id
int32 0
27.3k
| func
stringlengths 26
142k
| target
bool 2
classes | project
stringclasses 2
values | commit_id
stringlengths 40
40
| func_clean
stringlengths 26
131k
| vul_lines
dict | normalized_func
stringlengths 24
132k
| lines
sequencelengths 1
2.8k
| label
sequencelengths 1
2.8k
| line_no
sequencelengths 1
2.8k
|
---|---|---|---|---|---|---|---|---|---|---|
3,548 | int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
uint8_t *buf, int buf_size)
{
int size, i;
uint8_t *ppcm[4] = { 0 };
if (buf_size < DV_PROFILE_BYTES ||
!(c->sys = avpriv_dv_frame_profile(c->sys, buf, buf_size)) ||
buf_size < c->sys->frame_size) {
return -1; /* Broken frame, or not enough data */
}
/* Queueing audio packet */
/* FIXME: in case of no audio/bad audio we have to do something */
size = dv_extract_audio_info(c, buf);
for (i = 0; i < c->ach; i++) {
c->audio_pkt[i].size = size;
c->audio_pkt[i].pts = c->abytes * 30000 * 8 /
c->ast[i]->codec->bit_rate;
ppcm[i] = c->audio_buf[i];
}
if (c->ach)
dv_extract_audio(buf, ppcm, c->sys);
/* We work with 720p frames split in half, thus even frames have
* channels 0,1 and odd 2,3. */
if (c->sys->height == 720) {
if (buf[1] & 0x0C) {
c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
} else {
c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
c->abytes += size;
}
} else {
c->abytes += size;
}
/* Now it's time to return video packet */
size = dv_extract_video_info(c, buf);
av_init_packet(pkt);
pkt->data = buf;
pkt->size = size;
pkt->flags |= AV_PKT_FLAG_KEY;
pkt->stream_index = c->vst->index;
pkt->pts = c->frames;
c->frames++;
return size;
}
| true | FFmpeg | 7ee191cab0dc44700f26c5784e2adeb6a779651b | int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
uint8_t *buf, int buf_size)
{
int size, i;
uint8_t *ppcm[4] = { 0 };
if (buf_size < DV_PROFILE_BYTES ||
!(c->sys = avpriv_dv_frame_profile(c->sys, buf, buf_size)) ||
buf_size < c->sys->frame_size) {
return -1;
}
size = dv_extract_audio_info(c, buf);
for (i = 0; i < c->ach; i++) {
c->audio_pkt[i].size = size;
c->audio_pkt[i].pts = c->abytes * 30000 * 8 /
c->ast[i]->codec->bit_rate;
ppcm[i] = c->audio_buf[i];
}
if (c->ach)
dv_extract_audio(buf, ppcm, c->sys);
if (c->sys->height == 720) {
if (buf[1] & 0x0C) {
c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
} else {
c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
c->abytes += size;
}
} else {
c->abytes += size;
}
size = dv_extract_video_info(c, buf);
av_init_packet(pkt);
pkt->data = buf;
pkt->size = size;
pkt->flags |= AV_PKT_FLAG_KEY;
pkt->stream_index = c->vst->index;
pkt->pts = c->frames;
c->frames++;
return size;
}
| {
"code": [
" uint8_t *ppcm[4] = { 0 };"
],
"line_no": [
9
]
} | int FUNC_0(DVDemuxContext *VAR_0, AVPacket *VAR_1,
uint8_t *VAR_2, int VAR_3)
{
int VAR_4, VAR_5;
uint8_t *ppcm[4] = { 0 };
if (VAR_3 < DV_PROFILE_BYTES ||
!(VAR_0->sys = avpriv_dv_frame_profile(VAR_0->sys, VAR_2, VAR_3)) ||
VAR_3 < VAR_0->sys->frame_size) {
return -1;
}
VAR_4 = dv_extract_audio_info(VAR_0, VAR_2);
for (VAR_5 = 0; VAR_5 < VAR_0->ach; VAR_5++) {
VAR_0->audio_pkt[VAR_5].VAR_4 = VAR_4;
VAR_0->audio_pkt[VAR_5].pts = VAR_0->abytes * 30000 * 8 /
VAR_0->ast[VAR_5]->codec->bit_rate;
ppcm[VAR_5] = VAR_0->audio_buf[VAR_5];
}
if (VAR_0->ach)
dv_extract_audio(VAR_2, ppcm, VAR_0->sys);
if (VAR_0->sys->height == 720) {
if (VAR_2[1] & 0x0C) {
VAR_0->audio_pkt[2].VAR_4 = VAR_0->audio_pkt[3].VAR_4 = 0;
} else {
VAR_0->audio_pkt[0].VAR_4 = VAR_0->audio_pkt[1].VAR_4 = 0;
VAR_0->abytes += VAR_4;
}
} else {
VAR_0->abytes += VAR_4;
}
VAR_4 = dv_extract_video_info(VAR_0, VAR_2);
av_init_packet(VAR_1);
VAR_1->data = VAR_2;
VAR_1->VAR_4 = VAR_4;
VAR_1->flags |= AV_PKT_FLAG_KEY;
VAR_1->stream_index = VAR_0->vst->index;
VAR_1->pts = VAR_0->frames;
VAR_0->frames++;
return VAR_4;
}
| [
"int FUNC_0(DVDemuxContext *VAR_0, AVPacket *VAR_1,\nuint8_t *VAR_2, int VAR_3)\n{",
"int VAR_4, VAR_5;",
"uint8_t *ppcm[4] = { 0 };",
"if (VAR_3 < DV_PROFILE_BYTES ||\n!(VAR_0->sys = avpriv_dv_frame_profile(VAR_0->sys, VAR_2, VAR_3)) ||\nVAR_3 < VAR_0->sys->frame_size) {",
"return -1;",
"}",
"VAR_4 = dv_extract_audio_info(VAR_0, VAR_2);",
"for (VAR_5 = 0; VAR_5 < VAR_0->ach; VAR_5++) {",
"VAR_0->audio_pkt[VAR_5].VAR_4 = VAR_4;",
"VAR_0->audio_pkt[VAR_5].pts = VAR_0->abytes * 30000 * 8 /\nVAR_0->ast[VAR_5]->codec->bit_rate;",
"ppcm[VAR_5] = VAR_0->audio_buf[VAR_5];",
"}",
"if (VAR_0->ach)\ndv_extract_audio(VAR_2, ppcm, VAR_0->sys);",
"if (VAR_0->sys->height == 720) {",
"if (VAR_2[1] & 0x0C) {",
"VAR_0->audio_pkt[2].VAR_4 = VAR_0->audio_pkt[3].VAR_4 = 0;",
"} else {",
"VAR_0->audio_pkt[0].VAR_4 = VAR_0->audio_pkt[1].VAR_4 = 0;",
"VAR_0->abytes += VAR_4;",
"}",
"} else {",
"VAR_0->abytes += VAR_4;",
"}",
"VAR_4 = dv_extract_video_info(VAR_0, VAR_2);",
"av_init_packet(VAR_1);",
"VAR_1->data = VAR_2;",
"VAR_1->VAR_4 = VAR_4;",
"VAR_1->flags |= AV_PKT_FLAG_KEY;",
"VAR_1->stream_index = VAR_0->vst->index;",
"VAR_1->pts = VAR_0->frames;",
"VAR_0->frames++;",
"return VAR_4;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13,
15,
17
],
[
19
],
[
21
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43,
45
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
97
],
[
99
]
] |
3,549 | static void handle_event(int event)
{
static bool logged;
if (event & ~PVPANIC_PANICKED && !logged) {
qemu_log_mask(LOG_GUEST_ERROR, "pvpanic: unknown event %#x.\n", event);
logged = true;
}
if (event & PVPANIC_PANICKED) {
panicked_mon_event("pause");
vm_stop(RUN_STATE_GUEST_PANICKED);
return;
}
}
| true | qemu | 3a4496903795e05c1e8367bb4c9862d5670f48d7 | static void handle_event(int event)
{
static bool logged;
if (event & ~PVPANIC_PANICKED && !logged) {
qemu_log_mask(LOG_GUEST_ERROR, "pvpanic: unknown event %#x.\n", event);
logged = true;
}
if (event & PVPANIC_PANICKED) {
panicked_mon_event("pause");
vm_stop(RUN_STATE_GUEST_PANICKED);
return;
}
}
| {
"code": [
" panicked_mon_event(\"pause\");"
],
"line_no": [
21
]
} | static void FUNC_0(int VAR_0)
{
static bool VAR_1;
if (VAR_0 & ~PVPANIC_PANICKED && !VAR_1) {
qemu_log_mask(LOG_GUEST_ERROR, "pvpanic: unknown VAR_0 %#x.\n", VAR_0);
VAR_1 = true;
}
if (VAR_0 & PVPANIC_PANICKED) {
panicked_mon_event("pause");
vm_stop(RUN_STATE_GUEST_PANICKED);
return;
}
}
| [
"static void FUNC_0(int VAR_0)\n{",
"static bool VAR_1;",
"if (VAR_0 & ~PVPANIC_PANICKED && !VAR_1) {",
"qemu_log_mask(LOG_GUEST_ERROR, \"pvpanic: unknown VAR_0 %#x.\\n\", VAR_0);",
"VAR_1 = true;",
"}",
"if (VAR_0 & PVPANIC_PANICKED) {",
"panicked_mon_event(\"pause\");",
"vm_stop(RUN_STATE_GUEST_PANICKED);",
"return;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
3,550 | static void *iothread_run(void *opaque)
{
IOThread *iothread = opaque;
rcu_register_thread();
my_iothread = iothread;
qemu_mutex_lock(&iothread->init_done_lock);
iothread->thread_id = qemu_get_thread_id();
qemu_cond_signal(&iothread->init_done_cond);
qemu_mutex_unlock(&iothread->init_done_lock);
while (!atomic_read(&iothread->stopping)) {
aio_poll(iothread->ctx, true);
if (atomic_read(&iothread->worker_context)) {
GMainLoop *loop;
g_main_context_push_thread_default(iothread->worker_context);
iothread->main_loop =
g_main_loop_new(iothread->worker_context, TRUE);
loop = iothread->main_loop;
g_main_loop_run(iothread->main_loop);
iothread->main_loop = NULL;
g_main_loop_unref(loop);
g_main_context_pop_thread_default(iothread->worker_context);
}
}
rcu_unregister_thread();
return NULL;
}
| true | qemu | 2362a28ea11c145e1a13ae79342d76dc118a72a6 | static void *iothread_run(void *opaque)
{
IOThread *iothread = opaque;
rcu_register_thread();
my_iothread = iothread;
qemu_mutex_lock(&iothread->init_done_lock);
iothread->thread_id = qemu_get_thread_id();
qemu_cond_signal(&iothread->init_done_cond);
qemu_mutex_unlock(&iothread->init_done_lock);
while (!atomic_read(&iothread->stopping)) {
aio_poll(iothread->ctx, true);
if (atomic_read(&iothread->worker_context)) {
GMainLoop *loop;
g_main_context_push_thread_default(iothread->worker_context);
iothread->main_loop =
g_main_loop_new(iothread->worker_context, TRUE);
loop = iothread->main_loop;
g_main_loop_run(iothread->main_loop);
iothread->main_loop = NULL;
g_main_loop_unref(loop);
g_main_context_pop_thread_default(iothread->worker_context);
}
}
rcu_unregister_thread();
return NULL;
}
| {
"code": [
" while (!atomic_read(&iothread->stopping)) {"
],
"line_no": [
25
]
} | static void *FUNC_0(void *VAR_0)
{
IOThread *iothread = VAR_0;
rcu_register_thread();
my_iothread = iothread;
qemu_mutex_lock(&iothread->init_done_lock);
iothread->thread_id = qemu_get_thread_id();
qemu_cond_signal(&iothread->init_done_cond);
qemu_mutex_unlock(&iothread->init_done_lock);
while (!atomic_read(&iothread->stopping)) {
aio_poll(iothread->ctx, true);
if (atomic_read(&iothread->worker_context)) {
GMainLoop *loop;
g_main_context_push_thread_default(iothread->worker_context);
iothread->main_loop =
g_main_loop_new(iothread->worker_context, TRUE);
loop = iothread->main_loop;
g_main_loop_run(iothread->main_loop);
iothread->main_loop = NULL;
g_main_loop_unref(loop);
g_main_context_pop_thread_default(iothread->worker_context);
}
}
rcu_unregister_thread();
return NULL;
}
| [
"static void *FUNC_0(void *VAR_0)\n{",
"IOThread *iothread = VAR_0;",
"rcu_register_thread();",
"my_iothread = iothread;",
"qemu_mutex_lock(&iothread->init_done_lock);",
"iothread->thread_id = qemu_get_thread_id();",
"qemu_cond_signal(&iothread->init_done_cond);",
"qemu_mutex_unlock(&iothread->init_done_lock);",
"while (!atomic_read(&iothread->stopping)) {",
"aio_poll(iothread->ctx, true);",
"if (atomic_read(&iothread->worker_context)) {",
"GMainLoop *loop;",
"g_main_context_push_thread_default(iothread->worker_context);",
"iothread->main_loop =\ng_main_loop_new(iothread->worker_context, TRUE);",
"loop = iothread->main_loop;",
"g_main_loop_run(iothread->main_loop);",
"iothread->main_loop = NULL;",
"g_main_loop_unref(loop);",
"g_main_context_pop_thread_default(iothread->worker_context);",
"}",
"}",
"rcu_unregister_thread();",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39,
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
]
] |
3,552 | static void omap_rtc_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
{
struct omap_rtc_s *s = (struct omap_rtc_s *) opaque;
int offset = addr & OMAP_MPUI_REG_MASK;
struct tm new_tm;
time_t ti[2];
if (size != 1) {
return omap_badwidth_write8(opaque, addr, value);
}
switch (offset) {
case 0x00: /* SECONDS_REG */
#ifdef ALMDEBUG
printf("RTC SEC_REG <-- %02x\n", value);
#endif
s->ti -= s->current_tm.tm_sec;
s->ti += from_bcd(value);
return;
case 0x04: /* MINUTES_REG */
#ifdef ALMDEBUG
printf("RTC MIN_REG <-- %02x\n", value);
#endif
s->ti -= s->current_tm.tm_min * 60;
s->ti += from_bcd(value) * 60;
return;
case 0x08: /* HOURS_REG */
#ifdef ALMDEBUG
printf("RTC HRS_REG <-- %02x\n", value);
#endif
s->ti -= s->current_tm.tm_hour * 3600;
if (s->pm_am) {
s->ti += (from_bcd(value & 0x3f) & 12) * 3600;
s->ti += ((value >> 7) & 1) * 43200;
} else
s->ti += from_bcd(value & 0x3f) * 3600;
return;
case 0x0c: /* DAYS_REG */
#ifdef ALMDEBUG
printf("RTC DAY_REG <-- %02x\n", value);
#endif
s->ti -= s->current_tm.tm_mday * 86400;
s->ti += from_bcd(value) * 86400;
return;
case 0x10: /* MONTHS_REG */
#ifdef ALMDEBUG
printf("RTC MTH_REG <-- %02x\n", value);
#endif
memcpy(&new_tm, &s->current_tm, sizeof(new_tm));
new_tm.tm_mon = from_bcd(value);
ti[0] = mktimegm(&s->current_tm);
ti[1] = mktimegm(&new_tm);
if (ti[0] != -1 && ti[1] != -1) {
s->ti -= ti[0];
s->ti += ti[1];
} else {
/* A less accurate version */
s->ti -= s->current_tm.tm_mon * 2592000;
s->ti += from_bcd(value) * 2592000;
}
return;
case 0x14: /* YEARS_REG */
#ifdef ALMDEBUG
printf("RTC YRS_REG <-- %02x\n", value);
#endif
memcpy(&new_tm, &s->current_tm, sizeof(new_tm));
new_tm.tm_year += from_bcd(value) - (new_tm.tm_year % 100);
ti[0] = mktimegm(&s->current_tm);
ti[1] = mktimegm(&new_tm);
if (ti[0] != -1 && ti[1] != -1) {
s->ti -= ti[0];
s->ti += ti[1];
} else {
/* A less accurate version */
s->ti -= (s->current_tm.tm_year % 100) * 31536000;
s->ti += from_bcd(value) * 31536000;
}
return;
case 0x18: /* WEEK_REG */
return; /* Ignored */
case 0x20: /* ALARM_SECONDS_REG */
#ifdef ALMDEBUG
printf("ALM SEC_REG <-- %02x\n", value);
#endif
s->alarm_tm.tm_sec = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x24: /* ALARM_MINUTES_REG */
#ifdef ALMDEBUG
printf("ALM MIN_REG <-- %02x\n", value);
#endif
s->alarm_tm.tm_min = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x28: /* ALARM_HOURS_REG */
#ifdef ALMDEBUG
printf("ALM HRS_REG <-- %02x\n", value);
#endif
if (s->pm_am)
s->alarm_tm.tm_hour =
((from_bcd(value & 0x3f)) % 12) +
((value >> 7) & 1) * 12;
else
s->alarm_tm.tm_hour = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x2c: /* ALARM_DAYS_REG */
#ifdef ALMDEBUG
printf("ALM DAY_REG <-- %02x\n", value);
#endif
s->alarm_tm.tm_mday = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x30: /* ALARM_MONTHS_REG */
#ifdef ALMDEBUG
printf("ALM MON_REG <-- %02x\n", value);
#endif
s->alarm_tm.tm_mon = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x34: /* ALARM_YEARS_REG */
#ifdef ALMDEBUG
printf("ALM YRS_REG <-- %02x\n", value);
#endif
s->alarm_tm.tm_year = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x40: /* RTC_CTRL_REG */
#ifdef ALMDEBUG
printf("RTC CONTROL <-- %02x\n", value);
#endif
s->pm_am = (value >> 3) & 1;
s->auto_comp = (value >> 2) & 1;
s->round = (value >> 1) & 1;
s->running = value & 1;
s->status &= 0xfd;
s->status |= s->running << 1;
return;
case 0x44: /* RTC_STATUS_REG */
#ifdef ALMDEBUG
printf("RTC STATUSL <-- %02x\n", value);
#endif
s->status &= ~((value & 0xc0) ^ 0x80);
omap_rtc_interrupts_update(s);
return;
case 0x48: /* RTC_INTERRUPTS_REG */
#ifdef ALMDEBUG
printf("RTC INTRS <-- %02x\n", value);
#endif
s->interrupts = value;
return;
case 0x4c: /* RTC_COMP_LSB_REG */
#ifdef ALMDEBUG
printf("RTC COMPLSB <-- %02x\n", value);
#endif
s->comp_reg &= 0xff00;
s->comp_reg |= 0x00ff & value;
return;
case 0x50: /* RTC_COMP_MSB_REG */
#ifdef ALMDEBUG
printf("RTC COMPMSB <-- %02x\n", value);
#endif
s->comp_reg &= 0x00ff;
s->comp_reg |= 0xff00 & (value << 8);
return;
default:
OMAP_BAD_REG(addr);
return;
}
}
| true | qemu | 7e7e5858f83ae711b08d11e2268c6fc6f8385fb7 | static void omap_rtc_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
{
struct omap_rtc_s *s = (struct omap_rtc_s *) opaque;
int offset = addr & OMAP_MPUI_REG_MASK;
struct tm new_tm;
time_t ti[2];
if (size != 1) {
return omap_badwidth_write8(opaque, addr, value);
}
switch (offset) {
case 0x00:
#ifdef ALMDEBUG
printf("RTC SEC_REG <-- %02x\n", value);
#endif
s->ti -= s->current_tm.tm_sec;
s->ti += from_bcd(value);
return;
case 0x04:
#ifdef ALMDEBUG
printf("RTC MIN_REG <-- %02x\n", value);
#endif
s->ti -= s->current_tm.tm_min * 60;
s->ti += from_bcd(value) * 60;
return;
case 0x08:
#ifdef ALMDEBUG
printf("RTC HRS_REG <-- %02x\n", value);
#endif
s->ti -= s->current_tm.tm_hour * 3600;
if (s->pm_am) {
s->ti += (from_bcd(value & 0x3f) & 12) * 3600;
s->ti += ((value >> 7) & 1) * 43200;
} else
s->ti += from_bcd(value & 0x3f) * 3600;
return;
case 0x0c:
#ifdef ALMDEBUG
printf("RTC DAY_REG <-- %02x\n", value);
#endif
s->ti -= s->current_tm.tm_mday * 86400;
s->ti += from_bcd(value) * 86400;
return;
case 0x10:
#ifdef ALMDEBUG
printf("RTC MTH_REG <-- %02x\n", value);
#endif
memcpy(&new_tm, &s->current_tm, sizeof(new_tm));
new_tm.tm_mon = from_bcd(value);
ti[0] = mktimegm(&s->current_tm);
ti[1] = mktimegm(&new_tm);
if (ti[0] != -1 && ti[1] != -1) {
s->ti -= ti[0];
s->ti += ti[1];
} else {
s->ti -= s->current_tm.tm_mon * 2592000;
s->ti += from_bcd(value) * 2592000;
}
return;
case 0x14:
#ifdef ALMDEBUG
printf("RTC YRS_REG <-- %02x\n", value);
#endif
memcpy(&new_tm, &s->current_tm, sizeof(new_tm));
new_tm.tm_year += from_bcd(value) - (new_tm.tm_year % 100);
ti[0] = mktimegm(&s->current_tm);
ti[1] = mktimegm(&new_tm);
if (ti[0] != -1 && ti[1] != -1) {
s->ti -= ti[0];
s->ti += ti[1];
} else {
s->ti -= (s->current_tm.tm_year % 100) * 31536000;
s->ti += from_bcd(value) * 31536000;
}
return;
case 0x18:
return;
case 0x20:
#ifdef ALMDEBUG
printf("ALM SEC_REG <-- %02x\n", value);
#endif
s->alarm_tm.tm_sec = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x24:
#ifdef ALMDEBUG
printf("ALM MIN_REG <-- %02x\n", value);
#endif
s->alarm_tm.tm_min = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x28:
#ifdef ALMDEBUG
printf("ALM HRS_REG <-- %02x\n", value);
#endif
if (s->pm_am)
s->alarm_tm.tm_hour =
((from_bcd(value & 0x3f)) % 12) +
((value >> 7) & 1) * 12;
else
s->alarm_tm.tm_hour = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x2c:
#ifdef ALMDEBUG
printf("ALM DAY_REG <-- %02x\n", value);
#endif
s->alarm_tm.tm_mday = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x30:
#ifdef ALMDEBUG
printf("ALM MON_REG <-- %02x\n", value);
#endif
s->alarm_tm.tm_mon = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x34:
#ifdef ALMDEBUG
printf("ALM YRS_REG <-- %02x\n", value);
#endif
s->alarm_tm.tm_year = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x40:
#ifdef ALMDEBUG
printf("RTC CONTROL <-- %02x\n", value);
#endif
s->pm_am = (value >> 3) & 1;
s->auto_comp = (value >> 2) & 1;
s->round = (value >> 1) & 1;
s->running = value & 1;
s->status &= 0xfd;
s->status |= s->running << 1;
return;
case 0x44:
#ifdef ALMDEBUG
printf("RTC STATUSL <-- %02x\n", value);
#endif
s->status &= ~((value & 0xc0) ^ 0x80);
omap_rtc_interrupts_update(s);
return;
case 0x48:
#ifdef ALMDEBUG
printf("RTC INTRS <-- %02x\n", value);
#endif
s->interrupts = value;
return;
case 0x4c:
#ifdef ALMDEBUG
printf("RTC COMPLSB <-- %02x\n", value);
#endif
s->comp_reg &= 0xff00;
s->comp_reg |= 0x00ff & value;
return;
case 0x50:
#ifdef ALMDEBUG
printf("RTC COMPMSB <-- %02x\n", value);
#endif
s->comp_reg &= 0x00ff;
s->comp_reg |= 0xff00 & (value << 8);
return;
default:
OMAP_BAD_REG(addr);
return;
}
}
| {
"code": [
" s->ti -= (s->current_tm.tm_year % 100) * 31536000;",
" s->ti += from_bcd(value) * 31536000;"
],
"line_no": [
165,
167
]
} | static void FUNC_0(void *VAR_0, hwaddr VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
struct omap_rtc_s *VAR_4 = (struct omap_rtc_s *) VAR_0;
int VAR_5 = VAR_1 & OMAP_MPUI_REG_MASK;
struct tm VAR_6;
time_t ti[2];
if (VAR_3 != 1) {
return omap_badwidth_write8(VAR_0, VAR_1, VAR_2);
}
switch (VAR_5) {
case 0x00:
#ifdef ALMDEBUG
printf("RTC SEC_REG <-- %02x\n", VAR_2);
#endif
VAR_4->ti -= VAR_4->current_tm.tm_sec;
VAR_4->ti += from_bcd(VAR_2);
return;
case 0x04:
#ifdef ALMDEBUG
printf("RTC MIN_REG <-- %02x\n", VAR_2);
#endif
VAR_4->ti -= VAR_4->current_tm.tm_min * 60;
VAR_4->ti += from_bcd(VAR_2) * 60;
return;
case 0x08:
#ifdef ALMDEBUG
printf("RTC HRS_REG <-- %02x\n", VAR_2);
#endif
VAR_4->ti -= VAR_4->current_tm.tm_hour * 3600;
if (VAR_4->pm_am) {
VAR_4->ti += (from_bcd(VAR_2 & 0x3f) & 12) * 3600;
VAR_4->ti += ((VAR_2 >> 7) & 1) * 43200;
} else
VAR_4->ti += from_bcd(VAR_2 & 0x3f) * 3600;
return;
case 0x0c:
#ifdef ALMDEBUG
printf("RTC DAY_REG <-- %02x\n", VAR_2);
#endif
VAR_4->ti -= VAR_4->current_tm.tm_mday * 86400;
VAR_4->ti += from_bcd(VAR_2) * 86400;
return;
case 0x10:
#ifdef ALMDEBUG
printf("RTC MTH_REG <-- %02x\n", VAR_2);
#endif
memcpy(&VAR_6, &VAR_4->current_tm, sizeof(VAR_6));
VAR_6.tm_mon = from_bcd(VAR_2);
ti[0] = mktimegm(&VAR_4->current_tm);
ti[1] = mktimegm(&VAR_6);
if (ti[0] != -1 && ti[1] != -1) {
VAR_4->ti -= ti[0];
VAR_4->ti += ti[1];
} else {
VAR_4->ti -= VAR_4->current_tm.tm_mon * 2592000;
VAR_4->ti += from_bcd(VAR_2) * 2592000;
}
return;
case 0x14:
#ifdef ALMDEBUG
printf("RTC YRS_REG <-- %02x\n", VAR_2);
#endif
memcpy(&VAR_6, &VAR_4->current_tm, sizeof(VAR_6));
VAR_6.tm_year += from_bcd(VAR_2) - (VAR_6.tm_year % 100);
ti[0] = mktimegm(&VAR_4->current_tm);
ti[1] = mktimegm(&VAR_6);
if (ti[0] != -1 && ti[1] != -1) {
VAR_4->ti -= ti[0];
VAR_4->ti += ti[1];
} else {
VAR_4->ti -= (VAR_4->current_tm.tm_year % 100) * 31536000;
VAR_4->ti += from_bcd(VAR_2) * 31536000;
}
return;
case 0x18:
return;
case 0x20:
#ifdef ALMDEBUG
printf("ALM SEC_REG <-- %02x\n", VAR_2);
#endif
VAR_4->alarm_tm.tm_sec = from_bcd(VAR_2);
omap_rtc_alarm_update(VAR_4);
return;
case 0x24:
#ifdef ALMDEBUG
printf("ALM MIN_REG <-- %02x\n", VAR_2);
#endif
VAR_4->alarm_tm.tm_min = from_bcd(VAR_2);
omap_rtc_alarm_update(VAR_4);
return;
case 0x28:
#ifdef ALMDEBUG
printf("ALM HRS_REG <-- %02x\n", VAR_2);
#endif
if (VAR_4->pm_am)
VAR_4->alarm_tm.tm_hour =
((from_bcd(VAR_2 & 0x3f)) % 12) +
((VAR_2 >> 7) & 1) * 12;
else
VAR_4->alarm_tm.tm_hour = from_bcd(VAR_2);
omap_rtc_alarm_update(VAR_4);
return;
case 0x2c:
#ifdef ALMDEBUG
printf("ALM DAY_REG <-- %02x\n", VAR_2);
#endif
VAR_4->alarm_tm.tm_mday = from_bcd(VAR_2);
omap_rtc_alarm_update(VAR_4);
return;
case 0x30:
#ifdef ALMDEBUG
printf("ALM MON_REG <-- %02x\n", VAR_2);
#endif
VAR_4->alarm_tm.tm_mon = from_bcd(VAR_2);
omap_rtc_alarm_update(VAR_4);
return;
case 0x34:
#ifdef ALMDEBUG
printf("ALM YRS_REG <-- %02x\n", VAR_2);
#endif
VAR_4->alarm_tm.tm_year = from_bcd(VAR_2);
omap_rtc_alarm_update(VAR_4);
return;
case 0x40:
#ifdef ALMDEBUG
printf("RTC CONTROL <-- %02x\n", VAR_2);
#endif
VAR_4->pm_am = (VAR_2 >> 3) & 1;
VAR_4->auto_comp = (VAR_2 >> 2) & 1;
VAR_4->round = (VAR_2 >> 1) & 1;
VAR_4->running = VAR_2 & 1;
VAR_4->status &= 0xfd;
VAR_4->status |= VAR_4->running << 1;
return;
case 0x44:
#ifdef ALMDEBUG
printf("RTC STATUSL <-- %02x\n", VAR_2);
#endif
VAR_4->status &= ~((VAR_2 & 0xc0) ^ 0x80);
omap_rtc_interrupts_update(VAR_4);
return;
case 0x48:
#ifdef ALMDEBUG
printf("RTC INTRS <-- %02x\n", VAR_2);
#endif
VAR_4->interrupts = VAR_2;
return;
case 0x4c:
#ifdef ALMDEBUG
printf("RTC COMPLSB <-- %02x\n", VAR_2);
#endif
VAR_4->comp_reg &= 0xff00;
VAR_4->comp_reg |= 0x00ff & VAR_2;
return;
case 0x50:
#ifdef ALMDEBUG
printf("RTC COMPMSB <-- %02x\n", VAR_2);
#endif
VAR_4->comp_reg &= 0x00ff;
VAR_4->comp_reg |= 0xff00 & (VAR_2 << 8);
return;
default:
OMAP_BAD_REG(VAR_1);
return;
}
}
| [
"static void FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"struct omap_rtc_s *VAR_4 = (struct omap_rtc_s *) VAR_0;",
"int VAR_5 = VAR_1 & OMAP_MPUI_REG_MASK;",
"struct tm VAR_6;",
"time_t ti[2];",
"if (VAR_3 != 1) {",
"return omap_badwidth_write8(VAR_0, VAR_1, VAR_2);",
"}",
"switch (VAR_5) {",
"case 0x00:\n#ifdef ALMDEBUG\nprintf(\"RTC SEC_REG <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->ti -= VAR_4->current_tm.tm_sec;",
"VAR_4->ti += from_bcd(VAR_2);",
"return;",
"case 0x04:\n#ifdef ALMDEBUG\nprintf(\"RTC MIN_REG <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->ti -= VAR_4->current_tm.tm_min * 60;",
"VAR_4->ti += from_bcd(VAR_2) * 60;",
"return;",
"case 0x08:\n#ifdef ALMDEBUG\nprintf(\"RTC HRS_REG <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->ti -= VAR_4->current_tm.tm_hour * 3600;",
"if (VAR_4->pm_am) {",
"VAR_4->ti += (from_bcd(VAR_2 & 0x3f) & 12) * 3600;",
"VAR_4->ti += ((VAR_2 >> 7) & 1) * 43200;",
"} else",
"VAR_4->ti += from_bcd(VAR_2 & 0x3f) * 3600;",
"return;",
"case 0x0c:\n#ifdef ALMDEBUG\nprintf(\"RTC DAY_REG <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->ti -= VAR_4->current_tm.tm_mday * 86400;",
"VAR_4->ti += from_bcd(VAR_2) * 86400;",
"return;",
"case 0x10:\n#ifdef ALMDEBUG\nprintf(\"RTC MTH_REG <-- %02x\\n\", VAR_2);",
"#endif\nmemcpy(&VAR_6, &VAR_4->current_tm, sizeof(VAR_6));",
"VAR_6.tm_mon = from_bcd(VAR_2);",
"ti[0] = mktimegm(&VAR_4->current_tm);",
"ti[1] = mktimegm(&VAR_6);",
"if (ti[0] != -1 && ti[1] != -1) {",
"VAR_4->ti -= ti[0];",
"VAR_4->ti += ti[1];",
"} else {",
"VAR_4->ti -= VAR_4->current_tm.tm_mon * 2592000;",
"VAR_4->ti += from_bcd(VAR_2) * 2592000;",
"}",
"return;",
"case 0x14:\n#ifdef ALMDEBUG\nprintf(\"RTC YRS_REG <-- %02x\\n\", VAR_2);",
"#endif\nmemcpy(&VAR_6, &VAR_4->current_tm, sizeof(VAR_6));",
"VAR_6.tm_year += from_bcd(VAR_2) - (VAR_6.tm_year % 100);",
"ti[0] = mktimegm(&VAR_4->current_tm);",
"ti[1] = mktimegm(&VAR_6);",
"if (ti[0] != -1 && ti[1] != -1) {",
"VAR_4->ti -= ti[0];",
"VAR_4->ti += ti[1];",
"} else {",
"VAR_4->ti -= (VAR_4->current_tm.tm_year % 100) * 31536000;",
"VAR_4->ti += from_bcd(VAR_2) * 31536000;",
"}",
"return;",
"case 0x18:\nreturn;",
"case 0x20:\n#ifdef ALMDEBUG\nprintf(\"ALM SEC_REG <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->alarm_tm.tm_sec = from_bcd(VAR_2);",
"omap_rtc_alarm_update(VAR_4);",
"return;",
"case 0x24:\n#ifdef ALMDEBUG\nprintf(\"ALM MIN_REG <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->alarm_tm.tm_min = from_bcd(VAR_2);",
"omap_rtc_alarm_update(VAR_4);",
"return;",
"case 0x28:\n#ifdef ALMDEBUG\nprintf(\"ALM HRS_REG <-- %02x\\n\", VAR_2);",
"#endif\nif (VAR_4->pm_am)\nVAR_4->alarm_tm.tm_hour =\n((from_bcd(VAR_2 & 0x3f)) % 12) +\n((VAR_2 >> 7) & 1) * 12;",
"else\nVAR_4->alarm_tm.tm_hour = from_bcd(VAR_2);",
"omap_rtc_alarm_update(VAR_4);",
"return;",
"case 0x2c:\n#ifdef ALMDEBUG\nprintf(\"ALM DAY_REG <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->alarm_tm.tm_mday = from_bcd(VAR_2);",
"omap_rtc_alarm_update(VAR_4);",
"return;",
"case 0x30:\n#ifdef ALMDEBUG\nprintf(\"ALM MON_REG <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->alarm_tm.tm_mon = from_bcd(VAR_2);",
"omap_rtc_alarm_update(VAR_4);",
"return;",
"case 0x34:\n#ifdef ALMDEBUG\nprintf(\"ALM YRS_REG <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->alarm_tm.tm_year = from_bcd(VAR_2);",
"omap_rtc_alarm_update(VAR_4);",
"return;",
"case 0x40:\n#ifdef ALMDEBUG\nprintf(\"RTC CONTROL <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->pm_am = (VAR_2 >> 3) & 1;",
"VAR_4->auto_comp = (VAR_2 >> 2) & 1;",
"VAR_4->round = (VAR_2 >> 1) & 1;",
"VAR_4->running = VAR_2 & 1;",
"VAR_4->status &= 0xfd;",
"VAR_4->status |= VAR_4->running << 1;",
"return;",
"case 0x44:\n#ifdef ALMDEBUG\nprintf(\"RTC STATUSL <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->status &= ~((VAR_2 & 0xc0) ^ 0x80);",
"omap_rtc_interrupts_update(VAR_4);",
"return;",
"case 0x48:\n#ifdef ALMDEBUG\nprintf(\"RTC INTRS <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->interrupts = VAR_2;",
"return;",
"case 0x4c:\n#ifdef ALMDEBUG\nprintf(\"RTC COMPLSB <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->comp_reg &= 0xff00;",
"VAR_4->comp_reg |= 0x00ff & VAR_2;",
"return;",
"case 0x50:\n#ifdef ALMDEBUG\nprintf(\"RTC COMPMSB <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->comp_reg &= 0x00ff;",
"VAR_4->comp_reg |= 0xff00 & (VAR_2 << 8);",
"return;",
"default:\nOMAP_BAD_REG(VAR_1);",
"return;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
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,
51
],
[
53
],
[
55
],
[
59,
61,
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83,
85,
87
],
[
89,
91
],
[
93
],
[
95
],
[
99,
101,
103
],
[
105,
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137,
139,
141
],
[
143,
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175,
177
],
[
181,
183,
185
],
[
187,
189
],
[
191
],
[
193
],
[
197,
199,
201
],
[
203,
205
],
[
207
],
[
209
],
[
213,
215,
217
],
[
219,
221,
223,
225,
227
],
[
229,
231
],
[
233
],
[
235
],
[
239,
241,
243
],
[
245,
247
],
[
249
],
[
251
],
[
255,
257,
259
],
[
261,
263
],
[
265
],
[
267
],
[
271,
273,
275
],
[
277,
279
],
[
281
],
[
283
],
[
287,
289,
291
],
[
293,
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
311,
313,
315
],
[
317,
319
],
[
321
],
[
323
],
[
327,
329,
331
],
[
333,
335
],
[
337
],
[
341,
343,
345
],
[
347,
349
],
[
351
],
[
353
],
[
357,
359,
361
],
[
363,
365
],
[
367
],
[
369
],
[
373,
375
],
[
377
],
[
379
],
[
381
]
] |
3,553 | static void neon_store_reg(int reg, int pass, TCGv var)
{
tcg_gen_st_i32(var, cpu_env, neon_reg_offset(reg, pass));
dead_tmp(var);
}
| true | qemu | 7d1b0095bff7157e856d1d0e6c4295641ced2752 | static void neon_store_reg(int reg, int pass, TCGv var)
{
tcg_gen_st_i32(var, cpu_env, neon_reg_offset(reg, pass));
dead_tmp(var);
}
| {
"code": [
" dead_tmp(var);",
" dead_tmp(var);",
" dead_tmp(var);",
" dead_tmp(var);",
" dead_tmp(var);"
],
"line_no": [
7,
7,
7,
7,
7
]
} | static void FUNC_0(int VAR_0, int VAR_1, TCGv VAR_2)
{
tcg_gen_st_i32(VAR_2, cpu_env, neon_reg_offset(VAR_0, VAR_1));
dead_tmp(VAR_2);
}
| [
"static void FUNC_0(int VAR_0, int VAR_1, TCGv VAR_2)\n{",
"tcg_gen_st_i32(VAR_2, cpu_env, neon_reg_offset(VAR_0, VAR_1));",
"dead_tmp(VAR_2);",
"}"
] | [
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
3,554 | static target_ulong disas_insn(DisasContext *s, target_ulong pc_start)
{
int b, prefixes, aflag, dflag;
int shift, ot;
int modrm, reg, rm, mod, reg_addr, op, opreg, offset_addr, val;
target_ulong next_eip, tval;
int rex_w, rex_r;
if (unlikely(loglevel & CPU_LOG_TB_OP))
tcg_gen_debug_insn_start(pc_start);
s->pc = pc_start;
prefixes = 0;
aflag = s->code32;
dflag = s->code32;
s->override = -1;
rex_w = -1;
rex_r = 0;
#ifdef TARGET_X86_64
s->rex_x = 0;
s->rex_b = 0;
x86_64_hregs = 0;
#endif
s->rip_offset = 0; /* for relative ip address */
next_byte:
b = ldub_code(s->pc);
s->pc++;
/* check prefixes */
#ifdef TARGET_X86_64
if (CODE64(s)) {
switch (b) {
case 0xf3:
prefixes |= PREFIX_REPZ;
goto next_byte;
case 0xf2:
prefixes |= PREFIX_REPNZ;
goto next_byte;
case 0xf0:
prefixes |= PREFIX_LOCK;
goto next_byte;
case 0x2e:
s->override = R_CS;
goto next_byte;
case 0x36:
s->override = R_SS;
goto next_byte;
case 0x3e:
s->override = R_DS;
goto next_byte;
case 0x26:
s->override = R_ES;
goto next_byte;
case 0x64:
s->override = R_FS;
goto next_byte;
case 0x65:
s->override = R_GS;
goto next_byte;
case 0x66:
prefixes |= PREFIX_DATA;
goto next_byte;
case 0x67:
prefixes |= PREFIX_ADR;
goto next_byte;
case 0x40 ... 0x4f:
/* REX prefix */
rex_w = (b >> 3) & 1;
rex_r = (b & 0x4) << 1;
s->rex_x = (b & 0x2) << 2;
REX_B(s) = (b & 0x1) << 3;
x86_64_hregs = 1; /* select uniform byte register addressing */
goto next_byte;
}
if (rex_w == 1) {
/* 0x66 is ignored if rex.w is set */
dflag = 2;
} else {
if (prefixes & PREFIX_DATA)
dflag ^= 1;
}
if (!(prefixes & PREFIX_ADR))
aflag = 2;
} else
#endif
{
switch (b) {
case 0xf3:
prefixes |= PREFIX_REPZ;
goto next_byte;
case 0xf2:
prefixes |= PREFIX_REPNZ;
goto next_byte;
case 0xf0:
prefixes |= PREFIX_LOCK;
goto next_byte;
case 0x2e:
s->override = R_CS;
goto next_byte;
case 0x36:
s->override = R_SS;
goto next_byte;
case 0x3e:
s->override = R_DS;
goto next_byte;
case 0x26:
s->override = R_ES;
goto next_byte;
case 0x64:
s->override = R_FS;
goto next_byte;
case 0x65:
s->override = R_GS;
goto next_byte;
case 0x66:
prefixes |= PREFIX_DATA;
goto next_byte;
case 0x67:
prefixes |= PREFIX_ADR;
goto next_byte;
}
if (prefixes & PREFIX_DATA)
dflag ^= 1;
if (prefixes & PREFIX_ADR)
aflag ^= 1;
}
s->prefix = prefixes;
s->aflag = aflag;
s->dflag = dflag;
/* lock generation */
if (prefixes & PREFIX_LOCK)
gen_helper_lock();
/* now check op code */
reswitch:
switch(b) {
case 0x0f:
/**************************/
/* extended op code */
b = ldub_code(s->pc++) | 0x100;
goto reswitch;
/**************************/
/* arith & logic */
case 0x00 ... 0x05:
case 0x08 ... 0x0d:
case 0x10 ... 0x15:
case 0x18 ... 0x1d:
case 0x20 ... 0x25:
case 0x28 ... 0x2d:
case 0x30 ... 0x35:
case 0x38 ... 0x3d:
{
int op, f, val;
op = (b >> 3) & 7;
f = (b >> 1) & 3;
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
switch(f) {
case 0: /* OP Ev, Gv */
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
opreg = OR_TMP0;
} else if (op == OP_XORL && rm == reg) {
xor_zero:
/* xor reg, reg optimisation */
gen_op_movl_T0_0();
s->cc_op = CC_OP_LOGICB + ot;
gen_op_mov_reg_T0(ot, reg);
gen_op_update1_cc();
break;
} else {
opreg = rm;
}
gen_op_mov_TN_reg(ot, 1, reg);
gen_op(s, op, ot, opreg);
break;
case 1: /* OP Gv, Ev */
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
reg = ((modrm >> 3) & 7) | rex_r;
rm = (modrm & 7) | REX_B(s);
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T1_A0(ot + s->mem_index);
} else if (op == OP_XORL && rm == reg) {
goto xor_zero;
} else {
gen_op_mov_TN_reg(ot, 1, rm);
}
gen_op(s, op, ot, reg);
break;
case 2: /* OP A, Iv */
val = insn_get(s, ot);
gen_op_movl_T1_im(val);
gen_op(s, op, ot, OR_EAX);
break;
}
}
break;
case 0x82:
if (CODE64(s))
goto illegal_op;
case 0x80: /* GRP1 */
case 0x81:
case 0x83:
{
int val;
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
op = (modrm >> 3) & 7;
if (mod != 3) {
if (b == 0x83)
s->rip_offset = 1;
else
s->rip_offset = insn_const_size(ot);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
opreg = OR_TMP0;
} else {
opreg = rm;
}
switch(b) {
default:
case 0x80:
case 0x81:
case 0x82:
val = insn_get(s, ot);
break;
case 0x83:
val = (int8_t)insn_get(s, OT_BYTE);
break;
}
gen_op_movl_T1_im(val);
gen_op(s, op, ot, opreg);
}
break;
/**************************/
/* inc, dec, and other misc arith */
case 0x40 ... 0x47: /* inc Gv */
ot = dflag ? OT_LONG : OT_WORD;
gen_inc(s, ot, OR_EAX + (b & 7), 1);
break;
case 0x48 ... 0x4f: /* dec Gv */
ot = dflag ? OT_LONG : OT_WORD;
gen_inc(s, ot, OR_EAX + (b & 7), -1);
break;
case 0xf6: /* GRP3 */
case 0xf7:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
op = (modrm >> 3) & 7;
if (mod != 3) {
if (op == 0)
s->rip_offset = insn_const_size(ot);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T0_A0(ot + s->mem_index);
} else {
gen_op_mov_TN_reg(ot, 0, rm);
}
switch(op) {
case 0: /* test */
val = insn_get(s, ot);
gen_op_movl_T1_im(val);
gen_op_testl_T0_T1_cc();
s->cc_op = CC_OP_LOGICB + ot;
break;
case 2: /* not */
tcg_gen_not_tl(cpu_T[0], cpu_T[0]);
if (mod != 3) {
gen_op_st_T0_A0(ot + s->mem_index);
} else {
gen_op_mov_reg_T0(ot, rm);
}
break;
case 3: /* neg */
tcg_gen_neg_tl(cpu_T[0], cpu_T[0]);
if (mod != 3) {
gen_op_st_T0_A0(ot + s->mem_index);
} else {
gen_op_mov_reg_T0(ot, rm);
}
gen_op_update_neg_cc();
s->cc_op = CC_OP_SUBB + ot;
break;
case 4: /* mul */
switch(ot) {
case OT_BYTE:
gen_op_mov_TN_reg(OT_BYTE, 1, R_EAX);
tcg_gen_ext8u_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext8u_tl(cpu_T[1], cpu_T[1]);
/* XXX: use 32 bit mul which could be faster */
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_andi_tl(cpu_cc_src, cpu_T[0], 0xff00);
s->cc_op = CC_OP_MULB;
break;
case OT_WORD:
gen_op_mov_TN_reg(OT_WORD, 1, R_EAX);
tcg_gen_ext16u_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext16u_tl(cpu_T[1], cpu_T[1]);
/* XXX: use 32 bit mul which could be faster */
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_shri_tl(cpu_T[0], cpu_T[0], 16);
gen_op_mov_reg_T0(OT_WORD, R_EDX);
tcg_gen_mov_tl(cpu_cc_src, cpu_T[0]);
s->cc_op = CC_OP_MULW;
break;
default:
case OT_LONG:
#ifdef TARGET_X86_64
gen_op_mov_TN_reg(OT_LONG, 1, R_EAX);
tcg_gen_ext32u_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext32u_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_LONG, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_shri_tl(cpu_T[0], cpu_T[0], 32);
gen_op_mov_reg_T0(OT_LONG, R_EDX);
tcg_gen_mov_tl(cpu_cc_src, cpu_T[0]);
#else
{
TCGv_i64 t0, t1;
t0 = tcg_temp_new_i64();
t1 = tcg_temp_new_i64();
gen_op_mov_TN_reg(OT_LONG, 1, R_EAX);
tcg_gen_extu_i32_i64(t0, cpu_T[0]);
tcg_gen_extu_i32_i64(t1, cpu_T[1]);
tcg_gen_mul_i64(t0, t0, t1);
tcg_gen_trunc_i64_i32(cpu_T[0], t0);
gen_op_mov_reg_T0(OT_LONG, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_shri_i64(t0, t0, 32);
tcg_gen_trunc_i64_i32(cpu_T[0], t0);
gen_op_mov_reg_T0(OT_LONG, R_EDX);
tcg_gen_mov_tl(cpu_cc_src, cpu_T[0]);
}
#endif
s->cc_op = CC_OP_MULL;
break;
#ifdef TARGET_X86_64
case OT_QUAD:
gen_helper_mulq_EAX_T0(cpu_T[0]);
s->cc_op = CC_OP_MULQ;
break;
#endif
}
break;
case 5: /* imul */
switch(ot) {
case OT_BYTE:
gen_op_mov_TN_reg(OT_BYTE, 1, R_EAX);
tcg_gen_ext8s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext8s_tl(cpu_T[1], cpu_T[1]);
/* XXX: use 32 bit mul which could be faster */
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_ext8s_tl(cpu_tmp0, cpu_T[0]);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
s->cc_op = CC_OP_MULB;
break;
case OT_WORD:
gen_op_mov_TN_reg(OT_WORD, 1, R_EAX);
tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext16s_tl(cpu_T[1], cpu_T[1]);
/* XXX: use 32 bit mul which could be faster */
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_ext16s_tl(cpu_tmp0, cpu_T[0]);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
tcg_gen_shri_tl(cpu_T[0], cpu_T[0], 16);
gen_op_mov_reg_T0(OT_WORD, R_EDX);
s->cc_op = CC_OP_MULW;
break;
default:
case OT_LONG:
#ifdef TARGET_X86_64
gen_op_mov_TN_reg(OT_LONG, 1, R_EAX);
tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext32s_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_LONG, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_ext32s_tl(cpu_tmp0, cpu_T[0]);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
tcg_gen_shri_tl(cpu_T[0], cpu_T[0], 32);
gen_op_mov_reg_T0(OT_LONG, R_EDX);
#else
{
TCGv_i64 t0, t1;
t0 = tcg_temp_new_i64();
t1 = tcg_temp_new_i64();
gen_op_mov_TN_reg(OT_LONG, 1, R_EAX);
tcg_gen_ext_i32_i64(t0, cpu_T[0]);
tcg_gen_ext_i32_i64(t1, cpu_T[1]);
tcg_gen_mul_i64(t0, t0, t1);
tcg_gen_trunc_i64_i32(cpu_T[0], t0);
gen_op_mov_reg_T0(OT_LONG, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_sari_tl(cpu_tmp0, cpu_T[0], 31);
tcg_gen_shri_i64(t0, t0, 32);
tcg_gen_trunc_i64_i32(cpu_T[0], t0);
gen_op_mov_reg_T0(OT_LONG, R_EDX);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
}
#endif
s->cc_op = CC_OP_MULL;
break;
#ifdef TARGET_X86_64
case OT_QUAD:
gen_helper_imulq_EAX_T0(cpu_T[0]);
s->cc_op = CC_OP_MULQ;
break;
#endif
}
break;
case 6: /* div */
switch(ot) {
case OT_BYTE:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_divb_AL(cpu_T[0]);
break;
case OT_WORD:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_divw_AX(cpu_T[0]);
break;
default:
case OT_LONG:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_divl_EAX(cpu_T[0]);
break;
#ifdef TARGET_X86_64
case OT_QUAD:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_divq_EAX(cpu_T[0]);
break;
#endif
}
break;
case 7: /* idiv */
switch(ot) {
case OT_BYTE:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_idivb_AL(cpu_T[0]);
break;
case OT_WORD:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_idivw_AX(cpu_T[0]);
break;
default:
case OT_LONG:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_idivl_EAX(cpu_T[0]);
break;
#ifdef TARGET_X86_64
case OT_QUAD:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_idivq_EAX(cpu_T[0]);
break;
#endif
}
break;
default:
goto illegal_op;
}
break;
case 0xfe: /* GRP4 */
case 0xff: /* GRP5 */
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
op = (modrm >> 3) & 7;
if (op >= 2 && b == 0xfe) {
goto illegal_op;
}
if (CODE64(s)) {
if (op == 2 || op == 4) {
/* operand size for jumps is 64 bit */
ot = OT_QUAD;
} else if (op == 3 || op == 5) {
/* for call calls, the operand is 16 or 32 bit, even
in long mode */
ot = dflag ? OT_LONG : OT_WORD;
} else if (op == 6) {
/* default push size is 64 bit */
ot = dflag ? OT_QUAD : OT_WORD;
}
}
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (op >= 2 && op != 3 && op != 5)
gen_op_ld_T0_A0(ot + s->mem_index);
} else {
gen_op_mov_TN_reg(ot, 0, rm);
}
switch(op) {
case 0: /* inc Ev */
if (mod != 3)
opreg = OR_TMP0;
else
opreg = rm;
gen_inc(s, ot, opreg, 1);
break;
case 1: /* dec Ev */
if (mod != 3)
opreg = OR_TMP0;
else
opreg = rm;
gen_inc(s, ot, opreg, -1);
break;
case 2: /* call Ev */
/* XXX: optimize if memory (no 'and' is necessary) */
if (s->dflag == 0)
gen_op_andl_T0_ffff();
next_eip = s->pc - s->cs_base;
gen_movtl_T1_im(next_eip);
gen_push_T1(s);
gen_op_jmp_T0();
gen_eob(s);
break;
case 3: /* lcall Ev */
gen_op_ld_T1_A0(ot + s->mem_index);
gen_add_A0_im(s, 1 << (ot - OT_WORD + 1));
gen_op_ldu_T0_A0(OT_WORD + s->mem_index);
do_lcall:
if (s->pe && !s->vm86) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_lcall_protected(cpu_tmp2_i32, cpu_T[1],
tcg_const_i32(dflag),
tcg_const_i32(s->pc - pc_start));
} else {
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_lcall_real(cpu_tmp2_i32, cpu_T[1],
tcg_const_i32(dflag),
tcg_const_i32(s->pc - s->cs_base));
}
gen_eob(s);
break;
case 4: /* jmp Ev */
if (s->dflag == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
gen_eob(s);
break;
case 5: /* ljmp Ev */
gen_op_ld_T1_A0(ot + s->mem_index);
gen_add_A0_im(s, 1 << (ot - OT_WORD + 1));
gen_op_ldu_T0_A0(OT_WORD + s->mem_index);
do_ljmp:
if (s->pe && !s->vm86) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_ljmp_protected(cpu_tmp2_i32, cpu_T[1],
tcg_const_i32(s->pc - pc_start));
} else {
gen_op_movl_seg_T0_vm(R_CS);
gen_op_movl_T0_T1();
gen_op_jmp_T0();
}
gen_eob(s);
break;
case 6: /* push Ev */
gen_push_T0(s);
break;
default:
goto illegal_op;
}
break;
case 0x84: /* test Ev, Gv */
case 0x85:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
reg = ((modrm >> 3) & 7) | rex_r;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
gen_op_mov_TN_reg(ot, 1, reg);
gen_op_testl_T0_T1_cc();
s->cc_op = CC_OP_LOGICB + ot;
break;
case 0xa8: /* test eAX, Iv */
case 0xa9:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
val = insn_get(s, ot);
gen_op_mov_TN_reg(ot, 0, OR_EAX);
gen_op_movl_T1_im(val);
gen_op_testl_T0_T1_cc();
s->cc_op = CC_OP_LOGICB + ot;
break;
case 0x98: /* CWDE/CBW */
#ifdef TARGET_X86_64
if (dflag == 2) {
gen_op_mov_TN_reg(OT_LONG, 0, R_EAX);
tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_QUAD, R_EAX);
} else
#endif
if (dflag == 1) {
gen_op_mov_TN_reg(OT_WORD, 0, R_EAX);
tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_LONG, R_EAX);
} else {
gen_op_mov_TN_reg(OT_BYTE, 0, R_EAX);
tcg_gen_ext8s_tl(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
}
break;
case 0x99: /* CDQ/CWD */
#ifdef TARGET_X86_64
if (dflag == 2) {
gen_op_mov_TN_reg(OT_QUAD, 0, R_EAX);
tcg_gen_sari_tl(cpu_T[0], cpu_T[0], 63);
gen_op_mov_reg_T0(OT_QUAD, R_EDX);
} else
#endif
if (dflag == 1) {
gen_op_mov_TN_reg(OT_LONG, 0, R_EAX);
tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_sari_tl(cpu_T[0], cpu_T[0], 31);
gen_op_mov_reg_T0(OT_LONG, R_EDX);
} else {
gen_op_mov_TN_reg(OT_WORD, 0, R_EAX);
tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_sari_tl(cpu_T[0], cpu_T[0], 15);
gen_op_mov_reg_T0(OT_WORD, R_EDX);
}
break;
case 0x1af: /* imul Gv, Ev */
case 0x69: /* imul Gv, Ev, I */
case 0x6b:
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
if (b == 0x69)
s->rip_offset = insn_const_size(ot);
else if (b == 0x6b)
s->rip_offset = 1;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
if (b == 0x69) {
val = insn_get(s, ot);
gen_op_movl_T1_im(val);
} else if (b == 0x6b) {
val = (int8_t)insn_get(s, OT_BYTE);
gen_op_movl_T1_im(val);
} else {
gen_op_mov_TN_reg(ot, 1, reg);
}
#ifdef TARGET_X86_64
if (ot == OT_QUAD) {
gen_helper_imulq_T0_T1(cpu_T[0], cpu_T[0], cpu_T[1]);
} else
#endif
if (ot == OT_LONG) {
#ifdef TARGET_X86_64
tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext32s_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_ext32s_tl(cpu_tmp0, cpu_T[0]);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
#else
{
TCGv_i64 t0, t1;
t0 = tcg_temp_new_i64();
t1 = tcg_temp_new_i64();
tcg_gen_ext_i32_i64(t0, cpu_T[0]);
tcg_gen_ext_i32_i64(t1, cpu_T[1]);
tcg_gen_mul_i64(t0, t0, t1);
tcg_gen_trunc_i64_i32(cpu_T[0], t0);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_sari_tl(cpu_tmp0, cpu_T[0], 31);
tcg_gen_shri_i64(t0, t0, 32);
tcg_gen_trunc_i64_i32(cpu_T[1], t0);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[1], cpu_tmp0);
}
#endif
} else {
tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext16s_tl(cpu_T[1], cpu_T[1]);
/* XXX: use 32 bit mul which could be faster */
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_ext16s_tl(cpu_tmp0, cpu_T[0]);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
}
gen_op_mov_reg_T0(ot, reg);
s->cc_op = CC_OP_MULB + ot;
break;
case 0x1c0:
case 0x1c1: /* xadd Ev, Gv */
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
if (mod == 3) {
rm = (modrm & 7) | REX_B(s);
gen_op_mov_TN_reg(ot, 0, reg);
gen_op_mov_TN_reg(ot, 1, rm);
gen_op_addl_T0_T1();
gen_op_mov_reg_T1(ot, reg);
gen_op_mov_reg_T0(ot, rm);
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_mov_TN_reg(ot, 0, reg);
gen_op_ld_T1_A0(ot + s->mem_index);
gen_op_addl_T0_T1();
gen_op_st_T0_A0(ot + s->mem_index);
gen_op_mov_reg_T1(ot, reg);
}
gen_op_update2_cc();
s->cc_op = CC_OP_ADDB + ot;
break;
case 0x1b0:
case 0x1b1: /* cmpxchg Ev, Gv */
{
int label1, label2;
TCGv t0, t1, t2, a0;
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
t0 = tcg_temp_local_new();
t1 = tcg_temp_local_new();
t2 = tcg_temp_local_new();
a0 = tcg_temp_local_new();
gen_op_mov_v_reg(ot, t1, reg);
if (mod == 3) {
rm = (modrm & 7) | REX_B(s);
gen_op_mov_v_reg(ot, t0, rm);
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
tcg_gen_mov_tl(a0, cpu_A0);
gen_op_ld_v(ot + s->mem_index, t0, a0);
rm = 0; /* avoid warning */
}
label1 = gen_new_label();
tcg_gen_ld_tl(t2, cpu_env, offsetof(CPUState, regs[R_EAX]));
tcg_gen_sub_tl(t2, t2, t0);
gen_extu(ot, t2);
tcg_gen_brcondi_tl(TCG_COND_EQ, t2, 0, label1);
if (mod == 3) {
label2 = gen_new_label();
gen_op_mov_reg_v(ot, R_EAX, t0);
tcg_gen_br(label2);
gen_set_label(label1);
gen_op_mov_reg_v(ot, rm, t1);
gen_set_label(label2);
} else {
tcg_gen_mov_tl(t1, t0);
gen_op_mov_reg_v(ot, R_EAX, t0);
gen_set_label(label1);
/* always store */
gen_op_st_v(ot + s->mem_index, t1, a0);
}
tcg_gen_mov_tl(cpu_cc_src, t0);
tcg_gen_mov_tl(cpu_cc_dst, t2);
s->cc_op = CC_OP_SUBB + ot;
tcg_temp_free(t0);
tcg_temp_free(t1);
tcg_temp_free(t2);
tcg_temp_free(a0);
}
break;
case 0x1c7: /* cmpxchg8b */
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
if ((mod == 3) || ((modrm & 0x38) != 0x8))
goto illegal_op;
#ifdef TARGET_X86_64
if (dflag == 2) {
if (!(s->cpuid_ext_features & CPUID_EXT_CX16))
goto illegal_op;
gen_jmp_im(pc_start - s->cs_base);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_helper_cmpxchg16b(cpu_A0);
} else
#endif
{
if (!(s->cpuid_features & CPUID_CX8))
goto illegal_op;
gen_jmp_im(pc_start - s->cs_base);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_helper_cmpxchg8b(cpu_A0);
}
s->cc_op = CC_OP_EFLAGS;
break;
/**************************/
/* push/pop */
case 0x50 ... 0x57: /* push */
gen_op_mov_TN_reg(OT_LONG, 0, (b & 7) | REX_B(s));
gen_push_T0(s);
break;
case 0x58 ... 0x5f: /* pop */
if (CODE64(s)) {
ot = dflag ? OT_QUAD : OT_WORD;
} else {
ot = dflag + OT_WORD;
}
gen_pop_T0(s);
/* NOTE: order is important for pop %sp */
gen_pop_update(s);
gen_op_mov_reg_T0(ot, (b & 7) | REX_B(s));
break;
case 0x60: /* pusha */
if (CODE64(s))
goto illegal_op;
gen_pusha(s);
break;
case 0x61: /* popa */
if (CODE64(s))
goto illegal_op;
gen_popa(s);
break;
case 0x68: /* push Iv */
case 0x6a:
if (CODE64(s)) {
ot = dflag ? OT_QUAD : OT_WORD;
} else {
ot = dflag + OT_WORD;
}
if (b == 0x68)
val = insn_get(s, ot);
else
val = (int8_t)insn_get(s, OT_BYTE);
gen_op_movl_T0_im(val);
gen_push_T0(s);
break;
case 0x8f: /* pop Ev */
if (CODE64(s)) {
ot = dflag ? OT_QUAD : OT_WORD;
} else {
ot = dflag + OT_WORD;
}
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
gen_pop_T0(s);
if (mod == 3) {
/* NOTE: order is important for pop %sp */
gen_pop_update(s);
rm = (modrm & 7) | REX_B(s);
gen_op_mov_reg_T0(ot, rm);
} else {
/* NOTE: order is important too for MMU exceptions */
s->popl_esp_hack = 1 << ot;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 1);
s->popl_esp_hack = 0;
gen_pop_update(s);
}
break;
case 0xc8: /* enter */
{
int level;
val = lduw_code(s->pc);
s->pc += 2;
level = ldub_code(s->pc++);
gen_enter(s, val, level);
}
break;
case 0xc9: /* leave */
/* XXX: exception not precise (ESP is updated before potential exception) */
if (CODE64(s)) {
gen_op_mov_TN_reg(OT_QUAD, 0, R_EBP);
gen_op_mov_reg_T0(OT_QUAD, R_ESP);
} else if (s->ss32) {
gen_op_mov_TN_reg(OT_LONG, 0, R_EBP);
gen_op_mov_reg_T0(OT_LONG, R_ESP);
} else {
gen_op_mov_TN_reg(OT_WORD, 0, R_EBP);
gen_op_mov_reg_T0(OT_WORD, R_ESP);
}
gen_pop_T0(s);
if (CODE64(s)) {
ot = dflag ? OT_QUAD : OT_WORD;
} else {
ot = dflag + OT_WORD;
}
gen_op_mov_reg_T0(ot, R_EBP);
gen_pop_update(s);
break;
case 0x06: /* push es */
case 0x0e: /* push cs */
case 0x16: /* push ss */
case 0x1e: /* push ds */
if (CODE64(s))
goto illegal_op;
gen_op_movl_T0_seg(b >> 3);
gen_push_T0(s);
break;
case 0x1a0: /* push fs */
case 0x1a8: /* push gs */
gen_op_movl_T0_seg((b >> 3) & 7);
gen_push_T0(s);
break;
case 0x07: /* pop es */
case 0x17: /* pop ss */
case 0x1f: /* pop ds */
if (CODE64(s))
goto illegal_op;
reg = b >> 3;
gen_pop_T0(s);
gen_movl_seg_T0(s, reg, pc_start - s->cs_base);
gen_pop_update(s);
if (reg == R_SS) {
/* if reg == SS, inhibit interrupts/trace. */
/* If several instructions disable interrupts, only the
_first_ does it */
if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK))
gen_helper_set_inhibit_irq();
s->tf = 0;
}
if (s->is_jmp) {
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x1a1: /* pop fs */
case 0x1a9: /* pop gs */
gen_pop_T0(s);
gen_movl_seg_T0(s, (b >> 3) & 7, pc_start - s->cs_base);
gen_pop_update(s);
if (s->is_jmp) {
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
/**************************/
/* mov */
case 0x88:
case 0x89: /* mov Gv, Ev */
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
/* generate a generic store */
gen_ldst_modrm(s, modrm, ot, reg, 1);
break;
case 0xc6:
case 0xc7: /* mov Ev, Iv */
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
if (mod != 3) {
s->rip_offset = insn_const_size(ot);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
}
val = insn_get(s, ot);
gen_op_movl_T0_im(val);
if (mod != 3)
gen_op_st_T0_A0(ot + s->mem_index);
else
gen_op_mov_reg_T0(ot, (modrm & 7) | REX_B(s));
break;
case 0x8a:
case 0x8b: /* mov Ev, Gv */
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = OT_WORD + dflag;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
gen_op_mov_reg_T0(ot, reg);
break;
case 0x8e: /* mov seg, Gv */
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
if (reg >= 6 || reg == R_CS)
goto illegal_op;
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
gen_movl_seg_T0(s, reg, pc_start - s->cs_base);
if (reg == R_SS) {
/* if reg == SS, inhibit interrupts/trace */
/* If several instructions disable interrupts, only the
_first_ does it */
if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK))
gen_helper_set_inhibit_irq();
s->tf = 0;
}
if (s->is_jmp) {
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x8c: /* mov Gv, seg */
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
if (reg >= 6)
goto illegal_op;
gen_op_movl_T0_seg(reg);
if (mod == 3)
ot = OT_WORD + dflag;
else
ot = OT_WORD;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 1);
break;
case 0x1b6: /* movzbS Gv, Eb */
case 0x1b7: /* movzwS Gv, Eb */
case 0x1be: /* movsbS Gv, Eb */
case 0x1bf: /* movswS Gv, Eb */
{
int d_ot;
/* d_ot is the size of destination */
d_ot = dflag + OT_WORD;
/* ot is the size of source */
ot = (b & 1) + OT_BYTE;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
if (mod == 3) {
gen_op_mov_TN_reg(ot, 0, rm);
switch(ot | (b & 8)) {
case OT_BYTE:
tcg_gen_ext8u_tl(cpu_T[0], cpu_T[0]);
break;
case OT_BYTE | 8:
tcg_gen_ext8s_tl(cpu_T[0], cpu_T[0]);
break;
case OT_WORD:
tcg_gen_ext16u_tl(cpu_T[0], cpu_T[0]);
break;
default:
case OT_WORD | 8:
tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);
break;
}
gen_op_mov_reg_T0(d_ot, reg);
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (b & 8) {
gen_op_lds_T0_A0(ot + s->mem_index);
} else {
gen_op_ldu_T0_A0(ot + s->mem_index);
}
gen_op_mov_reg_T0(d_ot, reg);
}
}
break;
case 0x8d: /* lea */
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
reg = ((modrm >> 3) & 7) | rex_r;
/* we must ensure that no segment is added */
s->override = -1;
val = s->addseg;
s->addseg = 0;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
s->addseg = val;
gen_op_mov_reg_A0(ot - OT_WORD, reg);
break;
case 0xa0: /* mov EAX, Ov */
case 0xa1:
case 0xa2: /* mov Ov, EAX */
case 0xa3:
{
target_ulong offset_addr;
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
#ifdef TARGET_X86_64
if (s->aflag == 2) {
offset_addr = ldq_code(s->pc);
s->pc += 8;
gen_op_movq_A0_im(offset_addr);
} else
#endif
{
if (s->aflag) {
offset_addr = insn_get(s, OT_LONG);
} else {
offset_addr = insn_get(s, OT_WORD);
}
gen_op_movl_A0_im(offset_addr);
}
gen_add_A0_ds_seg(s);
if ((b & 2) == 0) {
gen_op_ld_T0_A0(ot + s->mem_index);
gen_op_mov_reg_T0(ot, R_EAX);
} else {
gen_op_mov_TN_reg(ot, 0, R_EAX);
gen_op_st_T0_A0(ot + s->mem_index);
}
}
break;
case 0xd7: /* xlat */
#ifdef TARGET_X86_64
if (s->aflag == 2) {
gen_op_movq_A0_reg(R_EBX);
gen_op_mov_TN_reg(OT_QUAD, 0, R_EAX);
tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0xff);
tcg_gen_add_tl(cpu_A0, cpu_A0, cpu_T[0]);
} else
#endif
{
gen_op_movl_A0_reg(R_EBX);
gen_op_mov_TN_reg(OT_LONG, 0, R_EAX);
tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0xff);
tcg_gen_add_tl(cpu_A0, cpu_A0, cpu_T[0]);
if (s->aflag == 0)
gen_op_andl_A0_ffff();
else
tcg_gen_andi_tl(cpu_A0, cpu_A0, 0xffffffff);
}
gen_add_A0_ds_seg(s);
gen_op_ldu_T0_A0(OT_BYTE + s->mem_index);
gen_op_mov_reg_T0(OT_BYTE, R_EAX);
break;
case 0xb0 ... 0xb7: /* mov R, Ib */
val = insn_get(s, OT_BYTE);
gen_op_movl_T0_im(val);
gen_op_mov_reg_T0(OT_BYTE, (b & 7) | REX_B(s));
break;
case 0xb8 ... 0xbf: /* mov R, Iv */
#ifdef TARGET_X86_64
if (dflag == 2) {
uint64_t tmp;
/* 64 bit case */
tmp = ldq_code(s->pc);
s->pc += 8;
reg = (b & 7) | REX_B(s);
gen_movtl_T0_im(tmp);
gen_op_mov_reg_T0(OT_QUAD, reg);
} else
#endif
{
ot = dflag ? OT_LONG : OT_WORD;
val = insn_get(s, ot);
reg = (b & 7) | REX_B(s);
gen_op_movl_T0_im(val);
gen_op_mov_reg_T0(ot, reg);
}
break;
case 0x91 ... 0x97: /* xchg R, EAX */
ot = dflag + OT_WORD;
reg = (b & 7) | REX_B(s);
rm = R_EAX;
goto do_xchg_reg;
case 0x86:
case 0x87: /* xchg Ev, Gv */
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
if (mod == 3) {
rm = (modrm & 7) | REX_B(s);
do_xchg_reg:
gen_op_mov_TN_reg(ot, 0, reg);
gen_op_mov_TN_reg(ot, 1, rm);
gen_op_mov_reg_T0(ot, rm);
gen_op_mov_reg_T1(ot, reg);
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_mov_TN_reg(ot, 0, reg);
/* for xchg, lock is implicit */
if (!(prefixes & PREFIX_LOCK))
gen_helper_lock();
gen_op_ld_T1_A0(ot + s->mem_index);
gen_op_st_T0_A0(ot + s->mem_index);
if (!(prefixes & PREFIX_LOCK))
gen_helper_unlock();
gen_op_mov_reg_T1(ot, reg);
}
break;
case 0xc4: /* les Gv */
if (CODE64(s))
goto illegal_op;
op = R_ES;
goto do_lxx;
case 0xc5: /* lds Gv */
if (CODE64(s))
goto illegal_op;
op = R_DS;
goto do_lxx;
case 0x1b2: /* lss Gv */
op = R_SS;
goto do_lxx;
case 0x1b4: /* lfs Gv */
op = R_FS;
goto do_lxx;
case 0x1b5: /* lgs Gv */
op = R_GS;
do_lxx:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T1_A0(ot + s->mem_index);
gen_add_A0_im(s, 1 << (ot - OT_WORD + 1));
/* load the segment first to handle exceptions properly */
gen_op_ldu_T0_A0(OT_WORD + s->mem_index);
gen_movl_seg_T0(s, op, pc_start - s->cs_base);
/* then put the data */
gen_op_mov_reg_T1(ot, reg);
if (s->is_jmp) {
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
/************************/
/* shifts */
case 0xc0:
case 0xc1:
/* shift Ev,Ib */
shift = 2;
grp2:
{
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
op = (modrm >> 3) & 7;
if (mod != 3) {
if (shift == 2) {
s->rip_offset = 1;
}
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
opreg = OR_TMP0;
} else {
opreg = (modrm & 7) | REX_B(s);
}
/* simpler op */
if (shift == 0) {
gen_shift(s, op, ot, opreg, OR_ECX);
} else {
if (shift == 2) {
shift = ldub_code(s->pc++);
}
gen_shifti(s, op, ot, opreg, shift);
}
}
break;
case 0xd0:
case 0xd1:
/* shift Ev,1 */
shift = 1;
goto grp2;
case 0xd2:
case 0xd3:
/* shift Ev,cl */
shift = 0;
goto grp2;
case 0x1a4: /* shld imm */
op = 0;
shift = 1;
goto do_shiftd;
case 0x1a5: /* shld cl */
op = 0;
shift = 0;
goto do_shiftd;
case 0x1ac: /* shrd imm */
op = 1;
shift = 1;
goto do_shiftd;
case 0x1ad: /* shrd cl */
op = 1;
shift = 0;
do_shiftd:
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
reg = ((modrm >> 3) & 7) | rex_r;
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
opreg = OR_TMP0;
} else {
opreg = rm;
}
gen_op_mov_TN_reg(ot, 1, reg);
if (shift) {
val = ldub_code(s->pc++);
tcg_gen_movi_tl(cpu_T3, val);
} else {
tcg_gen_ld_tl(cpu_T3, cpu_env, offsetof(CPUState, regs[R_ECX]));
}
gen_shiftd_rm_T1_T3(s, ot, opreg, op);
break;
/************************/
/* floats */
case 0xd8 ... 0xdf:
if (s->flags & (HF_EM_MASK | HF_TS_MASK)) {
/* if CR0.EM or CR0.TS are set, generate an FPU exception */
/* XXX: what to do if illegal op ? */
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
break;
}
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = modrm & 7;
op = ((b & 7) << 3) | ((modrm >> 3) & 7);
if (mod != 3) {
/* memory op */
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
switch(op) {
case 0x00 ... 0x07: /* fxxxs */
case 0x10 ... 0x17: /* fixxxl */
case 0x20 ... 0x27: /* fxxxl */
case 0x30 ... 0x37: /* fixxx */
{
int op1;
op1 = op & 7;
switch(op >> 4) {
case 0:
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_flds_FT0(cpu_tmp2_i32);
break;
case 1:
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_fildl_FT0(cpu_tmp2_i32);
break;
case 2:
tcg_gen_qemu_ld64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
gen_helper_fldl_FT0(cpu_tmp1_i64);
break;
case 3:
default:
gen_op_lds_T0_A0(OT_WORD + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_fildl_FT0(cpu_tmp2_i32);
break;
}
gen_helper_fp_arith_ST0_FT0(op1);
if (op1 == 3) {
/* fcomp needs pop */
gen_helper_fpop();
}
}
break;
case 0x08: /* flds */
case 0x0a: /* fsts */
case 0x0b: /* fstps */
case 0x18 ... 0x1b: /* fildl, fisttpl, fistl, fistpl */
case 0x28 ... 0x2b: /* fldl, fisttpll, fstl, fstpl */
case 0x38 ... 0x3b: /* filds, fisttps, fists, fistps */
switch(op & 7) {
case 0:
switch(op >> 4) {
case 0:
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_flds_ST0(cpu_tmp2_i32);
break;
case 1:
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_fildl_ST0(cpu_tmp2_i32);
break;
case 2:
tcg_gen_qemu_ld64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
gen_helper_fldl_ST0(cpu_tmp1_i64);
break;
case 3:
default:
gen_op_lds_T0_A0(OT_WORD + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_fildl_ST0(cpu_tmp2_i32);
break;
}
break;
case 1:
/* XXX: the corresponding CPUID bit must be tested ! */
switch(op >> 4) {
case 1:
gen_helper_fisttl_ST0(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_LONG + s->mem_index);
break;
case 2:
gen_helper_fisttll_ST0(cpu_tmp1_i64);
tcg_gen_qemu_st64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
break;
case 3:
default:
gen_helper_fistt_ST0(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_WORD + s->mem_index);
break;
}
gen_helper_fpop();
break;
default:
switch(op >> 4) {
case 0:
gen_helper_fsts_ST0(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_LONG + s->mem_index);
break;
case 1:
gen_helper_fistl_ST0(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_LONG + s->mem_index);
break;
case 2:
gen_helper_fstl_ST0(cpu_tmp1_i64);
tcg_gen_qemu_st64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
break;
case 3:
default:
gen_helper_fist_ST0(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_WORD + s->mem_index);
break;
}
if ((op & 7) == 3)
gen_helper_fpop();
break;
}
break;
case 0x0c: /* fldenv mem */
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fldenv(
cpu_A0, tcg_const_i32(s->dflag));
break;
case 0x0d: /* fldcw mem */
gen_op_ld_T0_A0(OT_WORD + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_fldcw(cpu_tmp2_i32);
break;
case 0x0e: /* fnstenv mem */
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fstenv(cpu_A0, tcg_const_i32(s->dflag));
break;
case 0x0f: /* fnstcw mem */
gen_helper_fnstcw(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_WORD + s->mem_index);
break;
case 0x1d: /* fldt mem */
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fldt_ST0(cpu_A0);
break;
case 0x1f: /* fstpt mem */
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fstt_ST0(cpu_A0);
gen_helper_fpop();
break;
case 0x2c: /* frstor mem */
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_frstor(cpu_A0, tcg_const_i32(s->dflag));
break;
case 0x2e: /* fnsave mem */
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fsave(cpu_A0, tcg_const_i32(s->dflag));
break;
case 0x2f: /* fnstsw mem */
gen_helper_fnstsw(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_WORD + s->mem_index);
break;
case 0x3c: /* fbld */
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fbld_ST0(cpu_A0);
break;
case 0x3e: /* fbstp */
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fbst_ST0(cpu_A0);
gen_helper_fpop();
break;
case 0x3d: /* fildll */
tcg_gen_qemu_ld64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
gen_helper_fildll_ST0(cpu_tmp1_i64);
break;
case 0x3f: /* fistpll */
gen_helper_fistll_ST0(cpu_tmp1_i64);
tcg_gen_qemu_st64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
gen_helper_fpop();
break;
default:
goto illegal_op;
}
} else {
/* register float ops */
opreg = rm;
switch(op) {
case 0x08: /* fld sti */
gen_helper_fpush();
gen_helper_fmov_ST0_STN(tcg_const_i32((opreg + 1) & 7));
break;
case 0x09: /* fxchg sti */
case 0x29: /* fxchg4 sti, undocumented op */
case 0x39: /* fxchg7 sti, undocumented op */
gen_helper_fxchg_ST0_STN(tcg_const_i32(opreg));
break;
case 0x0a: /* grp d9/2 */
switch(rm) {
case 0: /* fnop */
/* check exceptions (FreeBSD FPU probe) */
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fwait();
break;
default:
goto illegal_op;
}
break;
case 0x0c: /* grp d9/4 */
switch(rm) {
case 0: /* fchs */
gen_helper_fchs_ST0();
break;
case 1: /* fabs */
gen_helper_fabs_ST0();
break;
case 4: /* ftst */
gen_helper_fldz_FT0();
gen_helper_fcom_ST0_FT0();
break;
case 5: /* fxam */
gen_helper_fxam_ST0();
break;
default:
goto illegal_op;
}
break;
case 0x0d: /* grp d9/5 */
{
switch(rm) {
case 0:
gen_helper_fpush();
gen_helper_fld1_ST0();
break;
case 1:
gen_helper_fpush();
gen_helper_fldl2t_ST0();
break;
case 2:
gen_helper_fpush();
gen_helper_fldl2e_ST0();
break;
case 3:
gen_helper_fpush();
gen_helper_fldpi_ST0();
break;
case 4:
gen_helper_fpush();
gen_helper_fldlg2_ST0();
break;
case 5:
gen_helper_fpush();
gen_helper_fldln2_ST0();
break;
case 6:
gen_helper_fpush();
gen_helper_fldz_ST0();
break;
default:
goto illegal_op;
}
}
break;
case 0x0e: /* grp d9/6 */
switch(rm) {
case 0: /* f2xm1 */
gen_helper_f2xm1();
break;
case 1: /* fyl2x */
gen_helper_fyl2x();
break;
case 2: /* fptan */
gen_helper_fptan();
break;
case 3: /* fpatan */
gen_helper_fpatan();
break;
case 4: /* fxtract */
gen_helper_fxtract();
break;
case 5: /* fprem1 */
gen_helper_fprem1();
break;
case 6: /* fdecstp */
gen_helper_fdecstp();
break;
default:
case 7: /* fincstp */
gen_helper_fincstp();
break;
}
break;
case 0x0f: /* grp d9/7 */
switch(rm) {
case 0: /* fprem */
gen_helper_fprem();
break;
case 1: /* fyl2xp1 */
gen_helper_fyl2xp1();
break;
case 2: /* fsqrt */
gen_helper_fsqrt();
break;
case 3: /* fsincos */
gen_helper_fsincos();
break;
case 5: /* fscale */
gen_helper_fscale();
break;
case 4: /* frndint */
gen_helper_frndint();
break;
case 6: /* fsin */
gen_helper_fsin();
break;
default:
case 7: /* fcos */
gen_helper_fcos();
break;
}
break;
case 0x00: case 0x01: case 0x04 ... 0x07: /* fxxx st, sti */
case 0x20: case 0x21: case 0x24 ... 0x27: /* fxxx sti, st */
case 0x30: case 0x31: case 0x34 ... 0x37: /* fxxxp sti, st */
{
int op1;
op1 = op & 7;
if (op >= 0x20) {
gen_helper_fp_arith_STN_ST0(op1, opreg);
if (op >= 0x30)
gen_helper_fpop();
} else {
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fp_arith_ST0_FT0(op1);
}
}
break;
case 0x02: /* fcom */
case 0x22: /* fcom2, undocumented op */
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fcom_ST0_FT0();
break;
case 0x03: /* fcomp */
case 0x23: /* fcomp3, undocumented op */
case 0x32: /* fcomp5, undocumented op */
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fcom_ST0_FT0();
gen_helper_fpop();
break;
case 0x15: /* da/5 */
switch(rm) {
case 1: /* fucompp */
gen_helper_fmov_FT0_STN(tcg_const_i32(1));
gen_helper_fucom_ST0_FT0();
gen_helper_fpop();
gen_helper_fpop();
break;
default:
goto illegal_op;
}
break;
case 0x1c:
switch(rm) {
case 0: /* feni (287 only, just do nop here) */
break;
case 1: /* fdisi (287 only, just do nop here) */
break;
case 2: /* fclex */
gen_helper_fclex();
break;
case 3: /* fninit */
gen_helper_fninit();
break;
case 4: /* fsetpm (287 only, just do nop here) */
break;
default:
goto illegal_op;
}
break;
case 0x1d: /* fucomi */
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fucomi_ST0_FT0();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x1e: /* fcomi */
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fcomi_ST0_FT0();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x28: /* ffree sti */
gen_helper_ffree_STN(tcg_const_i32(opreg));
break;
case 0x2a: /* fst sti */
gen_helper_fmov_STN_ST0(tcg_const_i32(opreg));
break;
case 0x2b: /* fstp sti */
case 0x0b: /* fstp1 sti, undocumented op */
case 0x3a: /* fstp8 sti, undocumented op */
case 0x3b: /* fstp9 sti, undocumented op */
gen_helper_fmov_STN_ST0(tcg_const_i32(opreg));
gen_helper_fpop();
break;
case 0x2c: /* fucom st(i) */
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fucom_ST0_FT0();
break;
case 0x2d: /* fucomp st(i) */
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fucom_ST0_FT0();
gen_helper_fpop();
break;
case 0x33: /* de/3 */
switch(rm) {
case 1: /* fcompp */
gen_helper_fmov_FT0_STN(tcg_const_i32(1));
gen_helper_fcom_ST0_FT0();
gen_helper_fpop();
gen_helper_fpop();
break;
default:
goto illegal_op;
}
break;
case 0x38: /* ffreep sti, undocumented op */
gen_helper_ffree_STN(tcg_const_i32(opreg));
gen_helper_fpop();
break;
case 0x3c: /* df/4 */
switch(rm) {
case 0:
gen_helper_fnstsw(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
break;
default:
goto illegal_op;
}
break;
case 0x3d: /* fucomip */
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fucomi_ST0_FT0();
gen_helper_fpop();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x3e: /* fcomip */
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fcomi_ST0_FT0();
gen_helper_fpop();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x10 ... 0x13: /* fcmovxx */
case 0x18 ... 0x1b:
{
int op1, l1;
static const uint8_t fcmov_cc[8] = {
(JCC_B << 1),
(JCC_Z << 1),
(JCC_BE << 1),
(JCC_P << 1),
};
op1 = fcmov_cc[op & 3] | (((op >> 3) & 1) ^ 1);
l1 = gen_new_label();
gen_jcc1(s, s->cc_op, op1, l1);
gen_helper_fmov_ST0_STN(tcg_const_i32(opreg));
gen_set_label(l1);
}
break;
default:
goto illegal_op;
}
}
break;
/************************/
/* string ops */
case 0xa4: /* movsS */
case 0xa5:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_movs(s, ot, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_movs(s, ot);
}
break;
case 0xaa: /* stosS */
case 0xab:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_stos(s, ot, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_stos(s, ot);
}
break;
case 0xac: /* lodsS */
case 0xad:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_lods(s, ot, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_lods(s, ot);
}
break;
case 0xae: /* scasS */
case 0xaf:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
if (prefixes & PREFIX_REPNZ) {
gen_repz_scas(s, ot, pc_start - s->cs_base, s->pc - s->cs_base, 1);
} else if (prefixes & PREFIX_REPZ) {
gen_repz_scas(s, ot, pc_start - s->cs_base, s->pc - s->cs_base, 0);
} else {
gen_scas(s, ot);
s->cc_op = CC_OP_SUBB + ot;
}
break;
case 0xa6: /* cmpsS */
case 0xa7:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
if (prefixes & PREFIX_REPNZ) {
gen_repz_cmps(s, ot, pc_start - s->cs_base, s->pc - s->cs_base, 1);
} else if (prefixes & PREFIX_REPZ) {
gen_repz_cmps(s, ot, pc_start - s->cs_base, s->pc - s->cs_base, 0);
} else {
gen_cmps(s, ot);
s->cc_op = CC_OP_SUBB + ot;
}
break;
case 0x6c: /* insS */
case 0x6d:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
gen_op_mov_TN_reg(OT_WORD, 0, R_EDX);
gen_op_andl_T0_ffff();
gen_check_io(s, ot, pc_start - s->cs_base,
SVM_IOIO_TYPE_MASK | svm_is_rep(prefixes) | 4);
if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_ins(s, ot, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_ins(s, ot);
if (use_icount) {
gen_jmp(s, s->pc - s->cs_base);
}
}
break;
case 0x6e: /* outsS */
case 0x6f:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
gen_op_mov_TN_reg(OT_WORD, 0, R_EDX);
gen_op_andl_T0_ffff();
gen_check_io(s, ot, pc_start - s->cs_base,
svm_is_rep(prefixes) | 4);
if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_outs(s, ot, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_outs(s, ot);
if (use_icount) {
gen_jmp(s, s->pc - s->cs_base);
}
}
break;
/************************/
/* port I/O */
case 0xe4:
case 0xe5:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
val = ldub_code(s->pc++);
gen_op_movl_T0_im(val);
gen_check_io(s, ot, pc_start - s->cs_base,
SVM_IOIO_TYPE_MASK | svm_is_rep(prefixes));
if (use_icount)
gen_io_start();
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_in_func(ot, cpu_T[1], cpu_tmp2_i32);
gen_op_mov_reg_T1(ot, R_EAX);
if (use_icount) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0xe6:
case 0xe7:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
val = ldub_code(s->pc++);
gen_op_movl_T0_im(val);
gen_check_io(s, ot, pc_start - s->cs_base,
svm_is_rep(prefixes));
gen_op_mov_TN_reg(ot, 1, R_EAX);
if (use_icount)
gen_io_start();
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff);
tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T[1]);
gen_helper_out_func(ot, cpu_tmp2_i32, cpu_tmp3_i32);
if (use_icount) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0xec:
case 0xed:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
gen_op_mov_TN_reg(OT_WORD, 0, R_EDX);
gen_op_andl_T0_ffff();
gen_check_io(s, ot, pc_start - s->cs_base,
SVM_IOIO_TYPE_MASK | svm_is_rep(prefixes));
if (use_icount)
gen_io_start();
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_in_func(ot, cpu_T[1], cpu_tmp2_i32);
gen_op_mov_reg_T1(ot, R_EAX);
if (use_icount) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0xee:
case 0xef:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
gen_op_mov_TN_reg(OT_WORD, 0, R_EDX);
gen_op_andl_T0_ffff();
gen_check_io(s, ot, pc_start - s->cs_base,
svm_is_rep(prefixes));
gen_op_mov_TN_reg(ot, 1, R_EAX);
if (use_icount)
gen_io_start();
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff);
tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T[1]);
gen_helper_out_func(ot, cpu_tmp2_i32, cpu_tmp3_i32);
if (use_icount) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
/************************/
/* control */
case 0xc2: /* ret im */
val = ldsw_code(s->pc);
s->pc += 2;
gen_pop_T0(s);
if (CODE64(s) && s->dflag)
s->dflag = 2;
gen_stack_update(s, val + (2 << s->dflag));
if (s->dflag == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
gen_eob(s);
break;
case 0xc3: /* ret */
gen_pop_T0(s);
gen_pop_update(s);
if (s->dflag == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
gen_eob(s);
break;
case 0xca: /* lret im */
val = ldsw_code(s->pc);
s->pc += 2;
do_lret:
if (s->pe && !s->vm86) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_lret_protected(tcg_const_i32(s->dflag),
tcg_const_i32(val));
} else {
gen_stack_A0(s);
/* pop offset */
gen_op_ld_T0_A0(1 + s->dflag + s->mem_index);
if (s->dflag == 0)
gen_op_andl_T0_ffff();
/* NOTE: keeping EIP updated is not a problem in case of
exception */
gen_op_jmp_T0();
/* pop selector */
gen_op_addl_A0_im(2 << s->dflag);
gen_op_ld_T0_A0(1 + s->dflag + s->mem_index);
gen_op_movl_seg_T0_vm(R_CS);
/* add stack offset */
gen_stack_update(s, val + (4 << s->dflag));
}
gen_eob(s);
break;
case 0xcb: /* lret */
val = 0;
goto do_lret;
case 0xcf: /* iret */
gen_svm_check_intercept(s, pc_start, SVM_EXIT_IRET);
if (!s->pe) {
/* real mode */
gen_helper_iret_real(tcg_const_i32(s->dflag));
s->cc_op = CC_OP_EFLAGS;
} else if (s->vm86) {
if (s->iopl != 3) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_helper_iret_real(tcg_const_i32(s->dflag));
s->cc_op = CC_OP_EFLAGS;
}
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_iret_protected(tcg_const_i32(s->dflag),
tcg_const_i32(s->pc - s->cs_base));
s->cc_op = CC_OP_EFLAGS;
}
gen_eob(s);
break;
case 0xe8: /* call im */
{
if (dflag)
tval = (int32_t)insn_get(s, OT_LONG);
else
tval = (int16_t)insn_get(s, OT_WORD);
next_eip = s->pc - s->cs_base;
tval += next_eip;
if (s->dflag == 0)
tval &= 0xffff;
gen_movtl_T0_im(next_eip);
gen_push_T0(s);
gen_jmp(s, tval);
}
break;
case 0x9a: /* lcall im */
{
unsigned int selector, offset;
if (CODE64(s))
goto illegal_op;
ot = dflag ? OT_LONG : OT_WORD;
offset = insn_get(s, ot);
selector = insn_get(s, OT_WORD);
gen_op_movl_T0_im(selector);
gen_op_movl_T1_imu(offset);
}
goto do_lcall;
case 0xe9: /* jmp im */
if (dflag)
tval = (int32_t)insn_get(s, OT_LONG);
else
tval = (int16_t)insn_get(s, OT_WORD);
tval += s->pc - s->cs_base;
if (s->dflag == 0)
tval &= 0xffff;
gen_jmp(s, tval);
break;
case 0xea: /* ljmp im */
{
unsigned int selector, offset;
if (CODE64(s))
goto illegal_op;
ot = dflag ? OT_LONG : OT_WORD;
offset = insn_get(s, ot);
selector = insn_get(s, OT_WORD);
gen_op_movl_T0_im(selector);
gen_op_movl_T1_imu(offset);
}
goto do_ljmp;
case 0xeb: /* jmp Jb */
tval = (int8_t)insn_get(s, OT_BYTE);
tval += s->pc - s->cs_base;
if (s->dflag == 0)
tval &= 0xffff;
gen_jmp(s, tval);
break;
case 0x70 ... 0x7f: /* jcc Jb */
tval = (int8_t)insn_get(s, OT_BYTE);
goto do_jcc;
case 0x180 ... 0x18f: /* jcc Jv */
if (dflag) {
tval = (int32_t)insn_get(s, OT_LONG);
} else {
tval = (int16_t)insn_get(s, OT_WORD);
}
do_jcc:
next_eip = s->pc - s->cs_base;
tval += next_eip;
if (s->dflag == 0)
tval &= 0xffff;
gen_jcc(s, b, tval, next_eip);
break;
case 0x190 ... 0x19f: /* setcc Gv */
modrm = ldub_code(s->pc++);
gen_setcc(s, b);
gen_ldst_modrm(s, modrm, OT_BYTE, OR_TMP0, 1);
break;
case 0x140 ... 0x14f: /* cmov Gv, Ev */
{
int l1;
TCGv t0;
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
t0 = tcg_temp_local_new();
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_v(ot + s->mem_index, t0, cpu_A0);
} else {
rm = (modrm & 7) | REX_B(s);
gen_op_mov_v_reg(ot, t0, rm);
}
#ifdef TARGET_X86_64
if (ot == OT_LONG) {
/* XXX: specific Intel behaviour ? */
l1 = gen_new_label();
gen_jcc1(s, s->cc_op, b ^ 1, l1);
tcg_gen_st32_tl(t0, cpu_env, offsetof(CPUState, regs[reg]) + REG_L_OFFSET);
gen_set_label(l1);
tcg_gen_movi_tl(cpu_tmp0, 0);
tcg_gen_st32_tl(cpu_tmp0, cpu_env, offsetof(CPUState, regs[reg]) + REG_LH_OFFSET);
} else
#endif
{
l1 = gen_new_label();
gen_jcc1(s, s->cc_op, b ^ 1, l1);
gen_op_mov_reg_v(ot, reg, t0);
gen_set_label(l1);
}
tcg_temp_free(t0);
}
break;
/************************/
/* flags */
case 0x9c: /* pushf */
gen_svm_check_intercept(s, pc_start, SVM_EXIT_PUSHF);
if (s->vm86 && s->iopl != 3) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_read_eflags(cpu_T[0]);
gen_push_T0(s);
}
break;
case 0x9d: /* popf */
gen_svm_check_intercept(s, pc_start, SVM_EXIT_POPF);
if (s->vm86 && s->iopl != 3) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_pop_T0(s);
if (s->cpl == 0) {
if (s->dflag) {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK | IOPL_MASK)));
} else {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK | IOPL_MASK) & 0xffff));
}
} else {
if (s->cpl <= s->iopl) {
if (s->dflag) {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK)));
} else {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK) & 0xffff));
}
} else {
if (s->dflag) {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK)));
} else {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK) & 0xffff));
}
}
}
gen_pop_update(s);
s->cc_op = CC_OP_EFLAGS;
/* abort translation because TF flag may change */
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x9e: /* sahf */
if (CODE64(s) && !(s->cpuid_ext3_features & CPUID_EXT3_LAHF_LM))
goto illegal_op;
gen_op_mov_TN_reg(OT_BYTE, 0, R_AH);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_cc_src);
tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, CC_O);
tcg_gen_andi_tl(cpu_T[0], cpu_T[0], CC_S | CC_Z | CC_A | CC_P | CC_C);
tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, cpu_T[0]);
s->cc_op = CC_OP_EFLAGS;
break;
case 0x9f: /* lahf */
if (CODE64(s) && !(s->cpuid_ext3_features & CPUID_EXT3_LAHF_LM))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_T[0]);
/* Note: gen_compute_eflags() only gives the condition codes */
tcg_gen_ori_tl(cpu_T[0], cpu_T[0], 0x02);
gen_op_mov_reg_T0(OT_BYTE, R_AH);
break;
case 0xf5: /* cmc */
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_cc_src);
tcg_gen_xori_tl(cpu_cc_src, cpu_cc_src, CC_C);
s->cc_op = CC_OP_EFLAGS;
break;
case 0xf8: /* clc */
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_cc_src);
tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, ~CC_C);
s->cc_op = CC_OP_EFLAGS;
break;
case 0xf9: /* stc */
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_cc_src);
tcg_gen_ori_tl(cpu_cc_src, cpu_cc_src, CC_C);
s->cc_op = CC_OP_EFLAGS;
break;
case 0xfc: /* cld */
tcg_gen_movi_i32(cpu_tmp2_i32, 1);
tcg_gen_st_i32(cpu_tmp2_i32, cpu_env, offsetof(CPUState, df));
break;
case 0xfd: /* std */
tcg_gen_movi_i32(cpu_tmp2_i32, -1);
tcg_gen_st_i32(cpu_tmp2_i32, cpu_env, offsetof(CPUState, df));
break;
/************************/
/* bit operations */
case 0x1ba: /* bt/bts/btr/btc Gv, im */
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
op = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
if (mod != 3) {
s->rip_offset = 1;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T0_A0(ot + s->mem_index);
} else {
gen_op_mov_TN_reg(ot, 0, rm);
}
/* load shift */
val = ldub_code(s->pc++);
gen_op_movl_T1_im(val);
if (op < 4)
goto illegal_op;
op -= 4;
goto bt_op;
case 0x1a3: /* bt Gv, Ev */
op = 0;
goto do_btx;
case 0x1ab: /* bts */
op = 1;
goto do_btx;
case 0x1b3: /* btr */
op = 2;
goto do_btx;
case 0x1bb: /* btc */
op = 3;
do_btx:
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
gen_op_mov_TN_reg(OT_LONG, 1, reg);
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
/* specific case: we need to add a displacement */
gen_exts(ot, cpu_T[1]);
tcg_gen_sari_tl(cpu_tmp0, cpu_T[1], 3 + ot);
tcg_gen_shli_tl(cpu_tmp0, cpu_tmp0, ot);
tcg_gen_add_tl(cpu_A0, cpu_A0, cpu_tmp0);
gen_op_ld_T0_A0(ot + s->mem_index);
} else {
gen_op_mov_TN_reg(ot, 0, rm);
}
bt_op:
tcg_gen_andi_tl(cpu_T[1], cpu_T[1], (1 << (3 + ot)) - 1);
switch(op) {
case 0:
tcg_gen_shr_tl(cpu_cc_src, cpu_T[0], cpu_T[1]);
tcg_gen_movi_tl(cpu_cc_dst, 0);
break;
case 1:
tcg_gen_shr_tl(cpu_tmp4, cpu_T[0], cpu_T[1]);
tcg_gen_movi_tl(cpu_tmp0, 1);
tcg_gen_shl_tl(cpu_tmp0, cpu_tmp0, cpu_T[1]);
tcg_gen_or_tl(cpu_T[0], cpu_T[0], cpu_tmp0);
break;
case 2:
tcg_gen_shr_tl(cpu_tmp4, cpu_T[0], cpu_T[1]);
tcg_gen_movi_tl(cpu_tmp0, 1);
tcg_gen_shl_tl(cpu_tmp0, cpu_tmp0, cpu_T[1]);
tcg_gen_not_tl(cpu_tmp0, cpu_tmp0);
tcg_gen_and_tl(cpu_T[0], cpu_T[0], cpu_tmp0);
break;
default:
case 3:
tcg_gen_shr_tl(cpu_tmp4, cpu_T[0], cpu_T[1]);
tcg_gen_movi_tl(cpu_tmp0, 1);
tcg_gen_shl_tl(cpu_tmp0, cpu_tmp0, cpu_T[1]);
tcg_gen_xor_tl(cpu_T[0], cpu_T[0], cpu_tmp0);
break;
}
s->cc_op = CC_OP_SARB + ot;
if (op != 0) {
if (mod != 3)
gen_op_st_T0_A0(ot + s->mem_index);
else
gen_op_mov_reg_T0(ot, rm);
tcg_gen_mov_tl(cpu_cc_src, cpu_tmp4);
tcg_gen_movi_tl(cpu_cc_dst, 0);
}
break;
case 0x1bc: /* bsf */
case 0x1bd: /* bsr */
{
int label1;
TCGv t0;
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
gen_extu(ot, cpu_T[0]);
label1 = gen_new_label();
tcg_gen_movi_tl(cpu_cc_dst, 0);
t0 = tcg_temp_local_new();
tcg_gen_mov_tl(t0, cpu_T[0]);
tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, label1);
if (b & 1) {
gen_helper_bsr(cpu_T[0], t0);
} else {
gen_helper_bsf(cpu_T[0], t0);
}
gen_op_mov_reg_T0(ot, reg);
tcg_gen_movi_tl(cpu_cc_dst, 1);
gen_set_label(label1);
tcg_gen_discard_tl(cpu_cc_src);
s->cc_op = CC_OP_LOGICB + ot;
tcg_temp_free(t0);
}
break;
/************************/
/* bcd */
case 0x27: /* daa */
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_daa();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x2f: /* das */
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_das();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x37: /* aaa */
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_aaa();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x3f: /* aas */
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_aas();
s->cc_op = CC_OP_EFLAGS;
break;
case 0xd4: /* aam */
if (CODE64(s))
goto illegal_op;
val = ldub_code(s->pc++);
if (val == 0) {
gen_exception(s, EXCP00_DIVZ, pc_start - s->cs_base);
} else {
gen_helper_aam(tcg_const_i32(val));
s->cc_op = CC_OP_LOGICB;
}
break;
case 0xd5: /* aad */
if (CODE64(s))
goto illegal_op;
val = ldub_code(s->pc++);
gen_helper_aad(tcg_const_i32(val));
s->cc_op = CC_OP_LOGICB;
break;
/************************/
/* misc */
case 0x90: /* nop */
/* XXX: xchg + rex handling */
/* XXX: correct lock test for all insn */
if (prefixes & PREFIX_LOCK)
goto illegal_op;
if (prefixes & PREFIX_REPZ) {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_PAUSE);
}
break;
case 0x9b: /* fwait */
if ((s->flags & (HF_MP_MASK | HF_TS_MASK)) ==
(HF_MP_MASK | HF_TS_MASK)) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fwait();
}
break;
case 0xcc: /* int3 */
gen_interrupt(s, EXCP03_INT3, pc_start - s->cs_base, s->pc - s->cs_base);
break;
case 0xcd: /* int N */
val = ldub_code(s->pc++);
if (s->vm86 && s->iopl != 3) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_interrupt(s, val, pc_start - s->cs_base, s->pc - s->cs_base);
}
break;
case 0xce: /* into */
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_into(tcg_const_i32(s->pc - pc_start));
break;
#ifdef WANT_ICEBP
case 0xf1: /* icebp (undocumented, exits to external debugger) */
gen_svm_check_intercept(s, pc_start, SVM_EXIT_ICEBP);
#if 1
gen_debug(s, pc_start - s->cs_base);
#else
/* start debug */
tb_flush(cpu_single_env);
cpu_set_log(CPU_LOG_INT | CPU_LOG_TB_IN_ASM);
#endif
break;
#endif
case 0xfa: /* cli */
if (!s->vm86) {
if (s->cpl <= s->iopl) {
gen_helper_cli();
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
} else {
if (s->iopl == 3) {
gen_helper_cli();
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
}
break;
case 0xfb: /* sti */
if (!s->vm86) {
if (s->cpl <= s->iopl) {
gen_sti:
gen_helper_sti();
/* interruptions are enabled only the first insn after sti */
/* If several instructions disable interrupts, only the
_first_ does it */
if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK))
gen_helper_set_inhibit_irq();
/* give a chance to handle pending irqs */
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
} else {
if (s->iopl == 3) {
goto gen_sti;
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
}
break;
case 0x62: /* bound */
if (CODE64(s))
goto illegal_op;
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
gen_op_mov_TN_reg(ot, 0, reg);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_jmp_im(pc_start - s->cs_base);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
if (ot == OT_WORD)
gen_helper_boundw(cpu_A0, cpu_tmp2_i32);
else
gen_helper_boundl(cpu_A0, cpu_tmp2_i32);
break;
case 0x1c8 ... 0x1cf: /* bswap reg */
reg = (b & 7) | REX_B(s);
#ifdef TARGET_X86_64
if (dflag == 2) {
gen_op_mov_TN_reg(OT_QUAD, 0, reg);
tcg_gen_bswap_i64(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_QUAD, reg);
} else
{
TCGv_i32 tmp0;
gen_op_mov_TN_reg(OT_LONG, 0, reg);
tmp0 = tcg_temp_new_i32();
tcg_gen_trunc_i64_i32(tmp0, cpu_T[0]);
tcg_gen_bswap_i32(tmp0, tmp0);
tcg_gen_extu_i32_i64(cpu_T[0], tmp0);
gen_op_mov_reg_T0(OT_LONG, reg);
}
#else
{
gen_op_mov_TN_reg(OT_LONG, 0, reg);
tcg_gen_bswap_i32(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_LONG, reg);
}
#endif
break;
case 0xd6: /* salc */
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags_c(cpu_T[0]);
tcg_gen_neg_tl(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_BYTE, R_EAX);
break;
case 0xe0: /* loopnz */
case 0xe1: /* loopz */
case 0xe2: /* loop */
case 0xe3: /* jecxz */
{
int l1, l2, l3;
tval = (int8_t)insn_get(s, OT_BYTE);
next_eip = s->pc - s->cs_base;
tval += next_eip;
if (s->dflag == 0)
tval &= 0xffff;
l1 = gen_new_label();
l2 = gen_new_label();
l3 = gen_new_label();
b &= 3;
switch(b) {
case 0: /* loopnz */
case 1: /* loopz */
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_add_reg_im(s->aflag, R_ECX, -1);
gen_op_jz_ecx(s->aflag, l3);
gen_compute_eflags(cpu_tmp0);
tcg_gen_andi_tl(cpu_tmp0, cpu_tmp0, CC_Z);
if (b == 0) {
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_tmp0, 0, l1);
} else {
tcg_gen_brcondi_tl(TCG_COND_NE, cpu_tmp0, 0, l1);
}
break;
case 2: /* loop */
gen_op_add_reg_im(s->aflag, R_ECX, -1);
gen_op_jnz_ecx(s->aflag, l1);
break;
default:
case 3: /* jcxz */
gen_op_jz_ecx(s->aflag, l1);
break;
}
gen_set_label(l3);
gen_jmp_im(next_eip);
tcg_gen_br(l2);
gen_set_label(l1);
gen_jmp_im(tval);
gen_set_label(l2);
gen_eob(s);
}
break;
case 0x130: /* wrmsr */
case 0x132: /* rdmsr */
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
if (b & 2) {
gen_helper_rdmsr();
} else {
gen_helper_wrmsr();
}
}
break;
case 0x131: /* rdtsc */
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
if (use_icount)
gen_io_start();
gen_helper_rdtsc();
if (use_icount) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0x133: /* rdpmc */
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_rdpmc();
break;
case 0x134: /* sysenter */
/* For Intel SYSENTER is valid on 64-bit */
if (CODE64(s) && cpu_single_env->cpuid_vendor1 != CPUID_VENDOR_INTEL_1)
goto illegal_op;
if (!s->pe) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(pc_start - s->cs_base);
gen_helper_sysenter();
gen_eob(s);
}
break;
case 0x135: /* sysexit */
/* For Intel SYSEXIT is valid on 64-bit */
if (CODE64(s) && cpu_single_env->cpuid_vendor1 != CPUID_VENDOR_INTEL_1)
goto illegal_op;
if (!s->pe) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(pc_start - s->cs_base);
gen_helper_sysexit(tcg_const_i32(dflag));
gen_eob(s);
}
break;
#ifdef TARGET_X86_64
case 0x105: /* syscall */
/* XXX: is it usable in real mode ? */
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(pc_start - s->cs_base);
gen_helper_syscall(tcg_const_i32(s->pc - pc_start));
gen_eob(s);
break;
case 0x107: /* sysret */
if (!s->pe) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(pc_start - s->cs_base);
gen_helper_sysret(tcg_const_i32(s->dflag));
/* condition codes are modified only in long mode */
if (s->lma)
s->cc_op = CC_OP_EFLAGS;
gen_eob(s);
}
break;
#endif
case 0x1a2: /* cpuid */
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_cpuid();
break;
case 0xf4: /* hlt */
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_hlt(tcg_const_i32(s->pc - pc_start));
s->is_jmp = 3;
}
break;
case 0x100:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
op = (modrm >> 3) & 7;
switch(op) {
case 0: /* sldt */
if (!s->pe || s->vm86)
goto illegal_op;
gen_svm_check_intercept(s, pc_start, SVM_EXIT_LDTR_READ);
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,ldt.selector));
ot = OT_WORD;
if (mod == 3)
ot += s->dflag;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 1);
break;
case 2: /* lldt */
if (!s->pe || s->vm86)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_LDTR_WRITE);
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
gen_jmp_im(pc_start - s->cs_base);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_lldt(cpu_tmp2_i32);
}
break;
case 1: /* str */
if (!s->pe || s->vm86)
goto illegal_op;
gen_svm_check_intercept(s, pc_start, SVM_EXIT_TR_READ);
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,tr.selector));
ot = OT_WORD;
if (mod == 3)
ot += s->dflag;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 1);
break;
case 3: /* ltr */
if (!s->pe || s->vm86)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_TR_WRITE);
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
gen_jmp_im(pc_start - s->cs_base);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_ltr(cpu_tmp2_i32);
}
break;
case 4: /* verr */
case 5: /* verw */
if (!s->pe || s->vm86)
goto illegal_op;
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
if (op == 4)
gen_helper_verr(cpu_T[0]);
else
gen_helper_verw(cpu_T[0]);
s->cc_op = CC_OP_EFLAGS;
break;
default:
goto illegal_op;
}
break;
case 0x101:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
op = (modrm >> 3) & 7;
rm = modrm & 7;
switch(op) {
case 0: /* sgdt */
if (mod == 3)
goto illegal_op;
gen_svm_check_intercept(s, pc_start, SVM_EXIT_GDTR_READ);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, gdt.limit));
gen_op_st_T0_A0(OT_WORD + s->mem_index);
gen_add_A0_im(s, 2);
tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, gdt.base));
if (!s->dflag)
gen_op_andl_T0_im(0xffffff);
gen_op_st_T0_A0(CODE64(s) + OT_LONG + s->mem_index);
break;
case 1:
if (mod == 3) {
switch (rm) {
case 0: /* monitor */
if (!(s->cpuid_ext_features & CPUID_EXT_MONITOR) ||
s->cpl != 0)
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
#ifdef TARGET_X86_64
if (s->aflag == 2) {
gen_op_movq_A0_reg(R_EAX);
} else
#endif
{
gen_op_movl_A0_reg(R_EAX);
if (s->aflag == 0)
gen_op_andl_A0_ffff();
}
gen_add_A0_ds_seg(s);
gen_helper_monitor(cpu_A0);
break;
case 1: /* mwait */
if (!(s->cpuid_ext_features & CPUID_EXT_MONITOR) ||
s->cpl != 0)
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(pc_start - s->cs_base);
gen_helper_mwait(tcg_const_i32(s->pc - pc_start));
gen_eob(s);
break;
default:
goto illegal_op;
}
} else { /* sidt */
gen_svm_check_intercept(s, pc_start, SVM_EXIT_IDTR_READ);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, idt.limit));
gen_op_st_T0_A0(OT_WORD + s->mem_index);
gen_add_A0_im(s, 2);
tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, idt.base));
if (!s->dflag)
gen_op_andl_T0_im(0xffffff);
gen_op_st_T0_A0(CODE64(s) + OT_LONG + s->mem_index);
}
break;
case 2: /* lgdt */
case 3: /* lidt */
if (mod == 3) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
switch(rm) {
case 0: /* VMRUN */
if (!(s->flags & HF_SVME_MASK) || !s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_vmrun(tcg_const_i32(s->aflag),
tcg_const_i32(s->pc - pc_start));
tcg_gen_exit_tb(0);
s->is_jmp = 3;
}
break;
case 1: /* VMMCALL */
if (!(s->flags & HF_SVME_MASK))
goto illegal_op;
gen_helper_vmmcall();
break;
case 2: /* VMLOAD */
if (!(s->flags & HF_SVME_MASK) || !s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_vmload(tcg_const_i32(s->aflag));
}
break;
case 3: /* VMSAVE */
if (!(s->flags & HF_SVME_MASK) || !s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_vmsave(tcg_const_i32(s->aflag));
}
break;
case 4: /* STGI */
if ((!(s->flags & HF_SVME_MASK) &&
!(s->cpuid_ext3_features & CPUID_EXT3_SKINIT)) ||
!s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_stgi();
}
break;
case 5: /* CLGI */
if (!(s->flags & HF_SVME_MASK) || !s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_clgi();
}
break;
case 6: /* SKINIT */
if ((!(s->flags & HF_SVME_MASK) &&
!(s->cpuid_ext3_features & CPUID_EXT3_SKINIT)) ||
!s->pe)
goto illegal_op;
gen_helper_skinit();
break;
case 7: /* INVLPGA */
if (!(s->flags & HF_SVME_MASK) || !s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_invlpga(tcg_const_i32(s->aflag));
}
break;
default:
goto illegal_op;
}
} else if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start,
op==2 ? SVM_EXIT_GDTR_WRITE : SVM_EXIT_IDTR_WRITE);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T1_A0(OT_WORD + s->mem_index);
gen_add_A0_im(s, 2);
gen_op_ld_T0_A0(CODE64(s) + OT_LONG + s->mem_index);
if (!s->dflag)
gen_op_andl_T0_im(0xffffff);
if (op == 2) {
tcg_gen_st_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,gdt.base));
tcg_gen_st32_tl(cpu_T[1], cpu_env, offsetof(CPUX86State,gdt.limit));
} else {
tcg_gen_st_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,idt.base));
tcg_gen_st32_tl(cpu_T[1], cpu_env, offsetof(CPUX86State,idt.limit));
}
}
break;
case 4: /* smsw */
gen_svm_check_intercept(s, pc_start, SVM_EXIT_READ_CR0);
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,cr[0]));
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 1);
break;
case 6: /* lmsw */
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_WRITE_CR0);
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
gen_helper_lmsw(cpu_T[0]);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 7: /* invlpg */
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (mod == 3) {
#ifdef TARGET_X86_64
if (CODE64(s) && rm == 0) {
/* swapgs */
tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,segs[R_GS].base));
tcg_gen_ld_tl(cpu_T[1], cpu_env, offsetof(CPUX86State,kernelgsbase));
tcg_gen_st_tl(cpu_T[1], cpu_env, offsetof(CPUX86State,segs[R_GS].base));
tcg_gen_st_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,kernelgsbase));
} else
#endif
{
goto illegal_op;
}
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_helper_invlpg(cpu_A0);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
}
break;
default:
goto illegal_op;
}
break;
case 0x108: /* invd */
case 0x109: /* wbinvd */
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start, (b & 2) ? SVM_EXIT_INVD : SVM_EXIT_WBINVD);
/* nothing to do */
}
break;
case 0x63: /* arpl or movslS (x86_64) */
#ifdef TARGET_X86_64
if (CODE64(s)) {
int d_ot;
/* d_ot is the size of destination */
d_ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
if (mod == 3) {
gen_op_mov_TN_reg(OT_LONG, 0, rm);
/* sign extend */
if (d_ot == OT_QUAD)
tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(d_ot, reg);
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (d_ot == OT_QUAD) {
gen_op_lds_T0_A0(OT_LONG + s->mem_index);
} else {
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
}
gen_op_mov_reg_T0(d_ot, reg);
}
} else
#endif
{
int label1;
TCGv t0, t1, t2;
if (!s->pe || s->vm86)
goto illegal_op;
t0 = tcg_temp_local_new();
t1 = tcg_temp_local_new();
t2 = tcg_temp_local_new();
ot = OT_WORD;
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
rm = modrm & 7;
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_v(ot + s->mem_index, t0, cpu_A0);
} else {
gen_op_mov_v_reg(ot, t0, rm);
}
gen_op_mov_v_reg(ot, t1, reg);
tcg_gen_andi_tl(cpu_tmp0, t0, 3);
tcg_gen_andi_tl(t1, t1, 3);
tcg_gen_movi_tl(t2, 0);
label1 = gen_new_label();
tcg_gen_brcond_tl(TCG_COND_GE, cpu_tmp0, t1, label1);
tcg_gen_andi_tl(t0, t0, ~3);
tcg_gen_or_tl(t0, t0, t1);
tcg_gen_movi_tl(t2, CC_Z);
gen_set_label(label1);
if (mod != 3) {
gen_op_st_v(ot + s->mem_index, t0, cpu_A0);
} else {
gen_op_mov_reg_v(ot, rm, t0);
}
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_cc_src);
tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, ~CC_Z);
tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, t2);
s->cc_op = CC_OP_EFLAGS;
tcg_temp_free(t0);
tcg_temp_free(t1);
tcg_temp_free(t2);
}
break;
case 0x102: /* lar */
case 0x103: /* lsl */
{
int label1;
TCGv t0;
if (!s->pe || s->vm86)
goto illegal_op;
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
t0 = tcg_temp_local_new();
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
if (b == 0x102)
gen_helper_lar(t0, cpu_T[0]);
else
gen_helper_lsl(t0, cpu_T[0]);
tcg_gen_andi_tl(cpu_tmp0, cpu_cc_src, CC_Z);
label1 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_tmp0, 0, label1);
gen_op_mov_reg_v(ot, reg, t0);
gen_set_label(label1);
s->cc_op = CC_OP_EFLAGS;
tcg_temp_free(t0);
}
break;
case 0x118:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
op = (modrm >> 3) & 7;
switch(op) {
case 0: /* prefetchnta */
case 1: /* prefetchnt0 */
case 2: /* prefetchnt0 */
case 3: /* prefetchnt0 */
if (mod == 3)
goto illegal_op;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
/* nothing more to do */
break;
default: /* nop (multi byte) */
gen_nop_modrm(s, modrm);
break;
}
break;
case 0x119 ... 0x11f: /* nop (multi byte) */
modrm = ldub_code(s->pc++);
gen_nop_modrm(s, modrm);
break;
case 0x120: /* mov reg, crN */
case 0x122: /* mov crN, reg */
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
modrm = ldub_code(s->pc++);
if ((modrm & 0xc0) != 0xc0)
goto illegal_op;
rm = (modrm & 7) | REX_B(s);
reg = ((modrm >> 3) & 7) | rex_r;
if (CODE64(s))
ot = OT_QUAD;
else
ot = OT_LONG;
switch(reg) {
case 0:
case 2:
case 3:
case 4:
case 8:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
if (b & 2) {
gen_op_mov_TN_reg(ot, 0, rm);
gen_helper_write_crN(tcg_const_i32(reg), cpu_T[0]);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
} else {
gen_helper_read_crN(cpu_T[0], tcg_const_i32(reg));
gen_op_mov_reg_T0(ot, rm);
}
break;
default:
goto illegal_op;
}
}
break;
case 0x121: /* mov reg, drN */
case 0x123: /* mov drN, reg */
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
modrm = ldub_code(s->pc++);
if ((modrm & 0xc0) != 0xc0)
goto illegal_op;
rm = (modrm & 7) | REX_B(s);
reg = ((modrm >> 3) & 7) | rex_r;
if (CODE64(s))
ot = OT_QUAD;
else
ot = OT_LONG;
/* XXX: do it dynamically with CR4.DE bit */
if (reg == 4 || reg == 5 || reg >= 8)
goto illegal_op;
if (b & 2) {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_WRITE_DR0 + reg);
gen_op_mov_TN_reg(ot, 0, rm);
gen_helper_movl_drN_T0(tcg_const_i32(reg), cpu_T[0]);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_READ_DR0 + reg);
tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,dr[reg]));
gen_op_mov_reg_T0(ot, rm);
}
}
break;
case 0x106: /* clts */
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_WRITE_CR0);
gen_helper_clts();
/* abort block because static cpu state changed */
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
/* MMX/3DNow!/SSE/SSE2/SSE3/SSSE3/SSE4 support */
case 0x1c3: /* MOVNTI reg, mem */
if (!(s->cpuid_features & CPUID_SSE2))
goto illegal_op;
ot = s->dflag == 2 ? OT_QUAD : OT_LONG;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
reg = ((modrm >> 3) & 7) | rex_r;
/* generate a generic store */
gen_ldst_modrm(s, modrm, ot, reg, 1);
break;
case 0x1ae:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
op = (modrm >> 3) & 7;
switch(op) {
case 0: /* fxsave */
if (mod == 3 || !(s->cpuid_features & CPUID_FXSR) ||
(s->flags & HF_EM_MASK))
goto illegal_op;
if (s->flags & HF_TS_MASK) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
break;
}
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fxsave(cpu_A0, tcg_const_i32((s->dflag == 2)));
break;
case 1: /* fxrstor */
if (mod == 3 || !(s->cpuid_features & CPUID_FXSR) ||
(s->flags & HF_EM_MASK))
goto illegal_op;
if (s->flags & HF_TS_MASK) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
break;
}
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fxrstor(cpu_A0, tcg_const_i32((s->dflag == 2)));
break;
case 2: /* ldmxcsr */
case 3: /* stmxcsr */
if (s->flags & HF_TS_MASK) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
break;
}
if ((s->flags & HF_EM_MASK) || !(s->flags & HF_OSFXSR_MASK) ||
mod == 3)
goto illegal_op;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (op == 2) {
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
tcg_gen_st32_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, mxcsr));
} else {
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, mxcsr));
gen_op_st_T0_A0(OT_LONG + s->mem_index);
}
break;
case 5: /* lfence */
case 6: /* mfence */
if ((modrm & 0xc7) != 0xc0 || !(s->cpuid_features & CPUID_SSE))
goto illegal_op;
break;
case 7: /* sfence / clflush */
if ((modrm & 0xc7) == 0xc0) {
/* sfence */
/* XXX: also check for cpuid_ext2_features & CPUID_EXT2_EMMX */
if (!(s->cpuid_features & CPUID_SSE))
goto illegal_op;
} else {
/* clflush */
if (!(s->cpuid_features & CPUID_CLFLUSH))
goto illegal_op;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
}
break;
default:
goto illegal_op;
}
break;
case 0x10d: /* 3DNow! prefetch(w) */
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
/* ignore for now */
break;
case 0x1aa: /* rsm */
gen_svm_check_intercept(s, pc_start, SVM_EXIT_RSM);
if (!(s->flags & HF_SMM_MASK))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(s->pc - s->cs_base);
gen_helper_rsm();
gen_eob(s);
break;
case 0x1b8: /* SSE4.2 popcnt */
if ((prefixes & (PREFIX_REPZ | PREFIX_LOCK | PREFIX_REPNZ)) !=
PREFIX_REPZ)
goto illegal_op;
if (!(s->cpuid_ext_features & CPUID_EXT_POPCNT))
goto illegal_op;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7);
if (s->prefix & PREFIX_DATA)
ot = OT_WORD;
else if (s->dflag != 2)
ot = OT_LONG;
else
ot = OT_QUAD;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
gen_helper_popcnt(cpu_T[0], cpu_T[0], tcg_const_i32(ot));
gen_op_mov_reg_T0(ot, reg);
s->cc_op = CC_OP_EFLAGS;
break;
case 0x10e ... 0x10f:
/* 3DNow! instructions, ignore prefixes */
s->prefix &= ~(PREFIX_REPZ | PREFIX_REPNZ | PREFIX_DATA);
case 0x110 ... 0x117:
case 0x128 ... 0x12f:
case 0x138 ... 0x13a:
case 0x150 ... 0x177:
case 0x17c ... 0x17f:
case 0x1c2:
case 0x1c4 ... 0x1c6:
case 0x1d0 ... 0x1fe:
gen_sse(s, b, pc_start, rex_r);
break;
default:
goto illegal_op;
}
/* lock generation */
if (s->prefix & PREFIX_LOCK)
gen_helper_unlock();
return s->pc;
illegal_op:
if (s->prefix & PREFIX_LOCK)
gen_helper_unlock();
/* XXX: ensure that no lock was generated */
gen_exception(s, EXCP06_ILLOP, pc_start - s->cs_base);
return s->pc;
} | true | qemu | 32938e127f50a40844a0fb9c5abb8691aeeccf7e | static target_ulong disas_insn(DisasContext *s, target_ulong pc_start)
{
int b, prefixes, aflag, dflag;
int shift, ot;
int modrm, reg, rm, mod, reg_addr, op, opreg, offset_addr, val;
target_ulong next_eip, tval;
int rex_w, rex_r;
if (unlikely(loglevel & CPU_LOG_TB_OP))
tcg_gen_debug_insn_start(pc_start);
s->pc = pc_start;
prefixes = 0;
aflag = s->code32;
dflag = s->code32;
s->override = -1;
rex_w = -1;
rex_r = 0;
#ifdef TARGET_X86_64
s->rex_x = 0;
s->rex_b = 0;
x86_64_hregs = 0;
#endif
s->rip_offset = 0;
next_byte:
b = ldub_code(s->pc);
s->pc++;
#ifdef TARGET_X86_64
if (CODE64(s)) {
switch (b) {
case 0xf3:
prefixes |= PREFIX_REPZ;
goto next_byte;
case 0xf2:
prefixes |= PREFIX_REPNZ;
goto next_byte;
case 0xf0:
prefixes |= PREFIX_LOCK;
goto next_byte;
case 0x2e:
s->override = R_CS;
goto next_byte;
case 0x36:
s->override = R_SS;
goto next_byte;
case 0x3e:
s->override = R_DS;
goto next_byte;
case 0x26:
s->override = R_ES;
goto next_byte;
case 0x64:
s->override = R_FS;
goto next_byte;
case 0x65:
s->override = R_GS;
goto next_byte;
case 0x66:
prefixes |= PREFIX_DATA;
goto next_byte;
case 0x67:
prefixes |= PREFIX_ADR;
goto next_byte;
case 0x40 ... 0x4f:
rex_w = (b >> 3) & 1;
rex_r = (b & 0x4) << 1;
s->rex_x = (b & 0x2) << 2;
REX_B(s) = (b & 0x1) << 3;
x86_64_hregs = 1;
goto next_byte;
}
if (rex_w == 1) {
dflag = 2;
} else {
if (prefixes & PREFIX_DATA)
dflag ^= 1;
}
if (!(prefixes & PREFIX_ADR))
aflag = 2;
} else
#endif
{
switch (b) {
case 0xf3:
prefixes |= PREFIX_REPZ;
goto next_byte;
case 0xf2:
prefixes |= PREFIX_REPNZ;
goto next_byte;
case 0xf0:
prefixes |= PREFIX_LOCK;
goto next_byte;
case 0x2e:
s->override = R_CS;
goto next_byte;
case 0x36:
s->override = R_SS;
goto next_byte;
case 0x3e:
s->override = R_DS;
goto next_byte;
case 0x26:
s->override = R_ES;
goto next_byte;
case 0x64:
s->override = R_FS;
goto next_byte;
case 0x65:
s->override = R_GS;
goto next_byte;
case 0x66:
prefixes |= PREFIX_DATA;
goto next_byte;
case 0x67:
prefixes |= PREFIX_ADR;
goto next_byte;
}
if (prefixes & PREFIX_DATA)
dflag ^= 1;
if (prefixes & PREFIX_ADR)
aflag ^= 1;
}
s->prefix = prefixes;
s->aflag = aflag;
s->dflag = dflag;
if (prefixes & PREFIX_LOCK)
gen_helper_lock();
reswitch:
switch(b) {
case 0x0f:
b = ldub_code(s->pc++) | 0x100;
goto reswitch;
case 0x00 ... 0x05:
case 0x08 ... 0x0d:
case 0x10 ... 0x15:
case 0x18 ... 0x1d:
case 0x20 ... 0x25:
case 0x28 ... 0x2d:
case 0x30 ... 0x35:
case 0x38 ... 0x3d:
{
int op, f, val;
op = (b >> 3) & 7;
f = (b >> 1) & 3;
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
switch(f) {
case 0:
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
opreg = OR_TMP0;
} else if (op == OP_XORL && rm == reg) {
xor_zero:
gen_op_movl_T0_0();
s->cc_op = CC_OP_LOGICB + ot;
gen_op_mov_reg_T0(ot, reg);
gen_op_update1_cc();
break;
} else {
opreg = rm;
}
gen_op_mov_TN_reg(ot, 1, reg);
gen_op(s, op, ot, opreg);
break;
case 1:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
reg = ((modrm >> 3) & 7) | rex_r;
rm = (modrm & 7) | REX_B(s);
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T1_A0(ot + s->mem_index);
} else if (op == OP_XORL && rm == reg) {
goto xor_zero;
} else {
gen_op_mov_TN_reg(ot, 1, rm);
}
gen_op(s, op, ot, reg);
break;
case 2:
val = insn_get(s, ot);
gen_op_movl_T1_im(val);
gen_op(s, op, ot, OR_EAX);
break;
}
}
break;
case 0x82:
if (CODE64(s))
goto illegal_op;
case 0x80:
case 0x81:
case 0x83:
{
int val;
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
op = (modrm >> 3) & 7;
if (mod != 3) {
if (b == 0x83)
s->rip_offset = 1;
else
s->rip_offset = insn_const_size(ot);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
opreg = OR_TMP0;
} else {
opreg = rm;
}
switch(b) {
default:
case 0x80:
case 0x81:
case 0x82:
val = insn_get(s, ot);
break;
case 0x83:
val = (int8_t)insn_get(s, OT_BYTE);
break;
}
gen_op_movl_T1_im(val);
gen_op(s, op, ot, opreg);
}
break;
case 0x40 ... 0x47:
ot = dflag ? OT_LONG : OT_WORD;
gen_inc(s, ot, OR_EAX + (b & 7), 1);
break;
case 0x48 ... 0x4f:
ot = dflag ? OT_LONG : OT_WORD;
gen_inc(s, ot, OR_EAX + (b & 7), -1);
break;
case 0xf6:
case 0xf7:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
op = (modrm >> 3) & 7;
if (mod != 3) {
if (op == 0)
s->rip_offset = insn_const_size(ot);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T0_A0(ot + s->mem_index);
} else {
gen_op_mov_TN_reg(ot, 0, rm);
}
switch(op) {
case 0:
val = insn_get(s, ot);
gen_op_movl_T1_im(val);
gen_op_testl_T0_T1_cc();
s->cc_op = CC_OP_LOGICB + ot;
break;
case 2:
tcg_gen_not_tl(cpu_T[0], cpu_T[0]);
if (mod != 3) {
gen_op_st_T0_A0(ot + s->mem_index);
} else {
gen_op_mov_reg_T0(ot, rm);
}
break;
case 3:
tcg_gen_neg_tl(cpu_T[0], cpu_T[0]);
if (mod != 3) {
gen_op_st_T0_A0(ot + s->mem_index);
} else {
gen_op_mov_reg_T0(ot, rm);
}
gen_op_update_neg_cc();
s->cc_op = CC_OP_SUBB + ot;
break;
case 4:
switch(ot) {
case OT_BYTE:
gen_op_mov_TN_reg(OT_BYTE, 1, R_EAX);
tcg_gen_ext8u_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext8u_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_andi_tl(cpu_cc_src, cpu_T[0], 0xff00);
s->cc_op = CC_OP_MULB;
break;
case OT_WORD:
gen_op_mov_TN_reg(OT_WORD, 1, R_EAX);
tcg_gen_ext16u_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext16u_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_shri_tl(cpu_T[0], cpu_T[0], 16);
gen_op_mov_reg_T0(OT_WORD, R_EDX);
tcg_gen_mov_tl(cpu_cc_src, cpu_T[0]);
s->cc_op = CC_OP_MULW;
break;
default:
case OT_LONG:
#ifdef TARGET_X86_64
gen_op_mov_TN_reg(OT_LONG, 1, R_EAX);
tcg_gen_ext32u_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext32u_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_LONG, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_shri_tl(cpu_T[0], cpu_T[0], 32);
gen_op_mov_reg_T0(OT_LONG, R_EDX);
tcg_gen_mov_tl(cpu_cc_src, cpu_T[0]);
#else
{
TCGv_i64 t0, t1;
t0 = tcg_temp_new_i64();
t1 = tcg_temp_new_i64();
gen_op_mov_TN_reg(OT_LONG, 1, R_EAX);
tcg_gen_extu_i32_i64(t0, cpu_T[0]);
tcg_gen_extu_i32_i64(t1, cpu_T[1]);
tcg_gen_mul_i64(t0, t0, t1);
tcg_gen_trunc_i64_i32(cpu_T[0], t0);
gen_op_mov_reg_T0(OT_LONG, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_shri_i64(t0, t0, 32);
tcg_gen_trunc_i64_i32(cpu_T[0], t0);
gen_op_mov_reg_T0(OT_LONG, R_EDX);
tcg_gen_mov_tl(cpu_cc_src, cpu_T[0]);
}
#endif
s->cc_op = CC_OP_MULL;
break;
#ifdef TARGET_X86_64
case OT_QUAD:
gen_helper_mulq_EAX_T0(cpu_T[0]);
s->cc_op = CC_OP_MULQ;
break;
#endif
}
break;
case 5:
switch(ot) {
case OT_BYTE:
gen_op_mov_TN_reg(OT_BYTE, 1, R_EAX);
tcg_gen_ext8s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext8s_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_ext8s_tl(cpu_tmp0, cpu_T[0]);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
s->cc_op = CC_OP_MULB;
break;
case OT_WORD:
gen_op_mov_TN_reg(OT_WORD, 1, R_EAX);
tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext16s_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_ext16s_tl(cpu_tmp0, cpu_T[0]);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
tcg_gen_shri_tl(cpu_T[0], cpu_T[0], 16);
gen_op_mov_reg_T0(OT_WORD, R_EDX);
s->cc_op = CC_OP_MULW;
break;
default:
case OT_LONG:
#ifdef TARGET_X86_64
gen_op_mov_TN_reg(OT_LONG, 1, R_EAX);
tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext32s_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_LONG, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_ext32s_tl(cpu_tmp0, cpu_T[0]);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
tcg_gen_shri_tl(cpu_T[0], cpu_T[0], 32);
gen_op_mov_reg_T0(OT_LONG, R_EDX);
#else
{
TCGv_i64 t0, t1;
t0 = tcg_temp_new_i64();
t1 = tcg_temp_new_i64();
gen_op_mov_TN_reg(OT_LONG, 1, R_EAX);
tcg_gen_ext_i32_i64(t0, cpu_T[0]);
tcg_gen_ext_i32_i64(t1, cpu_T[1]);
tcg_gen_mul_i64(t0, t0, t1);
tcg_gen_trunc_i64_i32(cpu_T[0], t0);
gen_op_mov_reg_T0(OT_LONG, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_sari_tl(cpu_tmp0, cpu_T[0], 31);
tcg_gen_shri_i64(t0, t0, 32);
tcg_gen_trunc_i64_i32(cpu_T[0], t0);
gen_op_mov_reg_T0(OT_LONG, R_EDX);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
}
#endif
s->cc_op = CC_OP_MULL;
break;
#ifdef TARGET_X86_64
case OT_QUAD:
gen_helper_imulq_EAX_T0(cpu_T[0]);
s->cc_op = CC_OP_MULQ;
break;
#endif
}
break;
case 6:
switch(ot) {
case OT_BYTE:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_divb_AL(cpu_T[0]);
break;
case OT_WORD:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_divw_AX(cpu_T[0]);
break;
default:
case OT_LONG:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_divl_EAX(cpu_T[0]);
break;
#ifdef TARGET_X86_64
case OT_QUAD:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_divq_EAX(cpu_T[0]);
break;
#endif
}
break;
case 7:
switch(ot) {
case OT_BYTE:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_idivb_AL(cpu_T[0]);
break;
case OT_WORD:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_idivw_AX(cpu_T[0]);
break;
default:
case OT_LONG:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_idivl_EAX(cpu_T[0]);
break;
#ifdef TARGET_X86_64
case OT_QUAD:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_idivq_EAX(cpu_T[0]);
break;
#endif
}
break;
default:
goto illegal_op;
}
break;
case 0xfe:
case 0xff:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
op = (modrm >> 3) & 7;
if (op >= 2 && b == 0xfe) {
goto illegal_op;
}
if (CODE64(s)) {
if (op == 2 || op == 4) {
ot = OT_QUAD;
} else if (op == 3 || op == 5) {
ot = dflag ? OT_LONG : OT_WORD;
} else if (op == 6) {
ot = dflag ? OT_QUAD : OT_WORD;
}
}
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (op >= 2 && op != 3 && op != 5)
gen_op_ld_T0_A0(ot + s->mem_index);
} else {
gen_op_mov_TN_reg(ot, 0, rm);
}
switch(op) {
case 0:
if (mod != 3)
opreg = OR_TMP0;
else
opreg = rm;
gen_inc(s, ot, opreg, 1);
break;
case 1:
if (mod != 3)
opreg = OR_TMP0;
else
opreg = rm;
gen_inc(s, ot, opreg, -1);
break;
case 2:
if (s->dflag == 0)
gen_op_andl_T0_ffff();
next_eip = s->pc - s->cs_base;
gen_movtl_T1_im(next_eip);
gen_push_T1(s);
gen_op_jmp_T0();
gen_eob(s);
break;
case 3:
gen_op_ld_T1_A0(ot + s->mem_index);
gen_add_A0_im(s, 1 << (ot - OT_WORD + 1));
gen_op_ldu_T0_A0(OT_WORD + s->mem_index);
do_lcall:
if (s->pe && !s->vm86) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_lcall_protected(cpu_tmp2_i32, cpu_T[1],
tcg_const_i32(dflag),
tcg_const_i32(s->pc - pc_start));
} else {
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_lcall_real(cpu_tmp2_i32, cpu_T[1],
tcg_const_i32(dflag),
tcg_const_i32(s->pc - s->cs_base));
}
gen_eob(s);
break;
case 4:
if (s->dflag == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
gen_eob(s);
break;
case 5:
gen_op_ld_T1_A0(ot + s->mem_index);
gen_add_A0_im(s, 1 << (ot - OT_WORD + 1));
gen_op_ldu_T0_A0(OT_WORD + s->mem_index);
do_ljmp:
if (s->pe && !s->vm86) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_ljmp_protected(cpu_tmp2_i32, cpu_T[1],
tcg_const_i32(s->pc - pc_start));
} else {
gen_op_movl_seg_T0_vm(R_CS);
gen_op_movl_T0_T1();
gen_op_jmp_T0();
}
gen_eob(s);
break;
case 6:
gen_push_T0(s);
break;
default:
goto illegal_op;
}
break;
case 0x84:
case 0x85:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
reg = ((modrm >> 3) & 7) | rex_r;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
gen_op_mov_TN_reg(ot, 1, reg);
gen_op_testl_T0_T1_cc();
s->cc_op = CC_OP_LOGICB + ot;
break;
case 0xa8:
case 0xa9:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
val = insn_get(s, ot);
gen_op_mov_TN_reg(ot, 0, OR_EAX);
gen_op_movl_T1_im(val);
gen_op_testl_T0_T1_cc();
s->cc_op = CC_OP_LOGICB + ot;
break;
case 0x98:
#ifdef TARGET_X86_64
if (dflag == 2) {
gen_op_mov_TN_reg(OT_LONG, 0, R_EAX);
tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_QUAD, R_EAX);
} else
#endif
if (dflag == 1) {
gen_op_mov_TN_reg(OT_WORD, 0, R_EAX);
tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_LONG, R_EAX);
} else {
gen_op_mov_TN_reg(OT_BYTE, 0, R_EAX);
tcg_gen_ext8s_tl(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
}
break;
case 0x99:
#ifdef TARGET_X86_64
if (dflag == 2) {
gen_op_mov_TN_reg(OT_QUAD, 0, R_EAX);
tcg_gen_sari_tl(cpu_T[0], cpu_T[0], 63);
gen_op_mov_reg_T0(OT_QUAD, R_EDX);
} else
#endif
if (dflag == 1) {
gen_op_mov_TN_reg(OT_LONG, 0, R_EAX);
tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_sari_tl(cpu_T[0], cpu_T[0], 31);
gen_op_mov_reg_T0(OT_LONG, R_EDX);
} else {
gen_op_mov_TN_reg(OT_WORD, 0, R_EAX);
tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_sari_tl(cpu_T[0], cpu_T[0], 15);
gen_op_mov_reg_T0(OT_WORD, R_EDX);
}
break;
case 0x1af:
case 0x69:
case 0x6b:
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
if (b == 0x69)
s->rip_offset = insn_const_size(ot);
else if (b == 0x6b)
s->rip_offset = 1;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
if (b == 0x69) {
val = insn_get(s, ot);
gen_op_movl_T1_im(val);
} else if (b == 0x6b) {
val = (int8_t)insn_get(s, OT_BYTE);
gen_op_movl_T1_im(val);
} else {
gen_op_mov_TN_reg(ot, 1, reg);
}
#ifdef TARGET_X86_64
if (ot == OT_QUAD) {
gen_helper_imulq_T0_T1(cpu_T[0], cpu_T[0], cpu_T[1]);
} else
#endif
if (ot == OT_LONG) {
#ifdef TARGET_X86_64
tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext32s_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_ext32s_tl(cpu_tmp0, cpu_T[0]);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
#else
{
TCGv_i64 t0, t1;
t0 = tcg_temp_new_i64();
t1 = tcg_temp_new_i64();
tcg_gen_ext_i32_i64(t0, cpu_T[0]);
tcg_gen_ext_i32_i64(t1, cpu_T[1]);
tcg_gen_mul_i64(t0, t0, t1);
tcg_gen_trunc_i64_i32(cpu_T[0], t0);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_sari_tl(cpu_tmp0, cpu_T[0], 31);
tcg_gen_shri_i64(t0, t0, 32);
tcg_gen_trunc_i64_i32(cpu_T[1], t0);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[1], cpu_tmp0);
}
#endif
} else {
tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext16s_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_ext16s_tl(cpu_tmp0, cpu_T[0]);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
}
gen_op_mov_reg_T0(ot, reg);
s->cc_op = CC_OP_MULB + ot;
break;
case 0x1c0:
case 0x1c1:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
if (mod == 3) {
rm = (modrm & 7) | REX_B(s);
gen_op_mov_TN_reg(ot, 0, reg);
gen_op_mov_TN_reg(ot, 1, rm);
gen_op_addl_T0_T1();
gen_op_mov_reg_T1(ot, reg);
gen_op_mov_reg_T0(ot, rm);
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_mov_TN_reg(ot, 0, reg);
gen_op_ld_T1_A0(ot + s->mem_index);
gen_op_addl_T0_T1();
gen_op_st_T0_A0(ot + s->mem_index);
gen_op_mov_reg_T1(ot, reg);
}
gen_op_update2_cc();
s->cc_op = CC_OP_ADDB + ot;
break;
case 0x1b0:
case 0x1b1:
{
int label1, label2;
TCGv t0, t1, t2, a0;
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
t0 = tcg_temp_local_new();
t1 = tcg_temp_local_new();
t2 = tcg_temp_local_new();
a0 = tcg_temp_local_new();
gen_op_mov_v_reg(ot, t1, reg);
if (mod == 3) {
rm = (modrm & 7) | REX_B(s);
gen_op_mov_v_reg(ot, t0, rm);
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
tcg_gen_mov_tl(a0, cpu_A0);
gen_op_ld_v(ot + s->mem_index, t0, a0);
rm = 0;
}
label1 = gen_new_label();
tcg_gen_ld_tl(t2, cpu_env, offsetof(CPUState, regs[R_EAX]));
tcg_gen_sub_tl(t2, t2, t0);
gen_extu(ot, t2);
tcg_gen_brcondi_tl(TCG_COND_EQ, t2, 0, label1);
if (mod == 3) {
label2 = gen_new_label();
gen_op_mov_reg_v(ot, R_EAX, t0);
tcg_gen_br(label2);
gen_set_label(label1);
gen_op_mov_reg_v(ot, rm, t1);
gen_set_label(label2);
} else {
tcg_gen_mov_tl(t1, t0);
gen_op_mov_reg_v(ot, R_EAX, t0);
gen_set_label(label1);
gen_op_st_v(ot + s->mem_index, t1, a0);
}
tcg_gen_mov_tl(cpu_cc_src, t0);
tcg_gen_mov_tl(cpu_cc_dst, t2);
s->cc_op = CC_OP_SUBB + ot;
tcg_temp_free(t0);
tcg_temp_free(t1);
tcg_temp_free(t2);
tcg_temp_free(a0);
}
break;
case 0x1c7:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
if ((mod == 3) || ((modrm & 0x38) != 0x8))
goto illegal_op;
#ifdef TARGET_X86_64
if (dflag == 2) {
if (!(s->cpuid_ext_features & CPUID_EXT_CX16))
goto illegal_op;
gen_jmp_im(pc_start - s->cs_base);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_helper_cmpxchg16b(cpu_A0);
} else
#endif
{
if (!(s->cpuid_features & CPUID_CX8))
goto illegal_op;
gen_jmp_im(pc_start - s->cs_base);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_helper_cmpxchg8b(cpu_A0);
}
s->cc_op = CC_OP_EFLAGS;
break;
case 0x50 ... 0x57:
gen_op_mov_TN_reg(OT_LONG, 0, (b & 7) | REX_B(s));
gen_push_T0(s);
break;
case 0x58 ... 0x5f:
if (CODE64(s)) {
ot = dflag ? OT_QUAD : OT_WORD;
} else {
ot = dflag + OT_WORD;
}
gen_pop_T0(s);
gen_pop_update(s);
gen_op_mov_reg_T0(ot, (b & 7) | REX_B(s));
break;
case 0x60:
if (CODE64(s))
goto illegal_op;
gen_pusha(s);
break;
case 0x61:
if (CODE64(s))
goto illegal_op;
gen_popa(s);
break;
case 0x68:
case 0x6a:
if (CODE64(s)) {
ot = dflag ? OT_QUAD : OT_WORD;
} else {
ot = dflag + OT_WORD;
}
if (b == 0x68)
val = insn_get(s, ot);
else
val = (int8_t)insn_get(s, OT_BYTE);
gen_op_movl_T0_im(val);
gen_push_T0(s);
break;
case 0x8f:
if (CODE64(s)) {
ot = dflag ? OT_QUAD : OT_WORD;
} else {
ot = dflag + OT_WORD;
}
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
gen_pop_T0(s);
if (mod == 3) {
gen_pop_update(s);
rm = (modrm & 7) | REX_B(s);
gen_op_mov_reg_T0(ot, rm);
} else {
s->popl_esp_hack = 1 << ot;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 1);
s->popl_esp_hack = 0;
gen_pop_update(s);
}
break;
case 0xc8:
{
int level;
val = lduw_code(s->pc);
s->pc += 2;
level = ldub_code(s->pc++);
gen_enter(s, val, level);
}
break;
case 0xc9:
if (CODE64(s)) {
gen_op_mov_TN_reg(OT_QUAD, 0, R_EBP);
gen_op_mov_reg_T0(OT_QUAD, R_ESP);
} else if (s->ss32) {
gen_op_mov_TN_reg(OT_LONG, 0, R_EBP);
gen_op_mov_reg_T0(OT_LONG, R_ESP);
} else {
gen_op_mov_TN_reg(OT_WORD, 0, R_EBP);
gen_op_mov_reg_T0(OT_WORD, R_ESP);
}
gen_pop_T0(s);
if (CODE64(s)) {
ot = dflag ? OT_QUAD : OT_WORD;
} else {
ot = dflag + OT_WORD;
}
gen_op_mov_reg_T0(ot, R_EBP);
gen_pop_update(s);
break;
case 0x06:
case 0x0e:
case 0x16:
case 0x1e:
if (CODE64(s))
goto illegal_op;
gen_op_movl_T0_seg(b >> 3);
gen_push_T0(s);
break;
case 0x1a0:
case 0x1a8:
gen_op_movl_T0_seg((b >> 3) & 7);
gen_push_T0(s);
break;
case 0x07:
case 0x17:
case 0x1f:
if (CODE64(s))
goto illegal_op;
reg = b >> 3;
gen_pop_T0(s);
gen_movl_seg_T0(s, reg, pc_start - s->cs_base);
gen_pop_update(s);
if (reg == R_SS) {
if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK))
gen_helper_set_inhibit_irq();
s->tf = 0;
}
if (s->is_jmp) {
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x1a1:
case 0x1a9:
gen_pop_T0(s);
gen_movl_seg_T0(s, (b >> 3) & 7, pc_start - s->cs_base);
gen_pop_update(s);
if (s->is_jmp) {
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x88:
case 0x89:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
gen_ldst_modrm(s, modrm, ot, reg, 1);
break;
case 0xc6:
case 0xc7:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
if (mod != 3) {
s->rip_offset = insn_const_size(ot);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
}
val = insn_get(s, ot);
gen_op_movl_T0_im(val);
if (mod != 3)
gen_op_st_T0_A0(ot + s->mem_index);
else
gen_op_mov_reg_T0(ot, (modrm & 7) | REX_B(s));
break;
case 0x8a:
case 0x8b:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = OT_WORD + dflag;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
gen_op_mov_reg_T0(ot, reg);
break;
case 0x8e:
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
if (reg >= 6 || reg == R_CS)
goto illegal_op;
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
gen_movl_seg_T0(s, reg, pc_start - s->cs_base);
if (reg == R_SS) {
if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK))
gen_helper_set_inhibit_irq();
s->tf = 0;
}
if (s->is_jmp) {
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x8c:
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
if (reg >= 6)
goto illegal_op;
gen_op_movl_T0_seg(reg);
if (mod == 3)
ot = OT_WORD + dflag;
else
ot = OT_WORD;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 1);
break;
case 0x1b6:
case 0x1b7:
case 0x1be:
case 0x1bf:
{
int d_ot;
d_ot = dflag + OT_WORD;
ot = (b & 1) + OT_BYTE;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
if (mod == 3) {
gen_op_mov_TN_reg(ot, 0, rm);
switch(ot | (b & 8)) {
case OT_BYTE:
tcg_gen_ext8u_tl(cpu_T[0], cpu_T[0]);
break;
case OT_BYTE | 8:
tcg_gen_ext8s_tl(cpu_T[0], cpu_T[0]);
break;
case OT_WORD:
tcg_gen_ext16u_tl(cpu_T[0], cpu_T[0]);
break;
default:
case OT_WORD | 8:
tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);
break;
}
gen_op_mov_reg_T0(d_ot, reg);
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (b & 8) {
gen_op_lds_T0_A0(ot + s->mem_index);
} else {
gen_op_ldu_T0_A0(ot + s->mem_index);
}
gen_op_mov_reg_T0(d_ot, reg);
}
}
break;
case 0x8d:
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
reg = ((modrm >> 3) & 7) | rex_r;
s->override = -1;
val = s->addseg;
s->addseg = 0;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
s->addseg = val;
gen_op_mov_reg_A0(ot - OT_WORD, reg);
break;
case 0xa0:
case 0xa1:
case 0xa2:
case 0xa3:
{
target_ulong offset_addr;
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
#ifdef TARGET_X86_64
if (s->aflag == 2) {
offset_addr = ldq_code(s->pc);
s->pc += 8;
gen_op_movq_A0_im(offset_addr);
} else
#endif
{
if (s->aflag) {
offset_addr = insn_get(s, OT_LONG);
} else {
offset_addr = insn_get(s, OT_WORD);
}
gen_op_movl_A0_im(offset_addr);
}
gen_add_A0_ds_seg(s);
if ((b & 2) == 0) {
gen_op_ld_T0_A0(ot + s->mem_index);
gen_op_mov_reg_T0(ot, R_EAX);
} else {
gen_op_mov_TN_reg(ot, 0, R_EAX);
gen_op_st_T0_A0(ot + s->mem_index);
}
}
break;
case 0xd7:
#ifdef TARGET_X86_64
if (s->aflag == 2) {
gen_op_movq_A0_reg(R_EBX);
gen_op_mov_TN_reg(OT_QUAD, 0, R_EAX);
tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0xff);
tcg_gen_add_tl(cpu_A0, cpu_A0, cpu_T[0]);
} else
#endif
{
gen_op_movl_A0_reg(R_EBX);
gen_op_mov_TN_reg(OT_LONG, 0, R_EAX);
tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0xff);
tcg_gen_add_tl(cpu_A0, cpu_A0, cpu_T[0]);
if (s->aflag == 0)
gen_op_andl_A0_ffff();
else
tcg_gen_andi_tl(cpu_A0, cpu_A0, 0xffffffff);
}
gen_add_A0_ds_seg(s);
gen_op_ldu_T0_A0(OT_BYTE + s->mem_index);
gen_op_mov_reg_T0(OT_BYTE, R_EAX);
break;
case 0xb0 ... 0xb7:
val = insn_get(s, OT_BYTE);
gen_op_movl_T0_im(val);
gen_op_mov_reg_T0(OT_BYTE, (b & 7) | REX_B(s));
break;
case 0xb8 ... 0xbf:
#ifdef TARGET_X86_64
if (dflag == 2) {
uint64_t tmp;
tmp = ldq_code(s->pc);
s->pc += 8;
reg = (b & 7) | REX_B(s);
gen_movtl_T0_im(tmp);
gen_op_mov_reg_T0(OT_QUAD, reg);
} else
#endif
{
ot = dflag ? OT_LONG : OT_WORD;
val = insn_get(s, ot);
reg = (b & 7) | REX_B(s);
gen_op_movl_T0_im(val);
gen_op_mov_reg_T0(ot, reg);
}
break;
case 0x91 ... 0x97:
ot = dflag + OT_WORD;
reg = (b & 7) | REX_B(s);
rm = R_EAX;
goto do_xchg_reg;
case 0x86:
case 0x87:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
if (mod == 3) {
rm = (modrm & 7) | REX_B(s);
do_xchg_reg:
gen_op_mov_TN_reg(ot, 0, reg);
gen_op_mov_TN_reg(ot, 1, rm);
gen_op_mov_reg_T0(ot, rm);
gen_op_mov_reg_T1(ot, reg);
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_mov_TN_reg(ot, 0, reg);
if (!(prefixes & PREFIX_LOCK))
gen_helper_lock();
gen_op_ld_T1_A0(ot + s->mem_index);
gen_op_st_T0_A0(ot + s->mem_index);
if (!(prefixes & PREFIX_LOCK))
gen_helper_unlock();
gen_op_mov_reg_T1(ot, reg);
}
break;
case 0xc4:
if (CODE64(s))
goto illegal_op;
op = R_ES;
goto do_lxx;
case 0xc5:
if (CODE64(s))
goto illegal_op;
op = R_DS;
goto do_lxx;
case 0x1b2:
op = R_SS;
goto do_lxx;
case 0x1b4:
op = R_FS;
goto do_lxx;
case 0x1b5:
op = R_GS;
do_lxx:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T1_A0(ot + s->mem_index);
gen_add_A0_im(s, 1 << (ot - OT_WORD + 1));
gen_op_ldu_T0_A0(OT_WORD + s->mem_index);
gen_movl_seg_T0(s, op, pc_start - s->cs_base);
gen_op_mov_reg_T1(ot, reg);
if (s->is_jmp) {
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0xc0:
case 0xc1:
shift = 2;
grp2:
{
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
op = (modrm >> 3) & 7;
if (mod != 3) {
if (shift == 2) {
s->rip_offset = 1;
}
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
opreg = OR_TMP0;
} else {
opreg = (modrm & 7) | REX_B(s);
}
if (shift == 0) {
gen_shift(s, op, ot, opreg, OR_ECX);
} else {
if (shift == 2) {
shift = ldub_code(s->pc++);
}
gen_shifti(s, op, ot, opreg, shift);
}
}
break;
case 0xd0:
case 0xd1:
shift = 1;
goto grp2;
case 0xd2:
case 0xd3:
shift = 0;
goto grp2;
case 0x1a4:
op = 0;
shift = 1;
goto do_shiftd;
case 0x1a5:
op = 0;
shift = 0;
goto do_shiftd;
case 0x1ac:
op = 1;
shift = 1;
goto do_shiftd;
case 0x1ad:
op = 1;
shift = 0;
do_shiftd:
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
reg = ((modrm >> 3) & 7) | rex_r;
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
opreg = OR_TMP0;
} else {
opreg = rm;
}
gen_op_mov_TN_reg(ot, 1, reg);
if (shift) {
val = ldub_code(s->pc++);
tcg_gen_movi_tl(cpu_T3, val);
} else {
tcg_gen_ld_tl(cpu_T3, cpu_env, offsetof(CPUState, regs[R_ECX]));
}
gen_shiftd_rm_T1_T3(s, ot, opreg, op);
break;
case 0xd8 ... 0xdf:
if (s->flags & (HF_EM_MASK | HF_TS_MASK)) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
break;
}
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
rm = modrm & 7;
op = ((b & 7) << 3) | ((modrm >> 3) & 7);
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
switch(op) {
case 0x00 ... 0x07:
case 0x10 ... 0x17:
case 0x20 ... 0x27:
case 0x30 ... 0x37:
{
int op1;
op1 = op & 7;
switch(op >> 4) {
case 0:
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_flds_FT0(cpu_tmp2_i32);
break;
case 1:
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_fildl_FT0(cpu_tmp2_i32);
break;
case 2:
tcg_gen_qemu_ld64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
gen_helper_fldl_FT0(cpu_tmp1_i64);
break;
case 3:
default:
gen_op_lds_T0_A0(OT_WORD + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_fildl_FT0(cpu_tmp2_i32);
break;
}
gen_helper_fp_arith_ST0_FT0(op1);
if (op1 == 3) {
gen_helper_fpop();
}
}
break;
case 0x08:
case 0x0a:
case 0x0b:
case 0x18 ... 0x1b:
case 0x28 ... 0x2b:
case 0x38 ... 0x3b:
switch(op & 7) {
case 0:
switch(op >> 4) {
case 0:
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_flds_ST0(cpu_tmp2_i32);
break;
case 1:
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_fildl_ST0(cpu_tmp2_i32);
break;
case 2:
tcg_gen_qemu_ld64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
gen_helper_fldl_ST0(cpu_tmp1_i64);
break;
case 3:
default:
gen_op_lds_T0_A0(OT_WORD + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_fildl_ST0(cpu_tmp2_i32);
break;
}
break;
case 1:
switch(op >> 4) {
case 1:
gen_helper_fisttl_ST0(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_LONG + s->mem_index);
break;
case 2:
gen_helper_fisttll_ST0(cpu_tmp1_i64);
tcg_gen_qemu_st64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
break;
case 3:
default:
gen_helper_fistt_ST0(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_WORD + s->mem_index);
break;
}
gen_helper_fpop();
break;
default:
switch(op >> 4) {
case 0:
gen_helper_fsts_ST0(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_LONG + s->mem_index);
break;
case 1:
gen_helper_fistl_ST0(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_LONG + s->mem_index);
break;
case 2:
gen_helper_fstl_ST0(cpu_tmp1_i64);
tcg_gen_qemu_st64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
break;
case 3:
default:
gen_helper_fist_ST0(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_WORD + s->mem_index);
break;
}
if ((op & 7) == 3)
gen_helper_fpop();
break;
}
break;
case 0x0c:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fldenv(
cpu_A0, tcg_const_i32(s->dflag));
break;
case 0x0d:
gen_op_ld_T0_A0(OT_WORD + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_fldcw(cpu_tmp2_i32);
break;
case 0x0e:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fstenv(cpu_A0, tcg_const_i32(s->dflag));
break;
case 0x0f:
gen_helper_fnstcw(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_WORD + s->mem_index);
break;
case 0x1d:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fldt_ST0(cpu_A0);
break;
case 0x1f:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fstt_ST0(cpu_A0);
gen_helper_fpop();
break;
case 0x2c:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_frstor(cpu_A0, tcg_const_i32(s->dflag));
break;
case 0x2e:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fsave(cpu_A0, tcg_const_i32(s->dflag));
break;
case 0x2f:
gen_helper_fnstsw(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_WORD + s->mem_index);
break;
case 0x3c:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fbld_ST0(cpu_A0);
break;
case 0x3e:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fbst_ST0(cpu_A0);
gen_helper_fpop();
break;
case 0x3d:
tcg_gen_qemu_ld64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
gen_helper_fildll_ST0(cpu_tmp1_i64);
break;
case 0x3f:
gen_helper_fistll_ST0(cpu_tmp1_i64);
tcg_gen_qemu_st64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
gen_helper_fpop();
break;
default:
goto illegal_op;
}
} else {
opreg = rm;
switch(op) {
case 0x08:
gen_helper_fpush();
gen_helper_fmov_ST0_STN(tcg_const_i32((opreg + 1) & 7));
break;
case 0x09:
case 0x29:
case 0x39:
gen_helper_fxchg_ST0_STN(tcg_const_i32(opreg));
break;
case 0x0a:
switch(rm) {
case 0:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fwait();
break;
default:
goto illegal_op;
}
break;
case 0x0c:
switch(rm) {
case 0:
gen_helper_fchs_ST0();
break;
case 1:
gen_helper_fabs_ST0();
break;
case 4:
gen_helper_fldz_FT0();
gen_helper_fcom_ST0_FT0();
break;
case 5:
gen_helper_fxam_ST0();
break;
default:
goto illegal_op;
}
break;
case 0x0d:
{
switch(rm) {
case 0:
gen_helper_fpush();
gen_helper_fld1_ST0();
break;
case 1:
gen_helper_fpush();
gen_helper_fldl2t_ST0();
break;
case 2:
gen_helper_fpush();
gen_helper_fldl2e_ST0();
break;
case 3:
gen_helper_fpush();
gen_helper_fldpi_ST0();
break;
case 4:
gen_helper_fpush();
gen_helper_fldlg2_ST0();
break;
case 5:
gen_helper_fpush();
gen_helper_fldln2_ST0();
break;
case 6:
gen_helper_fpush();
gen_helper_fldz_ST0();
break;
default:
goto illegal_op;
}
}
break;
case 0x0e:
switch(rm) {
case 0:
gen_helper_f2xm1();
break;
case 1:
gen_helper_fyl2x();
break;
case 2:
gen_helper_fptan();
break;
case 3:
gen_helper_fpatan();
break;
case 4:
gen_helper_fxtract();
break;
case 5:
gen_helper_fprem1();
break;
case 6:
gen_helper_fdecstp();
break;
default:
case 7:
gen_helper_fincstp();
break;
}
break;
case 0x0f:
switch(rm) {
case 0:
gen_helper_fprem();
break;
case 1:
gen_helper_fyl2xp1();
break;
case 2:
gen_helper_fsqrt();
break;
case 3:
gen_helper_fsincos();
break;
case 5:
gen_helper_fscale();
break;
case 4:
gen_helper_frndint();
break;
case 6:
gen_helper_fsin();
break;
default:
case 7:
gen_helper_fcos();
break;
}
break;
case 0x00: case 0x01: case 0x04 ... 0x07:
case 0x20: case 0x21: case 0x24 ... 0x27:
case 0x30: case 0x31: case 0x34 ... 0x37:
{
int op1;
op1 = op & 7;
if (op >= 0x20) {
gen_helper_fp_arith_STN_ST0(op1, opreg);
if (op >= 0x30)
gen_helper_fpop();
} else {
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fp_arith_ST0_FT0(op1);
}
}
break;
case 0x02:
case 0x22:
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fcom_ST0_FT0();
break;
case 0x03:
case 0x23:
case 0x32:
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fcom_ST0_FT0();
gen_helper_fpop();
break;
case 0x15:
switch(rm) {
case 1:
gen_helper_fmov_FT0_STN(tcg_const_i32(1));
gen_helper_fucom_ST0_FT0();
gen_helper_fpop();
gen_helper_fpop();
break;
default:
goto illegal_op;
}
break;
case 0x1c:
switch(rm) {
case 0:
break;
case 1:
break;
case 2:
gen_helper_fclex();
break;
case 3:
gen_helper_fninit();
break;
case 4:
break;
default:
goto illegal_op;
}
break;
case 0x1d:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fucomi_ST0_FT0();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x1e:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fcomi_ST0_FT0();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x28:
gen_helper_ffree_STN(tcg_const_i32(opreg));
break;
case 0x2a:
gen_helper_fmov_STN_ST0(tcg_const_i32(opreg));
break;
case 0x2b:
case 0x0b:
case 0x3a:
case 0x3b:
gen_helper_fmov_STN_ST0(tcg_const_i32(opreg));
gen_helper_fpop();
break;
case 0x2c:
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fucom_ST0_FT0();
break;
case 0x2d:
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fucom_ST0_FT0();
gen_helper_fpop();
break;
case 0x33:
switch(rm) {
case 1:
gen_helper_fmov_FT0_STN(tcg_const_i32(1));
gen_helper_fcom_ST0_FT0();
gen_helper_fpop();
gen_helper_fpop();
break;
default:
goto illegal_op;
}
break;
case 0x38:
gen_helper_ffree_STN(tcg_const_i32(opreg));
gen_helper_fpop();
break;
case 0x3c:
switch(rm) {
case 0:
gen_helper_fnstsw(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
break;
default:
goto illegal_op;
}
break;
case 0x3d:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fucomi_ST0_FT0();
gen_helper_fpop();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x3e:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
gen_helper_fcomi_ST0_FT0();
gen_helper_fpop();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x10 ... 0x13:
case 0x18 ... 0x1b:
{
int op1, l1;
static const uint8_t fcmov_cc[8] = {
(JCC_B << 1),
(JCC_Z << 1),
(JCC_BE << 1),
(JCC_P << 1),
};
op1 = fcmov_cc[op & 3] | (((op >> 3) & 1) ^ 1);
l1 = gen_new_label();
gen_jcc1(s, s->cc_op, op1, l1);
gen_helper_fmov_ST0_STN(tcg_const_i32(opreg));
gen_set_label(l1);
}
break;
default:
goto illegal_op;
}
}
break;
case 0xa4:
case 0xa5:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_movs(s, ot, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_movs(s, ot);
}
break;
case 0xaa:
case 0xab:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_stos(s, ot, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_stos(s, ot);
}
break;
case 0xac:
case 0xad:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_lods(s, ot, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_lods(s, ot);
}
break;
case 0xae:
case 0xaf:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
if (prefixes & PREFIX_REPNZ) {
gen_repz_scas(s, ot, pc_start - s->cs_base, s->pc - s->cs_base, 1);
} else if (prefixes & PREFIX_REPZ) {
gen_repz_scas(s, ot, pc_start - s->cs_base, s->pc - s->cs_base, 0);
} else {
gen_scas(s, ot);
s->cc_op = CC_OP_SUBB + ot;
}
break;
case 0xa6:
case 0xa7:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag + OT_WORD;
if (prefixes & PREFIX_REPNZ) {
gen_repz_cmps(s, ot, pc_start - s->cs_base, s->pc - s->cs_base, 1);
} else if (prefixes & PREFIX_REPZ) {
gen_repz_cmps(s, ot, pc_start - s->cs_base, s->pc - s->cs_base, 0);
} else {
gen_cmps(s, ot);
s->cc_op = CC_OP_SUBB + ot;
}
break;
case 0x6c:
case 0x6d:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
gen_op_mov_TN_reg(OT_WORD, 0, R_EDX);
gen_op_andl_T0_ffff();
gen_check_io(s, ot, pc_start - s->cs_base,
SVM_IOIO_TYPE_MASK | svm_is_rep(prefixes) | 4);
if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_ins(s, ot, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_ins(s, ot);
if (use_icount) {
gen_jmp(s, s->pc - s->cs_base);
}
}
break;
case 0x6e:
case 0x6f:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
gen_op_mov_TN_reg(OT_WORD, 0, R_EDX);
gen_op_andl_T0_ffff();
gen_check_io(s, ot, pc_start - s->cs_base,
svm_is_rep(prefixes) | 4);
if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_outs(s, ot, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_outs(s, ot);
if (use_icount) {
gen_jmp(s, s->pc - s->cs_base);
}
}
break;
case 0xe4:
case 0xe5:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
val = ldub_code(s->pc++);
gen_op_movl_T0_im(val);
gen_check_io(s, ot, pc_start - s->cs_base,
SVM_IOIO_TYPE_MASK | svm_is_rep(prefixes));
if (use_icount)
gen_io_start();
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_in_func(ot, cpu_T[1], cpu_tmp2_i32);
gen_op_mov_reg_T1(ot, R_EAX);
if (use_icount) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0xe6:
case 0xe7:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
val = ldub_code(s->pc++);
gen_op_movl_T0_im(val);
gen_check_io(s, ot, pc_start - s->cs_base,
svm_is_rep(prefixes));
gen_op_mov_TN_reg(ot, 1, R_EAX);
if (use_icount)
gen_io_start();
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff);
tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T[1]);
gen_helper_out_func(ot, cpu_tmp2_i32, cpu_tmp3_i32);
if (use_icount) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0xec:
case 0xed:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
gen_op_mov_TN_reg(OT_WORD, 0, R_EDX);
gen_op_andl_T0_ffff();
gen_check_io(s, ot, pc_start - s->cs_base,
SVM_IOIO_TYPE_MASK | svm_is_rep(prefixes));
if (use_icount)
gen_io_start();
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_in_func(ot, cpu_T[1], cpu_tmp2_i32);
gen_op_mov_reg_T1(ot, R_EAX);
if (use_icount) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0xee:
case 0xef:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
gen_op_mov_TN_reg(OT_WORD, 0, R_EDX);
gen_op_andl_T0_ffff();
gen_check_io(s, ot, pc_start - s->cs_base,
svm_is_rep(prefixes));
gen_op_mov_TN_reg(ot, 1, R_EAX);
if (use_icount)
gen_io_start();
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff);
tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T[1]);
gen_helper_out_func(ot, cpu_tmp2_i32, cpu_tmp3_i32);
if (use_icount) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0xc2:
val = ldsw_code(s->pc);
s->pc += 2;
gen_pop_T0(s);
if (CODE64(s) && s->dflag)
s->dflag = 2;
gen_stack_update(s, val + (2 << s->dflag));
if (s->dflag == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
gen_eob(s);
break;
case 0xc3:
gen_pop_T0(s);
gen_pop_update(s);
if (s->dflag == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
gen_eob(s);
break;
case 0xca:
val = ldsw_code(s->pc);
s->pc += 2;
do_lret:
if (s->pe && !s->vm86) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_lret_protected(tcg_const_i32(s->dflag),
tcg_const_i32(val));
} else {
gen_stack_A0(s);
gen_op_ld_T0_A0(1 + s->dflag + s->mem_index);
if (s->dflag == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
gen_op_addl_A0_im(2 << s->dflag);
gen_op_ld_T0_A0(1 + s->dflag + s->mem_index);
gen_op_movl_seg_T0_vm(R_CS);
gen_stack_update(s, val + (4 << s->dflag));
}
gen_eob(s);
break;
case 0xcb:
val = 0;
goto do_lret;
case 0xcf:
gen_svm_check_intercept(s, pc_start, SVM_EXIT_IRET);
if (!s->pe) {
gen_helper_iret_real(tcg_const_i32(s->dflag));
s->cc_op = CC_OP_EFLAGS;
} else if (s->vm86) {
if (s->iopl != 3) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_helper_iret_real(tcg_const_i32(s->dflag));
s->cc_op = CC_OP_EFLAGS;
}
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_iret_protected(tcg_const_i32(s->dflag),
tcg_const_i32(s->pc - s->cs_base));
s->cc_op = CC_OP_EFLAGS;
}
gen_eob(s);
break;
case 0xe8:
{
if (dflag)
tval = (int32_t)insn_get(s, OT_LONG);
else
tval = (int16_t)insn_get(s, OT_WORD);
next_eip = s->pc - s->cs_base;
tval += next_eip;
if (s->dflag == 0)
tval &= 0xffff;
gen_movtl_T0_im(next_eip);
gen_push_T0(s);
gen_jmp(s, tval);
}
break;
case 0x9a:
{
unsigned int selector, offset;
if (CODE64(s))
goto illegal_op;
ot = dflag ? OT_LONG : OT_WORD;
offset = insn_get(s, ot);
selector = insn_get(s, OT_WORD);
gen_op_movl_T0_im(selector);
gen_op_movl_T1_imu(offset);
}
goto do_lcall;
case 0xe9:
if (dflag)
tval = (int32_t)insn_get(s, OT_LONG);
else
tval = (int16_t)insn_get(s, OT_WORD);
tval += s->pc - s->cs_base;
if (s->dflag == 0)
tval &= 0xffff;
gen_jmp(s, tval);
break;
case 0xea:
{
unsigned int selector, offset;
if (CODE64(s))
goto illegal_op;
ot = dflag ? OT_LONG : OT_WORD;
offset = insn_get(s, ot);
selector = insn_get(s, OT_WORD);
gen_op_movl_T0_im(selector);
gen_op_movl_T1_imu(offset);
}
goto do_ljmp;
case 0xeb:
tval = (int8_t)insn_get(s, OT_BYTE);
tval += s->pc - s->cs_base;
if (s->dflag == 0)
tval &= 0xffff;
gen_jmp(s, tval);
break;
case 0x70 ... 0x7f:
tval = (int8_t)insn_get(s, OT_BYTE);
goto do_jcc;
case 0x180 ... 0x18f:
if (dflag) {
tval = (int32_t)insn_get(s, OT_LONG);
} else {
tval = (int16_t)insn_get(s, OT_WORD);
}
do_jcc:
next_eip = s->pc - s->cs_base;
tval += next_eip;
if (s->dflag == 0)
tval &= 0xffff;
gen_jcc(s, b, tval, next_eip);
break;
case 0x190 ... 0x19f:
modrm = ldub_code(s->pc++);
gen_setcc(s, b);
gen_ldst_modrm(s, modrm, OT_BYTE, OR_TMP0, 1);
break;
case 0x140 ... 0x14f:
{
int l1;
TCGv t0;
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
t0 = tcg_temp_local_new();
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_v(ot + s->mem_index, t0, cpu_A0);
} else {
rm = (modrm & 7) | REX_B(s);
gen_op_mov_v_reg(ot, t0, rm);
}
#ifdef TARGET_X86_64
if (ot == OT_LONG) {
l1 = gen_new_label();
gen_jcc1(s, s->cc_op, b ^ 1, l1);
tcg_gen_st32_tl(t0, cpu_env, offsetof(CPUState, regs[reg]) + REG_L_OFFSET);
gen_set_label(l1);
tcg_gen_movi_tl(cpu_tmp0, 0);
tcg_gen_st32_tl(cpu_tmp0, cpu_env, offsetof(CPUState, regs[reg]) + REG_LH_OFFSET);
} else
#endif
{
l1 = gen_new_label();
gen_jcc1(s, s->cc_op, b ^ 1, l1);
gen_op_mov_reg_v(ot, reg, t0);
gen_set_label(l1);
}
tcg_temp_free(t0);
}
break;
case 0x9c:
gen_svm_check_intercept(s, pc_start, SVM_EXIT_PUSHF);
if (s->vm86 && s->iopl != 3) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_read_eflags(cpu_T[0]);
gen_push_T0(s);
}
break;
case 0x9d:
gen_svm_check_intercept(s, pc_start, SVM_EXIT_POPF);
if (s->vm86 && s->iopl != 3) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_pop_T0(s);
if (s->cpl == 0) {
if (s->dflag) {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK | IOPL_MASK)));
} else {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK | IOPL_MASK) & 0xffff));
}
} else {
if (s->cpl <= s->iopl) {
if (s->dflag) {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK)));
} else {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK) & 0xffff));
}
} else {
if (s->dflag) {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK)));
} else {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK) & 0xffff));
}
}
}
gen_pop_update(s);
s->cc_op = CC_OP_EFLAGS;
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x9e:
if (CODE64(s) && !(s->cpuid_ext3_features & CPUID_EXT3_LAHF_LM))
goto illegal_op;
gen_op_mov_TN_reg(OT_BYTE, 0, R_AH);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_cc_src);
tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, CC_O);
tcg_gen_andi_tl(cpu_T[0], cpu_T[0], CC_S | CC_Z | CC_A | CC_P | CC_C);
tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, cpu_T[0]);
s->cc_op = CC_OP_EFLAGS;
break;
case 0x9f:
if (CODE64(s) && !(s->cpuid_ext3_features & CPUID_EXT3_LAHF_LM))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_T[0]);
tcg_gen_ori_tl(cpu_T[0], cpu_T[0], 0x02);
gen_op_mov_reg_T0(OT_BYTE, R_AH);
break;
case 0xf5:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_cc_src);
tcg_gen_xori_tl(cpu_cc_src, cpu_cc_src, CC_C);
s->cc_op = CC_OP_EFLAGS;
break;
case 0xf8:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_cc_src);
tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, ~CC_C);
s->cc_op = CC_OP_EFLAGS;
break;
case 0xf9:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_cc_src);
tcg_gen_ori_tl(cpu_cc_src, cpu_cc_src, CC_C);
s->cc_op = CC_OP_EFLAGS;
break;
case 0xfc:
tcg_gen_movi_i32(cpu_tmp2_i32, 1);
tcg_gen_st_i32(cpu_tmp2_i32, cpu_env, offsetof(CPUState, df));
break;
case 0xfd:
tcg_gen_movi_i32(cpu_tmp2_i32, -1);
tcg_gen_st_i32(cpu_tmp2_i32, cpu_env, offsetof(CPUState, df));
break;
case 0x1ba:
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
op = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
if (mod != 3) {
s->rip_offset = 1;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T0_A0(ot + s->mem_index);
} else {
gen_op_mov_TN_reg(ot, 0, rm);
}
val = ldub_code(s->pc++);
gen_op_movl_T1_im(val);
if (op < 4)
goto illegal_op;
op -= 4;
goto bt_op;
case 0x1a3:
op = 0;
goto do_btx;
case 0x1ab:
op = 1;
goto do_btx;
case 0x1b3:
op = 2;
goto do_btx;
case 0x1bb:
op = 3;
do_btx:
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
gen_op_mov_TN_reg(OT_LONG, 1, reg);
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_exts(ot, cpu_T[1]);
tcg_gen_sari_tl(cpu_tmp0, cpu_T[1], 3 + ot);
tcg_gen_shli_tl(cpu_tmp0, cpu_tmp0, ot);
tcg_gen_add_tl(cpu_A0, cpu_A0, cpu_tmp0);
gen_op_ld_T0_A0(ot + s->mem_index);
} else {
gen_op_mov_TN_reg(ot, 0, rm);
}
bt_op:
tcg_gen_andi_tl(cpu_T[1], cpu_T[1], (1 << (3 + ot)) - 1);
switch(op) {
case 0:
tcg_gen_shr_tl(cpu_cc_src, cpu_T[0], cpu_T[1]);
tcg_gen_movi_tl(cpu_cc_dst, 0);
break;
case 1:
tcg_gen_shr_tl(cpu_tmp4, cpu_T[0], cpu_T[1]);
tcg_gen_movi_tl(cpu_tmp0, 1);
tcg_gen_shl_tl(cpu_tmp0, cpu_tmp0, cpu_T[1]);
tcg_gen_or_tl(cpu_T[0], cpu_T[0], cpu_tmp0);
break;
case 2:
tcg_gen_shr_tl(cpu_tmp4, cpu_T[0], cpu_T[1]);
tcg_gen_movi_tl(cpu_tmp0, 1);
tcg_gen_shl_tl(cpu_tmp0, cpu_tmp0, cpu_T[1]);
tcg_gen_not_tl(cpu_tmp0, cpu_tmp0);
tcg_gen_and_tl(cpu_T[0], cpu_T[0], cpu_tmp0);
break;
default:
case 3:
tcg_gen_shr_tl(cpu_tmp4, cpu_T[0], cpu_T[1]);
tcg_gen_movi_tl(cpu_tmp0, 1);
tcg_gen_shl_tl(cpu_tmp0, cpu_tmp0, cpu_T[1]);
tcg_gen_xor_tl(cpu_T[0], cpu_T[0], cpu_tmp0);
break;
}
s->cc_op = CC_OP_SARB + ot;
if (op != 0) {
if (mod != 3)
gen_op_st_T0_A0(ot + s->mem_index);
else
gen_op_mov_reg_T0(ot, rm);
tcg_gen_mov_tl(cpu_cc_src, cpu_tmp4);
tcg_gen_movi_tl(cpu_cc_dst, 0);
}
break;
case 0x1bc:
case 0x1bd:
{
int label1;
TCGv t0;
ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
gen_extu(ot, cpu_T[0]);
label1 = gen_new_label();
tcg_gen_movi_tl(cpu_cc_dst, 0);
t0 = tcg_temp_local_new();
tcg_gen_mov_tl(t0, cpu_T[0]);
tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, label1);
if (b & 1) {
gen_helper_bsr(cpu_T[0], t0);
} else {
gen_helper_bsf(cpu_T[0], t0);
}
gen_op_mov_reg_T0(ot, reg);
tcg_gen_movi_tl(cpu_cc_dst, 1);
gen_set_label(label1);
tcg_gen_discard_tl(cpu_cc_src);
s->cc_op = CC_OP_LOGICB + ot;
tcg_temp_free(t0);
}
break;
case 0x27:
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_daa();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x2f:
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_das();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x37:
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_aaa();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x3f:
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_aas();
s->cc_op = CC_OP_EFLAGS;
break;
case 0xd4:
if (CODE64(s))
goto illegal_op;
val = ldub_code(s->pc++);
if (val == 0) {
gen_exception(s, EXCP00_DIVZ, pc_start - s->cs_base);
} else {
gen_helper_aam(tcg_const_i32(val));
s->cc_op = CC_OP_LOGICB;
}
break;
case 0xd5:
if (CODE64(s))
goto illegal_op;
val = ldub_code(s->pc++);
gen_helper_aad(tcg_const_i32(val));
s->cc_op = CC_OP_LOGICB;
break;
case 0x90:
if (prefixes & PREFIX_LOCK)
goto illegal_op;
if (prefixes & PREFIX_REPZ) {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_PAUSE);
}
break;
case 0x9b:
if ((s->flags & (HF_MP_MASK | HF_TS_MASK)) ==
(HF_MP_MASK | HF_TS_MASK)) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fwait();
}
break;
case 0xcc:
gen_interrupt(s, EXCP03_INT3, pc_start - s->cs_base, s->pc - s->cs_base);
break;
case 0xcd:
val = ldub_code(s->pc++);
if (s->vm86 && s->iopl != 3) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_interrupt(s, val, pc_start - s->cs_base, s->pc - s->cs_base);
}
break;
case 0xce:
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_into(tcg_const_i32(s->pc - pc_start));
break;
#ifdef WANT_ICEBP
case 0xf1:
gen_svm_check_intercept(s, pc_start, SVM_EXIT_ICEBP);
#if 1
gen_debug(s, pc_start - s->cs_base);
#else
tb_flush(cpu_single_env);
cpu_set_log(CPU_LOG_INT | CPU_LOG_TB_IN_ASM);
#endif
break;
#endif
case 0xfa:
if (!s->vm86) {
if (s->cpl <= s->iopl) {
gen_helper_cli();
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
} else {
if (s->iopl == 3) {
gen_helper_cli();
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
}
break;
case 0xfb:
if (!s->vm86) {
if (s->cpl <= s->iopl) {
gen_sti:
gen_helper_sti();
if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK))
gen_helper_set_inhibit_irq();
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
} else {
if (s->iopl == 3) {
goto gen_sti;
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
}
break;
case 0x62:
if (CODE64(s))
goto illegal_op;
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
gen_op_mov_TN_reg(ot, 0, reg);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_jmp_im(pc_start - s->cs_base);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
if (ot == OT_WORD)
gen_helper_boundw(cpu_A0, cpu_tmp2_i32);
else
gen_helper_boundl(cpu_A0, cpu_tmp2_i32);
break;
case 0x1c8 ... 0x1cf:
reg = (b & 7) | REX_B(s);
#ifdef TARGET_X86_64
if (dflag == 2) {
gen_op_mov_TN_reg(OT_QUAD, 0, reg);
tcg_gen_bswap_i64(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_QUAD, reg);
} else
{
TCGv_i32 tmp0;
gen_op_mov_TN_reg(OT_LONG, 0, reg);
tmp0 = tcg_temp_new_i32();
tcg_gen_trunc_i64_i32(tmp0, cpu_T[0]);
tcg_gen_bswap_i32(tmp0, tmp0);
tcg_gen_extu_i32_i64(cpu_T[0], tmp0);
gen_op_mov_reg_T0(OT_LONG, reg);
}
#else
{
gen_op_mov_TN_reg(OT_LONG, 0, reg);
tcg_gen_bswap_i32(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_LONG, reg);
}
#endif
break;
case 0xd6:
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags_c(cpu_T[0]);
tcg_gen_neg_tl(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_BYTE, R_EAX);
break;
case 0xe0:
case 0xe1:
case 0xe2:
case 0xe3:
{
int l1, l2, l3;
tval = (int8_t)insn_get(s, OT_BYTE);
next_eip = s->pc - s->cs_base;
tval += next_eip;
if (s->dflag == 0)
tval &= 0xffff;
l1 = gen_new_label();
l2 = gen_new_label();
l3 = gen_new_label();
b &= 3;
switch(b) {
case 0:
case 1:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_add_reg_im(s->aflag, R_ECX, -1);
gen_op_jz_ecx(s->aflag, l3);
gen_compute_eflags(cpu_tmp0);
tcg_gen_andi_tl(cpu_tmp0, cpu_tmp0, CC_Z);
if (b == 0) {
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_tmp0, 0, l1);
} else {
tcg_gen_brcondi_tl(TCG_COND_NE, cpu_tmp0, 0, l1);
}
break;
case 2:
gen_op_add_reg_im(s->aflag, R_ECX, -1);
gen_op_jnz_ecx(s->aflag, l1);
break;
default:
case 3:
gen_op_jz_ecx(s->aflag, l1);
break;
}
gen_set_label(l3);
gen_jmp_im(next_eip);
tcg_gen_br(l2);
gen_set_label(l1);
gen_jmp_im(tval);
gen_set_label(l2);
gen_eob(s);
}
break;
case 0x130:
case 0x132:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
if (b & 2) {
gen_helper_rdmsr();
} else {
gen_helper_wrmsr();
}
}
break;
case 0x131:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
if (use_icount)
gen_io_start();
gen_helper_rdtsc();
if (use_icount) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0x133:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_rdpmc();
break;
case 0x134:
if (CODE64(s) && cpu_single_env->cpuid_vendor1 != CPUID_VENDOR_INTEL_1)
goto illegal_op;
if (!s->pe) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(pc_start - s->cs_base);
gen_helper_sysenter();
gen_eob(s);
}
break;
case 0x135:
if (CODE64(s) && cpu_single_env->cpuid_vendor1 != CPUID_VENDOR_INTEL_1)
goto illegal_op;
if (!s->pe) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(pc_start - s->cs_base);
gen_helper_sysexit(tcg_const_i32(dflag));
gen_eob(s);
}
break;
#ifdef TARGET_X86_64
case 0x105:
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(pc_start - s->cs_base);
gen_helper_syscall(tcg_const_i32(s->pc - pc_start));
gen_eob(s);
break;
case 0x107:
if (!s->pe) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(pc_start - s->cs_base);
gen_helper_sysret(tcg_const_i32(s->dflag));
if (s->lma)
s->cc_op = CC_OP_EFLAGS;
gen_eob(s);
}
break;
#endif
case 0x1a2:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_cpuid();
break;
case 0xf4:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_hlt(tcg_const_i32(s->pc - pc_start));
s->is_jmp = 3;
}
break;
case 0x100:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
op = (modrm >> 3) & 7;
switch(op) {
case 0:
if (!s->pe || s->vm86)
goto illegal_op;
gen_svm_check_intercept(s, pc_start, SVM_EXIT_LDTR_READ);
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,ldt.selector));
ot = OT_WORD;
if (mod == 3)
ot += s->dflag;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 1);
break;
case 2:
if (!s->pe || s->vm86)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_LDTR_WRITE);
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
gen_jmp_im(pc_start - s->cs_base);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_lldt(cpu_tmp2_i32);
}
break;
case 1:
if (!s->pe || s->vm86)
goto illegal_op;
gen_svm_check_intercept(s, pc_start, SVM_EXIT_TR_READ);
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,tr.selector));
ot = OT_WORD;
if (mod == 3)
ot += s->dflag;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 1);
break;
case 3:
if (!s->pe || s->vm86)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_TR_WRITE);
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
gen_jmp_im(pc_start - s->cs_base);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_ltr(cpu_tmp2_i32);
}
break;
case 4:
case 5:
if (!s->pe || s->vm86)
goto illegal_op;
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
if (op == 4)
gen_helper_verr(cpu_T[0]);
else
gen_helper_verw(cpu_T[0]);
s->cc_op = CC_OP_EFLAGS;
break;
default:
goto illegal_op;
}
break;
case 0x101:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
op = (modrm >> 3) & 7;
rm = modrm & 7;
switch(op) {
case 0:
if (mod == 3)
goto illegal_op;
gen_svm_check_intercept(s, pc_start, SVM_EXIT_GDTR_READ);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, gdt.limit));
gen_op_st_T0_A0(OT_WORD + s->mem_index);
gen_add_A0_im(s, 2);
tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, gdt.base));
if (!s->dflag)
gen_op_andl_T0_im(0xffffff);
gen_op_st_T0_A0(CODE64(s) + OT_LONG + s->mem_index);
break;
case 1:
if (mod == 3) {
switch (rm) {
case 0:
if (!(s->cpuid_ext_features & CPUID_EXT_MONITOR) ||
s->cpl != 0)
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
#ifdef TARGET_X86_64
if (s->aflag == 2) {
gen_op_movq_A0_reg(R_EAX);
} else
#endif
{
gen_op_movl_A0_reg(R_EAX);
if (s->aflag == 0)
gen_op_andl_A0_ffff();
}
gen_add_A0_ds_seg(s);
gen_helper_monitor(cpu_A0);
break;
case 1:
if (!(s->cpuid_ext_features & CPUID_EXT_MONITOR) ||
s->cpl != 0)
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(pc_start - s->cs_base);
gen_helper_mwait(tcg_const_i32(s->pc - pc_start));
gen_eob(s);
break;
default:
goto illegal_op;
}
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_IDTR_READ);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, idt.limit));
gen_op_st_T0_A0(OT_WORD + s->mem_index);
gen_add_A0_im(s, 2);
tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, idt.base));
if (!s->dflag)
gen_op_andl_T0_im(0xffffff);
gen_op_st_T0_A0(CODE64(s) + OT_LONG + s->mem_index);
}
break;
case 2:
case 3:
if (mod == 3) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
switch(rm) {
case 0:
if (!(s->flags & HF_SVME_MASK) || !s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_vmrun(tcg_const_i32(s->aflag),
tcg_const_i32(s->pc - pc_start));
tcg_gen_exit_tb(0);
s->is_jmp = 3;
}
break;
case 1:
if (!(s->flags & HF_SVME_MASK))
goto illegal_op;
gen_helper_vmmcall();
break;
case 2:
if (!(s->flags & HF_SVME_MASK) || !s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_vmload(tcg_const_i32(s->aflag));
}
break;
case 3:
if (!(s->flags & HF_SVME_MASK) || !s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_vmsave(tcg_const_i32(s->aflag));
}
break;
case 4:
if ((!(s->flags & HF_SVME_MASK) &&
!(s->cpuid_ext3_features & CPUID_EXT3_SKINIT)) ||
!s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_stgi();
}
break;
case 5:
if (!(s->flags & HF_SVME_MASK) || !s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_clgi();
}
break;
case 6:
if ((!(s->flags & HF_SVME_MASK) &&
!(s->cpuid_ext3_features & CPUID_EXT3_SKINIT)) ||
!s->pe)
goto illegal_op;
gen_helper_skinit();
break;
case 7:
if (!(s->flags & HF_SVME_MASK) || !s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_invlpga(tcg_const_i32(s->aflag));
}
break;
default:
goto illegal_op;
}
} else if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start,
op==2 ? SVM_EXIT_GDTR_WRITE : SVM_EXIT_IDTR_WRITE);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T1_A0(OT_WORD + s->mem_index);
gen_add_A0_im(s, 2);
gen_op_ld_T0_A0(CODE64(s) + OT_LONG + s->mem_index);
if (!s->dflag)
gen_op_andl_T0_im(0xffffff);
if (op == 2) {
tcg_gen_st_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,gdt.base));
tcg_gen_st32_tl(cpu_T[1], cpu_env, offsetof(CPUX86State,gdt.limit));
} else {
tcg_gen_st_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,idt.base));
tcg_gen_st32_tl(cpu_T[1], cpu_env, offsetof(CPUX86State,idt.limit));
}
}
break;
case 4:
gen_svm_check_intercept(s, pc_start, SVM_EXIT_READ_CR0);
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,cr[0]));
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 1);
break;
case 6:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_WRITE_CR0);
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
gen_helper_lmsw(cpu_T[0]);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 7:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (mod == 3) {
#ifdef TARGET_X86_64
if (CODE64(s) && rm == 0) {
tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,segs[R_GS].base));
tcg_gen_ld_tl(cpu_T[1], cpu_env, offsetof(CPUX86State,kernelgsbase));
tcg_gen_st_tl(cpu_T[1], cpu_env, offsetof(CPUX86State,segs[R_GS].base));
tcg_gen_st_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,kernelgsbase));
} else
#endif
{
goto illegal_op;
}
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_helper_invlpg(cpu_A0);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
}
break;
default:
goto illegal_op;
}
break;
case 0x108:
case 0x109:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start, (b & 2) ? SVM_EXIT_INVD : SVM_EXIT_WBINVD);
}
break;
case 0x63:
#ifdef TARGET_X86_64
if (CODE64(s)) {
int d_ot;
d_ot = dflag + OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
mod = (modrm >> 6) & 3;
rm = (modrm & 7) | REX_B(s);
if (mod == 3) {
gen_op_mov_TN_reg(OT_LONG, 0, rm);
if (d_ot == OT_QUAD)
tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(d_ot, reg);
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (d_ot == OT_QUAD) {
gen_op_lds_T0_A0(OT_LONG + s->mem_index);
} else {
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
}
gen_op_mov_reg_T0(d_ot, reg);
}
} else
#endif
{
int label1;
TCGv t0, t1, t2;
if (!s->pe || s->vm86)
goto illegal_op;
t0 = tcg_temp_local_new();
t1 = tcg_temp_local_new();
t2 = tcg_temp_local_new();
ot = OT_WORD;
modrm = ldub_code(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
rm = modrm & 7;
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_v(ot + s->mem_index, t0, cpu_A0);
} else {
gen_op_mov_v_reg(ot, t0, rm);
}
gen_op_mov_v_reg(ot, t1, reg);
tcg_gen_andi_tl(cpu_tmp0, t0, 3);
tcg_gen_andi_tl(t1, t1, 3);
tcg_gen_movi_tl(t2, 0);
label1 = gen_new_label();
tcg_gen_brcond_tl(TCG_COND_GE, cpu_tmp0, t1, label1);
tcg_gen_andi_tl(t0, t0, ~3);
tcg_gen_or_tl(t0, t0, t1);
tcg_gen_movi_tl(t2, CC_Z);
gen_set_label(label1);
if (mod != 3) {
gen_op_st_v(ot + s->mem_index, t0, cpu_A0);
} else {
gen_op_mov_reg_v(ot, rm, t0);
}
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_cc_src);
tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, ~CC_Z);
tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, t2);
s->cc_op = CC_OP_EFLAGS;
tcg_temp_free(t0);
tcg_temp_free(t1);
tcg_temp_free(t2);
}
break;
case 0x102:
case 0x103:
{
int label1;
TCGv t0;
if (!s->pe || s->vm86)
goto illegal_op;
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7) | rex_r;
gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
t0 = tcg_temp_local_new();
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
if (b == 0x102)
gen_helper_lar(t0, cpu_T[0]);
else
gen_helper_lsl(t0, cpu_T[0]);
tcg_gen_andi_tl(cpu_tmp0, cpu_cc_src, CC_Z);
label1 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_tmp0, 0, label1);
gen_op_mov_reg_v(ot, reg, t0);
gen_set_label(label1);
s->cc_op = CC_OP_EFLAGS;
tcg_temp_free(t0);
}
break;
case 0x118:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
op = (modrm >> 3) & 7;
switch(op) {
case 0:
case 1:
case 2:
case 3:
if (mod == 3)
goto illegal_op;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
break;
default:
gen_nop_modrm(s, modrm);
break;
}
break;
case 0x119 ... 0x11f:
modrm = ldub_code(s->pc++);
gen_nop_modrm(s, modrm);
break;
case 0x120:
case 0x122:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
modrm = ldub_code(s->pc++);
if ((modrm & 0xc0) != 0xc0)
goto illegal_op;
rm = (modrm & 7) | REX_B(s);
reg = ((modrm >> 3) & 7) | rex_r;
if (CODE64(s))
ot = OT_QUAD;
else
ot = OT_LONG;
switch(reg) {
case 0:
case 2:
case 3:
case 4:
case 8:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
if (b & 2) {
gen_op_mov_TN_reg(ot, 0, rm);
gen_helper_write_crN(tcg_const_i32(reg), cpu_T[0]);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
} else {
gen_helper_read_crN(cpu_T[0], tcg_const_i32(reg));
gen_op_mov_reg_T0(ot, rm);
}
break;
default:
goto illegal_op;
}
}
break;
case 0x121:
case 0x123:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
modrm = ldub_code(s->pc++);
if ((modrm & 0xc0) != 0xc0)
goto illegal_op;
rm = (modrm & 7) | REX_B(s);
reg = ((modrm >> 3) & 7) | rex_r;
if (CODE64(s))
ot = OT_QUAD;
else
ot = OT_LONG;
if (reg == 4 || reg == 5 || reg >= 8)
goto illegal_op;
if (b & 2) {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_WRITE_DR0 + reg);
gen_op_mov_TN_reg(ot, 0, rm);
gen_helper_movl_drN_T0(tcg_const_i32(reg), cpu_T[0]);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_READ_DR0 + reg);
tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,dr[reg]));
gen_op_mov_reg_T0(ot, rm);
}
}
break;
case 0x106:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_WRITE_CR0);
gen_helper_clts();
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x1c3:
if (!(s->cpuid_features & CPUID_SSE2))
goto illegal_op;
ot = s->dflag == 2 ? OT_QUAD : OT_LONG;
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
reg = ((modrm >> 3) & 7) | rex_r;
gen_ldst_modrm(s, modrm, ot, reg, 1);
break;
case 0x1ae:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
op = (modrm >> 3) & 7;
switch(op) {
case 0:
if (mod == 3 || !(s->cpuid_features & CPUID_FXSR) ||
(s->flags & HF_EM_MASK))
goto illegal_op;
if (s->flags & HF_TS_MASK) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
break;
}
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fxsave(cpu_A0, tcg_const_i32((s->dflag == 2)));
break;
case 1:
if (mod == 3 || !(s->cpuid_features & CPUID_FXSR) ||
(s->flags & HF_EM_MASK))
goto illegal_op;
if (s->flags & HF_TS_MASK) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
break;
}
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fxrstor(cpu_A0, tcg_const_i32((s->dflag == 2)));
break;
case 2:
case 3:
if (s->flags & HF_TS_MASK) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
break;
}
if ((s->flags & HF_EM_MASK) || !(s->flags & HF_OSFXSR_MASK) ||
mod == 3)
goto illegal_op;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (op == 2) {
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
tcg_gen_st32_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, mxcsr));
} else {
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, mxcsr));
gen_op_st_T0_A0(OT_LONG + s->mem_index);
}
break;
case 5:
case 6:
if ((modrm & 0xc7) != 0xc0 || !(s->cpuid_features & CPUID_SSE))
goto illegal_op;
break;
case 7:
if ((modrm & 0xc7) == 0xc0) {
if (!(s->cpuid_features & CPUID_SSE))
goto illegal_op;
} else {
if (!(s->cpuid_features & CPUID_CLFLUSH))
goto illegal_op;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
}
break;
default:
goto illegal_op;
}
break;
case 0x10d:
modrm = ldub_code(s->pc++);
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
break;
case 0x1aa:
gen_svm_check_intercept(s, pc_start, SVM_EXIT_RSM);
if (!(s->flags & HF_SMM_MASK))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(s->pc - s->cs_base);
gen_helper_rsm();
gen_eob(s);
break;
case 0x1b8:
if ((prefixes & (PREFIX_REPZ | PREFIX_LOCK | PREFIX_REPNZ)) !=
PREFIX_REPZ)
goto illegal_op;
if (!(s->cpuid_ext_features & CPUID_EXT_POPCNT))
goto illegal_op;
modrm = ldub_code(s->pc++);
reg = ((modrm >> 3) & 7);
if (s->prefix & PREFIX_DATA)
ot = OT_WORD;
else if (s->dflag != 2)
ot = OT_LONG;
else
ot = OT_QUAD;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
gen_helper_popcnt(cpu_T[0], cpu_T[0], tcg_const_i32(ot));
gen_op_mov_reg_T0(ot, reg);
s->cc_op = CC_OP_EFLAGS;
break;
case 0x10e ... 0x10f:
s->prefix &= ~(PREFIX_REPZ | PREFIX_REPNZ | PREFIX_DATA);
case 0x110 ... 0x117:
case 0x128 ... 0x12f:
case 0x138 ... 0x13a:
case 0x150 ... 0x177:
case 0x17c ... 0x17f:
case 0x1c2:
case 0x1c4 ... 0x1c6:
case 0x1d0 ... 0x1fe:
gen_sse(s, b, pc_start, rex_r);
break;
default:
goto illegal_op;
}
if (s->prefix & PREFIX_LOCK)
gen_helper_unlock();
return s->pc;
illegal_op:
if (s->prefix & PREFIX_LOCK)
gen_helper_unlock();
gen_exception(s, EXCP06_ILLOP, pc_start - s->cs_base);
return s->pc;
} | {
"code": [],
"line_no": []
} | static target_ulong FUNC_0(DisasContext *s, target_ulong pc_start)
{
int VAR_0, VAR_1, VAR_2, VAR_3;
int VAR_4, VAR_5;
int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_17, VAR_12, VAR_13, VAR_18;
target_ulong next_eip, tval;
int VAR_15, VAR_16;
if (unlikely(loglevel & CPU_LOG_TB_OP))
tcg_gen_debug_insn_start(pc_start);
s->pc = pc_start;
VAR_1 = 0;
VAR_2 = s->code32;
VAR_3 = s->code32;
s->override = -1;
VAR_15 = -1;
VAR_16 = 0;
#ifdef TARGET_X86_64
s->rex_x = 0;
s->rex_b = 0;
x86_64_hregs = 0;
#endif
s->rip_offset = 0;
next_byte:
VAR_0 = ldub_code(s->pc);
s->pc++;
#ifdef TARGET_X86_64
if (CODE64(s)) {
switch (VAR_0) {
case 0xf3:
VAR_1 |= PREFIX_REPZ;
goto next_byte;
case 0xf2:
VAR_1 |= PREFIX_REPNZ;
goto next_byte;
case 0xf0:
VAR_1 |= PREFIX_LOCK;
goto next_byte;
case 0x2e:
s->override = R_CS;
goto next_byte;
case 0x36:
s->override = R_SS;
goto next_byte;
case 0x3e:
s->override = R_DS;
goto next_byte;
case 0x26:
s->override = R_ES;
goto next_byte;
case 0x64:
s->override = R_FS;
goto next_byte;
case 0x65:
s->override = R_GS;
goto next_byte;
case 0x66:
VAR_1 |= PREFIX_DATA;
goto next_byte;
case 0x67:
VAR_1 |= PREFIX_ADR;
goto next_byte;
case 0x40 ... 0x4f:
VAR_15 = (VAR_0 >> 3) & 1;
VAR_16 = (VAR_0 & 0x4) << 1;
s->rex_x = (VAR_0 & 0x2) << 2;
REX_B(s) = (VAR_0 & 0x1) << 3;
x86_64_hregs = 1;
goto next_byte;
}
if (VAR_15 == 1) {
VAR_3 = 2;
} else {
if (VAR_1 & PREFIX_DATA)
VAR_3 ^= 1;
}
if (!(VAR_1 & PREFIX_ADR))
VAR_2 = 2;
} else
#endif
{
switch (VAR_0) {
case 0xf3:
VAR_1 |= PREFIX_REPZ;
goto next_byte;
case 0xf2:
VAR_1 |= PREFIX_REPNZ;
goto next_byte;
case 0xf0:
VAR_1 |= PREFIX_LOCK;
goto next_byte;
case 0x2e:
s->override = R_CS;
goto next_byte;
case 0x36:
s->override = R_SS;
goto next_byte;
case 0x3e:
s->override = R_DS;
goto next_byte;
case 0x26:
s->override = R_ES;
goto next_byte;
case 0x64:
s->override = R_FS;
goto next_byte;
case 0x65:
s->override = R_GS;
goto next_byte;
case 0x66:
VAR_1 |= PREFIX_DATA;
goto next_byte;
case 0x67:
VAR_1 |= PREFIX_ADR;
goto next_byte;
}
if (VAR_1 & PREFIX_DATA)
VAR_3 ^= 1;
if (VAR_1 & PREFIX_ADR)
VAR_2 ^= 1;
}
s->prefix = VAR_1;
s->VAR_2 = VAR_2;
s->VAR_3 = VAR_3;
if (VAR_1 & PREFIX_LOCK)
gen_helper_lock();
reswitch:
switch(VAR_0) {
case 0x0f:
VAR_0 = ldub_code(s->pc++) | 0x100;
goto reswitch;
case 0x00 ... 0x05:
case 0x08 ... 0x0d:
case 0x10 ... 0x15:
case 0x18 ... 0x1d:
case 0x20 ... 0x25:
case 0x28 ... 0x2d:
case 0x30 ... 0x35:
case 0x38 ... 0x3d:
{
int VAR_17, VAR_17, VAR_18;
VAR_17 = (VAR_0 >> 3) & 7;
VAR_17 = (VAR_0 >> 1) & 3;
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 + OT_WORD;
switch(VAR_17) {
case 0:
VAR_6 = ldub_code(s->pc++);
VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;
VAR_9 = (VAR_6 >> 6) & 3;
VAR_8 = (VAR_6 & 7) | REX_B(s);
if (VAR_9 != 3) {
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
VAR_12 = OR_TMP0;
} else if (VAR_17 == OP_XORL && VAR_8 == VAR_7) {
xor_zero:
gen_op_movl_T0_0();
s->cc_op = CC_OP_LOGICB + VAR_5;
gen_op_mov_reg_T0(VAR_5, VAR_7);
gen_op_update1_cc();
break;
} else {
VAR_12 = VAR_8;
}
gen_op_mov_TN_reg(VAR_5, 1, VAR_7);
gen_op(s, VAR_17, VAR_5, VAR_12);
break;
case 1:
VAR_6 = ldub_code(s->pc++);
VAR_9 = (VAR_6 >> 6) & 3;
VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;
VAR_8 = (VAR_6 & 7) | REX_B(s);
if (VAR_9 != 3) {
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
gen_op_ld_T1_A0(VAR_5 + s->mem_index);
} else if (VAR_17 == OP_XORL && VAR_8 == VAR_7) {
goto xor_zero;
} else {
gen_op_mov_TN_reg(VAR_5, 1, VAR_8);
}
gen_op(s, VAR_17, VAR_5, VAR_7);
break;
case 2:
VAR_18 = insn_get(s, VAR_5);
gen_op_movl_T1_im(VAR_18);
gen_op(s, VAR_17, VAR_5, OR_EAX);
break;
}
}
break;
case 0x82:
if (CODE64(s))
goto illegal_op;
case 0x80:
case 0x81:
case 0x83:
{
int VAR_18;
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 + OT_WORD;
VAR_6 = ldub_code(s->pc++);
VAR_9 = (VAR_6 >> 6) & 3;
VAR_8 = (VAR_6 & 7) | REX_B(s);
VAR_17 = (VAR_6 >> 3) & 7;
if (VAR_9 != 3) {
if (VAR_0 == 0x83)
s->rip_offset = 1;
else
s->rip_offset = insn_const_size(VAR_5);
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
VAR_12 = OR_TMP0;
} else {
VAR_12 = VAR_8;
}
switch(VAR_0) {
default:
case 0x80:
case 0x81:
case 0x82:
VAR_18 = insn_get(s, VAR_5);
break;
case 0x83:
VAR_18 = (int8_t)insn_get(s, OT_BYTE);
break;
}
gen_op_movl_T1_im(VAR_18);
gen_op(s, VAR_17, VAR_5, VAR_12);
}
break;
case 0x40 ... 0x47:
VAR_5 = VAR_3 ? OT_LONG : OT_WORD;
gen_inc(s, VAR_5, OR_EAX + (VAR_0 & 7), 1);
break;
case 0x48 ... 0x4f:
VAR_5 = VAR_3 ? OT_LONG : OT_WORD;
gen_inc(s, VAR_5, OR_EAX + (VAR_0 & 7), -1);
break;
case 0xf6:
case 0xf7:
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 + OT_WORD;
VAR_6 = ldub_code(s->pc++);
VAR_9 = (VAR_6 >> 6) & 3;
VAR_8 = (VAR_6 & 7) | REX_B(s);
VAR_17 = (VAR_6 >> 3) & 7;
if (VAR_9 != 3) {
if (VAR_17 == 0)
s->rip_offset = insn_const_size(VAR_5);
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
gen_op_ld_T0_A0(VAR_5 + s->mem_index);
} else {
gen_op_mov_TN_reg(VAR_5, 0, VAR_8);
}
switch(VAR_17) {
case 0:
VAR_18 = insn_get(s, VAR_5);
gen_op_movl_T1_im(VAR_18);
gen_op_testl_T0_T1_cc();
s->cc_op = CC_OP_LOGICB + VAR_5;
break;
case 2:
tcg_gen_not_tl(cpu_T[0], cpu_T[0]);
if (VAR_9 != 3) {
gen_op_st_T0_A0(VAR_5 + s->mem_index);
} else {
gen_op_mov_reg_T0(VAR_5, VAR_8);
}
break;
case 3:
tcg_gen_neg_tl(cpu_T[0], cpu_T[0]);
if (VAR_9 != 3) {
gen_op_st_T0_A0(VAR_5 + s->mem_index);
} else {
gen_op_mov_reg_T0(VAR_5, VAR_8);
}
gen_op_update_neg_cc();
s->cc_op = CC_OP_SUBB + VAR_5;
break;
case 4:
switch(VAR_5) {
case OT_BYTE:
gen_op_mov_TN_reg(OT_BYTE, 1, R_EAX);
tcg_gen_ext8u_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext8u_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_andi_tl(cpu_cc_src, cpu_T[0], 0xff00);
s->cc_op = CC_OP_MULB;
break;
case OT_WORD:
gen_op_mov_TN_reg(OT_WORD, 1, R_EAX);
tcg_gen_ext16u_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext16u_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_shri_tl(cpu_T[0], cpu_T[0], 16);
gen_op_mov_reg_T0(OT_WORD, R_EDX);
tcg_gen_mov_tl(cpu_cc_src, cpu_T[0]);
s->cc_op = CC_OP_MULW;
break;
default:
case OT_LONG:
#ifdef TARGET_X86_64
gen_op_mov_TN_reg(OT_LONG, 1, R_EAX);
tcg_gen_ext32u_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext32u_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_LONG, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_shri_tl(cpu_T[0], cpu_T[0], 32);
gen_op_mov_reg_T0(OT_LONG, R_EDX);
tcg_gen_mov_tl(cpu_cc_src, cpu_T[0]);
#else
{
TCGv_i64 t0, t1;
t0 = tcg_temp_new_i64();
t1 = tcg_temp_new_i64();
gen_op_mov_TN_reg(OT_LONG, 1, R_EAX);
tcg_gen_extu_i32_i64(t0, cpu_T[0]);
tcg_gen_extu_i32_i64(t1, cpu_T[1]);
tcg_gen_mul_i64(t0, t0, t1);
tcg_gen_trunc_i64_i32(cpu_T[0], t0);
gen_op_mov_reg_T0(OT_LONG, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_shri_i64(t0, t0, 32);
tcg_gen_trunc_i64_i32(cpu_T[0], t0);
gen_op_mov_reg_T0(OT_LONG, R_EDX);
tcg_gen_mov_tl(cpu_cc_src, cpu_T[0]);
}
#endif
s->cc_op = CC_OP_MULL;
break;
#ifdef TARGET_X86_64
case OT_QUAD:
gen_helper_mulq_EAX_T0(cpu_T[0]);
s->cc_op = CC_OP_MULQ;
break;
#endif
}
break;
case 5:
switch(VAR_5) {
case OT_BYTE:
gen_op_mov_TN_reg(OT_BYTE, 1, R_EAX);
tcg_gen_ext8s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext8s_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_ext8s_tl(cpu_tmp0, cpu_T[0]);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
s->cc_op = CC_OP_MULB;
break;
case OT_WORD:
gen_op_mov_TN_reg(OT_WORD, 1, R_EAX);
tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext16s_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_ext16s_tl(cpu_tmp0, cpu_T[0]);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
tcg_gen_shri_tl(cpu_T[0], cpu_T[0], 16);
gen_op_mov_reg_T0(OT_WORD, R_EDX);
s->cc_op = CC_OP_MULW;
break;
default:
case OT_LONG:
#ifdef TARGET_X86_64
gen_op_mov_TN_reg(OT_LONG, 1, R_EAX);
tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext32s_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
gen_op_mov_reg_T0(OT_LONG, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_ext32s_tl(cpu_tmp0, cpu_T[0]);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
tcg_gen_shri_tl(cpu_T[0], cpu_T[0], 32);
gen_op_mov_reg_T0(OT_LONG, R_EDX);
#else
{
TCGv_i64 t0, t1;
t0 = tcg_temp_new_i64();
t1 = tcg_temp_new_i64();
gen_op_mov_TN_reg(OT_LONG, 1, R_EAX);
tcg_gen_ext_i32_i64(t0, cpu_T[0]);
tcg_gen_ext_i32_i64(t1, cpu_T[1]);
tcg_gen_mul_i64(t0, t0, t1);
tcg_gen_trunc_i64_i32(cpu_T[0], t0);
gen_op_mov_reg_T0(OT_LONG, R_EAX);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_sari_tl(cpu_tmp0, cpu_T[0], 31);
tcg_gen_shri_i64(t0, t0, 32);
tcg_gen_trunc_i64_i32(cpu_T[0], t0);
gen_op_mov_reg_T0(OT_LONG, R_EDX);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
}
#endif
s->cc_op = CC_OP_MULL;
break;
#ifdef TARGET_X86_64
case OT_QUAD:
gen_helper_imulq_EAX_T0(cpu_T[0]);
s->cc_op = CC_OP_MULQ;
break;
#endif
}
break;
case 6:
switch(VAR_5) {
case OT_BYTE:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_divb_AL(cpu_T[0]);
break;
case OT_WORD:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_divw_AX(cpu_T[0]);
break;
default:
case OT_LONG:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_divl_EAX(cpu_T[0]);
break;
#ifdef TARGET_X86_64
case OT_QUAD:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_divq_EAX(cpu_T[0]);
break;
#endif
}
break;
case 7:
switch(VAR_5) {
case OT_BYTE:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_idivb_AL(cpu_T[0]);
break;
case OT_WORD:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_idivw_AX(cpu_T[0]);
break;
default:
case OT_LONG:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_idivl_EAX(cpu_T[0]);
break;
#ifdef TARGET_X86_64
case OT_QUAD:
gen_jmp_im(pc_start - s->cs_base);
gen_helper_idivq_EAX(cpu_T[0]);
break;
#endif
}
break;
default:
goto illegal_op;
}
break;
case 0xfe:
case 0xff:
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 + OT_WORD;
VAR_6 = ldub_code(s->pc++);
VAR_9 = (VAR_6 >> 6) & 3;
VAR_8 = (VAR_6 & 7) | REX_B(s);
VAR_17 = (VAR_6 >> 3) & 7;
if (VAR_17 >= 2 && VAR_0 == 0xfe) {
goto illegal_op;
}
if (CODE64(s)) {
if (VAR_17 == 2 || VAR_17 == 4) {
VAR_5 = OT_QUAD;
} else if (VAR_17 == 3 || VAR_17 == 5) {
VAR_5 = VAR_3 ? OT_LONG : OT_WORD;
} else if (VAR_17 == 6) {
VAR_5 = VAR_3 ? OT_QUAD : OT_WORD;
}
}
if (VAR_9 != 3) {
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
if (VAR_17 >= 2 && VAR_17 != 3 && VAR_17 != 5)
gen_op_ld_T0_A0(VAR_5 + s->mem_index);
} else {
gen_op_mov_TN_reg(VAR_5, 0, VAR_8);
}
switch(VAR_17) {
case 0:
if (VAR_9 != 3)
VAR_12 = OR_TMP0;
else
VAR_12 = VAR_8;
gen_inc(s, VAR_5, VAR_12, 1);
break;
case 1:
if (VAR_9 != 3)
VAR_12 = OR_TMP0;
else
VAR_12 = VAR_8;
gen_inc(s, VAR_5, VAR_12, -1);
break;
case 2:
if (s->VAR_3 == 0)
gen_op_andl_T0_ffff();
next_eip = s->pc - s->cs_base;
gen_movtl_T1_im(next_eip);
gen_push_T1(s);
gen_op_jmp_T0();
gen_eob(s);
break;
case 3:
gen_op_ld_T1_A0(VAR_5 + s->mem_index);
gen_add_A0_im(s, 1 << (VAR_5 - OT_WORD + 1));
gen_op_ldu_T0_A0(OT_WORD + s->mem_index);
do_lcall:
if (s->pe && !s->vm86) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_lcall_protected(cpu_tmp2_i32, cpu_T[1],
tcg_const_i32(VAR_3),
tcg_const_i32(s->pc - pc_start));
} else {
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_lcall_real(cpu_tmp2_i32, cpu_T[1],
tcg_const_i32(VAR_3),
tcg_const_i32(s->pc - s->cs_base));
}
gen_eob(s);
break;
case 4:
if (s->VAR_3 == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
gen_eob(s);
break;
case 5:
gen_op_ld_T1_A0(VAR_5 + s->mem_index);
gen_add_A0_im(s, 1 << (VAR_5 - OT_WORD + 1));
gen_op_ldu_T0_A0(OT_WORD + s->mem_index);
do_ljmp:
if (s->pe && !s->vm86) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_ljmp_protected(cpu_tmp2_i32, cpu_T[1],
tcg_const_i32(s->pc - pc_start));
} else {
gen_op_movl_seg_T0_vm(R_CS);
gen_op_movl_T0_T1();
gen_op_jmp_T0();
}
gen_eob(s);
break;
case 6:
gen_push_T0(s);
break;
default:
goto illegal_op;
}
break;
case 0x84:
case 0x85:
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 + OT_WORD;
VAR_6 = ldub_code(s->pc++);
VAR_9 = (VAR_6 >> 6) & 3;
VAR_8 = (VAR_6 & 7) | REX_B(s);
VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;
gen_ldst_modrm(s, VAR_6, VAR_5, OR_TMP0, 0);
gen_op_mov_TN_reg(VAR_5, 1, VAR_7);
gen_op_testl_T0_T1_cc();
s->cc_op = CC_OP_LOGICB + VAR_5;
break;
case 0xa8:
case 0xa9:
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 + OT_WORD;
VAR_18 = insn_get(s, VAR_5);
gen_op_mov_TN_reg(VAR_5, 0, OR_EAX);
gen_op_movl_T1_im(VAR_18);
gen_op_testl_T0_T1_cc();
s->cc_op = CC_OP_LOGICB + VAR_5;
break;
case 0x98:
#ifdef TARGET_X86_64
if (VAR_3 == 2) {
gen_op_mov_TN_reg(OT_LONG, 0, R_EAX);
tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_QUAD, R_EAX);
} else
#endif
if (VAR_3 == 1) {
gen_op_mov_TN_reg(OT_WORD, 0, R_EAX);
tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_LONG, R_EAX);
} else {
gen_op_mov_TN_reg(OT_BYTE, 0, R_EAX);
tcg_gen_ext8s_tl(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
}
break;
case 0x99:
#ifdef TARGET_X86_64
if (VAR_3 == 2) {
gen_op_mov_TN_reg(OT_QUAD, 0, R_EAX);
tcg_gen_sari_tl(cpu_T[0], cpu_T[0], 63);
gen_op_mov_reg_T0(OT_QUAD, R_EDX);
} else
#endif
if (VAR_3 == 1) {
gen_op_mov_TN_reg(OT_LONG, 0, R_EAX);
tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_sari_tl(cpu_T[0], cpu_T[0], 31);
gen_op_mov_reg_T0(OT_LONG, R_EDX);
} else {
gen_op_mov_TN_reg(OT_WORD, 0, R_EAX);
tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_sari_tl(cpu_T[0], cpu_T[0], 15);
gen_op_mov_reg_T0(OT_WORD, R_EDX);
}
break;
case 0x1af:
case 0x69:
case 0x6b:
VAR_5 = VAR_3 + OT_WORD;
VAR_6 = ldub_code(s->pc++);
VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;
if (VAR_0 == 0x69)
s->rip_offset = insn_const_size(VAR_5);
else if (VAR_0 == 0x6b)
s->rip_offset = 1;
gen_ldst_modrm(s, VAR_6, VAR_5, OR_TMP0, 0);
if (VAR_0 == 0x69) {
VAR_18 = insn_get(s, VAR_5);
gen_op_movl_T1_im(VAR_18);
} else if (VAR_0 == 0x6b) {
VAR_18 = (int8_t)insn_get(s, OT_BYTE);
gen_op_movl_T1_im(VAR_18);
} else {
gen_op_mov_TN_reg(VAR_5, 1, VAR_7);
}
#ifdef TARGET_X86_64
if (VAR_5 == OT_QUAD) {
gen_helper_imulq_T0_T1(cpu_T[0], cpu_T[0], cpu_T[1]);
} else
#endif
if (VAR_5 == OT_LONG) {
#ifdef TARGET_X86_64
tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext32s_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_ext32s_tl(cpu_tmp0, cpu_T[0]);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
#else
{
TCGv_i64 t0, t1;
t0 = tcg_temp_new_i64();
t1 = tcg_temp_new_i64();
tcg_gen_ext_i32_i64(t0, cpu_T[0]);
tcg_gen_ext_i32_i64(t1, cpu_T[1]);
tcg_gen_mul_i64(t0, t0, t1);
tcg_gen_trunc_i64_i32(cpu_T[0], t0);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_sari_tl(cpu_tmp0, cpu_T[0], 31);
tcg_gen_shri_i64(t0, t0, 32);
tcg_gen_trunc_i64_i32(cpu_T[1], t0);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[1], cpu_tmp0);
}
#endif
} else {
tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);
tcg_gen_ext16s_tl(cpu_T[1], cpu_T[1]);
tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);
tcg_gen_ext16s_tl(cpu_tmp0, cpu_T[0]);
tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);
}
gen_op_mov_reg_T0(VAR_5, VAR_7);
s->cc_op = CC_OP_MULB + VAR_5;
break;
case 0x1c0:
case 0x1c1:
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 + OT_WORD;
VAR_6 = ldub_code(s->pc++);
VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;
VAR_9 = (VAR_6 >> 6) & 3;
if (VAR_9 == 3) {
VAR_8 = (VAR_6 & 7) | REX_B(s);
gen_op_mov_TN_reg(VAR_5, 0, VAR_7);
gen_op_mov_TN_reg(VAR_5, 1, VAR_8);
gen_op_addl_T0_T1();
gen_op_mov_reg_T1(VAR_5, VAR_7);
gen_op_mov_reg_T0(VAR_5, VAR_8);
} else {
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
gen_op_mov_TN_reg(VAR_5, 0, VAR_7);
gen_op_ld_T1_A0(VAR_5 + s->mem_index);
gen_op_addl_T0_T1();
gen_op_st_T0_A0(VAR_5 + s->mem_index);
gen_op_mov_reg_T1(VAR_5, VAR_7);
}
gen_op_update2_cc();
s->cc_op = CC_OP_ADDB + VAR_5;
break;
case 0x1b0:
case 0x1b1:
{
int VAR_29, VAR_19;
TCGv t0, t1, t2, a0;
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 + OT_WORD;
VAR_6 = ldub_code(s->pc++);
VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;
VAR_9 = (VAR_6 >> 6) & 3;
t0 = tcg_temp_local_new();
t1 = tcg_temp_local_new();
t2 = tcg_temp_local_new();
a0 = tcg_temp_local_new();
gen_op_mov_v_reg(VAR_5, t1, VAR_7);
if (VAR_9 == 3) {
VAR_8 = (VAR_6 & 7) | REX_B(s);
gen_op_mov_v_reg(VAR_5, t0, VAR_8);
} else {
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
tcg_gen_mov_tl(a0, cpu_A0);
gen_op_ld_v(VAR_5 + s->mem_index, t0, a0);
VAR_8 = 0;
}
VAR_29 = gen_new_label();
tcg_gen_ld_tl(t2, cpu_env, offsetof(CPUState, regs[R_EAX]));
tcg_gen_sub_tl(t2, t2, t0);
gen_extu(VAR_5, t2);
tcg_gen_brcondi_tl(TCG_COND_EQ, t2, 0, VAR_29);
if (VAR_9 == 3) {
VAR_19 = gen_new_label();
gen_op_mov_reg_v(VAR_5, R_EAX, t0);
tcg_gen_br(VAR_19);
gen_set_label(VAR_29);
gen_op_mov_reg_v(VAR_5, VAR_8, t1);
gen_set_label(VAR_19);
} else {
tcg_gen_mov_tl(t1, t0);
gen_op_mov_reg_v(VAR_5, R_EAX, t0);
gen_set_label(VAR_29);
gen_op_st_v(VAR_5 + s->mem_index, t1, a0);
}
tcg_gen_mov_tl(cpu_cc_src, t0);
tcg_gen_mov_tl(cpu_cc_dst, t2);
s->cc_op = CC_OP_SUBB + VAR_5;
tcg_temp_free(t0);
tcg_temp_free(t1);
tcg_temp_free(t2);
tcg_temp_free(a0);
}
break;
case 0x1c7:
VAR_6 = ldub_code(s->pc++);
VAR_9 = (VAR_6 >> 6) & 3;
if ((VAR_9 == 3) || ((VAR_6 & 0x38) != 0x8))
goto illegal_op;
#ifdef TARGET_X86_64
if (VAR_3 == 2) {
if (!(s->cpuid_ext_features & CPUID_EXT_CX16))
goto illegal_op;
gen_jmp_im(pc_start - s->cs_base);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
gen_helper_cmpxchg16b(cpu_A0);
} else
#endif
{
if (!(s->cpuid_features & CPUID_CX8))
goto illegal_op;
gen_jmp_im(pc_start - s->cs_base);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
gen_helper_cmpxchg8b(cpu_A0);
}
s->cc_op = CC_OP_EFLAGS;
break;
case 0x50 ... 0x57:
gen_op_mov_TN_reg(OT_LONG, 0, (VAR_0 & 7) | REX_B(s));
gen_push_T0(s);
break;
case 0x58 ... 0x5f:
if (CODE64(s)) {
VAR_5 = VAR_3 ? OT_QUAD : OT_WORD;
} else {
VAR_5 = VAR_3 + OT_WORD;
}
gen_pop_T0(s);
gen_pop_update(s);
gen_op_mov_reg_T0(VAR_5, (VAR_0 & 7) | REX_B(s));
break;
case 0x60:
if (CODE64(s))
goto illegal_op;
gen_pusha(s);
break;
case 0x61:
if (CODE64(s))
goto illegal_op;
gen_popa(s);
break;
case 0x68:
case 0x6a:
if (CODE64(s)) {
VAR_5 = VAR_3 ? OT_QUAD : OT_WORD;
} else {
VAR_5 = VAR_3 + OT_WORD;
}
if (VAR_0 == 0x68)
VAR_18 = insn_get(s, VAR_5);
else
VAR_18 = (int8_t)insn_get(s, OT_BYTE);
gen_op_movl_T0_im(VAR_18);
gen_push_T0(s);
break;
case 0x8f:
if (CODE64(s)) {
VAR_5 = VAR_3 ? OT_QUAD : OT_WORD;
} else {
VAR_5 = VAR_3 + OT_WORD;
}
VAR_6 = ldub_code(s->pc++);
VAR_9 = (VAR_6 >> 6) & 3;
gen_pop_T0(s);
if (VAR_9 == 3) {
gen_pop_update(s);
VAR_8 = (VAR_6 & 7) | REX_B(s);
gen_op_mov_reg_T0(VAR_5, VAR_8);
} else {
s->popl_esp_hack = 1 << VAR_5;
gen_ldst_modrm(s, VAR_6, VAR_5, OR_TMP0, 1);
s->popl_esp_hack = 0;
gen_pop_update(s);
}
break;
case 0xc8:
{
int VAR_20;
VAR_18 = lduw_code(s->pc);
s->pc += 2;
VAR_20 = ldub_code(s->pc++);
gen_enter(s, VAR_18, VAR_20);
}
break;
case 0xc9:
if (CODE64(s)) {
gen_op_mov_TN_reg(OT_QUAD, 0, R_EBP);
gen_op_mov_reg_T0(OT_QUAD, R_ESP);
} else if (s->ss32) {
gen_op_mov_TN_reg(OT_LONG, 0, R_EBP);
gen_op_mov_reg_T0(OT_LONG, R_ESP);
} else {
gen_op_mov_TN_reg(OT_WORD, 0, R_EBP);
gen_op_mov_reg_T0(OT_WORD, R_ESP);
}
gen_pop_T0(s);
if (CODE64(s)) {
VAR_5 = VAR_3 ? OT_QUAD : OT_WORD;
} else {
VAR_5 = VAR_3 + OT_WORD;
}
gen_op_mov_reg_T0(VAR_5, R_EBP);
gen_pop_update(s);
break;
case 0x06:
case 0x0e:
case 0x16:
case 0x1e:
if (CODE64(s))
goto illegal_op;
gen_op_movl_T0_seg(VAR_0 >> 3);
gen_push_T0(s);
break;
case 0x1a0:
case 0x1a8:
gen_op_movl_T0_seg((VAR_0 >> 3) & 7);
gen_push_T0(s);
break;
case 0x07:
case 0x17:
case 0x1f:
if (CODE64(s))
goto illegal_op;
VAR_7 = VAR_0 >> 3;
gen_pop_T0(s);
gen_movl_seg_T0(s, VAR_7, pc_start - s->cs_base);
gen_pop_update(s);
if (VAR_7 == R_SS) {
if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK))
gen_helper_set_inhibit_irq();
s->tf = 0;
}
if (s->is_jmp) {
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x1a1:
case 0x1a9:
gen_pop_T0(s);
gen_movl_seg_T0(s, (VAR_0 >> 3) & 7, pc_start - s->cs_base);
gen_pop_update(s);
if (s->is_jmp) {
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x88:
case 0x89:
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 + OT_WORD;
VAR_6 = ldub_code(s->pc++);
VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;
gen_ldst_modrm(s, VAR_6, VAR_5, VAR_7, 1);
break;
case 0xc6:
case 0xc7:
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 + OT_WORD;
VAR_6 = ldub_code(s->pc++);
VAR_9 = (VAR_6 >> 6) & 3;
if (VAR_9 != 3) {
s->rip_offset = insn_const_size(VAR_5);
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
}
VAR_18 = insn_get(s, VAR_5);
gen_op_movl_T0_im(VAR_18);
if (VAR_9 != 3)
gen_op_st_T0_A0(VAR_5 + s->mem_index);
else
gen_op_mov_reg_T0(VAR_5, (VAR_6 & 7) | REX_B(s));
break;
case 0x8a:
case 0x8b:
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = OT_WORD + VAR_3;
VAR_6 = ldub_code(s->pc++);
VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;
gen_ldst_modrm(s, VAR_6, VAR_5, OR_TMP0, 0);
gen_op_mov_reg_T0(VAR_5, VAR_7);
break;
case 0x8e:
VAR_6 = ldub_code(s->pc++);
VAR_7 = (VAR_6 >> 3) & 7;
if (VAR_7 >= 6 || VAR_7 == R_CS)
goto illegal_op;
gen_ldst_modrm(s, VAR_6, OT_WORD, OR_TMP0, 0);
gen_movl_seg_T0(s, VAR_7, pc_start - s->cs_base);
if (VAR_7 == R_SS) {
if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK))
gen_helper_set_inhibit_irq();
s->tf = 0;
}
if (s->is_jmp) {
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x8c:
VAR_6 = ldub_code(s->pc++);
VAR_7 = (VAR_6 >> 3) & 7;
VAR_9 = (VAR_6 >> 6) & 3;
if (VAR_7 >= 6)
goto illegal_op;
gen_op_movl_T0_seg(VAR_7);
if (VAR_9 == 3)
VAR_5 = OT_WORD + VAR_3;
else
VAR_5 = OT_WORD;
gen_ldst_modrm(s, VAR_6, VAR_5, OR_TMP0, 1);
break;
case 0x1b6:
case 0x1b7:
case 0x1be:
case 0x1bf:
{
int VAR_21;
VAR_21 = VAR_3 + OT_WORD;
VAR_5 = (VAR_0 & 1) + OT_BYTE;
VAR_6 = ldub_code(s->pc++);
VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;
VAR_9 = (VAR_6 >> 6) & 3;
VAR_8 = (VAR_6 & 7) | REX_B(s);
if (VAR_9 == 3) {
gen_op_mov_TN_reg(VAR_5, 0, VAR_8);
switch(VAR_5 | (VAR_0 & 8)) {
case OT_BYTE:
tcg_gen_ext8u_tl(cpu_T[0], cpu_T[0]);
break;
case OT_BYTE | 8:
tcg_gen_ext8s_tl(cpu_T[0], cpu_T[0]);
break;
case OT_WORD:
tcg_gen_ext16u_tl(cpu_T[0], cpu_T[0]);
break;
default:
case OT_WORD | 8:
tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);
break;
}
gen_op_mov_reg_T0(VAR_21, VAR_7);
} else {
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
if (VAR_0 & 8) {
gen_op_lds_T0_A0(VAR_5 + s->mem_index);
} else {
gen_op_ldu_T0_A0(VAR_5 + s->mem_index);
}
gen_op_mov_reg_T0(VAR_21, VAR_7);
}
}
break;
case 0x8d:
VAR_5 = VAR_3 + OT_WORD;
VAR_6 = ldub_code(s->pc++);
VAR_9 = (VAR_6 >> 6) & 3;
if (VAR_9 == 3)
goto illegal_op;
VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;
s->override = -1;
VAR_18 = s->addseg;
s->addseg = 0;
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
s->addseg = VAR_18;
gen_op_mov_reg_A0(VAR_5 - OT_WORD, VAR_7);
break;
case 0xa0:
case 0xa1:
case 0xa2:
case 0xa3:
{
target_ulong VAR_13;
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 + OT_WORD;
#ifdef TARGET_X86_64
if (s->VAR_2 == 2) {
VAR_13 = ldq_code(s->pc);
s->pc += 8;
gen_op_movq_A0_im(VAR_13);
} else
#endif
{
if (s->VAR_2) {
VAR_13 = insn_get(s, OT_LONG);
} else {
VAR_13 = insn_get(s, OT_WORD);
}
gen_op_movl_A0_im(VAR_13);
}
gen_add_A0_ds_seg(s);
if ((VAR_0 & 2) == 0) {
gen_op_ld_T0_A0(VAR_5 + s->mem_index);
gen_op_mov_reg_T0(VAR_5, R_EAX);
} else {
gen_op_mov_TN_reg(VAR_5, 0, R_EAX);
gen_op_st_T0_A0(VAR_5 + s->mem_index);
}
}
break;
case 0xd7:
#ifdef TARGET_X86_64
if (s->VAR_2 == 2) {
gen_op_movq_A0_reg(R_EBX);
gen_op_mov_TN_reg(OT_QUAD, 0, R_EAX);
tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0xff);
tcg_gen_add_tl(cpu_A0, cpu_A0, cpu_T[0]);
} else
#endif
{
gen_op_movl_A0_reg(R_EBX);
gen_op_mov_TN_reg(OT_LONG, 0, R_EAX);
tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0xff);
tcg_gen_add_tl(cpu_A0, cpu_A0, cpu_T[0]);
if (s->VAR_2 == 0)
gen_op_andl_A0_ffff();
else
tcg_gen_andi_tl(cpu_A0, cpu_A0, 0xffffffff);
}
gen_add_A0_ds_seg(s);
gen_op_ldu_T0_A0(OT_BYTE + s->mem_index);
gen_op_mov_reg_T0(OT_BYTE, R_EAX);
break;
case 0xb0 ... 0xb7:
VAR_18 = insn_get(s, OT_BYTE);
gen_op_movl_T0_im(VAR_18);
gen_op_mov_reg_T0(OT_BYTE, (VAR_0 & 7) | REX_B(s));
break;
case 0xb8 ... 0xbf:
#ifdef TARGET_X86_64
if (VAR_3 == 2) {
uint64_t tmp;
tmp = ldq_code(s->pc);
s->pc += 8;
VAR_7 = (VAR_0 & 7) | REX_B(s);
gen_movtl_T0_im(tmp);
gen_op_mov_reg_T0(OT_QUAD, VAR_7);
} else
#endif
{
VAR_5 = VAR_3 ? OT_LONG : OT_WORD;
VAR_18 = insn_get(s, VAR_5);
VAR_7 = (VAR_0 & 7) | REX_B(s);
gen_op_movl_T0_im(VAR_18);
gen_op_mov_reg_T0(VAR_5, VAR_7);
}
break;
case 0x91 ... 0x97:
VAR_5 = VAR_3 + OT_WORD;
VAR_7 = (VAR_0 & 7) | REX_B(s);
VAR_8 = R_EAX;
goto do_xchg_reg;
case 0x86:
case 0x87:
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 + OT_WORD;
VAR_6 = ldub_code(s->pc++);
VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;
VAR_9 = (VAR_6 >> 6) & 3;
if (VAR_9 == 3) {
VAR_8 = (VAR_6 & 7) | REX_B(s);
do_xchg_reg:
gen_op_mov_TN_reg(VAR_5, 0, VAR_7);
gen_op_mov_TN_reg(VAR_5, 1, VAR_8);
gen_op_mov_reg_T0(VAR_5, VAR_8);
gen_op_mov_reg_T1(VAR_5, VAR_7);
} else {
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
gen_op_mov_TN_reg(VAR_5, 0, VAR_7);
if (!(VAR_1 & PREFIX_LOCK))
gen_helper_lock();
gen_op_ld_T1_A0(VAR_5 + s->mem_index);
gen_op_st_T0_A0(VAR_5 + s->mem_index);
if (!(VAR_1 & PREFIX_LOCK))
gen_helper_unlock();
gen_op_mov_reg_T1(VAR_5, VAR_7);
}
break;
case 0xc4:
if (CODE64(s))
goto illegal_op;
VAR_17 = R_ES;
goto do_lxx;
case 0xc5:
if (CODE64(s))
goto illegal_op;
VAR_17 = R_DS;
goto do_lxx;
case 0x1b2:
VAR_17 = R_SS;
goto do_lxx;
case 0x1b4:
VAR_17 = R_FS;
goto do_lxx;
case 0x1b5:
VAR_17 = R_GS;
do_lxx:
VAR_5 = VAR_3 ? OT_LONG : OT_WORD;
VAR_6 = ldub_code(s->pc++);
VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;
VAR_9 = (VAR_6 >> 6) & 3;
if (VAR_9 == 3)
goto illegal_op;
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
gen_op_ld_T1_A0(VAR_5 + s->mem_index);
gen_add_A0_im(s, 1 << (VAR_5 - OT_WORD + 1));
gen_op_ldu_T0_A0(OT_WORD + s->mem_index);
gen_movl_seg_T0(s, VAR_17, pc_start - s->cs_base);
gen_op_mov_reg_T1(VAR_5, VAR_7);
if (s->is_jmp) {
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0xc0:
case 0xc1:
VAR_4 = 2;
grp2:
{
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 + OT_WORD;
VAR_6 = ldub_code(s->pc++);
VAR_9 = (VAR_6 >> 6) & 3;
VAR_17 = (VAR_6 >> 3) & 7;
if (VAR_9 != 3) {
if (VAR_4 == 2) {
s->rip_offset = 1;
}
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
VAR_12 = OR_TMP0;
} else {
VAR_12 = (VAR_6 & 7) | REX_B(s);
}
if (VAR_4 == 0) {
gen_shift(s, VAR_17, VAR_5, VAR_12, OR_ECX);
} else {
if (VAR_4 == 2) {
VAR_4 = ldub_code(s->pc++);
}
gen_shifti(s, VAR_17, VAR_5, VAR_12, VAR_4);
}
}
break;
case 0xd0:
case 0xd1:
VAR_4 = 1;
goto grp2;
case 0xd2:
case 0xd3:
VAR_4 = 0;
goto grp2;
case 0x1a4:
VAR_17 = 0;
VAR_4 = 1;
goto do_shiftd;
case 0x1a5:
VAR_17 = 0;
VAR_4 = 0;
goto do_shiftd;
case 0x1ac:
VAR_17 = 1;
VAR_4 = 1;
goto do_shiftd;
case 0x1ad:
VAR_17 = 1;
VAR_4 = 0;
do_shiftd:
VAR_5 = VAR_3 + OT_WORD;
VAR_6 = ldub_code(s->pc++);
VAR_9 = (VAR_6 >> 6) & 3;
VAR_8 = (VAR_6 & 7) | REX_B(s);
VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;
if (VAR_9 != 3) {
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
VAR_12 = OR_TMP0;
} else {
VAR_12 = VAR_8;
}
gen_op_mov_TN_reg(VAR_5, 1, VAR_7);
if (VAR_4) {
VAR_18 = ldub_code(s->pc++);
tcg_gen_movi_tl(cpu_T3, VAR_18);
} else {
tcg_gen_ld_tl(cpu_T3, cpu_env, offsetof(CPUState, regs[R_ECX]));
}
gen_shiftd_rm_T1_T3(s, VAR_5, VAR_12, VAR_17);
break;
case 0xd8 ... 0xdf:
if (s->flags & (HF_EM_MASK | HF_TS_MASK)) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
break;
}
VAR_6 = ldub_code(s->pc++);
VAR_9 = (VAR_6 >> 6) & 3;
VAR_8 = VAR_6 & 7;
VAR_17 = ((VAR_0 & 7) << 3) | ((VAR_6 >> 3) & 7);
if (VAR_9 != 3) {
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
switch(VAR_17) {
case 0x00 ... 0x07:
case 0x10 ... 0x17:
case 0x20 ... 0x27:
case 0x30 ... 0x37:
{
int VAR_23;
VAR_23 = VAR_17 & 7;
switch(VAR_17 >> 4) {
case 0:
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_flds_FT0(cpu_tmp2_i32);
break;
case 1:
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_fildl_FT0(cpu_tmp2_i32);
break;
case 2:
tcg_gen_qemu_ld64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
gen_helper_fldl_FT0(cpu_tmp1_i64);
break;
case 3:
default:
gen_op_lds_T0_A0(OT_WORD + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_fildl_FT0(cpu_tmp2_i32);
break;
}
gen_helper_fp_arith_ST0_FT0(VAR_23);
if (VAR_23 == 3) {
gen_helper_fpop();
}
}
break;
case 0x08:
case 0x0a:
case 0x0b:
case 0x18 ... 0x1b:
case 0x28 ... 0x2b:
case 0x38 ... 0x3b:
switch(VAR_17 & 7) {
case 0:
switch(VAR_17 >> 4) {
case 0:
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_flds_ST0(cpu_tmp2_i32);
break;
case 1:
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_fildl_ST0(cpu_tmp2_i32);
break;
case 2:
tcg_gen_qemu_ld64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
gen_helper_fldl_ST0(cpu_tmp1_i64);
break;
case 3:
default:
gen_op_lds_T0_A0(OT_WORD + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_fildl_ST0(cpu_tmp2_i32);
break;
}
break;
case 1:
switch(VAR_17 >> 4) {
case 1:
gen_helper_fisttl_ST0(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_LONG + s->mem_index);
break;
case 2:
gen_helper_fisttll_ST0(cpu_tmp1_i64);
tcg_gen_qemu_st64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
break;
case 3:
default:
gen_helper_fistt_ST0(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_WORD + s->mem_index);
break;
}
gen_helper_fpop();
break;
default:
switch(VAR_17 >> 4) {
case 0:
gen_helper_fsts_ST0(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_LONG + s->mem_index);
break;
case 1:
gen_helper_fistl_ST0(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_LONG + s->mem_index);
break;
case 2:
gen_helper_fstl_ST0(cpu_tmp1_i64);
tcg_gen_qemu_st64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
break;
case 3:
default:
gen_helper_fist_ST0(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_WORD + s->mem_index);
break;
}
if ((VAR_17 & 7) == 3)
gen_helper_fpop();
break;
}
break;
case 0x0c:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fldenv(
cpu_A0, tcg_const_i32(s->VAR_3));
break;
case 0x0d:
gen_op_ld_T0_A0(OT_WORD + s->mem_index);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_fldcw(cpu_tmp2_i32);
break;
case 0x0e:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fstenv(cpu_A0, tcg_const_i32(s->VAR_3));
break;
case 0x0f:
gen_helper_fnstcw(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_WORD + s->mem_index);
break;
case 0x1d:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fldt_ST0(cpu_A0);
break;
case 0x1f:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fstt_ST0(cpu_A0);
gen_helper_fpop();
break;
case 0x2c:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_frstor(cpu_A0, tcg_const_i32(s->VAR_3));
break;
case 0x2e:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fsave(cpu_A0, tcg_const_i32(s->VAR_3));
break;
case 0x2f:
gen_helper_fnstsw(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_st_T0_A0(OT_WORD + s->mem_index);
break;
case 0x3c:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fbld_ST0(cpu_A0);
break;
case 0x3e:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fbst_ST0(cpu_A0);
gen_helper_fpop();
break;
case 0x3d:
tcg_gen_qemu_ld64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
gen_helper_fildll_ST0(cpu_tmp1_i64);
break;
case 0x3f:
gen_helper_fistll_ST0(cpu_tmp1_i64);
tcg_gen_qemu_st64(cpu_tmp1_i64, cpu_A0,
(s->mem_index >> 2) - 1);
gen_helper_fpop();
break;
default:
goto illegal_op;
}
} else {
VAR_12 = VAR_8;
switch(VAR_17) {
case 0x08:
gen_helper_fpush();
gen_helper_fmov_ST0_STN(tcg_const_i32((VAR_12 + 1) & 7));
break;
case 0x09:
case 0x29:
case 0x39:
gen_helper_fxchg_ST0_STN(tcg_const_i32(VAR_12));
break;
case 0x0a:
switch(VAR_8) {
case 0:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fwait();
break;
default:
goto illegal_op;
}
break;
case 0x0c:
switch(VAR_8) {
case 0:
gen_helper_fchs_ST0();
break;
case 1:
gen_helper_fabs_ST0();
break;
case 4:
gen_helper_fldz_FT0();
gen_helper_fcom_ST0_FT0();
break;
case 5:
gen_helper_fxam_ST0();
break;
default:
goto illegal_op;
}
break;
case 0x0d:
{
switch(VAR_8) {
case 0:
gen_helper_fpush();
gen_helper_fld1_ST0();
break;
case 1:
gen_helper_fpush();
gen_helper_fldl2t_ST0();
break;
case 2:
gen_helper_fpush();
gen_helper_fldl2e_ST0();
break;
case 3:
gen_helper_fpush();
gen_helper_fldpi_ST0();
break;
case 4:
gen_helper_fpush();
gen_helper_fldlg2_ST0();
break;
case 5:
gen_helper_fpush();
gen_helper_fldln2_ST0();
break;
case 6:
gen_helper_fpush();
gen_helper_fldz_ST0();
break;
default:
goto illegal_op;
}
}
break;
case 0x0e:
switch(VAR_8) {
case 0:
gen_helper_f2xm1();
break;
case 1:
gen_helper_fyl2x();
break;
case 2:
gen_helper_fptan();
break;
case 3:
gen_helper_fpatan();
break;
case 4:
gen_helper_fxtract();
break;
case 5:
gen_helper_fprem1();
break;
case 6:
gen_helper_fdecstp();
break;
default:
case 7:
gen_helper_fincstp();
break;
}
break;
case 0x0f:
switch(VAR_8) {
case 0:
gen_helper_fprem();
break;
case 1:
gen_helper_fyl2xp1();
break;
case 2:
gen_helper_fsqrt();
break;
case 3:
gen_helper_fsincos();
break;
case 5:
gen_helper_fscale();
break;
case 4:
gen_helper_frndint();
break;
case 6:
gen_helper_fsin();
break;
default:
case 7:
gen_helper_fcos();
break;
}
break;
case 0x00: case 0x01: case 0x04 ... 0x07:
case 0x20: case 0x21: case 0x24 ... 0x27:
case 0x30: case 0x31: case 0x34 ... 0x37:
{
int VAR_23;
VAR_23 = VAR_17 & 7;
if (VAR_17 >= 0x20) {
gen_helper_fp_arith_STN_ST0(VAR_23, VAR_12);
if (VAR_17 >= 0x30)
gen_helper_fpop();
} else {
gen_helper_fmov_FT0_STN(tcg_const_i32(VAR_12));
gen_helper_fp_arith_ST0_FT0(VAR_23);
}
}
break;
case 0x02:
case 0x22:
gen_helper_fmov_FT0_STN(tcg_const_i32(VAR_12));
gen_helper_fcom_ST0_FT0();
break;
case 0x03:
case 0x23:
case 0x32:
gen_helper_fmov_FT0_STN(tcg_const_i32(VAR_12));
gen_helper_fcom_ST0_FT0();
gen_helper_fpop();
break;
case 0x15:
switch(VAR_8) {
case 1:
gen_helper_fmov_FT0_STN(tcg_const_i32(1));
gen_helper_fucom_ST0_FT0();
gen_helper_fpop();
gen_helper_fpop();
break;
default:
goto illegal_op;
}
break;
case 0x1c:
switch(VAR_8) {
case 0:
break;
case 1:
break;
case 2:
gen_helper_fclex();
break;
case 3:
gen_helper_fninit();
break;
case 4:
break;
default:
goto illegal_op;
}
break;
case 0x1d:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_fmov_FT0_STN(tcg_const_i32(VAR_12));
gen_helper_fucomi_ST0_FT0();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x1e:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_fmov_FT0_STN(tcg_const_i32(VAR_12));
gen_helper_fcomi_ST0_FT0();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x28:
gen_helper_ffree_STN(tcg_const_i32(VAR_12));
break;
case 0x2a:
gen_helper_fmov_STN_ST0(tcg_const_i32(VAR_12));
break;
case 0x2b:
case 0x0b:
case 0x3a:
case 0x3b:
gen_helper_fmov_STN_ST0(tcg_const_i32(VAR_12));
gen_helper_fpop();
break;
case 0x2c:
gen_helper_fmov_FT0_STN(tcg_const_i32(VAR_12));
gen_helper_fucom_ST0_FT0();
break;
case 0x2d:
gen_helper_fmov_FT0_STN(tcg_const_i32(VAR_12));
gen_helper_fucom_ST0_FT0();
gen_helper_fpop();
break;
case 0x33:
switch(VAR_8) {
case 1:
gen_helper_fmov_FT0_STN(tcg_const_i32(1));
gen_helper_fcom_ST0_FT0();
gen_helper_fpop();
gen_helper_fpop();
break;
default:
goto illegal_op;
}
break;
case 0x38:
gen_helper_ffree_STN(tcg_const_i32(VAR_12));
gen_helper_fpop();
break;
case 0x3c:
switch(VAR_8) {
case 0:
gen_helper_fnstsw(cpu_tmp2_i32);
tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
gen_op_mov_reg_T0(OT_WORD, R_EAX);
break;
default:
goto illegal_op;
}
break;
case 0x3d:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_fmov_FT0_STN(tcg_const_i32(VAR_12));
gen_helper_fucomi_ST0_FT0();
gen_helper_fpop();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x3e:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_fmov_FT0_STN(tcg_const_i32(VAR_12));
gen_helper_fcomi_ST0_FT0();
gen_helper_fpop();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x10 ... 0x13:
case 0x18 ... 0x1b:
{
int VAR_23, VAR_27;
static const uint8_t VAR_24[8] = {
(JCC_B << 1),
(JCC_Z << 1),
(JCC_BE << 1),
(JCC_P << 1),
};
VAR_23 = VAR_24[VAR_17 & 3] | (((VAR_17 >> 3) & 1) ^ 1);
VAR_27 = gen_new_label();
gen_jcc1(s, s->cc_op, VAR_23, VAR_27);
gen_helper_fmov_ST0_STN(tcg_const_i32(VAR_12));
gen_set_label(VAR_27);
}
break;
default:
goto illegal_op;
}
}
break;
case 0xa4:
case 0xa5:
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 + OT_WORD;
if (VAR_1 & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_movs(s, VAR_5, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_movs(s, VAR_5);
}
break;
case 0xaa:
case 0xab:
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 + OT_WORD;
if (VAR_1 & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_stos(s, VAR_5, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_stos(s, VAR_5);
}
break;
case 0xac:
case 0xad:
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 + OT_WORD;
if (VAR_1 & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_lods(s, VAR_5, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_lods(s, VAR_5);
}
break;
case 0xae:
case 0xaf:
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 + OT_WORD;
if (VAR_1 & PREFIX_REPNZ) {
gen_repz_scas(s, VAR_5, pc_start - s->cs_base, s->pc - s->cs_base, 1);
} else if (VAR_1 & PREFIX_REPZ) {
gen_repz_scas(s, VAR_5, pc_start - s->cs_base, s->pc - s->cs_base, 0);
} else {
gen_scas(s, VAR_5);
s->cc_op = CC_OP_SUBB + VAR_5;
}
break;
case 0xa6:
case 0xa7:
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 + OT_WORD;
if (VAR_1 & PREFIX_REPNZ) {
gen_repz_cmps(s, VAR_5, pc_start - s->cs_base, s->pc - s->cs_base, 1);
} else if (VAR_1 & PREFIX_REPZ) {
gen_repz_cmps(s, VAR_5, pc_start - s->cs_base, s->pc - s->cs_base, 0);
} else {
gen_cmps(s, VAR_5);
s->cc_op = CC_OP_SUBB + VAR_5;
}
break;
case 0x6c:
case 0x6d:
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 ? OT_LONG : OT_WORD;
gen_op_mov_TN_reg(OT_WORD, 0, R_EDX);
gen_op_andl_T0_ffff();
gen_check_io(s, VAR_5, pc_start - s->cs_base,
SVM_IOIO_TYPE_MASK | svm_is_rep(VAR_1) | 4);
if (VAR_1 & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_ins(s, VAR_5, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_ins(s, VAR_5);
if (use_icount) {
gen_jmp(s, s->pc - s->cs_base);
}
}
break;
case 0x6e:
case 0x6f:
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 ? OT_LONG : OT_WORD;
gen_op_mov_TN_reg(OT_WORD, 0, R_EDX);
gen_op_andl_T0_ffff();
gen_check_io(s, VAR_5, pc_start - s->cs_base,
svm_is_rep(VAR_1) | 4);
if (VAR_1 & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_outs(s, VAR_5, pc_start - s->cs_base, s->pc - s->cs_base);
} else {
gen_outs(s, VAR_5);
if (use_icount) {
gen_jmp(s, s->pc - s->cs_base);
}
}
break;
case 0xe4:
case 0xe5:
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 ? OT_LONG : OT_WORD;
VAR_18 = ldub_code(s->pc++);
gen_op_movl_T0_im(VAR_18);
gen_check_io(s, VAR_5, pc_start - s->cs_base,
SVM_IOIO_TYPE_MASK | svm_is_rep(VAR_1));
if (use_icount)
gen_io_start();
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_in_func(VAR_5, cpu_T[1], cpu_tmp2_i32);
gen_op_mov_reg_T1(VAR_5, R_EAX);
if (use_icount) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0xe6:
case 0xe7:
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 ? OT_LONG : OT_WORD;
VAR_18 = ldub_code(s->pc++);
gen_op_movl_T0_im(VAR_18);
gen_check_io(s, VAR_5, pc_start - s->cs_base,
svm_is_rep(VAR_1));
gen_op_mov_TN_reg(VAR_5, 1, R_EAX);
if (use_icount)
gen_io_start();
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff);
tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T[1]);
gen_helper_out_func(VAR_5, cpu_tmp2_i32, cpu_tmp3_i32);
if (use_icount) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0xec:
case 0xed:
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 ? OT_LONG : OT_WORD;
gen_op_mov_TN_reg(OT_WORD, 0, R_EDX);
gen_op_andl_T0_ffff();
gen_check_io(s, VAR_5, pc_start - s->cs_base,
SVM_IOIO_TYPE_MASK | svm_is_rep(VAR_1));
if (use_icount)
gen_io_start();
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_in_func(VAR_5, cpu_T[1], cpu_tmp2_i32);
gen_op_mov_reg_T1(VAR_5, R_EAX);
if (use_icount) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0xee:
case 0xef:
if ((VAR_0 & 1) == 0)
VAR_5 = OT_BYTE;
else
VAR_5 = VAR_3 ? OT_LONG : OT_WORD;
gen_op_mov_TN_reg(OT_WORD, 0, R_EDX);
gen_op_andl_T0_ffff();
gen_check_io(s, VAR_5, pc_start - s->cs_base,
svm_is_rep(VAR_1));
gen_op_mov_TN_reg(VAR_5, 1, R_EAX);
if (use_icount)
gen_io_start();
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff);
tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T[1]);
gen_helper_out_func(VAR_5, cpu_tmp2_i32, cpu_tmp3_i32);
if (use_icount) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0xc2:
VAR_18 = ldsw_code(s->pc);
s->pc += 2;
gen_pop_T0(s);
if (CODE64(s) && s->VAR_3)
s->VAR_3 = 2;
gen_stack_update(s, VAR_18 + (2 << s->VAR_3));
if (s->VAR_3 == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
gen_eob(s);
break;
case 0xc3:
gen_pop_T0(s);
gen_pop_update(s);
if (s->VAR_3 == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
gen_eob(s);
break;
case 0xca:
VAR_18 = ldsw_code(s->pc);
s->pc += 2;
do_lret:
if (s->pe && !s->vm86) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_lret_protected(tcg_const_i32(s->VAR_3),
tcg_const_i32(VAR_18));
} else {
gen_stack_A0(s);
gen_op_ld_T0_A0(1 + s->VAR_3 + s->mem_index);
if (s->VAR_3 == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
gen_op_addl_A0_im(2 << s->VAR_3);
gen_op_ld_T0_A0(1 + s->VAR_3 + s->mem_index);
gen_op_movl_seg_T0_vm(R_CS);
gen_stack_update(s, VAR_18 + (4 << s->VAR_3));
}
gen_eob(s);
break;
case 0xcb:
VAR_18 = 0;
goto do_lret;
case 0xcf:
gen_svm_check_intercept(s, pc_start, SVM_EXIT_IRET);
if (!s->pe) {
gen_helper_iret_real(tcg_const_i32(s->VAR_3));
s->cc_op = CC_OP_EFLAGS;
} else if (s->vm86) {
if (s->iopl != 3) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_helper_iret_real(tcg_const_i32(s->VAR_3));
s->cc_op = CC_OP_EFLAGS;
}
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_iret_protected(tcg_const_i32(s->VAR_3),
tcg_const_i32(s->pc - s->cs_base));
s->cc_op = CC_OP_EFLAGS;
}
gen_eob(s);
break;
case 0xe8:
{
if (VAR_3)
tval = (int32_t)insn_get(s, OT_LONG);
else
tval = (int16_t)insn_get(s, OT_WORD);
next_eip = s->pc - s->cs_base;
tval += next_eip;
if (s->VAR_3 == 0)
tval &= 0xffff;
gen_movtl_T0_im(next_eip);
gen_push_T0(s);
gen_jmp(s, tval);
}
break;
case 0x9a:
{
unsigned int VAR_27, VAR_27;
if (CODE64(s))
goto illegal_op;
VAR_5 = VAR_3 ? OT_LONG : OT_WORD;
VAR_27 = insn_get(s, VAR_5);
VAR_27 = insn_get(s, OT_WORD);
gen_op_movl_T0_im(VAR_27);
gen_op_movl_T1_imu(VAR_27);
}
goto do_lcall;
case 0xe9:
if (VAR_3)
tval = (int32_t)insn_get(s, OT_LONG);
else
tval = (int16_t)insn_get(s, OT_WORD);
tval += s->pc - s->cs_base;
if (s->VAR_3 == 0)
tval &= 0xffff;
gen_jmp(s, tval);
break;
case 0xea:
{
unsigned int VAR_27, VAR_27;
if (CODE64(s))
goto illegal_op;
VAR_5 = VAR_3 ? OT_LONG : OT_WORD;
VAR_27 = insn_get(s, VAR_5);
VAR_27 = insn_get(s, OT_WORD);
gen_op_movl_T0_im(VAR_27);
gen_op_movl_T1_imu(VAR_27);
}
goto do_ljmp;
case 0xeb:
tval = (int8_t)insn_get(s, OT_BYTE);
tval += s->pc - s->cs_base;
if (s->VAR_3 == 0)
tval &= 0xffff;
gen_jmp(s, tval);
break;
case 0x70 ... 0x7f:
tval = (int8_t)insn_get(s, OT_BYTE);
goto do_jcc;
case 0x180 ... 0x18f:
if (VAR_3) {
tval = (int32_t)insn_get(s, OT_LONG);
} else {
tval = (int16_t)insn_get(s, OT_WORD);
}
do_jcc:
next_eip = s->pc - s->cs_base;
tval += next_eip;
if (s->VAR_3 == 0)
tval &= 0xffff;
gen_jcc(s, VAR_0, tval, next_eip);
break;
case 0x190 ... 0x19f:
VAR_6 = ldub_code(s->pc++);
gen_setcc(s, VAR_0);
gen_ldst_modrm(s, VAR_6, OT_BYTE, OR_TMP0, 1);
break;
case 0x140 ... 0x14f:
{
int VAR_27;
TCGv t0;
VAR_5 = VAR_3 + OT_WORD;
VAR_6 = ldub_code(s->pc++);
VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;
VAR_9 = (VAR_6 >> 6) & 3;
t0 = tcg_temp_local_new();
if (VAR_9 != 3) {
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
gen_op_ld_v(VAR_5 + s->mem_index, t0, cpu_A0);
} else {
VAR_8 = (VAR_6 & 7) | REX_B(s);
gen_op_mov_v_reg(VAR_5, t0, VAR_8);
}
#ifdef TARGET_X86_64
if (VAR_5 == OT_LONG) {
VAR_27 = gen_new_label();
gen_jcc1(s, s->cc_op, VAR_0 ^ 1, VAR_27);
tcg_gen_st32_tl(t0, cpu_env, offsetof(CPUState, regs[VAR_7]) + REG_L_OFFSET);
gen_set_label(VAR_27);
tcg_gen_movi_tl(cpu_tmp0, 0);
tcg_gen_st32_tl(cpu_tmp0, cpu_env, offsetof(CPUState, regs[VAR_7]) + REG_LH_OFFSET);
} else
#endif
{
VAR_27 = gen_new_label();
gen_jcc1(s, s->cc_op, VAR_0 ^ 1, VAR_27);
gen_op_mov_reg_v(VAR_5, VAR_7, t0);
gen_set_label(VAR_27);
}
tcg_temp_free(t0);
}
break;
case 0x9c:
gen_svm_check_intercept(s, pc_start, SVM_EXIT_PUSHF);
if (s->vm86 && s->iopl != 3) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_read_eflags(cpu_T[0]);
gen_push_T0(s);
}
break;
case 0x9d:
gen_svm_check_intercept(s, pc_start, SVM_EXIT_POPF);
if (s->vm86 && s->iopl != 3) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_pop_T0(s);
if (s->cpl == 0) {
if (s->VAR_3) {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK | IOPL_MASK)));
} else {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK | IOPL_MASK) & 0xffff));
}
} else {
if (s->cpl <= s->iopl) {
if (s->VAR_3) {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK)));
} else {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK) & 0xffff));
}
} else {
if (s->VAR_3) {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK)));
} else {
gen_helper_write_eflags(cpu_T[0],
tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK) & 0xffff));
}
}
}
gen_pop_update(s);
s->cc_op = CC_OP_EFLAGS;
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x9e:
if (CODE64(s) && !(s->cpuid_ext3_features & CPUID_EXT3_LAHF_LM))
goto illegal_op;
gen_op_mov_TN_reg(OT_BYTE, 0, R_AH);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_cc_src);
tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, CC_O);
tcg_gen_andi_tl(cpu_T[0], cpu_T[0], CC_S | CC_Z | CC_A | CC_P | CC_C);
tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, cpu_T[0]);
s->cc_op = CC_OP_EFLAGS;
break;
case 0x9f:
if (CODE64(s) && !(s->cpuid_ext3_features & CPUID_EXT3_LAHF_LM))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_T[0]);
tcg_gen_ori_tl(cpu_T[0], cpu_T[0], 0x02);
gen_op_mov_reg_T0(OT_BYTE, R_AH);
break;
case 0xf5:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_cc_src);
tcg_gen_xori_tl(cpu_cc_src, cpu_cc_src, CC_C);
s->cc_op = CC_OP_EFLAGS;
break;
case 0xf8:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_cc_src);
tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, ~CC_C);
s->cc_op = CC_OP_EFLAGS;
break;
case 0xf9:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_cc_src);
tcg_gen_ori_tl(cpu_cc_src, cpu_cc_src, CC_C);
s->cc_op = CC_OP_EFLAGS;
break;
case 0xfc:
tcg_gen_movi_i32(cpu_tmp2_i32, 1);
tcg_gen_st_i32(cpu_tmp2_i32, cpu_env, offsetof(CPUState, df));
break;
case 0xfd:
tcg_gen_movi_i32(cpu_tmp2_i32, -1);
tcg_gen_st_i32(cpu_tmp2_i32, cpu_env, offsetof(CPUState, df));
break;
case 0x1ba:
VAR_5 = VAR_3 + OT_WORD;
VAR_6 = ldub_code(s->pc++);
VAR_17 = (VAR_6 >> 3) & 7;
VAR_9 = (VAR_6 >> 6) & 3;
VAR_8 = (VAR_6 & 7) | REX_B(s);
if (VAR_9 != 3) {
s->rip_offset = 1;
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
gen_op_ld_T0_A0(VAR_5 + s->mem_index);
} else {
gen_op_mov_TN_reg(VAR_5, 0, VAR_8);
}
VAR_18 = ldub_code(s->pc++);
gen_op_movl_T1_im(VAR_18);
if (VAR_17 < 4)
goto illegal_op;
VAR_17 -= 4;
goto bt_op;
case 0x1a3:
VAR_17 = 0;
goto do_btx;
case 0x1ab:
VAR_17 = 1;
goto do_btx;
case 0x1b3:
VAR_17 = 2;
goto do_btx;
case 0x1bb:
VAR_17 = 3;
do_btx:
VAR_5 = VAR_3 + OT_WORD;
VAR_6 = ldub_code(s->pc++);
VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;
VAR_9 = (VAR_6 >> 6) & 3;
VAR_8 = (VAR_6 & 7) | REX_B(s);
gen_op_mov_TN_reg(OT_LONG, 1, VAR_7);
if (VAR_9 != 3) {
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
gen_exts(VAR_5, cpu_T[1]);
tcg_gen_sari_tl(cpu_tmp0, cpu_T[1], 3 + VAR_5);
tcg_gen_shli_tl(cpu_tmp0, cpu_tmp0, VAR_5);
tcg_gen_add_tl(cpu_A0, cpu_A0, cpu_tmp0);
gen_op_ld_T0_A0(VAR_5 + s->mem_index);
} else {
gen_op_mov_TN_reg(VAR_5, 0, VAR_8);
}
bt_op:
tcg_gen_andi_tl(cpu_T[1], cpu_T[1], (1 << (3 + VAR_5)) - 1);
switch(VAR_17) {
case 0:
tcg_gen_shr_tl(cpu_cc_src, cpu_T[0], cpu_T[1]);
tcg_gen_movi_tl(cpu_cc_dst, 0);
break;
case 1:
tcg_gen_shr_tl(cpu_tmp4, cpu_T[0], cpu_T[1]);
tcg_gen_movi_tl(cpu_tmp0, 1);
tcg_gen_shl_tl(cpu_tmp0, cpu_tmp0, cpu_T[1]);
tcg_gen_or_tl(cpu_T[0], cpu_T[0], cpu_tmp0);
break;
case 2:
tcg_gen_shr_tl(cpu_tmp4, cpu_T[0], cpu_T[1]);
tcg_gen_movi_tl(cpu_tmp0, 1);
tcg_gen_shl_tl(cpu_tmp0, cpu_tmp0, cpu_T[1]);
tcg_gen_not_tl(cpu_tmp0, cpu_tmp0);
tcg_gen_and_tl(cpu_T[0], cpu_T[0], cpu_tmp0);
break;
default:
case 3:
tcg_gen_shr_tl(cpu_tmp4, cpu_T[0], cpu_T[1]);
tcg_gen_movi_tl(cpu_tmp0, 1);
tcg_gen_shl_tl(cpu_tmp0, cpu_tmp0, cpu_T[1]);
tcg_gen_xor_tl(cpu_T[0], cpu_T[0], cpu_tmp0);
break;
}
s->cc_op = CC_OP_SARB + VAR_5;
if (VAR_17 != 0) {
if (VAR_9 != 3)
gen_op_st_T0_A0(VAR_5 + s->mem_index);
else
gen_op_mov_reg_T0(VAR_5, VAR_8);
tcg_gen_mov_tl(cpu_cc_src, cpu_tmp4);
tcg_gen_movi_tl(cpu_cc_dst, 0);
}
break;
case 0x1bc:
case 0x1bd:
{
int VAR_29;
TCGv t0;
VAR_5 = VAR_3 + OT_WORD;
VAR_6 = ldub_code(s->pc++);
VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;
gen_ldst_modrm(s, VAR_6, VAR_5, OR_TMP0, 0);
gen_extu(VAR_5, cpu_T[0]);
VAR_29 = gen_new_label();
tcg_gen_movi_tl(cpu_cc_dst, 0);
t0 = tcg_temp_local_new();
tcg_gen_mov_tl(t0, cpu_T[0]);
tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, VAR_29);
if (VAR_0 & 1) {
gen_helper_bsr(cpu_T[0], t0);
} else {
gen_helper_bsf(cpu_T[0], t0);
}
gen_op_mov_reg_T0(VAR_5, VAR_7);
tcg_gen_movi_tl(cpu_cc_dst, 1);
gen_set_label(VAR_29);
tcg_gen_discard_tl(cpu_cc_src);
s->cc_op = CC_OP_LOGICB + VAR_5;
tcg_temp_free(t0);
}
break;
case 0x27:
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_daa();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x2f:
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_das();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x37:
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_aaa();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x3f:
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_helper_aas();
s->cc_op = CC_OP_EFLAGS;
break;
case 0xd4:
if (CODE64(s))
goto illegal_op;
VAR_18 = ldub_code(s->pc++);
if (VAR_18 == 0) {
gen_exception(s, EXCP00_DIVZ, pc_start - s->cs_base);
} else {
gen_helper_aam(tcg_const_i32(VAR_18));
s->cc_op = CC_OP_LOGICB;
}
break;
case 0xd5:
if (CODE64(s))
goto illegal_op;
VAR_18 = ldub_code(s->pc++);
gen_helper_aad(tcg_const_i32(VAR_18));
s->cc_op = CC_OP_LOGICB;
break;
case 0x90:
if (VAR_1 & PREFIX_LOCK)
goto illegal_op;
if (VAR_1 & PREFIX_REPZ) {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_PAUSE);
}
break;
case 0x9b:
if ((s->flags & (HF_MP_MASK | HF_TS_MASK)) ==
(HF_MP_MASK | HF_TS_MASK)) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fwait();
}
break;
case 0xcc:
gen_interrupt(s, EXCP03_INT3, pc_start - s->cs_base, s->pc - s->cs_base);
break;
case 0xcd:
VAR_18 = ldub_code(s->pc++);
if (s->vm86 && s->iopl != 3) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_interrupt(s, VAR_18, pc_start - s->cs_base, s->pc - s->cs_base);
}
break;
case 0xce:
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_into(tcg_const_i32(s->pc - pc_start));
break;
#ifdef WANT_ICEBP
case 0xf1:
gen_svm_check_intercept(s, pc_start, SVM_EXIT_ICEBP);
#if 1
gen_debug(s, pc_start - s->cs_base);
#else
tb_flush(cpu_single_env);
cpu_set_log(CPU_LOG_INT | CPU_LOG_TB_IN_ASM);
#endif
break;
#endif
case 0xfa:
if (!s->vm86) {
if (s->cpl <= s->iopl) {
gen_helper_cli();
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
} else {
if (s->iopl == 3) {
gen_helper_cli();
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
}
break;
case 0xfb:
if (!s->vm86) {
if (s->cpl <= s->iopl) {
gen_sti:
gen_helper_sti();
if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK))
gen_helper_set_inhibit_irq();
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
} else {
if (s->iopl == 3) {
goto gen_sti;
} else {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
}
}
break;
case 0x62:
if (CODE64(s))
goto illegal_op;
VAR_5 = VAR_3 ? OT_LONG : OT_WORD;
VAR_6 = ldub_code(s->pc++);
VAR_7 = (VAR_6 >> 3) & 7;
VAR_9 = (VAR_6 >> 6) & 3;
if (VAR_9 == 3)
goto illegal_op;
gen_op_mov_TN_reg(VAR_5, 0, VAR_7);
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
gen_jmp_im(pc_start - s->cs_base);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
if (VAR_5 == OT_WORD)
gen_helper_boundw(cpu_A0, cpu_tmp2_i32);
else
gen_helper_boundl(cpu_A0, cpu_tmp2_i32);
break;
case 0x1c8 ... 0x1cf:
VAR_7 = (VAR_0 & 7) | REX_B(s);
#ifdef TARGET_X86_64
if (VAR_3 == 2) {
gen_op_mov_TN_reg(OT_QUAD, 0, VAR_7);
tcg_gen_bswap_i64(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_QUAD, VAR_7);
} else
{
TCGv_i32 tmp0;
gen_op_mov_TN_reg(OT_LONG, 0, VAR_7);
tmp0 = tcg_temp_new_i32();
tcg_gen_trunc_i64_i32(tmp0, cpu_T[0]);
tcg_gen_bswap_i32(tmp0, tmp0);
tcg_gen_extu_i32_i64(cpu_T[0], tmp0);
gen_op_mov_reg_T0(OT_LONG, VAR_7);
}
#else
{
gen_op_mov_TN_reg(OT_LONG, 0, VAR_7);
tcg_gen_bswap_i32(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_LONG, VAR_7);
}
#endif
break;
case 0xd6:
if (CODE64(s))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags_c(cpu_T[0]);
tcg_gen_neg_tl(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(OT_BYTE, R_EAX);
break;
case 0xe0:
case 0xe1:
case 0xe2:
case 0xe3:
{
int VAR_27, VAR_27, VAR_28;
tval = (int8_t)insn_get(s, OT_BYTE);
next_eip = s->pc - s->cs_base;
tval += next_eip;
if (s->VAR_3 == 0)
tval &= 0xffff;
VAR_27 = gen_new_label();
VAR_27 = gen_new_label();
VAR_28 = gen_new_label();
VAR_0 &= 3;
switch(VAR_0) {
case 0:
case 1:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_add_reg_im(s->VAR_2, R_ECX, -1);
gen_op_jz_ecx(s->VAR_2, VAR_28);
gen_compute_eflags(cpu_tmp0);
tcg_gen_andi_tl(cpu_tmp0, cpu_tmp0, CC_Z);
if (VAR_0 == 0) {
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_tmp0, 0, VAR_27);
} else {
tcg_gen_brcondi_tl(TCG_COND_NE, cpu_tmp0, 0, VAR_27);
}
break;
case 2:
gen_op_add_reg_im(s->VAR_2, R_ECX, -1);
gen_op_jnz_ecx(s->VAR_2, VAR_27);
break;
default:
case 3:
gen_op_jz_ecx(s->VAR_2, VAR_27);
break;
}
gen_set_label(VAR_28);
gen_jmp_im(next_eip);
tcg_gen_br(VAR_27);
gen_set_label(VAR_27);
gen_jmp_im(tval);
gen_set_label(VAR_27);
gen_eob(s);
}
break;
case 0x130:
case 0x132:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
if (VAR_0 & 2) {
gen_helper_rdmsr();
} else {
gen_helper_wrmsr();
}
}
break;
case 0x131:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
if (use_icount)
gen_io_start();
gen_helper_rdtsc();
if (use_icount) {
gen_io_end();
gen_jmp(s, s->pc - s->cs_base);
}
break;
case 0x133:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_rdpmc();
break;
case 0x134:
if (CODE64(s) && cpu_single_env->cpuid_vendor1 != CPUID_VENDOR_INTEL_1)
goto illegal_op;
if (!s->pe) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(pc_start - s->cs_base);
gen_helper_sysenter();
gen_eob(s);
}
break;
case 0x135:
if (CODE64(s) && cpu_single_env->cpuid_vendor1 != CPUID_VENDOR_INTEL_1)
goto illegal_op;
if (!s->pe) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(pc_start - s->cs_base);
gen_helper_sysexit(tcg_const_i32(VAR_3));
gen_eob(s);
}
break;
#ifdef TARGET_X86_64
case 0x105:
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(pc_start - s->cs_base);
gen_helper_syscall(tcg_const_i32(s->pc - pc_start));
gen_eob(s);
break;
case 0x107:
if (!s->pe) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(pc_start - s->cs_base);
gen_helper_sysret(tcg_const_i32(s->VAR_3));
if (s->lma)
s->cc_op = CC_OP_EFLAGS;
gen_eob(s);
}
break;
#endif
case 0x1a2:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_cpuid();
break;
case 0xf4:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_hlt(tcg_const_i32(s->pc - pc_start));
s->is_jmp = 3;
}
break;
case 0x100:
VAR_6 = ldub_code(s->pc++);
VAR_9 = (VAR_6 >> 6) & 3;
VAR_17 = (VAR_6 >> 3) & 7;
switch(VAR_17) {
case 0:
if (!s->pe || s->vm86)
goto illegal_op;
gen_svm_check_intercept(s, pc_start, SVM_EXIT_LDTR_READ);
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,ldt.VAR_27));
VAR_5 = OT_WORD;
if (VAR_9 == 3)
VAR_5 += s->VAR_3;
gen_ldst_modrm(s, VAR_6, VAR_5, OR_TMP0, 1);
break;
case 2:
if (!s->pe || s->vm86)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_LDTR_WRITE);
gen_ldst_modrm(s, VAR_6, OT_WORD, OR_TMP0, 0);
gen_jmp_im(pc_start - s->cs_base);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_lldt(cpu_tmp2_i32);
}
break;
case 1:
if (!s->pe || s->vm86)
goto illegal_op;
gen_svm_check_intercept(s, pc_start, SVM_EXIT_TR_READ);
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,tr.VAR_27));
VAR_5 = OT_WORD;
if (VAR_9 == 3)
VAR_5 += s->VAR_3;
gen_ldst_modrm(s, VAR_6, VAR_5, OR_TMP0, 1);
break;
case 3:
if (!s->pe || s->vm86)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_TR_WRITE);
gen_ldst_modrm(s, VAR_6, OT_WORD, OR_TMP0, 0);
gen_jmp_im(pc_start - s->cs_base);
tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
gen_helper_ltr(cpu_tmp2_i32);
}
break;
case 4:
case 5:
if (!s->pe || s->vm86)
goto illegal_op;
gen_ldst_modrm(s, VAR_6, OT_WORD, OR_TMP0, 0);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
if (VAR_17 == 4)
gen_helper_verr(cpu_T[0]);
else
gen_helper_verw(cpu_T[0]);
s->cc_op = CC_OP_EFLAGS;
break;
default:
goto illegal_op;
}
break;
case 0x101:
VAR_6 = ldub_code(s->pc++);
VAR_9 = (VAR_6 >> 6) & 3;
VAR_17 = (VAR_6 >> 3) & 7;
VAR_8 = VAR_6 & 7;
switch(VAR_17) {
case 0:
if (VAR_9 == 3)
goto illegal_op;
gen_svm_check_intercept(s, pc_start, SVM_EXIT_GDTR_READ);
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, gdt.limit));
gen_op_st_T0_A0(OT_WORD + s->mem_index);
gen_add_A0_im(s, 2);
tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, gdt.base));
if (!s->VAR_3)
gen_op_andl_T0_im(0xffffff);
gen_op_st_T0_A0(CODE64(s) + OT_LONG + s->mem_index);
break;
case 1:
if (VAR_9 == 3) {
switch (VAR_8) {
case 0:
if (!(s->cpuid_ext_features & CPUID_EXT_MONITOR) ||
s->cpl != 0)
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
#ifdef TARGET_X86_64
if (s->VAR_2 == 2) {
gen_op_movq_A0_reg(R_EAX);
} else
#endif
{
gen_op_movl_A0_reg(R_EAX);
if (s->VAR_2 == 0)
gen_op_andl_A0_ffff();
}
gen_add_A0_ds_seg(s);
gen_helper_monitor(cpu_A0);
break;
case 1:
if (!(s->cpuid_ext_features & CPUID_EXT_MONITOR) ||
s->cpl != 0)
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(pc_start - s->cs_base);
gen_helper_mwait(tcg_const_i32(s->pc - pc_start));
gen_eob(s);
break;
default:
goto illegal_op;
}
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_IDTR_READ);
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, idt.limit));
gen_op_st_T0_A0(OT_WORD + s->mem_index);
gen_add_A0_im(s, 2);
tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, idt.base));
if (!s->VAR_3)
gen_op_andl_T0_im(0xffffff);
gen_op_st_T0_A0(CODE64(s) + OT_LONG + s->mem_index);
}
break;
case 2:
case 3:
if (VAR_9 == 3) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
switch(VAR_8) {
case 0:
if (!(s->flags & HF_SVME_MASK) || !s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_vmrun(tcg_const_i32(s->VAR_2),
tcg_const_i32(s->pc - pc_start));
tcg_gen_exit_tb(0);
s->is_jmp = 3;
}
break;
case 1:
if (!(s->flags & HF_SVME_MASK))
goto illegal_op;
gen_helper_vmmcall();
break;
case 2:
if (!(s->flags & HF_SVME_MASK) || !s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_vmload(tcg_const_i32(s->VAR_2));
}
break;
case 3:
if (!(s->flags & HF_SVME_MASK) || !s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_vmsave(tcg_const_i32(s->VAR_2));
}
break;
case 4:
if ((!(s->flags & HF_SVME_MASK) &&
!(s->cpuid_ext3_features & CPUID_EXT3_SKINIT)) ||
!s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_stgi();
}
break;
case 5:
if (!(s->flags & HF_SVME_MASK) || !s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_clgi();
}
break;
case 6:
if ((!(s->flags & HF_SVME_MASK) &&
!(s->cpuid_ext3_features & CPUID_EXT3_SKINIT)) ||
!s->pe)
goto illegal_op;
gen_helper_skinit();
break;
case 7:
if (!(s->flags & HF_SVME_MASK) || !s->pe)
goto illegal_op;
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
break;
} else {
gen_helper_invlpga(tcg_const_i32(s->VAR_2));
}
break;
default:
goto illegal_op;
}
} else if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start,
VAR_17==2 ? SVM_EXIT_GDTR_WRITE : SVM_EXIT_IDTR_WRITE);
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
gen_op_ld_T1_A0(OT_WORD + s->mem_index);
gen_add_A0_im(s, 2);
gen_op_ld_T0_A0(CODE64(s) + OT_LONG + s->mem_index);
if (!s->VAR_3)
gen_op_andl_T0_im(0xffffff);
if (VAR_17 == 2) {
tcg_gen_st_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,gdt.base));
tcg_gen_st32_tl(cpu_T[1], cpu_env, offsetof(CPUX86State,gdt.limit));
} else {
tcg_gen_st_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,idt.base));
tcg_gen_st32_tl(cpu_T[1], cpu_env, offsetof(CPUX86State,idt.limit));
}
}
break;
case 4:
gen_svm_check_intercept(s, pc_start, SVM_EXIT_READ_CR0);
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,cr[0]));
gen_ldst_modrm(s, VAR_6, OT_WORD, OR_TMP0, 1);
break;
case 6:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_WRITE_CR0);
gen_ldst_modrm(s, VAR_6, OT_WORD, OR_TMP0, 0);
gen_helper_lmsw(cpu_T[0]);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 7:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
if (VAR_9 == 3) {
#ifdef TARGET_X86_64
if (CODE64(s) && VAR_8 == 0) {
tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,segs[R_GS].base));
tcg_gen_ld_tl(cpu_T[1], cpu_env, offsetof(CPUX86State,kernelgsbase));
tcg_gen_st_tl(cpu_T[1], cpu_env, offsetof(CPUX86State,segs[R_GS].base));
tcg_gen_st_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,kernelgsbase));
} else
#endif
{
goto illegal_op;
}
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
gen_helper_invlpg(cpu_A0);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
}
break;
default:
goto illegal_op;
}
break;
case 0x108:
case 0x109:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start, (VAR_0 & 2) ? SVM_EXIT_INVD : SVM_EXIT_WBINVD);
}
break;
case 0x63:
#ifdef TARGET_X86_64
if (CODE64(s)) {
int VAR_21;
VAR_21 = VAR_3 + OT_WORD;
VAR_6 = ldub_code(s->pc++);
VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;
VAR_9 = (VAR_6 >> 6) & 3;
VAR_8 = (VAR_6 & 7) | REX_B(s);
if (VAR_9 == 3) {
gen_op_mov_TN_reg(OT_LONG, 0, VAR_8);
if (VAR_21 == OT_QUAD)
tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
gen_op_mov_reg_T0(VAR_21, VAR_7);
} else {
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
if (VAR_21 == OT_QUAD) {
gen_op_lds_T0_A0(OT_LONG + s->mem_index);
} else {
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
}
gen_op_mov_reg_T0(VAR_21, VAR_7);
}
} else
#endif
{
int VAR_29;
TCGv t0, t1, t2;
if (!s->pe || s->vm86)
goto illegal_op;
t0 = tcg_temp_local_new();
t1 = tcg_temp_local_new();
t2 = tcg_temp_local_new();
VAR_5 = OT_WORD;
VAR_6 = ldub_code(s->pc++);
VAR_7 = (VAR_6 >> 3) & 7;
VAR_9 = (VAR_6 >> 6) & 3;
VAR_8 = VAR_6 & 7;
if (VAR_9 != 3) {
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
gen_op_ld_v(VAR_5 + s->mem_index, t0, cpu_A0);
} else {
gen_op_mov_v_reg(VAR_5, t0, VAR_8);
}
gen_op_mov_v_reg(VAR_5, t1, VAR_7);
tcg_gen_andi_tl(cpu_tmp0, t0, 3);
tcg_gen_andi_tl(t1, t1, 3);
tcg_gen_movi_tl(t2, 0);
VAR_29 = gen_new_label();
tcg_gen_brcond_tl(TCG_COND_GE, cpu_tmp0, t1, VAR_29);
tcg_gen_andi_tl(t0, t0, ~3);
tcg_gen_or_tl(t0, t0, t1);
tcg_gen_movi_tl(t2, CC_Z);
gen_set_label(VAR_29);
if (VAR_9 != 3) {
gen_op_st_v(VAR_5 + s->mem_index, t0, cpu_A0);
} else {
gen_op_mov_reg_v(VAR_5, VAR_8, t0);
}
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_compute_eflags(cpu_cc_src);
tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, ~CC_Z);
tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, t2);
s->cc_op = CC_OP_EFLAGS;
tcg_temp_free(t0);
tcg_temp_free(t1);
tcg_temp_free(t2);
}
break;
case 0x102:
case 0x103:
{
int VAR_29;
TCGv t0;
if (!s->pe || s->vm86)
goto illegal_op;
VAR_5 = VAR_3 ? OT_LONG : OT_WORD;
VAR_6 = ldub_code(s->pc++);
VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;
gen_ldst_modrm(s, VAR_6, OT_WORD, OR_TMP0, 0);
t0 = tcg_temp_local_new();
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
if (VAR_0 == 0x102)
gen_helper_lar(t0, cpu_T[0]);
else
gen_helper_lsl(t0, cpu_T[0]);
tcg_gen_andi_tl(cpu_tmp0, cpu_cc_src, CC_Z);
VAR_29 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_tmp0, 0, VAR_29);
gen_op_mov_reg_v(VAR_5, VAR_7, t0);
gen_set_label(VAR_29);
s->cc_op = CC_OP_EFLAGS;
tcg_temp_free(t0);
}
break;
case 0x118:
VAR_6 = ldub_code(s->pc++);
VAR_9 = (VAR_6 >> 6) & 3;
VAR_17 = (VAR_6 >> 3) & 7;
switch(VAR_17) {
case 0:
case 1:
case 2:
case 3:
if (VAR_9 == 3)
goto illegal_op;
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
break;
default:
gen_nop_modrm(s, VAR_6);
break;
}
break;
case 0x119 ... 0x11f:
VAR_6 = ldub_code(s->pc++);
gen_nop_modrm(s, VAR_6);
break;
case 0x120:
case 0x122:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
VAR_6 = ldub_code(s->pc++);
if ((VAR_6 & 0xc0) != 0xc0)
goto illegal_op;
VAR_8 = (VAR_6 & 7) | REX_B(s);
VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;
if (CODE64(s))
VAR_5 = OT_QUAD;
else
VAR_5 = OT_LONG;
switch(VAR_7) {
case 0:
case 2:
case 3:
case 4:
case 8:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
if (VAR_0 & 2) {
gen_op_mov_TN_reg(VAR_5, 0, VAR_8);
gen_helper_write_crN(tcg_const_i32(VAR_7), cpu_T[0]);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
} else {
gen_helper_read_crN(cpu_T[0], tcg_const_i32(VAR_7));
gen_op_mov_reg_T0(VAR_5, VAR_8);
}
break;
default:
goto illegal_op;
}
}
break;
case 0x121:
case 0x123:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
VAR_6 = ldub_code(s->pc++);
if ((VAR_6 & 0xc0) != 0xc0)
goto illegal_op;
VAR_8 = (VAR_6 & 7) | REX_B(s);
VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;
if (CODE64(s))
VAR_5 = OT_QUAD;
else
VAR_5 = OT_LONG;
if (VAR_7 == 4 || VAR_7 == 5 || VAR_7 >= 8)
goto illegal_op;
if (VAR_0 & 2) {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_WRITE_DR0 + VAR_7);
gen_op_mov_TN_reg(VAR_5, 0, VAR_8);
gen_helper_movl_drN_T0(tcg_const_i32(VAR_7), cpu_T[0]);
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_READ_DR0 + VAR_7);
tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,dr[VAR_7]));
gen_op_mov_reg_T0(VAR_5, VAR_8);
}
}
break;
case 0x106:
if (s->cpl != 0) {
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_svm_check_intercept(s, pc_start, SVM_EXIT_WRITE_CR0);
gen_helper_clts();
gen_jmp_im(s->pc - s->cs_base);
gen_eob(s);
}
break;
case 0x1c3:
if (!(s->cpuid_features & CPUID_SSE2))
goto illegal_op;
VAR_5 = s->VAR_3 == 2 ? OT_QUAD : OT_LONG;
VAR_6 = ldub_code(s->pc++);
VAR_9 = (VAR_6 >> 6) & 3;
if (VAR_9 == 3)
goto illegal_op;
VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;
gen_ldst_modrm(s, VAR_6, VAR_5, VAR_7, 1);
break;
case 0x1ae:
VAR_6 = ldub_code(s->pc++);
VAR_9 = (VAR_6 >> 6) & 3;
VAR_17 = (VAR_6 >> 3) & 7;
switch(VAR_17) {
case 0:
if (VAR_9 == 3 || !(s->cpuid_features & CPUID_FXSR) ||
(s->flags & HF_EM_MASK))
goto illegal_op;
if (s->flags & HF_TS_MASK) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
break;
}
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fxsave(cpu_A0, tcg_const_i32((s->VAR_3 == 2)));
break;
case 1:
if (VAR_9 == 3 || !(s->cpuid_features & CPUID_FXSR) ||
(s->flags & HF_EM_MASK))
goto illegal_op;
if (s->flags & HF_TS_MASK) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
break;
}
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
gen_helper_fxrstor(cpu_A0, tcg_const_i32((s->VAR_3 == 2)));
break;
case 2:
case 3:
if (s->flags & HF_TS_MASK) {
gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);
break;
}
if ((s->flags & HF_EM_MASK) || !(s->flags & HF_OSFXSR_MASK) ||
VAR_9 == 3)
goto illegal_op;
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
if (VAR_17 == 2) {
gen_op_ld_T0_A0(OT_LONG + s->mem_index);
tcg_gen_st32_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, mxcsr));
} else {
tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, mxcsr));
gen_op_st_T0_A0(OT_LONG + s->mem_index);
}
break;
case 5:
case 6:
if ((VAR_6 & 0xc7) != 0xc0 || !(s->cpuid_features & CPUID_SSE))
goto illegal_op;
break;
case 7:
if ((VAR_6 & 0xc7) == 0xc0) {
if (!(s->cpuid_features & CPUID_SSE))
goto illegal_op;
} else {
if (!(s->cpuid_features & CPUID_CLFLUSH))
goto illegal_op;
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
}
break;
default:
goto illegal_op;
}
break;
case 0x10d:
VAR_6 = ldub_code(s->pc++);
VAR_9 = (VAR_6 >> 6) & 3;
if (VAR_9 == 3)
goto illegal_op;
gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);
break;
case 0x1aa:
gen_svm_check_intercept(s, pc_start, SVM_EXIT_RSM);
if (!(s->flags & HF_SMM_MASK))
goto illegal_op;
if (s->cc_op != CC_OP_DYNAMIC) {
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
gen_jmp_im(s->pc - s->cs_base);
gen_helper_rsm();
gen_eob(s);
break;
case 0x1b8:
if ((VAR_1 & (PREFIX_REPZ | PREFIX_LOCK | PREFIX_REPNZ)) !=
PREFIX_REPZ)
goto illegal_op;
if (!(s->cpuid_ext_features & CPUID_EXT_POPCNT))
goto illegal_op;
VAR_6 = ldub_code(s->pc++);
VAR_7 = ((VAR_6 >> 3) & 7);
if (s->prefix & PREFIX_DATA)
VAR_5 = OT_WORD;
else if (s->VAR_3 != 2)
VAR_5 = OT_LONG;
else
VAR_5 = OT_QUAD;
gen_ldst_modrm(s, VAR_6, VAR_5, OR_TMP0, 0);
gen_helper_popcnt(cpu_T[0], cpu_T[0], tcg_const_i32(VAR_5));
gen_op_mov_reg_T0(VAR_5, VAR_7);
s->cc_op = CC_OP_EFLAGS;
break;
case 0x10e ... 0x10f:
s->prefix &= ~(PREFIX_REPZ | PREFIX_REPNZ | PREFIX_DATA);
case 0x110 ... 0x117:
case 0x128 ... 0x12f:
case 0x138 ... 0x13a:
case 0x150 ... 0x177:
case 0x17c ... 0x17f:
case 0x1c2:
case 0x1c4 ... 0x1c6:
case 0x1d0 ... 0x1fe:
gen_sse(s, VAR_0, pc_start, VAR_16);
break;
default:
goto illegal_op;
}
if (s->prefix & PREFIX_LOCK)
gen_helper_unlock();
return s->pc;
illegal_op:
if (s->prefix & PREFIX_LOCK)
gen_helper_unlock();
gen_exception(s, EXCP06_ILLOP, pc_start - s->cs_base);
return s->pc;
} | [
"static target_ulong FUNC_0(DisasContext *s, target_ulong pc_start)\n{",
"int VAR_0, VAR_1, VAR_2, VAR_3;",
"int VAR_4, VAR_5;",
"int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_17, VAR_12, VAR_13, VAR_18;",
"target_ulong next_eip, tval;",
"int VAR_15, VAR_16;",
"if (unlikely(loglevel & CPU_LOG_TB_OP))\ntcg_gen_debug_insn_start(pc_start);",
"s->pc = pc_start;",
"VAR_1 = 0;",
"VAR_2 = s->code32;",
"VAR_3 = s->code32;",
"s->override = -1;",
"VAR_15 = -1;",
"VAR_16 = 0;",
"#ifdef TARGET_X86_64\ns->rex_x = 0;",
"s->rex_b = 0;",
"x86_64_hregs = 0;",
"#endif\ns->rip_offset = 0;",
"next_byte:\nVAR_0 = ldub_code(s->pc);",
"s->pc++;",
"#ifdef TARGET_X86_64\nif (CODE64(s)) {",
"switch (VAR_0) {",
"case 0xf3:\nVAR_1 |= PREFIX_REPZ;",
"goto next_byte;",
"case 0xf2:\nVAR_1 |= PREFIX_REPNZ;",
"goto next_byte;",
"case 0xf0:\nVAR_1 |= PREFIX_LOCK;",
"goto next_byte;",
"case 0x2e:\ns->override = R_CS;",
"goto next_byte;",
"case 0x36:\ns->override = R_SS;",
"goto next_byte;",
"case 0x3e:\ns->override = R_DS;",
"goto next_byte;",
"case 0x26:\ns->override = R_ES;",
"goto next_byte;",
"case 0x64:\ns->override = R_FS;",
"goto next_byte;",
"case 0x65:\ns->override = R_GS;",
"goto next_byte;",
"case 0x66:\nVAR_1 |= PREFIX_DATA;",
"goto next_byte;",
"case 0x67:\nVAR_1 |= PREFIX_ADR;",
"goto next_byte;",
"case 0x40 ... 0x4f:\nVAR_15 = (VAR_0 >> 3) & 1;",
"VAR_16 = (VAR_0 & 0x4) << 1;",
"s->rex_x = (VAR_0 & 0x2) << 2;",
"REX_B(s) = (VAR_0 & 0x1) << 3;",
"x86_64_hregs = 1;",
"goto next_byte;",
"}",
"if (VAR_15 == 1) {",
"VAR_3 = 2;",
"} else {",
"if (VAR_1 & PREFIX_DATA)\nVAR_3 ^= 1;",
"}",
"if (!(VAR_1 & PREFIX_ADR))\nVAR_2 = 2;",
"} else",
"#endif\n{",
"switch (VAR_0) {",
"case 0xf3:\nVAR_1 |= PREFIX_REPZ;",
"goto next_byte;",
"case 0xf2:\nVAR_1 |= PREFIX_REPNZ;",
"goto next_byte;",
"case 0xf0:\nVAR_1 |= PREFIX_LOCK;",
"goto next_byte;",
"case 0x2e:\ns->override = R_CS;",
"goto next_byte;",
"case 0x36:\ns->override = R_SS;",
"goto next_byte;",
"case 0x3e:\ns->override = R_DS;",
"goto next_byte;",
"case 0x26:\ns->override = R_ES;",
"goto next_byte;",
"case 0x64:\ns->override = R_FS;",
"goto next_byte;",
"case 0x65:\ns->override = R_GS;",
"goto next_byte;",
"case 0x66:\nVAR_1 |= PREFIX_DATA;",
"goto next_byte;",
"case 0x67:\nVAR_1 |= PREFIX_ADR;",
"goto next_byte;",
"}",
"if (VAR_1 & PREFIX_DATA)\nVAR_3 ^= 1;",
"if (VAR_1 & PREFIX_ADR)\nVAR_2 ^= 1;",
"}",
"s->prefix = VAR_1;",
"s->VAR_2 = VAR_2;",
"s->VAR_3 = VAR_3;",
"if (VAR_1 & PREFIX_LOCK)\ngen_helper_lock();",
"reswitch:\nswitch(VAR_0) {",
"case 0x0f:\nVAR_0 = ldub_code(s->pc++) | 0x100;",
"goto reswitch;",
"case 0x00 ... 0x05:\ncase 0x08 ... 0x0d:\ncase 0x10 ... 0x15:\ncase 0x18 ... 0x1d:\ncase 0x20 ... 0x25:\ncase 0x28 ... 0x2d:\ncase 0x30 ... 0x35:\ncase 0x38 ... 0x3d:\n{",
"int VAR_17, VAR_17, VAR_18;",
"VAR_17 = (VAR_0 >> 3) & 7;",
"VAR_17 = (VAR_0 >> 1) & 3;",
"if ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 + OT_WORD;",
"switch(VAR_17) {",
"case 0:\nVAR_6 = ldub_code(s->pc++);",
"VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;",
"VAR_9 = (VAR_6 >> 6) & 3;",
"VAR_8 = (VAR_6 & 7) | REX_B(s);",
"if (VAR_9 != 3) {",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"VAR_12 = OR_TMP0;",
"} else if (VAR_17 == OP_XORL && VAR_8 == VAR_7) {",
"xor_zero:\ngen_op_movl_T0_0();",
"s->cc_op = CC_OP_LOGICB + VAR_5;",
"gen_op_mov_reg_T0(VAR_5, VAR_7);",
"gen_op_update1_cc();",
"break;",
"} else {",
"VAR_12 = VAR_8;",
"}",
"gen_op_mov_TN_reg(VAR_5, 1, VAR_7);",
"gen_op(s, VAR_17, VAR_5, VAR_12);",
"break;",
"case 1:\nVAR_6 = ldub_code(s->pc++);",
"VAR_9 = (VAR_6 >> 6) & 3;",
"VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;",
"VAR_8 = (VAR_6 & 7) | REX_B(s);",
"if (VAR_9 != 3) {",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"gen_op_ld_T1_A0(VAR_5 + s->mem_index);",
"} else if (VAR_17 == OP_XORL && VAR_8 == VAR_7) {",
"goto xor_zero;",
"} else {",
"gen_op_mov_TN_reg(VAR_5, 1, VAR_8);",
"}",
"gen_op(s, VAR_17, VAR_5, VAR_7);",
"break;",
"case 2:\nVAR_18 = insn_get(s, VAR_5);",
"gen_op_movl_T1_im(VAR_18);",
"gen_op(s, VAR_17, VAR_5, OR_EAX);",
"break;",
"}",
"}",
"break;",
"case 0x82:\nif (CODE64(s))\ngoto illegal_op;",
"case 0x80:\ncase 0x81:\ncase 0x83:\n{",
"int VAR_18;",
"if ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 + OT_WORD;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_9 = (VAR_6 >> 6) & 3;",
"VAR_8 = (VAR_6 & 7) | REX_B(s);",
"VAR_17 = (VAR_6 >> 3) & 7;",
"if (VAR_9 != 3) {",
"if (VAR_0 == 0x83)\ns->rip_offset = 1;",
"else\ns->rip_offset = insn_const_size(VAR_5);",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"VAR_12 = OR_TMP0;",
"} else {",
"VAR_12 = VAR_8;",
"}",
"switch(VAR_0) {",
"default:\ncase 0x80:\ncase 0x81:\ncase 0x82:\nVAR_18 = insn_get(s, VAR_5);",
"break;",
"case 0x83:\nVAR_18 = (int8_t)insn_get(s, OT_BYTE);",
"break;",
"}",
"gen_op_movl_T1_im(VAR_18);",
"gen_op(s, VAR_17, VAR_5, VAR_12);",
"}",
"break;",
"case 0x40 ... 0x47:\nVAR_5 = VAR_3 ? OT_LONG : OT_WORD;",
"gen_inc(s, VAR_5, OR_EAX + (VAR_0 & 7), 1);",
"break;",
"case 0x48 ... 0x4f:\nVAR_5 = VAR_3 ? OT_LONG : OT_WORD;",
"gen_inc(s, VAR_5, OR_EAX + (VAR_0 & 7), -1);",
"break;",
"case 0xf6:\ncase 0xf7:\nif ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 + OT_WORD;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_9 = (VAR_6 >> 6) & 3;",
"VAR_8 = (VAR_6 & 7) | REX_B(s);",
"VAR_17 = (VAR_6 >> 3) & 7;",
"if (VAR_9 != 3) {",
"if (VAR_17 == 0)\ns->rip_offset = insn_const_size(VAR_5);",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"gen_op_ld_T0_A0(VAR_5 + s->mem_index);",
"} else {",
"gen_op_mov_TN_reg(VAR_5, 0, VAR_8);",
"}",
"switch(VAR_17) {",
"case 0:\nVAR_18 = insn_get(s, VAR_5);",
"gen_op_movl_T1_im(VAR_18);",
"gen_op_testl_T0_T1_cc();",
"s->cc_op = CC_OP_LOGICB + VAR_5;",
"break;",
"case 2:\ntcg_gen_not_tl(cpu_T[0], cpu_T[0]);",
"if (VAR_9 != 3) {",
"gen_op_st_T0_A0(VAR_5 + s->mem_index);",
"} else {",
"gen_op_mov_reg_T0(VAR_5, VAR_8);",
"}",
"break;",
"case 3:\ntcg_gen_neg_tl(cpu_T[0], cpu_T[0]);",
"if (VAR_9 != 3) {",
"gen_op_st_T0_A0(VAR_5 + s->mem_index);",
"} else {",
"gen_op_mov_reg_T0(VAR_5, VAR_8);",
"}",
"gen_op_update_neg_cc();",
"s->cc_op = CC_OP_SUBB + VAR_5;",
"break;",
"case 4:\nswitch(VAR_5) {",
"case OT_BYTE:\ngen_op_mov_TN_reg(OT_BYTE, 1, R_EAX);",
"tcg_gen_ext8u_tl(cpu_T[0], cpu_T[0]);",
"tcg_gen_ext8u_tl(cpu_T[1], cpu_T[1]);",
"tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);",
"gen_op_mov_reg_T0(OT_WORD, R_EAX);",
"tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);",
"tcg_gen_andi_tl(cpu_cc_src, cpu_T[0], 0xff00);",
"s->cc_op = CC_OP_MULB;",
"break;",
"case OT_WORD:\ngen_op_mov_TN_reg(OT_WORD, 1, R_EAX);",
"tcg_gen_ext16u_tl(cpu_T[0], cpu_T[0]);",
"tcg_gen_ext16u_tl(cpu_T[1], cpu_T[1]);",
"tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);",
"gen_op_mov_reg_T0(OT_WORD, R_EAX);",
"tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);",
"tcg_gen_shri_tl(cpu_T[0], cpu_T[0], 16);",
"gen_op_mov_reg_T0(OT_WORD, R_EDX);",
"tcg_gen_mov_tl(cpu_cc_src, cpu_T[0]);",
"s->cc_op = CC_OP_MULW;",
"break;",
"default:\ncase OT_LONG:\n#ifdef TARGET_X86_64\ngen_op_mov_TN_reg(OT_LONG, 1, R_EAX);",
"tcg_gen_ext32u_tl(cpu_T[0], cpu_T[0]);",
"tcg_gen_ext32u_tl(cpu_T[1], cpu_T[1]);",
"tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);",
"gen_op_mov_reg_T0(OT_LONG, R_EAX);",
"tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);",
"tcg_gen_shri_tl(cpu_T[0], cpu_T[0], 32);",
"gen_op_mov_reg_T0(OT_LONG, R_EDX);",
"tcg_gen_mov_tl(cpu_cc_src, cpu_T[0]);",
"#else\n{",
"TCGv_i64 t0, t1;",
"t0 = tcg_temp_new_i64();",
"t1 = tcg_temp_new_i64();",
"gen_op_mov_TN_reg(OT_LONG, 1, R_EAX);",
"tcg_gen_extu_i32_i64(t0, cpu_T[0]);",
"tcg_gen_extu_i32_i64(t1, cpu_T[1]);",
"tcg_gen_mul_i64(t0, t0, t1);",
"tcg_gen_trunc_i64_i32(cpu_T[0], t0);",
"gen_op_mov_reg_T0(OT_LONG, R_EAX);",
"tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);",
"tcg_gen_shri_i64(t0, t0, 32);",
"tcg_gen_trunc_i64_i32(cpu_T[0], t0);",
"gen_op_mov_reg_T0(OT_LONG, R_EDX);",
"tcg_gen_mov_tl(cpu_cc_src, cpu_T[0]);",
"}",
"#endif\ns->cc_op = CC_OP_MULL;",
"break;",
"#ifdef TARGET_X86_64\ncase OT_QUAD:\ngen_helper_mulq_EAX_T0(cpu_T[0]);",
"s->cc_op = CC_OP_MULQ;",
"break;",
"#endif\n}",
"break;",
"case 5:\nswitch(VAR_5) {",
"case OT_BYTE:\ngen_op_mov_TN_reg(OT_BYTE, 1, R_EAX);",
"tcg_gen_ext8s_tl(cpu_T[0], cpu_T[0]);",
"tcg_gen_ext8s_tl(cpu_T[1], cpu_T[1]);",
"tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);",
"gen_op_mov_reg_T0(OT_WORD, R_EAX);",
"tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);",
"tcg_gen_ext8s_tl(cpu_tmp0, cpu_T[0]);",
"tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);",
"s->cc_op = CC_OP_MULB;",
"break;",
"case OT_WORD:\ngen_op_mov_TN_reg(OT_WORD, 1, R_EAX);",
"tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);",
"tcg_gen_ext16s_tl(cpu_T[1], cpu_T[1]);",
"tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);",
"gen_op_mov_reg_T0(OT_WORD, R_EAX);",
"tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);",
"tcg_gen_ext16s_tl(cpu_tmp0, cpu_T[0]);",
"tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);",
"tcg_gen_shri_tl(cpu_T[0], cpu_T[0], 16);",
"gen_op_mov_reg_T0(OT_WORD, R_EDX);",
"s->cc_op = CC_OP_MULW;",
"break;",
"default:\ncase OT_LONG:\n#ifdef TARGET_X86_64\ngen_op_mov_TN_reg(OT_LONG, 1, R_EAX);",
"tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);",
"tcg_gen_ext32s_tl(cpu_T[1], cpu_T[1]);",
"tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);",
"gen_op_mov_reg_T0(OT_LONG, R_EAX);",
"tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);",
"tcg_gen_ext32s_tl(cpu_tmp0, cpu_T[0]);",
"tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);",
"tcg_gen_shri_tl(cpu_T[0], cpu_T[0], 32);",
"gen_op_mov_reg_T0(OT_LONG, R_EDX);",
"#else\n{",
"TCGv_i64 t0, t1;",
"t0 = tcg_temp_new_i64();",
"t1 = tcg_temp_new_i64();",
"gen_op_mov_TN_reg(OT_LONG, 1, R_EAX);",
"tcg_gen_ext_i32_i64(t0, cpu_T[0]);",
"tcg_gen_ext_i32_i64(t1, cpu_T[1]);",
"tcg_gen_mul_i64(t0, t0, t1);",
"tcg_gen_trunc_i64_i32(cpu_T[0], t0);",
"gen_op_mov_reg_T0(OT_LONG, R_EAX);",
"tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);",
"tcg_gen_sari_tl(cpu_tmp0, cpu_T[0], 31);",
"tcg_gen_shri_i64(t0, t0, 32);",
"tcg_gen_trunc_i64_i32(cpu_T[0], t0);",
"gen_op_mov_reg_T0(OT_LONG, R_EDX);",
"tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);",
"}",
"#endif\ns->cc_op = CC_OP_MULL;",
"break;",
"#ifdef TARGET_X86_64\ncase OT_QUAD:\ngen_helper_imulq_EAX_T0(cpu_T[0]);",
"s->cc_op = CC_OP_MULQ;",
"break;",
"#endif\n}",
"break;",
"case 6:\nswitch(VAR_5) {",
"case OT_BYTE:\ngen_jmp_im(pc_start - s->cs_base);",
"gen_helper_divb_AL(cpu_T[0]);",
"break;",
"case OT_WORD:\ngen_jmp_im(pc_start - s->cs_base);",
"gen_helper_divw_AX(cpu_T[0]);",
"break;",
"default:\ncase OT_LONG:\ngen_jmp_im(pc_start - s->cs_base);",
"gen_helper_divl_EAX(cpu_T[0]);",
"break;",
"#ifdef TARGET_X86_64\ncase OT_QUAD:\ngen_jmp_im(pc_start - s->cs_base);",
"gen_helper_divq_EAX(cpu_T[0]);",
"break;",
"#endif\n}",
"break;",
"case 7:\nswitch(VAR_5) {",
"case OT_BYTE:\ngen_jmp_im(pc_start - s->cs_base);",
"gen_helper_idivb_AL(cpu_T[0]);",
"break;",
"case OT_WORD:\ngen_jmp_im(pc_start - s->cs_base);",
"gen_helper_idivw_AX(cpu_T[0]);",
"break;",
"default:\ncase OT_LONG:\ngen_jmp_im(pc_start - s->cs_base);",
"gen_helper_idivl_EAX(cpu_T[0]);",
"break;",
"#ifdef TARGET_X86_64\ncase OT_QUAD:\ngen_jmp_im(pc_start - s->cs_base);",
"gen_helper_idivq_EAX(cpu_T[0]);",
"break;",
"#endif\n}",
"break;",
"default:\ngoto illegal_op;",
"}",
"break;",
"case 0xfe:\ncase 0xff:\nif ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 + OT_WORD;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_9 = (VAR_6 >> 6) & 3;",
"VAR_8 = (VAR_6 & 7) | REX_B(s);",
"VAR_17 = (VAR_6 >> 3) & 7;",
"if (VAR_17 >= 2 && VAR_0 == 0xfe) {",
"goto illegal_op;",
"}",
"if (CODE64(s)) {",
"if (VAR_17 == 2 || VAR_17 == 4) {",
"VAR_5 = OT_QUAD;",
"} else if (VAR_17 == 3 || VAR_17 == 5) {",
"VAR_5 = VAR_3 ? OT_LONG : OT_WORD;",
"} else if (VAR_17 == 6) {",
"VAR_5 = VAR_3 ? OT_QUAD : OT_WORD;",
"}",
"}",
"if (VAR_9 != 3) {",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"if (VAR_17 >= 2 && VAR_17 != 3 && VAR_17 != 5)\ngen_op_ld_T0_A0(VAR_5 + s->mem_index);",
"} else {",
"gen_op_mov_TN_reg(VAR_5, 0, VAR_8);",
"}",
"switch(VAR_17) {",
"case 0:\nif (VAR_9 != 3)\nVAR_12 = OR_TMP0;",
"else\nVAR_12 = VAR_8;",
"gen_inc(s, VAR_5, VAR_12, 1);",
"break;",
"case 1:\nif (VAR_9 != 3)\nVAR_12 = OR_TMP0;",
"else\nVAR_12 = VAR_8;",
"gen_inc(s, VAR_5, VAR_12, -1);",
"break;",
"case 2:\nif (s->VAR_3 == 0)\ngen_op_andl_T0_ffff();",
"next_eip = s->pc - s->cs_base;",
"gen_movtl_T1_im(next_eip);",
"gen_push_T1(s);",
"gen_op_jmp_T0();",
"gen_eob(s);",
"break;",
"case 3:\ngen_op_ld_T1_A0(VAR_5 + s->mem_index);",
"gen_add_A0_im(s, 1 << (VAR_5 - OT_WORD + 1));",
"gen_op_ldu_T0_A0(OT_WORD + s->mem_index);",
"do_lcall:\nif (s->pe && !s->vm86) {",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);",
"gen_helper_lcall_protected(cpu_tmp2_i32, cpu_T[1],\ntcg_const_i32(VAR_3),\ntcg_const_i32(s->pc - pc_start));",
"} else {",
"tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);",
"gen_helper_lcall_real(cpu_tmp2_i32, cpu_T[1],\ntcg_const_i32(VAR_3),\ntcg_const_i32(s->pc - s->cs_base));",
"}",
"gen_eob(s);",
"break;",
"case 4:\nif (s->VAR_3 == 0)\ngen_op_andl_T0_ffff();",
"gen_op_jmp_T0();",
"gen_eob(s);",
"break;",
"case 5:\ngen_op_ld_T1_A0(VAR_5 + s->mem_index);",
"gen_add_A0_im(s, 1 << (VAR_5 - OT_WORD + 1));",
"gen_op_ldu_T0_A0(OT_WORD + s->mem_index);",
"do_ljmp:\nif (s->pe && !s->vm86) {",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);",
"gen_helper_ljmp_protected(cpu_tmp2_i32, cpu_T[1],\ntcg_const_i32(s->pc - pc_start));",
"} else {",
"gen_op_movl_seg_T0_vm(R_CS);",
"gen_op_movl_T0_T1();",
"gen_op_jmp_T0();",
"}",
"gen_eob(s);",
"break;",
"case 6:\ngen_push_T0(s);",
"break;",
"default:\ngoto illegal_op;",
"}",
"break;",
"case 0x84:\ncase 0x85:\nif ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 + OT_WORD;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_9 = (VAR_6 >> 6) & 3;",
"VAR_8 = (VAR_6 & 7) | REX_B(s);",
"VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;",
"gen_ldst_modrm(s, VAR_6, VAR_5, OR_TMP0, 0);",
"gen_op_mov_TN_reg(VAR_5, 1, VAR_7);",
"gen_op_testl_T0_T1_cc();",
"s->cc_op = CC_OP_LOGICB + VAR_5;",
"break;",
"case 0xa8:\ncase 0xa9:\nif ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 + OT_WORD;",
"VAR_18 = insn_get(s, VAR_5);",
"gen_op_mov_TN_reg(VAR_5, 0, OR_EAX);",
"gen_op_movl_T1_im(VAR_18);",
"gen_op_testl_T0_T1_cc();",
"s->cc_op = CC_OP_LOGICB + VAR_5;",
"break;",
"case 0x98:\n#ifdef TARGET_X86_64\nif (VAR_3 == 2) {",
"gen_op_mov_TN_reg(OT_LONG, 0, R_EAX);",
"tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);",
"gen_op_mov_reg_T0(OT_QUAD, R_EAX);",
"} else",
"#endif\nif (VAR_3 == 1) {",
"gen_op_mov_TN_reg(OT_WORD, 0, R_EAX);",
"tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);",
"gen_op_mov_reg_T0(OT_LONG, R_EAX);",
"} else {",
"gen_op_mov_TN_reg(OT_BYTE, 0, R_EAX);",
"tcg_gen_ext8s_tl(cpu_T[0], cpu_T[0]);",
"gen_op_mov_reg_T0(OT_WORD, R_EAX);",
"}",
"break;",
"case 0x99:\n#ifdef TARGET_X86_64\nif (VAR_3 == 2) {",
"gen_op_mov_TN_reg(OT_QUAD, 0, R_EAX);",
"tcg_gen_sari_tl(cpu_T[0], cpu_T[0], 63);",
"gen_op_mov_reg_T0(OT_QUAD, R_EDX);",
"} else",
"#endif\nif (VAR_3 == 1) {",
"gen_op_mov_TN_reg(OT_LONG, 0, R_EAX);",
"tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);",
"tcg_gen_sari_tl(cpu_T[0], cpu_T[0], 31);",
"gen_op_mov_reg_T0(OT_LONG, R_EDX);",
"} else {",
"gen_op_mov_TN_reg(OT_WORD, 0, R_EAX);",
"tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);",
"tcg_gen_sari_tl(cpu_T[0], cpu_T[0], 15);",
"gen_op_mov_reg_T0(OT_WORD, R_EDX);",
"}",
"break;",
"case 0x1af:\ncase 0x69:\ncase 0x6b:\nVAR_5 = VAR_3 + OT_WORD;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;",
"if (VAR_0 == 0x69)\ns->rip_offset = insn_const_size(VAR_5);",
"else if (VAR_0 == 0x6b)\ns->rip_offset = 1;",
"gen_ldst_modrm(s, VAR_6, VAR_5, OR_TMP0, 0);",
"if (VAR_0 == 0x69) {",
"VAR_18 = insn_get(s, VAR_5);",
"gen_op_movl_T1_im(VAR_18);",
"} else if (VAR_0 == 0x6b) {",
"VAR_18 = (int8_t)insn_get(s, OT_BYTE);",
"gen_op_movl_T1_im(VAR_18);",
"} else {",
"gen_op_mov_TN_reg(VAR_5, 1, VAR_7);",
"}",
"#ifdef TARGET_X86_64\nif (VAR_5 == OT_QUAD) {",
"gen_helper_imulq_T0_T1(cpu_T[0], cpu_T[0], cpu_T[1]);",
"} else",
"#endif\nif (VAR_5 == OT_LONG) {",
"#ifdef TARGET_X86_64\ntcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);",
"tcg_gen_ext32s_tl(cpu_T[1], cpu_T[1]);",
"tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);",
"tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);",
"tcg_gen_ext32s_tl(cpu_tmp0, cpu_T[0]);",
"tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);",
"#else\n{",
"TCGv_i64 t0, t1;",
"t0 = tcg_temp_new_i64();",
"t1 = tcg_temp_new_i64();",
"tcg_gen_ext_i32_i64(t0, cpu_T[0]);",
"tcg_gen_ext_i32_i64(t1, cpu_T[1]);",
"tcg_gen_mul_i64(t0, t0, t1);",
"tcg_gen_trunc_i64_i32(cpu_T[0], t0);",
"tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);",
"tcg_gen_sari_tl(cpu_tmp0, cpu_T[0], 31);",
"tcg_gen_shri_i64(t0, t0, 32);",
"tcg_gen_trunc_i64_i32(cpu_T[1], t0);",
"tcg_gen_sub_tl(cpu_cc_src, cpu_T[1], cpu_tmp0);",
"}",
"#endif\n} else {",
"tcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);",
"tcg_gen_ext16s_tl(cpu_T[1], cpu_T[1]);",
"tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);",
"tcg_gen_mov_tl(cpu_cc_dst, cpu_T[0]);",
"tcg_gen_ext16s_tl(cpu_tmp0, cpu_T[0]);",
"tcg_gen_sub_tl(cpu_cc_src, cpu_T[0], cpu_tmp0);",
"}",
"gen_op_mov_reg_T0(VAR_5, VAR_7);",
"s->cc_op = CC_OP_MULB + VAR_5;",
"break;",
"case 0x1c0:\ncase 0x1c1:\nif ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 + OT_WORD;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;",
"VAR_9 = (VAR_6 >> 6) & 3;",
"if (VAR_9 == 3) {",
"VAR_8 = (VAR_6 & 7) | REX_B(s);",
"gen_op_mov_TN_reg(VAR_5, 0, VAR_7);",
"gen_op_mov_TN_reg(VAR_5, 1, VAR_8);",
"gen_op_addl_T0_T1();",
"gen_op_mov_reg_T1(VAR_5, VAR_7);",
"gen_op_mov_reg_T0(VAR_5, VAR_8);",
"} else {",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"gen_op_mov_TN_reg(VAR_5, 0, VAR_7);",
"gen_op_ld_T1_A0(VAR_5 + s->mem_index);",
"gen_op_addl_T0_T1();",
"gen_op_st_T0_A0(VAR_5 + s->mem_index);",
"gen_op_mov_reg_T1(VAR_5, VAR_7);",
"}",
"gen_op_update2_cc();",
"s->cc_op = CC_OP_ADDB + VAR_5;",
"break;",
"case 0x1b0:\ncase 0x1b1:\n{",
"int VAR_29, VAR_19;",
"TCGv t0, t1, t2, a0;",
"if ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 + OT_WORD;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;",
"VAR_9 = (VAR_6 >> 6) & 3;",
"t0 = tcg_temp_local_new();",
"t1 = tcg_temp_local_new();",
"t2 = tcg_temp_local_new();",
"a0 = tcg_temp_local_new();",
"gen_op_mov_v_reg(VAR_5, t1, VAR_7);",
"if (VAR_9 == 3) {",
"VAR_8 = (VAR_6 & 7) | REX_B(s);",
"gen_op_mov_v_reg(VAR_5, t0, VAR_8);",
"} else {",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"tcg_gen_mov_tl(a0, cpu_A0);",
"gen_op_ld_v(VAR_5 + s->mem_index, t0, a0);",
"VAR_8 = 0;",
"}",
"VAR_29 = gen_new_label();",
"tcg_gen_ld_tl(t2, cpu_env, offsetof(CPUState, regs[R_EAX]));",
"tcg_gen_sub_tl(t2, t2, t0);",
"gen_extu(VAR_5, t2);",
"tcg_gen_brcondi_tl(TCG_COND_EQ, t2, 0, VAR_29);",
"if (VAR_9 == 3) {",
"VAR_19 = gen_new_label();",
"gen_op_mov_reg_v(VAR_5, R_EAX, t0);",
"tcg_gen_br(VAR_19);",
"gen_set_label(VAR_29);",
"gen_op_mov_reg_v(VAR_5, VAR_8, t1);",
"gen_set_label(VAR_19);",
"} else {",
"tcg_gen_mov_tl(t1, t0);",
"gen_op_mov_reg_v(VAR_5, R_EAX, t0);",
"gen_set_label(VAR_29);",
"gen_op_st_v(VAR_5 + s->mem_index, t1, a0);",
"}",
"tcg_gen_mov_tl(cpu_cc_src, t0);",
"tcg_gen_mov_tl(cpu_cc_dst, t2);",
"s->cc_op = CC_OP_SUBB + VAR_5;",
"tcg_temp_free(t0);",
"tcg_temp_free(t1);",
"tcg_temp_free(t2);",
"tcg_temp_free(a0);",
"}",
"break;",
"case 0x1c7:\nVAR_6 = ldub_code(s->pc++);",
"VAR_9 = (VAR_6 >> 6) & 3;",
"if ((VAR_9 == 3) || ((VAR_6 & 0x38) != 0x8))\ngoto illegal_op;",
"#ifdef TARGET_X86_64\nif (VAR_3 == 2) {",
"if (!(s->cpuid_ext_features & CPUID_EXT_CX16))\ngoto illegal_op;",
"gen_jmp_im(pc_start - s->cs_base);",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"gen_helper_cmpxchg16b(cpu_A0);",
"} else",
"#endif\n{",
"if (!(s->cpuid_features & CPUID_CX8))\ngoto illegal_op;",
"gen_jmp_im(pc_start - s->cs_base);",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"gen_helper_cmpxchg8b(cpu_A0);",
"}",
"s->cc_op = CC_OP_EFLAGS;",
"break;",
"case 0x50 ... 0x57:\ngen_op_mov_TN_reg(OT_LONG, 0, (VAR_0 & 7) | REX_B(s));",
"gen_push_T0(s);",
"break;",
"case 0x58 ... 0x5f:\nif (CODE64(s)) {",
"VAR_5 = VAR_3 ? OT_QUAD : OT_WORD;",
"} else {",
"VAR_5 = VAR_3 + OT_WORD;",
"}",
"gen_pop_T0(s);",
"gen_pop_update(s);",
"gen_op_mov_reg_T0(VAR_5, (VAR_0 & 7) | REX_B(s));",
"break;",
"case 0x60:\nif (CODE64(s))\ngoto illegal_op;",
"gen_pusha(s);",
"break;",
"case 0x61:\nif (CODE64(s))\ngoto illegal_op;",
"gen_popa(s);",
"break;",
"case 0x68:\ncase 0x6a:\nif (CODE64(s)) {",
"VAR_5 = VAR_3 ? OT_QUAD : OT_WORD;",
"} else {",
"VAR_5 = VAR_3 + OT_WORD;",
"}",
"if (VAR_0 == 0x68)\nVAR_18 = insn_get(s, VAR_5);",
"else\nVAR_18 = (int8_t)insn_get(s, OT_BYTE);",
"gen_op_movl_T0_im(VAR_18);",
"gen_push_T0(s);",
"break;",
"case 0x8f:\nif (CODE64(s)) {",
"VAR_5 = VAR_3 ? OT_QUAD : OT_WORD;",
"} else {",
"VAR_5 = VAR_3 + OT_WORD;",
"}",
"VAR_6 = ldub_code(s->pc++);",
"VAR_9 = (VAR_6 >> 6) & 3;",
"gen_pop_T0(s);",
"if (VAR_9 == 3) {",
"gen_pop_update(s);",
"VAR_8 = (VAR_6 & 7) | REX_B(s);",
"gen_op_mov_reg_T0(VAR_5, VAR_8);",
"} else {",
"s->popl_esp_hack = 1 << VAR_5;",
"gen_ldst_modrm(s, VAR_6, VAR_5, OR_TMP0, 1);",
"s->popl_esp_hack = 0;",
"gen_pop_update(s);",
"}",
"break;",
"case 0xc8:\n{",
"int VAR_20;",
"VAR_18 = lduw_code(s->pc);",
"s->pc += 2;",
"VAR_20 = ldub_code(s->pc++);",
"gen_enter(s, VAR_18, VAR_20);",
"}",
"break;",
"case 0xc9:\nif (CODE64(s)) {",
"gen_op_mov_TN_reg(OT_QUAD, 0, R_EBP);",
"gen_op_mov_reg_T0(OT_QUAD, R_ESP);",
"} else if (s->ss32) {",
"gen_op_mov_TN_reg(OT_LONG, 0, R_EBP);",
"gen_op_mov_reg_T0(OT_LONG, R_ESP);",
"} else {",
"gen_op_mov_TN_reg(OT_WORD, 0, R_EBP);",
"gen_op_mov_reg_T0(OT_WORD, R_ESP);",
"}",
"gen_pop_T0(s);",
"if (CODE64(s)) {",
"VAR_5 = VAR_3 ? OT_QUAD : OT_WORD;",
"} else {",
"VAR_5 = VAR_3 + OT_WORD;",
"}",
"gen_op_mov_reg_T0(VAR_5, R_EBP);",
"gen_pop_update(s);",
"break;",
"case 0x06:\ncase 0x0e:\ncase 0x16:\ncase 0x1e:\nif (CODE64(s))\ngoto illegal_op;",
"gen_op_movl_T0_seg(VAR_0 >> 3);",
"gen_push_T0(s);",
"break;",
"case 0x1a0:\ncase 0x1a8:\ngen_op_movl_T0_seg((VAR_0 >> 3) & 7);",
"gen_push_T0(s);",
"break;",
"case 0x07:\ncase 0x17:\ncase 0x1f:\nif (CODE64(s))\ngoto illegal_op;",
"VAR_7 = VAR_0 >> 3;",
"gen_pop_T0(s);",
"gen_movl_seg_T0(s, VAR_7, pc_start - s->cs_base);",
"gen_pop_update(s);",
"if (VAR_7 == R_SS) {",
"if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK))\ngen_helper_set_inhibit_irq();",
"s->tf = 0;",
"}",
"if (s->is_jmp) {",
"gen_jmp_im(s->pc - s->cs_base);",
"gen_eob(s);",
"}",
"break;",
"case 0x1a1:\ncase 0x1a9:\ngen_pop_T0(s);",
"gen_movl_seg_T0(s, (VAR_0 >> 3) & 7, pc_start - s->cs_base);",
"gen_pop_update(s);",
"if (s->is_jmp) {",
"gen_jmp_im(s->pc - s->cs_base);",
"gen_eob(s);",
"}",
"break;",
"case 0x88:\ncase 0x89:\nif ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 + OT_WORD;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;",
"gen_ldst_modrm(s, VAR_6, VAR_5, VAR_7, 1);",
"break;",
"case 0xc6:\ncase 0xc7:\nif ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 + OT_WORD;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_9 = (VAR_6 >> 6) & 3;",
"if (VAR_9 != 3) {",
"s->rip_offset = insn_const_size(VAR_5);",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"}",
"VAR_18 = insn_get(s, VAR_5);",
"gen_op_movl_T0_im(VAR_18);",
"if (VAR_9 != 3)\ngen_op_st_T0_A0(VAR_5 + s->mem_index);",
"else\ngen_op_mov_reg_T0(VAR_5, (VAR_6 & 7) | REX_B(s));",
"break;",
"case 0x8a:\ncase 0x8b:\nif ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = OT_WORD + VAR_3;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;",
"gen_ldst_modrm(s, VAR_6, VAR_5, OR_TMP0, 0);",
"gen_op_mov_reg_T0(VAR_5, VAR_7);",
"break;",
"case 0x8e:\nVAR_6 = ldub_code(s->pc++);",
"VAR_7 = (VAR_6 >> 3) & 7;",
"if (VAR_7 >= 6 || VAR_7 == R_CS)\ngoto illegal_op;",
"gen_ldst_modrm(s, VAR_6, OT_WORD, OR_TMP0, 0);",
"gen_movl_seg_T0(s, VAR_7, pc_start - s->cs_base);",
"if (VAR_7 == R_SS) {",
"if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK))\ngen_helper_set_inhibit_irq();",
"s->tf = 0;",
"}",
"if (s->is_jmp) {",
"gen_jmp_im(s->pc - s->cs_base);",
"gen_eob(s);",
"}",
"break;",
"case 0x8c:\nVAR_6 = ldub_code(s->pc++);",
"VAR_7 = (VAR_6 >> 3) & 7;",
"VAR_9 = (VAR_6 >> 6) & 3;",
"if (VAR_7 >= 6)\ngoto illegal_op;",
"gen_op_movl_T0_seg(VAR_7);",
"if (VAR_9 == 3)\nVAR_5 = OT_WORD + VAR_3;",
"else\nVAR_5 = OT_WORD;",
"gen_ldst_modrm(s, VAR_6, VAR_5, OR_TMP0, 1);",
"break;",
"case 0x1b6:\ncase 0x1b7:\ncase 0x1be:\ncase 0x1bf:\n{",
"int VAR_21;",
"VAR_21 = VAR_3 + OT_WORD;",
"VAR_5 = (VAR_0 & 1) + OT_BYTE;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;",
"VAR_9 = (VAR_6 >> 6) & 3;",
"VAR_8 = (VAR_6 & 7) | REX_B(s);",
"if (VAR_9 == 3) {",
"gen_op_mov_TN_reg(VAR_5, 0, VAR_8);",
"switch(VAR_5 | (VAR_0 & 8)) {",
"case OT_BYTE:\ntcg_gen_ext8u_tl(cpu_T[0], cpu_T[0]);",
"break;",
"case OT_BYTE | 8:\ntcg_gen_ext8s_tl(cpu_T[0], cpu_T[0]);",
"break;",
"case OT_WORD:\ntcg_gen_ext16u_tl(cpu_T[0], cpu_T[0]);",
"break;",
"default:\ncase OT_WORD | 8:\ntcg_gen_ext16s_tl(cpu_T[0], cpu_T[0]);",
"break;",
"}",
"gen_op_mov_reg_T0(VAR_21, VAR_7);",
"} else {",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"if (VAR_0 & 8) {",
"gen_op_lds_T0_A0(VAR_5 + s->mem_index);",
"} else {",
"gen_op_ldu_T0_A0(VAR_5 + s->mem_index);",
"}",
"gen_op_mov_reg_T0(VAR_21, VAR_7);",
"}",
"}",
"break;",
"case 0x8d:\nVAR_5 = VAR_3 + OT_WORD;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_9 = (VAR_6 >> 6) & 3;",
"if (VAR_9 == 3)\ngoto illegal_op;",
"VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;",
"s->override = -1;",
"VAR_18 = s->addseg;",
"s->addseg = 0;",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"s->addseg = VAR_18;",
"gen_op_mov_reg_A0(VAR_5 - OT_WORD, VAR_7);",
"break;",
"case 0xa0:\ncase 0xa1:\ncase 0xa2:\ncase 0xa3:\n{",
"target_ulong VAR_13;",
"if ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 + OT_WORD;",
"#ifdef TARGET_X86_64\nif (s->VAR_2 == 2) {",
"VAR_13 = ldq_code(s->pc);",
"s->pc += 8;",
"gen_op_movq_A0_im(VAR_13);",
"} else",
"#endif\n{",
"if (s->VAR_2) {",
"VAR_13 = insn_get(s, OT_LONG);",
"} else {",
"VAR_13 = insn_get(s, OT_WORD);",
"}",
"gen_op_movl_A0_im(VAR_13);",
"}",
"gen_add_A0_ds_seg(s);",
"if ((VAR_0 & 2) == 0) {",
"gen_op_ld_T0_A0(VAR_5 + s->mem_index);",
"gen_op_mov_reg_T0(VAR_5, R_EAX);",
"} else {",
"gen_op_mov_TN_reg(VAR_5, 0, R_EAX);",
"gen_op_st_T0_A0(VAR_5 + s->mem_index);",
"}",
"}",
"break;",
"case 0xd7:\n#ifdef TARGET_X86_64\nif (s->VAR_2 == 2) {",
"gen_op_movq_A0_reg(R_EBX);",
"gen_op_mov_TN_reg(OT_QUAD, 0, R_EAX);",
"tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0xff);",
"tcg_gen_add_tl(cpu_A0, cpu_A0, cpu_T[0]);",
"} else",
"#endif\n{",
"gen_op_movl_A0_reg(R_EBX);",
"gen_op_mov_TN_reg(OT_LONG, 0, R_EAX);",
"tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0xff);",
"tcg_gen_add_tl(cpu_A0, cpu_A0, cpu_T[0]);",
"if (s->VAR_2 == 0)\ngen_op_andl_A0_ffff();",
"else\ntcg_gen_andi_tl(cpu_A0, cpu_A0, 0xffffffff);",
"}",
"gen_add_A0_ds_seg(s);",
"gen_op_ldu_T0_A0(OT_BYTE + s->mem_index);",
"gen_op_mov_reg_T0(OT_BYTE, R_EAX);",
"break;",
"case 0xb0 ... 0xb7:\nVAR_18 = insn_get(s, OT_BYTE);",
"gen_op_movl_T0_im(VAR_18);",
"gen_op_mov_reg_T0(OT_BYTE, (VAR_0 & 7) | REX_B(s));",
"break;",
"case 0xb8 ... 0xbf:\n#ifdef TARGET_X86_64\nif (VAR_3 == 2) {",
"uint64_t tmp;",
"tmp = ldq_code(s->pc);",
"s->pc += 8;",
"VAR_7 = (VAR_0 & 7) | REX_B(s);",
"gen_movtl_T0_im(tmp);",
"gen_op_mov_reg_T0(OT_QUAD, VAR_7);",
"} else",
"#endif\n{",
"VAR_5 = VAR_3 ? OT_LONG : OT_WORD;",
"VAR_18 = insn_get(s, VAR_5);",
"VAR_7 = (VAR_0 & 7) | REX_B(s);",
"gen_op_movl_T0_im(VAR_18);",
"gen_op_mov_reg_T0(VAR_5, VAR_7);",
"}",
"break;",
"case 0x91 ... 0x97:\nVAR_5 = VAR_3 + OT_WORD;",
"VAR_7 = (VAR_0 & 7) | REX_B(s);",
"VAR_8 = R_EAX;",
"goto do_xchg_reg;",
"case 0x86:\ncase 0x87:\nif ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 + OT_WORD;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;",
"VAR_9 = (VAR_6 >> 6) & 3;",
"if (VAR_9 == 3) {",
"VAR_8 = (VAR_6 & 7) | REX_B(s);",
"do_xchg_reg:\ngen_op_mov_TN_reg(VAR_5, 0, VAR_7);",
"gen_op_mov_TN_reg(VAR_5, 1, VAR_8);",
"gen_op_mov_reg_T0(VAR_5, VAR_8);",
"gen_op_mov_reg_T1(VAR_5, VAR_7);",
"} else {",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"gen_op_mov_TN_reg(VAR_5, 0, VAR_7);",
"if (!(VAR_1 & PREFIX_LOCK))\ngen_helper_lock();",
"gen_op_ld_T1_A0(VAR_5 + s->mem_index);",
"gen_op_st_T0_A0(VAR_5 + s->mem_index);",
"if (!(VAR_1 & PREFIX_LOCK))\ngen_helper_unlock();",
"gen_op_mov_reg_T1(VAR_5, VAR_7);",
"}",
"break;",
"case 0xc4:\nif (CODE64(s))\ngoto illegal_op;",
"VAR_17 = R_ES;",
"goto do_lxx;",
"case 0xc5:\nif (CODE64(s))\ngoto illegal_op;",
"VAR_17 = R_DS;",
"goto do_lxx;",
"case 0x1b2:\nVAR_17 = R_SS;",
"goto do_lxx;",
"case 0x1b4:\nVAR_17 = R_FS;",
"goto do_lxx;",
"case 0x1b5:\nVAR_17 = R_GS;",
"do_lxx:\nVAR_5 = VAR_3 ? OT_LONG : OT_WORD;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;",
"VAR_9 = (VAR_6 >> 6) & 3;",
"if (VAR_9 == 3)\ngoto illegal_op;",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"gen_op_ld_T1_A0(VAR_5 + s->mem_index);",
"gen_add_A0_im(s, 1 << (VAR_5 - OT_WORD + 1));",
"gen_op_ldu_T0_A0(OT_WORD + s->mem_index);",
"gen_movl_seg_T0(s, VAR_17, pc_start - s->cs_base);",
"gen_op_mov_reg_T1(VAR_5, VAR_7);",
"if (s->is_jmp) {",
"gen_jmp_im(s->pc - s->cs_base);",
"gen_eob(s);",
"}",
"break;",
"case 0xc0:\ncase 0xc1:\nVAR_4 = 2;",
"grp2:\n{",
"if ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 + OT_WORD;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_9 = (VAR_6 >> 6) & 3;",
"VAR_17 = (VAR_6 >> 3) & 7;",
"if (VAR_9 != 3) {",
"if (VAR_4 == 2) {",
"s->rip_offset = 1;",
"}",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"VAR_12 = OR_TMP0;",
"} else {",
"VAR_12 = (VAR_6 & 7) | REX_B(s);",
"}",
"if (VAR_4 == 0) {",
"gen_shift(s, VAR_17, VAR_5, VAR_12, OR_ECX);",
"} else {",
"if (VAR_4 == 2) {",
"VAR_4 = ldub_code(s->pc++);",
"}",
"gen_shifti(s, VAR_17, VAR_5, VAR_12, VAR_4);",
"}",
"}",
"break;",
"case 0xd0:\ncase 0xd1:\nVAR_4 = 1;",
"goto grp2;",
"case 0xd2:\ncase 0xd3:\nVAR_4 = 0;",
"goto grp2;",
"case 0x1a4:\nVAR_17 = 0;",
"VAR_4 = 1;",
"goto do_shiftd;",
"case 0x1a5:\nVAR_17 = 0;",
"VAR_4 = 0;",
"goto do_shiftd;",
"case 0x1ac:\nVAR_17 = 1;",
"VAR_4 = 1;",
"goto do_shiftd;",
"case 0x1ad:\nVAR_17 = 1;",
"VAR_4 = 0;",
"do_shiftd:\nVAR_5 = VAR_3 + OT_WORD;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_9 = (VAR_6 >> 6) & 3;",
"VAR_8 = (VAR_6 & 7) | REX_B(s);",
"VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;",
"if (VAR_9 != 3) {",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"VAR_12 = OR_TMP0;",
"} else {",
"VAR_12 = VAR_8;",
"}",
"gen_op_mov_TN_reg(VAR_5, 1, VAR_7);",
"if (VAR_4) {",
"VAR_18 = ldub_code(s->pc++);",
"tcg_gen_movi_tl(cpu_T3, VAR_18);",
"} else {",
"tcg_gen_ld_tl(cpu_T3, cpu_env, offsetof(CPUState, regs[R_ECX]));",
"}",
"gen_shiftd_rm_T1_T3(s, VAR_5, VAR_12, VAR_17);",
"break;",
"case 0xd8 ... 0xdf:\nif (s->flags & (HF_EM_MASK | HF_TS_MASK)) {",
"gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);",
"break;",
"}",
"VAR_6 = ldub_code(s->pc++);",
"VAR_9 = (VAR_6 >> 6) & 3;",
"VAR_8 = VAR_6 & 7;",
"VAR_17 = ((VAR_0 & 7) << 3) | ((VAR_6 >> 3) & 7);",
"if (VAR_9 != 3) {",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"switch(VAR_17) {",
"case 0x00 ... 0x07:\ncase 0x10 ... 0x17:\ncase 0x20 ... 0x27:\ncase 0x30 ... 0x37:\n{",
"int VAR_23;",
"VAR_23 = VAR_17 & 7;",
"switch(VAR_17 >> 4) {",
"case 0:\ngen_op_ld_T0_A0(OT_LONG + s->mem_index);",
"tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);",
"gen_helper_flds_FT0(cpu_tmp2_i32);",
"break;",
"case 1:\ngen_op_ld_T0_A0(OT_LONG + s->mem_index);",
"tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);",
"gen_helper_fildl_FT0(cpu_tmp2_i32);",
"break;",
"case 2:\ntcg_gen_qemu_ld64(cpu_tmp1_i64, cpu_A0,\n(s->mem_index >> 2) - 1);",
"gen_helper_fldl_FT0(cpu_tmp1_i64);",
"break;",
"case 3:\ndefault:\ngen_op_lds_T0_A0(OT_WORD + s->mem_index);",
"tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);",
"gen_helper_fildl_FT0(cpu_tmp2_i32);",
"break;",
"}",
"gen_helper_fp_arith_ST0_FT0(VAR_23);",
"if (VAR_23 == 3) {",
"gen_helper_fpop();",
"}",
"}",
"break;",
"case 0x08:\ncase 0x0a:\ncase 0x0b:\ncase 0x18 ... 0x1b:\ncase 0x28 ... 0x2b:\ncase 0x38 ... 0x3b:\nswitch(VAR_17 & 7) {",
"case 0:\nswitch(VAR_17 >> 4) {",
"case 0:\ngen_op_ld_T0_A0(OT_LONG + s->mem_index);",
"tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);",
"gen_helper_flds_ST0(cpu_tmp2_i32);",
"break;",
"case 1:\ngen_op_ld_T0_A0(OT_LONG + s->mem_index);",
"tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);",
"gen_helper_fildl_ST0(cpu_tmp2_i32);",
"break;",
"case 2:\ntcg_gen_qemu_ld64(cpu_tmp1_i64, cpu_A0,\n(s->mem_index >> 2) - 1);",
"gen_helper_fldl_ST0(cpu_tmp1_i64);",
"break;",
"case 3:\ndefault:\ngen_op_lds_T0_A0(OT_WORD + s->mem_index);",
"tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);",
"gen_helper_fildl_ST0(cpu_tmp2_i32);",
"break;",
"}",
"break;",
"case 1:\nswitch(VAR_17 >> 4) {",
"case 1:\ngen_helper_fisttl_ST0(cpu_tmp2_i32);",
"tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);",
"gen_op_st_T0_A0(OT_LONG + s->mem_index);",
"break;",
"case 2:\ngen_helper_fisttll_ST0(cpu_tmp1_i64);",
"tcg_gen_qemu_st64(cpu_tmp1_i64, cpu_A0,\n(s->mem_index >> 2) - 1);",
"break;",
"case 3:\ndefault:\ngen_helper_fistt_ST0(cpu_tmp2_i32);",
"tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);",
"gen_op_st_T0_A0(OT_WORD + s->mem_index);",
"break;",
"}",
"gen_helper_fpop();",
"break;",
"default:\nswitch(VAR_17 >> 4) {",
"case 0:\ngen_helper_fsts_ST0(cpu_tmp2_i32);",
"tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);",
"gen_op_st_T0_A0(OT_LONG + s->mem_index);",
"break;",
"case 1:\ngen_helper_fistl_ST0(cpu_tmp2_i32);",
"tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);",
"gen_op_st_T0_A0(OT_LONG + s->mem_index);",
"break;",
"case 2:\ngen_helper_fstl_ST0(cpu_tmp1_i64);",
"tcg_gen_qemu_st64(cpu_tmp1_i64, cpu_A0,\n(s->mem_index >> 2) - 1);",
"break;",
"case 3:\ndefault:\ngen_helper_fist_ST0(cpu_tmp2_i32);",
"tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);",
"gen_op_st_T0_A0(OT_WORD + s->mem_index);",
"break;",
"}",
"if ((VAR_17 & 7) == 3)\ngen_helper_fpop();",
"break;",
"}",
"break;",
"case 0x0c:\nif (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_fldenv(\ncpu_A0, tcg_const_i32(s->VAR_3));",
"break;",
"case 0x0d:\ngen_op_ld_T0_A0(OT_WORD + s->mem_index);",
"tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);",
"gen_helper_fldcw(cpu_tmp2_i32);",
"break;",
"case 0x0e:\nif (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_fstenv(cpu_A0, tcg_const_i32(s->VAR_3));",
"break;",
"case 0x0f:\ngen_helper_fnstcw(cpu_tmp2_i32);",
"tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);",
"gen_op_st_T0_A0(OT_WORD + s->mem_index);",
"break;",
"case 0x1d:\nif (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_fldt_ST0(cpu_A0);",
"break;",
"case 0x1f:\nif (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_fstt_ST0(cpu_A0);",
"gen_helper_fpop();",
"break;",
"case 0x2c:\nif (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_frstor(cpu_A0, tcg_const_i32(s->VAR_3));",
"break;",
"case 0x2e:\nif (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_fsave(cpu_A0, tcg_const_i32(s->VAR_3));",
"break;",
"case 0x2f:\ngen_helper_fnstsw(cpu_tmp2_i32);",
"tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);",
"gen_op_st_T0_A0(OT_WORD + s->mem_index);",
"break;",
"case 0x3c:\nif (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_fbld_ST0(cpu_A0);",
"break;",
"case 0x3e:\nif (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_fbst_ST0(cpu_A0);",
"gen_helper_fpop();",
"break;",
"case 0x3d:\ntcg_gen_qemu_ld64(cpu_tmp1_i64, cpu_A0,\n(s->mem_index >> 2) - 1);",
"gen_helper_fildll_ST0(cpu_tmp1_i64);",
"break;",
"case 0x3f:\ngen_helper_fistll_ST0(cpu_tmp1_i64);",
"tcg_gen_qemu_st64(cpu_tmp1_i64, cpu_A0,\n(s->mem_index >> 2) - 1);",
"gen_helper_fpop();",
"break;",
"default:\ngoto illegal_op;",
"}",
"} else {",
"VAR_12 = VAR_8;",
"switch(VAR_17) {",
"case 0x08:\ngen_helper_fpush();",
"gen_helper_fmov_ST0_STN(tcg_const_i32((VAR_12 + 1) & 7));",
"break;",
"case 0x09:\ncase 0x29:\ncase 0x39:\ngen_helper_fxchg_ST0_STN(tcg_const_i32(VAR_12));",
"break;",
"case 0x0a:\nswitch(VAR_8) {",
"case 0:\nif (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_fwait();",
"break;",
"default:\ngoto illegal_op;",
"}",
"break;",
"case 0x0c:\nswitch(VAR_8) {",
"case 0:\ngen_helper_fchs_ST0();",
"break;",
"case 1:\ngen_helper_fabs_ST0();",
"break;",
"case 4:\ngen_helper_fldz_FT0();",
"gen_helper_fcom_ST0_FT0();",
"break;",
"case 5:\ngen_helper_fxam_ST0();",
"break;",
"default:\ngoto illegal_op;",
"}",
"break;",
"case 0x0d:\n{",
"switch(VAR_8) {",
"case 0:\ngen_helper_fpush();",
"gen_helper_fld1_ST0();",
"break;",
"case 1:\ngen_helper_fpush();",
"gen_helper_fldl2t_ST0();",
"break;",
"case 2:\ngen_helper_fpush();",
"gen_helper_fldl2e_ST0();",
"break;",
"case 3:\ngen_helper_fpush();",
"gen_helper_fldpi_ST0();",
"break;",
"case 4:\ngen_helper_fpush();",
"gen_helper_fldlg2_ST0();",
"break;",
"case 5:\ngen_helper_fpush();",
"gen_helper_fldln2_ST0();",
"break;",
"case 6:\ngen_helper_fpush();",
"gen_helper_fldz_ST0();",
"break;",
"default:\ngoto illegal_op;",
"}",
"}",
"break;",
"case 0x0e:\nswitch(VAR_8) {",
"case 0:\ngen_helper_f2xm1();",
"break;",
"case 1:\ngen_helper_fyl2x();",
"break;",
"case 2:\ngen_helper_fptan();",
"break;",
"case 3:\ngen_helper_fpatan();",
"break;",
"case 4:\ngen_helper_fxtract();",
"break;",
"case 5:\ngen_helper_fprem1();",
"break;",
"case 6:\ngen_helper_fdecstp();",
"break;",
"default:\ncase 7:\ngen_helper_fincstp();",
"break;",
"}",
"break;",
"case 0x0f:\nswitch(VAR_8) {",
"case 0:\ngen_helper_fprem();",
"break;",
"case 1:\ngen_helper_fyl2xp1();",
"break;",
"case 2:\ngen_helper_fsqrt();",
"break;",
"case 3:\ngen_helper_fsincos();",
"break;",
"case 5:\ngen_helper_fscale();",
"break;",
"case 4:\ngen_helper_frndint();",
"break;",
"case 6:\ngen_helper_fsin();",
"break;",
"default:\ncase 7:\ngen_helper_fcos();",
"break;",
"}",
"break;",
"case 0x00: case 0x01: case 0x04 ... 0x07:\ncase 0x20: case 0x21: case 0x24 ... 0x27:\ncase 0x30: case 0x31: case 0x34 ... 0x37:\n{",
"int VAR_23;",
"VAR_23 = VAR_17 & 7;",
"if (VAR_17 >= 0x20) {",
"gen_helper_fp_arith_STN_ST0(VAR_23, VAR_12);",
"if (VAR_17 >= 0x30)\ngen_helper_fpop();",
"} else {",
"gen_helper_fmov_FT0_STN(tcg_const_i32(VAR_12));",
"gen_helper_fp_arith_ST0_FT0(VAR_23);",
"}",
"}",
"break;",
"case 0x02:\ncase 0x22:\ngen_helper_fmov_FT0_STN(tcg_const_i32(VAR_12));",
"gen_helper_fcom_ST0_FT0();",
"break;",
"case 0x03:\ncase 0x23:\ncase 0x32:\ngen_helper_fmov_FT0_STN(tcg_const_i32(VAR_12));",
"gen_helper_fcom_ST0_FT0();",
"gen_helper_fpop();",
"break;",
"case 0x15:\nswitch(VAR_8) {",
"case 1:\ngen_helper_fmov_FT0_STN(tcg_const_i32(1));",
"gen_helper_fucom_ST0_FT0();",
"gen_helper_fpop();",
"gen_helper_fpop();",
"break;",
"default:\ngoto illegal_op;",
"}",
"break;",
"case 0x1c:\nswitch(VAR_8) {",
"case 0:\nbreak;",
"case 1:\nbreak;",
"case 2:\ngen_helper_fclex();",
"break;",
"case 3:\ngen_helper_fninit();",
"break;",
"case 4:\nbreak;",
"default:\ngoto illegal_op;",
"}",
"break;",
"case 0x1d:\nif (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_helper_fmov_FT0_STN(tcg_const_i32(VAR_12));",
"gen_helper_fucomi_ST0_FT0();",
"s->cc_op = CC_OP_EFLAGS;",
"break;",
"case 0x1e:\nif (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_helper_fmov_FT0_STN(tcg_const_i32(VAR_12));",
"gen_helper_fcomi_ST0_FT0();",
"s->cc_op = CC_OP_EFLAGS;",
"break;",
"case 0x28:\ngen_helper_ffree_STN(tcg_const_i32(VAR_12));",
"break;",
"case 0x2a:\ngen_helper_fmov_STN_ST0(tcg_const_i32(VAR_12));",
"break;",
"case 0x2b:\ncase 0x0b:\ncase 0x3a:\ncase 0x3b:\ngen_helper_fmov_STN_ST0(tcg_const_i32(VAR_12));",
"gen_helper_fpop();",
"break;",
"case 0x2c:\ngen_helper_fmov_FT0_STN(tcg_const_i32(VAR_12));",
"gen_helper_fucom_ST0_FT0();",
"break;",
"case 0x2d:\ngen_helper_fmov_FT0_STN(tcg_const_i32(VAR_12));",
"gen_helper_fucom_ST0_FT0();",
"gen_helper_fpop();",
"break;",
"case 0x33:\nswitch(VAR_8) {",
"case 1:\ngen_helper_fmov_FT0_STN(tcg_const_i32(1));",
"gen_helper_fcom_ST0_FT0();",
"gen_helper_fpop();",
"gen_helper_fpop();",
"break;",
"default:\ngoto illegal_op;",
"}",
"break;",
"case 0x38:\ngen_helper_ffree_STN(tcg_const_i32(VAR_12));",
"gen_helper_fpop();",
"break;",
"case 0x3c:\nswitch(VAR_8) {",
"case 0:\ngen_helper_fnstsw(cpu_tmp2_i32);",
"tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);",
"gen_op_mov_reg_T0(OT_WORD, R_EAX);",
"break;",
"default:\ngoto illegal_op;",
"}",
"break;",
"case 0x3d:\nif (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_helper_fmov_FT0_STN(tcg_const_i32(VAR_12));",
"gen_helper_fucomi_ST0_FT0();",
"gen_helper_fpop();",
"s->cc_op = CC_OP_EFLAGS;",
"break;",
"case 0x3e:\nif (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_helper_fmov_FT0_STN(tcg_const_i32(VAR_12));",
"gen_helper_fcomi_ST0_FT0();",
"gen_helper_fpop();",
"s->cc_op = CC_OP_EFLAGS;",
"break;",
"case 0x10 ... 0x13:\ncase 0x18 ... 0x1b:\n{",
"int VAR_23, VAR_27;",
"static const uint8_t VAR_24[8] = {",
"(JCC_B << 1),\n(JCC_Z << 1),\n(JCC_BE << 1),\n(JCC_P << 1),\n};",
"VAR_23 = VAR_24[VAR_17 & 3] | (((VAR_17 >> 3) & 1) ^ 1);",
"VAR_27 = gen_new_label();",
"gen_jcc1(s, s->cc_op, VAR_23, VAR_27);",
"gen_helper_fmov_ST0_STN(tcg_const_i32(VAR_12));",
"gen_set_label(VAR_27);",
"}",
"break;",
"default:\ngoto illegal_op;",
"}",
"}",
"break;",
"case 0xa4:\ncase 0xa5:\nif ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 + OT_WORD;",
"if (VAR_1 & (PREFIX_REPZ | PREFIX_REPNZ)) {",
"gen_repz_movs(s, VAR_5, pc_start - s->cs_base, s->pc - s->cs_base);",
"} else {",
"gen_movs(s, VAR_5);",
"}",
"break;",
"case 0xaa:\ncase 0xab:\nif ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 + OT_WORD;",
"if (VAR_1 & (PREFIX_REPZ | PREFIX_REPNZ)) {",
"gen_repz_stos(s, VAR_5, pc_start - s->cs_base, s->pc - s->cs_base);",
"} else {",
"gen_stos(s, VAR_5);",
"}",
"break;",
"case 0xac:\ncase 0xad:\nif ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 + OT_WORD;",
"if (VAR_1 & (PREFIX_REPZ | PREFIX_REPNZ)) {",
"gen_repz_lods(s, VAR_5, pc_start - s->cs_base, s->pc - s->cs_base);",
"} else {",
"gen_lods(s, VAR_5);",
"}",
"break;",
"case 0xae:\ncase 0xaf:\nif ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 + OT_WORD;",
"if (VAR_1 & PREFIX_REPNZ) {",
"gen_repz_scas(s, VAR_5, pc_start - s->cs_base, s->pc - s->cs_base, 1);",
"} else if (VAR_1 & PREFIX_REPZ) {",
"gen_repz_scas(s, VAR_5, pc_start - s->cs_base, s->pc - s->cs_base, 0);",
"} else {",
"gen_scas(s, VAR_5);",
"s->cc_op = CC_OP_SUBB + VAR_5;",
"}",
"break;",
"case 0xa6:\ncase 0xa7:\nif ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 + OT_WORD;",
"if (VAR_1 & PREFIX_REPNZ) {",
"gen_repz_cmps(s, VAR_5, pc_start - s->cs_base, s->pc - s->cs_base, 1);",
"} else if (VAR_1 & PREFIX_REPZ) {",
"gen_repz_cmps(s, VAR_5, pc_start - s->cs_base, s->pc - s->cs_base, 0);",
"} else {",
"gen_cmps(s, VAR_5);",
"s->cc_op = CC_OP_SUBB + VAR_5;",
"}",
"break;",
"case 0x6c:\ncase 0x6d:\nif ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 ? OT_LONG : OT_WORD;",
"gen_op_mov_TN_reg(OT_WORD, 0, R_EDX);",
"gen_op_andl_T0_ffff();",
"gen_check_io(s, VAR_5, pc_start - s->cs_base,\nSVM_IOIO_TYPE_MASK | svm_is_rep(VAR_1) | 4);",
"if (VAR_1 & (PREFIX_REPZ | PREFIX_REPNZ)) {",
"gen_repz_ins(s, VAR_5, pc_start - s->cs_base, s->pc - s->cs_base);",
"} else {",
"gen_ins(s, VAR_5);",
"if (use_icount) {",
"gen_jmp(s, s->pc - s->cs_base);",
"}",
"}",
"break;",
"case 0x6e:\ncase 0x6f:\nif ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 ? OT_LONG : OT_WORD;",
"gen_op_mov_TN_reg(OT_WORD, 0, R_EDX);",
"gen_op_andl_T0_ffff();",
"gen_check_io(s, VAR_5, pc_start - s->cs_base,\nsvm_is_rep(VAR_1) | 4);",
"if (VAR_1 & (PREFIX_REPZ | PREFIX_REPNZ)) {",
"gen_repz_outs(s, VAR_5, pc_start - s->cs_base, s->pc - s->cs_base);",
"} else {",
"gen_outs(s, VAR_5);",
"if (use_icount) {",
"gen_jmp(s, s->pc - s->cs_base);",
"}",
"}",
"break;",
"case 0xe4:\ncase 0xe5:\nif ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 ? OT_LONG : OT_WORD;",
"VAR_18 = ldub_code(s->pc++);",
"gen_op_movl_T0_im(VAR_18);",
"gen_check_io(s, VAR_5, pc_start - s->cs_base,\nSVM_IOIO_TYPE_MASK | svm_is_rep(VAR_1));",
"if (use_icount)\ngen_io_start();",
"tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);",
"gen_helper_in_func(VAR_5, cpu_T[1], cpu_tmp2_i32);",
"gen_op_mov_reg_T1(VAR_5, R_EAX);",
"if (use_icount) {",
"gen_io_end();",
"gen_jmp(s, s->pc - s->cs_base);",
"}",
"break;",
"case 0xe6:\ncase 0xe7:\nif ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 ? OT_LONG : OT_WORD;",
"VAR_18 = ldub_code(s->pc++);",
"gen_op_movl_T0_im(VAR_18);",
"gen_check_io(s, VAR_5, pc_start - s->cs_base,\nsvm_is_rep(VAR_1));",
"gen_op_mov_TN_reg(VAR_5, 1, R_EAX);",
"if (use_icount)\ngen_io_start();",
"tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);",
"tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff);",
"tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T[1]);",
"gen_helper_out_func(VAR_5, cpu_tmp2_i32, cpu_tmp3_i32);",
"if (use_icount) {",
"gen_io_end();",
"gen_jmp(s, s->pc - s->cs_base);",
"}",
"break;",
"case 0xec:\ncase 0xed:\nif ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 ? OT_LONG : OT_WORD;",
"gen_op_mov_TN_reg(OT_WORD, 0, R_EDX);",
"gen_op_andl_T0_ffff();",
"gen_check_io(s, VAR_5, pc_start - s->cs_base,\nSVM_IOIO_TYPE_MASK | svm_is_rep(VAR_1));",
"if (use_icount)\ngen_io_start();",
"tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);",
"gen_helper_in_func(VAR_5, cpu_T[1], cpu_tmp2_i32);",
"gen_op_mov_reg_T1(VAR_5, R_EAX);",
"if (use_icount) {",
"gen_io_end();",
"gen_jmp(s, s->pc - s->cs_base);",
"}",
"break;",
"case 0xee:\ncase 0xef:\nif ((VAR_0 & 1) == 0)\nVAR_5 = OT_BYTE;",
"else\nVAR_5 = VAR_3 ? OT_LONG : OT_WORD;",
"gen_op_mov_TN_reg(OT_WORD, 0, R_EDX);",
"gen_op_andl_T0_ffff();",
"gen_check_io(s, VAR_5, pc_start - s->cs_base,\nsvm_is_rep(VAR_1));",
"gen_op_mov_TN_reg(VAR_5, 1, R_EAX);",
"if (use_icount)\ngen_io_start();",
"tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);",
"tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff);",
"tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T[1]);",
"gen_helper_out_func(VAR_5, cpu_tmp2_i32, cpu_tmp3_i32);",
"if (use_icount) {",
"gen_io_end();",
"gen_jmp(s, s->pc - s->cs_base);",
"}",
"break;",
"case 0xc2:\nVAR_18 = ldsw_code(s->pc);",
"s->pc += 2;",
"gen_pop_T0(s);",
"if (CODE64(s) && s->VAR_3)\ns->VAR_3 = 2;",
"gen_stack_update(s, VAR_18 + (2 << s->VAR_3));",
"if (s->VAR_3 == 0)\ngen_op_andl_T0_ffff();",
"gen_op_jmp_T0();",
"gen_eob(s);",
"break;",
"case 0xc3:\ngen_pop_T0(s);",
"gen_pop_update(s);",
"if (s->VAR_3 == 0)\ngen_op_andl_T0_ffff();",
"gen_op_jmp_T0();",
"gen_eob(s);",
"break;",
"case 0xca:\nVAR_18 = ldsw_code(s->pc);",
"s->pc += 2;",
"do_lret:\nif (s->pe && !s->vm86) {",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_lret_protected(tcg_const_i32(s->VAR_3),\ntcg_const_i32(VAR_18));",
"} else {",
"gen_stack_A0(s);",
"gen_op_ld_T0_A0(1 + s->VAR_3 + s->mem_index);",
"if (s->VAR_3 == 0)\ngen_op_andl_T0_ffff();",
"gen_op_jmp_T0();",
"gen_op_addl_A0_im(2 << s->VAR_3);",
"gen_op_ld_T0_A0(1 + s->VAR_3 + s->mem_index);",
"gen_op_movl_seg_T0_vm(R_CS);",
"gen_stack_update(s, VAR_18 + (4 << s->VAR_3));",
"}",
"gen_eob(s);",
"break;",
"case 0xcb:\nVAR_18 = 0;",
"goto do_lret;",
"case 0xcf:\ngen_svm_check_intercept(s, pc_start, SVM_EXIT_IRET);",
"if (!s->pe) {",
"gen_helper_iret_real(tcg_const_i32(s->VAR_3));",
"s->cc_op = CC_OP_EFLAGS;",
"} else if (s->vm86) {",
"if (s->iopl != 3) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"} else {",
"gen_helper_iret_real(tcg_const_i32(s->VAR_3));",
"s->cc_op = CC_OP_EFLAGS;",
"}",
"} else {",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_iret_protected(tcg_const_i32(s->VAR_3),\ntcg_const_i32(s->pc - s->cs_base));",
"s->cc_op = CC_OP_EFLAGS;",
"}",
"gen_eob(s);",
"break;",
"case 0xe8:\n{",
"if (VAR_3)\ntval = (int32_t)insn_get(s, OT_LONG);",
"else\ntval = (int16_t)insn_get(s, OT_WORD);",
"next_eip = s->pc - s->cs_base;",
"tval += next_eip;",
"if (s->VAR_3 == 0)\ntval &= 0xffff;",
"gen_movtl_T0_im(next_eip);",
"gen_push_T0(s);",
"gen_jmp(s, tval);",
"}",
"break;",
"case 0x9a:\n{",
"unsigned int VAR_27, VAR_27;",
"if (CODE64(s))\ngoto illegal_op;",
"VAR_5 = VAR_3 ? OT_LONG : OT_WORD;",
"VAR_27 = insn_get(s, VAR_5);",
"VAR_27 = insn_get(s, OT_WORD);",
"gen_op_movl_T0_im(VAR_27);",
"gen_op_movl_T1_imu(VAR_27);",
"}",
"goto do_lcall;",
"case 0xe9:\nif (VAR_3)\ntval = (int32_t)insn_get(s, OT_LONG);",
"else\ntval = (int16_t)insn_get(s, OT_WORD);",
"tval += s->pc - s->cs_base;",
"if (s->VAR_3 == 0)\ntval &= 0xffff;",
"gen_jmp(s, tval);",
"break;",
"case 0xea:\n{",
"unsigned int VAR_27, VAR_27;",
"if (CODE64(s))\ngoto illegal_op;",
"VAR_5 = VAR_3 ? OT_LONG : OT_WORD;",
"VAR_27 = insn_get(s, VAR_5);",
"VAR_27 = insn_get(s, OT_WORD);",
"gen_op_movl_T0_im(VAR_27);",
"gen_op_movl_T1_imu(VAR_27);",
"}",
"goto do_ljmp;",
"case 0xeb:\ntval = (int8_t)insn_get(s, OT_BYTE);",
"tval += s->pc - s->cs_base;",
"if (s->VAR_3 == 0)\ntval &= 0xffff;",
"gen_jmp(s, tval);",
"break;",
"case 0x70 ... 0x7f:\ntval = (int8_t)insn_get(s, OT_BYTE);",
"goto do_jcc;",
"case 0x180 ... 0x18f:\nif (VAR_3) {",
"tval = (int32_t)insn_get(s, OT_LONG);",
"} else {",
"tval = (int16_t)insn_get(s, OT_WORD);",
"}",
"do_jcc:\nnext_eip = s->pc - s->cs_base;",
"tval += next_eip;",
"if (s->VAR_3 == 0)\ntval &= 0xffff;",
"gen_jcc(s, VAR_0, tval, next_eip);",
"break;",
"case 0x190 ... 0x19f:\nVAR_6 = ldub_code(s->pc++);",
"gen_setcc(s, VAR_0);",
"gen_ldst_modrm(s, VAR_6, OT_BYTE, OR_TMP0, 1);",
"break;",
"case 0x140 ... 0x14f:\n{",
"int VAR_27;",
"TCGv t0;",
"VAR_5 = VAR_3 + OT_WORD;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;",
"VAR_9 = (VAR_6 >> 6) & 3;",
"t0 = tcg_temp_local_new();",
"if (VAR_9 != 3) {",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"gen_op_ld_v(VAR_5 + s->mem_index, t0, cpu_A0);",
"} else {",
"VAR_8 = (VAR_6 & 7) | REX_B(s);",
"gen_op_mov_v_reg(VAR_5, t0, VAR_8);",
"}",
"#ifdef TARGET_X86_64\nif (VAR_5 == OT_LONG) {",
"VAR_27 = gen_new_label();",
"gen_jcc1(s, s->cc_op, VAR_0 ^ 1, VAR_27);",
"tcg_gen_st32_tl(t0, cpu_env, offsetof(CPUState, regs[VAR_7]) + REG_L_OFFSET);",
"gen_set_label(VAR_27);",
"tcg_gen_movi_tl(cpu_tmp0, 0);",
"tcg_gen_st32_tl(cpu_tmp0, cpu_env, offsetof(CPUState, regs[VAR_7]) + REG_LH_OFFSET);",
"} else",
"#endif\n{",
"VAR_27 = gen_new_label();",
"gen_jcc1(s, s->cc_op, VAR_0 ^ 1, VAR_27);",
"gen_op_mov_reg_v(VAR_5, VAR_7, t0);",
"gen_set_label(VAR_27);",
"}",
"tcg_temp_free(t0);",
"}",
"break;",
"case 0x9c:\ngen_svm_check_intercept(s, pc_start, SVM_EXIT_PUSHF);",
"if (s->vm86 && s->iopl != 3) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"} else {",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_helper_read_eflags(cpu_T[0]);",
"gen_push_T0(s);",
"}",
"break;",
"case 0x9d:\ngen_svm_check_intercept(s, pc_start, SVM_EXIT_POPF);",
"if (s->vm86 && s->iopl != 3) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"} else {",
"gen_pop_T0(s);",
"if (s->cpl == 0) {",
"if (s->VAR_3) {",
"gen_helper_write_eflags(cpu_T[0],\ntcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK | IOPL_MASK)));",
"} else {",
"gen_helper_write_eflags(cpu_T[0],\ntcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK | IOPL_MASK) & 0xffff));",
"}",
"} else {",
"if (s->cpl <= s->iopl) {",
"if (s->VAR_3) {",
"gen_helper_write_eflags(cpu_T[0],\ntcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK)));",
"} else {",
"gen_helper_write_eflags(cpu_T[0],\ntcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK) & 0xffff));",
"}",
"} else {",
"if (s->VAR_3) {",
"gen_helper_write_eflags(cpu_T[0],\ntcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK)));",
"} else {",
"gen_helper_write_eflags(cpu_T[0],\ntcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK) & 0xffff));",
"}",
"}",
"}",
"gen_pop_update(s);",
"s->cc_op = CC_OP_EFLAGS;",
"gen_jmp_im(s->pc - s->cs_base);",
"gen_eob(s);",
"}",
"break;",
"case 0x9e:\nif (CODE64(s) && !(s->cpuid_ext3_features & CPUID_EXT3_LAHF_LM))\ngoto illegal_op;",
"gen_op_mov_TN_reg(OT_BYTE, 0, R_AH);",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_compute_eflags(cpu_cc_src);",
"tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, CC_O);",
"tcg_gen_andi_tl(cpu_T[0], cpu_T[0], CC_S | CC_Z | CC_A | CC_P | CC_C);",
"tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, cpu_T[0]);",
"s->cc_op = CC_OP_EFLAGS;",
"break;",
"case 0x9f:\nif (CODE64(s) && !(s->cpuid_ext3_features & CPUID_EXT3_LAHF_LM))\ngoto illegal_op;",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_compute_eflags(cpu_T[0]);",
"tcg_gen_ori_tl(cpu_T[0], cpu_T[0], 0x02);",
"gen_op_mov_reg_T0(OT_BYTE, R_AH);",
"break;",
"case 0xf5:\nif (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_compute_eflags(cpu_cc_src);",
"tcg_gen_xori_tl(cpu_cc_src, cpu_cc_src, CC_C);",
"s->cc_op = CC_OP_EFLAGS;",
"break;",
"case 0xf8:\nif (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_compute_eflags(cpu_cc_src);",
"tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, ~CC_C);",
"s->cc_op = CC_OP_EFLAGS;",
"break;",
"case 0xf9:\nif (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_compute_eflags(cpu_cc_src);",
"tcg_gen_ori_tl(cpu_cc_src, cpu_cc_src, CC_C);",
"s->cc_op = CC_OP_EFLAGS;",
"break;",
"case 0xfc:\ntcg_gen_movi_i32(cpu_tmp2_i32, 1);",
"tcg_gen_st_i32(cpu_tmp2_i32, cpu_env, offsetof(CPUState, df));",
"break;",
"case 0xfd:\ntcg_gen_movi_i32(cpu_tmp2_i32, -1);",
"tcg_gen_st_i32(cpu_tmp2_i32, cpu_env, offsetof(CPUState, df));",
"break;",
"case 0x1ba:\nVAR_5 = VAR_3 + OT_WORD;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_17 = (VAR_6 >> 3) & 7;",
"VAR_9 = (VAR_6 >> 6) & 3;",
"VAR_8 = (VAR_6 & 7) | REX_B(s);",
"if (VAR_9 != 3) {",
"s->rip_offset = 1;",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"gen_op_ld_T0_A0(VAR_5 + s->mem_index);",
"} else {",
"gen_op_mov_TN_reg(VAR_5, 0, VAR_8);",
"}",
"VAR_18 = ldub_code(s->pc++);",
"gen_op_movl_T1_im(VAR_18);",
"if (VAR_17 < 4)\ngoto illegal_op;",
"VAR_17 -= 4;",
"goto bt_op;",
"case 0x1a3:\nVAR_17 = 0;",
"goto do_btx;",
"case 0x1ab:\nVAR_17 = 1;",
"goto do_btx;",
"case 0x1b3:\nVAR_17 = 2;",
"goto do_btx;",
"case 0x1bb:\nVAR_17 = 3;",
"do_btx:\nVAR_5 = VAR_3 + OT_WORD;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;",
"VAR_9 = (VAR_6 >> 6) & 3;",
"VAR_8 = (VAR_6 & 7) | REX_B(s);",
"gen_op_mov_TN_reg(OT_LONG, 1, VAR_7);",
"if (VAR_9 != 3) {",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"gen_exts(VAR_5, cpu_T[1]);",
"tcg_gen_sari_tl(cpu_tmp0, cpu_T[1], 3 + VAR_5);",
"tcg_gen_shli_tl(cpu_tmp0, cpu_tmp0, VAR_5);",
"tcg_gen_add_tl(cpu_A0, cpu_A0, cpu_tmp0);",
"gen_op_ld_T0_A0(VAR_5 + s->mem_index);",
"} else {",
"gen_op_mov_TN_reg(VAR_5, 0, VAR_8);",
"}",
"bt_op:\ntcg_gen_andi_tl(cpu_T[1], cpu_T[1], (1 << (3 + VAR_5)) - 1);",
"switch(VAR_17) {",
"case 0:\ntcg_gen_shr_tl(cpu_cc_src, cpu_T[0], cpu_T[1]);",
"tcg_gen_movi_tl(cpu_cc_dst, 0);",
"break;",
"case 1:\ntcg_gen_shr_tl(cpu_tmp4, cpu_T[0], cpu_T[1]);",
"tcg_gen_movi_tl(cpu_tmp0, 1);",
"tcg_gen_shl_tl(cpu_tmp0, cpu_tmp0, cpu_T[1]);",
"tcg_gen_or_tl(cpu_T[0], cpu_T[0], cpu_tmp0);",
"break;",
"case 2:\ntcg_gen_shr_tl(cpu_tmp4, cpu_T[0], cpu_T[1]);",
"tcg_gen_movi_tl(cpu_tmp0, 1);",
"tcg_gen_shl_tl(cpu_tmp0, cpu_tmp0, cpu_T[1]);",
"tcg_gen_not_tl(cpu_tmp0, cpu_tmp0);",
"tcg_gen_and_tl(cpu_T[0], cpu_T[0], cpu_tmp0);",
"break;",
"default:\ncase 3:\ntcg_gen_shr_tl(cpu_tmp4, cpu_T[0], cpu_T[1]);",
"tcg_gen_movi_tl(cpu_tmp0, 1);",
"tcg_gen_shl_tl(cpu_tmp0, cpu_tmp0, cpu_T[1]);",
"tcg_gen_xor_tl(cpu_T[0], cpu_T[0], cpu_tmp0);",
"break;",
"}",
"s->cc_op = CC_OP_SARB + VAR_5;",
"if (VAR_17 != 0) {",
"if (VAR_9 != 3)\ngen_op_st_T0_A0(VAR_5 + s->mem_index);",
"else\ngen_op_mov_reg_T0(VAR_5, VAR_8);",
"tcg_gen_mov_tl(cpu_cc_src, cpu_tmp4);",
"tcg_gen_movi_tl(cpu_cc_dst, 0);",
"}",
"break;",
"case 0x1bc:\ncase 0x1bd:\n{",
"int VAR_29;",
"TCGv t0;",
"VAR_5 = VAR_3 + OT_WORD;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;",
"gen_ldst_modrm(s, VAR_6, VAR_5, OR_TMP0, 0);",
"gen_extu(VAR_5, cpu_T[0]);",
"VAR_29 = gen_new_label();",
"tcg_gen_movi_tl(cpu_cc_dst, 0);",
"t0 = tcg_temp_local_new();",
"tcg_gen_mov_tl(t0, cpu_T[0]);",
"tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, VAR_29);",
"if (VAR_0 & 1) {",
"gen_helper_bsr(cpu_T[0], t0);",
"} else {",
"gen_helper_bsf(cpu_T[0], t0);",
"}",
"gen_op_mov_reg_T0(VAR_5, VAR_7);",
"tcg_gen_movi_tl(cpu_cc_dst, 1);",
"gen_set_label(VAR_29);",
"tcg_gen_discard_tl(cpu_cc_src);",
"s->cc_op = CC_OP_LOGICB + VAR_5;",
"tcg_temp_free(t0);",
"}",
"break;",
"case 0x27:\nif (CODE64(s))\ngoto illegal_op;",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_helper_daa();",
"s->cc_op = CC_OP_EFLAGS;",
"break;",
"case 0x2f:\nif (CODE64(s))\ngoto illegal_op;",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_helper_das();",
"s->cc_op = CC_OP_EFLAGS;",
"break;",
"case 0x37:\nif (CODE64(s))\ngoto illegal_op;",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_helper_aaa();",
"s->cc_op = CC_OP_EFLAGS;",
"break;",
"case 0x3f:\nif (CODE64(s))\ngoto illegal_op;",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_helper_aas();",
"s->cc_op = CC_OP_EFLAGS;",
"break;",
"case 0xd4:\nif (CODE64(s))\ngoto illegal_op;",
"VAR_18 = ldub_code(s->pc++);",
"if (VAR_18 == 0) {",
"gen_exception(s, EXCP00_DIVZ, pc_start - s->cs_base);",
"} else {",
"gen_helper_aam(tcg_const_i32(VAR_18));",
"s->cc_op = CC_OP_LOGICB;",
"}",
"break;",
"case 0xd5:\nif (CODE64(s))\ngoto illegal_op;",
"VAR_18 = ldub_code(s->pc++);",
"gen_helper_aad(tcg_const_i32(VAR_18));",
"s->cc_op = CC_OP_LOGICB;",
"break;",
"case 0x90:\nif (VAR_1 & PREFIX_LOCK)\ngoto illegal_op;",
"if (VAR_1 & PREFIX_REPZ) {",
"gen_svm_check_intercept(s, pc_start, SVM_EXIT_PAUSE);",
"}",
"break;",
"case 0x9b:\nif ((s->flags & (HF_MP_MASK | HF_TS_MASK)) ==\n(HF_MP_MASK | HF_TS_MASK)) {",
"gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);",
"} else {",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_fwait();",
"}",
"break;",
"case 0xcc:\ngen_interrupt(s, EXCP03_INT3, pc_start - s->cs_base, s->pc - s->cs_base);",
"break;",
"case 0xcd:\nVAR_18 = ldub_code(s->pc++);",
"if (s->vm86 && s->iopl != 3) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"} else {",
"gen_interrupt(s, VAR_18, pc_start - s->cs_base, s->pc - s->cs_base);",
"}",
"break;",
"case 0xce:\nif (CODE64(s))\ngoto illegal_op;",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_into(tcg_const_i32(s->pc - pc_start));",
"break;",
"#ifdef WANT_ICEBP\ncase 0xf1:\ngen_svm_check_intercept(s, pc_start, SVM_EXIT_ICEBP);",
"#if 1\ngen_debug(s, pc_start - s->cs_base);",
"#else\ntb_flush(cpu_single_env);",
"cpu_set_log(CPU_LOG_INT | CPU_LOG_TB_IN_ASM);",
"#endif\nbreak;",
"#endif\ncase 0xfa:\nif (!s->vm86) {",
"if (s->cpl <= s->iopl) {",
"gen_helper_cli();",
"} else {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"}",
"} else {",
"if (s->iopl == 3) {",
"gen_helper_cli();",
"} else {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"}",
"}",
"break;",
"case 0xfb:\nif (!s->vm86) {",
"if (s->cpl <= s->iopl) {",
"gen_sti:\ngen_helper_sti();",
"if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK))\ngen_helper_set_inhibit_irq();",
"gen_jmp_im(s->pc - s->cs_base);",
"gen_eob(s);",
"} else {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"}",
"} else {",
"if (s->iopl == 3) {",
"goto gen_sti;",
"} else {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"}",
"}",
"break;",
"case 0x62:\nif (CODE64(s))\ngoto illegal_op;",
"VAR_5 = VAR_3 ? OT_LONG : OT_WORD;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_7 = (VAR_6 >> 3) & 7;",
"VAR_9 = (VAR_6 >> 6) & 3;",
"if (VAR_9 == 3)\ngoto illegal_op;",
"gen_op_mov_TN_reg(VAR_5, 0, VAR_7);",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"gen_jmp_im(pc_start - s->cs_base);",
"tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);",
"if (VAR_5 == OT_WORD)\ngen_helper_boundw(cpu_A0, cpu_tmp2_i32);",
"else\ngen_helper_boundl(cpu_A0, cpu_tmp2_i32);",
"break;",
"case 0x1c8 ... 0x1cf:\nVAR_7 = (VAR_0 & 7) | REX_B(s);",
"#ifdef TARGET_X86_64\nif (VAR_3 == 2) {",
"gen_op_mov_TN_reg(OT_QUAD, 0, VAR_7);",
"tcg_gen_bswap_i64(cpu_T[0], cpu_T[0]);",
"gen_op_mov_reg_T0(OT_QUAD, VAR_7);",
"} else",
"{",
"TCGv_i32 tmp0;",
"gen_op_mov_TN_reg(OT_LONG, 0, VAR_7);",
"tmp0 = tcg_temp_new_i32();",
"tcg_gen_trunc_i64_i32(tmp0, cpu_T[0]);",
"tcg_gen_bswap_i32(tmp0, tmp0);",
"tcg_gen_extu_i32_i64(cpu_T[0], tmp0);",
"gen_op_mov_reg_T0(OT_LONG, VAR_7);",
"}",
"#else\n{",
"gen_op_mov_TN_reg(OT_LONG, 0, VAR_7);",
"tcg_gen_bswap_i32(cpu_T[0], cpu_T[0]);",
"gen_op_mov_reg_T0(OT_LONG, VAR_7);",
"}",
"#endif\nbreak;",
"case 0xd6:\nif (CODE64(s))\ngoto illegal_op;",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_compute_eflags_c(cpu_T[0]);",
"tcg_gen_neg_tl(cpu_T[0], cpu_T[0]);",
"gen_op_mov_reg_T0(OT_BYTE, R_EAX);",
"break;",
"case 0xe0:\ncase 0xe1:\ncase 0xe2:\ncase 0xe3:\n{",
"int VAR_27, VAR_27, VAR_28;",
"tval = (int8_t)insn_get(s, OT_BYTE);",
"next_eip = s->pc - s->cs_base;",
"tval += next_eip;",
"if (s->VAR_3 == 0)\ntval &= 0xffff;",
"VAR_27 = gen_new_label();",
"VAR_27 = gen_new_label();",
"VAR_28 = gen_new_label();",
"VAR_0 &= 3;",
"switch(VAR_0) {",
"case 0:\ncase 1:\nif (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_op_add_reg_im(s->VAR_2, R_ECX, -1);",
"gen_op_jz_ecx(s->VAR_2, VAR_28);",
"gen_compute_eflags(cpu_tmp0);",
"tcg_gen_andi_tl(cpu_tmp0, cpu_tmp0, CC_Z);",
"if (VAR_0 == 0) {",
"tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_tmp0, 0, VAR_27);",
"} else {",
"tcg_gen_brcondi_tl(TCG_COND_NE, cpu_tmp0, 0, VAR_27);",
"}",
"break;",
"case 2:\ngen_op_add_reg_im(s->VAR_2, R_ECX, -1);",
"gen_op_jnz_ecx(s->VAR_2, VAR_27);",
"break;",
"default:\ncase 3:\ngen_op_jz_ecx(s->VAR_2, VAR_27);",
"break;",
"}",
"gen_set_label(VAR_28);",
"gen_jmp_im(next_eip);",
"tcg_gen_br(VAR_27);",
"gen_set_label(VAR_27);",
"gen_jmp_im(tval);",
"gen_set_label(VAR_27);",
"gen_eob(s);",
"}",
"break;",
"case 0x130:\ncase 0x132:\nif (s->cpl != 0) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"} else {",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"if (VAR_0 & 2) {",
"gen_helper_rdmsr();",
"} else {",
"gen_helper_wrmsr();",
"}",
"}",
"break;",
"case 0x131:\nif (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"if (use_icount)\ngen_io_start();",
"gen_helper_rdtsc();",
"if (use_icount) {",
"gen_io_end();",
"gen_jmp(s, s->pc - s->cs_base);",
"}",
"break;",
"case 0x133:\nif (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_rdpmc();",
"break;",
"case 0x134:\nif (CODE64(s) && cpu_single_env->cpuid_vendor1 != CPUID_VENDOR_INTEL_1)\ngoto illegal_op;",
"if (!s->pe) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"} else {",
"if (s->cc_op != CC_OP_DYNAMIC) {",
"gen_op_set_cc_op(s->cc_op);",
"s->cc_op = CC_OP_DYNAMIC;",
"}",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_sysenter();",
"gen_eob(s);",
"}",
"break;",
"case 0x135:\nif (CODE64(s) && cpu_single_env->cpuid_vendor1 != CPUID_VENDOR_INTEL_1)\ngoto illegal_op;",
"if (!s->pe) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"} else {",
"if (s->cc_op != CC_OP_DYNAMIC) {",
"gen_op_set_cc_op(s->cc_op);",
"s->cc_op = CC_OP_DYNAMIC;",
"}",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_sysexit(tcg_const_i32(VAR_3));",
"gen_eob(s);",
"}",
"break;",
"#ifdef TARGET_X86_64\ncase 0x105:\nif (s->cc_op != CC_OP_DYNAMIC) {",
"gen_op_set_cc_op(s->cc_op);",
"s->cc_op = CC_OP_DYNAMIC;",
"}",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_syscall(tcg_const_i32(s->pc - pc_start));",
"gen_eob(s);",
"break;",
"case 0x107:\nif (!s->pe) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"} else {",
"if (s->cc_op != CC_OP_DYNAMIC) {",
"gen_op_set_cc_op(s->cc_op);",
"s->cc_op = CC_OP_DYNAMIC;",
"}",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_sysret(tcg_const_i32(s->VAR_3));",
"if (s->lma)\ns->cc_op = CC_OP_EFLAGS;",
"gen_eob(s);",
"}",
"break;",
"#endif\ncase 0x1a2:\nif (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_cpuid();",
"break;",
"case 0xf4:\nif (s->cpl != 0) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"} else {",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_hlt(tcg_const_i32(s->pc - pc_start));",
"s->is_jmp = 3;",
"}",
"break;",
"case 0x100:\nVAR_6 = ldub_code(s->pc++);",
"VAR_9 = (VAR_6 >> 6) & 3;",
"VAR_17 = (VAR_6 >> 3) & 7;",
"switch(VAR_17) {",
"case 0:\nif (!s->pe || s->vm86)\ngoto illegal_op;",
"gen_svm_check_intercept(s, pc_start, SVM_EXIT_LDTR_READ);",
"tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,ldt.VAR_27));",
"VAR_5 = OT_WORD;",
"if (VAR_9 == 3)\nVAR_5 += s->VAR_3;",
"gen_ldst_modrm(s, VAR_6, VAR_5, OR_TMP0, 1);",
"break;",
"case 2:\nif (!s->pe || s->vm86)\ngoto illegal_op;",
"if (s->cpl != 0) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"} else {",
"gen_svm_check_intercept(s, pc_start, SVM_EXIT_LDTR_WRITE);",
"gen_ldst_modrm(s, VAR_6, OT_WORD, OR_TMP0, 0);",
"gen_jmp_im(pc_start - s->cs_base);",
"tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);",
"gen_helper_lldt(cpu_tmp2_i32);",
"}",
"break;",
"case 1:\nif (!s->pe || s->vm86)\ngoto illegal_op;",
"gen_svm_check_intercept(s, pc_start, SVM_EXIT_TR_READ);",
"tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,tr.VAR_27));",
"VAR_5 = OT_WORD;",
"if (VAR_9 == 3)\nVAR_5 += s->VAR_3;",
"gen_ldst_modrm(s, VAR_6, VAR_5, OR_TMP0, 1);",
"break;",
"case 3:\nif (!s->pe || s->vm86)\ngoto illegal_op;",
"if (s->cpl != 0) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"} else {",
"gen_svm_check_intercept(s, pc_start, SVM_EXIT_TR_WRITE);",
"gen_ldst_modrm(s, VAR_6, OT_WORD, OR_TMP0, 0);",
"gen_jmp_im(pc_start - s->cs_base);",
"tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);",
"gen_helper_ltr(cpu_tmp2_i32);",
"}",
"break;",
"case 4:\ncase 5:\nif (!s->pe || s->vm86)\ngoto illegal_op;",
"gen_ldst_modrm(s, VAR_6, OT_WORD, OR_TMP0, 0);",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"if (VAR_17 == 4)\ngen_helper_verr(cpu_T[0]);",
"else\ngen_helper_verw(cpu_T[0]);",
"s->cc_op = CC_OP_EFLAGS;",
"break;",
"default:\ngoto illegal_op;",
"}",
"break;",
"case 0x101:\nVAR_6 = ldub_code(s->pc++);",
"VAR_9 = (VAR_6 >> 6) & 3;",
"VAR_17 = (VAR_6 >> 3) & 7;",
"VAR_8 = VAR_6 & 7;",
"switch(VAR_17) {",
"case 0:\nif (VAR_9 == 3)\ngoto illegal_op;",
"gen_svm_check_intercept(s, pc_start, SVM_EXIT_GDTR_READ);",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, gdt.limit));",
"gen_op_st_T0_A0(OT_WORD + s->mem_index);",
"gen_add_A0_im(s, 2);",
"tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, gdt.base));",
"if (!s->VAR_3)\ngen_op_andl_T0_im(0xffffff);",
"gen_op_st_T0_A0(CODE64(s) + OT_LONG + s->mem_index);",
"break;",
"case 1:\nif (VAR_9 == 3) {",
"switch (VAR_8) {",
"case 0:\nif (!(s->cpuid_ext_features & CPUID_EXT_MONITOR) ||\ns->cpl != 0)\ngoto illegal_op;",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"#ifdef TARGET_X86_64\nif (s->VAR_2 == 2) {",
"gen_op_movq_A0_reg(R_EAX);",
"} else",
"#endif\n{",
"gen_op_movl_A0_reg(R_EAX);",
"if (s->VAR_2 == 0)\ngen_op_andl_A0_ffff();",
"}",
"gen_add_A0_ds_seg(s);",
"gen_helper_monitor(cpu_A0);",
"break;",
"case 1:\nif (!(s->cpuid_ext_features & CPUID_EXT_MONITOR) ||\ns->cpl != 0)\ngoto illegal_op;",
"if (s->cc_op != CC_OP_DYNAMIC) {",
"gen_op_set_cc_op(s->cc_op);",
"s->cc_op = CC_OP_DYNAMIC;",
"}",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_mwait(tcg_const_i32(s->pc - pc_start));",
"gen_eob(s);",
"break;",
"default:\ngoto illegal_op;",
"}",
"} else {",
"gen_svm_check_intercept(s, pc_start, SVM_EXIT_IDTR_READ);",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, idt.limit));",
"gen_op_st_T0_A0(OT_WORD + s->mem_index);",
"gen_add_A0_im(s, 2);",
"tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, idt.base));",
"if (!s->VAR_3)\ngen_op_andl_T0_im(0xffffff);",
"gen_op_st_T0_A0(CODE64(s) + OT_LONG + s->mem_index);",
"}",
"break;",
"case 2:\ncase 3:\nif (VAR_9 == 3) {",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"switch(VAR_8) {",
"case 0:\nif (!(s->flags & HF_SVME_MASK) || !s->pe)\ngoto illegal_op;",
"if (s->cpl != 0) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"break;",
"} else {",
"gen_helper_vmrun(tcg_const_i32(s->VAR_2),\ntcg_const_i32(s->pc - pc_start));",
"tcg_gen_exit_tb(0);",
"s->is_jmp = 3;",
"}",
"break;",
"case 1:\nif (!(s->flags & HF_SVME_MASK))\ngoto illegal_op;",
"gen_helper_vmmcall();",
"break;",
"case 2:\nif (!(s->flags & HF_SVME_MASK) || !s->pe)\ngoto illegal_op;",
"if (s->cpl != 0) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"break;",
"} else {",
"gen_helper_vmload(tcg_const_i32(s->VAR_2));",
"}",
"break;",
"case 3:\nif (!(s->flags & HF_SVME_MASK) || !s->pe)\ngoto illegal_op;",
"if (s->cpl != 0) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"break;",
"} else {",
"gen_helper_vmsave(tcg_const_i32(s->VAR_2));",
"}",
"break;",
"case 4:\nif ((!(s->flags & HF_SVME_MASK) &&\n!(s->cpuid_ext3_features & CPUID_EXT3_SKINIT)) ||\n!s->pe)\ngoto illegal_op;",
"if (s->cpl != 0) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"break;",
"} else {",
"gen_helper_stgi();",
"}",
"break;",
"case 5:\nif (!(s->flags & HF_SVME_MASK) || !s->pe)\ngoto illegal_op;",
"if (s->cpl != 0) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"break;",
"} else {",
"gen_helper_clgi();",
"}",
"break;",
"case 6:\nif ((!(s->flags & HF_SVME_MASK) &&\n!(s->cpuid_ext3_features & CPUID_EXT3_SKINIT)) ||\n!s->pe)\ngoto illegal_op;",
"gen_helper_skinit();",
"break;",
"case 7:\nif (!(s->flags & HF_SVME_MASK) || !s->pe)\ngoto illegal_op;",
"if (s->cpl != 0) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"break;",
"} else {",
"gen_helper_invlpga(tcg_const_i32(s->VAR_2));",
"}",
"break;",
"default:\ngoto illegal_op;",
"}",
"} else if (s->cpl != 0) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"} else {",
"gen_svm_check_intercept(s, pc_start,\nVAR_17==2 ? SVM_EXIT_GDTR_WRITE : SVM_EXIT_IDTR_WRITE);",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"gen_op_ld_T1_A0(OT_WORD + s->mem_index);",
"gen_add_A0_im(s, 2);",
"gen_op_ld_T0_A0(CODE64(s) + OT_LONG + s->mem_index);",
"if (!s->VAR_3)\ngen_op_andl_T0_im(0xffffff);",
"if (VAR_17 == 2) {",
"tcg_gen_st_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,gdt.base));",
"tcg_gen_st32_tl(cpu_T[1], cpu_env, offsetof(CPUX86State,gdt.limit));",
"} else {",
"tcg_gen_st_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,idt.base));",
"tcg_gen_st32_tl(cpu_T[1], cpu_env, offsetof(CPUX86State,idt.limit));",
"}",
"}",
"break;",
"case 4:\ngen_svm_check_intercept(s, pc_start, SVM_EXIT_READ_CR0);",
"tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,cr[0]));",
"gen_ldst_modrm(s, VAR_6, OT_WORD, OR_TMP0, 1);",
"break;",
"case 6:\nif (s->cpl != 0) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"} else {",
"gen_svm_check_intercept(s, pc_start, SVM_EXIT_WRITE_CR0);",
"gen_ldst_modrm(s, VAR_6, OT_WORD, OR_TMP0, 0);",
"gen_helper_lmsw(cpu_T[0]);",
"gen_jmp_im(s->pc - s->cs_base);",
"gen_eob(s);",
"}",
"break;",
"case 7:\nif (s->cpl != 0) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"} else {",
"if (VAR_9 == 3) {",
"#ifdef TARGET_X86_64\nif (CODE64(s) && VAR_8 == 0) {",
"tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,segs[R_GS].base));",
"tcg_gen_ld_tl(cpu_T[1], cpu_env, offsetof(CPUX86State,kernelgsbase));",
"tcg_gen_st_tl(cpu_T[1], cpu_env, offsetof(CPUX86State,segs[R_GS].base));",
"tcg_gen_st_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,kernelgsbase));",
"} else",
"#endif\n{",
"goto illegal_op;",
"}",
"} else {",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"gen_helper_invlpg(cpu_A0);",
"gen_jmp_im(s->pc - s->cs_base);",
"gen_eob(s);",
"}",
"}",
"break;",
"default:\ngoto illegal_op;",
"}",
"break;",
"case 0x108:\ncase 0x109:\nif (s->cpl != 0) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"} else {",
"gen_svm_check_intercept(s, pc_start, (VAR_0 & 2) ? SVM_EXIT_INVD : SVM_EXIT_WBINVD);",
"}",
"break;",
"case 0x63:\n#ifdef TARGET_X86_64\nif (CODE64(s)) {",
"int VAR_21;",
"VAR_21 = VAR_3 + OT_WORD;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;",
"VAR_9 = (VAR_6 >> 6) & 3;",
"VAR_8 = (VAR_6 & 7) | REX_B(s);",
"if (VAR_9 == 3) {",
"gen_op_mov_TN_reg(OT_LONG, 0, VAR_8);",
"if (VAR_21 == OT_QUAD)\ntcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);",
"gen_op_mov_reg_T0(VAR_21, VAR_7);",
"} else {",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"if (VAR_21 == OT_QUAD) {",
"gen_op_lds_T0_A0(OT_LONG + s->mem_index);",
"} else {",
"gen_op_ld_T0_A0(OT_LONG + s->mem_index);",
"}",
"gen_op_mov_reg_T0(VAR_21, VAR_7);",
"}",
"} else",
"#endif\n{",
"int VAR_29;",
"TCGv t0, t1, t2;",
"if (!s->pe || s->vm86)\ngoto illegal_op;",
"t0 = tcg_temp_local_new();",
"t1 = tcg_temp_local_new();",
"t2 = tcg_temp_local_new();",
"VAR_5 = OT_WORD;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_7 = (VAR_6 >> 3) & 7;",
"VAR_9 = (VAR_6 >> 6) & 3;",
"VAR_8 = VAR_6 & 7;",
"if (VAR_9 != 3) {",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"gen_op_ld_v(VAR_5 + s->mem_index, t0, cpu_A0);",
"} else {",
"gen_op_mov_v_reg(VAR_5, t0, VAR_8);",
"}",
"gen_op_mov_v_reg(VAR_5, t1, VAR_7);",
"tcg_gen_andi_tl(cpu_tmp0, t0, 3);",
"tcg_gen_andi_tl(t1, t1, 3);",
"tcg_gen_movi_tl(t2, 0);",
"VAR_29 = gen_new_label();",
"tcg_gen_brcond_tl(TCG_COND_GE, cpu_tmp0, t1, VAR_29);",
"tcg_gen_andi_tl(t0, t0, ~3);",
"tcg_gen_or_tl(t0, t0, t1);",
"tcg_gen_movi_tl(t2, CC_Z);",
"gen_set_label(VAR_29);",
"if (VAR_9 != 3) {",
"gen_op_st_v(VAR_5 + s->mem_index, t0, cpu_A0);",
"} else {",
"gen_op_mov_reg_v(VAR_5, VAR_8, t0);",
"}",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_compute_eflags(cpu_cc_src);",
"tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, ~CC_Z);",
"tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, t2);",
"s->cc_op = CC_OP_EFLAGS;",
"tcg_temp_free(t0);",
"tcg_temp_free(t1);",
"tcg_temp_free(t2);",
"}",
"break;",
"case 0x102:\ncase 0x103:\n{",
"int VAR_29;",
"TCGv t0;",
"if (!s->pe || s->vm86)\ngoto illegal_op;",
"VAR_5 = VAR_3 ? OT_LONG : OT_WORD;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;",
"gen_ldst_modrm(s, VAR_6, OT_WORD, OR_TMP0, 0);",
"t0 = tcg_temp_local_new();",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"if (VAR_0 == 0x102)\ngen_helper_lar(t0, cpu_T[0]);",
"else\ngen_helper_lsl(t0, cpu_T[0]);",
"tcg_gen_andi_tl(cpu_tmp0, cpu_cc_src, CC_Z);",
"VAR_29 = gen_new_label();",
"tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_tmp0, 0, VAR_29);",
"gen_op_mov_reg_v(VAR_5, VAR_7, t0);",
"gen_set_label(VAR_29);",
"s->cc_op = CC_OP_EFLAGS;",
"tcg_temp_free(t0);",
"}",
"break;",
"case 0x118:\nVAR_6 = ldub_code(s->pc++);",
"VAR_9 = (VAR_6 >> 6) & 3;",
"VAR_17 = (VAR_6 >> 3) & 7;",
"switch(VAR_17) {",
"case 0:\ncase 1:\ncase 2:\ncase 3:\nif (VAR_9 == 3)\ngoto illegal_op;",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"break;",
"default:\ngen_nop_modrm(s, VAR_6);",
"break;",
"}",
"break;",
"case 0x119 ... 0x11f:\nVAR_6 = ldub_code(s->pc++);",
"gen_nop_modrm(s, VAR_6);",
"break;",
"case 0x120:\ncase 0x122:\nif (s->cpl != 0) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"} else {",
"VAR_6 = ldub_code(s->pc++);",
"if ((VAR_6 & 0xc0) != 0xc0)\ngoto illegal_op;",
"VAR_8 = (VAR_6 & 7) | REX_B(s);",
"VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;",
"if (CODE64(s))\nVAR_5 = OT_QUAD;",
"else\nVAR_5 = OT_LONG;",
"switch(VAR_7) {",
"case 0:\ncase 2:\ncase 3:\ncase 4:\ncase 8:\nif (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"if (VAR_0 & 2) {",
"gen_op_mov_TN_reg(VAR_5, 0, VAR_8);",
"gen_helper_write_crN(tcg_const_i32(VAR_7), cpu_T[0]);",
"gen_jmp_im(s->pc - s->cs_base);",
"gen_eob(s);",
"} else {",
"gen_helper_read_crN(cpu_T[0], tcg_const_i32(VAR_7));",
"gen_op_mov_reg_T0(VAR_5, VAR_8);",
"}",
"break;",
"default:\ngoto illegal_op;",
"}",
"}",
"break;",
"case 0x121:\ncase 0x123:\nif (s->cpl != 0) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"} else {",
"VAR_6 = ldub_code(s->pc++);",
"if ((VAR_6 & 0xc0) != 0xc0)\ngoto illegal_op;",
"VAR_8 = (VAR_6 & 7) | REX_B(s);",
"VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;",
"if (CODE64(s))\nVAR_5 = OT_QUAD;",
"else\nVAR_5 = OT_LONG;",
"if (VAR_7 == 4 || VAR_7 == 5 || VAR_7 >= 8)\ngoto illegal_op;",
"if (VAR_0 & 2) {",
"gen_svm_check_intercept(s, pc_start, SVM_EXIT_WRITE_DR0 + VAR_7);",
"gen_op_mov_TN_reg(VAR_5, 0, VAR_8);",
"gen_helper_movl_drN_T0(tcg_const_i32(VAR_7), cpu_T[0]);",
"gen_jmp_im(s->pc - s->cs_base);",
"gen_eob(s);",
"} else {",
"gen_svm_check_intercept(s, pc_start, SVM_EXIT_READ_DR0 + VAR_7);",
"tcg_gen_ld_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,dr[VAR_7]));",
"gen_op_mov_reg_T0(VAR_5, VAR_8);",
"}",
"}",
"break;",
"case 0x106:\nif (s->cpl != 0) {",
"gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);",
"} else {",
"gen_svm_check_intercept(s, pc_start, SVM_EXIT_WRITE_CR0);",
"gen_helper_clts();",
"gen_jmp_im(s->pc - s->cs_base);",
"gen_eob(s);",
"}",
"break;",
"case 0x1c3:\nif (!(s->cpuid_features & CPUID_SSE2))\ngoto illegal_op;",
"VAR_5 = s->VAR_3 == 2 ? OT_QUAD : OT_LONG;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_9 = (VAR_6 >> 6) & 3;",
"if (VAR_9 == 3)\ngoto illegal_op;",
"VAR_7 = ((VAR_6 >> 3) & 7) | VAR_16;",
"gen_ldst_modrm(s, VAR_6, VAR_5, VAR_7, 1);",
"break;",
"case 0x1ae:\nVAR_6 = ldub_code(s->pc++);",
"VAR_9 = (VAR_6 >> 6) & 3;",
"VAR_17 = (VAR_6 >> 3) & 7;",
"switch(VAR_17) {",
"case 0:\nif (VAR_9 == 3 || !(s->cpuid_features & CPUID_FXSR) ||\n(s->flags & HF_EM_MASK))\ngoto illegal_op;",
"if (s->flags & HF_TS_MASK) {",
"gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);",
"break;",
"}",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_fxsave(cpu_A0, tcg_const_i32((s->VAR_3 == 2)));",
"break;",
"case 1:\nif (VAR_9 == 3 || !(s->cpuid_features & CPUID_FXSR) ||\n(s->flags & HF_EM_MASK))\ngoto illegal_op;",
"if (s->flags & HF_TS_MASK) {",
"gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);",
"break;",
"}",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"if (s->cc_op != CC_OP_DYNAMIC)\ngen_op_set_cc_op(s->cc_op);",
"gen_jmp_im(pc_start - s->cs_base);",
"gen_helper_fxrstor(cpu_A0, tcg_const_i32((s->VAR_3 == 2)));",
"break;",
"case 2:\ncase 3:\nif (s->flags & HF_TS_MASK) {",
"gen_exception(s, EXCP07_PREX, pc_start - s->cs_base);",
"break;",
"}",
"if ((s->flags & HF_EM_MASK) || !(s->flags & HF_OSFXSR_MASK) ||\nVAR_9 == 3)\ngoto illegal_op;",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"if (VAR_17 == 2) {",
"gen_op_ld_T0_A0(OT_LONG + s->mem_index);",
"tcg_gen_st32_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, mxcsr));",
"} else {",
"tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, mxcsr));",
"gen_op_st_T0_A0(OT_LONG + s->mem_index);",
"}",
"break;",
"case 5:\ncase 6:\nif ((VAR_6 & 0xc7) != 0xc0 || !(s->cpuid_features & CPUID_SSE))\ngoto illegal_op;",
"break;",
"case 7:\nif ((VAR_6 & 0xc7) == 0xc0) {",
"if (!(s->cpuid_features & CPUID_SSE))\ngoto illegal_op;",
"} else {",
"if (!(s->cpuid_features & CPUID_CLFLUSH))\ngoto illegal_op;",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"}",
"break;",
"default:\ngoto illegal_op;",
"}",
"break;",
"case 0x10d:\nVAR_6 = ldub_code(s->pc++);",
"VAR_9 = (VAR_6 >> 6) & 3;",
"if (VAR_9 == 3)\ngoto illegal_op;",
"gen_lea_modrm(s, VAR_6, &VAR_10, &VAR_13);",
"break;",
"case 0x1aa:\ngen_svm_check_intercept(s, pc_start, SVM_EXIT_RSM);",
"if (!(s->flags & HF_SMM_MASK))\ngoto illegal_op;",
"if (s->cc_op != CC_OP_DYNAMIC) {",
"gen_op_set_cc_op(s->cc_op);",
"s->cc_op = CC_OP_DYNAMIC;",
"}",
"gen_jmp_im(s->pc - s->cs_base);",
"gen_helper_rsm();",
"gen_eob(s);",
"break;",
"case 0x1b8:\nif ((VAR_1 & (PREFIX_REPZ | PREFIX_LOCK | PREFIX_REPNZ)) !=\nPREFIX_REPZ)\ngoto illegal_op;",
"if (!(s->cpuid_ext_features & CPUID_EXT_POPCNT))\ngoto illegal_op;",
"VAR_6 = ldub_code(s->pc++);",
"VAR_7 = ((VAR_6 >> 3) & 7);",
"if (s->prefix & PREFIX_DATA)\nVAR_5 = OT_WORD;",
"else if (s->VAR_3 != 2)\nVAR_5 = OT_LONG;",
"else\nVAR_5 = OT_QUAD;",
"gen_ldst_modrm(s, VAR_6, VAR_5, OR_TMP0, 0);",
"gen_helper_popcnt(cpu_T[0], cpu_T[0], tcg_const_i32(VAR_5));",
"gen_op_mov_reg_T0(VAR_5, VAR_7);",
"s->cc_op = CC_OP_EFLAGS;",
"break;",
"case 0x10e ... 0x10f:\ns->prefix &= ~(PREFIX_REPZ | PREFIX_REPNZ | PREFIX_DATA);",
"case 0x110 ... 0x117:\ncase 0x128 ... 0x12f:\ncase 0x138 ... 0x13a:\ncase 0x150 ... 0x177:\ncase 0x17c ... 0x17f:\ncase 0x1c2:\ncase 0x1c4 ... 0x1c6:\ncase 0x1d0 ... 0x1fe:\ngen_sse(s, VAR_0, pc_start, VAR_16);",
"break;",
"default:\ngoto illegal_op;",
"}",
"if (s->prefix & PREFIX_LOCK)\ngen_helper_unlock();",
"return s->pc;",
"illegal_op:\nif (s->prefix & PREFIX_LOCK)\ngen_helper_unlock();",
"gen_exception(s, EXCP06_ILLOP, pc_start - s->cs_base);",
"return s->pc;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43,
45
],
[
47,
49
],
[
51
],
[
55,
57
],
[
59
],
[
61,
63
],
[
65
],
[
67,
69
],
[
71
],
[
73,
75
],
[
77
],
[
79,
81
],
[
83
],
[
85,
87
],
[
89
],
[
91,
93
],
[
95
],
[
97,
99
],
[
101
],
[
103,
105
],
[
107
],
[
109,
111
],
[
113
],
[
115,
117
],
[
119
],
[
121,
123
],
[
125
],
[
127,
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153,
155
],
[
157
],
[
159,
161
],
[
163
],
[
165,
167
],
[
169
],
[
171,
173
],
[
175
],
[
177,
179
],
[
181
],
[
183,
185
],
[
187
],
[
189,
191
],
[
193
],
[
195,
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
],
[
251
],
[
253
],
[
255
],
[
261,
263
],
[
269,
271
],
[
273,
279
],
[
281
],
[
289,
291,
293,
295,
297,
299,
301,
303,
305
],
[
307
],
[
309
],
[
311
],
[
315,
317
],
[
319,
321
],
[
325
],
[
327,
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345,
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371,
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401,
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
415
],
[
419,
421,
423
],
[
425,
427,
429,
431
],
[
433
],
[
437,
439
],
[
441,
443
],
[
447
],
[
449
],
[
451
],
[
453
],
[
457
],
[
459,
461
],
[
463,
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
479
],
[
481,
483,
485,
487,
489
],
[
491
],
[
493,
495
],
[
497
],
[
499
],
[
501
],
[
503
],
[
505
],
[
507
],
[
515,
517
],
[
519
],
[
521
],
[
523,
525
],
[
527
],
[
529
],
[
531,
533,
535,
537
],
[
539,
541
],
[
545
],
[
547
],
[
549
],
[
551
],
[
553
],
[
555,
557
],
[
559
],
[
561
],
[
563
],
[
565
],
[
567
],
[
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
],
[
635
],
[
637
],
[
639
],
[
641
],
[
643
],
[
645
],
[
647,
649
],
[
651
],
[
653
],
[
657
],
[
659
],
[
661
],
[
663
],
[
665
],
[
667
],
[
669
],
[
671
],
[
673,
675,
677,
679
],
[
681
],
[
683
],
[
685
],
[
687
],
[
689
],
[
691
],
[
693
],
[
695
],
[
697,
699
],
[
701
],
[
703
],
[
705
],
[
707
],
[
709
],
[
711
],
[
713
],
[
715
],
[
717
],
[
719
],
[
721
],
[
723
],
[
725
],
[
727
],
[
729
],
[
731,
733
],
[
735
],
[
737,
739,
741
],
[
743
],
[
745
],
[
747,
749
],
[
751
],
[
753,
755
],
[
757,
759
],
[
761
],
[
763
],
[
767
],
[
769
],
[
771
],
[
773
],
[
775
],
[
777
],
[
779
],
[
781,
783
],
[
785
],
[
787
],
[
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
],
[
957
],
[
959,
961,
963
],
[
965
],
[
967
],
[
969,
971,
973
],
[
975
],
[
977
],
[
979,
981
],
[
983
],
[
985,
987
],
[
989
],
[
991
],
[
995,
997,
999,
1001
],
[
1003,
1005
],
[
1009
],
[
1011
],
[
1013
],
[
1015
],
[
1017
],
[
1019
],
[
1021
],
[
1023
],
[
1025
],
[
1029
],
[
1031
],
[
1037
],
[
1039
],
[
1043
],
[
1045
],
[
1047
],
[
1049
],
[
1051
],
[
1053,
1055
],
[
1057
],
[
1059
],
[
1061
],
[
1065
],
[
1067,
1069,
1071
],
[
1073,
1075
],
[
1077
],
[
1079
],
[
1081,
1083,
1085
],
[
1087,
1089
],
[
1091
],
[
1093
],
[
1095,
1099,
1101
],
[
1103
],
[
1105
],
[
1107
],
[
1109
],
[
1111
],
[
1113
],
[
1115,
1117
],
[
1119
],
[
1121
],
[
1123,
1125
],
[
1127,
1129
],
[
1131
],
[
1133
],
[
1135,
1137,
1139
],
[
1141
],
[
1143
],
[
1145,
1147,
1149
],
[
1151
],
[
1153
],
[
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
],
[
1223,
1225,
1227,
1229
],
[
1231,
1233
],
[
1237
],
[
1239
],
[
1241
],
[
1243
],
[
1247
],
[
1249
],
[
1251
],
[
1253
],
[
1255
],
[
1259,
1261,
1263,
1265
],
[
1267,
1269
],
[
1271
],
[
1275
],
[
1277
],
[
1279
],
[
1281
],
[
1283
],
[
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
],
[
1405,
1407
],
[
1409
],
[
1411
],
[
1413,
1415
],
[
1417,
1419
],
[
1421
],
[
1423
],
[
1425
],
[
1427
],
[
1429
],
[
1431,
1433
],
[
1435
],
[
1437
],
[
1439
],
[
1441
],
[
1443
],
[
1445
],
[
1447
],
[
1449
],
[
1451
],
[
1453
],
[
1455
],
[
1457
],
[
1459
],
[
1461,
1463
],
[
1465
],
[
1467
],
[
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
],
[
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
],
[
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,
1687
],
[
1689
],
[
1691,
1693
],
[
1695
],
[
1697
],
[
1699
],
[
1701
],
[
1703
],
[
1711,
1713
],
[
1715
],
[
1717
],
[
1719,
1721
],
[
1723
],
[
1725
],
[
1727
],
[
1729
],
[
1731
],
[
1735
],
[
1737
],
[
1739
],
[
1741,
1743,
1745
],
[
1747
],
[
1749
],
[
1751,
1753,
1755
],
[
1757
],
[
1759
],
[
1761,
1763,
1765
],
[
1767
],
[
1769
],
[
1771
],
[
1773
],
[
1775,
1777
],
[
1779,
1781
],
[
1783
],
[
1785
],
[
1787
],
[
1789,
1791
],
[
1793
],
[
1795
],
[
1797
],
[
1799
],
[
1801
],
[
1803
],
[
1805
],
[
1807
],
[
1811
],
[
1813
],
[
1815
],
[
1817
],
[
1821
],
[
1823
],
[
1825
],
[
1827
],
[
1829
],
[
1831
],
[
1833,
1835
],
[
1837
],
[
1839
],
[
1841
],
[
1843
],
[
1845
],
[
1847
],
[
1849
],
[
1851,
1855
],
[
1857
],
[
1859
],
[
1861
],
[
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
],
[
1917
],
[
1919
],
[
1921,
1923,
1925,
1927,
1929
],
[
1931
],
[
1933
],
[
1935
],
[
1937
],
[
1939
],
[
1947,
1949
],
[
1951
],
[
1953
],
[
1955
],
[
1957
],
[
1959
],
[
1961
],
[
1963
],
[
1965,
1967,
1969
],
[
1971
],
[
1973
],
[
1975
],
[
1977
],
[
1979
],
[
1981
],
[
1983
],
[
1991,
1993,
1995,
1997
],
[
1999,
2001
],
[
2003
],
[
2005
],
[
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
],
[
2061,
2063
],
[
2065
],
[
2067
],
[
2071
],
[
2073
],
[
2075
],
[
2077,
2079
],
[
2081
],
[
2083,
2085
],
[
2087
],
[
2089
],
[
2091
],
[
2099,
2101
],
[
2103
],
[
2105
],
[
2107
],
[
2109
],
[
2111
],
[
2113
],
[
2115
],
[
2117,
2119
],
[
2121
],
[
2123
],
[
2125,
2127
],
[
2129
],
[
2131,
2133
],
[
2135,
2137
],
[
2139
],
[
2141
],
[
2145,
2147,
2149,
2151,
2153
],
[
2155
],
[
2159
],
[
2163
],
[
2165
],
[
2167
],
[
2169
],
[
2171
],
[
2175
],
[
2177
],
[
2179
],
[
2181,
2183
],
[
2185
],
[
2187,
2189
],
[
2191
],
[
2193,
2195
],
[
2197
],
[
2199,
2201,
2203
],
[
2205
],
[
2207
],
[
2209
],
[
2211
],
[
2213
],
[
2215
],
[
2217
],
[
2219
],
[
2221
],
[
2223
],
[
2225
],
[
2227
],
[
2229
],
[
2231
],
[
2235,
2237
],
[
2239
],
[
2241
],
[
2243,
2245
],
[
2247
],
[
2251
],
[
2253
],
[
2255
],
[
2257
],
[
2259
],
[
2261
],
[
2263
],
[
2267,
2269,
2271,
2273,
2275
],
[
2277
],
[
2281,
2283
],
[
2285,
2287
],
[
2289,
2291
],
[
2293
],
[
2295
],
[
2297
],
[
2299
],
[
2301,
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
],
[
2371,
2373
],
[
2375
],
[
2377
],
[
2379
],
[
2381
],
[
2383
],
[
2385,
2387
],
[
2389
],
[
2391
],
[
2393
],
[
2395,
2397,
2399
],
[
2401
],
[
2405
],
[
2407
],
[
2409
],
[
2411
],
[
2413
],
[
2415
],
[
2417,
2419
],
[
2421
],
[
2423
],
[
2425
],
[
2427
],
[
2429
],
[
2431
],
[
2433
],
[
2437,
2439
],
[
2441
],
[
2443
],
[
2445
],
[
2447,
2449,
2451,
2453
],
[
2455,
2457
],
[
2459
],
[
2461
],
[
2463
],
[
2465
],
[
2467
],
[
2469,
2471
],
[
2473
],
[
2475
],
[
2477
],
[
2479
],
[
2481
],
[
2483
],
[
2487,
2489
],
[
2491
],
[
2493
],
[
2495,
2497
],
[
2499
],
[
2501
],
[
2503
],
[
2505,
2507,
2509
],
[
2511
],
[
2513
],
[
2515,
2517,
2519
],
[
2521
],
[
2523
],
[
2525,
2527
],
[
2529
],
[
2531,
2533
],
[
2535
],
[
2537,
2539
],
[
2541,
2543
],
[
2545
],
[
2547
],
[
2549
],
[
2551,
2553
],
[
2555
],
[
2557
],
[
2559
],
[
2563
],
[
2565
],
[
2569
],
[
2571
],
[
2573
],
[
2575
],
[
2577
],
[
2579
],
[
2587,
2589,
2593
],
[
2595,
2597
],
[
2599,
2601
],
[
2603,
2605
],
[
2609
],
[
2611
],
[
2613
],
[
2617
],
[
2619
],
[
2621
],
[
2623
],
[
2625
],
[
2627
],
[
2629
],
[
2631
],
[
2633
],
[
2639
],
[
2641
],
[
2643
],
[
2645
],
[
2647
],
[
2649
],
[
2651
],
[
2653
],
[
2655
],
[
2657
],
[
2659,
2661,
2665
],
[
2667
],
[
2669,
2671,
2675
],
[
2677
],
[
2681,
2683
],
[
2685
],
[
2687
],
[
2689,
2691
],
[
2693
],
[
2695
],
[
2697,
2699
],
[
2701
],
[
2703
],
[
2705,
2707
],
[
2709
],
[
2711,
2713
],
[
2715
],
[
2717
],
[
2719
],
[
2721
],
[
2723
],
[
2725
],
[
2727
],
[
2729
],
[
2731
],
[
2733
],
[
2735
],
[
2739
],
[
2741
],
[
2743
],
[
2745
],
[
2747
],
[
2749
],
[
2751
],
[
2753
],
[
2761,
2763
],
[
2769
],
[
2771
],
[
2773
],
[
2775
],
[
2777
],
[
2779
],
[
2781
],
[
2783
],
[
2787
],
[
2789
],
[
2791,
2793,
2795,
2797,
2799
],
[
2801
],
[
2803
],
[
2807
],
[
2809,
2811
],
[
2813
],
[
2815
],
[
2817
],
[
2819,
2821
],
[
2823
],
[
2825
],
[
2827
],
[
2829,
2831,
2833
],
[
2835
],
[
2837
],
[
2839,
2841,
2843
],
[
2845
],
[
2847
],
[
2849
],
[
2851
],
[
2855
],
[
2857
],
[
2861
],
[
2863
],
[
2865
],
[
2867
],
[
2869,
2871,
2873,
2875,
2877,
2879,
2881
],
[
2883,
2885
],
[
2887,
2889
],
[
2891
],
[
2893
],
[
2895
],
[
2897,
2899
],
[
2901
],
[
2903
],
[
2905
],
[
2907,
2909,
2911
],
[
2913
],
[
2915
],
[
2917,
2919,
2921
],
[
2923
],
[
2925
],
[
2927
],
[
2929
],
[
2931
],
[
2933,
2937
],
[
2939,
2941
],
[
2943
],
[
2945
],
[
2947
],
[
2949,
2951
],
[
2953,
2955
],
[
2957
],
[
2959,
2961,
2963
],
[
2965
],
[
2967
],
[
2969
],
[
2971
],
[
2973
],
[
2975
],
[
2977,
2979
],
[
2981,
2983
],
[
2985
],
[
2987
],
[
2989
],
[
2991,
2993
],
[
2995
],
[
2997
],
[
2999
],
[
3001,
3003
],
[
3005,
3007
],
[
3009
],
[
3011,
3013,
3015
],
[
3017
],
[
3019
],
[
3021
],
[
3023
],
[
3025,
3027
],
[
3029
],
[
3031
],
[
3033
],
[
3035,
3037,
3039
],
[
3041
],
[
3043,
3045
],
[
3047
],
[
3049,
3051
],
[
3053
],
[
3055
],
[
3057
],
[
3059,
3061,
3063
],
[
3065
],
[
3067
],
[
3069
],
[
3071,
3073
],
[
3075
],
[
3077
],
[
3079
],
[
3081,
3083,
3085
],
[
3087
],
[
3089
],
[
3091
],
[
3093,
3095,
3097
],
[
3099
],
[
3101
],
[
3103
],
[
3105
],
[
3107,
3109,
3111
],
[
3113
],
[
3115
],
[
3117
],
[
3119,
3121,
3123
],
[
3125
],
[
3127
],
[
3129
],
[
3131,
3133
],
[
3135
],
[
3137
],
[
3139
],
[
3141,
3143,
3145
],
[
3147
],
[
3149
],
[
3151
],
[
3153,
3155,
3157
],
[
3159
],
[
3161
],
[
3163
],
[
3165
],
[
3167,
3169,
3171
],
[
3173
],
[
3175
],
[
3177,
3179
],
[
3181,
3183
],
[
3185
],
[
3187
],
[
3189,
3191
],
[
3193
],
[
3195
],
[
3199
],
[
3203
],
[
3205,
3207
],
[
3209
],
[
3211
],
[
3213,
3215,
3217,
3219
],
[
3221
],
[
3223,
3225
],
[
3227,
3231,
3233
],
[
3235
],
[
3237
],
[
3239
],
[
3241,
3243
],
[
3245
],
[
3247
],
[
3249,
3251
],
[
3253,
3255
],
[
3257
],
[
3259,
3261
],
[
3263
],
[
3265,
3267
],
[
3269
],
[
3271
],
[
3273,
3275
],
[
3277
],
[
3279,
3281
],
[
3283
],
[
3285
],
[
3287,
3289
],
[
3291
],
[
3293,
3295
],
[
3297
],
[
3299
],
[
3301,
3303
],
[
3305
],
[
3307
],
[
3309,
3311
],
[
3313
],
[
3315
],
[
3317,
3319
],
[
3321
],
[
3323
],
[
3325,
3327
],
[
3329
],
[
3331
],
[
3333,
3335
],
[
3337
],
[
3339
],
[
3341,
3343
],
[
3345
],
[
3347
],
[
3349,
3351
],
[
3353
],
[
3355
],
[
3357
],
[
3359,
3361
],
[
3363,
3365
],
[
3367
],
[
3369,
3371
],
[
3373
],
[
3375,
3377
],
[
3379
],
[
3381,
3383
],
[
3385
],
[
3387,
3389
],
[
3391
],
[
3393,
3395
],
[
3397
],
[
3399,
3401
],
[
3403
],
[
3405,
3407,
3409
],
[
3411
],
[
3413
],
[
3415
],
[
3417,
3419
],
[
3421,
3423
],
[
3425
],
[
3427,
3429
],
[
3431
],
[
3433,
3435
],
[
3437
],
[
3439,
3441
],
[
3443
],
[
3445,
3447
],
[
3449
],
[
3451,
3453
],
[
3455
],
[
3457,
3459
],
[
3461
],
[
3463,
3465,
3467
],
[
3469
],
[
3471
],
[
3473
],
[
3475,
3477,
3479,
3481
],
[
3483
],
[
3487
],
[
3489
],
[
3491
],
[
3493,
3495
],
[
3497
],
[
3499
],
[
3501
],
[
3503
],
[
3505
],
[
3507
],
[
3509,
3511,
3513
],
[
3515
],
[
3517
],
[
3519,
3521,
3523,
3525
],
[
3527
],
[
3529
],
[
3531
],
[
3533,
3535
],
[
3537,
3539
],
[
3541
],
[
3543
],
[
3545
],
[
3547
],
[
3549,
3551
],
[
3553
],
[
3555
],
[
3557,
3559
],
[
3561,
3563
],
[
3565,
3567
],
[
3569,
3571
],
[
3573
],
[
3575,
3577
],
[
3579
],
[
3581,
3583
],
[
3585,
3587
],
[
3589
],
[
3591
],
[
3593,
3595,
3597
],
[
3599
],
[
3601
],
[
3603
],
[
3605
],
[
3607,
3609,
3611
],
[
3613
],
[
3615
],
[
3617
],
[
3619
],
[
3621,
3623
],
[
3625
],
[
3627,
3629
],
[
3631
],
[
3633,
3635,
3637,
3639,
3641
],
[
3643
],
[
3645
],
[
3647,
3649
],
[
3651
],
[
3653
],
[
3655,
3657
],
[
3659
],
[
3661
],
[
3663
],
[
3665,
3667
],
[
3669,
3671
],
[
3673
],
[
3675
],
[
3677
],
[
3679
],
[
3681,
3683
],
[
3685
],
[
3687
],
[
3689,
3691
],
[
3693
],
[
3695
],
[
3697,
3699
],
[
3701,
3703
],
[
3705
],
[
3707
],
[
3709
],
[
3711,
3713
],
[
3715
],
[
3717
],
[
3719,
3721,
3723
],
[
3725
],
[
3727
],
[
3729
],
[
3731
],
[
3733
],
[
3735,
3737,
3739
],
[
3741
],
[
3743
],
[
3745
],
[
3747
],
[
3749
],
[
3751,
3753,
3755
],
[
3757
],
[
3759
],
[
3761,
3763,
3765,
3767,
3769
],
[
3771
],
[
3773
],
[
3775
],
[
3777
],
[
3779
],
[
3781
],
[
3783
],
[
3785,
3787
],
[
3789
],
[
3791
],
[
3793
],
[
3801,
3803,
3805,
3807
],
[
3809,
3811
],
[
3815
],
[
3817
],
[
3819
],
[
3821
],
[
3823
],
[
3825
],
[
3829,
3831,
3833,
3835
],
[
3837,
3839
],
[
3843
],
[
3845
],
[
3847
],
[
3849
],
[
3851
],
[
3853
],
[
3855,
3857,
3859,
3861
],
[
3863,
3865
],
[
3867
],
[
3869
],
[
3871
],
[
3873
],
[
3875
],
[
3877
],
[
3879,
3881,
3883,
3885
],
[
3887,
3889
],
[
3891
],
[
3893
],
[
3895
],
[
3897
],
[
3899
],
[
3901
],
[
3903
],
[
3905
],
[
3907
],
[
3911,
3913,
3915,
3917
],
[
3919,
3921
],
[
3923
],
[
3925
],
[
3927
],
[
3929
],
[
3931
],
[
3933
],
[
3935
],
[
3937
],
[
3939
],
[
3941,
3943,
3945,
3947
],
[
3949,
3951
],
[
3953
],
[
3955
],
[
3957,
3959
],
[
3961
],
[
3963
],
[
3965
],
[
3967
],
[
3969
],
[
3971
],
[
3973
],
[
3975
],
[
3977
],
[
3979,
3981,
3983,
3985
],
[
3987,
3989
],
[
3991
],
[
3993
],
[
3995,
3997
],
[
3999
],
[
4001
],
[
4003
],
[
4005
],
[
4007
],
[
4009
],
[
4011
],
[
4013
],
[
4015
],
[
4025,
4027,
4029,
4031
],
[
4033,
4035
],
[
4037
],
[
4039
],
[
4041,
4043
],
[
4045,
4047
],
[
4049
],
[
4051
],
[
4053
],
[
4055
],
[
4057
],
[
4059
],
[
4061
],
[
4063
],
[
4065,
4067,
4069,
4071
],
[
4073,
4075
],
[
4077
],
[
4079
],
[
4081,
4083
],
[
4085
],
[
4089,
4091
],
[
4093
],
[
4095
],
[
4097
],
[
4099
],
[
4101
],
[
4103
],
[
4105
],
[
4107
],
[
4109
],
[
4111,
4113,
4115,
4117
],
[
4119,
4121
],
[
4123
],
[
4125
],
[
4127,
4129
],
[
4131,
4133
],
[
4135
],
[
4137
],
[
4139
],
[
4141
],
[
4143
],
[
4145
],
[
4147
],
[
4149
],
[
4151,
4153,
4155,
4157
],
[
4159,
4161
],
[
4163
],
[
4165
],
[
4167,
4169
],
[
4171
],
[
4175,
4177
],
[
4179
],
[
4181
],
[
4183
],
[
4185
],
[
4187
],
[
4189
],
[
4191
],
[
4193
],
[
4195
],
[
4203,
4205
],
[
4207
],
[
4209
],
[
4211,
4213
],
[
4215
],
[
4217,
4219
],
[
4221
],
[
4223
],
[
4225
],
[
4227,
4229
],
[
4231
],
[
4233,
4235
],
[
4237
],
[
4239
],
[
4241
],
[
4243,
4245
],
[
4247
],
[
4249,
4251
],
[
4253,
4255
],
[
4257
],
[
4259,
4261
],
[
4263
],
[
4265
],
[
4269
],
[
4271,
4273
],
[
4279
],
[
4283
],
[
4285
],
[
4287
],
[
4291
],
[
4293
],
[
4295
],
[
4297
],
[
4299,
4301
],
[
4303
],
[
4305,
4307
],
[
4309
],
[
4313
],
[
4315
],
[
4317
],
[
4319
],
[
4321
],
[
4323
],
[
4325
],
[
4327
],
[
4329
],
[
4331
],
[
4333,
4335
],
[
4337
],
[
4339,
4341
],
[
4343
],
[
4345
],
[
4347
],
[
4349
],
[
4351,
4353
],
[
4355,
4357
],
[
4359,
4361
],
[
4363
],
[
4365
],
[
4367,
4369
],
[
4371
],
[
4373
],
[
4375
],
[
4377
],
[
4379
],
[
4381,
4383
],
[
4385
],
[
4389,
4391
],
[
4393
],
[
4395
],
[
4397
],
[
4401
],
[
4403
],
[
4405
],
[
4407
],
[
4409,
4411,
4413
],
[
4415,
4417
],
[
4419
],
[
4421,
4423
],
[
4427
],
[
4429
],
[
4431,
4433
],
[
4435
],
[
4439,
4441
],
[
4443
],
[
4445
],
[
4447
],
[
4451
],
[
4453
],
[
4455
],
[
4457
],
[
4459,
4461
],
[
4463
],
[
4465,
4467
],
[
4469
],
[
4471
],
[
4473,
4475
],
[
4477
],
[
4479,
4481
],
[
4483
],
[
4485
],
[
4487
],
[
4489
],
[
4491,
4493
],
[
4495
],
[
4497,
4499
],
[
4501
],
[
4503
],
[
4507,
4509
],
[
4511
],
[
4513
],
[
4515
],
[
4517,
4519
],
[
4521
],
[
4523
],
[
4527
],
[
4529
],
[
4531
],
[
4533
],
[
4535
],
[
4537
],
[
4539
],
[
4541
],
[
4543
],
[
4545
],
[
4547
],
[
4549
],
[
4551,
4553
],
[
4557
],
[
4559
],
[
4561
],
[
4563
],
[
4565
],
[
4567
],
[
4569
],
[
4571,
4573
],
[
4575
],
[
4577
],
[
4579
],
[
4581
],
[
4583
],
[
4585
],
[
4587
],
[
4589
],
[
4597,
4599
],
[
4601
],
[
4603
],
[
4605
],
[
4607,
4609
],
[
4611
],
[
4613
],
[
4615
],
[
4617
],
[
4619,
4621
],
[
4623
],
[
4625
],
[
4627
],
[
4629
],
[
4631
],
[
4633
],
[
4635,
4637
],
[
4639
],
[
4641,
4643
],
[
4645
],
[
4647
],
[
4649
],
[
4651
],
[
4653,
4655
],
[
4657
],
[
4659,
4661
],
[
4663
],
[
4665
],
[
4667
],
[
4669,
4671
],
[
4673
],
[
4675,
4677
],
[
4679
],
[
4681
],
[
4683
],
[
4685
],
[
4687
],
[
4691
],
[
4693
],
[
4695
],
[
4697
],
[
4699,
4701,
4703
],
[
4705
],
[
4707,
4709
],
[
4711
],
[
4713
],
[
4715
],
[
4717
],
[
4719
],
[
4721
],
[
4723,
4725,
4727
],
[
4729,
4731
],
[
4733
],
[
4737
],
[
4739
],
[
4741
],
[
4743,
4745,
4747
],
[
4749
],
[
4751
],
[
4753
],
[
4755
],
[
4757,
4759,
4761
],
[
4763
],
[
4765
],
[
4767
],
[
4769
],
[
4771,
4773,
4775
],
[
4777
],
[
4779
],
[
4781
],
[
4783
],
[
4785,
4787
],
[
4789
],
[
4791
],
[
4793,
4795
],
[
4797
],
[
4799
],
[
4807,
4809
],
[
4811
],
[
4813
],
[
4815
],
[
4817
],
[
4819
],
[
4821
],
[
4823
],
[
4825
],
[
4827
],
[
4829
],
[
4831
],
[
4835
],
[
4837
],
[
4839,
4841
],
[
4843
],
[
4845
],
[
4847,
4849
],
[
4851
],
[
4853,
4855
],
[
4857
],
[
4859,
4861
],
[
4863
],
[
4865,
4867
],
[
4869,
4871
],
[
4873
],
[
4875
],
[
4877
],
[
4879
],
[
4881
],
[
4883
],
[
4885
],
[
4889
],
[
4891
],
[
4893
],
[
4895
],
[
4897
],
[
4899
],
[
4901
],
[
4903
],
[
4905,
4907
],
[
4909
],
[
4911,
4913
],
[
4915
],
[
4917
],
[
4919,
4921
],
[
4923
],
[
4925
],
[
4927
],
[
4929
],
[
4931,
4933
],
[
4935
],
[
4937
],
[
4939
],
[
4941
],
[
4943
],
[
4945,
4947,
4949
],
[
4951
],
[
4953
],
[
4955
],
[
4957
],
[
4959
],
[
4961
],
[
4963
],
[
4965,
4967
],
[
4969,
4971
],
[
4973
],
[
4975
],
[
4977
],
[
4979
],
[
4981,
4983,
4985
],
[
4987
],
[
4989
],
[
4993
],
[
4995
],
[
4997
],
[
4999
],
[
5001
],
[
5003
],
[
5005
],
[
5007
],
[
5009
],
[
5011
],
[
5013
],
[
5015
],
[
5017
],
[
5019
],
[
5021
],
[
5023
],
[
5025
],
[
5027
],
[
5029
],
[
5031
],
[
5033
],
[
5035
],
[
5037
],
[
5043,
5045,
5047
],
[
5049,
5051
],
[
5053
],
[
5055
],
[
5057
],
[
5059,
5061,
5063
],
[
5065,
5067
],
[
5069
],
[
5071
],
[
5073
],
[
5075,
5077,
5079
],
[
5081,
5083
],
[
5085
],
[
5087
],
[
5089
],
[
5091,
5093,
5095
],
[
5097,
5099
],
[
5101
],
[
5103
],
[
5105
],
[
5107,
5109,
5111
],
[
5113
],
[
5115
],
[
5117
],
[
5119
],
[
5121
],
[
5123
],
[
5125
],
[
5127
],
[
5129,
5131,
5133
],
[
5135
],
[
5137
],
[
5139
],
[
5141
],
[
5147,
5153,
5155
],
[
5157
],
[
5159
],
[
5161
],
[
5163
],
[
5165,
5167,
5169
],
[
5171
],
[
5173
],
[
5175,
5177
],
[
5179
],
[
5181
],
[
5183
],
[
5185
],
[
5187,
5189
],
[
5191
],
[
5193,
5195
],
[
5197
],
[
5199
],
[
5201
],
[
5203
],
[
5205
],
[
5207
],
[
5209,
5211,
5213
],
[
5215,
5217
],
[
5219
],
[
5221
],
[
5223
],
[
5225,
5227,
5229
],
[
5231,
5233
],
[
5235,
5239
],
[
5241
],
[
5243,
5245
],
[
5247,
5249,
5251
],
[
5253
],
[
5255
],
[
5257
],
[
5259
],
[
5261
],
[
5263
],
[
5265
],
[
5267
],
[
5269
],
[
5271
],
[
5273
],
[
5275
],
[
5277
],
[
5279,
5281
],
[
5283
],
[
5285,
5287
],
[
5295,
5297
],
[
5301
],
[
5303
],
[
5305
],
[
5307
],
[
5309
],
[
5311
],
[
5313
],
[
5315
],
[
5317
],
[
5319
],
[
5321
],
[
5323
],
[
5325
],
[
5327,
5329,
5331
],
[
5333
],
[
5335
],
[
5337
],
[
5339
],
[
5341,
5343
],
[
5345
],
[
5347
],
[
5349
],
[
5351
],
[
5353,
5355
],
[
5357,
5359
],
[
5361
],
[
5363,
5365
],
[
5367,
5369
],
[
5371
],
[
5373
],
[
5375
],
[
5377
],
[
5379
],
[
5381
],
[
5383
],
[
5387
],
[
5389
],
[
5391
],
[
5393
],
[
5395
],
[
5397
],
[
5399,
5401
],
[
5403
],
[
5405
],
[
5407
],
[
5409
],
[
5411,
5413
],
[
5415,
5417,
5419
],
[
5421,
5423
],
[
5425
],
[
5427
],
[
5429
],
[
5431
],
[
5433,
5435,
5437,
5439,
5441
],
[
5443
],
[
5447
],
[
5449
],
[
5451
],
[
5453,
5455
],
[
5459
],
[
5461
],
[
5463
],
[
5465
],
[
5467
],
[
5469,
5471,
5473,
5475
],
[
5477
],
[
5479
],
[
5481
],
[
5483
],
[
5485
],
[
5487
],
[
5489
],
[
5491
],
[
5493
],
[
5495
],
[
5497,
5499
],
[
5501
],
[
5503
],
[
5505,
5507,
5509
],
[
5511
],
[
5513
],
[
5517
],
[
5519
],
[
5521
],
[
5525
],
[
5527
],
[
5529
],
[
5531
],
[
5533
],
[
5535
],
[
5537,
5539,
5541
],
[
5543
],
[
5545
],
[
5547,
5549
],
[
5551
],
[
5553
],
[
5555
],
[
5557
],
[
5559
],
[
5561
],
[
5563
],
[
5565
],
[
5567,
5569,
5571
],
[
5573
],
[
5575,
5577
],
[
5579
],
[
5581
],
[
5583
],
[
5585
],
[
5587
],
[
5589
],
[
5591,
5593,
5595
],
[
5597
],
[
5599
],
[
5601
],
[
5603,
5607,
5609
],
[
5611
],
[
5613
],
[
5615
],
[
5617
],
[
5619
],
[
5621
],
[
5623
],
[
5625
],
[
5627
],
[
5629
],
[
5631
],
[
5633
],
[
5635,
5639,
5641
],
[
5643
],
[
5645
],
[
5647
],
[
5649
],
[
5651
],
[
5653
],
[
5655
],
[
5657
],
[
5659
],
[
5661
],
[
5663
],
[
5665
],
[
5667,
5669,
5673
],
[
5675
],
[
5677
],
[
5679
],
[
5681
],
[
5683
],
[
5685
],
[
5687
],
[
5689,
5691
],
[
5693
],
[
5695
],
[
5697
],
[
5699
],
[
5701
],
[
5703
],
[
5705
],
[
5707
],
[
5711,
5713
],
[
5715
],
[
5717
],
[
5719
],
[
5721,
5723,
5725,
5727
],
[
5729
],
[
5731
],
[
5733
],
[
5735,
5737
],
[
5739
],
[
5741
],
[
5743,
5745
],
[
5747
],
[
5749
],
[
5751
],
[
5753
],
[
5755
],
[
5757,
5759
],
[
5761
],
[
5763
],
[
5765
],
[
5767,
5769,
5771
],
[
5773
],
[
5775
],
[
5777
],
[
5779,
5781
],
[
5783
],
[
5785
],
[
5787,
5789,
5791
],
[
5793
],
[
5795
],
[
5797
],
[
5799
],
[
5801
],
[
5803
],
[
5805
],
[
5807
],
[
5809
],
[
5811
],
[
5813,
5815,
5817
],
[
5819
],
[
5821
],
[
5823
],
[
5825,
5827
],
[
5829
],
[
5831
],
[
5833,
5835,
5837
],
[
5839
],
[
5841
],
[
5843
],
[
5845
],
[
5847
],
[
5849
],
[
5851
],
[
5853
],
[
5855
],
[
5857
],
[
5859,
5861,
5863,
5865
],
[
5867
],
[
5869,
5871
],
[
5873,
5875
],
[
5877,
5879
],
[
5881
],
[
5883
],
[
5885,
5887
],
[
5889
],
[
5891
],
[
5893,
5895
],
[
5897
],
[
5899
],
[
5901
],
[
5903
],
[
5905,
5907,
5909
],
[
5911
],
[
5913
],
[
5915
],
[
5917
],
[
5919
],
[
5921
],
[
5923,
5925
],
[
5927
],
[
5929
],
[
5931,
5933
],
[
5935
],
[
5937,
5939,
5941,
5943
],
[
5945,
5947
],
[
5949
],
[
5951,
5953
],
[
5955
],
[
5957
],
[
5959,
5961
],
[
5963
],
[
5965,
5967
],
[
5969
],
[
5971
],
[
5973
],
[
5975
],
[
5977,
5979,
5981,
5983
],
[
5985
],
[
5987
],
[
5989
],
[
5991
],
[
5993
],
[
5995
],
[
5997
],
[
5999
],
[
6001,
6003
],
[
6005
],
[
6007
],
[
6009
],
[
6011
],
[
6013
],
[
6015
],
[
6017
],
[
6019
],
[
6021,
6023
],
[
6025
],
[
6027
],
[
6029
],
[
6031,
6033,
6035
],
[
6037,
6039
],
[
6041
],
[
6043
],
[
6045,
6047,
6049
],
[
6051
],
[
6053
],
[
6055
],
[
6057
],
[
6059,
6061
],
[
6063
],
[
6065
],
[
6067
],
[
6069
],
[
6071,
6073,
6075
],
[
6077
],
[
6079
],
[
6081,
6083,
6085
],
[
6087
],
[
6089
],
[
6091
],
[
6093
],
[
6095
],
[
6097
],
[
6099
],
[
6101,
6103,
6105
],
[
6107
],
[
6109
],
[
6111
],
[
6113
],
[
6115
],
[
6117
],
[
6119
],
[
6121,
6123,
6125,
6127,
6129
],
[
6131
],
[
6133
],
[
6135
],
[
6137
],
[
6139
],
[
6141
],
[
6143
],
[
6145,
6147,
6149
],
[
6151
],
[
6153
],
[
6155
],
[
6157
],
[
6159
],
[
6161
],
[
6163
],
[
6165,
6167,
6169,
6171,
6173
],
[
6175
],
[
6177
],
[
6179,
6181,
6183
],
[
6185
],
[
6187
],
[
6189
],
[
6191
],
[
6193
],
[
6195
],
[
6197
],
[
6199,
6201
],
[
6203
],
[
6205
],
[
6207
],
[
6209
],
[
6211,
6213
],
[
6215
],
[
6217
],
[
6219
],
[
6221
],
[
6223,
6225
],
[
6227
],
[
6229
],
[
6231
],
[
6233
],
[
6235
],
[
6237
],
[
6239
],
[
6241
],
[
6243
],
[
6245,
6247
],
[
6249
],
[
6251
],
[
6253
],
[
6255,
6257
],
[
6259
],
[
6261
],
[
6263
],
[
6265
],
[
6267
],
[
6269
],
[
6271
],
[
6273
],
[
6275
],
[
6277,
6279
],
[
6281
],
[
6283
],
[
6285
],
[
6287,
6289
],
[
6293
],
[
6295
],
[
6297
],
[
6299
],
[
6301
],
[
6303,
6305
],
[
6307
],
[
6309
],
[
6311
],
[
6313,
6315
],
[
6317
],
[
6319
],
[
6321
],
[
6323
],
[
6325
],
[
6327
],
[
6329
],
[
6331
],
[
6333,
6335
],
[
6337
],
[
6339
],
[
6341,
6343,
6345
],
[
6347
],
[
6349
],
[
6351
],
[
6355
],
[
6357
],
[
6359,
6361,
6363
],
[
6365
],
[
6369
],
[
6373
],
[
6375
],
[
6377
],
[
6379
],
[
6383
],
[
6385
],
[
6389,
6391
],
[
6393
],
[
6395
],
[
6397
],
[
6399
],
[
6401
],
[
6403
],
[
6405
],
[
6407
],
[
6409
],
[
6411
],
[
6413
],
[
6415,
6417
],
[
6419
],
[
6421
],
[
6425,
6427
],
[
6429
],
[
6431
],
[
6433
],
[
6435
],
[
6437
],
[
6439
],
[
6441
],
[
6443
],
[
6445
],
[
6447
],
[
6449
],
[
6451
],
[
6453
],
[
6455
],
[
6457
],
[
6459
],
[
6461
],
[
6463
],
[
6465
],
[
6467
],
[
6469
],
[
6471
],
[
6473
],
[
6475
],
[
6477
],
[
6479
],
[
6481
],
[
6483
],
[
6485
],
[
6487,
6489
],
[
6491
],
[
6493
],
[
6495
],
[
6497
],
[
6499
],
[
6501
],
[
6503
],
[
6505
],
[
6507
],
[
6509,
6511,
6513
],
[
6515
],
[
6517
],
[
6519,
6521
],
[
6523
],
[
6525
],
[
6527
],
[
6529
],
[
6531
],
[
6533,
6535
],
[
6537,
6539
],
[
6541,
6543
],
[
6545
],
[
6547
],
[
6549
],
[
6551
],
[
6553
],
[
6555
],
[
6557
],
[
6559
],
[
6561
],
[
6563,
6565
],
[
6567
],
[
6569
],
[
6571
],
[
6573,
6575,
6577,
6579,
6581,
6583
],
[
6585
],
[
6589
],
[
6591,
6593
],
[
6595
],
[
6597
],
[
6599
],
[
6601,
6603
],
[
6605
],
[
6607
],
[
6609,
6611,
6613
],
[
6615
],
[
6617
],
[
6619
],
[
6621,
6623
],
[
6625
],
[
6627
],
[
6629,
6631
],
[
6633,
6635
],
[
6637
],
[
6639,
6641,
6643,
6645,
6647,
6649,
6651
],
[
6653
],
[
6655
],
[
6657
],
[
6659
],
[
6661
],
[
6663
],
[
6665
],
[
6667
],
[
6669
],
[
6671
],
[
6673
],
[
6675,
6677
],
[
6679
],
[
6681
],
[
6683
],
[
6685,
6687,
6689
],
[
6691
],
[
6693
],
[
6695
],
[
6697,
6699
],
[
6701
],
[
6703
],
[
6705,
6707
],
[
6709,
6711
],
[
6715,
6717
],
[
6719
],
[
6721
],
[
6723
],
[
6725
],
[
6727
],
[
6729
],
[
6731
],
[
6733
],
[
6735
],
[
6737
],
[
6739
],
[
6741
],
[
6743
],
[
6745,
6747
],
[
6749
],
[
6751
],
[
6753
],
[
6755
],
[
6759
],
[
6761
],
[
6763
],
[
6765
],
[
6769,
6771,
6773
],
[
6775
],
[
6777
],
[
6779
],
[
6781,
6783
],
[
6785
],
[
6789
],
[
6791
],
[
6793,
6795
],
[
6797
],
[
6799
],
[
6801
],
[
6803,
6805,
6807,
6809
],
[
6811
],
[
6813
],
[
6815
],
[
6817
],
[
6819
],
[
6821,
6823
],
[
6825
],
[
6827
],
[
6829
],
[
6831,
6833,
6835,
6837
],
[
6839
],
[
6841
],
[
6843
],
[
6845
],
[
6847
],
[
6849,
6851
],
[
6853
],
[
6855
],
[
6857
],
[
6859,
6861,
6863
],
[
6865
],
[
6867
],
[
6869
],
[
6871,
6873,
6875
],
[
6877
],
[
6879
],
[
6881
],
[
6883
],
[
6885
],
[
6887
],
[
6889
],
[
6891
],
[
6893
],
[
6895,
6897,
6899,
6901
],
[
6903
],
[
6905,
6907
],
[
6913,
6915
],
[
6917
],
[
6921,
6923
],
[
6925
],
[
6927
],
[
6929
],
[
6931,
6933
],
[
6935
],
[
6937
],
[
6939,
6941
],
[
6943
],
[
6945,
6947
],
[
6949
],
[
6953
],
[
6955,
6957
],
[
6959,
6961
],
[
6963
],
[
6965
],
[
6967
],
[
6969
],
[
6971
],
[
6973
],
[
6975
],
[
6977
],
[
6979,
6981,
6983,
6985
],
[
6987,
6989
],
[
6993
],
[
6995
],
[
6999,
7001
],
[
7003,
7005
],
[
7007,
7009
],
[
7013
],
[
7015
],
[
7017
],
[
7021
],
[
7023
],
[
7025,
7029
],
[
7031,
7033,
7035,
7037,
7039,
7041,
7043,
7045,
7047
],
[
7049
],
[
7051,
7053
],
[
7055
],
[
7059,
7061
],
[
7063
],
[
7065,
7067,
7069
],
[
7073
],
[
7075
],
[
7077
]
] |
3,556 | static void align_position(AVIOContext *pb, int64_t offset, uint64_t size)
{
if (avio_tell(pb) != offset + size)
avio_seek(pb, offset + size, SEEK_SET);
}
| true | FFmpeg | 74474750f1ac522730dae271a5ea5003caa8b73c | static void align_position(AVIOContext *pb, int64_t offset, uint64_t size)
{
if (avio_tell(pb) != offset + size)
avio_seek(pb, offset + size, SEEK_SET);
}
| {
"code": [
" if (avio_tell(pb) != offset + size)"
],
"line_no": [
5
]
} | static void FUNC_0(AVIOContext *VAR_0, int64_t VAR_1, uint64_t VAR_2)
{
if (avio_tell(VAR_0) != VAR_1 + VAR_2)
avio_seek(VAR_0, VAR_1 + VAR_2, SEEK_SET);
}
| [
"static void FUNC_0(AVIOContext *VAR_0, int64_t VAR_1, uint64_t VAR_2)\n{",
"if (avio_tell(VAR_0) != VAR_1 + VAR_2)\navio_seek(VAR_0, VAR_1 + VAR_2, SEEK_SET);",
"}"
] | [
0,
1,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
]
] |
3,557 | static int usb_serial_handle_data(USBDevice *dev, USBPacket *p)
{
USBSerialState *s = (USBSerialState *)dev;
int ret = 0;
uint8_t devep = p->devep;
uint8_t *data = p->data;
int len = p->len;
int first_len;
switch (p->pid) {
case USB_TOKEN_OUT:
if (devep != 2)
goto fail;
qemu_chr_write(s->cs, data, len);
break;
case USB_TOKEN_IN:
if (devep != 1)
goto fail;
first_len = RECV_BUF - s->recv_ptr;
if (len <= 2) {
ret = USB_RET_NAK;
break;
}
*data++ = usb_get_modem_lines(s) | 1;
/* We do not have the uart details */
/* handle serial break */
if (s->event_trigger && s->event_trigger & FTDI_BI) {
s->event_trigger &= ~FTDI_BI;
*data = FTDI_BI;
ret = 2;
break;
} else {
*data++ = 0;
}
len -= 2;
if (len > s->recv_used)
len = s->recv_used;
if (!len) {
ret = USB_RET_NAK;
break;
}
if (first_len > len)
first_len = len;
memcpy(data, s->recv_buf + s->recv_ptr, first_len);
if (len > first_len)
memcpy(data + first_len, s->recv_buf, len - first_len);
s->recv_used -= len;
s->recv_ptr = (s->recv_ptr + len) % RECV_BUF;
ret = len + 2;
break;
default:
DPRINTF("Bad token\n");
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| true | qemu | 4f4321c11ff6e98583846bfd6f0e81954924b003 | static int usb_serial_handle_data(USBDevice *dev, USBPacket *p)
{
USBSerialState *s = (USBSerialState *)dev;
int ret = 0;
uint8_t devep = p->devep;
uint8_t *data = p->data;
int len = p->len;
int first_len;
switch (p->pid) {
case USB_TOKEN_OUT:
if (devep != 2)
goto fail;
qemu_chr_write(s->cs, data, len);
break;
case USB_TOKEN_IN:
if (devep != 1)
goto fail;
first_len = RECV_BUF - s->recv_ptr;
if (len <= 2) {
ret = USB_RET_NAK;
break;
}
*data++ = usb_get_modem_lines(s) | 1;
if (s->event_trigger && s->event_trigger & FTDI_BI) {
s->event_trigger &= ~FTDI_BI;
*data = FTDI_BI;
ret = 2;
break;
} else {
*data++ = 0;
}
len -= 2;
if (len > s->recv_used)
len = s->recv_used;
if (!len) {
ret = USB_RET_NAK;
break;
}
if (first_len > len)
first_len = len;
memcpy(data, s->recv_buf + s->recv_ptr, first_len);
if (len > first_len)
memcpy(data + first_len, s->recv_buf, len - first_len);
s->recv_used -= len;
s->recv_ptr = (s->recv_ptr + len) % RECV_BUF;
ret = len + 2;
break;
default:
DPRINTF("Bad token\n");
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| {
"code": [
" uint8_t *data = p->data;",
" int len = p->len;",
" uint8_t *data = p->data;",
" int len = p->len;",
" uint8_t *data = p->data;",
" int len = p->len;"
],
"line_no": [
11,
13,
11,
13,
11,
13
]
} | static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)
{
USBSerialState *s = (USBSerialState *)VAR_0;
int VAR_2 = 0;
uint8_t devep = VAR_1->devep;
uint8_t *data = VAR_1->data;
int VAR_3 = VAR_1->VAR_3;
int VAR_4;
switch (VAR_1->pid) {
case USB_TOKEN_OUT:
if (devep != 2)
goto fail;
qemu_chr_write(s->cs, data, VAR_3);
break;
case USB_TOKEN_IN:
if (devep != 1)
goto fail;
VAR_4 = RECV_BUF - s->recv_ptr;
if (VAR_3 <= 2) {
VAR_2 = USB_RET_NAK;
break;
}
*data++ = usb_get_modem_lines(s) | 1;
if (s->event_trigger && s->event_trigger & FTDI_BI) {
s->event_trigger &= ~FTDI_BI;
*data = FTDI_BI;
VAR_2 = 2;
break;
} else {
*data++ = 0;
}
VAR_3 -= 2;
if (VAR_3 > s->recv_used)
VAR_3 = s->recv_used;
if (!VAR_3) {
VAR_2 = USB_RET_NAK;
break;
}
if (VAR_4 > VAR_3)
VAR_4 = VAR_3;
memcpy(data, s->recv_buf + s->recv_ptr, VAR_4);
if (VAR_3 > VAR_4)
memcpy(data + VAR_4, s->recv_buf, VAR_3 - VAR_4);
s->recv_used -= VAR_3;
s->recv_ptr = (s->recv_ptr + VAR_3) % RECV_BUF;
VAR_2 = VAR_3 + 2;
break;
default:
DPRINTF("Bad token\n");
fail:
VAR_2 = USB_RET_STALL;
break;
}
return VAR_2;
}
| [
"static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)\n{",
"USBSerialState *s = (USBSerialState *)VAR_0;",
"int VAR_2 = 0;",
"uint8_t devep = VAR_1->devep;",
"uint8_t *data = VAR_1->data;",
"int VAR_3 = VAR_1->VAR_3;",
"int VAR_4;",
"switch (VAR_1->pid) {",
"case USB_TOKEN_OUT:\nif (devep != 2)\ngoto fail;",
"qemu_chr_write(s->cs, data, VAR_3);",
"break;",
"case USB_TOKEN_IN:\nif (devep != 1)\ngoto fail;",
"VAR_4 = RECV_BUF - s->recv_ptr;",
"if (VAR_3 <= 2) {",
"VAR_2 = USB_RET_NAK;",
"break;",
"}",
"*data++ = usb_get_modem_lines(s) | 1;",
"if (s->event_trigger && s->event_trigger & FTDI_BI) {",
"s->event_trigger &= ~FTDI_BI;",
"*data = FTDI_BI;",
"VAR_2 = 2;",
"break;",
"} else {",
"*data++ = 0;",
"}",
"VAR_3 -= 2;",
"if (VAR_3 > s->recv_used)\nVAR_3 = s->recv_used;",
"if (!VAR_3) {",
"VAR_2 = USB_RET_NAK;",
"break;",
"}",
"if (VAR_4 > VAR_3)\nVAR_4 = VAR_3;",
"memcpy(data, s->recv_buf + s->recv_ptr, VAR_4);",
"if (VAR_3 > VAR_4)\nmemcpy(data + VAR_4, s->recv_buf, VAR_3 - VAR_4);",
"s->recv_used -= VAR_3;",
"s->recv_ptr = (s->recv_ptr + VAR_3) % RECV_BUF;",
"VAR_2 = VAR_3 + 2;",
"break;",
"default:\nDPRINTF(\"Bad token\\n\");",
"fail:\nVAR_2 = USB_RET_STALL;",
"break;",
"}",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21,
23,
25
],
[
27
],
[
29
],
[
33,
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85,
87
],
[
89
],
[
91,
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105,
107
],
[
109,
111
],
[
113
],
[
115
],
[
119
],
[
121
]
] |
3,558 | void isa_register_portio_list(ISADevice *dev, uint16_t start,
const MemoryRegionPortio *pio_start,
void *opaque, const char *name)
{
PortioList piolist;
/* START is how we should treat DEV, regardless of the actual
contents of the portio array. This is how the old code
actually handled e.g. the FDC device. */
isa_init_ioport(dev, start);
/* FIXME: the device should store created PortioList in its state. Note
that DEV can be NULL here and that single device can register several
portio lists. Current implementation is leaking memory allocated
in portio_list_init. The leak is not critical because it happens only
at initialization time. */
portio_list_init(&piolist, OBJECT(dev), pio_start, opaque, name);
portio_list_add(&piolist, isabus->address_space_io, start);
}
| true | qemu | e305a16510afa74eec20390479e349402e55ef4c | void isa_register_portio_list(ISADevice *dev, uint16_t start,
const MemoryRegionPortio *pio_start,
void *opaque, const char *name)
{
PortioList piolist;
isa_init_ioport(dev, start);
portio_list_init(&piolist, OBJECT(dev), pio_start, opaque, name);
portio_list_add(&piolist, isabus->address_space_io, start);
}
| {
"code": [
"void isa_register_portio_list(ISADevice *dev, uint16_t start,",
" PortioList piolist;",
" portio_list_init(&piolist, OBJECT(dev), pio_start, opaque, name);",
" portio_list_add(&piolist, isabus->address_space_io, start);",
"void isa_register_portio_list(ISADevice *dev, uint16_t start,"
],
"line_no": [
1,
9,
33,
35,
1
]
} | void FUNC_0(ISADevice *VAR_0, uint16_t VAR_1,
const MemoryRegionPortio *VAR_2,
void *VAR_3, const char *VAR_4)
{
PortioList piolist;
isa_init_ioport(VAR_0, VAR_1);
portio_list_init(&piolist, OBJECT(VAR_0), VAR_2, VAR_3, VAR_4);
portio_list_add(&piolist, isabus->address_space_io, VAR_1);
}
| [
"void FUNC_0(ISADevice *VAR_0, uint16_t VAR_1,\nconst MemoryRegionPortio *VAR_2,\nvoid *VAR_3, const char *VAR_4)\n{",
"PortioList piolist;",
"isa_init_ioport(VAR_0, VAR_1);",
"portio_list_init(&piolist, OBJECT(VAR_0), VAR_2, VAR_3, VAR_4);",
"portio_list_add(&piolist, isabus->address_space_io, VAR_1);",
"}"
] | [
1,
1,
0,
1,
1,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
19
],
[
33
],
[
35
],
[
37
]
] |
3,559 | static inline void write_mem(IVState *s, uint64_t off,
const void *buf, size_t len)
{
QTestState *qtest = global_qtest;
global_qtest = s->qtest;
qpci_memwrite(s->dev, s->mem_base + off, buf, len);
global_qtest = qtest;
}
| true | qemu | b4ba67d9a702507793c2724e56f98e9b0f7be02b | static inline void write_mem(IVState *s, uint64_t off,
const void *buf, size_t len)
{
QTestState *qtest = global_qtest;
global_qtest = s->qtest;
qpci_memwrite(s->dev, s->mem_base + off, buf, len);
global_qtest = qtest;
}
| {
"code": [
" qpci_memwrite(s->dev, s->mem_base + off, buf, len);"
],
"line_no": [
13
]
} | static inline void FUNC_0(IVState *VAR_0, uint64_t VAR_1,
const void *VAR_2, size_t VAR_3)
{
QTestState *qtest = global_qtest;
global_qtest = VAR_0->qtest;
qpci_memwrite(VAR_0->dev, VAR_0->mem_base + VAR_1, VAR_2, VAR_3);
global_qtest = qtest;
}
| [
"static inline void FUNC_0(IVState *VAR_0, uint64_t VAR_1,\nconst void *VAR_2, size_t VAR_3)\n{",
"QTestState *qtest = global_qtest;",
"global_qtest = VAR_0->qtest;",
"qpci_memwrite(VAR_0->dev, VAR_0->mem_base + VAR_1, VAR_2, VAR_3);",
"global_qtest = qtest;",
"}"
] | [
0,
0,
0,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
3,562 | static void qemu_mod_timer_ns(QEMUTimer *ts, int64_t expire_time)
{
QEMUTimer **pt, *t;
qemu_del_timer(ts);
/* add the timer in the sorted list */
/* NOTE: this code must be signal safe because
qemu_timer_expired() can be called from a signal. */
pt = &active_timers[ts->clock->type];
for(;;) {
t = *pt;
if (!t)
break;
if (t->expire_time > expire_time)
break;
pt = &t->next;
}
ts->expire_time = expire_time;
ts->next = *pt;
*pt = ts;
/* Rearm if necessary */
if (pt == &active_timers[ts->clock->type]) {
if (!alarm_timer->pending) {
qemu_rearm_alarm_timer(alarm_timer);
}
/* Interrupt execution to force deadline recalculation. */
if (use_icount)
qemu_notify_event();
}
}
| true | qemu | ab33fcda9f96b9195dfb3fcf5bd9bb5383caeaea | static void qemu_mod_timer_ns(QEMUTimer *ts, int64_t expire_time)
{
QEMUTimer **pt, *t;
qemu_del_timer(ts);
pt = &active_timers[ts->clock->type];
for(;;) {
t = *pt;
if (!t)
break;
if (t->expire_time > expire_time)
break;
pt = &t->next;
}
ts->expire_time = expire_time;
ts->next = *pt;
*pt = ts;
if (pt == &active_timers[ts->clock->type]) {
if (!alarm_timer->pending) {
qemu_rearm_alarm_timer(alarm_timer);
}
if (use_icount)
qemu_notify_event();
}
}
| {
"code": [
" if (use_icount)"
],
"line_no": [
57
]
} | static void FUNC_0(QEMUTimer *VAR_0, int64_t VAR_1)
{
QEMUTimer **pt, *t;
qemu_del_timer(VAR_0);
pt = &active_timers[VAR_0->clock->type];
for(;;) {
t = *pt;
if (!t)
break;
if (t->VAR_1 > VAR_1)
break;
pt = &t->next;
}
VAR_0->VAR_1 = VAR_1;
VAR_0->next = *pt;
*pt = VAR_0;
if (pt == &active_timers[VAR_0->clock->type]) {
if (!alarm_timer->pending) {
qemu_rearm_alarm_timer(alarm_timer);
}
if (use_icount)
qemu_notify_event();
}
}
| [
"static void FUNC_0(QEMUTimer *VAR_0, int64_t VAR_1)\n{",
"QEMUTimer **pt, *t;",
"qemu_del_timer(VAR_0);",
"pt = &active_timers[VAR_0->clock->type];",
"for(;;) {",
"t = *pt;",
"if (!t)\nbreak;",
"if (t->VAR_1 > VAR_1)\nbreak;",
"pt = &t->next;",
"}",
"VAR_0->VAR_1 = VAR_1;",
"VAR_0->next = *pt;",
"*pt = VAR_0;",
"if (pt == &active_timers[VAR_0->clock->type]) {",
"if (!alarm_timer->pending) {",
"qemu_rearm_alarm_timer(alarm_timer);",
"}",
"if (use_icount)\nqemu_notify_event();",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57,
59
],
[
61
],
[
63
]
] |
3,563 | static void co_read_response(void *opaque)
{
BDRVSheepdogState *s = opaque;
if (!s->co_recv) {
s->co_recv = qemu_coroutine_create(aio_read_response);
}
qemu_coroutine_enter(s->co_recv, opaque);
}
| true | qemu | 0b8b8753e4d94901627b3e86431230f2319215c4 | static void co_read_response(void *opaque)
{
BDRVSheepdogState *s = opaque;
if (!s->co_recv) {
s->co_recv = qemu_coroutine_create(aio_read_response);
}
qemu_coroutine_enter(s->co_recv, opaque);
}
| {
"code": [
" s->co_recv = qemu_coroutine_create(aio_read_response);",
" qemu_coroutine_enter(s->co_recv, opaque);"
],
"line_no": [
11,
17
]
} | static void FUNC_0(void *VAR_0)
{
BDRVSheepdogState *s = VAR_0;
if (!s->co_recv) {
s->co_recv = qemu_coroutine_create(aio_read_response);
}
qemu_coroutine_enter(s->co_recv, VAR_0);
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"BDRVSheepdogState *s = VAR_0;",
"if (!s->co_recv) {",
"s->co_recv = qemu_coroutine_create(aio_read_response);",
"}",
"qemu_coroutine_enter(s->co_recv, VAR_0);",
"}"
] | [
0,
0,
0,
1,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
]
] |
3,564 | static void omap2_inth_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) opaque;
int offset = addr;
int bank_no, line_no;
struct omap_intr_handler_bank_s *bank = NULL;
if ((offset & 0xf80) == 0x80) {
bank_no = (offset & 0x60) >> 5;
if (bank_no < s->nbanks) {
offset &= ~0x60;
bank = &s->bank[bank_no];
}
}
switch (offset) {
case 0x10: /* INTC_SYSCONFIG */
s->autoidle &= 4;
s->autoidle |= (value & 1) << 2;
if (value & 2) /* SOFTRESET */
omap_inth_reset(&s->busdev.qdev);
case 0x48: /* INTC_CONTROL */
s->mask = (value & 4) ? 0 : ~0; /* GLOBALMASK */
if (value & 2) { /* NEWFIQAGR */
qemu_set_irq(s->parent_intr[1], 0);
s->new_agr[1] = ~0;
omap_inth_update(s, 1);
}
if (value & 1) { /* NEWIRQAGR */
qemu_set_irq(s->parent_intr[0], 0);
s->new_agr[0] = ~0;
omap_inth_update(s, 0);
}
case 0x4c: /* INTC_PROTECTION */
/* TODO: Make a bitmap (or sizeof(char)map) of access privileges
* for every register, see Chapter 3 and 4 for privileged mode. */
if (value & 1)
fprintf(stderr, "%s: protection mode enable attempt\n",
__FUNCTION__);
case 0x50: /* INTC_IDLE */
s->autoidle &= ~3;
s->autoidle |= value & 3;
/* Per-bank registers */
case 0x84: /* INTC_MIR */
bank->mask = value;
omap_inth_update(s, 0);
omap_inth_update(s, 1);
case 0x88: /* INTC_MIR_CLEAR */
bank->mask &= ~value;
omap_inth_update(s, 0);
omap_inth_update(s, 1);
case 0x8c: /* INTC_MIR_SET */
bank->mask |= value;
case 0x90: /* INTC_ISR_SET */
bank->irqs |= bank->swi |= value;
omap_inth_update(s, 0);
omap_inth_update(s, 1);
case 0x94: /* INTC_ISR_CLEAR */
bank->swi &= ~value;
bank->irqs = bank->swi & bank->inputs;
/* Per-line registers */
case 0x100 ... 0x300: /* INTC_ILR */
bank_no = (offset - 0x100) >> 7;
if (bank_no > s->nbanks)
break;
bank = &s->bank[bank_no];
line_no = (offset & 0x7f) >> 2;
bank->priority[line_no] = (value >> 2) & 0x3f;
bank->fiq &= ~(1 << line_no);
bank->fiq |= (value & 1) << line_no;
case 0x00: /* INTC_REVISION */
case 0x14: /* INTC_SYSSTATUS */
case 0x40: /* INTC_SIR_IRQ */
case 0x44: /* INTC_SIR_FIQ */
case 0x80: /* INTC_ITR */
case 0x98: /* INTC_PENDING_IRQ */
case 0x9c: /* INTC_PENDING_FIQ */
OMAP_RO_REG(addr);
}
} | true | qemu | 096685fc2a955ea17d5363ab452e301be2b43873 | static void omap2_inth_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) opaque;
int offset = addr;
int bank_no, line_no;
struct omap_intr_handler_bank_s *bank = NULL;
if ((offset & 0xf80) == 0x80) {
bank_no = (offset & 0x60) >> 5;
if (bank_no < s->nbanks) {
offset &= ~0x60;
bank = &s->bank[bank_no];
}
}
switch (offset) {
case 0x10:
s->autoidle &= 4;
s->autoidle |= (value & 1) << 2;
if (value & 2)
omap_inth_reset(&s->busdev.qdev);
case 0x48:
s->mask = (value & 4) ? 0 : ~0;
if (value & 2) {
qemu_set_irq(s->parent_intr[1], 0);
s->new_agr[1] = ~0;
omap_inth_update(s, 1);
}
if (value & 1) {
qemu_set_irq(s->parent_intr[0], 0);
s->new_agr[0] = ~0;
omap_inth_update(s, 0);
}
case 0x4c:
if (value & 1)
fprintf(stderr, "%s: protection mode enable attempt\n",
__FUNCTION__);
case 0x50:
s->autoidle &= ~3;
s->autoidle |= value & 3;
case 0x84:
bank->mask = value;
omap_inth_update(s, 0);
omap_inth_update(s, 1);
case 0x88:
bank->mask &= ~value;
omap_inth_update(s, 0);
omap_inth_update(s, 1);
case 0x8c:
bank->mask |= value;
case 0x90:
bank->irqs |= bank->swi |= value;
omap_inth_update(s, 0);
omap_inth_update(s, 1);
case 0x94:
bank->swi &= ~value;
bank->irqs = bank->swi & bank->inputs;
case 0x100 ... 0x300:
bank_no = (offset - 0x100) >> 7;
if (bank_no > s->nbanks)
break;
bank = &s->bank[bank_no];
line_no = (offset & 0x7f) >> 2;
bank->priority[line_no] = (value >> 2) & 0x3f;
bank->fiq &= ~(1 << line_no);
bank->fiq |= (value & 1) << line_no;
case 0x00:
case 0x14:
case 0x40:
case 0x44:
case 0x80:
case 0x98:
case 0x9c:
OMAP_RO_REG(addr);
}
} | {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
struct omap_intr_handler_s *VAR_4 = (struct omap_intr_handler_s *) VAR_0;
int VAR_5 = VAR_1;
int VAR_6, VAR_7;
struct omap_intr_handler_bank_s *VAR_8 = NULL;
if ((VAR_5 & 0xf80) == 0x80) {
VAR_6 = (VAR_5 & 0x60) >> 5;
if (VAR_6 < VAR_4->nbanks) {
VAR_5 &= ~0x60;
VAR_8 = &VAR_4->VAR_8[VAR_6];
}
}
switch (VAR_5) {
case 0x10:
VAR_4->autoidle &= 4;
VAR_4->autoidle |= (VAR_2 & 1) << 2;
if (VAR_2 & 2)
omap_inth_reset(&VAR_4->busdev.qdev);
case 0x48:
VAR_4->mask = (VAR_2 & 4) ? 0 : ~0;
if (VAR_2 & 2) {
qemu_set_irq(VAR_4->parent_intr[1], 0);
VAR_4->new_agr[1] = ~0;
omap_inth_update(VAR_4, 1);
}
if (VAR_2 & 1) {
qemu_set_irq(VAR_4->parent_intr[0], 0);
VAR_4->new_agr[0] = ~0;
omap_inth_update(VAR_4, 0);
}
case 0x4c:
if (VAR_2 & 1)
fprintf(stderr, "%VAR_4: protection mode enable attempt\n",
__FUNCTION__);
case 0x50:
VAR_4->autoidle &= ~3;
VAR_4->autoidle |= VAR_2 & 3;
case 0x84:
VAR_8->mask = VAR_2;
omap_inth_update(VAR_4, 0);
omap_inth_update(VAR_4, 1);
case 0x88:
VAR_8->mask &= ~VAR_2;
omap_inth_update(VAR_4, 0);
omap_inth_update(VAR_4, 1);
case 0x8c:
VAR_8->mask |= VAR_2;
case 0x90:
VAR_8->irqs |= VAR_8->swi |= VAR_2;
omap_inth_update(VAR_4, 0);
omap_inth_update(VAR_4, 1);
case 0x94:
VAR_8->swi &= ~VAR_2;
VAR_8->irqs = VAR_8->swi & VAR_8->inputs;
case 0x100 ... 0x300:
VAR_6 = (VAR_5 - 0x100) >> 7;
if (VAR_6 > VAR_4->nbanks)
break;
VAR_8 = &VAR_4->VAR_8[VAR_6];
VAR_7 = (VAR_5 & 0x7f) >> 2;
VAR_8->priority[VAR_7] = (VAR_2 >> 2) & 0x3f;
VAR_8->fiq &= ~(1 << VAR_7);
VAR_8->fiq |= (VAR_2 & 1) << VAR_7;
case 0x00:
case 0x14:
case 0x40:
case 0x44:
case 0x80:
case 0x98:
case 0x9c:
OMAP_RO_REG(VAR_1);
}
} | [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"struct omap_intr_handler_s *VAR_4 = (struct omap_intr_handler_s *) VAR_0;",
"int VAR_5 = VAR_1;",
"int VAR_6, VAR_7;",
"struct omap_intr_handler_bank_s *VAR_8 = NULL;",
"if ((VAR_5 & 0xf80) == 0x80) {",
"VAR_6 = (VAR_5 & 0x60) >> 5;",
"if (VAR_6 < VAR_4->nbanks) {",
"VAR_5 &= ~0x60;",
"VAR_8 = &VAR_4->VAR_8[VAR_6];",
"}",
"}",
"switch (VAR_5) {",
"case 0x10:\nVAR_4->autoidle &= 4;",
"VAR_4->autoidle |= (VAR_2 & 1) << 2;",
"if (VAR_2 & 2)\nomap_inth_reset(&VAR_4->busdev.qdev);",
"case 0x48:\nVAR_4->mask = (VAR_2 & 4) ? 0 : ~0;",
"if (VAR_2 & 2) {",
"qemu_set_irq(VAR_4->parent_intr[1], 0);",
"VAR_4->new_agr[1] = ~0;",
"omap_inth_update(VAR_4, 1);",
"}",
"if (VAR_2 & 1) {",
"qemu_set_irq(VAR_4->parent_intr[0], 0);",
"VAR_4->new_agr[0] = ~0;",
"omap_inth_update(VAR_4, 0);",
"}",
"case 0x4c:\nif (VAR_2 & 1)\nfprintf(stderr, \"%VAR_4: protection mode enable attempt\\n\",\n__FUNCTION__);",
"case 0x50:\nVAR_4->autoidle &= ~3;",
"VAR_4->autoidle |= VAR_2 & 3;",
"case 0x84:\nVAR_8->mask = VAR_2;",
"omap_inth_update(VAR_4, 0);",
"omap_inth_update(VAR_4, 1);",
"case 0x88:\nVAR_8->mask &= ~VAR_2;",
"omap_inth_update(VAR_4, 0);",
"omap_inth_update(VAR_4, 1);",
"case 0x8c:\nVAR_8->mask |= VAR_2;",
"case 0x90:\nVAR_8->irqs |= VAR_8->swi |= VAR_2;",
"omap_inth_update(VAR_4, 0);",
"omap_inth_update(VAR_4, 1);",
"case 0x94:\nVAR_8->swi &= ~VAR_2;",
"VAR_8->irqs = VAR_8->swi & VAR_8->inputs;",
"case 0x100 ... 0x300:\nVAR_6 = (VAR_5 - 0x100) >> 7;",
"if (VAR_6 > VAR_4->nbanks)\nbreak;",
"VAR_8 = &VAR_4->VAR_8[VAR_6];",
"VAR_7 = (VAR_5 & 0x7f) >> 2;",
"VAR_8->priority[VAR_7] = (VAR_2 >> 2) & 0x3f;",
"VAR_8->fiq &= ~(1 << VAR_7);",
"VAR_8->fiq |= (VAR_2 & 1) << VAR_7;",
"case 0x00:\ncase 0x14:\ncase 0x40:\ncase 0x44:\ncase 0x80:\ncase 0x98:\ncase 0x9c:\nOMAP_RO_REG(VAR_1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
30
],
[
32
],
[
36
],
[
38,
40
],
[
42
],
[
44,
46
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
78,
84,
86,
88
],
[
93,
95
],
[
97
],
[
104,
106
],
[
108
],
[
110
],
[
115,
117
],
[
119
],
[
121
],
[
126,
128
],
[
133,
135
],
[
137
],
[
139
],
[
144,
146
],
[
148
],
[
155,
157
],
[
159,
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
176,
178,
180,
182,
184,
186,
188,
190
],
[
193
],
[
196
]
] |
3,565 | static int decode_hextile(VmncContext *c, uint8_t* dst, uint8_t* src, int w, int h, int stride)
{
int i, j, k;
int bg = 0, fg = 0, rects, color, flags, xy, wh;
const int bpp = c->bpp2;
uint8_t *dst2;
int bw = 16, bh = 16;
uint8_t *ssrc=src;
for(j = 0; j < h; j += 16) {
dst2 = dst;
bw = 16;
if(j + 16 > h) bh = h - j;
for(i = 0; i < w; i += 16, dst2 += 16 * bpp) {
if(i + 16 > w) bw = w - i;
flags = *src++;
if(flags & HT_RAW) {
paint_raw(dst2, bw, bh, src, bpp, c->bigendian, stride);
src += bw * bh * bpp;
} else {
if(flags & HT_BKG) {
bg = vmnc_get_pixel(src, bpp, c->bigendian); src += bpp;
}
if(flags & HT_FG) {
fg = vmnc_get_pixel(src, bpp, c->bigendian); src += bpp;
}
rects = 0;
if(flags & HT_SUB)
rects = *src++;
color = (flags & HT_CLR);
paint_rect(dst2, 0, 0, bw, bh, bg, bpp, stride);
for(k = 0; k < rects; k++) {
if(color) {
fg = vmnc_get_pixel(src, bpp, c->bigendian); src += bpp;
}
xy = *src++;
wh = *src++;
paint_rect(dst2, xy >> 4, xy & 0xF, (wh>>4)+1, (wh & 0xF)+1, fg, bpp, stride);
}
}
}
dst += stride * 16;
}
return src - ssrc;
}
| true | FFmpeg | 096bc417ae9b5bf35631d48fbc798020aac08aee | static int decode_hextile(VmncContext *c, uint8_t* dst, uint8_t* src, int w, int h, int stride)
{
int i, j, k;
int bg = 0, fg = 0, rects, color, flags, xy, wh;
const int bpp = c->bpp2;
uint8_t *dst2;
int bw = 16, bh = 16;
uint8_t *ssrc=src;
for(j = 0; j < h; j += 16) {
dst2 = dst;
bw = 16;
if(j + 16 > h) bh = h - j;
for(i = 0; i < w; i += 16, dst2 += 16 * bpp) {
if(i + 16 > w) bw = w - i;
flags = *src++;
if(flags & HT_RAW) {
paint_raw(dst2, bw, bh, src, bpp, c->bigendian, stride);
src += bw * bh * bpp;
} else {
if(flags & HT_BKG) {
bg = vmnc_get_pixel(src, bpp, c->bigendian); src += bpp;
}
if(flags & HT_FG) {
fg = vmnc_get_pixel(src, bpp, c->bigendian); src += bpp;
}
rects = 0;
if(flags & HT_SUB)
rects = *src++;
color = (flags & HT_CLR);
paint_rect(dst2, 0, 0, bw, bh, bg, bpp, stride);
for(k = 0; k < rects; k++) {
if(color) {
fg = vmnc_get_pixel(src, bpp, c->bigendian); src += bpp;
}
xy = *src++;
wh = *src++;
paint_rect(dst2, xy >> 4, xy & 0xF, (wh>>4)+1, (wh & 0xF)+1, fg, bpp, stride);
}
}
}
dst += stride * 16;
}
return src - ssrc;
}
| {
"code": [
"static int decode_hextile(VmncContext *c, uint8_t* dst, uint8_t* src, int w, int h, int stride)",
" color = (flags & HT_CLR);"
],
"line_no": [
1,
59
]
} | static int FUNC_0(VmncContext *VAR_0, uint8_t* VAR_1, uint8_t* VAR_2, int VAR_3, int VAR_4, int VAR_5)
{
int VAR_6, VAR_7, VAR_8;
int VAR_9 = 0, VAR_10 = 0, VAR_11, VAR_12, VAR_13, VAR_14, VAR_15;
const int VAR_16 = VAR_0->bpp2;
uint8_t *dst2;
int VAR_17 = 16, VAR_18 = 16;
uint8_t *ssrc=VAR_2;
for(VAR_7 = 0; VAR_7 < VAR_4; VAR_7 += 16) {
dst2 = VAR_1;
VAR_17 = 16;
if(VAR_7 + 16 > VAR_4) VAR_18 = VAR_4 - VAR_7;
for(VAR_6 = 0; VAR_6 < VAR_3; VAR_6 += 16, dst2 += 16 * VAR_16) {
if(VAR_6 + 16 > VAR_3) VAR_17 = VAR_3 - VAR_6;
VAR_13 = *VAR_2++;
if(VAR_13 & HT_RAW) {
paint_raw(dst2, VAR_17, VAR_18, VAR_2, VAR_16, VAR_0->bigendian, VAR_5);
VAR_2 += VAR_17 * VAR_18 * VAR_16;
} else {
if(VAR_13 & HT_BKG) {
VAR_9 = vmnc_get_pixel(VAR_2, VAR_16, VAR_0->bigendian); VAR_2 += VAR_16;
}
if(VAR_13 & HT_FG) {
VAR_10 = vmnc_get_pixel(VAR_2, VAR_16, VAR_0->bigendian); VAR_2 += VAR_16;
}
VAR_11 = 0;
if(VAR_13 & HT_SUB)
VAR_11 = *VAR_2++;
VAR_12 = (VAR_13 & HT_CLR);
paint_rect(dst2, 0, 0, VAR_17, VAR_18, VAR_9, VAR_16, VAR_5);
for(VAR_8 = 0; VAR_8 < VAR_11; VAR_8++) {
if(VAR_12) {
VAR_10 = vmnc_get_pixel(VAR_2, VAR_16, VAR_0->bigendian); VAR_2 += VAR_16;
}
VAR_14 = *VAR_2++;
VAR_15 = *VAR_2++;
paint_rect(dst2, VAR_14 >> 4, VAR_14 & 0xF, (VAR_15>>4)+1, (VAR_15 & 0xF)+1, VAR_10, VAR_16, VAR_5);
}
}
}
VAR_1 += VAR_5 * 16;
}
return VAR_2 - ssrc;
}
| [
"static int FUNC_0(VmncContext *VAR_0, uint8_t* VAR_1, uint8_t* VAR_2, int VAR_3, int VAR_4, int VAR_5)\n{",
"int VAR_6, VAR_7, VAR_8;",
"int VAR_9 = 0, VAR_10 = 0, VAR_11, VAR_12, VAR_13, VAR_14, VAR_15;",
"const int VAR_16 = VAR_0->bpp2;",
"uint8_t *dst2;",
"int VAR_17 = 16, VAR_18 = 16;",
"uint8_t *ssrc=VAR_2;",
"for(VAR_7 = 0; VAR_7 < VAR_4; VAR_7 += 16) {",
"dst2 = VAR_1;",
"VAR_17 = 16;",
"if(VAR_7 + 16 > VAR_4) VAR_18 = VAR_4 - VAR_7;",
"for(VAR_6 = 0; VAR_6 < VAR_3; VAR_6 += 16, dst2 += 16 * VAR_16) {",
"if(VAR_6 + 16 > VAR_3) VAR_17 = VAR_3 - VAR_6;",
"VAR_13 = *VAR_2++;",
"if(VAR_13 & HT_RAW) {",
"paint_raw(dst2, VAR_17, VAR_18, VAR_2, VAR_16, VAR_0->bigendian, VAR_5);",
"VAR_2 += VAR_17 * VAR_18 * VAR_16;",
"} else {",
"if(VAR_13 & HT_BKG) {",
"VAR_9 = vmnc_get_pixel(VAR_2, VAR_16, VAR_0->bigendian); VAR_2 += VAR_16;",
"}",
"if(VAR_13 & HT_FG) {",
"VAR_10 = vmnc_get_pixel(VAR_2, VAR_16, VAR_0->bigendian); VAR_2 += VAR_16;",
"}",
"VAR_11 = 0;",
"if(VAR_13 & HT_SUB)\nVAR_11 = *VAR_2++;",
"VAR_12 = (VAR_13 & HT_CLR);",
"paint_rect(dst2, 0, 0, VAR_17, VAR_18, VAR_9, VAR_16, VAR_5);",
"for(VAR_8 = 0; VAR_8 < VAR_11; VAR_8++) {",
"if(VAR_12) {",
"VAR_10 = vmnc_get_pixel(VAR_2, VAR_16, VAR_0->bigendian); VAR_2 += VAR_16;",
"}",
"VAR_14 = *VAR_2++;",
"VAR_15 = *VAR_2++;",
"paint_rect(dst2, VAR_14 >> 4, VAR_14 & 0xF, (VAR_15>>4)+1, (VAR_15 & 0xF)+1, VAR_10, VAR_16, VAR_5);",
"}",
"}",
"}",
"VAR_1 += VAR_5 * 16;",
"}",
"return VAR_2 - ssrc;",
"}"
] | [
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,
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
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
]
] |
3,567 | static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, int16_t bS[4], int bsi, int qp ) {
int i;
int index_a = qp + h->slice_alpha_c0_offset;
int alpha = (alpha_table+52)[index_a];
int beta = (beta_table+52)[qp + h->slice_beta_offset];
for( i = 0; i < 8; i++, pix += stride) {
const int bS_index = (i >> 1) * bsi;
if( bS[bS_index] == 0 ) {
continue;
}
if( bS[bS_index] < 4 ) {
const int tc0 = (tc0_table+52)[index_a][bS[bS_index]];
const int p0 = pix[-1];
const int p1 = pix[-2];
const int p2 = pix[-3];
const int q0 = pix[0];
const int q1 = pix[1];
const int q2 = pix[2];
if( FFABS( p0 - q0 ) < alpha &&
FFABS( p1 - p0 ) < beta &&
FFABS( q1 - q0 ) < beta ) {
int tc = tc0;
int i_delta;
if( FFABS( p2 - p0 ) < beta ) {
if(tc0)
pix[-2] = p1 + av_clip( ( p2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( p1 << 1 ) ) >> 1, -tc0, tc0 );
tc++;
}
if( FFABS( q2 - q0 ) < beta ) {
if(tc0)
pix[1] = q1 + av_clip( ( q2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( q1 << 1 ) ) >> 1, -tc0, tc0 );
tc++;
}
i_delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
pix[-1] = av_clip_uint8( p0 + i_delta ); /* p0' */
pix[0] = av_clip_uint8( q0 - i_delta ); /* q0' */
tprintf(h->s.avctx, "filter_mb_mbaff_edgev i:%d, qp:%d, indexA:%d, alpha:%d, beta:%d, tc:%d\n# bS:%d -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x]\n", i, qp[qp_index], index_a, alpha, beta, tc, bS[bS_index], pix[-3], p1, p0, q0, q1, pix[2], p1, pix[-1], pix[0], q1);
}
}else{
const int p0 = pix[-1];
const int p1 = pix[-2];
const int p2 = pix[-3];
const int q0 = pix[0];
const int q1 = pix[1];
const int q2 = pix[2];
if( FFABS( p0 - q0 ) < alpha &&
FFABS( p1 - p0 ) < beta &&
FFABS( q1 - q0 ) < beta ) {
if(FFABS( p0 - q0 ) < (( alpha >> 2 ) + 2 )){
if( FFABS( p2 - p0 ) < beta)
{
const int p3 = pix[-4];
/* p0', p1', p2' */
pix[-1] = ( p2 + 2*p1 + 2*p0 + 2*q0 + q1 + 4 ) >> 3;
pix[-2] = ( p2 + p1 + p0 + q0 + 2 ) >> 2;
pix[-3] = ( 2*p3 + 3*p2 + p1 + p0 + q0 + 4 ) >> 3;
} else {
/* p0' */
pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
}
if( FFABS( q2 - q0 ) < beta)
{
const int q3 = pix[3];
/* q0', q1', q2' */
pix[0] = ( p1 + 2*p0 + 2*q0 + 2*q1 + q2 + 4 ) >> 3;
pix[1] = ( p0 + q0 + q1 + q2 + 2 ) >> 2;
pix[2] = ( 2*q3 + 3*q2 + q1 + q0 + p0 + 4 ) >> 3;
} else {
/* q0' */
pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2;
}
}else{
/* p0', q0' */
pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
pix[ 0] = ( 2*q1 + q0 + p1 + 2 ) >> 2;
}
tprintf(h->s.avctx, "filter_mb_mbaff_edgev i:%d, qp:%d, indexA:%d, alpha:%d, beta:%d\n# bS:4 -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x, %02x, %02x]\n", i, qp[qp_index], index_a, alpha, beta, p2, p1, p0, q0, q1, q2, pix[-3], pix[-2], pix[-1], pix[0], pix[1], pix[2]);
}
}
}
}
| false | FFmpeg | 0c32e19d584ba6ddbc27f0a796260404daaf4b6a | static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, int16_t bS[4], int bsi, int qp ) {
int i;
int index_a = qp + h->slice_alpha_c0_offset;
int alpha = (alpha_table+52)[index_a];
int beta = (beta_table+52)[qp + h->slice_beta_offset];
for( i = 0; i < 8; i++, pix += stride) {
const int bS_index = (i >> 1) * bsi;
if( bS[bS_index] == 0 ) {
continue;
}
if( bS[bS_index] < 4 ) {
const int tc0 = (tc0_table+52)[index_a][bS[bS_index]];
const int p0 = pix[-1];
const int p1 = pix[-2];
const int p2 = pix[-3];
const int q0 = pix[0];
const int q1 = pix[1];
const int q2 = pix[2];
if( FFABS( p0 - q0 ) < alpha &&
FFABS( p1 - p0 ) < beta &&
FFABS( q1 - q0 ) < beta ) {
int tc = tc0;
int i_delta;
if( FFABS( p2 - p0 ) < beta ) {
if(tc0)
pix[-2] = p1 + av_clip( ( p2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( p1 << 1 ) ) >> 1, -tc0, tc0 );
tc++;
}
if( FFABS( q2 - q0 ) < beta ) {
if(tc0)
pix[1] = q1 + av_clip( ( q2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( q1 << 1 ) ) >> 1, -tc0, tc0 );
tc++;
}
i_delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
pix[-1] = av_clip_uint8( p0 + i_delta );
pix[0] = av_clip_uint8( q0 - i_delta );
tprintf(h->s.avctx, "filter_mb_mbaff_edgev i:%d, qp:%d, indexA:%d, alpha:%d, beta:%d, tc:%d\n# bS:%d -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x]\n", i, qp[qp_index], index_a, alpha, beta, tc, bS[bS_index], pix[-3], p1, p0, q0, q1, pix[2], p1, pix[-1], pix[0], q1);
}
}else{
const int p0 = pix[-1];
const int p1 = pix[-2];
const int p2 = pix[-3];
const int q0 = pix[0];
const int q1 = pix[1];
const int q2 = pix[2];
if( FFABS( p0 - q0 ) < alpha &&
FFABS( p1 - p0 ) < beta &&
FFABS( q1 - q0 ) < beta ) {
if(FFABS( p0 - q0 ) < (( alpha >> 2 ) + 2 )){
if( FFABS( p2 - p0 ) < beta)
{
const int p3 = pix[-4];
pix[-1] = ( p2 + 2*p1 + 2*p0 + 2*q0 + q1 + 4 ) >> 3;
pix[-2] = ( p2 + p1 + p0 + q0 + 2 ) >> 2;
pix[-3] = ( 2*p3 + 3*p2 + p1 + p0 + q0 + 4 ) >> 3;
} else {
pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
}
if( FFABS( q2 - q0 ) < beta)
{
const int q3 = pix[3];
pix[0] = ( p1 + 2*p0 + 2*q0 + 2*q1 + q2 + 4 ) >> 3;
pix[1] = ( p0 + q0 + q1 + q2 + 2 ) >> 2;
pix[2] = ( 2*q3 + 3*q2 + q1 + q0 + p0 + 4 ) >> 3;
} else {
pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2;
}
}else{
pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
pix[ 0] = ( 2*q1 + q0 + p1 + 2 ) >> 2;
}
tprintf(h->s.avctx, "filter_mb_mbaff_edgev i:%d, qp:%d, indexA:%d, alpha:%d, beta:%d\n# bS:4 -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x, %02x, %02x]\n", i, qp[qp_index], index_a, alpha, beta, p2, p1, p0, q0, q1, q2, pix[-3], pix[-2], pix[-1], pix[0], pix[1], pix[2]);
}
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0( H264Context *VAR_0, uint8_t *VAR_1, int VAR_2, int16_t VAR_3[4], int VAR_4, int VAR_5 ) {
int VAR_6;
int VAR_7 = VAR_5 + VAR_0->slice_alpha_c0_offset;
int VAR_8 = (alpha_table+52)[VAR_7];
int VAR_9 = (beta_table+52)[VAR_5 + VAR_0->slice_beta_offset];
for( VAR_6 = 0; VAR_6 < 8; VAR_6++, VAR_1 += VAR_2) {
const int VAR_10 = (VAR_6 >> 1) * VAR_4;
if( VAR_3[VAR_10] == 0 ) {
continue;
}
if( VAR_3[VAR_10] < 4 ) {
const int VAR_11 = (tc0_table+52)[VAR_7][VAR_3[VAR_10]];
const int VAR_20 = VAR_1[-1];
const int VAR_20 = VAR_1[-2];
const int VAR_20 = VAR_1[-3];
const int VAR_20 = VAR_1[0];
const int VAR_20 = VAR_1[1];
const int VAR_20 = VAR_1[2];
if( FFABS( VAR_20 - VAR_20 ) < VAR_8 &&
FFABS( VAR_20 - VAR_20 ) < VAR_9 &&
FFABS( VAR_20 - VAR_20 ) < VAR_9 ) {
int VAR_18 = VAR_11;
int VAR_19;
if( FFABS( VAR_20 - VAR_20 ) < VAR_9 ) {
if(VAR_11)
VAR_1[-2] = VAR_20 + av_clip( ( VAR_20 + ( ( VAR_20 + VAR_20 + 1 ) >> 1 ) - ( VAR_20 << 1 ) ) >> 1, -VAR_11, VAR_11 );
VAR_18++;
}
if( FFABS( VAR_20 - VAR_20 ) < VAR_9 ) {
if(VAR_11)
VAR_1[1] = VAR_20 + av_clip( ( VAR_20 + ( ( VAR_20 + VAR_20 + 1 ) >> 1 ) - ( VAR_20 << 1 ) ) >> 1, -VAR_11, VAR_11 );
VAR_18++;
}
VAR_19 = av_clip( (((VAR_20 - VAR_20 ) << 2) + (VAR_20 - VAR_20) + 4) >> 3, -VAR_18, VAR_18 );
VAR_1[-1] = av_clip_uint8( VAR_20 + VAR_19 );
VAR_1[0] = av_clip_uint8( VAR_20 - VAR_19 );
tprintf(VAR_0->s.avctx, "FUNC_0 VAR_6:%d, VAR_5:%d, indexA:%d, VAR_8:%d, VAR_9:%d, VAR_18:%d\n# VAR_3:%d -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x]\n", VAR_6, VAR_5[qp_index], VAR_7, VAR_8, VAR_9, VAR_18, VAR_3[VAR_10], VAR_1[-3], VAR_20, VAR_20, VAR_20, VAR_20, VAR_1[2], VAR_20, VAR_1[-1], VAR_1[0], VAR_20);
}
}else{
const int VAR_20 = VAR_1[-1];
const int VAR_20 = VAR_1[-2];
const int VAR_20 = VAR_1[-3];
const int VAR_20 = VAR_1[0];
const int VAR_20 = VAR_1[1];
const int VAR_20 = VAR_1[2];
if( FFABS( VAR_20 - VAR_20 ) < VAR_8 &&
FFABS( VAR_20 - VAR_20 ) < VAR_9 &&
FFABS( VAR_20 - VAR_20 ) < VAR_9 ) {
if(FFABS( VAR_20 - VAR_20 ) < (( VAR_8 >> 2 ) + 2 )){
if( FFABS( VAR_20 - VAR_20 ) < VAR_9)
{
const int VAR_20 = VAR_1[-4];
VAR_1[-1] = ( VAR_20 + 2*VAR_20 + 2*VAR_20 + 2*VAR_20 + VAR_20 + 4 ) >> 3;
VAR_1[-2] = ( VAR_20 + VAR_20 + VAR_20 + VAR_20 + 2 ) >> 2;
VAR_1[-3] = ( 2*VAR_20 + 3*VAR_20 + VAR_20 + VAR_20 + VAR_20 + 4 ) >> 3;
} else {
VAR_1[-1] = ( 2*VAR_20 + VAR_20 + VAR_20 + 2 ) >> 2;
}
if( FFABS( VAR_20 - VAR_20 ) < VAR_9)
{
const int VAR_21 = VAR_1[3];
VAR_1[0] = ( VAR_20 + 2*VAR_20 + 2*VAR_20 + 2*VAR_20 + VAR_20 + 4 ) >> 3;
VAR_1[1] = ( VAR_20 + VAR_20 + VAR_20 + VAR_20 + 2 ) >> 2;
VAR_1[2] = ( 2*VAR_21 + 3*VAR_20 + VAR_20 + VAR_20 + VAR_20 + 4 ) >> 3;
} else {
VAR_1[0] = ( 2*VAR_20 + VAR_20 + VAR_20 + 2 ) >> 2;
}
}else{
VAR_1[-1] = ( 2*VAR_20 + VAR_20 + VAR_20 + 2 ) >> 2;
VAR_1[ 0] = ( 2*VAR_20 + VAR_20 + VAR_20 + 2 ) >> 2;
}
tprintf(VAR_0->s.avctx, "FUNC_0 VAR_6:%d, VAR_5:%d, indexA:%d, VAR_8:%d, VAR_9:%d\n# VAR_3:4 -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x, %02x, %02x]\n", VAR_6, VAR_5[qp_index], VAR_7, VAR_8, VAR_9, VAR_20, VAR_20, VAR_20, VAR_20, VAR_20, VAR_20, VAR_1[-3], VAR_1[-2], VAR_1[-1], VAR_1[0], VAR_1[1], VAR_1[2]);
}
}
}
}
| [
"static void FUNC_0( H264Context *VAR_0, uint8_t *VAR_1, int VAR_2, int16_t VAR_3[4], int VAR_4, int VAR_5 ) {",
"int VAR_6;",
"int VAR_7 = VAR_5 + VAR_0->slice_alpha_c0_offset;",
"int VAR_8 = (alpha_table+52)[VAR_7];",
"int VAR_9 = (beta_table+52)[VAR_5 + VAR_0->slice_beta_offset];",
"for( VAR_6 = 0; VAR_6 < 8; VAR_6++, VAR_1 += VAR_2) {",
"const int VAR_10 = (VAR_6 >> 1) * VAR_4;",
"if( VAR_3[VAR_10] == 0 ) {",
"continue;",
"}",
"if( VAR_3[VAR_10] < 4 ) {",
"const int VAR_11 = (tc0_table+52)[VAR_7][VAR_3[VAR_10]];",
"const int VAR_20 = VAR_1[-1];",
"const int VAR_20 = VAR_1[-2];",
"const int VAR_20 = VAR_1[-3];",
"const int VAR_20 = VAR_1[0];",
"const int VAR_20 = VAR_1[1];",
"const int VAR_20 = VAR_1[2];",
"if( FFABS( VAR_20 - VAR_20 ) < VAR_8 &&\nFFABS( VAR_20 - VAR_20 ) < VAR_9 &&\nFFABS( VAR_20 - VAR_20 ) < VAR_9 ) {",
"int VAR_18 = VAR_11;",
"int VAR_19;",
"if( FFABS( VAR_20 - VAR_20 ) < VAR_9 ) {",
"if(VAR_11)\nVAR_1[-2] = VAR_20 + av_clip( ( VAR_20 + ( ( VAR_20 + VAR_20 + 1 ) >> 1 ) - ( VAR_20 << 1 ) ) >> 1, -VAR_11, VAR_11 );",
"VAR_18++;",
"}",
"if( FFABS( VAR_20 - VAR_20 ) < VAR_9 ) {",
"if(VAR_11)\nVAR_1[1] = VAR_20 + av_clip( ( VAR_20 + ( ( VAR_20 + VAR_20 + 1 ) >> 1 ) - ( VAR_20 << 1 ) ) >> 1, -VAR_11, VAR_11 );",
"VAR_18++;",
"}",
"VAR_19 = av_clip( (((VAR_20 - VAR_20 ) << 2) + (VAR_20 - VAR_20) + 4) >> 3, -VAR_18, VAR_18 );",
"VAR_1[-1] = av_clip_uint8( VAR_20 + VAR_19 );",
"VAR_1[0] = av_clip_uint8( VAR_20 - VAR_19 );",
"tprintf(VAR_0->s.avctx, \"FUNC_0 VAR_6:%d, VAR_5:%d, indexA:%d, VAR_8:%d, VAR_9:%d, VAR_18:%d\\n# VAR_3:%d -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x]\\n\", VAR_6, VAR_5[qp_index], VAR_7, VAR_8, VAR_9, VAR_18, VAR_3[VAR_10], VAR_1[-3], VAR_20, VAR_20, VAR_20, VAR_20, VAR_1[2], VAR_20, VAR_1[-1], VAR_1[0], VAR_20);",
"}",
"}else{",
"const int VAR_20 = VAR_1[-1];",
"const int VAR_20 = VAR_1[-2];",
"const int VAR_20 = VAR_1[-3];",
"const int VAR_20 = VAR_1[0];",
"const int VAR_20 = VAR_1[1];",
"const int VAR_20 = VAR_1[2];",
"if( FFABS( VAR_20 - VAR_20 ) < VAR_8 &&\nFFABS( VAR_20 - VAR_20 ) < VAR_9 &&\nFFABS( VAR_20 - VAR_20 ) < VAR_9 ) {",
"if(FFABS( VAR_20 - VAR_20 ) < (( VAR_8 >> 2 ) + 2 )){",
"if( FFABS( VAR_20 - VAR_20 ) < VAR_9)\n{",
"const int VAR_20 = VAR_1[-4];",
"VAR_1[-1] = ( VAR_20 + 2*VAR_20 + 2*VAR_20 + 2*VAR_20 + VAR_20 + 4 ) >> 3;",
"VAR_1[-2] = ( VAR_20 + VAR_20 + VAR_20 + VAR_20 + 2 ) >> 2;",
"VAR_1[-3] = ( 2*VAR_20 + 3*VAR_20 + VAR_20 + VAR_20 + VAR_20 + 4 ) >> 3;",
"} else {",
"VAR_1[-1] = ( 2*VAR_20 + VAR_20 + VAR_20 + 2 ) >> 2;",
"}",
"if( FFABS( VAR_20 - VAR_20 ) < VAR_9)\n{",
"const int VAR_21 = VAR_1[3];",
"VAR_1[0] = ( VAR_20 + 2*VAR_20 + 2*VAR_20 + 2*VAR_20 + VAR_20 + 4 ) >> 3;",
"VAR_1[1] = ( VAR_20 + VAR_20 + VAR_20 + VAR_20 + 2 ) >> 2;",
"VAR_1[2] = ( 2*VAR_21 + 3*VAR_20 + VAR_20 + VAR_20 + VAR_20 + 4 ) >> 3;",
"} else {",
"VAR_1[0] = ( 2*VAR_20 + VAR_20 + VAR_20 + 2 ) >> 2;",
"}",
"}else{",
"VAR_1[-1] = ( 2*VAR_20 + VAR_20 + VAR_20 + 2 ) >> 2;",
"VAR_1[ 0] = ( 2*VAR_20 + VAR_20 + VAR_20 + 2 ) >> 2;",
"}",
"tprintf(VAR_0->s.avctx, \"FUNC_0 VAR_6:%d, VAR_5:%d, indexA:%d, VAR_8:%d, VAR_9:%d\\n# VAR_3:4 -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x, %02x, %02x]\\n\", VAR_6, VAR_5[qp_index], VAR_7, VAR_8, VAR_9, VAR_20, VAR_20, VAR_20, VAR_20, VAR_20, VAR_20, VAR_1[-3], VAR_1[-2], VAR_1[-1], VAR_1[0], VAR_1[1], VAR_1[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
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43,
45,
47
],
[
49
],
[
51
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
105,
107,
109
],
[
113
],
[
115,
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135
],
[
137,
139
],
[
141
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
]
] |
3,570 | static void arm_idct_add(UINT8 *dest, int line_size, DCTELEM *block)
{
j_rev_dct_ARM (block);
add_pixels_clamped(block, dest, line_size);
}
| false | FFmpeg | 83f238cbf0c038245d2b2dffa5beb0916e7c36d2 | static void arm_idct_add(UINT8 *dest, int line_size, DCTELEM *block)
{
j_rev_dct_ARM (block);
add_pixels_clamped(block, dest, line_size);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(UINT8 *VAR_0, int VAR_1, DCTELEM *VAR_2)
{
j_rev_dct_ARM (VAR_2);
add_pixels_clamped(VAR_2, VAR_0, VAR_1);
}
| [
"static void FUNC_0(UINT8 *VAR_0, int VAR_1, DCTELEM *VAR_2)\n{",
"j_rev_dct_ARM (VAR_2);",
"add_pixels_clamped(VAR_2, VAR_0, VAR_1);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
3,571 | static inline void decode_block_intra(MadContext * t, DCTELEM * block)
{
MpegEncContext *s = &t->s;
int level, i, j, run;
RLTable *rl = &ff_rl_mpeg1;
const uint8_t *scantable = s->intra_scantable.permutated;
int16_t *quant_matrix = s->intra_matrix;
block[0] = (128 + get_sbits(&s->gb, 8)) * quant_matrix[0];
/* The RL decoder is derived from mpeg1_decode_block_intra;
Escaped level and run values a decoded differently */
i = 0;
{
OPEN_READER(re, &s->gb);
/* now quantify & encode AC coefficients */
for (;;) {
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
if (level == 127) {
break;
} else if (level != 0) {
i += run;
j = scantable[i];
level = (level*quant_matrix[j]) >> 4;
level = (level-1)|1;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
} else {
/* escape */
UPDATE_CACHE(re, &s->gb);
level = SHOW_SBITS(re, &s->gb, 10); SKIP_BITS(re, &s->gb, 10);
UPDATE_CACHE(re, &s->gb);
run = SHOW_UBITS(re, &s->gb, 6)+1; LAST_SKIP_BITS(re, &s->gb, 6);
i += run;
j = scantable[i];
if (level < 0) {
level = -level;
level = (level*quant_matrix[j]) >> 4;
level = (level-1)|1;
level = -level;
} else {
level = (level*quant_matrix[j]) >> 4;
level = (level-1)|1;
}
}
if (i > 63) {
av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
return;
}
block[j] = level;
}
CLOSE_READER(re, &s->gb);
}
}
| false | FFmpeg | 1d0ae92a259b924952856de1a5ca0dc6fd5031e5 | static inline void decode_block_intra(MadContext * t, DCTELEM * block)
{
MpegEncContext *s = &t->s;
int level, i, j, run;
RLTable *rl = &ff_rl_mpeg1;
const uint8_t *scantable = s->intra_scantable.permutated;
int16_t *quant_matrix = s->intra_matrix;
block[0] = (128 + get_sbits(&s->gb, 8)) * quant_matrix[0];
i = 0;
{
OPEN_READER(re, &s->gb);
for (;;) {
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
if (level == 127) {
break;
} else if (level != 0) {
i += run;
j = scantable[i];
level = (level*quant_matrix[j]) >> 4;
level = (level-1)|1;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
} else {
UPDATE_CACHE(re, &s->gb);
level = SHOW_SBITS(re, &s->gb, 10); SKIP_BITS(re, &s->gb, 10);
UPDATE_CACHE(re, &s->gb);
run = SHOW_UBITS(re, &s->gb, 6)+1; LAST_SKIP_BITS(re, &s->gb, 6);
i += run;
j = scantable[i];
if (level < 0) {
level = -level;
level = (level*quant_matrix[j]) >> 4;
level = (level-1)|1;
level = -level;
} else {
level = (level*quant_matrix[j]) >> 4;
level = (level-1)|1;
}
}
if (i > 63) {
av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
return;
}
block[j] = level;
}
CLOSE_READER(re, &s->gb);
}
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(MadContext * VAR_0, DCTELEM * VAR_1)
{
MpegEncContext *s = &VAR_0->s;
int VAR_2, VAR_3, VAR_4, VAR_5;
RLTable *rl = &ff_rl_mpeg1;
const uint8_t *VAR_6 = s->intra_scantable.permutated;
int16_t *quant_matrix = s->intra_matrix;
VAR_1[0] = (128 + get_sbits(&s->gb, 8)) * quant_matrix[0];
VAR_3 = 0;
{
OPEN_READER(re, &s->gb);
for (;;) {
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(VAR_2, VAR_5, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
if (VAR_2 == 127) {
break;
} else if (VAR_2 != 0) {
VAR_3 += VAR_5;
VAR_4 = VAR_6[VAR_3];
VAR_2 = (VAR_2*quant_matrix[VAR_4]) >> 4;
VAR_2 = (VAR_2-1)|1;
VAR_2 = (VAR_2 ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
} else {
UPDATE_CACHE(re, &s->gb);
VAR_2 = SHOW_SBITS(re, &s->gb, 10); SKIP_BITS(re, &s->gb, 10);
UPDATE_CACHE(re, &s->gb);
VAR_5 = SHOW_UBITS(re, &s->gb, 6)+1; LAST_SKIP_BITS(re, &s->gb, 6);
VAR_3 += VAR_5;
VAR_4 = VAR_6[VAR_3];
if (VAR_2 < 0) {
VAR_2 = -VAR_2;
VAR_2 = (VAR_2*quant_matrix[VAR_4]) >> 4;
VAR_2 = (VAR_2-1)|1;
VAR_2 = -VAR_2;
} else {
VAR_2 = (VAR_2*quant_matrix[VAR_4]) >> 4;
VAR_2 = (VAR_2-1)|1;
}
}
if (VAR_3 > 63) {
av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
return;
}
VAR_1[VAR_4] = VAR_2;
}
CLOSE_READER(re, &s->gb);
}
}
| [
"static inline void FUNC_0(MadContext * VAR_0, DCTELEM * VAR_1)\n{",
"MpegEncContext *s = &VAR_0->s;",
"int VAR_2, VAR_3, VAR_4, VAR_5;",
"RLTable *rl = &ff_rl_mpeg1;",
"const uint8_t *VAR_6 = s->intra_scantable.permutated;",
"int16_t *quant_matrix = s->intra_matrix;",
"VAR_1[0] = (128 + get_sbits(&s->gb, 8)) * quant_matrix[0];",
"VAR_3 = 0;",
"{",
"OPEN_READER(re, &s->gb);",
"for (;;) {",
"UPDATE_CACHE(re, &s->gb);",
"GET_RL_VLC(VAR_2, VAR_5, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);",
"if (VAR_2 == 127) {",
"break;",
"} else if (VAR_2 != 0) {",
"VAR_3 += VAR_5;",
"VAR_4 = VAR_6[VAR_3];",
"VAR_2 = (VAR_2*quant_matrix[VAR_4]) >> 4;",
"VAR_2 = (VAR_2-1)|1;",
"VAR_2 = (VAR_2 ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);",
"LAST_SKIP_BITS(re, &s->gb, 1);",
"} else {",
"UPDATE_CACHE(re, &s->gb);",
"VAR_2 = SHOW_SBITS(re, &s->gb, 10); SKIP_BITS(re, &s->gb, 10);",
"UPDATE_CACHE(re, &s->gb);",
"VAR_5 = SHOW_UBITS(re, &s->gb, 6)+1; LAST_SKIP_BITS(re, &s->gb, 6);",
"VAR_3 += VAR_5;",
"VAR_4 = VAR_6[VAR_3];",
"if (VAR_2 < 0) {",
"VAR_2 = -VAR_2;",
"VAR_2 = (VAR_2*quant_matrix[VAR_4]) >> 4;",
"VAR_2 = (VAR_2-1)|1;",
"VAR_2 = -VAR_2;",
"} else {",
"VAR_2 = (VAR_2*quant_matrix[VAR_4]) >> 4;",
"VAR_2 = (VAR_2-1)|1;",
"}",
"}",
"if (VAR_3 > 63) {",
"av_log(s->avctx, AV_LOG_ERROR, \"ac-tex damaged at %d %d\\n\", s->mb_x, s->mb_y);",
"return;",
"}",
"VAR_1[VAR_4] = VAR_2;",
"}",
"CLOSE_READER(re, &s->gb);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
]
] |
3,572 | static void test_ivshmem_memdev(void)
{
IVState state;
/* just for the sake of checking memory-backend property */
setup_vm_cmd(&state, "-object memory-backend-ram,size=1M,id=mb1"
" -device ivshmem,x-memdev=mb1", false);
qtest_quit(state.qtest);
}
| true | qemu | 1760048a5d21bacf0e4838da2f61b2d8db7d2866 | static void test_ivshmem_memdev(void)
{
IVState state;
setup_vm_cmd(&state, "-object memory-backend-ram,size=1M,id=mb1"
" -device ivshmem,x-memdev=mb1", false);
qtest_quit(state.qtest);
}
| {
"code": [
" qtest_quit(state.qtest);"
],
"line_no": [
17
]
} | static void FUNC_0(void)
{
IVState state;
setup_vm_cmd(&state, "-object memory-backend-ram,size=1M,id=mb1"
" -device ivshmem,x-memdev=mb1", false);
qtest_quit(state.qtest);
}
| [
"static void FUNC_0(void)\n{",
"IVState state;",
"setup_vm_cmd(&state, \"-object memory-backend-ram,size=1M,id=mb1\"\n\" -device ivshmem,x-memdev=mb1\", false);",
"qtest_quit(state.qtest);",
"}"
] | [
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
11,
13
],
[
17
],
[
19
]
] |
3,573 | static av_cold void init_static(void)
{
if (!huff_vlc[0].bits) {
INIT_VLC_STATIC(&huff_vlc[0], VLC_BITS, 18,
&ff_mlp_huffman_tables[0][0][1], 2, 1,
&ff_mlp_huffman_tables[0][0][0], 2, 1, 512);
INIT_VLC_STATIC(&huff_vlc[1], VLC_BITS, 16,
&ff_mlp_huffman_tables[1][0][1], 2, 1,
&ff_mlp_huffman_tables[1][0][0], 2, 1, 512);
INIT_VLC_STATIC(&huff_vlc[2], VLC_BITS, 15,
&ff_mlp_huffman_tables[2][0][1], 2, 1,
&ff_mlp_huffman_tables[2][0][0], 2, 1, 512);
ff_mlp_init_crc();
| true | FFmpeg | 7fd88069241ead2d2fd3e2db1b79e4b292e90001 | static av_cold void init_static(void)
{
if (!huff_vlc[0].bits) {
INIT_VLC_STATIC(&huff_vlc[0], VLC_BITS, 18,
&ff_mlp_huffman_tables[0][0][1], 2, 1,
&ff_mlp_huffman_tables[0][0][0], 2, 1, 512);
INIT_VLC_STATIC(&huff_vlc[1], VLC_BITS, 16,
&ff_mlp_huffman_tables[1][0][1], 2, 1,
&ff_mlp_huffman_tables[1][0][0], 2, 1, 512);
INIT_VLC_STATIC(&huff_vlc[2], VLC_BITS, 15,
&ff_mlp_huffman_tables[2][0][1], 2, 1,
&ff_mlp_huffman_tables[2][0][0], 2, 1, 512);
ff_mlp_init_crc();
| {
"code": [],
"line_no": []
} | static av_cold void FUNC_0(void)
{
if (!huff_vlc[0].bits) {
INIT_VLC_STATIC(&huff_vlc[0], VLC_BITS, 18,
&ff_mlp_huffman_tables[0][0][1], 2, 1,
&ff_mlp_huffman_tables[0][0][0], 2, 1, 512);
INIT_VLC_STATIC(&huff_vlc[1], VLC_BITS, 16,
&ff_mlp_huffman_tables[1][0][1], 2, 1,
&ff_mlp_huffman_tables[1][0][0], 2, 1, 512);
INIT_VLC_STATIC(&huff_vlc[2], VLC_BITS, 15,
&ff_mlp_huffman_tables[2][0][1], 2, 1,
&ff_mlp_huffman_tables[2][0][0], 2, 1, 512);
ff_mlp_init_crc();
| [
"static av_cold void FUNC_0(void)\n{",
"if (!huff_vlc[0].bits) {",
"INIT_VLC_STATIC(&huff_vlc[0], VLC_BITS, 18,\n&ff_mlp_huffman_tables[0][0][1], 2, 1,\n&ff_mlp_huffman_tables[0][0][0], 2, 1, 512);",
"INIT_VLC_STATIC(&huff_vlc[1], VLC_BITS, 16,\n&ff_mlp_huffman_tables[1][0][1], 2, 1,\n&ff_mlp_huffman_tables[1][0][0], 2, 1, 512);",
"INIT_VLC_STATIC(&huff_vlc[2], VLC_BITS, 15,\n&ff_mlp_huffman_tables[2][0][1], 2, 1,\n&ff_mlp_huffman_tables[2][0][0], 2, 1, 512);",
"ff_mlp_init_crc();"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9,
11
],
[
13,
15,
17
],
[
19,
21,
23
],
[
28
]
] |
3,574 | void gen_pc_load(CPUState *env, TranslationBlock *tb,
unsigned long searched_pc, int pc_pos, void *puc)
{
env->regs[15] = gen_opc_pc[pc_pos];
} | true | qemu | e12ce78d4aa05ccf80d6a843a9227042647db39d | void gen_pc_load(CPUState *env, TranslationBlock *tb,
unsigned long searched_pc, int pc_pos, void *puc)
{
env->regs[15] = gen_opc_pc[pc_pos];
} | {
"code": [],
"line_no": []
} | void FUNC_0(CPUState *VAR_0, TranslationBlock *VAR_1,
unsigned long VAR_2, int VAR_3, void *VAR_4)
{
VAR_0->regs[15] = gen_opc_pc[VAR_3];
} | [
"void FUNC_0(CPUState *VAR_0, TranslationBlock *VAR_1,\nunsigned long VAR_2, int VAR_3, void *VAR_4)\n{",
"VAR_0->regs[15] = gen_opc_pc[VAR_3];",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
10
]
] |
3,575 | void virtio_scsi_dataplane_notify(VirtIODevice *vdev, VirtIOSCSIReq *req)
{
if (virtio_should_notify(vdev, req->vq)) {
event_notifier_set(virtio_queue_get_guest_notifier(req->vq));
}
}
| true | qemu | 83d768b5640946b7da55ce8335509df297e2c7cd | void virtio_scsi_dataplane_notify(VirtIODevice *vdev, VirtIOSCSIReq *req)
{
if (virtio_should_notify(vdev, req->vq)) {
event_notifier_set(virtio_queue_get_guest_notifier(req->vq));
}
}
| {
"code": [
"void virtio_scsi_dataplane_notify(VirtIODevice *vdev, VirtIOSCSIReq *req)",
" if (virtio_should_notify(vdev, req->vq)) {",
" event_notifier_set(virtio_queue_get_guest_notifier(req->vq));"
],
"line_no": [
1,
5,
7
]
} | void FUNC_0(VirtIODevice *VAR_0, VirtIOSCSIReq *VAR_1)
{
if (virtio_should_notify(VAR_0, VAR_1->vq)) {
event_notifier_set(virtio_queue_get_guest_notifier(VAR_1->vq));
}
}
| [
"void FUNC_0(VirtIODevice *VAR_0, VirtIOSCSIReq *VAR_1)\n{",
"if (virtio_should_notify(VAR_0, VAR_1->vq)) {",
"event_notifier_set(virtio_queue_get_guest_notifier(VAR_1->vq));",
"}",
"}"
] | [
1,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
3,576 | SwsFunc ff_yuv2rgb_init_mmx(SwsContext *c)
{
int cpu_flags = av_get_cpu_flags();
if (c->srcFormat != PIX_FMT_YUV420P &&
c->srcFormat != PIX_FMT_YUVA420P)
return NULL;
if (HAVE_MMX2 && cpu_flags & AV_CPU_FLAG_MMX2) {
switch (c->dstFormat) {
case PIX_FMT_RGB24: return yuv420_rgb24_MMX2;
case PIX_FMT_BGR24: return yuv420_bgr24_MMX2;
}
}
if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) {
switch (c->dstFormat) {
case PIX_FMT_RGB32:
if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) {
#if HAVE_7REGS
return yuva420_rgb32_MMX;
#endif
break;
} else return yuv420_rgb32_MMX;
case PIX_FMT_BGR32:
if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) {
#if HAVE_7REGS
return yuva420_bgr32_MMX;
#endif
break;
} else return yuv420_bgr32_MMX;
case PIX_FMT_RGB24: return yuv420_rgb24_MMX;
case PIX_FMT_BGR24: return yuv420_bgr24_MMX;
case PIX_FMT_RGB565: return yuv420_rgb16_MMX;
case PIX_FMT_RGB555: return yuv420_rgb15_MMX;
}
}
return NULL;
}
| true | FFmpeg | 39d607e5bbc25ad9629683702b510e865434ef21 | SwsFunc ff_yuv2rgb_init_mmx(SwsContext *c)
{
int cpu_flags = av_get_cpu_flags();
if (c->srcFormat != PIX_FMT_YUV420P &&
c->srcFormat != PIX_FMT_YUVA420P)
return NULL;
if (HAVE_MMX2 && cpu_flags & AV_CPU_FLAG_MMX2) {
switch (c->dstFormat) {
case PIX_FMT_RGB24: return yuv420_rgb24_MMX2;
case PIX_FMT_BGR24: return yuv420_bgr24_MMX2;
}
}
if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) {
switch (c->dstFormat) {
case PIX_FMT_RGB32:
if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) {
#if HAVE_7REGS
return yuva420_rgb32_MMX;
#endif
break;
} else return yuv420_rgb32_MMX;
case PIX_FMT_BGR32:
if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) {
#if HAVE_7REGS
return yuva420_bgr32_MMX;
#endif
break;
} else return yuv420_bgr32_MMX;
case PIX_FMT_RGB24: return yuv420_rgb24_MMX;
case PIX_FMT_BGR24: return yuv420_bgr24_MMX;
case PIX_FMT_RGB565: return yuv420_rgb16_MMX;
case PIX_FMT_RGB555: return yuv420_rgb15_MMX;
}
}
return NULL;
}
| {
"code": [
" if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) {",
"#if HAVE_7REGS",
" if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) {",
"#if HAVE_7REGS"
],
"line_no": [
37,
39,
37,
39
]
} | SwsFunc FUNC_0(SwsContext *c)
{
int VAR_0 = av_get_cpu_flags();
if (c->srcFormat != PIX_FMT_YUV420P &&
c->srcFormat != PIX_FMT_YUVA420P)
return NULL;
if (HAVE_MMX2 && VAR_0 & AV_CPU_FLAG_MMX2) {
switch (c->dstFormat) {
case PIX_FMT_RGB24: return yuv420_rgb24_MMX2;
case PIX_FMT_BGR24: return yuv420_bgr24_MMX2;
}
}
if (HAVE_MMX && VAR_0 & AV_CPU_FLAG_MMX) {
switch (c->dstFormat) {
case PIX_FMT_RGB32:
if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) {
#if HAVE_7REGS
return yuva420_rgb32_MMX;
#endif
break;
} else return yuv420_rgb32_MMX;
case PIX_FMT_BGR32:
if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) {
#if HAVE_7REGS
return yuva420_bgr32_MMX;
#endif
break;
} else return yuv420_bgr32_MMX;
case PIX_FMT_RGB24: return yuv420_rgb24_MMX;
case PIX_FMT_BGR24: return yuv420_bgr24_MMX;
case PIX_FMT_RGB565: return yuv420_rgb16_MMX;
case PIX_FMT_RGB555: return yuv420_rgb15_MMX;
}
}
return NULL;
}
| [
"SwsFunc FUNC_0(SwsContext *c)\n{",
"int VAR_0 = av_get_cpu_flags();",
"if (c->srcFormat != PIX_FMT_YUV420P &&\nc->srcFormat != PIX_FMT_YUVA420P)\nreturn NULL;",
"if (HAVE_MMX2 && VAR_0 & AV_CPU_FLAG_MMX2) {",
"switch (c->dstFormat) {",
"case PIX_FMT_RGB24: return yuv420_rgb24_MMX2;",
"case PIX_FMT_BGR24: return yuv420_bgr24_MMX2;",
"}",
"}",
"if (HAVE_MMX && VAR_0 & AV_CPU_FLAG_MMX) {",
"switch (c->dstFormat) {",
"case PIX_FMT_RGB32:\nif (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) {",
"#if HAVE_7REGS\nreturn yuva420_rgb32_MMX;",
"#endif\nbreak;",
"} else return yuv420_rgb32_MMX;",
"case PIX_FMT_BGR32:\nif (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) {",
"#if HAVE_7REGS\nreturn yuva420_bgr32_MMX;",
"#endif\nbreak;",
"} else return yuv420_bgr32_MMX;",
"case PIX_FMT_RGB24: return yuv420_rgb24_MMX;",
"case PIX_FMT_BGR24: return yuv420_bgr24_MMX;",
"case PIX_FMT_RGB565: return yuv420_rgb16_MMX;",
"case PIX_FMT_RGB555: return yuv420_rgb15_MMX;",
"}",
"}",
"return NULL;",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
9,
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
],
[
77
],
[
79
]
] |
3,577 | int ide_init_drive(IDEState *s, BlockDriverState *bs,
const char *version, const char *serial)
{
int cylinders, heads, secs;
uint64_t nb_sectors;
s->bs = bs;
bdrv_get_geometry(bs, &nb_sectors);
bdrv_guess_geometry(bs, &cylinders, &heads, &secs);
if (cylinders < 1 || cylinders > 16383) {
error_report("cyls must be between 1 and 16383");
if (heads < 1 || heads > 16) {
error_report("heads must be between 1 and 16");
if (secs < 1 || secs > 63) {
error_report("secs must be between 1 and 63");
s->cylinders = cylinders;
s->heads = heads;
s->sectors = secs;
s->nb_sectors = nb_sectors;
/* The SMART values should be preserved across power cycles
but they aren't. */
s->smart_enabled = 1;
s->smart_autosave = 1;
s->smart_errors = 0;
s->smart_selftest_count = 0;
if (bdrv_get_type_hint(bs) == BDRV_TYPE_CDROM) {
s->drive_kind = IDE_CD;
bdrv_set_change_cb(bs, cdrom_change_cb, s);
} else {
if (bdrv_is_read_only(bs)) {
error_report("Can't use a read-only drive");
if (serial) {
strncpy(s->drive_serial_str, serial, sizeof(s->drive_serial_str));
} else {
snprintf(s->drive_serial_str, sizeof(s->drive_serial_str),
"QM%05d", s->drive_serial);
if (version) {
pstrcpy(s->version, sizeof(s->version), version);
} else {
pstrcpy(s->version, sizeof(s->version), QEMU_VERSION);
ide_reset(s);
bdrv_set_removable(bs, s->drive_kind == IDE_CD);
return 0;
| true | qemu | 98f28ad7a7d26e5e77c5cb37b262d76d6ccd963d | int ide_init_drive(IDEState *s, BlockDriverState *bs,
const char *version, const char *serial)
{
int cylinders, heads, secs;
uint64_t nb_sectors;
s->bs = bs;
bdrv_get_geometry(bs, &nb_sectors);
bdrv_guess_geometry(bs, &cylinders, &heads, &secs);
if (cylinders < 1 || cylinders > 16383) {
error_report("cyls must be between 1 and 16383");
if (heads < 1 || heads > 16) {
error_report("heads must be between 1 and 16");
if (secs < 1 || secs > 63) {
error_report("secs must be between 1 and 63");
s->cylinders = cylinders;
s->heads = heads;
s->sectors = secs;
s->nb_sectors = nb_sectors;
s->smart_enabled = 1;
s->smart_autosave = 1;
s->smart_errors = 0;
s->smart_selftest_count = 0;
if (bdrv_get_type_hint(bs) == BDRV_TYPE_CDROM) {
s->drive_kind = IDE_CD;
bdrv_set_change_cb(bs, cdrom_change_cb, s);
} else {
if (bdrv_is_read_only(bs)) {
error_report("Can't use a read-only drive");
if (serial) {
strncpy(s->drive_serial_str, serial, sizeof(s->drive_serial_str));
} else {
snprintf(s->drive_serial_str, sizeof(s->drive_serial_str),
"QM%05d", s->drive_serial);
if (version) {
pstrcpy(s->version, sizeof(s->version), version);
} else {
pstrcpy(s->version, sizeof(s->version), QEMU_VERSION);
ide_reset(s);
bdrv_set_removable(bs, s->drive_kind == IDE_CD);
return 0;
| {
"code": [],
"line_no": []
} | int FUNC_0(IDEState *VAR_0, BlockDriverState *VAR_1,
const char *VAR_2, const char *VAR_3)
{
int VAR_4, VAR_5, VAR_6;
uint64_t nb_sectors;
VAR_0->VAR_1 = VAR_1;
bdrv_get_geometry(VAR_1, &nb_sectors);
bdrv_guess_geometry(VAR_1, &VAR_4, &VAR_5, &VAR_6);
if (VAR_4 < 1 || VAR_4 > 16383) {
error_report("cyls must be between 1 and 16383");
if (VAR_5 < 1 || VAR_5 > 16) {
error_report("VAR_5 must be between 1 and 16");
if (VAR_6 < 1 || VAR_6 > 63) {
error_report("VAR_6 must be between 1 and 63");
VAR_0->VAR_4 = VAR_4;
VAR_0->VAR_5 = VAR_5;
VAR_0->sectors = VAR_6;
VAR_0->nb_sectors = nb_sectors;
VAR_0->smart_enabled = 1;
VAR_0->smart_autosave = 1;
VAR_0->smart_errors = 0;
VAR_0->smart_selftest_count = 0;
if (bdrv_get_type_hint(VAR_1) == BDRV_TYPE_CDROM) {
VAR_0->drive_kind = IDE_CD;
bdrv_set_change_cb(VAR_1, cdrom_change_cb, VAR_0);
} else {
if (bdrv_is_read_only(VAR_1)) {
error_report("Can't use a read-only drive");
if (VAR_3) {
strncpy(VAR_0->drive_serial_str, VAR_3, sizeof(VAR_0->drive_serial_str));
} else {
snprintf(VAR_0->drive_serial_str, sizeof(VAR_0->drive_serial_str),
"QM%05d", VAR_0->drive_serial);
if (VAR_2) {
pstrcpy(VAR_0->VAR_2, sizeof(VAR_0->VAR_2), VAR_2);
} else {
pstrcpy(VAR_0->VAR_2, sizeof(VAR_0->VAR_2), QEMU_VERSION);
ide_reset(VAR_0);
bdrv_set_removable(VAR_1, VAR_0->drive_kind == IDE_CD);
return 0;
| [
"int FUNC_0(IDEState *VAR_0, BlockDriverState *VAR_1,\nconst char *VAR_2, const char *VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6;",
"uint64_t nb_sectors;",
"VAR_0->VAR_1 = VAR_1;",
"bdrv_get_geometry(VAR_1, &nb_sectors);",
"bdrv_guess_geometry(VAR_1, &VAR_4, &VAR_5, &VAR_6);",
"if (VAR_4 < 1 || VAR_4 > 16383) {",
"error_report(\"cyls must be between 1 and 16383\");",
"if (VAR_5 < 1 || VAR_5 > 16) {",
"error_report(\"VAR_5 must be between 1 and 16\");",
"if (VAR_6 < 1 || VAR_6 > 63) {",
"error_report(\"VAR_6 must be between 1 and 63\");",
"VAR_0->VAR_4 = VAR_4;",
"VAR_0->VAR_5 = VAR_5;",
"VAR_0->sectors = VAR_6;",
"VAR_0->nb_sectors = nb_sectors;",
"VAR_0->smart_enabled = 1;",
"VAR_0->smart_autosave = 1;",
"VAR_0->smart_errors = 0;",
"VAR_0->smart_selftest_count = 0;",
"if (bdrv_get_type_hint(VAR_1) == BDRV_TYPE_CDROM) {",
"VAR_0->drive_kind = IDE_CD;",
"bdrv_set_change_cb(VAR_1, cdrom_change_cb, VAR_0);",
"} else {",
"if (bdrv_is_read_only(VAR_1)) {",
"error_report(\"Can't use a read-only drive\");",
"if (VAR_3) {",
"strncpy(VAR_0->drive_serial_str, VAR_3, sizeof(VAR_0->drive_serial_str));",
"} else {",
"snprintf(VAR_0->drive_serial_str, sizeof(VAR_0->drive_serial_str),\n\"QM%05d\", VAR_0->drive_serial);",
"if (VAR_2) {",
"pstrcpy(VAR_0->VAR_2, sizeof(VAR_0->VAR_2), VAR_2);",
"} else {",
"pstrcpy(VAR_0->VAR_2, sizeof(VAR_0->VAR_2), QEMU_VERSION);",
"ide_reset(VAR_0);",
"bdrv_set_removable(VAR_1, VAR_0->drive_kind == IDE_CD);",
"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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
69
],
[
71
],
[
76
],
[
78
],
[
80
],
[
82,
84
],
[
87
],
[
89
],
[
91
],
[
93
],
[
96
],
[
98
],
[
100
]
] |
3,578 | SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockDriverState *bdrv,
int unit, bool removable, int bootindex,
const char *serial, Error **errp)
{
const char *driver;
DeviceState *dev;
Error *err = NULL;
driver = bdrv_is_sg(bdrv) ? "scsi-generic" : "scsi-disk";
dev = qdev_create(&bus->qbus, driver);
qdev_prop_set_uint32(dev, "scsi-id", unit);
if (bootindex >= 0) {
qdev_prop_set_int32(dev, "bootindex", bootindex);
}
if (object_property_find(OBJECT(dev), "removable", NULL)) {
qdev_prop_set_bit(dev, "removable", removable);
}
if (serial) {
qdev_prop_set_string(dev, "serial", serial);
}
if (qdev_prop_set_drive(dev, "drive", bdrv) < 0) {
error_setg(errp, "Setting drive property failed");
qdev_free(dev);
return NULL;
}
object_property_set_bool(OBJECT(dev), true, "realized", &err);
if (err != NULL) {
error_propagate(errp, err);
qdev_free(dev);
return NULL;
}
return SCSI_DEVICE(dev);
}
| true | qemu | c24e7517ee4a98e90eee5f0f07708a1fa12326b3 | SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockDriverState *bdrv,
int unit, bool removable, int bootindex,
const char *serial, Error **errp)
{
const char *driver;
DeviceState *dev;
Error *err = NULL;
driver = bdrv_is_sg(bdrv) ? "scsi-generic" : "scsi-disk";
dev = qdev_create(&bus->qbus, driver);
qdev_prop_set_uint32(dev, "scsi-id", unit);
if (bootindex >= 0) {
qdev_prop_set_int32(dev, "bootindex", bootindex);
}
if (object_property_find(OBJECT(dev), "removable", NULL)) {
qdev_prop_set_bit(dev, "removable", removable);
}
if (serial) {
qdev_prop_set_string(dev, "serial", serial);
}
if (qdev_prop_set_drive(dev, "drive", bdrv) < 0) {
error_setg(errp, "Setting drive property failed");
qdev_free(dev);
return NULL;
}
object_property_set_bool(OBJECT(dev), true, "realized", &err);
if (err != NULL) {
error_propagate(errp, err);
qdev_free(dev);
return NULL;
}
return SCSI_DEVICE(dev);
}
| {
"code": [
" if (serial) {"
],
"line_no": [
35
]
} | SCSIDevice *FUNC_0(SCSIBus *bus, BlockDriverState *bdrv,
int unit, bool removable, int bootindex,
const char *serial, Error **errp)
{
const char *VAR_0;
DeviceState *dev;
Error *err = NULL;
VAR_0 = bdrv_is_sg(bdrv) ? "scsi-generic" : "scsi-disk";
dev = qdev_create(&bus->qbus, VAR_0);
qdev_prop_set_uint32(dev, "scsi-id", unit);
if (bootindex >= 0) {
qdev_prop_set_int32(dev, "bootindex", bootindex);
}
if (object_property_find(OBJECT(dev), "removable", NULL)) {
qdev_prop_set_bit(dev, "removable", removable);
}
if (serial) {
qdev_prop_set_string(dev, "serial", serial);
}
if (qdev_prop_set_drive(dev, "drive", bdrv) < 0) {
error_setg(errp, "Setting drive property failed");
qdev_free(dev);
return NULL;
}
object_property_set_bool(OBJECT(dev), true, "realized", &err);
if (err != NULL) {
error_propagate(errp, err);
qdev_free(dev);
return NULL;
}
return SCSI_DEVICE(dev);
}
| [
"SCSIDevice *FUNC_0(SCSIBus *bus, BlockDriverState *bdrv,\nint unit, bool removable, int bootindex,\nconst char *serial, Error **errp)\n{",
"const char *VAR_0;",
"DeviceState *dev;",
"Error *err = NULL;",
"VAR_0 = bdrv_is_sg(bdrv) ? \"scsi-generic\" : \"scsi-disk\";",
"dev = qdev_create(&bus->qbus, VAR_0);",
"qdev_prop_set_uint32(dev, \"scsi-id\", unit);",
"if (bootindex >= 0) {",
"qdev_prop_set_int32(dev, \"bootindex\", bootindex);",
"}",
"if (object_property_find(OBJECT(dev), \"removable\", NULL)) {",
"qdev_prop_set_bit(dev, \"removable\", removable);",
"}",
"if (serial) {",
"qdev_prop_set_string(dev, \"serial\", serial);",
"}",
"if (qdev_prop_set_drive(dev, \"drive\", bdrv) < 0) {",
"error_setg(errp, \"Setting drive property failed\");",
"qdev_free(dev);",
"return NULL;",
"}",
"object_property_set_bool(OBJECT(dev), true, \"realized\", &err);",
"if (err != NULL) {",
"error_propagate(errp, err);",
"qdev_free(dev);",
"return NULL;",
"}",
"return SCSI_DEVICE(dev);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
]
] |
3,579 | static int unix_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
{
QEMUFileSocket *s = opaque;
ssize_t len;
for (;;) {
len = read(s->fd, buf, size);
if (len != -1) {
break;
}
if (errno == EAGAIN) {
yield_until_fd_readable(s->fd);
} else if (errno != EINTR) {
break;
}
}
if (len == -1) {
len = -errno;
}
return len;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | static int unix_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
{
QEMUFileSocket *s = opaque;
ssize_t len;
for (;;) {
len = read(s->fd, buf, size);
if (len != -1) {
break;
}
if (errno == EAGAIN) {
yield_until_fd_readable(s->fd);
} else if (errno != EINTR) {
break;
}
}
if (len == -1) {
len = -errno;
}
return len;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(void *VAR_0, uint8_t *VAR_1, int64_t VAR_2, int VAR_3)
{
QEMUFileSocket *s = VAR_0;
ssize_t len;
for (;;) {
len = read(s->fd, VAR_1, VAR_3);
if (len != -1) {
break;
}
if (errno == EAGAIN) {
yield_until_fd_readable(s->fd);
} else if (errno != EINTR) {
break;
}
}
if (len == -1) {
len = -errno;
}
return len;
}
| [
"static int FUNC_0(void *VAR_0, uint8_t *VAR_1, int64_t VAR_2, int VAR_3)\n{",
"QEMUFileSocket *s = VAR_0;",
"ssize_t len;",
"for (;;) {",
"len = read(s->fd, VAR_1, VAR_3);",
"if (len != -1) {",
"break;",
"}",
"if (errno == EAGAIN) {",
"yield_until_fd_readable(s->fd);",
"} else if (errno != EINTR) {",
"break;",
"}",
"}",
"if (len == -1) {",
"len = -errno;",
"}",
"return len;",
"}"
] | [
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
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
]
] |
3,580 | DriveInfo *add_init_drive(const char *optstr)
{
DriveInfo *dinfo;
QemuOpts *opts;
MachineClass *mc;
opts = drive_def(optstr);
if (!opts)
return NULL;
mc = MACHINE_GET_CLASS(current_machine);
dinfo = drive_new(opts, mc->block_default_type);
if (!dinfo) {
qemu_opts_del(opts);
return NULL;
}
return dinfo;
}
| true | qemu | f51074cdc6e750daa3b6df727d83449a7e42b391 | DriveInfo *add_init_drive(const char *optstr)
{
DriveInfo *dinfo;
QemuOpts *opts;
MachineClass *mc;
opts = drive_def(optstr);
if (!opts)
return NULL;
mc = MACHINE_GET_CLASS(current_machine);
dinfo = drive_new(opts, mc->block_default_type);
if (!dinfo) {
qemu_opts_del(opts);
return NULL;
}
return dinfo;
}
| {
"code": [
"DriveInfo *add_init_drive(const char *optstr)",
" QemuOpts *opts;",
" return NULL;",
" return NULL;",
" return NULL;",
" return NULL;",
" return NULL;",
" return NULL;",
" return NULL;",
" return NULL;",
" return NULL;",
" return NULL;"
],
"line_no": [
1,
7,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17
]
} | DriveInfo *FUNC_0(const char *optstr)
{
DriveInfo *dinfo;
QemuOpts *opts;
MachineClass *mc;
opts = drive_def(optstr);
if (!opts)
return NULL;
mc = MACHINE_GET_CLASS(current_machine);
dinfo = drive_new(opts, mc->block_default_type);
if (!dinfo) {
qemu_opts_del(opts);
return NULL;
}
return dinfo;
}
| [
"DriveInfo *FUNC_0(const char *optstr)\n{",
"DriveInfo *dinfo;",
"QemuOpts *opts;",
"MachineClass *mc;",
"opts = drive_def(optstr);",
"if (!opts)\nreturn NULL;",
"mc = MACHINE_GET_CLASS(current_machine);",
"dinfo = drive_new(opts, mc->block_default_type);",
"if (!dinfo) {",
"qemu_opts_del(opts);",
"return NULL;",
"}",
"return dinfo;",
"}"
] | [
1,
0,
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
]
] |
3,581 | static void decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src, int log2w, int log2h, int stride){
const int index= size2index[log2h][log2w];
const int h= 1<<log2h;
int code= get_vlc2(&f->gb, block_type_vlc[1-(f->version>1)][index].table, BLOCK_TYPE_VLC_BITS, 1);
uint16_t *start= (uint16_t*)f->last_picture.data[0];
uint16_t *end= start + stride*(f->avctx->height-h+1) - (1<<log2w);
assert(code>=0 && code<=6);
if(code == 0){
src += f->mv[ *f->bytestream++ ];
if(start > src || src > end){
av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
return;
}
mcdc(dst, src, log2w, h, stride, 1, 0);
}else if(code == 1){
log2h--;
decode_p_block(f, dst , src , log2w, log2h, stride);
decode_p_block(f, dst + (stride<<log2h), src + (stride<<log2h), log2w, log2h, stride);
}else if(code == 2){
log2w--;
decode_p_block(f, dst , src , log2w, log2h, stride);
decode_p_block(f, dst + (1<<log2w), src + (1<<log2w), log2w, log2h, stride);
}else if(code == 3 && f->version<2){
mcdc(dst, src, log2w, h, stride, 1, 0);
}else if(code == 4){
src += f->mv[ *f->bytestream++ ];
if(start > src || src > end){
av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
return;
}
mcdc(dst, src, log2w, h, stride, 1, av_le2ne16(*f->wordstream++));
}else if(code == 5){
mcdc(dst, src, log2w, h, stride, 0, av_le2ne16(*f->wordstream++));
}else if(code == 6){
if(log2w){
dst[0] = av_le2ne16(*f->wordstream++);
dst[1] = av_le2ne16(*f->wordstream++);
}else{
dst[0 ] = av_le2ne16(*f->wordstream++);
dst[stride] = av_le2ne16(*f->wordstream++);
}
}
}
| true | FFmpeg | 1443ea93d935784370f41d85e224718484b0e32c | static void decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src, int log2w, int log2h, int stride){
const int index= size2index[log2h][log2w];
const int h= 1<<log2h;
int code= get_vlc2(&f->gb, block_type_vlc[1-(f->version>1)][index].table, BLOCK_TYPE_VLC_BITS, 1);
uint16_t *start= (uint16_t*)f->last_picture.data[0];
uint16_t *end= start + stride*(f->avctx->height-h+1) - (1<<log2w);
assert(code>=0 && code<=6);
if(code == 0){
src += f->mv[ *f->bytestream++ ];
if(start > src || src > end){
av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
return;
}
mcdc(dst, src, log2w, h, stride, 1, 0);
}else if(code == 1){
log2h--;
decode_p_block(f, dst , src , log2w, log2h, stride);
decode_p_block(f, dst + (stride<<log2h), src + (stride<<log2h), log2w, log2h, stride);
}else if(code == 2){
log2w--;
decode_p_block(f, dst , src , log2w, log2h, stride);
decode_p_block(f, dst + (1<<log2w), src + (1<<log2w), log2w, log2h, stride);
}else if(code == 3 && f->version<2){
mcdc(dst, src, log2w, h, stride, 1, 0);
}else if(code == 4){
src += f->mv[ *f->bytestream++ ];
if(start > src || src > end){
av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
return;
}
mcdc(dst, src, log2w, h, stride, 1, av_le2ne16(*f->wordstream++));
}else if(code == 5){
mcdc(dst, src, log2w, h, stride, 0, av_le2ne16(*f->wordstream++));
}else if(code == 6){
if(log2w){
dst[0] = av_le2ne16(*f->wordstream++);
dst[1] = av_le2ne16(*f->wordstream++);
}else{
dst[0 ] = av_le2ne16(*f->wordstream++);
dst[stride] = av_le2ne16(*f->wordstream++);
}
}
}
| {
"code": [
" src += f->mv[ *f->bytestream++ ];",
" src += f->mv[ *f->bytestream++ ];",
" mcdc(dst, src, log2w, h, stride, 1, av_le2ne16(*f->wordstream++));",
" mcdc(dst, src, log2w, h, stride, 0, av_le2ne16(*f->wordstream++));",
" dst[0] = av_le2ne16(*f->wordstream++);",
" dst[1] = av_le2ne16(*f->wordstream++);",
" dst[0 ] = av_le2ne16(*f->wordstream++);",
" dst[stride] = av_le2ne16(*f->wordstream++);"
],
"line_no": [
21,
21,
65,
69,
75,
77,
81,
83
]
} | static void FUNC_0(FourXContext *VAR_0, uint16_t *VAR_1, uint16_t *VAR_2, int VAR_3, int VAR_4, int VAR_5){
const int VAR_6= size2index[VAR_4][VAR_3];
const int VAR_7= 1<<VAR_4;
int VAR_8= get_vlc2(&VAR_0->gb, block_type_vlc[1-(VAR_0->version>1)][VAR_6].table, BLOCK_TYPE_VLC_BITS, 1);
uint16_t *start= (uint16_t*)VAR_0->last_picture.data[0];
uint16_t *end= start + VAR_5*(VAR_0->avctx->height-VAR_7+1) - (1<<VAR_3);
assert(VAR_8>=0 && VAR_8<=6);
if(VAR_8 == 0){
VAR_2 += VAR_0->mv[ *VAR_0->bytestream++ ];
if(start > VAR_2 || VAR_2 > end){
av_log(VAR_0->avctx, AV_LOG_ERROR, "mv out of pic\n");
return;
}
mcdc(VAR_1, VAR_2, VAR_3, VAR_7, VAR_5, 1, 0);
}else if(VAR_8 == 1){
VAR_4--;
FUNC_0(VAR_0, VAR_1 , VAR_2 , VAR_3, VAR_4, VAR_5);
FUNC_0(VAR_0, VAR_1 + (VAR_5<<VAR_4), VAR_2 + (VAR_5<<VAR_4), VAR_3, VAR_4, VAR_5);
}else if(VAR_8 == 2){
VAR_3--;
FUNC_0(VAR_0, VAR_1 , VAR_2 , VAR_3, VAR_4, VAR_5);
FUNC_0(VAR_0, VAR_1 + (1<<VAR_3), VAR_2 + (1<<VAR_3), VAR_3, VAR_4, VAR_5);
}else if(VAR_8 == 3 && VAR_0->version<2){
mcdc(VAR_1, VAR_2, VAR_3, VAR_7, VAR_5, 1, 0);
}else if(VAR_8 == 4){
VAR_2 += VAR_0->mv[ *VAR_0->bytestream++ ];
if(start > VAR_2 || VAR_2 > end){
av_log(VAR_0->avctx, AV_LOG_ERROR, "mv out of pic\n");
return;
}
mcdc(VAR_1, VAR_2, VAR_3, VAR_7, VAR_5, 1, av_le2ne16(*VAR_0->wordstream++));
}else if(VAR_8 == 5){
mcdc(VAR_1, VAR_2, VAR_3, VAR_7, VAR_5, 0, av_le2ne16(*VAR_0->wordstream++));
}else if(VAR_8 == 6){
if(VAR_3){
VAR_1[0] = av_le2ne16(*VAR_0->wordstream++);
VAR_1[1] = av_le2ne16(*VAR_0->wordstream++);
}else{
VAR_1[0 ] = av_le2ne16(*VAR_0->wordstream++);
VAR_1[VAR_5] = av_le2ne16(*VAR_0->wordstream++);
}
}
}
| [
"static void FUNC_0(FourXContext *VAR_0, uint16_t *VAR_1, uint16_t *VAR_2, int VAR_3, int VAR_4, int VAR_5){",
"const int VAR_6= size2index[VAR_4][VAR_3];",
"const int VAR_7= 1<<VAR_4;",
"int VAR_8= get_vlc2(&VAR_0->gb, block_type_vlc[1-(VAR_0->version>1)][VAR_6].table, BLOCK_TYPE_VLC_BITS, 1);",
"uint16_t *start= (uint16_t*)VAR_0->last_picture.data[0];",
"uint16_t *end= start + VAR_5*(VAR_0->avctx->height-VAR_7+1) - (1<<VAR_3);",
"assert(VAR_8>=0 && VAR_8<=6);",
"if(VAR_8 == 0){",
"VAR_2 += VAR_0->mv[ *VAR_0->bytestream++ ];",
"if(start > VAR_2 || VAR_2 > end){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"mv out of pic\\n\");",
"return;",
"}",
"mcdc(VAR_1, VAR_2, VAR_3, VAR_7, VAR_5, 1, 0);",
"}else if(VAR_8 == 1){",
"VAR_4--;",
"FUNC_0(VAR_0, VAR_1 , VAR_2 , VAR_3, VAR_4, VAR_5);",
"FUNC_0(VAR_0, VAR_1 + (VAR_5<<VAR_4), VAR_2 + (VAR_5<<VAR_4), VAR_3, VAR_4, VAR_5);",
"}else if(VAR_8 == 2){",
"VAR_3--;",
"FUNC_0(VAR_0, VAR_1 , VAR_2 , VAR_3, VAR_4, VAR_5);",
"FUNC_0(VAR_0, VAR_1 + (1<<VAR_3), VAR_2 + (1<<VAR_3), VAR_3, VAR_4, VAR_5);",
"}else if(VAR_8 == 3 && VAR_0->version<2){",
"mcdc(VAR_1, VAR_2, VAR_3, VAR_7, VAR_5, 1, 0);",
"}else if(VAR_8 == 4){",
"VAR_2 += VAR_0->mv[ *VAR_0->bytestream++ ];",
"if(start > VAR_2 || VAR_2 > end){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"mv out of pic\\n\");",
"return;",
"}",
"mcdc(VAR_1, VAR_2, VAR_3, VAR_7, VAR_5, 1, av_le2ne16(*VAR_0->wordstream++));",
"}else if(VAR_8 == 5){",
"mcdc(VAR_1, VAR_2, VAR_3, VAR_7, VAR_5, 0, av_le2ne16(*VAR_0->wordstream++));",
"}else if(VAR_8 == 6){",
"if(VAR_3){",
"VAR_1[0] = av_le2ne16(*VAR_0->wordstream++);",
"VAR_1[1] = av_le2ne16(*VAR_0->wordstream++);",
"}else{",
"VAR_1[0 ] = av_le2ne16(*VAR_0->wordstream++);",
"VAR_1[VAR_5] = av_le2ne16(*VAR_0->wordstream++);",
"}",
"}",
"}"
] | [
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,
0,
1,
0,
0,
1,
1,
0,
1,
1,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
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
]
] |
3,583 | static int mov_write_int8_metadata(AVFormatContext *s, AVIOContext *pb,
const char *name, const char *tag,
int len)
{
AVDictionaryEntry *t = NULL;
uint8_t num;
if (!(t = av_dict_get(s->metadata, tag, NULL, 0)))
return 0;
num = t ? atoi(t->value) : 0;
avio_wb32(pb, len+8);
ffio_wfourcc(pb, name);
if (len==4) avio_wb32(pb, num);
else avio_w8 (pb, num);
return len+8;
}
| false | FFmpeg | 5f531386210e844f0a6819404cde58da54c46a00 | static int mov_write_int8_metadata(AVFormatContext *s, AVIOContext *pb,
const char *name, const char *tag,
int len)
{
AVDictionaryEntry *t = NULL;
uint8_t num;
if (!(t = av_dict_get(s->metadata, tag, NULL, 0)))
return 0;
num = t ? atoi(t->value) : 0;
avio_wb32(pb, len+8);
ffio_wfourcc(pb, name);
if (len==4) avio_wb32(pb, num);
else avio_w8 (pb, num);
return len+8;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1,
const char *VAR_2, const char *VAR_3,
int VAR_4)
{
AVDictionaryEntry *t = NULL;
uint8_t num;
if (!(t = av_dict_get(VAR_0->metadata, VAR_3, NULL, 0)))
return 0;
num = t ? atoi(t->value) : 0;
avio_wb32(VAR_1, VAR_4+8);
ffio_wfourcc(VAR_1, VAR_2);
if (VAR_4==4) avio_wb32(VAR_1, num);
else avio_w8 (VAR_1, num);
return VAR_4+8;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1,\nconst char *VAR_2, const char *VAR_3,\nint VAR_4)\n{",
"AVDictionaryEntry *t = NULL;",
"uint8_t num;",
"if (!(t = av_dict_get(VAR_0->metadata, VAR_3, NULL, 0)))\nreturn 0;",
"num = t ? atoi(t->value) : 0;",
"avio_wb32(VAR_1, VAR_4+8);",
"ffio_wfourcc(VAR_1, VAR_2);",
"if (VAR_4==4) avio_wb32(VAR_1, num);",
"else avio_w8 (VAR_1, num);",
"return VAR_4+8;",
"}"
] | [
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
]
] |
3,584 | int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
const uint8_t *buf, int len)
{
unsigned int ssrc, h;
int payload_type, seq, ret;
AVStream *st;
uint32_t timestamp;
int rv= 0;
if (!buf) {
/* return the next packets, if any */
if(s->st && s->parse_packet) {
timestamp= 0; ///< Should not be used if buf is NULL, but should be set to the timestamp of the packet returned....
rv= s->parse_packet(s, pkt, ×tamp, NULL, 0);
finalize_packet(s, pkt, timestamp);
return rv;
} else {
// TODO: Move to a dynamic packet handler (like above)
if (s->read_buf_index >= s->read_buf_size)
return -1;
ret = mpegts_parse_packet(s->ts, pkt, s->buf + s->read_buf_index,
s->read_buf_size - s->read_buf_index);
if (ret < 0)
return -1;
s->read_buf_index += ret;
if (s->read_buf_index < s->read_buf_size)
return 1;
else
return 0;
}
}
if (len < 12)
return -1;
if ((buf[0] & 0xc0) != (RTP_VERSION << 6))
return -1;
if (buf[1] >= 200 && buf[1] <= 204) {
rtcp_parse_packet(s, buf, len);
return -1;
}
payload_type = buf[1] & 0x7f;
seq = (buf[2] << 8) | buf[3];
timestamp = decode_be32(buf + 4);
ssrc = decode_be32(buf + 8);
/* store the ssrc in the RTPDemuxContext */
s->ssrc = ssrc;
/* NOTE: we can handle only one payload type */
if (s->payload_type != payload_type)
return -1;
st = s->st;
#if defined(DEBUG) || 1
if (seq != ((s->seq + 1) & 0xffff)) {
av_log(st?st->codec:NULL, AV_LOG_ERROR, "RTP: PT=%02x: bad cseq %04x expected=%04x\n",
payload_type, seq, ((s->seq + 1) & 0xffff));
}
#endif
s->seq = seq;
len -= 12;
buf += 12;
if (!st) {
/* specific MPEG2TS demux support */
ret = mpegts_parse_packet(s->ts, pkt, buf, len);
if (ret < 0)
return -1;
if (ret < len) {
s->read_buf_size = len - ret;
memcpy(s->buf, buf + ret, s->read_buf_size);
s->read_buf_index = 0;
return 1;
}
} else {
// at this point, the RTP header has been stripped; This is ASSUMING that there is only 1 CSRC, which in't wise.
switch(st->codec->codec_id) {
case CODEC_ID_MP2:
/* better than nothing: skip mpeg audio RTP header */
if (len <= 4)
return -1;
h = decode_be32(buf);
len -= 4;
buf += 4;
av_new_packet(pkt, len);
memcpy(pkt->data, buf, len);
break;
case CODEC_ID_MPEG1VIDEO:
/* better than nothing: skip mpeg video RTP header */
if (len <= 4)
return -1;
h = decode_be32(buf);
buf += 4;
len -= 4;
if (h & (1 << 26)) {
/* mpeg2 */
if (len <= 4)
return -1;
buf += 4;
len -= 4;
}
av_new_packet(pkt, len);
memcpy(pkt->data, buf, len);
break;
// moved from below, verbatim. this is because this section handles packets, and the lower switch handles
// timestamps.
// TODO: Put this into a dynamic packet handler...
case CODEC_ID_MPEG4AAC:
if (rtp_parse_mp4_au(s, buf))
return -1;
{
rtp_payload_data_t *infos = s->rtp_payload_data;
if (infos == NULL)
return -1;
buf += infos->au_headers_length_bytes + 2;
len -= infos->au_headers_length_bytes + 2;
/* XXX: Fixme we only handle the case where rtp_parse_mp4_au define
one au_header */
av_new_packet(pkt, infos->au_headers[0].size);
memcpy(pkt->data, buf, infos->au_headers[0].size);
buf += infos->au_headers[0].size;
len -= infos->au_headers[0].size;
}
s->read_buf_size = len;
s->buf_ptr = buf;
rv= 0;
break;
default:
if(s->parse_packet) {
rv= s->parse_packet(s, pkt, ×tamp, buf, len);
} else {
av_new_packet(pkt, len);
memcpy(pkt->data, buf, len);
}
break;
}
// now perform timestamp things....
finalize_packet(s, pkt, timestamp);
}
return rv;
}
| false | FFmpeg | 4a6cc06123d969fe3214ff874bc87c1aec529143 | int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
const uint8_t *buf, int len)
{
unsigned int ssrc, h;
int payload_type, seq, ret;
AVStream *st;
uint32_t timestamp;
int rv= 0;
if (!buf) {
if(s->st && s->parse_packet) {
timestamp= 0;
rv= s->parse_packet(s, pkt, ×tamp, NULL, 0);
finalize_packet(s, pkt, timestamp);
return rv;
} else {
if (s->read_buf_index >= s->read_buf_size)
return -1;
ret = mpegts_parse_packet(s->ts, pkt, s->buf + s->read_buf_index,
s->read_buf_size - s->read_buf_index);
if (ret < 0)
return -1;
s->read_buf_index += ret;
if (s->read_buf_index < s->read_buf_size)
return 1;
else
return 0;
}
}
if (len < 12)
return -1;
if ((buf[0] & 0xc0) != (RTP_VERSION << 6))
return -1;
if (buf[1] >= 200 && buf[1] <= 204) {
rtcp_parse_packet(s, buf, len);
return -1;
}
payload_type = buf[1] & 0x7f;
seq = (buf[2] << 8) | buf[3];
timestamp = decode_be32(buf + 4);
ssrc = decode_be32(buf + 8);
s->ssrc = ssrc;
if (s->payload_type != payload_type)
return -1;
st = s->st;
#if defined(DEBUG) || 1
if (seq != ((s->seq + 1) & 0xffff)) {
av_log(st?st->codec:NULL, AV_LOG_ERROR, "RTP: PT=%02x: bad cseq %04x expected=%04x\n",
payload_type, seq, ((s->seq + 1) & 0xffff));
}
#endif
s->seq = seq;
len -= 12;
buf += 12;
if (!st) {
ret = mpegts_parse_packet(s->ts, pkt, buf, len);
if (ret < 0)
return -1;
if (ret < len) {
s->read_buf_size = len - ret;
memcpy(s->buf, buf + ret, s->read_buf_size);
s->read_buf_index = 0;
return 1;
}
} else {
switch(st->codec->codec_id) {
case CODEC_ID_MP2:
if (len <= 4)
return -1;
h = decode_be32(buf);
len -= 4;
buf += 4;
av_new_packet(pkt, len);
memcpy(pkt->data, buf, len);
break;
case CODEC_ID_MPEG1VIDEO:
if (len <= 4)
return -1;
h = decode_be32(buf);
buf += 4;
len -= 4;
if (h & (1 << 26)) {
if (len <= 4)
return -1;
buf += 4;
len -= 4;
}
av_new_packet(pkt, len);
memcpy(pkt->data, buf, len);
break;
case CODEC_ID_MPEG4AAC:
if (rtp_parse_mp4_au(s, buf))
return -1;
{
rtp_payload_data_t *infos = s->rtp_payload_data;
if (infos == NULL)
return -1;
buf += infos->au_headers_length_bytes + 2;
len -= infos->au_headers_length_bytes + 2;
av_new_packet(pkt, infos->au_headers[0].size);
memcpy(pkt->data, buf, infos->au_headers[0].size);
buf += infos->au_headers[0].size;
len -= infos->au_headers[0].size;
}
s->read_buf_size = len;
s->buf_ptr = buf;
rv= 0;
break;
default:
if(s->parse_packet) {
rv= s->parse_packet(s, pkt, ×tamp, buf, len);
} else {
av_new_packet(pkt, len);
memcpy(pkt->data, buf, len);
}
break;
}
finalize_packet(s, pkt, timestamp);
}
return rv;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(RTPDemuxContext *VAR_0, AVPacket *VAR_1,
const uint8_t *VAR_2, int VAR_3)
{
unsigned int VAR_4, VAR_5;
int VAR_6, VAR_7, VAR_8;
AVStream *st;
uint32_t timestamp;
int VAR_9= 0;
if (!VAR_2) {
if(VAR_0->st && VAR_0->parse_packet) {
timestamp= 0;
VAR_9= VAR_0->parse_packet(VAR_0, VAR_1, ×tamp, NULL, 0);
finalize_packet(VAR_0, VAR_1, timestamp);
return VAR_9;
} else {
if (VAR_0->read_buf_index >= VAR_0->read_buf_size)
return -1;
VAR_8 = mpegts_parse_packet(VAR_0->ts, VAR_1, VAR_0->VAR_2 + VAR_0->read_buf_index,
VAR_0->read_buf_size - VAR_0->read_buf_index);
if (VAR_8 < 0)
return -1;
VAR_0->read_buf_index += VAR_8;
if (VAR_0->read_buf_index < VAR_0->read_buf_size)
return 1;
else
return 0;
}
}
if (VAR_3 < 12)
return -1;
if ((VAR_2[0] & 0xc0) != (RTP_VERSION << 6))
return -1;
if (VAR_2[1] >= 200 && VAR_2[1] <= 204) {
rtcp_parse_packet(VAR_0, VAR_2, VAR_3);
return -1;
}
VAR_6 = VAR_2[1] & 0x7f;
VAR_7 = (VAR_2[2] << 8) | VAR_2[3];
timestamp = decode_be32(VAR_2 + 4);
VAR_4 = decode_be32(VAR_2 + 8);
VAR_0->VAR_4 = VAR_4;
if (VAR_0->VAR_6 != VAR_6)
return -1;
st = VAR_0->st;
#if defined(DEBUG) || 1
if (VAR_7 != ((VAR_0->VAR_7 + 1) & 0xffff)) {
av_log(st?st->codec:NULL, AV_LOG_ERROR, "RTP: PT=%02x: bad cseq %04x expected=%04x\n",
VAR_6, VAR_7, ((VAR_0->VAR_7 + 1) & 0xffff));
}
#endif
VAR_0->VAR_7 = VAR_7;
VAR_3 -= 12;
VAR_2 += 12;
if (!st) {
VAR_8 = mpegts_parse_packet(VAR_0->ts, VAR_1, VAR_2, VAR_3);
if (VAR_8 < 0)
return -1;
if (VAR_8 < VAR_3) {
VAR_0->read_buf_size = VAR_3 - VAR_8;
memcpy(VAR_0->VAR_2, VAR_2 + VAR_8, VAR_0->read_buf_size);
VAR_0->read_buf_index = 0;
return 1;
}
} else {
switch(st->codec->codec_id) {
case CODEC_ID_MP2:
if (VAR_3 <= 4)
return -1;
VAR_5 = decode_be32(VAR_2);
VAR_3 -= 4;
VAR_2 += 4;
av_new_packet(VAR_1, VAR_3);
memcpy(VAR_1->data, VAR_2, VAR_3);
break;
case CODEC_ID_MPEG1VIDEO:
if (VAR_3 <= 4)
return -1;
VAR_5 = decode_be32(VAR_2);
VAR_2 += 4;
VAR_3 -= 4;
if (VAR_5 & (1 << 26)) {
if (VAR_3 <= 4)
return -1;
VAR_2 += 4;
VAR_3 -= 4;
}
av_new_packet(VAR_1, VAR_3);
memcpy(VAR_1->data, VAR_2, VAR_3);
break;
case CODEC_ID_MPEG4AAC:
if (rtp_parse_mp4_au(VAR_0, VAR_2))
return -1;
{
rtp_payload_data_t *infos = VAR_0->rtp_payload_data;
if (infos == NULL)
return -1;
VAR_2 += infos->au_headers_length_bytes + 2;
VAR_3 -= infos->au_headers_length_bytes + 2;
av_new_packet(VAR_1, infos->au_headers[0].size);
memcpy(VAR_1->data, VAR_2, infos->au_headers[0].size);
VAR_2 += infos->au_headers[0].size;
VAR_3 -= infos->au_headers[0].size;
}
VAR_0->read_buf_size = VAR_3;
VAR_0->buf_ptr = VAR_2;
VAR_9= 0;
break;
default:
if(VAR_0->parse_packet) {
VAR_9= VAR_0->parse_packet(VAR_0, VAR_1, ×tamp, VAR_2, VAR_3);
} else {
av_new_packet(VAR_1, VAR_3);
memcpy(VAR_1->data, VAR_2, VAR_3);
}
break;
}
finalize_packet(VAR_0, VAR_1, timestamp);
}
return VAR_9;
}
| [
"int FUNC_0(RTPDemuxContext *VAR_0, AVPacket *VAR_1,\nconst uint8_t *VAR_2, int VAR_3)\n{",
"unsigned int VAR_4, VAR_5;",
"int VAR_6, VAR_7, VAR_8;",
"AVStream *st;",
"uint32_t timestamp;",
"int VAR_9= 0;",
"if (!VAR_2) {",
"if(VAR_0->st && VAR_0->parse_packet) {",
"timestamp= 0;",
"VAR_9= VAR_0->parse_packet(VAR_0, VAR_1, ×tamp, NULL, 0);",
"finalize_packet(VAR_0, VAR_1, timestamp);",
"return VAR_9;",
"} else {",
"if (VAR_0->read_buf_index >= VAR_0->read_buf_size)\nreturn -1;",
"VAR_8 = mpegts_parse_packet(VAR_0->ts, VAR_1, VAR_0->VAR_2 + VAR_0->read_buf_index,\nVAR_0->read_buf_size - VAR_0->read_buf_index);",
"if (VAR_8 < 0)\nreturn -1;",
"VAR_0->read_buf_index += VAR_8;",
"if (VAR_0->read_buf_index < VAR_0->read_buf_size)\nreturn 1;",
"else\nreturn 0;",
"}",
"}",
"if (VAR_3 < 12)\nreturn -1;",
"if ((VAR_2[0] & 0xc0) != (RTP_VERSION << 6))\nreturn -1;",
"if (VAR_2[1] >= 200 && VAR_2[1] <= 204) {",
"rtcp_parse_packet(VAR_0, VAR_2, VAR_3);",
"return -1;",
"}",
"VAR_6 = VAR_2[1] & 0x7f;",
"VAR_7 = (VAR_2[2] << 8) | VAR_2[3];",
"timestamp = decode_be32(VAR_2 + 4);",
"VAR_4 = decode_be32(VAR_2 + 8);",
"VAR_0->VAR_4 = VAR_4;",
"if (VAR_0->VAR_6 != VAR_6)\nreturn -1;",
"st = VAR_0->st;",
"#if defined(DEBUG) || 1\nif (VAR_7 != ((VAR_0->VAR_7 + 1) & 0xffff)) {",
"av_log(st?st->codec:NULL, AV_LOG_ERROR, \"RTP: PT=%02x: bad cseq %04x expected=%04x\\n\",\nVAR_6, VAR_7, ((VAR_0->VAR_7 + 1) & 0xffff));",
"}",
"#endif\nVAR_0->VAR_7 = VAR_7;",
"VAR_3 -= 12;",
"VAR_2 += 12;",
"if (!st) {",
"VAR_8 = mpegts_parse_packet(VAR_0->ts, VAR_1, VAR_2, VAR_3);",
"if (VAR_8 < 0)\nreturn -1;",
"if (VAR_8 < VAR_3) {",
"VAR_0->read_buf_size = VAR_3 - VAR_8;",
"memcpy(VAR_0->VAR_2, VAR_2 + VAR_8, VAR_0->read_buf_size);",
"VAR_0->read_buf_index = 0;",
"return 1;",
"}",
"} else {",
"switch(st->codec->codec_id) {",
"case CODEC_ID_MP2:\nif (VAR_3 <= 4)\nreturn -1;",
"VAR_5 = decode_be32(VAR_2);",
"VAR_3 -= 4;",
"VAR_2 += 4;",
"av_new_packet(VAR_1, VAR_3);",
"memcpy(VAR_1->data, VAR_2, VAR_3);",
"break;",
"case CODEC_ID_MPEG1VIDEO:\nif (VAR_3 <= 4)\nreturn -1;",
"VAR_5 = decode_be32(VAR_2);",
"VAR_2 += 4;",
"VAR_3 -= 4;",
"if (VAR_5 & (1 << 26)) {",
"if (VAR_3 <= 4)\nreturn -1;",
"VAR_2 += 4;",
"VAR_3 -= 4;",
"}",
"av_new_packet(VAR_1, VAR_3);",
"memcpy(VAR_1->data, VAR_2, VAR_3);",
"break;",
"case CODEC_ID_MPEG4AAC:\nif (rtp_parse_mp4_au(VAR_0, VAR_2))\nreturn -1;",
"{",
"rtp_payload_data_t *infos = VAR_0->rtp_payload_data;",
"if (infos == NULL)\nreturn -1;",
"VAR_2 += infos->au_headers_length_bytes + 2;",
"VAR_3 -= infos->au_headers_length_bytes + 2;",
"av_new_packet(VAR_1, infos->au_headers[0].size);",
"memcpy(VAR_1->data, VAR_2, infos->au_headers[0].size);",
"VAR_2 += infos->au_headers[0].size;",
"VAR_3 -= infos->au_headers[0].size;",
"}",
"VAR_0->read_buf_size = VAR_3;",
"VAR_0->buf_ptr = VAR_2;",
"VAR_9= 0;",
"break;",
"default:\nif(VAR_0->parse_packet) {",
"VAR_9= VAR_0->parse_packet(VAR_0, VAR_1, ×tamp, VAR_2, VAR_3);",
"} else {",
"av_new_packet(VAR_1, VAR_3);",
"memcpy(VAR_1->data, VAR_2, VAR_3);",
"}",
"break;",
"}",
"finalize_packet(VAR_0, VAR_1, timestamp);",
"}",
"return VAR_9;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
29
],
[
31
],
[
33
],
[
37,
39
],
[
41,
43
],
[
45,
47
],
[
49
],
[
51,
53
],
[
55,
57
],
[
59
],
[
61
],
[
65,
67
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
99,
101
],
[
105
],
[
107,
109
],
[
111,
113
],
[
115
],
[
117,
119
],
[
121
],
[
123
],
[
127
],
[
131
],
[
133,
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155,
159,
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175,
179,
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
193,
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
215,
217,
219
],
[
221
],
[
223
],
[
225,
227
],
[
229
],
[
231
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257,
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
279
],
[
281
],
[
283
],
[
285
]
] |
3,586 | static int decode_mb_info(IVI4DecContext *ctx, IVIBandDesc *band,
IVITile *tile, AVCodecContext *avctx)
{
int x, y, mv_x, mv_y, mv_delta, offs, mb_offset, blks_per_mb,
mv_scale, mb_type_bits, s;
IVIMbInfo *mb, *ref_mb;
int row_offset = band->mb_size * band->pitch;
mb = tile->mbs;
ref_mb = tile->ref_mbs;
offs = tile->ypos * band->pitch + tile->xpos;
blks_per_mb = band->mb_size != band->blk_size ? 4 : 1;
mb_type_bits = ctx->frame_type == FRAMETYPE_BIDIR ? 2 : 1;
/* scale factor for motion vectors */
mv_scale = (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3);
mv_x = mv_y = 0;
if (((tile->width + band->mb_size-1)/band->mb_size) * ((tile->height + band->mb_size-1)/band->mb_size) != tile->num_MBs) {
av_log(avctx, AV_LOG_ERROR, "num_MBs mismatch %d %d %d %d\n", tile->width, tile->height, band->mb_size, tile->num_MBs);
return -1;
}
for (y = tile->ypos; y < tile->ypos + tile->height; y += band->mb_size) {
mb_offset = offs;
for (x = tile->xpos; x < tile->xpos + tile->width; x += band->mb_size) {
mb->xpos = x;
mb->ypos = y;
mb->buf_offs = mb_offset;
if (get_bits1(&ctx->gb)) {
if (ctx->frame_type == FRAMETYPE_INTRA) {
av_log(avctx, AV_LOG_ERROR, "Empty macroblock in an INTRA picture!\n");
return AVERROR_INVALIDDATA;
}
mb->type = 1; /* empty macroblocks are always INTER */
mb->cbp = 0; /* all blocks are empty */
mb->q_delta = 0;
if (!band->plane && !band->band_num && ctx->in_q) {
mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mb->q_delta = IVI_TOSIGNED(mb->q_delta);
}
mb->mv_x = mb->mv_y = 0; /* no motion vector coded */
if (band->inherit_mv) {
/* motion vector inheritance */
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
} else {
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
}
}
} else {
if (band->inherit_mv && ref_mb) {
mb->type = ref_mb->type; /* copy mb_type from corresponding reference mb */
} else if (ctx->frame_type == FRAMETYPE_INTRA) {
mb->type = 0; /* mb_type is always INTRA for intra-frames */
} else {
mb->type = get_bits(&ctx->gb, mb_type_bits);
}
mb->cbp = get_bits(&ctx->gb, blks_per_mb);
mb->q_delta = 0;
if (band->inherit_qdelta) {
if (ref_mb) mb->q_delta = ref_mb->q_delta;
} else if (mb->cbp || (!band->plane && !band->band_num &&
ctx->in_q)) {
mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mb->q_delta = IVI_TOSIGNED(mb->q_delta);
}
if (!mb->type) {
mb->mv_x = mb->mv_y = 0; /* there is no motion vector in intra-macroblocks */
} else {
if (band->inherit_mv) {
/* motion vector inheritance */
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
} else {
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
}
} else {
/* decode motion vector deltas */
mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mv_y += IVI_TOSIGNED(mv_delta);
mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mv_x += IVI_TOSIGNED(mv_delta);
mb->mv_x = mv_x;
mb->mv_y = mv_y;
}
}
}
s= band->is_halfpel;
if (mb->type)
if ( x + (mb->mv_x >>s) + (y+ (mb->mv_y >>s))*band->pitch < 0 ||
x + ((mb->mv_x+s)>>s) + band->mb_size - 1
+ (y+band->mb_size - 1 +((mb->mv_y+s)>>s))*band->pitch > band->bufsize -1) {
av_log(avctx, AV_LOG_ERROR, "motion vector %d %d outside reference\n", x*s + mb->mv_x, y*s + mb->mv_y);
return AVERROR_INVALIDDATA;
}
mb++;
if (ref_mb)
ref_mb++;
mb_offset += band->mb_size;
}
offs += row_offset;
}
align_get_bits(&ctx->gb);
return 0;
}
| true | FFmpeg | 5216245a2c5ed8140d99f14fcc148fbb6db9831e | static int decode_mb_info(IVI4DecContext *ctx, IVIBandDesc *band,
IVITile *tile, AVCodecContext *avctx)
{
int x, y, mv_x, mv_y, mv_delta, offs, mb_offset, blks_per_mb,
mv_scale, mb_type_bits, s;
IVIMbInfo *mb, *ref_mb;
int row_offset = band->mb_size * band->pitch;
mb = tile->mbs;
ref_mb = tile->ref_mbs;
offs = tile->ypos * band->pitch + tile->xpos;
blks_per_mb = band->mb_size != band->blk_size ? 4 : 1;
mb_type_bits = ctx->frame_type == FRAMETYPE_BIDIR ? 2 : 1;
mv_scale = (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3);
mv_x = mv_y = 0;
if (((tile->width + band->mb_size-1)/band->mb_size) * ((tile->height + band->mb_size-1)/band->mb_size) != tile->num_MBs) {
av_log(avctx, AV_LOG_ERROR, "num_MBs mismatch %d %d %d %d\n", tile->width, tile->height, band->mb_size, tile->num_MBs);
return -1;
}
for (y = tile->ypos; y < tile->ypos + tile->height; y += band->mb_size) {
mb_offset = offs;
for (x = tile->xpos; x < tile->xpos + tile->width; x += band->mb_size) {
mb->xpos = x;
mb->ypos = y;
mb->buf_offs = mb_offset;
if (get_bits1(&ctx->gb)) {
if (ctx->frame_type == FRAMETYPE_INTRA) {
av_log(avctx, AV_LOG_ERROR, "Empty macroblock in an INTRA picture!\n");
return AVERROR_INVALIDDATA;
}
mb->type = 1;
mb->cbp = 0;
mb->q_delta = 0;
if (!band->plane && !band->band_num && ctx->in_q) {
mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mb->q_delta = IVI_TOSIGNED(mb->q_delta);
}
mb->mv_x = mb->mv_y = 0;
if (band->inherit_mv) {
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
} else {
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
}
}
} else {
if (band->inherit_mv && ref_mb) {
mb->type = ref_mb->type;
} else if (ctx->frame_type == FRAMETYPE_INTRA) {
mb->type = 0;
} else {
mb->type = get_bits(&ctx->gb, mb_type_bits);
}
mb->cbp = get_bits(&ctx->gb, blks_per_mb);
mb->q_delta = 0;
if (band->inherit_qdelta) {
if (ref_mb) mb->q_delta = ref_mb->q_delta;
} else if (mb->cbp || (!band->plane && !band->band_num &&
ctx->in_q)) {
mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mb->q_delta = IVI_TOSIGNED(mb->q_delta);
}
if (!mb->type) {
mb->mv_x = mb->mv_y = 0;
} else {
if (band->inherit_mv) {
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
} else {
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
}
} else {
mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mv_y += IVI_TOSIGNED(mv_delta);
mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mv_x += IVI_TOSIGNED(mv_delta);
mb->mv_x = mv_x;
mb->mv_y = mv_y;
}
}
}
s= band->is_halfpel;
if (mb->type)
if ( x + (mb->mv_x >>s) + (y+ (mb->mv_y >>s))*band->pitch < 0 ||
x + ((mb->mv_x+s)>>s) + band->mb_size - 1
+ (y+band->mb_size - 1 +((mb->mv_y+s)>>s))*band->pitch > band->bufsize -1) {
av_log(avctx, AV_LOG_ERROR, "motion vector %d %d outside reference\n", x*s + mb->mv_x, y*s + mb->mv_y);
return AVERROR_INVALIDDATA;
}
mb++;
if (ref_mb)
ref_mb++;
mb_offset += band->mb_size;
}
offs += row_offset;
}
align_get_bits(&ctx->gb);
return 0;
}
| {
"code": [
" if (band->inherit_mv) {",
" if (band->inherit_mv) {"
],
"line_no": [
97,
165
]
} | static int FUNC_0(IVI4DecContext *VAR_0, IVIBandDesc *VAR_1,
IVITile *VAR_2, AVCodecContext *VAR_3)
{
int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11,
VAR_12, VAR_13, VAR_14;
IVIMbInfo *mb, *ref_mb;
int VAR_15 = VAR_1->mb_size * VAR_1->pitch;
mb = VAR_2->mbs;
ref_mb = VAR_2->ref_mbs;
VAR_9 = VAR_2->ypos * VAR_1->pitch + VAR_2->xpos;
VAR_11 = VAR_1->mb_size != VAR_1->blk_size ? 4 : 1;
VAR_13 = VAR_0->frame_type == FRAMETYPE_BIDIR ? 2 : 1;
VAR_12 = (VAR_0->planes[0].bands[0].mb_size >> 3) - (VAR_1->mb_size >> 3);
VAR_6 = VAR_7 = 0;
if (((VAR_2->width + VAR_1->mb_size-1)/VAR_1->mb_size) * ((VAR_2->height + VAR_1->mb_size-1)/VAR_1->mb_size) != VAR_2->num_MBs) {
av_log(VAR_3, AV_LOG_ERROR, "num_MBs mismatch %d %d %d %d\n", VAR_2->width, VAR_2->height, VAR_1->mb_size, VAR_2->num_MBs);
return -1;
}
for (VAR_5 = VAR_2->ypos; VAR_5 < VAR_2->ypos + VAR_2->height; VAR_5 += VAR_1->mb_size) {
VAR_10 = VAR_9;
for (VAR_4 = VAR_2->xpos; VAR_4 < VAR_2->xpos + VAR_2->width; VAR_4 += VAR_1->mb_size) {
mb->xpos = VAR_4;
mb->ypos = VAR_5;
mb->buf_offs = VAR_10;
if (get_bits1(&VAR_0->gb)) {
if (VAR_0->frame_type == FRAMETYPE_INTRA) {
av_log(VAR_3, AV_LOG_ERROR, "Empty macroblock in an INTRA picture!\n");
return AVERROR_INVALIDDATA;
}
mb->type = 1;
mb->cbp = 0;
mb->q_delta = 0;
if (!VAR_1->plane && !VAR_1->band_num && VAR_0->in_q) {
mb->q_delta = get_vlc2(&VAR_0->gb, VAR_0->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mb->q_delta = IVI_TOSIGNED(mb->q_delta);
}
mb->VAR_6 = mb->VAR_7 = 0;
if (VAR_1->inherit_mv) {
if (VAR_12) {
mb->VAR_6 = ivi_scale_mv(ref_mb->VAR_6, VAR_12);
mb->VAR_7 = ivi_scale_mv(ref_mb->VAR_7, VAR_12);
} else {
mb->VAR_6 = ref_mb->VAR_6;
mb->VAR_7 = ref_mb->VAR_7;
}
}
} else {
if (VAR_1->inherit_mv && ref_mb) {
mb->type = ref_mb->type;
} else if (VAR_0->frame_type == FRAMETYPE_INTRA) {
mb->type = 0;
} else {
mb->type = get_bits(&VAR_0->gb, VAR_13);
}
mb->cbp = get_bits(&VAR_0->gb, VAR_11);
mb->q_delta = 0;
if (VAR_1->inherit_qdelta) {
if (ref_mb) mb->q_delta = ref_mb->q_delta;
} else if (mb->cbp || (!VAR_1->plane && !VAR_1->band_num &&
VAR_0->in_q)) {
mb->q_delta = get_vlc2(&VAR_0->gb, VAR_0->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mb->q_delta = IVI_TOSIGNED(mb->q_delta);
}
if (!mb->type) {
mb->VAR_6 = mb->VAR_7 = 0;
} else {
if (VAR_1->inherit_mv) {
if (VAR_12) {
mb->VAR_6 = ivi_scale_mv(ref_mb->VAR_6, VAR_12);
mb->VAR_7 = ivi_scale_mv(ref_mb->VAR_7, VAR_12);
} else {
mb->VAR_6 = ref_mb->VAR_6;
mb->VAR_7 = ref_mb->VAR_7;
}
} else {
VAR_8 = get_vlc2(&VAR_0->gb, VAR_0->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
VAR_7 += IVI_TOSIGNED(VAR_8);
VAR_8 = get_vlc2(&VAR_0->gb, VAR_0->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
VAR_6 += IVI_TOSIGNED(VAR_8);
mb->VAR_6 = VAR_6;
mb->VAR_7 = VAR_7;
}
}
}
VAR_14= VAR_1->is_halfpel;
if (mb->type)
if ( VAR_4 + (mb->VAR_6 >>VAR_14) + (VAR_5+ (mb->VAR_7 >>VAR_14))*VAR_1->pitch < 0 ||
VAR_4 + ((mb->VAR_6+VAR_14)>>VAR_14) + VAR_1->mb_size - 1
+ (VAR_5+VAR_1->mb_size - 1 +((mb->VAR_7+VAR_14)>>VAR_14))*VAR_1->pitch > VAR_1->bufsize -1) {
av_log(VAR_3, AV_LOG_ERROR, "motion vector %d %d outside reference\n", VAR_4*VAR_14 + mb->VAR_6, VAR_5*VAR_14 + mb->VAR_7);
return AVERROR_INVALIDDATA;
}
mb++;
if (ref_mb)
ref_mb++;
VAR_10 += VAR_1->mb_size;
}
VAR_9 += VAR_15;
}
align_get_bits(&VAR_0->gb);
return 0;
}
| [
"static int FUNC_0(IVI4DecContext *VAR_0, IVIBandDesc *VAR_1,\nIVITile *VAR_2, AVCodecContext *VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11,\nVAR_12, VAR_13, VAR_14;",
"IVIMbInfo *mb, *ref_mb;",
"int VAR_15 = VAR_1->mb_size * VAR_1->pitch;",
"mb = VAR_2->mbs;",
"ref_mb = VAR_2->ref_mbs;",
"VAR_9 = VAR_2->ypos * VAR_1->pitch + VAR_2->xpos;",
"VAR_11 = VAR_1->mb_size != VAR_1->blk_size ? 4 : 1;",
"VAR_13 = VAR_0->frame_type == FRAMETYPE_BIDIR ? 2 : 1;",
"VAR_12 = (VAR_0->planes[0].bands[0].mb_size >> 3) - (VAR_1->mb_size >> 3);",
"VAR_6 = VAR_7 = 0;",
"if (((VAR_2->width + VAR_1->mb_size-1)/VAR_1->mb_size) * ((VAR_2->height + VAR_1->mb_size-1)/VAR_1->mb_size) != VAR_2->num_MBs) {",
"av_log(VAR_3, AV_LOG_ERROR, \"num_MBs mismatch %d %d %d %d\\n\", VAR_2->width, VAR_2->height, VAR_1->mb_size, VAR_2->num_MBs);",
"return -1;",
"}",
"for (VAR_5 = VAR_2->ypos; VAR_5 < VAR_2->ypos + VAR_2->height; VAR_5 += VAR_1->mb_size) {",
"VAR_10 = VAR_9;",
"for (VAR_4 = VAR_2->xpos; VAR_4 < VAR_2->xpos + VAR_2->width; VAR_4 += VAR_1->mb_size) {",
"mb->xpos = VAR_4;",
"mb->ypos = VAR_5;",
"mb->buf_offs = VAR_10;",
"if (get_bits1(&VAR_0->gb)) {",
"if (VAR_0->frame_type == FRAMETYPE_INTRA) {",
"av_log(VAR_3, AV_LOG_ERROR, \"Empty macroblock in an INTRA picture!\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"mb->type = 1;",
"mb->cbp = 0;",
"mb->q_delta = 0;",
"if (!VAR_1->plane && !VAR_1->band_num && VAR_0->in_q) {",
"mb->q_delta = get_vlc2(&VAR_0->gb, VAR_0->mb_vlc.tab->table,\nIVI_VLC_BITS, 1);",
"mb->q_delta = IVI_TOSIGNED(mb->q_delta);",
"}",
"mb->VAR_6 = mb->VAR_7 = 0;",
"if (VAR_1->inherit_mv) {",
"if (VAR_12) {",
"mb->VAR_6 = ivi_scale_mv(ref_mb->VAR_6, VAR_12);",
"mb->VAR_7 = ivi_scale_mv(ref_mb->VAR_7, VAR_12);",
"} else {",
"mb->VAR_6 = ref_mb->VAR_6;",
"mb->VAR_7 = ref_mb->VAR_7;",
"}",
"}",
"} else {",
"if (VAR_1->inherit_mv && ref_mb) {",
"mb->type = ref_mb->type;",
"} else if (VAR_0->frame_type == FRAMETYPE_INTRA) {",
"mb->type = 0;",
"} else {",
"mb->type = get_bits(&VAR_0->gb, VAR_13);",
"}",
"mb->cbp = get_bits(&VAR_0->gb, VAR_11);",
"mb->q_delta = 0;",
"if (VAR_1->inherit_qdelta) {",
"if (ref_mb) mb->q_delta = ref_mb->q_delta;",
"} else if (mb->cbp || (!VAR_1->plane && !VAR_1->band_num &&",
"VAR_0->in_q)) {",
"mb->q_delta = get_vlc2(&VAR_0->gb, VAR_0->mb_vlc.tab->table,\nIVI_VLC_BITS, 1);",
"mb->q_delta = IVI_TOSIGNED(mb->q_delta);",
"}",
"if (!mb->type) {",
"mb->VAR_6 = mb->VAR_7 = 0;",
"} else {",
"if (VAR_1->inherit_mv) {",
"if (VAR_12) {",
"mb->VAR_6 = ivi_scale_mv(ref_mb->VAR_6, VAR_12);",
"mb->VAR_7 = ivi_scale_mv(ref_mb->VAR_7, VAR_12);",
"} else {",
"mb->VAR_6 = ref_mb->VAR_6;",
"mb->VAR_7 = ref_mb->VAR_7;",
"}",
"} else {",
"VAR_8 = get_vlc2(&VAR_0->gb, VAR_0->mb_vlc.tab->table,\nIVI_VLC_BITS, 1);",
"VAR_7 += IVI_TOSIGNED(VAR_8);",
"VAR_8 = get_vlc2(&VAR_0->gb, VAR_0->mb_vlc.tab->table,\nIVI_VLC_BITS, 1);",
"VAR_6 += IVI_TOSIGNED(VAR_8);",
"mb->VAR_6 = VAR_6;",
"mb->VAR_7 = VAR_7;",
"}",
"}",
"}",
"VAR_14= VAR_1->is_halfpel;",
"if (mb->type)\nif ( VAR_4 + (mb->VAR_6 >>VAR_14) + (VAR_5+ (mb->VAR_7 >>VAR_14))*VAR_1->pitch < 0 ||\nVAR_4 + ((mb->VAR_6+VAR_14)>>VAR_14) + VAR_1->mb_size - 1\n+ (VAR_5+VAR_1->mb_size - 1 +((mb->VAR_7+VAR_14)>>VAR_14))*VAR_1->pitch > VAR_1->bufsize -1) {",
"av_log(VAR_3, AV_LOG_ERROR, \"motion vector %d %d outside reference\\n\", VAR_4*VAR_14 + mb->VAR_6, VAR_5*VAR_14 + mb->VAR_7);",
"return AVERROR_INVALIDDATA;",
"}",
"mb++;",
"if (ref_mb)\nref_mb++;",
"VAR_10 += VAR_1->mb_size;",
"}",
"VAR_9 += VAR_15;",
"}",
"align_get_bits(&VAR_0->gb);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
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
] | [
[
1,
3,
5
],
[
7,
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85,
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149,
151
],
[
153
],
[
155
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
187,
189
],
[
191
],
[
193,
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
211
],
[
213,
215,
217,
219
],
[
221
],
[
223
],
[
225
],
[
229
],
[
231,
233
],
[
235
],
[
237
],
[
241
],
[
243
],
[
247
],
[
251
],
[
253
]
] |
3,587 | static int balloon_parse(const char *arg)
{
QemuOpts *opts;
if (strcmp(arg, "none") == 0) {
return 0;
}
if (!strncmp(arg, "virtio", 6)) {
if (arg[6] == ',') {
/* have params -> parse them */
opts = qemu_opts_parse(qemu_find_opts("device"), arg+7, 0);
if (!opts)
return -1;
} else {
/* create empty opts */
opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
}
qemu_opt_set(opts, "driver", "virtio-balloon");
return 0;
}
return -1;
}
| true | qemu | 8be7e7e4c72c048b90e3482557954a24bba43ba7 | static int balloon_parse(const char *arg)
{
QemuOpts *opts;
if (strcmp(arg, "none") == 0) {
return 0;
}
if (!strncmp(arg, "virtio", 6)) {
if (arg[6] == ',') {
opts = qemu_opts_parse(qemu_find_opts("device"), arg+7, 0);
if (!opts)
return -1;
} else {
opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
}
qemu_opt_set(opts, "driver", "virtio-balloon");
return 0;
}
return -1;
}
| {
"code": [
" opts = qemu_opts_create(qemu_find_opts(\"device\"), NULL, 0);",
" opts = qemu_opts_create(qemu_find_opts(\"device\"), NULL, 0);"
],
"line_no": [
33,
33
]
} | static int FUNC_0(const char *VAR_0)
{
QemuOpts *opts;
if (strcmp(VAR_0, "none") == 0) {
return 0;
}
if (!strncmp(VAR_0, "virtio", 6)) {
if (VAR_0[6] == ',') {
opts = qemu_opts_parse(qemu_find_opts("device"), VAR_0+7, 0);
if (!opts)
return -1;
} else {
opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
}
qemu_opt_set(opts, "driver", "virtio-balloon");
return 0;
}
return -1;
}
| [
"static int FUNC_0(const char *VAR_0)\n{",
"QemuOpts *opts;",
"if (strcmp(VAR_0, \"none\") == 0) {",
"return 0;",
"}",
"if (!strncmp(VAR_0, \"virtio\", 6)) {",
"if (VAR_0[6] == ',') {",
"opts = qemu_opts_parse(qemu_find_opts(\"device\"), VAR_0+7, 0);",
"if (!opts)\nreturn -1;",
"} else {",
"opts = qemu_opts_create(qemu_find_opts(\"device\"), NULL, 0);",
"}",
"qemu_opt_set(opts, \"driver\", \"virtio-balloon\");",
"return 0;",
"}",
"return -1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
23
],
[
25,
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
]
] |
3,588 | static inline void RENAME(yuv2yuvX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)
{
#ifdef HAVE_MMX
if(uDest != NULL)
{
asm volatile(
YSCALEYUV2YV12X(0, CHR_MMX_FILTER_OFFSET)
:: "r" (&c->redDither),
"r" (uDest), "p" ((long)chrDstW)
: "%"REG_a, "%"REG_d, "%"REG_S
);
asm volatile(
YSCALEYUV2YV12X(4096, CHR_MMX_FILTER_OFFSET)
:: "r" (&c->redDither),
"r" (vDest), "p" ((long)chrDstW)
: "%"REG_a, "%"REG_d, "%"REG_S
);
}
asm volatile(
YSCALEYUV2YV12X(0, LUM_MMX_FILTER_OFFSET)
:: "r" (&c->redDither),
"r" (dest), "p" ((long)dstW)
: "%"REG_a, "%"REG_d, "%"REG_S
);
#else
#ifdef HAVE_ALTIVEC
yuv2yuvX_altivec_real(lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
dest, uDest, vDest, dstW, chrDstW);
#else //HAVE_ALTIVEC
yuv2yuvXinC(lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
dest, uDest, vDest, dstW, chrDstW);
#endif //!HAVE_ALTIVEC
#endif
}
| true | FFmpeg | 7f526efd17973ec6d2204f7a47b6923e2be31363 | static inline void RENAME(yuv2yuvX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)
{
#ifdef HAVE_MMX
if(uDest != NULL)
{
asm volatile(
YSCALEYUV2YV12X(0, CHR_MMX_FILTER_OFFSET)
:: "r" (&c->redDither),
"r" (uDest), "p" ((long)chrDstW)
: "%"REG_a, "%"REG_d, "%"REG_S
);
asm volatile(
YSCALEYUV2YV12X(4096, CHR_MMX_FILTER_OFFSET)
:: "r" (&c->redDither),
"r" (vDest), "p" ((long)chrDstW)
: "%"REG_a, "%"REG_d, "%"REG_S
);
}
asm volatile(
YSCALEYUV2YV12X(0, LUM_MMX_FILTER_OFFSET)
:: "r" (&c->redDither),
"r" (dest), "p" ((long)dstW)
: "%"REG_a, "%"REG_d, "%"REG_S
);
#else
#ifdef HAVE_ALTIVEC
yuv2yuvX_altivec_real(lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
dest, uDest, vDest, dstW, chrDstW);
#else
yuv2yuvXinC(lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
dest, uDest, vDest, dstW, chrDstW);
#endif
#endif
}
| {
"code": [
"\t\t\t\t uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)",
"\t\t\t\t\"r\" (uDest), \"p\" ((long)chrDstW)",
"\t\t\t\t\"r\" (vDest), \"p\" ((long)chrDstW)",
"\t\t\t \"r\" (dest), \"p\" ((long)dstW)",
"\t\t\t\t uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)"
],
"line_no": [
5,
21,
35,
51,
5
]
} | static inline void FUNC_0(yuv2yuvX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)
{
#ifdef HAVE_MMX
if(uDest != NULL)
{
asm volatile(
YSCALEYUV2YV12X(0, CHR_MMX_FILTER_OFFSET)
:: "r" (&c->redDither),
"r" (uDest), "p" ((long)chrDstW)
: "%"REG_a, "%"REG_d, "%"REG_S
);
asm volatile(
YSCALEYUV2YV12X(4096, CHR_MMX_FILTER_OFFSET)
:: "r" (&c->redDither),
"r" (vDest), "p" ((long)chrDstW)
: "%"REG_a, "%"REG_d, "%"REG_S
);
}
asm volatile(
YSCALEYUV2YV12X(0, LUM_MMX_FILTER_OFFSET)
:: "r" (&c->redDither),
"r" (dest), "p" ((long)dstW)
: "%"REG_a, "%"REG_d, "%"REG_S
);
#else
#ifdef HAVE_ALTIVEC
yuv2yuvX_altivec_real(lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
dest, uDest, vDest, dstW, chrDstW);
#else
yuv2yuvXinC(lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
dest, uDest, vDest, dstW, chrDstW);
#endif
#endif
}
| [
"static inline void FUNC_0(yuv2yuvX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,\nint16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,\nuint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)\n{",
"#ifdef HAVE_MMX\nif(uDest != NULL)\n{",
"asm volatile(\nYSCALEYUV2YV12X(0, CHR_MMX_FILTER_OFFSET)\n:: \"r\" (&c->redDither),\n\"r\" (uDest), \"p\" ((long)chrDstW)\n: \"%\"REG_a, \"%\"REG_d, \"%\"REG_S\n);",
"asm volatile(\nYSCALEYUV2YV12X(4096, CHR_MMX_FILTER_OFFSET)\n:: \"r\" (&c->redDither),\n\"r\" (vDest), \"p\" ((long)chrDstW)\n: \"%\"REG_a, \"%\"REG_d, \"%\"REG_S\n);",
"}",
"asm volatile(\nYSCALEYUV2YV12X(0, LUM_MMX_FILTER_OFFSET)\n:: \"r\" (&c->redDither),\n\"r\" (dest), \"p\" ((long)dstW)\n: \"%\"REG_a, \"%\"REG_d, \"%\"REG_S\n);",
"#else\n#ifdef HAVE_ALTIVEC\nyuv2yuvX_altivec_real(lumFilter, lumSrc, lumFilterSize,\nchrFilter, chrSrc, chrFilterSize,\ndest, uDest, vDest, dstW, chrDstW);",
"#else\nyuv2yuvXinC(lumFilter, lumSrc, lumFilterSize,\nchrFilter, chrSrc, chrFilterSize,\ndest, uDest, vDest, dstW, chrDstW);",
"#endif\n#endif\n}"
] | [
1,
0,
1,
1,
0,
1,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9,
11,
13
],
[
15,
17,
19,
21,
23,
25
],
[
29,
31,
33,
35,
37,
39
],
[
41
],
[
45,
47,
49,
51,
53,
55
],
[
57,
59,
61,
63,
65
],
[
67,
69,
71,
73
],
[
75,
77,
79
]
] |
3,589 | int attribute_align_arg avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,
int *frame_size_ptr,
uint8_t *buf, int buf_size)
{
int ret;
if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){
//FIXME remove the check below _after_ ensuring that all audio check that the available space is enough
if(*frame_size_ptr < AVCODEC_MAX_AUDIO_FRAME_SIZE){
av_log(avctx, AV_LOG_ERROR, "buffer smaller than AVCODEC_MAX_AUDIO_FRAME_SIZE\n");
return -1;
}
if(*frame_size_ptr < FF_MIN_BUFFER_SIZE ||
*frame_size_ptr < avctx->channels * avctx->frame_size * sizeof(int16_t) ||
*frame_size_ptr < buf_size){
av_log(avctx, AV_LOG_ERROR, "buffer %d too small\n", *frame_size_ptr);
return -1;
}
ret = avctx->codec->decode(avctx, samples, frame_size_ptr,
buf, buf_size);
avctx->frame_number++;
}else{
ret= 0;
*frame_size_ptr=0;
}
return ret;
}
| false | FFmpeg | 81fc2f37db98b3472bf997e5f302e65d75670f3e | int attribute_align_arg avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,
int *frame_size_ptr,
uint8_t *buf, int buf_size)
{
int ret;
if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){
if(*frame_size_ptr < AVCODEC_MAX_AUDIO_FRAME_SIZE){
av_log(avctx, AV_LOG_ERROR, "buffer smaller than AVCODEC_MAX_AUDIO_FRAME_SIZE\n");
return -1;
}
if(*frame_size_ptr < FF_MIN_BUFFER_SIZE ||
*frame_size_ptr < avctx->channels * avctx->frame_size * sizeof(int16_t) ||
*frame_size_ptr < buf_size){
av_log(avctx, AV_LOG_ERROR, "buffer %d too small\n", *frame_size_ptr);
return -1;
}
ret = avctx->codec->decode(avctx, samples, frame_size_ptr,
buf, buf_size);
avctx->frame_number++;
}else{
ret= 0;
*frame_size_ptr=0;
}
return ret;
}
| {
"code": [],
"line_no": []
} | int VAR_0 avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,
int *frame_size_ptr,
uint8_t *buf, int buf_size)
{
int ret;
if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){
if(*frame_size_ptr < AVCODEC_MAX_AUDIO_FRAME_SIZE){
av_log(avctx, AV_LOG_ERROR, "buffer smaller than AVCODEC_MAX_AUDIO_FRAME_SIZE\n");
return -1;
}
if(*frame_size_ptr < FF_MIN_BUFFER_SIZE ||
*frame_size_ptr < avctx->channels * avctx->frame_size * sizeof(int16_t) ||
*frame_size_ptr < buf_size){
av_log(avctx, AV_LOG_ERROR, "buffer %d too small\n", *frame_size_ptr);
return -1;
}
ret = avctx->codec->decode(avctx, samples, frame_size_ptr,
buf, buf_size);
avctx->frame_number++;
}else{
ret= 0;
*frame_size_ptr=0;
}
return ret;
}
| [
"int VAR_0 avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,\nint *frame_size_ptr,\nuint8_t *buf, int buf_size)\n{",
"int ret;",
"if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){",
"if(*frame_size_ptr < AVCODEC_MAX_AUDIO_FRAME_SIZE){",
"av_log(avctx, AV_LOG_ERROR, \"buffer smaller than AVCODEC_MAX_AUDIO_FRAME_SIZE\\n\");",
"return -1;",
"}",
"if(*frame_size_ptr < FF_MIN_BUFFER_SIZE ||\n*frame_size_ptr < avctx->channels * avctx->frame_size * sizeof(int16_t) ||\n*frame_size_ptr < buf_size){",
"av_log(avctx, AV_LOG_ERROR, \"buffer %d too small\\n\", *frame_size_ptr);",
"return -1;",
"}",
"ret = avctx->codec->decode(avctx, samples, frame_size_ptr,\nbuf, buf_size);",
"avctx->frame_number++;",
"}else{",
"ret= 0;",
"*frame_size_ptr=0;",
"}",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27,
29
],
[
31
],
[
33
],
[
35
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
]
] |
3,590 | static void nbd_co_receive_reply(NBDClientSession *s,
NBDRequest *request,
NBDReply *reply,
QEMUIOVector *qiov)
{
int ret;
/* Wait until we're woken up by nbd_read_reply_entry. */
qemu_coroutine_yield();
*reply = s->reply;
if (reply->handle != request->handle ||
!s->ioc) {
reply->error = EIO;
} else {
if (qiov && reply->error == 0) {
ret = nbd_rwv(s->ioc, qiov->iov, qiov->niov, request->len, true,
NULL);
if (ret != request->len) {
reply->error = EIO;
}
}
/* Tell the read handler to read another header. */
s->reply.handle = 0;
}
}
| true | qemu | 72b6ffc76653214b69a94a7b1643ff80df134486 | static void nbd_co_receive_reply(NBDClientSession *s,
NBDRequest *request,
NBDReply *reply,
QEMUIOVector *qiov)
{
int ret;
qemu_coroutine_yield();
*reply = s->reply;
if (reply->handle != request->handle ||
!s->ioc) {
reply->error = EIO;
} else {
if (qiov && reply->error == 0) {
ret = nbd_rwv(s->ioc, qiov->iov, qiov->niov, request->len, true,
NULL);
if (ret != request->len) {
reply->error = EIO;
}
}
s->reply.handle = 0;
}
}
| {
"code": [
" if (reply->handle != request->handle ||",
" !s->ioc) {"
],
"line_no": [
21,
23
]
} | static void FUNC_0(NBDClientSession *VAR_0,
NBDRequest *VAR_1,
NBDReply *VAR_2,
QEMUIOVector *VAR_3)
{
int VAR_4;
qemu_coroutine_yield();
*VAR_2 = VAR_0->VAR_2;
if (VAR_2->handle != VAR_1->handle ||
!VAR_0->ioc) {
VAR_2->error = EIO;
} else {
if (VAR_3 && VAR_2->error == 0) {
VAR_4 = nbd_rwv(VAR_0->ioc, VAR_3->iov, VAR_3->niov, VAR_1->len, true,
NULL);
if (VAR_4 != VAR_1->len) {
VAR_2->error = EIO;
}
}
VAR_0->VAR_2.handle = 0;
}
}
| [
"static void FUNC_0(NBDClientSession *VAR_0,\nNBDRequest *VAR_1,\nNBDReply *VAR_2,\nQEMUIOVector *VAR_3)\n{",
"int VAR_4;",
"qemu_coroutine_yield();",
"*VAR_2 = VAR_0->VAR_2;",
"if (VAR_2->handle != VAR_1->handle ||\n!VAR_0->ioc) {",
"VAR_2->error = EIO;",
"} else {",
"if (VAR_3 && VAR_2->error == 0) {",
"VAR_4 = nbd_rwv(VAR_0->ioc, VAR_3->iov, VAR_3->niov, VAR_1->len, true,\nNULL);",
"if (VAR_4 != VAR_1->len) {",
"VAR_2->error = EIO;",
"}",
"}",
"VAR_0->VAR_2.handle = 0;",
"}",
"}"
] | [
0,
0,
0,
0,
1,
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
],
[
47
],
[
49
],
[
51
]
] |
3,591 | static const char *local_mapped_attr_path(FsContext *ctx,
const char *path, char *buffer)
{
char *dir_name;
char *tmp_path = strdup(path);
char *base_name = basename(tmp_path);
/* NULL terminate the directory */
dir_name = tmp_path;
*(base_name - 1) = '\0';
snprintf(buffer, PATH_MAX, "%s/%s/%s/%s",
ctx->fs_root, dir_name, VIRTFS_META_DIR, base_name);
free(tmp_path);
return buffer;
}
| true | qemu | d3f8e138c23ba082f87c96634d06b978473c1e9b | static const char *local_mapped_attr_path(FsContext *ctx,
const char *path, char *buffer)
{
char *dir_name;
char *tmp_path = strdup(path);
char *base_name = basename(tmp_path);
dir_name = tmp_path;
*(base_name - 1) = '\0';
snprintf(buffer, PATH_MAX, "%s/%s/%s/%s",
ctx->fs_root, dir_name, VIRTFS_META_DIR, base_name);
free(tmp_path);
return buffer;
}
| {
"code": [
" char *tmp_path = strdup(path);",
" free(tmp_path);",
" char *tmp_path = strdup(path);",
" free(tmp_path);"
],
"line_no": [
9,
27,
9,
27
]
} | static const char *FUNC_0(FsContext *VAR_0,
const char *VAR_1, char *VAR_2)
{
char *VAR_3;
char *VAR_4 = strdup(VAR_1);
char *VAR_5 = basename(VAR_4);
VAR_3 = VAR_4;
*(VAR_5 - 1) = '\0';
snprintf(VAR_2, PATH_MAX, "%s/%s/%s/%s",
VAR_0->fs_root, VAR_3, VIRTFS_META_DIR, VAR_5);
free(VAR_4);
return VAR_2;
}
| [
"static const char *FUNC_0(FsContext *VAR_0,\nconst char *VAR_1, char *VAR_2)\n{",
"char *VAR_3;",
"char *VAR_4 = strdup(VAR_1);",
"char *VAR_5 = basename(VAR_4);",
"VAR_3 = VAR_4;",
"*(VAR_5 - 1) = '\\0';",
"snprintf(VAR_2, PATH_MAX, \"%s/%s/%s/%s\",\nVAR_0->fs_root, VAR_3, VIRTFS_META_DIR, VAR_5);",
"free(VAR_4);",
"return VAR_2;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
17
],
[
19
],
[
23,
25
],
[
27
],
[
29
],
[
31
]
] |
3,592 | void usb_host_info(Monitor *mon, const QDict *qdict)
{
libusb_device **devs;
struct libusb_device_descriptor ddesc;
char port[16];
int i, n;
if (usb_host_init() != 0) {
return;
}
n = libusb_get_device_list(ctx, &devs);
for (i = 0; i < n; i++) {
if (libusb_get_device_descriptor(devs[i], &ddesc) != 0) {
continue;
}
if (ddesc.bDeviceClass == LIBUSB_CLASS_HUB) {
continue;
}
usb_host_get_port(devs[i], port, sizeof(port));
monitor_printf(mon, " Bus %d, Addr %d, Port %s, Speed %s Mb/s\n",
libusb_get_bus_number(devs[i]),
libusb_get_device_address(devs[i]),
port,
speed_name[libusb_get_device_speed(devs[i])]);
monitor_printf(mon, " Class %02x:", ddesc.bDeviceClass);
monitor_printf(mon, " USB device %04x:%04x",
ddesc.idVendor, ddesc.idProduct);
if (ddesc.iProduct) {
libusb_device_handle *handle;
if (libusb_open(devs[i], &handle) == 0) {
unsigned char name[64] = "";
libusb_get_string_descriptor_ascii(handle,
ddesc.iProduct,
name, sizeof(name));
libusb_close(handle);
monitor_printf(mon, ", %s", name);
}
}
monitor_printf(mon, "\n");
}
libusb_free_device_list(devs, 1);
}
| true | qemu | 3ce21445387c64032a21ae73c995195307a28a36 | void usb_host_info(Monitor *mon, const QDict *qdict)
{
libusb_device **devs;
struct libusb_device_descriptor ddesc;
char port[16];
int i, n;
if (usb_host_init() != 0) {
return;
}
n = libusb_get_device_list(ctx, &devs);
for (i = 0; i < n; i++) {
if (libusb_get_device_descriptor(devs[i], &ddesc) != 0) {
continue;
}
if (ddesc.bDeviceClass == LIBUSB_CLASS_HUB) {
continue;
}
usb_host_get_port(devs[i], port, sizeof(port));
monitor_printf(mon, " Bus %d, Addr %d, Port %s, Speed %s Mb/s\n",
libusb_get_bus_number(devs[i]),
libusb_get_device_address(devs[i]),
port,
speed_name[libusb_get_device_speed(devs[i])]);
monitor_printf(mon, " Class %02x:", ddesc.bDeviceClass);
monitor_printf(mon, " USB device %04x:%04x",
ddesc.idVendor, ddesc.idProduct);
if (ddesc.iProduct) {
libusb_device_handle *handle;
if (libusb_open(devs[i], &handle) == 0) {
unsigned char name[64] = "";
libusb_get_string_descriptor_ascii(handle,
ddesc.iProduct,
name, sizeof(name));
libusb_close(handle);
monitor_printf(mon, ", %s", name);
}
}
monitor_printf(mon, "\n");
}
libusb_free_device_list(devs, 1);
}
| {
"code": [
" libusb_device **devs;",
" libusb_device **devs;"
],
"line_no": [
5,
5
]
} | void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)
{
libusb_device **devs;
struct libusb_device_descriptor VAR_2;
char VAR_3[16];
int VAR_4, VAR_5;
if (usb_host_init() != 0) {
return;
}
VAR_5 = libusb_get_device_list(ctx, &devs);
for (VAR_4 = 0; VAR_4 < VAR_5; VAR_4++) {
if (libusb_get_device_descriptor(devs[VAR_4], &VAR_2) != 0) {
continue;
}
if (VAR_2.bDeviceClass == LIBUSB_CLASS_HUB) {
continue;
}
usb_host_get_port(devs[VAR_4], VAR_3, sizeof(VAR_3));
monitor_printf(VAR_0, " Bus %d, Addr %d, Port %s, Speed %s Mb/s\VAR_5",
libusb_get_bus_number(devs[VAR_4]),
libusb_get_device_address(devs[VAR_4]),
VAR_3,
speed_name[libusb_get_device_speed(devs[VAR_4])]);
monitor_printf(VAR_0, " Class %02x:", VAR_2.bDeviceClass);
monitor_printf(VAR_0, " USB device %04x:%04x",
VAR_2.idVendor, VAR_2.idProduct);
if (VAR_2.iProduct) {
libusb_device_handle *handle;
if (libusb_open(devs[VAR_4], &handle) == 0) {
unsigned char VAR_6[64] = "";
libusb_get_string_descriptor_ascii(handle,
VAR_2.iProduct,
VAR_6, sizeof(VAR_6));
libusb_close(handle);
monitor_printf(VAR_0, ", %s", VAR_6);
}
}
monitor_printf(VAR_0, "\VAR_5");
}
libusb_free_device_list(devs, 1);
}
| [
"void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)\n{",
"libusb_device **devs;",
"struct libusb_device_descriptor VAR_2;",
"char VAR_3[16];",
"int VAR_4, VAR_5;",
"if (usb_host_init() != 0) {",
"return;",
"}",
"VAR_5 = libusb_get_device_list(ctx, &devs);",
"for (VAR_4 = 0; VAR_4 < VAR_5; VAR_4++) {",
"if (libusb_get_device_descriptor(devs[VAR_4], &VAR_2) != 0) {",
"continue;",
"}",
"if (VAR_2.bDeviceClass == LIBUSB_CLASS_HUB) {",
"continue;",
"}",
"usb_host_get_port(devs[VAR_4], VAR_3, sizeof(VAR_3));",
"monitor_printf(VAR_0, \" Bus %d, Addr %d, Port %s, Speed %s Mb/s\\VAR_5\",\nlibusb_get_bus_number(devs[VAR_4]),\nlibusb_get_device_address(devs[VAR_4]),\nVAR_3,\nspeed_name[libusb_get_device_speed(devs[VAR_4])]);",
"monitor_printf(VAR_0, \" Class %02x:\", VAR_2.bDeviceClass);",
"monitor_printf(VAR_0, \" USB device %04x:%04x\",\nVAR_2.idVendor, VAR_2.idProduct);",
"if (VAR_2.iProduct) {",
"libusb_device_handle *handle;",
"if (libusb_open(devs[VAR_4], &handle) == 0) {",
"unsigned char VAR_6[64] = \"\";",
"libusb_get_string_descriptor_ascii(handle,\nVAR_2.iProduct,\nVAR_6, sizeof(VAR_6));",
"libusb_close(handle);",
"monitor_printf(VAR_0, \", %s\", VAR_6);",
"}",
"}",
"monitor_printf(VAR_0, \"\\VAR_5\");",
"}",
"libusb_free_device_list(devs, 1);",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43,
45,
47,
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
]
] |
3,593 | static void gen_mulldo(DisasContext *ctx)
{
TCGv_i64 t0 = tcg_temp_new_i64();
TCGv_i64 t1 = tcg_temp_new_i64();
tcg_gen_muls2_i64(t0, t1, cpu_gpr[rA(ctx->opcode)],
cpu_gpr[rB(ctx->opcode)]);
tcg_gen_mov_i64(cpu_gpr[rD(ctx->opcode)], t0);
tcg_gen_sari_i64(t0, t0, 63);
tcg_gen_setcond_i64(TCG_COND_NE, cpu_ov, t0, t1);
tcg_gen_or_tl(cpu_so, cpu_so, cpu_ov);
tcg_temp_free_i64(t0);
tcg_temp_free_i64(t1);
if (unlikely(Rc(ctx->opcode) != 0)) {
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
| true | qemu | 61aa9a697a1ec9b102e86cb7ea96876e6f20afe3 | static void gen_mulldo(DisasContext *ctx)
{
TCGv_i64 t0 = tcg_temp_new_i64();
TCGv_i64 t1 = tcg_temp_new_i64();
tcg_gen_muls2_i64(t0, t1, cpu_gpr[rA(ctx->opcode)],
cpu_gpr[rB(ctx->opcode)]);
tcg_gen_mov_i64(cpu_gpr[rD(ctx->opcode)], t0);
tcg_gen_sari_i64(t0, t0, 63);
tcg_gen_setcond_i64(TCG_COND_NE, cpu_ov, t0, t1);
tcg_gen_or_tl(cpu_so, cpu_so, cpu_ov);
tcg_temp_free_i64(t0);
tcg_temp_free_i64(t1);
if (unlikely(Rc(ctx->opcode) != 0)) {
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0)
{
TCGv_i64 t0 = tcg_temp_new_i64();
TCGv_i64 t1 = tcg_temp_new_i64();
tcg_gen_muls2_i64(t0, t1, cpu_gpr[rA(VAR_0->opcode)],
cpu_gpr[rB(VAR_0->opcode)]);
tcg_gen_mov_i64(cpu_gpr[rD(VAR_0->opcode)], t0);
tcg_gen_sari_i64(t0, t0, 63);
tcg_gen_setcond_i64(TCG_COND_NE, cpu_ov, t0, t1);
tcg_gen_or_tl(cpu_so, cpu_so, cpu_ov);
tcg_temp_free_i64(t0);
tcg_temp_free_i64(t1);
if (unlikely(Rc(VAR_0->opcode) != 0)) {
gen_set_Rc0(VAR_0, cpu_gpr[rD(VAR_0->opcode)]);
| [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"TCGv_i64 t0 = tcg_temp_new_i64();",
"TCGv_i64 t1 = tcg_temp_new_i64();",
"tcg_gen_muls2_i64(t0, t1, cpu_gpr[rA(VAR_0->opcode)],\ncpu_gpr[rB(VAR_0->opcode)]);",
"tcg_gen_mov_i64(cpu_gpr[rD(VAR_0->opcode)], t0);",
"tcg_gen_sari_i64(t0, t0, 63);",
"tcg_gen_setcond_i64(TCG_COND_NE, cpu_ov, t0, t1);",
"tcg_gen_or_tl(cpu_so, cpu_so, cpu_ov);",
"tcg_temp_free_i64(t0);",
"tcg_temp_free_i64(t1);",
"if (unlikely(Rc(VAR_0->opcode) != 0)) {",
"gen_set_Rc0(VAR_0, cpu_gpr[rD(VAR_0->opcode)]);"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15
],
[
19
],
[
21
],
[
26
],
[
30
],
[
32
],
[
36
],
[
38
]
] |
3,594 | static inline target_phys_addr_t get_pgaddr (target_phys_addr_t sdr1,
int sdr_sh,
target_phys_addr_t hash,
target_phys_addr_t mask)
{
return (sdr1 & ((target_ulong)(-1ULL) << sdr_sh)) | (hash & mask);
}
| true | qemu | 12de9a396acbc95e25c5d60ed097cc55777eaaed | static inline target_phys_addr_t get_pgaddr (target_phys_addr_t sdr1,
int sdr_sh,
target_phys_addr_t hash,
target_phys_addr_t mask)
{
return (sdr1 & ((target_ulong)(-1ULL) << sdr_sh)) | (hash & mask);
}
| {
"code": [
"static inline target_phys_addr_t get_pgaddr (target_phys_addr_t sdr1,",
" int sdr_sh,",
" target_phys_addr_t hash,",
" target_phys_addr_t mask)",
" return (sdr1 & ((target_ulong)(-1ULL) << sdr_sh)) | (hash & mask);"
],
"line_no": [
1,
3,
5,
7,
11
]
} | static inline target_phys_addr_t FUNC_0 (target_phys_addr_t sdr1,
int sdr_sh,
target_phys_addr_t hash,
target_phys_addr_t mask)
{
return (sdr1 & ((target_ulong)(-1ULL) << sdr_sh)) | (hash & mask);
}
| [
"static inline target_phys_addr_t FUNC_0 (target_phys_addr_t sdr1,\nint sdr_sh,\ntarget_phys_addr_t hash,\ntarget_phys_addr_t mask)\n{",
"return (sdr1 & ((target_ulong)(-1ULL) << sdr_sh)) | (hash & mask);",
"}"
] | [
1,
1,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
]
] |
3,595 | static unsigned int mszh_decomp(const unsigned char * srcptr, int srclen, unsigned char * destptr, unsigned int destsize)
{
unsigned char *destptr_bak = destptr;
unsigned char *destptr_end = destptr + destsize;
const unsigned char *srcptr_end = srcptr + srclen;
unsigned mask = *srcptr++;
unsigned maskbit = 0x80;
while (srcptr < srcptr_end && destptr < destptr_end) {
if (!(mask & maskbit)) {
memcpy(destptr, srcptr, 4);
destptr += 4;
srcptr += 4;
} else {
unsigned ofs = bytestream_get_le16(&srcptr);
unsigned cnt = (ofs >> 11) + 1;
ofs &= 0x7ff;
ofs = FFMIN(ofs, destptr - destptr_bak);
cnt *= 4;
cnt = FFMIN(cnt, destptr_end - destptr);
av_memcpy_backptr(destptr, ofs, cnt);
destptr += cnt;
}
maskbit >>= 1;
if (!maskbit) {
mask = *srcptr++;
while (!mask) {
if (destptr_end - destptr < 32 || srcptr_end - srcptr < 32) break;
memcpy(destptr, srcptr, 32);
destptr += 32;
srcptr += 32;
mask = *srcptr++;
}
maskbit = 0x80;
}
}
return destptr - destptr_bak;
}
| true | FFmpeg | 42a1f1d7a8cf67eed68db596d6a1e53c0c36e4ab | static unsigned int mszh_decomp(const unsigned char * srcptr, int srclen, unsigned char * destptr, unsigned int destsize)
{
unsigned char *destptr_bak = destptr;
unsigned char *destptr_end = destptr + destsize;
const unsigned char *srcptr_end = srcptr + srclen;
unsigned mask = *srcptr++;
unsigned maskbit = 0x80;
while (srcptr < srcptr_end && destptr < destptr_end) {
if (!(mask & maskbit)) {
memcpy(destptr, srcptr, 4);
destptr += 4;
srcptr += 4;
} else {
unsigned ofs = bytestream_get_le16(&srcptr);
unsigned cnt = (ofs >> 11) + 1;
ofs &= 0x7ff;
ofs = FFMIN(ofs, destptr - destptr_bak);
cnt *= 4;
cnt = FFMIN(cnt, destptr_end - destptr);
av_memcpy_backptr(destptr, ofs, cnt);
destptr += cnt;
}
maskbit >>= 1;
if (!maskbit) {
mask = *srcptr++;
while (!mask) {
if (destptr_end - destptr < 32 || srcptr_end - srcptr < 32) break;
memcpy(destptr, srcptr, 32);
destptr += 32;
srcptr += 32;
mask = *srcptr++;
}
maskbit = 0x80;
}
}
return destptr - destptr_bak;
}
| {
"code": [
" av_memcpy_backptr(destptr, ofs, cnt);"
],
"line_no": [
41
]
} | static unsigned int FUNC_0(const unsigned char * VAR_0, int VAR_1, unsigned char * VAR_2, unsigned int VAR_3)
{
unsigned char *VAR_4 = VAR_2;
unsigned char *VAR_5 = VAR_2 + VAR_3;
const unsigned char *VAR_6 = VAR_0 + VAR_1;
unsigned VAR_7 = *VAR_0++;
unsigned VAR_8 = 0x80;
while (VAR_0 < VAR_6 && VAR_2 < VAR_5) {
if (!(VAR_7 & VAR_8)) {
memcpy(VAR_2, VAR_0, 4);
VAR_2 += 4;
VAR_0 += 4;
} else {
unsigned VAR_9 = bytestream_get_le16(&VAR_0);
unsigned VAR_10 = (VAR_9 >> 11) + 1;
VAR_9 &= 0x7ff;
VAR_9 = FFMIN(VAR_9, VAR_2 - VAR_4);
VAR_10 *= 4;
VAR_10 = FFMIN(VAR_10, VAR_5 - VAR_2);
av_memcpy_backptr(VAR_2, VAR_9, VAR_10);
VAR_2 += VAR_10;
}
VAR_8 >>= 1;
if (!VAR_8) {
VAR_7 = *VAR_0++;
while (!VAR_7) {
if (VAR_5 - VAR_2 < 32 || VAR_6 - VAR_0 < 32) break;
memcpy(VAR_2, VAR_0, 32);
VAR_2 += 32;
VAR_0 += 32;
VAR_7 = *VAR_0++;
}
VAR_8 = 0x80;
}
}
return VAR_2 - VAR_4;
}
| [
"static unsigned int FUNC_0(const unsigned char * VAR_0, int VAR_1, unsigned char * VAR_2, unsigned int VAR_3)\n{",
"unsigned char *VAR_4 = VAR_2;",
"unsigned char *VAR_5 = VAR_2 + VAR_3;",
"const unsigned char *VAR_6 = VAR_0 + VAR_1;",
"unsigned VAR_7 = *VAR_0++;",
"unsigned VAR_8 = 0x80;",
"while (VAR_0 < VAR_6 && VAR_2 < VAR_5) {",
"if (!(VAR_7 & VAR_8)) {",
"memcpy(VAR_2, VAR_0, 4);",
"VAR_2 += 4;",
"VAR_0 += 4;",
"} else {",
"unsigned VAR_9 = bytestream_get_le16(&VAR_0);",
"unsigned VAR_10 = (VAR_9 >> 11) + 1;",
"VAR_9 &= 0x7ff;",
"VAR_9 = FFMIN(VAR_9, VAR_2 - VAR_4);",
"VAR_10 *= 4;",
"VAR_10 = FFMIN(VAR_10, VAR_5 - VAR_2);",
"av_memcpy_backptr(VAR_2, VAR_9, VAR_10);",
"VAR_2 += VAR_10;",
"}",
"VAR_8 >>= 1;",
"if (!VAR_8) {",
"VAR_7 = *VAR_0++;",
"while (!VAR_7) {",
"if (VAR_5 - VAR_2 < 32 || VAR_6 - VAR_0 < 32) break;",
"memcpy(VAR_2, VAR_0, 32);",
"VAR_2 += 32;",
"VAR_0 += 32;",
"VAR_7 = *VAR_0++;",
"}",
"VAR_8 = 0x80;",
"}",
"}",
"return VAR_2 - VAR_4;",
"}"
] | [
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
],
[
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
],
[
75
],
[
77
]
] |
3,597 | static uint32_t unassigned_mem_readb(void *opaque, target_phys_addr_t addr)
{
#ifdef DEBUG_UNASSIGNED
printf("Unassigned mem read " TARGET_FMT_plx "\n", addr);
#endif
#if defined(TARGET_ALPHA) || defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE)
do_unassigned_access(addr, 0, 0, 0, 1);
#endif
return 0;
}
| true | qemu | b14ef7c9ab41ea824c3ccadb070ad95567cca84e | static uint32_t unassigned_mem_readb(void *opaque, target_phys_addr_t addr)
{
#ifdef DEBUG_UNASSIGNED
printf("Unassigned mem read " TARGET_FMT_plx "\n", addr);
#endif
#if defined(TARGET_ALPHA) || defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE)
do_unassigned_access(addr, 0, 0, 0, 1);
#endif
return 0;
}
| {
"code": [
" do_unassigned_access(addr, 0, 0, 0, 1);"
],
"line_no": [
13
]
} | static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)
{
#ifdef DEBUG_UNASSIGNED
printf("Unassigned mem read " TARGET_FMT_plx "\n", addr);
#endif
#if defined(TARGET_ALPHA) || defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE)
do_unassigned_access(addr, 0, 0, 0, 1);
#endif
return 0;
}
| [
"static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)\n{",
"#ifdef DEBUG_UNASSIGNED\nprintf(\"Unassigned mem read \" TARGET_FMT_plx \"\\n\", addr);",
"#endif\n#if defined(TARGET_ALPHA) || defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE)\ndo_unassigned_access(addr, 0, 0, 0, 1);",
"#endif\nreturn 0;",
"}"
] | [
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9,
11,
13
],
[
15,
17
],
[
19
]
] |
3,599 | static int mxg_update_cache(AVFormatContext *s, unsigned int cache_size)
{
MXGContext *mxg = s->priv_data;
unsigned int current_pos = mxg->buffer_ptr - mxg->buffer;
unsigned int soi_pos;
int ret;
/* reallocate internal buffer */
if (current_pos > current_pos + cache_size)
return AVERROR(ENOMEM);
soi_pos = mxg->soi_ptr - mxg->buffer;
mxg->buffer = av_fast_realloc(mxg->buffer, &mxg->buffer_size,
current_pos + cache_size +
FF_INPUT_BUFFER_PADDING_SIZE);
if (!mxg->buffer)
return AVERROR(ENOMEM);
mxg->buffer_ptr = mxg->buffer + current_pos;
if (mxg->soi_ptr) mxg->soi_ptr = mxg->buffer + soi_pos;
/* get data */
ret = avio_read(s->pb, mxg->buffer_ptr + mxg->cache_size,
cache_size - mxg->cache_size);
if (ret < 0)
return ret;
mxg->cache_size += ret;
return ret;
}
| true | FFmpeg | a72b41035cc4925922b4164b7453c9a5c2b7e630 | static int mxg_update_cache(AVFormatContext *s, unsigned int cache_size)
{
MXGContext *mxg = s->priv_data;
unsigned int current_pos = mxg->buffer_ptr - mxg->buffer;
unsigned int soi_pos;
int ret;
if (current_pos > current_pos + cache_size)
return AVERROR(ENOMEM);
soi_pos = mxg->soi_ptr - mxg->buffer;
mxg->buffer = av_fast_realloc(mxg->buffer, &mxg->buffer_size,
current_pos + cache_size +
FF_INPUT_BUFFER_PADDING_SIZE);
if (!mxg->buffer)
return AVERROR(ENOMEM);
mxg->buffer_ptr = mxg->buffer + current_pos;
if (mxg->soi_ptr) mxg->soi_ptr = mxg->buffer + soi_pos;
ret = avio_read(s->pb, mxg->buffer_ptr + mxg->cache_size,
cache_size - mxg->cache_size);
if (ret < 0)
return ret;
mxg->cache_size += ret;
return ret;
}
| {
"code": [
" mxg->buffer = av_fast_realloc(mxg->buffer, &mxg->buffer_size,",
" current_pos + cache_size +",
" FF_INPUT_BUFFER_PADDING_SIZE);",
" if (!mxg->buffer)"
],
"line_no": [
23,
25,
27,
29
]
} | static int FUNC_0(AVFormatContext *VAR_0, unsigned int VAR_1)
{
MXGContext *mxg = VAR_0->priv_data;
unsigned int VAR_2 = mxg->buffer_ptr - mxg->buffer;
unsigned int VAR_3;
int VAR_4;
if (VAR_2 > VAR_2 + VAR_1)
return AVERROR(ENOMEM);
VAR_3 = mxg->soi_ptr - mxg->buffer;
mxg->buffer = av_fast_realloc(mxg->buffer, &mxg->buffer_size,
VAR_2 + VAR_1 +
FF_INPUT_BUFFER_PADDING_SIZE);
if (!mxg->buffer)
return AVERROR(ENOMEM);
mxg->buffer_ptr = mxg->buffer + VAR_2;
if (mxg->soi_ptr) mxg->soi_ptr = mxg->buffer + VAR_3;
VAR_4 = avio_read(VAR_0->pb, mxg->buffer_ptr + mxg->VAR_1,
VAR_1 - mxg->VAR_1);
if (VAR_4 < 0)
return VAR_4;
mxg->VAR_1 += VAR_4;
return VAR_4;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, unsigned int VAR_1)\n{",
"MXGContext *mxg = VAR_0->priv_data;",
"unsigned int VAR_2 = mxg->buffer_ptr - mxg->buffer;",
"unsigned int VAR_3;",
"int VAR_4;",
"if (VAR_2 > VAR_2 + VAR_1)\nreturn AVERROR(ENOMEM);",
"VAR_3 = mxg->soi_ptr - mxg->buffer;",
"mxg->buffer = av_fast_realloc(mxg->buffer, &mxg->buffer_size,\nVAR_2 + VAR_1 +\nFF_INPUT_BUFFER_PADDING_SIZE);",
"if (!mxg->buffer)\nreturn AVERROR(ENOMEM);",
"mxg->buffer_ptr = mxg->buffer + VAR_2;",
"if (mxg->soi_ptr) mxg->soi_ptr = mxg->buffer + VAR_3;",
"VAR_4 = avio_read(VAR_0->pb, mxg->buffer_ptr + mxg->VAR_1,\nVAR_1 - mxg->VAR_1);",
"if (VAR_4 < 0)\nreturn VAR_4;",
"mxg->VAR_1 += VAR_4;",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
17,
19
],
[
21
],
[
23,
25,
27
],
[
29,
31
],
[
33
],
[
35
],
[
41,
43
],
[
45,
47
],
[
51
],
[
55
],
[
57
]
] |
3,601 | vubr_set_mem_table_exec(VubrDev *dev, VhostUserMsg *vmsg)
{
int i;
VhostUserMemory *memory = &vmsg->payload.memory;
dev->nregions = memory->nregions;
DPRINT("Nregions: %d\n", memory->nregions);
for (i = 0; i < dev->nregions; i++) {
void *mmap_addr;
VhostUserMemoryRegion *msg_region = &memory->regions[i];
VubrDevRegion *dev_region = &dev->regions[i];
DPRINT("Region %d\n", i);
DPRINT(" guest_phys_addr: 0x%016"PRIx64"\n",
msg_region->guest_phys_addr);
DPRINT(" memory_size: 0x%016"PRIx64"\n",
msg_region->memory_size);
DPRINT(" userspace_addr 0x%016"PRIx64"\n",
msg_region->userspace_addr);
DPRINT(" mmap_offset 0x%016"PRIx64"\n",
msg_region->mmap_offset);
dev_region->gpa = msg_region->guest_phys_addr;
dev_region->size = msg_region->memory_size;
dev_region->qva = msg_region->userspace_addr;
dev_region->mmap_offset = msg_region->mmap_offset;
/* We don't use offset argument of mmap() since the
* mapped address has to be page aligned, and we use huge
* pages. */
mmap_addr = mmap(0, dev_region->size + dev_region->mmap_offset,
PROT_READ | PROT_WRITE, MAP_SHARED,
vmsg->fds[i], 0);
if (mmap_addr == MAP_FAILED) {
vubr_die("mmap");
}
dev_region->mmap_addr = (uint64_t) mmap_addr;
DPRINT(" mmap_addr: 0x%016"PRIx64"\n", dev_region->mmap_addr);
}
return 0;
}
| true | qemu | 6d0b908a628a7086fa855c68b217cc1e2a5c4c19 | vubr_set_mem_table_exec(VubrDev *dev, VhostUserMsg *vmsg)
{
int i;
VhostUserMemory *memory = &vmsg->payload.memory;
dev->nregions = memory->nregions;
DPRINT("Nregions: %d\n", memory->nregions);
for (i = 0; i < dev->nregions; i++) {
void *mmap_addr;
VhostUserMemoryRegion *msg_region = &memory->regions[i];
VubrDevRegion *dev_region = &dev->regions[i];
DPRINT("Region %d\n", i);
DPRINT(" guest_phys_addr: 0x%016"PRIx64"\n",
msg_region->guest_phys_addr);
DPRINT(" memory_size: 0x%016"PRIx64"\n",
msg_region->memory_size);
DPRINT(" userspace_addr 0x%016"PRIx64"\n",
msg_region->userspace_addr);
DPRINT(" mmap_offset 0x%016"PRIx64"\n",
msg_region->mmap_offset);
dev_region->gpa = msg_region->guest_phys_addr;
dev_region->size = msg_region->memory_size;
dev_region->qva = msg_region->userspace_addr;
dev_region->mmap_offset = msg_region->mmap_offset;
mmap_addr = mmap(0, dev_region->size + dev_region->mmap_offset,
PROT_READ | PROT_WRITE, MAP_SHARED,
vmsg->fds[i], 0);
if (mmap_addr == MAP_FAILED) {
vubr_die("mmap");
}
dev_region->mmap_addr = (uint64_t) mmap_addr;
DPRINT(" mmap_addr: 0x%016"PRIx64"\n", dev_region->mmap_addr);
}
return 0;
}
| {
"code": [],
"line_no": []
} | FUNC_0(VubrDev *VAR_0, VhostUserMsg *VAR_1)
{
int VAR_2;
VhostUserMemory *memory = &VAR_1->payload.memory;
VAR_0->nregions = memory->nregions;
DPRINT("Nregions: %d\n", memory->nregions);
for (VAR_2 = 0; VAR_2 < VAR_0->nregions; VAR_2++) {
void *mmap_addr;
VhostUserMemoryRegion *msg_region = &memory->regions[VAR_2];
VubrDevRegion *dev_region = &VAR_0->regions[VAR_2];
DPRINT("Region %d\n", VAR_2);
DPRINT(" guest_phys_addr: 0x%016"PRIx64"\n",
msg_region->guest_phys_addr);
DPRINT(" memory_size: 0x%016"PRIx64"\n",
msg_region->memory_size);
DPRINT(" userspace_addr 0x%016"PRIx64"\n",
msg_region->userspace_addr);
DPRINT(" mmap_offset 0x%016"PRIx64"\n",
msg_region->mmap_offset);
dev_region->gpa = msg_region->guest_phys_addr;
dev_region->size = msg_region->memory_size;
dev_region->qva = msg_region->userspace_addr;
dev_region->mmap_offset = msg_region->mmap_offset;
mmap_addr = mmap(0, dev_region->size + dev_region->mmap_offset,
PROT_READ | PROT_WRITE, MAP_SHARED,
VAR_1->fds[VAR_2], 0);
if (mmap_addr == MAP_FAILED) {
vubr_die("mmap");
}
dev_region->mmap_addr = (uint64_t) mmap_addr;
DPRINT(" mmap_addr: 0x%016"PRIx64"\n", dev_region->mmap_addr);
}
return 0;
}
| [
"FUNC_0(VubrDev *VAR_0, VhostUserMsg *VAR_1)\n{",
"int VAR_2;",
"VhostUserMemory *memory = &VAR_1->payload.memory;",
"VAR_0->nregions = memory->nregions;",
"DPRINT(\"Nregions: %d\\n\", memory->nregions);",
"for (VAR_2 = 0; VAR_2 < VAR_0->nregions; VAR_2++) {",
"void *mmap_addr;",
"VhostUserMemoryRegion *msg_region = &memory->regions[VAR_2];",
"VubrDevRegion *dev_region = &VAR_0->regions[VAR_2];",
"DPRINT(\"Region %d\\n\", VAR_2);",
"DPRINT(\" guest_phys_addr: 0x%016\"PRIx64\"\\n\",\nmsg_region->guest_phys_addr);",
"DPRINT(\" memory_size: 0x%016\"PRIx64\"\\n\",\nmsg_region->memory_size);",
"DPRINT(\" userspace_addr 0x%016\"PRIx64\"\\n\",\nmsg_region->userspace_addr);",
"DPRINT(\" mmap_offset 0x%016\"PRIx64\"\\n\",\nmsg_region->mmap_offset);",
"dev_region->gpa = msg_region->guest_phys_addr;",
"dev_region->size = msg_region->memory_size;",
"dev_region->qva = msg_region->userspace_addr;",
"dev_region->mmap_offset = msg_region->mmap_offset;",
"mmap_addr = mmap(0, dev_region->size + dev_region->mmap_offset,\nPROT_READ | PROT_WRITE, MAP_SHARED,\nVAR_1->fds[VAR_2], 0);",
"if (mmap_addr == MAP_FAILED) {",
"vubr_die(\"mmap\");",
"}",
"dev_region->mmap_addr = (uint64_t) mmap_addr;",
"DPRINT(\" mmap_addr: 0x%016\"PRIx64\"\\n\", dev_region->mmap_addr);",
"}",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27,
29
],
[
31,
33
],
[
35,
37
],
[
39,
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
61,
63,
65
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
]
] |
3,603 | static av_cold int dilate_init(AVFilterContext *ctx, const char *args)
{
OCVContext *s = ctx->priv;
DilateContext *dilate = s->priv;
char default_kernel_str[] = "3x3+0x0/rect";
char *kernel_str;
const char *buf = args;
int ret;
dilate->nb_iterations = 1;
if (args)
kernel_str = av_get_token(&buf, "|");
if ((ret = parse_iplconvkernel(&dilate->kernel,
*kernel_str ? kernel_str : default_kernel_str,
ctx)) < 0)
return ret;
av_free(kernel_str);
sscanf(buf, "|%d", &dilate->nb_iterations);
av_log(ctx, AV_LOG_VERBOSE, "iterations_nb:%d\n", dilate->nb_iterations);
if (dilate->nb_iterations <= 0) {
av_log(ctx, AV_LOG_ERROR, "Invalid non-positive value '%d' for nb_iterations\n",
dilate->nb_iterations);
return AVERROR(EINVAL);
}
return 0;
}
| false | FFmpeg | a6653787a4b1e89170ff7962312dd110769c83a3 | static av_cold int dilate_init(AVFilterContext *ctx, const char *args)
{
OCVContext *s = ctx->priv;
DilateContext *dilate = s->priv;
char default_kernel_str[] = "3x3+0x0/rect";
char *kernel_str;
const char *buf = args;
int ret;
dilate->nb_iterations = 1;
if (args)
kernel_str = av_get_token(&buf, "|");
if ((ret = parse_iplconvkernel(&dilate->kernel,
*kernel_str ? kernel_str : default_kernel_str,
ctx)) < 0)
return ret;
av_free(kernel_str);
sscanf(buf, "|%d", &dilate->nb_iterations);
av_log(ctx, AV_LOG_VERBOSE, "iterations_nb:%d\n", dilate->nb_iterations);
if (dilate->nb_iterations <= 0) {
av_log(ctx, AV_LOG_ERROR, "Invalid non-positive value '%d' for nb_iterations\n",
dilate->nb_iterations);
return AVERROR(EINVAL);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVFilterContext *ctx, const char *args)
{
OCVContext *s = ctx->priv;
DilateContext *dilate = s->priv;
char VAR_0[] = "3x3+0x0/rect";
char *VAR_1;
const char *VAR_2 = args;
int VAR_3;
dilate->nb_iterations = 1;
if (args)
VAR_1 = av_get_token(&VAR_2, "|");
if ((VAR_3 = parse_iplconvkernel(&dilate->kernel,
*VAR_1 ? VAR_1 : VAR_0,
ctx)) < 0)
return VAR_3;
av_free(VAR_1);
sscanf(VAR_2, "|%d", &dilate->nb_iterations);
av_log(ctx, AV_LOG_VERBOSE, "iterations_nb:%d\n", dilate->nb_iterations);
if (dilate->nb_iterations <= 0) {
av_log(ctx, AV_LOG_ERROR, "Invalid non-positive value '%d' for nb_iterations\n",
dilate->nb_iterations);
return AVERROR(EINVAL);
}
return 0;
}
| [
"static av_cold int FUNC_0(AVFilterContext *ctx, const char *args)\n{",
"OCVContext *s = ctx->priv;",
"DilateContext *dilate = s->priv;",
"char VAR_0[] = \"3x3+0x0/rect\";",
"char *VAR_1;",
"const char *VAR_2 = args;",
"int VAR_3;",
"dilate->nb_iterations = 1;",
"if (args)\nVAR_1 = av_get_token(&VAR_2, \"|\");",
"if ((VAR_3 = parse_iplconvkernel(&dilate->kernel,\n*VAR_1 ? VAR_1 : VAR_0,\nctx)) < 0)\nreturn VAR_3;",
"av_free(VAR_1);",
"sscanf(VAR_2, \"|%d\", &dilate->nb_iterations);",
"av_log(ctx, AV_LOG_VERBOSE, \"iterations_nb:%d\\n\", dilate->nb_iterations);",
"if (dilate->nb_iterations <= 0) {",
"av_log(ctx, AV_LOG_ERROR, \"Invalid non-positive value '%d' for nb_iterations\\n\",\ndilate->nb_iterations);",
"return AVERROR(EINVAL);",
"}",
"return 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,
29,
31,
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
]
] |
3,604 | static int transcode(OutputFile *output_files,
int nb_output_files,
InputFile *input_files,
int nb_input_files)
{
int ret = 0, i;
AVFormatContext *is, *os;
AVCodecContext *codec, *icodec;
OutputStream *ost;
InputStream *ist;
char error[1024];
int key;
int want_sdp = 1;
uint8_t *no_packet;
int no_packet_count=0;
int64_t timer_start;
if (!(no_packet = av_mallocz(nb_input_files)))
exit_program(1);
if (rate_emu)
for (i = 0; i < nb_input_streams; i++)
input_streams[i].start = av_gettime();
/* output stream init */
for(i=0;i<nb_output_files;i++) {
os = output_files[i].ctx;
if (!os->nb_streams && !(os->oformat->flags & AVFMT_NOSTREAMS)) {
av_dump_format(os, i, os->filename, 1);
fprintf(stderr, "Output file #%d does not contain any stream\n", i);
ret = AVERROR(EINVAL);
goto fail;
}
}
/* for each output stream, we compute the right encoding parameters */
for (i = 0; i < nb_output_streams; i++) {
ost = &output_streams[i];
os = output_files[ost->file_index].ctx;
ist = &input_streams[ost->source_index];
codec = ost->st->codec;
icodec = ist->st->codec;
ost->st->disposition = ist->st->disposition;
codec->bits_per_raw_sample= icodec->bits_per_raw_sample;
codec->chroma_sample_location = icodec->chroma_sample_location;
if (ost->st->stream_copy) {
uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE;
if (extra_size > INT_MAX) {
ret = AVERROR(EINVAL);
goto fail;
}
/* if stream_copy is selected, no need to decode or encode */
codec->codec_id = icodec->codec_id;
codec->codec_type = icodec->codec_type;
if(!codec->codec_tag){
if( !os->oformat->codec_tag
|| av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id
|| av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0)
codec->codec_tag = icodec->codec_tag;
}
codec->bit_rate = icodec->bit_rate;
codec->rc_max_rate = icodec->rc_max_rate;
codec->rc_buffer_size = icodec->rc_buffer_size;
codec->extradata= av_mallocz(extra_size);
if (!codec->extradata) {
ret = AVERROR(ENOMEM);
goto fail;
}
memcpy(codec->extradata, icodec->extradata, icodec->extradata_size);
codec->extradata_size= icodec->extradata_size;
codec->time_base = ist->st->time_base;
if(!strcmp(os->oformat->name, "avi")) {
if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > 2*av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){
codec->time_base = icodec->time_base;
codec->time_base.num *= icodec->ticks_per_frame;
codec->time_base.den *= 2;
}
} else if(!(os->oformat->flags & AVFMT_VARIABLE_FPS)) {
if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){
codec->time_base = icodec->time_base;
codec->time_base.num *= icodec->ticks_per_frame;
}
}
av_reduce(&codec->time_base.num, &codec->time_base.den,
codec->time_base.num, codec->time_base.den, INT_MAX);
switch(codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if(audio_volume != 256) {
fprintf(stderr,"-acodec copy and -vol are incompatible (frames are not decoded)\n");
exit_program(1);
}
codec->channel_layout = icodec->channel_layout;
codec->sample_rate = icodec->sample_rate;
codec->channels = icodec->channels;
codec->frame_size = icodec->frame_size;
codec->audio_service_type = icodec->audio_service_type;
codec->block_align= icodec->block_align;
if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3)
codec->block_align= 0;
if(codec->codec_id == CODEC_ID_AC3)
codec->block_align= 0;
break;
case AVMEDIA_TYPE_VIDEO:
codec->pix_fmt = icodec->pix_fmt;
codec->width = icodec->width;
codec->height = icodec->height;
codec->has_b_frames = icodec->has_b_frames;
if (!codec->sample_aspect_ratio.num) {
codec->sample_aspect_ratio =
ost->st->sample_aspect_ratio =
ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio :
ist->st->codec->sample_aspect_ratio.num ?
ist->st->codec->sample_aspect_ratio : (AVRational){0, 1};
}
break;
case AVMEDIA_TYPE_SUBTITLE:
codec->width = icodec->width;
codec->height = icodec->height;
break;
case AVMEDIA_TYPE_DATA:
break;
default:
abort();
}
} else {
if (!ost->enc)
ost->enc = avcodec_find_encoder(ost->st->codec->codec_id);
switch(codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
ost->fifo= av_fifo_alloc(1024);
if (!ost->fifo) {
ret = AVERROR(ENOMEM);
goto fail;
}
ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE);
if (!codec->sample_rate) {
codec->sample_rate = icodec->sample_rate;
}
choose_sample_rate(ost->st, ost->enc);
codec->time_base = (AVRational){1, codec->sample_rate};
if (codec->sample_fmt == AV_SAMPLE_FMT_NONE)
codec->sample_fmt = icodec->sample_fmt;
choose_sample_fmt(ost->st, ost->enc);
if (!codec->channels) {
codec->channels = icodec->channels;
codec->channel_layout = icodec->channel_layout;
}
if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels)
codec->channel_layout = 0;
ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1;
icodec->request_channels = codec->channels;
ist->decoding_needed = 1;
ost->encoding_needed = 1;
ost->resample_sample_fmt = icodec->sample_fmt;
ost->resample_sample_rate = icodec->sample_rate;
ost->resample_channels = icodec->channels;
break;
case AVMEDIA_TYPE_VIDEO:
if (codec->pix_fmt == PIX_FMT_NONE)
codec->pix_fmt = icodec->pix_fmt;
choose_pixel_fmt(ost->st, ost->enc);
if (ost->st->codec->pix_fmt == PIX_FMT_NONE) {
fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\n");
exit_program(1);
}
if (!codec->width || !codec->height) {
codec->width = icodec->width;
codec->height = icodec->height;
}
ost->video_resample = codec->width != icodec->width ||
codec->height != icodec->height ||
codec->pix_fmt != icodec->pix_fmt;
if (ost->video_resample) {
codec->bits_per_raw_sample= frame_bits_per_raw_sample;
}
ost->resample_height = icodec->height;
ost->resample_width = icodec->width;
ost->resample_pix_fmt= icodec->pix_fmt;
ost->encoding_needed = 1;
ist->decoding_needed = 1;
if (!ost->frame_rate.num)
ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25,1};
if (ost->enc && ost->enc->supported_framerates && !force_fps) {
int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates);
ost->frame_rate = ost->enc->supported_framerates[idx];
}
codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num};
if( av_q2d(codec->time_base) < 0.001 && video_sync_method
&& (video_sync_method==1 || (video_sync_method<0 && !(os->oformat->flags & AVFMT_VARIABLE_FPS)))){
av_log(os, AV_LOG_WARNING, "Frame rate very high for a muxer not effciciently supporting it.\n"
"Please consider specifiying a lower framerate, a different muxer or -vsync 2\n");
}
#if CONFIG_AVFILTER
if (configure_video_filters(ist, ost)) {
fprintf(stderr, "Error opening filters!\n");
exit(1);
}
#endif
break;
case AVMEDIA_TYPE_SUBTITLE:
ost->encoding_needed = 1;
ist->decoding_needed = 1;
break;
default:
abort();
break;
}
/* two pass mode */
if (ost->encoding_needed && codec->codec_id != CODEC_ID_H264 &&
(codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {
char logfilename[1024];
FILE *f;
snprintf(logfilename, sizeof(logfilename), "%s-%d.log",
pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX,
i);
if (codec->flags & CODEC_FLAG_PASS1) {
f = fopen(logfilename, "wb");
if (!f) {
fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\n", logfilename, strerror(errno));
exit_program(1);
}
ost->logfile = f;
} else {
char *logbuffer;
size_t logbuffer_size;
if (read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {
fprintf(stderr, "Error reading log file '%s' for pass-2 encoding\n", logfilename);
exit_program(1);
}
codec->stats_in = logbuffer;
}
}
}
if(codec->codec_type == AVMEDIA_TYPE_VIDEO){
/* maximum video buffer size is 6-bytes per pixel, plus DPX header size */
int size= codec->width * codec->height;
bit_buffer_size= FFMAX(bit_buffer_size, 6*size + 1664);
}
}
if (!bit_buffer)
bit_buffer = av_malloc(bit_buffer_size);
if (!bit_buffer) {
fprintf(stderr, "Cannot allocate %d bytes output buffer\n",
bit_buffer_size);
ret = AVERROR(ENOMEM);
goto fail;
}
/* open each encoder */
for (i = 0; i < nb_output_streams; i++) {
ost = &output_streams[i];
if (ost->encoding_needed) {
AVCodec *codec = ost->enc;
AVCodecContext *dec = input_streams[ost->source_index].st->codec;
if (!codec) {
snprintf(error, sizeof(error), "Encoder (codec %s) not found for output stream #%d.%d",
avcodec_get_name(ost->st->codec->codec_id), ost->file_index, ost->index);
ret = AVERROR(EINVAL);
goto dump_format;
}
if (dec->subtitle_header) {
ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size);
if (!ost->st->codec->subtitle_header) {
ret = AVERROR(ENOMEM);
goto dump_format;
}
memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);
ost->st->codec->subtitle_header_size = dec->subtitle_header_size;
}
if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) {
snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height",
ost->file_index, ost->index);
ret = AVERROR(EINVAL);
goto dump_format;
}
assert_codec_experimental(ost->st->codec, 1);
assert_avoptions(ost->opts);
if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000)
av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low."
"It takes bits/s as argument, not kbits/s\n");
extra_size += ost->st->codec->extradata_size;
}
}
/* init input streams */
for (i = 0; i < nb_input_streams; i++)
if ((ret = init_input_stream(i, output_streams, nb_output_streams, error, sizeof(error)) < 0))
goto dump_format;
/* open files and write file headers */
for (i = 0; i < nb_output_files; i++) {
os = output_files[i].ctx;
if (avformat_write_header(os, &output_files[i].opts) < 0) {
snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i);
ret = AVERROR(EINVAL);
goto dump_format;
}
// assert_avoptions(output_files[i].opts);
if (strcmp(os->oformat->name, "rtp")) {
want_sdp = 0;
}
}
dump_format:
/* dump the file output parameters - cannot be done before in case
of stream copy */
for(i=0;i<nb_output_files;i++) {
av_dump_format(output_files[i].ctx, i, output_files[i].ctx->filename, 1);
}
/* dump the stream mapping */
if (verbose >= 0) {
fprintf(stderr, "Stream mapping:\n");
for (i = 0; i < nb_output_streams;i ++) {
ost = &output_streams[i];
fprintf(stderr, " Stream #%d.%d -> #%d.%d",
input_streams[ost->source_index].file_index,
input_streams[ost->source_index].st->index,
ost->file_index,
ost->index);
if (ost->sync_ist != &input_streams[ost->source_index])
fprintf(stderr, " [sync #%d.%d]",
ost->sync_ist->file_index,
ost->sync_ist->st->index);
if(ost->encoding_needed)
fprintf(stderr, ": %s -> %s",
input_streams[ost->source_index].dec ?
input_streams[ost->source_index].dec->name : "?",
ost->enc ? ost->enc->name : "?");
else
fprintf(stderr, ": copy");
fprintf(stderr, "\n");
}
}
if (ret) {
fprintf(stderr, "%s\n", error);
goto fail;
}
if (want_sdp) {
print_sdp(output_files, nb_output_files);
}
if (!using_stdin) {
if(verbose >= 0)
fprintf(stderr, "Press [q] to stop, [?] for help\n");
avio_set_interrupt_cb(decode_interrupt_cb);
}
term_init();
timer_start = av_gettime();
for(; received_sigterm == 0;) {
int file_index, ist_index;
AVPacket pkt;
int64_t ipts_min;
double opts_min;
redo:
ipts_min= INT64_MAX;
opts_min= 1e100;
/* if 'q' pressed, exits */
if (!using_stdin) {
if (q_pressed)
break;
/* read_key() returns 0 on EOF */
key = read_key();
if (key == 'q')
break;
if (key == '+') verbose++;
if (key == '-') verbose--;
if (key == 's') qp_hist ^= 1;
if (key == 'h'){
if (do_hex_dump){
do_hex_dump = do_pkt_dump = 0;
} else if(do_pkt_dump){
do_hex_dump = 1;
} else
do_pkt_dump = 1;
av_log_set_level(AV_LOG_DEBUG);
}
if (key == 'c' || key == 'C'){
char ret[4096], target[64], cmd[256], arg[256]={0};
double ts;
fprintf(stderr, "\nEnter command: <target> <time> <command>[ <argument>]\n");
if(scanf("%4095[^\n\r]%*c", ret) == 1 && sscanf(ret, "%63[^ ] %lf %255[^ ] %255[^\n]", target, &ts, cmd, arg) >= 3){
for(i=0;i<nb_output_streams;i++) {
int r;
ost = &output_streams[i];
if(ost->graph){
if(ts<0){
r= avfilter_graph_send_command(ost->graph, target, cmd, arg, ret, sizeof(ret), key == 'c' ? AVFILTER_CMD_FLAG_ONE : 0);
fprintf(stderr, "Command reply for %d: %d, %s\n", i, r, ret);
}else{
r= avfilter_graph_queue_command(ost->graph, target, cmd, arg, 0, ts);
}
}
}
}else{
fprintf(stderr, "Parse error\n");
}
}
if (key == 'd' || key == 'D'){
int debug=0;
if(key == 'D') {
debug = input_streams[0].st->codec->debug<<1;
if(!debug) debug = 1;
while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) //unsupported, would just crash
debug += debug;
}else
scanf("%d", &debug);
for(i=0;i<nb_input_streams;i++) {
input_streams[i].st->codec->debug = debug;
}
for(i=0;i<nb_output_streams;i++) {
ost = &output_streams[i];
ost->st->codec->debug = debug;
}
if(debug) av_log_set_level(AV_LOG_DEBUG);
fprintf(stderr,"debug=%d\n", debug);
}
if (key == '?'){
fprintf(stderr, "key function\n"
"? show this help\n"
"+ increase verbosity\n"
"- decrease verbosity\n"
"c Send command to filtergraph\n"
"D cycle through available debug modes\n"
"h dump packets/hex press to cycle through the 3 states\n"
"q quit\n"
"s Show QP histogram\n"
);
}
}
/* select the stream that we must read now by looking at the
smallest output pts */
file_index = -1;
for (i = 0; i < nb_output_streams; i++) {
OutputFile *of;
int64_t ipts;
double opts;
ost = &output_streams[i];
of = &output_files[ost->file_index];
os = output_files[ost->file_index].ctx;
ist = &input_streams[ost->source_index];
if (ost->is_past_recording_time || no_packet[ist->file_index] ||
(os->pb && avio_tell(os->pb) >= of->limit_filesize))
continue;
opts = ost->st->pts.val * av_q2d(ost->st->time_base);
ipts = ist->pts;
if (!input_files[ist->file_index].eof_reached){
if(ipts < ipts_min) {
ipts_min = ipts;
if(input_sync ) file_index = ist->file_index;
}
if(opts < opts_min) {
opts_min = opts;
if(!input_sync) file_index = ist->file_index;
}
}
if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){
file_index= -1;
break;
}
}
/* if none, if is finished */
if (file_index < 0) {
if(no_packet_count){
no_packet_count=0;
memset(no_packet, 0, nb_input_files);
usleep(10000);
continue;
}
break;
}
/* read a frame from it and output it in the fifo */
is = input_files[file_index].ctx;
ret= av_read_frame(is, &pkt);
if(ret == AVERROR(EAGAIN)){
no_packet[file_index]=1;
no_packet_count++;
continue;
}
if (ret < 0) {
input_files[file_index].eof_reached = 1;
if (opt_shortest)
break;
else
continue;
}
no_packet_count=0;
memset(no_packet, 0, nb_input_files);
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 >= input_files[file_index].nb_streams)
goto discard_packet;
ist_index = input_files[file_index].ist_index + pkt.stream_index;
ist = &input_streams[ist_index];
if (ist->discard)
goto discard_packet;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (ist->ts_scale) {
if(pkt.pts != AV_NOPTS_VALUE)
pkt.pts *= ist->ts_scale;
if(pkt.dts != AV_NOPTS_VALUE)
pkt.dts *= ist->ts_scale;
}
// fprintf(stderr, "next:%"PRId64" dts:%"PRId64" off:%"PRId64" %d\n", ist->next_pts, pkt.dts, input_files[ist->file_index].ts_offset, ist->st->codec->codec_type);
if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE
&& (is->iformat->flags & AVFMT_TS_DISCONT)) {
int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);
int64_t delta= pkt_dts - ist->next_pts;
if((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)&& !copy_ts){
input_files[ist->file_index].ts_offset -= delta;
if (verbose > 2)
fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n",
delta, input_files[ist->file_index].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);
}
}
//fprintf(stderr,"read #%d.%d size=%d\n", ist->file_index, ist->st->index, pkt.size);
if (output_packet(ist, ist_index, output_streams, nb_output_streams, &pkt) < 0) {
if (verbose >= 0)
fprintf(stderr, "Error while decoding stream #%d.%d\n",
ist->file_index, ist->st->index);
if (exit_on_error)
exit_program(1);
av_free_packet(&pkt);
goto redo;
}
discard_packet:
av_free_packet(&pkt);
/* dump report by using the output first video and audio streams */
print_report(output_files, output_streams, nb_output_streams, 0, timer_start);
}
/* at the end of stream, we must flush the decoder buffers */
for (i = 0; i < nb_input_streams; i++) {
ist = &input_streams[i];
if (ist->decoding_needed) {
output_packet(ist, i, output_streams, nb_output_streams, NULL);
}
}
flush_encoders(output_streams, nb_output_streams);
term_exit();
/* write the trailer if needed and close file */
for(i=0;i<nb_output_files;i++) {
os = output_files[i].ctx;
av_write_trailer(os);
}
/* dump report by using the first video and audio streams */
print_report(output_files, output_streams, nb_output_streams, 1, timer_start);
/* close each encoder */
for (i = 0; i < nb_output_streams; i++) {
ost = &output_streams[i];
if (ost->encoding_needed) {
av_freep(&ost->st->codec->stats_in);
avcodec_close(ost->st->codec);
}
#if CONFIG_AVFILTER
avfilter_graph_free(&ost->graph);
#endif
}
/* close each decoder */
for (i = 0; i < nb_input_streams; i++) {
ist = &input_streams[i];
if (ist->decoding_needed) {
avcodec_close(ist->st->codec);
}
}
/* finished ! */
ret = 0;
fail:
av_freep(&bit_buffer);
av_freep(&no_packet);
if (output_streams) {
for (i = 0; i < nb_output_streams; i++) {
ost = &output_streams[i];
if (ost) {
if (ost->st->stream_copy)
av_freep(&ost->st->codec->extradata);
if (ost->logfile) {
fclose(ost->logfile);
ost->logfile = NULL;
}
av_fifo_free(ost->fifo); /* works even if fifo is not
initialized but set to zero */
av_freep(&ost->st->codec->subtitle_header);
av_free(ost->resample_frame.data[0]);
av_free(ost->forced_kf_pts);
if (ost->video_resample)
sws_freeContext(ost->img_resample_ctx);
if (ost->resample)
audio_resample_close(ost->resample);
if (ost->reformat_ctx)
av_audio_convert_free(ost->reformat_ctx);
av_dict_free(&ost->opts);
}
}
}
return ret;
}
| false | FFmpeg | 93ed69ad2103e0c58ebcaa80dd55742d75f8c461 | static int transcode(OutputFile *output_files,
int nb_output_files,
InputFile *input_files,
int nb_input_files)
{
int ret = 0, i;
AVFormatContext *is, *os;
AVCodecContext *codec, *icodec;
OutputStream *ost;
InputStream *ist;
char error[1024];
int key;
int want_sdp = 1;
uint8_t *no_packet;
int no_packet_count=0;
int64_t timer_start;
if (!(no_packet = av_mallocz(nb_input_files)))
exit_program(1);
if (rate_emu)
for (i = 0; i < nb_input_streams; i++)
input_streams[i].start = av_gettime();
for(i=0;i<nb_output_files;i++) {
os = output_files[i].ctx;
if (!os->nb_streams && !(os->oformat->flags & AVFMT_NOSTREAMS)) {
av_dump_format(os, i, os->filename, 1);
fprintf(stderr, "Output file #%d does not contain any stream\n", i);
ret = AVERROR(EINVAL);
goto fail;
}
}
for (i = 0; i < nb_output_streams; i++) {
ost = &output_streams[i];
os = output_files[ost->file_index].ctx;
ist = &input_streams[ost->source_index];
codec = ost->st->codec;
icodec = ist->st->codec;
ost->st->disposition = ist->st->disposition;
codec->bits_per_raw_sample= icodec->bits_per_raw_sample;
codec->chroma_sample_location = icodec->chroma_sample_location;
if (ost->st->stream_copy) {
uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE;
if (extra_size > INT_MAX) {
ret = AVERROR(EINVAL);
goto fail;
}
codec->codec_id = icodec->codec_id;
codec->codec_type = icodec->codec_type;
if(!codec->codec_tag){
if( !os->oformat->codec_tag
|| av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id
|| av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0)
codec->codec_tag = icodec->codec_tag;
}
codec->bit_rate = icodec->bit_rate;
codec->rc_max_rate = icodec->rc_max_rate;
codec->rc_buffer_size = icodec->rc_buffer_size;
codec->extradata= av_mallocz(extra_size);
if (!codec->extradata) {
ret = AVERROR(ENOMEM);
goto fail;
}
memcpy(codec->extradata, icodec->extradata, icodec->extradata_size);
codec->extradata_size= icodec->extradata_size;
codec->time_base = ist->st->time_base;
if(!strcmp(os->oformat->name, "avi")) {
if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > 2*av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){
codec->time_base = icodec->time_base;
codec->time_base.num *= icodec->ticks_per_frame;
codec->time_base.den *= 2;
}
} else if(!(os->oformat->flags & AVFMT_VARIABLE_FPS)) {
if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){
codec->time_base = icodec->time_base;
codec->time_base.num *= icodec->ticks_per_frame;
}
}
av_reduce(&codec->time_base.num, &codec->time_base.den,
codec->time_base.num, codec->time_base.den, INT_MAX);
switch(codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if(audio_volume != 256) {
fprintf(stderr,"-acodec copy and -vol are incompatible (frames are not decoded)\n");
exit_program(1);
}
codec->channel_layout = icodec->channel_layout;
codec->sample_rate = icodec->sample_rate;
codec->channels = icodec->channels;
codec->frame_size = icodec->frame_size;
codec->audio_service_type = icodec->audio_service_type;
codec->block_align= icodec->block_align;
if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3)
codec->block_align= 0;
if(codec->codec_id == CODEC_ID_AC3)
codec->block_align= 0;
break;
case AVMEDIA_TYPE_VIDEO:
codec->pix_fmt = icodec->pix_fmt;
codec->width = icodec->width;
codec->height = icodec->height;
codec->has_b_frames = icodec->has_b_frames;
if (!codec->sample_aspect_ratio.num) {
codec->sample_aspect_ratio =
ost->st->sample_aspect_ratio =
ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio :
ist->st->codec->sample_aspect_ratio.num ?
ist->st->codec->sample_aspect_ratio : (AVRational){0, 1};
}
break;
case AVMEDIA_TYPE_SUBTITLE:
codec->width = icodec->width;
codec->height = icodec->height;
break;
case AVMEDIA_TYPE_DATA:
break;
default:
abort();
}
} else {
if (!ost->enc)
ost->enc = avcodec_find_encoder(ost->st->codec->codec_id);
switch(codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
ost->fifo= av_fifo_alloc(1024);
if (!ost->fifo) {
ret = AVERROR(ENOMEM);
goto fail;
}
ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE);
if (!codec->sample_rate) {
codec->sample_rate = icodec->sample_rate;
}
choose_sample_rate(ost->st, ost->enc);
codec->time_base = (AVRational){1, codec->sample_rate};
if (codec->sample_fmt == AV_SAMPLE_FMT_NONE)
codec->sample_fmt = icodec->sample_fmt;
choose_sample_fmt(ost->st, ost->enc);
if (!codec->channels) {
codec->channels = icodec->channels;
codec->channel_layout = icodec->channel_layout;
}
if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels)
codec->channel_layout = 0;
ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1;
icodec->request_channels = codec->channels;
ist->decoding_needed = 1;
ost->encoding_needed = 1;
ost->resample_sample_fmt = icodec->sample_fmt;
ost->resample_sample_rate = icodec->sample_rate;
ost->resample_channels = icodec->channels;
break;
case AVMEDIA_TYPE_VIDEO:
if (codec->pix_fmt == PIX_FMT_NONE)
codec->pix_fmt = icodec->pix_fmt;
choose_pixel_fmt(ost->st, ost->enc);
if (ost->st->codec->pix_fmt == PIX_FMT_NONE) {
fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\n");
exit_program(1);
}
if (!codec->width || !codec->height) {
codec->width = icodec->width;
codec->height = icodec->height;
}
ost->video_resample = codec->width != icodec->width ||
codec->height != icodec->height ||
codec->pix_fmt != icodec->pix_fmt;
if (ost->video_resample) {
codec->bits_per_raw_sample= frame_bits_per_raw_sample;
}
ost->resample_height = icodec->height;
ost->resample_width = icodec->width;
ost->resample_pix_fmt= icodec->pix_fmt;
ost->encoding_needed = 1;
ist->decoding_needed = 1;
if (!ost->frame_rate.num)
ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25,1};
if (ost->enc && ost->enc->supported_framerates && !force_fps) {
int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates);
ost->frame_rate = ost->enc->supported_framerates[idx];
}
codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num};
if( av_q2d(codec->time_base) < 0.001 && video_sync_method
&& (video_sync_method==1 || (video_sync_method<0 && !(os->oformat->flags & AVFMT_VARIABLE_FPS)))){
av_log(os, AV_LOG_WARNING, "Frame rate very high for a muxer not effciciently supporting it.\n"
"Please consider specifiying a lower framerate, a different muxer or -vsync 2\n");
}
#if CONFIG_AVFILTER
if (configure_video_filters(ist, ost)) {
fprintf(stderr, "Error opening filters!\n");
exit(1);
}
#endif
break;
case AVMEDIA_TYPE_SUBTITLE:
ost->encoding_needed = 1;
ist->decoding_needed = 1;
break;
default:
abort();
break;
}
if (ost->encoding_needed && codec->codec_id != CODEC_ID_H264 &&
(codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {
char logfilename[1024];
FILE *f;
snprintf(logfilename, sizeof(logfilename), "%s-%d.log",
pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX,
i);
if (codec->flags & CODEC_FLAG_PASS1) {
f = fopen(logfilename, "wb");
if (!f) {
fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\n", logfilename, strerror(errno));
exit_program(1);
}
ost->logfile = f;
} else {
char *logbuffer;
size_t logbuffer_size;
if (read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {
fprintf(stderr, "Error reading log file '%s' for pass-2 encoding\n", logfilename);
exit_program(1);
}
codec->stats_in = logbuffer;
}
}
}
if(codec->codec_type == AVMEDIA_TYPE_VIDEO){
int size= codec->width * codec->height;
bit_buffer_size= FFMAX(bit_buffer_size, 6*size + 1664);
}
}
if (!bit_buffer)
bit_buffer = av_malloc(bit_buffer_size);
if (!bit_buffer) {
fprintf(stderr, "Cannot allocate %d bytes output buffer\n",
bit_buffer_size);
ret = AVERROR(ENOMEM);
goto fail;
}
for (i = 0; i < nb_output_streams; i++) {
ost = &output_streams[i];
if (ost->encoding_needed) {
AVCodec *codec = ost->enc;
AVCodecContext *dec = input_streams[ost->source_index].st->codec;
if (!codec) {
snprintf(error, sizeof(error), "Encoder (codec %s) not found for output stream #%d.%d",
avcodec_get_name(ost->st->codec->codec_id), ost->file_index, ost->index);
ret = AVERROR(EINVAL);
goto dump_format;
}
if (dec->subtitle_header) {
ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size);
if (!ost->st->codec->subtitle_header) {
ret = AVERROR(ENOMEM);
goto dump_format;
}
memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);
ost->st->codec->subtitle_header_size = dec->subtitle_header_size;
}
if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) {
snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height",
ost->file_index, ost->index);
ret = AVERROR(EINVAL);
goto dump_format;
}
assert_codec_experimental(ost->st->codec, 1);
assert_avoptions(ost->opts);
if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000)
av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low."
"It takes bits/s as argument, not kbits/s\n");
extra_size += ost->st->codec->extradata_size;
}
}
for (i = 0; i < nb_input_streams; i++)
if ((ret = init_input_stream(i, output_streams, nb_output_streams, error, sizeof(error)) < 0))
goto dump_format;
for (i = 0; i < nb_output_files; i++) {
os = output_files[i].ctx;
if (avformat_write_header(os, &output_files[i].opts) < 0) {
snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i);
ret = AVERROR(EINVAL);
goto dump_format;
}
if (strcmp(os->oformat->name, "rtp")) {
want_sdp = 0;
}
}
dump_format:
for(i=0;i<nb_output_files;i++) {
av_dump_format(output_files[i].ctx, i, output_files[i].ctx->filename, 1);
}
if (verbose >= 0) {
fprintf(stderr, "Stream mapping:\n");
for (i = 0; i < nb_output_streams;i ++) {
ost = &output_streams[i];
fprintf(stderr, " Stream #%d.%d -> #%d.%d",
input_streams[ost->source_index].file_index,
input_streams[ost->source_index].st->index,
ost->file_index,
ost->index);
if (ost->sync_ist != &input_streams[ost->source_index])
fprintf(stderr, " [sync #%d.%d]",
ost->sync_ist->file_index,
ost->sync_ist->st->index);
if(ost->encoding_needed)
fprintf(stderr, ": %s -> %s",
input_streams[ost->source_index].dec ?
input_streams[ost->source_index].dec->name : "?",
ost->enc ? ost->enc->name : "?");
else
fprintf(stderr, ": copy");
fprintf(stderr, "\n");
}
}
if (ret) {
fprintf(stderr, "%s\n", error);
goto fail;
}
if (want_sdp) {
print_sdp(output_files, nb_output_files);
}
if (!using_stdin) {
if(verbose >= 0)
fprintf(stderr, "Press [q] to stop, [?] for help\n");
avio_set_interrupt_cb(decode_interrupt_cb);
}
term_init();
timer_start = av_gettime();
for(; received_sigterm == 0;) {
int file_index, ist_index;
AVPacket pkt;
int64_t ipts_min;
double opts_min;
redo:
ipts_min= INT64_MAX;
opts_min= 1e100;
if (!using_stdin) {
if (q_pressed)
break;
key = read_key();
if (key == 'q')
break;
if (key == '+') verbose++;
if (key == '-') verbose--;
if (key == 's') qp_hist ^= 1;
if (key == 'h'){
if (do_hex_dump){
do_hex_dump = do_pkt_dump = 0;
} else if(do_pkt_dump){
do_hex_dump = 1;
} else
do_pkt_dump = 1;
av_log_set_level(AV_LOG_DEBUG);
}
if (key == 'c' || key == 'C'){
char ret[4096], target[64], cmd[256], arg[256]={0};
double ts;
fprintf(stderr, "\nEnter command: <target> <time> <command>[ <argument>]\n");
if(scanf("%4095[^\n\r]%*c", ret) == 1 && sscanf(ret, "%63[^ ] %lf %255[^ ] %255[^\n]", target, &ts, cmd, arg) >= 3){
for(i=0;i<nb_output_streams;i++) {
int r;
ost = &output_streams[i];
if(ost->graph){
if(ts<0){
r= avfilter_graph_send_command(ost->graph, target, cmd, arg, ret, sizeof(ret), key == 'c' ? AVFILTER_CMD_FLAG_ONE : 0);
fprintf(stderr, "Command reply for %d: %d, %s\n", i, r, ret);
}else{
r= avfilter_graph_queue_command(ost->graph, target, cmd, arg, 0, ts);
}
}
}
}else{
fprintf(stderr, "Parse error\n");
}
}
if (key == 'd' || key == 'D'){
int debug=0;
if(key == 'D') {
debug = input_streams[0].st->codec->debug<<1;
if(!debug) debug = 1;
while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE))
debug += debug;
}else
scanf("%d", &debug);
for(i=0;i<nb_input_streams;i++) {
input_streams[i].st->codec->debug = debug;
}
for(i=0;i<nb_output_streams;i++) {
ost = &output_streams[i];
ost->st->codec->debug = debug;
}
if(debug) av_log_set_level(AV_LOG_DEBUG);
fprintf(stderr,"debug=%d\n", debug);
}
if (key == '?'){
fprintf(stderr, "key function\n"
"? show this help\n"
"+ increase verbosity\n"
"- decrease verbosity\n"
"c Send command to filtergraph\n"
"D cycle through available debug modes\n"
"h dump packets/hex press to cycle through the 3 states\n"
"q quit\n"
"s Show QP histogram\n"
);
}
}
file_index = -1;
for (i = 0; i < nb_output_streams; i++) {
OutputFile *of;
int64_t ipts;
double opts;
ost = &output_streams[i];
of = &output_files[ost->file_index];
os = output_files[ost->file_index].ctx;
ist = &input_streams[ost->source_index];
if (ost->is_past_recording_time || no_packet[ist->file_index] ||
(os->pb && avio_tell(os->pb) >= of->limit_filesize))
continue;
opts = ost->st->pts.val * av_q2d(ost->st->time_base);
ipts = ist->pts;
if (!input_files[ist->file_index].eof_reached){
if(ipts < ipts_min) {
ipts_min = ipts;
if(input_sync ) file_index = ist->file_index;
}
if(opts < opts_min) {
opts_min = opts;
if(!input_sync) file_index = ist->file_index;
}
}
if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){
file_index= -1;
break;
}
}
if (file_index < 0) {
if(no_packet_count){
no_packet_count=0;
memset(no_packet, 0, nb_input_files);
usleep(10000);
continue;
}
break;
}
is = input_files[file_index].ctx;
ret= av_read_frame(is, &pkt);
if(ret == AVERROR(EAGAIN)){
no_packet[file_index]=1;
no_packet_count++;
continue;
}
if (ret < 0) {
input_files[file_index].eof_reached = 1;
if (opt_shortest)
break;
else
continue;
}
no_packet_count=0;
memset(no_packet, 0, nb_input_files);
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 >= input_files[file_index].nb_streams)
goto discard_packet;
ist_index = input_files[file_index].ist_index + pkt.stream_index;
ist = &input_streams[ist_index];
if (ist->discard)
goto discard_packet;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (ist->ts_scale) {
if(pkt.pts != AV_NOPTS_VALUE)
pkt.pts *= ist->ts_scale;
if(pkt.dts != AV_NOPTS_VALUE)
pkt.dts *= ist->ts_scale;
}
if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE
&& (is->iformat->flags & AVFMT_TS_DISCONT)) {
int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);
int64_t delta= pkt_dts - ist->next_pts;
if((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)&& !copy_ts){
input_files[ist->file_index].ts_offset -= delta;
if (verbose > 2)
fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n",
delta, input_files[ist->file_index].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);
}
}
if (output_packet(ist, ist_index, output_streams, nb_output_streams, &pkt) < 0) {
if (verbose >= 0)
fprintf(stderr, "Error while decoding stream #%d.%d\n",
ist->file_index, ist->st->index);
if (exit_on_error)
exit_program(1);
av_free_packet(&pkt);
goto redo;
}
discard_packet:
av_free_packet(&pkt);
print_report(output_files, output_streams, nb_output_streams, 0, timer_start);
}
for (i = 0; i < nb_input_streams; i++) {
ist = &input_streams[i];
if (ist->decoding_needed) {
output_packet(ist, i, output_streams, nb_output_streams, NULL);
}
}
flush_encoders(output_streams, nb_output_streams);
term_exit();
for(i=0;i<nb_output_files;i++) {
os = output_files[i].ctx;
av_write_trailer(os);
}
print_report(output_files, output_streams, nb_output_streams, 1, timer_start);
for (i = 0; i < nb_output_streams; i++) {
ost = &output_streams[i];
if (ost->encoding_needed) {
av_freep(&ost->st->codec->stats_in);
avcodec_close(ost->st->codec);
}
#if CONFIG_AVFILTER
avfilter_graph_free(&ost->graph);
#endif
}
for (i = 0; i < nb_input_streams; i++) {
ist = &input_streams[i];
if (ist->decoding_needed) {
avcodec_close(ist->st->codec);
}
}
ret = 0;
fail:
av_freep(&bit_buffer);
av_freep(&no_packet);
if (output_streams) {
for (i = 0; i < nb_output_streams; i++) {
ost = &output_streams[i];
if (ost) {
if (ost->st->stream_copy)
av_freep(&ost->st->codec->extradata);
if (ost->logfile) {
fclose(ost->logfile);
ost->logfile = NULL;
}
av_fifo_free(ost->fifo);
av_freep(&ost->st->codec->subtitle_header);
av_free(ost->resample_frame.data[0]);
av_free(ost->forced_kf_pts);
if (ost->video_resample)
sws_freeContext(ost->img_resample_ctx);
if (ost->resample)
audio_resample_close(ost->resample);
if (ost->reformat_ctx)
av_audio_convert_free(ost->reformat_ctx);
av_dict_free(&ost->opts);
}
}
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(OutputFile *VAR_0,
int VAR_1,
InputFile *VAR_2,
int VAR_3)
{
int VAR_4 = 0, VAR_5;
AVFormatContext *is, *os;
AVCodecContext *codec, *icodec;
OutputStream *ost;
InputStream *ist;
char VAR_6[1024];
int VAR_7;
int VAR_8 = 1;
uint8_t *no_packet;
int VAR_9=0;
int64_t timer_start;
if (!(no_packet = av_mallocz(VAR_3)))
exit_program(1);
if (rate_emu)
for (VAR_5 = 0; VAR_5 < nb_input_streams; VAR_5++)
input_streams[VAR_5].start = av_gettime();
for(VAR_5=0;VAR_5<VAR_1;VAR_5++) {
os = VAR_0[VAR_5].ctx;
if (!os->nb_streams && !(os->oformat->flags & AVFMT_NOSTREAMS)) {
av_dump_format(os, VAR_5, os->filename, 1);
fprintf(stderr, "Output file #%d does not contain any stream\n", VAR_5);
VAR_4 = AVERROR(EINVAL);
goto fail;
}
}
for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++) {
ost = &output_streams[VAR_5];
os = VAR_0[ost->file_index].ctx;
ist = &input_streams[ost->source_index];
codec = ost->st->codec;
icodec = ist->st->codec;
ost->st->disposition = ist->st->disposition;
codec->bits_per_raw_sample= icodec->bits_per_raw_sample;
codec->chroma_sample_location = icodec->chroma_sample_location;
if (ost->st->stream_copy) {
uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE;
if (extra_size > INT_MAX) {
VAR_4 = AVERROR(EINVAL);
goto fail;
}
codec->codec_id = icodec->codec_id;
codec->codec_type = icodec->codec_type;
if(!codec->codec_tag){
if( !os->oformat->codec_tag
|| av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id
|| av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0)
codec->codec_tag = icodec->codec_tag;
}
codec->bit_rate = icodec->bit_rate;
codec->rc_max_rate = icodec->rc_max_rate;
codec->rc_buffer_size = icodec->rc_buffer_size;
codec->extradata= av_mallocz(extra_size);
if (!codec->extradata) {
VAR_4 = AVERROR(ENOMEM);
goto fail;
}
memcpy(codec->extradata, icodec->extradata, icodec->extradata_size);
codec->extradata_size= icodec->extradata_size;
codec->time_base = ist->st->time_base;
if(!strcmp(os->oformat->name, "avi")) {
if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > 2*av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){
codec->time_base = icodec->time_base;
codec->time_base.num *= icodec->ticks_per_frame;
codec->time_base.den *= 2;
}
} else if(!(os->oformat->flags & AVFMT_VARIABLE_FPS)) {
if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){
codec->time_base = icodec->time_base;
codec->time_base.num *= icodec->ticks_per_frame;
}
}
av_reduce(&codec->time_base.num, &codec->time_base.den,
codec->time_base.num, codec->time_base.den, INT_MAX);
switch(codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if(audio_volume != 256) {
fprintf(stderr,"-acodec copy and -vol are incompatible (frames are not decoded)\n");
exit_program(1);
}
codec->channel_layout = icodec->channel_layout;
codec->sample_rate = icodec->sample_rate;
codec->channels = icodec->channels;
codec->frame_size = icodec->frame_size;
codec->audio_service_type = icodec->audio_service_type;
codec->block_align= icodec->block_align;
if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3)
codec->block_align= 0;
if(codec->codec_id == CODEC_ID_AC3)
codec->block_align= 0;
break;
case AVMEDIA_TYPE_VIDEO:
codec->pix_fmt = icodec->pix_fmt;
codec->width = icodec->width;
codec->height = icodec->height;
codec->has_b_frames = icodec->has_b_frames;
if (!codec->sample_aspect_ratio.num) {
codec->sample_aspect_ratio =
ost->st->sample_aspect_ratio =
ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio :
ist->st->codec->sample_aspect_ratio.num ?
ist->st->codec->sample_aspect_ratio : (AVRational){0, 1};
}
break;
case AVMEDIA_TYPE_SUBTITLE:
codec->width = icodec->width;
codec->height = icodec->height;
break;
case AVMEDIA_TYPE_DATA:
break;
default:
abort();
}
} else {
if (!ost->enc)
ost->enc = avcodec_find_encoder(ost->st->codec->codec_id);
switch(codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
ost->fifo= av_fifo_alloc(1024);
if (!ost->fifo) {
VAR_4 = AVERROR(ENOMEM);
goto fail;
}
ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE);
if (!codec->sample_rate) {
codec->sample_rate = icodec->sample_rate;
}
choose_sample_rate(ost->st, ost->enc);
codec->time_base = (AVRational){1, codec->sample_rate};
if (codec->sample_fmt == AV_SAMPLE_FMT_NONE)
codec->sample_fmt = icodec->sample_fmt;
choose_sample_fmt(ost->st, ost->enc);
if (!codec->channels) {
codec->channels = icodec->channels;
codec->channel_layout = icodec->channel_layout;
}
if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels)
codec->channel_layout = 0;
ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1;
icodec->request_channels = codec->channels;
ist->decoding_needed = 1;
ost->encoding_needed = 1;
ost->resample_sample_fmt = icodec->sample_fmt;
ost->resample_sample_rate = icodec->sample_rate;
ost->resample_channels = icodec->channels;
break;
case AVMEDIA_TYPE_VIDEO:
if (codec->pix_fmt == PIX_FMT_NONE)
codec->pix_fmt = icodec->pix_fmt;
choose_pixel_fmt(ost->st, ost->enc);
if (ost->st->codec->pix_fmt == PIX_FMT_NONE) {
fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\n");
exit_program(1);
}
if (!codec->width || !codec->height) {
codec->width = icodec->width;
codec->height = icodec->height;
}
ost->video_resample = codec->width != icodec->width ||
codec->height != icodec->height ||
codec->pix_fmt != icodec->pix_fmt;
if (ost->video_resample) {
codec->bits_per_raw_sample= frame_bits_per_raw_sample;
}
ost->resample_height = icodec->height;
ost->resample_width = icodec->width;
ost->resample_pix_fmt= icodec->pix_fmt;
ost->encoding_needed = 1;
ist->decoding_needed = 1;
if (!ost->frame_rate.num)
ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25,1};
if (ost->enc && ost->enc->supported_framerates && !force_fps) {
int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates);
ost->frame_rate = ost->enc->supported_framerates[idx];
}
codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num};
if( av_q2d(codec->time_base) < 0.001 && video_sync_method
&& (video_sync_method==1 || (video_sync_method<0 && !(os->oformat->flags & AVFMT_VARIABLE_FPS)))){
av_log(os, AV_LOG_WARNING, "Frame rate very high for a muxer not effciciently supporting it.\n"
"Please consider specifiying a lower framerate, a different muxer or -vsync 2\n");
}
#if CONFIG_AVFILTER
if (configure_video_filters(ist, ost)) {
fprintf(stderr, "Error opening filters!\n");
exit(1);
}
#endif
break;
case AVMEDIA_TYPE_SUBTITLE:
ost->encoding_needed = 1;
ist->decoding_needed = 1;
break;
default:
abort();
break;
}
if (ost->encoding_needed && codec->codec_id != CODEC_ID_H264 &&
(codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {
char logfilename[1024];
FILE *f;
snprintf(logfilename, sizeof(logfilename), "%s-%d.log",
pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX,
VAR_5);
if (codec->flags & CODEC_FLAG_PASS1) {
f = fopen(logfilename, "wb");
if (!f) {
fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\n", logfilename, strerror(errno));
exit_program(1);
}
ost->logfile = f;
} else {
char *logbuffer;
size_t logbuffer_size;
if (read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {
fprintf(stderr, "Error reading log file '%s' for pass-2 encoding\n", logfilename);
exit_program(1);
}
codec->stats_in = logbuffer;
}
}
}
if(codec->codec_type == AVMEDIA_TYPE_VIDEO){
int size= codec->width * codec->height;
bit_buffer_size= FFMAX(bit_buffer_size, 6*size + 1664);
}
}
if (!bit_buffer)
bit_buffer = av_malloc(bit_buffer_size);
if (!bit_buffer) {
fprintf(stderr, "Cannot allocate %d bytes output buffer\n",
bit_buffer_size);
VAR_4 = AVERROR(ENOMEM);
goto fail;
}
for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++) {
ost = &output_streams[VAR_5];
if (ost->encoding_needed) {
AVCodec *codec = ost->enc;
AVCodecContext *dec = input_streams[ost->source_index].st->codec;
if (!codec) {
snprintf(VAR_6, sizeof(VAR_6), "Encoder (codec %s) not found for output stream #%d.%d",
avcodec_get_name(ost->st->codec->codec_id), ost->file_index, ost->index);
VAR_4 = AVERROR(EINVAL);
goto dump_format;
}
if (dec->subtitle_header) {
ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size);
if (!ost->st->codec->subtitle_header) {
VAR_4 = AVERROR(ENOMEM);
goto dump_format;
}
memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);
ost->st->codec->subtitle_header_size = dec->subtitle_header_size;
}
if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) {
snprintf(VAR_6, sizeof(VAR_6), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height",
ost->file_index, ost->index);
VAR_4 = AVERROR(EINVAL);
goto dump_format;
}
assert_codec_experimental(ost->st->codec, 1);
assert_avoptions(ost->opts);
if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000)
av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low."
"It takes bits/s as argument, not kbits/s\n");
extra_size += ost->st->codec->extradata_size;
}
}
for (VAR_5 = 0; VAR_5 < nb_input_streams; VAR_5++)
if ((VAR_4 = init_input_stream(VAR_5, output_streams, nb_output_streams, VAR_6, sizeof(VAR_6)) < 0))
goto dump_format;
for (VAR_5 = 0; VAR_5 < VAR_1; VAR_5++) {
os = VAR_0[VAR_5].ctx;
if (avformat_write_header(os, &VAR_0[VAR_5].opts) < 0) {
snprintf(VAR_6, sizeof(VAR_6), "Could not write header for output file #%d (incorrect codec parameters ?)", VAR_5);
VAR_4 = AVERROR(EINVAL);
goto dump_format;
}
if (strcmp(os->oformat->name, "rtp")) {
VAR_8 = 0;
}
}
dump_format:
for(VAR_5=0;VAR_5<VAR_1;VAR_5++) {
av_dump_format(VAR_0[VAR_5].ctx, VAR_5, VAR_0[VAR_5].ctx->filename, 1);
}
if (verbose >= 0) {
fprintf(stderr, "Stream mapping:\n");
for (VAR_5 = 0; VAR_5 < nb_output_streams;VAR_5 ++) {
ost = &output_streams[VAR_5];
fprintf(stderr, " Stream #%d.%d -> #%d.%d",
input_streams[ost->source_index].file_index,
input_streams[ost->source_index].st->index,
ost->file_index,
ost->index);
if (ost->sync_ist != &input_streams[ost->source_index])
fprintf(stderr, " [sync #%d.%d]",
ost->sync_ist->file_index,
ost->sync_ist->st->index);
if(ost->encoding_needed)
fprintf(stderr, ": %s -> %s",
input_streams[ost->source_index].dec ?
input_streams[ost->source_index].dec->name : "?",
ost->enc ? ost->enc->name : "?");
else
fprintf(stderr, ": copy");
fprintf(stderr, "\n");
}
}
if (VAR_4) {
fprintf(stderr, "%s\n", VAR_6);
goto fail;
}
if (VAR_8) {
print_sdp(VAR_0, VAR_1);
}
if (!using_stdin) {
if(verbose >= 0)
fprintf(stderr, "Press [q] to stop, [?] for help\n");
avio_set_interrupt_cb(decode_interrupt_cb);
}
term_init();
timer_start = av_gettime();
for(; received_sigterm == 0;) {
int file_index, ist_index;
AVPacket pkt;
int64_t ipts_min;
double opts_min;
redo:
ipts_min= INT64_MAX;
opts_min= 1e100;
if (!using_stdin) {
if (q_pressed)
break;
VAR_7 = read_key();
if (VAR_7 == 'q')
break;
if (VAR_7 == '+') verbose++;
if (VAR_7 == '-') verbose--;
if (VAR_7 == 's') qp_hist ^= 1;
if (VAR_7 == 'h'){
if (do_hex_dump){
do_hex_dump = do_pkt_dump = 0;
} else if(do_pkt_dump){
do_hex_dump = 1;
} else
do_pkt_dump = 1;
av_log_set_level(AV_LOG_DEBUG);
}
if (VAR_7 == 'c' || VAR_7 == 'C'){
char VAR_4[4096], target[64], cmd[256], arg[256]={0};
double ts;
fprintf(stderr, "\nEnter command: <target> <time> <command>[ <argument>]\n");
if(scanf("%4095[^\n\r]%*c", VAR_4) == 1 && sscanf(VAR_4, "%63[^ ] %lf %255[^ ] %255[^\n]", target, &ts, cmd, arg) >= 3){
for(VAR_5=0;VAR_5<nb_output_streams;VAR_5++) {
int r;
ost = &output_streams[VAR_5];
if(ost->graph){
if(ts<0){
r= avfilter_graph_send_command(ost->graph, target, cmd, arg, VAR_4, sizeof(VAR_4), VAR_7 == 'c' ? AVFILTER_CMD_FLAG_ONE : 0);
fprintf(stderr, "Command reply for %d: %d, %s\n", VAR_5, r, VAR_4);
}else{
r= avfilter_graph_queue_command(ost->graph, target, cmd, arg, 0, ts);
}
}
}
}else{
fprintf(stderr, "Parse VAR_6\n");
}
}
if (VAR_7 == 'd' || VAR_7 == 'D'){
int debug=0;
if(VAR_7 == 'D') {
debug = input_streams[0].st->codec->debug<<1;
if(!debug) debug = 1;
while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE))
debug += debug;
}else
scanf("%d", &debug);
for(VAR_5=0;VAR_5<nb_input_streams;VAR_5++) {
input_streams[VAR_5].st->codec->debug = debug;
}
for(VAR_5=0;VAR_5<nb_output_streams;VAR_5++) {
ost = &output_streams[VAR_5];
ost->st->codec->debug = debug;
}
if(debug) av_log_set_level(AV_LOG_DEBUG);
fprintf(stderr,"debug=%d\n", debug);
}
if (VAR_7 == '?'){
fprintf(stderr, "VAR_7 function\n"
"? show this help\n"
"+ increase verbosity\n"
"- decrease verbosity\n"
"c Send command to filtergraph\n"
"D cycle through available debug modes\n"
"h dump packets/hex press to cycle through the 3 states\n"
"q quit\n"
"s Show QP histogram\n"
);
}
}
file_index = -1;
for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++) {
OutputFile *of;
int64_t ipts;
double opts;
ost = &output_streams[VAR_5];
of = &VAR_0[ost->file_index];
os = VAR_0[ost->file_index].ctx;
ist = &input_streams[ost->source_index];
if (ost->is_past_recording_time || no_packet[ist->file_index] ||
(os->pb && avio_tell(os->pb) >= of->limit_filesize))
continue;
opts = ost->st->pts.val * av_q2d(ost->st->time_base);
ipts = ist->pts;
if (!VAR_2[ist->file_index].eof_reached){
if(ipts < ipts_min) {
ipts_min = ipts;
if(input_sync ) file_index = ist->file_index;
}
if(opts < opts_min) {
opts_min = opts;
if(!input_sync) file_index = ist->file_index;
}
}
if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){
file_index= -1;
break;
}
}
if (file_index < 0) {
if(VAR_9){
VAR_9=0;
memset(no_packet, 0, VAR_3);
usleep(10000);
continue;
}
break;
}
is = VAR_2[file_index].ctx;
VAR_4= av_read_frame(is, &pkt);
if(VAR_4 == AVERROR(EAGAIN)){
no_packet[file_index]=1;
VAR_9++;
continue;
}
if (VAR_4 < 0) {
VAR_2[file_index].eof_reached = 1;
if (opt_shortest)
break;
else
continue;
}
VAR_9=0;
memset(no_packet, 0, VAR_3);
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 >= VAR_2[file_index].nb_streams)
goto discard_packet;
ist_index = VAR_2[file_index].ist_index + pkt.stream_index;
ist = &input_streams[ist_index];
if (ist->discard)
goto discard_packet;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts += av_rescale_q(VAR_2[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts += av_rescale_q(VAR_2[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (ist->ts_scale) {
if(pkt.pts != AV_NOPTS_VALUE)
pkt.pts *= ist->ts_scale;
if(pkt.dts != AV_NOPTS_VALUE)
pkt.dts *= ist->ts_scale;
}
if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE
&& (is->iformat->flags & AVFMT_TS_DISCONT)) {
int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);
int64_t delta= pkt_dts - ist->next_pts;
if((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)&& !copy_ts){
VAR_2[ist->file_index].ts_offset -= delta;
if (verbose > 2)
fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n",
delta, VAR_2[ist->file_index].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);
}
}
if (output_packet(ist, ist_index, output_streams, nb_output_streams, &pkt) < 0) {
if (verbose >= 0)
fprintf(stderr, "Error while decoding stream #%d.%d\n",
ist->file_index, ist->st->index);
if (exit_on_error)
exit_program(1);
av_free_packet(&pkt);
goto redo;
}
discard_packet:
av_free_packet(&pkt);
print_report(VAR_0, output_streams, nb_output_streams, 0, timer_start);
}
for (VAR_5 = 0; VAR_5 < nb_input_streams; VAR_5++) {
ist = &input_streams[VAR_5];
if (ist->decoding_needed) {
output_packet(ist, VAR_5, output_streams, nb_output_streams, NULL);
}
}
flush_encoders(output_streams, nb_output_streams);
term_exit();
for(VAR_5=0;VAR_5<VAR_1;VAR_5++) {
os = VAR_0[VAR_5].ctx;
av_write_trailer(os);
}
print_report(VAR_0, output_streams, nb_output_streams, 1, timer_start);
for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++) {
ost = &output_streams[VAR_5];
if (ost->encoding_needed) {
av_freep(&ost->st->codec->stats_in);
avcodec_close(ost->st->codec);
}
#if CONFIG_AVFILTER
avfilter_graph_free(&ost->graph);
#endif
}
for (VAR_5 = 0; VAR_5 < nb_input_streams; VAR_5++) {
ist = &input_streams[VAR_5];
if (ist->decoding_needed) {
avcodec_close(ist->st->codec);
}
}
VAR_4 = 0;
fail:
av_freep(&bit_buffer);
av_freep(&no_packet);
if (output_streams) {
for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++) {
ost = &output_streams[VAR_5];
if (ost) {
if (ost->st->stream_copy)
av_freep(&ost->st->codec->extradata);
if (ost->logfile) {
fclose(ost->logfile);
ost->logfile = NULL;
}
av_fifo_free(ost->fifo);
av_freep(&ost->st->codec->subtitle_header);
av_free(ost->resample_frame.data[0]);
av_free(ost->forced_kf_pts);
if (ost->video_resample)
sws_freeContext(ost->img_resample_ctx);
if (ost->resample)
audio_resample_close(ost->resample);
if (ost->reformat_ctx)
av_audio_convert_free(ost->reformat_ctx);
av_dict_free(&ost->opts);
}
}
}
return VAR_4;
}
| [
"static int FUNC_0(OutputFile *VAR_0,\nint VAR_1,\nInputFile *VAR_2,\nint VAR_3)\n{",
"int VAR_4 = 0, VAR_5;",
"AVFormatContext *is, *os;",
"AVCodecContext *codec, *icodec;",
"OutputStream *ost;",
"InputStream *ist;",
"char VAR_6[1024];",
"int VAR_7;",
"int VAR_8 = 1;",
"uint8_t *no_packet;",
"int VAR_9=0;",
"int64_t timer_start;",
"if (!(no_packet = av_mallocz(VAR_3)))\nexit_program(1);",
"if (rate_emu)\nfor (VAR_5 = 0; VAR_5 < nb_input_streams; VAR_5++)",
"input_streams[VAR_5].start = av_gettime();",
"for(VAR_5=0;VAR_5<VAR_1;VAR_5++) {",
"os = VAR_0[VAR_5].ctx;",
"if (!os->nb_streams && !(os->oformat->flags & AVFMT_NOSTREAMS)) {",
"av_dump_format(os, VAR_5, os->filename, 1);",
"fprintf(stderr, \"Output file #%d does not contain any stream\\n\", VAR_5);",
"VAR_4 = AVERROR(EINVAL);",
"goto fail;",
"}",
"}",
"for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++) {",
"ost = &output_streams[VAR_5];",
"os = VAR_0[ost->file_index].ctx;",
"ist = &input_streams[ost->source_index];",
"codec = ost->st->codec;",
"icodec = ist->st->codec;",
"ost->st->disposition = ist->st->disposition;",
"codec->bits_per_raw_sample= icodec->bits_per_raw_sample;",
"codec->chroma_sample_location = icodec->chroma_sample_location;",
"if (ost->st->stream_copy) {",
"uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE;",
"if (extra_size > INT_MAX) {",
"VAR_4 = AVERROR(EINVAL);",
"goto fail;",
"}",
"codec->codec_id = icodec->codec_id;",
"codec->codec_type = icodec->codec_type;",
"if(!codec->codec_tag){",
"if( !os->oformat->codec_tag\n|| av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id\n|| av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0)\ncodec->codec_tag = icodec->codec_tag;",
"}",
"codec->bit_rate = icodec->bit_rate;",
"codec->rc_max_rate = icodec->rc_max_rate;",
"codec->rc_buffer_size = icodec->rc_buffer_size;",
"codec->extradata= av_mallocz(extra_size);",
"if (!codec->extradata) {",
"VAR_4 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"memcpy(codec->extradata, icodec->extradata, icodec->extradata_size);",
"codec->extradata_size= icodec->extradata_size;",
"codec->time_base = ist->st->time_base;",
"if(!strcmp(os->oformat->name, \"avi\")) {",
"if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > 2*av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){",
"codec->time_base = icodec->time_base;",
"codec->time_base.num *= icodec->ticks_per_frame;",
"codec->time_base.den *= 2;",
"}",
"} else if(!(os->oformat->flags & AVFMT_VARIABLE_FPS)) {",
"if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){",
"codec->time_base = icodec->time_base;",
"codec->time_base.num *= icodec->ticks_per_frame;",
"}",
"}",
"av_reduce(&codec->time_base.num, &codec->time_base.den,\ncodec->time_base.num, codec->time_base.den, INT_MAX);",
"switch(codec->codec_type) {",
"case AVMEDIA_TYPE_AUDIO:\nif(audio_volume != 256) {",
"fprintf(stderr,\"-acodec copy and -vol are incompatible (frames are not decoded)\\n\");",
"exit_program(1);",
"}",
"codec->channel_layout = icodec->channel_layout;",
"codec->sample_rate = icodec->sample_rate;",
"codec->channels = icodec->channels;",
"codec->frame_size = icodec->frame_size;",
"codec->audio_service_type = icodec->audio_service_type;",
"codec->block_align= icodec->block_align;",
"if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3)\ncodec->block_align= 0;",
"if(codec->codec_id == CODEC_ID_AC3)\ncodec->block_align= 0;",
"break;",
"case AVMEDIA_TYPE_VIDEO:\ncodec->pix_fmt = icodec->pix_fmt;",
"codec->width = icodec->width;",
"codec->height = icodec->height;",
"codec->has_b_frames = icodec->has_b_frames;",
"if (!codec->sample_aspect_ratio.num) {",
"codec->sample_aspect_ratio =\nost->st->sample_aspect_ratio =\nist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio :\nist->st->codec->sample_aspect_ratio.num ?\nist->st->codec->sample_aspect_ratio : (AVRational){0, 1};",
"}",
"break;",
"case AVMEDIA_TYPE_SUBTITLE:\ncodec->width = icodec->width;",
"codec->height = icodec->height;",
"break;",
"case AVMEDIA_TYPE_DATA:\nbreak;",
"default:\nabort();",
"}",
"} else {",
"if (!ost->enc)\nost->enc = avcodec_find_encoder(ost->st->codec->codec_id);",
"switch(codec->codec_type) {",
"case AVMEDIA_TYPE_AUDIO:\nost->fifo= av_fifo_alloc(1024);",
"if (!ost->fifo) {",
"VAR_4 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE);",
"if (!codec->sample_rate) {",
"codec->sample_rate = icodec->sample_rate;",
"}",
"choose_sample_rate(ost->st, ost->enc);",
"codec->time_base = (AVRational){1, codec->sample_rate};",
"if (codec->sample_fmt == AV_SAMPLE_FMT_NONE)\ncodec->sample_fmt = icodec->sample_fmt;",
"choose_sample_fmt(ost->st, ost->enc);",
"if (!codec->channels) {",
"codec->channels = icodec->channels;",
"codec->channel_layout = icodec->channel_layout;",
"}",
"if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels)\ncodec->channel_layout = 0;",
"ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1;",
"icodec->request_channels = codec->channels;",
"ist->decoding_needed = 1;",
"ost->encoding_needed = 1;",
"ost->resample_sample_fmt = icodec->sample_fmt;",
"ost->resample_sample_rate = icodec->sample_rate;",
"ost->resample_channels = icodec->channels;",
"break;",
"case AVMEDIA_TYPE_VIDEO:\nif (codec->pix_fmt == PIX_FMT_NONE)\ncodec->pix_fmt = icodec->pix_fmt;",
"choose_pixel_fmt(ost->st, ost->enc);",
"if (ost->st->codec->pix_fmt == PIX_FMT_NONE) {",
"fprintf(stderr, \"Video pixel format is unknown, stream cannot be encoded\\n\");",
"exit_program(1);",
"}",
"if (!codec->width || !codec->height) {",
"codec->width = icodec->width;",
"codec->height = icodec->height;",
"}",
"ost->video_resample = codec->width != icodec->width ||\ncodec->height != icodec->height ||\ncodec->pix_fmt != icodec->pix_fmt;",
"if (ost->video_resample) {",
"codec->bits_per_raw_sample= frame_bits_per_raw_sample;",
"}",
"ost->resample_height = icodec->height;",
"ost->resample_width = icodec->width;",
"ost->resample_pix_fmt= icodec->pix_fmt;",
"ost->encoding_needed = 1;",
"ist->decoding_needed = 1;",
"if (!ost->frame_rate.num)\nost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25,1};",
"if (ost->enc && ost->enc->supported_framerates && !force_fps) {",
"int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates);",
"ost->frame_rate = ost->enc->supported_framerates[idx];",
"}",
"codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num};",
"if( av_q2d(codec->time_base) < 0.001 && video_sync_method\n&& (video_sync_method==1 || (video_sync_method<0 && !(os->oformat->flags & AVFMT_VARIABLE_FPS)))){",
"av_log(os, AV_LOG_WARNING, \"Frame rate very high for a muxer not effciciently supporting it.\\n\"\n\"Please consider specifiying a lower framerate, a different muxer or -vsync 2\\n\");",
"}",
"#if CONFIG_AVFILTER\nif (configure_video_filters(ist, ost)) {",
"fprintf(stderr, \"Error opening filters!\\n\");",
"exit(1);",
"}",
"#endif\nbreak;",
"case AVMEDIA_TYPE_SUBTITLE:\nost->encoding_needed = 1;",
"ist->decoding_needed = 1;",
"break;",
"default:\nabort();",
"break;",
"}",
"if (ost->encoding_needed && codec->codec_id != CODEC_ID_H264 &&\n(codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {",
"char logfilename[1024];",
"FILE *f;",
"snprintf(logfilename, sizeof(logfilename), \"%s-%d.log\",\npass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX,\nVAR_5);",
"if (codec->flags & CODEC_FLAG_PASS1) {",
"f = fopen(logfilename, \"wb\");",
"if (!f) {",
"fprintf(stderr, \"Cannot write log file '%s' for pass-1 encoding: %s\\n\", logfilename, strerror(errno));",
"exit_program(1);",
"}",
"ost->logfile = f;",
"} else {",
"char *logbuffer;",
"size_t logbuffer_size;",
"if (read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {",
"fprintf(stderr, \"Error reading log file '%s' for pass-2 encoding\\n\", logfilename);",
"exit_program(1);",
"}",
"codec->stats_in = logbuffer;",
"}",
"}",
"}",
"if(codec->codec_type == AVMEDIA_TYPE_VIDEO){",
"int size= codec->width * codec->height;",
"bit_buffer_size= FFMAX(bit_buffer_size, 6*size + 1664);",
"}",
"}",
"if (!bit_buffer)\nbit_buffer = av_malloc(bit_buffer_size);",
"if (!bit_buffer) {",
"fprintf(stderr, \"Cannot allocate %d bytes output buffer\\n\",\nbit_buffer_size);",
"VAR_4 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++) {",
"ost = &output_streams[VAR_5];",
"if (ost->encoding_needed) {",
"AVCodec *codec = ost->enc;",
"AVCodecContext *dec = input_streams[ost->source_index].st->codec;",
"if (!codec) {",
"snprintf(VAR_6, sizeof(VAR_6), \"Encoder (codec %s) not found for output stream #%d.%d\",\navcodec_get_name(ost->st->codec->codec_id), ost->file_index, ost->index);",
"VAR_4 = AVERROR(EINVAL);",
"goto dump_format;",
"}",
"if (dec->subtitle_header) {",
"ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size);",
"if (!ost->st->codec->subtitle_header) {",
"VAR_4 = AVERROR(ENOMEM);",
"goto dump_format;",
"}",
"memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);",
"ost->st->codec->subtitle_header_size = dec->subtitle_header_size;",
"}",
"if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) {",
"snprintf(VAR_6, sizeof(VAR_6), \"Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height\",\nost->file_index, ost->index);",
"VAR_4 = AVERROR(EINVAL);",
"goto dump_format;",
"}",
"assert_codec_experimental(ost->st->codec, 1);",
"assert_avoptions(ost->opts);",
"if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000)\nav_log(NULL, AV_LOG_WARNING, \"The bitrate parameter is set too low.\"\n\"It takes bits/s as argument, not kbits/s\\n\");",
"extra_size += ost->st->codec->extradata_size;",
"}",
"}",
"for (VAR_5 = 0; VAR_5 < nb_input_streams; VAR_5++)",
"if ((VAR_4 = init_input_stream(VAR_5, output_streams, nb_output_streams, VAR_6, sizeof(VAR_6)) < 0))\ngoto dump_format;",
"for (VAR_5 = 0; VAR_5 < VAR_1; VAR_5++) {",
"os = VAR_0[VAR_5].ctx;",
"if (avformat_write_header(os, &VAR_0[VAR_5].opts) < 0) {",
"snprintf(VAR_6, sizeof(VAR_6), \"Could not write header for output file #%d (incorrect codec parameters ?)\", VAR_5);",
"VAR_4 = AVERROR(EINVAL);",
"goto dump_format;",
"}",
"if (strcmp(os->oformat->name, \"rtp\")) {",
"VAR_8 = 0;",
"}",
"}",
"dump_format:\nfor(VAR_5=0;VAR_5<VAR_1;VAR_5++) {",
"av_dump_format(VAR_0[VAR_5].ctx, VAR_5, VAR_0[VAR_5].ctx->filename, 1);",
"}",
"if (verbose >= 0) {",
"fprintf(stderr, \"Stream mapping:\\n\");",
"for (VAR_5 = 0; VAR_5 < nb_output_streams;VAR_5 ++) {",
"ost = &output_streams[VAR_5];",
"fprintf(stderr, \" Stream #%d.%d -> #%d.%d\",\ninput_streams[ost->source_index].file_index,\ninput_streams[ost->source_index].st->index,\nost->file_index,\nost->index);",
"if (ost->sync_ist != &input_streams[ost->source_index])\nfprintf(stderr, \" [sync #%d.%d]\",\nost->sync_ist->file_index,\nost->sync_ist->st->index);",
"if(ost->encoding_needed)\nfprintf(stderr, \": %s -> %s\",\ninput_streams[ost->source_index].dec ?\ninput_streams[ost->source_index].dec->name : \"?\",\nost->enc ? ost->enc->name : \"?\");",
"else\nfprintf(stderr, \": copy\");",
"fprintf(stderr, \"\\n\");",
"}",
"}",
"if (VAR_4) {",
"fprintf(stderr, \"%s\\n\", VAR_6);",
"goto fail;",
"}",
"if (VAR_8) {",
"print_sdp(VAR_0, VAR_1);",
"}",
"if (!using_stdin) {",
"if(verbose >= 0)\nfprintf(stderr, \"Press [q] to stop, [?] for help\\n\");",
"avio_set_interrupt_cb(decode_interrupt_cb);",
"}",
"term_init();",
"timer_start = av_gettime();",
"for(; received_sigterm == 0;) {",
"int file_index, ist_index;",
"AVPacket pkt;",
"int64_t ipts_min;",
"double opts_min;",
"redo:\nipts_min= INT64_MAX;",
"opts_min= 1e100;",
"if (!using_stdin) {",
"if (q_pressed)\nbreak;",
"VAR_7 = read_key();",
"if (VAR_7 == 'q')\nbreak;",
"if (VAR_7 == '+') verbose++;",
"if (VAR_7 == '-') verbose--;",
"if (VAR_7 == 's') qp_hist ^= 1;",
"if (VAR_7 == 'h'){",
"if (do_hex_dump){",
"do_hex_dump = do_pkt_dump = 0;",
"} else if(do_pkt_dump){",
"do_hex_dump = 1;",
"} else",
"do_pkt_dump = 1;",
"av_log_set_level(AV_LOG_DEBUG);",
"}",
"if (VAR_7 == 'c' || VAR_7 == 'C'){",
"char VAR_4[4096], target[64], cmd[256], arg[256]={0};",
"double ts;",
"fprintf(stderr, \"\\nEnter command: <target> <time> <command>[ <argument>]\\n\");",
"if(scanf(\"%4095[^\\n\\r]%*c\", VAR_4) == 1 && sscanf(VAR_4, \"%63[^ ] %lf %255[^ ] %255[^\\n]\", target, &ts, cmd, arg) >= 3){",
"for(VAR_5=0;VAR_5<nb_output_streams;VAR_5++) {",
"int r;",
"ost = &output_streams[VAR_5];",
"if(ost->graph){",
"if(ts<0){",
"r= avfilter_graph_send_command(ost->graph, target, cmd, arg, VAR_4, sizeof(VAR_4), VAR_7 == 'c' ? AVFILTER_CMD_FLAG_ONE : 0);",
"fprintf(stderr, \"Command reply for %d: %d, %s\\n\", VAR_5, r, VAR_4);",
"}else{",
"r= avfilter_graph_queue_command(ost->graph, target, cmd, arg, 0, ts);",
"}",
"}",
"}",
"}else{",
"fprintf(stderr, \"Parse VAR_6\\n\");",
"}",
"}",
"if (VAR_7 == 'd' || VAR_7 == 'D'){",
"int debug=0;",
"if(VAR_7 == 'D') {",
"debug = input_streams[0].st->codec->debug<<1;",
"if(!debug) debug = 1;",
"while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE))\ndebug += debug;",
"}else",
"scanf(\"%d\", &debug);",
"for(VAR_5=0;VAR_5<nb_input_streams;VAR_5++) {",
"input_streams[VAR_5].st->codec->debug = debug;",
"}",
"for(VAR_5=0;VAR_5<nb_output_streams;VAR_5++) {",
"ost = &output_streams[VAR_5];",
"ost->st->codec->debug = debug;",
"}",
"if(debug) av_log_set_level(AV_LOG_DEBUG);",
"fprintf(stderr,\"debug=%d\\n\", debug);",
"}",
"if (VAR_7 == '?'){",
"fprintf(stderr, \"VAR_7 function\\n\"\n\"? show this help\\n\"\n\"+ increase verbosity\\n\"\n\"- decrease verbosity\\n\"\n\"c Send command to filtergraph\\n\"\n\"D cycle through available debug modes\\n\"\n\"h dump packets/hex press to cycle through the 3 states\\n\"\n\"q quit\\n\"\n\"s Show QP histogram\\n\"\n);",
"}",
"}",
"file_index = -1;",
"for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++) {",
"OutputFile *of;",
"int64_t ipts;",
"double opts;",
"ost = &output_streams[VAR_5];",
"of = &VAR_0[ost->file_index];",
"os = VAR_0[ost->file_index].ctx;",
"ist = &input_streams[ost->source_index];",
"if (ost->is_past_recording_time || no_packet[ist->file_index] ||\n(os->pb && avio_tell(os->pb) >= of->limit_filesize))\ncontinue;",
"opts = ost->st->pts.val * av_q2d(ost->st->time_base);",
"ipts = ist->pts;",
"if (!VAR_2[ist->file_index].eof_reached){",
"if(ipts < ipts_min) {",
"ipts_min = ipts;",
"if(input_sync ) file_index = ist->file_index;",
"}",
"if(opts < opts_min) {",
"opts_min = opts;",
"if(!input_sync) file_index = ist->file_index;",
"}",
"}",
"if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){",
"file_index= -1;",
"break;",
"}",
"}",
"if (file_index < 0) {",
"if(VAR_9){",
"VAR_9=0;",
"memset(no_packet, 0, VAR_3);",
"usleep(10000);",
"continue;",
"}",
"break;",
"}",
"is = VAR_2[file_index].ctx;",
"VAR_4= av_read_frame(is, &pkt);",
"if(VAR_4 == AVERROR(EAGAIN)){",
"no_packet[file_index]=1;",
"VAR_9++;",
"continue;",
"}",
"if (VAR_4 < 0) {",
"VAR_2[file_index].eof_reached = 1;",
"if (opt_shortest)\nbreak;",
"else\ncontinue;",
"}",
"VAR_9=0;",
"memset(no_packet, 0, VAR_3);",
"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 >= VAR_2[file_index].nb_streams)\ngoto discard_packet;",
"ist_index = VAR_2[file_index].ist_index + pkt.stream_index;",
"ist = &input_streams[ist_index];",
"if (ist->discard)\ngoto discard_packet;",
"if (pkt.dts != AV_NOPTS_VALUE)\npkt.dts += av_rescale_q(VAR_2[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base);",
"if (pkt.pts != AV_NOPTS_VALUE)\npkt.pts += av_rescale_q(VAR_2[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base);",
"if (ist->ts_scale) {",
"if(pkt.pts != AV_NOPTS_VALUE)\npkt.pts *= ist->ts_scale;",
"if(pkt.dts != AV_NOPTS_VALUE)\npkt.dts *= ist->ts_scale;",
"}",
"if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE\n&& (is->iformat->flags & AVFMT_TS_DISCONT)) {",
"int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);",
"int64_t delta= pkt_dts - ist->next_pts;",
"if((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)&& !copy_ts){",
"VAR_2[ist->file_index].ts_offset -= delta;",
"if (verbose > 2)\nfprintf(stderr, \"timestamp discontinuity %\"PRId64\", new offset= %\"PRId64\"\\n\",\ndelta, VAR_2[ist->file_index].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);",
"}",
"}",
"if (output_packet(ist, ist_index, output_streams, nb_output_streams, &pkt) < 0) {",
"if (verbose >= 0)\nfprintf(stderr, \"Error while decoding stream #%d.%d\\n\",\nist->file_index, ist->st->index);",
"if (exit_on_error)\nexit_program(1);",
"av_free_packet(&pkt);",
"goto redo;",
"}",
"discard_packet:\nav_free_packet(&pkt);",
"print_report(VAR_0, output_streams, nb_output_streams, 0, timer_start);",
"}",
"for (VAR_5 = 0; VAR_5 < nb_input_streams; VAR_5++) {",
"ist = &input_streams[VAR_5];",
"if (ist->decoding_needed) {",
"output_packet(ist, VAR_5, output_streams, nb_output_streams, NULL);",
"}",
"}",
"flush_encoders(output_streams, nb_output_streams);",
"term_exit();",
"for(VAR_5=0;VAR_5<VAR_1;VAR_5++) {",
"os = VAR_0[VAR_5].ctx;",
"av_write_trailer(os);",
"}",
"print_report(VAR_0, output_streams, nb_output_streams, 1, timer_start);",
"for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++) {",
"ost = &output_streams[VAR_5];",
"if (ost->encoding_needed) {",
"av_freep(&ost->st->codec->stats_in);",
"avcodec_close(ost->st->codec);",
"}",
"#if CONFIG_AVFILTER\navfilter_graph_free(&ost->graph);",
"#endif\n}",
"for (VAR_5 = 0; VAR_5 < nb_input_streams; VAR_5++) {",
"ist = &input_streams[VAR_5];",
"if (ist->decoding_needed) {",
"avcodec_close(ist->st->codec);",
"}",
"}",
"VAR_4 = 0;",
"fail:\nav_freep(&bit_buffer);",
"av_freep(&no_packet);",
"if (output_streams) {",
"for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++) {",
"ost = &output_streams[VAR_5];",
"if (ost) {",
"if (ost->st->stream_copy)\nav_freep(&ost->st->codec->extradata);",
"if (ost->logfile) {",
"fclose(ost->logfile);",
"ost->logfile = NULL;",
"}",
"av_fifo_free(ost->fifo);",
"av_freep(&ost->st->codec->subtitle_header);",
"av_free(ost->resample_frame.data[0]);",
"av_free(ost->forced_kf_pts);",
"if (ost->video_resample)\nsws_freeContext(ost->img_resample_ctx);",
"if (ost->resample)\naudio_resample_close(ost->resample);",
"if (ost->reformat_ctx)\nav_audio_convert_free(ost->reformat_ctx);",
"av_dict_free(&ost->opts);",
"}",
"}",
"}",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
115
],
[
117
],
[
121
],
[
123,
125,
127,
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183,
185
],
[
189
],
[
191,
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213,
215
],
[
217,
219
],
[
221
],
[
223,
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235,
237,
239,
241,
243
],
[
245
],
[
247
],
[
249,
251
],
[
253
],
[
255
],
[
257,
259
],
[
261,
263
],
[
265
],
[
267
],
[
269,
271
],
[
273
],
[
275,
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299,
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313,
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333,
335,
337
],
[
339
],
[
343
],
[
345
],
[
347
],
[
349
],
[
353
],
[
355
],
[
357
],
[
359
],
[
363,
365,
367
],
[
369
],
[
371
],
[
373
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
389,
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403,
405
],
[
407,
409
],
[
411
],
[
415,
417
],
[
419
],
[
421
],
[
423
],
[
425,
427
],
[
429,
431
],
[
433
],
[
435
],
[
437,
439
],
[
441
],
[
443
],
[
447,
449
],
[
451
],
[
453
],
[
457,
459,
461
],
[
463
],
[
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
477
],
[
479
],
[
481
],
[
483
],
[
485
],
[
487
],
[
489
],
[
491
],
[
493
],
[
495
],
[
497
],
[
499
],
[
503
],
[
505
],
[
507
],
[
509
],
[
513,
515
],
[
517
],
[
519,
521
],
[
523
],
[
525
],
[
527
],
[
533
],
[
535
],
[
537
],
[
539
],
[
541
],
[
543
],
[
545,
547
],
[
549
],
[
551
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563
],
[
565
],
[
567
],
[
569
],
[
571
],
[
573
],
[
575,
577
],
[
579
],
[
581
],
[
583
],
[
585
],
[
587
],
[
589,
591,
593
],
[
595
],
[
597
],
[
599
],
[
605
],
[
607,
609
],
[
615
],
[
617
],
[
619
],
[
621
],
[
623
],
[
625
],
[
627
],
[
631
],
[
633
],
[
635
],
[
637
],
[
641,
647
],
[
649
],
[
651
],
[
657
],
[
659
],
[
661
],
[
663
],
[
665,
667,
669,
671,
673
],
[
675,
677,
679,
681
],
[
683,
685,
687,
689,
691
],
[
693,
695
],
[
697
],
[
699
],
[
701
],
[
705
],
[
707
],
[
709
],
[
711
],
[
715
],
[
717
],
[
719
],
[
723
],
[
725,
727
],
[
729
],
[
731
],
[
733
],
[
737
],
[
741
],
[
743
],
[
745
],
[
747
],
[
749
],
[
753,
755
],
[
757
],
[
761
],
[
763,
765
],
[
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
],
[
911
],
[
913
],
[
915
],
[
917
],
[
919
],
[
921
],
[
923
],
[
925
],
[
927
],
[
929,
931,
933
],
[
935
],
[
937
],
[
939
],
[
941
],
[
943
],
[
945
],
[
947
],
[
949
],
[
951
],
[
953
],
[
955
],
[
957
],
[
959
],
[
961
],
[
963
],
[
965
],
[
967
],
[
971
],
[
973
],
[
975
],
[
977
],
[
979
],
[
981
],
[
983
],
[
985
],
[
987
],
[
993
],
[
995
],
[
997
],
[
999
],
[
1001
],
[
1003
],
[
1005
],
[
1007
],
[
1009
],
[
1011,
1013
],
[
1015,
1017
],
[
1019
],
[
1023
],
[
1025
],
[
1029
],
[
1031,
1033
],
[
1035
],
[
1041,
1043
],
[
1045
],
[
1047
],
[
1049,
1051
],
[
1055,
1057
],
[
1059,
1061
],
[
1065
],
[
1067,
1069
],
[
1071,
1073
],
[
1075
],
[
1081,
1083
],
[
1085
],
[
1087
],
[
1089,
1091,
1093,
1095
],
[
1097
],
[
1099,
1101,
1103
],
[
1105
],
[
1107,
1109
],
[
1111
],
[
1113
],
[
1119
],
[
1123,
1125,
1127
],
[
1129,
1131
],
[
1133
],
[
1135
],
[
1137
],
[
1141,
1143
],
[
1149
],
[
1151
],
[
1157
],
[
1159
],
[
1161
],
[
1163
],
[
1165
],
[
1167
],
[
1169
],
[
1173
],
[
1179
],
[
1181
],
[
1183
],
[
1185
],
[
1191
],
[
1197
],
[
1199
],
[
1201
],
[
1203
],
[
1205
],
[
1207
],
[
1209,
1211
],
[
1213,
1215
],
[
1221
],
[
1223
],
[
1225
],
[
1227
],
[
1229
],
[
1231
],
[
1237
],
[
1241,
1243
],
[
1245
],
[
1249
],
[
1251
],
[
1253
],
[
1255
],
[
1257,
1259
],
[
1261
],
[
1263
],
[
1265
],
[
1267
],
[
1269
],
[
1273
],
[
1275
],
[
1277
],
[
1279,
1281
],
[
1283,
1285
],
[
1287,
1289
],
[
1291
],
[
1293
],
[
1295
],
[
1297
],
[
1299
],
[
1301
]
] |
3,605 | static int dvvideo_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
DVVideoContext *s = avctx->priv_data;
/* special case for last picture */
if(buf_size==0)
return 0;
s->sys = dv_frame_profile(buf);
if (!s->sys || buf_size < s->sys->frame_size)
return -1; /* NOTE: we only accept several full frames */
if(s->picture.data[0])
avctx->release_buffer(avctx, &s->picture);
s->picture.reference = 0;
avctx->pix_fmt = s->sys->pix_fmt;
avctx->width = s->sys->width;
avctx->height = s->sys->height;
if(avctx->get_buffer(avctx, &s->picture) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
s->picture.interlaced_frame = 1;
s->picture.top_field_first = 0;
s->buf = buf;
avctx->execute(avctx, dv_decode_mt, (void**)&dv_anchor[0], NULL,
s->sys->difseg_size * 27);
emms_c();
/* return image */
*data_size = sizeof(AVFrame);
*(AVFrame*)data= s->picture;
return s->sys->frame_size;
}
| false | FFmpeg | 934982c4ace1a3d5d627b518782ed092a456c49e | static int dvvideo_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
DVVideoContext *s = avctx->priv_data;
if(buf_size==0)
return 0;
s->sys = dv_frame_profile(buf);
if (!s->sys || buf_size < s->sys->frame_size)
return -1;
if(s->picture.data[0])
avctx->release_buffer(avctx, &s->picture);
s->picture.reference = 0;
avctx->pix_fmt = s->sys->pix_fmt;
avctx->width = s->sys->width;
avctx->height = s->sys->height;
if(avctx->get_buffer(avctx, &s->picture) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
s->picture.interlaced_frame = 1;
s->picture.top_field_first = 0;
s->buf = buf;
avctx->execute(avctx, dv_decode_mt, (void**)&dv_anchor[0], NULL,
s->sys->difseg_size * 27);
emms_c();
*data_size = sizeof(AVFrame);
*(AVFrame*)data= s->picture;
return s->sys->frame_size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
uint8_t *VAR_3, int VAR_4)
{
DVVideoContext *s = VAR_0->priv_data;
if(VAR_4==0)
return 0;
s->sys = dv_frame_profile(VAR_3);
if (!s->sys || VAR_4 < s->sys->frame_size)
return -1;
if(s->picture.VAR_1[0])
VAR_0->release_buffer(VAR_0, &s->picture);
s->picture.reference = 0;
VAR_0->pix_fmt = s->sys->pix_fmt;
VAR_0->width = s->sys->width;
VAR_0->height = s->sys->height;
if(VAR_0->get_buffer(VAR_0, &s->picture) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
s->picture.interlaced_frame = 1;
s->picture.top_field_first = 0;
s->VAR_3 = VAR_3;
VAR_0->execute(VAR_0, dv_decode_mt, (void**)&dv_anchor[0], NULL,
s->sys->difseg_size * 27);
emms_c();
*VAR_2 = sizeof(AVFrame);
*(AVFrame*)VAR_1= s->picture;
return s->sys->frame_size;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nuint8_t *VAR_3, int VAR_4)\n{",
"DVVideoContext *s = VAR_0->priv_data;",
"if(VAR_4==0)\nreturn 0;",
"s->sys = dv_frame_profile(VAR_3);",
"if (!s->sys || VAR_4 < s->sys->frame_size)\nreturn -1;",
"if(s->picture.VAR_1[0])\nVAR_0->release_buffer(VAR_0, &s->picture);",
"s->picture.reference = 0;",
"VAR_0->pix_fmt = s->sys->pix_fmt;",
"VAR_0->width = s->sys->width;",
"VAR_0->height = s->sys->height;",
"if(VAR_0->get_buffer(VAR_0, &s->picture) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\n\");",
"return -1;",
"}",
"s->picture.interlaced_frame = 1;",
"s->picture.top_field_first = 0;",
"s->VAR_3 = VAR_3;",
"VAR_0->execute(VAR_0, dv_decode_mt, (void**)&dv_anchor[0], NULL,\ns->sys->difseg_size * 27);",
"emms_c();",
"*VAR_2 = sizeof(AVFrame);",
"*(AVFrame*)VAR_1= s->picture;",
"return s->sys->frame_size;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
15,
17
],
[
21
],
[
23,
25
],
[
29,
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59,
61
],
[
65
],
[
71
],
[
73
],
[
77
],
[
79
]
] |
3,606 | rdt_parse_packet (PayloadContext *rdt, AVStream *st,
AVPacket *pkt, uint32_t *timestamp,
const uint8_t *buf, int len, int flags)
{
int seq = 1, res;
ByteIOContext pb;
if (rdt->audio_pkt_cnt == 0) {
int pos;
init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
flags = (flags & PKT_FLAG_KEY) ? 2 : 0;
res = ff_rm_parse_packet (rdt->rmctx, &pb, st, rdt->rmst[0], len, pkt,
&seq, &flags, timestamp);
pos = url_ftell(&pb);
if (res < 0)
return res;
rdt->audio_pkt_cnt[st->id] = res;
if (rdt->audio_pkt_cnt[st->id] > 0 &&
st->codec->codec_id == CODEC_ID_AAC) {
memcpy (rdt->buffer, buf + pos, len - pos);
rdt->rmctx->pb = av_alloc_put_byte (rdt->buffer, len - pos, 0,
NULL, NULL, NULL, NULL);
}
} else {
ff_rm_retrieve_cache (rdt->rmctx, rdt->rmctx->pb, st, rdt->rmst[0], pkt);
if (rdt->audio_pkt_cnt[st->id] == 0 &&
st->codec->codec_id == CODEC_ID_AAC)
av_freep(&rdt->rmctx->pb);
}
pkt->stream_index = st->index;
pkt->pts = *timestamp;
return rdt->audio_pkt_cnt[st->id] > 0;
}
| false | FFmpeg | 5d88c2647def2557637077e9284cfe9806954502 | rdt_parse_packet (PayloadContext *rdt, AVStream *st,
AVPacket *pkt, uint32_t *timestamp,
const uint8_t *buf, int len, int flags)
{
int seq = 1, res;
ByteIOContext pb;
if (rdt->audio_pkt_cnt == 0) {
int pos;
init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
flags = (flags & PKT_FLAG_KEY) ? 2 : 0;
res = ff_rm_parse_packet (rdt->rmctx, &pb, st, rdt->rmst[0], len, pkt,
&seq, &flags, timestamp);
pos = url_ftell(&pb);
if (res < 0)
return res;
rdt->audio_pkt_cnt[st->id] = res;
if (rdt->audio_pkt_cnt[st->id] > 0 &&
st->codec->codec_id == CODEC_ID_AAC) {
memcpy (rdt->buffer, buf + pos, len - pos);
rdt->rmctx->pb = av_alloc_put_byte (rdt->buffer, len - pos, 0,
NULL, NULL, NULL, NULL);
}
} else {
ff_rm_retrieve_cache (rdt->rmctx, rdt->rmctx->pb, st, rdt->rmst[0], pkt);
if (rdt->audio_pkt_cnt[st->id] == 0 &&
st->codec->codec_id == CODEC_ID_AAC)
av_freep(&rdt->rmctx->pb);
}
pkt->stream_index = st->index;
pkt->pts = *timestamp;
return rdt->audio_pkt_cnt[st->id] > 0;
}
| {
"code": [],
"line_no": []
} | FUNC_0 (PayloadContext *VAR_0, AVStream *VAR_1,
AVPacket *VAR_2, uint32_t *VAR_3,
const uint8_t *VAR_4, int VAR_5, int VAR_6)
{
int VAR_7 = 1, VAR_8;
ByteIOContext pb;
if (VAR_0->audio_pkt_cnt == 0) {
int VAR_9;
init_put_byte(&pb, VAR_4, VAR_5, 0, NULL, NULL, NULL, NULL);
VAR_6 = (VAR_6 & PKT_FLAG_KEY) ? 2 : 0;
VAR_8 = ff_rm_parse_packet (VAR_0->rmctx, &pb, VAR_1, VAR_0->rmst[0], VAR_5, VAR_2,
&VAR_7, &VAR_6, VAR_3);
VAR_9 = url_ftell(&pb);
if (VAR_8 < 0)
return VAR_8;
VAR_0->audio_pkt_cnt[VAR_1->id] = VAR_8;
if (VAR_0->audio_pkt_cnt[VAR_1->id] > 0 &&
VAR_1->codec->codec_id == CODEC_ID_AAC) {
memcpy (VAR_0->buffer, VAR_4 + VAR_9, VAR_5 - VAR_9);
VAR_0->rmctx->pb = av_alloc_put_byte (VAR_0->buffer, VAR_5 - VAR_9, 0,
NULL, NULL, NULL, NULL);
}
} else {
ff_rm_retrieve_cache (VAR_0->rmctx, VAR_0->rmctx->pb, VAR_1, VAR_0->rmst[0], VAR_2);
if (VAR_0->audio_pkt_cnt[VAR_1->id] == 0 &&
VAR_1->codec->codec_id == CODEC_ID_AAC)
av_freep(&VAR_0->rmctx->pb);
}
VAR_2->stream_index = VAR_1->index;
VAR_2->pts = *VAR_3;
return VAR_0->audio_pkt_cnt[VAR_1->id] > 0;
}
| [
"FUNC_0 (PayloadContext *VAR_0, AVStream *VAR_1,\nAVPacket *VAR_2, uint32_t *VAR_3,\nconst uint8_t *VAR_4, int VAR_5, int VAR_6)\n{",
"int VAR_7 = 1, VAR_8;",
"ByteIOContext pb;",
"if (VAR_0->audio_pkt_cnt == 0) {",
"int VAR_9;",
"init_put_byte(&pb, VAR_4, VAR_5, 0, NULL, NULL, NULL, NULL);",
"VAR_6 = (VAR_6 & PKT_FLAG_KEY) ? 2 : 0;",
"VAR_8 = ff_rm_parse_packet (VAR_0->rmctx, &pb, VAR_1, VAR_0->rmst[0], VAR_5, VAR_2,\n&VAR_7, &VAR_6, VAR_3);",
"VAR_9 = url_ftell(&pb);",
"if (VAR_8 < 0)\nreturn VAR_8;",
"VAR_0->audio_pkt_cnt[VAR_1->id] = VAR_8;",
"if (VAR_0->audio_pkt_cnt[VAR_1->id] > 0 &&\nVAR_1->codec->codec_id == CODEC_ID_AAC) {",
"memcpy (VAR_0->buffer, VAR_4 + VAR_9, VAR_5 - VAR_9);",
"VAR_0->rmctx->pb = av_alloc_put_byte (VAR_0->buffer, VAR_5 - VAR_9, 0,\nNULL, NULL, NULL, NULL);",
"}",
"} else {",
"ff_rm_retrieve_cache (VAR_0->rmctx, VAR_0->rmctx->pb, VAR_1, VAR_0->rmst[0], VAR_2);",
"if (VAR_0->audio_pkt_cnt[VAR_1->id] == 0 &&\nVAR_1->codec->codec_id == CODEC_ID_AAC)\nav_freep(&VAR_0->rmctx->pb);",
"}",
"VAR_2->stream_index = VAR_1->index;",
"VAR_2->pts = *VAR_3;",
"return VAR_0->audio_pkt_cnt[VAR_1->id] > 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31,
33
],
[
35
],
[
37,
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53,
55,
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
]
] |
3,607 | static void FUNC(hevc_v_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride,
int *beta, int *tc, uint8_t *no_p,
uint8_t *no_q)
{
FUNC(hevc_loop_filter_luma)(pix, sizeof(pixel), stride,
beta, tc, no_p, no_q);
}
| false | FFmpeg | 73bb8f61d48dbf7237df2e9cacd037f12b84b00a | static void FUNC(hevc_v_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride,
int *beta, int *tc, uint8_t *no_p,
uint8_t *no_q)
{
FUNC(hevc_loop_filter_luma)(pix, sizeof(pixel), stride,
beta, tc, no_p, no_q);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(hevc_v_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride,
int *beta, int *tc, uint8_t *no_p,
uint8_t *no_q)
{
FUNC_0(hevc_loop_filter_luma)(pix, sizeof(pixel), stride,
beta, tc, no_p, no_q);
}
| [
"static void FUNC_0(hevc_v_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride,\nint *beta, int *tc, uint8_t *no_p,\nuint8_t *no_q)\n{",
"FUNC_0(hevc_loop_filter_luma)(pix, sizeof(pixel), stride,\nbeta, tc, no_p, no_q);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9,
11
],
[
13
]
] |
3,608 | static int http_server(void)
{
int server_fd, ret, rtsp_server_fd, delay, delay1;
struct pollfd poll_table[HTTP_MAX_CONNECTIONS + 2], *poll_entry;
HTTPContext *c, *c_next;
server_fd = socket_open_listen(&my_http_addr);
if (server_fd < 0)
return -1;
rtsp_server_fd = socket_open_listen(&my_rtsp_addr);
if (rtsp_server_fd < 0)
return -1;
http_log("ffserver started.\n");
start_children(first_feed);
first_http_ctx = NULL;
nb_connections = 0;
start_multicast();
for(;;) {
poll_entry = poll_table;
poll_entry->fd = server_fd;
poll_entry->events = POLLIN;
poll_entry++;
poll_entry->fd = rtsp_server_fd;
poll_entry->events = POLLIN;
poll_entry++;
/* wait for events on each HTTP handle */
c = first_http_ctx;
delay = 1000;
while (c != NULL) {
int fd;
fd = c->fd;
switch(c->state) {
case HTTPSTATE_SEND_HEADER:
case RTSPSTATE_SEND_REPLY:
case RTSPSTATE_SEND_PACKET:
c->poll_entry = poll_entry;
poll_entry->fd = fd;
poll_entry->events = POLLOUT;
poll_entry++;
break;
case HTTPSTATE_SEND_DATA_HEADER:
case HTTPSTATE_SEND_DATA:
case HTTPSTATE_SEND_DATA_TRAILER:
if (!c->is_packetized) {
/* for TCP, we output as much as we can (may need to put a limit) */
c->poll_entry = poll_entry;
poll_entry->fd = fd;
poll_entry->events = POLLOUT;
poll_entry++;
} else {
/* when ffserver is doing the timing, we work by
looking at which packet need to be sent every
10 ms */
delay1 = 10; /* one tick wait XXX: 10 ms assumed */
if (delay1 < delay)
delay = delay1;
}
break;
case HTTPSTATE_WAIT_REQUEST:
case HTTPSTATE_RECEIVE_DATA:
case HTTPSTATE_WAIT_FEED:
case RTSPSTATE_WAIT_REQUEST:
/* need to catch errors */
c->poll_entry = poll_entry;
poll_entry->fd = fd;
poll_entry->events = POLLIN;/* Maybe this will work */
poll_entry++;
break;
default:
c->poll_entry = NULL;
break;
}
c = c->next;
}
/* wait for an event on one connection. We poll at least every
second to handle timeouts */
do {
ret = poll(poll_table, poll_entry - poll_table, delay);
if (ret < 0 && errno != EAGAIN && errno != EINTR)
return -1;
} while (ret <= 0);
cur_time = av_gettime() / 1000;
if (need_to_start_children) {
need_to_start_children = 0;
start_children(first_feed);
}
/* now handle the events */
for(c = first_http_ctx; c != NULL; c = c_next) {
c_next = c->next;
if (handle_connection(c) < 0) {
/* close and free the connection */
log_connection(c);
close_connection(c);
}
}
poll_entry = poll_table;
/* new HTTP connection request ? */
if (poll_entry->revents & POLLIN) {
new_connection(server_fd, 0);
}
poll_entry++;
/* new RTSP connection request ? */
if (poll_entry->revents & POLLIN) {
new_connection(rtsp_server_fd, 1);
}
}
}
| false | FFmpeg | e8d658df344553170cc1302438a8e70d97b52169 | static int http_server(void)
{
int server_fd, ret, rtsp_server_fd, delay, delay1;
struct pollfd poll_table[HTTP_MAX_CONNECTIONS + 2], *poll_entry;
HTTPContext *c, *c_next;
server_fd = socket_open_listen(&my_http_addr);
if (server_fd < 0)
return -1;
rtsp_server_fd = socket_open_listen(&my_rtsp_addr);
if (rtsp_server_fd < 0)
return -1;
http_log("ffserver started.\n");
start_children(first_feed);
first_http_ctx = NULL;
nb_connections = 0;
start_multicast();
for(;;) {
poll_entry = poll_table;
poll_entry->fd = server_fd;
poll_entry->events = POLLIN;
poll_entry++;
poll_entry->fd = rtsp_server_fd;
poll_entry->events = POLLIN;
poll_entry++;
c = first_http_ctx;
delay = 1000;
while (c != NULL) {
int fd;
fd = c->fd;
switch(c->state) {
case HTTPSTATE_SEND_HEADER:
case RTSPSTATE_SEND_REPLY:
case RTSPSTATE_SEND_PACKET:
c->poll_entry = poll_entry;
poll_entry->fd = fd;
poll_entry->events = POLLOUT;
poll_entry++;
break;
case HTTPSTATE_SEND_DATA_HEADER:
case HTTPSTATE_SEND_DATA:
case HTTPSTATE_SEND_DATA_TRAILER:
if (!c->is_packetized) {
c->poll_entry = poll_entry;
poll_entry->fd = fd;
poll_entry->events = POLLOUT;
poll_entry++;
} else {
delay1 = 10;
if (delay1 < delay)
delay = delay1;
}
break;
case HTTPSTATE_WAIT_REQUEST:
case HTTPSTATE_RECEIVE_DATA:
case HTTPSTATE_WAIT_FEED:
case RTSPSTATE_WAIT_REQUEST:
c->poll_entry = poll_entry;
poll_entry->fd = fd;
poll_entry->events = POLLIN;
poll_entry++;
break;
default:
c->poll_entry = NULL;
break;
}
c = c->next;
}
do {
ret = poll(poll_table, poll_entry - poll_table, delay);
if (ret < 0 && errno != EAGAIN && errno != EINTR)
return -1;
} while (ret <= 0);
cur_time = av_gettime() / 1000;
if (need_to_start_children) {
need_to_start_children = 0;
start_children(first_feed);
}
for(c = first_http_ctx; c != NULL; c = c_next) {
c_next = c->next;
if (handle_connection(c) < 0) {
log_connection(c);
close_connection(c);
}
}
poll_entry = poll_table;
if (poll_entry->revents & POLLIN) {
new_connection(server_fd, 0);
}
poll_entry++;
if (poll_entry->revents & POLLIN) {
new_connection(rtsp_server_fd, 1);
}
}
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(void)
{
int VAR_0, VAR_1, VAR_2, VAR_3, VAR_4;
struct pollfd VAR_5[HTTP_MAX_CONNECTIONS + 2], *poll_entry;
HTTPContext *c, *c_next;
VAR_0 = socket_open_listen(&my_http_addr);
if (VAR_0 < 0)
return -1;
VAR_2 = socket_open_listen(&my_rtsp_addr);
if (VAR_2 < 0)
return -1;
http_log("ffserver started.\n");
start_children(first_feed);
first_http_ctx = NULL;
nb_connections = 0;
start_multicast();
for(;;) {
poll_entry = VAR_5;
poll_entry->VAR_6 = VAR_0;
poll_entry->events = POLLIN;
poll_entry++;
poll_entry->VAR_6 = VAR_2;
poll_entry->events = POLLIN;
poll_entry++;
c = first_http_ctx;
VAR_3 = 1000;
while (c != NULL) {
int VAR_6;
VAR_6 = c->VAR_6;
switch(c->state) {
case HTTPSTATE_SEND_HEADER:
case RTSPSTATE_SEND_REPLY:
case RTSPSTATE_SEND_PACKET:
c->poll_entry = poll_entry;
poll_entry->VAR_6 = VAR_6;
poll_entry->events = POLLOUT;
poll_entry++;
break;
case HTTPSTATE_SEND_DATA_HEADER:
case HTTPSTATE_SEND_DATA:
case HTTPSTATE_SEND_DATA_TRAILER:
if (!c->is_packetized) {
c->poll_entry = poll_entry;
poll_entry->VAR_6 = VAR_6;
poll_entry->events = POLLOUT;
poll_entry++;
} else {
VAR_4 = 10;
if (VAR_4 < VAR_3)
VAR_3 = VAR_4;
}
break;
case HTTPSTATE_WAIT_REQUEST:
case HTTPSTATE_RECEIVE_DATA:
case HTTPSTATE_WAIT_FEED:
case RTSPSTATE_WAIT_REQUEST:
c->poll_entry = poll_entry;
poll_entry->VAR_6 = VAR_6;
poll_entry->events = POLLIN;
poll_entry++;
break;
default:
c->poll_entry = NULL;
break;
}
c = c->next;
}
do {
VAR_1 = poll(VAR_5, poll_entry - VAR_5, VAR_3);
if (VAR_1 < 0 && errno != EAGAIN && errno != EINTR)
return -1;
} while (VAR_1 <= 0);
cur_time = av_gettime() / 1000;
if (need_to_start_children) {
need_to_start_children = 0;
start_children(first_feed);
}
for(c = first_http_ctx; c != NULL; c = c_next) {
c_next = c->next;
if (handle_connection(c) < 0) {
log_connection(c);
close_connection(c);
}
}
poll_entry = VAR_5;
if (poll_entry->revents & POLLIN) {
new_connection(VAR_0, 0);
}
poll_entry++;
if (poll_entry->revents & POLLIN) {
new_connection(VAR_2, 1);
}
}
}
| [
"static int FUNC_0(void)\n{",
"int VAR_0, VAR_1, VAR_2, VAR_3, VAR_4;",
"struct pollfd VAR_5[HTTP_MAX_CONNECTIONS + 2], *poll_entry;",
"HTTPContext *c, *c_next;",
"VAR_0 = socket_open_listen(&my_http_addr);",
"if (VAR_0 < 0)\nreturn -1;",
"VAR_2 = socket_open_listen(&my_rtsp_addr);",
"if (VAR_2 < 0)\nreturn -1;",
"http_log(\"ffserver started.\\n\");",
"start_children(first_feed);",
"first_http_ctx = NULL;",
"nb_connections = 0;",
"start_multicast();",
"for(;;) {",
"poll_entry = VAR_5;",
"poll_entry->VAR_6 = VAR_0;",
"poll_entry->events = POLLIN;",
"poll_entry++;",
"poll_entry->VAR_6 = VAR_2;",
"poll_entry->events = POLLIN;",
"poll_entry++;",
"c = first_http_ctx;",
"VAR_3 = 1000;",
"while (c != NULL) {",
"int VAR_6;",
"VAR_6 = c->VAR_6;",
"switch(c->state) {",
"case HTTPSTATE_SEND_HEADER:\ncase RTSPSTATE_SEND_REPLY:\ncase RTSPSTATE_SEND_PACKET:\nc->poll_entry = poll_entry;",
"poll_entry->VAR_6 = VAR_6;",
"poll_entry->events = POLLOUT;",
"poll_entry++;",
"break;",
"case HTTPSTATE_SEND_DATA_HEADER:\ncase HTTPSTATE_SEND_DATA:\ncase HTTPSTATE_SEND_DATA_TRAILER:\nif (!c->is_packetized) {",
"c->poll_entry = poll_entry;",
"poll_entry->VAR_6 = VAR_6;",
"poll_entry->events = POLLOUT;",
"poll_entry++;",
"} else {",
"VAR_4 = 10;",
"if (VAR_4 < VAR_3)\nVAR_3 = VAR_4;",
"}",
"break;",
"case HTTPSTATE_WAIT_REQUEST:\ncase HTTPSTATE_RECEIVE_DATA:\ncase HTTPSTATE_WAIT_FEED:\ncase RTSPSTATE_WAIT_REQUEST:\nc->poll_entry = poll_entry;",
"poll_entry->VAR_6 = VAR_6;",
"poll_entry->events = POLLIN;",
"poll_entry++;",
"break;",
"default:\nc->poll_entry = NULL;",
"break;",
"}",
"c = c->next;",
"}",
"do {",
"VAR_1 = poll(VAR_5, poll_entry - VAR_5, VAR_3);",
"if (VAR_1 < 0 && errno != EAGAIN && errno != EINTR)\nreturn -1;",
"} while (VAR_1 <= 0);",
"cur_time = av_gettime() / 1000;",
"if (need_to_start_children) {",
"need_to_start_children = 0;",
"start_children(first_feed);",
"}",
"for(c = first_http_ctx; c != NULL; c = c_next) {",
"c_next = c->next;",
"if (handle_connection(c) < 0) {",
"log_connection(c);",
"close_connection(c);",
"}",
"}",
"poll_entry = VAR_5;",
"if (poll_entry->revents & POLLIN) {",
"new_connection(VAR_0, 0);",
"}",
"poll_entry++;",
"if (poll_entry->revents & POLLIN) {",
"new_connection(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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
21
],
[
23,
25
],
[
29
],
[
33
],
[
37
],
[
39
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81,
83,
85,
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97,
99,
101,
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
123
],
[
125,
127
],
[
129
],
[
131
],
[
133,
135,
137,
139,
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153,
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
171
],
[
173
],
[
175,
177
],
[
179
],
[
183
],
[
187
],
[
189
],
[
191
],
[
193
],
[
199
],
[
201
],
[
203
],
[
207
],
[
209
],
[
211
],
[
213
],
[
217
],
[
221
],
[
223
],
[
225
],
[
227
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
]
] |
3,609 | static int h264_field_start(H264Context *h, const H264SliceContext *sl,
const H2645NAL *nal, int first_slice)
{
int i;
const SPS *sps;
int last_pic_structure, last_pic_droppable, ret;
ret = h264_init_ps(h, sl, first_slice);
if (ret < 0)
return ret;
sps = h->ps.sps;
last_pic_droppable = h->droppable;
last_pic_structure = h->picture_structure;
h->droppable = (nal->ref_idc == 0);
h->picture_structure = sl->picture_structure;
h->poc.frame_num = sl->frame_num;
h->poc.poc_lsb = sl->poc_lsb;
h->poc.delta_poc_bottom = sl->delta_poc_bottom;
h->poc.delta_poc[0] = sl->delta_poc[0];
h->poc.delta_poc[1] = sl->delta_poc[1];
/* Shorten frame num gaps so we don't have to allocate reference
* frames just to throw them away */
if (h->poc.frame_num != h->poc.prev_frame_num) {
int unwrap_prev_frame_num = h->poc.prev_frame_num;
int max_frame_num = 1 << sps->log2_max_frame_num;
if (unwrap_prev_frame_num > h->poc.frame_num)
unwrap_prev_frame_num -= max_frame_num;
if ((h->poc.frame_num - unwrap_prev_frame_num) > sps->ref_frame_count) {
unwrap_prev_frame_num = (h->poc.frame_num - sps->ref_frame_count) - 1;
if (unwrap_prev_frame_num < 0)
unwrap_prev_frame_num += max_frame_num;
h->poc.prev_frame_num = unwrap_prev_frame_num;
}
}
/* See if we have a decoded first field looking for a pair...
* Here, we're using that to see if we should mark previously
* decode frames as "finished".
* We have to do that before the "dummy" in-between frame allocation,
* since that can modify h->cur_pic_ptr. */
if (h->first_field) {
av_assert0(h->cur_pic_ptr);
av_assert0(h->cur_pic_ptr->f->buf[0]);
assert(h->cur_pic_ptr->reference != DELAYED_PIC_REF);
/* Mark old field/frame as completed */
if (h->cur_pic_ptr->tf.owner == h->avctx) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
last_pic_structure == PICT_BOTTOM_FIELD);
}
/* figure out if we have a complementary field pair */
if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
/* Previous field is unmatched. Don't display it, but let it
* remain for reference if marked as such. */
if (last_pic_structure != PICT_FRAME) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
last_pic_structure == PICT_TOP_FIELD);
}
} else {
if (h->cur_pic_ptr->frame_num != h->poc.frame_num) {
/* This and previous field were reference, but had
* different frame_nums. Consider this field first in
* pair. Throw away previous field except for reference
* purposes. */
if (last_pic_structure != PICT_FRAME) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
last_pic_structure == PICT_TOP_FIELD);
}
} else {
/* Second field in complementary pair */
if (!((last_pic_structure == PICT_TOP_FIELD &&
h->picture_structure == PICT_BOTTOM_FIELD) ||
(last_pic_structure == PICT_BOTTOM_FIELD &&
h->picture_structure == PICT_TOP_FIELD))) {
av_log(h->avctx, AV_LOG_ERROR,
"Invalid field mode combination %d/%d\n",
last_pic_structure, h->picture_structure);
h->picture_structure = last_pic_structure;
h->droppable = last_pic_droppable;
return AVERROR_INVALIDDATA;
} else if (last_pic_droppable != h->droppable) {
avpriv_request_sample(h->avctx,
"Found reference and non-reference fields in the same frame, which");
h->picture_structure = last_pic_structure;
h->droppable = last_pic_droppable;
return AVERROR_PATCHWELCOME;
}
}
}
}
while (h->poc.frame_num != h->poc.prev_frame_num && !h->first_field &&
h->poc.frame_num != (h->poc.prev_frame_num + 1) % (1 << sps->log2_max_frame_num)) {
H264Picture *prev = h->short_ref_count ? h->short_ref[0] : NULL;
av_log(h->avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n",
h->poc.frame_num, h->poc.prev_frame_num);
if (!sps->gaps_in_frame_num_allowed_flag)
for(i=0; i<FF_ARRAY_ELEMS(h->last_pocs); i++)
h->last_pocs[i] = INT_MIN;
ret = h264_frame_start(h);
if (ret < 0) {
h->first_field = 0;
return ret;
}
h->poc.prev_frame_num++;
h->poc.prev_frame_num %= 1 << sps->log2_max_frame_num;
h->cur_pic_ptr->frame_num = h->poc.prev_frame_num;
h->cur_pic_ptr->invalid_gap = !sps->gaps_in_frame_num_allowed_flag;
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 0);
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 1);
h->explicit_ref_marking = 0;
ret = ff_h264_execute_ref_pic_marking(h);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
return ret;
/* Error concealment: If a ref is missing, copy the previous ref
* in its place.
* FIXME: Avoiding a memcpy would be nice, but ref handling makes
* many assumptions about there being no actual duplicates.
* FIXME: This does not copy padding for out-of-frame motion
* vectors. Given we are concealing a lost frame, this probably
* is not noticeable by comparison, but it should be fixed. */
if (h->short_ref_count) {
if (prev &&
h->short_ref[0]->f->width == prev->f->width &&
h->short_ref[0]->f->height == prev->f->height &&
h->short_ref[0]->f->format == prev->f->format) {
ff_thread_await_progress(&prev->tf, INT_MAX, 0);
if (prev->field_picture)
ff_thread_await_progress(&prev->tf, INT_MAX, 1);
av_image_copy(h->short_ref[0]->f->data,
h->short_ref[0]->f->linesize,
(const uint8_t **)prev->f->data,
prev->f->linesize,
prev->f->format,
prev->f->width,
prev->f->height);
h->short_ref[0]->poc = prev->poc + 2;
}
h->short_ref[0]->frame_num = h->poc.prev_frame_num;
}
}
/* See if we have a decoded first field looking for a pair...
* We're using that to see whether to continue decoding in that
* frame, or to allocate a new one. */
if (h->first_field) {
av_assert0(h->cur_pic_ptr);
av_assert0(h->cur_pic_ptr->f->buf[0]);
assert(h->cur_pic_ptr->reference != DELAYED_PIC_REF);
/* figure out if we have a complementary field pair */
if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
/* Previous field is unmatched. Don't display it, but let it
* remain for reference if marked as such. */
h->missing_fields ++;
h->cur_pic_ptr = NULL;
h->first_field = FIELD_PICTURE(h);
} else {
h->missing_fields = 0;
if (h->cur_pic_ptr->frame_num != h->poc.frame_num) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
h->picture_structure==PICT_BOTTOM_FIELD);
/* This and the previous field had different frame_nums.
* Consider this field first in pair. Throw away previous
* one except for reference purposes. */
h->first_field = 1;
h->cur_pic_ptr = NULL;
} else {
/* Second field in complementary pair */
h->first_field = 0;
}
}
} else {
/* Frame or first field in a potentially complementary pair */
h->first_field = FIELD_PICTURE(h);
}
if (!FIELD_PICTURE(h) || h->first_field) {
if (h264_frame_start(h) < 0) {
h->first_field = 0;
return AVERROR_INVALIDDATA;
}
} else {
release_unused_pictures(h, 0);
}
/* Some macroblocks can be accessed before they're available in case
* of lost slices, MBAFF or threading. */
if (FIELD_PICTURE(h)) {
for(i = (h->picture_structure == PICT_BOTTOM_FIELD); i<h->mb_height; i++)
memset(h->slice_table + i*h->mb_stride, -1, (h->mb_stride - (i+1==h->mb_height)) * sizeof(*h->slice_table));
} else {
memset(h->slice_table, -1,
(h->mb_height * h->mb_stride - 1) * sizeof(*h->slice_table));
}
ff_h264_init_poc(h->cur_pic_ptr->field_poc, &h->cur_pic_ptr->poc,
h->ps.sps, &h->poc, h->picture_structure, nal->ref_idc);
memcpy(h->mmco, sl->mmco, sl->nb_mmco * sizeof(*h->mmco));
h->nb_mmco = sl->nb_mmco;
h->explicit_ref_marking = sl->explicit_ref_marking;
h->picture_idr = nal->type == H264_NAL_IDR_SLICE;
if (h->sei.recovery_point.recovery_frame_cnt >= 0) {
const int sei_recovery_frame_cnt = h->sei.recovery_point.recovery_frame_cnt;
if (h->poc.frame_num != sei_recovery_frame_cnt || sl->slice_type_nos != AV_PICTURE_TYPE_I)
h->valid_recovery_point = 1;
if ( h->recovery_frame < 0
|| av_mod_uintp2(h->recovery_frame - h->poc.frame_num, h->ps.sps->log2_max_frame_num) > sei_recovery_frame_cnt) {
h->recovery_frame = av_mod_uintp2(h->poc.frame_num + sei_recovery_frame_cnt, h->ps.sps->log2_max_frame_num);
if (!h->valid_recovery_point)
h->recovery_frame = h->poc.frame_num;
}
}
h->cur_pic_ptr->f->key_frame |= (nal->type == H264_NAL_IDR_SLICE);
if (nal->type == H264_NAL_IDR_SLICE ||
(h->recovery_frame == h->poc.frame_num && nal->ref_idc)) {
h->recovery_frame = -1;
h->cur_pic_ptr->recovered = 1;
}
// If we have an IDR, all frames after it in decoded order are
// "recovered".
if (nal->type == H264_NAL_IDR_SLICE)
h->frame_recovered |= FRAME_RECOVERED_IDR;
#if 1
h->cur_pic_ptr->recovered |= h->frame_recovered;
#else
h->cur_pic_ptr->recovered |= !!(h->frame_recovered & FRAME_RECOVERED_IDR);
#endif
/* Set the frame properties/side data. Only done for the second field in
* field coded frames, since some SEI information is present for each field
* and is merged by the SEI parsing code. */
if (!FIELD_PICTURE(h) || !h->first_field || h->missing_fields > 1) {
ret = h264_export_frame_props(h);
if (ret < 0)
return ret;
ret = h264_select_output_frame(h);
if (ret < 0)
return ret;
}
return 0;
}
| true | FFmpeg | 083300bea935d125b83f60d7030f78a7ffb0f3df | static int h264_field_start(H264Context *h, const H264SliceContext *sl,
const H2645NAL *nal, int first_slice)
{
int i;
const SPS *sps;
int last_pic_structure, last_pic_droppable, ret;
ret = h264_init_ps(h, sl, first_slice);
if (ret < 0)
return ret;
sps = h->ps.sps;
last_pic_droppable = h->droppable;
last_pic_structure = h->picture_structure;
h->droppable = (nal->ref_idc == 0);
h->picture_structure = sl->picture_structure;
h->poc.frame_num = sl->frame_num;
h->poc.poc_lsb = sl->poc_lsb;
h->poc.delta_poc_bottom = sl->delta_poc_bottom;
h->poc.delta_poc[0] = sl->delta_poc[0];
h->poc.delta_poc[1] = sl->delta_poc[1];
if (h->poc.frame_num != h->poc.prev_frame_num) {
int unwrap_prev_frame_num = h->poc.prev_frame_num;
int max_frame_num = 1 << sps->log2_max_frame_num;
if (unwrap_prev_frame_num > h->poc.frame_num)
unwrap_prev_frame_num -= max_frame_num;
if ((h->poc.frame_num - unwrap_prev_frame_num) > sps->ref_frame_count) {
unwrap_prev_frame_num = (h->poc.frame_num - sps->ref_frame_count) - 1;
if (unwrap_prev_frame_num < 0)
unwrap_prev_frame_num += max_frame_num;
h->poc.prev_frame_num = unwrap_prev_frame_num;
}
}
if (h->first_field) {
av_assert0(h->cur_pic_ptr);
av_assert0(h->cur_pic_ptr->f->buf[0]);
assert(h->cur_pic_ptr->reference != DELAYED_PIC_REF);
if (h->cur_pic_ptr->tf.owner == h->avctx) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
last_pic_structure == PICT_BOTTOM_FIELD);
}
if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
if (last_pic_structure != PICT_FRAME) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
last_pic_structure == PICT_TOP_FIELD);
}
} else {
if (h->cur_pic_ptr->frame_num != h->poc.frame_num) {
if (last_pic_structure != PICT_FRAME) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
last_pic_structure == PICT_TOP_FIELD);
}
} else {
if (!((last_pic_structure == PICT_TOP_FIELD &&
h->picture_structure == PICT_BOTTOM_FIELD) ||
(last_pic_structure == PICT_BOTTOM_FIELD &&
h->picture_structure == PICT_TOP_FIELD))) {
av_log(h->avctx, AV_LOG_ERROR,
"Invalid field mode combination %d/%d\n",
last_pic_structure, h->picture_structure);
h->picture_structure = last_pic_structure;
h->droppable = last_pic_droppable;
return AVERROR_INVALIDDATA;
} else if (last_pic_droppable != h->droppable) {
avpriv_request_sample(h->avctx,
"Found reference and non-reference fields in the same frame, which");
h->picture_structure = last_pic_structure;
h->droppable = last_pic_droppable;
return AVERROR_PATCHWELCOME;
}
}
}
}
while (h->poc.frame_num != h->poc.prev_frame_num && !h->first_field &&
h->poc.frame_num != (h->poc.prev_frame_num + 1) % (1 << sps->log2_max_frame_num)) {
H264Picture *prev = h->short_ref_count ? h->short_ref[0] : NULL;
av_log(h->avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n",
h->poc.frame_num, h->poc.prev_frame_num);
if (!sps->gaps_in_frame_num_allowed_flag)
for(i=0; i<FF_ARRAY_ELEMS(h->last_pocs); i++)
h->last_pocs[i] = INT_MIN;
ret = h264_frame_start(h);
if (ret < 0) {
h->first_field = 0;
return ret;
}
h->poc.prev_frame_num++;
h->poc.prev_frame_num %= 1 << sps->log2_max_frame_num;
h->cur_pic_ptr->frame_num = h->poc.prev_frame_num;
h->cur_pic_ptr->invalid_gap = !sps->gaps_in_frame_num_allowed_flag;
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 0);
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 1);
h->explicit_ref_marking = 0;
ret = ff_h264_execute_ref_pic_marking(h);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
return ret;
if (h->short_ref_count) {
if (prev &&
h->short_ref[0]->f->width == prev->f->width &&
h->short_ref[0]->f->height == prev->f->height &&
h->short_ref[0]->f->format == prev->f->format) {
ff_thread_await_progress(&prev->tf, INT_MAX, 0);
if (prev->field_picture)
ff_thread_await_progress(&prev->tf, INT_MAX, 1);
av_image_copy(h->short_ref[0]->f->data,
h->short_ref[0]->f->linesize,
(const uint8_t **)prev->f->data,
prev->f->linesize,
prev->f->format,
prev->f->width,
prev->f->height);
h->short_ref[0]->poc = prev->poc + 2;
}
h->short_ref[0]->frame_num = h->poc.prev_frame_num;
}
}
if (h->first_field) {
av_assert0(h->cur_pic_ptr);
av_assert0(h->cur_pic_ptr->f->buf[0]);
assert(h->cur_pic_ptr->reference != DELAYED_PIC_REF);
if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
h->missing_fields ++;
h->cur_pic_ptr = NULL;
h->first_field = FIELD_PICTURE(h);
} else {
h->missing_fields = 0;
if (h->cur_pic_ptr->frame_num != h->poc.frame_num) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
h->picture_structure==PICT_BOTTOM_FIELD);
h->first_field = 1;
h->cur_pic_ptr = NULL;
} else {
h->first_field = 0;
}
}
} else {
h->first_field = FIELD_PICTURE(h);
}
if (!FIELD_PICTURE(h) || h->first_field) {
if (h264_frame_start(h) < 0) {
h->first_field = 0;
return AVERROR_INVALIDDATA;
}
} else {
release_unused_pictures(h, 0);
}
if (FIELD_PICTURE(h)) {
for(i = (h->picture_structure == PICT_BOTTOM_FIELD); i<h->mb_height; i++)
memset(h->slice_table + i*h->mb_stride, -1, (h->mb_stride - (i+1==h->mb_height)) * sizeof(*h->slice_table));
} else {
memset(h->slice_table, -1,
(h->mb_height * h->mb_stride - 1) * sizeof(*h->slice_table));
}
ff_h264_init_poc(h->cur_pic_ptr->field_poc, &h->cur_pic_ptr->poc,
h->ps.sps, &h->poc, h->picture_structure, nal->ref_idc);
memcpy(h->mmco, sl->mmco, sl->nb_mmco * sizeof(*h->mmco));
h->nb_mmco = sl->nb_mmco;
h->explicit_ref_marking = sl->explicit_ref_marking;
h->picture_idr = nal->type == H264_NAL_IDR_SLICE;
if (h->sei.recovery_point.recovery_frame_cnt >= 0) {
const int sei_recovery_frame_cnt = h->sei.recovery_point.recovery_frame_cnt;
if (h->poc.frame_num != sei_recovery_frame_cnt || sl->slice_type_nos != AV_PICTURE_TYPE_I)
h->valid_recovery_point = 1;
if ( h->recovery_frame < 0
|| av_mod_uintp2(h->recovery_frame - h->poc.frame_num, h->ps.sps->log2_max_frame_num) > sei_recovery_frame_cnt) {
h->recovery_frame = av_mod_uintp2(h->poc.frame_num + sei_recovery_frame_cnt, h->ps.sps->log2_max_frame_num);
if (!h->valid_recovery_point)
h->recovery_frame = h->poc.frame_num;
}
}
h->cur_pic_ptr->f->key_frame |= (nal->type == H264_NAL_IDR_SLICE);
if (nal->type == H264_NAL_IDR_SLICE ||
(h->recovery_frame == h->poc.frame_num && nal->ref_idc)) {
h->recovery_frame = -1;
h->cur_pic_ptr->recovered = 1;
}
if (nal->type == H264_NAL_IDR_SLICE)
h->frame_recovered |= FRAME_RECOVERED_IDR;
#if 1
h->cur_pic_ptr->recovered |= h->frame_recovered;
#else
h->cur_pic_ptr->recovered |= !!(h->frame_recovered & FRAME_RECOVERED_IDR);
#endif
if (!FIELD_PICTURE(h) || !h->first_field || h->missing_fields > 1) {
ret = h264_export_frame_props(h);
if (ret < 0)
return ret;
ret = h264_select_output_frame(h);
if (ret < 0)
return ret;
}
return 0;
}
| {
"code": [
" if (h->cur_pic_ptr->tf.owner == h->avctx) {",
" ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,",
" last_pic_structure == PICT_BOTTOM_FIELD);"
],
"line_no": [
109,
111,
113
]
} | static int FUNC_0(H264Context *VAR_0, const H264SliceContext *VAR_1,
const H2645NAL *VAR_2, int VAR_3)
{
int VAR_4;
const SPS *VAR_5;
int VAR_6, VAR_7, VAR_8;
VAR_8 = h264_init_ps(VAR_0, VAR_1, VAR_3);
if (VAR_8 < 0)
return VAR_8;
VAR_5 = VAR_0->ps.VAR_5;
VAR_7 = VAR_0->droppable;
VAR_6 = VAR_0->picture_structure;
VAR_0->droppable = (VAR_2->ref_idc == 0);
VAR_0->picture_structure = VAR_1->picture_structure;
VAR_0->poc.frame_num = VAR_1->frame_num;
VAR_0->poc.poc_lsb = VAR_1->poc_lsb;
VAR_0->poc.delta_poc_bottom = VAR_1->delta_poc_bottom;
VAR_0->poc.delta_poc[0] = VAR_1->delta_poc[0];
VAR_0->poc.delta_poc[1] = VAR_1->delta_poc[1];
if (VAR_0->poc.frame_num != VAR_0->poc.prev_frame_num) {
int VAR_9 = VAR_0->poc.prev_frame_num;
int VAR_10 = 1 << VAR_5->log2_max_frame_num;
if (VAR_9 > VAR_0->poc.frame_num)
VAR_9 -= VAR_10;
if ((VAR_0->poc.frame_num - VAR_9) > VAR_5->ref_frame_count) {
VAR_9 = (VAR_0->poc.frame_num - VAR_5->ref_frame_count) - 1;
if (VAR_9 < 0)
VAR_9 += VAR_10;
VAR_0->poc.prev_frame_num = VAR_9;
}
}
if (VAR_0->first_field) {
av_assert0(VAR_0->cur_pic_ptr);
av_assert0(VAR_0->cur_pic_ptr->f->buf[0]);
assert(VAR_0->cur_pic_ptr->reference != DELAYED_PIC_REF);
if (VAR_0->cur_pic_ptr->tf.owner == VAR_0->avctx) {
ff_thread_report_progress(&VAR_0->cur_pic_ptr->tf, INT_MAX,
VAR_6 == PICT_BOTTOM_FIELD);
}
if (!FIELD_PICTURE(VAR_0) || VAR_0->picture_structure == VAR_6) {
if (VAR_6 != PICT_FRAME) {
ff_thread_report_progress(&VAR_0->cur_pic_ptr->tf, INT_MAX,
VAR_6 == PICT_TOP_FIELD);
}
} else {
if (VAR_0->cur_pic_ptr->frame_num != VAR_0->poc.frame_num) {
if (VAR_6 != PICT_FRAME) {
ff_thread_report_progress(&VAR_0->cur_pic_ptr->tf, INT_MAX,
VAR_6 == PICT_TOP_FIELD);
}
} else {
if (!((VAR_6 == PICT_TOP_FIELD &&
VAR_0->picture_structure == PICT_BOTTOM_FIELD) ||
(VAR_6 == PICT_BOTTOM_FIELD &&
VAR_0->picture_structure == PICT_TOP_FIELD))) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Invalid field mode combination %d/%d\n",
VAR_6, VAR_0->picture_structure);
VAR_0->picture_structure = VAR_6;
VAR_0->droppable = VAR_7;
return AVERROR_INVALIDDATA;
} else if (VAR_7 != VAR_0->droppable) {
avpriv_request_sample(VAR_0->avctx,
"Found reference and non-reference fields in the same frame, which");
VAR_0->picture_structure = VAR_6;
VAR_0->droppable = VAR_7;
return AVERROR_PATCHWELCOME;
}
}
}
}
while (VAR_0->poc.frame_num != VAR_0->poc.prev_frame_num && !VAR_0->first_field &&
VAR_0->poc.frame_num != (VAR_0->poc.prev_frame_num + 1) % (1 << VAR_5->log2_max_frame_num)) {
H264Picture *prev = VAR_0->short_ref_count ? VAR_0->short_ref[0] : NULL;
av_log(VAR_0->avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n",
VAR_0->poc.frame_num, VAR_0->poc.prev_frame_num);
if (!VAR_5->gaps_in_frame_num_allowed_flag)
for(VAR_4=0; VAR_4<FF_ARRAY_ELEMS(VAR_0->last_pocs); VAR_4++)
VAR_0->last_pocs[VAR_4] = INT_MIN;
VAR_8 = h264_frame_start(VAR_0);
if (VAR_8 < 0) {
VAR_0->first_field = 0;
return VAR_8;
}
VAR_0->poc.prev_frame_num++;
VAR_0->poc.prev_frame_num %= 1 << VAR_5->log2_max_frame_num;
VAR_0->cur_pic_ptr->frame_num = VAR_0->poc.prev_frame_num;
VAR_0->cur_pic_ptr->invalid_gap = !VAR_5->gaps_in_frame_num_allowed_flag;
ff_thread_report_progress(&VAR_0->cur_pic_ptr->tf, INT_MAX, 0);
ff_thread_report_progress(&VAR_0->cur_pic_ptr->tf, INT_MAX, 1);
VAR_0->explicit_ref_marking = 0;
VAR_8 = ff_h264_execute_ref_pic_marking(VAR_0);
if (VAR_8 < 0 && (VAR_0->avctx->err_recognition & AV_EF_EXPLODE))
return VAR_8;
if (VAR_0->short_ref_count) {
if (prev &&
VAR_0->short_ref[0]->f->width == prev->f->width &&
VAR_0->short_ref[0]->f->height == prev->f->height &&
VAR_0->short_ref[0]->f->format == prev->f->format) {
ff_thread_await_progress(&prev->tf, INT_MAX, 0);
if (prev->field_picture)
ff_thread_await_progress(&prev->tf, INT_MAX, 1);
av_image_copy(VAR_0->short_ref[0]->f->data,
VAR_0->short_ref[0]->f->linesize,
(const uint8_t **)prev->f->data,
prev->f->linesize,
prev->f->format,
prev->f->width,
prev->f->height);
VAR_0->short_ref[0]->poc = prev->poc + 2;
}
VAR_0->short_ref[0]->frame_num = VAR_0->poc.prev_frame_num;
}
}
if (VAR_0->first_field) {
av_assert0(VAR_0->cur_pic_ptr);
av_assert0(VAR_0->cur_pic_ptr->f->buf[0]);
assert(VAR_0->cur_pic_ptr->reference != DELAYED_PIC_REF);
if (!FIELD_PICTURE(VAR_0) || VAR_0->picture_structure == VAR_6) {
VAR_0->missing_fields ++;
VAR_0->cur_pic_ptr = NULL;
VAR_0->first_field = FIELD_PICTURE(VAR_0);
} else {
VAR_0->missing_fields = 0;
if (VAR_0->cur_pic_ptr->frame_num != VAR_0->poc.frame_num) {
ff_thread_report_progress(&VAR_0->cur_pic_ptr->tf, INT_MAX,
VAR_0->picture_structure==PICT_BOTTOM_FIELD);
VAR_0->first_field = 1;
VAR_0->cur_pic_ptr = NULL;
} else {
VAR_0->first_field = 0;
}
}
} else {
VAR_0->first_field = FIELD_PICTURE(VAR_0);
}
if (!FIELD_PICTURE(VAR_0) || VAR_0->first_field) {
if (h264_frame_start(VAR_0) < 0) {
VAR_0->first_field = 0;
return AVERROR_INVALIDDATA;
}
} else {
release_unused_pictures(VAR_0, 0);
}
if (FIELD_PICTURE(VAR_0)) {
for(VAR_4 = (VAR_0->picture_structure == PICT_BOTTOM_FIELD); VAR_4<VAR_0->mb_height; VAR_4++)
memset(VAR_0->slice_table + VAR_4*VAR_0->mb_stride, -1, (VAR_0->mb_stride - (VAR_4+1==VAR_0->mb_height)) * sizeof(*VAR_0->slice_table));
} else {
memset(VAR_0->slice_table, -1,
(VAR_0->mb_height * VAR_0->mb_stride - 1) * sizeof(*VAR_0->slice_table));
}
ff_h264_init_poc(VAR_0->cur_pic_ptr->field_poc, &VAR_0->cur_pic_ptr->poc,
VAR_0->ps.VAR_5, &VAR_0->poc, VAR_0->picture_structure, VAR_2->ref_idc);
memcpy(VAR_0->mmco, VAR_1->mmco, VAR_1->nb_mmco * sizeof(*VAR_0->mmco));
VAR_0->nb_mmco = VAR_1->nb_mmco;
VAR_0->explicit_ref_marking = VAR_1->explicit_ref_marking;
VAR_0->picture_idr = VAR_2->type == H264_NAL_IDR_SLICE;
if (VAR_0->sei.recovery_point.recovery_frame_cnt >= 0) {
const int VAR_11 = VAR_0->sei.recovery_point.recovery_frame_cnt;
if (VAR_0->poc.frame_num != VAR_11 || VAR_1->slice_type_nos != AV_PICTURE_TYPE_I)
VAR_0->valid_recovery_point = 1;
if ( VAR_0->recovery_frame < 0
|| av_mod_uintp2(VAR_0->recovery_frame - VAR_0->poc.frame_num, VAR_0->ps.VAR_5->log2_max_frame_num) > VAR_11) {
VAR_0->recovery_frame = av_mod_uintp2(VAR_0->poc.frame_num + VAR_11, VAR_0->ps.VAR_5->log2_max_frame_num);
if (!VAR_0->valid_recovery_point)
VAR_0->recovery_frame = VAR_0->poc.frame_num;
}
}
VAR_0->cur_pic_ptr->f->key_frame |= (VAR_2->type == H264_NAL_IDR_SLICE);
if (VAR_2->type == H264_NAL_IDR_SLICE ||
(VAR_0->recovery_frame == VAR_0->poc.frame_num && VAR_2->ref_idc)) {
VAR_0->recovery_frame = -1;
VAR_0->cur_pic_ptr->recovered = 1;
}
if (VAR_2->type == H264_NAL_IDR_SLICE)
VAR_0->frame_recovered |= FRAME_RECOVERED_IDR;
#if 1
VAR_0->cur_pic_ptr->recovered |= VAR_0->frame_recovered;
#else
VAR_0->cur_pic_ptr->recovered |= !!(VAR_0->frame_recovered & FRAME_RECOVERED_IDR);
#endif
if (!FIELD_PICTURE(VAR_0) || !VAR_0->first_field || VAR_0->missing_fields > 1) {
VAR_8 = h264_export_frame_props(VAR_0);
if (VAR_8 < 0)
return VAR_8;
VAR_8 = h264_select_output_frame(VAR_0);
if (VAR_8 < 0)
return VAR_8;
}
return 0;
}
| [
"static int FUNC_0(H264Context *VAR_0, const H264SliceContext *VAR_1,\nconst H2645NAL *VAR_2, int VAR_3)\n{",
"int VAR_4;",
"const SPS *VAR_5;",
"int VAR_6, VAR_7, VAR_8;",
"VAR_8 = h264_init_ps(VAR_0, VAR_1, VAR_3);",
"if (VAR_8 < 0)\nreturn VAR_8;",
"VAR_5 = VAR_0->ps.VAR_5;",
"VAR_7 = VAR_0->droppable;",
"VAR_6 = VAR_0->picture_structure;",
"VAR_0->droppable = (VAR_2->ref_idc == 0);",
"VAR_0->picture_structure = VAR_1->picture_structure;",
"VAR_0->poc.frame_num = VAR_1->frame_num;",
"VAR_0->poc.poc_lsb = VAR_1->poc_lsb;",
"VAR_0->poc.delta_poc_bottom = VAR_1->delta_poc_bottom;",
"VAR_0->poc.delta_poc[0] = VAR_1->delta_poc[0];",
"VAR_0->poc.delta_poc[1] = VAR_1->delta_poc[1];",
"if (VAR_0->poc.frame_num != VAR_0->poc.prev_frame_num) {",
"int VAR_9 = VAR_0->poc.prev_frame_num;",
"int VAR_10 = 1 << VAR_5->log2_max_frame_num;",
"if (VAR_9 > VAR_0->poc.frame_num)\nVAR_9 -= VAR_10;",
"if ((VAR_0->poc.frame_num - VAR_9) > VAR_5->ref_frame_count) {",
"VAR_9 = (VAR_0->poc.frame_num - VAR_5->ref_frame_count) - 1;",
"if (VAR_9 < 0)\nVAR_9 += VAR_10;",
"VAR_0->poc.prev_frame_num = VAR_9;",
"}",
"}",
"if (VAR_0->first_field) {",
"av_assert0(VAR_0->cur_pic_ptr);",
"av_assert0(VAR_0->cur_pic_ptr->f->buf[0]);",
"assert(VAR_0->cur_pic_ptr->reference != DELAYED_PIC_REF);",
"if (VAR_0->cur_pic_ptr->tf.owner == VAR_0->avctx) {",
"ff_thread_report_progress(&VAR_0->cur_pic_ptr->tf, INT_MAX,\nVAR_6 == PICT_BOTTOM_FIELD);",
"}",
"if (!FIELD_PICTURE(VAR_0) || VAR_0->picture_structure == VAR_6) {",
"if (VAR_6 != PICT_FRAME) {",
"ff_thread_report_progress(&VAR_0->cur_pic_ptr->tf, INT_MAX,\nVAR_6 == PICT_TOP_FIELD);",
"}",
"} else {",
"if (VAR_0->cur_pic_ptr->frame_num != VAR_0->poc.frame_num) {",
"if (VAR_6 != PICT_FRAME) {",
"ff_thread_report_progress(&VAR_0->cur_pic_ptr->tf, INT_MAX,\nVAR_6 == PICT_TOP_FIELD);",
"}",
"} else {",
"if (!((VAR_6 == PICT_TOP_FIELD &&\nVAR_0->picture_structure == PICT_BOTTOM_FIELD) ||\n(VAR_6 == PICT_BOTTOM_FIELD &&\nVAR_0->picture_structure == PICT_TOP_FIELD))) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Invalid field mode combination %d/%d\\n\",\nVAR_6, VAR_0->picture_structure);",
"VAR_0->picture_structure = VAR_6;",
"VAR_0->droppable = VAR_7;",
"return AVERROR_INVALIDDATA;",
"} else if (VAR_7 != VAR_0->droppable) {",
"avpriv_request_sample(VAR_0->avctx,\n\"Found reference and non-reference fields in the same frame, which\");",
"VAR_0->picture_structure = VAR_6;",
"VAR_0->droppable = VAR_7;",
"return AVERROR_PATCHWELCOME;",
"}",
"}",
"}",
"}",
"while (VAR_0->poc.frame_num != VAR_0->poc.prev_frame_num && !VAR_0->first_field &&\nVAR_0->poc.frame_num != (VAR_0->poc.prev_frame_num + 1) % (1 << VAR_5->log2_max_frame_num)) {",
"H264Picture *prev = VAR_0->short_ref_count ? VAR_0->short_ref[0] : NULL;",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Frame num gap %d %d\\n\",\nVAR_0->poc.frame_num, VAR_0->poc.prev_frame_num);",
"if (!VAR_5->gaps_in_frame_num_allowed_flag)\nfor(VAR_4=0; VAR_4<FF_ARRAY_ELEMS(VAR_0->last_pocs); VAR_4++)",
"VAR_0->last_pocs[VAR_4] = INT_MIN;",
"VAR_8 = h264_frame_start(VAR_0);",
"if (VAR_8 < 0) {",
"VAR_0->first_field = 0;",
"return VAR_8;",
"}",
"VAR_0->poc.prev_frame_num++;",
"VAR_0->poc.prev_frame_num %= 1 << VAR_5->log2_max_frame_num;",
"VAR_0->cur_pic_ptr->frame_num = VAR_0->poc.prev_frame_num;",
"VAR_0->cur_pic_ptr->invalid_gap = !VAR_5->gaps_in_frame_num_allowed_flag;",
"ff_thread_report_progress(&VAR_0->cur_pic_ptr->tf, INT_MAX, 0);",
"ff_thread_report_progress(&VAR_0->cur_pic_ptr->tf, INT_MAX, 1);",
"VAR_0->explicit_ref_marking = 0;",
"VAR_8 = ff_h264_execute_ref_pic_marking(VAR_0);",
"if (VAR_8 < 0 && (VAR_0->avctx->err_recognition & AV_EF_EXPLODE))\nreturn VAR_8;",
"if (VAR_0->short_ref_count) {",
"if (prev &&\nVAR_0->short_ref[0]->f->width == prev->f->width &&\nVAR_0->short_ref[0]->f->height == prev->f->height &&\nVAR_0->short_ref[0]->f->format == prev->f->format) {",
"ff_thread_await_progress(&prev->tf, INT_MAX, 0);",
"if (prev->field_picture)\nff_thread_await_progress(&prev->tf, INT_MAX, 1);",
"av_image_copy(VAR_0->short_ref[0]->f->data,\nVAR_0->short_ref[0]->f->linesize,\n(const uint8_t **)prev->f->data,\nprev->f->linesize,\nprev->f->format,\nprev->f->width,\nprev->f->height);",
"VAR_0->short_ref[0]->poc = prev->poc + 2;",
"}",
"VAR_0->short_ref[0]->frame_num = VAR_0->poc.prev_frame_num;",
"}",
"}",
"if (VAR_0->first_field) {",
"av_assert0(VAR_0->cur_pic_ptr);",
"av_assert0(VAR_0->cur_pic_ptr->f->buf[0]);",
"assert(VAR_0->cur_pic_ptr->reference != DELAYED_PIC_REF);",
"if (!FIELD_PICTURE(VAR_0) || VAR_0->picture_structure == VAR_6) {",
"VAR_0->missing_fields ++;",
"VAR_0->cur_pic_ptr = NULL;",
"VAR_0->first_field = FIELD_PICTURE(VAR_0);",
"} else {",
"VAR_0->missing_fields = 0;",
"if (VAR_0->cur_pic_ptr->frame_num != VAR_0->poc.frame_num) {",
"ff_thread_report_progress(&VAR_0->cur_pic_ptr->tf, INT_MAX,\nVAR_0->picture_structure==PICT_BOTTOM_FIELD);",
"VAR_0->first_field = 1;",
"VAR_0->cur_pic_ptr = NULL;",
"} else {",
"VAR_0->first_field = 0;",
"}",
"}",
"} else {",
"VAR_0->first_field = FIELD_PICTURE(VAR_0);",
"}",
"if (!FIELD_PICTURE(VAR_0) || VAR_0->first_field) {",
"if (h264_frame_start(VAR_0) < 0) {",
"VAR_0->first_field = 0;",
"return AVERROR_INVALIDDATA;",
"}",
"} else {",
"release_unused_pictures(VAR_0, 0);",
"}",
"if (FIELD_PICTURE(VAR_0)) {",
"for(VAR_4 = (VAR_0->picture_structure == PICT_BOTTOM_FIELD); VAR_4<VAR_0->mb_height; VAR_4++)",
"memset(VAR_0->slice_table + VAR_4*VAR_0->mb_stride, -1, (VAR_0->mb_stride - (VAR_4+1==VAR_0->mb_height)) * sizeof(*VAR_0->slice_table));",
"} else {",
"memset(VAR_0->slice_table, -1,\n(VAR_0->mb_height * VAR_0->mb_stride - 1) * sizeof(*VAR_0->slice_table));",
"}",
"ff_h264_init_poc(VAR_0->cur_pic_ptr->field_poc, &VAR_0->cur_pic_ptr->poc,\nVAR_0->ps.VAR_5, &VAR_0->poc, VAR_0->picture_structure, VAR_2->ref_idc);",
"memcpy(VAR_0->mmco, VAR_1->mmco, VAR_1->nb_mmco * sizeof(*VAR_0->mmco));",
"VAR_0->nb_mmco = VAR_1->nb_mmco;",
"VAR_0->explicit_ref_marking = VAR_1->explicit_ref_marking;",
"VAR_0->picture_idr = VAR_2->type == H264_NAL_IDR_SLICE;",
"if (VAR_0->sei.recovery_point.recovery_frame_cnt >= 0) {",
"const int VAR_11 = VAR_0->sei.recovery_point.recovery_frame_cnt;",
"if (VAR_0->poc.frame_num != VAR_11 || VAR_1->slice_type_nos != AV_PICTURE_TYPE_I)\nVAR_0->valid_recovery_point = 1;",
"if ( VAR_0->recovery_frame < 0\n|| av_mod_uintp2(VAR_0->recovery_frame - VAR_0->poc.frame_num, VAR_0->ps.VAR_5->log2_max_frame_num) > VAR_11) {",
"VAR_0->recovery_frame = av_mod_uintp2(VAR_0->poc.frame_num + VAR_11, VAR_0->ps.VAR_5->log2_max_frame_num);",
"if (!VAR_0->valid_recovery_point)\nVAR_0->recovery_frame = VAR_0->poc.frame_num;",
"}",
"}",
"VAR_0->cur_pic_ptr->f->key_frame |= (VAR_2->type == H264_NAL_IDR_SLICE);",
"if (VAR_2->type == H264_NAL_IDR_SLICE ||\n(VAR_0->recovery_frame == VAR_0->poc.frame_num && VAR_2->ref_idc)) {",
"VAR_0->recovery_frame = -1;",
"VAR_0->cur_pic_ptr->recovered = 1;",
"}",
"if (VAR_2->type == H264_NAL_IDR_SLICE)\nVAR_0->frame_recovered |= FRAME_RECOVERED_IDR;",
"#if 1\nVAR_0->cur_pic_ptr->recovered |= VAR_0->frame_recovered;",
"#else\nVAR_0->cur_pic_ptr->recovered |= !!(VAR_0->frame_recovered & FRAME_RECOVERED_IDR);",
"#endif\nif (!FIELD_PICTURE(VAR_0) || !VAR_0->first_field || VAR_0->missing_fields > 1) {",
"VAR_8 = h264_export_frame_props(VAR_0);",
"if (VAR_8 < 0)\nreturn VAR_8;",
"VAR_8 = h264_select_output_frame(VAR_0);",
"if (VAR_8 < 0)\nreturn VAR_8;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19,
21
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
55
],
[
57
],
[
59
],
[
63,
65
],
[
69
],
[
71
],
[
73,
75
],
[
79
],
[
81
],
[
83
],
[
97
],
[
99
],
[
101
],
[
103
],
[
109
],
[
111,
113
],
[
115
],
[
121
],
[
127
],
[
129,
131
],
[
133
],
[
135
],
[
137
],
[
147
],
[
149,
151
],
[
153
],
[
155
],
[
159,
161,
163,
165
],
[
167,
169,
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181,
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
201,
203
],
[
205
],
[
207,
209
],
[
211,
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
243
],
[
245
],
[
247,
249
],
[
265
],
[
267,
269,
271,
273
],
[
275
],
[
277,
279
],
[
281,
283,
285,
287,
289,
291,
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
313
],
[
315
],
[
317
],
[
319
],
[
325
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343,
345
],
[
353
],
[
355
],
[
357
],
[
361
],
[
363
],
[
365
],
[
367
],
[
371
],
[
373
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405,
407
],
[
409
],
[
413,
415
],
[
419
],
[
421
],
[
423
],
[
427
],
[
431
],
[
433
],
[
437,
439
],
[
443,
445
],
[
447
],
[
451,
453
],
[
455
],
[
457
],
[
461
],
[
465,
467
],
[
469
],
[
471
],
[
473
],
[
479,
481
],
[
483,
485
],
[
487,
489
],
[
491,
501
],
[
503
],
[
505,
507
],
[
511
],
[
513,
515
],
[
517
],
[
521
],
[
523
]
] |
3,612 | void fork_start(void)
{
mmap_fork_start();
qemu_mutex_lock(&tb_ctx.tb_lock);
cpu_list_lock();
} | true | qemu | 06065c451f10c7ef62cfb575a87f323a70ae1c9e | void fork_start(void)
{
mmap_fork_start();
qemu_mutex_lock(&tb_ctx.tb_lock);
cpu_list_lock();
} | {
"code": [],
"line_no": []
} | void FUNC_0(void)
{
mmap_fork_start();
qemu_mutex_lock(&tb_ctx.tb_lock);
cpu_list_lock();
} | [
"void FUNC_0(void)\n{",
"mmap_fork_start();",
"qemu_mutex_lock(&tb_ctx.tb_lock);",
"cpu_list_lock();",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
6
],
[
8
],
[
10
],
[
12
]
] |
3,613 | static int config_output(AVFilterLink *outlink)
{
AVFilterContext *ctx = outlink->src;
LIBVMAFContext *s = ctx->priv;
AVFilterLink *mainlink = ctx->inputs[0];
int ret;
outlink->w = mainlink->w;
outlink->h = mainlink->h;
outlink->time_base = mainlink->time_base;
outlink->sample_aspect_ratio = mainlink->sample_aspect_ratio;
outlink->frame_rate = mainlink->frame_rate;
if ((ret = ff_dualinput_init(ctx, &s->dinput)) < 0)
return ret;
return 0;
}
| true | FFmpeg | a8ab52fae7286d4e7eec9256a08b6ad0b1e39d6c | static int config_output(AVFilterLink *outlink)
{
AVFilterContext *ctx = outlink->src;
LIBVMAFContext *s = ctx->priv;
AVFilterLink *mainlink = ctx->inputs[0];
int ret;
outlink->w = mainlink->w;
outlink->h = mainlink->h;
outlink->time_base = mainlink->time_base;
outlink->sample_aspect_ratio = mainlink->sample_aspect_ratio;
outlink->frame_rate = mainlink->frame_rate;
if ((ret = ff_dualinput_init(ctx, &s->dinput)) < 0)
return ret;
return 0;
}
| {
"code": [
" if ((ret = ff_dualinput_init(ctx, &s->dinput)) < 0)"
],
"line_no": [
25
]
} | static int FUNC_0(AVFilterLink *VAR_0)
{
AVFilterContext *ctx = VAR_0->src;
LIBVMAFContext *s = ctx->priv;
AVFilterLink *mainlink = ctx->inputs[0];
int VAR_1;
VAR_0->w = mainlink->w;
VAR_0->h = mainlink->h;
VAR_0->time_base = mainlink->time_base;
VAR_0->sample_aspect_ratio = mainlink->sample_aspect_ratio;
VAR_0->frame_rate = mainlink->frame_rate;
if ((VAR_1 = ff_dualinput_init(ctx, &s->dinput)) < 0)
return VAR_1;
return 0;
}
| [
"static int FUNC_0(AVFilterLink *VAR_0)\n{",
"AVFilterContext *ctx = VAR_0->src;",
"LIBVMAFContext *s = ctx->priv;",
"AVFilterLink *mainlink = ctx->inputs[0];",
"int VAR_1;",
"VAR_0->w = mainlink->w;",
"VAR_0->h = mainlink->h;",
"VAR_0->time_base = mainlink->time_base;",
"VAR_0->sample_aspect_ratio = mainlink->sample_aspect_ratio;",
"VAR_0->frame_rate = mainlink->frame_rate;",
"if ((VAR_1 = ff_dualinput_init(ctx, &s->dinput)) < 0)\nreturn VAR_1;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
31
],
[
33
]
] |
3,614 | void h263_encode_mb(MpegEncContext * s,
DCTELEM block[6][64],
int motion_x, int motion_y)
{
int cbpc, cbpy, i, cbp, pred_x, pred_y;
// printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y);
if (!s->mb_intra) {
/* compute cbp */
cbp = 0;
for (i = 0; i < 6; i++) {
if (s->block_last_index[i] >= 0)
cbp |= 1 << (5 - i);
}
if ((cbp | motion_x | motion_y) == 0) {
/* skip macroblock */
put_bits(&s->pb, 1, 1);
return;
}
put_bits(&s->pb, 1, 0); /* mb coded */
cbpc = cbp & 3;
put_bits(&s->pb,
inter_MCBPC_bits[cbpc],
inter_MCBPC_code[cbpc]);
cbpy = cbp >> 2;
cbpy ^= 0xf;
put_bits(&s->pb, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]);
/* motion vectors: 16x16 mode only now */
h263_pred_motion(s, 0, &pred_x, &pred_y);
if (!umvplus) {
h263_encode_motion(s, motion_x - pred_x);
h263_encode_motion(s, motion_y - pred_y);
}
else {
h263p_encode_umotion(s, motion_x - pred_x);
h263p_encode_umotion(s, motion_y - pred_y);
if (((motion_x - pred_x) == 1) && ((motion_y - pred_y) == 1))
/* To prevent Start Code emulation */
put_bits(&s->pb,1,1);
}
} else {
/* compute cbp */
cbp = 0;
for (i = 0; i < 6; i++) {
if (s->block_last_index[i] >= 1)
cbp |= 1 << (5 - i);
}
cbpc = cbp & 3;
if (s->pict_type == I_TYPE) {
put_bits(&s->pb,
intra_MCBPC_bits[cbpc],
intra_MCBPC_code[cbpc]);
} else {
put_bits(&s->pb, 1, 0); /* mb coded */
put_bits(&s->pb,
inter_MCBPC_bits[cbpc + 4],
inter_MCBPC_code[cbpc + 4]);
}
if (s->h263_pred) {
/* XXX: currently, we do not try to use ac prediction */
put_bits(&s->pb, 1, 0); /* no ac prediction */
}
cbpy = cbp >> 2;
put_bits(&s->pb, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]);
}
/* encode each block */
if (s->h263_pred) {
for (i = 0; i < 6; i++) {
mpeg4_encode_block(s, block[i], i);
}
} else {
for (i = 0; i < 6; i++) {
h263_encode_block(s, block[i], i);
}
}
}
| true | FFmpeg | 544286b3d39365b30298ae07e66a755200b0895c | void h263_encode_mb(MpegEncContext * s,
DCTELEM block[6][64],
int motion_x, int motion_y)
{
int cbpc, cbpy, i, cbp, pred_x, pred_y;
if (!s->mb_intra) {
cbp = 0;
for (i = 0; i < 6; i++) {
if (s->block_last_index[i] >= 0)
cbp |= 1 << (5 - i);
}
if ((cbp | motion_x | motion_y) == 0) {
put_bits(&s->pb, 1, 1);
return;
}
put_bits(&s->pb, 1, 0);
cbpc = cbp & 3;
put_bits(&s->pb,
inter_MCBPC_bits[cbpc],
inter_MCBPC_code[cbpc]);
cbpy = cbp >> 2;
cbpy ^= 0xf;
put_bits(&s->pb, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]);
h263_pred_motion(s, 0, &pred_x, &pred_y);
if (!umvplus) {
h263_encode_motion(s, motion_x - pred_x);
h263_encode_motion(s, motion_y - pred_y);
}
else {
h263p_encode_umotion(s, motion_x - pred_x);
h263p_encode_umotion(s, motion_y - pred_y);
if (((motion_x - pred_x) == 1) && ((motion_y - pred_y) == 1))
put_bits(&s->pb,1,1);
}
} else {
cbp = 0;
for (i = 0; i < 6; i++) {
if (s->block_last_index[i] >= 1)
cbp |= 1 << (5 - i);
}
cbpc = cbp & 3;
if (s->pict_type == I_TYPE) {
put_bits(&s->pb,
intra_MCBPC_bits[cbpc],
intra_MCBPC_code[cbpc]);
} else {
put_bits(&s->pb, 1, 0);
put_bits(&s->pb,
inter_MCBPC_bits[cbpc + 4],
inter_MCBPC_code[cbpc + 4]);
}
if (s->h263_pred) {
put_bits(&s->pb, 1, 0);
}
cbpy = cbp >> 2;
put_bits(&s->pb, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]);
}
if (s->h263_pred) {
for (i = 0; i < 6; i++) {
mpeg4_encode_block(s, block[i], i);
}
} else {
for (i = 0; i < 6; i++) {
h263_encode_block(s, block[i], i);
}
}
}
| {
"code": [
" if (!umvplus) { "
],
"line_no": [
63
]
} | void FUNC_0(MpegEncContext * VAR_0,
DCTELEM VAR_1[6][64],
int VAR_2, int VAR_3)
{
int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;
if (!VAR_0->mb_intra) {
VAR_7 = 0;
for (VAR_6 = 0; VAR_6 < 6; VAR_6++) {
if (VAR_0->block_last_index[VAR_6] >= 0)
VAR_7 |= 1 << (5 - VAR_6);
}
if ((VAR_7 | VAR_2 | VAR_3) == 0) {
put_bits(&VAR_0->pb, 1, 1);
return;
}
put_bits(&VAR_0->pb, 1, 0);
VAR_4 = VAR_7 & 3;
put_bits(&VAR_0->pb,
inter_MCBPC_bits[VAR_4],
inter_MCBPC_code[VAR_4]);
VAR_5 = VAR_7 >> 2;
VAR_5 ^= 0xf;
put_bits(&VAR_0->pb, cbpy_tab[VAR_5][1], cbpy_tab[VAR_5][0]);
h263_pred_motion(VAR_0, 0, &VAR_8, &VAR_9);
if (!umvplus) {
h263_encode_motion(VAR_0, VAR_2 - VAR_8);
h263_encode_motion(VAR_0, VAR_3 - VAR_9);
}
else {
h263p_encode_umotion(VAR_0, VAR_2 - VAR_8);
h263p_encode_umotion(VAR_0, VAR_3 - VAR_9);
if (((VAR_2 - VAR_8) == 1) && ((VAR_3 - VAR_9) == 1))
put_bits(&VAR_0->pb,1,1);
}
} else {
VAR_7 = 0;
for (VAR_6 = 0; VAR_6 < 6; VAR_6++) {
if (VAR_0->block_last_index[VAR_6] >= 1)
VAR_7 |= 1 << (5 - VAR_6);
}
VAR_4 = VAR_7 & 3;
if (VAR_0->pict_type == I_TYPE) {
put_bits(&VAR_0->pb,
intra_MCBPC_bits[VAR_4],
intra_MCBPC_code[VAR_4]);
} else {
put_bits(&VAR_0->pb, 1, 0);
put_bits(&VAR_0->pb,
inter_MCBPC_bits[VAR_4 + 4],
inter_MCBPC_code[VAR_4 + 4]);
}
if (VAR_0->h263_pred) {
put_bits(&VAR_0->pb, 1, 0);
}
VAR_5 = VAR_7 >> 2;
put_bits(&VAR_0->pb, cbpy_tab[VAR_5][1], cbpy_tab[VAR_5][0]);
}
if (VAR_0->h263_pred) {
for (VAR_6 = 0; VAR_6 < 6; VAR_6++) {
mpeg4_encode_block(VAR_0, VAR_1[VAR_6], VAR_6);
}
} else {
for (VAR_6 = 0; VAR_6 < 6; VAR_6++) {
h263_encode_block(VAR_0, VAR_1[VAR_6], VAR_6);
}
}
}
| [
"void FUNC_0(MpegEncContext * VAR_0,\nDCTELEM VAR_1[6][64],\nint VAR_2, int VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;",
"if (!VAR_0->mb_intra) {",
"VAR_7 = 0;",
"for (VAR_6 = 0; VAR_6 < 6; VAR_6++) {",
"if (VAR_0->block_last_index[VAR_6] >= 0)\nVAR_7 |= 1 << (5 - VAR_6);",
"}",
"if ((VAR_7 | VAR_2 | VAR_3) == 0) {",
"put_bits(&VAR_0->pb, 1, 1);",
"return;",
"}",
"put_bits(&VAR_0->pb, 1, 0);",
"VAR_4 = VAR_7 & 3;",
"put_bits(&VAR_0->pb,\ninter_MCBPC_bits[VAR_4],\ninter_MCBPC_code[VAR_4]);",
"VAR_5 = VAR_7 >> 2;",
"VAR_5 ^= 0xf;",
"put_bits(&VAR_0->pb, cbpy_tab[VAR_5][1], cbpy_tab[VAR_5][0]);",
"h263_pred_motion(VAR_0, 0, &VAR_8, &VAR_9);",
"if (!umvplus) {",
"h263_encode_motion(VAR_0, VAR_2 - VAR_8);",
"h263_encode_motion(VAR_0, VAR_3 - VAR_9);",
"}",
"else {",
"h263p_encode_umotion(VAR_0, VAR_2 - VAR_8);",
"h263p_encode_umotion(VAR_0, VAR_3 - VAR_9);",
"if (((VAR_2 - VAR_8) == 1) && ((VAR_3 - VAR_9) == 1))\nput_bits(&VAR_0->pb,1,1);",
"}",
"} else {",
"VAR_7 = 0;",
"for (VAR_6 = 0; VAR_6 < 6; VAR_6++) {",
"if (VAR_0->block_last_index[VAR_6] >= 1)\nVAR_7 |= 1 << (5 - VAR_6);",
"}",
"VAR_4 = VAR_7 & 3;",
"if (VAR_0->pict_type == I_TYPE) {",
"put_bits(&VAR_0->pb,\nintra_MCBPC_bits[VAR_4],\nintra_MCBPC_code[VAR_4]);",
"} else {",
"put_bits(&VAR_0->pb, 1, 0);",
"put_bits(&VAR_0->pb,\ninter_MCBPC_bits[VAR_4 + 4],\ninter_MCBPC_code[VAR_4 + 4]);",
"}",
"if (VAR_0->h263_pred) {",
"put_bits(&VAR_0->pb, 1, 0);",
"}",
"VAR_5 = VAR_7 >> 2;",
"put_bits(&VAR_0->pb, cbpy_tab[VAR_5][1], cbpy_tab[VAR_5][0]);",
"}",
"if (VAR_0->h263_pred) {",
"for (VAR_6 = 0; VAR_6 < 6; VAR_6++) {",
"mpeg4_encode_block(VAR_0, VAR_1[VAR_6], VAR_6);",
"}",
"} else {",
"for (VAR_6 = 0; VAR_6 < 6; VAR_6++) {",
"h263_encode_block(VAR_0, VAR_1[VAR_6], VAR_6);",
"}",
"}",
"}"
] | [
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
] | [
[
1,
3,
5,
7
],
[
9
],
[
15
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45,
47
],
[
49
],
[
51
],
[
53
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93,
95
],
[
97
],
[
101
],
[
103
],
[
105,
107,
109
],
[
111
],
[
113
],
[
115,
117,
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
]
] |
3,615 | static int decode_band(IVI5DecContext *ctx, int plane_num,
IVIBandDesc *band, AVCodecContext *avctx)
{
int result, i, t, idx1, idx2;
IVITile *tile;
band->buf = band->bufs[ctx->dst_buf];
band->ref_buf = band->bufs[ctx->ref_buf];
band->data_ptr = ctx->frame_data + (get_bits_count(&ctx->gb) >> 3);
result = decode_band_hdr(ctx, band, avctx);
if (result) {
av_log(avctx, AV_LOG_ERROR, "Error while decoding band header: %d\n",
result);
return -1;
}
if (band->is_empty) {
av_log(avctx, AV_LOG_ERROR, "Empty band encountered!\n");
return -1;
}
band->rv_map = &ctx->rvmap_tabs[band->rvmap_sel];
/* apply corrections to the selected rvmap table if present */
for (i = 0; i < band->num_corr; i++) {
idx1 = band->corr[i*2];
idx2 = band->corr[i*2+1];
FFSWAP(uint8_t, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]);
FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]);
}
for (t = 0; t < band->num_tiles; t++) {
tile = &band->tiles[t];
tile->is_empty = get_bits1(&ctx->gb);
if (tile->is_empty) {
ff_ivi_process_empty_tile(avctx, band, tile,
(ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3));
align_get_bits(&ctx->gb);
} else {
tile->data_size = ff_ivi_dec_tile_data_size(&ctx->gb);
result = decode_mb_info(ctx, band, tile, avctx);
if (result < 0)
break;
if (band->blk_size == 8) {
band->intra_base = &ivi5_base_quant_8x8_intra[band->quant_mat][0];
band->inter_base = &ivi5_base_quant_8x8_inter[band->quant_mat][0];
band->intra_scale = &ivi5_scale_quant_8x8_intra[band->quant_mat][0];
band->inter_scale = &ivi5_scale_quant_8x8_inter[band->quant_mat][0];
} else {
band->intra_base = ivi5_base_quant_4x4_intra;
band->inter_base = ivi5_base_quant_4x4_inter;
band->intra_scale = ivi5_scale_quant_4x4_intra;
band->inter_scale = ivi5_scale_quant_4x4_inter;
}
result = ff_ivi_decode_blocks(&ctx->gb, band, tile);
if (result < 0) {
av_log(avctx, AV_LOG_ERROR, "Corrupted blocks data encountered!\n");
break;
}
}
}
/* restore the selected rvmap table by applying its corrections in reverse order */
for (i = band->num_corr-1; i >= 0; i--) {
idx1 = band->corr[i*2];
idx2 = band->corr[i*2+1];
FFSWAP(uint8_t, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]);
FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]);
}
#if IVI_DEBUG
if (band->checksum_present) {
uint16_t chksum = ivi_calc_band_checksum(band);
if (chksum != band->checksum) {
av_log(avctx, AV_LOG_ERROR,
"Band checksum mismatch! Plane %d, band %d, received: %x, calculated: %x\n",
band->plane, band->band_num, band->checksum, chksum);
}
}
#endif
return result;
}
| false | FFmpeg | 7fcb98a7ec51123ecfd810a167d96f128eed9b79 | static int decode_band(IVI5DecContext *ctx, int plane_num,
IVIBandDesc *band, AVCodecContext *avctx)
{
int result, i, t, idx1, idx2;
IVITile *tile;
band->buf = band->bufs[ctx->dst_buf];
band->ref_buf = band->bufs[ctx->ref_buf];
band->data_ptr = ctx->frame_data + (get_bits_count(&ctx->gb) >> 3);
result = decode_band_hdr(ctx, band, avctx);
if (result) {
av_log(avctx, AV_LOG_ERROR, "Error while decoding band header: %d\n",
result);
return -1;
}
if (band->is_empty) {
av_log(avctx, AV_LOG_ERROR, "Empty band encountered!\n");
return -1;
}
band->rv_map = &ctx->rvmap_tabs[band->rvmap_sel];
for (i = 0; i < band->num_corr; i++) {
idx1 = band->corr[i*2];
idx2 = band->corr[i*2+1];
FFSWAP(uint8_t, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]);
FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]);
}
for (t = 0; t < band->num_tiles; t++) {
tile = &band->tiles[t];
tile->is_empty = get_bits1(&ctx->gb);
if (tile->is_empty) {
ff_ivi_process_empty_tile(avctx, band, tile,
(ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3));
align_get_bits(&ctx->gb);
} else {
tile->data_size = ff_ivi_dec_tile_data_size(&ctx->gb);
result = decode_mb_info(ctx, band, tile, avctx);
if (result < 0)
break;
if (band->blk_size == 8) {
band->intra_base = &ivi5_base_quant_8x8_intra[band->quant_mat][0];
band->inter_base = &ivi5_base_quant_8x8_inter[band->quant_mat][0];
band->intra_scale = &ivi5_scale_quant_8x8_intra[band->quant_mat][0];
band->inter_scale = &ivi5_scale_quant_8x8_inter[band->quant_mat][0];
} else {
band->intra_base = ivi5_base_quant_4x4_intra;
band->inter_base = ivi5_base_quant_4x4_inter;
band->intra_scale = ivi5_scale_quant_4x4_intra;
band->inter_scale = ivi5_scale_quant_4x4_inter;
}
result = ff_ivi_decode_blocks(&ctx->gb, band, tile);
if (result < 0) {
av_log(avctx, AV_LOG_ERROR, "Corrupted blocks data encountered!\n");
break;
}
}
}
for (i = band->num_corr-1; i >= 0; i--) {
idx1 = band->corr[i*2];
idx2 = band->corr[i*2+1];
FFSWAP(uint8_t, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]);
FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]);
}
#if IVI_DEBUG
if (band->checksum_present) {
uint16_t chksum = ivi_calc_band_checksum(band);
if (chksum != band->checksum) {
av_log(avctx, AV_LOG_ERROR,
"Band checksum mismatch! Plane %d, band %d, received: %x, calculated: %x\n",
band->plane, band->band_num, band->checksum, chksum);
}
}
#endif
return result;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(IVI5DecContext *VAR_0, int VAR_1,
IVIBandDesc *VAR_2, AVCodecContext *VAR_3)
{
int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;
IVITile *tile;
VAR_2->buf = VAR_2->bufs[VAR_0->dst_buf];
VAR_2->ref_buf = VAR_2->bufs[VAR_0->ref_buf];
VAR_2->data_ptr = VAR_0->frame_data + (get_bits_count(&VAR_0->gb) >> 3);
VAR_4 = decode_band_hdr(VAR_0, VAR_2, VAR_3);
if (VAR_4) {
av_log(VAR_3, AV_LOG_ERROR, "Error while decoding VAR_2 header: %d\n",
VAR_4);
return -1;
}
if (VAR_2->is_empty) {
av_log(VAR_3, AV_LOG_ERROR, "Empty VAR_2 encountered!\n");
return -1;
}
VAR_2->rv_map = &VAR_0->rvmap_tabs[VAR_2->rvmap_sel];
for (VAR_5 = 0; VAR_5 < VAR_2->num_corr; VAR_5++) {
VAR_7 = VAR_2->corr[VAR_5*2];
VAR_8 = VAR_2->corr[VAR_5*2+1];
FFSWAP(uint8_t, VAR_2->rv_map->runtab[VAR_7], VAR_2->rv_map->runtab[VAR_8]);
FFSWAP(int16_t, VAR_2->rv_map->valtab[VAR_7], VAR_2->rv_map->valtab[VAR_8]);
}
for (VAR_6 = 0; VAR_6 < VAR_2->num_tiles; VAR_6++) {
tile = &VAR_2->tiles[VAR_6];
tile->is_empty = get_bits1(&VAR_0->gb);
if (tile->is_empty) {
ff_ivi_process_empty_tile(VAR_3, VAR_2, tile,
(VAR_0->planes[0].bands[0].mb_size >> 3) - (VAR_2->mb_size >> 3));
align_get_bits(&VAR_0->gb);
} else {
tile->data_size = ff_ivi_dec_tile_data_size(&VAR_0->gb);
VAR_4 = decode_mb_info(VAR_0, VAR_2, tile, VAR_3);
if (VAR_4 < 0)
break;
if (VAR_2->blk_size == 8) {
VAR_2->intra_base = &ivi5_base_quant_8x8_intra[VAR_2->quant_mat][0];
VAR_2->inter_base = &ivi5_base_quant_8x8_inter[VAR_2->quant_mat][0];
VAR_2->intra_scale = &ivi5_scale_quant_8x8_intra[VAR_2->quant_mat][0];
VAR_2->inter_scale = &ivi5_scale_quant_8x8_inter[VAR_2->quant_mat][0];
} else {
VAR_2->intra_base = ivi5_base_quant_4x4_intra;
VAR_2->inter_base = ivi5_base_quant_4x4_inter;
VAR_2->intra_scale = ivi5_scale_quant_4x4_intra;
VAR_2->inter_scale = ivi5_scale_quant_4x4_inter;
}
VAR_4 = ff_ivi_decode_blocks(&VAR_0->gb, VAR_2, tile);
if (VAR_4 < 0) {
av_log(VAR_3, AV_LOG_ERROR, "Corrupted blocks data encountered!\n");
break;
}
}
}
for (VAR_5 = VAR_2->num_corr-1; VAR_5 >= 0; VAR_5--) {
VAR_7 = VAR_2->corr[VAR_5*2];
VAR_8 = VAR_2->corr[VAR_5*2+1];
FFSWAP(uint8_t, VAR_2->rv_map->runtab[VAR_7], VAR_2->rv_map->runtab[VAR_8]);
FFSWAP(int16_t, VAR_2->rv_map->valtab[VAR_7], VAR_2->rv_map->valtab[VAR_8]);
}
#if IVI_DEBUG
if (VAR_2->checksum_present) {
uint16_t chksum = ivi_calc_band_checksum(VAR_2);
if (chksum != VAR_2->checksum) {
av_log(VAR_3, AV_LOG_ERROR,
"Band checksum mismatch! Plane %d, VAR_2 %d, received: %x, calculated: %x\n",
VAR_2->plane, VAR_2->band_num, VAR_2->checksum, chksum);
}
}
#endif
return VAR_4;
}
| [
"static int FUNC_0(IVI5DecContext *VAR_0, int VAR_1,\nIVIBandDesc *VAR_2, AVCodecContext *VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;",
"IVITile *tile;",
"VAR_2->buf = VAR_2->bufs[VAR_0->dst_buf];",
"VAR_2->ref_buf = VAR_2->bufs[VAR_0->ref_buf];",
"VAR_2->data_ptr = VAR_0->frame_data + (get_bits_count(&VAR_0->gb) >> 3);",
"VAR_4 = decode_band_hdr(VAR_0, VAR_2, VAR_3);",
"if (VAR_4) {",
"av_log(VAR_3, AV_LOG_ERROR, \"Error while decoding VAR_2 header: %d\\n\",\nVAR_4);",
"return -1;",
"}",
"if (VAR_2->is_empty) {",
"av_log(VAR_3, AV_LOG_ERROR, \"Empty VAR_2 encountered!\\n\");",
"return -1;",
"}",
"VAR_2->rv_map = &VAR_0->rvmap_tabs[VAR_2->rvmap_sel];",
"for (VAR_5 = 0; VAR_5 < VAR_2->num_corr; VAR_5++) {",
"VAR_7 = VAR_2->corr[VAR_5*2];",
"VAR_8 = VAR_2->corr[VAR_5*2+1];",
"FFSWAP(uint8_t, VAR_2->rv_map->runtab[VAR_7], VAR_2->rv_map->runtab[VAR_8]);",
"FFSWAP(int16_t, VAR_2->rv_map->valtab[VAR_7], VAR_2->rv_map->valtab[VAR_8]);",
"}",
"for (VAR_6 = 0; VAR_6 < VAR_2->num_tiles; VAR_6++) {",
"tile = &VAR_2->tiles[VAR_6];",
"tile->is_empty = get_bits1(&VAR_0->gb);",
"if (tile->is_empty) {",
"ff_ivi_process_empty_tile(VAR_3, VAR_2, tile,\n(VAR_0->planes[0].bands[0].mb_size >> 3) - (VAR_2->mb_size >> 3));",
"align_get_bits(&VAR_0->gb);",
"} else {",
"tile->data_size = ff_ivi_dec_tile_data_size(&VAR_0->gb);",
"VAR_4 = decode_mb_info(VAR_0, VAR_2, tile, VAR_3);",
"if (VAR_4 < 0)\nbreak;",
"if (VAR_2->blk_size == 8) {",
"VAR_2->intra_base = &ivi5_base_quant_8x8_intra[VAR_2->quant_mat][0];",
"VAR_2->inter_base = &ivi5_base_quant_8x8_inter[VAR_2->quant_mat][0];",
"VAR_2->intra_scale = &ivi5_scale_quant_8x8_intra[VAR_2->quant_mat][0];",
"VAR_2->inter_scale = &ivi5_scale_quant_8x8_inter[VAR_2->quant_mat][0];",
"} else {",
"VAR_2->intra_base = ivi5_base_quant_4x4_intra;",
"VAR_2->inter_base = ivi5_base_quant_4x4_inter;",
"VAR_2->intra_scale = ivi5_scale_quant_4x4_intra;",
"VAR_2->inter_scale = ivi5_scale_quant_4x4_inter;",
"}",
"VAR_4 = ff_ivi_decode_blocks(&VAR_0->gb, VAR_2, tile);",
"if (VAR_4 < 0) {",
"av_log(VAR_3, AV_LOG_ERROR, \"Corrupted blocks data encountered!\\n\");",
"break;",
"}",
"}",
"}",
"for (VAR_5 = VAR_2->num_corr-1; VAR_5 >= 0; VAR_5--) {",
"VAR_7 = VAR_2->corr[VAR_5*2];",
"VAR_8 = VAR_2->corr[VAR_5*2+1];",
"FFSWAP(uint8_t, VAR_2->rv_map->runtab[VAR_7], VAR_2->rv_map->runtab[VAR_8]);",
"FFSWAP(int16_t, VAR_2->rv_map->valtab[VAR_7], VAR_2->rv_map->valtab[VAR_8]);",
"}",
"#if IVI_DEBUG\nif (VAR_2->checksum_present) {",
"uint16_t chksum = ivi_calc_band_checksum(VAR_2);",
"if (chksum != VAR_2->checksum) {",
"av_log(VAR_3, AV_LOG_ERROR,\n\"Band checksum mismatch! Plane %d, VAR_2 %d, received: %x, calculated: %x\\n\",\nVAR_2->plane, VAR_2->band_num, VAR_2->checksum, chksum);",
"}",
"}",
"#endif\nreturn VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89,
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
151,
153
],
[
155
],
[
157
],
[
159,
161,
163
],
[
165
],
[
167
],
[
169,
173
],
[
175
]
] |
3,617 | static int select_reference_stream(AVFormatContext *s)
{
SegmentContext *seg = s->priv_data;
int ret, i;
seg->reference_stream_index = -1;
if (!strcmp(seg->reference_stream_specifier, "auto")) {
/* select first index of type with highest priority */
int type_index_map[AVMEDIA_TYPE_NB];
static const enum AVMediaType type_priority_list[] = {
AVMEDIA_TYPE_VIDEO,
AVMEDIA_TYPE_AUDIO,
AVMEDIA_TYPE_SUBTITLE,
AVMEDIA_TYPE_DATA,
AVMEDIA_TYPE_ATTACHMENT
};
enum AVMediaType type;
for (i = 0; i < AVMEDIA_TYPE_NB; i++)
type_index_map[i] = -1;
/* select first index for each type */
for (i = 0; i < s->nb_streams; i++) {
type = s->streams[i]->codec->codec_type;
if ((unsigned)type < AVMEDIA_TYPE_NB && type_index_map[type] == -1
/* ignore attached pictures/cover art streams */
&& !(s->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC))
type_index_map[type] = i;
}
for (i = 0; i < FF_ARRAY_ELEMS(type_priority_list); i++) {
type = type_priority_list[i];
if ((seg->reference_stream_index = type_index_map[type]) >= 0)
break;
}
} else {
for (i = 0; i < s->nb_streams; i++) {
ret = avformat_match_stream_specifier(s, s->streams[i],
seg->reference_stream_specifier);
if (ret < 0)
break;
if (ret > 0) {
seg->reference_stream_index = i;
break;
}
}
}
if (seg->reference_stream_index < 0) {
av_log(s, AV_LOG_ERROR, "Could not select stream matching identifier '%s'\n",
seg->reference_stream_specifier);
return AVERROR(EINVAL);
}
return 0;
}
| true | FFmpeg | e3197257171c347353538152523f9d3fe880aee6 | static int select_reference_stream(AVFormatContext *s)
{
SegmentContext *seg = s->priv_data;
int ret, i;
seg->reference_stream_index = -1;
if (!strcmp(seg->reference_stream_specifier, "auto")) {
int type_index_map[AVMEDIA_TYPE_NB];
static const enum AVMediaType type_priority_list[] = {
AVMEDIA_TYPE_VIDEO,
AVMEDIA_TYPE_AUDIO,
AVMEDIA_TYPE_SUBTITLE,
AVMEDIA_TYPE_DATA,
AVMEDIA_TYPE_ATTACHMENT
};
enum AVMediaType type;
for (i = 0; i < AVMEDIA_TYPE_NB; i++)
type_index_map[i] = -1;
for (i = 0; i < s->nb_streams; i++) {
type = s->streams[i]->codec->codec_type;
if ((unsigned)type < AVMEDIA_TYPE_NB && type_index_map[type] == -1
&& !(s->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC))
type_index_map[type] = i;
}
for (i = 0; i < FF_ARRAY_ELEMS(type_priority_list); i++) {
type = type_priority_list[i];
if ((seg->reference_stream_index = type_index_map[type]) >= 0)
break;
}
} else {
for (i = 0; i < s->nb_streams; i++) {
ret = avformat_match_stream_specifier(s, s->streams[i],
seg->reference_stream_specifier);
if (ret < 0)
break;
if (ret > 0) {
seg->reference_stream_index = i;
break;
}
}
}
if (seg->reference_stream_index < 0) {
av_log(s, AV_LOG_ERROR, "Could not select stream matching identifier '%s'\n",
seg->reference_stream_specifier);
return AVERROR(EINVAL);
}
return 0;
}
| {
"code": [
" break;"
],
"line_no": [
67
]
} | static int FUNC_0(AVFormatContext *VAR_0)
{
SegmentContext *seg = VAR_0->priv_data;
int VAR_1, VAR_2;
seg->reference_stream_index = -1;
if (!strcmp(seg->reference_stream_specifier, "auto")) {
int VAR_3[AVMEDIA_TYPE_NB];
static const enum AVMediaType VAR_4[] = {
AVMEDIA_TYPE_VIDEO,
AVMEDIA_TYPE_AUDIO,
AVMEDIA_TYPE_SUBTITLE,
AVMEDIA_TYPE_DATA,
AVMEDIA_TYPE_ATTACHMENT
};
enum AVMediaType VAR_5;
for (VAR_2 = 0; VAR_2 < AVMEDIA_TYPE_NB; VAR_2++)
VAR_3[VAR_2] = -1;
for (VAR_2 = 0; VAR_2 < VAR_0->nb_streams; VAR_2++) {
VAR_5 = VAR_0->streams[VAR_2]->codec->codec_type;
if ((unsigned)VAR_5 < AVMEDIA_TYPE_NB && VAR_3[VAR_5] == -1
&& !(VAR_0->streams[VAR_2]->disposition & AV_DISPOSITION_ATTACHED_PIC))
VAR_3[VAR_5] = VAR_2;
}
for (VAR_2 = 0; VAR_2 < FF_ARRAY_ELEMS(VAR_4); VAR_2++) {
VAR_5 = VAR_4[VAR_2];
if ((seg->reference_stream_index = VAR_3[VAR_5]) >= 0)
break;
}
} else {
for (VAR_2 = 0; VAR_2 < VAR_0->nb_streams; VAR_2++) {
VAR_1 = avformat_match_stream_specifier(VAR_0, VAR_0->streams[VAR_2],
seg->reference_stream_specifier);
if (VAR_1 < 0)
break;
if (VAR_1 > 0) {
seg->reference_stream_index = VAR_2;
break;
}
}
}
if (seg->reference_stream_index < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Could not select stream matching identifier '%VAR_0'\n",
seg->reference_stream_specifier);
return AVERROR(EINVAL);
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"SegmentContext *seg = VAR_0->priv_data;",
"int VAR_1, VAR_2;",
"seg->reference_stream_index = -1;",
"if (!strcmp(seg->reference_stream_specifier, \"auto\")) {",
"int VAR_3[AVMEDIA_TYPE_NB];",
"static const enum AVMediaType VAR_4[] = {",
"AVMEDIA_TYPE_VIDEO,\nAVMEDIA_TYPE_AUDIO,\nAVMEDIA_TYPE_SUBTITLE,\nAVMEDIA_TYPE_DATA,\nAVMEDIA_TYPE_ATTACHMENT\n};",
"enum AVMediaType VAR_5;",
"for (VAR_2 = 0; VAR_2 < AVMEDIA_TYPE_NB; VAR_2++)",
"VAR_3[VAR_2] = -1;",
"for (VAR_2 = 0; VAR_2 < VAR_0->nb_streams; VAR_2++) {",
"VAR_5 = VAR_0->streams[VAR_2]->codec->codec_type;",
"if ((unsigned)VAR_5 < AVMEDIA_TYPE_NB && VAR_3[VAR_5] == -1\n&& !(VAR_0->streams[VAR_2]->disposition & AV_DISPOSITION_ATTACHED_PIC))\nVAR_3[VAR_5] = VAR_2;",
"}",
"for (VAR_2 = 0; VAR_2 < FF_ARRAY_ELEMS(VAR_4); VAR_2++) {",
"VAR_5 = VAR_4[VAR_2];",
"if ((seg->reference_stream_index = VAR_3[VAR_5]) >= 0)\nbreak;",
"}",
"} else {",
"for (VAR_2 = 0; VAR_2 < VAR_0->nb_streams; VAR_2++) {",
"VAR_1 = avformat_match_stream_specifier(VAR_0, VAR_0->streams[VAR_2],\nseg->reference_stream_specifier);",
"if (VAR_1 < 0)\nbreak;",
"if (VAR_1 > 0) {",
"seg->reference_stream_index = VAR_2;",
"break;",
"}",
"}",
"}",
"if (seg->reference_stream_index < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Could not select stream matching identifier '%VAR_0'\\n\",\nseg->reference_stream_specifier);",
"return AVERROR(EINVAL);",
"}",
"return 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
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21,
23,
25,
27,
29,
31
],
[
33
],
[
37
],
[
39
],
[
45
],
[
47
],
[
49,
53,
55
],
[
57
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
109
],
[
111
]
] |
3,618 | static void property_get_tm(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
TMProperty *prop = opaque;
Error *err = NULL;
struct tm value;
prop->get(obj, &value, &err);
if (err) {
goto out;
}
visit_start_struct(v, name, NULL, 0, &err);
if (err) {
goto out;
}
visit_type_int32(v, "tm_year", &value.tm_year, &err);
if (err) {
goto out_end;
}
visit_type_int32(v, "tm_mon", &value.tm_mon, &err);
if (err) {
goto out_end;
}
visit_type_int32(v, "tm_mday", &value.tm_mday, &err);
if (err) {
goto out_end;
}
visit_type_int32(v, "tm_hour", &value.tm_hour, &err);
if (err) {
goto out_end;
}
visit_type_int32(v, "tm_min", &value.tm_min, &err);
if (err) {
goto out_end;
}
visit_type_int32(v, "tm_sec", &value.tm_sec, &err);
if (err) {
goto out_end;
}
out_end:
error_propagate(errp, err);
err = NULL;
visit_end_struct(v, errp);
out:
error_propagate(errp, err);
}
| true | qemu | 15c2f669e3fb2bc97f7b42d1871f595c0ac24af8 | static void property_get_tm(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
TMProperty *prop = opaque;
Error *err = NULL;
struct tm value;
prop->get(obj, &value, &err);
if (err) {
goto out;
}
visit_start_struct(v, name, NULL, 0, &err);
if (err) {
goto out;
}
visit_type_int32(v, "tm_year", &value.tm_year, &err);
if (err) {
goto out_end;
}
visit_type_int32(v, "tm_mon", &value.tm_mon, &err);
if (err) {
goto out_end;
}
visit_type_int32(v, "tm_mday", &value.tm_mday, &err);
if (err) {
goto out_end;
}
visit_type_int32(v, "tm_hour", &value.tm_hour, &err);
if (err) {
goto out_end;
}
visit_type_int32(v, "tm_min", &value.tm_min, &err);
if (err) {
goto out_end;
}
visit_type_int32(v, "tm_sec", &value.tm_sec, &err);
if (err) {
goto out_end;
}
out_end:
error_propagate(errp, err);
err = NULL;
visit_end_struct(v, errp);
out:
error_propagate(errp, err);
}
| {
"code": [
" error_propagate(errp, err);",
" err = NULL;",
" error_propagate(errp, err);",
" err = NULL;",
" error_propagate(errp, err);",
" err = NULL;",
" visit_end_struct(v, errp);",
" goto out;",
" error_propagate(errp, err);",
" err = NULL;"
],
"line_no": [
83,
85,
83,
85,
83,
85,
87,
19,
83,
85
]
} | static void FUNC_0(Object *VAR_0, Visitor *VAR_1, const char *VAR_2,
void *VAR_3, Error **VAR_4)
{
TMProperty *prop = VAR_3;
Error *err = NULL;
struct tm VAR_5;
prop->get(VAR_0, &VAR_5, &err);
if (err) {
goto out;
}
visit_start_struct(VAR_1, VAR_2, NULL, 0, &err);
if (err) {
goto out;
}
visit_type_int32(VAR_1, "tm_year", &VAR_5.tm_year, &err);
if (err) {
goto out_end;
}
visit_type_int32(VAR_1, "tm_mon", &VAR_5.tm_mon, &err);
if (err) {
goto out_end;
}
visit_type_int32(VAR_1, "tm_mday", &VAR_5.tm_mday, &err);
if (err) {
goto out_end;
}
visit_type_int32(VAR_1, "tm_hour", &VAR_5.tm_hour, &err);
if (err) {
goto out_end;
}
visit_type_int32(VAR_1, "tm_min", &VAR_5.tm_min, &err);
if (err) {
goto out_end;
}
visit_type_int32(VAR_1, "tm_sec", &VAR_5.tm_sec, &err);
if (err) {
goto out_end;
}
out_end:
error_propagate(VAR_4, err);
err = NULL;
visit_end_struct(VAR_1, VAR_4);
out:
error_propagate(VAR_4, err);
}
| [
"static void FUNC_0(Object *VAR_0, Visitor *VAR_1, const char *VAR_2,\nvoid *VAR_3, Error **VAR_4)\n{",
"TMProperty *prop = VAR_3;",
"Error *err = NULL;",
"struct tm VAR_5;",
"prop->get(VAR_0, &VAR_5, &err);",
"if (err) {",
"goto out;",
"}",
"visit_start_struct(VAR_1, VAR_2, NULL, 0, &err);",
"if (err) {",
"goto out;",
"}",
"visit_type_int32(VAR_1, \"tm_year\", &VAR_5.tm_year, &err);",
"if (err) {",
"goto out_end;",
"}",
"visit_type_int32(VAR_1, \"tm_mon\", &VAR_5.tm_mon, &err);",
"if (err) {",
"goto out_end;",
"}",
"visit_type_int32(VAR_1, \"tm_mday\", &VAR_5.tm_mday, &err);",
"if (err) {",
"goto out_end;",
"}",
"visit_type_int32(VAR_1, \"tm_hour\", &VAR_5.tm_hour, &err);",
"if (err) {",
"goto out_end;",
"}",
"visit_type_int32(VAR_1, \"tm_min\", &VAR_5.tm_min, &err);",
"if (err) {",
"goto out_end;",
"}",
"visit_type_int32(VAR_1, \"tm_sec\", &VAR_5.tm_sec, &err);",
"if (err) {",
"goto out_end;",
"}",
"out_end:\nerror_propagate(VAR_4, err);",
"err = NULL;",
"visit_end_struct(VAR_1, VAR_4);",
"out:\nerror_propagate(VAR_4, err);",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
89,
91
],
[
95
]
] |
3,622 | e1000e_write_lgcy_rx_descr(E1000ECore *core, uint8_t *desc,
struct NetRxPkt *pkt,
const E1000E_RSSInfo *rss_info,
uint16_t length)
{
uint32_t status_flags, rss, mrq;
uint16_t ip_id;
struct e1000_rx_desc *d = (struct e1000_rx_desc *) desc;
memset(d, 0, sizeof(*d));
assert(!rss_info->enabled);
d->length = cpu_to_le16(length);
e1000e_build_rx_metadata(core, pkt, pkt != NULL,
rss_info,
&rss, &mrq,
&status_flags, &ip_id,
&d->special);
d->errors = (uint8_t) (le32_to_cpu(status_flags) >> 24);
d->status = (uint8_t) le32_to_cpu(status_flags);
}
| true | qemu | c89d416a2b0fb6a21224186b10af4c4a3feee31b | e1000e_write_lgcy_rx_descr(E1000ECore *core, uint8_t *desc,
struct NetRxPkt *pkt,
const E1000E_RSSInfo *rss_info,
uint16_t length)
{
uint32_t status_flags, rss, mrq;
uint16_t ip_id;
struct e1000_rx_desc *d = (struct e1000_rx_desc *) desc;
memset(d, 0, sizeof(*d));
assert(!rss_info->enabled);
d->length = cpu_to_le16(length);
e1000e_build_rx_metadata(core, pkt, pkt != NULL,
rss_info,
&rss, &mrq,
&status_flags, &ip_id,
&d->special);
d->errors = (uint8_t) (le32_to_cpu(status_flags) >> 24);
d->status = (uint8_t) le32_to_cpu(status_flags);
}
| {
"code": [
" memset(d, 0, sizeof(*d));",
" memset(d, 0, sizeof(*d));",
" memset(d, 0, sizeof(*d));"
],
"line_no": [
21,
21,
21
]
} | FUNC_0(E1000ECore *VAR_0, uint8_t *VAR_1,
struct NetRxPkt *VAR_2,
const E1000E_RSSInfo *VAR_3,
uint16_t VAR_4)
{
uint32_t status_flags, rss, mrq;
uint16_t ip_id;
struct e1000_rx_desc *VAR_5 = (struct e1000_rx_desc *) VAR_1;
memset(VAR_5, 0, sizeof(*VAR_5));
assert(!VAR_3->enabled);
VAR_5->VAR_4 = cpu_to_le16(VAR_4);
e1000e_build_rx_metadata(VAR_0, VAR_2, VAR_2 != NULL,
VAR_3,
&rss, &mrq,
&status_flags, &ip_id,
&VAR_5->special);
VAR_5->errors = (uint8_t) (le32_to_cpu(status_flags) >> 24);
VAR_5->status = (uint8_t) le32_to_cpu(status_flags);
}
| [
"FUNC_0(E1000ECore *VAR_0, uint8_t *VAR_1,\nstruct NetRxPkt *VAR_2,\nconst E1000E_RSSInfo *VAR_3,\nuint16_t VAR_4)\n{",
"uint32_t status_flags, rss, mrq;",
"uint16_t ip_id;",
"struct e1000_rx_desc *VAR_5 = (struct e1000_rx_desc *) VAR_1;",
"memset(VAR_5, 0, sizeof(*VAR_5));",
"assert(!VAR_3->enabled);",
"VAR_5->VAR_4 = cpu_to_le16(VAR_4);",
"e1000e_build_rx_metadata(VAR_0, VAR_2, VAR_2 != NULL,\nVAR_3,\n&rss, &mrq,\n&status_flags, &ip_id,\n&VAR_5->special);",
"VAR_5->errors = (uint8_t) (le32_to_cpu(status_flags) >> 24);",
"VAR_5->status = (uint8_t) le32_to_cpu(status_flags);",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
25
],
[
29
],
[
33,
35,
37,
39,
41
],
[
43
],
[
45
],
[
47
]
] |
3,623 | void qemu_put_byte(QEMUFile *f, int v)
{
if (f->last_error) {
return;
}
f->buf[f->buf_index] = v;
f->bytes_xfer++;
if (f->ops->writev_buffer) {
add_to_iovec(f, f->buf + f->buf_index, 1);
}
f->buf_index++;
if (f->buf_index == IO_BUF_SIZE) {
qemu_fflush(f);
}
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | void qemu_put_byte(QEMUFile *f, int v)
{
if (f->last_error) {
return;
}
f->buf[f->buf_index] = v;
f->bytes_xfer++;
if (f->ops->writev_buffer) {
add_to_iovec(f, f->buf + f->buf_index, 1);
}
f->buf_index++;
if (f->buf_index == IO_BUF_SIZE) {
qemu_fflush(f);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(QEMUFile *VAR_0, int VAR_1)
{
if (VAR_0->last_error) {
return;
}
VAR_0->buf[VAR_0->buf_index] = VAR_1;
VAR_0->bytes_xfer++;
if (VAR_0->ops->writev_buffer) {
add_to_iovec(VAR_0, VAR_0->buf + VAR_0->buf_index, 1);
}
VAR_0->buf_index++;
if (VAR_0->buf_index == IO_BUF_SIZE) {
qemu_fflush(VAR_0);
}
}
| [
"void FUNC_0(QEMUFile *VAR_0, int VAR_1)\n{",
"if (VAR_0->last_error) {",
"return;",
"}",
"VAR_0->buf[VAR_0->buf_index] = VAR_1;",
"VAR_0->bytes_xfer++;",
"if (VAR_0->ops->writev_buffer) {",
"add_to_iovec(VAR_0, VAR_0->buf + VAR_0->buf_index, 1);",
"}",
"VAR_0->buf_index++;",
"if (VAR_0->buf_index == IO_BUF_SIZE) {",
"qemu_fflush(VAR_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
]
] |
3,624 | long do_rt_sigreturn(CPUX86State *env)
{
abi_ulong frame_addr;
struct rt_sigframe *frame;
sigset_t set;
frame_addr = env->regs[R_ESP] - 4;
trace_user_do_rt_sigreturn(env, frame_addr);
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
target_to_host_sigset(&set, &frame->uc.tuc_sigmask);
set_sigmask(&set);
if (restore_sigcontext(env, &frame->uc.tuc_mcontext)) {
goto badframe;
}
if (do_sigaltstack(frame_addr + offsetof(struct rt_sigframe, uc.tuc_stack), 0,
get_sp_from_cpustate(env)) == -EFAULT) {
goto badframe;
}
unlock_user_struct(frame, frame_addr, 0);
return -TARGET_QEMU_ESIGRETURN;
badframe:
unlock_user_struct(frame, frame_addr, 0);
force_sig(TARGET_SIGSEGV);
return 0;
}
| true | qemu | c599d4d6d6e9bfdb64e54c33a22cb26e3496b96d | long do_rt_sigreturn(CPUX86State *env)
{
abi_ulong frame_addr;
struct rt_sigframe *frame;
sigset_t set;
frame_addr = env->regs[R_ESP] - 4;
trace_user_do_rt_sigreturn(env, frame_addr);
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
target_to_host_sigset(&set, &frame->uc.tuc_sigmask);
set_sigmask(&set);
if (restore_sigcontext(env, &frame->uc.tuc_mcontext)) {
goto badframe;
}
if (do_sigaltstack(frame_addr + offsetof(struct rt_sigframe, uc.tuc_stack), 0,
get_sp_from_cpustate(env)) == -EFAULT) {
goto badframe;
}
unlock_user_struct(frame, frame_addr, 0);
return -TARGET_QEMU_ESIGRETURN;
badframe:
unlock_user_struct(frame, frame_addr, 0);
force_sig(TARGET_SIGSEGV);
return 0;
}
| {
"code": [
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;"
],
"line_no": [
57,
57,
57,
57,
57,
57,
57,
57,
57,
57,
57,
57,
57,
57,
57,
57,
57
]
} | long FUNC_0(CPUX86State *VAR_0)
{
abi_ulong frame_addr;
struct rt_sigframe *VAR_1;
sigset_t set;
frame_addr = VAR_0->regs[R_ESP] - 4;
trace_user_do_rt_sigreturn(VAR_0, frame_addr);
if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1))
goto badframe;
target_to_host_sigset(&set, &VAR_1->uc.tuc_sigmask);
set_sigmask(&set);
if (restore_sigcontext(VAR_0, &VAR_1->uc.tuc_mcontext)) {
goto badframe;
}
if (do_sigaltstack(frame_addr + offsetof(struct rt_sigframe, uc.tuc_stack), 0,
get_sp_from_cpustate(VAR_0)) == -EFAULT) {
goto badframe;
}
unlock_user_struct(VAR_1, frame_addr, 0);
return -TARGET_QEMU_ESIGRETURN;
badframe:
unlock_user_struct(VAR_1, frame_addr, 0);
force_sig(TARGET_SIGSEGV);
return 0;
}
| [
"long FUNC_0(CPUX86State *VAR_0)\n{",
"abi_ulong frame_addr;",
"struct rt_sigframe *VAR_1;",
"sigset_t set;",
"frame_addr = VAR_0->regs[R_ESP] - 4;",
"trace_user_do_rt_sigreturn(VAR_0, frame_addr);",
"if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1))\ngoto badframe;",
"target_to_host_sigset(&set, &VAR_1->uc.tuc_sigmask);",
"set_sigmask(&set);",
"if (restore_sigcontext(VAR_0, &VAR_1->uc.tuc_mcontext)) {",
"goto badframe;",
"}",
"if (do_sigaltstack(frame_addr + offsetof(struct rt_sigframe, uc.tuc_stack), 0,\nget_sp_from_cpustate(VAR_0)) == -EFAULT) {",
"goto badframe;",
"}",
"unlock_user_struct(VAR_1, frame_addr, 0);",
"return -TARGET_QEMU_ESIGRETURN;",
"badframe:\nunlock_user_struct(VAR_1, frame_addr, 0);",
"force_sig(TARGET_SIGSEGV);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35,
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
51,
53
],
[
55
],
[
57
],
[
59
]
] |
3,625 | unsigned ff_els_decode_unsigned(ElsDecCtx *ctx, ElsUnsignedRung *ur)
{
int i, n, r, bit;
ElsRungNode *rung_node;
if (ctx->err)
return 0;
/* decode unary prefix */
for (n = 0; n < ELS_EXPGOLOMB_LEN + 1; n++)
if (ff_els_decode_bit(ctx, &ur->prefix_rung[n]))
break;
/* handle the error/overflow case */
if (ctx->err || n >= ELS_EXPGOLOMB_LEN) {
ctx->err = AVERROR(EOVERFLOW);
return 0;
}
/* handle the zero case */
if (!n)
return 0;
/* initialize probability tree */
if (!ur->rem_rung_list) {
ur->rem_rung_list = av_realloc(NULL, RUNG_SPACE);
if (!ur->rem_rung_list) {
ctx->err = AVERROR(ENOMEM);
return 0;
}
memset(ur->rem_rung_list, 0, RUNG_SPACE);
ur->rung_list_size = RUNG_SPACE;
ur->avail_index = ELS_EXPGOLOMB_LEN;
}
/* decode the remainder */
for (i = 0, r = 0, bit = 0; i < n; i++) {
if (!i)
rung_node = &ur->rem_rung_list[n];
else {
if (!rung_node->next_index) {
if (ur->rung_list_size <= (ur->avail_index + 2) * sizeof(ElsRungNode)) {
// remember rung_node position
ptrdiff_t pos = rung_node - ur->rem_rung_list;
ur->rem_rung_list = av_realloc(ur->rem_rung_list,
ur->rung_list_size +
RUNG_SPACE);
if (!ur->rem_rung_list) {
av_free(ur->rem_rung_list);
ctx->err = AVERROR(ENOMEM);
return 0;
}
memset((uint8_t *) ur->rem_rung_list + ur->rung_list_size, 0,
RUNG_SPACE);
ur->rung_list_size += RUNG_SPACE;
// restore rung_node position in the new list
rung_node = &ur->rem_rung_list[pos];
}
rung_node->next_index = ur->avail_index;
ur->avail_index += 2;
}
rung_node = &ur->rem_rung_list[rung_node->next_index + bit];
}
bit = ff_els_decode_bit(ctx, &rung_node->rung);
if (ctx->err)
return bit;
r = (r << 1) + bit;
}
return (1 << n) - 1 + r; /* make value from exp golomb code */
}
| true | FFmpeg | 4e0819310e2d2eff60be2d6df28335f0739712b9 | unsigned ff_els_decode_unsigned(ElsDecCtx *ctx, ElsUnsignedRung *ur)
{
int i, n, r, bit;
ElsRungNode *rung_node;
if (ctx->err)
return 0;
for (n = 0; n < ELS_EXPGOLOMB_LEN + 1; n++)
if (ff_els_decode_bit(ctx, &ur->prefix_rung[n]))
break;
if (ctx->err || n >= ELS_EXPGOLOMB_LEN) {
ctx->err = AVERROR(EOVERFLOW);
return 0;
}
if (!n)
return 0;
if (!ur->rem_rung_list) {
ur->rem_rung_list = av_realloc(NULL, RUNG_SPACE);
if (!ur->rem_rung_list) {
ctx->err = AVERROR(ENOMEM);
return 0;
}
memset(ur->rem_rung_list, 0, RUNG_SPACE);
ur->rung_list_size = RUNG_SPACE;
ur->avail_index = ELS_EXPGOLOMB_LEN;
}
for (i = 0, r = 0, bit = 0; i < n; i++) {
if (!i)
rung_node = &ur->rem_rung_list[n];
else {
if (!rung_node->next_index) {
if (ur->rung_list_size <= (ur->avail_index + 2) * sizeof(ElsRungNode)) {
ptrdiff_t pos = rung_node - ur->rem_rung_list;
ur->rem_rung_list = av_realloc(ur->rem_rung_list,
ur->rung_list_size +
RUNG_SPACE);
if (!ur->rem_rung_list) {
av_free(ur->rem_rung_list);
ctx->err = AVERROR(ENOMEM);
return 0;
}
memset((uint8_t *) ur->rem_rung_list + ur->rung_list_size, 0,
RUNG_SPACE);
ur->rung_list_size += RUNG_SPACE;
rung_node = &ur->rem_rung_list[pos];
}
rung_node->next_index = ur->avail_index;
ur->avail_index += 2;
}
rung_node = &ur->rem_rung_list[rung_node->next_index + bit];
}
bit = ff_els_decode_bit(ctx, &rung_node->rung);
if (ctx->err)
return bit;
r = (r << 1) + bit;
}
return (1 << n) - 1 + r;
}
| {
"code": [
" ctx->err = AVERROR(EOVERFLOW);"
],
"line_no": [
31
]
} | unsigned FUNC_0(ElsDecCtx *VAR_0, ElsUnsignedRung *VAR_1)
{
int VAR_2, VAR_3, VAR_4, VAR_5;
ElsRungNode *rung_node;
if (VAR_0->err)
return 0;
for (VAR_3 = 0; VAR_3 < ELS_EXPGOLOMB_LEN + 1; VAR_3++)
if (ff_els_decode_bit(VAR_0, &VAR_1->prefix_rung[VAR_3]))
break;
if (VAR_0->err || VAR_3 >= ELS_EXPGOLOMB_LEN) {
VAR_0->err = AVERROR(EOVERFLOW);
return 0;
}
if (!VAR_3)
return 0;
if (!VAR_1->rem_rung_list) {
VAR_1->rem_rung_list = av_realloc(NULL, RUNG_SPACE);
if (!VAR_1->rem_rung_list) {
VAR_0->err = AVERROR(ENOMEM);
return 0;
}
memset(VAR_1->rem_rung_list, 0, RUNG_SPACE);
VAR_1->rung_list_size = RUNG_SPACE;
VAR_1->avail_index = ELS_EXPGOLOMB_LEN;
}
for (VAR_2 = 0, VAR_4 = 0, VAR_5 = 0; VAR_2 < VAR_3; VAR_2++) {
if (!VAR_2)
rung_node = &VAR_1->rem_rung_list[VAR_3];
else {
if (!rung_node->next_index) {
if (VAR_1->rung_list_size <= (VAR_1->avail_index + 2) * sizeof(ElsRungNode)) {
ptrdiff_t pos = rung_node - VAR_1->rem_rung_list;
VAR_1->rem_rung_list = av_realloc(VAR_1->rem_rung_list,
VAR_1->rung_list_size +
RUNG_SPACE);
if (!VAR_1->rem_rung_list) {
av_free(VAR_1->rem_rung_list);
VAR_0->err = AVERROR(ENOMEM);
return 0;
}
memset((uint8_t *) VAR_1->rem_rung_list + VAR_1->rung_list_size, 0,
RUNG_SPACE);
VAR_1->rung_list_size += RUNG_SPACE;
rung_node = &VAR_1->rem_rung_list[pos];
}
rung_node->next_index = VAR_1->avail_index;
VAR_1->avail_index += 2;
}
rung_node = &VAR_1->rem_rung_list[rung_node->next_index + VAR_5];
}
VAR_5 = ff_els_decode_bit(VAR_0, &rung_node->rung);
if (VAR_0->err)
return VAR_5;
VAR_4 = (VAR_4 << 1) + VAR_5;
}
return (1 << VAR_3) - 1 + VAR_4;
}
| [
"unsigned FUNC_0(ElsDecCtx *VAR_0, ElsUnsignedRung *VAR_1)\n{",
"int VAR_2, VAR_3, VAR_4, VAR_5;",
"ElsRungNode *rung_node;",
"if (VAR_0->err)\nreturn 0;",
"for (VAR_3 = 0; VAR_3 < ELS_EXPGOLOMB_LEN + 1; VAR_3++)",
"if (ff_els_decode_bit(VAR_0, &VAR_1->prefix_rung[VAR_3]))\nbreak;",
"if (VAR_0->err || VAR_3 >= ELS_EXPGOLOMB_LEN) {",
"VAR_0->err = AVERROR(EOVERFLOW);",
"return 0;",
"}",
"if (!VAR_3)\nreturn 0;",
"if (!VAR_1->rem_rung_list) {",
"VAR_1->rem_rung_list = av_realloc(NULL, RUNG_SPACE);",
"if (!VAR_1->rem_rung_list) {",
"VAR_0->err = AVERROR(ENOMEM);",
"return 0;",
"}",
"memset(VAR_1->rem_rung_list, 0, RUNG_SPACE);",
"VAR_1->rung_list_size = RUNG_SPACE;",
"VAR_1->avail_index = ELS_EXPGOLOMB_LEN;",
"}",
"for (VAR_2 = 0, VAR_4 = 0, VAR_5 = 0; VAR_2 < VAR_3; VAR_2++) {",
"if (!VAR_2)\nrung_node = &VAR_1->rem_rung_list[VAR_3];",
"else {",
"if (!rung_node->next_index) {",
"if (VAR_1->rung_list_size <= (VAR_1->avail_index + 2) * sizeof(ElsRungNode)) {",
"ptrdiff_t pos = rung_node - VAR_1->rem_rung_list;",
"VAR_1->rem_rung_list = av_realloc(VAR_1->rem_rung_list,\nVAR_1->rung_list_size +\nRUNG_SPACE);",
"if (!VAR_1->rem_rung_list) {",
"av_free(VAR_1->rem_rung_list);",
"VAR_0->err = AVERROR(ENOMEM);",
"return 0;",
"}",
"memset((uint8_t *) VAR_1->rem_rung_list + VAR_1->rung_list_size, 0,\nRUNG_SPACE);",
"VAR_1->rung_list_size += RUNG_SPACE;",
"rung_node = &VAR_1->rem_rung_list[pos];",
"}",
"rung_node->next_index = VAR_1->avail_index;",
"VAR_1->avail_index += 2;",
"}",
"rung_node = &VAR_1->rem_rung_list[rung_node->next_index + VAR_5];",
"}",
"VAR_5 = ff_els_decode_bit(VAR_0, &rung_node->rung);",
"if (VAR_0->err)\nreturn VAR_5;",
"VAR_4 = (VAR_4 << 1) + VAR_5;",
"}",
"return (1 << VAR_3) - 1 + VAR_4;",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
19
],
[
21,
23
],
[
29
],
[
31
],
[
33
],
[
35
],
[
41,
43
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89,
91,
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105,
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131,
133
],
[
137
],
[
139
],
[
143
],
[
145
]
] |
3,626 | static int sse_mb(MpegEncContext *s){
int w= 16;
int h= 16;
if(s->mb_x*16 + 16 > s->width ) w= s->width - s->mb_x*16;
if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16;
if(w==16 && h==16)
if(s->avctx->mb_cmp == FF_CMP_NSSE){
return s->dsp.nsse[0](s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16)
+s->dsp.nsse[1](s, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8)
+s->dsp.nsse[1](s, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8);
}else{
return s->dsp.sse[0](NULL, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16)
+s->dsp.sse[1](NULL, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8)
+s->dsp.sse[1](NULL, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8);
}
else
return sse(s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], w, h, s->linesize)
+sse(s, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], w>>1, h>>1, s->uvlinesize)
+sse(s, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], w>>1, h>>1, s->uvlinesize);
}
| true | FFmpeg | f6774f905fb3cfdc319523ac640be30b14c1bc55 | static int sse_mb(MpegEncContext *s){
int w= 16;
int h= 16;
if(s->mb_x*16 + 16 > s->width ) w= s->width - s->mb_x*16;
if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16;
if(w==16 && h==16)
if(s->avctx->mb_cmp == FF_CMP_NSSE){
return s->dsp.nsse[0](s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16)
+s->dsp.nsse[1](s, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8)
+s->dsp.nsse[1](s, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8);
}else{
return s->dsp.sse[0](NULL, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16)
+s->dsp.sse[1](NULL, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8)
+s->dsp.sse[1](NULL, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8);
}
else
return sse(s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], w, h, s->linesize)
+sse(s, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], w>>1, h>>1, s->uvlinesize)
+sse(s, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], w>>1, h>>1, s->uvlinesize);
}
| {
"code": [
" return s->dsp.nsse[0](s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16)",
" +s->dsp.nsse[1](s, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8)",
" +s->dsp.nsse[1](s, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8);",
" return s->dsp.sse[0](NULL, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16)",
" +s->dsp.sse[1](NULL, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8)",
" +s->dsp.sse[1](NULL, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8);",
" return sse(s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], w, h, s->linesize)",
" +sse(s, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], w>>1, h>>1, s->uvlinesize)",
" +sse(s, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], w>>1, h>>1, s->uvlinesize);"
],
"line_no": [
19,
21,
23,
27,
29,
31,
37,
39,
41
]
} | static int FUNC_0(MpegEncContext *VAR_0){
int VAR_1= 16;
int VAR_2= 16;
if(VAR_0->mb_x*16 + 16 > VAR_0->width ) VAR_1= VAR_0->width - VAR_0->mb_x*16;
if(VAR_0->mb_y*16 + 16 > VAR_0->height) VAR_2= VAR_0->height- VAR_0->mb_y*16;
if(VAR_1==16 && VAR_2==16)
if(VAR_0->avctx->mb_cmp == FF_CMP_NSSE){
return VAR_0->dsp.nsse[0](VAR_0, VAR_0->new_picture.f.data[0] + VAR_0->mb_x*16 + VAR_0->mb_y*VAR_0->linesize*16, VAR_0->dest[0], VAR_0->linesize, 16)
+VAR_0->dsp.nsse[1](VAR_0, VAR_0->new_picture.f.data[1] + VAR_0->mb_x*8 + VAR_0->mb_y*VAR_0->uvlinesize*8,VAR_0->dest[1], VAR_0->uvlinesize, 8)
+VAR_0->dsp.nsse[1](VAR_0, VAR_0->new_picture.f.data[2] + VAR_0->mb_x*8 + VAR_0->mb_y*VAR_0->uvlinesize*8,VAR_0->dest[2], VAR_0->uvlinesize, 8);
}else{
return VAR_0->dsp.sse[0](NULL, VAR_0->new_picture.f.data[0] + VAR_0->mb_x*16 + VAR_0->mb_y*VAR_0->linesize*16, VAR_0->dest[0], VAR_0->linesize, 16)
+VAR_0->dsp.sse[1](NULL, VAR_0->new_picture.f.data[1] + VAR_0->mb_x*8 + VAR_0->mb_y*VAR_0->uvlinesize*8,VAR_0->dest[1], VAR_0->uvlinesize, 8)
+VAR_0->dsp.sse[1](NULL, VAR_0->new_picture.f.data[2] + VAR_0->mb_x*8 + VAR_0->mb_y*VAR_0->uvlinesize*8,VAR_0->dest[2], VAR_0->uvlinesize, 8);
}
else
return sse(VAR_0, VAR_0->new_picture.f.data[0] + VAR_0->mb_x*16 + VAR_0->mb_y*VAR_0->linesize*16, VAR_0->dest[0], VAR_1, VAR_2, VAR_0->linesize)
+sse(VAR_0, VAR_0->new_picture.f.data[1] + VAR_0->mb_x*8 + VAR_0->mb_y*VAR_0->uvlinesize*8,VAR_0->dest[1], VAR_1>>1, VAR_2>>1, VAR_0->uvlinesize)
+sse(VAR_0, VAR_0->new_picture.f.data[2] + VAR_0->mb_x*8 + VAR_0->mb_y*VAR_0->uvlinesize*8,VAR_0->dest[2], VAR_1>>1, VAR_2>>1, VAR_0->uvlinesize);
}
| [
"static int FUNC_0(MpegEncContext *VAR_0){",
"int VAR_1= 16;",
"int VAR_2= 16;",
"if(VAR_0->mb_x*16 + 16 > VAR_0->width ) VAR_1= VAR_0->width - VAR_0->mb_x*16;",
"if(VAR_0->mb_y*16 + 16 > VAR_0->height) VAR_2= VAR_0->height- VAR_0->mb_y*16;",
"if(VAR_1==16 && VAR_2==16)\nif(VAR_0->avctx->mb_cmp == FF_CMP_NSSE){",
"return VAR_0->dsp.nsse[0](VAR_0, VAR_0->new_picture.f.data[0] + VAR_0->mb_x*16 + VAR_0->mb_y*VAR_0->linesize*16, VAR_0->dest[0], VAR_0->linesize, 16)\n+VAR_0->dsp.nsse[1](VAR_0, VAR_0->new_picture.f.data[1] + VAR_0->mb_x*8 + VAR_0->mb_y*VAR_0->uvlinesize*8,VAR_0->dest[1], VAR_0->uvlinesize, 8)\n+VAR_0->dsp.nsse[1](VAR_0, VAR_0->new_picture.f.data[2] + VAR_0->mb_x*8 + VAR_0->mb_y*VAR_0->uvlinesize*8,VAR_0->dest[2], VAR_0->uvlinesize, 8);",
"}else{",
"return VAR_0->dsp.sse[0](NULL, VAR_0->new_picture.f.data[0] + VAR_0->mb_x*16 + VAR_0->mb_y*VAR_0->linesize*16, VAR_0->dest[0], VAR_0->linesize, 16)\n+VAR_0->dsp.sse[1](NULL, VAR_0->new_picture.f.data[1] + VAR_0->mb_x*8 + VAR_0->mb_y*VAR_0->uvlinesize*8,VAR_0->dest[1], VAR_0->uvlinesize, 8)\n+VAR_0->dsp.sse[1](NULL, VAR_0->new_picture.f.data[2] + VAR_0->mb_x*8 + VAR_0->mb_y*VAR_0->uvlinesize*8,VAR_0->dest[2], VAR_0->uvlinesize, 8);",
"}",
"else\nreturn sse(VAR_0, VAR_0->new_picture.f.data[0] + VAR_0->mb_x*16 + VAR_0->mb_y*VAR_0->linesize*16, VAR_0->dest[0], VAR_1, VAR_2, VAR_0->linesize)\n+sse(VAR_0, VAR_0->new_picture.f.data[1] + VAR_0->mb_x*8 + VAR_0->mb_y*VAR_0->uvlinesize*8,VAR_0->dest[1], VAR_1>>1, VAR_2>>1, VAR_0->uvlinesize)\n+sse(VAR_0, VAR_0->new_picture.f.data[2] + VAR_0->mb_x*8 + VAR_0->mb_y*VAR_0->uvlinesize*8,VAR_0->dest[2], VAR_1>>1, VAR_2>>1, VAR_0->uvlinesize);",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
1,
0
] | [
[
1
],
[
3
],
[
5
],
[
9
],
[
11
],
[
15,
17
],
[
19,
21,
23
],
[
25
],
[
27,
29,
31
],
[
33
],
[
35,
37,
39,
41
],
[
43
]
] |
3,627 | static uint64_t alloc_cluster_offset(BlockDriverState *bs,
uint64_t offset,
int n_start, int n_end,
int *num, QCowL2Meta *m)
{
BDRVQcowState *s = bs->opaque;
int l2_index, ret;
uint64_t l2_offset, *l2_table, cluster_offset;
int nb_clusters, i = 0;
ret = get_cluster_table(bs, offset, &l2_table, &l2_offset, &l2_index);
if (ret == 0)
return 0;
nb_clusters = size_to_clusters(s, n_end << 9);
nb_clusters = MIN(nb_clusters, s->l2_size - l2_index);
cluster_offset = be64_to_cpu(l2_table[l2_index]);
/* We keep all QCOW_OFLAG_COPIED clusters */
if (cluster_offset & QCOW_OFLAG_COPIED) {
nb_clusters = count_contiguous_clusters(nb_clusters, s->cluster_size,
&l2_table[l2_index], 0);
cluster_offset &= ~QCOW_OFLAG_COPIED;
m->nb_clusters = 0;
goto out;
}
/* for the moment, multiple compressed clusters are not managed */
if (cluster_offset & QCOW_OFLAG_COMPRESSED)
nb_clusters = 1;
/* how many available clusters ? */
while (i < nb_clusters) {
i += count_contiguous_clusters(nb_clusters - i, s->cluster_size,
&l2_table[l2_index + i], 0);
if(be64_to_cpu(l2_table[l2_index + i]))
break;
i += count_contiguous_free_clusters(nb_clusters - i,
&l2_table[l2_index + i]);
cluster_offset = be64_to_cpu(l2_table[l2_index + i]);
if ((cluster_offset & QCOW_OFLAG_COPIED) ||
(cluster_offset & QCOW_OFLAG_COMPRESSED))
break;
}
nb_clusters = i;
/* allocate a new cluster */
cluster_offset = alloc_clusters(bs, nb_clusters * s->cluster_size);
/* save info needed for meta data update */
m->offset = offset;
m->n_start = n_start;
m->nb_clusters = nb_clusters;
out:
m->nb_available = MIN(nb_clusters << (s->cluster_bits - 9), n_end);
*num = m->nb_available - n_start;
return cluster_offset;
}
| true | qemu | ff4b91c2f7e51dab148aba4bf43c2f39f219e495 | static uint64_t alloc_cluster_offset(BlockDriverState *bs,
uint64_t offset,
int n_start, int n_end,
int *num, QCowL2Meta *m)
{
BDRVQcowState *s = bs->opaque;
int l2_index, ret;
uint64_t l2_offset, *l2_table, cluster_offset;
int nb_clusters, i = 0;
ret = get_cluster_table(bs, offset, &l2_table, &l2_offset, &l2_index);
if (ret == 0)
return 0;
nb_clusters = size_to_clusters(s, n_end << 9);
nb_clusters = MIN(nb_clusters, s->l2_size - l2_index);
cluster_offset = be64_to_cpu(l2_table[l2_index]);
if (cluster_offset & QCOW_OFLAG_COPIED) {
nb_clusters = count_contiguous_clusters(nb_clusters, s->cluster_size,
&l2_table[l2_index], 0);
cluster_offset &= ~QCOW_OFLAG_COPIED;
m->nb_clusters = 0;
goto out;
}
if (cluster_offset & QCOW_OFLAG_COMPRESSED)
nb_clusters = 1;
while (i < nb_clusters) {
i += count_contiguous_clusters(nb_clusters - i, s->cluster_size,
&l2_table[l2_index + i], 0);
if(be64_to_cpu(l2_table[l2_index + i]))
break;
i += count_contiguous_free_clusters(nb_clusters - i,
&l2_table[l2_index + i]);
cluster_offset = be64_to_cpu(l2_table[l2_index + i]);
if ((cluster_offset & QCOW_OFLAG_COPIED) ||
(cluster_offset & QCOW_OFLAG_COMPRESSED))
break;
}
nb_clusters = i;
cluster_offset = alloc_clusters(bs, nb_clusters * s->cluster_size);
m->offset = offset;
m->n_start = n_start;
m->nb_clusters = nb_clusters;
out:
m->nb_available = MIN(nb_clusters << (s->cluster_bits - 9), n_end);
*num = m->nb_available - n_start;
return cluster_offset;
}
| {
"code": [
" &l2_table[l2_index], 0);",
" &l2_table[l2_index + i], 0);"
],
"line_no": [
49,
83
]
} | static uint64_t FUNC_0(BlockDriverState *bs,
uint64_t offset,
int n_start, int n_end,
int *num, QCowL2Meta *m)
{
BDRVQcowState *s = bs->opaque;
int VAR_0, VAR_1;
uint64_t l2_offset, *l2_table, cluster_offset;
int VAR_2, VAR_3 = 0;
VAR_1 = get_cluster_table(bs, offset, &l2_table, &l2_offset, &VAR_0);
if (VAR_1 == 0)
return 0;
VAR_2 = size_to_clusters(s, n_end << 9);
VAR_2 = MIN(VAR_2, s->l2_size - VAR_0);
cluster_offset = be64_to_cpu(l2_table[VAR_0]);
if (cluster_offset & QCOW_OFLAG_COPIED) {
VAR_2 = count_contiguous_clusters(VAR_2, s->cluster_size,
&l2_table[VAR_0], 0);
cluster_offset &= ~QCOW_OFLAG_COPIED;
m->VAR_2 = 0;
goto out;
}
if (cluster_offset & QCOW_OFLAG_COMPRESSED)
VAR_2 = 1;
while (VAR_3 < VAR_2) {
VAR_3 += count_contiguous_clusters(VAR_2 - VAR_3, s->cluster_size,
&l2_table[VAR_0 + VAR_3], 0);
if(be64_to_cpu(l2_table[VAR_0 + VAR_3]))
break;
VAR_3 += count_contiguous_free_clusters(VAR_2 - VAR_3,
&l2_table[VAR_0 + VAR_3]);
cluster_offset = be64_to_cpu(l2_table[VAR_0 + VAR_3]);
if ((cluster_offset & QCOW_OFLAG_COPIED) ||
(cluster_offset & QCOW_OFLAG_COMPRESSED))
break;
}
VAR_2 = VAR_3;
cluster_offset = alloc_clusters(bs, VAR_2 * s->cluster_size);
m->offset = offset;
m->n_start = n_start;
m->VAR_2 = VAR_2;
out:
m->nb_available = MIN(VAR_2 << (s->cluster_bits - 9), n_end);
*num = m->nb_available - n_start;
return cluster_offset;
}
| [
"static uint64_t FUNC_0(BlockDriverState *bs,\nuint64_t offset,\nint n_start, int n_end,\nint *num, QCowL2Meta *m)\n{",
"BDRVQcowState *s = bs->opaque;",
"int VAR_0, VAR_1;",
"uint64_t l2_offset, *l2_table, cluster_offset;",
"int VAR_2, VAR_3 = 0;",
"VAR_1 = get_cluster_table(bs, offset, &l2_table, &l2_offset, &VAR_0);",
"if (VAR_1 == 0)\nreturn 0;",
"VAR_2 = size_to_clusters(s, n_end << 9);",
"VAR_2 = MIN(VAR_2, s->l2_size - VAR_0);",
"cluster_offset = be64_to_cpu(l2_table[VAR_0]);",
"if (cluster_offset & QCOW_OFLAG_COPIED) {",
"VAR_2 = count_contiguous_clusters(VAR_2, s->cluster_size,\n&l2_table[VAR_0], 0);",
"cluster_offset &= ~QCOW_OFLAG_COPIED;",
"m->VAR_2 = 0;",
"goto out;",
"}",
"if (cluster_offset & QCOW_OFLAG_COMPRESSED)\nVAR_2 = 1;",
"while (VAR_3 < VAR_2) {",
"VAR_3 += count_contiguous_clusters(VAR_2 - VAR_3, s->cluster_size,\n&l2_table[VAR_0 + VAR_3], 0);",
"if(be64_to_cpu(l2_table[VAR_0 + VAR_3]))\nbreak;",
"VAR_3 += count_contiguous_free_clusters(VAR_2 - VAR_3,\n&l2_table[VAR_0 + VAR_3]);",
"cluster_offset = be64_to_cpu(l2_table[VAR_0 + VAR_3]);",
"if ((cluster_offset & QCOW_OFLAG_COPIED) ||\n(cluster_offset & QCOW_OFLAG_COMPRESSED))\nbreak;",
"}",
"VAR_2 = VAR_3;",
"cluster_offset = alloc_clusters(bs, VAR_2 * s->cluster_size);",
"m->offset = offset;",
"m->n_start = n_start;",
"m->VAR_2 = VAR_2;",
"out:\nm->nb_available = MIN(VAR_2 << (s->cluster_bits - 9), n_end);",
"*num = m->nb_available - n_start;",
"return cluster_offset;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
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,
25
],
[
29
],
[
33
],
[
37
],
[
45
],
[
47,
49
],
[
53
],
[
55
],
[
59
],
[
61
],
[
69,
71
],
[
79
],
[
81,
83
],
[
87,
89
],
[
93,
95
],
[
99
],
[
103,
105,
107
],
[
109
],
[
111
],
[
119
],
[
125
],
[
127
],
[
129
],
[
133,
135
],
[
139
],
[
143
],
[
145
]
] |
3,628 | static int dv_extract_audio(uint8_t* frame, uint8_t* ppcm[4],
const DVprofile *sys)
{
int size, chan, i, j, d, of, smpls, freq, quant, half_ch;
uint16_t lc, rc;
const uint8_t* as_pack;
uint8_t *pcm, ipcm;
as_pack = dv_extract_pack(frame, dv_audio_source);
if (!as_pack) /* No audio ? */
return 0;
smpls = as_pack[1] & 0x3f; /* samples in this frame - min. samples */
freq = (as_pack[4] >> 3) & 0x07; /* 0 - 48kHz, 1 - 44,1kHz, 2 - 32kHz */
quant = as_pack[4] & 0x07; /* 0 - 16bit linear, 1 - 12bit nonlinear */
if (quant > 1)
return -1; /* unsupported quantization */
size = (sys->audio_min_samples[freq] + smpls) * 4; /* 2ch, 2bytes */
half_ch = sys->difseg_size / 2;
/* We work with 720p frames split in half, thus even frames have
* channels 0,1 and odd 2,3. */
ipcm = (sys->height == 720 && !(frame[1] & 0x0C)) ? 2 : 0;
pcm = ppcm[ipcm++];
/* for each DIF channel */
for (chan = 0; chan < sys->n_difchan; chan++) {
/* for each DIF segment */
for (i = 0; i < sys->difseg_size; i++) {
frame += 6 * 80; /* skip DIF segment header */
if (quant == 1 && i == half_ch) {
/* next stereo channel (12bit mode only) */
pcm = ppcm[ipcm++];
if (!pcm)
break;
}
/* for each AV sequence */
for (j = 0; j < 9; j++) {
for (d = 8; d < 80; d += 2) {
if (quant == 0) { /* 16bit quantization */
of = sys->audio_shuffle[i][j] + (d - 8) / 2 * sys->audio_stride;
if (of*2 >= size)
continue;
pcm[of*2] = frame[d+1]; // FIXME: maybe we have to admit
pcm[of*2+1] = frame[d]; // that DV is a big-endian PCM
if (pcm[of*2+1] == 0x80 && pcm[of*2] == 0x00)
pcm[of*2+1] = 0;
} else { /* 12bit quantization */
lc = ((uint16_t)frame[d] << 4) |
((uint16_t)frame[d+2] >> 4);
rc = ((uint16_t)frame[d+1] << 4) |
((uint16_t)frame[d+2] & 0x0f);
lc = (lc == 0x800 ? 0 : dv_audio_12to16(lc));
rc = (rc == 0x800 ? 0 : dv_audio_12to16(rc));
of = sys->audio_shuffle[i%half_ch][j] + (d - 8) / 3 * sys->audio_stride;
if (of*2 >= size)
continue;
pcm[of*2] = lc & 0xff; // FIXME: maybe we have to admit
pcm[of*2+1] = lc >> 8; // that DV is a big-endian PCM
of = sys->audio_shuffle[i%half_ch+half_ch][j] +
(d - 8) / 3 * sys->audio_stride;
pcm[of*2] = rc & 0xff; // FIXME: maybe we have to admit
pcm[of*2+1] = rc >> 8; // that DV is a big-endian PCM
++d;
}
}
frame += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */
}
}
/* next stereo channel (50Mbps and 100Mbps only) */
pcm = ppcm[ipcm++];
if (!pcm)
break;
}
return size;
}
| true | FFmpeg | 88d84dd8eacd4edfe29f12209f10733d631ca5ae | static int dv_extract_audio(uint8_t* frame, uint8_t* ppcm[4],
const DVprofile *sys)
{
int size, chan, i, j, d, of, smpls, freq, quant, half_ch;
uint16_t lc, rc;
const uint8_t* as_pack;
uint8_t *pcm, ipcm;
as_pack = dv_extract_pack(frame, dv_audio_source);
if (!as_pack)
return 0;
smpls = as_pack[1] & 0x3f;
freq = (as_pack[4] >> 3) & 0x07;
quant = as_pack[4] & 0x07;
if (quant > 1)
return -1;
size = (sys->audio_min_samples[freq] + smpls) * 4;
half_ch = sys->difseg_size / 2;
ipcm = (sys->height == 720 && !(frame[1] & 0x0C)) ? 2 : 0;
pcm = ppcm[ipcm++];
for (chan = 0; chan < sys->n_difchan; chan++) {
for (i = 0; i < sys->difseg_size; i++) {
frame += 6 * 80;
if (quant == 1 && i == half_ch) {
pcm = ppcm[ipcm++];
if (!pcm)
break;
}
for (j = 0; j < 9; j++) {
for (d = 8; d < 80; d += 2) {
if (quant == 0) {
of = sys->audio_shuffle[i][j] + (d - 8) / 2 * sys->audio_stride;
if (of*2 >= size)
continue;
pcm[of*2] = frame[d+1];
pcm[of*2+1] = frame[d];
if (pcm[of*2+1] == 0x80 && pcm[of*2] == 0x00)
pcm[of*2+1] = 0;
} else {
lc = ((uint16_t)frame[d] << 4) |
((uint16_t)frame[d+2] >> 4);
rc = ((uint16_t)frame[d+1] << 4) |
((uint16_t)frame[d+2] & 0x0f);
lc = (lc == 0x800 ? 0 : dv_audio_12to16(lc));
rc = (rc == 0x800 ? 0 : dv_audio_12to16(rc));
of = sys->audio_shuffle[i%half_ch][j] + (d - 8) / 3 * sys->audio_stride;
if (of*2 >= size)
continue;
pcm[of*2] = lc & 0xff;
pcm[of*2+1] = lc >> 8;
of = sys->audio_shuffle[i%half_ch+half_ch][j] +
(d - 8) / 3 * sys->audio_stride;
pcm[of*2] = rc & 0xff;
pcm[of*2+1] = rc >> 8;
++d;
}
}
frame += 16 * 80;
}
}
pcm = ppcm[ipcm++];
if (!pcm)
break;
}
return size;
}
| {
"code": [
" pcm = ppcm[ipcm++];",
" pcm = ppcm[ipcm++];",
" if (!pcm)",
" break;"
],
"line_no": [
51,
157,
159,
161
]
} | static int FUNC_0(uint8_t* VAR_0, uint8_t* VAR_1[4],
const DVprofile *VAR_2)
{
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;
uint16_t lc, rc;
const uint8_t* VAR_13;
uint8_t *pcm, ipcm;
VAR_13 = dv_extract_pack(VAR_0, dv_audio_source);
if (!VAR_13)
return 0;
VAR_9 = VAR_13[1] & 0x3f;
VAR_10 = (VAR_13[4] >> 3) & 0x07;
VAR_11 = VAR_13[4] & 0x07;
if (VAR_11 > 1)
return -1;
VAR_3 = (VAR_2->audio_min_samples[VAR_10] + VAR_9) * 4;
VAR_12 = VAR_2->difseg_size / 2;
ipcm = (VAR_2->height == 720 && !(VAR_0[1] & 0x0C)) ? 2 : 0;
pcm = VAR_1[ipcm++];
for (VAR_4 = 0; VAR_4 < VAR_2->n_difchan; VAR_4++) {
for (VAR_5 = 0; VAR_5 < VAR_2->difseg_size; VAR_5++) {
VAR_0 += 6 * 80;
if (VAR_11 == 1 && VAR_5 == VAR_12) {
pcm = VAR_1[ipcm++];
if (!pcm)
break;
}
for (VAR_6 = 0; VAR_6 < 9; VAR_6++) {
for (VAR_7 = 8; VAR_7 < 80; VAR_7 += 2) {
if (VAR_11 == 0) {
VAR_8 = VAR_2->audio_shuffle[VAR_5][VAR_6] + (VAR_7 - 8) / 2 * VAR_2->audio_stride;
if (VAR_8*2 >= VAR_3)
continue;
pcm[VAR_8*2] = VAR_0[VAR_7+1];
pcm[VAR_8*2+1] = VAR_0[VAR_7];
if (pcm[VAR_8*2+1] == 0x80 && pcm[VAR_8*2] == 0x00)
pcm[VAR_8*2+1] = 0;
} else {
lc = ((uint16_t)VAR_0[VAR_7] << 4) |
((uint16_t)VAR_0[VAR_7+2] >> 4);
rc = ((uint16_t)VAR_0[VAR_7+1] << 4) |
((uint16_t)VAR_0[VAR_7+2] & 0x0f);
lc = (lc == 0x800 ? 0 : dv_audio_12to16(lc));
rc = (rc == 0x800 ? 0 : dv_audio_12to16(rc));
VAR_8 = VAR_2->audio_shuffle[VAR_5%VAR_12][VAR_6] + (VAR_7 - 8) / 3 * VAR_2->audio_stride;
if (VAR_8*2 >= VAR_3)
continue;
pcm[VAR_8*2] = lc & 0xff;
pcm[VAR_8*2+1] = lc >> 8;
VAR_8 = VAR_2->audio_shuffle[VAR_5%VAR_12+VAR_12][VAR_6] +
(VAR_7 - 8) / 3 * VAR_2->audio_stride;
pcm[VAR_8*2] = rc & 0xff;
pcm[VAR_8*2+1] = rc >> 8;
++VAR_7;
}
}
VAR_0 += 16 * 80;
}
}
pcm = VAR_1[ipcm++];
if (!pcm)
break;
}
return VAR_3;
}
| [
"static int FUNC_0(uint8_t* VAR_0, uint8_t* VAR_1[4],\nconst DVprofile *VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;",
"uint16_t lc, rc;",
"const uint8_t* VAR_13;",
"uint8_t *pcm, ipcm;",
"VAR_13 = dv_extract_pack(VAR_0, dv_audio_source);",
"if (!VAR_13)\nreturn 0;",
"VAR_9 = VAR_13[1] & 0x3f;",
"VAR_10 = (VAR_13[4] >> 3) & 0x07;",
"VAR_11 = VAR_13[4] & 0x07;",
"if (VAR_11 > 1)\nreturn -1;",
"VAR_3 = (VAR_2->audio_min_samples[VAR_10] + VAR_9) * 4;",
"VAR_12 = VAR_2->difseg_size / 2;",
"ipcm = (VAR_2->height == 720 && !(VAR_0[1] & 0x0C)) ? 2 : 0;",
"pcm = VAR_1[ipcm++];",
"for (VAR_4 = 0; VAR_4 < VAR_2->n_difchan; VAR_4++) {",
"for (VAR_5 = 0; VAR_5 < VAR_2->difseg_size; VAR_5++) {",
"VAR_0 += 6 * 80;",
"if (VAR_11 == 1 && VAR_5 == VAR_12) {",
"pcm = VAR_1[ipcm++];",
"if (!pcm)\nbreak;",
"}",
"for (VAR_6 = 0; VAR_6 < 9; VAR_6++) {",
"for (VAR_7 = 8; VAR_7 < 80; VAR_7 += 2) {",
"if (VAR_11 == 0) {",
"VAR_8 = VAR_2->audio_shuffle[VAR_5][VAR_6] + (VAR_7 - 8) / 2 * VAR_2->audio_stride;",
"if (VAR_8*2 >= VAR_3)\ncontinue;",
"pcm[VAR_8*2] = VAR_0[VAR_7+1];",
"pcm[VAR_8*2+1] = VAR_0[VAR_7];",
"if (pcm[VAR_8*2+1] == 0x80 && pcm[VAR_8*2] == 0x00)\npcm[VAR_8*2+1] = 0;",
"} else {",
"lc = ((uint16_t)VAR_0[VAR_7] << 4) |\n((uint16_t)VAR_0[VAR_7+2] >> 4);",
"rc = ((uint16_t)VAR_0[VAR_7+1] << 4) |\n((uint16_t)VAR_0[VAR_7+2] & 0x0f);",
"lc = (lc == 0x800 ? 0 : dv_audio_12to16(lc));",
"rc = (rc == 0x800 ? 0 : dv_audio_12to16(rc));",
"VAR_8 = VAR_2->audio_shuffle[VAR_5%VAR_12][VAR_6] + (VAR_7 - 8) / 3 * VAR_2->audio_stride;",
"if (VAR_8*2 >= VAR_3)\ncontinue;",
"pcm[VAR_8*2] = lc & 0xff;",
"pcm[VAR_8*2+1] = lc >> 8;",
"VAR_8 = VAR_2->audio_shuffle[VAR_5%VAR_12+VAR_12][VAR_6] +\n(VAR_7 - 8) / 3 * VAR_2->audio_stride;",
"pcm[VAR_8*2] = rc & 0xff;",
"pcm[VAR_8*2+1] = rc >> 8;",
"++VAR_7;",
"}",
"}",
"VAR_0 += 16 * 80;",
"}",
"}",
"pcm = VAR_1[ipcm++];",
"if (!pcm)\nbreak;",
"}",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19,
21
],
[
25
],
[
27
],
[
29
],
[
33,
35
],
[
39
],
[
41
],
[
49
],
[
51
],
[
57
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71,
73
],
[
75
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89,
91
],
[
95
],
[
97
],
[
99,
101
],
[
103
],
[
105,
107
],
[
109,
111
],
[
113
],
[
115
],
[
119
],
[
121,
123
],
[
127
],
[
129
],
[
131,
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
157
],
[
159,
161
],
[
163
],
[
167
],
[
169
]
] |
3,629 | static int transcode_init(void)
{
int ret = 0, i, j, k;
AVFormatContext *oc;
AVCodecContext *codec, *icodec;
OutputStream *ost;
InputStream *ist;
char error[1024];
int want_sdp = 1;
/* init framerate emulation */
for (i = 0; i < nb_input_files; i++) {
InputFile *ifile = input_files[i];
if (ifile->rate_emu)
for (j = 0; j < ifile->nb_streams; j++)
input_streams[j + ifile->ist_index]->start = av_gettime();
}
/* output stream init */
for (i = 0; i < nb_output_files; i++) {
oc = output_files[i]->ctx;
if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) {
av_dump_format(oc, i, oc->filename, 1);
av_log(NULL, AV_LOG_ERROR, "Output file #%d does not contain any stream\n", i);
return AVERROR(EINVAL);
}
}
/* init complex filtergraphs */
for (i = 0; i < nb_filtergraphs; i++)
if ((ret = avfilter_graph_config(filtergraphs[i]->graph, NULL)) < 0)
return ret;
/* for each output stream, we compute the right encoding parameters */
for (i = 0; i < nb_output_streams; i++) {
ost = output_streams[i];
oc = output_files[ost->file_index]->ctx;
ist = get_input_stream(ost);
if (ost->attachment_filename)
continue;
codec = ost->st->codec;
if (ist) {
icodec = ist->st->codec;
ost->st->disposition = ist->st->disposition;
codec->bits_per_raw_sample = icodec->bits_per_raw_sample;
codec->chroma_sample_location = icodec->chroma_sample_location;
}
if (ost->stream_copy) {
uint64_t extra_size;
av_assert0(ist && !ost->filter);
extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE;
if (extra_size > INT_MAX) {
return AVERROR(EINVAL);
}
/* if stream_copy is selected, no need to decode or encode */
codec->codec_id = icodec->codec_id;
codec->codec_type = icodec->codec_type;
if (!codec->codec_tag) {
if (!oc->oformat->codec_tag ||
av_codec_get_id (oc->oformat->codec_tag, icodec->codec_tag) == codec->codec_id ||
av_codec_get_tag(oc->oformat->codec_tag, icodec->codec_id) <= 0)
codec->codec_tag = icodec->codec_tag;
}
codec->bit_rate = icodec->bit_rate;
codec->rc_max_rate = icodec->rc_max_rate;
codec->rc_buffer_size = icodec->rc_buffer_size;
codec->field_order = icodec->field_order;
codec->extradata = av_mallocz(extra_size);
if (!codec->extradata) {
return AVERROR(ENOMEM);
}
memcpy(codec->extradata, icodec->extradata, icodec->extradata_size);
codec->extradata_size = icodec->extradata_size;
if (!copy_tb) {
codec->time_base = icodec->time_base;
codec->time_base.num *= icodec->ticks_per_frame;
av_reduce(&codec->time_base.num, &codec->time_base.den,
codec->time_base.num, codec->time_base.den, INT_MAX);
} else
codec->time_base = ist->st->time_base;
switch (codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if (audio_volume != 256) {
av_log(NULL, AV_LOG_FATAL, "-acodec copy and -vol are incompatible (frames are not decoded)\n");
exit_program(1);
}
codec->channel_layout = icodec->channel_layout;
codec->sample_rate = icodec->sample_rate;
codec->channels = icodec->channels;
codec->frame_size = icodec->frame_size;
codec->audio_service_type = icodec->audio_service_type;
codec->block_align = icodec->block_align;
break;
case AVMEDIA_TYPE_VIDEO:
codec->pix_fmt = icodec->pix_fmt;
codec->width = icodec->width;
codec->height = icodec->height;
codec->has_b_frames = icodec->has_b_frames;
if (!codec->sample_aspect_ratio.num) {
codec->sample_aspect_ratio =
ost->st->sample_aspect_ratio =
ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio :
ist->st->codec->sample_aspect_ratio.num ?
ist->st->codec->sample_aspect_ratio : (AVRational){0, 1};
}
break;
case AVMEDIA_TYPE_SUBTITLE:
codec->width = icodec->width;
codec->height = icodec->height;
break;
case AVMEDIA_TYPE_DATA:
case AVMEDIA_TYPE_ATTACHMENT:
break;
default:
abort();
}
} else {
if (!ost->enc) {
/* should only happen when a default codec is not present. */
snprintf(error, sizeof(error), "Automatic encoder selection "
"failed for output stream #%d:%d. Default encoder for "
"format %s is probably disabled. Please choose an "
"encoder manually.\n", ost->file_index, ost->index,
oc->oformat->name);
ret = AVERROR(EINVAL);
goto dump_format;
}
if (ist)
ist->decoding_needed = 1;
ost->encoding_needed = 1;
switch (codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
ost->fifo = av_fifo_alloc(1024);
if (!ost->fifo) {
return AVERROR(ENOMEM);
}
if (!codec->sample_rate)
codec->sample_rate = icodec->sample_rate;
choose_sample_rate(ost->st, ost->enc);
codec->time_base = (AVRational){ 1, codec->sample_rate };
if (codec->sample_fmt == AV_SAMPLE_FMT_NONE)
codec->sample_fmt = icodec->sample_fmt;
choose_sample_fmt(ost->st, ost->enc);
if (!codec->channels)
codec->channels = icodec->channels;
if (!codec->channel_layout)
codec->channel_layout = icodec->channel_layout;
if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels)
codec->channel_layout = 0;
icodec->request_channels = codec-> channels;
ost->resample_sample_fmt = icodec->sample_fmt;
ost->resample_sample_rate = icodec->sample_rate;
ost->resample_channels = icodec->channels;
ost->resample_channel_layout = icodec->channel_layout;
break;
case AVMEDIA_TYPE_VIDEO:
if (!ost->filter) {
FilterGraph *fg;
fg = init_simple_filtergraph(ist, ost);
if (configure_video_filters(fg)) {
av_log(NULL, AV_LOG_FATAL, "Error opening filters!\n");
exit(1);
}
}
/*
* We want CFR output if and only if one of those is true:
* 1) user specified output framerate with -r
* 2) user specified -vsync cfr
* 3) output format is CFR and the user didn't force vsync to
* something else than CFR
*
* in such a case, set ost->frame_rate
*/
if (!ost->frame_rate.num && ist &&
(video_sync_method == VSYNC_CFR ||
(video_sync_method == VSYNC_AUTO &&
!(oc->oformat->flags & (AVFMT_NOTIMESTAMPS | AVFMT_VARIABLE_FPS))))) {
ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25, 1};
if (ost->enc && ost->enc->supported_framerates && !ost->force_fps) {
int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates);
ost->frame_rate = ost->enc->supported_framerates[idx];
}
}
if (ost->frame_rate.num) {
codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num};
video_sync_method = VSYNC_CFR;
} else if (ist)
codec->time_base = ist->st->time_base;
else
codec->time_base = ost->filter->filter->inputs[0]->time_base;
codec->width = ost->filter->filter->inputs[0]->w;
codec->height = ost->filter->filter->inputs[0]->h;
codec->sample_aspect_ratio = ost->st->sample_aspect_ratio =
ost->frame_aspect_ratio ? // overridden by the -aspect cli option
av_d2q(ost->frame_aspect_ratio * codec->height/codec->width, 255) :
ost->filter->filter->inputs[0]->sample_aspect_ratio;
codec->pix_fmt = ost->filter->filter->inputs[0]->format;
if (codec->width != icodec->width ||
codec->height != icodec->height ||
codec->pix_fmt != icodec->pix_fmt) {
codec->bits_per_raw_sample = 0;
}
break;
case AVMEDIA_TYPE_SUBTITLE:
codec->time_base = (AVRational){1, 1000};
break;
default:
abort();
break;
}
/* two pass mode */
if ((codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {
char logfilename[1024];
FILE *f;
snprintf(logfilename, sizeof(logfilename), "%s-%d.log",
pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX,
i);
if (!strcmp(ost->enc->name, "libx264")) {
av_dict_set(&ost->opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE);
} else {
if (codec->flags & CODEC_FLAG_PASS1) {
f = fopen(logfilename, "wb");
if (!f) {
av_log(NULL, AV_LOG_FATAL, "Cannot write log file '%s' for pass-1 encoding: %s\n",
logfilename, strerror(errno));
exit_program(1);
}
ost->logfile = f;
} else {
char *logbuffer;
size_t logbuffer_size;
if (cmdutils_read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {
av_log(NULL, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n",
logfilename);
exit_program(1);
}
codec->stats_in = logbuffer;
}
}
}
}
}
/* open each encoder */
for (i = 0; i < nb_output_streams; i++) {
ost = output_streams[i];
if (ost->encoding_needed) {
AVCodec *codec = ost->enc;
AVCodecContext *dec = NULL;
if ((ist = get_input_stream(ost)))
dec = ist->st->codec;
if (dec && dec->subtitle_header) {
ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size);
if (!ost->st->codec->subtitle_header) {
ret = AVERROR(ENOMEM);
goto dump_format;
}
memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);
ost->st->codec->subtitle_header_size = dec->subtitle_header_size;
}
if (!av_dict_get(ost->opts, "threads", NULL, 0))
av_dict_set(&ost->opts, "threads", "auto", 0);
if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) {
snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d:%d - maybe incorrect parameters such as bit_rate, rate, width or height",
ost->file_index, ost->index);
ret = AVERROR(EINVAL);
goto dump_format;
}
assert_codec_experimental(ost->st->codec, 1);
assert_avoptions(ost->opts);
if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000)
av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low."
"It takes bits/s as argument, not kbits/s\n");
extra_size += ost->st->codec->extradata_size;
if (ost->st->codec->me_threshold)
input_streams[ost->source_index]->st->codec->debug |= FF_DEBUG_MV;
}
}
/* init input streams */
for (i = 0; i < nb_input_streams; i++)
if ((ret = init_input_stream(i, error, sizeof(error))) < 0)
goto dump_format;
/* discard unused programs */
for (i = 0; i < nb_input_files; i++) {
InputFile *ifile = input_files[i];
for (j = 0; j < ifile->ctx->nb_programs; j++) {
AVProgram *p = ifile->ctx->programs[j];
int discard = AVDISCARD_ALL;
for (k = 0; k < p->nb_stream_indexes; k++)
if (!input_streams[ifile->ist_index + p->stream_index[k]]->discard) {
discard = AVDISCARD_DEFAULT;
break;
}
p->discard = discard;
}
}
/* open files and write file headers */
for (i = 0; i < nb_output_files; i++) {
oc = output_files[i]->ctx;
oc->interrupt_callback = int_cb;
if (avformat_write_header(oc, &output_files[i]->opts) < 0) {
snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i);
ret = AVERROR(EINVAL);
goto dump_format;
}
assert_avoptions(output_files[i]->opts);
if (strcmp(oc->oformat->name, "rtp")) {
want_sdp = 0;
}
}
dump_format:
/* dump the file output parameters - cannot be done before in case
of stream copy */
for (i = 0; i < nb_output_files; i++) {
av_dump_format(output_files[i]->ctx, i, output_files[i]->ctx->filename, 1);
}
/* dump the stream mapping */
av_log(NULL, AV_LOG_INFO, "Stream mapping:\n");
for (i = 0; i < nb_input_streams; i++) {
ist = input_streams[i];
for (j = 0; j < ist->nb_filters; j++) {
AVFilterLink *link = ist->filters[j]->filter->outputs[0];
if (ist->filters[j]->graph->graph_desc) {
av_log(NULL, AV_LOG_INFO, " Stream #%d:%d (%s) -> %s",
ist->file_index, ist->st->index, ist->dec ? ist->dec->name : "?",
link->dst->filter->name);
if (link->dst->input_count > 1)
av_log(NULL, AV_LOG_INFO, ":%s", link->dstpad->name);
if (nb_filtergraphs > 1)
av_log(NULL, AV_LOG_INFO, " (graph %d)", ist->filters[j]->graph->index);
av_log(NULL, AV_LOG_INFO, "\n");
}
}
}
for (i = 0; i < nb_output_streams; i++) {
ost = output_streams[i];
if (ost->attachment_filename) {
/* an attached file */
av_log(NULL, AV_LOG_INFO, " File %s -> Stream #%d:%d\n",
ost->attachment_filename, ost->file_index, ost->index);
continue;
}
if (ost->filter && ost->filter->graph->graph_desc) {
/* output from a complex graph */
AVFilterLink *link = ost->filter->filter->inputs[0];
av_log(NULL, AV_LOG_INFO, " %s", link->src->filter->name);
if (link->src->output_count > 1)
av_log(NULL, AV_LOG_INFO, ":%s", link->srcpad->name);
if (nb_filtergraphs > 1)
av_log(NULL, AV_LOG_INFO, " (graph %d)", ost->filter->graph->index);
av_log(NULL, AV_LOG_INFO, " -> Stream #%d:%d (%s)\n", ost->file_index,
ost->index, ost->enc ? ost->enc->name : "?");
continue;
}
av_log(NULL, AV_LOG_INFO, " Stream #%d:%d -> #%d:%d",
input_streams[ost->source_index]->file_index,
input_streams[ost->source_index]->st->index,
ost->file_index,
ost->index);
if (ost->sync_ist != input_streams[ost->source_index])
av_log(NULL, AV_LOG_INFO, " [sync #%d:%d]",
ost->sync_ist->file_index,
ost->sync_ist->st->index);
if (ost->stream_copy)
av_log(NULL, AV_LOG_INFO, " (copy)");
else
av_log(NULL, AV_LOG_INFO, " (%s -> %s)", input_streams[ost->source_index]->dec ?
input_streams[ost->source_index]->dec->name : "?",
ost->enc ? ost->enc->name : "?");
av_log(NULL, AV_LOG_INFO, "\n");
}
if (ret) {
av_log(NULL, AV_LOG_ERROR, "%s\n", error);
return ret;
}
if (want_sdp) {
print_sdp();
}
return 0;
}
| true | FFmpeg | 369cb092ecbbaff20bb0a2a1d60536c3bc04a8f0 | static int transcode_init(void)
{
int ret = 0, i, j, k;
AVFormatContext *oc;
AVCodecContext *codec, *icodec;
OutputStream *ost;
InputStream *ist;
char error[1024];
int want_sdp = 1;
for (i = 0; i < nb_input_files; i++) {
InputFile *ifile = input_files[i];
if (ifile->rate_emu)
for (j = 0; j < ifile->nb_streams; j++)
input_streams[j + ifile->ist_index]->start = av_gettime();
}
for (i = 0; i < nb_output_files; i++) {
oc = output_files[i]->ctx;
if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) {
av_dump_format(oc, i, oc->filename, 1);
av_log(NULL, AV_LOG_ERROR, "Output file #%d does not contain any stream\n", i);
return AVERROR(EINVAL);
}
}
for (i = 0; i < nb_filtergraphs; i++)
if ((ret = avfilter_graph_config(filtergraphs[i]->graph, NULL)) < 0)
return ret;
for (i = 0; i < nb_output_streams; i++) {
ost = output_streams[i];
oc = output_files[ost->file_index]->ctx;
ist = get_input_stream(ost);
if (ost->attachment_filename)
continue;
codec = ost->st->codec;
if (ist) {
icodec = ist->st->codec;
ost->st->disposition = ist->st->disposition;
codec->bits_per_raw_sample = icodec->bits_per_raw_sample;
codec->chroma_sample_location = icodec->chroma_sample_location;
}
if (ost->stream_copy) {
uint64_t extra_size;
av_assert0(ist && !ost->filter);
extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE;
if (extra_size > INT_MAX) {
return AVERROR(EINVAL);
}
codec->codec_id = icodec->codec_id;
codec->codec_type = icodec->codec_type;
if (!codec->codec_tag) {
if (!oc->oformat->codec_tag ||
av_codec_get_id (oc->oformat->codec_tag, icodec->codec_tag) == codec->codec_id ||
av_codec_get_tag(oc->oformat->codec_tag, icodec->codec_id) <= 0)
codec->codec_tag = icodec->codec_tag;
}
codec->bit_rate = icodec->bit_rate;
codec->rc_max_rate = icodec->rc_max_rate;
codec->rc_buffer_size = icodec->rc_buffer_size;
codec->field_order = icodec->field_order;
codec->extradata = av_mallocz(extra_size);
if (!codec->extradata) {
return AVERROR(ENOMEM);
}
memcpy(codec->extradata, icodec->extradata, icodec->extradata_size);
codec->extradata_size = icodec->extradata_size;
if (!copy_tb) {
codec->time_base = icodec->time_base;
codec->time_base.num *= icodec->ticks_per_frame;
av_reduce(&codec->time_base.num, &codec->time_base.den,
codec->time_base.num, codec->time_base.den, INT_MAX);
} else
codec->time_base = ist->st->time_base;
switch (codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if (audio_volume != 256) {
av_log(NULL, AV_LOG_FATAL, "-acodec copy and -vol are incompatible (frames are not decoded)\n");
exit_program(1);
}
codec->channel_layout = icodec->channel_layout;
codec->sample_rate = icodec->sample_rate;
codec->channels = icodec->channels;
codec->frame_size = icodec->frame_size;
codec->audio_service_type = icodec->audio_service_type;
codec->block_align = icodec->block_align;
break;
case AVMEDIA_TYPE_VIDEO:
codec->pix_fmt = icodec->pix_fmt;
codec->width = icodec->width;
codec->height = icodec->height;
codec->has_b_frames = icodec->has_b_frames;
if (!codec->sample_aspect_ratio.num) {
codec->sample_aspect_ratio =
ost->st->sample_aspect_ratio =
ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio :
ist->st->codec->sample_aspect_ratio.num ?
ist->st->codec->sample_aspect_ratio : (AVRational){0, 1};
}
break;
case AVMEDIA_TYPE_SUBTITLE:
codec->width = icodec->width;
codec->height = icodec->height;
break;
case AVMEDIA_TYPE_DATA:
case AVMEDIA_TYPE_ATTACHMENT:
break;
default:
abort();
}
} else {
if (!ost->enc) {
snprintf(error, sizeof(error), "Automatic encoder selection "
"failed for output stream #%d:%d. Default encoder for "
"format %s is probably disabled. Please choose an "
"encoder manually.\n", ost->file_index, ost->index,
oc->oformat->name);
ret = AVERROR(EINVAL);
goto dump_format;
}
if (ist)
ist->decoding_needed = 1;
ost->encoding_needed = 1;
switch (codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
ost->fifo = av_fifo_alloc(1024);
if (!ost->fifo) {
return AVERROR(ENOMEM);
}
if (!codec->sample_rate)
codec->sample_rate = icodec->sample_rate;
choose_sample_rate(ost->st, ost->enc);
codec->time_base = (AVRational){ 1, codec->sample_rate };
if (codec->sample_fmt == AV_SAMPLE_FMT_NONE)
codec->sample_fmt = icodec->sample_fmt;
choose_sample_fmt(ost->st, ost->enc);
if (!codec->channels)
codec->channels = icodec->channels;
if (!codec->channel_layout)
codec->channel_layout = icodec->channel_layout;
if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels)
codec->channel_layout = 0;
icodec->request_channels = codec-> channels;
ost->resample_sample_fmt = icodec->sample_fmt;
ost->resample_sample_rate = icodec->sample_rate;
ost->resample_channels = icodec->channels;
ost->resample_channel_layout = icodec->channel_layout;
break;
case AVMEDIA_TYPE_VIDEO:
if (!ost->filter) {
FilterGraph *fg;
fg = init_simple_filtergraph(ist, ost);
if (configure_video_filters(fg)) {
av_log(NULL, AV_LOG_FATAL, "Error opening filters!\n");
exit(1);
}
}
if (!ost->frame_rate.num && ist &&
(video_sync_method == VSYNC_CFR ||
(video_sync_method == VSYNC_AUTO &&
!(oc->oformat->flags & (AVFMT_NOTIMESTAMPS | AVFMT_VARIABLE_FPS))))) {
ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25, 1};
if (ost->enc && ost->enc->supported_framerates && !ost->force_fps) {
int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates);
ost->frame_rate = ost->enc->supported_framerates[idx];
}
}
if (ost->frame_rate.num) {
codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num};
video_sync_method = VSYNC_CFR;
} else if (ist)
codec->time_base = ist->st->time_base;
else
codec->time_base = ost->filter->filter->inputs[0]->time_base;
codec->width = ost->filter->filter->inputs[0]->w;
codec->height = ost->filter->filter->inputs[0]->h;
codec->sample_aspect_ratio = ost->st->sample_aspect_ratio =
ost->frame_aspect_ratio ?
av_d2q(ost->frame_aspect_ratio * codec->height/codec->width, 255) :
ost->filter->filter->inputs[0]->sample_aspect_ratio;
codec->pix_fmt = ost->filter->filter->inputs[0]->format;
if (codec->width != icodec->width ||
codec->height != icodec->height ||
codec->pix_fmt != icodec->pix_fmt) {
codec->bits_per_raw_sample = 0;
}
break;
case AVMEDIA_TYPE_SUBTITLE:
codec->time_base = (AVRational){1, 1000};
break;
default:
abort();
break;
}
if ((codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {
char logfilename[1024];
FILE *f;
snprintf(logfilename, sizeof(logfilename), "%s-%d.log",
pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX,
i);
if (!strcmp(ost->enc->name, "libx264")) {
av_dict_set(&ost->opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE);
} else {
if (codec->flags & CODEC_FLAG_PASS1) {
f = fopen(logfilename, "wb");
if (!f) {
av_log(NULL, AV_LOG_FATAL, "Cannot write log file '%s' for pass-1 encoding: %s\n",
logfilename, strerror(errno));
exit_program(1);
}
ost->logfile = f;
} else {
char *logbuffer;
size_t logbuffer_size;
if (cmdutils_read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {
av_log(NULL, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n",
logfilename);
exit_program(1);
}
codec->stats_in = logbuffer;
}
}
}
}
}
for (i = 0; i < nb_output_streams; i++) {
ost = output_streams[i];
if (ost->encoding_needed) {
AVCodec *codec = ost->enc;
AVCodecContext *dec = NULL;
if ((ist = get_input_stream(ost)))
dec = ist->st->codec;
if (dec && dec->subtitle_header) {
ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size);
if (!ost->st->codec->subtitle_header) {
ret = AVERROR(ENOMEM);
goto dump_format;
}
memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);
ost->st->codec->subtitle_header_size = dec->subtitle_header_size;
}
if (!av_dict_get(ost->opts, "threads", NULL, 0))
av_dict_set(&ost->opts, "threads", "auto", 0);
if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) {
snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d:%d - maybe incorrect parameters such as bit_rate, rate, width or height",
ost->file_index, ost->index);
ret = AVERROR(EINVAL);
goto dump_format;
}
assert_codec_experimental(ost->st->codec, 1);
assert_avoptions(ost->opts);
if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000)
av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low."
"It takes bits/s as argument, not kbits/s\n");
extra_size += ost->st->codec->extradata_size;
if (ost->st->codec->me_threshold)
input_streams[ost->source_index]->st->codec->debug |= FF_DEBUG_MV;
}
}
for (i = 0; i < nb_input_streams; i++)
if ((ret = init_input_stream(i, error, sizeof(error))) < 0)
goto dump_format;
for (i = 0; i < nb_input_files; i++) {
InputFile *ifile = input_files[i];
for (j = 0; j < ifile->ctx->nb_programs; j++) {
AVProgram *p = ifile->ctx->programs[j];
int discard = AVDISCARD_ALL;
for (k = 0; k < p->nb_stream_indexes; k++)
if (!input_streams[ifile->ist_index + p->stream_index[k]]->discard) {
discard = AVDISCARD_DEFAULT;
break;
}
p->discard = discard;
}
}
for (i = 0; i < nb_output_files; i++) {
oc = output_files[i]->ctx;
oc->interrupt_callback = int_cb;
if (avformat_write_header(oc, &output_files[i]->opts) < 0) {
snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i);
ret = AVERROR(EINVAL);
goto dump_format;
}
assert_avoptions(output_files[i]->opts);
if (strcmp(oc->oformat->name, "rtp")) {
want_sdp = 0;
}
}
dump_format:
for (i = 0; i < nb_output_files; i++) {
av_dump_format(output_files[i]->ctx, i, output_files[i]->ctx->filename, 1);
}
av_log(NULL, AV_LOG_INFO, "Stream mapping:\n");
for (i = 0; i < nb_input_streams; i++) {
ist = input_streams[i];
for (j = 0; j < ist->nb_filters; j++) {
AVFilterLink *link = ist->filters[j]->filter->outputs[0];
if (ist->filters[j]->graph->graph_desc) {
av_log(NULL, AV_LOG_INFO, " Stream #%d:%d (%s) -> %s",
ist->file_index, ist->st->index, ist->dec ? ist->dec->name : "?",
link->dst->filter->name);
if (link->dst->input_count > 1)
av_log(NULL, AV_LOG_INFO, ":%s", link->dstpad->name);
if (nb_filtergraphs > 1)
av_log(NULL, AV_LOG_INFO, " (graph %d)", ist->filters[j]->graph->index);
av_log(NULL, AV_LOG_INFO, "\n");
}
}
}
for (i = 0; i < nb_output_streams; i++) {
ost = output_streams[i];
if (ost->attachment_filename) {
av_log(NULL, AV_LOG_INFO, " File %s -> Stream #%d:%d\n",
ost->attachment_filename, ost->file_index, ost->index);
continue;
}
if (ost->filter && ost->filter->graph->graph_desc) {
AVFilterLink *link = ost->filter->filter->inputs[0];
av_log(NULL, AV_LOG_INFO, " %s", link->src->filter->name);
if (link->src->output_count > 1)
av_log(NULL, AV_LOG_INFO, ":%s", link->srcpad->name);
if (nb_filtergraphs > 1)
av_log(NULL, AV_LOG_INFO, " (graph %d)", ost->filter->graph->index);
av_log(NULL, AV_LOG_INFO, " -> Stream #%d:%d (%s)\n", ost->file_index,
ost->index, ost->enc ? ost->enc->name : "?");
continue;
}
av_log(NULL, AV_LOG_INFO, " Stream #%d:%d -> #%d:%d",
input_streams[ost->source_index]->file_index,
input_streams[ost->source_index]->st->index,
ost->file_index,
ost->index);
if (ost->sync_ist != input_streams[ost->source_index])
av_log(NULL, AV_LOG_INFO, " [sync #%d:%d]",
ost->sync_ist->file_index,
ost->sync_ist->st->index);
if (ost->stream_copy)
av_log(NULL, AV_LOG_INFO, " (copy)");
else
av_log(NULL, AV_LOG_INFO, " (%s -> %s)", input_streams[ost->source_index]->dec ?
input_streams[ost->source_index]->dec->name : "?",
ost->enc ? ost->enc->name : "?");
av_log(NULL, AV_LOG_INFO, "\n");
}
if (ret) {
av_log(NULL, AV_LOG_ERROR, "%s\n", error);
return ret;
}
if (want_sdp) {
print_sdp();
}
return 0;
}
| {
"code": [
" break;",
" } else {",
" } else {",
" return 0;",
" exit_program(1);",
" } else {",
" } else {",
" break;",
" default:",
" for (i = 0; i < nb_output_streams; i++) {",
" continue;",
" break;",
" switch (codec->codec_type) {",
" case AVMEDIA_TYPE_AUDIO:",
" ost->fifo = av_fifo_alloc(1024);",
" if (!ost->fifo) {",
" return AVERROR(ENOMEM);",
" if (!codec->sample_rate)",
" codec->sample_rate = icodec->sample_rate;",
" choose_sample_rate(ost->st, ost->enc);",
" codec->time_base = (AVRational){ 1, codec->sample_rate };",
" if (codec->sample_fmt == AV_SAMPLE_FMT_NONE)",
" codec->sample_fmt = icodec->sample_fmt;",
" choose_sample_fmt(ost->st, ost->enc);",
" if (!codec->channels)",
" codec->channels = icodec->channels;",
" if (!codec->channel_layout)",
" codec->channel_layout = icodec->channel_layout;",
" if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels)",
" codec->channel_layout = 0;",
" icodec->request_channels = codec-> channels;",
" ost->resample_sample_fmt = icodec->sample_fmt;",
" ost->resample_sample_rate = icodec->sample_rate;",
" ost->resample_channels = icodec->channels;",
" ost->resample_channel_layout = icodec->channel_layout;",
" break;",
" case AVMEDIA_TYPE_VIDEO:",
" if (!ost->filter) {",
" if (configure_video_filters(fg)) {"
],
"line_no": [
209,
257,
257,
837,
193,
485,
485,
209,
251,
69,
81,
639,
185,
187,
293,
295,
297,
303,
305,
307,
309,
313,
315,
317,
321,
323,
325,
327,
329,
331,
335,
337,
339,
341,
343,
209,
211,
349,
355
]
} | static int FUNC_0(void)
{
int VAR_0 = 0, VAR_1, VAR_2, VAR_3;
AVFormatContext *oc;
AVCodecContext *codec, *icodec;
OutputStream *ost;
InputStream *ist;
char VAR_4[1024];
int VAR_5 = 1;
for (VAR_1 = 0; VAR_1 < nb_input_files; VAR_1++) {
InputFile *ifile = input_files[VAR_1];
if (ifile->rate_emu)
for (VAR_2 = 0; VAR_2 < ifile->nb_streams; VAR_2++)
input_streams[VAR_2 + ifile->ist_index]->start = av_gettime();
}
for (VAR_1 = 0; VAR_1 < nb_output_files; VAR_1++) {
oc = output_files[VAR_1]->ctx;
if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) {
av_dump_format(oc, VAR_1, oc->filename, 1);
av_log(NULL, AV_LOG_ERROR, "Output file #%d does not contain any stream\n", VAR_1);
return AVERROR(EINVAL);
}
}
for (VAR_1 = 0; VAR_1 < nb_filtergraphs; VAR_1++)
if ((VAR_0 = avfilter_graph_config(filtergraphs[VAR_1]->graph, NULL)) < 0)
return VAR_0;
for (VAR_1 = 0; VAR_1 < nb_output_streams; VAR_1++) {
ost = output_streams[VAR_1];
oc = output_files[ost->file_index]->ctx;
ist = get_input_stream(ost);
if (ost->attachment_filename)
continue;
codec = ost->st->codec;
if (ist) {
icodec = ist->st->codec;
ost->st->disposition = ist->st->disposition;
codec->bits_per_raw_sample = icodec->bits_per_raw_sample;
codec->chroma_sample_location = icodec->chroma_sample_location;
}
if (ost->stream_copy) {
uint64_t extra_size;
av_assert0(ist && !ost->filter);
extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE;
if (extra_size > INT_MAX) {
return AVERROR(EINVAL);
}
codec->codec_id = icodec->codec_id;
codec->codec_type = icodec->codec_type;
if (!codec->codec_tag) {
if (!oc->oformat->codec_tag ||
av_codec_get_id (oc->oformat->codec_tag, icodec->codec_tag) == codec->codec_id ||
av_codec_get_tag(oc->oformat->codec_tag, icodec->codec_id) <= 0)
codec->codec_tag = icodec->codec_tag;
}
codec->bit_rate = icodec->bit_rate;
codec->rc_max_rate = icodec->rc_max_rate;
codec->rc_buffer_size = icodec->rc_buffer_size;
codec->field_order = icodec->field_order;
codec->extradata = av_mallocz(extra_size);
if (!codec->extradata) {
return AVERROR(ENOMEM);
}
memcpy(codec->extradata, icodec->extradata, icodec->extradata_size);
codec->extradata_size = icodec->extradata_size;
if (!copy_tb) {
codec->time_base = icodec->time_base;
codec->time_base.num *= icodec->ticks_per_frame;
av_reduce(&codec->time_base.num, &codec->time_base.den,
codec->time_base.num, codec->time_base.den, INT_MAX);
} else
codec->time_base = ist->st->time_base;
switch (codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if (audio_volume != 256) {
av_log(NULL, AV_LOG_FATAL, "-acodec copy and -vol are incompatible (frames are not decoded)\n");
exit_program(1);
}
codec->channel_layout = icodec->channel_layout;
codec->sample_rate = icodec->sample_rate;
codec->channels = icodec->channels;
codec->frame_size = icodec->frame_size;
codec->audio_service_type = icodec->audio_service_type;
codec->block_align = icodec->block_align;
break;
case AVMEDIA_TYPE_VIDEO:
codec->pix_fmt = icodec->pix_fmt;
codec->width = icodec->width;
codec->height = icodec->height;
codec->has_b_frames = icodec->has_b_frames;
if (!codec->sample_aspect_ratio.num) {
codec->sample_aspect_ratio =
ost->st->sample_aspect_ratio =
ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio :
ist->st->codec->sample_aspect_ratio.num ?
ist->st->codec->sample_aspect_ratio : (AVRational){0, 1};
}
break;
case AVMEDIA_TYPE_SUBTITLE:
codec->width = icodec->width;
codec->height = icodec->height;
break;
case AVMEDIA_TYPE_DATA:
case AVMEDIA_TYPE_ATTACHMENT:
break;
default:
abort();
}
} else {
if (!ost->enc) {
snprintf(VAR_4, sizeof(VAR_4), "Automatic encoder selection "
"failed for output stream #%d:%d. Default encoder for "
"format %s is probably disabled. Please choose an "
"encoder manually.\n", ost->file_index, ost->index,
oc->oformat->name);
VAR_0 = AVERROR(EINVAL);
goto dump_format;
}
if (ist)
ist->decoding_needed = 1;
ost->encoding_needed = 1;
switch (codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
ost->fifo = av_fifo_alloc(1024);
if (!ost->fifo) {
return AVERROR(ENOMEM);
}
if (!codec->sample_rate)
codec->sample_rate = icodec->sample_rate;
choose_sample_rate(ost->st, ost->enc);
codec->time_base = (AVRational){ 1, codec->sample_rate };
if (codec->sample_fmt == AV_SAMPLE_FMT_NONE)
codec->sample_fmt = icodec->sample_fmt;
choose_sample_fmt(ost->st, ost->enc);
if (!codec->channels)
codec->channels = icodec->channels;
if (!codec->channel_layout)
codec->channel_layout = icodec->channel_layout;
if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels)
codec->channel_layout = 0;
icodec->request_channels = codec-> channels;
ost->resample_sample_fmt = icodec->sample_fmt;
ost->resample_sample_rate = icodec->sample_rate;
ost->resample_channels = icodec->channels;
ost->resample_channel_layout = icodec->channel_layout;
break;
case AVMEDIA_TYPE_VIDEO:
if (!ost->filter) {
FilterGraph *fg;
fg = init_simple_filtergraph(ist, ost);
if (configure_video_filters(fg)) {
av_log(NULL, AV_LOG_FATAL, "Error opening filters!\n");
exit(1);
}
}
if (!ost->frame_rate.num && ist &&
(video_sync_method == VSYNC_CFR ||
(video_sync_method == VSYNC_AUTO &&
!(oc->oformat->flags & (AVFMT_NOTIMESTAMPS | AVFMT_VARIABLE_FPS))))) {
ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25, 1};
if (ost->enc && ost->enc->supported_framerates && !ost->force_fps) {
int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates);
ost->frame_rate = ost->enc->supported_framerates[idx];
}
}
if (ost->frame_rate.num) {
codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num};
video_sync_method = VSYNC_CFR;
} else if (ist)
codec->time_base = ist->st->time_base;
else
codec->time_base = ost->filter->filter->inputs[0]->time_base;
codec->width = ost->filter->filter->inputs[0]->w;
codec->height = ost->filter->filter->inputs[0]->h;
codec->sample_aspect_ratio = ost->st->sample_aspect_ratio =
ost->frame_aspect_ratio ?
av_d2q(ost->frame_aspect_ratio * codec->height/codec->width, 255) :
ost->filter->filter->inputs[0]->sample_aspect_ratio;
codec->pix_fmt = ost->filter->filter->inputs[0]->format;
if (codec->width != icodec->width ||
codec->height != icodec->height ||
codec->pix_fmt != icodec->pix_fmt) {
codec->bits_per_raw_sample = 0;
}
break;
case AVMEDIA_TYPE_SUBTITLE:
codec->time_base = (AVRational){1, 1000};
break;
default:
abort();
break;
}
if ((codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {
char logfilename[1024];
FILE *f;
snprintf(logfilename, sizeof(logfilename), "%s-%d.log",
pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX,
VAR_1);
if (!strcmp(ost->enc->name, "libx264")) {
av_dict_set(&ost->opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE);
} else {
if (codec->flags & CODEC_FLAG_PASS1) {
f = fopen(logfilename, "wb");
if (!f) {
av_log(NULL, AV_LOG_FATAL, "Cannot write log file '%s' for pass-1 encoding: %s\n",
logfilename, strerror(errno));
exit_program(1);
}
ost->logfile = f;
} else {
char *logbuffer;
size_t logbuffer_size;
if (cmdutils_read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {
av_log(NULL, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n",
logfilename);
exit_program(1);
}
codec->stats_in = logbuffer;
}
}
}
}
}
for (VAR_1 = 0; VAR_1 < nb_output_streams; VAR_1++) {
ost = output_streams[VAR_1];
if (ost->encoding_needed) {
AVCodec *codec = ost->enc;
AVCodecContext *dec = NULL;
if ((ist = get_input_stream(ost)))
dec = ist->st->codec;
if (dec && dec->subtitle_header) {
ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size);
if (!ost->st->codec->subtitle_header) {
VAR_0 = AVERROR(ENOMEM);
goto dump_format;
}
memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);
ost->st->codec->subtitle_header_size = dec->subtitle_header_size;
}
if (!av_dict_get(ost->opts, "threads", NULL, 0))
av_dict_set(&ost->opts, "threads", "auto", 0);
if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) {
snprintf(VAR_4, sizeof(VAR_4), "Error while opening encoder for output stream #%d:%d - maybe incorrect parameters such as bit_rate, rate, width or height",
ost->file_index, ost->index);
VAR_0 = AVERROR(EINVAL);
goto dump_format;
}
assert_codec_experimental(ost->st->codec, 1);
assert_avoptions(ost->opts);
if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000)
av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low."
"It takes bits/s as argument, not kbits/s\n");
extra_size += ost->st->codec->extradata_size;
if (ost->st->codec->me_threshold)
input_streams[ost->source_index]->st->codec->debug |= FF_DEBUG_MV;
}
}
for (VAR_1 = 0; VAR_1 < nb_input_streams; VAR_1++)
if ((VAR_0 = init_input_stream(VAR_1, VAR_4, sizeof(VAR_4))) < 0)
goto dump_format;
for (VAR_1 = 0; VAR_1 < nb_input_files; VAR_1++) {
InputFile *ifile = input_files[VAR_1];
for (VAR_2 = 0; VAR_2 < ifile->ctx->nb_programs; VAR_2++) {
AVProgram *p = ifile->ctx->programs[VAR_2];
int discard = AVDISCARD_ALL;
for (VAR_3 = 0; VAR_3 < p->nb_stream_indexes; VAR_3++)
if (!input_streams[ifile->ist_index + p->stream_index[VAR_3]]->discard) {
discard = AVDISCARD_DEFAULT;
break;
}
p->discard = discard;
}
}
for (VAR_1 = 0; VAR_1 < nb_output_files; VAR_1++) {
oc = output_files[VAR_1]->ctx;
oc->interrupt_callback = int_cb;
if (avformat_write_header(oc, &output_files[VAR_1]->opts) < 0) {
snprintf(VAR_4, sizeof(VAR_4), "Could not write header for output file #%d (incorrect codec parameters ?)", VAR_1);
VAR_0 = AVERROR(EINVAL);
goto dump_format;
}
assert_avoptions(output_files[VAR_1]->opts);
if (strcmp(oc->oformat->name, "rtp")) {
VAR_5 = 0;
}
}
dump_format:
for (VAR_1 = 0; VAR_1 < nb_output_files; VAR_1++) {
av_dump_format(output_files[VAR_1]->ctx, VAR_1, output_files[VAR_1]->ctx->filename, 1);
}
av_log(NULL, AV_LOG_INFO, "Stream mapping:\n");
for (VAR_1 = 0; VAR_1 < nb_input_streams; VAR_1++) {
ist = input_streams[VAR_1];
for (VAR_2 = 0; VAR_2 < ist->nb_filters; VAR_2++) {
AVFilterLink *link = ist->filters[VAR_2]->filter->outputs[0];
if (ist->filters[VAR_2]->graph->graph_desc) {
av_log(NULL, AV_LOG_INFO, " Stream #%d:%d (%s) -> %s",
ist->file_index, ist->st->index, ist->dec ? ist->dec->name : "?",
link->dst->filter->name);
if (link->dst->input_count > 1)
av_log(NULL, AV_LOG_INFO, ":%s", link->dstpad->name);
if (nb_filtergraphs > 1)
av_log(NULL, AV_LOG_INFO, " (graph %d)", ist->filters[VAR_2]->graph->index);
av_log(NULL, AV_LOG_INFO, "\n");
}
}
}
for (VAR_1 = 0; VAR_1 < nb_output_streams; VAR_1++) {
ost = output_streams[VAR_1];
if (ost->attachment_filename) {
av_log(NULL, AV_LOG_INFO, " File %s -> Stream #%d:%d\n",
ost->attachment_filename, ost->file_index, ost->index);
continue;
}
if (ost->filter && ost->filter->graph->graph_desc) {
AVFilterLink *link = ost->filter->filter->inputs[0];
av_log(NULL, AV_LOG_INFO, " %s", link->src->filter->name);
if (link->src->output_count > 1)
av_log(NULL, AV_LOG_INFO, ":%s", link->srcpad->name);
if (nb_filtergraphs > 1)
av_log(NULL, AV_LOG_INFO, " (graph %d)", ost->filter->graph->index);
av_log(NULL, AV_LOG_INFO, " -> Stream #%d:%d (%s)\n", ost->file_index,
ost->index, ost->enc ? ost->enc->name : "?");
continue;
}
av_log(NULL, AV_LOG_INFO, " Stream #%d:%d -> #%d:%d",
input_streams[ost->source_index]->file_index,
input_streams[ost->source_index]->st->index,
ost->file_index,
ost->index);
if (ost->sync_ist != input_streams[ost->source_index])
av_log(NULL, AV_LOG_INFO, " [sync #%d:%d]",
ost->sync_ist->file_index,
ost->sync_ist->st->index);
if (ost->stream_copy)
av_log(NULL, AV_LOG_INFO, " (copy)");
else
av_log(NULL, AV_LOG_INFO, " (%s -> %s)", input_streams[ost->source_index]->dec ?
input_streams[ost->source_index]->dec->name : "?",
ost->enc ? ost->enc->name : "?");
av_log(NULL, AV_LOG_INFO, "\n");
}
if (VAR_0) {
av_log(NULL, AV_LOG_ERROR, "%s\n", VAR_4);
return VAR_0;
}
if (VAR_5) {
print_sdp();
}
return 0;
}
| [
"static int FUNC_0(void)\n{",
"int VAR_0 = 0, VAR_1, VAR_2, VAR_3;",
"AVFormatContext *oc;",
"AVCodecContext *codec, *icodec;",
"OutputStream *ost;",
"InputStream *ist;",
"char VAR_4[1024];",
"int VAR_5 = 1;",
"for (VAR_1 = 0; VAR_1 < nb_input_files; VAR_1++) {",
"InputFile *ifile = input_files[VAR_1];",
"if (ifile->rate_emu)\nfor (VAR_2 = 0; VAR_2 < ifile->nb_streams; VAR_2++)",
"input_streams[VAR_2 + ifile->ist_index]->start = av_gettime();",
"}",
"for (VAR_1 = 0; VAR_1 < nb_output_files; VAR_1++) {",
"oc = output_files[VAR_1]->ctx;",
"if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) {",
"av_dump_format(oc, VAR_1, oc->filename, 1);",
"av_log(NULL, AV_LOG_ERROR, \"Output file #%d does not contain any stream\\n\", VAR_1);",
"return AVERROR(EINVAL);",
"}",
"}",
"for (VAR_1 = 0; VAR_1 < nb_filtergraphs; VAR_1++)",
"if ((VAR_0 = avfilter_graph_config(filtergraphs[VAR_1]->graph, NULL)) < 0)\nreturn VAR_0;",
"for (VAR_1 = 0; VAR_1 < nb_output_streams; VAR_1++) {",
"ost = output_streams[VAR_1];",
"oc = output_files[ost->file_index]->ctx;",
"ist = get_input_stream(ost);",
"if (ost->attachment_filename)\ncontinue;",
"codec = ost->st->codec;",
"if (ist) {",
"icodec = ist->st->codec;",
"ost->st->disposition = ist->st->disposition;",
"codec->bits_per_raw_sample = icodec->bits_per_raw_sample;",
"codec->chroma_sample_location = icodec->chroma_sample_location;",
"}",
"if (ost->stream_copy) {",
"uint64_t extra_size;",
"av_assert0(ist && !ost->filter);",
"extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE;",
"if (extra_size > INT_MAX) {",
"return AVERROR(EINVAL);",
"}",
"codec->codec_id = icodec->codec_id;",
"codec->codec_type = icodec->codec_type;",
"if (!codec->codec_tag) {",
"if (!oc->oformat->codec_tag ||\nav_codec_get_id (oc->oformat->codec_tag, icodec->codec_tag) == codec->codec_id ||\nav_codec_get_tag(oc->oformat->codec_tag, icodec->codec_id) <= 0)\ncodec->codec_tag = icodec->codec_tag;",
"}",
"codec->bit_rate = icodec->bit_rate;",
"codec->rc_max_rate = icodec->rc_max_rate;",
"codec->rc_buffer_size = icodec->rc_buffer_size;",
"codec->field_order = icodec->field_order;",
"codec->extradata = av_mallocz(extra_size);",
"if (!codec->extradata) {",
"return AVERROR(ENOMEM);",
"}",
"memcpy(codec->extradata, icodec->extradata, icodec->extradata_size);",
"codec->extradata_size = icodec->extradata_size;",
"if (!copy_tb) {",
"codec->time_base = icodec->time_base;",
"codec->time_base.num *= icodec->ticks_per_frame;",
"av_reduce(&codec->time_base.num, &codec->time_base.den,\ncodec->time_base.num, codec->time_base.den, INT_MAX);",
"} else",
"codec->time_base = ist->st->time_base;",
"switch (codec->codec_type) {",
"case AVMEDIA_TYPE_AUDIO:\nif (audio_volume != 256) {",
"av_log(NULL, AV_LOG_FATAL, \"-acodec copy and -vol are incompatible (frames are not decoded)\\n\");",
"exit_program(1);",
"}",
"codec->channel_layout = icodec->channel_layout;",
"codec->sample_rate = icodec->sample_rate;",
"codec->channels = icodec->channels;",
"codec->frame_size = icodec->frame_size;",
"codec->audio_service_type = icodec->audio_service_type;",
"codec->block_align = icodec->block_align;",
"break;",
"case AVMEDIA_TYPE_VIDEO:\ncodec->pix_fmt = icodec->pix_fmt;",
"codec->width = icodec->width;",
"codec->height = icodec->height;",
"codec->has_b_frames = icodec->has_b_frames;",
"if (!codec->sample_aspect_ratio.num) {",
"codec->sample_aspect_ratio =\nost->st->sample_aspect_ratio =\nist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio :\nist->st->codec->sample_aspect_ratio.num ?\nist->st->codec->sample_aspect_ratio : (AVRational){0, 1};",
"}",
"break;",
"case AVMEDIA_TYPE_SUBTITLE:\ncodec->width = icodec->width;",
"codec->height = icodec->height;",
"break;",
"case AVMEDIA_TYPE_DATA:\ncase AVMEDIA_TYPE_ATTACHMENT:\nbreak;",
"default:\nabort();",
"}",
"} else {",
"if (!ost->enc) {",
"snprintf(VAR_4, sizeof(VAR_4), \"Automatic encoder selection \"\n\"failed for output stream #%d:%d. Default encoder for \"\n\"format %s is probably disabled. Please choose an \"\n\"encoder manually.\\n\", ost->file_index, ost->index,\noc->oformat->name);",
"VAR_0 = AVERROR(EINVAL);",
"goto dump_format;",
"}",
"if (ist)\nist->decoding_needed = 1;",
"ost->encoding_needed = 1;",
"switch (codec->codec_type) {",
"case AVMEDIA_TYPE_AUDIO:\nost->fifo = av_fifo_alloc(1024);",
"if (!ost->fifo) {",
"return AVERROR(ENOMEM);",
"}",
"if (!codec->sample_rate)\ncodec->sample_rate = icodec->sample_rate;",
"choose_sample_rate(ost->st, ost->enc);",
"codec->time_base = (AVRational){ 1, codec->sample_rate };",
"if (codec->sample_fmt == AV_SAMPLE_FMT_NONE)\ncodec->sample_fmt = icodec->sample_fmt;",
"choose_sample_fmt(ost->st, ost->enc);",
"if (!codec->channels)\ncodec->channels = icodec->channels;",
"if (!codec->channel_layout)\ncodec->channel_layout = icodec->channel_layout;",
"if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels)\ncodec->channel_layout = 0;",
"icodec->request_channels = codec-> channels;",
"ost->resample_sample_fmt = icodec->sample_fmt;",
"ost->resample_sample_rate = icodec->sample_rate;",
"ost->resample_channels = icodec->channels;",
"ost->resample_channel_layout = icodec->channel_layout;",
"break;",
"case AVMEDIA_TYPE_VIDEO:\nif (!ost->filter) {",
"FilterGraph *fg;",
"fg = init_simple_filtergraph(ist, ost);",
"if (configure_video_filters(fg)) {",
"av_log(NULL, AV_LOG_FATAL, \"Error opening filters!\\n\");",
"exit(1);",
"}",
"}",
"if (!ost->frame_rate.num && ist &&\n(video_sync_method == VSYNC_CFR ||\n(video_sync_method == VSYNC_AUTO &&\n!(oc->oformat->flags & (AVFMT_NOTIMESTAMPS | AVFMT_VARIABLE_FPS))))) {",
"ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25, 1};",
"if (ost->enc && ost->enc->supported_framerates && !ost->force_fps) {",
"int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates);",
"ost->frame_rate = ost->enc->supported_framerates[idx];",
"}",
"}",
"if (ost->frame_rate.num) {",
"codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num};",
"video_sync_method = VSYNC_CFR;",
"} else if (ist)",
"codec->time_base = ist->st->time_base;",
"else\ncodec->time_base = ost->filter->filter->inputs[0]->time_base;",
"codec->width = ost->filter->filter->inputs[0]->w;",
"codec->height = ost->filter->filter->inputs[0]->h;",
"codec->sample_aspect_ratio = ost->st->sample_aspect_ratio =\nost->frame_aspect_ratio ?\nav_d2q(ost->frame_aspect_ratio * codec->height/codec->width, 255) :\nost->filter->filter->inputs[0]->sample_aspect_ratio;",
"codec->pix_fmt = ost->filter->filter->inputs[0]->format;",
"if (codec->width != icodec->width ||\ncodec->height != icodec->height ||\ncodec->pix_fmt != icodec->pix_fmt) {",
"codec->bits_per_raw_sample = 0;",
"}",
"break;",
"case AVMEDIA_TYPE_SUBTITLE:\ncodec->time_base = (AVRational){1, 1000};",
"break;",
"default:\nabort();",
"break;",
"}",
"if ((codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {",
"char logfilename[1024];",
"FILE *f;",
"snprintf(logfilename, sizeof(logfilename), \"%s-%d.log\",\npass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX,\nVAR_1);",
"if (!strcmp(ost->enc->name, \"libx264\")) {",
"av_dict_set(&ost->opts, \"stats\", logfilename, AV_DICT_DONT_OVERWRITE);",
"} else {",
"if (codec->flags & CODEC_FLAG_PASS1) {",
"f = fopen(logfilename, \"wb\");",
"if (!f) {",
"av_log(NULL, AV_LOG_FATAL, \"Cannot write log file '%s' for pass-1 encoding: %s\\n\",\nlogfilename, strerror(errno));",
"exit_program(1);",
"}",
"ost->logfile = f;",
"} else {",
"char *logbuffer;",
"size_t logbuffer_size;",
"if (cmdutils_read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {",
"av_log(NULL, AV_LOG_FATAL, \"Error reading log file '%s' for pass-2 encoding\\n\",\nlogfilename);",
"exit_program(1);",
"}",
"codec->stats_in = logbuffer;",
"}",
"}",
"}",
"}",
"}",
"for (VAR_1 = 0; VAR_1 < nb_output_streams; VAR_1++) {",
"ost = output_streams[VAR_1];",
"if (ost->encoding_needed) {",
"AVCodec *codec = ost->enc;",
"AVCodecContext *dec = NULL;",
"if ((ist = get_input_stream(ost)))\ndec = ist->st->codec;",
"if (dec && dec->subtitle_header) {",
"ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size);",
"if (!ost->st->codec->subtitle_header) {",
"VAR_0 = AVERROR(ENOMEM);",
"goto dump_format;",
"}",
"memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);",
"ost->st->codec->subtitle_header_size = dec->subtitle_header_size;",
"}",
"if (!av_dict_get(ost->opts, \"threads\", NULL, 0))\nav_dict_set(&ost->opts, \"threads\", \"auto\", 0);",
"if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) {",
"snprintf(VAR_4, sizeof(VAR_4), \"Error while opening encoder for output stream #%d:%d - maybe incorrect parameters such as bit_rate, rate, width or height\",\nost->file_index, ost->index);",
"VAR_0 = AVERROR(EINVAL);",
"goto dump_format;",
"}",
"assert_codec_experimental(ost->st->codec, 1);",
"assert_avoptions(ost->opts);",
"if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000)\nav_log(NULL, AV_LOG_WARNING, \"The bitrate parameter is set too low.\"\n\"It takes bits/s as argument, not kbits/s\\n\");",
"extra_size += ost->st->codec->extradata_size;",
"if (ost->st->codec->me_threshold)\ninput_streams[ost->source_index]->st->codec->debug |= FF_DEBUG_MV;",
"}",
"}",
"for (VAR_1 = 0; VAR_1 < nb_input_streams; VAR_1++)",
"if ((VAR_0 = init_input_stream(VAR_1, VAR_4, sizeof(VAR_4))) < 0)\ngoto dump_format;",
"for (VAR_1 = 0; VAR_1 < nb_input_files; VAR_1++) {",
"InputFile *ifile = input_files[VAR_1];",
"for (VAR_2 = 0; VAR_2 < ifile->ctx->nb_programs; VAR_2++) {",
"AVProgram *p = ifile->ctx->programs[VAR_2];",
"int discard = AVDISCARD_ALL;",
"for (VAR_3 = 0; VAR_3 < p->nb_stream_indexes; VAR_3++)",
"if (!input_streams[ifile->ist_index + p->stream_index[VAR_3]]->discard) {",
"discard = AVDISCARD_DEFAULT;",
"break;",
"}",
"p->discard = discard;",
"}",
"}",
"for (VAR_1 = 0; VAR_1 < nb_output_files; VAR_1++) {",
"oc = output_files[VAR_1]->ctx;",
"oc->interrupt_callback = int_cb;",
"if (avformat_write_header(oc, &output_files[VAR_1]->opts) < 0) {",
"snprintf(VAR_4, sizeof(VAR_4), \"Could not write header for output file #%d (incorrect codec parameters ?)\", VAR_1);",
"VAR_0 = AVERROR(EINVAL);",
"goto dump_format;",
"}",
"assert_avoptions(output_files[VAR_1]->opts);",
"if (strcmp(oc->oformat->name, \"rtp\")) {",
"VAR_5 = 0;",
"}",
"}",
"dump_format:\nfor (VAR_1 = 0; VAR_1 < nb_output_files; VAR_1++) {",
"av_dump_format(output_files[VAR_1]->ctx, VAR_1, output_files[VAR_1]->ctx->filename, 1);",
"}",
"av_log(NULL, AV_LOG_INFO, \"Stream mapping:\\n\");",
"for (VAR_1 = 0; VAR_1 < nb_input_streams; VAR_1++) {",
"ist = input_streams[VAR_1];",
"for (VAR_2 = 0; VAR_2 < ist->nb_filters; VAR_2++) {",
"AVFilterLink *link = ist->filters[VAR_2]->filter->outputs[0];",
"if (ist->filters[VAR_2]->graph->graph_desc) {",
"av_log(NULL, AV_LOG_INFO, \" Stream #%d:%d (%s) -> %s\",\nist->file_index, ist->st->index, ist->dec ? ist->dec->name : \"?\",\nlink->dst->filter->name);",
"if (link->dst->input_count > 1)\nav_log(NULL, AV_LOG_INFO, \":%s\", link->dstpad->name);",
"if (nb_filtergraphs > 1)\nav_log(NULL, AV_LOG_INFO, \" (graph %d)\", ist->filters[VAR_2]->graph->index);",
"av_log(NULL, AV_LOG_INFO, \"\\n\");",
"}",
"}",
"}",
"for (VAR_1 = 0; VAR_1 < nb_output_streams; VAR_1++) {",
"ost = output_streams[VAR_1];",
"if (ost->attachment_filename) {",
"av_log(NULL, AV_LOG_INFO, \" File %s -> Stream #%d:%d\\n\",\nost->attachment_filename, ost->file_index, ost->index);",
"continue;",
"}",
"if (ost->filter && ost->filter->graph->graph_desc) {",
"AVFilterLink *link = ost->filter->filter->inputs[0];",
"av_log(NULL, AV_LOG_INFO, \" %s\", link->src->filter->name);",
"if (link->src->output_count > 1)\nav_log(NULL, AV_LOG_INFO, \":%s\", link->srcpad->name);",
"if (nb_filtergraphs > 1)\nav_log(NULL, AV_LOG_INFO, \" (graph %d)\", ost->filter->graph->index);",
"av_log(NULL, AV_LOG_INFO, \" -> Stream #%d:%d (%s)\\n\", ost->file_index,\nost->index, ost->enc ? ost->enc->name : \"?\");",
"continue;",
"}",
"av_log(NULL, AV_LOG_INFO, \" Stream #%d:%d -> #%d:%d\",\ninput_streams[ost->source_index]->file_index,\ninput_streams[ost->source_index]->st->index,\nost->file_index,\nost->index);",
"if (ost->sync_ist != input_streams[ost->source_index])\nav_log(NULL, AV_LOG_INFO, \" [sync #%d:%d]\",\nost->sync_ist->file_index,\nost->sync_ist->st->index);",
"if (ost->stream_copy)\nav_log(NULL, AV_LOG_INFO, \" (copy)\");",
"else\nav_log(NULL, AV_LOG_INFO, \" (%s -> %s)\", input_streams[ost->source_index]->dec ?\ninput_streams[ost->source_index]->dec->name : \"?\",\nost->enc ? ost->enc->name : \"?\");",
"av_log(NULL, AV_LOG_INFO, \"\\n\");",
"}",
"if (VAR_0) {",
"av_log(NULL, AV_LOG_ERROR, \"%s\\n\", VAR_4);",
"return VAR_0;",
"}",
"if (VAR_5) {",
"print_sdp();",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
59
],
[
61,
63
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79,
81
],
[
85
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
111
],
[
115
],
[
119
],
[
121
],
[
123
],
[
129
],
[
131
],
[
135
],
[
137,
139,
141,
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175,
177
],
[
179
],
[
181
],
[
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
],
[
263,
265,
267,
269,
271
],
[
273
],
[
275
],
[
277
],
[
281,
283
],
[
285
],
[
289
],
[
291,
293
],
[
295
],
[
297
],
[
299
],
[
303,
305
],
[
307
],
[
309
],
[
313,
315
],
[
317
],
[
321,
323
],
[
325,
327
],
[
329,
331
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347,
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
385,
387,
389,
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
415,
417
],
[
421
],
[
423
],
[
425,
427,
429,
431
],
[
433
],
[
437,
439,
441
],
[
443
],
[
445
],
[
449
],
[
451,
453
],
[
455
],
[
457,
459
],
[
461
],
[
463
],
[
467
],
[
469
],
[
471
],
[
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
],
[
535
],
[
537
],
[
539
],
[
541
],
[
543
],
[
547,
549
],
[
551
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563
],
[
565
],
[
567
],
[
569,
571
],
[
573
],
[
575,
577
],
[
579
],
[
581
],
[
583
],
[
585
],
[
587
],
[
589,
591,
593
],
[
595
],
[
599,
601
],
[
603
],
[
605
],
[
611
],
[
613,
615
],
[
621
],
[
623
],
[
625
],
[
627
],
[
629
],
[
633
],
[
635
],
[
637
],
[
639
],
[
641
],
[
643
],
[
645
],
[
647
],
[
653
],
[
655
],
[
657
],
[
659
],
[
661
],
[
663
],
[
665
],
[
667
],
[
669
],
[
671
],
[
673
],
[
675
],
[
677
],
[
681,
687
],
[
689
],
[
691
],
[
697
],
[
699
],
[
701
],
[
705
],
[
707
],
[
709
],
[
711,
713,
715
],
[
717,
719
],
[
721,
723
],
[
725
],
[
727
],
[
729
],
[
731
],
[
735
],
[
737
],
[
741
],
[
745,
747
],
[
749
],
[
751
],
[
755
],
[
759
],
[
761
],
[
763,
765
],
[
767,
769
],
[
773,
775
],
[
777
],
[
779
],
[
783,
785,
787,
789,
791
],
[
793,
795,
797,
799
],
[
801,
803
],
[
805,
807,
809,
811
],
[
813
],
[
815
],
[
819
],
[
821
],
[
823
],
[
825
],
[
829
],
[
831
],
[
833
],
[
837
],
[
839
]
] |
3,630 | static int get_aiff_header(AVFormatContext *s, int size,
unsigned version)
{
AVIOContext *pb = s->pb;
AVCodecParameters *par = s->streams[0]->codecpar;
AIFFInputContext *aiff = s->priv_data;
int exp;
uint64_t val;
int sample_rate;
unsigned int num_frames;
if (size & 1)
size++;
par->codec_type = AVMEDIA_TYPE_AUDIO;
par->channels = avio_rb16(pb);
num_frames = avio_rb32(pb);
par->bits_per_coded_sample = avio_rb16(pb);
exp = avio_rb16(pb) - 16383 - 63;
val = avio_rb64(pb);
if (exp <-63 || exp >63) {
av_log(s, AV_LOG_ERROR, "exp %d is out of range\n", exp);
return AVERROR_INVALIDDATA;
}
if (exp >= 0)
sample_rate = val << exp;
else
sample_rate = (val + (1ULL<<(-exp-1))) >> -exp;
par->sample_rate = sample_rate;
size -= 18;
/* get codec id for AIFF-C */
if (size < 4) {
version = AIFF;
} else if (version == AIFF_C_VERSION1) {
par->codec_tag = avio_rl32(pb);
par->codec_id = ff_codec_get_id(ff_codec_aiff_tags, par->codec_tag);
if (par->codec_id == AV_CODEC_ID_NONE) {
char tag[32];
av_get_codec_tag_string(tag, sizeof(tag), par->codec_tag);
avpriv_request_sample(s, "unknown or unsupported codec tag: %s", tag);
}
size -= 4;
}
if (version != AIFF_C_VERSION1 || par->codec_id == AV_CODEC_ID_PCM_S16BE) {
par->codec_id = aiff_codec_get_id(par->bits_per_coded_sample);
par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id);
aiff->block_duration = 1;
} else {
switch (par->codec_id) {
case AV_CODEC_ID_PCM_F32BE:
case AV_CODEC_ID_PCM_F64BE:
case AV_CODEC_ID_PCM_S16LE:
case AV_CODEC_ID_PCM_ALAW:
case AV_CODEC_ID_PCM_MULAW:
aiff->block_duration = 1;
break;
case AV_CODEC_ID_ADPCM_IMA_QT:
par->block_align = 34 * par->channels;
break;
case AV_CODEC_ID_MACE3:
par->block_align = 2 * par->channels;
break;
case AV_CODEC_ID_ADPCM_G726LE:
par->bits_per_coded_sample = 5;
case AV_CODEC_ID_ADPCM_IMA_WS:
case AV_CODEC_ID_ADPCM_G722:
case AV_CODEC_ID_MACE6:
case AV_CODEC_ID_SDX2_DPCM:
par->block_align = 1 * par->channels;
break;
case AV_CODEC_ID_GSM:
par->block_align = 33;
break;
default:
aiff->block_duration = 1;
break;
}
if (par->block_align > 0)
aiff->block_duration = av_get_audio_frame_duration2(par,
par->block_align);
}
/* Block align needs to be computed in all cases, as the definition
* is specific to applications -> here we use the WAVE format definition */
if (!par->block_align)
par->block_align = (av_get_bits_per_sample(par->codec_id) * par->channels) >> 3;
if (aiff->block_duration) {
par->bit_rate = par->sample_rate * (par->block_align << 3) /
aiff->block_duration;
}
/* Chunk is over */
if (size)
avio_skip(pb, size);
return num_frames;
}
| true | FFmpeg | ad5807f8aa883bee5431186dc1f24c5435d722d3 | static int get_aiff_header(AVFormatContext *s, int size,
unsigned version)
{
AVIOContext *pb = s->pb;
AVCodecParameters *par = s->streams[0]->codecpar;
AIFFInputContext *aiff = s->priv_data;
int exp;
uint64_t val;
int sample_rate;
unsigned int num_frames;
if (size & 1)
size++;
par->codec_type = AVMEDIA_TYPE_AUDIO;
par->channels = avio_rb16(pb);
num_frames = avio_rb32(pb);
par->bits_per_coded_sample = avio_rb16(pb);
exp = avio_rb16(pb) - 16383 - 63;
val = avio_rb64(pb);
if (exp <-63 || exp >63) {
av_log(s, AV_LOG_ERROR, "exp %d is out of range\n", exp);
return AVERROR_INVALIDDATA;
}
if (exp >= 0)
sample_rate = val << exp;
else
sample_rate = (val + (1ULL<<(-exp-1))) >> -exp;
par->sample_rate = sample_rate;
size -= 18;
if (size < 4) {
version = AIFF;
} else if (version == AIFF_C_VERSION1) {
par->codec_tag = avio_rl32(pb);
par->codec_id = ff_codec_get_id(ff_codec_aiff_tags, par->codec_tag);
if (par->codec_id == AV_CODEC_ID_NONE) {
char tag[32];
av_get_codec_tag_string(tag, sizeof(tag), par->codec_tag);
avpriv_request_sample(s, "unknown or unsupported codec tag: %s", tag);
}
size -= 4;
}
if (version != AIFF_C_VERSION1 || par->codec_id == AV_CODEC_ID_PCM_S16BE) {
par->codec_id = aiff_codec_get_id(par->bits_per_coded_sample);
par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id);
aiff->block_duration = 1;
} else {
switch (par->codec_id) {
case AV_CODEC_ID_PCM_F32BE:
case AV_CODEC_ID_PCM_F64BE:
case AV_CODEC_ID_PCM_S16LE:
case AV_CODEC_ID_PCM_ALAW:
case AV_CODEC_ID_PCM_MULAW:
aiff->block_duration = 1;
break;
case AV_CODEC_ID_ADPCM_IMA_QT:
par->block_align = 34 * par->channels;
break;
case AV_CODEC_ID_MACE3:
par->block_align = 2 * par->channels;
break;
case AV_CODEC_ID_ADPCM_G726LE:
par->bits_per_coded_sample = 5;
case AV_CODEC_ID_ADPCM_IMA_WS:
case AV_CODEC_ID_ADPCM_G722:
case AV_CODEC_ID_MACE6:
case AV_CODEC_ID_SDX2_DPCM:
par->block_align = 1 * par->channels;
break;
case AV_CODEC_ID_GSM:
par->block_align = 33;
break;
default:
aiff->block_duration = 1;
break;
}
if (par->block_align > 0)
aiff->block_duration = av_get_audio_frame_duration2(par,
par->block_align);
}
if (!par->block_align)
par->block_align = (av_get_bits_per_sample(par->codec_id) * par->channels) >> 3;
if (aiff->block_duration) {
par->bit_rate = par->sample_rate * (par->block_align << 3) /
aiff->block_duration;
}
if (size)
avio_skip(pb, size);
return num_frames;
}
| {
"code": [
" par->bit_rate = par->sample_rate * (par->block_align << 3) /"
],
"line_no": [
181
]
} | static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,
unsigned VAR_2)
{
AVIOContext *pb = VAR_0->pb;
AVCodecParameters *par = VAR_0->streams[0]->codecpar;
AIFFInputContext *aiff = VAR_0->priv_data;
int VAR_3;
uint64_t val;
int VAR_4;
unsigned int VAR_5;
if (VAR_1 & 1)
VAR_1++;
par->codec_type = AVMEDIA_TYPE_AUDIO;
par->channels = avio_rb16(pb);
VAR_5 = avio_rb32(pb);
par->bits_per_coded_sample = avio_rb16(pb);
VAR_3 = avio_rb16(pb) - 16383 - 63;
val = avio_rb64(pb);
if (VAR_3 <-63 || VAR_3 >63) {
av_log(VAR_0, AV_LOG_ERROR, "VAR_3 %d is out of range\n", VAR_3);
return AVERROR_INVALIDDATA;
}
if (VAR_3 >= 0)
VAR_4 = val << VAR_3;
else
VAR_4 = (val + (1ULL<<(-VAR_3-1))) >> -VAR_3;
par->VAR_4 = VAR_4;
VAR_1 -= 18;
if (VAR_1 < 4) {
VAR_2 = AIFF;
} else if (VAR_2 == AIFF_C_VERSION1) {
par->codec_tag = avio_rl32(pb);
par->codec_id = ff_codec_get_id(ff_codec_aiff_tags, par->codec_tag);
if (par->codec_id == AV_CODEC_ID_NONE) {
char VAR_6[32];
av_get_codec_tag_string(VAR_6, sizeof(VAR_6), par->codec_tag);
avpriv_request_sample(VAR_0, "unknown or unsupported codec VAR_6: %VAR_0", VAR_6);
}
VAR_1 -= 4;
}
if (VAR_2 != AIFF_C_VERSION1 || par->codec_id == AV_CODEC_ID_PCM_S16BE) {
par->codec_id = aiff_codec_get_id(par->bits_per_coded_sample);
par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id);
aiff->block_duration = 1;
} else {
switch (par->codec_id) {
case AV_CODEC_ID_PCM_F32BE:
case AV_CODEC_ID_PCM_F64BE:
case AV_CODEC_ID_PCM_S16LE:
case AV_CODEC_ID_PCM_ALAW:
case AV_CODEC_ID_PCM_MULAW:
aiff->block_duration = 1;
break;
case AV_CODEC_ID_ADPCM_IMA_QT:
par->block_align = 34 * par->channels;
break;
case AV_CODEC_ID_MACE3:
par->block_align = 2 * par->channels;
break;
case AV_CODEC_ID_ADPCM_G726LE:
par->bits_per_coded_sample = 5;
case AV_CODEC_ID_ADPCM_IMA_WS:
case AV_CODEC_ID_ADPCM_G722:
case AV_CODEC_ID_MACE6:
case AV_CODEC_ID_SDX2_DPCM:
par->block_align = 1 * par->channels;
break;
case AV_CODEC_ID_GSM:
par->block_align = 33;
break;
default:
aiff->block_duration = 1;
break;
}
if (par->block_align > 0)
aiff->block_duration = av_get_audio_frame_duration2(par,
par->block_align);
}
if (!par->block_align)
par->block_align = (av_get_bits_per_sample(par->codec_id) * par->channels) >> 3;
if (aiff->block_duration) {
par->bit_rate = par->VAR_4 * (par->block_align << 3) /
aiff->block_duration;
}
if (VAR_1)
avio_skip(pb, VAR_1);
return VAR_5;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,\nunsigned VAR_2)\n{",
"AVIOContext *pb = VAR_0->pb;",
"AVCodecParameters *par = VAR_0->streams[0]->codecpar;",
"AIFFInputContext *aiff = VAR_0->priv_data;",
"int VAR_3;",
"uint64_t val;",
"int VAR_4;",
"unsigned int VAR_5;",
"if (VAR_1 & 1)\nVAR_1++;",
"par->codec_type = AVMEDIA_TYPE_AUDIO;",
"par->channels = avio_rb16(pb);",
"VAR_5 = avio_rb32(pb);",
"par->bits_per_coded_sample = avio_rb16(pb);",
"VAR_3 = avio_rb16(pb) - 16383 - 63;",
"val = avio_rb64(pb);",
"if (VAR_3 <-63 || VAR_3 >63) {",
"av_log(VAR_0, AV_LOG_ERROR, \"VAR_3 %d is out of range\\n\", VAR_3);",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_3 >= 0)\nVAR_4 = val << VAR_3;",
"else\nVAR_4 = (val + (1ULL<<(-VAR_3-1))) >> -VAR_3;",
"par->VAR_4 = VAR_4;",
"VAR_1 -= 18;",
"if (VAR_1 < 4) {",
"VAR_2 = AIFF;",
"} else if (VAR_2 == AIFF_C_VERSION1) {",
"par->codec_tag = avio_rl32(pb);",
"par->codec_id = ff_codec_get_id(ff_codec_aiff_tags, par->codec_tag);",
"if (par->codec_id == AV_CODEC_ID_NONE) {",
"char VAR_6[32];",
"av_get_codec_tag_string(VAR_6, sizeof(VAR_6), par->codec_tag);",
"avpriv_request_sample(VAR_0, \"unknown or unsupported codec VAR_6: %VAR_0\", VAR_6);",
"}",
"VAR_1 -= 4;",
"}",
"if (VAR_2 != AIFF_C_VERSION1 || par->codec_id == AV_CODEC_ID_PCM_S16BE) {",
"par->codec_id = aiff_codec_get_id(par->bits_per_coded_sample);",
"par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id);",
"aiff->block_duration = 1;",
"} else {",
"switch (par->codec_id) {",
"case AV_CODEC_ID_PCM_F32BE:\ncase AV_CODEC_ID_PCM_F64BE:\ncase AV_CODEC_ID_PCM_S16LE:\ncase AV_CODEC_ID_PCM_ALAW:\ncase AV_CODEC_ID_PCM_MULAW:\naiff->block_duration = 1;",
"break;",
"case AV_CODEC_ID_ADPCM_IMA_QT:\npar->block_align = 34 * par->channels;",
"break;",
"case AV_CODEC_ID_MACE3:\npar->block_align = 2 * par->channels;",
"break;",
"case AV_CODEC_ID_ADPCM_G726LE:\npar->bits_per_coded_sample = 5;",
"case AV_CODEC_ID_ADPCM_IMA_WS:\ncase AV_CODEC_ID_ADPCM_G722:\ncase AV_CODEC_ID_MACE6:\ncase AV_CODEC_ID_SDX2_DPCM:\npar->block_align = 1 * par->channels;",
"break;",
"case AV_CODEC_ID_GSM:\npar->block_align = 33;",
"break;",
"default:\naiff->block_duration = 1;",
"break;",
"}",
"if (par->block_align > 0)\naiff->block_duration = av_get_audio_frame_duration2(par,\npar->block_align);",
"}",
"if (!par->block_align)\npar->block_align = (av_get_bits_per_sample(par->codec_id) * par->channels) >> 3;",
"if (aiff->block_duration) {",
"par->bit_rate = par->VAR_4 * (par->block_align << 3) /\naiff->block_duration;",
"}",
"if (VAR_1)\navio_skip(pb, VAR_1);",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53,
55
],
[
57
],
[
59
],
[
65
],
[
67
],
[
69
],
[
71
],
[
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
],
[
129,
131
],
[
133,
135,
137,
139,
141
],
[
143
],
[
145,
147
],
[
149
],
[
151,
153
],
[
155
],
[
157
],
[
159,
161,
163
],
[
165
],
[
173,
175
],
[
179
],
[
181,
183
],
[
185
],
[
191,
193
],
[
197
],
[
199
]
] |
3,631 | static void xen_init_pv(QEMUMachineInitArgs *args)
{
const char *cpu_model = args->cpu_model;
const char *kernel_filename = args->kernel_filename;
const char *kernel_cmdline = args->kernel_cmdline;
const char *initrd_filename = args->initrd_filename;
X86CPU *cpu;
CPUState *cs;
DriveInfo *dinfo;
int i;
/* Initialize a dummy CPU */
if (cpu_model == NULL) {
#ifdef TARGET_X86_64
cpu_model = "qemu64";
#else
cpu_model = "qemu32";
#endif
}
cpu = cpu_x86_init(cpu_model);
cs = CPU(cpu);
cs->halted = 1;
/* Initialize backend core & drivers */
if (xen_be_init() != 0) {
fprintf(stderr, "%s: xen backend core setup failed\n", __FUNCTION__);
exit(1);
}
switch (xen_mode) {
case XEN_ATTACH:
/* nothing to do, xend handles everything */
break;
case XEN_CREATE:
if (xen_domain_build_pv(kernel_filename, initrd_filename,
kernel_cmdline) < 0) {
fprintf(stderr, "xen pv domain creation failed\n");
exit(1);
}
break;
case XEN_EMULATE:
fprintf(stderr, "xen emulation not implemented (yet)\n");
exit(1);
break;
}
xen_be_register("console", &xen_console_ops);
xen_be_register("vkbd", &xen_kbdmouse_ops);
xen_be_register("vfb", &xen_framebuffer_ops);
xen_be_register("qdisk", &xen_blkdev_ops);
xen_be_register("qnic", &xen_netdev_ops);
/* configure framebuffer */
if (xenfb_enabled) {
xen_config_dev_vfb(0, "vnc");
xen_config_dev_vkbd(0);
}
/* configure disks */
for (i = 0; i < 16; i++) {
dinfo = drive_get(IF_XEN, 0, i);
if (!dinfo)
continue;
xen_config_dev_blk(dinfo);
}
/* configure nics */
for (i = 0; i < nb_nics; i++) {
if (!nd_table[i].model || 0 != strcmp(nd_table[i].model, "xen"))
continue;
xen_config_dev_nic(nd_table + i);
}
/* config cleanup hook */
atexit(xen_config_cleanup);
/* setup framebuffer */
xen_init_display(xen_domid);
}
| true | qemu | 58ee9b0ae05d81c74d6869a25ce4263fc22ed809 | static void xen_init_pv(QEMUMachineInitArgs *args)
{
const char *cpu_model = args->cpu_model;
const char *kernel_filename = args->kernel_filename;
const char *kernel_cmdline = args->kernel_cmdline;
const char *initrd_filename = args->initrd_filename;
X86CPU *cpu;
CPUState *cs;
DriveInfo *dinfo;
int i;
if (cpu_model == NULL) {
#ifdef TARGET_X86_64
cpu_model = "qemu64";
#else
cpu_model = "qemu32";
#endif
}
cpu = cpu_x86_init(cpu_model);
cs = CPU(cpu);
cs->halted = 1;
if (xen_be_init() != 0) {
fprintf(stderr, "%s: xen backend core setup failed\n", __FUNCTION__);
exit(1);
}
switch (xen_mode) {
case XEN_ATTACH:
break;
case XEN_CREATE:
if (xen_domain_build_pv(kernel_filename, initrd_filename,
kernel_cmdline) < 0) {
fprintf(stderr, "xen pv domain creation failed\n");
exit(1);
}
break;
case XEN_EMULATE:
fprintf(stderr, "xen emulation not implemented (yet)\n");
exit(1);
break;
}
xen_be_register("console", &xen_console_ops);
xen_be_register("vkbd", &xen_kbdmouse_ops);
xen_be_register("vfb", &xen_framebuffer_ops);
xen_be_register("qdisk", &xen_blkdev_ops);
xen_be_register("qnic", &xen_netdev_ops);
if (xenfb_enabled) {
xen_config_dev_vfb(0, "vnc");
xen_config_dev_vkbd(0);
}
for (i = 0; i < 16; i++) {
dinfo = drive_get(IF_XEN, 0, i);
if (!dinfo)
continue;
xen_config_dev_blk(dinfo);
}
for (i = 0; i < nb_nics; i++) {
if (!nd_table[i].model || 0 != strcmp(nd_table[i].model, "xen"))
continue;
xen_config_dev_nic(nd_table + i);
}
atexit(xen_config_cleanup);
xen_init_display(xen_domid);
}
| {
"code": [
" const char *cpu_model = args->cpu_model;",
" X86CPU *cpu;",
" CPUState *cs;",
" if (cpu_model == NULL) {",
"#ifdef TARGET_X86_64",
" cpu_model = \"qemu64\";",
"#else",
" cpu_model = \"qemu32\";",
"#endif",
" cpu = cpu_x86_init(cpu_model);",
" cs = CPU(cpu);",
" cs->halted = 1;"
],
"line_no": [
5,
13,
15,
25,
27,
29,
31,
33,
35,
39,
41,
43
]
} | static void FUNC_0(QEMUMachineInitArgs *VAR_0)
{
const char *VAR_1 = VAR_0->VAR_1;
const char *VAR_2 = VAR_0->VAR_2;
const char *VAR_3 = VAR_0->VAR_3;
const char *VAR_4 = VAR_0->VAR_4;
X86CPU *cpu;
CPUState *cs;
DriveInfo *dinfo;
int VAR_5;
if (VAR_1 == NULL) {
#ifdef TARGET_X86_64
VAR_1 = "qemu64";
#else
VAR_1 = "qemu32";
#endif
}
cpu = cpu_x86_init(VAR_1);
cs = CPU(cpu);
cs->halted = 1;
if (xen_be_init() != 0) {
fprintf(stderr, "%s: xen backend core setup failed\n", __FUNCTION__);
exit(1);
}
switch (xen_mode) {
case XEN_ATTACH:
break;
case XEN_CREATE:
if (xen_domain_build_pv(VAR_2, VAR_4,
VAR_3) < 0) {
fprintf(stderr, "xen pv domain creation failed\n");
exit(1);
}
break;
case XEN_EMULATE:
fprintf(stderr, "xen emulation not implemented (yet)\n");
exit(1);
break;
}
xen_be_register("console", &xen_console_ops);
xen_be_register("vkbd", &xen_kbdmouse_ops);
xen_be_register("vfb", &xen_framebuffer_ops);
xen_be_register("qdisk", &xen_blkdev_ops);
xen_be_register("qnic", &xen_netdev_ops);
if (xenfb_enabled) {
xen_config_dev_vfb(0, "vnc");
xen_config_dev_vkbd(0);
}
for (VAR_5 = 0; VAR_5 < 16; VAR_5++) {
dinfo = drive_get(IF_XEN, 0, VAR_5);
if (!dinfo)
continue;
xen_config_dev_blk(dinfo);
}
for (VAR_5 = 0; VAR_5 < nb_nics; VAR_5++) {
if (!nd_table[VAR_5].model || 0 != strcmp(nd_table[VAR_5].model, "xen"))
continue;
xen_config_dev_nic(nd_table + VAR_5);
}
atexit(xen_config_cleanup);
xen_init_display(xen_domid);
}
| [
"static void FUNC_0(QEMUMachineInitArgs *VAR_0)\n{",
"const char *VAR_1 = VAR_0->VAR_1;",
"const char *VAR_2 = VAR_0->VAR_2;",
"const char *VAR_3 = VAR_0->VAR_3;",
"const char *VAR_4 = VAR_0->VAR_4;",
"X86CPU *cpu;",
"CPUState *cs;",
"DriveInfo *dinfo;",
"int VAR_5;",
"if (VAR_1 == NULL) {",
"#ifdef TARGET_X86_64\nVAR_1 = \"qemu64\";",
"#else\nVAR_1 = \"qemu32\";",
"#endif\n}",
"cpu = cpu_x86_init(VAR_1);",
"cs = CPU(cpu);",
"cs->halted = 1;",
"if (xen_be_init() != 0) {",
"fprintf(stderr, \"%s: xen backend core setup failed\\n\", __FUNCTION__);",
"exit(1);",
"}",
"switch (xen_mode) {",
"case XEN_ATTACH:\nbreak;",
"case XEN_CREATE:\nif (xen_domain_build_pv(VAR_2, VAR_4,\nVAR_3) < 0) {",
"fprintf(stderr, \"xen pv domain creation failed\\n\");",
"exit(1);",
"}",
"break;",
"case XEN_EMULATE:\nfprintf(stderr, \"xen emulation not implemented (yet)\\n\");",
"exit(1);",
"break;",
"}",
"xen_be_register(\"console\", &xen_console_ops);",
"xen_be_register(\"vkbd\", &xen_kbdmouse_ops);",
"xen_be_register(\"vfb\", &xen_framebuffer_ops);",
"xen_be_register(\"qdisk\", &xen_blkdev_ops);",
"xen_be_register(\"qnic\", &xen_netdev_ops);",
"if (xenfb_enabled) {",
"xen_config_dev_vfb(0, \"vnc\");",
"xen_config_dev_vkbd(0);",
"}",
"for (VAR_5 = 0; VAR_5 < 16; VAR_5++) {",
"dinfo = drive_get(IF_XEN, 0, VAR_5);",
"if (!dinfo)\ncontinue;",
"xen_config_dev_blk(dinfo);",
"}",
"for (VAR_5 = 0; VAR_5 < nb_nics; VAR_5++) {",
"if (!nd_table[VAR_5].model || 0 != strcmp(nd_table[VAR_5].model, \"xen\"))\ncontinue;",
"xen_config_dev_nic(nd_table + VAR_5);",
"}",
"atexit(xen_config_cleanup);",
"xen_init_display(xen_domid);",
"}"
] | [
0,
1,
0,
0,
0,
1,
1,
0,
0,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
25
],
[
27,
29
],
[
31,
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61,
65
],
[
67,
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
107
],
[
109
],
[
111
],
[
113
],
[
119
],
[
121
],
[
123,
125
],
[
127
],
[
129
],
[
135
],
[
137,
139
],
[
141
],
[
143
],
[
149
],
[
155
],
[
157
]
] |
3,632 | void signal_init(void)
{
struct sigaction act;
int i;
/* set all host signal handlers. ALL signals are blocked during
the handlers to serialize them. */
sigfillset(&act.sa_mask);
act.sa_flags = SA_SIGINFO;
act.sa_sigaction = host_signal_handler;
for(i = 1; i < NSIG; i++) {
sigaction(i, &act, NULL);
}
memset(sigact_table, 0, sizeof(sigact_table));
first_free = &sigqueue_table[0];
for(i = 0; i < MAX_SIGQUEUE_SIZE - 1; i++)
sigqueue_table[i].next = &sigqueue_table[i + 1];
sigqueue_table[MAX_SIGQUEUE_SIZE - 1].next = NULL;
}
| true | qemu | c9087c2a6068b23207517f7d7ff796e68290358b | void signal_init(void)
{
struct sigaction act;
int i;
sigfillset(&act.sa_mask);
act.sa_flags = SA_SIGINFO;
act.sa_sigaction = host_signal_handler;
for(i = 1; i < NSIG; i++) {
sigaction(i, &act, NULL);
}
memset(sigact_table, 0, sizeof(sigact_table));
first_free = &sigqueue_table[0];
for(i = 0; i < MAX_SIGQUEUE_SIZE - 1; i++)
sigqueue_table[i].next = &sigqueue_table[i + 1];
sigqueue_table[MAX_SIGQUEUE_SIZE - 1].next = NULL;
}
| {
"code": [
"\tsigaction(i, &act, NULL);"
],
"line_no": [
23
]
} | void FUNC_0(void)
{
struct sigaction VAR_0;
int VAR_1;
sigfillset(&VAR_0.sa_mask);
VAR_0.sa_flags = SA_SIGINFO;
VAR_0.sa_sigaction = host_signal_handler;
for(VAR_1 = 1; VAR_1 < NSIG; VAR_1++) {
sigaction(VAR_1, &VAR_0, NULL);
}
memset(sigact_table, 0, sizeof(sigact_table));
first_free = &sigqueue_table[0];
for(VAR_1 = 0; VAR_1 < MAX_SIGQUEUE_SIZE - 1; VAR_1++)
sigqueue_table[VAR_1].next = &sigqueue_table[VAR_1 + 1];
sigqueue_table[MAX_SIGQUEUE_SIZE - 1].next = NULL;
}
| [
"void FUNC_0(void)\n{",
"struct sigaction VAR_0;",
"int VAR_1;",
"sigfillset(&VAR_0.sa_mask);",
"VAR_0.sa_flags = SA_SIGINFO;",
"VAR_0.sa_sigaction = host_signal_handler;",
"for(VAR_1 = 1; VAR_1 < NSIG; VAR_1++) {",
"sigaction(VAR_1, &VAR_0, NULL);",
"}",
"memset(sigact_table, 0, sizeof(sigact_table));",
"first_free = &sigqueue_table[0];",
"for(VAR_1 = 0; VAR_1 < MAX_SIGQUEUE_SIZE - 1; VAR_1++)",
"sigqueue_table[VAR_1].next = &sigqueue_table[VAR_1 + 1];",
"sigqueue_table[MAX_SIGQUEUE_SIZE - 1].next = NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
]
] |
3,633 | static inline void gen_bx(DisasContext *s, TCGv_i32 var)
{
s->is_jmp = DISAS_UPDATE;
tcg_gen_andi_i32(cpu_R[15], var, ~1);
tcg_gen_andi_i32(var, var, 1);
store_cpu_field(var, thumb);
}
| true | qemu | 577bf808958d06497928c639efaa473bf8c5e099 | static inline void gen_bx(DisasContext *s, TCGv_i32 var)
{
s->is_jmp = DISAS_UPDATE;
tcg_gen_andi_i32(cpu_R[15], var, ~1);
tcg_gen_andi_i32(var, var, 1);
store_cpu_field(var, thumb);
}
| {
"code": [
" s->is_jmp = DISAS_UPDATE;",
" s->is_jmp = DISAS_UPDATE;",
" s->is_jmp = DISAS_UPDATE;",
" s->is_jmp = DISAS_UPDATE;",
" s->is_jmp = DISAS_UPDATE;"
],
"line_no": [
5,
5,
5,
5,
5
]
} | static inline void FUNC_0(DisasContext *VAR_0, TCGv_i32 VAR_1)
{
VAR_0->is_jmp = DISAS_UPDATE;
tcg_gen_andi_i32(cpu_R[15], VAR_1, ~1);
tcg_gen_andi_i32(VAR_1, VAR_1, 1);
store_cpu_field(VAR_1, thumb);
}
| [
"static inline void FUNC_0(DisasContext *VAR_0, TCGv_i32 VAR_1)\n{",
"VAR_0->is_jmp = DISAS_UPDATE;",
"tcg_gen_andi_i32(cpu_R[15], VAR_1, ~1);",
"tcg_gen_andi_i32(VAR_1, VAR_1, 1);",
"store_cpu_field(VAR_1, thumb);",
"}"
] | [
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
3,635 | static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
int buf_size, int *coded_samples, int *approx_nb_samples)
{
ADPCMDecodeContext *s = avctx->priv_data;
int nb_samples = 0;
int ch = avctx->channels;
int has_coded_samples = 0;
int header_size;
*coded_samples = 0;
*approx_nb_samples = 0;
if(ch <= 0)
return 0;
switch (avctx->codec->id) {
/* constant, only check buf_size */
case AV_CODEC_ID_ADPCM_EA_XAS:
if (buf_size < 76 * ch)
return 0;
nb_samples = 128;
break;
case AV_CODEC_ID_ADPCM_IMA_QT:
if (buf_size < 34 * ch)
return 0;
nb_samples = 64;
break;
/* simple 4-bit adpcm */
case AV_CODEC_ID_ADPCM_CT:
case AV_CODEC_ID_ADPCM_IMA_APC:
case AV_CODEC_ID_ADPCM_IMA_EA_SEAD:
case AV_CODEC_ID_ADPCM_IMA_OKI:
case AV_CODEC_ID_ADPCM_IMA_WS:
case AV_CODEC_ID_ADPCM_YAMAHA:
nb_samples = buf_size * 2 / ch;
break;
}
if (nb_samples)
return nb_samples;
/* simple 4-bit adpcm, with header */
header_size = 0;
switch (avctx->codec->id) {
case AV_CODEC_ID_ADPCM_4XM:
case AV_CODEC_ID_ADPCM_IMA_ISS: header_size = 4 * ch; break;
case AV_CODEC_ID_ADPCM_IMA_AMV: header_size = 8; break;
case AV_CODEC_ID_ADPCM_IMA_SMJPEG: header_size = 4 * ch; break;
}
if (header_size > 0)
return (buf_size - header_size) * 2 / ch;
/* more complex formats */
switch (avctx->codec->id) {
case AV_CODEC_ID_ADPCM_EA:
has_coded_samples = 1;
*coded_samples = bytestream2_get_le32(gb);
*coded_samples -= *coded_samples % 28;
nb_samples = (buf_size - 12) / 30 * 28;
break;
case AV_CODEC_ID_ADPCM_IMA_EA_EACS:
has_coded_samples = 1;
*coded_samples = bytestream2_get_le32(gb);
nb_samples = (buf_size - (4 + 8 * ch)) * 2 / ch;
break;
case AV_CODEC_ID_ADPCM_EA_MAXIS_XA:
nb_samples = (buf_size - ch) / ch * 2;
break;
case AV_CODEC_ID_ADPCM_EA_R1:
case AV_CODEC_ID_ADPCM_EA_R2:
case AV_CODEC_ID_ADPCM_EA_R3:
/* maximum number of samples */
/* has internal offsets and a per-frame switch to signal raw 16-bit */
has_coded_samples = 1;
switch (avctx->codec->id) {
case AV_CODEC_ID_ADPCM_EA_R1:
header_size = 4 + 9 * ch;
*coded_samples = bytestream2_get_le32(gb);
break;
case AV_CODEC_ID_ADPCM_EA_R2:
header_size = 4 + 5 * ch;
*coded_samples = bytestream2_get_le32(gb);
break;
case AV_CODEC_ID_ADPCM_EA_R3:
header_size = 4 + 5 * ch;
*coded_samples = bytestream2_get_be32(gb);
break;
}
*coded_samples -= *coded_samples % 28;
nb_samples = (buf_size - header_size) * 2 / ch;
nb_samples -= nb_samples % 28;
*approx_nb_samples = 1;
break;
case AV_CODEC_ID_ADPCM_IMA_DK3:
if (avctx->block_align > 0)
buf_size = FFMIN(buf_size, avctx->block_align);
nb_samples = ((buf_size - 16) * 2 / 3 * 4) / ch;
break;
case AV_CODEC_ID_ADPCM_IMA_DK4:
if (avctx->block_align > 0)
buf_size = FFMIN(buf_size, avctx->block_align);
nb_samples = 1 + (buf_size - 4 * ch) * 2 / ch;
break;
case AV_CODEC_ID_ADPCM_IMA_RAD:
if (avctx->block_align > 0)
buf_size = FFMIN(buf_size, avctx->block_align);
nb_samples = (buf_size - 4 * ch) * 2 / ch;
break;
case AV_CODEC_ID_ADPCM_IMA_WAV:
{
int bsize = ff_adpcm_ima_block_sizes[avctx->bits_per_coded_sample - 2];
int bsamples = ff_adpcm_ima_block_samples[avctx->bits_per_coded_sample - 2];
if (avctx->block_align > 0)
buf_size = FFMIN(buf_size, avctx->block_align);
nb_samples = 1 + (buf_size - 4 * ch) / (bsize * ch) * bsamples;
break;
}
case AV_CODEC_ID_ADPCM_MS:
if (avctx->block_align > 0)
buf_size = FFMIN(buf_size, avctx->block_align);
nb_samples = 2 + (buf_size - 7 * ch) * 2 / ch;
break;
case AV_CODEC_ID_ADPCM_SBPRO_2:
case AV_CODEC_ID_ADPCM_SBPRO_3:
case AV_CODEC_ID_ADPCM_SBPRO_4:
{
int samples_per_byte;
switch (avctx->codec->id) {
case AV_CODEC_ID_ADPCM_SBPRO_2: samples_per_byte = 4; break;
case AV_CODEC_ID_ADPCM_SBPRO_3: samples_per_byte = 3; break;
case AV_CODEC_ID_ADPCM_SBPRO_4: samples_per_byte = 2; break;
}
if (!s->status[0].step_index) {
nb_samples++;
buf_size -= ch;
}
nb_samples += buf_size * samples_per_byte / ch;
break;
}
case AV_CODEC_ID_ADPCM_SWF:
{
int buf_bits = buf_size * 8 - 2;
int nbits = (bytestream2_get_byte(gb) >> 6) + 2;
int block_hdr_size = 22 * ch;
int block_size = block_hdr_size + nbits * ch * 4095;
int nblocks = buf_bits / block_size;
int bits_left = buf_bits - nblocks * block_size;
nb_samples = nblocks * 4096;
if (bits_left >= block_hdr_size)
nb_samples += 1 + (bits_left - block_hdr_size) / (nbits * ch);
break;
}
case AV_CODEC_ID_ADPCM_THP:
if (avctx->extradata) {
nb_samples = buf_size / (8 * ch) * 14;
break;
}
has_coded_samples = 1;
bytestream2_skip(gb, 4); // channel size
*coded_samples = bytestream2_get_be32(gb);
*coded_samples -= *coded_samples % 14;
nb_samples = (buf_size - (8 + 36 * ch)) / (8 * ch) * 14;
break;
case AV_CODEC_ID_ADPCM_AFC:
nb_samples = buf_size / (9 * ch) * 16;
break;
case AV_CODEC_ID_ADPCM_XA:
nb_samples = (buf_size / 128) * 224 / ch;
break;
case AV_CODEC_ID_ADPCM_DTK:
nb_samples = buf_size / (16 * ch) * 28;
break;
}
/* validate coded sample count */
if (has_coded_samples && (*coded_samples <= 0 || *coded_samples > nb_samples))
return AVERROR_INVALIDDATA;
return nb_samples;
}
| true | FFmpeg | 3c803ed9cb23e5a8d76b6c31d8a8c71cac27e769 | static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
int buf_size, int *coded_samples, int *approx_nb_samples)
{
ADPCMDecodeContext *s = avctx->priv_data;
int nb_samples = 0;
int ch = avctx->channels;
int has_coded_samples = 0;
int header_size;
*coded_samples = 0;
*approx_nb_samples = 0;
if(ch <= 0)
return 0;
switch (avctx->codec->id) {
case AV_CODEC_ID_ADPCM_EA_XAS:
if (buf_size < 76 * ch)
return 0;
nb_samples = 128;
break;
case AV_CODEC_ID_ADPCM_IMA_QT:
if (buf_size < 34 * ch)
return 0;
nb_samples = 64;
break;
case AV_CODEC_ID_ADPCM_CT:
case AV_CODEC_ID_ADPCM_IMA_APC:
case AV_CODEC_ID_ADPCM_IMA_EA_SEAD:
case AV_CODEC_ID_ADPCM_IMA_OKI:
case AV_CODEC_ID_ADPCM_IMA_WS:
case AV_CODEC_ID_ADPCM_YAMAHA:
nb_samples = buf_size * 2 / ch;
break;
}
if (nb_samples)
return nb_samples;
header_size = 0;
switch (avctx->codec->id) {
case AV_CODEC_ID_ADPCM_4XM:
case AV_CODEC_ID_ADPCM_IMA_ISS: header_size = 4 * ch; break;
case AV_CODEC_ID_ADPCM_IMA_AMV: header_size = 8; break;
case AV_CODEC_ID_ADPCM_IMA_SMJPEG: header_size = 4 * ch; break;
}
if (header_size > 0)
return (buf_size - header_size) * 2 / ch;
switch (avctx->codec->id) {
case AV_CODEC_ID_ADPCM_EA:
has_coded_samples = 1;
*coded_samples = bytestream2_get_le32(gb);
*coded_samples -= *coded_samples % 28;
nb_samples = (buf_size - 12) / 30 * 28;
break;
case AV_CODEC_ID_ADPCM_IMA_EA_EACS:
has_coded_samples = 1;
*coded_samples = bytestream2_get_le32(gb);
nb_samples = (buf_size - (4 + 8 * ch)) * 2 / ch;
break;
case AV_CODEC_ID_ADPCM_EA_MAXIS_XA:
nb_samples = (buf_size - ch) / ch * 2;
break;
case AV_CODEC_ID_ADPCM_EA_R1:
case AV_CODEC_ID_ADPCM_EA_R2:
case AV_CODEC_ID_ADPCM_EA_R3:
has_coded_samples = 1;
switch (avctx->codec->id) {
case AV_CODEC_ID_ADPCM_EA_R1:
header_size = 4 + 9 * ch;
*coded_samples = bytestream2_get_le32(gb);
break;
case AV_CODEC_ID_ADPCM_EA_R2:
header_size = 4 + 5 * ch;
*coded_samples = bytestream2_get_le32(gb);
break;
case AV_CODEC_ID_ADPCM_EA_R3:
header_size = 4 + 5 * ch;
*coded_samples = bytestream2_get_be32(gb);
break;
}
*coded_samples -= *coded_samples % 28;
nb_samples = (buf_size - header_size) * 2 / ch;
nb_samples -= nb_samples % 28;
*approx_nb_samples = 1;
break;
case AV_CODEC_ID_ADPCM_IMA_DK3:
if (avctx->block_align > 0)
buf_size = FFMIN(buf_size, avctx->block_align);
nb_samples = ((buf_size - 16) * 2 / 3 * 4) / ch;
break;
case AV_CODEC_ID_ADPCM_IMA_DK4:
if (avctx->block_align > 0)
buf_size = FFMIN(buf_size, avctx->block_align);
nb_samples = 1 + (buf_size - 4 * ch) * 2 / ch;
break;
case AV_CODEC_ID_ADPCM_IMA_RAD:
if (avctx->block_align > 0)
buf_size = FFMIN(buf_size, avctx->block_align);
nb_samples = (buf_size - 4 * ch) * 2 / ch;
break;
case AV_CODEC_ID_ADPCM_IMA_WAV:
{
int bsize = ff_adpcm_ima_block_sizes[avctx->bits_per_coded_sample - 2];
int bsamples = ff_adpcm_ima_block_samples[avctx->bits_per_coded_sample - 2];
if (avctx->block_align > 0)
buf_size = FFMIN(buf_size, avctx->block_align);
nb_samples = 1 + (buf_size - 4 * ch) / (bsize * ch) * bsamples;
break;
}
case AV_CODEC_ID_ADPCM_MS:
if (avctx->block_align > 0)
buf_size = FFMIN(buf_size, avctx->block_align);
nb_samples = 2 + (buf_size - 7 * ch) * 2 / ch;
break;
case AV_CODEC_ID_ADPCM_SBPRO_2:
case AV_CODEC_ID_ADPCM_SBPRO_3:
case AV_CODEC_ID_ADPCM_SBPRO_4:
{
int samples_per_byte;
switch (avctx->codec->id) {
case AV_CODEC_ID_ADPCM_SBPRO_2: samples_per_byte = 4; break;
case AV_CODEC_ID_ADPCM_SBPRO_3: samples_per_byte = 3; break;
case AV_CODEC_ID_ADPCM_SBPRO_4: samples_per_byte = 2; break;
}
if (!s->status[0].step_index) {
nb_samples++;
buf_size -= ch;
}
nb_samples += buf_size * samples_per_byte / ch;
break;
}
case AV_CODEC_ID_ADPCM_SWF:
{
int buf_bits = buf_size * 8 - 2;
int nbits = (bytestream2_get_byte(gb) >> 6) + 2;
int block_hdr_size = 22 * ch;
int block_size = block_hdr_size + nbits * ch * 4095;
int nblocks = buf_bits / block_size;
int bits_left = buf_bits - nblocks * block_size;
nb_samples = nblocks * 4096;
if (bits_left >= block_hdr_size)
nb_samples += 1 + (bits_left - block_hdr_size) / (nbits * ch);
break;
}
case AV_CODEC_ID_ADPCM_THP:
if (avctx->extradata) {
nb_samples = buf_size / (8 * ch) * 14;
break;
}
has_coded_samples = 1;
bytestream2_skip(gb, 4);
*coded_samples = bytestream2_get_be32(gb);
*coded_samples -= *coded_samples % 14;
nb_samples = (buf_size - (8 + 36 * ch)) / (8 * ch) * 14;
break;
case AV_CODEC_ID_ADPCM_AFC:
nb_samples = buf_size / (9 * ch) * 16;
break;
case AV_CODEC_ID_ADPCM_XA:
nb_samples = (buf_size / 128) * 224 / ch;
break;
case AV_CODEC_ID_ADPCM_DTK:
nb_samples = buf_size / (16 * ch) * 28;
break;
}
if (has_coded_samples && (*coded_samples <= 0 || *coded_samples > nb_samples))
return AVERROR_INVALIDDATA;
return nb_samples;
}
| {
"code": [
" nb_samples = 2 + (buf_size - 7 * ch) * 2 / ch;"
],
"line_no": [
239
]
} | static int FUNC_0(AVCodecContext *VAR_0, GetByteContext *VAR_1,
int VAR_2, int *VAR_3, int *VAR_4)
{
ADPCMDecodeContext *s = VAR_0->priv_data;
int VAR_5 = 0;
int VAR_6 = VAR_0->channels;
int VAR_7 = 0;
int VAR_8;
*VAR_3 = 0;
*VAR_4 = 0;
if(VAR_6 <= 0)
return 0;
switch (VAR_0->codec->id) {
case AV_CODEC_ID_ADPCM_EA_XAS:
if (VAR_2 < 76 * VAR_6)
return 0;
VAR_5 = 128;
break;
case AV_CODEC_ID_ADPCM_IMA_QT:
if (VAR_2 < 34 * VAR_6)
return 0;
VAR_5 = 64;
break;
case AV_CODEC_ID_ADPCM_CT:
case AV_CODEC_ID_ADPCM_IMA_APC:
case AV_CODEC_ID_ADPCM_IMA_EA_SEAD:
case AV_CODEC_ID_ADPCM_IMA_OKI:
case AV_CODEC_ID_ADPCM_IMA_WS:
case AV_CODEC_ID_ADPCM_YAMAHA:
VAR_5 = VAR_2 * 2 / VAR_6;
break;
}
if (VAR_5)
return VAR_5;
VAR_8 = 0;
switch (VAR_0->codec->id) {
case AV_CODEC_ID_ADPCM_4XM:
case AV_CODEC_ID_ADPCM_IMA_ISS: VAR_8 = 4 * VAR_6; break;
case AV_CODEC_ID_ADPCM_IMA_AMV: VAR_8 = 8; break;
case AV_CODEC_ID_ADPCM_IMA_SMJPEG: VAR_8 = 4 * VAR_6; break;
}
if (VAR_8 > 0)
return (VAR_2 - VAR_8) * 2 / VAR_6;
switch (VAR_0->codec->id) {
case AV_CODEC_ID_ADPCM_EA:
VAR_7 = 1;
*VAR_3 = bytestream2_get_le32(VAR_1);
*VAR_3 -= *VAR_3 % 28;
VAR_5 = (VAR_2 - 12) / 30 * 28;
break;
case AV_CODEC_ID_ADPCM_IMA_EA_EACS:
VAR_7 = 1;
*VAR_3 = bytestream2_get_le32(VAR_1);
VAR_5 = (VAR_2 - (4 + 8 * VAR_6)) * 2 / VAR_6;
break;
case AV_CODEC_ID_ADPCM_EA_MAXIS_XA:
VAR_5 = (VAR_2 - VAR_6) / VAR_6 * 2;
break;
case AV_CODEC_ID_ADPCM_EA_R1:
case AV_CODEC_ID_ADPCM_EA_R2:
case AV_CODEC_ID_ADPCM_EA_R3:
VAR_7 = 1;
switch (VAR_0->codec->id) {
case AV_CODEC_ID_ADPCM_EA_R1:
VAR_8 = 4 + 9 * VAR_6;
*VAR_3 = bytestream2_get_le32(VAR_1);
break;
case AV_CODEC_ID_ADPCM_EA_R2:
VAR_8 = 4 + 5 * VAR_6;
*VAR_3 = bytestream2_get_le32(VAR_1);
break;
case AV_CODEC_ID_ADPCM_EA_R3:
VAR_8 = 4 + 5 * VAR_6;
*VAR_3 = bytestream2_get_be32(VAR_1);
break;
}
*VAR_3 -= *VAR_3 % 28;
VAR_5 = (VAR_2 - VAR_8) * 2 / VAR_6;
VAR_5 -= VAR_5 % 28;
*VAR_4 = 1;
break;
case AV_CODEC_ID_ADPCM_IMA_DK3:
if (VAR_0->block_align > 0)
VAR_2 = FFMIN(VAR_2, VAR_0->block_align);
VAR_5 = ((VAR_2 - 16) * 2 / 3 * 4) / VAR_6;
break;
case AV_CODEC_ID_ADPCM_IMA_DK4:
if (VAR_0->block_align > 0)
VAR_2 = FFMIN(VAR_2, VAR_0->block_align);
VAR_5 = 1 + (VAR_2 - 4 * VAR_6) * 2 / VAR_6;
break;
case AV_CODEC_ID_ADPCM_IMA_RAD:
if (VAR_0->block_align > 0)
VAR_2 = FFMIN(VAR_2, VAR_0->block_align);
VAR_5 = (VAR_2 - 4 * VAR_6) * 2 / VAR_6;
break;
case AV_CODEC_ID_ADPCM_IMA_WAV:
{
int VAR_9 = ff_adpcm_ima_block_sizes[VAR_0->bits_per_coded_sample - 2];
int VAR_10 = ff_adpcm_ima_block_samples[VAR_0->bits_per_coded_sample - 2];
if (VAR_0->block_align > 0)
VAR_2 = FFMIN(VAR_2, VAR_0->block_align);
VAR_5 = 1 + (VAR_2 - 4 * VAR_6) / (VAR_9 * VAR_6) * VAR_10;
break;
}
case AV_CODEC_ID_ADPCM_MS:
if (VAR_0->block_align > 0)
VAR_2 = FFMIN(VAR_2, VAR_0->block_align);
VAR_5 = 2 + (VAR_2 - 7 * VAR_6) * 2 / VAR_6;
break;
case AV_CODEC_ID_ADPCM_SBPRO_2:
case AV_CODEC_ID_ADPCM_SBPRO_3:
case AV_CODEC_ID_ADPCM_SBPRO_4:
{
int VAR_11;
switch (VAR_0->codec->id) {
case AV_CODEC_ID_ADPCM_SBPRO_2: VAR_11 = 4; break;
case AV_CODEC_ID_ADPCM_SBPRO_3: VAR_11 = 3; break;
case AV_CODEC_ID_ADPCM_SBPRO_4: VAR_11 = 2; break;
}
if (!s->status[0].step_index) {
VAR_5++;
VAR_2 -= VAR_6;
}
VAR_5 += VAR_2 * VAR_11 / VAR_6;
break;
}
case AV_CODEC_ID_ADPCM_SWF:
{
int VAR_12 = VAR_2 * 8 - 2;
int VAR_13 = (bytestream2_get_byte(VAR_1) >> 6) + 2;
int VAR_14 = 22 * VAR_6;
int VAR_15 = VAR_14 + VAR_13 * VAR_6 * 4095;
int VAR_16 = VAR_12 / VAR_15;
int VAR_17 = VAR_12 - VAR_16 * VAR_15;
VAR_5 = VAR_16 * 4096;
if (VAR_17 >= VAR_14)
VAR_5 += 1 + (VAR_17 - VAR_14) / (VAR_13 * VAR_6);
break;
}
case AV_CODEC_ID_ADPCM_THP:
if (VAR_0->extradata) {
VAR_5 = VAR_2 / (8 * VAR_6) * 14;
break;
}
VAR_7 = 1;
bytestream2_skip(VAR_1, 4);
*VAR_3 = bytestream2_get_be32(VAR_1);
*VAR_3 -= *VAR_3 % 14;
VAR_5 = (VAR_2 - (8 + 36 * VAR_6)) / (8 * VAR_6) * 14;
break;
case AV_CODEC_ID_ADPCM_AFC:
VAR_5 = VAR_2 / (9 * VAR_6) * 16;
break;
case AV_CODEC_ID_ADPCM_XA:
VAR_5 = (VAR_2 / 128) * 224 / VAR_6;
break;
case AV_CODEC_ID_ADPCM_DTK:
VAR_5 = VAR_2 / (16 * VAR_6) * 28;
break;
}
if (VAR_7 && (*VAR_3 <= 0 || *VAR_3 > VAR_5))
return AVERROR_INVALIDDATA;
return VAR_5;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, GetByteContext *VAR_1,\nint VAR_2, int *VAR_3, int *VAR_4)\n{",
"ADPCMDecodeContext *s = VAR_0->priv_data;",
"int VAR_5 = 0;",
"int VAR_6 = VAR_0->channels;",
"int VAR_7 = 0;",
"int VAR_8;",
"*VAR_3 = 0;",
"*VAR_4 = 0;",
"if(VAR_6 <= 0)\nreturn 0;",
"switch (VAR_0->codec->id) {",
"case AV_CODEC_ID_ADPCM_EA_XAS:\nif (VAR_2 < 76 * VAR_6)\nreturn 0;",
"VAR_5 = 128;",
"break;",
"case AV_CODEC_ID_ADPCM_IMA_QT:\nif (VAR_2 < 34 * VAR_6)\nreturn 0;",
"VAR_5 = 64;",
"break;",
"case AV_CODEC_ID_ADPCM_CT:\ncase AV_CODEC_ID_ADPCM_IMA_APC:\ncase AV_CODEC_ID_ADPCM_IMA_EA_SEAD:\ncase AV_CODEC_ID_ADPCM_IMA_OKI:\ncase AV_CODEC_ID_ADPCM_IMA_WS:\ncase AV_CODEC_ID_ADPCM_YAMAHA:\nVAR_5 = VAR_2 * 2 / VAR_6;",
"break;",
"}",
"if (VAR_5)\nreturn VAR_5;",
"VAR_8 = 0;",
"switch (VAR_0->codec->id) {",
"case AV_CODEC_ID_ADPCM_4XM:\ncase AV_CODEC_ID_ADPCM_IMA_ISS: VAR_8 = 4 * VAR_6; break;",
"case AV_CODEC_ID_ADPCM_IMA_AMV: VAR_8 = 8; break;",
"case AV_CODEC_ID_ADPCM_IMA_SMJPEG: VAR_8 = 4 * VAR_6; break;",
"}",
"if (VAR_8 > 0)\nreturn (VAR_2 - VAR_8) * 2 / VAR_6;",
"switch (VAR_0->codec->id) {",
"case AV_CODEC_ID_ADPCM_EA:\nVAR_7 = 1;",
"*VAR_3 = bytestream2_get_le32(VAR_1);",
"*VAR_3 -= *VAR_3 % 28;",
"VAR_5 = (VAR_2 - 12) / 30 * 28;",
"break;",
"case AV_CODEC_ID_ADPCM_IMA_EA_EACS:\nVAR_7 = 1;",
"*VAR_3 = bytestream2_get_le32(VAR_1);",
"VAR_5 = (VAR_2 - (4 + 8 * VAR_6)) * 2 / VAR_6;",
"break;",
"case AV_CODEC_ID_ADPCM_EA_MAXIS_XA:\nVAR_5 = (VAR_2 - VAR_6) / VAR_6 * 2;",
"break;",
"case AV_CODEC_ID_ADPCM_EA_R1:\ncase AV_CODEC_ID_ADPCM_EA_R2:\ncase AV_CODEC_ID_ADPCM_EA_R3:\nVAR_7 = 1;",
"switch (VAR_0->codec->id) {",
"case AV_CODEC_ID_ADPCM_EA_R1:\nVAR_8 = 4 + 9 * VAR_6;",
"*VAR_3 = bytestream2_get_le32(VAR_1);",
"break;",
"case AV_CODEC_ID_ADPCM_EA_R2:\nVAR_8 = 4 + 5 * VAR_6;",
"*VAR_3 = bytestream2_get_le32(VAR_1);",
"break;",
"case AV_CODEC_ID_ADPCM_EA_R3:\nVAR_8 = 4 + 5 * VAR_6;",
"*VAR_3 = bytestream2_get_be32(VAR_1);",
"break;",
"}",
"*VAR_3 -= *VAR_3 % 28;",
"VAR_5 = (VAR_2 - VAR_8) * 2 / VAR_6;",
"VAR_5 -= VAR_5 % 28;",
"*VAR_4 = 1;",
"break;",
"case AV_CODEC_ID_ADPCM_IMA_DK3:\nif (VAR_0->block_align > 0)\nVAR_2 = FFMIN(VAR_2, VAR_0->block_align);",
"VAR_5 = ((VAR_2 - 16) * 2 / 3 * 4) / VAR_6;",
"break;",
"case AV_CODEC_ID_ADPCM_IMA_DK4:\nif (VAR_0->block_align > 0)\nVAR_2 = FFMIN(VAR_2, VAR_0->block_align);",
"VAR_5 = 1 + (VAR_2 - 4 * VAR_6) * 2 / VAR_6;",
"break;",
"case AV_CODEC_ID_ADPCM_IMA_RAD:\nif (VAR_0->block_align > 0)\nVAR_2 = FFMIN(VAR_2, VAR_0->block_align);",
"VAR_5 = (VAR_2 - 4 * VAR_6) * 2 / VAR_6;",
"break;",
"case AV_CODEC_ID_ADPCM_IMA_WAV:\n{",
"int VAR_9 = ff_adpcm_ima_block_sizes[VAR_0->bits_per_coded_sample - 2];",
"int VAR_10 = ff_adpcm_ima_block_samples[VAR_0->bits_per_coded_sample - 2];",
"if (VAR_0->block_align > 0)\nVAR_2 = FFMIN(VAR_2, VAR_0->block_align);",
"VAR_5 = 1 + (VAR_2 - 4 * VAR_6) / (VAR_9 * VAR_6) * VAR_10;",
"break;",
"}",
"case AV_CODEC_ID_ADPCM_MS:\nif (VAR_0->block_align > 0)\nVAR_2 = FFMIN(VAR_2, VAR_0->block_align);",
"VAR_5 = 2 + (VAR_2 - 7 * VAR_6) * 2 / VAR_6;",
"break;",
"case AV_CODEC_ID_ADPCM_SBPRO_2:\ncase AV_CODEC_ID_ADPCM_SBPRO_3:\ncase AV_CODEC_ID_ADPCM_SBPRO_4:\n{",
"int VAR_11;",
"switch (VAR_0->codec->id) {",
"case AV_CODEC_ID_ADPCM_SBPRO_2: VAR_11 = 4; break;",
"case AV_CODEC_ID_ADPCM_SBPRO_3: VAR_11 = 3; break;",
"case AV_CODEC_ID_ADPCM_SBPRO_4: VAR_11 = 2; break;",
"}",
"if (!s->status[0].step_index) {",
"VAR_5++;",
"VAR_2 -= VAR_6;",
"}",
"VAR_5 += VAR_2 * VAR_11 / VAR_6;",
"break;",
"}",
"case AV_CODEC_ID_ADPCM_SWF:\n{",
"int VAR_12 = VAR_2 * 8 - 2;",
"int VAR_13 = (bytestream2_get_byte(VAR_1) >> 6) + 2;",
"int VAR_14 = 22 * VAR_6;",
"int VAR_15 = VAR_14 + VAR_13 * VAR_6 * 4095;",
"int VAR_16 = VAR_12 / VAR_15;",
"int VAR_17 = VAR_12 - VAR_16 * VAR_15;",
"VAR_5 = VAR_16 * 4096;",
"if (VAR_17 >= VAR_14)\nVAR_5 += 1 + (VAR_17 - VAR_14) / (VAR_13 * VAR_6);",
"break;",
"}",
"case AV_CODEC_ID_ADPCM_THP:\nif (VAR_0->extradata) {",
"VAR_5 = VAR_2 / (8 * VAR_6) * 14;",
"break;",
"}",
"VAR_7 = 1;",
"bytestream2_skip(VAR_1, 4);",
"*VAR_3 = bytestream2_get_be32(VAR_1);",
"*VAR_3 -= *VAR_3 % 14;",
"VAR_5 = (VAR_2 - (8 + 36 * VAR_6)) / (8 * VAR_6) * 14;",
"break;",
"case AV_CODEC_ID_ADPCM_AFC:\nVAR_5 = VAR_2 / (9 * VAR_6) * 16;",
"break;",
"case AV_CODEC_ID_ADPCM_XA:\nVAR_5 = (VAR_2 / 128) * 224 / VAR_6;",
"break;",
"case AV_CODEC_ID_ADPCM_DTK:\nVAR_5 = VAR_2 / (16 * VAR_6) * 28;",
"break;",
"}",
"if (VAR_7 && (*VAR_3 <= 0 || *VAR_3 > VAR_5))\nreturn AVERROR_INVALIDDATA;",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
25,
27
],
[
31
],
[
35,
37,
39
],
[
41
],
[
43
],
[
45,
47,
49
],
[
51
],
[
53
],
[
57,
59,
61,
63,
65,
67,
69
],
[
71
],
[
73
],
[
75,
77
],
[
83
],
[
85
],
[
87,
89
],
[
91
],
[
93
],
[
95
],
[
97,
99
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119,
121
],
[
123
],
[
125
],
[
127
],
[
129,
131
],
[
133
],
[
135,
137,
139,
145
],
[
147
],
[
149,
151
],
[
153
],
[
155
],
[
157,
159
],
[
161
],
[
163
],
[
165,
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185,
187,
189
],
[
191
],
[
193
],
[
195,
197,
199
],
[
201
],
[
203
],
[
205,
207,
209
],
[
211
],
[
213
],
[
215,
217
],
[
219
],
[
221
],
[
223,
225
],
[
227
],
[
229
],
[
231
],
[
233,
235,
237
],
[
239
],
[
241
],
[
243,
245,
247,
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277,
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295,
297
],
[
299
],
[
301
],
[
303,
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325,
327
],
[
329
],
[
331,
333
],
[
335
],
[
337,
339
],
[
341
],
[
343
],
[
349,
351
],
[
355
],
[
357
]
] |
3,636 | static void serial_receive1(void *opaque, const uint8_t *buf, int size)
{
SerialState *s = opaque;
serial_receive_byte(s, buf[0]);
}
| true | qemu | 81174dae3f9189519cd60c7b79e91c291b021bbe | static void serial_receive1(void *opaque, const uint8_t *buf, int size)
{
SerialState *s = opaque;
serial_receive_byte(s, buf[0]);
}
| {
"code": [
" SerialState *s = opaque;",
" serial_receive_byte(s, buf[0]);"
],
"line_no": [
5,
7
]
} | static void FUNC_0(void *VAR_0, const uint8_t *VAR_1, int VAR_2)
{
SerialState *s = VAR_0;
serial_receive_byte(s, VAR_1[0]);
}
| [
"static void FUNC_0(void *VAR_0, const uint8_t *VAR_1, int VAR_2)\n{",
"SerialState *s = VAR_0;",
"serial_receive_byte(s, VAR_1[0]);",
"}"
] | [
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
3,639 | static TCGv_i32 gen_get_asi(DisasContext *dc, int insn)
{
int asi;
if (IS_IMM) {
#ifdef TARGET_SPARC64
asi = dc->asi;
#else
gen_exception(dc, TT_ILL_INSN);
asi = 0;
#endif
} else {
asi = GET_FIELD(insn, 19, 26);
}
return tcg_const_i32(asi);
}
| false | qemu | 7ec1e5ea4bd0700fa48da86bffa2fcc6146c410a | static TCGv_i32 gen_get_asi(DisasContext *dc, int insn)
{
int asi;
if (IS_IMM) {
#ifdef TARGET_SPARC64
asi = dc->asi;
#else
gen_exception(dc, TT_ILL_INSN);
asi = 0;
#endif
} else {
asi = GET_FIELD(insn, 19, 26);
}
return tcg_const_i32(asi);
}
| {
"code": [],
"line_no": []
} | static TCGv_i32 FUNC_0(DisasContext *dc, int insn)
{
int VAR_0;
if (IS_IMM) {
#ifdef TARGET_SPARC64
VAR_0 = dc->VAR_0;
#else
gen_exception(dc, TT_ILL_INSN);
VAR_0 = 0;
#endif
} else {
VAR_0 = GET_FIELD(insn, 19, 26);
}
return tcg_const_i32(VAR_0);
}
| [
"static TCGv_i32 FUNC_0(DisasContext *dc, int insn)\n{",
"int VAR_0;",
"if (IS_IMM) {",
"#ifdef TARGET_SPARC64\nVAR_0 = dc->VAR_0;",
"#else\ngen_exception(dc, TT_ILL_INSN);",
"VAR_0 = 0;",
"#endif\n} else {",
"VAR_0 = GET_FIELD(insn, 19, 26);",
"}",
"return tcg_const_i32(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
15,
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
]
] |
3,640 | static void setup_rt_frame(int sig, struct target_sigaction *ka,
target_siginfo_t *info,
target_sigset_t *set, CPUSH4State *regs)
{
struct target_rt_sigframe *frame;
abi_ulong frame_addr;
int i;
int err = 0;
int signal;
frame_addr = get_sigframe(ka, regs->gregs[15], sizeof(*frame));
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto give_sigsegv;
signal = current_exec_domain_sig(sig);
err |= copy_siginfo_to_user(&frame->info, info);
/* Create the ucontext. */
__put_user(0, &frame->uc.tuc_flags);
__put_user(0, (unsigned long *)&frame->uc.tuc_link);
__put_user((unsigned long)target_sigaltstack_used.ss_sp,
&frame->uc.tuc_stack.ss_sp);
__put_user(sas_ss_flags(regs->gregs[15]),
&frame->uc.tuc_stack.ss_flags);
__put_user(target_sigaltstack_used.ss_size,
&frame->uc.tuc_stack.ss_size);
setup_sigcontext(&frame->uc.tuc_mcontext,
regs, set->sig[0]);
for(i = 0; i < TARGET_NSIG_WORDS; i++) {
__put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]);
}
/* Set up to return from userspace. If provided, use a stub
already in userspace. */
if (ka->sa_flags & TARGET_SA_RESTORER) {
regs->pr = (unsigned long) ka->sa_restorer;
} else {
/* Generate return code (system call to sigreturn) */
__put_user(MOVW(2), &frame->retcode[0]);
__put_user(TRAP_NOARG, &frame->retcode[1]);
__put_user((TARGET_NR_rt_sigreturn), &frame->retcode[2]);
regs->pr = (unsigned long) frame->retcode;
}
if (err)
goto give_sigsegv;
/* Set up registers for signal handler */
regs->gregs[15] = frame_addr;
regs->gregs[4] = signal; /* Arg for signal handler */
regs->gregs[5] = frame_addr + offsetof(typeof(*frame), info);
regs->gregs[6] = frame_addr + offsetof(typeof(*frame), uc);
regs->pc = (unsigned long) ka->_sa_handler;
unlock_user_struct(frame, frame_addr, 1);
return;
give_sigsegv:
unlock_user_struct(frame, frame_addr, 1);
force_sig(TARGET_SIGSEGV);
}
| false | qemu | b0fd8d18683f0d77a8e6b482771ebea82234d727 | static void setup_rt_frame(int sig, struct target_sigaction *ka,
target_siginfo_t *info,
target_sigset_t *set, CPUSH4State *regs)
{
struct target_rt_sigframe *frame;
abi_ulong frame_addr;
int i;
int err = 0;
int signal;
frame_addr = get_sigframe(ka, regs->gregs[15], sizeof(*frame));
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto give_sigsegv;
signal = current_exec_domain_sig(sig);
err |= copy_siginfo_to_user(&frame->info, info);
__put_user(0, &frame->uc.tuc_flags);
__put_user(0, (unsigned long *)&frame->uc.tuc_link);
__put_user((unsigned long)target_sigaltstack_used.ss_sp,
&frame->uc.tuc_stack.ss_sp);
__put_user(sas_ss_flags(regs->gregs[15]),
&frame->uc.tuc_stack.ss_flags);
__put_user(target_sigaltstack_used.ss_size,
&frame->uc.tuc_stack.ss_size);
setup_sigcontext(&frame->uc.tuc_mcontext,
regs, set->sig[0]);
for(i = 0; i < TARGET_NSIG_WORDS; i++) {
__put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]);
}
if (ka->sa_flags & TARGET_SA_RESTORER) {
regs->pr = (unsigned long) ka->sa_restorer;
} else {
__put_user(MOVW(2), &frame->retcode[0]);
__put_user(TRAP_NOARG, &frame->retcode[1]);
__put_user((TARGET_NR_rt_sigreturn), &frame->retcode[2]);
regs->pr = (unsigned long) frame->retcode;
}
if (err)
goto give_sigsegv;
regs->gregs[15] = frame_addr;
regs->gregs[4] = signal;
regs->gregs[5] = frame_addr + offsetof(typeof(*frame), info);
regs->gregs[6] = frame_addr + offsetof(typeof(*frame), uc);
regs->pc = (unsigned long) ka->_sa_handler;
unlock_user_struct(frame, frame_addr, 1);
return;
give_sigsegv:
unlock_user_struct(frame, frame_addr, 1);
force_sig(TARGET_SIGSEGV);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(int VAR_0, struct target_sigaction *VAR_1,
target_siginfo_t *VAR_2,
target_sigset_t *VAR_3, CPUSH4State *VAR_4)
{
struct target_rt_sigframe *VAR_5;
abi_ulong frame_addr;
int VAR_6;
int VAR_7 = 0;
int VAR_8;
frame_addr = get_sigframe(VAR_1, VAR_4->gregs[15], sizeof(*VAR_5));
if (!lock_user_struct(VERIFY_WRITE, VAR_5, frame_addr, 0))
goto give_sigsegv;
VAR_8 = current_exec_domain_sig(VAR_0);
VAR_7 |= copy_siginfo_to_user(&VAR_5->VAR_2, VAR_2);
__put_user(0, &VAR_5->uc.tuc_flags);
__put_user(0, (unsigned long *)&VAR_5->uc.tuc_link);
__put_user((unsigned long)target_sigaltstack_used.ss_sp,
&VAR_5->uc.tuc_stack.ss_sp);
__put_user(sas_ss_flags(VAR_4->gregs[15]),
&VAR_5->uc.tuc_stack.ss_flags);
__put_user(target_sigaltstack_used.ss_size,
&VAR_5->uc.tuc_stack.ss_size);
setup_sigcontext(&VAR_5->uc.tuc_mcontext,
VAR_4, VAR_3->VAR_0[0]);
for(VAR_6 = 0; VAR_6 < TARGET_NSIG_WORDS; VAR_6++) {
__put_user(VAR_3->VAR_0[VAR_6], &VAR_5->uc.tuc_sigmask.VAR_0[VAR_6]);
}
if (VAR_1->sa_flags & TARGET_SA_RESTORER) {
VAR_4->pr = (unsigned long) VAR_1->sa_restorer;
} else {
__put_user(MOVW(2), &VAR_5->retcode[0]);
__put_user(TRAP_NOARG, &VAR_5->retcode[1]);
__put_user((TARGET_NR_rt_sigreturn), &VAR_5->retcode[2]);
VAR_4->pr = (unsigned long) VAR_5->retcode;
}
if (VAR_7)
goto give_sigsegv;
VAR_4->gregs[15] = frame_addr;
VAR_4->gregs[4] = VAR_8;
VAR_4->gregs[5] = frame_addr + offsetof(typeof(*VAR_5), VAR_2);
VAR_4->gregs[6] = frame_addr + offsetof(typeof(*VAR_5), uc);
VAR_4->pc = (unsigned long) VAR_1->_sa_handler;
unlock_user_struct(VAR_5, frame_addr, 1);
return;
give_sigsegv:
unlock_user_struct(VAR_5, frame_addr, 1);
force_sig(TARGET_SIGSEGV);
}
| [
"static void FUNC_0(int VAR_0, struct target_sigaction *VAR_1,\ntarget_siginfo_t *VAR_2,\ntarget_sigset_t *VAR_3, CPUSH4State *VAR_4)\n{",
"struct target_rt_sigframe *VAR_5;",
"abi_ulong frame_addr;",
"int VAR_6;",
"int VAR_7 = 0;",
"int VAR_8;",
"frame_addr = get_sigframe(VAR_1, VAR_4->gregs[15], sizeof(*VAR_5));",
"if (!lock_user_struct(VERIFY_WRITE, VAR_5, frame_addr, 0))\ngoto give_sigsegv;",
"VAR_8 = current_exec_domain_sig(VAR_0);",
"VAR_7 |= copy_siginfo_to_user(&VAR_5->VAR_2, VAR_2);",
"__put_user(0, &VAR_5->uc.tuc_flags);",
"__put_user(0, (unsigned long *)&VAR_5->uc.tuc_link);",
"__put_user((unsigned long)target_sigaltstack_used.ss_sp,\n&VAR_5->uc.tuc_stack.ss_sp);",
"__put_user(sas_ss_flags(VAR_4->gregs[15]),\n&VAR_5->uc.tuc_stack.ss_flags);",
"__put_user(target_sigaltstack_used.ss_size,\n&VAR_5->uc.tuc_stack.ss_size);",
"setup_sigcontext(&VAR_5->uc.tuc_mcontext,\nVAR_4, VAR_3->VAR_0[0]);",
"for(VAR_6 = 0; VAR_6 < TARGET_NSIG_WORDS; VAR_6++) {",
"__put_user(VAR_3->VAR_0[VAR_6], &VAR_5->uc.tuc_sigmask.VAR_0[VAR_6]);",
"}",
"if (VAR_1->sa_flags & TARGET_SA_RESTORER) {",
"VAR_4->pr = (unsigned long) VAR_1->sa_restorer;",
"} else {",
"__put_user(MOVW(2), &VAR_5->retcode[0]);",
"__put_user(TRAP_NOARG, &VAR_5->retcode[1]);",
"__put_user((TARGET_NR_rt_sigreturn), &VAR_5->retcode[2]);",
"VAR_4->pr = (unsigned long) VAR_5->retcode;",
"}",
"if (VAR_7)\ngoto give_sigsegv;",
"VAR_4->gregs[15] = frame_addr;",
"VAR_4->gregs[4] = VAR_8;",
"VAR_4->gregs[5] = frame_addr + offsetof(typeof(*VAR_5), VAR_2);",
"VAR_4->gregs[6] = frame_addr + offsetof(typeof(*VAR_5), uc);",
"VAR_4->pc = (unsigned long) VAR_1->_sa_handler;",
"unlock_user_struct(VAR_5, frame_addr, 1);",
"return;",
"give_sigsegv:\nunlock_user_struct(VAR_5, frame_addr, 1);",
"force_sig(TARGET_SIGSEGV);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23,
25
],
[
29
],
[
33
],
[
39
],
[
41
],
[
43,
45
],
[
47,
49
],
[
51,
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91,
93
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
117,
119
],
[
121
],
[
123
]
] |
3,641 | static void display_mouse_set(DisplayChangeListener *dcl,
int x, int y, int on)
{
SimpleSpiceDisplay *ssd = container_of(dcl, SimpleSpiceDisplay, dcl);
qemu_mutex_lock(&ssd->lock);
ssd->ptr_x = x;
ssd->ptr_y = y;
if (ssd->ptr_move) {
g_free(ssd->ptr_move);
}
ssd->ptr_move = qemu_spice_create_cursor_update(ssd, NULL, on);
qemu_mutex_unlock(&ssd->lock);
}
| false | qemu | ef1e1e0782e99c9dcf2b35e5310cdd8ca9211374 | static void display_mouse_set(DisplayChangeListener *dcl,
int x, int y, int on)
{
SimpleSpiceDisplay *ssd = container_of(dcl, SimpleSpiceDisplay, dcl);
qemu_mutex_lock(&ssd->lock);
ssd->ptr_x = x;
ssd->ptr_y = y;
if (ssd->ptr_move) {
g_free(ssd->ptr_move);
}
ssd->ptr_move = qemu_spice_create_cursor_update(ssd, NULL, on);
qemu_mutex_unlock(&ssd->lock);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisplayChangeListener *VAR_0,
int VAR_1, int VAR_2, int VAR_3)
{
SimpleSpiceDisplay *ssd = container_of(VAR_0, SimpleSpiceDisplay, VAR_0);
qemu_mutex_lock(&ssd->lock);
ssd->ptr_x = VAR_1;
ssd->ptr_y = VAR_2;
if (ssd->ptr_move) {
g_free(ssd->ptr_move);
}
ssd->ptr_move = qemu_spice_create_cursor_update(ssd, NULL, VAR_3);
qemu_mutex_unlock(&ssd->lock);
}
| [
"static void FUNC_0(DisplayChangeListener *VAR_0,\nint VAR_1, int VAR_2, int VAR_3)\n{",
"SimpleSpiceDisplay *ssd = container_of(VAR_0, SimpleSpiceDisplay, VAR_0);",
"qemu_mutex_lock(&ssd->lock);",
"ssd->ptr_x = VAR_1;",
"ssd->ptr_y = VAR_2;",
"if (ssd->ptr_move) {",
"g_free(ssd->ptr_move);",
"}",
"ssd->ptr_move = qemu_spice_create_cursor_update(ssd, NULL, VAR_3);",
"qemu_mutex_unlock(&ssd->lock);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
3,642 | static void cpu_request_exit(void *opaque, int irq, int level)
{
CPUState *cpu = current_cpu;
if (cpu && level) {
cpu_exit(cpu);
}
}
| false | qemu | 5039d6e23586fe6bbedc5e4fe302b48a66890ade | static void cpu_request_exit(void *opaque, int irq, int level)
{
CPUState *cpu = current_cpu;
if (cpu && level) {
cpu_exit(cpu);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, int VAR_1, int VAR_2)
{
CPUState *cpu = current_cpu;
if (cpu && VAR_2) {
cpu_exit(cpu);
}
}
| [
"static void FUNC_0(void *VAR_0, int VAR_1, int VAR_2)\n{",
"CPUState *cpu = current_cpu;",
"if (cpu && VAR_2) {",
"cpu_exit(cpu);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
3,643 | int qemu_get_thread_id(void)
{
#if defined (__linux__)
return syscall(SYS_gettid);
#else
return getpid();
#endif
}
| false | qemu | cbcfa0418f0c196afa765f5c9837b9344d1adcf3 | int qemu_get_thread_id(void)
{
#if defined (__linux__)
return syscall(SYS_gettid);
#else
return getpid();
#endif
}
| {
"code": [],
"line_no": []
} | int FUNC_0(void)
{
#if defined (__linux__)
return syscall(SYS_gettid);
#else
return getpid();
#endif
}
| [
"int FUNC_0(void)\n{",
"#if defined (__linux__)\nreturn syscall(SYS_gettid);",
"#else\nreturn getpid();",
"#endif\n}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9,
11
],
[
13,
15
]
] |
3,644 | static void listflags(char *buf, int bufsize, uint32_t fbits,
const char **featureset, uint32_t flags)
{
const char **p = &featureset[31];
char *q, *b, bit;
int nc;
b = 4 <= bufsize ? buf + (bufsize -= 3) - 1 : NULL;
*buf = '\0';
for (q = buf, bit = 31; fbits && bufsize; --p, fbits &= ~(1 << bit), --bit)
if (fbits & 1 << bit && (*p || !flags)) {
if (*p)
nc = snprintf(q, bufsize, "%s%s", q == buf ? "" : " ", *p);
else
nc = snprintf(q, bufsize, "%s[%d]", q == buf ? "" : " ", bit);
if (bufsize <= nc) {
if (b)
sprintf(b, "...");
return;
}
q += nc;
bufsize -= nc;
}
}
| false | qemu | d354899c8279146f3e154b9ba1f7461abb7f5279 | static void listflags(char *buf, int bufsize, uint32_t fbits,
const char **featureset, uint32_t flags)
{
const char **p = &featureset[31];
char *q, *b, bit;
int nc;
b = 4 <= bufsize ? buf + (bufsize -= 3) - 1 : NULL;
*buf = '\0';
for (q = buf, bit = 31; fbits && bufsize; --p, fbits &= ~(1 << bit), --bit)
if (fbits & 1 << bit && (*p || !flags)) {
if (*p)
nc = snprintf(q, bufsize, "%s%s", q == buf ? "" : " ", *p);
else
nc = snprintf(q, bufsize, "%s[%d]", q == buf ? "" : " ", bit);
if (bufsize <= nc) {
if (b)
sprintf(b, "...");
return;
}
q += nc;
bufsize -= nc;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(char *VAR_0, int VAR_1, uint32_t VAR_2,
const char **VAR_3, uint32_t VAR_4)
{
const char **VAR_5 = &VAR_3[31];
char *VAR_6, *VAR_7, VAR_8;
int VAR_9;
VAR_7 = 4 <= VAR_1 ? VAR_0 + (VAR_1 -= 3) - 1 : NULL;
*VAR_0 = '\0';
for (VAR_6 = VAR_0, VAR_8 = 31; VAR_2 && VAR_1; --VAR_5, VAR_2 &= ~(1 << VAR_8), --VAR_8)
if (VAR_2 & 1 << VAR_8 && (*VAR_5 || !VAR_4)) {
if (*VAR_5)
VAR_9 = snprintf(VAR_6, VAR_1, "%s%s", VAR_6 == VAR_0 ? "" : " ", *VAR_5);
else
VAR_9 = snprintf(VAR_6, VAR_1, "%s[%d]", VAR_6 == VAR_0 ? "" : " ", VAR_8);
if (VAR_1 <= VAR_9) {
if (VAR_7)
sprintf(VAR_7, "...");
return;
}
VAR_6 += VAR_9;
VAR_1 -= VAR_9;
}
}
| [
"static void FUNC_0(char *VAR_0, int VAR_1, uint32_t VAR_2,\nconst char **VAR_3, uint32_t VAR_4)\n{",
"const char **VAR_5 = &VAR_3[31];",
"char *VAR_6, *VAR_7, VAR_8;",
"int VAR_9;",
"VAR_7 = 4 <= VAR_1 ? VAR_0 + (VAR_1 -= 3) - 1 : NULL;",
"*VAR_0 = '\\0';",
"for (VAR_6 = VAR_0, VAR_8 = 31; VAR_2 && VAR_1; --VAR_5, VAR_2 &= ~(1 << VAR_8), --VAR_8)",
"if (VAR_2 & 1 << VAR_8 && (*VAR_5 || !VAR_4)) {",
"if (*VAR_5)\nVAR_9 = snprintf(VAR_6, VAR_1, \"%s%s\", VAR_6 == VAR_0 ? \"\" : \" \", *VAR_5);",
"else\nVAR_9 = snprintf(VAR_6, VAR_1, \"%s[%d]\", VAR_6 == VAR_0 ? \"\" : \" \", VAR_8);",
"if (VAR_1 <= VAR_9) {",
"if (VAR_7)\nsprintf(VAR_7, \"...\");",
"return;",
"}",
"VAR_6 += VAR_9;",
"VAR_1 -= VAR_9;",
"}",
"}"
] | [
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
]
] |
3,645 | void watchdog_add_model(WatchdogTimerModel *model)
{
LIST_INSERT_HEAD(&watchdog_list, model, entry);
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | void watchdog_add_model(WatchdogTimerModel *model)
{
LIST_INSERT_HEAD(&watchdog_list, model, entry);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(WatchdogTimerModel *VAR_0)
{
LIST_INSERT_HEAD(&watchdog_list, VAR_0, entry);
}
| [
"void FUNC_0(WatchdogTimerModel *VAR_0)\n{",
"LIST_INSERT_HEAD(&watchdog_list, VAR_0, entry);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
3,646 | static void encode_plane(FFV1Context *s, uint8_t *src, int w, int h,
int stride, int plane_index)
{
int x, y, i;
const int ring_size = s->avctx->context_model ? 3 : 2;
int16_t *sample[3];
s->run_index = 0;
memset(s->sample_buffer, 0, ring_size * (w + 6) * sizeof(*s->sample_buffer));
for (y = 0; y < h; y++) {
for (i = 0; i < ring_size; i++)
sample[i] = s->sample_buffer + (w + 6) * ((h + i - y) % ring_size) + 3;
sample[0][-1]= sample[1][0 ];
sample[1][ w]= sample[1][w-1];
// { START_TIMER
if (s->bits_per_raw_sample <= 8) {
for (x = 0; x < w; x++)
sample[0][x] = src[x + stride * y];
encode_line(s, w, sample, plane_index, 8);
} else {
if (s->packed_at_lsb) {
for (x = 0; x < w; x++) {
sample[0][x] = ((uint16_t*)(src + stride*y))[x];
}
} else {
for (x = 0; x < w; x++) {
sample[0][x] = ((uint16_t*)(src + stride*y))[x] >> (16 - s->bits_per_raw_sample);
}
}
encode_line(s, w, sample, plane_index, s->bits_per_raw_sample);
}
// STOP_TIMER("encode line") }
}
}
| false | FFmpeg | 77f521d9e5126575f9bcc21241d81867173c7619 | static void encode_plane(FFV1Context *s, uint8_t *src, int w, int h,
int stride, int plane_index)
{
int x, y, i;
const int ring_size = s->avctx->context_model ? 3 : 2;
int16_t *sample[3];
s->run_index = 0;
memset(s->sample_buffer, 0, ring_size * (w + 6) * sizeof(*s->sample_buffer));
for (y = 0; y < h; y++) {
for (i = 0; i < ring_size; i++)
sample[i] = s->sample_buffer + (w + 6) * ((h + i - y) % ring_size) + 3;
sample[0][-1]= sample[1][0 ];
sample[1][ w]= sample[1][w-1];
if (s->bits_per_raw_sample <= 8) {
for (x = 0; x < w; x++)
sample[0][x] = src[x + stride * y];
encode_line(s, w, sample, plane_index, 8);
} else {
if (s->packed_at_lsb) {
for (x = 0; x < w; x++) {
sample[0][x] = ((uint16_t*)(src + stride*y))[x];
}
} else {
for (x = 0; x < w; x++) {
sample[0][x] = ((uint16_t*)(src + stride*y))[x] >> (16 - s->bits_per_raw_sample);
}
}
encode_line(s, w, sample, plane_index, s->bits_per_raw_sample);
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(FFV1Context *VAR_0, uint8_t *VAR_1, int VAR_2, int VAR_3,
int VAR_4, int VAR_5)
{
int VAR_6, VAR_7, VAR_8;
const int VAR_9 = VAR_0->avctx->context_model ? 3 : 2;
int16_t *sample[3];
VAR_0->run_index = 0;
memset(VAR_0->sample_buffer, 0, VAR_9 * (VAR_2 + 6) * sizeof(*VAR_0->sample_buffer));
for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {
for (VAR_8 = 0; VAR_8 < VAR_9; VAR_8++)
sample[VAR_8] = VAR_0->sample_buffer + (VAR_2 + 6) * ((VAR_3 + VAR_8 - VAR_7) % VAR_9) + 3;
sample[0][-1]= sample[1][0 ];
sample[1][ VAR_2]= sample[1][VAR_2-1];
if (VAR_0->bits_per_raw_sample <= 8) {
for (VAR_6 = 0; VAR_6 < VAR_2; VAR_6++)
sample[0][VAR_6] = VAR_1[VAR_6 + VAR_4 * VAR_7];
encode_line(VAR_0, VAR_2, sample, VAR_5, 8);
} else {
if (VAR_0->packed_at_lsb) {
for (VAR_6 = 0; VAR_6 < VAR_2; VAR_6++) {
sample[0][VAR_6] = ((uint16_t*)(VAR_1 + VAR_4*VAR_7))[VAR_6];
}
} else {
for (VAR_6 = 0; VAR_6 < VAR_2; VAR_6++) {
sample[0][VAR_6] = ((uint16_t*)(VAR_1 + VAR_4*VAR_7))[VAR_6] >> (16 - VAR_0->bits_per_raw_sample);
}
}
encode_line(VAR_0, VAR_2, sample, VAR_5, VAR_0->bits_per_raw_sample);
}
}
}
| [
"static void FUNC_0(FFV1Context *VAR_0, uint8_t *VAR_1, int VAR_2, int VAR_3,\nint VAR_4, int VAR_5)\n{",
"int VAR_6, VAR_7, VAR_8;",
"const int VAR_9 = VAR_0->avctx->context_model ? 3 : 2;",
"int16_t *sample[3];",
"VAR_0->run_index = 0;",
"memset(VAR_0->sample_buffer, 0, VAR_9 * (VAR_2 + 6) * sizeof(*VAR_0->sample_buffer));",
"for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {",
"for (VAR_8 = 0; VAR_8 < VAR_9; VAR_8++)",
"sample[VAR_8] = VAR_0->sample_buffer + (VAR_2 + 6) * ((VAR_3 + VAR_8 - VAR_7) % VAR_9) + 3;",
"sample[0][-1]= sample[1][0 ];",
"sample[1][ VAR_2]= sample[1][VAR_2-1];",
"if (VAR_0->bits_per_raw_sample <= 8) {",
"for (VAR_6 = 0; VAR_6 < VAR_2; VAR_6++)",
"sample[0][VAR_6] = VAR_1[VAR_6 + VAR_4 * VAR_7];",
"encode_line(VAR_0, VAR_2, sample, VAR_5, 8);",
"} else {",
"if (VAR_0->packed_at_lsb) {",
"for (VAR_6 = 0; VAR_6 < VAR_2; VAR_6++) {",
"sample[0][VAR_6] = ((uint16_t*)(VAR_1 + VAR_4*VAR_7))[VAR_6];",
"}",
"} else {",
"for (VAR_6 = 0; VAR_6 < VAR_2; VAR_6++) {",
"sample[0][VAR_6] = ((uint16_t*)(VAR_1 + VAR_4*VAR_7))[VAR_6] >> (16 - VAR_0->bits_per_raw_sample);",
"}",
"}",
"encode_line(VAR_0, VAR_2, sample, VAR_5, VAR_0->bits_per_raw_sample);",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
]
] |
3,647 | static int decode_plane(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
Plane *plane, const uint8_t *data, int32_t data_size,
int32_t strip_width)
{
Cell curr_cell;
int num_vectors;
/* each plane data starts with mc_vector_count field, */
/* an optional array of motion vectors followed by the vq data */
num_vectors = bytestream_get_le32(&data);
ctx->mc_vectors = num_vectors ? data : 0;
/* init the bitreader */
init_get_bits(&ctx->gb, &data[num_vectors * 2], data_size << 3);
ctx->skip_bits = 0;
ctx->need_resync = 0;
ctx->last_byte = data + data_size - 1;
/* initialize the 1st cell and set its dimensions to whole plane */
curr_cell.xpos = curr_cell.ypos = 0;
curr_cell.width = plane->width >> 2;
curr_cell.height = plane->height >> 2;
curr_cell.tree = 0; // we are in the MC tree now
curr_cell.mv_ptr = 0; // no motion vector = INTRA cell
return parse_bintree(ctx, avctx, plane, INTRA_NULL, &curr_cell, CELL_STACK_MAX, strip_width);
}
| false | FFmpeg | 1afe49b062a959ed0433e4fd9c1b5dff829ae03e | static int decode_plane(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
Plane *plane, const uint8_t *data, int32_t data_size,
int32_t strip_width)
{
Cell curr_cell;
int num_vectors;
num_vectors = bytestream_get_le32(&data);
ctx->mc_vectors = num_vectors ? data : 0;
init_get_bits(&ctx->gb, &data[num_vectors * 2], data_size << 3);
ctx->skip_bits = 0;
ctx->need_resync = 0;
ctx->last_byte = data + data_size - 1;
curr_cell.xpos = curr_cell.ypos = 0;
curr_cell.width = plane->width >> 2;
curr_cell.height = plane->height >> 2;
curr_cell.tree = 0;
curr_cell.mv_ptr = 0;
return parse_bintree(ctx, avctx, plane, INTRA_NULL, &curr_cell, CELL_STACK_MAX, strip_width);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(Indeo3DecodeContext *VAR_0, AVCodecContext *VAR_1,
Plane *VAR_2, const uint8_t *VAR_3, int32_t VAR_4,
int32_t VAR_5)
{
Cell curr_cell;
int VAR_6;
VAR_6 = bytestream_get_le32(&VAR_3);
VAR_0->mc_vectors = VAR_6 ? VAR_3 : 0;
init_get_bits(&VAR_0->gb, &VAR_3[VAR_6 * 2], VAR_4 << 3);
VAR_0->skip_bits = 0;
VAR_0->need_resync = 0;
VAR_0->last_byte = VAR_3 + VAR_4 - 1;
curr_cell.xpos = curr_cell.ypos = 0;
curr_cell.width = VAR_2->width >> 2;
curr_cell.height = VAR_2->height >> 2;
curr_cell.tree = 0;
curr_cell.mv_ptr = 0;
return parse_bintree(VAR_0, VAR_1, VAR_2, INTRA_NULL, &curr_cell, CELL_STACK_MAX, VAR_5);
}
| [
"static int FUNC_0(Indeo3DecodeContext *VAR_0, AVCodecContext *VAR_1,\nPlane *VAR_2, const uint8_t *VAR_3, int32_t VAR_4,\nint32_t VAR_5)\n{",
"Cell curr_cell;",
"int VAR_6;",
"VAR_6 = bytestream_get_le32(&VAR_3);",
"VAR_0->mc_vectors = VAR_6 ? VAR_3 : 0;",
"init_get_bits(&VAR_0->gb, &VAR_3[VAR_6 * 2], VAR_4 << 3);",
"VAR_0->skip_bits = 0;",
"VAR_0->need_resync = 0;",
"VAR_0->last_byte = VAR_3 + VAR_4 - 1;",
"curr_cell.xpos = curr_cell.ypos = 0;",
"curr_cell.width = VAR_2->width >> 2;",
"curr_cell.height = VAR_2->height >> 2;",
"curr_cell.tree = 0;",
"curr_cell.mv_ptr = 0;",
"return parse_bintree(VAR_0, VAR_1, VAR_2, INTRA_NULL, &curr_cell, CELL_STACK_MAX, VAR_5);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
19
],
[
21
],
[
27
],
[
29
],
[
31
],
[
35
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
]
] |
3,648 | int qemu_savevm_state_iterate(QEMUFile *f)
{
SaveStateEntry *se;
int ret = 1;
TAILQ_FOREACH(se, &savevm_handlers, entry) {
if (se->save_live_state == NULL)
continue;
/* Section type */
qemu_put_byte(f, QEMU_VM_SECTION_PART);
qemu_put_be32(f, se->section_id);
ret &= !!se->save_live_state(f, QEMU_VM_SECTION_PART, se->opaque);
}
if (ret)
return 1;
if (qemu_file_has_error(f))
return -EIO;
return 0;
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | int qemu_savevm_state_iterate(QEMUFile *f)
{
SaveStateEntry *se;
int ret = 1;
TAILQ_FOREACH(se, &savevm_handlers, entry) {
if (se->save_live_state == NULL)
continue;
qemu_put_byte(f, QEMU_VM_SECTION_PART);
qemu_put_be32(f, se->section_id);
ret &= !!se->save_live_state(f, QEMU_VM_SECTION_PART, se->opaque);
}
if (ret)
return 1;
if (qemu_file_has_error(f))
return -EIO;
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(QEMUFile *VAR_0)
{
SaveStateEntry *se;
int VAR_1 = 1;
TAILQ_FOREACH(se, &savevm_handlers, entry) {
if (se->save_live_state == NULL)
continue;
qemu_put_byte(VAR_0, QEMU_VM_SECTION_PART);
qemu_put_be32(VAR_0, se->section_id);
VAR_1 &= !!se->save_live_state(VAR_0, QEMU_VM_SECTION_PART, se->opaque);
}
if (VAR_1)
return 1;
if (qemu_file_has_error(VAR_0))
return -EIO;
return 0;
}
| [
"int FUNC_0(QEMUFile *VAR_0)\n{",
"SaveStateEntry *se;",
"int VAR_1 = 1;",
"TAILQ_FOREACH(se, &savevm_handlers, entry) {",
"if (se->save_live_state == NULL)\ncontinue;",
"qemu_put_byte(VAR_0, QEMU_VM_SECTION_PART);",
"qemu_put_be32(VAR_0, se->section_id);",
"VAR_1 &= !!se->save_live_state(VAR_0, QEMU_VM_SECTION_PART, se->opaque);",
"}",
"if (VAR_1)\nreturn 1;",
"if (qemu_file_has_error(VAR_0))\nreturn -EIO;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
21
],
[
23
],
[
27
],
[
29
],
[
33,
35
],
[
39,
41
],
[
45
],
[
47
]
] |
3,649 | static void qmp_cleanup(void *datap)
{
QmpSerializeData *d = datap;
visit_free(qmp_output_get_visitor(d->qov));
visit_free(d->qiv);
g_free(d);
}
| false | qemu | 3b098d56979d2f7fd707c5be85555d114353a28d | static void qmp_cleanup(void *datap)
{
QmpSerializeData *d = datap;
visit_free(qmp_output_get_visitor(d->qov));
visit_free(d->qiv);
g_free(d);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
QmpSerializeData *d = VAR_0;
visit_free(qmp_output_get_visitor(d->qov));
visit_free(d->qiv);
g_free(d);
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"QmpSerializeData *d = VAR_0;",
"visit_free(qmp_output_get_visitor(d->qov));",
"visit_free(d->qiv);",
"g_free(d);",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
]
] |
3,650 | void parse_numa_opts(MachineClass *mc)
{
int i;
if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, NULL, NULL)) {
exit(1);
}
assert(max_numa_nodeid <= MAX_NODES);
/* No support for sparse NUMA node IDs yet: */
for (i = max_numa_nodeid - 1; i >= 0; i--) {
/* Report large node IDs first, to make mistakes easier to spot */
if (!numa_info[i].present) {
error_report("numa: Node ID missing: %d", i);
exit(1);
}
}
/* This must be always true if all nodes are present: */
assert(nb_numa_nodes == max_numa_nodeid);
if (nb_numa_nodes > 0) {
uint64_t numa_total;
if (nb_numa_nodes > MAX_NODES) {
nb_numa_nodes = MAX_NODES;
}
/* If no memory size is given for any node, assume the default case
* and distribute the available memory equally across all nodes
*/
for (i = 0; i < nb_numa_nodes; i++) {
if (numa_info[i].node_mem != 0) {
break;
}
}
if (i == nb_numa_nodes) {
uint64_t usedmem = 0;
/* On Linux, each node's border has to be 8MB aligned,
* the final node gets the rest.
*/
for (i = 0; i < nb_numa_nodes - 1; i++) {
numa_info[i].node_mem = (ram_size / nb_numa_nodes) &
~((1 << 23UL) - 1);
usedmem += numa_info[i].node_mem;
}
numa_info[i].node_mem = ram_size - usedmem;
}
numa_total = 0;
for (i = 0; i < nb_numa_nodes; i++) {
numa_total += numa_info[i].node_mem;
}
if (numa_total != ram_size) {
error_report("total memory for NUMA nodes (0x%" PRIx64 ")"
" should equal RAM size (0x" RAM_ADDR_FMT ")",
numa_total, ram_size);
exit(1);
}
for (i = 0; i < nb_numa_nodes; i++) {
QLIST_INIT(&numa_info[i].addr);
}
numa_set_mem_ranges();
for (i = 0; i < nb_numa_nodes; i++) {
if (!bitmap_empty(numa_info[i].node_cpu, MAX_CPUMASK_BITS)) {
break;
}
}
/* Historically VCPUs were assigned in round-robin order to NUMA
* nodes. However it causes issues with guest not handling it nice
* in case where cores/threads from a multicore CPU appear on
* different nodes. So allow boards to override default distribution
* rule grouping VCPUs by socket so that VCPUs from the same socket
* would be on the same node.
*/
if (i == nb_numa_nodes) {
for (i = 0; i < max_cpus; i++) {
unsigned node_id = i % nb_numa_nodes;
if (mc->cpu_index_to_socket_id) {
node_id = mc->cpu_index_to_socket_id(i) % nb_numa_nodes;
}
set_bit(i, numa_info[node_id].node_cpu);
}
}
validate_numa_cpus();
} else {
numa_set_mem_node_id(0, ram_size, 0);
}
}
| false | qemu | cdda2018e3b9ce0c18938767dfdb1e05a05b67ca | void parse_numa_opts(MachineClass *mc)
{
int i;
if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, NULL, NULL)) {
exit(1);
}
assert(max_numa_nodeid <= MAX_NODES);
for (i = max_numa_nodeid - 1; i >= 0; i--) {
if (!numa_info[i].present) {
error_report("numa: Node ID missing: %d", i);
exit(1);
}
}
assert(nb_numa_nodes == max_numa_nodeid);
if (nb_numa_nodes > 0) {
uint64_t numa_total;
if (nb_numa_nodes > MAX_NODES) {
nb_numa_nodes = MAX_NODES;
}
for (i = 0; i < nb_numa_nodes; i++) {
if (numa_info[i].node_mem != 0) {
break;
}
}
if (i == nb_numa_nodes) {
uint64_t usedmem = 0;
for (i = 0; i < nb_numa_nodes - 1; i++) {
numa_info[i].node_mem = (ram_size / nb_numa_nodes) &
~((1 << 23UL) - 1);
usedmem += numa_info[i].node_mem;
}
numa_info[i].node_mem = ram_size - usedmem;
}
numa_total = 0;
for (i = 0; i < nb_numa_nodes; i++) {
numa_total += numa_info[i].node_mem;
}
if (numa_total != ram_size) {
error_report("total memory for NUMA nodes (0x%" PRIx64 ")"
" should equal RAM size (0x" RAM_ADDR_FMT ")",
numa_total, ram_size);
exit(1);
}
for (i = 0; i < nb_numa_nodes; i++) {
QLIST_INIT(&numa_info[i].addr);
}
numa_set_mem_ranges();
for (i = 0; i < nb_numa_nodes; i++) {
if (!bitmap_empty(numa_info[i].node_cpu, MAX_CPUMASK_BITS)) {
break;
}
}
if (i == nb_numa_nodes) {
for (i = 0; i < max_cpus; i++) {
unsigned node_id = i % nb_numa_nodes;
if (mc->cpu_index_to_socket_id) {
node_id = mc->cpu_index_to_socket_id(i) % nb_numa_nodes;
}
set_bit(i, numa_info[node_id].node_cpu);
}
}
validate_numa_cpus();
} else {
numa_set_mem_node_id(0, ram_size, 0);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(MachineClass *VAR_0)
{
int VAR_1;
if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, NULL, NULL)) {
exit(1);
}
assert(max_numa_nodeid <= MAX_NODES);
for (VAR_1 = max_numa_nodeid - 1; VAR_1 >= 0; VAR_1--) {
if (!numa_info[VAR_1].present) {
error_report("numa: Node ID missing: %d", VAR_1);
exit(1);
}
}
assert(nb_numa_nodes == max_numa_nodeid);
if (nb_numa_nodes > 0) {
uint64_t numa_total;
if (nb_numa_nodes > MAX_NODES) {
nb_numa_nodes = MAX_NODES;
}
for (VAR_1 = 0; VAR_1 < nb_numa_nodes; VAR_1++) {
if (numa_info[VAR_1].node_mem != 0) {
break;
}
}
if (VAR_1 == nb_numa_nodes) {
uint64_t usedmem = 0;
for (VAR_1 = 0; VAR_1 < nb_numa_nodes - 1; VAR_1++) {
numa_info[VAR_1].node_mem = (ram_size / nb_numa_nodes) &
~((1 << 23UL) - 1);
usedmem += numa_info[VAR_1].node_mem;
}
numa_info[VAR_1].node_mem = ram_size - usedmem;
}
numa_total = 0;
for (VAR_1 = 0; VAR_1 < nb_numa_nodes; VAR_1++) {
numa_total += numa_info[VAR_1].node_mem;
}
if (numa_total != ram_size) {
error_report("total memory for NUMA nodes (0x%" PRIx64 ")"
" should equal RAM size (0x" RAM_ADDR_FMT ")",
numa_total, ram_size);
exit(1);
}
for (VAR_1 = 0; VAR_1 < nb_numa_nodes; VAR_1++) {
QLIST_INIT(&numa_info[VAR_1].addr);
}
numa_set_mem_ranges();
for (VAR_1 = 0; VAR_1 < nb_numa_nodes; VAR_1++) {
if (!bitmap_empty(numa_info[VAR_1].node_cpu, MAX_CPUMASK_BITS)) {
break;
}
}
if (VAR_1 == nb_numa_nodes) {
for (VAR_1 = 0; VAR_1 < max_cpus; VAR_1++) {
unsigned node_id = VAR_1 % nb_numa_nodes;
if (VAR_0->cpu_index_to_socket_id) {
node_id = VAR_0->cpu_index_to_socket_id(VAR_1) % nb_numa_nodes;
}
set_bit(VAR_1, numa_info[node_id].node_cpu);
}
}
validate_numa_cpus();
} else {
numa_set_mem_node_id(0, ram_size, 0);
}
}
| [
"void FUNC_0(MachineClass *VAR_0)\n{",
"int VAR_1;",
"if (qemu_opts_foreach(qemu_find_opts(\"numa\"), parse_numa, NULL, NULL)) {",
"exit(1);",
"}",
"assert(max_numa_nodeid <= MAX_NODES);",
"for (VAR_1 = max_numa_nodeid - 1; VAR_1 >= 0; VAR_1--) {",
"if (!numa_info[VAR_1].present) {",
"error_report(\"numa: Node ID missing: %d\", VAR_1);",
"exit(1);",
"}",
"}",
"assert(nb_numa_nodes == max_numa_nodeid);",
"if (nb_numa_nodes > 0) {",
"uint64_t numa_total;",
"if (nb_numa_nodes > MAX_NODES) {",
"nb_numa_nodes = MAX_NODES;",
"}",
"for (VAR_1 = 0; VAR_1 < nb_numa_nodes; VAR_1++) {",
"if (numa_info[VAR_1].node_mem != 0) {",
"break;",
"}",
"}",
"if (VAR_1 == nb_numa_nodes) {",
"uint64_t usedmem = 0;",
"for (VAR_1 = 0; VAR_1 < nb_numa_nodes - 1; VAR_1++) {",
"numa_info[VAR_1].node_mem = (ram_size / nb_numa_nodes) &\n~((1 << 23UL) - 1);",
"usedmem += numa_info[VAR_1].node_mem;",
"}",
"numa_info[VAR_1].node_mem = ram_size - usedmem;",
"}",
"numa_total = 0;",
"for (VAR_1 = 0; VAR_1 < nb_numa_nodes; VAR_1++) {",
"numa_total += numa_info[VAR_1].node_mem;",
"}",
"if (numa_total != ram_size) {",
"error_report(\"total memory for NUMA nodes (0x%\" PRIx64 \")\"\n\" should equal RAM size (0x\" RAM_ADDR_FMT \")\",\nnuma_total, ram_size);",
"exit(1);",
"}",
"for (VAR_1 = 0; VAR_1 < nb_numa_nodes; VAR_1++) {",
"QLIST_INIT(&numa_info[VAR_1].addr);",
"}",
"numa_set_mem_ranges();",
"for (VAR_1 = 0; VAR_1 < nb_numa_nodes; VAR_1++) {",
"if (!bitmap_empty(numa_info[VAR_1].node_cpu, MAX_CPUMASK_BITS)) {",
"break;",
"}",
"}",
"if (VAR_1 == nb_numa_nodes) {",
"for (VAR_1 = 0; VAR_1 < max_cpus; VAR_1++) {",
"unsigned node_id = VAR_1 % nb_numa_nodes;",
"if (VAR_0->cpu_index_to_socket_id) {",
"node_id = VAR_0->cpu_index_to_socket_id(VAR_1) % nb_numa_nodes;",
"}",
"set_bit(VAR_1, numa_info[node_id].node_cpu);",
"}",
"}",
"validate_numa_cpus();",
"} else {",
"numa_set_mem_node_id(0, ram_size, 0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
41
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
87
],
[
89,
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113,
115,
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
133
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
]
] |
3,651 | static inline uint8_t *bt_hci_event_start(struct bt_hci_s *hci,
int evt, int len)
{
uint8_t *packet, mask;
int mask_byte;
if (len > 255) {
fprintf(stderr, "%s: HCI event params too long (%ib)\n",
__FUNCTION__, len);
exit(-1);
}
mask_byte = (evt - 1) >> 3;
mask = 1 << ((evt - 1) & 3);
if (mask & bt_event_reserved_mask[mask_byte] & ~hci->event_mask[mask_byte])
return NULL;
packet = hci->evt_packet(hci->opaque);
packet[0] = evt;
packet[1] = len;
return &packet[2];
}
| false | qemu | a89f364ae8740dfc31b321eed9ee454e996dc3c1 | static inline uint8_t *bt_hci_event_start(struct bt_hci_s *hci,
int evt, int len)
{
uint8_t *packet, mask;
int mask_byte;
if (len > 255) {
fprintf(stderr, "%s: HCI event params too long (%ib)\n",
__FUNCTION__, len);
exit(-1);
}
mask_byte = (evt - 1) >> 3;
mask = 1 << ((evt - 1) & 3);
if (mask & bt_event_reserved_mask[mask_byte] & ~hci->event_mask[mask_byte])
return NULL;
packet = hci->evt_packet(hci->opaque);
packet[0] = evt;
packet[1] = len;
return &packet[2];
}
| {
"code": [],
"line_no": []
} | static inline uint8_t *FUNC_0(struct bt_hci_s *hci,
int evt, int len)
{
uint8_t *packet, mask;
int VAR_0;
if (len > 255) {
fprintf(stderr, "%s: HCI event params too long (%ib)\n",
__FUNCTION__, len);
exit(-1);
}
VAR_0 = (evt - 1) >> 3;
mask = 1 << ((evt - 1) & 3);
if (mask & bt_event_reserved_mask[VAR_0] & ~hci->event_mask[VAR_0])
return NULL;
packet = hci->evt_packet(hci->opaque);
packet[0] = evt;
packet[1] = len;
return &packet[2];
}
| [
"static inline uint8_t *FUNC_0(struct bt_hci_s *hci,\nint evt, int len)\n{",
"uint8_t *packet, mask;",
"int VAR_0;",
"if (len > 255) {",
"fprintf(stderr, \"%s: HCI event params too long (%ib)\\n\",\n__FUNCTION__, len);",
"exit(-1);",
"}",
"VAR_0 = (evt - 1) >> 3;",
"mask = 1 << ((evt - 1) & 3);",
"if (mask & bt_event_reserved_mask[VAR_0] & ~hci->event_mask[VAR_0])\nreturn NULL;",
"packet = hci->evt_packet(hci->opaque);",
"packet[0] = evt;",
"packet[1] = len;",
"return &packet[2];",
"}"
] | [
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
],
[
25
],
[
27
],
[
29,
31
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
]
] |
3,652 | uint64_t helper_efdctsidz (uint64_t val)
{
CPU_DoubleU u;
u.ll = val;
/* NaN are not treated the same way IEEE 754 does */
if (unlikely(float64_is_nan(u.d)))
return 0;
return float64_to_int64_round_to_zero(u.d, &env->vec_status);
}
| false | qemu | 185698715dfb18c82ad2a5dbc169908602d43e81 | uint64_t helper_efdctsidz (uint64_t val)
{
CPU_DoubleU u;
u.ll = val;
if (unlikely(float64_is_nan(u.d)))
return 0;
return float64_to_int64_round_to_zero(u.d, &env->vec_status);
}
| {
"code": [],
"line_no": []
} | uint64_t FUNC_0 (uint64_t val)
{
CPU_DoubleU u;
u.ll = val;
if (unlikely(float64_is_nan(u.d)))
return 0;
return float64_to_int64_round_to_zero(u.d, &env->vec_status);
}
| [
"uint64_t FUNC_0 (uint64_t val)\n{",
"CPU_DoubleU u;",
"u.ll = val;",
"if (unlikely(float64_is_nan(u.d)))\nreturn 0;",
"return float64_to_int64_round_to_zero(u.d, &env->vec_status);",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13,
15
],
[
19
],
[
21
]
] |
3,653 | static int kvm_has_msr_star(CPUState *env)
{
kvm_supported_msrs(env);
return has_msr_star;
}
| false | qemu | c3a3a7d356c4df2fe145037172ae52cba5f545a5 | static int kvm_has_msr_star(CPUState *env)
{
kvm_supported_msrs(env);
return has_msr_star;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(CPUState *VAR_0)
{
kvm_supported_msrs(VAR_0);
return has_msr_star;
}
| [
"static int FUNC_0(CPUState *VAR_0)\n{",
"kvm_supported_msrs(VAR_0);",
"return has_msr_star;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
3,654 | int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence)
{
if (whence == SEEK_SET) {
/* nothing to do */
} else if (whence == SEEK_CUR) {
pos += qemu_ftell(f);
} else {
/* SEEK_END not supported */
return -1;
}
if (f->is_writable) {
qemu_fflush(f);
f->buf_offset = pos;
} else {
f->buf_offset = pos;
f->buf_index = 0;
f->buf_size = 0;
}
return pos;
}
| false | qemu | 5dafc53f1fb091d242f2179ffcb43bb28af36d1e | int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence)
{
if (whence == SEEK_SET) {
} else if (whence == SEEK_CUR) {
pos += qemu_ftell(f);
} else {
return -1;
}
if (f->is_writable) {
qemu_fflush(f);
f->buf_offset = pos;
} else {
f->buf_offset = pos;
f->buf_index = 0;
f->buf_size = 0;
}
return pos;
}
| {
"code": [],
"line_no": []
} | int64_t FUNC_0(QEMUFile *f, int64_t pos, int whence)
{
if (whence == SEEK_SET) {
} else if (whence == SEEK_CUR) {
pos += qemu_ftell(f);
} else {
return -1;
}
if (f->is_writable) {
qemu_fflush(f);
f->buf_offset = pos;
} else {
f->buf_offset = pos;
f->buf_index = 0;
f->buf_size = 0;
}
return pos;
}
| [
"int64_t FUNC_0(QEMUFile *f, int64_t pos, int whence)\n{",
"if (whence == SEEK_SET) {",
"} else if (whence == SEEK_CUR) {",
"pos += qemu_ftell(f);",
"} else {",
"return -1;",
"}",
"if (f->is_writable) {",
"qemu_fflush(f);",
"f->buf_offset = pos;",
"} else {",
"f->buf_offset = pos;",
"f->buf_index = 0;",
"f->buf_size = 0;",
"}",
"return pos;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
]
] |
3,655 | static void qbus_list_dev(BusState *bus, char *dest, int len)
{
DeviceState *dev;
const char *sep = " ";
int pos = 0;
pos += snprintf(dest+pos, len-pos, "devices at \"%s\":",
bus->name);
LIST_FOREACH(dev, &bus->children, sibling) {
pos += snprintf(dest+pos, len-pos, "%s\"%s\"",
sep, dev->info->name);
if (dev->id)
pos += snprintf(dest+pos, len-pos, "/\"%s\"", dev->id);
sep = ", ";
}
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | static void qbus_list_dev(BusState *bus, char *dest, int len)
{
DeviceState *dev;
const char *sep = " ";
int pos = 0;
pos += snprintf(dest+pos, len-pos, "devices at \"%s\":",
bus->name);
LIST_FOREACH(dev, &bus->children, sibling) {
pos += snprintf(dest+pos, len-pos, "%s\"%s\"",
sep, dev->info->name);
if (dev->id)
pos += snprintf(dest+pos, len-pos, "/\"%s\"", dev->id);
sep = ", ";
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BusState *VAR_0, char *VAR_1, int VAR_2)
{
DeviceState *dev;
const char *VAR_3 = " ";
int VAR_4 = 0;
VAR_4 += snprintf(VAR_1+VAR_4, VAR_2-VAR_4, "devices at \"%s\":",
VAR_0->name);
LIST_FOREACH(dev, &VAR_0->children, sibling) {
VAR_4 += snprintf(VAR_1+VAR_4, VAR_2-VAR_4, "%s\"%s\"",
VAR_3, dev->info->name);
if (dev->id)
VAR_4 += snprintf(VAR_1+VAR_4, VAR_2-VAR_4, "/\"%s\"", dev->id);
VAR_3 = ", ";
}
}
| [
"static void FUNC_0(BusState *VAR_0, char *VAR_1, int VAR_2)\n{",
"DeviceState *dev;",
"const char *VAR_3 = \" \";",
"int VAR_4 = 0;",
"VAR_4 += snprintf(VAR_1+VAR_4, VAR_2-VAR_4, \"devices at \\\"%s\\\":\",\nVAR_0->name);",
"LIST_FOREACH(dev, &VAR_0->children, sibling) {",
"VAR_4 += snprintf(VAR_1+VAR_4, VAR_2-VAR_4, \"%s\\\"%s\\\"\",\nVAR_3, dev->info->name);",
"if (dev->id)\nVAR_4 += snprintf(VAR_1+VAR_4, VAR_2-VAR_4, \"/\\\"%s\\\"\", dev->id);",
"VAR_3 = \", \";",
"}",
"}"
] | [
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
]
] |
3,656 | void vnc_zlib_zfree(void *x, void *addr)
{
qemu_free(addr);
}
| false | qemu | 245f7b51c0ea04fb2224b1127430a096c91aee70 | void vnc_zlib_zfree(void *x, void *addr)
{
qemu_free(addr);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(void *VAR_0, void *VAR_1)
{
qemu_free(VAR_1);
}
| [
"void FUNC_0(void *VAR_0, void *VAR_1)\n{",
"qemu_free(VAR_1);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
3,657 | static target_ulong h_put_term_char(CPUState *env, sPAPREnvironment *spapr,
target_ulong opcode, target_ulong *args)
{
target_ulong reg = args[0];
target_ulong len = args[1];
target_ulong char0_7 = args[2];
target_ulong char8_15 = args[3];
VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
uint8_t buf[16];
if (!sdev) {
return H_PARAMETER;
}
if (len > 16) {
return H_PARAMETER;
}
*((uint64_t *)buf) = cpu_to_be64(char0_7);
*((uint64_t *)buf + 1) = cpu_to_be64(char8_15);
vty_putchars(sdev, buf, len);
return H_SUCCESS;
}
| false | qemu | 3feef8ad17af7307373b9e88b9d7ecb98eeb99da | static target_ulong h_put_term_char(CPUState *env, sPAPREnvironment *spapr,
target_ulong opcode, target_ulong *args)
{
target_ulong reg = args[0];
target_ulong len = args[1];
target_ulong char0_7 = args[2];
target_ulong char8_15 = args[3];
VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
uint8_t buf[16];
if (!sdev) {
return H_PARAMETER;
}
if (len > 16) {
return H_PARAMETER;
}
*((uint64_t *)buf) = cpu_to_be64(char0_7);
*((uint64_t *)buf + 1) = cpu_to_be64(char8_15);
vty_putchars(sdev, buf, len);
return H_SUCCESS;
}
| {
"code": [],
"line_no": []
} | static target_ulong FUNC_0(CPUState *env, sPAPREnvironment *spapr,
target_ulong opcode, target_ulong *args)
{
target_ulong reg = args[0];
target_ulong len = args[1];
target_ulong char0_7 = args[2];
target_ulong char8_15 = args[3];
VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
uint8_t buf[16];
if (!sdev) {
return H_PARAMETER;
}
if (len > 16) {
return H_PARAMETER;
}
*((uint64_t *)buf) = cpu_to_be64(char0_7);
*((uint64_t *)buf + 1) = cpu_to_be64(char8_15);
vty_putchars(sdev, buf, len);
return H_SUCCESS;
}
| [
"static target_ulong FUNC_0(CPUState *env, sPAPREnvironment *spapr,\ntarget_ulong opcode, target_ulong *args)\n{",
"target_ulong reg = args[0];",
"target_ulong len = args[1];",
"target_ulong char0_7 = args[2];",
"target_ulong char8_15 = args[3];",
"VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);",
"uint8_t buf[16];",
"if (!sdev) {",
"return H_PARAMETER;",
"}",
"if (len > 16) {",
"return H_PARAMETER;",
"}",
"*((uint64_t *)buf) = cpu_to_be64(char0_7);",
"*((uint64_t *)buf + 1) = cpu_to_be64(char8_15);",
"vty_putchars(sdev, buf, len);",
"return H_SUCCESS;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
43
],
[
47
],
[
49
]
] |
3,659 | static void thread_pool_co_cb(void *opaque, int ret)
{
ThreadPoolCo *co = opaque;
co->ret = ret;
qemu_coroutine_enter(co->co);
}
| false | qemu | c2b38b277a7882a592f4f2ec955084b2b756daaa | static void thread_pool_co_cb(void *opaque, int ret)
{
ThreadPoolCo *co = opaque;
co->ret = ret;
qemu_coroutine_enter(co->co);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, int VAR_1)
{
ThreadPoolCo *co = VAR_0;
co->VAR_1 = VAR_1;
qemu_coroutine_enter(co->co);
}
| [
"static void FUNC_0(void *VAR_0, int VAR_1)\n{",
"ThreadPoolCo *co = VAR_0;",
"co->VAR_1 = VAR_1;",
"qemu_coroutine_enter(co->co);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
]
] |
3,660 | static int qemu_balloon(ram_addr_t target)
{
if (!balloon_event_fn) {
return 0;
}
trace_balloon_event(balloon_opaque, target);
balloon_event_fn(balloon_opaque, target);
return 1;
}
| false | qemu | 6502a14734e71b2f6dd079b0a1e546e6aa2d2f8d | static int qemu_balloon(ram_addr_t target)
{
if (!balloon_event_fn) {
return 0;
}
trace_balloon_event(balloon_opaque, target);
balloon_event_fn(balloon_opaque, target);
return 1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(ram_addr_t VAR_0)
{
if (!balloon_event_fn) {
return 0;
}
trace_balloon_event(balloon_opaque, VAR_0);
balloon_event_fn(balloon_opaque, VAR_0);
return 1;
}
| [
"static int FUNC_0(ram_addr_t VAR_0)\n{",
"if (!balloon_event_fn) {",
"return 0;",
"}",
"trace_balloon_event(balloon_opaque, VAR_0);",
"balloon_event_fn(balloon_opaque, VAR_0);",
"return 1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
3,661 | static bool cmd_write_dma(IDEState *s, uint8_t cmd)
{
bool lba48 = (cmd == WIN_WRITEDMA_EXT);
if (!s->bs) {
ide_abort_command(s);
return true;
}
ide_cmd_lba48_transform(s, lba48);
ide_sector_start_dma(s, IDE_DMA_WRITE);
s->media_changed = 1;
return false;
}
| false | qemu | 4be746345f13e99e468c60acbd3a355e8183e3ce | static bool cmd_write_dma(IDEState *s, uint8_t cmd)
{
bool lba48 = (cmd == WIN_WRITEDMA_EXT);
if (!s->bs) {
ide_abort_command(s);
return true;
}
ide_cmd_lba48_transform(s, lba48);
ide_sector_start_dma(s, IDE_DMA_WRITE);
s->media_changed = 1;
return false;
}
| {
"code": [],
"line_no": []
} | static bool FUNC_0(IDEState *s, uint8_t cmd)
{
bool lba48 = (cmd == WIN_WRITEDMA_EXT);
if (!s->bs) {
ide_abort_command(s);
return true;
}
ide_cmd_lba48_transform(s, lba48);
ide_sector_start_dma(s, IDE_DMA_WRITE);
s->media_changed = 1;
return false;
}
| [
"static bool FUNC_0(IDEState *s, uint8_t cmd)\n{",
"bool lba48 = (cmd == WIN_WRITEDMA_EXT);",
"if (!s->bs) {",
"ide_abort_command(s);",
"return true;",
"}",
"ide_cmd_lba48_transform(s, lba48);",
"ide_sector_start_dma(s, IDE_DMA_WRITE);",
"s->media_changed = 1;",
"return false;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
]
] |
3,663 | static uint64_t pxa2xx_pm_read(void *opaque, hwaddr addr,
unsigned size)
{
PXA2xxState *s = (PXA2xxState *) opaque;
switch (addr) {
case PMCR ... PCMD31:
if (addr & 3)
goto fail;
return s->pm_regs[addr >> 2];
default:
fail:
printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr);
break;
}
return 0;
}
| false | qemu | a89f364ae8740dfc31b321eed9ee454e996dc3c1 | static uint64_t pxa2xx_pm_read(void *opaque, hwaddr addr,
unsigned size)
{
PXA2xxState *s = (PXA2xxState *) opaque;
switch (addr) {
case PMCR ... PCMD31:
if (addr & 3)
goto fail;
return s->pm_regs[addr >> 2];
default:
fail:
printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr);
break;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, hwaddr addr,
unsigned size)
{
PXA2xxState *s = (PXA2xxState *) opaque;
switch (addr) {
case PMCR ... PCMD31:
if (addr & 3)
goto fail;
return s->pm_regs[addr >> 2];
default:
fail:
printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr);
break;
}
return 0;
}
| [
"static uint64_t FUNC_0(void *opaque, hwaddr addr,\nunsigned size)\n{",
"PXA2xxState *s = (PXA2xxState *) opaque;",
"switch (addr) {",
"case PMCR ... PCMD31:\nif (addr & 3)\ngoto fail;",
"return s->pm_regs[addr >> 2];",
"default:\nfail:\nprintf(\"%s: Bad register \" REG_FMT \"\\n\", __FUNCTION__, addr);",
"break;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13,
15,
17
],
[
21
],
[
23,
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
]
] |
3,664 | static void ics_base_realize(DeviceState *dev, Error **errp)
{
ICSStateClass *icsc = ICS_BASE_GET_CLASS(dev);
ICSState *ics = ICS_BASE(dev);
Object *obj;
Error *err = NULL;
obj = object_property_get_link(OBJECT(dev), ICS_PROP_XICS, &err);
if (!obj) {
error_setg(errp, "%s: required link '" ICS_PROP_XICS "' not found: %s",
__func__, error_get_pretty(err));
return;
}
ics->xics = XICS_FABRIC(obj);
if (icsc->realize) {
icsc->realize(dev, errp);
}
}
| false | qemu | 100f738850639a108d6767316ce4dcc1d1ea4ae4 | static void ics_base_realize(DeviceState *dev, Error **errp)
{
ICSStateClass *icsc = ICS_BASE_GET_CLASS(dev);
ICSState *ics = ICS_BASE(dev);
Object *obj;
Error *err = NULL;
obj = object_property_get_link(OBJECT(dev), ICS_PROP_XICS, &err);
if (!obj) {
error_setg(errp, "%s: required link '" ICS_PROP_XICS "' not found: %s",
__func__, error_get_pretty(err));
return;
}
ics->xics = XICS_FABRIC(obj);
if (icsc->realize) {
icsc->realize(dev, errp);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
ICSStateClass *icsc = ICS_BASE_GET_CLASS(VAR_0);
ICSState *ics = ICS_BASE(VAR_0);
Object *obj;
Error *err = NULL;
obj = object_property_get_link(OBJECT(VAR_0), ICS_PROP_XICS, &err);
if (!obj) {
error_setg(VAR_1, "%s: required link '" ICS_PROP_XICS "' not found: %s",
__func__, error_get_pretty(err));
return;
}
ics->xics = XICS_FABRIC(obj);
if (icsc->realize) {
icsc->realize(VAR_0, VAR_1);
}
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"ICSStateClass *icsc = ICS_BASE_GET_CLASS(VAR_0);",
"ICSState *ics = ICS_BASE(VAR_0);",
"Object *obj;",
"Error *err = NULL;",
"obj = object_property_get_link(OBJECT(VAR_0), ICS_PROP_XICS, &err);",
"if (!obj) {",
"error_setg(VAR_1, \"%s: required link '\" ICS_PROP_XICS \"' not found: %s\",\n__func__, error_get_pretty(err));",
"return;",
"}",
"ics->xics = XICS_FABRIC(obj);",
"if (icsc->realize) {",
"icsc->realize(VAR_0, VAR_1);",
"}",
"}"
] | [
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
],
[
33
],
[
35
],
[
37
],
[
39
]
] |
3,665 | bool postcopy_ram_supported_by_host(void)
{
error_report("%s: No OS support", __func__);
return false;
}
| false | qemu | d7651f150d61936344c4fab45eaeb0716c606af2 | bool postcopy_ram_supported_by_host(void)
{
error_report("%s: No OS support", __func__);
return false;
}
| {
"code": [],
"line_no": []
} | bool FUNC_0(void)
{
error_report("%s: No OS support", __func__);
return false;
}
| [
"bool FUNC_0(void)\n{",
"error_report(\"%s: No OS support\", __func__);",
"return false;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
3,666 | int64_t qemu_file_get_rate_limit(QEMUFile *f)
{
return f->xfer_limit;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | int64_t qemu_file_get_rate_limit(QEMUFile *f)
{
return f->xfer_limit;
}
| {
"code": [],
"line_no": []
} | int64_t FUNC_0(QEMUFile *f)
{
return f->xfer_limit;
}
| [
"int64_t FUNC_0(QEMUFile *f)\n{",
"return f->xfer_limit;",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
3,667 | static inline void put_codeword(PutBitContext *pb, vorbis_enc_codebook *cb,
int entry)
{
assert(entry >= 0);
assert(entry < cb->nentries);
assert(cb->lens[entry]);
put_bits(pb, cb->lens[entry], cb->codewords[entry]);
}
| true | FFmpeg | 1ba08c94f5bb4d1c3c2d3651b5e01edb4ce172e2 | static inline void put_codeword(PutBitContext *pb, vorbis_enc_codebook *cb,
int entry)
{
assert(entry >= 0);
assert(entry < cb->nentries);
assert(cb->lens[entry]);
put_bits(pb, cb->lens[entry], cb->codewords[entry]);
}
| {
"code": [
"static inline void put_codeword(PutBitContext *pb, vorbis_enc_codebook *cb,",
" int entry)"
],
"line_no": [
1,
3
]
} | static inline void FUNC_0(PutBitContext *VAR_0, vorbis_enc_codebook *VAR_1,
int VAR_2)
{
assert(VAR_2 >= 0);
assert(VAR_2 < VAR_1->nentries);
assert(VAR_1->lens[VAR_2]);
put_bits(VAR_0, VAR_1->lens[VAR_2], VAR_1->codewords[VAR_2]);
}
| [
"static inline void FUNC_0(PutBitContext *VAR_0, vorbis_enc_codebook *VAR_1,\nint VAR_2)\n{",
"assert(VAR_2 >= 0);",
"assert(VAR_2 < VAR_1->nentries);",
"assert(VAR_1->lens[VAR_2]);",
"put_bits(VAR_0, VAR_1->lens[VAR_2], VAR_1->codewords[VAR_2]);",
"}"
] | [
1,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
3,668 | static inline int qemu_rdma_buffer_mergable(RDMAContext *rdma,
uint64_t offset, uint64_t len)
{
RDMALocalBlock *block;
uint8_t *host_addr;
uint8_t *chunk_end;
if (rdma->current_index < 0) {
return 0;
}
if (rdma->current_chunk < 0) {
return 0;
}
block = &(rdma->local_ram_blocks.block[rdma->current_index]);
host_addr = block->local_host_addr + (offset - block->offset);
chunk_end = ram_chunk_end(block, rdma->current_chunk);
if (rdma->current_length == 0) {
return 0;
}
/*
* Only merge into chunk sequentially.
*/
if (offset != (rdma->current_addr + rdma->current_length)) {
return 0;
}
if (offset < block->offset) {
return 0;
}
if ((offset + len) > (block->offset + block->length)) {
return 0;
}
if ((host_addr + len) > chunk_end) {
return 0;
}
return 1;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | static inline int qemu_rdma_buffer_mergable(RDMAContext *rdma,
uint64_t offset, uint64_t len)
{
RDMALocalBlock *block;
uint8_t *host_addr;
uint8_t *chunk_end;
if (rdma->current_index < 0) {
return 0;
}
if (rdma->current_chunk < 0) {
return 0;
}
block = &(rdma->local_ram_blocks.block[rdma->current_index]);
host_addr = block->local_host_addr + (offset - block->offset);
chunk_end = ram_chunk_end(block, rdma->current_chunk);
if (rdma->current_length == 0) {
return 0;
}
if (offset != (rdma->current_addr + rdma->current_length)) {
return 0;
}
if (offset < block->offset) {
return 0;
}
if ((offset + len) > (block->offset + block->length)) {
return 0;
}
if ((host_addr + len) > chunk_end) {
return 0;
}
return 1;
}
| {
"code": [],
"line_no": []
} | static inline int FUNC_0(RDMAContext *VAR_0,
uint64_t VAR_1, uint64_t VAR_2)
{
RDMALocalBlock *block;
uint8_t *host_addr;
uint8_t *chunk_end;
if (VAR_0->current_index < 0) {
return 0;
}
if (VAR_0->current_chunk < 0) {
return 0;
}
block = &(VAR_0->local_ram_blocks.block[VAR_0->current_index]);
host_addr = block->local_host_addr + (VAR_1 - block->VAR_1);
chunk_end = ram_chunk_end(block, VAR_0->current_chunk);
if (VAR_0->current_length == 0) {
return 0;
}
if (VAR_1 != (VAR_0->current_addr + VAR_0->current_length)) {
return 0;
}
if (VAR_1 < block->VAR_1) {
return 0;
}
if ((VAR_1 + VAR_2) > (block->VAR_1 + block->length)) {
return 0;
}
if ((host_addr + VAR_2) > chunk_end) {
return 0;
}
return 1;
}
| [
"static inline int FUNC_0(RDMAContext *VAR_0,\nuint64_t VAR_1, uint64_t VAR_2)\n{",
"RDMALocalBlock *block;",
"uint8_t *host_addr;",
"uint8_t *chunk_end;",
"if (VAR_0->current_index < 0) {",
"return 0;",
"}",
"if (VAR_0->current_chunk < 0) {",
"return 0;",
"}",
"block = &(VAR_0->local_ram_blocks.block[VAR_0->current_index]);",
"host_addr = block->local_host_addr + (VAR_1 - block->VAR_1);",
"chunk_end = ram_chunk_end(block, VAR_0->current_chunk);",
"if (VAR_0->current_length == 0) {",
"return 0;",
"}",
"if (VAR_1 != (VAR_0->current_addr + VAR_0->current_length)) {",
"return 0;",
"}",
"if (VAR_1 < block->VAR_1) {",
"return 0;",
"}",
"if ((VAR_1 + VAR_2) > (block->VAR_1 + block->length)) {",
"return 0;",
"}",
"if ((host_addr + VAR_2) > chunk_end) {",
"return 0;",
"}",
"return 1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
]
] |
3,669 | static int vmdk_open_desc_file(BlockDriverState *bs, int flags,
int64_t desc_offset)
{
int ret;
char buf[2048];
char ct[128];
BDRVVmdkState *s = bs->opaque;
ret = bdrv_pread(bs->file, desc_offset, buf, sizeof(buf));
if (ret < 0) {
return ret;
}
buf[2047] = '\0';
if (vmdk_parse_description(buf, "createType", ct, sizeof(ct))) {
return -EINVAL;
}
if (strcmp(ct, "monolithicFlat") &&
strcmp(ct, "twoGbMaxExtentSparse") &&
strcmp(ct, "twoGbMaxExtentFlat")) {
fprintf(stderr,
"VMDK: Not supported image type \"%s\""".\n", ct);
return -ENOTSUP;
}
s->desc_offset = 0;
ret = vmdk_parse_extents(buf, bs, bs->file->filename);
if (ret) {
return ret;
}
/* try to open parent images, if exist */
if (vmdk_parent_open(bs)) {
g_free(s->extents);
return -EINVAL;
}
s->parent_cid = vmdk_read_cid(bs, 1);
return 0;
}
| true | qemu | b3c0bfb6f949d8f1c97f390f951c0bab3e703810 | static int vmdk_open_desc_file(BlockDriverState *bs, int flags,
int64_t desc_offset)
{
int ret;
char buf[2048];
char ct[128];
BDRVVmdkState *s = bs->opaque;
ret = bdrv_pread(bs->file, desc_offset, buf, sizeof(buf));
if (ret < 0) {
return ret;
}
buf[2047] = '\0';
if (vmdk_parse_description(buf, "createType", ct, sizeof(ct))) {
return -EINVAL;
}
if (strcmp(ct, "monolithicFlat") &&
strcmp(ct, "twoGbMaxExtentSparse") &&
strcmp(ct, "twoGbMaxExtentFlat")) {
fprintf(stderr,
"VMDK: Not supported image type \"%s\""".\n", ct);
return -ENOTSUP;
}
s->desc_offset = 0;
ret = vmdk_parse_extents(buf, bs, bs->file->filename);
if (ret) {
return ret;
}
if (vmdk_parent_open(bs)) {
g_free(s->extents);
return -EINVAL;
}
s->parent_cid = vmdk_read_cid(bs, 1);
return 0;
}
| {
"code": [
" g_free(s->extents);"
],
"line_no": [
63
]
} | static int FUNC_0(BlockDriverState *VAR_0, int VAR_1,
int64_t VAR_2)
{
int VAR_3;
char VAR_4[2048];
char VAR_5[128];
BDRVVmdkState *s = VAR_0->opaque;
VAR_3 = bdrv_pread(VAR_0->file, VAR_2, VAR_4, sizeof(VAR_4));
if (VAR_3 < 0) {
return VAR_3;
}
VAR_4[2047] = '\0';
if (vmdk_parse_description(VAR_4, "createType", VAR_5, sizeof(VAR_5))) {
return -EINVAL;
}
if (strcmp(VAR_5, "monolithicFlat") &&
strcmp(VAR_5, "twoGbMaxExtentSparse") &&
strcmp(VAR_5, "twoGbMaxExtentFlat")) {
fprintf(stderr,
"VMDK: Not supported image type \"%s\""".\n", VAR_5);
return -ENOTSUP;
}
s->VAR_2 = 0;
VAR_3 = vmdk_parse_extents(VAR_4, VAR_0, VAR_0->file->filename);
if (VAR_3) {
return VAR_3;
}
if (vmdk_parent_open(VAR_0)) {
g_free(s->extents);
return -EINVAL;
}
s->parent_cid = vmdk_read_cid(VAR_0, 1);
return 0;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, int VAR_1,\nint64_t VAR_2)\n{",
"int VAR_3;",
"char VAR_4[2048];",
"char VAR_5[128];",
"BDRVVmdkState *s = VAR_0->opaque;",
"VAR_3 = bdrv_pread(VAR_0->file, VAR_2, VAR_4, sizeof(VAR_4));",
"if (VAR_3 < 0) {",
"return VAR_3;",
"}",
"VAR_4[2047] = '\\0';",
"if (vmdk_parse_description(VAR_4, \"createType\", VAR_5, sizeof(VAR_5))) {",
"return -EINVAL;",
"}",
"if (strcmp(VAR_5, \"monolithicFlat\") &&\nstrcmp(VAR_5, \"twoGbMaxExtentSparse\") &&\nstrcmp(VAR_5, \"twoGbMaxExtentFlat\")) {",
"fprintf(stderr,\n\"VMDK: Not supported image type \\\"%s\\\"\"\".\\n\", VAR_5);",
"return -ENOTSUP;",
"}",
"s->VAR_2 = 0;",
"VAR_3 = vmdk_parse_extents(VAR_4, VAR_0, VAR_0->file->filename);",
"if (VAR_3) {",
"return VAR_3;",
"}",
"if (vmdk_parent_open(VAR_0)) {",
"g_free(s->extents);",
"return -EINVAL;",
"}",
"s->parent_cid = vmdk_read_cid(VAR_0, 1);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33,
35,
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
]
] |
3,670 | static void vc1_mc_4mv_chroma(VC1Context *v, int dir)
{
MpegEncContext *s = &v->s;
H264ChromaContext *h264chroma = &v->h264chroma;
uint8_t *srcU, *srcV;
int uvmx, uvmy, uvsrc_x, uvsrc_y;
int k, tx = 0, ty = 0;
int mvx[4], mvy[4], intra[4], mv_f[4];
int valid_count;
int chroma_ref_type = v->cur_field_type;
int v_edge_pos = s->v_edge_pos >> v->field_mode;
uint8_t (*lutuv)[256];
int use_ic;
if (!v->field_mode && !v->s.last_picture.f.data[0])
return;
if (s->flags & CODEC_FLAG_GRAY)
return;
for (k = 0; k < 4; k++) {
mvx[k] = s->mv[dir][k][0];
mvy[k] = s->mv[dir][k][1];
intra[k] = v->mb_type[0][s->block_index[k]];
if (v->field_mode)
mv_f[k] = v->mv_f[dir][s->block_index[k] + v->blocks_off];
}
/* calculate chroma MV vector from four luma MVs */
if (!v->field_mode || (v->field_mode && !v->numref)) {
valid_count = get_chroma_mv(mvx, mvy, intra, 0, &tx, &ty);
chroma_ref_type = v->reffield;
if (!valid_count) {
s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][0] = 0;
s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][1] = 0;
v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0;
return; //no need to do MC for intra blocks
}
} else {
int dominant = 0;
if (mv_f[0] + mv_f[1] + mv_f[2] + mv_f[3] > 2)
dominant = 1;
valid_count = get_chroma_mv(mvx, mvy, mv_f, dominant, &tx, &ty);
if (dominant)
chroma_ref_type = !v->cur_field_type;
}
if (v->field_mode && chroma_ref_type == 1 && v->cur_field_type == 1 && !v->s.last_picture.f.data[0])
return;
s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx;
s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty;
uvmx = (tx + ((tx & 3) == 3)) >> 1;
uvmy = (ty + ((ty & 3) == 3)) >> 1;
v->luma_mv[s->mb_x][0] = uvmx;
v->luma_mv[s->mb_x][1] = uvmy;
if (v->fastuvmc) {
uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));
uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));
}
// Field conversion bias
if (v->cur_field_type != chroma_ref_type)
uvmy += 2 - 4 * chroma_ref_type;
uvsrc_x = s->mb_x * 8 + (uvmx >> 2);
uvsrc_y = s->mb_y * 8 + (uvmy >> 2);
if (v->profile != PROFILE_ADVANCED) {
uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8);
uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8);
} else {
uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1);
uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
}
if (!dir) {
if (v->field_mode && (v->cur_field_type != chroma_ref_type) && v->second_field) {
srcU = s->current_picture.f.data[1];
srcV = s->current_picture.f.data[2];
lutuv = v->curr_lutuv;
use_ic = v->curr_use_ic;
} else {
srcU = s->last_picture.f.data[1];
srcV = s->last_picture.f.data[2];
lutuv = v->last_lutuv;
use_ic = v->last_use_ic;
}
} else {
srcU = s->next_picture.f.data[1];
srcV = s->next_picture.f.data[2];
lutuv = v->next_lutuv;
use_ic = v->next_use_ic;
}
if (!srcU) {
av_log(v->s.avctx, AV_LOG_ERROR, "Referenced frame missing.\n");
return;
}
srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
if (v->field_mode) {
if (chroma_ref_type) {
srcU += s->current_picture_ptr->f.linesize[1];
srcV += s->current_picture_ptr->f.linesize[2];
}
}
if (v->rangeredfrm || use_ic
|| s->h_edge_pos < 18 || v_edge_pos < 18
|| (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 9
|| (unsigned)uvsrc_y > (v_edge_pos >> 1) - 9) {
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, srcU,
s->uvlinesize, s->uvlinesize,
8 + 1, 8 + 1, uvsrc_x, uvsrc_y,
s->h_edge_pos >> 1, v_edge_pos >> 1);
s->vdsp.emulated_edge_mc(s->edge_emu_buffer + 16, srcV,
s->uvlinesize, s->uvlinesize,
8 + 1, 8 + 1, uvsrc_x, uvsrc_y,
s->h_edge_pos >> 1, v_edge_pos >> 1);
srcU = s->edge_emu_buffer;
srcV = s->edge_emu_buffer + 16;
/* if we deal with range reduction we need to scale source blocks */
if (v->rangeredfrm) {
int i, j;
uint8_t *src, *src2;
src = srcU;
src2 = srcV;
for (j = 0; j < 9; j++) {
for (i = 0; i < 9; i++) {
src[i] = ((src[i] - 128) >> 1) + 128;
src2[i] = ((src2[i] - 128) >> 1) + 128;
}
src += s->uvlinesize;
src2 += s->uvlinesize;
}
}
/* if we deal with intensity compensation we need to scale source blocks */
if (use_ic) {
int i, j;
uint8_t *src, *src2;
src = srcU;
src2 = srcV;
for (j = 0; j < 9; j++) {
int f = v->field_mode ? chroma_ref_type : ((j + uvsrc_y) & 1);
for (i = 0; i < 9; i++) {
src[i] = lutuv[f][src[i]];
src2[i] = lutuv[f][src2[i]];
}
src += s->uvlinesize;
src2 += s->uvlinesize;
}
}
}
/* Chroma MC always uses qpel bilinear */
uvmx = (uvmx & 3) << 1;
uvmy = (uvmy & 3) << 1;
if (!v->rnd) {
h264chroma->put_h264_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
h264chroma->put_h264_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
} else {
v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
}
}
| true | FFmpeg | f6774f905fb3cfdc319523ac640be30b14c1bc55 | static void vc1_mc_4mv_chroma(VC1Context *v, int dir)
{
MpegEncContext *s = &v->s;
H264ChromaContext *h264chroma = &v->h264chroma;
uint8_t *srcU, *srcV;
int uvmx, uvmy, uvsrc_x, uvsrc_y;
int k, tx = 0, ty = 0;
int mvx[4], mvy[4], intra[4], mv_f[4];
int valid_count;
int chroma_ref_type = v->cur_field_type;
int v_edge_pos = s->v_edge_pos >> v->field_mode;
uint8_t (*lutuv)[256];
int use_ic;
if (!v->field_mode && !v->s.last_picture.f.data[0])
return;
if (s->flags & CODEC_FLAG_GRAY)
return;
for (k = 0; k < 4; k++) {
mvx[k] = s->mv[dir][k][0];
mvy[k] = s->mv[dir][k][1];
intra[k] = v->mb_type[0][s->block_index[k]];
if (v->field_mode)
mv_f[k] = v->mv_f[dir][s->block_index[k] + v->blocks_off];
}
if (!v->field_mode || (v->field_mode && !v->numref)) {
valid_count = get_chroma_mv(mvx, mvy, intra, 0, &tx, &ty);
chroma_ref_type = v->reffield;
if (!valid_count) {
s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][0] = 0;
s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][1] = 0;
v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0;
return;
}
} else {
int dominant = 0;
if (mv_f[0] + mv_f[1] + mv_f[2] + mv_f[3] > 2)
dominant = 1;
valid_count = get_chroma_mv(mvx, mvy, mv_f, dominant, &tx, &ty);
if (dominant)
chroma_ref_type = !v->cur_field_type;
}
if (v->field_mode && chroma_ref_type == 1 && v->cur_field_type == 1 && !v->s.last_picture.f.data[0])
return;
s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx;
s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty;
uvmx = (tx + ((tx & 3) == 3)) >> 1;
uvmy = (ty + ((ty & 3) == 3)) >> 1;
v->luma_mv[s->mb_x][0] = uvmx;
v->luma_mv[s->mb_x][1] = uvmy;
if (v->fastuvmc) {
uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));
uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));
}
if (v->cur_field_type != chroma_ref_type)
uvmy += 2 - 4 * chroma_ref_type;
uvsrc_x = s->mb_x * 8 + (uvmx >> 2);
uvsrc_y = s->mb_y * 8 + (uvmy >> 2);
if (v->profile != PROFILE_ADVANCED) {
uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8);
uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8);
} else {
uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1);
uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
}
if (!dir) {
if (v->field_mode && (v->cur_field_type != chroma_ref_type) && v->second_field) {
srcU = s->current_picture.f.data[1];
srcV = s->current_picture.f.data[2];
lutuv = v->curr_lutuv;
use_ic = v->curr_use_ic;
} else {
srcU = s->last_picture.f.data[1];
srcV = s->last_picture.f.data[2];
lutuv = v->last_lutuv;
use_ic = v->last_use_ic;
}
} else {
srcU = s->next_picture.f.data[1];
srcV = s->next_picture.f.data[2];
lutuv = v->next_lutuv;
use_ic = v->next_use_ic;
}
if (!srcU) {
av_log(v->s.avctx, AV_LOG_ERROR, "Referenced frame missing.\n");
return;
}
srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
if (v->field_mode) {
if (chroma_ref_type) {
srcU += s->current_picture_ptr->f.linesize[1];
srcV += s->current_picture_ptr->f.linesize[2];
}
}
if (v->rangeredfrm || use_ic
|| s->h_edge_pos < 18 || v_edge_pos < 18
|| (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 9
|| (unsigned)uvsrc_y > (v_edge_pos >> 1) - 9) {
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, srcU,
s->uvlinesize, s->uvlinesize,
8 + 1, 8 + 1, uvsrc_x, uvsrc_y,
s->h_edge_pos >> 1, v_edge_pos >> 1);
s->vdsp.emulated_edge_mc(s->edge_emu_buffer + 16, srcV,
s->uvlinesize, s->uvlinesize,
8 + 1, 8 + 1, uvsrc_x, uvsrc_y,
s->h_edge_pos >> 1, v_edge_pos >> 1);
srcU = s->edge_emu_buffer;
srcV = s->edge_emu_buffer + 16;
if (v->rangeredfrm) {
int i, j;
uint8_t *src, *src2;
src = srcU;
src2 = srcV;
for (j = 0; j < 9; j++) {
for (i = 0; i < 9; i++) {
src[i] = ((src[i] - 128) >> 1) + 128;
src2[i] = ((src2[i] - 128) >> 1) + 128;
}
src += s->uvlinesize;
src2 += s->uvlinesize;
}
}
if (use_ic) {
int i, j;
uint8_t *src, *src2;
src = srcU;
src2 = srcV;
for (j = 0; j < 9; j++) {
int f = v->field_mode ? chroma_ref_type : ((j + uvsrc_y) & 1);
for (i = 0; i < 9; i++) {
src[i] = lutuv[f][src[i]];
src2[i] = lutuv[f][src2[i]];
}
src += s->uvlinesize;
src2 += s->uvlinesize;
}
}
}
uvmx = (uvmx & 3) << 1;
uvmy = (uvmy & 3) << 1;
if (!v->rnd) {
h264chroma->put_h264_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
h264chroma->put_h264_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
} else {
v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
}
}
| {
"code": [
" srcU = s->current_picture.f.data[1];",
" srcV = s->current_picture.f.data[2];",
" srcU = s->last_picture.f.data[1];",
" srcV = s->last_picture.f.data[2];",
" srcU = s->next_picture.f.data[1];",
" srcV = s->next_picture.f.data[2];",
" if (!v->field_mode && !v->s.last_picture.f.data[0])",
" if (v->field_mode && chroma_ref_type == 1 && v->cur_field_type == 1 && !v->s.last_picture.f.data[0])",
" srcU = s->current_picture.f.data[1];",
" srcV = s->current_picture.f.data[2];",
" srcU = s->last_picture.f.data[1];",
" srcV = s->last_picture.f.data[2];",
" srcU = s->next_picture.f.data[1];",
" srcV = s->next_picture.f.data[2];",
" srcU += s->current_picture_ptr->f.linesize[1];",
" srcV += s->current_picture_ptr->f.linesize[2];"
],
"line_no": [
153,
155,
163,
165,
175,
177,
29,
91,
153,
155,
163,
165,
175,
177,
207,
209
]
} | static void FUNC_0(VC1Context *VAR_0, int VAR_1)
{
MpegEncContext *s = &VAR_0->s;
H264ChromaContext *h264chroma = &VAR_0->h264chroma;
uint8_t *srcU, *srcV;
int VAR_2, VAR_3, VAR_4, VAR_5;
int VAR_6, VAR_7 = 0, VAR_8 = 0;
int VAR_9[4], VAR_10[4], VAR_11[4], VAR_12[4];
int VAR_13;
int VAR_14 = VAR_0->cur_field_type;
int VAR_15 = s->VAR_15 >> VAR_0->field_mode;
uint8_t (*lutuv)[256];
int VAR_16;
if (!VAR_0->field_mode && !VAR_0->s.last_picture.VAR_20.data[0])
return;
if (s->flags & CODEC_FLAG_GRAY)
return;
for (VAR_6 = 0; VAR_6 < 4; VAR_6++) {
VAR_9[VAR_6] = s->mv[VAR_1][VAR_6][0];
VAR_10[VAR_6] = s->mv[VAR_1][VAR_6][1];
VAR_11[VAR_6] = VAR_0->mb_type[0][s->block_index[VAR_6]];
if (VAR_0->field_mode)
VAR_12[VAR_6] = VAR_0->VAR_12[VAR_1][s->block_index[VAR_6] + VAR_0->blocks_off];
}
if (!VAR_0->field_mode || (VAR_0->field_mode && !VAR_0->numref)) {
VAR_13 = get_chroma_mv(VAR_9, VAR_10, VAR_11, 0, &VAR_7, &VAR_8);
VAR_14 = VAR_0->reffield;
if (!VAR_13) {
s->current_picture.motion_val[1][s->block_index[0] + VAR_0->blocks_off][0] = 0;
s->current_picture.motion_val[1][s->block_index[0] + VAR_0->blocks_off][1] = 0;
VAR_0->luma_mv[s->mb_x][0] = VAR_0->luma_mv[s->mb_x][1] = 0;
return;
}
} else {
int VAR_17 = 0;
if (VAR_12[0] + VAR_12[1] + VAR_12[2] + VAR_12[3] > 2)
VAR_17 = 1;
VAR_13 = get_chroma_mv(VAR_9, VAR_10, VAR_12, VAR_17, &VAR_7, &VAR_8);
if (VAR_17)
VAR_14 = !VAR_0->cur_field_type;
}
if (VAR_0->field_mode && VAR_14 == 1 && VAR_0->cur_field_type == 1 && !VAR_0->s.last_picture.VAR_20.data[0])
return;
s->current_picture.motion_val[1][s->block_index[0] + VAR_0->blocks_off][0] = VAR_7;
s->current_picture.motion_val[1][s->block_index[0] + VAR_0->blocks_off][1] = VAR_8;
VAR_2 = (VAR_7 + ((VAR_7 & 3) == 3)) >> 1;
VAR_3 = (VAR_8 + ((VAR_8 & 3) == 3)) >> 1;
VAR_0->luma_mv[s->mb_x][0] = VAR_2;
VAR_0->luma_mv[s->mb_x][1] = VAR_3;
if (VAR_0->fastuvmc) {
VAR_2 = VAR_2 + ((VAR_2 < 0) ? (VAR_2 & 1) : -(VAR_2 & 1));
VAR_3 = VAR_3 + ((VAR_3 < 0) ? (VAR_3 & 1) : -(VAR_3 & 1));
}
if (VAR_0->cur_field_type != VAR_14)
VAR_3 += 2 - 4 * VAR_14;
VAR_4 = s->mb_x * 8 + (VAR_2 >> 2);
VAR_5 = s->mb_y * 8 + (VAR_3 >> 2);
if (VAR_0->profile != PROFILE_ADVANCED) {
VAR_4 = av_clip(VAR_4, -8, s->mb_width * 8);
VAR_5 = av_clip(VAR_5, -8, s->mb_height * 8);
} else {
VAR_4 = av_clip(VAR_4, -8, s->avctx->coded_width >> 1);
VAR_5 = av_clip(VAR_5, -8, s->avctx->coded_height >> 1);
}
if (!VAR_1) {
if (VAR_0->field_mode && (VAR_0->cur_field_type != VAR_14) && VAR_0->second_field) {
srcU = s->current_picture.VAR_20.data[1];
srcV = s->current_picture.VAR_20.data[2];
lutuv = VAR_0->curr_lutuv;
VAR_16 = VAR_0->curr_use_ic;
} else {
srcU = s->last_picture.VAR_20.data[1];
srcV = s->last_picture.VAR_20.data[2];
lutuv = VAR_0->last_lutuv;
VAR_16 = VAR_0->last_use_ic;
}
} else {
srcU = s->next_picture.VAR_20.data[1];
srcV = s->next_picture.VAR_20.data[2];
lutuv = VAR_0->next_lutuv;
VAR_16 = VAR_0->next_use_ic;
}
if (!srcU) {
av_log(VAR_0->s.avctx, AV_LOG_ERROR, "Referenced frame missing.\n");
return;
}
srcU += VAR_5 * s->uvlinesize + VAR_4;
srcV += VAR_5 * s->uvlinesize + VAR_4;
if (VAR_0->field_mode) {
if (VAR_14) {
srcU += s->current_picture_ptr->VAR_20.linesize[1];
srcV += s->current_picture_ptr->VAR_20.linesize[2];
}
}
if (VAR_0->rangeredfrm || VAR_16
|| s->h_edge_pos < 18 || VAR_15 < 18
|| (unsigned)VAR_4 > (s->h_edge_pos >> 1) - 9
|| (unsigned)VAR_5 > (VAR_15 >> 1) - 9) {
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, srcU,
s->uvlinesize, s->uvlinesize,
8 + 1, 8 + 1, VAR_4, VAR_5,
s->h_edge_pos >> 1, VAR_15 >> 1);
s->vdsp.emulated_edge_mc(s->edge_emu_buffer + 16, srcV,
s->uvlinesize, s->uvlinesize,
8 + 1, 8 + 1, VAR_4, VAR_5,
s->h_edge_pos >> 1, VAR_15 >> 1);
srcU = s->edge_emu_buffer;
srcV = s->edge_emu_buffer + 16;
if (VAR_0->rangeredfrm) {
int VAR_20, VAR_20;
uint8_t *src, *src2;
src = srcU;
src2 = srcV;
for (VAR_20 = 0; VAR_20 < 9; VAR_20++) {
for (VAR_20 = 0; VAR_20 < 9; VAR_20++) {
src[VAR_20] = ((src[VAR_20] - 128) >> 1) + 128;
src2[VAR_20] = ((src2[VAR_20] - 128) >> 1) + 128;
}
src += s->uvlinesize;
src2 += s->uvlinesize;
}
}
if (VAR_16) {
int VAR_20, VAR_20;
uint8_t *src, *src2;
src = srcU;
src2 = srcV;
for (VAR_20 = 0; VAR_20 < 9; VAR_20++) {
int VAR_20 = VAR_0->field_mode ? VAR_14 : ((VAR_20 + VAR_5) & 1);
for (VAR_20 = 0; VAR_20 < 9; VAR_20++) {
src[VAR_20] = lutuv[VAR_20][src[VAR_20]];
src2[VAR_20] = lutuv[VAR_20][src2[VAR_20]];
}
src += s->uvlinesize;
src2 += s->uvlinesize;
}
}
}
VAR_2 = (VAR_2 & 3) << 1;
VAR_3 = (VAR_3 & 3) << 1;
if (!VAR_0->rnd) {
h264chroma->put_h264_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, VAR_2, VAR_3);
h264chroma->put_h264_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, VAR_2, VAR_3);
} else {
VAR_0->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, VAR_2, VAR_3);
VAR_0->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, VAR_2, VAR_3);
}
}
| [
"static void FUNC_0(VC1Context *VAR_0, int VAR_1)\n{",
"MpegEncContext *s = &VAR_0->s;",
"H264ChromaContext *h264chroma = &VAR_0->h264chroma;",
"uint8_t *srcU, *srcV;",
"int VAR_2, VAR_3, VAR_4, VAR_5;",
"int VAR_6, VAR_7 = 0, VAR_8 = 0;",
"int VAR_9[4], VAR_10[4], VAR_11[4], VAR_12[4];",
"int VAR_13;",
"int VAR_14 = VAR_0->cur_field_type;",
"int VAR_15 = s->VAR_15 >> VAR_0->field_mode;",
"uint8_t (*lutuv)[256];",
"int VAR_16;",
"if (!VAR_0->field_mode && !VAR_0->s.last_picture.VAR_20.data[0])\nreturn;",
"if (s->flags & CODEC_FLAG_GRAY)\nreturn;",
"for (VAR_6 = 0; VAR_6 < 4; VAR_6++) {",
"VAR_9[VAR_6] = s->mv[VAR_1][VAR_6][0];",
"VAR_10[VAR_6] = s->mv[VAR_1][VAR_6][1];",
"VAR_11[VAR_6] = VAR_0->mb_type[0][s->block_index[VAR_6]];",
"if (VAR_0->field_mode)\nVAR_12[VAR_6] = VAR_0->VAR_12[VAR_1][s->block_index[VAR_6] + VAR_0->blocks_off];",
"}",
"if (!VAR_0->field_mode || (VAR_0->field_mode && !VAR_0->numref)) {",
"VAR_13 = get_chroma_mv(VAR_9, VAR_10, VAR_11, 0, &VAR_7, &VAR_8);",
"VAR_14 = VAR_0->reffield;",
"if (!VAR_13) {",
"s->current_picture.motion_val[1][s->block_index[0] + VAR_0->blocks_off][0] = 0;",
"s->current_picture.motion_val[1][s->block_index[0] + VAR_0->blocks_off][1] = 0;",
"VAR_0->luma_mv[s->mb_x][0] = VAR_0->luma_mv[s->mb_x][1] = 0;",
"return;",
"}",
"} else {",
"int VAR_17 = 0;",
"if (VAR_12[0] + VAR_12[1] + VAR_12[2] + VAR_12[3] > 2)\nVAR_17 = 1;",
"VAR_13 = get_chroma_mv(VAR_9, VAR_10, VAR_12, VAR_17, &VAR_7, &VAR_8);",
"if (VAR_17)\nVAR_14 = !VAR_0->cur_field_type;",
"}",
"if (VAR_0->field_mode && VAR_14 == 1 && VAR_0->cur_field_type == 1 && !VAR_0->s.last_picture.VAR_20.data[0])\nreturn;",
"s->current_picture.motion_val[1][s->block_index[0] + VAR_0->blocks_off][0] = VAR_7;",
"s->current_picture.motion_val[1][s->block_index[0] + VAR_0->blocks_off][1] = VAR_8;",
"VAR_2 = (VAR_7 + ((VAR_7 & 3) == 3)) >> 1;",
"VAR_3 = (VAR_8 + ((VAR_8 & 3) == 3)) >> 1;",
"VAR_0->luma_mv[s->mb_x][0] = VAR_2;",
"VAR_0->luma_mv[s->mb_x][1] = VAR_3;",
"if (VAR_0->fastuvmc) {",
"VAR_2 = VAR_2 + ((VAR_2 < 0) ? (VAR_2 & 1) : -(VAR_2 & 1));",
"VAR_3 = VAR_3 + ((VAR_3 < 0) ? (VAR_3 & 1) : -(VAR_3 & 1));",
"}",
"if (VAR_0->cur_field_type != VAR_14)\nVAR_3 += 2 - 4 * VAR_14;",
"VAR_4 = s->mb_x * 8 + (VAR_2 >> 2);",
"VAR_5 = s->mb_y * 8 + (VAR_3 >> 2);",
"if (VAR_0->profile != PROFILE_ADVANCED) {",
"VAR_4 = av_clip(VAR_4, -8, s->mb_width * 8);",
"VAR_5 = av_clip(VAR_5, -8, s->mb_height * 8);",
"} else {",
"VAR_4 = av_clip(VAR_4, -8, s->avctx->coded_width >> 1);",
"VAR_5 = av_clip(VAR_5, -8, s->avctx->coded_height >> 1);",
"}",
"if (!VAR_1) {",
"if (VAR_0->field_mode && (VAR_0->cur_field_type != VAR_14) && VAR_0->second_field) {",
"srcU = s->current_picture.VAR_20.data[1];",
"srcV = s->current_picture.VAR_20.data[2];",
"lutuv = VAR_0->curr_lutuv;",
"VAR_16 = VAR_0->curr_use_ic;",
"} else {",
"srcU = s->last_picture.VAR_20.data[1];",
"srcV = s->last_picture.VAR_20.data[2];",
"lutuv = VAR_0->last_lutuv;",
"VAR_16 = VAR_0->last_use_ic;",
"}",
"} else {",
"srcU = s->next_picture.VAR_20.data[1];",
"srcV = s->next_picture.VAR_20.data[2];",
"lutuv = VAR_0->next_lutuv;",
"VAR_16 = VAR_0->next_use_ic;",
"}",
"if (!srcU) {",
"av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"Referenced frame missing.\\n\");",
"return;",
"}",
"srcU += VAR_5 * s->uvlinesize + VAR_4;",
"srcV += VAR_5 * s->uvlinesize + VAR_4;",
"if (VAR_0->field_mode) {",
"if (VAR_14) {",
"srcU += s->current_picture_ptr->VAR_20.linesize[1];",
"srcV += s->current_picture_ptr->VAR_20.linesize[2];",
"}",
"}",
"if (VAR_0->rangeredfrm || VAR_16\n|| s->h_edge_pos < 18 || VAR_15 < 18\n|| (unsigned)VAR_4 > (s->h_edge_pos >> 1) - 9\n|| (unsigned)VAR_5 > (VAR_15 >> 1) - 9) {",
"s->vdsp.emulated_edge_mc(s->edge_emu_buffer, srcU,\ns->uvlinesize, s->uvlinesize,\n8 + 1, 8 + 1, VAR_4, VAR_5,\ns->h_edge_pos >> 1, VAR_15 >> 1);",
"s->vdsp.emulated_edge_mc(s->edge_emu_buffer + 16, srcV,\ns->uvlinesize, s->uvlinesize,\n8 + 1, 8 + 1, VAR_4, VAR_5,\ns->h_edge_pos >> 1, VAR_15 >> 1);",
"srcU = s->edge_emu_buffer;",
"srcV = s->edge_emu_buffer + 16;",
"if (VAR_0->rangeredfrm) {",
"int VAR_20, VAR_20;",
"uint8_t *src, *src2;",
"src = srcU;",
"src2 = srcV;",
"for (VAR_20 = 0; VAR_20 < 9; VAR_20++) {",
"for (VAR_20 = 0; VAR_20 < 9; VAR_20++) {",
"src[VAR_20] = ((src[VAR_20] - 128) >> 1) + 128;",
"src2[VAR_20] = ((src2[VAR_20] - 128) >> 1) + 128;",
"}",
"src += s->uvlinesize;",
"src2 += s->uvlinesize;",
"}",
"}",
"if (VAR_16) {",
"int VAR_20, VAR_20;",
"uint8_t *src, *src2;",
"src = srcU;",
"src2 = srcV;",
"for (VAR_20 = 0; VAR_20 < 9; VAR_20++) {",
"int VAR_20 = VAR_0->field_mode ? VAR_14 : ((VAR_20 + VAR_5) & 1);",
"for (VAR_20 = 0; VAR_20 < 9; VAR_20++) {",
"src[VAR_20] = lutuv[VAR_20][src[VAR_20]];",
"src2[VAR_20] = lutuv[VAR_20][src2[VAR_20]];",
"}",
"src += s->uvlinesize;",
"src2 += s->uvlinesize;",
"}",
"}",
"}",
"VAR_2 = (VAR_2 & 3) << 1;",
"VAR_3 = (VAR_3 & 3) << 1;",
"if (!VAR_0->rnd) {",
"h264chroma->put_h264_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, VAR_2, VAR_3);",
"h264chroma->put_h264_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, VAR_2, VAR_3);",
"} else {",
"VAR_0->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, VAR_2, VAR_3);",
"VAR_0->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, VAR_2, VAR_3);",
"}",
"}"
] | [
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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
1,
1,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29,
31
],
[
33,
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79,
81
],
[
83
],
[
85,
87
],
[
89
],
[
91,
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121,
123
],
[
127
],
[
129
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
217,
219,
221,
223
],
[
225,
227,
229,
231
],
[
233,
235,
237,
239
],
[
241
],
[
243
],
[
249
],
[
251
],
[
253
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
281
],
[
283
],
[
285
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
]
] |
3,671 | void palette8torgb24(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette)
{
unsigned i;
/*
writes 1 byte o much and might cause alignment issues on some architectures?
for(i=0; i<num_pixels; i++)
((unsigned *)(&dst[i*3])) = ((unsigned *)palette)[ src[i] ];
*/
for(i=0; i<num_pixels; i++)
{
//FIXME slow?
dst[0]= palette[ src[i]*4+2 ];
dst[1]= palette[ src[i]*4+1 ];
dst[2]= palette[ src[i]*4+0 ];
dst+= 3;
}
}
| true | FFmpeg | 7f526efd17973ec6d2204f7a47b6923e2be31363 | void palette8torgb24(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette)
{
unsigned i;
for(i=0; i<num_pixels; i++)
{
dst[0]= palette[ src[i]*4+2 ];
dst[1]= palette[ src[i]*4+1 ];
dst[2]= palette[ src[i]*4+0 ];
dst+= 3;
}
}
| {
"code": [
"\tunsigned i;",
"\tunsigned i;",
"void palette8torgb24(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette)",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;"
],
"line_no": [
5,
5,
1,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
]
} | void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, unsigned VAR_2, const uint8_t *VAR_3)
{
unsigned VAR_4;
for(VAR_4=0; VAR_4<VAR_2; VAR_4++)
{
VAR_1[0]= VAR_3[ VAR_0[VAR_4]*4+2 ];
VAR_1[1]= VAR_3[ VAR_0[VAR_4]*4+1 ];
VAR_1[2]= VAR_3[ VAR_0[VAR_4]*4+0 ];
VAR_1+= 3;
}
}
| [
"void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, unsigned VAR_2, const uint8_t *VAR_3)\n{",
"unsigned VAR_4;",
"for(VAR_4=0; VAR_4<VAR_2; VAR_4++)",
"{",
"VAR_1[0]= VAR_3[ VAR_0[VAR_4]*4+2 ];",
"VAR_1[1]= VAR_3[ VAR_0[VAR_4]*4+1 ];",
"VAR_1[2]= VAR_3[ VAR_0[VAR_4]*4+0 ];",
"VAR_1+= 3;",
"}",
"}"
] | [
1,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
]
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.