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 |
|---|---|---|---|---|---|---|---|---|---|---|
9,444 | bool qvirtio_wait_config_isr(const QVirtioBus *bus, QVirtioDevice *d,
uint64_t timeout)
{
do {
clock_step(100);
if (bus->get_config_isr_status(d)) {
break; /* It has ended */
}
} while (--timeout);
return timeout != 0;
}
| true | qemu | 70556264a89a268efba1d7e8e341adcdd7881eb4 | bool qvirtio_wait_config_isr(const QVirtioBus *bus, QVirtioDevice *d,
uint64_t timeout)
{
do {
clock_step(100);
if (bus->get_config_isr_status(d)) {
break;
}
} while (--timeout);
return timeout != 0;
}
| {
"code": [
" do {",
" } while (--timeout);",
" return timeout != 0;",
"bool qvirtio_wait_config_isr(const QVirtioBus *bus, QVirtioDevice *d,",
" uint64_t timeout)",
" do {",
" } while (--timeout);",
" return timeout != 0;",
"bool qvirtio_wait_config_isr(const QVirtioBus *bus, QVirtioDevice *d,"
],
"line_no": [
7,
17,
21,
1,
3,
7,
17,
21,
1
]
} | bool FUNC_0(const QVirtioBus *bus, QVirtioDevice *d,
uint64_t timeout)
{
do {
clock_step(100);
if (bus->get_config_isr_status(d)) {
break;
}
} while (--timeout);
return timeout != 0;
}
| [
"bool FUNC_0(const QVirtioBus *bus, QVirtioDevice *d,\nuint64_t timeout)\n{",
"do {",
"clock_step(100);",
"if (bus->get_config_isr_status(d)) {",
"break;",
"}",
"} while (--timeout);",
"return timeout != 0;",
"}"
] | [
1,
0,
0,
0,
0,
0,
1,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
]
] |
9,446 | void serial_exit_core(SerialState *s)
{
qemu_chr_fe_deinit(&s->chr);
qemu_unregister_reset(serial_reset, s);
} | true | qemu | 8409dc884a201bf74b30a9d232b6bbdd00cb7e2b | void serial_exit_core(SerialState *s)
{
qemu_chr_fe_deinit(&s->chr);
qemu_unregister_reset(serial_reset, s);
} | {
"code": [],
"line_no": []
} | void FUNC_0(SerialState *VAR_0)
{
qemu_chr_fe_deinit(&VAR_0->chr);
qemu_unregister_reset(serial_reset, VAR_0);
} | [
"void FUNC_0(SerialState *VAR_0)\n{",
"qemu_chr_fe_deinit(&VAR_0->chr);",
"qemu_unregister_reset(serial_reset, VAR_0);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
]
] |
9,447 | int ff_nvdec_frame_params(AVCodecContext *avctx,
AVBufferRef *hw_frames_ctx,
int dpb_size)
{
AVHWFramesContext *frames_ctx = (AVHWFramesContext*)hw_frames_ctx->data;
const AVPixFmtDescriptor *sw_desc;
int cuvid_codec_type, cuvid_chroma_format;
sw_desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
if (!sw_desc)
return AVERROR_BUG;
cuvid_codec_type = map_avcodec_id(avctx->codec_id);
if (cuvid_codec_type < 0) {
av_log(avctx, AV_LOG_ERROR, "Unsupported codec ID\n");
return AVERROR_BUG;
}
cuvid_chroma_format = map_chroma_format(avctx->sw_pix_fmt);
if (cuvid_chroma_format < 0) {
av_log(avctx, AV_LOG_VERBOSE, "Unsupported chroma format\n");
return AVERROR(EINVAL);
}
if (avctx->thread_type & FF_THREAD_FRAME)
dpb_size += avctx->thread_count;
frames_ctx->format = AV_PIX_FMT_CUDA;
frames_ctx->width = avctx->coded_width;
frames_ctx->height = avctx->coded_height;
frames_ctx->sw_format = sw_desc->comp[0].depth > 8 ?
AV_PIX_FMT_P010 : AV_PIX_FMT_NV12;
frames_ctx->initial_pool_size = dpb_size;
return 0;
}
| false | FFmpeg | 3e0e1634585b1a26b7d753aa42c7f350636927ae | int ff_nvdec_frame_params(AVCodecContext *avctx,
AVBufferRef *hw_frames_ctx,
int dpb_size)
{
AVHWFramesContext *frames_ctx = (AVHWFramesContext*)hw_frames_ctx->data;
const AVPixFmtDescriptor *sw_desc;
int cuvid_codec_type, cuvid_chroma_format;
sw_desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
if (!sw_desc)
return AVERROR_BUG;
cuvid_codec_type = map_avcodec_id(avctx->codec_id);
if (cuvid_codec_type < 0) {
av_log(avctx, AV_LOG_ERROR, "Unsupported codec ID\n");
return AVERROR_BUG;
}
cuvid_chroma_format = map_chroma_format(avctx->sw_pix_fmt);
if (cuvid_chroma_format < 0) {
av_log(avctx, AV_LOG_VERBOSE, "Unsupported chroma format\n");
return AVERROR(EINVAL);
}
if (avctx->thread_type & FF_THREAD_FRAME)
dpb_size += avctx->thread_count;
frames_ctx->format = AV_PIX_FMT_CUDA;
frames_ctx->width = avctx->coded_width;
frames_ctx->height = avctx->coded_height;
frames_ctx->sw_format = sw_desc->comp[0].depth > 8 ?
AV_PIX_FMT_P010 : AV_PIX_FMT_NV12;
frames_ctx->initial_pool_size = dpb_size;
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVCodecContext *VAR_0,
AVBufferRef *VAR_1,
int VAR_2)
{
AVHWFramesContext *frames_ctx = (AVHWFramesContext*)VAR_1->data;
const AVPixFmtDescriptor *VAR_3;
int VAR_4, VAR_5;
VAR_3 = av_pix_fmt_desc_get(VAR_0->sw_pix_fmt);
if (!VAR_3)
return AVERROR_BUG;
VAR_4 = map_avcodec_id(VAR_0->codec_id);
if (VAR_4 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Unsupported codec ID\n");
return AVERROR_BUG;
}
VAR_5 = map_chroma_format(VAR_0->sw_pix_fmt);
if (VAR_5 < 0) {
av_log(VAR_0, AV_LOG_VERBOSE, "Unsupported chroma format\n");
return AVERROR(EINVAL);
}
if (VAR_0->thread_type & FF_THREAD_FRAME)
VAR_2 += VAR_0->thread_count;
frames_ctx->format = AV_PIX_FMT_CUDA;
frames_ctx->width = VAR_0->coded_width;
frames_ctx->height = VAR_0->coded_height;
frames_ctx->sw_format = VAR_3->comp[0].depth > 8 ?
AV_PIX_FMT_P010 : AV_PIX_FMT_NV12;
frames_ctx->initial_pool_size = VAR_2;
return 0;
}
| [
"int FUNC_0(AVCodecContext *VAR_0,\nAVBufferRef *VAR_1,\nint VAR_2)\n{",
"AVHWFramesContext *frames_ctx = (AVHWFramesContext*)VAR_1->data;",
"const AVPixFmtDescriptor *VAR_3;",
"int VAR_4, VAR_5;",
"VAR_3 = av_pix_fmt_desc_get(VAR_0->sw_pix_fmt);",
"if (!VAR_3)\nreturn AVERROR_BUG;",
"VAR_4 = map_avcode... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19,
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49,
51
],
[
55
... |
9,448 | static const char *ass_split_section(ASSSplitContext *ctx, const char *buf)
{
const ASSSection *section = &ass_sections[ctx->current_section];
int *number = &ctx->field_number[ctx->current_section];
int *order = ctx->field_order[ctx->current_section];
int *tmp, i, len;
while (buf && *buf) {
if (buf[0] == '[') {
ctx->current_section = -1;
break;
}
if (buf[0] == ';' || (buf[0] == '!' && buf[1] == ':')) {
/* skip comments */
} else if (section->format_header && !order) {
len = strlen(section->format_header);
if (strncmp(buf, section->format_header, len) || buf[len] != ':')
return NULL;
buf += len + 1;
while (!is_eol(*buf)) {
buf = skip_space(buf);
len = strcspn(buf, ", \r\n");
if (!(tmp = av_realloc(order, (*number + 1) * sizeof(*order))))
return NULL;
order = tmp;
order[*number] = -1;
for (i=0; section->fields[i].name; i++)
if (!strncmp(buf, section->fields[i].name, len)) {
order[*number] = i;
break;
}
(*number)++;
buf = skip_space(buf + len + (buf[len] == ','));
}
ctx->field_order[ctx->current_section] = order;
} else if (section->fields_header) {
len = strlen(section->fields_header);
if (!strncmp(buf, section->fields_header, len) && buf[len] == ':') {
uint8_t *ptr, *struct_ptr = realloc_section_array(ctx);
if (!struct_ptr) return NULL;
buf += len + 1;
for (i=0; !is_eol(*buf) && i < *number; i++) {
int last = i == *number - 1;
buf = skip_space(buf);
len = strcspn(buf, last ? "\r\n" : ",\r\n");
if (order[i] >= 0) {
ASSFieldType type = section->fields[order[i]].type;
ptr = struct_ptr + section->fields[order[i]].offset;
convert_func[type](ptr, buf, len);
}
buf = skip_space(buf + len + !last);
}
}
} else {
len = strcspn(buf, ":\r\n");
if (buf[len] == ':') {
for (i=0; section->fields[i].name; i++)
if (!strncmp(buf, section->fields[i].name, len)) {
ASSFieldType type = section->fields[i].type;
uint8_t *ptr = (uint8_t *)&ctx->ass + section->offset;
ptr += section->fields[i].offset;
buf = skip_space(buf + len + 1);
convert_func[type](ptr, buf, strcspn(buf, "\r\n"));
break;
}
}
}
buf += strcspn(buf, "\n");
buf += !!*buf;
}
return buf;
}
| false | FFmpeg | 97b1ba696baa1bb87415bad244533ac2beaf3568 | static const char *ass_split_section(ASSSplitContext *ctx, const char *buf)
{
const ASSSection *section = &ass_sections[ctx->current_section];
int *number = &ctx->field_number[ctx->current_section];
int *order = ctx->field_order[ctx->current_section];
int *tmp, i, len;
while (buf && *buf) {
if (buf[0] == '[') {
ctx->current_section = -1;
break;
}
if (buf[0] == ';' || (buf[0] == '!' && buf[1] == ':')) {
} else if (section->format_header && !order) {
len = strlen(section->format_header);
if (strncmp(buf, section->format_header, len) || buf[len] != ':')
return NULL;
buf += len + 1;
while (!is_eol(*buf)) {
buf = skip_space(buf);
len = strcspn(buf, ", \r\n");
if (!(tmp = av_realloc(order, (*number + 1) * sizeof(*order))))
return NULL;
order = tmp;
order[*number] = -1;
for (i=0; section->fields[i].name; i++)
if (!strncmp(buf, section->fields[i].name, len)) {
order[*number] = i;
break;
}
(*number)++;
buf = skip_space(buf + len + (buf[len] == ','));
}
ctx->field_order[ctx->current_section] = order;
} else if (section->fields_header) {
len = strlen(section->fields_header);
if (!strncmp(buf, section->fields_header, len) && buf[len] == ':') {
uint8_t *ptr, *struct_ptr = realloc_section_array(ctx);
if (!struct_ptr) return NULL;
buf += len + 1;
for (i=0; !is_eol(*buf) && i < *number; i++) {
int last = i == *number - 1;
buf = skip_space(buf);
len = strcspn(buf, last ? "\r\n" : ",\r\n");
if (order[i] >= 0) {
ASSFieldType type = section->fields[order[i]].type;
ptr = struct_ptr + section->fields[order[i]].offset;
convert_func[type](ptr, buf, len);
}
buf = skip_space(buf + len + !last);
}
}
} else {
len = strcspn(buf, ":\r\n");
if (buf[len] == ':') {
for (i=0; section->fields[i].name; i++)
if (!strncmp(buf, section->fields[i].name, len)) {
ASSFieldType type = section->fields[i].type;
uint8_t *ptr = (uint8_t *)&ctx->ass + section->offset;
ptr += section->fields[i].offset;
buf = skip_space(buf + len + 1);
convert_func[type](ptr, buf, strcspn(buf, "\r\n"));
break;
}
}
}
buf += strcspn(buf, "\n");
buf += !!*buf;
}
return buf;
}
| {
"code": [],
"line_no": []
} | static const char *FUNC_0(ASSSplitContext *VAR_0, const char *VAR_1)
{
const ASSSection *VAR_2 = &ass_sections[VAR_0->current_section];
int *VAR_3 = &VAR_0->field_number[VAR_0->current_section];
int *VAR_4 = VAR_0->field_order[VAR_0->current_section];
int *VAR_5, VAR_6, VAR_7;
while (VAR_1 && *VAR_1) {
if (VAR_1[0] == '[') {
VAR_0->current_section = -1;
break;
}
if (VAR_1[0] == ';' || (VAR_1[0] == '!' && VAR_1[1] == ':')) {
} else if (VAR_2->format_header && !VAR_4) {
VAR_7 = strlen(VAR_2->format_header);
if (strncmp(VAR_1, VAR_2->format_header, VAR_7) || VAR_1[VAR_7] != ':')
return NULL;
VAR_1 += VAR_7 + 1;
while (!is_eol(*VAR_1)) {
VAR_1 = skip_space(VAR_1);
VAR_7 = strcspn(VAR_1, ", \r\n");
if (!(VAR_5 = av_realloc(VAR_4, (*VAR_3 + 1) * sizeof(*VAR_4))))
return NULL;
VAR_4 = VAR_5;
VAR_4[*VAR_3] = -1;
for (VAR_6=0; VAR_2->fields[VAR_6].name; VAR_6++)
if (!strncmp(VAR_1, VAR_2->fields[VAR_6].name, VAR_7)) {
VAR_4[*VAR_3] = VAR_6;
break;
}
(*VAR_3)++;
VAR_1 = skip_space(VAR_1 + VAR_7 + (VAR_1[VAR_7] == ','));
}
VAR_0->field_order[VAR_0->current_section] = VAR_4;
} else if (VAR_2->fields_header) {
VAR_7 = strlen(VAR_2->fields_header);
if (!strncmp(VAR_1, VAR_2->fields_header, VAR_7) && VAR_1[VAR_7] == ':') {
uint8_t *ptr, *struct_ptr = realloc_section_array(VAR_0);
if (!struct_ptr) return NULL;
VAR_1 += VAR_7 + 1;
for (VAR_6=0; !is_eol(*VAR_1) && VAR_6 < *VAR_3; VAR_6++) {
int VAR_8 = VAR_6 == *VAR_3 - 1;
VAR_1 = skip_space(VAR_1);
VAR_7 = strcspn(VAR_1, VAR_8 ? "\r\n" : ",\r\n");
if (VAR_4[VAR_6] >= 0) {
ASSFieldType type = VAR_2->fields[VAR_4[VAR_6]].type;
ptr = struct_ptr + VAR_2->fields[VAR_4[VAR_6]].offset;
convert_func[type](ptr, VAR_1, VAR_7);
}
VAR_1 = skip_space(VAR_1 + VAR_7 + !VAR_8);
}
}
} else {
VAR_7 = strcspn(VAR_1, ":\r\n");
if (VAR_1[VAR_7] == ':') {
for (VAR_6=0; VAR_2->fields[VAR_6].name; VAR_6++)
if (!strncmp(VAR_1, VAR_2->fields[VAR_6].name, VAR_7)) {
ASSFieldType type = VAR_2->fields[VAR_6].type;
uint8_t *ptr = (uint8_t *)&VAR_0->ass + VAR_2->offset;
ptr += VAR_2->fields[VAR_6].offset;
VAR_1 = skip_space(VAR_1 + VAR_7 + 1);
convert_func[type](ptr, VAR_1, strcspn(VAR_1, "\r\n"));
break;
}
}
}
VAR_1 += strcspn(VAR_1, "\n");
VAR_1 += !!*VAR_1;
}
return VAR_1;
}
| [
"static const char *FUNC_0(ASSSplitContext *VAR_0, const char *VAR_1)\n{",
"const ASSSection *VAR_2 = &ass_sections[VAR_0->current_section];",
"int *VAR_3 = &VAR_0->field_number[VAR_0->current_section];",
"int *VAR_4 = VAR_0->field_order[VAR_0->current_section];",
"int *VAR_5, VAR_6, VAR_7;",
"while (VAR_... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
... |
9,449 | void ff_put_h264_qpel16_mc10_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_hz_qrt_16w_msa(src - 2, stride, dst, stride, 16, 0);
}
| false | FFmpeg | b5da07d4340a8e8e40dcd1900977a76ff31fbb84 | void ff_put_h264_qpel16_mc10_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_hz_qrt_16w_msa(src - 2, stride, dst, stride, 16, 0);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,
ptrdiff_t VAR_2)
{
avc_luma_hz_qrt_16w_msa(VAR_1 - 2, VAR_2, VAR_0, VAR_2, 16, 0);
}
| [
"void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,\nptrdiff_t VAR_2)\n{",
"avc_luma_hz_qrt_16w_msa(VAR_1 - 2, VAR_2, VAR_0, VAR_2, 16, 0);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
]
] |
9,450 | static void do_memory_save(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
FILE *f;
uint32_t size = qdict_get_int(qdict, "size");
const char *filename = qdict_get_str(qdict, "filename");
target_long addr = qdict_get_int(qdict, "val");
uint32_t l;
CPUState *env;
uint8_t buf[1024];
env = mon_get_cpu();
if (!env)
return;
f = fopen(filename, "wb");
if (!f) {
monitor_printf(mon, "could not open '%s'\n", filename);
return;
}
while (size != 0) {
l = sizeof(buf);
if (l > size)
l = size;
cpu_memory_rw_debug(env, addr, buf, l, 0);
fwrite(buf, 1, l, f);
addr += l;
size -= l;
}
fclose(f);
}
| true | qemu | 09b9418c6d085a0728372aa760ebd10128a020b1 | static void do_memory_save(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
FILE *f;
uint32_t size = qdict_get_int(qdict, "size");
const char *filename = qdict_get_str(qdict, "filename");
target_long addr = qdict_get_int(qdict, "val");
uint32_t l;
CPUState *env;
uint8_t buf[1024];
env = mon_get_cpu();
if (!env)
return;
f = fopen(filename, "wb");
if (!f) {
monitor_printf(mon, "could not open '%s'\n", filename);
return;
}
while (size != 0) {
l = sizeof(buf);
if (l > size)
l = size;
cpu_memory_rw_debug(env, addr, buf, l, 0);
fwrite(buf, 1, l, f);
addr += l;
size -= l;
}
fclose(f);
}
| {
"code": [
" if (!env)",
" if (!env)",
" if (!env)",
" if (!env)",
" if (!env)",
" if (!env)",
" if (!env)",
" if (!env)",
" if (!env)",
" if (!env)",
" if (!env)",
" if (!env)",
" if (!env)"
],
"line_no": [
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23
]
} | static void FUNC_0(Monitor *VAR_0, const QDict *VAR_1, QObject **VAR_2)
{
FILE *f;
uint32_t size = qdict_get_int(VAR_1, "size");
const char *VAR_3 = qdict_get_str(VAR_1, "VAR_3");
target_long addr = qdict_get_int(VAR_1, "val");
uint32_t l;
CPUState *env;
uint8_t buf[1024];
env = mon_get_cpu();
if (!env)
return;
f = fopen(VAR_3, "wb");
if (!f) {
monitor_printf(VAR_0, "could not open '%s'\n", VAR_3);
return;
}
while (size != 0) {
l = sizeof(buf);
if (l > size)
l = size;
cpu_memory_rw_debug(env, addr, buf, l, 0);
fwrite(buf, 1, l, f);
addr += l;
size -= l;
}
fclose(f);
}
| [
"static void FUNC_0(Monitor *VAR_0, const QDict *VAR_1, QObject **VAR_2)\n{",
"FILE *f;",
"uint32_t size = qdict_get_int(VAR_1, \"size\");",
"const char *VAR_3 = qdict_get_str(VAR_1, \"VAR_3\");",
"target_long addr = qdict_get_int(VAR_1, \"val\");",
"uint32_t l;",
"CPUState *env;",
"uint8_t buf[1024];... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23,
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
... |
9,451 | static uint32_t virtio_read_config(PCIDevice *pci_dev,
uint32_t address, int len)
{
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
struct virtio_pci_cfg_cap *cfg;
if (proxy->config_cap &&
ranges_overlap(address, len, proxy->config_cap + offsetof(struct virtio_pci_cfg_cap,
pci_cfg_data),
sizeof cfg->pci_cfg_data)) {
uint32_t off;
uint32_t len;
cfg = (void *)(proxy->pci_dev.config + proxy->config_cap);
off = le32_to_cpu(cfg->cap.offset);
len = le32_to_cpu(cfg->cap.length);
if (len <= sizeof cfg->pci_cfg_data) {
virtio_address_space_read(&proxy->modern_as, off,
cfg->pci_cfg_data, len);
}
}
return pci_default_read_config(pci_dev, address, len);
}
| true | qemu | 2a6391232fa58f32469fb61d55343eff32a91083 | static uint32_t virtio_read_config(PCIDevice *pci_dev,
uint32_t address, int len)
{
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
struct virtio_pci_cfg_cap *cfg;
if (proxy->config_cap &&
ranges_overlap(address, len, proxy->config_cap + offsetof(struct virtio_pci_cfg_cap,
pci_cfg_data),
sizeof cfg->pci_cfg_data)) {
uint32_t off;
uint32_t len;
cfg = (void *)(proxy->pci_dev.config + proxy->config_cap);
off = le32_to_cpu(cfg->cap.offset);
len = le32_to_cpu(cfg->cap.length);
if (len <= sizeof cfg->pci_cfg_data) {
virtio_address_space_read(&proxy->modern_as, off,
cfg->pci_cfg_data, len);
}
}
return pci_default_read_config(pci_dev, address, len);
}
| {
"code": [
" if (len <= sizeof cfg->pci_cfg_data) {",
" if (len <= sizeof cfg->pci_cfg_data) {"
],
"line_no": [
35,
35
]
} | static uint32_t FUNC_0(PCIDevice *pci_dev,
uint32_t address, int len)
{
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
struct virtio_pci_cfg_cap *VAR_0;
if (proxy->config_cap &&
ranges_overlap(address, len, proxy->config_cap + offsetof(struct virtio_pci_cfg_cap,
pci_cfg_data),
sizeof VAR_0->pci_cfg_data)) {
uint32_t off;
uint32_t len;
VAR_0 = (void *)(proxy->pci_dev.config + proxy->config_cap);
off = le32_to_cpu(VAR_0->cap.offset);
len = le32_to_cpu(VAR_0->cap.length);
if (len <= sizeof VAR_0->pci_cfg_data) {
virtio_address_space_read(&proxy->modern_as, off,
VAR_0->pci_cfg_data, len);
}
}
return pci_default_read_config(pci_dev, address, len);
}
| [
"static uint32_t FUNC_0(PCIDevice *pci_dev,\nuint32_t address, int len)\n{",
"VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);",
"struct virtio_pci_cfg_cap *VAR_0;",
"if (proxy->config_cap &&\nranges_overlap(address, len, proxy->config_cap + offsetof(struct virtio_pci_cfg_cap,\npci_cfg_dat... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13,
15,
17,
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
47
],
[
49
]
] |
9,452 | static struct omap_mcbsp_s *omap_mcbsp_init(MemoryRegion *system_memory,
hwaddr base,
qemu_irq txirq, qemu_irq rxirq,
qemu_irq *dma, omap_clk clk)
{
struct omap_mcbsp_s *s = (struct omap_mcbsp_s *)
g_malloc0(sizeof(struct omap_mcbsp_s));
s->txirq = txirq;
s->rxirq = rxirq;
s->txdrq = dma[0];
s->rxdrq = dma[1];
s->sink_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, omap_mcbsp_sink_tick, s);
s->source_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, omap_mcbsp_source_tick, s);
omap_mcbsp_reset(s);
memory_region_init_io(&s->iomem, NULL, &omap_mcbsp_ops, s, "omap-mcbsp", 0x800);
memory_region_add_subregion(system_memory, base, &s->iomem);
return s;
}
| true | qemu | b45c03f585ea9bb1af76c73e82195418c294919d | static struct omap_mcbsp_s *omap_mcbsp_init(MemoryRegion *system_memory,
hwaddr base,
qemu_irq txirq, qemu_irq rxirq,
qemu_irq *dma, omap_clk clk)
{
struct omap_mcbsp_s *s = (struct omap_mcbsp_s *)
g_malloc0(sizeof(struct omap_mcbsp_s));
s->txirq = txirq;
s->rxirq = rxirq;
s->txdrq = dma[0];
s->rxdrq = dma[1];
s->sink_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, omap_mcbsp_sink_tick, s);
s->source_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, omap_mcbsp_source_tick, s);
omap_mcbsp_reset(s);
memory_region_init_io(&s->iomem, NULL, &omap_mcbsp_ops, s, "omap-mcbsp", 0x800);
memory_region_add_subregion(system_memory, base, &s->iomem);
return s;
}
| {
"code": [
" struct omap_mcbsp_s *s = (struct omap_mcbsp_s *)",
" g_malloc0(sizeof(struct omap_mcbsp_s));"
],
"line_no": [
11,
13
]
} | static struct omap_mcbsp_s *FUNC_0(MemoryRegion *VAR_0,
hwaddr VAR_1,
qemu_irq VAR_2, qemu_irq VAR_3,
qemu_irq *VAR_4, omap_clk VAR_5)
{
struct omap_mcbsp_s *VAR_6 = (struct omap_mcbsp_s *)
g_malloc0(sizeof(struct omap_mcbsp_s));
VAR_6->VAR_2 = VAR_2;
VAR_6->VAR_3 = VAR_3;
VAR_6->txdrq = VAR_4[0];
VAR_6->rxdrq = VAR_4[1];
VAR_6->sink_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, omap_mcbsp_sink_tick, VAR_6);
VAR_6->source_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, omap_mcbsp_source_tick, VAR_6);
omap_mcbsp_reset(VAR_6);
memory_region_init_io(&VAR_6->iomem, NULL, &omap_mcbsp_ops, VAR_6, "omap-mcbsp", 0x800);
memory_region_add_subregion(VAR_0, VAR_1, &VAR_6->iomem);
return VAR_6;
}
| [
"static struct omap_mcbsp_s *FUNC_0(MemoryRegion *VAR_0,\nhwaddr VAR_1,\nqemu_irq VAR_2, qemu_irq VAR_3,\nqemu_irq *VAR_4, omap_clk VAR_5)\n{",
"struct omap_mcbsp_s *VAR_6 = (struct omap_mcbsp_s *)\ng_malloc0(sizeof(struct omap_mcbsp_s));",
"VAR_6->VAR_2 = VAR_2;",
"VAR_6->VAR_3 = VAR_3;",
"VAR_6->txdrq = V... | [
0,
1,
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
],
[
33
],
[
35
],
[
39
],
[
41
]
] |
9,453 | FWCfgState *pc_memory_init(MachineState *machine,
MemoryRegion *system_memory,
ram_addr_t below_4g_mem_size,
ram_addr_t above_4g_mem_size,
MemoryRegion *rom_memory,
MemoryRegion **ram_memory,
PcGuestInfo *guest_info)
{
int linux_boot, i;
MemoryRegion *ram, *option_rom_mr;
MemoryRegion *ram_below_4g, *ram_above_4g;
FWCfgState *fw_cfg;
PCMachineState *pcms = PC_MACHINE(machine);
assert(machine->ram_size == below_4g_mem_size + above_4g_mem_size);
linux_boot = (machine->kernel_filename != NULL);
/* Allocate RAM. We allocate it as a single memory region and use
* aliases to address portions of it, mostly for backwards compatibility
* with older qemus that used qemu_ram_alloc().
*/
ram = g_malloc(sizeof(*ram));
memory_region_allocate_system_memory(ram, NULL, "pc.ram",
machine->ram_size);
*ram_memory = ram;
ram_below_4g = g_malloc(sizeof(*ram_below_4g));
memory_region_init_alias(ram_below_4g, NULL, "ram-below-4g", ram,
0, below_4g_mem_size);
memory_region_add_subregion(system_memory, 0, ram_below_4g);
e820_add_entry(0, below_4g_mem_size, E820_RAM);
if (above_4g_mem_size > 0) {
ram_above_4g = g_malloc(sizeof(*ram_above_4g));
memory_region_init_alias(ram_above_4g, NULL, "ram-above-4g", ram,
below_4g_mem_size, above_4g_mem_size);
memory_region_add_subregion(system_memory, 0x100000000ULL,
ram_above_4g);
e820_add_entry(0x100000000ULL, above_4g_mem_size, E820_RAM);
if (!guest_info->has_reserved_memory &&
(machine->ram_slots ||
(machine->maxram_size > machine->ram_size))) {
MachineClass *mc = MACHINE_GET_CLASS(machine);
error_report("\"-memory 'slots|maxmem'\" is not supported by: %s",
mc->name);
/* initialize hotplug memory address space */
if (guest_info->has_reserved_memory &&
(machine->ram_size < machine->maxram_size)) {
ram_addr_t hotplug_mem_size =
machine->maxram_size - machine->ram_size;
if (machine->ram_slots > ACPI_MAX_RAM_SLOTS) {
error_report("unsupported amount of memory slots: %"PRIu64,
machine->ram_slots);
pcms->hotplug_memory_base =
ROUND_UP(0x100000000ULL + above_4g_mem_size, 1ULL << 30);
if (pcms->enforce_aligned_dimm) {
/* size hotplug region assuming 1G page max alignment per slot */
hotplug_mem_size += (1ULL << 30) * machine->ram_slots;
if ((pcms->hotplug_memory_base + hotplug_mem_size) <
hotplug_mem_size) {
error_report("unsupported amount of maximum memory: " RAM_ADDR_FMT,
machine->maxram_size);
memory_region_init(&pcms->hotplug_memory, OBJECT(pcms),
"hotplug-memory", hotplug_mem_size);
memory_region_add_subregion(system_memory, pcms->hotplug_memory_base,
&pcms->hotplug_memory);
/* Initialize PC system firmware */
pc_system_firmware_init(rom_memory, guest_info->isapc_ram_fw);
option_rom_mr = g_malloc(sizeof(*option_rom_mr));
memory_region_init_ram(option_rom_mr, NULL, "pc.rom", PC_ROM_SIZE,
&error_abort);
vmstate_register_ram_global(option_rom_mr);
memory_region_add_subregion_overlap(rom_memory,
PC_ROM_MIN_VGA,
option_rom_mr,
1);
fw_cfg = bochs_bios_init();
rom_set_fw(fw_cfg);
if (guest_info->has_reserved_memory && pcms->hotplug_memory_base) {
uint64_t *val = g_malloc(sizeof(*val));
*val = cpu_to_le64(ROUND_UP(pcms->hotplug_memory_base, 0x1ULL << 30));
fw_cfg_add_file(fw_cfg, "etc/reserved-memory-end", val, sizeof(*val));
if (linux_boot) {
load_linux(fw_cfg, machine->kernel_filename, machine->initrd_filename,
machine->kernel_cmdline, below_4g_mem_size);
for (i = 0; i < nb_option_roms; i++) {
rom_add_option(option_rom[i].name, option_rom[i].bootindex);
guest_info->fw_cfg = fw_cfg;
return fw_cfg; | true | qemu | f2c385220598523c8b9fefbfff1a6754cfd8232a | FWCfgState *pc_memory_init(MachineState *machine,
MemoryRegion *system_memory,
ram_addr_t below_4g_mem_size,
ram_addr_t above_4g_mem_size,
MemoryRegion *rom_memory,
MemoryRegion **ram_memory,
PcGuestInfo *guest_info)
{
int linux_boot, i;
MemoryRegion *ram, *option_rom_mr;
MemoryRegion *ram_below_4g, *ram_above_4g;
FWCfgState *fw_cfg;
PCMachineState *pcms = PC_MACHINE(machine);
assert(machine->ram_size == below_4g_mem_size + above_4g_mem_size);
linux_boot = (machine->kernel_filename != NULL);
ram = g_malloc(sizeof(*ram));
memory_region_allocate_system_memory(ram, NULL, "pc.ram",
machine->ram_size);
*ram_memory = ram;
ram_below_4g = g_malloc(sizeof(*ram_below_4g));
memory_region_init_alias(ram_below_4g, NULL, "ram-below-4g", ram,
0, below_4g_mem_size);
memory_region_add_subregion(system_memory, 0, ram_below_4g);
e820_add_entry(0, below_4g_mem_size, E820_RAM);
if (above_4g_mem_size > 0) {
ram_above_4g = g_malloc(sizeof(*ram_above_4g));
memory_region_init_alias(ram_above_4g, NULL, "ram-above-4g", ram,
below_4g_mem_size, above_4g_mem_size);
memory_region_add_subregion(system_memory, 0x100000000ULL,
ram_above_4g);
e820_add_entry(0x100000000ULL, above_4g_mem_size, E820_RAM);
if (!guest_info->has_reserved_memory &&
(machine->ram_slots ||
(machine->maxram_size > machine->ram_size))) {
MachineClass *mc = MACHINE_GET_CLASS(machine);
error_report("\"-memory 'slots|maxmem'\" is not supported by: %s",
mc->name);
if (guest_info->has_reserved_memory &&
(machine->ram_size < machine->maxram_size)) {
ram_addr_t hotplug_mem_size =
machine->maxram_size - machine->ram_size;
if (machine->ram_slots > ACPI_MAX_RAM_SLOTS) {
error_report("unsupported amount of memory slots: %"PRIu64,
machine->ram_slots);
pcms->hotplug_memory_base =
ROUND_UP(0x100000000ULL + above_4g_mem_size, 1ULL << 30);
if (pcms->enforce_aligned_dimm) {
hotplug_mem_size += (1ULL << 30) * machine->ram_slots;
if ((pcms->hotplug_memory_base + hotplug_mem_size) <
hotplug_mem_size) {
error_report("unsupported amount of maximum memory: " RAM_ADDR_FMT,
machine->maxram_size);
memory_region_init(&pcms->hotplug_memory, OBJECT(pcms),
"hotplug-memory", hotplug_mem_size);
memory_region_add_subregion(system_memory, pcms->hotplug_memory_base,
&pcms->hotplug_memory);
pc_system_firmware_init(rom_memory, guest_info->isapc_ram_fw);
option_rom_mr = g_malloc(sizeof(*option_rom_mr));
memory_region_init_ram(option_rom_mr, NULL, "pc.rom", PC_ROM_SIZE,
&error_abort);
vmstate_register_ram_global(option_rom_mr);
memory_region_add_subregion_overlap(rom_memory,
PC_ROM_MIN_VGA,
option_rom_mr,
1);
fw_cfg = bochs_bios_init();
rom_set_fw(fw_cfg);
if (guest_info->has_reserved_memory && pcms->hotplug_memory_base) {
uint64_t *val = g_malloc(sizeof(*val));
*val = cpu_to_le64(ROUND_UP(pcms->hotplug_memory_base, 0x1ULL << 30));
fw_cfg_add_file(fw_cfg, "etc/reserved-memory-end", val, sizeof(*val));
if (linux_boot) {
load_linux(fw_cfg, machine->kernel_filename, machine->initrd_filename,
machine->kernel_cmdline, below_4g_mem_size);
for (i = 0; i < nb_option_roms; i++) {
rom_add_option(option_rom[i].name, option_rom[i].bootindex);
guest_info->fw_cfg = fw_cfg;
return fw_cfg; | {
"code": [],
"line_no": []
} | FWCfgState *FUNC_0(MachineState *machine,
MemoryRegion *system_memory,
ram_addr_t below_4g_mem_size,
ram_addr_t above_4g_mem_size,
MemoryRegion *rom_memory,
MemoryRegion **ram_memory,
PcGuestInfo *guest_info)
{
int VAR_0, VAR_1;
MemoryRegion *ram, *option_rom_mr;
MemoryRegion *ram_below_4g, *ram_above_4g;
FWCfgState *fw_cfg;
PCMachineState *pcms = PC_MACHINE(machine);
assert(machine->ram_size == below_4g_mem_size + above_4g_mem_size);
VAR_0 = (machine->kernel_filename != NULL);
ram = g_malloc(sizeof(*ram));
memory_region_allocate_system_memory(ram, NULL, "pc.ram",
machine->ram_size);
*ram_memory = ram;
ram_below_4g = g_malloc(sizeof(*ram_below_4g));
memory_region_init_alias(ram_below_4g, NULL, "ram-below-4g", ram,
0, below_4g_mem_size);
memory_region_add_subregion(system_memory, 0, ram_below_4g);
e820_add_entry(0, below_4g_mem_size, E820_RAM);
if (above_4g_mem_size > 0) {
ram_above_4g = g_malloc(sizeof(*ram_above_4g));
memory_region_init_alias(ram_above_4g, NULL, "ram-above-4g", ram,
below_4g_mem_size, above_4g_mem_size);
memory_region_add_subregion(system_memory, 0x100000000ULL,
ram_above_4g);
e820_add_entry(0x100000000ULL, above_4g_mem_size, E820_RAM);
if (!guest_info->has_reserved_memory &&
(machine->ram_slots ||
(machine->maxram_size > machine->ram_size))) {
MachineClass *mc = MACHINE_GET_CLASS(machine);
error_report("\"-memory 'slots|maxmem'\" is not supported by: %s",
mc->name);
if (guest_info->has_reserved_memory &&
(machine->ram_size < machine->maxram_size)) {
ram_addr_t hotplug_mem_size =
machine->maxram_size - machine->ram_size;
if (machine->ram_slots > ACPI_MAX_RAM_SLOTS) {
error_report("unsupported amount of memory slots: %"PRIu64,
machine->ram_slots);
pcms->hotplug_memory_base =
ROUND_UP(0x100000000ULL + above_4g_mem_size, 1ULL << 30);
if (pcms->enforce_aligned_dimm) {
hotplug_mem_size += (1ULL << 30) * machine->ram_slots;
if ((pcms->hotplug_memory_base + hotplug_mem_size) <
hotplug_mem_size) {
error_report("unsupported amount of maximum memory: " RAM_ADDR_FMT,
machine->maxram_size);
memory_region_init(&pcms->hotplug_memory, OBJECT(pcms),
"hotplug-memory", hotplug_mem_size);
memory_region_add_subregion(system_memory, pcms->hotplug_memory_base,
&pcms->hotplug_memory);
pc_system_firmware_init(rom_memory, guest_info->isapc_ram_fw);
option_rom_mr = g_malloc(sizeof(*option_rom_mr));
memory_region_init_ram(option_rom_mr, NULL, "pc.rom", PC_ROM_SIZE,
&error_abort);
vmstate_register_ram_global(option_rom_mr);
memory_region_add_subregion_overlap(rom_memory,
PC_ROM_MIN_VGA,
option_rom_mr,
1);
fw_cfg = bochs_bios_init();
rom_set_fw(fw_cfg);
if (guest_info->has_reserved_memory && pcms->hotplug_memory_base) {
uint64_t *val = g_malloc(sizeof(*val));
*val = cpu_to_le64(ROUND_UP(pcms->hotplug_memory_base, 0x1ULL << 30));
fw_cfg_add_file(fw_cfg, "etc/reserved-memory-end", val, sizeof(*val));
if (VAR_0) {
load_linux(fw_cfg, machine->kernel_filename, machine->initrd_filename,
machine->kernel_cmdline, below_4g_mem_size);
for (VAR_1 = 0; VAR_1 < nb_option_roms; VAR_1++) {
rom_add_option(option_rom[VAR_1].name, option_rom[VAR_1].bootindex);
guest_info->fw_cfg = fw_cfg;
return fw_cfg; | [
"FWCfgState *FUNC_0(MachineState *machine,\nMemoryRegion *system_memory,\nram_addr_t below_4g_mem_size,\nram_addr_t above_4g_mem_size,\nMemoryRegion *rom_memory,\nMemoryRegion **ram_memory,\nPcGuestInfo *guest_info)\n{",
"int VAR_0, VAR_1;",
"MemoryRegion *ram, *option_rom_mr;",
"MemoryRegion *ram_below_4g, *... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2,
3,
4,
5,
6,
7,
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
20
],
[
21,
22
],
[
23
],
[
24
],
[
25,
26
],
[
27
],
[
28
],
[
29
],... |
9,454 | static MegasasCmd *megasas_next_frame(MegasasState *s,
hwaddr frame)
{
MegasasCmd *cmd = NULL;
int num = 0, index;
cmd = megasas_lookup_frame(s, frame);
if (cmd) {
trace_megasas_qf_found(cmd->index, cmd->pa);
return cmd;
}
index = s->reply_queue_head;
num = 0;
while (num < s->fw_cmds) {
if (!s->frames[index].pa) {
cmd = &s->frames[index];
break;
}
index = megasas_next_index(s, index, s->fw_cmds);
num++;
}
if (!cmd) {
trace_megasas_qf_failed(frame);
}
trace_megasas_qf_new(index, cmd);
return cmd;
}
| true | qemu | 6df5718bd3ec56225c44cf96440c723c1b611b87 | static MegasasCmd *megasas_next_frame(MegasasState *s,
hwaddr frame)
{
MegasasCmd *cmd = NULL;
int num = 0, index;
cmd = megasas_lookup_frame(s, frame);
if (cmd) {
trace_megasas_qf_found(cmd->index, cmd->pa);
return cmd;
}
index = s->reply_queue_head;
num = 0;
while (num < s->fw_cmds) {
if (!s->frames[index].pa) {
cmd = &s->frames[index];
break;
}
index = megasas_next_index(s, index, s->fw_cmds);
num++;
}
if (!cmd) {
trace_megasas_qf_failed(frame);
}
trace_megasas_qf_new(index, cmd);
return cmd;
}
| {
"code": [
"static MegasasCmd *megasas_next_frame(MegasasState *s,",
" hwaddr frame)",
" MegasasCmd *cmd = NULL;",
" int num = 0, index;",
" cmd = megasas_lookup_frame(s, frame);",
" if (cmd) {",
" trace_megasas_qf_found(cmd->index, cmd->pa);",
" return cmd;",
" index = s->reply_queue_head;",
" num = 0;",
" while (num < s->fw_cmds) {",
" if (!s->frames[index].pa) {",
" cmd = &s->frames[index];",
" break;",
" index = megasas_next_index(s, index, s->fw_cmds);",
" num++;",
" if (!cmd) {",
" trace_megasas_qf_failed(frame);",
" trace_megasas_qf_new(index, cmd);",
" return cmd;",
" if (!cmd) {"
],
"line_no": [
1,
3,
7,
9,
13,
15,
17,
19,
23,
25,
27,
29,
31,
33,
37,
39,
43,
45,
49,
51,
43
]
} | static MegasasCmd *FUNC_0(MegasasState *s,
hwaddr frame)
{
MegasasCmd *cmd = NULL;
int VAR_0 = 0, VAR_1;
cmd = megasas_lookup_frame(s, frame);
if (cmd) {
trace_megasas_qf_found(cmd->VAR_1, cmd->pa);
return cmd;
}
VAR_1 = s->reply_queue_head;
VAR_0 = 0;
while (VAR_0 < s->fw_cmds) {
if (!s->frames[VAR_1].pa) {
cmd = &s->frames[VAR_1];
break;
}
VAR_1 = megasas_next_index(s, VAR_1, s->fw_cmds);
VAR_0++;
}
if (!cmd) {
trace_megasas_qf_failed(frame);
}
trace_megasas_qf_new(VAR_1, cmd);
return cmd;
}
| [
"static MegasasCmd *FUNC_0(MegasasState *s,\nhwaddr frame)\n{",
"MegasasCmd *cmd = NULL;",
"int VAR_0 = 0, VAR_1;",
"cmd = megasas_lookup_frame(s, frame);",
"if (cmd) {",
"trace_megasas_qf_found(cmd->VAR_1, cmd->pa);",
"return cmd;",
"}",
"VAR_1 = s->reply_queue_head;",
"VAR_0 = 0;",
"while (VAR... | [
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
0,
1,
1,
0,
1,
1,
0,
1,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[... |
9,455 | static int mpegts_audio_write(void *opaque, uint8_t *buf, int size)
{
MpegTSWriteStream *ts_st = (MpegTSWriteStream *)opaque;
if (ts_st->adata_pos + size > ts_st->adata_size)
return AVERROR(EIO);
memcpy(ts_st->adata + ts_st->adata_pos, buf, size);
ts_st->adata_pos += size;
return 0;
}
| true | FFmpeg | 328e203ca9b5e5afcd0769dae149075735150346 | static int mpegts_audio_write(void *opaque, uint8_t *buf, int size)
{
MpegTSWriteStream *ts_st = (MpegTSWriteStream *)opaque;
if (ts_st->adata_pos + size > ts_st->adata_size)
return AVERROR(EIO);
memcpy(ts_st->adata + ts_st->adata_pos, buf, size);
ts_st->adata_pos += size;
return 0;
}
| {
"code": [
" if (ts_st->adata_pos + size > ts_st->adata_size)"
],
"line_no": [
7
]
} | static int FUNC_0(void *VAR_0, uint8_t *VAR_1, int VAR_2)
{
MpegTSWriteStream *ts_st = (MpegTSWriteStream *)VAR_0;
if (ts_st->adata_pos + VAR_2 > ts_st->adata_size)
return AVERROR(EIO);
memcpy(ts_st->adata + ts_st->adata_pos, VAR_1, VAR_2);
ts_st->adata_pos += VAR_2;
return 0;
}
| [
"static int FUNC_0(void *VAR_0, uint8_t *VAR_1, int VAR_2)\n{",
"MpegTSWriteStream *ts_st = (MpegTSWriteStream *)VAR_0;",
"if (ts_st->adata_pos + VAR_2 > ts_st->adata_size)\nreturn AVERROR(EIO);",
"memcpy(ts_st->adata + ts_st->adata_pos, VAR_1, VAR_2);",
"ts_st->adata_pos += VAR_2;",
"return 0;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
13
],
[
15
],
[
19
],
[
21
]
] |
9,456 | AVFormatContext *avformat_alloc_context(void)
{
AVFormatContext *ic;
ic = av_malloc(sizeof(AVFormatContext));
if (!ic) return ic;
avformat_get_context_defaults(ic);
ic->internal = av_mallocz(sizeof(*ic->internal));
if (!ic->internal) {
avformat_free_context(ic);
return NULL;
}
return ic;
} | true | FFmpeg | 9257692ac15eff7b07540c1f61cebde0d8823fbd | AVFormatContext *avformat_alloc_context(void)
{
AVFormatContext *ic;
ic = av_malloc(sizeof(AVFormatContext));
if (!ic) return ic;
avformat_get_context_defaults(ic);
ic->internal = av_mallocz(sizeof(*ic->internal));
if (!ic->internal) {
avformat_free_context(ic);
return NULL;
}
return ic;
} | {
"code": [],
"line_no": []
} | AVFormatContext *FUNC_0(void)
{
AVFormatContext *ic;
ic = av_malloc(sizeof(AVFormatContext));
if (!ic) return ic;
avformat_get_context_defaults(ic);
ic->internal = av_mallocz(sizeof(*ic->internal));
if (!ic->internal) {
avformat_free_context(ic);
return NULL;
}
return ic;
} | [
"AVFormatContext *FUNC_0(void)\n{",
"AVFormatContext *ic;",
"ic = av_malloc(sizeof(AVFormatContext));",
"if (!ic) return ic;",
"avformat_get_context_defaults(ic);",
"ic->internal = av_mallocz(sizeof(*ic->internal));",
"if (!ic->internal) {",
"avformat_free_context(ic);",
"return NULL;",
"}",
"re... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
16
],
[
18
],
[
20
],
[
22
],
[
24
],
[
28
],
[
30
]
] |
9,459 | void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb)
{
CPUSH4State *env = cs->env_ptr;
DisasContext ctx;
target_ulong pc_start;
int num_insns;
int max_insns;
pc_start = tb->pc;
ctx.pc = pc_start;
ctx.tbflags = (uint32_t)tb->flags;
ctx.envflags = tb->flags & TB_FLAG_ENVFLAGS_MASK;
ctx.bstate = BS_NONE;
ctx.memidx = (ctx.tbflags & (1u << SR_MD)) == 0 ? 1 : 0;
/* We don't know if the delayed pc came from a dynamic or static branch,
so assume it is a dynamic branch. */
ctx.delayed_pc = -1; /* use delayed pc from env pointer */
ctx.tb = tb;
ctx.singlestep_enabled = cs->singlestep_enabled;
ctx.features = env->features;
ctx.has_movcal = (ctx.tbflags & TB_FLAG_PENDING_MOVCA);
ctx.gbank = ((ctx.tbflags & (1 << SR_MD)) &&
(ctx.tbflags & (1 << SR_RB))) * 0x10;
ctx.fbank = ctx.tbflags & FPSCR_FR ? 0x10 : 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0) {
max_insns = CF_COUNT_MASK;
}
max_insns = MIN(max_insns, TCG_MAX_INSNS);
/* Since the ISA is fixed-width, we can bound by the number
of instructions remaining on the page. */
num_insns = -(ctx.pc | TARGET_PAGE_MASK) / 2;
max_insns = MIN(max_insns, num_insns);
/* Single stepping means just that. */
if (ctx.singlestep_enabled || singlestep) {
max_insns = 1;
}
gen_tb_start(tb);
num_insns = 0;
#ifdef CONFIG_USER_ONLY
if (ctx.tbflags & GUSA_MASK) {
num_insns = decode_gusa(&ctx, env, &max_insns);
}
#endif
while (ctx.bstate == BS_NONE
&& num_insns < max_insns
&& !tcg_op_buf_full()) {
tcg_gen_insn_start(ctx.pc, ctx.envflags);
num_insns++;
if (unlikely(cpu_breakpoint_test(cs, ctx.pc, BP_ANY))) {
/* We have hit a breakpoint - make sure PC is up-to-date */
gen_save_cpu_state(&ctx, true);
gen_helper_debug(cpu_env);
ctx.bstate = BS_EXCP;
/* 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. */
ctx.pc += 2;
break;
}
if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
}
ctx.opcode = cpu_lduw_code(env, ctx.pc);
decode_opc(&ctx);
ctx.pc += 2;
}
if (tb->cflags & CF_LAST_IO) {
gen_io_end();
}
if (ctx.tbflags & GUSA_EXCLUSIVE) {
/* Ending the region of exclusivity. Clear the bits. */
ctx.envflags &= ~GUSA_MASK;
}
if (cs->singlestep_enabled) {
gen_save_cpu_state(&ctx, true);
gen_helper_debug(cpu_env);
} else {
switch (ctx.bstate) {
case BS_STOP:
gen_save_cpu_state(&ctx, true);
tcg_gen_exit_tb(0);
break;
case BS_NONE:
gen_save_cpu_state(&ctx, false);
gen_goto_tb(&ctx, 0, ctx.pc);
break;
case BS_EXCP:
/* fall through */
case BS_BRANCH:
default:
break;
}
}
gen_tb_end(tb, num_insns);
tb->size = ctx.pc - pc_start;
tb->icount = num_insns;
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(pc_start)) {
qemu_log_lock();
qemu_log("IN:\n"); /* , lookup_symbol(pc_start)); */
log_target_disas(cs, pc_start, ctx.pc - pc_start, 0);
qemu_log("\n");
qemu_log_unlock();
}
#endif
}
| true | qemu | c5a49c63fa26e8825ad101dfe86339ae4c216539 | void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb)
{
CPUSH4State *env = cs->env_ptr;
DisasContext ctx;
target_ulong pc_start;
int num_insns;
int max_insns;
pc_start = tb->pc;
ctx.pc = pc_start;
ctx.tbflags = (uint32_t)tb->flags;
ctx.envflags = tb->flags & TB_FLAG_ENVFLAGS_MASK;
ctx.bstate = BS_NONE;
ctx.memidx = (ctx.tbflags & (1u << SR_MD)) == 0 ? 1 : 0;
ctx.delayed_pc = -1;
ctx.tb = tb;
ctx.singlestep_enabled = cs->singlestep_enabled;
ctx.features = env->features;
ctx.has_movcal = (ctx.tbflags & TB_FLAG_PENDING_MOVCA);
ctx.gbank = ((ctx.tbflags & (1 << SR_MD)) &&
(ctx.tbflags & (1 << SR_RB))) * 0x10;
ctx.fbank = ctx.tbflags & FPSCR_FR ? 0x10 : 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0) {
max_insns = CF_COUNT_MASK;
}
max_insns = MIN(max_insns, TCG_MAX_INSNS);
num_insns = -(ctx.pc | TARGET_PAGE_MASK) / 2;
max_insns = MIN(max_insns, num_insns);
if (ctx.singlestep_enabled || singlestep) {
max_insns = 1;
}
gen_tb_start(tb);
num_insns = 0;
#ifdef CONFIG_USER_ONLY
if (ctx.tbflags & GUSA_MASK) {
num_insns = decode_gusa(&ctx, env, &max_insns);
}
#endif
while (ctx.bstate == BS_NONE
&& num_insns < max_insns
&& !tcg_op_buf_full()) {
tcg_gen_insn_start(ctx.pc, ctx.envflags);
num_insns++;
if (unlikely(cpu_breakpoint_test(cs, ctx.pc, BP_ANY))) {
gen_save_cpu_state(&ctx, true);
gen_helper_debug(cpu_env);
ctx.bstate = BS_EXCP;
ctx.pc += 2;
break;
}
if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
}
ctx.opcode = cpu_lduw_code(env, ctx.pc);
decode_opc(&ctx);
ctx.pc += 2;
}
if (tb->cflags & CF_LAST_IO) {
gen_io_end();
}
if (ctx.tbflags & GUSA_EXCLUSIVE) {
ctx.envflags &= ~GUSA_MASK;
}
if (cs->singlestep_enabled) {
gen_save_cpu_state(&ctx, true);
gen_helper_debug(cpu_env);
} else {
switch (ctx.bstate) {
case BS_STOP:
gen_save_cpu_state(&ctx, true);
tcg_gen_exit_tb(0);
break;
case BS_NONE:
gen_save_cpu_state(&ctx, false);
gen_goto_tb(&ctx, 0, ctx.pc);
break;
case BS_EXCP:
case BS_BRANCH:
default:
break;
}
}
gen_tb_end(tb, num_insns);
tb->size = ctx.pc - pc_start;
tb->icount = num_insns;
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(pc_start)) {
qemu_log_lock();
qemu_log("IN:\n");
log_target_disas(cs, pc_start, ctx.pc - pc_start, 0);
qemu_log("\n");
qemu_log_unlock();
}
#endif
}
| {
"code": [
" max_insns = tb->cflags & CF_COUNT_MASK;",
" if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {",
" max_insns = tb->cflags & CF_COUNT_MASK;",
" if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {",
" if (tb->cflags & CF_LAST_IO) {",
" max_insns = tb->cflags & CF_COUNT_MASK;",
" if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {",
" max_insns = tb->cflags & CF_COUNT_MASK;",
" if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {",
" max_insns = tb->cflags & CF_COUNT_MASK;",
" if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {",
" if (tb->cflags & CF_LAST_IO) {",
" max_insns = tb->cflags & CF_COUNT_MASK;",
" if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {",
" if (tb->cflags & CF_LAST_IO) {",
" max_insns = tb->cflags & CF_COUNT_MASK;",
" if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {",
" if (tb->cflags & CF_LAST_IO) {",
" max_insns = tb->cflags & CF_COUNT_MASK;",
" max_insns = tb->cflags & CF_COUNT_MASK;",
" if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {",
" if (tb->cflags & CF_LAST_IO) {",
" max_insns = tb->cflags & CF_COUNT_MASK;",
" if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {",
" if (tb->cflags & CF_LAST_IO) {",
" max_insns = tb->cflags & CF_COUNT_MASK;",
" if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {",
" if (tb->cflags & CF_LAST_IO) {",
" max_insns = tb->cflags & CF_COUNT_MASK;",
" max_insns = tb->cflags & CF_COUNT_MASK;",
" if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {",
" if (tb->cflags & CF_LAST_IO) {",
" if (tb->cflags & CF_LAST_IO) {"
],
"line_no": [
51,
139,
51,
139,
155,
51,
139,
51,
139,
51,
139,
155,
51,
139,
155,
51,
139,
155,
51,
51,
139,
155,
51,
139,
155,
51,
139,
155,
51,
51,
139,
155,
155
]
} | void FUNC_0(CPUState *VAR_0, struct TranslationBlock *VAR_1)
{
CPUSH4State *env = VAR_0->env_ptr;
DisasContext ctx;
target_ulong pc_start;
int VAR_2;
int VAR_3;
pc_start = VAR_1->pc;
ctx.pc = pc_start;
ctx.tbflags = (uint32_t)VAR_1->flags;
ctx.envflags = VAR_1->flags & TB_FLAG_ENVFLAGS_MASK;
ctx.bstate = BS_NONE;
ctx.memidx = (ctx.tbflags & (1u << SR_MD)) == 0 ? 1 : 0;
ctx.delayed_pc = -1;
ctx.VAR_1 = VAR_1;
ctx.singlestep_enabled = VAR_0->singlestep_enabled;
ctx.features = env->features;
ctx.has_movcal = (ctx.tbflags & TB_FLAG_PENDING_MOVCA);
ctx.gbank = ((ctx.tbflags & (1 << SR_MD)) &&
(ctx.tbflags & (1 << SR_RB))) * 0x10;
ctx.fbank = ctx.tbflags & FPSCR_FR ? 0x10 : 0;
VAR_3 = VAR_1->cflags & CF_COUNT_MASK;
if (VAR_3 == 0) {
VAR_3 = CF_COUNT_MASK;
}
VAR_3 = MIN(VAR_3, TCG_MAX_INSNS);
VAR_2 = -(ctx.pc | TARGET_PAGE_MASK) / 2;
VAR_3 = MIN(VAR_3, VAR_2);
if (ctx.singlestep_enabled || singlestep) {
VAR_3 = 1;
}
gen_tb_start(VAR_1);
VAR_2 = 0;
#ifdef CONFIG_USER_ONLY
if (ctx.tbflags & GUSA_MASK) {
VAR_2 = decode_gusa(&ctx, env, &VAR_3);
}
#endif
while (ctx.bstate == BS_NONE
&& VAR_2 < VAR_3
&& !tcg_op_buf_full()) {
tcg_gen_insn_start(ctx.pc, ctx.envflags);
VAR_2++;
if (unlikely(cpu_breakpoint_test(VAR_0, ctx.pc, BP_ANY))) {
gen_save_cpu_state(&ctx, true);
gen_helper_debug(cpu_env);
ctx.bstate = BS_EXCP;
ctx.pc += 2;
break;
}
if (VAR_2 == VAR_3 && (VAR_1->cflags & CF_LAST_IO)) {
gen_io_start();
}
ctx.opcode = cpu_lduw_code(env, ctx.pc);
decode_opc(&ctx);
ctx.pc += 2;
}
if (VAR_1->cflags & CF_LAST_IO) {
gen_io_end();
}
if (ctx.tbflags & GUSA_EXCLUSIVE) {
ctx.envflags &= ~GUSA_MASK;
}
if (VAR_0->singlestep_enabled) {
gen_save_cpu_state(&ctx, true);
gen_helper_debug(cpu_env);
} else {
switch (ctx.bstate) {
case BS_STOP:
gen_save_cpu_state(&ctx, true);
tcg_gen_exit_tb(0);
break;
case BS_NONE:
gen_save_cpu_state(&ctx, false);
gen_goto_tb(&ctx, 0, ctx.pc);
break;
case BS_EXCP:
case BS_BRANCH:
default:
break;
}
}
gen_tb_end(VAR_1, VAR_2);
VAR_1->size = ctx.pc - pc_start;
VAR_1->icount = VAR_2;
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(pc_start)) {
qemu_log_lock();
qemu_log("IN:\n");
log_target_disas(VAR_0, pc_start, ctx.pc - pc_start, 0);
qemu_log("\n");
qemu_log_unlock();
}
#endif
}
| [
"void FUNC_0(CPUState *VAR_0, struct TranslationBlock *VAR_1)\n{",
"CPUSH4State *env = VAR_0->env_ptr;",
"DisasContext ctx;",
"target_ulong pc_start;",
"int VAR_2;",
"int VAR_3;",
"pc_start = VAR_1->pc;",
"ctx.pc = pc_start;",
"ctx.tbflags = (uint32_t)VAR_1->flags;",
"ctx.envflags = VAR_1->flags &... | [
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,
1,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[... |
9,461 | static void sh_serial_ioport_write(void *opaque, uint32_t offs, uint32_t val)
{
sh_serial_state *s = opaque;
unsigned char ch;
#ifdef DEBUG_SERIAL
printf("sh_serial: write offs=0x%02x val=0x%02x\n",
offs, val);
#endif
switch(offs) {
case 0x00: /* SMR */
s->smr = val & ((s->feat & SH_SERIAL_FEAT_SCIF) ? 0x7b : 0xff);
return;
case 0x04: /* BRR */
s->brr = val;
return;
case 0x08: /* SCR */
/* TODO : For SH7751, SCIF mask should be 0xfb. */
s->scr = val & ((s->feat & SH_SERIAL_FEAT_SCIF) ? 0xfa : 0xff);
if (!(val & (1 << 5)))
s->flags |= SH_SERIAL_FLAG_TEND;
if ((s->feat & SH_SERIAL_FEAT_SCIF) && s->txi) {
qemu_set_irq(s->txi, val & (1 << 7));
}
if (!(val & (1 << 6))) {
qemu_set_irq(s->rxi, 0);
}
return;
case 0x0c: /* FTDR / TDR */
if (s->chr) {
ch = val;
qemu_chr_write(s->chr, &ch, 1);
}
s->dr = val;
s->flags &= ~SH_SERIAL_FLAG_TDE;
return;
#if 0
case 0x14: /* FRDR / RDR */
ret = 0;
break;
#endif
}
if (s->feat & SH_SERIAL_FEAT_SCIF) {
switch(offs) {
case 0x10: /* FSR */
if (!(val & (1 << 6)))
s->flags &= ~SH_SERIAL_FLAG_TEND;
if (!(val & (1 << 5)))
s->flags &= ~SH_SERIAL_FLAG_TDE;
if (!(val & (1 << 4)))
s->flags &= ~SH_SERIAL_FLAG_BRK;
if (!(val & (1 << 1)))
s->flags &= ~SH_SERIAL_FLAG_RDF;
if (!(val & (1 << 0)))
s->flags &= ~SH_SERIAL_FLAG_DR;
if (!(val & (1 << 1)) || !(val & (1 << 0))) {
if (s->rxi) {
qemu_set_irq(s->rxi, 0);
}
}
return;
case 0x18: /* FCR */
s->fcr = val;
switch ((val >> 6) & 3) {
case 0:
s->rtrg = 1;
break;
case 1:
s->rtrg = 4;
break;
case 2:
s->rtrg = 8;
break;
case 3:
s->rtrg = 14;
break;
}
if (val & (1 << 1)) {
sh_serial_clear_fifo(s);
s->sr &= ~(1 << 1);
}
return;
case 0x20: /* SPTR */
s->sptr = val & 0xf3;
return;
case 0x24: /* LSR */
return;
}
}
else {
#if 0
switch(offs) {
case 0x0c:
ret = s->dr;
break;
case 0x10:
ret = 0;
break;
case 0x1c:
ret = s->sptr;
break;
}
#endif
}
fprintf(stderr, "sh_serial: unsupported write to 0x%02x\n", offs);
assert(0);
}
| true | qemu | d1f193b0edb919ab109f88c53469ec9073f2e142 | static void sh_serial_ioport_write(void *opaque, uint32_t offs, uint32_t val)
{
sh_serial_state *s = opaque;
unsigned char ch;
#ifdef DEBUG_SERIAL
printf("sh_serial: write offs=0x%02x val=0x%02x\n",
offs, val);
#endif
switch(offs) {
case 0x00:
s->smr = val & ((s->feat & SH_SERIAL_FEAT_SCIF) ? 0x7b : 0xff);
return;
case 0x04:
s->brr = val;
return;
case 0x08:
s->scr = val & ((s->feat & SH_SERIAL_FEAT_SCIF) ? 0xfa : 0xff);
if (!(val & (1 << 5)))
s->flags |= SH_SERIAL_FLAG_TEND;
if ((s->feat & SH_SERIAL_FEAT_SCIF) && s->txi) {
qemu_set_irq(s->txi, val & (1 << 7));
}
if (!(val & (1 << 6))) {
qemu_set_irq(s->rxi, 0);
}
return;
case 0x0c:
if (s->chr) {
ch = val;
qemu_chr_write(s->chr, &ch, 1);
}
s->dr = val;
s->flags &= ~SH_SERIAL_FLAG_TDE;
return;
#if 0
case 0x14:
ret = 0;
break;
#endif
}
if (s->feat & SH_SERIAL_FEAT_SCIF) {
switch(offs) {
case 0x10:
if (!(val & (1 << 6)))
s->flags &= ~SH_SERIAL_FLAG_TEND;
if (!(val & (1 << 5)))
s->flags &= ~SH_SERIAL_FLAG_TDE;
if (!(val & (1 << 4)))
s->flags &= ~SH_SERIAL_FLAG_BRK;
if (!(val & (1 << 1)))
s->flags &= ~SH_SERIAL_FLAG_RDF;
if (!(val & (1 << 0)))
s->flags &= ~SH_SERIAL_FLAG_DR;
if (!(val & (1 << 1)) || !(val & (1 << 0))) {
if (s->rxi) {
qemu_set_irq(s->rxi, 0);
}
}
return;
case 0x18:
s->fcr = val;
switch ((val >> 6) & 3) {
case 0:
s->rtrg = 1;
break;
case 1:
s->rtrg = 4;
break;
case 2:
s->rtrg = 8;
break;
case 3:
s->rtrg = 14;
break;
}
if (val & (1 << 1)) {
sh_serial_clear_fifo(s);
s->sr &= ~(1 << 1);
}
return;
case 0x20:
s->sptr = val & 0xf3;
return;
case 0x24:
return;
}
}
else {
#if 0
switch(offs) {
case 0x0c:
ret = s->dr;
break;
case 0x10:
ret = 0;
break;
case 0x1c:
ret = s->sptr;
break;
}
#endif
}
fprintf(stderr, "sh_serial: unsupported write to 0x%02x\n", offs);
assert(0);
}
| {
"code": [
"#if 0",
" ret = s->sptr;",
" break;",
"#endif",
"#if 0",
"#endif"
],
"line_no": [
73,
203,
193,
17,
73,
17
]
} | static void FUNC_0(void *VAR_0, uint32_t VAR_1, uint32_t VAR_2)
{
sh_serial_state *s = VAR_0;
unsigned char VAR_3;
#ifdef DEBUG_SERIAL
printf("sh_serial: write VAR_1=0x%02x VAR_2=0x%02x\n",
VAR_1, VAR_2);
#endif
switch(VAR_1) {
case 0x00:
s->smr = VAR_2 & ((s->feat & SH_SERIAL_FEAT_SCIF) ? 0x7b : 0xff);
return;
case 0x04:
s->brr = VAR_2;
return;
case 0x08:
s->scr = VAR_2 & ((s->feat & SH_SERIAL_FEAT_SCIF) ? 0xfa : 0xff);
if (!(VAR_2 & (1 << 5)))
s->flags |= SH_SERIAL_FLAG_TEND;
if ((s->feat & SH_SERIAL_FEAT_SCIF) && s->txi) {
qemu_set_irq(s->txi, VAR_2 & (1 << 7));
}
if (!(VAR_2 & (1 << 6))) {
qemu_set_irq(s->rxi, 0);
}
return;
case 0x0c:
if (s->chr) {
VAR_3 = VAR_2;
qemu_chr_write(s->chr, &VAR_3, 1);
}
s->dr = VAR_2;
s->flags &= ~SH_SERIAL_FLAG_TDE;
return;
#if 0
case 0x14:
ret = 0;
break;
#endif
}
if (s->feat & SH_SERIAL_FEAT_SCIF) {
switch(VAR_1) {
case 0x10:
if (!(VAR_2 & (1 << 6)))
s->flags &= ~SH_SERIAL_FLAG_TEND;
if (!(VAR_2 & (1 << 5)))
s->flags &= ~SH_SERIAL_FLAG_TDE;
if (!(VAR_2 & (1 << 4)))
s->flags &= ~SH_SERIAL_FLAG_BRK;
if (!(VAR_2 & (1 << 1)))
s->flags &= ~SH_SERIAL_FLAG_RDF;
if (!(VAR_2 & (1 << 0)))
s->flags &= ~SH_SERIAL_FLAG_DR;
if (!(VAR_2 & (1 << 1)) || !(VAR_2 & (1 << 0))) {
if (s->rxi) {
qemu_set_irq(s->rxi, 0);
}
}
return;
case 0x18:
s->fcr = VAR_2;
switch ((VAR_2 >> 6) & 3) {
case 0:
s->rtrg = 1;
break;
case 1:
s->rtrg = 4;
break;
case 2:
s->rtrg = 8;
break;
case 3:
s->rtrg = 14;
break;
}
if (VAR_2 & (1 << 1)) {
sh_serial_clear_fifo(s);
s->sr &= ~(1 << 1);
}
return;
case 0x20:
s->sptr = VAR_2 & 0xf3;
return;
case 0x24:
return;
}
}
else {
#if 0
switch(VAR_1) {
case 0x0c:
ret = s->dr;
break;
case 0x10:
ret = 0;
break;
case 0x1c:
ret = s->sptr;
break;
}
#endif
}
fprintf(stderr, "sh_serial: unsupported write to 0x%02x\n", VAR_1);
assert(0);
}
| [
"static void FUNC_0(void *VAR_0, uint32_t VAR_1, uint32_t VAR_2)\n{",
"sh_serial_state *s = VAR_0;",
"unsigned char VAR_3;",
"#ifdef DEBUG_SERIAL\nprintf(\"sh_serial: write VAR_1=0x%02x VAR_2=0x%02x\\n\",\nVAR_1, VAR_2);",
"#endif\nswitch(VAR_1) {",
"case 0x00:\ns->smr = VAR_2 & ((s->feat & SH_SERIAL_FEAT... | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
... |
9,462 | int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx,
uint8_t *buf, int buf_size,
const short *samples)
{
AVPacket pkt;
AVFrame frame0 = { 0 };
AVFrame *frame;
int ret, samples_size, got_packet;
av_init_packet(&pkt);
pkt.data = buf;
pkt.size = buf_size;
if (samples) {
frame = &frame0;
avcodec_get_frame_defaults(frame);
if (avctx->frame_size) {
frame->nb_samples = avctx->frame_size;
} else {
/* if frame_size is not set, the number of samples must be
* calculated from the buffer size */
int64_t nb_samples;
if (!av_get_bits_per_sample(avctx->codec_id)) {
av_log(avctx, AV_LOG_ERROR, "avcodec_encode_audio() does not "
"support this codec\n");
return AVERROR(EINVAL);
}
nb_samples = (int64_t)buf_size * 8 /
(av_get_bits_per_sample(avctx->codec_id) *
avctx->channels);
if (nb_samples >= INT_MAX)
return AVERROR(EINVAL);
frame->nb_samples = nb_samples;
}
/* it is assumed that the samples buffer is large enough based on the
* relevant parameters */
samples_size = av_samples_get_buffer_size(NULL, avctx->channels,
frame->nb_samples,
avctx->sample_fmt, 1);
if ((ret = avcodec_fill_audio_frame(frame, avctx->channels,
avctx->sample_fmt,
(const uint8_t *)samples,
samples_size, 1)))
return ret;
/* fabricate frame pts from sample count.
* this is needed because the avcodec_encode_audio() API does not have
* a way for the user to provide pts */
if (avctx->sample_rate && avctx->time_base.num)
frame->pts = ff_samples_to_time_base(avctx,
avctx->internal->sample_count);
else
frame->pts = AV_NOPTS_VALUE;
avctx->internal->sample_count += frame->nb_samples;
} else {
frame = NULL;
}
got_packet = 0;
ret = avcodec_encode_audio2(avctx, &pkt, frame, &got_packet);
if (!ret && got_packet && avctx->coded_frame) {
avctx->coded_frame->pts = pkt.pts;
avctx->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY);
}
/* free any side data since we cannot return it */
ff_packet_free_side_data(&pkt);
if (frame && frame->extended_data != frame->data)
av_freep(&frame->extended_data);
return ret ? ret : pkt.size;
}
| false | FFmpeg | e55c3857d20ba015e4914c2e80fcab037af0799d | int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx,
uint8_t *buf, int buf_size,
const short *samples)
{
AVPacket pkt;
AVFrame frame0 = { 0 };
AVFrame *frame;
int ret, samples_size, got_packet;
av_init_packet(&pkt);
pkt.data = buf;
pkt.size = buf_size;
if (samples) {
frame = &frame0;
avcodec_get_frame_defaults(frame);
if (avctx->frame_size) {
frame->nb_samples = avctx->frame_size;
} else {
int64_t nb_samples;
if (!av_get_bits_per_sample(avctx->codec_id)) {
av_log(avctx, AV_LOG_ERROR, "avcodec_encode_audio() does not "
"support this codec\n");
return AVERROR(EINVAL);
}
nb_samples = (int64_t)buf_size * 8 /
(av_get_bits_per_sample(avctx->codec_id) *
avctx->channels);
if (nb_samples >= INT_MAX)
return AVERROR(EINVAL);
frame->nb_samples = nb_samples;
}
samples_size = av_samples_get_buffer_size(NULL, avctx->channels,
frame->nb_samples,
avctx->sample_fmt, 1);
if ((ret = avcodec_fill_audio_frame(frame, avctx->channels,
avctx->sample_fmt,
(const uint8_t *)samples,
samples_size, 1)))
return ret;
if (avctx->sample_rate && avctx->time_base.num)
frame->pts = ff_samples_to_time_base(avctx,
avctx->internal->sample_count);
else
frame->pts = AV_NOPTS_VALUE;
avctx->internal->sample_count += frame->nb_samples;
} else {
frame = NULL;
}
got_packet = 0;
ret = avcodec_encode_audio2(avctx, &pkt, frame, &got_packet);
if (!ret && got_packet && avctx->coded_frame) {
avctx->coded_frame->pts = pkt.pts;
avctx->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY);
}
ff_packet_free_side_data(&pkt);
if (frame && frame->extended_data != frame->data)
av_freep(&frame->extended_data);
return ret ? ret : pkt.size;
}
| {
"code": [],
"line_no": []
} | int VAR_0 avcodec_encode_audio(AVCodecContext *avctx,
uint8_t *buf, int buf_size,
const short *samples)
{
AVPacket pkt;
AVFrame frame0 = { 0 };
AVFrame *frame;
int ret, samples_size, got_packet;
av_init_packet(&pkt);
pkt.data = buf;
pkt.size = buf_size;
if (samples) {
frame = &frame0;
avcodec_get_frame_defaults(frame);
if (avctx->frame_size) {
frame->nb_samples = avctx->frame_size;
} else {
int64_t nb_samples;
if (!av_get_bits_per_sample(avctx->codec_id)) {
av_log(avctx, AV_LOG_ERROR, "avcodec_encode_audio() does not "
"support this codec\n");
return AVERROR(EINVAL);
}
nb_samples = (int64_t)buf_size * 8 /
(av_get_bits_per_sample(avctx->codec_id) *
avctx->channels);
if (nb_samples >= INT_MAX)
return AVERROR(EINVAL);
frame->nb_samples = nb_samples;
}
samples_size = av_samples_get_buffer_size(NULL, avctx->channels,
frame->nb_samples,
avctx->sample_fmt, 1);
if ((ret = avcodec_fill_audio_frame(frame, avctx->channels,
avctx->sample_fmt,
(const uint8_t *)samples,
samples_size, 1)))
return ret;
if (avctx->sample_rate && avctx->time_base.num)
frame->pts = ff_samples_to_time_base(avctx,
avctx->internal->sample_count);
else
frame->pts = AV_NOPTS_VALUE;
avctx->internal->sample_count += frame->nb_samples;
} else {
frame = NULL;
}
got_packet = 0;
ret = avcodec_encode_audio2(avctx, &pkt, frame, &got_packet);
if (!ret && got_packet && avctx->coded_frame) {
avctx->coded_frame->pts = pkt.pts;
avctx->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY);
}
ff_packet_free_side_data(&pkt);
if (frame && frame->extended_data != frame->data)
av_freep(&frame->extended_data);
return ret ? ret : pkt.size;
}
| [
"int VAR_0 avcodec_encode_audio(AVCodecContext *avctx,\nuint8_t *buf, int buf_size,\nconst short *samples)\n{",
"AVPacket pkt;",
"AVFrame frame0 = { 0 };",
"AVFrame *frame;",
"int ret, samples_size, got_packet;",
"av_init_packet(&pkt);",
"pkt.data = buf;",
"pkt.size = buf_size;",
"if (samples) {",
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[... |
9,463 | static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
int size, int64_t pos, uint64_t cluster_time,
uint64_t block_duration, int is_keyframe,
uint8_t *additional, uint64_t additional_id, int additional_size,
int64_t cluster_pos)
{
uint64_t timecode = AV_NOPTS_VALUE;
MatroskaTrack *track;
int res = 0;
AVStream *st;
int16_t block_time;
uint32_t *lace_size = NULL;
int n, flags, laces = 0;
uint64_t num;
if ((n = matroska_ebmlnum_uint(matroska, data, size, &num)) < 0) {
av_log(matroska->ctx, AV_LOG_ERROR, "EBML block data error\n");
return n;
}
data += n;
size -= n;
track = matroska_find_track_by_num(matroska, num);
if (!track || !track->stream) {
av_log(matroska->ctx, AV_LOG_INFO,
"Invalid stream %"PRIu64" or size %u\n", num, size);
return AVERROR_INVALIDDATA;
} else if (size <= 3)
return 0;
st = track->stream;
if (st->discard >= AVDISCARD_ALL)
return res;
av_assert1(block_duration != AV_NOPTS_VALUE);
block_time = AV_RB16(data);
data += 2;
flags = *data++;
size -= 3;
if (is_keyframe == -1)
is_keyframe = flags & 0x80 ? AV_PKT_FLAG_KEY : 0;
if (cluster_time != (uint64_t)-1
&& (block_time >= 0 || cluster_time >= -block_time)) {
timecode = cluster_time + block_time;
if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE
&& timecode < track->end_timecode)
is_keyframe = 0; /* overlapping subtitles are not key frame */
if (is_keyframe)
av_add_index_entry(st, cluster_pos, timecode, 0,0,AVINDEX_KEYFRAME);
}
if (matroska->skip_to_keyframe && track->type != MATROSKA_TRACK_TYPE_SUBTITLE) {
if (timecode < matroska->skip_to_timecode)
return res;
if (!st->skip_to_keyframe) {
av_log(matroska->ctx, AV_LOG_ERROR, "File is broken, keyframes not correctly marked!\n");
matroska->skip_to_keyframe = 0;
}
if (is_keyframe)
matroska->skip_to_keyframe = 0;
}
res = matroska_parse_laces(matroska, &data, size, (flags & 0x06) >> 1,
&lace_size, &laces);
if (res)
goto end;
if (!block_duration)
block_duration = track->default_duration * laces / matroska->time_scale;
if (cluster_time != (uint64_t)-1 && (block_time >= 0 || cluster_time >= -block_time))
track->end_timecode =
FFMAX(track->end_timecode, timecode + block_duration);
for (n = 0; n < laces; n++) {
int64_t lace_duration = block_duration*(n+1) / laces - block_duration*n / laces;
if (lace_size[n] > size) {
av_log(matroska->ctx, AV_LOG_ERROR, "Invalid packet size\n");
break;
}
if ((st->codec->codec_id == AV_CODEC_ID_RA_288 ||
st->codec->codec_id == AV_CODEC_ID_COOK ||
st->codec->codec_id == AV_CODEC_ID_SIPR ||
st->codec->codec_id == AV_CODEC_ID_ATRAC3) &&
st->codec->block_align && track->audio.sub_packet_size) {
res = matroska_parse_rm_audio(matroska, track, st, data, size,
timecode, pos);
if (res)
goto end;
} else {
res = matroska_parse_frame(matroska, track, st, data, lace_size[n],
timecode, lace_duration,
pos, !n? is_keyframe : 0,
additional, additional_id, additional_size);
if (res)
goto end;
}
if (timecode != AV_NOPTS_VALUE)
timecode = lace_duration ? timecode + lace_duration : AV_NOPTS_VALUE;
data += lace_size[n];
size -= lace_size[n];
}
end:
av_free(lace_size);
return res;
}
| true | FFmpeg | 81e85bc95cb1e4f8cc7b1ba71ec027c8791b55d1 | static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
int size, int64_t pos, uint64_t cluster_time,
uint64_t block_duration, int is_keyframe,
uint8_t *additional, uint64_t additional_id, int additional_size,
int64_t cluster_pos)
{
uint64_t timecode = AV_NOPTS_VALUE;
MatroskaTrack *track;
int res = 0;
AVStream *st;
int16_t block_time;
uint32_t *lace_size = NULL;
int n, flags, laces = 0;
uint64_t num;
if ((n = matroska_ebmlnum_uint(matroska, data, size, &num)) < 0) {
av_log(matroska->ctx, AV_LOG_ERROR, "EBML block data error\n");
return n;
}
data += n;
size -= n;
track = matroska_find_track_by_num(matroska, num);
if (!track || !track->stream) {
av_log(matroska->ctx, AV_LOG_INFO,
"Invalid stream %"PRIu64" or size %u\n", num, size);
return AVERROR_INVALIDDATA;
} else if (size <= 3)
return 0;
st = track->stream;
if (st->discard >= AVDISCARD_ALL)
return res;
av_assert1(block_duration != AV_NOPTS_VALUE);
block_time = AV_RB16(data);
data += 2;
flags = *data++;
size -= 3;
if (is_keyframe == -1)
is_keyframe = flags & 0x80 ? AV_PKT_FLAG_KEY : 0;
if (cluster_time != (uint64_t)-1
&& (block_time >= 0 || cluster_time >= -block_time)) {
timecode = cluster_time + block_time;
if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE
&& timecode < track->end_timecode)
is_keyframe = 0;
if (is_keyframe)
av_add_index_entry(st, cluster_pos, timecode, 0,0,AVINDEX_KEYFRAME);
}
if (matroska->skip_to_keyframe && track->type != MATROSKA_TRACK_TYPE_SUBTITLE) {
if (timecode < matroska->skip_to_timecode)
return res;
if (!st->skip_to_keyframe) {
av_log(matroska->ctx, AV_LOG_ERROR, "File is broken, keyframes not correctly marked!\n");
matroska->skip_to_keyframe = 0;
}
if (is_keyframe)
matroska->skip_to_keyframe = 0;
}
res = matroska_parse_laces(matroska, &data, size, (flags & 0x06) >> 1,
&lace_size, &laces);
if (res)
goto end;
if (!block_duration)
block_duration = track->default_duration * laces / matroska->time_scale;
if (cluster_time != (uint64_t)-1 && (block_time >= 0 || cluster_time >= -block_time))
track->end_timecode =
FFMAX(track->end_timecode, timecode + block_duration);
for (n = 0; n < laces; n++) {
int64_t lace_duration = block_duration*(n+1) / laces - block_duration*n / laces;
if (lace_size[n] > size) {
av_log(matroska->ctx, AV_LOG_ERROR, "Invalid packet size\n");
break;
}
if ((st->codec->codec_id == AV_CODEC_ID_RA_288 ||
st->codec->codec_id == AV_CODEC_ID_COOK ||
st->codec->codec_id == AV_CODEC_ID_SIPR ||
st->codec->codec_id == AV_CODEC_ID_ATRAC3) &&
st->codec->block_align && track->audio.sub_packet_size) {
res = matroska_parse_rm_audio(matroska, track, st, data, size,
timecode, pos);
if (res)
goto end;
} else {
res = matroska_parse_frame(matroska, track, st, data, lace_size[n],
timecode, lace_duration,
pos, !n? is_keyframe : 0,
additional, additional_id, additional_size);
if (res)
goto end;
}
if (timecode != AV_NOPTS_VALUE)
timecode = lace_duration ? timecode + lace_duration : AV_NOPTS_VALUE;
data += lace_size[n];
size -= lace_size[n];
}
end:
av_free(lace_size);
return res;
}
| {
"code": [
" res = matroska_parse_laces(matroska, &data, size, (flags & 0x06) >> 1,"
],
"line_no": [
125
]
} | static int FUNC_0(MatroskaDemuxContext *VAR_0, uint8_t *VAR_1,
int VAR_2, int64_t VAR_3, uint64_t VAR_4,
uint64_t VAR_5, int VAR_6,
uint8_t *VAR_7, uint64_t VAR_8, int VAR_9,
int64_t VAR_10)
{
uint64_t timecode = AV_NOPTS_VALUE;
MatroskaTrack *track;
int VAR_11 = 0;
AVStream *st;
int16_t block_time;
uint32_t *lace_size = NULL;
int VAR_12, VAR_13, VAR_14 = 0;
uint64_t num;
if ((VAR_12 = matroska_ebmlnum_uint(VAR_0, VAR_1, VAR_2, &num)) < 0) {
av_log(VAR_0->ctx, AV_LOG_ERROR, "EBML block VAR_1 error\VAR_12");
return VAR_12;
}
VAR_1 += VAR_12;
VAR_2 -= VAR_12;
track = matroska_find_track_by_num(VAR_0, num);
if (!track || !track->stream) {
av_log(VAR_0->ctx, AV_LOG_INFO,
"Invalid stream %"PRIu64" or VAR_2 %u\VAR_12", num, VAR_2);
return AVERROR_INVALIDDATA;
} else if (VAR_2 <= 3)
return 0;
st = track->stream;
if (st->discard >= AVDISCARD_ALL)
return VAR_11;
av_assert1(VAR_5 != AV_NOPTS_VALUE);
block_time = AV_RB16(VAR_1);
VAR_1 += 2;
VAR_13 = *VAR_1++;
VAR_2 -= 3;
if (VAR_6 == -1)
VAR_6 = VAR_13 & 0x80 ? AV_PKT_FLAG_KEY : 0;
if (VAR_4 != (uint64_t)-1
&& (block_time >= 0 || VAR_4 >= -block_time)) {
timecode = VAR_4 + block_time;
if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE
&& timecode < track->end_timecode)
VAR_6 = 0;
if (VAR_6)
av_add_index_entry(st, VAR_10, timecode, 0,0,AVINDEX_KEYFRAME);
}
if (VAR_0->skip_to_keyframe && track->type != MATROSKA_TRACK_TYPE_SUBTITLE) {
if (timecode < VAR_0->skip_to_timecode)
return VAR_11;
if (!st->skip_to_keyframe) {
av_log(VAR_0->ctx, AV_LOG_ERROR, "File is broken, keyframes not correctly marked!\VAR_12");
VAR_0->skip_to_keyframe = 0;
}
if (VAR_6)
VAR_0->skip_to_keyframe = 0;
}
VAR_11 = matroska_parse_laces(VAR_0, &VAR_1, VAR_2, (VAR_13 & 0x06) >> 1,
&lace_size, &VAR_14);
if (VAR_11)
goto end;
if (!VAR_5)
VAR_5 = track->default_duration * VAR_14 / VAR_0->time_scale;
if (VAR_4 != (uint64_t)-1 && (block_time >= 0 || VAR_4 >= -block_time))
track->end_timecode =
FFMAX(track->end_timecode, timecode + VAR_5);
for (VAR_12 = 0; VAR_12 < VAR_14; VAR_12++) {
int64_t lace_duration = VAR_5*(VAR_12+1) / VAR_14 - VAR_5*VAR_12 / VAR_14;
if (lace_size[VAR_12] > VAR_2) {
av_log(VAR_0->ctx, AV_LOG_ERROR, "Invalid packet VAR_2\VAR_12");
break;
}
if ((st->codec->codec_id == AV_CODEC_ID_RA_288 ||
st->codec->codec_id == AV_CODEC_ID_COOK ||
st->codec->codec_id == AV_CODEC_ID_SIPR ||
st->codec->codec_id == AV_CODEC_ID_ATRAC3) &&
st->codec->block_align && track->audio.sub_packet_size) {
VAR_11 = matroska_parse_rm_audio(VAR_0, track, st, VAR_1, VAR_2,
timecode, VAR_3);
if (VAR_11)
goto end;
} else {
VAR_11 = matroska_parse_frame(VAR_0, track, st, VAR_1, lace_size[VAR_12],
timecode, lace_duration,
VAR_3, !VAR_12? VAR_6 : 0,
VAR_7, VAR_8, VAR_9);
if (VAR_11)
goto end;
}
if (timecode != AV_NOPTS_VALUE)
timecode = lace_duration ? timecode + lace_duration : AV_NOPTS_VALUE;
VAR_1 += lace_size[VAR_12];
VAR_2 -= lace_size[VAR_12];
}
end:
av_free(lace_size);
return VAR_11;
}
| [
"static int FUNC_0(MatroskaDemuxContext *VAR_0, uint8_t *VAR_1,\nint VAR_2, int64_t VAR_3, uint64_t VAR_4,\nuint64_t VAR_5, int VAR_6,\nuint8_t *VAR_7, uint64_t VAR_8, int VAR_9,\nint64_t VAR_10)\n{",
"uint64_t timecode = AV_NOPTS_VALUE;",
"MatroskaTrack *track;",
"int VAR_11 = 0;",
"AVStream *st;",
"int1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49,... |
9,465 | static void test_hbitmap_iter_past(TestHBitmapData *data,
const void *unused)
{
hbitmap_test_init(data, L3, 0);
hbitmap_test_set(data, 0, L3);
hbitmap_test_check(data, L3);
}
| true | qemu | 1b0952445522af73b0e78420a9078b3653923703 | static void test_hbitmap_iter_past(TestHBitmapData *data,
const void *unused)
{
hbitmap_test_init(data, L3, 0);
hbitmap_test_set(data, 0, L3);
hbitmap_test_check(data, L3);
}
| {
"code": [
"static void test_hbitmap_iter_past(TestHBitmapData *data,",
" const void *unused)",
" hbitmap_test_init(data, L3, 0);",
" hbitmap_test_set(data, 0, L3);",
" hbitmap_test_check(data, L3);"
],
"line_no": [
1,
3,
7,
9,
11
]
} | static void FUNC_0(TestHBitmapData *VAR_0,
const void *VAR_1)
{
hbitmap_test_init(VAR_0, L3, 0);
hbitmap_test_set(VAR_0, 0, L3);
hbitmap_test_check(VAR_0, L3);
}
| [
"static void FUNC_0(TestHBitmapData *VAR_0,\nconst void *VAR_1)\n{",
"hbitmap_test_init(VAR_0, L3, 0);",
"hbitmap_test_set(VAR_0, 0, L3);",
"hbitmap_test_check(VAR_0, L3);",
"}"
] | [
1,
1,
1,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
9,467 | int do_balloon(Monitor *mon, const QDict *params,
MonitorCompletion cb, void *opaque)
{
int ret;
if (kvm_enabled() && !kvm_has_sync_mmu()) {
qerror_report(QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon");
return -1;
}
ret = qemu_balloon(qdict_get_int(params, "value"), cb, opaque);
if (ret == 0) {
qerror_report(QERR_DEVICE_NOT_ACTIVE, "balloon");
return -1;
}
cb(opaque, NULL);
return 0;
}
| true | qemu | 30fb2ca603e8b8d0f02630ef18bc0d0637a88ffa | int do_balloon(Monitor *mon, const QDict *params,
MonitorCompletion cb, void *opaque)
{
int ret;
if (kvm_enabled() && !kvm_has_sync_mmu()) {
qerror_report(QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon");
return -1;
}
ret = qemu_balloon(qdict_get_int(params, "value"), cb, opaque);
if (ret == 0) {
qerror_report(QERR_DEVICE_NOT_ACTIVE, "balloon");
return -1;
}
cb(opaque, NULL);
return 0;
}
| {
"code": [
" ret = qemu_balloon(qdict_get_int(params, \"value\"), cb, opaque);"
],
"line_no": [
21
]
} | int FUNC_0(Monitor *VAR_0, const QDict *VAR_1,
MonitorCompletion VAR_2, void *VAR_3)
{
int VAR_4;
if (kvm_enabled() && !kvm_has_sync_mmu()) {
qerror_report(QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon");
return -1;
}
VAR_4 = qemu_balloon(qdict_get_int(VAR_1, "value"), VAR_2, VAR_3);
if (VAR_4 == 0) {
qerror_report(QERR_DEVICE_NOT_ACTIVE, "balloon");
return -1;
}
VAR_2(VAR_3, NULL);
return 0;
}
| [
"int FUNC_0(Monitor *VAR_0, const QDict *VAR_1,\nMonitorCompletion VAR_2, void *VAR_3)\n{",
"int VAR_4;",
"if (kvm_enabled() && !kvm_has_sync_mmu()) {",
"qerror_report(QERR_KVM_MISSING_CAP, \"synchronous MMU\", \"balloon\");",
"return -1;",
"}",
"VAR_4 = qemu_balloon(qdict_get_int(VAR_1, \"value\"), VAR... | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
]
] |
9,468 | static void gif_put_bits_rev(PutBitContext *s, int n, unsigned int value)
{
unsigned int bit_buf;
int bit_cnt;
// printf("put_bits=%d %x\n", n, value);
assert(n == 32 || value < (1U << n));
bit_buf = s->bit_buf;
bit_cnt = 32 - s->bit_left; /* XXX:lazyness... was = s->bit_cnt; */
// printf("n=%d value=%x cnt=%d buf=%x\n", n, value, bit_cnt, bit_buf);
/* XXX: optimize */
if (n < (32-bit_cnt)) {
bit_buf |= value << (bit_cnt);
bit_cnt+=n;
} else {
bit_buf |= value << (bit_cnt);
*s->buf_ptr = bit_buf & 0xff;
s->buf_ptr[1] = (bit_buf >> 8) & 0xff;
s->buf_ptr[2] = (bit_buf >> 16) & 0xff;
s->buf_ptr[3] = (bit_buf >> 24) & 0xff;
//printf("bitbuf = %08x\n", bit_buf);
s->buf_ptr+=4;
if (s->buf_ptr >= s->buf_end)
puts("bit buffer overflow !!"); // should never happen ! who got rid of the callback ???
// flush_buffer_rev(s);
bit_cnt=bit_cnt + n - 32;
if (bit_cnt == 0) {
bit_buf = 0;
} else {
bit_buf = value >> (n - bit_cnt);
}
}
s->bit_buf = bit_buf;
s->bit_left = 32 - bit_cnt;
}
| true | FFmpeg | 76d7c327eba042106b729e9d671b6f85f515b1af | static void gif_put_bits_rev(PutBitContext *s, int n, unsigned int value)
{
unsigned int bit_buf;
int bit_cnt;
assert(n == 32 || value < (1U << n));
bit_buf = s->bit_buf;
bit_cnt = 32 - s->bit_left;
if (n < (32-bit_cnt)) {
bit_buf |= value << (bit_cnt);
bit_cnt+=n;
} else {
bit_buf |= value << (bit_cnt);
*s->buf_ptr = bit_buf & 0xff;
s->buf_ptr[1] = (bit_buf >> 8) & 0xff;
s->buf_ptr[2] = (bit_buf >> 16) & 0xff;
s->buf_ptr[3] = (bit_buf >> 24) & 0xff;
s->buf_ptr+=4;
if (s->buf_ptr >= s->buf_end)
puts("bit buffer overflow !!");
bit_cnt=bit_cnt + n - 32;
if (bit_cnt == 0) {
bit_buf = 0;
} else {
bit_buf = value >> (n - bit_cnt);
}
}
s->bit_buf = bit_buf;
s->bit_left = 32 - bit_cnt;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(PutBitContext *VAR_0, int VAR_1, unsigned int VAR_2)
{
unsigned int VAR_3;
int VAR_4;
assert(VAR_1 == 32 || VAR_2 < (1U << VAR_1));
VAR_3 = VAR_0->VAR_3;
VAR_4 = 32 - VAR_0->bit_left;
if (VAR_1 < (32-VAR_4)) {
VAR_3 |= VAR_2 << (VAR_4);
VAR_4+=VAR_1;
} else {
VAR_3 |= VAR_2 << (VAR_4);
*VAR_0->buf_ptr = VAR_3 & 0xff;
VAR_0->buf_ptr[1] = (VAR_3 >> 8) & 0xff;
VAR_0->buf_ptr[2] = (VAR_3 >> 16) & 0xff;
VAR_0->buf_ptr[3] = (VAR_3 >> 24) & 0xff;
VAR_0->buf_ptr+=4;
if (VAR_0->buf_ptr >= VAR_0->buf_end)
puts("bit buffer overflow !!");
VAR_4=VAR_4 + VAR_1 - 32;
if (VAR_4 == 0) {
VAR_3 = 0;
} else {
VAR_3 = VAR_2 >> (VAR_1 - VAR_4);
}
}
VAR_0->VAR_3 = VAR_3;
VAR_0->bit_left = 32 - VAR_4;
}
| [
"static void FUNC_0(PutBitContext *VAR_0, int VAR_1, unsigned int VAR_2)\n{",
"unsigned int VAR_3;",
"int VAR_4;",
"assert(VAR_1 == 32 || VAR_2 < (1U << VAR_1));",
"VAR_3 = VAR_0->VAR_3;",
"VAR_4 = 32 - VAR_0->bit_left;",
"if (VAR_1 < (32-VAR_4)) {",
"VAR_3 |= VAR_2 << (VAR_4);",
"VAR_4+=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
] | [
[
1,
3
],
[
5
],
[
7
],
[
13
],
[
17
],
[
19
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
51
],
[
53,
55
],
[
59
],
[
61
],
... |
9,469 | uint64_t qemu_get_be64(QEMUFile *f)
{
uint64_t v;
v = (uint64_t)qemu_get_be32(f) << 32;
v |= qemu_get_be32(f);
return v;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | uint64_t qemu_get_be64(QEMUFile *f)
{
uint64_t v;
v = (uint64_t)qemu_get_be32(f) << 32;
v |= qemu_get_be32(f);
return v;
}
| {
"code": [],
"line_no": []
} | uint64_t FUNC_0(QEMUFile *f)
{
uint64_t v;
v = (uint64_t)qemu_get_be32(f) << 32;
v |= qemu_get_be32(f);
return v;
}
| [
"uint64_t FUNC_0(QEMUFile *f)\n{",
"uint64_t v;",
"v = (uint64_t)qemu_get_be32(f) << 32;",
"v |= qemu_get_be32(f);",
"return v;",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
9,470 | static int decode_b_mbs(VC9Context *v)
{
MpegEncContext *s = &v->s;
GetBitContext *gb = &v->s.gb;
int current_mb = 0, i /* MB / B postion information */;
int b_mv_type = BMV_TYPE_BACKWARD;
int mquant, mqdiff; /* MB quant stuff */
int ttmb; /* MacroBlock 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 dmv1_x, dmv1_y, dmv2_x, dmv2_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 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;
/* 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];
for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++)
{
for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++)
{
if (v->direct_mb_plane.is_raw)
v->direct_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 (!v->direct_mb_plane.data[current_mb])
{
if (v->skip_mb_plane.data[current_mb])
{
b_mv_type = decode012(gb);
if (v->bfraction > 420 /*1/2*/ &&
b_mv_type < 3) b_mv_type = 1-b_mv_type;
}
else
{
GET_MVDATA(dmv1_x, dmv1_y);
if (!s->mb_intra /* b_mv1 tells not intra */)
{
b_mv_type = decode012(gb);
if (v->bfraction > 420 /*1/2*/ &&
b_mv_type < 3) b_mv_type = 1-b_mv_type;
}
}
}
if (!v->skip_mb_plane.data[current_mb])
{
if (mb_has_coeffs /* BMV1 == "last" */)
{
GET_MQUANT();
if (s->mb_intra /* intra mb */)
s->ac_pred = get_bits(gb, 1);
}
else
{
/* if bmv1 tells MVs are interpolated */
if (b_mv_type == BMV_TYPE_INTERPOLATED)
{
GET_MVDATA(dmv2_x, dmv2_y);
}
/* GET_MVDATA has reset some stuff */
if (mb_has_coeffs /* b_mv2 == "last" */)
{
if (s->mb_intra /* intra_mb */)
s->ac_pred = get_bits(gb, 1);
GET_MQUANT();
}
}
}
//End1
if (v->ttmbf)
ttmb = get_vlc2(gb, v->ttmb_vlc->table,
VC9_TTMB_VLC_BITS, 12);
//End2
for (i=0; i<6; i++)
{
/* FIXME: process the block */
}
current_mb++;
}
}
return 0;
}
| true | FFmpeg | 7cc84d241ba6ef8e27e4d057176a4ad385ad3d59 | static int decode_b_mbs(VC9Context *v)
{
MpegEncContext *s = &v->s;
GetBitContext *gb = &v->s.gb;
int current_mb = 0, i ;
int b_mv_type = BMV_TYPE_BACKWARD;
int mquant, mqdiff;
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 dmv1_x, dmv1_y, dmv2_x, dmv2_y;
int k_x, k_y;
int hpel_flag;
int index, index1;
int val, sign;
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;
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];
for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++)
{
for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++)
{
if (v->direct_mb_plane.is_raw)
v->direct_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 (!v->direct_mb_plane.data[current_mb])
{
if (v->skip_mb_plane.data[current_mb])
{
b_mv_type = decode012(gb);
if (v->bfraction > 420 &&
b_mv_type < 3) b_mv_type = 1-b_mv_type;
}
else
{
GET_MVDATA(dmv1_x, dmv1_y);
if (!s->mb_intra )
{
b_mv_type = decode012(gb);
if (v->bfraction > 420 &&
b_mv_type < 3) b_mv_type = 1-b_mv_type;
}
}
}
if (!v->skip_mb_plane.data[current_mb])
{
if (mb_has_coeffs )
{
GET_MQUANT();
if (s->mb_intra )
s->ac_pred = get_bits(gb, 1);
}
else
{
if (b_mv_type == BMV_TYPE_INTERPOLATED)
{
GET_MVDATA(dmv2_x, dmv2_y);
}
if (mb_has_coeffs )
{
if (s->mb_intra )
s->ac_pred = get_bits(gb, 1);
GET_MQUANT();
}
}
}
if (v->ttmbf)
ttmb = get_vlc2(gb, v->ttmb_vlc->table,
VC9_TTMB_VLC_BITS, 12);
for (i=0; i<6; i++)
{
}
current_mb++;
}
}
return 0;
}
| {
"code": [
" GetBitContext *gb = &v->s.gb;",
" GetBitContext *gb = &v->s.gb;",
" 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];",
" 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->skip_mb_plane.data[current_mb] = get_bits(gb, 1);",
" 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->direct_mb_plane.data[current_mb] = get_bits(gb, 1);",
" v->skip_mb_plane.data[current_mb] = get_bits(gb, 1);",
" if (!v->direct_mb_plane.data[current_mb])",
" if (v->skip_mb_plane.data[current_mb])",
" if (!v->skip_mb_plane.data[current_mb])",
" ttmb = get_vlc2(gb, v->ttmb_vlc->table,",
" VC9_TTMB_VLC_BITS, 12);",
" current_mb++;"
],
"line_no": [
7,
7,
63,
65,
67,
197,
63,
65,
67,
43,
45,
47,
55,
57,
85,
197,
63,
65,
67,
81,
85,
89,
93,
127,
179,
181,
197
]
} | static int FUNC_0(VC9Context *VAR_0)
{
MpegEncContext *s = &VAR_0->s;
GetBitContext *gb = &VAR_0->s.gb;
int VAR_1 = 0, VAR_2 ;
int VAR_3 = BMV_TYPE_BACKWARD;
int VAR_4, VAR_5;
int VAR_6;
static const int VAR_7[6] = { 0, 2, 3, 4, 5, 8 },
VAR_8[6] = { 0, 1, 3, 7, 15, 31 };
int VAR_9 = 1;
int VAR_10, VAR_11, VAR_12, VAR_13;
int VAR_14, VAR_15;
int VAR_16;
int VAR_17, VAR_18;
int VAR_19, VAR_20;
switch (VAR_0->mvrange)
{
case 1: VAR_14 = 10; VAR_15 = 9; break;
case 2: VAR_14 = 12; VAR_15 = 10; break;
case 3: VAR_14 = 13; VAR_15 = 11; break;
default: VAR_14 = 9; VAR_15 = 8; break;
}
VAR_16 = VAR_0->mv_mode & 1;
VAR_14 -= VAR_16;
VAR_15 -= VAR_16;
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];
for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++)
{
for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++)
{
if (VAR_0->direct_mb_plane.is_raw)
VAR_0->direct_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_0->direct_mb_plane.data[VAR_1])
{
if (VAR_0->skip_mb_plane.data[VAR_1])
{
VAR_3 = decode012(gb);
if (VAR_0->bfraction > 420 &&
VAR_3 < 3) VAR_3 = 1-VAR_3;
}
else
{
GET_MVDATA(VAR_10, VAR_11);
if (!s->mb_intra )
{
VAR_3 = decode012(gb);
if (VAR_0->bfraction > 420 &&
VAR_3 < 3) VAR_3 = 1-VAR_3;
}
}
}
if (!VAR_0->skip_mb_plane.data[VAR_1])
{
if (VAR_9 )
{
GET_MQUANT();
if (s->mb_intra )
s->ac_pred = get_bits(gb, 1);
}
else
{
if (VAR_3 == BMV_TYPE_INTERPOLATED)
{
GET_MVDATA(VAR_12, VAR_13);
}
if (VAR_9 )
{
if (s->mb_intra )
s->ac_pred = get_bits(gb, 1);
GET_MQUANT();
}
}
}
if (VAR_0->ttmbf)
VAR_6 = get_vlc2(gb, VAR_0->ttmb_vlc->table,
VC9_TTMB_VLC_BITS, 12);
for (VAR_2=0; VAR_2<6; VAR_2++)
{
}
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 ;",
"int VAR_3 = BMV_TYPE_BACKWARD;",
"int VAR_4, VAR_5;",
"int VAR_6;",
"static const int VAR_7[6] = { 0, 2, 3, 4, 5, 8 },",
"VAR_8[6] = { 0, 1, 3, 7, 15, 31 };",
... | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
1,
1,
1,
1,
1,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0... | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[... |
9,471 | static int ehci_execute(EHCIQueue *q)
{
USBPort *port;
USBDevice *dev;
int ret;
int i;
int endp;
int devadr;
if ( !(q->qh.token & QTD_TOKEN_ACTIVE)) {
fprintf(stderr, "Attempting to execute inactive QH\n");
return USB_RET_PROCERR;
}
q->tbytes = (q->qh.token & QTD_TOKEN_TBYTES_MASK) >> QTD_TOKEN_TBYTES_SH;
if (q->tbytes > BUFF_SIZE) {
fprintf(stderr, "Request for more bytes than allowed\n");
return USB_RET_PROCERR;
}
q->pid = (q->qh.token & QTD_TOKEN_PID_MASK) >> QTD_TOKEN_PID_SH;
switch(q->pid) {
case 0: q->pid = USB_TOKEN_OUT; break;
case 1: q->pid = USB_TOKEN_IN; break;
case 2: q->pid = USB_TOKEN_SETUP; break;
default: fprintf(stderr, "bad token\n"); break;
}
if ((q->tbytes && q->pid != USB_TOKEN_IN) &&
(ehci_buffer_rw(q, q->tbytes, 0) != 0)) {
return USB_RET_PROCERR;
}
endp = get_field(q->qh.epchar, QH_EPCHAR_EP);
devadr = get_field(q->qh.epchar, QH_EPCHAR_DEVADDR);
ret = USB_RET_NODEV;
// TO-DO: associating device with ehci port
for(i = 0; i < NB_PORTS; i++) {
port = &q->ehci->ports[i];
dev = port->dev;
if (!(q->ehci->portsc[i] &(PORTSC_CONNECT))) {
DPRINTF("Port %d, no exec, not connected(%08X)\n",
i, q->ehci->portsc[i]);
continue;
}
q->packet.pid = q->pid;
q->packet.devaddr = devadr;
q->packet.devep = endp;
q->packet.data = q->buffer;
q->packet.len = q->tbytes;
ret = usb_handle_packet(dev, &q->packet);
DPRINTF("submit: qh %x next %x qtd %x pid %x len %d (total %d) endp %x ret %d\n",
q->qhaddr, q->qh.next, q->qtdaddr, q->pid,
q->packet.len, q->tbytes, endp, ret);
if (ret != USB_RET_NODEV) {
break;
}
}
if (ret > BUFF_SIZE) {
fprintf(stderr, "ret from usb_handle_packet > BUFF_SIZE\n");
return USB_RET_PROCERR;
}
return ret;
}
| true | qemu | 4f4321c11ff6e98583846bfd6f0e81954924b003 | static int ehci_execute(EHCIQueue *q)
{
USBPort *port;
USBDevice *dev;
int ret;
int i;
int endp;
int devadr;
if ( !(q->qh.token & QTD_TOKEN_ACTIVE)) {
fprintf(stderr, "Attempting to execute inactive QH\n");
return USB_RET_PROCERR;
}
q->tbytes = (q->qh.token & QTD_TOKEN_TBYTES_MASK) >> QTD_TOKEN_TBYTES_SH;
if (q->tbytes > BUFF_SIZE) {
fprintf(stderr, "Request for more bytes than allowed\n");
return USB_RET_PROCERR;
}
q->pid = (q->qh.token & QTD_TOKEN_PID_MASK) >> QTD_TOKEN_PID_SH;
switch(q->pid) {
case 0: q->pid = USB_TOKEN_OUT; break;
case 1: q->pid = USB_TOKEN_IN; break;
case 2: q->pid = USB_TOKEN_SETUP; break;
default: fprintf(stderr, "bad token\n"); break;
}
if ((q->tbytes && q->pid != USB_TOKEN_IN) &&
(ehci_buffer_rw(q, q->tbytes, 0) != 0)) {
return USB_RET_PROCERR;
}
endp = get_field(q->qh.epchar, QH_EPCHAR_EP);
devadr = get_field(q->qh.epchar, QH_EPCHAR_DEVADDR);
ret = USB_RET_NODEV;
for(i = 0; i < NB_PORTS; i++) {
port = &q->ehci->ports[i];
dev = port->dev;
if (!(q->ehci->portsc[i] &(PORTSC_CONNECT))) {
DPRINTF("Port %d, no exec, not connected(%08X)\n",
i, q->ehci->portsc[i]);
continue;
}
q->packet.pid = q->pid;
q->packet.devaddr = devadr;
q->packet.devep = endp;
q->packet.data = q->buffer;
q->packet.len = q->tbytes;
ret = usb_handle_packet(dev, &q->packet);
DPRINTF("submit: qh %x next %x qtd %x pid %x len %d (total %d) endp %x ret %d\n",
q->qhaddr, q->qh.next, q->qtdaddr, q->pid,
q->packet.len, q->tbytes, endp, ret);
if (ret != USB_RET_NODEV) {
break;
}
}
if (ret > BUFF_SIZE) {
fprintf(stderr, "ret from usb_handle_packet > BUFF_SIZE\n");
return USB_RET_PROCERR;
}
return ret;
}
| {
"code": [
" q->packet.pid = q->pid;",
" q->packet.devaddr = devadr;",
" q->packet.devep = endp;",
" q->packet.data = q->buffer;",
" q->packet.len = q->tbytes;",
" DPRINTF(\"submit: qh %x next %x qtd %x pid %x len %d (total %d) endp %x ret %d\\n\",",
" q->packet.len, q->tbytes, endp, ret);",
" int i;"
],
"line_no": [
99,
101,
103,
105,
107,
115,
119,
11
]
} | static int FUNC_0(EHCIQueue *VAR_0)
{
USBPort *port;
USBDevice *dev;
int VAR_1;
int VAR_2;
int VAR_3;
int VAR_4;
if ( !(VAR_0->qh.token & QTD_TOKEN_ACTIVE)) {
fprintf(stderr, "Attempting to execute inactive QH\n");
return USB_RET_PROCERR;
}
VAR_0->tbytes = (VAR_0->qh.token & QTD_TOKEN_TBYTES_MASK) >> QTD_TOKEN_TBYTES_SH;
if (VAR_0->tbytes > BUFF_SIZE) {
fprintf(stderr, "Request for more bytes than allowed\n");
return USB_RET_PROCERR;
}
VAR_0->pid = (VAR_0->qh.token & QTD_TOKEN_PID_MASK) >> QTD_TOKEN_PID_SH;
switch(VAR_0->pid) {
case 0: VAR_0->pid = USB_TOKEN_OUT; break;
case 1: VAR_0->pid = USB_TOKEN_IN; break;
case 2: VAR_0->pid = USB_TOKEN_SETUP; break;
default: fprintf(stderr, "bad token\n"); break;
}
if ((VAR_0->tbytes && VAR_0->pid != USB_TOKEN_IN) &&
(ehci_buffer_rw(VAR_0, VAR_0->tbytes, 0) != 0)) {
return USB_RET_PROCERR;
}
VAR_3 = get_field(VAR_0->qh.epchar, QH_EPCHAR_EP);
VAR_4 = get_field(VAR_0->qh.epchar, QH_EPCHAR_DEVADDR);
VAR_1 = USB_RET_NODEV;
for(VAR_2 = 0; VAR_2 < NB_PORTS; VAR_2++) {
port = &VAR_0->ehci->ports[VAR_2];
dev = port->dev;
if (!(VAR_0->ehci->portsc[VAR_2] &(PORTSC_CONNECT))) {
DPRINTF("Port %d, no exec, not connected(%08X)\n",
VAR_2, VAR_0->ehci->portsc[VAR_2]);
continue;
}
VAR_0->packet.pid = VAR_0->pid;
VAR_0->packet.devaddr = VAR_4;
VAR_0->packet.devep = VAR_3;
VAR_0->packet.data = VAR_0->buffer;
VAR_0->packet.len = VAR_0->tbytes;
VAR_1 = usb_handle_packet(dev, &VAR_0->packet);
DPRINTF("submit: qh %x next %x qtd %x pid %x len %d (total %d) VAR_3 %x VAR_1 %d\n",
VAR_0->qhaddr, VAR_0->qh.next, VAR_0->qtdaddr, VAR_0->pid,
VAR_0->packet.len, VAR_0->tbytes, VAR_3, VAR_1);
if (VAR_1 != USB_RET_NODEV) {
break;
}
}
if (VAR_1 > BUFF_SIZE) {
fprintf(stderr, "VAR_1 from usb_handle_packet > BUFF_SIZE\n");
return USB_RET_PROCERR;
}
return VAR_1;
}
| [
"static int FUNC_0(EHCIQueue *VAR_0)\n{",
"USBPort *port;",
"USBDevice *dev;",
"int VAR_1;",
"int VAR_2;",
"int VAR_3;",
"int VAR_4;",
"if ( !(VAR_0->qh.token & QTD_TOKEN_ACTIVE)) {",
"fprintf(stderr, \"Attempting to execute inactive QH\\n\");",
"return USB_RET_PROCERR;",
"}",
"VAR_0->tbytes =... | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
... |
9,472 | static void powerpc_set_compat(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
Error *error = NULL;
char *value = NULL;
Property *prop = opaque;
uint32_t *max_compat = qdev_get_prop_ptr(DEVICE(obj), prop);
visit_type_str(v, name, &value, &error);
if (error) {
error_propagate(errp, error);
return;
}
if (strcmp(value, "power6") == 0) {
*max_compat = CPU_POWERPC_LOGICAL_2_05;
} else if (strcmp(value, "power7") == 0) {
*max_compat = CPU_POWERPC_LOGICAL_2_06;
} else if (strcmp(value, "power8") == 0) {
*max_compat = CPU_POWERPC_LOGICAL_2_07;
} else {
error_setg(errp, "Invalid compatibility mode \"%s\"", value);
}
g_free(value);
}
| true | qemu | 7843c0d60db694b6d97e14ec5538fb97424016c1 | static void powerpc_set_compat(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
Error *error = NULL;
char *value = NULL;
Property *prop = opaque;
uint32_t *max_compat = qdev_get_prop_ptr(DEVICE(obj), prop);
visit_type_str(v, name, &value, &error);
if (error) {
error_propagate(errp, error);
return;
}
if (strcmp(value, "power6") == 0) {
*max_compat = CPU_POWERPC_LOGICAL_2_05;
} else if (strcmp(value, "power7") == 0) {
*max_compat = CPU_POWERPC_LOGICAL_2_06;
} else if (strcmp(value, "power8") == 0) {
*max_compat = CPU_POWERPC_LOGICAL_2_07;
} else {
error_setg(errp, "Invalid compatibility mode \"%s\"", value);
}
g_free(value);
}
| {
"code": [
" void *opaque, Error **errp)",
" Property *prop = opaque;",
" uint32_t *max_compat = qdev_get_prop_ptr(DEVICE(obj), prop);",
"static void powerpc_set_compat(Object *obj, Visitor *v, const char *name,",
" void *opaque, Error **errp)",
" Error *error = NULL;",
" char *value = NULL;",
" Property *prop = opaque;",
" uint32_t *max_compat = qdev_get_prop_ptr(DEVICE(obj), prop);",
" visit_type_str(v, name, &value, &error);",
" if (error) {",
" error_propagate(errp, error);",
" if (strcmp(value, \"power6\") == 0) {",
" *max_compat = CPU_POWERPC_LOGICAL_2_05;",
" } else if (strcmp(value, \"power7\") == 0) {",
" *max_compat = CPU_POWERPC_LOGICAL_2_06;",
" } else if (strcmp(value, \"power8\") == 0) {",
" *max_compat = CPU_POWERPC_LOGICAL_2_07;",
" } else {",
" error_setg(errp, \"Invalid compatibility mode \\\"%s\\\"\", value);",
" g_free(value);"
],
"line_no": [
3,
11,
13,
1,
3,
7,
9,
11,
13,
17,
19,
21,
29,
31,
33,
35,
37,
39,
41,
43,
49
]
} | static void FUNC_0(Object *VAR_0, Visitor *VAR_1, const char *VAR_2,
void *VAR_3, Error **VAR_4)
{
Error *error = NULL;
char *VAR_5 = NULL;
Property *prop = VAR_3;
uint32_t *max_compat = qdev_get_prop_ptr(DEVICE(VAR_0), prop);
visit_type_str(VAR_1, VAR_2, &VAR_5, &error);
if (error) {
error_propagate(VAR_4, error);
return;
}
if (strcmp(VAR_5, "power6") == 0) {
*max_compat = CPU_POWERPC_LOGICAL_2_05;
} else if (strcmp(VAR_5, "power7") == 0) {
*max_compat = CPU_POWERPC_LOGICAL_2_06;
} else if (strcmp(VAR_5, "power8") == 0) {
*max_compat = CPU_POWERPC_LOGICAL_2_07;
} else {
error_setg(VAR_4, "Invalid compatibility mode \"%s\"", VAR_5);
}
g_free(VAR_5);
}
| [
"static void FUNC_0(Object *VAR_0, Visitor *VAR_1, const char *VAR_2,\nvoid *VAR_3, Error **VAR_4)\n{",
"Error *error = NULL;",
"char *VAR_5 = NULL;",
"Property *prop = VAR_3;",
"uint32_t *max_compat = qdev_get_prop_ptr(DEVICE(VAR_0), prop);",
"visit_type_str(VAR_1, VAR_2, &VAR_5, &error);",
"if (error)... | [
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[... |
9,473 | static bool write_header(FILE *fp)
{
static const TraceRecord header = {
.event = HEADER_EVENT_ID,
.timestamp_ns = HEADER_MAGIC,
.x1 = HEADER_VERSION,
};
return fwrite(&header, sizeof header, 1, fp) == 1;
}
| true | qemu | 0b5538c300a56c3cfb33022840fe0b4968147e7a | static bool write_header(FILE *fp)
{
static const TraceRecord header = {
.event = HEADER_EVENT_ID,
.timestamp_ns = HEADER_MAGIC,
.x1 = HEADER_VERSION,
};
return fwrite(&header, sizeof header, 1, fp) == 1;
}
| {
"code": [
"static bool write_header(FILE *fp)",
" static const TraceRecord header = {",
" .event = HEADER_EVENT_ID,",
" .timestamp_ns = HEADER_MAGIC,",
" .x1 = HEADER_VERSION,",
" };",
" return fwrite(&header, sizeof header, 1, fp) == 1;"
],
"line_no": [
1,
5,
7,
9,
11,
13,
17
]
} | static bool FUNC_0(FILE *fp)
{
static const TraceRecord VAR_0 = {
.event = HEADER_EVENT_ID,
.timestamp_ns = HEADER_MAGIC,
.x1 = HEADER_VERSION,
};
return fwrite(&VAR_0, sizeof VAR_0, 1, fp) == 1;
}
| [
"static bool FUNC_0(FILE *fp)\n{",
"static const TraceRecord VAR_0 = {",
".event = HEADER_EVENT_ID,\n.timestamp_ns = HEADER_MAGIC,\n.x1 = HEADER_VERSION,\n};",
"return fwrite(&VAR_0, sizeof VAR_0, 1, fp) == 1;",
"}"
] | [
1,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7,
9,
11,
13
],
[
17
],
[
19
]
] |
9,474 | static int encode_mode(CinepakEncContext *s, int h, AVPicture *scratch_pict, AVPicture *last_pict, strip_info *info, unsigned char *buf)
{
int x, y, z, flags, bits, temp_size, header_ofs, ret = 0, mb_count = s->w * h / MB_AREA;
int needs_extra_bit, should_write_temp;
unsigned char temp[64]; //32/2 = 16 V4 blocks at 4 B each -> 64 B
mb_info *mb;
AVPicture sub_scratch, sub_last;
//encode codebooks
////// MacOS vintage decoder compatibility dictates the presence of
////// the codebook chunk even when the codebook is empty - pretty dumb...
////// and also the certain order of the codebook chunks -- rl
if(info->v4_size || !s->skip_empty_cb)
ret += encode_codebook(s, info->v4_codebook, info->v4_size, 0x20, 0x24, buf + ret);
if(info->v1_size || !s->skip_empty_cb)
ret += encode_codebook(s, info->v1_codebook, info->v1_size, 0x22, 0x26, buf + ret);
//update scratch picture
for(z = y = 0; y < h; y += MB_SIZE) {
for(x = 0; x < s->w; x += MB_SIZE, z++) {
mb = &s->mb[z];
get_sub_picture(s, x, y, scratch_pict, &sub_scratch);
if(info->mode == MODE_MC && mb->best_encoding == ENC_SKIP) {
get_sub_picture(s, x, y, last_pict, &sub_last);
copy_mb(s, &sub_scratch, &sub_last);
} else if(info->mode == MODE_V1_ONLY || mb->best_encoding == ENC_V1)
decode_v1_vector(s, &sub_scratch, mb->v1_vector, info);
else
decode_v4_vector(s, &sub_scratch, mb->v4_vector, info);
}
}
switch(info->mode) {
case MODE_V1_ONLY:
//av_log(s->avctx, AV_LOG_INFO, "mb_count = %i\n", mb_count);
ret += write_chunk_header(buf + ret, 0x32, mb_count);
for(x = 0; x < mb_count; x++)
buf[ret++] = s->mb[x].v1_vector;
break;
case MODE_V1_V4:
//remember header position
header_ofs = ret;
ret += CHUNK_HEADER_SIZE;
for(x = 0; x < mb_count; x += 32) {
flags = 0;
for(y = x; y < FFMIN(x+32, mb_count); y++)
if(s->mb[y].best_encoding == ENC_V4)
flags |= 1 << (31 - y + x);
AV_WB32(&buf[ret], flags);
ret += 4;
for(y = x; y < FFMIN(x+32, mb_count); y++) {
mb = &s->mb[y];
if(mb->best_encoding == ENC_V1)
buf[ret++] = mb->v1_vector;
else
for(z = 0; z < 4; z++)
buf[ret++] = mb->v4_vector[z];
}
}
write_chunk_header(buf + header_ofs, 0x30, ret - header_ofs - CHUNK_HEADER_SIZE);
break;
case MODE_MC:
//remember header position
header_ofs = ret;
ret += CHUNK_HEADER_SIZE;
flags = bits = temp_size = 0;
for(x = 0; x < mb_count; x++) {
mb = &s->mb[x];
flags |= (mb->best_encoding != ENC_SKIP) << (31 - bits++);
needs_extra_bit = 0;
should_write_temp = 0;
if(mb->best_encoding != ENC_SKIP) {
if(bits < 32)
flags |= (mb->best_encoding == ENC_V4) << (31 - bits++);
else
needs_extra_bit = 1;
}
if(bits == 32) {
AV_WB32(&buf[ret], flags);
ret += 4;
flags = bits = 0;
if(mb->best_encoding == ENC_SKIP || needs_extra_bit) {
memcpy(&buf[ret], temp, temp_size);
ret += temp_size;
temp_size = 0;
} else
should_write_temp = 1;
}
if(needs_extra_bit) {
flags = (mb->best_encoding == ENC_V4) << 31;
bits = 1;
}
if(mb->best_encoding == ENC_V1)
temp[temp_size++] = mb->v1_vector;
else if(mb->best_encoding == ENC_V4)
for(z = 0; z < 4; z++)
temp[temp_size++] = mb->v4_vector[z];
if(should_write_temp) {
memcpy(&buf[ret], temp, temp_size);
ret += temp_size;
temp_size = 0;
}
}
if(bits > 0) {
AV_WB32(&buf[ret], flags);
ret += 4;
memcpy(&buf[ret], temp, temp_size);
ret += temp_size;
}
write_chunk_header(buf + header_ofs, 0x31, ret - header_ofs - CHUNK_HEADER_SIZE);
break;
}
return ret;
}
| true | FFmpeg | a6e9448dc6971ba4e196656de3e6cd7bcac2cb8f | static int encode_mode(CinepakEncContext *s, int h, AVPicture *scratch_pict, AVPicture *last_pict, strip_info *info, unsigned char *buf)
{
int x, y, z, flags, bits, temp_size, header_ofs, ret = 0, mb_count = s->w * h / MB_AREA;
int needs_extra_bit, should_write_temp;
unsigned char temp[64];
mb_info *mb;
AVPicture sub_scratch, sub_last;
if(info->v4_size || !s->skip_empty_cb)
ret += encode_codebook(s, info->v4_codebook, info->v4_size, 0x20, 0x24, buf + ret);
if(info->v1_size || !s->skip_empty_cb)
ret += encode_codebook(s, info->v1_codebook, info->v1_size, 0x22, 0x26, buf + ret);
for(z = y = 0; y < h; y += MB_SIZE) {
for(x = 0; x < s->w; x += MB_SIZE, z++) {
mb = &s->mb[z];
get_sub_picture(s, x, y, scratch_pict, &sub_scratch);
if(info->mode == MODE_MC && mb->best_encoding == ENC_SKIP) {
get_sub_picture(s, x, y, last_pict, &sub_last);
copy_mb(s, &sub_scratch, &sub_last);
} else if(info->mode == MODE_V1_ONLY || mb->best_encoding == ENC_V1)
decode_v1_vector(s, &sub_scratch, mb->v1_vector, info);
else
decode_v4_vector(s, &sub_scratch, mb->v4_vector, info);
}
}
switch(info->mode) {
case MODE_V1_ONLY:
ret += write_chunk_header(buf + ret, 0x32, mb_count);
for(x = 0; x < mb_count; x++)
buf[ret++] = s->mb[x].v1_vector;
break;
case MODE_V1_V4:
header_ofs = ret;
ret += CHUNK_HEADER_SIZE;
for(x = 0; x < mb_count; x += 32) {
flags = 0;
for(y = x; y < FFMIN(x+32, mb_count); y++)
if(s->mb[y].best_encoding == ENC_V4)
flags |= 1 << (31 - y + x);
AV_WB32(&buf[ret], flags);
ret += 4;
for(y = x; y < FFMIN(x+32, mb_count); y++) {
mb = &s->mb[y];
if(mb->best_encoding == ENC_V1)
buf[ret++] = mb->v1_vector;
else
for(z = 0; z < 4; z++)
buf[ret++] = mb->v4_vector[z];
}
}
write_chunk_header(buf + header_ofs, 0x30, ret - header_ofs - CHUNK_HEADER_SIZE);
break;
case MODE_MC:
header_ofs = ret;
ret += CHUNK_HEADER_SIZE;
flags = bits = temp_size = 0;
for(x = 0; x < mb_count; x++) {
mb = &s->mb[x];
flags |= (mb->best_encoding != ENC_SKIP) << (31 - bits++);
needs_extra_bit = 0;
should_write_temp = 0;
if(mb->best_encoding != ENC_SKIP) {
if(bits < 32)
flags |= (mb->best_encoding == ENC_V4) << (31 - bits++);
else
needs_extra_bit = 1;
}
if(bits == 32) {
AV_WB32(&buf[ret], flags);
ret += 4;
flags = bits = 0;
if(mb->best_encoding == ENC_SKIP || needs_extra_bit) {
memcpy(&buf[ret], temp, temp_size);
ret += temp_size;
temp_size = 0;
} else
should_write_temp = 1;
}
if(needs_extra_bit) {
flags = (mb->best_encoding == ENC_V4) << 31;
bits = 1;
}
if(mb->best_encoding == ENC_V1)
temp[temp_size++] = mb->v1_vector;
else if(mb->best_encoding == ENC_V4)
for(z = 0; z < 4; z++)
temp[temp_size++] = mb->v4_vector[z];
if(should_write_temp) {
memcpy(&buf[ret], temp, temp_size);
ret += temp_size;
temp_size = 0;
}
}
if(bits > 0) {
AV_WB32(&buf[ret], flags);
ret += 4;
memcpy(&buf[ret], temp, temp_size);
ret += temp_size;
}
write_chunk_header(buf + header_ofs, 0x31, ret - header_ofs - CHUNK_HEADER_SIZE);
break;
}
return ret;
}
| {
"code": [
" AVPicture sub_scratch, sub_last;"
],
"line_no": [
13
]
} | static int FUNC_0(CinepakEncContext *VAR_0, int VAR_1, AVPicture *VAR_2, AVPicture *VAR_3, strip_info *VAR_4, unsigned char *VAR_5)
{
int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13 = 0, VAR_14 = VAR_0->w * VAR_1 / MB_AREA;
int VAR_15, VAR_16;
unsigned char VAR_17[64];
mb_info *mb;
AVPicture sub_scratch, sub_last;
if(VAR_4->v4_size || !VAR_0->skip_empty_cb)
VAR_13 += encode_codebook(VAR_0, VAR_4->v4_codebook, VAR_4->v4_size, 0x20, 0x24, VAR_5 + VAR_13);
if(VAR_4->v1_size || !VAR_0->skip_empty_cb)
VAR_13 += encode_codebook(VAR_0, VAR_4->v1_codebook, VAR_4->v1_size, 0x22, 0x26, VAR_5 + VAR_13);
for(VAR_8 = VAR_7 = 0; VAR_7 < VAR_1; VAR_7 += MB_SIZE) {
for(VAR_6 = 0; VAR_6 < VAR_0->w; VAR_6 += MB_SIZE, VAR_8++) {
mb = &VAR_0->mb[VAR_8];
get_sub_picture(VAR_0, VAR_6, VAR_7, VAR_2, &sub_scratch);
if(VAR_4->mode == MODE_MC && mb->best_encoding == ENC_SKIP) {
get_sub_picture(VAR_0, VAR_6, VAR_7, VAR_3, &sub_last);
copy_mb(VAR_0, &sub_scratch, &sub_last);
} else if(VAR_4->mode == MODE_V1_ONLY || mb->best_encoding == ENC_V1)
decode_v1_vector(VAR_0, &sub_scratch, mb->v1_vector, VAR_4);
else
decode_v4_vector(VAR_0, &sub_scratch, mb->v4_vector, VAR_4);
}
}
switch(VAR_4->mode) {
case MODE_V1_ONLY:
VAR_13 += write_chunk_header(VAR_5 + VAR_13, 0x32, VAR_14);
for(VAR_6 = 0; VAR_6 < VAR_14; VAR_6++)
VAR_5[VAR_13++] = VAR_0->mb[VAR_6].v1_vector;
break;
case MODE_V1_V4:
VAR_12 = VAR_13;
VAR_13 += CHUNK_HEADER_SIZE;
for(VAR_6 = 0; VAR_6 < VAR_14; VAR_6 += 32) {
VAR_9 = 0;
for(VAR_7 = VAR_6; VAR_7 < FFMIN(VAR_6+32, VAR_14); VAR_7++)
if(VAR_0->mb[VAR_7].best_encoding == ENC_V4)
VAR_9 |= 1 << (31 - VAR_7 + VAR_6);
AV_WB32(&VAR_5[VAR_13], VAR_9);
VAR_13 += 4;
for(VAR_7 = VAR_6; VAR_7 < FFMIN(VAR_6+32, VAR_14); VAR_7++) {
mb = &VAR_0->mb[VAR_7];
if(mb->best_encoding == ENC_V1)
VAR_5[VAR_13++] = mb->v1_vector;
else
for(VAR_8 = 0; VAR_8 < 4; VAR_8++)
VAR_5[VAR_13++] = mb->v4_vector[VAR_8];
}
}
write_chunk_header(VAR_5 + VAR_12, 0x30, VAR_13 - VAR_12 - CHUNK_HEADER_SIZE);
break;
case MODE_MC:
VAR_12 = VAR_13;
VAR_13 += CHUNK_HEADER_SIZE;
VAR_9 = VAR_10 = VAR_11 = 0;
for(VAR_6 = 0; VAR_6 < VAR_14; VAR_6++) {
mb = &VAR_0->mb[VAR_6];
VAR_9 |= (mb->best_encoding != ENC_SKIP) << (31 - VAR_10++);
VAR_15 = 0;
VAR_16 = 0;
if(mb->best_encoding != ENC_SKIP) {
if(VAR_10 < 32)
VAR_9 |= (mb->best_encoding == ENC_V4) << (31 - VAR_10++);
else
VAR_15 = 1;
}
if(VAR_10 == 32) {
AV_WB32(&VAR_5[VAR_13], VAR_9);
VAR_13 += 4;
VAR_9 = VAR_10 = 0;
if(mb->best_encoding == ENC_SKIP || VAR_15) {
memcpy(&VAR_5[VAR_13], VAR_17, VAR_11);
VAR_13 += VAR_11;
VAR_11 = 0;
} else
VAR_16 = 1;
}
if(VAR_15) {
VAR_9 = (mb->best_encoding == ENC_V4) << 31;
VAR_10 = 1;
}
if(mb->best_encoding == ENC_V1)
VAR_17[VAR_11++] = mb->v1_vector;
else if(mb->best_encoding == ENC_V4)
for(VAR_8 = 0; VAR_8 < 4; VAR_8++)
VAR_17[VAR_11++] = mb->v4_vector[VAR_8];
if(VAR_16) {
memcpy(&VAR_5[VAR_13], VAR_17, VAR_11);
VAR_13 += VAR_11;
VAR_11 = 0;
}
}
if(VAR_10 > 0) {
AV_WB32(&VAR_5[VAR_13], VAR_9);
VAR_13 += 4;
memcpy(&VAR_5[VAR_13], VAR_17, VAR_11);
VAR_13 += VAR_11;
}
write_chunk_header(VAR_5 + VAR_12, 0x31, VAR_13 - VAR_12 - CHUNK_HEADER_SIZE);
break;
}
return VAR_13;
}
| [
"static int FUNC_0(CinepakEncContext *VAR_0, int VAR_1, AVPicture *VAR_2, AVPicture *VAR_3, strip_info *VAR_4, unsigned char *VAR_5)\n{",
"int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13 = 0, VAR_14 = VAR_0->w * VAR_1 / MB_AREA;",
"int VAR_15, VAR_16;",
"unsigned char VAR_17[64];",
"mb_info *... | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
25,
27
],
[
31,
33
],
[
39
],
[
41
],
[
43
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[... |
9,475 | void mips_malta_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
ram_addr_t ram_low_size;
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;
char *filename;
pflash_t *fl;
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *ram_high = g_new(MemoryRegion, 1);
MemoryRegion *ram_low_preio = g_new(MemoryRegion, 1);
MemoryRegion *ram_low_postio;
MemoryRegion *bios, *bios_copy = g_new(MemoryRegion, 1);
target_long bios_size = FLASH_SIZE;
const size_t smbus_eeprom_size = 8 * 256;
uint8_t *smbus_eeprom_buf = g_malloc0(smbus_eeprom_size);
int64_t kernel_entry, bootloader_run_addr;
PCIBus *pci_bus;
ISABus *isa_bus;
MIPSCPU *cpu;
CPUMIPSState *env;
qemu_irq *isa_irq;
int piix4_devfn;
I2CBus *smbus;
int i;
DriveInfo *dinfo;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *fd[MAX_FD];
int fl_idx = 0;
int fl_sectors = bios_size >> 16;
int be;
DeviceState *dev = qdev_create(NULL, TYPE_MIPS_MALTA);
MaltaState *s = MIPS_MALTA(dev);
/* The whole address space decoded by the GT-64120A doesn't generate
exception when accessing invalid memory. Create an empty slot to
emulate this feature. */
empty_slot_init(0, 0x20000000);
qdev_init_nofail(dev);
/* Make sure the first 3 serial ports are associated with a device. */
for(i = 0; i < 3; i++) {
if (!serial_hds[i]) {
char label[32];
snprintf(label, sizeof(label), "serial%d", i);
serial_hds[i] = qemu_chr_new(label, "null", NULL);
}
}
/* init CPUs */
if (cpu_model == NULL) {
#ifdef TARGET_MIPS64
cpu_model = "20Kc";
#else
cpu_model = "24Kf";
#endif
}
for (i = 0; i < smp_cpus; i++) {
cpu = cpu_mips_init(cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
env = &cpu->env;
/* Init internal devices */
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
qemu_register_reset(main_cpu_reset, cpu);
}
cpu = MIPS_CPU(first_cpu);
env = &cpu->env;
/* allocate RAM */
if (ram_size > (2048u << 20)) {
fprintf(stderr,
"qemu: Too much memory for this machine: %d MB, maximum 2048 MB\n",
((unsigned int)ram_size / (1 << 20)));
exit(1);
}
/* register RAM at high address where it is undisturbed by IO */
memory_region_allocate_system_memory(ram_high, NULL, "mips_malta.ram",
ram_size);
memory_region_add_subregion(system_memory, 0x80000000, ram_high);
/* alias for pre IO hole access */
memory_region_init_alias(ram_low_preio, NULL, "mips_malta_low_preio.ram",
ram_high, 0, MIN(ram_size, (256 << 20)));
memory_region_add_subregion(system_memory, 0, ram_low_preio);
/* alias for post IO hole access, if there is enough RAM */
if (ram_size > (512 << 20)) {
ram_low_postio = g_new(MemoryRegion, 1);
memory_region_init_alias(ram_low_postio, NULL,
"mips_malta_low_postio.ram",
ram_high, 512 << 20,
ram_size - (512 << 20));
memory_region_add_subregion(system_memory, 512 << 20, ram_low_postio);
}
/* generate SPD EEPROM data */
generate_eeprom_spd(&smbus_eeprom_buf[0 * 256], ram_size);
generate_eeprom_serial(&smbus_eeprom_buf[6 * 256]);
#ifdef TARGET_WORDS_BIGENDIAN
be = 1;
#else
be = 0;
#endif
/* FPGA */
/* The CBUS UART is attached to the MIPS CPU INT2 pin, ie interrupt 4 */
malta_fpga_init(system_memory, FPGA_ADDRESS, env->irq[4], serial_hds[2]);
/* Load firmware in flash / BIOS. */
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
#ifdef DEBUG_BOARD_INIT
if (dinfo) {
printf("Register parallel flash %d size " TARGET_FMT_lx " at "
"addr %08llx '%s' %x\n",
fl_idx, bios_size, FLASH_ADDRESS,
blk_name(dinfo->bdrv), fl_sectors);
}
#endif
fl = pflash_cfi01_register(FLASH_ADDRESS, NULL, "mips_malta.bios",
BIOS_SIZE,
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
65536, fl_sectors,
4, 0x0000, 0x0000, 0x0000, 0x0000, be);
bios = pflash_cfi01_get_memory(fl);
fl_idx++;
if (kernel_filename) {
ram_low_size = MIN(ram_size, 256 << 20);
/* For KVM we reserve 1MB of RAM for running bootloader */
if (kvm_enabled()) {
ram_low_size -= 0x100000;
bootloader_run_addr = 0x40000000 + ram_low_size;
} else {
bootloader_run_addr = 0xbfc00000;
}
/* Write a small bootloader to the flash location. */
loaderparams.ram_size = ram_size;
loaderparams.ram_low_size = ram_low_size;
loaderparams.kernel_filename = kernel_filename;
loaderparams.kernel_cmdline = kernel_cmdline;
loaderparams.initrd_filename = initrd_filename;
kernel_entry = load_kernel();
write_bootloader(memory_region_get_ram_ptr(bios),
bootloader_run_addr, kernel_entry);
if (kvm_enabled()) {
/* Write the bootloader code @ the end of RAM, 1MB reserved */
write_bootloader(memory_region_get_ram_ptr(ram_low_preio) +
ram_low_size,
bootloader_run_addr, kernel_entry);
}
} else {
/* The flash region isn't executable from a KVM guest */
if (kvm_enabled()) {
error_report("KVM enabled but no -kernel argument was specified. "
"Booting from flash is not supported with KVM.");
exit(1);
}
/* Load firmware from flash. */
if (!dinfo) {
/* Load a BIOS image. */
if (bios_name == NULL) {
bios_name = BIOS_FILENAME;
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_image_targphys(filename, FLASH_ADDRESS,
BIOS_SIZE);
g_free(filename);
} else {
bios_size = -1;
}
if ((bios_size < 0 || bios_size > BIOS_SIZE) &&
!kernel_filename && !qtest_enabled()) {
error_report("Could not load MIPS bios '%s', and no "
"-kernel argument was specified", bios_name);
exit(1);
}
}
/* In little endian mode the 32bit words in the bios are swapped,
a neat trick which allows bi-endian firmware. */
#ifndef TARGET_WORDS_BIGENDIAN
{
uint32_t *end, *addr = rom_ptr(FLASH_ADDRESS);
if (!addr) {
addr = memory_region_get_ram_ptr(bios);
}
end = (void *)addr + MIN(bios_size, 0x3e0000);
while (addr < end) {
bswap32s(addr);
addr++;
}
}
#endif
}
/*
* Map the BIOS at a 2nd physical location, as on the real board.
* Copy it so that we can patch in the MIPS revision, which cannot be
* handled by an overlapping region as the resulting ROM code subpage
* regions are not executable.
*/
memory_region_init_ram(bios_copy, NULL, "bios.1fc", BIOS_SIZE,
&error_fatal);
if (!rom_copy(memory_region_get_ram_ptr(bios_copy),
FLASH_ADDRESS, BIOS_SIZE)) {
memcpy(memory_region_get_ram_ptr(bios_copy),
memory_region_get_ram_ptr(bios), BIOS_SIZE);
}
memory_region_set_readonly(bios_copy, true);
memory_region_add_subregion(system_memory, RESET_ADDRESS, bios_copy);
/* Board ID = 0x420 (Malta Board with CoreLV) */
stl_p(memory_region_get_ram_ptr(bios_copy) + 0x10, 0x00000420);
/* Init internal devices */
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
/*
* We have a circular dependency problem: pci_bus depends on isa_irq,
* isa_irq is provided by i8259, i8259 depends on ISA, ISA depends
* on piix4, and piix4 depends on pci_bus. To stop the cycle we have
* qemu_irq_proxy() adds an extra bit of indirection, allowing us
* to resolve the isa_irq -> i8259 dependency after i8259 is initialized.
*/
isa_irq = qemu_irq_proxy(&s->i8259, 16);
/* Northbridge */
pci_bus = gt64120_register(isa_irq);
/* Southbridge */
ide_drive_get(hd, ARRAY_SIZE(hd));
piix4_devfn = piix4_init(pci_bus, &isa_bus, 80);
/* Interrupt controller */
/* The 8259 is attached to the MIPS CPU INT0 pin, ie interrupt 2 */
s->i8259 = i8259_init(isa_bus, env->irq[2]);
isa_bus_irqs(isa_bus, s->i8259);
pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1);
pci_create_simple(pci_bus, piix4_devfn + 2, "piix4-usb-uhci");
smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100,
isa_get_irq(NULL, 9), NULL, 0, NULL);
smbus_eeprom_init(smbus, 8, smbus_eeprom_buf, smbus_eeprom_size);
g_free(smbus_eeprom_buf);
pit = pit_init(isa_bus, 0x40, 0, NULL);
DMA_init(isa_bus, 0);
/* Super I/O */
isa_create_simple(isa_bus, "i8042");
rtc_init(isa_bus, 2000, NULL);
serial_hds_isa_init(isa_bus, 2);
parallel_hds_isa_init(isa_bus, 1);
for(i = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
}
fdctrl_init_isa(isa_bus, fd);
/* Network card */
network_init(pci_bus);
/* Optional PCI video card */
pci_vga_init(pci_bus);
}
| true | qemu | dc520a7dee0a9307e844eb6c5d4b21482bf52fcd | void mips_malta_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
ram_addr_t ram_low_size;
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;
char *filename;
pflash_t *fl;
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *ram_high = g_new(MemoryRegion, 1);
MemoryRegion *ram_low_preio = g_new(MemoryRegion, 1);
MemoryRegion *ram_low_postio;
MemoryRegion *bios, *bios_copy = g_new(MemoryRegion, 1);
target_long bios_size = FLASH_SIZE;
const size_t smbus_eeprom_size = 8 * 256;
uint8_t *smbus_eeprom_buf = g_malloc0(smbus_eeprom_size);
int64_t kernel_entry, bootloader_run_addr;
PCIBus *pci_bus;
ISABus *isa_bus;
MIPSCPU *cpu;
CPUMIPSState *env;
qemu_irq *isa_irq;
int piix4_devfn;
I2CBus *smbus;
int i;
DriveInfo *dinfo;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *fd[MAX_FD];
int fl_idx = 0;
int fl_sectors = bios_size >> 16;
int be;
DeviceState *dev = qdev_create(NULL, TYPE_MIPS_MALTA);
MaltaState *s = MIPS_MALTA(dev);
empty_slot_init(0, 0x20000000);
qdev_init_nofail(dev);
for(i = 0; i < 3; i++) {
if (!serial_hds[i]) {
char label[32];
snprintf(label, sizeof(label), "serial%d", i);
serial_hds[i] = qemu_chr_new(label, "null", NULL);
}
}
if (cpu_model == NULL) {
#ifdef TARGET_MIPS64
cpu_model = "20Kc";
#else
cpu_model = "24Kf";
#endif
}
for (i = 0; i < smp_cpus; i++) {
cpu = cpu_mips_init(cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
env = &cpu->env;
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
qemu_register_reset(main_cpu_reset, cpu);
}
cpu = MIPS_CPU(first_cpu);
env = &cpu->env;
if (ram_size > (2048u << 20)) {
fprintf(stderr,
"qemu: Too much memory for this machine: %d MB, maximum 2048 MB\n",
((unsigned int)ram_size / (1 << 20)));
exit(1);
}
memory_region_allocate_system_memory(ram_high, NULL, "mips_malta.ram",
ram_size);
memory_region_add_subregion(system_memory, 0x80000000, ram_high);
memory_region_init_alias(ram_low_preio, NULL, "mips_malta_low_preio.ram",
ram_high, 0, MIN(ram_size, (256 << 20)));
memory_region_add_subregion(system_memory, 0, ram_low_preio);
if (ram_size > (512 << 20)) {
ram_low_postio = g_new(MemoryRegion, 1);
memory_region_init_alias(ram_low_postio, NULL,
"mips_malta_low_postio.ram",
ram_high, 512 << 20,
ram_size - (512 << 20));
memory_region_add_subregion(system_memory, 512 << 20, ram_low_postio);
}
generate_eeprom_spd(&smbus_eeprom_buf[0 * 256], ram_size);
generate_eeprom_serial(&smbus_eeprom_buf[6 * 256]);
#ifdef TARGET_WORDS_BIGENDIAN
be = 1;
#else
be = 0;
#endif
malta_fpga_init(system_memory, FPGA_ADDRESS, env->irq[4], serial_hds[2]);
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
#ifdef DEBUG_BOARD_INIT
if (dinfo) {
printf("Register parallel flash %d size " TARGET_FMT_lx " at "
"addr %08llx '%s' %x\n",
fl_idx, bios_size, FLASH_ADDRESS,
blk_name(dinfo->bdrv), fl_sectors);
}
#endif
fl = pflash_cfi01_register(FLASH_ADDRESS, NULL, "mips_malta.bios",
BIOS_SIZE,
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
65536, fl_sectors,
4, 0x0000, 0x0000, 0x0000, 0x0000, be);
bios = pflash_cfi01_get_memory(fl);
fl_idx++;
if (kernel_filename) {
ram_low_size = MIN(ram_size, 256 << 20);
if (kvm_enabled()) {
ram_low_size -= 0x100000;
bootloader_run_addr = 0x40000000 + ram_low_size;
} else {
bootloader_run_addr = 0xbfc00000;
}
loaderparams.ram_size = ram_size;
loaderparams.ram_low_size = ram_low_size;
loaderparams.kernel_filename = kernel_filename;
loaderparams.kernel_cmdline = kernel_cmdline;
loaderparams.initrd_filename = initrd_filename;
kernel_entry = load_kernel();
write_bootloader(memory_region_get_ram_ptr(bios),
bootloader_run_addr, kernel_entry);
if (kvm_enabled()) {
write_bootloader(memory_region_get_ram_ptr(ram_low_preio) +
ram_low_size,
bootloader_run_addr, kernel_entry);
}
} else {
if (kvm_enabled()) {
error_report("KVM enabled but no -kernel argument was specified. "
"Booting from flash is not supported with KVM.");
exit(1);
}
if (!dinfo) {
if (bios_name == NULL) {
bios_name = BIOS_FILENAME;
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_image_targphys(filename, FLASH_ADDRESS,
BIOS_SIZE);
g_free(filename);
} else {
bios_size = -1;
}
if ((bios_size < 0 || bios_size > BIOS_SIZE) &&
!kernel_filename && !qtest_enabled()) {
error_report("Could not load MIPS bios '%s', and no "
"-kernel argument was specified", bios_name);
exit(1);
}
}
#ifndef TARGET_WORDS_BIGENDIAN
{
uint32_t *end, *addr = rom_ptr(FLASH_ADDRESS);
if (!addr) {
addr = memory_region_get_ram_ptr(bios);
}
end = (void *)addr + MIN(bios_size, 0x3e0000);
while (addr < end) {
bswap32s(addr);
addr++;
}
}
#endif
}
memory_region_init_ram(bios_copy, NULL, "bios.1fc", BIOS_SIZE,
&error_fatal);
if (!rom_copy(memory_region_get_ram_ptr(bios_copy),
FLASH_ADDRESS, BIOS_SIZE)) {
memcpy(memory_region_get_ram_ptr(bios_copy),
memory_region_get_ram_ptr(bios), BIOS_SIZE);
}
memory_region_set_readonly(bios_copy, true);
memory_region_add_subregion(system_memory, RESET_ADDRESS, bios_copy);
stl_p(memory_region_get_ram_ptr(bios_copy) + 0x10, 0x00000420);
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
isa_irq = qemu_irq_proxy(&s->i8259, 16);
pci_bus = gt64120_register(isa_irq);
ide_drive_get(hd, ARRAY_SIZE(hd));
piix4_devfn = piix4_init(pci_bus, &isa_bus, 80);
s->i8259 = i8259_init(isa_bus, env->irq[2]);
isa_bus_irqs(isa_bus, s->i8259);
pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1);
pci_create_simple(pci_bus, piix4_devfn + 2, "piix4-usb-uhci");
smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100,
isa_get_irq(NULL, 9), NULL, 0, NULL);
smbus_eeprom_init(smbus, 8, smbus_eeprom_buf, smbus_eeprom_size);
g_free(smbus_eeprom_buf);
pit = pit_init(isa_bus, 0x40, 0, NULL);
DMA_init(isa_bus, 0);
isa_create_simple(isa_bus, "i8042");
rtc_init(isa_bus, 2000, NULL);
serial_hds_isa_init(isa_bus, 2);
parallel_hds_isa_init(isa_bus, 1);
for(i = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
}
fdctrl_init_isa(isa_bus, fd);
network_init(pci_bus);
pci_vga_init(pci_bus);
}
| {
"code": [
" cpu_mips_irq_init_cpu(env);",
" cpu_mips_clock_init(env);"
],
"line_no": [
455,
457
]
} | void FUNC_0(MachineState *VAR_0)
{
ram_addr_t ram_size = VAR_0->ram_size;
ram_addr_t ram_low_size;
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;
char *VAR_5;
pflash_t *fl;
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *ram_high = g_new(MemoryRegion, 1);
MemoryRegion *ram_low_preio = g_new(MemoryRegion, 1);
MemoryRegion *ram_low_postio;
MemoryRegion *bios, *bios_copy = g_new(MemoryRegion, 1);
target_long bios_size = FLASH_SIZE;
const size_t VAR_6 = 8 * 256;
uint8_t *smbus_eeprom_buf = g_malloc0(VAR_6);
int64_t kernel_entry, bootloader_run_addr;
PCIBus *pci_bus;
ISABus *isa_bus;
MIPSCPU *cpu;
CPUMIPSState *env;
qemu_irq *isa_irq;
int VAR_7;
I2CBus *smbus;
int VAR_8;
DriveInfo *dinfo;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *fd[MAX_FD];
int VAR_9 = 0;
int VAR_10 = bios_size >> 16;
int VAR_11;
DeviceState *dev = qdev_create(NULL, TYPE_MIPS_MALTA);
MaltaState *s = MIPS_MALTA(dev);
empty_slot_init(0, 0x20000000);
qdev_init_nofail(dev);
for(VAR_8 = 0; VAR_8 < 3; VAR_8++) {
if (!serial_hds[VAR_8]) {
char VAR_12[32];
snprintf(VAR_12, sizeof(VAR_12), "serial%d", VAR_8);
serial_hds[VAR_8] = qemu_chr_new(VAR_12, "null", NULL);
}
}
if (VAR_1 == NULL) {
#ifdef TARGET_MIPS64
VAR_1 = "20Kc";
#else
VAR_1 = "24Kf";
#endif
}
for (VAR_8 = 0; VAR_8 < smp_cpus; VAR_8++) {
cpu = cpu_mips_init(VAR_1);
if (cpu == NULL) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
env = &cpu->env;
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
qemu_register_reset(main_cpu_reset, cpu);
}
cpu = MIPS_CPU(first_cpu);
env = &cpu->env;
if (ram_size > (2048u << 20)) {
fprintf(stderr,
"qemu: Too much memory for this VAR_0: %d MB, maximum 2048 MB\n",
((unsigned int)ram_size / (1 << 20)));
exit(1);
}
memory_region_allocate_system_memory(ram_high, NULL, "mips_malta.ram",
ram_size);
memory_region_add_subregion(system_memory, 0x80000000, ram_high);
memory_region_init_alias(ram_low_preio, NULL, "mips_malta_low_preio.ram",
ram_high, 0, MIN(ram_size, (256 << 20)));
memory_region_add_subregion(system_memory, 0, ram_low_preio);
if (ram_size > (512 << 20)) {
ram_low_postio = g_new(MemoryRegion, 1);
memory_region_init_alias(ram_low_postio, NULL,
"mips_malta_low_postio.ram",
ram_high, 512 << 20,
ram_size - (512 << 20));
memory_region_add_subregion(system_memory, 512 << 20, ram_low_postio);
}
generate_eeprom_spd(&smbus_eeprom_buf[0 * 256], ram_size);
generate_eeprom_serial(&smbus_eeprom_buf[6 * 256]);
#ifdef TARGET_WORDS_BIGENDIAN
VAR_11 = 1;
#else
VAR_11 = 0;
#endif
malta_fpga_init(system_memory, FPGA_ADDRESS, env->irq[4], serial_hds[2]);
dinfo = drive_get(IF_PFLASH, 0, VAR_9);
#ifdef DEBUG_BOARD_INIT
if (dinfo) {
printf("Register parallel flash %d size " TARGET_FMT_lx " at "
"addr %08llx '%s' %x\n",
VAR_9, bios_size, FLASH_ADDRESS,
blk_name(dinfo->bdrv), VAR_10);
}
#endif
fl = pflash_cfi01_register(FLASH_ADDRESS, NULL, "mips_malta.bios",
BIOS_SIZE,
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
65536, VAR_10,
4, 0x0000, 0x0000, 0x0000, 0x0000, VAR_11);
bios = pflash_cfi01_get_memory(fl);
VAR_9++;
if (VAR_2) {
ram_low_size = MIN(ram_size, 256 << 20);
if (kvm_enabled()) {
ram_low_size -= 0x100000;
bootloader_run_addr = 0x40000000 + ram_low_size;
} else {
bootloader_run_addr = 0xbfc00000;
}
loaderparams.ram_size = ram_size;
loaderparams.ram_low_size = ram_low_size;
loaderparams.VAR_2 = VAR_2;
loaderparams.VAR_3 = VAR_3;
loaderparams.VAR_4 = VAR_4;
kernel_entry = load_kernel();
write_bootloader(memory_region_get_ram_ptr(bios),
bootloader_run_addr, kernel_entry);
if (kvm_enabled()) {
write_bootloader(memory_region_get_ram_ptr(ram_low_preio) +
ram_low_size,
bootloader_run_addr, kernel_entry);
}
} else {
if (kvm_enabled()) {
error_report("KVM enabled but no -kernel argument was specified. "
"Booting from flash is not supported with KVM.");
exit(1);
}
if (!dinfo) {
if (bios_name == NULL) {
bios_name = BIOS_FILENAME;
}
VAR_5 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (VAR_5) {
bios_size = load_image_targphys(VAR_5, FLASH_ADDRESS,
BIOS_SIZE);
g_free(VAR_5);
} else {
bios_size = -1;
}
if ((bios_size < 0 || bios_size > BIOS_SIZE) &&
!VAR_2 && !qtest_enabled()) {
error_report("Could not load MIPS bios '%s', and no "
"-kernel argument was specified", bios_name);
exit(1);
}
}
#ifndef TARGET_WORDS_BIGENDIAN
{
uint32_t *end, *addr = rom_ptr(FLASH_ADDRESS);
if (!addr) {
addr = memory_region_get_ram_ptr(bios);
}
end = (void *)addr + MIN(bios_size, 0x3e0000);
while (addr < end) {
bswap32s(addr);
addr++;
}
}
#endif
}
memory_region_init_ram(bios_copy, NULL, "bios.1fc", BIOS_SIZE,
&error_fatal);
if (!rom_copy(memory_region_get_ram_ptr(bios_copy),
FLASH_ADDRESS, BIOS_SIZE)) {
memcpy(memory_region_get_ram_ptr(bios_copy),
memory_region_get_ram_ptr(bios), BIOS_SIZE);
}
memory_region_set_readonly(bios_copy, true);
memory_region_add_subregion(system_memory, RESET_ADDRESS, bios_copy);
stl_p(memory_region_get_ram_ptr(bios_copy) + 0x10, 0x00000420);
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
isa_irq = qemu_irq_proxy(&s->i8259, 16);
pci_bus = gt64120_register(isa_irq);
ide_drive_get(hd, ARRAY_SIZE(hd));
VAR_7 = piix4_init(pci_bus, &isa_bus, 80);
s->i8259 = i8259_init(isa_bus, env->irq[2]);
isa_bus_irqs(isa_bus, s->i8259);
pci_piix4_ide_init(pci_bus, hd, VAR_7 + 1);
pci_create_simple(pci_bus, VAR_7 + 2, "piix4-usb-uhci");
smbus = piix4_pm_init(pci_bus, VAR_7 + 3, 0x1100,
isa_get_irq(NULL, 9), NULL, 0, NULL);
smbus_eeprom_init(smbus, 8, smbus_eeprom_buf, VAR_6);
g_free(smbus_eeprom_buf);
pit = pit_init(isa_bus, 0x40, 0, NULL);
DMA_init(isa_bus, 0);
isa_create_simple(isa_bus, "i8042");
rtc_init(isa_bus, 2000, NULL);
serial_hds_isa_init(isa_bus, 2);
parallel_hds_isa_init(isa_bus, 1);
for(VAR_8 = 0; VAR_8 < MAX_FD; VAR_8++) {
fd[VAR_8] = drive_get(IF_FLOPPY, 0, VAR_8);
}
fdctrl_init_isa(isa_bus, fd);
network_init(pci_bus);
pci_vga_init(pci_bus);
}
| [
"void FUNC_0(MachineState *VAR_0)\n{",
"ram_addr_t ram_size = VAR_0->ram_size;",
"ram_addr_t ram_low_size;",
"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;",
"char *VAR_5;",
"pflash_t *fl;",
"MemoryR... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
... |
9,476 | static void video_refresh(void *opaque, double *remaining_time)
{
VideoState *is = opaque;
VideoPicture *vp;
double time;
SubPicture *sp, *sp2;
if (!is->paused && get_master_sync_type(is) == AV_SYNC_EXTERNAL_CLOCK && is->realtime)
check_external_clock_speed(is);
if (!display_disable && is->show_mode != SHOW_MODE_VIDEO && is->audio_st) {
time = av_gettime() / 1000000.0;
if (is->force_refresh || is->last_vis_time + rdftspeed < time) {
video_display(is);
is->last_vis_time = time;
}
*remaining_time = FFMIN(*remaining_time, is->last_vis_time + rdftspeed - time);
}
if (is->video_st) {
int redisplay = 0;
if (is->force_refresh)
redisplay = pictq_prev_picture(is);
retry:
if (is->pictq_size == 0) {
SDL_LockMutex(is->pictq_mutex);
if (is->frame_last_dropped_pts != AV_NOPTS_VALUE && is->frame_last_dropped_pts > is->frame_last_pts) {
update_video_pts(is, is->frame_last_dropped_pts, is->frame_last_dropped_pos, is->frame_last_dropped_serial);
is->frame_last_dropped_pts = AV_NOPTS_VALUE;
}
SDL_UnlockMutex(is->pictq_mutex);
// nothing to do, no picture to display in the queue
} else {
double last_duration, duration, delay;
/* dequeue the picture */
vp = &is->pictq[is->pictq_rindex];
if (vp->serial != is->videoq.serial) {
pictq_next_picture(is);
redisplay = 0;
goto retry;
}
if (is->paused)
goto display;
/* compute nominal last_duration */
last_duration = vp->pts - is->frame_last_pts;
if (!isnan(last_duration) && last_duration > 0 && last_duration < is->max_frame_duration) {
/* if duration of the last frame was sane, update last_duration in video state */
is->frame_last_duration = last_duration;
}
if (redisplay)
delay = 0.0;
else
delay = compute_target_delay(is->frame_last_duration, is);
time= av_gettime()/1000000.0;
if (time < is->frame_timer + delay && !redisplay) {
*remaining_time = FFMIN(is->frame_timer + delay - time, *remaining_time);
return;
}
is->frame_timer += delay;
if (delay > 0 && time - is->frame_timer > AV_SYNC_THRESHOLD_MAX)
is->frame_timer = time;
SDL_LockMutex(is->pictq_mutex);
if (!redisplay && !isnan(vp->pts))
update_video_pts(is, vp->pts, vp->pos, vp->serial);
SDL_UnlockMutex(is->pictq_mutex);
if (is->pictq_size > 1) {
VideoPicture *nextvp = &is->pictq[(is->pictq_rindex + 1) % VIDEO_PICTURE_QUEUE_SIZE];
duration = nextvp->pts - vp->pts;
if(!is->step && (redisplay || framedrop>0 || (framedrop && get_master_sync_type(is) != AV_SYNC_VIDEO_MASTER)) && time > is->frame_timer + duration){
if (!redisplay)
is->frame_drops_late++;
pictq_next_picture(is);
redisplay = 0;
goto retry;
}
}
if (is->subtitle_st) {
while (is->subpq_size > 0) {
sp = &is->subpq[is->subpq_rindex];
if (is->subpq_size > 1)
sp2 = &is->subpq[(is->subpq_rindex + 1) % SUBPICTURE_QUEUE_SIZE];
else
sp2 = NULL;
if (sp->serial != is->subtitleq.serial
|| (is->vidclk.pts > (sp->pts + ((float) sp->sub.end_display_time / 1000)))
|| (sp2 && is->vidclk.pts > (sp2->pts + ((float) sp2->sub.start_display_time / 1000))))
{
free_subpicture(sp);
/* update queue size and signal for next picture */
if (++is->subpq_rindex == SUBPICTURE_QUEUE_SIZE)
is->subpq_rindex = 0;
SDL_LockMutex(is->subpq_mutex);
is->subpq_size--;
SDL_CondSignal(is->subpq_cond);
SDL_UnlockMutex(is->subpq_mutex);
} else {
break;
}
}
}
display:
/* display picture */
if (!display_disable && is->show_mode == SHOW_MODE_VIDEO)
video_display(is);
pictq_next_picture(is);
if (is->step && !is->paused)
stream_toggle_pause(is);
}
}
is->force_refresh = 0;
if (show_status) {
static int64_t last_time;
int64_t cur_time;
int aqsize, vqsize, sqsize;
double av_diff;
cur_time = av_gettime();
if (!last_time || (cur_time - last_time) >= 30000) {
aqsize = 0;
vqsize = 0;
sqsize = 0;
if (is->audio_st)
aqsize = is->audioq.size;
if (is->video_st)
vqsize = is->videoq.size;
if (is->subtitle_st)
sqsize = is->subtitleq.size;
av_diff = 0;
if (is->audio_st && is->video_st)
av_diff = get_clock(&is->audclk) - get_clock(&is->vidclk);
else if (is->video_st)
av_diff = get_master_clock(is) - get_clock(&is->vidclk);
else if (is->audio_st)
av_diff = get_master_clock(is) - get_clock(&is->audclk);
av_log(NULL, AV_LOG_INFO,
"%7.2f %s:%7.3f fd=%4d aq=%5dKB vq=%5dKB sq=%5dB f=%"PRId64"/%"PRId64" \r",
get_master_clock(is),
(is->audio_st && is->video_st) ? "A-V" : (is->video_st ? "M-V" : (is->audio_st ? "M-A" : " ")),
av_diff,
is->frame_drops_early + is->frame_drops_late,
aqsize / 1024,
vqsize / 1024,
sqsize,
is->video_st ? is->video_st->codec->pts_correction_num_faulty_dts : 0,
is->video_st ? is->video_st->codec->pts_correction_num_faulty_pts : 0);
fflush(stdout);
last_time = cur_time;
}
}
}
| false | FFmpeg | 5ecfcc7dff04ff0e86d8b6b3a33709ae956dfef7 | static void video_refresh(void *opaque, double *remaining_time)
{
VideoState *is = opaque;
VideoPicture *vp;
double time;
SubPicture *sp, *sp2;
if (!is->paused && get_master_sync_type(is) == AV_SYNC_EXTERNAL_CLOCK && is->realtime)
check_external_clock_speed(is);
if (!display_disable && is->show_mode != SHOW_MODE_VIDEO && is->audio_st) {
time = av_gettime() / 1000000.0;
if (is->force_refresh || is->last_vis_time + rdftspeed < time) {
video_display(is);
is->last_vis_time = time;
}
*remaining_time = FFMIN(*remaining_time, is->last_vis_time + rdftspeed - time);
}
if (is->video_st) {
int redisplay = 0;
if (is->force_refresh)
redisplay = pictq_prev_picture(is);
retry:
if (is->pictq_size == 0) {
SDL_LockMutex(is->pictq_mutex);
if (is->frame_last_dropped_pts != AV_NOPTS_VALUE && is->frame_last_dropped_pts > is->frame_last_pts) {
update_video_pts(is, is->frame_last_dropped_pts, is->frame_last_dropped_pos, is->frame_last_dropped_serial);
is->frame_last_dropped_pts = AV_NOPTS_VALUE;
}
SDL_UnlockMutex(is->pictq_mutex);
} else {
double last_duration, duration, delay;
vp = &is->pictq[is->pictq_rindex];
if (vp->serial != is->videoq.serial) {
pictq_next_picture(is);
redisplay = 0;
goto retry;
}
if (is->paused)
goto display;
last_duration = vp->pts - is->frame_last_pts;
if (!isnan(last_duration) && last_duration > 0 && last_duration < is->max_frame_duration) {
is->frame_last_duration = last_duration;
}
if (redisplay)
delay = 0.0;
else
delay = compute_target_delay(is->frame_last_duration, is);
time= av_gettime()/1000000.0;
if (time < is->frame_timer + delay && !redisplay) {
*remaining_time = FFMIN(is->frame_timer + delay - time, *remaining_time);
return;
}
is->frame_timer += delay;
if (delay > 0 && time - is->frame_timer > AV_SYNC_THRESHOLD_MAX)
is->frame_timer = time;
SDL_LockMutex(is->pictq_mutex);
if (!redisplay && !isnan(vp->pts))
update_video_pts(is, vp->pts, vp->pos, vp->serial);
SDL_UnlockMutex(is->pictq_mutex);
if (is->pictq_size > 1) {
VideoPicture *nextvp = &is->pictq[(is->pictq_rindex + 1) % VIDEO_PICTURE_QUEUE_SIZE];
duration = nextvp->pts - vp->pts;
if(!is->step && (redisplay || framedrop>0 || (framedrop && get_master_sync_type(is) != AV_SYNC_VIDEO_MASTER)) && time > is->frame_timer + duration){
if (!redisplay)
is->frame_drops_late++;
pictq_next_picture(is);
redisplay = 0;
goto retry;
}
}
if (is->subtitle_st) {
while (is->subpq_size > 0) {
sp = &is->subpq[is->subpq_rindex];
if (is->subpq_size > 1)
sp2 = &is->subpq[(is->subpq_rindex + 1) % SUBPICTURE_QUEUE_SIZE];
else
sp2 = NULL;
if (sp->serial != is->subtitleq.serial
|| (is->vidclk.pts > (sp->pts + ((float) sp->sub.end_display_time / 1000)))
|| (sp2 && is->vidclk.pts > (sp2->pts + ((float) sp2->sub.start_display_time / 1000))))
{
free_subpicture(sp);
if (++is->subpq_rindex == SUBPICTURE_QUEUE_SIZE)
is->subpq_rindex = 0;
SDL_LockMutex(is->subpq_mutex);
is->subpq_size--;
SDL_CondSignal(is->subpq_cond);
SDL_UnlockMutex(is->subpq_mutex);
} else {
break;
}
}
}
display:
if (!display_disable && is->show_mode == SHOW_MODE_VIDEO)
video_display(is);
pictq_next_picture(is);
if (is->step && !is->paused)
stream_toggle_pause(is);
}
}
is->force_refresh = 0;
if (show_status) {
static int64_t last_time;
int64_t cur_time;
int aqsize, vqsize, sqsize;
double av_diff;
cur_time = av_gettime();
if (!last_time || (cur_time - last_time) >= 30000) {
aqsize = 0;
vqsize = 0;
sqsize = 0;
if (is->audio_st)
aqsize = is->audioq.size;
if (is->video_st)
vqsize = is->videoq.size;
if (is->subtitle_st)
sqsize = is->subtitleq.size;
av_diff = 0;
if (is->audio_st && is->video_st)
av_diff = get_clock(&is->audclk) - get_clock(&is->vidclk);
else if (is->video_st)
av_diff = get_master_clock(is) - get_clock(&is->vidclk);
else if (is->audio_st)
av_diff = get_master_clock(is) - get_clock(&is->audclk);
av_log(NULL, AV_LOG_INFO,
"%7.2f %s:%7.3f fd=%4d aq=%5dKB vq=%5dKB sq=%5dB f=%"PRId64"/%"PRId64" \r",
get_master_clock(is),
(is->audio_st && is->video_st) ? "A-V" : (is->video_st ? "M-V" : (is->audio_st ? "M-A" : " ")),
av_diff,
is->frame_drops_early + is->frame_drops_late,
aqsize / 1024,
vqsize / 1024,
sqsize,
is->video_st ? is->video_st->codec->pts_correction_num_faulty_dts : 0,
is->video_st ? is->video_st->codec->pts_correction_num_faulty_pts : 0);
fflush(stdout);
last_time = cur_time;
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, double *VAR_1)
{
VideoState *is = VAR_0;
VideoPicture *vp;
double VAR_2;
SubPicture *sp, *sp2;
if (!is->paused && get_master_sync_type(is) == AV_SYNC_EXTERNAL_CLOCK && is->realtime)
check_external_clock_speed(is);
if (!display_disable && is->show_mode != SHOW_MODE_VIDEO && is->audio_st) {
VAR_2 = av_gettime() / 1000000.0;
if (is->force_refresh || is->last_vis_time + rdftspeed < VAR_2) {
video_display(is);
is->last_vis_time = VAR_2;
}
*VAR_1 = FFMIN(*VAR_1, is->last_vis_time + rdftspeed - VAR_2);
}
if (is->video_st) {
int VAR_3 = 0;
if (is->force_refresh)
VAR_3 = pictq_prev_picture(is);
retry:
if (is->pictq_size == 0) {
SDL_LockMutex(is->pictq_mutex);
if (is->frame_last_dropped_pts != AV_NOPTS_VALUE && is->frame_last_dropped_pts > is->frame_last_pts) {
update_video_pts(is, is->frame_last_dropped_pts, is->frame_last_dropped_pos, is->frame_last_dropped_serial);
is->frame_last_dropped_pts = AV_NOPTS_VALUE;
}
SDL_UnlockMutex(is->pictq_mutex);
} else {
double VAR_4, VAR_5, VAR_6;
vp = &is->pictq[is->pictq_rindex];
if (vp->serial != is->videoq.serial) {
pictq_next_picture(is);
VAR_3 = 0;
goto retry;
}
if (is->paused)
goto display;
VAR_4 = vp->pts - is->frame_last_pts;
if (!isnan(VAR_4) && VAR_4 > 0 && VAR_4 < is->max_frame_duration) {
is->frame_last_duration = VAR_4;
}
if (VAR_3)
VAR_6 = 0.0;
else
VAR_6 = compute_target_delay(is->frame_last_duration, is);
VAR_2= av_gettime()/1000000.0;
if (VAR_2 < is->frame_timer + VAR_6 && !VAR_3) {
*VAR_1 = FFMIN(is->frame_timer + VAR_6 - VAR_2, *VAR_1);
return;
}
is->frame_timer += VAR_6;
if (VAR_6 > 0 && VAR_2 - is->frame_timer > AV_SYNC_THRESHOLD_MAX)
is->frame_timer = VAR_2;
SDL_LockMutex(is->pictq_mutex);
if (!VAR_3 && !isnan(vp->pts))
update_video_pts(is, vp->pts, vp->pos, vp->serial);
SDL_UnlockMutex(is->pictq_mutex);
if (is->pictq_size > 1) {
VideoPicture *nextvp = &is->pictq[(is->pictq_rindex + 1) % VIDEO_PICTURE_QUEUE_SIZE];
VAR_5 = nextvp->pts - vp->pts;
if(!is->step && (VAR_3 || framedrop>0 || (framedrop && get_master_sync_type(is) != AV_SYNC_VIDEO_MASTER)) && VAR_2 > is->frame_timer + VAR_5){
if (!VAR_3)
is->frame_drops_late++;
pictq_next_picture(is);
VAR_3 = 0;
goto retry;
}
}
if (is->subtitle_st) {
while (is->subpq_size > 0) {
sp = &is->subpq[is->subpq_rindex];
if (is->subpq_size > 1)
sp2 = &is->subpq[(is->subpq_rindex + 1) % SUBPICTURE_QUEUE_SIZE];
else
sp2 = NULL;
if (sp->serial != is->subtitleq.serial
|| (is->vidclk.pts > (sp->pts + ((float) sp->sub.end_display_time / 1000)))
|| (sp2 && is->vidclk.pts > (sp2->pts + ((float) sp2->sub.start_display_time / 1000))))
{
free_subpicture(sp);
if (++is->subpq_rindex == SUBPICTURE_QUEUE_SIZE)
is->subpq_rindex = 0;
SDL_LockMutex(is->subpq_mutex);
is->subpq_size--;
SDL_CondSignal(is->subpq_cond);
SDL_UnlockMutex(is->subpq_mutex);
} else {
break;
}
}
}
display:
if (!display_disable && is->show_mode == SHOW_MODE_VIDEO)
video_display(is);
pictq_next_picture(is);
if (is->step && !is->paused)
stream_toggle_pause(is);
}
}
is->force_refresh = 0;
if (show_status) {
static int64_t VAR_7;
int64_t cur_time;
int VAR_8, VAR_9, VAR_10;
double VAR_11;
cur_time = av_gettime();
if (!VAR_7 || (cur_time - VAR_7) >= 30000) {
VAR_8 = 0;
VAR_9 = 0;
VAR_10 = 0;
if (is->audio_st)
VAR_8 = is->audioq.size;
if (is->video_st)
VAR_9 = is->videoq.size;
if (is->subtitle_st)
VAR_10 = is->subtitleq.size;
VAR_11 = 0;
if (is->audio_st && is->video_st)
VAR_11 = get_clock(&is->audclk) - get_clock(&is->vidclk);
else if (is->video_st)
VAR_11 = get_master_clock(is) - get_clock(&is->vidclk);
else if (is->audio_st)
VAR_11 = get_master_clock(is) - get_clock(&is->audclk);
av_log(NULL, AV_LOG_INFO,
"%7.2f %s:%7.3f fd=%4d aq=%5dKB vq=%5dKB sq=%5dB f=%"PRId64"/%"PRId64" \r",
get_master_clock(is),
(is->audio_st && is->video_st) ? "A-V" : (is->video_st ? "M-V" : (is->audio_st ? "M-A" : " ")),
VAR_11,
is->frame_drops_early + is->frame_drops_late,
VAR_8 / 1024,
VAR_9 / 1024,
VAR_10,
is->video_st ? is->video_st->codec->pts_correction_num_faulty_dts : 0,
is->video_st ? is->video_st->codec->pts_correction_num_faulty_pts : 0);
fflush(stdout);
VAR_7 = cur_time;
}
}
}
| [
"static void FUNC_0(void *VAR_0, double *VAR_1)\n{",
"VideoState *is = VAR_0;",
"VideoPicture *vp;",
"double VAR_2;",
"SubPicture *sp, *sp2;",
"if (!is->paused && get_master_sync_type(is) == AV_SYNC_EXTERNAL_CLOCK && is->realtime)\ncheck_external_clock_speed(is);",
"if (!display_disable && is->show_mode... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17,
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45,
47
],
[
49,
51
],
[... |
9,477 | static void extrapolate_isf(float out[LP_ORDER_16k], float isf[LP_ORDER])
{
float diff_isf[LP_ORDER - 2], diff_mean;
float *diff_hi = diff_isf - LP_ORDER + 1; // diff array for extrapolated indexes
float corr_lag[3];
float est, scale;
int i, i_max_corr;
memcpy(out, isf, (LP_ORDER - 1) * sizeof(float));
out[LP_ORDER_16k - 1] = isf[LP_ORDER - 1];
/* Calculate the difference vector */
for (i = 0; i < LP_ORDER - 2; i++)
diff_isf[i] = isf[i + 1] - isf[i];
diff_mean = 0.0;
for (i = 2; i < LP_ORDER - 2; i++)
diff_mean += diff_isf[i] * (1.0f / (LP_ORDER - 4));
/* Find which is the maximum autocorrelation */
i_max_corr = 0;
for (i = 0; i < 3; i++) {
corr_lag[i] = auto_correlation(diff_isf, diff_mean, i + 2);
if (corr_lag[i] > corr_lag[i_max_corr])
i_max_corr = i;
}
i_max_corr++;
for (i = LP_ORDER - 1; i < LP_ORDER_16k - 1; i++)
out[i] = isf[i - 1] + isf[i - 1 - i_max_corr]
- isf[i - 2 - i_max_corr];
/* Calculate an estimate for ISF(18) and scale ISF based on the error */
est = 7965 + (out[2] - out[3] - out[4]) / 6.0;
scale = 0.5 * (FFMIN(est, 7600) - out[LP_ORDER - 2]) /
(out[LP_ORDER_16k - 2] - out[LP_ORDER - 2]);
for (i = LP_ORDER - 1; i < LP_ORDER_16k - 1; i++)
diff_hi[i] = scale * (out[i] - out[i - 1]);
/* Stability insurance */
for (i = LP_ORDER; i < LP_ORDER_16k - 1; i++)
if (diff_hi[i] + diff_hi[i - 1] < 5.0) {
if (diff_hi[i] > diff_hi[i - 1]) {
diff_hi[i - 1] = 5.0 - diff_hi[i];
} else
diff_hi[i] = 5.0 - diff_hi[i - 1];
}
for (i = LP_ORDER - 1; i < LP_ORDER_16k - 1; i++)
out[i] = out[i - 1] + diff_hi[i] * (1.0f / (1 << 15));
/* Scale the ISF vector for 16000 Hz */
for (i = 0; i < LP_ORDER_16k - 1; i++)
out[i] *= 0.8;
}
| false | FFmpeg | 9d87374ec0f382c8394ad511243db6980afa42af | static void extrapolate_isf(float out[LP_ORDER_16k], float isf[LP_ORDER])
{
float diff_isf[LP_ORDER - 2], diff_mean;
float *diff_hi = diff_isf - LP_ORDER + 1;
float corr_lag[3];
float est, scale;
int i, i_max_corr;
memcpy(out, isf, (LP_ORDER - 1) * sizeof(float));
out[LP_ORDER_16k - 1] = isf[LP_ORDER - 1];
for (i = 0; i < LP_ORDER - 2; i++)
diff_isf[i] = isf[i + 1] - isf[i];
diff_mean = 0.0;
for (i = 2; i < LP_ORDER - 2; i++)
diff_mean += diff_isf[i] * (1.0f / (LP_ORDER - 4));
i_max_corr = 0;
for (i = 0; i < 3; i++) {
corr_lag[i] = auto_correlation(diff_isf, diff_mean, i + 2);
if (corr_lag[i] > corr_lag[i_max_corr])
i_max_corr = i;
}
i_max_corr++;
for (i = LP_ORDER - 1; i < LP_ORDER_16k - 1; i++)
out[i] = isf[i - 1] + isf[i - 1 - i_max_corr]
- isf[i - 2 - i_max_corr];
est = 7965 + (out[2] - out[3] - out[4]) / 6.0;
scale = 0.5 * (FFMIN(est, 7600) - out[LP_ORDER - 2]) /
(out[LP_ORDER_16k - 2] - out[LP_ORDER - 2]);
for (i = LP_ORDER - 1; i < LP_ORDER_16k - 1; i++)
diff_hi[i] = scale * (out[i] - out[i - 1]);
for (i = LP_ORDER; i < LP_ORDER_16k - 1; i++)
if (diff_hi[i] + diff_hi[i - 1] < 5.0) {
if (diff_hi[i] > diff_hi[i - 1]) {
diff_hi[i - 1] = 5.0 - diff_hi[i];
} else
diff_hi[i] = 5.0 - diff_hi[i - 1];
}
for (i = LP_ORDER - 1; i < LP_ORDER_16k - 1; i++)
out[i] = out[i - 1] + diff_hi[i] * (1.0f / (1 << 15));
for (i = 0; i < LP_ORDER_16k - 1; i++)
out[i] *= 0.8;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(float VAR_0[LP_ORDER_16k], float VAR_1[LP_ORDER])
{
float VAR_2[LP_ORDER - 2], diff_mean;
float *VAR_3 = VAR_2 - LP_ORDER + 1;
float VAR_4[3];
float VAR_5, VAR_6;
int VAR_7, VAR_8;
memcpy(VAR_0, VAR_1, (LP_ORDER - 1) * sizeof(float));
VAR_0[LP_ORDER_16k - 1] = VAR_1[LP_ORDER - 1];
for (VAR_7 = 0; VAR_7 < LP_ORDER - 2; VAR_7++)
VAR_2[VAR_7] = VAR_1[VAR_7 + 1] - VAR_1[VAR_7];
diff_mean = 0.0;
for (VAR_7 = 2; VAR_7 < LP_ORDER - 2; VAR_7++)
diff_mean += VAR_2[VAR_7] * (1.0f / (LP_ORDER - 4));
VAR_8 = 0;
for (VAR_7 = 0; VAR_7 < 3; VAR_7++) {
VAR_4[VAR_7] = auto_correlation(VAR_2, diff_mean, VAR_7 + 2);
if (VAR_4[VAR_7] > VAR_4[VAR_8])
VAR_8 = VAR_7;
}
VAR_8++;
for (VAR_7 = LP_ORDER - 1; VAR_7 < LP_ORDER_16k - 1; VAR_7++)
VAR_0[VAR_7] = VAR_1[VAR_7 - 1] + VAR_1[VAR_7 - 1 - VAR_8]
- VAR_1[VAR_7 - 2 - VAR_8];
VAR_5 = 7965 + (VAR_0[2] - VAR_0[3] - VAR_0[4]) / 6.0;
VAR_6 = 0.5 * (FFMIN(VAR_5, 7600) - VAR_0[LP_ORDER - 2]) /
(VAR_0[LP_ORDER_16k - 2] - VAR_0[LP_ORDER - 2]);
for (VAR_7 = LP_ORDER - 1; VAR_7 < LP_ORDER_16k - 1; VAR_7++)
VAR_3[VAR_7] = VAR_6 * (VAR_0[VAR_7] - VAR_0[VAR_7 - 1]);
for (VAR_7 = LP_ORDER; VAR_7 < LP_ORDER_16k - 1; VAR_7++)
if (VAR_3[VAR_7] + VAR_3[VAR_7 - 1] < 5.0) {
if (VAR_3[VAR_7] > VAR_3[VAR_7 - 1]) {
VAR_3[VAR_7 - 1] = 5.0 - VAR_3[VAR_7];
} else
VAR_3[VAR_7] = 5.0 - VAR_3[VAR_7 - 1];
}
for (VAR_7 = LP_ORDER - 1; VAR_7 < LP_ORDER_16k - 1; VAR_7++)
VAR_0[VAR_7] = VAR_0[VAR_7 - 1] + VAR_3[VAR_7] * (1.0f / (1 << 15));
for (VAR_7 = 0; VAR_7 < LP_ORDER_16k - 1; VAR_7++)
VAR_0[VAR_7] *= 0.8;
}
| [
"static void FUNC_0(float VAR_0[LP_ORDER_16k], float VAR_1[LP_ORDER])\n{",
"float VAR_2[LP_ORDER - 2], diff_mean;",
"float *VAR_3 = VAR_2 - LP_ORDER + 1;",
"float VAR_4[3];",
"float VAR_5, VAR_6;",
"int VAR_7, VAR_8;",
"memcpy(VAR_0, VAR_1, (LP_ORDER - 1) * sizeof(float));",
"VAR_0[LP_ORDER_16k - 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
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
41
],
[
43
],
[
45
],
[
49,
51
],
[
53
],
[
55
],
[... |
9,478 | static int get_video_private_data(struct VideoFile *vf, AVCodecContext *codec)
{
AVIOContext *io = NULL;
uint16_t sps_size, pps_size;
int err = AVERROR(EINVAL);
if (codec->codec_id == AV_CODEC_ID_VC1)
return get_private_data(vf, codec);
avio_open_dyn_buf(&io);
if (codec->extradata_size < 11 || codec->extradata[0] != 1)
goto fail;
sps_size = AV_RB16(&codec->extradata[6]);
if (11 + sps_size > codec->extradata_size)
goto fail;
avio_wb32(io, 0x00000001);
avio_write(io, &codec->extradata[8], sps_size);
pps_size = AV_RB16(&codec->extradata[9 + sps_size]);
if (11 + sps_size + pps_size > codec->extradata_size)
goto fail;
avio_wb32(io, 0x00000001);
avio_write(io, &codec->extradata[11 + sps_size], pps_size);
err = 0;
fail:
vf->codec_private_size = avio_close_dyn_buf(io, &vf->codec_private);
return err;
}
| false | FFmpeg | 224afddc7c869472caa57fc571aaf979a85d24ef | static int get_video_private_data(struct VideoFile *vf, AVCodecContext *codec)
{
AVIOContext *io = NULL;
uint16_t sps_size, pps_size;
int err = AVERROR(EINVAL);
if (codec->codec_id == AV_CODEC_ID_VC1)
return get_private_data(vf, codec);
avio_open_dyn_buf(&io);
if (codec->extradata_size < 11 || codec->extradata[0] != 1)
goto fail;
sps_size = AV_RB16(&codec->extradata[6]);
if (11 + sps_size > codec->extradata_size)
goto fail;
avio_wb32(io, 0x00000001);
avio_write(io, &codec->extradata[8], sps_size);
pps_size = AV_RB16(&codec->extradata[9 + sps_size]);
if (11 + sps_size + pps_size > codec->extradata_size)
goto fail;
avio_wb32(io, 0x00000001);
avio_write(io, &codec->extradata[11 + sps_size], pps_size);
err = 0;
fail:
vf->codec_private_size = avio_close_dyn_buf(io, &vf->codec_private);
return err;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(struct VideoFile *VAR_0, AVCodecContext *VAR_1)
{
AVIOContext *io = NULL;
uint16_t sps_size, pps_size;
int VAR_2 = AVERROR(EINVAL);
if (VAR_1->codec_id == AV_CODEC_ID_VC1)
return get_private_data(VAR_0, VAR_1);
avio_open_dyn_buf(&io);
if (VAR_1->extradata_size < 11 || VAR_1->extradata[0] != 1)
goto fail;
sps_size = AV_RB16(&VAR_1->extradata[6]);
if (11 + sps_size > VAR_1->extradata_size)
goto fail;
avio_wb32(io, 0x00000001);
avio_write(io, &VAR_1->extradata[8], sps_size);
pps_size = AV_RB16(&VAR_1->extradata[9 + sps_size]);
if (11 + sps_size + pps_size > VAR_1->extradata_size)
goto fail;
avio_wb32(io, 0x00000001);
avio_write(io, &VAR_1->extradata[11 + sps_size], pps_size);
VAR_2 = 0;
fail:
VAR_0->codec_private_size = avio_close_dyn_buf(io, &VAR_0->codec_private);
return VAR_2;
}
| [
"static int FUNC_0(struct VideoFile *VAR_0, AVCodecContext *VAR_1)\n{",
"AVIOContext *io = NULL;",
"uint16_t sps_size, pps_size;",
"int VAR_2 = AVERROR(EINVAL);",
"if (VAR_1->codec_id == AV_CODEC_ID_VC1)\nreturn get_private_data(VAR_0, VAR_1);",
"avio_open_dyn_buf(&io);",
"if (VAR_1->extradata_size < 11... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
19
],
[
21,
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
49,
51
],
[... |
9,479 | static void FUNCC(pred8x8l_horizontal)(uint8_t *p_src, int has_topleft, int has_topright, int p_stride)
{
pixel *src = (pixel*)p_src;
int stride = p_stride>>(sizeof(pixel)-1);
PREDICT_8x8_LOAD_LEFT;
#define ROW(y) ((pixel4*)(src+y*stride))[0] =\
((pixel4*)(src+y*stride))[1] = PIXEL_SPLAT_X4(l##y)
ROW(0); ROW(1); ROW(2); ROW(3); ROW(4); ROW(5); ROW(6); ROW(7);
#undef ROW
}
| false | FFmpeg | c77b858c4cafe74cd663bdd1bc9d96a487b20e14 | static void FUNCC(pred8x8l_horizontal)(uint8_t *p_src, int has_topleft, int has_topright, int p_stride)
{
pixel *src = (pixel*)p_src;
int stride = p_stride>>(sizeof(pixel)-1);
PREDICT_8x8_LOAD_LEFT;
#define ROW(y) ((pixel4*)(src+y*stride))[0] =\
((pixel4*)(src+y*stride))[1] = PIXEL_SPLAT_X4(l##y)
ROW(0); ROW(1); ROW(2); ROW(3); ROW(4); ROW(5); ROW(6); ROW(7);
#undef ROW
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(pred8x8l_horizontal)(uint8_t *p_src, int has_topleft, int has_topright, int p_stride)
{
pixel *src = (pixel*)p_src;
int VAR_0 = p_stride>>(sizeof(pixel)-1);
PREDICT_8x8_LOAD_LEFT;
#define ROW(y) ((pixel4*)(src+y*VAR_0))[0] =\
((pixel4*)(src+y*VAR_0))[1] = PIXEL_SPLAT_X4(l##y)
ROW(0); ROW(1); ROW(2); ROW(3); ROW(4); ROW(5); ROW(6); ROW(7);
#undef ROW
}
| [
"static void FUNC_0(pred8x8l_horizontal)(uint8_t *p_src, int has_topleft, int has_topright, int p_stride)\n{",
"pixel *src = (pixel*)p_src;",
"int VAR_0 = p_stride>>(sizeof(pixel)-1);",
"PREDICT_8x8_LOAD_LEFT;",
"#define ROW(y) ((pixel4*)(src+y*VAR_0))[0] =\\\n((pixel4*)(src+y*VAR_0))[1] = PIXEL_SPLAT_X4(l#... | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15,
17
],
[
19,
21
]
] |
9,480 | static int dca_parse_params(DCAParseContext *pc1, const uint8_t *buf,
int buf_size, int *duration, int *sample_rate,
int *profile)
{
DCAExssAsset *asset = &pc1->exss.assets[0];
GetBitContext gb;
DCACoreFrameHeader h;
uint8_t hdr[DCA_CORE_FRAME_HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 };
int ret, frame_size;
if (buf_size < DCA_CORE_FRAME_HEADER_SIZE)
return AVERROR_INVALIDDATA;
if (AV_RB32(buf) == DCA_SYNCWORD_SUBSTREAM) {
if ((ret = ff_dca_exss_parse(&pc1->exss, buf, buf_size)) < 0)
return ret;
if (asset->extension_mask & DCA_EXSS_LBR) {
if ((ret = init_get_bits8(&gb, buf + asset->lbr_offset, asset->lbr_size)) < 0)
return ret;
if (get_bits_long(&gb, 32) != DCA_SYNCWORD_LBR)
return AVERROR_INVALIDDATA;
switch (get_bits(&gb, 8)) {
case DCA_LBR_HEADER_DECODER_INIT:
pc1->sr_code = get_bits(&gb, 8);
case DCA_LBR_HEADER_SYNC_ONLY:
break;
default:
return AVERROR_INVALIDDATA;
}
if (pc1->sr_code >= FF_ARRAY_ELEMS(ff_dca_sampling_freqs))
return AVERROR_INVALIDDATA;
*sample_rate = ff_dca_sampling_freqs[pc1->sr_code];
*duration = 1024 << ff_dca_freq_ranges[pc1->sr_code];
*profile = FF_PROFILE_DTS_EXPRESS;
return 0;
}
if (asset->extension_mask & DCA_EXSS_XLL) {
int nsamples_log2;
if ((ret = init_get_bits8(&gb, buf + asset->xll_offset, asset->xll_size)) < 0)
return ret;
if (get_bits_long(&gb, 32) != DCA_SYNCWORD_XLL)
return AVERROR_INVALIDDATA;
if (get_bits(&gb, 4))
return AVERROR_INVALIDDATA;
skip_bits(&gb, 8);
skip_bits_long(&gb, get_bits(&gb, 5) + 1);
skip_bits(&gb, 4);
nsamples_log2 = get_bits(&gb, 4) + get_bits(&gb, 4);
if (nsamples_log2 > 24)
return AVERROR_INVALIDDATA;
*sample_rate = asset->max_sample_rate;
*duration = (1 + (*sample_rate > 96000)) << nsamples_log2;
*profile = FF_PROFILE_DTS_HD_MA;
return 0;
}
return AVERROR_INVALIDDATA;
}
if ((ret = avpriv_dca_convert_bitstream(buf, DCA_CORE_FRAME_HEADER_SIZE,
hdr, DCA_CORE_FRAME_HEADER_SIZE)) < 0)
return ret;
if ((ret = init_get_bits8(&gb, hdr, ret)) < 0)
return ret;
if (avpriv_dca_parse_core_frame_header(&gb, &h) < 0)
return AVERROR_INVALIDDATA;
*duration = h.npcmblocks * DCA_PCMBLOCK_SAMPLES;
*sample_rate = avpriv_dca_sample_rates[h.sr_code];
if (*profile != FF_PROFILE_UNKNOWN)
return 0;
*profile = FF_PROFILE_DTS;
if (h.ext_audio_present) {
switch (h.ext_audio_type) {
case DCA_EXT_AUDIO_XCH:
case DCA_EXT_AUDIO_XXCH:
*profile = FF_PROFILE_DTS_ES;
break;
case DCA_EXT_AUDIO_X96:
*profile = FF_PROFILE_DTS_96_24;
break;
}
}
frame_size = FFALIGN(h.frame_size, 4);
if (buf_size - 4 < frame_size)
return 0;
buf += frame_size;
buf_size -= frame_size;
if (AV_RB32(buf) != DCA_SYNCWORD_SUBSTREAM)
return 0;
if (ff_dca_exss_parse(&pc1->exss, buf, buf_size) < 0)
return 0;
if (asset->extension_mask & DCA_EXSS_XLL)
*profile = FF_PROFILE_DTS_HD_MA;
else if (asset->extension_mask & (DCA_EXSS_XBR | DCA_EXSS_XXCH | DCA_EXSS_X96))
*profile = FF_PROFILE_DTS_HD_HRA;
return 0;
}
| false | FFmpeg | 7c9d2ad45f4e46ad2c3b2e93051efbe1e0d0529e | static int dca_parse_params(DCAParseContext *pc1, const uint8_t *buf,
int buf_size, int *duration, int *sample_rate,
int *profile)
{
DCAExssAsset *asset = &pc1->exss.assets[0];
GetBitContext gb;
DCACoreFrameHeader h;
uint8_t hdr[DCA_CORE_FRAME_HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 };
int ret, frame_size;
if (buf_size < DCA_CORE_FRAME_HEADER_SIZE)
return AVERROR_INVALIDDATA;
if (AV_RB32(buf) == DCA_SYNCWORD_SUBSTREAM) {
if ((ret = ff_dca_exss_parse(&pc1->exss, buf, buf_size)) < 0)
return ret;
if (asset->extension_mask & DCA_EXSS_LBR) {
if ((ret = init_get_bits8(&gb, buf + asset->lbr_offset, asset->lbr_size)) < 0)
return ret;
if (get_bits_long(&gb, 32) != DCA_SYNCWORD_LBR)
return AVERROR_INVALIDDATA;
switch (get_bits(&gb, 8)) {
case DCA_LBR_HEADER_DECODER_INIT:
pc1->sr_code = get_bits(&gb, 8);
case DCA_LBR_HEADER_SYNC_ONLY:
break;
default:
return AVERROR_INVALIDDATA;
}
if (pc1->sr_code >= FF_ARRAY_ELEMS(ff_dca_sampling_freqs))
return AVERROR_INVALIDDATA;
*sample_rate = ff_dca_sampling_freqs[pc1->sr_code];
*duration = 1024 << ff_dca_freq_ranges[pc1->sr_code];
*profile = FF_PROFILE_DTS_EXPRESS;
return 0;
}
if (asset->extension_mask & DCA_EXSS_XLL) {
int nsamples_log2;
if ((ret = init_get_bits8(&gb, buf + asset->xll_offset, asset->xll_size)) < 0)
return ret;
if (get_bits_long(&gb, 32) != DCA_SYNCWORD_XLL)
return AVERROR_INVALIDDATA;
if (get_bits(&gb, 4))
return AVERROR_INVALIDDATA;
skip_bits(&gb, 8);
skip_bits_long(&gb, get_bits(&gb, 5) + 1);
skip_bits(&gb, 4);
nsamples_log2 = get_bits(&gb, 4) + get_bits(&gb, 4);
if (nsamples_log2 > 24)
return AVERROR_INVALIDDATA;
*sample_rate = asset->max_sample_rate;
*duration = (1 + (*sample_rate > 96000)) << nsamples_log2;
*profile = FF_PROFILE_DTS_HD_MA;
return 0;
}
return AVERROR_INVALIDDATA;
}
if ((ret = avpriv_dca_convert_bitstream(buf, DCA_CORE_FRAME_HEADER_SIZE,
hdr, DCA_CORE_FRAME_HEADER_SIZE)) < 0)
return ret;
if ((ret = init_get_bits8(&gb, hdr, ret)) < 0)
return ret;
if (avpriv_dca_parse_core_frame_header(&gb, &h) < 0)
return AVERROR_INVALIDDATA;
*duration = h.npcmblocks * DCA_PCMBLOCK_SAMPLES;
*sample_rate = avpriv_dca_sample_rates[h.sr_code];
if (*profile != FF_PROFILE_UNKNOWN)
return 0;
*profile = FF_PROFILE_DTS;
if (h.ext_audio_present) {
switch (h.ext_audio_type) {
case DCA_EXT_AUDIO_XCH:
case DCA_EXT_AUDIO_XXCH:
*profile = FF_PROFILE_DTS_ES;
break;
case DCA_EXT_AUDIO_X96:
*profile = FF_PROFILE_DTS_96_24;
break;
}
}
frame_size = FFALIGN(h.frame_size, 4);
if (buf_size - 4 < frame_size)
return 0;
buf += frame_size;
buf_size -= frame_size;
if (AV_RB32(buf) != DCA_SYNCWORD_SUBSTREAM)
return 0;
if (ff_dca_exss_parse(&pc1->exss, buf, buf_size) < 0)
return 0;
if (asset->extension_mask & DCA_EXSS_XLL)
*profile = FF_PROFILE_DTS_HD_MA;
else if (asset->extension_mask & (DCA_EXSS_XBR | DCA_EXSS_XXCH | DCA_EXSS_X96))
*profile = FF_PROFILE_DTS_HD_HRA;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(DCAParseContext *VAR_0, const uint8_t *VAR_1,
int VAR_2, int *VAR_3, int *VAR_4,
int *VAR_5)
{
DCAExssAsset *asset = &VAR_0->exss.assets[0];
GetBitContext gb;
DCACoreFrameHeader h;
uint8_t hdr[DCA_CORE_FRAME_HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 };
int VAR_6, VAR_7;
if (VAR_2 < DCA_CORE_FRAME_HEADER_SIZE)
return AVERROR_INVALIDDATA;
if (AV_RB32(VAR_1) == DCA_SYNCWORD_SUBSTREAM) {
if ((VAR_6 = ff_dca_exss_parse(&VAR_0->exss, VAR_1, VAR_2)) < 0)
return VAR_6;
if (asset->extension_mask & DCA_EXSS_LBR) {
if ((VAR_6 = init_get_bits8(&gb, VAR_1 + asset->lbr_offset, asset->lbr_size)) < 0)
return VAR_6;
if (get_bits_long(&gb, 32) != DCA_SYNCWORD_LBR)
return AVERROR_INVALIDDATA;
switch (get_bits(&gb, 8)) {
case DCA_LBR_HEADER_DECODER_INIT:
VAR_0->sr_code = get_bits(&gb, 8);
case DCA_LBR_HEADER_SYNC_ONLY:
break;
default:
return AVERROR_INVALIDDATA;
}
if (VAR_0->sr_code >= FF_ARRAY_ELEMS(ff_dca_sampling_freqs))
return AVERROR_INVALIDDATA;
*VAR_4 = ff_dca_sampling_freqs[VAR_0->sr_code];
*VAR_3 = 1024 << ff_dca_freq_ranges[VAR_0->sr_code];
*VAR_5 = FF_PROFILE_DTS_EXPRESS;
return 0;
}
if (asset->extension_mask & DCA_EXSS_XLL) {
int VAR_8;
if ((VAR_6 = init_get_bits8(&gb, VAR_1 + asset->xll_offset, asset->xll_size)) < 0)
return VAR_6;
if (get_bits_long(&gb, 32) != DCA_SYNCWORD_XLL)
return AVERROR_INVALIDDATA;
if (get_bits(&gb, 4))
return AVERROR_INVALIDDATA;
skip_bits(&gb, 8);
skip_bits_long(&gb, get_bits(&gb, 5) + 1);
skip_bits(&gb, 4);
VAR_8 = get_bits(&gb, 4) + get_bits(&gb, 4);
if (VAR_8 > 24)
return AVERROR_INVALIDDATA;
*VAR_4 = asset->max_sample_rate;
*VAR_3 = (1 + (*VAR_4 > 96000)) << VAR_8;
*VAR_5 = FF_PROFILE_DTS_HD_MA;
return 0;
}
return AVERROR_INVALIDDATA;
}
if ((VAR_6 = avpriv_dca_convert_bitstream(VAR_1, DCA_CORE_FRAME_HEADER_SIZE,
hdr, DCA_CORE_FRAME_HEADER_SIZE)) < 0)
return VAR_6;
if ((VAR_6 = init_get_bits8(&gb, hdr, VAR_6)) < 0)
return VAR_6;
if (avpriv_dca_parse_core_frame_header(&gb, &h) < 0)
return AVERROR_INVALIDDATA;
*VAR_3 = h.npcmblocks * DCA_PCMBLOCK_SAMPLES;
*VAR_4 = avpriv_dca_sample_rates[h.sr_code];
if (*VAR_5 != FF_PROFILE_UNKNOWN)
return 0;
*VAR_5 = FF_PROFILE_DTS;
if (h.ext_audio_present) {
switch (h.ext_audio_type) {
case DCA_EXT_AUDIO_XCH:
case DCA_EXT_AUDIO_XXCH:
*VAR_5 = FF_PROFILE_DTS_ES;
break;
case DCA_EXT_AUDIO_X96:
*VAR_5 = FF_PROFILE_DTS_96_24;
break;
}
}
VAR_7 = FFALIGN(h.VAR_7, 4);
if (VAR_2 - 4 < VAR_7)
return 0;
VAR_1 += VAR_7;
VAR_2 -= VAR_7;
if (AV_RB32(VAR_1) != DCA_SYNCWORD_SUBSTREAM)
return 0;
if (ff_dca_exss_parse(&VAR_0->exss, VAR_1, VAR_2) < 0)
return 0;
if (asset->extension_mask & DCA_EXSS_XLL)
*VAR_5 = FF_PROFILE_DTS_HD_MA;
else if (asset->extension_mask & (DCA_EXSS_XBR | DCA_EXSS_XXCH | DCA_EXSS_X96))
*VAR_5 = FF_PROFILE_DTS_HD_HRA;
return 0;
}
| [
"static int FUNC_0(DCAParseContext *VAR_0, const uint8_t *VAR_1,\nint VAR_2, int *VAR_3, int *VAR_4,\nint *VAR_5)\n{",
"DCAExssAsset *asset = &VAR_0->exss.assets[0];",
"GetBitContext gb;",
"DCACoreFrameHeader h;",
"uint8_t hdr[DCA_CORE_FRAME_HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 };",
"int VAR_... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
35
],
[
37,
39
],
[
43,
45
],
[
49
],
[
51,
53
],
[
55,
57
],
[
59,... |
9,484 | static int ffmmal_fill_input_port(AVCodecContext *avctx)
{
MMALDecodeContext *ctx = avctx->priv_data;
while (ctx->waiting_buffers) {
MMAL_BUFFER_HEADER_T *mbuffer;
FFBufferEntry *buffer;
MMAL_STATUS_T status;
mbuffer = mmal_queue_get(ctx->pool_in->queue);
if (!mbuffer)
return 0;
buffer = ctx->waiting_buffers;
mmal_buffer_header_reset(mbuffer);
mbuffer->cmd = 0;
mbuffer->pts = buffer->pts;
mbuffer->dts = buffer->dts;
mbuffer->flags = buffer->flags;
mbuffer->data = buffer->data;
mbuffer->length = buffer->length;
mbuffer->user_data = buffer->ref;
mbuffer->alloc_size = ctx->decoder->input[0]->buffer_size;
if ((status = mmal_port_send_buffer(ctx->decoder->input[0], mbuffer))) {
mmal_buffer_header_release(mbuffer);
av_buffer_unref(&buffer->ref);
}
// Remove from start of the list
ctx->waiting_buffers = buffer->next;
if (ctx->waiting_buffers_tail == buffer)
ctx->waiting_buffers_tail = NULL;
av_free(buffer);
if (status) {
av_log(avctx, AV_LOG_ERROR, "MMAL error %d when sending input\n", (int)status);
return AVERROR_UNKNOWN;
}
}
return 0;
}
| true | FFmpeg | 65db4899fa8790049bec3af16ecdb75dd81051fd | static int ffmmal_fill_input_port(AVCodecContext *avctx)
{
MMALDecodeContext *ctx = avctx->priv_data;
while (ctx->waiting_buffers) {
MMAL_BUFFER_HEADER_T *mbuffer;
FFBufferEntry *buffer;
MMAL_STATUS_T status;
mbuffer = mmal_queue_get(ctx->pool_in->queue);
if (!mbuffer)
return 0;
buffer = ctx->waiting_buffers;
mmal_buffer_header_reset(mbuffer);
mbuffer->cmd = 0;
mbuffer->pts = buffer->pts;
mbuffer->dts = buffer->dts;
mbuffer->flags = buffer->flags;
mbuffer->data = buffer->data;
mbuffer->length = buffer->length;
mbuffer->user_data = buffer->ref;
mbuffer->alloc_size = ctx->decoder->input[0]->buffer_size;
if ((status = mmal_port_send_buffer(ctx->decoder->input[0], mbuffer))) {
mmal_buffer_header_release(mbuffer);
av_buffer_unref(&buffer->ref);
}
ctx->waiting_buffers = buffer->next;
if (ctx->waiting_buffers_tail == buffer)
ctx->waiting_buffers_tail = NULL;
av_free(buffer);
if (status) {
av_log(avctx, AV_LOG_ERROR, "MMAL error %d when sending input\n", (int)status);
return AVERROR_UNKNOWN;
}
}
return 0;
}
| {
"code": [
" mbuffer->user_data = buffer->ref;",
" if ((status = mmal_port_send_buffer(ctx->decoder->input[0], mbuffer))) {",
" mmal_buffer_header_release(mbuffer);",
" av_buffer_unref(&buffer->ref);",
" av_free(buffer);"
],
"line_no": [
45,
51,
53,
55,
69
]
} | static int FUNC_0(AVCodecContext *VAR_0)
{
MMALDecodeContext *ctx = VAR_0->priv_data;
while (ctx->waiting_buffers) {
MMAL_BUFFER_HEADER_T *mbuffer;
FFBufferEntry *buffer;
MMAL_STATUS_T status;
mbuffer = mmal_queue_get(ctx->pool_in->queue);
if (!mbuffer)
return 0;
buffer = ctx->waiting_buffers;
mmal_buffer_header_reset(mbuffer);
mbuffer->cmd = 0;
mbuffer->pts = buffer->pts;
mbuffer->dts = buffer->dts;
mbuffer->flags = buffer->flags;
mbuffer->data = buffer->data;
mbuffer->length = buffer->length;
mbuffer->user_data = buffer->ref;
mbuffer->alloc_size = ctx->decoder->input[0]->buffer_size;
if ((status = mmal_port_send_buffer(ctx->decoder->input[0], mbuffer))) {
mmal_buffer_header_release(mbuffer);
av_buffer_unref(&buffer->ref);
}
ctx->waiting_buffers = buffer->next;
if (ctx->waiting_buffers_tail == buffer)
ctx->waiting_buffers_tail = NULL;
av_free(buffer);
if (status) {
av_log(VAR_0, AV_LOG_ERROR, "MMAL error %d when sending input\n", (int)status);
return AVERROR_UNKNOWN;
}
}
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0)\n{",
"MMALDecodeContext *ctx = VAR_0->priv_data;",
"while (ctx->waiting_buffers) {",
"MMAL_BUFFER_HEADER_T *mbuffer;",
"FFBufferEntry *buffer;",
"MMAL_STATUS_T status;",
"mbuffer = mmal_queue_get(ctx->pool_in->queue);",
"if (!mbuffer)\nreturn 0;",
"buffer = ... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
1,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21,
23
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
... |
9,485 | static av_always_inline int decode_mb_row_no_filter(AVCodecContext *avctx, void *tdata,
int jobnr, int threadnr, int is_vp7)
{
VP8Context *s = avctx->priv_data;
VP8ThreadData *prev_td, *next_td, *td = &s->thread_data[threadnr];
int mb_y = td->thread_mb_pos >> 16;
int mb_x, mb_xy = mb_y * s->mb_width;
int num_jobs = s->num_jobs;
VP8Frame *curframe = s->curframe, *prev_frame = s->prev_frame;
VP56RangeCoder *c = &s->coeff_partition[mb_y & (s->num_coeff_partitions - 1)];
VP8Macroblock *mb;
uint8_t *dst[3] = {
curframe->tf.f->data[0] + 16 * mb_y * s->linesize,
curframe->tf.f->data[1] + 8 * mb_y * s->uvlinesize,
curframe->tf.f->data[2] + 8 * mb_y * s->uvlinesize
};
if (mb_y == 0)
prev_td = td;
else
prev_td = &s->thread_data[(jobnr + num_jobs - 1) % num_jobs];
if (mb_y == s->mb_height - 1)
next_td = td;
else
next_td = &s->thread_data[(jobnr + 1) % num_jobs];
if (s->mb_layout == 1)
mb = s->macroblocks_base + ((s->mb_width + 1) * (mb_y + 1) + 1);
else {
// Make sure the previous frame has read its segmentation map,
// if we re-use the same map.
if (prev_frame && s->segmentation.enabled &&
!s->segmentation.update_map)
ff_thread_await_progress(&prev_frame->tf, mb_y, 0);
mb = s->macroblocks + (s->mb_height - mb_y - 1) * 2;
memset(mb - 1, 0, sizeof(*mb)); // zero left macroblock
AV_WN32A(s->intra4x4_pred_mode_left, DC_PRED * 0x01010101);
}
if (!is_vp7 || mb_y == 0)
memset(td->left_nnz, 0, sizeof(td->left_nnz));
s->mv_min.x = -MARGIN;
s->mv_max.x = ((s->mb_width - 1) << 6) + MARGIN;
for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) {
// Wait for previous thread to read mb_x+2, and reach mb_y-1.
if (prev_td != td) {
if (threadnr != 0) {
check_thread_pos(td, prev_td,
mb_x + (is_vp7 ? 2 : 1),
mb_y - (is_vp7 ? 2 : 1));
} else {
check_thread_pos(td, prev_td,
mb_x + (is_vp7 ? 2 : 1) + s->mb_width + 3,
mb_y - (is_vp7 ? 2 : 1));
}
}
s->vdsp.prefetch(dst[0] + (mb_x & 3) * 4 * s->linesize + 64,
s->linesize, 4);
s->vdsp.prefetch(dst[1] + (mb_x & 7) * s->uvlinesize + 64,
dst[2] - dst[1], 2);
if (!s->mb_layout)
decode_mb_mode(s, mb, mb_x, mb_y, curframe->seg_map->data + mb_xy,
prev_frame && prev_frame->seg_map ?
prev_frame->seg_map->data + mb_xy : NULL, 0, is_vp7);
prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_PREVIOUS);
if (!mb->skip)
decode_mb_coeffs(s, td, c, mb, s->top_nnz[mb_x], td->left_nnz, is_vp7);
if (mb->mode <= MODE_I4x4)
intra_predict(s, td, dst, mb, mb_x, mb_y, is_vp7);
else
inter_predict(s, td, dst, mb, mb_x, mb_y);
prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_GOLDEN);
if (!mb->skip) {
idct_mb(s, td, dst, mb);
} else {
AV_ZERO64(td->left_nnz);
AV_WN64(s->top_nnz[mb_x], 0); // array of 9, so unaligned
/* Reset DC block predictors if they would exist
* if the mb had coefficients */
if (mb->mode != MODE_I4x4 && mb->mode != VP8_MVMODE_SPLIT) {
td->left_nnz[8] = 0;
s->top_nnz[mb_x][8] = 0;
}
}
if (s->deblock_filter)
filter_level_for_mb(s, mb, &td->filter_strength[mb_x], is_vp7);
if (s->deblock_filter && num_jobs != 1 && threadnr == num_jobs - 1) {
if (s->filter.simple)
backup_mb_border(s->top_border[mb_x + 1], dst[0],
NULL, NULL, s->linesize, 0, 1);
else
backup_mb_border(s->top_border[mb_x + 1], dst[0],
dst[1], dst[2], s->linesize, s->uvlinesize, 0);
}
prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_GOLDEN2);
dst[0] += 16;
dst[1] += 8;
dst[2] += 8;
s->mv_min.x -= 64;
s->mv_max.x -= 64;
if (mb_x == s->mb_width + 1) {
update_pos(td, mb_y, s->mb_width + 3);
} else {
update_pos(td, mb_y, mb_x);
}
}
return 0;
} | true | FFmpeg | 1afd246960202917e244c844c534e9c1e3c323f5 | static av_always_inline int decode_mb_row_no_filter(AVCodecContext *avctx, void *tdata,
int jobnr, int threadnr, int is_vp7)
{
VP8Context *s = avctx->priv_data;
VP8ThreadData *prev_td, *next_td, *td = &s->thread_data[threadnr];
int mb_y = td->thread_mb_pos >> 16;
int mb_x, mb_xy = mb_y * s->mb_width;
int num_jobs = s->num_jobs;
VP8Frame *curframe = s->curframe, *prev_frame = s->prev_frame;
VP56RangeCoder *c = &s->coeff_partition[mb_y & (s->num_coeff_partitions - 1)];
VP8Macroblock *mb;
uint8_t *dst[3] = {
curframe->tf.f->data[0] + 16 * mb_y * s->linesize,
curframe->tf.f->data[1] + 8 * mb_y * s->uvlinesize,
curframe->tf.f->data[2] + 8 * mb_y * s->uvlinesize
};
if (mb_y == 0)
prev_td = td;
else
prev_td = &s->thread_data[(jobnr + num_jobs - 1) % num_jobs];
if (mb_y == s->mb_height - 1)
next_td = td;
else
next_td = &s->thread_data[(jobnr + 1) % num_jobs];
if (s->mb_layout == 1)
mb = s->macroblocks_base + ((s->mb_width + 1) * (mb_y + 1) + 1);
else {
if (prev_frame && s->segmentation.enabled &&
!s->segmentation.update_map)
ff_thread_await_progress(&prev_frame->tf, mb_y, 0);
mb = s->macroblocks + (s->mb_height - mb_y - 1) * 2;
memset(mb - 1, 0, sizeof(*mb));
AV_WN32A(s->intra4x4_pred_mode_left, DC_PRED * 0x01010101);
}
if (!is_vp7 || mb_y == 0)
memset(td->left_nnz, 0, sizeof(td->left_nnz));
s->mv_min.x = -MARGIN;
s->mv_max.x = ((s->mb_width - 1) << 6) + MARGIN;
for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) {
if (prev_td != td) {
if (threadnr != 0) {
check_thread_pos(td, prev_td,
mb_x + (is_vp7 ? 2 : 1),
mb_y - (is_vp7 ? 2 : 1));
} else {
check_thread_pos(td, prev_td,
mb_x + (is_vp7 ? 2 : 1) + s->mb_width + 3,
mb_y - (is_vp7 ? 2 : 1));
}
}
s->vdsp.prefetch(dst[0] + (mb_x & 3) * 4 * s->linesize + 64,
s->linesize, 4);
s->vdsp.prefetch(dst[1] + (mb_x & 7) * s->uvlinesize + 64,
dst[2] - dst[1], 2);
if (!s->mb_layout)
decode_mb_mode(s, mb, mb_x, mb_y, curframe->seg_map->data + mb_xy,
prev_frame && prev_frame->seg_map ?
prev_frame->seg_map->data + mb_xy : NULL, 0, is_vp7);
prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_PREVIOUS);
if (!mb->skip)
decode_mb_coeffs(s, td, c, mb, s->top_nnz[mb_x], td->left_nnz, is_vp7);
if (mb->mode <= MODE_I4x4)
intra_predict(s, td, dst, mb, mb_x, mb_y, is_vp7);
else
inter_predict(s, td, dst, mb, mb_x, mb_y);
prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_GOLDEN);
if (!mb->skip) {
idct_mb(s, td, dst, mb);
} else {
AV_ZERO64(td->left_nnz);
AV_WN64(s->top_nnz[mb_x], 0);
if (mb->mode != MODE_I4x4 && mb->mode != VP8_MVMODE_SPLIT) {
td->left_nnz[8] = 0;
s->top_nnz[mb_x][8] = 0;
}
}
if (s->deblock_filter)
filter_level_for_mb(s, mb, &td->filter_strength[mb_x], is_vp7);
if (s->deblock_filter && num_jobs != 1 && threadnr == num_jobs - 1) {
if (s->filter.simple)
backup_mb_border(s->top_border[mb_x + 1], dst[0],
NULL, NULL, s->linesize, 0, 1);
else
backup_mb_border(s->top_border[mb_x + 1], dst[0],
dst[1], dst[2], s->linesize, s->uvlinesize, 0);
}
prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_GOLDEN2);
dst[0] += 16;
dst[1] += 8;
dst[2] += 8;
s->mv_min.x -= 64;
s->mv_max.x -= 64;
if (mb_x == s->mb_width + 1) {
update_pos(td, mb_y, s->mb_width + 3);
} else {
update_pos(td, mb_y, mb_x);
}
}
return 0;
} | {
"code": [],
"line_no": []
} | static av_always_inline int FUNC_0(AVCodecContext *avctx, void *tdata,
int jobnr, int threadnr, int is_vp7)
{
VP8Context *s = avctx->priv_data;
VP8ThreadData *prev_td, *next_td, *td = &s->thread_data[threadnr];
int VAR_0 = td->thread_mb_pos >> 16;
int VAR_1, VAR_2 = VAR_0 * s->mb_width;
int VAR_3 = s->VAR_3;
VP8Frame *curframe = s->curframe, *prev_frame = s->prev_frame;
VP56RangeCoder *c = &s->coeff_partition[VAR_0 & (s->num_coeff_partitions - 1)];
VP8Macroblock *mb;
uint8_t *dst[3] = {
curframe->tf.f->data[0] + 16 * VAR_0 * s->linesize,
curframe->tf.f->data[1] + 8 * VAR_0 * s->uvlinesize,
curframe->tf.f->data[2] + 8 * VAR_0 * s->uvlinesize
};
if (VAR_0 == 0)
prev_td = td;
else
prev_td = &s->thread_data[(jobnr + VAR_3 - 1) % VAR_3];
if (VAR_0 == s->mb_height - 1)
next_td = td;
else
next_td = &s->thread_data[(jobnr + 1) % VAR_3];
if (s->mb_layout == 1)
mb = s->macroblocks_base + ((s->mb_width + 1) * (VAR_0 + 1) + 1);
else {
if (prev_frame && s->segmentation.enabled &&
!s->segmentation.update_map)
ff_thread_await_progress(&prev_frame->tf, VAR_0, 0);
mb = s->macroblocks + (s->mb_height - VAR_0 - 1) * 2;
memset(mb - 1, 0, sizeof(*mb));
AV_WN32A(s->intra4x4_pred_mode_left, DC_PRED * 0x01010101);
}
if (!is_vp7 || VAR_0 == 0)
memset(td->left_nnz, 0, sizeof(td->left_nnz));
s->mv_min.x = -MARGIN;
s->mv_max.x = ((s->mb_width - 1) << 6) + MARGIN;
for (VAR_1 = 0; VAR_1 < s->mb_width; VAR_1++, VAR_2++, mb++) {
if (prev_td != td) {
if (threadnr != 0) {
check_thread_pos(td, prev_td,
VAR_1 + (is_vp7 ? 2 : 1),
VAR_0 - (is_vp7 ? 2 : 1));
} else {
check_thread_pos(td, prev_td,
VAR_1 + (is_vp7 ? 2 : 1) + s->mb_width + 3,
VAR_0 - (is_vp7 ? 2 : 1));
}
}
s->vdsp.prefetch(dst[0] + (VAR_1 & 3) * 4 * s->linesize + 64,
s->linesize, 4);
s->vdsp.prefetch(dst[1] + (VAR_1 & 7) * s->uvlinesize + 64,
dst[2] - dst[1], 2);
if (!s->mb_layout)
decode_mb_mode(s, mb, VAR_1, VAR_0, curframe->seg_map->data + VAR_2,
prev_frame && prev_frame->seg_map ?
prev_frame->seg_map->data + VAR_2 : NULL, 0, is_vp7);
prefetch_motion(s, mb, VAR_1, VAR_0, VAR_2, VP56_FRAME_PREVIOUS);
if (!mb->skip)
decode_mb_coeffs(s, td, c, mb, s->top_nnz[VAR_1], td->left_nnz, is_vp7);
if (mb->mode <= MODE_I4x4)
intra_predict(s, td, dst, mb, VAR_1, VAR_0, is_vp7);
else
inter_predict(s, td, dst, mb, VAR_1, VAR_0);
prefetch_motion(s, mb, VAR_1, VAR_0, VAR_2, VP56_FRAME_GOLDEN);
if (!mb->skip) {
idct_mb(s, td, dst, mb);
} else {
AV_ZERO64(td->left_nnz);
AV_WN64(s->top_nnz[VAR_1], 0);
if (mb->mode != MODE_I4x4 && mb->mode != VP8_MVMODE_SPLIT) {
td->left_nnz[8] = 0;
s->top_nnz[VAR_1][8] = 0;
}
}
if (s->deblock_filter)
filter_level_for_mb(s, mb, &td->filter_strength[VAR_1], is_vp7);
if (s->deblock_filter && VAR_3 != 1 && threadnr == VAR_3 - 1) {
if (s->filter.simple)
backup_mb_border(s->top_border[VAR_1 + 1], dst[0],
NULL, NULL, s->linesize, 0, 1);
else
backup_mb_border(s->top_border[VAR_1 + 1], dst[0],
dst[1], dst[2], s->linesize, s->uvlinesize, 0);
}
prefetch_motion(s, mb, VAR_1, VAR_0, VAR_2, VP56_FRAME_GOLDEN2);
dst[0] += 16;
dst[1] += 8;
dst[2] += 8;
s->mv_min.x -= 64;
s->mv_max.x -= 64;
if (VAR_1 == s->mb_width + 1) {
update_pos(td, VAR_0, s->mb_width + 3);
} else {
update_pos(td, VAR_0, VAR_1);
}
}
return 0;
} | [
"static av_always_inline int FUNC_0(AVCodecContext *avctx, void *tdata,\nint jobnr, int threadnr, int is_vp7)\n{",
"VP8Context *s = avctx->priv_data;",
"VP8ThreadData *prev_td, *next_td, *td = &s->thread_data[threadnr];",
"int VAR_0 = td->thread_mb_pos >> 16;",
"int VAR_1, VAR_2 = VAR_0 * s->mb_width;",
"... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
39,
41
],
[
43,
45
],
[
47,
49
],
[
51,
53
],
[
55,... |
9,486 | static test_speed(int step)
{
const struct pix_func* pix = pix_func;
const int linesize = 720;
char empty[32768];
char* bu =(char*)(((long)empty + 32) & ~0xf);
int sum = 0;
while (pix->name)
{
int i;
uint64_t te, ts;
op_pixels_func func = pix->func;
char* im = bu;
if (!(pix->mm_flags & mm_flags))
continue;
printf("%30s... ", pix->name);
fflush(stdout);
ts = rdtsc();
for(i=0; i<100000; i++){
func(im, im + 1000, linesize, 16);
im += step;
if (im > bu + 20000)
im = bu;
}
te = rdtsc();
emms();
printf("% 9d\n", (int)(te - ts));
sum += (te - ts) / 100000;
if (pix->mm_flags & PAD)
puts("");
pix++;
}
printf("Total sum: %d\n", sum);
}
| true | FFmpeg | 6fea8454acff29735ea46184cb183ca6ff42e514 | static test_speed(int step)
{
const struct pix_func* pix = pix_func;
const int linesize = 720;
char empty[32768];
char* bu =(char*)(((long)empty + 32) & ~0xf);
int sum = 0;
while (pix->name)
{
int i;
uint64_t te, ts;
op_pixels_func func = pix->func;
char* im = bu;
if (!(pix->mm_flags & mm_flags))
continue;
printf("%30s... ", pix->name);
fflush(stdout);
ts = rdtsc();
for(i=0; i<100000; i++){
func(im, im + 1000, linesize, 16);
im += step;
if (im > bu + 20000)
im = bu;
}
te = rdtsc();
emms();
printf("% 9d\n", (int)(te - ts));
sum += (te - ts) / 100000;
if (pix->mm_flags & PAD)
puts("");
pix++;
}
printf("Total sum: %d\n", sum);
}
| {
"code": [
"\tif (!(pix->mm_flags & mm_flags))",
" continue;",
"\tprintf(\"%30s... \", pix->name);",
" fflush(stdout);",
"\tts = rdtsc();",
"\tfor(i=0; i<100000; i++){",
"\t func(im, im + 1000, linesize, 16);",
"\t im += step;",
"\t if (im > bu + 20000)",
"\t\tim = bu;",
"\tte = rdtsc();",
" emms();",
"\tprintf(\"% 9d\\n\", (int)(te - ts));",
" sum += (te - ts) / 100000;",
"\tif (pix->mm_flags & PAD)",
" puts(\"\");",
" pix++;"
],
"line_no": [
33,
35,
39,
41,
43,
45,
47,
49,
51,
53,
57,
59,
61,
63,
65,
67,
69
]
} | static FUNC_0(int VAR_0)
{
const struct pix_func* VAR_1 = pix_func;
const int VAR_2 = 720;
char VAR_3[32768];
char* VAR_4 =(char*)(((long)VAR_3 + 32) & ~0xf);
int VAR_5 = 0;
while (VAR_1->name)
{
int VAR_6;
uint64_t te, ts;
op_pixels_func func = VAR_1->func;
char* VAR_7 = VAR_4;
if (!(VAR_1->mm_flags & mm_flags))
continue;
printf("%30s... ", VAR_1->name);
fflush(stdout);
ts = rdtsc();
for(VAR_6=0; VAR_6<100000; VAR_6++){
func(VAR_7, VAR_7 + 1000, VAR_2, 16);
VAR_7 += VAR_0;
if (VAR_7 > VAR_4 + 20000)
VAR_7 = VAR_4;
}
te = rdtsc();
emms();
printf("% 9d\n", (int)(te - ts));
VAR_5 += (te - ts) / 100000;
if (VAR_1->mm_flags & PAD)
puts("");
VAR_1++;
}
printf("Total VAR_5: %d\n", VAR_5);
}
| [
"static FUNC_0(int VAR_0)\n{",
"const struct pix_func* VAR_1 = pix_func;",
"const int VAR_2 = 720;",
"char VAR_3[32768];",
"char* VAR_4 =(char*)(((long)VAR_3 + 32) & ~0xf);",
"int VAR_5 = 0;",
"while (VAR_1->name)\n{",
"int VAR_6;",
"uint64_t te, ts;",
"op_pixels_func func = VAR_1->func;",
"char... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33,
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51,... |
9,487 | static void writer_print_ts(WriterContext *wctx, const char *key, int64_t ts, int is_duration)
{
if ((!is_duration && ts == AV_NOPTS_VALUE) || (is_duration && ts == 0)) {
writer_print_string(wctx, key, "N/A", 1);
} else {
writer_print_integer(wctx, key, ts);
}
}
| false | FFmpeg | cbba331aa02f29870581ff0b7ded7477b279ae2c | static void writer_print_ts(WriterContext *wctx, const char *key, int64_t ts, int is_duration)
{
if ((!is_duration && ts == AV_NOPTS_VALUE) || (is_duration && ts == 0)) {
writer_print_string(wctx, key, "N/A", 1);
} else {
writer_print_integer(wctx, key, ts);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(WriterContext *VAR_0, const char *VAR_1, int64_t VAR_2, int VAR_3)
{
if ((!VAR_3 && VAR_2 == AV_NOPTS_VALUE) || (VAR_3 && VAR_2 == 0)) {
writer_print_string(VAR_0, VAR_1, "N/A", 1);
} else {
writer_print_integer(VAR_0, VAR_1, VAR_2);
}
}
| [
"static void FUNC_0(WriterContext *VAR_0, const char *VAR_1, int64_t VAR_2, int VAR_3)\n{",
"if ((!VAR_3 && VAR_2 == AV_NOPTS_VALUE) || (VAR_3 && VAR_2 == 0)) {",
"writer_print_string(VAR_0, VAR_1, \"N/A\", 1);",
"} else {",
"writer_print_integer(VAR_0, VAR_1, VAR_2);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
9,488 | static void ff_h264_idct8_add4_sse2(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
int i;
for(i=0; i<16; i+=4){
int nnz = nnzc[ scan8[i] ];
if(nnz){
if(nnz==1 && block[i*16]) ff_h264_idct8_dc_add_mmx2(dst + block_offset[i], block + i*16, stride);
else ff_h264_idct8_add_sse2 (dst + block_offset[i], block + i*16, stride);
}
}
}
| false | FFmpeg | 1d16a1cf99488f16492b1bb48e023f4da8377e07 | static void ff_h264_idct8_add4_sse2(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
int i;
for(i=0; i<16; i+=4){
int nnz = nnzc[ scan8[i] ];
if(nnz){
if(nnz==1 && block[i*16]) ff_h264_idct8_dc_add_mmx2(dst + block_offset[i], block + i*16, stride);
else ff_h264_idct8_add_sse2 (dst + block_offset[i], block + i*16, stride);
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint8_t *VAR_0, const int *VAR_1, DCTELEM *VAR_2, int VAR_3, const uint8_t VAR_4[6*8]){
int VAR_5;
for(VAR_5=0; VAR_5<16; VAR_5+=4){
int VAR_6 = VAR_4[ scan8[VAR_5] ];
if(VAR_6){
if(VAR_6==1 && VAR_2[VAR_5*16]) ff_h264_idct8_dc_add_mmx2(VAR_0 + VAR_1[VAR_5], VAR_2 + VAR_5*16, VAR_3);
else ff_h264_idct8_add_sse2 (VAR_0 + VAR_1[VAR_5], VAR_2 + VAR_5*16, VAR_3);
}
}
}
| [
"static void FUNC_0(uint8_t *VAR_0, const int *VAR_1, DCTELEM *VAR_2, int VAR_3, const uint8_t VAR_4[6*8]){",
"int VAR_5;",
"for(VAR_5=0; VAR_5<16; VAR_5+=4){",
"int VAR_6 = VAR_4[ scan8[VAR_5] ];",
"if(VAR_6){",
"if(VAR_6==1 && VAR_2[VAR_5*16]) ff_h264_idct8_dc_add_mmx2(VAR_0 + VAR_1[VAR_5], VAR_2 + VAR_... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
9,489 | void ff_avg_h264_qpel16_mc31_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_hv_qrt_and_aver_dst_16x16_msa(src - 2,
src - (stride * 2) +
sizeof(uint8_t), stride,
dst, stride);
}
| false | FFmpeg | 1181d93231e9b807965724587d363c1cfd5a1d0d | void ff_avg_h264_qpel16_mc31_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_hv_qrt_and_aver_dst_16x16_msa(src - 2,
src - (stride * 2) +
sizeof(uint8_t), stride,
dst, stride);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,
ptrdiff_t VAR_2)
{
avc_luma_hv_qrt_and_aver_dst_16x16_msa(VAR_1 - 2,
VAR_1 - (VAR_2 * 2) +
sizeof(uint8_t), VAR_2,
VAR_0, VAR_2);
}
| [
"void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,\nptrdiff_t VAR_2)\n{",
"avc_luma_hv_qrt_and_aver_dst_16x16_msa(VAR_1 - 2,\nVAR_1 - (VAR_2 * 2) +\nsizeof(uint8_t), VAR_2,\nVAR_0, VAR_2);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5
],
[
7,
9,
11,
13
],
[
15
]
] |
9,490 | int av_tempfile(char *prefix, char **filename) {
int fd=-1;
#ifdef __MINGW32__
*filename = tempnam(".", prefix);
#else
size_t len = strlen(prefix) + 12; /* room for "/tmp/" and "XXXXXX\0" */
*filename = av_malloc(len);
#endif
/* -----common section-----*/
if (*filename == NULL) {
av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot allocate file name\n");
return -1;
}
#ifdef __MINGW32__
fd = open(*filename, _O_RDWR | _O_BINARY | _O_CREAT, 0444);
#else
snprintf(*filename, len, "/tmp/%sXXXXXX", prefix);
fd = mkstemp(*filename);
if (fd < 0) {
snprintf(*filename, len, "./%sXXXXXX", prefix);
fd = mkstemp(*filename);
}
#endif
/* -----common section-----*/
if (fd < 0) {
av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot open temporary file %s\n", *filename);
return -1;
}
return fd; /* success */
}
| false | FFmpeg | 6ffa87d3254dd8bdc31b50b378e1cf59c5dc13e5 | int av_tempfile(char *prefix, char **filename) {
int fd=-1;
#ifdef __MINGW32__
*filename = tempnam(".", prefix);
#else
size_t len = strlen(prefix) + 12;
*filename = av_malloc(len);
#endif
if (*filename == NULL) {
av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot allocate file name\n");
return -1;
}
#ifdef __MINGW32__
fd = open(*filename, _O_RDWR | _O_BINARY | _O_CREAT, 0444);
#else
snprintf(*filename, len, "/tmp/%sXXXXXX", prefix);
fd = mkstemp(*filename);
if (fd < 0) {
snprintf(*filename, len, "./%sXXXXXX", prefix);
fd = mkstemp(*filename);
}
#endif
if (fd < 0) {
av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot open temporary file %s\n", *filename);
return -1;
}
return fd;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(char *VAR_0, char **VAR_1) {
int VAR_2=-1;
#ifdef __MINGW32__
*VAR_1 = tempnam(".", VAR_0);
#else
size_t len = strlen(VAR_0) + 12;
*VAR_1 = av_malloc(len);
#endif
if (*VAR_1 == NULL) {
av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot allocate file name\n");
return -1;
}
#ifdef __MINGW32__
VAR_2 = open(*VAR_1, _O_RDWR | _O_BINARY | _O_CREAT, 0444);
#else
snprintf(*VAR_1, len, "/tmp/%sXXXXXX", VAR_0);
VAR_2 = mkstemp(*VAR_1);
if (VAR_2 < 0) {
snprintf(*VAR_1, len, "./%sXXXXXX", VAR_0);
VAR_2 = mkstemp(*VAR_1);
}
#endif
if (VAR_2 < 0) {
av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot open temporary file %s\n", *VAR_1);
return -1;
}
return VAR_2;
}
| [
"int FUNC_0(char *VAR_0, char **VAR_1) {",
"int VAR_2=-1;",
"#ifdef __MINGW32__\n*VAR_1 = tempnam(\".\", VAR_0);",
"#else\nsize_t len = strlen(VAR_0) + 12;",
"*VAR_1 = av_malloc(len);",
"#endif\nif (*VAR_1 == NULL) {",
"av_log(NULL, AV_LOG_ERROR, \"ff_tempfile: Cannot allocate file name\\n\");",
"retu... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5,
7
],
[
9,
11
],
[
13
],
[
15,
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
49
],
[... |
9,491 | static av_always_inline void xchg_mb_border(H264Context *h, H264SliceContext *sl,
uint8_t *src_y,
uint8_t *src_cb, uint8_t *src_cr,
int linesize, int uvlinesize,
int xchg, int chroma444,
int simple, int pixel_shift)
{
int deblock_topleft;
int deblock_top;
int top_idx = 1;
uint8_t *top_border_m1;
uint8_t *top_border;
if (!simple && FRAME_MBAFF(h)) {
if (h->mb_y & 1) {
if (!MB_MBAFF(h))
return;
} else {
top_idx = MB_MBAFF(h) ? 0 : 1;
}
}
if (h->deblocking_filter == 2) {
deblock_topleft = h->slice_table[h->mb_xy - 1 - h->mb_stride] == sl->slice_num;
deblock_top = sl->top_type;
} else {
deblock_topleft = (h->mb_x > 0);
deblock_top = (h->mb_y > !!MB_FIELD(h));
}
src_y -= linesize + 1 + pixel_shift;
src_cb -= uvlinesize + 1 + pixel_shift;
src_cr -= uvlinesize + 1 + pixel_shift;
top_border_m1 = h->top_borders[top_idx][h->mb_x - 1];
top_border = h->top_borders[top_idx][h->mb_x];
#define XCHG(a, b, xchg) \
if (pixel_shift) { \
if (xchg) { \
AV_SWAP64(b + 0, a + 0); \
AV_SWAP64(b + 8, a + 8); \
} else { \
AV_COPY128(b, a); \
} \
} else if (xchg) \
AV_SWAP64(b, a); \
else \
AV_COPY64(b, a);
if (deblock_top) {
if (deblock_topleft) {
XCHG(top_border_m1 + (8 << pixel_shift),
src_y - (7 << pixel_shift), 1);
}
XCHG(top_border + (0 << pixel_shift), src_y + (1 << pixel_shift), xchg);
XCHG(top_border + (8 << pixel_shift), src_y + (9 << pixel_shift), 1);
if (h->mb_x + 1 < h->mb_width) {
XCHG(h->top_borders[top_idx][h->mb_x + 1],
src_y + (17 << pixel_shift), 1);
}
}
if (simple || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) {
if (chroma444) {
if (deblock_top) {
if (deblock_topleft) {
XCHG(top_border_m1 + (24 << pixel_shift), src_cb - (7 << pixel_shift), 1);
XCHG(top_border_m1 + (40 << pixel_shift), src_cr - (7 << pixel_shift), 1);
}
XCHG(top_border + (16 << pixel_shift), src_cb + (1 << pixel_shift), xchg);
XCHG(top_border + (24 << pixel_shift), src_cb + (9 << pixel_shift), 1);
XCHG(top_border + (32 << pixel_shift), src_cr + (1 << pixel_shift), xchg);
XCHG(top_border + (40 << pixel_shift), src_cr + (9 << pixel_shift), 1);
if (h->mb_x + 1 < h->mb_width) {
XCHG(h->top_borders[top_idx][h->mb_x + 1] + (16 << pixel_shift), src_cb + (17 << pixel_shift), 1);
XCHG(h->top_borders[top_idx][h->mb_x + 1] + (32 << pixel_shift), src_cr + (17 << pixel_shift), 1);
}
}
} else {
if (deblock_top) {
if (deblock_topleft) {
XCHG(top_border_m1 + (16 << pixel_shift), src_cb - (7 << pixel_shift), 1);
XCHG(top_border_m1 + (24 << pixel_shift), src_cr - (7 << pixel_shift), 1);
}
XCHG(top_border + (16 << pixel_shift), src_cb + 1 + pixel_shift, 1);
XCHG(top_border + (24 << pixel_shift), src_cr + 1 + pixel_shift, 1);
}
}
}
}
| false | FFmpeg | e6c90ce94f1b07f50cea2babf7471af455cca0ff | static av_always_inline void xchg_mb_border(H264Context *h, H264SliceContext *sl,
uint8_t *src_y,
uint8_t *src_cb, uint8_t *src_cr,
int linesize, int uvlinesize,
int xchg, int chroma444,
int simple, int pixel_shift)
{
int deblock_topleft;
int deblock_top;
int top_idx = 1;
uint8_t *top_border_m1;
uint8_t *top_border;
if (!simple && FRAME_MBAFF(h)) {
if (h->mb_y & 1) {
if (!MB_MBAFF(h))
return;
} else {
top_idx = MB_MBAFF(h) ? 0 : 1;
}
}
if (h->deblocking_filter == 2) {
deblock_topleft = h->slice_table[h->mb_xy - 1 - h->mb_stride] == sl->slice_num;
deblock_top = sl->top_type;
} else {
deblock_topleft = (h->mb_x > 0);
deblock_top = (h->mb_y > !!MB_FIELD(h));
}
src_y -= linesize + 1 + pixel_shift;
src_cb -= uvlinesize + 1 + pixel_shift;
src_cr -= uvlinesize + 1 + pixel_shift;
top_border_m1 = h->top_borders[top_idx][h->mb_x - 1];
top_border = h->top_borders[top_idx][h->mb_x];
#define XCHG(a, b, xchg) \
if (pixel_shift) { \
if (xchg) { \
AV_SWAP64(b + 0, a + 0); \
AV_SWAP64(b + 8, a + 8); \
} else { \
AV_COPY128(b, a); \
} \
} else if (xchg) \
AV_SWAP64(b, a); \
else \
AV_COPY64(b, a);
if (deblock_top) {
if (deblock_topleft) {
XCHG(top_border_m1 + (8 << pixel_shift),
src_y - (7 << pixel_shift), 1);
}
XCHG(top_border + (0 << pixel_shift), src_y + (1 << pixel_shift), xchg);
XCHG(top_border + (8 << pixel_shift), src_y + (9 << pixel_shift), 1);
if (h->mb_x + 1 < h->mb_width) {
XCHG(h->top_borders[top_idx][h->mb_x + 1],
src_y + (17 << pixel_shift), 1);
}
}
if (simple || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) {
if (chroma444) {
if (deblock_top) {
if (deblock_topleft) {
XCHG(top_border_m1 + (24 << pixel_shift), src_cb - (7 << pixel_shift), 1);
XCHG(top_border_m1 + (40 << pixel_shift), src_cr - (7 << pixel_shift), 1);
}
XCHG(top_border + (16 << pixel_shift), src_cb + (1 << pixel_shift), xchg);
XCHG(top_border + (24 << pixel_shift), src_cb + (9 << pixel_shift), 1);
XCHG(top_border + (32 << pixel_shift), src_cr + (1 << pixel_shift), xchg);
XCHG(top_border + (40 << pixel_shift), src_cr + (9 << pixel_shift), 1);
if (h->mb_x + 1 < h->mb_width) {
XCHG(h->top_borders[top_idx][h->mb_x + 1] + (16 << pixel_shift), src_cb + (17 << pixel_shift), 1);
XCHG(h->top_borders[top_idx][h->mb_x + 1] + (32 << pixel_shift), src_cr + (17 << pixel_shift), 1);
}
}
} else {
if (deblock_top) {
if (deblock_topleft) {
XCHG(top_border_m1 + (16 << pixel_shift), src_cb - (7 << pixel_shift), 1);
XCHG(top_border_m1 + (24 << pixel_shift), src_cr - (7 << pixel_shift), 1);
}
XCHG(top_border + (16 << pixel_shift), src_cb + 1 + pixel_shift, 1);
XCHG(top_border + (24 << pixel_shift), src_cr + 1 + pixel_shift, 1);
}
}
}
}
| {
"code": [],
"line_no": []
} | static av_always_inline void FUNC_0(H264Context *h, H264SliceContext *sl,
uint8_t *src_y,
uint8_t *src_cb, uint8_t *src_cr,
int linesize, int uvlinesize,
int xchg, int chroma444,
int simple, int pixel_shift)
{
int VAR_0;
int VAR_1;
int VAR_2 = 1;
uint8_t *top_border_m1;
uint8_t *top_border;
if (!simple && FRAME_MBAFF(h)) {
if (h->mb_y & 1) {
if (!MB_MBAFF(h))
return;
} else {
VAR_2 = MB_MBAFF(h) ? 0 : 1;
}
}
if (h->deblocking_filter == 2) {
VAR_0 = h->slice_table[h->mb_xy - 1 - h->mb_stride] == sl->slice_num;
VAR_1 = sl->top_type;
} else {
VAR_0 = (h->mb_x > 0);
VAR_1 = (h->mb_y > !!MB_FIELD(h));
}
src_y -= linesize + 1 + pixel_shift;
src_cb -= uvlinesize + 1 + pixel_shift;
src_cr -= uvlinesize + 1 + pixel_shift;
top_border_m1 = h->top_borders[VAR_2][h->mb_x - 1];
top_border = h->top_borders[VAR_2][h->mb_x];
#define XCHG(a, b, xchg) \
if (pixel_shift) { \
if (xchg) { \
AV_SWAP64(b + 0, a + 0); \
AV_SWAP64(b + 8, a + 8); \
} else { \
AV_COPY128(b, a); \
} \
} else if (xchg) \
AV_SWAP64(b, a); \
else \
AV_COPY64(b, a);
if (VAR_1) {
if (VAR_0) {
XCHG(top_border_m1 + (8 << pixel_shift),
src_y - (7 << pixel_shift), 1);
}
XCHG(top_border + (0 << pixel_shift), src_y + (1 << pixel_shift), xchg);
XCHG(top_border + (8 << pixel_shift), src_y + (9 << pixel_shift), 1);
if (h->mb_x + 1 < h->mb_width) {
XCHG(h->top_borders[VAR_2][h->mb_x + 1],
src_y + (17 << pixel_shift), 1);
}
}
if (simple || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) {
if (chroma444) {
if (VAR_1) {
if (VAR_0) {
XCHG(top_border_m1 + (24 << pixel_shift), src_cb - (7 << pixel_shift), 1);
XCHG(top_border_m1 + (40 << pixel_shift), src_cr - (7 << pixel_shift), 1);
}
XCHG(top_border + (16 << pixel_shift), src_cb + (1 << pixel_shift), xchg);
XCHG(top_border + (24 << pixel_shift), src_cb + (9 << pixel_shift), 1);
XCHG(top_border + (32 << pixel_shift), src_cr + (1 << pixel_shift), xchg);
XCHG(top_border + (40 << pixel_shift), src_cr + (9 << pixel_shift), 1);
if (h->mb_x + 1 < h->mb_width) {
XCHG(h->top_borders[VAR_2][h->mb_x + 1] + (16 << pixel_shift), src_cb + (17 << pixel_shift), 1);
XCHG(h->top_borders[VAR_2][h->mb_x + 1] + (32 << pixel_shift), src_cr + (17 << pixel_shift), 1);
}
}
} else {
if (VAR_1) {
if (VAR_0) {
XCHG(top_border_m1 + (16 << pixel_shift), src_cb - (7 << pixel_shift), 1);
XCHG(top_border_m1 + (24 << pixel_shift), src_cr - (7 << pixel_shift), 1);
}
XCHG(top_border + (16 << pixel_shift), src_cb + 1 + pixel_shift, 1);
XCHG(top_border + (24 << pixel_shift), src_cr + 1 + pixel_shift, 1);
}
}
}
}
| [
"static av_always_inline void FUNC_0(H264Context *h, H264SliceContext *sl,\nuint8_t *src_y,\nuint8_t *src_cb, uint8_t *src_cr,\nint linesize, int uvlinesize,\nint xchg, int chroma444,\nint simple, int pixel_shift)\n{",
"int VAR_0;",
"int VAR_1;",
"int VAR_2 = 1;",
"uint8_t *top_border_m1;",
"uint8_t *top_... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
[
1,
3,
5,
7,
9,
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
... |
9,492 | unsigned int codec_get_tag(const CodecTag *tags, int id)
{
while (tags->id != 0) {
if (tags->id == id)
return tags->tag;
tags++;
}
return 0;
}
| false | FFmpeg | fb7a2bf6956173eda6f9caceef8599fa4f83500d | unsigned int codec_get_tag(const CodecTag *tags, int id)
{
while (tags->id != 0) {
if (tags->id == id)
return tags->tag;
tags++;
}
return 0;
}
| {
"code": [],
"line_no": []
} | unsigned int FUNC_0(const CodecTag *VAR_0, int VAR_1)
{
while (VAR_0->VAR_1 != 0) {
if (VAR_0->VAR_1 == VAR_1)
return VAR_0->tag;
VAR_0++;
}
return 0;
}
| [
"unsigned int FUNC_0(const CodecTag *VAR_0, int VAR_1)\n{",
"while (VAR_0->VAR_1 != 0) {",
"if (VAR_0->VAR_1 == VAR_1)\nreturn VAR_0->tag;",
"VAR_0++;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
9,493 | static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int buf_size)
{
MpegEncContext *s = &r->s;
GetBitContext *gb = &s->gb;
int mb_pos;
int res;
init_get_bits(&r->s.gb, buf, buf_size*8);
res = r->parse_slice_header(r, gb, &r->si);
if(res < 0){
av_log(s->avctx, AV_LOG_ERROR, "Incorrect or unknown slice header\n");
return -1;
if ((s->mb_x == 0 && s->mb_y == 0) || s->current_picture_ptr==NULL) {
if(s->width != r->si.width || s->height != r->si.height){
av_log(s->avctx, AV_LOG_DEBUG, "Changing dimensions to %dx%d\n", r->si.width,r->si.height);
MPV_common_end(s);
s->width = r->si.width;
s->height = r->si.height;
avcodec_set_dimensions(s->avctx, s->width, s->height);
if(MPV_common_init(s) < 0)
return -1;
r->intra_types_stride = s->mb_width*4 + 4;
r->intra_types_hist = av_realloc(r->intra_types_hist, r->intra_types_stride * 4 * 2 * sizeof(*r->intra_types_hist));
r->intra_types = r->intra_types_hist + r->intra_types_stride * 4;
r->mb_type = av_realloc(r->mb_type, r->s.mb_stride * r->s.mb_height * sizeof(*r->mb_type));
r->cbp_luma = av_realloc(r->cbp_luma, r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_luma));
r->cbp_chroma = av_realloc(r->cbp_chroma, r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_chroma));
r->deblock_coefs = av_realloc(r->deblock_coefs, r->s.mb_stride * r->s.mb_height * sizeof(*r->deblock_coefs));
s->pict_type = r->si.type ? r->si.type : AV_PICTURE_TYPE_I;
if(MPV_frame_start(s, s->avctx) < 0)
return -1;
ff_er_frame_start(s);
if (!r->tmp_b_block_base || s->width != r->si.width || s->height != r->si.height) {
int i;
av_free(r->tmp_b_block_base); //realloc() doesn't guarantee alignment
r->tmp_b_block_base = av_malloc(s->linesize * 48);
for (i = 0; i < 2; i++)
r->tmp_b_block_y[i] = r->tmp_b_block_base + i * 16 * s->linesize;
for (i = 0; i < 4; i++)
r->tmp_b_block_uv[i] = r->tmp_b_block_base + 32 * s->linesize
+ (i >> 1) * 8 * s->uvlinesize + (i & 1) * 16;
r->cur_pts = r->si.pts;
if(s->pict_type != AV_PICTURE_TYPE_B){
r->last_pts = r->next_pts;
r->next_pts = r->cur_pts;
}else{
int refdist = GET_PTS_DIFF(r->next_pts, r->last_pts);
int dist0 = GET_PTS_DIFF(r->cur_pts, r->last_pts);
int dist1 = GET_PTS_DIFF(r->next_pts, r->cur_pts);
if(!refdist){
r->weight1 = r->weight2 = 8192;
}else{
r->weight1 = (dist0 << 14) / refdist;
r->weight2 = (dist1 << 14) / refdist;
s->mb_x = s->mb_y = 0;
r->si.end = end;
s->qscale = r->si.quant;
r->bits = buf_size*8;
s->mb_num_left = r->si.end - r->si.start;
r->s.mb_skip_run = 0;
mb_pos = s->mb_x + s->mb_y * s->mb_width;
if(r->si.start != mb_pos){
av_log(s->avctx, AV_LOG_ERROR, "Slice indicates MB offset %d, got %d\n", r->si.start, mb_pos);
s->mb_x = r->si.start % s->mb_width;
s->mb_y = r->si.start / s->mb_width;
memset(r->intra_types_hist, -1, r->intra_types_stride * 4 * 2 * sizeof(*r->intra_types_hist));
s->first_slice_line = 1;
s->resync_mb_x = s->mb_x;
s->resync_mb_y = s->mb_y;
ff_init_block_index(s);
while(!check_slice_end(r, s)) {
ff_update_block_index(s);
s->dsp.clear_blocks(s->block[0]);
if(rv34_decode_macroblock(r, r->intra_types + s->mb_x * 4 + 4) < 0){
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_ERROR|DC_ERROR|MV_ERROR);
return -1;
if (++s->mb_x == s->mb_width) {
s->mb_x = 0;
s->mb_y++;
ff_init_block_index(s);
memmove(r->intra_types_hist, r->intra_types, r->intra_types_stride * 4 * sizeof(*r->intra_types_hist));
memset(r->intra_types, -1, r->intra_types_stride * 4 * sizeof(*r->intra_types_hist));
if(r->loop_filter && s->mb_y >= 2)
r->loop_filter(r, s->mb_y - 2);
if(s->mb_x == s->resync_mb_x)
s->first_slice_line=0;
s->mb_num_left--;
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END);
return s->mb_y == s->mb_height; | true | FFmpeg | 23a1f0c59241465ba30103388029a7afc0ead909 | static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int buf_size)
{
MpegEncContext *s = &r->s;
GetBitContext *gb = &s->gb;
int mb_pos;
int res;
init_get_bits(&r->s.gb, buf, buf_size*8);
res = r->parse_slice_header(r, gb, &r->si);
if(res < 0){
av_log(s->avctx, AV_LOG_ERROR, "Incorrect or unknown slice header\n");
return -1;
if ((s->mb_x == 0 && s->mb_y == 0) || s->current_picture_ptr==NULL) {
if(s->width != r->si.width || s->height != r->si.height){
av_log(s->avctx, AV_LOG_DEBUG, "Changing dimensions to %dx%d\n", r->si.width,r->si.height);
MPV_common_end(s);
s->width = r->si.width;
s->height = r->si.height;
avcodec_set_dimensions(s->avctx, s->width, s->height);
if(MPV_common_init(s) < 0)
return -1;
r->intra_types_stride = s->mb_width*4 + 4;
r->intra_types_hist = av_realloc(r->intra_types_hist, r->intra_types_stride * 4 * 2 * sizeof(*r->intra_types_hist));
r->intra_types = r->intra_types_hist + r->intra_types_stride * 4;
r->mb_type = av_realloc(r->mb_type, r->s.mb_stride * r->s.mb_height * sizeof(*r->mb_type));
r->cbp_luma = av_realloc(r->cbp_luma, r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_luma));
r->cbp_chroma = av_realloc(r->cbp_chroma, r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_chroma));
r->deblock_coefs = av_realloc(r->deblock_coefs, r->s.mb_stride * r->s.mb_height * sizeof(*r->deblock_coefs));
s->pict_type = r->si.type ? r->si.type : AV_PICTURE_TYPE_I;
if(MPV_frame_start(s, s->avctx) < 0)
return -1;
ff_er_frame_start(s);
if (!r->tmp_b_block_base || s->width != r->si.width || s->height != r->si.height) {
int i;
av_free(r->tmp_b_block_base);
r->tmp_b_block_base = av_malloc(s->linesize * 48);
for (i = 0; i < 2; i++)
r->tmp_b_block_y[i] = r->tmp_b_block_base + i * 16 * s->linesize;
for (i = 0; i < 4; i++)
r->tmp_b_block_uv[i] = r->tmp_b_block_base + 32 * s->linesize
+ (i >> 1) * 8 * s->uvlinesize + (i & 1) * 16;
r->cur_pts = r->si.pts;
if(s->pict_type != AV_PICTURE_TYPE_B){
r->last_pts = r->next_pts;
r->next_pts = r->cur_pts;
}else{
int refdist = GET_PTS_DIFF(r->next_pts, r->last_pts);
int dist0 = GET_PTS_DIFF(r->cur_pts, r->last_pts);
int dist1 = GET_PTS_DIFF(r->next_pts, r->cur_pts);
if(!refdist){
r->weight1 = r->weight2 = 8192;
}else{
r->weight1 = (dist0 << 14) / refdist;
r->weight2 = (dist1 << 14) / refdist;
s->mb_x = s->mb_y = 0;
r->si.end = end;
s->qscale = r->si.quant;
r->bits = buf_size*8;
s->mb_num_left = r->si.end - r->si.start;
r->s.mb_skip_run = 0;
mb_pos = s->mb_x + s->mb_y * s->mb_width;
if(r->si.start != mb_pos){
av_log(s->avctx, AV_LOG_ERROR, "Slice indicates MB offset %d, got %d\n", r->si.start, mb_pos);
s->mb_x = r->si.start % s->mb_width;
s->mb_y = r->si.start / s->mb_width;
memset(r->intra_types_hist, -1, r->intra_types_stride * 4 * 2 * sizeof(*r->intra_types_hist));
s->first_slice_line = 1;
s->resync_mb_x = s->mb_x;
s->resync_mb_y = s->mb_y;
ff_init_block_index(s);
while(!check_slice_end(r, s)) {
ff_update_block_index(s);
s->dsp.clear_blocks(s->block[0]);
if(rv34_decode_macroblock(r, r->intra_types + s->mb_x * 4 + 4) < 0){
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_ERROR|DC_ERROR|MV_ERROR);
return -1;
if (++s->mb_x == s->mb_width) {
s->mb_x = 0;
s->mb_y++;
ff_init_block_index(s);
memmove(r->intra_types_hist, r->intra_types, r->intra_types_stride * 4 * sizeof(*r->intra_types_hist));
memset(r->intra_types, -1, r->intra_types_stride * 4 * sizeof(*r->intra_types_hist));
if(r->loop_filter && s->mb_y >= 2)
r->loop_filter(r, s->mb_y - 2);
if(s->mb_x == s->resync_mb_x)
s->first_slice_line=0;
s->mb_num_left--;
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END);
return s->mb_y == s->mb_height; | {
"code": [],
"line_no": []
} | static int FUNC_0(RV34DecContext *VAR_0, int VAR_1, const uint8_t* VAR_2, int VAR_3)
{
MpegEncContext *s = &VAR_0->s;
GetBitContext *gb = &s->gb;
int VAR_4;
int VAR_5;
init_get_bits(&VAR_0->s.gb, VAR_2, VAR_3*8);
VAR_5 = VAR_0->parse_slice_header(VAR_0, gb, &VAR_0->si);
if(VAR_5 < 0){
av_log(s->avctx, AV_LOG_ERROR, "Incorrect or unknown slice header\n");
return -1;
if ((s->mb_x == 0 && s->mb_y == 0) || s->current_picture_ptr==NULL) {
if(s->width != VAR_0->si.width || s->height != VAR_0->si.height){
av_log(s->avctx, AV_LOG_DEBUG, "Changing dimensions to %dx%d\n", VAR_0->si.width,VAR_0->si.height);
MPV_common_end(s);
s->width = VAR_0->si.width;
s->height = VAR_0->si.height;
avcodec_set_dimensions(s->avctx, s->width, s->height);
if(MPV_common_init(s) < 0)
return -1;
VAR_0->intra_types_stride = s->mb_width*4 + 4;
VAR_0->intra_types_hist = av_realloc(VAR_0->intra_types_hist, VAR_0->intra_types_stride * 4 * 2 * sizeof(*VAR_0->intra_types_hist));
VAR_0->intra_types = VAR_0->intra_types_hist + VAR_0->intra_types_stride * 4;
VAR_0->mb_type = av_realloc(VAR_0->mb_type, VAR_0->s.mb_stride * VAR_0->s.mb_height * sizeof(*VAR_0->mb_type));
VAR_0->cbp_luma = av_realloc(VAR_0->cbp_luma, VAR_0->s.mb_stride * VAR_0->s.mb_height * sizeof(*VAR_0->cbp_luma));
VAR_0->cbp_chroma = av_realloc(VAR_0->cbp_chroma, VAR_0->s.mb_stride * VAR_0->s.mb_height * sizeof(*VAR_0->cbp_chroma));
VAR_0->deblock_coefs = av_realloc(VAR_0->deblock_coefs, VAR_0->s.mb_stride * VAR_0->s.mb_height * sizeof(*VAR_0->deblock_coefs));
s->pict_type = VAR_0->si.type ? VAR_0->si.type : AV_PICTURE_TYPE_I;
if(MPV_frame_start(s, s->avctx) < 0)
return -1;
ff_er_frame_start(s);
if (!VAR_0->tmp_b_block_base || s->width != VAR_0->si.width || s->height != VAR_0->si.height) {
int VAR_6;
av_free(VAR_0->tmp_b_block_base);
VAR_0->tmp_b_block_base = av_malloc(s->linesize * 48);
for (VAR_6 = 0; VAR_6 < 2; VAR_6++)
VAR_0->tmp_b_block_y[VAR_6] = VAR_0->tmp_b_block_base + VAR_6 * 16 * s->linesize;
for (VAR_6 = 0; VAR_6 < 4; VAR_6++)
VAR_0->tmp_b_block_uv[VAR_6] = VAR_0->tmp_b_block_base + 32 * s->linesize
+ (VAR_6 >> 1) * 8 * s->uvlinesize + (VAR_6 & 1) * 16;
VAR_0->cur_pts = VAR_0->si.pts;
if(s->pict_type != AV_PICTURE_TYPE_B){
VAR_0->last_pts = VAR_0->next_pts;
VAR_0->next_pts = VAR_0->cur_pts;
}else{
int VAR_7 = GET_PTS_DIFF(VAR_0->next_pts, VAR_0->last_pts);
int VAR_8 = GET_PTS_DIFF(VAR_0->cur_pts, VAR_0->last_pts);
int VAR_9 = GET_PTS_DIFF(VAR_0->next_pts, VAR_0->cur_pts);
if(!VAR_7){
VAR_0->weight1 = VAR_0->weight2 = 8192;
}else{
VAR_0->weight1 = (VAR_8 << 14) / VAR_7;
VAR_0->weight2 = (VAR_9 << 14) / VAR_7;
s->mb_x = s->mb_y = 0;
VAR_0->si.VAR_1 = VAR_1;
s->qscale = VAR_0->si.quant;
VAR_0->bits = VAR_3*8;
s->mb_num_left = VAR_0->si.VAR_1 - VAR_0->si.start;
VAR_0->s.mb_skip_run = 0;
VAR_4 = s->mb_x + s->mb_y * s->mb_width;
if(VAR_0->si.start != VAR_4){
av_log(s->avctx, AV_LOG_ERROR, "Slice indicates MB offset %d, got %d\n", VAR_0->si.start, VAR_4);
s->mb_x = VAR_0->si.start % s->mb_width;
s->mb_y = VAR_0->si.start / s->mb_width;
memset(VAR_0->intra_types_hist, -1, VAR_0->intra_types_stride * 4 * 2 * sizeof(*VAR_0->intra_types_hist));
s->first_slice_line = 1;
s->resync_mb_x = s->mb_x;
s->resync_mb_y = s->mb_y;
ff_init_block_index(s);
while(!check_slice_end(VAR_0, s)) {
ff_update_block_index(s);
s->dsp.clear_blocks(s->block[0]);
if(rv34_decode_macroblock(VAR_0, VAR_0->intra_types + s->mb_x * 4 + 4) < 0){
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_ERROR|DC_ERROR|MV_ERROR);
return -1;
if (++s->mb_x == s->mb_width) {
s->mb_x = 0;
s->mb_y++;
ff_init_block_index(s);
memmove(VAR_0->intra_types_hist, VAR_0->intra_types, VAR_0->intra_types_stride * 4 * sizeof(*VAR_0->intra_types_hist));
memset(VAR_0->intra_types, -1, VAR_0->intra_types_stride * 4 * sizeof(*VAR_0->intra_types_hist));
if(VAR_0->loop_filter && s->mb_y >= 2)
VAR_0->loop_filter(VAR_0, s->mb_y - 2);
if(s->mb_x == s->resync_mb_x)
s->first_slice_line=0;
s->mb_num_left--;
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END);
return s->mb_y == s->mb_height; | [
"static int FUNC_0(RV34DecContext *VAR_0, int VAR_1, const uint8_t* VAR_2, int VAR_3)\n{",
"MpegEncContext *s = &VAR_0->s;",
"GetBitContext *gb = &s->gb;",
"int VAR_4;",
"int VAR_5;",
"init_get_bits(&VAR_0->s.gb, VAR_2, VAR_3*8);",
"VAR_5 = VAR_0->parse_slice_header(VAR_0, gb, &VAR_0->si);",
"if(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... | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19,
20
],
[
21
],
[
... |
9,494 | static inline void RENAME(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
{
#ifdef HAVE_MMX
asm volatile(
"mov %4, %%"REG_a" \n\t"
"movq "MANGLE(w1111)", %%mm5 \n\t"
"movq "MANGLE(bgr2UCoeff)", %%mm6 \n\t"
"pxor %%mm7, %%mm7 \n\t"
"lea (%%"REG_a", %%"REG_a", 2), %%"REG_b" \n\t"
"add %%"REG_b", %%"REG_b" \n\t"
".balign 16 \n\t"
"1: \n\t"
PREFETCH" 64(%0, %%"REG_b") \n\t"
PREFETCH" 64(%1, %%"REG_b") \n\t"
#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
"movq (%0, %%"REG_b"), %%mm0 \n\t"
"movq (%1, %%"REG_b"), %%mm1 \n\t"
"movq 6(%0, %%"REG_b"), %%mm2 \n\t"
"movq 6(%1, %%"REG_b"), %%mm3 \n\t"
PAVGB(%%mm1, %%mm0)
PAVGB(%%mm3, %%mm2)
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"psrlq $24, %%mm0 \n\t"
"psrlq $24, %%mm2 \n\t"
PAVGB(%%mm1, %%mm0)
PAVGB(%%mm3, %%mm2)
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
#else
"movd (%0, %%"REG_b"), %%mm0 \n\t"
"movd (%1, %%"REG_b"), %%mm1 \n\t"
"movd 3(%0, %%"REG_b"), %%mm2 \n\t"
"movd 3(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm0 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm2, %%mm0 \n\t"
"movd 6(%0, %%"REG_b"), %%mm4 \n\t"
"movd 6(%1, %%"REG_b"), %%mm1 \n\t"
"movd 9(%0, %%"REG_b"), %%mm2 \n\t"
"movd 9(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm4 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm4, %%mm2 \n\t"
"psrlw $2, %%mm0 \n\t"
"psrlw $2, %%mm2 \n\t"
#endif
"movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t"
"movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t"
"pmaddwd %%mm0, %%mm1 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"pmaddwd %%mm6, %%mm0 \n\t"
"pmaddwd %%mm6, %%mm2 \n\t"
#ifndef FAST_BGR2YV12
"psrad $8, %%mm0 \n\t"
"psrad $8, %%mm1 \n\t"
"psrad $8, %%mm2 \n\t"
"psrad $8, %%mm3 \n\t"
#endif
"packssdw %%mm2, %%mm0 \n\t"
"packssdw %%mm3, %%mm1 \n\t"
"pmaddwd %%mm5, %%mm0 \n\t"
"pmaddwd %%mm5, %%mm1 \n\t"
"packssdw %%mm1, %%mm0 \n\t" // V1 V0 U1 U0
"psraw $7, %%mm0 \n\t"
#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
"movq 12(%0, %%"REG_b"), %%mm4 \n\t"
"movq 12(%1, %%"REG_b"), %%mm1 \n\t"
"movq 18(%0, %%"REG_b"), %%mm2 \n\t"
"movq 18(%1, %%"REG_b"), %%mm3 \n\t"
PAVGB(%%mm1, %%mm4)
PAVGB(%%mm3, %%mm2)
"movq %%mm4, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"psrlq $24, %%mm4 \n\t"
"psrlq $24, %%mm2 \n\t"
PAVGB(%%mm1, %%mm4)
PAVGB(%%mm3, %%mm2)
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
#else
"movd 12(%0, %%"REG_b"), %%mm4 \n\t"
"movd 12(%1, %%"REG_b"), %%mm1 \n\t"
"movd 15(%0, %%"REG_b"), %%mm2 \n\t"
"movd 15(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm4 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm2, %%mm4 \n\t"
"movd 18(%0, %%"REG_b"), %%mm5 \n\t"
"movd 18(%1, %%"REG_b"), %%mm1 \n\t"
"movd 21(%0, %%"REG_b"), %%mm2 \n\t"
"movd 21(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm5 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm5 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm5, %%mm2 \n\t"
"movq "MANGLE(w1111)", %%mm5 \n\t"
"psrlw $2, %%mm4 \n\t"
"psrlw $2, %%mm2 \n\t"
#endif
"movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t"
"movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t"
"pmaddwd %%mm4, %%mm1 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"pmaddwd %%mm6, %%mm4 \n\t"
"pmaddwd %%mm6, %%mm2 \n\t"
#ifndef FAST_BGR2YV12
"psrad $8, %%mm4 \n\t"
"psrad $8, %%mm1 \n\t"
"psrad $8, %%mm2 \n\t"
"psrad $8, %%mm3 \n\t"
#endif
"packssdw %%mm2, %%mm4 \n\t"
"packssdw %%mm3, %%mm1 \n\t"
"pmaddwd %%mm5, %%mm4 \n\t"
"pmaddwd %%mm5, %%mm1 \n\t"
"add $24, %%"REG_b" \n\t"
"packssdw %%mm1, %%mm4 \n\t" // V3 V2 U3 U2
"psraw $7, %%mm4 \n\t"
"movq %%mm0, %%mm1 \n\t"
"punpckldq %%mm4, %%mm0 \n\t"
"punpckhdq %%mm4, %%mm1 \n\t"
"packsswb %%mm1, %%mm0 \n\t"
"paddb "MANGLE(bgr2UVOffset)", %%mm0 \n\t"
"movd %%mm0, (%2, %%"REG_a") \n\t"
"punpckhdq %%mm0, %%mm0 \n\t"
"movd %%mm0, (%3, %%"REG_a") \n\t"
"add $4, %%"REG_a" \n\t"
" js 1b \n\t"
: : "r" (src1+width*6), "r" (src2+width*6), "r" (dstU+width), "r" (dstV+width), "g" ((long)-width)
: "%"REG_a, "%"REG_b
);
#else
int i;
for(i=0; i<width; i++)
{
int b= src1[6*i + 0] + src1[6*i + 3] + src2[6*i + 0] + src2[6*i + 3];
int g= src1[6*i + 1] + src1[6*i + 4] + src2[6*i + 1] + src2[6*i + 4];
int r= src1[6*i + 2] + src1[6*i + 5] + src2[6*i + 2] + src2[6*i + 5];
dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128;
dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128;
}
#endif
}
| true | FFmpeg | 7f526efd17973ec6d2204f7a47b6923e2be31363 | static inline void RENAME(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
{
#ifdef HAVE_MMX
asm volatile(
"mov %4, %%"REG_a" \n\t"
"movq "MANGLE(w1111)", %%mm5 \n\t"
"movq "MANGLE(bgr2UCoeff)", %%mm6 \n\t"
"pxor %%mm7, %%mm7 \n\t"
"lea (%%"REG_a", %%"REG_a", 2), %%"REG_b" \n\t"
"add %%"REG_b", %%"REG_b" \n\t"
".balign 16 \n\t"
"1: \n\t"
PREFETCH" 64(%0, %%"REG_b") \n\t"
PREFETCH" 64(%1, %%"REG_b") \n\t"
#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
"movq (%0, %%"REG_b"), %%mm0 \n\t"
"movq (%1, %%"REG_b"), %%mm1 \n\t"
"movq 6(%0, %%"REG_b"), %%mm2 \n\t"
"movq 6(%1, %%"REG_b"), %%mm3 \n\t"
PAVGB(%%mm1, %%mm0)
PAVGB(%%mm3, %%mm2)
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"psrlq $24, %%mm0 \n\t"
"psrlq $24, %%mm2 \n\t"
PAVGB(%%mm1, %%mm0)
PAVGB(%%mm3, %%mm2)
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
#else
"movd (%0, %%"REG_b"), %%mm0 \n\t"
"movd (%1, %%"REG_b"), %%mm1 \n\t"
"movd 3(%0, %%"REG_b"), %%mm2 \n\t"
"movd 3(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm0 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm2, %%mm0 \n\t"
"movd 6(%0, %%"REG_b"), %%mm4 \n\t"
"movd 6(%1, %%"REG_b"), %%mm1 \n\t"
"movd 9(%0, %%"REG_b"), %%mm2 \n\t"
"movd 9(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm4 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm4, %%mm2 \n\t"
"psrlw $2, %%mm0 \n\t"
"psrlw $2, %%mm2 \n\t"
#endif
"movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t"
"movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t"
"pmaddwd %%mm0, %%mm1 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"pmaddwd %%mm6, %%mm0 \n\t"
"pmaddwd %%mm6, %%mm2 \n\t"
#ifndef FAST_BGR2YV12
"psrad $8, %%mm0 \n\t"
"psrad $8, %%mm1 \n\t"
"psrad $8, %%mm2 \n\t"
"psrad $8, %%mm3 \n\t"
#endif
"packssdw %%mm2, %%mm0 \n\t"
"packssdw %%mm3, %%mm1 \n\t"
"pmaddwd %%mm5, %%mm0 \n\t"
"pmaddwd %%mm5, %%mm1 \n\t"
"packssdw %%mm1, %%mm0 \n\t"
"psraw $7, %%mm0 \n\t"
#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
"movq 12(%0, %%"REG_b"), %%mm4 \n\t"
"movq 12(%1, %%"REG_b"), %%mm1 \n\t"
"movq 18(%0, %%"REG_b"), %%mm2 \n\t"
"movq 18(%1, %%"REG_b"), %%mm3 \n\t"
PAVGB(%%mm1, %%mm4)
PAVGB(%%mm3, %%mm2)
"movq %%mm4, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"psrlq $24, %%mm4 \n\t"
"psrlq $24, %%mm2 \n\t"
PAVGB(%%mm1, %%mm4)
PAVGB(%%mm3, %%mm2)
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
#else
"movd 12(%0, %%"REG_b"), %%mm4 \n\t"
"movd 12(%1, %%"REG_b"), %%mm1 \n\t"
"movd 15(%0, %%"REG_b"), %%mm2 \n\t"
"movd 15(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm4 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm2, %%mm4 \n\t"
"movd 18(%0, %%"REG_b"), %%mm5 \n\t"
"movd 18(%1, %%"REG_b"), %%mm1 \n\t"
"movd 21(%0, %%"REG_b"), %%mm2 \n\t"
"movd 21(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm5 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm5 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm5, %%mm2 \n\t"
"movq "MANGLE(w1111)", %%mm5 \n\t"
"psrlw $2, %%mm4 \n\t"
"psrlw $2, %%mm2 \n\t"
#endif
"movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t"
"movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t"
"pmaddwd %%mm4, %%mm1 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"pmaddwd %%mm6, %%mm4 \n\t"
"pmaddwd %%mm6, %%mm2 \n\t"
#ifndef FAST_BGR2YV12
"psrad $8, %%mm4 \n\t"
"psrad $8, %%mm1 \n\t"
"psrad $8, %%mm2 \n\t"
"psrad $8, %%mm3 \n\t"
#endif
"packssdw %%mm2, %%mm4 \n\t"
"packssdw %%mm3, %%mm1 \n\t"
"pmaddwd %%mm5, %%mm4 \n\t"
"pmaddwd %%mm5, %%mm1 \n\t"
"add $24, %%"REG_b" \n\t"
"packssdw %%mm1, %%mm4 \n\t"
"psraw $7, %%mm4 \n\t"
"movq %%mm0, %%mm1 \n\t"
"punpckldq %%mm4, %%mm0 \n\t"
"punpckhdq %%mm4, %%mm1 \n\t"
"packsswb %%mm1, %%mm0 \n\t"
"paddb "MANGLE(bgr2UVOffset)", %%mm0 \n\t"
"movd %%mm0, (%2, %%"REG_a") \n\t"
"punpckhdq %%mm0, %%mm0 \n\t"
"movd %%mm0, (%3, %%"REG_a") \n\t"
"add $4, %%"REG_a" \n\t"
" js 1b \n\t"
: : "r" (src1+width*6), "r" (src2+width*6), "r" (dstU+width), "r" (dstV+width), "g" ((long)-width)
: "%"REG_a, "%"REG_b
);
#else
int i;
for(i=0; i<width; i++)
{
int b= src1[6*i + 0] + src1[6*i + 3] + src2[6*i + 0] + src2[6*i + 3];
int g= src1[6*i + 1] + src1[6*i + 4] + src2[6*i + 1] + src2[6*i + 4];
int r= src1[6*i + 2] + src1[6*i + 5] + src2[6*i + 2] + src2[6*i + 5];
dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128;
dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128;
}
#endif
}
| {
"code": [
"static inline void RENAME(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)",
"\t\t: : \"r\" (src1+width*6), \"r\" (src2+width*6), \"r\" (dstU+width), \"r\" (dstV+width), \"g\" ((long)-width)"
],
"line_no": [
1,
299
]
} | static inline void FUNC_0(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
{
#ifdef HAVE_MMX
asm volatile(
"mov %4, %%"REG_a" \n\t"
"movq "MANGLE(w1111)", %%mm5 \n\t"
"movq "MANGLE(bgr2UCoeff)", %%mm6 \n\t"
"pxor %%mm7, %%mm7 \n\t"
"lea (%%"REG_a", %%"REG_a", 2), %%"REG_b" \n\t"
"add %%"REG_b", %%"REG_b" \n\t"
".balign 16 \n\t"
"1: \n\t"
PREFETCH" 64(%0, %%"REG_b") \n\t"
PREFETCH" 64(%1, %%"REG_b") \n\t"
#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
"movq (%0, %%"REG_b"), %%mm0 \n\t"
"movq (%1, %%"REG_b"), %%mm1 \n\t"
"movq 6(%0, %%"REG_b"), %%mm2 \n\t"
"movq 6(%1, %%"REG_b"), %%mm3 \n\t"
PAVGB(%%mm1, %%mm0)
PAVGB(%%mm3, %%mm2)
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"psrlq $24, %%mm0 \n\t"
"psrlq $24, %%mm2 \n\t"
PAVGB(%%mm1, %%mm0)
PAVGB(%%mm3, %%mm2)
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
#else
"movd (%0, %%"REG_b"), %%mm0 \n\t"
"movd (%1, %%"REG_b"), %%mm1 \n\t"
"movd 3(%0, %%"REG_b"), %%mm2 \n\t"
"movd 3(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm0 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm2, %%mm0 \n\t"
"movd 6(%0, %%"REG_b"), %%mm4 \n\t"
"movd 6(%1, %%"REG_b"), %%mm1 \n\t"
"movd 9(%0, %%"REG_b"), %%mm2 \n\t"
"movd 9(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm4 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm4, %%mm2 \n\t"
"psrlw $2, %%mm0 \n\t"
"psrlw $2, %%mm2 \n\t"
#endif
"movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t"
"movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t"
"pmaddwd %%mm0, %%mm1 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"pmaddwd %%mm6, %%mm0 \n\t"
"pmaddwd %%mm6, %%mm2 \n\t"
#ifndef FAST_BGR2YV12
"psrad $8, %%mm0 \n\t"
"psrad $8, %%mm1 \n\t"
"psrad $8, %%mm2 \n\t"
"psrad $8, %%mm3 \n\t"
#endif
"packssdw %%mm2, %%mm0 \n\t"
"packssdw %%mm3, %%mm1 \n\t"
"pmaddwd %%mm5, %%mm0 \n\t"
"pmaddwd %%mm5, %%mm1 \n\t"
"packssdw %%mm1, %%mm0 \n\t"
"psraw $7, %%mm0 \n\t"
#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
"movq 12(%0, %%"REG_b"), %%mm4 \n\t"
"movq 12(%1, %%"REG_b"), %%mm1 \n\t"
"movq 18(%0, %%"REG_b"), %%mm2 \n\t"
"movq 18(%1, %%"REG_b"), %%mm3 \n\t"
PAVGB(%%mm1, %%mm4)
PAVGB(%%mm3, %%mm2)
"movq %%mm4, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"psrlq $24, %%mm4 \n\t"
"psrlq $24, %%mm2 \n\t"
PAVGB(%%mm1, %%mm4)
PAVGB(%%mm3, %%mm2)
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
#else
"movd 12(%0, %%"REG_b"), %%mm4 \n\t"
"movd 12(%1, %%"REG_b"), %%mm1 \n\t"
"movd 15(%0, %%"REG_b"), %%mm2 \n\t"
"movd 15(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm4 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm2, %%mm4 \n\t"
"movd 18(%0, %%"REG_b"), %%mm5 \n\t"
"movd 18(%1, %%"REG_b"), %%mm1 \n\t"
"movd 21(%0, %%"REG_b"), %%mm2 \n\t"
"movd 21(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm5 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm5 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm5, %%mm2 \n\t"
"movq "MANGLE(w1111)", %%mm5 \n\t"
"psrlw $2, %%mm4 \n\t"
"psrlw $2, %%mm2 \n\t"
#endif
"movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t"
"movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t"
"pmaddwd %%mm4, %%mm1 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"pmaddwd %%mm6, %%mm4 \n\t"
"pmaddwd %%mm6, %%mm2 \n\t"
#ifndef FAST_BGR2YV12
"psrad $8, %%mm4 \n\t"
"psrad $8, %%mm1 \n\t"
"psrad $8, %%mm2 \n\t"
"psrad $8, %%mm3 \n\t"
#endif
"packssdw %%mm2, %%mm4 \n\t"
"packssdw %%mm3, %%mm1 \n\t"
"pmaddwd %%mm5, %%mm4 \n\t"
"pmaddwd %%mm5, %%mm1 \n\t"
"add $24, %%"REG_b" \n\t"
"packssdw %%mm1, %%mm4 \n\t"
"psraw $7, %%mm4 \n\t"
"movq %%mm0, %%mm1 \n\t"
"punpckldq %%mm4, %%mm0 \n\t"
"punpckhdq %%mm4, %%mm1 \n\t"
"packsswb %%mm1, %%mm0 \n\t"
"paddb "MANGLE(bgr2UVOffset)", %%mm0 \n\t"
"movd %%mm0, (%2, %%"REG_a") \n\t"
"punpckhdq %%mm0, %%mm0 \n\t"
"movd %%mm0, (%3, %%"REG_a") \n\t"
"add $4, %%"REG_a" \n\t"
" js 1b \n\t"
: : "r" (src1+width*6), "r" (src2+width*6), "r" (dstU+width), "r" (dstV+width), "g" ((long)-width)
: "%"REG_a, "%"REG_b
);
#else
int VAR_0;
for(VAR_0=0; VAR_0<width; VAR_0++)
{
int b= src1[6*VAR_0 + 0] + src1[6*VAR_0 + 3] + src2[6*VAR_0 + 0] + src2[6*VAR_0 + 3];
int g= src1[6*VAR_0 + 1] + src1[6*VAR_0 + 4] + src2[6*VAR_0 + 1] + src2[6*VAR_0 + 4];
int r= src1[6*VAR_0 + 2] + src1[6*VAR_0 + 5] + src2[6*VAR_0 + 2] + src2[6*VAR_0 + 5];
dstU[VAR_0]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128;
dstV[VAR_0]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128;
}
#endif
}
| [
"static inline void FUNC_0(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)\n{",
"#ifdef HAVE_MMX\nasm volatile(\n\"mov %4, %%\"REG_a\"\t\t\\n\\t\"\n\"movq \"MANGLE(w1111)\", %%mm5\t\t\\n\\t\"\n\"movq \"MANGLE(bgr2UCoeff)\", %%mm6\t\t\\n\\t\"\n\"pxor %%mm7, %%mm7\t\t\\n\\t\"\n\"le... | [
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7,
9,
11,
13,
15,
17,
19,
21,
23,
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,... |
9,496 | static size_t pdu_marshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...)
{
size_t old_offset = offset;
va_list ap;
int i;
va_start(ap, fmt);
for (i = 0; fmt[i]; i++) {
switch (fmt[i]) {
case 'b': {
uint8_t val = va_arg(ap, int);
offset += pdu_pack(pdu, offset, &val, sizeof(val));
break;
}
case 'w': {
uint16_t val;
cpu_to_le16w(&val, va_arg(ap, int));
offset += pdu_pack(pdu, offset, &val, sizeof(val));
break;
}
case 'd': {
uint32_t val;
cpu_to_le32w(&val, va_arg(ap, uint32_t));
offset += pdu_pack(pdu, offset, &val, sizeof(val));
break;
}
case 'q': {
uint64_t val;
cpu_to_le64w(&val, va_arg(ap, uint64_t));
offset += pdu_pack(pdu, offset, &val, sizeof(val));
break;
}
case 'v': {
struct iovec *iov = va_arg(ap, struct iovec *);
int *iovcnt = va_arg(ap, int *);
*iovcnt = pdu_copy_sg(pdu, offset, 1, iov);
break;
}
case 's': {
V9fsString *str = va_arg(ap, V9fsString *);
offset += pdu_marshal(pdu, offset, "w", str->size);
offset += pdu_pack(pdu, offset, str->data, str->size);
break;
}
case 'Q': {
V9fsQID *qidp = va_arg(ap, V9fsQID *);
offset += pdu_marshal(pdu, offset, "bdq",
qidp->type, qidp->version, qidp->path);
break;
}
case 'S': {
V9fsStat *statp = va_arg(ap, V9fsStat *);
offset += pdu_marshal(pdu, offset, "wwdQdddqsssssddd",
statp->size, statp->type, statp->dev,
&statp->qid, statp->mode, statp->atime,
statp->mtime, statp->length, &statp->name,
&statp->uid, &statp->gid, &statp->muid,
&statp->extension, statp->n_uid,
statp->n_gid, statp->n_muid);
break;
}
case 'A': {
V9fsStatDotl *statp = va_arg(ap, V9fsStatDotl *);
offset += pdu_marshal(pdu, offset, "qQdddqqqqqqqqqqqqqqq",
statp->st_result_mask,
&statp->qid, statp->st_mode,
statp->st_uid, statp->st_gid,
statp->st_nlink, statp->st_rdev,
statp->st_size, statp->st_blksize, statp->st_blocks,
statp->st_atime_sec, statp->st_atime_nsec,
statp->st_mtime_sec, statp->st_mtime_nsec,
statp->st_ctime_sec, statp->st_ctime_nsec,
statp->st_btime_sec, statp->st_btime_nsec,
statp->st_gen, statp->st_data_version);
break;
}
default:
break;
}
}
va_end(ap);
return offset - old_offset;
}
| true | qemu | 302a0d3ed721e4c30c6a2a37f64c60b50ffd33b9 | static size_t pdu_marshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...)
{
size_t old_offset = offset;
va_list ap;
int i;
va_start(ap, fmt);
for (i = 0; fmt[i]; i++) {
switch (fmt[i]) {
case 'b': {
uint8_t val = va_arg(ap, int);
offset += pdu_pack(pdu, offset, &val, sizeof(val));
break;
}
case 'w': {
uint16_t val;
cpu_to_le16w(&val, va_arg(ap, int));
offset += pdu_pack(pdu, offset, &val, sizeof(val));
break;
}
case 'd': {
uint32_t val;
cpu_to_le32w(&val, va_arg(ap, uint32_t));
offset += pdu_pack(pdu, offset, &val, sizeof(val));
break;
}
case 'q': {
uint64_t val;
cpu_to_le64w(&val, va_arg(ap, uint64_t));
offset += pdu_pack(pdu, offset, &val, sizeof(val));
break;
}
case 'v': {
struct iovec *iov = va_arg(ap, struct iovec *);
int *iovcnt = va_arg(ap, int *);
*iovcnt = pdu_copy_sg(pdu, offset, 1, iov);
break;
}
case 's': {
V9fsString *str = va_arg(ap, V9fsString *);
offset += pdu_marshal(pdu, offset, "w", str->size);
offset += pdu_pack(pdu, offset, str->data, str->size);
break;
}
case 'Q': {
V9fsQID *qidp = va_arg(ap, V9fsQID *);
offset += pdu_marshal(pdu, offset, "bdq",
qidp->type, qidp->version, qidp->path);
break;
}
case 'S': {
V9fsStat *statp = va_arg(ap, V9fsStat *);
offset += pdu_marshal(pdu, offset, "wwdQdddqsssssddd",
statp->size, statp->type, statp->dev,
&statp->qid, statp->mode, statp->atime,
statp->mtime, statp->length, &statp->name,
&statp->uid, &statp->gid, &statp->muid,
&statp->extension, statp->n_uid,
statp->n_gid, statp->n_muid);
break;
}
case 'A': {
V9fsStatDotl *statp = va_arg(ap, V9fsStatDotl *);
offset += pdu_marshal(pdu, offset, "qQdddqqqqqqqqqqqqqqq",
statp->st_result_mask,
&statp->qid, statp->st_mode,
statp->st_uid, statp->st_gid,
statp->st_nlink, statp->st_rdev,
statp->st_size, statp->st_blksize, statp->st_blocks,
statp->st_atime_sec, statp->st_atime_nsec,
statp->st_mtime_sec, statp->st_mtime_nsec,
statp->st_ctime_sec, statp->st_ctime_nsec,
statp->st_btime_sec, statp->st_btime_nsec,
statp->st_gen, statp->st_data_version);
break;
}
default:
break;
}
}
va_end(ap);
return offset - old_offset;
}
| {
"code": [
" case 'v': {",
" struct iovec *iov = va_arg(ap, struct iovec *);",
" int *iovcnt = va_arg(ap, int *);",
" break;",
" case 'v': {",
" struct iovec *iov = va_arg(ap, struct iovec *);",
" int *iovcnt = va_arg(ap, int *);",
" *iovcnt = pdu_copy_sg(pdu, offset, 1, iov);",
" break;",
" int i;",
" break;"
],
"line_no": [
65,
67,
69,
25,
65,
67,
69,
71,
25,
9,
25
]
} | static size_t FUNC_0(V9fsPDU *pdu, size_t offset, const char *fmt, ...)
{
size_t old_offset = offset;
va_list ap;
int VAR_0;
va_start(ap, fmt);
for (VAR_0 = 0; fmt[VAR_0]; VAR_0++) {
switch (fmt[VAR_0]) {
case 'b': {
uint8_t val = va_arg(ap, int);
offset += pdu_pack(pdu, offset, &val, sizeof(val));
break;
}
case 'w': {
uint16_t val;
cpu_to_le16w(&val, va_arg(ap, int));
offset += pdu_pack(pdu, offset, &val, sizeof(val));
break;
}
case 'd': {
uint32_t val;
cpu_to_le32w(&val, va_arg(ap, uint32_t));
offset += pdu_pack(pdu, offset, &val, sizeof(val));
break;
}
case 'q': {
uint64_t val;
cpu_to_le64w(&val, va_arg(ap, uint64_t));
offset += pdu_pack(pdu, offset, &val, sizeof(val));
break;
}
case 'v': {
struct iovec *VAR_1 = va_arg(ap, struct iovec *);
int *VAR_2 = va_arg(ap, int *);
*VAR_2 = pdu_copy_sg(pdu, offset, 1, VAR_1);
break;
}
case 's': {
V9fsString *str = va_arg(ap, V9fsString *);
offset += FUNC_0(pdu, offset, "w", str->size);
offset += pdu_pack(pdu, offset, str->data, str->size);
break;
}
case 'Q': {
V9fsQID *qidp = va_arg(ap, V9fsQID *);
offset += FUNC_0(pdu, offset, "bdq",
qidp->type, qidp->version, qidp->path);
break;
}
case 'S': {
V9fsStat *statp = va_arg(ap, V9fsStat *);
offset += FUNC_0(pdu, offset, "wwdQdddqsssssddd",
statp->size, statp->type, statp->dev,
&statp->qid, statp->mode, statp->atime,
statp->mtime, statp->length, &statp->name,
&statp->uid, &statp->gid, &statp->muid,
&statp->extension, statp->n_uid,
statp->n_gid, statp->n_muid);
break;
}
case 'A': {
V9fsStatDotl *statp = va_arg(ap, V9fsStatDotl *);
offset += FUNC_0(pdu, offset, "qQdddqqqqqqqqqqqqqqq",
statp->st_result_mask,
&statp->qid, statp->st_mode,
statp->st_uid, statp->st_gid,
statp->st_nlink, statp->st_rdev,
statp->st_size, statp->st_blksize, statp->st_blocks,
statp->st_atime_sec, statp->st_atime_nsec,
statp->st_mtime_sec, statp->st_mtime_nsec,
statp->st_ctime_sec, statp->st_ctime_nsec,
statp->st_btime_sec, statp->st_btime_nsec,
statp->st_gen, statp->st_data_version);
break;
}
default:
break;
}
}
va_end(ap);
return offset - old_offset;
}
| [
"static size_t FUNC_0(V9fsPDU *pdu, size_t offset, const char *fmt, ...)\n{",
"size_t old_offset = offset;",
"va_list ap;",
"int VAR_0;",
"va_start(ap, fmt);",
"for (VAR_0 = 0; fmt[VAR_0]; VAR_0++) {",
"switch (fmt[VAR_0]) {",
"case 'b': {",
"uint8_t val = va_arg(ap, int);",
"offset += pdu_pack(pd... | [
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,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
... |
9,497 | static inline uint32_t celt_icwrsi(uint32_t N, uint32_t K, const int *y)
{
int i, idx = 0, sum = 0;
for (i = N - 1; i >= 0; i--) {
const uint32_t i_s = CELT_PVQ_U(N - i, sum + FFABS(y[i]) + 1);
idx += CELT_PVQ_U(N - i, sum) + (y[i] < 0)*i_s;
sum += FFABS(y[i]);
}
av_assert0(sum == K);
return idx;
}
| true | FFmpeg | f19442c069929727b19c948619488370d279e177 | static inline uint32_t celt_icwrsi(uint32_t N, uint32_t K, const int *y)
{
int i, idx = 0, sum = 0;
for (i = N - 1; i >= 0; i--) {
const uint32_t i_s = CELT_PVQ_U(N - i, sum + FFABS(y[i]) + 1);
idx += CELT_PVQ_U(N - i, sum) + (y[i] < 0)*i_s;
sum += FFABS(y[i]);
}
av_assert0(sum == K);
return idx;
}
| {
"code": [
" av_assert0(sum == K);"
],
"line_no": [
17
]
} | static inline uint32_t FUNC_0(uint32_t N, uint32_t K, const int *y)
{
int VAR_0, VAR_1 = 0, VAR_2 = 0;
for (VAR_0 = N - 1; VAR_0 >= 0; VAR_0--) {
const uint32_t VAR_3 = CELT_PVQ_U(N - VAR_0, VAR_2 + FFABS(y[VAR_0]) + 1);
VAR_1 += CELT_PVQ_U(N - VAR_0, VAR_2) + (y[VAR_0] < 0)*VAR_3;
VAR_2 += FFABS(y[VAR_0]);
}
av_assert0(VAR_2 == K);
return VAR_1;
}
| [
"static inline uint32_t FUNC_0(uint32_t N, uint32_t K, const int *y)\n{",
"int VAR_0, VAR_1 = 0, VAR_2 = 0;",
"for (VAR_0 = N - 1; VAR_0 >= 0; VAR_0--) {",
"const uint32_t VAR_3 = CELT_PVQ_U(N - VAR_0, VAR_2 + FFABS(y[VAR_0]) + 1);",
"VAR_1 += CELT_PVQ_U(N - VAR_0, VAR_2) + (y[VAR_0] < 0)*VAR_3;",
"VAR_2 ... | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
9,498 | static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
MatroskaDemuxContext *matroska = s->priv_data;
EbmlList *attachements_list = &matroska->attachments;
MatroskaAttachement *attachements;
EbmlList *chapters_list = &matroska->chapters;
MatroskaChapter *chapters;
MatroskaTrack *tracks;
EbmlList *index_list;
MatroskaIndex *index;
int index_scale = 1;
Ebml ebml = { 0 };
AVStream *st;
int i, j;
matroska->ctx = s;
/* First read the EBML header. */
if (ebml_parse(matroska, ebml_syntax, &ebml)
|| ebml.version > EBML_VERSION || ebml.max_size > sizeof(uint64_t)
|| ebml.id_length > sizeof(uint32_t) || strcmp(ebml.doctype, "matroska")
|| ebml.doctype_version > 2) {
av_log(matroska->ctx, AV_LOG_ERROR,
"EBML header using unsupported features\n"
"(EBML version %"PRIu64", doctype %s, doc version %"PRIu64")\n",
ebml.version, ebml.doctype, ebml.doctype_version);
return AVERROR_NOFMT;
}
ebml_free(ebml_syntax, &ebml);
/* The next thing is a segment. */
if (ebml_parse(matroska, matroska_segments, matroska) < 0)
return -1;
matroska_execute_seekhead(matroska);
if (matroska->duration)
matroska->ctx->duration = matroska->duration * matroska->time_scale
* 1000 / AV_TIME_BASE;
if (matroska->title)
strncpy(matroska->ctx->title, matroska->title,
sizeof(matroska->ctx->title)-1);
matroska_convert_tags(s, &matroska->tags);
tracks = matroska->tracks.elem;
for (i=0; i < matroska->tracks.nb_elem; i++) {
MatroskaTrack *track = &tracks[i];
enum CodecID codec_id = CODEC_ID_NONE;
EbmlList *encodings_list = &tracks->encodings;
MatroskaTrackEncoding *encodings = encodings_list->elem;
uint8_t *extradata = NULL;
int extradata_size = 0;
int extradata_offset = 0;
/* Apply some sanity checks. */
if (track->type != MATROSKA_TRACK_TYPE_VIDEO &&
track->type != MATROSKA_TRACK_TYPE_AUDIO &&
track->type != MATROSKA_TRACK_TYPE_SUBTITLE) {
av_log(matroska->ctx, AV_LOG_INFO,
"Unknown or unsupported track type %"PRIu64"\n",
track->type);
continue;
}
if (track->codec_id == NULL)
continue;
if (track->type == MATROSKA_TRACK_TYPE_VIDEO) {
if (!track->default_duration)
track->default_duration = 1000000000/track->video.frame_rate;
if (!track->video.display_width)
track->video.display_width = track->video.pixel_width;
if (!track->video.display_height)
track->video.display_height = track->video.pixel_height;
} else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
if (!track->audio.out_samplerate)
track->audio.out_samplerate = track->audio.samplerate;
}
if (encodings_list->nb_elem > 1) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Multiple combined encodings no supported");
} else if (encodings_list->nb_elem == 1) {
if (encodings[0].type ||
(encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP &&
#ifdef CONFIG_ZLIB
encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_ZLIB &&
#endif
#ifdef CONFIG_BZLIB
encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_BZLIB &&
#endif
encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_LZO)) {
encodings[0].scope = 0;
av_log(matroska->ctx, AV_LOG_ERROR,
"Unsupported encoding type");
} else if (track->codec_priv.size && encodings[0].scope&2) {
uint8_t *codec_priv = track->codec_priv.data;
int offset = matroska_decode_buffer(&track->codec_priv.data,
&track->codec_priv.size,
track);
if (offset < 0) {
track->codec_priv.data = NULL;
track->codec_priv.size = 0;
av_log(matroska->ctx, AV_LOG_ERROR,
"Failed to decode codec private data\n");
} else if (offset > 0) {
track->codec_priv.data = av_malloc(track->codec_priv.size + offset);
memcpy(track->codec_priv.data,
encodings[0].compression.settings.data, offset);
memcpy(track->codec_priv.data+offset, codec_priv,
track->codec_priv.size);
track->codec_priv.size += offset;
}
if (codec_priv != track->codec_priv.data)
av_free(codec_priv);
}
}
for(j=0; ff_mkv_codec_tags[j].id != CODEC_ID_NONE; j++){
if(!strncmp(ff_mkv_codec_tags[j].str, track->codec_id,
strlen(ff_mkv_codec_tags[j].str))){
codec_id= ff_mkv_codec_tags[j].id;
break;
}
}
st = track->stream = av_new_stream(s, 0);
if (st == NULL)
return AVERROR(ENOMEM);
if (!strcmp(track->codec_id, "V_MS/VFW/FOURCC")
&& track->codec_priv.size >= 40
&& track->codec_priv.data != NULL) {
track->video.fourcc = AV_RL32(track->codec_priv.data + 16);
codec_id = codec_get_id(codec_bmp_tags, track->video.fourcc);
} else if (!strcmp(track->codec_id, "A_MS/ACM")
&& track->codec_priv.size >= 18
&& track->codec_priv.data != NULL) {
uint16_t tag = AV_RL16(track->codec_priv.data);
codec_id = codec_get_id(codec_wav_tags, tag);
} else if (!strcmp(track->codec_id, "V_QUICKTIME")
&& (track->codec_priv.size >= 86)
&& (track->codec_priv.data != NULL)) {
track->video.fourcc = AV_RL32(track->codec_priv.data);
codec_id=codec_get_id(codec_movvideo_tags, track->video.fourcc);
} else if (codec_id == CODEC_ID_PCM_S16BE) {
switch (track->audio.bitdepth) {
case 8: codec_id = CODEC_ID_PCM_U8; break;
case 24: codec_id = CODEC_ID_PCM_S24BE; break;
case 32: codec_id = CODEC_ID_PCM_S32BE; break;
}
} else if (codec_id == CODEC_ID_PCM_S16LE) {
switch (track->audio.bitdepth) {
case 8: codec_id = CODEC_ID_PCM_U8; break;
case 24: codec_id = CODEC_ID_PCM_S24LE; break;
case 32: codec_id = CODEC_ID_PCM_S32LE; break;
}
} else if (codec_id==CODEC_ID_PCM_F32LE && track->audio.bitdepth==64) {
codec_id = CODEC_ID_PCM_F64LE;
} else if (codec_id == CODEC_ID_AAC && !track->codec_priv.size) {
int profile = matroska_aac_profile(track->codec_id);
int sri = matroska_aac_sri(track->audio.samplerate);
extradata = av_malloc(5);
if (extradata == NULL)
return AVERROR(ENOMEM);
extradata[0] = (profile << 3) | ((sri&0x0E) >> 1);
extradata[1] = ((sri&0x01) << 7) | (track->audio.channels<<3);
if (strstr(track->codec_id, "SBR")) {
sri = matroska_aac_sri(track->audio.out_samplerate);
extradata[2] = 0x56;
extradata[3] = 0xE5;
extradata[4] = 0x80 | (sri<<3);
extradata_size = 5;
} else
extradata_size = 2;
} else if (codec_id == CODEC_ID_TTA) {
ByteIOContext b;
extradata_size = 30;
extradata = av_mallocz(extradata_size);
if (extradata == NULL)
return AVERROR(ENOMEM);
init_put_byte(&b, extradata, extradata_size, 1,
NULL, NULL, NULL, NULL);
put_buffer(&b, "TTA1", 4);
put_le16(&b, 1);
put_le16(&b, track->audio.channels);
put_le16(&b, track->audio.bitdepth);
put_le32(&b, track->audio.out_samplerate);
put_le32(&b, matroska->ctx->duration * track->audio.out_samplerate);
} else if (codec_id == CODEC_ID_RV10 || codec_id == CODEC_ID_RV20 ||
codec_id == CODEC_ID_RV30 || codec_id == CODEC_ID_RV40) {
extradata_offset = 26;
track->codec_priv.size -= extradata_offset;
} else if (codec_id == CODEC_ID_RA_144) {
track->audio.out_samplerate = 8000;
track->audio.channels = 1;
} else if (codec_id == CODEC_ID_RA_288 || codec_id == CODEC_ID_COOK ||
codec_id == CODEC_ID_ATRAC3) {
ByteIOContext b;
init_put_byte(&b, track->codec_priv.data,track->codec_priv.size,
0, NULL, NULL, NULL, NULL);
url_fskip(&b, 24);
track->audio.coded_framesize = get_be32(&b);
url_fskip(&b, 12);
track->audio.sub_packet_h = get_be16(&b);
track->audio.frame_size = get_be16(&b);
track->audio.sub_packet_size = get_be16(&b);
track->audio.buf = av_malloc(track->audio.frame_size * track->audio.sub_packet_h);
if (codec_id == CODEC_ID_RA_288) {
st->codec->block_align = track->audio.coded_framesize;
track->codec_priv.size = 0;
} else {
st->codec->block_align = track->audio.sub_packet_size;
extradata_offset = 78;
track->codec_priv.size -= extradata_offset;
}
}
if (codec_id == CODEC_ID_NONE)
av_log(matroska->ctx, AV_LOG_INFO,
"Unknown/unsupported CodecID %s.\n", track->codec_id);
if (track->time_scale < 0.01)
track->time_scale = 1.0;
av_set_pts_info(st, 64, matroska->time_scale*track->time_scale, 1000*1000*1000); /* 64 bit pts in ns */
st->codec->codec_id = codec_id;
st->start_time = 0;
if (strcmp(track->language, "und"))
av_strlcpy(st->language, track->language, 4);
if (track->flag_default)
st->disposition |= AV_DISPOSITION_DEFAULT;
if (track->default_duration)
av_reduce(&st->codec->time_base.num, &st->codec->time_base.den,
track->default_duration, 1000000000, 30000);
if(extradata){
st->codec->extradata = extradata;
st->codec->extradata_size = extradata_size;
} else if(track->codec_priv.data && track->codec_priv.size > 0){
st->codec->extradata = av_malloc(track->codec_priv.size);
if(st->codec->extradata == NULL)
return AVERROR(ENOMEM);
st->codec->extradata_size = track->codec_priv.size;
memcpy(st->codec->extradata,
track->codec_priv.data + extradata_offset,
track->codec_priv.size);
}
if (track->type == MATROSKA_TRACK_TYPE_VIDEO) {
st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_tag = track->video.fourcc;
st->codec->width = track->video.pixel_width;
st->codec->height = track->video.pixel_height;
av_reduce(&st->sample_aspect_ratio.num,
&st->sample_aspect_ratio.den,
st->codec->height * track->video.display_width,
st->codec-> width * track->video.display_height,
255);
st->need_parsing = AVSTREAM_PARSE_HEADERS;
} else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->sample_rate = track->audio.out_samplerate;
st->codec->channels = track->audio.channels;
} else if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE) {
st->codec->codec_type = CODEC_TYPE_SUBTITLE;
}
}
attachements = attachements_list->elem;
for (j=0; j<attachements_list->nb_elem; j++) {
if (!(attachements[j].filename && attachements[j].mime &&
attachements[j].bin.data && attachements[j].bin.size > 0)) {
av_log(matroska->ctx, AV_LOG_ERROR, "incomplete attachment\n");
} else {
AVStream *st = av_new_stream(s, 0);
if (st == NULL)
break;
st->filename = av_strdup(attachements[j].filename);
st->codec->codec_id = CODEC_ID_NONE;
st->codec->codec_type = CODEC_TYPE_ATTACHMENT;
st->codec->extradata = av_malloc(attachements[j].bin.size);
if(st->codec->extradata == NULL)
break;
st->codec->extradata_size = attachements[j].bin.size;
memcpy(st->codec->extradata, attachements[j].bin.data, attachements[j].bin.size);
for (i=0; ff_mkv_mime_tags[i].id != CODEC_ID_NONE; i++) {
if (!strncmp(ff_mkv_mime_tags[i].str, attachements[j].mime,
strlen(ff_mkv_mime_tags[i].str))) {
st->codec->codec_id = ff_mkv_mime_tags[i].id;
break;
}
}
}
}
chapters = chapters_list->elem;
for (i=0; i<chapters_list->nb_elem; i++)
if (chapters[i].start != AV_NOPTS_VALUE && chapters[i].uid)
ff_new_chapter(s, chapters[i].uid, (AVRational){1, 1000000000},
chapters[i].start, chapters[i].end,
chapters[i].title);
index_list = &matroska->index;
index = index_list->elem;
if (index_list->nb_elem
&& index[0].time > 100000000000000/matroska->time_scale) {
av_log(matroska->ctx, AV_LOG_WARNING, "Working around broken index.\n");
index_scale = matroska->time_scale;
}
for (i=0; i<index_list->nb_elem; i++) {
EbmlList *pos_list = &index[i].pos;
MatroskaIndexPos *pos = pos_list->elem;
for (j=0; j<pos_list->nb_elem; j++) {
MatroskaTrack *track = matroska_find_track_by_num(matroska,
pos[j].track);
if (track && track->stream)
av_add_index_entry(track->stream,
pos[j].pos + matroska->segment_start,
index[i].time/index_scale, 0, 0,
AVINDEX_KEYFRAME);
}
}
return 0;
}
| true | FFmpeg | 1ca610c0152f31847ab760fda1fb147692f31e7e | static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
MatroskaDemuxContext *matroska = s->priv_data;
EbmlList *attachements_list = &matroska->attachments;
MatroskaAttachement *attachements;
EbmlList *chapters_list = &matroska->chapters;
MatroskaChapter *chapters;
MatroskaTrack *tracks;
EbmlList *index_list;
MatroskaIndex *index;
int index_scale = 1;
Ebml ebml = { 0 };
AVStream *st;
int i, j;
matroska->ctx = s;
if (ebml_parse(matroska, ebml_syntax, &ebml)
|| ebml.version > EBML_VERSION || ebml.max_size > sizeof(uint64_t)
|| ebml.id_length > sizeof(uint32_t) || strcmp(ebml.doctype, "matroska")
|| ebml.doctype_version > 2) {
av_log(matroska->ctx, AV_LOG_ERROR,
"EBML header using unsupported features\n"
"(EBML version %"PRIu64", doctype %s, doc version %"PRIu64")\n",
ebml.version, ebml.doctype, ebml.doctype_version);
return AVERROR_NOFMT;
}
ebml_free(ebml_syntax, &ebml);
if (ebml_parse(matroska, matroska_segments, matroska) < 0)
return -1;
matroska_execute_seekhead(matroska);
if (matroska->duration)
matroska->ctx->duration = matroska->duration * matroska->time_scale
* 1000 / AV_TIME_BASE;
if (matroska->title)
strncpy(matroska->ctx->title, matroska->title,
sizeof(matroska->ctx->title)-1);
matroska_convert_tags(s, &matroska->tags);
tracks = matroska->tracks.elem;
for (i=0; i < matroska->tracks.nb_elem; i++) {
MatroskaTrack *track = &tracks[i];
enum CodecID codec_id = CODEC_ID_NONE;
EbmlList *encodings_list = &tracks->encodings;
MatroskaTrackEncoding *encodings = encodings_list->elem;
uint8_t *extradata = NULL;
int extradata_size = 0;
int extradata_offset = 0;
if (track->type != MATROSKA_TRACK_TYPE_VIDEO &&
track->type != MATROSKA_TRACK_TYPE_AUDIO &&
track->type != MATROSKA_TRACK_TYPE_SUBTITLE) {
av_log(matroska->ctx, AV_LOG_INFO,
"Unknown or unsupported track type %"PRIu64"\n",
track->type);
continue;
}
if (track->codec_id == NULL)
continue;
if (track->type == MATROSKA_TRACK_TYPE_VIDEO) {
if (!track->default_duration)
track->default_duration = 1000000000/track->video.frame_rate;
if (!track->video.display_width)
track->video.display_width = track->video.pixel_width;
if (!track->video.display_height)
track->video.display_height = track->video.pixel_height;
} else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
if (!track->audio.out_samplerate)
track->audio.out_samplerate = track->audio.samplerate;
}
if (encodings_list->nb_elem > 1) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Multiple combined encodings no supported");
} else if (encodings_list->nb_elem == 1) {
if (encodings[0].type ||
(encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP &&
#ifdef CONFIG_ZLIB
encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_ZLIB &&
#endif
#ifdef CONFIG_BZLIB
encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_BZLIB &&
#endif
encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_LZO)) {
encodings[0].scope = 0;
av_log(matroska->ctx, AV_LOG_ERROR,
"Unsupported encoding type");
} else if (track->codec_priv.size && encodings[0].scope&2) {
uint8_t *codec_priv = track->codec_priv.data;
int offset = matroska_decode_buffer(&track->codec_priv.data,
&track->codec_priv.size,
track);
if (offset < 0) {
track->codec_priv.data = NULL;
track->codec_priv.size = 0;
av_log(matroska->ctx, AV_LOG_ERROR,
"Failed to decode codec private data\n");
} else if (offset > 0) {
track->codec_priv.data = av_malloc(track->codec_priv.size + offset);
memcpy(track->codec_priv.data,
encodings[0].compression.settings.data, offset);
memcpy(track->codec_priv.data+offset, codec_priv,
track->codec_priv.size);
track->codec_priv.size += offset;
}
if (codec_priv != track->codec_priv.data)
av_free(codec_priv);
}
}
for(j=0; ff_mkv_codec_tags[j].id != CODEC_ID_NONE; j++){
if(!strncmp(ff_mkv_codec_tags[j].str, track->codec_id,
strlen(ff_mkv_codec_tags[j].str))){
codec_id= ff_mkv_codec_tags[j].id;
break;
}
}
st = track->stream = av_new_stream(s, 0);
if (st == NULL)
return AVERROR(ENOMEM);
if (!strcmp(track->codec_id, "V_MS/VFW/FOURCC")
&& track->codec_priv.size >= 40
&& track->codec_priv.data != NULL) {
track->video.fourcc = AV_RL32(track->codec_priv.data + 16);
codec_id = codec_get_id(codec_bmp_tags, track->video.fourcc);
} else if (!strcmp(track->codec_id, "A_MS/ACM")
&& track->codec_priv.size >= 18
&& track->codec_priv.data != NULL) {
uint16_t tag = AV_RL16(track->codec_priv.data);
codec_id = codec_get_id(codec_wav_tags, tag);
} else if (!strcmp(track->codec_id, "V_QUICKTIME")
&& (track->codec_priv.size >= 86)
&& (track->codec_priv.data != NULL)) {
track->video.fourcc = AV_RL32(track->codec_priv.data);
codec_id=codec_get_id(codec_movvideo_tags, track->video.fourcc);
} else if (codec_id == CODEC_ID_PCM_S16BE) {
switch (track->audio.bitdepth) {
case 8: codec_id = CODEC_ID_PCM_U8; break;
case 24: codec_id = CODEC_ID_PCM_S24BE; break;
case 32: codec_id = CODEC_ID_PCM_S32BE; break;
}
} else if (codec_id == CODEC_ID_PCM_S16LE) {
switch (track->audio.bitdepth) {
case 8: codec_id = CODEC_ID_PCM_U8; break;
case 24: codec_id = CODEC_ID_PCM_S24LE; break;
case 32: codec_id = CODEC_ID_PCM_S32LE; break;
}
} else if (codec_id==CODEC_ID_PCM_F32LE && track->audio.bitdepth==64) {
codec_id = CODEC_ID_PCM_F64LE;
} else if (codec_id == CODEC_ID_AAC && !track->codec_priv.size) {
int profile = matroska_aac_profile(track->codec_id);
int sri = matroska_aac_sri(track->audio.samplerate);
extradata = av_malloc(5);
if (extradata == NULL)
return AVERROR(ENOMEM);
extradata[0] = (profile << 3) | ((sri&0x0E) >> 1);
extradata[1] = ((sri&0x01) << 7) | (track->audio.channels<<3);
if (strstr(track->codec_id, "SBR")) {
sri = matroska_aac_sri(track->audio.out_samplerate);
extradata[2] = 0x56;
extradata[3] = 0xE5;
extradata[4] = 0x80 | (sri<<3);
extradata_size = 5;
} else
extradata_size = 2;
} else if (codec_id == CODEC_ID_TTA) {
ByteIOContext b;
extradata_size = 30;
extradata = av_mallocz(extradata_size);
if (extradata == NULL)
return AVERROR(ENOMEM);
init_put_byte(&b, extradata, extradata_size, 1,
NULL, NULL, NULL, NULL);
put_buffer(&b, "TTA1", 4);
put_le16(&b, 1);
put_le16(&b, track->audio.channels);
put_le16(&b, track->audio.bitdepth);
put_le32(&b, track->audio.out_samplerate);
put_le32(&b, matroska->ctx->duration * track->audio.out_samplerate);
} else if (codec_id == CODEC_ID_RV10 || codec_id == CODEC_ID_RV20 ||
codec_id == CODEC_ID_RV30 || codec_id == CODEC_ID_RV40) {
extradata_offset = 26;
track->codec_priv.size -= extradata_offset;
} else if (codec_id == CODEC_ID_RA_144) {
track->audio.out_samplerate = 8000;
track->audio.channels = 1;
} else if (codec_id == CODEC_ID_RA_288 || codec_id == CODEC_ID_COOK ||
codec_id == CODEC_ID_ATRAC3) {
ByteIOContext b;
init_put_byte(&b, track->codec_priv.data,track->codec_priv.size,
0, NULL, NULL, NULL, NULL);
url_fskip(&b, 24);
track->audio.coded_framesize = get_be32(&b);
url_fskip(&b, 12);
track->audio.sub_packet_h = get_be16(&b);
track->audio.frame_size = get_be16(&b);
track->audio.sub_packet_size = get_be16(&b);
track->audio.buf = av_malloc(track->audio.frame_size * track->audio.sub_packet_h);
if (codec_id == CODEC_ID_RA_288) {
st->codec->block_align = track->audio.coded_framesize;
track->codec_priv.size = 0;
} else {
st->codec->block_align = track->audio.sub_packet_size;
extradata_offset = 78;
track->codec_priv.size -= extradata_offset;
}
}
if (codec_id == CODEC_ID_NONE)
av_log(matroska->ctx, AV_LOG_INFO,
"Unknown/unsupported CodecID %s.\n", track->codec_id);
if (track->time_scale < 0.01)
track->time_scale = 1.0;
av_set_pts_info(st, 64, matroska->time_scale*track->time_scale, 1000*1000*1000);
st->codec->codec_id = codec_id;
st->start_time = 0;
if (strcmp(track->language, "und"))
av_strlcpy(st->language, track->language, 4);
if (track->flag_default)
st->disposition |= AV_DISPOSITION_DEFAULT;
if (track->default_duration)
av_reduce(&st->codec->time_base.num, &st->codec->time_base.den,
track->default_duration, 1000000000, 30000);
if(extradata){
st->codec->extradata = extradata;
st->codec->extradata_size = extradata_size;
} else if(track->codec_priv.data && track->codec_priv.size > 0){
st->codec->extradata = av_malloc(track->codec_priv.size);
if(st->codec->extradata == NULL)
return AVERROR(ENOMEM);
st->codec->extradata_size = track->codec_priv.size;
memcpy(st->codec->extradata,
track->codec_priv.data + extradata_offset,
track->codec_priv.size);
}
if (track->type == MATROSKA_TRACK_TYPE_VIDEO) {
st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_tag = track->video.fourcc;
st->codec->width = track->video.pixel_width;
st->codec->height = track->video.pixel_height;
av_reduce(&st->sample_aspect_ratio.num,
&st->sample_aspect_ratio.den,
st->codec->height * track->video.display_width,
st->codec-> width * track->video.display_height,
255);
st->need_parsing = AVSTREAM_PARSE_HEADERS;
} else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->sample_rate = track->audio.out_samplerate;
st->codec->channels = track->audio.channels;
} else if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE) {
st->codec->codec_type = CODEC_TYPE_SUBTITLE;
}
}
attachements = attachements_list->elem;
for (j=0; j<attachements_list->nb_elem; j++) {
if (!(attachements[j].filename && attachements[j].mime &&
attachements[j].bin.data && attachements[j].bin.size > 0)) {
av_log(matroska->ctx, AV_LOG_ERROR, "incomplete attachment\n");
} else {
AVStream *st = av_new_stream(s, 0);
if (st == NULL)
break;
st->filename = av_strdup(attachements[j].filename);
st->codec->codec_id = CODEC_ID_NONE;
st->codec->codec_type = CODEC_TYPE_ATTACHMENT;
st->codec->extradata = av_malloc(attachements[j].bin.size);
if(st->codec->extradata == NULL)
break;
st->codec->extradata_size = attachements[j].bin.size;
memcpy(st->codec->extradata, attachements[j].bin.data, attachements[j].bin.size);
for (i=0; ff_mkv_mime_tags[i].id != CODEC_ID_NONE; i++) {
if (!strncmp(ff_mkv_mime_tags[i].str, attachements[j].mime,
strlen(ff_mkv_mime_tags[i].str))) {
st->codec->codec_id = ff_mkv_mime_tags[i].id;
break;
}
}
}
}
chapters = chapters_list->elem;
for (i=0; i<chapters_list->nb_elem; i++)
if (chapters[i].start != AV_NOPTS_VALUE && chapters[i].uid)
ff_new_chapter(s, chapters[i].uid, (AVRational){1, 1000000000},
chapters[i].start, chapters[i].end,
chapters[i].title);
index_list = &matroska->index;
index = index_list->elem;
if (index_list->nb_elem
&& index[0].time > 100000000000000/matroska->time_scale) {
av_log(matroska->ctx, AV_LOG_WARNING, "Working around broken index.\n");
index_scale = matroska->time_scale;
}
for (i=0; i<index_list->nb_elem; i++) {
EbmlList *pos_list = &index[i].pos;
MatroskaIndexPos *pos = pos_list->elem;
for (j=0; j<pos_list->nb_elem; j++) {
MatroskaTrack *track = matroska_find_track_by_num(matroska,
pos[j].track);
if (track && track->stream)
av_add_index_entry(track->stream,
pos[j].pos + matroska->segment_start,
index[i].time/index_scale, 0, 0,
AVINDEX_KEYFRAME);
}
}
return 0;
}
| {
"code": [
" st->codec->extradata = av_malloc(track->codec_priv.size);"
],
"line_no": [
481
]
} | static int FUNC_0(AVFormatContext *VAR_0, AVFormatParameters *VAR_1)
{
MatroskaDemuxContext *matroska = VAR_0->priv_data;
EbmlList *attachements_list = &matroska->attachments;
MatroskaAttachement *attachements;
EbmlList *chapters_list = &matroska->chapters;
MatroskaChapter *chapters;
MatroskaTrack *tracks;
EbmlList *index_list;
MatroskaIndex *index;
int VAR_2 = 1;
Ebml ebml = { 0 };
AVStream *st;
int VAR_3, VAR_4;
matroska->ctx = VAR_0;
if (ebml_parse(matroska, ebml_syntax, &ebml)
|| ebml.version > EBML_VERSION || ebml.max_size > sizeof(uint64_t)
|| ebml.id_length > sizeof(uint32_t) || strcmp(ebml.doctype, "matroska")
|| ebml.doctype_version > 2) {
av_log(matroska->ctx, AV_LOG_ERROR,
"EBML header using unsupported features\n"
"(EBML version %"PRIu64", doctype %VAR_0, doc version %"PRIu64")\n",
ebml.version, ebml.doctype, ebml.doctype_version);
return AVERROR_NOFMT;
}
ebml_free(ebml_syntax, &ebml);
if (ebml_parse(matroska, matroska_segments, matroska) < 0)
return -1;
matroska_execute_seekhead(matroska);
if (matroska->duration)
matroska->ctx->duration = matroska->duration * matroska->time_scale
* 1000 / AV_TIME_BASE;
if (matroska->title)
strncpy(matroska->ctx->title, matroska->title,
sizeof(matroska->ctx->title)-1);
matroska_convert_tags(VAR_0, &matroska->tags);
tracks = matroska->tracks.elem;
for (VAR_3=0; VAR_3 < matroska->tracks.nb_elem; VAR_3++) {
MatroskaTrack *track = &tracks[VAR_3];
enum CodecID codec_id = CODEC_ID_NONE;
EbmlList *encodings_list = &tracks->encodings;
MatroskaTrackEncoding *encodings = encodings_list->elem;
uint8_t *extradata = NULL;
int extradata_size = 0;
int extradata_offset = 0;
if (track->type != MATROSKA_TRACK_TYPE_VIDEO &&
track->type != MATROSKA_TRACK_TYPE_AUDIO &&
track->type != MATROSKA_TRACK_TYPE_SUBTITLE) {
av_log(matroska->ctx, AV_LOG_INFO,
"Unknown or unsupported track type %"PRIu64"\n",
track->type);
continue;
}
if (track->codec_id == NULL)
continue;
if (track->type == MATROSKA_TRACK_TYPE_VIDEO) {
if (!track->default_duration)
track->default_duration = 1000000000/track->video.frame_rate;
if (!track->video.display_width)
track->video.display_width = track->video.pixel_width;
if (!track->video.display_height)
track->video.display_height = track->video.pixel_height;
} else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
if (!track->audio.out_samplerate)
track->audio.out_samplerate = track->audio.samplerate;
}
if (encodings_list->nb_elem > 1) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Multiple combined encodings no supported");
} else if (encodings_list->nb_elem == 1) {
if (encodings[0].type ||
(encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP &&
#ifdef CONFIG_ZLIB
encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_ZLIB &&
#endif
#ifdef CONFIG_BZLIB
encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_BZLIB &&
#endif
encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_LZO)) {
encodings[0].scope = 0;
av_log(matroska->ctx, AV_LOG_ERROR,
"Unsupported encoding type");
} else if (track->codec_priv.size && encodings[0].scope&2) {
uint8_t *codec_priv = track->codec_priv.data;
int offset = matroska_decode_buffer(&track->codec_priv.data,
&track->codec_priv.size,
track);
if (offset < 0) {
track->codec_priv.data = NULL;
track->codec_priv.size = 0;
av_log(matroska->ctx, AV_LOG_ERROR,
"Failed to decode codec private data\n");
} else if (offset > 0) {
track->codec_priv.data = av_malloc(track->codec_priv.size + offset);
memcpy(track->codec_priv.data,
encodings[0].compression.settings.data, offset);
memcpy(track->codec_priv.data+offset, codec_priv,
track->codec_priv.size);
track->codec_priv.size += offset;
}
if (codec_priv != track->codec_priv.data)
av_free(codec_priv);
}
}
for(VAR_4=0; ff_mkv_codec_tags[VAR_4].id != CODEC_ID_NONE; VAR_4++){
if(!strncmp(ff_mkv_codec_tags[VAR_4].str, track->codec_id,
strlen(ff_mkv_codec_tags[VAR_4].str))){
codec_id= ff_mkv_codec_tags[VAR_4].id;
break;
}
}
st = track->stream = av_new_stream(VAR_0, 0);
if (st == NULL)
return AVERROR(ENOMEM);
if (!strcmp(track->codec_id, "V_MS/VFW/FOURCC")
&& track->codec_priv.size >= 40
&& track->codec_priv.data != NULL) {
track->video.fourcc = AV_RL32(track->codec_priv.data + 16);
codec_id = codec_get_id(codec_bmp_tags, track->video.fourcc);
} else if (!strcmp(track->codec_id, "A_MS/ACM")
&& track->codec_priv.size >= 18
&& track->codec_priv.data != NULL) {
uint16_t tag = AV_RL16(track->codec_priv.data);
codec_id = codec_get_id(codec_wav_tags, tag);
} else if (!strcmp(track->codec_id, "V_QUICKTIME")
&& (track->codec_priv.size >= 86)
&& (track->codec_priv.data != NULL)) {
track->video.fourcc = AV_RL32(track->codec_priv.data);
codec_id=codec_get_id(codec_movvideo_tags, track->video.fourcc);
} else if (codec_id == CODEC_ID_PCM_S16BE) {
switch (track->audio.bitdepth) {
case 8: codec_id = CODEC_ID_PCM_U8; break;
case 24: codec_id = CODEC_ID_PCM_S24BE; break;
case 32: codec_id = CODEC_ID_PCM_S32BE; break;
}
} else if (codec_id == CODEC_ID_PCM_S16LE) {
switch (track->audio.bitdepth) {
case 8: codec_id = CODEC_ID_PCM_U8; break;
case 24: codec_id = CODEC_ID_PCM_S24LE; break;
case 32: codec_id = CODEC_ID_PCM_S32LE; break;
}
} else if (codec_id==CODEC_ID_PCM_F32LE && track->audio.bitdepth==64) {
codec_id = CODEC_ID_PCM_F64LE;
} else if (codec_id == CODEC_ID_AAC && !track->codec_priv.size) {
int profile = matroska_aac_profile(track->codec_id);
int sri = matroska_aac_sri(track->audio.samplerate);
extradata = av_malloc(5);
if (extradata == NULL)
return AVERROR(ENOMEM);
extradata[0] = (profile << 3) | ((sri&0x0E) >> 1);
extradata[1] = ((sri&0x01) << 7) | (track->audio.channels<<3);
if (strstr(track->codec_id, "SBR")) {
sri = matroska_aac_sri(track->audio.out_samplerate);
extradata[2] = 0x56;
extradata[3] = 0xE5;
extradata[4] = 0x80 | (sri<<3);
extradata_size = 5;
} else
extradata_size = 2;
} else if (codec_id == CODEC_ID_TTA) {
ByteIOContext b;
extradata_size = 30;
extradata = av_mallocz(extradata_size);
if (extradata == NULL)
return AVERROR(ENOMEM);
init_put_byte(&b, extradata, extradata_size, 1,
NULL, NULL, NULL, NULL);
put_buffer(&b, "TTA1", 4);
put_le16(&b, 1);
put_le16(&b, track->audio.channels);
put_le16(&b, track->audio.bitdepth);
put_le32(&b, track->audio.out_samplerate);
put_le32(&b, matroska->ctx->duration * track->audio.out_samplerate);
} else if (codec_id == CODEC_ID_RV10 || codec_id == CODEC_ID_RV20 ||
codec_id == CODEC_ID_RV30 || codec_id == CODEC_ID_RV40) {
extradata_offset = 26;
track->codec_priv.size -= extradata_offset;
} else if (codec_id == CODEC_ID_RA_144) {
track->audio.out_samplerate = 8000;
track->audio.channels = 1;
} else if (codec_id == CODEC_ID_RA_288 || codec_id == CODEC_ID_COOK ||
codec_id == CODEC_ID_ATRAC3) {
ByteIOContext b;
init_put_byte(&b, track->codec_priv.data,track->codec_priv.size,
0, NULL, NULL, NULL, NULL);
url_fskip(&b, 24);
track->audio.coded_framesize = get_be32(&b);
url_fskip(&b, 12);
track->audio.sub_packet_h = get_be16(&b);
track->audio.frame_size = get_be16(&b);
track->audio.sub_packet_size = get_be16(&b);
track->audio.buf = av_malloc(track->audio.frame_size * track->audio.sub_packet_h);
if (codec_id == CODEC_ID_RA_288) {
st->codec->block_align = track->audio.coded_framesize;
track->codec_priv.size = 0;
} else {
st->codec->block_align = track->audio.sub_packet_size;
extradata_offset = 78;
track->codec_priv.size -= extradata_offset;
}
}
if (codec_id == CODEC_ID_NONE)
av_log(matroska->ctx, AV_LOG_INFO,
"Unknown/unsupported CodecID %VAR_0.\n", track->codec_id);
if (track->time_scale < 0.01)
track->time_scale = 1.0;
av_set_pts_info(st, 64, matroska->time_scale*track->time_scale, 1000*1000*1000);
st->codec->codec_id = codec_id;
st->start_time = 0;
if (strcmp(track->language, "und"))
av_strlcpy(st->language, track->language, 4);
if (track->flag_default)
st->disposition |= AV_DISPOSITION_DEFAULT;
if (track->default_duration)
av_reduce(&st->codec->time_base.num, &st->codec->time_base.den,
track->default_duration, 1000000000, 30000);
if(extradata){
st->codec->extradata = extradata;
st->codec->extradata_size = extradata_size;
} else if(track->codec_priv.data && track->codec_priv.size > 0){
st->codec->extradata = av_malloc(track->codec_priv.size);
if(st->codec->extradata == NULL)
return AVERROR(ENOMEM);
st->codec->extradata_size = track->codec_priv.size;
memcpy(st->codec->extradata,
track->codec_priv.data + extradata_offset,
track->codec_priv.size);
}
if (track->type == MATROSKA_TRACK_TYPE_VIDEO) {
st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_tag = track->video.fourcc;
st->codec->width = track->video.pixel_width;
st->codec->height = track->video.pixel_height;
av_reduce(&st->sample_aspect_ratio.num,
&st->sample_aspect_ratio.den,
st->codec->height * track->video.display_width,
st->codec-> width * track->video.display_height,
255);
st->need_parsing = AVSTREAM_PARSE_HEADERS;
} else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->sample_rate = track->audio.out_samplerate;
st->codec->channels = track->audio.channels;
} else if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE) {
st->codec->codec_type = CODEC_TYPE_SUBTITLE;
}
}
attachements = attachements_list->elem;
for (VAR_4=0; VAR_4<attachements_list->nb_elem; VAR_4++) {
if (!(attachements[VAR_4].filename && attachements[VAR_4].mime &&
attachements[VAR_4].bin.data && attachements[VAR_4].bin.size > 0)) {
av_log(matroska->ctx, AV_LOG_ERROR, "incomplete attachment\n");
} else {
AVStream *st = av_new_stream(VAR_0, 0);
if (st == NULL)
break;
st->filename = av_strdup(attachements[VAR_4].filename);
st->codec->codec_id = CODEC_ID_NONE;
st->codec->codec_type = CODEC_TYPE_ATTACHMENT;
st->codec->extradata = av_malloc(attachements[VAR_4].bin.size);
if(st->codec->extradata == NULL)
break;
st->codec->extradata_size = attachements[VAR_4].bin.size;
memcpy(st->codec->extradata, attachements[VAR_4].bin.data, attachements[VAR_4].bin.size);
for (VAR_3=0; ff_mkv_mime_tags[VAR_3].id != CODEC_ID_NONE; VAR_3++) {
if (!strncmp(ff_mkv_mime_tags[VAR_3].str, attachements[VAR_4].mime,
strlen(ff_mkv_mime_tags[VAR_3].str))) {
st->codec->codec_id = ff_mkv_mime_tags[VAR_3].id;
break;
}
}
}
}
chapters = chapters_list->elem;
for (VAR_3=0; VAR_3<chapters_list->nb_elem; VAR_3++)
if (chapters[VAR_3].start != AV_NOPTS_VALUE && chapters[VAR_3].uid)
ff_new_chapter(VAR_0, chapters[VAR_3].uid, (AVRational){1, 1000000000},
chapters[VAR_3].start, chapters[VAR_3].end,
chapters[VAR_3].title);
index_list = &matroska->index;
index = index_list->elem;
if (index_list->nb_elem
&& index[0].time > 100000000000000/matroska->time_scale) {
av_log(matroska->ctx, AV_LOG_WARNING, "Working around broken index.\n");
VAR_2 = matroska->time_scale;
}
for (VAR_3=0; VAR_3<index_list->nb_elem; VAR_3++) {
EbmlList *pos_list = &index[VAR_3].pos;
MatroskaIndexPos *pos = pos_list->elem;
for (VAR_4=0; VAR_4<pos_list->nb_elem; VAR_4++) {
MatroskaTrack *track = matroska_find_track_by_num(matroska,
pos[VAR_4].track);
if (track && track->stream)
av_add_index_entry(track->stream,
pos[VAR_4].pos + matroska->segment_start,
index[VAR_3].time/VAR_2, 0, 0,
AVINDEX_KEYFRAME);
}
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVFormatParameters *VAR_1)\n{",
"MatroskaDemuxContext *matroska = VAR_0->priv_data;",
"EbmlList *attachements_list = &matroska->attachments;",
"MatroskaAttachement *attachements;",
"EbmlList *chapters_list = &matroska->chapters;",
"MatroskaChapter *chapters;",
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
37,
39,
41,
43
],
[
45,
47,
49,
51
],
[
53
... |
9,499 | static int vp8_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
{
VP56RangeCoder *c = &s->c;
int header_size, hscale, vscale, ret;
int width = s->avctx->width;
int height = s->avctx->height;
s->keyframe = !(buf[0] & 1);
s->profile = (buf[0]>>1) & 7;
s->invisible = !(buf[0] & 0x10);
header_size = AV_RL24(buf) >> 5;
buf += 3;
buf_size -= 3;
if (s->profile > 3)
av_log(s->avctx, AV_LOG_WARNING, "Unknown profile %d\n", s->profile);
if (!s->profile)
memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_epel_pixels_tab,
sizeof(s->put_pixels_tab));
else // profile 1-3 use bilinear, 4+ aren't defined so whatever
memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_bilinear_pixels_tab,
sizeof(s->put_pixels_tab));
if (header_size > buf_size - 7 * s->keyframe) {
av_log(s->avctx, AV_LOG_ERROR, "Header size larger than data provided\n");
if (s->keyframe) {
if (AV_RL24(buf) != 0x2a019d) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid start code 0x%x\n", AV_RL24(buf));
width = AV_RL16(buf + 3) & 0x3fff;
height = AV_RL16(buf + 5) & 0x3fff;
hscale = buf[4] >> 6;
vscale = buf[6] >> 6;
buf += 7;
buf_size -= 7;
if (hscale || vscale)
avpriv_request_sample(s->avctx, "Upscaling");
s->update_golden = s->update_altref = VP56_FRAME_CURRENT;
vp78_reset_probability_tables(s);
memcpy(s->prob->pred16x16, vp8_pred16x16_prob_inter,
sizeof(s->prob->pred16x16));
memcpy(s->prob->pred8x8c, vp8_pred8x8c_prob_inter,
sizeof(s->prob->pred8x8c));
memcpy(s->prob->mvc, vp8_mv_default_prob,
sizeof(s->prob->mvc));
memset(&s->segmentation, 0, sizeof(s->segmentation));
memset(&s->lf_delta, 0, sizeof(s->lf_delta));
ff_vp56_init_range_decoder(c, buf, header_size);
buf += header_size;
buf_size -= header_size;
if (s->keyframe) {
s->colorspace = vp8_rac_get(c);
if (s->colorspace)
av_log(s->avctx, AV_LOG_WARNING, "Unspecified colorspace\n");
s->fullrange = vp8_rac_get(c);
if ((s->segmentation.enabled = vp8_rac_get(c)))
parse_segment_info(s);
else
s->segmentation.update_map = 0; // FIXME: move this to some init function?
s->filter.simple = vp8_rac_get(c);
s->filter.level = vp8_rac_get_uint(c, 6);
s->filter.sharpness = vp8_rac_get_uint(c, 3);
if ((s->lf_delta.enabled = vp8_rac_get(c)))
if (vp8_rac_get(c))
update_lf_deltas(s);
if (setup_partitions(s, buf, buf_size)) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid partitions\n");
if (!s->macroblocks_base || /* first frame */
width != s->avctx->width || height != s->avctx->height ||
(width+15)/16 != s->mb_width || (height+15)/16 != s->mb_height)
if ((ret = vp8_update_dimensions(s, width, height)) < 0)
return ret;
vp8_get_quants(s);
if (!s->keyframe) {
update_refs(s);
s->sign_bias[VP56_FRAME_GOLDEN] = vp8_rac_get(c);
s->sign_bias[VP56_FRAME_GOLDEN2 /* altref */] = vp8_rac_get(c);
// if we aren't saving this frame's probabilities for future frames,
// make a copy of the current probabilities
if (!(s->update_probabilities = vp8_rac_get(c)))
s->prob[1] = s->prob[0];
s->update_last = s->keyframe || vp8_rac_get(c);
vp78_update_probability_tables(s);
if ((s->mbskip_enabled = vp8_rac_get(c)))
s->prob->mbskip = vp8_rac_get_uint(c, 8);
if (!s->keyframe) {
s->prob->intra = vp8_rac_get_uint(c, 8);
s->prob->last = vp8_rac_get_uint(c, 8);
s->prob->golden = vp8_rac_get_uint(c, 8);
vp78_update_pred16x16_pred8x8_mvc_probabilities(s, VP8_MVC_SIZE);
return 0; | true | FFmpeg | 599d746e07319dc792ed2e511b666fe482f1ff88 | static int vp8_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
{
VP56RangeCoder *c = &s->c;
int header_size, hscale, vscale, ret;
int width = s->avctx->width;
int height = s->avctx->height;
s->keyframe = !(buf[0] & 1);
s->profile = (buf[0]>>1) & 7;
s->invisible = !(buf[0] & 0x10);
header_size = AV_RL24(buf) >> 5;
buf += 3;
buf_size -= 3;
if (s->profile > 3)
av_log(s->avctx, AV_LOG_WARNING, "Unknown profile %d\n", s->profile);
if (!s->profile)
memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_epel_pixels_tab,
sizeof(s->put_pixels_tab));
else
memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_bilinear_pixels_tab,
sizeof(s->put_pixels_tab));
if (header_size > buf_size - 7 * s->keyframe) {
av_log(s->avctx, AV_LOG_ERROR, "Header size larger than data provided\n");
if (s->keyframe) {
if (AV_RL24(buf) != 0x2a019d) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid start code 0x%x\n", AV_RL24(buf));
width = AV_RL16(buf + 3) & 0x3fff;
height = AV_RL16(buf + 5) & 0x3fff;
hscale = buf[4] >> 6;
vscale = buf[6] >> 6;
buf += 7;
buf_size -= 7;
if (hscale || vscale)
avpriv_request_sample(s->avctx, "Upscaling");
s->update_golden = s->update_altref = VP56_FRAME_CURRENT;
vp78_reset_probability_tables(s);
memcpy(s->prob->pred16x16, vp8_pred16x16_prob_inter,
sizeof(s->prob->pred16x16));
memcpy(s->prob->pred8x8c, vp8_pred8x8c_prob_inter,
sizeof(s->prob->pred8x8c));
memcpy(s->prob->mvc, vp8_mv_default_prob,
sizeof(s->prob->mvc));
memset(&s->segmentation, 0, sizeof(s->segmentation));
memset(&s->lf_delta, 0, sizeof(s->lf_delta));
ff_vp56_init_range_decoder(c, buf, header_size);
buf += header_size;
buf_size -= header_size;
if (s->keyframe) {
s->colorspace = vp8_rac_get(c);
if (s->colorspace)
av_log(s->avctx, AV_LOG_WARNING, "Unspecified colorspace\n");
s->fullrange = vp8_rac_get(c);
if ((s->segmentation.enabled = vp8_rac_get(c)))
parse_segment_info(s);
else
s->segmentation.update_map = 0;
s->filter.simple = vp8_rac_get(c);
s->filter.level = vp8_rac_get_uint(c, 6);
s->filter.sharpness = vp8_rac_get_uint(c, 3);
if ((s->lf_delta.enabled = vp8_rac_get(c)))
if (vp8_rac_get(c))
update_lf_deltas(s);
if (setup_partitions(s, buf, buf_size)) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid partitions\n");
if (!s->macroblocks_base ||
width != s->avctx->width || height != s->avctx->height ||
(width+15)/16 != s->mb_width || (height+15)/16 != s->mb_height)
if ((ret = vp8_update_dimensions(s, width, height)) < 0)
return ret;
vp8_get_quants(s);
if (!s->keyframe) {
update_refs(s);
s->sign_bias[VP56_FRAME_GOLDEN] = vp8_rac_get(c);
s->sign_bias[VP56_FRAME_GOLDEN2 ] = vp8_rac_get(c);
if (!(s->update_probabilities = vp8_rac_get(c)))
s->prob[1] = s->prob[0];
s->update_last = s->keyframe || vp8_rac_get(c);
vp78_update_probability_tables(s);
if ((s->mbskip_enabled = vp8_rac_get(c)))
s->prob->mbskip = vp8_rac_get_uint(c, 8);
if (!s->keyframe) {
s->prob->intra = vp8_rac_get_uint(c, 8);
s->prob->last = vp8_rac_get_uint(c, 8);
s->prob->golden = vp8_rac_get_uint(c, 8);
vp78_update_pred16x16_pred8x8_mvc_probabilities(s, VP8_MVC_SIZE);
return 0; | {
"code": [],
"line_no": []
} | static int FUNC_0(VP8Context *VAR_0, const uint8_t *VAR_1, int VAR_2)
{
VP56RangeCoder *c = &VAR_0->c;
int VAR_3, VAR_4, VAR_5, VAR_6;
int VAR_7 = VAR_0->avctx->VAR_7;
int VAR_8 = VAR_0->avctx->VAR_8;
VAR_0->keyframe = !(VAR_1[0] & 1);
VAR_0->profile = (VAR_1[0]>>1) & 7;
VAR_0->invisible = !(VAR_1[0] & 0x10);
VAR_3 = AV_RL24(VAR_1) >> 5;
VAR_1 += 3;
VAR_2 -= 3;
if (VAR_0->profile > 3)
av_log(VAR_0->avctx, AV_LOG_WARNING, "Unknown profile %d\n", VAR_0->profile);
if (!VAR_0->profile)
memcpy(VAR_0->put_pixels_tab, VAR_0->vp8dsp.put_vp8_epel_pixels_tab,
sizeof(VAR_0->put_pixels_tab));
else
memcpy(VAR_0->put_pixels_tab, VAR_0->vp8dsp.put_vp8_bilinear_pixels_tab,
sizeof(VAR_0->put_pixels_tab));
if (VAR_3 > VAR_2 - 7 * VAR_0->keyframe) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Header size larger than data provided\n");
if (VAR_0->keyframe) {
if (AV_RL24(VAR_1) != 0x2a019d) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Invalid start code 0x%x\n", AV_RL24(VAR_1));
VAR_7 = AV_RL16(VAR_1 + 3) & 0x3fff;
VAR_8 = AV_RL16(VAR_1 + 5) & 0x3fff;
VAR_4 = VAR_1[4] >> 6;
VAR_5 = VAR_1[6] >> 6;
VAR_1 += 7;
VAR_2 -= 7;
if (VAR_4 || VAR_5)
avpriv_request_sample(VAR_0->avctx, "Upscaling");
VAR_0->update_golden = VAR_0->update_altref = VP56_FRAME_CURRENT;
vp78_reset_probability_tables(VAR_0);
memcpy(VAR_0->prob->pred16x16, vp8_pred16x16_prob_inter,
sizeof(VAR_0->prob->pred16x16));
memcpy(VAR_0->prob->pred8x8c, vp8_pred8x8c_prob_inter,
sizeof(VAR_0->prob->pred8x8c));
memcpy(VAR_0->prob->mvc, vp8_mv_default_prob,
sizeof(VAR_0->prob->mvc));
memset(&VAR_0->segmentation, 0, sizeof(VAR_0->segmentation));
memset(&VAR_0->lf_delta, 0, sizeof(VAR_0->lf_delta));
ff_vp56_init_range_decoder(c, VAR_1, VAR_3);
VAR_1 += VAR_3;
VAR_2 -= VAR_3;
if (VAR_0->keyframe) {
VAR_0->colorspace = vp8_rac_get(c);
if (VAR_0->colorspace)
av_log(VAR_0->avctx, AV_LOG_WARNING, "Unspecified colorspace\n");
VAR_0->fullrange = vp8_rac_get(c);
if ((VAR_0->segmentation.enabled = vp8_rac_get(c)))
parse_segment_info(VAR_0);
else
VAR_0->segmentation.update_map = 0;
VAR_0->filter.simple = vp8_rac_get(c);
VAR_0->filter.level = vp8_rac_get_uint(c, 6);
VAR_0->filter.sharpness = vp8_rac_get_uint(c, 3);
if ((VAR_0->lf_delta.enabled = vp8_rac_get(c)))
if (vp8_rac_get(c))
update_lf_deltas(VAR_0);
if (setup_partitions(VAR_0, VAR_1, VAR_2)) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid partitions\n");
if (!VAR_0->macroblocks_base ||
VAR_7 != VAR_0->avctx->VAR_7 || VAR_8 != VAR_0->avctx->VAR_8 ||
(VAR_7+15)/16 != VAR_0->mb_width || (VAR_8+15)/16 != VAR_0->mb_height)
if ((VAR_6 = vp8_update_dimensions(VAR_0, VAR_7, VAR_8)) < 0)
return VAR_6;
vp8_get_quants(VAR_0);
if (!VAR_0->keyframe) {
update_refs(VAR_0);
VAR_0->sign_bias[VP56_FRAME_GOLDEN] = vp8_rac_get(c);
VAR_0->sign_bias[VP56_FRAME_GOLDEN2 ] = vp8_rac_get(c);
if (!(VAR_0->update_probabilities = vp8_rac_get(c)))
VAR_0->prob[1] = VAR_0->prob[0];
VAR_0->update_last = VAR_0->keyframe || vp8_rac_get(c);
vp78_update_probability_tables(VAR_0);
if ((VAR_0->mbskip_enabled = vp8_rac_get(c)))
VAR_0->prob->mbskip = vp8_rac_get_uint(c, 8);
if (!VAR_0->keyframe) {
VAR_0->prob->intra = vp8_rac_get_uint(c, 8);
VAR_0->prob->last = vp8_rac_get_uint(c, 8);
VAR_0->prob->golden = vp8_rac_get_uint(c, 8);
vp78_update_pred16x16_pred8x8_mvc_probabilities(VAR_0, VP8_MVC_SIZE);
return 0; | [
"static int FUNC_0(VP8Context *VAR_0, const uint8_t *VAR_1, int VAR_2)\n{",
"VP56RangeCoder *c = &VAR_0->c;",
"int VAR_3, VAR_4, VAR_5, VAR_6;",
"int VAR_7 = VAR_0->avctx->VAR_7;",
"int VAR_8 = VAR_0->avctx->VAR_8;",
"VAR_0->keyframe = !(VAR_1[0] & 1);",
"VAR_0->profile = (VAR_1[0]>>1) & 7;",
"VA... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13,
14
],
[
15,
16,
17
],
[
18,
19,
20
],
[
21
],
[
22
],
[
23
],
[
... |
9,500 | static float voice_factor(float *p_vector, float p_gain,
float *f_vector, float f_gain,
CELPMContext *ctx)
{
double p_ener = (double) ctx->dot_productf(p_vector, p_vector,
AMRWB_SFR_SIZE) *
p_gain * p_gain;
double f_ener = (double) ctx->dot_productf(f_vector, f_vector,
AMRWB_SFR_SIZE) *
f_gain * f_gain;
return (p_ener - f_ener) / (p_ener + f_ener);
}
| true | FFmpeg | 1d0817d56b66797118880358ea7d7a2acfdca429 | static float voice_factor(float *p_vector, float p_gain,
float *f_vector, float f_gain,
CELPMContext *ctx)
{
double p_ener = (double) ctx->dot_productf(p_vector, p_vector,
AMRWB_SFR_SIZE) *
p_gain * p_gain;
double f_ener = (double) ctx->dot_productf(f_vector, f_vector,
AMRWB_SFR_SIZE) *
f_gain * f_gain;
return (p_ener - f_ener) / (p_ener + f_ener);
}
| {
"code": [
" return (p_ener - f_ener) / (p_ener + f_ener);"
],
"line_no": [
23
]
} | static float FUNC_0(float *VAR_0, float VAR_1,
float *VAR_2, float VAR_3,
CELPMContext *VAR_4)
{
double VAR_5 = (double) VAR_4->dot_productf(VAR_0, VAR_0,
AMRWB_SFR_SIZE) *
VAR_1 * VAR_1;
double VAR_6 = (double) VAR_4->dot_productf(VAR_2, VAR_2,
AMRWB_SFR_SIZE) *
VAR_3 * VAR_3;
return (VAR_5 - VAR_6) / (VAR_5 + VAR_6);
}
| [
"static float FUNC_0(float *VAR_0, float VAR_1,\nfloat *VAR_2, float VAR_3,\nCELPMContext *VAR_4)\n{",
"double VAR_5 = (double) VAR_4->dot_productf(VAR_0, VAR_0,\nAMRWB_SFR_SIZE) *\nVAR_1 * VAR_1;",
"double VAR_6 = (double) VAR_4->dot_productf(VAR_2, VAR_2,\nAMRWB_SFR_SIZE) *\nVAR_3 * VAR_3;",
"return (VAR_5 ... | [
0,
0,
0,
1,
0
] | [
[
1,
3,
5,
7
],
[
9,
11,
13
],
[
15,
17,
19
],
[
23
],
[
25
]
] |
9,501 | static int qcrypto_cipher_setiv_aes(QCryptoCipher *cipher,
const uint8_t *iv, size_t niv,
Error **errp)
{
QCryptoCipherBuiltin *ctxt = cipher->opaque;
if (niv != 16) {
error_setg(errp, "IV must be 16 bytes not %zu", niv);
return -1;
}
g_free(ctxt->state.aes.iv);
ctxt->state.aes.iv = g_new0(uint8_t, niv);
memcpy(ctxt->state.aes.iv, iv, niv);
ctxt->state.aes.niv = niv;
return 0;
}
| true | qemu | eb2a770b178b9040c3fc04ee31dc38d1775db09a | static int qcrypto_cipher_setiv_aes(QCryptoCipher *cipher,
const uint8_t *iv, size_t niv,
Error **errp)
{
QCryptoCipherBuiltin *ctxt = cipher->opaque;
if (niv != 16) {
error_setg(errp, "IV must be 16 bytes not %zu", niv);
return -1;
}
g_free(ctxt->state.aes.iv);
ctxt->state.aes.iv = g_new0(uint8_t, niv);
memcpy(ctxt->state.aes.iv, iv, niv);
ctxt->state.aes.niv = niv;
return 0;
}
| {
"code": [
" g_free(ctxt->state.aes.iv);",
" if (niv != 16) {",
" error_setg(errp, \"IV must be 16 bytes not %zu\", niv);",
" g_free(ctxt->state.aes.iv);",
" ctxt->state.aes.iv = g_new0(uint8_t, niv);",
" memcpy(ctxt->state.aes.iv, iv, niv);",
" ctxt->state.aes.niv = niv;"
],
"line_no": [
21,
11,
13,
21,
23,
25,
27
]
} | static int FUNC_0(QCryptoCipher *VAR_0,
const uint8_t *VAR_1, size_t VAR_2,
Error **VAR_3)
{
QCryptoCipherBuiltin *ctxt = VAR_0->opaque;
if (VAR_2 != 16) {
error_setg(VAR_3, "IV must be 16 bytes not %zu", VAR_2);
return -1;
}
g_free(ctxt->state.aes.VAR_1);
ctxt->state.aes.VAR_1 = g_new0(uint8_t, VAR_2);
memcpy(ctxt->state.aes.VAR_1, VAR_1, VAR_2);
ctxt->state.aes.VAR_2 = VAR_2;
return 0;
}
| [
"static int FUNC_0(QCryptoCipher *VAR_0,\nconst uint8_t *VAR_1, size_t VAR_2,\nError **VAR_3)\n{",
"QCryptoCipherBuiltin *ctxt = VAR_0->opaque;",
"if (VAR_2 != 16) {",
"error_setg(VAR_3, \"IV must be 16 bytes not %zu\", VAR_2);",
"return -1;",
"}",
"g_free(ctxt->state.aes.VAR_1);",
"ctxt->state.aes.VA... | [
0,
0,
1,
1,
0,
0,
1,
1,
1,
1,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
]
] |
9,502 | int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near,
int point_transform, int ilv)
{
int i, t = 0;
uint8_t *zero, *last, *cur;
JLSState *state;
int off = 0, stride = 1, width, shift, ret = 0;
zero = av_mallocz(s->picture_ptr->linesize[0]);
if (!zero)
return AVERROR(ENOMEM);
last = zero;
cur = s->picture_ptr->data[0];
state = av_mallocz(sizeof(JLSState));
if (!state) {
av_free(zero);
return AVERROR(ENOMEM);
}
/* initialize JPEG-LS state from JPEG parameters */
state->near = near;
state->bpp = (s->bits < 2) ? 2 : s->bits;
state->maxval = s->maxval;
state->T1 = s->t1;
state->T2 = s->t2;
state->T3 = s->t3;
state->reset = s->reset;
ff_jpegls_reset_coding_parameters(state, 0);
ff_jpegls_init_state(state);
if (s->bits <= 8)
shift = point_transform + (8 - s->bits);
else
shift = point_transform + (16 - s->bits);
if (shift >= 16) {
ret = AVERROR_INVALIDDATA;
}
if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
av_log(s->avctx, AV_LOG_DEBUG,
"JPEG-LS params: %ix%i NEAR=%i MV=%i T(%i,%i,%i) "
"RESET=%i, LIMIT=%i, qbpp=%i, RANGE=%i\n",
s->width, s->height, state->near, state->maxval,
state->T1, state->T2, state->T3,
state->reset, state->limit, state->qbpp, state->range);
av_log(s->avctx, AV_LOG_DEBUG, "JPEG params: ILV=%i Pt=%i BPP=%i, scan = %i\n",
ilv, point_transform, s->bits, s->cur_scan);
}
if (get_bits_left(&s->gb) < s->height) {
ret = AVERROR_INVALIDDATA;
}
if (ilv == 0) { /* separate planes */
if (s->cur_scan > s->nb_components) {
ret = AVERROR_INVALIDDATA;
}
stride = (s->nb_components > 1) ? 3 : 1;
off = av_clip(s->cur_scan - 1, 0, stride - 1);
width = s->width * stride;
cur += off;
for (i = 0; i < s->height; i++) {
if (s->bits <= 8) {
ls_decode_line(state, s, last, cur, t, width, stride, off, 8);
t = last[0];
} else {
ls_decode_line(state, s, last, cur, t, width, stride, off, 16);
t = *((uint16_t *)last);
}
last = cur;
cur += s->picture_ptr->linesize[0];
if (s->restart_interval && !--s->restart_count) {
align_get_bits(&s->gb);
skip_bits(&s->gb, 16); /* skip RSTn */
}
}
} else if (ilv == 1) { /* line interleaving */
int j;
int Rc[3] = { 0, 0, 0 };
stride = (s->nb_components > 1) ? 3 : 1;
memset(cur, 0, s->picture_ptr->linesize[0]);
width = s->width * stride;
for (i = 0; i < s->height; i++) {
for (j = 0; j < stride; j++) {
ls_decode_line(state, s, last + j, cur + j,
Rc[j], width, stride, j, 8);
Rc[j] = last[j];
if (s->restart_interval && !--s->restart_count) {
align_get_bits(&s->gb);
skip_bits(&s->gb, 16); /* skip RSTn */
}
}
last = cur;
cur += s->picture_ptr->linesize[0];
}
} else if (ilv == 2) { /* sample interleaving */
avpriv_report_missing_feature(s->avctx, "Sample interleaved images");
}
if (s->xfrm && s->nb_components == 3) {
int x, w;
w = s->width * s->nb_components;
if (s->bits <= 8) {
uint8_t *src = s->picture_ptr->data[0];
for (i = 0; i < s->height; i++) {
switch(s->xfrm) {
case 1:
for (x = off; x < w; x += 3) {
src[x ] += src[x+1] + 128;
src[x+2] += src[x+1] + 128;
}
break;
case 2:
for (x = off; x < w; x += 3) {
src[x ] += src[x+1] + 128;
src[x+2] += ((src[x ] + src[x+1])>>1) + 128;
}
break;
case 3:
for (x = off; x < w; x += 3) {
int g = src[x+0] - ((src[x+2]+src[x+1])>>2) + 64;
src[x+0] = src[x+2] + g + 128;
src[x+2] = src[x+1] + g + 128;
src[x+1] = g;
}
break;
case 4:
for (x = off; x < w; x += 3) {
int r = src[x+0] - (( 359 * (src[x+2]-128) + 490) >> 8);
int g = src[x+0] - (( 88 * (src[x+1]-128) - 183 * (src[x+2]-128) + 30) >> 8);
int b = src[x+0] + ((454 * (src[x+1]-128) + 574) >> 8);
src[x+0] = av_clip_uint8(r);
src[x+1] = av_clip_uint8(g);
src[x+2] = av_clip_uint8(b);
}
break;
}
src += s->picture_ptr->linesize[0];
}
}else
avpriv_report_missing_feature(s->avctx, "16bit xfrm");
}
if (shift) { /* we need to do point transform or normalize samples */
int x, w;
w = s->width * s->nb_components;
if (s->bits <= 8) {
uint8_t *src = s->picture_ptr->data[0];
for (i = 0; i < s->height; i++) {
for (x = off; x < w; x += stride)
src[x] <<= shift;
src += s->picture_ptr->linesize[0];
}
} else {
uint16_t *src = (uint16_t *)s->picture_ptr->data[0];
for (i = 0; i < s->height; i++) {
for (x = 0; x < w; x++)
src[x] <<= shift;
src += s->picture_ptr->linesize[0] / 2;
}
}
}
end:
av_free(state);
av_free(zero);
return ret;
} | true | FFmpeg | fe533628b9604e2f8e5179d5c5dd17c3cb764265 | int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near,
int point_transform, int ilv)
{
int i, t = 0;
uint8_t *zero, *last, *cur;
JLSState *state;
int off = 0, stride = 1, width, shift, ret = 0;
zero = av_mallocz(s->picture_ptr->linesize[0]);
if (!zero)
return AVERROR(ENOMEM);
last = zero;
cur = s->picture_ptr->data[0];
state = av_mallocz(sizeof(JLSState));
if (!state) {
av_free(zero);
return AVERROR(ENOMEM);
}
state->near = near;
state->bpp = (s->bits < 2) ? 2 : s->bits;
state->maxval = s->maxval;
state->T1 = s->t1;
state->T2 = s->t2;
state->T3 = s->t3;
state->reset = s->reset;
ff_jpegls_reset_coding_parameters(state, 0);
ff_jpegls_init_state(state);
if (s->bits <= 8)
shift = point_transform + (8 - s->bits);
else
shift = point_transform + (16 - s->bits);
if (shift >= 16) {
ret = AVERROR_INVALIDDATA;
}
if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
av_log(s->avctx, AV_LOG_DEBUG,
"JPEG-LS params: %ix%i NEAR=%i MV=%i T(%i,%i,%i) "
"RESET=%i, LIMIT=%i, qbpp=%i, RANGE=%i\n",
s->width, s->height, state->near, state->maxval,
state->T1, state->T2, state->T3,
state->reset, state->limit, state->qbpp, state->range);
av_log(s->avctx, AV_LOG_DEBUG, "JPEG params: ILV=%i Pt=%i BPP=%i, scan = %i\n",
ilv, point_transform, s->bits, s->cur_scan);
}
if (get_bits_left(&s->gb) < s->height) {
ret = AVERROR_INVALIDDATA;
}
if (ilv == 0) {
if (s->cur_scan > s->nb_components) {
ret = AVERROR_INVALIDDATA;
}
stride = (s->nb_components > 1) ? 3 : 1;
off = av_clip(s->cur_scan - 1, 0, stride - 1);
width = s->width * stride;
cur += off;
for (i = 0; i < s->height; i++) {
if (s->bits <= 8) {
ls_decode_line(state, s, last, cur, t, width, stride, off, 8);
t = last[0];
} else {
ls_decode_line(state, s, last, cur, t, width, stride, off, 16);
t = *((uint16_t *)last);
}
last = cur;
cur += s->picture_ptr->linesize[0];
if (s->restart_interval && !--s->restart_count) {
align_get_bits(&s->gb);
skip_bits(&s->gb, 16);
}
}
} else if (ilv == 1) {
int j;
int Rc[3] = { 0, 0, 0 };
stride = (s->nb_components > 1) ? 3 : 1;
memset(cur, 0, s->picture_ptr->linesize[0]);
width = s->width * stride;
for (i = 0; i < s->height; i++) {
for (j = 0; j < stride; j++) {
ls_decode_line(state, s, last + j, cur + j,
Rc[j], width, stride, j, 8);
Rc[j] = last[j];
if (s->restart_interval && !--s->restart_count) {
align_get_bits(&s->gb);
skip_bits(&s->gb, 16);
}
}
last = cur;
cur += s->picture_ptr->linesize[0];
}
} else if (ilv == 2) {
avpriv_report_missing_feature(s->avctx, "Sample interleaved images");
}
if (s->xfrm && s->nb_components == 3) {
int x, w;
w = s->width * s->nb_components;
if (s->bits <= 8) {
uint8_t *src = s->picture_ptr->data[0];
for (i = 0; i < s->height; i++) {
switch(s->xfrm) {
case 1:
for (x = off; x < w; x += 3) {
src[x ] += src[x+1] + 128;
src[x+2] += src[x+1] + 128;
}
break;
case 2:
for (x = off; x < w; x += 3) {
src[x ] += src[x+1] + 128;
src[x+2] += ((src[x ] + src[x+1])>>1) + 128;
}
break;
case 3:
for (x = off; x < w; x += 3) {
int g = src[x+0] - ((src[x+2]+src[x+1])>>2) + 64;
src[x+0] = src[x+2] + g + 128;
src[x+2] = src[x+1] + g + 128;
src[x+1] = g;
}
break;
case 4:
for (x = off; x < w; x += 3) {
int r = src[x+0] - (( 359 * (src[x+2]-128) + 490) >> 8);
int g = src[x+0] - (( 88 * (src[x+1]-128) - 183 * (src[x+2]-128) + 30) >> 8);
int b = src[x+0] + ((454 * (src[x+1]-128) + 574) >> 8);
src[x+0] = av_clip_uint8(r);
src[x+1] = av_clip_uint8(g);
src[x+2] = av_clip_uint8(b);
}
break;
}
src += s->picture_ptr->linesize[0];
}
}else
avpriv_report_missing_feature(s->avctx, "16bit xfrm");
}
if (shift) {
int x, w;
w = s->width * s->nb_components;
if (s->bits <= 8) {
uint8_t *src = s->picture_ptr->data[0];
for (i = 0; i < s->height; i++) {
for (x = off; x < w; x += stride)
src[x] <<= shift;
src += s->picture_ptr->linesize[0];
}
} else {
uint16_t *src = (uint16_t *)s->picture_ptr->data[0];
for (i = 0; i < s->height; i++) {
for (x = 0; x < w; x++)
src[x] <<= shift;
src += s->picture_ptr->linesize[0] / 2;
}
}
}
end:
av_free(state);
av_free(zero);
return ret;
} | {
"code": [],
"line_no": []
} | int FUNC_0(MJpegDecodeContext *VAR_0, int VAR_1,
int VAR_2, int VAR_3)
{
int VAR_4, VAR_5 = 0;
uint8_t *zero, *last, *cur;
JLSState *state;
int VAR_6 = 0, VAR_7 = 1, VAR_8, VAR_9, VAR_10 = 0;
zero = av_mallocz(VAR_0->picture_ptr->linesize[0]);
if (!zero)
return AVERROR(ENOMEM);
last = zero;
cur = VAR_0->picture_ptr->data[0];
state = av_mallocz(sizeof(JLSState));
if (!state) {
av_free(zero);
return AVERROR(ENOMEM);
}
state->VAR_1 = VAR_1;
state->bpp = (VAR_0->bits < 2) ? 2 : VAR_0->bits;
state->maxval = VAR_0->maxval;
state->T1 = VAR_0->t1;
state->T2 = VAR_0->t2;
state->T3 = VAR_0->t3;
state->reset = VAR_0->reset;
ff_jpegls_reset_coding_parameters(state, 0);
ff_jpegls_init_state(state);
if (VAR_0->bits <= 8)
VAR_9 = VAR_2 + (8 - VAR_0->bits);
else
VAR_9 = VAR_2 + (16 - VAR_0->bits);
if (VAR_9 >= 16) {
VAR_10 = AVERROR_INVALIDDATA;
}
if (VAR_0->avctx->debug & FF_DEBUG_PICT_INFO) {
av_log(VAR_0->avctx, AV_LOG_DEBUG,
"JPEG-LS params: %ix%VAR_4 NEAR=%VAR_4 MV=%VAR_4 T(%VAR_4,%VAR_4,%VAR_4) "
"RESET=%VAR_4, LIMIT=%VAR_4, qbpp=%VAR_4, RANGE=%VAR_4\n",
VAR_0->VAR_8, VAR_0->height, state->VAR_1, state->maxval,
state->T1, state->T2, state->T3,
state->reset, state->limit, state->qbpp, state->range);
av_log(VAR_0->avctx, AV_LOG_DEBUG, "JPEG params: ILV=%VAR_4 Pt=%VAR_4 BPP=%VAR_4, scan = %VAR_4\n",
VAR_3, VAR_2, VAR_0->bits, VAR_0->cur_scan);
}
if (get_bits_left(&VAR_0->gb) < VAR_0->height) {
VAR_10 = AVERROR_INVALIDDATA;
}
if (VAR_3 == 0) {
if (VAR_0->cur_scan > VAR_0->nb_components) {
VAR_10 = AVERROR_INVALIDDATA;
}
VAR_7 = (VAR_0->nb_components > 1) ? 3 : 1;
VAR_6 = av_clip(VAR_0->cur_scan - 1, 0, VAR_7 - 1);
VAR_8 = VAR_0->VAR_8 * VAR_7;
cur += VAR_6;
for (VAR_4 = 0; VAR_4 < VAR_0->height; VAR_4++) {
if (VAR_0->bits <= 8) {
ls_decode_line(state, VAR_0, last, cur, VAR_5, VAR_8, VAR_7, VAR_6, 8);
VAR_5 = last[0];
} else {
ls_decode_line(state, VAR_0, last, cur, VAR_5, VAR_8, VAR_7, VAR_6, 16);
VAR_5 = *((uint16_t *)last);
}
last = cur;
cur += VAR_0->picture_ptr->linesize[0];
if (VAR_0->restart_interval && !--VAR_0->restart_count) {
align_get_bits(&VAR_0->gb);
skip_bits(&VAR_0->gb, 16);
}
}
} else if (VAR_3 == 1) {
int VAR_11;
int VAR_12[3] = { 0, 0, 0 };
VAR_7 = (VAR_0->nb_components > 1) ? 3 : 1;
memset(cur, 0, VAR_0->picture_ptr->linesize[0]);
VAR_8 = VAR_0->VAR_8 * VAR_7;
for (VAR_4 = 0; VAR_4 < VAR_0->height; VAR_4++) {
for (VAR_11 = 0; VAR_11 < VAR_7; VAR_11++) {
ls_decode_line(state, VAR_0, last + VAR_11, cur + VAR_11,
VAR_12[VAR_11], VAR_8, VAR_7, VAR_11, 8);
VAR_12[VAR_11] = last[VAR_11];
if (VAR_0->restart_interval && !--VAR_0->restart_count) {
align_get_bits(&VAR_0->gb);
skip_bits(&VAR_0->gb, 16);
}
}
last = cur;
cur += VAR_0->picture_ptr->linesize[0];
}
} else if (VAR_3 == 2) {
avpriv_report_missing_feature(VAR_0->avctx, "Sample interleaved images");
}
if (VAR_0->xfrm && VAR_0->nb_components == 3) {
int VAR_15, VAR_15;
VAR_15 = VAR_0->VAR_8 * VAR_0->nb_components;
if (VAR_0->bits <= 8) {
uint8_t *src = VAR_0->picture_ptr->data[0];
for (VAR_4 = 0; VAR_4 < VAR_0->height; VAR_4++) {
switch(VAR_0->xfrm) {
case 1:
for (VAR_15 = VAR_6; VAR_15 < VAR_15; VAR_15 += 3) {
src[VAR_15 ] += src[VAR_15+1] + 128;
src[VAR_15+2] += src[VAR_15+1] + 128;
}
break;
case 2:
for (VAR_15 = VAR_6; VAR_15 < VAR_15; VAR_15 += 3) {
src[VAR_15 ] += src[VAR_15+1] + 128;
src[VAR_15+2] += ((src[VAR_15 ] + src[VAR_15+1])>>1) + 128;
}
break;
case 3:
for (VAR_15 = VAR_6; VAR_15 < VAR_15; VAR_15 += 3) {
int g = src[VAR_15+0] - ((src[VAR_15+2]+src[VAR_15+1])>>2) + 64;
src[VAR_15+0] = src[VAR_15+2] + g + 128;
src[VAR_15+2] = src[VAR_15+1] + g + 128;
src[VAR_15+1] = g;
}
break;
case 4:
for (VAR_15 = VAR_6; VAR_15 < VAR_15; VAR_15 += 3) {
int r = src[VAR_15+0] - (( 359 * (src[VAR_15+2]-128) + 490) >> 8);
int g = src[VAR_15+0] - (( 88 * (src[VAR_15+1]-128) - 183 * (src[VAR_15+2]-128) + 30) >> 8);
int b = src[VAR_15+0] + ((454 * (src[VAR_15+1]-128) + 574) >> 8);
src[VAR_15+0] = av_clip_uint8(r);
src[VAR_15+1] = av_clip_uint8(g);
src[VAR_15+2] = av_clip_uint8(b);
}
break;
}
src += VAR_0->picture_ptr->linesize[0];
}
}else
avpriv_report_missing_feature(VAR_0->avctx, "16bit xfrm");
}
if (VAR_9) {
int VAR_15, VAR_15;
VAR_15 = VAR_0->VAR_8 * VAR_0->nb_components;
if (VAR_0->bits <= 8) {
uint8_t *src = VAR_0->picture_ptr->data[0];
for (VAR_4 = 0; VAR_4 < VAR_0->height; VAR_4++) {
for (VAR_15 = VAR_6; VAR_15 < VAR_15; VAR_15 += VAR_7)
src[VAR_15] <<= VAR_9;
src += VAR_0->picture_ptr->linesize[0];
}
} else {
uint16_t *src = (uint16_t *)VAR_0->picture_ptr->data[0];
for (VAR_4 = 0; VAR_4 < VAR_0->height; VAR_4++) {
for (VAR_15 = 0; VAR_15 < VAR_15; VAR_15++)
src[VAR_15] <<= VAR_9;
src += VAR_0->picture_ptr->linesize[0] / 2;
}
}
}
end:
av_free(state);
av_free(zero);
return VAR_10;
} | [
"int FUNC_0(MJpegDecodeContext *VAR_0, int VAR_1,\nint VAR_2, int VAR_3)\n{",
"int VAR_4, VAR_5 = 0;",
"uint8_t *zero, *last, *cur;",
"JLSState *state;",
"int VAR_6 = 0, VAR_7 = 1, VAR_8, VAR_9, VAR_10 = 0;",
"zero = av_mallocz(VAR_0->picture_ptr->linesize[0]);",
"if (!zero)\nreturn AVERROR(ENOMEM);",
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
... |
9,503 | static void create_gic(const VirtBoardInfo *vbi, qemu_irq *pic)
{
/* We create a standalone GIC v2 */
DeviceState *gicdev;
SysBusDevice *gicbusdev;
const char *gictype = "arm_gic";
int i;
if (kvm_irqchip_in_kernel()) {
gictype = "kvm-arm-gic";
}
gicdev = qdev_create(NULL, gictype);
qdev_prop_set_uint32(gicdev, "revision", 2);
qdev_prop_set_uint32(gicdev, "num-cpu", smp_cpus);
/* Note that the num-irq property counts both internal and external
* interrupts; there are always 32 of the former (mandated by GIC spec).
*/
qdev_prop_set_uint32(gicdev, "num-irq", NUM_IRQS + 32);
qdev_init_nofail(gicdev);
gicbusdev = SYS_BUS_DEVICE(gicdev);
sysbus_mmio_map(gicbusdev, 0, vbi->memmap[VIRT_GIC_DIST].base);
sysbus_mmio_map(gicbusdev, 1, vbi->memmap[VIRT_GIC_CPU].base);
/* Wire the outputs from each CPU's generic timer to the
* appropriate GIC PPI inputs, and the GIC's IRQ output to
* the CPU's IRQ input.
*/
for (i = 0; i < smp_cpus; i++) {
DeviceState *cpudev = DEVICE(qemu_get_cpu(i));
int ppibase = NUM_IRQS + i * 32;
/* physical timer; we wire it up to the non-secure timer's ID,
* since a real A15 always has TrustZone but QEMU doesn't.
*/
qdev_connect_gpio_out(cpudev, 0,
qdev_get_gpio_in(gicdev, ppibase + 30));
/* virtual timer */
qdev_connect_gpio_out(cpudev, 1,
qdev_get_gpio_in(gicdev, ppibase + 27));
sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ));
}
for (i = 0; i < NUM_IRQS; i++) {
pic[i] = qdev_get_gpio_in(gicdev, i);
}
fdt_add_gic_node(vbi);
}
| true | qemu | 4ab29b8214cc4b54e0c1a8270b610a340311470e | static void create_gic(const VirtBoardInfo *vbi, qemu_irq *pic)
{
DeviceState *gicdev;
SysBusDevice *gicbusdev;
const char *gictype = "arm_gic";
int i;
if (kvm_irqchip_in_kernel()) {
gictype = "kvm-arm-gic";
}
gicdev = qdev_create(NULL, gictype);
qdev_prop_set_uint32(gicdev, "revision", 2);
qdev_prop_set_uint32(gicdev, "num-cpu", smp_cpus);
qdev_prop_set_uint32(gicdev, "num-irq", NUM_IRQS + 32);
qdev_init_nofail(gicdev);
gicbusdev = SYS_BUS_DEVICE(gicdev);
sysbus_mmio_map(gicbusdev, 0, vbi->memmap[VIRT_GIC_DIST].base);
sysbus_mmio_map(gicbusdev, 1, vbi->memmap[VIRT_GIC_CPU].base);
for (i = 0; i < smp_cpus; i++) {
DeviceState *cpudev = DEVICE(qemu_get_cpu(i));
int ppibase = NUM_IRQS + i * 32;
qdev_connect_gpio_out(cpudev, 0,
qdev_get_gpio_in(gicdev, ppibase + 30));
qdev_connect_gpio_out(cpudev, 1,
qdev_get_gpio_in(gicdev, ppibase + 27));
sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ));
}
for (i = 0; i < NUM_IRQS; i++) {
pic[i] = qdev_get_gpio_in(gicdev, i);
}
fdt_add_gic_node(vbi);
}
| {
"code": [
"static void create_gic(const VirtBoardInfo *vbi, qemu_irq *pic)",
" fdt_add_gic_node(vbi);"
],
"line_no": [
1,
95
]
} | static void FUNC_0(const VirtBoardInfo *VAR_0, qemu_irq *VAR_1)
{
DeviceState *gicdev;
SysBusDevice *gicbusdev;
const char *VAR_2 = "arm_gic";
int VAR_3;
if (kvm_irqchip_in_kernel()) {
VAR_2 = "kvm-arm-gic";
}
gicdev = qdev_create(NULL, VAR_2);
qdev_prop_set_uint32(gicdev, "revision", 2);
qdev_prop_set_uint32(gicdev, "num-cpu", smp_cpus);
qdev_prop_set_uint32(gicdev, "num-irq", NUM_IRQS + 32);
qdev_init_nofail(gicdev);
gicbusdev = SYS_BUS_DEVICE(gicdev);
sysbus_mmio_map(gicbusdev, 0, VAR_0->memmap[VIRT_GIC_DIST].base);
sysbus_mmio_map(gicbusdev, 1, VAR_0->memmap[VIRT_GIC_CPU].base);
for (VAR_3 = 0; VAR_3 < smp_cpus; VAR_3++) {
DeviceState *cpudev = DEVICE(qemu_get_cpu(VAR_3));
int ppibase = NUM_IRQS + VAR_3 * 32;
qdev_connect_gpio_out(cpudev, 0,
qdev_get_gpio_in(gicdev, ppibase + 30));
qdev_connect_gpio_out(cpudev, 1,
qdev_get_gpio_in(gicdev, ppibase + 27));
sysbus_connect_irq(gicbusdev, VAR_3, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ));
}
for (VAR_3 = 0; VAR_3 < NUM_IRQS; VAR_3++) {
VAR_1[VAR_3] = qdev_get_gpio_in(gicdev, VAR_3);
}
fdt_add_gic_node(VAR_0);
}
| [
"static void FUNC_0(const VirtBoardInfo *VAR_0, qemu_irq *VAR_1)\n{",
"DeviceState *gicdev;",
"SysBusDevice *gicbusdev;",
"const char *VAR_2 = \"arm_gic\";",
"int VAR_3;",
"if (kvm_irqchip_in_kernel()) {",
"VAR_2 = \"kvm-arm-gic\";",
"}",
"gicdev = qdev_create(NULL, VAR_2);",
"qdev_prop_set_uint32... | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
57
],
[
59
],
[
61
],
[
69... |
9,504 | virtio_crypto_sym_op_helper(VirtIODevice *vdev,
struct virtio_crypto_cipher_para *cipher_para,
struct virtio_crypto_alg_chain_data_para *alg_chain_para,
struct iovec *iov, unsigned int out_num)
{
VirtIOCrypto *vcrypto = VIRTIO_CRYPTO(vdev);
CryptoDevBackendSymOpInfo *op_info;
uint32_t src_len = 0, dst_len = 0;
uint32_t iv_len = 0;
uint32_t aad_len = 0, hash_result_len = 0;
uint32_t hash_start_src_offset = 0, len_to_hash = 0;
uint32_t cipher_start_src_offset = 0, len_to_cipher = 0;
size_t max_len, curr_size = 0;
size_t s;
/* Plain cipher */
if (cipher_para) {
iv_len = ldl_le_p(&cipher_para->iv_len);
src_len = ldl_le_p(&cipher_para->src_data_len);
dst_len = ldl_le_p(&cipher_para->dst_data_len);
} else if (alg_chain_para) { /* Algorithm chain */
iv_len = ldl_le_p(&alg_chain_para->iv_len);
src_len = ldl_le_p(&alg_chain_para->src_data_len);
dst_len = ldl_le_p(&alg_chain_para->dst_data_len);
aad_len = ldl_le_p(&alg_chain_para->aad_len);
hash_result_len = ldl_le_p(&alg_chain_para->hash_result_len);
hash_start_src_offset = ldl_le_p(
&alg_chain_para->hash_start_src_offset);
cipher_start_src_offset = ldl_le_p(
&alg_chain_para->cipher_start_src_offset);
len_to_cipher = ldl_le_p(&alg_chain_para->len_to_cipher);
len_to_hash = ldl_le_p(&alg_chain_para->len_to_hash);
} else {
return NULL;
}
max_len = iv_len + aad_len + src_len + dst_len + hash_result_len;
if (unlikely(max_len > vcrypto->conf.max_size)) {
virtio_error(vdev, "virtio-crypto too big length");
return NULL;
}
op_info = g_malloc0(sizeof(CryptoDevBackendSymOpInfo) + max_len);
op_info->iv_len = iv_len;
op_info->src_len = src_len;
op_info->dst_len = dst_len;
op_info->aad_len = aad_len;
op_info->digest_result_len = hash_result_len;
op_info->hash_start_src_offset = hash_start_src_offset;
op_info->len_to_hash = len_to_hash;
op_info->cipher_start_src_offset = cipher_start_src_offset;
op_info->len_to_cipher = len_to_cipher;
/* Handle the initilization vector */
if (op_info->iv_len > 0) {
DPRINTF("iv_len=%" PRIu32 "\n", op_info->iv_len);
op_info->iv = op_info->data + curr_size;
s = iov_to_buf(iov, out_num, 0, op_info->iv, op_info->iv_len);
if (unlikely(s != op_info->iv_len)) {
virtio_error(vdev, "virtio-crypto iv incorrect");
goto err;
}
iov_discard_front(&iov, &out_num, op_info->iv_len);
curr_size += op_info->iv_len;
}
/* Handle additional authentication data if exists */
if (op_info->aad_len > 0) {
DPRINTF("aad_len=%" PRIu32 "\n", op_info->aad_len);
op_info->aad_data = op_info->data + curr_size;
s = iov_to_buf(iov, out_num, 0, op_info->aad_data, op_info->aad_len);
if (unlikely(s != op_info->aad_len)) {
virtio_error(vdev, "virtio-crypto additional auth data incorrect");
goto err;
}
iov_discard_front(&iov, &out_num, op_info->aad_len);
curr_size += op_info->aad_len;
}
/* Handle the source data */
if (op_info->src_len > 0) {
DPRINTF("src_len=%" PRIu32 "\n", op_info->src_len);
op_info->src = op_info->data + curr_size;
s = iov_to_buf(iov, out_num, 0, op_info->src, op_info->src_len);
if (unlikely(s != op_info->src_len)) {
virtio_error(vdev, "virtio-crypto source data incorrect");
goto err;
}
iov_discard_front(&iov, &out_num, op_info->src_len);
curr_size += op_info->src_len;
}
/* Handle the destination data */
op_info->dst = op_info->data + curr_size;
curr_size += op_info->dst_len;
DPRINTF("dst_len=%" PRIu32 "\n", op_info->dst_len);
/* Handle the hash digest result */
if (hash_result_len > 0) {
DPRINTF("hash_result_len=%" PRIu32 "\n", hash_result_len);
op_info->digest_result = op_info->data + curr_size;
}
return op_info;
err:
g_free(op_info);
return NULL;
}
| true | qemu | a08aaff811fb194950f79711d2afe5a892ae03a4 | virtio_crypto_sym_op_helper(VirtIODevice *vdev,
struct virtio_crypto_cipher_para *cipher_para,
struct virtio_crypto_alg_chain_data_para *alg_chain_para,
struct iovec *iov, unsigned int out_num)
{
VirtIOCrypto *vcrypto = VIRTIO_CRYPTO(vdev);
CryptoDevBackendSymOpInfo *op_info;
uint32_t src_len = 0, dst_len = 0;
uint32_t iv_len = 0;
uint32_t aad_len = 0, hash_result_len = 0;
uint32_t hash_start_src_offset = 0, len_to_hash = 0;
uint32_t cipher_start_src_offset = 0, len_to_cipher = 0;
size_t max_len, curr_size = 0;
size_t s;
if (cipher_para) {
iv_len = ldl_le_p(&cipher_para->iv_len);
src_len = ldl_le_p(&cipher_para->src_data_len);
dst_len = ldl_le_p(&cipher_para->dst_data_len);
} else if (alg_chain_para) {
iv_len = ldl_le_p(&alg_chain_para->iv_len);
src_len = ldl_le_p(&alg_chain_para->src_data_len);
dst_len = ldl_le_p(&alg_chain_para->dst_data_len);
aad_len = ldl_le_p(&alg_chain_para->aad_len);
hash_result_len = ldl_le_p(&alg_chain_para->hash_result_len);
hash_start_src_offset = ldl_le_p(
&alg_chain_para->hash_start_src_offset);
cipher_start_src_offset = ldl_le_p(
&alg_chain_para->cipher_start_src_offset);
len_to_cipher = ldl_le_p(&alg_chain_para->len_to_cipher);
len_to_hash = ldl_le_p(&alg_chain_para->len_to_hash);
} else {
return NULL;
}
max_len = iv_len + aad_len + src_len + dst_len + hash_result_len;
if (unlikely(max_len > vcrypto->conf.max_size)) {
virtio_error(vdev, "virtio-crypto too big length");
return NULL;
}
op_info = g_malloc0(sizeof(CryptoDevBackendSymOpInfo) + max_len);
op_info->iv_len = iv_len;
op_info->src_len = src_len;
op_info->dst_len = dst_len;
op_info->aad_len = aad_len;
op_info->digest_result_len = hash_result_len;
op_info->hash_start_src_offset = hash_start_src_offset;
op_info->len_to_hash = len_to_hash;
op_info->cipher_start_src_offset = cipher_start_src_offset;
op_info->len_to_cipher = len_to_cipher;
if (op_info->iv_len > 0) {
DPRINTF("iv_len=%" PRIu32 "\n", op_info->iv_len);
op_info->iv = op_info->data + curr_size;
s = iov_to_buf(iov, out_num, 0, op_info->iv, op_info->iv_len);
if (unlikely(s != op_info->iv_len)) {
virtio_error(vdev, "virtio-crypto iv incorrect");
goto err;
}
iov_discard_front(&iov, &out_num, op_info->iv_len);
curr_size += op_info->iv_len;
}
if (op_info->aad_len > 0) {
DPRINTF("aad_len=%" PRIu32 "\n", op_info->aad_len);
op_info->aad_data = op_info->data + curr_size;
s = iov_to_buf(iov, out_num, 0, op_info->aad_data, op_info->aad_len);
if (unlikely(s != op_info->aad_len)) {
virtio_error(vdev, "virtio-crypto additional auth data incorrect");
goto err;
}
iov_discard_front(&iov, &out_num, op_info->aad_len);
curr_size += op_info->aad_len;
}
if (op_info->src_len > 0) {
DPRINTF("src_len=%" PRIu32 "\n", op_info->src_len);
op_info->src = op_info->data + curr_size;
s = iov_to_buf(iov, out_num, 0, op_info->src, op_info->src_len);
if (unlikely(s != op_info->src_len)) {
virtio_error(vdev, "virtio-crypto source data incorrect");
goto err;
}
iov_discard_front(&iov, &out_num, op_info->src_len);
curr_size += op_info->src_len;
}
op_info->dst = op_info->data + curr_size;
curr_size += op_info->dst_len;
DPRINTF("dst_len=%" PRIu32 "\n", op_info->dst_len);
if (hash_result_len > 0) {
DPRINTF("hash_result_len=%" PRIu32 "\n", hash_result_len);
op_info->digest_result = op_info->data + curr_size;
}
return op_info;
err:
g_free(op_info);
return NULL;
}
| {
"code": [
" size_t max_len, curr_size = 0;",
" max_len = iv_len + aad_len + src_len + dst_len + hash_result_len;"
],
"line_no": [
27,
77
]
} | FUNC_0(VirtIODevice *VAR_0,
struct virtio_crypto_cipher_para *VAR_1,
struct virtio_crypto_alg_chain_data_para *VAR_2,
struct iovec *VAR_3, unsigned int VAR_4)
{
VirtIOCrypto *vcrypto = VIRTIO_CRYPTO(VAR_0);
CryptoDevBackendSymOpInfo *op_info;
uint32_t src_len = 0, dst_len = 0;
uint32_t iv_len = 0;
uint32_t aad_len = 0, hash_result_len = 0;
uint32_t hash_start_src_offset = 0, len_to_hash = 0;
uint32_t cipher_start_src_offset = 0, len_to_cipher = 0;
size_t max_len, curr_size = 0;
size_t s;
if (VAR_1) {
iv_len = ldl_le_p(&VAR_1->iv_len);
src_len = ldl_le_p(&VAR_1->src_data_len);
dst_len = ldl_le_p(&VAR_1->dst_data_len);
} else if (VAR_2) {
iv_len = ldl_le_p(&VAR_2->iv_len);
src_len = ldl_le_p(&VAR_2->src_data_len);
dst_len = ldl_le_p(&VAR_2->dst_data_len);
aad_len = ldl_le_p(&VAR_2->aad_len);
hash_result_len = ldl_le_p(&VAR_2->hash_result_len);
hash_start_src_offset = ldl_le_p(
&VAR_2->hash_start_src_offset);
cipher_start_src_offset = ldl_le_p(
&VAR_2->cipher_start_src_offset);
len_to_cipher = ldl_le_p(&VAR_2->len_to_cipher);
len_to_hash = ldl_le_p(&VAR_2->len_to_hash);
} else {
return NULL;
}
max_len = iv_len + aad_len + src_len + dst_len + hash_result_len;
if (unlikely(max_len > vcrypto->conf.max_size)) {
virtio_error(VAR_0, "virtio-crypto too big length");
return NULL;
}
op_info = g_malloc0(sizeof(CryptoDevBackendSymOpInfo) + max_len);
op_info->iv_len = iv_len;
op_info->src_len = src_len;
op_info->dst_len = dst_len;
op_info->aad_len = aad_len;
op_info->digest_result_len = hash_result_len;
op_info->hash_start_src_offset = hash_start_src_offset;
op_info->len_to_hash = len_to_hash;
op_info->cipher_start_src_offset = cipher_start_src_offset;
op_info->len_to_cipher = len_to_cipher;
if (op_info->iv_len > 0) {
DPRINTF("iv_len=%" PRIu32 "\n", op_info->iv_len);
op_info->iv = op_info->data + curr_size;
s = iov_to_buf(VAR_3, VAR_4, 0, op_info->iv, op_info->iv_len);
if (unlikely(s != op_info->iv_len)) {
virtio_error(VAR_0, "virtio-crypto iv incorrect");
goto err;
}
iov_discard_front(&VAR_3, &VAR_4, op_info->iv_len);
curr_size += op_info->iv_len;
}
if (op_info->aad_len > 0) {
DPRINTF("aad_len=%" PRIu32 "\n", op_info->aad_len);
op_info->aad_data = op_info->data + curr_size;
s = iov_to_buf(VAR_3, VAR_4, 0, op_info->aad_data, op_info->aad_len);
if (unlikely(s != op_info->aad_len)) {
virtio_error(VAR_0, "virtio-crypto additional auth data incorrect");
goto err;
}
iov_discard_front(&VAR_3, &VAR_4, op_info->aad_len);
curr_size += op_info->aad_len;
}
if (op_info->src_len > 0) {
DPRINTF("src_len=%" PRIu32 "\n", op_info->src_len);
op_info->src = op_info->data + curr_size;
s = iov_to_buf(VAR_3, VAR_4, 0, op_info->src, op_info->src_len);
if (unlikely(s != op_info->src_len)) {
virtio_error(VAR_0, "virtio-crypto source data incorrect");
goto err;
}
iov_discard_front(&VAR_3, &VAR_4, op_info->src_len);
curr_size += op_info->src_len;
}
op_info->dst = op_info->data + curr_size;
curr_size += op_info->dst_len;
DPRINTF("dst_len=%" PRIu32 "\n", op_info->dst_len);
if (hash_result_len > 0) {
DPRINTF("hash_result_len=%" PRIu32 "\n", hash_result_len);
op_info->digest_result = op_info->data + curr_size;
}
return op_info;
err:
g_free(op_info);
return NULL;
}
| [
"FUNC_0(VirtIODevice *VAR_0,\nstruct virtio_crypto_cipher_para *VAR_1,\nstruct virtio_crypto_alg_chain_data_para *VAR_2,\nstruct iovec *VAR_3, unsigned int VAR_4)\n{",
"VirtIOCrypto *vcrypto = VIRTIO_CRYPTO(VAR_0);",
"CryptoDevBackendSymOpInfo *op_info;",
"uint32_t src_len = 0, dst_len = 0;",
"uint32_t iv_l... | [
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[... |
9,505 | int net_slirp_parse_legacy(QemuOptsList *opts_list, const char *optarg, int *ret)
{
if (strcmp(opts_list->name, "net") != 0 ||
strncmp(optarg, "channel,", strlen("channel,")) != 0) {
return 0;
}
error_report("The '-net channel' option is deprecated. "
"Please use '-netdev user,guestfwd=...' instead.");
/* handle legacy -net channel,port:chr */
optarg += strlen("channel,");
if (QTAILQ_EMPTY(&slirp_stacks)) {
struct slirp_config_str *config;
config = g_malloc(sizeof(*config));
pstrcpy(config->str, sizeof(config->str), optarg);
config->flags = SLIRP_CFG_LEGACY;
config->next = slirp_configs;
slirp_configs = config;
*ret = 0;
} else {
*ret = slirp_guestfwd(QTAILQ_FIRST(&slirp_stacks), optarg, 1);
}
return 1;
}
| true | qemu | 5c843af22604edecda10d4bb89d4eede9e1bd3d0 | int net_slirp_parse_legacy(QemuOptsList *opts_list, const char *optarg, int *ret)
{
if (strcmp(opts_list->name, "net") != 0 ||
strncmp(optarg, "channel,", strlen("channel,")) != 0) {
return 0;
}
error_report("The '-net channel' option is deprecated. "
"Please use '-netdev user,guestfwd=...' instead.");
optarg += strlen("channel,");
if (QTAILQ_EMPTY(&slirp_stacks)) {
struct slirp_config_str *config;
config = g_malloc(sizeof(*config));
pstrcpy(config->str, sizeof(config->str), optarg);
config->flags = SLIRP_CFG_LEGACY;
config->next = slirp_configs;
slirp_configs = config;
*ret = 0;
} else {
*ret = slirp_guestfwd(QTAILQ_FIRST(&slirp_stacks), optarg, 1);
}
return 1;
}
| {
"code": [
" *ret = slirp_guestfwd(QTAILQ_FIRST(&slirp_stacks), optarg, 1);"
],
"line_no": [
47
]
} | int FUNC_0(QemuOptsList *VAR_0, const char *VAR_1, int *VAR_2)
{
if (strcmp(VAR_0->name, "net") != 0 ||
strncmp(VAR_1, "channel,", strlen("channel,")) != 0) {
return 0;
}
error_report("The '-net channel' option is deprecated. "
"Please use '-netdev user,guestfwd=...' instead.");
VAR_1 += strlen("channel,");
if (QTAILQ_EMPTY(&slirp_stacks)) {
struct slirp_config_str *VAR_3;
VAR_3 = g_malloc(sizeof(*VAR_3));
pstrcpy(VAR_3->str, sizeof(VAR_3->str), VAR_1);
VAR_3->flags = SLIRP_CFG_LEGACY;
VAR_3->next = slirp_configs;
slirp_configs = VAR_3;
*VAR_2 = 0;
} else {
*VAR_2 = slirp_guestfwd(QTAILQ_FIRST(&slirp_stacks), VAR_1, 1);
}
return 1;
}
| [
"int FUNC_0(QemuOptsList *VAR_0, const char *VAR_1, int *VAR_2)\n{",
"if (strcmp(VAR_0->name, \"net\") != 0 ||\nstrncmp(VAR_1, \"channel,\", strlen(\"channel,\")) != 0) {",
"return 0;",
"}",
"error_report(\"The '-net channel' option is deprecated. \"\n\"Please use '-netdev user,guestfwd=...' instead.\");",
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
11
],
[
15,
17
],
[
23
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
... |
9,506 | static int shall_we_drop(AVFormatContext *s)
{
struct dshow_ctx *ctx = s->priv_data;
static const uint8_t dropscore[] = {62, 75, 87, 100};
const int ndropscores = FF_ARRAY_ELEMS(dropscore);
unsigned int buffer_fullness = (ctx->curbufsize*100)/s->max_picture_buffer;
if(dropscore[++ctx->video_frame_num%ndropscores] <= buffer_fullness) {
av_log(s, AV_LOG_ERROR,
"real-time buffer %d%% full! frame dropped!\n", buffer_fullness);
return 1;
}
return 0;
}
| true | FFmpeg | 6abc56e892c2c2500d1fc2698fa6d580b72f721b | static int shall_we_drop(AVFormatContext *s)
{
struct dshow_ctx *ctx = s->priv_data;
static const uint8_t dropscore[] = {62, 75, 87, 100};
const int ndropscores = FF_ARRAY_ELEMS(dropscore);
unsigned int buffer_fullness = (ctx->curbufsize*100)/s->max_picture_buffer;
if(dropscore[++ctx->video_frame_num%ndropscores] <= buffer_fullness) {
av_log(s, AV_LOG_ERROR,
"real-time buffer %d%% full! frame dropped!\n", buffer_fullness);
return 1;
}
return 0;
}
| {
"code": [
"static int shall_we_drop(AVFormatContext *s)",
" unsigned int buffer_fullness = (ctx->curbufsize*100)/s->max_picture_buffer;",
" \"real-time buffer %d%% full! frame dropped!\\n\", buffer_fullness);"
],
"line_no": [
1,
11,
19
]
} | static int FUNC_0(AVFormatContext *VAR_0)
{
struct dshow_ctx *VAR_1 = VAR_0->priv_data;
static const uint8_t VAR_2[] = {62, 75, 87, 100};
const int VAR_3 = FF_ARRAY_ELEMS(VAR_2);
unsigned int VAR_4 = (VAR_1->curbufsize*100)/VAR_0->max_picture_buffer;
if(VAR_2[++VAR_1->video_frame_num%VAR_3] <= VAR_4) {
av_log(VAR_0, AV_LOG_ERROR,
"real-time buffer %d%% full! frame dropped!\n", VAR_4);
return 1;
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"struct dshow_ctx *VAR_1 = VAR_0->priv_data;",
"static const uint8_t VAR_2[] = {62, 75, 87, 100};",
"const int VAR_3 = FF_ARRAY_ELEMS(VAR_2);",
"unsigned int VAR_4 = (VAR_1->curbufsize*100)/VAR_0->max_picture_buffer;",
"if(VAR_2[++VAR_1->video_frame_num%VAR_... | [
1,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
27
],
[
29
]
] |
9,507 | static int disas_dsp_insn(CPUState *env, DisasContext *s, uint32_t insn)
{
int acc, rd0, rd1, rdhi, rdlo;
TCGv tmp, tmp2;
if ((insn & 0x0ff00f10) == 0x0e200010) {
/* Multiply with Internal Accumulate Format */
rd0 = (insn >> 12) & 0xf;
rd1 = insn & 0xf;
acc = (insn >> 5) & 7;
if (acc != 0)
return 1;
tmp = load_reg(s, rd0);
tmp2 = load_reg(s, rd1);
switch ((insn >> 16) & 0xf) {
case 0x0: /* MIA */
gen_helper_iwmmxt_muladdsl(cpu_M0, cpu_M0, tmp, tmp2);
break;
case 0x8: /* MIAPH */
gen_helper_iwmmxt_muladdsw(cpu_M0, cpu_M0, tmp, tmp2);
break;
case 0xc: /* MIABB */
case 0xd: /* MIABT */
case 0xe: /* MIATB */
case 0xf: /* MIATT */
if (insn & (1 << 16))
tcg_gen_shri_i32(tmp, tmp, 16);
if (insn & (1 << 17))
tcg_gen_shri_i32(tmp2, tmp2, 16);
gen_helper_iwmmxt_muladdswl(cpu_M0, cpu_M0, tmp, tmp2);
break;
default:
return 1;
}
dead_tmp(tmp2);
dead_tmp(tmp);
gen_op_iwmmxt_movq_wRn_M0(acc);
return 0;
}
if ((insn & 0x0fe00ff8) == 0x0c400000) {
/* Internal Accumulator Access Format */
rdhi = (insn >> 16) & 0xf;
rdlo = (insn >> 12) & 0xf;
acc = insn & 7;
if (acc != 0)
return 1;
if (insn & ARM_CP_RW_BIT) { /* MRA */
iwmmxt_load_reg(cpu_V0, acc);
tcg_gen_trunc_i64_i32(cpu_R[rdlo], cpu_V0);
tcg_gen_shri_i64(cpu_V0, cpu_V0, 32);
tcg_gen_trunc_i64_i32(cpu_R[rdhi], cpu_V0);
tcg_gen_andi_i32(cpu_R[rdhi], cpu_R[rdhi], (1 << (40 - 32)) - 1);
} else { /* MAR */
tcg_gen_concat_i32_i64(cpu_V0, cpu_R[rdlo], cpu_R[rdhi]);
iwmmxt_store_reg(cpu_V0, acc);
}
return 0;
}
return 1;
}
| true | qemu | 7d1b0095bff7157e856d1d0e6c4295641ced2752 | static int disas_dsp_insn(CPUState *env, DisasContext *s, uint32_t insn)
{
int acc, rd0, rd1, rdhi, rdlo;
TCGv tmp, tmp2;
if ((insn & 0x0ff00f10) == 0x0e200010) {
rd0 = (insn >> 12) & 0xf;
rd1 = insn & 0xf;
acc = (insn >> 5) & 7;
if (acc != 0)
return 1;
tmp = load_reg(s, rd0);
tmp2 = load_reg(s, rd1);
switch ((insn >> 16) & 0xf) {
case 0x0:
gen_helper_iwmmxt_muladdsl(cpu_M0, cpu_M0, tmp, tmp2);
break;
case 0x8:
gen_helper_iwmmxt_muladdsw(cpu_M0, cpu_M0, tmp, tmp2);
break;
case 0xc:
case 0xd:
case 0xe:
case 0xf:
if (insn & (1 << 16))
tcg_gen_shri_i32(tmp, tmp, 16);
if (insn & (1 << 17))
tcg_gen_shri_i32(tmp2, tmp2, 16);
gen_helper_iwmmxt_muladdswl(cpu_M0, cpu_M0, tmp, tmp2);
break;
default:
return 1;
}
dead_tmp(tmp2);
dead_tmp(tmp);
gen_op_iwmmxt_movq_wRn_M0(acc);
return 0;
}
if ((insn & 0x0fe00ff8) == 0x0c400000) {
rdhi = (insn >> 16) & 0xf;
rdlo = (insn >> 12) & 0xf;
acc = insn & 7;
if (acc != 0)
return 1;
if (insn & ARM_CP_RW_BIT) {
iwmmxt_load_reg(cpu_V0, acc);
tcg_gen_trunc_i64_i32(cpu_R[rdlo], cpu_V0);
tcg_gen_shri_i64(cpu_V0, cpu_V0, 32);
tcg_gen_trunc_i64_i32(cpu_R[rdhi], cpu_V0);
tcg_gen_andi_i32(cpu_R[rdhi], cpu_R[rdhi], (1 << (40 - 32)) - 1);
} else {
tcg_gen_concat_i32_i64(cpu_V0, cpu_R[rdlo], cpu_R[rdhi]);
iwmmxt_store_reg(cpu_V0, acc);
}
return 0;
}
return 1;
}
| {
"code": [
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp2);",
" dead_tmp(tmp2);",
" dead_tmp(tmp);",
" dead_tmp(tmp2);",
" dead_tmp(tmp);",
" dead_tmp(tmp2);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp2);",
" dead_tmp(tmp);",
" dead_tmp(tmp2);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp2);",
" dead_tmp(tmp);",
" dead_tmp(tmp2);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp2);",
" dead_tmp(tmp2);",
" dead_tmp(tmp2);",
" dead_tmp(tmp);",
" dead_tmp(tmp);"
],
"line_no": [
75,
75,
73,
73,
75,
73,
75,
73,
75,
75,
75,
75,
75,
73,
75,
73,
75,
75,
75,
75,
75,
73,
75,
73,
75,
75,
75,
73,
73,
73,
75,
75
]
} | static int FUNC_0(CPUState *VAR_0, DisasContext *VAR_1, uint32_t VAR_2)
{
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;
TCGv tmp, tmp2;
if ((VAR_2 & 0x0ff00f10) == 0x0e200010) {
VAR_4 = (VAR_2 >> 12) & 0xf;
VAR_5 = VAR_2 & 0xf;
VAR_3 = (VAR_2 >> 5) & 7;
if (VAR_3 != 0)
return 1;
tmp = load_reg(VAR_1, VAR_4);
tmp2 = load_reg(VAR_1, VAR_5);
switch ((VAR_2 >> 16) & 0xf) {
case 0x0:
gen_helper_iwmmxt_muladdsl(cpu_M0, cpu_M0, tmp, tmp2);
break;
case 0x8:
gen_helper_iwmmxt_muladdsw(cpu_M0, cpu_M0, tmp, tmp2);
break;
case 0xc:
case 0xd:
case 0xe:
case 0xf:
if (VAR_2 & (1 << 16))
tcg_gen_shri_i32(tmp, tmp, 16);
if (VAR_2 & (1 << 17))
tcg_gen_shri_i32(tmp2, tmp2, 16);
gen_helper_iwmmxt_muladdswl(cpu_M0, cpu_M0, tmp, tmp2);
break;
default:
return 1;
}
dead_tmp(tmp2);
dead_tmp(tmp);
gen_op_iwmmxt_movq_wRn_M0(VAR_3);
return 0;
}
if ((VAR_2 & 0x0fe00ff8) == 0x0c400000) {
VAR_6 = (VAR_2 >> 16) & 0xf;
VAR_7 = (VAR_2 >> 12) & 0xf;
VAR_3 = VAR_2 & 7;
if (VAR_3 != 0)
return 1;
if (VAR_2 & ARM_CP_RW_BIT) {
iwmmxt_load_reg(cpu_V0, VAR_3);
tcg_gen_trunc_i64_i32(cpu_R[VAR_7], cpu_V0);
tcg_gen_shri_i64(cpu_V0, cpu_V0, 32);
tcg_gen_trunc_i64_i32(cpu_R[VAR_6], cpu_V0);
tcg_gen_andi_i32(cpu_R[VAR_6], cpu_R[VAR_6], (1 << (40 - 32)) - 1);
} else {
tcg_gen_concat_i32_i64(cpu_V0, cpu_R[VAR_7], cpu_R[VAR_6]);
iwmmxt_store_reg(cpu_V0, VAR_3);
}
return 0;
}
return 1;
}
| [
"static int FUNC_0(CPUState *VAR_0, DisasContext *VAR_1, uint32_t VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;",
"TCGv tmp, tmp2;",
"if ((VAR_2 & 0x0ff00f10) == 0x0e200010) {",
"VAR_4 = (VAR_2 >> 12) & 0xf;",
"VAR_5 = VAR_2 & 0xf;",
"VAR_3 = (VAR_2 >> 5) & 7;",
"if (VAR_3 != 0)\nreturn 1;",
"... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23,
25
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41,
43
],
[
45
],
[
47,
49,
51,
53,
55,
57... |
9,511 | static void decode_profile_tier_level(HEVCContext *s, PTLCommon *ptl)
{
int i;
HEVCLocalContext *lc = s->HEVClc;
GetBitContext *gb = &lc->gb;
ptl->profile_space = get_bits(gb, 2);
ptl->tier_flag = get_bits1(gb);
ptl->profile_idc = get_bits(gb, 5);
if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN)
av_log(s->avctx, AV_LOG_DEBUG, "Main profile bitstream\n");
else if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN_10)
av_log(s->avctx, AV_LOG_DEBUG, "Main 10 profile bitstream\n");
else if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN_STILL_PICTURE)
av_log(s->avctx, AV_LOG_DEBUG, "Main Still Picture profile bitstream\n");
else if (ptl->profile_idc == FF_PROFILE_HEVC_REXT)
av_log(s->avctx, AV_LOG_DEBUG, "Range Extension profile bitstream\n");
else
av_log(s->avctx, AV_LOG_WARNING, "Unknown HEVC profile: %d\n", ptl->profile_idc);
for (i = 0; i < 32; i++)
ptl->profile_compatibility_flag[i] = get_bits1(gb);
ptl->progressive_source_flag = get_bits1(gb);
ptl->interlaced_source_flag = get_bits1(gb);
ptl->non_packed_constraint_flag = get_bits1(gb);
ptl->frame_only_constraint_flag = get_bits1(gb);
skip_bits(gb, 16); // XXX_reserved_zero_44bits[0..15]
skip_bits(gb, 16); // XXX_reserved_zero_44bits[16..31]
skip_bits(gb, 12); // XXX_reserved_zero_44bits[32..43]
}
| true | FFmpeg | 0d0d24af0159ff08f396ad04cd63ce5655b1fc60 | static void decode_profile_tier_level(HEVCContext *s, PTLCommon *ptl)
{
int i;
HEVCLocalContext *lc = s->HEVClc;
GetBitContext *gb = &lc->gb;
ptl->profile_space = get_bits(gb, 2);
ptl->tier_flag = get_bits1(gb);
ptl->profile_idc = get_bits(gb, 5);
if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN)
av_log(s->avctx, AV_LOG_DEBUG, "Main profile bitstream\n");
else if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN_10)
av_log(s->avctx, AV_LOG_DEBUG, "Main 10 profile bitstream\n");
else if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN_STILL_PICTURE)
av_log(s->avctx, AV_LOG_DEBUG, "Main Still Picture profile bitstream\n");
else if (ptl->profile_idc == FF_PROFILE_HEVC_REXT)
av_log(s->avctx, AV_LOG_DEBUG, "Range Extension profile bitstream\n");
else
av_log(s->avctx, AV_LOG_WARNING, "Unknown HEVC profile: %d\n", ptl->profile_idc);
for (i = 0; i < 32; i++)
ptl->profile_compatibility_flag[i] = get_bits1(gb);
ptl->progressive_source_flag = get_bits1(gb);
ptl->interlaced_source_flag = get_bits1(gb);
ptl->non_packed_constraint_flag = get_bits1(gb);
ptl->frame_only_constraint_flag = get_bits1(gb);
skip_bits(gb, 16);
skip_bits(gb, 16);
skip_bits(gb, 12);
}
| {
"code": [
"static void decode_profile_tier_level(HEVCContext *s, PTLCommon *ptl)"
],
"line_no": [
1
]
} | static void FUNC_0(HEVCContext *VAR_0, PTLCommon *VAR_1)
{
int VAR_2;
HEVCLocalContext *lc = VAR_0->HEVClc;
GetBitContext *gb = &lc->gb;
VAR_1->profile_space = get_bits(gb, 2);
VAR_1->tier_flag = get_bits1(gb);
VAR_1->profile_idc = get_bits(gb, 5);
if (VAR_1->profile_idc == FF_PROFILE_HEVC_MAIN)
av_log(VAR_0->avctx, AV_LOG_DEBUG, "Main profile bitstream\n");
else if (VAR_1->profile_idc == FF_PROFILE_HEVC_MAIN_10)
av_log(VAR_0->avctx, AV_LOG_DEBUG, "Main 10 profile bitstream\n");
else if (VAR_1->profile_idc == FF_PROFILE_HEVC_MAIN_STILL_PICTURE)
av_log(VAR_0->avctx, AV_LOG_DEBUG, "Main Still Picture profile bitstream\n");
else if (VAR_1->profile_idc == FF_PROFILE_HEVC_REXT)
av_log(VAR_0->avctx, AV_LOG_DEBUG, "Range Extension profile bitstream\n");
else
av_log(VAR_0->avctx, AV_LOG_WARNING, "Unknown HEVC profile: %d\n", VAR_1->profile_idc);
for (VAR_2 = 0; VAR_2 < 32; VAR_2++)
VAR_1->profile_compatibility_flag[VAR_2] = get_bits1(gb);
VAR_1->progressive_source_flag = get_bits1(gb);
VAR_1->interlaced_source_flag = get_bits1(gb);
VAR_1->non_packed_constraint_flag = get_bits1(gb);
VAR_1->frame_only_constraint_flag = get_bits1(gb);
skip_bits(gb, 16);
skip_bits(gb, 16);
skip_bits(gb, 12);
}
| [
"static void FUNC_0(HEVCContext *VAR_0, PTLCommon *VAR_1)\n{",
"int VAR_2;",
"HEVCLocalContext *lc = VAR_0->HEVClc;",
"GetBitContext *gb = &lc->gb;",
"VAR_1->profile_space = get_bits(gb, 2);",
"VAR_1->tier_flag = get_bits1(gb);",
"VAR_1->profile_idc = get_bits(gb, 5);",
"if (VAR_1->profile_idc =... | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23,
25
],
[
27,
29
],
[
31,
33
],
[
35,
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[... |
9,513 | qemu_irq *mpic_init (target_phys_addr_t base, int nb_cpus,
qemu_irq **irqs, qemu_irq irq_out)
{
openpic_t *mpp;
int i;
struct {
CPUReadMemoryFunc * const *read;
CPUWriteMemoryFunc * const *write;
target_phys_addr_t start_addr;
ram_addr_t size;
} const list[] = {
{mpic_glb_read, mpic_glb_write, MPIC_GLB_REG_START, MPIC_GLB_REG_SIZE},
{mpic_tmr_read, mpic_tmr_write, MPIC_TMR_REG_START, MPIC_TMR_REG_SIZE},
{mpic_ext_read, mpic_ext_write, MPIC_EXT_REG_START, MPIC_EXT_REG_SIZE},
{mpic_int_read, mpic_int_write, MPIC_INT_REG_START, MPIC_INT_REG_SIZE},
{mpic_msg_read, mpic_msg_write, MPIC_MSG_REG_START, MPIC_MSG_REG_SIZE},
{mpic_msi_read, mpic_msi_write, MPIC_MSI_REG_START, MPIC_MSI_REG_SIZE},
{mpic_cpu_read, mpic_cpu_write, MPIC_CPU_REG_START, MPIC_CPU_REG_SIZE},
};
/* XXX: for now, only one CPU is supported */
if (nb_cpus != 1)
return NULL;
mpp = g_malloc0(sizeof(openpic_t));
for (i = 0; i < sizeof(list)/sizeof(list[0]); i++) {
int mem_index;
mem_index = cpu_register_io_memory(list[i].read, list[i].write, mpp,
DEVICE_BIG_ENDIAN);
if (mem_index < 0) {
goto free;
}
cpu_register_physical_memory(base + list[i].start_addr,
list[i].size, mem_index);
}
mpp->nb_cpus = nb_cpus;
mpp->max_irq = MPIC_MAX_IRQ;
mpp->irq_ipi0 = MPIC_IPI_IRQ;
mpp->irq_tim0 = MPIC_TMR_IRQ;
for (i = 0; i < nb_cpus; i++)
mpp->dst[i].irqs = irqs[i];
mpp->irq_out = irq_out;
mpp->irq_raise = mpic_irq_raise;
mpp->reset = mpic_reset;
register_savevm(NULL, "mpic", 0, 2, openpic_save, openpic_load, mpp);
qemu_register_reset(mpic_reset, mpp);
return qemu_allocate_irqs(openpic_set_irq, mpp, mpp->max_irq);
free:
g_free(mpp);
return NULL;
}
| true | qemu | bbc5842211cdd90103cfe52f2ca24afac880694f | qemu_irq *mpic_init (target_phys_addr_t base, int nb_cpus,
qemu_irq **irqs, qemu_irq irq_out)
{
openpic_t *mpp;
int i;
struct {
CPUReadMemoryFunc * const *read;
CPUWriteMemoryFunc * const *write;
target_phys_addr_t start_addr;
ram_addr_t size;
} const list[] = {
{mpic_glb_read, mpic_glb_write, MPIC_GLB_REG_START, MPIC_GLB_REG_SIZE},
{mpic_tmr_read, mpic_tmr_write, MPIC_TMR_REG_START, MPIC_TMR_REG_SIZE},
{mpic_ext_read, mpic_ext_write, MPIC_EXT_REG_START, MPIC_EXT_REG_SIZE},
{mpic_int_read, mpic_int_write, MPIC_INT_REG_START, MPIC_INT_REG_SIZE},
{mpic_msg_read, mpic_msg_write, MPIC_MSG_REG_START, MPIC_MSG_REG_SIZE},
{mpic_msi_read, mpic_msi_write, MPIC_MSI_REG_START, MPIC_MSI_REG_SIZE},
{mpic_cpu_read, mpic_cpu_write, MPIC_CPU_REG_START, MPIC_CPU_REG_SIZE},
};
if (nb_cpus != 1)
return NULL;
mpp = g_malloc0(sizeof(openpic_t));
for (i = 0; i < sizeof(list)/sizeof(list[0]); i++) {
int mem_index;
mem_index = cpu_register_io_memory(list[i].read, list[i].write, mpp,
DEVICE_BIG_ENDIAN);
if (mem_index < 0) {
goto free;
}
cpu_register_physical_memory(base + list[i].start_addr,
list[i].size, mem_index);
}
mpp->nb_cpus = nb_cpus;
mpp->max_irq = MPIC_MAX_IRQ;
mpp->irq_ipi0 = MPIC_IPI_IRQ;
mpp->irq_tim0 = MPIC_TMR_IRQ;
for (i = 0; i < nb_cpus; i++)
mpp->dst[i].irqs = irqs[i];
mpp->irq_out = irq_out;
mpp->irq_raise = mpic_irq_raise;
mpp->reset = mpic_reset;
register_savevm(NULL, "mpic", 0, 2, openpic_save, openpic_load, mpp);
qemu_register_reset(mpic_reset, mpp);
return qemu_allocate_irqs(openpic_set_irq, mpp, mpp->max_irq);
free:
g_free(mpp);
return NULL;
}
| {
"code": [
" if (nb_cpus != 1)",
" return NULL;"
],
"line_no": [
43,
45
]
} | qemu_irq *FUNC_0 (target_phys_addr_t base, int nb_cpus,
qemu_irq **irqs, qemu_irq irq_out)
{
openpic_t *mpp;
int VAR_0;
struct {
CPUReadMemoryFunc * const *read;
CPUWriteMemoryFunc * const *write;
target_phys_addr_t start_addr;
ram_addr_t size;
} const VAR_1[] = {
{mpic_glb_read, mpic_glb_write, MPIC_GLB_REG_START, MPIC_GLB_REG_SIZE},
{mpic_tmr_read, mpic_tmr_write, MPIC_TMR_REG_START, MPIC_TMR_REG_SIZE},
{mpic_ext_read, mpic_ext_write, MPIC_EXT_REG_START, MPIC_EXT_REG_SIZE},
{mpic_int_read, mpic_int_write, MPIC_INT_REG_START, MPIC_INT_REG_SIZE},
{mpic_msg_read, mpic_msg_write, MPIC_MSG_REG_START, MPIC_MSG_REG_SIZE},
{mpic_msi_read, mpic_msi_write, MPIC_MSI_REG_START, MPIC_MSI_REG_SIZE},
{mpic_cpu_read, mpic_cpu_write, MPIC_CPU_REG_START, MPIC_CPU_REG_SIZE},
};
if (nb_cpus != 1)
return NULL;
mpp = g_malloc0(sizeof(openpic_t));
for (VAR_0 = 0; VAR_0 < sizeof(VAR_1)/sizeof(VAR_1[0]); VAR_0++) {
int mem_index;
mem_index = cpu_register_io_memory(VAR_1[VAR_0].read, VAR_1[VAR_0].write, mpp,
DEVICE_BIG_ENDIAN);
if (mem_index < 0) {
goto free;
}
cpu_register_physical_memory(base + VAR_1[VAR_0].start_addr,
VAR_1[VAR_0].size, mem_index);
}
mpp->nb_cpus = nb_cpus;
mpp->max_irq = MPIC_MAX_IRQ;
mpp->irq_ipi0 = MPIC_IPI_IRQ;
mpp->irq_tim0 = MPIC_TMR_IRQ;
for (VAR_0 = 0; VAR_0 < nb_cpus; VAR_0++)
mpp->dst[VAR_0].irqs = irqs[VAR_0];
mpp->irq_out = irq_out;
mpp->irq_raise = mpic_irq_raise;
mpp->reset = mpic_reset;
register_savevm(NULL, "mpic", 0, 2, openpic_save, openpic_load, mpp);
qemu_register_reset(mpic_reset, mpp);
return qemu_allocate_irqs(openpic_set_irq, mpp, mpp->max_irq);
free:
g_free(mpp);
return NULL;
}
| [
"qemu_irq *FUNC_0 (target_phys_addr_t base, int nb_cpus,\nqemu_irq **irqs, qemu_irq irq_out)\n{",
"openpic_t *mpp;",
"int VAR_0;",
"struct {",
"CPUReadMemoryFunc * const *read;",
"CPUWriteMemoryFunc * const *write;",
"target_phys_addr_t start_addr;",
"ram_addr_t size;",
"} const VAR_1[] = {",
"{mp... | [
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
43,
45
],
[
49
... |
9,517 | static void float_to_int16_stride_altivec(int16_t *dst, const float *src,
long len, int stride)
{
int i, j;
vector signed short d, s;
for (i = 0; i < len - 7; i += 8) {
d = float_to_int16_one_altivec(src + i);
for (j = 0; j < 8; j++) {
s = vec_splat(d, j);
vec_ste(s, 0, dst);
dst += stride;
}
}
}
| true | FFmpeg | 9425dc3dba0bd1209aa7a788ea8f3c194fc7c7c5 | static void float_to_int16_stride_altivec(int16_t *dst, const float *src,
long len, int stride)
{
int i, j;
vector signed short d, s;
for (i = 0; i < len - 7; i += 8) {
d = float_to_int16_one_altivec(src + i);
for (j = 0; j < 8; j++) {
s = vec_splat(d, j);
vec_ste(s, 0, dst);
dst += stride;
}
}
}
| {
"code": [
" int i, j;",
" for (j = 0; j < 8; j++) {",
" s = vec_splat(d, j);",
" vec_ste(s, 0, dst);",
" dst += stride;"
],
"line_no": [
7,
17,
19,
21,
23
]
} | static void FUNC_0(int16_t *VAR_0, const float *VAR_1,
long VAR_2, int VAR_3)
{
int VAR_4, VAR_5;
vector signed short d, s;
for (VAR_4 = 0; VAR_4 < VAR_2 - 7; VAR_4 += 8) {
d = float_to_int16_one_altivec(VAR_1 + VAR_4);
for (VAR_5 = 0; VAR_5 < 8; VAR_5++) {
s = vec_splat(d, VAR_5);
vec_ste(s, 0, VAR_0);
VAR_0 += VAR_3;
}
}
}
| [
"static void FUNC_0(int16_t *VAR_0, const float *VAR_1,\nlong VAR_2, int VAR_3)\n{",
"int VAR_4, VAR_5;",
"vector signed short d, s;",
"for (VAR_4 = 0; VAR_4 < VAR_2 - 7; VAR_4 += 8) {",
"d = float_to_int16_one_altivec(VAR_1 + VAR_4);",
"for (VAR_5 = 0; VAR_5 < 8; VAR_5++) {",
"s = vec_splat(d, VAR_5);"... | [
0,
1,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
9,518 | ssize_t iov_send_recv(int sockfd, struct iovec *iov,
size_t offset, size_t bytes,
bool do_sendv)
{
int iovlen;
ssize_t ret;
size_t diff;
struct iovec *last_iov;
/* last_iov is inclusive, so count from one. */
iovlen = 1;
last_iov = iov;
bytes += offset;
while (last_iov->iov_len < bytes) {
bytes -= last_iov->iov_len;
last_iov++;
iovlen++;
}
diff = last_iov->iov_len - bytes;
last_iov->iov_len -= diff;
while (iov->iov_len <= offset) {
offset -= iov->iov_len;
iov++;
iovlen--;
}
iov->iov_base = (char *) iov->iov_base + offset;
iov->iov_len -= offset;
{
#if defined CONFIG_IOVEC && defined CONFIG_POSIX
struct msghdr msg;
memset(&msg, 0, sizeof(msg));
msg.msg_iov = iov;
msg.msg_iovlen = iovlen;
do {
if (do_sendv) {
ret = sendmsg(sockfd, &msg, 0);
} else {
ret = recvmsg(sockfd, &msg, 0);
}
} while (ret == -1 && errno == EINTR);
#else
struct iovec *p = iov;
ret = 0;
while (iovlen > 0) {
int rc;
if (do_sendv) {
rc = send(sockfd, p->iov_base, p->iov_len, 0);
} else {
rc = qemu_recv(sockfd, p->iov_base, p->iov_len, 0);
}
if (rc == -1) {
if (errno == EINTR) {
continue;
}
if (ret == 0) {
ret = -1;
}
break;
}
if (rc == 0) {
break;
}
ret += rc;
iovlen--, p++;
}
#endif
}
/* Undo the changes above */
iov->iov_base = (char *) iov->iov_base - offset;
iov->iov_len += offset;
last_iov->iov_len += diff;
return ret;
}
| true | qemu | 25e5e4c7e9d5ec3e95c9526d1abaca40ada50ab0 | ssize_t iov_send_recv(int sockfd, struct iovec *iov,
size_t offset, size_t bytes,
bool do_sendv)
{
int iovlen;
ssize_t ret;
size_t diff;
struct iovec *last_iov;
iovlen = 1;
last_iov = iov;
bytes += offset;
while (last_iov->iov_len < bytes) {
bytes -= last_iov->iov_len;
last_iov++;
iovlen++;
}
diff = last_iov->iov_len - bytes;
last_iov->iov_len -= diff;
while (iov->iov_len <= offset) {
offset -= iov->iov_len;
iov++;
iovlen--;
}
iov->iov_base = (char *) iov->iov_base + offset;
iov->iov_len -= offset;
{
#if defined CONFIG_IOVEC && defined CONFIG_POSIX
struct msghdr msg;
memset(&msg, 0, sizeof(msg));
msg.msg_iov = iov;
msg.msg_iovlen = iovlen;
do {
if (do_sendv) {
ret = sendmsg(sockfd, &msg, 0);
} else {
ret = recvmsg(sockfd, &msg, 0);
}
} while (ret == -1 && errno == EINTR);
#else
struct iovec *p = iov;
ret = 0;
while (iovlen > 0) {
int rc;
if (do_sendv) {
rc = send(sockfd, p->iov_base, p->iov_len, 0);
} else {
rc = qemu_recv(sockfd, p->iov_base, p->iov_len, 0);
}
if (rc == -1) {
if (errno == EINTR) {
continue;
}
if (ret == 0) {
ret = -1;
}
break;
}
if (rc == 0) {
break;
}
ret += rc;
iovlen--, p++;
}
#endif
}
iov->iov_base = (char *) iov->iov_base - offset;
iov->iov_len += offset;
last_iov->iov_len += diff;
return ret;
}
| {
"code": [
"ssize_t iov_send_recv(int sockfd, struct iovec *iov,",
" size_t offset, size_t bytes,",
" bool do_sendv)",
" int iovlen;",
" ssize_t ret;",
" size_t diff;",
" struct iovec *last_iov;",
" iovlen = 1;",
" last_iov = iov;",
" bytes += offset;",
" while (last_iov->iov_len < bytes) {",
" bytes -= last_iov->iov_len;",
" last_iov++;",
" iovlen++;",
" diff = last_iov->iov_len - bytes;",
" last_iov->iov_len -= diff;",
" while (iov->iov_len <= offset) {",
" offset -= iov->iov_len;",
" iov++;",
" iovlen--;",
" iov->iov_base = (char *) iov->iov_base + offset;",
" iov->iov_len -= offset;",
"#if defined CONFIG_IOVEC && defined CONFIG_POSIX",
" struct msghdr msg;",
" memset(&msg, 0, sizeof(msg));",
" msg.msg_iov = iov;",
" msg.msg_iovlen = iovlen;",
" do {",
" if (do_sendv) {",
" ret = sendmsg(sockfd, &msg, 0);",
" } else {",
" ret = recvmsg(sockfd, &msg, 0);",
" } while (ret == -1 && errno == EINTR);",
"#else",
" struct iovec *p = iov;",
" ret = 0;",
" while (iovlen > 0) {",
" int rc;",
" if (do_sendv) {",
" rc = send(sockfd, p->iov_base, p->iov_len, 0);",
" } else {",
" rc = qemu_recv(sockfd, p->iov_base, p->iov_len, 0);",
" if (rc == -1) {",
" if (errno == EINTR) {",
" continue;",
" if (ret == 0) {",
" ret = -1;",
" break;",
" if (rc == 0) {",
" break;",
" ret += rc;",
" iovlen--, p++;",
"#endif",
" iov->iov_base = (char *) iov->iov_base - offset;",
" iov->iov_len += offset;",
" last_iov->iov_len += diff;",
" return ret;",
"ssize_t iov_send_recv(int sockfd, struct iovec *iov,"
],
"line_no": [
1,
3,
5,
9,
11,
13,
15,
21,
23,
25,
29,
31,
35,
37,
43,
45,
49,
51,
55,
57,
63,
65,
71,
73,
75,
77,
79,
83,
85,
87,
89,
91,
95,
97,
99,
101,
103,
105,
85,
109,
89,
113,
117,
119,
121,
125,
127,
131,
135,
131,
141,
143,
147,
155,
157,
159,
161,
1
]
} | ssize_t FUNC_0(int sockfd, struct iovec *iov,
size_t offset, size_t bytes,
bool do_sendv)
{
int VAR_0;
ssize_t ret;
size_t diff;
struct iovec *VAR_1;
VAR_0 = 1;
VAR_1 = iov;
bytes += offset;
while (VAR_1->iov_len < bytes) {
bytes -= VAR_1->iov_len;
VAR_1++;
VAR_0++;
}
diff = VAR_1->iov_len - bytes;
VAR_1->iov_len -= diff;
while (iov->iov_len <= offset) {
offset -= iov->iov_len;
iov++;
VAR_0--;
}
iov->iov_base = (char *) iov->iov_base + offset;
iov->iov_len -= offset;
{
#if defined CONFIG_IOVEC && defined CONFIG_POSIX
struct msghdr msg;
memset(&msg, 0, sizeof(msg));
msg.msg_iov = iov;
msg.msg_iovlen = VAR_0;
do {
if (do_sendv) {
ret = sendmsg(sockfd, &msg, 0);
} else {
ret = recvmsg(sockfd, &msg, 0);
}
} while (ret == -1 && errno == EINTR);
#else
struct iovec *VAR_2 = iov;
ret = 0;
while (VAR_0 > 0) {
int VAR_3;
if (do_sendv) {
VAR_3 = send(sockfd, VAR_2->iov_base, VAR_2->iov_len, 0);
} else {
VAR_3 = qemu_recv(sockfd, VAR_2->iov_base, VAR_2->iov_len, 0);
}
if (VAR_3 == -1) {
if (errno == EINTR) {
continue;
}
if (ret == 0) {
ret = -1;
}
break;
}
if (VAR_3 == 0) {
break;
}
ret += VAR_3;
VAR_0--, VAR_2++;
}
#endif
}
iov->iov_base = (char *) iov->iov_base - offset;
iov->iov_len += offset;
VAR_1->iov_len += diff;
return ret;
}
| [
"ssize_t FUNC_0(int sockfd, struct iovec *iov,\nsize_t offset, size_t bytes,\nbool do_sendv)\n{",
"int VAR_0;",
"ssize_t ret;",
"size_t diff;",
"struct iovec *VAR_1;",
"VAR_0 = 1;",
"VAR_1 = iov;",
"bytes += offset;",
"while (VAR_1->iov_len < bytes) {",
"bytes -= VAR_1->iov_len;",
"VAR_1++;",
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
0,
1,
1,
0,
1,
1,
1,
1,
0,
1,
1,
0,
1,
0,
1,
1,
1,
1,
1,
0,
1,
0,
1,
0,
1,
1,
1,
0,
1,
1,
0,
1,
0,
1,
0,
0,
1,
1,
0,
1,
1,
1,
1,
1,
0... | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
49
],
[
51
],
[
55
],
[
57
... |
9,519 | static long do_rt_sigreturn_v2(CPUARMState *env)
{
abi_ulong frame_addr;
struct rt_sigframe_v2 *frame = NULL;
/*
* Since we stacked the signal on a 64-bit boundary,
* then 'sp' should be word aligned here. If it's
* not, then the user is trying to mess with us.
*/
frame_addr = env->regs[13];
trace_user_do_rt_sigreturn(env, frame_addr);
if (frame_addr & 7) {
goto badframe;
}
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
goto badframe;
}
if (do_sigframe_return_v2(env, frame_addr, &frame->uc)) {
goto badframe;
}
unlock_user_struct(frame, frame_addr, 0);
return -TARGET_QEMU_ESIGRETURN;
badframe:
unlock_user_struct(frame, frame_addr, 0);
force_sig(TARGET_SIGSEGV /* , current */);
return 0;
}
| true | qemu | c599d4d6d6e9bfdb64e54c33a22cb26e3496b96d | static long do_rt_sigreturn_v2(CPUARMState *env)
{
abi_ulong frame_addr;
struct rt_sigframe_v2 *frame = NULL;
frame_addr = env->regs[13];
trace_user_do_rt_sigreturn(env, frame_addr);
if (frame_addr & 7) {
goto badframe;
}
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
goto badframe;
}
if (do_sigframe_return_v2(env, frame_addr, &frame->uc)) {
goto badframe;
}
unlock_user_struct(frame, frame_addr, 0);
return -TARGET_QEMU_ESIGRETURN;
badframe:
unlock_user_struct(frame, frame_addr, 0);
force_sig(TARGET_SIGSEGV );
return 0;
}
| {
"code": [
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;"
],
"line_no": [
61,
61,
61,
61,
61,
61,
61,
61,
61,
61,
61,
61,
61,
61,
61,
61,
61
]
} | static long FUNC_0(CPUARMState *VAR_0)
{
abi_ulong frame_addr;
struct rt_sigframe_v2 *VAR_1 = NULL;
frame_addr = VAR_0->regs[13];
trace_user_do_rt_sigreturn(VAR_0, frame_addr);
if (frame_addr & 7) {
goto badframe;
}
if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1)) {
goto badframe;
}
if (do_sigframe_return_v2(VAR_0, frame_addr, &VAR_1->uc)) {
goto badframe;
}
unlock_user_struct(VAR_1, frame_addr, 0);
return -TARGET_QEMU_ESIGRETURN;
badframe:
unlock_user_struct(VAR_1, frame_addr, 0);
force_sig(TARGET_SIGSEGV );
return 0;
}
| [
"static long FUNC_0(CPUARMState *VAR_0)\n{",
"abi_ulong frame_addr;",
"struct rt_sigframe_v2 *VAR_1 = NULL;",
"frame_addr = VAR_0->regs[13];",
"trace_user_do_rt_sigreturn(VAR_0, frame_addr);",
"if (frame_addr & 7) {",
"goto badframe;",
"}",
"if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1)) ... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
55,
57
],
[
59
],
[
61
],
... |
9,520 | static void vp8_h_loop_filter_simple_c(uint8_t *dst, ptrdiff_t stride, int flim)
{
int i;
for (i = 0; i < 16; i++)
if (simple_limit(dst + i * stride, 1, flim))
filter_common(dst + i * stride, 1, 1);
}
| true | FFmpeg | ac4b32df71bd932838043a4838b86d11e169707f | static void vp8_h_loop_filter_simple_c(uint8_t *dst, ptrdiff_t stride, int flim)
{
int i;
for (i = 0; i < 16; i++)
if (simple_limit(dst + i * stride, 1, flim))
filter_common(dst + i * stride, 1, 1);
}
| {
"code": [
" int i;",
" for (i = 0; i < 16; i++)",
"static void vp8_h_loop_filter_simple_c(uint8_t *dst, ptrdiff_t stride, int flim)",
" int i;",
" for (i = 0; i < 16; i++)",
" if (simple_limit(dst + i * stride, 1, flim))",
" filter_common(dst + i * stride, 1, 1);"
],
"line_no": [
5,
9,
1,
5,
9,
11,
13
]
} | static void FUNC_0(uint8_t *VAR_0, ptrdiff_t VAR_1, int VAR_2)
{
int VAR_3;
for (VAR_3 = 0; VAR_3 < 16; VAR_3++)
if (simple_limit(VAR_0 + VAR_3 * VAR_1, 1, VAR_2))
filter_common(VAR_0 + VAR_3 * VAR_1, 1, 1);
}
| [
"static void FUNC_0(uint8_t *VAR_0, ptrdiff_t VAR_1, int VAR_2)\n{",
"int VAR_3;",
"for (VAR_3 = 0; VAR_3 < 16; VAR_3++)",
"if (simple_limit(VAR_0 + VAR_3 * VAR_1, 1, VAR_2))\nfilter_common(VAR_0 + VAR_3 * VAR_1, 1, 1);",
"}"
] | [
1,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
15
]
] |
9,521 | static void gain_scale(G723_1_Context *p, int16_t * buf, int energy)
{
int num, denom, gain, bits1, bits2;
int i;
num = energy;
denom = 0;
for (i = 0; i < SUBFRAME_LEN; i++) {
int64_t temp = buf[i] >> 2;
temp = av_clipl_int32(MUL64(temp, temp) << 1);
denom = av_clipl_int32(denom + temp);
}
if (num && denom) {
bits1 = normalize_bits(num, 31);
bits2 = normalize_bits(denom, 31);
num = num << bits1 >> 1;
denom <<= bits2;
bits2 = 5 + bits1 - bits2;
bits2 = FFMAX(0, bits2);
gain = (num >> 1) / (denom >> 16);
gain = square_root(gain << 16 >> bits2);
} else {
gain = 1 << 12;
}
for (i = 0; i < SUBFRAME_LEN; i++) {
p->pf_gain = (15 * p->pf_gain + gain + (1 << 3)) >> 4;
buf[i] = av_clip_int16((buf[i] * (p->pf_gain + (p->pf_gain >> 4)) +
(1 << 10)) >> 11);
}
}
| true | FFmpeg | 1eb1f6f281eb6036d363e0317c1500be4a2708f2 | static void gain_scale(G723_1_Context *p, int16_t * buf, int energy)
{
int num, denom, gain, bits1, bits2;
int i;
num = energy;
denom = 0;
for (i = 0; i < SUBFRAME_LEN; i++) {
int64_t temp = buf[i] >> 2;
temp = av_clipl_int32(MUL64(temp, temp) << 1);
denom = av_clipl_int32(denom + temp);
}
if (num && denom) {
bits1 = normalize_bits(num, 31);
bits2 = normalize_bits(denom, 31);
num = num << bits1 >> 1;
denom <<= bits2;
bits2 = 5 + bits1 - bits2;
bits2 = FFMAX(0, bits2);
gain = (num >> 1) / (denom >> 16);
gain = square_root(gain << 16 >> bits2);
} else {
gain = 1 << 12;
}
for (i = 0; i < SUBFRAME_LEN; i++) {
p->pf_gain = (15 * p->pf_gain + gain + (1 << 3)) >> 4;
buf[i] = av_clip_int16((buf[i] * (p->pf_gain + (p->pf_gain >> 4)) +
(1 << 10)) >> 11);
}
}
| {
"code": [
" int64_t temp = buf[i] >> 2;",
" temp = av_clipl_int32(MUL64(temp, temp) << 1);",
" denom = av_clipl_int32(denom + temp);"
],
"line_no": [
17,
19,
21
]
} | static void FUNC_0(G723_1_Context *VAR_0, int16_t * VAR_1, int VAR_2)
{
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;
int VAR_8;
VAR_3 = VAR_2;
VAR_4 = 0;
for (VAR_8 = 0; VAR_8 < SUBFRAME_LEN; VAR_8++) {
int64_t temp = VAR_1[VAR_8] >> 2;
temp = av_clipl_int32(MUL64(temp, temp) << 1);
VAR_4 = av_clipl_int32(VAR_4 + temp);
}
if (VAR_3 && VAR_4) {
VAR_6 = normalize_bits(VAR_3, 31);
VAR_7 = normalize_bits(VAR_4, 31);
VAR_3 = VAR_3 << VAR_6 >> 1;
VAR_4 <<= VAR_7;
VAR_7 = 5 + VAR_6 - VAR_7;
VAR_7 = FFMAX(0, VAR_7);
VAR_5 = (VAR_3 >> 1) / (VAR_4 >> 16);
VAR_5 = square_root(VAR_5 << 16 >> VAR_7);
} else {
VAR_5 = 1 << 12;
}
for (VAR_8 = 0; VAR_8 < SUBFRAME_LEN; VAR_8++) {
VAR_0->pf_gain = (15 * VAR_0->pf_gain + VAR_5 + (1 << 3)) >> 4;
VAR_1[VAR_8] = av_clip_int16((VAR_1[VAR_8] * (VAR_0->pf_gain + (VAR_0->pf_gain >> 4)) +
(1 << 10)) >> 11);
}
}
| [
"static void FUNC_0(G723_1_Context *VAR_0, int16_t * VAR_1, int VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;",
"int VAR_8;",
"VAR_3 = VAR_2;",
"VAR_4 = 0;",
"for (VAR_8 = 0; VAR_8 < SUBFRAME_LEN; VAR_8++) {",
"int64_t temp = VAR_1[VAR_8] >> 2;",
"temp = av_clipl_int32(MUL64(temp, temp) << 1)... | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49... |
9,524 | void OPPROTO op_store_msr_32 (void)
{
ppc_store_msr_32(env, T0);
RETURN();
}
| true | qemu | a97fed52e57385fc749e6f6ef95be7ebdb81ba9b | void OPPROTO op_store_msr_32 (void)
{
ppc_store_msr_32(env, T0);
RETURN();
}
| {
"code": [
" ppc_store_msr_32(env, T0);"
],
"line_no": [
5
]
} | void VAR_0 op_store_msr_32 (void)
{
ppc_store_msr_32(env, T0);
RETURN();
}
| [
"void VAR_0 op_store_msr_32 (void)\n{",
"ppc_store_msr_32(env, T0);",
"RETURN();",
"}"
] | [
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
9,525 | int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr orig_vaddr,
int rw, int mmu_idx)
{
S390CPU *cpu = S390_CPU(cs);
CPUS390XState *env = &cpu->env;
uint64_t asc = cpu_mmu_idx_to_asc(mmu_idx);
target_ulong vaddr, raddr;
int prot;
DPRINTF("%s: address 0x%" VADDR_PRIx " rw %d mmu_idx %d\n",
__func__, orig_vaddr, rw, mmu_idx);
orig_vaddr &= TARGET_PAGE_MASK;
vaddr = orig_vaddr;
/* 31-Bit mode */
if (!(env->psw.mask & PSW_MASK_64)) {
vaddr &= 0x7fffffff;
}
if (mmu_translate(env, vaddr, rw, asc, &raddr, &prot, true)) {
/* Translation ended in exception */
return 1;
}
/* check out of RAM access */
if (raddr > ram_size) {
DPRINTF("%s: raddr %" PRIx64 " > ram_size %" PRIx64 "\n", __func__,
(uint64_t)raddr, (uint64_t)ram_size);
trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO);
return 1;
}
qemu_log_mask(CPU_LOG_MMU, "%s: set tlb %" PRIx64 " -> %" PRIx64 " (%x)\n",
__func__, (uint64_t)vaddr, (uint64_t)raddr, prot);
tlb_set_page(cs, orig_vaddr, raddr, prot,
mmu_idx, TARGET_PAGE_SIZE);
return 0;
}
| true | qemu | 0bd695a960bf05f27ad6d710d2b64059037574ce | int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr orig_vaddr,
int rw, int mmu_idx)
{
S390CPU *cpu = S390_CPU(cs);
CPUS390XState *env = &cpu->env;
uint64_t asc = cpu_mmu_idx_to_asc(mmu_idx);
target_ulong vaddr, raddr;
int prot;
DPRINTF("%s: address 0x%" VADDR_PRIx " rw %d mmu_idx %d\n",
__func__, orig_vaddr, rw, mmu_idx);
orig_vaddr &= TARGET_PAGE_MASK;
vaddr = orig_vaddr;
if (!(env->psw.mask & PSW_MASK_64)) {
vaddr &= 0x7fffffff;
}
if (mmu_translate(env, vaddr, rw, asc, &raddr, &prot, true)) {
return 1;
}
if (raddr > ram_size) {
DPRINTF("%s: raddr %" PRIx64 " > ram_size %" PRIx64 "\n", __func__,
(uint64_t)raddr, (uint64_t)ram_size);
trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO);
return 1;
}
qemu_log_mask(CPU_LOG_MMU, "%s: set tlb %" PRIx64 " -> %" PRIx64 " (%x)\n",
__func__, (uint64_t)vaddr, (uint64_t)raddr, prot);
tlb_set_page(cs, orig_vaddr, raddr, prot,
mmu_idx, TARGET_PAGE_SIZE);
return 0;
}
| {
"code": [
" if (raddr > ram_size) {"
],
"line_no": [
53
]
} | int FUNC_0(CPUState *VAR_0, vaddr VAR_1,
int VAR_2, int VAR_3)
{
S390CPU *cpu = S390_CPU(VAR_0);
CPUS390XState *env = &cpu->env;
uint64_t asc = cpu_mmu_idx_to_asc(VAR_3);
target_ulong vaddr, raddr;
int VAR_4;
DPRINTF("%s: address 0x%" VADDR_PRIx " VAR_2 %d VAR_3 %d\n",
__func__, VAR_1, VAR_2, VAR_3);
VAR_1 &= TARGET_PAGE_MASK;
vaddr = VAR_1;
if (!(env->psw.mask & PSW_MASK_64)) {
vaddr &= 0x7fffffff;
}
if (mmu_translate(env, vaddr, VAR_2, asc, &raddr, &VAR_4, true)) {
return 1;
}
if (raddr > ram_size) {
DPRINTF("%s: raddr %" PRIx64 " > ram_size %" PRIx64 "\n", __func__,
(uint64_t)raddr, (uint64_t)ram_size);
trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO);
return 1;
}
qemu_log_mask(CPU_LOG_MMU, "%s: set tlb %" PRIx64 " -> %" PRIx64 " (%x)\n",
__func__, (uint64_t)vaddr, (uint64_t)raddr, VAR_4);
tlb_set_page(VAR_0, VAR_1, raddr, VAR_4,
VAR_3, TARGET_PAGE_SIZE);
return 0;
}
| [
"int FUNC_0(CPUState *VAR_0, vaddr VAR_1,\nint VAR_2, int VAR_3)\n{",
"S390CPU *cpu = S390_CPU(VAR_0);",
"CPUS390XState *env = &cpu->env;",
"uint64_t asc = cpu_mmu_idx_to_asc(VAR_3);",
"target_ulong vaddr, raddr;",
"int VAR_4;",
"DPRINTF(\"%s: address 0x%\" VADDR_PRIx \" VAR_2 %d VAR_3 %d\\n\",\n__func_... | [
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
],
[
15
],
[
19,
21
],
[
25
],
[
27
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45
],
[
47
],
[
53
],
[
55,
57
],
[
59
],
[... |
9,526 | static int ffm_seek(AVFormatContext *s, int stream_index, int64_t wanted_pts, int flags)
{
FFMContext *ffm = s->priv_data;
int64_t pos_min, pos_max, pos;
int64_t pts_min, pts_max, pts;
double pos1;
av_dlog(s, "wanted_pts=%0.6f\n", wanted_pts / 1000000.0);
/* find the position using linear interpolation (better than
dichotomy in typical cases) */
if (ffm->write_index && ffm->write_index < ffm->file_size) {
if (get_dts(s, FFM_PACKET_SIZE) < wanted_pts) {
pos_min = FFM_PACKET_SIZE;
pos_max = ffm->write_index - FFM_PACKET_SIZE;
} else {
pos_min = ffm->write_index;
pos_max = ffm->file_size - FFM_PACKET_SIZE;
}
} else {
pos_min = FFM_PACKET_SIZE;
pos_max = ffm->file_size - FFM_PACKET_SIZE;
}
while (pos_min <= pos_max) {
pts_min = get_dts(s, pos_min);
pts_max = get_dts(s, pos_max);
if (pts_min > wanted_pts || pts_max < wanted_pts) {
pos = pts_min > wanted_pts ? pos_min : pos_max;
goto found;
}
/* linear interpolation */
pos1 = (double)(pos_max - pos_min) * (double)(wanted_pts - pts_min) /
(double)(pts_max - pts_min);
pos = (((int64_t)pos1) / FFM_PACKET_SIZE) * FFM_PACKET_SIZE;
if (pos <= pos_min)
pos = pos_min;
else if (pos >= pos_max)
pos = pos_max;
pts = get_dts(s, pos);
/* check if we are lucky */
if (pts == wanted_pts) {
goto found;
} else if (pts > wanted_pts) {
pos_max = pos - FFM_PACKET_SIZE;
} else {
pos_min = pos + FFM_PACKET_SIZE;
}
}
pos = (flags & AVSEEK_FLAG_BACKWARD) ? pos_min : pos_max;
found:
if (ffm_seek1(s, pos) < 0)
return -1;
/* reset read state */
ffm->read_state = READ_HEADER;
ffm->packet_ptr = ffm->packet;
ffm->packet_end = ffm->packet;
ffm->first_packet = 1;
return 0;
}
| true | FFmpeg | 7fd65104f489302188a91af710b7520dc9ba7b04 | static int ffm_seek(AVFormatContext *s, int stream_index, int64_t wanted_pts, int flags)
{
FFMContext *ffm = s->priv_data;
int64_t pos_min, pos_max, pos;
int64_t pts_min, pts_max, pts;
double pos1;
av_dlog(s, "wanted_pts=%0.6f\n", wanted_pts / 1000000.0);
if (ffm->write_index && ffm->write_index < ffm->file_size) {
if (get_dts(s, FFM_PACKET_SIZE) < wanted_pts) {
pos_min = FFM_PACKET_SIZE;
pos_max = ffm->write_index - FFM_PACKET_SIZE;
} else {
pos_min = ffm->write_index;
pos_max = ffm->file_size - FFM_PACKET_SIZE;
}
} else {
pos_min = FFM_PACKET_SIZE;
pos_max = ffm->file_size - FFM_PACKET_SIZE;
}
while (pos_min <= pos_max) {
pts_min = get_dts(s, pos_min);
pts_max = get_dts(s, pos_max);
if (pts_min > wanted_pts || pts_max < wanted_pts) {
pos = pts_min > wanted_pts ? pos_min : pos_max;
goto found;
}
pos1 = (double)(pos_max - pos_min) * (double)(wanted_pts - pts_min) /
(double)(pts_max - pts_min);
pos = (((int64_t)pos1) / FFM_PACKET_SIZE) * FFM_PACKET_SIZE;
if (pos <= pos_min)
pos = pos_min;
else if (pos >= pos_max)
pos = pos_max;
pts = get_dts(s, pos);
if (pts == wanted_pts) {
goto found;
} else if (pts > wanted_pts) {
pos_max = pos - FFM_PACKET_SIZE;
} else {
pos_min = pos + FFM_PACKET_SIZE;
}
}
pos = (flags & AVSEEK_FLAG_BACKWARD) ? pos_min : pos_max;
found:
if (ffm_seek1(s, pos) < 0)
return -1;
ffm->read_state = READ_HEADER;
ffm->packet_ptr = ffm->packet;
ffm->packet_end = ffm->packet;
ffm->first_packet = 1;
return 0;
}
| {
"code": [
" if (pts_min > wanted_pts || pts_max < wanted_pts) {"
],
"line_no": [
51
]
} | static int FUNC_0(AVFormatContext *VAR_0, int VAR_1, int64_t VAR_2, int VAR_3)
{
FFMContext *ffm = VAR_0->priv_data;
int64_t pos_min, pos_max, pos;
int64_t pts_min, pts_max, pts;
double VAR_4;
av_dlog(VAR_0, "VAR_2=%0.6f\n", VAR_2 / 1000000.0);
if (ffm->write_index && ffm->write_index < ffm->file_size) {
if (get_dts(VAR_0, FFM_PACKET_SIZE) < VAR_2) {
pos_min = FFM_PACKET_SIZE;
pos_max = ffm->write_index - FFM_PACKET_SIZE;
} else {
pos_min = ffm->write_index;
pos_max = ffm->file_size - FFM_PACKET_SIZE;
}
} else {
pos_min = FFM_PACKET_SIZE;
pos_max = ffm->file_size - FFM_PACKET_SIZE;
}
while (pos_min <= pos_max) {
pts_min = get_dts(VAR_0, pos_min);
pts_max = get_dts(VAR_0, pos_max);
if (pts_min > VAR_2 || pts_max < VAR_2) {
pos = pts_min > VAR_2 ? pos_min : pos_max;
goto found;
}
VAR_4 = (double)(pos_max - pos_min) * (double)(VAR_2 - pts_min) /
(double)(pts_max - pts_min);
pos = (((int64_t)VAR_4) / FFM_PACKET_SIZE) * FFM_PACKET_SIZE;
if (pos <= pos_min)
pos = pos_min;
else if (pos >= pos_max)
pos = pos_max;
pts = get_dts(VAR_0, pos);
if (pts == VAR_2) {
goto found;
} else if (pts > VAR_2) {
pos_max = pos - FFM_PACKET_SIZE;
} else {
pos_min = pos + FFM_PACKET_SIZE;
}
}
pos = (VAR_3 & AVSEEK_FLAG_BACKWARD) ? pos_min : pos_max;
found:
if (ffm_seek1(VAR_0, pos) < 0)
return -1;
ffm->read_state = READ_HEADER;
ffm->packet_ptr = ffm->packet;
ffm->packet_end = ffm->packet;
ffm->first_packet = 1;
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, int VAR_1, int64_t VAR_2, int VAR_3)\n{",
"FFMContext *ffm = VAR_0->priv_data;",
"int64_t pos_min, pos_max, pos;",
"int64_t pts_min, pts_max, pts;",
"double VAR_4;",
"av_dlog(VAR_0, \"VAR_2=%0.6f\\n\", VAR_2 / 1000000.0);",
"if (ffm->write_index && ffm->write_i... | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
... |
9,527 | static void openpic_load_IRQ_queue(QEMUFile* f, IRQ_queue_t *q)
{
unsigned int i;
for (i = 0; i < BF_WIDTH(MAX_IRQ); i++)
qemu_get_be32s(f, &q->queue[i]);
qemu_get_sbe32s(f, &q->next);
qemu_get_sbe32s(f, &q->priority);
}
| true | qemu | af7e9e74c6a62a5bcd911726a9e88d28b61490e0 | static void openpic_load_IRQ_queue(QEMUFile* f, IRQ_queue_t *q)
{
unsigned int i;
for (i = 0; i < BF_WIDTH(MAX_IRQ); i++)
qemu_get_be32s(f, &q->queue[i]);
qemu_get_sbe32s(f, &q->next);
qemu_get_sbe32s(f, &q->priority);
}
| {
"code": [
"static void openpic_load_IRQ_queue(QEMUFile* f, IRQ_queue_t *q)"
],
"line_no": [
1
]
} | static void FUNC_0(QEMUFile* VAR_0, IRQ_queue_t *VAR_1)
{
unsigned int VAR_2;
for (VAR_2 = 0; VAR_2 < BF_WIDTH(MAX_IRQ); VAR_2++)
qemu_get_be32s(VAR_0, &VAR_1->queue[VAR_2]);
qemu_get_sbe32s(VAR_0, &VAR_1->next);
qemu_get_sbe32s(VAR_0, &VAR_1->priority);
}
| [
"static void FUNC_0(QEMUFile* VAR_0, IRQ_queue_t *VAR_1)\n{",
"unsigned int VAR_2;",
"for (VAR_2 = 0; VAR_2 < BF_WIDTH(MAX_IRQ); VAR_2++)",
"qemu_get_be32s(VAR_0, &VAR_1->queue[VAR_2]);",
"qemu_get_sbe32s(VAR_0, &VAR_1->next);",
"qemu_get_sbe32s(VAR_0, &VAR_1->priority);",
"}"
] | [
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
]
] |
9,529 | static void rtas_set_time_of_day(sPAPREnvironment *spapr,
uint32_t token, uint32_t nargs,
target_ulong args,
uint32_t nret, target_ulong rets)
{
struct tm tm;
tm.tm_year = rtas_ld(args, 0) - 1900;
tm.tm_mon = rtas_ld(args, 1) - 1;
tm.tm_mday = rtas_ld(args, 2);
tm.tm_hour = rtas_ld(args, 3);
tm.tm_min = rtas_ld(args, 4);
tm.tm_sec = rtas_ld(args, 5);
/* Just generate a monitor event for the change */
rtc_change_mon_event(&tm);
spapr->rtc_offset = qemu_timedate_diff(&tm);
rtas_st(rets, 0, 0); /* Success */
}
| false | qemu | 210b580b106fa798149e28aa13c66b325a43204e | static void rtas_set_time_of_day(sPAPREnvironment *spapr,
uint32_t token, uint32_t nargs,
target_ulong args,
uint32_t nret, target_ulong rets)
{
struct tm tm;
tm.tm_year = rtas_ld(args, 0) - 1900;
tm.tm_mon = rtas_ld(args, 1) - 1;
tm.tm_mday = rtas_ld(args, 2);
tm.tm_hour = rtas_ld(args, 3);
tm.tm_min = rtas_ld(args, 4);
tm.tm_sec = rtas_ld(args, 5);
rtc_change_mon_event(&tm);
spapr->rtc_offset = qemu_timedate_diff(&tm);
rtas_st(rets, 0, 0);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(sPAPREnvironment *VAR_0,
uint32_t VAR_1, uint32_t VAR_2,
target_ulong VAR_3,
uint32_t VAR_4, target_ulong VAR_5)
{
struct VAR_6 VAR_6;
VAR_6.tm_year = rtas_ld(VAR_3, 0) - 1900;
VAR_6.tm_mon = rtas_ld(VAR_3, 1) - 1;
VAR_6.tm_mday = rtas_ld(VAR_3, 2);
VAR_6.tm_hour = rtas_ld(VAR_3, 3);
VAR_6.tm_min = rtas_ld(VAR_3, 4);
VAR_6.tm_sec = rtas_ld(VAR_3, 5);
rtc_change_mon_event(&VAR_6);
VAR_0->rtc_offset = qemu_timedate_diff(&VAR_6);
rtas_st(VAR_5, 0, 0);
}
| [
"static void FUNC_0(sPAPREnvironment *VAR_0,\nuint32_t VAR_1, uint32_t VAR_2,\ntarget_ulong VAR_3,\nuint32_t VAR_4, target_ulong VAR_5)\n{",
"struct VAR_6 VAR_6;",
"VAR_6.tm_year = rtas_ld(VAR_3, 0) - 1900;",
"VAR_6.tm_mon = rtas_ld(VAR_3, 1) - 1;",
"VAR_6.tm_mday = rtas_ld(VAR_3, 2);",
"VAR_6.tm_hour = r... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
31
],
[
33
],
[
37
],
[
39
]
] |
9,530 | void virtqueue_map(VirtIODevice *vdev, VirtQueueElement *elem)
{
virtqueue_map_iovec(vdev, elem->in_sg, elem->in_addr, &elem->in_num,
MIN(ARRAY_SIZE(elem->in_sg), ARRAY_SIZE(elem->in_addr)),
1);
virtqueue_map_iovec(vdev, elem->out_sg, elem->out_addr, &elem->out_num,
MIN(ARRAY_SIZE(elem->out_sg),
ARRAY_SIZE(elem->out_addr)),
0);
}
| false | qemu | 6bdc21c050a2a7b92cbbd0b2a1f8934e9b5f896f | void virtqueue_map(VirtIODevice *vdev, VirtQueueElement *elem)
{
virtqueue_map_iovec(vdev, elem->in_sg, elem->in_addr, &elem->in_num,
MIN(ARRAY_SIZE(elem->in_sg), ARRAY_SIZE(elem->in_addr)),
1);
virtqueue_map_iovec(vdev, elem->out_sg, elem->out_addr, &elem->out_num,
MIN(ARRAY_SIZE(elem->out_sg),
ARRAY_SIZE(elem->out_addr)),
0);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(VirtIODevice *VAR_0, VirtQueueElement *VAR_1)
{
virtqueue_map_iovec(VAR_0, VAR_1->in_sg, VAR_1->in_addr, &VAR_1->in_num,
MIN(ARRAY_SIZE(VAR_1->in_sg), ARRAY_SIZE(VAR_1->in_addr)),
1);
virtqueue_map_iovec(VAR_0, VAR_1->out_sg, VAR_1->out_addr, &VAR_1->out_num,
MIN(ARRAY_SIZE(VAR_1->out_sg),
ARRAY_SIZE(VAR_1->out_addr)),
0);
}
| [
"void FUNC_0(VirtIODevice *VAR_0, VirtQueueElement *VAR_1)\n{",
"virtqueue_map_iovec(VAR_0, VAR_1->in_sg, VAR_1->in_addr, &VAR_1->in_num,\nMIN(ARRAY_SIZE(VAR_1->in_sg), ARRAY_SIZE(VAR_1->in_addr)),\n1);",
"virtqueue_map_iovec(VAR_0, VAR_1->out_sg, VAR_1->out_addr, &VAR_1->out_num,\nMIN(ARRAY_SIZE(VAR_1->out_sg)... | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7,
9
],
[
11,
13,
15,
17
],
[
19
]
] |
9,531 | static int qed_write_header_sync(BDRVQEDState *s)
{
QEDHeader le;
int ret;
qed_header_cpu_to_le(&s->header, &le);
ret = bdrv_pwrite(s->bs->file, 0, &le, sizeof(le));
if (ret != sizeof(le)) {
return ret;
}
return 0;
}
| false | qemu | b10170aca0616df85482dcc7ddda03437bc07cca | static int qed_write_header_sync(BDRVQEDState *s)
{
QEDHeader le;
int ret;
qed_header_cpu_to_le(&s->header, &le);
ret = bdrv_pwrite(s->bs->file, 0, &le, sizeof(le));
if (ret != sizeof(le)) {
return ret;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BDRVQEDState *VAR_0)
{
QEDHeader le;
int VAR_1;
qed_header_cpu_to_le(&VAR_0->header, &le);
VAR_1 = bdrv_pwrite(VAR_0->bs->file, 0, &le, sizeof(le));
if (VAR_1 != sizeof(le)) {
return VAR_1;
}
return 0;
}
| [
"static int FUNC_0(BDRVQEDState *VAR_0)\n{",
"QEDHeader le;",
"int VAR_1;",
"qed_header_cpu_to_le(&VAR_0->header, &le);",
"VAR_1 = bdrv_pwrite(VAR_0->bs->file, 0, &le, sizeof(le));",
"if (VAR_1 != sizeof(le)) {",
"return VAR_1;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
9,532 | int v9fs_device_realize_common(V9fsState *s, Error **errp)
{
V9fsVirtioState *v = container_of(s, V9fsVirtioState, state);
int i, len;
struct stat stat;
FsDriverEntry *fse;
V9fsPath path;
int rc = 1;
/* initialize pdu allocator */
QLIST_INIT(&s->free_list);
QLIST_INIT(&s->active_list);
for (i = 0; i < (MAX_REQ - 1); i++) {
QLIST_INSERT_HEAD(&s->free_list, &v->pdus[i], next);
v->pdus[i].s = s;
v->pdus[i].idx = i;
}
v9fs_path_init(&path);
fse = get_fsdev_fsentry(s->fsconf.fsdev_id);
if (!fse) {
/* We don't have a fsdev identified by fsdev_id */
error_setg(errp, "9pfs device couldn't find fsdev with the "
"id = %s",
s->fsconf.fsdev_id ? s->fsconf.fsdev_id : "NULL");
goto out;
}
if (!s->fsconf.tag) {
/* we haven't specified a mount_tag */
error_setg(errp, "fsdev with id %s needs mount_tag arguments",
s->fsconf.fsdev_id);
goto out;
}
s->ctx.export_flags = fse->export_flags;
s->ctx.fs_root = g_strdup(fse->path);
s->ctx.exops.get_st_gen = NULL;
len = strlen(s->fsconf.tag);
if (len > MAX_TAG_LEN - 1) {
error_setg(errp, "mount tag '%s' (%d bytes) is longer than "
"maximum (%d bytes)", s->fsconf.tag, len, MAX_TAG_LEN - 1);
goto out;
}
s->tag = g_strdup(s->fsconf.tag);
s->ctx.uid = -1;
s->ops = fse->ops;
s->fid_list = NULL;
qemu_co_rwlock_init(&s->rename_lock);
if (s->ops->init(&s->ctx) < 0) {
error_setg(errp, "9pfs Failed to initialize fs-driver with id:%s"
" and export path:%s", s->fsconf.fsdev_id, s->ctx.fs_root);
goto out;
}
/*
* Check details of export path, We need to use fs driver
* call back to do that. Since we are in the init path, we don't
* use co-routines here.
*/
if (s->ops->name_to_path(&s->ctx, NULL, "/", &path) < 0) {
error_setg(errp,
"error in converting name to path %s", strerror(errno));
goto out;
}
if (s->ops->lstat(&s->ctx, &path, &stat)) {
error_setg(errp, "share path %s does not exist", fse->path);
goto out;
} else if (!S_ISDIR(stat.st_mode)) {
error_setg(errp, "share path %s is not a directory", fse->path);
goto out;
}
v9fs_path_free(&path);
rc = 0;
out:
if (rc) {
if (s->ops->cleanup && s->ctx.private) {
s->ops->cleanup(&s->ctx);
}
g_free(s->tag);
g_free(s->ctx.fs_root);
v9fs_path_free(&path);
}
return rc;
}
| false | qemu | 583f21f8b9982d60c451e812af2d9dfe19d19d3f | int v9fs_device_realize_common(V9fsState *s, Error **errp)
{
V9fsVirtioState *v = container_of(s, V9fsVirtioState, state);
int i, len;
struct stat stat;
FsDriverEntry *fse;
V9fsPath path;
int rc = 1;
QLIST_INIT(&s->free_list);
QLIST_INIT(&s->active_list);
for (i = 0; i < (MAX_REQ - 1); i++) {
QLIST_INSERT_HEAD(&s->free_list, &v->pdus[i], next);
v->pdus[i].s = s;
v->pdus[i].idx = i;
}
v9fs_path_init(&path);
fse = get_fsdev_fsentry(s->fsconf.fsdev_id);
if (!fse) {
error_setg(errp, "9pfs device couldn't find fsdev with the "
"id = %s",
s->fsconf.fsdev_id ? s->fsconf.fsdev_id : "NULL");
goto out;
}
if (!s->fsconf.tag) {
error_setg(errp, "fsdev with id %s needs mount_tag arguments",
s->fsconf.fsdev_id);
goto out;
}
s->ctx.export_flags = fse->export_flags;
s->ctx.fs_root = g_strdup(fse->path);
s->ctx.exops.get_st_gen = NULL;
len = strlen(s->fsconf.tag);
if (len > MAX_TAG_LEN - 1) {
error_setg(errp, "mount tag '%s' (%d bytes) is longer than "
"maximum (%d bytes)", s->fsconf.tag, len, MAX_TAG_LEN - 1);
goto out;
}
s->tag = g_strdup(s->fsconf.tag);
s->ctx.uid = -1;
s->ops = fse->ops;
s->fid_list = NULL;
qemu_co_rwlock_init(&s->rename_lock);
if (s->ops->init(&s->ctx) < 0) {
error_setg(errp, "9pfs Failed to initialize fs-driver with id:%s"
" and export path:%s", s->fsconf.fsdev_id, s->ctx.fs_root);
goto out;
}
if (s->ops->name_to_path(&s->ctx, NULL, "/", &path) < 0) {
error_setg(errp,
"error in converting name to path %s", strerror(errno));
goto out;
}
if (s->ops->lstat(&s->ctx, &path, &stat)) {
error_setg(errp, "share path %s does not exist", fse->path);
goto out;
} else if (!S_ISDIR(stat.st_mode)) {
error_setg(errp, "share path %s is not a directory", fse->path);
goto out;
}
v9fs_path_free(&path);
rc = 0;
out:
if (rc) {
if (s->ops->cleanup && s->ctx.private) {
s->ops->cleanup(&s->ctx);
}
g_free(s->tag);
g_free(s->ctx.fs_root);
v9fs_path_free(&path);
}
return rc;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(V9fsState *VAR_0, Error **VAR_1)
{
V9fsVirtioState *v = container_of(VAR_0, V9fsVirtioState, state);
int VAR_2, VAR_3;
struct VAR_4 VAR_4;
FsDriverEntry *fse;
V9fsPath path;
int VAR_5 = 1;
QLIST_INIT(&VAR_0->free_list);
QLIST_INIT(&VAR_0->active_list);
for (VAR_2 = 0; VAR_2 < (MAX_REQ - 1); VAR_2++) {
QLIST_INSERT_HEAD(&VAR_0->free_list, &v->pdus[VAR_2], next);
v->pdus[VAR_2].VAR_0 = VAR_0;
v->pdus[VAR_2].idx = VAR_2;
}
v9fs_path_init(&path);
fse = get_fsdev_fsentry(VAR_0->fsconf.fsdev_id);
if (!fse) {
error_setg(VAR_1, "9pfs device couldn't find fsdev with the "
"id = %VAR_0",
VAR_0->fsconf.fsdev_id ? VAR_0->fsconf.fsdev_id : "NULL");
goto out;
}
if (!VAR_0->fsconf.tag) {
error_setg(VAR_1, "fsdev with id %VAR_0 needs mount_tag arguments",
VAR_0->fsconf.fsdev_id);
goto out;
}
VAR_0->ctx.export_flags = fse->export_flags;
VAR_0->ctx.fs_root = g_strdup(fse->path);
VAR_0->ctx.exops.get_st_gen = NULL;
VAR_3 = strlen(VAR_0->fsconf.tag);
if (VAR_3 > MAX_TAG_LEN - 1) {
error_setg(VAR_1, "mount tag '%VAR_0' (%d bytes) is longer than "
"maximum (%d bytes)", VAR_0->fsconf.tag, VAR_3, MAX_TAG_LEN - 1);
goto out;
}
VAR_0->tag = g_strdup(VAR_0->fsconf.tag);
VAR_0->ctx.uid = -1;
VAR_0->ops = fse->ops;
VAR_0->fid_list = NULL;
qemu_co_rwlock_init(&VAR_0->rename_lock);
if (VAR_0->ops->init(&VAR_0->ctx) < 0) {
error_setg(VAR_1, "9pfs Failed to initialize fs-driver with id:%VAR_0"
" and export path:%VAR_0", VAR_0->fsconf.fsdev_id, VAR_0->ctx.fs_root);
goto out;
}
if (VAR_0->ops->name_to_path(&VAR_0->ctx, NULL, "/", &path) < 0) {
error_setg(VAR_1,
"error in converting name to path %VAR_0", strerror(errno));
goto out;
}
if (VAR_0->ops->lstat(&VAR_0->ctx, &path, &VAR_4)) {
error_setg(VAR_1, "share path %VAR_0 does not exist", fse->path);
goto out;
} else if (!S_ISDIR(VAR_4.st_mode)) {
error_setg(VAR_1, "share path %VAR_0 is not a directory", fse->path);
goto out;
}
v9fs_path_free(&path);
VAR_5 = 0;
out:
if (VAR_5) {
if (VAR_0->ops->cleanup && VAR_0->ctx.private) {
VAR_0->ops->cleanup(&VAR_0->ctx);
}
g_free(VAR_0->tag);
g_free(VAR_0->ctx.fs_root);
v9fs_path_free(&path);
}
return VAR_5;
}
| [
"int FUNC_0(V9fsState *VAR_0, Error **VAR_1)\n{",
"V9fsVirtioState *v = container_of(VAR_0, V9fsVirtioState, state);",
"int VAR_2, VAR_3;",
"struct VAR_4 VAR_4;",
"FsDriverEntry *fse;",
"V9fsPath path;",
"int VAR_5 = 1;",
"QLIST_INIT(&VAR_0->free_list);",
"QLIST_INIT(&VAR_0->active_list);",
"for (... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
41
],
[
45
],
[
49,
51,
53
],
[
55
... |
9,534 | static void pc_compat_1_6(MachineState *machine)
{
pc_compat_1_7(machine);
rom_file_has_mr = false;
has_acpi_build = false;
}
| false | qemu | 7102fa7073b2cefb33ab4012a11f15fbf297a74b | static void pc_compat_1_6(MachineState *machine)
{
pc_compat_1_7(machine);
rom_file_has_mr = false;
has_acpi_build = false;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(MachineState *VAR_0)
{
pc_compat_1_7(VAR_0);
rom_file_has_mr = false;
has_acpi_build = false;
}
| [
"static void FUNC_0(MachineState *VAR_0)\n{",
"pc_compat_1_7(VAR_0);",
"rom_file_has_mr = false;",
"has_acpi_build = false;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
9,535 | static void __attribute__((destructor)) coroutine_cleanup(void)
{
Coroutine *co;
Coroutine *tmp;
QSLIST_FOREACH_SAFE(co, &pool, pool_next, tmp) {
QSLIST_REMOVE_HEAD(&pool, pool_next);
qemu_coroutine_delete(co);
}
}
| false | qemu | b84c4586234b26ccc875595713f6f4491e5b3385 | static void __attribute__((destructor)) coroutine_cleanup(void)
{
Coroutine *co;
Coroutine *tmp;
QSLIST_FOREACH_SAFE(co, &pool, pool_next, tmp) {
QSLIST_REMOVE_HEAD(&pool, pool_next);
qemu_coroutine_delete(co);
}
}
| {
"code": [],
"line_no": []
} | static void __attribute__((destructor)) FUNC_0(void)
{
Coroutine *co;
Coroutine *tmp;
QSLIST_FOREACH_SAFE(co, &pool, pool_next, tmp) {
QSLIST_REMOVE_HEAD(&pool, pool_next);
qemu_coroutine_delete(co);
}
}
| [
"static void __attribute__((destructor)) FUNC_0(void)\n{",
"Coroutine *co;",
"Coroutine *tmp;",
"QSLIST_FOREACH_SAFE(co, &pool, pool_next, tmp) {",
"QSLIST_REMOVE_HEAD(&pool, pool_next);",
"qemu_coroutine_delete(co);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
9,536 | int qemu_acl_party_is_allowed(qemu_acl *acl,
const char *party)
{
qemu_acl_entry *entry;
TAILQ_FOREACH(entry, &acl->entries, next) {
#ifdef CONFIG_FNMATCH
if (fnmatch(entry->match, party, 0) == 0)
return entry->deny ? 0 : 1;
#else
/* No fnmatch, so fallback to exact string matching
* instead of allowing wildcards */
if (strcmp(entry->match, party) == 0)
return entry->deny ? 0 : 1;
#endif
}
return acl->defaultDeny ? 0 : 1;
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | int qemu_acl_party_is_allowed(qemu_acl *acl,
const char *party)
{
qemu_acl_entry *entry;
TAILQ_FOREACH(entry, &acl->entries, next) {
#ifdef CONFIG_FNMATCH
if (fnmatch(entry->match, party, 0) == 0)
return entry->deny ? 0 : 1;
#else
if (strcmp(entry->match, party) == 0)
return entry->deny ? 0 : 1;
#endif
}
return acl->defaultDeny ? 0 : 1;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(qemu_acl *VAR_0,
const char *VAR_1)
{
qemu_acl_entry *entry;
TAILQ_FOREACH(entry, &VAR_0->entries, next) {
#ifdef CONFIG_FNMATCH
if (fnmatch(entry->match, VAR_1, 0) == 0)
return entry->deny ? 0 : 1;
#else
if (strcmp(entry->match, VAR_1) == 0)
return entry->deny ? 0 : 1;
#endif
}
return VAR_0->defaultDeny ? 0 : 1;
}
| [
"int FUNC_0(qemu_acl *VAR_0,\nconst char *VAR_1)\n{",
"qemu_acl_entry *entry;",
"TAILQ_FOREACH(entry, &VAR_0->entries, next) {",
"#ifdef CONFIG_FNMATCH\nif (fnmatch(entry->match, VAR_1, 0) == 0)\nreturn entry->deny ? 0 : 1;",
"#else\nif (strcmp(entry->match, VAR_1) == 0)\nreturn entry->deny ? 0 : 1;",
"#e... | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13,
15,
17
],
[
19,
25,
27
],
[
29,
31
],
[
35
],
[
37
]
] |
9,537 | static void tcg_out_ld_abs(TCGContext *s, TCGType type, TCGReg dest, void *abs)
{
intptr_t addr = (intptr_t)abs;
if ((facilities & FACILITY_GEN_INST_EXT) && !(addr & 1)) {
ptrdiff_t disp = tcg_pcrel_diff(s, abs) >> 1;
if (disp == (int32_t)disp) {
if (type == TCG_TYPE_I32) {
tcg_out_insn(s, RIL, LRL, dest, disp);
} else {
tcg_out_insn(s, RIL, LGRL, dest, disp);
}
return;
}
}
tcg_out_movi(s, TCG_TYPE_PTR, dest, addr & ~0xffff);
tcg_out_ld(s, type, dest, dest, addr & 0xffff);
}
| false | qemu | b2c98d9d392c87c9b9e975d30f79924719d9cbbe | static void tcg_out_ld_abs(TCGContext *s, TCGType type, TCGReg dest, void *abs)
{
intptr_t addr = (intptr_t)abs;
if ((facilities & FACILITY_GEN_INST_EXT) && !(addr & 1)) {
ptrdiff_t disp = tcg_pcrel_diff(s, abs) >> 1;
if (disp == (int32_t)disp) {
if (type == TCG_TYPE_I32) {
tcg_out_insn(s, RIL, LRL, dest, disp);
} else {
tcg_out_insn(s, RIL, LGRL, dest, disp);
}
return;
}
}
tcg_out_movi(s, TCG_TYPE_PTR, dest, addr & ~0xffff);
tcg_out_ld(s, type, dest, dest, addr & 0xffff);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TCGContext *VAR_0, TCGType VAR_1, TCGReg VAR_2, void *VAR_3)
{
intptr_t addr = (intptr_t)VAR_3;
if ((facilities & FACILITY_GEN_INST_EXT) && !(addr & 1)) {
ptrdiff_t disp = tcg_pcrel_diff(VAR_0, VAR_3) >> 1;
if (disp == (int32_t)disp) {
if (VAR_1 == TCG_TYPE_I32) {
tcg_out_insn(VAR_0, RIL, LRL, VAR_2, disp);
} else {
tcg_out_insn(VAR_0, RIL, LGRL, VAR_2, disp);
}
return;
}
}
tcg_out_movi(VAR_0, TCG_TYPE_PTR, VAR_2, addr & ~0xffff);
tcg_out_ld(VAR_0, VAR_1, VAR_2, VAR_2, addr & 0xffff);
}
| [
"static void FUNC_0(TCGContext *VAR_0, TCGType VAR_1, TCGReg VAR_2, void *VAR_3)\n{",
"intptr_t addr = (intptr_t)VAR_3;",
"if ((facilities & FACILITY_GEN_INST_EXT) && !(addr & 1)) {",
"ptrdiff_t disp = tcg_pcrel_diff(VAR_0, VAR_3) >> 1;",
"if (disp == (int32_t)disp) {",
"if (VAR_1 == TCG_TYPE_I32) {",
"... | [
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
]
] |
9,539 | static void v9fs_wstat(void *opaque)
{
int32_t fid;
int err = 0;
int16_t unused;
V9fsStat v9stat;
size_t offset = 7;
struct stat stbuf;
V9fsFidState *fidp;
V9fsPDU *pdu = opaque;
V9fsState *s = pdu->s;
pdu_unmarshal(pdu, offset, "dwS", &fid, &unused, &v9stat);
trace_v9fs_wstat(pdu->tag, pdu->id, fid,
v9stat.mode, v9stat.atime, v9stat.mtime);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
err = -EINVAL;
goto out_nofid;
}
/* do we need to sync the file? */
if (donttouch_stat(&v9stat)) {
err = v9fs_co_fsync(pdu, fidp, 0);
goto out;
}
if (v9stat.mode != -1) {
uint32_t v9_mode;
err = v9fs_co_lstat(pdu, &fidp->path, &stbuf);
if (err < 0) {
goto out;
}
v9_mode = stat_to_v9mode(&stbuf);
if ((v9stat.mode & P9_STAT_MODE_TYPE_BITS) !=
(v9_mode & P9_STAT_MODE_TYPE_BITS)) {
/* Attempting to change the type */
err = -EIO;
goto out;
}
err = v9fs_co_chmod(pdu, &fidp->path,
v9mode_to_mode(v9stat.mode,
&v9stat.extension));
if (err < 0) {
goto out;
}
}
if (v9stat.mtime != -1 || v9stat.atime != -1) {
struct timespec times[2];
if (v9stat.atime != -1) {
times[0].tv_sec = v9stat.atime;
times[0].tv_nsec = 0;
} else {
times[0].tv_nsec = UTIME_OMIT;
}
if (v9stat.mtime != -1) {
times[1].tv_sec = v9stat.mtime;
times[1].tv_nsec = 0;
} else {
times[1].tv_nsec = UTIME_OMIT;
}
err = v9fs_co_utimensat(pdu, &fidp->path, times);
if (err < 0) {
goto out;
}
}
if (v9stat.n_gid != -1 || v9stat.n_uid != -1) {
err = v9fs_co_chown(pdu, &fidp->path, v9stat.n_uid, v9stat.n_gid);
if (err < 0) {
goto out;
}
}
if (v9stat.name.size != 0) {
err = v9fs_complete_rename(pdu, fidp, -1, &v9stat.name);
if (err < 0) {
goto out;
}
}
if (v9stat.length != -1) {
err = v9fs_co_truncate(pdu, &fidp->path, v9stat.length);
if (err < 0) {
goto out;
}
}
err = offset;
out:
put_fid(pdu, fidp);
out_nofid:
v9fs_stat_free(&v9stat);
complete_pdu(s, pdu, err);
}
| false | qemu | ddca7f86ac022289840e0200fd4050b2b58e9176 | static void v9fs_wstat(void *opaque)
{
int32_t fid;
int err = 0;
int16_t unused;
V9fsStat v9stat;
size_t offset = 7;
struct stat stbuf;
V9fsFidState *fidp;
V9fsPDU *pdu = opaque;
V9fsState *s = pdu->s;
pdu_unmarshal(pdu, offset, "dwS", &fid, &unused, &v9stat);
trace_v9fs_wstat(pdu->tag, pdu->id, fid,
v9stat.mode, v9stat.atime, v9stat.mtime);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
err = -EINVAL;
goto out_nofid;
}
if (donttouch_stat(&v9stat)) {
err = v9fs_co_fsync(pdu, fidp, 0);
goto out;
}
if (v9stat.mode != -1) {
uint32_t v9_mode;
err = v9fs_co_lstat(pdu, &fidp->path, &stbuf);
if (err < 0) {
goto out;
}
v9_mode = stat_to_v9mode(&stbuf);
if ((v9stat.mode & P9_STAT_MODE_TYPE_BITS) !=
(v9_mode & P9_STAT_MODE_TYPE_BITS)) {
err = -EIO;
goto out;
}
err = v9fs_co_chmod(pdu, &fidp->path,
v9mode_to_mode(v9stat.mode,
&v9stat.extension));
if (err < 0) {
goto out;
}
}
if (v9stat.mtime != -1 || v9stat.atime != -1) {
struct timespec times[2];
if (v9stat.atime != -1) {
times[0].tv_sec = v9stat.atime;
times[0].tv_nsec = 0;
} else {
times[0].tv_nsec = UTIME_OMIT;
}
if (v9stat.mtime != -1) {
times[1].tv_sec = v9stat.mtime;
times[1].tv_nsec = 0;
} else {
times[1].tv_nsec = UTIME_OMIT;
}
err = v9fs_co_utimensat(pdu, &fidp->path, times);
if (err < 0) {
goto out;
}
}
if (v9stat.n_gid != -1 || v9stat.n_uid != -1) {
err = v9fs_co_chown(pdu, &fidp->path, v9stat.n_uid, v9stat.n_gid);
if (err < 0) {
goto out;
}
}
if (v9stat.name.size != 0) {
err = v9fs_complete_rename(pdu, fidp, -1, &v9stat.name);
if (err < 0) {
goto out;
}
}
if (v9stat.length != -1) {
err = v9fs_co_truncate(pdu, &fidp->path, v9stat.length);
if (err < 0) {
goto out;
}
}
err = offset;
out:
put_fid(pdu, fidp);
out_nofid:
v9fs_stat_free(&v9stat);
complete_pdu(s, pdu, err);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
int32_t fid;
int VAR_1 = 0;
int16_t unused;
V9fsStat v9stat;
size_t offset = 7;
struct stat VAR_2;
V9fsFidState *fidp;
V9fsPDU *pdu = VAR_0;
V9fsState *s = pdu->s;
pdu_unmarshal(pdu, offset, "dwS", &fid, &unused, &v9stat);
trace_v9fs_wstat(pdu->tag, pdu->id, fid,
v9stat.mode, v9stat.atime, v9stat.mtime);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
VAR_1 = -EINVAL;
goto out_nofid;
}
if (donttouch_stat(&v9stat)) {
VAR_1 = v9fs_co_fsync(pdu, fidp, 0);
goto out;
}
if (v9stat.mode != -1) {
uint32_t v9_mode;
VAR_1 = v9fs_co_lstat(pdu, &fidp->path, &VAR_2);
if (VAR_1 < 0) {
goto out;
}
v9_mode = stat_to_v9mode(&VAR_2);
if ((v9stat.mode & P9_STAT_MODE_TYPE_BITS) !=
(v9_mode & P9_STAT_MODE_TYPE_BITS)) {
VAR_1 = -EIO;
goto out;
}
VAR_1 = v9fs_co_chmod(pdu, &fidp->path,
v9mode_to_mode(v9stat.mode,
&v9stat.extension));
if (VAR_1 < 0) {
goto out;
}
}
if (v9stat.mtime != -1 || v9stat.atime != -1) {
struct timespec VAR_3[2];
if (v9stat.atime != -1) {
VAR_3[0].tv_sec = v9stat.atime;
VAR_3[0].tv_nsec = 0;
} else {
VAR_3[0].tv_nsec = UTIME_OMIT;
}
if (v9stat.mtime != -1) {
VAR_3[1].tv_sec = v9stat.mtime;
VAR_3[1].tv_nsec = 0;
} else {
VAR_3[1].tv_nsec = UTIME_OMIT;
}
VAR_1 = v9fs_co_utimensat(pdu, &fidp->path, VAR_3);
if (VAR_1 < 0) {
goto out;
}
}
if (v9stat.n_gid != -1 || v9stat.n_uid != -1) {
VAR_1 = v9fs_co_chown(pdu, &fidp->path, v9stat.n_uid, v9stat.n_gid);
if (VAR_1 < 0) {
goto out;
}
}
if (v9stat.name.size != 0) {
VAR_1 = v9fs_complete_rename(pdu, fidp, -1, &v9stat.name);
if (VAR_1 < 0) {
goto out;
}
}
if (v9stat.length != -1) {
VAR_1 = v9fs_co_truncate(pdu, &fidp->path, v9stat.length);
if (VAR_1 < 0) {
goto out;
}
}
VAR_1 = offset;
out:
put_fid(pdu, fidp);
out_nofid:
v9fs_stat_free(&v9stat);
complete_pdu(s, pdu, VAR_1);
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"int32_t fid;",
"int VAR_1 = 0;",
"int16_t unused;",
"V9fsStat v9stat;",
"size_t offset = 7;",
"struct stat VAR_2;",
"V9fsFidState *fidp;",
"V9fsPDU *pdu = VAR_0;",
"V9fsState *s = pdu->s;",
"pdu_unmarshal(pdu, offset, \"dwS\", &fid, &unused, &v9stat);",
"... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27,
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[... |
9,541 | static void drive_backup_prepare(BlkTransactionState *common, Error **errp)
{
DriveBackupState *state = DO_UPCAST(DriveBackupState, common, common);
BlockBackend *blk;
DriveBackup *backup;
Error *local_err = NULL;
assert(common->action->kind == TRANSACTION_ACTION_KIND_DRIVE_BACKUP);
backup = common->action->drive_backup;
blk = blk_by_name(backup->device);
if (!blk) {
error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", backup->device);
return;
}
/* AioContext is released in .clean() */
state->aio_context = blk_get_aio_context(blk);
aio_context_acquire(state->aio_context);
qmp_drive_backup(backup->device, backup->target,
backup->has_format, backup->format,
backup->sync,
backup->has_mode, backup->mode,
backup->has_speed, backup->speed,
backup->has_bitmap, backup->bitmap,
backup->has_on_source_error, backup->on_source_error,
backup->has_on_target_error, backup->on_target_error,
&local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
state->bs = blk_bs(blk);
state->job = state->bs->job;
}
| false | qemu | 1fdd4b7be3655d39c3594bc215eb1df5ce225c7d | static void drive_backup_prepare(BlkTransactionState *common, Error **errp)
{
DriveBackupState *state = DO_UPCAST(DriveBackupState, common, common);
BlockBackend *blk;
DriveBackup *backup;
Error *local_err = NULL;
assert(common->action->kind == TRANSACTION_ACTION_KIND_DRIVE_BACKUP);
backup = common->action->drive_backup;
blk = blk_by_name(backup->device);
if (!blk) {
error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", backup->device);
return;
}
state->aio_context = blk_get_aio_context(blk);
aio_context_acquire(state->aio_context);
qmp_drive_backup(backup->device, backup->target,
backup->has_format, backup->format,
backup->sync,
backup->has_mode, backup->mode,
backup->has_speed, backup->speed,
backup->has_bitmap, backup->bitmap,
backup->has_on_source_error, backup->on_source_error,
backup->has_on_target_error, backup->on_target_error,
&local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
state->bs = blk_bs(blk);
state->job = state->bs->job;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BlkTransactionState *VAR_0, Error **VAR_1)
{
DriveBackupState *state = DO_UPCAST(DriveBackupState, VAR_0, VAR_0);
BlockBackend *blk;
DriveBackup *backup;
Error *local_err = NULL;
assert(VAR_0->action->kind == TRANSACTION_ACTION_KIND_DRIVE_BACKUP);
backup = VAR_0->action->drive_backup;
blk = blk_by_name(backup->device);
if (!blk) {
error_set(VAR_1, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", backup->device);
return;
}
state->aio_context = blk_get_aio_context(blk);
aio_context_acquire(state->aio_context);
qmp_drive_backup(backup->device, backup->target,
backup->has_format, backup->format,
backup->sync,
backup->has_mode, backup->mode,
backup->has_speed, backup->speed,
backup->has_bitmap, backup->bitmap,
backup->has_on_source_error, backup->on_source_error,
backup->has_on_target_error, backup->on_target_error,
&local_err);
if (local_err) {
error_propagate(VAR_1, local_err);
return;
}
state->bs = blk_bs(blk);
state->job = state->bs->job;
}
| [
"static void FUNC_0(BlkTransactionState *VAR_0, Error **VAR_1)\n{",
"DriveBackupState *state = DO_UPCAST(DriveBackupState, VAR_0, VAR_0);",
"BlockBackend *blk;",
"DriveBackup *backup;",
"Error *local_err = NULL;",
"assert(VAR_0->action->kind == TRANSACTION_ACTION_KIND_DRIVE_BACKUP);",
"backup = VAR_0->a... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
37
],
[
39
],
[
43,
45,
47,
49,
51,
53,
55,
57,
59
],
[... |
9,542 | void helper_ltr_T0(void)
{
int selector;
SegmentCache *dt;
uint32_t e1, e2;
int index, type, entry_limit;
target_ulong ptr;
selector = T0 & 0xffff;
if ((selector & 0xfffc) == 0) {
/* NULL selector case: invalid TR */
env->tr.base = 0;
env->tr.limit = 0;
env->tr.flags = 0;
} else {
if (selector & 0x4)
raise_exception_err(EXCP0D_GPF, selector & 0xfffc);
dt = &env->gdt;
index = selector & ~7;
#ifdef TARGET_X86_64
if (env->hflags & HF_LMA_MASK)
entry_limit = 15;
else
#endif
entry_limit = 7;
if ((index + entry_limit) > dt->limit)
raise_exception_err(EXCP0D_GPF, selector & 0xfffc);
ptr = dt->base + index;
e1 = ldl_kernel(ptr);
e2 = ldl_kernel(ptr + 4);
type = (e2 >> DESC_TYPE_SHIFT) & 0xf;
if ((e2 & DESC_S_MASK) ||
(type != 1 && type != 9))
raise_exception_err(EXCP0D_GPF, selector & 0xfffc);
if (!(e2 & DESC_P_MASK))
raise_exception_err(EXCP0B_NOSEG, selector & 0xfffc);
#ifdef TARGET_X86_64
if (env->hflags & HF_LMA_MASK) {
uint32_t e3;
e3 = ldl_kernel(ptr + 8);
load_seg_cache_raw_dt(&env->tr, e1, e2);
env->tr.base |= (target_ulong)e3 << 32;
} else
#endif
{
load_seg_cache_raw_dt(&env->tr, e1, e2);
}
e2 |= DESC_TSS_BUSY_MASK;
stl_kernel(ptr + 4, e2);
}
env->tr.selector = selector;
}
| false | qemu | b0ee3ff06e54a30b1540c08507b873a00192aa0e | void helper_ltr_T0(void)
{
int selector;
SegmentCache *dt;
uint32_t e1, e2;
int index, type, entry_limit;
target_ulong ptr;
selector = T0 & 0xffff;
if ((selector & 0xfffc) == 0) {
env->tr.base = 0;
env->tr.limit = 0;
env->tr.flags = 0;
} else {
if (selector & 0x4)
raise_exception_err(EXCP0D_GPF, selector & 0xfffc);
dt = &env->gdt;
index = selector & ~7;
#ifdef TARGET_X86_64
if (env->hflags & HF_LMA_MASK)
entry_limit = 15;
else
#endif
entry_limit = 7;
if ((index + entry_limit) > dt->limit)
raise_exception_err(EXCP0D_GPF, selector & 0xfffc);
ptr = dt->base + index;
e1 = ldl_kernel(ptr);
e2 = ldl_kernel(ptr + 4);
type = (e2 >> DESC_TYPE_SHIFT) & 0xf;
if ((e2 & DESC_S_MASK) ||
(type != 1 && type != 9))
raise_exception_err(EXCP0D_GPF, selector & 0xfffc);
if (!(e2 & DESC_P_MASK))
raise_exception_err(EXCP0B_NOSEG, selector & 0xfffc);
#ifdef TARGET_X86_64
if (env->hflags & HF_LMA_MASK) {
uint32_t e3;
e3 = ldl_kernel(ptr + 8);
load_seg_cache_raw_dt(&env->tr, e1, e2);
env->tr.base |= (target_ulong)e3 << 32;
} else
#endif
{
load_seg_cache_raw_dt(&env->tr, e1, e2);
}
e2 |= DESC_TSS_BUSY_MASK;
stl_kernel(ptr + 4, e2);
}
env->tr.selector = selector;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(void)
{
int VAR_0;
SegmentCache *dt;
uint32_t e1, e2;
int VAR_1, VAR_2, VAR_3;
target_ulong ptr;
VAR_0 = T0 & 0xffff;
if ((VAR_0 & 0xfffc) == 0) {
env->tr.base = 0;
env->tr.limit = 0;
env->tr.flags = 0;
} else {
if (VAR_0 & 0x4)
raise_exception_err(EXCP0D_GPF, VAR_0 & 0xfffc);
dt = &env->gdt;
VAR_1 = VAR_0 & ~7;
#ifdef TARGET_X86_64
if (env->hflags & HF_LMA_MASK)
VAR_3 = 15;
else
#endif
VAR_3 = 7;
if ((VAR_1 + VAR_3) > dt->limit)
raise_exception_err(EXCP0D_GPF, VAR_0 & 0xfffc);
ptr = dt->base + VAR_1;
e1 = ldl_kernel(ptr);
e2 = ldl_kernel(ptr + 4);
VAR_2 = (e2 >> DESC_TYPE_SHIFT) & 0xf;
if ((e2 & DESC_S_MASK) ||
(VAR_2 != 1 && VAR_2 != 9))
raise_exception_err(EXCP0D_GPF, VAR_0 & 0xfffc);
if (!(e2 & DESC_P_MASK))
raise_exception_err(EXCP0B_NOSEG, VAR_0 & 0xfffc);
#ifdef TARGET_X86_64
if (env->hflags & HF_LMA_MASK) {
uint32_t e3;
e3 = ldl_kernel(ptr + 8);
load_seg_cache_raw_dt(&env->tr, e1, e2);
env->tr.base |= (target_ulong)e3 << 32;
} else
#endif
{
load_seg_cache_raw_dt(&env->tr, e1, e2);
}
e2 |= DESC_TSS_BUSY_MASK;
stl_kernel(ptr + 4, e2);
}
env->tr.VAR_0 = VAR_0;
}
| [
"void FUNC_0(void)\n{",
"int VAR_0;",
"SegmentCache *dt;",
"uint32_t e1, e2;",
"int VAR_1, VAR_2, VAR_3;",
"target_ulong ptr;",
"VAR_0 = T0 & 0xffff;",
"if ((VAR_0 & 0xfffc) == 0) {",
"env->tr.base = 0;",
"env->tr.limit = 0;",
"env->tr.flags = 0;",
"} else {",
"if (VAR_0 & 0x4)\nraise_except... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39,
41,
43
],
[
45,
47,
49
],
[... |
9,543 | static void uhci_async_cancel_device(UHCIState *s, USBDevice *dev)
{
UHCIQueue *queue;
UHCIAsync *curr, *n;
QTAILQ_FOREACH(queue, &s->queues, next) {
QTAILQ_FOREACH_SAFE(curr, &queue->asyncs, next, n) {
if (!usb_packet_is_inflight(&curr->packet) ||
curr->packet.ep->dev != dev) {
continue;
}
uhci_async_cancel(curr);
}
}
}
| false | qemu | 5ad23e873c858292dc58b9296261365312b8f683 | static void uhci_async_cancel_device(UHCIState *s, USBDevice *dev)
{
UHCIQueue *queue;
UHCIAsync *curr, *n;
QTAILQ_FOREACH(queue, &s->queues, next) {
QTAILQ_FOREACH_SAFE(curr, &queue->asyncs, next, n) {
if (!usb_packet_is_inflight(&curr->packet) ||
curr->packet.ep->dev != dev) {
continue;
}
uhci_async_cancel(curr);
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(UHCIState *VAR_0, USBDevice *VAR_1)
{
UHCIQueue *queue;
UHCIAsync *curr, *n;
QTAILQ_FOREACH(queue, &VAR_0->queues, next) {
QTAILQ_FOREACH_SAFE(curr, &queue->asyncs, next, n) {
if (!usb_packet_is_inflight(&curr->packet) ||
curr->packet.ep->VAR_1 != VAR_1) {
continue;
}
uhci_async_cancel(curr);
}
}
}
| [
"static void FUNC_0(UHCIState *VAR_0, USBDevice *VAR_1)\n{",
"UHCIQueue *queue;",
"UHCIAsync *curr, *n;",
"QTAILQ_FOREACH(queue, &VAR_0->queues, next) {",
"QTAILQ_FOREACH_SAFE(curr, &queue->asyncs, next, n) {",
"if (!usb_packet_is_inflight(&curr->packet) ||\ncurr->packet.ep->VAR_1 != VAR_1) {",
"continu... | [
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
]
] |
9,544 | static int dnxhd_decode_macroblock(DNXHDContext *ctx, AVFrame *frame,
int x, int y)
{
int shift1 = ctx->bit_depth == 10;
int dct_linesize_luma = frame->linesize[0];
int dct_linesize_chroma = frame->linesize[1];
uint8_t *dest_y, *dest_u, *dest_v;
int dct_y_offset, dct_x_offset;
int qscale, i;
qscale = get_bits(&ctx->gb, 11);
skip_bits1(&ctx->gb);
if (qscale != ctx->last_qscale) {
for (i = 0; i < 64; i++) {
ctx->luma_scale[i] = qscale * ctx->cid_table->luma_weight[i];
ctx->chroma_scale[i] = qscale * ctx->cid_table->chroma_weight[i];
}
ctx->last_qscale = qscale;
}
for (i = 0; i < 8; i++) {
ctx->bdsp.clear_block(ctx->blocks[i]);
ctx->decode_dct_block(ctx, ctx->blocks[i], i, qscale);
}
if (ctx->is_444) {
for (; i < 12; i++) {
ctx->bdsp.clear_block(ctx->blocks[i]);
ctx->decode_dct_block(ctx, ctx->blocks[i], i, qscale);
}
}
if (frame->interlaced_frame) {
dct_linesize_luma <<= 1;
dct_linesize_chroma <<= 1;
}
dest_y = frame->data[0] + ((y * dct_linesize_luma) << 4) + (x << (4 + shift1));
dest_u = frame->data[1] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1 + ctx->is_444));
dest_v = frame->data[2] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1 + ctx->is_444));
if (ctx->cur_field) {
dest_y += frame->linesize[0];
dest_u += frame->linesize[1];
dest_v += frame->linesize[2];
}
dct_y_offset = dct_linesize_luma << 3;
dct_x_offset = 8 << shift1;
if (!ctx->is_444) {
ctx->idsp.idct_put(dest_y, dct_linesize_luma, ctx->blocks[0]);
ctx->idsp.idct_put(dest_y + dct_x_offset, dct_linesize_luma, ctx->blocks[1]);
ctx->idsp.idct_put(dest_y + dct_y_offset, dct_linesize_luma, ctx->blocks[4]);
ctx->idsp.idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, ctx->blocks[5]);
if (!(ctx->avctx->flags & CODEC_FLAG_GRAY)) {
dct_y_offset = dct_linesize_chroma << 3;
ctx->idsp.idct_put(dest_u, dct_linesize_chroma, ctx->blocks[2]);
ctx->idsp.idct_put(dest_v, dct_linesize_chroma, ctx->blocks[3]);
ctx->idsp.idct_put(dest_u + dct_y_offset, dct_linesize_chroma, ctx->blocks[6]);
ctx->idsp.idct_put(dest_v + dct_y_offset, dct_linesize_chroma, ctx->blocks[7]);
}
} else {
ctx->idsp.idct_put(dest_y, dct_linesize_luma, ctx->blocks[0]);
ctx->idsp.idct_put(dest_y + dct_x_offset, dct_linesize_luma, ctx->blocks[1]);
ctx->idsp.idct_put(dest_y + dct_y_offset, dct_linesize_luma, ctx->blocks[6]);
ctx->idsp.idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, ctx->blocks[7]);
if (!(ctx->avctx->flags & CODEC_FLAG_GRAY)) {
dct_y_offset = dct_linesize_chroma << 3;
ctx->idsp.idct_put(dest_u, dct_linesize_chroma, ctx->blocks[2]);
ctx->idsp.idct_put(dest_u + dct_x_offset, dct_linesize_chroma, ctx->blocks[3]);
ctx->idsp.idct_put(dest_u + dct_y_offset, dct_linesize_chroma, ctx->blocks[8]);
ctx->idsp.idct_put(dest_u + dct_y_offset + dct_x_offset, dct_linesize_chroma, ctx->blocks[9]);
ctx->idsp.idct_put(dest_v, dct_linesize_chroma, ctx->blocks[4]);
ctx->idsp.idct_put(dest_v + dct_x_offset, dct_linesize_chroma, ctx->blocks[5]);
ctx->idsp.idct_put(dest_v + dct_y_offset, dct_linesize_chroma, ctx->blocks[10]);
ctx->idsp.idct_put(dest_v + dct_y_offset + dct_x_offset, dct_linesize_chroma, ctx->blocks[11]);
}
}
return 0;
}
| false | FFmpeg | 2c660e34cf3c2b77cd2bef6f292920334dfd9192 | static int dnxhd_decode_macroblock(DNXHDContext *ctx, AVFrame *frame,
int x, int y)
{
int shift1 = ctx->bit_depth == 10;
int dct_linesize_luma = frame->linesize[0];
int dct_linesize_chroma = frame->linesize[1];
uint8_t *dest_y, *dest_u, *dest_v;
int dct_y_offset, dct_x_offset;
int qscale, i;
qscale = get_bits(&ctx->gb, 11);
skip_bits1(&ctx->gb);
if (qscale != ctx->last_qscale) {
for (i = 0; i < 64; i++) {
ctx->luma_scale[i] = qscale * ctx->cid_table->luma_weight[i];
ctx->chroma_scale[i] = qscale * ctx->cid_table->chroma_weight[i];
}
ctx->last_qscale = qscale;
}
for (i = 0; i < 8; i++) {
ctx->bdsp.clear_block(ctx->blocks[i]);
ctx->decode_dct_block(ctx, ctx->blocks[i], i, qscale);
}
if (ctx->is_444) {
for (; i < 12; i++) {
ctx->bdsp.clear_block(ctx->blocks[i]);
ctx->decode_dct_block(ctx, ctx->blocks[i], i, qscale);
}
}
if (frame->interlaced_frame) {
dct_linesize_luma <<= 1;
dct_linesize_chroma <<= 1;
}
dest_y = frame->data[0] + ((y * dct_linesize_luma) << 4) + (x << (4 + shift1));
dest_u = frame->data[1] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1 + ctx->is_444));
dest_v = frame->data[2] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1 + ctx->is_444));
if (ctx->cur_field) {
dest_y += frame->linesize[0];
dest_u += frame->linesize[1];
dest_v += frame->linesize[2];
}
dct_y_offset = dct_linesize_luma << 3;
dct_x_offset = 8 << shift1;
if (!ctx->is_444) {
ctx->idsp.idct_put(dest_y, dct_linesize_luma, ctx->blocks[0]);
ctx->idsp.idct_put(dest_y + dct_x_offset, dct_linesize_luma, ctx->blocks[1]);
ctx->idsp.idct_put(dest_y + dct_y_offset, dct_linesize_luma, ctx->blocks[4]);
ctx->idsp.idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, ctx->blocks[5]);
if (!(ctx->avctx->flags & CODEC_FLAG_GRAY)) {
dct_y_offset = dct_linesize_chroma << 3;
ctx->idsp.idct_put(dest_u, dct_linesize_chroma, ctx->blocks[2]);
ctx->idsp.idct_put(dest_v, dct_linesize_chroma, ctx->blocks[3]);
ctx->idsp.idct_put(dest_u + dct_y_offset, dct_linesize_chroma, ctx->blocks[6]);
ctx->idsp.idct_put(dest_v + dct_y_offset, dct_linesize_chroma, ctx->blocks[7]);
}
} else {
ctx->idsp.idct_put(dest_y, dct_linesize_luma, ctx->blocks[0]);
ctx->idsp.idct_put(dest_y + dct_x_offset, dct_linesize_luma, ctx->blocks[1]);
ctx->idsp.idct_put(dest_y + dct_y_offset, dct_linesize_luma, ctx->blocks[6]);
ctx->idsp.idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, ctx->blocks[7]);
if (!(ctx->avctx->flags & CODEC_FLAG_GRAY)) {
dct_y_offset = dct_linesize_chroma << 3;
ctx->idsp.idct_put(dest_u, dct_linesize_chroma, ctx->blocks[2]);
ctx->idsp.idct_put(dest_u + dct_x_offset, dct_linesize_chroma, ctx->blocks[3]);
ctx->idsp.idct_put(dest_u + dct_y_offset, dct_linesize_chroma, ctx->blocks[8]);
ctx->idsp.idct_put(dest_u + dct_y_offset + dct_x_offset, dct_linesize_chroma, ctx->blocks[9]);
ctx->idsp.idct_put(dest_v, dct_linesize_chroma, ctx->blocks[4]);
ctx->idsp.idct_put(dest_v + dct_x_offset, dct_linesize_chroma, ctx->blocks[5]);
ctx->idsp.idct_put(dest_v + dct_y_offset, dct_linesize_chroma, ctx->blocks[10]);
ctx->idsp.idct_put(dest_v + dct_y_offset + dct_x_offset, dct_linesize_chroma, ctx->blocks[11]);
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(DNXHDContext *VAR_0, AVFrame *VAR_1,
int VAR_2, int VAR_3)
{
int VAR_4 = VAR_0->bit_depth == 10;
int VAR_5 = VAR_1->linesize[0];
int VAR_6 = VAR_1->linesize[1];
uint8_t *dest_y, *dest_u, *dest_v;
int VAR_7, VAR_8;
int VAR_9, VAR_10;
VAR_9 = get_bits(&VAR_0->gb, 11);
skip_bits1(&VAR_0->gb);
if (VAR_9 != VAR_0->last_qscale) {
for (VAR_10 = 0; VAR_10 < 64; VAR_10++) {
VAR_0->luma_scale[VAR_10] = VAR_9 * VAR_0->cid_table->luma_weight[VAR_10];
VAR_0->chroma_scale[VAR_10] = VAR_9 * VAR_0->cid_table->chroma_weight[VAR_10];
}
VAR_0->last_qscale = VAR_9;
}
for (VAR_10 = 0; VAR_10 < 8; VAR_10++) {
VAR_0->bdsp.clear_block(VAR_0->blocks[VAR_10]);
VAR_0->decode_dct_block(VAR_0, VAR_0->blocks[VAR_10], VAR_10, VAR_9);
}
if (VAR_0->is_444) {
for (; VAR_10 < 12; VAR_10++) {
VAR_0->bdsp.clear_block(VAR_0->blocks[VAR_10]);
VAR_0->decode_dct_block(VAR_0, VAR_0->blocks[VAR_10], VAR_10, VAR_9);
}
}
if (VAR_1->interlaced_frame) {
VAR_5 <<= 1;
VAR_6 <<= 1;
}
dest_y = VAR_1->data[0] + ((VAR_3 * VAR_5) << 4) + (VAR_2 << (4 + VAR_4));
dest_u = VAR_1->data[1] + ((VAR_3 * VAR_6) << 4) + (VAR_2 << (3 + VAR_4 + VAR_0->is_444));
dest_v = VAR_1->data[2] + ((VAR_3 * VAR_6) << 4) + (VAR_2 << (3 + VAR_4 + VAR_0->is_444));
if (VAR_0->cur_field) {
dest_y += VAR_1->linesize[0];
dest_u += VAR_1->linesize[1];
dest_v += VAR_1->linesize[2];
}
VAR_7 = VAR_5 << 3;
VAR_8 = 8 << VAR_4;
if (!VAR_0->is_444) {
VAR_0->idsp.idct_put(dest_y, VAR_5, VAR_0->blocks[0]);
VAR_0->idsp.idct_put(dest_y + VAR_8, VAR_5, VAR_0->blocks[1]);
VAR_0->idsp.idct_put(dest_y + VAR_7, VAR_5, VAR_0->blocks[4]);
VAR_0->idsp.idct_put(dest_y + VAR_7 + VAR_8, VAR_5, VAR_0->blocks[5]);
if (!(VAR_0->avctx->flags & CODEC_FLAG_GRAY)) {
VAR_7 = VAR_6 << 3;
VAR_0->idsp.idct_put(dest_u, VAR_6, VAR_0->blocks[2]);
VAR_0->idsp.idct_put(dest_v, VAR_6, VAR_0->blocks[3]);
VAR_0->idsp.idct_put(dest_u + VAR_7, VAR_6, VAR_0->blocks[6]);
VAR_0->idsp.idct_put(dest_v + VAR_7, VAR_6, VAR_0->blocks[7]);
}
} else {
VAR_0->idsp.idct_put(dest_y, VAR_5, VAR_0->blocks[0]);
VAR_0->idsp.idct_put(dest_y + VAR_8, VAR_5, VAR_0->blocks[1]);
VAR_0->idsp.idct_put(dest_y + VAR_7, VAR_5, VAR_0->blocks[6]);
VAR_0->idsp.idct_put(dest_y + VAR_7 + VAR_8, VAR_5, VAR_0->blocks[7]);
if (!(VAR_0->avctx->flags & CODEC_FLAG_GRAY)) {
VAR_7 = VAR_6 << 3;
VAR_0->idsp.idct_put(dest_u, VAR_6, VAR_0->blocks[2]);
VAR_0->idsp.idct_put(dest_u + VAR_8, VAR_6, VAR_0->blocks[3]);
VAR_0->idsp.idct_put(dest_u + VAR_7, VAR_6, VAR_0->blocks[8]);
VAR_0->idsp.idct_put(dest_u + VAR_7 + VAR_8, VAR_6, VAR_0->blocks[9]);
VAR_0->idsp.idct_put(dest_v, VAR_6, VAR_0->blocks[4]);
VAR_0->idsp.idct_put(dest_v + VAR_8, VAR_6, VAR_0->blocks[5]);
VAR_0->idsp.idct_put(dest_v + VAR_7, VAR_6, VAR_0->blocks[10]);
VAR_0->idsp.idct_put(dest_v + VAR_7 + VAR_8, VAR_6, VAR_0->blocks[11]);
}
}
return 0;
}
| [
"static int FUNC_0(DNXHDContext *VAR_0, AVFrame *VAR_1,\nint VAR_2, int VAR_3)\n{",
"int VAR_4 = VAR_0->bit_depth == 10;",
"int VAR_5 = VAR_1->linesize[0];",
"int VAR_6 = VAR_1->linesize[1];",
"uint8_t *dest_y, *dest_u, *dest_v;",
"int VAR_7, VAR_8;",
"int VAR_9, VAR_10;",
"VAR_9 = get_bits(&VAR_0->... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
43
],
[
45
],
[
47
],
[... |
9,545 | static void apply_loop_filter(Vp3DecodeContext *s)
{
int x, y, plane;
int width, height;
int fragment;
int stride;
unsigned char *plane_data;
int bounding_values_array[256];
int *bounding_values= bounding_values_array+127;
int filter_limit;
/* find the right loop limit value */
for (x = 63; x >= 0; x--) {
if (vp31_ac_scale_factor[x] >= s->quality_index)
break;
}
filter_limit = vp31_filter_limit_values[s->quality_index];
/* set up the bounding values */
memset(bounding_values_array, 0, 256 * sizeof(int));
for (x = 0; x < filter_limit; x++) {
bounding_values[-x - filter_limit] = -filter_limit + x;
bounding_values[-x] = -x;
bounding_values[x] = x;
bounding_values[x + filter_limit] = filter_limit - x;
}
for (plane = 0; plane < 3; plane++) {
if (plane == 0) {
/* Y plane parameters */
fragment = 0;
width = s->fragment_width;
height = s->fragment_height;
stride = s->current_frame.linesize[0];
plane_data = s->current_frame.data[0];
} else if (plane == 1) {
/* U plane parameters */
fragment = s->u_fragment_start;
width = s->fragment_width / 2;
height = s->fragment_height / 2;
stride = s->current_frame.linesize[1];
plane_data = s->current_frame.data[1];
} else {
/* V plane parameters */
fragment = s->v_fragment_start;
width = s->fragment_width / 2;
height = s->fragment_height / 2;
stride = s->current_frame.linesize[2];
plane_data = s->current_frame.data[2];
}
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
START_TIMER
/* do not perform left edge filter for left columns frags */
if ((x > 0) &&
(s->all_fragments[fragment].coding_method != MODE_COPY)) {
horizontal_filter(
plane_data + s->all_fragments[fragment].first_pixel - 7*stride,
stride, bounding_values);
}
/* do not perform top edge filter for top row fragments */
if ((y > 0) &&
(s->all_fragments[fragment].coding_method != MODE_COPY)) {
vertical_filter(
plane_data + s->all_fragments[fragment].first_pixel + stride,
stride, bounding_values);
}
/* do not perform right edge filter for right column
* fragments or if right fragment neighbor is also coded
* in this frame (it will be filtered in next iteration) */
if ((x < width - 1) &&
(s->all_fragments[fragment].coding_method != MODE_COPY) &&
(s->all_fragments[fragment + 1].coding_method == MODE_COPY)) {
horizontal_filter(
plane_data + s->all_fragments[fragment + 1].first_pixel - 7*stride,
stride, bounding_values);
}
/* do not perform bottom edge filter for bottom row
* fragments or if bottom fragment neighbor is also coded
* in this frame (it will be filtered in the next row) */
if ((y < height - 1) &&
(s->all_fragments[fragment].coding_method != MODE_COPY) &&
(s->all_fragments[fragment + width].coding_method == MODE_COPY)) {
vertical_filter(
plane_data + s->all_fragments[fragment + width].first_pixel + stride,
stride, bounding_values);
}
fragment++;
STOP_TIMER("loop filter")
}
}
}
}
| false | FFmpeg | f44b08a5a0ee46b52a9a608cbf2d075eab93db61 | static void apply_loop_filter(Vp3DecodeContext *s)
{
int x, y, plane;
int width, height;
int fragment;
int stride;
unsigned char *plane_data;
int bounding_values_array[256];
int *bounding_values= bounding_values_array+127;
int filter_limit;
for (x = 63; x >= 0; x--) {
if (vp31_ac_scale_factor[x] >= s->quality_index)
break;
}
filter_limit = vp31_filter_limit_values[s->quality_index];
memset(bounding_values_array, 0, 256 * sizeof(int));
for (x = 0; x < filter_limit; x++) {
bounding_values[-x - filter_limit] = -filter_limit + x;
bounding_values[-x] = -x;
bounding_values[x] = x;
bounding_values[x + filter_limit] = filter_limit - x;
}
for (plane = 0; plane < 3; plane++) {
if (plane == 0) {
fragment = 0;
width = s->fragment_width;
height = s->fragment_height;
stride = s->current_frame.linesize[0];
plane_data = s->current_frame.data[0];
} else if (plane == 1) {
fragment = s->u_fragment_start;
width = s->fragment_width / 2;
height = s->fragment_height / 2;
stride = s->current_frame.linesize[1];
plane_data = s->current_frame.data[1];
} else {
fragment = s->v_fragment_start;
width = s->fragment_width / 2;
height = s->fragment_height / 2;
stride = s->current_frame.linesize[2];
plane_data = s->current_frame.data[2];
}
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
START_TIMER
if ((x > 0) &&
(s->all_fragments[fragment].coding_method != MODE_COPY)) {
horizontal_filter(
plane_data + s->all_fragments[fragment].first_pixel - 7*stride,
stride, bounding_values);
}
if ((y > 0) &&
(s->all_fragments[fragment].coding_method != MODE_COPY)) {
vertical_filter(
plane_data + s->all_fragments[fragment].first_pixel + stride,
stride, bounding_values);
}
if ((x < width - 1) &&
(s->all_fragments[fragment].coding_method != MODE_COPY) &&
(s->all_fragments[fragment + 1].coding_method == MODE_COPY)) {
horizontal_filter(
plane_data + s->all_fragments[fragment + 1].first_pixel - 7*stride,
stride, bounding_values);
}
if ((y < height - 1) &&
(s->all_fragments[fragment].coding_method != MODE_COPY) &&
(s->all_fragments[fragment + width].coding_method == MODE_COPY)) {
vertical_filter(
plane_data + s->all_fragments[fragment + width].first_pixel + stride,
stride, bounding_values);
}
fragment++;
STOP_TIMER("loop filter")
}
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Vp3DecodeContext *VAR_0)
{
int VAR_1, VAR_2, VAR_3;
int VAR_4, VAR_5;
int VAR_6;
int VAR_7;
unsigned char *VAR_8;
int VAR_9[256];
int *VAR_10= VAR_9+127;
int VAR_11;
for (VAR_1 = 63; VAR_1 >= 0; VAR_1--) {
if (vp31_ac_scale_factor[VAR_1] >= VAR_0->quality_index)
break;
}
VAR_11 = vp31_filter_limit_values[VAR_0->quality_index];
memset(VAR_9, 0, 256 * sizeof(int));
for (VAR_1 = 0; VAR_1 < VAR_11; VAR_1++) {
VAR_10[-VAR_1 - VAR_11] = -VAR_11 + VAR_1;
VAR_10[-VAR_1] = -VAR_1;
VAR_10[VAR_1] = VAR_1;
VAR_10[VAR_1 + VAR_11] = VAR_11 - VAR_1;
}
for (VAR_3 = 0; VAR_3 < 3; VAR_3++) {
if (VAR_3 == 0) {
VAR_6 = 0;
VAR_4 = VAR_0->fragment_width;
VAR_5 = VAR_0->fragment_height;
VAR_7 = VAR_0->current_frame.linesize[0];
VAR_8 = VAR_0->current_frame.data[0];
} else if (VAR_3 == 1) {
VAR_6 = VAR_0->u_fragment_start;
VAR_4 = VAR_0->fragment_width / 2;
VAR_5 = VAR_0->fragment_height / 2;
VAR_7 = VAR_0->current_frame.linesize[1];
VAR_8 = VAR_0->current_frame.data[1];
} else {
VAR_6 = VAR_0->v_fragment_start;
VAR_4 = VAR_0->fragment_width / 2;
VAR_5 = VAR_0->fragment_height / 2;
VAR_7 = VAR_0->current_frame.linesize[2];
VAR_8 = VAR_0->current_frame.data[2];
}
for (VAR_2 = 0; VAR_2 < VAR_5; VAR_2++) {
for (VAR_1 = 0; VAR_1 < VAR_4; VAR_1++) {
START_TIMER
if ((VAR_1 > 0) &&
(VAR_0->all_fragments[VAR_6].coding_method != MODE_COPY)) {
horizontal_filter(
VAR_8 + VAR_0->all_fragments[VAR_6].first_pixel - 7*VAR_7,
VAR_7, VAR_10);
}
if ((VAR_2 > 0) &&
(VAR_0->all_fragments[VAR_6].coding_method != MODE_COPY)) {
vertical_filter(
VAR_8 + VAR_0->all_fragments[VAR_6].first_pixel + VAR_7,
VAR_7, VAR_10);
}
if ((VAR_1 < VAR_4 - 1) &&
(VAR_0->all_fragments[VAR_6].coding_method != MODE_COPY) &&
(VAR_0->all_fragments[VAR_6 + 1].coding_method == MODE_COPY)) {
horizontal_filter(
VAR_8 + VAR_0->all_fragments[VAR_6 + 1].first_pixel - 7*VAR_7,
VAR_7, VAR_10);
}
if ((VAR_2 < VAR_5 - 1) &&
(VAR_0->all_fragments[VAR_6].coding_method != MODE_COPY) &&
(VAR_0->all_fragments[VAR_6 + VAR_4].coding_method == MODE_COPY)) {
vertical_filter(
VAR_8 + VAR_0->all_fragments[VAR_6 + VAR_4].first_pixel + VAR_7,
VAR_7, VAR_10);
}
VAR_6++;
STOP_TIMER("loop filter")
}
}
}
}
| [
"static void FUNC_0(Vp3DecodeContext *VAR_0)\n{",
"int VAR_1, VAR_2, VAR_3;",
"int VAR_4, VAR_5;",
"int VAR_6;",
"int VAR_7;",
"unsigned char *VAR_8;",
"int VAR_9[256];",
"int *VAR_10= VAR_9+127;",
"int VAR_11;",
"for (VAR_1 = 63; VAR_1 >= 0; VAR_1--) {",
"if (vp31_ac_scale_factor[VAR_1] >= VAR_... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[... |
9,547 | static int vt82c686b_ide_initfn(PCIDevice *dev)
{
PCIIDEState *d = DO_UPCAST(PCIIDEState, dev, dev);;
uint8_t *pci_conf = d->dev.config;
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_VIA);
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_VIA_IDE);
pci_config_set_class(pci_conf, PCI_CLASS_STORAGE_IDE);
pci_config_set_prog_interface(pci_conf, 0x8a); /* legacy ATA mode */
pci_config_set_revision(pci_conf,0x06); /* Revision 0.6 */
pci_set_long(pci_conf + PCI_CAPABILITY_LIST, 0x000000c0);
qemu_register_reset(via_reset, d);
pci_register_bar(&d->dev, 4, 0x10,
PCI_BASE_ADDRESS_SPACE_IO, bmdma_map);
vmstate_register(&dev->qdev, 0, &vmstate_ide_pci, d);
vt82c686b_init_ports(d);
return 0;
}
| false | qemu | 65ff544b41c4e097d49a0c81b97cb2f9f9b039b8 | static int vt82c686b_ide_initfn(PCIDevice *dev)
{
PCIIDEState *d = DO_UPCAST(PCIIDEState, dev, dev);;
uint8_t *pci_conf = d->dev.config;
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_VIA);
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_VIA_IDE);
pci_config_set_class(pci_conf, PCI_CLASS_STORAGE_IDE);
pci_config_set_prog_interface(pci_conf, 0x8a);
pci_config_set_revision(pci_conf,0x06);
pci_set_long(pci_conf + PCI_CAPABILITY_LIST, 0x000000c0);
qemu_register_reset(via_reset, d);
pci_register_bar(&d->dev, 4, 0x10,
PCI_BASE_ADDRESS_SPACE_IO, bmdma_map);
vmstate_register(&dev->qdev, 0, &vmstate_ide_pci, d);
vt82c686b_init_ports(d);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(PCIDevice *VAR_0)
{
PCIIDEState *d = DO_UPCAST(PCIIDEState, VAR_0, VAR_0);;
uint8_t *pci_conf = d->VAR_0.config;
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_VIA);
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_VIA_IDE);
pci_config_set_class(pci_conf, PCI_CLASS_STORAGE_IDE);
pci_config_set_prog_interface(pci_conf, 0x8a);
pci_config_set_revision(pci_conf,0x06);
pci_set_long(pci_conf + PCI_CAPABILITY_LIST, 0x000000c0);
qemu_register_reset(via_reset, d);
pci_register_bar(&d->VAR_0, 4, 0x10,
PCI_BASE_ADDRESS_SPACE_IO, bmdma_map);
vmstate_register(&VAR_0->qdev, 0, &vmstate_ide_pci, d);
vt82c686b_init_ports(d);
return 0;
}
| [
"static int FUNC_0(PCIDevice *VAR_0)\n{",
"PCIIDEState *d = DO_UPCAST(PCIIDEState, VAR_0, VAR_0);;",
"uint8_t *pci_conf = d->VAR_0.config;",
"pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_VIA);",
"pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_VIA_IDE);",
"pci_config_set_class(pci_conf, PCI_CLASS_STO... | [
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
],
[
25
],
[
27,
29
],
[
33
],
[
37
],
[
41
],
[
43
]
] |
9,549 | void set_numa_modes(void)
{
CPUArchState *env;
int i;
for (env = first_cpu; env != NULL; env = env->next_cpu) {
for (i = 0; i < nb_numa_nodes; i++) {
if (node_cpumask[i] & (1 << env->cpu_index)) {
env->numa_node = i;
}
}
}
}
| false | qemu | ee785fed5dd035d4b12142cacec6d3c344426dec | void set_numa_modes(void)
{
CPUArchState *env;
int i;
for (env = first_cpu; env != NULL; env = env->next_cpu) {
for (i = 0; i < nb_numa_nodes; i++) {
if (node_cpumask[i] & (1 << env->cpu_index)) {
env->numa_node = i;
}
}
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(void)
{
CPUArchState *env;
int VAR_0;
for (env = first_cpu; env != NULL; env = env->next_cpu) {
for (VAR_0 = 0; VAR_0 < nb_numa_nodes; VAR_0++) {
if (node_cpumask[VAR_0] & (1 << env->cpu_index)) {
env->numa_node = VAR_0;
}
}
}
}
| [
"void FUNC_0(void)\n{",
"CPUArchState *env;",
"int VAR_0;",
"for (env = first_cpu; env != NULL; env = env->next_cpu) {",
"for (VAR_0 = 0; VAR_0 < nb_numa_nodes; VAR_0++) {",
"if (node_cpumask[VAR_0] & (1 << env->cpu_index)) {",
"env->numa_node = VAR_0;",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
9,550 | static void omap_mcbsp_writew(void *opaque, hwaddr addr,
uint32_t value)
{
struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque;
int offset = addr & OMAP_MPUI_REG_MASK;
if (offset == 0x04) { /* DXR */
if (((s->xcr[0] >> 5) & 7) < 3) /* XWDLEN1 */
return;
if (s->tx_req > 3) {
s->tx_req -= 4;
if (s->codec && s->codec->cts) {
s->codec->out.fifo[s->codec->out.len ++] =
(value >> 24) & 0xff;
s->codec->out.fifo[s->codec->out.len ++] =
(value >> 16) & 0xff;
s->codec->out.fifo[s->codec->out.len ++] =
(value >> 8) & 0xff;
s->codec->out.fifo[s->codec->out.len ++] =
(value >> 0) & 0xff;
}
if (s->tx_req < 4)
omap_mcbsp_tx_done(s);
} else
printf("%s: Tx FIFO overrun\n", __FUNCTION__);
return;
}
omap_badwidth_write16(opaque, addr, value);
}
| false | qemu | a89f364ae8740dfc31b321eed9ee454e996dc3c1 | static void omap_mcbsp_writew(void *opaque, hwaddr addr,
uint32_t value)
{
struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque;
int offset = addr & OMAP_MPUI_REG_MASK;
if (offset == 0x04) {
if (((s->xcr[0] >> 5) & 7) < 3)
return;
if (s->tx_req > 3) {
s->tx_req -= 4;
if (s->codec && s->codec->cts) {
s->codec->out.fifo[s->codec->out.len ++] =
(value >> 24) & 0xff;
s->codec->out.fifo[s->codec->out.len ++] =
(value >> 16) & 0xff;
s->codec->out.fifo[s->codec->out.len ++] =
(value >> 8) & 0xff;
s->codec->out.fifo[s->codec->out.len ++] =
(value >> 0) & 0xff;
}
if (s->tx_req < 4)
omap_mcbsp_tx_done(s);
} else
printf("%s: Tx FIFO overrun\n", __FUNCTION__);
return;
}
omap_badwidth_write16(opaque, addr, value);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, hwaddr VAR_1,
uint32_t VAR_2)
{
struct omap_mcbsp_s *VAR_3 = (struct omap_mcbsp_s *) VAR_0;
int VAR_4 = VAR_1 & OMAP_MPUI_REG_MASK;
if (VAR_4 == 0x04) {
if (((VAR_3->xcr[0] >> 5) & 7) < 3)
return;
if (VAR_3->tx_req > 3) {
VAR_3->tx_req -= 4;
if (VAR_3->codec && VAR_3->codec->cts) {
VAR_3->codec->out.fifo[VAR_3->codec->out.len ++] =
(VAR_2 >> 24) & 0xff;
VAR_3->codec->out.fifo[VAR_3->codec->out.len ++] =
(VAR_2 >> 16) & 0xff;
VAR_3->codec->out.fifo[VAR_3->codec->out.len ++] =
(VAR_2 >> 8) & 0xff;
VAR_3->codec->out.fifo[VAR_3->codec->out.len ++] =
(VAR_2 >> 0) & 0xff;
}
if (VAR_3->tx_req < 4)
omap_mcbsp_tx_done(VAR_3);
} else
printf("%VAR_3: Tx FIFO overrun\n", __FUNCTION__);
return;
}
omap_badwidth_write16(VAR_0, VAR_1, VAR_2);
}
| [
"static void FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint32_t VAR_2)\n{",
"struct omap_mcbsp_s *VAR_3 = (struct omap_mcbsp_s *) VAR_0;",
"int VAR_4 = VAR_1 & OMAP_MPUI_REG_MASK;",
"if (VAR_4 == 0x04) {",
"if (((VAR_3->xcr[0] >> 5) & 7) < 3)\nreturn;",
"if (VAR_3->tx_req > 3) {",
"VAR_3->tx_req -= 4;",
"if ... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29,
31
],
[
33,
35
],
[
37,
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[... |
9,551 | static void fcse_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
{
ARMCPU *cpu = arm_env_get_cpu(env);
if (env->cp15.c13_fcse != value) {
/* Unlike real hardware the qemu TLB uses virtual addresses,
* not modified virtual addresses, so this causes a TLB flush.
*/
tlb_flush(CPU(cpu), 1);
env->cp15.c13_fcse = value;
}
}
| false | qemu | 8d5c773e323b22402abdd0beef4c7d2fc91dd0eb | static void fcse_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
{
ARMCPU *cpu = arm_env_get_cpu(env);
if (env->cp15.c13_fcse != value) {
tlb_flush(CPU(cpu), 1);
env->cp15.c13_fcse = value;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(CPUARMState *VAR_0, const ARMCPRegInfo *VAR_1, uint64_t VAR_2)
{
ARMCPU *cpu = arm_env_get_cpu(VAR_0);
if (VAR_0->cp15.c13_fcse != VAR_2) {
tlb_flush(CPU(cpu), 1);
VAR_0->cp15.c13_fcse = VAR_2;
}
}
| [
"static void FUNC_0(CPUARMState *VAR_0, const ARMCPRegInfo *VAR_1, uint64_t VAR_2)\n{",
"ARMCPU *cpu = arm_env_get_cpu(VAR_0);",
"if (VAR_0->cp15.c13_fcse != VAR_2) {",
"tlb_flush(CPU(cpu), 1);",
"VAR_0->cp15.c13_fcse = VAR_2;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
9,552 | static void bw_io_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
switch (size) {
case 1:
cpu_outb(addr, val);
break;
case 2:
cpu_outw(addr, val);
break;
case 4:
cpu_outl(addr, val);
break;
default:
abort();
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void bw_io_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
switch (size) {
case 1:
cpu_outb(addr, val);
break;
case 2:
cpu_outw(addr, val);
break;
case 4:
cpu_outl(addr, val);
break;
default:
abort();
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
switch (VAR_3) {
case 1:
cpu_outb(VAR_1, VAR_2);
break;
case 2:
cpu_outw(VAR_1, VAR_2);
break;
case 4:
cpu_outl(VAR_1, VAR_2);
break;
default:
abort();
}
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"switch (VAR_3) {",
"case 1:\ncpu_outb(VAR_1, VAR_2);",
"break;",
"case 2:\ncpu_outw(VAR_1, VAR_2);",
"break;",
"case 4:\ncpu_outl(VAR_1, VAR_2);",
"break;",
"default:\nabort();",
"}",
"}"
] | [
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
]
] |
9,553 | static void check_watchpoint(int offset, int len, int flags)
{
CPUState *cpu = current_cpu;
CPUArchState *env = cpu->env_ptr;
target_ulong pc, cs_base;
target_ulong vaddr;
CPUWatchpoint *wp;
int cpu_flags;
if (cpu->watchpoint_hit) {
/* We re-entered the check after replacing the TB. Now raise
* the debug interrupt so that is will trigger after the
* current instruction. */
cpu_interrupt(cpu, CPU_INTERRUPT_DEBUG);
return;
}
vaddr = (cpu->mem_io_vaddr & TARGET_PAGE_MASK) + offset;
QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) {
if (cpu_watchpoint_address_matches(wp, vaddr, len)
&& (wp->flags & flags)) {
wp->flags |= BP_WATCHPOINT_HIT;
if (!cpu->watchpoint_hit) {
cpu->watchpoint_hit = wp;
tb_check_watchpoint(cpu);
if (wp->flags & BP_STOP_BEFORE_ACCESS) {
cpu->exception_index = EXCP_DEBUG;
cpu_loop_exit(cpu);
} else {
cpu_get_tb_cpu_state(env, &pc, &cs_base, &cpu_flags);
tb_gen_code(cpu, pc, cs_base, cpu_flags, 1);
cpu_resume_from_signal(cpu, NULL);
}
}
} else {
wp->flags &= ~BP_WATCHPOINT_HIT;
}
}
}
| false | qemu | 08225676b279fd14683275b65ed701972e008043 | static void check_watchpoint(int offset, int len, int flags)
{
CPUState *cpu = current_cpu;
CPUArchState *env = cpu->env_ptr;
target_ulong pc, cs_base;
target_ulong vaddr;
CPUWatchpoint *wp;
int cpu_flags;
if (cpu->watchpoint_hit) {
cpu_interrupt(cpu, CPU_INTERRUPT_DEBUG);
return;
}
vaddr = (cpu->mem_io_vaddr & TARGET_PAGE_MASK) + offset;
QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) {
if (cpu_watchpoint_address_matches(wp, vaddr, len)
&& (wp->flags & flags)) {
wp->flags |= BP_WATCHPOINT_HIT;
if (!cpu->watchpoint_hit) {
cpu->watchpoint_hit = wp;
tb_check_watchpoint(cpu);
if (wp->flags & BP_STOP_BEFORE_ACCESS) {
cpu->exception_index = EXCP_DEBUG;
cpu_loop_exit(cpu);
} else {
cpu_get_tb_cpu_state(env, &pc, &cs_base, &cpu_flags);
tb_gen_code(cpu, pc, cs_base, cpu_flags, 1);
cpu_resume_from_signal(cpu, NULL);
}
}
} else {
wp->flags &= ~BP_WATCHPOINT_HIT;
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(int VAR_0, int VAR_1, int VAR_2)
{
CPUState *cpu = current_cpu;
CPUArchState *env = cpu->env_ptr;
target_ulong pc, cs_base;
target_ulong vaddr;
CPUWatchpoint *wp;
int VAR_3;
if (cpu->watchpoint_hit) {
cpu_interrupt(cpu, CPU_INTERRUPT_DEBUG);
return;
}
vaddr = (cpu->mem_io_vaddr & TARGET_PAGE_MASK) + VAR_0;
QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) {
if (cpu_watchpoint_address_matches(wp, vaddr, VAR_1)
&& (wp->VAR_2 & VAR_2)) {
wp->VAR_2 |= BP_WATCHPOINT_HIT;
if (!cpu->watchpoint_hit) {
cpu->watchpoint_hit = wp;
tb_check_watchpoint(cpu);
if (wp->VAR_2 & BP_STOP_BEFORE_ACCESS) {
cpu->exception_index = EXCP_DEBUG;
cpu_loop_exit(cpu);
} else {
cpu_get_tb_cpu_state(env, &pc, &cs_base, &VAR_3);
tb_gen_code(cpu, pc, cs_base, VAR_3, 1);
cpu_resume_from_signal(cpu, NULL);
}
}
} else {
wp->VAR_2 &= ~BP_WATCHPOINT_HIT;
}
}
}
| [
"static void FUNC_0(int VAR_0, int VAR_1, int VAR_2)\n{",
"CPUState *cpu = current_cpu;",
"CPUArchState *env = cpu->env_ptr;",
"target_ulong pc, cs_base;",
"target_ulong vaddr;",
"CPUWatchpoint *wp;",
"int VAR_3;",
"if (cpu->watchpoint_hit) {",
"cpu_interrupt(cpu, CPU_INTERRUPT_DEBUG);",
"return;"... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[... |
9,554 | static void *qpa_thread_in (void *arg)
{
PAVoiceIn *pa = arg;
HWVoiceIn *hw = &pa->hw;
int threshold;
threshold = conf.divisor ? hw->samples / conf.divisor : 0;
if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
for (;;) {
int incr, to_grab, wpos;
for (;;) {
if (pa->done) {
goto exit;
}
if (pa->dead > threshold) {
break;
}
if (audio_pt_wait (&pa->pt, AUDIO_FUNC)) {
goto exit;
}
}
incr = to_grab = pa->dead;
wpos = hw->wpos;
if (audio_pt_unlock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
while (to_grab) {
int error;
int chunk = audio_MIN (to_grab, hw->samples - wpos);
void *buf = advance (pa->pcm_buf, wpos);
if (pa_simple_read (pa->s, buf,
chunk << hw->info.shift, &error) < 0) {
qpa_logerr (error, "pa_simple_read failed\n");
return NULL;
}
hw->conv (hw->conv_buf + wpos, buf, chunk);
wpos = (wpos + chunk) % hw->samples;
to_grab -= chunk;
}
if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
pa->wpos = wpos;
pa->dead -= incr;
pa->incr += incr;
}
exit:
audio_pt_unlock (&pa->pt, AUDIO_FUNC);
return NULL;
}
| false | qemu | 6315633b2535dc82dc1b3403f884b81e26b4c72c | static void *qpa_thread_in (void *arg)
{
PAVoiceIn *pa = arg;
HWVoiceIn *hw = &pa->hw;
int threshold;
threshold = conf.divisor ? hw->samples / conf.divisor : 0;
if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
for (;;) {
int incr, to_grab, wpos;
for (;;) {
if (pa->done) {
goto exit;
}
if (pa->dead > threshold) {
break;
}
if (audio_pt_wait (&pa->pt, AUDIO_FUNC)) {
goto exit;
}
}
incr = to_grab = pa->dead;
wpos = hw->wpos;
if (audio_pt_unlock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
while (to_grab) {
int error;
int chunk = audio_MIN (to_grab, hw->samples - wpos);
void *buf = advance (pa->pcm_buf, wpos);
if (pa_simple_read (pa->s, buf,
chunk << hw->info.shift, &error) < 0) {
qpa_logerr (error, "pa_simple_read failed\n");
return NULL;
}
hw->conv (hw->conv_buf + wpos, buf, chunk);
wpos = (wpos + chunk) % hw->samples;
to_grab -= chunk;
}
if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
pa->wpos = wpos;
pa->dead -= incr;
pa->incr += incr;
}
exit:
audio_pt_unlock (&pa->pt, AUDIO_FUNC);
return NULL;
}
| {
"code": [],
"line_no": []
} | static void *FUNC_0 (void *VAR_0)
{
PAVoiceIn *pa = VAR_0;
HWVoiceIn *hw = &pa->hw;
int VAR_1;
VAR_1 = conf.divisor ? hw->samples / conf.divisor : 0;
if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
for (;;) {
int VAR_2, VAR_3, VAR_4;
for (;;) {
if (pa->done) {
goto exit;
}
if (pa->dead > VAR_1) {
break;
}
if (audio_pt_wait (&pa->pt, AUDIO_FUNC)) {
goto exit;
}
}
VAR_2 = VAR_3 = pa->dead;
VAR_4 = hw->VAR_4;
if (audio_pt_unlock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
while (VAR_3) {
int VAR_5;
int VAR_6 = audio_MIN (VAR_3, hw->samples - VAR_4);
void *VAR_7 = advance (pa->pcm_buf, VAR_4);
if (pa_simple_read (pa->s, VAR_7,
VAR_6 << hw->info.shift, &VAR_5) < 0) {
qpa_logerr (VAR_5, "pa_simple_read failed\n");
return NULL;
}
hw->conv (hw->conv_buf + VAR_4, VAR_7, VAR_6);
VAR_4 = (VAR_4 + VAR_6) % hw->samples;
VAR_3 -= VAR_6;
}
if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {
return NULL;
}
pa->VAR_4 = VAR_4;
pa->dead -= VAR_2;
pa->VAR_2 += VAR_2;
}
exit:
audio_pt_unlock (&pa->pt, AUDIO_FUNC);
return NULL;
}
| [
"static void *FUNC_0 (void *VAR_0)\n{",
"PAVoiceIn *pa = VAR_0;",
"HWVoiceIn *hw = &pa->hw;",
"int VAR_1;",
"VAR_1 = conf.divisor ? hw->samples / conf.divisor : 0;",
"if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) {",
"return NULL;",
"}",
"for (;;) {",
"int VAR_2, VAR_3, VAR_4;",
"for (;;) {",
"if (... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
... |
9,555 | void check_file_unfixed_eof_mmaps(void)
{
char *cp;
unsigned int *p1;
uintptr_t p;
int i;
fprintf (stderr, "%s", __func__);
for (i = 0; i < 0x10; i++)
{
p1 = mmap(NULL, pagesize, PROT_READ,
MAP_PRIVATE,
test_fd,
(test_fsize - sizeof *p1) & ~pagemask);
fail_unless (p1 != MAP_FAILED);
/* Make sure we get pages aligned with the pagesize. The
target expects this. */
p = (uintptr_t) p1;
fail_unless ((p & pagemask) == 0);
/* Verify that the file maps was made correctly. */
fail_unless (p1[(test_fsize & pagemask) / sizeof *p1 - 1]
== ((test_fsize - sizeof *p1) / sizeof *p1));
/* Verify that the end of page is accessable and zeroed. */
cp = (void *) p1;
fail_unless (cp[pagesize - 4] == 0);
munmap (p1, pagesize);
}
fprintf (stderr, " passed\n");
}
| false | qemu | 64c7b9d8e07936383db181876b59c597d6a1ff69 | void check_file_unfixed_eof_mmaps(void)
{
char *cp;
unsigned int *p1;
uintptr_t p;
int i;
fprintf (stderr, "%s", __func__);
for (i = 0; i < 0x10; i++)
{
p1 = mmap(NULL, pagesize, PROT_READ,
MAP_PRIVATE,
test_fd,
(test_fsize - sizeof *p1) & ~pagemask);
fail_unless (p1 != MAP_FAILED);
p = (uintptr_t) p1;
fail_unless ((p & pagemask) == 0);
fail_unless (p1[(test_fsize & pagemask) / sizeof *p1 - 1]
== ((test_fsize - sizeof *p1) / sizeof *p1));
cp = (void *) p1;
fail_unless (cp[pagesize - 4] == 0);
munmap (p1, pagesize);
}
fprintf (stderr, " passed\n");
}
| {
"code": [],
"line_no": []
} | void FUNC_0(void)
{
char *VAR_0;
unsigned int *VAR_1;
uintptr_t p;
int VAR_2;
fprintf (stderr, "%s", __func__);
for (VAR_2 = 0; VAR_2 < 0x10; VAR_2++)
{
VAR_1 = mmap(NULL, pagesize, PROT_READ,
MAP_PRIVATE,
test_fd,
(test_fsize - sizeof *VAR_1) & ~pagemask);
fail_unless (VAR_1 != MAP_FAILED);
p = (uintptr_t) VAR_1;
fail_unless ((p & pagemask) == 0);
fail_unless (VAR_1[(test_fsize & pagemask) / sizeof *VAR_1 - 1]
== ((test_fsize - sizeof *VAR_1) / sizeof *VAR_1));
VAR_0 = (void *) VAR_1;
fail_unless (VAR_0[pagesize - 4] == 0);
munmap (VAR_1, pagesize);
}
fprintf (stderr, " passed\n");
}
| [
"void FUNC_0(void)\n{",
"char *VAR_0;",
"unsigned int *VAR_1;",
"uintptr_t p;",
"int VAR_2;",
"fprintf (stderr, \"%s\", __func__);",
"for (VAR_2 = 0; VAR_2 < 0x10; VAR_2++)",
"{",
"VAR_1 = mmap(NULL, pagesize, PROT_READ,\nMAP_PRIVATE,\ntest_fd,\n(test_fsize - sizeof *VAR_1) & ~pagemask);",
"fail_u... | [
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
],
[
31
],
[
39
],
[
41
],
[
45,
47
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
... |
9,556 | static int64_t update_scr(AVFormatContext *ctx,int stream_index,int64_t pts)
{
MpegMuxContext *s = ctx->priv_data;
int64_t scr;
if (s->is_vcd)
/* Since the data delivery rate is constant, SCR is computed
using the formula C + i * 1200 where C is the start constant
and i is the pack index.
It is recommended that SCR 0 is at the beginning of the VCD front
margin (a sequence of empty Form 2 sectors on the CD).
It is recommended that the front margin is 30 sectors long, so
we use C = 30*1200 = 36000
(Note that even if the front margin is not 30 sectors the file
will still be correct according to the standard. It just won't have
the "recommended" value).*/
scr = 36000 + s->packet_number * 1200;
else {
/* XXX I believe this calculation of SCR is wrong. SCR
specifies at which time the data should enter the decoder.
Two packs cannot enter the decoder at the same time. */
/* XXX: system clock should be computed precisely, especially for
CBR case. The current mode gives at least something coherent */
if (stream_index == s->scr_stream_index
&& pts != AV_NOPTS_VALUE)
scr = pts;
else
scr = s->last_scr;
}
s->last_scr=scr;
return scr;
}
| false | FFmpeg | 224944895efe6ac23e3b8f9d35abfee9f5c6c440 | static int64_t update_scr(AVFormatContext *ctx,int stream_index,int64_t pts)
{
MpegMuxContext *s = ctx->priv_data;
int64_t scr;
if (s->is_vcd)
scr = 36000 + s->packet_number * 1200;
else {
if (stream_index == s->scr_stream_index
&& pts != AV_NOPTS_VALUE)
scr = pts;
else
scr = s->last_scr;
}
s->last_scr=scr;
return scr;
}
| {
"code": [],
"line_no": []
} | static int64_t FUNC_0(AVFormatContext *ctx,int stream_index,int64_t pts)
{
MpegMuxContext *s = ctx->priv_data;
int64_t scr;
if (s->is_vcd)
scr = 36000 + s->packet_number * 1200;
else {
if (stream_index == s->scr_stream_index
&& pts != AV_NOPTS_VALUE)
scr = pts;
else
scr = s->last_scr;
}
s->last_scr=scr;
return scr;
}
| [
"static int64_t FUNC_0(AVFormatContext *ctx,int stream_index,int64_t pts)\n{",
"MpegMuxContext *s = ctx->priv_data;",
"int64_t scr;",
"if (s->is_vcd)\nscr = 36000 + s->packet_number * 1200;",
"else {",
"if (stream_index == s->scr_stream_index\n&& pts != AV_NOPTS_VALUE)\nscr = pts;",
"else\nscr = s->last... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
33
],
[
35
],
[
49,
51,
53
],
[
55,
57
],
[
59
],
[
63
],
[
67
],
[
69
]
] |
9,557 | static int decode_micromips_opc (CPUMIPSState *env, DisasContext *ctx)
{
uint32_t op;
/* make sure instructions are on a halfword boundary */
if (ctx->pc & 0x1) {
env->CP0_BadVAddr = ctx->pc;
generate_exception(ctx, EXCP_AdEL);
ctx->bstate = BS_STOP;
return 2;
}
op = (ctx->opcode >> 10) & 0x3f;
/* Enforce properly-sized instructions in a delay slot */
if (ctx->hflags & MIPS_HFLAG_BDS_STRICT) {
switch (op & 0x7) { /* MSB-3..MSB-5 */
case 0:
/* POOL32A, POOL32B, POOL32I, POOL32C */
case 4:
/* ADDI32, ADDIU32, ORI32, XORI32, SLTI32, SLTIU32, ANDI32, JALX32 */
case 5:
/* LBU32, LHU32, POOL32F, JALS32, BEQ32, BNE32, J32, JAL32 */
case 6:
/* SB32, SH32, ADDIUPC, SWC132, SDC132, SW32 */
case 7:
/* LB32, LH32, LWC132, LDC132, LW32 */
if (ctx->hflags & MIPS_HFLAG_BDS16) {
generate_exception(ctx, EXCP_RI);
/* Just stop translation; the user is confused. */
ctx->bstate = BS_STOP;
return 2;
}
break;
case 1:
/* POOL16A, POOL16B, POOL16C, LWGP16, POOL16F */
case 2:
/* LBU16, LHU16, LWSP16, LW16, SB16, SH16, SWSP16, SW16 */
case 3:
/* MOVE16, ANDI16, POOL16D, POOL16E, BEQZ16, BNEZ16, B16, LI16 */
if (ctx->hflags & MIPS_HFLAG_BDS32) {
generate_exception(ctx, EXCP_RI);
/* Just stop translation; the user is confused. */
ctx->bstate = BS_STOP;
return 2;
}
break;
}
}
switch (op) {
case POOL16A:
{
int rd = mmreg(uMIPS_RD(ctx->opcode));
int rs1 = mmreg(uMIPS_RS1(ctx->opcode));
int rs2 = mmreg(uMIPS_RS2(ctx->opcode));
uint32_t opc = 0;
switch (ctx->opcode & 0x1) {
case ADDU16:
opc = OPC_ADDU;
break;
case SUBU16:
opc = OPC_SUBU;
break;
}
gen_arith(ctx, opc, rd, rs1, rs2);
}
break;
case POOL16B:
{
int rd = mmreg(uMIPS_RD(ctx->opcode));
int rs = mmreg(uMIPS_RS(ctx->opcode));
int amount = (ctx->opcode >> 1) & 0x7;
uint32_t opc = 0;
amount = amount == 0 ? 8 : amount;
switch (ctx->opcode & 0x1) {
case SLL16:
opc = OPC_SLL;
break;
case SRL16:
opc = OPC_SRL;
break;
}
gen_shift_imm(ctx, opc, rd, rs, amount);
}
break;
case POOL16C:
gen_pool16c_insn(ctx);
break;
case LWGP16:
{
int rd = mmreg(uMIPS_RD(ctx->opcode));
int rb = 28; /* GP */
int16_t offset = SIMM(ctx->opcode, 0, 7) << 2;
gen_ld(ctx, OPC_LW, rd, rb, offset);
}
break;
case POOL16F:
check_insn_opc_removed(ctx, ISA_MIPS32R6);
if (ctx->opcode & 1) {
generate_exception(ctx, EXCP_RI);
} else {
/* MOVEP */
int enc_dest = uMIPS_RD(ctx->opcode);
int enc_rt = uMIPS_RS2(ctx->opcode);
int enc_rs = uMIPS_RS1(ctx->opcode);
int rd, rs, re, rt;
static const int rd_enc[] = { 5, 5, 6, 4, 4, 4, 4, 4 };
static const int re_enc[] = { 6, 7, 7, 21, 22, 5, 6, 7 };
static const int rs_rt_enc[] = { 0, 17, 2, 3, 16, 18, 19, 20 };
rd = rd_enc[enc_dest];
re = re_enc[enc_dest];
rs = rs_rt_enc[enc_rs];
rt = rs_rt_enc[enc_rt];
gen_arith(ctx, OPC_ADDU, rd, rs, 0);
gen_arith(ctx, OPC_ADDU, re, rt, 0);
}
break;
case LBU16:
{
int rd = mmreg(uMIPS_RD(ctx->opcode));
int rb = mmreg(uMIPS_RS(ctx->opcode));
int16_t offset = ZIMM(ctx->opcode, 0, 4);
offset = (offset == 0xf ? -1 : offset);
gen_ld(ctx, OPC_LBU, rd, rb, offset);
}
break;
case LHU16:
{
int rd = mmreg(uMIPS_RD(ctx->opcode));
int rb = mmreg(uMIPS_RS(ctx->opcode));
int16_t offset = ZIMM(ctx->opcode, 0, 4) << 1;
gen_ld(ctx, OPC_LHU, rd, rb, offset);
}
break;
case LWSP16:
{
int rd = (ctx->opcode >> 5) & 0x1f;
int rb = 29; /* SP */
int16_t offset = ZIMM(ctx->opcode, 0, 5) << 2;
gen_ld(ctx, OPC_LW, rd, rb, offset);
}
break;
case LW16:
{
int rd = mmreg(uMIPS_RD(ctx->opcode));
int rb = mmreg(uMIPS_RS(ctx->opcode));
int16_t offset = ZIMM(ctx->opcode, 0, 4) << 2;
gen_ld(ctx, OPC_LW, rd, rb, offset);
}
break;
case SB16:
{
int rd = mmreg2(uMIPS_RD(ctx->opcode));
int rb = mmreg(uMIPS_RS(ctx->opcode));
int16_t offset = ZIMM(ctx->opcode, 0, 4);
gen_st(ctx, OPC_SB, rd, rb, offset);
}
break;
case SH16:
{
int rd = mmreg2(uMIPS_RD(ctx->opcode));
int rb = mmreg(uMIPS_RS(ctx->opcode));
int16_t offset = ZIMM(ctx->opcode, 0, 4) << 1;
gen_st(ctx, OPC_SH, rd, rb, offset);
}
break;
case SWSP16:
{
int rd = (ctx->opcode >> 5) & 0x1f;
int rb = 29; /* SP */
int16_t offset = ZIMM(ctx->opcode, 0, 5) << 2;
gen_st(ctx, OPC_SW, rd, rb, offset);
}
break;
case SW16:
{
int rd = mmreg2(uMIPS_RD(ctx->opcode));
int rb = mmreg(uMIPS_RS(ctx->opcode));
int16_t offset = ZIMM(ctx->opcode, 0, 4) << 2;
gen_st(ctx, OPC_SW, rd, rb, offset);
}
break;
case MOVE16:
{
int rd = uMIPS_RD5(ctx->opcode);
int rs = uMIPS_RS5(ctx->opcode);
gen_arith(ctx, OPC_ADDU, rd, rs, 0);
}
break;
case ANDI16:
gen_andi16(ctx);
break;
case POOL16D:
switch (ctx->opcode & 0x1) {
case ADDIUS5:
gen_addius5(ctx);
break;
case ADDIUSP:
gen_addiusp(ctx);
break;
}
break;
case POOL16E:
switch (ctx->opcode & 0x1) {
case ADDIUR2:
gen_addiur2(ctx);
break;
case ADDIUR1SP:
gen_addiur1sp(ctx);
break;
}
break;
case B16:
gen_compute_branch(ctx, OPC_BEQ, 2, 0, 0,
SIMM(ctx->opcode, 0, 10) << 1, 4);
break;
case BNEZ16:
case BEQZ16:
gen_compute_branch(ctx, op == BNEZ16 ? OPC_BNE : OPC_BEQ, 2,
mmreg(uMIPS_RD(ctx->opcode)),
0, SIMM(ctx->opcode, 0, 7) << 1, 4);
break;
case LI16:
{
int reg = mmreg(uMIPS_RD(ctx->opcode));
int imm = ZIMM(ctx->opcode, 0, 7);
imm = (imm == 0x7f ? -1 : imm);
tcg_gen_movi_tl(cpu_gpr[reg], imm);
}
break;
case RES_20:
case RES_28:
case RES_29:
case RES_30:
case RES_31:
case RES_38:
case RES_39:
generate_exception(ctx, EXCP_RI);
break;
default:
decode_micromips32_opc(env, ctx);
return 4;
}
return 2;
}
| false | qemu | 3a1f426828cd8ffeec1a4fa8ca6ca3ed4f800edb | static int decode_micromips_opc (CPUMIPSState *env, DisasContext *ctx)
{
uint32_t op;
if (ctx->pc & 0x1) {
env->CP0_BadVAddr = ctx->pc;
generate_exception(ctx, EXCP_AdEL);
ctx->bstate = BS_STOP;
return 2;
}
op = (ctx->opcode >> 10) & 0x3f;
if (ctx->hflags & MIPS_HFLAG_BDS_STRICT) {
switch (op & 0x7) {
case 0:
case 4:
case 5:
case 6:
case 7:
if (ctx->hflags & MIPS_HFLAG_BDS16) {
generate_exception(ctx, EXCP_RI);
ctx->bstate = BS_STOP;
return 2;
}
break;
case 1:
case 2:
case 3:
if (ctx->hflags & MIPS_HFLAG_BDS32) {
generate_exception(ctx, EXCP_RI);
ctx->bstate = BS_STOP;
return 2;
}
break;
}
}
switch (op) {
case POOL16A:
{
int rd = mmreg(uMIPS_RD(ctx->opcode));
int rs1 = mmreg(uMIPS_RS1(ctx->opcode));
int rs2 = mmreg(uMIPS_RS2(ctx->opcode));
uint32_t opc = 0;
switch (ctx->opcode & 0x1) {
case ADDU16:
opc = OPC_ADDU;
break;
case SUBU16:
opc = OPC_SUBU;
break;
}
gen_arith(ctx, opc, rd, rs1, rs2);
}
break;
case POOL16B:
{
int rd = mmreg(uMIPS_RD(ctx->opcode));
int rs = mmreg(uMIPS_RS(ctx->opcode));
int amount = (ctx->opcode >> 1) & 0x7;
uint32_t opc = 0;
amount = amount == 0 ? 8 : amount;
switch (ctx->opcode & 0x1) {
case SLL16:
opc = OPC_SLL;
break;
case SRL16:
opc = OPC_SRL;
break;
}
gen_shift_imm(ctx, opc, rd, rs, amount);
}
break;
case POOL16C:
gen_pool16c_insn(ctx);
break;
case LWGP16:
{
int rd = mmreg(uMIPS_RD(ctx->opcode));
int rb = 28;
int16_t offset = SIMM(ctx->opcode, 0, 7) << 2;
gen_ld(ctx, OPC_LW, rd, rb, offset);
}
break;
case POOL16F:
check_insn_opc_removed(ctx, ISA_MIPS32R6);
if (ctx->opcode & 1) {
generate_exception(ctx, EXCP_RI);
} else {
int enc_dest = uMIPS_RD(ctx->opcode);
int enc_rt = uMIPS_RS2(ctx->opcode);
int enc_rs = uMIPS_RS1(ctx->opcode);
int rd, rs, re, rt;
static const int rd_enc[] = { 5, 5, 6, 4, 4, 4, 4, 4 };
static const int re_enc[] = { 6, 7, 7, 21, 22, 5, 6, 7 };
static const int rs_rt_enc[] = { 0, 17, 2, 3, 16, 18, 19, 20 };
rd = rd_enc[enc_dest];
re = re_enc[enc_dest];
rs = rs_rt_enc[enc_rs];
rt = rs_rt_enc[enc_rt];
gen_arith(ctx, OPC_ADDU, rd, rs, 0);
gen_arith(ctx, OPC_ADDU, re, rt, 0);
}
break;
case LBU16:
{
int rd = mmreg(uMIPS_RD(ctx->opcode));
int rb = mmreg(uMIPS_RS(ctx->opcode));
int16_t offset = ZIMM(ctx->opcode, 0, 4);
offset = (offset == 0xf ? -1 : offset);
gen_ld(ctx, OPC_LBU, rd, rb, offset);
}
break;
case LHU16:
{
int rd = mmreg(uMIPS_RD(ctx->opcode));
int rb = mmreg(uMIPS_RS(ctx->opcode));
int16_t offset = ZIMM(ctx->opcode, 0, 4) << 1;
gen_ld(ctx, OPC_LHU, rd, rb, offset);
}
break;
case LWSP16:
{
int rd = (ctx->opcode >> 5) & 0x1f;
int rb = 29;
int16_t offset = ZIMM(ctx->opcode, 0, 5) << 2;
gen_ld(ctx, OPC_LW, rd, rb, offset);
}
break;
case LW16:
{
int rd = mmreg(uMIPS_RD(ctx->opcode));
int rb = mmreg(uMIPS_RS(ctx->opcode));
int16_t offset = ZIMM(ctx->opcode, 0, 4) << 2;
gen_ld(ctx, OPC_LW, rd, rb, offset);
}
break;
case SB16:
{
int rd = mmreg2(uMIPS_RD(ctx->opcode));
int rb = mmreg(uMIPS_RS(ctx->opcode));
int16_t offset = ZIMM(ctx->opcode, 0, 4);
gen_st(ctx, OPC_SB, rd, rb, offset);
}
break;
case SH16:
{
int rd = mmreg2(uMIPS_RD(ctx->opcode));
int rb = mmreg(uMIPS_RS(ctx->opcode));
int16_t offset = ZIMM(ctx->opcode, 0, 4) << 1;
gen_st(ctx, OPC_SH, rd, rb, offset);
}
break;
case SWSP16:
{
int rd = (ctx->opcode >> 5) & 0x1f;
int rb = 29;
int16_t offset = ZIMM(ctx->opcode, 0, 5) << 2;
gen_st(ctx, OPC_SW, rd, rb, offset);
}
break;
case SW16:
{
int rd = mmreg2(uMIPS_RD(ctx->opcode));
int rb = mmreg(uMIPS_RS(ctx->opcode));
int16_t offset = ZIMM(ctx->opcode, 0, 4) << 2;
gen_st(ctx, OPC_SW, rd, rb, offset);
}
break;
case MOVE16:
{
int rd = uMIPS_RD5(ctx->opcode);
int rs = uMIPS_RS5(ctx->opcode);
gen_arith(ctx, OPC_ADDU, rd, rs, 0);
}
break;
case ANDI16:
gen_andi16(ctx);
break;
case POOL16D:
switch (ctx->opcode & 0x1) {
case ADDIUS5:
gen_addius5(ctx);
break;
case ADDIUSP:
gen_addiusp(ctx);
break;
}
break;
case POOL16E:
switch (ctx->opcode & 0x1) {
case ADDIUR2:
gen_addiur2(ctx);
break;
case ADDIUR1SP:
gen_addiur1sp(ctx);
break;
}
break;
case B16:
gen_compute_branch(ctx, OPC_BEQ, 2, 0, 0,
SIMM(ctx->opcode, 0, 10) << 1, 4);
break;
case BNEZ16:
case BEQZ16:
gen_compute_branch(ctx, op == BNEZ16 ? OPC_BNE : OPC_BEQ, 2,
mmreg(uMIPS_RD(ctx->opcode)),
0, SIMM(ctx->opcode, 0, 7) << 1, 4);
break;
case LI16:
{
int reg = mmreg(uMIPS_RD(ctx->opcode));
int imm = ZIMM(ctx->opcode, 0, 7);
imm = (imm == 0x7f ? -1 : imm);
tcg_gen_movi_tl(cpu_gpr[reg], imm);
}
break;
case RES_20:
case RES_28:
case RES_29:
case RES_30:
case RES_31:
case RES_38:
case RES_39:
generate_exception(ctx, EXCP_RI);
break;
default:
decode_micromips32_opc(env, ctx);
return 4;
}
return 2;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0 (CPUMIPSState *VAR_0, DisasContext *VAR_1)
{
uint32_t op;
if (VAR_1->pc & 0x1) {
VAR_0->CP0_BadVAddr = VAR_1->pc;
generate_exception(VAR_1, EXCP_AdEL);
VAR_1->bstate = BS_STOP;
return 2;
}
op = (VAR_1->opcode >> 10) & 0x3f;
if (VAR_1->hflags & MIPS_HFLAG_BDS_STRICT) {
switch (op & 0x7) {
case 0:
case 4:
case 5:
case 6:
case 7:
if (VAR_1->hflags & MIPS_HFLAG_BDS16) {
generate_exception(VAR_1, EXCP_RI);
VAR_1->bstate = BS_STOP;
return 2;
}
break;
case 1:
case 2:
case 3:
if (VAR_1->hflags & MIPS_HFLAG_BDS32) {
generate_exception(VAR_1, EXCP_RI);
VAR_1->bstate = BS_STOP;
return 2;
}
break;
}
}
switch (op) {
case POOL16A:
{
int VAR_16 = mmreg(uMIPS_RD(VAR_1->opcode));
int VAR_3 = mmreg(uMIPS_RS1(VAR_1->opcode));
int VAR_4 = mmreg(uMIPS_RS2(VAR_1->opcode));
uint32_t opc = 0;
switch (VAR_1->opcode & 0x1) {
case ADDU16:
opc = OPC_ADDU;
break;
case SUBU16:
opc = OPC_SUBU;
break;
}
gen_arith(VAR_1, opc, VAR_16, VAR_3, VAR_4);
}
break;
case POOL16B:
{
int VAR_16 = mmreg(uMIPS_RD(VAR_1->opcode));
int VAR_16 = mmreg(uMIPS_RS(VAR_1->opcode));
int VAR_6 = (VAR_1->opcode >> 1) & 0x7;
uint32_t opc = 0;
VAR_6 = VAR_6 == 0 ? 8 : VAR_6;
switch (VAR_1->opcode & 0x1) {
case SLL16:
opc = OPC_SLL;
break;
case SRL16:
opc = OPC_SRL;
break;
}
gen_shift_imm(VAR_1, opc, VAR_16, VAR_16, VAR_6);
}
break;
case POOL16C:
gen_pool16c_insn(VAR_1);
break;
case LWGP16:
{
int VAR_16 = mmreg(uMIPS_RD(VAR_1->opcode));
int VAR_16 = 28;
int16_t offset = SIMM(VAR_1->opcode, 0, 7) << 2;
gen_ld(VAR_1, OPC_LW, VAR_16, VAR_16, offset);
}
break;
case POOL16F:
check_insn_opc_removed(VAR_1, ISA_MIPS32R6);
if (VAR_1->opcode & 1) {
generate_exception(VAR_1, EXCP_RI);
} else {
int VAR_8 = uMIPS_RD(VAR_1->opcode);
int VAR_9 = uMIPS_RS2(VAR_1->opcode);
int VAR_10 = uMIPS_RS1(VAR_1->opcode);
int VAR_16, VAR_16, VAR_11, VAR_12;
static const int VAR_13[] = { 5, 5, 6, 4, 4, 4, 4, 4 };
static const int VAR_14[] = { 6, 7, 7, 21, 22, 5, 6, 7 };
static const int VAR_15[] = { 0, 17, 2, 3, 16, 18, 19, 20 };
VAR_16 = VAR_13[VAR_8];
VAR_11 = VAR_14[VAR_8];
VAR_16 = VAR_15[VAR_10];
VAR_12 = VAR_15[VAR_9];
gen_arith(VAR_1, OPC_ADDU, VAR_16, VAR_16, 0);
gen_arith(VAR_1, OPC_ADDU, VAR_11, VAR_12, 0);
}
break;
case LBU16:
{
int VAR_16 = mmreg(uMIPS_RD(VAR_1->opcode));
int VAR_16 = mmreg(uMIPS_RS(VAR_1->opcode));
int16_t offset = ZIMM(VAR_1->opcode, 0, 4);
offset = (offset == 0xf ? -1 : offset);
gen_ld(VAR_1, OPC_LBU, VAR_16, VAR_16, offset);
}
break;
case LHU16:
{
int VAR_16 = mmreg(uMIPS_RD(VAR_1->opcode));
int VAR_16 = mmreg(uMIPS_RS(VAR_1->opcode));
int16_t offset = ZIMM(VAR_1->opcode, 0, 4) << 1;
gen_ld(VAR_1, OPC_LHU, VAR_16, VAR_16, offset);
}
break;
case LWSP16:
{
int VAR_16 = (VAR_1->opcode >> 5) & 0x1f;
int VAR_16 = 29;
int16_t offset = ZIMM(VAR_1->opcode, 0, 5) << 2;
gen_ld(VAR_1, OPC_LW, VAR_16, VAR_16, offset);
}
break;
case LW16:
{
int VAR_16 = mmreg(uMIPS_RD(VAR_1->opcode));
int VAR_16 = mmreg(uMIPS_RS(VAR_1->opcode));
int16_t offset = ZIMM(VAR_1->opcode, 0, 4) << 2;
gen_ld(VAR_1, OPC_LW, VAR_16, VAR_16, offset);
}
break;
case SB16:
{
int VAR_16 = mmreg2(uMIPS_RD(VAR_1->opcode));
int VAR_16 = mmreg(uMIPS_RS(VAR_1->opcode));
int16_t offset = ZIMM(VAR_1->opcode, 0, 4);
gen_st(VAR_1, OPC_SB, VAR_16, VAR_16, offset);
}
break;
case SH16:
{
int VAR_16 = mmreg2(uMIPS_RD(VAR_1->opcode));
int VAR_16 = mmreg(uMIPS_RS(VAR_1->opcode));
int16_t offset = ZIMM(VAR_1->opcode, 0, 4) << 1;
gen_st(VAR_1, OPC_SH, VAR_16, VAR_16, offset);
}
break;
case SWSP16:
{
int VAR_16 = (VAR_1->opcode >> 5) & 0x1f;
int VAR_16 = 29;
int16_t offset = ZIMM(VAR_1->opcode, 0, 5) << 2;
gen_st(VAR_1, OPC_SW, VAR_16, VAR_16, offset);
}
break;
case SW16:
{
int VAR_16 = mmreg2(uMIPS_RD(VAR_1->opcode));
int VAR_16 = mmreg(uMIPS_RS(VAR_1->opcode));
int16_t offset = ZIMM(VAR_1->opcode, 0, 4) << 2;
gen_st(VAR_1, OPC_SW, VAR_16, VAR_16, offset);
}
break;
case MOVE16:
{
int VAR_16 = uMIPS_RD5(VAR_1->opcode);
int VAR_16 = uMIPS_RS5(VAR_1->opcode);
gen_arith(VAR_1, OPC_ADDU, VAR_16, VAR_16, 0);
}
break;
case ANDI16:
gen_andi16(VAR_1);
break;
case POOL16D:
switch (VAR_1->opcode & 0x1) {
case ADDIUS5:
gen_addius5(VAR_1);
break;
case ADDIUSP:
gen_addiusp(VAR_1);
break;
}
break;
case POOL16E:
switch (VAR_1->opcode & 0x1) {
case ADDIUR2:
gen_addiur2(VAR_1);
break;
case ADDIUR1SP:
gen_addiur1sp(VAR_1);
break;
}
break;
case B16:
gen_compute_branch(VAR_1, OPC_BEQ, 2, 0, 0,
SIMM(VAR_1->opcode, 0, 10) << 1, 4);
break;
case BNEZ16:
case BEQZ16:
gen_compute_branch(VAR_1, op == BNEZ16 ? OPC_BNE : OPC_BEQ, 2,
mmreg(uMIPS_RD(VAR_1->opcode)),
0, SIMM(VAR_1->opcode, 0, 7) << 1, 4);
break;
case LI16:
{
int VAR_16 = mmreg(uMIPS_RD(VAR_1->opcode));
int VAR_17 = ZIMM(VAR_1->opcode, 0, 7);
VAR_17 = (VAR_17 == 0x7f ? -1 : VAR_17);
tcg_gen_movi_tl(cpu_gpr[VAR_16], VAR_17);
}
break;
case RES_20:
case RES_28:
case RES_29:
case RES_30:
case RES_31:
case RES_38:
case RES_39:
generate_exception(VAR_1, EXCP_RI);
break;
default:
decode_micromips32_opc(VAR_0, VAR_1);
return 4;
}
return 2;
}
| [
"static int FUNC_0 (CPUMIPSState *VAR_0, DisasContext *VAR_1)\n{",
"uint32_t op;",
"if (VAR_1->pc & 0x1) {",
"VAR_0->CP0_BadVAddr = VAR_1->pc;",
"generate_exception(VAR_1, EXCP_AdEL);",
"VAR_1->bstate = BS_STOP;",
"return 2;",
"}",
"op = (VAR_1->opcode >> 10) & 0x3f;",
"if (VAR_1->hflags & MIPS_HF... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
33,
37,
41,
45,
49,
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
... |
9,558 | static void ratelimit_set_speed(RateLimit *limit, uint64_t speed)
{
limit->slice_quota = speed / (1000000000ULL / SLICE_TIME);
}
| false | qemu | 6ef228fc0de1d5fb43ebfef039563d39a3a37067 | static void ratelimit_set_speed(RateLimit *limit, uint64_t speed)
{
limit->slice_quota = speed / (1000000000ULL / SLICE_TIME);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(RateLimit *VAR_0, uint64_t VAR_1)
{
VAR_0->slice_quota = VAR_1 / (1000000000ULL / SLICE_TIME);
}
| [
"static void FUNC_0(RateLimit *VAR_0, uint64_t VAR_1)\n{",
"VAR_0->slice_quota = VAR_1 / (1000000000ULL / SLICE_TIME);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
9,559 | static void tap_update_fd_handler(TAPState *s)
{
qemu_set_fd_handler2(s->fd,
s->read_poll && s->enabled ? tap_can_send : NULL,
s->read_poll && s->enabled ? tap_send : NULL,
s->write_poll && s->enabled ? tap_writable : NULL,
s);
}
| false | qemu | a90a7425cf592a3afeff3eaf32f543b83050ee5c | static void tap_update_fd_handler(TAPState *s)
{
qemu_set_fd_handler2(s->fd,
s->read_poll && s->enabled ? tap_can_send : NULL,
s->read_poll && s->enabled ? tap_send : NULL,
s->write_poll && s->enabled ? tap_writable : NULL,
s);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TAPState *VAR_0)
{
qemu_set_fd_handler2(VAR_0->fd,
VAR_0->read_poll && VAR_0->enabled ? tap_can_send : NULL,
VAR_0->read_poll && VAR_0->enabled ? tap_send : NULL,
VAR_0->write_poll && VAR_0->enabled ? tap_writable : NULL,
VAR_0);
}
| [
"static void FUNC_0(TAPState *VAR_0)\n{",
"qemu_set_fd_handler2(VAR_0->fd,\nVAR_0->read_poll && VAR_0->enabled ? tap_can_send : NULL,\nVAR_0->read_poll && VAR_0->enabled ? tap_send : NULL,\nVAR_0->write_poll && VAR_0->enabled ? tap_writable : NULL,\nVAR_0);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5,
7,
9,
11,
13
],
[
15
]
] |
9,560 | static void pc_init1(ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
const char *cpu_model,
int pci_enabled)
{
char *filename;
int ret, linux_boot, i;
ram_addr_t ram_addr, bios_offset, option_rom_offset;
ram_addr_t below_4g_mem_size, above_4g_mem_size = 0;
int bios_size, isa_bios_size;
PCIBus *pci_bus;
ISADevice *isa_dev;
int piix3_devfn = -1;
CPUState *env;
qemu_irq *cpu_irq;
qemu_irq *isa_irq;
qemu_irq *i8259;
IsaIrqState *isa_irq_state;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *fd[MAX_FD];
void *fw_cfg;
if (ram_size >= 0xe0000000 ) {
above_4g_mem_size = ram_size - 0xe0000000;
below_4g_mem_size = 0xe0000000;
} else {
below_4g_mem_size = ram_size;
}
linux_boot = (kernel_filename != NULL);
/* init CPUs */
if (cpu_model == NULL) {
#ifdef TARGET_X86_64
cpu_model = "qemu64";
#else
cpu_model = "qemu32";
#endif
}
for (i = 0; i < smp_cpus; i++) {
env = pc_new_cpu(cpu_model);
}
vmport_init();
/* allocate RAM */
ram_addr = qemu_ram_alloc(0xa0000);
cpu_register_physical_memory(0, 0xa0000, ram_addr);
/* Allocate, even though we won't register, so we don't break the
* phys_ram_base + PA assumption. This range includes vga (0xa0000 - 0xc0000),
* and some bios areas, which will be registered later
*/
ram_addr = qemu_ram_alloc(0x100000 - 0xa0000);
ram_addr = qemu_ram_alloc(below_4g_mem_size - 0x100000);
cpu_register_physical_memory(0x100000,
below_4g_mem_size - 0x100000,
ram_addr);
/* above 4giga memory allocation */
if (above_4g_mem_size > 0) {
#if TARGET_PHYS_ADDR_BITS == 32
hw_error("To much RAM for 32-bit physical address");
#else
ram_addr = qemu_ram_alloc(above_4g_mem_size);
cpu_register_physical_memory(0x100000000ULL,
above_4g_mem_size,
ram_addr);
#endif
}
/* BIOS load */
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = get_image_size(filename);
} else {
bios_size = -1;
}
if (bios_size <= 0 ||
(bios_size % 65536) != 0) {
goto bios_error;
}
bios_offset = qemu_ram_alloc(bios_size);
ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size));
if (ret != 0) {
bios_error:
fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name);
exit(1);
}
if (filename) {
qemu_free(filename);
}
/* map the last 128KB of the BIOS in ISA space */
isa_bios_size = bios_size;
if (isa_bios_size > (128 * 1024))
isa_bios_size = 128 * 1024;
cpu_register_physical_memory(0x100000 - isa_bios_size,
isa_bios_size,
(bios_offset + bios_size - isa_bios_size) | IO_MEM_ROM);
rom_enable_driver_roms = 1;
option_rom_offset = qemu_ram_alloc(PC_ROM_SIZE);
cpu_register_physical_memory(PC_ROM_MIN_VGA, PC_ROM_SIZE, option_rom_offset);
/* map all the bios at the top of memory */
cpu_register_physical_memory((uint32_t)(-bios_size),
bios_size, bios_offset | IO_MEM_ROM);
fw_cfg = bochs_bios_init();
if (linux_boot) {
load_linux(fw_cfg, kernel_filename, initrd_filename, kernel_cmdline, below_4g_mem_size);
}
for (i = 0; i < nb_option_roms; i++) {
rom_add_option(option_rom[i]);
}
cpu_irq = qemu_allocate_irqs(pic_irq_request, NULL, 1);
i8259 = i8259_init(cpu_irq[0]);
isa_irq_state = qemu_mallocz(sizeof(*isa_irq_state));
isa_irq_state->i8259 = i8259;
isa_irq = qemu_allocate_irqs(isa_irq_handler, isa_irq_state, 24);
if (pci_enabled) {
pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, isa_irq);
} else {
pci_bus = NULL;
isa_bus_new(NULL);
}
isa_bus_irqs(isa_irq);
ferr_irq = isa_reserve_irq(13);
/* init basic PC hardware */
register_ioport_write(0x80, 1, 1, ioport80_write, NULL);
register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL);
if (cirrus_vga_enabled) {
if (pci_enabled) {
pci_cirrus_vga_init(pci_bus);
} else {
isa_cirrus_vga_init();
}
} else if (vmsvga_enabled) {
if (pci_enabled)
pci_vmsvga_init(pci_bus);
else
fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION__);
} else if (std_vga_enabled) {
if (pci_enabled) {
pci_vga_init(pci_bus, 0, 0);
} else {
isa_vga_init();
}
}
rtc_state = rtc_init(2000);
qemu_register_boot_set(pc_boot_set, rtc_state);
register_ioport_read(0x92, 1, 1, ioport92_read, NULL);
register_ioport_write(0x92, 1, 1, ioport92_write, NULL);
if (pci_enabled) {
isa_irq_state->ioapic = ioapic_init();
}
pit = pit_init(0x40, isa_reserve_irq(0));
pcspk_init(pit);
if (!no_hpet) {
hpet_init(isa_irq);
}
for(i = 0; i < MAX_SERIAL_PORTS; i++) {
if (serial_hds[i]) {
serial_isa_init(i, serial_hds[i]);
}
}
for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
if (parallel_hds[i]) {
parallel_init(i, parallel_hds[i]);
}
}
for(i = 0; i < nb_nics; i++) {
NICInfo *nd = &nd_table[i];
if (!pci_enabled || (nd->model && strcmp(nd->model, "ne2k_isa") == 0))
pc_init_ne2k_isa(nd);
else
pci_nic_init_nofail(nd, "e1000", NULL);
}
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
fprintf(stderr, "qemu: too many IDE bus\n");
exit(1);
}
for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) {
hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS);
}
if (pci_enabled) {
pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
} else {
for(i = 0; i < MAX_IDE_BUS; i++) {
isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i],
hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
}
}
isa_dev = isa_create_simple("i8042");
DMA_init(0);
#ifdef HAS_AUDIO
audio_init(pci_enabled ? pci_bus : NULL, isa_irq);
#endif
for(i = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
}
floppy_controller = fdctrl_init_isa(fd);
cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device, hd);
if (pci_enabled && usb_enabled) {
usb_uhci_piix3_init(pci_bus, piix3_devfn + 2);
}
if (pci_enabled && acpi_enabled) {
uint8_t *eeprom_buf = qemu_mallocz(8 * 256); /* XXX: make this persistent */
i2c_bus *smbus;
/* TODO: Populate SPD eeprom data. */
smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
isa_reserve_irq(9));
for (i = 0; i < 8; i++) {
DeviceState *eeprom;
eeprom = qdev_create((BusState *)smbus, "smbus-eeprom");
qdev_prop_set_uint8(eeprom, "address", 0x50 + i);
qdev_prop_set_ptr(eeprom, "data", eeprom_buf + (i * 256));
qdev_init_nofail(eeprom);
}
piix4_acpi_system_hot_add_init(pci_bus);
}
if (i440fx_state) {
i440fx_init_memory_mappings(i440fx_state);
}
if (pci_enabled) {
int max_bus;
int bus;
max_bus = drive_get_max_bus(IF_SCSI);
for (bus = 0; bus <= max_bus; bus++) {
pci_create_simple(pci_bus, -1, "lsi53c895a");
}
}
/* Add virtio console devices */
if (pci_enabled) {
for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) {
if (virtcon_hds[i]) {
pci_create_simple(pci_bus, -1, "virtio-console-pci");
}
}
}
rom_load_fw(fw_cfg);
}
| false | qemu | 8832cb805dcb65009b979cd8e17d75ac4b03c7e4 | static void pc_init1(ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
const char *cpu_model,
int pci_enabled)
{
char *filename;
int ret, linux_boot, i;
ram_addr_t ram_addr, bios_offset, option_rom_offset;
ram_addr_t below_4g_mem_size, above_4g_mem_size = 0;
int bios_size, isa_bios_size;
PCIBus *pci_bus;
ISADevice *isa_dev;
int piix3_devfn = -1;
CPUState *env;
qemu_irq *cpu_irq;
qemu_irq *isa_irq;
qemu_irq *i8259;
IsaIrqState *isa_irq_state;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *fd[MAX_FD];
void *fw_cfg;
if (ram_size >= 0xe0000000 ) {
above_4g_mem_size = ram_size - 0xe0000000;
below_4g_mem_size = 0xe0000000;
} else {
below_4g_mem_size = ram_size;
}
linux_boot = (kernel_filename != NULL);
if (cpu_model == NULL) {
#ifdef TARGET_X86_64
cpu_model = "qemu64";
#else
cpu_model = "qemu32";
#endif
}
for (i = 0; i < smp_cpus; i++) {
env = pc_new_cpu(cpu_model);
}
vmport_init();
ram_addr = qemu_ram_alloc(0xa0000);
cpu_register_physical_memory(0, 0xa0000, ram_addr);
ram_addr = qemu_ram_alloc(0x100000 - 0xa0000);
ram_addr = qemu_ram_alloc(below_4g_mem_size - 0x100000);
cpu_register_physical_memory(0x100000,
below_4g_mem_size - 0x100000,
ram_addr);
if (above_4g_mem_size > 0) {
#if TARGET_PHYS_ADDR_BITS == 32
hw_error("To much RAM for 32-bit physical address");
#else
ram_addr = qemu_ram_alloc(above_4g_mem_size);
cpu_register_physical_memory(0x100000000ULL,
above_4g_mem_size,
ram_addr);
#endif
}
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = get_image_size(filename);
} else {
bios_size = -1;
}
if (bios_size <= 0 ||
(bios_size % 65536) != 0) {
goto bios_error;
}
bios_offset = qemu_ram_alloc(bios_size);
ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size));
if (ret != 0) {
bios_error:
fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name);
exit(1);
}
if (filename) {
qemu_free(filename);
}
isa_bios_size = bios_size;
if (isa_bios_size > (128 * 1024))
isa_bios_size = 128 * 1024;
cpu_register_physical_memory(0x100000 - isa_bios_size,
isa_bios_size,
(bios_offset + bios_size - isa_bios_size) | IO_MEM_ROM);
rom_enable_driver_roms = 1;
option_rom_offset = qemu_ram_alloc(PC_ROM_SIZE);
cpu_register_physical_memory(PC_ROM_MIN_VGA, PC_ROM_SIZE, option_rom_offset);
cpu_register_physical_memory((uint32_t)(-bios_size),
bios_size, bios_offset | IO_MEM_ROM);
fw_cfg = bochs_bios_init();
if (linux_boot) {
load_linux(fw_cfg, kernel_filename, initrd_filename, kernel_cmdline, below_4g_mem_size);
}
for (i = 0; i < nb_option_roms; i++) {
rom_add_option(option_rom[i]);
}
cpu_irq = qemu_allocate_irqs(pic_irq_request, NULL, 1);
i8259 = i8259_init(cpu_irq[0]);
isa_irq_state = qemu_mallocz(sizeof(*isa_irq_state));
isa_irq_state->i8259 = i8259;
isa_irq = qemu_allocate_irqs(isa_irq_handler, isa_irq_state, 24);
if (pci_enabled) {
pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, isa_irq);
} else {
pci_bus = NULL;
isa_bus_new(NULL);
}
isa_bus_irqs(isa_irq);
ferr_irq = isa_reserve_irq(13);
register_ioport_write(0x80, 1, 1, ioport80_write, NULL);
register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL);
if (cirrus_vga_enabled) {
if (pci_enabled) {
pci_cirrus_vga_init(pci_bus);
} else {
isa_cirrus_vga_init();
}
} else if (vmsvga_enabled) {
if (pci_enabled)
pci_vmsvga_init(pci_bus);
else
fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION__);
} else if (std_vga_enabled) {
if (pci_enabled) {
pci_vga_init(pci_bus, 0, 0);
} else {
isa_vga_init();
}
}
rtc_state = rtc_init(2000);
qemu_register_boot_set(pc_boot_set, rtc_state);
register_ioport_read(0x92, 1, 1, ioport92_read, NULL);
register_ioport_write(0x92, 1, 1, ioport92_write, NULL);
if (pci_enabled) {
isa_irq_state->ioapic = ioapic_init();
}
pit = pit_init(0x40, isa_reserve_irq(0));
pcspk_init(pit);
if (!no_hpet) {
hpet_init(isa_irq);
}
for(i = 0; i < MAX_SERIAL_PORTS; i++) {
if (serial_hds[i]) {
serial_isa_init(i, serial_hds[i]);
}
}
for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
if (parallel_hds[i]) {
parallel_init(i, parallel_hds[i]);
}
}
for(i = 0; i < nb_nics; i++) {
NICInfo *nd = &nd_table[i];
if (!pci_enabled || (nd->model && strcmp(nd->model, "ne2k_isa") == 0))
pc_init_ne2k_isa(nd);
else
pci_nic_init_nofail(nd, "e1000", NULL);
}
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
fprintf(stderr, "qemu: too many IDE bus\n");
exit(1);
}
for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) {
hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS);
}
if (pci_enabled) {
pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
} else {
for(i = 0; i < MAX_IDE_BUS; i++) {
isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i],
hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
}
}
isa_dev = isa_create_simple("i8042");
DMA_init(0);
#ifdef HAS_AUDIO
audio_init(pci_enabled ? pci_bus : NULL, isa_irq);
#endif
for(i = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
}
floppy_controller = fdctrl_init_isa(fd);
cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device, hd);
if (pci_enabled && usb_enabled) {
usb_uhci_piix3_init(pci_bus, piix3_devfn + 2);
}
if (pci_enabled && acpi_enabled) {
uint8_t *eeprom_buf = qemu_mallocz(8 * 256);
i2c_bus *smbus;
smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
isa_reserve_irq(9));
for (i = 0; i < 8; i++) {
DeviceState *eeprom;
eeprom = qdev_create((BusState *)smbus, "smbus-eeprom");
qdev_prop_set_uint8(eeprom, "address", 0x50 + i);
qdev_prop_set_ptr(eeprom, "data", eeprom_buf + (i * 256));
qdev_init_nofail(eeprom);
}
piix4_acpi_system_hot_add_init(pci_bus);
}
if (i440fx_state) {
i440fx_init_memory_mappings(i440fx_state);
}
if (pci_enabled) {
int max_bus;
int bus;
max_bus = drive_get_max_bus(IF_SCSI);
for (bus = 0; bus <= max_bus; bus++) {
pci_create_simple(pci_bus, -1, "lsi53c895a");
}
}
if (pci_enabled) {
for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) {
if (virtcon_hds[i]) {
pci_create_simple(pci_bus, -1, "virtio-console-pci");
}
}
}
rom_load_fw(fw_cfg);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(ram_addr_t VAR_0,
const char *VAR_1,
const char *VAR_2,
const char *VAR_3,
const char *VAR_4,
const char *VAR_5,
int VAR_6)
{
char *VAR_7;
int VAR_8, VAR_9, VAR_10;
ram_addr_t ram_addr, bios_offset, option_rom_offset;
ram_addr_t below_4g_mem_size, above_4g_mem_size = 0;
int VAR_11, VAR_12;
PCIBus *pci_bus;
ISADevice *isa_dev;
int VAR_13 = -1;
CPUState *env;
qemu_irq *cpu_irq;
qemu_irq *isa_irq;
qemu_irq *i8259;
IsaIrqState *isa_irq_state;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *fd[MAX_FD];
void *VAR_14;
if (VAR_0 >= 0xe0000000 ) {
above_4g_mem_size = VAR_0 - 0xe0000000;
below_4g_mem_size = 0xe0000000;
} else {
below_4g_mem_size = VAR_0;
}
VAR_9 = (VAR_2 != NULL);
if (VAR_5 == NULL) {
#ifdef TARGET_X86_64
VAR_5 = "qemu64";
#else
VAR_5 = "qemu32";
#endif
}
for (VAR_10 = 0; VAR_10 < smp_cpus; VAR_10++) {
env = pc_new_cpu(VAR_5);
}
vmport_init();
ram_addr = qemu_ram_alloc(0xa0000);
cpu_register_physical_memory(0, 0xa0000, ram_addr);
ram_addr = qemu_ram_alloc(0x100000 - 0xa0000);
ram_addr = qemu_ram_alloc(below_4g_mem_size - 0x100000);
cpu_register_physical_memory(0x100000,
below_4g_mem_size - 0x100000,
ram_addr);
if (above_4g_mem_size > 0) {
#if TARGET_PHYS_ADDR_BITS == 32
hw_error("To much RAM for 32-bit physical address");
#else
ram_addr = qemu_ram_alloc(above_4g_mem_size);
cpu_register_physical_memory(0x100000000ULL,
above_4g_mem_size,
ram_addr);
#endif
}
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
VAR_7 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (VAR_7) {
VAR_11 = get_image_size(VAR_7);
} else {
VAR_11 = -1;
}
if (VAR_11 <= 0 ||
(VAR_11 % 65536) != 0) {
goto bios_error;
}
bios_offset = qemu_ram_alloc(VAR_11);
VAR_8 = rom_add_file_fixed(bios_name, (uint32_t)(-VAR_11));
if (VAR_8 != 0) {
bios_error:
fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name);
exit(1);
}
if (VAR_7) {
qemu_free(VAR_7);
}
VAR_12 = VAR_11;
if (VAR_12 > (128 * 1024))
VAR_12 = 128 * 1024;
cpu_register_physical_memory(0x100000 - VAR_12,
VAR_12,
(bios_offset + VAR_11 - VAR_12) | IO_MEM_ROM);
rom_enable_driver_roms = 1;
option_rom_offset = qemu_ram_alloc(PC_ROM_SIZE);
cpu_register_physical_memory(PC_ROM_MIN_VGA, PC_ROM_SIZE, option_rom_offset);
cpu_register_physical_memory((uint32_t)(-VAR_11),
VAR_11, bios_offset | IO_MEM_ROM);
VAR_14 = bochs_bios_init();
if (VAR_9) {
load_linux(VAR_14, VAR_2, VAR_4, VAR_3, below_4g_mem_size);
}
for (VAR_10 = 0; VAR_10 < nb_option_roms; VAR_10++) {
rom_add_option(option_rom[VAR_10]);
}
cpu_irq = qemu_allocate_irqs(pic_irq_request, NULL, 1);
i8259 = i8259_init(cpu_irq[0]);
isa_irq_state = qemu_mallocz(sizeof(*isa_irq_state));
isa_irq_state->i8259 = i8259;
isa_irq = qemu_allocate_irqs(isa_irq_handler, isa_irq_state, 24);
if (VAR_6) {
pci_bus = i440fx_init(&i440fx_state, &VAR_13, isa_irq);
} else {
pci_bus = NULL;
isa_bus_new(NULL);
}
isa_bus_irqs(isa_irq);
ferr_irq = isa_reserve_irq(13);
register_ioport_write(0x80, 1, 1, ioport80_write, NULL);
register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL);
if (cirrus_vga_enabled) {
if (VAR_6) {
pci_cirrus_vga_init(pci_bus);
} else {
isa_cirrus_vga_init();
}
} else if (vmsvga_enabled) {
if (VAR_6)
pci_vmsvga_init(pci_bus);
else
fprintf(stderr, "%s: vmware_vga: no PCI VAR_16\n", __FUNCTION__);
} else if (std_vga_enabled) {
if (VAR_6) {
pci_vga_init(pci_bus, 0, 0);
} else {
isa_vga_init();
}
}
rtc_state = rtc_init(2000);
qemu_register_boot_set(pc_boot_set, rtc_state);
register_ioport_read(0x92, 1, 1, ioport92_read, NULL);
register_ioport_write(0x92, 1, 1, ioport92_write, NULL);
if (VAR_6) {
isa_irq_state->ioapic = ioapic_init();
}
pit = pit_init(0x40, isa_reserve_irq(0));
pcspk_init(pit);
if (!no_hpet) {
hpet_init(isa_irq);
}
for(VAR_10 = 0; VAR_10 < MAX_SERIAL_PORTS; VAR_10++) {
if (serial_hds[VAR_10]) {
serial_isa_init(VAR_10, serial_hds[VAR_10]);
}
}
for(VAR_10 = 0; VAR_10 < MAX_PARALLEL_PORTS; VAR_10++) {
if (parallel_hds[VAR_10]) {
parallel_init(VAR_10, parallel_hds[VAR_10]);
}
}
for(VAR_10 = 0; VAR_10 < nb_nics; VAR_10++) {
NICInfo *nd = &nd_table[VAR_10];
if (!VAR_6 || (nd->model && strcmp(nd->model, "ne2k_isa") == 0))
pc_init_ne2k_isa(nd);
else
pci_nic_init_nofail(nd, "e1000", NULL);
}
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
fprintf(stderr, "qemu: too many IDE VAR_16\n");
exit(1);
}
for(VAR_10 = 0; VAR_10 < MAX_IDE_BUS * MAX_IDE_DEVS; VAR_10++) {
hd[VAR_10] = drive_get(IF_IDE, VAR_10 / MAX_IDE_DEVS, VAR_10 % MAX_IDE_DEVS);
}
if (VAR_6) {
pci_piix3_ide_init(pci_bus, hd, VAR_13 + 1);
} else {
for(VAR_10 = 0; VAR_10 < MAX_IDE_BUS; VAR_10++) {
isa_ide_init(ide_iobase[VAR_10], ide_iobase2[VAR_10], ide_irq[VAR_10],
hd[MAX_IDE_DEVS * VAR_10], hd[MAX_IDE_DEVS * VAR_10 + 1]);
}
}
isa_dev = isa_create_simple("i8042");
DMA_init(0);
#ifdef HAS_AUDIO
audio_init(VAR_6 ? pci_bus : NULL, isa_irq);
#endif
for(VAR_10 = 0; VAR_10 < MAX_FD; VAR_10++) {
fd[VAR_10] = drive_get(IF_FLOPPY, 0, VAR_10);
}
floppy_controller = fdctrl_init_isa(fd);
cmos_init(below_4g_mem_size, above_4g_mem_size, VAR_1, hd);
if (VAR_6 && usb_enabled) {
usb_uhci_piix3_init(pci_bus, VAR_13 + 2);
}
if (VAR_6 && acpi_enabled) {
uint8_t *eeprom_buf = qemu_mallocz(8 * 256);
i2c_bus *smbus;
smbus = piix4_pm_init(pci_bus, VAR_13 + 3, 0xb100,
isa_reserve_irq(9));
for (VAR_10 = 0; VAR_10 < 8; VAR_10++) {
DeviceState *eeprom;
eeprom = qdev_create((BusState *)smbus, "smbus-eeprom");
qdev_prop_set_uint8(eeprom, "address", 0x50 + VAR_10);
qdev_prop_set_ptr(eeprom, "data", eeprom_buf + (VAR_10 * 256));
qdev_init_nofail(eeprom);
}
piix4_acpi_system_hot_add_init(pci_bus);
}
if (i440fx_state) {
i440fx_init_memory_mappings(i440fx_state);
}
if (VAR_6) {
int VAR_15;
int VAR_16;
VAR_15 = drive_get_max_bus(IF_SCSI);
for (VAR_16 = 0; VAR_16 <= VAR_15; VAR_16++) {
pci_create_simple(pci_bus, -1, "lsi53c895a");
}
}
if (VAR_6) {
for(VAR_10 = 0; VAR_10 < MAX_VIRTIO_CONSOLES; VAR_10++) {
if (virtcon_hds[VAR_10]) {
pci_create_simple(pci_bus, -1, "virtio-console-pci");
}
}
}
rom_load_fw(VAR_14);
}
| [
"static void FUNC_0(ram_addr_t VAR_0,\nconst char *VAR_1,\nconst char *VAR_2,\nconst char *VAR_3,\nconst char *VAR_4,\nconst char *VAR_5,\nint VAR_6)\n{",
"char *VAR_7;",
"int VAR_8, VAR_9, VAR_10;",
"ram_addr_t ram_addr, bios_offset, option_rom_offset;",
"ram_addr_t below_4g_mem_size, above_4g_mem_size = 0... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
... |
9,561 | static void dec_mul(DisasContext *dc)
{
TCGv d[2];
unsigned int subcode;
if ((dc->tb_flags & MSR_EE_FLAG)
&& !(dc->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK)
&& !(dc->env->pvr.regs[0] & PVR0_USE_HW_MUL_MASK)) {
tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP);
t_gen_raise_exception(dc, EXCP_HW_EXCP);
return;
}
subcode = dc->imm & 3;
d[0] = tcg_temp_new();
d[1] = tcg_temp_new();
if (dc->type_b) {
LOG_DIS("muli r%d r%d %x\n", dc->rd, dc->ra, dc->imm);
t_gen_mulu(cpu_R[dc->rd], d[1], cpu_R[dc->ra], *(dec_alu_op_b(dc)));
goto done;
}
/* mulh, mulhsu and mulhu are not available if C_USE_HW_MUL is < 2. */
if (subcode >= 1 && subcode <= 3
&& !((dc->env->pvr.regs[2] & PVR2_USE_MUL64_MASK))) {
/* nop??? */
}
switch (subcode) {
case 0:
LOG_DIS("mul r%d r%d r%d\n", dc->rd, dc->ra, dc->rb);
t_gen_mulu(cpu_R[dc->rd], d[1], cpu_R[dc->ra], cpu_R[dc->rb]);
break;
case 1:
LOG_DIS("mulh r%d r%d r%d\n", dc->rd, dc->ra, dc->rb);
t_gen_muls(d[0], cpu_R[dc->rd], cpu_R[dc->ra], cpu_R[dc->rb]);
break;
case 2:
LOG_DIS("mulhsu r%d r%d r%d\n", dc->rd, dc->ra, dc->rb);
t_gen_muls(d[0], cpu_R[dc->rd], cpu_R[dc->ra], cpu_R[dc->rb]);
break;
case 3:
LOG_DIS("mulhu r%d r%d r%d\n", dc->rd, dc->ra, dc->rb);
t_gen_mulu(d[0], cpu_R[dc->rd], cpu_R[dc->ra], cpu_R[dc->rb]);
break;
default:
cpu_abort(dc->env, "unknown MUL insn %x\n", subcode);
break;
}
done:
tcg_temp_free(d[0]);
tcg_temp_free(d[1]);
}
| false | qemu | 97f90cbfe810bb153fc44bde732d9639610783bb | static void dec_mul(DisasContext *dc)
{
TCGv d[2];
unsigned int subcode;
if ((dc->tb_flags & MSR_EE_FLAG)
&& !(dc->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK)
&& !(dc->env->pvr.regs[0] & PVR0_USE_HW_MUL_MASK)) {
tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP);
t_gen_raise_exception(dc, EXCP_HW_EXCP);
return;
}
subcode = dc->imm & 3;
d[0] = tcg_temp_new();
d[1] = tcg_temp_new();
if (dc->type_b) {
LOG_DIS("muli r%d r%d %x\n", dc->rd, dc->ra, dc->imm);
t_gen_mulu(cpu_R[dc->rd], d[1], cpu_R[dc->ra], *(dec_alu_op_b(dc)));
goto done;
}
if (subcode >= 1 && subcode <= 3
&& !((dc->env->pvr.regs[2] & PVR2_USE_MUL64_MASK))) {
}
switch (subcode) {
case 0:
LOG_DIS("mul r%d r%d r%d\n", dc->rd, dc->ra, dc->rb);
t_gen_mulu(cpu_R[dc->rd], d[1], cpu_R[dc->ra], cpu_R[dc->rb]);
break;
case 1:
LOG_DIS("mulh r%d r%d r%d\n", dc->rd, dc->ra, dc->rb);
t_gen_muls(d[0], cpu_R[dc->rd], cpu_R[dc->ra], cpu_R[dc->rb]);
break;
case 2:
LOG_DIS("mulhsu r%d r%d r%d\n", dc->rd, dc->ra, dc->rb);
t_gen_muls(d[0], cpu_R[dc->rd], cpu_R[dc->ra], cpu_R[dc->rb]);
break;
case 3:
LOG_DIS("mulhu r%d r%d r%d\n", dc->rd, dc->ra, dc->rb);
t_gen_mulu(d[0], cpu_R[dc->rd], cpu_R[dc->ra], cpu_R[dc->rb]);
break;
default:
cpu_abort(dc->env, "unknown MUL insn %x\n", subcode);
break;
}
done:
tcg_temp_free(d[0]);
tcg_temp_free(d[1]);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0)
{
TCGv d[2];
unsigned int VAR_1;
if ((VAR_0->tb_flags & MSR_EE_FLAG)
&& !(VAR_0->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK)
&& !(VAR_0->env->pvr.regs[0] & PVR0_USE_HW_MUL_MASK)) {
tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP);
t_gen_raise_exception(VAR_0, EXCP_HW_EXCP);
return;
}
VAR_1 = VAR_0->imm & 3;
d[0] = tcg_temp_new();
d[1] = tcg_temp_new();
if (VAR_0->type_b) {
LOG_DIS("muli r%d r%d %x\n", VAR_0->rd, VAR_0->ra, VAR_0->imm);
t_gen_mulu(cpu_R[VAR_0->rd], d[1], cpu_R[VAR_0->ra], *(dec_alu_op_b(VAR_0)));
goto done;
}
if (VAR_1 >= 1 && VAR_1 <= 3
&& !((VAR_0->env->pvr.regs[2] & PVR2_USE_MUL64_MASK))) {
}
switch (VAR_1) {
case 0:
LOG_DIS("mul r%d r%d r%d\n", VAR_0->rd, VAR_0->ra, VAR_0->rb);
t_gen_mulu(cpu_R[VAR_0->rd], d[1], cpu_R[VAR_0->ra], cpu_R[VAR_0->rb]);
break;
case 1:
LOG_DIS("mulh r%d r%d r%d\n", VAR_0->rd, VAR_0->ra, VAR_0->rb);
t_gen_muls(d[0], cpu_R[VAR_0->rd], cpu_R[VAR_0->ra], cpu_R[VAR_0->rb]);
break;
case 2:
LOG_DIS("mulhsu r%d r%d r%d\n", VAR_0->rd, VAR_0->ra, VAR_0->rb);
t_gen_muls(d[0], cpu_R[VAR_0->rd], cpu_R[VAR_0->ra], cpu_R[VAR_0->rb]);
break;
case 3:
LOG_DIS("mulhu r%d r%d r%d\n", VAR_0->rd, VAR_0->ra, VAR_0->rb);
t_gen_mulu(d[0], cpu_R[VAR_0->rd], cpu_R[VAR_0->ra], cpu_R[VAR_0->rb]);
break;
default:
cpu_abort(VAR_0->env, "unknown MUL insn %x\n", VAR_1);
break;
}
done:
tcg_temp_free(d[0]);
tcg_temp_free(d[1]);
}
| [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"TCGv d[2];",
"unsigned int VAR_1;",
"if ((VAR_0->tb_flags & MSR_EE_FLAG)\n&& !(VAR_0->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK)\n&& !(VAR_0->env->pvr.regs[0] & PVR0_USE_HW_MUL_MASK)) {",
"tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP);",
"t_gen_raise_e... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
49,
51
],
[
55
],
... |
9,562 | static void fimd_update_memory_section(Exynos4210fimdState *s, unsigned win)
{
Exynos4210fimdWindow *w = &s->window[win];
target_phys_addr_t fb_start_addr, fb_mapped_len;
if (!s->enabled || !(w->wincon & FIMD_WINCON_ENWIN) ||
FIMD_WINDOW_PROTECTED(s->shadowcon, win)) {
return;
}
if (w->host_fb_addr) {
cpu_physical_memory_unmap(w->host_fb_addr, w->fb_len, 0, 0);
w->host_fb_addr = NULL;
w->fb_len = 0;
}
fb_start_addr = w->buf_start[fimd_get_buffer_id(w)];
/* Total number of bytes of virtual screen used by current window */
w->fb_len = fb_mapped_len = (w->virtpage_width + w->virtpage_offsize) *
(w->rightbot_y - w->lefttop_y + 1);
w->mem_section = memory_region_find(sysbus_address_space(&s->busdev),
fb_start_addr, w->fb_len);
assert(w->mem_section.mr);
assert(w->mem_section.offset_within_address_space == fb_start_addr);
DPRINT_TRACE("Window %u framebuffer changed: address=0x%08x, len=0x%x\n",
win, fb_start_addr, w->fb_len);
if (w->mem_section.size != w->fb_len ||
!memory_region_is_ram(w->mem_section.mr)) {
DPRINT_ERROR("Failed to find window %u framebuffer region\n", win);
goto error_return;
}
w->host_fb_addr = cpu_physical_memory_map(fb_start_addr, &fb_mapped_len, 0);
if (!w->host_fb_addr) {
DPRINT_ERROR("Failed to map window %u framebuffer\n", win);
goto error_return;
}
if (fb_mapped_len != w->fb_len) {
DPRINT_ERROR("Window %u mapped framebuffer length is less then "
"expected\n", win);
cpu_physical_memory_unmap(w->host_fb_addr, fb_mapped_len, 0, 0);
goto error_return;
}
return;
error_return:
w->mem_section.mr = NULL;
w->mem_section.size = 0;
w->host_fb_addr = NULL;
w->fb_len = 0;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void fimd_update_memory_section(Exynos4210fimdState *s, unsigned win)
{
Exynos4210fimdWindow *w = &s->window[win];
target_phys_addr_t fb_start_addr, fb_mapped_len;
if (!s->enabled || !(w->wincon & FIMD_WINCON_ENWIN) ||
FIMD_WINDOW_PROTECTED(s->shadowcon, win)) {
return;
}
if (w->host_fb_addr) {
cpu_physical_memory_unmap(w->host_fb_addr, w->fb_len, 0, 0);
w->host_fb_addr = NULL;
w->fb_len = 0;
}
fb_start_addr = w->buf_start[fimd_get_buffer_id(w)];
w->fb_len = fb_mapped_len = (w->virtpage_width + w->virtpage_offsize) *
(w->rightbot_y - w->lefttop_y + 1);
w->mem_section = memory_region_find(sysbus_address_space(&s->busdev),
fb_start_addr, w->fb_len);
assert(w->mem_section.mr);
assert(w->mem_section.offset_within_address_space == fb_start_addr);
DPRINT_TRACE("Window %u framebuffer changed: address=0x%08x, len=0x%x\n",
win, fb_start_addr, w->fb_len);
if (w->mem_section.size != w->fb_len ||
!memory_region_is_ram(w->mem_section.mr)) {
DPRINT_ERROR("Failed to find window %u framebuffer region\n", win);
goto error_return;
}
w->host_fb_addr = cpu_physical_memory_map(fb_start_addr, &fb_mapped_len, 0);
if (!w->host_fb_addr) {
DPRINT_ERROR("Failed to map window %u framebuffer\n", win);
goto error_return;
}
if (fb_mapped_len != w->fb_len) {
DPRINT_ERROR("Window %u mapped framebuffer length is less then "
"expected\n", win);
cpu_physical_memory_unmap(w->host_fb_addr, fb_mapped_len, 0, 0);
goto error_return;
}
return;
error_return:
w->mem_section.mr = NULL;
w->mem_section.size = 0;
w->host_fb_addr = NULL;
w->fb_len = 0;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Exynos4210fimdState *VAR_0, unsigned VAR_1)
{
Exynos4210fimdWindow *w = &VAR_0->window[VAR_1];
target_phys_addr_t fb_start_addr, fb_mapped_len;
if (!VAR_0->enabled || !(w->wincon & FIMD_WINCON_ENWIN) ||
FIMD_WINDOW_PROTECTED(VAR_0->shadowcon, VAR_1)) {
return;
}
if (w->host_fb_addr) {
cpu_physical_memory_unmap(w->host_fb_addr, w->fb_len, 0, 0);
w->host_fb_addr = NULL;
w->fb_len = 0;
}
fb_start_addr = w->buf_start[fimd_get_buffer_id(w)];
w->fb_len = fb_mapped_len = (w->virtpage_width + w->virtpage_offsize) *
(w->rightbot_y - w->lefttop_y + 1);
w->mem_section = memory_region_find(sysbus_address_space(&VAR_0->busdev),
fb_start_addr, w->fb_len);
assert(w->mem_section.mr);
assert(w->mem_section.offset_within_address_space == fb_start_addr);
DPRINT_TRACE("Window %u framebuffer changed: address=0x%08x, len=0x%x\n",
VAR_1, fb_start_addr, w->fb_len);
if (w->mem_section.size != w->fb_len ||
!memory_region_is_ram(w->mem_section.mr)) {
DPRINT_ERROR("Failed to find window %u framebuffer region\n", VAR_1);
goto error_return;
}
w->host_fb_addr = cpu_physical_memory_map(fb_start_addr, &fb_mapped_len, 0);
if (!w->host_fb_addr) {
DPRINT_ERROR("Failed to map window %u framebuffer\n", VAR_1);
goto error_return;
}
if (fb_mapped_len != w->fb_len) {
DPRINT_ERROR("Window %u mapped framebuffer length is less then "
"expected\n", VAR_1);
cpu_physical_memory_unmap(w->host_fb_addr, fb_mapped_len, 0, 0);
goto error_return;
}
return;
error_return:
w->mem_section.mr = NULL;
w->mem_section.size = 0;
w->host_fb_addr = NULL;
w->fb_len = 0;
}
| [
"static void FUNC_0(Exynos4210fimdState *VAR_0, unsigned VAR_1)\n{",
"Exynos4210fimdWindow *w = &VAR_0->window[VAR_1];",
"target_phys_addr_t fb_start_addr, fb_mapped_len;",
"if (!VAR_0->enabled || !(w->wincon & FIMD_WINCON_ENWIN) ||\nFIMD_WINDOW_PROTECTED(VAR_0->shadowcon, VAR_1)) {",
"return;",
"}",
"i... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
37,
39
],
[
41,
43
],
[
45
],
[
47
],
[
49,
51
],
[
55... |
9,563 | PCIDevice *pci_try_create_multifunction(PCIBus *bus, int devfn,
bool multifunction,
const char *name)
{
DeviceState *dev;
dev = qdev_try_create(&bus->qbus, name);
if (!dev) {
return NULL;
}
qdev_prop_set_uint32(dev, "addr", devfn);
qdev_prop_set_bit(dev, "multifunction", multifunction);
return DO_UPCAST(PCIDevice, qdev, dev);
}
| false | qemu | a369da5f31ddbdeb32a7f76622e480d3995fbb00 | PCIDevice *pci_try_create_multifunction(PCIBus *bus, int devfn,
bool multifunction,
const char *name)
{
DeviceState *dev;
dev = qdev_try_create(&bus->qbus, name);
if (!dev) {
return NULL;
}
qdev_prop_set_uint32(dev, "addr", devfn);
qdev_prop_set_bit(dev, "multifunction", multifunction);
return DO_UPCAST(PCIDevice, qdev, dev);
}
| {
"code": [],
"line_no": []
} | PCIDevice *FUNC_0(PCIBus *bus, int devfn,
bool multifunction,
const char *name)
{
DeviceState *dev;
dev = qdev_try_create(&bus->qbus, name);
if (!dev) {
return NULL;
}
qdev_prop_set_uint32(dev, "addr", devfn);
qdev_prop_set_bit(dev, "multifunction", multifunction);
return DO_UPCAST(PCIDevice, qdev, dev);
}
| [
"PCIDevice *FUNC_0(PCIBus *bus, int devfn,\nbool multifunction,\nconst char *name)\n{",
"DeviceState *dev;",
"dev = qdev_try_create(&bus->qbus, name);",
"if (!dev) {",
"return NULL;",
"}",
"qdev_prop_set_uint32(dev, \"addr\", devfn);",
"qdev_prop_set_bit(dev, \"multifunction\", multifunction);",
"re... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
9,564 | void OPPROTO op_addq_ESI_T0(void)
{
ESI = (ESI + T0);
}
| false | qemu | 6e0d8677cb443e7408c0b7a25a93c6596d7fa380 | void OPPROTO op_addq_ESI_T0(void)
{
ESI = (ESI + T0);
}
| {
"code": [],
"line_no": []
} | void VAR_0 op_addq_ESI_T0(void)
{
ESI = (ESI + T0);
}
| [
"void VAR_0 op_addq_ESI_T0(void)\n{",
"ESI = (ESI + T0);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
9,565 | static int mov_write_trailer(AVFormatContext *s)
{
MOVMuxContext *mov = s->priv_data;
AVIOContext *pb = s->pb;
int res = 0;
int i;
int64_t moov_pos;
/*
* Before actually writing the trailer, make sure that there are no
* dangling subtitles, that need a terminating sample.
*/
for (i = 0; i < mov->nb_streams; i++) {
MOVTrack *trk = &mov->tracks[i];
if (trk->enc->codec_id == AV_CODEC_ID_MOV_TEXT &&
!trk->last_sample_is_subtitle_end) {
mov_write_subtitle_end_packet(s, i, trk->track_duration);
trk->last_sample_is_subtitle_end = 1;
}
}
// If there were no chapters when the header was written, but there
// are chapters now, write them in the trailer. This only works
// when we are not doing fragments.
if (!mov->chapter_track && !(mov->flags & FF_MOV_FLAG_FRAGMENT)) {
if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && s->nb_chapters) {
mov->chapter_track = mov->nb_streams++;
if ((res = mov_create_chapter_track(s, mov->chapter_track)) < 0)
goto error;
}
}
if (!(mov->flags & FF_MOV_FLAG_FRAGMENT)) {
moov_pos = avio_tell(pb);
/* Write size of mdat tag */
if (mov->mdat_size + 8 <= UINT32_MAX) {
avio_seek(pb, mov->mdat_pos, SEEK_SET);
avio_wb32(pb, mov->mdat_size + 8);
} else {
/* overwrite 'wide' placeholder atom */
avio_seek(pb, mov->mdat_pos - 8, SEEK_SET);
/* special value: real atom size will be 64 bit value after
* tag field */
avio_wb32(pb, 1);
ffio_wfourcc(pb, "mdat");
avio_wb64(pb, mov->mdat_size + 16);
}
avio_seek(pb, mov->reserved_moov_size > 0 ? mov->reserved_moov_pos : moov_pos, SEEK_SET);
if (mov->flags & FF_MOV_FLAG_FASTSTART) {
av_log(s, AV_LOG_INFO, "Starting second pass: moving the moov atom to the beginning of the file\n");
res = shift_data(s);
if (res == 0) {
avio_seek(s->pb, mov->reserved_moov_pos, SEEK_SET);
mov_write_moov_tag(pb, mov, s);
}
} else if (mov->reserved_moov_size > 0) {
int64_t size;
mov_write_moov_tag(pb, mov, s);
size = mov->reserved_moov_size - (avio_tell(pb) - mov->reserved_moov_pos);
if (size < 8){
av_log(s, AV_LOG_ERROR, "reserved_moov_size is too small, needed %"PRId64" additional\n", 8-size);
return -1;
}
avio_wb32(pb, size);
ffio_wfourcc(pb, "free");
for (i = 0; i < size; i++)
avio_w8(pb, 0);
avio_seek(pb, moov_pos, SEEK_SET);
} else {
mov_write_moov_tag(pb, mov, s);
}
} else {
mov_flush_fragment(s);
mov_write_mfra_tag(pb, mov);
}
for (i = 0; i < mov->nb_streams; i++) {
if (mov->flags & FF_MOV_FLAG_FRAGMENT &&
mov->tracks[i].vc1_info.struct_offset && s->pb->seekable) {
int64_t off = avio_tell(pb);
uint8_t buf[7];
if (mov_write_dvc1_structs(&mov->tracks[i], buf) >= 0) {
avio_seek(pb, mov->tracks[i].vc1_info.struct_offset, SEEK_SET);
avio_write(pb, buf, 7);
avio_seek(pb, off, SEEK_SET);
}
}
}
error:
mov_free(s);
return res;
}
| false | FFmpeg | 0e70266bbfade1457189cc402cab2cdd7ec94c7b | static int mov_write_trailer(AVFormatContext *s)
{
MOVMuxContext *mov = s->priv_data;
AVIOContext *pb = s->pb;
int res = 0;
int i;
int64_t moov_pos;
for (i = 0; i < mov->nb_streams; i++) {
MOVTrack *trk = &mov->tracks[i];
if (trk->enc->codec_id == AV_CODEC_ID_MOV_TEXT &&
!trk->last_sample_is_subtitle_end) {
mov_write_subtitle_end_packet(s, i, trk->track_duration);
trk->last_sample_is_subtitle_end = 1;
}
}
if (!mov->chapter_track && !(mov->flags & FF_MOV_FLAG_FRAGMENT)) {
if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && s->nb_chapters) {
mov->chapter_track = mov->nb_streams++;
if ((res = mov_create_chapter_track(s, mov->chapter_track)) < 0)
goto error;
}
}
if (!(mov->flags & FF_MOV_FLAG_FRAGMENT)) {
moov_pos = avio_tell(pb);
if (mov->mdat_size + 8 <= UINT32_MAX) {
avio_seek(pb, mov->mdat_pos, SEEK_SET);
avio_wb32(pb, mov->mdat_size + 8);
} else {
avio_seek(pb, mov->mdat_pos - 8, SEEK_SET);
avio_wb32(pb, 1);
ffio_wfourcc(pb, "mdat");
avio_wb64(pb, mov->mdat_size + 16);
}
avio_seek(pb, mov->reserved_moov_size > 0 ? mov->reserved_moov_pos : moov_pos, SEEK_SET);
if (mov->flags & FF_MOV_FLAG_FASTSTART) {
av_log(s, AV_LOG_INFO, "Starting second pass: moving the moov atom to the beginning of the file\n");
res = shift_data(s);
if (res == 0) {
avio_seek(s->pb, mov->reserved_moov_pos, SEEK_SET);
mov_write_moov_tag(pb, mov, s);
}
} else if (mov->reserved_moov_size > 0) {
int64_t size;
mov_write_moov_tag(pb, mov, s);
size = mov->reserved_moov_size - (avio_tell(pb) - mov->reserved_moov_pos);
if (size < 8){
av_log(s, AV_LOG_ERROR, "reserved_moov_size is too small, needed %"PRId64" additional\n", 8-size);
return -1;
}
avio_wb32(pb, size);
ffio_wfourcc(pb, "free");
for (i = 0; i < size; i++)
avio_w8(pb, 0);
avio_seek(pb, moov_pos, SEEK_SET);
} else {
mov_write_moov_tag(pb, mov, s);
}
} else {
mov_flush_fragment(s);
mov_write_mfra_tag(pb, mov);
}
for (i = 0; i < mov->nb_streams; i++) {
if (mov->flags & FF_MOV_FLAG_FRAGMENT &&
mov->tracks[i].vc1_info.struct_offset && s->pb->seekable) {
int64_t off = avio_tell(pb);
uint8_t buf[7];
if (mov_write_dvc1_structs(&mov->tracks[i], buf) >= 0) {
avio_seek(pb, mov->tracks[i].vc1_info.struct_offset, SEEK_SET);
avio_write(pb, buf, 7);
avio_seek(pb, off, SEEK_SET);
}
}
}
error:
mov_free(s);
return res;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
MOVMuxContext *mov = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
int VAR_1 = 0;
int VAR_2;
int64_t moov_pos;
for (VAR_2 = 0; VAR_2 < mov->nb_streams; VAR_2++) {
MOVTrack *trk = &mov->tracks[VAR_2];
if (trk->enc->codec_id == AV_CODEC_ID_MOV_TEXT &&
!trk->last_sample_is_subtitle_end) {
mov_write_subtitle_end_packet(VAR_0, VAR_2, trk->track_duration);
trk->last_sample_is_subtitle_end = 1;
}
}
if (!mov->chapter_track && !(mov->flags & FF_MOV_FLAG_FRAGMENT)) {
if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && VAR_0->nb_chapters) {
mov->chapter_track = mov->nb_streams++;
if ((VAR_1 = mov_create_chapter_track(VAR_0, mov->chapter_track)) < 0)
goto error;
}
}
if (!(mov->flags & FF_MOV_FLAG_FRAGMENT)) {
moov_pos = avio_tell(pb);
if (mov->mdat_size + 8 <= UINT32_MAX) {
avio_seek(pb, mov->mdat_pos, SEEK_SET);
avio_wb32(pb, mov->mdat_size + 8);
} else {
avio_seek(pb, mov->mdat_pos - 8, SEEK_SET);
avio_wb32(pb, 1);
ffio_wfourcc(pb, "mdat");
avio_wb64(pb, mov->mdat_size + 16);
}
avio_seek(pb, mov->reserved_moov_size > 0 ? mov->reserved_moov_pos : moov_pos, SEEK_SET);
if (mov->flags & FF_MOV_FLAG_FASTSTART) {
av_log(VAR_0, AV_LOG_INFO, "Starting second pass: moving the moov atom to the beginning of the file\n");
VAR_1 = shift_data(VAR_0);
if (VAR_1 == 0) {
avio_seek(VAR_0->pb, mov->reserved_moov_pos, SEEK_SET);
mov_write_moov_tag(pb, mov, VAR_0);
}
} else if (mov->reserved_moov_size > 0) {
int64_t size;
mov_write_moov_tag(pb, mov, VAR_0);
size = mov->reserved_moov_size - (avio_tell(pb) - mov->reserved_moov_pos);
if (size < 8){
av_log(VAR_0, AV_LOG_ERROR, "reserved_moov_size is too small, needed %"PRId64" additional\n", 8-size);
return -1;
}
avio_wb32(pb, size);
ffio_wfourcc(pb, "free");
for (VAR_2 = 0; VAR_2 < size; VAR_2++)
avio_w8(pb, 0);
avio_seek(pb, moov_pos, SEEK_SET);
} else {
mov_write_moov_tag(pb, mov, VAR_0);
}
} else {
mov_flush_fragment(VAR_0);
mov_write_mfra_tag(pb, mov);
}
for (VAR_2 = 0; VAR_2 < mov->nb_streams; VAR_2++) {
if (mov->flags & FF_MOV_FLAG_FRAGMENT &&
mov->tracks[VAR_2].vc1_info.struct_offset && VAR_0->pb->seekable) {
int64_t off = avio_tell(pb);
uint8_t buf[7];
if (mov_write_dvc1_structs(&mov->tracks[VAR_2], buf) >= 0) {
avio_seek(pb, mov->tracks[VAR_2].vc1_info.struct_offset, SEEK_SET);
avio_write(pb, buf, 7);
avio_seek(pb, off, SEEK_SET);
}
}
}
error:
mov_free(VAR_0);
return VAR_1;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"MOVMuxContext *mov = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"int VAR_1 = 0;",
"int VAR_2;",
"int64_t moov_pos;",
"for (VAR_2 = 0; VAR_2 < mov->nb_streams; VAR_2++) {",
"MOVTrack *trk = &mov->tracks[VAR_2];",
"if (trk->enc->codec_id == AV_... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
... |
9,566 | static void acquire_privilege(const char *name, Error **errp)
{
HANDLE token = NULL;
TOKEN_PRIVILEGES priv;
Error *local_err = NULL;
if (OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &token))
{
if (!LookupPrivilegeValue(NULL, name, &priv.Privileges[0].Luid)) {
error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
"no luid for requested privilege");
goto out;
}
priv.PrivilegeCount = 1;
priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if (!AdjustTokenPrivileges(token, FALSE, &priv, 0, NULL, 0)) {
error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
"unable to acquire requested privilege");
goto out;
}
} else {
error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
"failed to open privilege token");
}
out:
if (token) {
CloseHandle(token);
}
if (local_err) {
error_propagate(errp, local_err);
}
}
| false | qemu | 621ff94d5074d88253a5818c6b9c4db718fbfc65 | static void acquire_privilege(const char *name, Error **errp)
{
HANDLE token = NULL;
TOKEN_PRIVILEGES priv;
Error *local_err = NULL;
if (OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &token))
{
if (!LookupPrivilegeValue(NULL, name, &priv.Privileges[0].Luid)) {
error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
"no luid for requested privilege");
goto out;
}
priv.PrivilegeCount = 1;
priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if (!AdjustTokenPrivileges(token, FALSE, &priv, 0, NULL, 0)) {
error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
"unable to acquire requested privilege");
goto out;
}
} else {
error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
"failed to open privilege token");
}
out:
if (token) {
CloseHandle(token);
}
if (local_err) {
error_propagate(errp, local_err);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const char *VAR_0, Error **VAR_1)
{
HANDLE token = NULL;
TOKEN_PRIVILEGES priv;
Error *local_err = NULL;
if (OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &token))
{
if (!LookupPrivilegeValue(NULL, VAR_0, &priv.Privileges[0].Luid)) {
error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
"no luid for requested privilege");
goto out;
}
priv.PrivilegeCount = 1;
priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if (!AdjustTokenPrivileges(token, FALSE, &priv, 0, NULL, 0)) {
error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
"unable to acquire requested privilege");
goto out;
}
} else {
error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
"failed to open privilege token");
}
out:
if (token) {
CloseHandle(token);
}
if (local_err) {
error_propagate(VAR_1, local_err);
}
}
| [
"static void FUNC_0(const char *VAR_0, Error **VAR_1)\n{",
"HANDLE token = NULL;",
"TOKEN_PRIVILEGES priv;",
"Error *local_err = NULL;",
"if (OpenProcessToken(GetCurrentProcess(),\nTOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &token))\n{",
"if (!LookupPrivilegeValue(NULL, VAR_0, &priv.Privileges[0].Luid)) {",
"... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15,
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
49
],
[
51,
53
],
[... |
9,567 | static int aio_write_f(int argc, char **argv)
{
int nr_iov, c;
int pattern = 0xcd;
struct aio_ctx *ctx = calloc(1, sizeof(struct aio_ctx));
while ((c = getopt(argc, argv, "CqP:")) != EOF) {
switch (c) {
case 'C':
ctx->Cflag = 1;
break;
case 'q':
ctx->qflag = 1;
break;
case 'P':
pattern = parse_pattern(optarg);
if (pattern < 0) {
free(ctx);
return 0;
}
break;
default:
free(ctx);
return command_usage(&aio_write_cmd);
}
}
if (optind > argc - 2) {
free(ctx);
return command_usage(&aio_write_cmd);
}
ctx->offset = cvtnum(argv[optind]);
if (ctx->offset < 0) {
printf("non-numeric length argument -- %s\n", argv[optind]);
free(ctx);
return 0;
}
optind++;
if (ctx->offset & 0x1ff) {
printf("offset %" PRId64 " is not sector aligned\n",
ctx->offset);
free(ctx);
return 0;
}
nr_iov = argc - optind;
ctx->buf = create_iovec(&ctx->qiov, &argv[optind], nr_iov, pattern);
if (ctx->buf == NULL) {
free(ctx);
return 0;
}
gettimeofday(&ctx->t1, NULL);
bdrv_aio_writev(bs, ctx->offset >> 9, &ctx->qiov,
ctx->qiov.size >> 9, aio_write_done, ctx);
return 0;
}
| false | qemu | 031380d8770d2df6c386e4aeabd412007d3ebd54 | static int aio_write_f(int argc, char **argv)
{
int nr_iov, c;
int pattern = 0xcd;
struct aio_ctx *ctx = calloc(1, sizeof(struct aio_ctx));
while ((c = getopt(argc, argv, "CqP:")) != EOF) {
switch (c) {
case 'C':
ctx->Cflag = 1;
break;
case 'q':
ctx->qflag = 1;
break;
case 'P':
pattern = parse_pattern(optarg);
if (pattern < 0) {
free(ctx);
return 0;
}
break;
default:
free(ctx);
return command_usage(&aio_write_cmd);
}
}
if (optind > argc - 2) {
free(ctx);
return command_usage(&aio_write_cmd);
}
ctx->offset = cvtnum(argv[optind]);
if (ctx->offset < 0) {
printf("non-numeric length argument -- %s\n", argv[optind]);
free(ctx);
return 0;
}
optind++;
if (ctx->offset & 0x1ff) {
printf("offset %" PRId64 " is not sector aligned\n",
ctx->offset);
free(ctx);
return 0;
}
nr_iov = argc - optind;
ctx->buf = create_iovec(&ctx->qiov, &argv[optind], nr_iov, pattern);
if (ctx->buf == NULL) {
free(ctx);
return 0;
}
gettimeofday(&ctx->t1, NULL);
bdrv_aio_writev(bs, ctx->offset >> 9, &ctx->qiov,
ctx->qiov.size >> 9, aio_write_done, ctx);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(int VAR_0, char **VAR_1)
{
int VAR_2, VAR_3;
int VAR_4 = 0xcd;
struct aio_ctx *VAR_5 = calloc(1, sizeof(struct aio_ctx));
while ((VAR_3 = getopt(VAR_0, VAR_1, "CqP:")) != EOF) {
switch (VAR_3) {
case 'C':
VAR_5->Cflag = 1;
break;
case 'q':
VAR_5->qflag = 1;
break;
case 'P':
VAR_4 = parse_pattern(optarg);
if (VAR_4 < 0) {
free(VAR_5);
return 0;
}
break;
default:
free(VAR_5);
return command_usage(&aio_write_cmd);
}
}
if (optind > VAR_0 - 2) {
free(VAR_5);
return command_usage(&aio_write_cmd);
}
VAR_5->offset = cvtnum(VAR_1[optind]);
if (VAR_5->offset < 0) {
printf("non-numeric length argument -- %s\n", VAR_1[optind]);
free(VAR_5);
return 0;
}
optind++;
if (VAR_5->offset & 0x1ff) {
printf("offset %" PRId64 " is not sector aligned\n",
VAR_5->offset);
free(VAR_5);
return 0;
}
VAR_2 = VAR_0 - optind;
VAR_5->buf = create_iovec(&VAR_5->qiov, &VAR_1[optind], VAR_2, VAR_4);
if (VAR_5->buf == NULL) {
free(VAR_5);
return 0;
}
gettimeofday(&VAR_5->t1, NULL);
bdrv_aio_writev(bs, VAR_5->offset >> 9, &VAR_5->qiov,
VAR_5->qiov.size >> 9, aio_write_done, VAR_5);
return 0;
}
| [
"static int FUNC_0(int VAR_0, char **VAR_1)\n{",
"int VAR_2, VAR_3;",
"int VAR_4 = 0xcd;",
"struct aio_ctx *VAR_5 = calloc(1, sizeof(struct aio_ctx));",
"while ((VAR_3 = getopt(VAR_0, VAR_1, \"CqP:\")) != EOF) {",
"switch (VAR_3) {",
"case 'C':\nVAR_5->Cflag = 1;",
"break;",
"case 'q':\nVAR_5->qflag... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23,
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
... |
9,568 | void tlb_set_page(CPUState *cpu, target_ulong vaddr,
hwaddr paddr, int prot,
int mmu_idx, target_ulong size)
{
CPUArchState *env = cpu->env_ptr;
MemoryRegionSection *section;
unsigned int index;
target_ulong address;
target_ulong code_address;
uintptr_t addend;
CPUTLBEntry *te;
hwaddr iotlb, xlat, sz;
assert(size >= TARGET_PAGE_SIZE);
if (size != TARGET_PAGE_SIZE) {
tlb_add_large_page(env, vaddr, size);
}
sz = size;
section = address_space_translate_for_iotlb(cpu->as, paddr,
&xlat, &sz);
assert(sz >= TARGET_PAGE_SIZE);
#if defined(DEBUG_TLB)
printf("tlb_set_page: vaddr=" TARGET_FMT_lx " paddr=0x" TARGET_FMT_plx
" prot=%x idx=%d\n",
vaddr, paddr, prot, mmu_idx);
#endif
address = vaddr;
if (!memory_region_is_ram(section->mr) && !memory_region_is_romd(section->mr)) {
/* IO memory case */
address |= TLB_MMIO;
addend = 0;
} else {
/* TLB_MMIO for rom/romd handled below */
addend = (uintptr_t)memory_region_get_ram_ptr(section->mr) + xlat;
}
code_address = address;
iotlb = memory_region_section_get_iotlb(cpu, section, vaddr, paddr, xlat,
prot, &address);
index = (vaddr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
env->iotlb[mmu_idx][index] = iotlb - vaddr;
te = &env->tlb_table[mmu_idx][index];
te->addend = addend - vaddr;
if (prot & PAGE_READ) {
te->addr_read = address;
} else {
te->addr_read = -1;
}
if (prot & PAGE_EXEC) {
te->addr_code = code_address;
} else {
te->addr_code = -1;
}
if (prot & PAGE_WRITE) {
if ((memory_region_is_ram(section->mr) && section->readonly)
|| memory_region_is_romd(section->mr)) {
/* Write access calls the I/O callback. */
te->addr_write = address | TLB_MMIO;
} else if (memory_region_is_ram(section->mr)
&& cpu_physical_memory_is_clean(section->mr->ram_addr
+ xlat)) {
te->addr_write = address | TLB_NOTDIRTY;
} else {
te->addr_write = address;
}
} else {
te->addr_write = -1;
}
}
| false | qemu | 88e89a57f985296a6eeb416b2a875072e09d7faa | void tlb_set_page(CPUState *cpu, target_ulong vaddr,
hwaddr paddr, int prot,
int mmu_idx, target_ulong size)
{
CPUArchState *env = cpu->env_ptr;
MemoryRegionSection *section;
unsigned int index;
target_ulong address;
target_ulong code_address;
uintptr_t addend;
CPUTLBEntry *te;
hwaddr iotlb, xlat, sz;
assert(size >= TARGET_PAGE_SIZE);
if (size != TARGET_PAGE_SIZE) {
tlb_add_large_page(env, vaddr, size);
}
sz = size;
section = address_space_translate_for_iotlb(cpu->as, paddr,
&xlat, &sz);
assert(sz >= TARGET_PAGE_SIZE);
#if defined(DEBUG_TLB)
printf("tlb_set_page: vaddr=" TARGET_FMT_lx " paddr=0x" TARGET_FMT_plx
" prot=%x idx=%d\n",
vaddr, paddr, prot, mmu_idx);
#endif
address = vaddr;
if (!memory_region_is_ram(section->mr) && !memory_region_is_romd(section->mr)) {
address |= TLB_MMIO;
addend = 0;
} else {
addend = (uintptr_t)memory_region_get_ram_ptr(section->mr) + xlat;
}
code_address = address;
iotlb = memory_region_section_get_iotlb(cpu, section, vaddr, paddr, xlat,
prot, &address);
index = (vaddr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
env->iotlb[mmu_idx][index] = iotlb - vaddr;
te = &env->tlb_table[mmu_idx][index];
te->addend = addend - vaddr;
if (prot & PAGE_READ) {
te->addr_read = address;
} else {
te->addr_read = -1;
}
if (prot & PAGE_EXEC) {
te->addr_code = code_address;
} else {
te->addr_code = -1;
}
if (prot & PAGE_WRITE) {
if ((memory_region_is_ram(section->mr) && section->readonly)
|| memory_region_is_romd(section->mr)) {
te->addr_write = address | TLB_MMIO;
} else if (memory_region_is_ram(section->mr)
&& cpu_physical_memory_is_clean(section->mr->ram_addr
+ xlat)) {
te->addr_write = address | TLB_NOTDIRTY;
} else {
te->addr_write = address;
}
} else {
te->addr_write = -1;
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(CPUState *VAR_0, target_ulong VAR_1,
hwaddr VAR_2, int VAR_3,
int VAR_4, target_ulong VAR_5)
{
CPUArchState *env = VAR_0->env_ptr;
MemoryRegionSection *section;
unsigned int VAR_6;
target_ulong address;
target_ulong code_address;
uintptr_t addend;
CPUTLBEntry *te;
hwaddr iotlb, xlat, sz;
assert(VAR_5 >= TARGET_PAGE_SIZE);
if (VAR_5 != TARGET_PAGE_SIZE) {
tlb_add_large_page(env, VAR_1, VAR_5);
}
sz = VAR_5;
section = address_space_translate_for_iotlb(VAR_0->as, VAR_2,
&xlat, &sz);
assert(sz >= TARGET_PAGE_SIZE);
#if defined(DEBUG_TLB)
printf("FUNC_0: VAR_1=" TARGET_FMT_lx " VAR_2=0x" TARGET_FMT_plx
" VAR_3=%x idx=%d\n",
VAR_1, VAR_2, VAR_3, VAR_4);
#endif
address = VAR_1;
if (!memory_region_is_ram(section->mr) && !memory_region_is_romd(section->mr)) {
address |= TLB_MMIO;
addend = 0;
} else {
addend = (uintptr_t)memory_region_get_ram_ptr(section->mr) + xlat;
}
code_address = address;
iotlb = memory_region_section_get_iotlb(VAR_0, section, VAR_1, VAR_2, xlat,
VAR_3, &address);
VAR_6 = (VAR_1 >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
env->iotlb[VAR_4][VAR_6] = iotlb - VAR_1;
te = &env->tlb_table[VAR_4][VAR_6];
te->addend = addend - VAR_1;
if (VAR_3 & PAGE_READ) {
te->addr_read = address;
} else {
te->addr_read = -1;
}
if (VAR_3 & PAGE_EXEC) {
te->addr_code = code_address;
} else {
te->addr_code = -1;
}
if (VAR_3 & PAGE_WRITE) {
if ((memory_region_is_ram(section->mr) && section->readonly)
|| memory_region_is_romd(section->mr)) {
te->addr_write = address | TLB_MMIO;
} else if (memory_region_is_ram(section->mr)
&& cpu_physical_memory_is_clean(section->mr->ram_addr
+ xlat)) {
te->addr_write = address | TLB_NOTDIRTY;
} else {
te->addr_write = address;
}
} else {
te->addr_write = -1;
}
}
| [
"void FUNC_0(CPUState *VAR_0, target_ulong VAR_1,\nhwaddr VAR_2, int VAR_3,\nint VAR_4, target_ulong VAR_5)\n{",
"CPUArchState *env = VAR_0->env_ptr;",
"MemoryRegionSection *section;",
"unsigned int VAR_6;",
"target_ulong address;",
"target_ulong code_address;",
"uintptr_t addend;",
"CPUTLBEntry *te;"... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39,
41
],
[
43
],
[
47,
49,
51,
53
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.