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
8,820
void rgb15tobgr32(const uint8_t *src, uint8_t *dst, long src_size) { const uint16_t *end; uint8_t *d = (uint8_t *)dst; const uint16_t *s = (const uint16_t *)src; end = s + src_size/2; while(s < end) { register uint16_t bgr; bgr = *s++; #ifdef WORDS_BIGENDIAN *d++ = 0; *d++ = (bgr&0x1F)<<3; *d++ = (bgr&0x3E0)>>2; *d++ = (bgr&0x7C00)>>7; #else *d++ = (bgr&0x7C00)>>7; *d++ = (bgr&0x3E0)>>2; *d++ = (bgr&0x1F)<<3; *d++ = 0; #endif } }
true
FFmpeg
6e42e6c4b410dbef8b593c2d796a5dad95f89ee4
void rgb15tobgr32(const uint8_t *src, uint8_t *dst, long src_size) { const uint16_t *end; uint8_t *d = (uint8_t *)dst; const uint16_t *s = (const uint16_t *)src; end = s + src_size/2; while(s < end) { register uint16_t bgr; bgr = *s++; #ifdef WORDS_BIGENDIAN *d++ = 0; *d++ = (bgr&0x1F)<<3; *d++ = (bgr&0x3E0)>>2; *d++ = (bgr&0x7C00)>>7; #else *d++ = (bgr&0x7C00)>>7; *d++ = (bgr&0x3E0)>>2; *d++ = (bgr&0x1F)<<3; *d++ = 0; #endif } }
{ "code": [ "\t\t#ifdef WORDS_BIGENDIAN", "\t\t#else", "\t\t#endif", "\t\t#ifdef WORDS_BIGENDIAN", "\t\t#else", "\t\t#endif", "\t\t#ifdef WORDS_BIGENDIAN", "\t\t#else", "\t\t#endif", "\t\t#ifdef WORDS_BIGENDIAN", "\t\t#else", "\t\t#endif", "\tconst uint16_t *end;", "\tuint8_t *d = (uint8_t *)dst;", "\tend = s + src_size/2;", "\twhile(s < end)", "\t\tregister uint16_t bgr;", "\t\tbgr = *s++;", "\t\t#ifdef WORDS_BIGENDIAN", "\t\t\t*d++ = 0;", "\t\t\t*d++ = (bgr&0x1F)<<3;", "\t\t#else", "\t\t\t*d++ = (bgr&0x1F)<<3;", "\t\t\t*d++ = 0;", "\t\t#endif", "\tconst uint16_t *end;", "\tuint8_t *d = (uint8_t *)dst;", "\tconst uint16_t *s = (const uint16_t *)src;", "\tend = s + src_size/2;", "\twhile(s < end)", "\t\tregister uint16_t bgr;", "\t\tbgr = *s++;", "\tconst uint16_t *end;", "\tuint8_t *d = (uint8_t *)dst;", "\tconst uint16_t *s = (const uint16_t *)src;", "\tend = s + src_size/2;", "\twhile(s < end)", "\t\tregister uint16_t bgr;", "\t\tbgr = *s++;", "\t\t#ifdef WORDS_BIGENDIAN", "\t\t\t*d++ = 0;", "\t\t\t*d++ = (bgr&0x1F)<<3;", "\t\t\t*d++ = (bgr&0x3E0)>>2;", "\t\t\t*d++ = (bgr&0x7C00)>>7;", "\t\t#else", "\t\t\t*d++ = (bgr&0x7C00)>>7;", "\t\t\t*d++ = (bgr&0x3E0)>>2;", "\t\t\t*d++ = (bgr&0x1F)<<3;", "\t\t\t*d++ = 0;", "\t\t#endif", "\tconst uint16_t *end;", "\tuint8_t *d = (uint8_t *)dst;", "\tend = s + src_size/2;", "\twhile(s < end)", "\t\tregister uint16_t bgr;", "\t\tbgr = *s++;", "\twhile(s < end)", "\twhile(s < end)", "\twhile(s < end)", "\twhile(s < end)", "\twhile(s < end)", "\twhile(s < end)", "\twhile(s < end)", "\twhile(s < end)", "\tconst uint16_t *end;", "\tuint8_t *d = (uint8_t *)dst;", "\tend = s + src_size/2;", "\twhile(s < end)", "\t\tregister uint16_t bgr;", "\t\tbgr = *s++;", "\tconst uint16_t *end;", "\tuint8_t *d = (uint8_t *)dst;", "\tconst uint16_t *s = (const uint16_t *)src;", "\tend = s + src_size/2;", "\twhile(s < end)", "\t\tregister uint16_t bgr;", "\t\tbgr = *s++;", "\tconst uint16_t *end;", "\tuint8_t *d = (uint8_t *)dst;", "\tconst uint16_t *s = (const uint16_t *)src;", "\tend = s + src_size/2;", "\twhile(s < end)", "\t\tregister uint16_t bgr;", "\t\tbgr = *s++;", "\tconst uint16_t *end;", "\tuint8_t *d = (uint8_t *)dst;", "\tend = s + src_size/2;", "\twhile(s < end)", "\t\tregister uint16_t bgr;", "\t\tbgr = *s++;" ], "line_no": [ 21, 31, 41, 21, 31, 41, 21, 31, 41, 21, 31, 41, 5, 7, 11, 13, 17, 19, 21, 23, 25, 31, 25, 23, 41, 5, 7, 9, 11, 13, 17, 19, 5, 7, 9, 11, 13, 17, 19, 21, 23, 25, 27, 29, 31, 29, 27, 25, 23, 41, 5, 7, 11, 13, 17, 19, 13, 13, 13, 13, 13, 13, 13, 13, 5, 7, 11, 13, 17, 19, 5, 7, 9, 11, 13, 17, 19, 5, 7, 9, 11, 13, 17, 19, 5, 7, 11, 13, 17, 19 ] }
void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, long VAR_2) { const uint16_t *VAR_3; uint8_t *d = (uint8_t *)VAR_1; const uint16_t *VAR_4 = (const uint16_t *)VAR_0; VAR_3 = VAR_4 + VAR_2/2; while(VAR_4 < VAR_3) { register uint16_t VAR_5; VAR_5 = *VAR_4++; #ifdef WORDS_BIGENDIAN *d++ = 0; *d++ = (VAR_5&0x1F)<<3; *d++ = (VAR_5&0x3E0)>>2; *d++ = (VAR_5&0x7C00)>>7; #else *d++ = (VAR_5&0x7C00)>>7; *d++ = (VAR_5&0x3E0)>>2; *d++ = (VAR_5&0x1F)<<3; *d++ = 0; #endif } }
[ "void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, long VAR_2)\n{", "const uint16_t *VAR_3;", "uint8_t *d = (uint8_t *)VAR_1;", "const uint16_t *VAR_4 = (const uint16_t *)VAR_0;", "VAR_3 = VAR_4 + VAR_2/2;", "while(VAR_4 < VAR_3)\n{", "register uint16_t VAR_5;", "VAR_5 = *VAR_4++;", "#ifdef WORDS_BIGENDIAN\n*d++ = 0;", "*d++ = (VAR_5&0x1F)<<3;", "*d++ = (VAR_5&0x3E0)>>2;", "*d++ = (VAR_5&0x7C00)>>7;", "#else\n*d++ = (VAR_5&0x7C00)>>7;", "*d++ = (VAR_5&0x3E0)>>2;", "*d++ = (VAR_5&0x1F)<<3;", "*d++ = 0;", "#endif\n}", "}" ]
[ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13, 15 ], [ 17 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31, 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41, 43 ], [ 45 ] ]
8,821
static inline int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc) { void *val; if (min_size < *size) return 0; min_size = FFMAX(17 * min_size / 16 + 32, min_size); av_freep(ptr); val = zero_realloc ? av_mallocz(min_size) : av_malloc(min_size); memcpy(ptr, &val, sizeof(val)); if (!val) min_size = 0; *size = min_size; return 1; }
true
FFmpeg
b3415e4c5f9205820fd6c9211ad50a4df2692a36
static inline int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc) { void *val; if (min_size < *size) return 0; min_size = FFMAX(17 * min_size / 16 + 32, min_size); av_freep(ptr); val = zero_realloc ? av_mallocz(min_size) : av_malloc(min_size); memcpy(ptr, &val, sizeof(val)); if (!val) min_size = 0; *size = min_size; return 1; }
{ "code": [ " min_size = FFMAX(17 * min_size / 16 + 32, min_size);", " min_size = FFMAX(17 * min_size / 16 + 32, min_size);" ], "line_no": [ 13, 13 ] }
static inline int FUNC_0(void *VAR_0, unsigned int *VAR_1, size_t VAR_2, int VAR_3) { void *VAR_4; if (VAR_2 < *VAR_1) return 0; VAR_2 = FFMAX(17 * VAR_2 / 16 + 32, VAR_2); av_freep(VAR_0); VAR_4 = VAR_3 ? av_mallocz(VAR_2) : av_malloc(VAR_2); memcpy(VAR_0, &VAR_4, sizeof(VAR_4)); if (!VAR_4) VAR_2 = 0; *VAR_1 = VAR_2; return 1; }
[ "static inline int FUNC_0(void *VAR_0, unsigned int *VAR_1, size_t VAR_2, int VAR_3)\n{", "void *VAR_4;", "if (VAR_2 < *VAR_1)\nreturn 0;", "VAR_2 = FFMAX(17 * VAR_2 / 16 + 32, VAR_2);", "av_freep(VAR_0);", "VAR_4 = VAR_3 ? av_mallocz(VAR_2) : av_malloc(VAR_2);", "memcpy(VAR_0, &VAR_4, sizeof(VAR_4));", "if (!VAR_4)\nVAR_2 = 0;", "*VAR_1 = VAR_2;", "return 1;", "}" ]
[ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9, 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 27 ], [ 29 ] ]
8,822
int qcow2_update_header(BlockDriverState *bs) BDRVQcowState *s = bs->opaque; QCowHeader *header; char *buf; size_t buflen = s->cluster_size; int ret; uint64_t total_size; uint32_t refcount_table_clusters; size_t header_length; Qcow2UnknownHeaderExtension *uext; buf = qemu_blockalign(bs, buflen); /* Header structure */ header = (QCowHeader*) buf; if (buflen < sizeof(*header)) { ret = -ENOSPC; goto fail; } header_length = sizeof(*header) + s->unknown_header_fields_size; total_size = bs->total_sectors * BDRV_SECTOR_SIZE; refcount_table_clusters = s->refcount_table_size >> (s->cluster_bits - 3); *header = (QCowHeader) { /* Version 2 fields */ .magic = cpu_to_be32(QCOW_MAGIC), .version = cpu_to_be32(s->qcow_version), .backing_file_offset = 0, .backing_file_size = 0, .cluster_bits = cpu_to_be32(s->cluster_bits), .size = cpu_to_be64(total_size), .crypt_method = cpu_to_be32(s->crypt_method_header), .l1_size = cpu_to_be32(s->l1_size), .l1_table_offset = cpu_to_be64(s->l1_table_offset), .refcount_table_offset = cpu_to_be64(s->refcount_table_offset), .refcount_table_clusters = cpu_to_be32(refcount_table_clusters), .nb_snapshots = cpu_to_be32(s->nb_snapshots), .snapshots_offset = cpu_to_be64(s->snapshots_offset), /* Version 3 fields */ .incompatible_features = cpu_to_be64(s->incompatible_features), .compatible_features = cpu_to_be64(s->compatible_features), .autoclear_features = cpu_to_be64(s->autoclear_features), .refcount_order = cpu_to_be32(3 + REFCOUNT_SHIFT), .header_length = cpu_to_be32(header_length), }; /* For older versions, write a shorter header */ switch (s->qcow_version) { case 2: ret = offsetof(QCowHeader, incompatible_features); break; case 3: ret = sizeof(*header); break; default: ret = -EINVAL; goto fail; } buf += ret; buflen -= ret; memset(buf, 0, buflen); /* Preserve any unknown field in the header */ if (s->unknown_header_fields_size) { if (buflen < s->unknown_header_fields_size) { ret = -ENOSPC; goto fail; } memcpy(buf, s->unknown_header_fields, s->unknown_header_fields_size); buf += s->unknown_header_fields_size; buflen -= s->unknown_header_fields_size; } /* Backing file format header extension */ if (*bs->backing_format) { ret = header_ext_add(buf, QCOW2_EXT_MAGIC_BACKING_FORMAT, bs->backing_format, strlen(bs->backing_format), buflen); if (ret < 0) { goto fail; } buf += ret; buflen -= ret; } /* Feature table */ Qcow2Feature features[] = { .bit = QCOW2_INCOMPAT_DIRTY_BITNR, .name = "dirty bit", .type = QCOW2_FEAT_TYPE_COMPATIBLE, .bit = QCOW2_COMPAT_LAZY_REFCOUNTS_BITNR, .name = "lazy refcounts", }; ret = header_ext_add(buf, QCOW2_EXT_MAGIC_FEATURE_TABLE, features, sizeof(features), buflen); if (ret < 0) { goto fail; } buf += ret; buflen -= ret; /* Keep unknown header extensions */ QLIST_FOREACH(uext, &s->unknown_header_ext, next) { ret = header_ext_add(buf, uext->magic, uext->data, uext->len, buflen); if (ret < 0) { goto fail; } buf += ret; buflen -= ret; } /* End of header extensions */ ret = header_ext_add(buf, QCOW2_EXT_MAGIC_END, NULL, 0, buflen); if (ret < 0) { goto fail; } buf += ret; buflen -= ret; /* Backing file name */ if (*bs->backing_file) { size_t backing_file_len = strlen(bs->backing_file); if (buflen < backing_file_len) { ret = -ENOSPC; goto fail; } /* Using strncpy is ok here, since buf is not NUL-terminated. */ strncpy(buf, bs->backing_file, buflen); header->backing_file_offset = cpu_to_be64(buf - ((char*) header)); header->backing_file_size = cpu_to_be32(backing_file_len); } /* Write the new header */ ret = bdrv_pwrite(bs->file, 0, header, s->cluster_size); if (ret < 0) { goto fail; } ret = 0; fail: qemu_vfree(header); return ret; }
true
qemu
69c98726537627e708abb8fcb33e3a2b10e40bf1
int qcow2_update_header(BlockDriverState *bs) BDRVQcowState *s = bs->opaque; QCowHeader *header; char *buf; size_t buflen = s->cluster_size; int ret; uint64_t total_size; uint32_t refcount_table_clusters; size_t header_length; Qcow2UnknownHeaderExtension *uext; buf = qemu_blockalign(bs, buflen); header = (QCowHeader*) buf; if (buflen < sizeof(*header)) { ret = -ENOSPC; goto fail; } header_length = sizeof(*header) + s->unknown_header_fields_size; total_size = bs->total_sectors * BDRV_SECTOR_SIZE; refcount_table_clusters = s->refcount_table_size >> (s->cluster_bits - 3); *header = (QCowHeader) { .magic = cpu_to_be32(QCOW_MAGIC), .version = cpu_to_be32(s->qcow_version), .backing_file_offset = 0, .backing_file_size = 0, .cluster_bits = cpu_to_be32(s->cluster_bits), .size = cpu_to_be64(total_size), .crypt_method = cpu_to_be32(s->crypt_method_header), .l1_size = cpu_to_be32(s->l1_size), .l1_table_offset = cpu_to_be64(s->l1_table_offset), .refcount_table_offset = cpu_to_be64(s->refcount_table_offset), .refcount_table_clusters = cpu_to_be32(refcount_table_clusters), .nb_snapshots = cpu_to_be32(s->nb_snapshots), .snapshots_offset = cpu_to_be64(s->snapshots_offset), .incompatible_features = cpu_to_be64(s->incompatible_features), .compatible_features = cpu_to_be64(s->compatible_features), .autoclear_features = cpu_to_be64(s->autoclear_features), .refcount_order = cpu_to_be32(3 + REFCOUNT_SHIFT), .header_length = cpu_to_be32(header_length), }; switch (s->qcow_version) { case 2: ret = offsetof(QCowHeader, incompatible_features); break; case 3: ret = sizeof(*header); break; default: ret = -EINVAL; goto fail; } buf += ret; buflen -= ret; memset(buf, 0, buflen); if (s->unknown_header_fields_size) { if (buflen < s->unknown_header_fields_size) { ret = -ENOSPC; goto fail; } memcpy(buf, s->unknown_header_fields, s->unknown_header_fields_size); buf += s->unknown_header_fields_size; buflen -= s->unknown_header_fields_size; } if (*bs->backing_format) { ret = header_ext_add(buf, QCOW2_EXT_MAGIC_BACKING_FORMAT, bs->backing_format, strlen(bs->backing_format), buflen); if (ret < 0) { goto fail; } buf += ret; buflen -= ret; } Qcow2Feature features[] = { .bit = QCOW2_INCOMPAT_DIRTY_BITNR, .name = "dirty bit", .type = QCOW2_FEAT_TYPE_COMPATIBLE, .bit = QCOW2_COMPAT_LAZY_REFCOUNTS_BITNR, .name = "lazy refcounts", }; ret = header_ext_add(buf, QCOW2_EXT_MAGIC_FEATURE_TABLE, features, sizeof(features), buflen); if (ret < 0) { goto fail; } buf += ret; buflen -= ret; QLIST_FOREACH(uext, &s->unknown_header_ext, next) { ret = header_ext_add(buf, uext->magic, uext->data, uext->len, buflen); if (ret < 0) { goto fail; } buf += ret; buflen -= ret; } ret = header_ext_add(buf, QCOW2_EXT_MAGIC_END, NULL, 0, buflen); if (ret < 0) { goto fail; } buf += ret; buflen -= ret; if (*bs->backing_file) { size_t backing_file_len = strlen(bs->backing_file); if (buflen < backing_file_len) { ret = -ENOSPC; goto fail; } strncpy(buf, bs->backing_file, buflen); header->backing_file_offset = cpu_to_be64(buf - ((char*) header)); header->backing_file_size = cpu_to_be32(backing_file_len); } ret = bdrv_pwrite(bs->file, 0, header, s->cluster_size); if (ret < 0) { goto fail; } ret = 0; fail: qemu_vfree(header); return ret; }
{ "code": [], "line_no": [] }
int qcow2_update_header(BlockDriverState *bs) BDRVQcowState *s = bs->opaque; QCowHeader *VAR_8; char *VAR_8; size_t VAR_2 = s->cluster_size; int VAR_9; uint64_t VAR_8; uint32_t VAR_8; size_t VAR_8; Qcow2UnknownHeaderExtension *VAR_7; VAR_8 = qemu_blockalign(bs, VAR_2); VAR_8 = (QCowHeader*) VAR_8; if (VAR_2 < sizeof(*VAR_8)) { VAR_9 = -ENOSPC; goto VAR_9; } VAR_8 = sizeof(*VAR_8) + s->unknown_header_fields_size; VAR_8 = bs->total_sectors * BDRV_SECTOR_SIZE; VAR_8 = s->refcount_table_size >> (s->cluster_bits - 3); *VAR_8 = (QCowHeader) { .magic = cpu_to_be32(QCOW_MAGIC), .version = cpu_to_be32(s->qcow_version), .backing_file_offset = 0, .backing_file_size = 0, .cluster_bits = cpu_to_be32(s->cluster_bits), .size = cpu_to_be64(VAR_8), .crypt_method = cpu_to_be32(s->crypt_method_header), .l1_size = cpu_to_be32(s->l1_size), .l1_table_offset = cpu_to_be64(s->l1_table_offset), .refcount_table_offset = cpu_to_be64(s->refcount_table_offset), .VAR_8 = cpu_to_be32(VAR_8), .nb_snapshots = cpu_to_be32(s->nb_snapshots), .snapshots_offset = cpu_to_be64(s->snapshots_offset), .incompatible_features = cpu_to_be64(s->incompatible_features), .compatible_features = cpu_to_be64(s->compatible_features), .autoclear_features = cpu_to_be64(s->autoclear_features), .refcount_order = cpu_to_be32(3 + REFCOUNT_SHIFT), .VAR_8 = cpu_to_be32(VAR_8), }; switch (s->qcow_version) { case 2: VAR_9 = offsetof(QCowHeader, incompatible_features); break; case 3: VAR_9 = sizeof(*VAR_8); break; default: VAR_9 = -EINVAL; goto VAR_9; } VAR_8 += VAR_9; VAR_2 -= VAR_9; FUNC_0(VAR_8, 0, VAR_2); if (s->unknown_header_fields_size) { if (VAR_2 < s->unknown_header_fields_size) { VAR_9 = -ENOSPC; goto VAR_9; } memcpy(VAR_8, s->unknown_header_fields, s->unknown_header_fields_size); VAR_8 += s->unknown_header_fields_size; VAR_2 -= s->unknown_header_fields_size; } if (*bs->backing_format) { VAR_9 = header_ext_add(VAR_8, QCOW2_EXT_MAGIC_BACKING_FORMAT, bs->backing_format, strlen(bs->backing_format), VAR_2); if (VAR_9 < 0) { goto VAR_9; } VAR_8 += VAR_9; VAR_2 -= VAR_9; } Qcow2Feature VAR_8[] = { .bit = QCOW2_INCOMPAT_DIRTY_BITNR, .name = "dirty bit", .type = QCOW2_FEAT_TYPE_COMPATIBLE, .bit = QCOW2_COMPAT_LAZY_REFCOUNTS_BITNR, .name = "lazy refcounts", }; VAR_9 = header_ext_add(VAR_8, QCOW2_EXT_MAGIC_FEATURE_TABLE, VAR_8, sizeof(VAR_8), VAR_2); if (VAR_9 < 0) { goto VAR_9; } VAR_8 += VAR_9; VAR_2 -= VAR_9; FUNC_1(VAR_7, &s->unknown_header_ext, next) { VAR_9 = header_ext_add(VAR_8, VAR_7->magic, VAR_7->data, VAR_7->len, VAR_2); if (VAR_9 < 0) { goto VAR_9; } VAR_8 += VAR_9; VAR_2 -= VAR_9; } VAR_9 = header_ext_add(VAR_8, QCOW2_EXT_MAGIC_END, NULL, 0, VAR_2); if (VAR_9 < 0) { goto VAR_9; } VAR_8 += VAR_9; VAR_2 -= VAR_9; if (*bs->backing_file) { size_t backing_file_len = strlen(bs->backing_file); if (VAR_2 < backing_file_len) { VAR_9 = -ENOSPC; goto VAR_9; } strncpy(VAR_8, bs->backing_file, VAR_2); VAR_8->backing_file_offset = cpu_to_be64(VAR_8 - ((char*) VAR_8)); VAR_8->backing_file_size = cpu_to_be32(backing_file_len); } VAR_9 = bdrv_pwrite(bs->file, 0, VAR_8, s->cluster_size); if (VAR_9 < 0) { goto VAR_9; } VAR_9 = 0; VAR_9: FUNC_2(VAR_8); return VAR_9; }
[ "int qcow2_update_header(BlockDriverState *bs)\nBDRVQcowState *s = bs->opaque;", "QCowHeader *VAR_8;", "char *VAR_8;", "size_t VAR_2 = s->cluster_size;", "int VAR_9;", "uint64_t VAR_8;", "uint32_t VAR_8;", "size_t VAR_8;", "Qcow2UnknownHeaderExtension *VAR_7;", "VAR_8 = qemu_blockalign(bs, VAR_2);", "VAR_8 = (QCowHeader*) VAR_8;", "if (VAR_2 < sizeof(*VAR_8)) {", "VAR_9 = -ENOSPC;", "goto VAR_9;", "}", "VAR_8 = sizeof(*VAR_8) + s->unknown_header_fields_size;", "VAR_8 = bs->total_sectors * BDRV_SECTOR_SIZE;", "VAR_8 = s->refcount_table_size >> (s->cluster_bits - 3);", "*VAR_8 = (QCowHeader) {", ".magic = cpu_to_be32(QCOW_MAGIC),\n.version = cpu_to_be32(s->qcow_version),\n.backing_file_offset = 0,\n.backing_file_size = 0,\n.cluster_bits = cpu_to_be32(s->cluster_bits),\n.size = cpu_to_be64(VAR_8),\n.crypt_method = cpu_to_be32(s->crypt_method_header),\n.l1_size = cpu_to_be32(s->l1_size),\n.l1_table_offset = cpu_to_be64(s->l1_table_offset),\n.refcount_table_offset = cpu_to_be64(s->refcount_table_offset),\n.VAR_8 = cpu_to_be32(VAR_8),\n.nb_snapshots = cpu_to_be32(s->nb_snapshots),\n.snapshots_offset = cpu_to_be64(s->snapshots_offset),\n.incompatible_features = cpu_to_be64(s->incompatible_features),\n.compatible_features = cpu_to_be64(s->compatible_features),\n.autoclear_features = cpu_to_be64(s->autoclear_features),\n.refcount_order = cpu_to_be32(3 + REFCOUNT_SHIFT),\n.VAR_8 = cpu_to_be32(VAR_8),\n};", "switch (s->qcow_version) {", "case 2:\nVAR_9 = offsetof(QCowHeader, incompatible_features);", "break;", "case 3:\nVAR_9 = sizeof(*VAR_8);", "break;", "default:\nVAR_9 = -EINVAL;", "goto VAR_9;", "}", "VAR_8 += VAR_9;", "VAR_2 -= VAR_9;", "FUNC_0(VAR_8, 0, VAR_2);", "if (s->unknown_header_fields_size) {", "if (VAR_2 < s->unknown_header_fields_size) {", "VAR_9 = -ENOSPC;", "goto VAR_9;", "}", "memcpy(VAR_8, s->unknown_header_fields, s->unknown_header_fields_size);", "VAR_8 += s->unknown_header_fields_size;", "VAR_2 -= s->unknown_header_fields_size;", "}", "if (*bs->backing_format) {", "VAR_9 = header_ext_add(VAR_8, QCOW2_EXT_MAGIC_BACKING_FORMAT,\nbs->backing_format, strlen(bs->backing_format),\nVAR_2);", "if (VAR_9 < 0) {", "goto VAR_9;", "}", "VAR_8 += VAR_9;", "VAR_2 -= VAR_9;", "}", "Qcow2Feature VAR_8[] = {", ".bit = QCOW2_INCOMPAT_DIRTY_BITNR,\n.name = \"dirty bit\",\n.type = QCOW2_FEAT_TYPE_COMPATIBLE,\n.bit = QCOW2_COMPAT_LAZY_REFCOUNTS_BITNR,\n.name = \"lazy refcounts\",\n};", "VAR_9 = header_ext_add(VAR_8, QCOW2_EXT_MAGIC_FEATURE_TABLE,\nVAR_8, sizeof(VAR_8), VAR_2);", "if (VAR_9 < 0) {", "goto VAR_9;", "}", "VAR_8 += VAR_9;", "VAR_2 -= VAR_9;", "FUNC_1(VAR_7, &s->unknown_header_ext, next) {", "VAR_9 = header_ext_add(VAR_8, VAR_7->magic, VAR_7->data, VAR_7->len, VAR_2);", "if (VAR_9 < 0) {", "goto VAR_9;", "}", "VAR_8 += VAR_9;", "VAR_2 -= VAR_9;", "}", "VAR_9 = header_ext_add(VAR_8, QCOW2_EXT_MAGIC_END, NULL, 0, VAR_2);", "if (VAR_9 < 0) {", "goto VAR_9;", "}", "VAR_8 += VAR_9;", "VAR_2 -= VAR_9;", "if (*bs->backing_file) {", "size_t backing_file_len = strlen(bs->backing_file);", "if (VAR_2 < backing_file_len) {", "VAR_9 = -ENOSPC;", "goto VAR_9;", "}", "strncpy(VAR_8, bs->backing_file, VAR_2);", "VAR_8->backing_file_offset = cpu_to_be64(VAR_8 - ((char*) VAR_8));", "VAR_8->backing_file_size = cpu_to_be32(backing_file_len);", "}", "VAR_9 = bdrv_pwrite(bs->file, 0, VAR_8, s->cluster_size);", "if (VAR_9 < 0) {", "goto VAR_9;", "}", "VAR_9 = 0;", "VAR_9:\nFUNC_2(VAR_8);", "return VAR_9;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 4 ], [ 6 ], [ 8 ], [ 10 ], [ 12 ], [ 14 ], [ 16 ], [ 18 ], [ 20 ], [ 24 ], [ 30 ], [ 34 ], [ 36 ], [ 38 ], [ 40 ], [ 44 ], [ 46 ], [ 48 ], [ 52 ], [ 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 86, 88, 90, 92, 94, 96 ], [ 102 ], [ 104, 106 ], [ 108 ], [ 110, 112 ], [ 114 ], [ 116, 118 ], [ 120 ], [ 122 ], [ 126 ], [ 128 ], [ 130 ], [ 136 ], [ 138 ], [ 140 ], [ 142 ], [ 144 ], [ 148 ], [ 150 ], [ 152 ], [ 154 ], [ 160 ], [ 162, 164, 166 ], [ 168 ], [ 170 ], [ 172 ], [ 176 ], [ 178 ], [ 180 ], [ 186 ], [ 190, 192, 201, 203, 205, 208 ], [ 212, 214 ], [ 216 ], [ 218 ], [ 220 ], [ 222 ], [ 224 ], [ 230 ], [ 232 ], [ 234 ], [ 236 ], [ 238 ], [ 242 ], [ 244 ], [ 246 ], [ 252 ], [ 254 ], [ 256 ], [ 258 ], [ 262 ], [ 264 ], [ 270 ], [ 272 ], [ 276 ], [ 278 ], [ 280 ], [ 282 ], [ 288 ], [ 292 ], [ 294 ], [ 296 ], [ 302 ], [ 304 ], [ 306 ], [ 308 ], [ 312 ], [ 314, 316 ], [ 318 ], [ 320 ] ]
8,823
void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp) { #if HAVE_YASM int mm_flags = av_get_cpu_flags(); if (mm_flags & AV_CPU_FLAG_SSE && HAVE_SSE) { fdsp->vector_fmul = ff_vector_fmul_sse; fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_sse; } if (mm_flags & AV_CPU_FLAG_AVX && HAVE_AVX) { fdsp->vector_fmul = ff_vector_fmul_avx; fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_avx; } #endif }
false
FFmpeg
e0c6cce44729d94e2a5507a4b6d031f23e8bd7b6
void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp) { #if HAVE_YASM int mm_flags = av_get_cpu_flags(); if (mm_flags & AV_CPU_FLAG_SSE && HAVE_SSE) { fdsp->vector_fmul = ff_vector_fmul_sse; fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_sse; } if (mm_flags & AV_CPU_FLAG_AVX && HAVE_AVX) { fdsp->vector_fmul = ff_vector_fmul_avx; fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_avx; } #endif }
{ "code": [], "line_no": [] }
void FUNC_0(AVFloatDSPContext *VAR_0) { #if HAVE_YASM int mm_flags = av_get_cpu_flags(); if (mm_flags & AV_CPU_FLAG_SSE && HAVE_SSE) { VAR_0->vector_fmul = ff_vector_fmul_sse; VAR_0->vector_fmac_scalar = ff_vector_fmac_scalar_sse; } if (mm_flags & AV_CPU_FLAG_AVX && HAVE_AVX) { VAR_0->vector_fmul = ff_vector_fmul_avx; VAR_0->vector_fmac_scalar = ff_vector_fmac_scalar_avx; } #endif }
[ "void FUNC_0(AVFloatDSPContext *VAR_0)\n{", "#if HAVE_YASM\nint mm_flags = av_get_cpu_flags();", "if (mm_flags & AV_CPU_FLAG_SSE && HAVE_SSE) {", "VAR_0->vector_fmul = ff_vector_fmul_sse;", "VAR_0->vector_fmac_scalar = ff_vector_fmac_scalar_sse;", "}", "if (mm_flags & AV_CPU_FLAG_AVX && HAVE_AVX) {", "VAR_0->vector_fmul = ff_vector_fmul_avx;", "VAR_0->vector_fmac_scalar = ff_vector_fmac_scalar_avx;", "}", "#endif\n}" ]
[ 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 ] ]
8,824
static void dequantization_float(int x, int y, Jpeg2000Cblk *cblk, Jpeg2000Component *comp, Jpeg2000T1Context *t1, Jpeg2000Band *band) { int i, j; int w = cblk->coord[0][1] - cblk->coord[0][0]; for (j = 0; j < (cblk->coord[1][1] - cblk->coord[1][0]); ++j) { float *datap = &comp->f_data[(comp->coord[0][1] - comp->coord[0][0]) * (y + j) + x]; int *src = t1->data[j]; for (i = 0; i < w; ++i) datap[i] = src[i] * band->f_stepsize; } }
false
FFmpeg
f1e173049ecc9de03817385ba8962d14cba779db
static void dequantization_float(int x, int y, Jpeg2000Cblk *cblk, Jpeg2000Component *comp, Jpeg2000T1Context *t1, Jpeg2000Band *band) { int i, j; int w = cblk->coord[0][1] - cblk->coord[0][0]; for (j = 0; j < (cblk->coord[1][1] - cblk->coord[1][0]); ++j) { float *datap = &comp->f_data[(comp->coord[0][1] - comp->coord[0][0]) * (y + j) + x]; int *src = t1->data[j]; for (i = 0; i < w; ++i) datap[i] = src[i] * band->f_stepsize; } }
{ "code": [], "line_no": [] }
static void FUNC_0(int VAR_0, int VAR_1, Jpeg2000Cblk *VAR_2, Jpeg2000Component *VAR_3, Jpeg2000T1Context *VAR_4, Jpeg2000Band *VAR_5) { int VAR_6, VAR_7; int VAR_8 = VAR_2->coord[0][1] - VAR_2->coord[0][0]; for (VAR_7 = 0; VAR_7 < (VAR_2->coord[1][1] - VAR_2->coord[1][0]); ++VAR_7) { float *datap = &VAR_3->f_data[(VAR_3->coord[0][1] - VAR_3->coord[0][0]) * (VAR_1 + VAR_7) + VAR_0]; int *src = VAR_4->data[VAR_7]; for (VAR_6 = 0; VAR_6 < VAR_8; ++VAR_6) datap[VAR_6] = src[VAR_6] * VAR_5->f_stepsize; } }
[ "static void FUNC_0(int VAR_0, int VAR_1, Jpeg2000Cblk *VAR_2,\nJpeg2000Component *VAR_3,\nJpeg2000T1Context *VAR_4, Jpeg2000Band *VAR_5)\n{", "int VAR_6, VAR_7;", "int VAR_8 = VAR_2->coord[0][1] - VAR_2->coord[0][0];", "for (VAR_7 = 0; VAR_7 < (VAR_2->coord[1][1] - VAR_2->coord[1][0]); ++VAR_7) {", "float *datap = &VAR_3->f_data[(VAR_3->coord[0][1] - VAR_3->coord[0][0]) * (VAR_1 + VAR_7) + VAR_0];", "int *src = VAR_4->data[VAR_7];", "for (VAR_6 = 0; VAR_6 < VAR_8; ++VAR_6)", "datap[VAR_6] = src[VAR_6] * VAR_5->f_stepsize;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ] ]
8,826
static int read_extra_header(FFV1Context *f) { RangeCoder *const c = &f->c; uint8_t state[CONTEXT_SIZE]; int i, j, k, ret; uint8_t state2[32][CONTEXT_SIZE]; memset(state2, 128, sizeof(state2)); memset(state, 128, sizeof(state)); ff_init_range_decoder(c, f->avctx->extradata, f->avctx->extradata_size); ff_build_rac_states(c, 0.05 * (1LL << 32), 256 - 8); f->version = get_symbol(c, state, 0); if (f->version < 2) { av_log(f->avctx, AV_LOG_ERROR, "Invalid version in global header\n"); return AVERROR_INVALIDDATA; } if (f->version > 2) { c->bytestream_end -= 4; f->micro_version = get_symbol(c, state, 0); if (f->micro_version < 0) return AVERROR_INVALIDDATA; } f->ac = f->avctx->coder_type = get_symbol(c, state, 0); if (f->ac > 1) { for (i = 1; i < 256; i++) f->state_transition[i] = get_symbol(c, state, 1) + c->one_state[i]; } f->colorspace = get_symbol(c, state, 0); //YUV cs type f->avctx->bits_per_raw_sample = get_symbol(c, state, 0); f->chroma_planes = get_rac(c, state); f->chroma_h_shift = get_symbol(c, state, 0); f->chroma_v_shift = get_symbol(c, state, 0); f->transparency = get_rac(c, state); f->plane_count = 1 + (f->chroma_planes || f->version<4) + f->transparency; f->num_h_slices = 1 + get_symbol(c, state, 0); f->num_v_slices = 1 + get_symbol(c, state, 0); if (f->chroma_h_shift > 4U || f->chroma_v_shift > 4U) { av_log(f->avctx, AV_LOG_ERROR, "chroma shift parameters %d %d are invalid\n", f->chroma_h_shift, f->chroma_v_shift); return AVERROR_INVALIDDATA; } if (f->num_h_slices > (unsigned)f->width || !f->num_h_slices || f->num_v_slices > (unsigned)f->height || !f->num_v_slices ) { av_log(f->avctx, AV_LOG_ERROR, "slice count invalid\n"); return AVERROR_INVALIDDATA; } f->quant_table_count = get_symbol(c, state, 0); if (f->quant_table_count > (unsigned)MAX_QUANT_TABLES) return AVERROR_INVALIDDATA; for (i = 0; i < f->quant_table_count; i++) { f->context_count[i] = read_quant_tables(c, f->quant_tables[i]); if (f->context_count[i] < 0) { av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n"); return AVERROR_INVALIDDATA; } } if ((ret = ff_ffv1_allocate_initial_states(f)) < 0) return ret; for (i = 0; i < f->quant_table_count; i++) if (get_rac(c, state)) { for (j = 0; j < f->context_count[i]; j++) for (k = 0; k < CONTEXT_SIZE; k++) { int pred = j ? f->initial_states[i][j - 1][k] : 128; f->initial_states[i][j][k] = (pred + get_symbol(c, state2[k], 1)) & 0xFF; } } if (f->version > 2) { f->ec = get_symbol(c, state, 0); if (f->micro_version > 2) f->intra = get_symbol(c, state, 0); } if (f->version > 2) { unsigned v; v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, f->avctx->extradata, f->avctx->extradata_size); if (v) { av_log(f->avctx, AV_LOG_ERROR, "CRC mismatch %X!\n", v); return AVERROR_INVALIDDATA; } } if (f->avctx->debug & FF_DEBUG_PICT_INFO) av_log(f->avctx, AV_LOG_DEBUG, "global: ver:%d.%d, coder:%d, colorspace: %d bpr:%d chroma:%d(%d:%d), alpha:%d slices:%dx%d qtabs:%d ec:%d intra:%d\n", f->version, f->micro_version, f->ac, f->colorspace, f->avctx->bits_per_raw_sample, f->chroma_planes, f->chroma_h_shift, f->chroma_v_shift, f->transparency, f->num_h_slices, f->num_v_slices, f->quant_table_count, f->ec, f->intra ); return 0; }
false
FFmpeg
eac161451d248fdd375d403f9bb7d0bec68bc40b
static int read_extra_header(FFV1Context *f) { RangeCoder *const c = &f->c; uint8_t state[CONTEXT_SIZE]; int i, j, k, ret; uint8_t state2[32][CONTEXT_SIZE]; memset(state2, 128, sizeof(state2)); memset(state, 128, sizeof(state)); ff_init_range_decoder(c, f->avctx->extradata, f->avctx->extradata_size); ff_build_rac_states(c, 0.05 * (1LL << 32), 256 - 8); f->version = get_symbol(c, state, 0); if (f->version < 2) { av_log(f->avctx, AV_LOG_ERROR, "Invalid version in global header\n"); return AVERROR_INVALIDDATA; } if (f->version > 2) { c->bytestream_end -= 4; f->micro_version = get_symbol(c, state, 0); if (f->micro_version < 0) return AVERROR_INVALIDDATA; } f->ac = f->avctx->coder_type = get_symbol(c, state, 0); if (f->ac > 1) { for (i = 1; i < 256; i++) f->state_transition[i] = get_symbol(c, state, 1) + c->one_state[i]; } f->colorspace = get_symbol(c, state, 0); f->avctx->bits_per_raw_sample = get_symbol(c, state, 0); f->chroma_planes = get_rac(c, state); f->chroma_h_shift = get_symbol(c, state, 0); f->chroma_v_shift = get_symbol(c, state, 0); f->transparency = get_rac(c, state); f->plane_count = 1 + (f->chroma_planes || f->version<4) + f->transparency; f->num_h_slices = 1 + get_symbol(c, state, 0); f->num_v_slices = 1 + get_symbol(c, state, 0); if (f->chroma_h_shift > 4U || f->chroma_v_shift > 4U) { av_log(f->avctx, AV_LOG_ERROR, "chroma shift parameters %d %d are invalid\n", f->chroma_h_shift, f->chroma_v_shift); return AVERROR_INVALIDDATA; } if (f->num_h_slices > (unsigned)f->width || !f->num_h_slices || f->num_v_slices > (unsigned)f->height || !f->num_v_slices ) { av_log(f->avctx, AV_LOG_ERROR, "slice count invalid\n"); return AVERROR_INVALIDDATA; } f->quant_table_count = get_symbol(c, state, 0); if (f->quant_table_count > (unsigned)MAX_QUANT_TABLES) return AVERROR_INVALIDDATA; for (i = 0; i < f->quant_table_count; i++) { f->context_count[i] = read_quant_tables(c, f->quant_tables[i]); if (f->context_count[i] < 0) { av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n"); return AVERROR_INVALIDDATA; } } if ((ret = ff_ffv1_allocate_initial_states(f)) < 0) return ret; for (i = 0; i < f->quant_table_count; i++) if (get_rac(c, state)) { for (j = 0; j < f->context_count[i]; j++) for (k = 0; k < CONTEXT_SIZE; k++) { int pred = j ? f->initial_states[i][j - 1][k] : 128; f->initial_states[i][j][k] = (pred + get_symbol(c, state2[k], 1)) & 0xFF; } } if (f->version > 2) { f->ec = get_symbol(c, state, 0); if (f->micro_version > 2) f->intra = get_symbol(c, state, 0); } if (f->version > 2) { unsigned v; v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, f->avctx->extradata, f->avctx->extradata_size); if (v) { av_log(f->avctx, AV_LOG_ERROR, "CRC mismatch %X!\n", v); return AVERROR_INVALIDDATA; } } if (f->avctx->debug & FF_DEBUG_PICT_INFO) av_log(f->avctx, AV_LOG_DEBUG, "global: ver:%d.%d, coder:%d, colorspace: %d bpr:%d chroma:%d(%d:%d), alpha:%d slices:%dx%d qtabs:%d ec:%d intra:%d\n", f->version, f->micro_version, f->ac, f->colorspace, f->avctx->bits_per_raw_sample, f->chroma_planes, f->chroma_h_shift, f->chroma_v_shift, f->transparency, f->num_h_slices, f->num_v_slices, f->quant_table_count, f->ec, f->intra ); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(FFV1Context *VAR_0) { RangeCoder *const c = &VAR_0->c; uint8_t state[CONTEXT_SIZE]; int VAR_1, VAR_2, VAR_3, VAR_4; uint8_t state2[32][CONTEXT_SIZE]; memset(state2, 128, sizeof(state2)); memset(state, 128, sizeof(state)); ff_init_range_decoder(c, VAR_0->avctx->extradata, VAR_0->avctx->extradata_size); ff_build_rac_states(c, 0.05 * (1LL << 32), 256 - 8); VAR_0->version = get_symbol(c, state, 0); if (VAR_0->version < 2) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid version in global header\n"); return AVERROR_INVALIDDATA; } if (VAR_0->version > 2) { c->bytestream_end -= 4; VAR_0->micro_version = get_symbol(c, state, 0); if (VAR_0->micro_version < 0) return AVERROR_INVALIDDATA; } VAR_0->ac = VAR_0->avctx->coder_type = get_symbol(c, state, 0); if (VAR_0->ac > 1) { for (VAR_1 = 1; VAR_1 < 256; VAR_1++) VAR_0->state_transition[VAR_1] = get_symbol(c, state, 1) + c->one_state[VAR_1]; } VAR_0->colorspace = get_symbol(c, state, 0); VAR_0->avctx->bits_per_raw_sample = get_symbol(c, state, 0); VAR_0->chroma_planes = get_rac(c, state); VAR_0->chroma_h_shift = get_symbol(c, state, 0); VAR_0->chroma_v_shift = get_symbol(c, state, 0); VAR_0->transparency = get_rac(c, state); VAR_0->plane_count = 1 + (VAR_0->chroma_planes || VAR_0->version<4) + VAR_0->transparency; VAR_0->num_h_slices = 1 + get_symbol(c, state, 0); VAR_0->num_v_slices = 1 + get_symbol(c, state, 0); if (VAR_0->chroma_h_shift > 4U || VAR_0->chroma_v_shift > 4U) { av_log(VAR_0->avctx, AV_LOG_ERROR, "chroma shift parameters %d %d are invalid\n", VAR_0->chroma_h_shift, VAR_0->chroma_v_shift); return AVERROR_INVALIDDATA; } if (VAR_0->num_h_slices > (unsigned)VAR_0->width || !VAR_0->num_h_slices || VAR_0->num_v_slices > (unsigned)VAR_0->height || !VAR_0->num_v_slices ) { av_log(VAR_0->avctx, AV_LOG_ERROR, "slice count invalid\n"); return AVERROR_INVALIDDATA; } VAR_0->quant_table_count = get_symbol(c, state, 0); if (VAR_0->quant_table_count > (unsigned)MAX_QUANT_TABLES) return AVERROR_INVALIDDATA; for (VAR_1 = 0; VAR_1 < VAR_0->quant_table_count; VAR_1++) { VAR_0->context_count[VAR_1] = read_quant_tables(c, VAR_0->quant_tables[VAR_1]); if (VAR_0->context_count[VAR_1] < 0) { av_log(VAR_0->avctx, AV_LOG_ERROR, "read_quant_table error\n"); return AVERROR_INVALIDDATA; } } if ((VAR_4 = ff_ffv1_allocate_initial_states(VAR_0)) < 0) return VAR_4; for (VAR_1 = 0; VAR_1 < VAR_0->quant_table_count; VAR_1++) if (get_rac(c, state)) { for (VAR_2 = 0; VAR_2 < VAR_0->context_count[VAR_1]; VAR_2++) for (VAR_3 = 0; VAR_3 < CONTEXT_SIZE; VAR_3++) { int pred = VAR_2 ? VAR_0->initial_states[VAR_1][VAR_2 - 1][VAR_3] : 128; VAR_0->initial_states[VAR_1][VAR_2][VAR_3] = (pred + get_symbol(c, state2[VAR_3], 1)) & 0xFF; } } if (VAR_0->version > 2) { VAR_0->ec = get_symbol(c, state, 0); if (VAR_0->micro_version > 2) VAR_0->intra = get_symbol(c, state, 0); } if (VAR_0->version > 2) { unsigned VAR_5; VAR_5 = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, VAR_0->avctx->extradata, VAR_0->avctx->extradata_size); if (VAR_5) { av_log(VAR_0->avctx, AV_LOG_ERROR, "CRC mismatch %X!\n", VAR_5); return AVERROR_INVALIDDATA; } } if (VAR_0->avctx->debug & FF_DEBUG_PICT_INFO) av_log(VAR_0->avctx, AV_LOG_DEBUG, "global: ver:%d.%d, coder:%d, colorspace: %d bpr:%d chroma:%d(%d:%d), alpha:%d slices:%dx%d qtabs:%d ec:%d intra:%d\n", VAR_0->version, VAR_0->micro_version, VAR_0->ac, VAR_0->colorspace, VAR_0->avctx->bits_per_raw_sample, VAR_0->chroma_planes, VAR_0->chroma_h_shift, VAR_0->chroma_v_shift, VAR_0->transparency, VAR_0->num_h_slices, VAR_0->num_v_slices, VAR_0->quant_table_count, VAR_0->ec, VAR_0->intra ); return 0; }
[ "static int FUNC_0(FFV1Context *VAR_0)\n{", "RangeCoder *const c = &VAR_0->c;", "uint8_t state[CONTEXT_SIZE];", "int VAR_1, VAR_2, VAR_3, VAR_4;", "uint8_t state2[32][CONTEXT_SIZE];", "memset(state2, 128, sizeof(state2));", "memset(state, 128, sizeof(state));", "ff_init_range_decoder(c, VAR_0->avctx->extradata, VAR_0->avctx->extradata_size);", "ff_build_rac_states(c, 0.05 * (1LL << 32), 256 - 8);", "VAR_0->version = get_symbol(c, state, 0);", "if (VAR_0->version < 2) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid version in global header\\n\");", "return AVERROR_INVALIDDATA;", "}", "if (VAR_0->version > 2) {", "c->bytestream_end -= 4;", "VAR_0->micro_version = get_symbol(c, state, 0);", "if (VAR_0->micro_version < 0)\nreturn AVERROR_INVALIDDATA;", "}", "VAR_0->ac = VAR_0->avctx->coder_type = get_symbol(c, state, 0);", "if (VAR_0->ac > 1) {", "for (VAR_1 = 1; VAR_1 < 256; VAR_1++)", "VAR_0->state_transition[VAR_1] = get_symbol(c, state, 1) + c->one_state[VAR_1];", "}", "VAR_0->colorspace = get_symbol(c, state, 0);", "VAR_0->avctx->bits_per_raw_sample = get_symbol(c, state, 0);", "VAR_0->chroma_planes = get_rac(c, state);", "VAR_0->chroma_h_shift = get_symbol(c, state, 0);", "VAR_0->chroma_v_shift = get_symbol(c, state, 0);", "VAR_0->transparency = get_rac(c, state);", "VAR_0->plane_count = 1 + (VAR_0->chroma_planes || VAR_0->version<4) + VAR_0->transparency;", "VAR_0->num_h_slices = 1 + get_symbol(c, state, 0);", "VAR_0->num_v_slices = 1 + get_symbol(c, state, 0);", "if (VAR_0->chroma_h_shift > 4U || VAR_0->chroma_v_shift > 4U) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"chroma shift parameters %d %d are invalid\\n\",\nVAR_0->chroma_h_shift, VAR_0->chroma_v_shift);", "return AVERROR_INVALIDDATA;", "}", "if (VAR_0->num_h_slices > (unsigned)VAR_0->width || !VAR_0->num_h_slices ||\nVAR_0->num_v_slices > (unsigned)VAR_0->height || !VAR_0->num_v_slices\n) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"slice count invalid\\n\");", "return AVERROR_INVALIDDATA;", "}", "VAR_0->quant_table_count = get_symbol(c, state, 0);", "if (VAR_0->quant_table_count > (unsigned)MAX_QUANT_TABLES)\nreturn AVERROR_INVALIDDATA;", "for (VAR_1 = 0; VAR_1 < VAR_0->quant_table_count; VAR_1++) {", "VAR_0->context_count[VAR_1] = read_quant_tables(c, VAR_0->quant_tables[VAR_1]);", "if (VAR_0->context_count[VAR_1] < 0) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"read_quant_table error\\n\");", "return AVERROR_INVALIDDATA;", "}", "}", "if ((VAR_4 = ff_ffv1_allocate_initial_states(VAR_0)) < 0)\nreturn VAR_4;", "for (VAR_1 = 0; VAR_1 < VAR_0->quant_table_count; VAR_1++)", "if (get_rac(c, state)) {", "for (VAR_2 = 0; VAR_2 < VAR_0->context_count[VAR_1]; VAR_2++)", "for (VAR_3 = 0; VAR_3 < CONTEXT_SIZE; VAR_3++) {", "int pred = VAR_2 ? VAR_0->initial_states[VAR_1][VAR_2 - 1][VAR_3] : 128;", "VAR_0->initial_states[VAR_1][VAR_2][VAR_3] =\n(pred + get_symbol(c, state2[VAR_3], 1)) & 0xFF;", "}", "}", "if (VAR_0->version > 2) {", "VAR_0->ec = get_symbol(c, state, 0);", "if (VAR_0->micro_version > 2)\nVAR_0->intra = get_symbol(c, state, 0);", "}", "if (VAR_0->version > 2) {", "unsigned VAR_5;", "VAR_5 = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0,\nVAR_0->avctx->extradata, VAR_0->avctx->extradata_size);", "if (VAR_5) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"CRC mismatch %X!\\n\", VAR_5);", "return AVERROR_INVALIDDATA;", "}", "}", "if (VAR_0->avctx->debug & FF_DEBUG_PICT_INFO)\nav_log(VAR_0->avctx, AV_LOG_DEBUG,\n\"global: ver:%d.%d, coder:%d, colorspace: %d bpr:%d chroma:%d(%d:%d), alpha:%d slices:%dx%d qtabs:%d ec:%d intra:%d\\n\",\nVAR_0->version, VAR_0->micro_version,\nVAR_0->ac,\nVAR_0->colorspace,\nVAR_0->avctx->bits_per_raw_sample,\nVAR_0->chroma_planes, VAR_0->chroma_h_shift, VAR_0->chroma_v_shift,\nVAR_0->transparency,\nVAR_0->num_h_slices, VAR_0->num_v_slices,\nVAR_0->quant_table_count,\nVAR_0->ec,\nVAR_0->intra\n);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43, 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 81 ], [ 83, 85 ], [ 87 ], [ 89 ], [ 93, 95, 97 ], [ 99 ], [ 101 ], [ 103 ], [ 107 ], [ 109, 111 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129, 131 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145, 147 ], [ 149 ], [ 151 ], [ 155 ], [ 157 ], [ 159, 161 ], [ 163 ], [ 167 ], [ 169 ], [ 171, 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 187, 189, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213 ], [ 215 ], [ 217 ] ]
8,828
int ff_v4l2_m2m_codec_end(AVCodecContext *avctx) { V4L2m2mContext* s = avctx->priv_data; int ret; ret = ff_v4l2_context_set_status(&s->output, VIDIOC_STREAMOFF); if (ret) av_log(avctx, AV_LOG_ERROR, "VIDIOC_STREAMOFF %s\n", s->output.name); ret = ff_v4l2_context_set_status(&s->capture, VIDIOC_STREAMOFF); if (ret) av_log(avctx, AV_LOG_ERROR, "VIDIOC_STREAMOFF %s\n", s->capture.name); ff_v4l2_context_release(&s->output); if (atomic_load(&s->refcount)) av_log(avctx, AV_LOG_ERROR, "ff_v4l2m2m_codec_end leaving pending buffers\n"); ff_v4l2_context_release(&s->capture); sem_destroy(&s->refsync); /* release the hardware */ if (close(s->fd) < 0 ) av_log(avctx, AV_LOG_ERROR, "failure closing %s (%s)\n", s->devname, av_err2str(AVERROR(errno))); s->fd = -1; return 0; }
true
FFmpeg
a0c624e299730c8c5800375c2f5f3c6c200053ff
int ff_v4l2_m2m_codec_end(AVCodecContext *avctx) { V4L2m2mContext* s = avctx->priv_data; int ret; ret = ff_v4l2_context_set_status(&s->output, VIDIOC_STREAMOFF); if (ret) av_log(avctx, AV_LOG_ERROR, "VIDIOC_STREAMOFF %s\n", s->output.name); ret = ff_v4l2_context_set_status(&s->capture, VIDIOC_STREAMOFF); if (ret) av_log(avctx, AV_LOG_ERROR, "VIDIOC_STREAMOFF %s\n", s->capture.name); ff_v4l2_context_release(&s->output); if (atomic_load(&s->refcount)) av_log(avctx, AV_LOG_ERROR, "ff_v4l2m2m_codec_end leaving pending buffers\n"); ff_v4l2_context_release(&s->capture); sem_destroy(&s->refsync); if (close(s->fd) < 0 ) av_log(avctx, AV_LOG_ERROR, "failure closing %s (%s)\n", s->devname, av_err2str(AVERROR(errno))); s->fd = -1; return 0; }
{ "code": [ " sem_destroy(&s->refsync);", " s->fd = -1;", " V4L2m2mContext* s = avctx->priv_data;", " if (atomic_load(&s->refcount))", " av_log(avctx, AV_LOG_ERROR, \"ff_v4l2m2m_codec_end leaving pending buffers\\n\");", " ff_v4l2_context_release(&s->capture);", " sem_destroy(&s->refsync);", " if (close(s->fd) < 0 )", " av_log(avctx, AV_LOG_ERROR, \"failure closing %s (%s)\\n\", s->devname, av_err2str(AVERROR(errno)));", " s->fd = -1;" ], "line_no": [ 39, 51, 5, 31, 33, 37, 39, 45, 47, 51 ] }
int FUNC_0(AVCodecContext *VAR_0) { V4L2m2mContext* s = VAR_0->priv_data; int VAR_1; VAR_1 = ff_v4l2_context_set_status(&s->output, VIDIOC_STREAMOFF); if (VAR_1) av_log(VAR_0, AV_LOG_ERROR, "VIDIOC_STREAMOFF %s\n", s->output.name); VAR_1 = ff_v4l2_context_set_status(&s->capture, VIDIOC_STREAMOFF); if (VAR_1) av_log(VAR_0, AV_LOG_ERROR, "VIDIOC_STREAMOFF %s\n", s->capture.name); ff_v4l2_context_release(&s->output); if (atomic_load(&s->refcount)) av_log(VAR_0, AV_LOG_ERROR, "ff_v4l2m2m_codec_end leaving pending buffers\n"); ff_v4l2_context_release(&s->capture); sem_destroy(&s->refsync); if (close(s->fd) < 0 ) av_log(VAR_0, AV_LOG_ERROR, "failure closing %s (%s)\n", s->devname, av_err2str(AVERROR(errno))); s->fd = -1; return 0; }
[ "int FUNC_0(AVCodecContext *VAR_0)\n{", "V4L2m2mContext* s = VAR_0->priv_data;", "int VAR_1;", "VAR_1 = ff_v4l2_context_set_status(&s->output, VIDIOC_STREAMOFF);", "if (VAR_1)\nav_log(VAR_0, AV_LOG_ERROR, \"VIDIOC_STREAMOFF %s\\n\", s->output.name);", "VAR_1 = ff_v4l2_context_set_status(&s->capture, VIDIOC_STREAMOFF);", "if (VAR_1)\nav_log(VAR_0, AV_LOG_ERROR, \"VIDIOC_STREAMOFF %s\\n\", s->capture.name);", "ff_v4l2_context_release(&s->output);", "if (atomic_load(&s->refcount))\nav_log(VAR_0, AV_LOG_ERROR, \"ff_v4l2m2m_codec_end leaving pending buffers\\n\");", "ff_v4l2_context_release(&s->capture);", "sem_destroy(&s->refsync);", "if (close(s->fd) < 0 )\nav_log(VAR_0, AV_LOG_ERROR, \"failure closing %s (%s)\\n\", s->devname, av_err2str(AVERROR(errno)));", "s->fd = -1;", "return 0;", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13, 15 ], [ 19 ], [ 21, 23 ], [ 27 ], [ 31, 33 ], [ 37 ], [ 39 ], [ 45, 47 ], [ 51 ], [ 55 ], [ 57 ] ]
8,829
static void spr_read_tbl(DisasContext *ctx, int gprn, int sprn) { if (ctx->tb->cflags & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_load_tbl(cpu_gpr[gprn], cpu_env); if (ctx->tb->cflags & CF_USE_ICOUNT) { gen_io_end(); gen_stop_exception(ctx); } }
true
qemu
c5a49c63fa26e8825ad101dfe86339ae4c216539
static void spr_read_tbl(DisasContext *ctx, int gprn, int sprn) { if (ctx->tb->cflags & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_load_tbl(cpu_gpr[gprn], cpu_env); if (ctx->tb->cflags & CF_USE_ICOUNT) { gen_io_end(); gen_stop_exception(ctx); } }
{ "code": [ " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {" ], "line_no": [ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 ] }
static void FUNC_0(DisasContext *VAR_0, int VAR_1, int VAR_2) { if (VAR_0->tb->cflags & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_load_tbl(cpu_gpr[VAR_1], cpu_env); if (VAR_0->tb->cflags & CF_USE_ICOUNT) { gen_io_end(); gen_stop_exception(VAR_0); } }
[ "static void FUNC_0(DisasContext *VAR_0, int VAR_1, int VAR_2)\n{", "if (VAR_0->tb->cflags & CF_USE_ICOUNT) {", "gen_io_start();", "}", "gen_helper_load_tbl(cpu_gpr[VAR_1], cpu_env);", "if (VAR_0->tb->cflags & CF_USE_ICOUNT) {", "gen_io_end();", "gen_stop_exception(VAR_0);", "}", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ] ]
8,830
void vnc_client_read(void *opaque) { VncState *vs = opaque; long ret; buffer_reserve(&vs->input, 4096); #ifdef CONFIG_VNC_TLS if (vs->tls.session) { ret = gnutls_read(vs->tls.session, buffer_end(&vs->input), 4096); if (ret < 0) { if (ret == GNUTLS_E_AGAIN) errno = EAGAIN; else errno = EIO; ret = -1; } } else #endif /* CONFIG_VNC_TLS */ ret = recv(vs->csock, buffer_end(&vs->input), 4096, 0); ret = vnc_client_io_error(vs, ret, socket_error()); if (!ret) return; vs->input.offset += ret; while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) { size_t len = vs->read_handler_expect; int ret; ret = vs->read_handler(vs, vs->input.buffer, len); if (vs->csock == -1) return; if (!ret) { memmove(vs->input.buffer, vs->input.buffer + len, (vs->input.offset - len)); vs->input.offset -= len; } else { vs->read_handler_expect = ret; } } }
true
qemu
2f9606b3736c3be4dbd606c46525c7b770ced119
void vnc_client_read(void *opaque) { VncState *vs = opaque; long ret; buffer_reserve(&vs->input, 4096); #ifdef CONFIG_VNC_TLS if (vs->tls.session) { ret = gnutls_read(vs->tls.session, buffer_end(&vs->input), 4096); if (ret < 0) { if (ret == GNUTLS_E_AGAIN) errno = EAGAIN; else errno = EIO; ret = -1; } } else #endif ret = recv(vs->csock, buffer_end(&vs->input), 4096, 0); ret = vnc_client_io_error(vs, ret, socket_error()); if (!ret) return; vs->input.offset += ret; while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) { size_t len = vs->read_handler_expect; int ret; ret = vs->read_handler(vs, vs->input.buffer, len); if (vs->csock == -1) return; if (!ret) { memmove(vs->input.buffer, vs->input.buffer + len, (vs->input.offset - len)); vs->input.offset -= len; } else { vs->read_handler_expect = ret; } } }
{ "code": [ " VncState *vs = opaque;", " ret = vnc_client_io_error(vs, ret, socket_error());", "void vnc_client_read(void *opaque)", " VncState *vs = opaque;", " buffer_reserve(&vs->input, 4096);", "\tret = gnutls_read(vs->tls.session, buffer_end(&vs->input), 4096);", "\tret = recv(vs->csock, buffer_end(&vs->input), 4096, 0);", " ret = vnc_client_io_error(vs, ret, socket_error());", " if (!ret)" ], "line_no": [ 5, 41, 1, 5, 11, 19, 39, 41, 43 ] }
void FUNC_0(void *VAR_0) { VncState *vs = VAR_0; long VAR_2; buffer_reserve(&vs->input, 4096); #ifdef CONFIG_VNC_TLS if (vs->tls.session) { VAR_2 = gnutls_read(vs->tls.session, buffer_end(&vs->input), 4096); if (VAR_2 < 0) { if (VAR_2 == GNUTLS_E_AGAIN) errno = EAGAIN; else errno = EIO; VAR_2 = -1; } } else #endif VAR_2 = recv(vs->csock, buffer_end(&vs->input), 4096, 0); VAR_2 = vnc_client_io_error(vs, VAR_2, socket_error()); if (!VAR_2) return; vs->input.offset += VAR_2; while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) { size_t len = vs->read_handler_expect; int VAR_2; VAR_2 = vs->read_handler(vs, vs->input.buffer, len); if (vs->csock == -1) return; if (!VAR_2) { memmove(vs->input.buffer, vs->input.buffer + len, (vs->input.offset - len)); vs->input.offset -= len; } else { vs->read_handler_expect = VAR_2; } } }
[ "void FUNC_0(void *VAR_0)\n{", "VncState *vs = VAR_0;", "long VAR_2;", "buffer_reserve(&vs->input, 4096);", "#ifdef CONFIG_VNC_TLS\nif (vs->tls.session) {", "VAR_2 = gnutls_read(vs->tls.session, buffer_end(&vs->input), 4096);", "if (VAR_2 < 0) {", "if (VAR_2 == GNUTLS_E_AGAIN)\nerrno = EAGAIN;", "else\nerrno = EIO;", "VAR_2 = -1;", "}", "} else", "#endif\nVAR_2 = recv(vs->csock, buffer_end(&vs->input), 4096, 0);", "VAR_2 = vnc_client_io_error(vs, VAR_2, socket_error());", "if (!VAR_2)\nreturn;", "vs->input.offset += VAR_2;", "while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) {", "size_t len = vs->read_handler_expect;", "int VAR_2;", "VAR_2 = vs->read_handler(vs, vs->input.buffer, len);", "if (vs->csock == -1)\nreturn;", "if (!VAR_2) {", "memmove(vs->input.buffer, vs->input.buffer + len, (vs->input.offset - len));", "vs->input.offset -= len;", "} else {", "vs->read_handler_expect = VAR_2;", "}", "}", "}" ]
[ 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 15, 17 ], [ 19 ], [ 21 ], [ 23, 25 ], [ 27, 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37, 39 ], [ 41 ], [ 43, 45 ], [ 49 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 63, 65 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ] ]
8,831
static void test_bmdma_short_prdt(void) { QPCIDevice *dev; QPCIBar bmdma_bar, ide_bar; uint8_t status; PrdtEntry prdt[] = { { .addr = 0, .size = cpu_to_le32(0x10 | PRDT_EOT), }, }; dev = get_pci_device(&bmdma_bar, &ide_bar); /* Normal request */ status = send_dma_request(CMD_READ_DMA, 0, 1, prdt, ARRAY_SIZE(prdt), NULL); g_assert_cmphex(status, ==, 0); assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR); /* Abort the request before it completes */ status = send_dma_request(CMD_READ_DMA | CMDF_ABORT, 0, 1, prdt, ARRAY_SIZE(prdt), NULL); g_assert_cmphex(status, ==, 0); assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR); }
true
qemu
f5aa4bdc766190b95d18be27d5cdf4d80c35b33c
static void test_bmdma_short_prdt(void) { QPCIDevice *dev; QPCIBar bmdma_bar, ide_bar; uint8_t status; PrdtEntry prdt[] = { { .addr = 0, .size = cpu_to_le32(0x10 | PRDT_EOT), }, }; dev = get_pci_device(&bmdma_bar, &ide_bar); status = send_dma_request(CMD_READ_DMA, 0, 1, prdt, ARRAY_SIZE(prdt), NULL); g_assert_cmphex(status, ==, 0); assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR); status = send_dma_request(CMD_READ_DMA | CMDF_ABORT, 0, 1, prdt, ARRAY_SIZE(prdt), NULL); g_assert_cmphex(status, ==, 0); assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR); }
{ "code": [], "line_no": [] }
static void FUNC_0(void) { QPCIDevice *dev; QPCIBar bmdma_bar, ide_bar; uint8_t status; PrdtEntry prdt[] = { { .addr = 0, .size = cpu_to_le32(0x10 | PRDT_EOT), }, }; dev = get_pci_device(&bmdma_bar, &ide_bar); status = send_dma_request(CMD_READ_DMA, 0, 1, prdt, ARRAY_SIZE(prdt), NULL); g_assert_cmphex(status, ==, 0); assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR); status = send_dma_request(CMD_READ_DMA | CMDF_ABORT, 0, 1, prdt, ARRAY_SIZE(prdt), NULL); g_assert_cmphex(status, ==, 0); assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR); }
[ "static void FUNC_0(void)\n{", "QPCIDevice *dev;", "QPCIBar bmdma_bar, ide_bar;", "uint8_t status;", "PrdtEntry prdt[] = {", "{", ".addr = 0,\n.size = cpu_to_le32(0x10 | PRDT_EOT),\n},", "};", "dev = get_pci_device(&bmdma_bar, &ide_bar);", "status = send_dma_request(CMD_READ_DMA, 0, 1,\nprdt, ARRAY_SIZE(prdt), NULL);", "g_assert_cmphex(status, ==, 0);", "assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR);", "status = send_dma_request(CMD_READ_DMA | CMDF_ABORT, 0, 1,\nprdt, ARRAY_SIZE(prdt), NULL);", "g_assert_cmphex(status, ==, 0);", "assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR);", "}" ]
[ 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 ], [ 27 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 45, 47 ], [ 49 ], [ 51 ], [ 54 ] ]
8,832
int ff_mpeg4_decode_picture_header(MpegEncContext * s, GetBitContext *gb) { int startcode, v; /* search next start code */ align_get_bits(gb); if(s->avctx->codec_tag == ff_get_fourcc("WV1F") && show_bits(gb, 24) == 0x575630){ skip_bits(gb, 24); if(get_bits(gb, 8) == 0xF0) return decode_vop_header(s, gb); } startcode = 0xff; for(;;) { v = get_bits(gb, 8); startcode = ((startcode << 8) | v) & 0xffffffff; if(get_bits_count(gb) >= gb->size_in_bits){ if(gb->size_in_bits==8 && (s->divx_version || s->xvid_build)){ av_log(s->avctx, AV_LOG_ERROR, "frame skip %d\n", gb->size_in_bits); return FRAME_SKIPPED; //divx bug }else return -1; //end of stream } if((startcode&0xFFFFFF00) != 0x100) continue; //no startcode if(s->avctx->debug&FF_DEBUG_STARTCODE){ av_log(s->avctx, AV_LOG_DEBUG, "startcode: %3X ", startcode); if (startcode<=0x11F) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Start"); else if(startcode<=0x12F) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Layer Start"); else if(startcode<=0x13F) av_log(s->avctx, AV_LOG_DEBUG, "Reserved"); else if(startcode<=0x15F) av_log(s->avctx, AV_LOG_DEBUG, "FGS bp start"); else if(startcode<=0x1AF) av_log(s->avctx, AV_LOG_DEBUG, "Reserved"); else if(startcode==0x1B0) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Seq Start"); else if(startcode==0x1B1) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Seq End"); else if(startcode==0x1B2) av_log(s->avctx, AV_LOG_DEBUG, "User Data"); else if(startcode==0x1B3) av_log(s->avctx, AV_LOG_DEBUG, "Group of VOP start"); else if(startcode==0x1B4) av_log(s->avctx, AV_LOG_DEBUG, "Video Session Error"); else if(startcode==0x1B5) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Start"); else if(startcode==0x1B6) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Plane start"); else if(startcode==0x1B7) av_log(s->avctx, AV_LOG_DEBUG, "slice start"); else if(startcode==0x1B8) av_log(s->avctx, AV_LOG_DEBUG, "extension start"); else if(startcode==0x1B9) av_log(s->avctx, AV_LOG_DEBUG, "fgs start"); else if(startcode==0x1BA) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object start"); else if(startcode==0x1BB) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object Plane start"); else if(startcode==0x1BC) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object start"); else if(startcode==0x1BD) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object Plane start"); else if(startcode==0x1BE) av_log(s->avctx, AV_LOG_DEBUG, "Still Texture Object start"); else if(startcode==0x1BF) av_log(s->avctx, AV_LOG_DEBUG, "Texture Spatial Layer start"); else if(startcode==0x1C0) av_log(s->avctx, AV_LOG_DEBUG, "Texture SNR Layer start"); else if(startcode==0x1C1) av_log(s->avctx, AV_LOG_DEBUG, "Texture Tile start"); else if(startcode==0x1C2) av_log(s->avctx, AV_LOG_DEBUG, "Texture Shape Layer start"); else if(startcode==0x1C3) av_log(s->avctx, AV_LOG_DEBUG, "stuffing start"); else if(startcode<=0x1C5) av_log(s->avctx, AV_LOG_DEBUG, "reserved"); else if(startcode<=0x1FF) av_log(s->avctx, AV_LOG_DEBUG, "System start"); av_log(s->avctx, AV_LOG_DEBUG, " at %d\n", get_bits_count(gb)); } if(startcode >= 0x120 && startcode <= 0x12F){ if(decode_vol_header(s, gb) < 0) return -1; } else if(startcode == USER_DATA_STARTCODE){ decode_user_data(s, gb); } else if(startcode == GOP_STARTCODE){ mpeg4_decode_gop_header(s, gb); } else if(startcode == VOP_STARTCODE){ return decode_vop_header(s, gb); } align_get_bits(gb); startcode = 0xff; } }
true
FFmpeg
63d33cf4390a9280b1ba42ee722f3140cf1cad3e
int ff_mpeg4_decode_picture_header(MpegEncContext * s, GetBitContext *gb) { int startcode, v; align_get_bits(gb); if(s->avctx->codec_tag == ff_get_fourcc("WV1F") && show_bits(gb, 24) == 0x575630){ skip_bits(gb, 24); if(get_bits(gb, 8) == 0xF0) return decode_vop_header(s, gb); } startcode = 0xff; for(;;) { v = get_bits(gb, 8); startcode = ((startcode << 8) | v) & 0xffffffff; if(get_bits_count(gb) >= gb->size_in_bits){ if(gb->size_in_bits==8 && (s->divx_version || s->xvid_build)){ av_log(s->avctx, AV_LOG_ERROR, "frame skip %d\n", gb->size_in_bits); return FRAME_SKIPPED; }else return -1; } if((startcode&0xFFFFFF00) != 0x100) continue; if(s->avctx->debug&FF_DEBUG_STARTCODE){ av_log(s->avctx, AV_LOG_DEBUG, "startcode: %3X ", startcode); if (startcode<=0x11F) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Start"); else if(startcode<=0x12F) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Layer Start"); else if(startcode<=0x13F) av_log(s->avctx, AV_LOG_DEBUG, "Reserved"); else if(startcode<=0x15F) av_log(s->avctx, AV_LOG_DEBUG, "FGS bp start"); else if(startcode<=0x1AF) av_log(s->avctx, AV_LOG_DEBUG, "Reserved"); else if(startcode==0x1B0) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Seq Start"); else if(startcode==0x1B1) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Seq End"); else if(startcode==0x1B2) av_log(s->avctx, AV_LOG_DEBUG, "User Data"); else if(startcode==0x1B3) av_log(s->avctx, AV_LOG_DEBUG, "Group of VOP start"); else if(startcode==0x1B4) av_log(s->avctx, AV_LOG_DEBUG, "Video Session Error"); else if(startcode==0x1B5) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Start"); else if(startcode==0x1B6) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Plane start"); else if(startcode==0x1B7) av_log(s->avctx, AV_LOG_DEBUG, "slice start"); else if(startcode==0x1B8) av_log(s->avctx, AV_LOG_DEBUG, "extension start"); else if(startcode==0x1B9) av_log(s->avctx, AV_LOG_DEBUG, "fgs start"); else if(startcode==0x1BA) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object start"); else if(startcode==0x1BB) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object Plane start"); else if(startcode==0x1BC) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object start"); else if(startcode==0x1BD) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object Plane start"); else if(startcode==0x1BE) av_log(s->avctx, AV_LOG_DEBUG, "Still Texture Object start"); else if(startcode==0x1BF) av_log(s->avctx, AV_LOG_DEBUG, "Texture Spatial Layer start"); else if(startcode==0x1C0) av_log(s->avctx, AV_LOG_DEBUG, "Texture SNR Layer start"); else if(startcode==0x1C1) av_log(s->avctx, AV_LOG_DEBUG, "Texture Tile start"); else if(startcode==0x1C2) av_log(s->avctx, AV_LOG_DEBUG, "Texture Shape Layer start"); else if(startcode==0x1C3) av_log(s->avctx, AV_LOG_DEBUG, "stuffing start"); else if(startcode<=0x1C5) av_log(s->avctx, AV_LOG_DEBUG, "reserved"); else if(startcode<=0x1FF) av_log(s->avctx, AV_LOG_DEBUG, "System start"); av_log(s->avctx, AV_LOG_DEBUG, " at %d\n", get_bits_count(gb)); } if(startcode >= 0x120 && startcode <= 0x12F){ if(decode_vol_header(s, gb) < 0) return -1; } else if(startcode == USER_DATA_STARTCODE){ decode_user_data(s, gb); } else if(startcode == GOP_STARTCODE){ mpeg4_decode_gop_header(s, gb); } else if(startcode == VOP_STARTCODE){ return decode_vop_header(s, gb); } align_get_bits(gb); startcode = 0xff; } }
{ "code": [ " v = get_bits(gb, 8);", " startcode = ((startcode << 8) | v) & 0xffffffff;" ], "line_no": [ 31, 33 ] }
int FUNC_0(MpegEncContext * VAR_0, GetBitContext *VAR_1) { int VAR_2, VAR_3; align_get_bits(VAR_1); if(VAR_0->avctx->codec_tag == ff_get_fourcc("WV1F") && show_bits(VAR_1, 24) == 0x575630){ skip_bits(VAR_1, 24); if(get_bits(VAR_1, 8) == 0xF0) return decode_vop_header(VAR_0, VAR_1); } VAR_2 = 0xff; for(;;) { VAR_3 = get_bits(VAR_1, 8); VAR_2 = ((VAR_2 << 8) | VAR_3) & 0xffffffff; if(get_bits_count(VAR_1) >= VAR_1->size_in_bits){ if(VAR_1->size_in_bits==8 && (VAR_0->divx_version || VAR_0->xvid_build)){ av_log(VAR_0->avctx, AV_LOG_ERROR, "frame skip %d\n", VAR_1->size_in_bits); return FRAME_SKIPPED; }else return -1; } if((VAR_2&0xFFFFFF00) != 0x100) continue; if(VAR_0->avctx->debug&FF_DEBUG_STARTCODE){ av_log(VAR_0->avctx, AV_LOG_DEBUG, "VAR_2: %3X ", VAR_2); if (VAR_2<=0x11F) av_log(VAR_0->avctx, AV_LOG_DEBUG, "Video Object Start"); else if(VAR_2<=0x12F) av_log(VAR_0->avctx, AV_LOG_DEBUG, "Video Object Layer Start"); else if(VAR_2<=0x13F) av_log(VAR_0->avctx, AV_LOG_DEBUG, "Reserved"); else if(VAR_2<=0x15F) av_log(VAR_0->avctx, AV_LOG_DEBUG, "FGS bp start"); else if(VAR_2<=0x1AF) av_log(VAR_0->avctx, AV_LOG_DEBUG, "Reserved"); else if(VAR_2==0x1B0) av_log(VAR_0->avctx, AV_LOG_DEBUG, "Visual Object Seq Start"); else if(VAR_2==0x1B1) av_log(VAR_0->avctx, AV_LOG_DEBUG, "Visual Object Seq End"); else if(VAR_2==0x1B2) av_log(VAR_0->avctx, AV_LOG_DEBUG, "User Data"); else if(VAR_2==0x1B3) av_log(VAR_0->avctx, AV_LOG_DEBUG, "Group of VOP start"); else if(VAR_2==0x1B4) av_log(VAR_0->avctx, AV_LOG_DEBUG, "Video Session Error"); else if(VAR_2==0x1B5) av_log(VAR_0->avctx, AV_LOG_DEBUG, "Visual Object Start"); else if(VAR_2==0x1B6) av_log(VAR_0->avctx, AV_LOG_DEBUG, "Video Object Plane start"); else if(VAR_2==0x1B7) av_log(VAR_0->avctx, AV_LOG_DEBUG, "slice start"); else if(VAR_2==0x1B8) av_log(VAR_0->avctx, AV_LOG_DEBUG, "extension start"); else if(VAR_2==0x1B9) av_log(VAR_0->avctx, AV_LOG_DEBUG, "fgs start"); else if(VAR_2==0x1BA) av_log(VAR_0->avctx, AV_LOG_DEBUG, "FBA Object start"); else if(VAR_2==0x1BB) av_log(VAR_0->avctx, AV_LOG_DEBUG, "FBA Object Plane start"); else if(VAR_2==0x1BC) av_log(VAR_0->avctx, AV_LOG_DEBUG, "Mesh Object start"); else if(VAR_2==0x1BD) av_log(VAR_0->avctx, AV_LOG_DEBUG, "Mesh Object Plane start"); else if(VAR_2==0x1BE) av_log(VAR_0->avctx, AV_LOG_DEBUG, "Still Texture Object start"); else if(VAR_2==0x1BF) av_log(VAR_0->avctx, AV_LOG_DEBUG, "Texture Spatial Layer start"); else if(VAR_2==0x1C0) av_log(VAR_0->avctx, AV_LOG_DEBUG, "Texture SNR Layer start"); else if(VAR_2==0x1C1) av_log(VAR_0->avctx, AV_LOG_DEBUG, "Texture Tile start"); else if(VAR_2==0x1C2) av_log(VAR_0->avctx, AV_LOG_DEBUG, "Texture Shape Layer start"); else if(VAR_2==0x1C3) av_log(VAR_0->avctx, AV_LOG_DEBUG, "stuffing start"); else if(VAR_2<=0x1C5) av_log(VAR_0->avctx, AV_LOG_DEBUG, "reserved"); else if(VAR_2<=0x1FF) av_log(VAR_0->avctx, AV_LOG_DEBUG, "System start"); av_log(VAR_0->avctx, AV_LOG_DEBUG, " at %d\n", get_bits_count(VAR_1)); } if(VAR_2 >= 0x120 && VAR_2 <= 0x12F){ if(decode_vol_header(VAR_0, VAR_1) < 0) return -1; } else if(VAR_2 == USER_DATA_STARTCODE){ decode_user_data(VAR_0, VAR_1); } else if(VAR_2 == GOP_STARTCODE){ mpeg4_decode_gop_header(VAR_0, VAR_1); } else if(VAR_2 == VOP_STARTCODE){ return decode_vop_header(VAR_0, VAR_1); } align_get_bits(VAR_1); VAR_2 = 0xff; } }
[ "int FUNC_0(MpegEncContext * VAR_0, GetBitContext *VAR_1)\n{", "int VAR_2, VAR_3;", "align_get_bits(VAR_1);", "if(VAR_0->avctx->codec_tag == ff_get_fourcc(\"WV1F\") && show_bits(VAR_1, 24) == 0x575630){", "skip_bits(VAR_1, 24);", "if(get_bits(VAR_1, 8) == 0xF0)\nreturn decode_vop_header(VAR_0, VAR_1);", "}", "VAR_2 = 0xff;", "for(;;) {", "VAR_3 = get_bits(VAR_1, 8);", "VAR_2 = ((VAR_2 << 8) | VAR_3) & 0xffffffff;", "if(get_bits_count(VAR_1) >= VAR_1->size_in_bits){", "if(VAR_1->size_in_bits==8 && (VAR_0->divx_version || VAR_0->xvid_build)){", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"frame skip %d\\n\", VAR_1->size_in_bits);", "return FRAME_SKIPPED;", "}else", "return -1;", "}", "if((VAR_2&0xFFFFFF00) != 0x100)\ncontinue;", "if(VAR_0->avctx->debug&FF_DEBUG_STARTCODE){", "av_log(VAR_0->avctx, AV_LOG_DEBUG, \"VAR_2: %3X \", VAR_2);", "if (VAR_2<=0x11F) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Video Object Start\");", "else if(VAR_2<=0x12F) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Video Object Layer Start\");", "else if(VAR_2<=0x13F) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Reserved\");", "else if(VAR_2<=0x15F) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"FGS bp start\");", "else if(VAR_2<=0x1AF) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Reserved\");", "else if(VAR_2==0x1B0) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Visual Object Seq Start\");", "else if(VAR_2==0x1B1) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Visual Object Seq End\");", "else if(VAR_2==0x1B2) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"User Data\");", "else if(VAR_2==0x1B3) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Group of VOP start\");", "else if(VAR_2==0x1B4) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Video Session Error\");", "else if(VAR_2==0x1B5) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Visual Object Start\");", "else if(VAR_2==0x1B6) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Video Object Plane start\");", "else if(VAR_2==0x1B7) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"slice start\");", "else if(VAR_2==0x1B8) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"extension start\");", "else if(VAR_2==0x1B9) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"fgs start\");", "else if(VAR_2==0x1BA) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"FBA Object start\");", "else if(VAR_2==0x1BB) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"FBA Object Plane start\");", "else if(VAR_2==0x1BC) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Mesh Object start\");", "else if(VAR_2==0x1BD) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Mesh Object Plane start\");", "else if(VAR_2==0x1BE) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Still Texture Object start\");", "else if(VAR_2==0x1BF) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Texture Spatial Layer start\");", "else if(VAR_2==0x1C0) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Texture SNR Layer start\");", "else if(VAR_2==0x1C1) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Texture Tile start\");", "else if(VAR_2==0x1C2) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Texture Shape Layer start\");", "else if(VAR_2==0x1C3) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"stuffing start\");", "else if(VAR_2<=0x1C5) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"reserved\");", "else if(VAR_2<=0x1FF) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"System start\");", "av_log(VAR_0->avctx, AV_LOG_DEBUG, \" at %d\\n\", get_bits_count(VAR_1));", "}", "if(VAR_2 >= 0x120 && VAR_2 <= 0x12F){", "if(decode_vol_header(VAR_0, VAR_1) < 0)\nreturn -1;", "}", "else if(VAR_2 == USER_DATA_STARTCODE){", "decode_user_data(VAR_0, VAR_1);", "}", "else if(VAR_2 == GOP_STARTCODE){", "mpeg4_decode_gop_header(VAR_0, VAR_1);", "}", "else if(VAR_2 == VOP_STARTCODE){", "return decode_vop_header(VAR_0, VAR_1);", "}", "align_get_bits(VAR_1);", "VAR_2 = 0xff;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 11 ], [ 15 ], [ 17 ], [ 19, 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53, 55 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 123 ], [ 125, 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ] ]
8,833
SwsFunc yuv2rgb_init_altivec (SwsContext *c) { if (!(c->flags & SWS_CPU_CAPS_ALTIVEC)) return NULL; /* and this seems not to matter too much I tried a bunch of videos with abnormal widths and mplayer crashes else where. mplayer -vo x11 -rawvideo on:w=350:h=240 raw-350x240.eyuv boom with X11 bad match. */ if ((c->srcW & 0xf) != 0) return NULL; switch (c->srcFormat) { case PIX_FMT_YUV410P: case PIX_FMT_YUV420P: /*case IMGFMT_CLPL: ??? */ case PIX_FMT_GRAY8: case PIX_FMT_NV12: case PIX_FMT_NV21: if ((c->srcH & 0x1) != 0) return NULL; switch(c->dstFormat){ case PIX_FMT_RGB24: av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space RGB24\n"); return altivec_yuv2_rgb24; case PIX_FMT_BGR24: av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space BGR24\n"); return altivec_yuv2_bgr24; case PIX_FMT_ARGB: av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space ARGB\n"); return altivec_yuv2_argb; case PIX_FMT_ABGR: av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space ABGR\n"); return altivec_yuv2_abgr; case PIX_FMT_RGBA: av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space RGBA\n"); return altivec_yuv2_rgba; case PIX_FMT_BGRA: av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space BGRA\n"); return altivec_yuv2_bgra; default: return NULL; } break; case PIX_FMT_UYVY422: switch(c->dstFormat){ case PIX_FMT_BGR32: av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space UYVY -> RGB32\n"); return altivec_uyvy_rgb32; default: return NULL; } break; } return NULL; }
true
FFmpeg
428098165de4c3edfe42c1b7f00627d287015863
SwsFunc yuv2rgb_init_altivec (SwsContext *c) { if (!(c->flags & SWS_CPU_CAPS_ALTIVEC)) return NULL; if ((c->srcW & 0xf) != 0) return NULL; switch (c->srcFormat) { case PIX_FMT_YUV410P: case PIX_FMT_YUV420P: case PIX_FMT_GRAY8: case PIX_FMT_NV12: case PIX_FMT_NV21: if ((c->srcH & 0x1) != 0) return NULL; switch(c->dstFormat){ case PIX_FMT_RGB24: av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space RGB24\n"); return altivec_yuv2_rgb24; case PIX_FMT_BGR24: av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space BGR24\n"); return altivec_yuv2_bgr24; case PIX_FMT_ARGB: av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space ARGB\n"); return altivec_yuv2_argb; case PIX_FMT_ABGR: av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space ABGR\n"); return altivec_yuv2_abgr; case PIX_FMT_RGBA: av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space RGBA\n"); return altivec_yuv2_rgba; case PIX_FMT_BGRA: av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space BGRA\n"); return altivec_yuv2_bgra; default: return NULL; } break; case PIX_FMT_UYVY422: switch(c->dstFormat){ case PIX_FMT_BGR32: av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space UYVY -> RGB32\n"); return altivec_uyvy_rgb32; default: return NULL; } break; } return NULL; }
{ "code": [ " if (!(c->flags & SWS_CPU_CAPS_ALTIVEC))", " return NULL;", " if ((c->srcW & 0xf) != 0) return NULL;", " switch (c->srcFormat) {", " case PIX_FMT_YUV410P:", " case PIX_FMT_YUV420P:", " case PIX_FMT_GRAY8:", " case PIX_FMT_NV12:", " case PIX_FMT_NV21:", " if ((c->srcH & 0x1) != 0)", " return NULL;", " switch(c->dstFormat){", " case PIX_FMT_RGB24:", " av_log(c, AV_LOG_WARNING, \"ALTIVEC: Color Space RGB24\\n\");", " return altivec_yuv2_rgb24;", " case PIX_FMT_BGR24:", " av_log(c, AV_LOG_WARNING, \"ALTIVEC: Color Space BGR24\\n\");", " return altivec_yuv2_bgr24;", " case PIX_FMT_ARGB:", " av_log(c, AV_LOG_WARNING, \"ALTIVEC: Color Space ARGB\\n\");", " return altivec_yuv2_argb;", " case PIX_FMT_ABGR:", " av_log(c, AV_LOG_WARNING, \"ALTIVEC: Color Space ABGR\\n\");", " return altivec_yuv2_abgr;", " case PIX_FMT_RGBA:", " av_log(c, AV_LOG_WARNING, \"ALTIVEC: Color Space RGBA\\n\");", " return altivec_yuv2_rgba;", " case PIX_FMT_BGRA:", " av_log(c, AV_LOG_WARNING, \"ALTIVEC: Color Space BGRA\\n\");", " return altivec_yuv2_bgra;", " default: return NULL;", " break;", " case PIX_FMT_UYVY422:", " switch(c->dstFormat){", " case PIX_FMT_BGR32:", " av_log(c, AV_LOG_WARNING, \"ALTIVEC: Color Space UYVY -> RGB32\\n\");", " return altivec_uyvy_rgb32;", " default: return NULL;", " break;", " return NULL;" ], "line_no": [ 5, 7, 25, 29, 31, 33, 37, 39, 41, 43, 45, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 91, 95, 49, 99, 101, 103, 87, 91, 115 ] }
SwsFunc FUNC_0 (SwsContext *c) { if (!(c->flags & SWS_CPU_CAPS_ALTIVEC)) return NULL; if ((c->srcW & 0xf) != 0) return NULL; switch (c->srcFormat) { case PIX_FMT_YUV410P: case PIX_FMT_YUV420P: case PIX_FMT_GRAY8: case PIX_FMT_NV12: case PIX_FMT_NV21: if ((c->srcH & 0x1) != 0) return NULL; switch(c->dstFormat){ case PIX_FMT_RGB24: av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space RGB24\n"); return altivec_yuv2_rgb24; case PIX_FMT_BGR24: av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space BGR24\n"); return altivec_yuv2_bgr24; case PIX_FMT_ARGB: av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space ARGB\n"); return altivec_yuv2_argb; case PIX_FMT_ABGR: av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space ABGR\n"); return altivec_yuv2_abgr; case PIX_FMT_RGBA: av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space RGBA\n"); return altivec_yuv2_rgba; case PIX_FMT_BGRA: av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space BGRA\n"); return altivec_yuv2_bgra; default: return NULL; } break; case PIX_FMT_UYVY422: switch(c->dstFormat){ case PIX_FMT_BGR32: av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space UYVY -> RGB32\n"); return altivec_uyvy_rgb32; default: return NULL; } break; } return NULL; }
[ "SwsFunc FUNC_0 (SwsContext *c)\n{", "if (!(c->flags & SWS_CPU_CAPS_ALTIVEC))\nreturn NULL;", "if ((c->srcW & 0xf) != 0) return NULL;", "switch (c->srcFormat) {", "case PIX_FMT_YUV410P:\ncase PIX_FMT_YUV420P:\ncase PIX_FMT_GRAY8:\ncase PIX_FMT_NV12:\ncase PIX_FMT_NV21:\nif ((c->srcH & 0x1) != 0)\nreturn NULL;", "switch(c->dstFormat){", "case PIX_FMT_RGB24:\nav_log(c, AV_LOG_WARNING, \"ALTIVEC: Color Space RGB24\\n\");", "return altivec_yuv2_rgb24;", "case PIX_FMT_BGR24:\nav_log(c, AV_LOG_WARNING, \"ALTIVEC: Color Space BGR24\\n\");", "return altivec_yuv2_bgr24;", "case PIX_FMT_ARGB:\nav_log(c, AV_LOG_WARNING, \"ALTIVEC: Color Space ARGB\\n\");", "return altivec_yuv2_argb;", "case PIX_FMT_ABGR:\nav_log(c, AV_LOG_WARNING, \"ALTIVEC: Color Space ABGR\\n\");", "return altivec_yuv2_abgr;", "case PIX_FMT_RGBA:\nav_log(c, AV_LOG_WARNING, \"ALTIVEC: Color Space RGBA\\n\");", "return altivec_yuv2_rgba;", "case PIX_FMT_BGRA:\nav_log(c, AV_LOG_WARNING, \"ALTIVEC: Color Space BGRA\\n\");", "return altivec_yuv2_bgra;", "default: return NULL;", "}", "break;", "case PIX_FMT_UYVY422:\nswitch(c->dstFormat){", "case PIX_FMT_BGR32:\nav_log(c, AV_LOG_WARNING, \"ALTIVEC: Color Space UYVY -> RGB32\\n\");", "return altivec_uyvy_rgb32;", "default: return NULL;", "}", "break;", "}", "return NULL;", "}" ]
[ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5, 7 ], [ 25 ], [ 29 ], [ 31, 33, 37, 39, 41, 43, 45 ], [ 49 ], [ 51, 53 ], [ 55 ], [ 57, 59 ], [ 61 ], [ 63, 65 ], [ 67 ], [ 69, 71 ], [ 73 ], [ 75, 77 ], [ 79 ], [ 81, 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 95, 97 ], [ 99, 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 113 ], [ 115 ], [ 117 ] ]
8,834
static void string_output_append(StringOutputVisitor *sov, int64_t a) { Range *r = g_malloc0(sizeof(*r)); r->begin = a; r->end = a + 1; sov->ranges = g_list_insert_sorted_merged(sov->ranges, r, range_compare); }
true
qemu
7c47959d0cb05db43014141a156ada0b6d53a750
static void string_output_append(StringOutputVisitor *sov, int64_t a) { Range *r = g_malloc0(sizeof(*r)); r->begin = a; r->end = a + 1; sov->ranges = g_list_insert_sorted_merged(sov->ranges, r, range_compare); }
{ "code": [ " sov->ranges = g_list_insert_sorted_merged(sov->ranges, r, range_compare);", " sov->ranges = g_list_insert_sorted_merged(sov->ranges, r, range_compare);" ], "line_no": [ 11, 11 ] }
static void FUNC_0(StringOutputVisitor *VAR_0, int64_t VAR_1) { Range *r = g_malloc0(sizeof(*r)); r->begin = VAR_1; r->end = VAR_1 + 1; VAR_0->ranges = g_list_insert_sorted_merged(VAR_0->ranges, r, range_compare); }
[ "static void FUNC_0(StringOutputVisitor *VAR_0, int64_t VAR_1)\n{", "Range *r = g_malloc0(sizeof(*r));", "r->begin = VAR_1;", "r->end = VAR_1 + 1;", "VAR_0->ranges = g_list_insert_sorted_merged(VAR_0->ranges, r, range_compare);", "}" ]
[ 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ] ]
8,836
static void run_postproc(AVCodecContext *avctx, AVFrame *frame) { DDSContext *ctx = avctx->priv_data; int i, x_off; switch (ctx->postproc) { case DDS_ALPHA_EXP: /* Alpha-exponential mode divides each channel by the maximum * R, G or B value, and stores the multiplying factor in the * alpha channel. */ av_log(avctx, AV_LOG_DEBUG, "Post-processing alpha exponent.\n"); for (i = 0; i < frame->linesize[0] * frame->height; i += 4) { uint8_t *src = frame->data[0] + i; int r = src[0]; int g = src[1]; int b = src[2]; int a = src[3]; src[0] = r * a / 255; src[1] = g * a / 255; src[2] = b * a / 255; src[3] = 255; } break; case DDS_NORMAL_MAP: /* Normal maps work in the XYZ color space and they encode * X in R or in A, depending on the texture type, Y in G and * derive Z with a square root of the distance. * * http://www.realtimecollisiondetection.net/blog/?p=28 */ av_log(avctx, AV_LOG_DEBUG, "Post-processing normal map.\n"); x_off = ctx->tex_ratio == 8 ? 0 : 3; for (i = 0; i < frame->linesize[0] * frame->height; i += 4) { uint8_t *src = frame->data[0] + i; int x = src[x_off]; int y = src[1]; int z = 127; int d = (255 * 255 - x * x - y * y) / 2; if (d > 0) z = rint(sqrtf(d)); src[0] = x; src[1] = y; src[2] = z; src[3] = 255; } break; case DDS_RAW_YCOCG: /* Data is Y-Co-Cg-A and not RGBA, but they are represented * with the same masks in the DDPF header. */ av_log(avctx, AV_LOG_DEBUG, "Post-processing raw YCoCg.\n"); for (i = 0; i < frame->linesize[0] * frame->height; i += 4) { uint8_t *src = frame->data[0] + i; int a = src[0]; int cg = src[1] - 128; int co = src[2] - 128; int y = src[3]; src[0] = av_clip_uint8(y + co - cg); src[1] = av_clip_uint8(y + cg); src[2] = av_clip_uint8(y - co - cg); src[3] = a; } break; case DDS_SWAP_ALPHA: /* Alpha and Luma are stored swapped. */ av_log(avctx, AV_LOG_DEBUG, "Post-processing swapped Luma/Alpha.\n"); for (i = 0; i < frame->linesize[0] * frame->height; i += 2) { uint8_t *src = frame->data[0] + i; FFSWAP(uint8_t, src[0], src[1]); } break; case DDS_SWIZZLE_A2XY: /* Swap R and G, often used to restore a standard RGTC2. */ av_log(avctx, AV_LOG_DEBUG, "Post-processing A2XY swizzle.\n"); do_swizzle(frame, 0, 1); break; case DDS_SWIZZLE_RBXG: /* Swap G and A, then B and new A (G). */ av_log(avctx, AV_LOG_DEBUG, "Post-processing RBXG swizzle.\n"); do_swizzle(frame, 1, 3); do_swizzle(frame, 2, 3); break; case DDS_SWIZZLE_RGXB: /* Swap B and A. */ av_log(avctx, AV_LOG_DEBUG, "Post-processing RGXB swizzle.\n"); do_swizzle(frame, 2, 3); break; case DDS_SWIZZLE_RXBG: /* Swap G and A. */ av_log(avctx, AV_LOG_DEBUG, "Post-processing RXBG swizzle.\n"); do_swizzle(frame, 1, 3); break; case DDS_SWIZZLE_RXGB: /* Swap R and A (misleading name). */ av_log(avctx, AV_LOG_DEBUG, "Post-processing RXGB swizzle.\n"); do_swizzle(frame, 0, 3); break; case DDS_SWIZZLE_XGBR: /* Swap B and A, then R and new A (B). */ av_log(avctx, AV_LOG_DEBUG, "Post-processing XGBR swizzle.\n"); do_swizzle(frame, 2, 3); do_swizzle(frame, 0, 3); break; case DDS_SWIZZLE_XGXR: /* Swap G and A, then R and new A (G), then new R (G) and new G (A). * This variant does not store any B component. */ av_log(avctx, AV_LOG_DEBUG, "Post-processing XGXR swizzle.\n"); do_swizzle(frame, 1, 3); do_swizzle(frame, 0, 3); do_swizzle(frame, 0, 1); break; case DDS_SWIZZLE_XRBG: /* Swap G and A, then R and new A (G). */ av_log(avctx, AV_LOG_DEBUG, "Post-processing XRBG swizzle.\n"); do_swizzle(frame, 1, 3); do_swizzle(frame, 0, 3); break; } }
false
FFmpeg
6eb2505855fa832ba7d0a1c2fb9f92c41c5446e3
static void run_postproc(AVCodecContext *avctx, AVFrame *frame) { DDSContext *ctx = avctx->priv_data; int i, x_off; switch (ctx->postproc) { case DDS_ALPHA_EXP: av_log(avctx, AV_LOG_DEBUG, "Post-processing alpha exponent.\n"); for (i = 0; i < frame->linesize[0] * frame->height; i += 4) { uint8_t *src = frame->data[0] + i; int r = src[0]; int g = src[1]; int b = src[2]; int a = src[3]; src[0] = r * a / 255; src[1] = g * a / 255; src[2] = b * a / 255; src[3] = 255; } break; case DDS_NORMAL_MAP: av_log(avctx, AV_LOG_DEBUG, "Post-processing normal map.\n"); x_off = ctx->tex_ratio == 8 ? 0 : 3; for (i = 0; i < frame->linesize[0] * frame->height; i += 4) { uint8_t *src = frame->data[0] + i; int x = src[x_off]; int y = src[1]; int z = 127; int d = (255 * 255 - x * x - y * y) / 2; if (d > 0) z = rint(sqrtf(d)); src[0] = x; src[1] = y; src[2] = z; src[3] = 255; } break; case DDS_RAW_YCOCG: av_log(avctx, AV_LOG_DEBUG, "Post-processing raw YCoCg.\n"); for (i = 0; i < frame->linesize[0] * frame->height; i += 4) { uint8_t *src = frame->data[0] + i; int a = src[0]; int cg = src[1] - 128; int co = src[2] - 128; int y = src[3]; src[0] = av_clip_uint8(y + co - cg); src[1] = av_clip_uint8(y + cg); src[2] = av_clip_uint8(y - co - cg); src[3] = a; } break; case DDS_SWAP_ALPHA: av_log(avctx, AV_LOG_DEBUG, "Post-processing swapped Luma/Alpha.\n"); for (i = 0; i < frame->linesize[0] * frame->height; i += 2) { uint8_t *src = frame->data[0] + i; FFSWAP(uint8_t, src[0], src[1]); } break; case DDS_SWIZZLE_A2XY: av_log(avctx, AV_LOG_DEBUG, "Post-processing A2XY swizzle.\n"); do_swizzle(frame, 0, 1); break; case DDS_SWIZZLE_RBXG: av_log(avctx, AV_LOG_DEBUG, "Post-processing RBXG swizzle.\n"); do_swizzle(frame, 1, 3); do_swizzle(frame, 2, 3); break; case DDS_SWIZZLE_RGXB: av_log(avctx, AV_LOG_DEBUG, "Post-processing RGXB swizzle.\n"); do_swizzle(frame, 2, 3); break; case DDS_SWIZZLE_RXBG: av_log(avctx, AV_LOG_DEBUG, "Post-processing RXBG swizzle.\n"); do_swizzle(frame, 1, 3); break; case DDS_SWIZZLE_RXGB: av_log(avctx, AV_LOG_DEBUG, "Post-processing RXGB swizzle.\n"); do_swizzle(frame, 0, 3); break; case DDS_SWIZZLE_XGBR: av_log(avctx, AV_LOG_DEBUG, "Post-processing XGBR swizzle.\n"); do_swizzle(frame, 2, 3); do_swizzle(frame, 0, 3); break; case DDS_SWIZZLE_XGXR: av_log(avctx, AV_LOG_DEBUG, "Post-processing XGXR swizzle.\n"); do_swizzle(frame, 1, 3); do_swizzle(frame, 0, 3); do_swizzle(frame, 0, 1); break; case DDS_SWIZZLE_XRBG: av_log(avctx, AV_LOG_DEBUG, "Post-processing XRBG swizzle.\n"); do_swizzle(frame, 1, 3); do_swizzle(frame, 0, 3); break; } }
{ "code": [], "line_no": [] }
static void FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1) { DDSContext *ctx = VAR_0->priv_data; int VAR_2, VAR_3; switch (ctx->postproc) { case DDS_ALPHA_EXP: av_log(VAR_0, AV_LOG_DEBUG, "Post-processing alpha exponent.\n"); for (VAR_2 = 0; VAR_2 < VAR_1->linesize[0] * VAR_1->height; VAR_2 += 4) { uint8_t *src = VAR_1->data[0] + VAR_2; int r = src[0]; int g = src[1]; int b = src[2]; int a = src[3]; src[0] = r * a / 255; src[1] = g * a / 255; src[2] = b * a / 255; src[3] = 255; } break; case DDS_NORMAL_MAP: av_log(VAR_0, AV_LOG_DEBUG, "Post-processing normal map.\n"); VAR_3 = ctx->tex_ratio == 8 ? 0 : 3; for (VAR_2 = 0; VAR_2 < VAR_1->linesize[0] * VAR_1->height; VAR_2 += 4) { uint8_t *src = VAR_1->data[0] + VAR_2; int x = src[VAR_3]; int y = src[1]; int z = 127; int d = (255 * 255 - x * x - y * y) / 2; if (d > 0) z = rint(sqrtf(d)); src[0] = x; src[1] = y; src[2] = z; src[3] = 255; } break; case DDS_RAW_YCOCG: av_log(VAR_0, AV_LOG_DEBUG, "Post-processing raw YCoCg.\n"); for (VAR_2 = 0; VAR_2 < VAR_1->linesize[0] * VAR_1->height; VAR_2 += 4) { uint8_t *src = VAR_1->data[0] + VAR_2; int a = src[0]; int cg = src[1] - 128; int co = src[2] - 128; int y = src[3]; src[0] = av_clip_uint8(y + co - cg); src[1] = av_clip_uint8(y + cg); src[2] = av_clip_uint8(y - co - cg); src[3] = a; } break; case DDS_SWAP_ALPHA: av_log(VAR_0, AV_LOG_DEBUG, "Post-processing swapped Luma/Alpha.\n"); for (VAR_2 = 0; VAR_2 < VAR_1->linesize[0] * VAR_1->height; VAR_2 += 2) { uint8_t *src = VAR_1->data[0] + VAR_2; FFSWAP(uint8_t, src[0], src[1]); } break; case DDS_SWIZZLE_A2XY: av_log(VAR_0, AV_LOG_DEBUG, "Post-processing A2XY swizzle.\n"); do_swizzle(VAR_1, 0, 1); break; case DDS_SWIZZLE_RBXG: av_log(VAR_0, AV_LOG_DEBUG, "Post-processing RBXG swizzle.\n"); do_swizzle(VAR_1, 1, 3); do_swizzle(VAR_1, 2, 3); break; case DDS_SWIZZLE_RGXB: av_log(VAR_0, AV_LOG_DEBUG, "Post-processing RGXB swizzle.\n"); do_swizzle(VAR_1, 2, 3); break; case DDS_SWIZZLE_RXBG: av_log(VAR_0, AV_LOG_DEBUG, "Post-processing RXBG swizzle.\n"); do_swizzle(VAR_1, 1, 3); break; case DDS_SWIZZLE_RXGB: av_log(VAR_0, AV_LOG_DEBUG, "Post-processing RXGB swizzle.\n"); do_swizzle(VAR_1, 0, 3); break; case DDS_SWIZZLE_XGBR: av_log(VAR_0, AV_LOG_DEBUG, "Post-processing XGBR swizzle.\n"); do_swizzle(VAR_1, 2, 3); do_swizzle(VAR_1, 0, 3); break; case DDS_SWIZZLE_XGXR: av_log(VAR_0, AV_LOG_DEBUG, "Post-processing XGXR swizzle.\n"); do_swizzle(VAR_1, 1, 3); do_swizzle(VAR_1, 0, 3); do_swizzle(VAR_1, 0, 1); break; case DDS_SWIZZLE_XRBG: av_log(VAR_0, AV_LOG_DEBUG, "Post-processing XRBG swizzle.\n"); do_swizzle(VAR_1, 1, 3); do_swizzle(VAR_1, 0, 3); break; } }
[ "static void FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1)\n{", "DDSContext *ctx = VAR_0->priv_data;", "int VAR_2, VAR_3;", "switch (ctx->postproc) {", "case DDS_ALPHA_EXP:\nav_log(VAR_0, AV_LOG_DEBUG, \"Post-processing alpha exponent.\\n\");", "for (VAR_2 = 0; VAR_2 < VAR_1->linesize[0] * VAR_1->height; VAR_2 += 4) {", "uint8_t *src = VAR_1->data[0] + VAR_2;", "int r = src[0];", "int g = src[1];", "int b = src[2];", "int a = src[3];", "src[0] = r * a / 255;", "src[1] = g * a / 255;", "src[2] = b * a / 255;", "src[3] = 255;", "}", "break;", "case DDS_NORMAL_MAP:\nav_log(VAR_0, AV_LOG_DEBUG, \"Post-processing normal map.\\n\");", "VAR_3 = ctx->tex_ratio == 8 ? 0 : 3;", "for (VAR_2 = 0; VAR_2 < VAR_1->linesize[0] * VAR_1->height; VAR_2 += 4) {", "uint8_t *src = VAR_1->data[0] + VAR_2;", "int x = src[VAR_3];", "int y = src[1];", "int z = 127;", "int d = (255 * 255 - x * x - y * y) / 2;", "if (d > 0)\nz = rint(sqrtf(d));", "src[0] = x;", "src[1] = y;", "src[2] = z;", "src[3] = 255;", "}", "break;", "case DDS_RAW_YCOCG:\nav_log(VAR_0, AV_LOG_DEBUG, \"Post-processing raw YCoCg.\\n\");", "for (VAR_2 = 0; VAR_2 < VAR_1->linesize[0] * VAR_1->height; VAR_2 += 4) {", "uint8_t *src = VAR_1->data[0] + VAR_2;", "int a = src[0];", "int cg = src[1] - 128;", "int co = src[2] - 128;", "int y = src[3];", "src[0] = av_clip_uint8(y + co - cg);", "src[1] = av_clip_uint8(y + cg);", "src[2] = av_clip_uint8(y - co - cg);", "src[3] = a;", "}", "break;", "case DDS_SWAP_ALPHA:\nav_log(VAR_0, AV_LOG_DEBUG, \"Post-processing swapped Luma/Alpha.\\n\");", "for (VAR_2 = 0; VAR_2 < VAR_1->linesize[0] * VAR_1->height; VAR_2 += 2) {", "uint8_t *src = VAR_1->data[0] + VAR_2;", "FFSWAP(uint8_t, src[0], src[1]);", "}", "break;", "case DDS_SWIZZLE_A2XY:\nav_log(VAR_0, AV_LOG_DEBUG, \"Post-processing A2XY swizzle.\\n\");", "do_swizzle(VAR_1, 0, 1);", "break;", "case DDS_SWIZZLE_RBXG:\nav_log(VAR_0, AV_LOG_DEBUG, \"Post-processing RBXG swizzle.\\n\");", "do_swizzle(VAR_1, 1, 3);", "do_swizzle(VAR_1, 2, 3);", "break;", "case DDS_SWIZZLE_RGXB:\nav_log(VAR_0, AV_LOG_DEBUG, \"Post-processing RGXB swizzle.\\n\");", "do_swizzle(VAR_1, 2, 3);", "break;", "case DDS_SWIZZLE_RXBG:\nav_log(VAR_0, AV_LOG_DEBUG, \"Post-processing RXBG swizzle.\\n\");", "do_swizzle(VAR_1, 1, 3);", "break;", "case DDS_SWIZZLE_RXGB:\nav_log(VAR_0, AV_LOG_DEBUG, \"Post-processing RXGB swizzle.\\n\");", "do_swizzle(VAR_1, 0, 3);", "break;", "case DDS_SWIZZLE_XGBR:\nav_log(VAR_0, AV_LOG_DEBUG, \"Post-processing XGBR swizzle.\\n\");", "do_swizzle(VAR_1, 2, 3);", "do_swizzle(VAR_1, 0, 3);", "break;", "case DDS_SWIZZLE_XGXR:\nav_log(VAR_0, AV_LOG_DEBUG, \"Post-processing XGXR swizzle.\\n\");", "do_swizzle(VAR_1, 1, 3);", "do_swizzle(VAR_1, 0, 3);", "do_swizzle(VAR_1, 0, 1);", "break;", "case DDS_SWIZZLE_XRBG:\nav_log(VAR_0, AV_LOG_DEBUG, \"Post-processing XRBG swizzle.\\n\");", "do_swizzle(VAR_1, 1, 3);", "do_swizzle(VAR_1, 0, 3);", "break;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13, 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51, 63 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 81 ], [ 83, 85 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101, 107 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137, 141 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155, 159 ], [ 161 ], [ 163 ], [ 165, 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177, 181 ], [ 183 ], [ 185 ], [ 187, 191 ], [ 193 ], [ 195 ], [ 197, 201 ], [ 203 ], [ 205 ], [ 207, 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219, 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235, 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ] ]
8,839
static void ipvideo_decode_format_10_opcodes(IpvideoContext *s, AVFrame *frame) { int pass, x, y, changed_block; int16_t opcode, skip; GetByteContext decoding_map_ptr; GetByteContext skip_map_ptr; bytestream2_skip(&s->stream_ptr, 14); /* data starts 14 bytes in */ /* this is PAL8, so make the palette available */ memcpy(frame->data[1], s->pal, AVPALETTE_SIZE); s->stride = frame->linesize[0]; s->line_inc = s->stride - 8; s->upper_motion_limit_offset = (s->avctx->height - 8) * frame->linesize[0] + (s->avctx->width - 8) * (1 + s->is_16bpp); bytestream2_init(&decoding_map_ptr, s->decoding_map, s->decoding_map_size); bytestream2_init(&skip_map_ptr, s->skip_map, s->skip_map_size); for (pass = 0; pass < 2; ++pass) { bytestream2_seek(&decoding_map_ptr, 0, SEEK_SET); bytestream2_seek(&skip_map_ptr, 0, SEEK_SET); skip = bytestream2_get_le16(&skip_map_ptr); for (y = 0; y < s->avctx->height; y += 8) { for (x = 0; x < s->avctx->width; x += 8) { s->pixel_ptr = s->cur_decode_frame->data[0] + x + y * s->cur_decode_frame->linesize[0]; while (skip <= 0 && bytestream2_get_bytes_left(&decoding_map_ptr) > 1) { if (skip != -0x8000 && skip) { opcode = bytestream2_get_le16(&decoding_map_ptr); ipvideo_format_10_passes[pass](s, frame, opcode); break; } skip = bytestream2_get_le16(&skip_map_ptr); } skip *= 2; } } } bytestream2_seek(&skip_map_ptr, 0, SEEK_SET); skip = bytestream2_get_le16(&skip_map_ptr); for (y = 0; y < s->avctx->height; y += 8) { for (x = 0; x < s->avctx->width; x += 8) { changed_block = 0; s->pixel_ptr = frame->data[0] + x + y*frame->linesize[0]; while (skip <= 0) { if (skip != -0x8000 && skip) { changed_block = 1; break; } if (bytestream2_get_bytes_left(&skip_map_ptr) < 2) return; skip = bytestream2_get_le16(&skip_map_ptr); } if (changed_block) { copy_from(s, s->cur_decode_frame, frame, 0, 0); } else { /* Don't try to copy last_frame data on the first frame */ if (s->avctx->frame_number) copy_from(s, s->last_frame, frame, 0, 0); } skip *= 2; } } FFSWAP(AVFrame*, s->prev_decode_frame, s->cur_decode_frame); if (bytestream2_get_bytes_left(&s->stream_ptr) > 1) { av_log(s->avctx, AV_LOG_DEBUG, "decode finished with %d bytes left over\n", bytestream2_get_bytes_left(&s->stream_ptr)); } }
false
FFmpeg
f0edab6e63ecee29cb68230100f0c2fb5468284c
static void ipvideo_decode_format_10_opcodes(IpvideoContext *s, AVFrame *frame) { int pass, x, y, changed_block; int16_t opcode, skip; GetByteContext decoding_map_ptr; GetByteContext skip_map_ptr; bytestream2_skip(&s->stream_ptr, 14); memcpy(frame->data[1], s->pal, AVPALETTE_SIZE); s->stride = frame->linesize[0]; s->line_inc = s->stride - 8; s->upper_motion_limit_offset = (s->avctx->height - 8) * frame->linesize[0] + (s->avctx->width - 8) * (1 + s->is_16bpp); bytestream2_init(&decoding_map_ptr, s->decoding_map, s->decoding_map_size); bytestream2_init(&skip_map_ptr, s->skip_map, s->skip_map_size); for (pass = 0; pass < 2; ++pass) { bytestream2_seek(&decoding_map_ptr, 0, SEEK_SET); bytestream2_seek(&skip_map_ptr, 0, SEEK_SET); skip = bytestream2_get_le16(&skip_map_ptr); for (y = 0; y < s->avctx->height; y += 8) { for (x = 0; x < s->avctx->width; x += 8) { s->pixel_ptr = s->cur_decode_frame->data[0] + x + y * s->cur_decode_frame->linesize[0]; while (skip <= 0 && bytestream2_get_bytes_left(&decoding_map_ptr) > 1) { if (skip != -0x8000 && skip) { opcode = bytestream2_get_le16(&decoding_map_ptr); ipvideo_format_10_passes[pass](s, frame, opcode); break; } skip = bytestream2_get_le16(&skip_map_ptr); } skip *= 2; } } } bytestream2_seek(&skip_map_ptr, 0, SEEK_SET); skip = bytestream2_get_le16(&skip_map_ptr); for (y = 0; y < s->avctx->height; y += 8) { for (x = 0; x < s->avctx->width; x += 8) { changed_block = 0; s->pixel_ptr = frame->data[0] + x + y*frame->linesize[0]; while (skip <= 0) { if (skip != -0x8000 && skip) { changed_block = 1; break; } if (bytestream2_get_bytes_left(&skip_map_ptr) < 2) return; skip = bytestream2_get_le16(&skip_map_ptr); } if (changed_block) { copy_from(s, s->cur_decode_frame, frame, 0, 0); } else { if (s->avctx->frame_number) copy_from(s, s->last_frame, frame, 0, 0); } skip *= 2; } } FFSWAP(AVFrame*, s->prev_decode_frame, s->cur_decode_frame); if (bytestream2_get_bytes_left(&s->stream_ptr) > 1) { av_log(s->avctx, AV_LOG_DEBUG, "decode finished with %d bytes left over\n", bytestream2_get_bytes_left(&s->stream_ptr)); } }
{ "code": [], "line_no": [] }
static void FUNC_0(IpvideoContext *VAR_0, AVFrame *VAR_1) { int VAR_2, VAR_3, VAR_4, VAR_5; int16_t opcode, skip; GetByteContext decoding_map_ptr; GetByteContext skip_map_ptr; bytestream2_skip(&VAR_0->stream_ptr, 14); memcpy(VAR_1->data[1], VAR_0->pal, AVPALETTE_SIZE); VAR_0->stride = VAR_1->linesize[0]; VAR_0->line_inc = VAR_0->stride - 8; VAR_0->upper_motion_limit_offset = (VAR_0->avctx->height - 8) * VAR_1->linesize[0] + (VAR_0->avctx->width - 8) * (1 + VAR_0->is_16bpp); bytestream2_init(&decoding_map_ptr, VAR_0->decoding_map, VAR_0->decoding_map_size); bytestream2_init(&skip_map_ptr, VAR_0->skip_map, VAR_0->skip_map_size); for (VAR_2 = 0; VAR_2 < 2; ++VAR_2) { bytestream2_seek(&decoding_map_ptr, 0, SEEK_SET); bytestream2_seek(&skip_map_ptr, 0, SEEK_SET); skip = bytestream2_get_le16(&skip_map_ptr); for (VAR_4 = 0; VAR_4 < VAR_0->avctx->height; VAR_4 += 8) { for (VAR_3 = 0; VAR_3 < VAR_0->avctx->width; VAR_3 += 8) { VAR_0->pixel_ptr = VAR_0->cur_decode_frame->data[0] + VAR_3 + VAR_4 * VAR_0->cur_decode_frame->linesize[0]; while (skip <= 0 && bytestream2_get_bytes_left(&decoding_map_ptr) > 1) { if (skip != -0x8000 && skip) { opcode = bytestream2_get_le16(&decoding_map_ptr); ipvideo_format_10_passes[VAR_2](VAR_0, VAR_1, opcode); break; } skip = bytestream2_get_le16(&skip_map_ptr); } skip *= 2; } } } bytestream2_seek(&skip_map_ptr, 0, SEEK_SET); skip = bytestream2_get_le16(&skip_map_ptr); for (VAR_4 = 0; VAR_4 < VAR_0->avctx->height; VAR_4 += 8) { for (VAR_3 = 0; VAR_3 < VAR_0->avctx->width; VAR_3 += 8) { VAR_5 = 0; VAR_0->pixel_ptr = VAR_1->data[0] + VAR_3 + VAR_4*VAR_1->linesize[0]; while (skip <= 0) { if (skip != -0x8000 && skip) { VAR_5 = 1; break; } if (bytestream2_get_bytes_left(&skip_map_ptr) < 2) return; skip = bytestream2_get_le16(&skip_map_ptr); } if (VAR_5) { copy_from(VAR_0, VAR_0->cur_decode_frame, VAR_1, 0, 0); } else { if (VAR_0->avctx->frame_number) copy_from(VAR_0, VAR_0->last_frame, VAR_1, 0, 0); } skip *= 2; } } FFSWAP(AVFrame*, VAR_0->prev_decode_frame, VAR_0->cur_decode_frame); if (bytestream2_get_bytes_left(&VAR_0->stream_ptr) > 1) { av_log(VAR_0->avctx, AV_LOG_DEBUG, "decode finished with %d bytes left over\n", bytestream2_get_bytes_left(&VAR_0->stream_ptr)); } }
[ "static void FUNC_0(IpvideoContext *VAR_0, AVFrame *VAR_1)\n{", "int VAR_2, VAR_3, VAR_4, VAR_5;", "int16_t opcode, skip;", "GetByteContext decoding_map_ptr;", "GetByteContext skip_map_ptr;", "bytestream2_skip(&VAR_0->stream_ptr, 14);", "memcpy(VAR_1->data[1], VAR_0->pal, AVPALETTE_SIZE);", "VAR_0->stride = VAR_1->linesize[0];", "VAR_0->line_inc = VAR_0->stride - 8;", "VAR_0->upper_motion_limit_offset = (VAR_0->avctx->height - 8) * VAR_1->linesize[0]\n+ (VAR_0->avctx->width - 8) * (1 + VAR_0->is_16bpp);", "bytestream2_init(&decoding_map_ptr, VAR_0->decoding_map, VAR_0->decoding_map_size);", "bytestream2_init(&skip_map_ptr, VAR_0->skip_map, VAR_0->skip_map_size);", "for (VAR_2 = 0; VAR_2 < 2; ++VAR_2) {", "bytestream2_seek(&decoding_map_ptr, 0, SEEK_SET);", "bytestream2_seek(&skip_map_ptr, 0, SEEK_SET);", "skip = bytestream2_get_le16(&skip_map_ptr);", "for (VAR_4 = 0; VAR_4 < VAR_0->avctx->height; VAR_4 += 8) {", "for (VAR_3 = 0; VAR_3 < VAR_0->avctx->width; VAR_3 += 8) {", "VAR_0->pixel_ptr = VAR_0->cur_decode_frame->data[0] + VAR_3 + VAR_4 * VAR_0->cur_decode_frame->linesize[0];", "while (skip <= 0 && bytestream2_get_bytes_left(&decoding_map_ptr) > 1) {", "if (skip != -0x8000 && skip) {", "opcode = bytestream2_get_le16(&decoding_map_ptr);", "ipvideo_format_10_passes[VAR_2](VAR_0, VAR_1, opcode);", "break;", "}", "skip = bytestream2_get_le16(&skip_map_ptr);", "}", "skip *= 2;", "}", "}", "}", "bytestream2_seek(&skip_map_ptr, 0, SEEK_SET);", "skip = bytestream2_get_le16(&skip_map_ptr);", "for (VAR_4 = 0; VAR_4 < VAR_0->avctx->height; VAR_4 += 8) {", "for (VAR_3 = 0; VAR_3 < VAR_0->avctx->width; VAR_3 += 8) {", "VAR_5 = 0;", "VAR_0->pixel_ptr = VAR_1->data[0] + VAR_3 + VAR_4*VAR_1->linesize[0];", "while (skip <= 0) {", "if (skip != -0x8000 && skip) {", "VAR_5 = 1;", "break;", "}", "if (bytestream2_get_bytes_left(&skip_map_ptr) < 2)\nreturn;", "skip = bytestream2_get_le16(&skip_map_ptr);", "}", "if (VAR_5) {", "copy_from(VAR_0, VAR_0->cur_decode_frame, VAR_1, 0, 0);", "} else {", "if (VAR_0->avctx->frame_number)\ncopy_from(VAR_0, VAR_0->last_frame, VAR_1, 0, 0);", "}", "skip *= 2;", "}", "}", "FFSWAP(AVFrame*, VAR_0->prev_decode_frame, VAR_0->cur_decode_frame);", "if (bytestream2_get_bytes_left(&VAR_0->stream_ptr) > 1) {", "av_log(VAR_0->avctx, AV_LOG_DEBUG,\n\"decode finished with %d bytes left over\\n\",\nbytestream2_get_bytes_left(&VAR_0->stream_ptr));", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 27 ], [ 29, 31 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109, 111 ], [ 113 ], [ 115 ], [ 119 ], [ 121 ], [ 123 ], [ 127, 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 141 ], [ 145 ], [ 147, 149, 151 ], [ 153 ], [ 155 ] ]
8,840
static uint64_t omap_clkm_read(void *opaque, target_phys_addr_t addr, unsigned size) { struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; if (size != 2) { return omap_badwidth_read16(opaque, addr); } switch (addr) { case 0x00: /* ARM_CKCTL */ return s->clkm.arm_ckctl; case 0x04: /* ARM_IDLECT1 */ return s->clkm.arm_idlect1; case 0x08: /* ARM_IDLECT2 */ return s->clkm.arm_idlect2; case 0x0c: /* ARM_EWUPCT */ return s->clkm.arm_ewupct; case 0x10: /* ARM_RSTCT1 */ return s->clkm.arm_rstct1; case 0x14: /* ARM_RSTCT2 */ return s->clkm.arm_rstct2; case 0x18: /* ARM_SYSST */ return (s->clkm.clocking_scheme << 11) | s->clkm.cold_start; case 0x1c: /* ARM_CKOUT1 */ return s->clkm.arm_ckout1; case 0x20: /* ARM_CKOUT2 */ break; } OMAP_BAD_REG(addr); return 0; }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static uint64_t omap_clkm_read(void *opaque, target_phys_addr_t addr, unsigned size) { struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; if (size != 2) { return omap_badwidth_read16(opaque, addr); } switch (addr) { case 0x00: return s->clkm.arm_ckctl; case 0x04: return s->clkm.arm_idlect1; case 0x08: return s->clkm.arm_idlect2; case 0x0c: return s->clkm.arm_ewupct; case 0x10: return s->clkm.arm_rstct1; case 0x14: return s->clkm.arm_rstct2; case 0x18: return (s->clkm.clocking_scheme << 11) | s->clkm.cold_start; case 0x1c: return s->clkm.arm_ckout1; case 0x20: break; } OMAP_BAD_REG(addr); return 0; }
{ "code": [], "line_no": [] }
static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr, unsigned size) { struct omap_mpu_state_s *VAR_0 = (struct omap_mpu_state_s *) opaque; if (size != 2) { return omap_badwidth_read16(opaque, addr); } switch (addr) { case 0x00: return VAR_0->clkm.arm_ckctl; case 0x04: return VAR_0->clkm.arm_idlect1; case 0x08: return VAR_0->clkm.arm_idlect2; case 0x0c: return VAR_0->clkm.arm_ewupct; case 0x10: return VAR_0->clkm.arm_rstct1; case 0x14: return VAR_0->clkm.arm_rstct2; case 0x18: return (VAR_0->clkm.clocking_scheme << 11) | VAR_0->clkm.cold_start; case 0x1c: return VAR_0->clkm.arm_ckout1; case 0x20: break; } OMAP_BAD_REG(addr); return 0; }
[ "static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{", "struct omap_mpu_state_s *VAR_0 = (struct omap_mpu_state_s *) opaque;", "if (size != 2) {", "return omap_badwidth_read16(opaque, addr);", "}", "switch (addr) {", "case 0x00:\nreturn VAR_0->clkm.arm_ckctl;", "case 0x04:\nreturn VAR_0->clkm.arm_idlect1;", "case 0x08:\nreturn VAR_0->clkm.arm_idlect2;", "case 0x0c:\nreturn VAR_0->clkm.arm_ewupct;", "case 0x10:\nreturn VAR_0->clkm.arm_rstct1;", "case 0x14:\nreturn VAR_0->clkm.arm_rstct2;", "case 0x18:\nreturn (VAR_0->clkm.clocking_scheme << 11) | VAR_0->clkm.cold_start;", "case 0x1c:\nreturn VAR_0->clkm.arm_ckout1;", "case 0x20:\nbreak;", "}", "OMAP_BAD_REG(addr);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21, 23 ], [ 27, 29 ], [ 33, 35 ], [ 39, 41 ], [ 45, 47 ], [ 51, 53 ], [ 57, 59 ], [ 63, 65 ], [ 69, 71 ], [ 73 ], [ 77 ], [ 79 ], [ 81 ] ]
8,841
static int xen_pt_msgaddr32_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, uint32_t *val, uint32_t dev_value, uint32_t valid_mask) { XenPTRegInfo *reg = cfg_entry->reg; uint32_t writable_mask = 0; uint32_t old_addr = cfg_entry->data; /* modify emulate register */ writable_mask = reg->emu_mask & ~reg->ro_mask & valid_mask; cfg_entry->data = XEN_PT_MERGE_VALUE(*val, cfg_entry->data, writable_mask); s->msi->addr_lo = cfg_entry->data; /* create value for writing to I/O device register */ *val = XEN_PT_MERGE_VALUE(*val, dev_value, 0); /* update MSI */ if (cfg_entry->data != old_addr) { if (s->msi->mapped) { xen_pt_msi_update(s); } } return 0; }
false
qemu
e2779de053b64f023de382fd87b3596613d47d1e
static int xen_pt_msgaddr32_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, uint32_t *val, uint32_t dev_value, uint32_t valid_mask) { XenPTRegInfo *reg = cfg_entry->reg; uint32_t writable_mask = 0; uint32_t old_addr = cfg_entry->data; writable_mask = reg->emu_mask & ~reg->ro_mask & valid_mask; cfg_entry->data = XEN_PT_MERGE_VALUE(*val, cfg_entry->data, writable_mask); s->msi->addr_lo = cfg_entry->data; *val = XEN_PT_MERGE_VALUE(*val, dev_value, 0); if (cfg_entry->data != old_addr) { if (s->msi->mapped) { xen_pt_msi_update(s); } } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(XenPCIPassthroughState *VAR_0, XenPTReg *VAR_1, uint32_t *VAR_2, uint32_t VAR_3, uint32_t VAR_4) { XenPTRegInfo *reg = VAR_1->reg; uint32_t writable_mask = 0; uint32_t old_addr = VAR_1->data; writable_mask = reg->emu_mask & ~reg->ro_mask & VAR_4; VAR_1->data = XEN_PT_MERGE_VALUE(*VAR_2, VAR_1->data, writable_mask); VAR_0->msi->addr_lo = VAR_1->data; *VAR_2 = XEN_PT_MERGE_VALUE(*VAR_2, VAR_3, 0); if (VAR_1->data != old_addr) { if (VAR_0->msi->mapped) { xen_pt_msi_update(VAR_0); } } return 0; }
[ "static int FUNC_0(XenPCIPassthroughState *VAR_0,\nXenPTReg *VAR_1, uint32_t *VAR_2,\nuint32_t VAR_3, uint32_t VAR_4)\n{", "XenPTRegInfo *reg = VAR_1->reg;", "uint32_t writable_mask = 0;", "uint32_t old_addr = VAR_1->data;", "writable_mask = reg->emu_mask & ~reg->ro_mask & VAR_4;", "VAR_1->data = XEN_PT_MERGE_VALUE(*VAR_2, VAR_1->data, writable_mask);", "VAR_0->msi->addr_lo = VAR_1->data;", "*VAR_2 = XEN_PT_MERGE_VALUE(*VAR_2, VAR_3, 0);", "if (VAR_1->data != old_addr) {", "if (VAR_0->msi->mapped) {", "xen_pt_msi_update(VAR_0);", "}", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 19 ], [ 21 ], [ 23 ], [ 29 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ] ]
8,842
static void bdrv_qed_refresh_limits(BlockDriverState *bs, Error **errp) { BDRVQEDState *s = bs->opaque; bs->bl.write_zeroes_alignment = s->header.cluster_size >> BDRV_SECTOR_BITS; }
false
qemu
cf081fca4e3cc02a309659b571ab0c5b225ea4cf
static void bdrv_qed_refresh_limits(BlockDriverState *bs, Error **errp) { BDRVQEDState *s = bs->opaque; bs->bl.write_zeroes_alignment = s->header.cluster_size >> BDRV_SECTOR_BITS; }
{ "code": [], "line_no": [] }
static void FUNC_0(BlockDriverState *VAR_0, Error **VAR_1) { BDRVQEDState *s = VAR_0->opaque; VAR_0->bl.write_zeroes_alignment = s->header.cluster_size >> BDRV_SECTOR_BITS; }
[ "static void FUNC_0(BlockDriverState *VAR_0, Error **VAR_1)\n{", "BDRVQEDState *s = VAR_0->opaque;", "VAR_0->bl.write_zeroes_alignment = s->header.cluster_size >> BDRV_SECTOR_BITS;", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ] ]
8,843
int block_signals(void) { TaskState *ts = (TaskState *)thread_cpu->opaque; sigset_t set; int pending; /* It's OK to block everything including SIGSEGV, because we won't * run any further guest code before unblocking signals in * process_pending_signals(). */ sigfillset(&set); sigprocmask(SIG_SETMASK, &set, 0); pending = atomic_xchg(&ts->signal_pending, 1); return pending; }
false
qemu
9be385980d37e8f4fd33f605f5fb1c3d144170a8
int block_signals(void) { TaskState *ts = (TaskState *)thread_cpu->opaque; sigset_t set; int pending; sigfillset(&set); sigprocmask(SIG_SETMASK, &set, 0); pending = atomic_xchg(&ts->signal_pending, 1); return pending; }
{ "code": [], "line_no": [] }
int FUNC_0(void) { TaskState *ts = (TaskState *)thread_cpu->opaque; sigset_t set; int VAR_0; sigfillset(&set); sigprocmask(SIG_SETMASK, &set, 0); VAR_0 = atomic_xchg(&ts->signal_pending, 1); return VAR_0; }
[ "int FUNC_0(void)\n{", "TaskState *ts = (TaskState *)thread_cpu->opaque;", "sigset_t set;", "int VAR_0;", "sigfillset(&set);", "sigprocmask(SIG_SETMASK, &set, 0);", "VAR_0 = atomic_xchg(&ts->signal_pending, 1);", "return VAR_0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 21 ], [ 23 ], [ 27 ], [ 31 ], [ 33 ] ]
8,844
static void poll_set_started(AioContext *ctx, bool started) { AioHandler *node; if (started == ctx->poll_started) { return; } ctx->poll_started = started; qemu_lockcnt_inc(&ctx->list_lock); QLIST_FOREACH_RCU(node, &ctx->aio_handlers, node) { IOHandler *fn; if (node->deleted) { continue; } if (started) { fn = node->io_poll_begin; } else { fn = node->io_poll_end; } if (fn) { fn(node->opaque); } } qemu_lockcnt_dec(&ctx->list_lock); }
false
qemu
c2b38b277a7882a592f4f2ec955084b2b756daaa
static void poll_set_started(AioContext *ctx, bool started) { AioHandler *node; if (started == ctx->poll_started) { return; } ctx->poll_started = started; qemu_lockcnt_inc(&ctx->list_lock); QLIST_FOREACH_RCU(node, &ctx->aio_handlers, node) { IOHandler *fn; if (node->deleted) { continue; } if (started) { fn = node->io_poll_begin; } else { fn = node->io_poll_end; } if (fn) { fn(node->opaque); } } qemu_lockcnt_dec(&ctx->list_lock); }
{ "code": [], "line_no": [] }
static void FUNC_0(AioContext *VAR_0, bool VAR_1) { AioHandler *node; if (VAR_1 == VAR_0->poll_started) { return; } VAR_0->poll_started = VAR_1; qemu_lockcnt_inc(&VAR_0->list_lock); QLIST_FOREACH_RCU(node, &VAR_0->aio_handlers, node) { IOHandler *fn; if (node->deleted) { continue; } if (VAR_1) { fn = node->io_poll_begin; } else { fn = node->io_poll_end; } if (fn) { fn(node->opaque); } } qemu_lockcnt_dec(&VAR_0->list_lock); }
[ "static void FUNC_0(AioContext *VAR_0, bool VAR_1)\n{", "AioHandler *node;", "if (VAR_1 == VAR_0->poll_started) {", "return;", "}", "VAR_0->poll_started = VAR_1;", "qemu_lockcnt_inc(&VAR_0->list_lock);", "QLIST_FOREACH_RCU(node, &VAR_0->aio_handlers, node) {", "IOHandler *fn;", "if (node->deleted) {", "continue;", "}", "if (VAR_1) {", "fn = node->io_poll_begin;", "} else {", "fn = node->io_poll_end;", "}", "if (fn) {", "fn(node->opaque);", "}", "}", "qemu_lockcnt_dec(&VAR_0->list_lock);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ] ]
8,845
void qemu_iohandler_fill(GArray *pollfds) { IOHandlerRecord *ioh; QLIST_FOREACH(ioh, &io_handlers, next) { int events = 0; if (ioh->deleted) continue; if (ioh->fd_read && (!ioh->fd_read_poll || ioh->fd_read_poll(ioh->opaque) != 0)) { events |= G_IO_IN | G_IO_HUP | G_IO_ERR; } if (ioh->fd_write) { events |= G_IO_OUT | G_IO_ERR; } if (events) { GPollFD pfd = { .fd = ioh->fd, .events = events, }; ioh->pollfds_idx = pollfds->len; g_array_append_val(pollfds, pfd); } else { ioh->pollfds_idx = -1; } } }
false
qemu
6484e422479c93f28e3f8a68258b0eacd3b31e6d
void qemu_iohandler_fill(GArray *pollfds) { IOHandlerRecord *ioh; QLIST_FOREACH(ioh, &io_handlers, next) { int events = 0; if (ioh->deleted) continue; if (ioh->fd_read && (!ioh->fd_read_poll || ioh->fd_read_poll(ioh->opaque) != 0)) { events |= G_IO_IN | G_IO_HUP | G_IO_ERR; } if (ioh->fd_write) { events |= G_IO_OUT | G_IO_ERR; } if (events) { GPollFD pfd = { .fd = ioh->fd, .events = events, }; ioh->pollfds_idx = pollfds->len; g_array_append_val(pollfds, pfd); } else { ioh->pollfds_idx = -1; } } }
{ "code": [], "line_no": [] }
void FUNC_0(GArray *VAR_0) { IOHandlerRecord *ioh; QLIST_FOREACH(ioh, &io_handlers, next) { int events = 0; if (ioh->deleted) continue; if (ioh->fd_read && (!ioh->fd_read_poll || ioh->fd_read_poll(ioh->opaque) != 0)) { events |= G_IO_IN | G_IO_HUP | G_IO_ERR; } if (ioh->fd_write) { events |= G_IO_OUT | G_IO_ERR; } if (events) { GPollFD pfd = { .fd = ioh->fd, .events = events, }; ioh->pollfds_idx = VAR_0->len; g_array_append_val(VAR_0, pfd); } else { ioh->pollfds_idx = -1; } } }
[ "void FUNC_0(GArray *VAR_0)\n{", "IOHandlerRecord *ioh;", "QLIST_FOREACH(ioh, &io_handlers, next) {", "int events = 0;", "if (ioh->deleted)\ncontinue;", "if (ioh->fd_read &&\n(!ioh->fd_read_poll ||\nioh->fd_read_poll(ioh->opaque) != 0)) {", "events |= G_IO_IN | G_IO_HUP | G_IO_ERR;", "}", "if (ioh->fd_write) {", "events |= G_IO_OUT | G_IO_ERR;", "}", "if (events) {", "GPollFD pfd = {", ".fd = ioh->fd,\n.events = events,\n};", "ioh->pollfds_idx = VAR_0->len;", "g_array_append_val(VAR_0, pfd);", "} else {", "ioh->pollfds_idx = -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 ], [ 9 ], [ 11 ], [ 15, 17 ], [ 19, 21, 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39, 41, 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ] ]
8,847
static void powernv_create_core_node(PnvChip *chip, PnvCore *pc, void *fdt) { CPUState *cs = CPU(DEVICE(pc->threads)); DeviceClass *dc = DEVICE_GET_CLASS(cs); PowerPCCPU *cpu = POWERPC_CPU(cs); int smt_threads = CPU_CORE(pc)->nr_threads; CPUPPCState *env = &cpu->env; PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs); uint32_t servers_prop[smt_threads]; int i; uint32_t segs[] = {cpu_to_be32(28), cpu_to_be32(40), 0xffffffff, 0xffffffff}; uint32_t tbfreq = PNV_TIMEBASE_FREQ; uint32_t cpufreq = 1000000000; uint32_t page_sizes_prop[64]; size_t page_sizes_prop_size; const uint8_t pa_features[] = { 24, 0, 0xf6, 0x3f, 0xc7, 0xc0, 0x80, 0xf0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00 }; int offset; char *nodename; int cpus_offset = get_cpus_node(fdt); nodename = g_strdup_printf("%s@%x", dc->fw_name, pc->pir); offset = fdt_add_subnode(fdt, cpus_offset, nodename); _FDT(offset); g_free(nodename); _FDT((fdt_setprop_cell(fdt, offset, "ibm,chip-id", chip->chip_id))); _FDT((fdt_setprop_cell(fdt, offset, "reg", pc->pir))); _FDT((fdt_setprop_cell(fdt, offset, "ibm,pir", pc->pir))); _FDT((fdt_setprop_string(fdt, offset, "device_type", "cpu"))); _FDT((fdt_setprop_cell(fdt, offset, "cpu-version", env->spr[SPR_PVR]))); _FDT((fdt_setprop_cell(fdt, offset, "d-cache-block-size", env->dcache_line_size))); _FDT((fdt_setprop_cell(fdt, offset, "d-cache-line-size", env->dcache_line_size))); _FDT((fdt_setprop_cell(fdt, offset, "i-cache-block-size", env->icache_line_size))); _FDT((fdt_setprop_cell(fdt, offset, "i-cache-line-size", env->icache_line_size))); if (pcc->l1_dcache_size) { _FDT((fdt_setprop_cell(fdt, offset, "d-cache-size", pcc->l1_dcache_size))); } else { error_report("Warning: Unknown L1 dcache size for cpu"); } if (pcc->l1_icache_size) { _FDT((fdt_setprop_cell(fdt, offset, "i-cache-size", pcc->l1_icache_size))); } else { error_report("Warning: Unknown L1 icache size for cpu"); } _FDT((fdt_setprop_cell(fdt, offset, "timebase-frequency", tbfreq))); _FDT((fdt_setprop_cell(fdt, offset, "clock-frequency", cpufreq))); _FDT((fdt_setprop_cell(fdt, offset, "ibm,slb-size", env->slb_nr))); _FDT((fdt_setprop_string(fdt, offset, "status", "okay"))); _FDT((fdt_setprop(fdt, offset, "64-bit", NULL, 0))); if (env->spr_cb[SPR_PURR].oea_read) { _FDT((fdt_setprop(fdt, offset, "ibm,purr", NULL, 0))); } if (env->mmu_model & POWERPC_MMU_1TSEG) { _FDT((fdt_setprop(fdt, offset, "ibm,processor-segment-sizes", segs, sizeof(segs)))); } /* Advertise VMX/VSX (vector extensions) if available * 0 / no property == no vector extensions * 1 == VMX / Altivec available * 2 == VSX available */ if (env->insns_flags & PPC_ALTIVEC) { uint32_t vmx = (env->insns_flags2 & PPC2_VSX) ? 2 : 1; _FDT((fdt_setprop_cell(fdt, offset, "ibm,vmx", vmx))); } /* Advertise DFP (Decimal Floating Point) if available * 0 / no property == no DFP * 1 == DFP available */ if (env->insns_flags2 & PPC2_DFP) { _FDT((fdt_setprop_cell(fdt, offset, "ibm,dfp", 1))); } page_sizes_prop_size = ppc_create_page_sizes_prop(env, page_sizes_prop, sizeof(page_sizes_prop)); if (page_sizes_prop_size) { _FDT((fdt_setprop(fdt, offset, "ibm,segment-page-sizes", page_sizes_prop, page_sizes_prop_size))); } _FDT((fdt_setprop(fdt, offset, "ibm,pa-features", pa_features, sizeof(pa_features)))); /* Build interrupt servers properties */ for (i = 0; i < smt_threads; i++) { servers_prop[i] = cpu_to_be32(pc->pir + i); } _FDT((fdt_setprop(fdt, offset, "ibm,ppc-interrupt-server#s", servers_prop, sizeof(servers_prop)))); }
false
qemu
3dc6f8693694a649a9c83f1e2746565b47683923
static void powernv_create_core_node(PnvChip *chip, PnvCore *pc, void *fdt) { CPUState *cs = CPU(DEVICE(pc->threads)); DeviceClass *dc = DEVICE_GET_CLASS(cs); PowerPCCPU *cpu = POWERPC_CPU(cs); int smt_threads = CPU_CORE(pc)->nr_threads; CPUPPCState *env = &cpu->env; PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs); uint32_t servers_prop[smt_threads]; int i; uint32_t segs[] = {cpu_to_be32(28), cpu_to_be32(40), 0xffffffff, 0xffffffff}; uint32_t tbfreq = PNV_TIMEBASE_FREQ; uint32_t cpufreq = 1000000000; uint32_t page_sizes_prop[64]; size_t page_sizes_prop_size; const uint8_t pa_features[] = { 24, 0, 0xf6, 0x3f, 0xc7, 0xc0, 0x80, 0xf0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00 }; int offset; char *nodename; int cpus_offset = get_cpus_node(fdt); nodename = g_strdup_printf("%s@%x", dc->fw_name, pc->pir); offset = fdt_add_subnode(fdt, cpus_offset, nodename); _FDT(offset); g_free(nodename); _FDT((fdt_setprop_cell(fdt, offset, "ibm,chip-id", chip->chip_id))); _FDT((fdt_setprop_cell(fdt, offset, "reg", pc->pir))); _FDT((fdt_setprop_cell(fdt, offset, "ibm,pir", pc->pir))); _FDT((fdt_setprop_string(fdt, offset, "device_type", "cpu"))); _FDT((fdt_setprop_cell(fdt, offset, "cpu-version", env->spr[SPR_PVR]))); _FDT((fdt_setprop_cell(fdt, offset, "d-cache-block-size", env->dcache_line_size))); _FDT((fdt_setprop_cell(fdt, offset, "d-cache-line-size", env->dcache_line_size))); _FDT((fdt_setprop_cell(fdt, offset, "i-cache-block-size", env->icache_line_size))); _FDT((fdt_setprop_cell(fdt, offset, "i-cache-line-size", env->icache_line_size))); if (pcc->l1_dcache_size) { _FDT((fdt_setprop_cell(fdt, offset, "d-cache-size", pcc->l1_dcache_size))); } else { error_report("Warning: Unknown L1 dcache size for cpu"); } if (pcc->l1_icache_size) { _FDT((fdt_setprop_cell(fdt, offset, "i-cache-size", pcc->l1_icache_size))); } else { error_report("Warning: Unknown L1 icache size for cpu"); } _FDT((fdt_setprop_cell(fdt, offset, "timebase-frequency", tbfreq))); _FDT((fdt_setprop_cell(fdt, offset, "clock-frequency", cpufreq))); _FDT((fdt_setprop_cell(fdt, offset, "ibm,slb-size", env->slb_nr))); _FDT((fdt_setprop_string(fdt, offset, "status", "okay"))); _FDT((fdt_setprop(fdt, offset, "64-bit", NULL, 0))); if (env->spr_cb[SPR_PURR].oea_read) { _FDT((fdt_setprop(fdt, offset, "ibm,purr", NULL, 0))); } if (env->mmu_model & POWERPC_MMU_1TSEG) { _FDT((fdt_setprop(fdt, offset, "ibm,processor-segment-sizes", segs, sizeof(segs)))); } if (env->insns_flags & PPC_ALTIVEC) { uint32_t vmx = (env->insns_flags2 & PPC2_VSX) ? 2 : 1; _FDT((fdt_setprop_cell(fdt, offset, "ibm,vmx", vmx))); } if (env->insns_flags2 & PPC2_DFP) { _FDT((fdt_setprop_cell(fdt, offset, "ibm,dfp", 1))); } page_sizes_prop_size = ppc_create_page_sizes_prop(env, page_sizes_prop, sizeof(page_sizes_prop)); if (page_sizes_prop_size) { _FDT((fdt_setprop(fdt, offset, "ibm,segment-page-sizes", page_sizes_prop, page_sizes_prop_size))); } _FDT((fdt_setprop(fdt, offset, "ibm,pa-features", pa_features, sizeof(pa_features)))); for (i = 0; i < smt_threads; i++) { servers_prop[i] = cpu_to_be32(pc->pir + i); } _FDT((fdt_setprop(fdt, offset, "ibm,ppc-interrupt-server#s", servers_prop, sizeof(servers_prop)))); }
{ "code": [], "line_no": [] }
static void FUNC_0(PnvChip *VAR_0, PnvCore *VAR_1, void *VAR_2) { CPUState *cs = CPU(DEVICE(VAR_1->threads)); DeviceClass *dc = DEVICE_GET_CLASS(cs); PowerPCCPU *cpu = POWERPC_CPU(cs); int VAR_3 = CPU_CORE(VAR_1)->nr_threads; CPUPPCState *env = &cpu->env; PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs); uint32_t servers_prop[VAR_3]; int VAR_4; uint32_t segs[] = {cpu_to_be32(28), cpu_to_be32(40), 0xffffffff, 0xffffffff}; uint32_t tbfreq = PNV_TIMEBASE_FREQ; uint32_t cpufreq = 1000000000; uint32_t page_sizes_prop[64]; size_t page_sizes_prop_size; const uint8_t VAR_5[] = { 24, 0, 0xf6, 0x3f, 0xc7, 0xc0, 0x80, 0xf0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00 }; int VAR_6; char *VAR_7; int VAR_8 = get_cpus_node(VAR_2); VAR_7 = g_strdup_printf("%s@%x", dc->fw_name, VAR_1->pir); VAR_6 = fdt_add_subnode(VAR_2, VAR_8, VAR_7); _FDT(VAR_6); g_free(VAR_7); _FDT((fdt_setprop_cell(VAR_2, VAR_6, "ibm,VAR_0-id", VAR_0->chip_id))); _FDT((fdt_setprop_cell(VAR_2, VAR_6, "reg", VAR_1->pir))); _FDT((fdt_setprop_cell(VAR_2, VAR_6, "ibm,pir", VAR_1->pir))); _FDT((fdt_setprop_string(VAR_2, VAR_6, "device_type", "cpu"))); _FDT((fdt_setprop_cell(VAR_2, VAR_6, "cpu-version", env->spr[SPR_PVR]))); _FDT((fdt_setprop_cell(VAR_2, VAR_6, "d-cache-block-size", env->dcache_line_size))); _FDT((fdt_setprop_cell(VAR_2, VAR_6, "d-cache-line-size", env->dcache_line_size))); _FDT((fdt_setprop_cell(VAR_2, VAR_6, "VAR_4-cache-block-size", env->icache_line_size))); _FDT((fdt_setprop_cell(VAR_2, VAR_6, "VAR_4-cache-line-size", env->icache_line_size))); if (pcc->l1_dcache_size) { _FDT((fdt_setprop_cell(VAR_2, VAR_6, "d-cache-size", pcc->l1_dcache_size))); } else { error_report("Warning: Unknown L1 dcache size for cpu"); } if (pcc->l1_icache_size) { _FDT((fdt_setprop_cell(VAR_2, VAR_6, "VAR_4-cache-size", pcc->l1_icache_size))); } else { error_report("Warning: Unknown L1 icache size for cpu"); } _FDT((fdt_setprop_cell(VAR_2, VAR_6, "timebase-frequency", tbfreq))); _FDT((fdt_setprop_cell(VAR_2, VAR_6, "clock-frequency", cpufreq))); _FDT((fdt_setprop_cell(VAR_2, VAR_6, "ibm,slb-size", env->slb_nr))); _FDT((fdt_setprop_string(VAR_2, VAR_6, "status", "okay"))); _FDT((fdt_setprop(VAR_2, VAR_6, "64-bit", NULL, 0))); if (env->spr_cb[SPR_PURR].oea_read) { _FDT((fdt_setprop(VAR_2, VAR_6, "ibm,purr", NULL, 0))); } if (env->mmu_model & POWERPC_MMU_1TSEG) { _FDT((fdt_setprop(VAR_2, VAR_6, "ibm,processor-segment-sizes", segs, sizeof(segs)))); } if (env->insns_flags & PPC_ALTIVEC) { uint32_t vmx = (env->insns_flags2 & PPC2_VSX) ? 2 : 1; _FDT((fdt_setprop_cell(VAR_2, VAR_6, "ibm,vmx", vmx))); } if (env->insns_flags2 & PPC2_DFP) { _FDT((fdt_setprop_cell(VAR_2, VAR_6, "ibm,dfp", 1))); } page_sizes_prop_size = ppc_create_page_sizes_prop(env, page_sizes_prop, sizeof(page_sizes_prop)); if (page_sizes_prop_size) { _FDT((fdt_setprop(VAR_2, VAR_6, "ibm,segment-page-sizes", page_sizes_prop, page_sizes_prop_size))); } _FDT((fdt_setprop(VAR_2, VAR_6, "ibm,pa-features", VAR_5, sizeof(VAR_5)))); for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) { servers_prop[VAR_4] = cpu_to_be32(VAR_1->pir + VAR_4); } _FDT((fdt_setprop(VAR_2, VAR_6, "ibm,ppc-interrupt-server#s", servers_prop, sizeof(servers_prop)))); }
[ "static void FUNC_0(PnvChip *VAR_0, PnvCore *VAR_1, void *VAR_2)\n{", "CPUState *cs = CPU(DEVICE(VAR_1->threads));", "DeviceClass *dc = DEVICE_GET_CLASS(cs);", "PowerPCCPU *cpu = POWERPC_CPU(cs);", "int VAR_3 = CPU_CORE(VAR_1)->nr_threads;", "CPUPPCState *env = &cpu->env;", "PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs);", "uint32_t servers_prop[VAR_3];", "int VAR_4;", "uint32_t segs[] = {cpu_to_be32(28), cpu_to_be32(40),", "0xffffffff, 0xffffffff};", "uint32_t tbfreq = PNV_TIMEBASE_FREQ;", "uint32_t cpufreq = 1000000000;", "uint32_t page_sizes_prop[64];", "size_t page_sizes_prop_size;", "const uint8_t VAR_5[] = { 24, 0,", "0xf6, 0x3f, 0xc7, 0xc0, 0x80, 0xf0,\n0x80, 0x00, 0x00, 0x00, 0x00, 0x00,\n0x00, 0x00, 0x00, 0x00, 0x80, 0x00,\n0x80, 0x00, 0x80, 0x00, 0x80, 0x00 };", "int VAR_6;", "char *VAR_7;", "int VAR_8 = get_cpus_node(VAR_2);", "VAR_7 = g_strdup_printf(\"%s@%x\", dc->fw_name, VAR_1->pir);", "VAR_6 = fdt_add_subnode(VAR_2, VAR_8, VAR_7);", "_FDT(VAR_6);", "g_free(VAR_7);", "_FDT((fdt_setprop_cell(VAR_2, VAR_6, \"ibm,VAR_0-id\", VAR_0->chip_id)));", "_FDT((fdt_setprop_cell(VAR_2, VAR_6, \"reg\", VAR_1->pir)));", "_FDT((fdt_setprop_cell(VAR_2, VAR_6, \"ibm,pir\", VAR_1->pir)));", "_FDT((fdt_setprop_string(VAR_2, VAR_6, \"device_type\", \"cpu\")));", "_FDT((fdt_setprop_cell(VAR_2, VAR_6, \"cpu-version\", env->spr[SPR_PVR])));", "_FDT((fdt_setprop_cell(VAR_2, VAR_6, \"d-cache-block-size\",\nenv->dcache_line_size)));", "_FDT((fdt_setprop_cell(VAR_2, VAR_6, \"d-cache-line-size\",\nenv->dcache_line_size)));", "_FDT((fdt_setprop_cell(VAR_2, VAR_6, \"VAR_4-cache-block-size\",\nenv->icache_line_size)));", "_FDT((fdt_setprop_cell(VAR_2, VAR_6, \"VAR_4-cache-line-size\",\nenv->icache_line_size)));", "if (pcc->l1_dcache_size) {", "_FDT((fdt_setprop_cell(VAR_2, VAR_6, \"d-cache-size\",\npcc->l1_dcache_size)));", "} else {", "error_report(\"Warning: Unknown L1 dcache size for cpu\");", "}", "if (pcc->l1_icache_size) {", "_FDT((fdt_setprop_cell(VAR_2, VAR_6, \"VAR_4-cache-size\",\npcc->l1_icache_size)));", "} else {", "error_report(\"Warning: Unknown L1 icache size for cpu\");", "}", "_FDT((fdt_setprop_cell(VAR_2, VAR_6, \"timebase-frequency\", tbfreq)));", "_FDT((fdt_setprop_cell(VAR_2, VAR_6, \"clock-frequency\", cpufreq)));", "_FDT((fdt_setprop_cell(VAR_2, VAR_6, \"ibm,slb-size\", env->slb_nr)));", "_FDT((fdt_setprop_string(VAR_2, VAR_6, \"status\", \"okay\")));", "_FDT((fdt_setprop(VAR_2, VAR_6, \"64-bit\", NULL, 0)));", "if (env->spr_cb[SPR_PURR].oea_read) {", "_FDT((fdt_setprop(VAR_2, VAR_6, \"ibm,purr\", NULL, 0)));", "}", "if (env->mmu_model & POWERPC_MMU_1TSEG) {", "_FDT((fdt_setprop(VAR_2, VAR_6, \"ibm,processor-segment-sizes\",\nsegs, sizeof(segs))));", "}", "if (env->insns_flags & PPC_ALTIVEC) {", "uint32_t vmx = (env->insns_flags2 & PPC2_VSX) ? 2 : 1;", "_FDT((fdt_setprop_cell(VAR_2, VAR_6, \"ibm,vmx\", vmx)));", "}", "if (env->insns_flags2 & PPC2_DFP) {", "_FDT((fdt_setprop_cell(VAR_2, VAR_6, \"ibm,dfp\", 1)));", "}", "page_sizes_prop_size = ppc_create_page_sizes_prop(env, page_sizes_prop,\nsizeof(page_sizes_prop));", "if (page_sizes_prop_size) {", "_FDT((fdt_setprop(VAR_2, VAR_6, \"ibm,segment-page-sizes\",\npage_sizes_prop, page_sizes_prop_size)));", "}", "_FDT((fdt_setprop(VAR_2, VAR_6, \"ibm,pa-features\",\nVAR_5, sizeof(VAR_5))));", "for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) {", "servers_prop[VAR_4] = cpu_to_be32(VAR_1->pir + VAR_4);", "}", "_FDT((fdt_setprop(VAR_2, VAR_6, \"ibm,ppc-interrupt-server#s\",\nservers_prop, sizeof(servers_prop))));", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 73 ], [ 75, 77 ], [ 79, 81 ], [ 83, 85 ], [ 87, 89 ], [ 93 ], [ 95, 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107, 109 ], [ 111 ], [ 113 ], [ 115 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 131 ], [ 133 ], [ 135 ], [ 139 ], [ 141, 143 ], [ 145 ], [ 157 ], [ 159 ], [ 163 ], [ 165 ], [ 175 ], [ 177 ], [ 179 ], [ 183, 185 ], [ 187 ], [ 189, 191 ], [ 193 ], [ 197, 199 ], [ 205 ], [ 207 ], [ 209 ], [ 211, 213 ], [ 215 ] ]
8,848
static void test_bh_flush(void) { BHTestData data = { .n = 0 }; data.bh = aio_bh_new(ctx, bh_test_cb, &data); qemu_bh_schedule(data.bh); g_assert_cmpint(data.n, ==, 0); wait_for_aio(); g_assert_cmpint(data.n, ==, 1); g_assert(!aio_poll(ctx, false)); g_assert_cmpint(data.n, ==, 1); qemu_bh_delete(data.bh); }
false
qemu
acfb23ad3dd8d0ab385a10e483776ba7dcf927ad
static void test_bh_flush(void) { BHTestData data = { .n = 0 }; data.bh = aio_bh_new(ctx, bh_test_cb, &data); qemu_bh_schedule(data.bh); g_assert_cmpint(data.n, ==, 0); wait_for_aio(); g_assert_cmpint(data.n, ==, 1); g_assert(!aio_poll(ctx, false)); g_assert_cmpint(data.n, ==, 1); qemu_bh_delete(data.bh); }
{ "code": [], "line_no": [] }
static void FUNC_0(void) { BHTestData data = { .n = 0 }; data.bh = aio_bh_new(ctx, bh_test_cb, &data); qemu_bh_schedule(data.bh); g_assert_cmpint(data.n, ==, 0); wait_for_aio(); g_assert_cmpint(data.n, ==, 1); g_assert(!aio_poll(ctx, false)); g_assert_cmpint(data.n, ==, 1); qemu_bh_delete(data.bh); }
[ "static void FUNC_0(void)\n{", "BHTestData data = { .n = 0 };", "data.bh = aio_bh_new(ctx, bh_test_cb, &data);", "qemu_bh_schedule(data.bh);", "g_assert_cmpint(data.n, ==, 0);", "wait_for_aio();", "g_assert_cmpint(data.n, ==, 1);", "g_assert(!aio_poll(ctx, false));", "g_assert_cmpint(data.n, ==, 1);", "qemu_bh_delete(data.bh);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ] ]
8,849
static int spapr_tce_table_realize(DeviceState *dev) { sPAPRTCETable *tcet = SPAPR_TCE_TABLE(dev); if (kvm_enabled()) { tcet->table = kvmppc_create_spapr_tce(tcet->liobn, tcet->window_size, &tcet->fd); } if (!tcet->table) { size_t table_size = (tcet->window_size >> SPAPR_TCE_PAGE_SHIFT) * sizeof(uint64_t); tcet->table = g_malloc0(table_size); } tcet->nb_table = tcet->window_size >> SPAPR_TCE_PAGE_SHIFT; trace_spapr_iommu_new_table(tcet->liobn, tcet, tcet->table, tcet->fd); memory_region_init_iommu(&tcet->iommu, OBJECT(dev), &spapr_iommu_ops, "iommu-spapr", UINT64_MAX); QLIST_INSERT_HEAD(&spapr_tce_tables, tcet, list); vmstate_register(DEVICE(tcet), tcet->liobn, &vmstate_spapr_tce_table, tcet); return 0; }
false
qemu
cca7fad5765251fece44cd230156a101867522dd
static int spapr_tce_table_realize(DeviceState *dev) { sPAPRTCETable *tcet = SPAPR_TCE_TABLE(dev); if (kvm_enabled()) { tcet->table = kvmppc_create_spapr_tce(tcet->liobn, tcet->window_size, &tcet->fd); } if (!tcet->table) { size_t table_size = (tcet->window_size >> SPAPR_TCE_PAGE_SHIFT) * sizeof(uint64_t); tcet->table = g_malloc0(table_size); } tcet->nb_table = tcet->window_size >> SPAPR_TCE_PAGE_SHIFT; trace_spapr_iommu_new_table(tcet->liobn, tcet, tcet->table, tcet->fd); memory_region_init_iommu(&tcet->iommu, OBJECT(dev), &spapr_iommu_ops, "iommu-spapr", UINT64_MAX); QLIST_INSERT_HEAD(&spapr_tce_tables, tcet, list); vmstate_register(DEVICE(tcet), tcet->liobn, &vmstate_spapr_tce_table, tcet); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(DeviceState *VAR_0) { sPAPRTCETable *tcet = SPAPR_TCE_TABLE(VAR_0); if (kvm_enabled()) { tcet->table = kvmppc_create_spapr_tce(tcet->liobn, tcet->window_size, &tcet->fd); } if (!tcet->table) { size_t table_size = (tcet->window_size >> SPAPR_TCE_PAGE_SHIFT) * sizeof(uint64_t); tcet->table = g_malloc0(table_size); } tcet->nb_table = tcet->window_size >> SPAPR_TCE_PAGE_SHIFT; trace_spapr_iommu_new_table(tcet->liobn, tcet, tcet->table, tcet->fd); memory_region_init_iommu(&tcet->iommu, OBJECT(VAR_0), &spapr_iommu_ops, "iommu-spapr", UINT64_MAX); QLIST_INSERT_HEAD(&spapr_tce_tables, tcet, list); vmstate_register(DEVICE(tcet), tcet->liobn, &vmstate_spapr_tce_table, tcet); return 0; }
[ "static int FUNC_0(DeviceState *VAR_0)\n{", "sPAPRTCETable *tcet = SPAPR_TCE_TABLE(VAR_0);", "if (kvm_enabled()) {", "tcet->table = kvmppc_create_spapr_tce(tcet->liobn,\ntcet->window_size,\n&tcet->fd);", "}", "if (!tcet->table) {", "size_t table_size = (tcet->window_size >> SPAPR_TCE_PAGE_SHIFT)\n* sizeof(uint64_t);", "tcet->table = g_malloc0(table_size);", "}", "tcet->nb_table = tcet->window_size >> SPAPR_TCE_PAGE_SHIFT;", "trace_spapr_iommu_new_table(tcet->liobn, tcet, tcet->table, tcet->fd);", "memory_region_init_iommu(&tcet->iommu, OBJECT(VAR_0), &spapr_iommu_ops,\n\"iommu-spapr\", UINT64_MAX);", "QLIST_INSERT_HEAD(&spapr_tce_tables, tcet, list);", "vmstate_register(DEVICE(tcet), tcet->liobn, &vmstate_spapr_tce_table,\ntcet);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11, 13, 15 ], [ 17 ], [ 21 ], [ 23, 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 39, 41 ], [ 45 ], [ 49, 51 ], [ 55 ], [ 57 ] ]
8,850
static int avi_write_header(AVFormatContext *s) { AVIContext *avi = s->priv_data; AVIOContext *pb = s->pb; int bitrate, n, i, nb_frames, au_byterate, au_ssize, au_scale; AVCodecContext *stream, *video_enc; int64_t list1, list2, strh, strf; AVDictionaryEntry *t = NULL; if (s->nb_streams > AVI_MAX_STREAM_COUNT) { av_log(s, AV_LOG_ERROR, "AVI does not support >%d streams\n", AVI_MAX_STREAM_COUNT); return -1; } for (n = 0; n < s->nb_streams; n++) { s->streams[n]->priv_data = av_mallocz(sizeof(AVIStream)); if (!s->streams[n]->priv_data) return AVERROR(ENOMEM); } /* header list */ avi->riff_id = 0; list1 = avi_start_new_riff(s, pb, "AVI ", "hdrl"); /* avi header */ ffio_wfourcc(pb, "avih"); avio_wl32(pb, 14 * 4); bitrate = 0; video_enc = NULL; for (n = 0; n < s->nb_streams; n++) { stream = s->streams[n]->codec; bitrate += stream->bit_rate; if (stream->codec_type == AVMEDIA_TYPE_VIDEO) video_enc = stream; } nb_frames = 0; if (video_enc) avio_wl32(pb, (uint32_t) (INT64_C(1000000) * video_enc->time_base.num / video_enc->time_base.den)); else avio_wl32(pb, 0); avio_wl32(pb, bitrate / 8); /* XXX: not quite exact */ avio_wl32(pb, 0); /* padding */ if (!pb->seekable) avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_ISINTERLEAVED); /* flags */ else avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_HASINDEX | AVIF_ISINTERLEAVED); /* flags */ avi->frames_hdr_all = avio_tell(pb); /* remember this offset to fill later */ avio_wl32(pb, nb_frames); /* nb frames, filled later */ avio_wl32(pb, 0); /* initial frame */ avio_wl32(pb, s->nb_streams); /* nb streams */ avio_wl32(pb, 1024 * 1024); /* suggested buffer size */ if (video_enc) { avio_wl32(pb, video_enc->width); avio_wl32(pb, video_enc->height); } else { avio_wl32(pb, 0); avio_wl32(pb, 0); } avio_wl32(pb, 0); /* reserved */ avio_wl32(pb, 0); /* reserved */ avio_wl32(pb, 0); /* reserved */ avio_wl32(pb, 0); /* reserved */ /* stream list */ for (i = 0; i < n; i++) { AVIStream *avist = s->streams[i]->priv_data; list2 = ff_start_tag(pb, "LIST"); ffio_wfourcc(pb, "strl"); stream = s->streams[i]->codec; /* stream generic header */ strh = ff_start_tag(pb, "strh"); switch (stream->codec_type) { case AVMEDIA_TYPE_SUBTITLE: // XSUB subtitles behave like video tracks, other subtitles // are not (yet) supported. if (stream->codec_id != AV_CODEC_ID_XSUB) { av_log(s, AV_LOG_ERROR, "Subtitle streams other than DivX XSUB are not supported by the AVI muxer.\n"); return AVERROR_PATCHWELCOME; } case AVMEDIA_TYPE_VIDEO: ffio_wfourcc(pb, "vids"); break; case AVMEDIA_TYPE_AUDIO: ffio_wfourcc(pb, "auds"); break; // case AVMEDIA_TYPE_TEXT: // ffio_wfourcc(pb, "txts"); // break; case AVMEDIA_TYPE_DATA: ffio_wfourcc(pb, "dats"); break; } if (stream->codec_type == AVMEDIA_TYPE_VIDEO || stream->codec_id == AV_CODEC_ID_XSUB) avio_wl32(pb, stream->codec_tag); else avio_wl32(pb, 1); avio_wl32(pb, 0); /* flags */ avio_wl16(pb, 0); /* priority */ avio_wl16(pb, 0); /* language */ avio_wl32(pb, 0); /* initial frame */ ff_parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale); avio_wl32(pb, au_scale); /* scale */ avio_wl32(pb, au_byterate); /* rate */ avpriv_set_pts_info(s->streams[i], 64, au_scale, au_byterate); avio_wl32(pb, 0); /* start */ /* remember this offset to fill later */ avist->frames_hdr_strm = avio_tell(pb); if (!pb->seekable) /* FIXME: this may be broken, but who cares */ avio_wl32(pb, AVI_MAX_RIFF_SIZE); else avio_wl32(pb, 0); /* length, XXX: filled later */ /* suggested buffer size */ //FIXME set at the end to largest chunk if (stream->codec_type == AVMEDIA_TYPE_VIDEO) avio_wl32(pb, 1024 * 1024); else if (stream->codec_type == AVMEDIA_TYPE_AUDIO) avio_wl32(pb, 12 * 1024); else avio_wl32(pb, 0); avio_wl32(pb, -1); /* quality */ avio_wl32(pb, au_ssize); /* sample size */ avio_wl32(pb, 0); avio_wl16(pb, stream->width); avio_wl16(pb, stream->height); ff_end_tag(pb, strh); if (stream->codec_type != AVMEDIA_TYPE_DATA) { strf = ff_start_tag(pb, "strf"); switch (stream->codec_type) { case AVMEDIA_TYPE_SUBTITLE: /* XSUB subtitles behave like video tracks, other subtitles * are not (yet) supported. */ if (stream->codec_id != AV_CODEC_ID_XSUB) break; case AVMEDIA_TYPE_VIDEO: ff_put_bmp_header(pb, stream, ff_codec_bmp_tags, 0); break; case AVMEDIA_TYPE_AUDIO: if (ff_put_wav_header(pb, stream) < 0) return -1; break; default: return -1; } ff_end_tag(pb, strf); if ((t = av_dict_get(s->streams[i]->metadata, "title", NULL, 0))) { ff_riff_write_info_tag(s->pb, "strn", t->value); t = NULL; } } if (pb->seekable) { unsigned char tag[5]; int j; /* Starting to lay out AVI OpenDML master index. * We want to make it JUNK entry for now, since we'd * like to get away without making AVI an OpenDML one * for compatibility reasons. */ avist->indexes.entry = avist->indexes.ents_allocated = 0; avist->indexes.indx_start = ff_start_tag(pb, "JUNK"); avio_wl16(pb, 4); /* wLongsPerEntry */ avio_w8(pb, 0); /* bIndexSubType (0 == frame index) */ avio_w8(pb, 0); /* bIndexType (0 == AVI_INDEX_OF_INDEXES) */ avio_wl32(pb, 0); /* nEntriesInUse (will fill out later on) */ ffio_wfourcc(pb, avi_stream2fourcc(tag, i, stream->codec_type)); /* dwChunkId */ avio_wl64(pb, 0); /* dwReserved[3] */ // avio_wl32(pb, 0); /* Must be 0. */ for (j = 0; j < AVI_MASTER_INDEX_SIZE * 2; j++) avio_wl64(pb, 0); ff_end_tag(pb, avist->indexes.indx_start); } if (stream->codec_type == AVMEDIA_TYPE_VIDEO && s->streams[i]->sample_aspect_ratio.num > 0 && s->streams[i]->sample_aspect_ratio.den > 0) { int vprp = ff_start_tag(pb, "vprp"); AVRational dar = av_mul_q(s->streams[i]->sample_aspect_ratio, (AVRational) { stream->width, stream->height }); int num, den; av_reduce(&num, &den, dar.num, dar.den, 0xFFFF); avio_wl32(pb, 0); // video format = unknown avio_wl32(pb, 0); // video standard = unknown avio_wl32(pb, lrintf(1.0 / av_q2d(stream->time_base))); avio_wl32(pb, stream->width); avio_wl32(pb, stream->height); avio_wl16(pb, den); avio_wl16(pb, num); avio_wl32(pb, stream->width); avio_wl32(pb, stream->height); avio_wl32(pb, 1); // progressive FIXME avio_wl32(pb, stream->height); avio_wl32(pb, stream->width); avio_wl32(pb, stream->height); avio_wl32(pb, stream->width); avio_wl32(pb, 0); avio_wl32(pb, 0); avio_wl32(pb, 0); avio_wl32(pb, 0); ff_end_tag(pb, vprp); } ff_end_tag(pb, list2); } if (pb->seekable) { /* AVI could become an OpenDML one, if it grows beyond 2Gb range */ avi->odml_list = ff_start_tag(pb, "JUNK"); ffio_wfourcc(pb, "odml"); ffio_wfourcc(pb, "dmlh"); avio_wl32(pb, 248); for (i = 0; i < 248; i += 4) avio_wl32(pb, 0); ff_end_tag(pb, avi->odml_list); } ff_end_tag(pb, list1); ff_riff_write_info(s); /* some padding for easier tag editing */ list2 = ff_start_tag(pb, "JUNK"); for (i = 0; i < 1016; i += 4) avio_wl32(pb, 0); ff_end_tag(pb, list2); avi->movi_list = ff_start_tag(pb, "LIST"); ffio_wfourcc(pb, "movi"); avio_flush(pb); return 0; }
false
FFmpeg
c3311d472a7528c67f76d0d061704ae70a99b32e
static int avi_write_header(AVFormatContext *s) { AVIContext *avi = s->priv_data; AVIOContext *pb = s->pb; int bitrate, n, i, nb_frames, au_byterate, au_ssize, au_scale; AVCodecContext *stream, *video_enc; int64_t list1, list2, strh, strf; AVDictionaryEntry *t = NULL; if (s->nb_streams > AVI_MAX_STREAM_COUNT) { av_log(s, AV_LOG_ERROR, "AVI does not support >%d streams\n", AVI_MAX_STREAM_COUNT); return -1; } for (n = 0; n < s->nb_streams; n++) { s->streams[n]->priv_data = av_mallocz(sizeof(AVIStream)); if (!s->streams[n]->priv_data) return AVERROR(ENOMEM); } avi->riff_id = 0; list1 = avi_start_new_riff(s, pb, "AVI ", "hdrl"); ffio_wfourcc(pb, "avih"); avio_wl32(pb, 14 * 4); bitrate = 0; video_enc = NULL; for (n = 0; n < s->nb_streams; n++) { stream = s->streams[n]->codec; bitrate += stream->bit_rate; if (stream->codec_type == AVMEDIA_TYPE_VIDEO) video_enc = stream; } nb_frames = 0; if (video_enc) avio_wl32(pb, (uint32_t) (INT64_C(1000000) * video_enc->time_base.num / video_enc->time_base.den)); else avio_wl32(pb, 0); avio_wl32(pb, bitrate / 8); avio_wl32(pb, 0); if (!pb->seekable) avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_ISINTERLEAVED); else avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_HASINDEX | AVIF_ISINTERLEAVED); avi->frames_hdr_all = avio_tell(pb); avio_wl32(pb, nb_frames); avio_wl32(pb, 0); avio_wl32(pb, s->nb_streams); avio_wl32(pb, 1024 * 1024); if (video_enc) { avio_wl32(pb, video_enc->width); avio_wl32(pb, video_enc->height); } else { avio_wl32(pb, 0); avio_wl32(pb, 0); } avio_wl32(pb, 0); avio_wl32(pb, 0); avio_wl32(pb, 0); avio_wl32(pb, 0); for (i = 0; i < n; i++) { AVIStream *avist = s->streams[i]->priv_data; list2 = ff_start_tag(pb, "LIST"); ffio_wfourcc(pb, "strl"); stream = s->streams[i]->codec; strh = ff_start_tag(pb, "strh"); switch (stream->codec_type) { case AVMEDIA_TYPE_SUBTITLE: if (stream->codec_id != AV_CODEC_ID_XSUB) { av_log(s, AV_LOG_ERROR, "Subtitle streams other than DivX XSUB are not supported by the AVI muxer.\n"); return AVERROR_PATCHWELCOME; } case AVMEDIA_TYPE_VIDEO: ffio_wfourcc(pb, "vids"); break; case AVMEDIA_TYPE_AUDIO: ffio_wfourcc(pb, "auds"); break; case AVMEDIA_TYPE_DATA: ffio_wfourcc(pb, "dats"); break; } if (stream->codec_type == AVMEDIA_TYPE_VIDEO || stream->codec_id == AV_CODEC_ID_XSUB) avio_wl32(pb, stream->codec_tag); else avio_wl32(pb, 1); avio_wl32(pb, 0); avio_wl16(pb, 0); avio_wl16(pb, 0); avio_wl32(pb, 0); ff_parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale); avio_wl32(pb, au_scale); avio_wl32(pb, au_byterate); avpriv_set_pts_info(s->streams[i], 64, au_scale, au_byterate); avio_wl32(pb, 0); avist->frames_hdr_strm = avio_tell(pb); if (!pb->seekable) avio_wl32(pb, AVI_MAX_RIFF_SIZE); else avio_wl32(pb, 0); if (stream->codec_type == AVMEDIA_TYPE_VIDEO) avio_wl32(pb, 1024 * 1024); else if (stream->codec_type == AVMEDIA_TYPE_AUDIO) avio_wl32(pb, 12 * 1024); else avio_wl32(pb, 0); avio_wl32(pb, -1); avio_wl32(pb, au_ssize); avio_wl32(pb, 0); avio_wl16(pb, stream->width); avio_wl16(pb, stream->height); ff_end_tag(pb, strh); if (stream->codec_type != AVMEDIA_TYPE_DATA) { strf = ff_start_tag(pb, "strf"); switch (stream->codec_type) { case AVMEDIA_TYPE_SUBTITLE: if (stream->codec_id != AV_CODEC_ID_XSUB) break; case AVMEDIA_TYPE_VIDEO: ff_put_bmp_header(pb, stream, ff_codec_bmp_tags, 0); break; case AVMEDIA_TYPE_AUDIO: if (ff_put_wav_header(pb, stream) < 0) return -1; break; default: return -1; } ff_end_tag(pb, strf); if ((t = av_dict_get(s->streams[i]->metadata, "title", NULL, 0))) { ff_riff_write_info_tag(s->pb, "strn", t->value); t = NULL; } } if (pb->seekable) { unsigned char tag[5]; int j; avist->indexes.entry = avist->indexes.ents_allocated = 0; avist->indexes.indx_start = ff_start_tag(pb, "JUNK"); avio_wl16(pb, 4); avio_w8(pb, 0); avio_w8(pb, 0); avio_wl32(pb, 0); ffio_wfourcc(pb, avi_stream2fourcc(tag, i, stream->codec_type)); avio_wl64(pb, 0); for (j = 0; j < AVI_MASTER_INDEX_SIZE * 2; j++) avio_wl64(pb, 0); ff_end_tag(pb, avist->indexes.indx_start); } if (stream->codec_type == AVMEDIA_TYPE_VIDEO && s->streams[i]->sample_aspect_ratio.num > 0 && s->streams[i]->sample_aspect_ratio.den > 0) { int vprp = ff_start_tag(pb, "vprp"); AVRational dar = av_mul_q(s->streams[i]->sample_aspect_ratio, (AVRational) { stream->width, stream->height }); int num, den; av_reduce(&num, &den, dar.num, dar.den, 0xFFFF); avio_wl32(pb, 0); avio_wl32(pb, 0); avio_wl32(pb, lrintf(1.0 / av_q2d(stream->time_base))); avio_wl32(pb, stream->width); avio_wl32(pb, stream->height); avio_wl16(pb, den); avio_wl16(pb, num); avio_wl32(pb, stream->width); avio_wl32(pb, stream->height); avio_wl32(pb, 1); avio_wl32(pb, stream->height); avio_wl32(pb, stream->width); avio_wl32(pb, stream->height); avio_wl32(pb, stream->width); avio_wl32(pb, 0); avio_wl32(pb, 0); avio_wl32(pb, 0); avio_wl32(pb, 0); ff_end_tag(pb, vprp); } ff_end_tag(pb, list2); } if (pb->seekable) { avi->odml_list = ff_start_tag(pb, "JUNK"); ffio_wfourcc(pb, "odml"); ffio_wfourcc(pb, "dmlh"); avio_wl32(pb, 248); for (i = 0; i < 248; i += 4) avio_wl32(pb, 0); ff_end_tag(pb, avi->odml_list); } ff_end_tag(pb, list1); ff_riff_write_info(s); list2 = ff_start_tag(pb, "JUNK"); for (i = 0; i < 1016; i += 4) avio_wl32(pb, 0); ff_end_tag(pb, list2); avi->movi_list = ff_start_tag(pb, "LIST"); ffio_wfourcc(pb, "movi"); avio_flush(pb); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0) { AVIContext *avi = VAR_0->priv_data; AVIOContext *pb = VAR_0->pb; int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7; AVCodecContext *stream, *video_enc; int64_t list1, list2, strh, strf; AVDictionaryEntry *t = NULL; if (VAR_0->nb_streams > AVI_MAX_STREAM_COUNT) { av_log(VAR_0, AV_LOG_ERROR, "AVI does not support >%d streams\VAR_2", AVI_MAX_STREAM_COUNT); return -1; } for (VAR_2 = 0; VAR_2 < VAR_0->nb_streams; VAR_2++) { VAR_0->streams[VAR_2]->priv_data = av_mallocz(sizeof(AVIStream)); if (!VAR_0->streams[VAR_2]->priv_data) return AVERROR(ENOMEM); } avi->riff_id = 0; list1 = avi_start_new_riff(VAR_0, pb, "AVI ", "hdrl"); ffio_wfourcc(pb, "avih"); avio_wl32(pb, 14 * 4); VAR_1 = 0; video_enc = NULL; for (VAR_2 = 0; VAR_2 < VAR_0->nb_streams; VAR_2++) { stream = VAR_0->streams[VAR_2]->codec; VAR_1 += stream->bit_rate; if (stream->codec_type == AVMEDIA_TYPE_VIDEO) video_enc = stream; } VAR_4 = 0; if (video_enc) avio_wl32(pb, (uint32_t) (INT64_C(1000000) * video_enc->time_base.VAR_11 / video_enc->time_base.VAR_12)); else avio_wl32(pb, 0); avio_wl32(pb, VAR_1 / 8); avio_wl32(pb, 0); if (!pb->seekable) avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_ISINTERLEAVED); else avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_HASINDEX | AVIF_ISINTERLEAVED); avi->frames_hdr_all = avio_tell(pb); avio_wl32(pb, VAR_4); avio_wl32(pb, 0); avio_wl32(pb, VAR_0->nb_streams); avio_wl32(pb, 1024 * 1024); if (video_enc) { avio_wl32(pb, video_enc->width); avio_wl32(pb, video_enc->height); } else { avio_wl32(pb, 0); avio_wl32(pb, 0); } avio_wl32(pb, 0); avio_wl32(pb, 0); avio_wl32(pb, 0); avio_wl32(pb, 0); for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) { AVIStream *avist = VAR_0->streams[VAR_3]->priv_data; list2 = ff_start_tag(pb, "LIST"); ffio_wfourcc(pb, "strl"); stream = VAR_0->streams[VAR_3]->codec; strh = ff_start_tag(pb, "strh"); switch (stream->codec_type) { case AVMEDIA_TYPE_SUBTITLE: if (stream->codec_id != AV_CODEC_ID_XSUB) { av_log(VAR_0, AV_LOG_ERROR, "Subtitle streams other than DivX XSUB are not supported by the AVI muxer.\VAR_2"); return AVERROR_PATCHWELCOME; } case AVMEDIA_TYPE_VIDEO: ffio_wfourcc(pb, "vids"); break; case AVMEDIA_TYPE_AUDIO: ffio_wfourcc(pb, "auds"); break; case AVMEDIA_TYPE_DATA: ffio_wfourcc(pb, "dats"); break; } if (stream->codec_type == AVMEDIA_TYPE_VIDEO || stream->codec_id == AV_CODEC_ID_XSUB) avio_wl32(pb, stream->codec_tag); else avio_wl32(pb, 1); avio_wl32(pb, 0); avio_wl16(pb, 0); avio_wl16(pb, 0); avio_wl32(pb, 0); ff_parse_specific_params(stream, &VAR_5, &VAR_6, &VAR_7); avio_wl32(pb, VAR_7); avio_wl32(pb, VAR_5); avpriv_set_pts_info(VAR_0->streams[VAR_3], 64, VAR_7, VAR_5); avio_wl32(pb, 0); avist->frames_hdr_strm = avio_tell(pb); if (!pb->seekable) avio_wl32(pb, AVI_MAX_RIFF_SIZE); else avio_wl32(pb, 0); if (stream->codec_type == AVMEDIA_TYPE_VIDEO) avio_wl32(pb, 1024 * 1024); else if (stream->codec_type == AVMEDIA_TYPE_AUDIO) avio_wl32(pb, 12 * 1024); else avio_wl32(pb, 0); avio_wl32(pb, -1); avio_wl32(pb, VAR_6); avio_wl32(pb, 0); avio_wl16(pb, stream->width); avio_wl16(pb, stream->height); ff_end_tag(pb, strh); if (stream->codec_type != AVMEDIA_TYPE_DATA) { strf = ff_start_tag(pb, "strf"); switch (stream->codec_type) { case AVMEDIA_TYPE_SUBTITLE: if (stream->codec_id != AV_CODEC_ID_XSUB) break; case AVMEDIA_TYPE_VIDEO: ff_put_bmp_header(pb, stream, ff_codec_bmp_tags, 0); break; case AVMEDIA_TYPE_AUDIO: if (ff_put_wav_header(pb, stream) < 0) return -1; break; default: return -1; } ff_end_tag(pb, strf); if ((t = av_dict_get(VAR_0->streams[VAR_3]->metadata, "title", NULL, 0))) { ff_riff_write_info_tag(VAR_0->pb, "strn", t->value); t = NULL; } } if (pb->seekable) { unsigned char VAR_8[5]; int VAR_9; avist->indexes.entry = avist->indexes.ents_allocated = 0; avist->indexes.indx_start = ff_start_tag(pb, "JUNK"); avio_wl16(pb, 4); avio_w8(pb, 0); avio_w8(pb, 0); avio_wl32(pb, 0); ffio_wfourcc(pb, avi_stream2fourcc(VAR_8, VAR_3, stream->codec_type)); avio_wl64(pb, 0); for (VAR_9 = 0; VAR_9 < AVI_MASTER_INDEX_SIZE * 2; VAR_9++) avio_wl64(pb, 0); ff_end_tag(pb, avist->indexes.indx_start); } if (stream->codec_type == AVMEDIA_TYPE_VIDEO && VAR_0->streams[VAR_3]->sample_aspect_ratio.VAR_11 > 0 && VAR_0->streams[VAR_3]->sample_aspect_ratio.VAR_12 > 0) { int VAR_10 = ff_start_tag(pb, "VAR_10"); AVRational dar = av_mul_q(VAR_0->streams[VAR_3]->sample_aspect_ratio, (AVRational) { stream->width, stream->height }); int VAR_11, VAR_12; av_reduce(&VAR_11, &VAR_12, dar.VAR_11, dar.VAR_12, 0xFFFF); avio_wl32(pb, 0); avio_wl32(pb, 0); avio_wl32(pb, lrintf(1.0 / av_q2d(stream->time_base))); avio_wl32(pb, stream->width); avio_wl32(pb, stream->height); avio_wl16(pb, VAR_12); avio_wl16(pb, VAR_11); avio_wl32(pb, stream->width); avio_wl32(pb, stream->height); avio_wl32(pb, 1); avio_wl32(pb, stream->height); avio_wl32(pb, stream->width); avio_wl32(pb, stream->height); avio_wl32(pb, stream->width); avio_wl32(pb, 0); avio_wl32(pb, 0); avio_wl32(pb, 0); avio_wl32(pb, 0); ff_end_tag(pb, VAR_10); } ff_end_tag(pb, list2); } if (pb->seekable) { avi->odml_list = ff_start_tag(pb, "JUNK"); ffio_wfourcc(pb, "odml"); ffio_wfourcc(pb, "dmlh"); avio_wl32(pb, 248); for (VAR_3 = 0; VAR_3 < 248; VAR_3 += 4) avio_wl32(pb, 0); ff_end_tag(pb, avi->odml_list); } ff_end_tag(pb, list1); ff_riff_write_info(VAR_0); list2 = ff_start_tag(pb, "JUNK"); for (VAR_3 = 0; VAR_3 < 1016; VAR_3 += 4) avio_wl32(pb, 0); ff_end_tag(pb, list2); avi->movi_list = ff_start_tag(pb, "LIST"); ffio_wfourcc(pb, "movi"); avio_flush(pb); return 0; }
[ "static int FUNC_0(AVFormatContext *VAR_0)\n{", "AVIContext *avi = VAR_0->priv_data;", "AVIOContext *pb = VAR_0->pb;", "int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;", "AVCodecContext *stream, *video_enc;", "int64_t list1, list2, strh, strf;", "AVDictionaryEntry *t = NULL;", "if (VAR_0->nb_streams > AVI_MAX_STREAM_COUNT) {", "av_log(VAR_0, AV_LOG_ERROR, \"AVI does not support >%d streams\\VAR_2\",\nAVI_MAX_STREAM_COUNT);", "return -1;", "}", "for (VAR_2 = 0; VAR_2 < VAR_0->nb_streams; VAR_2++) {", "VAR_0->streams[VAR_2]->priv_data = av_mallocz(sizeof(AVIStream));", "if (!VAR_0->streams[VAR_2]->priv_data)\nreturn AVERROR(ENOMEM);", "}", "avi->riff_id = 0;", "list1 = avi_start_new_riff(VAR_0, pb, \"AVI \", \"hdrl\");", "ffio_wfourcc(pb, \"avih\");", "avio_wl32(pb, 14 * 4);", "VAR_1 = 0;", "video_enc = NULL;", "for (VAR_2 = 0; VAR_2 < VAR_0->nb_streams; VAR_2++) {", "stream = VAR_0->streams[VAR_2]->codec;", "VAR_1 += stream->bit_rate;", "if (stream->codec_type == AVMEDIA_TYPE_VIDEO)\nvideo_enc = stream;", "}", "VAR_4 = 0;", "if (video_enc)\navio_wl32(pb, (uint32_t) (INT64_C(1000000) * video_enc->time_base.VAR_11 /\nvideo_enc->time_base.VAR_12));", "else\navio_wl32(pb, 0);", "avio_wl32(pb, VAR_1 / 8);", "avio_wl32(pb, 0);", "if (!pb->seekable)\navio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_ISINTERLEAVED);", "else\navio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_HASINDEX | AVIF_ISINTERLEAVED);", "avi->frames_hdr_all = avio_tell(pb);", "avio_wl32(pb, VAR_4);", "avio_wl32(pb, 0);", "avio_wl32(pb, VAR_0->nb_streams);", "avio_wl32(pb, 1024 * 1024);", "if (video_enc) {", "avio_wl32(pb, video_enc->width);", "avio_wl32(pb, video_enc->height);", "} else {", "avio_wl32(pb, 0);", "avio_wl32(pb, 0);", "}", "avio_wl32(pb, 0);", "avio_wl32(pb, 0);", "avio_wl32(pb, 0);", "avio_wl32(pb, 0);", "for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) {", "AVIStream *avist = VAR_0->streams[VAR_3]->priv_data;", "list2 = ff_start_tag(pb, \"LIST\");", "ffio_wfourcc(pb, \"strl\");", "stream = VAR_0->streams[VAR_3]->codec;", "strh = ff_start_tag(pb, \"strh\");", "switch (stream->codec_type) {", "case AVMEDIA_TYPE_SUBTITLE:\nif (stream->codec_id != AV_CODEC_ID_XSUB) {", "av_log(VAR_0, AV_LOG_ERROR,\n\"Subtitle streams other than DivX XSUB are not supported by the AVI muxer.\\VAR_2\");", "return AVERROR_PATCHWELCOME;", "}", "case AVMEDIA_TYPE_VIDEO:\nffio_wfourcc(pb, \"vids\");", "break;", "case AVMEDIA_TYPE_AUDIO:\nffio_wfourcc(pb, \"auds\");", "break;", "case AVMEDIA_TYPE_DATA:\nffio_wfourcc(pb, \"dats\");", "break;", "}", "if (stream->codec_type == AVMEDIA_TYPE_VIDEO ||\nstream->codec_id == AV_CODEC_ID_XSUB)\navio_wl32(pb, stream->codec_tag);", "else\navio_wl32(pb, 1);", "avio_wl32(pb, 0);", "avio_wl16(pb, 0);", "avio_wl16(pb, 0);", "avio_wl32(pb, 0);", "ff_parse_specific_params(stream, &VAR_5, &VAR_6, &VAR_7);", "avio_wl32(pb, VAR_7);", "avio_wl32(pb, VAR_5);", "avpriv_set_pts_info(VAR_0->streams[VAR_3], 64, VAR_7, VAR_5);", "avio_wl32(pb, 0);", "avist->frames_hdr_strm = avio_tell(pb);", "if (!pb->seekable)\navio_wl32(pb, AVI_MAX_RIFF_SIZE);", "else\navio_wl32(pb, 0);", "if (stream->codec_type == AVMEDIA_TYPE_VIDEO)\navio_wl32(pb, 1024 * 1024);", "else if (stream->codec_type == AVMEDIA_TYPE_AUDIO)\navio_wl32(pb, 12 * 1024);", "else\navio_wl32(pb, 0);", "avio_wl32(pb, -1);", "avio_wl32(pb, VAR_6);", "avio_wl32(pb, 0);", "avio_wl16(pb, stream->width);", "avio_wl16(pb, stream->height);", "ff_end_tag(pb, strh);", "if (stream->codec_type != AVMEDIA_TYPE_DATA) {", "strf = ff_start_tag(pb, \"strf\");", "switch (stream->codec_type) {", "case AVMEDIA_TYPE_SUBTITLE:\nif (stream->codec_id != AV_CODEC_ID_XSUB)\nbreak;", "case AVMEDIA_TYPE_VIDEO:\nff_put_bmp_header(pb, stream, ff_codec_bmp_tags, 0);", "break;", "case AVMEDIA_TYPE_AUDIO:\nif (ff_put_wav_header(pb, stream) < 0)\nreturn -1;", "break;", "default:\nreturn -1;", "}", "ff_end_tag(pb, strf);", "if ((t = av_dict_get(VAR_0->streams[VAR_3]->metadata, \"title\", NULL, 0))) {", "ff_riff_write_info_tag(VAR_0->pb, \"strn\", t->value);", "t = NULL;", "}", "}", "if (pb->seekable) {", "unsigned char VAR_8[5];", "int VAR_9;", "avist->indexes.entry = avist->indexes.ents_allocated = 0;", "avist->indexes.indx_start = ff_start_tag(pb, \"JUNK\");", "avio_wl16(pb, 4);", "avio_w8(pb, 0);", "avio_w8(pb, 0);", "avio_wl32(pb, 0);", "ffio_wfourcc(pb, avi_stream2fourcc(VAR_8, VAR_3, stream->codec_type));", "avio_wl64(pb, 0);", "for (VAR_9 = 0; VAR_9 < AVI_MASTER_INDEX_SIZE * 2; VAR_9++)", "avio_wl64(pb, 0);", "ff_end_tag(pb, avist->indexes.indx_start);", "}", "if (stream->codec_type == AVMEDIA_TYPE_VIDEO &&\nVAR_0->streams[VAR_3]->sample_aspect_ratio.VAR_11 > 0 &&\nVAR_0->streams[VAR_3]->sample_aspect_ratio.VAR_12 > 0) {", "int VAR_10 = ff_start_tag(pb, \"VAR_10\");", "AVRational dar = av_mul_q(VAR_0->streams[VAR_3]->sample_aspect_ratio,\n(AVRational) { stream->width,", "stream->height });", "int VAR_11, VAR_12;", "av_reduce(&VAR_11, &VAR_12, dar.VAR_11, dar.VAR_12, 0xFFFF);", "avio_wl32(pb, 0);", "avio_wl32(pb, 0);", "avio_wl32(pb, lrintf(1.0 / av_q2d(stream->time_base)));", "avio_wl32(pb, stream->width);", "avio_wl32(pb, stream->height);", "avio_wl16(pb, VAR_12);", "avio_wl16(pb, VAR_11);", "avio_wl32(pb, stream->width);", "avio_wl32(pb, stream->height);", "avio_wl32(pb, 1);", "avio_wl32(pb, stream->height);", "avio_wl32(pb, stream->width);", "avio_wl32(pb, stream->height);", "avio_wl32(pb, stream->width);", "avio_wl32(pb, 0);", "avio_wl32(pb, 0);", "avio_wl32(pb, 0);", "avio_wl32(pb, 0);", "ff_end_tag(pb, VAR_10);", "}", "ff_end_tag(pb, list2);", "}", "if (pb->seekable) {", "avi->odml_list = ff_start_tag(pb, \"JUNK\");", "ffio_wfourcc(pb, \"odml\");", "ffio_wfourcc(pb, \"dmlh\");", "avio_wl32(pb, 248);", "for (VAR_3 = 0; VAR_3 < 248; VAR_3 += 4)", "avio_wl32(pb, 0);", "ff_end_tag(pb, avi->odml_list);", "}", "ff_end_tag(pb, list1);", "ff_riff_write_info(VAR_0);", "list2 = ff_start_tag(pb, \"JUNK\");", "for (VAR_3 = 0; VAR_3 < 1016; VAR_3 += 4)", "avio_wl32(pb, 0);", "ff_end_tag(pb, list2);", "avi->movi_list = ff_start_tag(pb, \"LIST\");", "ffio_wfourcc(pb, \"movi\");", "avio_flush(pb);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35, 37 ], [ 39 ], [ 45 ], [ 47 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69, 71 ], [ 73 ], [ 77 ], [ 81, 83, 85 ], [ 87, 89 ], [ 91 ], [ 93 ], [ 95, 97 ], [ 99, 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 149 ], [ 155 ], [ 157 ], [ 159, 165 ], [ 167, 169 ], [ 171 ], [ 173 ], [ 175, 177 ], [ 179 ], [ 181, 183 ], [ 185 ], [ 193, 195 ], [ 197 ], [ 199 ], [ 201, 203, 205 ], [ 207, 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 221 ], [ 225 ], [ 227 ], [ 229 ], [ 233 ], [ 237 ], [ 239, 243 ], [ 245, 247 ], [ 253, 255 ], [ 257, 259 ], [ 261, 263 ], [ 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 279 ], [ 281 ], [ 283 ], [ 285, 291, 293 ], [ 295, 297 ], [ 299 ], [ 301, 303, 305 ], [ 307 ], [ 309, 311 ], [ 313 ], [ 315 ], [ 317 ], [ 319 ], [ 321 ], [ 323 ], [ 325 ], [ 329 ], [ 331 ], [ 333 ], [ 345 ], [ 347 ], [ 349 ], [ 351 ], [ 353 ], [ 355 ], [ 357 ], [ 361 ], [ 365 ], [ 367 ], [ 369 ], [ 371 ], [ 375, 377, 379 ], [ 381 ], [ 383, 385 ], [ 387 ], [ 389 ], [ 391 ], [ 395 ], [ 397 ], [ 399 ], [ 401 ], [ 403 ], [ 405 ], [ 407 ], [ 409 ], [ 411 ], [ 413 ], [ 417 ], [ 419 ], [ 421 ], [ 423 ], [ 425 ], [ 427 ], [ 431 ], [ 433 ], [ 435 ], [ 437 ], [ 441 ], [ 443 ], [ 447 ], [ 451 ], [ 453 ], [ 455 ], [ 457 ], [ 459 ], [ 461 ], [ 463 ], [ 465 ], [ 469 ], [ 473 ], [ 479 ], [ 481 ], [ 483 ], [ 485 ], [ 489 ], [ 491 ], [ 495 ], [ 499 ], [ 501 ] ]
8,851
void ide_dma_cb(void *opaque, int ret) { IDEState *s = opaque; int n; int64_t sector_num; bool stay_active = false; if (ret == -ECANCELED) { return; } if (ret < 0) { int op = IDE_RETRY_DMA; if (s->dma_cmd == IDE_DMA_READ) op |= IDE_RETRY_READ; else if (s->dma_cmd == IDE_DMA_TRIM) op |= IDE_RETRY_TRIM; if (ide_handle_rw_error(s, -ret, op)) { return; } } n = s->io_buffer_size >> 9; if (n > s->nsector) { /* The PRDs were longer than needed for this request. Shorten them so * we don't get a negative remainder. The Active bit must remain set * after the request completes. */ n = s->nsector; stay_active = true; } sector_num = ide_get_sector(s); if (n > 0) { dma_buf_commit(s); sector_num += n; ide_set_sector(s, sector_num); s->nsector -= n; } /* end of transfer ? */ if (s->nsector == 0) { s->status = READY_STAT | SEEK_STAT; ide_set_irq(s->bus); goto eot; } /* launch next transfer */ n = s->nsector; s->io_buffer_index = 0; s->io_buffer_size = n * 512; if (s->bus->dma->ops->prepare_buf(s->bus->dma, ide_cmd_is_read(s)) == 0) { /* The PRDs were too short. Reset the Active bit, but don't raise an * interrupt. */ s->status = READY_STAT | SEEK_STAT; goto eot; } #ifdef DEBUG_AIO printf("ide_dma_cb: sector_num=%" PRId64 " n=%d, cmd_cmd=%d\n", sector_num, n, s->dma_cmd); #endif if ((s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) && !ide_sect_range_ok(s, sector_num, n)) { dma_buf_commit(s); ide_dma_error(s); return; } switch (s->dma_cmd) { case IDE_DMA_READ: s->bus->dma->aiocb = dma_bdrv_read(s->bs, &s->sg, sector_num, ide_dma_cb, s); break; case IDE_DMA_WRITE: s->bus->dma->aiocb = dma_bdrv_write(s->bs, &s->sg, sector_num, ide_dma_cb, s); break; case IDE_DMA_TRIM: s->bus->dma->aiocb = dma_bdrv_io(s->bs, &s->sg, sector_num, ide_issue_trim, ide_dma_cb, s, DMA_DIRECTION_TO_DEVICE); break; } return; eot: if (s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) { block_acct_done(bdrv_get_stats(s->bs), &s->acct); } ide_set_inactive(s, stay_active); }
false
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
void ide_dma_cb(void *opaque, int ret) { IDEState *s = opaque; int n; int64_t sector_num; bool stay_active = false; if (ret == -ECANCELED) { return; } if (ret < 0) { int op = IDE_RETRY_DMA; if (s->dma_cmd == IDE_DMA_READ) op |= IDE_RETRY_READ; else if (s->dma_cmd == IDE_DMA_TRIM) op |= IDE_RETRY_TRIM; if (ide_handle_rw_error(s, -ret, op)) { return; } } n = s->io_buffer_size >> 9; if (n > s->nsector) { n = s->nsector; stay_active = true; } sector_num = ide_get_sector(s); if (n > 0) { dma_buf_commit(s); sector_num += n; ide_set_sector(s, sector_num); s->nsector -= n; } if (s->nsector == 0) { s->status = READY_STAT | SEEK_STAT; ide_set_irq(s->bus); goto eot; } n = s->nsector; s->io_buffer_index = 0; s->io_buffer_size = n * 512; if (s->bus->dma->ops->prepare_buf(s->bus->dma, ide_cmd_is_read(s)) == 0) { s->status = READY_STAT | SEEK_STAT; goto eot; } #ifdef DEBUG_AIO printf("ide_dma_cb: sector_num=%" PRId64 " n=%d, cmd_cmd=%d\n", sector_num, n, s->dma_cmd); #endif if ((s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) && !ide_sect_range_ok(s, sector_num, n)) { dma_buf_commit(s); ide_dma_error(s); return; } switch (s->dma_cmd) { case IDE_DMA_READ: s->bus->dma->aiocb = dma_bdrv_read(s->bs, &s->sg, sector_num, ide_dma_cb, s); break; case IDE_DMA_WRITE: s->bus->dma->aiocb = dma_bdrv_write(s->bs, &s->sg, sector_num, ide_dma_cb, s); break; case IDE_DMA_TRIM: s->bus->dma->aiocb = dma_bdrv_io(s->bs, &s->sg, sector_num, ide_issue_trim, ide_dma_cb, s, DMA_DIRECTION_TO_DEVICE); break; } return; eot: if (s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) { block_acct_done(bdrv_get_stats(s->bs), &s->acct); } ide_set_inactive(s, stay_active); }
{ "code": [], "line_no": [] }
void FUNC_0(void *VAR_0, int VAR_1) { IDEState *s = VAR_0; int VAR_2; int64_t sector_num; bool stay_active = false; if (VAR_1 == -ECANCELED) { return; } if (VAR_1 < 0) { int VAR_3 = IDE_RETRY_DMA; if (s->dma_cmd == IDE_DMA_READ) VAR_3 |= IDE_RETRY_READ; else if (s->dma_cmd == IDE_DMA_TRIM) VAR_3 |= IDE_RETRY_TRIM; if (ide_handle_rw_error(s, -VAR_1, VAR_3)) { return; } } VAR_2 = s->io_buffer_size >> 9; if (VAR_2 > s->nsector) { VAR_2 = s->nsector; stay_active = true; } sector_num = ide_get_sector(s); if (VAR_2 > 0) { dma_buf_commit(s); sector_num += VAR_2; ide_set_sector(s, sector_num); s->nsector -= VAR_2; } if (s->nsector == 0) { s->status = READY_STAT | SEEK_STAT; ide_set_irq(s->bus); goto eot; } VAR_2 = s->nsector; s->io_buffer_index = 0; s->io_buffer_size = VAR_2 * 512; if (s->bus->dma->ops->prepare_buf(s->bus->dma, ide_cmd_is_read(s)) == 0) { s->status = READY_STAT | SEEK_STAT; goto eot; } #ifdef DEBUG_AIO printf("FUNC_0: sector_num=%" PRId64 " VAR_2=%d, cmd_cmd=%d\VAR_2", sector_num, VAR_2, s->dma_cmd); #endif if ((s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) && !ide_sect_range_ok(s, sector_num, VAR_2)) { dma_buf_commit(s); ide_dma_error(s); return; } switch (s->dma_cmd) { case IDE_DMA_READ: s->bus->dma->aiocb = dma_bdrv_read(s->bs, &s->sg, sector_num, FUNC_0, s); break; case IDE_DMA_WRITE: s->bus->dma->aiocb = dma_bdrv_write(s->bs, &s->sg, sector_num, FUNC_0, s); break; case IDE_DMA_TRIM: s->bus->dma->aiocb = dma_bdrv_io(s->bs, &s->sg, sector_num, ide_issue_trim, FUNC_0, s, DMA_DIRECTION_TO_DEVICE); break; } return; eot: if (s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) { block_acct_done(bdrv_get_stats(s->bs), &s->acct); } ide_set_inactive(s, stay_active); }
[ "void FUNC_0(void *VAR_0, int VAR_1)\n{", "IDEState *s = VAR_0;", "int VAR_2;", "int64_t sector_num;", "bool stay_active = false;", "if (VAR_1 == -ECANCELED) {", "return;", "}", "if (VAR_1 < 0) {", "int VAR_3 = IDE_RETRY_DMA;", "if (s->dma_cmd == IDE_DMA_READ)\nVAR_3 |= IDE_RETRY_READ;", "else if (s->dma_cmd == IDE_DMA_TRIM)\nVAR_3 |= IDE_RETRY_TRIM;", "if (ide_handle_rw_error(s, -VAR_1, VAR_3)) {", "return;", "}", "}", "VAR_2 = s->io_buffer_size >> 9;", "if (VAR_2 > s->nsector) {", "VAR_2 = s->nsector;", "stay_active = true;", "}", "sector_num = ide_get_sector(s);", "if (VAR_2 > 0) {", "dma_buf_commit(s);", "sector_num += VAR_2;", "ide_set_sector(s, sector_num);", "s->nsector -= VAR_2;", "}", "if (s->nsector == 0) {", "s->status = READY_STAT | SEEK_STAT;", "ide_set_irq(s->bus);", "goto eot;", "}", "VAR_2 = s->nsector;", "s->io_buffer_index = 0;", "s->io_buffer_size = VAR_2 * 512;", "if (s->bus->dma->ops->prepare_buf(s->bus->dma, ide_cmd_is_read(s)) == 0) {", "s->status = READY_STAT | SEEK_STAT;", "goto eot;", "}", "#ifdef DEBUG_AIO\nprintf(\"FUNC_0: sector_num=%\" PRId64 \" VAR_2=%d, cmd_cmd=%d\\VAR_2\",\nsector_num, VAR_2, s->dma_cmd);", "#endif\nif ((s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) &&\n!ide_sect_range_ok(s, sector_num, VAR_2)) {", "dma_buf_commit(s);", "ide_dma_error(s);", "return;", "}", "switch (s->dma_cmd) {", "case IDE_DMA_READ:\ns->bus->dma->aiocb = dma_bdrv_read(s->bs, &s->sg, sector_num,\nFUNC_0, s);", "break;", "case IDE_DMA_WRITE:\ns->bus->dma->aiocb = dma_bdrv_write(s->bs, &s->sg, sector_num,\nFUNC_0, s);", "break;", "case IDE_DMA_TRIM:\ns->bus->dma->aiocb = dma_bdrv_io(s->bs, &s->sg, sector_num,\nide_issue_trim, FUNC_0, s,\nDMA_DIRECTION_TO_DEVICE);", "break;", "}", "return;", "eot:\nif (s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) {", "block_acct_done(bdrv_get_stats(s->bs), &s->acct);", "}", "ide_set_inactive(s, stay_active);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 27, 29 ], [ 31, 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 109 ], [ 111 ], [ 113 ], [ 117, 119, 121 ], [ 123, 127, 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 141 ], [ 143, 145, 147 ], [ 149 ], [ 151, 153, 155 ], [ 157 ], [ 159, 161, 163, 165 ], [ 167 ], [ 169 ], [ 171 ], [ 175, 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ] ]
8,852
int load_elf(const char *filename, int64_t address_offset, uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr, int big_endian, int elf_machine, int clear_lsb) { int fd, data_order, target_data_order, must_swab, ret; uint8_t e_ident[EI_NIDENT]; fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) { perror(filename); return -1; } if (read(fd, e_ident, sizeof(e_ident)) != sizeof(e_ident)) goto fail; if (e_ident[0] != ELFMAG0 || e_ident[1] != ELFMAG1 || e_ident[2] != ELFMAG2 || e_ident[3] != ELFMAG3) goto fail; #ifdef HOST_WORDS_BIGENDIAN data_order = ELFDATA2MSB; #else data_order = ELFDATA2LSB; #endif must_swab = data_order != e_ident[EI_DATA]; if (big_endian) { target_data_order = ELFDATA2MSB; } else { target_data_order = ELFDATA2LSB; } if (target_data_order != e_ident[EI_DATA]) return -1; lseek(fd, 0, SEEK_SET); if (e_ident[EI_CLASS] == ELFCLASS64) { ret = load_elf64(fd, address_offset, must_swab, pentry, lowaddr, highaddr, elf_machine, clear_lsb); } else { ret = load_elf32(fd, address_offset, must_swab, pentry, lowaddr, highaddr, elf_machine, clear_lsb); } close(fd); return ret; fail: close(fd); return -1; }
false
qemu
45a50b1668822c23afc2a89f724654e176518bc4
int load_elf(const char *filename, int64_t address_offset, uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr, int big_endian, int elf_machine, int clear_lsb) { int fd, data_order, target_data_order, must_swab, ret; uint8_t e_ident[EI_NIDENT]; fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) { perror(filename); return -1; } if (read(fd, e_ident, sizeof(e_ident)) != sizeof(e_ident)) goto fail; if (e_ident[0] != ELFMAG0 || e_ident[1] != ELFMAG1 || e_ident[2] != ELFMAG2 || e_ident[3] != ELFMAG3) goto fail; #ifdef HOST_WORDS_BIGENDIAN data_order = ELFDATA2MSB; #else data_order = ELFDATA2LSB; #endif must_swab = data_order != e_ident[EI_DATA]; if (big_endian) { target_data_order = ELFDATA2MSB; } else { target_data_order = ELFDATA2LSB; } if (target_data_order != e_ident[EI_DATA]) return -1; lseek(fd, 0, SEEK_SET); if (e_ident[EI_CLASS] == ELFCLASS64) { ret = load_elf64(fd, address_offset, must_swab, pentry, lowaddr, highaddr, elf_machine, clear_lsb); } else { ret = load_elf32(fd, address_offset, must_swab, pentry, lowaddr, highaddr, elf_machine, clear_lsb); } close(fd); return ret; fail: close(fd); return -1; }
{ "code": [], "line_no": [] }
int FUNC_0(const char *VAR_0, int64_t VAR_1, uint64_t *VAR_2, uint64_t *VAR_3, uint64_t *VAR_4, int VAR_5, int VAR_6, int VAR_7) { int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12; uint8_t e_ident[EI_NIDENT]; VAR_8 = open(VAR_0, O_RDONLY | O_BINARY); if (VAR_8 < 0) { perror(VAR_0); return -1; } if (read(VAR_8, e_ident, sizeof(e_ident)) != sizeof(e_ident)) goto fail; if (e_ident[0] != ELFMAG0 || e_ident[1] != ELFMAG1 || e_ident[2] != ELFMAG2 || e_ident[3] != ELFMAG3) goto fail; #ifdef HOST_WORDS_BIGENDIAN VAR_9 = ELFDATA2MSB; #else VAR_9 = ELFDATA2LSB; #endif VAR_11 = VAR_9 != e_ident[EI_DATA]; if (VAR_5) { VAR_10 = ELFDATA2MSB; } else { VAR_10 = ELFDATA2LSB; } if (VAR_10 != e_ident[EI_DATA]) return -1; lseek(VAR_8, 0, SEEK_SET); if (e_ident[EI_CLASS] == ELFCLASS64) { VAR_12 = load_elf64(VAR_8, VAR_1, VAR_11, VAR_2, VAR_3, VAR_4, VAR_6, VAR_7); } else { VAR_12 = load_elf32(VAR_8, VAR_1, VAR_11, VAR_2, VAR_3, VAR_4, VAR_6, VAR_7); } close(VAR_8); return VAR_12; fail: close(VAR_8); return -1; }
[ "int FUNC_0(const char *VAR_0, int64_t VAR_1,\nuint64_t *VAR_2, uint64_t *VAR_3, uint64_t *VAR_4,\nint VAR_5, int VAR_6, int VAR_7)\n{", "int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;", "uint8_t e_ident[EI_NIDENT];", "VAR_8 = open(VAR_0, O_RDONLY | O_BINARY);", "if (VAR_8 < 0) {", "perror(VAR_0);", "return -1;", "}", "if (read(VAR_8, e_ident, sizeof(e_ident)) != sizeof(e_ident))\ngoto fail;", "if (e_ident[0] != ELFMAG0 ||\ne_ident[1] != ELFMAG1 ||\ne_ident[2] != ELFMAG2 ||\ne_ident[3] != ELFMAG3)\ngoto fail;", "#ifdef HOST_WORDS_BIGENDIAN\nVAR_9 = ELFDATA2MSB;", "#else\nVAR_9 = ELFDATA2LSB;", "#endif\nVAR_11 = VAR_9 != e_ident[EI_DATA];", "if (VAR_5) {", "VAR_10 = ELFDATA2MSB;", "} else {", "VAR_10 = ELFDATA2LSB;", "}", "if (VAR_10 != e_ident[EI_DATA])\nreturn -1;", "lseek(VAR_8, 0, SEEK_SET);", "if (e_ident[EI_CLASS] == ELFCLASS64) {", "VAR_12 = load_elf64(VAR_8, VAR_1, VAR_11, VAR_2,\nVAR_3, VAR_4, VAR_6, VAR_7);", "} else {", "VAR_12 = load_elf32(VAR_8, VAR_1, VAR_11, VAR_2,\nVAR_3, VAR_4, VAR_6, VAR_7);", "}", "close(VAR_8);", "return VAR_12;", "fail:\nclose(VAR_8);", "return -1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 29, 31, 33, 35, 37 ], [ 39, 41 ], [ 43, 45 ], [ 47, 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 63, 65 ], [ 69 ], [ 71 ], [ 73, 75 ], [ 77 ], [ 79, 81 ], [ 83 ], [ 87 ], [ 89 ], [ 93, 95 ], [ 97 ], [ 99 ] ]
8,854
static CharDriverState *qemu_chr_open_pty(const char *id, ChardevBackend *backend, ChardevReturn *ret, Error **errp) { CharDriverState *chr; PtyCharDriver *s; int master_fd, slave_fd; char pty_name[PATH_MAX]; master_fd = qemu_openpty_raw(&slave_fd, pty_name); if (master_fd < 0) { error_setg_errno(errp, errno, "Failed to create PTY"); return NULL; } close(slave_fd); qemu_set_nonblock(master_fd); chr = qemu_chr_alloc(); chr->filename = g_strdup_printf("pty:%s", pty_name); ret->pty = g_strdup(pty_name); ret->has_pty = true; fprintf(stderr, "char device redirected to %s (label %s)\n", pty_name, id); s = g_new0(PtyCharDriver, 1); chr->opaque = s; chr->chr_write = pty_chr_write; chr->chr_update_read_handler = pty_chr_update_read_handler; chr->chr_close = pty_chr_close; chr->chr_add_watch = pty_chr_add_watch; chr->explicit_be_open = true; s->fd = io_channel_from_fd(master_fd); s->timer_tag = 0; return chr; }
false
qemu
d0d7708ba29cbcc343364a46bff981e0ff88366f
static CharDriverState *qemu_chr_open_pty(const char *id, ChardevBackend *backend, ChardevReturn *ret, Error **errp) { CharDriverState *chr; PtyCharDriver *s; int master_fd, slave_fd; char pty_name[PATH_MAX]; master_fd = qemu_openpty_raw(&slave_fd, pty_name); if (master_fd < 0) { error_setg_errno(errp, errno, "Failed to create PTY"); return NULL; } close(slave_fd); qemu_set_nonblock(master_fd); chr = qemu_chr_alloc(); chr->filename = g_strdup_printf("pty:%s", pty_name); ret->pty = g_strdup(pty_name); ret->has_pty = true; fprintf(stderr, "char device redirected to %s (label %s)\n", pty_name, id); s = g_new0(PtyCharDriver, 1); chr->opaque = s; chr->chr_write = pty_chr_write; chr->chr_update_read_handler = pty_chr_update_read_handler; chr->chr_close = pty_chr_close; chr->chr_add_watch = pty_chr_add_watch; chr->explicit_be_open = true; s->fd = io_channel_from_fd(master_fd); s->timer_tag = 0; return chr; }
{ "code": [], "line_no": [] }
static CharDriverState *FUNC_0(const char *id, ChardevBackend *backend, ChardevReturn *ret, Error **errp) { CharDriverState *chr; PtyCharDriver *s; int VAR_0, VAR_1; char VAR_2[PATH_MAX]; VAR_0 = qemu_openpty_raw(&VAR_1, VAR_2); if (VAR_0 < 0) { error_setg_errno(errp, errno, "Failed to create PTY"); return NULL; } close(VAR_1); qemu_set_nonblock(VAR_0); chr = qemu_chr_alloc(); chr->filename = g_strdup_printf("pty:%s", VAR_2); ret->pty = g_strdup(VAR_2); ret->has_pty = true; fprintf(stderr, "char device redirected to %s (label %s)\n", VAR_2, id); s = g_new0(PtyCharDriver, 1); chr->opaque = s; chr->chr_write = pty_chr_write; chr->chr_update_read_handler = pty_chr_update_read_handler; chr->chr_close = pty_chr_close; chr->chr_add_watch = pty_chr_add_watch; chr->explicit_be_open = true; s->fd = io_channel_from_fd(VAR_0); s->timer_tag = 0; return chr; }
[ "static CharDriverState *FUNC_0(const char *id,\nChardevBackend *backend,\nChardevReturn *ret,\nError **errp)\n{", "CharDriverState *chr;", "PtyCharDriver *s;", "int VAR_0, VAR_1;", "char VAR_2[PATH_MAX];", "VAR_0 = qemu_openpty_raw(&VAR_1, VAR_2);", "if (VAR_0 < 0) {", "error_setg_errno(errp, errno, \"Failed to create PTY\");", "return NULL;", "}", "close(VAR_1);", "qemu_set_nonblock(VAR_0);", "chr = qemu_chr_alloc();", "chr->filename = g_strdup_printf(\"pty:%s\", VAR_2);", "ret->pty = g_strdup(VAR_2);", "ret->has_pty = true;", "fprintf(stderr, \"char device redirected to %s (label %s)\\n\",\nVAR_2, id);", "s = g_new0(PtyCharDriver, 1);", "chr->opaque = s;", "chr->chr_write = pty_chr_write;", "chr->chr_update_read_handler = pty_chr_update_read_handler;", "chr->chr_close = pty_chr_close;", "chr->chr_add_watch = pty_chr_add_watch;", "chr->explicit_be_open = true;", "s->fd = io_channel_from_fd(VAR_0);", "s->timer_tag = 0;", "return chr;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 51, 53 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ] ]
8,856
static uint64_t cirrus_linear_read(void *opaque, target_phys_addr_t addr, unsigned size) { CirrusVGAState *s = opaque; uint32_t ret; addr &= s->cirrus_addr_mask; if (((s->vga.sr[0x17] & 0x44) == 0x44) && ((addr & s->linear_mmio_mask) == s->linear_mmio_mask)) { /* memory-mapped I/O */ ret = cirrus_mmio_blt_read(s, addr & 0xff); } else if (0) { /* XXX handle bitblt */ ret = 0xff; } else { /* video memory */ if ((s->vga.gr[0x0B] & 0x14) == 0x14) { addr <<= 4; } else if (s->vga.gr[0x0B] & 0x02) { addr <<= 3; } addr &= s->cirrus_addr_mask; ret = *(s->vga.vram_ptr + addr); } return ret; }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static uint64_t cirrus_linear_read(void *opaque, target_phys_addr_t addr, unsigned size) { CirrusVGAState *s = opaque; uint32_t ret; addr &= s->cirrus_addr_mask; if (((s->vga.sr[0x17] & 0x44) == 0x44) && ((addr & s->linear_mmio_mask) == s->linear_mmio_mask)) { ret = cirrus_mmio_blt_read(s, addr & 0xff); } else if (0) { ret = 0xff; } else { if ((s->vga.gr[0x0B] & 0x14) == 0x14) { addr <<= 4; } else if (s->vga.gr[0x0B] & 0x02) { addr <<= 3; } addr &= s->cirrus_addr_mask; ret = *(s->vga.vram_ptr + addr); } return ret; }
{ "code": [], "line_no": [] }
static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr, unsigned size) { CirrusVGAState *s = opaque; uint32_t ret; addr &= s->cirrus_addr_mask; if (((s->vga.sr[0x17] & 0x44) == 0x44) && ((addr & s->linear_mmio_mask) == s->linear_mmio_mask)) { ret = cirrus_mmio_blt_read(s, addr & 0xff); } else if (0) { ret = 0xff; } else { if ((s->vga.gr[0x0B] & 0x14) == 0x14) { addr <<= 4; } else if (s->vga.gr[0x0B] & 0x02) { addr <<= 3; } addr &= s->cirrus_addr_mask; ret = *(s->vga.vram_ptr + addr); } return ret; }
[ "static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{", "CirrusVGAState *s = opaque;", "uint32_t ret;", "addr &= s->cirrus_addr_mask;", "if (((s->vga.sr[0x17] & 0x44) == 0x44) &&\n((addr & s->linear_mmio_mask) == s->linear_mmio_mask)) {", "ret = cirrus_mmio_blt_read(s, addr & 0xff);", "} else if (0) {", "ret = 0xff;", "} else {", "if ((s->vga.gr[0x0B] & 0x14) == 0x14) {", "addr <<= 4;", "} else if (s->vga.gr[0x0B] & 0x02) {", "addr <<= 3;", "}", "addr &= s->cirrus_addr_mask;", "ret = *(s->vga.vram_ptr + addr);", "}", "return ret;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 17, 19 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ] ]
8,857
static int qemu_gluster_create(const char *filename, QemuOpts *opts, Error **errp) { BlockdevOptionsGluster *gconf; struct glfs *glfs; struct glfs_fd *fd; int ret = 0; int prealloc = 0; int64_t total_size = 0; char *tmp = NULL; gconf = g_new0(BlockdevOptionsGluster, 1); gconf->debug = qemu_opt_get_number_del(opts, GLUSTER_OPT_DEBUG, GLUSTER_DEBUG_DEFAULT); if (gconf->debug < 0) { gconf->debug = 0; } else if (gconf->debug > GLUSTER_DEBUG_MAX) { gconf->debug = GLUSTER_DEBUG_MAX; } gconf->has_debug = true; gconf->logfile = qemu_opt_get_del(opts, GLUSTER_OPT_LOGFILE); if (!gconf->logfile) { gconf->logfile = g_strdup(GLUSTER_LOGFILE_DEFAULT); } gconf->has_logfile = true; glfs = qemu_gluster_init(gconf, filename, NULL, errp); if (!glfs) { ret = -errno; goto out; } total_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), BDRV_SECTOR_SIZE); tmp = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC); if (!tmp || !strcmp(tmp, "off")) { prealloc = 0; } else if (!strcmp(tmp, "full") && gluster_supports_zerofill()) { prealloc = 1; } else { error_setg(errp, "Invalid preallocation mode: '%s'" " or GlusterFS doesn't support zerofill API", tmp); ret = -EINVAL; goto out; } fd = glfs_creat(glfs, gconf->path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR); if (!fd) { ret = -errno; } else { if (!glfs_ftruncate(fd, total_size)) { if (prealloc && qemu_gluster_zerofill(fd, 0, total_size)) { ret = -errno; } } else { ret = -errno; } if (glfs_close(fd) != 0) { ret = -errno; } } out: g_free(tmp); qapi_free_BlockdevOptionsGluster(gconf); glfs_clear_preopened(glfs); return ret; }
false
qemu
df3a429ae82c0f45becdfab105617701d75e0f05
static int qemu_gluster_create(const char *filename, QemuOpts *opts, Error **errp) { BlockdevOptionsGluster *gconf; struct glfs *glfs; struct glfs_fd *fd; int ret = 0; int prealloc = 0; int64_t total_size = 0; char *tmp = NULL; gconf = g_new0(BlockdevOptionsGluster, 1); gconf->debug = qemu_opt_get_number_del(opts, GLUSTER_OPT_DEBUG, GLUSTER_DEBUG_DEFAULT); if (gconf->debug < 0) { gconf->debug = 0; } else if (gconf->debug > GLUSTER_DEBUG_MAX) { gconf->debug = GLUSTER_DEBUG_MAX; } gconf->has_debug = true; gconf->logfile = qemu_opt_get_del(opts, GLUSTER_OPT_LOGFILE); if (!gconf->logfile) { gconf->logfile = g_strdup(GLUSTER_LOGFILE_DEFAULT); } gconf->has_logfile = true; glfs = qemu_gluster_init(gconf, filename, NULL, errp); if (!glfs) { ret = -errno; goto out; } total_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), BDRV_SECTOR_SIZE); tmp = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC); if (!tmp || !strcmp(tmp, "off")) { prealloc = 0; } else if (!strcmp(tmp, "full") && gluster_supports_zerofill()) { prealloc = 1; } else { error_setg(errp, "Invalid preallocation mode: '%s'" " or GlusterFS doesn't support zerofill API", tmp); ret = -EINVAL; goto out; } fd = glfs_creat(glfs, gconf->path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR); if (!fd) { ret = -errno; } else { if (!glfs_ftruncate(fd, total_size)) { if (prealloc && qemu_gluster_zerofill(fd, 0, total_size)) { ret = -errno; } } else { ret = -errno; } if (glfs_close(fd) != 0) { ret = -errno; } } out: g_free(tmp); qapi_free_BlockdevOptionsGluster(gconf); glfs_clear_preopened(glfs); return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(const char *VAR_0, QemuOpts *VAR_1, Error **VAR_2) { BlockdevOptionsGluster *gconf; struct VAR_3 *VAR_3; struct glfs_fd *VAR_4; int VAR_5 = 0; int VAR_6 = 0; int64_t total_size = 0; char *VAR_7 = NULL; gconf = g_new0(BlockdevOptionsGluster, 1); gconf->debug = qemu_opt_get_number_del(VAR_1, GLUSTER_OPT_DEBUG, GLUSTER_DEBUG_DEFAULT); if (gconf->debug < 0) { gconf->debug = 0; } else if (gconf->debug > GLUSTER_DEBUG_MAX) { gconf->debug = GLUSTER_DEBUG_MAX; } gconf->has_debug = true; gconf->logfile = qemu_opt_get_del(VAR_1, GLUSTER_OPT_LOGFILE); if (!gconf->logfile) { gconf->logfile = g_strdup(GLUSTER_LOGFILE_DEFAULT); } gconf->has_logfile = true; VAR_3 = qemu_gluster_init(gconf, VAR_0, NULL, VAR_2); if (!VAR_3) { VAR_5 = -errno; goto out; } total_size = ROUND_UP(qemu_opt_get_size_del(VAR_1, BLOCK_OPT_SIZE, 0), BDRV_SECTOR_SIZE); VAR_7 = qemu_opt_get_del(VAR_1, BLOCK_OPT_PREALLOC); if (!VAR_7 || !strcmp(VAR_7, "off")) { VAR_6 = 0; } else if (!strcmp(VAR_7, "full") && gluster_supports_zerofill()) { VAR_6 = 1; } else { error_setg(VAR_2, "Invalid preallocation mode: '%s'" " or GlusterFS doesn't support zerofill API", VAR_7); VAR_5 = -EINVAL; goto out; } VAR_4 = glfs_creat(VAR_3, gconf->path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR); if (!VAR_4) { VAR_5 = -errno; } else { if (!glfs_ftruncate(VAR_4, total_size)) { if (VAR_6 && qemu_gluster_zerofill(VAR_4, 0, total_size)) { VAR_5 = -errno; } } else { VAR_5 = -errno; } if (glfs_close(VAR_4) != 0) { VAR_5 = -errno; } } out: g_free(VAR_7); qapi_free_BlockdevOptionsGluster(gconf); glfs_clear_preopened(VAR_3); return VAR_5; }
[ "static int FUNC_0(const char *VAR_0,\nQemuOpts *VAR_1, Error **VAR_2)\n{", "BlockdevOptionsGluster *gconf;", "struct VAR_3 *VAR_3;", "struct glfs_fd *VAR_4;", "int VAR_5 = 0;", "int VAR_6 = 0;", "int64_t total_size = 0;", "char *VAR_7 = NULL;", "gconf = g_new0(BlockdevOptionsGluster, 1);", "gconf->debug = qemu_opt_get_number_del(VAR_1, GLUSTER_OPT_DEBUG,\nGLUSTER_DEBUG_DEFAULT);", "if (gconf->debug < 0) {", "gconf->debug = 0;", "} else if (gconf->debug > GLUSTER_DEBUG_MAX) {", "gconf->debug = GLUSTER_DEBUG_MAX;", "}", "gconf->has_debug = true;", "gconf->logfile = qemu_opt_get_del(VAR_1, GLUSTER_OPT_LOGFILE);", "if (!gconf->logfile) {", "gconf->logfile = g_strdup(GLUSTER_LOGFILE_DEFAULT);", "}", "gconf->has_logfile = true;", "VAR_3 = qemu_gluster_init(gconf, VAR_0, NULL, VAR_2);", "if (!VAR_3) {", "VAR_5 = -errno;", "goto out;", "}", "total_size = ROUND_UP(qemu_opt_get_size_del(VAR_1, BLOCK_OPT_SIZE, 0),\nBDRV_SECTOR_SIZE);", "VAR_7 = qemu_opt_get_del(VAR_1, BLOCK_OPT_PREALLOC);", "if (!VAR_7 || !strcmp(VAR_7, \"off\")) {", "VAR_6 = 0;", "} else if (!strcmp(VAR_7, \"full\") && gluster_supports_zerofill()) {", "VAR_6 = 1;", "} else {", "error_setg(VAR_2, \"Invalid preallocation mode: '%s'\"\n\" or GlusterFS doesn't support zerofill API\", VAR_7);", "VAR_5 = -EINVAL;", "goto out;", "}", "VAR_4 = glfs_creat(VAR_3, gconf->path,\nO_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR);", "if (!VAR_4) {", "VAR_5 = -errno;", "} else {", "if (!glfs_ftruncate(VAR_4, total_size)) {", "if (VAR_6 && qemu_gluster_zerofill(VAR_4, 0, total_size)) {", "VAR_5 = -errno;", "}", "} else {", "VAR_5 = -errno;", "}", "if (glfs_close(VAR_4) != 0) {", "VAR_5 = -errno;", "}", "}", "out:\ng_free(VAR_7);", "qapi_free_BlockdevOptionsGluster(gconf);", "glfs_clear_preopened(VAR_3);", "return VAR_5;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25, 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67, 69 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85, 87 ], [ 89 ], [ 91 ], [ 93 ], [ 97, 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131, 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ] ]
8,859
static void memory_region_iorange_read(IORange *iorange, uint64_t offset, unsigned width, uint64_t *data) { MemoryRegion *mr = container_of(iorange, MemoryRegion, iorange); if (mr->ops->old_portio) { const MemoryRegionPortio *mrp = find_portio(mr, offset, width, false); *data = ((uint64_t)1 << (width * 8)) - 1; if (mrp) { *data = mrp->read(mr->opaque, offset - mrp->offset); } return; } *data = mr->ops->read(mr->opaque, offset, width); }
false
qemu
3a130f4ef07f4532500473aeab43c86a3c2991c8
static void memory_region_iorange_read(IORange *iorange, uint64_t offset, unsigned width, uint64_t *data) { MemoryRegion *mr = container_of(iorange, MemoryRegion, iorange); if (mr->ops->old_portio) { const MemoryRegionPortio *mrp = find_portio(mr, offset, width, false); *data = ((uint64_t)1 << (width * 8)) - 1; if (mrp) { *data = mrp->read(mr->opaque, offset - mrp->offset); } return; } *data = mr->ops->read(mr->opaque, offset, width); }
{ "code": [], "line_no": [] }
static void FUNC_0(IORange *VAR_0, uint64_t VAR_1, unsigned VAR_2, uint64_t *VAR_3) { MemoryRegion *mr = container_of(VAR_0, MemoryRegion, VAR_0); if (mr->ops->old_portio) { const MemoryRegionPortio *VAR_4 = find_portio(mr, VAR_1, VAR_2, false); *VAR_3 = ((uint64_t)1 << (VAR_2 * 8)) - 1; if (VAR_4) { *VAR_3 = VAR_4->read(mr->opaque, VAR_1 - VAR_4->VAR_1); } return; } *VAR_3 = mr->ops->read(mr->opaque, VAR_1, VAR_2); }
[ "static void FUNC_0(IORange *VAR_0,\nuint64_t VAR_1,\nunsigned VAR_2,\nuint64_t *VAR_3)\n{", "MemoryRegion *mr = container_of(VAR_0, MemoryRegion, VAR_0);", "if (mr->ops->old_portio) {", "const MemoryRegionPortio *VAR_4 = find_portio(mr, VAR_1, VAR_2, false);", "*VAR_3 = ((uint64_t)1 << (VAR_2 * 8)) - 1;", "if (VAR_4) {", "*VAR_3 = VAR_4->read(mr->opaque, VAR_1 - VAR_4->VAR_1);", "}", "return;", "}", "*VAR_3 = mr->ops->read(mr->opaque, VAR_1, VAR_2);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ] ]
8,860
static int ide_drive_initfn(IDEDevice *dev) { return ide_dev_initfn(dev, bdrv_get_type_hint(dev->conf.bs) == BDRV_TYPE_CDROM ? IDE_CD : IDE_HD); }
false
qemu
95b5edcd92d64c7b8fe9f2e3e0725fdf84be0dfa
static int ide_drive_initfn(IDEDevice *dev) { return ide_dev_initfn(dev, bdrv_get_type_hint(dev->conf.bs) == BDRV_TYPE_CDROM ? IDE_CD : IDE_HD); }
{ "code": [], "line_no": [] }
static int FUNC_0(IDEDevice *VAR_0) { return ide_dev_initfn(VAR_0, bdrv_get_type_hint(VAR_0->conf.bs) == BDRV_TYPE_CDROM ? IDE_CD : IDE_HD); }
[ "static int FUNC_0(IDEDevice *VAR_0)\n{", "return ide_dev_initfn(VAR_0,\nbdrv_get_type_hint(VAR_0->conf.bs) == BDRV_TYPE_CDROM\n? IDE_CD : IDE_HD);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5, 7, 9 ], [ 11 ] ]
8,861
static av_cold void h264dsp_init_neon(H264DSPContext *c, const int bit_depth, const int chroma_format_idc) { #if HAVE_NEON if (bit_depth == 8) { c->h264_v_loop_filter_luma = ff_h264_v_loop_filter_luma_neon; c->h264_h_loop_filter_luma = ff_h264_h_loop_filter_luma_neon; if(chroma_format_idc == 1){ c->h264_v_loop_filter_chroma = ff_h264_v_loop_filter_chroma_neon; c->h264_h_loop_filter_chroma = ff_h264_h_loop_filter_chroma_neon; } c->weight_h264_pixels_tab[0] = ff_weight_h264_pixels_16_neon; c->weight_h264_pixels_tab[1] = ff_weight_h264_pixels_8_neon; c->weight_h264_pixels_tab[2] = ff_weight_h264_pixels_4_neon; c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels_16_neon; c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels_8_neon; c->biweight_h264_pixels_tab[2] = ff_biweight_h264_pixels_4_neon; c->h264_idct_add = ff_h264_idct_add_neon; c->h264_idct_dc_add = ff_h264_idct_dc_add_neon; c->h264_idct_add16 = ff_h264_idct_add16_neon; c->h264_idct_add16intra = ff_h264_idct_add16intra_neon; if (chroma_format_idc <= 1) c->h264_idct_add8 = ff_h264_idct_add8_neon; c->h264_idct8_add = ff_h264_idct8_add_neon; c->h264_idct8_dc_add = ff_h264_idct8_dc_add_neon; c->h264_idct8_add4 = ff_h264_idct8_add4_neon; } #endif // HAVE_NEON }
false
FFmpeg
f9f9ae1b77e4fb1bffa6b23be7bd20e514b8ba7b
static av_cold void h264dsp_init_neon(H264DSPContext *c, const int bit_depth, const int chroma_format_idc) { #if HAVE_NEON if (bit_depth == 8) { c->h264_v_loop_filter_luma = ff_h264_v_loop_filter_luma_neon; c->h264_h_loop_filter_luma = ff_h264_h_loop_filter_luma_neon; if(chroma_format_idc == 1){ c->h264_v_loop_filter_chroma = ff_h264_v_loop_filter_chroma_neon; c->h264_h_loop_filter_chroma = ff_h264_h_loop_filter_chroma_neon; } c->weight_h264_pixels_tab[0] = ff_weight_h264_pixels_16_neon; c->weight_h264_pixels_tab[1] = ff_weight_h264_pixels_8_neon; c->weight_h264_pixels_tab[2] = ff_weight_h264_pixels_4_neon; c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels_16_neon; c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels_8_neon; c->biweight_h264_pixels_tab[2] = ff_biweight_h264_pixels_4_neon; c->h264_idct_add = ff_h264_idct_add_neon; c->h264_idct_dc_add = ff_h264_idct_dc_add_neon; c->h264_idct_add16 = ff_h264_idct_add16_neon; c->h264_idct_add16intra = ff_h264_idct_add16intra_neon; if (chroma_format_idc <= 1) c->h264_idct_add8 = ff_h264_idct_add8_neon; c->h264_idct8_add = ff_h264_idct8_add_neon; c->h264_idct8_dc_add = ff_h264_idct8_dc_add_neon; c->h264_idct8_add4 = ff_h264_idct8_add4_neon; } #endif }
{ "code": [], "line_no": [] }
static av_cold void FUNC_0(H264DSPContext *c, const int bit_depth, const int chroma_format_idc) { #if HAVE_NEON if (bit_depth == 8) { c->h264_v_loop_filter_luma = ff_h264_v_loop_filter_luma_neon; c->h264_h_loop_filter_luma = ff_h264_h_loop_filter_luma_neon; if(chroma_format_idc == 1){ c->h264_v_loop_filter_chroma = ff_h264_v_loop_filter_chroma_neon; c->h264_h_loop_filter_chroma = ff_h264_h_loop_filter_chroma_neon; } c->weight_h264_pixels_tab[0] = ff_weight_h264_pixels_16_neon; c->weight_h264_pixels_tab[1] = ff_weight_h264_pixels_8_neon; c->weight_h264_pixels_tab[2] = ff_weight_h264_pixels_4_neon; c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels_16_neon; c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels_8_neon; c->biweight_h264_pixels_tab[2] = ff_biweight_h264_pixels_4_neon; c->h264_idct_add = ff_h264_idct_add_neon; c->h264_idct_dc_add = ff_h264_idct_dc_add_neon; c->h264_idct_add16 = ff_h264_idct_add16_neon; c->h264_idct_add16intra = ff_h264_idct_add16intra_neon; if (chroma_format_idc <= 1) c->h264_idct_add8 = ff_h264_idct_add8_neon; c->h264_idct8_add = ff_h264_idct8_add_neon; c->h264_idct8_dc_add = ff_h264_idct8_dc_add_neon; c->h264_idct8_add4 = ff_h264_idct8_add4_neon; } #endif }
[ "static av_cold void FUNC_0(H264DSPContext *c, const int bit_depth,\nconst int chroma_format_idc)\n{", "#if HAVE_NEON\nif (bit_depth == 8) {", "c->h264_v_loop_filter_luma = ff_h264_v_loop_filter_luma_neon;", "c->h264_h_loop_filter_luma = ff_h264_h_loop_filter_luma_neon;", "if(chroma_format_idc == 1){", "c->h264_v_loop_filter_chroma = ff_h264_v_loop_filter_chroma_neon;", "c->h264_h_loop_filter_chroma = ff_h264_h_loop_filter_chroma_neon;", "}", "c->weight_h264_pixels_tab[0] = ff_weight_h264_pixels_16_neon;", "c->weight_h264_pixels_tab[1] = ff_weight_h264_pixels_8_neon;", "c->weight_h264_pixels_tab[2] = ff_weight_h264_pixels_4_neon;", "c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels_16_neon;", "c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels_8_neon;", "c->biweight_h264_pixels_tab[2] = ff_biweight_h264_pixels_4_neon;", "c->h264_idct_add = ff_h264_idct_add_neon;", "c->h264_idct_dc_add = ff_h264_idct_dc_add_neon;", "c->h264_idct_add16 = ff_h264_idct_add16_neon;", "c->h264_idct_add16intra = ff_h264_idct_add16intra_neon;", "if (chroma_format_idc <= 1)\nc->h264_idct_add8 = ff_h264_idct_add8_neon;", "c->h264_idct8_add = ff_h264_idct8_add_neon;", "c->h264_idct8_dc_add = ff_h264_idct8_dc_add_neon;", "c->h264_idct8_add4 = ff_h264_idct8_add4_neon;", "}", "#endif\n}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49, 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61, 63 ] ]
8,863
int load_vmstate(Monitor *mon, const char *name) { DriveInfo *dinfo; BlockDriverState *bs, *bs1; QEMUSnapshotInfo sn; QEMUFile *f; int ret; bs = get_bs_snapshots(); if (!bs) { monitor_printf(mon, "No block device supports snapshots\n"); return -EINVAL; } /* Flush all IO requests so they don't interfere with the new state. */ qemu_aio_flush(); TAILQ_FOREACH(dinfo, &drives, next) { bs1 = dinfo->bdrv; if (bdrv_has_snapshot(bs1)) { ret = bdrv_snapshot_goto(bs1, name); if (ret < 0) { if (bs != bs1) monitor_printf(mon, "Warning: "); switch(ret) { case -ENOTSUP: monitor_printf(mon, "Snapshots not supported on device '%s'\n", bdrv_get_device_name(bs1)); break; case -ENOENT: monitor_printf(mon, "Could not find snapshot '%s' on " "device '%s'\n", name, bdrv_get_device_name(bs1)); break; default: monitor_printf(mon, "Error %d while activating snapshot on" " '%s'\n", ret, bdrv_get_device_name(bs1)); break; } /* fatal on snapshot block device */ if (bs == bs1) return 0; } } } /* Don't even try to load empty VM states */ ret = bdrv_snapshot_find(bs, &sn, name); if ((ret >= 0) && (sn.vm_state_size == 0)) return -EINVAL; /* restore the VM state */ f = qemu_fopen_bdrv(bs, 0); if (!f) { monitor_printf(mon, "Could not open VM state file\n"); return -EINVAL; } ret = qemu_loadvm_state(f); qemu_fclose(f); if (ret < 0) { monitor_printf(mon, "Error %d while loading VM state\n", ret); return ret; } return 0; }
false
qemu
72cf2d4f0e181d0d3a3122e04129c58a95da713e
int load_vmstate(Monitor *mon, const char *name) { DriveInfo *dinfo; BlockDriverState *bs, *bs1; QEMUSnapshotInfo sn; QEMUFile *f; int ret; bs = get_bs_snapshots(); if (!bs) { monitor_printf(mon, "No block device supports snapshots\n"); return -EINVAL; } qemu_aio_flush(); TAILQ_FOREACH(dinfo, &drives, next) { bs1 = dinfo->bdrv; if (bdrv_has_snapshot(bs1)) { ret = bdrv_snapshot_goto(bs1, name); if (ret < 0) { if (bs != bs1) monitor_printf(mon, "Warning: "); switch(ret) { case -ENOTSUP: monitor_printf(mon, "Snapshots not supported on device '%s'\n", bdrv_get_device_name(bs1)); break; case -ENOENT: monitor_printf(mon, "Could not find snapshot '%s' on " "device '%s'\n", name, bdrv_get_device_name(bs1)); break; default: monitor_printf(mon, "Error %d while activating snapshot on" " '%s'\n", ret, bdrv_get_device_name(bs1)); break; } if (bs == bs1) return 0; } } } ret = bdrv_snapshot_find(bs, &sn, name); if ((ret >= 0) && (sn.vm_state_size == 0)) return -EINVAL; f = qemu_fopen_bdrv(bs, 0); if (!f) { monitor_printf(mon, "Could not open VM state file\n"); return -EINVAL; } ret = qemu_loadvm_state(f); qemu_fclose(f); if (ret < 0) { monitor_printf(mon, "Error %d while loading VM state\n", ret); return ret; } return 0; }
{ "code": [], "line_no": [] }
int FUNC_0(Monitor *VAR_0, const char *VAR_1) { DriveInfo *dinfo; BlockDriverState *bs, *bs1; QEMUSnapshotInfo sn; QEMUFile *f; int VAR_2; bs = get_bs_snapshots(); if (!bs) { monitor_printf(VAR_0, "No block device supports snapshots\n"); return -EINVAL; } qemu_aio_flush(); TAILQ_FOREACH(dinfo, &drives, next) { bs1 = dinfo->bdrv; if (bdrv_has_snapshot(bs1)) { VAR_2 = bdrv_snapshot_goto(bs1, VAR_1); if (VAR_2 < 0) { if (bs != bs1) monitor_printf(VAR_0, "Warning: "); switch(VAR_2) { case -ENOTSUP: monitor_printf(VAR_0, "Snapshots not supported on device '%s'\n", bdrv_get_device_name(bs1)); break; case -ENOENT: monitor_printf(VAR_0, "Could not find snapshot '%s' on " "device '%s'\n", VAR_1, bdrv_get_device_name(bs1)); break; default: monitor_printf(VAR_0, "Error %d while activating snapshot on" " '%s'\n", VAR_2, bdrv_get_device_name(bs1)); break; } if (bs == bs1) return 0; } } } VAR_2 = bdrv_snapshot_find(bs, &sn, VAR_1); if ((VAR_2 >= 0) && (sn.vm_state_size == 0)) return -EINVAL; f = qemu_fopen_bdrv(bs, 0); if (!f) { monitor_printf(VAR_0, "Could not open VM state file\n"); return -EINVAL; } VAR_2 = qemu_loadvm_state(f); qemu_fclose(f); if (VAR_2 < 0) { monitor_printf(VAR_0, "Error %d while loading VM state\n", VAR_2); return VAR_2; } return 0; }
[ "int FUNC_0(Monitor *VAR_0, const char *VAR_1)\n{", "DriveInfo *dinfo;", "BlockDriverState *bs, *bs1;", "QEMUSnapshotInfo sn;", "QEMUFile *f;", "int VAR_2;", "bs = get_bs_snapshots();", "if (!bs) {", "monitor_printf(VAR_0, \"No block device supports snapshots\\n\");", "return -EINVAL;", "}", "qemu_aio_flush();", "TAILQ_FOREACH(dinfo, &drives, next) {", "bs1 = dinfo->bdrv;", "if (bdrv_has_snapshot(bs1)) {", "VAR_2 = bdrv_snapshot_goto(bs1, VAR_1);", "if (VAR_2 < 0) {", "if (bs != bs1)\nmonitor_printf(VAR_0, \"Warning: \");", "switch(VAR_2) {", "case -ENOTSUP:\nmonitor_printf(VAR_0,\n\"Snapshots not supported on device '%s'\\n\",\nbdrv_get_device_name(bs1));", "break;", "case -ENOENT:\nmonitor_printf(VAR_0, \"Could not find snapshot '%s' on \"\n\"device '%s'\\n\",\nVAR_1, bdrv_get_device_name(bs1));", "break;", "default:\nmonitor_printf(VAR_0, \"Error %d while activating snapshot on\"\n\" '%s'\\n\", VAR_2, bdrv_get_device_name(bs1));", "break;", "}", "if (bs == bs1)\nreturn 0;", "}", "}", "}", "VAR_2 = bdrv_snapshot_find(bs, &sn, VAR_1);", "if ((VAR_2 >= 0) && (sn.vm_state_size == 0))\nreturn -EINVAL;", "f = qemu_fopen_bdrv(bs, 0);", "if (!f) {", "monitor_printf(VAR_0, \"Could not open VM state file\\n\");", "return -EINVAL;", "}", "VAR_2 = qemu_loadvm_state(f);", "qemu_fclose(f);", "if (VAR_2 < 0) {", "monitor_printf(VAR_0, \"Error %d while loading VM state\\n\", VAR_2);", "return VAR_2;", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45, 47 ], [ 49 ], [ 51, 53, 55, 57 ], [ 59 ], [ 61, 63, 65, 67 ], [ 69 ], [ 71, 73, 75 ], [ 77 ], [ 79 ], [ 83, 85 ], [ 87 ], [ 89 ], [ 91 ], [ 97 ], [ 99, 101 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ] ]
8,865
static void spapr_tce_reset(DeviceState *dev) { sPAPRTCETable *tcet = SPAPR_TCE_TABLE(dev); size_t table_size = tcet->nb_table * sizeof(uint64_t); tcet->bypass = false; memset(tcet->table, 0, table_size); }
false
qemu
ee9a569ab88edd0755402aaf31ec0c69decf7756
static void spapr_tce_reset(DeviceState *dev) { sPAPRTCETable *tcet = SPAPR_TCE_TABLE(dev); size_t table_size = tcet->nb_table * sizeof(uint64_t); tcet->bypass = false; memset(tcet->table, 0, table_size); }
{ "code": [], "line_no": [] }
static void FUNC_0(DeviceState *VAR_0) { sPAPRTCETable *tcet = SPAPR_TCE_TABLE(VAR_0); size_t table_size = tcet->nb_table * sizeof(uint64_t); tcet->bypass = false; memset(tcet->table, 0, table_size); }
[ "static void FUNC_0(DeviceState *VAR_0)\n{", "sPAPRTCETable *tcet = SPAPR_TCE_TABLE(VAR_0);", "size_t table_size = tcet->nb_table * sizeof(uint64_t);", "tcet->bypass = false;", "memset(tcet->table, 0, table_size);", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ] ]
8,867
AVIOContext *avio_alloc_context( unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t (*seek)(void *opaque, int64_t offset, int whence)) { AVIOContext *s = av_mallocz(sizeof(AVIOContext)); ffio_init_context(s, buffer, buffer_size, write_flag, opaque, read_packet, write_packet, seek); return s; }
true
FFmpeg
9e2dabed4a7bf21e3e0c0f4ddc895f8ed90fa839
AVIOContext *avio_alloc_context( unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t (*seek)(void *opaque, int64_t offset, int whence)) { AVIOContext *s = av_mallocz(sizeof(AVIOContext)); ffio_init_context(s, buffer, buffer_size, write_flag, opaque, read_packet, write_packet, seek); return s; }
{ "code": [], "line_no": [] }
AVIOContext *FUNC_0( unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t (*seek)(void *opaque, int64_t offset, int whence)) { AVIOContext *s = av_mallocz(sizeof(AVIOContext)); ffio_init_context(s, buffer, buffer_size, write_flag, opaque, read_packet, write_packet, seek); return s; }
[ "AVIOContext *FUNC_0(\nunsigned char *buffer,\nint buffer_size,\nint write_flag,\nvoid *opaque,\nint (*read_packet)(void *opaque, uint8_t *buf, int buf_size),\nint (*write_packet)(void *opaque, uint8_t *buf, int buf_size),\nint64_t (*seek)(void *opaque, int64_t offset, int whence))\n{", "AVIOContext *s = av_mallocz(sizeof(AVIOContext));", "ffio_init_context(s, buffer, buffer_size, write_flag, opaque,\nread_packet, write_packet, seek);", "return s;", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11, 13, 15, 17 ], [ 19 ], [ 23, 25 ], [ 27 ], [ 29 ] ]
8,868
static void slirp_guestfwd(SlirpState *s, Monitor *mon, const char *config_str, int legacy_format) { struct in_addr server = { .s_addr = 0 }; struct GuestFwd *fwd; const char *p; char buf[128]; char *end; int port; p = config_str; if (legacy_format) { if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) { goto fail_syntax; } } else { if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) { goto fail_syntax; } if (strcmp(buf, "tcp") && buf[0] != '\0') { goto fail_syntax; } if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) { goto fail_syntax; } if (buf[0] != '\0' && !inet_aton(buf, &server)) { goto fail_syntax; } if (get_str_sep(buf, sizeof(buf), &p, '-') < 0) { goto fail_syntax; } } port = strtol(buf, &end, 10); if (*end != '\0' || port < 1 || port > 65535) { goto fail_syntax; } fwd = qemu_malloc(sizeof(struct GuestFwd)); snprintf(buf, sizeof(buf), "guestfwd.tcp:%d", port); fwd->hd = qemu_chr_open(buf, p, NULL); if (!fwd->hd) { config_error(mon, "could not open guest forwarding device '%s'\n", buf); qemu_free(fwd); return; } if (slirp_add_exec(s->slirp, 3, fwd->hd, &server, port) < 0) { config_error(mon, "conflicting/invalid host:port in guest forwarding " "rule '%s'\n", config_str); qemu_free(fwd); return; } fwd->server = server; fwd->port = port; fwd->slirp = s->slirp; qemu_chr_add_handlers(fwd->hd, guestfwd_can_read, guestfwd_read, NULL, fwd); return; fail_syntax: config_error(mon, "invalid guest forwarding rule '%s'\n", config_str); }
true
qemu
0752706de257b38763006ff5bb6b39a97e669ba2
static void slirp_guestfwd(SlirpState *s, Monitor *mon, const char *config_str, int legacy_format) { struct in_addr server = { .s_addr = 0 }; struct GuestFwd *fwd; const char *p; char buf[128]; char *end; int port; p = config_str; if (legacy_format) { if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) { goto fail_syntax; } } else { if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) { goto fail_syntax; } if (strcmp(buf, "tcp") && buf[0] != '\0') { goto fail_syntax; } if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) { goto fail_syntax; } if (buf[0] != '\0' && !inet_aton(buf, &server)) { goto fail_syntax; } if (get_str_sep(buf, sizeof(buf), &p, '-') < 0) { goto fail_syntax; } } port = strtol(buf, &end, 10); if (*end != '\0' || port < 1 || port > 65535) { goto fail_syntax; } fwd = qemu_malloc(sizeof(struct GuestFwd)); snprintf(buf, sizeof(buf), "guestfwd.tcp:%d", port); fwd->hd = qemu_chr_open(buf, p, NULL); if (!fwd->hd) { config_error(mon, "could not open guest forwarding device '%s'\n", buf); qemu_free(fwd); return; } if (slirp_add_exec(s->slirp, 3, fwd->hd, &server, port) < 0) { config_error(mon, "conflicting/invalid host:port in guest forwarding " "rule '%s'\n", config_str); qemu_free(fwd); return; } fwd->server = server; fwd->port = port; fwd->slirp = s->slirp; qemu_chr_add_handlers(fwd->hd, guestfwd_can_read, guestfwd_read, NULL, fwd); return; fail_syntax: config_error(mon, "invalid guest forwarding rule '%s'\n", config_str); }
{ "code": [ "static void slirp_guestfwd(SlirpState *s, Monitor *mon, const char *config_str,", "static void slirp_guestfwd(SlirpState *s, Monitor *mon, const char *config_str,", " int legacy_format)" ], "line_no": [ 1, 1, 3 ] }
static void FUNC_0(SlirpState *VAR_0, Monitor *VAR_1, const char *VAR_2, int VAR_3) { struct in_addr VAR_4 = { .s_addr = 0 }; struct GuestFwd *VAR_5; const char *VAR_6; char VAR_7[128]; char *VAR_8; int VAR_9; VAR_6 = VAR_2; if (VAR_3) { if (get_str_sep(VAR_7, sizeof(VAR_7), &VAR_6, ':') < 0) { goto fail_syntax; } } else { if (get_str_sep(VAR_7, sizeof(VAR_7), &VAR_6, ':') < 0) { goto fail_syntax; } if (strcmp(VAR_7, "tcp") && VAR_7[0] != '\0') { goto fail_syntax; } if (get_str_sep(VAR_7, sizeof(VAR_7), &VAR_6, ':') < 0) { goto fail_syntax; } if (VAR_7[0] != '\0' && !inet_aton(VAR_7, &VAR_4)) { goto fail_syntax; } if (get_str_sep(VAR_7, sizeof(VAR_7), &VAR_6, '-') < 0) { goto fail_syntax; } } VAR_9 = strtol(VAR_7, &VAR_8, 10); if (*VAR_8 != '\0' || VAR_9 < 1 || VAR_9 > 65535) { goto fail_syntax; } VAR_5 = qemu_malloc(sizeof(struct GuestFwd)); snprintf(VAR_7, sizeof(VAR_7), "guestfwd.tcp:%d", VAR_9); VAR_5->hd = qemu_chr_open(VAR_7, VAR_6, NULL); if (!VAR_5->hd) { config_error(VAR_1, "could not open guest forwarding device '%VAR_0'\n", VAR_7); qemu_free(VAR_5); return; } if (slirp_add_exec(VAR_0->slirp, 3, VAR_5->hd, &VAR_4, VAR_9) < 0) { config_error(VAR_1, "conflicting/invalid host:VAR_9 in guest forwarding " "rule '%VAR_0'\n", VAR_2); qemu_free(VAR_5); return; } VAR_5->VAR_4 = VAR_4; VAR_5->VAR_9 = VAR_9; VAR_5->slirp = VAR_0->slirp; qemu_chr_add_handlers(VAR_5->hd, guestfwd_can_read, guestfwd_read, NULL, VAR_5); return; fail_syntax: config_error(VAR_1, "invalid guest forwarding rule '%VAR_0'\n", VAR_2); }
[ "static void FUNC_0(SlirpState *VAR_0, Monitor *VAR_1, const char *VAR_2,\nint VAR_3)\n{", "struct in_addr VAR_4 = { .s_addr = 0 };", "struct GuestFwd *VAR_5;", "const char *VAR_6;", "char VAR_7[128];", "char *VAR_8;", "int VAR_9;", "VAR_6 = VAR_2;", "if (VAR_3) {", "if (get_str_sep(VAR_7, sizeof(VAR_7), &VAR_6, ':') < 0) {", "goto fail_syntax;", "}", "} else {", "if (get_str_sep(VAR_7, sizeof(VAR_7), &VAR_6, ':') < 0) {", "goto fail_syntax;", "}", "if (strcmp(VAR_7, \"tcp\") && VAR_7[0] != '\\0') {", "goto fail_syntax;", "}", "if (get_str_sep(VAR_7, sizeof(VAR_7), &VAR_6, ':') < 0) {", "goto fail_syntax;", "}", "if (VAR_7[0] != '\\0' && !inet_aton(VAR_7, &VAR_4)) {", "goto fail_syntax;", "}", "if (get_str_sep(VAR_7, sizeof(VAR_7), &VAR_6, '-') < 0) {", "goto fail_syntax;", "}", "}", "VAR_9 = strtol(VAR_7, &VAR_8, 10);", "if (*VAR_8 != '\\0' || VAR_9 < 1 || VAR_9 > 65535) {", "goto fail_syntax;", "}", "VAR_5 = qemu_malloc(sizeof(struct GuestFwd));", "snprintf(VAR_7, sizeof(VAR_7), \"guestfwd.tcp:%d\", VAR_9);", "VAR_5->hd = qemu_chr_open(VAR_7, VAR_6, NULL);", "if (!VAR_5->hd) {", "config_error(VAR_1, \"could not open guest forwarding device '%VAR_0'\\n\",\nVAR_7);", "qemu_free(VAR_5);", "return;", "}", "if (slirp_add_exec(VAR_0->slirp, 3, VAR_5->hd, &VAR_4, VAR_9) < 0) {", "config_error(VAR_1, \"conflicting/invalid host:VAR_9 in guest forwarding \"\n\"rule '%VAR_0'\\n\", VAR_2);", "qemu_free(VAR_5);", "return;", "}", "VAR_5->VAR_4 = VAR_4;", "VAR_5->VAR_9 = VAR_9;", "VAR_5->slirp = VAR_0->slirp;", "qemu_chr_add_handlers(VAR_5->hd, guestfwd_can_read, guestfwd_read,\nNULL, VAR_5);", "return;", "fail_syntax:\nconfig_error(VAR_1, \"invalid guest forwarding rule '%VAR_0'\\n\", VAR_2);", "}" ]
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83, 85 ], [ 87 ], [ 89 ], [ 91 ], [ 95 ], [ 97, 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 115, 117 ], [ 119 ], [ 123, 125 ], [ 127 ] ]
8,869
int s390_virtio_hypercall(CPUState *env, uint64_t mem, uint64_t hypercall) { int r = 0, i; dprintf("KVM hypercall: %ld\n", hypercall); switch (hypercall) { case KVM_S390_VIRTIO_NOTIFY: if (mem > ram_size) { VirtIOS390Device *dev = s390_virtio_bus_find_vring(s390_bus, mem, &i); if (dev) { virtio_queue_notify(dev->vdev, i); } else { r = -EINVAL; } } else { /* Early printk */ } break; case KVM_S390_VIRTIO_RESET: { VirtIOS390Device *dev; dev = s390_virtio_bus_find_mem(s390_bus, mem); virtio_reset(dev->vdev); s390_virtio_device_sync(dev); break; } case KVM_S390_VIRTIO_SET_STATUS: { VirtIOS390Device *dev; dev = s390_virtio_bus_find_mem(s390_bus, mem); if (dev) { s390_virtio_device_update_status(dev); } else { r = -EINVAL; } break; } default: r = -EINVAL; break; } return r; }
true
qemu
e9d86b760cca52dc35c7716873c342eb03c22b61
int s390_virtio_hypercall(CPUState *env, uint64_t mem, uint64_t hypercall) { int r = 0, i; dprintf("KVM hypercall: %ld\n", hypercall); switch (hypercall) { case KVM_S390_VIRTIO_NOTIFY: if (mem > ram_size) { VirtIOS390Device *dev = s390_virtio_bus_find_vring(s390_bus, mem, &i); if (dev) { virtio_queue_notify(dev->vdev, i); } else { r = -EINVAL; } } else { } break; case KVM_S390_VIRTIO_RESET: { VirtIOS390Device *dev; dev = s390_virtio_bus_find_mem(s390_bus, mem); virtio_reset(dev->vdev); s390_virtio_device_sync(dev); break; } case KVM_S390_VIRTIO_SET_STATUS: { VirtIOS390Device *dev; dev = s390_virtio_bus_find_mem(s390_bus, mem); if (dev) { s390_virtio_device_update_status(dev); } else { r = -EINVAL; } break; } default: r = -EINVAL; break; } return r; }
{ "code": [], "line_no": [] }
int FUNC_0(CPUState *VAR_0, uint64_t VAR_1, uint64_t VAR_2) { int VAR_3 = 0, VAR_4; dprintf("KVM VAR_2: %ld\n", VAR_2); switch (VAR_2) { case KVM_S390_VIRTIO_NOTIFY: if (VAR_1 > ram_size) { VirtIOS390Device *dev = s390_virtio_bus_find_vring(s390_bus, VAR_1, &VAR_4); if (dev) { virtio_queue_notify(dev->vdev, VAR_4); } else { VAR_3 = -EINVAL; } } else { } break; case KVM_S390_VIRTIO_RESET: { VirtIOS390Device *dev; dev = s390_virtio_bus_find_mem(s390_bus, VAR_1); virtio_reset(dev->vdev); s390_virtio_device_sync(dev); break; } case KVM_S390_VIRTIO_SET_STATUS: { VirtIOS390Device *dev; dev = s390_virtio_bus_find_mem(s390_bus, VAR_1); if (dev) { s390_virtio_device_update_status(dev); } else { VAR_3 = -EINVAL; } break; } default: VAR_3 = -EINVAL; break; } return VAR_3; }
[ "int FUNC_0(CPUState *VAR_0, uint64_t VAR_1, uint64_t VAR_2)\n{", "int VAR_3 = 0, VAR_4;", "dprintf(\"KVM VAR_2: %ld\\n\", VAR_2);", "switch (VAR_2) {", "case KVM_S390_VIRTIO_NOTIFY:\nif (VAR_1 > ram_size) {", "VirtIOS390Device *dev = s390_virtio_bus_find_vring(s390_bus,\nVAR_1, &VAR_4);", "if (dev) {", "virtio_queue_notify(dev->vdev, VAR_4);", "} else {", "VAR_3 = -EINVAL;", "}", "} else {", "}", "break;", "case KVM_S390_VIRTIO_RESET:\n{", "VirtIOS390Device *dev;", "dev = s390_virtio_bus_find_mem(s390_bus, VAR_1);", "virtio_reset(dev->vdev);", "s390_virtio_device_sync(dev);", "break;", "}", "case KVM_S390_VIRTIO_SET_STATUS:\n{", "VirtIOS390Device *dev;", "dev = s390_virtio_bus_find_mem(s390_bus, VAR_1);", "if (dev) {", "s390_virtio_device_update_status(dev);", "} else {", "VAR_3 = -EINVAL;", "}", "break;", "}", "default:\nVAR_3 = -EINVAL;", "break;", "}", "return VAR_3;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13, 15 ], [ 17, 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39, 41 ], [ 43 ], [ 47 ], [ 49 ], [ 52 ], [ 54 ], [ 56 ], [ 58, 60 ], [ 62 ], [ 66 ], [ 68 ], [ 70 ], [ 72 ], [ 74 ], [ 76 ], [ 78 ], [ 80 ], [ 82, 84 ], [ 86 ], [ 88 ], [ 92 ], [ 94 ] ]
8,870
PXA2xxPCMCIAState *pxa2xx_pcmcia_init(MemoryRegion *sysmem, hwaddr base) { DeviceState *dev; PXA2xxPCMCIAState *s; dev = qdev_create(NULL, TYPE_PXA2XX_PCMCIA); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); s = PXA2XX_PCMCIA(dev); if (base == 0x30000000) { s->slot.slot_string = "PXA PC Card Socket 1"; } else { s->slot.slot_string = "PXA PC Card Socket 0"; } qdev_init_nofail(dev); return s; }
true
qemu
7797a73947d5c0e63dd5552b348cf66c384b4555
PXA2xxPCMCIAState *pxa2xx_pcmcia_init(MemoryRegion *sysmem, hwaddr base) { DeviceState *dev; PXA2xxPCMCIAState *s; dev = qdev_create(NULL, TYPE_PXA2XX_PCMCIA); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); s = PXA2XX_PCMCIA(dev); if (base == 0x30000000) { s->slot.slot_string = "PXA PC Card Socket 1"; } else { s->slot.slot_string = "PXA PC Card Socket 0"; } qdev_init_nofail(dev); return s; }
{ "code": [ " if (base == 0x30000000) {", " s->slot.slot_string = \"PXA PC Card Socket 1\";", " } else {", " s->slot.slot_string = \"PXA PC Card Socket 0\";" ], "line_no": [ 21, 23, 25, 27 ] }
PXA2xxPCMCIAState *FUNC_0(MemoryRegion *sysmem, hwaddr base) { DeviceState *dev; PXA2xxPCMCIAState *s; dev = qdev_create(NULL, TYPE_PXA2XX_PCMCIA); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); s = PXA2XX_PCMCIA(dev); if (base == 0x30000000) { s->slot.slot_string = "PXA PC Card Socket 1"; } else { s->slot.slot_string = "PXA PC Card Socket 0"; } qdev_init_nofail(dev); return s; }
[ "PXA2xxPCMCIAState *FUNC_0(MemoryRegion *sysmem,\nhwaddr base)\n{", "DeviceState *dev;", "PXA2xxPCMCIAState *s;", "dev = qdev_create(NULL, TYPE_PXA2XX_PCMCIA);", "sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);", "s = PXA2XX_PCMCIA(dev);", "if (base == 0x30000000) {", "s->slot.slot_string = \"PXA PC Card Socket 1\";", "} else {", "s->slot.slot_string = \"PXA PC Card Socket 0\";", "}", "qdev_init_nofail(dev);", "return s;", "}" ]
[ 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 37 ], [ 39 ] ]
8,871
static void qxl_exit_vga_mode(PCIQXLDevice *d) { if (d->mode != QXL_MODE_VGA) { return; } trace_qxl_exit_vga_mode(d->id); qxl_destroy_primary(d, QXL_SYNC); }
true
qemu
0f7bfd8198ffad58a5095ac5d7a46288ea7f5c6e
static void qxl_exit_vga_mode(PCIQXLDevice *d) { if (d->mode != QXL_MODE_VGA) { return; } trace_qxl_exit_vga_mode(d->id); qxl_destroy_primary(d, QXL_SYNC); }
{ "code": [], "line_no": [] }
static void FUNC_0(PCIQXLDevice *VAR_0) { if (VAR_0->mode != QXL_MODE_VGA) { return; } trace_qxl_exit_vga_mode(VAR_0->id); qxl_destroy_primary(VAR_0, QXL_SYNC); }
[ "static void FUNC_0(PCIQXLDevice *VAR_0)\n{", "if (VAR_0->mode != QXL_MODE_VGA) {", "return;", "}", "trace_qxl_exit_vga_mode(VAR_0->id);", "qxl_destroy_primary(VAR_0, QXL_SYNC);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 14 ], [ 16 ] ]
8,872
static int synth_frame(AVCodecContext *ctx, GetBitContext *gb, int frame_idx, float *samples, const double *lsps, const double *prev_lsps, float *excitation, float *synth) { WMAVoiceContext *s = ctx->priv_data; int n, n_blocks_x2, log_n_blocks_x2, cur_pitch_val; int pitch[MAX_BLOCKS], last_block_pitch; /* Parse frame type ("frame header"), see frame_descs */ int bd_idx = s->vbm_tree[get_vlc2(gb, frame_type_vlc.table, 6, 3)], block_nsamples; if (bd_idx < 0) { av_log(ctx, AV_LOG_ERROR, "Invalid frame type VLC code, skipping\n"); return -1; } block_nsamples = MAX_FRAMESIZE / frame_descs[bd_idx].n_blocks; /* Pitch calculation for ACB_TYPE_ASYMMETRIC ("pitch-per-frame") */ if (frame_descs[bd_idx].acb_type == ACB_TYPE_ASYMMETRIC) { /* Pitch is provided per frame, which is interpreted as the pitch of * the last sample of the last block of this frame. We can interpolate * the pitch of other blocks (and even pitch-per-sample) by gradually * incrementing/decrementing prev_frame_pitch to cur_pitch_val. */ n_blocks_x2 = frame_descs[bd_idx].n_blocks << 1; log_n_blocks_x2 = frame_descs[bd_idx].log_n_blocks + 1; cur_pitch_val = s->min_pitch_val + get_bits(gb, s->pitch_nbits); cur_pitch_val = FFMIN(cur_pitch_val, s->max_pitch_val - 1); if (s->last_acb_type == ACB_TYPE_NONE || 20 * abs(cur_pitch_val - s->last_pitch_val) > (cur_pitch_val + s->last_pitch_val)) s->last_pitch_val = cur_pitch_val; /* pitch per block */ for (n = 0; n < frame_descs[bd_idx].n_blocks; n++) { int fac = n * 2 + 1; pitch[n] = (MUL16(fac, cur_pitch_val) + MUL16((n_blocks_x2 - fac), s->last_pitch_val) + frame_descs[bd_idx].n_blocks) >> log_n_blocks_x2; } /* "pitch-diff-per-sample" for calculation of pitch per sample */ s->pitch_diff_sh16 = ((cur_pitch_val - s->last_pitch_val) << 16) / MAX_FRAMESIZE; } /* Global gain (if silence) and pitch-adaptive window coordinates */ switch (frame_descs[bd_idx].fcb_type) { case FCB_TYPE_SILENCE: s->silence_gain = wmavoice_gain_silence[get_bits(gb, 8)]; break; case FCB_TYPE_AW_PULSES: aw_parse_coords(s, gb, pitch); break; } for (n = 0; n < frame_descs[bd_idx].n_blocks; n++) { int bl_pitch_sh2; /* Pitch calculation for ACB_TYPE_HAMMING ("pitch-per-block") */ switch (frame_descs[bd_idx].acb_type) { case ACB_TYPE_HAMMING: { /* Pitch is given per block. Per-block pitches are encoded as an * absolute value for the first block, and then delta values * relative to this value) for all subsequent blocks. The scale of * this pitch value is semi-logaritmic compared to its use in the * decoder, so we convert it to normal scale also. */ int block_pitch, t1 = (s->block_conv_table[1] - s->block_conv_table[0]) << 2, t2 = (s->block_conv_table[2] - s->block_conv_table[1]) << 1, t3 = s->block_conv_table[3] - s->block_conv_table[2] + 1; if (n == 0) { block_pitch = get_bits(gb, s->block_pitch_nbits); } else block_pitch = last_block_pitch - s->block_delta_pitch_hrange + get_bits(gb, s->block_delta_pitch_nbits); /* Convert last_ so that any next delta is within _range */ last_block_pitch = av_clip(block_pitch, s->block_delta_pitch_hrange, s->block_pitch_range - s->block_delta_pitch_hrange); /* Convert semi-log-style scale back to normal scale */ if (block_pitch < t1) { bl_pitch_sh2 = (s->block_conv_table[0] << 2) + block_pitch; } else { block_pitch -= t1; if (block_pitch < t2) { bl_pitch_sh2 = (s->block_conv_table[1] << 2) + (block_pitch << 1); } else { block_pitch -= t2; if (block_pitch < t3) { bl_pitch_sh2 = (s->block_conv_table[2] + block_pitch) << 2; } else bl_pitch_sh2 = s->block_conv_table[3] << 2; } } pitch[n] = bl_pitch_sh2 >> 2; break; } case ACB_TYPE_ASYMMETRIC: { bl_pitch_sh2 = pitch[n] << 2; break; } default: // ACB_TYPE_NONE has no pitch bl_pitch_sh2 = 0; break; } synth_block(s, gb, n, block_nsamples, bl_pitch_sh2, lsps, prev_lsps, &frame_descs[bd_idx], &excitation[n * block_nsamples], &synth[n * block_nsamples]); } /* Averaging projection filter, if applicable. Else, just copy samples * from synthesis buffer */ if (s->do_apf) { double i_lsps[MAX_LSPS]; float lpcs[MAX_LSPS]; for (n = 0; n < s->lsps; n++) // LSF -> LSP i_lsps[n] = cos(0.5 * (prev_lsps[n] + lsps[n])); ff_acelp_lspd2lpc(i_lsps, lpcs, s->lsps >> 1); postfilter(s, synth, samples, 80, lpcs, &s->zero_exc_pf[s->history_nsamples + MAX_FRAMESIZE * frame_idx], frame_descs[bd_idx].fcb_type, pitch[0]); for (n = 0; n < s->lsps; n++) // LSF -> LSP i_lsps[n] = cos(lsps[n]); ff_acelp_lspd2lpc(i_lsps, lpcs, s->lsps >> 1); postfilter(s, &synth[80], &samples[80], 80, lpcs, &s->zero_exc_pf[s->history_nsamples + MAX_FRAMESIZE * frame_idx + 80], frame_descs[bd_idx].fcb_type, pitch[0]); } else memcpy(samples, synth, 160 * sizeof(synth[0])); /* Cache values for next frame */ s->frame_cntr++; if (s->frame_cntr >= 0xFFFF) s->frame_cntr -= 0xFFFF; // i.e. modulo (%) s->last_acb_type = frame_descs[bd_idx].acb_type; switch (frame_descs[bd_idx].acb_type) { case ACB_TYPE_NONE: s->last_pitch_val = 0; break; case ACB_TYPE_ASYMMETRIC: s->last_pitch_val = cur_pitch_val; break; case ACB_TYPE_HAMMING: s->last_pitch_val = pitch[frame_descs[bd_idx].n_blocks - 1]; break; } return 0; }
true
FFmpeg
96a08d8627301dae41a7697ea4346cc9981df17c
static int synth_frame(AVCodecContext *ctx, GetBitContext *gb, int frame_idx, float *samples, const double *lsps, const double *prev_lsps, float *excitation, float *synth) { WMAVoiceContext *s = ctx->priv_data; int n, n_blocks_x2, log_n_blocks_x2, cur_pitch_val; int pitch[MAX_BLOCKS], last_block_pitch; int bd_idx = s->vbm_tree[get_vlc2(gb, frame_type_vlc.table, 6, 3)], block_nsamples; if (bd_idx < 0) { av_log(ctx, AV_LOG_ERROR, "Invalid frame type VLC code, skipping\n"); return -1; } block_nsamples = MAX_FRAMESIZE / frame_descs[bd_idx].n_blocks; if (frame_descs[bd_idx].acb_type == ACB_TYPE_ASYMMETRIC) { n_blocks_x2 = frame_descs[bd_idx].n_blocks << 1; log_n_blocks_x2 = frame_descs[bd_idx].log_n_blocks + 1; cur_pitch_val = s->min_pitch_val + get_bits(gb, s->pitch_nbits); cur_pitch_val = FFMIN(cur_pitch_val, s->max_pitch_val - 1); if (s->last_acb_type == ACB_TYPE_NONE || 20 * abs(cur_pitch_val - s->last_pitch_val) > (cur_pitch_val + s->last_pitch_val)) s->last_pitch_val = cur_pitch_val; for (n = 0; n < frame_descs[bd_idx].n_blocks; n++) { int fac = n * 2 + 1; pitch[n] = (MUL16(fac, cur_pitch_val) + MUL16((n_blocks_x2 - fac), s->last_pitch_val) + frame_descs[bd_idx].n_blocks) >> log_n_blocks_x2; } s->pitch_diff_sh16 = ((cur_pitch_val - s->last_pitch_val) << 16) / MAX_FRAMESIZE; } switch (frame_descs[bd_idx].fcb_type) { case FCB_TYPE_SILENCE: s->silence_gain = wmavoice_gain_silence[get_bits(gb, 8)]; break; case FCB_TYPE_AW_PULSES: aw_parse_coords(s, gb, pitch); break; } for (n = 0; n < frame_descs[bd_idx].n_blocks; n++) { int bl_pitch_sh2; switch (frame_descs[bd_idx].acb_type) { case ACB_TYPE_HAMMING: { int block_pitch, t1 = (s->block_conv_table[1] - s->block_conv_table[0]) << 2, t2 = (s->block_conv_table[2] - s->block_conv_table[1]) << 1, t3 = s->block_conv_table[3] - s->block_conv_table[2] + 1; if (n == 0) { block_pitch = get_bits(gb, s->block_pitch_nbits); } else block_pitch = last_block_pitch - s->block_delta_pitch_hrange + get_bits(gb, s->block_delta_pitch_nbits); last_block_pitch = av_clip(block_pitch, s->block_delta_pitch_hrange, s->block_pitch_range - s->block_delta_pitch_hrange); if (block_pitch < t1) { bl_pitch_sh2 = (s->block_conv_table[0] << 2) + block_pitch; } else { block_pitch -= t1; if (block_pitch < t2) { bl_pitch_sh2 = (s->block_conv_table[1] << 2) + (block_pitch << 1); } else { block_pitch -= t2; if (block_pitch < t3) { bl_pitch_sh2 = (s->block_conv_table[2] + block_pitch) << 2; } else bl_pitch_sh2 = s->block_conv_table[3] << 2; } } pitch[n] = bl_pitch_sh2 >> 2; break; } case ACB_TYPE_ASYMMETRIC: { bl_pitch_sh2 = pitch[n] << 2; break; } default: bl_pitch_sh2 = 0; break; } synth_block(s, gb, n, block_nsamples, bl_pitch_sh2, lsps, prev_lsps, &frame_descs[bd_idx], &excitation[n * block_nsamples], &synth[n * block_nsamples]); } if (s->do_apf) { double i_lsps[MAX_LSPS]; float lpcs[MAX_LSPS]; for (n = 0; n < s->lsps; n++) i_lsps[n] = cos(0.5 * (prev_lsps[n] + lsps[n])); ff_acelp_lspd2lpc(i_lsps, lpcs, s->lsps >> 1); postfilter(s, synth, samples, 80, lpcs, &s->zero_exc_pf[s->history_nsamples + MAX_FRAMESIZE * frame_idx], frame_descs[bd_idx].fcb_type, pitch[0]); for (n = 0; n < s->lsps; n++) i_lsps[n] = cos(lsps[n]); ff_acelp_lspd2lpc(i_lsps, lpcs, s->lsps >> 1); postfilter(s, &synth[80], &samples[80], 80, lpcs, &s->zero_exc_pf[s->history_nsamples + MAX_FRAMESIZE * frame_idx + 80], frame_descs[bd_idx].fcb_type, pitch[0]); } else memcpy(samples, synth, 160 * sizeof(synth[0])); s->frame_cntr++; if (s->frame_cntr >= 0xFFFF) s->frame_cntr -= 0xFFFF; s->last_acb_type = frame_descs[bd_idx].acb_type; switch (frame_descs[bd_idx].acb_type) { case ACB_TYPE_NONE: s->last_pitch_val = 0; break; case ACB_TYPE_ASYMMETRIC: s->last_pitch_val = cur_pitch_val; break; case ACB_TYPE_HAMMING: s->last_pitch_val = pitch[frame_descs[bd_idx].n_blocks - 1]; break; } return 0; }
{ "code": [ " int n, n_blocks_x2, log_n_blocks_x2, cur_pitch_val;", " int pitch[MAX_BLOCKS], last_block_pitch;" ], "line_no": [ 13, 15 ] }
static int FUNC_0(AVCodecContext *VAR_0, GetBitContext *VAR_1, int VAR_2, float *VAR_3, const double *VAR_4, const double *VAR_5, float *VAR_6, float *VAR_7) { WMAVoiceContext *s = VAR_0->priv_data; int VAR_8, VAR_9, VAR_10, VAR_11; int VAR_12[MAX_BLOCKS], last_block_pitch; int VAR_13 = s->vbm_tree[get_vlc2(VAR_1, frame_type_vlc.table, 6, 3)], VAR_14; if (VAR_13 < 0) { av_log(VAR_0, AV_LOG_ERROR, "Invalid frame type VLC code, skipping\VAR_8"); return -1; } VAR_14 = MAX_FRAMESIZE / frame_descs[VAR_13].n_blocks; if (frame_descs[VAR_13].acb_type == ACB_TYPE_ASYMMETRIC) { VAR_9 = frame_descs[VAR_13].n_blocks << 1; VAR_10 = frame_descs[VAR_13].log_n_blocks + 1; VAR_11 = s->min_pitch_val + get_bits(VAR_1, s->pitch_nbits); VAR_11 = FFMIN(VAR_11, s->max_pitch_val - 1); if (s->last_acb_type == ACB_TYPE_NONE || 20 * abs(VAR_11 - s->last_pitch_val) > (VAR_11 + s->last_pitch_val)) s->last_pitch_val = VAR_11; for (VAR_8 = 0; VAR_8 < frame_descs[VAR_13].n_blocks; VAR_8++) { int fac = VAR_8 * 2 + 1; VAR_12[VAR_8] = (MUL16(fac, VAR_11) + MUL16((VAR_9 - fac), s->last_pitch_val) + frame_descs[VAR_13].n_blocks) >> VAR_10; } s->pitch_diff_sh16 = ((VAR_11 - s->last_pitch_val) << 16) / MAX_FRAMESIZE; } switch (frame_descs[VAR_13].fcb_type) { case FCB_TYPE_SILENCE: s->silence_gain = wmavoice_gain_silence[get_bits(VAR_1, 8)]; break; case FCB_TYPE_AW_PULSES: aw_parse_coords(s, VAR_1, VAR_12); break; } for (VAR_8 = 0; VAR_8 < frame_descs[VAR_13].n_blocks; VAR_8++) { int bl_pitch_sh2; switch (frame_descs[VAR_13].acb_type) { case ACB_TYPE_HAMMING: { int block_pitch, t1 = (s->block_conv_table[1] - s->block_conv_table[0]) << 2, t2 = (s->block_conv_table[2] - s->block_conv_table[1]) << 1, t3 = s->block_conv_table[3] - s->block_conv_table[2] + 1; if (VAR_8 == 0) { block_pitch = get_bits(VAR_1, s->block_pitch_nbits); } else block_pitch = last_block_pitch - s->block_delta_pitch_hrange + get_bits(VAR_1, s->block_delta_pitch_nbits); last_block_pitch = av_clip(block_pitch, s->block_delta_pitch_hrange, s->block_pitch_range - s->block_delta_pitch_hrange); if (block_pitch < t1) { bl_pitch_sh2 = (s->block_conv_table[0] << 2) + block_pitch; } else { block_pitch -= t1; if (block_pitch < t2) { bl_pitch_sh2 = (s->block_conv_table[1] << 2) + (block_pitch << 1); } else { block_pitch -= t2; if (block_pitch < t3) { bl_pitch_sh2 = (s->block_conv_table[2] + block_pitch) << 2; } else bl_pitch_sh2 = s->block_conv_table[3] << 2; } } VAR_12[VAR_8] = bl_pitch_sh2 >> 2; break; } case ACB_TYPE_ASYMMETRIC: { bl_pitch_sh2 = VAR_12[VAR_8] << 2; break; } default: bl_pitch_sh2 = 0; break; } synth_block(s, VAR_1, VAR_8, VAR_14, bl_pitch_sh2, VAR_4, VAR_5, &frame_descs[VAR_13], &VAR_6[VAR_8 * VAR_14], &VAR_7[VAR_8 * VAR_14]); } if (s->do_apf) { double VAR_15[MAX_LSPS]; float VAR_16[MAX_LSPS]; for (VAR_8 = 0; VAR_8 < s->VAR_4; VAR_8++) VAR_15[VAR_8] = cos(0.5 * (VAR_5[VAR_8] + VAR_4[VAR_8])); ff_acelp_lspd2lpc(VAR_15, VAR_16, s->VAR_4 >> 1); postfilter(s, VAR_7, VAR_3, 80, VAR_16, &s->zero_exc_pf[s->history_nsamples + MAX_FRAMESIZE * VAR_2], frame_descs[VAR_13].fcb_type, VAR_12[0]); for (VAR_8 = 0; VAR_8 < s->VAR_4; VAR_8++) VAR_15[VAR_8] = cos(VAR_4[VAR_8]); ff_acelp_lspd2lpc(VAR_15, VAR_16, s->VAR_4 >> 1); postfilter(s, &VAR_7[80], &VAR_3[80], 80, VAR_16, &s->zero_exc_pf[s->history_nsamples + MAX_FRAMESIZE * VAR_2 + 80], frame_descs[VAR_13].fcb_type, VAR_12[0]); } else memcpy(VAR_3, VAR_7, 160 * sizeof(VAR_7[0])); s->frame_cntr++; if (s->frame_cntr >= 0xFFFF) s->frame_cntr -= 0xFFFF; s->last_acb_type = frame_descs[VAR_13].acb_type; switch (frame_descs[VAR_13].acb_type) { case ACB_TYPE_NONE: s->last_pitch_val = 0; break; case ACB_TYPE_ASYMMETRIC: s->last_pitch_val = VAR_11; break; case ACB_TYPE_HAMMING: s->last_pitch_val = VAR_12[frame_descs[VAR_13].n_blocks - 1]; break; } return 0; }
[ "static int FUNC_0(AVCodecContext *VAR_0, GetBitContext *VAR_1, int VAR_2,\nfloat *VAR_3,\nconst double *VAR_4, const double *VAR_5,\nfloat *VAR_6, float *VAR_7)\n{", "WMAVoiceContext *s = VAR_0->priv_data;", "int VAR_8, VAR_9, VAR_10, VAR_11;", "int VAR_12[MAX_BLOCKS], last_block_pitch;", "int VAR_13 = s->vbm_tree[get_vlc2(VAR_1, frame_type_vlc.table, 6, 3)], VAR_14;", "if (VAR_13 < 0) {", "av_log(VAR_0, AV_LOG_ERROR,\n\"Invalid frame type VLC code, skipping\\VAR_8\");", "return -1;", "}", "VAR_14 = MAX_FRAMESIZE / frame_descs[VAR_13].n_blocks;", "if (frame_descs[VAR_13].acb_type == ACB_TYPE_ASYMMETRIC) {", "VAR_9 = frame_descs[VAR_13].n_blocks << 1;", "VAR_10 = frame_descs[VAR_13].log_n_blocks + 1;", "VAR_11 = s->min_pitch_val + get_bits(VAR_1, s->pitch_nbits);", "VAR_11 = FFMIN(VAR_11, s->max_pitch_val - 1);", "if (s->last_acb_type == ACB_TYPE_NONE ||\n20 * abs(VAR_11 - s->last_pitch_val) >\n(VAR_11 + s->last_pitch_val))\ns->last_pitch_val = VAR_11;", "for (VAR_8 = 0; VAR_8 < frame_descs[VAR_13].n_blocks; VAR_8++) {", "int fac = VAR_8 * 2 + 1;", "VAR_12[VAR_8] = (MUL16(fac, VAR_11) +\nMUL16((VAR_9 - fac), s->last_pitch_val) +\nframe_descs[VAR_13].n_blocks) >> VAR_10;", "}", "s->pitch_diff_sh16 =\n((VAR_11 - s->last_pitch_val) << 16) / MAX_FRAMESIZE;", "}", "switch (frame_descs[VAR_13].fcb_type) {", "case FCB_TYPE_SILENCE:\ns->silence_gain = wmavoice_gain_silence[get_bits(VAR_1, 8)];", "break;", "case FCB_TYPE_AW_PULSES:\naw_parse_coords(s, VAR_1, VAR_12);", "break;", "}", "for (VAR_8 = 0; VAR_8 < frame_descs[VAR_13].n_blocks; VAR_8++) {", "int bl_pitch_sh2;", "switch (frame_descs[VAR_13].acb_type) {", "case ACB_TYPE_HAMMING: {", "int block_pitch,\nt1 = (s->block_conv_table[1] - s->block_conv_table[0]) << 2,\nt2 = (s->block_conv_table[2] - s->block_conv_table[1]) << 1,\nt3 = s->block_conv_table[3] - s->block_conv_table[2] + 1;", "if (VAR_8 == 0) {", "block_pitch = get_bits(VAR_1, s->block_pitch_nbits);", "} else", "block_pitch = last_block_pitch - s->block_delta_pitch_hrange +\nget_bits(VAR_1, s->block_delta_pitch_nbits);", "last_block_pitch = av_clip(block_pitch,\ns->block_delta_pitch_hrange,\ns->block_pitch_range -\ns->block_delta_pitch_hrange);", "if (block_pitch < t1) {", "bl_pitch_sh2 = (s->block_conv_table[0] << 2) + block_pitch;", "} else {", "block_pitch -= t1;", "if (block_pitch < t2) {", "bl_pitch_sh2 =\n(s->block_conv_table[1] << 2) + (block_pitch << 1);", "} else {", "block_pitch -= t2;", "if (block_pitch < t3) {", "bl_pitch_sh2 =\n(s->block_conv_table[2] + block_pitch) << 2;", "} else", "bl_pitch_sh2 = s->block_conv_table[3] << 2;", "}", "}", "VAR_12[VAR_8] = bl_pitch_sh2 >> 2;", "break;", "}", "case ACB_TYPE_ASYMMETRIC: {", "bl_pitch_sh2 = VAR_12[VAR_8] << 2;", "break;", "}", "default:\nbl_pitch_sh2 = 0;", "break;", "}", "synth_block(s, VAR_1, VAR_8, VAR_14, bl_pitch_sh2,\nVAR_4, VAR_5, &frame_descs[VAR_13],\n&VAR_6[VAR_8 * VAR_14],\n&VAR_7[VAR_8 * VAR_14]);", "}", "if (s->do_apf) {", "double VAR_15[MAX_LSPS];", "float VAR_16[MAX_LSPS];", "for (VAR_8 = 0; VAR_8 < s->VAR_4; VAR_8++)", "VAR_15[VAR_8] = cos(0.5 * (VAR_5[VAR_8] + VAR_4[VAR_8]));", "ff_acelp_lspd2lpc(VAR_15, VAR_16, s->VAR_4 >> 1);", "postfilter(s, VAR_7, VAR_3, 80, VAR_16,\n&s->zero_exc_pf[s->history_nsamples + MAX_FRAMESIZE * VAR_2],\nframe_descs[VAR_13].fcb_type, VAR_12[0]);", "for (VAR_8 = 0; VAR_8 < s->VAR_4; VAR_8++)", "VAR_15[VAR_8] = cos(VAR_4[VAR_8]);", "ff_acelp_lspd2lpc(VAR_15, VAR_16, s->VAR_4 >> 1);", "postfilter(s, &VAR_7[80], &VAR_3[80], 80, VAR_16,\n&s->zero_exc_pf[s->history_nsamples + MAX_FRAMESIZE * VAR_2 + 80],\nframe_descs[VAR_13].fcb_type, VAR_12[0]);", "} else", "memcpy(VAR_3, VAR_7, 160 * sizeof(VAR_7[0]));", "s->frame_cntr++;", "if (s->frame_cntr >= 0xFFFF) s->frame_cntr -= 0xFFFF;", "s->last_acb_type = frame_descs[VAR_13].acb_type;", "switch (frame_descs[VAR_13].acb_type) {", "case ACB_TYPE_NONE:\ns->last_pitch_val = 0;", "break;", "case ACB_TYPE_ASYMMETRIC:\ns->last_pitch_val = VAR_11;", "break;", "case ACB_TYPE_HAMMING:\ns->last_pitch_val = VAR_12[frame_descs[VAR_13].n_blocks - 1];", "break;", "}", "return 0;", "}" ]
[ 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 21 ], [ 25 ], [ 27, 29 ], [ 31 ], [ 33 ], [ 37 ], [ 43 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61, 63, 65, 67 ], [ 73 ], [ 75 ], [ 79, 81, 83 ], [ 85 ], [ 91, 93 ], [ 95 ], [ 101 ], [ 103, 105 ], [ 107 ], [ 109, 111 ], [ 113 ], [ 115 ], [ 119 ], [ 121 ], [ 127 ], [ 129 ], [ 141, 143, 145, 147 ], [ 151 ], [ 153 ], [ 155 ], [ 157, 159 ], [ 163, 165, 167, 169 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185, 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195, 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 225, 227 ], [ 229 ], [ 231 ], [ 235, 237, 239, 241 ], [ 243 ], [ 251 ], [ 253 ], [ 255 ], [ 259 ], [ 261 ], [ 263 ], [ 265, 267, 269 ], [ 273 ], [ 275 ], [ 277 ], [ 279, 281, 283 ], [ 285 ], [ 287 ], [ 293 ], [ 295 ], [ 297 ], [ 299 ], [ 301, 303 ], [ 305 ], [ 307, 309 ], [ 311 ], [ 313, 315 ], [ 317 ], [ 319 ], [ 323 ], [ 325 ] ]
8,875
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd) { int64_t r = 0; av_assert2(c > 0); av_assert2(b >=0); av_assert2((unsigned)(rnd&~AV_ROUND_PASS_MINMAX)<=5 && (rnd&~AV_ROUND_PASS_MINMAX)!=4); if (c <= 0 || b < 0 || !((unsigned)(rnd&~AV_ROUND_PASS_MINMAX)<=5 && (rnd&~AV_ROUND_PASS_MINMAX)!=4)) return INT64_MIN; if (rnd & AV_ROUND_PASS_MINMAX) { if (a == INT64_MIN || a == INT64_MAX) return a; rnd -= AV_ROUND_PASS_MINMAX; } if (a < 0 && a != INT64_MIN) return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd >> 1) & 1)); if (rnd == AV_ROUND_NEAR_INF) r = c / 2; else if (rnd & 1) r = c - 1; if (b <= INT_MAX && c <= INT_MAX) { if (a <= INT_MAX) return (a * b + r) / c; else return a / c * b + (a % c * b + r) / c; } else { #if 1 uint64_t a0 = a & 0xFFFFFFFF; uint64_t a1 = a >> 32; uint64_t b0 = b & 0xFFFFFFFF; uint64_t b1 = b >> 32; uint64_t t1 = a0 * b1 + a1 * b0; uint64_t t1a = t1 << 32; int i; a0 = a0 * b0 + t1a; a1 = a1 * b1 + (t1 >> 32) + (a0 < t1a); a0 += r; a1 += a0 < r; for (i = 63; i >= 0; i--) { a1 += a1 + ((a0 >> i) & 1); t1 += t1; if (c <= a1) { a1 -= c; t1++; } } return t1; } #else AVInteger ai; ai = av_mul_i(av_int2i(a), av_int2i(b)); ai = av_add_i(ai, av_int2i(r)); return av_i2int(av_div_i(ai, av_int2i(c))); } #endif }
false
FFmpeg
25e37f5ea92d4201976a59ae306ce848d257a7e6
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd) { int64_t r = 0; av_assert2(c > 0); av_assert2(b >=0); av_assert2((unsigned)(rnd&~AV_ROUND_PASS_MINMAX)<=5 && (rnd&~AV_ROUND_PASS_MINMAX)!=4); if (c <= 0 || b < 0 || !((unsigned)(rnd&~AV_ROUND_PASS_MINMAX)<=5 && (rnd&~AV_ROUND_PASS_MINMAX)!=4)) return INT64_MIN; if (rnd & AV_ROUND_PASS_MINMAX) { if (a == INT64_MIN || a == INT64_MAX) return a; rnd -= AV_ROUND_PASS_MINMAX; } if (a < 0 && a != INT64_MIN) return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd >> 1) & 1)); if (rnd == AV_ROUND_NEAR_INF) r = c / 2; else if (rnd & 1) r = c - 1; if (b <= INT_MAX && c <= INT_MAX) { if (a <= INT_MAX) return (a * b + r) / c; else return a / c * b + (a % c * b + r) / c; } else { #if 1 uint64_t a0 = a & 0xFFFFFFFF; uint64_t a1 = a >> 32; uint64_t b0 = b & 0xFFFFFFFF; uint64_t b1 = b >> 32; uint64_t t1 = a0 * b1 + a1 * b0; uint64_t t1a = t1 << 32; int i; a0 = a0 * b0 + t1a; a1 = a1 * b1 + (t1 >> 32) + (a0 < t1a); a0 += r; a1 += a0 < r; for (i = 63; i >= 0; i--) { a1 += a1 + ((a0 >> i) & 1); t1 += t1; if (c <= a1) { a1 -= c; t1++; } } return t1; } #else AVInteger ai; ai = av_mul_i(av_int2i(a), av_int2i(b)); ai = av_add_i(ai, av_int2i(r)); return av_i2int(av_div_i(ai, av_int2i(c))); } #endif }
{ "code": [], "line_no": [] }
int64_t FUNC_0(int64_t a, int64_t b, int64_t c, enum AVRounding rnd) { int64_t r = 0; av_assert2(c > 0); av_assert2(b >=0); av_assert2((unsigned)(rnd&~AV_ROUND_PASS_MINMAX)<=5 && (rnd&~AV_ROUND_PASS_MINMAX)!=4); if (c <= 0 || b < 0 || !((unsigned)(rnd&~AV_ROUND_PASS_MINMAX)<=5 && (rnd&~AV_ROUND_PASS_MINMAX)!=4)) return INT64_MIN; if (rnd & AV_ROUND_PASS_MINMAX) { if (a == INT64_MIN || a == INT64_MAX) return a; rnd -= AV_ROUND_PASS_MINMAX; } if (a < 0 && a != INT64_MIN) return -FUNC_0(-a, b, c, rnd ^ ((rnd >> 1) & 1)); if (rnd == AV_ROUND_NEAR_INF) r = c / 2; else if (rnd & 1) r = c - 1; if (b <= INT_MAX && c <= INT_MAX) { if (a <= INT_MAX) return (a * b + r) / c; else return a / c * b + (a % c * b + r) / c; } else { #if 1 uint64_t a0 = a & 0xFFFFFFFF; uint64_t a1 = a >> 32; uint64_t b0 = b & 0xFFFFFFFF; uint64_t b1 = b >> 32; uint64_t t1 = a0 * b1 + a1 * b0; uint64_t t1a = t1 << 32; int VAR_0; a0 = a0 * b0 + t1a; a1 = a1 * b1 + (t1 >> 32) + (a0 < t1a); a0 += r; a1 += a0 < r; for (VAR_0 = 63; VAR_0 >= 0; VAR_0--) { a1 += a1 + ((a0 >> VAR_0) & 1); t1 += t1; if (c <= a1) { a1 -= c; t1++; } } return t1; } #else AVInteger ai; ai = av_mul_i(av_int2i(a), av_int2i(b)); ai = av_add_i(ai, av_int2i(r)); return av_i2int(av_div_i(ai, av_int2i(c))); } #endif }
[ "int64_t FUNC_0(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)\n{", "int64_t r = 0;", "av_assert2(c > 0);", "av_assert2(b >=0);", "av_assert2((unsigned)(rnd&~AV_ROUND_PASS_MINMAX)<=5 && (rnd&~AV_ROUND_PASS_MINMAX)!=4);", "if (c <= 0 || b < 0 || !((unsigned)(rnd&~AV_ROUND_PASS_MINMAX)<=5 && (rnd&~AV_ROUND_PASS_MINMAX)!=4))\nreturn INT64_MIN;", "if (rnd & AV_ROUND_PASS_MINMAX) {", "if (a == INT64_MIN || a == INT64_MAX)\nreturn a;", "rnd -= AV_ROUND_PASS_MINMAX;", "}", "if (a < 0 && a != INT64_MIN)\nreturn -FUNC_0(-a, b, c, rnd ^ ((rnd >> 1) & 1));", "if (rnd == AV_ROUND_NEAR_INF)\nr = c / 2;", "else if (rnd & 1)\nr = c - 1;", "if (b <= INT_MAX && c <= INT_MAX) {", "if (a <= INT_MAX)\nreturn (a * b + r) / c;", "else\nreturn a / c * b + (a % c * b + r) / c;", "} else {", "#if 1\nuint64_t a0 = a & 0xFFFFFFFF;", "uint64_t a1 = a >> 32;", "uint64_t b0 = b & 0xFFFFFFFF;", "uint64_t b1 = b >> 32;", "uint64_t t1 = a0 * b1 + a1 * b0;", "uint64_t t1a = t1 << 32;", "int VAR_0;", "a0 = a0 * b0 + t1a;", "a1 = a1 * b1 + (t1 >> 32) + (a0 < t1a);", "a0 += r;", "a1 += a0 < r;", "for (VAR_0 = 63; VAR_0 >= 0; VAR_0--) {", "a1 += a1 + ((a0 >> VAR_0) & 1);", "t1 += t1;", "if (c <= a1) {", "a1 -= c;", "t1++;", "}", "}", "return t1;", "}", "#else\nAVInteger ai;", "ai = av_mul_i(av_int2i(a), av_int2i(b));", "ai = av_add_i(ai, av_int2i(r));", "return av_i2int(av_div_i(ai, av_int2i(c)));", "}", "#endif\n}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15, 17 ], [ 21 ], [ 23, 25 ], [ 27 ], [ 29 ], [ 33, 35 ], [ 39, 41 ], [ 43, 45 ], [ 49 ], [ 51, 53 ], [ 55, 57 ], [ 59 ], [ 61, 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109, 111 ], [ 113 ], [ 115 ], [ 119 ], [ 121 ], [ 123, 125 ] ]
8,876
static inline void RENAME(rgb24tobgr32)(const uint8_t *src, uint8_t *dst, long src_size) { uint8_t *dest = dst; const uint8_t *s = src; const uint8_t *end; #if COMPILE_TEMPLATE_MMX const uint8_t *mm_end; #endif end = s + src_size; #if COMPILE_TEMPLATE_MMX __asm__ volatile(PREFETCH" %0"::"m"(*s):"memory"); mm_end = end - 23; __asm__ volatile("movq %0, %%mm7"::"m"(mask32a):"memory"); while (s < mm_end) { __asm__ volatile( PREFETCH" 32%1 \n\t" "movd %1, %%mm0 \n\t" "punpckldq 3%1, %%mm0 \n\t" "movd 6%1, %%mm1 \n\t" "punpckldq 9%1, %%mm1 \n\t" "movd 12%1, %%mm2 \n\t" "punpckldq 15%1, %%mm2 \n\t" "movd 18%1, %%mm3 \n\t" "punpckldq 21%1, %%mm3 \n\t" "por %%mm7, %%mm0 \n\t" "por %%mm7, %%mm1 \n\t" "por %%mm7, %%mm2 \n\t" "por %%mm7, %%mm3 \n\t" MOVNTQ" %%mm0, %0 \n\t" MOVNTQ" %%mm1, 8%0 \n\t" MOVNTQ" %%mm2, 16%0 \n\t" MOVNTQ" %%mm3, 24%0" :"=m"(*dest) :"m"(*s) :"memory"); dest += 32; s += 24; } __asm__ volatile(SFENCE:::"memory"); __asm__ volatile(EMMS:::"memory"); #endif while (s < end) { #if HAVE_BIGENDIAN /* RGB24 (= R,G,B) -> RGB32 (= A,B,G,R) */ *dest++ = 255; *dest++ = s[2]; *dest++ = s[1]; *dest++ = s[0]; s+=3; #else *dest++ = *s++; *dest++ = *s++; *dest++ = *s++; *dest++ = 255; #endif } }
false
FFmpeg
d1adad3cca407f493c3637e20ecd4f7124e69212
static inline void RENAME(rgb24tobgr32)(const uint8_t *src, uint8_t *dst, long src_size) { uint8_t *dest = dst; const uint8_t *s = src; const uint8_t *end; #if COMPILE_TEMPLATE_MMX const uint8_t *mm_end; #endif end = s + src_size; #if COMPILE_TEMPLATE_MMX __asm__ volatile(PREFETCH" %0"::"m"(*s):"memory"); mm_end = end - 23; __asm__ volatile("movq %0, %%mm7"::"m"(mask32a):"memory"); while (s < mm_end) { __asm__ volatile( PREFETCH" 32%1 \n\t" "movd %1, %%mm0 \n\t" "punpckldq 3%1, %%mm0 \n\t" "movd 6%1, %%mm1 \n\t" "punpckldq 9%1, %%mm1 \n\t" "movd 12%1, %%mm2 \n\t" "punpckldq 15%1, %%mm2 \n\t" "movd 18%1, %%mm3 \n\t" "punpckldq 21%1, %%mm3 \n\t" "por %%mm7, %%mm0 \n\t" "por %%mm7, %%mm1 \n\t" "por %%mm7, %%mm2 \n\t" "por %%mm7, %%mm3 \n\t" MOVNTQ" %%mm0, %0 \n\t" MOVNTQ" %%mm1, 8%0 \n\t" MOVNTQ" %%mm2, 16%0 \n\t" MOVNTQ" %%mm3, 24%0" :"=m"(*dest) :"m"(*s) :"memory"); dest += 32; s += 24; } __asm__ volatile(SFENCE:::"memory"); __asm__ volatile(EMMS:::"memory"); #endif while (s < end) { #if HAVE_BIGENDIAN *dest++ = 255; *dest++ = s[2]; *dest++ = s[1]; *dest++ = s[0]; s+=3; #else *dest++ = *s++; *dest++ = *s++; *dest++ = *s++; *dest++ = 255; #endif } }
{ "code": [], "line_no": [] }
static inline void FUNC_0(rgb24tobgr32)(const uint8_t *src, uint8_t *dst, long src_size) { uint8_t *dest = dst; const uint8_t *VAR_0 = src; const uint8_t *VAR_1; #if COMPILE_TEMPLATE_MMX const uint8_t *mm_end; #endif VAR_1 = VAR_0 + src_size; #if COMPILE_TEMPLATE_MMX __asm__ volatile(PREFETCH" %0"::"m"(*VAR_0):"memory"); mm_end = VAR_1 - 23; __asm__ volatile("movq %0, %%mm7"::"m"(mask32a):"memory"); while (VAR_0 < mm_end) { __asm__ volatile( PREFETCH" 32%1 \n\t" "movd %1, %%mm0 \n\t" "punpckldq 3%1, %%mm0 \n\t" "movd 6%1, %%mm1 \n\t" "punpckldq 9%1, %%mm1 \n\t" "movd 12%1, %%mm2 \n\t" "punpckldq 15%1, %%mm2 \n\t" "movd 18%1, %%mm3 \n\t" "punpckldq 21%1, %%mm3 \n\t" "por %%mm7, %%mm0 \n\t" "por %%mm7, %%mm1 \n\t" "por %%mm7, %%mm2 \n\t" "por %%mm7, %%mm3 \n\t" MOVNTQ" %%mm0, %0 \n\t" MOVNTQ" %%mm1, 8%0 \n\t" MOVNTQ" %%mm2, 16%0 \n\t" MOVNTQ" %%mm3, 24%0" :"=m"(*dest) :"m"(*VAR_0) :"memory"); dest += 32; VAR_0 += 24; } __asm__ volatile(SFENCE:::"memory"); __asm__ volatile(EMMS:::"memory"); #endif while (VAR_0 < VAR_1) { #if HAVE_BIGENDIAN *dest++ = 255; *dest++ = VAR_0[2]; *dest++ = VAR_0[1]; *dest++ = VAR_0[0]; VAR_0+=3; #else *dest++ = *VAR_0++; *dest++ = *VAR_0++; *dest++ = *VAR_0++; *dest++ = 255; #endif } }
[ "static inline void FUNC_0(rgb24tobgr32)(const uint8_t *src, uint8_t *dst, long src_size)\n{", "uint8_t *dest = dst;", "const uint8_t *VAR_0 = src;", "const uint8_t *VAR_1;", "#if COMPILE_TEMPLATE_MMX\nconst uint8_t *mm_end;", "#endif\nVAR_1 = VAR_0 + src_size;", "#if COMPILE_TEMPLATE_MMX\n__asm__ volatile(PREFETCH\" %0\"::\"m\"(*VAR_0):\"memory\");", "mm_end = VAR_1 - 23;", "__asm__ volatile(\"movq %0, %%mm7\"::\"m\"(mask32a):\"memory\");", "while (VAR_0 < mm_end) {", "__asm__ volatile(\nPREFETCH\" 32%1 \\n\\t\"\n\"movd %1, %%mm0 \\n\\t\"\n\"punpckldq 3%1, %%mm0 \\n\\t\"\n\"movd 6%1, %%mm1 \\n\\t\"\n\"punpckldq 9%1, %%mm1 \\n\\t\"\n\"movd 12%1, %%mm2 \\n\\t\"\n\"punpckldq 15%1, %%mm2 \\n\\t\"\n\"movd 18%1, %%mm3 \\n\\t\"\n\"punpckldq 21%1, %%mm3 \\n\\t\"\n\"por %%mm7, %%mm0 \\n\\t\"\n\"por %%mm7, %%mm1 \\n\\t\"\n\"por %%mm7, %%mm2 \\n\\t\"\n\"por %%mm7, %%mm3 \\n\\t\"\nMOVNTQ\" %%mm0, %0 \\n\\t\"\nMOVNTQ\" %%mm1, 8%0 \\n\\t\"\nMOVNTQ\" %%mm2, 16%0 \\n\\t\"\nMOVNTQ\" %%mm3, 24%0\"\n:\"=m\"(*dest)\n:\"m\"(*VAR_0)\n:\"memory\");", "dest += 32;", "VAR_0 += 24;", "}", "__asm__ volatile(SFENCE:::\"memory\");", "__asm__ volatile(EMMS:::\"memory\");", "#endif\nwhile (VAR_0 < VAR_1) {", "#if HAVE_BIGENDIAN\n*dest++ = 255;", "*dest++ = VAR_0[2];", "*dest++ = VAR_0[1];", "*dest++ = VAR_0[0];", "VAR_0+=3;", "#else\n*dest++ = *VAR_0++;", "*dest++ = *VAR_0++;", "*dest++ = *VAR_0++;", "*dest++ = 255;", "#endif\n}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11, 13 ], [ 15, 17 ], [ 19, 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81, 83 ], [ 85, 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99, 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109, 111 ], [ 113 ] ]
8,877
static void FUNC(transquant_bypass16x16)(uint8_t *_dst, int16_t *coeffs, ptrdiff_t stride) { int x, y; pixel *dst = (pixel *)_dst; stride /= sizeof(pixel); for (y = 0; y < 16; y++) { for (x = 0; x < 16; x++) { dst[x] += *coeffs; coeffs++; } dst += stride; } }
false
FFmpeg
c9fe0caf7a1abde7ca0b1a359f551103064867b1
static void FUNC(transquant_bypass16x16)(uint8_t *_dst, int16_t *coeffs, ptrdiff_t stride) { int x, y; pixel *dst = (pixel *)_dst; stride /= sizeof(pixel); for (y = 0; y < 16; y++) { for (x = 0; x < 16; x++) { dst[x] += *coeffs; coeffs++; } dst += stride; } }
{ "code": [], "line_no": [] }
static void FUNC_0(transquant_bypass16x16)(uint8_t *_dst, int16_t *coeffs, ptrdiff_t stride) { int VAR_0, VAR_1; pixel *dst = (pixel *)_dst; stride /= sizeof(pixel); for (VAR_1 = 0; VAR_1 < 16; VAR_1++) { for (VAR_0 = 0; VAR_0 < 16; VAR_0++) { dst[VAR_0] += *coeffs; coeffs++; } dst += stride; } }
[ "static void FUNC_0(transquant_bypass16x16)(uint8_t *_dst, int16_t *coeffs,\nptrdiff_t stride)\n{", "int VAR_0, VAR_1;", "pixel *dst = (pixel *)_dst;", "stride /= sizeof(pixel);", "for (VAR_1 = 0; VAR_1 < 16; VAR_1++) {", "for (VAR_0 = 0; VAR_0 < 16; VAR_0++) {", "dst[VAR_0] += *coeffs;", "coeffs++;", "}", "dst += stride;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ] ]
8,879
static int CUDAAPI cuvid_handle_video_sequence(void *opaque, CUVIDEOFORMAT* format) { AVCodecContext *avctx = opaque; CuvidContext *ctx = avctx->priv_data; AVHWFramesContext *hwframe_ctx = (AVHWFramesContext*)ctx->hwframe->data; CUVIDDECODECREATEINFO cuinfo; int surface_fmt; enum AVPixelFormat pix_fmts[3] = { AV_PIX_FMT_CUDA, AV_PIX_FMT_NONE, // Will be updated below AV_PIX_FMT_NONE }; av_log(avctx, AV_LOG_TRACE, "pfnSequenceCallback, progressive_sequence=%d\n", format->progressive_sequence); ctx->internal_error = 0; switch (format->bit_depth_luma_minus8) { case 0: // 8-bit pix_fmts[1] = AV_PIX_FMT_NV12; break; case 2: // 10-bit pix_fmts[1] = AV_PIX_FMT_P010; break; case 4: // 12-bit pix_fmts[1] = AV_PIX_FMT_P016; break; default: av_log(avctx, AV_LOG_ERROR, "unsupported bit depth: %d\n", format->bit_depth_luma_minus8 + 8); ctx->internal_error = AVERROR(EINVAL); return 0; } surface_fmt = ff_get_format(avctx, pix_fmts); if (surface_fmt < 0) { av_log(avctx, AV_LOG_ERROR, "ff_get_format failed: %d\n", surface_fmt); ctx->internal_error = AVERROR(EINVAL); return 0; } av_log(avctx, AV_LOG_VERBOSE, "Formats: Original: %s | HW: %s | SW: %s\n", av_get_pix_fmt_name(avctx->pix_fmt), av_get_pix_fmt_name(surface_fmt), av_get_pix_fmt_name(avctx->sw_pix_fmt)); avctx->pix_fmt = surface_fmt; // Update our hwframe ctx, as the get_format callback might have refreshed it! if (avctx->hw_frames_ctx) { av_buffer_unref(&ctx->hwframe); ctx->hwframe = av_buffer_ref(avctx->hw_frames_ctx); if (!ctx->hwframe) { ctx->internal_error = AVERROR(ENOMEM); return 0; } hwframe_ctx = (AVHWFramesContext*)ctx->hwframe->data; } avctx->width = format->display_area.right; avctx->height = format->display_area.bottom; ff_set_sar(avctx, av_div_q( (AVRational){ format->display_aspect_ratio.x, format->display_aspect_ratio.y }, (AVRational){ avctx->width, avctx->height })); if (!format->progressive_sequence && ctx->deint_mode == cudaVideoDeinterlaceMode_Weave) avctx->flags |= AV_CODEC_FLAG_INTERLACED_DCT; else avctx->flags &= ~AV_CODEC_FLAG_INTERLACED_DCT; if (format->video_signal_description.video_full_range_flag) avctx->color_range = AVCOL_RANGE_JPEG; else avctx->color_range = AVCOL_RANGE_MPEG; avctx->color_primaries = format->video_signal_description.color_primaries; avctx->color_trc = format->video_signal_description.transfer_characteristics; avctx->colorspace = format->video_signal_description.matrix_coefficients; if (format->bitrate) avctx->bit_rate = format->bitrate; if (format->frame_rate.numerator && format->frame_rate.denominator) { avctx->framerate.num = format->frame_rate.numerator; avctx->framerate.den = format->frame_rate.denominator; } if (ctx->cudecoder && avctx->coded_width == format->coded_width && avctx->coded_height == format->coded_height && ctx->chroma_format == format->chroma_format && ctx->codec_type == format->codec) return 1; if (ctx->cudecoder) { av_log(avctx, AV_LOG_TRACE, "Re-initializing decoder\n"); ctx->internal_error = CHECK_CU(ctx->cvdl->cuvidDestroyDecoder(ctx->cudecoder)); if (ctx->internal_error < 0) return 0; ctx->cudecoder = NULL; } if (hwframe_ctx->pool && ( hwframe_ctx->width < avctx->width || hwframe_ctx->height < avctx->height || hwframe_ctx->format != AV_PIX_FMT_CUDA || hwframe_ctx->sw_format != avctx->sw_pix_fmt)) { av_log(avctx, AV_LOG_ERROR, "AVHWFramesContext is already initialized with incompatible parameters\n"); ctx->internal_error = AVERROR(EINVAL); return 0; } if (format->chroma_format != cudaVideoChromaFormat_420) { av_log(avctx, AV_LOG_ERROR, "Chroma formats other than 420 are not supported\n"); ctx->internal_error = AVERROR(EINVAL); return 0; } avctx->coded_width = format->coded_width; avctx->coded_height = format->coded_height; ctx->chroma_format = format->chroma_format; memset(&cuinfo, 0, sizeof(cuinfo)); cuinfo.CodecType = ctx->codec_type = format->codec; cuinfo.ChromaFormat = format->chroma_format; switch (avctx->sw_pix_fmt) { case AV_PIX_FMT_NV12: cuinfo.OutputFormat = cudaVideoSurfaceFormat_NV12; break; case AV_PIX_FMT_P010: case AV_PIX_FMT_P016: cuinfo.OutputFormat = cudaVideoSurfaceFormat_P016; break; default: av_log(avctx, AV_LOG_ERROR, "Output formats other than NV12, P010 or P016 are not supported\n"); ctx->internal_error = AVERROR(EINVAL); return 0; } cuinfo.ulWidth = avctx->coded_width; cuinfo.ulHeight = avctx->coded_height; cuinfo.ulTargetWidth = cuinfo.ulWidth; cuinfo.ulTargetHeight = cuinfo.ulHeight; cuinfo.target_rect.left = 0; cuinfo.target_rect.top = 0; cuinfo.target_rect.right = cuinfo.ulWidth; cuinfo.target_rect.bottom = cuinfo.ulHeight; cuinfo.ulNumDecodeSurfaces = ctx->nb_surfaces; cuinfo.ulNumOutputSurfaces = 1; cuinfo.ulCreationFlags = cudaVideoCreate_PreferCUVID; cuinfo.bitDepthMinus8 = format->bit_depth_luma_minus8; if (format->progressive_sequence) { ctx->deint_mode = cuinfo.DeinterlaceMode = cudaVideoDeinterlaceMode_Weave; } else { cuinfo.DeinterlaceMode = ctx->deint_mode; } if (ctx->deint_mode != cudaVideoDeinterlaceMode_Weave) avctx->framerate = av_mul_q(avctx->framerate, (AVRational){2, 1}); ctx->internal_error = CHECK_CU(ctx->cvdl->cuvidCreateDecoder(&ctx->cudecoder, &cuinfo)); if (ctx->internal_error < 0) return 0; if (!hwframe_ctx->pool) { hwframe_ctx->format = AV_PIX_FMT_CUDA; hwframe_ctx->sw_format = avctx->sw_pix_fmt; hwframe_ctx->width = avctx->width; hwframe_ctx->height = avctx->height; if ((ctx->internal_error = av_hwframe_ctx_init(ctx->hwframe)) < 0) { av_log(avctx, AV_LOG_ERROR, "av_hwframe_ctx_init failed\n"); return 0; } } return 1; }
false
FFmpeg
ce79410bba776d4121685654056f2b4e39bbd3f7
static int CUDAAPI cuvid_handle_video_sequence(void *opaque, CUVIDEOFORMAT* format) { AVCodecContext *avctx = opaque; CuvidContext *ctx = avctx->priv_data; AVHWFramesContext *hwframe_ctx = (AVHWFramesContext*)ctx->hwframe->data; CUVIDDECODECREATEINFO cuinfo; int surface_fmt; enum AVPixelFormat pix_fmts[3] = { AV_PIX_FMT_CUDA, AV_PIX_FMT_NONE, AV_PIX_FMT_NONE }; av_log(avctx, AV_LOG_TRACE, "pfnSequenceCallback, progressive_sequence=%d\n", format->progressive_sequence); ctx->internal_error = 0; switch (format->bit_depth_luma_minus8) { case 0: pix_fmts[1] = AV_PIX_FMT_NV12; break; case 2: pix_fmts[1] = AV_PIX_FMT_P010; break; case 4: pix_fmts[1] = AV_PIX_FMT_P016; break; default: av_log(avctx, AV_LOG_ERROR, "unsupported bit depth: %d\n", format->bit_depth_luma_minus8 + 8); ctx->internal_error = AVERROR(EINVAL); return 0; } surface_fmt = ff_get_format(avctx, pix_fmts); if (surface_fmt < 0) { av_log(avctx, AV_LOG_ERROR, "ff_get_format failed: %d\n", surface_fmt); ctx->internal_error = AVERROR(EINVAL); return 0; } av_log(avctx, AV_LOG_VERBOSE, "Formats: Original: %s | HW: %s | SW: %s\n", av_get_pix_fmt_name(avctx->pix_fmt), av_get_pix_fmt_name(surface_fmt), av_get_pix_fmt_name(avctx->sw_pix_fmt)); avctx->pix_fmt = surface_fmt; if (avctx->hw_frames_ctx) { av_buffer_unref(&ctx->hwframe); ctx->hwframe = av_buffer_ref(avctx->hw_frames_ctx); if (!ctx->hwframe) { ctx->internal_error = AVERROR(ENOMEM); return 0; } hwframe_ctx = (AVHWFramesContext*)ctx->hwframe->data; } avctx->width = format->display_area.right; avctx->height = format->display_area.bottom; ff_set_sar(avctx, av_div_q( (AVRational){ format->display_aspect_ratio.x, format->display_aspect_ratio.y }, (AVRational){ avctx->width, avctx->height })); if (!format->progressive_sequence && ctx->deint_mode == cudaVideoDeinterlaceMode_Weave) avctx->flags |= AV_CODEC_FLAG_INTERLACED_DCT; else avctx->flags &= ~AV_CODEC_FLAG_INTERLACED_DCT; if (format->video_signal_description.video_full_range_flag) avctx->color_range = AVCOL_RANGE_JPEG; else avctx->color_range = AVCOL_RANGE_MPEG; avctx->color_primaries = format->video_signal_description.color_primaries; avctx->color_trc = format->video_signal_description.transfer_characteristics; avctx->colorspace = format->video_signal_description.matrix_coefficients; if (format->bitrate) avctx->bit_rate = format->bitrate; if (format->frame_rate.numerator && format->frame_rate.denominator) { avctx->framerate.num = format->frame_rate.numerator; avctx->framerate.den = format->frame_rate.denominator; } if (ctx->cudecoder && avctx->coded_width == format->coded_width && avctx->coded_height == format->coded_height && ctx->chroma_format == format->chroma_format && ctx->codec_type == format->codec) return 1; if (ctx->cudecoder) { av_log(avctx, AV_LOG_TRACE, "Re-initializing decoder\n"); ctx->internal_error = CHECK_CU(ctx->cvdl->cuvidDestroyDecoder(ctx->cudecoder)); if (ctx->internal_error < 0) return 0; ctx->cudecoder = NULL; } if (hwframe_ctx->pool && ( hwframe_ctx->width < avctx->width || hwframe_ctx->height < avctx->height || hwframe_ctx->format != AV_PIX_FMT_CUDA || hwframe_ctx->sw_format != avctx->sw_pix_fmt)) { av_log(avctx, AV_LOG_ERROR, "AVHWFramesContext is already initialized with incompatible parameters\n"); ctx->internal_error = AVERROR(EINVAL); return 0; } if (format->chroma_format != cudaVideoChromaFormat_420) { av_log(avctx, AV_LOG_ERROR, "Chroma formats other than 420 are not supported\n"); ctx->internal_error = AVERROR(EINVAL); return 0; } avctx->coded_width = format->coded_width; avctx->coded_height = format->coded_height; ctx->chroma_format = format->chroma_format; memset(&cuinfo, 0, sizeof(cuinfo)); cuinfo.CodecType = ctx->codec_type = format->codec; cuinfo.ChromaFormat = format->chroma_format; switch (avctx->sw_pix_fmt) { case AV_PIX_FMT_NV12: cuinfo.OutputFormat = cudaVideoSurfaceFormat_NV12; break; case AV_PIX_FMT_P010: case AV_PIX_FMT_P016: cuinfo.OutputFormat = cudaVideoSurfaceFormat_P016; break; default: av_log(avctx, AV_LOG_ERROR, "Output formats other than NV12, P010 or P016 are not supported\n"); ctx->internal_error = AVERROR(EINVAL); return 0; } cuinfo.ulWidth = avctx->coded_width; cuinfo.ulHeight = avctx->coded_height; cuinfo.ulTargetWidth = cuinfo.ulWidth; cuinfo.ulTargetHeight = cuinfo.ulHeight; cuinfo.target_rect.left = 0; cuinfo.target_rect.top = 0; cuinfo.target_rect.right = cuinfo.ulWidth; cuinfo.target_rect.bottom = cuinfo.ulHeight; cuinfo.ulNumDecodeSurfaces = ctx->nb_surfaces; cuinfo.ulNumOutputSurfaces = 1; cuinfo.ulCreationFlags = cudaVideoCreate_PreferCUVID; cuinfo.bitDepthMinus8 = format->bit_depth_luma_minus8; if (format->progressive_sequence) { ctx->deint_mode = cuinfo.DeinterlaceMode = cudaVideoDeinterlaceMode_Weave; } else { cuinfo.DeinterlaceMode = ctx->deint_mode; } if (ctx->deint_mode != cudaVideoDeinterlaceMode_Weave) avctx->framerate = av_mul_q(avctx->framerate, (AVRational){2, 1}); ctx->internal_error = CHECK_CU(ctx->cvdl->cuvidCreateDecoder(&ctx->cudecoder, &cuinfo)); if (ctx->internal_error < 0) return 0; if (!hwframe_ctx->pool) { hwframe_ctx->format = AV_PIX_FMT_CUDA; hwframe_ctx->sw_format = avctx->sw_pix_fmt; hwframe_ctx->width = avctx->width; hwframe_ctx->height = avctx->height; if ((ctx->internal_error = av_hwframe_ctx_init(ctx->hwframe)) < 0) { av_log(avctx, AV_LOG_ERROR, "av_hwframe_ctx_init failed\n"); return 0; } } return 1; }
{ "code": [], "line_no": [] }
static int VAR_0 cuvid_handle_video_sequence(void *opaque, CUVIDEOFORMAT* format) { AVCodecContext *avctx = opaque; CuvidContext *ctx = avctx->priv_data; AVHWFramesContext *hwframe_ctx = (AVHWFramesContext*)ctx->hwframe->data; CUVIDDECODECREATEINFO cuinfo; int surface_fmt; enum AVPixelFormat pix_fmts[3] = { AV_PIX_FMT_CUDA, AV_PIX_FMT_NONE, AV_PIX_FMT_NONE }; av_log(avctx, AV_LOG_TRACE, "pfnSequenceCallback, progressive_sequence=%d\n", format->progressive_sequence); ctx->internal_error = 0; switch (format->bit_depth_luma_minus8) { case 0: pix_fmts[1] = AV_PIX_FMT_NV12; break; case 2: pix_fmts[1] = AV_PIX_FMT_P010; break; case 4: pix_fmts[1] = AV_PIX_FMT_P016; break; default: av_log(avctx, AV_LOG_ERROR, "unsupported bit depth: %d\n", format->bit_depth_luma_minus8 + 8); ctx->internal_error = AVERROR(EINVAL); return 0; } surface_fmt = ff_get_format(avctx, pix_fmts); if (surface_fmt < 0) { av_log(avctx, AV_LOG_ERROR, "ff_get_format failed: %d\n", surface_fmt); ctx->internal_error = AVERROR(EINVAL); return 0; } av_log(avctx, AV_LOG_VERBOSE, "Formats: Original: %s | HW: %s | SW: %s\n", av_get_pix_fmt_name(avctx->pix_fmt), av_get_pix_fmt_name(surface_fmt), av_get_pix_fmt_name(avctx->sw_pix_fmt)); avctx->pix_fmt = surface_fmt; if (avctx->hw_frames_ctx) { av_buffer_unref(&ctx->hwframe); ctx->hwframe = av_buffer_ref(avctx->hw_frames_ctx); if (!ctx->hwframe) { ctx->internal_error = AVERROR(ENOMEM); return 0; } hwframe_ctx = (AVHWFramesContext*)ctx->hwframe->data; } avctx->width = format->display_area.right; avctx->height = format->display_area.bottom; ff_set_sar(avctx, av_div_q( (AVRational){ format->display_aspect_ratio.x, format->display_aspect_ratio.y }, (AVRational){ avctx->width, avctx->height })); if (!format->progressive_sequence && ctx->deint_mode == cudaVideoDeinterlaceMode_Weave) avctx->flags |= AV_CODEC_FLAG_INTERLACED_DCT; else avctx->flags &= ~AV_CODEC_FLAG_INTERLACED_DCT; if (format->video_signal_description.video_full_range_flag) avctx->color_range = AVCOL_RANGE_JPEG; else avctx->color_range = AVCOL_RANGE_MPEG; avctx->color_primaries = format->video_signal_description.color_primaries; avctx->color_trc = format->video_signal_description.transfer_characteristics; avctx->colorspace = format->video_signal_description.matrix_coefficients; if (format->bitrate) avctx->bit_rate = format->bitrate; if (format->frame_rate.numerator && format->frame_rate.denominator) { avctx->framerate.num = format->frame_rate.numerator; avctx->framerate.den = format->frame_rate.denominator; } if (ctx->cudecoder && avctx->coded_width == format->coded_width && avctx->coded_height == format->coded_height && ctx->chroma_format == format->chroma_format && ctx->codec_type == format->codec) return 1; if (ctx->cudecoder) { av_log(avctx, AV_LOG_TRACE, "Re-initializing decoder\n"); ctx->internal_error = CHECK_CU(ctx->cvdl->cuvidDestroyDecoder(ctx->cudecoder)); if (ctx->internal_error < 0) return 0; ctx->cudecoder = NULL; } if (hwframe_ctx->pool && ( hwframe_ctx->width < avctx->width || hwframe_ctx->height < avctx->height || hwframe_ctx->format != AV_PIX_FMT_CUDA || hwframe_ctx->sw_format != avctx->sw_pix_fmt)) { av_log(avctx, AV_LOG_ERROR, "AVHWFramesContext is already initialized with incompatible parameters\n"); ctx->internal_error = AVERROR(EINVAL); return 0; } if (format->chroma_format != cudaVideoChromaFormat_420) { av_log(avctx, AV_LOG_ERROR, "Chroma formats other than 420 are not supported\n"); ctx->internal_error = AVERROR(EINVAL); return 0; } avctx->coded_width = format->coded_width; avctx->coded_height = format->coded_height; ctx->chroma_format = format->chroma_format; memset(&cuinfo, 0, sizeof(cuinfo)); cuinfo.CodecType = ctx->codec_type = format->codec; cuinfo.ChromaFormat = format->chroma_format; switch (avctx->sw_pix_fmt) { case AV_PIX_FMT_NV12: cuinfo.OutputFormat = cudaVideoSurfaceFormat_NV12; break; case AV_PIX_FMT_P010: case AV_PIX_FMT_P016: cuinfo.OutputFormat = cudaVideoSurfaceFormat_P016; break; default: av_log(avctx, AV_LOG_ERROR, "Output formats other than NV12, P010 or P016 are not supported\n"); ctx->internal_error = AVERROR(EINVAL); return 0; } cuinfo.ulWidth = avctx->coded_width; cuinfo.ulHeight = avctx->coded_height; cuinfo.ulTargetWidth = cuinfo.ulWidth; cuinfo.ulTargetHeight = cuinfo.ulHeight; cuinfo.target_rect.left = 0; cuinfo.target_rect.top = 0; cuinfo.target_rect.right = cuinfo.ulWidth; cuinfo.target_rect.bottom = cuinfo.ulHeight; cuinfo.ulNumDecodeSurfaces = ctx->nb_surfaces; cuinfo.ulNumOutputSurfaces = 1; cuinfo.ulCreationFlags = cudaVideoCreate_PreferCUVID; cuinfo.bitDepthMinus8 = format->bit_depth_luma_minus8; if (format->progressive_sequence) { ctx->deint_mode = cuinfo.DeinterlaceMode = cudaVideoDeinterlaceMode_Weave; } else { cuinfo.DeinterlaceMode = ctx->deint_mode; } if (ctx->deint_mode != cudaVideoDeinterlaceMode_Weave) avctx->framerate = av_mul_q(avctx->framerate, (AVRational){2, 1}); ctx->internal_error = CHECK_CU(ctx->cvdl->cuvidCreateDecoder(&ctx->cudecoder, &cuinfo)); if (ctx->internal_error < 0) return 0; if (!hwframe_ctx->pool) { hwframe_ctx->format = AV_PIX_FMT_CUDA; hwframe_ctx->sw_format = avctx->sw_pix_fmt; hwframe_ctx->width = avctx->width; hwframe_ctx->height = avctx->height; if ((ctx->internal_error = av_hwframe_ctx_init(ctx->hwframe)) < 0) { av_log(avctx, AV_LOG_ERROR, "av_hwframe_ctx_init failed\n"); return 0; } } return 1; }
[ "static int VAR_0 cuvid_handle_video_sequence(void *opaque, CUVIDEOFORMAT* format)\n{", "AVCodecContext *avctx = opaque;", "CuvidContext *ctx = avctx->priv_data;", "AVHWFramesContext *hwframe_ctx = (AVHWFramesContext*)ctx->hwframe->data;", "CUVIDDECODECREATEINFO cuinfo;", "int surface_fmt;", "enum AVPixelFormat pix_fmts[3] = { AV_PIX_FMT_CUDA,", "AV_PIX_FMT_NONE,\nAV_PIX_FMT_NONE };", "av_log(avctx, AV_LOG_TRACE, \"pfnSequenceCallback, progressive_sequence=%d\\n\", format->progressive_sequence);", "ctx->internal_error = 0;", "switch (format->bit_depth_luma_minus8) {", "case 0:\npix_fmts[1] = AV_PIX_FMT_NV12;", "break;", "case 2:\npix_fmts[1] = AV_PIX_FMT_P010;", "break;", "case 4:\npix_fmts[1] = AV_PIX_FMT_P016;", "break;", "default:\nav_log(avctx, AV_LOG_ERROR, \"unsupported bit depth: %d\\n\",\nformat->bit_depth_luma_minus8 + 8);", "ctx->internal_error = AVERROR(EINVAL);", "return 0;", "}", "surface_fmt = ff_get_format(avctx, pix_fmts);", "if (surface_fmt < 0) {", "av_log(avctx, AV_LOG_ERROR, \"ff_get_format failed: %d\\n\", surface_fmt);", "ctx->internal_error = AVERROR(EINVAL);", "return 0;", "}", "av_log(avctx, AV_LOG_VERBOSE, \"Formats: Original: %s | HW: %s | SW: %s\\n\",\nav_get_pix_fmt_name(avctx->pix_fmt),\nav_get_pix_fmt_name(surface_fmt),\nav_get_pix_fmt_name(avctx->sw_pix_fmt));", "avctx->pix_fmt = surface_fmt;", "if (avctx->hw_frames_ctx) {", "av_buffer_unref(&ctx->hwframe);", "ctx->hwframe = av_buffer_ref(avctx->hw_frames_ctx);", "if (!ctx->hwframe) {", "ctx->internal_error = AVERROR(ENOMEM);", "return 0;", "}", "hwframe_ctx = (AVHWFramesContext*)ctx->hwframe->data;", "}", "avctx->width = format->display_area.right;", "avctx->height = format->display_area.bottom;", "ff_set_sar(avctx, av_div_q(\n(AVRational){ format->display_aspect_ratio.x, format->display_aspect_ratio.y },", "(AVRational){ avctx->width, avctx->height }));", "if (!format->progressive_sequence && ctx->deint_mode == cudaVideoDeinterlaceMode_Weave)\navctx->flags |= AV_CODEC_FLAG_INTERLACED_DCT;", "else\navctx->flags &= ~AV_CODEC_FLAG_INTERLACED_DCT;", "if (format->video_signal_description.video_full_range_flag)\navctx->color_range = AVCOL_RANGE_JPEG;", "else\navctx->color_range = AVCOL_RANGE_MPEG;", "avctx->color_primaries = format->video_signal_description.color_primaries;", "avctx->color_trc = format->video_signal_description.transfer_characteristics;", "avctx->colorspace = format->video_signal_description.matrix_coefficients;", "if (format->bitrate)\navctx->bit_rate = format->bitrate;", "if (format->frame_rate.numerator && format->frame_rate.denominator) {", "avctx->framerate.num = format->frame_rate.numerator;", "avctx->framerate.den = format->frame_rate.denominator;", "}", "if (ctx->cudecoder\n&& avctx->coded_width == format->coded_width\n&& avctx->coded_height == format->coded_height\n&& ctx->chroma_format == format->chroma_format\n&& ctx->codec_type == format->codec)\nreturn 1;", "if (ctx->cudecoder) {", "av_log(avctx, AV_LOG_TRACE, \"Re-initializing decoder\\n\");", "ctx->internal_error = CHECK_CU(ctx->cvdl->cuvidDestroyDecoder(ctx->cudecoder));", "if (ctx->internal_error < 0)\nreturn 0;", "ctx->cudecoder = NULL;", "}", "if (hwframe_ctx->pool && (\nhwframe_ctx->width < avctx->width ||\nhwframe_ctx->height < avctx->height ||\nhwframe_ctx->format != AV_PIX_FMT_CUDA ||\nhwframe_ctx->sw_format != avctx->sw_pix_fmt)) {", "av_log(avctx, AV_LOG_ERROR, \"AVHWFramesContext is already initialized with incompatible parameters\\n\");", "ctx->internal_error = AVERROR(EINVAL);", "return 0;", "}", "if (format->chroma_format != cudaVideoChromaFormat_420) {", "av_log(avctx, AV_LOG_ERROR, \"Chroma formats other than 420 are not supported\\n\");", "ctx->internal_error = AVERROR(EINVAL);", "return 0;", "}", "avctx->coded_width = format->coded_width;", "avctx->coded_height = format->coded_height;", "ctx->chroma_format = format->chroma_format;", "memset(&cuinfo, 0, sizeof(cuinfo));", "cuinfo.CodecType = ctx->codec_type = format->codec;", "cuinfo.ChromaFormat = format->chroma_format;", "switch (avctx->sw_pix_fmt) {", "case AV_PIX_FMT_NV12:\ncuinfo.OutputFormat = cudaVideoSurfaceFormat_NV12;", "break;", "case AV_PIX_FMT_P010:\ncase AV_PIX_FMT_P016:\ncuinfo.OutputFormat = cudaVideoSurfaceFormat_P016;", "break;", "default:\nav_log(avctx, AV_LOG_ERROR, \"Output formats other than NV12, P010 or P016 are not supported\\n\");", "ctx->internal_error = AVERROR(EINVAL);", "return 0;", "}", "cuinfo.ulWidth = avctx->coded_width;", "cuinfo.ulHeight = avctx->coded_height;", "cuinfo.ulTargetWidth = cuinfo.ulWidth;", "cuinfo.ulTargetHeight = cuinfo.ulHeight;", "cuinfo.target_rect.left = 0;", "cuinfo.target_rect.top = 0;", "cuinfo.target_rect.right = cuinfo.ulWidth;", "cuinfo.target_rect.bottom = cuinfo.ulHeight;", "cuinfo.ulNumDecodeSurfaces = ctx->nb_surfaces;", "cuinfo.ulNumOutputSurfaces = 1;", "cuinfo.ulCreationFlags = cudaVideoCreate_PreferCUVID;", "cuinfo.bitDepthMinus8 = format->bit_depth_luma_minus8;", "if (format->progressive_sequence) {", "ctx->deint_mode = cuinfo.DeinterlaceMode = cudaVideoDeinterlaceMode_Weave;", "} else {", "cuinfo.DeinterlaceMode = ctx->deint_mode;", "}", "if (ctx->deint_mode != cudaVideoDeinterlaceMode_Weave)\navctx->framerate = av_mul_q(avctx->framerate, (AVRational){2, 1});", "ctx->internal_error = CHECK_CU(ctx->cvdl->cuvidCreateDecoder(&ctx->cudecoder, &cuinfo));", "if (ctx->internal_error < 0)\nreturn 0;", "if (!hwframe_ctx->pool) {", "hwframe_ctx->format = AV_PIX_FMT_CUDA;", "hwframe_ctx->sw_format = avctx->sw_pix_fmt;", "hwframe_ctx->width = avctx->width;", "hwframe_ctx->height = avctx->height;", "if ((ctx->internal_error = av_hwframe_ctx_init(ctx->hwframe)) < 0) {", "av_log(avctx, AV_LOG_ERROR, \"av_hwframe_ctx_init failed\\n\");", "return 0;", "}", "}", "return 1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 29 ], [ 33 ], [ 35, 37 ], [ 39 ], [ 41, 43 ], [ 45 ], [ 47, 49 ], [ 51 ], [ 53, 55, 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79, 81, 83, 85 ], [ 89 ], [ 95 ], [ 97 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 113 ], [ 115 ], [ 119 ], [ 121 ], [ 125, 127 ], [ 129 ], [ 133, 135 ], [ 137, 139 ], [ 143, 145 ], [ 147, 149 ], [ 153 ], [ 155 ], [ 157 ], [ 161, 163 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 177, 179, 181, 183, 185, 187 ], [ 191 ], [ 193 ], [ 195 ], [ 197, 199 ], [ 201 ], [ 203 ], [ 207, 209, 211, 213, 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 239 ], [ 241 ], [ 245 ], [ 249 ], [ 253 ], [ 255 ], [ 259 ], [ 261, 263 ], [ 265 ], [ 267, 269, 271 ], [ 273 ], [ 275, 277 ], [ 279 ], [ 281 ], [ 283 ], [ 287 ], [ 289 ], [ 291 ], [ 293 ], [ 297 ], [ 299 ], [ 301 ], [ 303 ], [ 307 ], [ 309 ], [ 311 ], [ 313 ], [ 317 ], [ 319 ], [ 321 ], [ 323 ], [ 325 ], [ 329, 331 ], [ 335 ], [ 337, 339 ], [ 343 ], [ 345 ], [ 347 ], [ 349 ], [ 351 ], [ 355 ], [ 357 ], [ 359 ], [ 361 ], [ 363 ], [ 367 ], [ 369 ] ]
8,880
static void set_stream_info_from_input_stream(AVStream *st, struct playlist *pls, AVStream *ist) { avcodec_parameters_copy(st->codecpar, ist->codecpar); if (pls->is_id3_timestamped) /* custom timestamps via id3 */ avpriv_set_pts_info(st, 33, 1, MPEG_TIME_BASE); else avpriv_set_pts_info(st, ist->pts_wrap_bits, ist->time_base.num, ist->time_base.den); st->internal->need_context_update = 1; }
false
FFmpeg
e2193b53eab9f207544a75ebaf51871b7a1a7931
static void set_stream_info_from_input_stream(AVStream *st, struct playlist *pls, AVStream *ist) { avcodec_parameters_copy(st->codecpar, ist->codecpar); if (pls->is_id3_timestamped) avpriv_set_pts_info(st, 33, 1, MPEG_TIME_BASE); else avpriv_set_pts_info(st, ist->pts_wrap_bits, ist->time_base.num, ist->time_base.den); st->internal->need_context_update = 1; }
{ "code": [], "line_no": [] }
static void FUNC_0(AVStream *VAR_0, struct playlist *VAR_1, AVStream *VAR_2) { avcodec_parameters_copy(VAR_0->codecpar, VAR_2->codecpar); if (VAR_1->is_id3_timestamped) avpriv_set_pts_info(VAR_0, 33, 1, MPEG_TIME_BASE); else avpriv_set_pts_info(VAR_0, VAR_2->pts_wrap_bits, VAR_2->time_base.num, VAR_2->time_base.den); VAR_0->internal->need_context_update = 1; }
[ "static void FUNC_0(AVStream *VAR_0, struct playlist *VAR_1, AVStream *VAR_2)\n{", "avcodec_parameters_copy(VAR_0->codecpar, VAR_2->codecpar);", "if (VAR_1->is_id3_timestamped)\navpriv_set_pts_info(VAR_0, 33, 1, MPEG_TIME_BASE);", "else\navpriv_set_pts_info(VAR_0, VAR_2->pts_wrap_bits, VAR_2->time_base.num, VAR_2->time_base.den);", "VAR_0->internal->need_context_update = 1;", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9, 11 ], [ 13, 15 ], [ 19 ], [ 21 ] ]
8,882
void ff_rtp_send_h264(AVFormatContext *s1, const uint8_t *buf1, int size) { const uint8_t *r, *end = buf1 + size; RTPMuxContext *s = s1->priv_data; s->timestamp = s->cur_timestamp; s->buf_ptr = s->buf; if (s->nal_length_size) r = ff_avc_mp4_find_startcode(buf1, end, s->nal_length_size) ? buf1 : end; else r = ff_avc_find_startcode(buf1, end); while (r < end) { const uint8_t *r1; if (s->nal_length_size) { r1 = ff_avc_mp4_find_startcode(r, end, s->nal_length_size); if (!r1) r1 = end; r += s->nal_length_size; } else { while (!*(r++)); r1 = ff_avc_find_startcode(r, end); } nal_send(s1, r, r1 - r, r1 == end); r = r1; } flush_buffered(s1, 1); }
true
FFmpeg
c82bf15dca00f67a701d126e47ea9075fc9459cb
void ff_rtp_send_h264(AVFormatContext *s1, const uint8_t *buf1, int size) { const uint8_t *r, *end = buf1 + size; RTPMuxContext *s = s1->priv_data; s->timestamp = s->cur_timestamp; s->buf_ptr = s->buf; if (s->nal_length_size) r = ff_avc_mp4_find_startcode(buf1, end, s->nal_length_size) ? buf1 : end; else r = ff_avc_find_startcode(buf1, end); while (r < end) { const uint8_t *r1; if (s->nal_length_size) { r1 = ff_avc_mp4_find_startcode(r, end, s->nal_length_size); if (!r1) r1 = end; r += s->nal_length_size; } else { while (!*(r++)); r1 = ff_avc_find_startcode(r, end); } nal_send(s1, r, r1 - r, r1 == end); r = r1; } flush_buffered(s1, 1); }
{ "code": [ " RTPMuxContext *s = s1->priv_data;", " RTPMuxContext *s = s1->priv_data;", " } else {", "void ff_rtp_send_h264(AVFormatContext *s1, const uint8_t *buf1, int size)", " const uint8_t *r, *end = buf1 + size;", " RTPMuxContext *s = s1->priv_data;", " s->timestamp = s->cur_timestamp;", " s->buf_ptr = s->buf;", " if (s->nal_length_size)", " r = ff_avc_mp4_find_startcode(buf1, end, s->nal_length_size) ? buf1 : end;", " r = ff_avc_find_startcode(buf1, end);", " while (r < end) {", " const uint8_t *r1;", " if (s->nal_length_size) {", " r1 = ff_avc_mp4_find_startcode(r, end, s->nal_length_size);", " if (!r1)", " r1 = end;", " r += s->nal_length_size;", " } else {", " while (!*(r++));", " r1 = ff_avc_find_startcode(r, end);", " nal_send(s1, r, r1 - r, r1 == end);", " r = r1;", " flush_buffered(s1, 1);", " RTPMuxContext *s = s1->priv_data;", " } else {", " } else {" ], "line_no": [ 7, 7, 39, 1, 5, 7, 11, 13, 15, 17, 21, 23, 25, 29, 31, 33, 35, 37, 39, 41, 43, 47, 49, 53, 7, 39, 39 ] }
void FUNC_0(AVFormatContext *VAR_0, const uint8_t *VAR_1, int VAR_2) { const uint8_t *VAR_3, *end = VAR_1 + VAR_2; RTPMuxContext *s = VAR_0->priv_data; s->timestamp = s->cur_timestamp; s->buf_ptr = s->buf; if (s->nal_length_size) VAR_3 = ff_avc_mp4_find_startcode(VAR_1, end, s->nal_length_size) ? VAR_1 : end; else VAR_3 = ff_avc_find_startcode(VAR_1, end); while (VAR_3 < end) { const uint8_t *VAR_4; if (s->nal_length_size) { VAR_4 = ff_avc_mp4_find_startcode(VAR_3, end, s->nal_length_size); if (!VAR_4) VAR_4 = end; VAR_3 += s->nal_length_size; } else { while (!*(VAR_3++)); VAR_4 = ff_avc_find_startcode(VAR_3, end); } nal_send(VAR_0, VAR_3, VAR_4 - VAR_3, VAR_4 == end); VAR_3 = VAR_4; } flush_buffered(VAR_0, 1); }
[ "void FUNC_0(AVFormatContext *VAR_0, const uint8_t *VAR_1, int VAR_2)\n{", "const uint8_t *VAR_3, *end = VAR_1 + VAR_2;", "RTPMuxContext *s = VAR_0->priv_data;", "s->timestamp = s->cur_timestamp;", "s->buf_ptr = s->buf;", "if (s->nal_length_size)\nVAR_3 = ff_avc_mp4_find_startcode(VAR_1, end, s->nal_length_size) ? VAR_1 : end;", "else\nVAR_3 = ff_avc_find_startcode(VAR_1, end);", "while (VAR_3 < end) {", "const uint8_t *VAR_4;", "if (s->nal_length_size) {", "VAR_4 = ff_avc_mp4_find_startcode(VAR_3, end, s->nal_length_size);", "if (!VAR_4)\nVAR_4 = end;", "VAR_3 += s->nal_length_size;", "} else {", "while (!*(VAR_3++));", "VAR_4 = ff_avc_find_startcode(VAR_3, end);", "}", "nal_send(VAR_0, VAR_3, VAR_4 - VAR_3, VAR_4 == end);", "VAR_3 = VAR_4;", "}", "flush_buffered(VAR_0, 1);", "}" ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15, 17 ], [ 19, 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ] ]
8,883
static inline void idct4col_put(uint8_t *dest, int line_size, const DCTELEM *col) { int c0, c1, c2, c3, a0, a1, a2, a3; const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; a0 = col[8*0]; a1 = col[8*2]; a2 = col[8*4]; a3 = col[8*6]; c0 = ((a0 + a2) << (CN_SHIFT - 1)) + (1 << (C_SHIFT - 1)); c2 = ((a0 - a2) << (CN_SHIFT - 1)) + (1 << (C_SHIFT - 1)); c1 = a1 * C1 + a3 * C2; c3 = a1 * C2 - a3 * C1; dest[0] = cm[(c0 + c1) >> C_SHIFT]; dest += line_size; dest[0] = cm[(c2 + c3) >> C_SHIFT]; dest += line_size; dest[0] = cm[(c2 - c3) >> C_SHIFT]; dest += line_size; dest[0] = cm[(c0 - c1) >> C_SHIFT]; }
true
FFmpeg
c23acbaed40101c677dfcfbbfe0d2c230a8e8f44
static inline void idct4col_put(uint8_t *dest, int line_size, const DCTELEM *col) { int c0, c1, c2, c3, a0, a1, a2, a3; const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; a0 = col[8*0]; a1 = col[8*2]; a2 = col[8*4]; a3 = col[8*6]; c0 = ((a0 + a2) << (CN_SHIFT - 1)) + (1 << (C_SHIFT - 1)); c2 = ((a0 - a2) << (CN_SHIFT - 1)) + (1 << (C_SHIFT - 1)); c1 = a1 * C1 + a3 * C2; c3 = a1 * C2 - a3 * C1; dest[0] = cm[(c0 + c1) >> C_SHIFT]; dest += line_size; dest[0] = cm[(c2 + c3) >> C_SHIFT]; dest += line_size; dest[0] = cm[(c2 - c3) >> C_SHIFT]; dest += line_size; dest[0] = cm[(c0 - c1) >> C_SHIFT]; }
{ "code": [ " const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;", " const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;", " dest[0] = cm[(c0 + c1) >> C_SHIFT];", " dest[0] = cm[(c2 + c3) >> C_SHIFT];", " dest[0] = cm[(c2 - c3) >> C_SHIFT];", " dest[0] = cm[(c0 - c1) >> C_SHIFT];", " const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;", " const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;", " const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;", " const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;" ], "line_no": [ 7, 7, 27, 31, 35, 39, 7, 7, 7, 7 ] }
static inline void FUNC_0(uint8_t *VAR_0, int VAR_1, const DCTELEM *VAR_2) { int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10; const uint8_t *VAR_11 = ff_cropTbl + MAX_NEG_CROP; VAR_7 = VAR_2[8*0]; VAR_8 = VAR_2[8*2]; VAR_9 = VAR_2[8*4]; VAR_10 = VAR_2[8*6]; VAR_3 = ((VAR_7 + VAR_9) << (CN_SHIFT - 1)) + (1 << (C_SHIFT - 1)); VAR_5 = ((VAR_7 - VAR_9) << (CN_SHIFT - 1)) + (1 << (C_SHIFT - 1)); VAR_4 = VAR_8 * C1 + VAR_10 * C2; VAR_6 = VAR_8 * C2 - VAR_10 * C1; VAR_0[0] = VAR_11[(VAR_3 + VAR_4) >> C_SHIFT]; VAR_0 += VAR_1; VAR_0[0] = VAR_11[(VAR_5 + VAR_6) >> C_SHIFT]; VAR_0 += VAR_1; VAR_0[0] = VAR_11[(VAR_5 - VAR_6) >> C_SHIFT]; VAR_0 += VAR_1; VAR_0[0] = VAR_11[(VAR_3 - VAR_4) >> C_SHIFT]; }
[ "static inline void FUNC_0(uint8_t *VAR_0, int VAR_1, const DCTELEM *VAR_2)\n{", "int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;", "const uint8_t *VAR_11 = ff_cropTbl + MAX_NEG_CROP;", "VAR_7 = VAR_2[8*0];", "VAR_8 = VAR_2[8*2];", "VAR_9 = VAR_2[8*4];", "VAR_10 = VAR_2[8*6];", "VAR_3 = ((VAR_7 + VAR_9) << (CN_SHIFT - 1)) + (1 << (C_SHIFT - 1));", "VAR_5 = ((VAR_7 - VAR_9) << (CN_SHIFT - 1)) + (1 << (C_SHIFT - 1));", "VAR_4 = VAR_8 * C1 + VAR_10 * C2;", "VAR_6 = VAR_8 * C2 - VAR_10 * C1;", "VAR_0[0] = VAR_11[(VAR_3 + VAR_4) >> C_SHIFT];", "VAR_0 += VAR_1;", "VAR_0[0] = VAR_11[(VAR_5 + VAR_6) >> C_SHIFT];", "VAR_0 += VAR_1;", "VAR_0[0] = VAR_11[(VAR_5 - VAR_6) >> C_SHIFT];", "VAR_0 += VAR_1;", "VAR_0[0] = VAR_11[(VAR_3 - VAR_4) >> C_SHIFT];", "}" ]
[ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ] ]
8,884
static ExitStatus gen_fbcond(DisasContext *ctx, TCGCond cond, int ra, int32_t disp) { TCGv cmp_tmp = tcg_temp_new(); gen_fold_mzero(cond, cmp_tmp, load_fpr(ctx, ra)); return gen_bcond_internal(ctx, cond, cmp_tmp, disp); }
true
qemu
6a9b110d54b885dbb29872a142cc4d2a402fada8
static ExitStatus gen_fbcond(DisasContext *ctx, TCGCond cond, int ra, int32_t disp) { TCGv cmp_tmp = tcg_temp_new(); gen_fold_mzero(cond, cmp_tmp, load_fpr(ctx, ra)); return gen_bcond_internal(ctx, cond, cmp_tmp, disp); }
{ "code": [ " return gen_bcond_internal(ctx, cond, cmp_tmp, disp);" ], "line_no": [ 11 ] }
static ExitStatus FUNC_0(DisasContext *ctx, TCGCond cond, int ra, int32_t disp) { TCGv cmp_tmp = tcg_temp_new(); gen_fold_mzero(cond, cmp_tmp, load_fpr(ctx, ra)); return gen_bcond_internal(ctx, cond, cmp_tmp, disp); }
[ "static ExitStatus FUNC_0(DisasContext *ctx, TCGCond cond, int ra,\nint32_t disp)\n{", "TCGv cmp_tmp = tcg_temp_new();", "gen_fold_mzero(cond, cmp_tmp, load_fpr(ctx, ra));", "return gen_bcond_internal(ctx, cond, cmp_tmp, disp);", "}" ]
[ 0, 0, 0, 1, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ] ]
8,885
int cpu_ppc_handle_mmu_fault (CPUState *env, target_ulong address, int rw, int is_user, int is_softmmu) { mmu_ctx_t ctx; int access_type; int ret = 0; if (rw == 2) { /* code access */ rw = 0; access_type = ACCESS_CODE; } else { /* data access */ /* XXX: put correct access by using cpu_restore_state() correctly */ access_type = ACCESS_INT; // access_type = env->access_type; } ret = get_physical_address(env, &ctx, address, rw, access_type, 1); if (ret == 0) { ret = tlb_set_page(env, address & TARGET_PAGE_MASK, ctx.raddr & TARGET_PAGE_MASK, ctx.prot, is_user, is_softmmu); } else if (ret < 0) { #if defined (DEBUG_MMU) if (loglevel != 0) cpu_dump_state(env, logfile, fprintf, 0); #endif if (access_type == ACCESS_CODE) { switch (ret) { case -1: /* No matches in page tables or TLB */ switch (env->mmu_model) { case POWERPC_MMU_SOFT_6xx: env->exception_index = POWERPC_EXCP_IFTLB; env->error_code = 1 << 18; env->spr[SPR_IMISS] = address; env->spr[SPR_ICMP] = 0x80000000 | ctx.ptem; goto tlb_miss; case POWERPC_MMU_SOFT_74xx: env->exception_index = POWERPC_EXCP_IFTLB; goto tlb_miss_74xx; case POWERPC_MMU_SOFT_4xx: case POWERPC_MMU_SOFT_4xx_Z: env->exception_index = POWERPC_EXCP_ITLB; env->error_code = 0; env->spr[SPR_40x_DEAR] = address; env->spr[SPR_40x_ESR] = 0x00000000; break; case POWERPC_MMU_32B: #if defined(TARGET_PPC64) case POWERPC_MMU_64B: case POWERPC_MMU_64BRIDGE: #endif env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x40000000; break; case POWERPC_MMU_601: /* XXX: TODO */ cpu_abort(env, "MMU model not implemented\n"); return -1; case POWERPC_MMU_BOOKE: /* XXX: TODO */ cpu_abort(env, "MMU model not implemented\n"); return -1; case POWERPC_MMU_BOOKE_FSL: /* XXX: TODO */ cpu_abort(env, "MMU model not implemented\n"); return -1; case POWERPC_MMU_REAL_4xx: cpu_abort(env, "PowerPC 401 should never raise any MMU " "exceptions\n"); return -1; default: cpu_abort(env, "Unknown or invalid MMU model\n"); return -1; } break; case -2: /* Access rights violation */ env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x08000000; break; case -3: /* No execute protection violation */ env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x10000000; break; case -4: /* Direct store exception */ /* No code fetch is allowed in direct-store areas */ env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x10000000; break; #if defined(TARGET_PPC64) case -5: /* No match in segment table */ env->exception_index = POWERPC_EXCP_ISEG; env->error_code = 0; break; #endif } } else { switch (ret) { case -1: /* No matches in page tables or TLB */ switch (env->mmu_model) { case POWERPC_MMU_SOFT_6xx: if (rw == 1) { env->exception_index = POWERPC_EXCP_DSTLB; env->error_code = 1 << 16; } else { env->exception_index = POWERPC_EXCP_DLTLB; env->error_code = 0; } env->spr[SPR_DMISS] = address; env->spr[SPR_DCMP] = 0x80000000 | ctx.ptem; tlb_miss: env->error_code |= ctx.key << 19; env->spr[SPR_HASH1] = ctx.pg_addr[0]; env->spr[SPR_HASH2] = ctx.pg_addr[1]; break; case POWERPC_MMU_SOFT_74xx: if (rw == 1) { env->exception_index = POWERPC_EXCP_DSTLB; } else { env->exception_index = POWERPC_EXCP_DLTLB; } tlb_miss_74xx: /* Implement LRU algorithm */ env->error_code = ctx.key << 19; env->spr[SPR_TLBMISS] = (address & ~((target_ulong)0x3)) | ((env->last_way + 1) & (env->nb_ways - 1)); env->spr[SPR_PTEHI] = 0x80000000 | ctx.ptem; break; case POWERPC_MMU_SOFT_4xx: case POWERPC_MMU_SOFT_4xx_Z: env->exception_index = POWERPC_EXCP_DTLB; env->error_code = 0; env->spr[SPR_40x_DEAR] = address; if (rw) env->spr[SPR_40x_ESR] = 0x00800000; else env->spr[SPR_40x_ESR] = 0x00000000; break; case POWERPC_MMU_32B: #if defined(TARGET_PPC64) case POWERPC_MMU_64B: case POWERPC_MMU_64BRIDGE: #endif env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) env->spr[SPR_DSISR] = 0x42000000; else env->spr[SPR_DSISR] = 0x40000000; break; case POWERPC_MMU_601: /* XXX: TODO */ cpu_abort(env, "MMU model not implemented\n"); return -1; case POWERPC_MMU_BOOKE: /* XXX: TODO */ cpu_abort(env, "MMU model not implemented\n"); return -1; case POWERPC_MMU_BOOKE_FSL: /* XXX: TODO */ cpu_abort(env, "MMU model not implemented\n"); return -1; case POWERPC_MMU_REAL_4xx: cpu_abort(env, "PowerPC 401 should never raise any MMU " "exceptions\n"); return -1; default: cpu_abort(env, "Unknown or invalid MMU model\n"); return -1; } break; case -2: /* Access rights violation */ env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) env->spr[SPR_DSISR] = 0x0A000000; else env->spr[SPR_DSISR] = 0x08000000; break; case -4: /* Direct store exception */ switch (access_type) { case ACCESS_FLOAT: /* Floating point load/store */ env->exception_index = POWERPC_EXCP_ALIGN; env->error_code = POWERPC_EXCP_ALIGN_FP; env->spr[SPR_DAR] = address; break; case ACCESS_RES: /* lwarx, ldarx or stwcx. */ env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) env->spr[SPR_DSISR] = 0x06000000; else env->spr[SPR_DSISR] = 0x04000000; break; case ACCESS_EXT: /* eciwx or ecowx */ env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) env->spr[SPR_DSISR] = 0x06100000; else env->spr[SPR_DSISR] = 0x04100000; break; default: printf("DSI: invalid exception (%d)\n", ret); env->exception_index = POWERPC_EXCP_PROGRAM; env->error_code = POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL; env->spr[SPR_DAR] = address; break; } break; #if defined(TARGET_PPC64) case -5: /* No match in segment table */ env->exception_index = POWERPC_EXCP_DSEG; env->error_code = 0; env->spr[SPR_DAR] = address; break; #endif } } #if 0 printf("%s: set exception to %d %02x\n", __func__, env->exception, env->error_code); #endif ret = 1; } return ret; }
true
qemu
12de9a396acbc95e25c5d60ed097cc55777eaaed
int cpu_ppc_handle_mmu_fault (CPUState *env, target_ulong address, int rw, int is_user, int is_softmmu) { mmu_ctx_t ctx; int access_type; int ret = 0; if (rw == 2) { rw = 0; access_type = ACCESS_CODE; } else { access_type = ACCESS_INT; } ret = get_physical_address(env, &ctx, address, rw, access_type, 1); if (ret == 0) { ret = tlb_set_page(env, address & TARGET_PAGE_MASK, ctx.raddr & TARGET_PAGE_MASK, ctx.prot, is_user, is_softmmu); } else if (ret < 0) { #if defined (DEBUG_MMU) if (loglevel != 0) cpu_dump_state(env, logfile, fprintf, 0); #endif if (access_type == ACCESS_CODE) { switch (ret) { case -1: switch (env->mmu_model) { case POWERPC_MMU_SOFT_6xx: env->exception_index = POWERPC_EXCP_IFTLB; env->error_code = 1 << 18; env->spr[SPR_IMISS] = address; env->spr[SPR_ICMP] = 0x80000000 | ctx.ptem; goto tlb_miss; case POWERPC_MMU_SOFT_74xx: env->exception_index = POWERPC_EXCP_IFTLB; goto tlb_miss_74xx; case POWERPC_MMU_SOFT_4xx: case POWERPC_MMU_SOFT_4xx_Z: env->exception_index = POWERPC_EXCP_ITLB; env->error_code = 0; env->spr[SPR_40x_DEAR] = address; env->spr[SPR_40x_ESR] = 0x00000000; break; case POWERPC_MMU_32B: #if defined(TARGET_PPC64) case POWERPC_MMU_64B: case POWERPC_MMU_64BRIDGE: #endif env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x40000000; break; case POWERPC_MMU_601: cpu_abort(env, "MMU model not implemented\n"); return -1; case POWERPC_MMU_BOOKE: cpu_abort(env, "MMU model not implemented\n"); return -1; case POWERPC_MMU_BOOKE_FSL: cpu_abort(env, "MMU model not implemented\n"); return -1; case POWERPC_MMU_REAL_4xx: cpu_abort(env, "PowerPC 401 should never raise any MMU " "exceptions\n"); return -1; default: cpu_abort(env, "Unknown or invalid MMU model\n"); return -1; } break; case -2: env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x08000000; break; case -3: env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x10000000; break; case -4: env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x10000000; break; #if defined(TARGET_PPC64) case -5: env->exception_index = POWERPC_EXCP_ISEG; env->error_code = 0; break; #endif } } else { switch (ret) { case -1: switch (env->mmu_model) { case POWERPC_MMU_SOFT_6xx: if (rw == 1) { env->exception_index = POWERPC_EXCP_DSTLB; env->error_code = 1 << 16; } else { env->exception_index = POWERPC_EXCP_DLTLB; env->error_code = 0; } env->spr[SPR_DMISS] = address; env->spr[SPR_DCMP] = 0x80000000 | ctx.ptem; tlb_miss: env->error_code |= ctx.key << 19; env->spr[SPR_HASH1] = ctx.pg_addr[0]; env->spr[SPR_HASH2] = ctx.pg_addr[1]; break; case POWERPC_MMU_SOFT_74xx: if (rw == 1) { env->exception_index = POWERPC_EXCP_DSTLB; } else { env->exception_index = POWERPC_EXCP_DLTLB; } tlb_miss_74xx: env->error_code = ctx.key << 19; env->spr[SPR_TLBMISS] = (address & ~((target_ulong)0x3)) | ((env->last_way + 1) & (env->nb_ways - 1)); env->spr[SPR_PTEHI] = 0x80000000 | ctx.ptem; break; case POWERPC_MMU_SOFT_4xx: case POWERPC_MMU_SOFT_4xx_Z: env->exception_index = POWERPC_EXCP_DTLB; env->error_code = 0; env->spr[SPR_40x_DEAR] = address; if (rw) env->spr[SPR_40x_ESR] = 0x00800000; else env->spr[SPR_40x_ESR] = 0x00000000; break; case POWERPC_MMU_32B: #if defined(TARGET_PPC64) case POWERPC_MMU_64B: case POWERPC_MMU_64BRIDGE: #endif env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) env->spr[SPR_DSISR] = 0x42000000; else env->spr[SPR_DSISR] = 0x40000000; break; case POWERPC_MMU_601: cpu_abort(env, "MMU model not implemented\n"); return -1; case POWERPC_MMU_BOOKE: cpu_abort(env, "MMU model not implemented\n"); return -1; case POWERPC_MMU_BOOKE_FSL: cpu_abort(env, "MMU model not implemented\n"); return -1; case POWERPC_MMU_REAL_4xx: cpu_abort(env, "PowerPC 401 should never raise any MMU " "exceptions\n"); return -1; default: cpu_abort(env, "Unknown or invalid MMU model\n"); return -1; } break; case -2: env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) env->spr[SPR_DSISR] = 0x0A000000; else env->spr[SPR_DSISR] = 0x08000000; break; case -4: switch (access_type) { case ACCESS_FLOAT: env->exception_index = POWERPC_EXCP_ALIGN; env->error_code = POWERPC_EXCP_ALIGN_FP; env->spr[SPR_DAR] = address; break; case ACCESS_RES: env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) env->spr[SPR_DSISR] = 0x06000000; else env->spr[SPR_DSISR] = 0x04000000; break; case ACCESS_EXT: env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) env->spr[SPR_DSISR] = 0x06100000; else env->spr[SPR_DSISR] = 0x04100000; break; default: printf("DSI: invalid exception (%d)\n", ret); env->exception_index = POWERPC_EXCP_PROGRAM; env->error_code = POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL; env->spr[SPR_DAR] = address; break; } break; #if defined(TARGET_PPC64) case -5: env->exception_index = POWERPC_EXCP_DSEG; env->error_code = 0; env->spr[SPR_DAR] = address; break; #endif } } #if 0 printf("%s: set exception to %d %02x\n", __func__, env->exception, env->error_code); #endif ret = 1; } return ret; }
{ "code": [ "#endif", "#endif", " case POWERPC_MMU_64BRIDGE:", " case POWERPC_MMU_64BRIDGE:" ], "line_no": [ 55, 55, 105, 105 ] }
int FUNC_0 (CPUState *VAR_0, target_ulong VAR_1, int VAR_2, int VAR_3, int VAR_4) { mmu_ctx_t ctx; int VAR_5; int VAR_6 = 0; if (VAR_2 == 2) { VAR_2 = 0; VAR_5 = ACCESS_CODE; } else { VAR_5 = ACCESS_INT; } VAR_6 = get_physical_address(VAR_0, &ctx, VAR_1, VAR_2, VAR_5, 1); if (VAR_6 == 0) { VAR_6 = tlb_set_page(VAR_0, VAR_1 & TARGET_PAGE_MASK, ctx.raddr & TARGET_PAGE_MASK, ctx.prot, VAR_3, VAR_4); } else if (VAR_6 < 0) { #if defined (DEBUG_MMU) if (loglevel != 0) cpu_dump_state(VAR_0, logfile, fprintf, 0); #endif if (VAR_5 == ACCESS_CODE) { switch (VAR_6) { case -1: switch (VAR_0->mmu_model) { case POWERPC_MMU_SOFT_6xx: VAR_0->exception_index = POWERPC_EXCP_IFTLB; VAR_0->error_code = 1 << 18; VAR_0->spr[SPR_IMISS] = VAR_1; VAR_0->spr[SPR_ICMP] = 0x80000000 | ctx.ptem; goto tlb_miss; case POWERPC_MMU_SOFT_74xx: VAR_0->exception_index = POWERPC_EXCP_IFTLB; goto tlb_miss_74xx; case POWERPC_MMU_SOFT_4xx: case POWERPC_MMU_SOFT_4xx_Z: VAR_0->exception_index = POWERPC_EXCP_ITLB; VAR_0->error_code = 0; VAR_0->spr[SPR_40x_DEAR] = VAR_1; VAR_0->spr[SPR_40x_ESR] = 0x00000000; break; case POWERPC_MMU_32B: #if defined(TARGET_PPC64) case POWERPC_MMU_64B: case POWERPC_MMU_64BRIDGE: #endif VAR_0->exception_index = POWERPC_EXCP_ISI; VAR_0->error_code = 0x40000000; break; case POWERPC_MMU_601: cpu_abort(VAR_0, "MMU model not implemented\n"); return -1; case POWERPC_MMU_BOOKE: cpu_abort(VAR_0, "MMU model not implemented\n"); return -1; case POWERPC_MMU_BOOKE_FSL: cpu_abort(VAR_0, "MMU model not implemented\n"); return -1; case POWERPC_MMU_REAL_4xx: cpu_abort(VAR_0, "PowerPC 401 should never raise any MMU " "exceptions\n"); return -1; default: cpu_abort(VAR_0, "Unknown or invalid MMU model\n"); return -1; } break; case -2: VAR_0->exception_index = POWERPC_EXCP_ISI; VAR_0->error_code = 0x08000000; break; case -3: VAR_0->exception_index = POWERPC_EXCP_ISI; VAR_0->error_code = 0x10000000; break; case -4: VAR_0->exception_index = POWERPC_EXCP_ISI; VAR_0->error_code = 0x10000000; break; #if defined(TARGET_PPC64) case -5: VAR_0->exception_index = POWERPC_EXCP_ISEG; VAR_0->error_code = 0; break; #endif } } else { switch (VAR_6) { case -1: switch (VAR_0->mmu_model) { case POWERPC_MMU_SOFT_6xx: if (VAR_2 == 1) { VAR_0->exception_index = POWERPC_EXCP_DSTLB; VAR_0->error_code = 1 << 16; } else { VAR_0->exception_index = POWERPC_EXCP_DLTLB; VAR_0->error_code = 0; } VAR_0->spr[SPR_DMISS] = VAR_1; VAR_0->spr[SPR_DCMP] = 0x80000000 | ctx.ptem; tlb_miss: VAR_0->error_code |= ctx.key << 19; VAR_0->spr[SPR_HASH1] = ctx.pg_addr[0]; VAR_0->spr[SPR_HASH2] = ctx.pg_addr[1]; break; case POWERPC_MMU_SOFT_74xx: if (VAR_2 == 1) { VAR_0->exception_index = POWERPC_EXCP_DSTLB; } else { VAR_0->exception_index = POWERPC_EXCP_DLTLB; } tlb_miss_74xx: VAR_0->error_code = ctx.key << 19; VAR_0->spr[SPR_TLBMISS] = (VAR_1 & ~((target_ulong)0x3)) | ((VAR_0->last_way + 1) & (VAR_0->nb_ways - 1)); VAR_0->spr[SPR_PTEHI] = 0x80000000 | ctx.ptem; break; case POWERPC_MMU_SOFT_4xx: case POWERPC_MMU_SOFT_4xx_Z: VAR_0->exception_index = POWERPC_EXCP_DTLB; VAR_0->error_code = 0; VAR_0->spr[SPR_40x_DEAR] = VAR_1; if (VAR_2) VAR_0->spr[SPR_40x_ESR] = 0x00800000; else VAR_0->spr[SPR_40x_ESR] = 0x00000000; break; case POWERPC_MMU_32B: #if defined(TARGET_PPC64) case POWERPC_MMU_64B: case POWERPC_MMU_64BRIDGE: #endif VAR_0->exception_index = POWERPC_EXCP_DSI; VAR_0->error_code = 0; VAR_0->spr[SPR_DAR] = VAR_1; if (VAR_2 == 1) VAR_0->spr[SPR_DSISR] = 0x42000000; else VAR_0->spr[SPR_DSISR] = 0x40000000; break; case POWERPC_MMU_601: cpu_abort(VAR_0, "MMU model not implemented\n"); return -1; case POWERPC_MMU_BOOKE: cpu_abort(VAR_0, "MMU model not implemented\n"); return -1; case POWERPC_MMU_BOOKE_FSL: cpu_abort(VAR_0, "MMU model not implemented\n"); return -1; case POWERPC_MMU_REAL_4xx: cpu_abort(VAR_0, "PowerPC 401 should never raise any MMU " "exceptions\n"); return -1; default: cpu_abort(VAR_0, "Unknown or invalid MMU model\n"); return -1; } break; case -2: VAR_0->exception_index = POWERPC_EXCP_DSI; VAR_0->error_code = 0; VAR_0->spr[SPR_DAR] = VAR_1; if (VAR_2 == 1) VAR_0->spr[SPR_DSISR] = 0x0A000000; else VAR_0->spr[SPR_DSISR] = 0x08000000; break; case -4: switch (VAR_5) { case ACCESS_FLOAT: VAR_0->exception_index = POWERPC_EXCP_ALIGN; VAR_0->error_code = POWERPC_EXCP_ALIGN_FP; VAR_0->spr[SPR_DAR] = VAR_1; break; case ACCESS_RES: VAR_0->exception_index = POWERPC_EXCP_DSI; VAR_0->error_code = 0; VAR_0->spr[SPR_DAR] = VAR_1; if (VAR_2 == 1) VAR_0->spr[SPR_DSISR] = 0x06000000; else VAR_0->spr[SPR_DSISR] = 0x04000000; break; case ACCESS_EXT: VAR_0->exception_index = POWERPC_EXCP_DSI; VAR_0->error_code = 0; VAR_0->spr[SPR_DAR] = VAR_1; if (VAR_2 == 1) VAR_0->spr[SPR_DSISR] = 0x06100000; else VAR_0->spr[SPR_DSISR] = 0x04100000; break; default: printf("DSI: invalid exception (%d)\n", VAR_6); VAR_0->exception_index = POWERPC_EXCP_PROGRAM; VAR_0->error_code = POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL; VAR_0->spr[SPR_DAR] = VAR_1; break; } break; #if defined(TARGET_PPC64) case -5: VAR_0->exception_index = POWERPC_EXCP_DSEG; VAR_0->error_code = 0; VAR_0->spr[SPR_DAR] = VAR_1; break; #endif } } #if 0 printf("%s: set exception to %d %02x\n", __func__, VAR_0->exception, VAR_0->error_code); #endif VAR_6 = 1; } return VAR_6; }
[ "int FUNC_0 (CPUState *VAR_0, target_ulong VAR_1, int VAR_2,\nint VAR_3, int VAR_4)\n{", "mmu_ctx_t ctx;", "int VAR_5;", "int VAR_6 = 0;", "if (VAR_2 == 2) {", "VAR_2 = 0;", "VAR_5 = ACCESS_CODE;", "} else {", "VAR_5 = ACCESS_INT;", "}", "VAR_6 = get_physical_address(VAR_0, &ctx, VAR_1, VAR_2, VAR_5, 1);", "if (VAR_6 == 0) {", "VAR_6 = tlb_set_page(VAR_0, VAR_1 & TARGET_PAGE_MASK,\nctx.raddr & TARGET_PAGE_MASK, ctx.prot,\nVAR_3, VAR_4);", "} else if (VAR_6 < 0) {", "#if defined (DEBUG_MMU)\nif (loglevel != 0)\ncpu_dump_state(VAR_0, logfile, fprintf, 0);", "#endif\nif (VAR_5 == ACCESS_CODE) {", "switch (VAR_6) {", "case -1:\nswitch (VAR_0->mmu_model) {", "case POWERPC_MMU_SOFT_6xx:\nVAR_0->exception_index = POWERPC_EXCP_IFTLB;", "VAR_0->error_code = 1 << 18;", "VAR_0->spr[SPR_IMISS] = VAR_1;", "VAR_0->spr[SPR_ICMP] = 0x80000000 | ctx.ptem;", "goto tlb_miss;", "case POWERPC_MMU_SOFT_74xx:\nVAR_0->exception_index = POWERPC_EXCP_IFTLB;", "goto tlb_miss_74xx;", "case POWERPC_MMU_SOFT_4xx:\ncase POWERPC_MMU_SOFT_4xx_Z:\nVAR_0->exception_index = POWERPC_EXCP_ITLB;", "VAR_0->error_code = 0;", "VAR_0->spr[SPR_40x_DEAR] = VAR_1;", "VAR_0->spr[SPR_40x_ESR] = 0x00000000;", "break;", "case POWERPC_MMU_32B:\n#if defined(TARGET_PPC64)\ncase POWERPC_MMU_64B:\ncase POWERPC_MMU_64BRIDGE:\n#endif\nVAR_0->exception_index = POWERPC_EXCP_ISI;", "VAR_0->error_code = 0x40000000;", "break;", "case POWERPC_MMU_601:\ncpu_abort(VAR_0, \"MMU model not implemented\\n\");", "return -1;", "case POWERPC_MMU_BOOKE:\ncpu_abort(VAR_0, \"MMU model not implemented\\n\");", "return -1;", "case POWERPC_MMU_BOOKE_FSL:\ncpu_abort(VAR_0, \"MMU model not implemented\\n\");", "return -1;", "case POWERPC_MMU_REAL_4xx:\ncpu_abort(VAR_0, \"PowerPC 401 should never raise any MMU \"\n\"exceptions\\n\");", "return -1;", "default:\ncpu_abort(VAR_0, \"Unknown or invalid MMU model\\n\");", "return -1;", "}", "break;", "case -2:\nVAR_0->exception_index = POWERPC_EXCP_ISI;", "VAR_0->error_code = 0x08000000;", "break;", "case -3:\nVAR_0->exception_index = POWERPC_EXCP_ISI;", "VAR_0->error_code = 0x10000000;", "break;", "case -4:\nVAR_0->exception_index = POWERPC_EXCP_ISI;", "VAR_0->error_code = 0x10000000;", "break;", "#if defined(TARGET_PPC64)\ncase -5:\nVAR_0->exception_index = POWERPC_EXCP_ISEG;", "VAR_0->error_code = 0;", "break;", "#endif\n}", "} else {", "switch (VAR_6) {", "case -1:\nswitch (VAR_0->mmu_model) {", "case POWERPC_MMU_SOFT_6xx:\nif (VAR_2 == 1) {", "VAR_0->exception_index = POWERPC_EXCP_DSTLB;", "VAR_0->error_code = 1 << 16;", "} else {", "VAR_0->exception_index = POWERPC_EXCP_DLTLB;", "VAR_0->error_code = 0;", "}", "VAR_0->spr[SPR_DMISS] = VAR_1;", "VAR_0->spr[SPR_DCMP] = 0x80000000 | ctx.ptem;", "tlb_miss:\nVAR_0->error_code |= ctx.key << 19;", "VAR_0->spr[SPR_HASH1] = ctx.pg_addr[0];", "VAR_0->spr[SPR_HASH2] = ctx.pg_addr[1];", "break;", "case POWERPC_MMU_SOFT_74xx:\nif (VAR_2 == 1) {", "VAR_0->exception_index = POWERPC_EXCP_DSTLB;", "} else {", "VAR_0->exception_index = POWERPC_EXCP_DLTLB;", "}", "tlb_miss_74xx:\nVAR_0->error_code = ctx.key << 19;", "VAR_0->spr[SPR_TLBMISS] = (VAR_1 & ~((target_ulong)0x3)) |\n((VAR_0->last_way + 1) & (VAR_0->nb_ways - 1));", "VAR_0->spr[SPR_PTEHI] = 0x80000000 | ctx.ptem;", "break;", "case POWERPC_MMU_SOFT_4xx:\ncase POWERPC_MMU_SOFT_4xx_Z:\nVAR_0->exception_index = POWERPC_EXCP_DTLB;", "VAR_0->error_code = 0;", "VAR_0->spr[SPR_40x_DEAR] = VAR_1;", "if (VAR_2)\nVAR_0->spr[SPR_40x_ESR] = 0x00800000;", "else\nVAR_0->spr[SPR_40x_ESR] = 0x00000000;", "break;", "case POWERPC_MMU_32B:\n#if defined(TARGET_PPC64)\ncase POWERPC_MMU_64B:\ncase POWERPC_MMU_64BRIDGE:\n#endif\nVAR_0->exception_index = POWERPC_EXCP_DSI;", "VAR_0->error_code = 0;", "VAR_0->spr[SPR_DAR] = VAR_1;", "if (VAR_2 == 1)\nVAR_0->spr[SPR_DSISR] = 0x42000000;", "else\nVAR_0->spr[SPR_DSISR] = 0x40000000;", "break;", "case POWERPC_MMU_601:\ncpu_abort(VAR_0, \"MMU model not implemented\\n\");", "return -1;", "case POWERPC_MMU_BOOKE:\ncpu_abort(VAR_0, \"MMU model not implemented\\n\");", "return -1;", "case POWERPC_MMU_BOOKE_FSL:\ncpu_abort(VAR_0, \"MMU model not implemented\\n\");", "return -1;", "case POWERPC_MMU_REAL_4xx:\ncpu_abort(VAR_0, \"PowerPC 401 should never raise any MMU \"\n\"exceptions\\n\");", "return -1;", "default:\ncpu_abort(VAR_0, \"Unknown or invalid MMU model\\n\");", "return -1;", "}", "break;", "case -2:\nVAR_0->exception_index = POWERPC_EXCP_DSI;", "VAR_0->error_code = 0;", "VAR_0->spr[SPR_DAR] = VAR_1;", "if (VAR_2 == 1)\nVAR_0->spr[SPR_DSISR] = 0x0A000000;", "else\nVAR_0->spr[SPR_DSISR] = 0x08000000;", "break;", "case -4:\nswitch (VAR_5) {", "case ACCESS_FLOAT:\nVAR_0->exception_index = POWERPC_EXCP_ALIGN;", "VAR_0->error_code = POWERPC_EXCP_ALIGN_FP;", "VAR_0->spr[SPR_DAR] = VAR_1;", "break;", "case ACCESS_RES:\nVAR_0->exception_index = POWERPC_EXCP_DSI;", "VAR_0->error_code = 0;", "VAR_0->spr[SPR_DAR] = VAR_1;", "if (VAR_2 == 1)\nVAR_0->spr[SPR_DSISR] = 0x06000000;", "else\nVAR_0->spr[SPR_DSISR] = 0x04000000;", "break;", "case ACCESS_EXT:\nVAR_0->exception_index = POWERPC_EXCP_DSI;", "VAR_0->error_code = 0;", "VAR_0->spr[SPR_DAR] = VAR_1;", "if (VAR_2 == 1)\nVAR_0->spr[SPR_DSISR] = 0x06100000;", "else\nVAR_0->spr[SPR_DSISR] = 0x04100000;", "break;", "default:\nprintf(\"DSI: invalid exception (%d)\\n\", VAR_6);", "VAR_0->exception_index = POWERPC_EXCP_PROGRAM;", "VAR_0->error_code =\nPOWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL;", "VAR_0->spr[SPR_DAR] = VAR_1;", "break;", "}", "break;", "#if defined(TARGET_PPC64)\ncase -5:\nVAR_0->exception_index = POWERPC_EXCP_DSEG;", "VAR_0->error_code = 0;", "VAR_0->spr[SPR_DAR] = VAR_1;", "break;", "#endif\n}", "}", "#if 0\nprintf(\"%s: set exception to %d %02x\\n\", __func__,\nVAR_0->exception, VAR_0->error_code);", "#endif\nVAR_6 = 1;", "}", "return VAR_6;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41, 43, 45 ], [ 47 ], [ 49, 51, 53 ], [ 55, 57 ], [ 59 ], [ 61, 65 ], [ 67, 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79, 81 ], [ 83 ], [ 85, 87, 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99, 101, 103, 105, 107, 109 ], [ 111 ], [ 113 ], [ 115, 119 ], [ 121 ], [ 123, 127 ], [ 129 ], [ 131, 135 ], [ 137 ], [ 139, 141, 143 ], [ 145 ], [ 147, 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157, 161 ], [ 163 ], [ 165 ], [ 167, 171 ], [ 173 ], [ 175 ], [ 177, 183 ], [ 185 ], [ 187 ], [ 189, 191, 195 ], [ 197 ], [ 199 ], [ 201, 203 ], [ 205 ], [ 207 ], [ 209, 213 ], [ 215, 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235, 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245, 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257, 261 ], [ 263, 265 ], [ 267 ], [ 269 ], [ 271, 273, 275 ], [ 277 ], [ 279 ], [ 281, 283 ], [ 285, 287 ], [ 289 ], [ 291, 293, 295, 297, 299, 301 ], [ 303 ], [ 305 ], [ 307, 309 ], [ 311, 313 ], [ 315 ], [ 317, 321 ], [ 323 ], [ 325, 329 ], [ 331 ], [ 333, 337 ], [ 339 ], [ 341, 343, 345 ], [ 347 ], [ 349, 351 ], [ 353 ], [ 355 ], [ 357 ], [ 359, 363 ], [ 365 ], [ 367 ], [ 369, 371 ], [ 373, 375 ], [ 377 ], [ 379, 383 ], [ 385, 389 ], [ 391 ], [ 393 ], [ 395 ], [ 397, 401 ], [ 403 ], [ 405 ], [ 407, 409 ], [ 411, 413 ], [ 415 ], [ 417, 421 ], [ 423 ], [ 425 ], [ 427, 429 ], [ 431, 433 ], [ 435 ], [ 437, 439 ], [ 441 ], [ 443, 445 ], [ 447 ], [ 449 ], [ 451 ], [ 453 ], [ 455, 457, 461 ], [ 463 ], [ 465 ], [ 467 ], [ 469, 471 ], [ 473 ], [ 475, 477, 479 ], [ 481, 483 ], [ 485 ], [ 489 ], [ 491 ] ]
8,886
static inline void writer_print_string(WriterContext *wctx, const char *key, const char *val) { wctx->writer->print_string(wctx, key, val); wctx->nb_item++; }
false
FFmpeg
0491a2a07a44f6e5e6f34081835e402c07025fd2
static inline void writer_print_string(WriterContext *wctx, const char *key, const char *val) { wctx->writer->print_string(wctx, key, val); wctx->nb_item++; }
{ "code": [], "line_no": [] }
static inline void FUNC_0(WriterContext *VAR_0, const char *VAR_1, const char *VAR_2) { VAR_0->writer->print_string(VAR_0, VAR_1, VAR_2); VAR_0->nb_item++; }
[ "static inline void FUNC_0(WriterContext *VAR_0,\nconst char *VAR_1, const char *VAR_2)\n{", "VAR_0->writer->print_string(VAR_0, VAR_1, VAR_2);", "VAR_0->nb_item++;", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ] ]
8,887
static av_cold int cinvideo_decode_init(AVCodecContext *avctx) { CinVideoContext *cin = avctx->priv_data; unsigned int i; cin->avctx = avctx; avctx->pix_fmt = AV_PIX_FMT_PAL8; cin->frame.data[0] = NULL; cin->bitmap_size = avctx->width * avctx->height; for (i = 0; i < 3; ++i) { cin->bitmap_table[i] = av_mallocz(cin->bitmap_size); if (!cin->bitmap_table[i]) av_log(avctx, AV_LOG_ERROR, "Can't allocate bitmap buffers.\n"); } return 0; }
false
FFmpeg
3b199d29cd597a3518136d78860e172060b9e83d
static av_cold int cinvideo_decode_init(AVCodecContext *avctx) { CinVideoContext *cin = avctx->priv_data; unsigned int i; cin->avctx = avctx; avctx->pix_fmt = AV_PIX_FMT_PAL8; cin->frame.data[0] = NULL; cin->bitmap_size = avctx->width * avctx->height; for (i = 0; i < 3; ++i) { cin->bitmap_table[i] = av_mallocz(cin->bitmap_size); if (!cin->bitmap_table[i]) av_log(avctx, AV_LOG_ERROR, "Can't allocate bitmap buffers.\n"); } return 0; }
{ "code": [], "line_no": [] }
static av_cold int FUNC_0(AVCodecContext *avctx) { CinVideoContext *cin = avctx->priv_data; unsigned int VAR_0; cin->avctx = avctx; avctx->pix_fmt = AV_PIX_FMT_PAL8; cin->frame.data[0] = NULL; cin->bitmap_size = avctx->width * avctx->height; for (VAR_0 = 0; VAR_0 < 3; ++VAR_0) { cin->bitmap_table[VAR_0] = av_mallocz(cin->bitmap_size); if (!cin->bitmap_table[VAR_0]) av_log(avctx, AV_LOG_ERROR, "Can't allocate bitmap buffers.\n"); } return 0; }
[ "static av_cold int FUNC_0(AVCodecContext *avctx)\n{", "CinVideoContext *cin = avctx->priv_data;", "unsigned int VAR_0;", "cin->avctx = avctx;", "avctx->pix_fmt = AV_PIX_FMT_PAL8;", "cin->frame.data[0] = NULL;", "cin->bitmap_size = avctx->width * avctx->height;", "for (VAR_0 = 0; VAR_0 < 3; ++VAR_0) {", "cin->bitmap_table[VAR_0] = av_mallocz(cin->bitmap_size);", "if (!cin->bitmap_table[VAR_0])\nav_log(avctx, AV_LOG_ERROR, \"Can't allocate bitmap buffers.\\n\");", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27, 29 ], [ 31 ], [ 35 ], [ 37 ] ]
8,888
static int add_file(AVFormatContext *avf, char *filename, ConcatFile **rfile, unsigned *nb_files_alloc) { ConcatContext *cat = avf->priv_data; ConcatFile *file; char *url; size_t url_len; url_len = strlen(avf->filename) + strlen(filename) + 16; if (!(url = av_malloc(url_len))) return AVERROR(ENOMEM); ff_make_absolute_url(url, url_len, avf->filename, filename); av_free(filename); if (cat->nb_files >= *nb_files_alloc) { unsigned n = FFMAX(*nb_files_alloc * 2, 16); ConcatFile *new_files; if (n <= cat->nb_files || n > SIZE_MAX / sizeof(*cat->files) || !(new_files = av_realloc(cat->files, n * sizeof(*cat->files)))) return AVERROR(ENOMEM); cat->files = new_files; *nb_files_alloc = n; } file = &cat->files[cat->nb_files++]; memset(file, 0, sizeof(*file)); *rfile = file; file->url = url; file->start_time = AV_NOPTS_VALUE; file->duration = AV_NOPTS_VALUE; return 0; }
false
FFmpeg
8976ef7aec4c62e41a0abb50d2bf4dbfa3508e2a
static int add_file(AVFormatContext *avf, char *filename, ConcatFile **rfile, unsigned *nb_files_alloc) { ConcatContext *cat = avf->priv_data; ConcatFile *file; char *url; size_t url_len; url_len = strlen(avf->filename) + strlen(filename) + 16; if (!(url = av_malloc(url_len))) return AVERROR(ENOMEM); ff_make_absolute_url(url, url_len, avf->filename, filename); av_free(filename); if (cat->nb_files >= *nb_files_alloc) { unsigned n = FFMAX(*nb_files_alloc * 2, 16); ConcatFile *new_files; if (n <= cat->nb_files || n > SIZE_MAX / sizeof(*cat->files) || !(new_files = av_realloc(cat->files, n * sizeof(*cat->files)))) return AVERROR(ENOMEM); cat->files = new_files; *nb_files_alloc = n; } file = &cat->files[cat->nb_files++]; memset(file, 0, sizeof(*file)); *rfile = file; file->url = url; file->start_time = AV_NOPTS_VALUE; file->duration = AV_NOPTS_VALUE; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0, char *VAR_1, ConcatFile **VAR_2, unsigned *VAR_3) { ConcatContext *cat = VAR_0->priv_data; ConcatFile *file; char *VAR_4; size_t url_len; url_len = strlen(VAR_0->VAR_1) + strlen(VAR_1) + 16; if (!(VAR_4 = av_malloc(url_len))) return AVERROR(ENOMEM); ff_make_absolute_url(VAR_4, url_len, VAR_0->VAR_1, VAR_1); av_free(VAR_1); if (cat->nb_files >= *VAR_3) { unsigned VAR_5 = FFMAX(*VAR_3 * 2, 16); ConcatFile *new_files; if (VAR_5 <= cat->nb_files || VAR_5 > SIZE_MAX / sizeof(*cat->files) || !(new_files = av_realloc(cat->files, VAR_5 * sizeof(*cat->files)))) return AVERROR(ENOMEM); cat->files = new_files; *VAR_3 = VAR_5; } file = &cat->files[cat->nb_files++]; memset(file, 0, sizeof(*file)); *VAR_2 = file; file->VAR_4 = VAR_4; file->start_time = AV_NOPTS_VALUE; file->duration = AV_NOPTS_VALUE; return 0; }
[ "static int FUNC_0(AVFormatContext *VAR_0, char *VAR_1, ConcatFile **VAR_2,\nunsigned *VAR_3)\n{", "ConcatContext *cat = VAR_0->priv_data;", "ConcatFile *file;", "char *VAR_4;", "size_t url_len;", "url_len = strlen(VAR_0->VAR_1) + strlen(VAR_1) + 16;", "if (!(VAR_4 = av_malloc(url_len)))\nreturn AVERROR(ENOMEM);", "ff_make_absolute_url(VAR_4, url_len, VAR_0->VAR_1, VAR_1);", "av_free(VAR_1);", "if (cat->nb_files >= *VAR_3) {", "unsigned VAR_5 = FFMAX(*VAR_3 * 2, 16);", "ConcatFile *new_files;", "if (VAR_5 <= cat->nb_files || VAR_5 > SIZE_MAX / sizeof(*cat->files) ||\n!(new_files = av_realloc(cat->files, VAR_5 * sizeof(*cat->files))))\nreturn AVERROR(ENOMEM);", "cat->files = new_files;", "*VAR_3 = VAR_5;", "}", "file = &cat->files[cat->nb_files++];", "memset(file, 0, sizeof(*file));", "*VAR_2 = file;", "file->VAR_4 = VAR_4;", "file->start_time = AV_NOPTS_VALUE;", "file->duration = AV_NOPTS_VALUE;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19, 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35, 37, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ] ]
8,889
int kvm_arch_remove_hw_breakpoint(target_ulong addr, target_ulong len, int type) { return -EINVAL; }
true
qemu
88365d17d586bcf0d9f4432447db345f72278a2a
int kvm_arch_remove_hw_breakpoint(target_ulong addr, target_ulong len, int type) { return -EINVAL; }
{ "code": [ " return -EINVAL;", "int kvm_arch_remove_hw_breakpoint(target_ulong addr, target_ulong len, int type)", " return -EINVAL;" ], "line_no": [ 5, 1, 5 ] }
int FUNC_0(target_ulong VAR_0, target_ulong VAR_1, int VAR_2) { return -EINVAL; }
[ "int FUNC_0(target_ulong VAR_0, target_ulong VAR_1, int VAR_2)\n{", "return -EINVAL;", "}" ]
[ 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
8,890
static double compute_target_time(double frame_current_pts, VideoState *is) { double delay, sync_threshold, diff; /* compute nominal delay */ delay = frame_current_pts - is->frame_last_pts; if (delay <= 0 || delay >= 10.0) { /* if incorrect delay, use previous one */ delay = is->frame_last_delay; } else { is->frame_last_delay = delay; } is->frame_last_pts = frame_current_pts; /* update delay to follow master synchronisation source */ if (((is->av_sync_type == AV_SYNC_AUDIO_MASTER && is->audio_st) || is->av_sync_type == AV_SYNC_EXTERNAL_CLOCK)) { /* if video is slave, we try to correct big delays by duplicating or deleting a frame */ diff = get_video_clock(is) - get_master_clock(is); /* skip or repeat frame. We take into account the delay to compute the threshold. I still don't know if it is the best guess */ sync_threshold = FFMAX(AV_SYNC_THRESHOLD, delay); if (fabs(diff) < AV_NOSYNC_THRESHOLD) { if (diff <= -sync_threshold) delay = 0; else if (diff >= sync_threshold) delay = 2 * delay; } } is->frame_timer += delay; av_log(NULL, AV_LOG_TRACE, "video: delay=%0.3f pts=%0.3f A-V=%f\n", delay, frame_current_pts, -diff); return is->frame_timer; }
true
FFmpeg
06f4b1e37a08f3fd269ecbfeb0181129e5bfc86e
static double compute_target_time(double frame_current_pts, VideoState *is) { double delay, sync_threshold, diff; delay = frame_current_pts - is->frame_last_pts; if (delay <= 0 || delay >= 10.0) { delay = is->frame_last_delay; } else { is->frame_last_delay = delay; } is->frame_last_pts = frame_current_pts; if (((is->av_sync_type == AV_SYNC_AUDIO_MASTER && is->audio_st) || is->av_sync_type == AV_SYNC_EXTERNAL_CLOCK)) { diff = get_video_clock(is) - get_master_clock(is); sync_threshold = FFMAX(AV_SYNC_THRESHOLD, delay); if (fabs(diff) < AV_NOSYNC_THRESHOLD) { if (diff <= -sync_threshold) delay = 0; else if (diff >= sync_threshold) delay = 2 * delay; } } is->frame_timer += delay; av_log(NULL, AV_LOG_TRACE, "video: delay=%0.3f pts=%0.3f A-V=%f\n", delay, frame_current_pts, -diff); return is->frame_timer; }
{ "code": [ " double delay, sync_threshold, diff;" ], "line_no": [ 5 ] }
static double FUNC_0(double VAR_0, VideoState *VAR_1) { double VAR_2, VAR_3, VAR_4; VAR_2 = VAR_0 - VAR_1->frame_last_pts; if (VAR_2 <= 0 || VAR_2 >= 10.0) { VAR_2 = VAR_1->frame_last_delay; } else { VAR_1->frame_last_delay = VAR_2; } VAR_1->frame_last_pts = VAR_0; if (((VAR_1->av_sync_type == AV_SYNC_AUDIO_MASTER && VAR_1->audio_st) || VAR_1->av_sync_type == AV_SYNC_EXTERNAL_CLOCK)) { VAR_4 = get_video_clock(VAR_1) - get_master_clock(VAR_1); VAR_3 = FFMAX(AV_SYNC_THRESHOLD, VAR_2); if (fabs(VAR_4) < AV_NOSYNC_THRESHOLD) { if (VAR_4 <= -VAR_3) VAR_2 = 0; else if (VAR_4 >= VAR_3) VAR_2 = 2 * VAR_2; } } VAR_1->frame_timer += VAR_2; av_log(NULL, AV_LOG_TRACE, "video: VAR_2=%0.3f pts=%0.3f A-V=%f\n", VAR_2, VAR_0, -VAR_4); return VAR_1->frame_timer; }
[ "static double FUNC_0(double VAR_0, VideoState *VAR_1)\n{", "double VAR_2, VAR_3, VAR_4;", "VAR_2 = VAR_0 - VAR_1->frame_last_pts;", "if (VAR_2 <= 0 || VAR_2 >= 10.0) {", "VAR_2 = VAR_1->frame_last_delay;", "} else {", "VAR_1->frame_last_delay = VAR_2;", "}", "VAR_1->frame_last_pts = VAR_0;", "if (((VAR_1->av_sync_type == AV_SYNC_AUDIO_MASTER && VAR_1->audio_st) ||\nVAR_1->av_sync_type == AV_SYNC_EXTERNAL_CLOCK)) {", "VAR_4 = get_video_clock(VAR_1) - get_master_clock(VAR_1);", "VAR_3 = FFMAX(AV_SYNC_THRESHOLD, VAR_2);", "if (fabs(VAR_4) < AV_NOSYNC_THRESHOLD) {", "if (VAR_4 <= -VAR_3)\nVAR_2 = 0;", "else if (VAR_4 >= VAR_3)\nVAR_2 = 2 * VAR_2;", "}", "}", "VAR_1->frame_timer += VAR_2;", "av_log(NULL, AV_LOG_TRACE, \"video: VAR_2=%0.3f pts=%0.3f A-V=%f\\n\",\nVAR_2, VAR_0, -VAR_4);", "return VAR_1->frame_timer;", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 31, 33 ], [ 39 ], [ 49 ], [ 51 ], [ 53, 55 ], [ 57, 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69, 71 ], [ 75 ], [ 77 ] ]
8,891
long target_mmap(target_ulong start, target_ulong len, int prot, int flags, int fd, target_ulong offset) { target_ulong ret, end, real_start, real_end, retaddr, host_offset, host_len; long host_start; #if defined(__alpha__) || defined(__sparc__) || defined(__x86_64__) || \ defined(__ia64) || defined(__mips__) static target_ulong last_start = 0x40000000; #elif defined(__CYGWIN__) /* Cygwin doesn't have a whole lot of address space. */ static target_ulong last_start = 0x18000000; #endif #ifdef DEBUG_MMAP { printf("mmap: start=0x%lx len=0x%lx prot=%c%c%c flags=", start, len, prot & PROT_READ ? 'r' : '-', prot & PROT_WRITE ? 'w' : '-', prot & PROT_EXEC ? 'x' : '-'); if (flags & MAP_FIXED) printf("MAP_FIXED "); if (flags & MAP_ANONYMOUS) printf("MAP_ANON "); switch(flags & MAP_TYPE) { case MAP_PRIVATE: printf("MAP_PRIVATE "); break; case MAP_SHARED: printf("MAP_SHARED "); break; default: printf("[MAP_TYPE=0x%x] ", flags & MAP_TYPE); break; } printf("fd=%d offset=%lx\n", fd, offset); } #endif if (offset & ~TARGET_PAGE_MASK) { errno = EINVAL; return -1; } len = TARGET_PAGE_ALIGN(len); if (len == 0) return start; real_start = start & qemu_host_page_mask; if (!(flags & MAP_FIXED)) { #if defined(__alpha__) || defined(__sparc__) || defined(__x86_64__) || \ defined(__ia64) || defined(__mips__) || defined(__CYGWIN__) /* tell the kernel to search at the same place as i386 */ if (real_start == 0) { real_start = last_start; last_start += HOST_PAGE_ALIGN(len); } #endif if (0 && qemu_host_page_size != qemu_real_host_page_size) { /* NOTE: this code is only for debugging with '-p' option */ /* ??? Can also occur when TARGET_PAGE_SIZE > host page size. */ /* reserve a memory area */ /* ??? This needs fixing for remapping. */ abort(); host_len = HOST_PAGE_ALIGN(len) + qemu_host_page_size - TARGET_PAGE_SIZE; real_start = (long)mmap(g2h(real_start), host_len, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (real_start == -1) return real_start; real_end = real_start + host_len; start = HOST_PAGE_ALIGN(real_start); end = start + HOST_PAGE_ALIGN(len); if (start > real_start) munmap((void *)real_start, start - real_start); if (end < real_end) munmap((void *)end, real_end - end); /* use it as a fixed mapping */ flags |= MAP_FIXED; } else { /* if not fixed, no need to do anything */ host_offset = offset & qemu_host_page_mask; host_len = len + offset - host_offset; host_start = (long)mmap(real_start ? g2h(real_start) : NULL, host_len, prot, flags, fd, host_offset); if (host_start == -1) return host_start; /* update start so that it points to the file position at 'offset' */ if (!(flags & MAP_ANONYMOUS)) host_start += offset - host_offset; start = h2g(host_start); goto the_end1; } } if (start & ~TARGET_PAGE_MASK) { errno = EINVAL; return -1; } end = start + len; real_end = HOST_PAGE_ALIGN(end); /* worst case: we cannot map the file because the offset is not aligned, so we read it */ if (!(flags & MAP_ANONYMOUS) && (offset & ~qemu_host_page_mask) != (start & ~qemu_host_page_mask)) { /* msync() won't work here, so we return an error if write is possible while it is a shared mapping */ if ((flags & MAP_TYPE) == MAP_SHARED && (prot & PROT_WRITE)) { errno = EINVAL; return -1; } retaddr = target_mmap(start, len, prot | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (retaddr == -1) return retaddr; pread(fd, g2h(start), len, offset); if (!(prot & PROT_WRITE)) { ret = target_mprotect(start, len, prot); if (ret != 0) return ret; } goto the_end; } /* handle the start of the mapping */ if (start > real_start) { if (real_end == real_start + qemu_host_page_size) { /* one single host page */ ret = mmap_frag(real_start, start, end, prot, flags, fd, offset); if (ret == -1) return ret; goto the_end1; } ret = mmap_frag(real_start, start, real_start + qemu_host_page_size, prot, flags, fd, offset); if (ret == -1) return ret; real_start += qemu_host_page_size; } /* handle the end of the mapping */ if (end < real_end) { ret = mmap_frag(real_end - qemu_host_page_size, real_end - qemu_host_page_size, real_end, prot, flags, fd, offset + real_end - qemu_host_page_size - start); if (ret == -1) return ret; real_end -= qemu_host_page_size; } /* map the middle (easier) */ if (real_start < real_end) { unsigned long offset1; if (flags & MAP_ANONYMOUS) offset1 = 0; else offset1 = offset + real_start - start; ret = (long)mmap(g2h(real_start), real_end - real_start, prot, flags, fd, offset1); if (ret == -1) return ret; } the_end1: page_set_flags(start, start + len, prot | PAGE_VALID); the_end: #ifdef DEBUG_MMAP printf("ret=0x%lx\n", (long)start); page_dump(stdout); printf("\n"); #endif return start; }
true
qemu
4118a97030aa9bd1d520d1d06bbe0655d829df04
long target_mmap(target_ulong start, target_ulong len, int prot, int flags, int fd, target_ulong offset) { target_ulong ret, end, real_start, real_end, retaddr, host_offset, host_len; long host_start; #if defined(__alpha__) || defined(__sparc__) || defined(__x86_64__) || \ defined(__ia64) || defined(__mips__) static target_ulong last_start = 0x40000000; #elif defined(__CYGWIN__) static target_ulong last_start = 0x18000000; #endif #ifdef DEBUG_MMAP { printf("mmap: start=0x%lx len=0x%lx prot=%c%c%c flags=", start, len, prot & PROT_READ ? 'r' : '-', prot & PROT_WRITE ? 'w' : '-', prot & PROT_EXEC ? 'x' : '-'); if (flags & MAP_FIXED) printf("MAP_FIXED "); if (flags & MAP_ANONYMOUS) printf("MAP_ANON "); switch(flags & MAP_TYPE) { case MAP_PRIVATE: printf("MAP_PRIVATE "); break; case MAP_SHARED: printf("MAP_SHARED "); break; default: printf("[MAP_TYPE=0x%x] ", flags & MAP_TYPE); break; } printf("fd=%d offset=%lx\n", fd, offset); } #endif if (offset & ~TARGET_PAGE_MASK) { errno = EINVAL; return -1; } len = TARGET_PAGE_ALIGN(len); if (len == 0) return start; real_start = start & qemu_host_page_mask; if (!(flags & MAP_FIXED)) { #if defined(__alpha__) || defined(__sparc__) || defined(__x86_64__) || \ defined(__ia64) || defined(__mips__) || defined(__CYGWIN__) if (real_start == 0) { real_start = last_start; last_start += HOST_PAGE_ALIGN(len); } #endif if (0 && qemu_host_page_size != qemu_real_host_page_size) { abort(); host_len = HOST_PAGE_ALIGN(len) + qemu_host_page_size - TARGET_PAGE_SIZE; real_start = (long)mmap(g2h(real_start), host_len, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (real_start == -1) return real_start; real_end = real_start + host_len; start = HOST_PAGE_ALIGN(real_start); end = start + HOST_PAGE_ALIGN(len); if (start > real_start) munmap((void *)real_start, start - real_start); if (end < real_end) munmap((void *)end, real_end - end); flags |= MAP_FIXED; } else { host_offset = offset & qemu_host_page_mask; host_len = len + offset - host_offset; host_start = (long)mmap(real_start ? g2h(real_start) : NULL, host_len, prot, flags, fd, host_offset); if (host_start == -1) return host_start; if (!(flags & MAP_ANONYMOUS)) host_start += offset - host_offset; start = h2g(host_start); goto the_end1; } } if (start & ~TARGET_PAGE_MASK) { errno = EINVAL; return -1; } end = start + len; real_end = HOST_PAGE_ALIGN(end); if (!(flags & MAP_ANONYMOUS) && (offset & ~qemu_host_page_mask) != (start & ~qemu_host_page_mask)) { if ((flags & MAP_TYPE) == MAP_SHARED && (prot & PROT_WRITE)) { errno = EINVAL; return -1; } retaddr = target_mmap(start, len, prot | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (retaddr == -1) return retaddr; pread(fd, g2h(start), len, offset); if (!(prot & PROT_WRITE)) { ret = target_mprotect(start, len, prot); if (ret != 0) return ret; } goto the_end; } if (start > real_start) { if (real_end == real_start + qemu_host_page_size) { ret = mmap_frag(real_start, start, end, prot, flags, fd, offset); if (ret == -1) return ret; goto the_end1; } ret = mmap_frag(real_start, start, real_start + qemu_host_page_size, prot, flags, fd, offset); if (ret == -1) return ret; real_start += qemu_host_page_size; } if (end < real_end) { ret = mmap_frag(real_end - qemu_host_page_size, real_end - qemu_host_page_size, real_end, prot, flags, fd, offset + real_end - qemu_host_page_size - start); if (ret == -1) return ret; real_end -= qemu_host_page_size; } if (real_start < real_end) { unsigned long offset1; if (flags & MAP_ANONYMOUS) offset1 = 0; else offset1 = offset + real_start - start; ret = (long)mmap(g2h(real_start), real_end - real_start, prot, flags, fd, offset1); if (ret == -1) return ret; } the_end1: page_set_flags(start, start + len, prot | PAGE_VALID); the_end: #ifdef DEBUG_MMAP printf("ret=0x%lx\n", (long)start); page_dump(stdout); printf("\n"); #endif return start; }
{ "code": [ " munmap((void *)real_start, start - real_start);", " munmap((void *)end, real_end - end);" ], "line_no": [ 147, 151 ] }
long FUNC_0(target_ulong VAR_0, target_ulong VAR_1, int VAR_2, int VAR_3, int VAR_4, target_ulong VAR_5) { target_ulong ret, end, real_start, real_end, retaddr, host_offset, host_len; long VAR_6; #if defined(__alpha__) || defined(__sparc__) || defined(__x86_64__) || \ defined(__ia64) || defined(__mips__) static target_ulong last_start = 0x40000000; #elif defined(__CYGWIN__) static target_ulong last_start = 0x18000000; #endif #ifdef DEBUG_MMAP { printf("mmap: VAR_0=0x%lx VAR_1=0x%lx VAR_2=%c%c%c VAR_3=", VAR_0, VAR_1, VAR_2 & PROT_READ ? 'r' : '-', VAR_2 & PROT_WRITE ? 'w' : '-', VAR_2 & PROT_EXEC ? 'x' : '-'); if (VAR_3 & MAP_FIXED) printf("MAP_FIXED "); if (VAR_3 & MAP_ANONYMOUS) printf("MAP_ANON "); switch(VAR_3 & MAP_TYPE) { case MAP_PRIVATE: printf("MAP_PRIVATE "); break; case MAP_SHARED: printf("MAP_SHARED "); break; default: printf("[MAP_TYPE=0x%x] ", VAR_3 & MAP_TYPE); break; } printf("VAR_4=%d VAR_5=%lx\n", VAR_4, VAR_5); } #endif if (VAR_5 & ~TARGET_PAGE_MASK) { errno = EINVAL; return -1; } VAR_1 = TARGET_PAGE_ALIGN(VAR_1); if (VAR_1 == 0) return VAR_0; real_start = VAR_0 & qemu_host_page_mask; if (!(VAR_3 & MAP_FIXED)) { #if defined(__alpha__) || defined(__sparc__) || defined(__x86_64__) || \ defined(__ia64) || defined(__mips__) || defined(__CYGWIN__) if (real_start == 0) { real_start = last_start; last_start += HOST_PAGE_ALIGN(VAR_1); } #endif if (0 && qemu_host_page_size != qemu_real_host_page_size) { abort(); host_len = HOST_PAGE_ALIGN(VAR_1) + qemu_host_page_size - TARGET_PAGE_SIZE; real_start = (long)mmap(g2h(real_start), host_len, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (real_start == -1) return real_start; real_end = real_start + host_len; VAR_0 = HOST_PAGE_ALIGN(real_start); end = VAR_0 + HOST_PAGE_ALIGN(VAR_1); if (VAR_0 > real_start) munmap((void *)real_start, VAR_0 - real_start); if (end < real_end) munmap((void *)end, real_end - end); VAR_3 |= MAP_FIXED; } else { host_offset = VAR_5 & qemu_host_page_mask; host_len = VAR_1 + VAR_5 - host_offset; VAR_6 = (long)mmap(real_start ? g2h(real_start) : NULL, host_len, VAR_2, VAR_3, VAR_4, host_offset); if (VAR_6 == -1) return VAR_6; if (!(VAR_3 & MAP_ANONYMOUS)) VAR_6 += VAR_5 - host_offset; VAR_0 = h2g(VAR_6); goto the_end1; } } if (VAR_0 & ~TARGET_PAGE_MASK) { errno = EINVAL; return -1; } end = VAR_0 + VAR_1; real_end = HOST_PAGE_ALIGN(end); if (!(VAR_3 & MAP_ANONYMOUS) && (VAR_5 & ~qemu_host_page_mask) != (VAR_0 & ~qemu_host_page_mask)) { if ((VAR_3 & MAP_TYPE) == MAP_SHARED && (VAR_2 & PROT_WRITE)) { errno = EINVAL; return -1; } retaddr = FUNC_0(VAR_0, VAR_1, VAR_2 | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (retaddr == -1) return retaddr; pread(VAR_4, g2h(VAR_0), VAR_1, VAR_5); if (!(VAR_2 & PROT_WRITE)) { ret = target_mprotect(VAR_0, VAR_1, VAR_2); if (ret != 0) return ret; } goto the_end; } if (VAR_0 > real_start) { if (real_end == real_start + qemu_host_page_size) { ret = mmap_frag(real_start, VAR_0, end, VAR_2, VAR_3, VAR_4, VAR_5); if (ret == -1) return ret; goto the_end1; } ret = mmap_frag(real_start, VAR_0, real_start + qemu_host_page_size, VAR_2, VAR_3, VAR_4, VAR_5); if (ret == -1) return ret; real_start += qemu_host_page_size; } if (end < real_end) { ret = mmap_frag(real_end - qemu_host_page_size, real_end - qemu_host_page_size, real_end, VAR_2, VAR_3, VAR_4, VAR_5 + real_end - qemu_host_page_size - VAR_0); if (ret == -1) return ret; real_end -= qemu_host_page_size; } if (real_start < real_end) { unsigned long VAR_7; if (VAR_3 & MAP_ANONYMOUS) VAR_7 = 0; else VAR_7 = VAR_5 + real_start - VAR_0; ret = (long)mmap(g2h(real_start), real_end - real_start, VAR_2, VAR_3, VAR_4, VAR_7); if (ret == -1) return ret; } the_end1: page_set_flags(VAR_0, VAR_0 + VAR_1, VAR_2 | PAGE_VALID); the_end: #ifdef DEBUG_MMAP printf("ret=0x%lx\n", (long)VAR_0); page_dump(stdout); printf("\n"); #endif return VAR_0; }
[ "long FUNC_0(target_ulong VAR_0, target_ulong VAR_1, int VAR_2,\nint VAR_3, int VAR_4, target_ulong VAR_5)\n{", "target_ulong ret, end, real_start, real_end, retaddr, host_offset, host_len;", "long VAR_6;", "#if defined(__alpha__) || defined(__sparc__) || defined(__x86_64__) || \\\ndefined(__ia64) || defined(__mips__)\nstatic target_ulong last_start = 0x40000000;", "#elif defined(__CYGWIN__)\nstatic target_ulong last_start = 0x18000000;", "#endif\n#ifdef DEBUG_MMAP\n{", "printf(\"mmap: VAR_0=0x%lx VAR_1=0x%lx VAR_2=%c%c%c VAR_3=\",\nVAR_0, VAR_1,\nVAR_2 & PROT_READ ? 'r' : '-',\nVAR_2 & PROT_WRITE ? 'w' : '-',\nVAR_2 & PROT_EXEC ? 'x' : '-');", "if (VAR_3 & MAP_FIXED)\nprintf(\"MAP_FIXED \");", "if (VAR_3 & MAP_ANONYMOUS)\nprintf(\"MAP_ANON \");", "switch(VAR_3 & MAP_TYPE) {", "case MAP_PRIVATE:\nprintf(\"MAP_PRIVATE \");", "break;", "case MAP_SHARED:\nprintf(\"MAP_SHARED \");", "break;", "default:\nprintf(\"[MAP_TYPE=0x%x] \", VAR_3 & MAP_TYPE);", "break;", "}", "printf(\"VAR_4=%d VAR_5=%lx\\n\", VAR_4, VAR_5);", "}", "#endif\nif (VAR_5 & ~TARGET_PAGE_MASK) {", "errno = EINVAL;", "return -1;", "}", "VAR_1 = TARGET_PAGE_ALIGN(VAR_1);", "if (VAR_1 == 0)\nreturn VAR_0;", "real_start = VAR_0 & qemu_host_page_mask;", "if (!(VAR_3 & MAP_FIXED)) {", "#if defined(__alpha__) || defined(__sparc__) || defined(__x86_64__) || \\\ndefined(__ia64) || defined(__mips__) || defined(__CYGWIN__)\nif (real_start == 0) {", "real_start = last_start;", "last_start += HOST_PAGE_ALIGN(VAR_1);", "}", "#endif\nif (0 && qemu_host_page_size != qemu_real_host_page_size) {", "abort();", "host_len = HOST_PAGE_ALIGN(VAR_1) + qemu_host_page_size - TARGET_PAGE_SIZE;", "real_start = (long)mmap(g2h(real_start), host_len, PROT_NONE,\nMAP_PRIVATE | MAP_ANONYMOUS, -1, 0);", "if (real_start == -1)\nreturn real_start;", "real_end = real_start + host_len;", "VAR_0 = HOST_PAGE_ALIGN(real_start);", "end = VAR_0 + HOST_PAGE_ALIGN(VAR_1);", "if (VAR_0 > real_start)\nmunmap((void *)real_start, VAR_0 - real_start);", "if (end < real_end)\nmunmap((void *)end, real_end - end);", "VAR_3 |= MAP_FIXED;", "} else {", "host_offset = VAR_5 & qemu_host_page_mask;", "host_len = VAR_1 + VAR_5 - host_offset;", "VAR_6 = (long)mmap(real_start ? g2h(real_start) : NULL,\nhost_len, VAR_2, VAR_3, VAR_4, host_offset);", "if (VAR_6 == -1)\nreturn VAR_6;", "if (!(VAR_3 & MAP_ANONYMOUS))\nVAR_6 += VAR_5 - host_offset;", "VAR_0 = h2g(VAR_6);", "goto the_end1;", "}", "}", "if (VAR_0 & ~TARGET_PAGE_MASK) {", "errno = EINVAL;", "return -1;", "}", "end = VAR_0 + VAR_1;", "real_end = HOST_PAGE_ALIGN(end);", "if (!(VAR_3 & MAP_ANONYMOUS) &&\n(VAR_5 & ~qemu_host_page_mask) != (VAR_0 & ~qemu_host_page_mask)) {", "if ((VAR_3 & MAP_TYPE) == MAP_SHARED &&\n(VAR_2 & PROT_WRITE)) {", "errno = EINVAL;", "return -1;", "}", "retaddr = FUNC_0(VAR_0, VAR_1, VAR_2 | PROT_WRITE,\nMAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS,\n-1, 0);", "if (retaddr == -1)\nreturn retaddr;", "pread(VAR_4, g2h(VAR_0), VAR_1, VAR_5);", "if (!(VAR_2 & PROT_WRITE)) {", "ret = target_mprotect(VAR_0, VAR_1, VAR_2);", "if (ret != 0)\nreturn ret;", "}", "goto the_end;", "}", "if (VAR_0 > real_start) {", "if (real_end == real_start + qemu_host_page_size) {", "ret = mmap_frag(real_start, VAR_0, end,\nVAR_2, VAR_3, VAR_4, VAR_5);", "if (ret == -1)\nreturn ret;", "goto the_end1;", "}", "ret = mmap_frag(real_start, VAR_0, real_start + qemu_host_page_size,\nVAR_2, VAR_3, VAR_4, VAR_5);", "if (ret == -1)\nreturn ret;", "real_start += qemu_host_page_size;", "}", "if (end < real_end) {", "ret = mmap_frag(real_end - qemu_host_page_size,\nreal_end - qemu_host_page_size, real_end,\nVAR_2, VAR_3, VAR_4,\nVAR_5 + real_end - qemu_host_page_size - VAR_0);", "if (ret == -1)\nreturn ret;", "real_end -= qemu_host_page_size;", "}", "if (real_start < real_end) {", "unsigned long VAR_7;", "if (VAR_3 & MAP_ANONYMOUS)\nVAR_7 = 0;", "else\nVAR_7 = VAR_5 + real_start - VAR_0;", "ret = (long)mmap(g2h(real_start), real_end - real_start,\nVAR_2, VAR_3, VAR_4, VAR_7);", "if (ret == -1)\nreturn ret;", "}", "the_end1:\npage_set_flags(VAR_0, VAR_0 + VAR_1, VAR_2 | PAGE_VALID);", "the_end:\n#ifdef DEBUG_MMAP\nprintf(\"ret=0x%lx\\n\", (long)VAR_0);", "page_dump(stdout);", "printf(\"\\n\");", "#endif\nreturn 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, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11, 13, 15 ], [ 17, 21 ], [ 23, 27, 29 ], [ 31, 33, 35, 37, 39 ], [ 41, 43 ], [ 45, 47 ], [ 49 ], [ 51, 53 ], [ 55 ], [ 57, 59 ], [ 61 ], [ 63, 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75, 79 ], [ 81 ], [ 83 ], [ 85 ], [ 89 ], [ 91, 93 ], [ 95 ], [ 99 ], [ 101, 103, 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115, 117 ], [ 127 ], [ 129 ], [ 131, 133 ], [ 135, 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145, 147 ], [ 149, 151 ], [ 155 ], [ 157 ], [ 161 ], [ 163 ], [ 165, 167 ], [ 169, 171 ], [ 175, 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 207, 209 ], [ 215, 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225, 227, 229 ], [ 231, 233 ], [ 235 ], [ 237 ], [ 239 ], [ 241, 243 ], [ 245 ], [ 247 ], [ 249 ], [ 255 ], [ 257 ], [ 261, 263 ], [ 265, 267 ], [ 269 ], [ 271 ], [ 273, 275 ], [ 277, 279 ], [ 281 ], [ 283 ], [ 287 ], [ 289, 291, 293, 295 ], [ 297, 299 ], [ 301 ], [ 303 ], [ 309 ], [ 311 ], [ 313, 315 ], [ 317, 319 ], [ 321, 323 ], [ 325, 327 ], [ 329 ], [ 331, 333 ], [ 335, 337, 339 ], [ 341 ], [ 343 ], [ 345, 347 ], [ 349 ] ]
8,892
read_f(int argc, char **argv) { struct timeval t1, t2; int Cflag = 0, pflag = 0, qflag = 0, vflag = 0; int Pflag = 0, sflag = 0, lflag = 0; int c, cnt; char *buf; int64_t offset; int count; /* Some compilers get confused and warn if this is not initialized. */ int total = 0; int pattern = 0, pattern_offset = 0, pattern_count = 0; while ((c = getopt(argc, argv, "Cl:pP:qs:v")) != EOF) { switch (c) { case 'C': Cflag = 1; break; case 'l': lflag = 1; pattern_count = cvtnum(optarg); if (pattern_count < 0) { printf("non-numeric length argument -- %s\n", optarg); return 0; } break; case 'p': pflag = 1; break; case 'P': Pflag = 1; pattern = atoi(optarg); break; case 'q': qflag = 1; break; case 's': sflag = 1; pattern_offset = cvtnum(optarg); if (pattern_offset < 0) { printf("non-numeric length argument -- %s\n", optarg); return 0; } break; case 'v': vflag = 1; break; default: return command_usage(&read_cmd); } } if (optind != argc - 2) return command_usage(&read_cmd); offset = cvtnum(argv[optind]); if (offset < 0) { printf("non-numeric length argument -- %s\n", argv[optind]); return 0; } optind++; count = cvtnum(argv[optind]); if (count < 0) { printf("non-numeric length argument -- %s\n", argv[optind]); return 0; } if (!Pflag && (lflag || sflag)) { return command_usage(&read_cmd); } if (!lflag) { pattern_count = count - pattern_offset; } if ((pattern_count < 0) || (pattern_count + pattern_offset > count)) { printf("pattern verfication range exceeds end of read data\n"); return 0; } if (!pflag) if (offset & 0x1ff) { printf("offset %lld is not sector aligned\n", (long long)offset); return 0; if (count & 0x1ff) { printf("count %d is not sector aligned\n", count); return 0; } } buf = qemu_io_alloc(count, 0xab); gettimeofday(&t1, NULL); if (pflag) cnt = do_pread(buf, offset, count, &total); else cnt = do_read(buf, offset, count, &total); gettimeofday(&t2, NULL); if (cnt < 0) { printf("read failed: %s\n", strerror(-cnt)); return 0; } if (Pflag) { void* cmp_buf = malloc(pattern_count); memset(cmp_buf, pattern, pattern_count); if (memcmp(buf + pattern_offset, cmp_buf, pattern_count)) { printf("Pattern verification failed at offset %lld, " "%d bytes\n", (long long) offset + pattern_offset, pattern_count); } free(cmp_buf); } if (qflag) return 0; if (vflag) dump_buffer(buf, offset, count); /* Finally, report back -- -C gives a parsable format */ t2 = tsub(t2, t1); print_report("read", &t2, offset, count, total, cnt, Cflag); qemu_io_free(buf); return 0; }
true
qemu
7d8abfcb50a33aed369bbd267852cf04009c49e9
read_f(int argc, char **argv) { struct timeval t1, t2; int Cflag = 0, pflag = 0, qflag = 0, vflag = 0; int Pflag = 0, sflag = 0, lflag = 0; int c, cnt; char *buf; int64_t offset; int count; int total = 0; int pattern = 0, pattern_offset = 0, pattern_count = 0; while ((c = getopt(argc, argv, "Cl:pP:qs:v")) != EOF) { switch (c) { case 'C': Cflag = 1; break; case 'l': lflag = 1; pattern_count = cvtnum(optarg); if (pattern_count < 0) { printf("non-numeric length argument -- %s\n", optarg); return 0; } break; case 'p': pflag = 1; break; case 'P': Pflag = 1; pattern = atoi(optarg); break; case 'q': qflag = 1; break; case 's': sflag = 1; pattern_offset = cvtnum(optarg); if (pattern_offset < 0) { printf("non-numeric length argument -- %s\n", optarg); return 0; } break; case 'v': vflag = 1; break; default: return command_usage(&read_cmd); } } if (optind != argc - 2) return command_usage(&read_cmd); offset = cvtnum(argv[optind]); if (offset < 0) { printf("non-numeric length argument -- %s\n", argv[optind]); return 0; } optind++; count = cvtnum(argv[optind]); if (count < 0) { printf("non-numeric length argument -- %s\n", argv[optind]); return 0; } if (!Pflag && (lflag || sflag)) { return command_usage(&read_cmd); } if (!lflag) { pattern_count = count - pattern_offset; } if ((pattern_count < 0) || (pattern_count + pattern_offset > count)) { printf("pattern verfication range exceeds end of read data\n"); return 0; } if (!pflag) if (offset & 0x1ff) { printf("offset %lld is not sector aligned\n", (long long)offset); return 0; if (count & 0x1ff) { printf("count %d is not sector aligned\n", count); return 0; } } buf = qemu_io_alloc(count, 0xab); gettimeofday(&t1, NULL); if (pflag) cnt = do_pread(buf, offset, count, &total); else cnt = do_read(buf, offset, count, &total); gettimeofday(&t2, NULL); if (cnt < 0) { printf("read failed: %s\n", strerror(-cnt)); return 0; } if (Pflag) { void* cmp_buf = malloc(pattern_count); memset(cmp_buf, pattern, pattern_count); if (memcmp(buf + pattern_offset, cmp_buf, pattern_count)) { printf("Pattern verification failed at offset %lld, " "%d bytes\n", (long long) offset + pattern_offset, pattern_count); } free(cmp_buf); } if (qflag) return 0; if (vflag) dump_buffer(buf, offset, count); t2 = tsub(t2, t1); print_report("read", &t2, offset, count, total, cnt, Cflag); qemu_io_free(buf); return 0; }
{ "code": [ "\t\treturn 0;", "\t\treturn 0;", "\t\treturn 0;", "\t\treturn 0;", "\t\treturn 0;", "\t\treturn 0;", "\t\treturn 0;", "\t\treturn 0;" ], "line_no": [ 117, 117, 117, 117, 117, 117, 117, 117 ] }
FUNC_0(int VAR_0, char **VAR_1) { struct timeval VAR_2, VAR_3; int VAR_4 = 0, VAR_5 = 0, VAR_6 = 0, VAR_7 = 0; int VAR_8 = 0, VAR_9 = 0, VAR_10 = 0; int VAR_11, VAR_12; char *VAR_13; int64_t offset; int VAR_14; int VAR_15 = 0; int VAR_16 = 0, VAR_17 = 0, VAR_18 = 0; while ((VAR_11 = getopt(VAR_0, VAR_1, "Cl:pP:qs:v")) != EOF) { switch (VAR_11) { case 'C': VAR_4 = 1; break; case 'l': VAR_10 = 1; VAR_18 = cvtnum(optarg); if (VAR_18 < 0) { printf("non-numeric length argument -- %s\n", optarg); return 0; } break; case 'p': VAR_5 = 1; break; case 'P': VAR_8 = 1; VAR_16 = atoi(optarg); break; case 'q': VAR_6 = 1; break; case 's': VAR_9 = 1; VAR_17 = cvtnum(optarg); if (VAR_17 < 0) { printf("non-numeric length argument -- %s\n", optarg); return 0; } break; case 'v': VAR_7 = 1; break; default: return command_usage(&read_cmd); } } if (optind != VAR_0 - 2) return command_usage(&read_cmd); offset = cvtnum(VAR_1[optind]); if (offset < 0) { printf("non-numeric length argument -- %s\n", VAR_1[optind]); return 0; } optind++; VAR_14 = cvtnum(VAR_1[optind]); if (VAR_14 < 0) { printf("non-numeric length argument -- %s\n", VAR_1[optind]); return 0; } if (!VAR_8 && (VAR_10 || VAR_9)) { return command_usage(&read_cmd); } if (!VAR_10) { VAR_18 = VAR_14 - VAR_17; } if ((VAR_18 < 0) || (VAR_18 + VAR_17 > VAR_14)) { printf("VAR_16 verfication range exceeds end of read data\n"); return 0; } if (!VAR_5) if (offset & 0x1ff) { printf("offset %lld is not sector aligned\n", (long long)offset); return 0; if (VAR_14 & 0x1ff) { printf("VAR_14 %d is not sector aligned\n", VAR_14); return 0; } } VAR_13 = qemu_io_alloc(VAR_14, 0xab); gettimeofday(&VAR_2, NULL); if (VAR_5) VAR_12 = do_pread(VAR_13, offset, VAR_14, &VAR_15); else VAR_12 = do_read(VAR_13, offset, VAR_14, &VAR_15); gettimeofday(&VAR_3, NULL); if (VAR_12 < 0) { printf("read failed: %s\n", strerror(-VAR_12)); return 0; } if (VAR_8) { void* VAR_19 = malloc(VAR_18); memset(VAR_19, VAR_16, VAR_18); if (memcmp(VAR_13 + VAR_17, VAR_19, VAR_18)) { printf("Pattern verification failed at offset %lld, " "%d bytes\n", (long long) offset + VAR_17, VAR_18); } free(VAR_19); } if (VAR_6) return 0; if (VAR_7) dump_buffer(VAR_13, offset, VAR_14); VAR_3 = tsub(VAR_3, VAR_2); print_report("read", &VAR_3, offset, VAR_14, VAR_15, VAR_12, VAR_4); qemu_io_free(VAR_13); return 0; }
[ "FUNC_0(int VAR_0, char **VAR_1)\n{", "struct timeval VAR_2, VAR_3;", "int VAR_4 = 0, VAR_5 = 0, VAR_6 = 0, VAR_7 = 0;", "int VAR_8 = 0, VAR_9 = 0, VAR_10 = 0;", "int VAR_11, VAR_12;", "char *VAR_13;", "int64_t offset;", "int VAR_14;", "int VAR_15 = 0;", "int VAR_16 = 0, VAR_17 = 0, VAR_18 = 0;", "while ((VAR_11 = getopt(VAR_0, VAR_1, \"Cl:pP:qs:v\")) != EOF) {", "switch (VAR_11) {", "case 'C':\nVAR_4 = 1;", "break;", "case 'l':\nVAR_10 = 1;", "VAR_18 = cvtnum(optarg);", "if (VAR_18 < 0) {", "printf(\"non-numeric length argument -- %s\\n\", optarg);", "return 0;", "}", "break;", "case 'p':\nVAR_5 = 1;", "break;", "case 'P':\nVAR_8 = 1;", "VAR_16 = atoi(optarg);", "break;", "case 'q':\nVAR_6 = 1;", "break;", "case 's':\nVAR_9 = 1;", "VAR_17 = cvtnum(optarg);", "if (VAR_17 < 0) {", "printf(\"non-numeric length argument -- %s\\n\", optarg);", "return 0;", "}", "break;", "case 'v':\nVAR_7 = 1;", "break;", "default:\nreturn command_usage(&read_cmd);", "}", "}", "if (optind != VAR_0 - 2)\nreturn command_usage(&read_cmd);", "offset = cvtnum(VAR_1[optind]);", "if (offset < 0) {", "printf(\"non-numeric length argument -- %s\\n\", VAR_1[optind]);", "return 0;", "}", "optind++;", "VAR_14 = cvtnum(VAR_1[optind]);", "if (VAR_14 < 0) {", "printf(\"non-numeric length argument -- %s\\n\", VAR_1[optind]);", "return 0;", "}", "if (!VAR_8 && (VAR_10 || VAR_9)) {", "return command_usage(&read_cmd);", "}", "if (!VAR_10) {", "VAR_18 = VAR_14 - VAR_17;", "}", "if ((VAR_18 < 0) || (VAR_18 + VAR_17 > VAR_14)) {", "printf(\"VAR_16 verfication range exceeds end of read data\\n\");", "return 0;", "}", "if (!VAR_5)\nif (offset & 0x1ff) {", "printf(\"offset %lld is not sector aligned\\n\",\n(long long)offset);", "return 0;", "if (VAR_14 & 0x1ff) {", "printf(\"VAR_14 %d is not sector aligned\\n\",\nVAR_14);", "return 0;", "}", "}", "VAR_13 = qemu_io_alloc(VAR_14, 0xab);", "gettimeofday(&VAR_2, NULL);", "if (VAR_5)\nVAR_12 = do_pread(VAR_13, offset, VAR_14, &VAR_15);", "else\nVAR_12 = do_read(VAR_13, offset, VAR_14, &VAR_15);", "gettimeofday(&VAR_3, NULL);", "if (VAR_12 < 0) {", "printf(\"read failed: %s\\n\", strerror(-VAR_12));", "return 0;", "}", "if (VAR_8) {", "void* VAR_19 = malloc(VAR_18);", "memset(VAR_19, VAR_16, VAR_18);", "if (memcmp(VAR_13 + VAR_17, VAR_19, VAR_18)) {", "printf(\"Pattern verification failed at offset %lld, \"\n\"%d bytes\\n\",\n(long long) offset + VAR_17, VAR_18);", "}", "free(VAR_19);", "}", "if (VAR_6)\nreturn 0;", "if (VAR_7)\ndump_buffer(VAR_13, offset, VAR_14);", "VAR_3 = tsub(VAR_3, VAR_2);", "print_report(\"read\", &VAR_3, offset, VAR_14, VAR_15, VAR_12, VAR_4);", "qemu_io_free(VAR_13);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31, 33 ], [ 35 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53, 55 ], [ 57 ], [ 59, 61 ], [ 63 ], [ 65 ], [ 67, 69 ], [ 71 ], [ 73, 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89, 91 ], [ 93 ], [ 95, 97 ], [ 99 ], [ 101 ], [ 105, 107 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 137 ], [ 139 ], [ 141 ], [ 145 ], [ 147 ], [ 149 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 163, 165 ], [ 167, 169 ], [ 171 ], [ 175 ], [ 177, 179 ], [ 181 ], [ 183 ], [ 185 ], [ 189 ], [ 193 ], [ 195, 197 ], [ 199, 201 ], [ 203 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225, 227, 229 ], [ 231 ], [ 233 ], [ 235 ], [ 239, 241 ], [ 245, 247 ], [ 253 ], [ 255 ], [ 259 ], [ 263 ], [ 265 ] ]
8,893
e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size) { E1000State *s = DO_UPCAST(NICState, nc, nc)->opaque; struct e1000_rx_desc desc; target_phys_addr_t base; unsigned int n, rdt; uint32_t rdh_start; uint16_t vlan_special = 0; uint8_t vlan_status = 0, vlan_offset = 0; uint8_t min_buf[MIN_BUF_SIZE]; size_t desc_offset; size_t desc_size; size_t total_size; if (!(s->mac_reg[RCTL] & E1000_RCTL_EN)) return -1; /* Pad to minimum Ethernet frame length */ if (size < sizeof(min_buf)) { memcpy(min_buf, buf, size); memset(&min_buf[size], 0, sizeof(min_buf) - size); buf = min_buf; size = sizeof(min_buf); } if (!receive_filter(s, buf, size)) return size; if (vlan_enabled(s) && is_vlan_packet(s, buf)) { vlan_special = cpu_to_le16(be16_to_cpup((uint16_t *)(buf + 14))); memmove((uint8_t *)buf + 4, buf, 12); vlan_status = E1000_RXD_STAT_VP; vlan_offset = 4; size -= 4; } rdh_start = s->mac_reg[RDH]; desc_offset = 0; total_size = size + fcs_len(s); do { desc_size = total_size - desc_offset; if (desc_size > s->rxbuf_size) { desc_size = s->rxbuf_size; } if (s->mac_reg[RDH] == s->mac_reg[RDT] && s->check_rxov) { /* Discard all data written so far */ s->mac_reg[RDH] = rdh_start; set_ics(s, 0, E1000_ICS_RXO); return -1; } base = ((uint64_t)s->mac_reg[RDBAH] << 32) + s->mac_reg[RDBAL] + sizeof(desc) * s->mac_reg[RDH]; cpu_physical_memory_read(base, (void *)&desc, sizeof(desc)); desc.special = vlan_special; desc.status |= (vlan_status | E1000_RXD_STAT_DD); if (desc.buffer_addr) { if (desc_offset < size) { size_t copy_size = size - desc_offset; if (copy_size > s->rxbuf_size) { copy_size = s->rxbuf_size; } cpu_physical_memory_write(le64_to_cpu(desc.buffer_addr), (void *)(buf + desc_offset + vlan_offset), copy_size); } desc_offset += desc_size; desc.length = cpu_to_le16(desc_size); if (desc_offset >= total_size) { desc.status |= E1000_RXD_STAT_EOP | E1000_RXD_STAT_IXSM; } else { /* Guest zeroing out status is not a hardware requirement. Clear EOP in case guest didn't do it. */ desc.status &= ~E1000_RXD_STAT_EOP; } } else { // as per intel docs; skip descriptors with null buf addr DBGOUT(RX, "Null RX descriptor!!\n"); } cpu_physical_memory_write(base, (void *)&desc, sizeof(desc)); if (++s->mac_reg[RDH] * sizeof(desc) >= s->mac_reg[RDLEN]) s->mac_reg[RDH] = 0; s->check_rxov = 1; /* see comment in start_xmit; same here */ if (s->mac_reg[RDH] == rdh_start) { DBGOUT(RXERR, "RDH wraparound @%x, RDT %x, RDLEN %x\n", rdh_start, s->mac_reg[RDT], s->mac_reg[RDLEN]); set_ics(s, 0, E1000_ICS_RXO); return -1; } } while (desc_offset < total_size); s->mac_reg[GPRC]++; s->mac_reg[TPR]++; /* TOR - Total Octets Received: * This register includes bytes received in a packet from the <Destination * Address> field through the <CRC> field, inclusively. */ n = s->mac_reg[TORL] + size + /* Always include FCS length. */ 4; if (n < s->mac_reg[TORL]) s->mac_reg[TORH]++; s->mac_reg[TORL] = n; n = E1000_ICS_RXT0; if ((rdt = s->mac_reg[RDT]) < s->mac_reg[RDH]) rdt += s->mac_reg[RDLEN] / sizeof(desc); if (((rdt - s->mac_reg[RDH]) * sizeof(desc)) <= s->mac_reg[RDLEN] >> s->rxbuf_min_shift) n |= E1000_ICS_RXDMT0; set_ics(s, 0, n); return size; }
true
qemu
322fd48afbed1ef7b834ac343a0c8687bcb33695
e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size) { E1000State *s = DO_UPCAST(NICState, nc, nc)->opaque; struct e1000_rx_desc desc; target_phys_addr_t base; unsigned int n, rdt; uint32_t rdh_start; uint16_t vlan_special = 0; uint8_t vlan_status = 0, vlan_offset = 0; uint8_t min_buf[MIN_BUF_SIZE]; size_t desc_offset; size_t desc_size; size_t total_size; if (!(s->mac_reg[RCTL] & E1000_RCTL_EN)) return -1; if (size < sizeof(min_buf)) { memcpy(min_buf, buf, size); memset(&min_buf[size], 0, sizeof(min_buf) - size); buf = min_buf; size = sizeof(min_buf); } if (!receive_filter(s, buf, size)) return size; if (vlan_enabled(s) && is_vlan_packet(s, buf)) { vlan_special = cpu_to_le16(be16_to_cpup((uint16_t *)(buf + 14))); memmove((uint8_t *)buf + 4, buf, 12); vlan_status = E1000_RXD_STAT_VP; vlan_offset = 4; size -= 4; } rdh_start = s->mac_reg[RDH]; desc_offset = 0; total_size = size + fcs_len(s); do { desc_size = total_size - desc_offset; if (desc_size > s->rxbuf_size) { desc_size = s->rxbuf_size; } if (s->mac_reg[RDH] == s->mac_reg[RDT] && s->check_rxov) { s->mac_reg[RDH] = rdh_start; set_ics(s, 0, E1000_ICS_RXO); return -1; } base = ((uint64_t)s->mac_reg[RDBAH] << 32) + s->mac_reg[RDBAL] + sizeof(desc) * s->mac_reg[RDH]; cpu_physical_memory_read(base, (void *)&desc, sizeof(desc)); desc.special = vlan_special; desc.status |= (vlan_status | E1000_RXD_STAT_DD); if (desc.buffer_addr) { if (desc_offset < size) { size_t copy_size = size - desc_offset; if (copy_size > s->rxbuf_size) { copy_size = s->rxbuf_size; } cpu_physical_memory_write(le64_to_cpu(desc.buffer_addr), (void *)(buf + desc_offset + vlan_offset), copy_size); } desc_offset += desc_size; desc.length = cpu_to_le16(desc_size); if (desc_offset >= total_size) { desc.status |= E1000_RXD_STAT_EOP | E1000_RXD_STAT_IXSM; } else { desc.status &= ~E1000_RXD_STAT_EOP; } } else { DBGOUT(RX, "Null RX descriptor!!\n"); } cpu_physical_memory_write(base, (void *)&desc, sizeof(desc)); if (++s->mac_reg[RDH] * sizeof(desc) >= s->mac_reg[RDLEN]) s->mac_reg[RDH] = 0; s->check_rxov = 1; if (s->mac_reg[RDH] == rdh_start) { DBGOUT(RXERR, "RDH wraparound @%x, RDT %x, RDLEN %x\n", rdh_start, s->mac_reg[RDT], s->mac_reg[RDLEN]); set_ics(s, 0, E1000_ICS_RXO); return -1; } } while (desc_offset < total_size); s->mac_reg[GPRC]++; s->mac_reg[TPR]++; n = s->mac_reg[TORL] + size + 4; if (n < s->mac_reg[TORL]) s->mac_reg[TORH]++; s->mac_reg[TORL] = n; n = E1000_ICS_RXT0; if ((rdt = s->mac_reg[RDT]) < s->mac_reg[RDH]) rdt += s->mac_reg[RDLEN] / sizeof(desc); if (((rdt - s->mac_reg[RDH]) * sizeof(desc)) <= s->mac_reg[RDLEN] >> s->rxbuf_min_shift) n |= E1000_ICS_RXDMT0; set_ics(s, 0, n); return size; }
{ "code": [ " if (s->mac_reg[RDH] == s->mac_reg[RDT] && s->check_rxov) {", " s->mac_reg[RDH] = rdh_start;", " set_ics(s, 0, E1000_ICS_RXO);", " return -1;" ], "line_no": [ 89, 93, 95, 97 ] }
FUNC_0(VLANClientState *VAR_0, const uint8_t *VAR_1, size_t VAR_2) { E1000State *s = DO_UPCAST(NICState, VAR_0, VAR_0)->opaque; struct e1000_rx_desc VAR_3; target_phys_addr_t base; unsigned int VAR_4, VAR_5; uint32_t rdh_start; uint16_t vlan_special = 0; uint8_t vlan_status = 0, vlan_offset = 0; uint8_t min_buf[MIN_BUF_SIZE]; size_t desc_offset; size_t desc_size; size_t total_size; if (!(s->mac_reg[RCTL] & E1000_RCTL_EN)) return -1; if (VAR_2 < sizeof(min_buf)) { memcpy(min_buf, VAR_1, VAR_2); memset(&min_buf[VAR_2], 0, sizeof(min_buf) - VAR_2); VAR_1 = min_buf; VAR_2 = sizeof(min_buf); } if (!receive_filter(s, VAR_1, VAR_2)) return VAR_2; if (vlan_enabled(s) && is_vlan_packet(s, VAR_1)) { vlan_special = cpu_to_le16(be16_to_cpup((uint16_t *)(VAR_1 + 14))); memmove((uint8_t *)VAR_1 + 4, VAR_1, 12); vlan_status = E1000_RXD_STAT_VP; vlan_offset = 4; VAR_2 -= 4; } rdh_start = s->mac_reg[RDH]; desc_offset = 0; total_size = VAR_2 + fcs_len(s); do { desc_size = total_size - desc_offset; if (desc_size > s->rxbuf_size) { desc_size = s->rxbuf_size; } if (s->mac_reg[RDH] == s->mac_reg[RDT] && s->check_rxov) { s->mac_reg[RDH] = rdh_start; set_ics(s, 0, E1000_ICS_RXO); return -1; } base = ((uint64_t)s->mac_reg[RDBAH] << 32) + s->mac_reg[RDBAL] + sizeof(VAR_3) * s->mac_reg[RDH]; cpu_physical_memory_read(base, (void *)&VAR_3, sizeof(VAR_3)); VAR_3.special = vlan_special; VAR_3.status |= (vlan_status | E1000_RXD_STAT_DD); if (VAR_3.buffer_addr) { if (desc_offset < VAR_2) { size_t copy_size = VAR_2 - desc_offset; if (copy_size > s->rxbuf_size) { copy_size = s->rxbuf_size; } cpu_physical_memory_write(le64_to_cpu(VAR_3.buffer_addr), (void *)(VAR_1 + desc_offset + vlan_offset), copy_size); } desc_offset += desc_size; VAR_3.length = cpu_to_le16(desc_size); if (desc_offset >= total_size) { VAR_3.status |= E1000_RXD_STAT_EOP | E1000_RXD_STAT_IXSM; } else { VAR_3.status &= ~E1000_RXD_STAT_EOP; } } else { DBGOUT(RX, "Null RX descriptor!!\VAR_4"); } cpu_physical_memory_write(base, (void *)&VAR_3, sizeof(VAR_3)); if (++s->mac_reg[RDH] * sizeof(VAR_3) >= s->mac_reg[RDLEN]) s->mac_reg[RDH] = 0; s->check_rxov = 1; if (s->mac_reg[RDH] == rdh_start) { DBGOUT(RXERR, "RDH wraparound @%x, RDT %x, RDLEN %x\VAR_4", rdh_start, s->mac_reg[RDT], s->mac_reg[RDLEN]); set_ics(s, 0, E1000_ICS_RXO); return -1; } } while (desc_offset < total_size); s->mac_reg[GPRC]++; s->mac_reg[TPR]++; VAR_4 = s->mac_reg[TORL] + VAR_2 + 4; if (VAR_4 < s->mac_reg[TORL]) s->mac_reg[TORH]++; s->mac_reg[TORL] = VAR_4; VAR_4 = E1000_ICS_RXT0; if ((VAR_5 = s->mac_reg[RDT]) < s->mac_reg[RDH]) VAR_5 += s->mac_reg[RDLEN] / sizeof(VAR_3); if (((VAR_5 - s->mac_reg[RDH]) * sizeof(VAR_3)) <= s->mac_reg[RDLEN] >> s->rxbuf_min_shift) VAR_4 |= E1000_ICS_RXDMT0; set_ics(s, 0, VAR_4); return VAR_2; }
[ "FUNC_0(VLANClientState *VAR_0, const uint8_t *VAR_1, size_t VAR_2)\n{", "E1000State *s = DO_UPCAST(NICState, VAR_0, VAR_0)->opaque;", "struct e1000_rx_desc VAR_3;", "target_phys_addr_t base;", "unsigned int VAR_4, VAR_5;", "uint32_t rdh_start;", "uint16_t vlan_special = 0;", "uint8_t vlan_status = 0, vlan_offset = 0;", "uint8_t min_buf[MIN_BUF_SIZE];", "size_t desc_offset;", "size_t desc_size;", "size_t total_size;", "if (!(s->mac_reg[RCTL] & E1000_RCTL_EN))\nreturn -1;", "if (VAR_2 < sizeof(min_buf)) {", "memcpy(min_buf, VAR_1, VAR_2);", "memset(&min_buf[VAR_2], 0, sizeof(min_buf) - VAR_2);", "VAR_1 = min_buf;", "VAR_2 = sizeof(min_buf);", "}", "if (!receive_filter(s, VAR_1, VAR_2))\nreturn VAR_2;", "if (vlan_enabled(s) && is_vlan_packet(s, VAR_1)) {", "vlan_special = cpu_to_le16(be16_to_cpup((uint16_t *)(VAR_1 + 14)));", "memmove((uint8_t *)VAR_1 + 4, VAR_1, 12);", "vlan_status = E1000_RXD_STAT_VP;", "vlan_offset = 4;", "VAR_2 -= 4;", "}", "rdh_start = s->mac_reg[RDH];", "desc_offset = 0;", "total_size = VAR_2 + fcs_len(s);", "do {", "desc_size = total_size - desc_offset;", "if (desc_size > s->rxbuf_size) {", "desc_size = s->rxbuf_size;", "}", "if (s->mac_reg[RDH] == s->mac_reg[RDT] && s->check_rxov) {", "s->mac_reg[RDH] = rdh_start;", "set_ics(s, 0, E1000_ICS_RXO);", "return -1;", "}", "base = ((uint64_t)s->mac_reg[RDBAH] << 32) + s->mac_reg[RDBAL] +\nsizeof(VAR_3) * s->mac_reg[RDH];", "cpu_physical_memory_read(base, (void *)&VAR_3, sizeof(VAR_3));", "VAR_3.special = vlan_special;", "VAR_3.status |= (vlan_status | E1000_RXD_STAT_DD);", "if (VAR_3.buffer_addr) {", "if (desc_offset < VAR_2) {", "size_t copy_size = VAR_2 - desc_offset;", "if (copy_size > s->rxbuf_size) {", "copy_size = s->rxbuf_size;", "}", "cpu_physical_memory_write(le64_to_cpu(VAR_3.buffer_addr),\n(void *)(VAR_1 + desc_offset + vlan_offset),\ncopy_size);", "}", "desc_offset += desc_size;", "VAR_3.length = cpu_to_le16(desc_size);", "if (desc_offset >= total_size) {", "VAR_3.status |= E1000_RXD_STAT_EOP | E1000_RXD_STAT_IXSM;", "} else {", "VAR_3.status &= ~E1000_RXD_STAT_EOP;", "}", "} else {", "DBGOUT(RX, \"Null RX descriptor!!\\VAR_4\");", "}", "cpu_physical_memory_write(base, (void *)&VAR_3, sizeof(VAR_3));", "if (++s->mac_reg[RDH] * sizeof(VAR_3) >= s->mac_reg[RDLEN])\ns->mac_reg[RDH] = 0;", "s->check_rxov = 1;", "if (s->mac_reg[RDH] == rdh_start) {", "DBGOUT(RXERR, \"RDH wraparound @%x, RDT %x, RDLEN %x\\VAR_4\",\nrdh_start, s->mac_reg[RDT], s->mac_reg[RDLEN]);", "set_ics(s, 0, E1000_ICS_RXO);", "return -1;", "}", "} while (desc_offset < total_size);", "s->mac_reg[GPRC]++;", "s->mac_reg[TPR]++;", "VAR_4 = s->mac_reg[TORL] + VAR_2 + 4;", "if (VAR_4 < s->mac_reg[TORL])\ns->mac_reg[TORH]++;", "s->mac_reg[TORL] = VAR_4;", "VAR_4 = E1000_ICS_RXT0;", "if ((VAR_5 = s->mac_reg[RDT]) < s->mac_reg[RDH])\nVAR_5 += s->mac_reg[RDLEN] / sizeof(VAR_3);", "if (((VAR_5 - s->mac_reg[RDH]) * sizeof(VAR_3)) <= s->mac_reg[RDLEN] >>\ns->rxbuf_min_shift)\nVAR_4 |= E1000_ICS_RXDMT0;", "set_ics(s, 0, VAR_4);", "return VAR_2;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29, 31 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51, 53 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101, 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123, 125, 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 159, 161 ], [ 163 ], [ 167 ], [ 169, 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 183 ], [ 185 ], [ 195 ], [ 197, 199 ], [ 201 ], [ 205 ], [ 207, 209 ], [ 211, 213, 215 ], [ 219 ], [ 223 ], [ 225 ] ]
8,894
static void ehci_update_frindex(EHCIState *ehci, int uframes) { int i; if (!ehci_enabled(ehci) && ehci->pstate == EST_INACTIVE) { return; } for (i = 0; i < uframes; i++) { ehci->frindex++; if (ehci->frindex == 0x00002000) { ehci_raise_irq(ehci, USBSTS_FLR); } if (ehci->frindex == 0x00004000) { ehci_raise_irq(ehci, USBSTS_FLR); ehci->frindex = 0; if (ehci->usbsts_frindex >= 0x00004000) { ehci->usbsts_frindex -= 0x00004000; } else { ehci->usbsts_frindex = 0; } } } }
true
qemu
72aa364b1d9daa889bb5898ea4aded9d27fd1c96
static void ehci_update_frindex(EHCIState *ehci, int uframes) { int i; if (!ehci_enabled(ehci) && ehci->pstate == EST_INACTIVE) { return; } for (i = 0; i < uframes; i++) { ehci->frindex++; if (ehci->frindex == 0x00002000) { ehci_raise_irq(ehci, USBSTS_FLR); } if (ehci->frindex == 0x00004000) { ehci_raise_irq(ehci, USBSTS_FLR); ehci->frindex = 0; if (ehci->usbsts_frindex >= 0x00004000) { ehci->usbsts_frindex -= 0x00004000; } else { ehci->usbsts_frindex = 0; } } } }
{ "code": [ " int i;", " for (i = 0; i < uframes; i++) {", " ehci->frindex++;", " if (ehci->frindex == 0x00002000) {", " ehci_raise_irq(ehci, USBSTS_FLR);", " if (ehci->frindex == 0x00004000) {", " ehci_raise_irq(ehci, USBSTS_FLR);", " ehci->frindex = 0;", " if (ehci->usbsts_frindex >= 0x00004000) {", " ehci->usbsts_frindex -= 0x00004000;", " } else {", " ehci->usbsts_frindex = 0;" ], "line_no": [ 5, 17, 19, 23, 25, 31, 25, 35, 37, 39, 41, 43 ] }
static void FUNC_0(EHCIState *VAR_0, int VAR_1) { int VAR_2; if (!ehci_enabled(VAR_0) && VAR_0->pstate == EST_INACTIVE) { return; } for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) { VAR_0->frindex++; if (VAR_0->frindex == 0x00002000) { ehci_raise_irq(VAR_0, USBSTS_FLR); } if (VAR_0->frindex == 0x00004000) { ehci_raise_irq(VAR_0, USBSTS_FLR); VAR_0->frindex = 0; if (VAR_0->usbsts_frindex >= 0x00004000) { VAR_0->usbsts_frindex -= 0x00004000; } else { VAR_0->usbsts_frindex = 0; } } } }
[ "static void FUNC_0(EHCIState *VAR_0, int VAR_1)\n{", "int VAR_2;", "if (!ehci_enabled(VAR_0) && VAR_0->pstate == EST_INACTIVE) {", "return;", "}", "for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) {", "VAR_0->frindex++;", "if (VAR_0->frindex == 0x00002000) {", "ehci_raise_irq(VAR_0, USBSTS_FLR);", "}", "if (VAR_0->frindex == 0x00004000) {", "ehci_raise_irq(VAR_0, USBSTS_FLR);", "VAR_0->frindex = 0;", "if (VAR_0->usbsts_frindex >= 0x00004000) {", "VAR_0->usbsts_frindex -= 0x00004000;", "} else {", "VAR_0->usbsts_frindex = 0;", "}", "}", "}", "}" ]
[ 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ] ]
8,895
static int tee_write_header(AVFormatContext *avf) { TeeContext *tee = avf->priv_data; unsigned nb_slaves = 0, i; const char *filename = avf->filename; char *slaves[MAX_SLAVES]; int ret; while (*filename) { if (nb_slaves == MAX_SLAVES) { av_log(avf, AV_LOG_ERROR, "Maximum %d slave muxers reached.\n", MAX_SLAVES); ret = AVERROR_PATCHWELCOME; goto fail; } if (!(slaves[nb_slaves++] = av_get_token(&filename, slave_delim))) { ret = AVERROR(ENOMEM); goto fail; } if (strspn(filename, slave_delim)) filename++; } for (i = 0; i < nb_slaves; i++) { if ((ret = open_slave(avf, slaves[i], &tee->slaves[i])) < 0) goto fail; log_slave(&tee->slaves[i], avf, AV_LOG_VERBOSE); av_freep(&slaves[i]); } tee->nb_slaves = nb_slaves; for (i = 0; i < avf->nb_streams; i++) { int j, mapped = 0; for (j = 0; j < tee->nb_slaves; j++) mapped += tee->slaves[j].stream_map[i] >= 0; if (!mapped) av_log(avf, AV_LOG_WARNING, "Input stream #%d is not mapped " "to any slave.\n", i); } return 0; fail: for (i = 0; i < nb_slaves; i++) av_freep(&slaves[i]); close_slaves(avf); return ret; }
true
FFmpeg
f9d7e9feec2a0fd7f7930d01876a70a9b8a4a3b9
static int tee_write_header(AVFormatContext *avf) { TeeContext *tee = avf->priv_data; unsigned nb_slaves = 0, i; const char *filename = avf->filename; char *slaves[MAX_SLAVES]; int ret; while (*filename) { if (nb_slaves == MAX_SLAVES) { av_log(avf, AV_LOG_ERROR, "Maximum %d slave muxers reached.\n", MAX_SLAVES); ret = AVERROR_PATCHWELCOME; goto fail; } if (!(slaves[nb_slaves++] = av_get_token(&filename, slave_delim))) { ret = AVERROR(ENOMEM); goto fail; } if (strspn(filename, slave_delim)) filename++; } for (i = 0; i < nb_slaves; i++) { if ((ret = open_slave(avf, slaves[i], &tee->slaves[i])) < 0) goto fail; log_slave(&tee->slaves[i], avf, AV_LOG_VERBOSE); av_freep(&slaves[i]); } tee->nb_slaves = nb_slaves; for (i = 0; i < avf->nb_streams; i++) { int j, mapped = 0; for (j = 0; j < tee->nb_slaves; j++) mapped += tee->slaves[j].stream_map[i] >= 0; if (!mapped) av_log(avf, AV_LOG_WARNING, "Input stream #%d is not mapped " "to any slave.\n", i); } return 0; fail: for (i = 0; i < nb_slaves; i++) av_freep(&slaves[i]); close_slaves(avf); return ret; }
{ "code": [ " tee->nb_slaves = nb_slaves;", " close_slaves(avf);" ], "line_no": [ 61, 91 ] }
static int FUNC_0(AVFormatContext *VAR_0) { TeeContext *tee = VAR_0->priv_data; unsigned VAR_1 = 0, VAR_2; const char *VAR_3 = VAR_0->VAR_3; char *VAR_4[MAX_SLAVES]; int VAR_5; while (*VAR_3) { if (VAR_1 == MAX_SLAVES) { av_log(VAR_0, AV_LOG_ERROR, "Maximum %d slave muxers reached.\n", MAX_SLAVES); VAR_5 = AVERROR_PATCHWELCOME; goto fail; } if (!(VAR_4[VAR_1++] = av_get_token(&VAR_3, slave_delim))) { VAR_5 = AVERROR(ENOMEM); goto fail; } if (strspn(VAR_3, slave_delim)) VAR_3++; } for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) { if ((VAR_5 = open_slave(VAR_0, VAR_4[VAR_2], &tee->VAR_4[VAR_2])) < 0) goto fail; log_slave(&tee->VAR_4[VAR_2], VAR_0, AV_LOG_VERBOSE); av_freep(&VAR_4[VAR_2]); } tee->VAR_1 = VAR_1; for (VAR_2 = 0; VAR_2 < VAR_0->nb_streams; VAR_2++) { int j, mapped = 0; for (j = 0; j < tee->VAR_1; j++) mapped += tee->VAR_4[j].stream_map[VAR_2] >= 0; if (!mapped) av_log(VAR_0, AV_LOG_WARNING, "Input stream #%d is not mapped " "to any slave.\n", VAR_2); } return 0; fail: for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) av_freep(&VAR_4[VAR_2]); close_slaves(VAR_0); return VAR_5; }
[ "static int FUNC_0(AVFormatContext *VAR_0)\n{", "TeeContext *tee = VAR_0->priv_data;", "unsigned VAR_1 = 0, VAR_2;", "const char *VAR_3 = VAR_0->VAR_3;", "char *VAR_4[MAX_SLAVES];", "int VAR_5;", "while (*VAR_3) {", "if (VAR_1 == MAX_SLAVES) {", "av_log(VAR_0, AV_LOG_ERROR, \"Maximum %d slave muxers reached.\\n\",\nMAX_SLAVES);", "VAR_5 = AVERROR_PATCHWELCOME;", "goto fail;", "}", "if (!(VAR_4[VAR_1++] = av_get_token(&VAR_3, slave_delim))) {", "VAR_5 = AVERROR(ENOMEM);", "goto fail;", "}", "if (strspn(VAR_3, slave_delim))\nVAR_3++;", "}", "for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) {", "if ((VAR_5 = open_slave(VAR_0, VAR_4[VAR_2], &tee->VAR_4[VAR_2])) < 0)\ngoto fail;", "log_slave(&tee->VAR_4[VAR_2], VAR_0, AV_LOG_VERBOSE);", "av_freep(&VAR_4[VAR_2]);", "}", "tee->VAR_1 = VAR_1;", "for (VAR_2 = 0; VAR_2 < VAR_0->nb_streams; VAR_2++) {", "int j, mapped = 0;", "for (j = 0; j < tee->VAR_1; j++)", "mapped += tee->VAR_4[j].stream_map[VAR_2] >= 0;", "if (!mapped)\nav_log(VAR_0, AV_LOG_WARNING, \"Input stream #%d is not mapped \"\n\"to any slave.\\n\", VAR_2);", "}", "return 0;", "fail:\nfor (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++)", "av_freep(&VAR_4[VAR_2]);", "close_slaves(VAR_0);", "return VAR_5;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39, 41 ], [ 43 ], [ 47 ], [ 49, 51 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73, 75, 77 ], [ 79 ], [ 81 ], [ 85, 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ] ]
8,896
static int css_add_virtual_chpid(uint8_t cssid, uint8_t chpid, uint8_t type) { CssImage *css; trace_css_chpid_add(cssid, chpid, type); if (cssid > MAX_CSSID) { return -EINVAL; } css = channel_subsys.css[cssid]; if (!css) { return -EINVAL; } if (css->chpids[chpid].in_use) { return -EEXIST; } css->chpids[chpid].in_use = 1; css->chpids[chpid].type = type; css->chpids[chpid].is_virtual = 1; css_generate_chp_crws(cssid, chpid); return 0; }
true
qemu
882b3b97697affb36ca3d174f42f846232008979
static int css_add_virtual_chpid(uint8_t cssid, uint8_t chpid, uint8_t type) { CssImage *css; trace_css_chpid_add(cssid, chpid, type); if (cssid > MAX_CSSID) { return -EINVAL; } css = channel_subsys.css[cssid]; if (!css) { return -EINVAL; } if (css->chpids[chpid].in_use) { return -EEXIST; } css->chpids[chpid].in_use = 1; css->chpids[chpid].type = type; css->chpids[chpid].is_virtual = 1; css_generate_chp_crws(cssid, chpid); return 0; }
{ "code": [ " if (cssid > MAX_CSSID) {", " if (cssid > MAX_CSSID) {", " return -EINVAL;" ], "line_no": [ 11, 11, 13 ] }
static int FUNC_0(uint8_t VAR_0, uint8_t VAR_1, uint8_t VAR_2) { CssImage *css; trace_css_chpid_add(VAR_0, VAR_1, VAR_2); if (VAR_0 > MAX_CSSID) { return -EINVAL; } css = channel_subsys.css[VAR_0]; if (!css) { return -EINVAL; } if (css->chpids[VAR_1].in_use) { return -EEXIST; } css->chpids[VAR_1].in_use = 1; css->chpids[VAR_1].VAR_2 = VAR_2; css->chpids[VAR_1].is_virtual = 1; css_generate_chp_crws(VAR_0, VAR_1); return 0; }
[ "static int FUNC_0(uint8_t VAR_0, uint8_t VAR_1, uint8_t VAR_2)\n{", "CssImage *css;", "trace_css_chpid_add(VAR_0, VAR_1, VAR_2);", "if (VAR_0 > MAX_CSSID) {", "return -EINVAL;", "}", "css = channel_subsys.css[VAR_0];", "if (!css) {", "return -EINVAL;", "}", "if (css->chpids[VAR_1].in_use) {", "return -EEXIST;", "}", "css->chpids[VAR_1].in_use = 1;", "css->chpids[VAR_1].VAR_2 = VAR_2;", "css->chpids[VAR_1].is_virtual = 1;", "css_generate_chp_crws(VAR_0, VAR_1);", "return 0;", "}" ]
[ 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 43 ], [ 45 ] ]
8,897
iscsi_readcapacity10_cb(struct iscsi_context *iscsi, int status, void *command_data, void *opaque) { struct IscsiTask *itask = opaque; struct scsi_readcapacity10 *rc10; struct scsi_task *task = command_data; if (status != 0) { error_report("iSCSI: Failed to read capacity of iSCSI lun. %s", iscsi_get_error(iscsi)); itask->status = 1; itask->complete = 1; scsi_free_scsi_task(task); return; } rc10 = scsi_datain_unmarshall(task); if (rc10 == NULL) { error_report("iSCSI: Failed to unmarshall readcapacity10 data."); itask->status = 1; itask->complete = 1; scsi_free_scsi_task(task); return; } itask->iscsilun->block_size = rc10->block_size; if (rc10->lba == 0) { /* blank disk loaded */ itask->iscsilun->num_blocks = 0; } else { itask->iscsilun->num_blocks = rc10->lba + 1; } itask->bs->total_sectors = itask->iscsilun->num_blocks * itask->iscsilun->block_size / BDRV_SECTOR_SIZE ; itask->status = 0; itask->complete = 1; scsi_free_scsi_task(task); }
true
qemu
e829b0bb054ed3389e5b22dad61875e51674e629
iscsi_readcapacity10_cb(struct iscsi_context *iscsi, int status, void *command_data, void *opaque) { struct IscsiTask *itask = opaque; struct scsi_readcapacity10 *rc10; struct scsi_task *task = command_data; if (status != 0) { error_report("iSCSI: Failed to read capacity of iSCSI lun. %s", iscsi_get_error(iscsi)); itask->status = 1; itask->complete = 1; scsi_free_scsi_task(task); return; } rc10 = scsi_datain_unmarshall(task); if (rc10 == NULL) { error_report("iSCSI: Failed to unmarshall readcapacity10 data."); itask->status = 1; itask->complete = 1; scsi_free_scsi_task(task); return; } itask->iscsilun->block_size = rc10->block_size; if (rc10->lba == 0) { itask->iscsilun->num_blocks = 0; } else { itask->iscsilun->num_blocks = rc10->lba + 1; } itask->bs->total_sectors = itask->iscsilun->num_blocks * itask->iscsilun->block_size / BDRV_SECTOR_SIZE ; itask->status = 0; itask->complete = 1; scsi_free_scsi_task(task); }
{ "code": [ " void *command_data, void *opaque)", " struct IscsiTask *itask = opaque;", " struct scsi_task *task = command_data;", " if (status != 0) {", " error_report(\"iSCSI: Failed to read capacity of iSCSI lun. %s\",", " iscsi_get_error(iscsi));", " itask->status = 1;", " itask->complete = 1;", " scsi_free_scsi_task(task);", " itask->status = 1;", " itask->complete = 1;", " scsi_free_scsi_task(task);", " itask->bs->total_sectors = itask->iscsilun->num_blocks *", " itask->iscsilun->block_size / BDRV_SECTOR_SIZE ;", " itask->status = 0;", " itask->complete = 1;", " scsi_free_scsi_task(task);", "iscsi_readcapacity10_cb(struct iscsi_context *iscsi, int status,", " void *command_data, void *opaque)", " struct IscsiTask *itask = opaque;", " struct scsi_readcapacity10 *rc10;", " struct scsi_task *task = command_data;", " if (status != 0) {", " error_report(\"iSCSI: Failed to read capacity of iSCSI lun. %s\",", " iscsi_get_error(iscsi));", " itask->status = 1;", " itask->complete = 1;", " scsi_free_scsi_task(task);", " rc10 = scsi_datain_unmarshall(task);", " if (rc10 == NULL) {", " error_report(\"iSCSI: Failed to unmarshall readcapacity10 data.\");", " itask->status = 1;", " itask->complete = 1;", " scsi_free_scsi_task(task);", " itask->iscsilun->block_size = rc10->block_size;", " if (rc10->lba == 0) {", " itask->iscsilun->num_blocks = 0;", " } else {", " itask->iscsilun->num_blocks = rc10->lba + 1;", " itask->bs->total_sectors = itask->iscsilun->num_blocks *", " itask->iscsilun->block_size / BDRV_SECTOR_SIZE ;", " itask->status = 0;", " itask->complete = 1;", " scsi_free_scsi_task(task);", " struct IscsiTask *itask = opaque;", " struct scsi_task *task = command_data;", " if (status != 0) {", " itask->status = 1;", " itask->complete = 1;", " scsi_free_scsi_task(task);", " itask->status = 1;", " itask->complete = 1;", " scsi_free_scsi_task(task);", " scsi_free_scsi_task(task);", " itask->complete = 1;", " struct IscsiTask *itask = opaque;", " if (status != 0) {", " itask->status = 1;", " itask->complete = 1;", " itask->status = 1;", " itask->complete = 1;", " iscsi_get_error(iscsi));" ], "line_no": [ 3, 7, 11, 15, 17, 19, 21, 23, 25, 21, 23, 25, 65, 67, 71, 73, 75, 1, 3, 7, 9, 11, 15, 17, 19, 21, 23, 25, 33, 35, 37, 21, 23, 25, 51, 53, 57, 59, 61, 65, 67, 71, 73, 75, 7, 11, 15, 21, 23, 25, 21, 23, 25, 75, 23, 7, 15, 21, 23, 21, 23, 19 ] }
FUNC_0(struct iscsi_context *VAR_0, int VAR_1, void *VAR_2, void *VAR_3) { struct IscsiTask *VAR_4 = VAR_3; struct scsi_readcapacity10 *VAR_5; struct scsi_task *VAR_6 = VAR_2; if (VAR_1 != 0) { error_report("iSCSI: Failed to read capacity of iSCSI lun. %s", iscsi_get_error(VAR_0)); VAR_4->VAR_1 = 1; VAR_4->complete = 1; scsi_free_scsi_task(VAR_6); return; } VAR_5 = scsi_datain_unmarshall(VAR_6); if (VAR_5 == NULL) { error_report("iSCSI: Failed to unmarshall readcapacity10 data."); VAR_4->VAR_1 = 1; VAR_4->complete = 1; scsi_free_scsi_task(VAR_6); return; } VAR_4->iscsilun->block_size = VAR_5->block_size; if (VAR_5->lba == 0) { VAR_4->iscsilun->num_blocks = 0; } else { VAR_4->iscsilun->num_blocks = VAR_5->lba + 1; } VAR_4->bs->total_sectors = VAR_4->iscsilun->num_blocks * VAR_4->iscsilun->block_size / BDRV_SECTOR_SIZE ; VAR_4->VAR_1 = 0; VAR_4->complete = 1; scsi_free_scsi_task(VAR_6); }
[ "FUNC_0(struct iscsi_context *VAR_0, int VAR_1,\nvoid *VAR_2, void *VAR_3)\n{", "struct IscsiTask *VAR_4 = VAR_3;", "struct scsi_readcapacity10 *VAR_5;", "struct scsi_task *VAR_6 = VAR_2;", "if (VAR_1 != 0) {", "error_report(\"iSCSI: Failed to read capacity of iSCSI lun. %s\",\niscsi_get_error(VAR_0));", "VAR_4->VAR_1 = 1;", "VAR_4->complete = 1;", "scsi_free_scsi_task(VAR_6);", "return;", "}", "VAR_5 = scsi_datain_unmarshall(VAR_6);", "if (VAR_5 == NULL) {", "error_report(\"iSCSI: Failed to unmarshall readcapacity10 data.\");", "VAR_4->VAR_1 = 1;", "VAR_4->complete = 1;", "scsi_free_scsi_task(VAR_6);", "return;", "}", "VAR_4->iscsilun->block_size = VAR_5->block_size;", "if (VAR_5->lba == 0) {", "VAR_4->iscsilun->num_blocks = 0;", "} else {", "VAR_4->iscsilun->num_blocks = VAR_5->lba + 1;", "}", "VAR_4->bs->total_sectors = VAR_4->iscsilun->num_blocks *\nVAR_4->iscsilun->block_size / BDRV_SECTOR_SIZE ;", "VAR_4->VAR_1 = 0;", "VAR_4->complete = 1;", "scsi_free_scsi_task(VAR_6);", "}" ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17, 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65, 67 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ] ]
8,898
bool qemu_net_queue_flush(NetQueue *queue) { while (!QTAILQ_EMPTY(&queue->packets)) { NetPacket *packet; int ret; packet = QTAILQ_FIRST(&queue->packets); QTAILQ_REMOVE(&queue->packets, packet, entry); ret = qemu_net_queue_deliver(queue, packet->sender, packet->flags, packet->data, packet->size); if (ret == 0) { queue->nq_count++; QTAILQ_INSERT_HEAD(&queue->packets, packet, entry); return false; } if (packet->sent_cb) { packet->sent_cb(packet->sender, ret); } g_free(packet); } return true; }
true
qemu
7d91ddd25e3a4e5008a2ac16127d51a34fd56bf1
bool qemu_net_queue_flush(NetQueue *queue) { while (!QTAILQ_EMPTY(&queue->packets)) { NetPacket *packet; int ret; packet = QTAILQ_FIRST(&queue->packets); QTAILQ_REMOVE(&queue->packets, packet, entry); ret = qemu_net_queue_deliver(queue, packet->sender, packet->flags, packet->data, packet->size); if (ret == 0) { queue->nq_count++; QTAILQ_INSERT_HEAD(&queue->packets, packet, entry); return false; } if (packet->sent_cb) { packet->sent_cb(packet->sender, ret); } g_free(packet); } return true; }
{ "code": [], "line_no": [] }
bool FUNC_0(NetQueue *queue) { while (!QTAILQ_EMPTY(&queue->packets)) { NetPacket *packet; int VAR_0; packet = QTAILQ_FIRST(&queue->packets); QTAILQ_REMOVE(&queue->packets, packet, entry); VAR_0 = qemu_net_queue_deliver(queue, packet->sender, packet->flags, packet->data, packet->size); if (VAR_0 == 0) { queue->nq_count++; QTAILQ_INSERT_HEAD(&queue->packets, packet, entry); return false; } if (packet->sent_cb) { packet->sent_cb(packet->sender, VAR_0); } g_free(packet); } return true; }
[ "bool FUNC_0(NetQueue *queue)\n{", "while (!QTAILQ_EMPTY(&queue->packets)) {", "NetPacket *packet;", "int VAR_0;", "packet = QTAILQ_FIRST(&queue->packets);", "QTAILQ_REMOVE(&queue->packets, packet, entry);", "VAR_0 = qemu_net_queue_deliver(queue,\npacket->sender,\npacket->flags,\npacket->data,\npacket->size);", "if (VAR_0 == 0) {", "queue->nq_count++;", "QTAILQ_INSERT_HEAD(&queue->packets, packet, entry);", "return false;", "}", "if (packet->sent_cb) {", "packet->sent_cb(packet->sender, VAR_0);", "}", "g_free(packet);", "}", "return true;", "}" ]
[ 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 ], [ 20, 22, 24, 26, 28 ], [ 30 ], [ 32 ], [ 34 ], [ 36 ], [ 38 ], [ 42 ], [ 44 ], [ 46 ], [ 50 ], [ 52 ], [ 54 ], [ 56 ] ]
8,899
void ffserver_parse_acl_row(FFServerStream *stream, FFServerStream* feed, FFServerIPAddressACL *ext_acl, const char *p, const char *filename, int line_num) { char arg[1024]; FFServerIPAddressACL acl; FFServerIPAddressACL *nacl; FFServerIPAddressACL **naclp; ffserver_get_arg(arg, sizeof(arg), &p); if (av_strcasecmp(arg, "allow") == 0) acl.action = IP_ALLOW; else if (av_strcasecmp(arg, "deny") == 0) acl.action = IP_DENY; else { fprintf(stderr, "%s:%d: ACL action '%s' should be ALLOW or DENY.\n", filename, line_num, arg); ffserver_get_arg(arg, sizeof(arg), &p); if (resolve_host(&acl.first, arg)) { fprintf(stderr, "%s:%d: ACL refers to invalid host or IP address '%s'\n", filename, line_num, arg); acl.last = acl.first; ffserver_get_arg(arg, sizeof(arg), &p); if (arg[0]) { if (resolve_host(&acl.last, arg)) { fprintf(stderr, "%s:%d: ACL refers to invalid host or IP address '%s'\n", filename, line_num, arg); nacl = av_mallocz(sizeof(*nacl)); naclp = 0; acl.next = 0; *nacl = acl; if (stream) naclp = &stream->acl; else if (feed) naclp = &feed->acl; else if (ext_acl) naclp = &ext_acl; else fprintf(stderr, "%s:%d: ACL found not in <Stream> or <Feed>\n", filename, line_num); if (naclp) { while (*naclp) naclp = &(*naclp)->next; *naclp = nacl; } else av_free(nacl); bail: return;
true
FFmpeg
f9315ea984efc1a58499664e27b75c37295381db
void ffserver_parse_acl_row(FFServerStream *stream, FFServerStream* feed, FFServerIPAddressACL *ext_acl, const char *p, const char *filename, int line_num) { char arg[1024]; FFServerIPAddressACL acl; FFServerIPAddressACL *nacl; FFServerIPAddressACL **naclp; ffserver_get_arg(arg, sizeof(arg), &p); if (av_strcasecmp(arg, "allow") == 0) acl.action = IP_ALLOW; else if (av_strcasecmp(arg, "deny") == 0) acl.action = IP_DENY; else { fprintf(stderr, "%s:%d: ACL action '%s' should be ALLOW or DENY.\n", filename, line_num, arg); ffserver_get_arg(arg, sizeof(arg), &p); if (resolve_host(&acl.first, arg)) { fprintf(stderr, "%s:%d: ACL refers to invalid host or IP address '%s'\n", filename, line_num, arg); acl.last = acl.first; ffserver_get_arg(arg, sizeof(arg), &p); if (arg[0]) { if (resolve_host(&acl.last, arg)) { fprintf(stderr, "%s:%d: ACL refers to invalid host or IP address '%s'\n", filename, line_num, arg); nacl = av_mallocz(sizeof(*nacl)); naclp = 0; acl.next = 0; *nacl = acl; if (stream) naclp = &stream->acl; else if (feed) naclp = &feed->acl; else if (ext_acl) naclp = &ext_acl; else fprintf(stderr, "%s:%d: ACL found not in <Stream> or <Feed>\n", filename, line_num); if (naclp) { while (*naclp) naclp = &(*naclp)->next; *naclp = nacl; } else av_free(nacl); bail: return;
{ "code": [], "line_no": [] }
void FUNC_0(FFServerStream *VAR_0, FFServerStream* VAR_1, FFServerIPAddressACL *VAR_2, const char *VAR_3, const char *VAR_4, int VAR_5) { char VAR_6[1024]; FFServerIPAddressACL acl; FFServerIPAddressACL *nacl; FFServerIPAddressACL **naclp; ffserver_get_arg(VAR_6, sizeof(VAR_6), &VAR_3); if (av_strcasecmp(VAR_6, "allow") == 0) acl.action = IP_ALLOW; else if (av_strcasecmp(VAR_6, "deny") == 0) acl.action = IP_DENY; else { fprintf(stderr, "%s:%d: ACL action '%s' should be ALLOW or DENY.\n", VAR_4, VAR_5, VAR_6); ffserver_get_arg(VAR_6, sizeof(VAR_6), &VAR_3); if (resolve_host(&acl.first, VAR_6)) { fprintf(stderr, "%s:%d: ACL refers to invalid host or IP address '%s'\n", VAR_4, VAR_5, VAR_6); acl.last = acl.first; ffserver_get_arg(VAR_6, sizeof(VAR_6), &VAR_3); if (VAR_6[0]) { if (resolve_host(&acl.last, VAR_6)) { fprintf(stderr, "%s:%d: ACL refers to invalid host or IP address '%s'\n", VAR_4, VAR_5, VAR_6); nacl = av_mallocz(sizeof(*nacl)); naclp = 0; acl.next = 0; *nacl = acl; if (VAR_0) naclp = &VAR_0->acl; else if (VAR_1) naclp = &VAR_1->acl; else if (VAR_2) naclp = &VAR_2; else fprintf(stderr, "%s:%d: ACL found not in <Stream> or <Feed>\n", VAR_4, VAR_5); if (naclp) { while (*naclp) naclp = &(*naclp)->next; *naclp = nacl; } else av_free(nacl); bail: return;
[ "void FUNC_0(FFServerStream *VAR_0, FFServerStream* VAR_1,\nFFServerIPAddressACL *VAR_2,\nconst char *VAR_3, const char *VAR_4, int VAR_5)\n{", "char VAR_6[1024];", "FFServerIPAddressACL acl;", "FFServerIPAddressACL *nacl;", "FFServerIPAddressACL **naclp;", "ffserver_get_arg(VAR_6, sizeof(VAR_6), &VAR_3);", "if (av_strcasecmp(VAR_6, \"allow\") == 0)\nacl.action = IP_ALLOW;", "else if (av_strcasecmp(VAR_6, \"deny\") == 0)\nacl.action = IP_DENY;", "else {", "fprintf(stderr, \"%s:%d: ACL action '%s' should be ALLOW or DENY.\\n\",\nVAR_4, VAR_5, VAR_6);", "ffserver_get_arg(VAR_6, sizeof(VAR_6), &VAR_3);", "if (resolve_host(&acl.first, VAR_6)) {", "fprintf(stderr,\n\"%s:%d: ACL refers to invalid host or IP address '%s'\\n\",\nVAR_4, VAR_5, VAR_6);", "acl.last = acl.first;", "ffserver_get_arg(VAR_6, sizeof(VAR_6), &VAR_3);", "if (VAR_6[0]) {", "if (resolve_host(&acl.last, VAR_6)) {", "fprintf(stderr,\n\"%s:%d: ACL refers to invalid host or IP address '%s'\\n\",\nVAR_4, VAR_5, VAR_6);", "nacl = av_mallocz(sizeof(*nacl));", "naclp = 0;", "acl.next = 0;", "*nacl = acl;", "if (VAR_0)\nnaclp = &VAR_0->acl;", "else if (VAR_1)\nnaclp = &VAR_1->acl;", "else if (VAR_2)\nnaclp = &VAR_2;", "else\nfprintf(stderr, \"%s:%d: ACL found not in <Stream> or <Feed>\\n\",\nVAR_4, VAR_5);", "if (naclp) {", "while (*naclp)\nnaclp = &(*naclp)->next;", "*naclp = nacl;", "} else", "av_free(nacl);", "bail:\nreturn;" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 2, 3, 4 ], [ 5 ], [ 6 ], [ 7 ], [ 8 ], [ 9 ], [ 10, 11 ], [ 12, 13 ], [ 14 ], [ 15, 16 ], [ 17 ], [ 18 ], [ 19, 20, 21 ], [ 22 ], [ 23 ], [ 24 ], [ 25 ], [ 26, 27, 28 ], [ 29 ], [ 30 ], [ 31 ], [ 32 ], [ 33, 34 ], [ 35, 36 ], [ 37, 38 ], [ 39, 40, 41 ], [ 42 ], [ 43, 44 ], [ 45 ], [ 46 ], [ 47 ], [ 48, 49 ] ]
8,902
static int check_refblocks(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix, uint16_t **refcount_table, int64_t *nb_clusters) { BDRVQcowState *s = bs->opaque; int64_t i, size; int ret; for(i = 0; i < s->refcount_table_size; i++) { uint64_t offset, cluster; offset = s->refcount_table[i]; cluster = offset >> s->cluster_bits; /* Refcount blocks are cluster aligned */ if (offset_into_cluster(s, offset)) { fprintf(stderr, "ERROR refcount block %" PRId64 " is not " "cluster aligned; refcount table entry corrupted\n", i); res->corruptions++; continue; } if (cluster >= *nb_clusters) { fprintf(stderr, "%s refcount block %" PRId64 " is outside image\n", fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); if (fix & BDRV_FIX_ERRORS) { int64_t old_nb_clusters = *nb_clusters; uint16_t *new_refcount_table; if (offset > INT64_MAX - s->cluster_size) { ret = -EINVAL; goto resize_fail; } ret = bdrv_truncate(bs->file, offset + s->cluster_size); if (ret < 0) { goto resize_fail; } size = bdrv_getlength(bs->file); if (size < 0) { ret = size; goto resize_fail; } *nb_clusters = size_to_clusters(s, size); assert(*nb_clusters >= old_nb_clusters); new_refcount_table = g_try_realloc(*refcount_table, *nb_clusters * sizeof(**refcount_table)); if (!new_refcount_table) { *nb_clusters = old_nb_clusters; res->check_errors++; return -ENOMEM; } *refcount_table = new_refcount_table; memset(*refcount_table + old_nb_clusters, 0, (*nb_clusters - old_nb_clusters) * sizeof(**refcount_table)); if (cluster >= *nb_clusters) { ret = -EINVAL; goto resize_fail; } res->corruptions_fixed++; ret = inc_refcounts(bs, res, refcount_table, nb_clusters, offset, s->cluster_size); if (ret < 0) { return ret; } /* No need to check whether the refcount is now greater than 1: * This area was just allocated and zeroed, so it can only be * exactly 1 after inc_refcounts() */ continue; resize_fail: res->corruptions++; fprintf(stderr, "ERROR could not resize image: %s\n", strerror(-ret)); } else { res->corruptions++; } continue; } if (offset != 0) { ret = inc_refcounts(bs, res, refcount_table, nb_clusters, offset, s->cluster_size); if (ret < 0) { return ret; } if ((*refcount_table)[cluster] != 1) { fprintf(stderr, "%s refcount block %" PRId64 " refcount=%d\n", fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i, (*refcount_table)[cluster]); if (fix & BDRV_FIX_ERRORS) { int64_t new_offset; new_offset = realloc_refcount_block(bs, i, offset); if (new_offset < 0) { res->corruptions++; continue; } /* update refcounts */ if ((new_offset >> s->cluster_bits) >= *nb_clusters) { /* increase refcount_table size if necessary */ int old_nb_clusters = *nb_clusters; *nb_clusters = (new_offset >> s->cluster_bits) + 1; *refcount_table = g_renew(uint16_t, *refcount_table, *nb_clusters); memset(&(*refcount_table)[old_nb_clusters], 0, (*nb_clusters - old_nb_clusters) * sizeof(**refcount_table)); } (*refcount_table)[cluster]--; ret = inc_refcounts(bs, res, refcount_table, nb_clusters, new_offset, s->cluster_size); if (ret < 0) { return ret; } res->corruptions_fixed++; } else { res->corruptions++; } } } } return 0; }
true
qemu
f307b2558f61e068ce514f2dde2cad74c62036d6
static int check_refblocks(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix, uint16_t **refcount_table, int64_t *nb_clusters) { BDRVQcowState *s = bs->opaque; int64_t i, size; int ret; for(i = 0; i < s->refcount_table_size; i++) { uint64_t offset, cluster; offset = s->refcount_table[i]; cluster = offset >> s->cluster_bits; if (offset_into_cluster(s, offset)) { fprintf(stderr, "ERROR refcount block %" PRId64 " is not " "cluster aligned; refcount table entry corrupted\n", i); res->corruptions++; continue; } if (cluster >= *nb_clusters) { fprintf(stderr, "%s refcount block %" PRId64 " is outside image\n", fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); if (fix & BDRV_FIX_ERRORS) { int64_t old_nb_clusters = *nb_clusters; uint16_t *new_refcount_table; if (offset > INT64_MAX - s->cluster_size) { ret = -EINVAL; goto resize_fail; } ret = bdrv_truncate(bs->file, offset + s->cluster_size); if (ret < 0) { goto resize_fail; } size = bdrv_getlength(bs->file); if (size < 0) { ret = size; goto resize_fail; } *nb_clusters = size_to_clusters(s, size); assert(*nb_clusters >= old_nb_clusters); new_refcount_table = g_try_realloc(*refcount_table, *nb_clusters * sizeof(**refcount_table)); if (!new_refcount_table) { *nb_clusters = old_nb_clusters; res->check_errors++; return -ENOMEM; } *refcount_table = new_refcount_table; memset(*refcount_table + old_nb_clusters, 0, (*nb_clusters - old_nb_clusters) * sizeof(**refcount_table)); if (cluster >= *nb_clusters) { ret = -EINVAL; goto resize_fail; } res->corruptions_fixed++; ret = inc_refcounts(bs, res, refcount_table, nb_clusters, offset, s->cluster_size); if (ret < 0) { return ret; } continue; resize_fail: res->corruptions++; fprintf(stderr, "ERROR could not resize image: %s\n", strerror(-ret)); } else { res->corruptions++; } continue; } if (offset != 0) { ret = inc_refcounts(bs, res, refcount_table, nb_clusters, offset, s->cluster_size); if (ret < 0) { return ret; } if ((*refcount_table)[cluster] != 1) { fprintf(stderr, "%s refcount block %" PRId64 " refcount=%d\n", fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i, (*refcount_table)[cluster]); if (fix & BDRV_FIX_ERRORS) { int64_t new_offset; new_offset = realloc_refcount_block(bs, i, offset); if (new_offset < 0) { res->corruptions++; continue; } if ((new_offset >> s->cluster_bits) >= *nb_clusters) { int old_nb_clusters = *nb_clusters; *nb_clusters = (new_offset >> s->cluster_bits) + 1; *refcount_table = g_renew(uint16_t, *refcount_table, *nb_clusters); memset(&(*refcount_table)[old_nb_clusters], 0, (*nb_clusters - old_nb_clusters) * sizeof(**refcount_table)); } (*refcount_table)[cluster]--; ret = inc_refcounts(bs, res, refcount_table, nb_clusters, new_offset, s->cluster_size); if (ret < 0) { return ret; } res->corruptions_fixed++; } else { res->corruptions++; } } } } return 0; }
{ "code": [ " BDRVQcowState *s = bs->opaque;", " return 0;", " BDRVQcowState *s = bs->opaque;", " int ret;", " BdrvCheckMode fix, uint16_t **refcount_table,", " int64_t *nb_clusters)", " fprintf(stderr, \"%s refcount block %\" PRId64", " \" refcount=%d\\n\",", " fix & BDRV_FIX_ERRORS ? \"Repairing\" :", " \"ERROR\",", " i, (*refcount_table)[cluster]);", " if (fix & BDRV_FIX_ERRORS) {", " int64_t new_offset;", " new_offset = realloc_refcount_block(bs, i, offset);", " if (new_offset < 0) {", " res->corruptions++;", " continue;", " if ((new_offset >> s->cluster_bits) >= *nb_clusters) {", " int old_nb_clusters = *nb_clusters;", " *nb_clusters = (new_offset >> s->cluster_bits) + 1;", " *refcount_table = g_renew(uint16_t, *refcount_table,", " *nb_clusters);", " memset(&(*refcount_table)[old_nb_clusters], 0,", " (*nb_clusters - old_nb_clusters) *", " sizeof(**refcount_table));", " (*refcount_table)[cluster]--;", " ret = inc_refcounts(bs, res, refcount_table, nb_clusters,", " new_offset, s->cluster_size);", " if (ret < 0) {", " return ret;", " res->corruptions_fixed++;", " } else {", " res->corruptions++;" ], "line_no": [ 9, 271, 9, 13, 3, 5, 189, 191, 193, 195, 197, 201, 203, 207, 209, 211, 213, 221, 225, 227, 229, 231, 233, 235, 237, 241, 243, 245, 247, 249, 255, 257, 259 ] }
static int FUNC_0(BlockDriverState *VAR_0, BdrvCheckResult *VAR_1, BdrvCheckMode VAR_2, uint16_t **VAR_3, int64_t *VAR_4) { BDRVQcowState *s = VAR_0->opaque; int64_t i, size; int VAR_5; for(i = 0; i < s->refcount_table_size; i++) { uint64_t offset, cluster; offset = s->VAR_3[i]; cluster = offset >> s->cluster_bits; if (offset_into_cluster(s, offset)) { fprintf(stderr, "ERROR refcount block %" PRId64 " is not " "cluster aligned; refcount table entry corrupted\n", i); VAR_1->corruptions++; continue; } if (cluster >= *VAR_4) { fprintf(stderr, "%s refcount block %" PRId64 " is outside image\n", VAR_2 & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); if (VAR_2 & BDRV_FIX_ERRORS) { int64_t old_nb_clusters = *VAR_4; uint16_t *new_refcount_table; if (offset > INT64_MAX - s->cluster_size) { VAR_5 = -EINVAL; goto resize_fail; } VAR_5 = bdrv_truncate(VAR_0->file, offset + s->cluster_size); if (VAR_5 < 0) { goto resize_fail; } size = bdrv_getlength(VAR_0->file); if (size < 0) { VAR_5 = size; goto resize_fail; } *VAR_4 = size_to_clusters(s, size); assert(*VAR_4 >= old_nb_clusters); new_refcount_table = g_try_realloc(*VAR_3, *VAR_4 * sizeof(**VAR_3)); if (!new_refcount_table) { *VAR_4 = old_nb_clusters; VAR_1->check_errors++; return -ENOMEM; } *VAR_3 = new_refcount_table; memset(*VAR_3 + old_nb_clusters, 0, (*VAR_4 - old_nb_clusters) * sizeof(**VAR_3)); if (cluster >= *VAR_4) { VAR_5 = -EINVAL; goto resize_fail; } VAR_1->corruptions_fixed++; VAR_5 = inc_refcounts(VAR_0, VAR_1, VAR_3, VAR_4, offset, s->cluster_size); if (VAR_5 < 0) { return VAR_5; } continue; resize_fail: VAR_1->corruptions++; fprintf(stderr, "ERROR could not resize image: %s\n", strerror(-VAR_5)); } else { VAR_1->corruptions++; } continue; } if (offset != 0) { VAR_5 = inc_refcounts(VAR_0, VAR_1, VAR_3, VAR_4, offset, s->cluster_size); if (VAR_5 < 0) { return VAR_5; } if ((*VAR_3)[cluster] != 1) { fprintf(stderr, "%s refcount block %" PRId64 " refcount=%d\n", VAR_2 & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i, (*VAR_3)[cluster]); if (VAR_2 & BDRV_FIX_ERRORS) { int64_t new_offset; new_offset = realloc_refcount_block(VAR_0, i, offset); if (new_offset < 0) { VAR_1->corruptions++; continue; } if ((new_offset >> s->cluster_bits) >= *VAR_4) { int old_nb_clusters = *VAR_4; *VAR_4 = (new_offset >> s->cluster_bits) + 1; *VAR_3 = g_renew(uint16_t, *VAR_3, *VAR_4); memset(&(*VAR_3)[old_nb_clusters], 0, (*VAR_4 - old_nb_clusters) * sizeof(**VAR_3)); } (*VAR_3)[cluster]--; VAR_5 = inc_refcounts(VAR_0, VAR_1, VAR_3, VAR_4, new_offset, s->cluster_size); if (VAR_5 < 0) { return VAR_5; } VAR_1->corruptions_fixed++; } else { VAR_1->corruptions++; } } } } return 0; }
[ "static int FUNC_0(BlockDriverState *VAR_0, BdrvCheckResult *VAR_1,\nBdrvCheckMode VAR_2, uint16_t **VAR_3,\nint64_t *VAR_4)\n{", "BDRVQcowState *s = VAR_0->opaque;", "int64_t i, size;", "int VAR_5;", "for(i = 0; i < s->refcount_table_size; i++) {", "uint64_t offset, cluster;", "offset = s->VAR_3[i];", "cluster = offset >> s->cluster_bits;", "if (offset_into_cluster(s, offset)) {", "fprintf(stderr, \"ERROR refcount block %\" PRId64 \" is not \"\n\"cluster aligned; refcount table entry corrupted\\n\", i);", "VAR_1->corruptions++;", "continue;", "}", "if (cluster >= *VAR_4) {", "fprintf(stderr, \"%s refcount block %\" PRId64 \" is outside image\\n\",\nVAR_2 & BDRV_FIX_ERRORS ? \"Repairing\" : \"ERROR\", i);", "if (VAR_2 & BDRV_FIX_ERRORS) {", "int64_t old_nb_clusters = *VAR_4;", "uint16_t *new_refcount_table;", "if (offset > INT64_MAX - s->cluster_size) {", "VAR_5 = -EINVAL;", "goto resize_fail;", "}", "VAR_5 = bdrv_truncate(VAR_0->file, offset + s->cluster_size);", "if (VAR_5 < 0) {", "goto resize_fail;", "}", "size = bdrv_getlength(VAR_0->file);", "if (size < 0) {", "VAR_5 = size;", "goto resize_fail;", "}", "*VAR_4 = size_to_clusters(s, size);", "assert(*VAR_4 >= old_nb_clusters);", "new_refcount_table = g_try_realloc(*VAR_3,\n*VAR_4 *\nsizeof(**VAR_3));", "if (!new_refcount_table) {", "*VAR_4 = old_nb_clusters;", "VAR_1->check_errors++;", "return -ENOMEM;", "}", "*VAR_3 = new_refcount_table;", "memset(*VAR_3 + old_nb_clusters, 0,\n(*VAR_4 - old_nb_clusters) *\nsizeof(**VAR_3));", "if (cluster >= *VAR_4) {", "VAR_5 = -EINVAL;", "goto resize_fail;", "}", "VAR_1->corruptions_fixed++;", "VAR_5 = inc_refcounts(VAR_0, VAR_1, VAR_3, VAR_4,\noffset, s->cluster_size);", "if (VAR_5 < 0) {", "return VAR_5;", "}", "continue;", "resize_fail:\nVAR_1->corruptions++;", "fprintf(stderr, \"ERROR could not resize image: %s\\n\",\nstrerror(-VAR_5));", "} else {", "VAR_1->corruptions++;", "}", "continue;", "}", "if (offset != 0) {", "VAR_5 = inc_refcounts(VAR_0, VAR_1, VAR_3, VAR_4,\noffset, s->cluster_size);", "if (VAR_5 < 0) {", "return VAR_5;", "}", "if ((*VAR_3)[cluster] != 1) {", "fprintf(stderr, \"%s refcount block %\" PRId64\n\" refcount=%d\\n\",\nVAR_2 & BDRV_FIX_ERRORS ? \"Repairing\" :\n\"ERROR\",\ni, (*VAR_3)[cluster]);", "if (VAR_2 & BDRV_FIX_ERRORS) {", "int64_t new_offset;", "new_offset = realloc_refcount_block(VAR_0, i, offset);", "if (new_offset < 0) {", "VAR_1->corruptions++;", "continue;", "}", "if ((new_offset >> s->cluster_bits) >= *VAR_4) {", "int old_nb_clusters = *VAR_4;", "*VAR_4 = (new_offset >> s->cluster_bits) + 1;", "*VAR_3 = g_renew(uint16_t, *VAR_3,\n*VAR_4);", "memset(&(*VAR_3)[old_nb_clusters], 0,\n(*VAR_4 - old_nb_clusters) *\nsizeof(**VAR_3));", "}", "(*VAR_3)[cluster]--;", "VAR_5 = inc_refcounts(VAR_0, VAR_1, VAR_3, VAR_4,\nnew_offset, s->cluster_size);", "if (VAR_5 < 0) {", "return VAR_5;", "}", "VAR_1->corruptions_fixed++;", "} else {", "VAR_1->corruptions++;", "}", "}", "}", "}", "return 0;", "}" ]
[ 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 29 ], [ 31, 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45, 47 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 89 ], [ 91 ], [ 95, 97, 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 115, 117, 119 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 133 ], [ 135, 137 ], [ 139 ], [ 141 ], [ 143 ], [ 151 ], [ 155, 157 ], [ 159, 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 175 ], [ 177, 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189, 191, 193, 195, 197 ], [ 201 ], [ 203 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 221 ], [ 225 ], [ 227 ], [ 229, 231 ], [ 233, 235, 237 ], [ 239 ], [ 241 ], [ 243, 245 ], [ 247 ], [ 249 ], [ 251 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 271 ], [ 273 ] ]
8,904
static void handle_sys(DisasContext *s, uint32_t insn, bool isread, unsigned int op0, unsigned int op1, unsigned int op2, unsigned int crn, unsigned int crm, unsigned int rt) { const ARMCPRegInfo *ri; TCGv_i64 tcg_rt; ri = get_arm_cp_reginfo(s->cp_regs, ENCODE_AA64_CP_REG(CP_REG_ARM64_SYSREG_CP, crn, crm, op0, op1, op2)); if (!ri) { /* Unknown register; this might be a guest error or a QEMU * unimplemented feature. */ qemu_log_mask(LOG_UNIMP, "%s access to unsupported AArch64 " "system register op0:%d op1:%d crn:%d crm:%d op2:%d\n", isread ? "read" : "write", op0, op1, crn, crm, op2); unallocated_encoding(s); return; } /* Check access permissions */ if (!cp_access_ok(s->current_pl, ri, isread)) { unallocated_encoding(s); return; } if (ri->accessfn) { /* Emit code to perform further access permissions checks at * runtime; this may result in an exception. */ TCGv_ptr tmpptr; gen_a64_set_pc_im(s->pc - 4); tmpptr = tcg_const_ptr(ri); gen_helper_access_check_cp_reg(cpu_env, tmpptr); tcg_temp_free_ptr(tmpptr); } /* Handle special cases first */ switch (ri->type & ~(ARM_CP_FLAG_MASK & ~ARM_CP_SPECIAL)) { case ARM_CP_NOP: return; case ARM_CP_NZCV: tcg_rt = cpu_reg(s, rt); if (isread) { gen_get_nzcv(tcg_rt); } else { gen_set_nzcv(tcg_rt); } return; case ARM_CP_CURRENTEL: /* Reads as current EL value from pstate, which is * guaranteed to be constant by the tb flags. */ tcg_rt = cpu_reg(s, rt); tcg_gen_movi_i64(tcg_rt, s->current_pl << 2); return; default: break; } if (use_icount && (ri->type & ARM_CP_IO)) { gen_io_start(); } tcg_rt = cpu_reg(s, rt); if (isread) { if (ri->type & ARM_CP_CONST) { tcg_gen_movi_i64(tcg_rt, ri->resetvalue); } else if (ri->readfn) { TCGv_ptr tmpptr; tmpptr = tcg_const_ptr(ri); gen_helper_get_cp_reg64(tcg_rt, cpu_env, tmpptr); tcg_temp_free_ptr(tmpptr); } else { tcg_gen_ld_i64(tcg_rt, cpu_env, ri->fieldoffset); } } else { if (ri->type & ARM_CP_CONST) { /* If not forbidden by access permissions, treat as WI */ return; } else if (ri->writefn) { TCGv_ptr tmpptr; tmpptr = tcg_const_ptr(ri); gen_helper_set_cp_reg64(cpu_env, tmpptr, tcg_rt); tcg_temp_free_ptr(tmpptr); } else { tcg_gen_st_i64(tcg_rt, cpu_env, ri->fieldoffset); } } if (use_icount && (ri->type & ARM_CP_IO)) { /* I/O operations must end the TB here (whether read or write) */ gen_io_end(); s->is_jmp = DISAS_UPDATE; } else if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { /* We default to ending the TB on a coprocessor register write, * but allow this to be suppressed by the register definition * (usually only necessary to work around guest bugs). */ s->is_jmp = DISAS_UPDATE; } }
true
qemu
8bcbf37caa87ba89bc391bad70039f942a98c7e3
static void handle_sys(DisasContext *s, uint32_t insn, bool isread, unsigned int op0, unsigned int op1, unsigned int op2, unsigned int crn, unsigned int crm, unsigned int rt) { const ARMCPRegInfo *ri; TCGv_i64 tcg_rt; ri = get_arm_cp_reginfo(s->cp_regs, ENCODE_AA64_CP_REG(CP_REG_ARM64_SYSREG_CP, crn, crm, op0, op1, op2)); if (!ri) { qemu_log_mask(LOG_UNIMP, "%s access to unsupported AArch64 " "system register op0:%d op1:%d crn:%d crm:%d op2:%d\n", isread ? "read" : "write", op0, op1, crn, crm, op2); unallocated_encoding(s); return; } if (!cp_access_ok(s->current_pl, ri, isread)) { unallocated_encoding(s); return; } if (ri->accessfn) { TCGv_ptr tmpptr; gen_a64_set_pc_im(s->pc - 4); tmpptr = tcg_const_ptr(ri); gen_helper_access_check_cp_reg(cpu_env, tmpptr); tcg_temp_free_ptr(tmpptr); } switch (ri->type & ~(ARM_CP_FLAG_MASK & ~ARM_CP_SPECIAL)) { case ARM_CP_NOP: return; case ARM_CP_NZCV: tcg_rt = cpu_reg(s, rt); if (isread) { gen_get_nzcv(tcg_rt); } else { gen_set_nzcv(tcg_rt); } return; case ARM_CP_CURRENTEL: tcg_rt = cpu_reg(s, rt); tcg_gen_movi_i64(tcg_rt, s->current_pl << 2); return; default: break; } if (use_icount && (ri->type & ARM_CP_IO)) { gen_io_start(); } tcg_rt = cpu_reg(s, rt); if (isread) { if (ri->type & ARM_CP_CONST) { tcg_gen_movi_i64(tcg_rt, ri->resetvalue); } else if (ri->readfn) { TCGv_ptr tmpptr; tmpptr = tcg_const_ptr(ri); gen_helper_get_cp_reg64(tcg_rt, cpu_env, tmpptr); tcg_temp_free_ptr(tmpptr); } else { tcg_gen_ld_i64(tcg_rt, cpu_env, ri->fieldoffset); } } else { if (ri->type & ARM_CP_CONST) { return; } else if (ri->writefn) { TCGv_ptr tmpptr; tmpptr = tcg_const_ptr(ri); gen_helper_set_cp_reg64(cpu_env, tmpptr, tcg_rt); tcg_temp_free_ptr(tmpptr); } else { tcg_gen_st_i64(tcg_rt, cpu_env, ri->fieldoffset); } } if (use_icount && (ri->type & ARM_CP_IO)) { gen_io_end(); s->is_jmp = DISAS_UPDATE; } else if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { s->is_jmp = DISAS_UPDATE; } }
{ "code": [ " gen_helper_access_check_cp_reg(cpu_env, tmpptr);" ], "line_no": [ 71 ] }
static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1, bool VAR_2, unsigned int VAR_3, unsigned int VAR_4, unsigned int VAR_5, unsigned int VAR_6, unsigned int VAR_7, unsigned int VAR_8) { const ARMCPRegInfo *VAR_9; TCGv_i64 tcg_rt; VAR_9 = get_arm_cp_reginfo(VAR_0->cp_regs, ENCODE_AA64_CP_REG(CP_REG_ARM64_SYSREG_CP, VAR_6, VAR_7, VAR_3, VAR_4, VAR_5)); if (!VAR_9) { qemu_log_mask(LOG_UNIMP, "%VAR_0 access to unsupported AArch64 " "system register VAR_3:%d VAR_4:%d VAR_6:%d VAR_7:%d VAR_5:%d\n", VAR_2 ? "read" : "write", VAR_3, VAR_4, VAR_6, VAR_7, VAR_5); unallocated_encoding(VAR_0); return; } if (!cp_access_ok(VAR_0->current_pl, VAR_9, VAR_2)) { unallocated_encoding(VAR_0); return; } if (VAR_9->accessfn) { TCGv_ptr tmpptr; gen_a64_set_pc_im(VAR_0->pc - 4); tmpptr = tcg_const_ptr(VAR_9); gen_helper_access_check_cp_reg(cpu_env, tmpptr); tcg_temp_free_ptr(tmpptr); } switch (VAR_9->type & ~(ARM_CP_FLAG_MASK & ~ARM_CP_SPECIAL)) { case ARM_CP_NOP: return; case ARM_CP_NZCV: tcg_rt = cpu_reg(VAR_0, VAR_8); if (VAR_2) { gen_get_nzcv(tcg_rt); } else { gen_set_nzcv(tcg_rt); } return; case ARM_CP_CURRENTEL: tcg_rt = cpu_reg(VAR_0, VAR_8); tcg_gen_movi_i64(tcg_rt, VAR_0->current_pl << 2); return; default: break; } if (use_icount && (VAR_9->type & ARM_CP_IO)) { gen_io_start(); } tcg_rt = cpu_reg(VAR_0, VAR_8); if (VAR_2) { if (VAR_9->type & ARM_CP_CONST) { tcg_gen_movi_i64(tcg_rt, VAR_9->resetvalue); } else if (VAR_9->readfn) { TCGv_ptr tmpptr; tmpptr = tcg_const_ptr(VAR_9); gen_helper_get_cp_reg64(tcg_rt, cpu_env, tmpptr); tcg_temp_free_ptr(tmpptr); } else { tcg_gen_ld_i64(tcg_rt, cpu_env, VAR_9->fieldoffset); } } else { if (VAR_9->type & ARM_CP_CONST) { return; } else if (VAR_9->writefn) { TCGv_ptr tmpptr; tmpptr = tcg_const_ptr(VAR_9); gen_helper_set_cp_reg64(cpu_env, tmpptr, tcg_rt); tcg_temp_free_ptr(tmpptr); } else { tcg_gen_st_i64(tcg_rt, cpu_env, VAR_9->fieldoffset); } } if (use_icount && (VAR_9->type & ARM_CP_IO)) { gen_io_end(); VAR_0->is_jmp = DISAS_UPDATE; } else if (!VAR_2 && !(VAR_9->type & ARM_CP_SUPPRESS_TB_END)) { VAR_0->is_jmp = DISAS_UPDATE; } }
[ "static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1, bool VAR_2,\nunsigned int VAR_3, unsigned int VAR_4, unsigned int VAR_5,\nunsigned int VAR_6, unsigned int VAR_7, unsigned int VAR_8)\n{", "const ARMCPRegInfo *VAR_9;", "TCGv_i64 tcg_rt;", "VAR_9 = get_arm_cp_reginfo(VAR_0->cp_regs,\nENCODE_AA64_CP_REG(CP_REG_ARM64_SYSREG_CP,\nVAR_6, VAR_7, VAR_3, VAR_4, VAR_5));", "if (!VAR_9) {", "qemu_log_mask(LOG_UNIMP, \"%VAR_0 access to unsupported AArch64 \"\n\"system register VAR_3:%d VAR_4:%d VAR_6:%d VAR_7:%d VAR_5:%d\\n\",\nVAR_2 ? \"read\" : \"write\", VAR_3, VAR_4, VAR_6, VAR_7, VAR_5);", "unallocated_encoding(VAR_0);", "return;", "}", "if (!cp_access_ok(VAR_0->current_pl, VAR_9, VAR_2)) {", "unallocated_encoding(VAR_0);", "return;", "}", "if (VAR_9->accessfn) {", "TCGv_ptr tmpptr;", "gen_a64_set_pc_im(VAR_0->pc - 4);", "tmpptr = tcg_const_ptr(VAR_9);", "gen_helper_access_check_cp_reg(cpu_env, tmpptr);", "tcg_temp_free_ptr(tmpptr);", "}", "switch (VAR_9->type & ~(ARM_CP_FLAG_MASK & ~ARM_CP_SPECIAL)) {", "case ARM_CP_NOP:\nreturn;", "case ARM_CP_NZCV:\ntcg_rt = cpu_reg(VAR_0, VAR_8);", "if (VAR_2) {", "gen_get_nzcv(tcg_rt);", "} else {", "gen_set_nzcv(tcg_rt);", "}", "return;", "case ARM_CP_CURRENTEL:\ntcg_rt = cpu_reg(VAR_0, VAR_8);", "tcg_gen_movi_i64(tcg_rt, VAR_0->current_pl << 2);", "return;", "default:\nbreak;", "}", "if (use_icount && (VAR_9->type & ARM_CP_IO)) {", "gen_io_start();", "}", "tcg_rt = cpu_reg(VAR_0, VAR_8);", "if (VAR_2) {", "if (VAR_9->type & ARM_CP_CONST) {", "tcg_gen_movi_i64(tcg_rt, VAR_9->resetvalue);", "} else if (VAR_9->readfn) {", "TCGv_ptr tmpptr;", "tmpptr = tcg_const_ptr(VAR_9);", "gen_helper_get_cp_reg64(tcg_rt, cpu_env, tmpptr);", "tcg_temp_free_ptr(tmpptr);", "} else {", "tcg_gen_ld_i64(tcg_rt, cpu_env, VAR_9->fieldoffset);", "}", "} else {", "if (VAR_9->type & ARM_CP_CONST) {", "return;", "} else if (VAR_9->writefn) {", "TCGv_ptr tmpptr;", "tmpptr = tcg_const_ptr(VAR_9);", "gen_helper_set_cp_reg64(cpu_env, tmpptr, tcg_rt);", "tcg_temp_free_ptr(tmpptr);", "} else {", "tcg_gen_st_i64(tcg_rt, cpu_env, VAR_9->fieldoffset);", "}", "}", "if (use_icount && (VAR_9->type & ARM_CP_IO)) {", "gen_io_end();", "VAR_0->is_jmp = DISAS_UPDATE;", "} else if (!VAR_2 && !(VAR_9->type & ARM_CP_SUPPRESS_TB_END)) {", "VAR_0->is_jmp = DISAS_UPDATE;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 15, 17, 19 ], [ 23 ], [ 31, 33, 35 ], [ 37 ], [ 39 ], [ 41 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 81 ], [ 83, 85 ], [ 87, 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103, 111 ], [ 113 ], [ 115 ], [ 117, 119 ], [ 121 ], [ 125 ], [ 127 ], [ 129 ], [ 133 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 187 ], [ 191 ], [ 193 ], [ 195 ], [ 205 ], [ 207 ], [ 209 ] ]
8,905
soread(so) struct socket *so; { int n, nn, lss, total; struct sbuf *sb = &so->so_snd; int len = sb->sb_datalen - sb->sb_cc; struct iovec iov[2]; int mss = so->so_tcpcb->t_maxseg; DEBUG_CALL("soread"); DEBUG_ARG("so = %lx", (long )so); /* * No need to check if there's enough room to read. * soread wouldn't have been called if there weren't */ len = sb->sb_datalen - sb->sb_cc; iov[0].iov_base = sb->sb_wptr; if (sb->sb_wptr < sb->sb_rptr) { iov[0].iov_len = sb->sb_rptr - sb->sb_wptr; /* Should never succeed, but... */ if (iov[0].iov_len > len) iov[0].iov_len = len; if (iov[0].iov_len > mss) iov[0].iov_len -= iov[0].iov_len%mss; n = 1; } else { iov[0].iov_len = (sb->sb_data + sb->sb_datalen) - sb->sb_wptr; /* Should never succeed, but... */ if (iov[0].iov_len > len) iov[0].iov_len = len; len -= iov[0].iov_len; if (len) { iov[1].iov_base = sb->sb_data; iov[1].iov_len = sb->sb_rptr - sb->sb_data; if(iov[1].iov_len > len) iov[1].iov_len = len; total = iov[0].iov_len + iov[1].iov_len; if (total > mss) { lss = total%mss; if (iov[1].iov_len > lss) { iov[1].iov_len -= lss; n = 2; } else { lss -= iov[1].iov_len; iov[0].iov_len -= lss; n = 1; } } else n = 2; } else { if (iov[0].iov_len > mss) iov[0].iov_len -= iov[0].iov_len%mss; n = 1; } } #ifdef HAVE_READV nn = readv(so->s, (struct iovec *)iov, n); DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn)); #else nn = recv(so->s, iov[0].iov_base, iov[0].iov_len,0); #endif if (nn <= 0) { if (nn < 0 && (errno == EINTR || errno == EAGAIN)) return 0; else { DEBUG_MISC((dfd, " --- soread() disconnected, nn = %d, errno = %d-%s\n", nn, errno,strerror(errno))); sofcantrcvmore(so); tcp_sockclosed(sototcpcb(so)); return -1; } } #ifndef HAVE_READV /* * If there was no error, try and read the second time round * We read again if n = 2 (ie, there's another part of the buffer) * and we read as much as we could in the first read * We don't test for <= 0 this time, because there legitimately * might not be any more data (since the socket is non-blocking), * a close will be detected on next iteration. * A return of -1 wont (shouldn't) happen, since it didn't happen above */ if (n == 2 && nn == iov[0].iov_len) { int ret; ret = recv(so->s, iov[1].iov_base, iov[1].iov_len,0); if (ret > 0) nn += ret; } DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn)); #endif /* Update fields */ sb->sb_cc += nn; sb->sb_wptr += nn; if (sb->sb_wptr >= (sb->sb_data + sb->sb_datalen)) sb->sb_wptr -= sb->sb_datalen; return nn; }
true
qemu
66029f6a2f717873f2d170681f0250801a6d0d39
soread(so) struct socket *so; { int n, nn, lss, total; struct sbuf *sb = &so->so_snd; int len = sb->sb_datalen - sb->sb_cc; struct iovec iov[2]; int mss = so->so_tcpcb->t_maxseg; DEBUG_CALL("soread"); DEBUG_ARG("so = %lx", (long )so); len = sb->sb_datalen - sb->sb_cc; iov[0].iov_base = sb->sb_wptr; if (sb->sb_wptr < sb->sb_rptr) { iov[0].iov_len = sb->sb_rptr - sb->sb_wptr; if (iov[0].iov_len > len) iov[0].iov_len = len; if (iov[0].iov_len > mss) iov[0].iov_len -= iov[0].iov_len%mss; n = 1; } else { iov[0].iov_len = (sb->sb_data + sb->sb_datalen) - sb->sb_wptr; if (iov[0].iov_len > len) iov[0].iov_len = len; len -= iov[0].iov_len; if (len) { iov[1].iov_base = sb->sb_data; iov[1].iov_len = sb->sb_rptr - sb->sb_data; if(iov[1].iov_len > len) iov[1].iov_len = len; total = iov[0].iov_len + iov[1].iov_len; if (total > mss) { lss = total%mss; if (iov[1].iov_len > lss) { iov[1].iov_len -= lss; n = 2; } else { lss -= iov[1].iov_len; iov[0].iov_len -= lss; n = 1; } } else n = 2; } else { if (iov[0].iov_len > mss) iov[0].iov_len -= iov[0].iov_len%mss; n = 1; } } #ifdef HAVE_READV nn = readv(so->s, (struct iovec *)iov, n); DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn)); #else nn = recv(so->s, iov[0].iov_base, iov[0].iov_len,0); #endif if (nn <= 0) { if (nn < 0 && (errno == EINTR || errno == EAGAIN)) return 0; else { DEBUG_MISC((dfd, " --- soread() disconnected, nn = %d, errno = %d-%s\n", nn, errno,strerror(errno))); sofcantrcvmore(so); tcp_sockclosed(sototcpcb(so)); return -1; } } #ifndef HAVE_READV if (n == 2 && nn == iov[0].iov_len) { int ret; ret = recv(so->s, iov[1].iov_base, iov[1].iov_len,0); if (ret > 0) nn += ret; } DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn)); #endif sb->sb_cc += nn; sb->sb_wptr += nn; if (sb->sb_wptr >= (sb->sb_data + sb->sb_datalen)) sb->sb_wptr -= sb->sb_datalen; return nn; }
{ "code": [], "line_no": [] }
FUNC_0(VAR_0) struct socket *VAR_0; { int VAR_1, VAR_2, VAR_3, VAR_4; struct sbuf *VAR_5 = &VAR_0->so_snd; int VAR_6 = VAR_5->sb_datalen - VAR_5->sb_cc; struct iovec VAR_7[2]; int VAR_8 = VAR_0->so_tcpcb->t_maxseg; DEBUG_CALL("FUNC_0"); DEBUG_ARG("VAR_0 = %lx", (long )VAR_0); VAR_6 = VAR_5->sb_datalen - VAR_5->sb_cc; VAR_7[0].iov_base = VAR_5->sb_wptr; if (VAR_5->sb_wptr < VAR_5->sb_rptr) { VAR_7[0].iov_len = VAR_5->sb_rptr - VAR_5->sb_wptr; if (VAR_7[0].iov_len > VAR_6) VAR_7[0].iov_len = VAR_6; if (VAR_7[0].iov_len > VAR_8) VAR_7[0].iov_len -= VAR_7[0].iov_len%VAR_8; VAR_1 = 1; } else { VAR_7[0].iov_len = (VAR_5->sb_data + VAR_5->sb_datalen) - VAR_5->sb_wptr; if (VAR_7[0].iov_len > VAR_6) VAR_7[0].iov_len = VAR_6; VAR_6 -= VAR_7[0].iov_len; if (VAR_6) { VAR_7[1].iov_base = VAR_5->sb_data; VAR_7[1].iov_len = VAR_5->sb_rptr - VAR_5->sb_data; if(VAR_7[1].iov_len > VAR_6) VAR_7[1].iov_len = VAR_6; VAR_4 = VAR_7[0].iov_len + VAR_7[1].iov_len; if (VAR_4 > VAR_8) { VAR_3 = VAR_4%VAR_8; if (VAR_7[1].iov_len > VAR_3) { VAR_7[1].iov_len -= VAR_3; VAR_1 = 2; } else { VAR_3 -= VAR_7[1].iov_len; VAR_7[0].iov_len -= VAR_3; VAR_1 = 1; } } else VAR_1 = 2; } else { if (VAR_7[0].iov_len > VAR_8) VAR_7[0].iov_len -= VAR_7[0].iov_len%VAR_8; VAR_1 = 1; } } #ifdef HAVE_READV VAR_2 = readv(VAR_0->s, (struct iovec *)VAR_7, VAR_1); DEBUG_MISC((dfd, " ... read VAR_2 = %d bytes\VAR_1", VAR_2)); #else VAR_2 = recv(VAR_0->s, VAR_7[0].iov_base, VAR_7[0].iov_len,0); #endif if (VAR_2 <= 0) { if (VAR_2 < 0 && (errno == EINTR || errno == EAGAIN)) return 0; else { DEBUG_MISC((dfd, " --- FUNC_0() disconnected, VAR_2 = %d, errno = %d-%s\VAR_1", VAR_2, errno,strerror(errno))); sofcantrcvmore(VAR_0); tcp_sockclosed(sototcpcb(VAR_0)); return -1; } } #ifndef HAVE_READV if (VAR_1 == 2 && VAR_2 == VAR_7[0].iov_len) { int VAR_9; VAR_9 = recv(VAR_0->s, VAR_7[1].iov_base, VAR_7[1].iov_len,0); if (VAR_9 > 0) VAR_2 += VAR_9; } DEBUG_MISC((dfd, " ... read VAR_2 = %d bytes\VAR_1", VAR_2)); #endif VAR_5->sb_cc += VAR_2; VAR_5->sb_wptr += VAR_2; if (VAR_5->sb_wptr >= (VAR_5->sb_data + VAR_5->sb_datalen)) VAR_5->sb_wptr -= VAR_5->sb_datalen; return VAR_2; }
[ "FUNC_0(VAR_0)\nstruct socket *VAR_0;", "{", "int VAR_1, VAR_2, VAR_3, VAR_4;", "struct sbuf *VAR_5 = &VAR_0->so_snd;", "int VAR_6 = VAR_5->sb_datalen - VAR_5->sb_cc;", "struct iovec VAR_7[2];", "int VAR_8 = VAR_0->so_tcpcb->t_maxseg;", "DEBUG_CALL(\"FUNC_0\");", "DEBUG_ARG(\"VAR_0 = %lx\", (long )VAR_0);", "VAR_6 = VAR_5->sb_datalen - VAR_5->sb_cc;", "VAR_7[0].iov_base = VAR_5->sb_wptr;", "if (VAR_5->sb_wptr < VAR_5->sb_rptr) {", "VAR_7[0].iov_len = VAR_5->sb_rptr - VAR_5->sb_wptr;", "if (VAR_7[0].iov_len > VAR_6)\nVAR_7[0].iov_len = VAR_6;", "if (VAR_7[0].iov_len > VAR_8)\nVAR_7[0].iov_len -= VAR_7[0].iov_len%VAR_8;", "VAR_1 = 1;", "} else {", "VAR_7[0].iov_len = (VAR_5->sb_data + VAR_5->sb_datalen) - VAR_5->sb_wptr;", "if (VAR_7[0].iov_len > VAR_6) VAR_7[0].iov_len = VAR_6;", "VAR_6 -= VAR_7[0].iov_len;", "if (VAR_6) {", "VAR_7[1].iov_base = VAR_5->sb_data;", "VAR_7[1].iov_len = VAR_5->sb_rptr - VAR_5->sb_data;", "if(VAR_7[1].iov_len > VAR_6)\nVAR_7[1].iov_len = VAR_6;", "VAR_4 = VAR_7[0].iov_len + VAR_7[1].iov_len;", "if (VAR_4 > VAR_8) {", "VAR_3 = VAR_4%VAR_8;", "if (VAR_7[1].iov_len > VAR_3) {", "VAR_7[1].iov_len -= VAR_3;", "VAR_1 = 2;", "} else {", "VAR_3 -= VAR_7[1].iov_len;", "VAR_7[0].iov_len -= VAR_3;", "VAR_1 = 1;", "}", "} else", "VAR_1 = 2;", "} else {", "if (VAR_7[0].iov_len > VAR_8)\nVAR_7[0].iov_len -= VAR_7[0].iov_len%VAR_8;", "VAR_1 = 1;", "}", "}", "#ifdef HAVE_READV\nVAR_2 = readv(VAR_0->s, (struct iovec *)VAR_7, VAR_1);", "DEBUG_MISC((dfd, \" ... read VAR_2 = %d bytes\\VAR_1\", VAR_2));", "#else\nVAR_2 = recv(VAR_0->s, VAR_7[0].iov_base, VAR_7[0].iov_len,0);", "#endif\nif (VAR_2 <= 0) {", "if (VAR_2 < 0 && (errno == EINTR || errno == EAGAIN))\nreturn 0;", "else {", "DEBUG_MISC((dfd, \" --- FUNC_0() disconnected, VAR_2 = %d, errno = %d-%s\\VAR_1\", VAR_2, errno,strerror(errno)));", "sofcantrcvmore(VAR_0);", "tcp_sockclosed(sototcpcb(VAR_0));", "return -1;", "}", "}", "#ifndef HAVE_READV\nif (VAR_1 == 2 && VAR_2 == VAR_7[0].iov_len) {", "int VAR_9;", "VAR_9 = recv(VAR_0->s, VAR_7[1].iov_base, VAR_7[1].iov_len,0);", "if (VAR_9 > 0)\nVAR_2 += VAR_9;", "}", "DEBUG_MISC((dfd, \" ... read VAR_2 = %d bytes\\VAR_1\", VAR_2));", "#endif\nVAR_5->sb_cc += VAR_2;", "VAR_5->sb_wptr += VAR_2;", "if (VAR_5->sb_wptr >= (VAR_5->sb_data + VAR_5->sb_datalen))\nVAR_5->sb_wptr -= VAR_5->sb_datalen;", "return VAR_2;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 35 ], [ 39 ], [ 43 ], [ 45 ], [ 49, 51 ], [ 53, 55 ], [ 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75, 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107, 109 ], [ 111 ], [ 113 ], [ 115 ], [ 119, 121 ], [ 123 ], [ 125, 127 ], [ 129, 131 ], [ 133, 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 153, 173 ], [ 175 ], [ 177 ], [ 179, 181 ], [ 183 ], [ 187 ], [ 189, 195 ], [ 197 ], [ 199, 201 ], [ 203 ], [ 205 ] ]
8,907
static void decode_422_bitstream(HYuvContext *s, int count) { int i; count /= 2; if (count >= (get_bits_left(&s->gb)) / (31 * 4)) { for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) { READ_2PIX(s->temp[0][2 * i ], s->temp[1][i], 1); READ_2PIX(s->temp[0][2 * i + 1], s->temp[2][i], 2); } } else { for (i = 0; i < count; i++) { READ_2PIX(s->temp[0][2 * i ], s->temp[1][i], 1); READ_2PIX(s->temp[0][2 * i + 1], s->temp[2][i], 2); } } }
true
FFmpeg
42b6805cc1989f759f19e9d253527311741cbd3a
static void decode_422_bitstream(HYuvContext *s, int count) { int i; count /= 2; if (count >= (get_bits_left(&s->gb)) / (31 * 4)) { for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) { READ_2PIX(s->temp[0][2 * i ], s->temp[1][i], 1); READ_2PIX(s->temp[0][2 * i + 1], s->temp[2][i], 2); } } else { for (i = 0; i < count; i++) { READ_2PIX(s->temp[0][2 * i ], s->temp[1][i], 1); READ_2PIX(s->temp[0][2 * i + 1], s->temp[2][i], 2); } } }
{ "code": [], "line_no": [] }
static void FUNC_0(HYuvContext *VAR_0, int VAR_1) { int VAR_2; VAR_1 /= 2; if (VAR_1 >= (get_bits_left(&VAR_0->gb)) / (31 * 4)) { for (VAR_2 = 0; VAR_2 < VAR_1 && get_bits_left(&VAR_0->gb) > 0; VAR_2++) { READ_2PIX(VAR_0->temp[0][2 * VAR_2 ], VAR_0->temp[1][VAR_2], 1); READ_2PIX(VAR_0->temp[0][2 * VAR_2 + 1], VAR_0->temp[2][VAR_2], 2); } } else { for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) { READ_2PIX(VAR_0->temp[0][2 * VAR_2 ], VAR_0->temp[1][VAR_2], 1); READ_2PIX(VAR_0->temp[0][2 * VAR_2 + 1], VAR_0->temp[2][VAR_2], 2); } } }
[ "static void FUNC_0(HYuvContext *VAR_0, int VAR_1)\n{", "int VAR_2;", "VAR_1 /= 2;", "if (VAR_1 >= (get_bits_left(&VAR_0->gb)) / (31 * 4)) {", "for (VAR_2 = 0; VAR_2 < VAR_1 && get_bits_left(&VAR_0->gb) > 0; VAR_2++) {", "READ_2PIX(VAR_0->temp[0][2 * VAR_2 ], VAR_0->temp[1][VAR_2], 1);", "READ_2PIX(VAR_0->temp[0][2 * VAR_2 + 1], VAR_0->temp[2][VAR_2], 2);", "}", "} else {", "for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) {", "READ_2PIX(VAR_0->temp[0][2 * VAR_2 ], VAR_0->temp[1][VAR_2], 1);", "READ_2PIX(VAR_0->temp[0][2 * VAR_2 + 1], VAR_0->temp[2][VAR_2], 2);", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 26 ], [ 28 ], [ 30 ], [ 32 ], [ 34 ], [ 36 ], [ 38 ] ]
8,908
static int dv_extract_audio(uint8_t* frame, uint8_t* ppcm[4], const DVprofile *sys) { int size, chan, i, j, d, of, smpls, freq, quant, half_ch; uint16_t lc, rc; const uint8_t* as_pack; uint8_t *pcm, ipcm; as_pack = dv_extract_pack(frame, dv_audio_source); if (!as_pack) /* No audio ? */ return 0; smpls = as_pack[1] & 0x3f; /* samples in this frame - min. samples */ freq = (as_pack[4] >> 3) & 0x07; /* 0 - 48kHz, 1 - 44,1kHz, 2 - 32kHz */ quant = as_pack[4] & 0x07; /* 0 - 16bit linear, 1 - 12bit nonlinear */ if (quant > 1) return -1; /* unsupported quantization */ if (freq >= FF_ARRAY_ELEMS(dv_audio_frequency)) size = (sys->audio_min_samples[freq] + smpls) * 4; /* 2ch, 2bytes */ half_ch = sys->difseg_size / 2; /* We work with 720p frames split in half, thus even frames have * channels 0,1 and odd 2,3. */ ipcm = (sys->height == 720 && !(frame[1] & 0x0C)) ? 2 : 0; /* for each DIF channel */ for (chan = 0; chan < sys->n_difchan; chan++) { av_assert0(ipcm<4); pcm = ppcm[ipcm++]; if (!pcm) break; /* for each DIF segment */ for (i = 0; i < sys->difseg_size; i++) { frame += 6 * 80; /* skip DIF segment header */ if (quant == 1 && i == half_ch) { /* next stereo channel (12bit mode only) */ av_assert0(ipcm<4); pcm = ppcm[ipcm++]; if (!pcm) break; /* for each AV sequence */ for (j = 0; j < 9; j++) { for (d = 8; d < 80; d += 2) { if (quant == 0) { /* 16bit quantization */ of = sys->audio_shuffle[i][j] + (d - 8) / 2 * sys->audio_stride; if (of*2 >= size) continue; pcm[of*2] = frame[d+1]; // FIXME: maybe we have to admit pcm[of*2+1] = frame[d]; // that DV is a big-endian PCM if (pcm[of*2+1] == 0x80 && pcm[of*2] == 0x00) pcm[of*2+1] = 0; } else { /* 12bit quantization */ lc = ((uint16_t)frame[d] << 4) | ((uint16_t)frame[d+2] >> 4); rc = ((uint16_t)frame[d+1] << 4) | ((uint16_t)frame[d+2] & 0x0f); lc = (lc == 0x800 ? 0 : dv_audio_12to16(lc)); rc = (rc == 0x800 ? 0 : dv_audio_12to16(rc)); of = sys->audio_shuffle[i%half_ch][j] + (d - 8) / 3 * sys->audio_stride; if (of*2 >= size) continue; pcm[of*2] = lc & 0xff; // FIXME: maybe we have to admit pcm[of*2+1] = lc >> 8; // that DV is a big-endian PCM of = sys->audio_shuffle[i%half_ch+half_ch][j] + (d - 8) / 3 * sys->audio_stride; pcm[of*2] = rc & 0xff; // FIXME: maybe we have to admit pcm[of*2+1] = rc >> 8; // that DV is a big-endian PCM ++d; frame += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */ return size;
true
FFmpeg
3669915e93b3df63034857534245c3f2575d78ff
static int dv_extract_audio(uint8_t* frame, uint8_t* ppcm[4], const DVprofile *sys) { int size, chan, i, j, d, of, smpls, freq, quant, half_ch; uint16_t lc, rc; const uint8_t* as_pack; uint8_t *pcm, ipcm; as_pack = dv_extract_pack(frame, dv_audio_source); if (!as_pack) return 0; smpls = as_pack[1] & 0x3f; freq = (as_pack[4] >> 3) & 0x07; quant = as_pack[4] & 0x07; if (quant > 1) return -1; if (freq >= FF_ARRAY_ELEMS(dv_audio_frequency)) size = (sys->audio_min_samples[freq] + smpls) * 4; half_ch = sys->difseg_size / 2; ipcm = (sys->height == 720 && !(frame[1] & 0x0C)) ? 2 : 0; for (chan = 0; chan < sys->n_difchan; chan++) { av_assert0(ipcm<4); pcm = ppcm[ipcm++]; if (!pcm) break; for (i = 0; i < sys->difseg_size; i++) { frame += 6 * 80; if (quant == 1 && i == half_ch) { av_assert0(ipcm<4); pcm = ppcm[ipcm++]; if (!pcm) break; for (j = 0; j < 9; j++) { for (d = 8; d < 80; d += 2) { if (quant == 0) { of = sys->audio_shuffle[i][j] + (d - 8) / 2 * sys->audio_stride; if (of*2 >= size) continue; pcm[of*2] = frame[d+1]; pcm[of*2+1] = frame[d]; if (pcm[of*2+1] == 0x80 && pcm[of*2] == 0x00) pcm[of*2+1] = 0; } else { lc = ((uint16_t)frame[d] << 4) | ((uint16_t)frame[d+2] >> 4); rc = ((uint16_t)frame[d+1] << 4) | ((uint16_t)frame[d+2] & 0x0f); lc = (lc == 0x800 ? 0 : dv_audio_12to16(lc)); rc = (rc == 0x800 ? 0 : dv_audio_12to16(rc)); of = sys->audio_shuffle[i%half_ch][j] + (d - 8) / 3 * sys->audio_stride; if (of*2 >= size) continue; pcm[of*2] = lc & 0xff; pcm[of*2+1] = lc >> 8; of = sys->audio_shuffle[i%half_ch+half_ch][j] + (d - 8) / 3 * sys->audio_stride; pcm[of*2] = rc & 0xff; pcm[of*2+1] = rc >> 8; ++d; frame += 16 * 80; return size;
{ "code": [], "line_no": [] }
static int FUNC_0(uint8_t* VAR_0, uint8_t* VAR_1[4], const DVprofile *VAR_2) { int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12; uint16_t lc, rc; const uint8_t* VAR_13; uint8_t *pcm, ipcm; VAR_13 = dv_extract_pack(VAR_0, dv_audio_source); if (!VAR_13) return 0; VAR_9 = VAR_13[1] & 0x3f; VAR_10 = (VAR_13[4] >> 3) & 0x07; VAR_11 = VAR_13[4] & 0x07; if (VAR_11 > 1) return -1; if (VAR_10 >= FF_ARRAY_ELEMS(dv_audio_frequency)) VAR_3 = (VAR_2->audio_min_samples[VAR_10] + VAR_9) * 4; VAR_12 = VAR_2->difseg_size / 2; ipcm = (VAR_2->height == 720 && !(VAR_0[1] & 0x0C)) ? 2 : 0; for (VAR_4 = 0; VAR_4 < VAR_2->n_difchan; VAR_4++) { av_assert0(ipcm<4); pcm = VAR_1[ipcm++]; if (!pcm) break; for (VAR_5 = 0; VAR_5 < VAR_2->difseg_size; VAR_5++) { VAR_0 += 6 * 80; if (VAR_11 == 1 && VAR_5 == VAR_12) { av_assert0(ipcm<4); pcm = VAR_1[ipcm++]; if (!pcm) break; for (VAR_6 = 0; VAR_6 < 9; VAR_6++) { for (VAR_7 = 8; VAR_7 < 80; VAR_7 += 2) { if (VAR_11 == 0) { VAR_8 = VAR_2->audio_shuffle[VAR_5][VAR_6] + (VAR_7 - 8) / 2 * VAR_2->audio_stride; if (VAR_8*2 >= VAR_3) continue; pcm[VAR_8*2] = VAR_0[VAR_7+1]; pcm[VAR_8*2+1] = VAR_0[VAR_7]; if (pcm[VAR_8*2+1] == 0x80 && pcm[VAR_8*2] == 0x00) pcm[VAR_8*2+1] = 0; } else { lc = ((uint16_t)VAR_0[VAR_7] << 4) | ((uint16_t)VAR_0[VAR_7+2] >> 4); rc = ((uint16_t)VAR_0[VAR_7+1] << 4) | ((uint16_t)VAR_0[VAR_7+2] & 0x0f); lc = (lc == 0x800 ? 0 : dv_audio_12to16(lc)); rc = (rc == 0x800 ? 0 : dv_audio_12to16(rc)); VAR_8 = VAR_2->audio_shuffle[VAR_5%VAR_12][VAR_6] + (VAR_7 - 8) / 3 * VAR_2->audio_stride; if (VAR_8*2 >= VAR_3) continue; pcm[VAR_8*2] = lc & 0xff; pcm[VAR_8*2+1] = lc >> 8; VAR_8 = VAR_2->audio_shuffle[VAR_5%VAR_12+VAR_12][VAR_6] + (VAR_7 - 8) / 3 * VAR_2->audio_stride; pcm[VAR_8*2] = rc & 0xff; pcm[VAR_8*2+1] = rc >> 8; ++VAR_7; VAR_0 += 16 * 80; return VAR_3;
[ "static int FUNC_0(uint8_t* VAR_0, uint8_t* VAR_1[4],\nconst DVprofile *VAR_2)\n{", "int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;", "uint16_t lc, rc;", "const uint8_t* VAR_13;", "uint8_t *pcm, ipcm;", "VAR_13 = dv_extract_pack(VAR_0, dv_audio_source);", "if (!VAR_13)\nreturn 0;", "VAR_9 = VAR_13[1] & 0x3f;", "VAR_10 = (VAR_13[4] >> 3) & 0x07;", "VAR_11 = VAR_13[4] & 0x07;", "if (VAR_11 > 1)\nreturn -1;", "if (VAR_10 >= FF_ARRAY_ELEMS(dv_audio_frequency))\nVAR_3 = (VAR_2->audio_min_samples[VAR_10] + VAR_9) * 4;", "VAR_12 = VAR_2->difseg_size / 2;", "ipcm = (VAR_2->height == 720 && !(VAR_0[1] & 0x0C)) ? 2 : 0;", "for (VAR_4 = 0; VAR_4 < VAR_2->n_difchan; VAR_4++) {", "av_assert0(ipcm<4);", "pcm = VAR_1[ipcm++];", "if (!pcm)\nbreak;", "for (VAR_5 = 0; VAR_5 < VAR_2->difseg_size; VAR_5++) {", "VAR_0 += 6 * 80;", "if (VAR_11 == 1 && VAR_5 == VAR_12) {", "av_assert0(ipcm<4);", "pcm = VAR_1[ipcm++];", "if (!pcm)\nbreak;", "for (VAR_6 = 0; VAR_6 < 9; VAR_6++) {", "for (VAR_7 = 8; VAR_7 < 80; VAR_7 += 2) {", "if (VAR_11 == 0) {", "VAR_8 = VAR_2->audio_shuffle[VAR_5][VAR_6] + (VAR_7 - 8) / 2 * VAR_2->audio_stride;", "if (VAR_8*2 >= VAR_3)\ncontinue;", "pcm[VAR_8*2] = VAR_0[VAR_7+1];", "pcm[VAR_8*2+1] = VAR_0[VAR_7];", "if (pcm[VAR_8*2+1] == 0x80 && pcm[VAR_8*2] == 0x00)\npcm[VAR_8*2+1] = 0;", "} else {", "lc = ((uint16_t)VAR_0[VAR_7] << 4) |\n((uint16_t)VAR_0[VAR_7+2] >> 4);", "rc = ((uint16_t)VAR_0[VAR_7+1] << 4) |\n((uint16_t)VAR_0[VAR_7+2] & 0x0f);", "lc = (lc == 0x800 ? 0 : dv_audio_12to16(lc));", "rc = (rc == 0x800 ? 0 : dv_audio_12to16(rc));", "VAR_8 = VAR_2->audio_shuffle[VAR_5%VAR_12][VAR_6] + (VAR_7 - 8) / 3 * VAR_2->audio_stride;", "if (VAR_8*2 >= VAR_3)\ncontinue;", "pcm[VAR_8*2] = lc & 0xff;", "pcm[VAR_8*2+1] = lc >> 8;", "VAR_8 = VAR_2->audio_shuffle[VAR_5%VAR_12+VAR_12][VAR_6] +\n(VAR_7 - 8) / 3 * VAR_2->audio_stride;", "pcm[VAR_8*2] = rc & 0xff;", "pcm[VAR_8*2+1] = rc >> 8;", "++VAR_7;", "VAR_0 += 16 * 80;", "return VAR_3;" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 21 ], [ 23 ], [ 24 ], [ 25 ], [ 26, 27 ], [ 29 ], [ 30 ], [ 31 ], [ 33 ], [ 34 ], [ 35, 36 ], [ 38 ], [ 39 ], [ 40 ], [ 41 ], [ 42, 43 ], [ 44 ], [ 45 ], [ 46, 47 ], [ 48 ], [ 49, 50 ], [ 51, 52 ], [ 53 ], [ 54 ], [ 55 ], [ 56, 57 ], [ 58 ], [ 59 ], [ 60, 61 ], [ 62 ], [ 63 ], [ 64 ], [ 65 ], [ 66 ] ]
8,909
void ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number) { int time_incr; int time_div, time_mod; if (s->pict_type == AV_PICTURE_TYPE_I) { if (!(s->avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)) { if (s->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT) // HACK, the reference sw is buggy mpeg4_encode_visual_object_header(s); if (s->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT || picture_number == 0) // HACK, the reference sw is buggy mpeg4_encode_vol_header(s, 0, 0); } if (!(s->workaround_bugs & FF_BUG_MS)) mpeg4_encode_gop_header(s); } s->partitioned_frame = s->data_partitioning && s->pict_type != AV_PICTURE_TYPE_B; put_bits(&s->pb, 16, 0); /* vop header */ put_bits(&s->pb, 16, VOP_STARTCODE); /* vop header */ put_bits(&s->pb, 2, s->pict_type - 1); /* pict type: I = 0 , P = 1 */ time_div = FFUDIV(s->time, s->avctx->time_base.den); time_mod = FFUMOD(s->time, s->avctx->time_base.den); time_incr = time_div - s->last_time_base; av_assert0(time_incr >= 0); while (time_incr--) put_bits(&s->pb, 1, 1); put_bits(&s->pb, 1, 0); put_bits(&s->pb, 1, 1); /* marker */ put_bits(&s->pb, s->time_increment_bits, time_mod); /* time increment */ put_bits(&s->pb, 1, 1); /* marker */ put_bits(&s->pb, 1, 1); /* vop coded */ if (s->pict_type == AV_PICTURE_TYPE_P) { put_bits(&s->pb, 1, s->no_rounding); /* rounding type */ } put_bits(&s->pb, 3, 0); /* intra dc VLC threshold */ if (!s->progressive_sequence) { put_bits(&s->pb, 1, s->current_picture_ptr->f->top_field_first); put_bits(&s->pb, 1, s->alternate_scan); } // FIXME sprite stuff put_bits(&s->pb, 5, s->qscale); if (s->pict_type != AV_PICTURE_TYPE_I) put_bits(&s->pb, 3, s->f_code); /* fcode_for */ if (s->pict_type == AV_PICTURE_TYPE_B) put_bits(&s->pb, 3, s->b_code); /* fcode_back */ }
true
FFmpeg
7c97946d6131b31340954a3f603b6bf92590a9a5
void ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number) { int time_incr; int time_div, time_mod; if (s->pict_type == AV_PICTURE_TYPE_I) { if (!(s->avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)) { if (s->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT) mpeg4_encode_visual_object_header(s); if (s->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT || picture_number == 0) mpeg4_encode_vol_header(s, 0, 0); } if (!(s->workaround_bugs & FF_BUG_MS)) mpeg4_encode_gop_header(s); } s->partitioned_frame = s->data_partitioning && s->pict_type != AV_PICTURE_TYPE_B; put_bits(&s->pb, 16, 0); put_bits(&s->pb, 16, VOP_STARTCODE); put_bits(&s->pb, 2, s->pict_type - 1); time_div = FFUDIV(s->time, s->avctx->time_base.den); time_mod = FFUMOD(s->time, s->avctx->time_base.den); time_incr = time_div - s->last_time_base; av_assert0(time_incr >= 0); while (time_incr--) put_bits(&s->pb, 1, 1); put_bits(&s->pb, 1, 0); put_bits(&s->pb, 1, 1); put_bits(&s->pb, s->time_increment_bits, time_mod); put_bits(&s->pb, 1, 1); put_bits(&s->pb, 1, 1); if (s->pict_type == AV_PICTURE_TYPE_P) { put_bits(&s->pb, 1, s->no_rounding); } put_bits(&s->pb, 3, 0); if (!s->progressive_sequence) { put_bits(&s->pb, 1, s->current_picture_ptr->f->top_field_first); put_bits(&s->pb, 1, s->alternate_scan); } put_bits(&s->pb, 5, s->qscale); if (s->pict_type != AV_PICTURE_TYPE_I) put_bits(&s->pb, 3, s->f_code); if (s->pict_type == AV_PICTURE_TYPE_B) put_bits(&s->pb, 3, s->b_code); }
{ "code": [ "void ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number)" ], "line_no": [ 1 ] }
void FUNC_0(MpegEncContext *VAR_0, int VAR_1) { int VAR_2; int VAR_3, VAR_4; if (VAR_0->pict_type == AV_PICTURE_TYPE_I) { if (!(VAR_0->avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)) { if (VAR_0->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT) mpeg4_encode_visual_object_header(VAR_0); if (VAR_0->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT || VAR_1 == 0) mpeg4_encode_vol_header(VAR_0, 0, 0); } if (!(VAR_0->workaround_bugs & FF_BUG_MS)) mpeg4_encode_gop_header(VAR_0); } VAR_0->partitioned_frame = VAR_0->data_partitioning && VAR_0->pict_type != AV_PICTURE_TYPE_B; put_bits(&VAR_0->pb, 16, 0); put_bits(&VAR_0->pb, 16, VOP_STARTCODE); put_bits(&VAR_0->pb, 2, VAR_0->pict_type - 1); VAR_3 = FFUDIV(VAR_0->time, VAR_0->avctx->time_base.den); VAR_4 = FFUMOD(VAR_0->time, VAR_0->avctx->time_base.den); VAR_2 = VAR_3 - VAR_0->last_time_base; av_assert0(VAR_2 >= 0); while (VAR_2--) put_bits(&VAR_0->pb, 1, 1); put_bits(&VAR_0->pb, 1, 0); put_bits(&VAR_0->pb, 1, 1); put_bits(&VAR_0->pb, VAR_0->time_increment_bits, VAR_4); put_bits(&VAR_0->pb, 1, 1); put_bits(&VAR_0->pb, 1, 1); if (VAR_0->pict_type == AV_PICTURE_TYPE_P) { put_bits(&VAR_0->pb, 1, VAR_0->no_rounding); } put_bits(&VAR_0->pb, 3, 0); if (!VAR_0->progressive_sequence) { put_bits(&VAR_0->pb, 1, VAR_0->current_picture_ptr->f->top_field_first); put_bits(&VAR_0->pb, 1, VAR_0->alternate_scan); } put_bits(&VAR_0->pb, 5, VAR_0->qscale); if (VAR_0->pict_type != AV_PICTURE_TYPE_I) put_bits(&VAR_0->pb, 3, VAR_0->f_code); if (VAR_0->pict_type == AV_PICTURE_TYPE_B) put_bits(&VAR_0->pb, 3, VAR_0->b_code); }
[ "void FUNC_0(MpegEncContext *VAR_0, int VAR_1)\n{", "int VAR_2;", "int VAR_3, VAR_4;", "if (VAR_0->pict_type == AV_PICTURE_TYPE_I) {", "if (!(VAR_0->avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)) {", "if (VAR_0->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT)\nmpeg4_encode_visual_object_header(VAR_0);", "if (VAR_0->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT || VAR_1 == 0)\nmpeg4_encode_vol_header(VAR_0, 0, 0);", "}", "if (!(VAR_0->workaround_bugs & FF_BUG_MS))\nmpeg4_encode_gop_header(VAR_0);", "}", "VAR_0->partitioned_frame = VAR_0->data_partitioning && VAR_0->pict_type != AV_PICTURE_TYPE_B;", "put_bits(&VAR_0->pb, 16, 0);", "put_bits(&VAR_0->pb, 16, VOP_STARTCODE);", "put_bits(&VAR_0->pb, 2, VAR_0->pict_type - 1);", "VAR_3 = FFUDIV(VAR_0->time, VAR_0->avctx->time_base.den);", "VAR_4 = FFUMOD(VAR_0->time, VAR_0->avctx->time_base.den);", "VAR_2 = VAR_3 - VAR_0->last_time_base;", "av_assert0(VAR_2 >= 0);", "while (VAR_2--)\nput_bits(&VAR_0->pb, 1, 1);", "put_bits(&VAR_0->pb, 1, 0);", "put_bits(&VAR_0->pb, 1, 1);", "put_bits(&VAR_0->pb, VAR_0->time_increment_bits, VAR_4);", "put_bits(&VAR_0->pb, 1, 1);", "put_bits(&VAR_0->pb, 1, 1);", "if (VAR_0->pict_type == AV_PICTURE_TYPE_P) {", "put_bits(&VAR_0->pb, 1, VAR_0->no_rounding);", "}", "put_bits(&VAR_0->pb, 3, 0);", "if (!VAR_0->progressive_sequence) {", "put_bits(&VAR_0->pb, 1, VAR_0->current_picture_ptr->f->top_field_first);", "put_bits(&VAR_0->pb, 1, VAR_0->alternate_scan);", "}", "put_bits(&VAR_0->pb, 5, VAR_0->qscale);", "if (VAR_0->pict_type != AV_PICTURE_TYPE_I)\nput_bits(&VAR_0->pb, 3, VAR_0->f_code);", "if (VAR_0->pict_type == AV_PICTURE_TYPE_B)\nput_bits(&VAR_0->pb, 3, VAR_0->b_code);", "}" ]
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15, 17 ], [ 19, 21 ], [ 23 ], [ 25, 27 ], [ 29 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53, 55 ], [ 59 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 91 ], [ 95, 97 ], [ 99, 101 ], [ 103 ] ]
8,910
static int hls_slice_data_wpp(HEVCContext *s, const HEVCNAL *nal) { const uint8_t *data = nal->data; int length = nal->size; HEVCLocalContext *lc = s->HEVClc; int *ret = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int)); int *arg = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int)); int64_t offset; int startheader, cmpt = 0; int i, j, res = 0; if (!ret || !arg) { av_free(ret); av_free(arg); return AVERROR(ENOMEM); } if (s->sh.slice_ctb_addr_rs + s->sh.num_entry_point_offsets * s->ps.sps->ctb_width >= s->ps.sps->ctb_width * s->ps.sps->ctb_height) { av_log(s->avctx, AV_LOG_ERROR, "WPP ctb addresses are wrong (%d %d %d %d)\n", s->sh.slice_ctb_addr_rs, s->sh.num_entry_point_offsets, s->ps.sps->ctb_width, s->ps.sps->ctb_height ); res = AVERROR_INVALIDDATA; goto error; } ff_alloc_entries(s->avctx, s->sh.num_entry_point_offsets + 1); if (!s->sList[1]) { for (i = 1; i < s->threads_number; i++) { s->sList[i] = av_malloc(sizeof(HEVCContext)); memcpy(s->sList[i], s, sizeof(HEVCContext)); s->HEVClcList[i] = av_mallocz(sizeof(HEVCLocalContext)); s->sList[i]->HEVClc = s->HEVClcList[i]; } } offset = (lc->gb.index >> 3); for (j = 0, cmpt = 0, startheader = offset + s->sh.entry_point_offset[0]; j < nal->skipped_bytes; j++) { if (nal->skipped_bytes_pos[j] >= offset && nal->skipped_bytes_pos[j] < startheader) { startheader--; cmpt++; } } for (i = 1; i < s->sh.num_entry_point_offsets; i++) { offset += (s->sh.entry_point_offset[i - 1] - cmpt); for (j = 0, cmpt = 0, startheader = offset + s->sh.entry_point_offset[i]; j < nal->skipped_bytes; j++) { if (nal->skipped_bytes_pos[j] >= offset && nal->skipped_bytes_pos[j] < startheader) { startheader--; cmpt++; } } s->sh.size[i - 1] = s->sh.entry_point_offset[i] - cmpt; s->sh.offset[i - 1] = offset; } if (s->sh.num_entry_point_offsets != 0) { offset += s->sh.entry_point_offset[s->sh.num_entry_point_offsets - 1] - cmpt; if (length < offset) { av_log(s->avctx, AV_LOG_ERROR, "entry_point_offset table is corrupted\n"); res = AVERROR_INVALIDDATA; goto error; } s->sh.size[s->sh.num_entry_point_offsets - 1] = length - offset; s->sh.offset[s->sh.num_entry_point_offsets - 1] = offset; } s->data = data; for (i = 1; i < s->threads_number; i++) { s->sList[i]->HEVClc->first_qp_group = 1; s->sList[i]->HEVClc->qp_y = s->sList[0]->HEVClc->qp_y; memcpy(s->sList[i], s, sizeof(HEVCContext)); s->sList[i]->HEVClc = s->HEVClcList[i]; } avpriv_atomic_int_set(&s->wpp_err, 0); ff_reset_entries(s->avctx); for (i = 0; i <= s->sh.num_entry_point_offsets; i++) { arg[i] = i; ret[i] = 0; } if (s->ps.pps->entropy_coding_sync_enabled_flag) s->avctx->execute2(s->avctx, hls_decode_entry_wpp, arg, ret, s->sh.num_entry_point_offsets + 1); for (i = 0; i <= s->sh.num_entry_point_offsets; i++) res += ret[i]; error: av_free(ret); av_free(arg); return res; }
true
FFmpeg
214085852491448631dcecb008b5d172c11b8892
static int hls_slice_data_wpp(HEVCContext *s, const HEVCNAL *nal) { const uint8_t *data = nal->data; int length = nal->size; HEVCLocalContext *lc = s->HEVClc; int *ret = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int)); int *arg = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int)); int64_t offset; int startheader, cmpt = 0; int i, j, res = 0; if (!ret || !arg) { av_free(ret); av_free(arg); return AVERROR(ENOMEM); } if (s->sh.slice_ctb_addr_rs + s->sh.num_entry_point_offsets * s->ps.sps->ctb_width >= s->ps.sps->ctb_width * s->ps.sps->ctb_height) { av_log(s->avctx, AV_LOG_ERROR, "WPP ctb addresses are wrong (%d %d %d %d)\n", s->sh.slice_ctb_addr_rs, s->sh.num_entry_point_offsets, s->ps.sps->ctb_width, s->ps.sps->ctb_height ); res = AVERROR_INVALIDDATA; goto error; } ff_alloc_entries(s->avctx, s->sh.num_entry_point_offsets + 1); if (!s->sList[1]) { for (i = 1; i < s->threads_number; i++) { s->sList[i] = av_malloc(sizeof(HEVCContext)); memcpy(s->sList[i], s, sizeof(HEVCContext)); s->HEVClcList[i] = av_mallocz(sizeof(HEVCLocalContext)); s->sList[i]->HEVClc = s->HEVClcList[i]; } } offset = (lc->gb.index >> 3); for (j = 0, cmpt = 0, startheader = offset + s->sh.entry_point_offset[0]; j < nal->skipped_bytes; j++) { if (nal->skipped_bytes_pos[j] >= offset && nal->skipped_bytes_pos[j] < startheader) { startheader--; cmpt++; } } for (i = 1; i < s->sh.num_entry_point_offsets; i++) { offset += (s->sh.entry_point_offset[i - 1] - cmpt); for (j = 0, cmpt = 0, startheader = offset + s->sh.entry_point_offset[i]; j < nal->skipped_bytes; j++) { if (nal->skipped_bytes_pos[j] >= offset && nal->skipped_bytes_pos[j] < startheader) { startheader--; cmpt++; } } s->sh.size[i - 1] = s->sh.entry_point_offset[i] - cmpt; s->sh.offset[i - 1] = offset; } if (s->sh.num_entry_point_offsets != 0) { offset += s->sh.entry_point_offset[s->sh.num_entry_point_offsets - 1] - cmpt; if (length < offset) { av_log(s->avctx, AV_LOG_ERROR, "entry_point_offset table is corrupted\n"); res = AVERROR_INVALIDDATA; goto error; } s->sh.size[s->sh.num_entry_point_offsets - 1] = length - offset; s->sh.offset[s->sh.num_entry_point_offsets - 1] = offset; } s->data = data; for (i = 1; i < s->threads_number; i++) { s->sList[i]->HEVClc->first_qp_group = 1; s->sList[i]->HEVClc->qp_y = s->sList[0]->HEVClc->qp_y; memcpy(s->sList[i], s, sizeof(HEVCContext)); s->sList[i]->HEVClc = s->HEVClcList[i]; } avpriv_atomic_int_set(&s->wpp_err, 0); ff_reset_entries(s->avctx); for (i = 0; i <= s->sh.num_entry_point_offsets; i++) { arg[i] = i; ret[i] = 0; } if (s->ps.pps->entropy_coding_sync_enabled_flag) s->avctx->execute2(s->avctx, hls_decode_entry_wpp, arg, ret, s->sh.num_entry_point_offsets + 1); for (i = 0; i <= s->sh.num_entry_point_offsets; i++) res += ret[i]; error: av_free(ret); av_free(arg); return res; }
{ "code": [ " int startheader, cmpt = 0;" ], "line_no": [ 17 ] }
static int FUNC_0(HEVCContext *VAR_0, const HEVCNAL *VAR_1) { const uint8_t *VAR_2 = VAR_1->VAR_2; int VAR_3 = VAR_1->size; HEVCLocalContext *lc = VAR_0->HEVClc; int *VAR_4 = av_malloc_array(VAR_0->sh.num_entry_point_offsets + 1, sizeof(int)); int *VAR_5 = av_malloc_array(VAR_0->sh.num_entry_point_offsets + 1, sizeof(int)); int64_t offset; int VAR_6, VAR_7 = 0; int VAR_8, VAR_9, VAR_10 = 0; if (!VAR_4 || !VAR_5) { av_free(VAR_4); av_free(VAR_5); return AVERROR(ENOMEM); } if (VAR_0->sh.slice_ctb_addr_rs + VAR_0->sh.num_entry_point_offsets * VAR_0->ps.sps->ctb_width >= VAR_0->ps.sps->ctb_width * VAR_0->ps.sps->ctb_height) { av_log(VAR_0->avctx, AV_LOG_ERROR, "WPP ctb addresses are wrong (%d %d %d %d)\n", VAR_0->sh.slice_ctb_addr_rs, VAR_0->sh.num_entry_point_offsets, VAR_0->ps.sps->ctb_width, VAR_0->ps.sps->ctb_height ); VAR_10 = AVERROR_INVALIDDATA; goto error; } ff_alloc_entries(VAR_0->avctx, VAR_0->sh.num_entry_point_offsets + 1); if (!VAR_0->sList[1]) { for (VAR_8 = 1; VAR_8 < VAR_0->threads_number; VAR_8++) { VAR_0->sList[VAR_8] = av_malloc(sizeof(HEVCContext)); memcpy(VAR_0->sList[VAR_8], VAR_0, sizeof(HEVCContext)); VAR_0->HEVClcList[VAR_8] = av_mallocz(sizeof(HEVCLocalContext)); VAR_0->sList[VAR_8]->HEVClc = VAR_0->HEVClcList[VAR_8]; } } offset = (lc->gb.index >> 3); for (VAR_9 = 0, VAR_7 = 0, VAR_6 = offset + VAR_0->sh.entry_point_offset[0]; VAR_9 < VAR_1->skipped_bytes; VAR_9++) { if (VAR_1->skipped_bytes_pos[VAR_9] >= offset && VAR_1->skipped_bytes_pos[VAR_9] < VAR_6) { VAR_6--; VAR_7++; } } for (VAR_8 = 1; VAR_8 < VAR_0->sh.num_entry_point_offsets; VAR_8++) { offset += (VAR_0->sh.entry_point_offset[VAR_8 - 1] - VAR_7); for (VAR_9 = 0, VAR_7 = 0, VAR_6 = offset + VAR_0->sh.entry_point_offset[VAR_8]; VAR_9 < VAR_1->skipped_bytes; VAR_9++) { if (VAR_1->skipped_bytes_pos[VAR_9] >= offset && VAR_1->skipped_bytes_pos[VAR_9] < VAR_6) { VAR_6--; VAR_7++; } } VAR_0->sh.size[VAR_8 - 1] = VAR_0->sh.entry_point_offset[VAR_8] - VAR_7; VAR_0->sh.offset[VAR_8 - 1] = offset; } if (VAR_0->sh.num_entry_point_offsets != 0) { offset += VAR_0->sh.entry_point_offset[VAR_0->sh.num_entry_point_offsets - 1] - VAR_7; if (VAR_3 < offset) { av_log(VAR_0->avctx, AV_LOG_ERROR, "entry_point_offset table is corrupted\n"); VAR_10 = AVERROR_INVALIDDATA; goto error; } VAR_0->sh.size[VAR_0->sh.num_entry_point_offsets - 1] = VAR_3 - offset; VAR_0->sh.offset[VAR_0->sh.num_entry_point_offsets - 1] = offset; } VAR_0->VAR_2 = VAR_2; for (VAR_8 = 1; VAR_8 < VAR_0->threads_number; VAR_8++) { VAR_0->sList[VAR_8]->HEVClc->first_qp_group = 1; VAR_0->sList[VAR_8]->HEVClc->qp_y = VAR_0->sList[0]->HEVClc->qp_y; memcpy(VAR_0->sList[VAR_8], VAR_0, sizeof(HEVCContext)); VAR_0->sList[VAR_8]->HEVClc = VAR_0->HEVClcList[VAR_8]; } avpriv_atomic_int_set(&VAR_0->wpp_err, 0); ff_reset_entries(VAR_0->avctx); for (VAR_8 = 0; VAR_8 <= VAR_0->sh.num_entry_point_offsets; VAR_8++) { VAR_5[VAR_8] = VAR_8; VAR_4[VAR_8] = 0; } if (VAR_0->ps.pps->entropy_coding_sync_enabled_flag) VAR_0->avctx->execute2(VAR_0->avctx, hls_decode_entry_wpp, VAR_5, VAR_4, VAR_0->sh.num_entry_point_offsets + 1); for (VAR_8 = 0; VAR_8 <= VAR_0->sh.num_entry_point_offsets; VAR_8++) VAR_10 += VAR_4[VAR_8]; error: av_free(VAR_4); av_free(VAR_5); return VAR_10; }
[ "static int FUNC_0(HEVCContext *VAR_0, const HEVCNAL *VAR_1)\n{", "const uint8_t *VAR_2 = VAR_1->VAR_2;", "int VAR_3 = VAR_1->size;", "HEVCLocalContext *lc = VAR_0->HEVClc;", "int *VAR_4 = av_malloc_array(VAR_0->sh.num_entry_point_offsets + 1, sizeof(int));", "int *VAR_5 = av_malloc_array(VAR_0->sh.num_entry_point_offsets + 1, sizeof(int));", "int64_t offset;", "int VAR_6, VAR_7 = 0;", "int VAR_8, VAR_9, VAR_10 = 0;", "if (!VAR_4 || !VAR_5) {", "av_free(VAR_4);", "av_free(VAR_5);", "return AVERROR(ENOMEM);", "}", "if (VAR_0->sh.slice_ctb_addr_rs + VAR_0->sh.num_entry_point_offsets * VAR_0->ps.sps->ctb_width >= VAR_0->ps.sps->ctb_width * VAR_0->ps.sps->ctb_height) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"WPP ctb addresses are wrong (%d %d %d %d)\\n\",\nVAR_0->sh.slice_ctb_addr_rs, VAR_0->sh.num_entry_point_offsets,\nVAR_0->ps.sps->ctb_width, VAR_0->ps.sps->ctb_height\n);", "VAR_10 = AVERROR_INVALIDDATA;", "goto error;", "}", "ff_alloc_entries(VAR_0->avctx, VAR_0->sh.num_entry_point_offsets + 1);", "if (!VAR_0->sList[1]) {", "for (VAR_8 = 1; VAR_8 < VAR_0->threads_number; VAR_8++) {", "VAR_0->sList[VAR_8] = av_malloc(sizeof(HEVCContext));", "memcpy(VAR_0->sList[VAR_8], VAR_0, sizeof(HEVCContext));", "VAR_0->HEVClcList[VAR_8] = av_mallocz(sizeof(HEVCLocalContext));", "VAR_0->sList[VAR_8]->HEVClc = VAR_0->HEVClcList[VAR_8];", "}", "}", "offset = (lc->gb.index >> 3);", "for (VAR_9 = 0, VAR_7 = 0, VAR_6 = offset + VAR_0->sh.entry_point_offset[0]; VAR_9 < VAR_1->skipped_bytes; VAR_9++) {", "if (VAR_1->skipped_bytes_pos[VAR_9] >= offset && VAR_1->skipped_bytes_pos[VAR_9] < VAR_6) {", "VAR_6--;", "VAR_7++;", "}", "}", "for (VAR_8 = 1; VAR_8 < VAR_0->sh.num_entry_point_offsets; VAR_8++) {", "offset += (VAR_0->sh.entry_point_offset[VAR_8 - 1] - VAR_7);", "for (VAR_9 = 0, VAR_7 = 0, VAR_6 = offset\n+ VAR_0->sh.entry_point_offset[VAR_8]; VAR_9 < VAR_1->skipped_bytes; VAR_9++) {", "if (VAR_1->skipped_bytes_pos[VAR_9] >= offset && VAR_1->skipped_bytes_pos[VAR_9] < VAR_6) {", "VAR_6--;", "VAR_7++;", "}", "}", "VAR_0->sh.size[VAR_8 - 1] = VAR_0->sh.entry_point_offset[VAR_8] - VAR_7;", "VAR_0->sh.offset[VAR_8 - 1] = offset;", "}", "if (VAR_0->sh.num_entry_point_offsets != 0) {", "offset += VAR_0->sh.entry_point_offset[VAR_0->sh.num_entry_point_offsets - 1] - VAR_7;", "if (VAR_3 < offset) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"entry_point_offset table is corrupted\\n\");", "VAR_10 = AVERROR_INVALIDDATA;", "goto error;", "}", "VAR_0->sh.size[VAR_0->sh.num_entry_point_offsets - 1] = VAR_3 - offset;", "VAR_0->sh.offset[VAR_0->sh.num_entry_point_offsets - 1] = offset;", "}", "VAR_0->VAR_2 = VAR_2;", "for (VAR_8 = 1; VAR_8 < VAR_0->threads_number; VAR_8++) {", "VAR_0->sList[VAR_8]->HEVClc->first_qp_group = 1;", "VAR_0->sList[VAR_8]->HEVClc->qp_y = VAR_0->sList[0]->HEVClc->qp_y;", "memcpy(VAR_0->sList[VAR_8], VAR_0, sizeof(HEVCContext));", "VAR_0->sList[VAR_8]->HEVClc = VAR_0->HEVClcList[VAR_8];", "}", "avpriv_atomic_int_set(&VAR_0->wpp_err, 0);", "ff_reset_entries(VAR_0->avctx);", "for (VAR_8 = 0; VAR_8 <= VAR_0->sh.num_entry_point_offsets; VAR_8++) {", "VAR_5[VAR_8] = VAR_8;", "VAR_4[VAR_8] = 0;", "}", "if (VAR_0->ps.pps->entropy_coding_sync_enabled_flag)\nVAR_0->avctx->execute2(VAR_0->avctx, hls_decode_entry_wpp, VAR_5, VAR_4, VAR_0->sh.num_entry_point_offsets + 1);", "for (VAR_8 = 0; VAR_8 <= VAR_0->sh.num_entry_point_offsets; VAR_8++)", "VAR_10 += VAR_4[VAR_8];", "error:\nav_free(VAR_4);", "av_free(VAR_5);", "return VAR_10;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37, 39, 41, 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 93 ], [ 95 ], [ 97, 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 139 ], [ 141 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 159 ], [ 161 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 175, 177 ], [ 181 ], [ 183 ], [ 185, 187 ], [ 189 ], [ 191 ], [ 193 ] ]
8,911
void qemu_file_reset_rate_limit(QEMUFile *f) { f->bytes_xfer = 0; }
true
qemu
60fe637bf0e4d7989e21e50f52526444765c63b4
void qemu_file_reset_rate_limit(QEMUFile *f) { f->bytes_xfer = 0; }
{ "code": [], "line_no": [] }
void FUNC_0(QEMUFile *VAR_0) { VAR_0->bytes_xfer = 0; }
[ "void FUNC_0(QEMUFile *VAR_0)\n{", "VAR_0->bytes_xfer = 0;", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
8,912
static struct mmsghdr *build_l2tpv3_vector(NetL2TPV3State *s, int count) { int i; struct iovec *iov; struct mmsghdr *msgvec, *result; msgvec = g_malloc(sizeof(struct mmsghdr) * count); result = msgvec; for (i = 0; i < count ; i++) { msgvec->msg_hdr.msg_name = NULL; msgvec->msg_hdr.msg_namelen = 0; iov = g_malloc(sizeof(struct iovec) * IOVSIZE); msgvec->msg_hdr.msg_iov = iov; iov->iov_base = g_malloc(s->header_size); iov->iov_len = s->header_size; iov++ ; iov->iov_base = qemu_memalign(BUFFER_ALIGN, BUFFER_SIZE); iov->iov_len = BUFFER_SIZE; msgvec->msg_hdr.msg_iovlen = 2; msgvec->msg_hdr.msg_control = NULL; msgvec->msg_hdr.msg_controllen = 0; msgvec->msg_hdr.msg_flags = 0; msgvec++; } return result; }
true
qemu
58889fe50a7c5b8776cf3096a8fe611fb66c4e5c
static struct mmsghdr *build_l2tpv3_vector(NetL2TPV3State *s, int count) { int i; struct iovec *iov; struct mmsghdr *msgvec, *result; msgvec = g_malloc(sizeof(struct mmsghdr) * count); result = msgvec; for (i = 0; i < count ; i++) { msgvec->msg_hdr.msg_name = NULL; msgvec->msg_hdr.msg_namelen = 0; iov = g_malloc(sizeof(struct iovec) * IOVSIZE); msgvec->msg_hdr.msg_iov = iov; iov->iov_base = g_malloc(s->header_size); iov->iov_len = s->header_size; iov++ ; iov->iov_base = qemu_memalign(BUFFER_ALIGN, BUFFER_SIZE); iov->iov_len = BUFFER_SIZE; msgvec->msg_hdr.msg_iovlen = 2; msgvec->msg_hdr.msg_control = NULL; msgvec->msg_hdr.msg_controllen = 0; msgvec->msg_hdr.msg_flags = 0; msgvec++; } return result; }
{ "code": [ " msgvec = g_malloc(sizeof(struct mmsghdr) * count);", " iov = g_malloc(sizeof(struct iovec) * IOVSIZE);" ], "line_no": [ 13, 23 ] }
static struct mmsghdr *FUNC_0(NetL2TPV3State *VAR_0, int VAR_1) { int VAR_2; struct iovec *VAR_3; struct mmsghdr *VAR_4, *VAR_5; VAR_4 = g_malloc(sizeof(struct mmsghdr) * VAR_1); VAR_5 = VAR_4; for (VAR_2 = 0; VAR_2 < VAR_1 ; VAR_2++) { VAR_4->msg_hdr.msg_name = NULL; VAR_4->msg_hdr.msg_namelen = 0; VAR_3 = g_malloc(sizeof(struct iovec) * IOVSIZE); VAR_4->msg_hdr.msg_iov = VAR_3; VAR_3->iov_base = g_malloc(VAR_0->header_size); VAR_3->iov_len = VAR_0->header_size; VAR_3++ ; VAR_3->iov_base = qemu_memalign(BUFFER_ALIGN, BUFFER_SIZE); VAR_3->iov_len = BUFFER_SIZE; VAR_4->msg_hdr.msg_iovlen = 2; VAR_4->msg_hdr.msg_control = NULL; VAR_4->msg_hdr.msg_controllen = 0; VAR_4->msg_hdr.msg_flags = 0; VAR_4++; } return VAR_5; }
[ "static struct mmsghdr *FUNC_0(NetL2TPV3State *VAR_0, int VAR_1)\n{", "int VAR_2;", "struct iovec *VAR_3;", "struct mmsghdr *VAR_4, *VAR_5;", "VAR_4 = g_malloc(sizeof(struct mmsghdr) * VAR_1);", "VAR_5 = VAR_4;", "for (VAR_2 = 0; VAR_2 < VAR_1 ; VAR_2++) {", "VAR_4->msg_hdr.msg_name = NULL;", "VAR_4->msg_hdr.msg_namelen = 0;", "VAR_3 = g_malloc(sizeof(struct iovec) * IOVSIZE);", "VAR_4->msg_hdr.msg_iov = VAR_3;", "VAR_3->iov_base = g_malloc(VAR_0->header_size);", "VAR_3->iov_len = VAR_0->header_size;", "VAR_3++ ;", "VAR_3->iov_base = qemu_memalign(BUFFER_ALIGN, BUFFER_SIZE);", "VAR_3->iov_len = BUFFER_SIZE;", "VAR_4->msg_hdr.msg_iovlen = 2;", "VAR_4->msg_hdr.msg_control = NULL;", "VAR_4->msg_hdr.msg_controllen = 0;", "VAR_4->msg_hdr.msg_flags = 0;", "VAR_4++;", "}", "return VAR_5;", "}" ]
[ 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 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 ], [ 51 ] ]
8,913
int64_t bdrv_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { Coroutine *co; BdrvCoGetBlockStatusData data = { .bs = bs, .sector_num = sector_num, .nb_sectors = nb_sectors, .pnum = pnum, .done = false, }; if (qemu_in_coroutine()) { /* Fast-path if already in coroutine context */ bdrv_get_block_status_co_entry(&data); } else { co = qemu_coroutine_create(bdrv_get_block_status_co_entry); qemu_coroutine_enter(co, &data); while (!data.done) { qemu_aio_wait(); } } return data.ret; }
false
qemu
2572b37a4751cc967582d7d04f21d9bf97187ae5
int64_t bdrv_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { Coroutine *co; BdrvCoGetBlockStatusData data = { .bs = bs, .sector_num = sector_num, .nb_sectors = nb_sectors, .pnum = pnum, .done = false, }; if (qemu_in_coroutine()) { bdrv_get_block_status_co_entry(&data); } else { co = qemu_coroutine_create(bdrv_get_block_status_co_entry); qemu_coroutine_enter(co, &data); while (!data.done) { qemu_aio_wait(); } } return data.ret; }
{ "code": [], "line_no": [] }
int64_t FUNC_0(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { Coroutine *co; BdrvCoGetBlockStatusData data = { .bs = bs, .sector_num = sector_num, .nb_sectors = nb_sectors, .pnum = pnum, .done = false, }; if (qemu_in_coroutine()) { bdrv_get_block_status_co_entry(&data); } else { co = qemu_coroutine_create(bdrv_get_block_status_co_entry); qemu_coroutine_enter(co, &data); while (!data.done) { qemu_aio_wait(); } } return data.ret; }
[ "int64_t FUNC_0(BlockDriverState *bs, int64_t sector_num,\nint nb_sectors, int *pnum)\n{", "Coroutine *co;", "BdrvCoGetBlockStatusData data = {", ".bs = bs,\n.sector_num = sector_num,\n.nb_sectors = nb_sectors,\n.pnum = pnum,\n.done = false,\n};", "if (qemu_in_coroutine()) {", "bdrv_get_block_status_co_entry(&data);", "} else {", "co = qemu_coroutine_create(bdrv_get_block_status_co_entry);", "qemu_coroutine_enter(co, &data);", "while (!data.done) {", "qemu_aio_wait();", "}", "}", "return data.ret;", "}" ]
[ 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 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ] ]
8,914
static BlockDriverState *bdrv_new_open(const char *filename, const char *fmt, int flags, bool require_io, bool quiet) { BlockDriverState *bs; BlockDriver *drv; char password[256]; Error *local_err = NULL; int ret; bs = bdrv_new("image"); if (fmt) { drv = bdrv_find_format(fmt); if (!drv) { error_report("Unknown file format '%s'", fmt); goto fail; } } else { drv = NULL; } ret = bdrv_open(&bs, filename, NULL, NULL, flags, drv, &local_err); if (ret < 0) { error_report("Could not open '%s': %s", filename, error_get_pretty(local_err)); error_free(local_err); goto fail; } if (bdrv_is_encrypted(bs) && require_io) { qprintf(quiet, "Disk image '%s' is encrypted.\n", filename); if (read_password(password, sizeof(password)) < 0) { error_report("No password given"); goto fail; } if (bdrv_set_key(bs, password) < 0) { error_report("invalid password"); goto fail; } } return bs; fail: bdrv_unref(bs); return NULL; }
false
qemu
98522f63f40adaebc412481e1d2e9170160d4539
static BlockDriverState *bdrv_new_open(const char *filename, const char *fmt, int flags, bool require_io, bool quiet) { BlockDriverState *bs; BlockDriver *drv; char password[256]; Error *local_err = NULL; int ret; bs = bdrv_new("image"); if (fmt) { drv = bdrv_find_format(fmt); if (!drv) { error_report("Unknown file format '%s'", fmt); goto fail; } } else { drv = NULL; } ret = bdrv_open(&bs, filename, NULL, NULL, flags, drv, &local_err); if (ret < 0) { error_report("Could not open '%s': %s", filename, error_get_pretty(local_err)); error_free(local_err); goto fail; } if (bdrv_is_encrypted(bs) && require_io) { qprintf(quiet, "Disk image '%s' is encrypted.\n", filename); if (read_password(password, sizeof(password)) < 0) { error_report("No password given"); goto fail; } if (bdrv_set_key(bs, password) < 0) { error_report("invalid password"); goto fail; } } return bs; fail: bdrv_unref(bs); return NULL; }
{ "code": [], "line_no": [] }
static BlockDriverState *FUNC_0(const char *filename, const char *fmt, int flags, bool require_io, bool quiet) { BlockDriverState *bs; BlockDriver *drv; char VAR_0[256]; Error *local_err = NULL; int VAR_1; bs = bdrv_new("image"); if (fmt) { drv = bdrv_find_format(fmt); if (!drv) { error_report("Unknown file format '%s'", fmt); goto fail; } } else { drv = NULL; } VAR_1 = bdrv_open(&bs, filename, NULL, NULL, flags, drv, &local_err); if (VAR_1 < 0) { error_report("Could not open '%s': %s", filename, error_get_pretty(local_err)); error_free(local_err); goto fail; } if (bdrv_is_encrypted(bs) && require_io) { qprintf(quiet, "Disk image '%s' is encrypted.\n", filename); if (read_password(VAR_0, sizeof(VAR_0)) < 0) { error_report("No VAR_0 given"); goto fail; } if (bdrv_set_key(bs, VAR_0) < 0) { error_report("invalid VAR_0"); goto fail; } } return bs; fail: bdrv_unref(bs); return NULL; }
[ "static BlockDriverState *FUNC_0(const char *filename,\nconst char *fmt,\nint flags,\nbool require_io,\nbool quiet)\n{", "BlockDriverState *bs;", "BlockDriver *drv;", "char VAR_0[256];", "Error *local_err = NULL;", "int VAR_1;", "bs = bdrv_new(\"image\");", "if (fmt) {", "drv = bdrv_find_format(fmt);", "if (!drv) {", "error_report(\"Unknown file format '%s'\", fmt);", "goto fail;", "}", "} else {", "drv = NULL;", "}", "VAR_1 = bdrv_open(&bs, filename, NULL, NULL, flags, drv, &local_err);", "if (VAR_1 < 0) {", "error_report(\"Could not open '%s': %s\", filename,\nerror_get_pretty(local_err));", "error_free(local_err);", "goto fail;", "}", "if (bdrv_is_encrypted(bs) && require_io) {", "qprintf(quiet, \"Disk image '%s' is encrypted.\\n\", filename);", "if (read_password(VAR_0, sizeof(VAR_0)) < 0) {", "error_report(\"No VAR_0 given\");", "goto fail;", "}", "if (bdrv_set_key(bs, VAR_0) < 0) {", "error_report(\"invalid VAR_0\");", "goto fail;", "}", "}", "return bs;", "fail:\nbdrv_unref(bs);", "return NULL;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53, 55 ], [ 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89, 91 ], [ 93 ], [ 95 ] ]
8,916
void monitor_init(CharDriverState *hd, int show_banner) { int i; if (is_first_init) { key_timer = qemu_new_timer(vm_clock, release_keys, NULL); if (!key_timer) return; for (i = 0; i < MAX_MON; i++) { monitor_hd[i] = NULL; } is_first_init = 0; } for (i = 0; i < MAX_MON; i++) { if (monitor_hd[i] == NULL) { monitor_hd[i] = hd; break; } } hide_banner = !show_banner; qemu_chr_add_handlers(hd, term_can_read, term_read, term_event, NULL); readline_start("", 0, monitor_handle_command1, NULL); }
false
qemu
396f929762d10ba2c7b38f7e8a2276dd066be2d7
void monitor_init(CharDriverState *hd, int show_banner) { int i; if (is_first_init) { key_timer = qemu_new_timer(vm_clock, release_keys, NULL); if (!key_timer) return; for (i = 0; i < MAX_MON; i++) { monitor_hd[i] = NULL; } is_first_init = 0; } for (i = 0; i < MAX_MON; i++) { if (monitor_hd[i] == NULL) { monitor_hd[i] = hd; break; } } hide_banner = !show_banner; qemu_chr_add_handlers(hd, term_can_read, term_read, term_event, NULL); readline_start("", 0, monitor_handle_command1, NULL); }
{ "code": [], "line_no": [] }
void FUNC_0(CharDriverState *VAR_0, int VAR_1) { int VAR_2; if (is_first_init) { key_timer = qemu_new_timer(vm_clock, release_keys, NULL); if (!key_timer) return; for (VAR_2 = 0; VAR_2 < MAX_MON; VAR_2++) { monitor_hd[VAR_2] = NULL; } is_first_init = 0; } for (VAR_2 = 0; VAR_2 < MAX_MON; VAR_2++) { if (monitor_hd[VAR_2] == NULL) { monitor_hd[VAR_2] = VAR_0; break; } } hide_banner = !VAR_1; qemu_chr_add_handlers(VAR_0, term_can_read, term_read, term_event, NULL); readline_start("", 0, monitor_handle_command1, NULL); }
[ "void FUNC_0(CharDriverState *VAR_0, int VAR_1)\n{", "int VAR_2;", "if (is_first_init) {", "key_timer = qemu_new_timer(vm_clock, release_keys, NULL);", "if (!key_timer)\nreturn;", "for (VAR_2 = 0; VAR_2 < MAX_MON; VAR_2++) {", "monitor_hd[VAR_2] = NULL;", "}", "is_first_init = 0;", "}", "for (VAR_2 = 0; VAR_2 < MAX_MON; VAR_2++) {", "if (monitor_hd[VAR_2] == NULL) {", "monitor_hd[VAR_2] = VAR_0;", "break;", "}", "}", "hide_banner = !VAR_1;", "qemu_chr_add_handlers(VAR_0, term_can_read, term_read, term_event, NULL);", "readline_start(\"\", 0, monitor_handle_command1, NULL);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13, 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 45 ], [ 49 ], [ 51 ] ]
8,917
void OPPROTO op_jz_T0_label(void) { if (!T0) GOTO_LABEL_PARAM(1); FORCE_RET(); }
false
qemu
6e0d8677cb443e7408c0b7a25a93c6596d7fa380
void OPPROTO op_jz_T0_label(void) { if (!T0) GOTO_LABEL_PARAM(1); FORCE_RET(); }
{ "code": [], "line_no": [] }
void VAR_0 op_jz_T0_label(void) { if (!T0) GOTO_LABEL_PARAM(1); FORCE_RET(); }
[ "void VAR_0 op_jz_T0_label(void)\n{", "if (!T0)\nGOTO_LABEL_PARAM(1);", "FORCE_RET();", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5, 7 ], [ 9 ], [ 11 ] ]
8,918
struct omap_lcd_panel_s *omap_lcdc_init(MemoryRegion *sysmem, hwaddr base, qemu_irq irq, struct omap_dma_lcd_channel_s *dma, omap_clk clk) { struct omap_lcd_panel_s *s = (struct omap_lcd_panel_s *) g_malloc0(sizeof(struct omap_lcd_panel_s)); s->irq = irq; s->dma = dma; s->sysmem = sysmem; omap_lcdc_reset(s); memory_region_init_io(&s->iomem, &omap_lcdc_ops, s, "omap.lcdc", 0x100); memory_region_add_subregion(sysmem, base, &s->iomem); s->con = graphic_console_init(omap_update_display, omap_invalidate_display, omap_screen_dump, NULL, s); return s; }
false
qemu
2c62f08ddbf3fa80dc7202eb9a2ea60ae44e2cc5
struct omap_lcd_panel_s *omap_lcdc_init(MemoryRegion *sysmem, hwaddr base, qemu_irq irq, struct omap_dma_lcd_channel_s *dma, omap_clk clk) { struct omap_lcd_panel_s *s = (struct omap_lcd_panel_s *) g_malloc0(sizeof(struct omap_lcd_panel_s)); s->irq = irq; s->dma = dma; s->sysmem = sysmem; omap_lcdc_reset(s); memory_region_init_io(&s->iomem, &omap_lcdc_ops, s, "omap.lcdc", 0x100); memory_region_add_subregion(sysmem, base, &s->iomem); s->con = graphic_console_init(omap_update_display, omap_invalidate_display, omap_screen_dump, NULL, s); return s; }
{ "code": [], "line_no": [] }
struct omap_lcd_panel_s *FUNC_0(MemoryRegion *VAR_0, hwaddr VAR_1, qemu_irq VAR_2, struct omap_dma_lcd_channel_s *VAR_3, omap_clk VAR_4) { struct omap_lcd_panel_s *VAR_5 = (struct omap_lcd_panel_s *) g_malloc0(sizeof(struct omap_lcd_panel_s)); VAR_5->VAR_2 = VAR_2; VAR_5->VAR_3 = VAR_3; VAR_5->VAR_0 = VAR_0; omap_lcdc_reset(VAR_5); memory_region_init_io(&VAR_5->iomem, &omap_lcdc_ops, VAR_5, "omap.lcdc", 0x100); memory_region_add_subregion(VAR_0, VAR_1, &VAR_5->iomem); VAR_5->con = graphic_console_init(omap_update_display, omap_invalidate_display, omap_screen_dump, NULL, VAR_5); return VAR_5; }
[ "struct omap_lcd_panel_s *FUNC_0(MemoryRegion *VAR_0,\nhwaddr VAR_1,\nqemu_irq VAR_2,\nstruct omap_dma_lcd_channel_s *VAR_3,\nomap_clk VAR_4)\n{", "struct omap_lcd_panel_s *VAR_5 = (struct omap_lcd_panel_s *)\ng_malloc0(sizeof(struct omap_lcd_panel_s));", "VAR_5->VAR_2 = VAR_2;", "VAR_5->VAR_3 = VAR_3;", "VAR_5->VAR_0 = VAR_0;", "omap_lcdc_reset(VAR_5);", "memory_region_init_io(&VAR_5->iomem, &omap_lcdc_ops, VAR_5, \"omap.lcdc\", 0x100);", "memory_region_add_subregion(VAR_0, VAR_1, &VAR_5->iomem);", "VAR_5->con = graphic_console_init(omap_update_display,\nomap_invalidate_display,\nomap_screen_dump, NULL, VAR_5);", "return VAR_5;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11 ], [ 13, 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 35, 37, 39 ], [ 43 ], [ 45 ] ]
8,919
int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush){ AVPacketList *pktl, **next_point, *this_pktl; int stream_count=0; int streams[MAX_STREAMS]; if(pkt){ AVStream *st= s->streams[ pkt->stream_index]; // assert(pkt->destruct != av_destruct_packet); //FIXME this_pktl = av_mallocz(sizeof(AVPacketList)); this_pktl->pkt= *pkt; if(pkt->destruct == av_destruct_packet) pkt->destruct= NULL; // not shared -> must keep original from being freed else av_dup_packet(&this_pktl->pkt); //shared -> must dup next_point = &s->packet_buffer; while(*next_point){ AVStream *st2= s->streams[ (*next_point)->pkt.stream_index]; int64_t left= st2->time_base.num * (int64_t)st ->time_base.den; int64_t right= st ->time_base.num * (int64_t)st2->time_base.den; if((*next_point)->pkt.dts * left > pkt->dts * right) //FIXME this can overflow break; next_point= &(*next_point)->next; } this_pktl->next= *next_point; *next_point= this_pktl; } memset(streams, 0, sizeof(streams)); pktl= s->packet_buffer; while(pktl){ //av_log(s, AV_LOG_DEBUG, "show st:%d dts:%"PRId64"\n", pktl->pkt.stream_index, pktl->pkt.dts); if(streams[ pktl->pkt.stream_index ] == 0) stream_count++; streams[ pktl->pkt.stream_index ]++; pktl= pktl->next; } if(s->nb_streams == stream_count || (flush && stream_count)){ pktl= s->packet_buffer; *out= pktl->pkt; s->packet_buffer= pktl->next; av_freep(&pktl); return 1; }else{ av_init_packet(out); return 0; } }
false
FFmpeg
6919e54c00b750cd3d9d756258d3677df52f96a9
int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush){ AVPacketList *pktl, **next_point, *this_pktl; int stream_count=0; int streams[MAX_STREAMS]; if(pkt){ AVStream *st= s->streams[ pkt->stream_index]; this_pktl = av_mallocz(sizeof(AVPacketList)); this_pktl->pkt= *pkt; if(pkt->destruct == av_destruct_packet) pkt->destruct= NULL; else av_dup_packet(&this_pktl->pkt); next_point = &s->packet_buffer; while(*next_point){ AVStream *st2= s->streams[ (*next_point)->pkt.stream_index]; int64_t left= st2->time_base.num * (int64_t)st ->time_base.den; int64_t right= st ->time_base.num * (int64_t)st2->time_base.den; if((*next_point)->pkt.dts * left > pkt->dts * right) break; next_point= &(*next_point)->next; } this_pktl->next= *next_point; *next_point= this_pktl; } memset(streams, 0, sizeof(streams)); pktl= s->packet_buffer; while(pktl){ if(streams[ pktl->pkt.stream_index ] == 0) stream_count++; streams[ pktl->pkt.stream_index ]++; pktl= pktl->next; } if(s->nb_streams == stream_count || (flush && stream_count)){ pktl= s->packet_buffer; *out= pktl->pkt; s->packet_buffer= pktl->next; av_freep(&pktl); return 1; }else{ av_init_packet(out); return 0; } }
{ "code": [], "line_no": [] }
int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1, AVPacket *VAR_2, int VAR_3){ AVPacketList *pktl, **next_point, *this_pktl; int VAR_4=0; int VAR_5[MAX_STREAMS]; if(VAR_2){ AVStream *st= VAR_0->VAR_5[ VAR_2->stream_index]; this_pktl = av_mallocz(sizeof(AVPacketList)); this_pktl->VAR_2= *VAR_2; if(VAR_2->destruct == av_destruct_packet) VAR_2->destruct= NULL; else av_dup_packet(&this_pktl->VAR_2); next_point = &VAR_0->packet_buffer; while(*next_point){ AVStream *st2= VAR_0->VAR_5[ (*next_point)->VAR_2.stream_index]; int64_t left= st2->time_base.num * (int64_t)st ->time_base.den; int64_t right= st ->time_base.num * (int64_t)st2->time_base.den; if((*next_point)->VAR_2.dts * left > VAR_2->dts * right) break; next_point= &(*next_point)->next; } this_pktl->next= *next_point; *next_point= this_pktl; } memset(VAR_5, 0, sizeof(VAR_5)); pktl= VAR_0->packet_buffer; while(pktl){ if(VAR_5[ pktl->VAR_2.stream_index ] == 0) VAR_4++; VAR_5[ pktl->VAR_2.stream_index ]++; pktl= pktl->next; } if(VAR_0->nb_streams == VAR_4 || (VAR_3 && VAR_4)){ pktl= VAR_0->packet_buffer; *VAR_1= pktl->VAR_2; VAR_0->packet_buffer= pktl->next; av_freep(&pktl); return 1; }else{ av_init_packet(VAR_1); return 0; } }
[ "int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1, AVPacket *VAR_2, int VAR_3){", "AVPacketList *pktl, **next_point, *this_pktl;", "int VAR_4=0;", "int VAR_5[MAX_STREAMS];", "if(VAR_2){", "AVStream *st= VAR_0->VAR_5[ VAR_2->stream_index];", "this_pktl = av_mallocz(sizeof(AVPacketList));", "this_pktl->VAR_2= *VAR_2;", "if(VAR_2->destruct == av_destruct_packet)\nVAR_2->destruct= NULL;", "else\nav_dup_packet(&this_pktl->VAR_2);", "next_point = &VAR_0->packet_buffer;", "while(*next_point){", "AVStream *st2= VAR_0->VAR_5[ (*next_point)->VAR_2.stream_index];", "int64_t left= st2->time_base.num * (int64_t)st ->time_base.den;", "int64_t right= st ->time_base.num * (int64_t)st2->time_base.den;", "if((*next_point)->VAR_2.dts * left > VAR_2->dts * right)\nbreak;", "next_point= &(*next_point)->next;", "}", "this_pktl->next= *next_point;", "*next_point= this_pktl;", "}", "memset(VAR_5, 0, sizeof(VAR_5));", "pktl= VAR_0->packet_buffer;", "while(pktl){", "if(VAR_5[ pktl->VAR_2.stream_index ] == 0)\nVAR_4++;", "VAR_5[ pktl->VAR_2.stream_index ]++;", "pktl= pktl->next;", "}", "if(VAR_0->nb_streams == VAR_4 || (VAR_3 && VAR_4)){", "pktl= VAR_0->packet_buffer;", "*VAR_1= pktl->VAR_2;", "VAR_0->packet_buffer= pktl->next;", "av_freep(&pktl);", "return 1;", "}else{", "av_init_packet(VAR_1);", "return 0;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1 ], [ 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 29, 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ], [ 69, 71 ], [ 73 ], [ 75 ], [ 77 ], [ 81 ], [ 83 ], [ 85 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ] ]
8,920
int cpu_mb_handle_mmu_fault (CPUState *env, target_ulong address, int rw, int mmu_idx, int is_softmmu) { unsigned int hit; unsigned int mmu_available; int r = 1; int prot; mmu_available = 0; if (env->pvr.regs[0] & PVR0_USE_MMU) { mmu_available = 1; if ((env->pvr.regs[0] & PVR0_PVR_FULL_MASK) && (env->pvr.regs[11] & PVR11_USE_MMU) != PVR11_USE_MMU) { mmu_available = 0; } } /* Translate if the MMU is available and enabled. */ if (mmu_available && (env->sregs[SR_MSR] & MSR_VM)) { target_ulong vaddr, paddr; struct microblaze_mmu_lookup lu; hit = mmu_translate(&env->mmu, &lu, address, rw, mmu_idx); if (hit) { vaddr = address & TARGET_PAGE_MASK; paddr = lu.paddr + vaddr - lu.vaddr; DMMU(qemu_log("MMU map mmu=%d v=%x p=%x prot=%x\n", mmu_idx, vaddr, paddr, lu.prot)); r = tlb_set_page(env, vaddr, paddr, lu.prot, mmu_idx, is_softmmu); } else { env->sregs[SR_EAR] = address; DMMU(qemu_log("mmu=%d miss v=%x\n", mmu_idx, address)); switch (lu.err) { case ERR_PROT: env->sregs[SR_ESR] = rw == 2 ? 17 : 16; env->sregs[SR_ESR] |= (rw == 1) << 10; break; case ERR_MISS: env->sregs[SR_ESR] = rw == 2 ? 19 : 18; env->sregs[SR_ESR] |= (rw == 1) << 10; break; default: abort(); break; } if (env->exception_index == EXCP_MMU) { cpu_abort(env, "recursive faults\n"); } /* TLB miss. */ env->exception_index = EXCP_MMU; } } else { /* MMU disabled or not available. */ address &= TARGET_PAGE_MASK; prot = PAGE_BITS; r = tlb_set_page(env, address, address, prot, mmu_idx, is_softmmu); } return r; }
false
qemu
d4c430a80f000d722bb70287af4d4c184a8d7006
int cpu_mb_handle_mmu_fault (CPUState *env, target_ulong address, int rw, int mmu_idx, int is_softmmu) { unsigned int hit; unsigned int mmu_available; int r = 1; int prot; mmu_available = 0; if (env->pvr.regs[0] & PVR0_USE_MMU) { mmu_available = 1; if ((env->pvr.regs[0] & PVR0_PVR_FULL_MASK) && (env->pvr.regs[11] & PVR11_USE_MMU) != PVR11_USE_MMU) { mmu_available = 0; } } if (mmu_available && (env->sregs[SR_MSR] & MSR_VM)) { target_ulong vaddr, paddr; struct microblaze_mmu_lookup lu; hit = mmu_translate(&env->mmu, &lu, address, rw, mmu_idx); if (hit) { vaddr = address & TARGET_PAGE_MASK; paddr = lu.paddr + vaddr - lu.vaddr; DMMU(qemu_log("MMU map mmu=%d v=%x p=%x prot=%x\n", mmu_idx, vaddr, paddr, lu.prot)); r = tlb_set_page(env, vaddr, paddr, lu.prot, mmu_idx, is_softmmu); } else { env->sregs[SR_EAR] = address; DMMU(qemu_log("mmu=%d miss v=%x\n", mmu_idx, address)); switch (lu.err) { case ERR_PROT: env->sregs[SR_ESR] = rw == 2 ? 17 : 16; env->sregs[SR_ESR] |= (rw == 1) << 10; break; case ERR_MISS: env->sregs[SR_ESR] = rw == 2 ? 19 : 18; env->sregs[SR_ESR] |= (rw == 1) << 10; break; default: abort(); break; } if (env->exception_index == EXCP_MMU) { cpu_abort(env, "recursive faults\n"); } env->exception_index = EXCP_MMU; } } else { address &= TARGET_PAGE_MASK; prot = PAGE_BITS; r = tlb_set_page(env, address, address, prot, mmu_idx, is_softmmu); } return r; }
{ "code": [], "line_no": [] }
int FUNC_0 (CPUState *VAR_0, target_ulong VAR_1, int VAR_2, int VAR_3, int VAR_4) { unsigned int VAR_5; unsigned int VAR_6; int VAR_7 = 1; int VAR_8; VAR_6 = 0; if (VAR_0->pvr.regs[0] & PVR0_USE_MMU) { VAR_6 = 1; if ((VAR_0->pvr.regs[0] & PVR0_PVR_FULL_MASK) && (VAR_0->pvr.regs[11] & PVR11_USE_MMU) != PVR11_USE_MMU) { VAR_6 = 0; } } if (VAR_6 && (VAR_0->sregs[SR_MSR] & MSR_VM)) { target_ulong vaddr, paddr; struct microblaze_mmu_lookup VAR_9; VAR_5 = mmu_translate(&VAR_0->mmu, &VAR_9, VAR_1, VAR_2, VAR_3); if (VAR_5) { vaddr = VAR_1 & TARGET_PAGE_MASK; paddr = VAR_9.paddr + vaddr - VAR_9.vaddr; DMMU(qemu_log("MMU map mmu=%d v=%x p=%x VAR_8=%x\n", VAR_3, vaddr, paddr, VAR_9.VAR_8)); VAR_7 = tlb_set_page(VAR_0, vaddr, paddr, VAR_9.VAR_8, VAR_3, VAR_4); } else { VAR_0->sregs[SR_EAR] = VAR_1; DMMU(qemu_log("mmu=%d miss v=%x\n", VAR_3, VAR_1)); switch (VAR_9.err) { case ERR_PROT: VAR_0->sregs[SR_ESR] = VAR_2 == 2 ? 17 : 16; VAR_0->sregs[SR_ESR] |= (VAR_2 == 1) << 10; break; case ERR_MISS: VAR_0->sregs[SR_ESR] = VAR_2 == 2 ? 19 : 18; VAR_0->sregs[SR_ESR] |= (VAR_2 == 1) << 10; break; default: abort(); break; } if (VAR_0->exception_index == EXCP_MMU) { cpu_abort(VAR_0, "recursive faults\n"); } VAR_0->exception_index = EXCP_MMU; } } else { VAR_1 &= TARGET_PAGE_MASK; VAR_8 = PAGE_BITS; VAR_7 = tlb_set_page(VAR_0, VAR_1, VAR_1, VAR_8, VAR_3, VAR_4); } return VAR_7; }
[ "int FUNC_0 (CPUState *VAR_0, target_ulong VAR_1, int VAR_2,\nint VAR_3, int VAR_4)\n{", "unsigned int VAR_5;", "unsigned int VAR_6;", "int VAR_7 = 1;", "int VAR_8;", "VAR_6 = 0;", "if (VAR_0->pvr.regs[0] & PVR0_USE_MMU) {", "VAR_6 = 1;", "if ((VAR_0->pvr.regs[0] & PVR0_PVR_FULL_MASK)\n&& (VAR_0->pvr.regs[11] & PVR11_USE_MMU) != PVR11_USE_MMU) {", "VAR_6 = 0;", "}", "}", "if (VAR_6 && (VAR_0->sregs[SR_MSR] & MSR_VM)) {", "target_ulong vaddr, paddr;", "struct microblaze_mmu_lookup VAR_9;", "VAR_5 = mmu_translate(&VAR_0->mmu, &VAR_9, VAR_1, VAR_2, VAR_3);", "if (VAR_5) {", "vaddr = VAR_1 & TARGET_PAGE_MASK;", "paddr = VAR_9.paddr + vaddr - VAR_9.vaddr;", "DMMU(qemu_log(\"MMU map mmu=%d v=%x p=%x VAR_8=%x\\n\",\nVAR_3, vaddr, paddr, VAR_9.VAR_8));", "VAR_7 = tlb_set_page(VAR_0, vaddr,\npaddr, VAR_9.VAR_8, VAR_3, VAR_4);", "} else {", "VAR_0->sregs[SR_EAR] = VAR_1;", "DMMU(qemu_log(\"mmu=%d miss v=%x\\n\", VAR_3, VAR_1));", "switch (VAR_9.err) {", "case ERR_PROT:\nVAR_0->sregs[SR_ESR] = VAR_2 == 2 ? 17 : 16;", "VAR_0->sregs[SR_ESR] |= (VAR_2 == 1) << 10;", "break;", "case ERR_MISS:\nVAR_0->sregs[SR_ESR] = VAR_2 == 2 ? 19 : 18;", "VAR_0->sregs[SR_ESR] |= (VAR_2 == 1) << 10;", "break;", "default:\nabort();", "break;", "}", "if (VAR_0->exception_index == EXCP_MMU) {", "cpu_abort(VAR_0, \"recursive faults\\n\");", "}", "VAR_0->exception_index = EXCP_MMU;", "}", "} else {", "VAR_1 &= TARGET_PAGE_MASK;", "VAR_8 = PAGE_BITS;", "VAR_7 = tlb_set_page(VAR_0, VAR_1, VAR_1, VAR_8, VAR_3, VAR_4);", "}", "return VAR_7;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23, 25 ], [ 27 ], [ 29 ], [ 31 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55, 57 ], [ 59, 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73, 75 ], [ 77 ], [ 79 ], [ 81, 83 ], [ 85 ], [ 87 ], [ 89, 91 ], [ 93 ], [ 95 ], [ 99 ], [ 101 ], [ 103 ], [ 109 ], [ 111 ], [ 113 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ] ]
8,921
static uint64_t grlib_irqmp_read(void *opaque, target_phys_addr_t addr, unsigned size) { IRQMP *irqmp = opaque; IRQMPState *state; assert(irqmp != NULL); state = irqmp->state; assert(state != NULL); addr &= 0xff; /* global registers */ switch (addr) { case LEVEL_OFFSET: return state->level; case PENDING_OFFSET: return state->pending; case FORCE0_OFFSET: /* This register is an "alias" for the force register of CPU 0 */ return state->force[0]; case CLEAR_OFFSET: case MP_STATUS_OFFSET: /* Always read as 0 */ return 0; case BROADCAST_OFFSET: return state->broadcast; default: break; } /* mask registers */ if (addr >= MASK_OFFSET && addr < FORCE_OFFSET) { int cpu = (addr - MASK_OFFSET) / 4; assert(cpu >= 0 && cpu < IRQMP_MAX_CPU); return state->mask[cpu]; } /* force registers */ if (addr >= FORCE_OFFSET && addr < EXTENDED_OFFSET) { int cpu = (addr - FORCE_OFFSET) / 4; assert(cpu >= 0 && cpu < IRQMP_MAX_CPU); return state->force[cpu]; } /* extended (not supported) */ if (addr >= EXTENDED_OFFSET && addr < IRQMP_REG_SIZE) { int cpu = (addr - EXTENDED_OFFSET) / 4; assert(cpu >= 0 && cpu < IRQMP_MAX_CPU); return state->extended[cpu]; } trace_grlib_irqmp_readl_unknown(addr); return 0; }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static uint64_t grlib_irqmp_read(void *opaque, target_phys_addr_t addr, unsigned size) { IRQMP *irqmp = opaque; IRQMPState *state; assert(irqmp != NULL); state = irqmp->state; assert(state != NULL); addr &= 0xff; switch (addr) { case LEVEL_OFFSET: return state->level; case PENDING_OFFSET: return state->pending; case FORCE0_OFFSET: return state->force[0]; case CLEAR_OFFSET: case MP_STATUS_OFFSET: return 0; case BROADCAST_OFFSET: return state->broadcast; default: break; } if (addr >= MASK_OFFSET && addr < FORCE_OFFSET) { int cpu = (addr - MASK_OFFSET) / 4; assert(cpu >= 0 && cpu < IRQMP_MAX_CPU); return state->mask[cpu]; } if (addr >= FORCE_OFFSET && addr < EXTENDED_OFFSET) { int cpu = (addr - FORCE_OFFSET) / 4; assert(cpu >= 0 && cpu < IRQMP_MAX_CPU); return state->force[cpu]; } if (addr >= EXTENDED_OFFSET && addr < IRQMP_REG_SIZE) { int cpu = (addr - EXTENDED_OFFSET) / 4; assert(cpu >= 0 && cpu < IRQMP_MAX_CPU); return state->extended[cpu]; } trace_grlib_irqmp_readl_unknown(addr); return 0; }
{ "code": [], "line_no": [] }
static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr, unsigned size) { IRQMP *irqmp = opaque; IRQMPState *state; assert(irqmp != NULL); state = irqmp->state; assert(state != NULL); addr &= 0xff; switch (addr) { case LEVEL_OFFSET: return state->level; case PENDING_OFFSET: return state->pending; case FORCE0_OFFSET: return state->force[0]; case CLEAR_OFFSET: case MP_STATUS_OFFSET: return 0; case BROADCAST_OFFSET: return state->broadcast; default: break; } if (addr >= MASK_OFFSET && addr < FORCE_OFFSET) { int VAR_1 = (addr - MASK_OFFSET) / 4; assert(VAR_1 >= 0 && VAR_1 < IRQMP_MAX_CPU); return state->mask[VAR_1]; } if (addr >= FORCE_OFFSET && addr < EXTENDED_OFFSET) { int VAR_1 = (addr - FORCE_OFFSET) / 4; assert(VAR_1 >= 0 && VAR_1 < IRQMP_MAX_CPU); return state->force[VAR_1]; } if (addr >= EXTENDED_OFFSET && addr < IRQMP_REG_SIZE) { int VAR_1 = (addr - EXTENDED_OFFSET) / 4; assert(VAR_1 >= 0 && VAR_1 < IRQMP_MAX_CPU); return state->extended[VAR_1]; } trace_grlib_irqmp_readl_unknown(addr); return 0; }
[ "static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{", "IRQMP *irqmp = opaque;", "IRQMPState *state;", "assert(irqmp != NULL);", "state = irqmp->state;", "assert(state != NULL);", "addr &= 0xff;", "switch (addr) {", "case LEVEL_OFFSET:\nreturn state->level;", "case PENDING_OFFSET:\nreturn state->pending;", "case FORCE0_OFFSET:\nreturn state->force[0];", "case CLEAR_OFFSET:\ncase MP_STATUS_OFFSET:\nreturn 0;", "case BROADCAST_OFFSET:\nreturn state->broadcast;", "default:\nbreak;", "}", "if (addr >= MASK_OFFSET && addr < FORCE_OFFSET) {", "int VAR_1 = (addr - MASK_OFFSET) / 4;", "assert(VAR_1 >= 0 && VAR_1 < IRQMP_MAX_CPU);", "return state->mask[VAR_1];", "}", "if (addr >= FORCE_OFFSET && addr < EXTENDED_OFFSET) {", "int VAR_1 = (addr - FORCE_OFFSET) / 4;", "assert(VAR_1 >= 0 && VAR_1 < IRQMP_MAX_CPU);", "return state->force[VAR_1];", "}", "if (addr >= EXTENDED_OFFSET && addr < IRQMP_REG_SIZE) {", "int VAR_1 = (addr - EXTENDED_OFFSET) / 4;", "assert(VAR_1 >= 0 && VAR_1 < IRQMP_MAX_CPU);", "return state->extended[VAR_1];", "}", "trace_grlib_irqmp_readl_unknown(addr);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 27 ], [ 29, 31 ], [ 35, 37 ], [ 41, 45 ], [ 49, 51, 55 ], [ 59, 61 ], [ 65, 67 ], [ 69 ], [ 75 ], [ 77 ], [ 79 ], [ 83 ], [ 85 ], [ 91 ], [ 93 ], [ 95 ], [ 99 ], [ 101 ], [ 107 ], [ 109 ], [ 111 ], [ 115 ], [ 117 ], [ 121 ], [ 123 ], [ 125 ] ]
8,922
Object *object_new_with_propv(const char *typename, Object *parent, const char *id, Error **errp, va_list vargs) { Object *obj; ObjectClass *klass; Error *local_err = NULL; klass = object_class_by_name(typename); if (!klass) { error_setg(errp, "invalid object type: %s", typename); return NULL; } if (object_class_is_abstract(klass)) { error_setg(errp, "object type '%s' is abstract", typename); return NULL; } obj = object_new(typename); if (object_set_propv(obj, &local_err, vargs) < 0) { goto error; } object_property_add_child(parent, id, obj, &local_err); if (local_err) { goto error; } if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) { user_creatable_complete(obj, &local_err); if (local_err) { object_unparent(obj); goto error; } } object_unref(OBJECT(obj)); return obj; error: if (local_err) { error_propagate(errp, local_err); } object_unref(obj); return NULL; }
false
qemu
621ff94d5074d88253a5818c6b9c4db718fbfc65
Object *object_new_with_propv(const char *typename, Object *parent, const char *id, Error **errp, va_list vargs) { Object *obj; ObjectClass *klass; Error *local_err = NULL; klass = object_class_by_name(typename); if (!klass) { error_setg(errp, "invalid object type: %s", typename); return NULL; } if (object_class_is_abstract(klass)) { error_setg(errp, "object type '%s' is abstract", typename); return NULL; } obj = object_new(typename); if (object_set_propv(obj, &local_err, vargs) < 0) { goto error; } object_property_add_child(parent, id, obj, &local_err); if (local_err) { goto error; } if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) { user_creatable_complete(obj, &local_err); if (local_err) { object_unparent(obj); goto error; } } object_unref(OBJECT(obj)); return obj; error: if (local_err) { error_propagate(errp, local_err); } object_unref(obj); return NULL; }
{ "code": [], "line_no": [] }
Object *FUNC_0(const char *typename, Object *parent, const char *id, Error **errp, va_list vargs) { Object *obj; ObjectClass *klass; Error *local_err = NULL; klass = object_class_by_name(typename); if (!klass) { error_setg(errp, "invalid object type: %s", typename); return NULL; } if (object_class_is_abstract(klass)) { error_setg(errp, "object type '%s' is abstract", typename); return NULL; } obj = object_new(typename); if (object_set_propv(obj, &local_err, vargs) < 0) { goto error; } object_property_add_child(parent, id, obj, &local_err); if (local_err) { goto error; } if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) { user_creatable_complete(obj, &local_err); if (local_err) { object_unparent(obj); goto error; } } object_unref(OBJECT(obj)); return obj; error: if (local_err) { error_propagate(errp, local_err); } object_unref(obj); return NULL; }
[ "Object *FUNC_0(const char *typename,\nObject *parent,\nconst char *id,\nError **errp,\nva_list vargs)\n{", "Object *obj;", "ObjectClass *klass;", "Error *local_err = NULL;", "klass = object_class_by_name(typename);", "if (!klass) {", "error_setg(errp, \"invalid object type: %s\", typename);", "return NULL;", "}", "if (object_class_is_abstract(klass)) {", "error_setg(errp, \"object type '%s' is abstract\", typename);", "return NULL;", "}", "obj = object_new(typename);", "if (object_set_propv(obj, &local_err, vargs) < 0) {", "goto error;", "}", "object_property_add_child(parent, id, obj, &local_err);", "if (local_err) {", "goto error;", "}", "if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {", "user_creatable_complete(obj, &local_err);", "if (local_err) {", "object_unparent(obj);", "goto error;", "}", "}", "object_unref(OBJECT(obj));", "return obj;", "error:\nif (local_err) {", "error_propagate(errp, local_err);", "}", "object_unref(obj);", "return NULL;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 85, 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ] ]
8,923
void start_auth_sasl(VncState *vs) { const char *mechlist = NULL; sasl_security_properties_t secprops; int err; char *localAddr, *remoteAddr; int mechlistlen; VNC_DEBUG("Initialize SASL auth %d\n", vs->csock); /* Get local & remote client addresses in form IPADDR;PORT */ if (!(localAddr = vnc_socket_local_addr("%s;%s", vs->csock))) goto authabort; if (!(remoteAddr = vnc_socket_remote_addr("%s;%s", vs->csock))) { free(localAddr); goto authabort; } err = sasl_server_new("vnc", NULL, /* FQDN - just delegates to gethostname */ NULL, /* User realm */ localAddr, remoteAddr, NULL, /* Callbacks, not needed */ SASL_SUCCESS_DATA, &vs->sasl.conn); free(localAddr); free(remoteAddr); localAddr = remoteAddr = NULL; if (err != SASL_OK) { VNC_DEBUG("sasl context setup failed %d (%s)", err, sasl_errstring(err, NULL, NULL)); vs->sasl.conn = NULL; goto authabort; } #ifdef CONFIG_VNC_TLS /* Inform SASL that we've got an external SSF layer from TLS/x509 */ if (vs->vd->auth == VNC_AUTH_VENCRYPT && vs->vd->subauth == VNC_AUTH_VENCRYPT_X509SASL) { gnutls_cipher_algorithm_t cipher; sasl_ssf_t ssf; cipher = gnutls_cipher_get(vs->tls.session); if (!(ssf = (sasl_ssf_t)gnutls_cipher_get_key_size(cipher))) { VNC_DEBUG("%s", "cannot TLS get cipher size\n"); sasl_dispose(&vs->sasl.conn); vs->sasl.conn = NULL; goto authabort; } ssf *= 8; /* tls key size is bytes, sasl wants bits */ err = sasl_setprop(vs->sasl.conn, SASL_SSF_EXTERNAL, &ssf); if (err != SASL_OK) { VNC_DEBUG("cannot set SASL external SSF %d (%s)\n", err, sasl_errstring(err, NULL, NULL)); sasl_dispose(&vs->sasl.conn); vs->sasl.conn = NULL; goto authabort; } } else #endif /* CONFIG_VNC_TLS */ vs->sasl.wantSSF = 1; memset (&secprops, 0, sizeof secprops); /* Inform SASL that we've got an external SSF layer from TLS */ if (strncmp(vs->vd->display, "unix:", 5) == 0 #ifdef CONFIG_VNC_TLS /* Disable SSF, if using TLS+x509+SASL only. TLS without x509 is not sufficiently strong */ || (vs->vd->auth == VNC_AUTH_VENCRYPT && vs->vd->subauth == VNC_AUTH_VENCRYPT_X509SASL) #endif /* CONFIG_VNC_TLS */ ) { /* If we've got TLS or UNIX domain sock, we don't care about SSF */ secprops.min_ssf = 0; secprops.max_ssf = 0; secprops.maxbufsize = 8192; secprops.security_flags = 0; } else { /* Plain TCP, better get an SSF layer */ secprops.min_ssf = 56; /* Good enough to require kerberos */ secprops.max_ssf = 100000; /* Arbitrary big number */ secprops.maxbufsize = 8192; /* Forbid any anonymous or trivially crackable auth */ secprops.security_flags = SASL_SEC_NOANONYMOUS | SASL_SEC_NOPLAINTEXT; } err = sasl_setprop(vs->sasl.conn, SASL_SEC_PROPS, &secprops); if (err != SASL_OK) { VNC_DEBUG("cannot set SASL security props %d (%s)\n", err, sasl_errstring(err, NULL, NULL)); sasl_dispose(&vs->sasl.conn); vs->sasl.conn = NULL; goto authabort; } err = sasl_listmech(vs->sasl.conn, NULL, /* Don't need to set user */ "", /* Prefix */ ",", /* Separator */ "", /* Suffix */ &mechlist, NULL, NULL); if (err != SASL_OK) { VNC_DEBUG("cannot list SASL mechanisms %d (%s)\n", err, sasl_errdetail(vs->sasl.conn)); sasl_dispose(&vs->sasl.conn); vs->sasl.conn = NULL; goto authabort; } VNC_DEBUG("Available mechanisms for client: '%s'\n", mechlist); if (!(vs->sasl.mechlist = strdup(mechlist))) { VNC_DEBUG("Out of memory"); sasl_dispose(&vs->sasl.conn); vs->sasl.conn = NULL; goto authabort; } mechlistlen = strlen(mechlist); vnc_write_u32(vs, mechlistlen); vnc_write(vs, mechlist, mechlistlen); vnc_flush(vs); VNC_DEBUG("Wait for client mechname length\n"); vnc_read_when(vs, protocol_client_auth_sasl_mechname_len, 4); return; authabort: vnc_client_error(vs); return; }
false
qemu
7e7e2ebc942da8285931ceabf12823e165dced8b
void start_auth_sasl(VncState *vs) { const char *mechlist = NULL; sasl_security_properties_t secprops; int err; char *localAddr, *remoteAddr; int mechlistlen; VNC_DEBUG("Initialize SASL auth %d\n", vs->csock); if (!(localAddr = vnc_socket_local_addr("%s;%s", vs->csock))) goto authabort; if (!(remoteAddr = vnc_socket_remote_addr("%s;%s", vs->csock))) { free(localAddr); goto authabort; } err = sasl_server_new("vnc", NULL, NULL, localAddr, remoteAddr, NULL, SASL_SUCCESS_DATA, &vs->sasl.conn); free(localAddr); free(remoteAddr); localAddr = remoteAddr = NULL; if (err != SASL_OK) { VNC_DEBUG("sasl context setup failed %d (%s)", err, sasl_errstring(err, NULL, NULL)); vs->sasl.conn = NULL; goto authabort; } #ifdef CONFIG_VNC_TLS if (vs->vd->auth == VNC_AUTH_VENCRYPT && vs->vd->subauth == VNC_AUTH_VENCRYPT_X509SASL) { gnutls_cipher_algorithm_t cipher; sasl_ssf_t ssf; cipher = gnutls_cipher_get(vs->tls.session); if (!(ssf = (sasl_ssf_t)gnutls_cipher_get_key_size(cipher))) { VNC_DEBUG("%s", "cannot TLS get cipher size\n"); sasl_dispose(&vs->sasl.conn); vs->sasl.conn = NULL; goto authabort; } ssf *= 8; err = sasl_setprop(vs->sasl.conn, SASL_SSF_EXTERNAL, &ssf); if (err != SASL_OK) { VNC_DEBUG("cannot set SASL external SSF %d (%s)\n", err, sasl_errstring(err, NULL, NULL)); sasl_dispose(&vs->sasl.conn); vs->sasl.conn = NULL; goto authabort; } } else #endif vs->sasl.wantSSF = 1; memset (&secprops, 0, sizeof secprops); if (strncmp(vs->vd->display, "unix:", 5) == 0 #ifdef CONFIG_VNC_TLS || (vs->vd->auth == VNC_AUTH_VENCRYPT && vs->vd->subauth == VNC_AUTH_VENCRYPT_X509SASL) #endif ) { secprops.min_ssf = 0; secprops.max_ssf = 0; secprops.maxbufsize = 8192; secprops.security_flags = 0; } else { secprops.min_ssf = 56; secprops.max_ssf = 100000; secprops.maxbufsize = 8192; secprops.security_flags = SASL_SEC_NOANONYMOUS | SASL_SEC_NOPLAINTEXT; } err = sasl_setprop(vs->sasl.conn, SASL_SEC_PROPS, &secprops); if (err != SASL_OK) { VNC_DEBUG("cannot set SASL security props %d (%s)\n", err, sasl_errstring(err, NULL, NULL)); sasl_dispose(&vs->sasl.conn); vs->sasl.conn = NULL; goto authabort; } err = sasl_listmech(vs->sasl.conn, NULL, "", ",", "", &mechlist, NULL, NULL); if (err != SASL_OK) { VNC_DEBUG("cannot list SASL mechanisms %d (%s)\n", err, sasl_errdetail(vs->sasl.conn)); sasl_dispose(&vs->sasl.conn); vs->sasl.conn = NULL; goto authabort; } VNC_DEBUG("Available mechanisms for client: '%s'\n", mechlist); if (!(vs->sasl.mechlist = strdup(mechlist))) { VNC_DEBUG("Out of memory"); sasl_dispose(&vs->sasl.conn); vs->sasl.conn = NULL; goto authabort; } mechlistlen = strlen(mechlist); vnc_write_u32(vs, mechlistlen); vnc_write(vs, mechlist, mechlistlen); vnc_flush(vs); VNC_DEBUG("Wait for client mechname length\n"); vnc_read_when(vs, protocol_client_auth_sasl_mechname_len, 4); return; authabort: vnc_client_error(vs); return; }
{ "code": [], "line_no": [] }
void FUNC_0(VncState *VAR_0) { const char *VAR_1 = NULL; sasl_security_properties_t secprops; int VAR_2; char *VAR_3, *VAR_4; int VAR_5; VNC_DEBUG("Initialize SASL auth %d\n", VAR_0->csock); if (!(VAR_3 = vnc_socket_local_addr("%s;%s", VAR_0->csock))) goto authabort; if (!(VAR_4 = vnc_socket_remote_addr("%s;%s", VAR_0->csock))) { free(VAR_3); goto authabort; } VAR_2 = sasl_server_new("vnc", NULL, NULL, VAR_3, VAR_4, NULL, SASL_SUCCESS_DATA, &VAR_0->sasl.conn); free(VAR_3); free(VAR_4); VAR_3 = VAR_4 = NULL; if (VAR_2 != SASL_OK) { VNC_DEBUG("sasl context setup failed %d (%s)", VAR_2, sasl_errstring(VAR_2, NULL, NULL)); VAR_0->sasl.conn = NULL; goto authabort; } #ifdef CONFIG_VNC_TLS if (VAR_0->vd->auth == VNC_AUTH_VENCRYPT && VAR_0->vd->subauth == VNC_AUTH_VENCRYPT_X509SASL) { gnutls_cipher_algorithm_t cipher; sasl_ssf_t ssf; cipher = gnutls_cipher_get(VAR_0->tls.session); if (!(ssf = (sasl_ssf_t)gnutls_cipher_get_key_size(cipher))) { VNC_DEBUG("%s", "cannot TLS get cipher size\n"); sasl_dispose(&VAR_0->sasl.conn); VAR_0->sasl.conn = NULL; goto authabort; } ssf *= 8; VAR_2 = sasl_setprop(VAR_0->sasl.conn, SASL_SSF_EXTERNAL, &ssf); if (VAR_2 != SASL_OK) { VNC_DEBUG("cannot set SASL external SSF %d (%s)\n", VAR_2, sasl_errstring(VAR_2, NULL, NULL)); sasl_dispose(&VAR_0->sasl.conn); VAR_0->sasl.conn = NULL; goto authabort; } } else #endif VAR_0->sasl.wantSSF = 1; memset (&secprops, 0, sizeof secprops); if (strncmp(VAR_0->vd->display, "unix:", 5) == 0 #ifdef CONFIG_VNC_TLS || (VAR_0->vd->auth == VNC_AUTH_VENCRYPT && VAR_0->vd->subauth == VNC_AUTH_VENCRYPT_X509SASL) #endif ) { secprops.min_ssf = 0; secprops.max_ssf = 0; secprops.maxbufsize = 8192; secprops.security_flags = 0; } else { secprops.min_ssf = 56; secprops.max_ssf = 100000; secprops.maxbufsize = 8192; secprops.security_flags = SASL_SEC_NOANONYMOUS | SASL_SEC_NOPLAINTEXT; } VAR_2 = sasl_setprop(VAR_0->sasl.conn, SASL_SEC_PROPS, &secprops); if (VAR_2 != SASL_OK) { VNC_DEBUG("cannot set SASL security props %d (%s)\n", VAR_2, sasl_errstring(VAR_2, NULL, NULL)); sasl_dispose(&VAR_0->sasl.conn); VAR_0->sasl.conn = NULL; goto authabort; } VAR_2 = sasl_listmech(VAR_0->sasl.conn, NULL, "", ",", "", &VAR_1, NULL, NULL); if (VAR_2 != SASL_OK) { VNC_DEBUG("cannot list SASL mechanisms %d (%s)\n", VAR_2, sasl_errdetail(VAR_0->sasl.conn)); sasl_dispose(&VAR_0->sasl.conn); VAR_0->sasl.conn = NULL; goto authabort; } VNC_DEBUG("Available mechanisms for client: '%s'\n", VAR_1); if (!(VAR_0->sasl.VAR_1 = strdup(VAR_1))) { VNC_DEBUG("Out of memory"); sasl_dispose(&VAR_0->sasl.conn); VAR_0->sasl.conn = NULL; goto authabort; } VAR_5 = strlen(VAR_1); vnc_write_u32(VAR_0, VAR_5); vnc_write(VAR_0, VAR_1, VAR_5); vnc_flush(VAR_0); VNC_DEBUG("Wait for client mechname length\n"); vnc_read_when(VAR_0, protocol_client_auth_sasl_mechname_len, 4); return; authabort: vnc_client_error(VAR_0); return; }
[ "void FUNC_0(VncState *VAR_0)\n{", "const char *VAR_1 = NULL;", "sasl_security_properties_t secprops;", "int VAR_2;", "char *VAR_3, *VAR_4;", "int VAR_5;", "VNC_DEBUG(\"Initialize SASL auth %d\\n\", VAR_0->csock);", "if (!(VAR_3 = vnc_socket_local_addr(\"%s;%s\", VAR_0->csock)))", "goto authabort;", "if (!(VAR_4 = vnc_socket_remote_addr(\"%s;%s\", VAR_0->csock))) {", "free(VAR_3);", "goto authabort;", "}", "VAR_2 = sasl_server_new(\"vnc\",\nNULL,\nNULL,\nVAR_3,\nVAR_4,\nNULL,\nSASL_SUCCESS_DATA,\n&VAR_0->sasl.conn);", "free(VAR_3);", "free(VAR_4);", "VAR_3 = VAR_4 = NULL;", "if (VAR_2 != SASL_OK) {", "VNC_DEBUG(\"sasl context setup failed %d (%s)\",\nVAR_2, sasl_errstring(VAR_2, NULL, NULL));", "VAR_0->sasl.conn = NULL;", "goto authabort;", "}", "#ifdef CONFIG_VNC_TLS\nif (VAR_0->vd->auth == VNC_AUTH_VENCRYPT &&\nVAR_0->vd->subauth == VNC_AUTH_VENCRYPT_X509SASL) {", "gnutls_cipher_algorithm_t cipher;", "sasl_ssf_t ssf;", "cipher = gnutls_cipher_get(VAR_0->tls.session);", "if (!(ssf = (sasl_ssf_t)gnutls_cipher_get_key_size(cipher))) {", "VNC_DEBUG(\"%s\", \"cannot TLS get cipher size\\n\");", "sasl_dispose(&VAR_0->sasl.conn);", "VAR_0->sasl.conn = NULL;", "goto authabort;", "}", "ssf *= 8;", "VAR_2 = sasl_setprop(VAR_0->sasl.conn, SASL_SSF_EXTERNAL, &ssf);", "if (VAR_2 != SASL_OK) {", "VNC_DEBUG(\"cannot set SASL external SSF %d (%s)\\n\",\nVAR_2, sasl_errstring(VAR_2, NULL, NULL));", "sasl_dispose(&VAR_0->sasl.conn);", "VAR_0->sasl.conn = NULL;", "goto authabort;", "}", "} else", "#endif\nVAR_0->sasl.wantSSF = 1;", "memset (&secprops, 0, sizeof secprops);", "if (strncmp(VAR_0->vd->display, \"unix:\", 5) == 0\n#ifdef CONFIG_VNC_TLS\n|| (VAR_0->vd->auth == VNC_AUTH_VENCRYPT &&\nVAR_0->vd->subauth == VNC_AUTH_VENCRYPT_X509SASL)\n#endif\n) {", "secprops.min_ssf = 0;", "secprops.max_ssf = 0;", "secprops.maxbufsize = 8192;", "secprops.security_flags = 0;", "} else {", "secprops.min_ssf = 56;", "secprops.max_ssf = 100000;", "secprops.maxbufsize = 8192;", "secprops.security_flags =\nSASL_SEC_NOANONYMOUS | SASL_SEC_NOPLAINTEXT;", "}", "VAR_2 = sasl_setprop(VAR_0->sasl.conn, SASL_SEC_PROPS, &secprops);", "if (VAR_2 != SASL_OK) {", "VNC_DEBUG(\"cannot set SASL security props %d (%s)\\n\",\nVAR_2, sasl_errstring(VAR_2, NULL, NULL));", "sasl_dispose(&VAR_0->sasl.conn);", "VAR_0->sasl.conn = NULL;", "goto authabort;", "}", "VAR_2 = sasl_listmech(VAR_0->sasl.conn,\nNULL,\n\"\",\n\",\",\n\"\",\n&VAR_1,\nNULL,\nNULL);", "if (VAR_2 != SASL_OK) {", "VNC_DEBUG(\"cannot list SASL mechanisms %d (%s)\\n\",\nVAR_2, sasl_errdetail(VAR_0->sasl.conn));", "sasl_dispose(&VAR_0->sasl.conn);", "VAR_0->sasl.conn = NULL;", "goto authabort;", "}", "VNC_DEBUG(\"Available mechanisms for client: '%s'\\n\", VAR_1);", "if (!(VAR_0->sasl.VAR_1 = strdup(VAR_1))) {", "VNC_DEBUG(\"Out of memory\");", "sasl_dispose(&VAR_0->sasl.conn);", "VAR_0->sasl.conn = NULL;", "goto authabort;", "}", "VAR_5 = strlen(VAR_1);", "vnc_write_u32(VAR_0, VAR_5);", "vnc_write(VAR_0, VAR_1, VAR_5);", "vnc_flush(VAR_0);", "VNC_DEBUG(\"Wait for client mechname length\\n\");", "vnc_read_when(VAR_0, protocol_client_auth_sasl_mechname_len, 4);", "return;", "authabort:\nvnc_client_error(VAR_0);", "return;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39, 41, 43, 45, 47, 49, 51, 53 ], [ 55 ], [ 57 ], [ 59 ], [ 63 ], [ 65, 67 ], [ 69 ], [ 71 ], [ 73 ], [ 77, 81, 83 ], [ 85 ], [ 87 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 109 ], [ 111 ], [ 113, 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127, 129 ], [ 133 ], [ 137, 139, 145, 147, 149, 151 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 167 ], [ 169 ], [ 171 ], [ 175, 177 ], [ 179 ], [ 183 ], [ 185 ], [ 187, 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 201, 203, 205, 207, 209, 211, 213, 215 ], [ 217 ], [ 219, 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 257 ], [ 259 ], [ 263 ], [ 267, 269 ], [ 271 ], [ 273 ] ]
8,924
static void visitor_output_teardown(TestOutputVisitorData *data, const void *unused) { visit_free(data->ov); data->sov = NULL; data->ov = NULL; g_free(data->str); data->str = NULL; }
false
qemu
3b098d56979d2f7fd707c5be85555d114353a28d
static void visitor_output_teardown(TestOutputVisitorData *data, const void *unused) { visit_free(data->ov); data->sov = NULL; data->ov = NULL; g_free(data->str); data->str = NULL; }
{ "code": [], "line_no": [] }
static void FUNC_0(TestOutputVisitorData *VAR_0, const void *VAR_1) { visit_free(VAR_0->ov); VAR_0->sov = NULL; VAR_0->ov = NULL; g_free(VAR_0->str); VAR_0->str = NULL; }
[ "static void FUNC_0(TestOutputVisitorData *VAR_0,\nconst void *VAR_1)\n{", "visit_free(VAR_0->ov);", "VAR_0->sov = NULL;", "VAR_0->ov = NULL;", "g_free(VAR_0->str);", "VAR_0->str = NULL;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ] ]
8,925
static void megasas_port_write(void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size) { megasas_mmio_write(opaque, addr & 0xff, val, size); }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static void megasas_port_write(void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size) { megasas_mmio_write(opaque, addr & 0xff, val, size); }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint64_t VAR_2, unsigned VAR_3) { megasas_mmio_write(VAR_0, VAR_1 & 0xff, VAR_2, VAR_3); }
[ "static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{", "megasas_mmio_write(VAR_0, VAR_1 & 0xff, VAR_2, VAR_3);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ] ]
8,926
static inline void os_host_main_loop_wait(int *timeout) { }
false
qemu
15455536df5ef652759ccf465d5e6f73acb493df
static inline void os_host_main_loop_wait(int *timeout) { }
{ "code": [], "line_no": [] }
static inline void FUNC_0(int *VAR_0) { }
[ "static inline void FUNC_0(int *VAR_0)\n{", "}" ]
[ 0, 0 ]
[ [ 1, 3 ], [ 5 ] ]
8,928
uint32_t HELPER(ucf64_get_fpscr)(CPUUniCore32State *env) { int i; uint32_t fpscr; fpscr = (env->ucf64.xregs[UC32_UCF64_FPSCR] & UCF64_FPSCR_MASK); i = get_float_exception_flags(&env->ucf64.fp_status); fpscr |= ucf64_exceptbits_from_host(i); return fpscr; }
false
qemu
e8ede0a8bb5298a6979bcf7ed84ef64a64a4e3fe
uint32_t HELPER(ucf64_get_fpscr)(CPUUniCore32State *env) { int i; uint32_t fpscr; fpscr = (env->ucf64.xregs[UC32_UCF64_FPSCR] & UCF64_FPSCR_MASK); i = get_float_exception_flags(&env->ucf64.fp_status); fpscr |= ucf64_exceptbits_from_host(i); return fpscr; }
{ "code": [], "line_no": [] }
uint32_t FUNC_0(ucf64_get_fpscr)(CPUUniCore32State *env) { int VAR_0; uint32_t fpscr; fpscr = (env->ucf64.xregs[UC32_UCF64_FPSCR] & UCF64_FPSCR_MASK); VAR_0 = get_float_exception_flags(&env->ucf64.fp_status); fpscr |= ucf64_exceptbits_from_host(VAR_0); return fpscr; }
[ "uint32_t FUNC_0(ucf64_get_fpscr)(CPUUniCore32State *env)\n{", "int VAR_0;", "uint32_t fpscr;", "fpscr = (env->ucf64.xregs[UC32_UCF64_FPSCR] & UCF64_FPSCR_MASK);", "VAR_0 = get_float_exception_flags(&env->ucf64.fp_status);", "fpscr |= ucf64_exceptbits_from_host(VAR_0);", "return fpscr;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
8,929
static int img_resize(int argc, char **argv) { int c, ret, relative; const char *filename, *fmt, *size; int64_t n, total_size; BlockDriverState *bs = NULL; QemuOpts *param; static QemuOptsList resize_options = { .name = "resize_options", .head = QTAILQ_HEAD_INITIALIZER(resize_options.head), .desc = { { .name = BLOCK_OPT_SIZE, .type = QEMU_OPT_SIZE, .help = "Virtual disk size" }, { /* end of list */ } }, }; /* Remove size from argv manually so that negative numbers are not treated * as options by getopt. */ if (argc < 3) { help(); return 1; } size = argv[--argc]; /* Parse getopt arguments */ fmt = NULL; for(;;) { c = getopt(argc, argv, "f:h"); if (c == -1) { break; } switch(c) { case '?': case 'h': help(); break; case 'f': fmt = optarg; break; } } if (optind >= argc) { help(); } filename = argv[optind++]; /* Choose grow, shrink, or absolute resize mode */ switch (size[0]) { case '+': relative = 1; size++; break; case '-': relative = -1; size++; break; default: relative = 0; break; } /* Parse size */ param = qemu_opts_create(&resize_options, NULL, 0, NULL); if (qemu_opt_set(param, BLOCK_OPT_SIZE, size)) { /* Error message already printed when size parsing fails */ ret = -1; qemu_opts_del(param); goto out; } n = qemu_opt_get_size(param, BLOCK_OPT_SIZE, 0); qemu_opts_del(param); bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_RDWR); if (!bs) { ret = -1; goto out; } if (relative) { total_size = bdrv_getlength(bs) + n * relative; } else { total_size = n; } if (total_size <= 0) { error_report("New image size must be positive"); ret = -1; goto out; } ret = bdrv_truncate(bs, total_size); switch (ret) { case 0: printf("Image resized.\n"); break; case -ENOTSUP: error_report("This image does not support resize"); break; case -EACCES: error_report("Image is read-only"); break; default: error_report("Error resizing image (%d)", -ret); break; } out: if (bs) { bdrv_delete(bs); } if (ret) { return 1; } return 0; }
false
qemu
f0536bb848ad6eb2709a7dc675f261bd160c751b
static int img_resize(int argc, char **argv) { int c, ret, relative; const char *filename, *fmt, *size; int64_t n, total_size; BlockDriverState *bs = NULL; QemuOpts *param; static QemuOptsList resize_options = { .name = "resize_options", .head = QTAILQ_HEAD_INITIALIZER(resize_options.head), .desc = { { .name = BLOCK_OPT_SIZE, .type = QEMU_OPT_SIZE, .help = "Virtual disk size" }, { } }, }; if (argc < 3) { help(); return 1; } size = argv[--argc]; fmt = NULL; for(;;) { c = getopt(argc, argv, "f:h"); if (c == -1) { break; } switch(c) { case '?': case 'h': help(); break; case 'f': fmt = optarg; break; } } if (optind >= argc) { help(); } filename = argv[optind++]; switch (size[0]) { case '+': relative = 1; size++; break; case '-': relative = -1; size++; break; default: relative = 0; break; } param = qemu_opts_create(&resize_options, NULL, 0, NULL); if (qemu_opt_set(param, BLOCK_OPT_SIZE, size)) { ret = -1; qemu_opts_del(param); goto out; } n = qemu_opt_get_size(param, BLOCK_OPT_SIZE, 0); qemu_opts_del(param); bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_RDWR); if (!bs) { ret = -1; goto out; } if (relative) { total_size = bdrv_getlength(bs) + n * relative; } else { total_size = n; } if (total_size <= 0) { error_report("New image size must be positive"); ret = -1; goto out; } ret = bdrv_truncate(bs, total_size); switch (ret) { case 0: printf("Image resized.\n"); break; case -ENOTSUP: error_report("This image does not support resize"); break; case -EACCES: error_report("Image is read-only"); break; default: error_report("Error resizing image (%d)", -ret); break; } out: if (bs) { bdrv_delete(bs); } if (ret) { return 1; } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(int VAR_0, char **VAR_1) { int VAR_2, VAR_3, VAR_4; const char *VAR_5, *VAR_6, *VAR_7; int64_t n, total_size; BlockDriverState *bs = NULL; QemuOpts *param; static QemuOptsList VAR_8 = { .name = "VAR_8", .head = QTAILQ_HEAD_INITIALIZER(VAR_8.head), .desc = { { .name = BLOCK_OPT_SIZE, .type = QEMU_OPT_SIZE, .help = "Virtual disk VAR_7" }, { } }, }; if (VAR_0 < 3) { help(); return 1; } VAR_7 = VAR_1[--VAR_0]; VAR_6 = NULL; for(;;) { VAR_2 = getopt(VAR_0, VAR_1, "f:h"); if (VAR_2 == -1) { break; } switch(VAR_2) { case '?': case 'h': help(); break; case 'f': VAR_6 = optarg; break; } } if (optind >= VAR_0) { help(); } VAR_5 = VAR_1[optind++]; switch (VAR_7[0]) { case '+': VAR_4 = 1; VAR_7++; break; case '-': VAR_4 = -1; VAR_7++; break; default: VAR_4 = 0; break; } param = qemu_opts_create(&VAR_8, NULL, 0, NULL); if (qemu_opt_set(param, BLOCK_OPT_SIZE, VAR_7)) { VAR_3 = -1; qemu_opts_del(param); goto out; } n = qemu_opt_get_size(param, BLOCK_OPT_SIZE, 0); qemu_opts_del(param); bs = bdrv_new_open(VAR_5, VAR_6, BDRV_O_FLAGS | BDRV_O_RDWR); if (!bs) { VAR_3 = -1; goto out; } if (VAR_4) { total_size = bdrv_getlength(bs) + n * VAR_4; } else { total_size = n; } if (total_size <= 0) { error_report("New image VAR_7 must be positive"); VAR_3 = -1; goto out; } VAR_3 = bdrv_truncate(bs, total_size); switch (VAR_3) { case 0: printf("Image resized.\n"); break; case -ENOTSUP: error_report("This image does not support resize"); break; case -EACCES: error_report("Image is read-only"); break; default: error_report("Error resizing image (%d)", -VAR_3); break; } out: if (bs) { bdrv_delete(bs); } if (VAR_3) { return 1; } return 0; }
[ "static int FUNC_0(int VAR_0, char **VAR_1)\n{", "int VAR_2, VAR_3, VAR_4;", "const char *VAR_5, *VAR_6, *VAR_7;", "int64_t n, total_size;", "BlockDriverState *bs = NULL;", "QemuOpts *param;", "static QemuOptsList VAR_8 = {", ".name = \"VAR_8\",\n.head = QTAILQ_HEAD_INITIALIZER(VAR_8.head),\n.desc = {", "{", ".name = BLOCK_OPT_SIZE,\n.type = QEMU_OPT_SIZE,\n.help = \"Virtual disk VAR_7\"\n}, {", "}", "},", "};", "if (VAR_0 < 3) {", "help();", "return 1;", "}", "VAR_7 = VAR_1[--VAR_0];", "VAR_6 = NULL;", "for(;;) {", "VAR_2 = getopt(VAR_0, VAR_1, \"f:h\");", "if (VAR_2 == -1) {", "break;", "}", "switch(VAR_2) {", "case '?':\ncase 'h':\nhelp();", "break;", "case 'f':\nVAR_6 = optarg;", "break;", "}", "}", "if (optind >= VAR_0) {", "help();", "}", "VAR_5 = VAR_1[optind++];", "switch (VAR_7[0]) {", "case '+':\nVAR_4 = 1;", "VAR_7++;", "break;", "case '-':\nVAR_4 = -1;", "VAR_7++;", "break;", "default:\nVAR_4 = 0;", "break;", "}", "param = qemu_opts_create(&VAR_8, NULL, 0, NULL);", "if (qemu_opt_set(param, BLOCK_OPT_SIZE, VAR_7)) {", "VAR_3 = -1;", "qemu_opts_del(param);", "goto out;", "}", "n = qemu_opt_get_size(param, BLOCK_OPT_SIZE, 0);", "qemu_opts_del(param);", "bs = bdrv_new_open(VAR_5, VAR_6, BDRV_O_FLAGS | BDRV_O_RDWR);", "if (!bs) {", "VAR_3 = -1;", "goto out;", "}", "if (VAR_4) {", "total_size = bdrv_getlength(bs) + n * VAR_4;", "} else {", "total_size = n;", "}", "if (total_size <= 0) {", "error_report(\"New image VAR_7 must be positive\");", "VAR_3 = -1;", "goto out;", "}", "VAR_3 = bdrv_truncate(bs, total_size);", "switch (VAR_3) {", "case 0:\nprintf(\"Image resized.\\n\");", "break;", "case -ENOTSUP:\nerror_report(\"This image does not support resize\");", "break;", "case -EACCES:\nerror_report(\"Image is read-only\");", "break;", "default:\nerror_report(\"Error resizing image (%d)\", -VAR_3);", "break;", "}", "out:\nif (bs) {", "bdrv_delete(bs);", "}", "if (VAR_3) {", "return 1;", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17, 19, 21 ], [ 23 ], [ 25, 27, 29, 31 ], [ 35 ], [ 37 ], [ 39 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77, 79, 81 ], [ 83 ], [ 85, 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 107 ], [ 109, 111 ], [ 113 ], [ 115 ], [ 117, 119 ], [ 121 ], [ 123 ], [ 125, 127 ], [ 129 ], [ 131 ], [ 137 ], [ 139 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 191 ], [ 193 ], [ 195, 197 ], [ 199 ], [ 201, 203 ], [ 205 ], [ 207, 209 ], [ 211 ], [ 213, 215 ], [ 217 ], [ 219 ], [ 221, 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ] ]
8,932
void dump_exec_info(FILE *f, fprintf_function cpu_fprintf) { int i, target_code_size, max_target_code_size; int direct_jmp_count, direct_jmp2_count, cross_page; TranslationBlock *tb; struct qht_stats hst; tb_lock(); if (!tcg_enabled()) { cpu_fprintf(f, "TCG not enabled\n"); return; } target_code_size = 0; max_target_code_size = 0; cross_page = 0; direct_jmp_count = 0; direct_jmp2_count = 0; for (i = 0; i < tcg_ctx.tb_ctx.nb_tbs; i++) { tb = tcg_ctx.tb_ctx.tbs[i]; target_code_size += tb->size; if (tb->size > max_target_code_size) { max_target_code_size = tb->size; } if (tb->page_addr[1] != -1) { cross_page++; } if (tb->jmp_reset_offset[0] != TB_JMP_RESET_OFFSET_INVALID) { direct_jmp_count++; if (tb->jmp_reset_offset[1] != TB_JMP_RESET_OFFSET_INVALID) { direct_jmp2_count++; } } } /* XXX: avoid using doubles ? */ cpu_fprintf(f, "Translation buffer state:\n"); cpu_fprintf(f, "gen code size %td/%zd\n", tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer, tcg_ctx.code_gen_highwater - tcg_ctx.code_gen_buffer); cpu_fprintf(f, "TB count %d\n", tcg_ctx.tb_ctx.nb_tbs); cpu_fprintf(f, "TB avg target size %d max=%d bytes\n", tcg_ctx.tb_ctx.nb_tbs ? target_code_size / tcg_ctx.tb_ctx.nb_tbs : 0, max_target_code_size); cpu_fprintf(f, "TB avg host size %td bytes (expansion ratio: %0.1f)\n", tcg_ctx.tb_ctx.nb_tbs ? (tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer) / tcg_ctx.tb_ctx.nb_tbs : 0, target_code_size ? (double) (tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer) / target_code_size : 0); cpu_fprintf(f, "cross page TB count %d (%d%%)\n", cross_page, tcg_ctx.tb_ctx.nb_tbs ? (cross_page * 100) / tcg_ctx.tb_ctx.nb_tbs : 0); cpu_fprintf(f, "direct jump count %d (%d%%) (2 jumps=%d %d%%)\n", direct_jmp_count, tcg_ctx.tb_ctx.nb_tbs ? (direct_jmp_count * 100) / tcg_ctx.tb_ctx.nb_tbs : 0, direct_jmp2_count, tcg_ctx.tb_ctx.nb_tbs ? (direct_jmp2_count * 100) / tcg_ctx.tb_ctx.nb_tbs : 0); qht_statistics_init(&tcg_ctx.tb_ctx.htable, &hst); print_qht_statistics(f, cpu_fprintf, hst); qht_statistics_destroy(&hst); cpu_fprintf(f, "\nStatistics:\n"); cpu_fprintf(f, "TB flush count %u\n", atomic_read(&tcg_ctx.tb_ctx.tb_flush_count)); cpu_fprintf(f, "TB invalidate count %d\n", tcg_ctx.tb_ctx.tb_phys_invalidate_count); cpu_fprintf(f, "TLB flush count %d\n", tlb_flush_count); tcg_dump_info(f, cpu_fprintf); tb_unlock(); }
false
qemu
d40d3da00c10f0169a26985ecb65033bff536f2c
void dump_exec_info(FILE *f, fprintf_function cpu_fprintf) { int i, target_code_size, max_target_code_size; int direct_jmp_count, direct_jmp2_count, cross_page; TranslationBlock *tb; struct qht_stats hst; tb_lock(); if (!tcg_enabled()) { cpu_fprintf(f, "TCG not enabled\n"); return; } target_code_size = 0; max_target_code_size = 0; cross_page = 0; direct_jmp_count = 0; direct_jmp2_count = 0; for (i = 0; i < tcg_ctx.tb_ctx.nb_tbs; i++) { tb = tcg_ctx.tb_ctx.tbs[i]; target_code_size += tb->size; if (tb->size > max_target_code_size) { max_target_code_size = tb->size; } if (tb->page_addr[1] != -1) { cross_page++; } if (tb->jmp_reset_offset[0] != TB_JMP_RESET_OFFSET_INVALID) { direct_jmp_count++; if (tb->jmp_reset_offset[1] != TB_JMP_RESET_OFFSET_INVALID) { direct_jmp2_count++; } } } cpu_fprintf(f, "Translation buffer state:\n"); cpu_fprintf(f, "gen code size %td/%zd\n", tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer, tcg_ctx.code_gen_highwater - tcg_ctx.code_gen_buffer); cpu_fprintf(f, "TB count %d\n", tcg_ctx.tb_ctx.nb_tbs); cpu_fprintf(f, "TB avg target size %d max=%d bytes\n", tcg_ctx.tb_ctx.nb_tbs ? target_code_size / tcg_ctx.tb_ctx.nb_tbs : 0, max_target_code_size); cpu_fprintf(f, "TB avg host size %td bytes (expansion ratio: %0.1f)\n", tcg_ctx.tb_ctx.nb_tbs ? (tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer) / tcg_ctx.tb_ctx.nb_tbs : 0, target_code_size ? (double) (tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer) / target_code_size : 0); cpu_fprintf(f, "cross page TB count %d (%d%%)\n", cross_page, tcg_ctx.tb_ctx.nb_tbs ? (cross_page * 100) / tcg_ctx.tb_ctx.nb_tbs : 0); cpu_fprintf(f, "direct jump count %d (%d%%) (2 jumps=%d %d%%)\n", direct_jmp_count, tcg_ctx.tb_ctx.nb_tbs ? (direct_jmp_count * 100) / tcg_ctx.tb_ctx.nb_tbs : 0, direct_jmp2_count, tcg_ctx.tb_ctx.nb_tbs ? (direct_jmp2_count * 100) / tcg_ctx.tb_ctx.nb_tbs : 0); qht_statistics_init(&tcg_ctx.tb_ctx.htable, &hst); print_qht_statistics(f, cpu_fprintf, hst); qht_statistics_destroy(&hst); cpu_fprintf(f, "\nStatistics:\n"); cpu_fprintf(f, "TB flush count %u\n", atomic_read(&tcg_ctx.tb_ctx.tb_flush_count)); cpu_fprintf(f, "TB invalidate count %d\n", tcg_ctx.tb_ctx.tb_phys_invalidate_count); cpu_fprintf(f, "TLB flush count %d\n", tlb_flush_count); tcg_dump_info(f, cpu_fprintf); tb_unlock(); }
{ "code": [], "line_no": [] }
void FUNC_0(FILE *VAR_0, fprintf_function VAR_1) { int VAR_2, VAR_3, VAR_4; int VAR_5, VAR_6, VAR_7; TranslationBlock *tb; struct qht_stats VAR_8; tb_lock(); if (!tcg_enabled()) { VAR_1(VAR_0, "TCG not enabled\n"); return; } VAR_3 = 0; VAR_4 = 0; VAR_7 = 0; VAR_5 = 0; VAR_6 = 0; for (VAR_2 = 0; VAR_2 < tcg_ctx.tb_ctx.nb_tbs; VAR_2++) { tb = tcg_ctx.tb_ctx.tbs[VAR_2]; VAR_3 += tb->size; if (tb->size > VAR_4) { VAR_4 = tb->size; } if (tb->page_addr[1] != -1) { VAR_7++; } if (tb->jmp_reset_offset[0] != TB_JMP_RESET_OFFSET_INVALID) { VAR_5++; if (tb->jmp_reset_offset[1] != TB_JMP_RESET_OFFSET_INVALID) { VAR_6++; } } } VAR_1(VAR_0, "Translation buffer state:\n"); VAR_1(VAR_0, "gen code size %td/%zd\n", tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer, tcg_ctx.code_gen_highwater - tcg_ctx.code_gen_buffer); VAR_1(VAR_0, "TB count %d\n", tcg_ctx.tb_ctx.nb_tbs); VAR_1(VAR_0, "TB avg target size %d max=%d bytes\n", tcg_ctx.tb_ctx.nb_tbs ? VAR_3 / tcg_ctx.tb_ctx.nb_tbs : 0, VAR_4); VAR_1(VAR_0, "TB avg host size %td bytes (expansion ratio: %0.1f)\n", tcg_ctx.tb_ctx.nb_tbs ? (tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer) / tcg_ctx.tb_ctx.nb_tbs : 0, VAR_3 ? (double) (tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer) / VAR_3 : 0); VAR_1(VAR_0, "cross page TB count %d (%d%%)\n", VAR_7, tcg_ctx.tb_ctx.nb_tbs ? (VAR_7 * 100) / tcg_ctx.tb_ctx.nb_tbs : 0); VAR_1(VAR_0, "direct jump count %d (%d%%) (2 jumps=%d %d%%)\n", VAR_5, tcg_ctx.tb_ctx.nb_tbs ? (VAR_5 * 100) / tcg_ctx.tb_ctx.nb_tbs : 0, VAR_6, tcg_ctx.tb_ctx.nb_tbs ? (VAR_6 * 100) / tcg_ctx.tb_ctx.nb_tbs : 0); qht_statistics_init(&tcg_ctx.tb_ctx.htable, &VAR_8); print_qht_statistics(VAR_0, VAR_1, VAR_8); qht_statistics_destroy(&VAR_8); VAR_1(VAR_0, "\nStatistics:\n"); VAR_1(VAR_0, "TB flush count %u\n", atomic_read(&tcg_ctx.tb_ctx.tb_flush_count)); VAR_1(VAR_0, "TB invalidate count %d\n", tcg_ctx.tb_ctx.tb_phys_invalidate_count); VAR_1(VAR_0, "TLB flush count %d\n", tlb_flush_count); tcg_dump_info(VAR_0, VAR_1); tb_unlock(); }
[ "void FUNC_0(FILE *VAR_0, fprintf_function VAR_1)\n{", "int VAR_2, VAR_3, VAR_4;", "int VAR_5, VAR_6, VAR_7;", "TranslationBlock *tb;", "struct qht_stats VAR_8;", "tb_lock();", "if (!tcg_enabled()) {", "VAR_1(VAR_0, \"TCG not enabled\\n\");", "return;", "}", "VAR_3 = 0;", "VAR_4 = 0;", "VAR_7 = 0;", "VAR_5 = 0;", "VAR_6 = 0;", "for (VAR_2 = 0; VAR_2 < tcg_ctx.tb_ctx.nb_tbs; VAR_2++) {", "tb = tcg_ctx.tb_ctx.tbs[VAR_2];", "VAR_3 += tb->size;", "if (tb->size > VAR_4) {", "VAR_4 = tb->size;", "}", "if (tb->page_addr[1] != -1) {", "VAR_7++;", "}", "if (tb->jmp_reset_offset[0] != TB_JMP_RESET_OFFSET_INVALID) {", "VAR_5++;", "if (tb->jmp_reset_offset[1] != TB_JMP_RESET_OFFSET_INVALID) {", "VAR_6++;", "}", "}", "}", "VAR_1(VAR_0, \"Translation buffer state:\\n\");", "VAR_1(VAR_0, \"gen code size %td/%zd\\n\",\ntcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer,\ntcg_ctx.code_gen_highwater - tcg_ctx.code_gen_buffer);", "VAR_1(VAR_0, \"TB count %d\\n\", tcg_ctx.tb_ctx.nb_tbs);", "VAR_1(VAR_0, \"TB avg target size %d max=%d bytes\\n\",\ntcg_ctx.tb_ctx.nb_tbs ? VAR_3 /\ntcg_ctx.tb_ctx.nb_tbs : 0,\nVAR_4);", "VAR_1(VAR_0, \"TB avg host size %td bytes (expansion ratio: %0.1f)\\n\",\ntcg_ctx.tb_ctx.nb_tbs ? (tcg_ctx.code_gen_ptr -\ntcg_ctx.code_gen_buffer) /\ntcg_ctx.tb_ctx.nb_tbs : 0,\nVAR_3 ? (double) (tcg_ctx.code_gen_ptr -\ntcg_ctx.code_gen_buffer) /\nVAR_3 : 0);", "VAR_1(VAR_0, \"cross page TB count %d (%d%%)\\n\", VAR_7,\ntcg_ctx.tb_ctx.nb_tbs ? (VAR_7 * 100) /\ntcg_ctx.tb_ctx.nb_tbs : 0);", "VAR_1(VAR_0, \"direct jump count %d (%d%%) (2 jumps=%d %d%%)\\n\",\nVAR_5,\ntcg_ctx.tb_ctx.nb_tbs ? (VAR_5 * 100) /\ntcg_ctx.tb_ctx.nb_tbs : 0,\nVAR_6,\ntcg_ctx.tb_ctx.nb_tbs ? (VAR_6 * 100) /\ntcg_ctx.tb_ctx.nb_tbs : 0);", "qht_statistics_init(&tcg_ctx.tb_ctx.htable, &VAR_8);", "print_qht_statistics(VAR_0, VAR_1, VAR_8);", "qht_statistics_destroy(&VAR_8);", "VAR_1(VAR_0, \"\\nStatistics:\\n\");", "VAR_1(VAR_0, \"TB flush count %u\\n\",\natomic_read(&tcg_ctx.tb_ctx.tb_flush_count));", "VAR_1(VAR_0, \"TB invalidate count %d\\n\",\ntcg_ctx.tb_ctx.tb_phys_invalidate_count);", "VAR_1(VAR_0, \"TLB flush count %d\\n\", tlb_flush_count);", "tcg_dump_info(VAR_0, VAR_1);", "tb_unlock();", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 73 ], [ 75, 77, 79 ], [ 81 ], [ 83, 85, 87, 89 ], [ 91, 93, 95, 97, 99, 101, 103 ], [ 105, 107, 109 ], [ 111, 113, 115, 117, 119, 121, 123 ], [ 127 ], [ 129 ], [ 131 ], [ 135 ], [ 137, 139 ], [ 141, 143 ], [ 145 ], [ 147 ], [ 151 ], [ 153 ] ]
8,933
build_fadt(GArray *table_data, BIOSLinker *linker, AcpiPmInfo *pm, unsigned facs, unsigned dsdt, const char *oem_id, const char *oem_table_id) { AcpiFadtDescriptorRev1 *fadt = acpi_data_push(table_data, sizeof(*fadt)); fadt->firmware_ctrl = cpu_to_le32(facs); /* FACS address to be filled by Guest linker */ bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, ACPI_BUILD_TABLE_FILE, &fadt->firmware_ctrl, sizeof fadt->firmware_ctrl); fadt->dsdt = cpu_to_le32(dsdt); /* DSDT address to be filled by Guest linker */ bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, ACPI_BUILD_TABLE_FILE, &fadt->dsdt, sizeof fadt->dsdt); fadt_setup(fadt, pm); build_header(linker, table_data, (void *)fadt, "FACP", sizeof(*fadt), 1, oem_id, oem_table_id); }
false
qemu
4678124bb9bfb49e93b83f95c4d2feeb443ea38b
build_fadt(GArray *table_data, BIOSLinker *linker, AcpiPmInfo *pm, unsigned facs, unsigned dsdt, const char *oem_id, const char *oem_table_id) { AcpiFadtDescriptorRev1 *fadt = acpi_data_push(table_data, sizeof(*fadt)); fadt->firmware_ctrl = cpu_to_le32(facs); bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, ACPI_BUILD_TABLE_FILE, &fadt->firmware_ctrl, sizeof fadt->firmware_ctrl); fadt->dsdt = cpu_to_le32(dsdt); bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, ACPI_BUILD_TABLE_FILE, &fadt->dsdt, sizeof fadt->dsdt); fadt_setup(fadt, pm); build_header(linker, table_data, (void *)fadt, "FACP", sizeof(*fadt), 1, oem_id, oem_table_id); }
{ "code": [], "line_no": [] }
FUNC_0(GArray *VAR_0, BIOSLinker *VAR_1, AcpiPmInfo *VAR_2, unsigned VAR_3, unsigned VAR_4, const char *VAR_5, const char *VAR_6) { AcpiFadtDescriptorRev1 *fadt = acpi_data_push(VAR_0, sizeof(*fadt)); fadt->firmware_ctrl = cpu_to_le32(VAR_3); bios_linker_loader_add_pointer(VAR_1, ACPI_BUILD_TABLE_FILE, ACPI_BUILD_TABLE_FILE, &fadt->firmware_ctrl, sizeof fadt->firmware_ctrl); fadt->VAR_4 = cpu_to_le32(VAR_4); bios_linker_loader_add_pointer(VAR_1, ACPI_BUILD_TABLE_FILE, ACPI_BUILD_TABLE_FILE, &fadt->VAR_4, sizeof fadt->VAR_4); fadt_setup(fadt, VAR_2); build_header(VAR_1, VAR_0, (void *)fadt, "FACP", sizeof(*fadt), 1, VAR_5, VAR_6); }
[ "FUNC_0(GArray *VAR_0, BIOSLinker *VAR_1, AcpiPmInfo *VAR_2,\nunsigned VAR_3, unsigned VAR_4,\nconst char *VAR_5, const char *VAR_6)\n{", "AcpiFadtDescriptorRev1 *fadt = acpi_data_push(VAR_0, sizeof(*fadt));", "fadt->firmware_ctrl = cpu_to_le32(VAR_3);", "bios_linker_loader_add_pointer(VAR_1, ACPI_BUILD_TABLE_FILE,\nACPI_BUILD_TABLE_FILE,\n&fadt->firmware_ctrl,\nsizeof fadt->firmware_ctrl);", "fadt->VAR_4 = cpu_to_le32(VAR_4);", "bios_linker_loader_add_pointer(VAR_1, ACPI_BUILD_TABLE_FILE,\nACPI_BUILD_TABLE_FILE,\n&fadt->VAR_4,\nsizeof fadt->VAR_4);", "fadt_setup(fadt, VAR_2);", "build_header(VAR_1, VAR_0,\n(void *)fadt, \"FACP\", sizeof(*fadt), 1, VAR_5, VAR_6);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 13 ], [ 17, 19, 21, 23 ], [ 27 ], [ 31, 33, 35, 37 ], [ 41 ], [ 45, 47 ], [ 49 ] ]
8,934
void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, int is_write, int is_user, uintptr_t retaddr) { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; int target_el; bool same_el; if (retaddr) { /* now we have a real cpu fault */ cpu_restore_state(cs, retaddr); } target_el = exception_target_el(env); same_el = (arm_current_el(env) == target_el); env->exception.vaddress = vaddr; /* the DFSR for an alignment fault depends on whether we're using * the LPAE long descriptor format, or the short descriptor format */ if (arm_regime_using_lpae_format(env, cpu_mmu_index(env, false))) { env->exception.fsr = 0x21; } else { env->exception.fsr = 0x1; } if (is_write == 1 && arm_feature(env, ARM_FEATURE_V6)) { env->exception.fsr |= (1 << 11); } raise_exception(env, EXCP_DATA_ABORT, syn_data_abort(same_el, 0, 0, 0, is_write == 1, 0x21), target_el); }
false
qemu
deb2db996cbb9470b39ae1e383791ef34c4eb3c2
void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, int is_write, int is_user, uintptr_t retaddr) { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; int target_el; bool same_el; if (retaddr) { cpu_restore_state(cs, retaddr); } target_el = exception_target_el(env); same_el = (arm_current_el(env) == target_el); env->exception.vaddress = vaddr; if (arm_regime_using_lpae_format(env, cpu_mmu_index(env, false))) { env->exception.fsr = 0x21; } else { env->exception.fsr = 0x1; } if (is_write == 1 && arm_feature(env, ARM_FEATURE_V6)) { env->exception.fsr |= (1 << 11); } raise_exception(env, EXCP_DATA_ABORT, syn_data_abort(same_el, 0, 0, 0, is_write == 1, 0x21), target_el); }
{ "code": [], "line_no": [] }
void FUNC_0(CPUState *VAR_0, VAR_1 VAR_1, int VAR_2, int VAR_3, uintptr_t VAR_4) { ARMCPU *cpu = ARM_CPU(VAR_0); CPUARMState *env = &cpu->env; int VAR_5; bool same_el; if (VAR_4) { cpu_restore_state(VAR_0, VAR_4); } VAR_5 = exception_target_el(env); same_el = (arm_current_el(env) == VAR_5); env->exception.vaddress = VAR_1; if (arm_regime_using_lpae_format(env, cpu_mmu_index(env, false))) { env->exception.fsr = 0x21; } else { env->exception.fsr = 0x1; } if (VAR_2 == 1 && arm_feature(env, ARM_FEATURE_V6)) { env->exception.fsr |= (1 << 11); } raise_exception(env, EXCP_DATA_ABORT, syn_data_abort(same_el, 0, 0, 0, VAR_2 == 1, 0x21), VAR_5); }
[ "void FUNC_0(CPUState *VAR_0, VAR_1 VAR_1, int VAR_2,\nint VAR_3, uintptr_t VAR_4)\n{", "ARMCPU *cpu = ARM_CPU(VAR_0);", "CPUARMState *env = &cpu->env;", "int VAR_5;", "bool same_el;", "if (VAR_4) {", "cpu_restore_state(VAR_0, VAR_4);", "}", "VAR_5 = exception_target_el(env);", "same_el = (arm_current_el(env) == VAR_5);", "env->exception.vaddress = VAR_1;", "if (arm_regime_using_lpae_format(env, cpu_mmu_index(env, false))) {", "env->exception.fsr = 0x21;", "} else {", "env->exception.fsr = 0x1;", "}", "if (VAR_2 == 1 && arm_feature(env, ARM_FEATURE_V6)) {", "env->exception.fsr |= (1 << 11);", "}", "raise_exception(env, EXCP_DATA_ABORT,\nsyn_data_abort(same_el, 0, 0, 0, VAR_2 == 1, 0x21),\nVAR_5);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 33 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 63, 65, 67 ], [ 69 ] ]
8,935
static void flash_sync_page(Flash *s, int page) { int bdrv_sector, nb_sectors; QEMUIOVector iov; if (!s->bdrv || bdrv_is_read_only(s->bdrv)) { return; } bdrv_sector = (page * s->pi->page_size) / BDRV_SECTOR_SIZE; nb_sectors = DIV_ROUND_UP(s->pi->page_size, BDRV_SECTOR_SIZE); qemu_iovec_init(&iov, 1); qemu_iovec_add(&iov, s->storage + bdrv_sector * BDRV_SECTOR_SIZE, nb_sectors * BDRV_SECTOR_SIZE); bdrv_aio_writev(s->bdrv, bdrv_sector, &iov, nb_sectors, bdrv_sync_complete, NULL); }
false
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
static void flash_sync_page(Flash *s, int page) { int bdrv_sector, nb_sectors; QEMUIOVector iov; if (!s->bdrv || bdrv_is_read_only(s->bdrv)) { return; } bdrv_sector = (page * s->pi->page_size) / BDRV_SECTOR_SIZE; nb_sectors = DIV_ROUND_UP(s->pi->page_size, BDRV_SECTOR_SIZE); qemu_iovec_init(&iov, 1); qemu_iovec_add(&iov, s->storage + bdrv_sector * BDRV_SECTOR_SIZE, nb_sectors * BDRV_SECTOR_SIZE); bdrv_aio_writev(s->bdrv, bdrv_sector, &iov, nb_sectors, bdrv_sync_complete, NULL); }
{ "code": [], "line_no": [] }
static void FUNC_0(Flash *VAR_0, int VAR_1) { int VAR_2, VAR_3; QEMUIOVector iov; if (!VAR_0->bdrv || bdrv_is_read_only(VAR_0->bdrv)) { return; } VAR_2 = (VAR_1 * VAR_0->pi->page_size) / BDRV_SECTOR_SIZE; VAR_3 = DIV_ROUND_UP(VAR_0->pi->page_size, BDRV_SECTOR_SIZE); qemu_iovec_init(&iov, 1); qemu_iovec_add(&iov, VAR_0->storage + VAR_2 * BDRV_SECTOR_SIZE, VAR_3 * BDRV_SECTOR_SIZE); bdrv_aio_writev(VAR_0->bdrv, VAR_2, &iov, VAR_3, bdrv_sync_complete, NULL); }
[ "static void FUNC_0(Flash *VAR_0, int VAR_1)\n{", "int VAR_2, VAR_3;", "QEMUIOVector iov;", "if (!VAR_0->bdrv || bdrv_is_read_only(VAR_0->bdrv)) {", "return;", "}", "VAR_2 = (VAR_1 * VAR_0->pi->page_size) / BDRV_SECTOR_SIZE;", "VAR_3 = DIV_ROUND_UP(VAR_0->pi->page_size, BDRV_SECTOR_SIZE);", "qemu_iovec_init(&iov, 1);", "qemu_iovec_add(&iov, VAR_0->storage + VAR_2 * BDRV_SECTOR_SIZE,\nVAR_3 * BDRV_SECTOR_SIZE);", "bdrv_aio_writev(VAR_0->bdrv, VAR_2, &iov, VAR_3, bdrv_sync_complete,\nNULL);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 29, 31 ], [ 33 ] ]
8,936
static int proxy_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat *stbuf) { int retval; retval = v9fs_request(fs_ctx->private, T_LSTAT, stbuf, "s", fs_path); if (retval < 0) { errno = -retval; return -1; } return retval; }
false
qemu
494a8ebe713055d3946183f4b395f85a18b43e9e
static int proxy_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat *stbuf) { int retval; retval = v9fs_request(fs_ctx->private, T_LSTAT, stbuf, "s", fs_path); if (retval < 0) { errno = -retval; return -1; } return retval; }
{ "code": [], "line_no": [] }
static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1, struct stat *VAR_2) { int VAR_3; VAR_3 = v9fs_request(VAR_0->private, T_LSTAT, VAR_2, "s", VAR_1); if (VAR_3 < 0) { errno = -VAR_3; return -1; } return VAR_3; }
[ "static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1, struct stat *VAR_2)\n{", "int VAR_3;", "VAR_3 = v9fs_request(VAR_0->private, T_LSTAT, VAR_2, \"s\", VAR_1);", "if (VAR_3 < 0) {", "errno = -VAR_3;", "return -1;", "}", "return VAR_3;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
8,937
void bios_linker_loader_add_checksum(GArray *linker, const char *file, GArray *table, void *start, unsigned size, uint8_t *checksum) { BiosLinkerLoaderEntry entry; ptrdiff_t checksum_offset = (gchar *)checksum - table->data; ptrdiff_t start_offset = (gchar *)start - table->data; assert(checksum_offset >= 0); assert(start_offset >= 0); assert(checksum_offset + 1 <= table->len); assert(start_offset + size <= table->len); assert(*checksum == 0x0); memset(&entry, 0, sizeof entry); strncpy(entry.cksum.file, file, sizeof entry.cksum.file - 1); entry.command = cpu_to_le32(BIOS_LINKER_LOADER_COMMAND_ADD_CHECKSUM); entry.cksum.offset = cpu_to_le32(checksum_offset); entry.cksum.start = cpu_to_le32(start_offset); entry.cksum.length = cpu_to_le32(size); g_array_append_vals(linker, &entry, sizeof entry); }
false
qemu
0e9b9edae7bebfd31fdbead4ccbbce03876a7edd
void bios_linker_loader_add_checksum(GArray *linker, const char *file, GArray *table, void *start, unsigned size, uint8_t *checksum) { BiosLinkerLoaderEntry entry; ptrdiff_t checksum_offset = (gchar *)checksum - table->data; ptrdiff_t start_offset = (gchar *)start - table->data; assert(checksum_offset >= 0); assert(start_offset >= 0); assert(checksum_offset + 1 <= table->len); assert(start_offset + size <= table->len); assert(*checksum == 0x0); memset(&entry, 0, sizeof entry); strncpy(entry.cksum.file, file, sizeof entry.cksum.file - 1); entry.command = cpu_to_le32(BIOS_LINKER_LOADER_COMMAND_ADD_CHECKSUM); entry.cksum.offset = cpu_to_le32(checksum_offset); entry.cksum.start = cpu_to_le32(start_offset); entry.cksum.length = cpu_to_le32(size); g_array_append_vals(linker, &entry, sizeof entry); }
{ "code": [], "line_no": [] }
void FUNC_0(GArray *VAR_0, const char *VAR_1, GArray *VAR_2, void *VAR_3, unsigned VAR_4, uint8_t *VAR_5) { BiosLinkerLoaderEntry entry; ptrdiff_t checksum_offset = (gchar *)VAR_5 - VAR_2->data; ptrdiff_t start_offset = (gchar *)VAR_3 - VAR_2->data; assert(checksum_offset >= 0); assert(start_offset >= 0); assert(checksum_offset + 1 <= VAR_2->len); assert(start_offset + VAR_4 <= VAR_2->len); assert(*VAR_5 == 0x0); memset(&entry, 0, sizeof entry); strncpy(entry.cksum.VAR_1, VAR_1, sizeof entry.cksum.VAR_1 - 1); entry.command = cpu_to_le32(BIOS_LINKER_LOADER_COMMAND_ADD_CHECKSUM); entry.cksum.offset = cpu_to_le32(checksum_offset); entry.cksum.VAR_3 = cpu_to_le32(start_offset); entry.cksum.length = cpu_to_le32(VAR_4); g_array_append_vals(VAR_0, &entry, sizeof entry); }
[ "void FUNC_0(GArray *VAR_0, const char *VAR_1,\nGArray *VAR_2,\nvoid *VAR_3, unsigned VAR_4,\nuint8_t *VAR_5)\n{", "BiosLinkerLoaderEntry entry;", "ptrdiff_t checksum_offset = (gchar *)VAR_5 - VAR_2->data;", "ptrdiff_t start_offset = (gchar *)VAR_3 - VAR_2->data;", "assert(checksum_offset >= 0);", "assert(start_offset >= 0);", "assert(checksum_offset + 1 <= VAR_2->len);", "assert(start_offset + VAR_4 <= VAR_2->len);", "assert(*VAR_5 == 0x0);", "memset(&entry, 0, sizeof entry);", "strncpy(entry.cksum.VAR_1, VAR_1, sizeof entry.cksum.VAR_1 - 1);", "entry.command = cpu_to_le32(BIOS_LINKER_LOADER_COMMAND_ADD_CHECKSUM);", "entry.cksum.offset = cpu_to_le32(checksum_offset);", "entry.cksum.VAR_3 = cpu_to_le32(start_offset);", "entry.cksum.length = cpu_to_le32(VAR_4);", "g_array_append_vals(VAR_0, &entry, sizeof entry);", "}" ]
[ 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 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ] ]
8,938
void backup_do_checkpoint(BlockJob *job, Error **errp) { BackupBlockJob *backup_job = container_of(job, BackupBlockJob, common); int64_t len; assert(job->driver->job_type == BLOCK_JOB_TYPE_BACKUP); if (backup_job->sync_mode != MIRROR_SYNC_MODE_NONE) { error_setg(errp, "The backup job only supports block checkpoint in" " sync=none mode"); return; } len = DIV_ROUND_UP(backup_job->common.len, backup_job->cluster_size); bitmap_zero(backup_job->done_bitmap, len); }
false
qemu
a193b0f0a8d7735f4eb2ff863fd0902a5fa5eec6
void backup_do_checkpoint(BlockJob *job, Error **errp) { BackupBlockJob *backup_job = container_of(job, BackupBlockJob, common); int64_t len; assert(job->driver->job_type == BLOCK_JOB_TYPE_BACKUP); if (backup_job->sync_mode != MIRROR_SYNC_MODE_NONE) { error_setg(errp, "The backup job only supports block checkpoint in" " sync=none mode"); return; } len = DIV_ROUND_UP(backup_job->common.len, backup_job->cluster_size); bitmap_zero(backup_job->done_bitmap, len); }
{ "code": [], "line_no": [] }
void FUNC_0(BlockJob *VAR_0, Error **VAR_1) { BackupBlockJob *backup_job = container_of(VAR_0, BackupBlockJob, common); int64_t len; assert(VAR_0->driver->job_type == BLOCK_JOB_TYPE_BACKUP); if (backup_job->sync_mode != MIRROR_SYNC_MODE_NONE) { error_setg(VAR_1, "The backup VAR_0 only supports block checkpoint in" " sync=none mode"); return; } len = DIV_ROUND_UP(backup_job->common.len, backup_job->cluster_size); bitmap_zero(backup_job->done_bitmap, len); }
[ "void FUNC_0(BlockJob *VAR_0, Error **VAR_1)\n{", "BackupBlockJob *backup_job = container_of(VAR_0, BackupBlockJob, common);", "int64_t len;", "assert(VAR_0->driver->job_type == BLOCK_JOB_TYPE_BACKUP);", "if (backup_job->sync_mode != MIRROR_SYNC_MODE_NONE) {", "error_setg(VAR_1, \"The backup VAR_0 only supports block checkpoint in\"\n\" sync=none mode\");", "return;", "}", "len = DIV_ROUND_UP(backup_job->common.len, backup_job->cluster_size);", "bitmap_zero(backup_job->done_bitmap, len);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 15 ], [ 17, 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ] ]
8,939
int floatx80_is_nan( floatx80 a1 ) { floatx80u u; u.f = a1; return ( ( u.i.high & 0x7FFF ) == 0x7FFF ) && (bits64) ( u.i.low<<1 ); }
false
qemu
185698715dfb18c82ad2a5dbc169908602d43e81
int floatx80_is_nan( floatx80 a1 ) { floatx80u u; u.f = a1; return ( ( u.i.high & 0x7FFF ) == 0x7FFF ) && (bits64) ( u.i.low<<1 ); }
{ "code": [], "line_no": [] }
int FUNC_0( floatx80 VAR_0 ) { floatx80u u; u.f = VAR_0; return ( ( u.i.high & 0x7FFF ) == 0x7FFF ) && (bits64) ( u.i.low<<1 ); }
[ "int FUNC_0( floatx80 VAR_0 )\n{", "floatx80u u;", "u.f = VAR_0;", "return ( ( u.i.high & 0x7FFF ) == 0x7FFF ) && (bits64) ( u.i.low<<1 );", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ] ]
8,940
static void taihu_cpld_writel (void *opaque, hwaddr addr, uint32_t value) { taihu_cpld_writel(opaque, addr, (value >> 24) & 0xFF); taihu_cpld_writel(opaque, addr + 1, (value >> 16) & 0xFF); taihu_cpld_writel(opaque, addr + 2, (value >> 8) & 0xFF); taihu_cpld_writeb(opaque, addr + 3, value & 0xFF); }
false
qemu
e2a176dfda32f5cf80703c2921a19fe75850c38c
static void taihu_cpld_writel (void *opaque, hwaddr addr, uint32_t value) { taihu_cpld_writel(opaque, addr, (value >> 24) & 0xFF); taihu_cpld_writel(opaque, addr + 1, (value >> 16) & 0xFF); taihu_cpld_writel(opaque, addr + 2, (value >> 8) & 0xFF); taihu_cpld_writeb(opaque, addr + 3, value & 0xFF); }
{ "code": [], "line_no": [] }
static void FUNC_0 (void *VAR_0, hwaddr VAR_1, uint32_t VAR_2) { FUNC_0(VAR_0, VAR_1, (VAR_2 >> 24) & 0xFF); FUNC_0(VAR_0, VAR_1 + 1, (VAR_2 >> 16) & 0xFF); FUNC_0(VAR_0, VAR_1 + 2, (VAR_2 >> 8) & 0xFF); taihu_cpld_writeb(VAR_0, VAR_1 + 3, VAR_2 & 0xFF); }
[ "static void FUNC_0 (void *VAR_0,\nhwaddr VAR_1, uint32_t VAR_2)\n{", "FUNC_0(VAR_0, VAR_1, (VAR_2 >> 24) & 0xFF);", "FUNC_0(VAR_0, VAR_1 + 1, (VAR_2 >> 16) & 0xFF);", "FUNC_0(VAR_0, VAR_1 + 2, (VAR_2 >> 8) & 0xFF);", "taihu_cpld_writeb(VAR_0, VAR_1 + 3, VAR_2 & 0xFF);", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ] ]
8,941
static int mov_write_stts_tag(AVIOContext *pb, MOVTrack *track) { MOVStts *stts_entries; uint32_t entries = -1; uint32_t atom_size; int i; if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO && !track->audio_vbr) { stts_entries = av_malloc(sizeof(*stts_entries)); /* one entry */ if (!stts_entries) return AVERROR(ENOMEM); stts_entries[0].count = track->sample_count; stts_entries[0].duration = 1; entries = 1; } else { stts_entries = track->entry ? av_malloc_array(track->entry, sizeof(*stts_entries)) : /* worst case */ NULL; if (!stts_entries) return AVERROR(ENOMEM); for (i = 0; i < track->entry; i++) { int duration = get_cluster_duration(track, i); if (i && duration == stts_entries[entries].duration) { stts_entries[entries].count++; /* compress */ } else { entries++; stts_entries[entries].duration = duration; stts_entries[entries].count = 1; } } entries++; /* last one */ } atom_size = 16 + (entries * 8); avio_wb32(pb, atom_size); /* size */ ffio_wfourcc(pb, "stts"); avio_wb32(pb, 0); /* version & flags */ avio_wb32(pb, entries); /* entry count */ for (i = 0; i < entries; i++) { avio_wb32(pb, stts_entries[i].count); avio_wb32(pb, stts_entries[i].duration); } av_free(stts_entries); return atom_size; }
false
FFmpeg
95165f7c1b533c121b890fa1e82e8ed596cfc108
static int mov_write_stts_tag(AVIOContext *pb, MOVTrack *track) { MOVStts *stts_entries; uint32_t entries = -1; uint32_t atom_size; int i; if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO && !track->audio_vbr) { stts_entries = av_malloc(sizeof(*stts_entries)); if (!stts_entries) return AVERROR(ENOMEM); stts_entries[0].count = track->sample_count; stts_entries[0].duration = 1; entries = 1; } else { stts_entries = track->entry ? av_malloc_array(track->entry, sizeof(*stts_entries)) : NULL; if (!stts_entries) return AVERROR(ENOMEM); for (i = 0; i < track->entry; i++) { int duration = get_cluster_duration(track, i); if (i && duration == stts_entries[entries].duration) { stts_entries[entries].count++; } else { entries++; stts_entries[entries].duration = duration; stts_entries[entries].count = 1; } } entries++; } atom_size = 16 + (entries * 8); avio_wb32(pb, atom_size); ffio_wfourcc(pb, "stts"); avio_wb32(pb, 0); avio_wb32(pb, entries); for (i = 0; i < entries; i++) { avio_wb32(pb, stts_entries[i].count); avio_wb32(pb, stts_entries[i].duration); } av_free(stts_entries); return atom_size; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVIOContext *VAR_0, MOVTrack *VAR_1) { MOVStts *stts_entries; uint32_t entries = -1; uint32_t atom_size; int VAR_2; if (VAR_1->enc->codec_type == AVMEDIA_TYPE_AUDIO && !VAR_1->audio_vbr) { stts_entries = av_malloc(sizeof(*stts_entries)); if (!stts_entries) return AVERROR(ENOMEM); stts_entries[0].count = VAR_1->sample_count; stts_entries[0].duration = 1; entries = 1; } else { stts_entries = VAR_1->entry ? av_malloc_array(VAR_1->entry, sizeof(*stts_entries)) : NULL; if (!stts_entries) return AVERROR(ENOMEM); for (VAR_2 = 0; VAR_2 < VAR_1->entry; VAR_2++) { int duration = get_cluster_duration(VAR_1, VAR_2); if (VAR_2 && duration == stts_entries[entries].duration) { stts_entries[entries].count++; } else { entries++; stts_entries[entries].duration = duration; stts_entries[entries].count = 1; } } entries++; } atom_size = 16 + (entries * 8); avio_wb32(VAR_0, atom_size); ffio_wfourcc(VAR_0, "stts"); avio_wb32(VAR_0, 0); avio_wb32(VAR_0, entries); for (VAR_2 = 0; VAR_2 < entries; VAR_2++) { avio_wb32(VAR_0, stts_entries[VAR_2].count); avio_wb32(VAR_0, stts_entries[VAR_2].duration); } av_free(stts_entries); return atom_size; }
[ "static int FUNC_0(AVIOContext *VAR_0, MOVTrack *VAR_1)\n{", "MOVStts *stts_entries;", "uint32_t entries = -1;", "uint32_t atom_size;", "int VAR_2;", "if (VAR_1->enc->codec_type == AVMEDIA_TYPE_AUDIO && !VAR_1->audio_vbr) {", "stts_entries = av_malloc(sizeof(*stts_entries));", "if (!stts_entries)\nreturn AVERROR(ENOMEM);", "stts_entries[0].count = VAR_1->sample_count;", "stts_entries[0].duration = 1;", "entries = 1;", "} else {", "stts_entries = VAR_1->entry ?\nav_malloc_array(VAR_1->entry, sizeof(*stts_entries)) :\nNULL;", "if (!stts_entries)\nreturn AVERROR(ENOMEM);", "for (VAR_2 = 0; VAR_2 < VAR_1->entry; VAR_2++) {", "int duration = get_cluster_duration(VAR_1, VAR_2);", "if (VAR_2 && duration == stts_entries[entries].duration) {", "stts_entries[entries].count++;", "} else {", "entries++;", "stts_entries[entries].duration = duration;", "stts_entries[entries].count = 1;", "}", "}", "entries++;", "}", "atom_size = 16 + (entries * 8);", "avio_wb32(VAR_0, atom_size);", "ffio_wfourcc(VAR_0, \"stts\");", "avio_wb32(VAR_0, 0);", "avio_wb32(VAR_0, entries);", "for (VAR_2 = 0; VAR_2 < entries; VAR_2++) {", "avio_wb32(VAR_0, stts_entries[VAR_2].count);", "avio_wb32(VAR_0, stts_entries[VAR_2].duration);", "}", "av_free(stts_entries);", "return atom_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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19, 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31, 33, 35 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ] ]
8,942
void qcrypto_cipher_free(QCryptoCipher *cipher) { QCryptoCipherBuiltin *ctxt = cipher->opaque; if (!cipher) { return; } ctxt->free(cipher); g_free(cipher); }
false
qemu
4f4f6976d80614e2d81cea4385885876f24bb257
void qcrypto_cipher_free(QCryptoCipher *cipher) { QCryptoCipherBuiltin *ctxt = cipher->opaque; if (!cipher) { return; } ctxt->free(cipher); g_free(cipher); }
{ "code": [], "line_no": [] }
void FUNC_0(QCryptoCipher *VAR_0) { QCryptoCipherBuiltin *ctxt = VAR_0->opaque; if (!VAR_0) { return; } ctxt->free(VAR_0); g_free(VAR_0); }
[ "void FUNC_0(QCryptoCipher *VAR_0)\n{", "QCryptoCipherBuiltin *ctxt = VAR_0->opaque;", "if (!VAR_0) {", "return;", "}", "ctxt->free(VAR_0);", "g_free(VAR_0);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ] ]
8,943
static uint64_t omap_wd_timer_read(void *opaque, target_phys_addr_t addr, unsigned size) { struct omap_watchdog_timer_s *s = (struct omap_watchdog_timer_s *) opaque; if (size != 2) { return omap_badwidth_read16(opaque, addr); } switch (addr) { case 0x00: /* CNTL_TIMER */ return (s->timer.ptv << 9) | (s->timer.ar << 8) | (s->timer.st << 7) | (s->free << 1); case 0x04: /* READ_TIMER */ return omap_timer_read(&s->timer); case 0x08: /* TIMER_MODE */ return s->mode << 15; } OMAP_BAD_REG(addr); return 0; }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static uint64_t omap_wd_timer_read(void *opaque, target_phys_addr_t addr, unsigned size) { struct omap_watchdog_timer_s *s = (struct omap_watchdog_timer_s *) opaque; if (size != 2) { return omap_badwidth_read16(opaque, addr); } switch (addr) { case 0x00: return (s->timer.ptv << 9) | (s->timer.ar << 8) | (s->timer.st << 7) | (s->free << 1); case 0x04: return omap_timer_read(&s->timer); case 0x08: return s->mode << 15; } OMAP_BAD_REG(addr); return 0; }
{ "code": [], "line_no": [] }
static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr, unsigned size) { struct omap_watchdog_timer_s *VAR_0 = (struct omap_watchdog_timer_s *) opaque; if (size != 2) { return omap_badwidth_read16(opaque, addr); } switch (addr) { case 0x00: return (VAR_0->timer.ptv << 9) | (VAR_0->timer.ar << 8) | (VAR_0->timer.st << 7) | (VAR_0->free << 1); case 0x04: return omap_timer_read(&VAR_0->timer); case 0x08: return VAR_0->mode << 15; } OMAP_BAD_REG(addr); return 0; }
[ "static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{", "struct omap_watchdog_timer_s *VAR_0 = (struct omap_watchdog_timer_s *) opaque;", "if (size != 2) {", "return omap_badwidth_read16(opaque, addr);", "}", "switch (addr) {", "case 0x00:\nreturn (VAR_0->timer.ptv << 9) | (VAR_0->timer.ar << 8) |\n(VAR_0->timer.st << 7) | (VAR_0->free << 1);", "case 0x04:\nreturn omap_timer_read(&VAR_0->timer);", "case 0x08:\nreturn VAR_0->mode << 15;", "}", "OMAP_BAD_REG(addr);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21, 23, 25 ], [ 29, 31 ], [ 35, 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ] ]