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
listlengths 1
2.8k
| label
listlengths 1
2.8k
| line_no
listlengths 1
2.8k
|
---|---|---|---|---|---|---|---|---|---|---|
14,315 | int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
int tag;
if (fc->nb_streams < 1)
return 0;
st = fc->streams[fc->nb_streams-1];
avio_rb32(pb); /* version + flags */
ff_mp4_read_descr(fc, pb, &tag);
if (tag == MP4ESDescrTag) {
ff_mp4_parse_es_descr(pb, NULL);
} else
avio_rb16(pb); /* ID */
ff_mp4_read_descr(fc, pb, &tag);
if (tag == MP4DecConfigDescrTag)
ff_mp4_read_dec_config_descr(fc, st, pb);
return 0;
}
| true | FFmpeg | 86dfcfd0e30d6645eea2c63c1c60a0550e7c97ea | int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
int tag;
if (fc->nb_streams < 1)
return 0;
st = fc->streams[fc->nb_streams-1];
avio_rb32(pb);
ff_mp4_read_descr(fc, pb, &tag);
if (tag == MP4ESDescrTag) {
ff_mp4_parse_es_descr(pb, NULL);
} else
avio_rb16(pb);
ff_mp4_read_descr(fc, pb, &tag);
if (tag == MP4DecConfigDescrTag)
ff_mp4_read_dec_config_descr(fc, st, pb);
return 0;
}
| {
"code": [
"int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb, MOVAtom atom)"
],
"line_no": [
1
]
} | int FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2)
{
AVStream *st;
int VAR_3;
if (VAR_0->nb_streams < 1)
return 0;
st = VAR_0->streams[VAR_0->nb_streams-1];
avio_rb32(VAR_1);
ff_mp4_read_descr(VAR_0, VAR_1, &VAR_3);
if (VAR_3 == MP4ESDescrTag) {
ff_mp4_parse_es_descr(VAR_1, NULL);
} else
avio_rb16(VAR_1);
ff_mp4_read_descr(VAR_0, VAR_1, &VAR_3);
if (VAR_3 == MP4DecConfigDescrTag)
ff_mp4_read_dec_config_descr(VAR_0, st, VAR_1);
return 0;
}
| [
"int FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2)\n{",
"AVStream *st;",
"int VAR_3;",
"if (VAR_0->nb_streams < 1)\nreturn 0;",
"st = VAR_0->streams[VAR_0->nb_streams-1];",
"avio_rb32(VAR_1);",
"ff_mp4_read_descr(VAR_0, VAR_1, &VAR_3);",
"if (VAR_3 == MP4ESDescrTag) {",
"ff_mp4_parse_es_descr(VAR_1, NULL);",
"} else",
"avio_rb16(VAR_1);",
"ff_mp4_read_descr(VAR_0, VAR_1, &VAR_3);",
"if (VAR_3 == MP4DecConfigDescrTag)\nff_mp4_read_dec_config_descr(VAR_0, st, VAR_1);",
"return 0;",
"}"
]
| [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35,
37
],
[
39
],
[
41
]
]
|
14,316 | static void usb_serial_handle_data(USBDevice *dev, USBPacket *p)
{
USBSerialState *s = (USBSerialState *)dev;
uint8_t devep = p->ep->nr;
struct iovec *iov;
uint8_t header[2];
int i, first_len, len;
switch (p->pid) {
case USB_TOKEN_OUT:
if (devep != 2)
goto fail;
for (i = 0; i < p->iov.niov; i++) {
iov = p->iov.iov + i;
qemu_chr_fe_write(s->cs, iov->iov_base, iov->iov_len);
}
p->actual_length = p->iov.size;
break;
case USB_TOKEN_IN:
if (devep != 1)
goto fail;
first_len = RECV_BUF - s->recv_ptr;
len = p->iov.size;
if (len <= 2) {
p->status = USB_RET_NAK;
break;
}
header[0] = 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;
header[1] = FTDI_BI;
usb_packet_copy(p, header, 2);
break;
} else {
header[1] = 0;
}
len -= 2;
if (len > s->recv_used)
len = s->recv_used;
if (!len) {
p->status = USB_RET_NAK;
break;
}
if (first_len > len)
first_len = len;
usb_packet_copy(p, header, 2);
usb_packet_copy(p, s->recv_buf + s->recv_ptr, first_len);
if (len > first_len)
usb_packet_copy(p, s->recv_buf, len - first_len);
s->recv_used -= len;
s->recv_ptr = (s->recv_ptr + len) % RECV_BUF;
break;
default:
DPRINTF("Bad token\n");
fail:
p->status = USB_RET_STALL;
break;
}
}
| true | qemu | 6ab3fc32ea640026726bc5f9f4db622d0954fb8a | static void usb_serial_handle_data(USBDevice *dev, USBPacket *p)
{
USBSerialState *s = (USBSerialState *)dev;
uint8_t devep = p->ep->nr;
struct iovec *iov;
uint8_t header[2];
int i, first_len, len;
switch (p->pid) {
case USB_TOKEN_OUT:
if (devep != 2)
goto fail;
for (i = 0; i < p->iov.niov; i++) {
iov = p->iov.iov + i;
qemu_chr_fe_write(s->cs, iov->iov_base, iov->iov_len);
}
p->actual_length = p->iov.size;
break;
case USB_TOKEN_IN:
if (devep != 1)
goto fail;
first_len = RECV_BUF - s->recv_ptr;
len = p->iov.size;
if (len <= 2) {
p->status = USB_RET_NAK;
break;
}
header[0] = usb_get_modem_lines(s) | 1;
if (s->event_trigger && s->event_trigger & FTDI_BI) {
s->event_trigger &= ~FTDI_BI;
header[1] = FTDI_BI;
usb_packet_copy(p, header, 2);
break;
} else {
header[1] = 0;
}
len -= 2;
if (len > s->recv_used)
len = s->recv_used;
if (!len) {
p->status = USB_RET_NAK;
break;
}
if (first_len > len)
first_len = len;
usb_packet_copy(p, header, 2);
usb_packet_copy(p, s->recv_buf + s->recv_ptr, first_len);
if (len > first_len)
usb_packet_copy(p, s->recv_buf, len - first_len);
s->recv_used -= len;
s->recv_ptr = (s->recv_ptr + len) % RECV_BUF;
break;
default:
DPRINTF("Bad token\n");
fail:
p->status = USB_RET_STALL;
break;
}
}
| {
"code": [
" qemu_chr_fe_write(s->cs, iov->iov_base, iov->iov_len);"
],
"line_no": [
29
]
} | static void FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)
{
USBSerialState *s = (USBSerialState *)VAR_0;
uint8_t devep = VAR_1->ep->nr;
struct iovec *VAR_2;
uint8_t header[2];
int VAR_3, VAR_4, VAR_5;
switch (VAR_1->pid) {
case USB_TOKEN_OUT:
if (devep != 2)
goto fail;
for (VAR_3 = 0; VAR_3 < VAR_1->VAR_2.niov; VAR_3++) {
VAR_2 = VAR_1->VAR_2.VAR_2 + VAR_3;
qemu_chr_fe_write(s->cs, VAR_2->iov_base, VAR_2->iov_len);
}
VAR_1->actual_length = VAR_1->VAR_2.size;
break;
case USB_TOKEN_IN:
if (devep != 1)
goto fail;
VAR_4 = RECV_BUF - s->recv_ptr;
VAR_5 = VAR_1->VAR_2.size;
if (VAR_5 <= 2) {
VAR_1->status = USB_RET_NAK;
break;
}
header[0] = usb_get_modem_lines(s) | 1;
if (s->event_trigger && s->event_trigger & FTDI_BI) {
s->event_trigger &= ~FTDI_BI;
header[1] = FTDI_BI;
usb_packet_copy(VAR_1, header, 2);
break;
} else {
header[1] = 0;
}
VAR_5 -= 2;
if (VAR_5 > s->recv_used)
VAR_5 = s->recv_used;
if (!VAR_5) {
VAR_1->status = USB_RET_NAK;
break;
}
if (VAR_4 > VAR_5)
VAR_4 = VAR_5;
usb_packet_copy(VAR_1, header, 2);
usb_packet_copy(VAR_1, s->recv_buf + s->recv_ptr, VAR_4);
if (VAR_5 > VAR_4)
usb_packet_copy(VAR_1, s->recv_buf, VAR_5 - VAR_4);
s->recv_used -= VAR_5;
s->recv_ptr = (s->recv_ptr + VAR_5) % RECV_BUF;
break;
default:
DPRINTF("Bad token\n");
fail:
VAR_1->status = USB_RET_STALL;
break;
}
}
| [
"static void FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)\n{",
"USBSerialState *s = (USBSerialState *)VAR_0;",
"uint8_t devep = VAR_1->ep->nr;",
"struct iovec *VAR_2;",
"uint8_t header[2];",
"int VAR_3, VAR_4, VAR_5;",
"switch (VAR_1->pid) {",
"case USB_TOKEN_OUT:\nif (devep != 2)\ngoto fail;",
"for (VAR_3 = 0; VAR_3 < VAR_1->VAR_2.niov; VAR_3++) {",
"VAR_2 = VAR_1->VAR_2.VAR_2 + VAR_3;",
"qemu_chr_fe_write(s->cs, VAR_2->iov_base, VAR_2->iov_len);",
"}",
"VAR_1->actual_length = VAR_1->VAR_2.size;",
"break;",
"case USB_TOKEN_IN:\nif (devep != 1)\ngoto fail;",
"VAR_4 = RECV_BUF - s->recv_ptr;",
"VAR_5 = VAR_1->VAR_2.size;",
"if (VAR_5 <= 2) {",
"VAR_1->status = USB_RET_NAK;",
"break;",
"}",
"header[0] = usb_get_modem_lines(s) | 1;",
"if (s->event_trigger && s->event_trigger & FTDI_BI) {",
"s->event_trigger &= ~FTDI_BI;",
"header[1] = FTDI_BI;",
"usb_packet_copy(VAR_1, header, 2);",
"break;",
"} else {",
"header[1] = 0;",
"}",
"VAR_5 -= 2;",
"if (VAR_5 > s->recv_used)\nVAR_5 = s->recv_used;",
"if (!VAR_5) {",
"VAR_1->status = USB_RET_NAK;",
"break;",
"}",
"if (VAR_4 > VAR_5)\nVAR_4 = VAR_5;",
"usb_packet_copy(VAR_1, header, 2);",
"usb_packet_copy(VAR_1, s->recv_buf + s->recv_ptr, VAR_4);",
"if (VAR_5 > VAR_4)\nusb_packet_copy(VAR_1, s->recv_buf, VAR_5 - VAR_4);",
"s->recv_used -= VAR_5;",
"s->recv_ptr = (s->recv_ptr + VAR_5) % RECV_BUF;",
"break;",
"default:\nDPRINTF(\"Bad token\\n\");",
"fail:\nVAR_1->status = USB_RET_STALL;",
"break;",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19,
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39,
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93,
95
],
[
97
],
[
99
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
113,
115
],
[
117,
119
],
[
121
],
[
123
],
[
125
]
]
|
14,317 | int ff_hevc_decode_nal_pps(HEVCContext *s)
{
GetBitContext *gb = &s->HEVClc.gb;
HEVCSPS *sps = NULL;
int pic_area_in_ctbs, pic_area_in_min_cbs, pic_area_in_min_tbs;
int log2_diff_ctb_min_tb_size;
int i, j, x, y, ctb_addr_rs, tile_id;
int ret = 0;
int pps_id = 0;
AVBufferRef *pps_buf;
HEVCPPS *pps = av_mallocz(sizeof(*pps));
if (!pps)
return AVERROR(ENOMEM);
pps_buf = av_buffer_create((uint8_t *)pps, sizeof(*pps),
hevc_pps_free, NULL, 0);
if (!pps_buf) {
av_freep(&pps);
return AVERROR(ENOMEM);
}
av_log(s->avctx, AV_LOG_DEBUG, "Decoding PPS\n");
// Default values
pps->loop_filter_across_tiles_enabled_flag = 1;
pps->num_tile_columns = 1;
pps->num_tile_rows = 1;
pps->uniform_spacing_flag = 1;
pps->disable_dbf = 0;
pps->beta_offset = 0;
pps->tc_offset = 0;
// Coded parameters
pps_id = get_ue_golomb_long(gb);
if (pps_id >= MAX_PPS_COUNT) {
av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id);
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->sps_id = get_ue_golomb_long(gb);
if (pps->sps_id >= MAX_SPS_COUNT) {
av_log(s->avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", pps->sps_id);
ret = AVERROR_INVALIDDATA;
goto err;
}
if (!s->sps_list[pps->sps_id]) {
av_log(s->avctx, AV_LOG_ERROR, "SPS %u does not exist.\n", pps->sps_id);
ret = AVERROR_INVALIDDATA;
goto err;
}
sps = (HEVCSPS *)s->sps_list[pps->sps_id]->data;
pps->dependent_slice_segments_enabled_flag = get_bits1(gb);
pps->output_flag_present_flag = get_bits1(gb);
pps->num_extra_slice_header_bits = get_bits(gb, 3);
pps->sign_data_hiding_flag = get_bits1(gb);
pps->cabac_init_present_flag = get_bits1(gb);
pps->num_ref_idx_l0_default_active = get_ue_golomb_long(gb) + 1;
pps->num_ref_idx_l1_default_active = get_ue_golomb_long(gb) + 1;
pps->pic_init_qp_minus26 = get_se_golomb(gb);
pps->constrained_intra_pred_flag = get_bits1(gb);
pps->transform_skip_enabled_flag = get_bits1(gb);
pps->cu_qp_delta_enabled_flag = get_bits1(gb);
pps->diff_cu_qp_delta_depth = 0;
if (pps->cu_qp_delta_enabled_flag)
pps->diff_cu_qp_delta_depth = get_ue_golomb_long(gb);
pps->cb_qp_offset = get_se_golomb(gb);
if (pps->cb_qp_offset < -12 || pps->cb_qp_offset > 12) {
av_log(s->avctx, AV_LOG_ERROR, "pps_cb_qp_offset out of range: %d\n",
pps->cb_qp_offset);
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->cr_qp_offset = get_se_golomb(gb);
if (pps->cr_qp_offset < -12 || pps->cr_qp_offset > 12) {
av_log(s->avctx, AV_LOG_ERROR, "pps_cr_qp_offset out of range: %d\n",
pps->cr_qp_offset);
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->pic_slice_level_chroma_qp_offsets_present_flag = get_bits1(gb);
pps->weighted_pred_flag = get_bits1(gb);
pps->weighted_bipred_flag = get_bits1(gb);
pps->transquant_bypass_enable_flag = get_bits1(gb);
pps->tiles_enabled_flag = get_bits1(gb);
pps->entropy_coding_sync_enabled_flag = get_bits1(gb);
if (pps->tiles_enabled_flag) {
pps->num_tile_columns = get_ue_golomb_long(gb) + 1;
pps->num_tile_rows = get_ue_golomb_long(gb) + 1;
if (pps->num_tile_columns == 0 ||
pps->num_tile_columns >= sps->width) {
av_log(s->avctx, AV_LOG_ERROR, "num_tile_columns_minus1 out of range: %d\n",
pps->num_tile_columns - 1);
ret = AVERROR_INVALIDDATA;
goto err;
}
if (pps->num_tile_rows == 0 ||
pps->num_tile_rows >= sps->height) {
av_log(s->avctx, AV_LOG_ERROR, "num_tile_rows_minus1 out of range: %d\n",
pps->num_tile_rows - 1);
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->column_width = av_malloc_array(pps->num_tile_columns, sizeof(*pps->column_width));
pps->row_height = av_malloc_array(pps->num_tile_rows, sizeof(*pps->row_height));
if (!pps->column_width || !pps->row_height) {
ret = AVERROR(ENOMEM);
goto err;
}
pps->uniform_spacing_flag = get_bits1(gb);
if (!pps->uniform_spacing_flag) {
uint64_t sum = 0;
for (i = 0; i < pps->num_tile_columns - 1; i++) {
pps->column_width[i] = get_ue_golomb_long(gb) + 1;
sum += pps->column_width[i];
}
if (sum >= sps->ctb_width) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid tile widths.\n");
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->column_width[pps->num_tile_columns - 1] = sps->ctb_width - sum;
sum = 0;
for (i = 0; i < pps->num_tile_rows - 1; i++) {
pps->row_height[i] = get_ue_golomb_long(gb) + 1;
sum += pps->row_height[i];
}
if (sum >= sps->ctb_height) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid tile heights.\n");
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->row_height[pps->num_tile_rows - 1] = sps->ctb_height - sum;
}
pps->loop_filter_across_tiles_enabled_flag = get_bits1(gb);
}
pps->seq_loop_filter_across_slices_enabled_flag = get_bits1(gb);
pps->deblocking_filter_control_present_flag = get_bits1(gb);
if (pps->deblocking_filter_control_present_flag) {
pps->deblocking_filter_override_enabled_flag = get_bits1(gb);
pps->disable_dbf = get_bits1(gb);
if (!pps->disable_dbf) {
pps->beta_offset = get_se_golomb(gb) * 2;
pps->tc_offset = get_se_golomb(gb) * 2;
if (pps->beta_offset/2 < -6 || pps->beta_offset/2 > 6) {
av_log(s->avctx, AV_LOG_ERROR, "pps_beta_offset_div2 out of range: %d\n",
pps->beta_offset/2);
ret = AVERROR_INVALIDDATA;
goto err;
}
if (pps->tc_offset/2 < -6 || pps->tc_offset/2 > 6) {
av_log(s->avctx, AV_LOG_ERROR, "pps_tc_offset_div2 out of range: %d\n",
pps->tc_offset/2);
ret = AVERROR_INVALIDDATA;
goto err;
}
}
}
pps->scaling_list_data_present_flag = get_bits1(gb);
if (pps->scaling_list_data_present_flag) {
set_default_scaling_list_data(&pps->scaling_list);
ret = scaling_list_data(s, &pps->scaling_list);
if (ret < 0)
goto err;
}
pps->lists_modification_present_flag = get_bits1(gb);
pps->log2_parallel_merge_level = get_ue_golomb_long(gb) + 2;
if (pps->log2_parallel_merge_level > sps->log2_ctb_size) {
av_log(s->avctx, AV_LOG_ERROR, "log2_parallel_merge_level_minus2 out of range: %d\n",
pps->log2_parallel_merge_level - 2);
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->slice_header_extension_present_flag = get_bits1(gb);
skip_bits1(gb); // pps_extension_flag
// Inferred parameters
pps->col_bd = av_malloc_array(pps->num_tile_columns + 1, sizeof(*pps->col_bd));
pps->row_bd = av_malloc_array(pps->num_tile_rows + 1, sizeof(*pps->row_bd));
pps->col_idxX = av_malloc_array(sps->ctb_width, sizeof(*pps->col_idxX));
if (!pps->col_bd || !pps->row_bd || !pps->col_idxX) {
ret = AVERROR(ENOMEM);
goto err;
}
if (pps->uniform_spacing_flag) {
if (!pps->column_width) {
pps->column_width = av_malloc_array(pps->num_tile_columns, sizeof(*pps->column_width));
pps->row_height = av_malloc_array(pps->num_tile_rows, sizeof(*pps->row_height));
}
if (!pps->column_width || !pps->row_height) {
ret = AVERROR(ENOMEM);
goto err;
}
for (i = 0; i < pps->num_tile_columns; i++) {
pps->column_width[i] = ((i + 1) * sps->ctb_width) / pps->num_tile_columns -
(i * sps->ctb_width) / pps->num_tile_columns;
}
for (i = 0; i < pps->num_tile_rows; i++) {
pps->row_height[i] = ((i + 1) * sps->ctb_height) / pps->num_tile_rows -
(i * sps->ctb_height) / pps->num_tile_rows;
}
}
pps->col_bd[0] = 0;
for (i = 0; i < pps->num_tile_columns; i++)
pps->col_bd[i + 1] = pps->col_bd[i] + pps->column_width[i];
pps->row_bd[0] = 0;
for (i = 0; i < pps->num_tile_rows; i++)
pps->row_bd[i + 1] = pps->row_bd[i] + pps->row_height[i];
for (i = 0, j = 0; i < sps->ctb_width; i++) {
if (i > pps->col_bd[j])
j++;
pps->col_idxX[i] = j;
}
/**
* 6.5
*/
pic_area_in_ctbs = sps->ctb_width * sps->ctb_height;
pic_area_in_min_cbs = sps->min_cb_width * sps->min_cb_height;
pic_area_in_min_tbs = sps->min_tb_width * sps->min_tb_height;
pps->ctb_addr_rs_to_ts = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->ctb_addr_rs_to_ts));
pps->ctb_addr_ts_to_rs = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->ctb_addr_ts_to_rs));
pps->tile_id = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->tile_id));
pps->min_cb_addr_zs = av_malloc_array(pic_area_in_min_cbs, sizeof(*pps->min_cb_addr_zs));
pps->min_tb_addr_zs = av_malloc_array(pic_area_in_min_tbs, sizeof(*pps->min_tb_addr_zs));
if (!pps->ctb_addr_rs_to_ts || !pps->ctb_addr_ts_to_rs ||
!pps->tile_id || !pps->min_cb_addr_zs || !pps->min_tb_addr_zs) {
ret = AVERROR(ENOMEM);
goto err;
}
for (ctb_addr_rs = 0; ctb_addr_rs < pic_area_in_ctbs; ctb_addr_rs++) {
int tb_x = ctb_addr_rs % sps->ctb_width;
int tb_y = ctb_addr_rs / sps->ctb_width;
int tile_x = 0;
int tile_y = 0;
int val = 0;
for (i = 0; i < pps->num_tile_columns; i++) {
if (tb_x < pps->col_bd[i + 1]) {
tile_x = i;
break;
}
}
for (i = 0; i < pps->num_tile_rows; i++) {
if (tb_y < pps->row_bd[i + 1]) {
tile_y = i;
break;
}
}
for (i = 0; i < tile_x; i++)
val += pps->row_height[tile_y] * pps->column_width[i];
for (i = 0; i < tile_y; i++)
val += sps->ctb_width * pps->row_height[i];
val += (tb_y - pps->row_bd[tile_y]) * pps->column_width[tile_x] +
tb_x - pps->col_bd[tile_x];
pps->ctb_addr_rs_to_ts[ctb_addr_rs] = val;
pps->ctb_addr_ts_to_rs[val] = ctb_addr_rs;
}
for (j = 0, tile_id = 0; j < pps->num_tile_rows; j++)
for (i = 0; i < pps->num_tile_columns; i++, tile_id++)
for (y = pps->row_bd[j]; y < pps->row_bd[j + 1]; y++)
for (x = pps->col_bd[i]; x < pps->col_bd[i + 1]; x++)
pps->tile_id[pps->ctb_addr_rs_to_ts[y * sps->ctb_width + x]] = tile_id;
pps->tile_pos_rs = av_malloc_array(tile_id, sizeof(*pps->tile_pos_rs));
if (!pps->tile_pos_rs) {
ret = AVERROR(ENOMEM);
goto err;
}
for (j = 0; j < pps->num_tile_rows; j++)
for (i = 0; i < pps->num_tile_columns; i++)
pps->tile_pos_rs[j * pps->num_tile_columns + i] = pps->row_bd[j] * sps->ctb_width + pps->col_bd[i];
for (y = 0; y < sps->min_cb_height; y++) {
for (x = 0; x < sps->min_cb_width; x++) {
int tb_x = x >> sps->log2_diff_max_min_coding_block_size;
int tb_y = y >> sps->log2_diff_max_min_coding_block_size;
int ctb_addr_rs = sps->ctb_width * tb_y + tb_x;
int val = pps->ctb_addr_rs_to_ts[ctb_addr_rs] <<
(sps->log2_diff_max_min_coding_block_size * 2);
for (i = 0; i < sps->log2_diff_max_min_coding_block_size; i++) {
int m = 1 << i;
val += (m & x ? m * m : 0) + (m & y ? 2 * m * m : 0);
}
pps->min_cb_addr_zs[y * sps->min_cb_width + x] = val;
}
}
log2_diff_ctb_min_tb_size = sps->log2_ctb_size - sps->log2_min_tb_size;
for (y = 0; y < sps->min_tb_height; y++) {
for (x = 0; x < sps->min_tb_width; x++) {
int tb_x = x >> log2_diff_ctb_min_tb_size;
int tb_y = y >> log2_diff_ctb_min_tb_size;
int ctb_addr_rs = sps->ctb_width * tb_y + tb_x;
int val = pps->ctb_addr_rs_to_ts[ctb_addr_rs] <<
(log2_diff_ctb_min_tb_size * 2);
for (i = 0; i < log2_diff_ctb_min_tb_size; i++) {
int m = 1 << i;
val += (m & x ? m * m : 0) + (m & y ? 2 * m * m : 0);
}
pps->min_tb_addr_zs[y * sps->min_tb_width + x] = val;
}
}
av_buffer_unref(&s->pps_list[pps_id]);
s->pps_list[pps_id] = pps_buf;
return 0;
err:
av_buffer_unref(&pps_buf);
return ret;
}
| true | FFmpeg | 4d33873c2990b8d6096f60fef384f0efc4482b55 | int ff_hevc_decode_nal_pps(HEVCContext *s)
{
GetBitContext *gb = &s->HEVClc.gb;
HEVCSPS *sps = NULL;
int pic_area_in_ctbs, pic_area_in_min_cbs, pic_area_in_min_tbs;
int log2_diff_ctb_min_tb_size;
int i, j, x, y, ctb_addr_rs, tile_id;
int ret = 0;
int pps_id = 0;
AVBufferRef *pps_buf;
HEVCPPS *pps = av_mallocz(sizeof(*pps));
if (!pps)
return AVERROR(ENOMEM);
pps_buf = av_buffer_create((uint8_t *)pps, sizeof(*pps),
hevc_pps_free, NULL, 0);
if (!pps_buf) {
av_freep(&pps);
return AVERROR(ENOMEM);
}
av_log(s->avctx, AV_LOG_DEBUG, "Decoding PPS\n");
pps->loop_filter_across_tiles_enabled_flag = 1;
pps->num_tile_columns = 1;
pps->num_tile_rows = 1;
pps->uniform_spacing_flag = 1;
pps->disable_dbf = 0;
pps->beta_offset = 0;
pps->tc_offset = 0;
pps_id = get_ue_golomb_long(gb);
if (pps_id >= MAX_PPS_COUNT) {
av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id);
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->sps_id = get_ue_golomb_long(gb);
if (pps->sps_id >= MAX_SPS_COUNT) {
av_log(s->avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", pps->sps_id);
ret = AVERROR_INVALIDDATA;
goto err;
}
if (!s->sps_list[pps->sps_id]) {
av_log(s->avctx, AV_LOG_ERROR, "SPS %u does not exist.\n", pps->sps_id);
ret = AVERROR_INVALIDDATA;
goto err;
}
sps = (HEVCSPS *)s->sps_list[pps->sps_id]->data;
pps->dependent_slice_segments_enabled_flag = get_bits1(gb);
pps->output_flag_present_flag = get_bits1(gb);
pps->num_extra_slice_header_bits = get_bits(gb, 3);
pps->sign_data_hiding_flag = get_bits1(gb);
pps->cabac_init_present_flag = get_bits1(gb);
pps->num_ref_idx_l0_default_active = get_ue_golomb_long(gb) + 1;
pps->num_ref_idx_l1_default_active = get_ue_golomb_long(gb) + 1;
pps->pic_init_qp_minus26 = get_se_golomb(gb);
pps->constrained_intra_pred_flag = get_bits1(gb);
pps->transform_skip_enabled_flag = get_bits1(gb);
pps->cu_qp_delta_enabled_flag = get_bits1(gb);
pps->diff_cu_qp_delta_depth = 0;
if (pps->cu_qp_delta_enabled_flag)
pps->diff_cu_qp_delta_depth = get_ue_golomb_long(gb);
pps->cb_qp_offset = get_se_golomb(gb);
if (pps->cb_qp_offset < -12 || pps->cb_qp_offset > 12) {
av_log(s->avctx, AV_LOG_ERROR, "pps_cb_qp_offset out of range: %d\n",
pps->cb_qp_offset);
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->cr_qp_offset = get_se_golomb(gb);
if (pps->cr_qp_offset < -12 || pps->cr_qp_offset > 12) {
av_log(s->avctx, AV_LOG_ERROR, "pps_cr_qp_offset out of range: %d\n",
pps->cr_qp_offset);
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->pic_slice_level_chroma_qp_offsets_present_flag = get_bits1(gb);
pps->weighted_pred_flag = get_bits1(gb);
pps->weighted_bipred_flag = get_bits1(gb);
pps->transquant_bypass_enable_flag = get_bits1(gb);
pps->tiles_enabled_flag = get_bits1(gb);
pps->entropy_coding_sync_enabled_flag = get_bits1(gb);
if (pps->tiles_enabled_flag) {
pps->num_tile_columns = get_ue_golomb_long(gb) + 1;
pps->num_tile_rows = get_ue_golomb_long(gb) + 1;
if (pps->num_tile_columns == 0 ||
pps->num_tile_columns >= sps->width) {
av_log(s->avctx, AV_LOG_ERROR, "num_tile_columns_minus1 out of range: %d\n",
pps->num_tile_columns - 1);
ret = AVERROR_INVALIDDATA;
goto err;
}
if (pps->num_tile_rows == 0 ||
pps->num_tile_rows >= sps->height) {
av_log(s->avctx, AV_LOG_ERROR, "num_tile_rows_minus1 out of range: %d\n",
pps->num_tile_rows - 1);
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->column_width = av_malloc_array(pps->num_tile_columns, sizeof(*pps->column_width));
pps->row_height = av_malloc_array(pps->num_tile_rows, sizeof(*pps->row_height));
if (!pps->column_width || !pps->row_height) {
ret = AVERROR(ENOMEM);
goto err;
}
pps->uniform_spacing_flag = get_bits1(gb);
if (!pps->uniform_spacing_flag) {
uint64_t sum = 0;
for (i = 0; i < pps->num_tile_columns - 1; i++) {
pps->column_width[i] = get_ue_golomb_long(gb) + 1;
sum += pps->column_width[i];
}
if (sum >= sps->ctb_width) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid tile widths.\n");
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->column_width[pps->num_tile_columns - 1] = sps->ctb_width - sum;
sum = 0;
for (i = 0; i < pps->num_tile_rows - 1; i++) {
pps->row_height[i] = get_ue_golomb_long(gb) + 1;
sum += pps->row_height[i];
}
if (sum >= sps->ctb_height) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid tile heights.\n");
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->row_height[pps->num_tile_rows - 1] = sps->ctb_height - sum;
}
pps->loop_filter_across_tiles_enabled_flag = get_bits1(gb);
}
pps->seq_loop_filter_across_slices_enabled_flag = get_bits1(gb);
pps->deblocking_filter_control_present_flag = get_bits1(gb);
if (pps->deblocking_filter_control_present_flag) {
pps->deblocking_filter_override_enabled_flag = get_bits1(gb);
pps->disable_dbf = get_bits1(gb);
if (!pps->disable_dbf) {
pps->beta_offset = get_se_golomb(gb) * 2;
pps->tc_offset = get_se_golomb(gb) * 2;
if (pps->beta_offset/2 < -6 || pps->beta_offset/2 > 6) {
av_log(s->avctx, AV_LOG_ERROR, "pps_beta_offset_div2 out of range: %d\n",
pps->beta_offset/2);
ret = AVERROR_INVALIDDATA;
goto err;
}
if (pps->tc_offset/2 < -6 || pps->tc_offset/2 > 6) {
av_log(s->avctx, AV_LOG_ERROR, "pps_tc_offset_div2 out of range: %d\n",
pps->tc_offset/2);
ret = AVERROR_INVALIDDATA;
goto err;
}
}
}
pps->scaling_list_data_present_flag = get_bits1(gb);
if (pps->scaling_list_data_present_flag) {
set_default_scaling_list_data(&pps->scaling_list);
ret = scaling_list_data(s, &pps->scaling_list);
if (ret < 0)
goto err;
}
pps->lists_modification_present_flag = get_bits1(gb);
pps->log2_parallel_merge_level = get_ue_golomb_long(gb) + 2;
if (pps->log2_parallel_merge_level > sps->log2_ctb_size) {
av_log(s->avctx, AV_LOG_ERROR, "log2_parallel_merge_level_minus2 out of range: %d\n",
pps->log2_parallel_merge_level - 2);
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->slice_header_extension_present_flag = get_bits1(gb);
skip_bits1(gb);
pps->col_bd = av_malloc_array(pps->num_tile_columns + 1, sizeof(*pps->col_bd));
pps->row_bd = av_malloc_array(pps->num_tile_rows + 1, sizeof(*pps->row_bd));
pps->col_idxX = av_malloc_array(sps->ctb_width, sizeof(*pps->col_idxX));
if (!pps->col_bd || !pps->row_bd || !pps->col_idxX) {
ret = AVERROR(ENOMEM);
goto err;
}
if (pps->uniform_spacing_flag) {
if (!pps->column_width) {
pps->column_width = av_malloc_array(pps->num_tile_columns, sizeof(*pps->column_width));
pps->row_height = av_malloc_array(pps->num_tile_rows, sizeof(*pps->row_height));
}
if (!pps->column_width || !pps->row_height) {
ret = AVERROR(ENOMEM);
goto err;
}
for (i = 0; i < pps->num_tile_columns; i++) {
pps->column_width[i] = ((i + 1) * sps->ctb_width) / pps->num_tile_columns -
(i * sps->ctb_width) / pps->num_tile_columns;
}
for (i = 0; i < pps->num_tile_rows; i++) {
pps->row_height[i] = ((i + 1) * sps->ctb_height) / pps->num_tile_rows -
(i * sps->ctb_height) / pps->num_tile_rows;
}
}
pps->col_bd[0] = 0;
for (i = 0; i < pps->num_tile_columns; i++)
pps->col_bd[i + 1] = pps->col_bd[i] + pps->column_width[i];
pps->row_bd[0] = 0;
for (i = 0; i < pps->num_tile_rows; i++)
pps->row_bd[i + 1] = pps->row_bd[i] + pps->row_height[i];
for (i = 0, j = 0; i < sps->ctb_width; i++) {
if (i > pps->col_bd[j])
j++;
pps->col_idxX[i] = j;
}
pic_area_in_ctbs = sps->ctb_width * sps->ctb_height;
pic_area_in_min_cbs = sps->min_cb_width * sps->min_cb_height;
pic_area_in_min_tbs = sps->min_tb_width * sps->min_tb_height;
pps->ctb_addr_rs_to_ts = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->ctb_addr_rs_to_ts));
pps->ctb_addr_ts_to_rs = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->ctb_addr_ts_to_rs));
pps->tile_id = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->tile_id));
pps->min_cb_addr_zs = av_malloc_array(pic_area_in_min_cbs, sizeof(*pps->min_cb_addr_zs));
pps->min_tb_addr_zs = av_malloc_array(pic_area_in_min_tbs, sizeof(*pps->min_tb_addr_zs));
if (!pps->ctb_addr_rs_to_ts || !pps->ctb_addr_ts_to_rs ||
!pps->tile_id || !pps->min_cb_addr_zs || !pps->min_tb_addr_zs) {
ret = AVERROR(ENOMEM);
goto err;
}
for (ctb_addr_rs = 0; ctb_addr_rs < pic_area_in_ctbs; ctb_addr_rs++) {
int tb_x = ctb_addr_rs % sps->ctb_width;
int tb_y = ctb_addr_rs / sps->ctb_width;
int tile_x = 0;
int tile_y = 0;
int val = 0;
for (i = 0; i < pps->num_tile_columns; i++) {
if (tb_x < pps->col_bd[i + 1]) {
tile_x = i;
break;
}
}
for (i = 0; i < pps->num_tile_rows; i++) {
if (tb_y < pps->row_bd[i + 1]) {
tile_y = i;
break;
}
}
for (i = 0; i < tile_x; i++)
val += pps->row_height[tile_y] * pps->column_width[i];
for (i = 0; i < tile_y; i++)
val += sps->ctb_width * pps->row_height[i];
val += (tb_y - pps->row_bd[tile_y]) * pps->column_width[tile_x] +
tb_x - pps->col_bd[tile_x];
pps->ctb_addr_rs_to_ts[ctb_addr_rs] = val;
pps->ctb_addr_ts_to_rs[val] = ctb_addr_rs;
}
for (j = 0, tile_id = 0; j < pps->num_tile_rows; j++)
for (i = 0; i < pps->num_tile_columns; i++, tile_id++)
for (y = pps->row_bd[j]; y < pps->row_bd[j + 1]; y++)
for (x = pps->col_bd[i]; x < pps->col_bd[i + 1]; x++)
pps->tile_id[pps->ctb_addr_rs_to_ts[y * sps->ctb_width + x]] = tile_id;
pps->tile_pos_rs = av_malloc_array(tile_id, sizeof(*pps->tile_pos_rs));
if (!pps->tile_pos_rs) {
ret = AVERROR(ENOMEM);
goto err;
}
for (j = 0; j < pps->num_tile_rows; j++)
for (i = 0; i < pps->num_tile_columns; i++)
pps->tile_pos_rs[j * pps->num_tile_columns + i] = pps->row_bd[j] * sps->ctb_width + pps->col_bd[i];
for (y = 0; y < sps->min_cb_height; y++) {
for (x = 0; x < sps->min_cb_width; x++) {
int tb_x = x >> sps->log2_diff_max_min_coding_block_size;
int tb_y = y >> sps->log2_diff_max_min_coding_block_size;
int ctb_addr_rs = sps->ctb_width * tb_y + tb_x;
int val = pps->ctb_addr_rs_to_ts[ctb_addr_rs] <<
(sps->log2_diff_max_min_coding_block_size * 2);
for (i = 0; i < sps->log2_diff_max_min_coding_block_size; i++) {
int m = 1 << i;
val += (m & x ? m * m : 0) + (m & y ? 2 * m * m : 0);
}
pps->min_cb_addr_zs[y * sps->min_cb_width + x] = val;
}
}
log2_diff_ctb_min_tb_size = sps->log2_ctb_size - sps->log2_min_tb_size;
for (y = 0; y < sps->min_tb_height; y++) {
for (x = 0; x < sps->min_tb_width; x++) {
int tb_x = x >> log2_diff_ctb_min_tb_size;
int tb_y = y >> log2_diff_ctb_min_tb_size;
int ctb_addr_rs = sps->ctb_width * tb_y + tb_x;
int val = pps->ctb_addr_rs_to_ts[ctb_addr_rs] <<
(log2_diff_ctb_min_tb_size * 2);
for (i = 0; i < log2_diff_ctb_min_tb_size; i++) {
int m = 1 << i;
val += (m & x ? m * m : 0) + (m & y ? 2 * m * m : 0);
}
pps->min_tb_addr_zs[y * sps->min_tb_width + x] = val;
}
}
av_buffer_unref(&s->pps_list[pps_id]);
s->pps_list[pps_id] = pps_buf;
return 0;
err:
av_buffer_unref(&pps_buf);
return ret;
}
| {
"code": [
" int ret = 0;",
" int ret = 0;",
" int pps_id = 0;"
],
"line_no": [
15,
15,
17
]
} | int FUNC_0(HEVCContext *VAR_0)
{
GetBitContext *gb = &VAR_0->HEVClc.gb;
HEVCSPS *sps = NULL;
int VAR_1, VAR_2, VAR_3;
int VAR_4;
int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;
int VAR_11 = 0;
int VAR_12 = 0;
AVBufferRef *pps_buf;
HEVCPPS *pps = av_mallocz(sizeof(*pps));
if (!pps)
return AVERROR(ENOMEM);
pps_buf = av_buffer_create((uint8_t *)pps, sizeof(*pps),
hevc_pps_free, NULL, 0);
if (!pps_buf) {
av_freep(&pps);
return AVERROR(ENOMEM);
}
av_log(VAR_0->avctx, AV_LOG_DEBUG, "Decoding PPS\n");
pps->loop_filter_across_tiles_enabled_flag = 1;
pps->num_tile_columns = 1;
pps->num_tile_rows = 1;
pps->uniform_spacing_flag = 1;
pps->disable_dbf = 0;
pps->beta_offset = 0;
pps->tc_offset = 0;
VAR_12 = get_ue_golomb_long(gb);
if (VAR_12 >= MAX_PPS_COUNT) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", VAR_12);
VAR_11 = AVERROR_INVALIDDATA;
goto err;
}
pps->sps_id = get_ue_golomb_long(gb);
if (pps->sps_id >= MAX_SPS_COUNT) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", pps->sps_id);
VAR_11 = AVERROR_INVALIDDATA;
goto err;
}
if (!VAR_0->sps_list[pps->sps_id]) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "SPS %u does not exist.\n", pps->sps_id);
VAR_11 = AVERROR_INVALIDDATA;
goto err;
}
sps = (HEVCSPS *)VAR_0->sps_list[pps->sps_id]->data;
pps->dependent_slice_segments_enabled_flag = get_bits1(gb);
pps->output_flag_present_flag = get_bits1(gb);
pps->num_extra_slice_header_bits = get_bits(gb, 3);
pps->sign_data_hiding_flag = get_bits1(gb);
pps->cabac_init_present_flag = get_bits1(gb);
pps->num_ref_idx_l0_default_active = get_ue_golomb_long(gb) + 1;
pps->num_ref_idx_l1_default_active = get_ue_golomb_long(gb) + 1;
pps->pic_init_qp_minus26 = get_se_golomb(gb);
pps->constrained_intra_pred_flag = get_bits1(gb);
pps->transform_skip_enabled_flag = get_bits1(gb);
pps->cu_qp_delta_enabled_flag = get_bits1(gb);
pps->diff_cu_qp_delta_depth = 0;
if (pps->cu_qp_delta_enabled_flag)
pps->diff_cu_qp_delta_depth = get_ue_golomb_long(gb);
pps->cb_qp_offset = get_se_golomb(gb);
if (pps->cb_qp_offset < -12 || pps->cb_qp_offset > 12) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "pps_cb_qp_offset out of range: %d\n",
pps->cb_qp_offset);
VAR_11 = AVERROR_INVALIDDATA;
goto err;
}
pps->cr_qp_offset = get_se_golomb(gb);
if (pps->cr_qp_offset < -12 || pps->cr_qp_offset > 12) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "pps_cr_qp_offset out of range: %d\n",
pps->cr_qp_offset);
VAR_11 = AVERROR_INVALIDDATA;
goto err;
}
pps->pic_slice_level_chroma_qp_offsets_present_flag = get_bits1(gb);
pps->weighted_pred_flag = get_bits1(gb);
pps->weighted_bipred_flag = get_bits1(gb);
pps->transquant_bypass_enable_flag = get_bits1(gb);
pps->tiles_enabled_flag = get_bits1(gb);
pps->entropy_coding_sync_enabled_flag = get_bits1(gb);
if (pps->tiles_enabled_flag) {
pps->num_tile_columns = get_ue_golomb_long(gb) + 1;
pps->num_tile_rows = get_ue_golomb_long(gb) + 1;
if (pps->num_tile_columns == 0 ||
pps->num_tile_columns >= sps->width) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "num_tile_columns_minus1 out of range: %d\n",
pps->num_tile_columns - 1);
VAR_11 = AVERROR_INVALIDDATA;
goto err;
}
if (pps->num_tile_rows == 0 ||
pps->num_tile_rows >= sps->height) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "num_tile_rows_minus1 out of range: %d\n",
pps->num_tile_rows - 1);
VAR_11 = AVERROR_INVALIDDATA;
goto err;
}
pps->column_width = av_malloc_array(pps->num_tile_columns, sizeof(*pps->column_width));
pps->row_height = av_malloc_array(pps->num_tile_rows, sizeof(*pps->row_height));
if (!pps->column_width || !pps->row_height) {
VAR_11 = AVERROR(ENOMEM);
goto err;
}
pps->uniform_spacing_flag = get_bits1(gb);
if (!pps->uniform_spacing_flag) {
uint64_t sum = 0;
for (VAR_5 = 0; VAR_5 < pps->num_tile_columns - 1; VAR_5++) {
pps->column_width[VAR_5] = get_ue_golomb_long(gb) + 1;
sum += pps->column_width[VAR_5];
}
if (sum >= sps->ctb_width) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid tile widths.\n");
VAR_11 = AVERROR_INVALIDDATA;
goto err;
}
pps->column_width[pps->num_tile_columns - 1] = sps->ctb_width - sum;
sum = 0;
for (VAR_5 = 0; VAR_5 < pps->num_tile_rows - 1; VAR_5++) {
pps->row_height[VAR_5] = get_ue_golomb_long(gb) + 1;
sum += pps->row_height[VAR_5];
}
if (sum >= sps->ctb_height) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid tile heights.\n");
VAR_11 = AVERROR_INVALIDDATA;
goto err;
}
pps->row_height[pps->num_tile_rows - 1] = sps->ctb_height - sum;
}
pps->loop_filter_across_tiles_enabled_flag = get_bits1(gb);
}
pps->seq_loop_filter_across_slices_enabled_flag = get_bits1(gb);
pps->deblocking_filter_control_present_flag = get_bits1(gb);
if (pps->deblocking_filter_control_present_flag) {
pps->deblocking_filter_override_enabled_flag = get_bits1(gb);
pps->disable_dbf = get_bits1(gb);
if (!pps->disable_dbf) {
pps->beta_offset = get_se_golomb(gb) * 2;
pps->tc_offset = get_se_golomb(gb) * 2;
if (pps->beta_offset/2 < -6 || pps->beta_offset/2 > 6) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "pps_beta_offset_div2 out of range: %d\n",
pps->beta_offset/2);
VAR_11 = AVERROR_INVALIDDATA;
goto err;
}
if (pps->tc_offset/2 < -6 || pps->tc_offset/2 > 6) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "pps_tc_offset_div2 out of range: %d\n",
pps->tc_offset/2);
VAR_11 = AVERROR_INVALIDDATA;
goto err;
}
}
}
pps->scaling_list_data_present_flag = get_bits1(gb);
if (pps->scaling_list_data_present_flag) {
set_default_scaling_list_data(&pps->scaling_list);
VAR_11 = scaling_list_data(VAR_0, &pps->scaling_list);
if (VAR_11 < 0)
goto err;
}
pps->lists_modification_present_flag = get_bits1(gb);
pps->log2_parallel_merge_level = get_ue_golomb_long(gb) + 2;
if (pps->log2_parallel_merge_level > sps->log2_ctb_size) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "log2_parallel_merge_level_minus2 out of range: %d\n",
pps->log2_parallel_merge_level - 2);
VAR_11 = AVERROR_INVALIDDATA;
goto err;
}
pps->slice_header_extension_present_flag = get_bits1(gb);
skip_bits1(gb);
pps->col_bd = av_malloc_array(pps->num_tile_columns + 1, sizeof(*pps->col_bd));
pps->row_bd = av_malloc_array(pps->num_tile_rows + 1, sizeof(*pps->row_bd));
pps->col_idxX = av_malloc_array(sps->ctb_width, sizeof(*pps->col_idxX));
if (!pps->col_bd || !pps->row_bd || !pps->col_idxX) {
VAR_11 = AVERROR(ENOMEM);
goto err;
}
if (pps->uniform_spacing_flag) {
if (!pps->column_width) {
pps->column_width = av_malloc_array(pps->num_tile_columns, sizeof(*pps->column_width));
pps->row_height = av_malloc_array(pps->num_tile_rows, sizeof(*pps->row_height));
}
if (!pps->column_width || !pps->row_height) {
VAR_11 = AVERROR(ENOMEM);
goto err;
}
for (VAR_5 = 0; VAR_5 < pps->num_tile_columns; VAR_5++) {
pps->column_width[VAR_5] = ((VAR_5 + 1) * sps->ctb_width) / pps->num_tile_columns -
(VAR_5 * sps->ctb_width) / pps->num_tile_columns;
}
for (VAR_5 = 0; VAR_5 < pps->num_tile_rows; VAR_5++) {
pps->row_height[VAR_5] = ((VAR_5 + 1) * sps->ctb_height) / pps->num_tile_rows -
(VAR_5 * sps->ctb_height) / pps->num_tile_rows;
}
}
pps->col_bd[0] = 0;
for (VAR_5 = 0; VAR_5 < pps->num_tile_columns; VAR_5++)
pps->col_bd[VAR_5 + 1] = pps->col_bd[VAR_5] + pps->column_width[VAR_5];
pps->row_bd[0] = 0;
for (VAR_5 = 0; VAR_5 < pps->num_tile_rows; VAR_5++)
pps->row_bd[VAR_5 + 1] = pps->row_bd[VAR_5] + pps->row_height[VAR_5];
for (VAR_5 = 0, VAR_6 = 0; VAR_5 < sps->ctb_width; VAR_5++) {
if (VAR_5 > pps->col_bd[VAR_6])
VAR_6++;
pps->col_idxX[VAR_5] = VAR_6;
}
VAR_1 = sps->ctb_width * sps->ctb_height;
VAR_2 = sps->min_cb_width * sps->min_cb_height;
VAR_3 = sps->min_tb_width * sps->min_tb_height;
pps->ctb_addr_rs_to_ts = av_malloc_array(VAR_1, sizeof(*pps->ctb_addr_rs_to_ts));
pps->ctb_addr_ts_to_rs = av_malloc_array(VAR_1, sizeof(*pps->ctb_addr_ts_to_rs));
pps->VAR_10 = av_malloc_array(VAR_1, sizeof(*pps->VAR_10));
pps->min_cb_addr_zs = av_malloc_array(VAR_2, sizeof(*pps->min_cb_addr_zs));
pps->min_tb_addr_zs = av_malloc_array(VAR_3, sizeof(*pps->min_tb_addr_zs));
if (!pps->ctb_addr_rs_to_ts || !pps->ctb_addr_ts_to_rs ||
!pps->VAR_10 || !pps->min_cb_addr_zs || !pps->min_tb_addr_zs) {
VAR_11 = AVERROR(ENOMEM);
goto err;
}
for (VAR_9 = 0; VAR_9 < VAR_1; VAR_9++) {
int VAR_13 = VAR_9 % sps->ctb_width;
int VAR_14 = VAR_9 / sps->ctb_width;
int VAR_15 = 0;
int VAR_16 = 0;
int VAR_17 = 0;
for (VAR_5 = 0; VAR_5 < pps->num_tile_columns; VAR_5++) {
if (VAR_13 < pps->col_bd[VAR_5 + 1]) {
VAR_15 = VAR_5;
break;
}
}
for (VAR_5 = 0; VAR_5 < pps->num_tile_rows; VAR_5++) {
if (VAR_14 < pps->row_bd[VAR_5 + 1]) {
VAR_16 = VAR_5;
break;
}
}
for (VAR_5 = 0; VAR_5 < VAR_15; VAR_5++)
VAR_17 += pps->row_height[VAR_16] * pps->column_width[VAR_5];
for (VAR_5 = 0; VAR_5 < VAR_16; VAR_5++)
VAR_17 += sps->ctb_width * pps->row_height[VAR_5];
VAR_17 += (VAR_14 - pps->row_bd[VAR_16]) * pps->column_width[VAR_15] +
VAR_13 - pps->col_bd[VAR_15];
pps->ctb_addr_rs_to_ts[VAR_9] = VAR_17;
pps->ctb_addr_ts_to_rs[VAR_17] = VAR_9;
}
for (VAR_6 = 0, VAR_10 = 0; VAR_6 < pps->num_tile_rows; VAR_6++)
for (VAR_5 = 0; VAR_5 < pps->num_tile_columns; VAR_5++, VAR_10++)
for (VAR_8 = pps->row_bd[VAR_6]; VAR_8 < pps->row_bd[VAR_6 + 1]; VAR_8++)
for (VAR_7 = pps->col_bd[VAR_5]; VAR_7 < pps->col_bd[VAR_5 + 1]; VAR_7++)
pps->VAR_10[pps->ctb_addr_rs_to_ts[VAR_8 * sps->ctb_width + VAR_7]] = VAR_10;
pps->tile_pos_rs = av_malloc_array(VAR_10, sizeof(*pps->tile_pos_rs));
if (!pps->tile_pos_rs) {
VAR_11 = AVERROR(ENOMEM);
goto err;
}
for (VAR_6 = 0; VAR_6 < pps->num_tile_rows; VAR_6++)
for (VAR_5 = 0; VAR_5 < pps->num_tile_columns; VAR_5++)
pps->tile_pos_rs[VAR_6 * pps->num_tile_columns + VAR_5] = pps->row_bd[VAR_6] * sps->ctb_width + pps->col_bd[VAR_5];
for (VAR_8 = 0; VAR_8 < sps->min_cb_height; VAR_8++) {
for (VAR_7 = 0; VAR_7 < sps->min_cb_width; VAR_7++) {
int VAR_13 = VAR_7 >> sps->log2_diff_max_min_coding_block_size;
int VAR_14 = VAR_8 >> sps->log2_diff_max_min_coding_block_size;
int VAR_9 = sps->ctb_width * VAR_14 + VAR_13;
int VAR_17 = pps->ctb_addr_rs_to_ts[VAR_9] <<
(sps->log2_diff_max_min_coding_block_size * 2);
for (VAR_5 = 0; VAR_5 < sps->log2_diff_max_min_coding_block_size; VAR_5++) {
int m = 1 << VAR_5;
VAR_17 += (m & VAR_7 ? m * m : 0) + (m & VAR_8 ? 2 * m * m : 0);
}
pps->min_cb_addr_zs[VAR_8 * sps->min_cb_width + VAR_7] = VAR_17;
}
}
VAR_4 = sps->log2_ctb_size - sps->log2_min_tb_size;
for (VAR_8 = 0; VAR_8 < sps->min_tb_height; VAR_8++) {
for (VAR_7 = 0; VAR_7 < sps->min_tb_width; VAR_7++) {
int VAR_13 = VAR_7 >> VAR_4;
int VAR_14 = VAR_8 >> VAR_4;
int VAR_9 = sps->ctb_width * VAR_14 + VAR_13;
int VAR_17 = pps->ctb_addr_rs_to_ts[VAR_9] <<
(VAR_4 * 2);
for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {
int m = 1 << VAR_5;
VAR_17 += (m & VAR_7 ? m * m : 0) + (m & VAR_8 ? 2 * m * m : 0);
}
pps->min_tb_addr_zs[VAR_8 * sps->min_tb_width + VAR_7] = VAR_17;
}
}
av_buffer_unref(&VAR_0->pps_list[VAR_12]);
VAR_0->pps_list[VAR_12] = pps_buf;
return 0;
err:
av_buffer_unref(&pps_buf);
return VAR_11;
}
| [
"int FUNC_0(HEVCContext *VAR_0)\n{",
"GetBitContext *gb = &VAR_0->HEVClc.gb;",
"HEVCSPS *sps = NULL;",
"int VAR_1, VAR_2, VAR_3;",
"int VAR_4;",
"int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;",
"int VAR_11 = 0;",
"int VAR_12 = 0;",
"AVBufferRef *pps_buf;",
"HEVCPPS *pps = av_mallocz(sizeof(*pps));",
"if (!pps)\nreturn AVERROR(ENOMEM);",
"pps_buf = av_buffer_create((uint8_t *)pps, sizeof(*pps),\nhevc_pps_free, NULL, 0);",
"if (!pps_buf) {",
"av_freep(&pps);",
"return AVERROR(ENOMEM);",
"}",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Decoding PPS\\n\");",
"pps->loop_filter_across_tiles_enabled_flag = 1;",
"pps->num_tile_columns = 1;",
"pps->num_tile_rows = 1;",
"pps->uniform_spacing_flag = 1;",
"pps->disable_dbf = 0;",
"pps->beta_offset = 0;",
"pps->tc_offset = 0;",
"VAR_12 = get_ue_golomb_long(gb);",
"if (VAR_12 >= MAX_PPS_COUNT) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"PPS id out of range: %d\\n\", VAR_12);",
"VAR_11 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"pps->sps_id = get_ue_golomb_long(gb);",
"if (pps->sps_id >= MAX_SPS_COUNT) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"SPS id out of range: %d\\n\", pps->sps_id);",
"VAR_11 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"if (!VAR_0->sps_list[pps->sps_id]) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"SPS %u does not exist.\\n\", pps->sps_id);",
"VAR_11 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"sps = (HEVCSPS *)VAR_0->sps_list[pps->sps_id]->data;",
"pps->dependent_slice_segments_enabled_flag = get_bits1(gb);",
"pps->output_flag_present_flag = get_bits1(gb);",
"pps->num_extra_slice_header_bits = get_bits(gb, 3);",
"pps->sign_data_hiding_flag = get_bits1(gb);",
"pps->cabac_init_present_flag = get_bits1(gb);",
"pps->num_ref_idx_l0_default_active = get_ue_golomb_long(gb) + 1;",
"pps->num_ref_idx_l1_default_active = get_ue_golomb_long(gb) + 1;",
"pps->pic_init_qp_minus26 = get_se_golomb(gb);",
"pps->constrained_intra_pred_flag = get_bits1(gb);",
"pps->transform_skip_enabled_flag = get_bits1(gb);",
"pps->cu_qp_delta_enabled_flag = get_bits1(gb);",
"pps->diff_cu_qp_delta_depth = 0;",
"if (pps->cu_qp_delta_enabled_flag)\npps->diff_cu_qp_delta_depth = get_ue_golomb_long(gb);",
"pps->cb_qp_offset = get_se_golomb(gb);",
"if (pps->cb_qp_offset < -12 || pps->cb_qp_offset > 12) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"pps_cb_qp_offset out of range: %d\\n\",\npps->cb_qp_offset);",
"VAR_11 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"pps->cr_qp_offset = get_se_golomb(gb);",
"if (pps->cr_qp_offset < -12 || pps->cr_qp_offset > 12) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"pps_cr_qp_offset out of range: %d\\n\",\npps->cr_qp_offset);",
"VAR_11 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"pps->pic_slice_level_chroma_qp_offsets_present_flag = get_bits1(gb);",
"pps->weighted_pred_flag = get_bits1(gb);",
"pps->weighted_bipred_flag = get_bits1(gb);",
"pps->transquant_bypass_enable_flag = get_bits1(gb);",
"pps->tiles_enabled_flag = get_bits1(gb);",
"pps->entropy_coding_sync_enabled_flag = get_bits1(gb);",
"if (pps->tiles_enabled_flag) {",
"pps->num_tile_columns = get_ue_golomb_long(gb) + 1;",
"pps->num_tile_rows = get_ue_golomb_long(gb) + 1;",
"if (pps->num_tile_columns == 0 ||\npps->num_tile_columns >= sps->width) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"num_tile_columns_minus1 out of range: %d\\n\",\npps->num_tile_columns - 1);",
"VAR_11 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"if (pps->num_tile_rows == 0 ||\npps->num_tile_rows >= sps->height) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"num_tile_rows_minus1 out of range: %d\\n\",\npps->num_tile_rows - 1);",
"VAR_11 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"pps->column_width = av_malloc_array(pps->num_tile_columns, sizeof(*pps->column_width));",
"pps->row_height = av_malloc_array(pps->num_tile_rows, sizeof(*pps->row_height));",
"if (!pps->column_width || !pps->row_height) {",
"VAR_11 = AVERROR(ENOMEM);",
"goto err;",
"}",
"pps->uniform_spacing_flag = get_bits1(gb);",
"if (!pps->uniform_spacing_flag) {",
"uint64_t sum = 0;",
"for (VAR_5 = 0; VAR_5 < pps->num_tile_columns - 1; VAR_5++) {",
"pps->column_width[VAR_5] = get_ue_golomb_long(gb) + 1;",
"sum += pps->column_width[VAR_5];",
"}",
"if (sum >= sps->ctb_width) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid tile widths.\\n\");",
"VAR_11 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"pps->column_width[pps->num_tile_columns - 1] = sps->ctb_width - sum;",
"sum = 0;",
"for (VAR_5 = 0; VAR_5 < pps->num_tile_rows - 1; VAR_5++) {",
"pps->row_height[VAR_5] = get_ue_golomb_long(gb) + 1;",
"sum += pps->row_height[VAR_5];",
"}",
"if (sum >= sps->ctb_height) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid tile heights.\\n\");",
"VAR_11 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"pps->row_height[pps->num_tile_rows - 1] = sps->ctb_height - sum;",
"}",
"pps->loop_filter_across_tiles_enabled_flag = get_bits1(gb);",
"}",
"pps->seq_loop_filter_across_slices_enabled_flag = get_bits1(gb);",
"pps->deblocking_filter_control_present_flag = get_bits1(gb);",
"if (pps->deblocking_filter_control_present_flag) {",
"pps->deblocking_filter_override_enabled_flag = get_bits1(gb);",
"pps->disable_dbf = get_bits1(gb);",
"if (!pps->disable_dbf) {",
"pps->beta_offset = get_se_golomb(gb) * 2;",
"pps->tc_offset = get_se_golomb(gb) * 2;",
"if (pps->beta_offset/2 < -6 || pps->beta_offset/2 > 6) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"pps_beta_offset_div2 out of range: %d\\n\",\npps->beta_offset/2);",
"VAR_11 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"if (pps->tc_offset/2 < -6 || pps->tc_offset/2 > 6) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"pps_tc_offset_div2 out of range: %d\\n\",\npps->tc_offset/2);",
"VAR_11 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"}",
"}",
"pps->scaling_list_data_present_flag = get_bits1(gb);",
"if (pps->scaling_list_data_present_flag) {",
"set_default_scaling_list_data(&pps->scaling_list);",
"VAR_11 = scaling_list_data(VAR_0, &pps->scaling_list);",
"if (VAR_11 < 0)\ngoto err;",
"}",
"pps->lists_modification_present_flag = get_bits1(gb);",
"pps->log2_parallel_merge_level = get_ue_golomb_long(gb) + 2;",
"if (pps->log2_parallel_merge_level > sps->log2_ctb_size) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"log2_parallel_merge_level_minus2 out of range: %d\\n\",\npps->log2_parallel_merge_level - 2);",
"VAR_11 = AVERROR_INVALIDDATA;",
"goto err;",
"}",
"pps->slice_header_extension_present_flag = get_bits1(gb);",
"skip_bits1(gb);",
"pps->col_bd = av_malloc_array(pps->num_tile_columns + 1, sizeof(*pps->col_bd));",
"pps->row_bd = av_malloc_array(pps->num_tile_rows + 1, sizeof(*pps->row_bd));",
"pps->col_idxX = av_malloc_array(sps->ctb_width, sizeof(*pps->col_idxX));",
"if (!pps->col_bd || !pps->row_bd || !pps->col_idxX) {",
"VAR_11 = AVERROR(ENOMEM);",
"goto err;",
"}",
"if (pps->uniform_spacing_flag) {",
"if (!pps->column_width) {",
"pps->column_width = av_malloc_array(pps->num_tile_columns, sizeof(*pps->column_width));",
"pps->row_height = av_malloc_array(pps->num_tile_rows, sizeof(*pps->row_height));",
"}",
"if (!pps->column_width || !pps->row_height) {",
"VAR_11 = AVERROR(ENOMEM);",
"goto err;",
"}",
"for (VAR_5 = 0; VAR_5 < pps->num_tile_columns; VAR_5++) {",
"pps->column_width[VAR_5] = ((VAR_5 + 1) * sps->ctb_width) / pps->num_tile_columns -\n(VAR_5 * sps->ctb_width) / pps->num_tile_columns;",
"}",
"for (VAR_5 = 0; VAR_5 < pps->num_tile_rows; VAR_5++) {",
"pps->row_height[VAR_5] = ((VAR_5 + 1) * sps->ctb_height) / pps->num_tile_rows -\n(VAR_5 * sps->ctb_height) / pps->num_tile_rows;",
"}",
"}",
"pps->col_bd[0] = 0;",
"for (VAR_5 = 0; VAR_5 < pps->num_tile_columns; VAR_5++)",
"pps->col_bd[VAR_5 + 1] = pps->col_bd[VAR_5] + pps->column_width[VAR_5];",
"pps->row_bd[0] = 0;",
"for (VAR_5 = 0; VAR_5 < pps->num_tile_rows; VAR_5++)",
"pps->row_bd[VAR_5 + 1] = pps->row_bd[VAR_5] + pps->row_height[VAR_5];",
"for (VAR_5 = 0, VAR_6 = 0; VAR_5 < sps->ctb_width; VAR_5++) {",
"if (VAR_5 > pps->col_bd[VAR_6])\nVAR_6++;",
"pps->col_idxX[VAR_5] = VAR_6;",
"}",
"VAR_1 = sps->ctb_width * sps->ctb_height;",
"VAR_2 = sps->min_cb_width * sps->min_cb_height;",
"VAR_3 = sps->min_tb_width * sps->min_tb_height;",
"pps->ctb_addr_rs_to_ts = av_malloc_array(VAR_1, sizeof(*pps->ctb_addr_rs_to_ts));",
"pps->ctb_addr_ts_to_rs = av_malloc_array(VAR_1, sizeof(*pps->ctb_addr_ts_to_rs));",
"pps->VAR_10 = av_malloc_array(VAR_1, sizeof(*pps->VAR_10));",
"pps->min_cb_addr_zs = av_malloc_array(VAR_2, sizeof(*pps->min_cb_addr_zs));",
"pps->min_tb_addr_zs = av_malloc_array(VAR_3, sizeof(*pps->min_tb_addr_zs));",
"if (!pps->ctb_addr_rs_to_ts || !pps->ctb_addr_ts_to_rs ||\n!pps->VAR_10 || !pps->min_cb_addr_zs || !pps->min_tb_addr_zs) {",
"VAR_11 = AVERROR(ENOMEM);",
"goto err;",
"}",
"for (VAR_9 = 0; VAR_9 < VAR_1; VAR_9++) {",
"int VAR_13 = VAR_9 % sps->ctb_width;",
"int VAR_14 = VAR_9 / sps->ctb_width;",
"int VAR_15 = 0;",
"int VAR_16 = 0;",
"int VAR_17 = 0;",
"for (VAR_5 = 0; VAR_5 < pps->num_tile_columns; VAR_5++) {",
"if (VAR_13 < pps->col_bd[VAR_5 + 1]) {",
"VAR_15 = VAR_5;",
"break;",
"}",
"}",
"for (VAR_5 = 0; VAR_5 < pps->num_tile_rows; VAR_5++) {",
"if (VAR_14 < pps->row_bd[VAR_5 + 1]) {",
"VAR_16 = VAR_5;",
"break;",
"}",
"}",
"for (VAR_5 = 0; VAR_5 < VAR_15; VAR_5++)",
"VAR_17 += pps->row_height[VAR_16] * pps->column_width[VAR_5];",
"for (VAR_5 = 0; VAR_5 < VAR_16; VAR_5++)",
"VAR_17 += sps->ctb_width * pps->row_height[VAR_5];",
"VAR_17 += (VAR_14 - pps->row_bd[VAR_16]) * pps->column_width[VAR_15] +\nVAR_13 - pps->col_bd[VAR_15];",
"pps->ctb_addr_rs_to_ts[VAR_9] = VAR_17;",
"pps->ctb_addr_ts_to_rs[VAR_17] = VAR_9;",
"}",
"for (VAR_6 = 0, VAR_10 = 0; VAR_6 < pps->num_tile_rows; VAR_6++)",
"for (VAR_5 = 0; VAR_5 < pps->num_tile_columns; VAR_5++, VAR_10++)",
"for (VAR_8 = pps->row_bd[VAR_6]; VAR_8 < pps->row_bd[VAR_6 + 1]; VAR_8++)",
"for (VAR_7 = pps->col_bd[VAR_5]; VAR_7 < pps->col_bd[VAR_5 + 1]; VAR_7++)",
"pps->VAR_10[pps->ctb_addr_rs_to_ts[VAR_8 * sps->ctb_width + VAR_7]] = VAR_10;",
"pps->tile_pos_rs = av_malloc_array(VAR_10, sizeof(*pps->tile_pos_rs));",
"if (!pps->tile_pos_rs) {",
"VAR_11 = AVERROR(ENOMEM);",
"goto err;",
"}",
"for (VAR_6 = 0; VAR_6 < pps->num_tile_rows; VAR_6++)",
"for (VAR_5 = 0; VAR_5 < pps->num_tile_columns; VAR_5++)",
"pps->tile_pos_rs[VAR_6 * pps->num_tile_columns + VAR_5] = pps->row_bd[VAR_6] * sps->ctb_width + pps->col_bd[VAR_5];",
"for (VAR_8 = 0; VAR_8 < sps->min_cb_height; VAR_8++) {",
"for (VAR_7 = 0; VAR_7 < sps->min_cb_width; VAR_7++) {",
"int VAR_13 = VAR_7 >> sps->log2_diff_max_min_coding_block_size;",
"int VAR_14 = VAR_8 >> sps->log2_diff_max_min_coding_block_size;",
"int VAR_9 = sps->ctb_width * VAR_14 + VAR_13;",
"int VAR_17 = pps->ctb_addr_rs_to_ts[VAR_9] <<\n(sps->log2_diff_max_min_coding_block_size * 2);",
"for (VAR_5 = 0; VAR_5 < sps->log2_diff_max_min_coding_block_size; VAR_5++) {",
"int m = 1 << VAR_5;",
"VAR_17 += (m & VAR_7 ? m * m : 0) + (m & VAR_8 ? 2 * m * m : 0);",
"}",
"pps->min_cb_addr_zs[VAR_8 * sps->min_cb_width + VAR_7] = VAR_17;",
"}",
"}",
"VAR_4 = sps->log2_ctb_size - sps->log2_min_tb_size;",
"for (VAR_8 = 0; VAR_8 < sps->min_tb_height; VAR_8++) {",
"for (VAR_7 = 0; VAR_7 < sps->min_tb_width; VAR_7++) {",
"int VAR_13 = VAR_7 >> VAR_4;",
"int VAR_14 = VAR_8 >> VAR_4;",
"int VAR_9 = sps->ctb_width * VAR_14 + VAR_13;",
"int VAR_17 = pps->ctb_addr_rs_to_ts[VAR_9] <<\n(VAR_4 * 2);",
"for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {",
"int m = 1 << VAR_5;",
"VAR_17 += (m & VAR_7 ? m * m : 0) + (m & VAR_8 ? 2 * m * m : 0);",
"}",
"pps->min_tb_addr_zs[VAR_8 * sps->min_tb_width + VAR_7] = VAR_17;",
"}",
"}",
"av_buffer_unref(&VAR_0->pps_list[VAR_12]);",
"VAR_0->pps_list[VAR_12] = pps_buf;",
"return 0;",
"err:\nav_buffer_unref(&pps_buf);",
"return VAR_11;",
"}"
]
| [
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27,
29
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
117
],
[
121
],
[
125
],
[
127
],
[
131
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145,
147
],
[
151
],
[
153
],
[
155,
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169,
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
183
],
[
185
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
201
],
[
203,
205
],
[
207,
209
],
[
211
],
[
213
],
[
215
],
[
217,
219
],
[
221,
223
],
[
225
],
[
227
],
[
229
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
305
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325,
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337,
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361,
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373,
375
],
[
377
],
[
379
],
[
381
],
[
385
],
[
387
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
429
],
[
431,
433
],
[
435
],
[
439
],
[
441,
443
],
[
445
],
[
447
],
[
451
],
[
453
],
[
455
],
[
459
],
[
461
],
[
463
],
[
467
],
[
469,
471
],
[
473
],
[
475
],
[
485
],
[
487
],
[
489
],
[
493
],
[
495
],
[
497
],
[
499
],
[
501
],
[
503,
505
],
[
507
],
[
509
],
[
511
],
[
515
],
[
517
],
[
519
],
[
521
],
[
523
],
[
525
],
[
529
],
[
531
],
[
533
],
[
535
],
[
537
],
[
539
],
[
543
],
[
545
],
[
547
],
[
549
],
[
551
],
[
553
],
[
557
],
[
559
],
[
561
],
[
563
],
[
567,
569
],
[
573
],
[
575
],
[
577
],
[
581
],
[
583
],
[
585
],
[
587
],
[
589
],
[
593
],
[
595
],
[
597
],
[
599
],
[
601
],
[
605
],
[
607
],
[
609
],
[
613
],
[
615
],
[
617
],
[
619
],
[
621
],
[
623,
625
],
[
627
],
[
629
],
[
631
],
[
633
],
[
635
],
[
637
],
[
639
],
[
643
],
[
645
],
[
647
],
[
649
],
[
651
],
[
653
],
[
655,
657
],
[
659
],
[
661
],
[
663
],
[
665
],
[
667
],
[
669
],
[
671
],
[
675
],
[
677
],
[
681
],
[
685,
687
],
[
689
],
[
691
]
]
|
14,318 | static int raw_read_options(QDict *options, BlockDriverState *bs,
BDRVRawState *s, Error **errp)
{
Error *local_err = NULL;
QemuOpts *opts = NULL;
int64_t real_size = 0;
int ret;
real_size = bdrv_getlength(bs->file->bs);
if (real_size < 0) {
error_setg_errno(errp, -real_size, "Could not get image size");
return real_size;
}
opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto end;
}
s->offset = qemu_opt_get_size(opts, "offset", 0);
if (s->offset > real_size) {
error_setg(errp, "Offset (%" PRIu64 ") cannot be greater than "
"size of the containing file (%" PRId64 ")",
s->offset, real_size);
ret = -EINVAL;
goto end;
}
if (qemu_opt_find(opts, "size") != NULL) {
s->size = qemu_opt_get_size(opts, "size", 0);
s->has_size = true;
} else {
s->has_size = false;
s->size = real_size - s->offset;
}
/* Check size and offset */
if ((real_size - s->offset) < s->size) {
error_setg(errp, "The sum of offset (%" PRIu64 ") and size "
"(%" PRIu64 ") has to be smaller or equal to the "
" actual size of the containing file (%" PRId64 ")",
s->offset, s->size, real_size);
ret = -EINVAL;
goto end;
}
/* Make sure size is multiple of BDRV_SECTOR_SIZE to prevent rounding
* up and leaking out of the specified area. */
if (!QEMU_IS_ALIGNED(s->size, BDRV_SECTOR_SIZE)) {
error_setg(errp, "Specified size is not multiple of %llu",
BDRV_SECTOR_SIZE);
ret = -EINVAL;
goto end;
}
ret = 0;
end:
qemu_opts_del(opts);
return ret;
}
| true | qemu | 80a15e3e2eed96926d886693663503985c9a98bb | static int raw_read_options(QDict *options, BlockDriverState *bs,
BDRVRawState *s, Error **errp)
{
Error *local_err = NULL;
QemuOpts *opts = NULL;
int64_t real_size = 0;
int ret;
real_size = bdrv_getlength(bs->file->bs);
if (real_size < 0) {
error_setg_errno(errp, -real_size, "Could not get image size");
return real_size;
}
opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto end;
}
s->offset = qemu_opt_get_size(opts, "offset", 0);
if (s->offset > real_size) {
error_setg(errp, "Offset (%" PRIu64 ") cannot be greater than "
"size of the containing file (%" PRId64 ")",
s->offset, real_size);
ret = -EINVAL;
goto end;
}
if (qemu_opt_find(opts, "size") != NULL) {
s->size = qemu_opt_get_size(opts, "size", 0);
s->has_size = true;
} else {
s->has_size = false;
s->size = real_size - s->offset;
}
if ((real_size - s->offset) < s->size) {
error_setg(errp, "The sum of offset (%" PRIu64 ") and size "
"(%" PRIu64 ") has to be smaller or equal to the "
" actual size of the containing file (%" PRId64 ")",
s->offset, s->size, real_size);
ret = -EINVAL;
goto end;
}
if (!QEMU_IS_ALIGNED(s->size, BDRV_SECTOR_SIZE)) {
error_setg(errp, "Specified size is not multiple of %llu",
BDRV_SECTOR_SIZE);
ret = -EINVAL;
goto end;
}
ret = 0;
end:
qemu_opts_del(opts);
return ret;
}
| {
"code": [
" if (!QEMU_IS_ALIGNED(s->size, BDRV_SECTOR_SIZE)) {"
],
"line_no": [
103
]
} | static int FUNC_0(QDict *VAR_0, BlockDriverState *VAR_1,
BDRVRawState *VAR_2, Error **VAR_3)
{
Error *local_err = NULL;
QemuOpts *opts = NULL;
int64_t real_size = 0;
int VAR_4;
real_size = bdrv_getlength(VAR_1->file->VAR_1);
if (real_size < 0) {
error_setg_errno(VAR_3, -real_size, "Could not get image size");
return real_size;
}
opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, VAR_0, &local_err);
if (local_err) {
error_propagate(VAR_3, local_err);
VAR_4 = -EINVAL;
goto end;
}
VAR_2->offset = qemu_opt_get_size(opts, "offset", 0);
if (VAR_2->offset > real_size) {
error_setg(VAR_3, "Offset (%" PRIu64 ") cannot be greater than "
"size of the containing file (%" PRId64 ")",
VAR_2->offset, real_size);
VAR_4 = -EINVAL;
goto end;
}
if (qemu_opt_find(opts, "size") != NULL) {
VAR_2->size = qemu_opt_get_size(opts, "size", 0);
VAR_2->has_size = true;
} else {
VAR_2->has_size = false;
VAR_2->size = real_size - VAR_2->offset;
}
if ((real_size - VAR_2->offset) < VAR_2->size) {
error_setg(VAR_3, "The sum of offset (%" PRIu64 ") and size "
"(%" PRIu64 ") has to be smaller or equal to the "
" actual size of the containing file (%" PRId64 ")",
VAR_2->offset, VAR_2->size, real_size);
VAR_4 = -EINVAL;
goto end;
}
if (!QEMU_IS_ALIGNED(VAR_2->size, BDRV_SECTOR_SIZE)) {
error_setg(VAR_3, "Specified size is not multiple of %llu",
BDRV_SECTOR_SIZE);
VAR_4 = -EINVAL;
goto end;
}
VAR_4 = 0;
end:
qemu_opts_del(opts);
return VAR_4;
}
| [
"static int FUNC_0(QDict *VAR_0, BlockDriverState *VAR_1,\nBDRVRawState *VAR_2, Error **VAR_3)\n{",
"Error *local_err = NULL;",
"QemuOpts *opts = NULL;",
"int64_t real_size = 0;",
"int VAR_4;",
"real_size = bdrv_getlength(VAR_1->file->VAR_1);",
"if (real_size < 0) {",
"error_setg_errno(VAR_3, -real_size, \"Could not get image size\");",
"return real_size;",
"}",
"opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort);",
"qemu_opts_absorb_qdict(opts, VAR_0, &local_err);",
"if (local_err) {",
"error_propagate(VAR_3, local_err);",
"VAR_4 = -EINVAL;",
"goto end;",
"}",
"VAR_2->offset = qemu_opt_get_size(opts, \"offset\", 0);",
"if (VAR_2->offset > real_size) {",
"error_setg(VAR_3, \"Offset (%\" PRIu64 \") cannot be greater than \"\n\"size of the containing file (%\" PRId64 \")\",\nVAR_2->offset, real_size);",
"VAR_4 = -EINVAL;",
"goto end;",
"}",
"if (qemu_opt_find(opts, \"size\") != NULL) {",
"VAR_2->size = qemu_opt_get_size(opts, \"size\", 0);",
"VAR_2->has_size = true;",
"} else {",
"VAR_2->has_size = false;",
"VAR_2->size = real_size - VAR_2->offset;",
"}",
"if ((real_size - VAR_2->offset) < VAR_2->size) {",
"error_setg(VAR_3, \"The sum of offset (%\" PRIu64 \") and size \"\n\"(%\" PRIu64 \") has to be smaller or equal to the \"\n\" actual size of the containing file (%\" PRId64 \")\",\nVAR_2->offset, VAR_2->size, real_size);",
"VAR_4 = -EINVAL;",
"goto end;",
"}",
"if (!QEMU_IS_ALIGNED(VAR_2->size, BDRV_SECTOR_SIZE)) {",
"error_setg(VAR_3, \"Specified size is not multiple of %llu\",\nBDRV_SECTOR_SIZE);",
"VAR_4 = -EINVAL;",
"goto end;",
"}",
"VAR_4 = 0;",
"end:\nqemu_opts_del(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,
1,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49,
51,
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
81
],
[
83,
85,
87,
89
],
[
91
],
[
93
],
[
95
],
[
103
],
[
105,
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
121,
125
],
[
129
],
[
131
]
]
|
14,319 | inline static void RENAME(hcscale)(uint16_t *dst, long dstWidth, uint8_t *src1, uint8_t *src2,
int srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter,
int16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode,
int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,
int32_t *mmx2FilterPos, uint8_t *pal)
{
if (srcFormat==PIX_FMT_YUYV422)
{
RENAME(yuy2ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_UYVY422)
{
RENAME(uyvyToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_RGB32)
{
RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_BGR24)
{
RENAME(bgr24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_BGR565)
{
RENAME(bgr16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_BGR555)
{
RENAME(bgr15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_BGR32)
{
RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_RGB24)
{
RENAME(rgb24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_RGB565)
{
RENAME(rgb16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_RGB555)
{
RENAME(rgb15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (isGray(srcFormat))
{
return;
}
else if (srcFormat==PIX_FMT_RGB8 || srcFormat==PIX_FMT_BGR8 || srcFormat==PIX_FMT_PAL8 || srcFormat==PIX_FMT_BGR4_BYTE || srcFormat==PIX_FMT_RGB4_BYTE)
{
RENAME(palToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW, pal);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
#ifdef HAVE_MMX
// use the new MMX scaler if the mmx2 can't be used (it is faster than the x86 ASM one)
if (!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed))
#else
if (!(flags&SWS_FAST_BILINEAR))
#endif
{
RENAME(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
RENAME(hScale)(dst+2048, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
}
else // Fast Bilinear upscale / crap downscale
{
#if defined(ARCH_X86)
#ifdef HAVE_MMX2
int i;
#if defined(PIC)
uint64_t ebxsave __attribute__((aligned(8)));
#endif
if (canMMX2BeUsed)
{
asm volatile(
#if defined(PIC)
"mov %%"REG_b", %6 \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t" // i
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
#ifdef ARCH_X86_64
#define FUNNY_UV_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"movl (%%"REG_b", %%"REG_a"), %%esi \n\t"\
"add %%"REG_S", %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#else
#define FUNNY_UV_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"addl (%%"REG_b", %%"REG_a"), %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#endif /* ARCH_X86_64 */
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
"xor %%"REG_a", %%"REG_a" \n\t" // i
"mov %5, %%"REG_c" \n\t" // src
"mov %1, %%"REG_D" \n\t" // buf1
"add $4096, %%"REG_D" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
#if defined(PIC)
"mov %6, %%"REG_b" \n\t"
#endif
:: "m" (src1), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos),
"m" (funnyUVCode), "m" (src2)
#if defined(PIC)
,"m" (ebxsave)
#endif
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
#if !defined(PIC)
,"%"REG_b
#endif
);
for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--)
{
//printf("%d %d %d\n", dstWidth, i, srcW);
dst[i] = src1[srcW-1]*128;
dst[i+2048] = src2[srcW-1]*128;
}
}
else
{
#endif /* HAVE_MMX2 */
long xInc_shr16 = (long) (xInc >> 16);
uint16_t xInc_mask = xInc & 0xffff;
asm volatile(
"xor %%"REG_a", %%"REG_a" \n\t" // i
"xor %%"REG_d", %%"REG_d" \n\t" // xx
"xorl %%ecx, %%ecx \n\t" // 2*xalpha
ASMALIGN(4)
"1: \n\t"
"mov %0, %%"REG_S" \n\t"
"movzbl (%%"REG_S", %%"REG_d"), %%edi \n\t" //src[xx]
"movzbl 1(%%"REG_S", %%"REG_d"), %%esi \n\t" //src[xx+1]
"subl %%edi, %%esi \n\t" //src[xx+1] - src[xx]
"imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, (%%"REG_D", %%"REG_a", 2) \n\t"
"movzbl (%5, %%"REG_d"), %%edi \n\t" //src[xx]
"movzbl 1(%5, %%"REG_d"), %%esi \n\t" //src[xx+1]
"subl %%edi, %%esi \n\t" //src[xx+1] - src[xx]
"imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, 4096(%%"REG_D", %%"REG_a", 2) \n\t"
"addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF
"adc %3, %%"REG_d" \n\t" //xx+= xInc>>8 + carry
"add $1, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
/* GCC-3.3 makes MPlayer crash on IA-32 machines when using "g" operand here,
which is needed to support GCC-4.0 */
#if defined(ARCH_X86_64) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
:: "m" (src1), "m" (dst), "g" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#else
:: "m" (src1), "m" (dst), "m" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#endif
"r" (src2)
: "%"REG_a, "%"REG_d, "%ecx", "%"REG_D, "%esi"
);
#ifdef HAVE_MMX2
} //if MMX2 can't be used
#endif
#else
int i;
unsigned int xpos=0;
for (i=0;i<dstWidth;i++)
{
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
dst[i+2048]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
/* slower
dst[i]= (src1[xx]<<7) + (src1[xx+1] - src1[xx])*xalpha;
dst[i+2048]=(src2[xx]<<7) + (src2[xx+1] - src2[xx])*xalpha;
*/
xpos+=xInc;
}
#endif /* defined(ARCH_X86) */
}
}
| true | FFmpeg | 8b2fce0d3f5a56c40c28899c9237210ca8f9cf75 | inline static void RENAME(hcscale)(uint16_t *dst, long dstWidth, uint8_t *src1, uint8_t *src2,
int srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter,
int16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode,
int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,
int32_t *mmx2FilterPos, uint8_t *pal)
{
if (srcFormat==PIX_FMT_YUYV422)
{
RENAME(yuy2ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_UYVY422)
{
RENAME(uyvyToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_RGB32)
{
RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_BGR24)
{
RENAME(bgr24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_BGR565)
{
RENAME(bgr16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_BGR555)
{
RENAME(bgr15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_BGR32)
{
RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_RGB24)
{
RENAME(rgb24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_RGB565)
{
RENAME(rgb16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_RGB555)
{
RENAME(rgb15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (isGray(srcFormat))
{
return;
}
else if (srcFormat==PIX_FMT_RGB8 || srcFormat==PIX_FMT_BGR8 || srcFormat==PIX_FMT_PAL8 || srcFormat==PIX_FMT_BGR4_BYTE || srcFormat==PIX_FMT_RGB4_BYTE)
{
RENAME(palToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW, pal);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
#ifdef HAVE_MMX
if (!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed))
#else
if (!(flags&SWS_FAST_BILINEAR))
#endif
{
RENAME(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
RENAME(hScale)(dst+2048, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
}
else
{
#if defined(ARCH_X86)
#ifdef HAVE_MMX2
int i;
#if defined(PIC)
uint64_t ebxsave __attribute__((aligned(8)));
#endif
if (canMMX2BeUsed)
{
asm volatile(
#if defined(PIC)
"mov %%"REG_b", %6 \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
#ifdef ARCH_X86_64
#define FUNNY_UV_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"movl (%%"REG_b", %%"REG_a"), %%esi \n\t"\
"add %%"REG_S", %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#else
#define FUNNY_UV_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"addl (%%"REG_b", %%"REG_a"), %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#endif
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
"xor %%"REG_a", %%"REG_a" \n\t"
"mov %5, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"add $4096, %%"REG_D" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
#if defined(PIC)
"mov %6, %%"REG_b" \n\t"
#endif
:: "m" (src1), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos),
"m" (funnyUVCode), "m" (src2)
#if defined(PIC)
,"m" (ebxsave)
#endif
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
#if !defined(PIC)
,"%"REG_b
#endif
);
for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--)
{
dst[i] = src1[srcW-1]*128;
dst[i+2048] = src2[srcW-1]*128;
}
}
else
{
#endif
long xInc_shr16 = (long) (xInc >> 16);
uint16_t xInc_mask = xInc & 0xffff;
asm volatile(
"xor %%"REG_a", %%"REG_a" \n\t"
"xor %%"REG_d", %%"REG_d" \n\t"
"xorl %%ecx, %%ecx \n\t"
ASMALIGN(4)
"1: \n\t"
"mov %0, %%"REG_S" \n\t"
"movzbl (%%"REG_S", %%"REG_d"), %%edi \n\t"
"movzbl 1(%%"REG_S", %%"REG_d"), %%esi \n\t"
"subl %%edi, %%esi \n\t" - src[xx]
"imull %%ecx, %%esi \n\t"
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, (%%"REG_D", %%"REG_a", 2) \n\t"
"movzbl (%5, %%"REG_d"), %%edi \n\t"
"movzbl 1(%5, %%"REG_d"), %%esi \n\t"
"subl %%edi, %%esi \n\t" - src[xx]
"imull %%ecx, %%esi \n\t"
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, 4096(%%"REG_D", %%"REG_a", 2) \n\t"
"addw %4, %%cx \n\t"
"adc %3, %%"REG_d" \n\t"
"add $1, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
#if defined(ARCH_X86_64) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
:: "m" (src1), "m" (dst), "g" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#else
:: "m" (src1), "m" (dst), "m" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#endif
"r" (src2)
: "%"REG_a, "%"REG_d, "%ecx", "%"REG_D, "%esi"
);
#ifdef HAVE_MMX2
}
#endif
#else
int i;
unsigned int xpos=0;
for (i=0;i<dstWidth;i++)
{
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
dst[i+2048]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
xpos+=xInc;
}
#endif
}
}
| {
"code": [
" RENAME(yuy2ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
" src2= formatConvBuffer+2048;",
" RENAME(uyvyToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
" src2= formatConvBuffer+2048;",
" RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
" src2= formatConvBuffer+2048;",
" RENAME(bgr24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
" src2= formatConvBuffer+2048;",
" RENAME(bgr16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
" src2= formatConvBuffer+2048;",
" RENAME(bgr15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
" src2= formatConvBuffer+2048;",
" RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
" src2= formatConvBuffer+2048;",
" RENAME(rgb24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
" src2= formatConvBuffer+2048;",
" RENAME(rgb16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
" src2= formatConvBuffer+2048;",
" RENAME(rgb15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
" src2= formatConvBuffer+2048;",
" RENAME(palToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW, pal);",
" src2= formatConvBuffer+2048;",
" RENAME(hScale)(dst+2048, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);",
" \"add $4096, %%\"REG_D\" \\n\\t\"",
" dst[i+2048] = src2[srcW-1]*128;",
" \"movw %%si, 4096(%%\"REG_D\", %%\"REG_a\", 2) \\n\\t\"",
" dst[i+2048]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);"
],
"line_no": [
17,
21,
29,
21,
41,
21,
53,
21,
65,
21,
77,
21,
89,
21,
101,
21,
113,
21,
125,
21,
145,
21,
171,
279,
333,
399,
457
]
} | inline static void FUNC_0(hcscale)(uint16_t *dst, long dstWidth, uint8_t *src1, uint8_t *src2,
int srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter,
int16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode,
int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,
int32_t *mmx2FilterPos, uint8_t *pal)
{
if (srcFormat==PIX_FMT_YUYV422)
{
FUNC_0(yuy2ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_UYVY422)
{
FUNC_0(uyvyToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_RGB32)
{
FUNC_0(bgr32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_BGR24)
{
FUNC_0(bgr24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_BGR565)
{
FUNC_0(bgr16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_BGR555)
{
FUNC_0(bgr15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_BGR32)
{
FUNC_0(rgb32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_RGB24)
{
FUNC_0(rgb24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_RGB565)
{
FUNC_0(rgb16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (srcFormat==PIX_FMT_RGB555)
{
FUNC_0(rgb15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
else if (isGray(srcFormat))
{
return;
}
else if (srcFormat==PIX_FMT_RGB8 || srcFormat==PIX_FMT_BGR8 || srcFormat==PIX_FMT_PAL8 || srcFormat==PIX_FMT_BGR4_BYTE || srcFormat==PIX_FMT_RGB4_BYTE)
{
FUNC_0(palToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW, pal);
src1= formatConvBuffer;
src2= formatConvBuffer+2048;
}
#ifdef HAVE_MMX
if (!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed))
#else
if (!(flags&SWS_FAST_BILINEAR))
#endif
{
FUNC_0(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
FUNC_0(hScale)(dst+2048, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
}
else
{
#if defined(ARCH_X86)
#ifdef HAVE_MMX2
int VAR_0;
#if defined(PIC)
uint64_t ebxsave __attribute__((aligned(8)));
#endif
if (canMMX2BeUsed)
{
asm volatile(
#if defined(PIC)
"mov %%"REG_b", %6 \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
#ifdef ARCH_X86_64
#define FUNNY_UV_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"movl (%%"REG_b", %%"REG_a"), %%esi \n\t"\
"add %%"REG_S", %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#else
#define FUNNY_UV_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"addl (%%"REG_b", %%"REG_a"), %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#endif
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
"xor %%"REG_a", %%"REG_a" \n\t"
"mov %5, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"add $4096, %%"REG_D" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
#if defined(PIC)
"mov %6, %%"REG_b" \n\t"
#endif
:: "m" (src1), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos),
"m" (funnyUVCode), "m" (src2)
#if defined(PIC)
,"m" (ebxsave)
#endif
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
#if !defined(PIC)
,"%"REG_b
#endif
);
for (VAR_0=dstWidth-1; (VAR_0*xInc)>>16 >=srcW-1; VAR_0--)
{
dst[VAR_0] = src1[srcW-1]*128;
dst[VAR_0+2048] = src2[srcW-1]*128;
}
}
else
{
#endif
long xInc_shr16 = (long) (xInc >> 16);
uint16_t xInc_mask = xInc & 0xffff;
asm volatile(
"xor %%"REG_a", %%"REG_a" \n\t"
"xor %%"REG_d", %%"REG_d" \n\t"
"xorl %%ecx, %%ecx \n\t"
ASMALIGN(4)
"1: \n\t"
"mov %0, %%"REG_S" \n\t"
"movzbl (%%"REG_S", %%"REG_d"), %%edi \n\t"
"movzbl 1(%%"REG_S", %%"REG_d"), %%esi \n\t"
"subl %%edi, %%esi \n\t" - src[xx]
"imull %%ecx, %%esi \n\t"
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, (%%"REG_D", %%"REG_a", 2) \n\t"
"movzbl (%5, %%"REG_d"), %%edi \n\t"
"movzbl 1(%5, %%"REG_d"), %%esi \n\t"
"subl %%edi, %%esi \n\t" - src[xx]
"imull %%ecx, %%esi \n\t"
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, 4096(%%"REG_D", %%"REG_a", 2) \n\t"
"addw %4, %%cx \n\t"
"adc %3, %%"REG_d" \n\t"
"add $1, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
#if defined(ARCH_X86_64) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
:: "m" (src1), "m" (dst), "g" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#else
:: "m" (src1), "m" (dst), "m" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#endif
"r" (src2)
: "%"REG_a, "%"REG_d, "%ecx", "%"REG_D, "%esi"
);
#ifdef HAVE_MMX2
}
#endif
#else
int VAR_0;
unsigned int VAR_1=0;
for (VAR_0=0;VAR_0<dstWidth;VAR_0++)
{
register unsigned int xx=VAR_1>>16;
register unsigned int xalpha=(VAR_1&0xFFFF)>>9;
dst[VAR_0]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
dst[VAR_0+2048]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
VAR_1+=xInc;
}
#endif
}
}
| [
"inline static void FUNC_0(hcscale)(uint16_t *dst, long dstWidth, uint8_t *src1, uint8_t *src2,\nint srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter,\nint16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode,\nint srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,\nint32_t *mmx2FilterPos, uint8_t *pal)\n{",
"if (srcFormat==PIX_FMT_YUYV422)\n{",
"FUNC_0(yuy2ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
"src1= formatConvBuffer;",
"src2= formatConvBuffer+2048;",
"}",
"else if (srcFormat==PIX_FMT_UYVY422)\n{",
"FUNC_0(uyvyToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
"src1= formatConvBuffer;",
"src2= formatConvBuffer+2048;",
"}",
"else if (srcFormat==PIX_FMT_RGB32)\n{",
"FUNC_0(bgr32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
"src1= formatConvBuffer;",
"src2= formatConvBuffer+2048;",
"}",
"else if (srcFormat==PIX_FMT_BGR24)\n{",
"FUNC_0(bgr24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
"src1= formatConvBuffer;",
"src2= formatConvBuffer+2048;",
"}",
"else if (srcFormat==PIX_FMT_BGR565)\n{",
"FUNC_0(bgr16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
"src1= formatConvBuffer;",
"src2= formatConvBuffer+2048;",
"}",
"else if (srcFormat==PIX_FMT_BGR555)\n{",
"FUNC_0(bgr15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
"src1= formatConvBuffer;",
"src2= formatConvBuffer+2048;",
"}",
"else if (srcFormat==PIX_FMT_BGR32)\n{",
"FUNC_0(rgb32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
"src1= formatConvBuffer;",
"src2= formatConvBuffer+2048;",
"}",
"else if (srcFormat==PIX_FMT_RGB24)\n{",
"FUNC_0(rgb24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
"src1= formatConvBuffer;",
"src2= formatConvBuffer+2048;",
"}",
"else if (srcFormat==PIX_FMT_RGB565)\n{",
"FUNC_0(rgb16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
"src1= formatConvBuffer;",
"src2= formatConvBuffer+2048;",
"}",
"else if (srcFormat==PIX_FMT_RGB555)\n{",
"FUNC_0(rgb15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);",
"src1= formatConvBuffer;",
"src2= formatConvBuffer+2048;",
"}",
"else if (isGray(srcFormat))\n{",
"return;",
"}",
"else if (srcFormat==PIX_FMT_RGB8 || srcFormat==PIX_FMT_BGR8 || srcFormat==PIX_FMT_PAL8 || srcFormat==PIX_FMT_BGR4_BYTE || srcFormat==PIX_FMT_RGB4_BYTE)\n{",
"FUNC_0(palToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW, pal);",
"src1= formatConvBuffer;",
"src2= formatConvBuffer+2048;",
"}",
"#ifdef HAVE_MMX\nif (!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed))\n#else\nif (!(flags&SWS_FAST_BILINEAR))\n#endif\n{",
"FUNC_0(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);",
"FUNC_0(hScale)(dst+2048, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);",
"}",
"else\n{",
"#if defined(ARCH_X86)\n#ifdef HAVE_MMX2\nint VAR_0;",
"#if defined(PIC)\nuint64_t ebxsave __attribute__((aligned(8)));",
"#endif\nif (canMMX2BeUsed)\n{",
"asm volatile(\n#if defined(PIC)\n\"mov %%\"REG_b\", %6 \\n\\t\"\n#endif\n\"pxor %%mm7, %%mm7 \\n\\t\"\n\"mov %0, %%\"REG_c\" \\n\\t\"\n\"mov %1, %%\"REG_D\" \\n\\t\"\n\"mov %2, %%\"REG_d\" \\n\\t\"\n\"mov %3, %%\"REG_b\" \\n\\t\"\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\nPREFETCH\" (%%\"REG_c\") \\n\\t\"\nPREFETCH\" 32(%%\"REG_c\") \\n\\t\"\nPREFETCH\" 64(%%\"REG_c\") \\n\\t\"\n#ifdef ARCH_X86_64\n#define FUNNY_UV_CODE \\\n\"movl (%%\"REG_b\"), %%esi \\n\\t\"\\\n\"call *%4 \\n\\t\"\\\n\"movl (%%\"REG_b\", %%\"REG_a\"), %%esi \\n\\t\"\\\n\"add %%\"REG_S\", %%\"REG_c\" \\n\\t\"\\\n\"add %%\"REG_a\", %%\"REG_D\" \\n\\t\"\\\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\\\n#else\n#define FUNNY_UV_CODE \\\n\"movl (%%\"REG_b\"), %%esi \\n\\t\"\\\n\"call *%4 \\n\\t\"\\\n\"addl (%%\"REG_b\", %%\"REG_a\"), %%\"REG_c\" \\n\\t\"\\\n\"add %%\"REG_a\", %%\"REG_D\" \\n\\t\"\\\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\\\n#endif\nFUNNY_UV_CODE\nFUNNY_UV_CODE\nFUNNY_UV_CODE\nFUNNY_UV_CODE\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\n\"mov %5, %%\"REG_c\" \\n\\t\"\n\"mov %1, %%\"REG_D\" \\n\\t\"\n\"add $4096, %%\"REG_D\" \\n\\t\"\nPREFETCH\" (%%\"REG_c\") \\n\\t\"\nPREFETCH\" 32(%%\"REG_c\") \\n\\t\"\nPREFETCH\" 64(%%\"REG_c\") \\n\\t\"\nFUNNY_UV_CODE\nFUNNY_UV_CODE\nFUNNY_UV_CODE\nFUNNY_UV_CODE\n#if defined(PIC)\n\"mov %6, %%\"REG_b\" \\n\\t\"\n#endif\n:: \"m\" (src1), \"m\" (dst), \"m\" (mmx2Filter), \"m\" (mmx2FilterPos),\n\"m\" (funnyUVCode), \"m\" (src2)\n#if defined(PIC)\n,\"m\" (ebxsave)\n#endif\n: \"%\"REG_a, \"%\"REG_c, \"%\"REG_d, \"%\"REG_S, \"%\"REG_D\n#if !defined(PIC)\n,\"%\"REG_b\n#endif\n);",
"for (VAR_0=dstWidth-1; (VAR_0*xInc)>>16 >=srcW-1; VAR_0--)",
"{",
"dst[VAR_0] = src1[srcW-1]*128;",
"dst[VAR_0+2048] = src2[srcW-1]*128;",
"}",
"}",
"else\n{",
"#endif\nlong xInc_shr16 = (long) (xInc >> 16);",
"uint16_t xInc_mask = xInc & 0xffff;",
"asm volatile(\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\n\"xor %%\"REG_d\", %%\"REG_d\" \\n\\t\"\n\"xorl %%ecx, %%ecx \\n\\t\"\nASMALIGN(4)\n\"1: \\n\\t\"\n\"mov %0, %%\"REG_S\" \\n\\t\"\n\"movzbl (%%\"REG_S\", %%\"REG_d\"), %%edi \\n\\t\"\n\"movzbl 1(%%\"REG_S\", %%\"REG_d\"), %%esi \\n\\t\"\n\"subl %%edi, %%esi \\n\\t\" - src[xx]\n\"imull %%ecx, %%esi \\n\\t\"\n\"shll $16, %%edi \\n\\t\"\n\"addl %%edi, %%esi \\n\\t\" *2*xalpha + src[xx]*(1-2*xalpha)\n\"mov %1, %%\"REG_D\" \\n\\t\"\n\"shrl $9, %%esi \\n\\t\"\n\"movw %%si, (%%\"REG_D\", %%\"REG_a\", 2) \\n\\t\"\n\"movzbl (%5, %%\"REG_d\"), %%edi \\n\\t\"\n\"movzbl 1(%5, %%\"REG_d\"), %%esi \\n\\t\"\n\"subl %%edi, %%esi \\n\\t\" - src[xx]\n\"imull %%ecx, %%esi \\n\\t\"\n\"shll $16, %%edi \\n\\t\"\n\"addl %%edi, %%esi \\n\\t\" *2*xalpha + src[xx]*(1-2*xalpha)\n\"mov %1, %%\"REG_D\" \\n\\t\"\n\"shrl $9, %%esi \\n\\t\"\n\"movw %%si, 4096(%%\"REG_D\", %%\"REG_a\", 2) \\n\\t\"\n\"addw %4, %%cx \\n\\t\"\n\"adc %3, %%\"REG_d\" \\n\\t\"\n\"add $1, %%\"REG_a\" \\n\\t\"\n\"cmp %2, %%\"REG_a\" \\n\\t\"\n\" jb 1b \\n\\t\"\n#if defined(ARCH_X86_64) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))\n:: \"m\" (src1), \"m\" (dst), \"g\" ((long)dstWidth), \"m\" (xInc_shr16), \"m\" (xInc_mask),\n#else\n:: \"m\" (src1), \"m\" (dst), \"m\" ((long)dstWidth), \"m\" (xInc_shr16), \"m\" (xInc_mask),\n#endif\n\"r\" (src2)\n: \"%\"REG_a, \"%\"REG_d, \"%ecx\", \"%\"REG_D, \"%esi\"\n);",
"#ifdef HAVE_MMX2\n}",
"#endif\n#else\nint VAR_0;",
"unsigned int VAR_1=0;",
"for (VAR_0=0;VAR_0<dstWidth;VAR_0++)",
"{",
"register unsigned int xx=VAR_1>>16;",
"register unsigned int xalpha=(VAR_1&0xFFFF)>>9;",
"dst[VAR_0]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);",
"dst[VAR_0+2048]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);",
"VAR_1+=xInc;",
"}",
"#endif\n}",
"}"
]
| [
0,
0,
1,
0,
1,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9,
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97,
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133,
135
],
[
137
],
[
139
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155,
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,
223,
227,
229,
231,
233,
235,
237,
239,
243,
247,
249,
251,
253,
255,
257,
261,
265,
267,
269,
271,
273,
275,
277,
279,
281,
283,
285,
289,
291,
293,
295,
299,
301,
303,
305,
307,
309,
311,
313,
315,
317,
319,
321,
323
],
[
325
],
[
327
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339,
341
],
[
343,
345
],
[
347
],
[
349,
351,
353,
355,
357,
359,
361,
363,
365,
367,
369,
371,
373,
375,
377,
379,
383,
385,
387,
389,
391,
393,
395,
397,
399,
403,
405,
407,
409,
411,
419,
421,
423,
425,
427,
429,
431,
433
],
[
435,
437
],
[
439,
441,
443
],
[
445
],
[
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
457
],
[
467
],
[
469
],
[
471,
473
],
[
475
]
]
|
14,320 | uint64_t cpu_tick_get_count(CPUTimer *timer)
{
uint64_t real_count = timer_to_cpu_ticks(
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - timer->clock_offset,
timer->frequency);
TIMER_DPRINTF("%s get_count count=0x%016lx (%s) p=%p\n",
timer->name, real_count,
timer->disabled?"disabled":"enabled", timer);
if (timer->disabled)
real_count |= timer->disabled_mask;
return real_count;
}
| true | qemu | bf43330aa418908f7a5e2acda28ac1a8ed0d8ad6 | uint64_t cpu_tick_get_count(CPUTimer *timer)
{
uint64_t real_count = timer_to_cpu_ticks(
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - timer->clock_offset,
timer->frequency);
TIMER_DPRINTF("%s get_count count=0x%016lx (%s) p=%p\n",
timer->name, real_count,
timer->disabled?"disabled":"enabled", timer);
if (timer->disabled)
real_count |= timer->disabled_mask;
return real_count;
}
| {
"code": [
" TIMER_DPRINTF(\"%s get_count count=0x%016lx (%s) p=%p\\n\",",
" timer->disabled?\"disabled\":\"enabled\", timer);",
" if (timer->disabled)",
" real_count |= timer->disabled_mask;"
],
"line_no": [
13,
17,
21,
23
]
} | uint64_t FUNC_0(CPUTimer *timer)
{
uint64_t real_count = timer_to_cpu_ticks(
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - timer->clock_offset,
timer->frequency);
TIMER_DPRINTF("%s get_count count=0x%016lx (%s) p=%p\n",
timer->name, real_count,
timer->disabled?"disabled":"enabled", timer);
if (timer->disabled)
real_count |= timer->disabled_mask;
return real_count;
}
| [
"uint64_t FUNC_0(CPUTimer *timer)\n{",
"uint64_t real_count = timer_to_cpu_ticks(\nqemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - timer->clock_offset,\ntimer->frequency);",
"TIMER_DPRINTF(\"%s get_count count=0x%016lx (%s) p=%p\\n\",\ntimer->name, real_count,\ntimer->disabled?\"disabled\":\"enabled\", timer);",
"if (timer->disabled)\nreal_count |= timer->disabled_mask;",
"return real_count;",
"}"
]
| [
0,
0,
1,
1,
0,
0
]
| [
[
1,
3
],
[
5,
7,
9
],
[
13,
15,
17
],
[
21,
23
],
[
27
],
[
29
]
]
|
14,321 | static int mov_read_colr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
char color_parameter_type[5] = { 0 };
int color_primaries, color_trc, color_matrix;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams - 1];
avio_read(pb, color_parameter_type, 4);
if (strncmp(color_parameter_type, "nclx", 4) &&
strncmp(color_parameter_type, "nclc", 4)) {
av_log(c->fc, AV_LOG_WARNING, "unsupported color_parameter_type %s\n",
color_parameter_type);
return 0;
}
color_primaries = avio_rb16(pb);
color_trc = avio_rb16(pb);
color_matrix = avio_rb16(pb);
av_log(c->fc, AV_LOG_TRACE,
"%s: pri %"PRIu16" trc %"PRIu16" matrix %"PRIu16"",
color_parameter_type, color_primaries, color_trc, color_matrix);
if (!strncmp(color_parameter_type, "nclx", 4)) {
uint8_t color_range = avio_r8(pb) >> 7;
av_log(c->fc, AV_LOG_TRACE, " full %"PRIu8"", color_range);
if (color_range)
st->codec->color_range = AVCOL_RANGE_JPEG;
else
st->codec->color_range = AVCOL_RANGE_MPEG;
/* 14496-12 references JPEG XR specs (rather than the more complete
* 23001-8) so some adjusting is required */
if (color_primaries >= AVCOL_PRI_FILM)
color_primaries = AVCOL_PRI_UNSPECIFIED;
if ((color_trc >= AVCOL_TRC_LINEAR &&
color_trc <= AVCOL_TRC_LOG_SQRT) ||
color_trc >= AVCOL_TRC_BT2020_10)
color_trc = AVCOL_TRC_UNSPECIFIED;
if (color_matrix >= AVCOL_SPC_BT2020_NCL)
color_matrix = AVCOL_SPC_UNSPECIFIED;
st->codec->color_primaries = color_primaries;
st->codec->color_trc = color_trc;
st->codec->colorspace = color_matrix;
} else if (!strncmp(color_parameter_type, "nclc", 4)) {
/* color primaries, Table 4-4 */
switch (color_primaries) {
case 1: st->codec->color_primaries = AVCOL_PRI_BT709; break;
case 5: st->codec->color_primaries = AVCOL_PRI_SMPTE170M; break;
case 6: st->codec->color_primaries = AVCOL_PRI_SMPTE240M; break;
}
/* color transfer, Table 4-5 */
switch (color_trc) {
case 1: st->codec->color_trc = AVCOL_TRC_BT709; break;
case 7: st->codec->color_trc = AVCOL_TRC_SMPTE240M; break;
}
/* color matrix, Table 4-6 */
switch (color_matrix) {
case 1: st->codec->colorspace = AVCOL_SPC_BT709; break;
case 6: st->codec->colorspace = AVCOL_SPC_BT470BG; break;
case 7: st->codec->colorspace = AVCOL_SPC_SMPTE240M; break;
}
}
av_log(c->fc, AV_LOG_TRACE, "\n");
return 0;
}
| true | FFmpeg | 5c720657c23afd798ae0db7c7362eb859a89ab3d | static int mov_read_colr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
char color_parameter_type[5] = { 0 };
int color_primaries, color_trc, color_matrix;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams - 1];
avio_read(pb, color_parameter_type, 4);
if (strncmp(color_parameter_type, "nclx", 4) &&
strncmp(color_parameter_type, "nclc", 4)) {
av_log(c->fc, AV_LOG_WARNING, "unsupported color_parameter_type %s\n",
color_parameter_type);
return 0;
}
color_primaries = avio_rb16(pb);
color_trc = avio_rb16(pb);
color_matrix = avio_rb16(pb);
av_log(c->fc, AV_LOG_TRACE,
"%s: pri %"PRIu16" trc %"PRIu16" matrix %"PRIu16"",
color_parameter_type, color_primaries, color_trc, color_matrix);
if (!strncmp(color_parameter_type, "nclx", 4)) {
uint8_t color_range = avio_r8(pb) >> 7;
av_log(c->fc, AV_LOG_TRACE, " full %"PRIu8"", color_range);
if (color_range)
st->codec->color_range = AVCOL_RANGE_JPEG;
else
st->codec->color_range = AVCOL_RANGE_MPEG;
if (color_primaries >= AVCOL_PRI_FILM)
color_primaries = AVCOL_PRI_UNSPECIFIED;
if ((color_trc >= AVCOL_TRC_LINEAR &&
color_trc <= AVCOL_TRC_LOG_SQRT) ||
color_trc >= AVCOL_TRC_BT2020_10)
color_trc = AVCOL_TRC_UNSPECIFIED;
if (color_matrix >= AVCOL_SPC_BT2020_NCL)
color_matrix = AVCOL_SPC_UNSPECIFIED;
st->codec->color_primaries = color_primaries;
st->codec->color_trc = color_trc;
st->codec->colorspace = color_matrix;
} else if (!strncmp(color_parameter_type, "nclc", 4)) {
switch (color_primaries) {
case 1: st->codec->color_primaries = AVCOL_PRI_BT709; break;
case 5: st->codec->color_primaries = AVCOL_PRI_SMPTE170M; break;
case 6: st->codec->color_primaries = AVCOL_PRI_SMPTE240M; break;
}
switch (color_trc) {
case 1: st->codec->color_trc = AVCOL_TRC_BT709; break;
case 7: st->codec->color_trc = AVCOL_TRC_SMPTE240M; break;
}
switch (color_matrix) {
case 1: st->codec->colorspace = AVCOL_SPC_BT709; break;
case 6: st->codec->colorspace = AVCOL_SPC_BT470BG; break;
case 7: st->codec->colorspace = AVCOL_SPC_SMPTE240M; break;
}
}
av_log(c->fc, AV_LOG_TRACE, "\n");
return 0;
}
| {
"code": [
" avio_read(pb, color_parameter_type, 4);"
],
"line_no": [
21
]
} | static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2)
{
AVStream *st;
char VAR_3[5] = { 0 };
int VAR_4, VAR_5, VAR_6;
if (VAR_0->fc->nb_streams < 1)
return 0;
st = VAR_0->fc->streams[VAR_0->fc->nb_streams - 1];
avio_read(VAR_1, VAR_3, 4);
if (strncmp(VAR_3, "nclx", 4) &&
strncmp(VAR_3, "nclc", 4)) {
av_log(VAR_0->fc, AV_LOG_WARNING, "unsupported VAR_3 %s\n",
VAR_3);
return 0;
}
VAR_4 = avio_rb16(VAR_1);
VAR_5 = avio_rb16(VAR_1);
VAR_6 = avio_rb16(VAR_1);
av_log(VAR_0->fc, AV_LOG_TRACE,
"%s: pri %"PRIu16" trc %"PRIu16" matrix %"PRIu16"",
VAR_3, VAR_4, VAR_5, VAR_6);
if (!strncmp(VAR_3, "nclx", 4)) {
uint8_t color_range = avio_r8(VAR_1) >> 7;
av_log(VAR_0->fc, AV_LOG_TRACE, " full %"PRIu8"", color_range);
if (color_range)
st->codec->color_range = AVCOL_RANGE_JPEG;
else
st->codec->color_range = AVCOL_RANGE_MPEG;
if (VAR_4 >= AVCOL_PRI_FILM)
VAR_4 = AVCOL_PRI_UNSPECIFIED;
if ((VAR_5 >= AVCOL_TRC_LINEAR &&
VAR_5 <= AVCOL_TRC_LOG_SQRT) ||
VAR_5 >= AVCOL_TRC_BT2020_10)
VAR_5 = AVCOL_TRC_UNSPECIFIED;
if (VAR_6 >= AVCOL_SPC_BT2020_NCL)
VAR_6 = AVCOL_SPC_UNSPECIFIED;
st->codec->VAR_4 = VAR_4;
st->codec->VAR_5 = VAR_5;
st->codec->colorspace = VAR_6;
} else if (!strncmp(VAR_3, "nclc", 4)) {
switch (VAR_4) {
case 1: st->codec->VAR_4 = AVCOL_PRI_BT709; break;
case 5: st->codec->VAR_4 = AVCOL_PRI_SMPTE170M; break;
case 6: st->codec->VAR_4 = AVCOL_PRI_SMPTE240M; break;
}
switch (VAR_5) {
case 1: st->codec->VAR_5 = AVCOL_TRC_BT709; break;
case 7: st->codec->VAR_5 = AVCOL_TRC_SMPTE240M; break;
}
switch (VAR_6) {
case 1: st->codec->colorspace = AVCOL_SPC_BT709; break;
case 6: st->codec->colorspace = AVCOL_SPC_BT470BG; break;
case 7: st->codec->colorspace = AVCOL_SPC_SMPTE240M; break;
}
}
av_log(VAR_0->fc, AV_LOG_TRACE, "\n");
return 0;
}
| [
"static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2)\n{",
"AVStream *st;",
"char VAR_3[5] = { 0 };",
"int VAR_4, VAR_5, VAR_6;",
"if (VAR_0->fc->nb_streams < 1)\nreturn 0;",
"st = VAR_0->fc->streams[VAR_0->fc->nb_streams - 1];",
"avio_read(VAR_1, VAR_3, 4);",
"if (strncmp(VAR_3, \"nclx\", 4) &&\nstrncmp(VAR_3, \"nclc\", 4)) {",
"av_log(VAR_0->fc, AV_LOG_WARNING, \"unsupported VAR_3 %s\\n\",\nVAR_3);",
"return 0;",
"}",
"VAR_4 = avio_rb16(VAR_1);",
"VAR_5 = avio_rb16(VAR_1);",
"VAR_6 = avio_rb16(VAR_1);",
"av_log(VAR_0->fc, AV_LOG_TRACE,\n\"%s: pri %\"PRIu16\" trc %\"PRIu16\" matrix %\"PRIu16\"\",\nVAR_3, VAR_4, VAR_5, VAR_6);",
"if (!strncmp(VAR_3, \"nclx\", 4)) {",
"uint8_t color_range = avio_r8(VAR_1) >> 7;",
"av_log(VAR_0->fc, AV_LOG_TRACE, \" full %\"PRIu8\"\", color_range);",
"if (color_range)\nst->codec->color_range = AVCOL_RANGE_JPEG;",
"else\nst->codec->color_range = AVCOL_RANGE_MPEG;",
"if (VAR_4 >= AVCOL_PRI_FILM)\nVAR_4 = AVCOL_PRI_UNSPECIFIED;",
"if ((VAR_5 >= AVCOL_TRC_LINEAR &&\nVAR_5 <= AVCOL_TRC_LOG_SQRT) ||\nVAR_5 >= AVCOL_TRC_BT2020_10)\nVAR_5 = AVCOL_TRC_UNSPECIFIED;",
"if (VAR_6 >= AVCOL_SPC_BT2020_NCL)\nVAR_6 = AVCOL_SPC_UNSPECIFIED;",
"st->codec->VAR_4 = VAR_4;",
"st->codec->VAR_5 = VAR_5;",
"st->codec->colorspace = VAR_6;",
"} else if (!strncmp(VAR_3, \"nclc\", 4)) {",
"switch (VAR_4) {",
"case 1: st->codec->VAR_4 = AVCOL_PRI_BT709; break;",
"case 5: st->codec->VAR_4 = AVCOL_PRI_SMPTE170M; break;",
"case 6: st->codec->VAR_4 = AVCOL_PRI_SMPTE240M; break;",
"}",
"switch (VAR_5) {",
"case 1: st->codec->VAR_5 = AVCOL_TRC_BT709; break;",
"case 7: st->codec->VAR_5 = AVCOL_TRC_SMPTE240M; break;",
"}",
"switch (VAR_6) {",
"case 1: st->codec->colorspace = AVCOL_SPC_BT709; break;",
"case 6: st->codec->colorspace = AVCOL_SPC_BT470BG; break;",
"case 7: st->codec->colorspace = AVCOL_SPC_SMPTE240M; break;",
"}",
"}",
"av_log(VAR_0->fc, AV_LOG_TRACE, \"\\n\");",
"return 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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
17
],
[
21
],
[
23,
25
],
[
27,
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
45,
47,
49
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63,
65
],
[
71,
73
],
[
75,
77,
79,
81
],
[
83,
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
]
]
|
14,322 | void gen_intermediate_code(CPUOpenRISCState *env, struct TranslationBlock *tb)
{
OpenRISCCPU *cpu = openrisc_env_get_cpu(env);
CPUState *cs = CPU(cpu);
struct DisasContext ctx, *dc = &ctx;
uint32_t pc_start;
uint32_t next_page_start;
int num_insns;
int max_insns;
pc_start = tb->pc;
dc->tb = tb;
dc->is_jmp = DISAS_NEXT;
dc->ppc = pc_start;
dc->pc = pc_start;
dc->flags = cpu->env.cpucfgr;
dc->mem_idx = cpu_mmu_index(&cpu->env, false);
dc->synced_flags = dc->tb_flags = tb->flags;
dc->delayed_branch = !!(dc->tb_flags & D_FLAG);
dc->singlestep_enabled = cs->singlestep_enabled;
next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0) {
max_insns = CF_COUNT_MASK;
}
if (max_insns > TCG_MAX_INSNS) {
max_insns = TCG_MAX_INSNS;
}
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(pc_start)) {
qemu_log_lock();
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
}
gen_tb_start(tb);
do {
tcg_gen_insn_start(dc->pc);
num_insns++;
if (unlikely(cpu_breakpoint_test(cs, dc->pc, BP_ANY))) {
tcg_gen_movi_tl(cpu_pc, dc->pc);
gen_exception(dc, EXCP_DEBUG);
dc->is_jmp = DISAS_UPDATE;
/* The address covered by the breakpoint must be included in
[tb->pc, tb->pc + tb->size) in order to for it to be
properly cleared -- thus we increment the PC here so that
the logic setting tb->size below does the right thing. */
dc->pc += 4;
break;
}
if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
}
dc->ppc = dc->pc - 4;
dc->npc = dc->pc + 4;
tcg_gen_movi_tl(cpu_ppc, dc->ppc);
tcg_gen_movi_tl(cpu_npc, dc->npc);
disas_openrisc_insn(dc, cpu);
dc->pc = dc->npc;
/* delay slot */
if (dc->delayed_branch) {
dc->delayed_branch--;
if (!dc->delayed_branch) {
dc->tb_flags &= ~D_FLAG;
gen_sync_flags(dc);
tcg_gen_mov_tl(cpu_pc, jmp_pc);
tcg_gen_mov_tl(cpu_npc, jmp_pc);
tcg_gen_movi_tl(jmp_pc, 0);
tcg_gen_exit_tb(0);
dc->is_jmp = DISAS_JUMP;
break;
}
}
} while (!dc->is_jmp
&& !tcg_op_buf_full()
&& !cs->singlestep_enabled
&& !singlestep
&& (dc->pc < next_page_start)
&& num_insns < max_insns);
if (tb->cflags & CF_LAST_IO) {
gen_io_end();
}
if (dc->is_jmp == DISAS_NEXT) {
dc->is_jmp = DISAS_UPDATE;
tcg_gen_movi_tl(cpu_pc, dc->pc);
}
if (unlikely(cs->singlestep_enabled)) {
if (dc->is_jmp == DISAS_NEXT) {
tcg_gen_movi_tl(cpu_pc, dc->pc);
}
gen_exception(dc, EXCP_DEBUG);
} else {
switch (dc->is_jmp) {
case DISAS_NEXT:
gen_goto_tb(dc, 0, dc->pc);
break;
default:
case DISAS_JUMP:
break;
case DISAS_UPDATE:
/* indicate that the hash table must be used
to find the next TB */
tcg_gen_exit_tb(0);
break;
case DISAS_TB_JUMP:
/* nothing more to generate */
break;
}
}
gen_tb_end(tb, num_insns);
tb->size = dc->pc - pc_start;
tb->icount = num_insns;
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(pc_start)) {
log_target_disas(cs, pc_start, tb->size, 0);
qemu_log("\n");
qemu_log_unlock();
}
}
| true | qemu | 0c53d7342b4e8412f3b81eed67f053304813dc5d | void gen_intermediate_code(CPUOpenRISCState *env, struct TranslationBlock *tb)
{
OpenRISCCPU *cpu = openrisc_env_get_cpu(env);
CPUState *cs = CPU(cpu);
struct DisasContext ctx, *dc = &ctx;
uint32_t pc_start;
uint32_t next_page_start;
int num_insns;
int max_insns;
pc_start = tb->pc;
dc->tb = tb;
dc->is_jmp = DISAS_NEXT;
dc->ppc = pc_start;
dc->pc = pc_start;
dc->flags = cpu->env.cpucfgr;
dc->mem_idx = cpu_mmu_index(&cpu->env, false);
dc->synced_flags = dc->tb_flags = tb->flags;
dc->delayed_branch = !!(dc->tb_flags & D_FLAG);
dc->singlestep_enabled = cs->singlestep_enabled;
next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0) {
max_insns = CF_COUNT_MASK;
}
if (max_insns > TCG_MAX_INSNS) {
max_insns = TCG_MAX_INSNS;
}
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(pc_start)) {
qemu_log_lock();
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
}
gen_tb_start(tb);
do {
tcg_gen_insn_start(dc->pc);
num_insns++;
if (unlikely(cpu_breakpoint_test(cs, dc->pc, BP_ANY))) {
tcg_gen_movi_tl(cpu_pc, dc->pc);
gen_exception(dc, EXCP_DEBUG);
dc->is_jmp = DISAS_UPDATE;
dc->pc += 4;
break;
}
if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
}
dc->ppc = dc->pc - 4;
dc->npc = dc->pc + 4;
tcg_gen_movi_tl(cpu_ppc, dc->ppc);
tcg_gen_movi_tl(cpu_npc, dc->npc);
disas_openrisc_insn(dc, cpu);
dc->pc = dc->npc;
if (dc->delayed_branch) {
dc->delayed_branch--;
if (!dc->delayed_branch) {
dc->tb_flags &= ~D_FLAG;
gen_sync_flags(dc);
tcg_gen_mov_tl(cpu_pc, jmp_pc);
tcg_gen_mov_tl(cpu_npc, jmp_pc);
tcg_gen_movi_tl(jmp_pc, 0);
tcg_gen_exit_tb(0);
dc->is_jmp = DISAS_JUMP;
break;
}
}
} while (!dc->is_jmp
&& !tcg_op_buf_full()
&& !cs->singlestep_enabled
&& !singlestep
&& (dc->pc < next_page_start)
&& num_insns < max_insns);
if (tb->cflags & CF_LAST_IO) {
gen_io_end();
}
if (dc->is_jmp == DISAS_NEXT) {
dc->is_jmp = DISAS_UPDATE;
tcg_gen_movi_tl(cpu_pc, dc->pc);
}
if (unlikely(cs->singlestep_enabled)) {
if (dc->is_jmp == DISAS_NEXT) {
tcg_gen_movi_tl(cpu_pc, dc->pc);
}
gen_exception(dc, EXCP_DEBUG);
} else {
switch (dc->is_jmp) {
case DISAS_NEXT:
gen_goto_tb(dc, 0, dc->pc);
break;
default:
case DISAS_JUMP:
break;
case DISAS_UPDATE:
tcg_gen_exit_tb(0);
break;
case DISAS_TB_JUMP:
break;
}
}
gen_tb_end(tb, num_insns);
tb->size = dc->pc - pc_start;
tb->icount = num_insns;
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(pc_start)) {
log_target_disas(cs, pc_start, tb->size, 0);
qemu_log("\n");
qemu_log_unlock();
}
}
| {
"code": [
" dc->delayed_branch = !!(dc->tb_flags & D_FLAG);"
],
"line_no": [
39
]
} | void FUNC_0(CPUOpenRISCState *VAR_0, struct TranslationBlock *VAR_1)
{
OpenRISCCPU *cpu = openrisc_env_get_cpu(VAR_0);
CPUState *cs = CPU(cpu);
struct DisasContext VAR_2, *VAR_3 = &VAR_2;
uint32_t pc_start;
uint32_t next_page_start;
int VAR_4;
int VAR_5;
pc_start = VAR_1->pc;
VAR_3->VAR_1 = VAR_1;
VAR_3->is_jmp = DISAS_NEXT;
VAR_3->ppc = pc_start;
VAR_3->pc = pc_start;
VAR_3->flags = cpu->VAR_0.cpucfgr;
VAR_3->mem_idx = cpu_mmu_index(&cpu->VAR_0, false);
VAR_3->synced_flags = VAR_3->tb_flags = VAR_1->flags;
VAR_3->delayed_branch = !!(VAR_3->tb_flags & D_FLAG);
VAR_3->singlestep_enabled = cs->singlestep_enabled;
next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
VAR_4 = 0;
VAR_5 = VAR_1->cflags & CF_COUNT_MASK;
if (VAR_5 == 0) {
VAR_5 = CF_COUNT_MASK;
}
if (VAR_5 > TCG_MAX_INSNS) {
VAR_5 = TCG_MAX_INSNS;
}
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(pc_start)) {
qemu_log_lock();
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
}
gen_tb_start(VAR_1);
do {
tcg_gen_insn_start(VAR_3->pc);
VAR_4++;
if (unlikely(cpu_breakpoint_test(cs, VAR_3->pc, BP_ANY))) {
tcg_gen_movi_tl(cpu_pc, VAR_3->pc);
gen_exception(VAR_3, EXCP_DEBUG);
VAR_3->is_jmp = DISAS_UPDATE;
VAR_3->pc += 4;
break;
}
if (VAR_4 == VAR_5 && (VAR_1->cflags & CF_LAST_IO)) {
gen_io_start();
}
VAR_3->ppc = VAR_3->pc - 4;
VAR_3->npc = VAR_3->pc + 4;
tcg_gen_movi_tl(cpu_ppc, VAR_3->ppc);
tcg_gen_movi_tl(cpu_npc, VAR_3->npc);
disas_openrisc_insn(VAR_3, cpu);
VAR_3->pc = VAR_3->npc;
if (VAR_3->delayed_branch) {
VAR_3->delayed_branch--;
if (!VAR_3->delayed_branch) {
VAR_3->tb_flags &= ~D_FLAG;
gen_sync_flags(VAR_3);
tcg_gen_mov_tl(cpu_pc, jmp_pc);
tcg_gen_mov_tl(cpu_npc, jmp_pc);
tcg_gen_movi_tl(jmp_pc, 0);
tcg_gen_exit_tb(0);
VAR_3->is_jmp = DISAS_JUMP;
break;
}
}
} while (!VAR_3->is_jmp
&& !tcg_op_buf_full()
&& !cs->singlestep_enabled
&& !singlestep
&& (VAR_3->pc < next_page_start)
&& VAR_4 < VAR_5);
if (VAR_1->cflags & CF_LAST_IO) {
gen_io_end();
}
if (VAR_3->is_jmp == DISAS_NEXT) {
VAR_3->is_jmp = DISAS_UPDATE;
tcg_gen_movi_tl(cpu_pc, VAR_3->pc);
}
if (unlikely(cs->singlestep_enabled)) {
if (VAR_3->is_jmp == DISAS_NEXT) {
tcg_gen_movi_tl(cpu_pc, VAR_3->pc);
}
gen_exception(VAR_3, EXCP_DEBUG);
} else {
switch (VAR_3->is_jmp) {
case DISAS_NEXT:
gen_goto_tb(VAR_3, 0, VAR_3->pc);
break;
default:
case DISAS_JUMP:
break;
case DISAS_UPDATE:
tcg_gen_exit_tb(0);
break;
case DISAS_TB_JUMP:
break;
}
}
gen_tb_end(VAR_1, VAR_4);
VAR_1->size = VAR_3->pc - pc_start;
VAR_1->icount = VAR_4;
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(pc_start)) {
log_target_disas(cs, pc_start, VAR_1->size, 0);
qemu_log("\n");
qemu_log_unlock();
}
}
| [
"void FUNC_0(CPUOpenRISCState *VAR_0, struct TranslationBlock *VAR_1)\n{",
"OpenRISCCPU *cpu = openrisc_env_get_cpu(VAR_0);",
"CPUState *cs = CPU(cpu);",
"struct DisasContext VAR_2, *VAR_3 = &VAR_2;",
"uint32_t pc_start;",
"uint32_t next_page_start;",
"int VAR_4;",
"int VAR_5;",
"pc_start = VAR_1->pc;",
"VAR_3->VAR_1 = VAR_1;",
"VAR_3->is_jmp = DISAS_NEXT;",
"VAR_3->ppc = pc_start;",
"VAR_3->pc = pc_start;",
"VAR_3->flags = cpu->VAR_0.cpucfgr;",
"VAR_3->mem_idx = cpu_mmu_index(&cpu->VAR_0, false);",
"VAR_3->synced_flags = VAR_3->tb_flags = VAR_1->flags;",
"VAR_3->delayed_branch = !!(VAR_3->tb_flags & D_FLAG);",
"VAR_3->singlestep_enabled = cs->singlestep_enabled;",
"next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;",
"VAR_4 = 0;",
"VAR_5 = VAR_1->cflags & CF_COUNT_MASK;",
"if (VAR_5 == 0) {",
"VAR_5 = CF_COUNT_MASK;",
"}",
"if (VAR_5 > TCG_MAX_INSNS) {",
"VAR_5 = TCG_MAX_INSNS;",
"}",
"if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)\n&& qemu_log_in_addr_range(pc_start)) {",
"qemu_log_lock();",
"qemu_log(\"----------------\\n\");",
"qemu_log(\"IN: %s\\n\", lookup_symbol(pc_start));",
"}",
"gen_tb_start(VAR_1);",
"do {",
"tcg_gen_insn_start(VAR_3->pc);",
"VAR_4++;",
"if (unlikely(cpu_breakpoint_test(cs, VAR_3->pc, BP_ANY))) {",
"tcg_gen_movi_tl(cpu_pc, VAR_3->pc);",
"gen_exception(VAR_3, EXCP_DEBUG);",
"VAR_3->is_jmp = DISAS_UPDATE;",
"VAR_3->pc += 4;",
"break;",
"}",
"if (VAR_4 == VAR_5 && (VAR_1->cflags & CF_LAST_IO)) {",
"gen_io_start();",
"}",
"VAR_3->ppc = VAR_3->pc - 4;",
"VAR_3->npc = VAR_3->pc + 4;",
"tcg_gen_movi_tl(cpu_ppc, VAR_3->ppc);",
"tcg_gen_movi_tl(cpu_npc, VAR_3->npc);",
"disas_openrisc_insn(VAR_3, cpu);",
"VAR_3->pc = VAR_3->npc;",
"if (VAR_3->delayed_branch) {",
"VAR_3->delayed_branch--;",
"if (!VAR_3->delayed_branch) {",
"VAR_3->tb_flags &= ~D_FLAG;",
"gen_sync_flags(VAR_3);",
"tcg_gen_mov_tl(cpu_pc, jmp_pc);",
"tcg_gen_mov_tl(cpu_npc, jmp_pc);",
"tcg_gen_movi_tl(jmp_pc, 0);",
"tcg_gen_exit_tb(0);",
"VAR_3->is_jmp = DISAS_JUMP;",
"break;",
"}",
"}",
"} while (!VAR_3->is_jmp",
"&& !tcg_op_buf_full()\n&& !cs->singlestep_enabled\n&& !singlestep\n&& (VAR_3->pc < next_page_start)\n&& VAR_4 < VAR_5);",
"if (VAR_1->cflags & CF_LAST_IO) {",
"gen_io_end();",
"}",
"if (VAR_3->is_jmp == DISAS_NEXT) {",
"VAR_3->is_jmp = DISAS_UPDATE;",
"tcg_gen_movi_tl(cpu_pc, VAR_3->pc);",
"}",
"if (unlikely(cs->singlestep_enabled)) {",
"if (VAR_3->is_jmp == DISAS_NEXT) {",
"tcg_gen_movi_tl(cpu_pc, VAR_3->pc);",
"}",
"gen_exception(VAR_3, EXCP_DEBUG);",
"} else {",
"switch (VAR_3->is_jmp) {",
"case DISAS_NEXT:\ngen_goto_tb(VAR_3, 0, VAR_3->pc);",
"break;",
"default:\ncase DISAS_JUMP:\nbreak;",
"case DISAS_UPDATE:\ntcg_gen_exit_tb(0);",
"break;",
"case DISAS_TB_JUMP:\nbreak;",
"}",
"}",
"gen_tb_end(VAR_1, VAR_4);",
"VAR_1->size = VAR_3->pc - pc_start;",
"VAR_1->icount = VAR_4;",
"if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)\n&& qemu_log_in_addr_range(pc_start)) {",
"log_target_disas(cs, pc_start, VAR_1->size, 0);",
"qemu_log(\"\\n\");",
"qemu_log_unlock();",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165,
167,
169,
171,
173
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205,
207
],
[
209
],
[
211,
213,
215
],
[
217,
223
],
[
225
],
[
227,
231
],
[
233
],
[
235
],
[
239
],
[
243
],
[
245
],
[
249,
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
]
]
|
14,323 | static int videotoolbox_common_end_frame(AVCodecContext *avctx, AVFrame *frame)
{
int status;
AVVideotoolboxContext *videotoolbox = avctx->hwaccel_context;
VTContext *vtctx = avctx->internal->hwaccel_priv_data;
av_buffer_unref(&frame->buf[0]);
if (!videotoolbox->session || !vtctx->bitstream)
return AVERROR_INVALIDDATA;
status = videotoolbox_session_decode_frame(avctx);
if (status) {
av_log(avctx, AV_LOG_ERROR, "Failed to decode frame (%d)\n", status);
return AVERROR_UNKNOWN;
}
if (!vtctx->frame)
return AVERROR_UNKNOWN;
return ff_videotoolbox_buffer_create(vtctx, frame);
}
| true | FFmpeg | b6eaa3928e198554a3934dd5ad6eac4d16f27df2 | static int videotoolbox_common_end_frame(AVCodecContext *avctx, AVFrame *frame)
{
int status;
AVVideotoolboxContext *videotoolbox = avctx->hwaccel_context;
VTContext *vtctx = avctx->internal->hwaccel_priv_data;
av_buffer_unref(&frame->buf[0]);
if (!videotoolbox->session || !vtctx->bitstream)
return AVERROR_INVALIDDATA;
status = videotoolbox_session_decode_frame(avctx);
if (status) {
av_log(avctx, AV_LOG_ERROR, "Failed to decode frame (%d)\n", status);
return AVERROR_UNKNOWN;
}
if (!vtctx->frame)
return AVERROR_UNKNOWN;
return ff_videotoolbox_buffer_create(vtctx, frame);
}
| {
"code": [
" av_buffer_unref(&frame->buf[0]);"
],
"line_no": [
13
]
} | static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1)
{
int VAR_2;
AVVideotoolboxContext *videotoolbox = VAR_0->hwaccel_context;
VTContext *vtctx = VAR_0->internal->hwaccel_priv_data;
av_buffer_unref(&VAR_1->buf[0]);
if (!videotoolbox->session || !vtctx->bitstream)
return AVERROR_INVALIDDATA;
VAR_2 = videotoolbox_session_decode_frame(VAR_0);
if (VAR_2) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to decode VAR_1 (%d)\n", VAR_2);
return AVERROR_UNKNOWN;
}
if (!vtctx->VAR_1)
return AVERROR_UNKNOWN;
return ff_videotoolbox_buffer_create(vtctx, VAR_1);
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1)\n{",
"int VAR_2;",
"AVVideotoolboxContext *videotoolbox = VAR_0->hwaccel_context;",
"VTContext *vtctx = VAR_0->internal->hwaccel_priv_data;",
"av_buffer_unref(&VAR_1->buf[0]);",
"if (!videotoolbox->session || !vtctx->bitstream)\nreturn AVERROR_INVALIDDATA;",
"VAR_2 = videotoolbox_session_decode_frame(VAR_0);",
"if (VAR_2) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to decode VAR_1 (%d)\\n\", VAR_2);",
"return AVERROR_UNKNOWN;",
"}",
"if (!vtctx->VAR_1)\nreturn AVERROR_UNKNOWN;",
"return ff_videotoolbox_buffer_create(vtctx, VAR_1);",
"}"
]
| [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17,
19
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37,
39
],
[
43
],
[
45
]
]
|
14,325 | static void block_job_completed_single(BlockJob *job)
{
if (!job->ret) {
if (job->driver->commit) {
job->driver->commit(job);
} else {
if (job->driver->abort) {
job->driver->abort(job);
if (job->cb) {
job->cb(job->opaque, job->ret);
if (block_job_is_cancelled(job)) {
block_job_event_cancelled(job);
} else {
const char *msg = NULL;
if (job->ret < 0) {
msg = strerror(-job->ret);
block_job_event_completed(job, msg);
if (job->txn) {
QLIST_REMOVE(job, txn_list);
block_job_txn_unref(job->txn);
block_job_unref(job);
| true | qemu | e8a40bf71d606f9f87866fb2461eaed52814b38e | static void block_job_completed_single(BlockJob *job)
{
if (!job->ret) {
if (job->driver->commit) {
job->driver->commit(job);
} else {
if (job->driver->abort) {
job->driver->abort(job);
if (job->cb) {
job->cb(job->opaque, job->ret);
if (block_job_is_cancelled(job)) {
block_job_event_cancelled(job);
} else {
const char *msg = NULL;
if (job->ret < 0) {
msg = strerror(-job->ret);
block_job_event_completed(job, msg);
if (job->txn) {
QLIST_REMOVE(job, txn_list);
block_job_txn_unref(job->txn);
block_job_unref(job);
| {
"code": [],
"line_no": []
} | static void FUNC_0(BlockJob *VAR_0)
{
if (!VAR_0->ret) {
if (VAR_0->driver->commit) {
VAR_0->driver->commit(VAR_0);
} else {
if (VAR_0->driver->abort) {
VAR_0->driver->abort(VAR_0);
if (VAR_0->cb) {
VAR_0->cb(VAR_0->opaque, VAR_0->ret);
if (block_job_is_cancelled(VAR_0)) {
block_job_event_cancelled(VAR_0);
} else {
const char *VAR_1 = NULL;
if (VAR_0->ret < 0) {
VAR_1 = strerror(-VAR_0->ret);
block_job_event_completed(VAR_0, VAR_1);
if (VAR_0->txn) {
QLIST_REMOVE(VAR_0, txn_list);
block_job_txn_unref(VAR_0->txn);
block_job_unref(VAR_0);
| [
"static void FUNC_0(BlockJob *VAR_0)\n{",
"if (!VAR_0->ret) {",
"if (VAR_0->driver->commit) {",
"VAR_0->driver->commit(VAR_0);",
"} else {",
"if (VAR_0->driver->abort) {",
"VAR_0->driver->abort(VAR_0);",
"if (VAR_0->cb) {",
"VAR_0->cb(VAR_0->opaque, VAR_0->ret);",
"if (block_job_is_cancelled(VAR_0)) {",
"block_job_event_cancelled(VAR_0);",
"} else {",
"const char *VAR_1 = NULL;",
"if (VAR_0->ret < 0) {",
"VAR_1 = strerror(-VAR_0->ret);",
"block_job_event_completed(VAR_0, VAR_1);",
"if (VAR_0->txn) {",
"QLIST_REMOVE(VAR_0, txn_list);",
"block_job_txn_unref(VAR_0->txn);",
"block_job_unref(VAR_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
],
[
12
],
[
14
],
[
16
],
[
25
],
[
27
],
[
30
],
[
32
],
[
34
],
[
36
],
[
38
],
[
40
],
[
43
],
[
48
],
[
50
],
[
52
],
[
55
]
]
|
14,326 | static UHCIQueue *uhci_queue_get(UHCIState *s, UHCI_TD *td, USBEndpoint *ep)
{
uint32_t token = uhci_queue_token(td);
UHCIQueue *queue;
QTAILQ_FOREACH(queue, &s->queues, next) {
if (queue->token == token) {
return queue;
}
}
queue = g_new0(UHCIQueue, 1);
queue->uhci = s;
queue->token = token;
queue->ep = ep;
QTAILQ_INIT(&queue->asyncs);
QTAILQ_INSERT_HEAD(&s->queues, queue, next);
trace_usb_uhci_queue_add(queue->token);
return queue;
}
| true | qemu | 66a08cbe6ad1aebec8eecf58b3ba042e19dd1649 | static UHCIQueue *uhci_queue_get(UHCIState *s, UHCI_TD *td, USBEndpoint *ep)
{
uint32_t token = uhci_queue_token(td);
UHCIQueue *queue;
QTAILQ_FOREACH(queue, &s->queues, next) {
if (queue->token == token) {
return queue;
}
}
queue = g_new0(UHCIQueue, 1);
queue->uhci = s;
queue->token = token;
queue->ep = ep;
QTAILQ_INIT(&queue->asyncs);
QTAILQ_INSERT_HEAD(&s->queues, queue, next);
trace_usb_uhci_queue_add(queue->token);
return queue;
}
| {
"code": [
"static UHCIQueue *uhci_queue_get(UHCIState *s, UHCI_TD *td, USBEndpoint *ep)",
" uint32_t token = uhci_queue_token(td);",
" QTAILQ_FOREACH(queue, &s->queues, next) {",
" if (queue->token == token) {",
" return queue;",
" queue->token = token;"
],
"line_no": [
1,
5,
11,
13,
15,
27
]
} | static UHCIQueue *FUNC_0(UHCIState *s, UHCI_TD *td, USBEndpoint *ep)
{
uint32_t token = uhci_queue_token(td);
UHCIQueue *queue;
QTAILQ_FOREACH(queue, &s->queues, next) {
if (queue->token == token) {
return queue;
}
}
queue = g_new0(UHCIQueue, 1);
queue->uhci = s;
queue->token = token;
queue->ep = ep;
QTAILQ_INIT(&queue->asyncs);
QTAILQ_INSERT_HEAD(&s->queues, queue, next);
trace_usb_uhci_queue_add(queue->token);
return queue;
}
| [
"static UHCIQueue *FUNC_0(UHCIState *s, UHCI_TD *td, USBEndpoint *ep)\n{",
"uint32_t token = uhci_queue_token(td);",
"UHCIQueue *queue;",
"QTAILQ_FOREACH(queue, &s->queues, next) {",
"if (queue->token == token) {",
"return queue;",
"}",
"}",
"queue = g_new0(UHCIQueue, 1);",
"queue->uhci = s;",
"queue->token = token;",
"queue->ep = ep;",
"QTAILQ_INIT(&queue->asyncs);",
"QTAILQ_INSERT_HEAD(&s->queues, queue, next);",
"trace_usb_uhci_queue_add(queue->token);",
"return queue;",
"}"
]
| [
1,
1,
0,
1,
1,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
]
]
|
14,327 | HBitmap *hbitmap_alloc(uint64_t size, int granularity)
{
HBitmap *hb = g_malloc0(sizeof (struct HBitmap));
unsigned i;
assert(granularity >= 0 && granularity < 64);
size = (size + (1ULL << granularity) - 1) >> granularity;
assert(size <= ((uint64_t)1 << HBITMAP_LOG_MAX_SIZE));
hb->size = size;
hb->granularity = granularity;
for (i = HBITMAP_LEVELS; i-- > 0; ) {
size = MAX((size + BITS_PER_LONG - 1) >> BITS_PER_LEVEL, 1);
hb->levels[i] = g_malloc0(size * sizeof(unsigned long));
}
/* We necessarily have free bits in level 0 due to the definition
* of HBITMAP_LEVELS, so use one for a sentinel. This speeds up
* hbitmap_iter_skip_words.
*/
assert(size == 1);
hb->levels[0][0] |= 1UL << (BITS_PER_LONG - 1);
return hb;
}
| true | qemu | e1cf5582644ef63528993fb2b88dd3b43b9914c6 | HBitmap *hbitmap_alloc(uint64_t size, int granularity)
{
HBitmap *hb = g_malloc0(sizeof (struct HBitmap));
unsigned i;
assert(granularity >= 0 && granularity < 64);
size = (size + (1ULL << granularity) - 1) >> granularity;
assert(size <= ((uint64_t)1 << HBITMAP_LOG_MAX_SIZE));
hb->size = size;
hb->granularity = granularity;
for (i = HBITMAP_LEVELS; i-- > 0; ) {
size = MAX((size + BITS_PER_LONG - 1) >> BITS_PER_LEVEL, 1);
hb->levels[i] = g_malloc0(size * sizeof(unsigned long));
}
assert(size == 1);
hb->levels[0][0] |= 1UL << (BITS_PER_LONG - 1);
return hb;
}
| {
"code": [
" HBitmap *hb = g_malloc0(sizeof (struct HBitmap));",
" hb->levels[i] = g_malloc0(size * sizeof(unsigned long));"
],
"line_no": [
5,
27
]
} | HBitmap *FUNC_0(uint64_t size, int granularity)
{
HBitmap *hb = g_malloc0(sizeof (struct HBitmap));
unsigned VAR_0;
assert(granularity >= 0 && granularity < 64);
size = (size + (1ULL << granularity) - 1) >> granularity;
assert(size <= ((uint64_t)1 << HBITMAP_LOG_MAX_SIZE));
hb->size = size;
hb->granularity = granularity;
for (VAR_0 = HBITMAP_LEVELS; VAR_0-- > 0; ) {
size = MAX((size + BITS_PER_LONG - 1) >> BITS_PER_LEVEL, 1);
hb->levels[VAR_0] = g_malloc0(size * sizeof(unsigned long));
}
assert(size == 1);
hb->levels[0][0] |= 1UL << (BITS_PER_LONG - 1);
return hb;
}
| [
"HBitmap *FUNC_0(uint64_t size, int granularity)\n{",
"HBitmap *hb = g_malloc0(sizeof (struct HBitmap));",
"unsigned VAR_0;",
"assert(granularity >= 0 && granularity < 64);",
"size = (size + (1ULL << granularity) - 1) >> granularity;",
"assert(size <= ((uint64_t)1 << HBITMAP_LOG_MAX_SIZE));",
"hb->size = size;",
"hb->granularity = granularity;",
"for (VAR_0 = HBITMAP_LEVELS; VAR_0-- > 0; ) {",
"size = MAX((size + BITS_PER_LONG - 1) >> BITS_PER_LEVEL, 1);",
"hb->levels[VAR_0] = g_malloc0(size * sizeof(unsigned long));",
"}",
"assert(size == 1);",
"hb->levels[0][0] |= 1UL << (BITS_PER_LONG - 1);",
"return hb;",
"}"
]
| [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
41
],
[
43
],
[
45
],
[
47
]
]
|
14,328 | static int mp3_read_header(AVFormatContext *s)
{
MP3DecContext *mp3 = s->priv_data;
AVStream *st;
int64_t off;
int ret;
int i;
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_MP3;
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
st->start_time = 0;
// lcm of all mp3 sample rates
avpriv_set_pts_info(st, 64, 1, 14112000);
s->pb->maxsize = -1;
off = avio_tell(s->pb);
if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))
ff_id3v1_read(s);
if(s->pb->seekable)
mp3->filesize = avio_size(s->pb);
if (mp3_parse_vbr_tags(s, st, off) < 0)
avio_seek(s->pb, off, SEEK_SET);
ret = ff_replaygain_export(st, s->metadata);
if (ret < 0)
return ret;
off = avio_tell(s->pb);
for (i = 0; i < 64 * 1024; i++) {
uint32_t header, header2;
int frame_size;
if (!(i&1023))
ffio_ensure_seekback(s->pb, i + 1024 + 4);
frame_size = check(s->pb, off + i, &header);
if (frame_size > 0) {
avio_seek(s->pb, off, SEEK_SET);
ffio_ensure_seekback(s->pb, i + 1024 + frame_size + 4);
if (check(s->pb, off + i + frame_size, &header2) >= 0 &&
(header & SAME_HEADER_MASK) == (header2 & SAME_HEADER_MASK))
{
av_log(s, AV_LOG_INFO, "Skipping %d bytes of junk at %"PRId64".\n", i, off);
avio_seek(s->pb, off + i, SEEK_SET);
break;
}
}
avio_seek(s->pb, off, SEEK_SET);
}
// the seek index is relative to the end of the xing vbr headers
for (i = 0; i < st->nb_index_entries; i++)
st->index_entries[i].pos += avio_tell(s->pb);
/* the parameters will be extracted from the compressed bitstream */
return 0;
}
| false | FFmpeg | 1c9215e580b6436d1aff3c0118ef01269712ebd9 | static int mp3_read_header(AVFormatContext *s)
{
MP3DecContext *mp3 = s->priv_data;
AVStream *st;
int64_t off;
int ret;
int i;
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_MP3;
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
st->start_time = 0;
avpriv_set_pts_info(st, 64, 1, 14112000);
s->pb->maxsize = -1;
off = avio_tell(s->pb);
if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))
ff_id3v1_read(s);
if(s->pb->seekable)
mp3->filesize = avio_size(s->pb);
if (mp3_parse_vbr_tags(s, st, off) < 0)
avio_seek(s->pb, off, SEEK_SET);
ret = ff_replaygain_export(st, s->metadata);
if (ret < 0)
return ret;
off = avio_tell(s->pb);
for (i = 0; i < 64 * 1024; i++) {
uint32_t header, header2;
int frame_size;
if (!(i&1023))
ffio_ensure_seekback(s->pb, i + 1024 + 4);
frame_size = check(s->pb, off + i, &header);
if (frame_size > 0) {
avio_seek(s->pb, off, SEEK_SET);
ffio_ensure_seekback(s->pb, i + 1024 + frame_size + 4);
if (check(s->pb, off + i + frame_size, &header2) >= 0 &&
(header & SAME_HEADER_MASK) == (header2 & SAME_HEADER_MASK))
{
av_log(s, AV_LOG_INFO, "Skipping %d bytes of junk at %"PRId64".\n", i, off);
avio_seek(s->pb, off + i, SEEK_SET);
break;
}
}
avio_seek(s->pb, off, SEEK_SET);
}
for (i = 0; i < st->nb_index_entries; i++)
st->index_entries[i].pos += avio_tell(s->pb);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
MP3DecContext *mp3 = VAR_0->priv_data;
AVStream *st;
int64_t off;
int VAR_1;
int VAR_2;
st = avformat_new_stream(VAR_0, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_MP3;
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
st->start_time = 0;
avpriv_set_pts_info(st, 64, 1, 14112000);
VAR_0->pb->maxsize = -1;
off = avio_tell(VAR_0->pb);
if (!av_dict_get(VAR_0->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))
ff_id3v1_read(VAR_0);
if(VAR_0->pb->seekable)
mp3->filesize = avio_size(VAR_0->pb);
if (mp3_parse_vbr_tags(VAR_0, st, off) < 0)
avio_seek(VAR_0->pb, off, SEEK_SET);
VAR_1 = ff_replaygain_export(st, VAR_0->metadata);
if (VAR_1 < 0)
return VAR_1;
off = avio_tell(VAR_0->pb);
for (VAR_2 = 0; VAR_2 < 64 * 1024; VAR_2++) {
uint32_t header, header2;
int VAR_3;
if (!(VAR_2&1023))
ffio_ensure_seekback(VAR_0->pb, VAR_2 + 1024 + 4);
VAR_3 = check(VAR_0->pb, off + VAR_2, &header);
if (VAR_3 > 0) {
avio_seek(VAR_0->pb, off, SEEK_SET);
ffio_ensure_seekback(VAR_0->pb, VAR_2 + 1024 + VAR_3 + 4);
if (check(VAR_0->pb, off + VAR_2 + VAR_3, &header2) >= 0 &&
(header & SAME_HEADER_MASK) == (header2 & SAME_HEADER_MASK))
{
av_log(VAR_0, AV_LOG_INFO, "Skipping %d bytes of junk at %"PRId64".\n", VAR_2, off);
avio_seek(VAR_0->pb, off + VAR_2, SEEK_SET);
break;
}
}
avio_seek(VAR_0->pb, off, SEEK_SET);
}
for (VAR_2 = 0; VAR_2 < st->nb_index_entries; VAR_2++)
st->index_entries[VAR_2].pos += avio_tell(VAR_0->pb);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"MP3DecContext *mp3 = VAR_0->priv_data;",
"AVStream *st;",
"int64_t off;",
"int VAR_1;",
"int VAR_2;",
"st = avformat_new_stream(VAR_0, NULL);",
"if (!st)\nreturn AVERROR(ENOMEM);",
"st->codec->codec_type = AVMEDIA_TYPE_AUDIO;",
"st->codec->codec_id = AV_CODEC_ID_MP3;",
"st->need_parsing = AVSTREAM_PARSE_FULL_RAW;",
"st->start_time = 0;",
"avpriv_set_pts_info(st, 64, 1, 14112000);",
"VAR_0->pb->maxsize = -1;",
"off = avio_tell(VAR_0->pb);",
"if (!av_dict_get(VAR_0->metadata, \"\", NULL, AV_DICT_IGNORE_SUFFIX))\nff_id3v1_read(VAR_0);",
"if(VAR_0->pb->seekable)\nmp3->filesize = avio_size(VAR_0->pb);",
"if (mp3_parse_vbr_tags(VAR_0, st, off) < 0)\navio_seek(VAR_0->pb, off, SEEK_SET);",
"VAR_1 = ff_replaygain_export(st, VAR_0->metadata);",
"if (VAR_1 < 0)\nreturn VAR_1;",
"off = avio_tell(VAR_0->pb);",
"for (VAR_2 = 0; VAR_2 < 64 * 1024; VAR_2++) {",
"uint32_t header, header2;",
"int VAR_3;",
"if (!(VAR_2&1023))\nffio_ensure_seekback(VAR_0->pb, VAR_2 + 1024 + 4);",
"VAR_3 = check(VAR_0->pb, off + VAR_2, &header);",
"if (VAR_3 > 0) {",
"avio_seek(VAR_0->pb, off, SEEK_SET);",
"ffio_ensure_seekback(VAR_0->pb, VAR_2 + 1024 + VAR_3 + 4);",
"if (check(VAR_0->pb, off + VAR_2 + VAR_3, &header2) >= 0 &&\n(header & SAME_HEADER_MASK) == (header2 & SAME_HEADER_MASK))\n{",
"av_log(VAR_0, AV_LOG_INFO, \"Skipping %d bytes of junk at %\"PRId64\".\\n\", VAR_2, off);",
"avio_seek(VAR_0->pb, off + VAR_2, SEEK_SET);",
"break;",
"}",
"}",
"avio_seek(VAR_0->pb, off, SEEK_SET);",
"}",
"for (VAR_2 = 0; VAR_2 < st->nb_index_entries; VAR_2++)",
"st->index_entries[VAR_2].pos += avio_tell(VAR_0->pb);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19,
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
37
],
[
41
],
[
43
],
[
47,
49
],
[
53,
55
],
[
59,
61
],
[
65
],
[
67,
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93,
95,
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
117
],
[
119
],
[
125
],
[
127
]
]
|
14,329 | static av_cold int close_decoder(AVCodecContext *avctx)
{
PGSSubContext *ctx = avctx->priv_data;
av_freep(&ctx->picture.rle);
ctx->picture.rle_buffer_size = 0;
return 0;
}
| false | FFmpeg | d150a147dac67faeaf6b1f25a523ae330168ee1e | static av_cold int close_decoder(AVCodecContext *avctx)
{
PGSSubContext *ctx = avctx->priv_data;
av_freep(&ctx->picture.rle);
ctx->picture.rle_buffer_size = 0;
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
PGSSubContext *ctx = avctx->priv_data;
av_freep(&ctx->picture.rle);
ctx->picture.rle_buffer_size = 0;
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"PGSSubContext *ctx = avctx->priv_data;",
"av_freep(&ctx->picture.rle);",
"ctx->picture.rle_buffer_size = 0;",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
15
],
[
17
]
]
|
14,330 | static int gsm_parse(AVCodecParserContext *s1, AVCodecContext *avctx,
const uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size)
{
GSMParseContext *s = s1->priv_data;
ParseContext *pc = &s->pc;
int next;
if (!s->block_size) {
switch (avctx->codec_id) {
case AV_CODEC_ID_GSM:
s->block_size = GSM_BLOCK_SIZE;
s->duration = GSM_FRAME_SIZE;
break;
case AV_CODEC_ID_GSM_MS:
s->block_size = GSM_MS_BLOCK_SIZE;
s->duration = GSM_FRAME_SIZE * 2;
break;
default:
return AVERROR(EINVAL);
}
}
if (!s->remaining)
s->remaining = s->block_size;
if (s->remaining <= buf_size) {
next = s->remaining;
s->remaining = 0;
} else {
next = END_NOT_FOUND;
s->remaining -= buf_size;
}
if (ff_combine_frame(pc, next, &buf, &buf_size) < 0 || !buf_size) {
*poutbuf = NULL;
*poutbuf_size = 0;
return buf_size;
}
s1->duration = s->duration;
*poutbuf = buf;
*poutbuf_size = buf_size;
return next;
}
| false | FFmpeg | 4d2f83f8acb6c6444c3b276e15c5369d28b7c037 | static int gsm_parse(AVCodecParserContext *s1, AVCodecContext *avctx,
const uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size)
{
GSMParseContext *s = s1->priv_data;
ParseContext *pc = &s->pc;
int next;
if (!s->block_size) {
switch (avctx->codec_id) {
case AV_CODEC_ID_GSM:
s->block_size = GSM_BLOCK_SIZE;
s->duration = GSM_FRAME_SIZE;
break;
case AV_CODEC_ID_GSM_MS:
s->block_size = GSM_MS_BLOCK_SIZE;
s->duration = GSM_FRAME_SIZE * 2;
break;
default:
return AVERROR(EINVAL);
}
}
if (!s->remaining)
s->remaining = s->block_size;
if (s->remaining <= buf_size) {
next = s->remaining;
s->remaining = 0;
} else {
next = END_NOT_FOUND;
s->remaining -= buf_size;
}
if (ff_combine_frame(pc, next, &buf, &buf_size) < 0 || !buf_size) {
*poutbuf = NULL;
*poutbuf_size = 0;
return buf_size;
}
s1->duration = s->duration;
*poutbuf = buf;
*poutbuf_size = buf_size;
return next;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecParserContext *VAR_0, AVCodecContext *VAR_1,
const uint8_t **VAR_2, int *VAR_3,
const uint8_t *VAR_4, int VAR_5)
{
GSMParseContext *s = VAR_0->priv_data;
ParseContext *pc = &s->pc;
int VAR_6;
if (!s->block_size) {
switch (VAR_1->codec_id) {
case AV_CODEC_ID_GSM:
s->block_size = GSM_BLOCK_SIZE;
s->duration = GSM_FRAME_SIZE;
break;
case AV_CODEC_ID_GSM_MS:
s->block_size = GSM_MS_BLOCK_SIZE;
s->duration = GSM_FRAME_SIZE * 2;
break;
default:
return AVERROR(EINVAL);
}
}
if (!s->remaining)
s->remaining = s->block_size;
if (s->remaining <= VAR_5) {
VAR_6 = s->remaining;
s->remaining = 0;
} else {
VAR_6 = END_NOT_FOUND;
s->remaining -= VAR_5;
}
if (ff_combine_frame(pc, VAR_6, &VAR_4, &VAR_5) < 0 || !VAR_5) {
*VAR_2 = NULL;
*VAR_3 = 0;
return VAR_5;
}
VAR_0->duration = s->duration;
*VAR_2 = VAR_4;
*VAR_3 = VAR_5;
return VAR_6;
}
| [
"static int FUNC_0(AVCodecParserContext *VAR_0, AVCodecContext *VAR_1,\nconst uint8_t **VAR_2, int *VAR_3,\nconst uint8_t *VAR_4, int VAR_5)\n{",
"GSMParseContext *s = VAR_0->priv_data;",
"ParseContext *pc = &s->pc;",
"int VAR_6;",
"if (!s->block_size) {",
"switch (VAR_1->codec_id) {",
"case AV_CODEC_ID_GSM:\ns->block_size = GSM_BLOCK_SIZE;",
"s->duration = GSM_FRAME_SIZE;",
"break;",
"case AV_CODEC_ID_GSM_MS:\ns->block_size = GSM_MS_BLOCK_SIZE;",
"s->duration = GSM_FRAME_SIZE * 2;",
"break;",
"default:\nreturn AVERROR(EINVAL);",
"}",
"}",
"if (!s->remaining)\ns->remaining = s->block_size;",
"if (s->remaining <= VAR_5) {",
"VAR_6 = s->remaining;",
"s->remaining = 0;",
"} else {",
"VAR_6 = END_NOT_FOUND;",
"s->remaining -= VAR_5;",
"}",
"if (ff_combine_frame(pc, VAR_6, &VAR_4, &VAR_5) < 0 || !VAR_5) {",
"*VAR_2 = NULL;",
"*VAR_3 = 0;",
"return VAR_5;",
"}",
"VAR_0->duration = s->duration;",
"*VAR_2 = VAR_4;",
"*VAR_3 = VAR_5;",
"return VAR_6;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
]
]
|
14,331 | static void put_ebml_uint(ByteIOContext *pb, unsigned int elementid, uint64_t val)
{
int i, bytes = 1;
while (val >> bytes*8) bytes++;
put_ebml_id(pb, elementid);
put_ebml_num(pb, bytes, 0);
for (i = bytes - 1; i >= 0; i--)
put_byte(pb, val >> i*8);
}
| false | FFmpeg | d597655f771979c70c08f8f8ed84c1319da121e8 | static void put_ebml_uint(ByteIOContext *pb, unsigned int elementid, uint64_t val)
{
int i, bytes = 1;
while (val >> bytes*8) bytes++;
put_ebml_id(pb, elementid);
put_ebml_num(pb, bytes, 0);
for (i = bytes - 1; i >= 0; i--)
put_byte(pb, val >> i*8);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(ByteIOContext *VAR_0, unsigned int VAR_1, uint64_t VAR_2)
{
int VAR_3, VAR_4 = 1;
while (VAR_2 >> VAR_4*8) VAR_4++;
put_ebml_id(VAR_0, VAR_1);
put_ebml_num(VAR_0, VAR_4, 0);
for (VAR_3 = VAR_4 - 1; VAR_3 >= 0; VAR_3--)
put_byte(VAR_0, VAR_2 >> VAR_3*8);
}
| [
"static void FUNC_0(ByteIOContext *VAR_0, unsigned int VAR_1, uint64_t VAR_2)\n{",
"int VAR_3, VAR_4 = 1;",
"while (VAR_2 >> VAR_4*8) VAR_4++;",
"put_ebml_id(VAR_0, VAR_1);",
"put_ebml_num(VAR_0, VAR_4, 0);",
"for (VAR_3 = VAR_4 - 1; VAR_3 >= 0; VAR_3--)",
"put_byte(VAR_0, VAR_2 >> VAR_3*8);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
]
|
14,332 | static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
{
VideoState *is = opaque;
int audio_size, len1;
int bytes_per_sec;
int frame_size = av_samples_get_buffer_size(NULL, is->audio_tgt.channels, 1, is->audio_tgt.fmt, 1);
double pts;
audio_callback_time = av_gettime();
while (len > 0) {
if (is->audio_buf_index >= is->audio_buf_size) {
audio_size = audio_decode_frame(is, &pts);
if (audio_size < 0) {
/* if error, just output silence */
is->audio_buf = is->silence_buf;
is->audio_buf_size = sizeof(is->silence_buf) / frame_size * frame_size;
} else {
if (is->show_mode != SHOW_MODE_VIDEO)
update_sample_display(is, (int16_t *)is->audio_buf, audio_size);
is->audio_buf_size = audio_size;
}
is->audio_buf_index = 0;
}
len1 = is->audio_buf_size - is->audio_buf_index;
if (len1 > len)
len1 = len;
memcpy(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1);
len -= len1;
stream += len1;
is->audio_buf_index += len1;
}
bytes_per_sec = is->audio_tgt.freq * is->audio_tgt.channels * av_get_bytes_per_sample(is->audio_tgt.fmt);
is->audio_write_buf_size = is->audio_buf_size - is->audio_buf_index;
/* Let's assume the audio driver that is used by SDL has two periods. */
is->audio_current_pts = is->audio_clock - (double)(2 * is->audio_hw_buf_size + is->audio_write_buf_size) / bytes_per_sec;
is->audio_current_pts_drift = is->audio_current_pts - audio_callback_time / 1000000.0;
check_external_clock_sync(is, is->audio_current_pts);
}
| false | FFmpeg | b2a8850969b89151677253be4d99e0ba29212749 | static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
{
VideoState *is = opaque;
int audio_size, len1;
int bytes_per_sec;
int frame_size = av_samples_get_buffer_size(NULL, is->audio_tgt.channels, 1, is->audio_tgt.fmt, 1);
double pts;
audio_callback_time = av_gettime();
while (len > 0) {
if (is->audio_buf_index >= is->audio_buf_size) {
audio_size = audio_decode_frame(is, &pts);
if (audio_size < 0) {
is->audio_buf = is->silence_buf;
is->audio_buf_size = sizeof(is->silence_buf) / frame_size * frame_size;
} else {
if (is->show_mode != SHOW_MODE_VIDEO)
update_sample_display(is, (int16_t *)is->audio_buf, audio_size);
is->audio_buf_size = audio_size;
}
is->audio_buf_index = 0;
}
len1 = is->audio_buf_size - is->audio_buf_index;
if (len1 > len)
len1 = len;
memcpy(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1);
len -= len1;
stream += len1;
is->audio_buf_index += len1;
}
bytes_per_sec = is->audio_tgt.freq * is->audio_tgt.channels * av_get_bytes_per_sample(is->audio_tgt.fmt);
is->audio_write_buf_size = is->audio_buf_size - is->audio_buf_index;
is->audio_current_pts = is->audio_clock - (double)(2 * is->audio_hw_buf_size + is->audio_write_buf_size) / bytes_per_sec;
is->audio_current_pts_drift = is->audio_current_pts - audio_callback_time / 1000000.0;
check_external_clock_sync(is, is->audio_current_pts);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, Uint8 *VAR_1, int VAR_2)
{
VideoState *is = VAR_0;
int VAR_3, VAR_4;
int VAR_5;
int VAR_6 = av_samples_get_buffer_size(NULL, is->audio_tgt.channels, 1, is->audio_tgt.fmt, 1);
double VAR_7;
audio_callback_time = av_gettime();
while (VAR_2 > 0) {
if (is->audio_buf_index >= is->audio_buf_size) {
VAR_3 = audio_decode_frame(is, &VAR_7);
if (VAR_3 < 0) {
is->audio_buf = is->silence_buf;
is->audio_buf_size = sizeof(is->silence_buf) / VAR_6 * VAR_6;
} else {
if (is->show_mode != SHOW_MODE_VIDEO)
update_sample_display(is, (int16_t *)is->audio_buf, VAR_3);
is->audio_buf_size = VAR_3;
}
is->audio_buf_index = 0;
}
VAR_4 = is->audio_buf_size - is->audio_buf_index;
if (VAR_4 > VAR_2)
VAR_4 = VAR_2;
memcpy(VAR_1, (uint8_t *)is->audio_buf + is->audio_buf_index, VAR_4);
VAR_2 -= VAR_4;
VAR_1 += VAR_4;
is->audio_buf_index += VAR_4;
}
VAR_5 = is->audio_tgt.freq * is->audio_tgt.channels * av_get_bytes_per_sample(is->audio_tgt.fmt);
is->audio_write_buf_size = is->audio_buf_size - is->audio_buf_index;
is->audio_current_pts = is->audio_clock - (double)(2 * is->audio_hw_buf_size + is->audio_write_buf_size) / VAR_5;
is->audio_current_pts_drift = is->audio_current_pts - audio_callback_time / 1000000.0;
check_external_clock_sync(is, is->audio_current_pts);
}
| [
"static void FUNC_0(void *VAR_0, Uint8 *VAR_1, int VAR_2)\n{",
"VideoState *is = VAR_0;",
"int VAR_3, VAR_4;",
"int VAR_5;",
"int VAR_6 = av_samples_get_buffer_size(NULL, is->audio_tgt.channels, 1, is->audio_tgt.fmt, 1);",
"double VAR_7;",
"audio_callback_time = av_gettime();",
"while (VAR_2 > 0) {",
"if (is->audio_buf_index >= is->audio_buf_size) {",
"VAR_3 = audio_decode_frame(is, &VAR_7);",
"if (VAR_3 < 0) {",
"is->audio_buf = is->silence_buf;",
"is->audio_buf_size = sizeof(is->silence_buf) / VAR_6 * VAR_6;",
"} else {",
"if (is->show_mode != SHOW_MODE_VIDEO)\nupdate_sample_display(is, (int16_t *)is->audio_buf, VAR_3);",
"is->audio_buf_size = VAR_3;",
"}",
"is->audio_buf_index = 0;",
"}",
"VAR_4 = is->audio_buf_size - is->audio_buf_index;",
"if (VAR_4 > VAR_2)\nVAR_4 = VAR_2;",
"memcpy(VAR_1, (uint8_t *)is->audio_buf + is->audio_buf_index, VAR_4);",
"VAR_2 -= VAR_4;",
"VAR_1 += VAR_4;",
"is->audio_buf_index += VAR_4;",
"}",
"VAR_5 = is->audio_tgt.freq * is->audio_tgt.channels * av_get_bytes_per_sample(is->audio_tgt.fmt);",
"is->audio_write_buf_size = is->audio_buf_size - is->audio_buf_index;",
"is->audio_current_pts = is->audio_clock - (double)(2 * is->audio_hw_buf_size + is->audio_write_buf_size) / VAR_5;",
"is->audio_current_pts_drift = is->audio_current_pts - audio_callback_time / 1000000.0;",
"check_external_clock_sync(is, is->audio_current_pts);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
]
]
|
14,334 | static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid)
{
char desc[DESC_SIZE], tmp_desc[DESC_SIZE];
char *p_name, *tmp_str;
/* the descriptor offset = 0x200 */
if (bdrv_pread(bs->file, 0x200, desc, DESC_SIZE) != DESC_SIZE)
return -1;
tmp_str = strstr(desc,"parentCID");
pstrcpy(tmp_desc, sizeof(tmp_desc), tmp_str);
if ((p_name = strstr(desc,"CID")) != NULL) {
p_name += sizeof("CID");
snprintf(p_name, sizeof(desc) - (p_name - desc), "%x\n", cid);
pstrcat(desc, sizeof(desc), tmp_desc);
}
if (bdrv_pwrite(bs->file, 0x200, desc, DESC_SIZE) != DESC_SIZE)
return -1;
return 0;
}
| true | qemu | b8852e87d9d113096342c3e0977266cda0fe9ee5 | static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid)
{
char desc[DESC_SIZE], tmp_desc[DESC_SIZE];
char *p_name, *tmp_str;
if (bdrv_pread(bs->file, 0x200, desc, DESC_SIZE) != DESC_SIZE)
return -1;
tmp_str = strstr(desc,"parentCID");
pstrcpy(tmp_desc, sizeof(tmp_desc), tmp_str);
if ((p_name = strstr(desc,"CID")) != NULL) {
p_name += sizeof("CID");
snprintf(p_name, sizeof(desc) - (p_name - desc), "%x\n", cid);
pstrcat(desc, sizeof(desc), tmp_desc);
}
if (bdrv_pwrite(bs->file, 0x200, desc, DESC_SIZE) != DESC_SIZE)
return -1;
return 0;
}
| {
"code": [
" if (bdrv_pwrite(bs->file, 0x200, desc, DESC_SIZE) != DESC_SIZE)"
],
"line_no": [
35
]
} | static int FUNC_0(BlockDriverState *VAR_0, uint32_t VAR_1)
{
char VAR_2[DESC_SIZE], tmp_desc[DESC_SIZE];
char *VAR_3, *VAR_4;
if (bdrv_pread(VAR_0->file, 0x200, VAR_2, DESC_SIZE) != DESC_SIZE)
return -1;
VAR_4 = strstr(VAR_2,"parentCID");
pstrcpy(tmp_desc, sizeof(tmp_desc), VAR_4);
if ((VAR_3 = strstr(VAR_2,"CID")) != NULL) {
VAR_3 += sizeof("CID");
snprintf(VAR_3, sizeof(VAR_2) - (VAR_3 - VAR_2), "%x\n", VAR_1);
pstrcat(VAR_2, sizeof(VAR_2), tmp_desc);
}
if (bdrv_pwrite(VAR_0->file, 0x200, VAR_2, DESC_SIZE) != DESC_SIZE)
return -1;
return 0;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, uint32_t VAR_1)\n{",
"char VAR_2[DESC_SIZE], tmp_desc[DESC_SIZE];",
"char *VAR_3, *VAR_4;",
"if (bdrv_pread(VAR_0->file, 0x200, VAR_2, DESC_SIZE) != DESC_SIZE)\nreturn -1;",
"VAR_4 = strstr(VAR_2,\"parentCID\");",
"pstrcpy(tmp_desc, sizeof(tmp_desc), VAR_4);",
"if ((VAR_3 = strstr(VAR_2,\"CID\")) != NULL) {",
"VAR_3 += sizeof(\"CID\");",
"snprintf(VAR_3, sizeof(VAR_2) - (VAR_3 - VAR_2), \"%x\\n\", VAR_1);",
"pstrcat(VAR_2, sizeof(VAR_2), tmp_desc);",
"}",
"if (bdrv_pwrite(VAR_0->file, 0x200, VAR_2, DESC_SIZE) != DESC_SIZE)\nreturn -1;",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
13,
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35,
37
],
[
39
],
[
41
]
]
|
14,335 | static int process_input(void)
{
InputFile *ifile;
AVFormatContext *is;
InputStream *ist;
AVPacket pkt;
int ret, i, j;
/* select the stream that we must read now */
ifile = select_input_file();
/* if none, if is finished */
if (!ifile) {
if (got_eagain()) {
reset_eagain();
av_usleep(10000);
return AVERROR(EAGAIN);
}
av_log(NULL, AV_LOG_VERBOSE, "No more inputs to read from.\n");
return AVERROR_EOF;
}
is = ifile->ctx;
ret = get_input_packet(ifile, &pkt);
if (ret == AVERROR(EAGAIN)) {
ifile->eagain = 1;
return ret;
}
if (ret < 0) {
if (ret != AVERROR_EOF) {
print_error(is->filename, ret);
if (exit_on_error)
exit(1);
}
ifile->eof_reached = 1;
for (i = 0; i < ifile->nb_streams; i++) {
ist = input_streams[ifile->ist_index + i];
if (ist->decoding_needed)
output_packet(ist, NULL);
/* mark all outputs that don't go through lavfi as finished */
for (j = 0; j < nb_output_streams; j++) {
OutputStream *ost = output_streams[j];
if (ost->source_index == ifile->ist_index + i &&
(ost->stream_copy || ost->enc->type == AVMEDIA_TYPE_SUBTITLE))
ost->finished= 1;
}
}
return AVERROR(EAGAIN);
}
reset_eagain();
if (do_pkt_dump) {
av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,
is->streams[pkt.stream_index]);
}
/* the following test is needed in case new streams appear
dynamically in stream : we ignore them */
if (pkt.stream_index >= ifile->nb_streams)
goto discard_packet;
ist = input_streams[ifile->ist_index + pkt.stream_index];
if (ist->discard)
goto discard_packet;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts *= ist->ts_scale;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts *= ist->ts_scale;
if (pkt.dts != AV_NOPTS_VALUE && ist->next_dts != 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_dts;
if ((FFABS(delta) > 1LL * dts_delta_threshold * AV_TIME_BASE || pkt_dts + 1 < ist->last_dts) && !copy_ts) {
ifile->ts_offset -= delta;
av_log(NULL, AV_LOG_DEBUG,
"timestamp discontinuity %"PRId64", new offset= %"PRId64"\n",
delta, ifile->ts_offset);
pkt.dts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
}
}
ret = output_packet(ist, &pkt);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d\n",
ist->file_index, ist->st->index);
if (exit_on_error)
exit(1);
}
discard_packet:
av_free_packet(&pkt);
return 0;
}
| true | FFmpeg | 636ced8e1dc8248a1353b416240b93d70ad03edb | static int process_input(void)
{
InputFile *ifile;
AVFormatContext *is;
InputStream *ist;
AVPacket pkt;
int ret, i, j;
ifile = select_input_file();
if (!ifile) {
if (got_eagain()) {
reset_eagain();
av_usleep(10000);
return AVERROR(EAGAIN);
}
av_log(NULL, AV_LOG_VERBOSE, "No more inputs to read from.\n");
return AVERROR_EOF;
}
is = ifile->ctx;
ret = get_input_packet(ifile, &pkt);
if (ret == AVERROR(EAGAIN)) {
ifile->eagain = 1;
return ret;
}
if (ret < 0) {
if (ret != AVERROR_EOF) {
print_error(is->filename, ret);
if (exit_on_error)
exit(1);
}
ifile->eof_reached = 1;
for (i = 0; i < ifile->nb_streams; i++) {
ist = input_streams[ifile->ist_index + i];
if (ist->decoding_needed)
output_packet(ist, NULL);
for (j = 0; j < nb_output_streams; j++) {
OutputStream *ost = output_streams[j];
if (ost->source_index == ifile->ist_index + i &&
(ost->stream_copy || ost->enc->type == AVMEDIA_TYPE_SUBTITLE))
ost->finished= 1;
}
}
return AVERROR(EAGAIN);
}
reset_eagain();
if (do_pkt_dump) {
av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,
is->streams[pkt.stream_index]);
}
if (pkt.stream_index >= ifile->nb_streams)
goto discard_packet;
ist = input_streams[ifile->ist_index + pkt.stream_index];
if (ist->discard)
goto discard_packet;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts *= ist->ts_scale;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts *= ist->ts_scale;
if (pkt.dts != AV_NOPTS_VALUE && ist->next_dts != 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_dts;
if ((FFABS(delta) > 1LL * dts_delta_threshold * AV_TIME_BASE || pkt_dts + 1 < ist->last_dts) && !copy_ts) {
ifile->ts_offset -= delta;
av_log(NULL, AV_LOG_DEBUG,
"timestamp discontinuity %"PRId64", new offset= %"PRId64"\n",
delta, ifile->ts_offset);
pkt.dts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
}
}
ret = output_packet(ist, &pkt);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d\n",
ist->file_index, ist->st->index);
if (exit_on_error)
exit(1);
}
discard_packet:
av_free_packet(&pkt);
return 0;
}
| {
"code": [
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);"
],
"line_no": [
65,
65,
201,
201,
201,
201,
201,
65,
201,
65,
65,
65,
201,
65,
201
]
} | static int FUNC_0(void)
{
InputFile *ifile;
AVFormatContext *is;
InputStream *ist;
AVPacket pkt;
int VAR_0, VAR_1, VAR_2;
ifile = select_input_file();
if (!ifile) {
if (got_eagain()) {
reset_eagain();
av_usleep(10000);
return AVERROR(EAGAIN);
}
av_log(NULL, AV_LOG_VERBOSE, "No more inputs to read from.\n");
return AVERROR_EOF;
}
is = ifile->ctx;
VAR_0 = get_input_packet(ifile, &pkt);
if (VAR_0 == AVERROR(EAGAIN)) {
ifile->eagain = 1;
return VAR_0;
}
if (VAR_0 < 0) {
if (VAR_0 != AVERROR_EOF) {
print_error(is->filename, VAR_0);
if (exit_on_error)
exit(1);
}
ifile->eof_reached = 1;
for (VAR_1 = 0; VAR_1 < ifile->nb_streams; VAR_1++) {
ist = input_streams[ifile->ist_index + VAR_1];
if (ist->decoding_needed)
output_packet(ist, NULL);
for (VAR_2 = 0; VAR_2 < nb_output_streams; VAR_2++) {
OutputStream *ost = output_streams[VAR_2];
if (ost->source_index == ifile->ist_index + VAR_1 &&
(ost->stream_copy || ost->enc->type == AVMEDIA_TYPE_SUBTITLE))
ost->finished= 1;
}
}
return AVERROR(EAGAIN);
}
reset_eagain();
if (do_pkt_dump) {
av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,
is->streams[pkt.stream_index]);
}
if (pkt.stream_index >= ifile->nb_streams)
goto discard_packet;
ist = input_streams[ifile->ist_index + pkt.stream_index];
if (ist->discard)
goto discard_packet;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts *= ist->ts_scale;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts *= ist->ts_scale;
if (pkt.dts != AV_NOPTS_VALUE && ist->next_dts != 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_dts;
if ((FFABS(delta) > 1LL * dts_delta_threshold * AV_TIME_BASE || pkt_dts + 1 < ist->last_dts) && !copy_ts) {
ifile->ts_offset -= delta;
av_log(NULL, AV_LOG_DEBUG,
"timestamp discontinuity %"PRId64", new offset= %"PRId64"\n",
delta, ifile->ts_offset);
pkt.dts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
}
}
VAR_0 = output_packet(ist, &pkt);
if (VAR_0 < 0) {
av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d\n",
ist->file_index, ist->st->index);
if (exit_on_error)
exit(1);
}
discard_packet:
av_free_packet(&pkt);
return 0;
}
| [
"static int FUNC_0(void)\n{",
"InputFile *ifile;",
"AVFormatContext *is;",
"InputStream *ist;",
"AVPacket pkt;",
"int VAR_0, VAR_1, VAR_2;",
"ifile = select_input_file();",
"if (!ifile) {",
"if (got_eagain()) {",
"reset_eagain();",
"av_usleep(10000);",
"return AVERROR(EAGAIN);",
"}",
"av_log(NULL, AV_LOG_VERBOSE, \"No more inputs to read from.\\n\");",
"return AVERROR_EOF;",
"}",
"is = ifile->ctx;",
"VAR_0 = get_input_packet(ifile, &pkt);",
"if (VAR_0 == AVERROR(EAGAIN)) {",
"ifile->eagain = 1;",
"return VAR_0;",
"}",
"if (VAR_0 < 0) {",
"if (VAR_0 != AVERROR_EOF) {",
"print_error(is->filename, VAR_0);",
"if (exit_on_error)\nexit(1);",
"}",
"ifile->eof_reached = 1;",
"for (VAR_1 = 0; VAR_1 < ifile->nb_streams; VAR_1++) {",
"ist = input_streams[ifile->ist_index + VAR_1];",
"if (ist->decoding_needed)\noutput_packet(ist, NULL);",
"for (VAR_2 = 0; VAR_2 < nb_output_streams; VAR_2++) {",
"OutputStream *ost = output_streams[VAR_2];",
"if (ost->source_index == ifile->ist_index + VAR_1 &&\n(ost->stream_copy || ost->enc->type == AVMEDIA_TYPE_SUBTITLE))\nost->finished= 1;",
"}",
"}",
"return AVERROR(EAGAIN);",
"}",
"reset_eagain();",
"if (do_pkt_dump) {",
"av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,\nis->streams[pkt.stream_index]);",
"}",
"if (pkt.stream_index >= ifile->nb_streams)\ngoto discard_packet;",
"ist = input_streams[ifile->ist_index + pkt.stream_index];",
"if (ist->discard)\ngoto discard_packet;",
"if (pkt.dts != AV_NOPTS_VALUE)\npkt.dts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);",
"if (pkt.pts != AV_NOPTS_VALUE)\npkt.pts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);",
"if (pkt.pts != AV_NOPTS_VALUE)\npkt.pts *= ist->ts_scale;",
"if (pkt.dts != AV_NOPTS_VALUE)\npkt.dts *= ist->ts_scale;",
"if (pkt.dts != AV_NOPTS_VALUE && ist->next_dts != 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_dts;",
"if ((FFABS(delta) > 1LL * dts_delta_threshold * AV_TIME_BASE || pkt_dts + 1 < ist->last_dts) && !copy_ts) {",
"ifile->ts_offset -= delta;",
"av_log(NULL, AV_LOG_DEBUG,\n\"timestamp discontinuity %\"PRId64\", new offset= %\"PRId64\"\\n\",\ndelta, ifile->ts_offset);",
"pkt.dts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);",
"if (pkt.pts != AV_NOPTS_VALUE)\npkt.pts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);",
"}",
"}",
"VAR_0 = output_packet(ist, &pkt);",
"if (VAR_0 < 0) {",
"av_log(NULL, AV_LOG_ERROR, \"Error while decoding stream #%d:%d\\n\",\nist->file_index, ist->st->index);",
"if (exit_on_error)\nexit(1);",
"}",
"discard_packet:\nav_free_packet(&pkt);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77,
79
],
[
85
],
[
87
],
[
91,
93,
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
109
],
[
113
],
[
115,
117
],
[
119
],
[
125,
127
],
[
131
],
[
133,
135
],
[
139,
141
],
[
143,
145
],
[
149,
151
],
[
153,
155
],
[
159,
161
],
[
163
],
[
165
],
[
169
],
[
171
],
[
173,
175,
177
],
[
179
],
[
181,
183
],
[
185
],
[
187
],
[
191
],
[
193
],
[
195,
197
],
[
199,
201
],
[
203
],
[
207,
209
],
[
213
],
[
215
]
]
|
14,336 | static int get_int32_le(QEMUFile *f, void *pv, size_t size)
{
int32_t *cur = pv;
int32_t loaded;
qemu_get_sbe32s(f, &loaded);
if (loaded >= 0 && loaded <= *cur) {
*cur = loaded;
return 0;
}
return -EINVAL;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | static int get_int32_le(QEMUFile *f, void *pv, size_t size)
{
int32_t *cur = pv;
int32_t loaded;
qemu_get_sbe32s(f, &loaded);
if (loaded >= 0 && loaded <= *cur) {
*cur = loaded;
return 0;
}
return -EINVAL;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2)
{
int32_t *cur = VAR_1;
int32_t loaded;
qemu_get_sbe32s(VAR_0, &loaded);
if (loaded >= 0 && loaded <= *cur) {
*cur = loaded;
return 0;
}
return -EINVAL;
}
| [
"static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2)\n{",
"int32_t *cur = VAR_1;",
"int32_t loaded;",
"qemu_get_sbe32s(VAR_0, &loaded);",
"if (loaded >= 0 && loaded <= *cur) {",
"*cur = loaded;",
"return 0;",
"}",
"return -EINVAL;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
]
|
14,337 | static int h264_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
H264Context *h = avctx->priv_data;
AVFrame *pict = data;
int buf_index = 0;
H264Picture *out;
int i, out_idx;
int ret;
h->flags = avctx->flags;
h->setup_finished = 0;
if (h->backup_width != -1) {
avctx->width = h->backup_width;
h->backup_width = -1;
}
if (h->backup_height != -1) {
avctx->height = h->backup_height;
h->backup_height = -1;
}
if (h->backup_pix_fmt != AV_PIX_FMT_NONE) {
avctx->pix_fmt = h->backup_pix_fmt;
h->backup_pix_fmt = AV_PIX_FMT_NONE;
}
ff_h264_unref_picture(h, &h->last_pic_for_ec);
/* end of stream, output what is still in the buffers */
if (buf_size == 0) {
out:
h->cur_pic_ptr = NULL;
h->first_field = 0;
// FIXME factorize this with the output code below
out = h->delayed_pic[0];
out_idx = 0;
for (i = 1;
h->delayed_pic[i] &&
!h->delayed_pic[i]->f->key_frame &&
!h->delayed_pic[i]->mmco_reset;
i++)
if (h->delayed_pic[i]->poc < out->poc) {
out = h->delayed_pic[i];
out_idx = i;
}
for (i = out_idx; h->delayed_pic[i]; i++)
h->delayed_pic[i] = h->delayed_pic[i + 1];
if (out) {
out->reference &= ~DELAYED_PIC_REF;
ret = output_frame(h, pict, out);
if (ret < 0)
return ret;
*got_frame = 1;
}
return buf_index;
}
if (h->is_avc && av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, NULL)) {
int side_size;
uint8_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size);
if (is_extra(side, side_size))
ff_h264_decode_extradata(h, side, side_size);
}
if(h->is_avc && buf_size >= 9 && buf[0]==1 && buf[2]==0 && (buf[4]&0xFC)==0xFC && (buf[5]&0x1F) && buf[8]==0x67){
if (is_extra(buf, buf_size))
return ff_h264_decode_extradata(h, buf, buf_size);
}
buf_index = decode_nal_units(h, buf, buf_size, 0);
if (buf_index < 0)
return AVERROR_INVALIDDATA;
if (!h->cur_pic_ptr && h->nal_unit_type == NAL_END_SEQUENCE) {
av_assert0(buf_index <= buf_size);
goto out;
}
if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS) && !h->cur_pic_ptr) {
if (avctx->skip_frame >= AVDISCARD_NONREF ||
buf_size >= 4 && !memcmp("Q264", buf, 4))
return buf_size;
av_log(avctx, AV_LOG_ERROR, "no frame!\n");
return AVERROR_INVALIDDATA;
}
if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS) ||
(h->mb_y >= h->mb_height && h->mb_height)) {
if (avctx->flags2 & AV_CODEC_FLAG2_CHUNKS)
decode_postinit(h, 1);
if ((ret = ff_h264_field_end(h, &h->slice_ctx[0], 0)) < 0)
return ret;
/* Wait for second field. */
*got_frame = 0;
if (h->next_output_pic && (
h->next_output_pic->recovered)) {
if (!h->next_output_pic->recovered)
h->next_output_pic->f->flags |= AV_FRAME_FLAG_CORRUPT;
if (!h->avctx->hwaccel &&
(h->next_output_pic->field_poc[0] == INT_MAX ||
h->next_output_pic->field_poc[1] == INT_MAX)
) {
int p;
AVFrame *f = h->next_output_pic->f;
int field = h->next_output_pic->field_poc[0] == INT_MAX;
uint8_t *dst_data[4];
int linesizes[4];
const uint8_t *src_data[4];
av_log(h->avctx, AV_LOG_DEBUG, "Duplicating field %d to fill missing\n", field);
for (p = 0; p<4; p++) {
dst_data[p] = f->data[p] + (field^1)*f->linesize[p];
src_data[p] = f->data[p] + field *f->linesize[p];
linesizes[p] = 2*f->linesize[p];
}
av_image_copy(dst_data, linesizes, src_data, linesizes,
f->format, f->width, f->height>>1);
}
ret = output_frame(h, pict, h->next_output_pic);
if (ret < 0)
return ret;
*got_frame = 1;
if (CONFIG_MPEGVIDEO) {
ff_print_debug_info2(h->avctx, pict, NULL,
h->next_output_pic->mb_type,
h->next_output_pic->qscale_table,
h->next_output_pic->motion_val,
&h->low_delay,
h->mb_width, h->mb_height, h->mb_stride, 1);
}
}
}
av_assert0(pict->buf[0] || !*got_frame);
ff_h264_unref_picture(h, &h->last_pic_for_ec);
return get_consumed_bytes(buf_index, buf_size);
}
| true | FFmpeg | 9aebea0a4de1dc19c6309694cb1a5cd7554438cc | static int h264_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
H264Context *h = avctx->priv_data;
AVFrame *pict = data;
int buf_index = 0;
H264Picture *out;
int i, out_idx;
int ret;
h->flags = avctx->flags;
h->setup_finished = 0;
if (h->backup_width != -1) {
avctx->width = h->backup_width;
h->backup_width = -1;
}
if (h->backup_height != -1) {
avctx->height = h->backup_height;
h->backup_height = -1;
}
if (h->backup_pix_fmt != AV_PIX_FMT_NONE) {
avctx->pix_fmt = h->backup_pix_fmt;
h->backup_pix_fmt = AV_PIX_FMT_NONE;
}
ff_h264_unref_picture(h, &h->last_pic_for_ec);
if (buf_size == 0) {
out:
h->cur_pic_ptr = NULL;
h->first_field = 0;
out = h->delayed_pic[0];
out_idx = 0;
for (i = 1;
h->delayed_pic[i] &&
!h->delayed_pic[i]->f->key_frame &&
!h->delayed_pic[i]->mmco_reset;
i++)
if (h->delayed_pic[i]->poc < out->poc) {
out = h->delayed_pic[i];
out_idx = i;
}
for (i = out_idx; h->delayed_pic[i]; i++)
h->delayed_pic[i] = h->delayed_pic[i + 1];
if (out) {
out->reference &= ~DELAYED_PIC_REF;
ret = output_frame(h, pict, out);
if (ret < 0)
return ret;
*got_frame = 1;
}
return buf_index;
}
if (h->is_avc && av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, NULL)) {
int side_size;
uint8_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size);
if (is_extra(side, side_size))
ff_h264_decode_extradata(h, side, side_size);
}
if(h->is_avc && buf_size >= 9 && buf[0]==1 && buf[2]==0 && (buf[4]&0xFC)==0xFC && (buf[5]&0x1F) && buf[8]==0x67){
if (is_extra(buf, buf_size))
return ff_h264_decode_extradata(h, buf, buf_size);
}
buf_index = decode_nal_units(h, buf, buf_size, 0);
if (buf_index < 0)
return AVERROR_INVALIDDATA;
if (!h->cur_pic_ptr && h->nal_unit_type == NAL_END_SEQUENCE) {
av_assert0(buf_index <= buf_size);
goto out;
}
if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS) && !h->cur_pic_ptr) {
if (avctx->skip_frame >= AVDISCARD_NONREF ||
buf_size >= 4 && !memcmp("Q264", buf, 4))
return buf_size;
av_log(avctx, AV_LOG_ERROR, "no frame!\n");
return AVERROR_INVALIDDATA;
}
if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS) ||
(h->mb_y >= h->mb_height && h->mb_height)) {
if (avctx->flags2 & AV_CODEC_FLAG2_CHUNKS)
decode_postinit(h, 1);
if ((ret = ff_h264_field_end(h, &h->slice_ctx[0], 0)) < 0)
return ret;
*got_frame = 0;
if (h->next_output_pic && (
h->next_output_pic->recovered)) {
if (!h->next_output_pic->recovered)
h->next_output_pic->f->flags |= AV_FRAME_FLAG_CORRUPT;
if (!h->avctx->hwaccel &&
(h->next_output_pic->field_poc[0] == INT_MAX ||
h->next_output_pic->field_poc[1] == INT_MAX)
) {
int p;
AVFrame *f = h->next_output_pic->f;
int field = h->next_output_pic->field_poc[0] == INT_MAX;
uint8_t *dst_data[4];
int linesizes[4];
const uint8_t *src_data[4];
av_log(h->avctx, AV_LOG_DEBUG, "Duplicating field %d to fill missing\n", field);
for (p = 0; p<4; p++) {
dst_data[p] = f->data[p] + (field^1)*f->linesize[p];
src_data[p] = f->data[p] + field *f->linesize[p];
linesizes[p] = 2*f->linesize[p];
}
av_image_copy(dst_data, linesizes, src_data, linesizes,
f->format, f->width, f->height>>1);
}
ret = output_frame(h, pict, h->next_output_pic);
if (ret < 0)
return ret;
*got_frame = 1;
if (CONFIG_MPEGVIDEO) {
ff_print_debug_info2(h->avctx, pict, NULL,
h->next_output_pic->mb_type,
h->next_output_pic->qscale_table,
h->next_output_pic->motion_val,
&h->low_delay,
h->mb_width, h->mb_height, h->mb_stride, 1);
}
}
}
av_assert0(pict->buf[0] || !*got_frame);
ff_h264_unref_picture(h, &h->last_pic_for_ec);
return get_consumed_bytes(buf_index, buf_size);
}
| {
"code": [
" if (h->next_output_pic && ("
],
"line_no": [
203
]
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
H264Context *h = VAR_0->priv_data;
AVFrame *pict = VAR_1;
int VAR_6 = 0;
H264Picture *out;
int VAR_7, VAR_8;
int VAR_9;
h->flags = VAR_0->flags;
h->setup_finished = 0;
if (h->backup_width != -1) {
VAR_0->width = h->backup_width;
h->backup_width = -1;
}
if (h->backup_height != -1) {
VAR_0->height = h->backup_height;
h->backup_height = -1;
}
if (h->backup_pix_fmt != AV_PIX_FMT_NONE) {
VAR_0->pix_fmt = h->backup_pix_fmt;
h->backup_pix_fmt = AV_PIX_FMT_NONE;
}
ff_h264_unref_picture(h, &h->last_pic_for_ec);
if (VAR_5 == 0) {
out:
h->cur_pic_ptr = NULL;
h->first_field = 0;
out = h->delayed_pic[0];
VAR_8 = 0;
for (VAR_7 = 1;
h->delayed_pic[VAR_7] &&
!h->delayed_pic[VAR_7]->f->key_frame &&
!h->delayed_pic[VAR_7]->mmco_reset;
VAR_7++)
if (h->delayed_pic[VAR_7]->poc < out->poc) {
out = h->delayed_pic[VAR_7];
VAR_8 = VAR_7;
}
for (VAR_7 = VAR_8; h->delayed_pic[VAR_7]; VAR_7++)
h->delayed_pic[VAR_7] = h->delayed_pic[VAR_7 + 1];
if (out) {
out->reference &= ~DELAYED_PIC_REF;
VAR_9 = output_frame(h, pict, out);
if (VAR_9 < 0)
return VAR_9;
*VAR_2 = 1;
}
return VAR_6;
}
if (h->is_avc && av_packet_get_side_data(VAR_3, AV_PKT_DATA_NEW_EXTRADATA, NULL)) {
int VAR_10;
uint8_t *side = av_packet_get_side_data(VAR_3, AV_PKT_DATA_NEW_EXTRADATA, &VAR_10);
if (is_extra(side, VAR_10))
ff_h264_decode_extradata(h, side, VAR_10);
}
if(h->is_avc && VAR_5 >= 9 && VAR_4[0]==1 && VAR_4[2]==0 && (VAR_4[4]&0xFC)==0xFC && (VAR_4[5]&0x1F) && VAR_4[8]==0x67){
if (is_extra(VAR_4, VAR_5))
return ff_h264_decode_extradata(h, VAR_4, VAR_5);
}
VAR_6 = decode_nal_units(h, VAR_4, VAR_5, 0);
if (VAR_6 < 0)
return AVERROR_INVALIDDATA;
if (!h->cur_pic_ptr && h->nal_unit_type == NAL_END_SEQUENCE) {
av_assert0(VAR_6 <= VAR_5);
goto out;
}
if (!(VAR_0->flags2 & AV_CODEC_FLAG2_CHUNKS) && !h->cur_pic_ptr) {
if (VAR_0->skip_frame >= AVDISCARD_NONREF ||
VAR_5 >= 4 && !memcmp("Q264", VAR_4, 4))
return VAR_5;
av_log(VAR_0, AV_LOG_ERROR, "no frame!\n");
return AVERROR_INVALIDDATA;
}
if (!(VAR_0->flags2 & AV_CODEC_FLAG2_CHUNKS) ||
(h->mb_y >= h->mb_height && h->mb_height)) {
if (VAR_0->flags2 & AV_CODEC_FLAG2_CHUNKS)
decode_postinit(h, 1);
if ((VAR_9 = ff_h264_field_end(h, &h->slice_ctx[0], 0)) < 0)
return VAR_9;
*VAR_2 = 0;
if (h->next_output_pic && (
h->next_output_pic->recovered)) {
if (!h->next_output_pic->recovered)
h->next_output_pic->f->flags |= AV_FRAME_FLAG_CORRUPT;
if (!h->VAR_0->hwaccel &&
(h->next_output_pic->field_poc[0] == INT_MAX ||
h->next_output_pic->field_poc[1] == INT_MAX)
) {
int VAR_11;
AVFrame *f = h->next_output_pic->f;
int VAR_12 = h->next_output_pic->field_poc[0] == INT_MAX;
uint8_t *dst_data[4];
int VAR_13[4];
const uint8_t *VAR_14[4];
av_log(h->VAR_0, AV_LOG_DEBUG, "Duplicating VAR_12 %d to fill missing\n", VAR_12);
for (VAR_11 = 0; VAR_11<4; VAR_11++) {
dst_data[VAR_11] = f->VAR_1[VAR_11] + (VAR_12^1)*f->linesize[VAR_11];
VAR_14[VAR_11] = f->VAR_1[VAR_11] + VAR_12 *f->linesize[VAR_11];
VAR_13[VAR_11] = 2*f->linesize[VAR_11];
}
av_image_copy(dst_data, VAR_13, VAR_14, VAR_13,
f->format, f->width, f->height>>1);
}
VAR_9 = output_frame(h, pict, h->next_output_pic);
if (VAR_9 < 0)
return VAR_9;
*VAR_2 = 1;
if (CONFIG_MPEGVIDEO) {
ff_print_debug_info2(h->VAR_0, pict, NULL,
h->next_output_pic->mb_type,
h->next_output_pic->qscale_table,
h->next_output_pic->motion_val,
&h->low_delay,
h->mb_width, h->mb_height, h->mb_stride, 1);
}
}
}
av_assert0(pict->VAR_4[0] || !*VAR_2);
ff_h264_unref_picture(h, &h->last_pic_for_ec);
return get_consumed_bytes(VAR_6, VAR_5);
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"H264Context *h = VAR_0->priv_data;",
"AVFrame *pict = VAR_1;",
"int VAR_6 = 0;",
"H264Picture *out;",
"int VAR_7, VAR_8;",
"int VAR_9;",
"h->flags = VAR_0->flags;",
"h->setup_finished = 0;",
"if (h->backup_width != -1) {",
"VAR_0->width = h->backup_width;",
"h->backup_width = -1;",
"}",
"if (h->backup_height != -1) {",
"VAR_0->height = h->backup_height;",
"h->backup_height = -1;",
"}",
"if (h->backup_pix_fmt != AV_PIX_FMT_NONE) {",
"VAR_0->pix_fmt = h->backup_pix_fmt;",
"h->backup_pix_fmt = AV_PIX_FMT_NONE;",
"}",
"ff_h264_unref_picture(h, &h->last_pic_for_ec);",
"if (VAR_5 == 0) {",
"out:\nh->cur_pic_ptr = NULL;",
"h->first_field = 0;",
"out = h->delayed_pic[0];",
"VAR_8 = 0;",
"for (VAR_7 = 1;",
"h->delayed_pic[VAR_7] &&\n!h->delayed_pic[VAR_7]->f->key_frame &&\n!h->delayed_pic[VAR_7]->mmco_reset;",
"VAR_7++)\nif (h->delayed_pic[VAR_7]->poc < out->poc) {",
"out = h->delayed_pic[VAR_7];",
"VAR_8 = VAR_7;",
"}",
"for (VAR_7 = VAR_8; h->delayed_pic[VAR_7]; VAR_7++)",
"h->delayed_pic[VAR_7] = h->delayed_pic[VAR_7 + 1];",
"if (out) {",
"out->reference &= ~DELAYED_PIC_REF;",
"VAR_9 = output_frame(h, pict, out);",
"if (VAR_9 < 0)\nreturn VAR_9;",
"*VAR_2 = 1;",
"}",
"return VAR_6;",
"}",
"if (h->is_avc && av_packet_get_side_data(VAR_3, AV_PKT_DATA_NEW_EXTRADATA, NULL)) {",
"int VAR_10;",
"uint8_t *side = av_packet_get_side_data(VAR_3, AV_PKT_DATA_NEW_EXTRADATA, &VAR_10);",
"if (is_extra(side, VAR_10))\nff_h264_decode_extradata(h, side, VAR_10);",
"}",
"if(h->is_avc && VAR_5 >= 9 && VAR_4[0]==1 && VAR_4[2]==0 && (VAR_4[4]&0xFC)==0xFC && (VAR_4[5]&0x1F) && VAR_4[8]==0x67){",
"if (is_extra(VAR_4, VAR_5))\nreturn ff_h264_decode_extradata(h, VAR_4, VAR_5);",
"}",
"VAR_6 = decode_nal_units(h, VAR_4, VAR_5, 0);",
"if (VAR_6 < 0)\nreturn AVERROR_INVALIDDATA;",
"if (!h->cur_pic_ptr && h->nal_unit_type == NAL_END_SEQUENCE) {",
"av_assert0(VAR_6 <= VAR_5);",
"goto out;",
"}",
"if (!(VAR_0->flags2 & AV_CODEC_FLAG2_CHUNKS) && !h->cur_pic_ptr) {",
"if (VAR_0->skip_frame >= AVDISCARD_NONREF ||\nVAR_5 >= 4 && !memcmp(\"Q264\", VAR_4, 4))\nreturn VAR_5;",
"av_log(VAR_0, AV_LOG_ERROR, \"no frame!\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (!(VAR_0->flags2 & AV_CODEC_FLAG2_CHUNKS) ||\n(h->mb_y >= h->mb_height && h->mb_height)) {",
"if (VAR_0->flags2 & AV_CODEC_FLAG2_CHUNKS)\ndecode_postinit(h, 1);",
"if ((VAR_9 = ff_h264_field_end(h, &h->slice_ctx[0], 0)) < 0)\nreturn VAR_9;",
"*VAR_2 = 0;",
"if (h->next_output_pic && (\nh->next_output_pic->recovered)) {",
"if (!h->next_output_pic->recovered)\nh->next_output_pic->f->flags |= AV_FRAME_FLAG_CORRUPT;",
"if (!h->VAR_0->hwaccel &&\n(h->next_output_pic->field_poc[0] == INT_MAX ||\nh->next_output_pic->field_poc[1] == INT_MAX)\n) {",
"int VAR_11;",
"AVFrame *f = h->next_output_pic->f;",
"int VAR_12 = h->next_output_pic->field_poc[0] == INT_MAX;",
"uint8_t *dst_data[4];",
"int VAR_13[4];",
"const uint8_t *VAR_14[4];",
"av_log(h->VAR_0, AV_LOG_DEBUG, \"Duplicating VAR_12 %d to fill missing\\n\", VAR_12);",
"for (VAR_11 = 0; VAR_11<4; VAR_11++) {",
"dst_data[VAR_11] = f->VAR_1[VAR_11] + (VAR_12^1)*f->linesize[VAR_11];",
"VAR_14[VAR_11] = f->VAR_1[VAR_11] + VAR_12 *f->linesize[VAR_11];",
"VAR_13[VAR_11] = 2*f->linesize[VAR_11];",
"}",
"av_image_copy(dst_data, VAR_13, VAR_14, VAR_13,\nf->format, f->width, f->height>>1);",
"}",
"VAR_9 = output_frame(h, pict, h->next_output_pic);",
"if (VAR_9 < 0)\nreturn VAR_9;",
"*VAR_2 = 1;",
"if (CONFIG_MPEGVIDEO) {",
"ff_print_debug_info2(h->VAR_0, pict, NULL,\nh->next_output_pic->mb_type,\nh->next_output_pic->qscale_table,\nh->next_output_pic->motion_val,\n&h->low_delay,\nh->mb_width, h->mb_height, h->mb_stride, 1);",
"}",
"}",
"}",
"av_assert0(pict->VAR_4[0] || !*VAR_2);",
"ff_h264_unref_picture(h, &h->last_pic_for_ec);",
"return get_consumed_bytes(VAR_6, 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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
63
],
[
65,
69
],
[
71
],
[
77
],
[
79
],
[
81
],
[
83,
85,
87
],
[
89,
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113,
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133,
135
],
[
137
],
[
139
],
[
141,
143
],
[
145
],
[
149
],
[
151,
153
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169,
171,
173
],
[
175
],
[
177
],
[
179
],
[
183,
185
],
[
187,
189
],
[
193,
195
],
[
201
],
[
203,
205
],
[
207,
209
],
[
213,
215,
217,
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
235
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
251,
253
],
[
255
],
[
259
],
[
261,
263
],
[
265
],
[
267
],
[
269,
271,
273,
275,
277,
279
],
[
281
],
[
283
],
[
285
],
[
289
],
[
293
],
[
297
],
[
299
]
]
|
14,338 | static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
{
MXFContext *mxf = arg;
MXFPartition *partition, *tmp_part;
UID op;
uint64_t footer_partition;
uint32_t nb_essence_containers;
tmp_part = av_realloc_array(mxf->partitions, mxf->partitions_count + 1, sizeof(*mxf->partitions));
if (!tmp_part)
return AVERROR(ENOMEM);
mxf->partitions = tmp_part;
if (mxf->parsing_backward) {
/* insert the new partition pack in the middle
* this makes the entries in mxf->partitions sorted by offset */
memmove(&mxf->partitions[mxf->last_forward_partition+1],
&mxf->partitions[mxf->last_forward_partition],
(mxf->partitions_count - mxf->last_forward_partition)*sizeof(*mxf->partitions));
partition = mxf->current_partition = &mxf->partitions[mxf->last_forward_partition];
} else {
mxf->last_forward_partition++;
partition = mxf->current_partition = &mxf->partitions[mxf->partitions_count];
}
memset(partition, 0, sizeof(*partition));
mxf->partitions_count++;
partition->pack_length = avio_tell(pb) - klv_offset + size;
switch(uid[13]) {
case 2:
partition->type = Header;
break;
case 3:
partition->type = BodyPartition;
break;
case 4:
partition->type = Footer;
break;
default:
av_log(mxf->fc, AV_LOG_ERROR, "unknown partition type %i\n", uid[13]);
return AVERROR_INVALIDDATA;
}
/* consider both footers to be closed (there is only Footer and CompleteFooter) */
partition->closed = partition->type == Footer || !(uid[14] & 1);
partition->complete = uid[14] > 2;
avio_skip(pb, 4);
partition->kag_size = avio_rb32(pb);
partition->this_partition = avio_rb64(pb);
partition->previous_partition = avio_rb64(pb);
footer_partition = avio_rb64(pb);
partition->header_byte_count = avio_rb64(pb);
partition->index_byte_count = avio_rb64(pb);
partition->index_sid = avio_rb32(pb);
avio_skip(pb, 8);
partition->body_sid = avio_rb32(pb);
avio_read(pb, op, sizeof(UID));
nb_essence_containers = avio_rb32(pb);
/* some files don'thave FooterPartition set in every partition */
if (footer_partition) {
if (mxf->footer_partition && mxf->footer_partition != footer_partition) {
av_log(mxf->fc, AV_LOG_ERROR,
"inconsistent FooterPartition value: %"PRIu64" != %"PRIu64"\n",
mxf->footer_partition, footer_partition);
} else {
mxf->footer_partition = footer_partition;
}
}
av_dlog(mxf->fc,
"PartitionPack: ThisPartition = 0x%"PRIX64
", PreviousPartition = 0x%"PRIX64", "
"FooterPartition = 0x%"PRIX64", IndexSID = %i, BodySID = %i\n",
partition->this_partition,
partition->previous_partition, footer_partition,
partition->index_sid, partition->body_sid);
/* sanity check PreviousPartition if set */
if (partition->previous_partition &&
mxf->run_in + partition->previous_partition >= klv_offset) {
av_log(mxf->fc, AV_LOG_ERROR,
"PreviousPartition points to this partition or forward\n");
return AVERROR_INVALIDDATA;
}
if (op[12] == 1 && op[13] == 1) mxf->op = OP1a;
else if (op[12] == 1 && op[13] == 2) mxf->op = OP1b;
else if (op[12] == 1 && op[13] == 3) mxf->op = OP1c;
else if (op[12] == 2 && op[13] == 1) mxf->op = OP2a;
else if (op[12] == 2 && op[13] == 2) mxf->op = OP2b;
else if (op[12] == 2 && op[13] == 3) mxf->op = OP2c;
else if (op[12] == 3 && op[13] == 1) mxf->op = OP3a;
else if (op[12] == 3 && op[13] == 2) mxf->op = OP3b;
else if (op[12] == 3 && op[13] == 3) mxf->op = OP3c;
else if (op[12] == 64&& op[13] == 1) mxf->op = OPSONYOpt;
else if (op[12] == 0x10) {
/* SMPTE 390m: "There shall be exactly one essence container"
* The following block deals with files that violate this, namely:
* 2011_DCPTEST_24FPS.V.mxf - two ECs, OP1a
* abcdefghiv016f56415e.mxf - zero ECs, OPAtom, output by Avid AirSpeed */
if (nb_essence_containers != 1) {
MXFOP op = nb_essence_containers ? OP1a : OPAtom;
/* only nag once */
if (!mxf->op)
av_log(mxf->fc, AV_LOG_WARNING, "\"OPAtom\" with %u ECs - assuming %s\n",
nb_essence_containers, op == OP1a ? "OP1a" : "OPAtom");
mxf->op = op;
} else
mxf->op = OPAtom;
} else {
av_log(mxf->fc, AV_LOG_ERROR, "unknown operational pattern: %02xh %02xh - guessing OP1a\n", op[12], op[13]);
mxf->op = OP1a;
}
if (partition->kag_size <= 0 || partition->kag_size > (1 << 20)) {
av_log(mxf->fc, AV_LOG_WARNING, "invalid KAGSize %i - guessing ", partition->kag_size);
if (mxf->op == OPSONYOpt)
partition->kag_size = 512;
else
partition->kag_size = 1;
av_log(mxf->fc, AV_LOG_WARNING, "%i\n", partition->kag_size);
}
return 0;
}
| true | FFmpeg | 4162ceea93684f3cd656dc21d30903e102a44e73 | static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
{
MXFContext *mxf = arg;
MXFPartition *partition, *tmp_part;
UID op;
uint64_t footer_partition;
uint32_t nb_essence_containers;
tmp_part = av_realloc_array(mxf->partitions, mxf->partitions_count + 1, sizeof(*mxf->partitions));
if (!tmp_part)
return AVERROR(ENOMEM);
mxf->partitions = tmp_part;
if (mxf->parsing_backward) {
memmove(&mxf->partitions[mxf->last_forward_partition+1],
&mxf->partitions[mxf->last_forward_partition],
(mxf->partitions_count - mxf->last_forward_partition)*sizeof(*mxf->partitions));
partition = mxf->current_partition = &mxf->partitions[mxf->last_forward_partition];
} else {
mxf->last_forward_partition++;
partition = mxf->current_partition = &mxf->partitions[mxf->partitions_count];
}
memset(partition, 0, sizeof(*partition));
mxf->partitions_count++;
partition->pack_length = avio_tell(pb) - klv_offset + size;
switch(uid[13]) {
case 2:
partition->type = Header;
break;
case 3:
partition->type = BodyPartition;
break;
case 4:
partition->type = Footer;
break;
default:
av_log(mxf->fc, AV_LOG_ERROR, "unknown partition type %i\n", uid[13]);
return AVERROR_INVALIDDATA;
}
partition->closed = partition->type == Footer || !(uid[14] & 1);
partition->complete = uid[14] > 2;
avio_skip(pb, 4);
partition->kag_size = avio_rb32(pb);
partition->this_partition = avio_rb64(pb);
partition->previous_partition = avio_rb64(pb);
footer_partition = avio_rb64(pb);
partition->header_byte_count = avio_rb64(pb);
partition->index_byte_count = avio_rb64(pb);
partition->index_sid = avio_rb32(pb);
avio_skip(pb, 8);
partition->body_sid = avio_rb32(pb);
avio_read(pb, op, sizeof(UID));
nb_essence_containers = avio_rb32(pb);
if (footer_partition) {
if (mxf->footer_partition && mxf->footer_partition != footer_partition) {
av_log(mxf->fc, AV_LOG_ERROR,
"inconsistent FooterPartition value: %"PRIu64" != %"PRIu64"\n",
mxf->footer_partition, footer_partition);
} else {
mxf->footer_partition = footer_partition;
}
}
av_dlog(mxf->fc,
"PartitionPack: ThisPartition = 0x%"PRIX64
", PreviousPartition = 0x%"PRIX64", "
"FooterPartition = 0x%"PRIX64", IndexSID = %i, BodySID = %i\n",
partition->this_partition,
partition->previous_partition, footer_partition,
partition->index_sid, partition->body_sid);
if (partition->previous_partition &&
mxf->run_in + partition->previous_partition >= klv_offset) {
av_log(mxf->fc, AV_LOG_ERROR,
"PreviousPartition points to this partition or forward\n");
return AVERROR_INVALIDDATA;
}
if (op[12] == 1 && op[13] == 1) mxf->op = OP1a;
else if (op[12] == 1 && op[13] == 2) mxf->op = OP1b;
else if (op[12] == 1 && op[13] == 3) mxf->op = OP1c;
else if (op[12] == 2 && op[13] == 1) mxf->op = OP2a;
else if (op[12] == 2 && op[13] == 2) mxf->op = OP2b;
else if (op[12] == 2 && op[13] == 3) mxf->op = OP2c;
else if (op[12] == 3 && op[13] == 1) mxf->op = OP3a;
else if (op[12] == 3 && op[13] == 2) mxf->op = OP3b;
else if (op[12] == 3 && op[13] == 3) mxf->op = OP3c;
else if (op[12] == 64&& op[13] == 1) mxf->op = OPSONYOpt;
else if (op[12] == 0x10) {
if (nb_essence_containers != 1) {
MXFOP op = nb_essence_containers ? OP1a : OPAtom;
if (!mxf->op)
av_log(mxf->fc, AV_LOG_WARNING, "\"OPAtom\" with %u ECs - assuming %s\n",
nb_essence_containers, op == OP1a ? "OP1a" : "OPAtom");
mxf->op = op;
} else
mxf->op = OPAtom;
} else {
av_log(mxf->fc, AV_LOG_ERROR, "unknown operational pattern: %02xh %02xh - guessing OP1a\n", op[12], op[13]);
mxf->op = OP1a;
}
if (partition->kag_size <= 0 || partition->kag_size > (1 << 20)) {
av_log(mxf->fc, AV_LOG_WARNING, "invalid KAGSize %i - guessing ", partition->kag_size);
if (mxf->op == OPSONYOpt)
partition->kag_size = 512;
else
partition->kag_size = 1;
av_log(mxf->fc, AV_LOG_WARNING, "%i\n", partition->kag_size);
}
return 0;
}
| {
"code": [
" avio_read(pb, op, sizeof(UID));"
],
"line_no": [
115
]
} | static int FUNC_0(void *VAR_0, AVIOContext *VAR_1, int VAR_2, int VAR_3, UID VAR_4, int64_t VAR_5)
{
MXFContext *mxf = VAR_0;
MXFPartition *partition, *tmp_part;
UID op;
uint64_t footer_partition;
uint32_t nb_essence_containers;
tmp_part = av_realloc_array(mxf->partitions, mxf->partitions_count + 1, sizeof(*mxf->partitions));
if (!tmp_part)
return AVERROR(ENOMEM);
mxf->partitions = tmp_part;
if (mxf->parsing_backward) {
memmove(&mxf->partitions[mxf->last_forward_partition+1],
&mxf->partitions[mxf->last_forward_partition],
(mxf->partitions_count - mxf->last_forward_partition)*sizeof(*mxf->partitions));
partition = mxf->current_partition = &mxf->partitions[mxf->last_forward_partition];
} else {
mxf->last_forward_partition++;
partition = mxf->current_partition = &mxf->partitions[mxf->partitions_count];
}
memset(partition, 0, sizeof(*partition));
mxf->partitions_count++;
partition->pack_length = avio_tell(VAR_1) - VAR_5 + VAR_3;
switch(VAR_4[13]) {
case 2:
partition->type = Header;
break;
case 3:
partition->type = BodyPartition;
break;
case 4:
partition->type = Footer;
break;
default:
av_log(mxf->fc, AV_LOG_ERROR, "unknown partition type %i\n", VAR_4[13]);
return AVERROR_INVALIDDATA;
}
partition->closed = partition->type == Footer || !(VAR_4[14] & 1);
partition->complete = VAR_4[14] > 2;
avio_skip(VAR_1, 4);
partition->kag_size = avio_rb32(VAR_1);
partition->this_partition = avio_rb64(VAR_1);
partition->previous_partition = avio_rb64(VAR_1);
footer_partition = avio_rb64(VAR_1);
partition->header_byte_count = avio_rb64(VAR_1);
partition->index_byte_count = avio_rb64(VAR_1);
partition->index_sid = avio_rb32(VAR_1);
avio_skip(VAR_1, 8);
partition->body_sid = avio_rb32(VAR_1);
avio_read(VAR_1, op, sizeof(UID));
nb_essence_containers = avio_rb32(VAR_1);
if (footer_partition) {
if (mxf->footer_partition && mxf->footer_partition != footer_partition) {
av_log(mxf->fc, AV_LOG_ERROR,
"inconsistent FooterPartition value: %"PRIu64" != %"PRIu64"\n",
mxf->footer_partition, footer_partition);
} else {
mxf->footer_partition = footer_partition;
}
}
av_dlog(mxf->fc,
"PartitionPack: ThisPartition = 0x%"PRIX64
", PreviousPartition = 0x%"PRIX64", "
"FooterPartition = 0x%"PRIX64", IndexSID = %i, BodySID = %i\n",
partition->this_partition,
partition->previous_partition, footer_partition,
partition->index_sid, partition->body_sid);
if (partition->previous_partition &&
mxf->run_in + partition->previous_partition >= VAR_5) {
av_log(mxf->fc, AV_LOG_ERROR,
"PreviousPartition points to this partition or forward\n");
return AVERROR_INVALIDDATA;
}
if (op[12] == 1 && op[13] == 1) mxf->op = OP1a;
else if (op[12] == 1 && op[13] == 2) mxf->op = OP1b;
else if (op[12] == 1 && op[13] == 3) mxf->op = OP1c;
else if (op[12] == 2 && op[13] == 1) mxf->op = OP2a;
else if (op[12] == 2 && op[13] == 2) mxf->op = OP2b;
else if (op[12] == 2 && op[13] == 3) mxf->op = OP2c;
else if (op[12] == 3 && op[13] == 1) mxf->op = OP3a;
else if (op[12] == 3 && op[13] == 2) mxf->op = OP3b;
else if (op[12] == 3 && op[13] == 3) mxf->op = OP3c;
else if (op[12] == 64&& op[13] == 1) mxf->op = OPSONYOpt;
else if (op[12] == 0x10) {
if (nb_essence_containers != 1) {
MXFOP op = nb_essence_containers ? OP1a : OPAtom;
if (!mxf->op)
av_log(mxf->fc, AV_LOG_WARNING, "\"OPAtom\" with %u ECs - assuming %s\n",
nb_essence_containers, op == OP1a ? "OP1a" : "OPAtom");
mxf->op = op;
} else
mxf->op = OPAtom;
} else {
av_log(mxf->fc, AV_LOG_ERROR, "unknown operational pattern: %02xh %02xh - guessing OP1a\n", op[12], op[13]);
mxf->op = OP1a;
}
if (partition->kag_size <= 0 || partition->kag_size > (1 << 20)) {
av_log(mxf->fc, AV_LOG_WARNING, "invalid KAGSize %i - guessing ", partition->kag_size);
if (mxf->op == OPSONYOpt)
partition->kag_size = 512;
else
partition->kag_size = 1;
av_log(mxf->fc, AV_LOG_WARNING, "%i\n", partition->kag_size);
}
return 0;
}
| [
"static int FUNC_0(void *VAR_0, AVIOContext *VAR_1, int VAR_2, int VAR_3, UID VAR_4, int64_t VAR_5)\n{",
"MXFContext *mxf = VAR_0;",
"MXFPartition *partition, *tmp_part;",
"UID op;",
"uint64_t footer_partition;",
"uint32_t nb_essence_containers;",
"tmp_part = av_realloc_array(mxf->partitions, mxf->partitions_count + 1, sizeof(*mxf->partitions));",
"if (!tmp_part)\nreturn AVERROR(ENOMEM);",
"mxf->partitions = tmp_part;",
"if (mxf->parsing_backward) {",
"memmove(&mxf->partitions[mxf->last_forward_partition+1],\n&mxf->partitions[mxf->last_forward_partition],\n(mxf->partitions_count - mxf->last_forward_partition)*sizeof(*mxf->partitions));",
"partition = mxf->current_partition = &mxf->partitions[mxf->last_forward_partition];",
"} else {",
"mxf->last_forward_partition++;",
"partition = mxf->current_partition = &mxf->partitions[mxf->partitions_count];",
"}",
"memset(partition, 0, sizeof(*partition));",
"mxf->partitions_count++;",
"partition->pack_length = avio_tell(VAR_1) - VAR_5 + VAR_3;",
"switch(VAR_4[13]) {",
"case 2:\npartition->type = Header;",
"break;",
"case 3:\npartition->type = BodyPartition;",
"break;",
"case 4:\npartition->type = Footer;",
"break;",
"default:\nav_log(mxf->fc, AV_LOG_ERROR, \"unknown partition type %i\\n\", VAR_4[13]);",
"return AVERROR_INVALIDDATA;",
"}",
"partition->closed = partition->type == Footer || !(VAR_4[14] & 1);",
"partition->complete = VAR_4[14] > 2;",
"avio_skip(VAR_1, 4);",
"partition->kag_size = avio_rb32(VAR_1);",
"partition->this_partition = avio_rb64(VAR_1);",
"partition->previous_partition = avio_rb64(VAR_1);",
"footer_partition = avio_rb64(VAR_1);",
"partition->header_byte_count = avio_rb64(VAR_1);",
"partition->index_byte_count = avio_rb64(VAR_1);",
"partition->index_sid = avio_rb32(VAR_1);",
"avio_skip(VAR_1, 8);",
"partition->body_sid = avio_rb32(VAR_1);",
"avio_read(VAR_1, op, sizeof(UID));",
"nb_essence_containers = avio_rb32(VAR_1);",
"if (footer_partition) {",
"if (mxf->footer_partition && mxf->footer_partition != footer_partition) {",
"av_log(mxf->fc, AV_LOG_ERROR,\n\"inconsistent FooterPartition value: %\"PRIu64\" != %\"PRIu64\"\\n\",\nmxf->footer_partition, footer_partition);",
"} else {",
"mxf->footer_partition = footer_partition;",
"}",
"}",
"av_dlog(mxf->fc,\n\"PartitionPack: ThisPartition = 0x%\"PRIX64\n\", PreviousPartition = 0x%\"PRIX64\", \"\n\"FooterPartition = 0x%\"PRIX64\", IndexSID = %i, BodySID = %i\\n\",\npartition->this_partition,\npartition->previous_partition, footer_partition,\npartition->index_sid, partition->body_sid);",
"if (partition->previous_partition &&\nmxf->run_in + partition->previous_partition >= VAR_5) {",
"av_log(mxf->fc, AV_LOG_ERROR,\n\"PreviousPartition points to this partition or forward\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (op[12] == 1 && op[13] == 1) mxf->op = OP1a;",
"else if (op[12] == 1 && op[13] == 2) mxf->op = OP1b;",
"else if (op[12] == 1 && op[13] == 3) mxf->op = OP1c;",
"else if (op[12] == 2 && op[13] == 1) mxf->op = OP2a;",
"else if (op[12] == 2 && op[13] == 2) mxf->op = OP2b;",
"else if (op[12] == 2 && op[13] == 3) mxf->op = OP2c;",
"else if (op[12] == 3 && op[13] == 1) mxf->op = OP3a;",
"else if (op[12] == 3 && op[13] == 2) mxf->op = OP3b;",
"else if (op[12] == 3 && op[13] == 3) mxf->op = OP3c;",
"else if (op[12] == 64&& op[13] == 1) mxf->op = OPSONYOpt;",
"else if (op[12] == 0x10) {",
"if (nb_essence_containers != 1) {",
"MXFOP op = nb_essence_containers ? OP1a : OPAtom;",
"if (!mxf->op)\nav_log(mxf->fc, AV_LOG_WARNING, \"\\\"OPAtom\\\" with %u ECs - assuming %s\\n\",\nnb_essence_containers, op == OP1a ? \"OP1a\" : \"OPAtom\");",
"mxf->op = op;",
"} else",
"mxf->op = OPAtom;",
"} else {",
"av_log(mxf->fc, AV_LOG_ERROR, \"unknown operational pattern: %02xh %02xh - guessing OP1a\\n\", op[12], op[13]);",
"mxf->op = OP1a;",
"}",
"if (partition->kag_size <= 0 || partition->kag_size > (1 << 20)) {",
"av_log(mxf->fc, AV_LOG_WARNING, \"invalid KAGSize %i - guessing \", partition->kag_size);",
"if (mxf->op == OPSONYOpt)\npartition->kag_size = 512;",
"else\npartition->kag_size = 1;",
"av_log(mxf->fc, AV_LOG_WARNING, \"%i\\n\", partition->kag_size);",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19,
21
],
[
23
],
[
27
],
[
33,
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61,
63
],
[
65
],
[
67,
69
],
[
71
],
[
73,
75
],
[
77
],
[
79,
81
],
[
83
],
[
85
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
123
],
[
125
],
[
127,
129,
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143,
145,
147,
149,
151,
153,
155
],
[
161,
163
],
[
165,
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
205
],
[
207
],
[
213,
215,
217
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
237
],
[
239
],
[
243,
245
],
[
247,
249
],
[
253
],
[
255
],
[
259
],
[
261
]
]
|
14,339 | void commit_start(BlockDriverState *bs, BlockDriverState *base,
BlockDriverState *top, int64_t speed,
BlockdevOnError on_error, BlockCompletionFunc *cb,
void *opaque, const char *backing_file_str, Error **errp)
{
CommitBlockJob *s;
BlockReopenQueue *reopen_queue = NULL;
int orig_overlay_flags;
int orig_base_flags;
BlockDriverState *overlay_bs;
Error *local_err = NULL;
assert(top != bs);
if (top == base) {
error_setg(errp, "Invalid files for merge: top and base are the same");
return;
}
overlay_bs = bdrv_find_overlay(bs, top);
if (overlay_bs == NULL) {
error_setg(errp, "Could not find overlay image for %s:", top->filename);
return;
}
s = block_job_create(&commit_job_driver, bs, speed, cb, opaque, errp);
if (!s) {
return;
}
orig_base_flags = bdrv_get_flags(base);
orig_overlay_flags = bdrv_get_flags(overlay_bs);
/* convert base & overlay_bs to r/w, if necessary */
if (!(orig_overlay_flags & BDRV_O_RDWR)) {
reopen_queue = bdrv_reopen_queue(reopen_queue, overlay_bs, NULL,
orig_overlay_flags | BDRV_O_RDWR);
}
if (!(orig_base_flags & BDRV_O_RDWR)) {
reopen_queue = bdrv_reopen_queue(reopen_queue, base, NULL,
orig_base_flags | BDRV_O_RDWR);
}
if (reopen_queue) {
bdrv_reopen_multiple(reopen_queue, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
block_job_unref(&s->common);
return;
}
}
s->base = blk_new();
blk_insert_bs(s->base, base);
s->top = blk_new();
blk_insert_bs(s->top, top);
s->active = bs;
s->base_flags = orig_base_flags;
s->orig_overlay_flags = orig_overlay_flags;
s->backing_file_str = g_strdup(backing_file_str);
s->on_error = on_error;
s->common.co = qemu_coroutine_create(commit_run);
trace_commit_start(bs, base, top, s, s->common.co, opaque);
qemu_coroutine_enter(s->common.co, s);
}
| true | qemu | 7f0317cfc8da620cdb38cb5cfec5f82b8dd05403 | void commit_start(BlockDriverState *bs, BlockDriverState *base,
BlockDriverState *top, int64_t speed,
BlockdevOnError on_error, BlockCompletionFunc *cb,
void *opaque, const char *backing_file_str, Error **errp)
{
CommitBlockJob *s;
BlockReopenQueue *reopen_queue = NULL;
int orig_overlay_flags;
int orig_base_flags;
BlockDriverState *overlay_bs;
Error *local_err = NULL;
assert(top != bs);
if (top == base) {
error_setg(errp, "Invalid files for merge: top and base are the same");
return;
}
overlay_bs = bdrv_find_overlay(bs, top);
if (overlay_bs == NULL) {
error_setg(errp, "Could not find overlay image for %s:", top->filename);
return;
}
s = block_job_create(&commit_job_driver, bs, speed, cb, opaque, errp);
if (!s) {
return;
}
orig_base_flags = bdrv_get_flags(base);
orig_overlay_flags = bdrv_get_flags(overlay_bs);
if (!(orig_overlay_flags & BDRV_O_RDWR)) {
reopen_queue = bdrv_reopen_queue(reopen_queue, overlay_bs, NULL,
orig_overlay_flags | BDRV_O_RDWR);
}
if (!(orig_base_flags & BDRV_O_RDWR)) {
reopen_queue = bdrv_reopen_queue(reopen_queue, base, NULL,
orig_base_flags | BDRV_O_RDWR);
}
if (reopen_queue) {
bdrv_reopen_multiple(reopen_queue, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
block_job_unref(&s->common);
return;
}
}
s->base = blk_new();
blk_insert_bs(s->base, base);
s->top = blk_new();
blk_insert_bs(s->top, top);
s->active = bs;
s->base_flags = orig_base_flags;
s->orig_overlay_flags = orig_overlay_flags;
s->backing_file_str = g_strdup(backing_file_str);
s->on_error = on_error;
s->common.co = qemu_coroutine_create(commit_run);
trace_commit_start(bs, base, top, s, s->common.co, opaque);
qemu_coroutine_enter(s->common.co, s);
}
| {
"code": [
" s = block_job_create(&commit_job_driver, bs, speed, cb, opaque, errp);"
],
"line_no": [
51
]
} | void FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1,
BlockDriverState *VAR_2, int64_t VAR_3,
BlockdevOnError VAR_4, BlockCompletionFunc *VAR_5,
void *VAR_6, const char *VAR_7, Error **VAR_8)
{
CommitBlockJob *s;
BlockReopenQueue *reopen_queue = NULL;
int VAR_9;
int VAR_10;
BlockDriverState *overlay_bs;
Error *local_err = NULL;
assert(VAR_2 != VAR_0);
if (VAR_2 == VAR_1) {
error_setg(VAR_8, "Invalid files for merge: VAR_2 and VAR_1 are the same");
return;
}
overlay_bs = bdrv_find_overlay(VAR_0, VAR_2);
if (overlay_bs == NULL) {
error_setg(VAR_8, "Could not find overlay image for %s:", VAR_2->filename);
return;
}
s = block_job_create(&commit_job_driver, VAR_0, VAR_3, VAR_5, VAR_6, VAR_8);
if (!s) {
return;
}
VAR_10 = bdrv_get_flags(VAR_1);
VAR_9 = bdrv_get_flags(overlay_bs);
if (!(VAR_9 & BDRV_O_RDWR)) {
reopen_queue = bdrv_reopen_queue(reopen_queue, overlay_bs, NULL,
VAR_9 | BDRV_O_RDWR);
}
if (!(VAR_10 & BDRV_O_RDWR)) {
reopen_queue = bdrv_reopen_queue(reopen_queue, VAR_1, NULL,
VAR_10 | BDRV_O_RDWR);
}
if (reopen_queue) {
bdrv_reopen_multiple(reopen_queue, &local_err);
if (local_err != NULL) {
error_propagate(VAR_8, local_err);
block_job_unref(&s->common);
return;
}
}
s->VAR_1 = blk_new();
blk_insert_bs(s->VAR_1, VAR_1);
s->VAR_2 = blk_new();
blk_insert_bs(s->VAR_2, VAR_2);
s->active = VAR_0;
s->base_flags = VAR_10;
s->VAR_9 = VAR_9;
s->VAR_7 = g_strdup(VAR_7);
s->VAR_4 = VAR_4;
s->common.co = qemu_coroutine_create(commit_run);
trace_commit_start(VAR_0, VAR_1, VAR_2, s, s->common.co, VAR_6);
qemu_coroutine_enter(s->common.co, s);
}
| [
"void FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1,\nBlockDriverState *VAR_2, int64_t VAR_3,\nBlockdevOnError VAR_4, BlockCompletionFunc *VAR_5,\nvoid *VAR_6, const char *VAR_7, Error **VAR_8)\n{",
"CommitBlockJob *s;",
"BlockReopenQueue *reopen_queue = NULL;",
"int VAR_9;",
"int VAR_10;",
"BlockDriverState *overlay_bs;",
"Error *local_err = NULL;",
"assert(VAR_2 != VAR_0);",
"if (VAR_2 == VAR_1) {",
"error_setg(VAR_8, \"Invalid files for merge: VAR_2 and VAR_1 are the same\");",
"return;",
"}",
"overlay_bs = bdrv_find_overlay(VAR_0, VAR_2);",
"if (overlay_bs == NULL) {",
"error_setg(VAR_8, \"Could not find overlay image for %s:\", VAR_2->filename);",
"return;",
"}",
"s = block_job_create(&commit_job_driver, VAR_0, VAR_3, VAR_5, VAR_6, VAR_8);",
"if (!s) {",
"return;",
"}",
"VAR_10 = bdrv_get_flags(VAR_1);",
"VAR_9 = bdrv_get_flags(overlay_bs);",
"if (!(VAR_9 & BDRV_O_RDWR)) {",
"reopen_queue = bdrv_reopen_queue(reopen_queue, overlay_bs, NULL,\nVAR_9 | BDRV_O_RDWR);",
"}",
"if (!(VAR_10 & BDRV_O_RDWR)) {",
"reopen_queue = bdrv_reopen_queue(reopen_queue, VAR_1, NULL,\nVAR_10 | BDRV_O_RDWR);",
"}",
"if (reopen_queue) {",
"bdrv_reopen_multiple(reopen_queue, &local_err);",
"if (local_err != NULL) {",
"error_propagate(VAR_8, local_err);",
"block_job_unref(&s->common);",
"return;",
"}",
"}",
"s->VAR_1 = blk_new();",
"blk_insert_bs(s->VAR_1, VAR_1);",
"s->VAR_2 = blk_new();",
"blk_insert_bs(s->VAR_2, VAR_2);",
"s->active = VAR_0;",
"s->base_flags = VAR_10;",
"s->VAR_9 = VAR_9;",
"s->VAR_7 = g_strdup(VAR_7);",
"s->VAR_4 = VAR_4;",
"s->common.co = qemu_coroutine_create(commit_run);",
"trace_commit_start(VAR_0, VAR_1, VAR_2, s, s->common.co, VAR_6);",
"qemu_coroutine_enter(s->common.co, s);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
105
],
[
107
],
[
111
],
[
113
],
[
117
],
[
121
],
[
123
],
[
127
],
[
131
],
[
133
],
[
137
],
[
139
],
[
141
]
]
|
14,340 | int spapr_tce_dma_read(VIOsPAPRDevice *dev, uint64_t taddr, void *buf,
uint32_t size)
{
#ifdef DEBUG_TCE
fprintf(stderr, "spapr_tce_dma_write taddr=0x%llx size=0x%x\n",
(unsigned long long)taddr, size);
#endif
/* Check for bypass */
if (dev->flags & VIO_PAPR_FLAG_DMA_BYPASS) {
cpu_physical_memory_read(taddr, buf, size);
return 0;
}
while (size) {
uint64_t tce;
uint32_t lsize;
uint64_t txaddr;
/* Check if we are in bound */
if (taddr >= dev->rtce_window_size) {
#ifdef DEBUG_TCE
fprintf(stderr, "spapr_tce_dma_read out of bounds\n");
#endif
return H_DEST_PARM;
}
tce = dev->rtce_table[taddr >> SPAPR_VIO_TCE_PAGE_SHIFT].tce;
/* How much til end of page ? */
lsize = MIN(size, ((~taddr) & SPAPR_VIO_TCE_PAGE_MASK) + 1);
/* Check TCE */
if (!(tce & 1)) {
return H_DEST_PARM;
}
/* Translate */
txaddr = (tce & ~SPAPR_VIO_TCE_PAGE_MASK) |
(taddr & SPAPR_VIO_TCE_PAGE_MASK);
#ifdef DEBUG_TCE
fprintf(stderr, " -> write to txaddr=0x%llx, size=0x%x\n",
(unsigned long long)txaddr, lsize);
#endif
/* Do it */
cpu_physical_memory_read(txaddr, buf, lsize);
buf += lsize;
taddr += lsize;
size -= lsize;
}
return H_SUCCESS;
}
| true | qemu | ad0ebb91cd8b5fdc4a583b03645677771f420a46 | int spapr_tce_dma_read(VIOsPAPRDevice *dev, uint64_t taddr, void *buf,
uint32_t size)
{
#ifdef DEBUG_TCE
fprintf(stderr, "spapr_tce_dma_write taddr=0x%llx size=0x%x\n",
(unsigned long long)taddr, size);
#endif
if (dev->flags & VIO_PAPR_FLAG_DMA_BYPASS) {
cpu_physical_memory_read(taddr, buf, size);
return 0;
}
while (size) {
uint64_t tce;
uint32_t lsize;
uint64_t txaddr;
if (taddr >= dev->rtce_window_size) {
#ifdef DEBUG_TCE
fprintf(stderr, "spapr_tce_dma_read out of bounds\n");
#endif
return H_DEST_PARM;
}
tce = dev->rtce_table[taddr >> SPAPR_VIO_TCE_PAGE_SHIFT].tce;
lsize = MIN(size, ((~taddr) & SPAPR_VIO_TCE_PAGE_MASK) + 1);
if (!(tce & 1)) {
return H_DEST_PARM;
}
txaddr = (tce & ~SPAPR_VIO_TCE_PAGE_MASK) |
(taddr & SPAPR_VIO_TCE_PAGE_MASK);
#ifdef DEBUG_TCE
fprintf(stderr, " -> write to txaddr=0x%llx, size=0x%x\n",
(unsigned long long)txaddr, lsize);
#endif
cpu_physical_memory_read(txaddr, buf, lsize);
buf += lsize;
taddr += lsize;
size -= lsize;
}
return H_SUCCESS;
}
| {
"code": [
"#ifdef DEBUG_TCE",
"#endif",
" return H_SUCCESS;",
"#ifdef DEBUG_TCE",
"#endif",
"#ifdef DEBUG_TCE",
" fprintf(stderr, \"spapr_tce_dma_write taddr=0x%llx size=0x%x\\n\",",
" (unsigned long long)taddr, size);",
"#endif",
" if (dev->flags & VIO_PAPR_FLAG_DMA_BYPASS) {",
" return 0;",
" while (size) {",
" uint64_t tce;",
" uint32_t lsize;",
" uint64_t txaddr;",
" if (taddr >= dev->rtce_window_size) {",
"#ifdef DEBUG_TCE",
"#endif",
" return H_DEST_PARM;",
" tce = dev->rtce_table[taddr >> SPAPR_VIO_TCE_PAGE_SHIFT].tce;",
" lsize = MIN(size, ((~taddr) & SPAPR_VIO_TCE_PAGE_MASK) + 1);",
" return H_DEST_PARM;",
" txaddr = (tce & ~SPAPR_VIO_TCE_PAGE_MASK) |",
" (taddr & SPAPR_VIO_TCE_PAGE_MASK);",
"#ifdef DEBUG_TCE",
" fprintf(stderr, \" -> write to txaddr=0x%llx, size=0x%x\\n\",",
" (unsigned long long)txaddr, lsize);",
"#endif",
" buf += lsize;",
" taddr += lsize;",
" size -= lsize;",
"#ifdef DEBUG_TCE",
" (unsigned long long)taddr, size);",
"#endif",
"int spapr_tce_dma_read(VIOsPAPRDevice *dev, uint64_t taddr, void *buf,",
" uint32_t size)",
"#ifdef DEBUG_TCE",
" fprintf(stderr, \"spapr_tce_dma_write taddr=0x%llx size=0x%x\\n\",",
" (unsigned long long)taddr, size);",
"#endif",
" if (dev->flags & VIO_PAPR_FLAG_DMA_BYPASS) {",
" cpu_physical_memory_read(taddr, buf, size);",
" return 0;",
" while (size) {",
" uint64_t tce;",
" uint32_t lsize;",
" uint64_t txaddr;",
" if (taddr >= dev->rtce_window_size) {",
"#ifdef DEBUG_TCE",
" fprintf(stderr, \"spapr_tce_dma_read out of bounds\\n\");",
"#endif",
" return H_DEST_PARM;",
" tce = dev->rtce_table[taddr >> SPAPR_VIO_TCE_PAGE_SHIFT].tce;",
" lsize = MIN(size, ((~taddr) & SPAPR_VIO_TCE_PAGE_MASK) + 1);",
" if (!(tce & 1)) {",
" return H_DEST_PARM;",
" txaddr = (tce & ~SPAPR_VIO_TCE_PAGE_MASK) |",
" (taddr & SPAPR_VIO_TCE_PAGE_MASK);",
"#ifdef DEBUG_TCE",
" fprintf(stderr, \" -> write to txaddr=0x%llx, size=0x%x\\n\",",
" (unsigned long long)txaddr, lsize);",
"#endif",
" cpu_physical_memory_read(txaddr, buf, lsize);",
" buf += lsize;",
" taddr += lsize;",
" size -= lsize;",
" return H_SUCCESS;"
],
"line_no": [
7,
13,
101,
7,
13,
7,
9,
11,
13,
19,
23,
29,
31,
33,
35,
41,
7,
13,
49,
53,
59,
49,
75,
77,
7,
83,
85,
13,
93,
95,
97,
7,
11,
13,
1,
3,
7,
9,
11,
13,
19,
21,
23,
29,
31,
33,
35,
41,
7,
45,
13,
49,
53,
59,
65,
49,
75,
77,
7,
83,
85,
13,
91,
93,
95,
97,
101
]
} | int FUNC_0(VIOsPAPRDevice *VAR_0, uint64_t VAR_1, void *VAR_2,
uint32_t VAR_3)
{
#ifdef DEBUG_TCE
fprintf(stderr, "spapr_tce_dma_write VAR_1=0x%llx VAR_3=0x%x\n",
(unsigned long long)VAR_1, VAR_3);
#endif
if (VAR_0->flags & VIO_PAPR_FLAG_DMA_BYPASS) {
cpu_physical_memory_read(VAR_1, VAR_2, VAR_3);
return 0;
}
while (VAR_3) {
uint64_t tce;
uint32_t lsize;
uint64_t txaddr;
if (VAR_1 >= VAR_0->rtce_window_size) {
#ifdef DEBUG_TCE
fprintf(stderr, "FUNC_0 out of bounds\n");
#endif
return H_DEST_PARM;
}
tce = VAR_0->rtce_table[VAR_1 >> SPAPR_VIO_TCE_PAGE_SHIFT].tce;
lsize = MIN(VAR_3, ((~VAR_1) & SPAPR_VIO_TCE_PAGE_MASK) + 1);
if (!(tce & 1)) {
return H_DEST_PARM;
}
txaddr = (tce & ~SPAPR_VIO_TCE_PAGE_MASK) |
(VAR_1 & SPAPR_VIO_TCE_PAGE_MASK);
#ifdef DEBUG_TCE
fprintf(stderr, " -> write to txaddr=0x%llx, VAR_3=0x%x\n",
(unsigned long long)txaddr, lsize);
#endif
cpu_physical_memory_read(txaddr, VAR_2, lsize);
VAR_2 += lsize;
VAR_1 += lsize;
VAR_3 -= lsize;
}
return H_SUCCESS;
}
| [
"int FUNC_0(VIOsPAPRDevice *VAR_0, uint64_t VAR_1, void *VAR_2,\nuint32_t VAR_3)\n{",
"#ifdef DEBUG_TCE\nfprintf(stderr, \"spapr_tce_dma_write VAR_1=0x%llx VAR_3=0x%x\\n\",\n(unsigned long long)VAR_1, VAR_3);",
"#endif\nif (VAR_0->flags & VIO_PAPR_FLAG_DMA_BYPASS) {",
"cpu_physical_memory_read(VAR_1, VAR_2, VAR_3);",
"return 0;",
"}",
"while (VAR_3) {",
"uint64_t tce;",
"uint32_t lsize;",
"uint64_t txaddr;",
"if (VAR_1 >= VAR_0->rtce_window_size) {",
"#ifdef DEBUG_TCE\nfprintf(stderr, \"FUNC_0 out of bounds\\n\");",
"#endif\nreturn H_DEST_PARM;",
"}",
"tce = VAR_0->rtce_table[VAR_1 >> SPAPR_VIO_TCE_PAGE_SHIFT].tce;",
"lsize = MIN(VAR_3, ((~VAR_1) & SPAPR_VIO_TCE_PAGE_MASK) + 1);",
"if (!(tce & 1)) {",
"return H_DEST_PARM;",
"}",
"txaddr = (tce & ~SPAPR_VIO_TCE_PAGE_MASK) |\n(VAR_1 & SPAPR_VIO_TCE_PAGE_MASK);",
"#ifdef DEBUG_TCE\nfprintf(stderr, \" -> write to txaddr=0x%llx, VAR_3=0x%x\\n\",\n(unsigned long long)txaddr, lsize);",
"#endif\ncpu_physical_memory_read(txaddr, VAR_2, lsize);",
"VAR_2 += lsize;",
"VAR_1 += lsize;",
"VAR_3 -= lsize;",
"}",
"return H_SUCCESS;",
"}"
]
| [
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
0,
0,
1,
1,
1,
1,
1,
1,
0,
1,
0
]
| [
[
1,
3,
5
],
[
7,
9,
11
],
[
13,
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
41
],
[
43,
45
],
[
47,
49
],
[
51
],
[
53
],
[
59
],
[
65
],
[
67
],
[
69
],
[
75,
77
],
[
81,
83,
85
],
[
87,
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
]
]
|
14,341 | static av_cold int sunrast_encode_init(AVCodecContext *avctx)
{
SUNRASTContext *s = avctx->priv_data;
switch (avctx->coder_type) {
case FF_CODER_TYPE_RLE:
s->type = RT_BYTE_ENCODED;
break;
case FF_CODER_TYPE_RAW:
s->type = RT_STANDARD;
break;
default:
av_log(avctx, AV_LOG_ERROR, "invalid coder_type\n");
return AVERROR(EINVAL);
}
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
avctx->coded_frame->key_frame = 1;
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
s->maptype = RMT_NONE;
s->maplength = 0;
switch (avctx->pix_fmt) {
case AV_PIX_FMT_MONOWHITE:
s->depth = 1;
break;
case AV_PIX_FMT_PAL8 :
s->maptype = RMT_EQUAL_RGB;
s->maplength = 3 * 256;
/* fall-through */
case AV_PIX_FMT_GRAY8:
s->depth = 8;
break;
case AV_PIX_FMT_BGR24:
s->depth = 24;
break;
default:
return AVERROR_BUG;
}
s->length = avctx->height * (FFALIGN(avctx->width * s->depth, 16) >> 3);
s->size = 32 + s->maplength +
s->length * (s->type == RT_BYTE_ENCODED ? 2 : 1);
return 0;
}
| false | FFmpeg | d6604b29ef544793479d7fb4e05ef6622bb3e534 | static av_cold int sunrast_encode_init(AVCodecContext *avctx)
{
SUNRASTContext *s = avctx->priv_data;
switch (avctx->coder_type) {
case FF_CODER_TYPE_RLE:
s->type = RT_BYTE_ENCODED;
break;
case FF_CODER_TYPE_RAW:
s->type = RT_STANDARD;
break;
default:
av_log(avctx, AV_LOG_ERROR, "invalid coder_type\n");
return AVERROR(EINVAL);
}
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
avctx->coded_frame->key_frame = 1;
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
s->maptype = RMT_NONE;
s->maplength = 0;
switch (avctx->pix_fmt) {
case AV_PIX_FMT_MONOWHITE:
s->depth = 1;
break;
case AV_PIX_FMT_PAL8 :
s->maptype = RMT_EQUAL_RGB;
s->maplength = 3 * 256;
case AV_PIX_FMT_GRAY8:
s->depth = 8;
break;
case AV_PIX_FMT_BGR24:
s->depth = 24;
break;
default:
return AVERROR_BUG;
}
s->length = avctx->height * (FFALIGN(avctx->width * s->depth, 16) >> 3);
s->size = 32 + s->maplength +
s->length * (s->type == RT_BYTE_ENCODED ? 2 : 1);
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
SUNRASTContext *s = avctx->priv_data;
switch (avctx->coder_type) {
case FF_CODER_TYPE_RLE:
s->type = RT_BYTE_ENCODED;
break;
case FF_CODER_TYPE_RAW:
s->type = RT_STANDARD;
break;
default:
av_log(avctx, AV_LOG_ERROR, "invalid coder_type\n");
return AVERROR(EINVAL);
}
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
avctx->coded_frame->key_frame = 1;
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
s->maptype = RMT_NONE;
s->maplength = 0;
switch (avctx->pix_fmt) {
case AV_PIX_FMT_MONOWHITE:
s->depth = 1;
break;
case AV_PIX_FMT_PAL8 :
s->maptype = RMT_EQUAL_RGB;
s->maplength = 3 * 256;
case AV_PIX_FMT_GRAY8:
s->depth = 8;
break;
case AV_PIX_FMT_BGR24:
s->depth = 24;
break;
default:
return AVERROR_BUG;
}
s->length = avctx->height * (FFALIGN(avctx->width * s->depth, 16) >> 3);
s->size = 32 + s->maplength +
s->length * (s->type == RT_BYTE_ENCODED ? 2 : 1);
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"SUNRASTContext *s = avctx->priv_data;",
"switch (avctx->coder_type) {",
"case FF_CODER_TYPE_RLE:\ns->type = RT_BYTE_ENCODED;",
"break;",
"case FF_CODER_TYPE_RAW:\ns->type = RT_STANDARD;",
"break;",
"default:\nav_log(avctx, AV_LOG_ERROR, \"invalid coder_type\\n\");",
"return AVERROR(EINVAL);",
"}",
"avctx->coded_frame = av_frame_alloc();",
"if (!avctx->coded_frame)\nreturn AVERROR(ENOMEM);",
"avctx->coded_frame->key_frame = 1;",
"avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;",
"s->maptype = RMT_NONE;",
"s->maplength = 0;",
"switch (avctx->pix_fmt) {",
"case AV_PIX_FMT_MONOWHITE:\ns->depth = 1;",
"break;",
"case AV_PIX_FMT_PAL8 :\ns->maptype = RMT_EQUAL_RGB;",
"s->maplength = 3 * 256;",
"case AV_PIX_FMT_GRAY8:\ns->depth = 8;",
"break;",
"case AV_PIX_FMT_BGR24:\ns->depth = 24;",
"break;",
"default:\nreturn AVERROR_BUG;",
"}",
"s->length = avctx->height * (FFALIGN(avctx->width * s->depth, 16) >> 3);",
"s->size = 32 + s->maplength +\ns->length * (s->type == RT_BYTE_ENCODED ? 2 : 1);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
15
],
[
17,
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
33
],
[
35,
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53,
55
],
[
57
],
[
59,
61
],
[
63
],
[
67,
69
],
[
71
],
[
73,
75
],
[
77
],
[
79,
81
],
[
83
],
[
85
],
[
87,
89
],
[
93
],
[
95
]
]
|
14,342 | static void frame_end(MpegEncContext *s)
{
if (s->unrestricted_mv &&
s->current_picture.reference &&
!s->intra_only) {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
int hshift = desc->log2_chroma_w;
int vshift = desc->log2_chroma_h;
s->mpvencdsp.draw_edges(s->current_picture.f->data[0],
s->current_picture.f->linesize[0],
s->h_edge_pos, s->v_edge_pos,
EDGE_WIDTH, EDGE_WIDTH,
EDGE_TOP | EDGE_BOTTOM);
s->mpvencdsp.draw_edges(s->current_picture.f->data[1],
s->current_picture.f->linesize[1],
s->h_edge_pos >> hshift,
s->v_edge_pos >> vshift,
EDGE_WIDTH >> hshift,
EDGE_WIDTH >> vshift,
EDGE_TOP | EDGE_BOTTOM);
s->mpvencdsp.draw_edges(s->current_picture.f->data[2],
s->current_picture.f->linesize[2],
s->h_edge_pos >> hshift,
s->v_edge_pos >> vshift,
EDGE_WIDTH >> hshift,
EDGE_WIDTH >> vshift,
EDGE_TOP | EDGE_BOTTOM);
}
emms_c();
s->last_pict_type = s->pict_type;
s->last_lambda_for [s->pict_type] = s->current_picture_ptr->f->quality;
if (s->pict_type!= AV_PICTURE_TYPE_B)
s->last_non_b_pict_type = s->pict_type;
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
av_frame_copy_props(s->avctx->coded_frame, s->current_picture.f);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
#if FF_API_ERROR_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
memcpy(s->current_picture.f->error, s->current_picture.encoding_error,
sizeof(s->current_picture.encoding_error));
FF_ENABLE_DEPRECATION_WARNINGS
#endif
} | true | FFmpeg | 99b823f0a1be42abc0f3a6a0da946c4464db5fb6 | static void frame_end(MpegEncContext *s)
{
if (s->unrestricted_mv &&
s->current_picture.reference &&
!s->intra_only) {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
int hshift = desc->log2_chroma_w;
int vshift = desc->log2_chroma_h;
s->mpvencdsp.draw_edges(s->current_picture.f->data[0],
s->current_picture.f->linesize[0],
s->h_edge_pos, s->v_edge_pos,
EDGE_WIDTH, EDGE_WIDTH,
EDGE_TOP | EDGE_BOTTOM);
s->mpvencdsp.draw_edges(s->current_picture.f->data[1],
s->current_picture.f->linesize[1],
s->h_edge_pos >> hshift,
s->v_edge_pos >> vshift,
EDGE_WIDTH >> hshift,
EDGE_WIDTH >> vshift,
EDGE_TOP | EDGE_BOTTOM);
s->mpvencdsp.draw_edges(s->current_picture.f->data[2],
s->current_picture.f->linesize[2],
s->h_edge_pos >> hshift,
s->v_edge_pos >> vshift,
EDGE_WIDTH >> hshift,
EDGE_WIDTH >> vshift,
EDGE_TOP | EDGE_BOTTOM);
}
emms_c();
s->last_pict_type = s->pict_type;
s->last_lambda_for [s->pict_type] = s->current_picture_ptr->f->quality;
if (s->pict_type!= AV_PICTURE_TYPE_B)
s->last_non_b_pict_type = s->pict_type;
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
av_frame_copy_props(s->avctx->coded_frame, s->current_picture.f);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
#if FF_API_ERROR_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
memcpy(s->current_picture.f->error, s->current_picture.encoding_error,
sizeof(s->current_picture.encoding_error));
FF_ENABLE_DEPRECATION_WARNINGS
#endif
} | {
"code": [],
"line_no": []
} | static void FUNC_0(MpegEncContext *VAR_0)
{
if (VAR_0->unrestricted_mv &&
VAR_0->current_picture.reference &&
!VAR_0->intra_only) {
const AVPixFmtDescriptor *VAR_1 = av_pix_fmt_desc_get(VAR_0->avctx->pix_fmt);
int VAR_2 = VAR_1->log2_chroma_w;
int VAR_3 = VAR_1->log2_chroma_h;
VAR_0->mpvencdsp.draw_edges(VAR_0->current_picture.f->data[0],
VAR_0->current_picture.f->linesize[0],
VAR_0->h_edge_pos, VAR_0->v_edge_pos,
EDGE_WIDTH, EDGE_WIDTH,
EDGE_TOP | EDGE_BOTTOM);
VAR_0->mpvencdsp.draw_edges(VAR_0->current_picture.f->data[1],
VAR_0->current_picture.f->linesize[1],
VAR_0->h_edge_pos >> VAR_2,
VAR_0->v_edge_pos >> VAR_3,
EDGE_WIDTH >> VAR_2,
EDGE_WIDTH >> VAR_3,
EDGE_TOP | EDGE_BOTTOM);
VAR_0->mpvencdsp.draw_edges(VAR_0->current_picture.f->data[2],
VAR_0->current_picture.f->linesize[2],
VAR_0->h_edge_pos >> VAR_2,
VAR_0->v_edge_pos >> VAR_3,
EDGE_WIDTH >> VAR_2,
EDGE_WIDTH >> VAR_3,
EDGE_TOP | EDGE_BOTTOM);
}
emms_c();
VAR_0->last_pict_type = VAR_0->pict_type;
VAR_0->last_lambda_for [VAR_0->pict_type] = VAR_0->current_picture_ptr->f->quality;
if (VAR_0->pict_type!= AV_PICTURE_TYPE_B)
VAR_0->last_non_b_pict_type = VAR_0->pict_type;
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
av_frame_copy_props(VAR_0->avctx->coded_frame, VAR_0->current_picture.f);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
#if FF_API_ERROR_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
memcpy(VAR_0->current_picture.f->error, VAR_0->current_picture.encoding_error,
sizeof(VAR_0->current_picture.encoding_error));
FF_ENABLE_DEPRECATION_WARNINGS
#endif
} | [
"static void FUNC_0(MpegEncContext *VAR_0)\n{",
"if (VAR_0->unrestricted_mv &&\nVAR_0->current_picture.reference &&\n!VAR_0->intra_only) {",
"const AVPixFmtDescriptor *VAR_1 = av_pix_fmt_desc_get(VAR_0->avctx->pix_fmt);",
"int VAR_2 = VAR_1->log2_chroma_w;",
"int VAR_3 = VAR_1->log2_chroma_h;",
"VAR_0->mpvencdsp.draw_edges(VAR_0->current_picture.f->data[0],\nVAR_0->current_picture.f->linesize[0],\nVAR_0->h_edge_pos, VAR_0->v_edge_pos,\nEDGE_WIDTH, EDGE_WIDTH,\nEDGE_TOP | EDGE_BOTTOM);",
"VAR_0->mpvencdsp.draw_edges(VAR_0->current_picture.f->data[1],\nVAR_0->current_picture.f->linesize[1],\nVAR_0->h_edge_pos >> VAR_2,\nVAR_0->v_edge_pos >> VAR_3,\nEDGE_WIDTH >> VAR_2,\nEDGE_WIDTH >> VAR_3,\nEDGE_TOP | EDGE_BOTTOM);",
"VAR_0->mpvencdsp.draw_edges(VAR_0->current_picture.f->data[2],\nVAR_0->current_picture.f->linesize[2],\nVAR_0->h_edge_pos >> VAR_2,\nVAR_0->v_edge_pos >> VAR_3,\nEDGE_WIDTH >> VAR_2,\nEDGE_WIDTH >> VAR_3,\nEDGE_TOP | EDGE_BOTTOM);",
"}",
"emms_c();",
"VAR_0->last_pict_type = VAR_0->pict_type;",
"VAR_0->last_lambda_for [VAR_0->pict_type] = VAR_0->current_picture_ptr->f->quality;",
"if (VAR_0->pict_type!= AV_PICTURE_TYPE_B)\nVAR_0->last_non_b_pict_type = VAR_0->pict_type;",
"#if FF_API_CODED_FRAME\nFF_DISABLE_DEPRECATION_WARNINGS\nav_frame_copy_props(VAR_0->avctx->coded_frame, VAR_0->current_picture.f);",
"FF_ENABLE_DEPRECATION_WARNINGS\n#endif\n#if FF_API_ERROR_FRAME\nFF_DISABLE_DEPRECATION_WARNINGS\nmemcpy(VAR_0->current_picture.f->error, VAR_0->current_picture.encoding_error,\nsizeof(VAR_0->current_picture.encoding_error));",
"FF_ENABLE_DEPRECATION_WARNINGS\n#endif\n}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17,
19,
21,
23,
25
],
[
27,
29,
31,
33,
35,
37,
39
],
[
41,
43,
45,
47,
49,
51,
53
],
[
55
],
[
59
],
[
63
],
[
65
],
[
67,
69
],
[
73,
75,
78
],
[
80,
82,
84,
86,
88,
90
],
[
92,
94,
96
]
]
|
14,343 | static int scsi_disk_emulate_read_toc(SCSIRequest *req, uint8_t *outbuf)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev);
int start_track, format, msf, toclen;
uint64_t nb_sectors;
msf = req->cmd.buf[1] & 2;
format = req->cmd.buf[2] & 0xf;
start_track = req->cmd.buf[6];
bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors);
DPRINTF("Read TOC (track %d format %d msf %d)\n", start_track, format, msf >> 1);
nb_sectors /= s->qdev.blocksize / 512;
switch (format) {
case 0:
toclen = cdrom_read_toc(nb_sectors, outbuf, msf, start_track);
break;
case 1:
/* multi session : only a single session defined */
toclen = 12;
memset(outbuf, 0, 12);
outbuf[1] = 0x0a;
outbuf[2] = 0x01;
outbuf[3] = 0x01;
break;
case 2:
toclen = cdrom_read_toc_raw(nb_sectors, outbuf, msf, start_track);
break;
default:
return -1;
}
if (toclen > req->cmd.xfer) {
toclen = req->cmd.xfer;
}
return toclen;
}
| true | qemu | e2f0c49ffae8d3a00272c3cbc68850cc5aafbffa | static int scsi_disk_emulate_read_toc(SCSIRequest *req, uint8_t *outbuf)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev);
int start_track, format, msf, toclen;
uint64_t nb_sectors;
msf = req->cmd.buf[1] & 2;
format = req->cmd.buf[2] & 0xf;
start_track = req->cmd.buf[6];
bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors);
DPRINTF("Read TOC (track %d format %d msf %d)\n", start_track, format, msf >> 1);
nb_sectors /= s->qdev.blocksize / 512;
switch (format) {
case 0:
toclen = cdrom_read_toc(nb_sectors, outbuf, msf, start_track);
break;
case 1:
toclen = 12;
memset(outbuf, 0, 12);
outbuf[1] = 0x0a;
outbuf[2] = 0x01;
outbuf[3] = 0x01;
break;
case 2:
toclen = cdrom_read_toc_raw(nb_sectors, outbuf, msf, start_track);
break;
default:
return -1;
}
if (toclen > req->cmd.xfer) {
toclen = req->cmd.xfer;
}
return toclen;
}
| {
"code": [
" if (toclen > req->cmd.xfer) {",
" toclen = req->cmd.xfer;"
],
"line_no": [
61,
63
]
} | static int FUNC_0(SCSIRequest *VAR_0, uint8_t *VAR_1)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, VAR_0->dev);
int VAR_2, VAR_3, VAR_4, VAR_5;
uint64_t nb_sectors;
VAR_4 = VAR_0->cmd.buf[1] & 2;
VAR_3 = VAR_0->cmd.buf[2] & 0xf;
VAR_2 = VAR_0->cmd.buf[6];
bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors);
DPRINTF("Read TOC (track %d VAR_3 %d VAR_4 %d)\n", VAR_2, VAR_3, VAR_4 >> 1);
nb_sectors /= s->qdev.blocksize / 512;
switch (VAR_3) {
case 0:
VAR_5 = cdrom_read_toc(nb_sectors, VAR_1, VAR_4, VAR_2);
break;
case 1:
VAR_5 = 12;
memset(VAR_1, 0, 12);
VAR_1[1] = 0x0a;
VAR_1[2] = 0x01;
VAR_1[3] = 0x01;
break;
case 2:
VAR_5 = cdrom_read_toc_raw(nb_sectors, VAR_1, VAR_4, VAR_2);
break;
default:
return -1;
}
if (VAR_5 > VAR_0->cmd.xfer) {
VAR_5 = VAR_0->cmd.xfer;
}
return VAR_5;
}
| [
"static int FUNC_0(SCSIRequest *VAR_0, uint8_t *VAR_1)\n{",
"SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, VAR_0->dev);",
"int VAR_2, VAR_3, VAR_4, VAR_5;",
"uint64_t nb_sectors;",
"VAR_4 = VAR_0->cmd.buf[1] & 2;",
"VAR_3 = VAR_0->cmd.buf[2] & 0xf;",
"VAR_2 = VAR_0->cmd.buf[6];",
"bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors);",
"DPRINTF(\"Read TOC (track %d VAR_3 %d VAR_4 %d)\\n\", VAR_2, VAR_3, VAR_4 >> 1);",
"nb_sectors /= s->qdev.blocksize / 512;",
"switch (VAR_3) {",
"case 0:\nVAR_5 = cdrom_read_toc(nb_sectors, VAR_1, VAR_4, VAR_2);",
"break;",
"case 1:\nVAR_5 = 12;",
"memset(VAR_1, 0, 12);",
"VAR_1[1] = 0x0a;",
"VAR_1[2] = 0x01;",
"VAR_1[3] = 0x01;",
"break;",
"case 2:\nVAR_5 = cdrom_read_toc_raw(nb_sectors, VAR_1, VAR_4, VAR_2);",
"break;",
"default:\nreturn -1;",
"}",
"if (VAR_5 > VAR_0->cmd.xfer) {",
"VAR_5 = VAR_0->cmd.xfer;",
"}",
"return VAR_5;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
]
]
|
14,344 | static CharDriverState *qemu_chr_open_win_file(HANDLE fd_out)
{
CharDriverState *chr;
WinCharState *s;
chr = qemu_chr_alloc();
s = g_malloc0(sizeof(WinCharState));
s->hcom = fd_out;
chr->opaque = s;
chr->chr_write = win_chr_write;
return chr;
}
| true | qemu | 2d528d45ecf5ee3c1a566a9f3d664464925ef830 | static CharDriverState *qemu_chr_open_win_file(HANDLE fd_out)
{
CharDriverState *chr;
WinCharState *s;
chr = qemu_chr_alloc();
s = g_malloc0(sizeof(WinCharState));
s->hcom = fd_out;
chr->opaque = s;
chr->chr_write = win_chr_write;
return chr;
}
| {
"code": [
" s = g_malloc0(sizeof(WinCharState));",
" s = g_malloc0(sizeof(WinCharState));",
" s = g_malloc0(sizeof(WinCharState));"
],
"line_no": [
13,
13,
13
]
} | static CharDriverState *FUNC_0(HANDLE fd_out)
{
CharDriverState *chr;
WinCharState *s;
chr = qemu_chr_alloc();
s = g_malloc0(sizeof(WinCharState));
s->hcom = fd_out;
chr->opaque = s;
chr->chr_write = win_chr_write;
return chr;
}
| [
"static CharDriverState *FUNC_0(HANDLE fd_out)\n{",
"CharDriverState *chr;",
"WinCharState *s;",
"chr = qemu_chr_alloc();",
"s = g_malloc0(sizeof(WinCharState));",
"s->hcom = fd_out;",
"chr->opaque = s;",
"chr->chr_write = win_chr_write;",
"return chr;",
"}"
]
| [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
]
|
14,345 | static av_cold int v4l2_decode_init(AVCodecContext *avctx)
{
V4L2m2mContext *s = avctx->priv_data;
V4L2Context *capture = &s->capture;
V4L2Context *output = &s->output;
int ret;
/* if these dimensions are invalid (ie, 0 or too small) an event will be raised
* by the v4l2 driver; this event will trigger a full pipeline reconfig and
* the proper values will be retrieved from the kernel driver.
*/
output->height = capture->height = avctx->coded_height;
output->width = capture->width = avctx->coded_width;
output->av_codec_id = avctx->codec_id;
output->av_pix_fmt = AV_PIX_FMT_NONE;
capture->av_codec_id = AV_CODEC_ID_RAWVIDEO;
capture->av_pix_fmt = avctx->pix_fmt;
ret = ff_v4l2_m2m_codec_init(avctx);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "can't configure decoder\n");
return ret;
}
return v4l2_prepare_decoder(s);
}
| true | FFmpeg | a0c624e299730c8c5800375c2f5f3c6c200053ff | static av_cold int v4l2_decode_init(AVCodecContext *avctx)
{
V4L2m2mContext *s = avctx->priv_data;
V4L2Context *capture = &s->capture;
V4L2Context *output = &s->output;
int ret;
output->height = capture->height = avctx->coded_height;
output->width = capture->width = avctx->coded_width;
output->av_codec_id = avctx->codec_id;
output->av_pix_fmt = AV_PIX_FMT_NONE;
capture->av_codec_id = AV_CODEC_ID_RAWVIDEO;
capture->av_pix_fmt = avctx->pix_fmt;
ret = ff_v4l2_m2m_codec_init(avctx);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "can't configure decoder\n");
return ret;
}
return v4l2_prepare_decoder(s);
}
| {
"code": [
" V4L2m2mContext *s = avctx->priv_data;",
" V4L2m2mContext *s = avctx->priv_data;",
" V4L2m2mContext *s = avctx->priv_data;",
" V4L2m2mContext *s = avctx->priv_data;",
" V4L2Context *capture = &s->capture;",
" V4L2Context *output = &s->output;",
" V4L2m2mContext *s = avctx->priv_data;",
" V4L2m2mContext *s = avctx->priv_data;",
" V4L2m2mContext *s = avctx->priv_data;",
" V4L2Context *capture = &s->capture;",
" V4L2Context *output = &s->output;"
],
"line_no": [
5,
5,
5,
5,
7,
9,
5,
5,
5,
7,
9
]
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
V4L2m2mContext *s = avctx->priv_data;
V4L2Context *capture = &s->capture;
V4L2Context *output = &s->output;
int VAR_0;
output->height = capture->height = avctx->coded_height;
output->width = capture->width = avctx->coded_width;
output->av_codec_id = avctx->codec_id;
output->av_pix_fmt = AV_PIX_FMT_NONE;
capture->av_codec_id = AV_CODEC_ID_RAWVIDEO;
capture->av_pix_fmt = avctx->pix_fmt;
VAR_0 = ff_v4l2_m2m_codec_init(avctx);
if (VAR_0) {
av_log(avctx, AV_LOG_ERROR, "can't configure decoder\n");
return VAR_0;
}
return v4l2_prepare_decoder(s);
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"V4L2m2mContext *s = avctx->priv_data;",
"V4L2Context *capture = &s->capture;",
"V4L2Context *output = &s->output;",
"int VAR_0;",
"output->height = capture->height = avctx->coded_height;",
"output->width = capture->width = avctx->coded_width;",
"output->av_codec_id = avctx->codec_id;",
"output->av_pix_fmt = AV_PIX_FMT_NONE;",
"capture->av_codec_id = AV_CODEC_ID_RAWVIDEO;",
"capture->av_pix_fmt = avctx->pix_fmt;",
"VAR_0 = ff_v4l2_m2m_codec_init(avctx);",
"if (VAR_0) {",
"av_log(avctx, AV_LOG_ERROR, \"can't configure decoder\\n\");",
"return VAR_0;",
"}",
"return v4l2_prepare_decoder(s);",
"}"
]
| [
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
23
],
[
25
],
[
29
],
[
31
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
]
]
|
14,346 | static int16_t square_root(int val)
{
return (ff_sqrt(val << 1) >> 1) & (~1);
}
| true | FFmpeg | 014b178f84fd6c5766e6a626a83f15a0dc635c90 | static int16_t square_root(int val)
{
return (ff_sqrt(val << 1) >> 1) & (~1);
}
| {
"code": [
"static int16_t square_root(int val)"
],
"line_no": [
1
]
} | static int16_t FUNC_0(int val)
{
return (ff_sqrt(val << 1) >> 1) & (~1);
}
| [
"static int16_t FUNC_0(int val)\n{",
"return (ff_sqrt(val << 1) >> 1) & (~1);",
"}"
]
| [
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
14,347 | static int process_audio_header_eacs(AVFormatContext *s)
{
EaDemuxContext *ea = s->priv_data;
AVIOContext *pb = s->pb;
int compression_type;
ea->sample_rate = ea->big_endian ? avio_rb32(pb) : avio_rl32(pb);
ea->bytes = avio_r8(pb); /* 1=8-bit, 2=16-bit */
ea->num_channels = avio_r8(pb);
compression_type = avio_r8(pb);
avio_skip(pb, 13);
switch (compression_type) {
case 0:
switch (ea->bytes) {
case 1: ea->audio_codec = CODEC_ID_PCM_S8; break;
case 2: ea->audio_codec = CODEC_ID_PCM_S16LE; break;
break;
case 1: ea->audio_codec = CODEC_ID_PCM_MULAW; ea->bytes = 1; break;
case 2: ea->audio_codec = CODEC_ID_ADPCM_IMA_EA_EACS; break;
default:
av_log (s, AV_LOG_ERROR, "unsupported stream type; audio compression_type=%i\n", compression_type);
return 1;
| true | FFmpeg | 0d3a51e5d279dd2a56c81ba7a81a70128c5a7545 | static int process_audio_header_eacs(AVFormatContext *s)
{
EaDemuxContext *ea = s->priv_data;
AVIOContext *pb = s->pb;
int compression_type;
ea->sample_rate = ea->big_endian ? avio_rb32(pb) : avio_rl32(pb);
ea->bytes = avio_r8(pb);
ea->num_channels = avio_r8(pb);
compression_type = avio_r8(pb);
avio_skip(pb, 13);
switch (compression_type) {
case 0:
switch (ea->bytes) {
case 1: ea->audio_codec = CODEC_ID_PCM_S8; break;
case 2: ea->audio_codec = CODEC_ID_PCM_S16LE; break;
break;
case 1: ea->audio_codec = CODEC_ID_PCM_MULAW; ea->bytes = 1; break;
case 2: ea->audio_codec = CODEC_ID_ADPCM_IMA_EA_EACS; break;
default:
av_log (s, AV_LOG_ERROR, "unsupported stream type; audio compression_type=%i\n", compression_type);
return 1;
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
EaDemuxContext *ea = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
int VAR_1;
ea->sample_rate = ea->big_endian ? avio_rb32(pb) : avio_rl32(pb);
ea->bytes = avio_r8(pb);
ea->num_channels = avio_r8(pb);
VAR_1 = avio_r8(pb);
avio_skip(pb, 13);
switch (VAR_1) {
case 0:
switch (ea->bytes) {
case 1: ea->audio_codec = CODEC_ID_PCM_S8; break;
case 2: ea->audio_codec = CODEC_ID_PCM_S16LE; break;
break;
case 1: ea->audio_codec = CODEC_ID_PCM_MULAW; ea->bytes = 1; break;
case 2: ea->audio_codec = CODEC_ID_ADPCM_IMA_EA_EACS; break;
default:
av_log (VAR_0, AV_LOG_ERROR, "unsupported stream type; audio VAR_1=%i\n", VAR_1);
return 1;
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"EaDemuxContext *ea = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"int VAR_1;",
"ea->sample_rate = ea->big_endian ? avio_rb32(pb) : avio_rl32(pb);",
"ea->bytes = avio_r8(pb);",
"ea->num_channels = avio_r8(pb);",
"VAR_1 = avio_r8(pb);",
"avio_skip(pb, 13);",
"switch (VAR_1) {",
"case 0:\nswitch (ea->bytes) {",
"case 1: ea->audio_codec = CODEC_ID_PCM_S8; break;",
"case 2: ea->audio_codec = CODEC_ID_PCM_S16LE; break;",
"break;",
"case 1: ea->audio_codec = CODEC_ID_PCM_MULAW; ea->bytes = 1; break;",
"case 2: ea->audio_codec = CODEC_ID_ADPCM_IMA_EA_EACS; break;",
"default:\nav_log (VAR_0, AV_LOG_ERROR, \"unsupported stream type; audio VAR_1=%i\\n\", VAR_1);",
"return 1;"
]
| [
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
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
40
],
[
42
],
[
44
],
[
46,
48
],
[
53
]
]
|
14,348 | void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd)
{
NE2000State *s;
qemu_check_nic_model(nd, "ne2k_isa");
s = qemu_mallocz(sizeof(NE2000State));
register_ioport_write(base, 16, 1, ne2000_ioport_write, s);
register_ioport_read(base, 16, 1, ne2000_ioport_read, s);
register_ioport_write(base + 0x10, 1, 1, ne2000_asic_ioport_write, s);
register_ioport_read(base + 0x10, 1, 1, ne2000_asic_ioport_read, s);
register_ioport_write(base + 0x10, 2, 2, ne2000_asic_ioport_write, s);
register_ioport_read(base + 0x10, 2, 2, ne2000_asic_ioport_read, s);
register_ioport_write(base + 0x1f, 1, 1, ne2000_reset_ioport_write, s);
register_ioport_read(base + 0x1f, 1, 1, ne2000_reset_ioport_read, s);
s->irq = irq;
memcpy(s->macaddr, nd->macaddr, 6);
ne2000_reset(s);
s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
ne2000_receive, ne2000_can_receive, s);
qemu_format_nic_info_str(s->vc, s->macaddr);
register_savevm("ne2000", -1, 2, ne2000_save, ne2000_load, s);
}
| true | qemu | b946a1533209f61a93e34898aebb5b43154b99c3 | void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd)
{
NE2000State *s;
qemu_check_nic_model(nd, "ne2k_isa");
s = qemu_mallocz(sizeof(NE2000State));
register_ioport_write(base, 16, 1, ne2000_ioport_write, s);
register_ioport_read(base, 16, 1, ne2000_ioport_read, s);
register_ioport_write(base + 0x10, 1, 1, ne2000_asic_ioport_write, s);
register_ioport_read(base + 0x10, 1, 1, ne2000_asic_ioport_read, s);
register_ioport_write(base + 0x10, 2, 2, ne2000_asic_ioport_write, s);
register_ioport_read(base + 0x10, 2, 2, ne2000_asic_ioport_read, s);
register_ioport_write(base + 0x1f, 1, 1, ne2000_reset_ioport_write, s);
register_ioport_read(base + 0x1f, 1, 1, ne2000_reset_ioport_read, s);
s->irq = irq;
memcpy(s->macaddr, nd->macaddr, 6);
ne2000_reset(s);
s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
ne2000_receive, ne2000_can_receive, s);
qemu_format_nic_info_str(s->vc, s->macaddr);
register_savevm("ne2000", -1, 2, ne2000_save, ne2000_load, s);
}
| {
"code": [
" ne2000_receive, ne2000_can_receive, s);",
" ne2000_receive, ne2000_can_receive, s);"
],
"line_no": [
49,
49
]
} | void FUNC_0(int VAR_0, qemu_irq VAR_1, NICInfo *VAR_2)
{
NE2000State *s;
qemu_check_nic_model(VAR_2, "ne2k_isa");
s = qemu_mallocz(sizeof(NE2000State));
register_ioport_write(VAR_0, 16, 1, ne2000_ioport_write, s);
register_ioport_read(VAR_0, 16, 1, ne2000_ioport_read, s);
register_ioport_write(VAR_0 + 0x10, 1, 1, ne2000_asic_ioport_write, s);
register_ioport_read(VAR_0 + 0x10, 1, 1, ne2000_asic_ioport_read, s);
register_ioport_write(VAR_0 + 0x10, 2, 2, ne2000_asic_ioport_write, s);
register_ioport_read(VAR_0 + 0x10, 2, 2, ne2000_asic_ioport_read, s);
register_ioport_write(VAR_0 + 0x1f, 1, 1, ne2000_reset_ioport_write, s);
register_ioport_read(VAR_0 + 0x1f, 1, 1, ne2000_reset_ioport_read, s);
s->VAR_1 = VAR_1;
memcpy(s->macaddr, VAR_2->macaddr, 6);
ne2000_reset(s);
s->vc = qemu_new_vlan_client(VAR_2->vlan, VAR_2->model, VAR_2->name,
ne2000_receive, ne2000_can_receive, s);
qemu_format_nic_info_str(s->vc, s->macaddr);
register_savevm("ne2000", -1, 2, ne2000_save, ne2000_load, s);
}
| [
"void FUNC_0(int VAR_0, qemu_irq VAR_1, NICInfo *VAR_2)\n{",
"NE2000State *s;",
"qemu_check_nic_model(VAR_2, \"ne2k_isa\");",
"s = qemu_mallocz(sizeof(NE2000State));",
"register_ioport_write(VAR_0, 16, 1, ne2000_ioport_write, s);",
"register_ioport_read(VAR_0, 16, 1, ne2000_ioport_read, s);",
"register_ioport_write(VAR_0 + 0x10, 1, 1, ne2000_asic_ioport_write, s);",
"register_ioport_read(VAR_0 + 0x10, 1, 1, ne2000_asic_ioport_read, s);",
"register_ioport_write(VAR_0 + 0x10, 2, 2, ne2000_asic_ioport_write, s);",
"register_ioport_read(VAR_0 + 0x10, 2, 2, ne2000_asic_ioport_read, s);",
"register_ioport_write(VAR_0 + 0x1f, 1, 1, ne2000_reset_ioport_write, s);",
"register_ioport_read(VAR_0 + 0x1f, 1, 1, ne2000_reset_ioport_read, s);",
"s->VAR_1 = VAR_1;",
"memcpy(s->macaddr, VAR_2->macaddr, 6);",
"ne2000_reset(s);",
"s->vc = qemu_new_vlan_client(VAR_2->vlan, VAR_2->model, VAR_2->name,\nne2000_receive, ne2000_can_receive, s);",
"qemu_format_nic_info_str(s->vc, s->macaddr);",
"register_savevm(\"ne2000\", -1, 2, ne2000_save, ne2000_load, s);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
47,
49
],
[
53
],
[
57
],
[
59
]
]
|
14,349 | static void add_pid_to_pmt(MpegTSContext *ts, unsigned int programid,
unsigned int pid)
{
struct Program *p = get_program(ts, programid);
int i;
if (!p)
return;
if (p->nb_pids >= MAX_PIDS_PER_PROGRAM)
return;
for (i = 0; i < MAX_PIDS_PER_PROGRAM; i++)
if (p->pids[i] == pid)
return;
p->pids[p->nb_pids++] = pid;
}
| true | FFmpeg | 786594184a1797cc4b573001f3eeb188d5912062 | static void add_pid_to_pmt(MpegTSContext *ts, unsigned int programid,
unsigned int pid)
{
struct Program *p = get_program(ts, programid);
int i;
if (!p)
return;
if (p->nb_pids >= MAX_PIDS_PER_PROGRAM)
return;
for (i = 0; i < MAX_PIDS_PER_PROGRAM; i++)
if (p->pids[i] == pid)
return;
p->pids[p->nb_pids++] = pid;
}
| {
"code": [
" for (i = 0; i < MAX_PIDS_PER_PROGRAM; i++)"
],
"line_no": [
23
]
} | static void FUNC_0(MpegTSContext *VAR_0, unsigned int VAR_1,
unsigned int VAR_2)
{
struct Program *VAR_3 = get_program(VAR_0, VAR_1);
int VAR_4;
if (!VAR_3)
return;
if (VAR_3->nb_pids >= MAX_PIDS_PER_PROGRAM)
return;
for (VAR_4 = 0; VAR_4 < MAX_PIDS_PER_PROGRAM; VAR_4++)
if (VAR_3->pids[VAR_4] == VAR_2)
return;
VAR_3->pids[VAR_3->nb_pids++] = VAR_2;
}
| [
"static void FUNC_0(MpegTSContext *VAR_0, unsigned int VAR_1,\nunsigned int VAR_2)\n{",
"struct Program *VAR_3 = get_program(VAR_0, VAR_1);",
"int VAR_4;",
"if (!VAR_3)\nreturn;",
"if (VAR_3->nb_pids >= MAX_PIDS_PER_PROGRAM)\nreturn;",
"for (VAR_4 = 0; VAR_4 < MAX_PIDS_PER_PROGRAM; VAR_4++)",
"if (VAR_3->pids[VAR_4] == VAR_2)\nreturn;",
"VAR_3->pids[VAR_3->nb_pids++] = VAR_2;",
"}"
]
| [
0,
0,
0,
0,
0,
1,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11,
13
],
[
17,
19
],
[
23
],
[
25,
27
],
[
31
],
[
33
]
]
|
14,351 | static int calculate_geometry(int64_t total_sectors, uint16_t* cyls,
uint8_t* heads, uint8_t* secs_per_cyl)
{
uint32_t cyls_times_heads;
if (total_sectors > 65535 * 16 * 255)
return -EFBIG;
if (total_sectors > 65535 * 16 * 63) {
*secs_per_cyl = 255;
*heads = 16;
cyls_times_heads = total_sectors / *secs_per_cyl;
} else {
*secs_per_cyl = 17;
cyls_times_heads = total_sectors / *secs_per_cyl;
*heads = (cyls_times_heads + 1023) / 1024;
if (*heads < 4)
*heads = 4;
if (cyls_times_heads >= (*heads * 1024) || *heads > 16) {
*secs_per_cyl = 31;
*heads = 16;
cyls_times_heads = total_sectors / *secs_per_cyl;
}
if (cyls_times_heads >= (*heads * 1024)) {
*secs_per_cyl = 63;
*heads = 16;
cyls_times_heads = total_sectors / *secs_per_cyl;
}
}
// Note: Rounding up deviates from the Virtual PC behaviour
// However, we need this to avoid truncating images in qemu-img convert
*cyls = (cyls_times_heads + *heads - 1) / *heads;
return 0;
}
| true | qemu | dede4188cc817a039154ed2ecd7f3285f6b94056 | static int calculate_geometry(int64_t total_sectors, uint16_t* cyls,
uint8_t* heads, uint8_t* secs_per_cyl)
{
uint32_t cyls_times_heads;
if (total_sectors > 65535 * 16 * 255)
return -EFBIG;
if (total_sectors > 65535 * 16 * 63) {
*secs_per_cyl = 255;
*heads = 16;
cyls_times_heads = total_sectors / *secs_per_cyl;
} else {
*secs_per_cyl = 17;
cyls_times_heads = total_sectors / *secs_per_cyl;
*heads = (cyls_times_heads + 1023) / 1024;
if (*heads < 4)
*heads = 4;
if (cyls_times_heads >= (*heads * 1024) || *heads > 16) {
*secs_per_cyl = 31;
*heads = 16;
cyls_times_heads = total_sectors / *secs_per_cyl;
}
if (cyls_times_heads >= (*heads * 1024)) {
*secs_per_cyl = 63;
*heads = 16;
cyls_times_heads = total_sectors / *secs_per_cyl;
}
}
*cyls = (cyls_times_heads + *heads - 1) / *heads;
return 0;
}
| {
"code": [
" *cyls = (cyls_times_heads + *heads - 1) / *heads;",
" return -EFBIG;"
],
"line_no": [
71,
13
]
} | static int FUNC_0(int64_t VAR_0, uint16_t* VAR_1,
uint8_t* VAR_2, uint8_t* VAR_3)
{
uint32_t cyls_times_heads;
if (VAR_0 > 65535 * 16 * 255)
return -EFBIG;
if (VAR_0 > 65535 * 16 * 63) {
*VAR_3 = 255;
*VAR_2 = 16;
cyls_times_heads = VAR_0 / *VAR_3;
} else {
*VAR_3 = 17;
cyls_times_heads = VAR_0 / *VAR_3;
*VAR_2 = (cyls_times_heads + 1023) / 1024;
if (*VAR_2 < 4)
*VAR_2 = 4;
if (cyls_times_heads >= (*VAR_2 * 1024) || *VAR_2 > 16) {
*VAR_3 = 31;
*VAR_2 = 16;
cyls_times_heads = VAR_0 / *VAR_3;
}
if (cyls_times_heads >= (*VAR_2 * 1024)) {
*VAR_3 = 63;
*VAR_2 = 16;
cyls_times_heads = VAR_0 / *VAR_3;
}
}
*VAR_1 = (cyls_times_heads + *VAR_2 - 1) / *VAR_2;
return 0;
}
| [
"static int FUNC_0(int64_t VAR_0, uint16_t* VAR_1,\nuint8_t* VAR_2, uint8_t* VAR_3)\n{",
"uint32_t cyls_times_heads;",
"if (VAR_0 > 65535 * 16 * 255)\nreturn -EFBIG;",
"if (VAR_0 > 65535 * 16 * 63) {",
"*VAR_3 = 255;",
"*VAR_2 = 16;",
"cyls_times_heads = VAR_0 / *VAR_3;",
"} else {",
"*VAR_3 = 17;",
"cyls_times_heads = VAR_0 / *VAR_3;",
"*VAR_2 = (cyls_times_heads + 1023) / 1024;",
"if (*VAR_2 < 4)\n*VAR_2 = 4;",
"if (cyls_times_heads >= (*VAR_2 * 1024) || *VAR_2 > 16) {",
"*VAR_3 = 31;",
"*VAR_2 = 16;",
"cyls_times_heads = VAR_0 / *VAR_3;",
"}",
"if (cyls_times_heads >= (*VAR_2 * 1024)) {",
"*VAR_3 = 63;",
"*VAR_2 = 16;",
"cyls_times_heads = VAR_0 / *VAR_3;",
"}",
"}",
"*VAR_1 = (cyls_times_heads + *VAR_2 - 1) / *VAR_2;",
"return 0;",
"}"
]
| [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11,
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35,
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
71
],
[
75
],
[
77
]
]
|
14,352 | static inline void gen_arm_shift_reg(TCGv var, int shiftop,
TCGv shift, int flags)
{
if (flags) {
switch (shiftop) {
case 0: gen_helper_shl_cc(var, var, shift); break;
case 1: gen_helper_shr_cc(var, var, shift); break;
case 2: gen_helper_sar_cc(var, var, shift); break;
case 3: gen_helper_ror_cc(var, var, shift); break;
}
} else {
switch (shiftop) {
case 0: gen_helper_shl(var, var, shift); break;
case 1: gen_helper_shr(var, var, shift); break;
case 2: gen_helper_sar(var, var, shift); break;
case 3: tcg_gen_andi_i32(shift, shift, 0x1f);
tcg_gen_rotr_i32(var, var, shift); break;
}
}
dead_tmp(shift);
}
| true | qemu | 7d1b0095bff7157e856d1d0e6c4295641ced2752 | static inline void gen_arm_shift_reg(TCGv var, int shiftop,
TCGv shift, int flags)
{
if (flags) {
switch (shiftop) {
case 0: gen_helper_shl_cc(var, var, shift); break;
case 1: gen_helper_shr_cc(var, var, shift); break;
case 2: gen_helper_sar_cc(var, var, shift); break;
case 3: gen_helper_ror_cc(var, var, shift); break;
}
} else {
switch (shiftop) {
case 0: gen_helper_shl(var, var, shift); break;
case 1: gen_helper_shr(var, var, shift); break;
case 2: gen_helper_sar(var, var, shift); break;
case 3: tcg_gen_andi_i32(shift, shift, 0x1f);
tcg_gen_rotr_i32(var, var, shift); break;
}
}
dead_tmp(shift);
}
| {
"code": [
" dead_tmp(shift);"
],
"line_no": [
39
]
} | static inline void FUNC_0(TCGv VAR_0, int VAR_1,
TCGv VAR_2, int VAR_3)
{
if (VAR_3) {
switch (VAR_1) {
case 0: gen_helper_shl_cc(VAR_0, VAR_0, VAR_2); break;
case 1: gen_helper_shr_cc(VAR_0, VAR_0, VAR_2); break;
case 2: gen_helper_sar_cc(VAR_0, VAR_0, VAR_2); break;
case 3: gen_helper_ror_cc(VAR_0, VAR_0, VAR_2); break;
}
} else {
switch (VAR_1) {
case 0: gen_helper_shl(VAR_0, VAR_0, VAR_2); break;
case 1: gen_helper_shr(VAR_0, VAR_0, VAR_2); break;
case 2: gen_helper_sar(VAR_0, VAR_0, VAR_2); break;
case 3: tcg_gen_andi_i32(VAR_2, VAR_2, 0x1f);
tcg_gen_rotr_i32(VAR_0, VAR_0, VAR_2); break;
}
}
dead_tmp(VAR_2);
}
| [
"static inline void FUNC_0(TCGv VAR_0, int VAR_1,\nTCGv VAR_2, int VAR_3)\n{",
"if (VAR_3) {",
"switch (VAR_1) {",
"case 0: gen_helper_shl_cc(VAR_0, VAR_0, VAR_2); break;",
"case 1: gen_helper_shr_cc(VAR_0, VAR_0, VAR_2); break;",
"case 2: gen_helper_sar_cc(VAR_0, VAR_0, VAR_2); break;",
"case 3: gen_helper_ror_cc(VAR_0, VAR_0, VAR_2); break;",
"}",
"} else {",
"switch (VAR_1) {",
"case 0: gen_helper_shl(VAR_0, VAR_0, VAR_2); break;",
"case 1: gen_helper_shr(VAR_0, VAR_0, VAR_2); break;",
"case 2: gen_helper_sar(VAR_0, VAR_0, VAR_2); break;",
"case 3: tcg_gen_andi_i32(VAR_2, VAR_2, 0x1f);",
"tcg_gen_rotr_i32(VAR_0, VAR_0, VAR_2); break;",
"}",
"}",
"dead_tmp(VAR_2);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
]
]
|
14,353 | static inline void RENAME(bgr15ToY)(uint8_t *dst, uint8_t *src, int width)
{
int i;
for(i=0; i<width; i++)
{
int d= ((uint16_t*)src)[i];
int b= d&0x1F;
int g= (d>>5)&0x1F;
int r= (d>>10)&0x1F;
dst[i]= ((RY*r + GY*g + BY*b)>>(RGB2YUV_SHIFT-3)) + 16;
}
}
| true | FFmpeg | 2da0d70d5eebe42f9fcd27ee554419ebe2a5da06 | static inline void RENAME(bgr15ToY)(uint8_t *dst, uint8_t *src, int width)
{
int i;
for(i=0; i<width; i++)
{
int d= ((uint16_t*)src)[i];
int b= d&0x1F;
int g= (d>>5)&0x1F;
int r= (d>>10)&0x1F;
dst[i]= ((RY*r + GY*g + BY*b)>>(RGB2YUV_SHIFT-3)) + 16;
}
}
| {
"code": [
"\tint i;",
"\tint i;",
"\tint i;",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\t\tint d= ((uint16_t*)src)[i];",
"\t\tint b= d&0x1F;",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\t\tint d= ((uint16_t*)src)[i];",
"\t\tint b= d&0x1F;",
"\t\tint g= (d>>5)&0x1F;",
"\t\tint r= (d>>10)&0x1F;",
"\t\tdst[i]= ((RY*r + GY*g + BY*b)>>(RGB2YUV_SHIFT-3)) + 16;",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\t\tint d= ((uint16_t*)src)[i];",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\t\tint d= ((uint16_t*)src)[i];",
"\t\tint g= (d>>5)&0x1F;",
"\t\tdst[i]= ((RY*r + GY*g + BY*b)>>(RGB2YUV_SHIFT-3)) + 16;",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tint i;",
"\tint i;",
"\tint i;",
"\tint i;"
],
"line_no": [
5,
5,
5,
5,
7,
5,
7,
5,
7,
5,
7,
5,
7,
5,
7,
5,
7,
5,
7,
5,
7,
11,
13,
5,
7,
5,
7,
11,
13,
15,
17,
21,
5,
7,
5,
7,
5,
7,
5,
7,
5,
7,
5,
7,
11,
5,
7,
5,
7,
11,
15,
21,
5,
7,
5,
7,
5,
7,
5,
5,
5,
5,
5
]
} | static inline void FUNC_0(bgr15ToY)(uint8_t *dst, uint8_t *src, int width)
{
int VAR_0;
for(VAR_0=0; VAR_0<width; VAR_0++)
{
int d= ((uint16_t*)src)[VAR_0];
int b= d&0x1F;
int g= (d>>5)&0x1F;
int r= (d>>10)&0x1F;
dst[VAR_0]= ((RY*r + GY*g + BY*b)>>(RGB2YUV_SHIFT-3)) + 16;
}
}
| [
"static inline void FUNC_0(bgr15ToY)(uint8_t *dst, uint8_t *src, int width)\n{",
"int VAR_0;",
"for(VAR_0=0; VAR_0<width; VAR_0++)",
"{",
"int d= ((uint16_t*)src)[VAR_0];",
"int b= d&0x1F;",
"int g= (d>>5)&0x1F;",
"int r= (d>>10)&0x1F;",
"dst[VAR_0]= ((RY*r + GY*g + BY*b)>>(RGB2YUV_SHIFT-3)) + 16;",
"}",
"}"
]
| [
0,
1,
1,
0,
1,
1,
1,
1,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
]
]
|
14,355 | static void decode_gain_info(GetBitContext *gb, int *gaininfo)
{
int i, n;
while (get_bits1(gb)) {
/* NOTHING */
}
n = get_bits_count(gb) - 1; // amount of elements*2 to update
i = 0;
while (n--) {
int index = get_bits(gb, 3);
int gain = get_bits1(gb) ? get_bits(gb, 4) - 7 : -1;
while (i <= index)
gaininfo[i++] = gain;
}
while (i <= 8)
gaininfo[i++] = 0;
}
| true | FFmpeg | 65988b991659fea72365be53e17d10953c0f8f78 | static void decode_gain_info(GetBitContext *gb, int *gaininfo)
{
int i, n;
while (get_bits1(gb)) {
}
n = get_bits_count(gb) - 1;
i = 0;
while (n--) {
int index = get_bits(gb, 3);
int gain = get_bits1(gb) ? get_bits(gb, 4) - 7 : -1;
while (i <= index)
gaininfo[i++] = gain;
}
while (i <= 8)
gaininfo[i++] = 0;
}
| {
"code": [
" while (get_bits1(gb)) {"
],
"line_no": [
9
]
} | static void FUNC_0(GetBitContext *VAR_0, int *VAR_1)
{
int VAR_2, VAR_3;
while (get_bits1(VAR_0)) {
}
VAR_3 = get_bits_count(VAR_0) - 1;
VAR_2 = 0;
while (VAR_3--) {
int VAR_4 = get_bits(VAR_0, 3);
int VAR_5 = get_bits1(VAR_0) ? get_bits(VAR_0, 4) - 7 : -1;
while (VAR_2 <= VAR_4)
VAR_1[VAR_2++] = VAR_5;
}
while (VAR_2 <= 8)
VAR_1[VAR_2++] = 0;
}
| [
"static void FUNC_0(GetBitContext *VAR_0, int *VAR_1)\n{",
"int VAR_2, VAR_3;",
"while (get_bits1(VAR_0)) {",
"}",
"VAR_3 = get_bits_count(VAR_0) - 1;",
"VAR_2 = 0;",
"while (VAR_3--) {",
"int VAR_4 = get_bits(VAR_0, 3);",
"int VAR_5 = get_bits1(VAR_0) ? get_bits(VAR_0, 4) - 7 : -1;",
"while (VAR_2 <= VAR_4)\nVAR_1[VAR_2++] = VAR_5;",
"}",
"while (VAR_2 <= 8)\nVAR_1[VAR_2++] = 0;",
"}"
]
| [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31,
33
],
[
35
],
[
37,
39
],
[
41
]
]
|
14,357 | static int decode_b_picture_primary_header(VC9Context *v)
{
GetBitContext *gb = &v->s.gb;
int pqindex;
/* Prolog common to all frametypes should be done in caller */
if (v->profile == PROFILE_SIMPLE)
{
av_log(v->s.avctx, AV_LOG_ERROR, "Found a B frame while in Simple Profile!\n");
return FRAME_SKIPED;
}
v->bfraction = vc9_bfraction_lut[get_vlc2(gb, vc9_bfraction_vlc.table,
VC9_BFRACTION_VLC_BITS, 2)];
if (v->bfraction < -1)
{
av_log(v->s.avctx, AV_LOG_ERROR, "Invalid BFRaction\n");
return FRAME_SKIPED;
}
else if (!v->bfraction)
{
/* We actually have a BI frame */
v->s.pict_type = BI_TYPE;
v->buffer_fullness = get_bits(gb, 7);
}
/* Read the quantization stuff */
pqindex = get_bits(gb, 5);
if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
v->pq = pquant_table[0][pqindex];
else
{
v->pq = pquant_table[v->quantizer_mode-1][pqindex];
}
if (pqindex < 9) v->halfpq = get_bits(gb, 1);
if (v->quantizer_mode == QUANT_FRAME_EXPLICIT)
v->pquantizer = get_bits(gb, 1);
if (v->profile > PROFILE_MAIN)
{
if (v->postprocflag) v->postproc = get_bits(gb, 2);
if (v->extended_mv == 1 && v->s.pict_type != BI_TYPE)
v->mvrange = get_prefix(gb, 0, 3);
}
else
{
if (v->extended_mv == 1)
v->mvrange = get_prefix(gb, 0, 3);
}
/* Read the MV mode */
if (v->s.pict_type != BI_TYPE)
{
v->mv_mode = get_bits(gb, 1);
if (v->pq < 13)
{
if (!v->mv_mode)
{
v->mv_mode = get_bits(gb, 2);
if (v->mv_mode)
av_log(v->s.avctx, AV_LOG_ERROR,
"mv_mode for lowquant B frame was %i\n", v->mv_mode);
}
}
else
{
if (!v->mv_mode)
{
if (get_bits(gb, 1))
av_log(v->s.avctx, AV_LOG_ERROR,
"mv_mode for highquant B frame was %i\n", v->mv_mode);
}
v->mv_mode = 1-v->mv_mode; //To match (pq < 13) mapping
}
}
return 0;
}
| true | FFmpeg | 7cc84d241ba6ef8e27e4d057176a4ad385ad3d59 | static int decode_b_picture_primary_header(VC9Context *v)
{
GetBitContext *gb = &v->s.gb;
int pqindex;
if (v->profile == PROFILE_SIMPLE)
{
av_log(v->s.avctx, AV_LOG_ERROR, "Found a B frame while in Simple Profile!\n");
return FRAME_SKIPED;
}
v->bfraction = vc9_bfraction_lut[get_vlc2(gb, vc9_bfraction_vlc.table,
VC9_BFRACTION_VLC_BITS, 2)];
if (v->bfraction < -1)
{
av_log(v->s.avctx, AV_LOG_ERROR, "Invalid BFRaction\n");
return FRAME_SKIPED;
}
else if (!v->bfraction)
{
v->s.pict_type = BI_TYPE;
v->buffer_fullness = get_bits(gb, 7);
}
pqindex = get_bits(gb, 5);
if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
v->pq = pquant_table[0][pqindex];
else
{
v->pq = pquant_table[v->quantizer_mode-1][pqindex];
}
if (pqindex < 9) v->halfpq = get_bits(gb, 1);
if (v->quantizer_mode == QUANT_FRAME_EXPLICIT)
v->pquantizer = get_bits(gb, 1);
if (v->profile > PROFILE_MAIN)
{
if (v->postprocflag) v->postproc = get_bits(gb, 2);
if (v->extended_mv == 1 && v->s.pict_type != BI_TYPE)
v->mvrange = get_prefix(gb, 0, 3);
}
else
{
if (v->extended_mv == 1)
v->mvrange = get_prefix(gb, 0, 3);
}
if (v->s.pict_type != BI_TYPE)
{
v->mv_mode = get_bits(gb, 1);
if (v->pq < 13)
{
if (!v->mv_mode)
{
v->mv_mode = get_bits(gb, 2);
if (v->mv_mode)
av_log(v->s.avctx, AV_LOG_ERROR,
"mv_mode for lowquant B frame was %i\n", v->mv_mode);
}
}
else
{
if (!v->mv_mode)
{
if (get_bits(gb, 1))
av_log(v->s.avctx, AV_LOG_ERROR,
"mv_mode for highquant B frame was %i\n", v->mv_mode);
}
v->mv_mode = 1-v->mv_mode;
}
}
return 0;
}
| {
"code": [
" if (v->profile > PROFILE_MAIN)",
" GetBitContext *gb = &v->s.gb;",
" GetBitContext *gb = &v->s.gb;",
" if (v->profile > PROFILE_MAIN)",
" if (v->profile > PROFILE_MAIN)",
" if (v->profile > PROFILE_MAIN)",
" if (v->profile > PROFILE_MAIN)",
" if (v->profile > PROFILE_MAIN)",
" if (v->profile > PROFILE_MAIN)",
" if (v->profile > PROFILE_MAIN)"
],
"line_no": [
75,
5,
5,
75,
75,
75,
75,
75,
75,
75
]
} | static int FUNC_0(VC9Context *VAR_0)
{
GetBitContext *gb = &VAR_0->s.gb;
int VAR_1;
if (VAR_0->profile == PROFILE_SIMPLE)
{
av_log(VAR_0->s.avctx, AV_LOG_ERROR, "Found a B frame while in Simple Profile!\n");
return FRAME_SKIPED;
}
VAR_0->bfraction = vc9_bfraction_lut[get_vlc2(gb, vc9_bfraction_vlc.table,
VC9_BFRACTION_VLC_BITS, 2)];
if (VAR_0->bfraction < -1)
{
av_log(VAR_0->s.avctx, AV_LOG_ERROR, "Invalid BFRaction\n");
return FRAME_SKIPED;
}
else if (!VAR_0->bfraction)
{
VAR_0->s.pict_type = BI_TYPE;
VAR_0->buffer_fullness = get_bits(gb, 7);
}
VAR_1 = get_bits(gb, 5);
if (VAR_0->quantizer_mode == QUANT_FRAME_IMPLICIT)
VAR_0->pq = pquant_table[0][VAR_1];
else
{
VAR_0->pq = pquant_table[VAR_0->quantizer_mode-1][VAR_1];
}
if (VAR_1 < 9) VAR_0->halfpq = get_bits(gb, 1);
if (VAR_0->quantizer_mode == QUANT_FRAME_EXPLICIT)
VAR_0->pquantizer = get_bits(gb, 1);
if (VAR_0->profile > PROFILE_MAIN)
{
if (VAR_0->postprocflag) VAR_0->postproc = get_bits(gb, 2);
if (VAR_0->extended_mv == 1 && VAR_0->s.pict_type != BI_TYPE)
VAR_0->mvrange = get_prefix(gb, 0, 3);
}
else
{
if (VAR_0->extended_mv == 1)
VAR_0->mvrange = get_prefix(gb, 0, 3);
}
if (VAR_0->s.pict_type != BI_TYPE)
{
VAR_0->mv_mode = get_bits(gb, 1);
if (VAR_0->pq < 13)
{
if (!VAR_0->mv_mode)
{
VAR_0->mv_mode = get_bits(gb, 2);
if (VAR_0->mv_mode)
av_log(VAR_0->s.avctx, AV_LOG_ERROR,
"mv_mode for lowquant B frame was %i\n", VAR_0->mv_mode);
}
}
else
{
if (!VAR_0->mv_mode)
{
if (get_bits(gb, 1))
av_log(VAR_0->s.avctx, AV_LOG_ERROR,
"mv_mode for highquant B frame was %i\n", VAR_0->mv_mode);
}
VAR_0->mv_mode = 1-VAR_0->mv_mode;
}
}
return 0;
}
| [
"static int FUNC_0(VC9Context *VAR_0)\n{",
"GetBitContext *gb = &VAR_0->s.gb;",
"int VAR_1;",
"if (VAR_0->profile == PROFILE_SIMPLE)\n{",
"av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"Found a B frame while in Simple Profile!\\n\");",
"return FRAME_SKIPED;",
"}",
"VAR_0->bfraction = vc9_bfraction_lut[get_vlc2(gb, vc9_bfraction_vlc.table,\nVC9_BFRACTION_VLC_BITS, 2)];",
"if (VAR_0->bfraction < -1)\n{",
"av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"Invalid BFRaction\\n\");",
"return FRAME_SKIPED;",
"}",
"else if (!VAR_0->bfraction)\n{",
"VAR_0->s.pict_type = BI_TYPE;",
"VAR_0->buffer_fullness = get_bits(gb, 7);",
"}",
"VAR_1 = get_bits(gb, 5);",
"if (VAR_0->quantizer_mode == QUANT_FRAME_IMPLICIT)\nVAR_0->pq = pquant_table[0][VAR_1];",
"else\n{",
"VAR_0->pq = pquant_table[VAR_0->quantizer_mode-1][VAR_1];",
"}",
"if (VAR_1 < 9) VAR_0->halfpq = get_bits(gb, 1);",
"if (VAR_0->quantizer_mode == QUANT_FRAME_EXPLICIT)\nVAR_0->pquantizer = get_bits(gb, 1);",
"if (VAR_0->profile > PROFILE_MAIN)\n{",
"if (VAR_0->postprocflag) VAR_0->postproc = get_bits(gb, 2);",
"if (VAR_0->extended_mv == 1 && VAR_0->s.pict_type != BI_TYPE)\nVAR_0->mvrange = get_prefix(gb, 0, 3);",
"}",
"else\n{",
"if (VAR_0->extended_mv == 1)\nVAR_0->mvrange = get_prefix(gb, 0, 3);",
"}",
"if (VAR_0->s.pict_type != BI_TYPE)\n{",
"VAR_0->mv_mode = get_bits(gb, 1);",
"if (VAR_0->pq < 13)\n{",
"if (!VAR_0->mv_mode)\n{",
"VAR_0->mv_mode = get_bits(gb, 2);",
"if (VAR_0->mv_mode)\nav_log(VAR_0->s.avctx, AV_LOG_ERROR,\n\"mv_mode for lowquant B frame was %i\\n\", VAR_0->mv_mode);",
"}",
"}",
"else\n{",
"if (!VAR_0->mv_mode)\n{",
"if (get_bits(gb, 1))\nav_log(VAR_0->s.avctx, AV_LOG_ERROR,\n\"mv_mode for highquant B frame was %i\\n\", VAR_0->mv_mode);",
"}",
"VAR_0->mv_mode = 1-VAR_0->mv_mode;",
"}",
"}",
"return 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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23,
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
43
],
[
45
],
[
47
],
[
53
],
[
55,
57
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
75,
77
],
[
79
],
[
81,
83
],
[
85
],
[
87,
89
],
[
91,
93
],
[
95
],
[
99,
101
],
[
103
],
[
105,
107
],
[
109,
111
],
[
113
],
[
115,
117,
119
],
[
121
],
[
123
],
[
125,
127
],
[
129,
131
],
[
133,
135,
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
]
]
|
14,358 | static inline void check_privileged(DisasContext *s)
{
if (s->tb->flags & (PSW_MASK_PSTATE >> 32)) {
gen_program_exception(s, PGM_PRIVILEGED);
}
}
| true | qemu | 8841d9dfc7f871cec7c3401a8a2d31ad34e881f7 | static inline void check_privileged(DisasContext *s)
{
if (s->tb->flags & (PSW_MASK_PSTATE >> 32)) {
gen_program_exception(s, PGM_PRIVILEGED);
}
}
| {
"code": [
"static inline void check_privileged(DisasContext *s)"
],
"line_no": [
1
]
} | static inline void FUNC_0(DisasContext *VAR_0)
{
if (VAR_0->tb->flags & (PSW_MASK_PSTATE >> 32)) {
gen_program_exception(VAR_0, PGM_PRIVILEGED);
}
}
| [
"static inline void FUNC_0(DisasContext *VAR_0)\n{",
"if (VAR_0->tb->flags & (PSW_MASK_PSTATE >> 32)) {",
"gen_program_exception(VAR_0, PGM_PRIVILEGED);",
"}",
"}"
]
| [
1,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
]
|
14,361 | static int decode_p_mbs(VC9Context *v)
{
MpegEncContext *s = &v->s;
GetBitContext *gb = &v->s.gb;
int current_mb = 0, i; /* MB/Block Position info */
uint8_t cbpcy[4], previous_cbpcy[4], predicted_cbpcy,
*p_cbpcy /* Pointer to skip some math */;
int hybrid_pred; /* Prediction types */
int mv_mode_bit = 0;
int mqdiff, mquant; /* MB quantization */
int ttmb; /* MB Transform type */
static const int size_table[6] = { 0, 2, 3, 4, 5, 8 },
offset_table[6] = { 0, 1, 3, 7, 15, 31 };
int mb_has_coeffs = 1; /* last_flag */
int dmv_x, dmv_y; /* Differential MV components */
int k_x, k_y; /* Long MV fixed bitlength */
int hpel_flag; /* Some MB properties */
int index, index1; /* LUT indices */
int val, sign; /* MVDATA temp values */
/* Select ttmb table depending on pq */
if (v->pq < 5) v->ttmb_vlc = &vc9_ttmb_vlc[0];
else if (v->pq < 13) v->ttmb_vlc = &vc9_ttmb_vlc[1];
else v->ttmb_vlc = &vc9_ttmb_vlc[2];
/* Select proper long MV range */
switch (v->mvrange)
{
case 1: k_x = 10; k_y = 9; break;
case 2: k_x = 12; k_y = 10; break;
case 3: k_x = 13; k_y = 11; break;
default: /*case 0 too */ k_x = 9; k_y = 8; break;
}
hpel_flag = v->mv_mode & 1; //MV_PMODE is HPEL
k_x -= hpel_flag;
k_y -= hpel_flag;
/* Reset CBPCY predictors */
memset(v->previous_line_cbpcy, 0, s->mb_stride<<2);
for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++)
{
/* Init CBPCY for line */
*((uint32_t*)previous_cbpcy) = 0x00000000;
p_cbpcy = v->previous_line_cbpcy+4;
for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++, p_cbpcy += 4)
{
if (v->mv_type_mb_plane.is_raw)
v->mv_type_mb_plane.data[current_mb] = get_bits(gb, 1);
if (v->skip_mb_plane.is_raw)
v->skip_mb_plane.data[current_mb] = get_bits(gb, 1);
if (!mv_mode_bit) /* 1MV mode */
{
if (!v->skip_mb_plane.data[current_mb])
{
GET_MVDATA(dmv_x, dmv_y);
/* hybrid mv pred, 8.3.5.3.4 */
if (v->mv_mode == MV_PMODE_1MV ||
v->mv_mode == MV_PMODE_MIXED_MV)
hybrid_pred = get_bits(gb, 1);
if (s->mb_intra && !mb_has_coeffs)
{
GET_MQUANT();
s->ac_pred = get_bits(gb, 1);
}
else if (mb_has_coeffs)
{
if (s->mb_intra) s->ac_pred = get_bits(gb, 1);
predicted_cbpcy = get_vlc2(gb, v->cbpcy_vlc->table, VC9_CBPCY_P_VLC_BITS, 2);
cbpcy[0] = (p_cbpcy[-1] == p_cbpcy[2]) ? previous_cbpcy[1] : p_cbpcy[2];
cbpcy[0] ^= ((predicted_cbpcy>>5)&0x01);
cbpcy[1] = (p_cbpcy[2] == p_cbpcy[3]) ? cbpcy[0] : p_cbpcy[3];
cbpcy[1] ^= ((predicted_cbpcy>>4)&0x01);
cbpcy[2] = (previous_cbpcy[1] == cbpcy[0]) ? previous_cbpcy[3] : cbpcy[0];
cbpcy[2] ^= ((predicted_cbpcy>>3)&0x01);
cbpcy[3] = (cbpcy[1] == cbpcy[0]) ? cbpcy[2] : cbpcy[1];
cbpcy[3] ^= ((predicted_cbpcy>>2)&0x01);
//GET_CBPCY(v->cbpcy_vlc->table, VC9_CBPCY_P_VLC_BITS);
GET_MQUANT();
}
if (!v->ttmbf)
ttmb = get_vlc2(gb, v->ttmb_vlc->table,
VC9_TTMB_VLC_BITS, 12);
/* TODO: decode blocks from that mb wrt cbpcy */
}
else //Skipped
{
/* hybrid mv pred, 8.3.5.3.4 */
if (v->mv_mode == MV_PMODE_1MV ||
v->mv_mode == MV_PMODE_MIXED_MV)
hybrid_pred = get_bits(gb, 1);
}
} //1MV mode
else //4MV mode
{
if (!v->skip_mb_plane.data[current_mb] /* unskipped MB */)
{
/* Get CBPCY */
GET_CBPCY(v->cbpcy_vlc->table, VC9_CBPCY_P_VLC_BITS);
for (i=0; i<4; i++) //For all 4 Y blocks
{
if (cbpcy[i] /* cbpcy set for this block */)
{
GET_MVDATA(dmv_x, dmv_y);
}
if (v->mv_mode == MV_PMODE_MIXED_MV /* Hybrid pred */)
hybrid_pred = get_bits(gb, 1);
GET_MQUANT();
if (s->mb_intra /* One of the 4 blocks is intra */ &&
index /* non-zero pred for that block */)
s->ac_pred = get_bits(gb, 1);
if (!v->ttmbf)
ttmb = get_vlc2(gb, v->ttmb_vlc->table,
VC9_TTMB_VLC_BITS, 12);
/* TODO: Process blocks wrt cbpcy */
}
}
else //Skipped MB
{
for (i=0; i<4; i++) //All 4 Y blocks
{
if (v->mv_mode == MV_PMODE_MIXED_MV /* Hybrid pred */)
hybrid_pred = get_bits(gb, 1);
/* TODO: do something */
}
}
}
/* Update for next block */
#if TRACE > 2
av_log(s->avctx, AV_LOG_DEBUG, "Block %4i: p_cbpcy=%i%i%i%i, previous_cbpcy=%i%i%i%i,"
" cbpcy=%i%i%i%i\n", current_mb,
p_cbpcy[0], p_cbpcy[1], p_cbpcy[2], p_cbpcy[3],
previous_cbpcy[0], previous_cbpcy[1], previous_cbpcy[2], previous_cbpcy[3],
cbpcy[0], cbpcy[1], cbpcy[2], cbpcy[3]);
#endif
*((uint32_t*)p_cbpcy) = *((uint32_t*)previous_cbpcy);
*((uint32_t*)previous_cbpcy) = *((uint32_t*)cbpcy);
current_mb++;
}
}
return 0;
}
| true | FFmpeg | 7cc84d241ba6ef8e27e4d057176a4ad385ad3d59 | static int decode_p_mbs(VC9Context *v)
{
MpegEncContext *s = &v->s;
GetBitContext *gb = &v->s.gb;
int current_mb = 0, i;
uint8_t cbpcy[4], previous_cbpcy[4], predicted_cbpcy,
*p_cbpcy ;
int hybrid_pred;
int mv_mode_bit = 0;
int mqdiff, mquant;
int ttmb;
static const int size_table[6] = { 0, 2, 3, 4, 5, 8 },
offset_table[6] = { 0, 1, 3, 7, 15, 31 };
int mb_has_coeffs = 1;
int dmv_x, dmv_y;
int k_x, k_y;
int hpel_flag;
int index, index1;
int val, sign;
if (v->pq < 5) v->ttmb_vlc = &vc9_ttmb_vlc[0];
else if (v->pq < 13) v->ttmb_vlc = &vc9_ttmb_vlc[1];
else v->ttmb_vlc = &vc9_ttmb_vlc[2];
switch (v->mvrange)
{
case 1: k_x = 10; k_y = 9; break;
case 2: k_x = 12; k_y = 10; break;
case 3: k_x = 13; k_y = 11; break;
default: k_x = 9; k_y = 8; break;
}
hpel_flag = v->mv_mode & 1;
k_x -= hpel_flag;
k_y -= hpel_flag;
memset(v->previous_line_cbpcy, 0, s->mb_stride<<2);
for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++)
{
*((uint32_t*)previous_cbpcy) = 0x00000000;
p_cbpcy = v->previous_line_cbpcy+4;
for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++, p_cbpcy += 4)
{
if (v->mv_type_mb_plane.is_raw)
v->mv_type_mb_plane.data[current_mb] = get_bits(gb, 1);
if (v->skip_mb_plane.is_raw)
v->skip_mb_plane.data[current_mb] = get_bits(gb, 1);
if (!mv_mode_bit)
{
if (!v->skip_mb_plane.data[current_mb])
{
GET_MVDATA(dmv_x, dmv_y);
if (v->mv_mode == MV_PMODE_1MV ||
v->mv_mode == MV_PMODE_MIXED_MV)
hybrid_pred = get_bits(gb, 1);
if (s->mb_intra && !mb_has_coeffs)
{
GET_MQUANT();
s->ac_pred = get_bits(gb, 1);
}
else if (mb_has_coeffs)
{
if (s->mb_intra) s->ac_pred = get_bits(gb, 1);
predicted_cbpcy = get_vlc2(gb, v->cbpcy_vlc->table, VC9_CBPCY_P_VLC_BITS, 2);
cbpcy[0] = (p_cbpcy[-1] == p_cbpcy[2]) ? previous_cbpcy[1] : p_cbpcy[2];
cbpcy[0] ^= ((predicted_cbpcy>>5)&0x01);
cbpcy[1] = (p_cbpcy[2] == p_cbpcy[3]) ? cbpcy[0] : p_cbpcy[3];
cbpcy[1] ^= ((predicted_cbpcy>>4)&0x01);
cbpcy[2] = (previous_cbpcy[1] == cbpcy[0]) ? previous_cbpcy[3] : cbpcy[0];
cbpcy[2] ^= ((predicted_cbpcy>>3)&0x01);
cbpcy[3] = (cbpcy[1] == cbpcy[0]) ? cbpcy[2] : cbpcy[1];
cbpcy[3] ^= ((predicted_cbpcy>>2)&0x01);
GET_MQUANT();
}
if (!v->ttmbf)
ttmb = get_vlc2(gb, v->ttmb_vlc->table,
VC9_TTMB_VLC_BITS, 12);
}
else
{
if (v->mv_mode == MV_PMODE_1MV ||
v->mv_mode == MV_PMODE_MIXED_MV)
hybrid_pred = get_bits(gb, 1);
}
}
else
{
if (!v->skip_mb_plane.data[current_mb] )
{
GET_CBPCY(v->cbpcy_vlc->table, VC9_CBPCY_P_VLC_BITS);
for (i=0; i<4; i++)
{
if (cbpcy[i] )
{
GET_MVDATA(dmv_x, dmv_y);
}
if (v->mv_mode == MV_PMODE_MIXED_MV )
hybrid_pred = get_bits(gb, 1);
GET_MQUANT();
if (s->mb_intra &&
index )
s->ac_pred = get_bits(gb, 1);
if (!v->ttmbf)
ttmb = get_vlc2(gb, v->ttmb_vlc->table,
VC9_TTMB_VLC_BITS, 12);
}
}
else MB
{
for (i=0; i<4; i++)
{
if (v->mv_mode == MV_PMODE_MIXED_MV )
hybrid_pred = get_bits(gb, 1);
}
}
}
#if TRACE > 2
av_log(s->avctx, AV_LOG_DEBUG, "Block %4i: p_cbpcy=%i%i%i%i, previous_cbpcy=%i%i%i%i,"
" cbpcy=%i%i%i%i\n", current_mb,
p_cbpcy[0], p_cbpcy[1], p_cbpcy[2], p_cbpcy[3],
previous_cbpcy[0], previous_cbpcy[1], previous_cbpcy[2], previous_cbpcy[3],
cbpcy[0], cbpcy[1], cbpcy[2], cbpcy[3]);
#endif
*((uint32_t*)p_cbpcy) = *((uint32_t*)previous_cbpcy);
*((uint32_t*)previous_cbpcy) = *((uint32_t*)cbpcy);
current_mb++;
}
}
return 0;
}
| {
"code": [
"#endif",
"#endif",
"#endif",
"#endif",
" GetBitContext *gb = &v->s.gb;",
" GetBitContext *gb = &v->s.gb;",
"#endif",
" if (v->pq < 5) v->ttmb_vlc = &vc9_ttmb_vlc[0];",
" else if (v->pq < 13) v->ttmb_vlc = &vc9_ttmb_vlc[1];",
" else v->ttmb_vlc = &vc9_ttmb_vlc[2];",
" \" cbpcy=%i%i%i%i\\n\", current_mb,",
" current_mb++;",
" if (v->pq < 5) v->ttmb_vlc = &vc9_ttmb_vlc[0];",
" else if (v->pq < 13) v->ttmb_vlc = &vc9_ttmb_vlc[1];",
" else v->ttmb_vlc = &vc9_ttmb_vlc[2];",
" case 1: k_x = 10; k_y = 9; break;",
" case 2: k_x = 12; k_y = 10; break;",
" case 3: k_x = 13; k_y = 11; break;",
" k_x -= hpel_flag;",
" k_y -= hpel_flag;",
" v->mv_type_mb_plane.data[current_mb] = get_bits(gb, 1);",
" v->skip_mb_plane.data[current_mb] = get_bits(gb, 1);",
" if (!v->skip_mb_plane.data[current_mb])",
" cbpcy[0] = (p_cbpcy[-1] == p_cbpcy[2]) ? previous_cbpcy[1] : p_cbpcy[2];",
" cbpcy[0] ^= ((predicted_cbpcy>>5)&0x01);",
" cbpcy[1] = (p_cbpcy[2] == p_cbpcy[3]) ? cbpcy[0] : p_cbpcy[3];",
" cbpcy[1] ^= ((predicted_cbpcy>>4)&0x01);",
" cbpcy[2] = (previous_cbpcy[1] == cbpcy[0]) ? previous_cbpcy[3] : cbpcy[0];",
" cbpcy[2] ^= ((predicted_cbpcy>>3)&0x01);",
" cbpcy[3] = (cbpcy[1] == cbpcy[0]) ? cbpcy[2] : cbpcy[1];",
" cbpcy[3] ^= ((predicted_cbpcy>>2)&0x01);",
" ttmb = get_vlc2(gb, v->ttmb_vlc->table,",
" ttmb = get_vlc2(gb, v->ttmb_vlc->table,",
" \" cbpcy=%i%i%i%i\\n\", current_mb,",
" current_mb++;",
" if (v->pq < 5) v->ttmb_vlc = &vc9_ttmb_vlc[0];",
" else if (v->pq < 13) v->ttmb_vlc = &vc9_ttmb_vlc[1];",
" else v->ttmb_vlc = &vc9_ttmb_vlc[2];",
" v->skip_mb_plane.data[current_mb] = get_bits(gb, 1);",
" current_mb++;",
"#endif",
"#endif"
],
"line_no": [
287,
287,
287,
287,
7,
7,
287,
45,
47,
49,
279,
293,
45,
47,
49,
59,
61,
63,
73,
75,
103,
107,
113,
147,
149,
151,
153,
155,
157,
159,
161,
173,
235,
279,
293,
45,
47,
49,
107,
293,
287,
287
]
} | static int FUNC_0(VC9Context *VAR_0)
{
MpegEncContext *s = &VAR_0->s;
GetBitContext *gb = &VAR_0->s.gb;
int VAR_1 = 0, VAR_2;
uint8_t cbpcy[4], previous_cbpcy[4], predicted_cbpcy,
*p_cbpcy ;
int VAR_3;
int VAR_4 = 0;
int VAR_5, VAR_6;
int VAR_7;
static const int VAR_8[6] = { 0, 2, 3, 4, 5, 8 },
VAR_9[6] = { 0, 1, 3, 7, 15, 31 };
int VAR_10 = 1;
int VAR_11, VAR_12;
int VAR_13, VAR_14;
int VAR_15;
int VAR_16, VAR_17;
int VAR_18, VAR_19;
if (VAR_0->pq < 5) VAR_0->ttmb_vlc = &vc9_ttmb_vlc[0];
else if (VAR_0->pq < 13) VAR_0->ttmb_vlc = &vc9_ttmb_vlc[1];
else VAR_0->ttmb_vlc = &vc9_ttmb_vlc[2];
switch (VAR_0->mvrange)
{
case 1: VAR_13 = 10; VAR_14 = 9; break;
case 2: VAR_13 = 12; VAR_14 = 10; break;
case 3: VAR_13 = 13; VAR_14 = 11; break;
default: VAR_13 = 9; VAR_14 = 8; break;
}
VAR_15 = VAR_0->mv_mode & 1;
VAR_13 -= VAR_15;
VAR_14 -= VAR_15;
memset(VAR_0->previous_line_cbpcy, 0, s->mb_stride<<2);
for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++)
{
*((uint32_t*)previous_cbpcy) = 0x00000000;
p_cbpcy = VAR_0->previous_line_cbpcy+4;
for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++, p_cbpcy += 4)
{
if (VAR_0->mv_type_mb_plane.is_raw)
VAR_0->mv_type_mb_plane.data[VAR_1] = get_bits(gb, 1);
if (VAR_0->skip_mb_plane.is_raw)
VAR_0->skip_mb_plane.data[VAR_1] = get_bits(gb, 1);
if (!VAR_4)
{
if (!VAR_0->skip_mb_plane.data[VAR_1])
{
GET_MVDATA(VAR_11, VAR_12);
if (VAR_0->mv_mode == MV_PMODE_1MV ||
VAR_0->mv_mode == MV_PMODE_MIXED_MV)
VAR_3 = get_bits(gb, 1);
if (s->mb_intra && !VAR_10)
{
GET_MQUANT();
s->ac_pred = get_bits(gb, 1);
}
else if (VAR_10)
{
if (s->mb_intra) s->ac_pred = get_bits(gb, 1);
predicted_cbpcy = get_vlc2(gb, VAR_0->cbpcy_vlc->table, VC9_CBPCY_P_VLC_BITS, 2);
cbpcy[0] = (p_cbpcy[-1] == p_cbpcy[2]) ? previous_cbpcy[1] : p_cbpcy[2];
cbpcy[0] ^= ((predicted_cbpcy>>5)&0x01);
cbpcy[1] = (p_cbpcy[2] == p_cbpcy[3]) ? cbpcy[0] : p_cbpcy[3];
cbpcy[1] ^= ((predicted_cbpcy>>4)&0x01);
cbpcy[2] = (previous_cbpcy[1] == cbpcy[0]) ? previous_cbpcy[3] : cbpcy[0];
cbpcy[2] ^= ((predicted_cbpcy>>3)&0x01);
cbpcy[3] = (cbpcy[1] == cbpcy[0]) ? cbpcy[2] : cbpcy[1];
cbpcy[3] ^= ((predicted_cbpcy>>2)&0x01);
GET_MQUANT();
}
if (!VAR_0->ttmbf)
VAR_7 = get_vlc2(gb, VAR_0->ttmb_vlc->table,
VC9_TTMB_VLC_BITS, 12);
}
else
{
if (VAR_0->mv_mode == MV_PMODE_1MV ||
VAR_0->mv_mode == MV_PMODE_MIXED_MV)
VAR_3 = get_bits(gb, 1);
}
}
else
{
if (!VAR_0->skip_mb_plane.data[VAR_1] )
{
GET_CBPCY(VAR_0->cbpcy_vlc->table, VC9_CBPCY_P_VLC_BITS);
for (VAR_2=0; VAR_2<4; VAR_2++)
{
if (cbpcy[VAR_2] )
{
GET_MVDATA(VAR_11, VAR_12);
}
if (VAR_0->mv_mode == MV_PMODE_MIXED_MV )
VAR_3 = get_bits(gb, 1);
GET_MQUANT();
if (s->mb_intra &&
VAR_16 )
s->ac_pred = get_bits(gb, 1);
if (!VAR_0->ttmbf)
VAR_7 = get_vlc2(gb, VAR_0->ttmb_vlc->table,
VC9_TTMB_VLC_BITS, 12);
}
}
else MB
{
for (VAR_2=0; VAR_2<4; VAR_2++)
{
if (VAR_0->mv_mode == MV_PMODE_MIXED_MV )
VAR_3 = get_bits(gb, 1);
}
}
}
#if TRACE > 2
av_log(s->avctx, AV_LOG_DEBUG, "Block %4i: p_cbpcy=%VAR_2%VAR_2%VAR_2%VAR_2, previous_cbpcy=%VAR_2%VAR_2%VAR_2%VAR_2,"
" cbpcy=%VAR_2%VAR_2%VAR_2%VAR_2\n", VAR_1,
p_cbpcy[0], p_cbpcy[1], p_cbpcy[2], p_cbpcy[3],
previous_cbpcy[0], previous_cbpcy[1], previous_cbpcy[2], previous_cbpcy[3],
cbpcy[0], cbpcy[1], cbpcy[2], cbpcy[3]);
#endif
*((uint32_t*)p_cbpcy) = *((uint32_t*)previous_cbpcy);
*((uint32_t*)previous_cbpcy) = *((uint32_t*)cbpcy);
VAR_1++;
}
}
return 0;
}
| [
"static int FUNC_0(VC9Context *VAR_0)\n{",
"MpegEncContext *s = &VAR_0->s;",
"GetBitContext *gb = &VAR_0->s.gb;",
"int VAR_1 = 0, VAR_2;",
"uint8_t cbpcy[4], previous_cbpcy[4], predicted_cbpcy,\n*p_cbpcy ;",
"int VAR_3;",
"int VAR_4 = 0;",
"int VAR_5, VAR_6;",
"int VAR_7;",
"static const int VAR_8[6] = { 0, 2, 3, 4, 5, 8 },",
"VAR_9[6] = { 0, 1, 3, 7, 15, 31 };",
"int VAR_10 = 1;",
"int VAR_11, VAR_12;",
"int VAR_13, VAR_14;",
"int VAR_15;",
"int VAR_16, VAR_17;",
"int VAR_18, VAR_19;",
"if (VAR_0->pq < 5) VAR_0->ttmb_vlc = &vc9_ttmb_vlc[0];",
"else if (VAR_0->pq < 13) VAR_0->ttmb_vlc = &vc9_ttmb_vlc[1];",
"else VAR_0->ttmb_vlc = &vc9_ttmb_vlc[2];",
"switch (VAR_0->mvrange)\n{",
"case 1: VAR_13 = 10; VAR_14 = 9; break;",
"case 2: VAR_13 = 12; VAR_14 = 10; break;",
"case 3: VAR_13 = 13; VAR_14 = 11; break;",
"default: VAR_13 = 9; VAR_14 = 8; break;",
"}",
"VAR_15 = VAR_0->mv_mode & 1;",
"VAR_13 -= VAR_15;",
"VAR_14 -= VAR_15;",
"memset(VAR_0->previous_line_cbpcy, 0, s->mb_stride<<2);",
"for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++)",
"{",
"*((uint32_t*)previous_cbpcy) = 0x00000000;",
"p_cbpcy = VAR_0->previous_line_cbpcy+4;",
"for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++, p_cbpcy += 4)",
"{",
"if (VAR_0->mv_type_mb_plane.is_raw)\nVAR_0->mv_type_mb_plane.data[VAR_1] = get_bits(gb, 1);",
"if (VAR_0->skip_mb_plane.is_raw)\nVAR_0->skip_mb_plane.data[VAR_1] = get_bits(gb, 1);",
"if (!VAR_4)\n{",
"if (!VAR_0->skip_mb_plane.data[VAR_1])\n{",
"GET_MVDATA(VAR_11, VAR_12);",
"if (VAR_0->mv_mode == MV_PMODE_1MV ||\nVAR_0->mv_mode == MV_PMODE_MIXED_MV)\nVAR_3 = get_bits(gb, 1);",
"if (s->mb_intra && !VAR_10)\n{",
"GET_MQUANT();",
"s->ac_pred = get_bits(gb, 1);",
"}",
"else if (VAR_10)\n{",
"if (s->mb_intra) s->ac_pred = get_bits(gb, 1);",
"predicted_cbpcy = get_vlc2(gb, VAR_0->cbpcy_vlc->table, VC9_CBPCY_P_VLC_BITS, 2);",
"cbpcy[0] = (p_cbpcy[-1] == p_cbpcy[2]) ? previous_cbpcy[1] : p_cbpcy[2];",
"cbpcy[0] ^= ((predicted_cbpcy>>5)&0x01);",
"cbpcy[1] = (p_cbpcy[2] == p_cbpcy[3]) ? cbpcy[0] : p_cbpcy[3];",
"cbpcy[1] ^= ((predicted_cbpcy>>4)&0x01);",
"cbpcy[2] = (previous_cbpcy[1] == cbpcy[0]) ? previous_cbpcy[3] : cbpcy[0];",
"cbpcy[2] ^= ((predicted_cbpcy>>3)&0x01);",
"cbpcy[3] = (cbpcy[1] == cbpcy[0]) ? cbpcy[2] : cbpcy[1];",
"cbpcy[3] ^= ((predicted_cbpcy>>2)&0x01);",
"GET_MQUANT();",
"}",
"if (!VAR_0->ttmbf)\nVAR_7 = get_vlc2(gb, VAR_0->ttmb_vlc->table,\nVC9_TTMB_VLC_BITS, 12);",
"}",
"else\n{",
"if (VAR_0->mv_mode == MV_PMODE_1MV ||\nVAR_0->mv_mode == MV_PMODE_MIXED_MV)\nVAR_3 = get_bits(gb, 1);",
"}",
"}",
"else\n{",
"if (!VAR_0->skip_mb_plane.data[VAR_1] )\n{",
"GET_CBPCY(VAR_0->cbpcy_vlc->table, VC9_CBPCY_P_VLC_BITS);",
"for (VAR_2=0; VAR_2<4; VAR_2++)",
"{",
"if (cbpcy[VAR_2] )\n{",
"GET_MVDATA(VAR_11, VAR_12);",
"}",
"if (VAR_0->mv_mode == MV_PMODE_MIXED_MV )\nVAR_3 = get_bits(gb, 1);",
"GET_MQUANT();",
"if (s->mb_intra &&\nVAR_16 )\ns->ac_pred = get_bits(gb, 1);",
"if (!VAR_0->ttmbf)\nVAR_7 = get_vlc2(gb, VAR_0->ttmb_vlc->table,\nVC9_TTMB_VLC_BITS, 12);",
"}",
"}",
"else MB\n{",
"for (VAR_2=0; VAR_2<4; VAR_2++)",
"{",
"if (VAR_0->mv_mode == MV_PMODE_MIXED_MV )\nVAR_3 = get_bits(gb, 1);",
"}",
"}",
"}",
"#if TRACE > 2\nav_log(s->avctx, AV_LOG_DEBUG, \"Block %4i: p_cbpcy=%VAR_2%VAR_2%VAR_2%VAR_2, previous_cbpcy=%VAR_2%VAR_2%VAR_2%VAR_2,\"\n\" cbpcy=%VAR_2%VAR_2%VAR_2%VAR_2\\n\", VAR_1,\np_cbpcy[0], p_cbpcy[1], p_cbpcy[2], p_cbpcy[3],\nprevious_cbpcy[0], previous_cbpcy[1], previous_cbpcy[2], previous_cbpcy[3],\ncbpcy[0], cbpcy[1], cbpcy[2], cbpcy[3]);",
"#endif\n*((uint32_t*)p_cbpcy) = *((uint32_t*)previous_cbpcy);",
"*((uint32_t*)previous_cbpcy) = *((uint32_t*)cbpcy);",
"VAR_1++;",
"}",
"}",
"return 0;",
"}"
]
| [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
1,
1,
1,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
1,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
45
],
[
47
],
[
49
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
81
],
[
85
],
[
87
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101,
103
],
[
105,
107
],
[
109,
111
],
[
113,
115
],
[
117
],
[
123,
125,
127
],
[
129,
131
],
[
133
],
[
135
],
[
137
],
[
139,
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
167
],
[
169
],
[
171,
173,
175
],
[
179
],
[
181,
183
],
[
187,
189,
191
],
[
193
],
[
195
],
[
197,
199
],
[
201,
203
],
[
207
],
[
209
],
[
211
],
[
213,
215
],
[
217
],
[
219
],
[
221,
223
],
[
225
],
[
227,
229,
231
],
[
233,
235,
237
],
[
245
],
[
247
],
[
249,
251
],
[
253
],
[
255
],
[
257,
259
],
[
265
],
[
267
],
[
269
],
[
275,
277,
279,
281,
283,
285
],
[
287,
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
]
]
|
14,363 | static void fsl_imx25_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
dc->realize = fsl_imx25_realize;
} | true | qemu | 4c315c27661502a0813b129e41c0bf640c34a8d6 | static void fsl_imx25_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
dc->realize = fsl_imx25_realize;
} | {
"code": [],
"line_no": []
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
dc->realize = fsl_imx25_realize;
} | [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"dc->realize = fsl_imx25_realize;",
"}"
]
| [
0,
0,
0,
0
]
| [
[
1,
2
],
[
3
],
[
4
],
[
5
]
]
|
14,364 | SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c)
{
SwsFunc t = NULL;
#if (HAVE_MMX2 || HAVE_MMX) && CONFIG_GPL
t = ff_yuv2rgb_init_mmx(c);
#endif
#if HAVE_VIS
t = ff_yuv2rgb_init_vis(c);
#endif
#if CONFIG_MLIB
t = ff_yuv2rgb_init_mlib(c);
#endif
#if HAVE_ALTIVEC && CONFIG_GPL
if (c->flags & SWS_CPU_CAPS_ALTIVEC)
t = ff_yuv2rgb_init_altivec(c);
#endif
#if ARCH_BFIN
if (c->flags & SWS_CPU_CAPS_BFIN)
t = ff_yuv2rgb_get_func_ptr_bfin(c);
#endif
if (t)
return t;
av_log(c, AV_LOG_WARNING, "No accelerated colorspace conversion found.\n");
switch (c->dstFormat) {
case PIX_FMT_RGB48BE:
case PIX_FMT_RGB48LE: return yuv2rgb_c_48;
case PIX_FMT_ARGB:
case PIX_FMT_ABGR: if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) return yuva2argb_c;
case PIX_FMT_RGBA:
case PIX_FMT_BGRA: return (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) ? yuva2rgba_c : yuv2rgb_c_32;
case PIX_FMT_RGB24: return yuv2rgb_c_24_rgb;
case PIX_FMT_BGR24: return yuv2rgb_c_24_bgr;
case PIX_FMT_RGB565:
case PIX_FMT_BGR565:
case PIX_FMT_RGB555:
case PIX_FMT_BGR555: return yuv2rgb_c_16;
case PIX_FMT_RGB8:
case PIX_FMT_BGR8: return yuv2rgb_c_8_ordered_dither;
case PIX_FMT_RGB4:
case PIX_FMT_BGR4: return yuv2rgb_c_4_ordered_dither;
case PIX_FMT_RGB4_BYTE:
case PIX_FMT_BGR4_BYTE: return yuv2rgb_c_4b_ordered_dither;
case PIX_FMT_MONOBLACK: return yuv2rgb_c_1_ordered_dither;
default:
assert(0);
}
return NULL;
}
| false | FFmpeg | 29ce0433743c8cb0bfa4b0e174437212d31730fb | SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c)
{
SwsFunc t = NULL;
#if (HAVE_MMX2 || HAVE_MMX) && CONFIG_GPL
t = ff_yuv2rgb_init_mmx(c);
#endif
#if HAVE_VIS
t = ff_yuv2rgb_init_vis(c);
#endif
#if CONFIG_MLIB
t = ff_yuv2rgb_init_mlib(c);
#endif
#if HAVE_ALTIVEC && CONFIG_GPL
if (c->flags & SWS_CPU_CAPS_ALTIVEC)
t = ff_yuv2rgb_init_altivec(c);
#endif
#if ARCH_BFIN
if (c->flags & SWS_CPU_CAPS_BFIN)
t = ff_yuv2rgb_get_func_ptr_bfin(c);
#endif
if (t)
return t;
av_log(c, AV_LOG_WARNING, "No accelerated colorspace conversion found.\n");
switch (c->dstFormat) {
case PIX_FMT_RGB48BE:
case PIX_FMT_RGB48LE: return yuv2rgb_c_48;
case PIX_FMT_ARGB:
case PIX_FMT_ABGR: if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) return yuva2argb_c;
case PIX_FMT_RGBA:
case PIX_FMT_BGRA: return (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) ? yuva2rgba_c : yuv2rgb_c_32;
case PIX_FMT_RGB24: return yuv2rgb_c_24_rgb;
case PIX_FMT_BGR24: return yuv2rgb_c_24_bgr;
case PIX_FMT_RGB565:
case PIX_FMT_BGR565:
case PIX_FMT_RGB555:
case PIX_FMT_BGR555: return yuv2rgb_c_16;
case PIX_FMT_RGB8:
case PIX_FMT_BGR8: return yuv2rgb_c_8_ordered_dither;
case PIX_FMT_RGB4:
case PIX_FMT_BGR4: return yuv2rgb_c_4_ordered_dither;
case PIX_FMT_RGB4_BYTE:
case PIX_FMT_BGR4_BYTE: return yuv2rgb_c_4b_ordered_dither;
case PIX_FMT_MONOBLACK: return yuv2rgb_c_1_ordered_dither;
default:
assert(0);
}
return NULL;
}
| {
"code": [],
"line_no": []
} | SwsFunc FUNC_0(SwsContext *c)
{
SwsFunc t = NULL;
#if (HAVE_MMX2 || HAVE_MMX) && CONFIG_GPL
t = ff_yuv2rgb_init_mmx(c);
#endif
#if HAVE_VIS
t = ff_yuv2rgb_init_vis(c);
#endif
#if CONFIG_MLIB
t = ff_yuv2rgb_init_mlib(c);
#endif
#if HAVE_ALTIVEC && CONFIG_GPL
if (c->flags & SWS_CPU_CAPS_ALTIVEC)
t = ff_yuv2rgb_init_altivec(c);
#endif
#if ARCH_BFIN
if (c->flags & SWS_CPU_CAPS_BFIN)
t = ff_yuv2rgb_get_func_ptr_bfin(c);
#endif
if (t)
return t;
av_log(c, AV_LOG_WARNING, "No accelerated colorspace conversion found.\n");
switch (c->dstFormat) {
case PIX_FMT_RGB48BE:
case PIX_FMT_RGB48LE: return yuv2rgb_c_48;
case PIX_FMT_ARGB:
case PIX_FMT_ABGR: if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) return yuva2argb_c;
case PIX_FMT_RGBA:
case PIX_FMT_BGRA: return (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) ? yuva2rgba_c : yuv2rgb_c_32;
case PIX_FMT_RGB24: return yuv2rgb_c_24_rgb;
case PIX_FMT_BGR24: return yuv2rgb_c_24_bgr;
case PIX_FMT_RGB565:
case PIX_FMT_BGR565:
case PIX_FMT_RGB555:
case PIX_FMT_BGR555: return yuv2rgb_c_16;
case PIX_FMT_RGB8:
case PIX_FMT_BGR8: return yuv2rgb_c_8_ordered_dither;
case PIX_FMT_RGB4:
case PIX_FMT_BGR4: return yuv2rgb_c_4_ordered_dither;
case PIX_FMT_RGB4_BYTE:
case PIX_FMT_BGR4_BYTE: return yuv2rgb_c_4b_ordered_dither;
case PIX_FMT_MONOBLACK: return yuv2rgb_c_1_ordered_dither;
default:
assert(0);
}
return NULL;
}
| [
"SwsFunc FUNC_0(SwsContext *c)\n{",
"SwsFunc t = NULL;",
"#if (HAVE_MMX2 || HAVE_MMX) && CONFIG_GPL\nt = ff_yuv2rgb_init_mmx(c);",
"#endif\n#if HAVE_VIS\nt = ff_yuv2rgb_init_vis(c);",
"#endif\n#if CONFIG_MLIB\nt = ff_yuv2rgb_init_mlib(c);",
"#endif\n#if HAVE_ALTIVEC && CONFIG_GPL\nif (c->flags & SWS_CPU_CAPS_ALTIVEC)\nt = ff_yuv2rgb_init_altivec(c);",
"#endif\n#if ARCH_BFIN\nif (c->flags & SWS_CPU_CAPS_BFIN)\nt = ff_yuv2rgb_get_func_ptr_bfin(c);",
"#endif\nif (t)\nreturn t;",
"av_log(c, AV_LOG_WARNING, \"No accelerated colorspace conversion found.\\n\");",
"switch (c->dstFormat) {",
"case PIX_FMT_RGB48BE:\ncase PIX_FMT_RGB48LE: return yuv2rgb_c_48;",
"case PIX_FMT_ARGB:\ncase PIX_FMT_ABGR: if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) return yuva2argb_c;",
"case PIX_FMT_RGBA:\ncase PIX_FMT_BGRA: return (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) ? yuva2rgba_c : yuv2rgb_c_32;",
"case PIX_FMT_RGB24: return yuv2rgb_c_24_rgb;",
"case PIX_FMT_BGR24: return yuv2rgb_c_24_bgr;",
"case PIX_FMT_RGB565:\ncase PIX_FMT_BGR565:\ncase PIX_FMT_RGB555:\ncase PIX_FMT_BGR555: return yuv2rgb_c_16;",
"case PIX_FMT_RGB8:\ncase PIX_FMT_BGR8: return yuv2rgb_c_8_ordered_dither;",
"case PIX_FMT_RGB4:\ncase PIX_FMT_BGR4: return yuv2rgb_c_4_ordered_dither;",
"case PIX_FMT_RGB4_BYTE:\ncase PIX_FMT_BGR4_BYTE: return yuv2rgb_c_4b_ordered_dither;",
"case PIX_FMT_MONOBLACK: return yuv2rgb_c_1_ordered_dither;",
"default:\nassert(0);",
"}",
"return NULL;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7,
9
],
[
11,
13,
15
],
[
17,
19,
21
],
[
23,
25,
27,
29
],
[
31,
35,
37,
39
],
[
41,
45,
47
],
[
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
]
]
|
14,365 | static inline void celt_encode_pulses(OpusRangeCoder *rc, int *y, uint32_t N, uint32_t K)
{
ff_opus_rc_enc_uint(rc, celt_icwrsi(N, y), CELT_PVQ_V(N, K));
}
| false | FFmpeg | 67fa02ed794f9505bd9c3584c14bfb61c895f5bc | static inline void celt_encode_pulses(OpusRangeCoder *rc, int *y, uint32_t N, uint32_t K)
{
ff_opus_rc_enc_uint(rc, celt_icwrsi(N, y), CELT_PVQ_V(N, K));
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(OpusRangeCoder *VAR_0, int *VAR_1, uint32_t VAR_2, uint32_t VAR_3)
{
ff_opus_rc_enc_uint(VAR_0, celt_icwrsi(VAR_2, VAR_1), CELT_PVQ_V(VAR_2, VAR_3));
}
| [
"static inline void FUNC_0(OpusRangeCoder *VAR_0, int *VAR_1, uint32_t VAR_2, uint32_t VAR_3)\n{",
"ff_opus_rc_enc_uint(VAR_0, celt_icwrsi(VAR_2, VAR_1), CELT_PVQ_V(VAR_2, VAR_3));",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
14,368 | static void gen_partset_reg(int opsize, TCGv reg, TCGv val)
{
TCGv tmp;
switch (opsize) {
case OS_BYTE:
tcg_gen_andi_i32(reg, reg, 0xffffff00);
tmp = tcg_temp_new();
tcg_gen_ext8u_i32(tmp, val);
tcg_gen_or_i32(reg, reg, tmp);
break;
case OS_WORD:
tcg_gen_andi_i32(reg, reg, 0xffff0000);
tmp = tcg_temp_new();
tcg_gen_ext16u_i32(tmp, val);
tcg_gen_or_i32(reg, reg, tmp);
break;
case OS_LONG:
case OS_SINGLE:
tcg_gen_mov_i32(reg, val);
break;
default:
qemu_assert(0, "Bad operand size");
break;
}
}
| true | qemu | 7372c2b926200db295412efbb53f93773b7f1754 | static void gen_partset_reg(int opsize, TCGv reg, TCGv val)
{
TCGv tmp;
switch (opsize) {
case OS_BYTE:
tcg_gen_andi_i32(reg, reg, 0xffffff00);
tmp = tcg_temp_new();
tcg_gen_ext8u_i32(tmp, val);
tcg_gen_or_i32(reg, reg, tmp);
break;
case OS_WORD:
tcg_gen_andi_i32(reg, reg, 0xffff0000);
tmp = tcg_temp_new();
tcg_gen_ext16u_i32(tmp, val);
tcg_gen_or_i32(reg, reg, tmp);
break;
case OS_LONG:
case OS_SINGLE:
tcg_gen_mov_i32(reg, val);
break;
default:
qemu_assert(0, "Bad operand size");
break;
}
}
| {
"code": [
" qemu_assert(0, \"Bad operand size\");",
" break;",
" qemu_assert(0, \"Bad operand size\");"
],
"line_no": [
43,
19,
43
]
} | static void FUNC_0(int VAR_0, TCGv VAR_1, TCGv VAR_2)
{
TCGv tmp;
switch (VAR_0) {
case OS_BYTE:
tcg_gen_andi_i32(VAR_1, VAR_1, 0xffffff00);
tmp = tcg_temp_new();
tcg_gen_ext8u_i32(tmp, VAR_2);
tcg_gen_or_i32(VAR_1, VAR_1, tmp);
break;
case OS_WORD:
tcg_gen_andi_i32(VAR_1, VAR_1, 0xffff0000);
tmp = tcg_temp_new();
tcg_gen_ext16u_i32(tmp, VAR_2);
tcg_gen_or_i32(VAR_1, VAR_1, tmp);
break;
case OS_LONG:
case OS_SINGLE:
tcg_gen_mov_i32(VAR_1, VAR_2);
break;
default:
qemu_assert(0, "Bad operand size");
break;
}
}
| [
"static void FUNC_0(int VAR_0, TCGv VAR_1, TCGv VAR_2)\n{",
"TCGv tmp;",
"switch (VAR_0) {",
"case OS_BYTE:\ntcg_gen_andi_i32(VAR_1, VAR_1, 0xffffff00);",
"tmp = tcg_temp_new();",
"tcg_gen_ext8u_i32(tmp, VAR_2);",
"tcg_gen_or_i32(VAR_1, VAR_1, tmp);",
"break;",
"case OS_WORD:\ntcg_gen_andi_i32(VAR_1, VAR_1, 0xffff0000);",
"tmp = tcg_temp_new();",
"tcg_gen_ext16u_i32(tmp, VAR_2);",
"tcg_gen_or_i32(VAR_1, VAR_1, tmp);",
"break;",
"case OS_LONG:\ncase OS_SINGLE:\ntcg_gen_mov_i32(VAR_1, VAR_2);",
"break;",
"default:\nqemu_assert(0, \"Bad operand size\");",
"break;",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33,
35,
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
]
]
|
14,369 | PCIBus *pci_apb_init(target_phys_addr_t special_base,
target_phys_addr_t mem_base,
qemu_irq *pic, PCIBus **bus2, PCIBus **bus3)
{
DeviceState *dev;
SysBusDevice *s;
APBState *d;
/* Ultrasparc PBM main bus */
dev = qdev_create(NULL, "pbm");
qdev_init(dev);
s = sysbus_from_qdev(dev);
/* apb_config */
sysbus_mmio_map(s, 0, special_base + 0x2000ULL);
/* pci_ioport */
sysbus_mmio_map(s, 1, special_base + 0x2000000ULL);
/* mem_config: XXX size should be 4G-prom */
sysbus_mmio_map(s, 2, special_base + 0x1000000ULL);
/* mem_data */
sysbus_mmio_map(s, 3, mem_base);
d = FROM_SYSBUS(APBState, s);
d->host_state.bus = pci_register_bus(&d->busdev.qdev, "pci",
pci_apb_set_irq, pci_pbm_map_irq, pic,
0, 32);
pci_create_simple(d->host_state.bus, 0, "pbm");
/* APB secondary busses */
*bus2 = pci_bridge_init(d->host_state.bus, 8, PCI_VENDOR_ID_SUN,
PCI_DEVICE_ID_SUN_SIMBA, pci_apb_map_irq,
"Advanced PCI Bus secondary bridge 1");
*bus3 = pci_bridge_init(d->host_state.bus, 9, PCI_VENDOR_ID_SUN,
PCI_DEVICE_ID_SUN_SIMBA, pci_apb_map_irq,
"Advanced PCI Bus secondary bridge 2");
return d->host_state.bus;
}
| true | qemu | e23a1b33b53d25510320b26d9f154e19c6c99725 | PCIBus *pci_apb_init(target_phys_addr_t special_base,
target_phys_addr_t mem_base,
qemu_irq *pic, PCIBus **bus2, PCIBus **bus3)
{
DeviceState *dev;
SysBusDevice *s;
APBState *d;
dev = qdev_create(NULL, "pbm");
qdev_init(dev);
s = sysbus_from_qdev(dev);
sysbus_mmio_map(s, 0, special_base + 0x2000ULL);
sysbus_mmio_map(s, 1, special_base + 0x2000000ULL);
sysbus_mmio_map(s, 2, special_base + 0x1000000ULL);
sysbus_mmio_map(s, 3, mem_base);
d = FROM_SYSBUS(APBState, s);
d->host_state.bus = pci_register_bus(&d->busdev.qdev, "pci",
pci_apb_set_irq, pci_pbm_map_irq, pic,
0, 32);
pci_create_simple(d->host_state.bus, 0, "pbm");
*bus2 = pci_bridge_init(d->host_state.bus, 8, PCI_VENDOR_ID_SUN,
PCI_DEVICE_ID_SUN_SIMBA, pci_apb_map_irq,
"Advanced PCI Bus secondary bridge 1");
*bus3 = pci_bridge_init(d->host_state.bus, 9, PCI_VENDOR_ID_SUN,
PCI_DEVICE_ID_SUN_SIMBA, pci_apb_map_irq,
"Advanced PCI Bus secondary bridge 2");
return d->host_state.bus;
}
| {
"code": [
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);"
],
"line_no": [
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21
]
} | PCIBus *FUNC_0(target_phys_addr_t special_base,
target_phys_addr_t mem_base,
qemu_irq *pic, PCIBus **bus2, PCIBus **bus3)
{
DeviceState *dev;
SysBusDevice *s;
APBState *d;
dev = qdev_create(NULL, "pbm");
qdev_init(dev);
s = sysbus_from_qdev(dev);
sysbus_mmio_map(s, 0, special_base + 0x2000ULL);
sysbus_mmio_map(s, 1, special_base + 0x2000000ULL);
sysbus_mmio_map(s, 2, special_base + 0x1000000ULL);
sysbus_mmio_map(s, 3, mem_base);
d = FROM_SYSBUS(APBState, s);
d->host_state.bus = pci_register_bus(&d->busdev.qdev, "pci",
pci_apb_set_irq, pci_pbm_map_irq, pic,
0, 32);
pci_create_simple(d->host_state.bus, 0, "pbm");
*bus2 = pci_bridge_init(d->host_state.bus, 8, PCI_VENDOR_ID_SUN,
PCI_DEVICE_ID_SUN_SIMBA, pci_apb_map_irq,
"Advanced PCI Bus secondary bridge 1");
*bus3 = pci_bridge_init(d->host_state.bus, 9, PCI_VENDOR_ID_SUN,
PCI_DEVICE_ID_SUN_SIMBA, pci_apb_map_irq,
"Advanced PCI Bus secondary bridge 2");
return d->host_state.bus;
}
| [
"PCIBus *FUNC_0(target_phys_addr_t special_base,\ntarget_phys_addr_t mem_base,\nqemu_irq *pic, PCIBus **bus2, PCIBus **bus3)\n{",
"DeviceState *dev;",
"SysBusDevice *s;",
"APBState *d;",
"dev = qdev_create(NULL, \"pbm\");",
"qdev_init(dev);",
"s = sysbus_from_qdev(dev);",
"sysbus_mmio_map(s, 0, special_base + 0x2000ULL);",
"sysbus_mmio_map(s, 1, special_base + 0x2000000ULL);",
"sysbus_mmio_map(s, 2, special_base + 0x1000000ULL);",
"sysbus_mmio_map(s, 3, mem_base);",
"d = FROM_SYSBUS(APBState, s);",
"d->host_state.bus = pci_register_bus(&d->busdev.qdev, \"pci\",\npci_apb_set_irq, pci_pbm_map_irq, pic,\n0, 32);",
"pci_create_simple(d->host_state.bus, 0, \"pbm\");",
"*bus2 = pci_bridge_init(d->host_state.bus, 8, PCI_VENDOR_ID_SUN,\nPCI_DEVICE_ID_SUN_SIMBA, pci_apb_map_irq,\n\"Advanced PCI Bus secondary bridge 1\");",
"*bus3 = pci_bridge_init(d->host_state.bus, 9, PCI_VENDOR_ID_SUN,\nPCI_DEVICE_ID_SUN_SIMBA, pci_apb_map_irq,\n\"Advanced PCI Bus secondary bridge 2\");",
"return d->host_state.bus;",
"}"
]
| [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
19
],
[
21
],
[
23
],
[
27
],
[
31
],
[
35
],
[
39
],
[
41
],
[
43,
45,
47
],
[
49
],
[
53,
55,
57
],
[
59,
61,
63
],
[
67
],
[
69
]
]
|
14,370 | static void pc_numa_cpu(const void *data)
{
char *cli;
QDict *resp;
QList *cpus;
const QObject *e;
cli = make_cli(data, "-cpu pentium -smp 8,sockets=2,cores=2,threads=2 "
"-numa node,nodeid=0 -numa node,nodeid=1 "
"-numa cpu,node-id=1,socket-id=0 "
"-numa cpu,node-id=0,socket-id=1,core-id=0 "
"-numa cpu,node-id=0,socket-id=1,core-id=1,thread-id=0 "
"-numa cpu,node-id=1,socket-id=1,core-id=1,thread-id=1");
qtest_start(cli);
cpus = get_cpus(&resp);
g_assert(cpus);
while ((e = qlist_pop(cpus))) {
QDict *cpu, *props;
int64_t socket, core, thread, node;
cpu = qobject_to_qdict(e);
g_assert(qdict_haskey(cpu, "props"));
props = qdict_get_qdict(cpu, "props");
g_assert(qdict_haskey(props, "node-id"));
node = qdict_get_int(props, "node-id");
g_assert(qdict_haskey(props, "socket-id"));
socket = qdict_get_int(props, "socket-id");
g_assert(qdict_haskey(props, "core-id"));
core = qdict_get_int(props, "core-id");
g_assert(qdict_haskey(props, "thread-id"));
thread = qdict_get_int(props, "thread-id");
if (socket == 0) {
g_assert_cmpint(node, ==, 1);
} else if (socket == 1 && core == 0) {
g_assert_cmpint(node, ==, 0);
} else if (socket == 1 && core == 1 && thread == 0) {
g_assert_cmpint(node, ==, 0);
} else if (socket == 1 && core == 1 && thread == 1) {
g_assert_cmpint(node, ==, 1);
} else {
g_assert(false);
}
}
QDECREF(resp);
qtest_end();
g_free(cli);
}
| true | qemu | 5e39d89d20b17cf6fb7f09d181d34f17b2ae2160 | static void pc_numa_cpu(const void *data)
{
char *cli;
QDict *resp;
QList *cpus;
const QObject *e;
cli = make_cli(data, "-cpu pentium -smp 8,sockets=2,cores=2,threads=2 "
"-numa node,nodeid=0 -numa node,nodeid=1 "
"-numa cpu,node-id=1,socket-id=0 "
"-numa cpu,node-id=0,socket-id=1,core-id=0 "
"-numa cpu,node-id=0,socket-id=1,core-id=1,thread-id=0 "
"-numa cpu,node-id=1,socket-id=1,core-id=1,thread-id=1");
qtest_start(cli);
cpus = get_cpus(&resp);
g_assert(cpus);
while ((e = qlist_pop(cpus))) {
QDict *cpu, *props;
int64_t socket, core, thread, node;
cpu = qobject_to_qdict(e);
g_assert(qdict_haskey(cpu, "props"));
props = qdict_get_qdict(cpu, "props");
g_assert(qdict_haskey(props, "node-id"));
node = qdict_get_int(props, "node-id");
g_assert(qdict_haskey(props, "socket-id"));
socket = qdict_get_int(props, "socket-id");
g_assert(qdict_haskey(props, "core-id"));
core = qdict_get_int(props, "core-id");
g_assert(qdict_haskey(props, "thread-id"));
thread = qdict_get_int(props, "thread-id");
if (socket == 0) {
g_assert_cmpint(node, ==, 1);
} else if (socket == 1 && core == 0) {
g_assert_cmpint(node, ==, 0);
} else if (socket == 1 && core == 1 && thread == 0) {
g_assert_cmpint(node, ==, 0);
} else if (socket == 1 && core == 1 && thread == 1) {
g_assert_cmpint(node, ==, 1);
} else {
g_assert(false);
}
}
QDECREF(resp);
qtest_end();
g_free(cli);
}
| {
"code": [
" const QObject *e;",
" const QObject *e;",
" const QObject *e;",
" const QObject *e;"
],
"line_no": [
11,
11,
11,
11
]
} | static void FUNC_0(const void *VAR_0)
{
char *VAR_1;
QDict *resp;
QList *cpus;
const QObject *VAR_2;
VAR_1 = make_cli(VAR_0, "-cpu pentium -smp 8,sockets=2,cores=2,threads=2 "
"-numa node,nodeid=0 -numa node,nodeid=1 "
"-numa cpu,node-id=1,socket-id=0 "
"-numa cpu,node-id=0,socket-id=1,core-id=0 "
"-numa cpu,node-id=0,socket-id=1,core-id=1,thread-id=0 "
"-numa cpu,node-id=1,socket-id=1,core-id=1,thread-id=1");
qtest_start(VAR_1);
cpus = get_cpus(&resp);
g_assert(cpus);
while ((VAR_2 = qlist_pop(cpus))) {
QDict *cpu, *props;
int64_t socket, core, thread, node;
cpu = qobject_to_qdict(VAR_2);
g_assert(qdict_haskey(cpu, "props"));
props = qdict_get_qdict(cpu, "props");
g_assert(qdict_haskey(props, "node-id"));
node = qdict_get_int(props, "node-id");
g_assert(qdict_haskey(props, "socket-id"));
socket = qdict_get_int(props, "socket-id");
g_assert(qdict_haskey(props, "core-id"));
core = qdict_get_int(props, "core-id");
g_assert(qdict_haskey(props, "thread-id"));
thread = qdict_get_int(props, "thread-id");
if (socket == 0) {
g_assert_cmpint(node, ==, 1);
} else if (socket == 1 && core == 0) {
g_assert_cmpint(node, ==, 0);
} else if (socket == 1 && core == 1 && thread == 0) {
g_assert_cmpint(node, ==, 0);
} else if (socket == 1 && core == 1 && thread == 1) {
g_assert_cmpint(node, ==, 1);
} else {
g_assert(false);
}
}
QDECREF(resp);
qtest_end();
g_free(VAR_1);
}
| [
"static void FUNC_0(const void *VAR_0)\n{",
"char *VAR_1;",
"QDict *resp;",
"QList *cpus;",
"const QObject *VAR_2;",
"VAR_1 = make_cli(VAR_0, \"-cpu pentium -smp 8,sockets=2,cores=2,threads=2 \"\n\"-numa node,nodeid=0 -numa node,nodeid=1 \"\n\"-numa cpu,node-id=1,socket-id=0 \"\n\"-numa cpu,node-id=0,socket-id=1,core-id=0 \"\n\"-numa cpu,node-id=0,socket-id=1,core-id=1,thread-id=0 \"\n\"-numa cpu,node-id=1,socket-id=1,core-id=1,thread-id=1\");",
"qtest_start(VAR_1);",
"cpus = get_cpus(&resp);",
"g_assert(cpus);",
"while ((VAR_2 = qlist_pop(cpus))) {",
"QDict *cpu, *props;",
"int64_t socket, core, thread, node;",
"cpu = qobject_to_qdict(VAR_2);",
"g_assert(qdict_haskey(cpu, \"props\"));",
"props = qdict_get_qdict(cpu, \"props\");",
"g_assert(qdict_haskey(props, \"node-id\"));",
"node = qdict_get_int(props, \"node-id\");",
"g_assert(qdict_haskey(props, \"socket-id\"));",
"socket = qdict_get_int(props, \"socket-id\");",
"g_assert(qdict_haskey(props, \"core-id\"));",
"core = qdict_get_int(props, \"core-id\");",
"g_assert(qdict_haskey(props, \"thread-id\"));",
"thread = qdict_get_int(props, \"thread-id\");",
"if (socket == 0) {",
"g_assert_cmpint(node, ==, 1);",
"} else if (socket == 1 && core == 0) {",
"g_assert_cmpint(node, ==, 0);",
"} else if (socket == 1 && core == 1 && thread == 0) {",
"g_assert_cmpint(node, ==, 0);",
"} else if (socket == 1 && core == 1 && thread == 1) {",
"g_assert_cmpint(node, ==, 1);",
"} else {",
"g_assert(false);",
"}",
"}",
"QDECREF(resp);",
"qtest_end();",
"g_free(VAR_1);",
"}"
]
| [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15,
17,
19,
21,
23,
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
]
]
|
14,371 | static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
{
CPUState *cs = CPU(cpu);
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0;
if (smp_cpus == 1) {
handlers = &s->rom_state.up;
} else {
handlers = &s->rom_state.mp;
}
if (!kvm_enabled()) {
cpu_get_tb_cpu_state(env, ¤t_pc, ¤t_cs_base,
¤t_flags);
/* Account this instruction, because we will exit the tb.
This is the first instruction in the block. Therefore
there is no need in restoring CPU state. */
if (use_icount) {
--cs->icount_decr.u16.low;
}
}
pause_all_vcpus();
cpu_memory_rw_debug(cs, ip, opcode, sizeof(opcode), 0);
switch (opcode[0]) {
case 0x89: /* mov r32 to r/m32 */
patch_byte(cpu, ip, 0x50 + modrm_reg(opcode[1])); /* push reg */
patch_call(s, cpu, ip + 1, handlers->set_tpr);
break;
case 0x8b: /* mov r/m32 to r32 */
patch_byte(cpu, ip, 0x90);
patch_call(s, cpu, ip + 1, handlers->get_tpr[modrm_reg(opcode[1])]);
break;
case 0xa1: /* mov abs to eax */
patch_call(s, cpu, ip, handlers->get_tpr[0]);
break;
case 0xa3: /* mov eax to abs */
patch_call(s, cpu, ip, handlers->set_tpr_eax);
break;
case 0xc7: /* mov imm32, r/m32 (c7/0) */
patch_byte(cpu, ip, 0x68); /* push imm32 */
cpu_memory_rw_debug(cs, ip + 6, (void *)&imm32, sizeof(imm32), 0);
cpu_memory_rw_debug(cs, ip + 1, (void *)&imm32, sizeof(imm32), 1);
patch_call(s, cpu, ip + 5, handlers->set_tpr);
break;
case 0xff: /* push r/m32 */
patch_byte(cpu, ip, 0x50); /* push eax */
patch_call(s, cpu, ip + 1, handlers->get_tpr_stack);
break;
default:
abort();
}
resume_all_vcpus();
if (!kvm_enabled()) {
/* tb_lock will be reset when cpu_loop_exit_noexc longjmps
* back into the cpu_exec loop. */
tb_lock();
tb_gen_code(cs, current_pc, current_cs_base, current_flags, 1);
cpu_loop_exit_noexc(cs);
}
}
| true | qemu | 8d04fb55dec381bc5105cb47f29d918e579e8cbd | static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
{
CPUState *cs = CPU(cpu);
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0;
if (smp_cpus == 1) {
handlers = &s->rom_state.up;
} else {
handlers = &s->rom_state.mp;
}
if (!kvm_enabled()) {
cpu_get_tb_cpu_state(env, ¤t_pc, ¤t_cs_base,
¤t_flags);
if (use_icount) {
--cs->icount_decr.u16.low;
}
}
pause_all_vcpus();
cpu_memory_rw_debug(cs, ip, opcode, sizeof(opcode), 0);
switch (opcode[0]) {
case 0x89:
patch_byte(cpu, ip, 0x50 + modrm_reg(opcode[1]));
patch_call(s, cpu, ip + 1, handlers->set_tpr);
break;
case 0x8b:
patch_byte(cpu, ip, 0x90);
patch_call(s, cpu, ip + 1, handlers->get_tpr[modrm_reg(opcode[1])]);
break;
case 0xa1:
patch_call(s, cpu, ip, handlers->get_tpr[0]);
break;
case 0xa3:
patch_call(s, cpu, ip, handlers->set_tpr_eax);
break;
case 0xc7:
patch_byte(cpu, ip, 0x68);
cpu_memory_rw_debug(cs, ip + 6, (void *)&imm32, sizeof(imm32), 0);
cpu_memory_rw_debug(cs, ip + 1, (void *)&imm32, sizeof(imm32), 1);
patch_call(s, cpu, ip + 5, handlers->set_tpr);
break;
case 0xff:
patch_byte(cpu, ip, 0x50);
patch_call(s, cpu, ip + 1, handlers->get_tpr_stack);
break;
default:
abort();
}
resume_all_vcpus();
if (!kvm_enabled()) {
tb_lock();
tb_gen_code(cs, current_pc, current_cs_base, current_flags, 1);
cpu_loop_exit_noexc(cs);
}
}
| {
"code": [
" } else {"
],
"line_no": [
27
]
} | static void FUNC_0(VAPICROMState *VAR_0, X86CPU *VAR_1, target_ulong VAR_2)
{
CPUState *cs = CPU(VAR_1);
CPUX86State *env = &VAR_1->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0;
if (smp_cpus == 1) {
handlers = &VAR_0->rom_state.up;
} else {
handlers = &VAR_0->rom_state.mp;
}
if (!kvm_enabled()) {
cpu_get_tb_cpu_state(env, ¤t_pc, ¤t_cs_base,
¤t_flags);
if (use_icount) {
--cs->icount_decr.u16.low;
}
}
pause_all_vcpus();
cpu_memory_rw_debug(cs, VAR_2, opcode, sizeof(opcode), 0);
switch (opcode[0]) {
case 0x89:
patch_byte(VAR_1, VAR_2, 0x50 + modrm_reg(opcode[1]));
patch_call(VAR_0, VAR_1, VAR_2 + 1, handlers->set_tpr);
break;
case 0x8b:
patch_byte(VAR_1, VAR_2, 0x90);
patch_call(VAR_0, VAR_1, VAR_2 + 1, handlers->get_tpr[modrm_reg(opcode[1])]);
break;
case 0xa1:
patch_call(VAR_0, VAR_1, VAR_2, handlers->get_tpr[0]);
break;
case 0xa3:
patch_call(VAR_0, VAR_1, VAR_2, handlers->set_tpr_eax);
break;
case 0xc7:
patch_byte(VAR_1, VAR_2, 0x68);
cpu_memory_rw_debug(cs, VAR_2 + 6, (void *)&imm32, sizeof(imm32), 0);
cpu_memory_rw_debug(cs, VAR_2 + 1, (void *)&imm32, sizeof(imm32), 1);
patch_call(VAR_0, VAR_1, VAR_2 + 5, handlers->set_tpr);
break;
case 0xff:
patch_byte(VAR_1, VAR_2, 0x50);
patch_call(VAR_0, VAR_1, VAR_2 + 1, handlers->get_tpr_stack);
break;
default:
abort();
}
resume_all_vcpus();
if (!kvm_enabled()) {
tb_lock();
tb_gen_code(cs, current_pc, current_cs_base, current_flags, 1);
cpu_loop_exit_noexc(cs);
}
}
| [
"static void FUNC_0(VAPICROMState *VAR_0, X86CPU *VAR_1, target_ulong VAR_2)\n{",
"CPUState *cs = CPU(VAR_1);",
"CPUX86State *env = &VAR_1->env;",
"VAPICHandlers *handlers;",
"uint8_t opcode[2];",
"uint32_t imm32 = 0;",
"target_ulong current_pc = 0;",
"target_ulong current_cs_base = 0;",
"uint32_t current_flags = 0;",
"if (smp_cpus == 1) {",
"handlers = &VAR_0->rom_state.up;",
"} else {",
"handlers = &VAR_0->rom_state.mp;",
"}",
"if (!kvm_enabled()) {",
"cpu_get_tb_cpu_state(env, ¤t_pc, ¤t_cs_base,\n¤t_flags);",
"if (use_icount) {",
"--cs->icount_decr.u16.low;",
"}",
"}",
"pause_all_vcpus();",
"cpu_memory_rw_debug(cs, VAR_2, opcode, sizeof(opcode), 0);",
"switch (opcode[0]) {",
"case 0x89:\npatch_byte(VAR_1, VAR_2, 0x50 + modrm_reg(opcode[1]));",
"patch_call(VAR_0, VAR_1, VAR_2 + 1, handlers->set_tpr);",
"break;",
"case 0x8b:\npatch_byte(VAR_1, VAR_2, 0x90);",
"patch_call(VAR_0, VAR_1, VAR_2 + 1, handlers->get_tpr[modrm_reg(opcode[1])]);",
"break;",
"case 0xa1:\npatch_call(VAR_0, VAR_1, VAR_2, handlers->get_tpr[0]);",
"break;",
"case 0xa3:\npatch_call(VAR_0, VAR_1, VAR_2, handlers->set_tpr_eax);",
"break;",
"case 0xc7:\npatch_byte(VAR_1, VAR_2, 0x68);",
"cpu_memory_rw_debug(cs, VAR_2 + 6, (void *)&imm32, sizeof(imm32), 0);",
"cpu_memory_rw_debug(cs, VAR_2 + 1, (void *)&imm32, sizeof(imm32), 1);",
"patch_call(VAR_0, VAR_1, VAR_2 + 5, handlers->set_tpr);",
"break;",
"case 0xff:\npatch_byte(VAR_1, VAR_2, 0x50);",
"patch_call(VAR_0, VAR_1, VAR_2 + 1, handlers->get_tpr_stack);",
"break;",
"default:\nabort();",
"}",
"resume_all_vcpus();",
"if (!kvm_enabled()) {",
"tb_lock();",
"tb_gen_code(cs, current_pc, current_cs_base, current_flags, 1);",
"cpu_loop_exit_noexc(cs);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37,
39
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
61
],
[
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
],
[
123
],
[
127
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
]
]
|
14,374 | static int vc9_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
VC9Context *v = avctx->priv_data;
MpegEncContext *s = &v->s;
int ret = FRAME_SKIPED, len, start_code;
AVFrame *pict = data;
uint8_t *tmp_buf;
v->s.avctx = avctx;
//buf_size = 0 -> last frame
if (!buf_size) return 0;
len = avpicture_get_size(avctx->pix_fmt, avctx->width,
avctx->height);
tmp_buf = (uint8_t *)av_mallocz(len);
avpicture_fill((AVPicture *)pict, tmp_buf, avctx->pix_fmt,
avctx->width, avctx->height);
if (avctx->codec_id == CODEC_ID_VC9)
{
#if 0
// search for IDU's
// FIXME
uint32_t scp = 0;
int scs = 0, i = 0;
while (i < buf_size)
{
for (; i < buf_size && scp != 0x000001; i++)
scp = ((scp<<8)|buf[i])&0xffffff;
if (scp != 0x000001)
break; // eof ?
scs = buf[i++];
init_get_bits(gb, buf+i, (buf_size-i)*8);
switch(scs)
{
case 0x0A: //Sequence End Code
return 0;
case 0x0B: //Slice Start Code
av_log(avctx, AV_LOG_ERROR, "Slice coding not supported\n");
return -1;
case 0x0C: //Field start code
av_log(avctx, AV_LOG_ERROR, "Interlaced coding not supported\n");
return -1;
case 0x0D: //Frame start code
break;
case 0x0E: //Entry point Start Code
if (v->profile <= MAIN_PROFILE)
av_log(avctx, AV_LOG_ERROR,
"Found an entry point in profile %i\n", v->profile);
advanced_entry_point_process(avctx, gb);
break;
case 0x0F: //Sequence header Start Code
decode_sequence_header(avctx, gb);
break;
default:
av_log(avctx, AV_LOG_ERROR,
"Unsupported IDU suffix %lX\n", scs);
}
i += get_bits_count(gb)*8;
}
#else
av_abort();
#endif
}
else
init_get_bits(&v->s.gb, buf, buf_size*8);
s->flags= avctx->flags;
s->flags2= avctx->flags2;
/* no supplementary picture */
if (buf_size == 0) {
/* special case for last picture */
if (s->low_delay==0 && s->next_picture_ptr) {
*pict= *(AVFrame*)s->next_picture_ptr;
s->next_picture_ptr= NULL;
*data_size = sizeof(AVFrame);
}
return 0;
}
//No IDU - we mimic ff_h263_decode_frame
s->bitstream_buffer_size=0;
if (!s->context_initialized) {
if (MPV_common_init(s) < 0) //we need the idct permutaton for reading a custom matrix
return -1;
}
//we need to set current_picture_ptr before reading the header, otherwise we cant store anyting im there
if(s->current_picture_ptr==NULL || s->current_picture_ptr->data[0]){
s->current_picture_ptr= &s->picture[ff_find_unused_picture(s, 0)];
}
#if HAS_ADVANCED_PROFILE
if (v->profile > PROFILE_MAIN)
ret= advanced_decode_picture_primary_header(v);
else
#endif
ret= standard_decode_picture_primary_header(v);
if (ret == FRAME_SKIPED) return buf_size;
/* skip if the header was thrashed */
if (ret < 0){
av_log(s->avctx, AV_LOG_ERROR, "header damaged\n");
return -1;
}
//No bug workaround yet, no DCT conformance
//WMV9 does have resized images
if (v->profile <= PROFILE_MAIN && v->multires){
//Parse context stuff in here, don't know how appliable it is
}
//Not sure about context initialization
// for hurry_up==5
s->current_picture.pict_type= s->pict_type;
s->current_picture.key_frame= s->pict_type == I_TYPE;
/* skip b frames if we dont have reference frames */
if(s->last_picture_ptr==NULL && (s->pict_type==B_TYPE || s->dropable))
return buf_size; //FIXME simulating all buffer consumed
/* skip b frames if we are in a hurry */
if(avctx->hurry_up && s->pict_type==B_TYPE)
return buf_size; //FIXME simulating all buffer consumed
/* skip everything if we are in a hurry>=5 */
if(avctx->hurry_up>=5)
return buf_size; //FIXME simulating all buffer consumed
if(s->next_p_frame_damaged){
if(s->pict_type==B_TYPE)
return buf_size; //FIXME simulating all buffer consumed
else
s->next_p_frame_damaged=0;
}
if(MPV_frame_start(s, avctx) < 0)
return -1;
ff_er_frame_start(s);
//wmv9 may or may not have skip bits
#if HAS_ADVANCED_PROFILE
if (v->profile > PROFILE_MAIN)
ret= advanced_decode_picture_secondary_header(v);
else
#endif
ret = standard_decode_picture_secondary_header(v);
if (ret<0) return FRAME_SKIPED; //FIXME Non fatal for now
//We consider the image coded in only one slice
#if HAS_ADVANCED_PROFILE
if (v->profile > PROFILE_MAIN)
{
switch(s->pict_type)
{
case I_TYPE: ret = advanced_decode_i_mbs(v); break;
case P_TYPE: ret = decode_p_mbs(v); break;
case B_TYPE:
case BI_TYPE: ret = decode_b_mbs(v); break;
default: ret = FRAME_SKIPED;
}
if (ret == FRAME_SKIPED) return buf_size; //We ignore for now failures
}
else
#endif
{
switch(s->pict_type)
{
case I_TYPE: ret = standard_decode_i_mbs(v); break;
case P_TYPE: ret = decode_p_mbs(v); break;
case B_TYPE:
case BI_TYPE: ret = decode_b_mbs(v); break;
default: ret = FRAME_SKIPED;
}
if (ret == FRAME_SKIPED) return buf_size;
}
ff_er_frame_end(s);
MPV_frame_end(s);
assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type);
assert(s->current_picture.pict_type == s->pict_type);
if(s->pict_type==B_TYPE || s->low_delay){
*pict= *(AVFrame*)&s->current_picture;
ff_print_debug_info(s, pict);
} else {
*pict= *(AVFrame*)&s->last_picture;
if(pict)
ff_print_debug_info(s, pict);
}
/* Return the Picture timestamp as the frame number */
/* we substract 1 because it is added on utils.c */
avctx->frame_number = s->picture_number - 1;
/* dont output the last pic after seeking */
if(s->last_picture_ptr || s->low_delay)
*data_size = sizeof(AVFrame);
av_log(avctx, AV_LOG_DEBUG, "Consumed %i/%i bits\n",
get_bits_count(&s->gb), buf_size*8);
/* Fake consumption of all data */
*data_size = len;
return buf_size; //Number of bytes consumed
}
| true | FFmpeg | 7cc84d241ba6ef8e27e4d057176a4ad385ad3d59 | static int vc9_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
VC9Context *v = avctx->priv_data;
MpegEncContext *s = &v->s;
int ret = FRAME_SKIPED, len, start_code;
AVFrame *pict = data;
uint8_t *tmp_buf;
v->s.avctx = avctx;
if (!buf_size) return 0;
len = avpicture_get_size(avctx->pix_fmt, avctx->width,
avctx->height);
tmp_buf = (uint8_t *)av_mallocz(len);
avpicture_fill((AVPicture *)pict, tmp_buf, avctx->pix_fmt,
avctx->width, avctx->height);
if (avctx->codec_id == CODEC_ID_VC9)
{
#if 0
uint32_t scp = 0;
int scs = 0, i = 0;
while (i < buf_size)
{
for (; i < buf_size && scp != 0x000001; i++)
scp = ((scp<<8)|buf[i])&0xffffff;
if (scp != 0x000001)
break;
scs = buf[i++];
init_get_bits(gb, buf+i, (buf_size-i)*8);
switch(scs)
{
case 0x0A:
return 0;
case 0x0B:
av_log(avctx, AV_LOG_ERROR, "Slice coding not supported\n");
return -1;
case 0x0C:
av_log(avctx, AV_LOG_ERROR, "Interlaced coding not supported\n");
return -1;
case 0x0D:
break;
case 0x0E:
if (v->profile <= MAIN_PROFILE)
av_log(avctx, AV_LOG_ERROR,
"Found an entry point in profile %i\n", v->profile);
advanced_entry_point_process(avctx, gb);
break;
case 0x0F:
decode_sequence_header(avctx, gb);
break;
default:
av_log(avctx, AV_LOG_ERROR,
"Unsupported IDU suffix %lX\n", scs);
}
i += get_bits_count(gb)*8;
}
#else
av_abort();
#endif
}
else
init_get_bits(&v->s.gb, buf, buf_size*8);
s->flags= avctx->flags;
s->flags2= avctx->flags2;
if (buf_size == 0) {
if (s->low_delay==0 && s->next_picture_ptr) {
*pict= *(AVFrame*)s->next_picture_ptr;
s->next_picture_ptr= NULL;
*data_size = sizeof(AVFrame);
}
return 0;
}
s->bitstream_buffer_size=0;
if (!s->context_initialized) {
if (MPV_common_init(s) < 0)
return -1;
}
if(s->current_picture_ptr==NULL || s->current_picture_ptr->data[0]){
s->current_picture_ptr= &s->picture[ff_find_unused_picture(s, 0)];
}
#if HAS_ADVANCED_PROFILE
if (v->profile > PROFILE_MAIN)
ret= advanced_decode_picture_primary_header(v);
else
#endif
ret= standard_decode_picture_primary_header(v);
if (ret == FRAME_SKIPED) return buf_size;
if (ret < 0){
av_log(s->avctx, AV_LOG_ERROR, "header damaged\n");
return -1;
}
if (v->profile <= PROFILE_MAIN && v->multires){
}
s->current_picture.pict_type= s->pict_type;
s->current_picture.key_frame= s->pict_type == I_TYPE;
if(s->last_picture_ptr==NULL && (s->pict_type==B_TYPE || s->dropable))
return buf_size;
if(avctx->hurry_up && s->pict_type==B_TYPE)
return buf_size;
if(avctx->hurry_up>=5)
return buf_size;
if(s->next_p_frame_damaged){
if(s->pict_type==B_TYPE)
return buf_size;
else
s->next_p_frame_damaged=0;
}
if(MPV_frame_start(s, avctx) < 0)
return -1;
ff_er_frame_start(s);
#if HAS_ADVANCED_PROFILE
if (v->profile > PROFILE_MAIN)
ret= advanced_decode_picture_secondary_header(v);
else
#endif
ret = standard_decode_picture_secondary_header(v);
if (ret<0) return FRAME_SKIPED;
#if HAS_ADVANCED_PROFILE
if (v->profile > PROFILE_MAIN)
{
switch(s->pict_type)
{
case I_TYPE: ret = advanced_decode_i_mbs(v); break;
case P_TYPE: ret = decode_p_mbs(v); break;
case B_TYPE:
case BI_TYPE: ret = decode_b_mbs(v); break;
default: ret = FRAME_SKIPED;
}
if (ret == FRAME_SKIPED) return buf_size;
}
else
#endif
{
switch(s->pict_type)
{
case I_TYPE: ret = standard_decode_i_mbs(v); break;
case P_TYPE: ret = decode_p_mbs(v); break;
case B_TYPE:
case BI_TYPE: ret = decode_b_mbs(v); break;
default: ret = FRAME_SKIPED;
}
if (ret == FRAME_SKIPED) return buf_size;
}
ff_er_frame_end(s);
MPV_frame_end(s);
assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type);
assert(s->current_picture.pict_type == s->pict_type);
if(s->pict_type==B_TYPE || s->low_delay){
*pict= *(AVFrame*)&s->current_picture;
ff_print_debug_info(s, pict);
} else {
*pict= *(AVFrame*)&s->last_picture;
if(pict)
ff_print_debug_info(s, pict);
}
avctx->frame_number = s->picture_number - 1;
if(s->last_picture_ptr || s->low_delay)
*data_size = sizeof(AVFrame);
av_log(avctx, AV_LOG_DEBUG, "Consumed %i/%i bits\n",
get_bits_count(&s->gb), buf_size*8);
*data_size = len;
return buf_size;
}
| {
"code": [
"#endif",
"#endif",
"#endif",
"#endif",
" if (v->profile > PROFILE_MAIN)",
"#endif",
" if (v->profile > PROFILE_MAIN)",
" if (v->profile > PROFILE_MAIN)",
" if (v->profile > PROFILE_MAIN)",
" if (v->profile > PROFILE_MAIN)",
" if (v->profile <= MAIN_PROFILE)",
" if (v->profile > PROFILE_MAIN)",
" if (v->profile <= PROFILE_MAIN && v->multires){",
" if (v->profile > PROFILE_MAIN)",
" if (v->profile > PROFILE_MAIN)",
"#endif",
"#endif"
],
"line_no": [
141,
141,
141,
141,
209,
141,
209,
209,
209,
209,
107,
209,
239,
209,
209,
141,
141
]
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
uint8_t *VAR_3, int VAR_4)
{
VC9Context *v = VAR_0->priv_data;
MpegEncContext *s = &v->s;
int VAR_5 = FRAME_SKIPED, VAR_6, VAR_7;
AVFrame *pict = VAR_1;
uint8_t *tmp_buf;
v->s.VAR_0 = VAR_0;
if (!VAR_4) return 0;
VAR_6 = avpicture_get_size(VAR_0->pix_fmt, VAR_0->width,
VAR_0->height);
tmp_buf = (uint8_t *)av_mallocz(VAR_6);
avpicture_fill((AVPicture *)pict, tmp_buf, VAR_0->pix_fmt,
VAR_0->width, VAR_0->height);
if (VAR_0->codec_id == CODEC_ID_VC9)
{
#if 0
uint32_t scp = 0;
int scs = 0, i = 0;
while (i < VAR_4)
{
for (; i < VAR_4 && scp != 0x000001; i++)
scp = ((scp<<8)|VAR_3[i])&0xffffff;
if (scp != 0x000001)
break;
scs = VAR_3[i++];
init_get_bits(gb, VAR_3+i, (VAR_4-i)*8);
switch(scs)
{
case 0x0A:
return 0;
case 0x0B:
av_log(VAR_0, AV_LOG_ERROR, "Slice coding not supported\n");
return -1;
case 0x0C:
av_log(VAR_0, AV_LOG_ERROR, "Interlaced coding not supported\n");
return -1;
case 0x0D:
break;
case 0x0E:
if (v->profile <= MAIN_PROFILE)
av_log(VAR_0, AV_LOG_ERROR,
"Found an entry point in profile %i\n", v->profile);
advanced_entry_point_process(VAR_0, gb);
break;
case 0x0F:
decode_sequence_header(VAR_0, gb);
break;
default:
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported IDU suffix %lX\n", scs);
}
i += get_bits_count(gb)*8;
}
#else
av_abort();
#endif
}
else
init_get_bits(&v->s.gb, VAR_3, VAR_4*8);
s->flags= VAR_0->flags;
s->flags2= VAR_0->flags2;
if (VAR_4 == 0) {
if (s->low_delay==0 && s->next_picture_ptr) {
*pict= *(AVFrame*)s->next_picture_ptr;
s->next_picture_ptr= NULL;
*VAR_2 = sizeof(AVFrame);
}
return 0;
}
s->bitstream_buffer_size=0;
if (!s->context_initialized) {
if (MPV_common_init(s) < 0)
return -1;
}
if(s->current_picture_ptr==NULL || s->current_picture_ptr->VAR_1[0]){
s->current_picture_ptr= &s->picture[ff_find_unused_picture(s, 0)];
}
#if HAS_ADVANCED_PROFILE
if (v->profile > PROFILE_MAIN)
VAR_5= advanced_decode_picture_primary_header(v);
else
#endif
VAR_5= standard_decode_picture_primary_header(v);
if (VAR_5 == FRAME_SKIPED) return VAR_4;
if (VAR_5 < 0){
av_log(s->VAR_0, AV_LOG_ERROR, "header damaged\n");
return -1;
}
if (v->profile <= PROFILE_MAIN && v->multires){
}
s->current_picture.pict_type= s->pict_type;
s->current_picture.key_frame= s->pict_type == I_TYPE;
if(s->last_picture_ptr==NULL && (s->pict_type==B_TYPE || s->dropable))
return VAR_4;
if(VAR_0->hurry_up && s->pict_type==B_TYPE)
return VAR_4;
if(VAR_0->hurry_up>=5)
return VAR_4;
if(s->next_p_frame_damaged){
if(s->pict_type==B_TYPE)
return VAR_4;
else
s->next_p_frame_damaged=0;
}
if(MPV_frame_start(s, VAR_0) < 0)
return -1;
ff_er_frame_start(s);
#if HAS_ADVANCED_PROFILE
if (v->profile > PROFILE_MAIN)
VAR_5= advanced_decode_picture_secondary_header(v);
else
#endif
VAR_5 = standard_decode_picture_secondary_header(v);
if (VAR_5<0) return FRAME_SKIPED;
#if HAS_ADVANCED_PROFILE
if (v->profile > PROFILE_MAIN)
{
switch(s->pict_type)
{
case I_TYPE: VAR_5 = advanced_decode_i_mbs(v); break;
case P_TYPE: VAR_5 = decode_p_mbs(v); break;
case B_TYPE:
case BI_TYPE: VAR_5 = decode_b_mbs(v); break;
default: VAR_5 = FRAME_SKIPED;
}
if (VAR_5 == FRAME_SKIPED) return VAR_4;
}
else
#endif
{
switch(s->pict_type)
{
case I_TYPE: VAR_5 = standard_decode_i_mbs(v); break;
case P_TYPE: VAR_5 = decode_p_mbs(v); break;
case B_TYPE:
case BI_TYPE: VAR_5 = decode_b_mbs(v); break;
default: VAR_5 = FRAME_SKIPED;
}
if (VAR_5 == FRAME_SKIPED) return VAR_4;
}
ff_er_frame_end(s);
MPV_frame_end(s);
assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type);
assert(s->current_picture.pict_type == s->pict_type);
if(s->pict_type==B_TYPE || s->low_delay){
*pict= *(AVFrame*)&s->current_picture;
ff_print_debug_info(s, pict);
} else {
*pict= *(AVFrame*)&s->last_picture;
if(pict)
ff_print_debug_info(s, pict);
}
VAR_0->frame_number = s->picture_number - 1;
if(s->last_picture_ptr || s->low_delay)
*VAR_2 = sizeof(AVFrame);
av_log(VAR_0, AV_LOG_DEBUG, "Consumed %i/%i bits\n",
get_bits_count(&s->gb), VAR_4*8);
*VAR_2 = VAR_6;
return VAR_4;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nuint8_t *VAR_3, int VAR_4)\n{",
"VC9Context *v = VAR_0->priv_data;",
"MpegEncContext *s = &v->s;",
"int VAR_5 = FRAME_SKIPED, VAR_6, VAR_7;",
"AVFrame *pict = VAR_1;",
"uint8_t *tmp_buf;",
"v->s.VAR_0 = VAR_0;",
"if (!VAR_4) return 0;",
"VAR_6 = avpicture_get_size(VAR_0->pix_fmt, VAR_0->width,\nVAR_0->height);",
"tmp_buf = (uint8_t *)av_mallocz(VAR_6);",
"avpicture_fill((AVPicture *)pict, tmp_buf, VAR_0->pix_fmt,\nVAR_0->width, VAR_0->height);",
"if (VAR_0->codec_id == CODEC_ID_VC9)\n{",
"#if 0\nuint32_t scp = 0;",
"int scs = 0, i = 0;",
"while (i < VAR_4)\n{",
"for (; i < VAR_4 && scp != 0x000001; i++)",
"scp = ((scp<<8)|VAR_3[i])&0xffffff;",
"if (scp != 0x000001)\nbreak;",
"scs = VAR_3[i++];",
"init_get_bits(gb, VAR_3+i, (VAR_4-i)*8);",
"switch(scs)\n{",
"case 0x0A:\nreturn 0;",
"case 0x0B:\nav_log(VAR_0, AV_LOG_ERROR, \"Slice coding not supported\\n\");",
"return -1;",
"case 0x0C:\nav_log(VAR_0, AV_LOG_ERROR, \"Interlaced coding not supported\\n\");",
"return -1;",
"case 0x0D:\nbreak;",
"case 0x0E:\nif (v->profile <= MAIN_PROFILE)\nav_log(VAR_0, AV_LOG_ERROR,\n\"Found an entry point in profile %i\\n\", v->profile);",
"advanced_entry_point_process(VAR_0, gb);",
"break;",
"case 0x0F:\ndecode_sequence_header(VAR_0, gb);",
"break;",
"default:\nav_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported IDU suffix %lX\\n\", scs);",
"}",
"i += get_bits_count(gb)*8;",
"}",
"#else\nav_abort();",
"#endif\n}",
"else\ninit_get_bits(&v->s.gb, VAR_3, VAR_4*8);",
"s->flags= VAR_0->flags;",
"s->flags2= VAR_0->flags2;",
"if (VAR_4 == 0) {",
"if (s->low_delay==0 && s->next_picture_ptr) {",
"*pict= *(AVFrame*)s->next_picture_ptr;",
"s->next_picture_ptr= NULL;",
"*VAR_2 = sizeof(AVFrame);",
"}",
"return 0;",
"}",
"s->bitstream_buffer_size=0;",
"if (!s->context_initialized) {",
"if (MPV_common_init(s) < 0)\nreturn -1;",
"}",
"if(s->current_picture_ptr==NULL || s->current_picture_ptr->VAR_1[0]){",
"s->current_picture_ptr= &s->picture[ff_find_unused_picture(s, 0)];",
"}",
"#if HAS_ADVANCED_PROFILE\nif (v->profile > PROFILE_MAIN)\nVAR_5= advanced_decode_picture_primary_header(v);",
"else\n#endif\nVAR_5= standard_decode_picture_primary_header(v);",
"if (VAR_5 == FRAME_SKIPED) return VAR_4;",
"if (VAR_5 < 0){",
"av_log(s->VAR_0, AV_LOG_ERROR, \"header damaged\\n\");",
"return -1;",
"}",
"if (v->profile <= PROFILE_MAIN && v->multires){",
"}",
"s->current_picture.pict_type= s->pict_type;",
"s->current_picture.key_frame= s->pict_type == I_TYPE;",
"if(s->last_picture_ptr==NULL && (s->pict_type==B_TYPE || s->dropable))\nreturn VAR_4;",
"if(VAR_0->hurry_up && s->pict_type==B_TYPE)\nreturn VAR_4;",
"if(VAR_0->hurry_up>=5)\nreturn VAR_4;",
"if(s->next_p_frame_damaged){",
"if(s->pict_type==B_TYPE)\nreturn VAR_4;",
"else\ns->next_p_frame_damaged=0;",
"}",
"if(MPV_frame_start(s, VAR_0) < 0)\nreturn -1;",
"ff_er_frame_start(s);",
"#if HAS_ADVANCED_PROFILE\nif (v->profile > PROFILE_MAIN)\nVAR_5= advanced_decode_picture_secondary_header(v);",
"else\n#endif\nVAR_5 = standard_decode_picture_secondary_header(v);",
"if (VAR_5<0) return FRAME_SKIPED;",
"#if HAS_ADVANCED_PROFILE\nif (v->profile > PROFILE_MAIN)\n{",
"switch(s->pict_type)\n{",
"case I_TYPE: VAR_5 = advanced_decode_i_mbs(v); break;",
"case P_TYPE: VAR_5 = decode_p_mbs(v); break;",
"case B_TYPE:\ncase BI_TYPE: VAR_5 = decode_b_mbs(v); break;",
"default: VAR_5 = FRAME_SKIPED;",
"}",
"if (VAR_5 == FRAME_SKIPED) return VAR_4;",
"}",
"else\n#endif\n{",
"switch(s->pict_type)\n{",
"case I_TYPE: VAR_5 = standard_decode_i_mbs(v); break;",
"case P_TYPE: VAR_5 = decode_p_mbs(v); break;",
"case B_TYPE:\ncase BI_TYPE: VAR_5 = decode_b_mbs(v); break;",
"default: VAR_5 = FRAME_SKIPED;",
"}",
"if (VAR_5 == FRAME_SKIPED) return VAR_4;",
"}",
"ff_er_frame_end(s);",
"MPV_frame_end(s);",
"assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type);",
"assert(s->current_picture.pict_type == s->pict_type);",
"if(s->pict_type==B_TYPE || s->low_delay){",
"*pict= *(AVFrame*)&s->current_picture;",
"ff_print_debug_info(s, pict);",
"} else {",
"*pict= *(AVFrame*)&s->last_picture;",
"if(pict)\nff_print_debug_info(s, pict);",
"}",
"VAR_0->frame_number = s->picture_number - 1;",
"if(s->last_picture_ptr || s->low_delay)\n*VAR_2 = sizeof(AVFrame);",
"av_log(VAR_0, AV_LOG_DEBUG, \"Consumed %i/%i bits\\n\",\nget_bits_count(&s->gb), VAR_4*8);",
"*VAR_2 = VAR_6;",
"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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
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
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
25
],
[
29,
31
],
[
33
],
[
35,
37
],
[
41,
43
],
[
45,
51
],
[
53
],
[
57,
59
],
[
61
],
[
63
],
[
67,
69
],
[
73
],
[
77
],
[
81,
83
],
[
85,
87
],
[
89,
91
],
[
93
],
[
95,
97
],
[
99
],
[
101,
103
],
[
105,
107,
109,
111
],
[
113
],
[
115
],
[
117,
119
],
[
121
],
[
123,
125,
127
],
[
129
],
[
133
],
[
135
],
[
137,
139
],
[
141,
143
],
[
145,
147
],
[
151
],
[
153
],
[
159
],
[
163
],
[
165
],
[
167
],
[
171
],
[
173
],
[
177
],
[
179
],
[
185
],
[
189
],
[
191,
193
],
[
195
],
[
201
],
[
203
],
[
205
],
[
207,
209,
211
],
[
213,
215,
217
],
[
219
],
[
223
],
[
225
],
[
227
],
[
229
],
[
239
],
[
243
],
[
251
],
[
253
],
[
259,
261
],
[
265,
267
],
[
271,
273
],
[
277
],
[
279,
281
],
[
283,
285
],
[
287
],
[
291,
293
],
[
297
],
[
303,
305,
307
],
[
309,
311,
313
],
[
315
],
[
321,
323,
325
],
[
327,
329
],
[
331
],
[
333
],
[
335,
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347,
349,
351
],
[
353,
355
],
[
357
],
[
359
],
[
361,
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
375
],
[
379
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397,
399
],
[
401
],
[
409
],
[
415,
417
],
[
421,
423
],
[
429
],
[
431
],
[
433
]
]
|
14,375 | static void lm32_uclinux_init(MachineState *machine)
{
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
LM32CPU *cpu;
CPULM32State *env;
DriveInfo *dinfo;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
qemu_irq irq[32];
HWSetup *hw;
ResetInfo *reset_info;
int i;
/* memory map */
hwaddr flash_base = 0x04000000;
size_t flash_sector_size = 256 * 1024;
size_t flash_size = 32 * 1024 * 1024;
hwaddr ram_base = 0x08000000;
size_t ram_size = 64 * 1024 * 1024;
hwaddr uart0_base = 0x80000000;
hwaddr timer0_base = 0x80002000;
hwaddr timer1_base = 0x80010000;
hwaddr timer2_base = 0x80012000;
int uart0_irq = 0;
int timer0_irq = 1;
int timer1_irq = 20;
int timer2_irq = 21;
hwaddr hwsetup_base = 0x0bffe000;
hwaddr cmdline_base = 0x0bfff000;
hwaddr initrd_base = 0x08400000;
size_t initrd_max = 0x01000000;
reset_info = g_malloc0(sizeof(ResetInfo));
if (cpu_model == NULL) {
cpu_model = "lm32-full";
}
cpu = LM32_CPU(cpu_generic_init(TYPE_LM32_CPU, cpu_model));
if (cpu == NULL) {
fprintf(stderr, "qemu: unable to find CPU '%s'\n", cpu_model);
exit(1);
}
env = &cpu->env;
reset_info->cpu = cpu;
reset_info->flash_base = flash_base;
memory_region_allocate_system_memory(phys_ram, NULL,
"lm32_uclinux.sdram", ram_size);
memory_region_add_subregion(address_space_mem, ram_base, phys_ram);
dinfo = drive_get(IF_PFLASH, 0, 0);
/* Spansion S29NS128P */
pflash_cfi02_register(flash_base, NULL, "lm32_uclinux.flash", flash_size,
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
flash_sector_size, flash_size / flash_sector_size,
1, 2, 0x01, 0x7e, 0x43, 0x00, 0x555, 0x2aa, 1);
/* create irq lines */
env->pic_state = lm32_pic_init(qemu_allocate_irq(cpu_irq_handler, env, 0));
for (i = 0; i < 32; i++) {
irq[i] = qdev_get_gpio_in(env->pic_state, i);
}
lm32_uart_create(uart0_base, irq[uart0_irq], serial_hds[0]);
sysbus_create_simple("lm32-timer", timer0_base, irq[timer0_irq]);
sysbus_create_simple("lm32-timer", timer1_base, irq[timer1_irq]);
sysbus_create_simple("lm32-timer", timer2_base, irq[timer2_irq]);
/* make sure juart isn't the first chardev */
env->juart_state = lm32_juart_init(serial_hds[1]);
reset_info->bootstrap_pc = flash_base;
if (kernel_filename) {
uint64_t entry;
int kernel_size;
kernel_size = load_elf(kernel_filename, NULL, NULL, &entry, NULL, NULL,
1, EM_LATTICEMICO32, 0, 0);
reset_info->bootstrap_pc = entry;
if (kernel_size < 0) {
kernel_size = load_image_targphys(kernel_filename, ram_base,
ram_size);
reset_info->bootstrap_pc = ram_base;
}
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
kernel_filename);
exit(1);
}
}
/* generate a rom with the hardware description */
hw = hwsetup_init();
hwsetup_add_cpu(hw, "LM32", 75000000);
hwsetup_add_flash(hw, "flash", flash_base, flash_size);
hwsetup_add_ddr_sdram(hw, "ddr_sdram", ram_base, ram_size);
hwsetup_add_timer(hw, "timer0", timer0_base, timer0_irq);
hwsetup_add_timer(hw, "timer1_dev_only", timer1_base, timer1_irq);
hwsetup_add_timer(hw, "timer2_dev_only", timer2_base, timer2_irq);
hwsetup_add_uart(hw, "uart", uart0_base, uart0_irq);
hwsetup_add_trailer(hw);
hwsetup_create_rom(hw, hwsetup_base);
hwsetup_free(hw);
reset_info->hwsetup_base = hwsetup_base;
if (kernel_cmdline && strlen(kernel_cmdline)) {
pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE,
kernel_cmdline);
reset_info->cmdline_base = cmdline_base;
}
if (initrd_filename) {
size_t initrd_size;
initrd_size = load_image_targphys(initrd_filename, initrd_base,
initrd_max);
reset_info->initrd_base = initrd_base;
reset_info->initrd_size = initrd_size;
}
qemu_register_reset(main_cpu_reset, reset_info);
}
| true | qemu | 4482e05cbbb7e50e476f6a9500cf0b38913bd939 | static void lm32_uclinux_init(MachineState *machine)
{
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
LM32CPU *cpu;
CPULM32State *env;
DriveInfo *dinfo;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
qemu_irq irq[32];
HWSetup *hw;
ResetInfo *reset_info;
int i;
hwaddr flash_base = 0x04000000;
size_t flash_sector_size = 256 * 1024;
size_t flash_size = 32 * 1024 * 1024;
hwaddr ram_base = 0x08000000;
size_t ram_size = 64 * 1024 * 1024;
hwaddr uart0_base = 0x80000000;
hwaddr timer0_base = 0x80002000;
hwaddr timer1_base = 0x80010000;
hwaddr timer2_base = 0x80012000;
int uart0_irq = 0;
int timer0_irq = 1;
int timer1_irq = 20;
int timer2_irq = 21;
hwaddr hwsetup_base = 0x0bffe000;
hwaddr cmdline_base = 0x0bfff000;
hwaddr initrd_base = 0x08400000;
size_t initrd_max = 0x01000000;
reset_info = g_malloc0(sizeof(ResetInfo));
if (cpu_model == NULL) {
cpu_model = "lm32-full";
}
cpu = LM32_CPU(cpu_generic_init(TYPE_LM32_CPU, cpu_model));
if (cpu == NULL) {
fprintf(stderr, "qemu: unable to find CPU '%s'\n", cpu_model);
exit(1);
}
env = &cpu->env;
reset_info->cpu = cpu;
reset_info->flash_base = flash_base;
memory_region_allocate_system_memory(phys_ram, NULL,
"lm32_uclinux.sdram", ram_size);
memory_region_add_subregion(address_space_mem, ram_base, phys_ram);
dinfo = drive_get(IF_PFLASH, 0, 0);
pflash_cfi02_register(flash_base, NULL, "lm32_uclinux.flash", flash_size,
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
flash_sector_size, flash_size / flash_sector_size,
1, 2, 0x01, 0x7e, 0x43, 0x00, 0x555, 0x2aa, 1);
env->pic_state = lm32_pic_init(qemu_allocate_irq(cpu_irq_handler, env, 0));
for (i = 0; i < 32; i++) {
irq[i] = qdev_get_gpio_in(env->pic_state, i);
}
lm32_uart_create(uart0_base, irq[uart0_irq], serial_hds[0]);
sysbus_create_simple("lm32-timer", timer0_base, irq[timer0_irq]);
sysbus_create_simple("lm32-timer", timer1_base, irq[timer1_irq]);
sysbus_create_simple("lm32-timer", timer2_base, irq[timer2_irq]);
env->juart_state = lm32_juart_init(serial_hds[1]);
reset_info->bootstrap_pc = flash_base;
if (kernel_filename) {
uint64_t entry;
int kernel_size;
kernel_size = load_elf(kernel_filename, NULL, NULL, &entry, NULL, NULL,
1, EM_LATTICEMICO32, 0, 0);
reset_info->bootstrap_pc = entry;
if (kernel_size < 0) {
kernel_size = load_image_targphys(kernel_filename, ram_base,
ram_size);
reset_info->bootstrap_pc = ram_base;
}
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
kernel_filename);
exit(1);
}
}
hw = hwsetup_init();
hwsetup_add_cpu(hw, "LM32", 75000000);
hwsetup_add_flash(hw, "flash", flash_base, flash_size);
hwsetup_add_ddr_sdram(hw, "ddr_sdram", ram_base, ram_size);
hwsetup_add_timer(hw, "timer0", timer0_base, timer0_irq);
hwsetup_add_timer(hw, "timer1_dev_only", timer1_base, timer1_irq);
hwsetup_add_timer(hw, "timer2_dev_only", timer2_base, timer2_irq);
hwsetup_add_uart(hw, "uart", uart0_base, uart0_irq);
hwsetup_add_trailer(hw);
hwsetup_create_rom(hw, hwsetup_base);
hwsetup_free(hw);
reset_info->hwsetup_base = hwsetup_base;
if (kernel_cmdline && strlen(kernel_cmdline)) {
pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE,
kernel_cmdline);
reset_info->cmdline_base = cmdline_base;
}
if (initrd_filename) {
size_t initrd_size;
initrd_size = load_image_targphys(initrd_filename, initrd_base,
initrd_max);
reset_info->initrd_base = initrd_base;
reset_info->initrd_size = initrd_size;
}
qemu_register_reset(main_cpu_reset, reset_info);
}
| {
"code": [
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" if (cpu == NULL) {",
" fprintf(stderr, \"qemu: unable to find CPU '%s'\\n\", cpu_model);",
" exit(1);",
" if (cpu == NULL) {",
" fprintf(stderr, \"qemu: unable to find CPU '%s'\\n\", cpu_model);",
" exit(1);",
" if (cpu == NULL) {",
" fprintf(stderr, \"qemu: unable to find CPU '%s'\\n\", cpu_model);",
" exit(1);",
" exit(1);",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" exit(1);",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" exit(1);",
" exit(1);"
],
"line_no": [
87,
191,
87,
87,
87,
87,
87,
87,
83,
85,
87,
83,
85,
87,
83,
85,
87,
87,
87,
83,
87,
83,
87,
191,
83,
87,
83,
87,
87,
191,
191,
191,
191,
83,
87,
83,
87,
191,
87,
83,
87,
83,
87,
83,
87,
83,
87,
83,
87,
83,
87,
87,
87
]
} | static void FUNC_0(MachineState *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;
LM32CPU *cpu;
CPULM32State *env;
DriveInfo *dinfo;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
qemu_irq irq[32];
HWSetup *hw;
ResetInfo *reset_info;
int VAR_5;
hwaddr flash_base = 0x04000000;
size_t flash_sector_size = 256 * 1024;
size_t flash_size = 32 * 1024 * 1024;
hwaddr ram_base = 0x08000000;
size_t ram_size = 64 * 1024 * 1024;
hwaddr uart0_base = 0x80000000;
hwaddr timer0_base = 0x80002000;
hwaddr timer1_base = 0x80010000;
hwaddr timer2_base = 0x80012000;
int VAR_6 = 0;
int VAR_7 = 1;
int VAR_8 = 20;
int VAR_9 = 21;
hwaddr hwsetup_base = 0x0bffe000;
hwaddr cmdline_base = 0x0bfff000;
hwaddr initrd_base = 0x08400000;
size_t initrd_max = 0x01000000;
reset_info = g_malloc0(sizeof(ResetInfo));
if (VAR_1 == NULL) {
VAR_1 = "lm32-full";
}
cpu = LM32_CPU(cpu_generic_init(TYPE_LM32_CPU, VAR_1));
if (cpu == NULL) {
fprintf(stderr, "qemu: unable to find CPU '%s'\n", VAR_1);
exit(1);
}
env = &cpu->env;
reset_info->cpu = cpu;
reset_info->flash_base = flash_base;
memory_region_allocate_system_memory(phys_ram, NULL,
"lm32_uclinux.sdram", ram_size);
memory_region_add_subregion(address_space_mem, ram_base, phys_ram);
dinfo = drive_get(IF_PFLASH, 0, 0);
pflash_cfi02_register(flash_base, NULL, "lm32_uclinux.flash", flash_size,
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
flash_sector_size, flash_size / flash_sector_size,
1, 2, 0x01, 0x7e, 0x43, 0x00, 0x555, 0x2aa, 1);
env->pic_state = lm32_pic_init(qemu_allocate_irq(cpu_irq_handler, env, 0));
for (VAR_5 = 0; VAR_5 < 32; VAR_5++) {
irq[VAR_5] = qdev_get_gpio_in(env->pic_state, VAR_5);
}
lm32_uart_create(uart0_base, irq[VAR_6], serial_hds[0]);
sysbus_create_simple("lm32-timer", timer0_base, irq[VAR_7]);
sysbus_create_simple("lm32-timer", timer1_base, irq[VAR_8]);
sysbus_create_simple("lm32-timer", timer2_base, irq[VAR_9]);
env->juart_state = lm32_juart_init(serial_hds[1]);
reset_info->bootstrap_pc = flash_base;
if (VAR_2) {
uint64_t entry;
int VAR_10;
VAR_10 = load_elf(VAR_2, NULL, NULL, &entry, NULL, NULL,
1, EM_LATTICEMICO32, 0, 0);
reset_info->bootstrap_pc = entry;
if (VAR_10 < 0) {
VAR_10 = load_image_targphys(VAR_2, ram_base,
ram_size);
reset_info->bootstrap_pc = ram_base;
}
if (VAR_10 < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
VAR_2);
exit(1);
}
}
hw = hwsetup_init();
hwsetup_add_cpu(hw, "LM32", 75000000);
hwsetup_add_flash(hw, "flash", flash_base, flash_size);
hwsetup_add_ddr_sdram(hw, "ddr_sdram", ram_base, ram_size);
hwsetup_add_timer(hw, "timer0", timer0_base, VAR_7);
hwsetup_add_timer(hw, "timer1_dev_only", timer1_base, VAR_8);
hwsetup_add_timer(hw, "timer2_dev_only", timer2_base, VAR_9);
hwsetup_add_uart(hw, "uart", uart0_base, VAR_6);
hwsetup_add_trailer(hw);
hwsetup_create_rom(hw, hwsetup_base);
hwsetup_free(hw);
reset_info->hwsetup_base = hwsetup_base;
if (VAR_3 && strlen(VAR_3)) {
pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE,
VAR_3);
reset_info->cmdline_base = cmdline_base;
}
if (VAR_4) {
size_t initrd_size;
initrd_size = load_image_targphys(VAR_4, initrd_base,
initrd_max);
reset_info->initrd_base = initrd_base;
reset_info->initrd_size = initrd_size;
}
qemu_register_reset(main_cpu_reset, reset_info);
}
| [
"static void FUNC_0(MachineState *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;",
"LM32CPU *cpu;",
"CPULM32State *env;",
"DriveInfo *dinfo;",
"MemoryRegion *address_space_mem = get_system_memory();",
"MemoryRegion *phys_ram = g_new(MemoryRegion, 1);",
"qemu_irq irq[32];",
"HWSetup *hw;",
"ResetInfo *reset_info;",
"int VAR_5;",
"hwaddr flash_base = 0x04000000;",
"size_t flash_sector_size = 256 * 1024;",
"size_t flash_size = 32 * 1024 * 1024;",
"hwaddr ram_base = 0x08000000;",
"size_t ram_size = 64 * 1024 * 1024;",
"hwaddr uart0_base = 0x80000000;",
"hwaddr timer0_base = 0x80002000;",
"hwaddr timer1_base = 0x80010000;",
"hwaddr timer2_base = 0x80012000;",
"int VAR_6 = 0;",
"int VAR_7 = 1;",
"int VAR_8 = 20;",
"int VAR_9 = 21;",
"hwaddr hwsetup_base = 0x0bffe000;",
"hwaddr cmdline_base = 0x0bfff000;",
"hwaddr initrd_base = 0x08400000;",
"size_t initrd_max = 0x01000000;",
"reset_info = g_malloc0(sizeof(ResetInfo));",
"if (VAR_1 == NULL) {",
"VAR_1 = \"lm32-full\";",
"}",
"cpu = LM32_CPU(cpu_generic_init(TYPE_LM32_CPU, VAR_1));",
"if (cpu == NULL) {",
"fprintf(stderr, \"qemu: unable to find CPU '%s'\\n\", VAR_1);",
"exit(1);",
"}",
"env = &cpu->env;",
"reset_info->cpu = cpu;",
"reset_info->flash_base = flash_base;",
"memory_region_allocate_system_memory(phys_ram, NULL,\n\"lm32_uclinux.sdram\", ram_size);",
"memory_region_add_subregion(address_space_mem, ram_base, phys_ram);",
"dinfo = drive_get(IF_PFLASH, 0, 0);",
"pflash_cfi02_register(flash_base, NULL, \"lm32_uclinux.flash\", flash_size,\ndinfo ? blk_by_legacy_dinfo(dinfo) : NULL,\nflash_sector_size, flash_size / flash_sector_size,\n1, 2, 0x01, 0x7e, 0x43, 0x00, 0x555, 0x2aa, 1);",
"env->pic_state = lm32_pic_init(qemu_allocate_irq(cpu_irq_handler, env, 0));",
"for (VAR_5 = 0; VAR_5 < 32; VAR_5++) {",
"irq[VAR_5] = qdev_get_gpio_in(env->pic_state, VAR_5);",
"}",
"lm32_uart_create(uart0_base, irq[VAR_6], serial_hds[0]);",
"sysbus_create_simple(\"lm32-timer\", timer0_base, irq[VAR_7]);",
"sysbus_create_simple(\"lm32-timer\", timer1_base, irq[VAR_8]);",
"sysbus_create_simple(\"lm32-timer\", timer2_base, irq[VAR_9]);",
"env->juart_state = lm32_juart_init(serial_hds[1]);",
"reset_info->bootstrap_pc = flash_base;",
"if (VAR_2) {",
"uint64_t entry;",
"int VAR_10;",
"VAR_10 = load_elf(VAR_2, NULL, NULL, &entry, NULL, NULL,\n1, EM_LATTICEMICO32, 0, 0);",
"reset_info->bootstrap_pc = entry;",
"if (VAR_10 < 0) {",
"VAR_10 = load_image_targphys(VAR_2, ram_base,\nram_size);",
"reset_info->bootstrap_pc = ram_base;",
"}",
"if (VAR_10 < 0) {",
"fprintf(stderr, \"qemu: could not load kernel '%s'\\n\",\nVAR_2);",
"exit(1);",
"}",
"}",
"hw = hwsetup_init();",
"hwsetup_add_cpu(hw, \"LM32\", 75000000);",
"hwsetup_add_flash(hw, \"flash\", flash_base, flash_size);",
"hwsetup_add_ddr_sdram(hw, \"ddr_sdram\", ram_base, ram_size);",
"hwsetup_add_timer(hw, \"timer0\", timer0_base, VAR_7);",
"hwsetup_add_timer(hw, \"timer1_dev_only\", timer1_base, VAR_8);",
"hwsetup_add_timer(hw, \"timer2_dev_only\", timer2_base, VAR_9);",
"hwsetup_add_uart(hw, \"uart\", uart0_base, VAR_6);",
"hwsetup_add_trailer(hw);",
"hwsetup_create_rom(hw, hwsetup_base);",
"hwsetup_free(hw);",
"reset_info->hwsetup_base = hwsetup_base;",
"if (VAR_3 && strlen(VAR_3)) {",
"pstrcpy_targphys(\"cmdline\", cmdline_base, TARGET_PAGE_SIZE,\nVAR_3);",
"reset_info->cmdline_base = cmdline_base;",
"}",
"if (VAR_4) {",
"size_t initrd_size;",
"initrd_size = load_image_targphys(VAR_4, initrd_base,\ninitrd_max);",
"reset_info->initrd_base = initrd_base;",
"reset_info->initrd_size = initrd_size;",
"}",
"qemu_register_reset(main_cpu_reset, reset_info);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
99
],
[
103,
105
],
[
107
],
[
111
],
[
115,
117,
119,
121
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
141
],
[
143
],
[
149
],
[
153
],
[
157
],
[
159
],
[
161
],
[
165,
167
],
[
169
],
[
173
],
[
175,
177
],
[
179
],
[
181
],
[
185
],
[
187,
189
],
[
191
],
[
193
],
[
195
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
225
],
[
229
],
[
231,
233
],
[
235
],
[
237
],
[
241
],
[
243
],
[
245,
247
],
[
249
],
[
251
],
[
253
],
[
257
],
[
259
]
]
|
14,377 | static int vnc_update_client(VncState *vs, int has_dirty)
{
if (vs->need_update && vs->csock != -1) {
VncDisplay *vd = vs->vd;
VncJob *job;
int y;
int width, height;
int n = 0;
if (vs->output.offset && !vs->audio_cap && !vs->force_update)
/* kernel send buffers are full -> drop frames to throttle */
return 0;
if (!has_dirty && !vs->audio_cap && !vs->force_update)
return 0;
/*
* Send screen updates to the vnc client using the server
* surface and server dirty map. guest surface updates
* happening in parallel don't disturb us, the next pass will
* send them to the client.
*/
job = vnc_job_new(vs);
width = MIN(pixman_image_get_width(vd->server), vs->client_width);
height = MIN(pixman_image_get_height(vd->server), vs->client_height);
for (y = 0; y < height; y++) {
int x;
int last_x = -1;
for (x = 0; x < width / 16; x++) {
if (test_and_clear_bit(x, vs->dirty[y])) {
if (last_x == -1) {
last_x = x;
}
} else {
if (last_x != -1) {
int h = find_and_clear_dirty_height(vs, y, last_x, x,
height);
n += vnc_job_add_rect(job, last_x * 16, y,
(x - last_x) * 16, h);
}
last_x = -1;
}
}
if (last_x != -1) {
int h = find_and_clear_dirty_height(vs, y, last_x, x, height);
n += vnc_job_add_rect(job, last_x * 16, y,
(x - last_x) * 16, h);
}
}
vnc_job_push(job);
vs->force_update = 0;
return n;
}
if (vs->csock == -1)
vnc_disconnect_finish(vs);
return 0;
}
| true | qemu | 38ee14f4f33f8836fc0e209ca59c6ae8c6edf380 | static int vnc_update_client(VncState *vs, int has_dirty)
{
if (vs->need_update && vs->csock != -1) {
VncDisplay *vd = vs->vd;
VncJob *job;
int y;
int width, height;
int n = 0;
if (vs->output.offset && !vs->audio_cap && !vs->force_update)
return 0;
if (!has_dirty && !vs->audio_cap && !vs->force_update)
return 0;
job = vnc_job_new(vs);
width = MIN(pixman_image_get_width(vd->server), vs->client_width);
height = MIN(pixman_image_get_height(vd->server), vs->client_height);
for (y = 0; y < height; y++) {
int x;
int last_x = -1;
for (x = 0; x < width / 16; x++) {
if (test_and_clear_bit(x, vs->dirty[y])) {
if (last_x == -1) {
last_x = x;
}
} else {
if (last_x != -1) {
int h = find_and_clear_dirty_height(vs, y, last_x, x,
height);
n += vnc_job_add_rect(job, last_x * 16, y,
(x - last_x) * 16, h);
}
last_x = -1;
}
}
if (last_x != -1) {
int h = find_and_clear_dirty_height(vs, y, last_x, x, height);
n += vnc_job_add_rect(job, last_x * 16, y,
(x - last_x) * 16, h);
}
}
vnc_job_push(job);
vs->force_update = 0;
return n;
}
if (vs->csock == -1)
vnc_disconnect_finish(vs);
return 0;
}
| {
"code": [
"static int vnc_update_client(VncState *vs, int has_dirty)",
" if (vs->csock == -1)"
],
"line_no": [
1,
119
]
} | static int FUNC_0(VncState *VAR_0, int VAR_1)
{
if (VAR_0->need_update && VAR_0->csock != -1) {
VncDisplay *vd = VAR_0->vd;
VncJob *job;
int VAR_2;
int VAR_3, VAR_4;
int VAR_5 = 0;
if (VAR_0->output.offset && !VAR_0->audio_cap && !VAR_0->force_update)
return 0;
if (!VAR_1 && !VAR_0->audio_cap && !VAR_0->force_update)
return 0;
job = vnc_job_new(VAR_0);
VAR_3 = MIN(pixman_image_get_width(vd->server), VAR_0->client_width);
VAR_4 = MIN(pixman_image_get_height(vd->server), VAR_0->client_height);
for (VAR_2 = 0; VAR_2 < VAR_4; VAR_2++) {
int VAR_6;
int VAR_7 = -1;
for (VAR_6 = 0; VAR_6 < VAR_3 / 16; VAR_6++) {
if (test_and_clear_bit(VAR_6, VAR_0->dirty[VAR_2])) {
if (VAR_7 == -1) {
VAR_7 = VAR_6;
}
} else {
if (VAR_7 != -1) {
int VAR_9 = find_and_clear_dirty_height(VAR_0, VAR_2, VAR_7, VAR_6,
VAR_4);
VAR_5 += vnc_job_add_rect(job, VAR_7 * 16, VAR_2,
(VAR_6 - VAR_7) * 16, VAR_9);
}
VAR_7 = -1;
}
}
if (VAR_7 != -1) {
int VAR_9 = find_and_clear_dirty_height(VAR_0, VAR_2, VAR_7, VAR_6, VAR_4);
VAR_5 += vnc_job_add_rect(job, VAR_7 * 16, VAR_2,
(VAR_6 - VAR_7) * 16, VAR_9);
}
}
vnc_job_push(job);
VAR_0->force_update = 0;
return VAR_5;
}
if (VAR_0->csock == -1)
vnc_disconnect_finish(VAR_0);
return 0;
}
| [
"static int FUNC_0(VncState *VAR_0, int VAR_1)\n{",
"if (VAR_0->need_update && VAR_0->csock != -1) {",
"VncDisplay *vd = VAR_0->vd;",
"VncJob *job;",
"int VAR_2;",
"int VAR_3, VAR_4;",
"int VAR_5 = 0;",
"if (VAR_0->output.offset && !VAR_0->audio_cap && !VAR_0->force_update)\nreturn 0;",
"if (!VAR_1 && !VAR_0->audio_cap && !VAR_0->force_update)\nreturn 0;",
"job = vnc_job_new(VAR_0);",
"VAR_3 = MIN(pixman_image_get_width(vd->server), VAR_0->client_width);",
"VAR_4 = MIN(pixman_image_get_height(vd->server), VAR_0->client_height);",
"for (VAR_2 = 0; VAR_2 < VAR_4; VAR_2++) {",
"int VAR_6;",
"int VAR_7 = -1;",
"for (VAR_6 = 0; VAR_6 < VAR_3 / 16; VAR_6++) {",
"if (test_and_clear_bit(VAR_6, VAR_0->dirty[VAR_2])) {",
"if (VAR_7 == -1) {",
"VAR_7 = VAR_6;",
"}",
"} else {",
"if (VAR_7 != -1) {",
"int VAR_9 = find_and_clear_dirty_height(VAR_0, VAR_2, VAR_7, VAR_6,\nVAR_4);",
"VAR_5 += vnc_job_add_rect(job, VAR_7 * 16, VAR_2,\n(VAR_6 - VAR_7) * 16, VAR_9);",
"}",
"VAR_7 = -1;",
"}",
"}",
"if (VAR_7 != -1) {",
"int VAR_9 = find_and_clear_dirty_height(VAR_0, VAR_2, VAR_7, VAR_6, VAR_4);",
"VAR_5 += vnc_job_add_rect(job, VAR_7 * 16, VAR_2,\n(VAR_6 - VAR_7) * 16, VAR_9);",
"}",
"}",
"vnc_job_push(job);",
"VAR_0->force_update = 0;",
"return VAR_5;",
"}",
"if (VAR_0->csock == -1)\nvnc_disconnect_finish(VAR_0);",
"return 0;",
"}"
]
| [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
21,
25
],
[
29,
31
],
[
47
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
83,
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119,
121
],
[
125
],
[
127
]
]
|
14,378 | static void test_qemu_strtol_empty(void)
{
const char *str = "";
char f = 'X';
const char *endptr = &f;
long res = 999;
int err;
err = qemu_strtol(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, 0);
g_assert(endptr == str);
}
| true | qemu | 47d4be12c3997343e436c6cca89aefbbbeb70863 | static void test_qemu_strtol_empty(void)
{
const char *str = "";
char f = 'X';
const char *endptr = &f;
long res = 999;
int err;
err = qemu_strtol(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, 0);
g_assert(endptr == str);
}
| {
"code": [
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);"
],
"line_no": [
21,
23,
25,
21,
23,
25,
21,
23,
25,
21,
23,
21,
23,
25,
21,
23,
25,
21,
25,
21,
23,
21,
23,
25,
21,
23,
25,
21,
25,
21,
23,
21,
23,
25,
21,
23,
25,
21,
25,
21,
23
]
} | static void FUNC_0(void)
{
const char *VAR_0 = "";
char VAR_1 = 'X';
const char *VAR_2 = &VAR_1;
long VAR_3 = 999;
int VAR_4;
VAR_4 = qemu_strtol(VAR_0, &VAR_2, 0, &VAR_3);
g_assert_cmpint(VAR_4, ==, 0);
g_assert_cmpint(VAR_3, ==, 0);
g_assert(VAR_2 == VAR_0);
}
| [
"static void FUNC_0(void)\n{",
"const char *VAR_0 = \"\";",
"char VAR_1 = 'X';",
"const char *VAR_2 = &VAR_1;",
"long VAR_3 = 999;",
"int VAR_4;",
"VAR_4 = qemu_strtol(VAR_0, &VAR_2, 0, &VAR_3);",
"g_assert_cmpint(VAR_4, ==, 0);",
"g_assert_cmpint(VAR_3, ==, 0);",
"g_assert(VAR_2 == VAR_0);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
]
]
|
14,380 | static void test_endianness(gconstpointer data)
{
const TestCase *test = data;
char *args;
args = g_strdup_printf("-display none -M %s%s%s -device pc-testdev",
test->machine,
test->superio ? " -device " : "",
test->superio ?: "");
qtest_start(args);
isa_outl(test, 0xe0, 0x87654321);
g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654321);
g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765);
g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4321);
g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x87);
g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x65);
g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x43);
g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x21);
isa_outw(test, 0xe2, 0x8866);
g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x88664321);
g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8866);
g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4321);
g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x88);
g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x66);
g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x43);
g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x21);
isa_outw(test, 0xe0, 0x4422);
g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x88664422);
g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8866);
g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4422);
g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x88);
g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x66);
g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x44);
g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x22);
isa_outb(test, 0xe3, 0x87);
g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87664422);
g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8766);
g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x87);
g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x66);
g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x44);
g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x22);
isa_outb(test, 0xe2, 0x65);
g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654422);
g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765);
g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4422);
g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x87);
g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x65);
g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x44);
g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x22);
isa_outb(test, 0xe1, 0x43);
g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654322);
g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765);
g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4322);
g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x87);
g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x65);
g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x43);
g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x22);
isa_outb(test, 0xe0, 0x21);
g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654321);
g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765);
g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4321);
g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x87);
g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x65);
g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x43);
g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x21);
qtest_quit(global_qtest);
g_free(args);
}
| true | qemu | 2ad645d2854746b55ddfd1d8e951f689cca5d78f | static void test_endianness(gconstpointer data)
{
const TestCase *test = data;
char *args;
args = g_strdup_printf("-display none -M %s%s%s -device pc-testdev",
test->machine,
test->superio ? " -device " : "",
test->superio ?: "");
qtest_start(args);
isa_outl(test, 0xe0, 0x87654321);
g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654321);
g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765);
g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4321);
g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x87);
g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x65);
g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x43);
g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x21);
isa_outw(test, 0xe2, 0x8866);
g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x88664321);
g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8866);
g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4321);
g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x88);
g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x66);
g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x43);
g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x21);
isa_outw(test, 0xe0, 0x4422);
g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x88664422);
g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8866);
g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4422);
g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x88);
g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x66);
g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x44);
g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x22);
isa_outb(test, 0xe3, 0x87);
g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87664422);
g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8766);
g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x87);
g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x66);
g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x44);
g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x22);
isa_outb(test, 0xe2, 0x65);
g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654422);
g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765);
g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4422);
g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x87);
g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x65);
g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x44);
g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x22);
isa_outb(test, 0xe1, 0x43);
g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654322);
g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765);
g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4322);
g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x87);
g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x65);
g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x43);
g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x22);
isa_outb(test, 0xe0, 0x21);
g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654321);
g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765);
g_assert_cmphex(isa_inw(test, 0xe0), ==, 0x4321);
g_assert_cmphex(isa_inb(test, 0xe3), ==, 0x87);
g_assert_cmphex(isa_inb(test, 0xe2), ==, 0x65);
g_assert_cmphex(isa_inb(test, 0xe1), ==, 0x43);
g_assert_cmphex(isa_inb(test, 0xe0), ==, 0x21);
qtest_quit(global_qtest);
g_free(args);
}
| {
"code": [
" args = g_strdup_printf(\"-display none -M %s%s%s -device pc-testdev\",",
" args = g_strdup_printf(\"-display none -M %s%s%s -device pc-testdev\",",
" args = g_strdup_printf(\"-display none -M %s%s%s -device pc-testdev\","
],
"line_no": [
11,
11,
11
]
} | static void FUNC_0(gconstpointer VAR_0)
{
const TestCase *VAR_1 = VAR_0;
char *VAR_2;
VAR_2 = g_strdup_printf("-display none -M %s%s%s -device pc-testdev",
VAR_1->machine,
VAR_1->superio ? " -device " : "",
VAR_1->superio ?: "");
qtest_start(VAR_2);
isa_outl(VAR_1, 0xe0, 0x87654321);
g_assert_cmphex(isa_inl(VAR_1, 0xe0), ==, 0x87654321);
g_assert_cmphex(isa_inw(VAR_1, 0xe2), ==, 0x8765);
g_assert_cmphex(isa_inw(VAR_1, 0xe0), ==, 0x4321);
g_assert_cmphex(isa_inb(VAR_1, 0xe3), ==, 0x87);
g_assert_cmphex(isa_inb(VAR_1, 0xe2), ==, 0x65);
g_assert_cmphex(isa_inb(VAR_1, 0xe1), ==, 0x43);
g_assert_cmphex(isa_inb(VAR_1, 0xe0), ==, 0x21);
isa_outw(VAR_1, 0xe2, 0x8866);
g_assert_cmphex(isa_inl(VAR_1, 0xe0), ==, 0x88664321);
g_assert_cmphex(isa_inw(VAR_1, 0xe2), ==, 0x8866);
g_assert_cmphex(isa_inw(VAR_1, 0xe0), ==, 0x4321);
g_assert_cmphex(isa_inb(VAR_1, 0xe3), ==, 0x88);
g_assert_cmphex(isa_inb(VAR_1, 0xe2), ==, 0x66);
g_assert_cmphex(isa_inb(VAR_1, 0xe1), ==, 0x43);
g_assert_cmphex(isa_inb(VAR_1, 0xe0), ==, 0x21);
isa_outw(VAR_1, 0xe0, 0x4422);
g_assert_cmphex(isa_inl(VAR_1, 0xe0), ==, 0x88664422);
g_assert_cmphex(isa_inw(VAR_1, 0xe2), ==, 0x8866);
g_assert_cmphex(isa_inw(VAR_1, 0xe0), ==, 0x4422);
g_assert_cmphex(isa_inb(VAR_1, 0xe3), ==, 0x88);
g_assert_cmphex(isa_inb(VAR_1, 0xe2), ==, 0x66);
g_assert_cmphex(isa_inb(VAR_1, 0xe1), ==, 0x44);
g_assert_cmphex(isa_inb(VAR_1, 0xe0), ==, 0x22);
isa_outb(VAR_1, 0xe3, 0x87);
g_assert_cmphex(isa_inl(VAR_1, 0xe0), ==, 0x87664422);
g_assert_cmphex(isa_inw(VAR_1, 0xe2), ==, 0x8766);
g_assert_cmphex(isa_inb(VAR_1, 0xe3), ==, 0x87);
g_assert_cmphex(isa_inb(VAR_1, 0xe2), ==, 0x66);
g_assert_cmphex(isa_inb(VAR_1, 0xe1), ==, 0x44);
g_assert_cmphex(isa_inb(VAR_1, 0xe0), ==, 0x22);
isa_outb(VAR_1, 0xe2, 0x65);
g_assert_cmphex(isa_inl(VAR_1, 0xe0), ==, 0x87654422);
g_assert_cmphex(isa_inw(VAR_1, 0xe2), ==, 0x8765);
g_assert_cmphex(isa_inw(VAR_1, 0xe0), ==, 0x4422);
g_assert_cmphex(isa_inb(VAR_1, 0xe3), ==, 0x87);
g_assert_cmphex(isa_inb(VAR_1, 0xe2), ==, 0x65);
g_assert_cmphex(isa_inb(VAR_1, 0xe1), ==, 0x44);
g_assert_cmphex(isa_inb(VAR_1, 0xe0), ==, 0x22);
isa_outb(VAR_1, 0xe1, 0x43);
g_assert_cmphex(isa_inl(VAR_1, 0xe0), ==, 0x87654322);
g_assert_cmphex(isa_inw(VAR_1, 0xe2), ==, 0x8765);
g_assert_cmphex(isa_inw(VAR_1, 0xe0), ==, 0x4322);
g_assert_cmphex(isa_inb(VAR_1, 0xe3), ==, 0x87);
g_assert_cmphex(isa_inb(VAR_1, 0xe2), ==, 0x65);
g_assert_cmphex(isa_inb(VAR_1, 0xe1), ==, 0x43);
g_assert_cmphex(isa_inb(VAR_1, 0xe0), ==, 0x22);
isa_outb(VAR_1, 0xe0, 0x21);
g_assert_cmphex(isa_inl(VAR_1, 0xe0), ==, 0x87654321);
g_assert_cmphex(isa_inw(VAR_1, 0xe2), ==, 0x8765);
g_assert_cmphex(isa_inw(VAR_1, 0xe0), ==, 0x4321);
g_assert_cmphex(isa_inb(VAR_1, 0xe3), ==, 0x87);
g_assert_cmphex(isa_inb(VAR_1, 0xe2), ==, 0x65);
g_assert_cmphex(isa_inb(VAR_1, 0xe1), ==, 0x43);
g_assert_cmphex(isa_inb(VAR_1, 0xe0), ==, 0x21);
qtest_quit(global_qtest);
g_free(VAR_2);
}
| [
"static void FUNC_0(gconstpointer VAR_0)\n{",
"const TestCase *VAR_1 = VAR_0;",
"char *VAR_2;",
"VAR_2 = g_strdup_printf(\"-display none -M %s%s%s -device pc-testdev\",\nVAR_1->machine,\nVAR_1->superio ? \" -device \" : \"\",\nVAR_1->superio ?: \"\");",
"qtest_start(VAR_2);",
"isa_outl(VAR_1, 0xe0, 0x87654321);",
"g_assert_cmphex(isa_inl(VAR_1, 0xe0), ==, 0x87654321);",
"g_assert_cmphex(isa_inw(VAR_1, 0xe2), ==, 0x8765);",
"g_assert_cmphex(isa_inw(VAR_1, 0xe0), ==, 0x4321);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe3), ==, 0x87);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe2), ==, 0x65);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe1), ==, 0x43);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe0), ==, 0x21);",
"isa_outw(VAR_1, 0xe2, 0x8866);",
"g_assert_cmphex(isa_inl(VAR_1, 0xe0), ==, 0x88664321);",
"g_assert_cmphex(isa_inw(VAR_1, 0xe2), ==, 0x8866);",
"g_assert_cmphex(isa_inw(VAR_1, 0xe0), ==, 0x4321);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe3), ==, 0x88);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe2), ==, 0x66);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe1), ==, 0x43);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe0), ==, 0x21);",
"isa_outw(VAR_1, 0xe0, 0x4422);",
"g_assert_cmphex(isa_inl(VAR_1, 0xe0), ==, 0x88664422);",
"g_assert_cmphex(isa_inw(VAR_1, 0xe2), ==, 0x8866);",
"g_assert_cmphex(isa_inw(VAR_1, 0xe0), ==, 0x4422);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe3), ==, 0x88);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe2), ==, 0x66);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe1), ==, 0x44);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe0), ==, 0x22);",
"isa_outb(VAR_1, 0xe3, 0x87);",
"g_assert_cmphex(isa_inl(VAR_1, 0xe0), ==, 0x87664422);",
"g_assert_cmphex(isa_inw(VAR_1, 0xe2), ==, 0x8766);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe3), ==, 0x87);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe2), ==, 0x66);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe1), ==, 0x44);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe0), ==, 0x22);",
"isa_outb(VAR_1, 0xe2, 0x65);",
"g_assert_cmphex(isa_inl(VAR_1, 0xe0), ==, 0x87654422);",
"g_assert_cmphex(isa_inw(VAR_1, 0xe2), ==, 0x8765);",
"g_assert_cmphex(isa_inw(VAR_1, 0xe0), ==, 0x4422);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe3), ==, 0x87);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe2), ==, 0x65);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe1), ==, 0x44);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe0), ==, 0x22);",
"isa_outb(VAR_1, 0xe1, 0x43);",
"g_assert_cmphex(isa_inl(VAR_1, 0xe0), ==, 0x87654322);",
"g_assert_cmphex(isa_inw(VAR_1, 0xe2), ==, 0x8765);",
"g_assert_cmphex(isa_inw(VAR_1, 0xe0), ==, 0x4322);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe3), ==, 0x87);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe2), ==, 0x65);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe1), ==, 0x43);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe0), ==, 0x22);",
"isa_outb(VAR_1, 0xe0, 0x21);",
"g_assert_cmphex(isa_inl(VAR_1, 0xe0), ==, 0x87654321);",
"g_assert_cmphex(isa_inw(VAR_1, 0xe2), ==, 0x8765);",
"g_assert_cmphex(isa_inw(VAR_1, 0xe0), ==, 0x4321);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe3), ==, 0x87);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe2), ==, 0x65);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe1), ==, 0x43);",
"g_assert_cmphex(isa_inb(VAR_1, 0xe0), ==, 0x21);",
"qtest_quit(global_qtest);",
"g_free(VAR_2);",
"}"
]
| [
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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11,
13,
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
]
]
|
14,381 | float32 HELPER(ucf64_negs)(float32 a)
{
return float32_chs(a);
}
| false | qemu | e8ede0a8bb5298a6979bcf7ed84ef64a64a4e3fe | float32 HELPER(ucf64_negs)(float32 a)
{
return float32_chs(a);
}
| {
"code": [],
"line_no": []
} | float32 FUNC_0(ucf64_negs)(float32 a)
{
return float32_chs(a);
}
| [
"float32 FUNC_0(ucf64_negs)(float32 a)\n{",
"return float32_chs(a);",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
14,382 | static void *rcu_read_perf_test(void *arg)
{
int i;
long long n_reads_local = 0;
rcu_register_thread();
*(struct rcu_reader_data **)arg = &rcu_reader;
atomic_inc(&nthreadsrunning);
while (goflag == GOFLAG_INIT) {
g_usleep(1000);
}
while (goflag == GOFLAG_RUN) {
for (i = 0; i < RCU_READ_RUN; i++) {
rcu_read_lock();
rcu_read_unlock();
}
n_reads_local += RCU_READ_RUN;
}
atomic_add(&n_reads, n_reads_local);
rcu_unregister_thread();
return NULL;
}
| false | qemu | 8a5956ad6392f115521dad774055c737c49fb0dd | static void *rcu_read_perf_test(void *arg)
{
int i;
long long n_reads_local = 0;
rcu_register_thread();
*(struct rcu_reader_data **)arg = &rcu_reader;
atomic_inc(&nthreadsrunning);
while (goflag == GOFLAG_INIT) {
g_usleep(1000);
}
while (goflag == GOFLAG_RUN) {
for (i = 0; i < RCU_READ_RUN; i++) {
rcu_read_lock();
rcu_read_unlock();
}
n_reads_local += RCU_READ_RUN;
}
atomic_add(&n_reads, n_reads_local);
rcu_unregister_thread();
return NULL;
}
| {
"code": [],
"line_no": []
} | static void *FUNC_0(void *VAR_0)
{
int VAR_1;
long long VAR_2 = 0;
rcu_register_thread();
*(struct rcu_reader_data **)VAR_0 = &rcu_reader;
atomic_inc(&nthreadsrunning);
while (goflag == GOFLAG_INIT) {
g_usleep(1000);
}
while (goflag == GOFLAG_RUN) {
for (VAR_1 = 0; VAR_1 < RCU_READ_RUN; VAR_1++) {
rcu_read_lock();
rcu_read_unlock();
}
VAR_2 += RCU_READ_RUN;
}
atomic_add(&n_reads, VAR_2);
rcu_unregister_thread();
return NULL;
}
| [
"static void *FUNC_0(void *VAR_0)\n{",
"int VAR_1;",
"long long VAR_2 = 0;",
"rcu_register_thread();",
"*(struct rcu_reader_data **)VAR_0 = &rcu_reader;",
"atomic_inc(&nthreadsrunning);",
"while (goflag == GOFLAG_INIT) {",
"g_usleep(1000);",
"}",
"while (goflag == GOFLAG_RUN) {",
"for (VAR_1 = 0; VAR_1 < RCU_READ_RUN; VAR_1++) {",
"rcu_read_lock();",
"rcu_read_unlock();",
"}",
"VAR_2 += RCU_READ_RUN;",
"}",
"atomic_add(&n_reads, VAR_2);",
"rcu_unregister_thread();",
"return NULL;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
]
]
|
14,383 | static inline int coeff_unpack_golomb(GetBitContext *gb, int qfactor, int qoffset)
{
int sign, coeff;
uint32_t buf;
OPEN_READER(re, gb);
UPDATE_CACHE(re, gb);
buf = GET_CACHE(re, gb);
if (buf & 0xAA800000) {
buf >>= 32 - 8;
SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]);
coeff = ff_interleaved_ue_golomb_vlc_code[buf];
} else {
unsigned ret = 1;
do {
buf >>= 32 - 8;
SKIP_BITS(re, gb,
FFMIN(ff_interleaved_golomb_vlc_len[buf], 8));
if (ff_interleaved_golomb_vlc_len[buf] != 9) {
ret <<= (ff_interleaved_golomb_vlc_len[buf] - 1) >> 1;
ret |= ff_interleaved_dirac_golomb_vlc_code[buf];
break;
}
ret = (ret << 4) | ff_interleaved_dirac_golomb_vlc_code[buf];
UPDATE_CACHE(re, gb);
buf = GET_CACHE(re, gb);
} while (ret<0x8000000U && BITS_AVAILABLE(re, gb));
coeff = ret - 1;
}
if (coeff) {
coeff = (coeff * qfactor + qoffset + 2) >> 2;
sign = SHOW_SBITS(re, gb, 1);
LAST_SKIP_BITS(re, gb, 1);
coeff = (coeff ^ sign) - sign;
}
CLOSE_READER(re, gb);
return coeff;
}
| false | FFmpeg | bbd977162590db4b29a5532e3e7102e054ff3ae0 | static inline int coeff_unpack_golomb(GetBitContext *gb, int qfactor, int qoffset)
{
int sign, coeff;
uint32_t buf;
OPEN_READER(re, gb);
UPDATE_CACHE(re, gb);
buf = GET_CACHE(re, gb);
if (buf & 0xAA800000) {
buf >>= 32 - 8;
SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]);
coeff = ff_interleaved_ue_golomb_vlc_code[buf];
} else {
unsigned ret = 1;
do {
buf >>= 32 - 8;
SKIP_BITS(re, gb,
FFMIN(ff_interleaved_golomb_vlc_len[buf], 8));
if (ff_interleaved_golomb_vlc_len[buf] != 9) {
ret <<= (ff_interleaved_golomb_vlc_len[buf] - 1) >> 1;
ret |= ff_interleaved_dirac_golomb_vlc_code[buf];
break;
}
ret = (ret << 4) | ff_interleaved_dirac_golomb_vlc_code[buf];
UPDATE_CACHE(re, gb);
buf = GET_CACHE(re, gb);
} while (ret<0x8000000U && BITS_AVAILABLE(re, gb));
coeff = ret - 1;
}
if (coeff) {
coeff = (coeff * qfactor + qoffset + 2) >> 2;
sign = SHOW_SBITS(re, gb, 1);
LAST_SKIP_BITS(re, gb, 1);
coeff = (coeff ^ sign) - sign;
}
CLOSE_READER(re, gb);
return coeff;
}
| {
"code": [],
"line_no": []
} | static inline int FUNC_0(GetBitContext *VAR_0, int VAR_1, int VAR_2)
{
int VAR_3, VAR_4;
uint32_t buf;
OPEN_READER(re, VAR_0);
UPDATE_CACHE(re, VAR_0);
buf = GET_CACHE(re, VAR_0);
if (buf & 0xAA800000) {
buf >>= 32 - 8;
SKIP_BITS(re, VAR_0, ff_interleaved_golomb_vlc_len[buf]);
VAR_4 = ff_interleaved_ue_golomb_vlc_code[buf];
} else {
unsigned VAR_5 = 1;
do {
buf >>= 32 - 8;
SKIP_BITS(re, VAR_0,
FFMIN(ff_interleaved_golomb_vlc_len[buf], 8));
if (ff_interleaved_golomb_vlc_len[buf] != 9) {
VAR_5 <<= (ff_interleaved_golomb_vlc_len[buf] - 1) >> 1;
VAR_5 |= ff_interleaved_dirac_golomb_vlc_code[buf];
break;
}
VAR_5 = (VAR_5 << 4) | ff_interleaved_dirac_golomb_vlc_code[buf];
UPDATE_CACHE(re, VAR_0);
buf = GET_CACHE(re, VAR_0);
} while (VAR_5<0x8000000U && BITS_AVAILABLE(re, VAR_0));
VAR_4 = VAR_5 - 1;
}
if (VAR_4) {
VAR_4 = (VAR_4 * VAR_1 + VAR_2 + 2) >> 2;
VAR_3 = SHOW_SBITS(re, VAR_0, 1);
LAST_SKIP_BITS(re, VAR_0, 1);
VAR_4 = (VAR_4 ^ VAR_3) - VAR_3;
}
CLOSE_READER(re, VAR_0);
return VAR_4;
}
| [
"static inline int FUNC_0(GetBitContext *VAR_0, int VAR_1, int VAR_2)\n{",
"int VAR_3, VAR_4;",
"uint32_t buf;",
"OPEN_READER(re, VAR_0);",
"UPDATE_CACHE(re, VAR_0);",
"buf = GET_CACHE(re, VAR_0);",
"if (buf & 0xAA800000) {",
"buf >>= 32 - 8;",
"SKIP_BITS(re, VAR_0, ff_interleaved_golomb_vlc_len[buf]);",
"VAR_4 = ff_interleaved_ue_golomb_vlc_code[buf];",
"} else {",
"unsigned VAR_5 = 1;",
"do {",
"buf >>= 32 - 8;",
"SKIP_BITS(re, VAR_0,\nFFMIN(ff_interleaved_golomb_vlc_len[buf], 8));",
"if (ff_interleaved_golomb_vlc_len[buf] != 9) {",
"VAR_5 <<= (ff_interleaved_golomb_vlc_len[buf] - 1) >> 1;",
"VAR_5 |= ff_interleaved_dirac_golomb_vlc_code[buf];",
"break;",
"}",
"VAR_5 = (VAR_5 << 4) | ff_interleaved_dirac_golomb_vlc_code[buf];",
"UPDATE_CACHE(re, VAR_0);",
"buf = GET_CACHE(re, VAR_0);",
"} while (VAR_5<0x8000000U && BITS_AVAILABLE(re, VAR_0));",
"VAR_4 = VAR_5 - 1;",
"}",
"if (VAR_4) {",
"VAR_4 = (VAR_4 * VAR_1 + VAR_2 + 2) >> 2;",
"VAR_3 = SHOW_SBITS(re, VAR_0, 1);",
"LAST_SKIP_BITS(re, VAR_0, 1);",
"VAR_4 = (VAR_4 ^ VAR_3) - VAR_3;",
"}",
"CLOSE_READER(re, VAR_0);",
"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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39,
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
]
]
|
14,384 | static CharDriverState *qemu_chr_open_tcp(const char *host_str,
int is_telnet,
int is_unix)
{
CharDriverState *chr = NULL;
TCPCharDriver *s = NULL;
int fd = -1, ret, err, val;
int is_listen = 0;
int is_waitconnect = 1;
int do_nodelay = 0;
const char *ptr;
struct sockaddr_in saddr;
#ifndef _WIN32
struct sockaddr_un uaddr;
#endif
struct sockaddr *addr;
socklen_t addrlen;
#ifndef _WIN32
if (is_unix) {
addr = (struct sockaddr *)&uaddr;
addrlen = sizeof(uaddr);
if (parse_unix_path(&uaddr, host_str) < 0)
goto fail;
} else
#endif
{
addr = (struct sockaddr *)&saddr;
addrlen = sizeof(saddr);
if (parse_host_port(&saddr, host_str) < 0)
goto fail;
}
ptr = host_str;
while((ptr = strchr(ptr,','))) {
ptr++;
if (!strncmp(ptr,"server",6)) {
is_listen = 1;
} else if (!strncmp(ptr,"nowait",6)) {
is_waitconnect = 0;
} else if (!strncmp(ptr,"nodelay",6)) {
do_nodelay = 1;
} else {
printf("Unknown option: %s\n", ptr);
goto fail;
}
}
if (!is_listen)
is_waitconnect = 0;
chr = qemu_mallocz(sizeof(CharDriverState));
if (!chr)
goto fail;
s = qemu_mallocz(sizeof(TCPCharDriver));
if (!s)
goto fail;
#ifndef _WIN32
if (is_unix)
fd = socket(PF_UNIX, SOCK_STREAM, 0);
else
#endif
fd = socket(PF_INET, SOCK_STREAM, 0);
if (fd < 0)
goto fail;
if (!is_waitconnect)
socket_set_nonblock(fd);
s->connected = 0;
s->fd = -1;
s->listen_fd = -1;
s->is_unix = is_unix;
s->do_nodelay = do_nodelay && !is_unix;
chr->opaque = s;
chr->chr_write = tcp_chr_write;
chr->chr_close = tcp_chr_close;
if (is_listen) {
/* allow fast reuse */
#ifndef _WIN32
if (is_unix) {
char path[109];
pstrcpy(path, sizeof(path), uaddr.sun_path);
unlink(path);
} else
#endif
{
val = 1;
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char *)&val, sizeof(val));
}
ret = bind(fd, addr, addrlen);
if (ret < 0)
goto fail;
ret = listen(fd, 0);
if (ret < 0)
goto fail;
s->listen_fd = fd;
qemu_set_fd_handler(s->listen_fd, tcp_chr_accept, NULL, chr);
if (is_telnet)
s->do_telnetopt = 1;
} else {
for(;;) {
ret = connect(fd, addr, addrlen);
if (ret < 0) {
err = socket_error();
if (err == EINTR || err == EWOULDBLOCK) {
} else if (err == EINPROGRESS) {
break;
#ifdef _WIN32
} else if (err == WSAEALREADY) {
break;
#endif
} else {
goto fail;
}
} else {
s->connected = 1;
break;
}
}
s->fd = fd;
socket_set_nodelay(fd);
if (s->connected)
tcp_chr_connect(chr);
else
qemu_set_fd_handler(s->fd, NULL, tcp_chr_connect, chr);
}
if (is_listen && is_waitconnect) {
printf("QEMU waiting for connection on: %s\n", host_str);
tcp_chr_accept(chr);
socket_set_nonblock(s->listen_fd);
}
return chr;
fail:
if (fd >= 0)
closesocket(fd);
qemu_free(s);
qemu_free(chr);
return NULL;
}
| false | qemu | f07b6003b6cebaa5404d702ad8aca181580e4d6c | static CharDriverState *qemu_chr_open_tcp(const char *host_str,
int is_telnet,
int is_unix)
{
CharDriverState *chr = NULL;
TCPCharDriver *s = NULL;
int fd = -1, ret, err, val;
int is_listen = 0;
int is_waitconnect = 1;
int do_nodelay = 0;
const char *ptr;
struct sockaddr_in saddr;
#ifndef _WIN32
struct sockaddr_un uaddr;
#endif
struct sockaddr *addr;
socklen_t addrlen;
#ifndef _WIN32
if (is_unix) {
addr = (struct sockaddr *)&uaddr;
addrlen = sizeof(uaddr);
if (parse_unix_path(&uaddr, host_str) < 0)
goto fail;
} else
#endif
{
addr = (struct sockaddr *)&saddr;
addrlen = sizeof(saddr);
if (parse_host_port(&saddr, host_str) < 0)
goto fail;
}
ptr = host_str;
while((ptr = strchr(ptr,','))) {
ptr++;
if (!strncmp(ptr,"server",6)) {
is_listen = 1;
} else if (!strncmp(ptr,"nowait",6)) {
is_waitconnect = 0;
} else if (!strncmp(ptr,"nodelay",6)) {
do_nodelay = 1;
} else {
printf("Unknown option: %s\n", ptr);
goto fail;
}
}
if (!is_listen)
is_waitconnect = 0;
chr = qemu_mallocz(sizeof(CharDriverState));
if (!chr)
goto fail;
s = qemu_mallocz(sizeof(TCPCharDriver));
if (!s)
goto fail;
#ifndef _WIN32
if (is_unix)
fd = socket(PF_UNIX, SOCK_STREAM, 0);
else
#endif
fd = socket(PF_INET, SOCK_STREAM, 0);
if (fd < 0)
goto fail;
if (!is_waitconnect)
socket_set_nonblock(fd);
s->connected = 0;
s->fd = -1;
s->listen_fd = -1;
s->is_unix = is_unix;
s->do_nodelay = do_nodelay && !is_unix;
chr->opaque = s;
chr->chr_write = tcp_chr_write;
chr->chr_close = tcp_chr_close;
if (is_listen) {
#ifndef _WIN32
if (is_unix) {
char path[109];
pstrcpy(path, sizeof(path), uaddr.sun_path);
unlink(path);
} else
#endif
{
val = 1;
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char *)&val, sizeof(val));
}
ret = bind(fd, addr, addrlen);
if (ret < 0)
goto fail;
ret = listen(fd, 0);
if (ret < 0)
goto fail;
s->listen_fd = fd;
qemu_set_fd_handler(s->listen_fd, tcp_chr_accept, NULL, chr);
if (is_telnet)
s->do_telnetopt = 1;
} else {
for(;;) {
ret = connect(fd, addr, addrlen);
if (ret < 0) {
err = socket_error();
if (err == EINTR || err == EWOULDBLOCK) {
} else if (err == EINPROGRESS) {
break;
#ifdef _WIN32
} else if (err == WSAEALREADY) {
break;
#endif
} else {
goto fail;
}
} else {
s->connected = 1;
break;
}
}
s->fd = fd;
socket_set_nodelay(fd);
if (s->connected)
tcp_chr_connect(chr);
else
qemu_set_fd_handler(s->fd, NULL, tcp_chr_connect, chr);
}
if (is_listen && is_waitconnect) {
printf("QEMU waiting for connection on: %s\n", host_str);
tcp_chr_accept(chr);
socket_set_nonblock(s->listen_fd);
}
return chr;
fail:
if (fd >= 0)
closesocket(fd);
qemu_free(s);
qemu_free(chr);
return NULL;
}
| {
"code": [],
"line_no": []
} | static CharDriverState *FUNC_0(const char *host_str,
int is_telnet,
int is_unix)
{
CharDriverState *chr = NULL;
TCPCharDriver *s = NULL;
int VAR_0 = -1, VAR_1, VAR_2, VAR_3;
int VAR_4 = 0;
int VAR_5 = 1;
int VAR_6 = 0;
const char *VAR_7;
struct sockaddr_in VAR_8;
#ifndef _WIN32
struct sockaddr_un VAR_9;
#endif
struct sockaddr *VAR_10;
socklen_t addrlen;
#ifndef _WIN32
if (is_unix) {
VAR_10 = (struct sockaddr *)&VAR_9;
addrlen = sizeof(VAR_9);
if (parse_unix_path(&VAR_9, host_str) < 0)
goto fail;
} else
#endif
{
VAR_10 = (struct sockaddr *)&VAR_8;
addrlen = sizeof(VAR_8);
if (parse_host_port(&VAR_8, host_str) < 0)
goto fail;
}
VAR_7 = host_str;
while((VAR_7 = strchr(VAR_7,','))) {
VAR_7++;
if (!strncmp(VAR_7,"server",6)) {
VAR_4 = 1;
} else if (!strncmp(VAR_7,"nowait",6)) {
VAR_5 = 0;
} else if (!strncmp(VAR_7,"nodelay",6)) {
VAR_6 = 1;
} else {
printf("Unknown option: %s\n", VAR_7);
goto fail;
}
}
if (!VAR_4)
VAR_5 = 0;
chr = qemu_mallocz(sizeof(CharDriverState));
if (!chr)
goto fail;
s = qemu_mallocz(sizeof(TCPCharDriver));
if (!s)
goto fail;
#ifndef _WIN32
if (is_unix)
VAR_0 = socket(PF_UNIX, SOCK_STREAM, 0);
else
#endif
VAR_0 = socket(PF_INET, SOCK_STREAM, 0);
if (VAR_0 < 0)
goto fail;
if (!VAR_5)
socket_set_nonblock(VAR_0);
s->connected = 0;
s->VAR_0 = -1;
s->listen_fd = -1;
s->is_unix = is_unix;
s->VAR_6 = VAR_6 && !is_unix;
chr->opaque = s;
chr->chr_write = tcp_chr_write;
chr->chr_close = tcp_chr_close;
if (VAR_4) {
#ifndef _WIN32
if (is_unix) {
char VAR_11[109];
pstrcpy(VAR_11, sizeof(VAR_11), VAR_9.sun_path);
unlink(VAR_11);
} else
#endif
{
VAR_3 = 1;
setsockopt(VAR_0, SOL_SOCKET, SO_REUSEADDR, (const char *)&VAR_3, sizeof(VAR_3));
}
VAR_1 = bind(VAR_0, VAR_10, addrlen);
if (VAR_1 < 0)
goto fail;
VAR_1 = listen(VAR_0, 0);
if (VAR_1 < 0)
goto fail;
s->listen_fd = VAR_0;
qemu_set_fd_handler(s->listen_fd, tcp_chr_accept, NULL, chr);
if (is_telnet)
s->do_telnetopt = 1;
} else {
for(;;) {
VAR_1 = connect(VAR_0, VAR_10, addrlen);
if (VAR_1 < 0) {
VAR_2 = socket_error();
if (VAR_2 == EINTR || VAR_2 == EWOULDBLOCK) {
} else if (VAR_2 == EINPROGRESS) {
break;
#ifdef _WIN32
} else if (VAR_2 == WSAEALREADY) {
break;
#endif
} else {
goto fail;
}
} else {
s->connected = 1;
break;
}
}
s->VAR_0 = VAR_0;
socket_set_nodelay(VAR_0);
if (s->connected)
tcp_chr_connect(chr);
else
qemu_set_fd_handler(s->VAR_0, NULL, tcp_chr_connect, chr);
}
if (VAR_4 && VAR_5) {
printf("QEMU waiting for connection on: %s\n", host_str);
tcp_chr_accept(chr);
socket_set_nonblock(s->listen_fd);
}
return chr;
fail:
if (VAR_0 >= 0)
closesocket(VAR_0);
qemu_free(s);
qemu_free(chr);
return NULL;
}
| [
"static CharDriverState *FUNC_0(const char *host_str,\nint is_telnet,\nint is_unix)\n{",
"CharDriverState *chr = NULL;",
"TCPCharDriver *s = NULL;",
"int VAR_0 = -1, VAR_1, VAR_2, VAR_3;",
"int VAR_4 = 0;",
"int VAR_5 = 1;",
"int VAR_6 = 0;",
"const char *VAR_7;",
"struct sockaddr_in VAR_8;",
"#ifndef _WIN32\nstruct sockaddr_un VAR_9;",
"#endif\nstruct sockaddr *VAR_10;",
"socklen_t addrlen;",
"#ifndef _WIN32\nif (is_unix) {",
"VAR_10 = (struct sockaddr *)&VAR_9;",
"addrlen = sizeof(VAR_9);",
"if (parse_unix_path(&VAR_9, host_str) < 0)\ngoto fail;",
"} else",
"#endif\n{",
"VAR_10 = (struct sockaddr *)&VAR_8;",
"addrlen = sizeof(VAR_8);",
"if (parse_host_port(&VAR_8, host_str) < 0)\ngoto fail;",
"}",
"VAR_7 = host_str;",
"while((VAR_7 = strchr(VAR_7,','))) {",
"VAR_7++;",
"if (!strncmp(VAR_7,\"server\",6)) {",
"VAR_4 = 1;",
"} else if (!strncmp(VAR_7,\"nowait\",6)) {",
"VAR_5 = 0;",
"} else if (!strncmp(VAR_7,\"nodelay\",6)) {",
"VAR_6 = 1;",
"} else {",
"printf(\"Unknown option: %s\\n\", VAR_7);",
"goto fail;",
"}",
"}",
"if (!VAR_4)\nVAR_5 = 0;",
"chr = qemu_mallocz(sizeof(CharDriverState));",
"if (!chr)\ngoto fail;",
"s = qemu_mallocz(sizeof(TCPCharDriver));",
"if (!s)\ngoto fail;",
"#ifndef _WIN32\nif (is_unix)\nVAR_0 = socket(PF_UNIX, SOCK_STREAM, 0);",
"else\n#endif\nVAR_0 = socket(PF_INET, SOCK_STREAM, 0);",
"if (VAR_0 < 0)\ngoto fail;",
"if (!VAR_5)\nsocket_set_nonblock(VAR_0);",
"s->connected = 0;",
"s->VAR_0 = -1;",
"s->listen_fd = -1;",
"s->is_unix = is_unix;",
"s->VAR_6 = VAR_6 && !is_unix;",
"chr->opaque = s;",
"chr->chr_write = tcp_chr_write;",
"chr->chr_close = tcp_chr_close;",
"if (VAR_4) {",
"#ifndef _WIN32\nif (is_unix) {",
"char VAR_11[109];",
"pstrcpy(VAR_11, sizeof(VAR_11), VAR_9.sun_path);",
"unlink(VAR_11);",
"} else",
"#endif\n{",
"VAR_3 = 1;",
"setsockopt(VAR_0, SOL_SOCKET, SO_REUSEADDR, (const char *)&VAR_3, sizeof(VAR_3));",
"}",
"VAR_1 = bind(VAR_0, VAR_10, addrlen);",
"if (VAR_1 < 0)\ngoto fail;",
"VAR_1 = listen(VAR_0, 0);",
"if (VAR_1 < 0)\ngoto fail;",
"s->listen_fd = VAR_0;",
"qemu_set_fd_handler(s->listen_fd, tcp_chr_accept, NULL, chr);",
"if (is_telnet)\ns->do_telnetopt = 1;",
"} else {",
"for(;;) {",
"VAR_1 = connect(VAR_0, VAR_10, addrlen);",
"if (VAR_1 < 0) {",
"VAR_2 = socket_error();",
"if (VAR_2 == EINTR || VAR_2 == EWOULDBLOCK) {",
"} else if (VAR_2 == EINPROGRESS) {",
"break;",
"#ifdef _WIN32\n} else if (VAR_2 == WSAEALREADY) {",
"break;",
"#endif\n} else {",
"goto fail;",
"}",
"} else {",
"s->connected = 1;",
"break;",
"}",
"}",
"s->VAR_0 = VAR_0;",
"socket_set_nodelay(VAR_0);",
"if (s->connected)\ntcp_chr_connect(chr);",
"else\nqemu_set_fd_handler(s->VAR_0, NULL, tcp_chr_connect, chr);",
"}",
"if (VAR_4 && VAR_5) {",
"printf(\"QEMU waiting for connection on: %s\\n\", host_str);",
"tcp_chr_accept(chr);",
"socket_set_nonblock(s->listen_fd);",
"}",
"return chr;",
"fail:\nif (VAR_0 >= 0)\nclosesocket(VAR_0);",
"qemu_free(s);",
"qemu_free(chr);",
"return NULL;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29,
31
],
[
33
],
[
37,
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95,
97
],
[
101
],
[
103,
105
],
[
107
],
[
109,
111
],
[
115,
117,
119
],
[
121,
123,
125
],
[
129,
131
],
[
135,
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
161
],
[
165,
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177,
179
],
[
181
],
[
183
],
[
185
],
[
189
],
[
191,
193
],
[
197
],
[
199,
201
],
[
205
],
[
207
],
[
209,
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229,
231
],
[
233
],
[
235,
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257,
259
],
[
261,
263
],
[
265
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
281
],
[
283,
285,
287
],
[
289
],
[
291
],
[
293
],
[
295
]
]
|
14,385 | void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
const ARMCPRegInfo *r, void *opaque)
{
/* Define implementations of coprocessor registers.
* We store these in a hashtable because typically
* there are less than 150 registers in a space which
* is 16*16*16*8*8 = 262144 in size.
* Wildcarding is supported for the crm, opc1 and opc2 fields.
* If a register is defined twice then the second definition is
* used, so this can be used to define some generic registers and
* then override them with implementation specific variations.
* At least one of the original and the second definition should
* include ARM_CP_OVERRIDE in its type bits -- this is just a guard
* against accidental use.
*/
int crm, opc1, opc2;
int crmmin = (r->crm == CP_ANY) ? 0 : r->crm;
int crmmax = (r->crm == CP_ANY) ? 15 : r->crm;
int opc1min = (r->opc1 == CP_ANY) ? 0 : r->opc1;
int opc1max = (r->opc1 == CP_ANY) ? 7 : r->opc1;
int opc2min = (r->opc2 == CP_ANY) ? 0 : r->opc2;
int opc2max = (r->opc2 == CP_ANY) ? 7 : r->opc2;
/* 64 bit registers have only CRm and Opc1 fields */
assert(!((r->type & ARM_CP_64BIT) && (r->opc2 || r->crn)));
/* Check that the register definition has enough info to handle
* reads and writes if they are permitted.
*/
if (!(r->type & (ARM_CP_SPECIAL|ARM_CP_CONST))) {
if (r->access & PL3_R) {
assert(r->fieldoffset || r->readfn);
}
if (r->access & PL3_W) {
assert(r->fieldoffset || r->writefn);
}
}
/* Bad type field probably means missing sentinel at end of reg list */
assert(cptype_valid(r->type));
for (crm = crmmin; crm <= crmmax; crm++) {
for (opc1 = opc1min; opc1 <= opc1max; opc1++) {
for (opc2 = opc2min; opc2 <= opc2max; opc2++) {
uint32_t *key = g_new(uint32_t, 1);
ARMCPRegInfo *r2 = g_memdup(r, sizeof(ARMCPRegInfo));
int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0;
*key = ENCODE_CP_REG(r->cp, is64, r->crn, crm, opc1, opc2);
if (opaque) {
r2->opaque = opaque;
}
/* Make sure reginfo passed to helpers for wildcarded regs
* has the correct crm/opc1/opc2 for this reg, not CP_ANY:
*/
r2->crm = crm;
r2->opc1 = opc1;
r2->opc2 = opc2;
/* By convention, for wildcarded registers only the first
* entry is used for migration; the others are marked as
* NO_MIGRATE so we don't try to transfer the register
* multiple times. Special registers (ie NOP/WFI) are
* never migratable.
*/
if ((r->type & ARM_CP_SPECIAL) ||
((r->crm == CP_ANY) && crm != 0) ||
((r->opc1 == CP_ANY) && opc1 != 0) ||
((r->opc2 == CP_ANY) && opc2 != 0)) {
r2->type |= ARM_CP_NO_MIGRATE;
}
/* Overriding of an existing definition must be explicitly
* requested.
*/
if (!(r->type & ARM_CP_OVERRIDE)) {
ARMCPRegInfo *oldreg;
oldreg = g_hash_table_lookup(cpu->cp_regs, key);
if (oldreg && !(oldreg->type & ARM_CP_OVERRIDE)) {
fprintf(stderr, "Register redefined: cp=%d %d bit "
"crn=%d crm=%d opc1=%d opc2=%d, "
"was %s, now %s\n", r2->cp, 32 + 32 * is64,
r2->crn, r2->crm, r2->opc1, r2->opc2,
oldreg->name, r2->name);
g_assert_not_reached();
}
}
g_hash_table_insert(cpu->cp_regs, key, r2);
}
}
}
}
| false | qemu | 6e6efd612f58726189893fd4d948b7fc10acd872 | void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
const ARMCPRegInfo *r, void *opaque)
{
int crm, opc1, opc2;
int crmmin = (r->crm == CP_ANY) ? 0 : r->crm;
int crmmax = (r->crm == CP_ANY) ? 15 : r->crm;
int opc1min = (r->opc1 == CP_ANY) ? 0 : r->opc1;
int opc1max = (r->opc1 == CP_ANY) ? 7 : r->opc1;
int opc2min = (r->opc2 == CP_ANY) ? 0 : r->opc2;
int opc2max = (r->opc2 == CP_ANY) ? 7 : r->opc2;
assert(!((r->type & ARM_CP_64BIT) && (r->opc2 || r->crn)));
if (!(r->type & (ARM_CP_SPECIAL|ARM_CP_CONST))) {
if (r->access & PL3_R) {
assert(r->fieldoffset || r->readfn);
}
if (r->access & PL3_W) {
assert(r->fieldoffset || r->writefn);
}
}
assert(cptype_valid(r->type));
for (crm = crmmin; crm <= crmmax; crm++) {
for (opc1 = opc1min; opc1 <= opc1max; opc1++) {
for (opc2 = opc2min; opc2 <= opc2max; opc2++) {
uint32_t *key = g_new(uint32_t, 1);
ARMCPRegInfo *r2 = g_memdup(r, sizeof(ARMCPRegInfo));
int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0;
*key = ENCODE_CP_REG(r->cp, is64, r->crn, crm, opc1, opc2);
if (opaque) {
r2->opaque = opaque;
}
r2->crm = crm;
r2->opc1 = opc1;
r2->opc2 = opc2;
if ((r->type & ARM_CP_SPECIAL) ||
((r->crm == CP_ANY) && crm != 0) ||
((r->opc1 == CP_ANY) && opc1 != 0) ||
((r->opc2 == CP_ANY) && opc2 != 0)) {
r2->type |= ARM_CP_NO_MIGRATE;
}
if (!(r->type & ARM_CP_OVERRIDE)) {
ARMCPRegInfo *oldreg;
oldreg = g_hash_table_lookup(cpu->cp_regs, key);
if (oldreg && !(oldreg->type & ARM_CP_OVERRIDE)) {
fprintf(stderr, "Register redefined: cp=%d %d bit "
"crn=%d crm=%d opc1=%d opc2=%d, "
"was %s, now %s\n", r2->cp, 32 + 32 * is64,
r2->crn, r2->crm, r2->opc1, r2->opc2,
oldreg->name, r2->name);
g_assert_not_reached();
}
}
g_hash_table_insert(cpu->cp_regs, key, r2);
}
}
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(ARMCPU *VAR_0,
const ARMCPRegInfo *VAR_1, void *VAR_2)
{
int VAR_3, VAR_4, VAR_5;
int VAR_6 = (VAR_1->VAR_3 == CP_ANY) ? 0 : VAR_1->VAR_3;
int VAR_7 = (VAR_1->VAR_3 == CP_ANY) ? 15 : VAR_1->VAR_3;
int VAR_8 = (VAR_1->VAR_4 == CP_ANY) ? 0 : VAR_1->VAR_4;
int VAR_9 = (VAR_1->VAR_4 == CP_ANY) ? 7 : VAR_1->VAR_4;
int VAR_10 = (VAR_1->VAR_5 == CP_ANY) ? 0 : VAR_1->VAR_5;
int VAR_11 = (VAR_1->VAR_5 == CP_ANY) ? 7 : VAR_1->VAR_5;
assert(!((VAR_1->type & ARM_CP_64BIT) && (VAR_1->VAR_5 || VAR_1->crn)));
if (!(VAR_1->type & (ARM_CP_SPECIAL|ARM_CP_CONST))) {
if (VAR_1->access & PL3_R) {
assert(VAR_1->fieldoffset || VAR_1->readfn);
}
if (VAR_1->access & PL3_W) {
assert(VAR_1->fieldoffset || VAR_1->writefn);
}
}
assert(cptype_valid(VAR_1->type));
for (VAR_3 = VAR_6; VAR_3 <= VAR_7; VAR_3++) {
for (VAR_4 = VAR_8; VAR_4 <= VAR_9; VAR_4++) {
for (VAR_5 = VAR_10; VAR_5 <= VAR_11; VAR_5++) {
uint32_t *key = g_new(uint32_t, 1);
ARMCPRegInfo *r2 = g_memdup(VAR_1, sizeof(ARMCPRegInfo));
int VAR_12 = (VAR_1->type & ARM_CP_64BIT) ? 1 : 0;
*key = ENCODE_CP_REG(VAR_1->cp, VAR_12, VAR_1->crn, VAR_3, VAR_4, VAR_5);
if (VAR_2) {
r2->VAR_2 = VAR_2;
}
r2->VAR_3 = VAR_3;
r2->VAR_4 = VAR_4;
r2->VAR_5 = VAR_5;
if ((VAR_1->type & ARM_CP_SPECIAL) ||
((VAR_1->VAR_3 == CP_ANY) && VAR_3 != 0) ||
((VAR_1->VAR_4 == CP_ANY) && VAR_4 != 0) ||
((VAR_1->VAR_5 == CP_ANY) && VAR_5 != 0)) {
r2->type |= ARM_CP_NO_MIGRATE;
}
if (!(VAR_1->type & ARM_CP_OVERRIDE)) {
ARMCPRegInfo *oldreg;
oldreg = g_hash_table_lookup(VAR_0->cp_regs, key);
if (oldreg && !(oldreg->type & ARM_CP_OVERRIDE)) {
fprintf(stderr, "Register redefined: cp=%d %d bit "
"crn=%d VAR_3=%d VAR_4=%d VAR_5=%d, "
"was %s, now %s\n", r2->cp, 32 + 32 * VAR_12,
r2->crn, r2->VAR_3, r2->VAR_4, r2->VAR_5,
oldreg->name, r2->name);
g_assert_not_reached();
}
}
g_hash_table_insert(VAR_0->cp_regs, key, r2);
}
}
}
}
| [
"void FUNC_0(ARMCPU *VAR_0,\nconst ARMCPRegInfo *VAR_1, void *VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5;",
"int VAR_6 = (VAR_1->VAR_3 == CP_ANY) ? 0 : VAR_1->VAR_3;",
"int VAR_7 = (VAR_1->VAR_3 == CP_ANY) ? 15 : VAR_1->VAR_3;",
"int VAR_8 = (VAR_1->VAR_4 == CP_ANY) ? 0 : VAR_1->VAR_4;",
"int VAR_9 = (VAR_1->VAR_4 == CP_ANY) ? 7 : VAR_1->VAR_4;",
"int VAR_10 = (VAR_1->VAR_5 == CP_ANY) ? 0 : VAR_1->VAR_5;",
"int VAR_11 = (VAR_1->VAR_5 == CP_ANY) ? 7 : VAR_1->VAR_5;",
"assert(!((VAR_1->type & ARM_CP_64BIT) && (VAR_1->VAR_5 || VAR_1->crn)));",
"if (!(VAR_1->type & (ARM_CP_SPECIAL|ARM_CP_CONST))) {",
"if (VAR_1->access & PL3_R) {",
"assert(VAR_1->fieldoffset || VAR_1->readfn);",
"}",
"if (VAR_1->access & PL3_W) {",
"assert(VAR_1->fieldoffset || VAR_1->writefn);",
"}",
"}",
"assert(cptype_valid(VAR_1->type));",
"for (VAR_3 = VAR_6; VAR_3 <= VAR_7; VAR_3++) {",
"for (VAR_4 = VAR_8; VAR_4 <= VAR_9; VAR_4++) {",
"for (VAR_5 = VAR_10; VAR_5 <= VAR_11; VAR_5++) {",
"uint32_t *key = g_new(uint32_t, 1);",
"ARMCPRegInfo *r2 = g_memdup(VAR_1, sizeof(ARMCPRegInfo));",
"int VAR_12 = (VAR_1->type & ARM_CP_64BIT) ? 1 : 0;",
"*key = ENCODE_CP_REG(VAR_1->cp, VAR_12, VAR_1->crn, VAR_3, VAR_4, VAR_5);",
"if (VAR_2) {",
"r2->VAR_2 = VAR_2;",
"}",
"r2->VAR_3 = VAR_3;",
"r2->VAR_4 = VAR_4;",
"r2->VAR_5 = VAR_5;",
"if ((VAR_1->type & ARM_CP_SPECIAL) ||\n((VAR_1->VAR_3 == CP_ANY) && VAR_3 != 0) ||\n((VAR_1->VAR_4 == CP_ANY) && VAR_4 != 0) ||\n((VAR_1->VAR_5 == CP_ANY) && VAR_5 != 0)) {",
"r2->type |= ARM_CP_NO_MIGRATE;",
"}",
"if (!(VAR_1->type & ARM_CP_OVERRIDE)) {",
"ARMCPRegInfo *oldreg;",
"oldreg = g_hash_table_lookup(VAR_0->cp_regs, key);",
"if (oldreg && !(oldreg->type & ARM_CP_OVERRIDE)) {",
"fprintf(stderr, \"Register redefined: cp=%d %d bit \"\n\"crn=%d VAR_3=%d VAR_4=%d VAR_5=%d, \"\n\"was %s, now %s\\n\", r2->cp, 32 + 32 * VAR_12,\nr2->crn, r2->VAR_3, r2->VAR_4, r2->VAR_5,\noldreg->name, r2->name);",
"g_assert_not_reached();",
"}",
"}",
"g_hash_table_insert(VAR_0->cp_regs, key, r2);",
"}",
"}",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
101
],
[
103
],
[
105
],
[
119,
121,
123,
125
],
[
127
],
[
129
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147,
149,
151,
153,
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
]
]
|
14,389 | static void sdhci_sdma_transfer_single_block(SDHCIState *s)
{
int n;
uint32_t datacnt = s->blksize & 0x0fff;
if (s->trnmod & SDHC_TRNS_READ) {
for (n = 0; n < datacnt; n++) {
s->fifo_buffer[n] = sdbus_read_data(&s->sdbus);
}
dma_memory_write(&address_space_memory, s->sdmasysad, s->fifo_buffer,
datacnt);
} else {
dma_memory_read(&address_space_memory, s->sdmasysad, s->fifo_buffer,
datacnt);
for (n = 0; n < datacnt; n++) {
sdbus_write_data(&s->sdbus, s->fifo_buffer[n]);
}
}
if (s->trnmod & SDHC_TRNS_BLK_CNT_EN) {
s->blkcnt--;
}
sdhci_end_transfer(s);
}
| false | qemu | 241999bf4c0dd75d300ceee46f7ad28b3a39fe97 | static void sdhci_sdma_transfer_single_block(SDHCIState *s)
{
int n;
uint32_t datacnt = s->blksize & 0x0fff;
if (s->trnmod & SDHC_TRNS_READ) {
for (n = 0; n < datacnt; n++) {
s->fifo_buffer[n] = sdbus_read_data(&s->sdbus);
}
dma_memory_write(&address_space_memory, s->sdmasysad, s->fifo_buffer,
datacnt);
} else {
dma_memory_read(&address_space_memory, s->sdmasysad, s->fifo_buffer,
datacnt);
for (n = 0; n < datacnt; n++) {
sdbus_write_data(&s->sdbus, s->fifo_buffer[n]);
}
}
if (s->trnmod & SDHC_TRNS_BLK_CNT_EN) {
s->blkcnt--;
}
sdhci_end_transfer(s);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(SDHCIState *VAR_0)
{
int VAR_1;
uint32_t datacnt = VAR_0->blksize & 0x0fff;
if (VAR_0->trnmod & SDHC_TRNS_READ) {
for (VAR_1 = 0; VAR_1 < datacnt; VAR_1++) {
VAR_0->fifo_buffer[VAR_1] = sdbus_read_data(&VAR_0->sdbus);
}
dma_memory_write(&address_space_memory, VAR_0->sdmasysad, VAR_0->fifo_buffer,
datacnt);
} else {
dma_memory_read(&address_space_memory, VAR_0->sdmasysad, VAR_0->fifo_buffer,
datacnt);
for (VAR_1 = 0; VAR_1 < datacnt; VAR_1++) {
sdbus_write_data(&VAR_0->sdbus, VAR_0->fifo_buffer[VAR_1]);
}
}
if (VAR_0->trnmod & SDHC_TRNS_BLK_CNT_EN) {
VAR_0->blkcnt--;
}
sdhci_end_transfer(VAR_0);
}
| [
"static void FUNC_0(SDHCIState *VAR_0)\n{",
"int VAR_1;",
"uint32_t datacnt = VAR_0->blksize & 0x0fff;",
"if (VAR_0->trnmod & SDHC_TRNS_READ) {",
"for (VAR_1 = 0; VAR_1 < datacnt; VAR_1++) {",
"VAR_0->fifo_buffer[VAR_1] = sdbus_read_data(&VAR_0->sdbus);",
"}",
"dma_memory_write(&address_space_memory, VAR_0->sdmasysad, VAR_0->fifo_buffer,\ndatacnt);",
"} else {",
"dma_memory_read(&address_space_memory, VAR_0->sdmasysad, VAR_0->fifo_buffer,\ndatacnt);",
"for (VAR_1 = 0; VAR_1 < datacnt; VAR_1++) {",
"sdbus_write_data(&VAR_0->sdbus, VAR_0->fifo_buffer[VAR_1]);",
"}",
"}",
"if (VAR_0->trnmod & SDHC_TRNS_BLK_CNT_EN) {",
"VAR_0->blkcnt--;",
"}",
"sdhci_end_transfer(VAR_0);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
]
]
|
14,391 | static int tight_compress_data(VncState *vs, int stream_id, size_t bytes,
int level, int strategy)
{
z_streamp zstream = &vs->tight_stream[stream_id];
int previous_out;
if (bytes < VNC_TIGHT_MIN_TO_COMPRESS) {
vnc_write(vs, vs->tight.buffer, vs->tight.offset);
return bytes;
}
if (tight_init_stream(vs, stream_id, level, strategy)) {
return -1;
}
/* reserve memory in output buffer */
buffer_reserve(&vs->tight_zlib, bytes + 64);
/* set pointers */
zstream->next_in = vs->tight.buffer;
zstream->avail_in = vs->tight.offset;
zstream->next_out = vs->tight_zlib.buffer + vs->tight_zlib.offset;
zstream->avail_out = vs->tight_zlib.capacity - vs->tight_zlib.offset;
zstream->data_type = Z_BINARY;
previous_out = zstream->total_out;
/* start encoding */
if (deflate(zstream, Z_SYNC_FLUSH) != Z_OK) {
fprintf(stderr, "VNC: error during tight compression\n");
return -1;
}
vs->tight_zlib.offset = vs->tight_zlib.capacity - zstream->avail_out;
bytes = zstream->total_out - previous_out;
tight_send_compact_size(vs, bytes);
vnc_write(vs, vs->tight_zlib.buffer, bytes);
buffer_reset(&vs->tight_zlib);
return bytes;
}
| false | qemu | 245f7b51c0ea04fb2224b1127430a096c91aee70 | static int tight_compress_data(VncState *vs, int stream_id, size_t bytes,
int level, int strategy)
{
z_streamp zstream = &vs->tight_stream[stream_id];
int previous_out;
if (bytes < VNC_TIGHT_MIN_TO_COMPRESS) {
vnc_write(vs, vs->tight.buffer, vs->tight.offset);
return bytes;
}
if (tight_init_stream(vs, stream_id, level, strategy)) {
return -1;
}
buffer_reserve(&vs->tight_zlib, bytes + 64);
zstream->next_in = vs->tight.buffer;
zstream->avail_in = vs->tight.offset;
zstream->next_out = vs->tight_zlib.buffer + vs->tight_zlib.offset;
zstream->avail_out = vs->tight_zlib.capacity - vs->tight_zlib.offset;
zstream->data_type = Z_BINARY;
previous_out = zstream->total_out;
if (deflate(zstream, Z_SYNC_FLUSH) != Z_OK) {
fprintf(stderr, "VNC: error during tight compression\n");
return -1;
}
vs->tight_zlib.offset = vs->tight_zlib.capacity - zstream->avail_out;
bytes = zstream->total_out - previous_out;
tight_send_compact_size(vs, bytes);
vnc_write(vs, vs->tight_zlib.buffer, bytes);
buffer_reset(&vs->tight_zlib);
return bytes;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(VncState *VAR_0, int VAR_1, size_t VAR_2,
int VAR_3, int VAR_4)
{
z_streamp zstream = &VAR_0->tight_stream[VAR_1];
int VAR_5;
if (VAR_2 < VNC_TIGHT_MIN_TO_COMPRESS) {
vnc_write(VAR_0, VAR_0->tight.buffer, VAR_0->tight.offset);
return VAR_2;
}
if (tight_init_stream(VAR_0, VAR_1, VAR_3, VAR_4)) {
return -1;
}
buffer_reserve(&VAR_0->tight_zlib, VAR_2 + 64);
zstream->next_in = VAR_0->tight.buffer;
zstream->avail_in = VAR_0->tight.offset;
zstream->next_out = VAR_0->tight_zlib.buffer + VAR_0->tight_zlib.offset;
zstream->avail_out = VAR_0->tight_zlib.capacity - VAR_0->tight_zlib.offset;
zstream->data_type = Z_BINARY;
VAR_5 = zstream->total_out;
if (deflate(zstream, Z_SYNC_FLUSH) != Z_OK) {
fprintf(stderr, "VNC: error during tight compression\n");
return -1;
}
VAR_0->tight_zlib.offset = VAR_0->tight_zlib.capacity - zstream->avail_out;
VAR_2 = zstream->total_out - VAR_5;
tight_send_compact_size(VAR_0, VAR_2);
vnc_write(VAR_0, VAR_0->tight_zlib.buffer, VAR_2);
buffer_reset(&VAR_0->tight_zlib);
return VAR_2;
}
| [
"static int FUNC_0(VncState *VAR_0, int VAR_1, size_t VAR_2,\nint VAR_3, int VAR_4)\n{",
"z_streamp zstream = &VAR_0->tight_stream[VAR_1];",
"int VAR_5;",
"if (VAR_2 < VNC_TIGHT_MIN_TO_COMPRESS) {",
"vnc_write(VAR_0, VAR_0->tight.buffer, VAR_0->tight.offset);",
"return VAR_2;",
"}",
"if (tight_init_stream(VAR_0, VAR_1, VAR_3, VAR_4)) {",
"return -1;",
"}",
"buffer_reserve(&VAR_0->tight_zlib, VAR_2 + 64);",
"zstream->next_in = VAR_0->tight.buffer;",
"zstream->avail_in = VAR_0->tight.offset;",
"zstream->next_out = VAR_0->tight_zlib.buffer + VAR_0->tight_zlib.offset;",
"zstream->avail_out = VAR_0->tight_zlib.capacity - VAR_0->tight_zlib.offset;",
"zstream->data_type = Z_BINARY;",
"VAR_5 = zstream->total_out;",
"if (deflate(zstream, Z_SYNC_FLUSH) != Z_OK) {",
"fprintf(stderr, \"VNC: error during tight compression\\n\");",
"return -1;",
"}",
"VAR_0->tight_zlib.offset = VAR_0->tight_zlib.capacity - zstream->avail_out;",
"VAR_2 = zstream->total_out - VAR_5;",
"tight_send_compact_size(VAR_0, VAR_2);",
"vnc_write(VAR_0, VAR_0->tight_zlib.buffer, VAR_2);",
"buffer_reset(&VAR_0->tight_zlib);",
"return VAR_2;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
33
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
71
],
[
73
],
[
77
],
[
81
],
[
83
]
]
|
14,392 | static void gen_compute_eflags_p(DisasContext *s, TCGv reg)
{
gen_compute_eflags(s);
tcg_gen_shri_tl(reg, cpu_cc_src, 2);
tcg_gen_andi_tl(reg, reg, 1);
}
| false | qemu | bec93d7283b635aabaf0bbff67b6da7fc99e020a | static void gen_compute_eflags_p(DisasContext *s, TCGv reg)
{
gen_compute_eflags(s);
tcg_gen_shri_tl(reg, cpu_cc_src, 2);
tcg_gen_andi_tl(reg, reg, 1);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0, TCGv VAR_1)
{
gen_compute_eflags(VAR_0);
tcg_gen_shri_tl(VAR_1, cpu_cc_src, 2);
tcg_gen_andi_tl(VAR_1, VAR_1, 1);
}
| [
"static void FUNC_0(DisasContext *VAR_0, TCGv VAR_1)\n{",
"gen_compute_eflags(VAR_0);",
"tcg_gen_shri_tl(VAR_1, cpu_cc_src, 2);",
"tcg_gen_andi_tl(VAR_1, VAR_1, 1);",
"}"
]
| [
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
]
|
14,394 | int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
{
int ret;
av_frame_unref(frame);
if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec))
return AVERROR(EINVAL);
if (avctx->codec->receive_frame) {
if (avctx->internal->draining && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY))
return AVERROR_EOF;
return avctx->codec->receive_frame(avctx, frame);
}
// Emulation via old API.
if (!avctx->internal->buffer_frame->buf[0]) {
if (!avctx->internal->buffer_pkt->size && !avctx->internal->draining)
return AVERROR(EAGAIN);
while (1) {
if ((ret = do_decode(avctx, avctx->internal->buffer_pkt)) < 0) {
av_packet_unref(avctx->internal->buffer_pkt);
return ret;
}
// Some audio decoders may consume partial data without returning
// a frame (fate-wmapro-2ch). There is no way to make the caller
// call avcodec_receive_frame() again without returning a frame,
// so try to decode more in these cases.
if (avctx->internal->buffer_frame->buf[0] ||
!avctx->internal->buffer_pkt->size)
break;
}
}
if (!avctx->internal->buffer_frame->buf[0])
return avctx->internal->draining ? AVERROR_EOF : AVERROR(EAGAIN);
av_frame_move_ref(frame, avctx->internal->buffer_frame);
return 0;
}
| false | FFmpeg | 40fbf3204208f89a0626f85ce6dd06ca0741583b | int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
{
int ret;
av_frame_unref(frame);
if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec))
return AVERROR(EINVAL);
if (avctx->codec->receive_frame) {
if (avctx->internal->draining && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY))
return AVERROR_EOF;
return avctx->codec->receive_frame(avctx, frame);
}
if (!avctx->internal->buffer_frame->buf[0]) {
if (!avctx->internal->buffer_pkt->size && !avctx->internal->draining)
return AVERROR(EAGAIN);
while (1) {
if ((ret = do_decode(avctx, avctx->internal->buffer_pkt)) < 0) {
av_packet_unref(avctx->internal->buffer_pkt);
return ret;
}
if (avctx->internal->buffer_frame->buf[0] ||
!avctx->internal->buffer_pkt->size)
break;
}
}
if (!avctx->internal->buffer_frame->buf[0])
return avctx->internal->draining ? AVERROR_EOF : AVERROR(EAGAIN);
av_frame_move_ref(frame, avctx->internal->buffer_frame);
return 0;
}
| {
"code": [],
"line_no": []
} | int VAR_0 avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
{
int ret;
av_frame_unref(frame);
if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec))
return AVERROR(EINVAL);
if (avctx->codec->receive_frame) {
if (avctx->internal->draining && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY))
return AVERROR_EOF;
return avctx->codec->receive_frame(avctx, frame);
}
if (!avctx->internal->buffer_frame->buf[0]) {
if (!avctx->internal->buffer_pkt->size && !avctx->internal->draining)
return AVERROR(EAGAIN);
while (1) {
if ((ret = do_decode(avctx, avctx->internal->buffer_pkt)) < 0) {
av_packet_unref(avctx->internal->buffer_pkt);
return ret;
}
if (avctx->internal->buffer_frame->buf[0] ||
!avctx->internal->buffer_pkt->size)
break;
}
}
if (!avctx->internal->buffer_frame->buf[0])
return avctx->internal->draining ? AVERROR_EOF : AVERROR(EAGAIN);
av_frame_move_ref(frame, avctx->internal->buffer_frame);
return 0;
}
| [
"int VAR_0 avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)\n{",
"int ret;",
"av_frame_unref(frame);",
"if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec))\nreturn AVERROR(EINVAL);",
"if (avctx->codec->receive_frame) {",
"if (avctx->internal->draining && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY))\nreturn AVERROR_EOF;",
"return avctx->codec->receive_frame(avctx, frame);",
"}",
"if (!avctx->internal->buffer_frame->buf[0]) {",
"if (!avctx->internal->buffer_pkt->size && !avctx->internal->draining)\nreturn AVERROR(EAGAIN);",
"while (1) {",
"if ((ret = do_decode(avctx, avctx->internal->buffer_pkt)) < 0) {",
"av_packet_unref(avctx->internal->buffer_pkt);",
"return ret;",
"}",
"if (avctx->internal->buffer_frame->buf[0] ||\n!avctx->internal->buffer_pkt->size)\nbreak;",
"}",
"}",
"if (!avctx->internal->buffer_frame->buf[0])\nreturn avctx->internal->draining ? AVERROR_EOF : AVERROR(EAGAIN);",
"av_frame_move_ref(frame, avctx->internal->buffer_frame);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
13,
15
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
35
],
[
37,
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
61,
63,
65
],
[
67
],
[
69
],
[
73,
75
],
[
79
],
[
81
],
[
83
]
]
|
14,395 | static void test_visitor_out_no_string(TestOutputVisitorData *data,
const void *unused)
{
char *string = NULL;
QObject *obj;
/* A null string should return "" */
visit_type_str(data->ov, NULL, &string, &error_abort);
obj = visitor_get(data);
g_assert(qobject_type(obj) == QTYPE_QSTRING);
g_assert_cmpstr(qstring_get_str(qobject_to_qstring(obj)), ==, "");
}
| false | qemu | b3db211f3c80bb996a704d665fe275619f728bd4 | static void test_visitor_out_no_string(TestOutputVisitorData *data,
const void *unused)
{
char *string = NULL;
QObject *obj;
visit_type_str(data->ov, NULL, &string, &error_abort);
obj = visitor_get(data);
g_assert(qobject_type(obj) == QTYPE_QSTRING);
g_assert_cmpstr(qstring_get_str(qobject_to_qstring(obj)), ==, "");
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TestOutputVisitorData *VAR_0,
const void *VAR_1)
{
char *VAR_2 = NULL;
QObject *obj;
visit_type_str(VAR_0->ov, NULL, &VAR_2, &error_abort);
obj = visitor_get(VAR_0);
g_assert(qobject_type(obj) == QTYPE_QSTRING);
g_assert_cmpstr(qstring_get_str(qobject_to_qstring(obj)), ==, "");
}
| [
"static void FUNC_0(TestOutputVisitorData *VAR_0,\nconst void *VAR_1)\n{",
"char *VAR_2 = NULL;",
"QObject *obj;",
"visit_type_str(VAR_0->ov, NULL, &VAR_2, &error_abort);",
"obj = visitor_get(VAR_0);",
"g_assert(qobject_type(obj) == QTYPE_QSTRING);",
"g_assert_cmpstr(qstring_get_str(qobject_to_qstring(obj)), ==, \"\");",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
]
]
|
14,397 | static int spapr_fixup_cpu_dt(void *fdt, sPAPREnvironment *spapr)
{
int ret = 0, offset, cpus_offset;
CPUState *cs;
char cpu_model[32];
int smt = kvmppc_smt_threads();
uint32_t pft_size_prop[] = {0, cpu_to_be32(spapr->htab_shift)};
CPU_FOREACH(cs) {
PowerPCCPU *cpu = POWERPC_CPU(cs);
DeviceClass *dc = DEVICE_GET_CLASS(cs);
int index = ppc_get_vcpu_dt_id(cpu);
uint32_t associativity[] = {cpu_to_be32(0x5),
cpu_to_be32(0x0),
cpu_to_be32(0x0),
cpu_to_be32(0x0),
cpu_to_be32(cs->numa_node),
cpu_to_be32(index)};
if ((index % smt) != 0) {
continue;
}
snprintf(cpu_model, 32, "%s@%x", dc->fw_name, index);
cpus_offset = fdt_path_offset(fdt, "/cpus");
if (cpus_offset < 0) {
cpus_offset = fdt_add_subnode(fdt, fdt_path_offset(fdt, "/"),
"cpus");
if (cpus_offset < 0) {
return cpus_offset;
}
}
offset = fdt_subnode_offset(fdt, cpus_offset, cpu_model);
if (offset < 0) {
offset = fdt_add_subnode(fdt, cpus_offset, cpu_model);
if (offset < 0) {
return offset;
}
}
if (nb_numa_nodes > 1) {
ret = fdt_setprop(fdt, offset, "ibm,associativity", associativity,
sizeof(associativity));
if (ret < 0) {
return ret;
}
}
ret = fdt_setprop(fdt, offset, "ibm,pft-size",
pft_size_prop, sizeof(pft_size_prop));
if (ret < 0) {
return ret;
}
ret = spapr_fixup_cpu_smt_dt(fdt, offset, cpu,
smp_threads);
if (ret < 0) {
return ret;
}
}
return ret;
}
| false | qemu | 2a48d99335c572b0d3da59c1387ad131ea6ee590 | static int spapr_fixup_cpu_dt(void *fdt, sPAPREnvironment *spapr)
{
int ret = 0, offset, cpus_offset;
CPUState *cs;
char cpu_model[32];
int smt = kvmppc_smt_threads();
uint32_t pft_size_prop[] = {0, cpu_to_be32(spapr->htab_shift)};
CPU_FOREACH(cs) {
PowerPCCPU *cpu = POWERPC_CPU(cs);
DeviceClass *dc = DEVICE_GET_CLASS(cs);
int index = ppc_get_vcpu_dt_id(cpu);
uint32_t associativity[] = {cpu_to_be32(0x5),
cpu_to_be32(0x0),
cpu_to_be32(0x0),
cpu_to_be32(0x0),
cpu_to_be32(cs->numa_node),
cpu_to_be32(index)};
if ((index % smt) != 0) {
continue;
}
snprintf(cpu_model, 32, "%s@%x", dc->fw_name, index);
cpus_offset = fdt_path_offset(fdt, "/cpus");
if (cpus_offset < 0) {
cpus_offset = fdt_add_subnode(fdt, fdt_path_offset(fdt, "/"),
"cpus");
if (cpus_offset < 0) {
return cpus_offset;
}
}
offset = fdt_subnode_offset(fdt, cpus_offset, cpu_model);
if (offset < 0) {
offset = fdt_add_subnode(fdt, cpus_offset, cpu_model);
if (offset < 0) {
return offset;
}
}
if (nb_numa_nodes > 1) {
ret = fdt_setprop(fdt, offset, "ibm,associativity", associativity,
sizeof(associativity));
if (ret < 0) {
return ret;
}
}
ret = fdt_setprop(fdt, offset, "ibm,pft-size",
pft_size_prop, sizeof(pft_size_prop));
if (ret < 0) {
return ret;
}
ret = spapr_fixup_cpu_smt_dt(fdt, offset, cpu,
smp_threads);
if (ret < 0) {
return ret;
}
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(void *VAR_0, sPAPREnvironment *VAR_1)
{
int VAR_2 = 0, VAR_3, VAR_4;
CPUState *cs;
char VAR_5[32];
int VAR_6 = kvmppc_smt_threads();
uint32_t pft_size_prop[] = {0, cpu_to_be32(VAR_1->htab_shift)};
CPU_FOREACH(cs) {
PowerPCCPU *cpu = POWERPC_CPU(cs);
DeviceClass *dc = DEVICE_GET_CLASS(cs);
int index = ppc_get_vcpu_dt_id(cpu);
uint32_t associativity[] = {cpu_to_be32(0x5),
cpu_to_be32(0x0),
cpu_to_be32(0x0),
cpu_to_be32(0x0),
cpu_to_be32(cs->numa_node),
cpu_to_be32(index)};
if ((index % VAR_6) != 0) {
continue;
}
snprintf(VAR_5, 32, "%s@%x", dc->fw_name, index);
VAR_4 = fdt_path_offset(VAR_0, "/cpus");
if (VAR_4 < 0) {
VAR_4 = fdt_add_subnode(VAR_0, fdt_path_offset(VAR_0, "/"),
"cpus");
if (VAR_4 < 0) {
return VAR_4;
}
}
VAR_3 = fdt_subnode_offset(VAR_0, VAR_4, VAR_5);
if (VAR_3 < 0) {
VAR_3 = fdt_add_subnode(VAR_0, VAR_4, VAR_5);
if (VAR_3 < 0) {
return VAR_3;
}
}
if (nb_numa_nodes > 1) {
VAR_2 = fdt_setprop(VAR_0, VAR_3, "ibm,associativity", associativity,
sizeof(associativity));
if (VAR_2 < 0) {
return VAR_2;
}
}
VAR_2 = fdt_setprop(VAR_0, VAR_3, "ibm,pft-size",
pft_size_prop, sizeof(pft_size_prop));
if (VAR_2 < 0) {
return VAR_2;
}
VAR_2 = spapr_fixup_cpu_smt_dt(VAR_0, VAR_3, cpu,
smp_threads);
if (VAR_2 < 0) {
return VAR_2;
}
}
return VAR_2;
}
| [
"static int FUNC_0(void *VAR_0, sPAPREnvironment *VAR_1)\n{",
"int VAR_2 = 0, VAR_3, VAR_4;",
"CPUState *cs;",
"char VAR_5[32];",
"int VAR_6 = kvmppc_smt_threads();",
"uint32_t pft_size_prop[] = {0, cpu_to_be32(VAR_1->htab_shift)};",
"CPU_FOREACH(cs) {",
"PowerPCCPU *cpu = POWERPC_CPU(cs);",
"DeviceClass *dc = DEVICE_GET_CLASS(cs);",
"int index = ppc_get_vcpu_dt_id(cpu);",
"uint32_t associativity[] = {cpu_to_be32(0x5),",
"cpu_to_be32(0x0),\ncpu_to_be32(0x0),\ncpu_to_be32(0x0),\ncpu_to_be32(cs->numa_node),\ncpu_to_be32(index)};",
"if ((index % VAR_6) != 0) {",
"continue;",
"}",
"snprintf(VAR_5, 32, \"%s@%x\", dc->fw_name, index);",
"VAR_4 = fdt_path_offset(VAR_0, \"/cpus\");",
"if (VAR_4 < 0) {",
"VAR_4 = fdt_add_subnode(VAR_0, fdt_path_offset(VAR_0, \"/\"),\n\"cpus\");",
"if (VAR_4 < 0) {",
"return VAR_4;",
"}",
"}",
"VAR_3 = fdt_subnode_offset(VAR_0, VAR_4, VAR_5);",
"if (VAR_3 < 0) {",
"VAR_3 = fdt_add_subnode(VAR_0, VAR_4, VAR_5);",
"if (VAR_3 < 0) {",
"return VAR_3;",
"}",
"}",
"if (nb_numa_nodes > 1) {",
"VAR_2 = fdt_setprop(VAR_0, VAR_3, \"ibm,associativity\", associativity,\nsizeof(associativity));",
"if (VAR_2 < 0) {",
"return VAR_2;",
"}",
"}",
"VAR_2 = fdt_setprop(VAR_0, VAR_3, \"ibm,pft-size\",\npft_size_prop, sizeof(pft_size_prop));",
"if (VAR_2 < 0) {",
"return VAR_2;",
"}",
"VAR_2 = spapr_fixup_cpu_smt_dt(VAR_0, VAR_3, cpu,\nsmp_threads);",
"if (VAR_2 < 0) {",
"return VAR_2;",
"}",
"}",
"return VAR_2;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27,
29,
31,
33,
35
],
[
39
],
[
41
],
[
43
],
[
47
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99,
101
],
[
103
],
[
105
],
[
107
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
]
]
|
14,398 | static always_inline void gen_excp (DisasContext *ctx,
int exception, int error_code)
{
TCGv tmp1, tmp2;
tcg_gen_movi_i64(cpu_pc, ctx->pc);
tmp1 = tcg_const_i32(exception);
tmp2 = tcg_const_i32(error_code);
tcg_gen_helper_0_2(helper_excp, tmp1, tmp2);
tcg_temp_free(tmp2);
tcg_temp_free(tmp1);
}
| false | qemu | a7812ae412311d7d47f8aa85656faadac9d64b56 | static always_inline void gen_excp (DisasContext *ctx,
int exception, int error_code)
{
TCGv tmp1, tmp2;
tcg_gen_movi_i64(cpu_pc, ctx->pc);
tmp1 = tcg_const_i32(exception);
tmp2 = tcg_const_i32(error_code);
tcg_gen_helper_0_2(helper_excp, tmp1, tmp2);
tcg_temp_free(tmp2);
tcg_temp_free(tmp1);
}
| {
"code": [],
"line_no": []
} | static always_inline void FUNC_0 (DisasContext *ctx,
int exception, int error_code)
{
TCGv tmp1, tmp2;
tcg_gen_movi_i64(cpu_pc, ctx->pc);
tmp1 = tcg_const_i32(exception);
tmp2 = tcg_const_i32(error_code);
tcg_gen_helper_0_2(helper_excp, tmp1, tmp2);
tcg_temp_free(tmp2);
tcg_temp_free(tmp1);
}
| [
"static always_inline void FUNC_0 (DisasContext *ctx,\nint exception, int error_code)\n{",
"TCGv tmp1, tmp2;",
"tcg_gen_movi_i64(cpu_pc, ctx->pc);",
"tmp1 = tcg_const_i32(exception);",
"tmp2 = tcg_const_i32(error_code);",
"tcg_gen_helper_0_2(helper_excp, tmp1, tmp2);",
"tcg_temp_free(tmp2);",
"tcg_temp_free(tmp1);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
]
|
14,399 | static bool gen_check_loop_end(DisasContext *dc, int slot)
{
if (option_enabled(dc, XTENSA_OPTION_LOOP) &&
!(dc->tb->flags & XTENSA_TBFLAG_EXCM) &&
dc->next_pc == dc->lend) {
int label = gen_new_label();
gen_advance_ccount(dc);
tcg_gen_brcondi_i32(TCG_COND_EQ, cpu_SR[LCOUNT], 0, label);
tcg_gen_subi_i32(cpu_SR[LCOUNT], cpu_SR[LCOUNT], 1);
gen_jumpi(dc, dc->lbeg, slot);
gen_set_label(label);
gen_jumpi(dc, dc->next_pc, -1);
return true;
}
return false;
}
| false | qemu | 42a268c241183877192c376d03bd9b6d527407c7 | static bool gen_check_loop_end(DisasContext *dc, int slot)
{
if (option_enabled(dc, XTENSA_OPTION_LOOP) &&
!(dc->tb->flags & XTENSA_TBFLAG_EXCM) &&
dc->next_pc == dc->lend) {
int label = gen_new_label();
gen_advance_ccount(dc);
tcg_gen_brcondi_i32(TCG_COND_EQ, cpu_SR[LCOUNT], 0, label);
tcg_gen_subi_i32(cpu_SR[LCOUNT], cpu_SR[LCOUNT], 1);
gen_jumpi(dc, dc->lbeg, slot);
gen_set_label(label);
gen_jumpi(dc, dc->next_pc, -1);
return true;
}
return false;
}
| {
"code": [],
"line_no": []
} | static bool FUNC_0(DisasContext *dc, int slot)
{
if (option_enabled(dc, XTENSA_OPTION_LOOP) &&
!(dc->tb->flags & XTENSA_TBFLAG_EXCM) &&
dc->next_pc == dc->lend) {
int VAR_0 = gen_new_label();
gen_advance_ccount(dc);
tcg_gen_brcondi_i32(TCG_COND_EQ, cpu_SR[LCOUNT], 0, VAR_0);
tcg_gen_subi_i32(cpu_SR[LCOUNT], cpu_SR[LCOUNT], 1);
gen_jumpi(dc, dc->lbeg, slot);
gen_set_label(VAR_0);
gen_jumpi(dc, dc->next_pc, -1);
return true;
}
return false;
}
| [
"static bool FUNC_0(DisasContext *dc, int slot)\n{",
"if (option_enabled(dc, XTENSA_OPTION_LOOP) &&\n!(dc->tb->flags & XTENSA_TBFLAG_EXCM) &&\ndc->next_pc == dc->lend) {",
"int VAR_0 = gen_new_label();",
"gen_advance_ccount(dc);",
"tcg_gen_brcondi_i32(TCG_COND_EQ, cpu_SR[LCOUNT], 0, VAR_0);",
"tcg_gen_subi_i32(cpu_SR[LCOUNT], cpu_SR[LCOUNT], 1);",
"gen_jumpi(dc, dc->lbeg, slot);",
"gen_set_label(VAR_0);",
"gen_jumpi(dc, dc->next_pc, -1);",
"return true;",
"}",
"return false;",
"}"
]
| [
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
]
]
|
14,400 | int i2c_send(I2CBus *bus, uint8_t data)
{
I2CSlaveClass *sc;
I2CNode *node;
int ret = 0;
QLIST_FOREACH(node, &bus->current_devs, next) {
sc = I2C_SLAVE_GET_CLASS(node->elt);
if (sc->send) {
ret = ret || sc->send(node->elt, data);
} else {
ret = -1;
}
}
return ret ? -1 : 0;
}
| false | qemu | 056fca7b51d949aa0e18e0eb647838874a53bcbe | int i2c_send(I2CBus *bus, uint8_t data)
{
I2CSlaveClass *sc;
I2CNode *node;
int ret = 0;
QLIST_FOREACH(node, &bus->current_devs, next) {
sc = I2C_SLAVE_GET_CLASS(node->elt);
if (sc->send) {
ret = ret || sc->send(node->elt, data);
} else {
ret = -1;
}
}
return ret ? -1 : 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(I2CBus *VAR_0, uint8_t VAR_1)
{
I2CSlaveClass *sc;
I2CNode *node;
int VAR_2 = 0;
QLIST_FOREACH(node, &VAR_0->current_devs, next) {
sc = I2C_SLAVE_GET_CLASS(node->elt);
if (sc->send) {
VAR_2 = VAR_2 || sc->send(node->elt, VAR_1);
} else {
VAR_2 = -1;
}
}
return VAR_2 ? -1 : 0;
}
| [
"int FUNC_0(I2CBus *VAR_0, uint8_t VAR_1)\n{",
"I2CSlaveClass *sc;",
"I2CNode *node;",
"int VAR_2 = 0;",
"QLIST_FOREACH(node, &VAR_0->current_devs, next) {",
"sc = I2C_SLAVE_GET_CLASS(node->elt);",
"if (sc->send) {",
"VAR_2 = VAR_2 || sc->send(node->elt, VAR_1);",
"} else {",
"VAR_2 = -1;",
"}",
"}",
"return VAR_2 ? -1 : 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
]
]
|
14,401 | static int find_image_range(int *pfirst_index, int *plast_index,
const char *path, int start_index, int start_index_range)
{
char buf[1024];
int range, last_index, range1, first_index;
/* find the first image */
for (first_index = start_index; first_index < start_index + start_index_range; first_index++) {
if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0) {
*pfirst_index =
*plast_index = 1;
if (avio_check(buf, AVIO_FLAG_READ) > 0)
return 0;
return -1;
}
if (avio_check(buf, AVIO_FLAG_READ) > 0)
break;
}
if (first_index == start_index + start_index_range)
goto fail;
/* find the last image */
last_index = first_index;
for (;;) {
range = 0;
for (;;) {
if (!range)
range1 = 1;
else
range1 = 2 * range;
if (av_get_frame_filename(buf, sizeof(buf), path,
last_index + range1) < 0)
goto fail;
if (avio_check(buf, AVIO_FLAG_READ) <= 0)
break;
range = range1;
/* just in case... */
if (range >= (1 << 30))
goto fail;
}
/* we are sure than image last_index + range exists */
if (!range)
break;
last_index += range;
}
*pfirst_index = first_index;
*plast_index = last_index;
return 0;
fail:
return -1;
}
| false | FFmpeg | e9e87822022fc81f92866f870ecedfd2f6272ac9 | static int find_image_range(int *pfirst_index, int *plast_index,
const char *path, int start_index, int start_index_range)
{
char buf[1024];
int range, last_index, range1, first_index;
for (first_index = start_index; first_index < start_index + start_index_range; first_index++) {
if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0) {
*pfirst_index =
*plast_index = 1;
if (avio_check(buf, AVIO_FLAG_READ) > 0)
return 0;
return -1;
}
if (avio_check(buf, AVIO_FLAG_READ) > 0)
break;
}
if (first_index == start_index + start_index_range)
goto fail;
last_index = first_index;
for (;;) {
range = 0;
for (;;) {
if (!range)
range1 = 1;
else
range1 = 2 * range;
if (av_get_frame_filename(buf, sizeof(buf), path,
last_index + range1) < 0)
goto fail;
if (avio_check(buf, AVIO_FLAG_READ) <= 0)
break;
range = range1;
if (range >= (1 << 30))
goto fail;
}
if (!range)
break;
last_index += range;
}
*pfirst_index = first_index;
*plast_index = last_index;
return 0;
fail:
return -1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(int *VAR_0, int *VAR_1,
const char *VAR_2, int VAR_3, int VAR_4)
{
char VAR_5[1024];
int VAR_6, VAR_7, VAR_8, VAR_9;
for (VAR_9 = VAR_3; VAR_9 < VAR_3 + VAR_4; VAR_9++) {
if (av_get_frame_filename(VAR_5, sizeof(VAR_5), VAR_2, VAR_9) < 0) {
*VAR_0 =
*VAR_1 = 1;
if (avio_check(VAR_5, AVIO_FLAG_READ) > 0)
return 0;
return -1;
}
if (avio_check(VAR_5, AVIO_FLAG_READ) > 0)
break;
}
if (VAR_9 == VAR_3 + VAR_4)
goto fail;
VAR_7 = VAR_9;
for (;;) {
VAR_6 = 0;
for (;;) {
if (!VAR_6)
VAR_8 = 1;
else
VAR_8 = 2 * VAR_6;
if (av_get_frame_filename(VAR_5, sizeof(VAR_5), VAR_2,
VAR_7 + VAR_8) < 0)
goto fail;
if (avio_check(VAR_5, AVIO_FLAG_READ) <= 0)
break;
VAR_6 = VAR_8;
if (VAR_6 >= (1 << 30))
goto fail;
}
if (!VAR_6)
break;
VAR_7 += VAR_6;
}
*VAR_0 = VAR_9;
*VAR_1 = VAR_7;
return 0;
fail:
return -1;
}
| [
"static int FUNC_0(int *VAR_0, int *VAR_1,\nconst char *VAR_2, int VAR_3, int VAR_4)\n{",
"char VAR_5[1024];",
"int VAR_6, VAR_7, VAR_8, VAR_9;",
"for (VAR_9 = VAR_3; VAR_9 < VAR_3 + VAR_4; VAR_9++) {",
"if (av_get_frame_filename(VAR_5, sizeof(VAR_5), VAR_2, VAR_9) < 0) {",
"*VAR_0 =\n*VAR_1 = 1;",
"if (avio_check(VAR_5, AVIO_FLAG_READ) > 0)\nreturn 0;",
"return -1;",
"}",
"if (avio_check(VAR_5, AVIO_FLAG_READ) > 0)\nbreak;",
"}",
"if (VAR_9 == VAR_3 + VAR_4)\ngoto fail;",
"VAR_7 = VAR_9;",
"for (;;) {",
"VAR_6 = 0;",
"for (;;) {",
"if (!VAR_6)\nVAR_8 = 1;",
"else\nVAR_8 = 2 * VAR_6;",
"if (av_get_frame_filename(VAR_5, sizeof(VAR_5), VAR_2,\nVAR_7 + VAR_8) < 0)\ngoto fail;",
"if (avio_check(VAR_5, AVIO_FLAG_READ) <= 0)\nbreak;",
"VAR_6 = VAR_8;",
"if (VAR_6 >= (1 << 30))\ngoto fail;",
"}",
"if (!VAR_6)\nbreak;",
"VAR_7 += VAR_6;",
"}",
"*VAR_0 = VAR_9;",
"*VAR_1 = VAR_7;",
"return 0;",
"fail:\nreturn -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
],
[
15
],
[
17
],
[
19,
21
],
[
23,
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37,
39
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57,
59
],
[
61,
63,
65
],
[
67,
69
],
[
71
],
[
75,
77
],
[
79
],
[
83,
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99,
101
],
[
103
]
]
|
14,403 | start_list(Visitor *v, const char *name, GenericList **list, size_t size,
Error **errp)
{
StringInputVisitor *siv = to_siv(v);
/* We don't support visits without a list */
assert(list);
if (parse_str(siv, name, errp) < 0) {
*list = NULL;
return;
}
siv->cur_range = g_list_first(siv->ranges);
if (siv->cur_range) {
Range *r = siv->cur_range->data;
if (r) {
siv->cur = r->begin;
}
*list = g_malloc0(size);
} else {
*list = NULL;
}
}
| false | qemu | a0efbf16604770b9d805bcf210ec29942321134f | start_list(Visitor *v, const char *name, GenericList **list, size_t size,
Error **errp)
{
StringInputVisitor *siv = to_siv(v);
assert(list);
if (parse_str(siv, name, errp) < 0) {
*list = NULL;
return;
}
siv->cur_range = g_list_first(siv->ranges);
if (siv->cur_range) {
Range *r = siv->cur_range->data;
if (r) {
siv->cur = r->begin;
}
*list = g_malloc0(size);
} else {
*list = NULL;
}
}
| {
"code": [],
"line_no": []
} | FUNC_0(Visitor *VAR_0, const char *VAR_1, GenericList **VAR_2, size_t VAR_3,
Error **VAR_4)
{
StringInputVisitor *siv = to_siv(VAR_0);
assert(VAR_2);
if (parse_str(siv, VAR_1, VAR_4) < 0) {
*VAR_2 = NULL;
return;
}
siv->cur_range = g_list_first(siv->ranges);
if (siv->cur_range) {
Range *r = siv->cur_range->data;
if (r) {
siv->cur = r->begin;
}
*VAR_2 = g_malloc0(VAR_3);
} else {
*VAR_2 = NULL;
}
}
| [
"FUNC_0(Visitor *VAR_0, const char *VAR_1, GenericList **VAR_2, size_t VAR_3,\nError **VAR_4)\n{",
"StringInputVisitor *siv = to_siv(VAR_0);",
"assert(VAR_2);",
"if (parse_str(siv, VAR_1, VAR_4) < 0) {",
"*VAR_2 = NULL;",
"return;",
"}",
"siv->cur_range = g_list_first(siv->ranges);",
"if (siv->cur_range) {",
"Range *r = siv->cur_range->data;",
"if (r) {",
"siv->cur = r->begin;",
"}",
"*VAR_2 = g_malloc0(VAR_3);",
"} else {",
"*VAR_2 = NULL;",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
]
]
|
14,404 | static int xio3130_downstream_initfn(PCIDevice *d)
{
PCIBridge* br = DO_UPCAST(PCIBridge, dev, d);
PCIEPort *p = DO_UPCAST(PCIEPort, br, br);
PCIESlot *s = DO_UPCAST(PCIESlot, port, p);
int rc;
int tmp;
rc = pci_bridge_initfn(d);
if (rc < 0) {
return rc;
}
pcie_port_init_reg(d);
pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_TI);
pci_config_set_device_id(d->config, PCI_DEVICE_ID_TI_XIO3130D);
d->config[PCI_REVISION_ID] = XIO3130_REVISION;
rc = msi_init(d, XIO3130_MSI_OFFSET, XIO3130_MSI_NR_VECTOR,
XIO3130_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_64BIT,
XIO3130_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_MASKBIT);
if (rc < 0) {
goto err_bridge;
}
rc = pci_bridge_ssvid_init(d, XIO3130_SSVID_OFFSET,
XIO3130_SSVID_SVID, XIO3130_SSVID_SSID);
if (rc < 0) {
goto err_bridge;
}
rc = pcie_cap_init(d, XIO3130_EXP_OFFSET, PCI_EXP_TYPE_DOWNSTREAM,
p->port);
if (rc < 0) {
goto err_msi;
}
pcie_cap_flr_init(d);
pcie_cap_deverr_init(d);
pcie_cap_slot_init(d, s->slot);
pcie_chassis_create(s->chassis);
rc = pcie_chassis_add_slot(s);
if (rc < 0) {
goto err_pcie_cap;
}
pcie_cap_ari_init(d);
rc = pcie_aer_init(d, XIO3130_AER_OFFSET);
if (rc < 0) {
goto err;
}
return 0;
err:
pcie_chassis_del_slot(s);
err_pcie_cap:
pcie_cap_exit(d);
err_msi:
msi_uninit(d);
err_bridge:
tmp = pci_bridge_exitfn(d);
assert(!tmp);
return rc;
}
| false | qemu | 3ec39b2d20a25505382619e31e6572e3d04f311e | static int xio3130_downstream_initfn(PCIDevice *d)
{
PCIBridge* br = DO_UPCAST(PCIBridge, dev, d);
PCIEPort *p = DO_UPCAST(PCIEPort, br, br);
PCIESlot *s = DO_UPCAST(PCIESlot, port, p);
int rc;
int tmp;
rc = pci_bridge_initfn(d);
if (rc < 0) {
return rc;
}
pcie_port_init_reg(d);
pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_TI);
pci_config_set_device_id(d->config, PCI_DEVICE_ID_TI_XIO3130D);
d->config[PCI_REVISION_ID] = XIO3130_REVISION;
rc = msi_init(d, XIO3130_MSI_OFFSET, XIO3130_MSI_NR_VECTOR,
XIO3130_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_64BIT,
XIO3130_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_MASKBIT);
if (rc < 0) {
goto err_bridge;
}
rc = pci_bridge_ssvid_init(d, XIO3130_SSVID_OFFSET,
XIO3130_SSVID_SVID, XIO3130_SSVID_SSID);
if (rc < 0) {
goto err_bridge;
}
rc = pcie_cap_init(d, XIO3130_EXP_OFFSET, PCI_EXP_TYPE_DOWNSTREAM,
p->port);
if (rc < 0) {
goto err_msi;
}
pcie_cap_flr_init(d);
pcie_cap_deverr_init(d);
pcie_cap_slot_init(d, s->slot);
pcie_chassis_create(s->chassis);
rc = pcie_chassis_add_slot(s);
if (rc < 0) {
goto err_pcie_cap;
}
pcie_cap_ari_init(d);
rc = pcie_aer_init(d, XIO3130_AER_OFFSET);
if (rc < 0) {
goto err;
}
return 0;
err:
pcie_chassis_del_slot(s);
err_pcie_cap:
pcie_cap_exit(d);
err_msi:
msi_uninit(d);
err_bridge:
tmp = pci_bridge_exitfn(d);
assert(!tmp);
return rc;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(PCIDevice *VAR_0)
{
PCIBridge* br = DO_UPCAST(PCIBridge, dev, VAR_0);
PCIEPort *p = DO_UPCAST(PCIEPort, br, br);
PCIESlot *s = DO_UPCAST(PCIESlot, port, p);
int VAR_1;
int VAR_2;
VAR_1 = pci_bridge_initfn(VAR_0);
if (VAR_1 < 0) {
return VAR_1;
}
pcie_port_init_reg(VAR_0);
pci_config_set_vendor_id(VAR_0->config, PCI_VENDOR_ID_TI);
pci_config_set_device_id(VAR_0->config, PCI_DEVICE_ID_TI_XIO3130D);
VAR_0->config[PCI_REVISION_ID] = XIO3130_REVISION;
VAR_1 = msi_init(VAR_0, XIO3130_MSI_OFFSET, XIO3130_MSI_NR_VECTOR,
XIO3130_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_64BIT,
XIO3130_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_MASKBIT);
if (VAR_1 < 0) {
goto err_bridge;
}
VAR_1 = pci_bridge_ssvid_init(VAR_0, XIO3130_SSVID_OFFSET,
XIO3130_SSVID_SVID, XIO3130_SSVID_SSID);
if (VAR_1 < 0) {
goto err_bridge;
}
VAR_1 = pcie_cap_init(VAR_0, XIO3130_EXP_OFFSET, PCI_EXP_TYPE_DOWNSTREAM,
p->port);
if (VAR_1 < 0) {
goto err_msi;
}
pcie_cap_flr_init(VAR_0);
pcie_cap_deverr_init(VAR_0);
pcie_cap_slot_init(VAR_0, s->slot);
pcie_chassis_create(s->chassis);
VAR_1 = pcie_chassis_add_slot(s);
if (VAR_1 < 0) {
goto err_pcie_cap;
}
pcie_cap_ari_init(VAR_0);
VAR_1 = pcie_aer_init(VAR_0, XIO3130_AER_OFFSET);
if (VAR_1 < 0) {
goto err;
}
return 0;
err:
pcie_chassis_del_slot(s);
err_pcie_cap:
pcie_cap_exit(VAR_0);
err_msi:
msi_uninit(VAR_0);
err_bridge:
VAR_2 = pci_bridge_exitfn(VAR_0);
assert(!VAR_2);
return VAR_1;
}
| [
"static int FUNC_0(PCIDevice *VAR_0)\n{",
"PCIBridge* br = DO_UPCAST(PCIBridge, dev, VAR_0);",
"PCIEPort *p = DO_UPCAST(PCIEPort, br, br);",
"PCIESlot *s = DO_UPCAST(PCIESlot, port, p);",
"int VAR_1;",
"int VAR_2;",
"VAR_1 = pci_bridge_initfn(VAR_0);",
"if (VAR_1 < 0) {",
"return VAR_1;",
"}",
"pcie_port_init_reg(VAR_0);",
"pci_config_set_vendor_id(VAR_0->config, PCI_VENDOR_ID_TI);",
"pci_config_set_device_id(VAR_0->config, PCI_DEVICE_ID_TI_XIO3130D);",
"VAR_0->config[PCI_REVISION_ID] = XIO3130_REVISION;",
"VAR_1 = msi_init(VAR_0, XIO3130_MSI_OFFSET, XIO3130_MSI_NR_VECTOR,\nXIO3130_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_64BIT,\nXIO3130_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_MASKBIT);",
"if (VAR_1 < 0) {",
"goto err_bridge;",
"}",
"VAR_1 = pci_bridge_ssvid_init(VAR_0, XIO3130_SSVID_OFFSET,\nXIO3130_SSVID_SVID, XIO3130_SSVID_SSID);",
"if (VAR_1 < 0) {",
"goto err_bridge;",
"}",
"VAR_1 = pcie_cap_init(VAR_0, XIO3130_EXP_OFFSET, PCI_EXP_TYPE_DOWNSTREAM,\np->port);",
"if (VAR_1 < 0) {",
"goto err_msi;",
"}",
"pcie_cap_flr_init(VAR_0);",
"pcie_cap_deverr_init(VAR_0);",
"pcie_cap_slot_init(VAR_0, s->slot);",
"pcie_chassis_create(s->chassis);",
"VAR_1 = pcie_chassis_add_slot(s);",
"if (VAR_1 < 0) {",
"goto err_pcie_cap;",
"}",
"pcie_cap_ari_init(VAR_0);",
"VAR_1 = pcie_aer_init(VAR_0, XIO3130_AER_OFFSET);",
"if (VAR_1 < 0) {",
"goto err;",
"}",
"return 0;",
"err:\npcie_chassis_del_slot(s);",
"err_pcie_cap:\npcie_cap_exit(VAR_0);",
"err_msi:\nmsi_uninit(VAR_0);",
"err_bridge:\nVAR_2 = pci_bridge_exitfn(VAR_0);",
"assert(!VAR_2);",
"return 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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37,
39,
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
101,
103
],
[
105,
107
],
[
109,
111
],
[
113,
115
],
[
117
],
[
119
],
[
121
]
]
|
14,406 | void imx_timerg_create(const target_phys_addr_t addr,
qemu_irq irq,
DeviceState *ccm)
{
IMXTimerGState *pp;
DeviceState *dev;
dev = sysbus_create_simple("imx_timerg", addr, irq);
pp = container_of(dev, IMXTimerGState, busdev.qdev);
pp->ccm = ccm;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | void imx_timerg_create(const target_phys_addr_t addr,
qemu_irq irq,
DeviceState *ccm)
{
IMXTimerGState *pp;
DeviceState *dev;
dev = sysbus_create_simple("imx_timerg", addr, irq);
pp = container_of(dev, IMXTimerGState, busdev.qdev);
pp->ccm = ccm;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(const target_phys_addr_t VAR_0,
qemu_irq VAR_1,
DeviceState *VAR_2)
{
IMXTimerGState *pp;
DeviceState *dev;
dev = sysbus_create_simple("imx_timerg", VAR_0, VAR_1);
pp = container_of(dev, IMXTimerGState, busdev.qdev);
pp->VAR_2 = VAR_2;
}
| [
"void FUNC_0(const target_phys_addr_t VAR_0,\nqemu_irq VAR_1,\nDeviceState *VAR_2)\n{",
"IMXTimerGState *pp;",
"DeviceState *dev;",
"dev = sysbus_create_simple(\"imx_timerg\", VAR_0, VAR_1);",
"pp = container_of(dev, IMXTimerGState, busdev.qdev);",
"pp->VAR_2 = VAR_2;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
]
]
|
14,407 | static int mig_save_device_bulk(Monitor *mon, QEMUFile *f,
BlkMigDevState *bmds)
{
int64_t total_sectors = bmds->total_sectors;
int64_t cur_sector = bmds->cur_sector;
BlockDriverState *bs = bmds->bs;
BlkMigBlock *blk;
int nr_sectors;
if (bmds->shared_base) {
while (cur_sector < total_sectors &&
!bdrv_is_allocated(bs, cur_sector, MAX_IS_ALLOCATED_SEARCH,
&nr_sectors)) {
cur_sector += nr_sectors;
}
}
if (cur_sector >= total_sectors) {
bmds->cur_sector = bmds->completed_sectors = total_sectors;
return 1;
}
bmds->completed_sectors = cur_sector;
cur_sector &= ~((int64_t)BDRV_SECTORS_PER_DIRTY_CHUNK - 1);
/* we are going to transfer a full block even if it is not allocated */
nr_sectors = BDRV_SECTORS_PER_DIRTY_CHUNK;
if (total_sectors - cur_sector < BDRV_SECTORS_PER_DIRTY_CHUNK) {
nr_sectors = total_sectors - cur_sector;
}
blk = g_malloc(sizeof(BlkMigBlock));
blk->buf = g_malloc(BLOCK_SIZE);
blk->bmds = bmds;
blk->sector = cur_sector;
blk->nr_sectors = nr_sectors;
blk->iov.iov_base = blk->buf;
blk->iov.iov_len = nr_sectors * BDRV_SECTOR_SIZE;
qemu_iovec_init_external(&blk->qiov, &blk->iov, 1);
if (block_mig_state.submitted == 0) {
block_mig_state.prev_time_offset = qemu_get_clock_ns(rt_clock);
}
blk->aiocb = bdrv_aio_readv(bs, cur_sector, &blk->qiov,
nr_sectors, blk_mig_read_cb, blk);
block_mig_state.submitted++;
bdrv_reset_dirty(bs, cur_sector, nr_sectors);
bmds->cur_sector = cur_sector + nr_sectors;
return (bmds->cur_sector >= total_sectors);
}
| false | qemu | 539de1246d355d3b8aa33fb7cde732352d8827c7 | static int mig_save_device_bulk(Monitor *mon, QEMUFile *f,
BlkMigDevState *bmds)
{
int64_t total_sectors = bmds->total_sectors;
int64_t cur_sector = bmds->cur_sector;
BlockDriverState *bs = bmds->bs;
BlkMigBlock *blk;
int nr_sectors;
if (bmds->shared_base) {
while (cur_sector < total_sectors &&
!bdrv_is_allocated(bs, cur_sector, MAX_IS_ALLOCATED_SEARCH,
&nr_sectors)) {
cur_sector += nr_sectors;
}
}
if (cur_sector >= total_sectors) {
bmds->cur_sector = bmds->completed_sectors = total_sectors;
return 1;
}
bmds->completed_sectors = cur_sector;
cur_sector &= ~((int64_t)BDRV_SECTORS_PER_DIRTY_CHUNK - 1);
nr_sectors = BDRV_SECTORS_PER_DIRTY_CHUNK;
if (total_sectors - cur_sector < BDRV_SECTORS_PER_DIRTY_CHUNK) {
nr_sectors = total_sectors - cur_sector;
}
blk = g_malloc(sizeof(BlkMigBlock));
blk->buf = g_malloc(BLOCK_SIZE);
blk->bmds = bmds;
blk->sector = cur_sector;
blk->nr_sectors = nr_sectors;
blk->iov.iov_base = blk->buf;
blk->iov.iov_len = nr_sectors * BDRV_SECTOR_SIZE;
qemu_iovec_init_external(&blk->qiov, &blk->iov, 1);
if (block_mig_state.submitted == 0) {
block_mig_state.prev_time_offset = qemu_get_clock_ns(rt_clock);
}
blk->aiocb = bdrv_aio_readv(bs, cur_sector, &blk->qiov,
nr_sectors, blk_mig_read_cb, blk);
block_mig_state.submitted++;
bdrv_reset_dirty(bs, cur_sector, nr_sectors);
bmds->cur_sector = cur_sector + nr_sectors;
return (bmds->cur_sector >= total_sectors);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(Monitor *VAR_0, QEMUFile *VAR_1,
BlkMigDevState *VAR_2)
{
int64_t total_sectors = VAR_2->total_sectors;
int64_t cur_sector = VAR_2->cur_sector;
BlockDriverState *bs = VAR_2->bs;
BlkMigBlock *blk;
int VAR_3;
if (VAR_2->shared_base) {
while (cur_sector < total_sectors &&
!bdrv_is_allocated(bs, cur_sector, MAX_IS_ALLOCATED_SEARCH,
&VAR_3)) {
cur_sector += VAR_3;
}
}
if (cur_sector >= total_sectors) {
VAR_2->cur_sector = VAR_2->completed_sectors = total_sectors;
return 1;
}
VAR_2->completed_sectors = cur_sector;
cur_sector &= ~((int64_t)BDRV_SECTORS_PER_DIRTY_CHUNK - 1);
VAR_3 = BDRV_SECTORS_PER_DIRTY_CHUNK;
if (total_sectors - cur_sector < BDRV_SECTORS_PER_DIRTY_CHUNK) {
VAR_3 = total_sectors - cur_sector;
}
blk = g_malloc(sizeof(BlkMigBlock));
blk->buf = g_malloc(BLOCK_SIZE);
blk->VAR_2 = VAR_2;
blk->sector = cur_sector;
blk->VAR_3 = VAR_3;
blk->iov.iov_base = blk->buf;
blk->iov.iov_len = VAR_3 * BDRV_SECTOR_SIZE;
qemu_iovec_init_external(&blk->qiov, &blk->iov, 1);
if (block_mig_state.submitted == 0) {
block_mig_state.prev_time_offset = qemu_get_clock_ns(rt_clock);
}
blk->aiocb = bdrv_aio_readv(bs, cur_sector, &blk->qiov,
VAR_3, blk_mig_read_cb, blk);
block_mig_state.submitted++;
bdrv_reset_dirty(bs, cur_sector, VAR_3);
VAR_2->cur_sector = cur_sector + VAR_3;
return (VAR_2->cur_sector >= total_sectors);
}
| [
"static int FUNC_0(Monitor *VAR_0, QEMUFile *VAR_1,\nBlkMigDevState *VAR_2)\n{",
"int64_t total_sectors = VAR_2->total_sectors;",
"int64_t cur_sector = VAR_2->cur_sector;",
"BlockDriverState *bs = VAR_2->bs;",
"BlkMigBlock *blk;",
"int VAR_3;",
"if (VAR_2->shared_base) {",
"while (cur_sector < total_sectors &&\n!bdrv_is_allocated(bs, cur_sector, MAX_IS_ALLOCATED_SEARCH,\n&VAR_3)) {",
"cur_sector += VAR_3;",
"}",
"}",
"if (cur_sector >= total_sectors) {",
"VAR_2->cur_sector = VAR_2->completed_sectors = total_sectors;",
"return 1;",
"}",
"VAR_2->completed_sectors = cur_sector;",
"cur_sector &= ~((int64_t)BDRV_SECTORS_PER_DIRTY_CHUNK - 1);",
"VAR_3 = BDRV_SECTORS_PER_DIRTY_CHUNK;",
"if (total_sectors - cur_sector < BDRV_SECTORS_PER_DIRTY_CHUNK) {",
"VAR_3 = total_sectors - cur_sector;",
"}",
"blk = g_malloc(sizeof(BlkMigBlock));",
"blk->buf = g_malloc(BLOCK_SIZE);",
"blk->VAR_2 = VAR_2;",
"blk->sector = cur_sector;",
"blk->VAR_3 = VAR_3;",
"blk->iov.iov_base = blk->buf;",
"blk->iov.iov_len = VAR_3 * BDRV_SECTOR_SIZE;",
"qemu_iovec_init_external(&blk->qiov, &blk->iov, 1);",
"if (block_mig_state.submitted == 0) {",
"block_mig_state.prev_time_offset = qemu_get_clock_ns(rt_clock);",
"}",
"blk->aiocb = bdrv_aio_readv(bs, cur_sector, &blk->qiov,\nVAR_3, blk_mig_read_cb, blk);",
"block_mig_state.submitted++;",
"bdrv_reset_dirty(bs, cur_sector, VAR_3);",
"VAR_2->cur_sector = cur_sector + VAR_3;",
"return (VAR_2->cur_sector >= total_sectors);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21,
23,
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
49
],
[
55
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
95,
97
],
[
99
],
[
103
],
[
105
],
[
109
],
[
111
]
]
|
14,408 | int64_t qemu_clock_get_ns(QEMUClockType type)
{
int64_t now, last;
QEMUClock *clock = qemu_clock_ptr(type);
switch (type) {
case QEMU_CLOCK_REALTIME:
return get_clock();
default:
case QEMU_CLOCK_VIRTUAL:
if (use_icount) {
return cpu_get_icount();
} else {
return cpu_get_clock();
}
case QEMU_CLOCK_HOST:
now = get_clock_realtime();
last = clock->last;
clock->last = now;
if (now < last) {
notifier_list_notify(&clock->reset_notifiers, &now);
}
return now;
case QEMU_CLOCK_VIRTUAL_RT:
return cpu_get_clock();
}
}
| false | qemu | fb1a3a051d89975f26296163066bb0745ecca49d | int64_t qemu_clock_get_ns(QEMUClockType type)
{
int64_t now, last;
QEMUClock *clock = qemu_clock_ptr(type);
switch (type) {
case QEMU_CLOCK_REALTIME:
return get_clock();
default:
case QEMU_CLOCK_VIRTUAL:
if (use_icount) {
return cpu_get_icount();
} else {
return cpu_get_clock();
}
case QEMU_CLOCK_HOST:
now = get_clock_realtime();
last = clock->last;
clock->last = now;
if (now < last) {
notifier_list_notify(&clock->reset_notifiers, &now);
}
return now;
case QEMU_CLOCK_VIRTUAL_RT:
return cpu_get_clock();
}
}
| {
"code": [],
"line_no": []
} | int64_t FUNC_0(QEMUClockType type)
{
int64_t now, last;
QEMUClock *clock = qemu_clock_ptr(type);
switch (type) {
case QEMU_CLOCK_REALTIME:
return get_clock();
default:
case QEMU_CLOCK_VIRTUAL:
if (use_icount) {
return cpu_get_icount();
} else {
return cpu_get_clock();
}
case QEMU_CLOCK_HOST:
now = get_clock_realtime();
last = clock->last;
clock->last = now;
if (now < last) {
notifier_list_notify(&clock->reset_notifiers, &now);
}
return now;
case QEMU_CLOCK_VIRTUAL_RT:
return cpu_get_clock();
}
}
| [
"int64_t FUNC_0(QEMUClockType type)\n{",
"int64_t now, last;",
"QEMUClock *clock = qemu_clock_ptr(type);",
"switch (type) {",
"case QEMU_CLOCK_REALTIME:\nreturn get_clock();",
"default:\ncase QEMU_CLOCK_VIRTUAL:\nif (use_icount) {",
"return cpu_get_icount();",
"} else {",
"return cpu_get_clock();",
"}",
"case QEMU_CLOCK_HOST:\nnow = get_clock_realtime();",
"last = clock->last;",
"clock->last = now;",
"if (now < last) {",
"notifier_list_notify(&clock->reset_notifiers, &now);",
"}",
"return now;",
"case QEMU_CLOCK_VIRTUAL_RT:\nreturn cpu_get_clock();",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
17,
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
]
]
|
14,409 | static void test_acpi_q35_tcg_cphp(void)
{
test_data data;
memset(&data, 0, sizeof(data));
data.machine = MACHINE_Q35;
data.variant = ".cphp";
test_acpi_one(" -smp 2,cores=3,sockets=2,maxcpus=6"
" -numa node -numa node",
&data);
free_test_data(&data);
}
| false | qemu | fda4096fca83dcdc72e0fc0e4a1ae6e7724fb5e0 | static void test_acpi_q35_tcg_cphp(void)
{
test_data data;
memset(&data, 0, sizeof(data));
data.machine = MACHINE_Q35;
data.variant = ".cphp";
test_acpi_one(" -smp 2,cores=3,sockets=2,maxcpus=6"
" -numa node -numa node",
&data);
free_test_data(&data);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
test_data data;
memset(&data, 0, sizeof(data));
data.machine = MACHINE_Q35;
data.variant = ".cphp";
test_acpi_one(" -smp 2,cores=3,sockets=2,maxcpus=6"
" -numa node -numa node",
&data);
free_test_data(&data);
}
| [
"static void FUNC_0(void)\n{",
"test_data data;",
"memset(&data, 0, sizeof(data));",
"data.machine = MACHINE_Q35;",
"data.variant = \".cphp\";",
"test_acpi_one(\" -smp 2,cores=3,sockets=2,maxcpus=6\"\n\" -numa node -numa node\",\n&data);",
"free_test_data(&data);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15,
17,
19
],
[
21
],
[
23
]
]
|
14,411 | int block_job_set_speed(BlockJob *job, int64_t value)
{
int rc;
if (!job->job_type->set_speed) {
return -ENOTSUP;
}
rc = job->job_type->set_speed(job, value);
if (rc == 0) {
job->speed = value;
}
return rc;
}
| false | qemu | 9e6636c72d8d6f0605e23ed820c8487686882b12 | int block_job_set_speed(BlockJob *job, int64_t value)
{
int rc;
if (!job->job_type->set_speed) {
return -ENOTSUP;
}
rc = job->job_type->set_speed(job, value);
if (rc == 0) {
job->speed = value;
}
return rc;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(BlockJob *VAR_0, int64_t VAR_1)
{
int VAR_2;
if (!VAR_0->job_type->set_speed) {
return -ENOTSUP;
}
VAR_2 = VAR_0->job_type->set_speed(VAR_0, VAR_1);
if (VAR_2 == 0) {
VAR_0->speed = VAR_1;
}
return VAR_2;
}
| [
"int FUNC_0(BlockJob *VAR_0, int64_t VAR_1)\n{",
"int VAR_2;",
"if (!VAR_0->job_type->set_speed) {",
"return -ENOTSUP;",
"}",
"VAR_2 = VAR_0->job_type->set_speed(VAR_0, VAR_1);",
"if (VAR_2 == 0) {",
"VAR_0->speed = VAR_1;",
"}",
"return VAR_2;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
]
|
14,412 | static void test_acpi_q35_tcg_memhp(void)
{
test_data data;
memset(&data, 0, sizeof(data));
data.machine = MACHINE_Q35;
data.variant = ".memhp";
test_acpi_one(" -m 128,slots=3,maxmem=1G -numa node", &data);
free_test_data(&data);
}
| false | qemu | fda4096fca83dcdc72e0fc0e4a1ae6e7724fb5e0 | static void test_acpi_q35_tcg_memhp(void)
{
test_data data;
memset(&data, 0, sizeof(data));
data.machine = MACHINE_Q35;
data.variant = ".memhp";
test_acpi_one(" -m 128,slots=3,maxmem=1G -numa node", &data);
free_test_data(&data);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
test_data data;
memset(&data, 0, sizeof(data));
data.machine = MACHINE_Q35;
data.variant = ".memhp";
test_acpi_one(" -m 128,slots=3,maxmem=1G -numa node", &data);
free_test_data(&data);
}
| [
"static void FUNC_0(void)\n{",
"test_data data;",
"memset(&data, 0, sizeof(data));",
"data.machine = MACHINE_Q35;",
"data.variant = \".memhp\";",
"test_acpi_one(\" -m 128,slots=3,maxmem=1G -numa node\", &data);",
"free_test_data(&data);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
]
|
14,414 | void pci_bus_reset(PCIBus *bus)
{
int i;
for (i = 0; i < bus->nirq; i++) {
bus->irq_count[i] = 0;
}
for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
if (bus->devices[i]) {
pci_device_reset(bus->devices[i]);
}
}
}
| false | qemu | 81e3e75b6461c53724fe7c7918bc54468fcdaf9d | void pci_bus_reset(PCIBus *bus)
{
int i;
for (i = 0; i < bus->nirq; i++) {
bus->irq_count[i] = 0;
}
for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
if (bus->devices[i]) {
pci_device_reset(bus->devices[i]);
}
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(PCIBus *VAR_0)
{
int VAR_1;
for (VAR_1 = 0; VAR_1 < VAR_0->nirq; VAR_1++) {
VAR_0->irq_count[VAR_1] = 0;
}
for (VAR_1 = 0; VAR_1 < ARRAY_SIZE(VAR_0->devices); ++VAR_1) {
if (VAR_0->devices[VAR_1]) {
pci_device_reset(VAR_0->devices[VAR_1]);
}
}
}
| [
"void FUNC_0(PCIBus *VAR_0)\n{",
"int VAR_1;",
"for (VAR_1 = 0; VAR_1 < VAR_0->nirq; VAR_1++) {",
"VAR_0->irq_count[VAR_1] = 0;",
"}",
"for (VAR_1 = 0; VAR_1 < ARRAY_SIZE(VAR_0->devices); ++VAR_1) {",
"if (VAR_0->devices[VAR_1]) {",
"pci_device_reset(VAR_0->devices[VAR_1]);",
"}",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
]
|
14,415 | static bool invalid_qmp_mode(const Monitor *mon, const mon_cmd_t *cmd)
{
bool is_cap = cmd->mhandler.cmd_new == do_qmp_capabilities;
if (is_cap && qmp_cmd_mode(mon)) {
qerror_report(ERROR_CLASS_COMMAND_NOT_FOUND,
"Capabilities negotiation is already complete, command "
"'%s' ignored", cmd->name);
return true;
}
if (!is_cap && !qmp_cmd_mode(mon)) {
qerror_report(ERROR_CLASS_COMMAND_NOT_FOUND,
"Expecting capabilities negotiation with "
"'qmp_capabilities' before command '%s'", cmd->name);
return true;
}
return false;
}
| false | qemu | 4086182fcd9b106345b5cc535d78bcc6d13a7683 | static bool invalid_qmp_mode(const Monitor *mon, const mon_cmd_t *cmd)
{
bool is_cap = cmd->mhandler.cmd_new == do_qmp_capabilities;
if (is_cap && qmp_cmd_mode(mon)) {
qerror_report(ERROR_CLASS_COMMAND_NOT_FOUND,
"Capabilities negotiation is already complete, command "
"'%s' ignored", cmd->name);
return true;
}
if (!is_cap && !qmp_cmd_mode(mon)) {
qerror_report(ERROR_CLASS_COMMAND_NOT_FOUND,
"Expecting capabilities negotiation with "
"'qmp_capabilities' before command '%s'", cmd->name);
return true;
}
return false;
}
| {
"code": [],
"line_no": []
} | static bool FUNC_0(const Monitor *mon, const mon_cmd_t *cmd)
{
bool is_cap = cmd->mhandler.cmd_new == do_qmp_capabilities;
if (is_cap && qmp_cmd_mode(mon)) {
qerror_report(ERROR_CLASS_COMMAND_NOT_FOUND,
"Capabilities negotiation is already complete, command "
"'%s' ignored", cmd->name);
return true;
}
if (!is_cap && !qmp_cmd_mode(mon)) {
qerror_report(ERROR_CLASS_COMMAND_NOT_FOUND,
"Expecting capabilities negotiation with "
"'qmp_capabilities' before command '%s'", cmd->name);
return true;
}
return false;
}
| [
"static bool FUNC_0(const Monitor *mon, const mon_cmd_t *cmd)\n{",
"bool is_cap = cmd->mhandler.cmd_new == do_qmp_capabilities;",
"if (is_cap && qmp_cmd_mode(mon)) {",
"qerror_report(ERROR_CLASS_COMMAND_NOT_FOUND,\n\"Capabilities negotiation is already complete, command \"\n\"'%s' ignored\", cmd->name);",
"return true;",
"}",
"if (!is_cap && !qmp_cmd_mode(mon)) {",
"qerror_report(ERROR_CLASS_COMMAND_NOT_FOUND,\n\"Expecting capabilities negotiation with \"\n\"'qmp_capabilities' before command '%s'\", cmd->name);",
"return true;",
"}",
"return false;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9,
11,
13
],
[
15
],
[
17
],
[
19
],
[
21,
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
]
]
|
14,416 | static int encode_ext_header(Wmv2Context *w){
MpegEncContext * const s= &w->s;
PutBitContext pb;
int code;
init_put_bits(&pb, s->avctx->extradata, s->avctx->extradata_size);
put_bits(&pb, 5, s->avctx->time_base.den / s->avctx->time_base.num); //yes 29.97 -> 29
put_bits(&pb, 11, FFMIN(s->bit_rate/1024, 2047));
put_bits(&pb, 1, w->mspel_bit=1);
put_bits(&pb, 1, w->flag3=1);
put_bits(&pb, 1, w->abt_flag=1);
put_bits(&pb, 1, w->j_type_bit=1);
put_bits(&pb, 1, w->top_left_mv_flag=0);
put_bits(&pb, 1, w->per_mb_rl_bit=1);
put_bits(&pb, 3, code=1);
flush_put_bits(&pb);
s->slice_height = s->mb_height / code;
return 0;
}
| false | FFmpeg | a8ff69ce2bad1c4bb043e88ea35f5ab5691d4f3c | static int encode_ext_header(Wmv2Context *w){
MpegEncContext * const s= &w->s;
PutBitContext pb;
int code;
init_put_bits(&pb, s->avctx->extradata, s->avctx->extradata_size);
put_bits(&pb, 5, s->avctx->time_base.den / s->avctx->time_base.num);
put_bits(&pb, 11, FFMIN(s->bit_rate/1024, 2047));
put_bits(&pb, 1, w->mspel_bit=1);
put_bits(&pb, 1, w->flag3=1);
put_bits(&pb, 1, w->abt_flag=1);
put_bits(&pb, 1, w->j_type_bit=1);
put_bits(&pb, 1, w->top_left_mv_flag=0);
put_bits(&pb, 1, w->per_mb_rl_bit=1);
put_bits(&pb, 3, code=1);
flush_put_bits(&pb);
s->slice_height = s->mb_height / code;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(Wmv2Context *VAR_0){
MpegEncContext * const s= &VAR_0->s;
PutBitContext pb;
int VAR_1;
init_put_bits(&pb, s->avctx->extradata, s->avctx->extradata_size);
put_bits(&pb, 5, s->avctx->time_base.den / s->avctx->time_base.num);
put_bits(&pb, 11, FFMIN(s->bit_rate/1024, 2047));
put_bits(&pb, 1, VAR_0->mspel_bit=1);
put_bits(&pb, 1, VAR_0->flag3=1);
put_bits(&pb, 1, VAR_0->abt_flag=1);
put_bits(&pb, 1, VAR_0->j_type_bit=1);
put_bits(&pb, 1, VAR_0->top_left_mv_flag=0);
put_bits(&pb, 1, VAR_0->per_mb_rl_bit=1);
put_bits(&pb, 3, VAR_1=1);
flush_put_bits(&pb);
s->slice_height = s->mb_height / VAR_1;
return 0;
}
| [
"static int FUNC_0(Wmv2Context *VAR_0){",
"MpegEncContext * const s= &VAR_0->s;",
"PutBitContext pb;",
"int VAR_1;",
"init_put_bits(&pb, s->avctx->extradata, s->avctx->extradata_size);",
"put_bits(&pb, 5, s->avctx->time_base.den / s->avctx->time_base.num);",
"put_bits(&pb, 11, FFMIN(s->bit_rate/1024, 2047));",
"put_bits(&pb, 1, VAR_0->mspel_bit=1);",
"put_bits(&pb, 1, VAR_0->flag3=1);",
"put_bits(&pb, 1, VAR_0->abt_flag=1);",
"put_bits(&pb, 1, VAR_0->j_type_bit=1);",
"put_bits(&pb, 1, VAR_0->top_left_mv_flag=0);",
"put_bits(&pb, 1, VAR_0->per_mb_rl_bit=1);",
"put_bits(&pb, 3, VAR_1=1);",
"flush_put_bits(&pb);",
"s->slice_height = s->mb_height / VAR_1;",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1
],
[
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
41
],
[
45
],
[
47
]
]
|
14,417 | static int sd_schedule_bh(QEMUBHFunc *cb, SheepdogAIOCB *acb)
{
if (acb->bh) {
error_report("bug: %d %d\n", acb->aiocb_type, acb->aiocb_type);
return -EIO;
}
acb->bh = qemu_bh_new(cb, acb);
if (!acb->bh) {
error_report("oom: %d %d\n", acb->aiocb_type, acb->aiocb_type);
return -EIO;
}
qemu_bh_schedule(acb->bh);
return 0;
}
| false | qemu | db78ef5b0a93b16ad56b70a70e21b1c5e7d06ba8 | static int sd_schedule_bh(QEMUBHFunc *cb, SheepdogAIOCB *acb)
{
if (acb->bh) {
error_report("bug: %d %d\n", acb->aiocb_type, acb->aiocb_type);
return -EIO;
}
acb->bh = qemu_bh_new(cb, acb);
if (!acb->bh) {
error_report("oom: %d %d\n", acb->aiocb_type, acb->aiocb_type);
return -EIO;
}
qemu_bh_schedule(acb->bh);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(QEMUBHFunc *VAR_0, SheepdogAIOCB *VAR_1)
{
if (VAR_1->bh) {
error_report("bug: %d %d\n", VAR_1->aiocb_type, VAR_1->aiocb_type);
return -EIO;
}
VAR_1->bh = qemu_bh_new(VAR_0, VAR_1);
if (!VAR_1->bh) {
error_report("oom: %d %d\n", VAR_1->aiocb_type, VAR_1->aiocb_type);
return -EIO;
}
qemu_bh_schedule(VAR_1->bh);
return 0;
}
| [
"static int FUNC_0(QEMUBHFunc *VAR_0, SheepdogAIOCB *VAR_1)\n{",
"if (VAR_1->bh) {",
"error_report(\"bug: %d %d\\n\", VAR_1->aiocb_type, VAR_1->aiocb_type);",
"return -EIO;",
"}",
"VAR_1->bh = qemu_bh_new(VAR_0, VAR_1);",
"if (!VAR_1->bh) {",
"error_report(\"oom: %d %d\\n\", VAR_1->aiocb_type, VAR_1->aiocb_type);",
"return -EIO;",
"}",
"qemu_bh_schedule(VAR_1->bh);",
"return 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
],
[
27
],
[
31
],
[
33
]
]
|
14,418 | static int uhci_handle_td(UHCIState *s, UHCIQueue *q, uint32_t qh_addr,
UHCI_TD *td, uint32_t td_addr, uint32_t *int_mask)
{
int len = 0, max_len;
bool spd;
bool queuing = (q != NULL);
uint8_t pid = td->token & 0xff;
UHCIAsync *async = uhci_async_find_td(s, td_addr);
if (async) {
if (uhci_queue_verify(async->queue, qh_addr, td, td_addr, queuing)) {
assert(q == NULL || q == async->queue);
q = async->queue;
} else {
uhci_queue_free(async->queue, "guest re-used pending td");
async = NULL;
}
}
if (q == NULL) {
q = uhci_queue_find(s, td);
if (q && !uhci_queue_verify(q, qh_addr, td, td_addr, queuing)) {
uhci_queue_free(q, "guest re-used qh");
q = NULL;
}
}
if (q) {
q->valid = 32;
}
/* Is active ? */
if (!(td->ctrl & TD_CTRL_ACTIVE)) {
if (async) {
/* Guest marked a pending td non-active, cancel the queue */
uhci_queue_free(async->queue, "pending td non-active");
}
/*
* ehci11d spec page 22: "Even if the Active bit in the TD is already
* cleared when the TD is fetched ... an IOC interrupt is generated"
*/
if (td->ctrl & TD_CTRL_IOC) {
*int_mask |= 0x01;
}
return TD_RESULT_NEXT_QH;
}
if (async) {
if (!async->done)
return TD_RESULT_ASYNC_CONT;
if (queuing) {
/* we are busy filling the queue, we are not prepared
to consume completed packages then, just leave them
in async state */
return TD_RESULT_ASYNC_CONT;
}
uhci_async_unlink(async);
goto done;
}
/* Allocate new packet */
if (q == NULL) {
USBDevice *dev = uhci_find_device(s, (td->token >> 8) & 0x7f);
USBEndpoint *ep = usb_ep_get(dev, pid, (td->token >> 15) & 0xf);
q = uhci_queue_new(s, qh_addr, td, ep);
}
async = uhci_async_alloc(q, td_addr);
max_len = ((td->token >> 21) + 1) & 0x7ff;
spd = (pid == USB_TOKEN_IN && (td->ctrl & TD_CTRL_SPD) != 0);
usb_packet_setup(&async->packet, pid, q->ep, td_addr, spd,
(td->ctrl & TD_CTRL_IOC) != 0);
qemu_sglist_add(&async->sgl, td->buffer, max_len);
usb_packet_map(&async->packet, &async->sgl);
switch(pid) {
case USB_TOKEN_OUT:
case USB_TOKEN_SETUP:
len = usb_handle_packet(q->ep->dev, &async->packet);
if (len >= 0)
len = max_len;
break;
case USB_TOKEN_IN:
len = usb_handle_packet(q->ep->dev, &async->packet);
break;
default:
/* invalid pid : frame interrupted */
usb_packet_unmap(&async->packet, &async->sgl);
uhci_async_free(async);
s->status |= UHCI_STS_HCPERR;
uhci_update_irq(s);
return TD_RESULT_STOP_FRAME;
}
if (len == USB_RET_ASYNC) {
uhci_async_link(async);
if (!queuing) {
uhci_queue_fill(q, td);
}
return TD_RESULT_ASYNC_START;
}
async->packet.result = len;
done:
len = uhci_complete_td(s, td, async, int_mask);
usb_packet_unmap(&async->packet, &async->sgl);
uhci_async_free(async);
return len;
}
| false | qemu | 8928c9c43df1a0eeda1ae2e9582beb34dce49330 | static int uhci_handle_td(UHCIState *s, UHCIQueue *q, uint32_t qh_addr,
UHCI_TD *td, uint32_t td_addr, uint32_t *int_mask)
{
int len = 0, max_len;
bool spd;
bool queuing = (q != NULL);
uint8_t pid = td->token & 0xff;
UHCIAsync *async = uhci_async_find_td(s, td_addr);
if (async) {
if (uhci_queue_verify(async->queue, qh_addr, td, td_addr, queuing)) {
assert(q == NULL || q == async->queue);
q = async->queue;
} else {
uhci_queue_free(async->queue, "guest re-used pending td");
async = NULL;
}
}
if (q == NULL) {
q = uhci_queue_find(s, td);
if (q && !uhci_queue_verify(q, qh_addr, td, td_addr, queuing)) {
uhci_queue_free(q, "guest re-used qh");
q = NULL;
}
}
if (q) {
q->valid = 32;
}
if (!(td->ctrl & TD_CTRL_ACTIVE)) {
if (async) {
uhci_queue_free(async->queue, "pending td non-active");
}
if (td->ctrl & TD_CTRL_IOC) {
*int_mask |= 0x01;
}
return TD_RESULT_NEXT_QH;
}
if (async) {
if (!async->done)
return TD_RESULT_ASYNC_CONT;
if (queuing) {
return TD_RESULT_ASYNC_CONT;
}
uhci_async_unlink(async);
goto done;
}
if (q == NULL) {
USBDevice *dev = uhci_find_device(s, (td->token >> 8) & 0x7f);
USBEndpoint *ep = usb_ep_get(dev, pid, (td->token >> 15) & 0xf);
q = uhci_queue_new(s, qh_addr, td, ep);
}
async = uhci_async_alloc(q, td_addr);
max_len = ((td->token >> 21) + 1) & 0x7ff;
spd = (pid == USB_TOKEN_IN && (td->ctrl & TD_CTRL_SPD) != 0);
usb_packet_setup(&async->packet, pid, q->ep, td_addr, spd,
(td->ctrl & TD_CTRL_IOC) != 0);
qemu_sglist_add(&async->sgl, td->buffer, max_len);
usb_packet_map(&async->packet, &async->sgl);
switch(pid) {
case USB_TOKEN_OUT:
case USB_TOKEN_SETUP:
len = usb_handle_packet(q->ep->dev, &async->packet);
if (len >= 0)
len = max_len;
break;
case USB_TOKEN_IN:
len = usb_handle_packet(q->ep->dev, &async->packet);
break;
default:
usb_packet_unmap(&async->packet, &async->sgl);
uhci_async_free(async);
s->status |= UHCI_STS_HCPERR;
uhci_update_irq(s);
return TD_RESULT_STOP_FRAME;
}
if (len == USB_RET_ASYNC) {
uhci_async_link(async);
if (!queuing) {
uhci_queue_fill(q, td);
}
return TD_RESULT_ASYNC_START;
}
async->packet.result = len;
done:
len = uhci_complete_td(s, td, async, int_mask);
usb_packet_unmap(&async->packet, &async->sgl);
uhci_async_free(async);
return len;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(UHCIState *VAR_0, UHCIQueue *VAR_1, uint32_t VAR_2,
UHCI_TD *VAR_3, uint32_t VAR_4, uint32_t *VAR_5)
{
int VAR_6 = 0, VAR_7;
bool spd;
bool queuing = (VAR_1 != NULL);
uint8_t pid = VAR_3->token & 0xff;
UHCIAsync *async = uhci_async_find_td(VAR_0, VAR_4);
if (async) {
if (uhci_queue_verify(async->queue, VAR_2, VAR_3, VAR_4, queuing)) {
assert(VAR_1 == NULL || VAR_1 == async->queue);
VAR_1 = async->queue;
} else {
uhci_queue_free(async->queue, "guest re-used pending VAR_3");
async = NULL;
}
}
if (VAR_1 == NULL) {
VAR_1 = uhci_queue_find(VAR_0, VAR_3);
if (VAR_1 && !uhci_queue_verify(VAR_1, VAR_2, VAR_3, VAR_4, queuing)) {
uhci_queue_free(VAR_1, "guest re-used qh");
VAR_1 = NULL;
}
}
if (VAR_1) {
VAR_1->valid = 32;
}
if (!(VAR_3->ctrl & TD_CTRL_ACTIVE)) {
if (async) {
uhci_queue_free(async->queue, "pending VAR_3 non-active");
}
if (VAR_3->ctrl & TD_CTRL_IOC) {
*VAR_5 |= 0x01;
}
return TD_RESULT_NEXT_QH;
}
if (async) {
if (!async->done)
return TD_RESULT_ASYNC_CONT;
if (queuing) {
return TD_RESULT_ASYNC_CONT;
}
uhci_async_unlink(async);
goto done;
}
if (VAR_1 == NULL) {
USBDevice *dev = uhci_find_device(VAR_0, (VAR_3->token >> 8) & 0x7f);
USBEndpoint *ep = usb_ep_get(dev, pid, (VAR_3->token >> 15) & 0xf);
VAR_1 = uhci_queue_new(VAR_0, VAR_2, VAR_3, ep);
}
async = uhci_async_alloc(VAR_1, VAR_4);
VAR_7 = ((VAR_3->token >> 21) + 1) & 0x7ff;
spd = (pid == USB_TOKEN_IN && (VAR_3->ctrl & TD_CTRL_SPD) != 0);
usb_packet_setup(&async->packet, pid, VAR_1->ep, VAR_4, spd,
(VAR_3->ctrl & TD_CTRL_IOC) != 0);
qemu_sglist_add(&async->sgl, VAR_3->buffer, VAR_7);
usb_packet_map(&async->packet, &async->sgl);
switch(pid) {
case USB_TOKEN_OUT:
case USB_TOKEN_SETUP:
VAR_6 = usb_handle_packet(VAR_1->ep->dev, &async->packet);
if (VAR_6 >= 0)
VAR_6 = VAR_7;
break;
case USB_TOKEN_IN:
VAR_6 = usb_handle_packet(VAR_1->ep->dev, &async->packet);
break;
default:
usb_packet_unmap(&async->packet, &async->sgl);
uhci_async_free(async);
VAR_0->status |= UHCI_STS_HCPERR;
uhci_update_irq(VAR_0);
return TD_RESULT_STOP_FRAME;
}
if (VAR_6 == USB_RET_ASYNC) {
uhci_async_link(async);
if (!queuing) {
uhci_queue_fill(VAR_1, VAR_3);
}
return TD_RESULT_ASYNC_START;
}
async->packet.result = VAR_6;
done:
VAR_6 = uhci_complete_td(VAR_0, VAR_3, async, VAR_5);
usb_packet_unmap(&async->packet, &async->sgl);
uhci_async_free(async);
return VAR_6;
}
| [
"static int FUNC_0(UHCIState *VAR_0, UHCIQueue *VAR_1, uint32_t VAR_2,\nUHCI_TD *VAR_3, uint32_t VAR_4, uint32_t *VAR_5)\n{",
"int VAR_6 = 0, VAR_7;",
"bool spd;",
"bool queuing = (VAR_1 != NULL);",
"uint8_t pid = VAR_3->token & 0xff;",
"UHCIAsync *async = uhci_async_find_td(VAR_0, VAR_4);",
"if (async) {",
"if (uhci_queue_verify(async->queue, VAR_2, VAR_3, VAR_4, queuing)) {",
"assert(VAR_1 == NULL || VAR_1 == async->queue);",
"VAR_1 = async->queue;",
"} else {",
"uhci_queue_free(async->queue, \"guest re-used pending VAR_3\");",
"async = NULL;",
"}",
"}",
"if (VAR_1 == NULL) {",
"VAR_1 = uhci_queue_find(VAR_0, VAR_3);",
"if (VAR_1 && !uhci_queue_verify(VAR_1, VAR_2, VAR_3, VAR_4, queuing)) {",
"uhci_queue_free(VAR_1, \"guest re-used qh\");",
"VAR_1 = NULL;",
"}",
"}",
"if (VAR_1) {",
"VAR_1->valid = 32;",
"}",
"if (!(VAR_3->ctrl & TD_CTRL_ACTIVE)) {",
"if (async) {",
"uhci_queue_free(async->queue, \"pending VAR_3 non-active\");",
"}",
"if (VAR_3->ctrl & TD_CTRL_IOC) {",
"*VAR_5 |= 0x01;",
"}",
"return TD_RESULT_NEXT_QH;",
"}",
"if (async) {",
"if (!async->done)\nreturn TD_RESULT_ASYNC_CONT;",
"if (queuing) {",
"return TD_RESULT_ASYNC_CONT;",
"}",
"uhci_async_unlink(async);",
"goto done;",
"}",
"if (VAR_1 == NULL) {",
"USBDevice *dev = uhci_find_device(VAR_0, (VAR_3->token >> 8) & 0x7f);",
"USBEndpoint *ep = usb_ep_get(dev, pid, (VAR_3->token >> 15) & 0xf);",
"VAR_1 = uhci_queue_new(VAR_0, VAR_2, VAR_3, ep);",
"}",
"async = uhci_async_alloc(VAR_1, VAR_4);",
"VAR_7 = ((VAR_3->token >> 21) + 1) & 0x7ff;",
"spd = (pid == USB_TOKEN_IN && (VAR_3->ctrl & TD_CTRL_SPD) != 0);",
"usb_packet_setup(&async->packet, pid, VAR_1->ep, VAR_4, spd,\n(VAR_3->ctrl & TD_CTRL_IOC) != 0);",
"qemu_sglist_add(&async->sgl, VAR_3->buffer, VAR_7);",
"usb_packet_map(&async->packet, &async->sgl);",
"switch(pid) {",
"case USB_TOKEN_OUT:\ncase USB_TOKEN_SETUP:\nVAR_6 = usb_handle_packet(VAR_1->ep->dev, &async->packet);",
"if (VAR_6 >= 0)\nVAR_6 = VAR_7;",
"break;",
"case USB_TOKEN_IN:\nVAR_6 = usb_handle_packet(VAR_1->ep->dev, &async->packet);",
"break;",
"default:\nusb_packet_unmap(&async->packet, &async->sgl);",
"uhci_async_free(async);",
"VAR_0->status |= UHCI_STS_HCPERR;",
"uhci_update_irq(VAR_0);",
"return TD_RESULT_STOP_FRAME;",
"}",
"if (VAR_6 == USB_RET_ASYNC) {",
"uhci_async_link(async);",
"if (!queuing) {",
"uhci_queue_fill(VAR_1, VAR_3);",
"}",
"return TD_RESULT_ASYNC_START;",
"}",
"async->packet.result = VAR_6;",
"done:\nVAR_6 = uhci_complete_td(VAR_0, VAR_3, async, VAR_5);",
"usb_packet_unmap(&async->packet, &async->sgl);",
"uhci_async_free(async);",
"return VAR_6;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
65
],
[
67
],
[
71
],
[
73
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97,
99
],
[
101
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
139
],
[
141
],
[
143,
145
],
[
147
],
[
149
],
[
153
],
[
155,
157,
159
],
[
161,
163
],
[
165
],
[
169,
171
],
[
173
],
[
177,
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
211
],
[
215,
217
],
[
219
],
[
221
],
[
223
],
[
225
]
]
|
14,419 | static int ccid_handle_data(USBDevice *dev, USBPacket *p)
{
USBCCIDState *s = DO_UPCAST(USBCCIDState, dev, dev);
int ret = 0;
uint8_t buf[2];
switch (p->pid) {
case USB_TOKEN_OUT:
ret = ccid_handle_bulk_out(s, p);
break;
case USB_TOKEN_IN:
switch (p->devep & 0xf) {
case CCID_BULK_IN_EP:
if (!p->iov.size) {
ret = USB_RET_NAK;
} else {
ret = ccid_bulk_in_copy_to_guest(s, p);
}
break;
case CCID_INT_IN_EP:
if (s->notify_slot_change) {
/* page 56, RDR_to_PC_NotifySlotChange */
buf[0] = CCID_MESSAGE_TYPE_RDR_to_PC_NotifySlotChange;
buf[1] = s->bmSlotICCState;
usb_packet_copy(p, buf, 2);
ret = 2;
s->notify_slot_change = false;
s->bmSlotICCState &= ~SLOT_0_CHANGED_MASK;
DPRINTF(s, D_INFO,
"handle_data: int_in: notify_slot_change %X, "
"requested len %zd\n",
s->bmSlotICCState, p->iov.size);
}
break;
default:
DPRINTF(s, 1, "Bad endpoint\n");
ret = USB_RET_STALL;
break;
}
break;
default:
DPRINTF(s, 1, "Bad token\n");
ret = USB_RET_STALL;
break;
}
return ret;
}
| false | qemu | 079d0b7f1eedcc634c371fe05b617fdc55c8b762 | static int ccid_handle_data(USBDevice *dev, USBPacket *p)
{
USBCCIDState *s = DO_UPCAST(USBCCIDState, dev, dev);
int ret = 0;
uint8_t buf[2];
switch (p->pid) {
case USB_TOKEN_OUT:
ret = ccid_handle_bulk_out(s, p);
break;
case USB_TOKEN_IN:
switch (p->devep & 0xf) {
case CCID_BULK_IN_EP:
if (!p->iov.size) {
ret = USB_RET_NAK;
} else {
ret = ccid_bulk_in_copy_to_guest(s, p);
}
break;
case CCID_INT_IN_EP:
if (s->notify_slot_change) {
buf[0] = CCID_MESSAGE_TYPE_RDR_to_PC_NotifySlotChange;
buf[1] = s->bmSlotICCState;
usb_packet_copy(p, buf, 2);
ret = 2;
s->notify_slot_change = false;
s->bmSlotICCState &= ~SLOT_0_CHANGED_MASK;
DPRINTF(s, D_INFO,
"handle_data: int_in: notify_slot_change %X, "
"requested len %zd\n",
s->bmSlotICCState, p->iov.size);
}
break;
default:
DPRINTF(s, 1, "Bad endpoint\n");
ret = USB_RET_STALL;
break;
}
break;
default:
DPRINTF(s, 1, "Bad token\n");
ret = USB_RET_STALL;
break;
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)
{
USBCCIDState *s = DO_UPCAST(USBCCIDState, VAR_0, VAR_0);
int VAR_2 = 0;
uint8_t buf[2];
switch (VAR_1->pid) {
case USB_TOKEN_OUT:
VAR_2 = ccid_handle_bulk_out(s, VAR_1);
break;
case USB_TOKEN_IN:
switch (VAR_1->devep & 0xf) {
case CCID_BULK_IN_EP:
if (!VAR_1->iov.size) {
VAR_2 = USB_RET_NAK;
} else {
VAR_2 = ccid_bulk_in_copy_to_guest(s, VAR_1);
}
break;
case CCID_INT_IN_EP:
if (s->notify_slot_change) {
buf[0] = CCID_MESSAGE_TYPE_RDR_to_PC_NotifySlotChange;
buf[1] = s->bmSlotICCState;
usb_packet_copy(VAR_1, buf, 2);
VAR_2 = 2;
s->notify_slot_change = false;
s->bmSlotICCState &= ~SLOT_0_CHANGED_MASK;
DPRINTF(s, D_INFO,
"handle_data: int_in: notify_slot_change %X, "
"requested len %zd\n",
s->bmSlotICCState, VAR_1->iov.size);
}
break;
default:
DPRINTF(s, 1, "Bad endpoint\n");
VAR_2 = USB_RET_STALL;
break;
}
break;
default:
DPRINTF(s, 1, "Bad token\n");
VAR_2 = USB_RET_STALL;
break;
}
return VAR_2;
}
| [
"static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)\n{",
"USBCCIDState *s = DO_UPCAST(USBCCIDState, VAR_0, VAR_0);",
"int VAR_2 = 0;",
"uint8_t buf[2];",
"switch (VAR_1->pid) {",
"case USB_TOKEN_OUT:\nVAR_2 = ccid_handle_bulk_out(s, VAR_1);",
"break;",
"case USB_TOKEN_IN:\nswitch (VAR_1->devep & 0xf) {",
"case CCID_BULK_IN_EP:\nif (!VAR_1->iov.size) {",
"VAR_2 = USB_RET_NAK;",
"} else {",
"VAR_2 = ccid_bulk_in_copy_to_guest(s, VAR_1);",
"}",
"break;",
"case CCID_INT_IN_EP:\nif (s->notify_slot_change) {",
"buf[0] = CCID_MESSAGE_TYPE_RDR_to_PC_NotifySlotChange;",
"buf[1] = s->bmSlotICCState;",
"usb_packet_copy(VAR_1, buf, 2);",
"VAR_2 = 2;",
"s->notify_slot_change = false;",
"s->bmSlotICCState &= ~SLOT_0_CHANGED_MASK;",
"DPRINTF(s, D_INFO,\n\"handle_data: int_in: notify_slot_change %X, \"\n\"requested len %zd\\n\",\ns->bmSlotICCState, VAR_1->iov.size);",
"}",
"break;",
"default:\nDPRINTF(s, 1, \"Bad endpoint\\n\");",
"VAR_2 = USB_RET_STALL;",
"break;",
"}",
"break;",
"default:\nDPRINTF(s, 1, \"Bad token\\n\");",
"VAR_2 = USB_RET_STALL;",
"break;",
"}",
"return VAR_2;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
23,
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59,
61,
63,
65
],
[
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
]
]
|
14,420 | char *g_strconcat(const char *s, ...)
{
char *s;
/*
* Can't model: last argument must be null, the others
* null-terminated strings
*/
s = __coverity_alloc_nosize__();
__coverity_writeall__(s);
__coverity_mark_as_afm_allocated__(s, AFM_free);
return s;
}
| false | qemu | 7ad4c7200111d20eb97eed4f46b6026e3f0b0eef | char *g_strconcat(const char *s, ...)
{
char *s;
s = __coverity_alloc_nosize__();
__coverity_writeall__(s);
__coverity_mark_as_afm_allocated__(s, AFM_free);
return s;
}
| {
"code": [],
"line_no": []
} | char *FUNC_0(const char *VAR_1, ...)
{
char *VAR_1;
VAR_1 = __coverity_alloc_nosize__();
__coverity_writeall__(VAR_1);
__coverity_mark_as_afm_allocated__(VAR_1, AFM_free);
return VAR_1;
}
| [
"char *FUNC_0(const char *VAR_1, ...)\n{",
"char *VAR_1;",
"VAR_1 = __coverity_alloc_nosize__();",
"__coverity_writeall__(VAR_1);",
"__coverity_mark_as_afm_allocated__(VAR_1, AFM_free);",
"return VAR_1;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
]
|
14,421 | static void test_qemu_strtoul_max(void)
{
char *str = g_strdup_printf("%lu", ULONG_MAX);
char f = 'X';
const char *endptr = &f;
unsigned long res = 999;
int err;
err = qemu_strtoul(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, ULONG_MAX);
g_assert(endptr == str + strlen(str));
g_free(str);
}
| false | qemu | bc7c08a2c375acb7ae4d433054415588b176d34c | static void test_qemu_strtoul_max(void)
{
char *str = g_strdup_printf("%lu", ULONG_MAX);
char f = 'X';
const char *endptr = &f;
unsigned long res = 999;
int err;
err = qemu_strtoul(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, ULONG_MAX);
g_assert(endptr == str + strlen(str));
g_free(str);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
char *VAR_0 = g_strdup_printf("%lu", ULONG_MAX);
char VAR_1 = 'X';
const char *VAR_2 = &VAR_1;
unsigned long VAR_3 = 999;
int VAR_4;
VAR_4 = qemu_strtoul(VAR_0, &VAR_2, 0, &VAR_3);
g_assert_cmpint(VAR_4, ==, 0);
g_assert_cmpint(VAR_3, ==, ULONG_MAX);
g_assert(VAR_2 == VAR_0 + strlen(VAR_0));
g_free(VAR_0);
}
| [
"static void FUNC_0(void)\n{",
"char *VAR_0 = g_strdup_printf(\"%lu\", ULONG_MAX);",
"char VAR_1 = 'X';",
"const char *VAR_2 = &VAR_1;",
"unsigned long VAR_3 = 999;",
"int VAR_4;",
"VAR_4 = qemu_strtoul(VAR_0, &VAR_2, 0, &VAR_3);",
"g_assert_cmpint(VAR_4, ==, 0);",
"g_assert_cmpint(VAR_3, ==, ULONG_MAX);",
"g_assert(VAR_2 == VAR_0 + strlen(VAR_0));",
"g_free(VAR_0);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
]
|
14,422 | static int coroutine_enter_func(void *arg)
{
Coroutine *co = arg;
qemu_coroutine_enter(co, NULL);
return 0;
}
| false | qemu | fe52840c8760122257be7b7e4893dd951480a71f | static int coroutine_enter_func(void *arg)
{
Coroutine *co = arg;
qemu_coroutine_enter(co, NULL);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(void *VAR_0)
{
Coroutine *co = VAR_0;
qemu_coroutine_enter(co, NULL);
return 0;
}
| [
"static int FUNC_0(void *VAR_0)\n{",
"Coroutine *co = VAR_0;",
"qemu_coroutine_enter(co, NULL);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
]
|
14,423 | START_TEST(qdict_new_test)
{
QDict *qdict;
qdict = qdict_new();
fail_unless(qdict != NULL);
fail_unless(qdict_size(qdict) == 0);
fail_unless(qdict->base.refcnt == 1);
fail_unless(qobject_type(QOBJECT(qdict)) == QTYPE_QDICT);
// destroy doesn't exit yet
free(qdict);
}
| false | qemu | ac531cb6e542b1e61d668604adf9dc5306a948c0 | START_TEST(qdict_new_test)
{
QDict *qdict;
qdict = qdict_new();
fail_unless(qdict != NULL);
fail_unless(qdict_size(qdict) == 0);
fail_unless(qdict->base.refcnt == 1);
fail_unless(qobject_type(QOBJECT(qdict)) == QTYPE_QDICT);
free(qdict);
}
| {
"code": [],
"line_no": []
} | FUNC_0(VAR_0)
{
QDict *qdict;
qdict = qdict_new();
fail_unless(qdict != NULL);
fail_unless(qdict_size(qdict) == 0);
fail_unless(qdict->base.refcnt == 1);
fail_unless(qobject_type(QOBJECT(qdict)) == QTYPE_QDICT);
free(qdict);
}
| [
"FUNC_0(VAR_0)\n{",
"QDict *qdict;",
"qdict = qdict_new();",
"fail_unless(qdict != NULL);",
"fail_unless(qdict_size(qdict) == 0);",
"fail_unless(qdict->base.refcnt == 1);",
"fail_unless(qobject_type(QOBJECT(qdict)) == QTYPE_QDICT);",
"free(qdict);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
]
]
|
14,424 | int print_insn_xtensa(bfd_vma memaddr, struct disassemble_info *info)
{
xtensa_isa isa = info->private_data;
xtensa_insnbuf insnbuf = xtensa_insnbuf_alloc(isa);
xtensa_insnbuf slotbuf = xtensa_insnbuf_alloc(isa);
bfd_byte *buffer = g_malloc(1);
int status = info->read_memory_func(memaddr, buffer, 1, info);
xtensa_format fmt;
unsigned slot, slots;
unsigned len;
if (status) {
info->memory_error_func(status, memaddr, info);
len = -1;
goto out;
}
len = xtensa_isa_length_from_chars(isa, buffer);
if (len == XTENSA_UNDEFINED) {
info->fprintf_func(info->stream, ".byte 0x%02x", buffer[0]);
len = 1;
goto out;
}
buffer = g_realloc(buffer, len);
status = info->read_memory_func(memaddr + 1, buffer + 1, len - 1, info);
if (status) {
info->fprintf_func(info->stream, ".byte 0x%02x", buffer[0]);
info->memory_error_func(status, memaddr + 1, info);
len = 1;
goto out;
}
xtensa_insnbuf_from_chars(isa, insnbuf, buffer, len);
fmt = xtensa_format_decode(isa, insnbuf);
if (fmt == XTENSA_UNDEFINED) {
unsigned i;
for (i = 0; i < len; ++i) {
info->fprintf_func(info->stream, "%s 0x%02x",
i ? ", " : ".byte ", buffer[i]);
}
goto out;
}
slots = xtensa_format_num_slots(isa, fmt);
if (slots > 1) {
info->fprintf_func(info->stream, "{ ");
}
for (slot = 0; slot < slots; ++slot) {
xtensa_opcode opc;
unsigned opnd, vopnd, opnds;
if (slot) {
info->fprintf_func(info->stream, "; ");
}
xtensa_format_get_slot(isa, fmt, slot, insnbuf, slotbuf);
opc = xtensa_opcode_decode(isa, fmt, slot, slotbuf);
if (opc == XTENSA_UNDEFINED) {
info->fprintf_func(info->stream, "???");
continue;
}
opnds = xtensa_opcode_num_operands(isa, opc);
info->fprintf_func(info->stream, "%s", xtensa_opcode_name(isa, opc));
for (opnd = vopnd = 0; opnd < opnds; ++opnd) {
if (xtensa_operand_is_visible(isa, opc, opnd)) {
uint32_t v = 0xbadc0de;
int rc;
info->fprintf_func(info->stream, vopnd ? ", " : "\t");
xtensa_operand_get_field(isa, opc, opnd, fmt, slot,
slotbuf, &v);
rc = xtensa_operand_decode(isa, opc, opnd, &v);
if (rc == XTENSA_UNDEFINED) {
info->fprintf_func(info->stream, "???");
} else if (xtensa_operand_is_register(isa, opc, opnd)) {
xtensa_regfile rf = xtensa_operand_regfile(isa, opc, opnd);
info->fprintf_func(info->stream, "%s%d",
xtensa_regfile_shortname(isa, rf), v);
} else if (xtensa_operand_is_PCrelative(isa, opc, opnd)) {
xtensa_operand_undo_reloc(isa, opc, opnd, &v, memaddr);
info->fprintf_func(info->stream, "0x%x", v);
} else {
info->fprintf_func(info->stream, "%d", v);
}
++vopnd;
}
}
}
if (slots > 1) {
info->fprintf_func(info->stream, " }");
}
out:
g_free(buffer);
xtensa_insnbuf_free(isa, insnbuf);
xtensa_insnbuf_free(isa, slotbuf);
return len;
}
| false | qemu | 847a6473206607bc6c84f6c537a0fe603ff7aaa6 | int print_insn_xtensa(bfd_vma memaddr, struct disassemble_info *info)
{
xtensa_isa isa = info->private_data;
xtensa_insnbuf insnbuf = xtensa_insnbuf_alloc(isa);
xtensa_insnbuf slotbuf = xtensa_insnbuf_alloc(isa);
bfd_byte *buffer = g_malloc(1);
int status = info->read_memory_func(memaddr, buffer, 1, info);
xtensa_format fmt;
unsigned slot, slots;
unsigned len;
if (status) {
info->memory_error_func(status, memaddr, info);
len = -1;
goto out;
}
len = xtensa_isa_length_from_chars(isa, buffer);
if (len == XTENSA_UNDEFINED) {
info->fprintf_func(info->stream, ".byte 0x%02x", buffer[0]);
len = 1;
goto out;
}
buffer = g_realloc(buffer, len);
status = info->read_memory_func(memaddr + 1, buffer + 1, len - 1, info);
if (status) {
info->fprintf_func(info->stream, ".byte 0x%02x", buffer[0]);
info->memory_error_func(status, memaddr + 1, info);
len = 1;
goto out;
}
xtensa_insnbuf_from_chars(isa, insnbuf, buffer, len);
fmt = xtensa_format_decode(isa, insnbuf);
if (fmt == XTENSA_UNDEFINED) {
unsigned i;
for (i = 0; i < len; ++i) {
info->fprintf_func(info->stream, "%s 0x%02x",
i ? ", " : ".byte ", buffer[i]);
}
goto out;
}
slots = xtensa_format_num_slots(isa, fmt);
if (slots > 1) {
info->fprintf_func(info->stream, "{ ");
}
for (slot = 0; slot < slots; ++slot) {
xtensa_opcode opc;
unsigned opnd, vopnd, opnds;
if (slot) {
info->fprintf_func(info->stream, "; ");
}
xtensa_format_get_slot(isa, fmt, slot, insnbuf, slotbuf);
opc = xtensa_opcode_decode(isa, fmt, slot, slotbuf);
if (opc == XTENSA_UNDEFINED) {
info->fprintf_func(info->stream, "???");
continue;
}
opnds = xtensa_opcode_num_operands(isa, opc);
info->fprintf_func(info->stream, "%s", xtensa_opcode_name(isa, opc));
for (opnd = vopnd = 0; opnd < opnds; ++opnd) {
if (xtensa_operand_is_visible(isa, opc, opnd)) {
uint32_t v = 0xbadc0de;
int rc;
info->fprintf_func(info->stream, vopnd ? ", " : "\t");
xtensa_operand_get_field(isa, opc, opnd, fmt, slot,
slotbuf, &v);
rc = xtensa_operand_decode(isa, opc, opnd, &v);
if (rc == XTENSA_UNDEFINED) {
info->fprintf_func(info->stream, "???");
} else if (xtensa_operand_is_register(isa, opc, opnd)) {
xtensa_regfile rf = xtensa_operand_regfile(isa, opc, opnd);
info->fprintf_func(info->stream, "%s%d",
xtensa_regfile_shortname(isa, rf), v);
} else if (xtensa_operand_is_PCrelative(isa, opc, opnd)) {
xtensa_operand_undo_reloc(isa, opc, opnd, &v, memaddr);
info->fprintf_func(info->stream, "0x%x", v);
} else {
info->fprintf_func(info->stream, "%d", v);
}
++vopnd;
}
}
}
if (slots > 1) {
info->fprintf_func(info->stream, " }");
}
out:
g_free(buffer);
xtensa_insnbuf_free(isa, insnbuf);
xtensa_insnbuf_free(isa, slotbuf);
return len;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(bfd_vma VAR_0, struct disassemble_info *VAR_1)
{
xtensa_isa isa = VAR_1->private_data;
xtensa_insnbuf insnbuf = xtensa_insnbuf_alloc(isa);
xtensa_insnbuf slotbuf = xtensa_insnbuf_alloc(isa);
bfd_byte *buffer = g_malloc(1);
int VAR_2 = VAR_1->read_memory_func(VAR_0, buffer, 1, VAR_1);
xtensa_format fmt;
unsigned VAR_3, VAR_4;
unsigned VAR_5;
if (VAR_2) {
VAR_1->memory_error_func(VAR_2, VAR_0, VAR_1);
VAR_5 = -1;
goto out;
}
VAR_5 = xtensa_isa_length_from_chars(isa, buffer);
if (VAR_5 == XTENSA_UNDEFINED) {
VAR_1->fprintf_func(VAR_1->stream, ".byte 0x%02x", buffer[0]);
VAR_5 = 1;
goto out;
}
buffer = g_realloc(buffer, VAR_5);
VAR_2 = VAR_1->read_memory_func(VAR_0 + 1, buffer + 1, VAR_5 - 1, VAR_1);
if (VAR_2) {
VAR_1->fprintf_func(VAR_1->stream, ".byte 0x%02x", buffer[0]);
VAR_1->memory_error_func(VAR_2, VAR_0 + 1, VAR_1);
VAR_5 = 1;
goto out;
}
xtensa_insnbuf_from_chars(isa, insnbuf, buffer, VAR_5);
fmt = xtensa_format_decode(isa, insnbuf);
if (fmt == XTENSA_UNDEFINED) {
unsigned VAR_6;
for (VAR_6 = 0; VAR_6 < VAR_5; ++VAR_6) {
VAR_1->fprintf_func(VAR_1->stream, "%s 0x%02x",
VAR_6 ? ", " : ".byte ", buffer[VAR_6]);
}
goto out;
}
VAR_4 = xtensa_format_num_slots(isa, fmt);
if (VAR_4 > 1) {
VAR_1->fprintf_func(VAR_1->stream, "{ ");
}
for (VAR_3 = 0; VAR_3 < VAR_4; ++VAR_3) {
xtensa_opcode opc;
unsigned VAR_7, VAR_8, VAR_9;
if (VAR_3) {
VAR_1->fprintf_func(VAR_1->stream, "; ");
}
xtensa_format_get_slot(isa, fmt, VAR_3, insnbuf, slotbuf);
opc = xtensa_opcode_decode(isa, fmt, VAR_3, slotbuf);
if (opc == XTENSA_UNDEFINED) {
VAR_1->fprintf_func(VAR_1->stream, "???");
continue;
}
VAR_9 = xtensa_opcode_num_operands(isa, opc);
VAR_1->fprintf_func(VAR_1->stream, "%s", xtensa_opcode_name(isa, opc));
for (VAR_7 = VAR_8 = 0; VAR_7 < VAR_9; ++VAR_7) {
if (xtensa_operand_is_visible(isa, opc, VAR_7)) {
uint32_t v = 0xbadc0de;
int VAR_10;
VAR_1->fprintf_func(VAR_1->stream, VAR_8 ? ", " : "\t");
xtensa_operand_get_field(isa, opc, VAR_7, fmt, VAR_3,
slotbuf, &v);
VAR_10 = xtensa_operand_decode(isa, opc, VAR_7, &v);
if (VAR_10 == XTENSA_UNDEFINED) {
VAR_1->fprintf_func(VAR_1->stream, "???");
} else if (xtensa_operand_is_register(isa, opc, VAR_7)) {
xtensa_regfile rf = xtensa_operand_regfile(isa, opc, VAR_7);
VAR_1->fprintf_func(VAR_1->stream, "%s%d",
xtensa_regfile_shortname(isa, rf), v);
} else if (xtensa_operand_is_PCrelative(isa, opc, VAR_7)) {
xtensa_operand_undo_reloc(isa, opc, VAR_7, &v, VAR_0);
VAR_1->fprintf_func(VAR_1->stream, "0x%x", v);
} else {
VAR_1->fprintf_func(VAR_1->stream, "%d", v);
}
++VAR_8;
}
}
}
if (VAR_4 > 1) {
VAR_1->fprintf_func(VAR_1->stream, " }");
}
out:
g_free(buffer);
xtensa_insnbuf_free(isa, insnbuf);
xtensa_insnbuf_free(isa, slotbuf);
return VAR_5;
}
| [
"int FUNC_0(bfd_vma VAR_0, struct disassemble_info *VAR_1)\n{",
"xtensa_isa isa = VAR_1->private_data;",
"xtensa_insnbuf insnbuf = xtensa_insnbuf_alloc(isa);",
"xtensa_insnbuf slotbuf = xtensa_insnbuf_alloc(isa);",
"bfd_byte *buffer = g_malloc(1);",
"int VAR_2 = VAR_1->read_memory_func(VAR_0, buffer, 1, VAR_1);",
"xtensa_format fmt;",
"unsigned VAR_3, VAR_4;",
"unsigned VAR_5;",
"if (VAR_2) {",
"VAR_1->memory_error_func(VAR_2, VAR_0, VAR_1);",
"VAR_5 = -1;",
"goto out;",
"}",
"VAR_5 = xtensa_isa_length_from_chars(isa, buffer);",
"if (VAR_5 == XTENSA_UNDEFINED) {",
"VAR_1->fprintf_func(VAR_1->stream, \".byte 0x%02x\", buffer[0]);",
"VAR_5 = 1;",
"goto out;",
"}",
"buffer = g_realloc(buffer, VAR_5);",
"VAR_2 = VAR_1->read_memory_func(VAR_0 + 1, buffer + 1, VAR_5 - 1, VAR_1);",
"if (VAR_2) {",
"VAR_1->fprintf_func(VAR_1->stream, \".byte 0x%02x\", buffer[0]);",
"VAR_1->memory_error_func(VAR_2, VAR_0 + 1, VAR_1);",
"VAR_5 = 1;",
"goto out;",
"}",
"xtensa_insnbuf_from_chars(isa, insnbuf, buffer, VAR_5);",
"fmt = xtensa_format_decode(isa, insnbuf);",
"if (fmt == XTENSA_UNDEFINED) {",
"unsigned VAR_6;",
"for (VAR_6 = 0; VAR_6 < VAR_5; ++VAR_6) {",
"VAR_1->fprintf_func(VAR_1->stream, \"%s 0x%02x\",\nVAR_6 ? \", \" : \".byte \", buffer[VAR_6]);",
"}",
"goto out;",
"}",
"VAR_4 = xtensa_format_num_slots(isa, fmt);",
"if (VAR_4 > 1) {",
"VAR_1->fprintf_func(VAR_1->stream, \"{ \");",
"}",
"for (VAR_3 = 0; VAR_3 < VAR_4; ++VAR_3) {",
"xtensa_opcode opc;",
"unsigned VAR_7, VAR_8, VAR_9;",
"if (VAR_3) {",
"VAR_1->fprintf_func(VAR_1->stream, \"; \");",
"}",
"xtensa_format_get_slot(isa, fmt, VAR_3, insnbuf, slotbuf);",
"opc = xtensa_opcode_decode(isa, fmt, VAR_3, slotbuf);",
"if (opc == XTENSA_UNDEFINED) {",
"VAR_1->fprintf_func(VAR_1->stream, \"???\");",
"continue;",
"}",
"VAR_9 = xtensa_opcode_num_operands(isa, opc);",
"VAR_1->fprintf_func(VAR_1->stream, \"%s\", xtensa_opcode_name(isa, opc));",
"for (VAR_7 = VAR_8 = 0; VAR_7 < VAR_9; ++VAR_7) {",
"if (xtensa_operand_is_visible(isa, opc, VAR_7)) {",
"uint32_t v = 0xbadc0de;",
"int VAR_10;",
"VAR_1->fprintf_func(VAR_1->stream, VAR_8 ? \", \" : \"\\t\");",
"xtensa_operand_get_field(isa, opc, VAR_7, fmt, VAR_3,\nslotbuf, &v);",
"VAR_10 = xtensa_operand_decode(isa, opc, VAR_7, &v);",
"if (VAR_10 == XTENSA_UNDEFINED) {",
"VAR_1->fprintf_func(VAR_1->stream, \"???\");",
"} else if (xtensa_operand_is_register(isa, opc, VAR_7)) {",
"xtensa_regfile rf = xtensa_operand_regfile(isa, opc, VAR_7);",
"VAR_1->fprintf_func(VAR_1->stream, \"%s%d\",\nxtensa_regfile_shortname(isa, rf), v);",
"} else if (xtensa_operand_is_PCrelative(isa, opc, VAR_7)) {",
"xtensa_operand_undo_reloc(isa, opc, VAR_7, &v, VAR_0);",
"VAR_1->fprintf_func(VAR_1->stream, \"0x%x\", v);",
"} else {",
"VAR_1->fprintf_func(VAR_1->stream, \"%d\", v);",
"}",
"++VAR_8;",
"}",
"}",
"}",
"if (VAR_4 > 1) {",
"VAR_1->fprintf_func(VAR_1->stream, \" }\");",
"}",
"out:\ng_free(buffer);",
"xtensa_insnbuf_free(isa, insnbuf);",
"xtensa_insnbuf_free(isa, slotbuf);",
"return VAR_5;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143,
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159,
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191,
193
],
[
195
],
[
197
],
[
201
],
[
203
]
]
|
14,425 | char *qemu_strdup(const char *str)
{
char *ptr;
size_t len = strlen(str);
ptr = qemu_malloc(len + 1);
if (!ptr)
return NULL;
pstrcpy(ptr, len + 1, str);
return ptr;
}
| false | qemu | ac4b0d0c4feb291643c0e8a07a92e449e13881b5 | char *qemu_strdup(const char *str)
{
char *ptr;
size_t len = strlen(str);
ptr = qemu_malloc(len + 1);
if (!ptr)
return NULL;
pstrcpy(ptr, len + 1, str);
return ptr;
}
| {
"code": [],
"line_no": []
} | char *FUNC_0(const char *VAR_0)
{
char *VAR_1;
size_t len = strlen(VAR_0);
VAR_1 = qemu_malloc(len + 1);
if (!VAR_1)
return NULL;
pstrcpy(VAR_1, len + 1, VAR_0);
return VAR_1;
}
| [
"char *FUNC_0(const char *VAR_0)\n{",
"char *VAR_1;",
"size_t len = strlen(VAR_0);",
"VAR_1 = qemu_malloc(len + 1);",
"if (!VAR_1)\nreturn NULL;",
"pstrcpy(VAR_1, len + 1, VAR_0);",
"return VAR_1;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
15
],
[
17
],
[
19
]
]
|
14,426 | static inline void flash_sync_area(Flash *s, int64_t off, int64_t len)
{
int64_t start, end, nb_sectors;
QEMUIOVector iov;
if (!s->bdrv || bdrv_is_read_only(s->bdrv)) {
return;
}
assert(!(len % BDRV_SECTOR_SIZE));
start = off / BDRV_SECTOR_SIZE;
end = (off + len) / BDRV_SECTOR_SIZE;
nb_sectors = end - start;
qemu_iovec_init(&iov, 1);
qemu_iovec_add(&iov, s->storage + (start * BDRV_SECTOR_SIZE),
nb_sectors * BDRV_SECTOR_SIZE);
bdrv_aio_writev(s->bdrv, start, &iov, nb_sectors, bdrv_sync_complete, NULL);
}
| false | qemu | 4be746345f13e99e468c60acbd3a355e8183e3ce | static inline void flash_sync_area(Flash *s, int64_t off, int64_t len)
{
int64_t start, end, nb_sectors;
QEMUIOVector iov;
if (!s->bdrv || bdrv_is_read_only(s->bdrv)) {
return;
}
assert(!(len % BDRV_SECTOR_SIZE));
start = off / BDRV_SECTOR_SIZE;
end = (off + len) / BDRV_SECTOR_SIZE;
nb_sectors = end - start;
qemu_iovec_init(&iov, 1);
qemu_iovec_add(&iov, s->storage + (start * BDRV_SECTOR_SIZE),
nb_sectors * BDRV_SECTOR_SIZE);
bdrv_aio_writev(s->bdrv, start, &iov, nb_sectors, bdrv_sync_complete, NULL);
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(Flash *VAR_0, int64_t VAR_1, int64_t VAR_2)
{
int64_t start, end, nb_sectors;
QEMUIOVector iov;
if (!VAR_0->bdrv || bdrv_is_read_only(VAR_0->bdrv)) {
return;
}
assert(!(VAR_2 % BDRV_SECTOR_SIZE));
start = VAR_1 / BDRV_SECTOR_SIZE;
end = (VAR_1 + VAR_2) / BDRV_SECTOR_SIZE;
nb_sectors = end - start;
qemu_iovec_init(&iov, 1);
qemu_iovec_add(&iov, VAR_0->storage + (start * BDRV_SECTOR_SIZE),
nb_sectors * BDRV_SECTOR_SIZE);
bdrv_aio_writev(VAR_0->bdrv, start, &iov, nb_sectors, bdrv_sync_complete, NULL);
}
| [
"static inline void FUNC_0(Flash *VAR_0, int64_t VAR_1, int64_t VAR_2)\n{",
"int64_t start, end, nb_sectors;",
"QEMUIOVector iov;",
"if (!VAR_0->bdrv || bdrv_is_read_only(VAR_0->bdrv)) {",
"return;",
"}",
"assert(!(VAR_2 % BDRV_SECTOR_SIZE));",
"start = VAR_1 / BDRV_SECTOR_SIZE;",
"end = (VAR_1 + VAR_2) / BDRV_SECTOR_SIZE;",
"nb_sectors = end - start;",
"qemu_iovec_init(&iov, 1);",
"qemu_iovec_add(&iov, VAR_0->storage + (start * BDRV_SECTOR_SIZE),\nnb_sectors * BDRV_SECTOR_SIZE);",
"bdrv_aio_writev(VAR_0->bdrv, start, &iov, nb_sectors, bdrv_sync_complete, NULL);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
]
]
|
14,428 | static ssize_t test_block_read_func(QCryptoBlock *block,
size_t offset,
uint8_t *buf,
size_t buflen,
Error **errp,
void *opaque)
{
Buffer *header = opaque;
g_assert_cmpint(offset + buflen, <=, header->capacity);
memcpy(buf, header->buffer + offset, buflen);
return buflen;
}
| false | qemu | 375092332eeaa6e47561ce47fd36144cdaf964d0 | static ssize_t test_block_read_func(QCryptoBlock *block,
size_t offset,
uint8_t *buf,
size_t buflen,
Error **errp,
void *opaque)
{
Buffer *header = opaque;
g_assert_cmpint(offset + buflen, <=, header->capacity);
memcpy(buf, header->buffer + offset, buflen);
return buflen;
}
| {
"code": [],
"line_no": []
} | static ssize_t FUNC_0(QCryptoBlock *block,
size_t offset,
uint8_t *buf,
size_t buflen,
Error **errp,
void *opaque)
{
Buffer *header = opaque;
g_assert_cmpint(offset + buflen, <=, header->capacity);
memcpy(buf, header->buffer + offset, buflen);
return buflen;
}
| [
"static ssize_t FUNC_0(QCryptoBlock *block,\nsize_t offset,\nuint8_t *buf,\nsize_t buflen,\nError **errp,\nvoid *opaque)\n{",
"Buffer *header = opaque;",
"g_assert_cmpint(offset + buflen, <=, header->capacity);",
"memcpy(buf, header->buffer + offset, buflen);",
"return buflen;",
"}"
]
| [
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9,
11,
13
],
[
15
],
[
19
],
[
23
],
[
27
],
[
29
]
]
|
14,430 | static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
uint16_t insn_hw1)
{
int32_t offset;
uint16_t insn;
int rt, rs, rd, rr;
int16_t imm;
uint32_t op, minor, mips32_op;
uint32_t cond, fmt, cc;
insn = cpu_lduw_code(env, ctx->pc + 2);
ctx->opcode = (ctx->opcode << 16) | insn;
rt = (ctx->opcode >> 21) & 0x1f;
rs = (ctx->opcode >> 16) & 0x1f;
rd = (ctx->opcode >> 11) & 0x1f;
rr = (ctx->opcode >> 6) & 0x1f;
imm = (int16_t) ctx->opcode;
op = (ctx->opcode >> 26) & 0x3f;
switch (op) {
case POOL32A:
minor = ctx->opcode & 0x3f;
switch (minor) {
case 0x00:
minor = (ctx->opcode >> 6) & 0xf;
switch (minor) {
case SLL32:
mips32_op = OPC_SLL;
goto do_shifti;
case SRA:
mips32_op = OPC_SRA;
goto do_shifti;
case SRL32:
mips32_op = OPC_SRL;
goto do_shifti;
case ROTR:
mips32_op = OPC_ROTR;
do_shifti:
gen_shift_imm(ctx, mips32_op, rt, rs, rd);
break;
default:
goto pool32a_invalid;
}
break;
case 0x10:
minor = (ctx->opcode >> 6) & 0xf;
switch (minor) {
/* Arithmetic */
case ADD:
mips32_op = OPC_ADD;
goto do_arith;
case ADDU32:
mips32_op = OPC_ADDU;
goto do_arith;
case SUB:
mips32_op = OPC_SUB;
goto do_arith;
case SUBU32:
mips32_op = OPC_SUBU;
goto do_arith;
case MUL:
mips32_op = OPC_MUL;
do_arith:
gen_arith(ctx, mips32_op, rd, rs, rt);
break;
/* Shifts */
case SLLV:
mips32_op = OPC_SLLV;
goto do_shift;
case SRLV:
mips32_op = OPC_SRLV;
goto do_shift;
case SRAV:
mips32_op = OPC_SRAV;
goto do_shift;
case ROTRV:
mips32_op = OPC_ROTRV;
do_shift:
gen_shift(ctx, mips32_op, rd, rs, rt);
break;
/* Logical operations */
case AND:
mips32_op = OPC_AND;
goto do_logic;
case OR32:
mips32_op = OPC_OR;
goto do_logic;
case NOR:
mips32_op = OPC_NOR;
goto do_logic;
case XOR32:
mips32_op = OPC_XOR;
do_logic:
gen_logic(ctx, mips32_op, rd, rs, rt);
break;
/* Set less than */
case SLT:
mips32_op = OPC_SLT;
goto do_slt;
case SLTU:
mips32_op = OPC_SLTU;
do_slt:
gen_slt(ctx, mips32_op, rd, rs, rt);
break;
default:
goto pool32a_invalid;
}
break;
case 0x18:
minor = (ctx->opcode >> 6) & 0xf;
switch (minor) {
/* Conditional moves */
case MOVN:
mips32_op = OPC_MOVN;
goto do_cmov;
case MOVZ:
mips32_op = OPC_MOVZ;
do_cmov:
gen_cond_move(ctx, mips32_op, rd, rs, rt);
break;
case LWXS:
gen_ldxs(ctx, rs, rt, rd);
break;
default:
goto pool32a_invalid;
}
break;
case INS:
gen_bitops(ctx, OPC_INS, rt, rs, rr, rd);
return;
case EXT:
gen_bitops(ctx, OPC_EXT, rt, rs, rr, rd);
return;
case POOL32AXF:
gen_pool32axf(env, ctx, rt, rs);
break;
case 0x07:
generate_exception(ctx, EXCP_BREAK);
break;
default:
pool32a_invalid:
MIPS_INVAL("pool32a");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case POOL32B:
minor = (ctx->opcode >> 12) & 0xf;
switch (minor) {
case CACHE:
check_cp0_enabled(ctx);
/* Treat as no-op. */
break;
case LWC2:
case SWC2:
/* COP2: Not implemented. */
generate_exception_err(ctx, EXCP_CpU, 2);
break;
case LWP:
case SWP:
#ifdef TARGET_MIPS64
case LDP:
case SDP:
#endif
gen_ldst_pair(ctx, minor, rt, rs, SIMM(ctx->opcode, 0, 12));
break;
case LWM32:
case SWM32:
#ifdef TARGET_MIPS64
case LDM:
case SDM:
#endif
gen_ldst_multiple(ctx, minor, rt, rs, SIMM(ctx->opcode, 0, 12));
break;
default:
MIPS_INVAL("pool32b");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case POOL32F:
if (env->CP0_Config1 & (1 << CP0C1_FP)) {
minor = ctx->opcode & 0x3f;
check_cp1_enabled(ctx);
switch (minor) {
case ALNV_PS:
mips32_op = OPC_ALNV_PS;
goto do_madd;
case MADD_S:
mips32_op = OPC_MADD_S;
goto do_madd;
case MADD_D:
mips32_op = OPC_MADD_D;
goto do_madd;
case MADD_PS:
mips32_op = OPC_MADD_PS;
goto do_madd;
case MSUB_S:
mips32_op = OPC_MSUB_S;
goto do_madd;
case MSUB_D:
mips32_op = OPC_MSUB_D;
goto do_madd;
case MSUB_PS:
mips32_op = OPC_MSUB_PS;
goto do_madd;
case NMADD_S:
mips32_op = OPC_NMADD_S;
goto do_madd;
case NMADD_D:
mips32_op = OPC_NMADD_D;
goto do_madd;
case NMADD_PS:
mips32_op = OPC_NMADD_PS;
goto do_madd;
case NMSUB_S:
mips32_op = OPC_NMSUB_S;
goto do_madd;
case NMSUB_D:
mips32_op = OPC_NMSUB_D;
goto do_madd;
case NMSUB_PS:
mips32_op = OPC_NMSUB_PS;
do_madd:
gen_flt3_arith(ctx, mips32_op, rd, rr, rs, rt);
break;
case CABS_COND_FMT:
cond = (ctx->opcode >> 6) & 0xf;
cc = (ctx->opcode >> 13) & 0x7;
fmt = (ctx->opcode >> 10) & 0x3;
switch (fmt) {
case 0x0:
gen_cmpabs_s(ctx, cond, rt, rs, cc);
break;
case 0x1:
gen_cmpabs_d(ctx, cond, rt, rs, cc);
break;
case 0x2:
gen_cmpabs_ps(ctx, cond, rt, rs, cc);
break;
default:
goto pool32f_invalid;
}
break;
case C_COND_FMT:
cond = (ctx->opcode >> 6) & 0xf;
cc = (ctx->opcode >> 13) & 0x7;
fmt = (ctx->opcode >> 10) & 0x3;
switch (fmt) {
case 0x0:
gen_cmp_s(ctx, cond, rt, rs, cc);
break;
case 0x1:
gen_cmp_d(ctx, cond, rt, rs, cc);
break;
case 0x2:
gen_cmp_ps(ctx, cond, rt, rs, cc);
break;
default:
goto pool32f_invalid;
}
break;
case POOL32FXF:
gen_pool32fxf(ctx, rt, rs);
break;
case 0x00:
/* PLL foo */
switch ((ctx->opcode >> 6) & 0x7) {
case PLL_PS:
mips32_op = OPC_PLL_PS;
goto do_ps;
case PLU_PS:
mips32_op = OPC_PLU_PS;
goto do_ps;
case PUL_PS:
mips32_op = OPC_PUL_PS;
goto do_ps;
case PUU_PS:
mips32_op = OPC_PUU_PS;
goto do_ps;
case CVT_PS_S:
mips32_op = OPC_CVT_PS_S;
do_ps:
gen_farith(ctx, mips32_op, rt, rs, rd, 0);
break;
default:
goto pool32f_invalid;
}
break;
case 0x08:
/* [LS][WDU]XC1 */
switch ((ctx->opcode >> 6) & 0x7) {
case LWXC1:
mips32_op = OPC_LWXC1;
goto do_ldst_cp1;
case SWXC1:
mips32_op = OPC_SWXC1;
goto do_ldst_cp1;
case LDXC1:
mips32_op = OPC_LDXC1;
goto do_ldst_cp1;
case SDXC1:
mips32_op = OPC_SDXC1;
goto do_ldst_cp1;
case LUXC1:
mips32_op = OPC_LUXC1;
goto do_ldst_cp1;
case SUXC1:
mips32_op = OPC_SUXC1;
do_ldst_cp1:
gen_flt3_ldst(ctx, mips32_op, rd, rd, rt, rs);
break;
default:
goto pool32f_invalid;
}
break;
case 0x18:
/* 3D insns */
fmt = (ctx->opcode >> 9) & 0x3;
switch ((ctx->opcode >> 6) & 0x7) {
case RSQRT2_FMT:
switch (fmt) {
case FMT_SDPS_S:
mips32_op = OPC_RSQRT2_S;
goto do_3d;
case FMT_SDPS_D:
mips32_op = OPC_RSQRT2_D;
goto do_3d;
case FMT_SDPS_PS:
mips32_op = OPC_RSQRT2_PS;
goto do_3d;
default:
goto pool32f_invalid;
}
break;
case RECIP2_FMT:
switch (fmt) {
case FMT_SDPS_S:
mips32_op = OPC_RECIP2_S;
goto do_3d;
case FMT_SDPS_D:
mips32_op = OPC_RECIP2_D;
goto do_3d;
case FMT_SDPS_PS:
mips32_op = OPC_RECIP2_PS;
goto do_3d;
default:
goto pool32f_invalid;
}
break;
case ADDR_PS:
mips32_op = OPC_ADDR_PS;
goto do_3d;
case MULR_PS:
mips32_op = OPC_MULR_PS;
do_3d:
gen_farith(ctx, mips32_op, rt, rs, rd, 0);
break;
default:
goto pool32f_invalid;
}
break;
case 0x20:
/* MOV[FT].fmt and PREFX */
cc = (ctx->opcode >> 13) & 0x7;
fmt = (ctx->opcode >> 9) & 0x3;
switch ((ctx->opcode >> 6) & 0x7) {
case MOVF_FMT:
switch (fmt) {
case FMT_SDPS_S:
gen_movcf_s(rs, rt, cc, 0);
break;
case FMT_SDPS_D:
gen_movcf_d(ctx, rs, rt, cc, 0);
break;
case FMT_SDPS_PS:
gen_movcf_ps(rs, rt, cc, 0);
break;
default:
goto pool32f_invalid;
}
break;
case MOVT_FMT:
switch (fmt) {
case FMT_SDPS_S:
gen_movcf_s(rs, rt, cc, 1);
break;
case FMT_SDPS_D:
gen_movcf_d(ctx, rs, rt, cc, 1);
break;
case FMT_SDPS_PS:
gen_movcf_ps(rs, rt, cc, 1);
break;
default:
goto pool32f_invalid;
}
break;
case PREFX:
break;
default:
goto pool32f_invalid;
}
break;
#define FINSN_3ARG_SDPS(prfx) \
switch ((ctx->opcode >> 8) & 0x3) { \
case FMT_SDPS_S: \
mips32_op = OPC_##prfx##_S; \
goto do_fpop; \
case FMT_SDPS_D: \
mips32_op = OPC_##prfx##_D; \
goto do_fpop; \
case FMT_SDPS_PS: \
mips32_op = OPC_##prfx##_PS; \
goto do_fpop; \
default: \
goto pool32f_invalid; \
}
case 0x30:
/* regular FP ops */
switch ((ctx->opcode >> 6) & 0x3) {
case ADD_FMT:
FINSN_3ARG_SDPS(ADD);
break;
case SUB_FMT:
FINSN_3ARG_SDPS(SUB);
break;
case MUL_FMT:
FINSN_3ARG_SDPS(MUL);
break;
case DIV_FMT:
fmt = (ctx->opcode >> 8) & 0x3;
if (fmt == 1) {
mips32_op = OPC_DIV_D;
} else if (fmt == 0) {
mips32_op = OPC_DIV_S;
} else {
goto pool32f_invalid;
}
goto do_fpop;
default:
goto pool32f_invalid;
}
break;
case 0x38:
/* cmovs */
switch ((ctx->opcode >> 6) & 0x3) {
case MOVN_FMT:
FINSN_3ARG_SDPS(MOVN);
break;
case MOVZ_FMT:
FINSN_3ARG_SDPS(MOVZ);
break;
default:
goto pool32f_invalid;
}
break;
do_fpop:
gen_farith(ctx, mips32_op, rt, rs, rd, 0);
break;
default:
pool32f_invalid:
MIPS_INVAL("pool32f");
generate_exception(ctx, EXCP_RI);
break;
}
} else {
generate_exception_err(ctx, EXCP_CpU, 1);
}
break;
case POOL32I:
minor = (ctx->opcode >> 21) & 0x1f;
switch (minor) {
case BLTZ:
mips32_op = OPC_BLTZ;
goto do_branch;
case BLTZAL:
mips32_op = OPC_BLTZAL;
goto do_branch;
case BLTZALS:
mips32_op = OPC_BLTZALS;
goto do_branch;
case BGEZ:
mips32_op = OPC_BGEZ;
goto do_branch;
case BGEZAL:
mips32_op = OPC_BGEZAL;
goto do_branch;
case BGEZALS:
mips32_op = OPC_BGEZALS;
goto do_branch;
case BLEZ:
mips32_op = OPC_BLEZ;
goto do_branch;
case BGTZ:
mips32_op = OPC_BGTZ;
do_branch:
gen_compute_branch(ctx, mips32_op, 4, rs, -1, imm << 1);
break;
/* Traps */
case TLTI:
mips32_op = OPC_TLTI;
goto do_trapi;
case TGEI:
mips32_op = OPC_TGEI;
goto do_trapi;
case TLTIU:
mips32_op = OPC_TLTIU;
goto do_trapi;
case TGEIU:
mips32_op = OPC_TGEIU;
goto do_trapi;
case TNEI:
mips32_op = OPC_TNEI;
goto do_trapi;
case TEQI:
mips32_op = OPC_TEQI;
do_trapi:
gen_trap(ctx, mips32_op, rs, -1, imm);
break;
case BNEZC:
case BEQZC:
gen_compute_branch(ctx, minor == BNEZC ? OPC_BNE : OPC_BEQ,
4, rs, 0, imm << 1);
/* Compact branches don't have a delay slot, so just let
the normal delay slot handling take us to the branch
target. */
break;
case LUI:
gen_logic_imm(ctx, OPC_LUI, rs, -1, imm);
break;
case SYNCI:
break;
case BC2F:
case BC2T:
/* COP2: Not implemented. */
generate_exception_err(ctx, EXCP_CpU, 2);
break;
case BC1F:
mips32_op = (ctx->opcode & (1 << 16)) ? OPC_BC1FANY2 : OPC_BC1F;
goto do_cp1branch;
case BC1T:
mips32_op = (ctx->opcode & (1 << 16)) ? OPC_BC1TANY2 : OPC_BC1T;
goto do_cp1branch;
case BC1ANY4F:
mips32_op = OPC_BC1FANY4;
goto do_cp1mips3d;
case BC1ANY4T:
mips32_op = OPC_BC1TANY4;
do_cp1mips3d:
check_cop1x(ctx);
check_insn(ctx, ASE_MIPS3D);
/* Fall through */
do_cp1branch:
gen_compute_branch1(ctx, mips32_op,
(ctx->opcode >> 18) & 0x7, imm << 1);
break;
case BPOSGE64:
case BPOSGE32:
/* MIPS DSP: not implemented */
/* Fall through */
default:
MIPS_INVAL("pool32i");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case POOL32C:
minor = (ctx->opcode >> 12) & 0xf;
switch (minor) {
case LWL:
mips32_op = OPC_LWL;
goto do_ld_lr;
case SWL:
mips32_op = OPC_SWL;
goto do_st_lr;
case LWR:
mips32_op = OPC_LWR;
goto do_ld_lr;
case SWR:
mips32_op = OPC_SWR;
goto do_st_lr;
#if defined(TARGET_MIPS64)
case LDL:
mips32_op = OPC_LDL;
goto do_ld_lr;
case SDL:
mips32_op = OPC_SDL;
goto do_st_lr;
case LDR:
mips32_op = OPC_LDR;
goto do_ld_lr;
case SDR:
mips32_op = OPC_SDR;
goto do_st_lr;
case LWU:
mips32_op = OPC_LWU;
goto do_ld_lr;
case LLD:
mips32_op = OPC_LLD;
goto do_ld_lr;
#endif
case LL:
mips32_op = OPC_LL;
goto do_ld_lr;
do_ld_lr:
gen_ld(ctx, mips32_op, rt, rs, SIMM(ctx->opcode, 0, 12));
break;
do_st_lr:
gen_st(ctx, mips32_op, rt, rs, SIMM(ctx->opcode, 0, 12));
break;
case SC:
gen_st_cond(ctx, OPC_SC, rt, rs, SIMM(ctx->opcode, 0, 12));
break;
#if defined(TARGET_MIPS64)
case SCD:
gen_st_cond(ctx, OPC_SCD, rt, rs, SIMM(ctx->opcode, 0, 12));
break;
#endif
case PREF:
/* Treat as no-op */
break;
default:
MIPS_INVAL("pool32c");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case ADDI32:
mips32_op = OPC_ADDI;
goto do_addi;
case ADDIU32:
mips32_op = OPC_ADDIU;
do_addi:
gen_arith_imm(ctx, mips32_op, rt, rs, imm);
break;
/* Logical operations */
case ORI32:
mips32_op = OPC_ORI;
goto do_logici;
case XORI32:
mips32_op = OPC_XORI;
goto do_logici;
case ANDI32:
mips32_op = OPC_ANDI;
do_logici:
gen_logic_imm(ctx, mips32_op, rt, rs, imm);
break;
/* Set less than immediate */
case SLTI32:
mips32_op = OPC_SLTI;
goto do_slti;
case SLTIU32:
mips32_op = OPC_SLTIU;
do_slti:
gen_slt_imm(ctx, mips32_op, rt, rs, imm);
break;
case JALX32:
offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 2;
gen_compute_branch(ctx, OPC_JALX, 4, rt, rs, offset);
break;
case JALS32:
offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 1;
gen_compute_branch(ctx, OPC_JALS, 4, rt, rs, offset);
break;
case BEQ32:
gen_compute_branch(ctx, OPC_BEQ, 4, rt, rs, imm << 1);
break;
case BNE32:
gen_compute_branch(ctx, OPC_BNE, 4, rt, rs, imm << 1);
break;
case J32:
gen_compute_branch(ctx, OPC_J, 4, rt, rs,
(int32_t)(ctx->opcode & 0x3FFFFFF) << 1);
break;
case JAL32:
gen_compute_branch(ctx, OPC_JAL, 4, rt, rs,
(int32_t)(ctx->opcode & 0x3FFFFFF) << 1);
break;
/* Floating point (COP1) */
case LWC132:
mips32_op = OPC_LWC1;
goto do_cop1;
case LDC132:
mips32_op = OPC_LDC1;
goto do_cop1;
case SWC132:
mips32_op = OPC_SWC1;
goto do_cop1;
case SDC132:
mips32_op = OPC_SDC1;
do_cop1:
gen_cop1_ldst(env, ctx, mips32_op, rt, rs, imm);
break;
case ADDIUPC:
{
int reg = mmreg(ZIMM(ctx->opcode, 23, 3));
int offset = SIMM(ctx->opcode, 0, 23) << 2;
gen_addiupc(ctx, reg, offset, 0, 0);
}
break;
/* Loads and stores */
case LB32:
mips32_op = OPC_LB;
goto do_ld;
case LBU32:
mips32_op = OPC_LBU;
goto do_ld;
case LH32:
mips32_op = OPC_LH;
goto do_ld;
case LHU32:
mips32_op = OPC_LHU;
goto do_ld;
case LW32:
mips32_op = OPC_LW;
goto do_ld;
#ifdef TARGET_MIPS64
case LD32:
mips32_op = OPC_LD;
goto do_ld;
case SD32:
mips32_op = OPC_SD;
goto do_st;
#endif
case SB32:
mips32_op = OPC_SB;
goto do_st;
case SH32:
mips32_op = OPC_SH;
goto do_st;
case SW32:
mips32_op = OPC_SW;
goto do_st;
do_ld:
gen_ld(ctx, mips32_op, rt, rs, imm);
break;
do_st:
gen_st(ctx, mips32_op, rt, rs, imm);
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
}
| false | qemu | 7f6613cedc59fa849105668ae971dc31004bca1c | static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
uint16_t insn_hw1)
{
int32_t offset;
uint16_t insn;
int rt, rs, rd, rr;
int16_t imm;
uint32_t op, minor, mips32_op;
uint32_t cond, fmt, cc;
insn = cpu_lduw_code(env, ctx->pc + 2);
ctx->opcode = (ctx->opcode << 16) | insn;
rt = (ctx->opcode >> 21) & 0x1f;
rs = (ctx->opcode >> 16) & 0x1f;
rd = (ctx->opcode >> 11) & 0x1f;
rr = (ctx->opcode >> 6) & 0x1f;
imm = (int16_t) ctx->opcode;
op = (ctx->opcode >> 26) & 0x3f;
switch (op) {
case POOL32A:
minor = ctx->opcode & 0x3f;
switch (minor) {
case 0x00:
minor = (ctx->opcode >> 6) & 0xf;
switch (minor) {
case SLL32:
mips32_op = OPC_SLL;
goto do_shifti;
case SRA:
mips32_op = OPC_SRA;
goto do_shifti;
case SRL32:
mips32_op = OPC_SRL;
goto do_shifti;
case ROTR:
mips32_op = OPC_ROTR;
do_shifti:
gen_shift_imm(ctx, mips32_op, rt, rs, rd);
break;
default:
goto pool32a_invalid;
}
break;
case 0x10:
minor = (ctx->opcode >> 6) & 0xf;
switch (minor) {
case ADD:
mips32_op = OPC_ADD;
goto do_arith;
case ADDU32:
mips32_op = OPC_ADDU;
goto do_arith;
case SUB:
mips32_op = OPC_SUB;
goto do_arith;
case SUBU32:
mips32_op = OPC_SUBU;
goto do_arith;
case MUL:
mips32_op = OPC_MUL;
do_arith:
gen_arith(ctx, mips32_op, rd, rs, rt);
break;
case SLLV:
mips32_op = OPC_SLLV;
goto do_shift;
case SRLV:
mips32_op = OPC_SRLV;
goto do_shift;
case SRAV:
mips32_op = OPC_SRAV;
goto do_shift;
case ROTRV:
mips32_op = OPC_ROTRV;
do_shift:
gen_shift(ctx, mips32_op, rd, rs, rt);
break;
case AND:
mips32_op = OPC_AND;
goto do_logic;
case OR32:
mips32_op = OPC_OR;
goto do_logic;
case NOR:
mips32_op = OPC_NOR;
goto do_logic;
case XOR32:
mips32_op = OPC_XOR;
do_logic:
gen_logic(ctx, mips32_op, rd, rs, rt);
break;
case SLT:
mips32_op = OPC_SLT;
goto do_slt;
case SLTU:
mips32_op = OPC_SLTU;
do_slt:
gen_slt(ctx, mips32_op, rd, rs, rt);
break;
default:
goto pool32a_invalid;
}
break;
case 0x18:
minor = (ctx->opcode >> 6) & 0xf;
switch (minor) {
case MOVN:
mips32_op = OPC_MOVN;
goto do_cmov;
case MOVZ:
mips32_op = OPC_MOVZ;
do_cmov:
gen_cond_move(ctx, mips32_op, rd, rs, rt);
break;
case LWXS:
gen_ldxs(ctx, rs, rt, rd);
break;
default:
goto pool32a_invalid;
}
break;
case INS:
gen_bitops(ctx, OPC_INS, rt, rs, rr, rd);
return;
case EXT:
gen_bitops(ctx, OPC_EXT, rt, rs, rr, rd);
return;
case POOL32AXF:
gen_pool32axf(env, ctx, rt, rs);
break;
case 0x07:
generate_exception(ctx, EXCP_BREAK);
break;
default:
pool32a_invalid:
MIPS_INVAL("pool32a");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case POOL32B:
minor = (ctx->opcode >> 12) & 0xf;
switch (minor) {
case CACHE:
check_cp0_enabled(ctx);
break;
case LWC2:
case SWC2:
generate_exception_err(ctx, EXCP_CpU, 2);
break;
case LWP:
case SWP:
#ifdef TARGET_MIPS64
case LDP:
case SDP:
#endif
gen_ldst_pair(ctx, minor, rt, rs, SIMM(ctx->opcode, 0, 12));
break;
case LWM32:
case SWM32:
#ifdef TARGET_MIPS64
case LDM:
case SDM:
#endif
gen_ldst_multiple(ctx, minor, rt, rs, SIMM(ctx->opcode, 0, 12));
break;
default:
MIPS_INVAL("pool32b");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case POOL32F:
if (env->CP0_Config1 & (1 << CP0C1_FP)) {
minor = ctx->opcode & 0x3f;
check_cp1_enabled(ctx);
switch (minor) {
case ALNV_PS:
mips32_op = OPC_ALNV_PS;
goto do_madd;
case MADD_S:
mips32_op = OPC_MADD_S;
goto do_madd;
case MADD_D:
mips32_op = OPC_MADD_D;
goto do_madd;
case MADD_PS:
mips32_op = OPC_MADD_PS;
goto do_madd;
case MSUB_S:
mips32_op = OPC_MSUB_S;
goto do_madd;
case MSUB_D:
mips32_op = OPC_MSUB_D;
goto do_madd;
case MSUB_PS:
mips32_op = OPC_MSUB_PS;
goto do_madd;
case NMADD_S:
mips32_op = OPC_NMADD_S;
goto do_madd;
case NMADD_D:
mips32_op = OPC_NMADD_D;
goto do_madd;
case NMADD_PS:
mips32_op = OPC_NMADD_PS;
goto do_madd;
case NMSUB_S:
mips32_op = OPC_NMSUB_S;
goto do_madd;
case NMSUB_D:
mips32_op = OPC_NMSUB_D;
goto do_madd;
case NMSUB_PS:
mips32_op = OPC_NMSUB_PS;
do_madd:
gen_flt3_arith(ctx, mips32_op, rd, rr, rs, rt);
break;
case CABS_COND_FMT:
cond = (ctx->opcode >> 6) & 0xf;
cc = (ctx->opcode >> 13) & 0x7;
fmt = (ctx->opcode >> 10) & 0x3;
switch (fmt) {
case 0x0:
gen_cmpabs_s(ctx, cond, rt, rs, cc);
break;
case 0x1:
gen_cmpabs_d(ctx, cond, rt, rs, cc);
break;
case 0x2:
gen_cmpabs_ps(ctx, cond, rt, rs, cc);
break;
default:
goto pool32f_invalid;
}
break;
case C_COND_FMT:
cond = (ctx->opcode >> 6) & 0xf;
cc = (ctx->opcode >> 13) & 0x7;
fmt = (ctx->opcode >> 10) & 0x3;
switch (fmt) {
case 0x0:
gen_cmp_s(ctx, cond, rt, rs, cc);
break;
case 0x1:
gen_cmp_d(ctx, cond, rt, rs, cc);
break;
case 0x2:
gen_cmp_ps(ctx, cond, rt, rs, cc);
break;
default:
goto pool32f_invalid;
}
break;
case POOL32FXF:
gen_pool32fxf(ctx, rt, rs);
break;
case 0x00:
switch ((ctx->opcode >> 6) & 0x7) {
case PLL_PS:
mips32_op = OPC_PLL_PS;
goto do_ps;
case PLU_PS:
mips32_op = OPC_PLU_PS;
goto do_ps;
case PUL_PS:
mips32_op = OPC_PUL_PS;
goto do_ps;
case PUU_PS:
mips32_op = OPC_PUU_PS;
goto do_ps;
case CVT_PS_S:
mips32_op = OPC_CVT_PS_S;
do_ps:
gen_farith(ctx, mips32_op, rt, rs, rd, 0);
break;
default:
goto pool32f_invalid;
}
break;
case 0x08:
switch ((ctx->opcode >> 6) & 0x7) {
case LWXC1:
mips32_op = OPC_LWXC1;
goto do_ldst_cp1;
case SWXC1:
mips32_op = OPC_SWXC1;
goto do_ldst_cp1;
case LDXC1:
mips32_op = OPC_LDXC1;
goto do_ldst_cp1;
case SDXC1:
mips32_op = OPC_SDXC1;
goto do_ldst_cp1;
case LUXC1:
mips32_op = OPC_LUXC1;
goto do_ldst_cp1;
case SUXC1:
mips32_op = OPC_SUXC1;
do_ldst_cp1:
gen_flt3_ldst(ctx, mips32_op, rd, rd, rt, rs);
break;
default:
goto pool32f_invalid;
}
break;
case 0x18:
fmt = (ctx->opcode >> 9) & 0x3;
switch ((ctx->opcode >> 6) & 0x7) {
case RSQRT2_FMT:
switch (fmt) {
case FMT_SDPS_S:
mips32_op = OPC_RSQRT2_S;
goto do_3d;
case FMT_SDPS_D:
mips32_op = OPC_RSQRT2_D;
goto do_3d;
case FMT_SDPS_PS:
mips32_op = OPC_RSQRT2_PS;
goto do_3d;
default:
goto pool32f_invalid;
}
break;
case RECIP2_FMT:
switch (fmt) {
case FMT_SDPS_S:
mips32_op = OPC_RECIP2_S;
goto do_3d;
case FMT_SDPS_D:
mips32_op = OPC_RECIP2_D;
goto do_3d;
case FMT_SDPS_PS:
mips32_op = OPC_RECIP2_PS;
goto do_3d;
default:
goto pool32f_invalid;
}
break;
case ADDR_PS:
mips32_op = OPC_ADDR_PS;
goto do_3d;
case MULR_PS:
mips32_op = OPC_MULR_PS;
do_3d:
gen_farith(ctx, mips32_op, rt, rs, rd, 0);
break;
default:
goto pool32f_invalid;
}
break;
case 0x20:
cc = (ctx->opcode >> 13) & 0x7;
fmt = (ctx->opcode >> 9) & 0x3;
switch ((ctx->opcode >> 6) & 0x7) {
case MOVF_FMT:
switch (fmt) {
case FMT_SDPS_S:
gen_movcf_s(rs, rt, cc, 0);
break;
case FMT_SDPS_D:
gen_movcf_d(ctx, rs, rt, cc, 0);
break;
case FMT_SDPS_PS:
gen_movcf_ps(rs, rt, cc, 0);
break;
default:
goto pool32f_invalid;
}
break;
case MOVT_FMT:
switch (fmt) {
case FMT_SDPS_S:
gen_movcf_s(rs, rt, cc, 1);
break;
case FMT_SDPS_D:
gen_movcf_d(ctx, rs, rt, cc, 1);
break;
case FMT_SDPS_PS:
gen_movcf_ps(rs, rt, cc, 1);
break;
default:
goto pool32f_invalid;
}
break;
case PREFX:
break;
default:
goto pool32f_invalid;
}
break;
#define FINSN_3ARG_SDPS(prfx) \
switch ((ctx->opcode >> 8) & 0x3) { \
case FMT_SDPS_S: \
mips32_op = OPC_##prfx##_S; \
goto do_fpop; \
case FMT_SDPS_D: \
mips32_op = OPC_##prfx##_D; \
goto do_fpop; \
case FMT_SDPS_PS: \
mips32_op = OPC_##prfx##_PS; \
goto do_fpop; \
default: \
goto pool32f_invalid; \
}
case 0x30:
switch ((ctx->opcode >> 6) & 0x3) {
case ADD_FMT:
FINSN_3ARG_SDPS(ADD);
break;
case SUB_FMT:
FINSN_3ARG_SDPS(SUB);
break;
case MUL_FMT:
FINSN_3ARG_SDPS(MUL);
break;
case DIV_FMT:
fmt = (ctx->opcode >> 8) & 0x3;
if (fmt == 1) {
mips32_op = OPC_DIV_D;
} else if (fmt == 0) {
mips32_op = OPC_DIV_S;
} else {
goto pool32f_invalid;
}
goto do_fpop;
default:
goto pool32f_invalid;
}
break;
case 0x38:
switch ((ctx->opcode >> 6) & 0x3) {
case MOVN_FMT:
FINSN_3ARG_SDPS(MOVN);
break;
case MOVZ_FMT:
FINSN_3ARG_SDPS(MOVZ);
break;
default:
goto pool32f_invalid;
}
break;
do_fpop:
gen_farith(ctx, mips32_op, rt, rs, rd, 0);
break;
default:
pool32f_invalid:
MIPS_INVAL("pool32f");
generate_exception(ctx, EXCP_RI);
break;
}
} else {
generate_exception_err(ctx, EXCP_CpU, 1);
}
break;
case POOL32I:
minor = (ctx->opcode >> 21) & 0x1f;
switch (minor) {
case BLTZ:
mips32_op = OPC_BLTZ;
goto do_branch;
case BLTZAL:
mips32_op = OPC_BLTZAL;
goto do_branch;
case BLTZALS:
mips32_op = OPC_BLTZALS;
goto do_branch;
case BGEZ:
mips32_op = OPC_BGEZ;
goto do_branch;
case BGEZAL:
mips32_op = OPC_BGEZAL;
goto do_branch;
case BGEZALS:
mips32_op = OPC_BGEZALS;
goto do_branch;
case BLEZ:
mips32_op = OPC_BLEZ;
goto do_branch;
case BGTZ:
mips32_op = OPC_BGTZ;
do_branch:
gen_compute_branch(ctx, mips32_op, 4, rs, -1, imm << 1);
break;
case TLTI:
mips32_op = OPC_TLTI;
goto do_trapi;
case TGEI:
mips32_op = OPC_TGEI;
goto do_trapi;
case TLTIU:
mips32_op = OPC_TLTIU;
goto do_trapi;
case TGEIU:
mips32_op = OPC_TGEIU;
goto do_trapi;
case TNEI:
mips32_op = OPC_TNEI;
goto do_trapi;
case TEQI:
mips32_op = OPC_TEQI;
do_trapi:
gen_trap(ctx, mips32_op, rs, -1, imm);
break;
case BNEZC:
case BEQZC:
gen_compute_branch(ctx, minor == BNEZC ? OPC_BNE : OPC_BEQ,
4, rs, 0, imm << 1);
break;
case LUI:
gen_logic_imm(ctx, OPC_LUI, rs, -1, imm);
break;
case SYNCI:
break;
case BC2F:
case BC2T:
generate_exception_err(ctx, EXCP_CpU, 2);
break;
case BC1F:
mips32_op = (ctx->opcode & (1 << 16)) ? OPC_BC1FANY2 : OPC_BC1F;
goto do_cp1branch;
case BC1T:
mips32_op = (ctx->opcode & (1 << 16)) ? OPC_BC1TANY2 : OPC_BC1T;
goto do_cp1branch;
case BC1ANY4F:
mips32_op = OPC_BC1FANY4;
goto do_cp1mips3d;
case BC1ANY4T:
mips32_op = OPC_BC1TANY4;
do_cp1mips3d:
check_cop1x(ctx);
check_insn(ctx, ASE_MIPS3D);
do_cp1branch:
gen_compute_branch1(ctx, mips32_op,
(ctx->opcode >> 18) & 0x7, imm << 1);
break;
case BPOSGE64:
case BPOSGE32:
default:
MIPS_INVAL("pool32i");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case POOL32C:
minor = (ctx->opcode >> 12) & 0xf;
switch (minor) {
case LWL:
mips32_op = OPC_LWL;
goto do_ld_lr;
case SWL:
mips32_op = OPC_SWL;
goto do_st_lr;
case LWR:
mips32_op = OPC_LWR;
goto do_ld_lr;
case SWR:
mips32_op = OPC_SWR;
goto do_st_lr;
#if defined(TARGET_MIPS64)
case LDL:
mips32_op = OPC_LDL;
goto do_ld_lr;
case SDL:
mips32_op = OPC_SDL;
goto do_st_lr;
case LDR:
mips32_op = OPC_LDR;
goto do_ld_lr;
case SDR:
mips32_op = OPC_SDR;
goto do_st_lr;
case LWU:
mips32_op = OPC_LWU;
goto do_ld_lr;
case LLD:
mips32_op = OPC_LLD;
goto do_ld_lr;
#endif
case LL:
mips32_op = OPC_LL;
goto do_ld_lr;
do_ld_lr:
gen_ld(ctx, mips32_op, rt, rs, SIMM(ctx->opcode, 0, 12));
break;
do_st_lr:
gen_st(ctx, mips32_op, rt, rs, SIMM(ctx->opcode, 0, 12));
break;
case SC:
gen_st_cond(ctx, OPC_SC, rt, rs, SIMM(ctx->opcode, 0, 12));
break;
#if defined(TARGET_MIPS64)
case SCD:
gen_st_cond(ctx, OPC_SCD, rt, rs, SIMM(ctx->opcode, 0, 12));
break;
#endif
case PREF:
break;
default:
MIPS_INVAL("pool32c");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case ADDI32:
mips32_op = OPC_ADDI;
goto do_addi;
case ADDIU32:
mips32_op = OPC_ADDIU;
do_addi:
gen_arith_imm(ctx, mips32_op, rt, rs, imm);
break;
case ORI32:
mips32_op = OPC_ORI;
goto do_logici;
case XORI32:
mips32_op = OPC_XORI;
goto do_logici;
case ANDI32:
mips32_op = OPC_ANDI;
do_logici:
gen_logic_imm(ctx, mips32_op, rt, rs, imm);
break;
case SLTI32:
mips32_op = OPC_SLTI;
goto do_slti;
case SLTIU32:
mips32_op = OPC_SLTIU;
do_slti:
gen_slt_imm(ctx, mips32_op, rt, rs, imm);
break;
case JALX32:
offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 2;
gen_compute_branch(ctx, OPC_JALX, 4, rt, rs, offset);
break;
case JALS32:
offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 1;
gen_compute_branch(ctx, OPC_JALS, 4, rt, rs, offset);
break;
case BEQ32:
gen_compute_branch(ctx, OPC_BEQ, 4, rt, rs, imm << 1);
break;
case BNE32:
gen_compute_branch(ctx, OPC_BNE, 4, rt, rs, imm << 1);
break;
case J32:
gen_compute_branch(ctx, OPC_J, 4, rt, rs,
(int32_t)(ctx->opcode & 0x3FFFFFF) << 1);
break;
case JAL32:
gen_compute_branch(ctx, OPC_JAL, 4, rt, rs,
(int32_t)(ctx->opcode & 0x3FFFFFF) << 1);
break;
case LWC132:
mips32_op = OPC_LWC1;
goto do_cop1;
case LDC132:
mips32_op = OPC_LDC1;
goto do_cop1;
case SWC132:
mips32_op = OPC_SWC1;
goto do_cop1;
case SDC132:
mips32_op = OPC_SDC1;
do_cop1:
gen_cop1_ldst(env, ctx, mips32_op, rt, rs, imm);
break;
case ADDIUPC:
{
int reg = mmreg(ZIMM(ctx->opcode, 23, 3));
int offset = SIMM(ctx->opcode, 0, 23) << 2;
gen_addiupc(ctx, reg, offset, 0, 0);
}
break;
case LB32:
mips32_op = OPC_LB;
goto do_ld;
case LBU32:
mips32_op = OPC_LBU;
goto do_ld;
case LH32:
mips32_op = OPC_LH;
goto do_ld;
case LHU32:
mips32_op = OPC_LHU;
goto do_ld;
case LW32:
mips32_op = OPC_LW;
goto do_ld;
#ifdef TARGET_MIPS64
case LD32:
mips32_op = OPC_LD;
goto do_ld;
case SD32:
mips32_op = OPC_SD;
goto do_st;
#endif
case SB32:
mips32_op = OPC_SB;
goto do_st;
case SH32:
mips32_op = OPC_SH;
goto do_st;
case SW32:
mips32_op = OPC_SW;
goto do_st;
do_ld:
gen_ld(ctx, mips32_op, rt, rs, imm);
break;
do_st:
gen_st(ctx, mips32_op, rt, rs, imm);
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (CPUMIPSState *VAR_0, DisasContext *VAR_1,
uint16_t VAR_2)
{
int32_t VAR_8;
uint16_t insn;
int VAR_3, VAR_4, VAR_5, VAR_6;
int16_t imm;
uint32_t op, minor, mips32_op;
uint32_t cond, fmt, cc;
insn = cpu_lduw_code(VAR_0, VAR_1->pc + 2);
VAR_1->opcode = (VAR_1->opcode << 16) | insn;
VAR_3 = (VAR_1->opcode >> 21) & 0x1f;
VAR_4 = (VAR_1->opcode >> 16) & 0x1f;
VAR_5 = (VAR_1->opcode >> 11) & 0x1f;
VAR_6 = (VAR_1->opcode >> 6) & 0x1f;
imm = (int16_t) VAR_1->opcode;
op = (VAR_1->opcode >> 26) & 0x3f;
switch (op) {
case POOL32A:
minor = VAR_1->opcode & 0x3f;
switch (minor) {
case 0x00:
minor = (VAR_1->opcode >> 6) & 0xf;
switch (minor) {
case SLL32:
mips32_op = OPC_SLL;
goto do_shifti;
case SRA:
mips32_op = OPC_SRA;
goto do_shifti;
case SRL32:
mips32_op = OPC_SRL;
goto do_shifti;
case ROTR:
mips32_op = OPC_ROTR;
do_shifti:
gen_shift_imm(VAR_1, mips32_op, VAR_3, VAR_4, VAR_5);
break;
default:
goto pool32a_invalid;
}
break;
case 0x10:
minor = (VAR_1->opcode >> 6) & 0xf;
switch (minor) {
case ADD:
mips32_op = OPC_ADD;
goto do_arith;
case ADDU32:
mips32_op = OPC_ADDU;
goto do_arith;
case SUB:
mips32_op = OPC_SUB;
goto do_arith;
case SUBU32:
mips32_op = OPC_SUBU;
goto do_arith;
case MUL:
mips32_op = OPC_MUL;
do_arith:
gen_arith(VAR_1, mips32_op, VAR_5, VAR_4, VAR_3);
break;
case SLLV:
mips32_op = OPC_SLLV;
goto do_shift;
case SRLV:
mips32_op = OPC_SRLV;
goto do_shift;
case SRAV:
mips32_op = OPC_SRAV;
goto do_shift;
case ROTRV:
mips32_op = OPC_ROTRV;
do_shift:
gen_shift(VAR_1, mips32_op, VAR_5, VAR_4, VAR_3);
break;
case AND:
mips32_op = OPC_AND;
goto do_logic;
case OR32:
mips32_op = OPC_OR;
goto do_logic;
case NOR:
mips32_op = OPC_NOR;
goto do_logic;
case XOR32:
mips32_op = OPC_XOR;
do_logic:
gen_logic(VAR_1, mips32_op, VAR_5, VAR_4, VAR_3);
break;
case SLT:
mips32_op = OPC_SLT;
goto do_slt;
case SLTU:
mips32_op = OPC_SLTU;
do_slt:
gen_slt(VAR_1, mips32_op, VAR_5, VAR_4, VAR_3);
break;
default:
goto pool32a_invalid;
}
break;
case 0x18:
minor = (VAR_1->opcode >> 6) & 0xf;
switch (minor) {
case MOVN:
mips32_op = OPC_MOVN;
goto do_cmov;
case MOVZ:
mips32_op = OPC_MOVZ;
do_cmov:
gen_cond_move(VAR_1, mips32_op, VAR_5, VAR_4, VAR_3);
break;
case LWXS:
gen_ldxs(VAR_1, VAR_4, VAR_3, VAR_5);
break;
default:
goto pool32a_invalid;
}
break;
case INS:
gen_bitops(VAR_1, OPC_INS, VAR_3, VAR_4, VAR_6, VAR_5);
return;
case EXT:
gen_bitops(VAR_1, OPC_EXT, VAR_3, VAR_4, VAR_6, VAR_5);
return;
case POOL32AXF:
gen_pool32axf(VAR_0, VAR_1, VAR_3, VAR_4);
break;
case 0x07:
generate_exception(VAR_1, EXCP_BREAK);
break;
default:
pool32a_invalid:
MIPS_INVAL("pool32a");
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case POOL32B:
minor = (VAR_1->opcode >> 12) & 0xf;
switch (minor) {
case CACHE:
check_cp0_enabled(VAR_1);
break;
case LWC2:
case SWC2:
generate_exception_err(VAR_1, EXCP_CpU, 2);
break;
case LWP:
case SWP:
#ifdef TARGET_MIPS64
case LDP:
case SDP:
#endif
gen_ldst_pair(VAR_1, minor, VAR_3, VAR_4, SIMM(VAR_1->opcode, 0, 12));
break;
case LWM32:
case SWM32:
#ifdef TARGET_MIPS64
case LDM:
case SDM:
#endif
gen_ldst_multiple(VAR_1, minor, VAR_3, VAR_4, SIMM(VAR_1->opcode, 0, 12));
break;
default:
MIPS_INVAL("pool32b");
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case POOL32F:
if (VAR_0->CP0_Config1 & (1 << CP0C1_FP)) {
minor = VAR_1->opcode & 0x3f;
check_cp1_enabled(VAR_1);
switch (minor) {
case ALNV_PS:
mips32_op = OPC_ALNV_PS;
goto do_madd;
case MADD_S:
mips32_op = OPC_MADD_S;
goto do_madd;
case MADD_D:
mips32_op = OPC_MADD_D;
goto do_madd;
case MADD_PS:
mips32_op = OPC_MADD_PS;
goto do_madd;
case MSUB_S:
mips32_op = OPC_MSUB_S;
goto do_madd;
case MSUB_D:
mips32_op = OPC_MSUB_D;
goto do_madd;
case MSUB_PS:
mips32_op = OPC_MSUB_PS;
goto do_madd;
case NMADD_S:
mips32_op = OPC_NMADD_S;
goto do_madd;
case NMADD_D:
mips32_op = OPC_NMADD_D;
goto do_madd;
case NMADD_PS:
mips32_op = OPC_NMADD_PS;
goto do_madd;
case NMSUB_S:
mips32_op = OPC_NMSUB_S;
goto do_madd;
case NMSUB_D:
mips32_op = OPC_NMSUB_D;
goto do_madd;
case NMSUB_PS:
mips32_op = OPC_NMSUB_PS;
do_madd:
gen_flt3_arith(VAR_1, mips32_op, VAR_5, VAR_6, VAR_4, VAR_3);
break;
case CABS_COND_FMT:
cond = (VAR_1->opcode >> 6) & 0xf;
cc = (VAR_1->opcode >> 13) & 0x7;
fmt = (VAR_1->opcode >> 10) & 0x3;
switch (fmt) {
case 0x0:
gen_cmpabs_s(VAR_1, cond, VAR_3, VAR_4, cc);
break;
case 0x1:
gen_cmpabs_d(VAR_1, cond, VAR_3, VAR_4, cc);
break;
case 0x2:
gen_cmpabs_ps(VAR_1, cond, VAR_3, VAR_4, cc);
break;
default:
goto pool32f_invalid;
}
break;
case C_COND_FMT:
cond = (VAR_1->opcode >> 6) & 0xf;
cc = (VAR_1->opcode >> 13) & 0x7;
fmt = (VAR_1->opcode >> 10) & 0x3;
switch (fmt) {
case 0x0:
gen_cmp_s(VAR_1, cond, VAR_3, VAR_4, cc);
break;
case 0x1:
gen_cmp_d(VAR_1, cond, VAR_3, VAR_4, cc);
break;
case 0x2:
gen_cmp_ps(VAR_1, cond, VAR_3, VAR_4, cc);
break;
default:
goto pool32f_invalid;
}
break;
case POOL32FXF:
gen_pool32fxf(VAR_1, VAR_3, VAR_4);
break;
case 0x00:
switch ((VAR_1->opcode >> 6) & 0x7) {
case PLL_PS:
mips32_op = OPC_PLL_PS;
goto do_ps;
case PLU_PS:
mips32_op = OPC_PLU_PS;
goto do_ps;
case PUL_PS:
mips32_op = OPC_PUL_PS;
goto do_ps;
case PUU_PS:
mips32_op = OPC_PUU_PS;
goto do_ps;
case CVT_PS_S:
mips32_op = OPC_CVT_PS_S;
do_ps:
gen_farith(VAR_1, mips32_op, VAR_3, VAR_4, VAR_5, 0);
break;
default:
goto pool32f_invalid;
}
break;
case 0x08:
switch ((VAR_1->opcode >> 6) & 0x7) {
case LWXC1:
mips32_op = OPC_LWXC1;
goto do_ldst_cp1;
case SWXC1:
mips32_op = OPC_SWXC1;
goto do_ldst_cp1;
case LDXC1:
mips32_op = OPC_LDXC1;
goto do_ldst_cp1;
case SDXC1:
mips32_op = OPC_SDXC1;
goto do_ldst_cp1;
case LUXC1:
mips32_op = OPC_LUXC1;
goto do_ldst_cp1;
case SUXC1:
mips32_op = OPC_SUXC1;
do_ldst_cp1:
gen_flt3_ldst(VAR_1, mips32_op, VAR_5, VAR_5, VAR_3, VAR_4);
break;
default:
goto pool32f_invalid;
}
break;
case 0x18:
fmt = (VAR_1->opcode >> 9) & 0x3;
switch ((VAR_1->opcode >> 6) & 0x7) {
case RSQRT2_FMT:
switch (fmt) {
case FMT_SDPS_S:
mips32_op = OPC_RSQRT2_S;
goto do_3d;
case FMT_SDPS_D:
mips32_op = OPC_RSQRT2_D;
goto do_3d;
case FMT_SDPS_PS:
mips32_op = OPC_RSQRT2_PS;
goto do_3d;
default:
goto pool32f_invalid;
}
break;
case RECIP2_FMT:
switch (fmt) {
case FMT_SDPS_S:
mips32_op = OPC_RECIP2_S;
goto do_3d;
case FMT_SDPS_D:
mips32_op = OPC_RECIP2_D;
goto do_3d;
case FMT_SDPS_PS:
mips32_op = OPC_RECIP2_PS;
goto do_3d;
default:
goto pool32f_invalid;
}
break;
case ADDR_PS:
mips32_op = OPC_ADDR_PS;
goto do_3d;
case MULR_PS:
mips32_op = OPC_MULR_PS;
do_3d:
gen_farith(VAR_1, mips32_op, VAR_3, VAR_4, VAR_5, 0);
break;
default:
goto pool32f_invalid;
}
break;
case 0x20:
cc = (VAR_1->opcode >> 13) & 0x7;
fmt = (VAR_1->opcode >> 9) & 0x3;
switch ((VAR_1->opcode >> 6) & 0x7) {
case MOVF_FMT:
switch (fmt) {
case FMT_SDPS_S:
gen_movcf_s(VAR_4, VAR_3, cc, 0);
break;
case FMT_SDPS_D:
gen_movcf_d(VAR_1, VAR_4, VAR_3, cc, 0);
break;
case FMT_SDPS_PS:
gen_movcf_ps(VAR_4, VAR_3, cc, 0);
break;
default:
goto pool32f_invalid;
}
break;
case MOVT_FMT:
switch (fmt) {
case FMT_SDPS_S:
gen_movcf_s(VAR_4, VAR_3, cc, 1);
break;
case FMT_SDPS_D:
gen_movcf_d(VAR_1, VAR_4, VAR_3, cc, 1);
break;
case FMT_SDPS_PS:
gen_movcf_ps(VAR_4, VAR_3, cc, 1);
break;
default:
goto pool32f_invalid;
}
break;
case PREFX:
break;
default:
goto pool32f_invalid;
}
break;
#define FINSN_3ARG_SDPS(prfx) \
switch ((VAR_1->opcode >> 8) & 0x3) { \
case FMT_SDPS_S: \
mips32_op = OPC_##prfx##_S; \
goto do_fpop; \
case FMT_SDPS_D: \
mips32_op = OPC_##prfx##_D; \
goto do_fpop; \
case FMT_SDPS_PS: \
mips32_op = OPC_##prfx##_PS; \
goto do_fpop; \
default: \
goto pool32f_invalid; \
}
case 0x30:
switch ((VAR_1->opcode >> 6) & 0x3) {
case ADD_FMT:
FINSN_3ARG_SDPS(ADD);
break;
case SUB_FMT:
FINSN_3ARG_SDPS(SUB);
break;
case MUL_FMT:
FINSN_3ARG_SDPS(MUL);
break;
case DIV_FMT:
fmt = (VAR_1->opcode >> 8) & 0x3;
if (fmt == 1) {
mips32_op = OPC_DIV_D;
} else if (fmt == 0) {
mips32_op = OPC_DIV_S;
} else {
goto pool32f_invalid;
}
goto do_fpop;
default:
goto pool32f_invalid;
}
break;
case 0x38:
switch ((VAR_1->opcode >> 6) & 0x3) {
case MOVN_FMT:
FINSN_3ARG_SDPS(MOVN);
break;
case MOVZ_FMT:
FINSN_3ARG_SDPS(MOVZ);
break;
default:
goto pool32f_invalid;
}
break;
do_fpop:
gen_farith(VAR_1, mips32_op, VAR_3, VAR_4, VAR_5, 0);
break;
default:
pool32f_invalid:
MIPS_INVAL("pool32f");
generate_exception(VAR_1, EXCP_RI);
break;
}
} else {
generate_exception_err(VAR_1, EXCP_CpU, 1);
}
break;
case POOL32I:
minor = (VAR_1->opcode >> 21) & 0x1f;
switch (minor) {
case BLTZ:
mips32_op = OPC_BLTZ;
goto do_branch;
case BLTZAL:
mips32_op = OPC_BLTZAL;
goto do_branch;
case BLTZALS:
mips32_op = OPC_BLTZALS;
goto do_branch;
case BGEZ:
mips32_op = OPC_BGEZ;
goto do_branch;
case BGEZAL:
mips32_op = OPC_BGEZAL;
goto do_branch;
case BGEZALS:
mips32_op = OPC_BGEZALS;
goto do_branch;
case BLEZ:
mips32_op = OPC_BLEZ;
goto do_branch;
case BGTZ:
mips32_op = OPC_BGTZ;
do_branch:
gen_compute_branch(VAR_1, mips32_op, 4, VAR_4, -1, imm << 1);
break;
case TLTI:
mips32_op = OPC_TLTI;
goto do_trapi;
case TGEI:
mips32_op = OPC_TGEI;
goto do_trapi;
case TLTIU:
mips32_op = OPC_TLTIU;
goto do_trapi;
case TGEIU:
mips32_op = OPC_TGEIU;
goto do_trapi;
case TNEI:
mips32_op = OPC_TNEI;
goto do_trapi;
case TEQI:
mips32_op = OPC_TEQI;
do_trapi:
gen_trap(VAR_1, mips32_op, VAR_4, -1, imm);
break;
case BNEZC:
case BEQZC:
gen_compute_branch(VAR_1, minor == BNEZC ? OPC_BNE : OPC_BEQ,
4, VAR_4, 0, imm << 1);
break;
case LUI:
gen_logic_imm(VAR_1, OPC_LUI, VAR_4, -1, imm);
break;
case SYNCI:
break;
case BC2F:
case BC2T:
generate_exception_err(VAR_1, EXCP_CpU, 2);
break;
case BC1F:
mips32_op = (VAR_1->opcode & (1 << 16)) ? OPC_BC1FANY2 : OPC_BC1F;
goto do_cp1branch;
case BC1T:
mips32_op = (VAR_1->opcode & (1 << 16)) ? OPC_BC1TANY2 : OPC_BC1T;
goto do_cp1branch;
case BC1ANY4F:
mips32_op = OPC_BC1FANY4;
goto do_cp1mips3d;
case BC1ANY4T:
mips32_op = OPC_BC1TANY4;
do_cp1mips3d:
check_cop1x(VAR_1);
check_insn(VAR_1, ASE_MIPS3D);
do_cp1branch:
gen_compute_branch1(VAR_1, mips32_op,
(VAR_1->opcode >> 18) & 0x7, imm << 1);
break;
case BPOSGE64:
case BPOSGE32:
default:
MIPS_INVAL("pool32i");
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case POOL32C:
minor = (VAR_1->opcode >> 12) & 0xf;
switch (minor) {
case LWL:
mips32_op = OPC_LWL;
goto do_ld_lr;
case SWL:
mips32_op = OPC_SWL;
goto do_st_lr;
case LWR:
mips32_op = OPC_LWR;
goto do_ld_lr;
case SWR:
mips32_op = OPC_SWR;
goto do_st_lr;
#if defined(TARGET_MIPS64)
case LDL:
mips32_op = OPC_LDL;
goto do_ld_lr;
case SDL:
mips32_op = OPC_SDL;
goto do_st_lr;
case LDR:
mips32_op = OPC_LDR;
goto do_ld_lr;
case SDR:
mips32_op = OPC_SDR;
goto do_st_lr;
case LWU:
mips32_op = OPC_LWU;
goto do_ld_lr;
case LLD:
mips32_op = OPC_LLD;
goto do_ld_lr;
#endif
case LL:
mips32_op = OPC_LL;
goto do_ld_lr;
do_ld_lr:
gen_ld(VAR_1, mips32_op, VAR_3, VAR_4, SIMM(VAR_1->opcode, 0, 12));
break;
do_st_lr:
gen_st(VAR_1, mips32_op, VAR_3, VAR_4, SIMM(VAR_1->opcode, 0, 12));
break;
case SC:
gen_st_cond(VAR_1, OPC_SC, VAR_3, VAR_4, SIMM(VAR_1->opcode, 0, 12));
break;
#if defined(TARGET_MIPS64)
case SCD:
gen_st_cond(VAR_1, OPC_SCD, VAR_3, VAR_4, SIMM(VAR_1->opcode, 0, 12));
break;
#endif
case PREF:
break;
default:
MIPS_INVAL("pool32c");
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case ADDI32:
mips32_op = OPC_ADDI;
goto do_addi;
case ADDIU32:
mips32_op = OPC_ADDIU;
do_addi:
gen_arith_imm(VAR_1, mips32_op, VAR_3, VAR_4, imm);
break;
case ORI32:
mips32_op = OPC_ORI;
goto do_logici;
case XORI32:
mips32_op = OPC_XORI;
goto do_logici;
case ANDI32:
mips32_op = OPC_ANDI;
do_logici:
gen_logic_imm(VAR_1, mips32_op, VAR_3, VAR_4, imm);
break;
case SLTI32:
mips32_op = OPC_SLTI;
goto do_slti;
case SLTIU32:
mips32_op = OPC_SLTIU;
do_slti:
gen_slt_imm(VAR_1, mips32_op, VAR_3, VAR_4, imm);
break;
case JALX32:
VAR_8 = (int32_t)(VAR_1->opcode & 0x3FFFFFF) << 2;
gen_compute_branch(VAR_1, OPC_JALX, 4, VAR_3, VAR_4, VAR_8);
break;
case JALS32:
VAR_8 = (int32_t)(VAR_1->opcode & 0x3FFFFFF) << 1;
gen_compute_branch(VAR_1, OPC_JALS, 4, VAR_3, VAR_4, VAR_8);
break;
case BEQ32:
gen_compute_branch(VAR_1, OPC_BEQ, 4, VAR_3, VAR_4, imm << 1);
break;
case BNE32:
gen_compute_branch(VAR_1, OPC_BNE, 4, VAR_3, VAR_4, imm << 1);
break;
case J32:
gen_compute_branch(VAR_1, OPC_J, 4, VAR_3, VAR_4,
(int32_t)(VAR_1->opcode & 0x3FFFFFF) << 1);
break;
case JAL32:
gen_compute_branch(VAR_1, OPC_JAL, 4, VAR_3, VAR_4,
(int32_t)(VAR_1->opcode & 0x3FFFFFF) << 1);
break;
case LWC132:
mips32_op = OPC_LWC1;
goto do_cop1;
case LDC132:
mips32_op = OPC_LDC1;
goto do_cop1;
case SWC132:
mips32_op = OPC_SWC1;
goto do_cop1;
case SDC132:
mips32_op = OPC_SDC1;
do_cop1:
gen_cop1_ldst(VAR_0, VAR_1, mips32_op, VAR_3, VAR_4, imm);
break;
case ADDIUPC:
{
int VAR_7 = mmreg(ZIMM(VAR_1->opcode, 23, 3));
int VAR_8 = SIMM(VAR_1->opcode, 0, 23) << 2;
gen_addiupc(VAR_1, VAR_7, VAR_8, 0, 0);
}
break;
case LB32:
mips32_op = OPC_LB;
goto do_ld;
case LBU32:
mips32_op = OPC_LBU;
goto do_ld;
case LH32:
mips32_op = OPC_LH;
goto do_ld;
case LHU32:
mips32_op = OPC_LHU;
goto do_ld;
case LW32:
mips32_op = OPC_LW;
goto do_ld;
#ifdef TARGET_MIPS64
case LD32:
mips32_op = OPC_LD;
goto do_ld;
case SD32:
mips32_op = OPC_SD;
goto do_st;
#endif
case SB32:
mips32_op = OPC_SB;
goto do_st;
case SH32:
mips32_op = OPC_SH;
goto do_st;
case SW32:
mips32_op = OPC_SW;
goto do_st;
do_ld:
gen_ld(VAR_1, mips32_op, VAR_3, VAR_4, imm);
break;
do_st:
gen_st(VAR_1, mips32_op, VAR_3, VAR_4, imm);
break;
default:
generate_exception(VAR_1, EXCP_RI);
break;
}
}
| [
"static void FUNC_0 (CPUMIPSState *VAR_0, DisasContext *VAR_1,\nuint16_t VAR_2)\n{",
"int32_t VAR_8;",
"uint16_t insn;",
"int VAR_3, VAR_4, VAR_5, VAR_6;",
"int16_t imm;",
"uint32_t op, minor, mips32_op;",
"uint32_t cond, fmt, cc;",
"insn = cpu_lduw_code(VAR_0, VAR_1->pc + 2);",
"VAR_1->opcode = (VAR_1->opcode << 16) | insn;",
"VAR_3 = (VAR_1->opcode >> 21) & 0x1f;",
"VAR_4 = (VAR_1->opcode >> 16) & 0x1f;",
"VAR_5 = (VAR_1->opcode >> 11) & 0x1f;",
"VAR_6 = (VAR_1->opcode >> 6) & 0x1f;",
"imm = (int16_t) VAR_1->opcode;",
"op = (VAR_1->opcode >> 26) & 0x3f;",
"switch (op) {",
"case POOL32A:\nminor = VAR_1->opcode & 0x3f;",
"switch (minor) {",
"case 0x00:\nminor = (VAR_1->opcode >> 6) & 0xf;",
"switch (minor) {",
"case SLL32:\nmips32_op = OPC_SLL;",
"goto do_shifti;",
"case SRA:\nmips32_op = OPC_SRA;",
"goto do_shifti;",
"case SRL32:\nmips32_op = OPC_SRL;",
"goto do_shifti;",
"case ROTR:\nmips32_op = OPC_ROTR;",
"do_shifti:\ngen_shift_imm(VAR_1, mips32_op, VAR_3, VAR_4, VAR_5);",
"break;",
"default:\ngoto pool32a_invalid;",
"}",
"break;",
"case 0x10:\nminor = (VAR_1->opcode >> 6) & 0xf;",
"switch (minor) {",
"case ADD:\nmips32_op = OPC_ADD;",
"goto do_arith;",
"case ADDU32:\nmips32_op = OPC_ADDU;",
"goto do_arith;",
"case SUB:\nmips32_op = OPC_SUB;",
"goto do_arith;",
"case SUBU32:\nmips32_op = OPC_SUBU;",
"goto do_arith;",
"case MUL:\nmips32_op = OPC_MUL;",
"do_arith:\ngen_arith(VAR_1, mips32_op, VAR_5, VAR_4, VAR_3);",
"break;",
"case SLLV:\nmips32_op = OPC_SLLV;",
"goto do_shift;",
"case SRLV:\nmips32_op = OPC_SRLV;",
"goto do_shift;",
"case SRAV:\nmips32_op = OPC_SRAV;",
"goto do_shift;",
"case ROTRV:\nmips32_op = OPC_ROTRV;",
"do_shift:\ngen_shift(VAR_1, mips32_op, VAR_5, VAR_4, VAR_3);",
"break;",
"case AND:\nmips32_op = OPC_AND;",
"goto do_logic;",
"case OR32:\nmips32_op = OPC_OR;",
"goto do_logic;",
"case NOR:\nmips32_op = OPC_NOR;",
"goto do_logic;",
"case XOR32:\nmips32_op = OPC_XOR;",
"do_logic:\ngen_logic(VAR_1, mips32_op, VAR_5, VAR_4, VAR_3);",
"break;",
"case SLT:\nmips32_op = OPC_SLT;",
"goto do_slt;",
"case SLTU:\nmips32_op = OPC_SLTU;",
"do_slt:\ngen_slt(VAR_1, mips32_op, VAR_5, VAR_4, VAR_3);",
"break;",
"default:\ngoto pool32a_invalid;",
"}",
"break;",
"case 0x18:\nminor = (VAR_1->opcode >> 6) & 0xf;",
"switch (minor) {",
"case MOVN:\nmips32_op = OPC_MOVN;",
"goto do_cmov;",
"case MOVZ:\nmips32_op = OPC_MOVZ;",
"do_cmov:\ngen_cond_move(VAR_1, mips32_op, VAR_5, VAR_4, VAR_3);",
"break;",
"case LWXS:\ngen_ldxs(VAR_1, VAR_4, VAR_3, VAR_5);",
"break;",
"default:\ngoto pool32a_invalid;",
"}",
"break;",
"case INS:\ngen_bitops(VAR_1, OPC_INS, VAR_3, VAR_4, VAR_6, VAR_5);",
"return;",
"case EXT:\ngen_bitops(VAR_1, OPC_EXT, VAR_3, VAR_4, VAR_6, VAR_5);",
"return;",
"case POOL32AXF:\ngen_pool32axf(VAR_0, VAR_1, VAR_3, VAR_4);",
"break;",
"case 0x07:\ngenerate_exception(VAR_1, EXCP_BREAK);",
"break;",
"default:\npool32a_invalid:\nMIPS_INVAL(\"pool32a\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case POOL32B:\nminor = (VAR_1->opcode >> 12) & 0xf;",
"switch (minor) {",
"case CACHE:\ncheck_cp0_enabled(VAR_1);",
"break;",
"case LWC2:\ncase SWC2:\ngenerate_exception_err(VAR_1, EXCP_CpU, 2);",
"break;",
"case LWP:\ncase SWP:\n#ifdef TARGET_MIPS64\ncase LDP:\ncase SDP:\n#endif\ngen_ldst_pair(VAR_1, minor, VAR_3, VAR_4, SIMM(VAR_1->opcode, 0, 12));",
"break;",
"case LWM32:\ncase SWM32:\n#ifdef TARGET_MIPS64\ncase LDM:\ncase SDM:\n#endif\ngen_ldst_multiple(VAR_1, minor, VAR_3, VAR_4, SIMM(VAR_1->opcode, 0, 12));",
"break;",
"default:\nMIPS_INVAL(\"pool32b\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case POOL32F:\nif (VAR_0->CP0_Config1 & (1 << CP0C1_FP)) {",
"minor = VAR_1->opcode & 0x3f;",
"check_cp1_enabled(VAR_1);",
"switch (minor) {",
"case ALNV_PS:\nmips32_op = OPC_ALNV_PS;",
"goto do_madd;",
"case MADD_S:\nmips32_op = OPC_MADD_S;",
"goto do_madd;",
"case MADD_D:\nmips32_op = OPC_MADD_D;",
"goto do_madd;",
"case MADD_PS:\nmips32_op = OPC_MADD_PS;",
"goto do_madd;",
"case MSUB_S:\nmips32_op = OPC_MSUB_S;",
"goto do_madd;",
"case MSUB_D:\nmips32_op = OPC_MSUB_D;",
"goto do_madd;",
"case MSUB_PS:\nmips32_op = OPC_MSUB_PS;",
"goto do_madd;",
"case NMADD_S:\nmips32_op = OPC_NMADD_S;",
"goto do_madd;",
"case NMADD_D:\nmips32_op = OPC_NMADD_D;",
"goto do_madd;",
"case NMADD_PS:\nmips32_op = OPC_NMADD_PS;",
"goto do_madd;",
"case NMSUB_S:\nmips32_op = OPC_NMSUB_S;",
"goto do_madd;",
"case NMSUB_D:\nmips32_op = OPC_NMSUB_D;",
"goto do_madd;",
"case NMSUB_PS:\nmips32_op = OPC_NMSUB_PS;",
"do_madd:\ngen_flt3_arith(VAR_1, mips32_op, VAR_5, VAR_6, VAR_4, VAR_3);",
"break;",
"case CABS_COND_FMT:\ncond = (VAR_1->opcode >> 6) & 0xf;",
"cc = (VAR_1->opcode >> 13) & 0x7;",
"fmt = (VAR_1->opcode >> 10) & 0x3;",
"switch (fmt) {",
"case 0x0:\ngen_cmpabs_s(VAR_1, cond, VAR_3, VAR_4, cc);",
"break;",
"case 0x1:\ngen_cmpabs_d(VAR_1, cond, VAR_3, VAR_4, cc);",
"break;",
"case 0x2:\ngen_cmpabs_ps(VAR_1, cond, VAR_3, VAR_4, cc);",
"break;",
"default:\ngoto pool32f_invalid;",
"}",
"break;",
"case C_COND_FMT:\ncond = (VAR_1->opcode >> 6) & 0xf;",
"cc = (VAR_1->opcode >> 13) & 0x7;",
"fmt = (VAR_1->opcode >> 10) & 0x3;",
"switch (fmt) {",
"case 0x0:\ngen_cmp_s(VAR_1, cond, VAR_3, VAR_4, cc);",
"break;",
"case 0x1:\ngen_cmp_d(VAR_1, cond, VAR_3, VAR_4, cc);",
"break;",
"case 0x2:\ngen_cmp_ps(VAR_1, cond, VAR_3, VAR_4, cc);",
"break;",
"default:\ngoto pool32f_invalid;",
"}",
"break;",
"case POOL32FXF:\ngen_pool32fxf(VAR_1, VAR_3, VAR_4);",
"break;",
"case 0x00:\nswitch ((VAR_1->opcode >> 6) & 0x7) {",
"case PLL_PS:\nmips32_op = OPC_PLL_PS;",
"goto do_ps;",
"case PLU_PS:\nmips32_op = OPC_PLU_PS;",
"goto do_ps;",
"case PUL_PS:\nmips32_op = OPC_PUL_PS;",
"goto do_ps;",
"case PUU_PS:\nmips32_op = OPC_PUU_PS;",
"goto do_ps;",
"case CVT_PS_S:\nmips32_op = OPC_CVT_PS_S;",
"do_ps:\ngen_farith(VAR_1, mips32_op, VAR_3, VAR_4, VAR_5, 0);",
"break;",
"default:\ngoto pool32f_invalid;",
"}",
"break;",
"case 0x08:\nswitch ((VAR_1->opcode >> 6) & 0x7) {",
"case LWXC1:\nmips32_op = OPC_LWXC1;",
"goto do_ldst_cp1;",
"case SWXC1:\nmips32_op = OPC_SWXC1;",
"goto do_ldst_cp1;",
"case LDXC1:\nmips32_op = OPC_LDXC1;",
"goto do_ldst_cp1;",
"case SDXC1:\nmips32_op = OPC_SDXC1;",
"goto do_ldst_cp1;",
"case LUXC1:\nmips32_op = OPC_LUXC1;",
"goto do_ldst_cp1;",
"case SUXC1:\nmips32_op = OPC_SUXC1;",
"do_ldst_cp1:\ngen_flt3_ldst(VAR_1, mips32_op, VAR_5, VAR_5, VAR_3, VAR_4);",
"break;",
"default:\ngoto pool32f_invalid;",
"}",
"break;",
"case 0x18:\nfmt = (VAR_1->opcode >> 9) & 0x3;",
"switch ((VAR_1->opcode >> 6) & 0x7) {",
"case RSQRT2_FMT:\nswitch (fmt) {",
"case FMT_SDPS_S:\nmips32_op = OPC_RSQRT2_S;",
"goto do_3d;",
"case FMT_SDPS_D:\nmips32_op = OPC_RSQRT2_D;",
"goto do_3d;",
"case FMT_SDPS_PS:\nmips32_op = OPC_RSQRT2_PS;",
"goto do_3d;",
"default:\ngoto pool32f_invalid;",
"}",
"break;",
"case RECIP2_FMT:\nswitch (fmt) {",
"case FMT_SDPS_S:\nmips32_op = OPC_RECIP2_S;",
"goto do_3d;",
"case FMT_SDPS_D:\nmips32_op = OPC_RECIP2_D;",
"goto do_3d;",
"case FMT_SDPS_PS:\nmips32_op = OPC_RECIP2_PS;",
"goto do_3d;",
"default:\ngoto pool32f_invalid;",
"}",
"break;",
"case ADDR_PS:\nmips32_op = OPC_ADDR_PS;",
"goto do_3d;",
"case MULR_PS:\nmips32_op = OPC_MULR_PS;",
"do_3d:\ngen_farith(VAR_1, mips32_op, VAR_3, VAR_4, VAR_5, 0);",
"break;",
"default:\ngoto pool32f_invalid;",
"}",
"break;",
"case 0x20:\ncc = (VAR_1->opcode >> 13) & 0x7;",
"fmt = (VAR_1->opcode >> 9) & 0x3;",
"switch ((VAR_1->opcode >> 6) & 0x7) {",
"case MOVF_FMT:\nswitch (fmt) {",
"case FMT_SDPS_S:\ngen_movcf_s(VAR_4, VAR_3, cc, 0);",
"break;",
"case FMT_SDPS_D:\ngen_movcf_d(VAR_1, VAR_4, VAR_3, cc, 0);",
"break;",
"case FMT_SDPS_PS:\ngen_movcf_ps(VAR_4, VAR_3, cc, 0);",
"break;",
"default:\ngoto pool32f_invalid;",
"}",
"break;",
"case MOVT_FMT:\nswitch (fmt) {",
"case FMT_SDPS_S:\ngen_movcf_s(VAR_4, VAR_3, cc, 1);",
"break;",
"case FMT_SDPS_D:\ngen_movcf_d(VAR_1, VAR_4, VAR_3, cc, 1);",
"break;",
"case FMT_SDPS_PS:\ngen_movcf_ps(VAR_4, VAR_3, cc, 1);",
"break;",
"default:\ngoto pool32f_invalid;",
"}",
"break;",
"case PREFX:\nbreak;",
"default:\ngoto pool32f_invalid;",
"}",
"break;",
"#define FINSN_3ARG_SDPS(prfx) \\\nswitch ((VAR_1->opcode >> 8) & 0x3) { \\",
"case FMT_SDPS_S: \\\nmips32_op = OPC_##prfx##_S; \\",
"goto do_fpop; \\",
"case FMT_SDPS_D: \\\nmips32_op = OPC_##prfx##_D; \\",
"goto do_fpop; \\",
"case FMT_SDPS_PS: \\\nmips32_op = OPC_##prfx##_PS; \\",
"goto do_fpop; \\",
"default: \\\ngoto pool32f_invalid; \\",
"}",
"case 0x30:\nswitch ((VAR_1->opcode >> 6) & 0x3) {",
"case ADD_FMT:\nFINSN_3ARG_SDPS(ADD);",
"break;",
"case SUB_FMT:\nFINSN_3ARG_SDPS(SUB);",
"break;",
"case MUL_FMT:\nFINSN_3ARG_SDPS(MUL);",
"break;",
"case DIV_FMT:\nfmt = (VAR_1->opcode >> 8) & 0x3;",
"if (fmt == 1) {",
"mips32_op = OPC_DIV_D;",
"} else if (fmt == 0) {",
"mips32_op = OPC_DIV_S;",
"} else {",
"goto pool32f_invalid;",
"}",
"goto do_fpop;",
"default:\ngoto pool32f_invalid;",
"}",
"break;",
"case 0x38:\nswitch ((VAR_1->opcode >> 6) & 0x3) {",
"case MOVN_FMT:\nFINSN_3ARG_SDPS(MOVN);",
"break;",
"case MOVZ_FMT:\nFINSN_3ARG_SDPS(MOVZ);",
"break;",
"default:\ngoto pool32f_invalid;",
"}",
"break;",
"do_fpop:\ngen_farith(VAR_1, mips32_op, VAR_3, VAR_4, VAR_5, 0);",
"break;",
"default:\npool32f_invalid:\nMIPS_INVAL(\"pool32f\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"} else {",
"generate_exception_err(VAR_1, EXCP_CpU, 1);",
"}",
"break;",
"case POOL32I:\nminor = (VAR_1->opcode >> 21) & 0x1f;",
"switch (minor) {",
"case BLTZ:\nmips32_op = OPC_BLTZ;",
"goto do_branch;",
"case BLTZAL:\nmips32_op = OPC_BLTZAL;",
"goto do_branch;",
"case BLTZALS:\nmips32_op = OPC_BLTZALS;",
"goto do_branch;",
"case BGEZ:\nmips32_op = OPC_BGEZ;",
"goto do_branch;",
"case BGEZAL:\nmips32_op = OPC_BGEZAL;",
"goto do_branch;",
"case BGEZALS:\nmips32_op = OPC_BGEZALS;",
"goto do_branch;",
"case BLEZ:\nmips32_op = OPC_BLEZ;",
"goto do_branch;",
"case BGTZ:\nmips32_op = OPC_BGTZ;",
"do_branch:\ngen_compute_branch(VAR_1, mips32_op, 4, VAR_4, -1, imm << 1);",
"break;",
"case TLTI:\nmips32_op = OPC_TLTI;",
"goto do_trapi;",
"case TGEI:\nmips32_op = OPC_TGEI;",
"goto do_trapi;",
"case TLTIU:\nmips32_op = OPC_TLTIU;",
"goto do_trapi;",
"case TGEIU:\nmips32_op = OPC_TGEIU;",
"goto do_trapi;",
"case TNEI:\nmips32_op = OPC_TNEI;",
"goto do_trapi;",
"case TEQI:\nmips32_op = OPC_TEQI;",
"do_trapi:\ngen_trap(VAR_1, mips32_op, VAR_4, -1, imm);",
"break;",
"case BNEZC:\ncase BEQZC:\ngen_compute_branch(VAR_1, minor == BNEZC ? OPC_BNE : OPC_BEQ,\n4, VAR_4, 0, imm << 1);",
"break;",
"case LUI:\ngen_logic_imm(VAR_1, OPC_LUI, VAR_4, -1, imm);",
"break;",
"case SYNCI:\nbreak;",
"case BC2F:\ncase BC2T:\ngenerate_exception_err(VAR_1, EXCP_CpU, 2);",
"break;",
"case BC1F:\nmips32_op = (VAR_1->opcode & (1 << 16)) ? OPC_BC1FANY2 : OPC_BC1F;",
"goto do_cp1branch;",
"case BC1T:\nmips32_op = (VAR_1->opcode & (1 << 16)) ? OPC_BC1TANY2 : OPC_BC1T;",
"goto do_cp1branch;",
"case BC1ANY4F:\nmips32_op = OPC_BC1FANY4;",
"goto do_cp1mips3d;",
"case BC1ANY4T:\nmips32_op = OPC_BC1TANY4;",
"do_cp1mips3d:\ncheck_cop1x(VAR_1);",
"check_insn(VAR_1, ASE_MIPS3D);",
"do_cp1branch:\ngen_compute_branch1(VAR_1, mips32_op,\n(VAR_1->opcode >> 18) & 0x7, imm << 1);",
"break;",
"case BPOSGE64:\ncase BPOSGE32:\ndefault:\nMIPS_INVAL(\"pool32i\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case POOL32C:\nminor = (VAR_1->opcode >> 12) & 0xf;",
"switch (minor) {",
"case LWL:\nmips32_op = OPC_LWL;",
"goto do_ld_lr;",
"case SWL:\nmips32_op = OPC_SWL;",
"goto do_st_lr;",
"case LWR:\nmips32_op = OPC_LWR;",
"goto do_ld_lr;",
"case SWR:\nmips32_op = OPC_SWR;",
"goto do_st_lr;",
"#if defined(TARGET_MIPS64)\ncase LDL:\nmips32_op = OPC_LDL;",
"goto do_ld_lr;",
"case SDL:\nmips32_op = OPC_SDL;",
"goto do_st_lr;",
"case LDR:\nmips32_op = OPC_LDR;",
"goto do_ld_lr;",
"case SDR:\nmips32_op = OPC_SDR;",
"goto do_st_lr;",
"case LWU:\nmips32_op = OPC_LWU;",
"goto do_ld_lr;",
"case LLD:\nmips32_op = OPC_LLD;",
"goto do_ld_lr;",
"#endif\ncase LL:\nmips32_op = OPC_LL;",
"goto do_ld_lr;",
"do_ld_lr:\ngen_ld(VAR_1, mips32_op, VAR_3, VAR_4, SIMM(VAR_1->opcode, 0, 12));",
"break;",
"do_st_lr:\ngen_st(VAR_1, mips32_op, VAR_3, VAR_4, SIMM(VAR_1->opcode, 0, 12));",
"break;",
"case SC:\ngen_st_cond(VAR_1, OPC_SC, VAR_3, VAR_4, SIMM(VAR_1->opcode, 0, 12));",
"break;",
"#if defined(TARGET_MIPS64)\ncase SCD:\ngen_st_cond(VAR_1, OPC_SCD, VAR_3, VAR_4, SIMM(VAR_1->opcode, 0, 12));",
"break;",
"#endif\ncase PREF:\nbreak;",
"default:\nMIPS_INVAL(\"pool32c\");",
"generate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case ADDI32:\nmips32_op = OPC_ADDI;",
"goto do_addi;",
"case ADDIU32:\nmips32_op = OPC_ADDIU;",
"do_addi:\ngen_arith_imm(VAR_1, mips32_op, VAR_3, VAR_4, imm);",
"break;",
"case ORI32:\nmips32_op = OPC_ORI;",
"goto do_logici;",
"case XORI32:\nmips32_op = OPC_XORI;",
"goto do_logici;",
"case ANDI32:\nmips32_op = OPC_ANDI;",
"do_logici:\ngen_logic_imm(VAR_1, mips32_op, VAR_3, VAR_4, imm);",
"break;",
"case SLTI32:\nmips32_op = OPC_SLTI;",
"goto do_slti;",
"case SLTIU32:\nmips32_op = OPC_SLTIU;",
"do_slti:\ngen_slt_imm(VAR_1, mips32_op, VAR_3, VAR_4, imm);",
"break;",
"case JALX32:\nVAR_8 = (int32_t)(VAR_1->opcode & 0x3FFFFFF) << 2;",
"gen_compute_branch(VAR_1, OPC_JALX, 4, VAR_3, VAR_4, VAR_8);",
"break;",
"case JALS32:\nVAR_8 = (int32_t)(VAR_1->opcode & 0x3FFFFFF) << 1;",
"gen_compute_branch(VAR_1, OPC_JALS, 4, VAR_3, VAR_4, VAR_8);",
"break;",
"case BEQ32:\ngen_compute_branch(VAR_1, OPC_BEQ, 4, VAR_3, VAR_4, imm << 1);",
"break;",
"case BNE32:\ngen_compute_branch(VAR_1, OPC_BNE, 4, VAR_3, VAR_4, imm << 1);",
"break;",
"case J32:\ngen_compute_branch(VAR_1, OPC_J, 4, VAR_3, VAR_4,\n(int32_t)(VAR_1->opcode & 0x3FFFFFF) << 1);",
"break;",
"case JAL32:\ngen_compute_branch(VAR_1, OPC_JAL, 4, VAR_3, VAR_4,\n(int32_t)(VAR_1->opcode & 0x3FFFFFF) << 1);",
"break;",
"case LWC132:\nmips32_op = OPC_LWC1;",
"goto do_cop1;",
"case LDC132:\nmips32_op = OPC_LDC1;",
"goto do_cop1;",
"case SWC132:\nmips32_op = OPC_SWC1;",
"goto do_cop1;",
"case SDC132:\nmips32_op = OPC_SDC1;",
"do_cop1:\ngen_cop1_ldst(VAR_0, VAR_1, mips32_op, VAR_3, VAR_4, imm);",
"break;",
"case ADDIUPC:\n{",
"int VAR_7 = mmreg(ZIMM(VAR_1->opcode, 23, 3));",
"int VAR_8 = SIMM(VAR_1->opcode, 0, 23) << 2;",
"gen_addiupc(VAR_1, VAR_7, VAR_8, 0, 0);",
"}",
"break;",
"case LB32:\nmips32_op = OPC_LB;",
"goto do_ld;",
"case LBU32:\nmips32_op = OPC_LBU;",
"goto do_ld;",
"case LH32:\nmips32_op = OPC_LH;",
"goto do_ld;",
"case LHU32:\nmips32_op = OPC_LHU;",
"goto do_ld;",
"case LW32:\nmips32_op = OPC_LW;",
"goto do_ld;",
"#ifdef TARGET_MIPS64\ncase LD32:\nmips32_op = OPC_LD;",
"goto do_ld;",
"case SD32:\nmips32_op = OPC_SD;",
"goto do_st;",
"#endif\ncase SB32:\nmips32_op = OPC_SB;",
"goto do_st;",
"case SH32:\nmips32_op = OPC_SH;",
"goto do_st;",
"case SW32:\nmips32_op = OPC_SW;",
"goto do_st;",
"do_ld:\ngen_ld(VAR_1, mips32_op, VAR_3, VAR_4, imm);",
"break;",
"do_st:\ngen_st(VAR_1, mips32_op, VAR_3, VAR_4, imm);",
"break;",
"default:\ngenerate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49,
51
],
[
53
],
[
55,
57
],
[
59
],
[
61,
63
],
[
65
],
[
67,
69
],
[
71
],
[
73,
75
],
[
77,
79
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
91,
93
],
[
95
],
[
99,
101
],
[
103
],
[
105,
107
],
[
109
],
[
111,
113
],
[
115
],
[
117,
119
],
[
121
],
[
123,
125
],
[
127,
129
],
[
131
],
[
135,
137
],
[
139
],
[
141,
143
],
[
145
],
[
147,
149
],
[
151
],
[
153,
155
],
[
157,
159
],
[
161
],
[
165,
167
],
[
169
],
[
171,
173
],
[
175
],
[
177,
179
],
[
181
],
[
183,
185
],
[
187,
189
],
[
191
],
[
195,
197
],
[
199
],
[
201,
203
],
[
205,
207
],
[
209
],
[
211,
213
],
[
215
],
[
217
],
[
219,
221
],
[
223
],
[
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
],
[
307
],
[
309,
311,
315
],
[
317
],
[
319,
321,
323,
325,
327,
329,
331
],
[
333
],
[
335,
337,
339,
341,
343,
345,
347
],
[
349
],
[
351,
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363,
365
],
[
367
],
[
369
],
[
371
],
[
373,
375
],
[
377
],
[
379,
381
],
[
383
],
[
385,
387
],
[
389
],
[
391,
393
],
[
395
],
[
397,
399
],
[
401
],
[
403,
405
],
[
407
],
[
409,
411
],
[
413
],
[
415,
417
],
[
419
],
[
421,
423
],
[
425
],
[
427,
429
],
[
431
],
[
433,
435
],
[
437
],
[
439,
441
],
[
443
],
[
445,
447
],
[
449,
451
],
[
453
],
[
455,
457
],
[
459
],
[
461
],
[
463
],
[
465,
467
],
[
469
],
[
471,
473
],
[
475
],
[
477,
479
],
[
481
],
[
483,
485
],
[
487
],
[
489
],
[
491,
493
],
[
495
],
[
497
],
[
499
],
[
501,
503
],
[
505
],
[
507,
509
],
[
511
],
[
513,
515
],
[
517
],
[
519,
521
],
[
523
],
[
525
],
[
527,
529
],
[
531
],
[
533,
537
],
[
539,
541
],
[
543
],
[
545,
547
],
[
549
],
[
551,
553
],
[
555
],
[
557,
559
],
[
561
],
[
563,
565
],
[
567,
569
],
[
571
],
[
573,
575
],
[
577
],
[
579
],
[
581,
585
],
[
587,
589
],
[
591
],
[
593,
595
],
[
597
],
[
599,
601
],
[
603
],
[
605,
607
],
[
609
],
[
611,
613
],
[
615
],
[
617,
619
],
[
621,
623
],
[
625
],
[
627,
629
],
[
631
],
[
633
],
[
635,
639
],
[
641
],
[
643,
645
],
[
647,
649
],
[
651
],
[
653,
655
],
[
657
],
[
659,
661
],
[
663
],
[
665,
667
],
[
669
],
[
671
],
[
673,
675
],
[
677,
679
],
[
681
],
[
683,
685
],
[
687
],
[
689,
691
],
[
693
],
[
695,
697
],
[
699
],
[
701
],
[
703,
705
],
[
707
],
[
709,
711
],
[
713,
715
],
[
717
],
[
719,
721
],
[
723
],
[
725
],
[
727,
731
],
[
733
],
[
735
],
[
737,
739
],
[
741,
743
],
[
745
],
[
747,
749
],
[
751
],
[
753,
755
],
[
757
],
[
759,
761
],
[
763
],
[
765
],
[
767,
769
],
[
771,
773
],
[
775
],
[
777,
779
],
[
781
],
[
783,
785
],
[
787
],
[
789,
791
],
[
793
],
[
795
],
[
797,
799
],
[
801,
803
],
[
805
],
[
807
],
[
809,
811
],
[
813,
815
],
[
817
],
[
819,
821
],
[
823
],
[
825,
827
],
[
829
],
[
831,
833
],
[
835
],
[
837,
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,
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
],
[
993,
995
],
[
997
],
[
1003,
1005
],
[
1007
],
[
1009,
1011
],
[
1013
],
[
1015,
1017
],
[
1019
],
[
1021,
1023
],
[
1025
],
[
1027,
1029
],
[
1031
],
[
1033,
1035
],
[
1037,
1039
],
[
1041
],
[
1045,
1047,
1049,
1051
],
[
1059
],
[
1061,
1063
],
[
1065
],
[
1067,
1069
],
[
1071,
1073,
1077
],
[
1079
],
[
1081,
1083
],
[
1085
],
[
1087,
1089
],
[
1091
],
[
1093,
1095
],
[
1097
],
[
1099,
1101
],
[
1103,
1105
],
[
1107
],
[
1111,
1113,
1115
],
[
1117
],
[
1119,
1121,
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
],
[
1221,
1223
],
[
1225
],
[
1227,
1229
],
[
1231
],
[
1233,
1235,
1237
],
[
1239
],
[
1241,
1243,
1247
],
[
1249,
1251
],
[
1253
],
[
1255
],
[
1257
],
[
1259
],
[
1261,
1263
],
[
1265
],
[
1267,
1269
],
[
1271,
1273
],
[
1275
],
[
1281,
1283
],
[
1285
],
[
1287,
1289
],
[
1291
],
[
1293,
1295
],
[
1297,
1299
],
[
1301
],
[
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
],
[
1369,
1371
],
[
1373
],
[
1375,
1377
],
[
1379
],
[
1381,
1383
],
[
1385
],
[
1387,
1389
],
[
1391,
1393
],
[
1395
],
[
1397,
1399
],
[
1401
],
[
1403
],
[
1407
],
[
1409
],
[
1411
],
[
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,
1469
],
[
1471
],
[
1473,
1475
],
[
1477
],
[
1479,
1481
],
[
1483
],
[
1485,
1487
],
[
1489
],
[
1491,
1493
],
[
1495
],
[
1497
],
[
1499
]
]
|
14,431 | static void test_qga_guest_exec(gconstpointer fix)
{
const TestFixture *fixture = fix;
QDict *ret, *val;
const gchar *out;
guchar *decoded;
int64_t pid, now, exitcode;
gsize len;
bool exited;
/* exec 'echo foo bar' */
ret = qmp_fd(fixture->fd, "{'execute': 'guest-exec', 'arguments': {"
" 'path': '/bin/echo', 'arg': [ '-n', '\" test_str \"' ],"
" 'capture-output': true } }");
g_assert_nonnull(ret);
qmp_assert_no_error(ret);
val = qdict_get_qdict(ret, "return");
pid = qdict_get_int(val, "pid");
g_assert_cmpint(pid, >, 0);
QDECREF(ret);
/* wait for completion */
now = g_get_monotonic_time();
do {
ret = qmp_fd(fixture->fd, "{'execute': 'guest-exec-status',"
" 'arguments': { 'pid': %" PRId64 " } }", pid);
g_assert_nonnull(ret);
val = qdict_get_qdict(ret, "return");
exited = qdict_get_bool(val, "exited");
if (!exited) {
QDECREF(ret);
}
} while (!exited &&
g_get_monotonic_time() < now + 5 * G_TIME_SPAN_SECOND);
g_assert(exited);
/* check stdout */
exitcode = qdict_get_int(val, "exitcode");
g_assert_cmpint(exitcode, ==, 0);
out = qdict_get_str(val, "out-data");
decoded = g_base64_decode(out, &len);
g_assert_cmpint(len, ==, 12);
g_assert_cmpstr((char *)decoded, ==, "\" test_str \"");
g_free(decoded);
QDECREF(ret);
}
| false | qemu | 1792d7d0a2dc18496e8fc52906163f9f73f3d931 | static void test_qga_guest_exec(gconstpointer fix)
{
const TestFixture *fixture = fix;
QDict *ret, *val;
const gchar *out;
guchar *decoded;
int64_t pid, now, exitcode;
gsize len;
bool exited;
ret = qmp_fd(fixture->fd, "{'execute': 'guest-exec', 'arguments': {"
" 'path': '/bin/echo', 'arg': [ '-n', '\" test_str \"' ],"
" 'capture-output': true } }");
g_assert_nonnull(ret);
qmp_assert_no_error(ret);
val = qdict_get_qdict(ret, "return");
pid = qdict_get_int(val, "pid");
g_assert_cmpint(pid, >, 0);
QDECREF(ret);
now = g_get_monotonic_time();
do {
ret = qmp_fd(fixture->fd, "{'execute': 'guest-exec-status',"
" 'arguments': { 'pid': %" PRId64 " } }", pid);
g_assert_nonnull(ret);
val = qdict_get_qdict(ret, "return");
exited = qdict_get_bool(val, "exited");
if (!exited) {
QDECREF(ret);
}
} while (!exited &&
g_get_monotonic_time() < now + 5 * G_TIME_SPAN_SECOND);
g_assert(exited);
exitcode = qdict_get_int(val, "exitcode");
g_assert_cmpint(exitcode, ==, 0);
out = qdict_get_str(val, "out-data");
decoded = g_base64_decode(out, &len);
g_assert_cmpint(len, ==, 12);
g_assert_cmpstr((char *)decoded, ==, "\" test_str \"");
g_free(decoded);
QDECREF(ret);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(gconstpointer VAR_0)
{
const TestFixture *VAR_1 = VAR_0;
QDict *ret, *val;
const gchar *VAR_2;
guchar *decoded;
int64_t pid, now, exitcode;
gsize len;
bool exited;
ret = qmp_fd(VAR_1->fd, "{'execute': 'guest-exec', 'arguments': {"
" 'path': '/bin/echo', 'arg': [ '-n', '\" test_str \"' ],"
" 'capture-output': true } }");
g_assert_nonnull(ret);
qmp_assert_no_error(ret);
val = qdict_get_qdict(ret, "return");
pid = qdict_get_int(val, "pid");
g_assert_cmpint(pid, >, 0);
QDECREF(ret);
now = g_get_monotonic_time();
do {
ret = qmp_fd(VAR_1->fd, "{'execute': 'guest-exec-status',"
" 'arguments': { 'pid': %" PRId64 " } }", pid);
g_assert_nonnull(ret);
val = qdict_get_qdict(ret, "return");
exited = qdict_get_bool(val, "exited");
if (!exited) {
QDECREF(ret);
}
} while (!exited &&
g_get_monotonic_time() < now + 5 * G_TIME_SPAN_SECOND);
g_assert(exited);
exitcode = qdict_get_int(val, "exitcode");
g_assert_cmpint(exitcode, ==, 0);
VAR_2 = qdict_get_str(val, "VAR_2-data");
decoded = g_base64_decode(VAR_2, &len);
g_assert_cmpint(len, ==, 12);
g_assert_cmpstr((char *)decoded, ==, "\" test_str \"");
g_free(decoded);
QDECREF(ret);
}
| [
"static void FUNC_0(gconstpointer VAR_0)\n{",
"const TestFixture *VAR_1 = VAR_0;",
"QDict *ret, *val;",
"const gchar *VAR_2;",
"guchar *decoded;",
"int64_t pid, now, exitcode;",
"gsize len;",
"bool exited;",
"ret = qmp_fd(VAR_1->fd, \"{'execute': 'guest-exec', 'arguments': {\"",
"\" 'path': '/bin/echo', 'arg': [ '-n', '\\\" test_str \\\"' ],\"\n\" 'capture-output': true } }\");",
"g_assert_nonnull(ret);",
"qmp_assert_no_error(ret);",
"val = qdict_get_qdict(ret, \"return\");",
"pid = qdict_get_int(val, \"pid\");",
"g_assert_cmpint(pid, >, 0);",
"QDECREF(ret);",
"now = g_get_monotonic_time();",
"do {",
"ret = qmp_fd(VAR_1->fd, \"{'execute': 'guest-exec-status',\"",
"\" 'arguments': { 'pid': %\" PRId64 \" } }\", pid);",
"g_assert_nonnull(ret);",
"val = qdict_get_qdict(ret, \"return\");",
"exited = qdict_get_bool(val, \"exited\");",
"if (!exited) {",
"QDECREF(ret);",
"}",
"} while (!exited &&",
"g_get_monotonic_time() < now + 5 * G_TIME_SPAN_SECOND);",
"g_assert(exited);",
"exitcode = qdict_get_int(val, \"exitcode\");",
"g_assert_cmpint(exitcode, ==, 0);",
"VAR_2 = qdict_get_str(val, \"VAR_2-data\");",
"decoded = g_base64_decode(VAR_2, &len);",
"g_assert_cmpint(len, ==, 12);",
"g_assert_cmpstr((char *)decoded, ==, \"\\\" test_str \\\"\");",
"g_free(decoded);",
"QDECREF(ret);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
]
]
|
14,432 | static void vtd_do_iommu_translate(VTDAddressSpace *vtd_as, uint8_t bus_num,
uint8_t devfn, hwaddr addr, bool is_write,
IOMMUTLBEntry *entry)
{
IntelIOMMUState *s = vtd_as->iommu_state;
VTDContextEntry ce;
VTDContextCacheEntry *cc_entry = &vtd_as->context_cache_entry;
uint64_t slpte;
uint32_t level;
uint16_t source_id = vtd_make_source_id(bus_num, devfn);
int ret_fr;
bool is_fpd_set = false;
bool reads = true;
bool writes = true;
VTDIOTLBEntry *iotlb_entry;
/* Check if the request is in interrupt address range */
if (vtd_is_interrupt_addr(addr)) {
if (is_write) {
/* FIXME: since we don't know the length of the access here, we
* treat Non-DWORD length write requests without PASID as
* interrupt requests, too. Withoud interrupt remapping support,
* we just use 1:1 mapping.
*/
VTD_DPRINTF(MMU, "write request to interrupt address "
"gpa 0x%"PRIx64, addr);
entry->iova = addr & VTD_PAGE_MASK_4K;
entry->translated_addr = addr & VTD_PAGE_MASK_4K;
entry->addr_mask = ~VTD_PAGE_MASK_4K;
entry->perm = IOMMU_WO;
return;
} else {
VTD_DPRINTF(GENERAL, "error: read request from interrupt address "
"gpa 0x%"PRIx64, addr);
vtd_report_dmar_fault(s, source_id, addr, VTD_FR_READ, is_write);
return;
}
}
/* Try to fetch slpte form IOTLB */
iotlb_entry = vtd_lookup_iotlb(s, source_id, addr);
if (iotlb_entry) {
VTD_DPRINTF(CACHE, "hit iotlb sid 0x%"PRIx16 " gpa 0x%"PRIx64
" slpte 0x%"PRIx64 " did 0x%"PRIx16, source_id, addr,
iotlb_entry->slpte, iotlb_entry->domain_id);
slpte = iotlb_entry->slpte;
reads = iotlb_entry->read_flags;
writes = iotlb_entry->write_flags;
goto out;
}
/* Try to fetch context-entry from cache first */
if (cc_entry->context_cache_gen == s->context_cache_gen) {
VTD_DPRINTF(CACHE, "hit context-cache bus %d devfn %d "
"(hi %"PRIx64 " lo %"PRIx64 " gen %"PRIu32 ")",
bus_num, devfn, cc_entry->context_entry.hi,
cc_entry->context_entry.lo, cc_entry->context_cache_gen);
ce = cc_entry->context_entry;
is_fpd_set = ce.lo & VTD_CONTEXT_ENTRY_FPD;
} else {
ret_fr = vtd_dev_to_context_entry(s, bus_num, devfn, &ce);
is_fpd_set = ce.lo & VTD_CONTEXT_ENTRY_FPD;
if (ret_fr) {
ret_fr = -ret_fr;
if (is_fpd_set && vtd_is_qualified_fault(ret_fr)) {
VTD_DPRINTF(FLOG, "fault processing is disabled for DMA "
"requests through this context-entry "
"(with FPD Set)");
} else {
vtd_report_dmar_fault(s, source_id, addr, ret_fr, is_write);
}
return;
}
/* Update context-cache */
VTD_DPRINTF(CACHE, "update context-cache bus %d devfn %d "
"(hi %"PRIx64 " lo %"PRIx64 " gen %"PRIu32 "->%"PRIu32 ")",
bus_num, devfn, ce.hi, ce.lo,
cc_entry->context_cache_gen, s->context_cache_gen);
cc_entry->context_entry = ce;
cc_entry->context_cache_gen = s->context_cache_gen;
}
ret_fr = vtd_gpa_to_slpte(&ce, addr, is_write, &slpte, &level,
&reads, &writes);
if (ret_fr) {
ret_fr = -ret_fr;
if (is_fpd_set && vtd_is_qualified_fault(ret_fr)) {
VTD_DPRINTF(FLOG, "fault processing is disabled for DMA requests "
"through this context-entry (with FPD Set)");
} else {
vtd_report_dmar_fault(s, source_id, addr, ret_fr, is_write);
}
return;
}
vtd_update_iotlb(s, source_id, VTD_CONTEXT_ENTRY_DID(ce.hi), addr, slpte,
reads, writes);
out:
entry->iova = addr & VTD_PAGE_MASK_4K;
entry->translated_addr = vtd_get_slpte_addr(slpte) & VTD_PAGE_MASK_4K;
entry->addr_mask = ~VTD_PAGE_MASK_4K;
entry->perm = (writes ? 2 : 0) + (reads ? 1 : 0);
}
| false | qemu | 7df953bd456da45f761064974820ab5c3fd7b2aa | static void vtd_do_iommu_translate(VTDAddressSpace *vtd_as, uint8_t bus_num,
uint8_t devfn, hwaddr addr, bool is_write,
IOMMUTLBEntry *entry)
{
IntelIOMMUState *s = vtd_as->iommu_state;
VTDContextEntry ce;
VTDContextCacheEntry *cc_entry = &vtd_as->context_cache_entry;
uint64_t slpte;
uint32_t level;
uint16_t source_id = vtd_make_source_id(bus_num, devfn);
int ret_fr;
bool is_fpd_set = false;
bool reads = true;
bool writes = true;
VTDIOTLBEntry *iotlb_entry;
if (vtd_is_interrupt_addr(addr)) {
if (is_write) {
VTD_DPRINTF(MMU, "write request to interrupt address "
"gpa 0x%"PRIx64, addr);
entry->iova = addr & VTD_PAGE_MASK_4K;
entry->translated_addr = addr & VTD_PAGE_MASK_4K;
entry->addr_mask = ~VTD_PAGE_MASK_4K;
entry->perm = IOMMU_WO;
return;
} else {
VTD_DPRINTF(GENERAL, "error: read request from interrupt address "
"gpa 0x%"PRIx64, addr);
vtd_report_dmar_fault(s, source_id, addr, VTD_FR_READ, is_write);
return;
}
}
iotlb_entry = vtd_lookup_iotlb(s, source_id, addr);
if (iotlb_entry) {
VTD_DPRINTF(CACHE, "hit iotlb sid 0x%"PRIx16 " gpa 0x%"PRIx64
" slpte 0x%"PRIx64 " did 0x%"PRIx16, source_id, addr,
iotlb_entry->slpte, iotlb_entry->domain_id);
slpte = iotlb_entry->slpte;
reads = iotlb_entry->read_flags;
writes = iotlb_entry->write_flags;
goto out;
}
if (cc_entry->context_cache_gen == s->context_cache_gen) {
VTD_DPRINTF(CACHE, "hit context-cache bus %d devfn %d "
"(hi %"PRIx64 " lo %"PRIx64 " gen %"PRIu32 ")",
bus_num, devfn, cc_entry->context_entry.hi,
cc_entry->context_entry.lo, cc_entry->context_cache_gen);
ce = cc_entry->context_entry;
is_fpd_set = ce.lo & VTD_CONTEXT_ENTRY_FPD;
} else {
ret_fr = vtd_dev_to_context_entry(s, bus_num, devfn, &ce);
is_fpd_set = ce.lo & VTD_CONTEXT_ENTRY_FPD;
if (ret_fr) {
ret_fr = -ret_fr;
if (is_fpd_set && vtd_is_qualified_fault(ret_fr)) {
VTD_DPRINTF(FLOG, "fault processing is disabled for DMA "
"requests through this context-entry "
"(with FPD Set)");
} else {
vtd_report_dmar_fault(s, source_id, addr, ret_fr, is_write);
}
return;
}
VTD_DPRINTF(CACHE, "update context-cache bus %d devfn %d "
"(hi %"PRIx64 " lo %"PRIx64 " gen %"PRIu32 "->%"PRIu32 ")",
bus_num, devfn, ce.hi, ce.lo,
cc_entry->context_cache_gen, s->context_cache_gen);
cc_entry->context_entry = ce;
cc_entry->context_cache_gen = s->context_cache_gen;
}
ret_fr = vtd_gpa_to_slpte(&ce, addr, is_write, &slpte, &level,
&reads, &writes);
if (ret_fr) {
ret_fr = -ret_fr;
if (is_fpd_set && vtd_is_qualified_fault(ret_fr)) {
VTD_DPRINTF(FLOG, "fault processing is disabled for DMA requests "
"through this context-entry (with FPD Set)");
} else {
vtd_report_dmar_fault(s, source_id, addr, ret_fr, is_write);
}
return;
}
vtd_update_iotlb(s, source_id, VTD_CONTEXT_ENTRY_DID(ce.hi), addr, slpte,
reads, writes);
out:
entry->iova = addr & VTD_PAGE_MASK_4K;
entry->translated_addr = vtd_get_slpte_addr(slpte) & VTD_PAGE_MASK_4K;
entry->addr_mask = ~VTD_PAGE_MASK_4K;
entry->perm = (writes ? 2 : 0) + (reads ? 1 : 0);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(VTDAddressSpace *VAR_0, uint8_t VAR_1,
uint8_t VAR_2, hwaddr VAR_3, bool VAR_4,
IOMMUTLBEntry *VAR_5)
{
IntelIOMMUState *s = VAR_0->iommu_state;
VTDContextEntry ce;
VTDContextCacheEntry *cc_entry = &VAR_0->context_cache_entry;
uint64_t slpte;
uint32_t level;
uint16_t source_id = vtd_make_source_id(VAR_1, VAR_2);
int VAR_6;
bool is_fpd_set = false;
bool reads = true;
bool writes = true;
VTDIOTLBEntry *iotlb_entry;
if (vtd_is_interrupt_addr(VAR_3)) {
if (VAR_4) {
VTD_DPRINTF(MMU, "write request to interrupt address "
"gpa 0x%"PRIx64, VAR_3);
VAR_5->iova = VAR_3 & VTD_PAGE_MASK_4K;
VAR_5->translated_addr = VAR_3 & VTD_PAGE_MASK_4K;
VAR_5->addr_mask = ~VTD_PAGE_MASK_4K;
VAR_5->perm = IOMMU_WO;
return;
} else {
VTD_DPRINTF(GENERAL, "error: read request from interrupt address "
"gpa 0x%"PRIx64, VAR_3);
vtd_report_dmar_fault(s, source_id, VAR_3, VTD_FR_READ, VAR_4);
return;
}
}
iotlb_entry = vtd_lookup_iotlb(s, source_id, VAR_3);
if (iotlb_entry) {
VTD_DPRINTF(CACHE, "hit iotlb sid 0x%"PRIx16 " gpa 0x%"PRIx64
" slpte 0x%"PRIx64 " did 0x%"PRIx16, source_id, VAR_3,
iotlb_entry->slpte, iotlb_entry->domain_id);
slpte = iotlb_entry->slpte;
reads = iotlb_entry->read_flags;
writes = iotlb_entry->write_flags;
goto out;
}
if (cc_entry->context_cache_gen == s->context_cache_gen) {
VTD_DPRINTF(CACHE, "hit context-cache bus %d VAR_2 %d "
"(hi %"PRIx64 " lo %"PRIx64 " gen %"PRIu32 ")",
VAR_1, VAR_2, cc_entry->context_entry.hi,
cc_entry->context_entry.lo, cc_entry->context_cache_gen);
ce = cc_entry->context_entry;
is_fpd_set = ce.lo & VTD_CONTEXT_ENTRY_FPD;
} else {
VAR_6 = vtd_dev_to_context_entry(s, VAR_1, VAR_2, &ce);
is_fpd_set = ce.lo & VTD_CONTEXT_ENTRY_FPD;
if (VAR_6) {
VAR_6 = -VAR_6;
if (is_fpd_set && vtd_is_qualified_fault(VAR_6)) {
VTD_DPRINTF(FLOG, "fault processing is disabled for DMA "
"requests through this context-VAR_5 "
"(with FPD Set)");
} else {
vtd_report_dmar_fault(s, source_id, VAR_3, VAR_6, VAR_4);
}
return;
}
VTD_DPRINTF(CACHE, "update context-cache bus %d VAR_2 %d "
"(hi %"PRIx64 " lo %"PRIx64 " gen %"PRIu32 "->%"PRIu32 ")",
VAR_1, VAR_2, ce.hi, ce.lo,
cc_entry->context_cache_gen, s->context_cache_gen);
cc_entry->context_entry = ce;
cc_entry->context_cache_gen = s->context_cache_gen;
}
VAR_6 = vtd_gpa_to_slpte(&ce, VAR_3, VAR_4, &slpte, &level,
&reads, &writes);
if (VAR_6) {
VAR_6 = -VAR_6;
if (is_fpd_set && vtd_is_qualified_fault(VAR_6)) {
VTD_DPRINTF(FLOG, "fault processing is disabled for DMA requests "
"through this context-VAR_5 (with FPD Set)");
} else {
vtd_report_dmar_fault(s, source_id, VAR_3, VAR_6, VAR_4);
}
return;
}
vtd_update_iotlb(s, source_id, VTD_CONTEXT_ENTRY_DID(ce.hi), VAR_3, slpte,
reads, writes);
out:
VAR_5->iova = VAR_3 & VTD_PAGE_MASK_4K;
VAR_5->translated_addr = vtd_get_slpte_addr(slpte) & VTD_PAGE_MASK_4K;
VAR_5->addr_mask = ~VTD_PAGE_MASK_4K;
VAR_5->perm = (writes ? 2 : 0) + (reads ? 1 : 0);
}
| [
"static void FUNC_0(VTDAddressSpace *VAR_0, uint8_t VAR_1,\nuint8_t VAR_2, hwaddr VAR_3, bool VAR_4,\nIOMMUTLBEntry *VAR_5)\n{",
"IntelIOMMUState *s = VAR_0->iommu_state;",
"VTDContextEntry ce;",
"VTDContextCacheEntry *cc_entry = &VAR_0->context_cache_entry;",
"uint64_t slpte;",
"uint32_t level;",
"uint16_t source_id = vtd_make_source_id(VAR_1, VAR_2);",
"int VAR_6;",
"bool is_fpd_set = false;",
"bool reads = true;",
"bool writes = true;",
"VTDIOTLBEntry *iotlb_entry;",
"if (vtd_is_interrupt_addr(VAR_3)) {",
"if (VAR_4) {",
"VTD_DPRINTF(MMU, \"write request to interrupt address \"\n\"gpa 0x%\"PRIx64, VAR_3);",
"VAR_5->iova = VAR_3 & VTD_PAGE_MASK_4K;",
"VAR_5->translated_addr = VAR_3 & VTD_PAGE_MASK_4K;",
"VAR_5->addr_mask = ~VTD_PAGE_MASK_4K;",
"VAR_5->perm = IOMMU_WO;",
"return;",
"} else {",
"VTD_DPRINTF(GENERAL, \"error: read request from interrupt address \"\n\"gpa 0x%\"PRIx64, VAR_3);",
"vtd_report_dmar_fault(s, source_id, VAR_3, VTD_FR_READ, VAR_4);",
"return;",
"}",
"}",
"iotlb_entry = vtd_lookup_iotlb(s, source_id, VAR_3);",
"if (iotlb_entry) {",
"VTD_DPRINTF(CACHE, \"hit iotlb sid 0x%\"PRIx16 \" gpa 0x%\"PRIx64\n\" slpte 0x%\"PRIx64 \" did 0x%\"PRIx16, source_id, VAR_3,\niotlb_entry->slpte, iotlb_entry->domain_id);",
"slpte = iotlb_entry->slpte;",
"reads = iotlb_entry->read_flags;",
"writes = iotlb_entry->write_flags;",
"goto out;",
"}",
"if (cc_entry->context_cache_gen == s->context_cache_gen) {",
"VTD_DPRINTF(CACHE, \"hit context-cache bus %d VAR_2 %d \"\n\"(hi %\"PRIx64 \" lo %\"PRIx64 \" gen %\"PRIu32 \")\",\nVAR_1, VAR_2, cc_entry->context_entry.hi,\ncc_entry->context_entry.lo, cc_entry->context_cache_gen);",
"ce = cc_entry->context_entry;",
"is_fpd_set = ce.lo & VTD_CONTEXT_ENTRY_FPD;",
"} else {",
"VAR_6 = vtd_dev_to_context_entry(s, VAR_1, VAR_2, &ce);",
"is_fpd_set = ce.lo & VTD_CONTEXT_ENTRY_FPD;",
"if (VAR_6) {",
"VAR_6 = -VAR_6;",
"if (is_fpd_set && vtd_is_qualified_fault(VAR_6)) {",
"VTD_DPRINTF(FLOG, \"fault processing is disabled for DMA \"\n\"requests through this context-VAR_5 \"\n\"(with FPD Set)\");",
"} else {",
"vtd_report_dmar_fault(s, source_id, VAR_3, VAR_6, VAR_4);",
"}",
"return;",
"}",
"VTD_DPRINTF(CACHE, \"update context-cache bus %d VAR_2 %d \"\n\"(hi %\"PRIx64 \" lo %\"PRIx64 \" gen %\"PRIu32 \"->%\"PRIu32 \")\",\nVAR_1, VAR_2, ce.hi, ce.lo,\ncc_entry->context_cache_gen, s->context_cache_gen);",
"cc_entry->context_entry = ce;",
"cc_entry->context_cache_gen = s->context_cache_gen;",
"}",
"VAR_6 = vtd_gpa_to_slpte(&ce, VAR_3, VAR_4, &slpte, &level,\n&reads, &writes);",
"if (VAR_6) {",
"VAR_6 = -VAR_6;",
"if (is_fpd_set && vtd_is_qualified_fault(VAR_6)) {",
"VTD_DPRINTF(FLOG, \"fault processing is disabled for DMA requests \"\n\"through this context-VAR_5 (with FPD Set)\");",
"} else {",
"vtd_report_dmar_fault(s, source_id, VAR_3, VAR_6, VAR_4);",
"}",
"return;",
"}",
"vtd_update_iotlb(s, source_id, VTD_CONTEXT_ENTRY_DID(ce.hi), VAR_3, slpte,\nreads, writes);",
"out:\nVAR_5->iova = VAR_3 & VTD_PAGE_MASK_4K;",
"VAR_5->translated_addr = vtd_get_slpte_addr(slpte) & VTD_PAGE_MASK_4K;",
"VAR_5->addr_mask = ~VTD_PAGE_MASK_4K;",
"VAR_5->perm = (writes ? 2 : 0) + (reads ? 1 : 0);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
35
],
[
37
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83,
85,
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103,
105,
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127,
129,
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145,
147,
149,
151
],
[
153
],
[
155
],
[
157
],
[
161,
163
],
[
165
],
[
167
],
[
169
],
[
171,
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
187,
189
],
[
191,
193
],
[
195
],
[
197
],
[
199
],
[
201
]
]
|
14,433 | static void single_quote_string(void)
{
int i;
struct {
const char *encoded;
const char *decoded;
} test_cases[] = {
{ "'hello world'", "hello world" },
{ "'the quick brown fox \\' jumped over the fence'",
"the quick brown fox ' jumped over the fence" },
{}
};
for (i = 0; test_cases[i].encoded; i++) {
QObject *obj;
QString *str;
obj = qobject_from_json(test_cases[i].encoded);
g_assert(obj != NULL);
g_assert(qobject_type(obj) == QTYPE_QSTRING);
str = qobject_to_qstring(obj);
g_assert(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0);
QDECREF(str);
}
}
| false | qemu | 363e13f86eb60bce1e112a35a4c107505a69c9fe | static void single_quote_string(void)
{
int i;
struct {
const char *encoded;
const char *decoded;
} test_cases[] = {
{ "'hello world'", "hello world" },
{ "'the quick brown fox \\' jumped over the fence'",
"the quick brown fox ' jumped over the fence" },
{}
};
for (i = 0; test_cases[i].encoded; i++) {
QObject *obj;
QString *str;
obj = qobject_from_json(test_cases[i].encoded);
g_assert(obj != NULL);
g_assert(qobject_type(obj) == QTYPE_QSTRING);
str = qobject_to_qstring(obj);
g_assert(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0);
QDECREF(str);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
int VAR_0;
struct {
const char *encoded;
const char *decoded;
} VAR_1[] = {
{ "'hello world'", "hello world" },
{ "'the quick brown fox \\' jumped over the fence'",
"the quick brown fox ' jumped over the fence" },
{}
};
for (VAR_0 = 0; VAR_1[VAR_0].encoded; VAR_0++) {
QObject *obj;
QString *str;
obj = qobject_from_json(VAR_1[VAR_0].encoded);
g_assert(obj != NULL);
g_assert(qobject_type(obj) == QTYPE_QSTRING);
str = qobject_to_qstring(obj);
g_assert(strcmp(qstring_get_str(str), VAR_1[VAR_0].decoded) == 0);
QDECREF(str);
}
}
| [
"static void FUNC_0(void)\n{",
"int VAR_0;",
"struct {",
"const char *encoded;",
"const char *decoded;",
"} VAR_1[] = {",
"{ \"'hello world'\", \"hello world\" },",
"{ \"'the quick brown fox \\\\' jumped over the fence'\",",
"\"the quick brown fox ' jumped over the fence\" },",
"{}",
"};",
"for (VAR_0 = 0; VAR_1[VAR_0].encoded; VAR_0++) {",
"QObject *obj;",
"QString *str;",
"obj = qobject_from_json(VAR_1[VAR_0].encoded);",
"g_assert(obj != NULL);",
"g_assert(qobject_type(obj) == QTYPE_QSTRING);",
"str = qobject_to_qstring(obj);",
"g_assert(strcmp(qstring_get_str(str), VAR_1[VAR_0].decoded) == 0);",
"QDECREF(str);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
]
]
|
14,434 | static int alloc_refcount_block(BlockDriverState *bs,
int64_t cluster_index, uint16_t **refcount_block)
{
BDRVQcowState *s = bs->opaque;
unsigned int refcount_table_index;
int ret;
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC);
/* Find the refcount block for the given cluster */
refcount_table_index = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT);
if (refcount_table_index < s->refcount_table_size) {
uint64_t refcount_block_offset =
s->refcount_table[refcount_table_index];
/* If it's already there, we're done */
if (refcount_block_offset) {
return load_refcount_block(bs, refcount_block_offset,
(void**) refcount_block);
}
}
/*
* If we came here, we need to allocate something. Something is at least
* a cluster for the new refcount block. It may also include a new refcount
* table if the old refcount table is too small.
*
* Note that allocating clusters here needs some special care:
*
* - We can't use the normal qcow2_alloc_clusters(), it would try to
* increase the refcount and very likely we would end up with an endless
* recursion. Instead we must place the refcount blocks in a way that
* they can describe them themselves.
*
* - We need to consider that at this point we are inside update_refcounts
* and doing the initial refcount increase. This means that some clusters
* have already been allocated by the caller, but their refcount isn't
* accurate yet. free_cluster_index tells us where this allocation ends
* as long as we don't overwrite it by freeing clusters.
*
* - alloc_clusters_noref and qcow2_free_clusters may load a different
* refcount block into the cache
*/
*refcount_block = NULL;
/* We write to the refcount table, so we might depend on L2 tables */
qcow2_cache_flush(bs, s->l2_table_cache);
/* Allocate the refcount block itself and mark it as used */
int64_t new_block = alloc_clusters_noref(bs, s->cluster_size);
if (new_block < 0) {
return new_block;
}
#ifdef DEBUG_ALLOC2
fprintf(stderr, "qcow2: Allocate refcount block %d for %" PRIx64
" at %" PRIx64 "\n",
refcount_table_index, cluster_index << s->cluster_bits, new_block);
#endif
if (in_same_refcount_block(s, new_block, cluster_index << s->cluster_bits)) {
/* Zero the new refcount block before updating it */
ret = qcow2_cache_get_empty(bs, s->refcount_block_cache, new_block,
(void**) refcount_block);
if (ret < 0) {
goto fail_block;
}
memset(*refcount_block, 0, s->cluster_size);
/* The block describes itself, need to update the cache */
int block_index = (new_block >> s->cluster_bits) &
((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1);
(*refcount_block)[block_index] = cpu_to_be16(1);
} else {
/* Described somewhere else. This can recurse at most twice before we
* arrive at a block that describes itself. */
ret = update_refcount(bs, new_block, s->cluster_size, 1);
if (ret < 0) {
goto fail_block;
}
bdrv_flush(bs->file);
/* Initialize the new refcount block only after updating its refcount,
* update_refcount uses the refcount cache itself */
ret = qcow2_cache_get_empty(bs, s->refcount_block_cache, new_block,
(void**) refcount_block);
if (ret < 0) {
goto fail_block;
}
memset(*refcount_block, 0, s->cluster_size);
}
/* Now the new refcount block needs to be written to disk */
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE);
qcow2_cache_entry_mark_dirty(s->refcount_block_cache, *refcount_block);
ret = qcow2_cache_flush(bs, s->refcount_block_cache);
if (ret < 0) {
goto fail_block;
}
/* If the refcount table is big enough, just hook the block up there */
if (refcount_table_index < s->refcount_table_size) {
uint64_t data64 = cpu_to_be64(new_block);
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_HOOKUP);
ret = bdrv_pwrite_sync(bs->file,
s->refcount_table_offset + refcount_table_index * sizeof(uint64_t),
&data64, sizeof(data64));
if (ret < 0) {
goto fail_block;
}
s->refcount_table[refcount_table_index] = new_block;
return 0;
}
ret = qcow2_cache_put(bs, s->refcount_block_cache, (void**) refcount_block);
if (ret < 0) {
goto fail_block;
}
/*
* If we come here, we need to grow the refcount table. Again, a new
* refcount table needs some space and we can't simply allocate to avoid
* endless recursion.
*
* Therefore let's grab new refcount blocks at the end of the image, which
* will describe themselves and the new refcount table. This way we can
* reference them only in the new table and do the switch to the new
* refcount table at once without producing an inconsistent state in
* between.
*/
BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_GROW);
/* Calculate the number of refcount blocks needed so far */
uint64_t refcount_block_clusters = 1 << (s->cluster_bits - REFCOUNT_SHIFT);
uint64_t blocks_used = (s->free_cluster_index +
refcount_block_clusters - 1) / refcount_block_clusters;
/* And now we need at least one block more for the new metadata */
uint64_t table_size = next_refcount_table_size(s, blocks_used + 1);
uint64_t last_table_size;
uint64_t blocks_clusters;
do {
uint64_t table_clusters = size_to_clusters(s, table_size);
blocks_clusters = 1 +
((table_clusters + refcount_block_clusters - 1)
/ refcount_block_clusters);
uint64_t meta_clusters = table_clusters + blocks_clusters;
last_table_size = table_size;
table_size = next_refcount_table_size(s, blocks_used +
((meta_clusters + refcount_block_clusters - 1)
/ refcount_block_clusters));
} while (last_table_size != table_size);
#ifdef DEBUG_ALLOC2
fprintf(stderr, "qcow2: Grow refcount table %" PRId32 " => %" PRId64 "\n",
s->refcount_table_size, table_size);
#endif
/* Create the new refcount table and blocks */
uint64_t meta_offset = (blocks_used * refcount_block_clusters) *
s->cluster_size;
uint64_t table_offset = meta_offset + blocks_clusters * s->cluster_size;
uint16_t *new_blocks = g_malloc0(blocks_clusters * s->cluster_size);
uint64_t *new_table = g_malloc0(table_size * sizeof(uint64_t));
assert(meta_offset >= (s->free_cluster_index * s->cluster_size));
/* Fill the new refcount table */
memcpy(new_table, s->refcount_table,
s->refcount_table_size * sizeof(uint64_t));
new_table[refcount_table_index] = new_block;
int i;
for (i = 0; i < blocks_clusters; i++) {
new_table[blocks_used + i] = meta_offset + (i * s->cluster_size);
}
/* Fill the refcount blocks */
uint64_t table_clusters = size_to_clusters(s, table_size * sizeof(uint64_t));
int block = 0;
for (i = 0; i < table_clusters + blocks_clusters; i++) {
new_blocks[block++] = cpu_to_be16(1);
}
/* Write refcount blocks to disk */
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS);
ret = bdrv_pwrite_sync(bs->file, meta_offset, new_blocks,
blocks_clusters * s->cluster_size);
g_free(new_blocks);
if (ret < 0) {
goto fail_table;
}
/* Write refcount table to disk */
for(i = 0; i < table_size; i++) {
cpu_to_be64s(&new_table[i]);
}
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE);
ret = bdrv_pwrite_sync(bs->file, table_offset, new_table,
table_size * sizeof(uint64_t));
if (ret < 0) {
goto fail_table;
}
for(i = 0; i < table_size; i++) {
cpu_to_be64s(&new_table[i]);
}
/* Hook up the new refcount table in the qcow2 header */
uint8_t data[12];
cpu_to_be64w((uint64_t*)data, table_offset);
cpu_to_be32w((uint32_t*)(data + 8), table_clusters);
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE);
ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, refcount_table_offset),
data, sizeof(data));
if (ret < 0) {
goto fail_table;
}
/* And switch it in memory */
uint64_t old_table_offset = s->refcount_table_offset;
uint64_t old_table_size = s->refcount_table_size;
g_free(s->refcount_table);
s->refcount_table = new_table;
s->refcount_table_size = table_size;
s->refcount_table_offset = table_offset;
/* Free old table. Remember, we must not change free_cluster_index */
uint64_t old_free_cluster_index = s->free_cluster_index;
qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t));
s->free_cluster_index = old_free_cluster_index;
ret = load_refcount_block(bs, new_block, (void**) refcount_block);
if (ret < 0) {
return ret;
}
return new_block;
fail_table:
g_free(new_table);
fail_block:
if (*refcount_block != NULL) {
qcow2_cache_put(bs, s->refcount_block_cache, (void**) refcount_block);
}
return ret;
}
| false | qemu | 2795ecf681107d55e4113592b3045ece5f6e7b3b | static int alloc_refcount_block(BlockDriverState *bs,
int64_t cluster_index, uint16_t **refcount_block)
{
BDRVQcowState *s = bs->opaque;
unsigned int refcount_table_index;
int ret;
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC);
refcount_table_index = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT);
if (refcount_table_index < s->refcount_table_size) {
uint64_t refcount_block_offset =
s->refcount_table[refcount_table_index];
if (refcount_block_offset) {
return load_refcount_block(bs, refcount_block_offset,
(void**) refcount_block);
}
}
*refcount_block = NULL;
qcow2_cache_flush(bs, s->l2_table_cache);
int64_t new_block = alloc_clusters_noref(bs, s->cluster_size);
if (new_block < 0) {
return new_block;
}
#ifdef DEBUG_ALLOC2
fprintf(stderr, "qcow2: Allocate refcount block %d for %" PRIx64
" at %" PRIx64 "\n",
refcount_table_index, cluster_index << s->cluster_bits, new_block);
#endif
if (in_same_refcount_block(s, new_block, cluster_index << s->cluster_bits)) {
ret = qcow2_cache_get_empty(bs, s->refcount_block_cache, new_block,
(void**) refcount_block);
if (ret < 0) {
goto fail_block;
}
memset(*refcount_block, 0, s->cluster_size);
int block_index = (new_block >> s->cluster_bits) &
((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1);
(*refcount_block)[block_index] = cpu_to_be16(1);
} else {
ret = update_refcount(bs, new_block, s->cluster_size, 1);
if (ret < 0) {
goto fail_block;
}
bdrv_flush(bs->file);
ret = qcow2_cache_get_empty(bs, s->refcount_block_cache, new_block,
(void**) refcount_block);
if (ret < 0) {
goto fail_block;
}
memset(*refcount_block, 0, s->cluster_size);
}
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE);
qcow2_cache_entry_mark_dirty(s->refcount_block_cache, *refcount_block);
ret = qcow2_cache_flush(bs, s->refcount_block_cache);
if (ret < 0) {
goto fail_block;
}
if (refcount_table_index < s->refcount_table_size) {
uint64_t data64 = cpu_to_be64(new_block);
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_HOOKUP);
ret = bdrv_pwrite_sync(bs->file,
s->refcount_table_offset + refcount_table_index * sizeof(uint64_t),
&data64, sizeof(data64));
if (ret < 0) {
goto fail_block;
}
s->refcount_table[refcount_table_index] = new_block;
return 0;
}
ret = qcow2_cache_put(bs, s->refcount_block_cache, (void**) refcount_block);
if (ret < 0) {
goto fail_block;
}
BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_GROW);
uint64_t refcount_block_clusters = 1 << (s->cluster_bits - REFCOUNT_SHIFT);
uint64_t blocks_used = (s->free_cluster_index +
refcount_block_clusters - 1) / refcount_block_clusters;
uint64_t table_size = next_refcount_table_size(s, blocks_used + 1);
uint64_t last_table_size;
uint64_t blocks_clusters;
do {
uint64_t table_clusters = size_to_clusters(s, table_size);
blocks_clusters = 1 +
((table_clusters + refcount_block_clusters - 1)
/ refcount_block_clusters);
uint64_t meta_clusters = table_clusters + blocks_clusters;
last_table_size = table_size;
table_size = next_refcount_table_size(s, blocks_used +
((meta_clusters + refcount_block_clusters - 1)
/ refcount_block_clusters));
} while (last_table_size != table_size);
#ifdef DEBUG_ALLOC2
fprintf(stderr, "qcow2: Grow refcount table %" PRId32 " => %" PRId64 "\n",
s->refcount_table_size, table_size);
#endif
uint64_t meta_offset = (blocks_used * refcount_block_clusters) *
s->cluster_size;
uint64_t table_offset = meta_offset + blocks_clusters * s->cluster_size;
uint16_t *new_blocks = g_malloc0(blocks_clusters * s->cluster_size);
uint64_t *new_table = g_malloc0(table_size * sizeof(uint64_t));
assert(meta_offset >= (s->free_cluster_index * s->cluster_size));
memcpy(new_table, s->refcount_table,
s->refcount_table_size * sizeof(uint64_t));
new_table[refcount_table_index] = new_block;
int i;
for (i = 0; i < blocks_clusters; i++) {
new_table[blocks_used + i] = meta_offset + (i * s->cluster_size);
}
uint64_t table_clusters = size_to_clusters(s, table_size * sizeof(uint64_t));
int block = 0;
for (i = 0; i < table_clusters + blocks_clusters; i++) {
new_blocks[block++] = cpu_to_be16(1);
}
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS);
ret = bdrv_pwrite_sync(bs->file, meta_offset, new_blocks,
blocks_clusters * s->cluster_size);
g_free(new_blocks);
if (ret < 0) {
goto fail_table;
}
for(i = 0; i < table_size; i++) {
cpu_to_be64s(&new_table[i]);
}
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE);
ret = bdrv_pwrite_sync(bs->file, table_offset, new_table,
table_size * sizeof(uint64_t));
if (ret < 0) {
goto fail_table;
}
for(i = 0; i < table_size; i++) {
cpu_to_be64s(&new_table[i]);
}
uint8_t data[12];
cpu_to_be64w((uint64_t*)data, table_offset);
cpu_to_be32w((uint32_t*)(data + 8), table_clusters);
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE);
ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, refcount_table_offset),
data, sizeof(data));
if (ret < 0) {
goto fail_table;
}
uint64_t old_table_offset = s->refcount_table_offset;
uint64_t old_table_size = s->refcount_table_size;
g_free(s->refcount_table);
s->refcount_table = new_table;
s->refcount_table_size = table_size;
s->refcount_table_offset = table_offset;
uint64_t old_free_cluster_index = s->free_cluster_index;
qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t));
s->free_cluster_index = old_free_cluster_index;
ret = load_refcount_block(bs, new_block, (void**) refcount_block);
if (ret < 0) {
return ret;
}
return new_block;
fail_table:
g_free(new_table);
fail_block:
if (*refcount_block != NULL) {
qcow2_cache_put(bs, s->refcount_block_cache, (void**) refcount_block);
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0,
int64_t VAR_1, uint16_t **VAR_2)
{
BDRVQcowState *s = VAR_0->opaque;
unsigned int VAR_3;
int VAR_4;
BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC);
VAR_3 = VAR_1 >> (s->cluster_bits - REFCOUNT_SHIFT);
if (VAR_3 < s->refcount_table_size) {
uint64_t refcount_block_offset =
s->refcount_table[VAR_3];
if (refcount_block_offset) {
return load_refcount_block(VAR_0, refcount_block_offset,
(void**) VAR_2);
}
}
*VAR_2 = NULL;
qcow2_cache_flush(VAR_0, s->l2_table_cache);
int64_t new_block = alloc_clusters_noref(VAR_0, s->cluster_size);
if (new_block < 0) {
return new_block;
}
#ifdef DEBUG_ALLOC2
fprintf(stderr, "qcow2: Allocate refcount VAR_7 %d for %" PRIx64
" at %" PRIx64 "\n",
VAR_3, VAR_1 << s->cluster_bits, new_block);
#endif
if (in_same_refcount_block(s, new_block, VAR_1 << s->cluster_bits)) {
VAR_4 = qcow2_cache_get_empty(VAR_0, s->refcount_block_cache, new_block,
(void**) VAR_2);
if (VAR_4 < 0) {
goto fail_block;
}
memset(*VAR_2, 0, s->cluster_size);
int VAR_5 = (new_block >> s->cluster_bits) &
((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1);
(*VAR_2)[VAR_5] = cpu_to_be16(1);
} else {
VAR_4 = update_refcount(VAR_0, new_block, s->cluster_size, 1);
if (VAR_4 < 0) {
goto fail_block;
}
bdrv_flush(VAR_0->file);
VAR_4 = qcow2_cache_get_empty(VAR_0, s->refcount_block_cache, new_block,
(void**) VAR_2);
if (VAR_4 < 0) {
goto fail_block;
}
memset(*VAR_2, 0, s->cluster_size);
}
BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC_WRITE);
qcow2_cache_entry_mark_dirty(s->refcount_block_cache, *VAR_2);
VAR_4 = qcow2_cache_flush(VAR_0, s->refcount_block_cache);
if (VAR_4 < 0) {
goto fail_block;
}
if (VAR_3 < s->refcount_table_size) {
uint64_t data64 = cpu_to_be64(new_block);
BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC_HOOKUP);
VAR_4 = bdrv_pwrite_sync(VAR_0->file,
s->refcount_table_offset + VAR_3 * sizeof(uint64_t),
&data64, sizeof(data64));
if (VAR_4 < 0) {
goto fail_block;
}
s->refcount_table[VAR_3] = new_block;
return 0;
}
VAR_4 = qcow2_cache_put(VAR_0, s->refcount_block_cache, (void**) VAR_2);
if (VAR_4 < 0) {
goto fail_block;
}
BLKDBG_EVENT(VAR_0->file, BLKDBG_REFTABLE_GROW);
uint64_t refcount_block_clusters = 1 << (s->cluster_bits - REFCOUNT_SHIFT);
uint64_t blocks_used = (s->free_cluster_index +
refcount_block_clusters - 1) / refcount_block_clusters;
uint64_t table_size = next_refcount_table_size(s, blocks_used + 1);
uint64_t last_table_size;
uint64_t blocks_clusters;
do {
uint64_t table_clusters = size_to_clusters(s, table_size);
blocks_clusters = 1 +
((table_clusters + refcount_block_clusters - 1)
/ refcount_block_clusters);
uint64_t meta_clusters = table_clusters + blocks_clusters;
last_table_size = table_size;
table_size = next_refcount_table_size(s, blocks_used +
((meta_clusters + refcount_block_clusters - 1)
/ refcount_block_clusters));
} while (last_table_size != table_size);
#ifdef DEBUG_ALLOC2
fprintf(stderr, "qcow2: Grow refcount table %" PRId32 " => %" PRId64 "\n",
s->refcount_table_size, table_size);
#endif
uint64_t meta_offset = (blocks_used * refcount_block_clusters) *
s->cluster_size;
uint64_t table_offset = meta_offset + blocks_clusters * s->cluster_size;
uint16_t *new_blocks = g_malloc0(blocks_clusters * s->cluster_size);
uint64_t *new_table = g_malloc0(table_size * sizeof(uint64_t));
assert(meta_offset >= (s->free_cluster_index * s->cluster_size));
memcpy(new_table, s->refcount_table,
s->refcount_table_size * sizeof(uint64_t));
new_table[VAR_3] = new_block;
int VAR_6;
for (VAR_6 = 0; VAR_6 < blocks_clusters; VAR_6++) {
new_table[blocks_used + VAR_6] = meta_offset + (VAR_6 * s->cluster_size);
}
uint64_t table_clusters = size_to_clusters(s, table_size * sizeof(uint64_t));
int VAR_7 = 0;
for (VAR_6 = 0; VAR_6 < table_clusters + blocks_clusters; VAR_6++) {
new_blocks[VAR_7++] = cpu_to_be16(1);
}
BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS);
VAR_4 = bdrv_pwrite_sync(VAR_0->file, meta_offset, new_blocks,
blocks_clusters * s->cluster_size);
g_free(new_blocks);
if (VAR_4 < 0) {
goto fail_table;
}
for(VAR_6 = 0; VAR_6 < table_size; VAR_6++) {
cpu_to_be64s(&new_table[VAR_6]);
}
BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE);
VAR_4 = bdrv_pwrite_sync(VAR_0->file, table_offset, new_table,
table_size * sizeof(uint64_t));
if (VAR_4 < 0) {
goto fail_table;
}
for(VAR_6 = 0; VAR_6 < table_size; VAR_6++) {
cpu_to_be64s(&new_table[VAR_6]);
}
uint8_t data[12];
cpu_to_be64w((uint64_t*)data, table_offset);
cpu_to_be32w((uint32_t*)(data + 8), table_clusters);
BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE);
VAR_4 = bdrv_pwrite_sync(VAR_0->file, offsetof(QCowHeader, refcount_table_offset),
data, sizeof(data));
if (VAR_4 < 0) {
goto fail_table;
}
uint64_t old_table_offset = s->refcount_table_offset;
uint64_t old_table_size = s->refcount_table_size;
g_free(s->refcount_table);
s->refcount_table = new_table;
s->refcount_table_size = table_size;
s->refcount_table_offset = table_offset;
uint64_t old_free_cluster_index = s->free_cluster_index;
qcow2_free_clusters(VAR_0, old_table_offset, old_table_size * sizeof(uint64_t));
s->free_cluster_index = old_free_cluster_index;
VAR_4 = load_refcount_block(VAR_0, new_block, (void**) VAR_2);
if (VAR_4 < 0) {
return VAR_4;
}
return new_block;
fail_table:
g_free(new_table);
fail_block:
if (*VAR_2 != NULL) {
qcow2_cache_put(VAR_0, s->refcount_block_cache, (void**) VAR_2);
}
return VAR_4;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0,\nint64_t VAR_1, uint16_t **VAR_2)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"unsigned int VAR_3;",
"int VAR_4;",
"BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC);",
"VAR_3 = VAR_1 >> (s->cluster_bits - REFCOUNT_SHIFT);",
"if (VAR_3 < s->refcount_table_size) {",
"uint64_t refcount_block_offset =\ns->refcount_table[VAR_3];",
"if (refcount_block_offset) {",
"return load_refcount_block(VAR_0, refcount_block_offset,\n(void**) VAR_2);",
"}",
"}",
"*VAR_2 = NULL;",
"qcow2_cache_flush(VAR_0, s->l2_table_cache);",
"int64_t new_block = alloc_clusters_noref(VAR_0, s->cluster_size);",
"if (new_block < 0) {",
"return new_block;",
"}",
"#ifdef DEBUG_ALLOC2\nfprintf(stderr, \"qcow2: Allocate refcount VAR_7 %d for %\" PRIx64\n\" at %\" PRIx64 \"\\n\",\nVAR_3, VAR_1 << s->cluster_bits, new_block);",
"#endif\nif (in_same_refcount_block(s, new_block, VAR_1 << s->cluster_bits)) {",
"VAR_4 = qcow2_cache_get_empty(VAR_0, s->refcount_block_cache, new_block,\n(void**) VAR_2);",
"if (VAR_4 < 0) {",
"goto fail_block;",
"}",
"memset(*VAR_2, 0, s->cluster_size);",
"int VAR_5 = (new_block >> s->cluster_bits) &\n((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1);",
"(*VAR_2)[VAR_5] = cpu_to_be16(1);",
"} else {",
"VAR_4 = update_refcount(VAR_0, new_block, s->cluster_size, 1);",
"if (VAR_4 < 0) {",
"goto fail_block;",
"}",
"bdrv_flush(VAR_0->file);",
"VAR_4 = qcow2_cache_get_empty(VAR_0, s->refcount_block_cache, new_block,\n(void**) VAR_2);",
"if (VAR_4 < 0) {",
"goto fail_block;",
"}",
"memset(*VAR_2, 0, s->cluster_size);",
"}",
"BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC_WRITE);",
"qcow2_cache_entry_mark_dirty(s->refcount_block_cache, *VAR_2);",
"VAR_4 = qcow2_cache_flush(VAR_0, s->refcount_block_cache);",
"if (VAR_4 < 0) {",
"goto fail_block;",
"}",
"if (VAR_3 < s->refcount_table_size) {",
"uint64_t data64 = cpu_to_be64(new_block);",
"BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC_HOOKUP);",
"VAR_4 = bdrv_pwrite_sync(VAR_0->file,\ns->refcount_table_offset + VAR_3 * sizeof(uint64_t),\n&data64, sizeof(data64));",
"if (VAR_4 < 0) {",
"goto fail_block;",
"}",
"s->refcount_table[VAR_3] = new_block;",
"return 0;",
"}",
"VAR_4 = qcow2_cache_put(VAR_0, s->refcount_block_cache, (void**) VAR_2);",
"if (VAR_4 < 0) {",
"goto fail_block;",
"}",
"BLKDBG_EVENT(VAR_0->file, BLKDBG_REFTABLE_GROW);",
"uint64_t refcount_block_clusters = 1 << (s->cluster_bits - REFCOUNT_SHIFT);",
"uint64_t blocks_used = (s->free_cluster_index +\nrefcount_block_clusters - 1) / refcount_block_clusters;",
"uint64_t table_size = next_refcount_table_size(s, blocks_used + 1);",
"uint64_t last_table_size;",
"uint64_t blocks_clusters;",
"do {",
"uint64_t table_clusters = size_to_clusters(s, table_size);",
"blocks_clusters = 1 +\n((table_clusters + refcount_block_clusters - 1)\n/ refcount_block_clusters);",
"uint64_t meta_clusters = table_clusters + blocks_clusters;",
"last_table_size = table_size;",
"table_size = next_refcount_table_size(s, blocks_used +\n((meta_clusters + refcount_block_clusters - 1)\n/ refcount_block_clusters));",
"} while (last_table_size != table_size);",
"#ifdef DEBUG_ALLOC2\nfprintf(stderr, \"qcow2: Grow refcount table %\" PRId32 \" => %\" PRId64 \"\\n\",\ns->refcount_table_size, table_size);",
"#endif\nuint64_t meta_offset = (blocks_used * refcount_block_clusters) *\ns->cluster_size;",
"uint64_t table_offset = meta_offset + blocks_clusters * s->cluster_size;",
"uint16_t *new_blocks = g_malloc0(blocks_clusters * s->cluster_size);",
"uint64_t *new_table = g_malloc0(table_size * sizeof(uint64_t));",
"assert(meta_offset >= (s->free_cluster_index * s->cluster_size));",
"memcpy(new_table, s->refcount_table,\ns->refcount_table_size * sizeof(uint64_t));",
"new_table[VAR_3] = new_block;",
"int VAR_6;",
"for (VAR_6 = 0; VAR_6 < blocks_clusters; VAR_6++) {",
"new_table[blocks_used + VAR_6] = meta_offset + (VAR_6 * s->cluster_size);",
"}",
"uint64_t table_clusters = size_to_clusters(s, table_size * sizeof(uint64_t));",
"int VAR_7 = 0;",
"for (VAR_6 = 0; VAR_6 < table_clusters + blocks_clusters; VAR_6++) {",
"new_blocks[VAR_7++] = cpu_to_be16(1);",
"}",
"BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS);",
"VAR_4 = bdrv_pwrite_sync(VAR_0->file, meta_offset, new_blocks,\nblocks_clusters * s->cluster_size);",
"g_free(new_blocks);",
"if (VAR_4 < 0) {",
"goto fail_table;",
"}",
"for(VAR_6 = 0; VAR_6 < table_size; VAR_6++) {",
"cpu_to_be64s(&new_table[VAR_6]);",
"}",
"BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE);",
"VAR_4 = bdrv_pwrite_sync(VAR_0->file, table_offset, new_table,\ntable_size * sizeof(uint64_t));",
"if (VAR_4 < 0) {",
"goto fail_table;",
"}",
"for(VAR_6 = 0; VAR_6 < table_size; VAR_6++) {",
"cpu_to_be64s(&new_table[VAR_6]);",
"}",
"uint8_t data[12];",
"cpu_to_be64w((uint64_t*)data, table_offset);",
"cpu_to_be32w((uint32_t*)(data + 8), table_clusters);",
"BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE);",
"VAR_4 = bdrv_pwrite_sync(VAR_0->file, offsetof(QCowHeader, refcount_table_offset),\ndata, sizeof(data));",
"if (VAR_4 < 0) {",
"goto fail_table;",
"}",
"uint64_t old_table_offset = s->refcount_table_offset;",
"uint64_t old_table_size = s->refcount_table_size;",
"g_free(s->refcount_table);",
"s->refcount_table = new_table;",
"s->refcount_table_size = table_size;",
"s->refcount_table_offset = table_offset;",
"uint64_t old_free_cluster_index = s->free_cluster_index;",
"qcow2_free_clusters(VAR_0, old_table_offset, old_table_size * sizeof(uint64_t));",
"s->free_cluster_index = old_free_cluster_index;",
"VAR_4 = load_refcount_block(VAR_0, new_block, (void**) VAR_2);",
"if (VAR_4 < 0) {",
"return VAR_4;",
"}",
"return new_block;",
"fail_table:\ng_free(new_table);",
"fail_block:\nif (*VAR_2 != NULL) {",
"qcow2_cache_put(VAR_0, s->refcount_block_cache, (void**) VAR_2);",
"}",
"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
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
21
],
[
25
],
[
29,
31
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
93
],
[
99
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115,
117,
119,
121
],
[
123,
127
],
[
131,
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
149,
151
],
[
153
],
[
155
],
[
161
],
[
163
],
[
165
],
[
167
],
[
171
],
[
179,
181
],
[
183
],
[
185
],
[
187
],
[
191
],
[
193
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
215
],
[
217
],
[
219
],
[
221,
223,
225
],
[
227
],
[
229
],
[
231
],
[
235
],
[
237
],
[
239
],
[
243
],
[
245
],
[
247
],
[
249
],
[
275
],
[
281
],
[
283,
285
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301,
303,
305
],
[
307
],
[
311
],
[
313,
315,
317
],
[
321
],
[
325,
327,
329
],
[
331,
337,
339
],
[
341
],
[
343
],
[
345
],
[
349
],
[
355,
357
],
[
359
],
[
363
],
[
365
],
[
367
],
[
369
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
389
],
[
391,
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
407
],
[
409
],
[
411
],
[
415
],
[
417,
419
],
[
421
],
[
423
],
[
425
],
[
429
],
[
431
],
[
433
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447,
449
],
[
451
],
[
453
],
[
455
],
[
461
],
[
463
],
[
467
],
[
469
],
[
471
],
[
473
],
[
479
],
[
481
],
[
483
],
[
487
],
[
489
],
[
491
],
[
493
],
[
497
],
[
501,
503
],
[
505,
507
],
[
509
],
[
511
],
[
513
],
[
515
]
]
|
14,435 | static always_inline void gen_qemu_stg (TCGv t0, TCGv t1, int flags)
{
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_helper_1_1(helper_g_to_memory, tmp, t0);
tcg_gen_qemu_st64(tmp, t1, flags);
tcg_temp_free(tmp);
}
| false | qemu | a7812ae412311d7d47f8aa85656faadac9d64b56 | static always_inline void gen_qemu_stg (TCGv t0, TCGv t1, int flags)
{
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_helper_1_1(helper_g_to_memory, tmp, t0);
tcg_gen_qemu_st64(tmp, t1, flags);
tcg_temp_free(tmp);
}
| {
"code": [],
"line_no": []
} | static always_inline void FUNC_0 (TCGv t0, TCGv t1, int flags)
{
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_helper_1_1(helper_g_to_memory, tmp, t0);
tcg_gen_qemu_st64(tmp, t1, flags);
tcg_temp_free(tmp);
}
| [
"static always_inline void FUNC_0 (TCGv t0, TCGv t1, int flags)\n{",
"TCGv tmp = tcg_temp_new(TCG_TYPE_I64);",
"tcg_gen_helper_1_1(helper_g_to_memory, tmp, t0);",
"tcg_gen_qemu_st64(tmp, t1, flags);",
"tcg_temp_free(tmp);",
"}"
]
| [
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
]
|
14,436 | static void test_qemu_strtosz_erange(void)
{
const char *str = "10E";
char *endptr = NULL;
int64_t res;
res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, -ERANGE);
g_assert(endptr == str + 3);
}
| false | qemu | 0b742797aaada3a2e243175a69d542d2ed997aac | static void test_qemu_strtosz_erange(void)
{
const char *str = "10E";
char *endptr = NULL;
int64_t res;
res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, -ERANGE);
g_assert(endptr == str + 3);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
const char *VAR_0 = "10E";
char *VAR_1 = NULL;
int64_t res;
res = qemu_strtosz(VAR_0, &VAR_1);
g_assert_cmpint(res, ==, -ERANGE);
g_assert(VAR_1 == VAR_0 + 3);
}
| [
"static void FUNC_0(void)\n{",
"const char *VAR_0 = \"10E\";",
"char *VAR_1 = NULL;",
"int64_t res;",
"res = qemu_strtosz(VAR_0, &VAR_1);",
"g_assert_cmpint(res, ==, -ERANGE);",
"g_assert(VAR_1 == VAR_0 + 3);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
]
]
|
14,437 | static uint32_t scsi_init_iovec(SCSIDiskReq *r)
{
r->iov.iov_len = MIN(r->sector_count * 512, SCSI_DMA_BUF_SIZE);
qemu_iovec_init_external(&r->qiov, &r->iov, 1);
return r->qiov.size / 512;
}
| false | qemu | 7285477ab11831b1cf56e45878a89170dd06d9b9 | static uint32_t scsi_init_iovec(SCSIDiskReq *r)
{
r->iov.iov_len = MIN(r->sector_count * 512, SCSI_DMA_BUF_SIZE);
qemu_iovec_init_external(&r->qiov, &r->iov, 1);
return r->qiov.size / 512;
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(SCSIDiskReq *r)
{
r->iov.iov_len = MIN(r->sector_count * 512, SCSI_DMA_BUF_SIZE);
qemu_iovec_init_external(&r->qiov, &r->iov, 1);
return r->qiov.size / 512;
}
| [
"static uint32_t FUNC_0(SCSIDiskReq *r)\n{",
"r->iov.iov_len = MIN(r->sector_count * 512, SCSI_DMA_BUF_SIZE);",
"qemu_iovec_init_external(&r->qiov, &r->iov, 1);",
"return r->qiov.size / 512;",
"}"
]
| [
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
]
|
14,438 | static int read_dct_coeffs(BitstreamContext *bc, int32_t block[64],
const uint8_t *scan,
const int32_t quant_matrices[16][64], int q)
{
int coef_list[128];
int mode_list[128];
int i, t, bits, ccoef, mode;
int list_start = 64, list_end = 64, list_pos;
int coef_count = 0;
int coef_idx[64];
int quant_idx;
const int32_t *quant;
coef_list[list_end] = 4; mode_list[list_end++] = 0;
coef_list[list_end] = 24; mode_list[list_end++] = 0;
coef_list[list_end] = 44; mode_list[list_end++] = 0;
coef_list[list_end] = 1; mode_list[list_end++] = 3;
coef_list[list_end] = 2; mode_list[list_end++] = 3;
coef_list[list_end] = 3; mode_list[list_end++] = 3;
for (bits = bitstream_read(bc, 4) - 1; bits >= 0; bits--) {
list_pos = list_start;
while (list_pos < list_end) {
if (!(mode_list[list_pos] | coef_list[list_pos]) || !bitstream_read_bit(bc)) {
list_pos++;
continue;
}
ccoef = coef_list[list_pos];
mode = mode_list[list_pos];
switch (mode) {
case 0:
coef_list[list_pos] = ccoef + 4;
mode_list[list_pos] = 1;
case 2:
if (mode == 2) {
coef_list[list_pos] = 0;
mode_list[list_pos++] = 0;
}
for (i = 0; i < 4; i++, ccoef++) {
if (bitstream_read_bit(bc)) {
coef_list[--list_start] = ccoef;
mode_list[ list_start] = 3;
} else {
if (!bits) {
t = 1 - (bitstream_read_bit(bc) << 1);
} else {
t = bitstream_read(bc, bits) | 1 << bits;
t = bitstream_apply_sign(bc, t);
}
block[scan[ccoef]] = t;
coef_idx[coef_count++] = ccoef;
}
}
break;
case 1:
mode_list[list_pos] = 2;
for (i = 0; i < 3; i++) {
ccoef += 4;
coef_list[list_end] = ccoef;
mode_list[list_end++] = 2;
}
break;
case 3:
if (!bits) {
t = 1 - (bitstream_read_bit(bc) << 1);
} else {
t = bitstream_read(bc, bits) | 1 << bits;
t = bitstream_apply_sign(bc, t);
}
block[scan[ccoef]] = t;
coef_idx[coef_count++] = ccoef;
coef_list[list_pos] = 0;
mode_list[list_pos++] = 0;
break;
}
}
}
if (q == -1) {
quant_idx = bitstream_read(bc, 4);
} else {
quant_idx = q;
}
if (quant_idx >= 16)
return AVERROR_INVALIDDATA;
quant = quant_matrices[quant_idx];
block[0] = (block[0] * quant[0]) >> 11;
for (i = 0; i < coef_count; i++) {
int idx = coef_idx[i];
block[scan[idx]] = (block[scan[idx]] * quant[idx]) >> 11;
}
return 0;
}
| false | FFmpeg | fd92dafaff8844b5fedf94679b93d953939a7f7b | static int read_dct_coeffs(BitstreamContext *bc, int32_t block[64],
const uint8_t *scan,
const int32_t quant_matrices[16][64], int q)
{
int coef_list[128];
int mode_list[128];
int i, t, bits, ccoef, mode;
int list_start = 64, list_end = 64, list_pos;
int coef_count = 0;
int coef_idx[64];
int quant_idx;
const int32_t *quant;
coef_list[list_end] = 4; mode_list[list_end++] = 0;
coef_list[list_end] = 24; mode_list[list_end++] = 0;
coef_list[list_end] = 44; mode_list[list_end++] = 0;
coef_list[list_end] = 1; mode_list[list_end++] = 3;
coef_list[list_end] = 2; mode_list[list_end++] = 3;
coef_list[list_end] = 3; mode_list[list_end++] = 3;
for (bits = bitstream_read(bc, 4) - 1; bits >= 0; bits--) {
list_pos = list_start;
while (list_pos < list_end) {
if (!(mode_list[list_pos] | coef_list[list_pos]) || !bitstream_read_bit(bc)) {
list_pos++;
continue;
}
ccoef = coef_list[list_pos];
mode = mode_list[list_pos];
switch (mode) {
case 0:
coef_list[list_pos] = ccoef + 4;
mode_list[list_pos] = 1;
case 2:
if (mode == 2) {
coef_list[list_pos] = 0;
mode_list[list_pos++] = 0;
}
for (i = 0; i < 4; i++, ccoef++) {
if (bitstream_read_bit(bc)) {
coef_list[--list_start] = ccoef;
mode_list[ list_start] = 3;
} else {
if (!bits) {
t = 1 - (bitstream_read_bit(bc) << 1);
} else {
t = bitstream_read(bc, bits) | 1 << bits;
t = bitstream_apply_sign(bc, t);
}
block[scan[ccoef]] = t;
coef_idx[coef_count++] = ccoef;
}
}
break;
case 1:
mode_list[list_pos] = 2;
for (i = 0; i < 3; i++) {
ccoef += 4;
coef_list[list_end] = ccoef;
mode_list[list_end++] = 2;
}
break;
case 3:
if (!bits) {
t = 1 - (bitstream_read_bit(bc) << 1);
} else {
t = bitstream_read(bc, bits) | 1 << bits;
t = bitstream_apply_sign(bc, t);
}
block[scan[ccoef]] = t;
coef_idx[coef_count++] = ccoef;
coef_list[list_pos] = 0;
mode_list[list_pos++] = 0;
break;
}
}
}
if (q == -1) {
quant_idx = bitstream_read(bc, 4);
} else {
quant_idx = q;
}
if (quant_idx >= 16)
return AVERROR_INVALIDDATA;
quant = quant_matrices[quant_idx];
block[0] = (block[0] * quant[0]) >> 11;
for (i = 0; i < coef_count; i++) {
int idx = coef_idx[i];
block[scan[idx]] = (block[scan[idx]] * quant[idx]) >> 11;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BitstreamContext *VAR_0, int32_t VAR_1[64],
const uint8_t *VAR_2,
const int32_t VAR_3[16][64], int VAR_4)
{
int VAR_5[128];
int VAR_6[128];
int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;
int VAR_12 = 64, VAR_13 = 64, VAR_14;
int VAR_15 = 0;
int VAR_16[64];
int VAR_17;
const int32_t *VAR_18;
VAR_5[VAR_13] = 4; VAR_6[VAR_13++] = 0;
VAR_5[VAR_13] = 24; VAR_6[VAR_13++] = 0;
VAR_5[VAR_13] = 44; VAR_6[VAR_13++] = 0;
VAR_5[VAR_13] = 1; VAR_6[VAR_13++] = 3;
VAR_5[VAR_13] = 2; VAR_6[VAR_13++] = 3;
VAR_5[VAR_13] = 3; VAR_6[VAR_13++] = 3;
for (VAR_9 = bitstream_read(VAR_0, 4) - 1; VAR_9 >= 0; VAR_9--) {
VAR_14 = VAR_12;
while (VAR_14 < VAR_13) {
if (!(VAR_6[VAR_14] | VAR_5[VAR_14]) || !bitstream_read_bit(VAR_0)) {
VAR_14++;
continue;
}
VAR_10 = VAR_5[VAR_14];
VAR_11 = VAR_6[VAR_14];
switch (VAR_11) {
case 0:
VAR_5[VAR_14] = VAR_10 + 4;
VAR_6[VAR_14] = 1;
case 2:
if (VAR_11 == 2) {
VAR_5[VAR_14] = 0;
VAR_6[VAR_14++] = 0;
}
for (VAR_7 = 0; VAR_7 < 4; VAR_7++, VAR_10++) {
if (bitstream_read_bit(VAR_0)) {
VAR_5[--VAR_12] = VAR_10;
VAR_6[ VAR_12] = 3;
} else {
if (!VAR_9) {
VAR_8 = 1 - (bitstream_read_bit(VAR_0) << 1);
} else {
VAR_8 = bitstream_read(VAR_0, VAR_9) | 1 << VAR_9;
VAR_8 = bitstream_apply_sign(VAR_0, VAR_8);
}
VAR_1[VAR_2[VAR_10]] = VAR_8;
VAR_16[VAR_15++] = VAR_10;
}
}
break;
case 1:
VAR_6[VAR_14] = 2;
for (VAR_7 = 0; VAR_7 < 3; VAR_7++) {
VAR_10 += 4;
VAR_5[VAR_13] = VAR_10;
VAR_6[VAR_13++] = 2;
}
break;
case 3:
if (!VAR_9) {
VAR_8 = 1 - (bitstream_read_bit(VAR_0) << 1);
} else {
VAR_8 = bitstream_read(VAR_0, VAR_9) | 1 << VAR_9;
VAR_8 = bitstream_apply_sign(VAR_0, VAR_8);
}
VAR_1[VAR_2[VAR_10]] = VAR_8;
VAR_16[VAR_15++] = VAR_10;
VAR_5[VAR_14] = 0;
VAR_6[VAR_14++] = 0;
break;
}
}
}
if (VAR_4 == -1) {
VAR_17 = bitstream_read(VAR_0, 4);
} else {
VAR_17 = VAR_4;
}
if (VAR_17 >= 16)
return AVERROR_INVALIDDATA;
VAR_18 = VAR_3[VAR_17];
VAR_1[0] = (VAR_1[0] * VAR_18[0]) >> 11;
for (VAR_7 = 0; VAR_7 < VAR_15; VAR_7++) {
int VAR_19 = VAR_16[VAR_7];
VAR_1[VAR_2[VAR_19]] = (VAR_1[VAR_2[VAR_19]] * VAR_18[VAR_19]) >> 11;
}
return 0;
}
| [
"static int FUNC_0(BitstreamContext *VAR_0, int32_t VAR_1[64],\nconst uint8_t *VAR_2,\nconst int32_t VAR_3[16][64], int VAR_4)\n{",
"int VAR_5[128];",
"int VAR_6[128];",
"int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;",
"int VAR_12 = 64, VAR_13 = 64, VAR_14;",
"int VAR_15 = 0;",
"int VAR_16[64];",
"int VAR_17;",
"const int32_t *VAR_18;",
"VAR_5[VAR_13] = 4; VAR_6[VAR_13++] = 0;",
"VAR_5[VAR_13] = 24; VAR_6[VAR_13++] = 0;",
"VAR_5[VAR_13] = 44; VAR_6[VAR_13++] = 0;",
"VAR_5[VAR_13] = 1; VAR_6[VAR_13++] = 3;",
"VAR_5[VAR_13] = 2; VAR_6[VAR_13++] = 3;",
"VAR_5[VAR_13] = 3; VAR_6[VAR_13++] = 3;",
"for (VAR_9 = bitstream_read(VAR_0, 4) - 1; VAR_9 >= 0; VAR_9--) {",
"VAR_14 = VAR_12;",
"while (VAR_14 < VAR_13) {",
"if (!(VAR_6[VAR_14] | VAR_5[VAR_14]) || !bitstream_read_bit(VAR_0)) {",
"VAR_14++;",
"continue;",
"}",
"VAR_10 = VAR_5[VAR_14];",
"VAR_11 = VAR_6[VAR_14];",
"switch (VAR_11) {",
"case 0:\nVAR_5[VAR_14] = VAR_10 + 4;",
"VAR_6[VAR_14] = 1;",
"case 2:\nif (VAR_11 == 2) {",
"VAR_5[VAR_14] = 0;",
"VAR_6[VAR_14++] = 0;",
"}",
"for (VAR_7 = 0; VAR_7 < 4; VAR_7++, VAR_10++) {",
"if (bitstream_read_bit(VAR_0)) {",
"VAR_5[--VAR_12] = VAR_10;",
"VAR_6[ VAR_12] = 3;",
"} else {",
"if (!VAR_9) {",
"VAR_8 = 1 - (bitstream_read_bit(VAR_0) << 1);",
"} else {",
"VAR_8 = bitstream_read(VAR_0, VAR_9) | 1 << VAR_9;",
"VAR_8 = bitstream_apply_sign(VAR_0, VAR_8);",
"}",
"VAR_1[VAR_2[VAR_10]] = VAR_8;",
"VAR_16[VAR_15++] = VAR_10;",
"}",
"}",
"break;",
"case 1:\nVAR_6[VAR_14] = 2;",
"for (VAR_7 = 0; VAR_7 < 3; VAR_7++) {",
"VAR_10 += 4;",
"VAR_5[VAR_13] = VAR_10;",
"VAR_6[VAR_13++] = 2;",
"}",
"break;",
"case 3:\nif (!VAR_9) {",
"VAR_8 = 1 - (bitstream_read_bit(VAR_0) << 1);",
"} else {",
"VAR_8 = bitstream_read(VAR_0, VAR_9) | 1 << VAR_9;",
"VAR_8 = bitstream_apply_sign(VAR_0, VAR_8);",
"}",
"VAR_1[VAR_2[VAR_10]] = VAR_8;",
"VAR_16[VAR_15++] = VAR_10;",
"VAR_5[VAR_14] = 0;",
"VAR_6[VAR_14++] = 0;",
"break;",
"}",
"}",
"}",
"if (VAR_4 == -1) {",
"VAR_17 = bitstream_read(VAR_0, 4);",
"} else {",
"VAR_17 = VAR_4;",
"}",
"if (VAR_17 >= 16)\nreturn AVERROR_INVALIDDATA;",
"VAR_18 = VAR_3[VAR_17];",
"VAR_1[0] = (VAR_1[0] * VAR_18[0]) >> 11;",
"for (VAR_7 = 0; VAR_7 < VAR_15; VAR_7++) {",
"int VAR_19 = VAR_16[VAR_7];",
"VAR_1[VAR_2[VAR_19]] = (VAR_1[VAR_2[VAR_19]] * VAR_18[VAR_19]) >> 11;",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125,
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169,
171
],
[
175
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191
],
[
193
]
]
|
14,439 | bool qemu_co_queue_next(CoQueue *queue)
{
Coroutine *next;
next = QTAILQ_FIRST(&queue->entries);
if (next) {
QTAILQ_REMOVE(&queue->entries, next, co_queue_next);
QTAILQ_INSERT_TAIL(&unlock_bh_queue, next, co_queue_next);
trace_qemu_co_queue_next(next);
qemu_bh_schedule(unlock_bh);
}
return (next != NULL);
}
| false | qemu | 28f082469650a0f4c0e37b4ccd6f9514b1a0698d | bool qemu_co_queue_next(CoQueue *queue)
{
Coroutine *next;
next = QTAILQ_FIRST(&queue->entries);
if (next) {
QTAILQ_REMOVE(&queue->entries, next, co_queue_next);
QTAILQ_INSERT_TAIL(&unlock_bh_queue, next, co_queue_next);
trace_qemu_co_queue_next(next);
qemu_bh_schedule(unlock_bh);
}
return (next != NULL);
}
| {
"code": [],
"line_no": []
} | bool FUNC_0(CoQueue *queue)
{
Coroutine *next;
next = QTAILQ_FIRST(&queue->entries);
if (next) {
QTAILQ_REMOVE(&queue->entries, next, co_queue_next);
QTAILQ_INSERT_TAIL(&unlock_bh_queue, next, co_queue_next);
trace_qemu_co_queue_next(next);
qemu_bh_schedule(unlock_bh);
}
return (next != NULL);
}
| [
"bool FUNC_0(CoQueue *queue)\n{",
"Coroutine *next;",
"next = QTAILQ_FIRST(&queue->entries);",
"if (next) {",
"QTAILQ_REMOVE(&queue->entries, next, co_queue_next);",
"QTAILQ_INSERT_TAIL(&unlock_bh_queue, next, co_queue_next);",
"trace_qemu_co_queue_next(next);",
"qemu_bh_schedule(unlock_bh);",
"}",
"return (next != NULL);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
]
]
|
14,440 | static int nut_write_packet(AVFormatContext *s, int stream_index,
const uint8_t *buf, int size, int64_t pts)
{
NUTContext *nut = s->priv_data;
StreamContext *stream= &nut->stream[stream_index];
ByteIOContext *bc = &s->pb;
int key_frame = 0, full_pts=0;
AVCodecContext *enc;
int64_t lsb_pts, delta_pts;
int frame_type, best_length, frame_code, flags, i, size_mul, size_lsb;
const int64_t frame_start= url_ftell(bc);
if (stream_index > s->nb_streams)
return 1;
pts= (av_rescale(pts, stream->rate_num, stream->rate_den) + AV_TIME_BASE/2) / AV_TIME_BASE;
enc = &s->streams[stream_index]->codec;
key_frame = enc->coded_frame->key_frame;
delta_pts= pts - stream->last_pts;
frame_type=0;
if(frame_start + size + 20 - FFMAX(nut->last_frame_start[1], nut->last_frame_start[2]) > MAX_TYPE1_DISTANCE)
frame_type=1;
if(key_frame){
if(frame_type==1 && frame_start + size - nut->last_frame_start[2] > MAX_TYPE2_DISTANCE)
frame_type=2;
if(!stream->last_key_frame)
frame_type=2;
}
if(frame_type>0){
update_packetheader(nut, bc, 0);
reset(s);
full_pts=1;
}
//FIXME ensure that the timestamp can be represented by either delta or lsb or full_pts=1
lsb_pts = pts & ((1 << stream->msb_timestamp_shift)-1);
best_length=INT_MAX;
frame_code= -1;
for(i=0; i<256; i++){
int stream_id_plus1= nut->frame_code[i].stream_id_plus1;
int fc_key_frame= stream->last_key_frame;
int length=0;
size_mul= nut->frame_code[i].size_mul;
size_lsb= nut->frame_code[i].size_lsb;
flags= nut->frame_code[i].flags;
if(stream_id_plus1 == 0) length+= get_length(stream_index);
else if(stream_id_plus1 - 1 != stream_index)
continue;
if(flags & FLAG_PRED_KEY_FRAME){
if(flags & FLAG_KEY_FRAME)
fc_key_frame= !fc_key_frame;
}else{
fc_key_frame= !!(flags & FLAG_KEY_FRAME);
}
assert(key_frame==0 || key_frame==1);
if(fc_key_frame != key_frame)
continue;
if((!!(flags & FLAG_FRAME_TYPE)) != (frame_type > 0))
continue;
if(size_mul <= size_lsb){
int p= stream->lru_size[size_lsb - size_mul];
if(p != size)
continue;
}else{
if(size % size_mul != size_lsb)
continue;
if(flags & FLAG_DATA_SIZE)
length += get_length(size / size_mul);
else if(size/size_mul)
continue;
}
if(full_pts != ((flags & FLAG_PTS) && (flags & FLAG_FULL_PTS)))
continue;
if(flags&FLAG_PTS){
if(flags&FLAG_FULL_PTS){
length += get_length(pts);
}else{
length += get_length(lsb_pts);
}
}else{
int delta= stream->lru_pts_delta[(flags & 12)>>2];
if(delta != pts - stream->last_pts)
continue;
assert(frame_type == 0);
}
if(length < best_length){
best_length= length;
frame_code=i;
}
// av_log(s, AV_LOG_DEBUG, "%d %d %d %d %d %d %d %d %d %d\n", key_frame, frame_type, full_pts, size, stream_index, flags, size_mul, size_lsb, stream_id_plus1, length);
}
assert(frame_code != -1);
flags= nut->frame_code[frame_code].flags;
size_mul= nut->frame_code[frame_code].size_mul;
size_lsb= nut->frame_code[frame_code].size_lsb;
#if 0
best_length /= 7;
best_length ++; //frame_code
if(frame_type>0){
best_length += 4; //packet header
if(frame_type>1)
best_length += 8; // startcode
}
av_log(s, AV_LOG_DEBUG, "kf:%d ft:%d pt:%d fc:%2X len:%2d size:%d stream:%d flag:%d mul:%d lsb:%d s+1:%d pts_delta:%d\n", key_frame, frame_type, full_pts ? 2 : ((flags & FLAG_PTS) ? 1 : 0), frame_code, best_length, size, stream_index, flags, size_mul, size_lsb, nut->frame_code[frame_code].stream_id_plus1,(int)(pts - stream->last_pts));
#endif
if (frame_type==2)
put_be64(bc, KEYFRAME_STARTCODE);
put_byte(bc, frame_code);
if(frame_type>0)
put_packetheader(nut, bc, FFMAX(size+20, MAX_TYPE1_DISTANCE));
if(nut->frame_code[frame_code].stream_id_plus1 == 0)
put_v(bc, stream_index);
if (flags & FLAG_PTS){
if (flags & FLAG_FULL_PTS)
put_v(bc, pts);
else
put_v(bc, lsb_pts);
}
if(flags & FLAG_DATA_SIZE)
put_v(bc, size / size_mul);
if(size > MAX_TYPE1_DISTANCE){
assert(frame_type > 0);
update_packetheader(nut, bc, size);
}
put_buffer(bc, buf, size);
update(nut, stream_index, frame_start, frame_type, frame_code, key_frame, size, pts);
return 0;
}
| false | FFmpeg | ee9f36a88eb3e2706ea659acb0ca80c414fa5d8a | static int nut_write_packet(AVFormatContext *s, int stream_index,
const uint8_t *buf, int size, int64_t pts)
{
NUTContext *nut = s->priv_data;
StreamContext *stream= &nut->stream[stream_index];
ByteIOContext *bc = &s->pb;
int key_frame = 0, full_pts=0;
AVCodecContext *enc;
int64_t lsb_pts, delta_pts;
int frame_type, best_length, frame_code, flags, i, size_mul, size_lsb;
const int64_t frame_start= url_ftell(bc);
if (stream_index > s->nb_streams)
return 1;
pts= (av_rescale(pts, stream->rate_num, stream->rate_den) + AV_TIME_BASE/2) / AV_TIME_BASE;
enc = &s->streams[stream_index]->codec;
key_frame = enc->coded_frame->key_frame;
delta_pts= pts - stream->last_pts;
frame_type=0;
if(frame_start + size + 20 - FFMAX(nut->last_frame_start[1], nut->last_frame_start[2]) > MAX_TYPE1_DISTANCE)
frame_type=1;
if(key_frame){
if(frame_type==1 && frame_start + size - nut->last_frame_start[2] > MAX_TYPE2_DISTANCE)
frame_type=2;
if(!stream->last_key_frame)
frame_type=2;
}
if(frame_type>0){
update_packetheader(nut, bc, 0);
reset(s);
full_pts=1;
}
lsb_pts = pts & ((1 << stream->msb_timestamp_shift)-1);
best_length=INT_MAX;
frame_code= -1;
for(i=0; i<256; i++){
int stream_id_plus1= nut->frame_code[i].stream_id_plus1;
int fc_key_frame= stream->last_key_frame;
int length=0;
size_mul= nut->frame_code[i].size_mul;
size_lsb= nut->frame_code[i].size_lsb;
flags= nut->frame_code[i].flags;
if(stream_id_plus1 == 0) length+= get_length(stream_index);
else if(stream_id_plus1 - 1 != stream_index)
continue;
if(flags & FLAG_PRED_KEY_FRAME){
if(flags & FLAG_KEY_FRAME)
fc_key_frame= !fc_key_frame;
}else{
fc_key_frame= !!(flags & FLAG_KEY_FRAME);
}
assert(key_frame==0 || key_frame==1);
if(fc_key_frame != key_frame)
continue;
if((!!(flags & FLAG_FRAME_TYPE)) != (frame_type > 0))
continue;
if(size_mul <= size_lsb){
int p= stream->lru_size[size_lsb - size_mul];
if(p != size)
continue;
}else{
if(size % size_mul != size_lsb)
continue;
if(flags & FLAG_DATA_SIZE)
length += get_length(size / size_mul);
else if(size/size_mul)
continue;
}
if(full_pts != ((flags & FLAG_PTS) && (flags & FLAG_FULL_PTS)))
continue;
if(flags&FLAG_PTS){
if(flags&FLAG_FULL_PTS){
length += get_length(pts);
}else{
length += get_length(lsb_pts);
}
}else{
int delta= stream->lru_pts_delta[(flags & 12)>>2];
if(delta != pts - stream->last_pts)
continue;
assert(frame_type == 0);
}
if(length < best_length){
best_length= length;
frame_code=i;
}
}
assert(frame_code != -1);
flags= nut->frame_code[frame_code].flags;
size_mul= nut->frame_code[frame_code].size_mul;
size_lsb= nut->frame_code[frame_code].size_lsb;
#if 0
best_length /= 7;
best_length ++;
if(frame_type>0){
best_length += 4;
if(frame_type>1)
best_length += 8;
}
av_log(s, AV_LOG_DEBUG, "kf:%d ft:%d pt:%d fc:%2X len:%2d size:%d stream:%d flag:%d mul:%d lsb:%d s+1:%d pts_delta:%d\n", key_frame, frame_type, full_pts ? 2 : ((flags & FLAG_PTS) ? 1 : 0), frame_code, best_length, size, stream_index, flags, size_mul, size_lsb, nut->frame_code[frame_code].stream_id_plus1,(int)(pts - stream->last_pts));
#endif
if (frame_type==2)
put_be64(bc, KEYFRAME_STARTCODE);
put_byte(bc, frame_code);
if(frame_type>0)
put_packetheader(nut, bc, FFMAX(size+20, MAX_TYPE1_DISTANCE));
if(nut->frame_code[frame_code].stream_id_plus1 == 0)
put_v(bc, stream_index);
if (flags & FLAG_PTS){
if (flags & FLAG_FULL_PTS)
put_v(bc, pts);
else
put_v(bc, lsb_pts);
}
if(flags & FLAG_DATA_SIZE)
put_v(bc, size / size_mul);
if(size > MAX_TYPE1_DISTANCE){
assert(frame_type > 0);
update_packetheader(nut, bc, size);
}
put_buffer(bc, buf, size);
update(nut, stream_index, frame_start, frame_type, frame_code, key_frame, size, pts);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,
const uint8_t *VAR_2, int VAR_3, int64_t VAR_4)
{
NUTContext *nut = VAR_0->priv_data;
StreamContext *stream= &nut->stream[VAR_1];
ByteIOContext *bc = &VAR_0->pb;
int VAR_5 = 0, VAR_6=0;
AVCodecContext *enc;
int64_t lsb_pts, delta_pts;
int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;
const int64_t VAR_14= url_ftell(bc);
if (VAR_1 > VAR_0->nb_streams)
return 1;
VAR_4= (av_rescale(VAR_4, stream->rate_num, stream->rate_den) + AV_TIME_BASE/2) / AV_TIME_BASE;
enc = &VAR_0->streams[VAR_1]->codec;
VAR_5 = enc->coded_frame->VAR_5;
delta_pts= VAR_4 - stream->last_pts;
VAR_7=0;
if(VAR_14 + VAR_3 + 20 - FFMAX(nut->last_frame_start[1], nut->last_frame_start[2]) > MAX_TYPE1_DISTANCE)
VAR_7=1;
if(VAR_5){
if(VAR_7==1 && VAR_14 + VAR_3 - nut->last_frame_start[2] > MAX_TYPE2_DISTANCE)
VAR_7=2;
if(!stream->last_key_frame)
VAR_7=2;
}
if(VAR_7>0){
update_packetheader(nut, bc, 0);
reset(VAR_0);
VAR_6=1;
}
lsb_pts = VAR_4 & ((1 << stream->msb_timestamp_shift)-1);
VAR_8=INT_MAX;
VAR_9= -1;
for(VAR_11=0; VAR_11<256; VAR_11++){
int VAR_15= nut->VAR_9[VAR_11].VAR_15;
int VAR_16= stream->last_key_frame;
int VAR_17=0;
VAR_12= nut->VAR_9[VAR_11].VAR_12;
VAR_13= nut->VAR_9[VAR_11].VAR_13;
VAR_10= nut->VAR_9[VAR_11].VAR_10;
if(VAR_15 == 0) VAR_17+= get_length(VAR_1);
else if(VAR_15 - 1 != VAR_1)
continue;
if(VAR_10 & FLAG_PRED_KEY_FRAME){
if(VAR_10 & FLAG_KEY_FRAME)
VAR_16= !VAR_16;
}else{
VAR_16= !!(VAR_10 & FLAG_KEY_FRAME);
}
assert(VAR_5==0 || VAR_5==1);
if(VAR_16 != VAR_5)
continue;
if((!!(VAR_10 & FLAG_FRAME_TYPE)) != (VAR_7 > 0))
continue;
if(VAR_12 <= VAR_13){
int VAR_18= stream->lru_size[VAR_13 - VAR_12];
if(VAR_18 != VAR_3)
continue;
}else{
if(VAR_3 % VAR_12 != VAR_13)
continue;
if(VAR_10 & FLAG_DATA_SIZE)
VAR_17 += get_length(VAR_3 / VAR_12);
else if(VAR_3/VAR_12)
continue;
}
if(VAR_6 != ((VAR_10 & FLAG_PTS) && (VAR_10 & FLAG_FULL_PTS)))
continue;
if(VAR_10&FLAG_PTS){
if(VAR_10&FLAG_FULL_PTS){
VAR_17 += get_length(VAR_4);
}else{
VAR_17 += get_length(lsb_pts);
}
}else{
int VAR_19= stream->lru_pts_delta[(VAR_10 & 12)>>2];
if(VAR_19 != VAR_4 - stream->last_pts)
continue;
assert(VAR_7 == 0);
}
if(VAR_17 < VAR_8){
VAR_8= VAR_17;
VAR_9=VAR_11;
}
}
assert(VAR_9 != -1);
VAR_10= nut->VAR_9[VAR_9].VAR_10;
VAR_12= nut->VAR_9[VAR_9].VAR_12;
VAR_13= nut->VAR_9[VAR_9].VAR_13;
#if 0
VAR_8 /= 7;
VAR_8 ++;
if(VAR_7>0){
VAR_8 += 4;
if(VAR_7>1)
VAR_8 += 8;
}
av_log(VAR_0, AV_LOG_DEBUG, "kf:%d ft:%d pt:%d fc:%2X len:%2d VAR_3:%d stream:%d flag:%d mul:%d lsb:%d VAR_0+1:%d pts_delta:%d\n", VAR_5, VAR_7, VAR_6 ? 2 : ((VAR_10 & FLAG_PTS) ? 1 : 0), VAR_9, VAR_8, VAR_3, VAR_1, VAR_10, VAR_12, VAR_13, nut->VAR_9[VAR_9].VAR_15,(int)(VAR_4 - stream->last_pts));
#endif
if (VAR_7==2)
put_be64(bc, KEYFRAME_STARTCODE);
put_byte(bc, VAR_9);
if(VAR_7>0)
put_packetheader(nut, bc, FFMAX(VAR_3+20, MAX_TYPE1_DISTANCE));
if(nut->VAR_9[VAR_9].VAR_15 == 0)
put_v(bc, VAR_1);
if (VAR_10 & FLAG_PTS){
if (VAR_10 & FLAG_FULL_PTS)
put_v(bc, VAR_4);
else
put_v(bc, lsb_pts);
}
if(VAR_10 & FLAG_DATA_SIZE)
put_v(bc, VAR_3 / VAR_12);
if(VAR_3 > MAX_TYPE1_DISTANCE){
assert(VAR_7 > 0);
update_packetheader(nut, bc, VAR_3);
}
put_buffer(bc, VAR_2, VAR_3);
update(nut, VAR_1, VAR_14, VAR_7, VAR_9, VAR_5, VAR_3, VAR_4);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,\nconst uint8_t *VAR_2, int VAR_3, int64_t VAR_4)\n{",
"NUTContext *nut = VAR_0->priv_data;",
"StreamContext *stream= &nut->stream[VAR_1];",
"ByteIOContext *bc = &VAR_0->pb;",
"int VAR_5 = 0, VAR_6=0;",
"AVCodecContext *enc;",
"int64_t lsb_pts, delta_pts;",
"int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;",
"const int64_t VAR_14= url_ftell(bc);",
"if (VAR_1 > VAR_0->nb_streams)\nreturn 1;",
"VAR_4= (av_rescale(VAR_4, stream->rate_num, stream->rate_den) + AV_TIME_BASE/2) / AV_TIME_BASE;",
"enc = &VAR_0->streams[VAR_1]->codec;",
"VAR_5 = enc->coded_frame->VAR_5;",
"delta_pts= VAR_4 - stream->last_pts;",
"VAR_7=0;",
"if(VAR_14 + VAR_3 + 20 - FFMAX(nut->last_frame_start[1], nut->last_frame_start[2]) > MAX_TYPE1_DISTANCE)\nVAR_7=1;",
"if(VAR_5){",
"if(VAR_7==1 && VAR_14 + VAR_3 - nut->last_frame_start[2] > MAX_TYPE2_DISTANCE)\nVAR_7=2;",
"if(!stream->last_key_frame)\nVAR_7=2;",
"}",
"if(VAR_7>0){",
"update_packetheader(nut, bc, 0);",
"reset(VAR_0);",
"VAR_6=1;",
"}",
"lsb_pts = VAR_4 & ((1 << stream->msb_timestamp_shift)-1);",
"VAR_8=INT_MAX;",
"VAR_9= -1;",
"for(VAR_11=0; VAR_11<256; VAR_11++){",
"int VAR_15= nut->VAR_9[VAR_11].VAR_15;",
"int VAR_16= stream->last_key_frame;",
"int VAR_17=0;",
"VAR_12= nut->VAR_9[VAR_11].VAR_12;",
"VAR_13= nut->VAR_9[VAR_11].VAR_13;",
"VAR_10= nut->VAR_9[VAR_11].VAR_10;",
"if(VAR_15 == 0) VAR_17+= get_length(VAR_1);",
"else if(VAR_15 - 1 != VAR_1)\ncontinue;",
"if(VAR_10 & FLAG_PRED_KEY_FRAME){",
"if(VAR_10 & FLAG_KEY_FRAME)\nVAR_16= !VAR_16;",
"}else{",
"VAR_16= !!(VAR_10 & FLAG_KEY_FRAME);",
"}",
"assert(VAR_5==0 || VAR_5==1);",
"if(VAR_16 != VAR_5)\ncontinue;",
"if((!!(VAR_10 & FLAG_FRAME_TYPE)) != (VAR_7 > 0))\ncontinue;",
"if(VAR_12 <= VAR_13){",
"int VAR_18= stream->lru_size[VAR_13 - VAR_12];",
"if(VAR_18 != VAR_3)\ncontinue;",
"}else{",
"if(VAR_3 % VAR_12 != VAR_13)\ncontinue;",
"if(VAR_10 & FLAG_DATA_SIZE)\nVAR_17 += get_length(VAR_3 / VAR_12);",
"else if(VAR_3/VAR_12)\ncontinue;",
"}",
"if(VAR_6 != ((VAR_10 & FLAG_PTS) && (VAR_10 & FLAG_FULL_PTS)))\ncontinue;",
"if(VAR_10&FLAG_PTS){",
"if(VAR_10&FLAG_FULL_PTS){",
"VAR_17 += get_length(VAR_4);",
"}else{",
"VAR_17 += get_length(lsb_pts);",
"}",
"}else{",
"int VAR_19= stream->lru_pts_delta[(VAR_10 & 12)>>2];",
"if(VAR_19 != VAR_4 - stream->last_pts)\ncontinue;",
"assert(VAR_7 == 0);",
"}",
"if(VAR_17 < VAR_8){",
"VAR_8= VAR_17;",
"VAR_9=VAR_11;",
"}",
"}",
"assert(VAR_9 != -1);",
"VAR_10= nut->VAR_9[VAR_9].VAR_10;",
"VAR_12= nut->VAR_9[VAR_9].VAR_12;",
"VAR_13= nut->VAR_9[VAR_9].VAR_13;",
"#if 0\nVAR_8 /= 7;",
"VAR_8 ++;",
"if(VAR_7>0){",
"VAR_8 += 4;",
"if(VAR_7>1)\nVAR_8 += 8;",
"}",
"av_log(VAR_0, AV_LOG_DEBUG, \"kf:%d ft:%d pt:%d fc:%2X len:%2d VAR_3:%d stream:%d flag:%d mul:%d lsb:%d VAR_0+1:%d pts_delta:%d\\n\", VAR_5, VAR_7, VAR_6 ? 2 : ((VAR_10 & FLAG_PTS) ? 1 : 0), VAR_9, VAR_8, VAR_3, VAR_1, VAR_10, VAR_12, VAR_13, nut->VAR_9[VAR_9].VAR_15,(int)(VAR_4 - stream->last_pts));",
"#endif\nif (VAR_7==2)\nput_be64(bc, KEYFRAME_STARTCODE);",
"put_byte(bc, VAR_9);",
"if(VAR_7>0)\nput_packetheader(nut, bc, FFMAX(VAR_3+20, MAX_TYPE1_DISTANCE));",
"if(nut->VAR_9[VAR_9].VAR_15 == 0)\nput_v(bc, VAR_1);",
"if (VAR_10 & FLAG_PTS){",
"if (VAR_10 & FLAG_FULL_PTS)\nput_v(bc, VAR_4);",
"else\nput_v(bc, lsb_pts);",
"}",
"if(VAR_10 & FLAG_DATA_SIZE)\nput_v(bc, VAR_3 / VAR_12);",
"if(VAR_3 > MAX_TYPE1_DISTANCE){",
"assert(VAR_7 > 0);",
"update_packetheader(nut, bc, VAR_3);",
"}",
"put_buffer(bc, VAR_2, VAR_3);",
"update(nut, VAR_1, VAR_14, VAR_7, VAR_9, VAR_5, VAR_3, VAR_4);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25,
27
],
[
31
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45,
47
],
[
49
],
[
51,
53
],
[
55,
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103,
105
],
[
107
],
[
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121,
123
],
[
127,
129
],
[
133
],
[
135
],
[
137,
139
],
[
141
],
[
143,
145
],
[
147,
149
],
[
151,
153
],
[
155
],
[
159,
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181,
183
],
[
185
],
[
187
],
[
191
],
[
193
],
[
195
],
[
197
],
[
201
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213,
215
],
[
217
],
[
219
],
[
221
],
[
223,
225
],
[
227
],
[
229
],
[
231,
235,
237
],
[
239
],
[
243,
245
],
[
247,
249
],
[
251
],
[
253,
255
],
[
257,
259
],
[
261
],
[
263,
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
277
],
[
281
],
[
285
],
[
287
]
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.