id
int32 0
27.3k
| func
stringlengths 26
142k
| target
bool 2
classes | project
stringclasses 2
values | commit_id
stringlengths 40
40
| func_clean
stringlengths 26
131k
| vul_lines
dict | normalized_func
stringlengths 24
132k
| lines
sequencelengths 1
2.8k
| label
sequencelengths 1
2.8k
| line_no
sequencelengths 1
2.8k
|
---|---|---|---|---|---|---|---|---|---|---|
20,748 | static int coroutine_fn blkreplay_co_discard(BlockDriverState *bs,
int64_t sector_num, int nb_sectors)
{
uint64_t reqid = request_id++;
int ret = bdrv_co_discard(bs->file->bs, sector_num, nb_sectors);
block_request_create(reqid, bs, qemu_coroutine_self());
qemu_coroutine_yield();
return ret;
}
| false | qemu | 9f1963b3f72521f75a549f8afd61b19e7da63c6f | static int coroutine_fn blkreplay_co_discard(BlockDriverState *bs,
int64_t sector_num, int nb_sectors)
{
uint64_t reqid = request_id++;
int ret = bdrv_co_discard(bs->file->bs, sector_num, nb_sectors);
block_request_create(reqid, bs, qemu_coroutine_self());
qemu_coroutine_yield();
return ret;
}
| {
"code": [],
"line_no": []
} | static int VAR_0 blkreplay_co_discard(BlockDriverState *bs,
int64_t sector_num, int nb_sectors)
{
uint64_t reqid = request_id++;
int ret = bdrv_co_discard(bs->file->bs, sector_num, nb_sectors);
block_request_create(reqid, bs, qemu_coroutine_self());
qemu_coroutine_yield();
return ret;
}
| [
"static int VAR_0 blkreplay_co_discard(BlockDriverState *bs,\nint64_t sector_num, int nb_sectors)\n{",
"uint64_t reqid = request_id++;",
"int ret = bdrv_co_discard(bs->file->bs, sector_num, nb_sectors);",
"block_request_create(reqid, bs, qemu_coroutine_self());",
"qemu_coroutine_yield();",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
]
] |
20,749 | static inline uint32_t ldl_phys_internal(hwaddr addr,
enum device_endian endian)
{
uint8_t *ptr;
uint32_t val;
MemoryRegionSection *section;
section = phys_page_find(address_space_memory.dispatch, addr >> TARGET_PAGE_BITS);
if (!(memory_region_is_ram(section->mr) ||
memory_region_is_romd(section->mr))) {
/* I/O case */
addr = memory_region_section_addr(section, addr);
val = io_mem_read(section->mr, addr, 4);
#if defined(TARGET_WORDS_BIGENDIAN)
if (endian == DEVICE_LITTLE_ENDIAN) {
val = bswap32(val);
}
#else
if (endian == DEVICE_BIG_ENDIAN) {
val = bswap32(val);
}
#endif
} else {
/* RAM case */
ptr = qemu_get_ram_ptr((memory_region_get_ram_addr(section->mr)
& TARGET_PAGE_MASK)
+ memory_region_section_addr(section, addr));
switch (endian) {
case DEVICE_LITTLE_ENDIAN:
val = ldl_le_p(ptr);
break;
case DEVICE_BIG_ENDIAN:
val = ldl_be_p(ptr);
break;
default:
val = ldl_p(ptr);
break;
}
}
return val;
}
| false | qemu | 149f54b53b7666a3facd45e86eece60ce7d3b114 | static inline uint32_t ldl_phys_internal(hwaddr addr,
enum device_endian endian)
{
uint8_t *ptr;
uint32_t val;
MemoryRegionSection *section;
section = phys_page_find(address_space_memory.dispatch, addr >> TARGET_PAGE_BITS);
if (!(memory_region_is_ram(section->mr) ||
memory_region_is_romd(section->mr))) {
addr = memory_region_section_addr(section, addr);
val = io_mem_read(section->mr, addr, 4);
#if defined(TARGET_WORDS_BIGENDIAN)
if (endian == DEVICE_LITTLE_ENDIAN) {
val = bswap32(val);
}
#else
if (endian == DEVICE_BIG_ENDIAN) {
val = bswap32(val);
}
#endif
} else {
ptr = qemu_get_ram_ptr((memory_region_get_ram_addr(section->mr)
& TARGET_PAGE_MASK)
+ memory_region_section_addr(section, addr));
switch (endian) {
case DEVICE_LITTLE_ENDIAN:
val = ldl_le_p(ptr);
break;
case DEVICE_BIG_ENDIAN:
val = ldl_be_p(ptr);
break;
default:
val = ldl_p(ptr);
break;
}
}
return val;
}
| {
"code": [],
"line_no": []
} | static inline uint32_t FUNC_0(hwaddr addr,
enum device_endian endian)
{
uint8_t *ptr;
uint32_t val;
MemoryRegionSection *section;
section = phys_page_find(address_space_memory.dispatch, addr >> TARGET_PAGE_BITS);
if (!(memory_region_is_ram(section->mr) ||
memory_region_is_romd(section->mr))) {
addr = memory_region_section_addr(section, addr);
val = io_mem_read(section->mr, addr, 4);
#if defined(TARGET_WORDS_BIGENDIAN)
if (endian == DEVICE_LITTLE_ENDIAN) {
val = bswap32(val);
}
#else
if (endian == DEVICE_BIG_ENDIAN) {
val = bswap32(val);
}
#endif
} else {
ptr = qemu_get_ram_ptr((memory_region_get_ram_addr(section->mr)
& TARGET_PAGE_MASK)
+ memory_region_section_addr(section, addr));
switch (endian) {
case DEVICE_LITTLE_ENDIAN:
val = ldl_le_p(ptr);
break;
case DEVICE_BIG_ENDIAN:
val = ldl_be_p(ptr);
break;
default:
val = ldl_p(ptr);
break;
}
}
return val;
}
| [
"static inline uint32_t FUNC_0(hwaddr addr,\nenum device_endian endian)\n{",
"uint8_t *ptr;",
"uint32_t val;",
"MemoryRegionSection *section;",
"section = phys_page_find(address_space_memory.dispatch, addr >> TARGET_PAGE_BITS);",
"if (!(memory_region_is_ram(section->mr) ||\nmemory_region_is_romd(section->mr))) {",
"addr = memory_region_section_addr(section, addr);",
"val = io_mem_read(section->mr, addr, 4);",
"#if defined(TARGET_WORDS_BIGENDIAN)\nif (endian == DEVICE_LITTLE_ENDIAN) {",
"val = bswap32(val);",
"}",
"#else\nif (endian == DEVICE_BIG_ENDIAN) {",
"val = bswap32(val);",
"}",
"#endif\n} else {",
"ptr = qemu_get_ram_ptr((memory_region_get_ram_addr(section->mr)\n& TARGET_PAGE_MASK)\n+ memory_region_section_addr(section, addr));",
"switch (endian) {",
"case DEVICE_LITTLE_ENDIAN:\nval = ldl_le_p(ptr);",
"break;",
"case DEVICE_BIG_ENDIAN:\nval = ldl_be_p(ptr);",
"break;",
"default:\nval = ldl_p(ptr);",
"break;",
"}",
"}",
"return val;",
"}"
] | [
0,
0,
0,
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
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45,
47
],
[
51,
53,
55
],
[
57
],
[
59,
61
],
[
63
],
[
65,
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
]
] |
20,750 | int ne2000_can_receive(NetClientState *nc)
{
NE2000State *s = qemu_get_nic_opaque(nc);
if (s->cmd & E8390_STOP)
return 1;
return !ne2000_buffer_full(s);
}
| false | qemu | c5a93780453e6da919287c17e873c843544ef2a3 | int ne2000_can_receive(NetClientState *nc)
{
NE2000State *s = qemu_get_nic_opaque(nc);
if (s->cmd & E8390_STOP)
return 1;
return !ne2000_buffer_full(s);
}
| {
"code": [],
"line_no": []
} | int FUNC_0(NetClientState *VAR_0)
{
NE2000State *s = qemu_get_nic_opaque(VAR_0);
if (s->cmd & E8390_STOP)
return 1;
return !ne2000_buffer_full(s);
}
| [
"int FUNC_0(NetClientState *VAR_0)\n{",
"NE2000State *s = qemu_get_nic_opaque(VAR_0);",
"if (s->cmd & E8390_STOP)\nreturn 1;",
"return !ne2000_buffer_full(s);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
13
],
[
15
]
] |
20,752 | static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pic, int *got_packet)
{
ProresContext *ctx = avctx->priv_data;
uint8_t *orig_buf, *buf, *slice_hdr, *slice_sizes, *tmp;
uint8_t *picture_size_pos;
PutBitContext pb;
int x, y, i, mb, q = 0;
int sizes[4] = { 0 };
int slice_hdr_size = 2 + 2 * (ctx->num_planes - 1);
int frame_size, picture_size, slice_size;
int mbs_per_slice = ctx->mbs_per_slice;
int pkt_size, ret;
*avctx->coded_frame = *pic;
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
pkt_size = ctx->mb_width * ctx->mb_height * 64 * 3 * 12
+ ctx->num_slices * 2 + 200 + FF_MIN_BUFFER_SIZE;
if ((ret = ff_alloc_packet(pkt, pkt_size)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
return ret;
}
orig_buf = pkt->data;
// frame atom
orig_buf += 4; // frame size
bytestream_put_be32 (&orig_buf, FRAME_ID); // frame container ID
buf = orig_buf;
// frame header
tmp = buf;
buf += 2; // frame header size will be stored here
bytestream_put_be16 (&buf, 0); // version 1
bytestream_put_buffer(&buf, "Lavc", 4); // creator
bytestream_put_be16 (&buf, avctx->width);
bytestream_put_be16 (&buf, avctx->height);
bytestream_put_byte (&buf, ctx->chroma_factor << 6); // frame flags
bytestream_put_byte (&buf, 0); // reserved
bytestream_put_byte (&buf, 0); // primaries
bytestream_put_byte (&buf, 0); // transfer function
bytestream_put_byte (&buf, 6); // colour matrix - ITU-R BT.601-4
bytestream_put_byte (&buf, 0x40); // source format and alpha information
bytestream_put_byte (&buf, 0); // reserved
bytestream_put_byte (&buf, 0x03); // matrix flags - both matrices are present
// luma quantisation matrix
for (i = 0; i < 64; i++)
bytestream_put_byte(&buf, ctx->profile_info->quant[i]);
// chroma quantisation matrix
for (i = 0; i < 64; i++)
bytestream_put_byte(&buf, ctx->profile_info->quant[i]);
bytestream_put_be16 (&tmp, buf - orig_buf); // write back frame header size
// picture header
picture_size_pos = buf + 1;
bytestream_put_byte (&buf, 0x40); // picture header size (in bits)
buf += 4; // picture data size will be stored here
bytestream_put_be16 (&buf, ctx->num_slices); // total number of slices
bytestream_put_byte (&buf, av_log2(ctx->mbs_per_slice) << 4); // slice width and height in MBs
// seek table - will be filled during slice encoding
slice_sizes = buf;
buf += ctx->num_slices * 2;
// slices
for (y = 0; y < ctx->mb_height; y++) {
mbs_per_slice = ctx->mbs_per_slice;
for (x = mb = 0; x < ctx->mb_width; x += mbs_per_slice, mb++) {
while (ctx->mb_width - x < mbs_per_slice)
mbs_per_slice >>= 1;
q = find_slice_quant(avctx, pic, (mb + 1) * TRELLIS_WIDTH, x, y,
mbs_per_slice);
}
for (x = ctx->slices_width - 1; x >= 0; x--) {
ctx->slice_q[x] = ctx->nodes[q].quant;
q = ctx->nodes[q].prev_node;
}
mbs_per_slice = ctx->mbs_per_slice;
for (x = mb = 0; x < ctx->mb_width; x += mbs_per_slice, mb++) {
q = ctx->slice_q[mb];
while (ctx->mb_width - x < mbs_per_slice)
mbs_per_slice >>= 1;
bytestream_put_byte(&buf, slice_hdr_size << 3);
slice_hdr = buf;
buf += slice_hdr_size - 1;
init_put_bits(&pb, buf, (pkt_size - (buf - orig_buf)) * 8);
encode_slice(avctx, pic, &pb, sizes, x, y, q, mbs_per_slice);
bytestream_put_byte(&slice_hdr, q);
slice_size = slice_hdr_size + sizes[ctx->num_planes - 1];
for (i = 0; i < ctx->num_planes - 1; i++) {
bytestream_put_be16(&slice_hdr, sizes[i]);
slice_size += sizes[i];
}
bytestream_put_be16(&slice_sizes, slice_size);
buf += slice_size - slice_hdr_size;
}
}
orig_buf -= 8;
frame_size = buf - orig_buf;
picture_size = buf - picture_size_pos - 6;
bytestream_put_be32(&orig_buf, frame_size);
bytestream_put_be32(&picture_size_pos, picture_size);
pkt->size = frame_size;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
| false | FFmpeg | 6d702dc072ffc255cd0f709132e55661698313e7 | static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pic, int *got_packet)
{
ProresContext *ctx = avctx->priv_data;
uint8_t *orig_buf, *buf, *slice_hdr, *slice_sizes, *tmp;
uint8_t *picture_size_pos;
PutBitContext pb;
int x, y, i, mb, q = 0;
int sizes[4] = { 0 };
int slice_hdr_size = 2 + 2 * (ctx->num_planes - 1);
int frame_size, picture_size, slice_size;
int mbs_per_slice = ctx->mbs_per_slice;
int pkt_size, ret;
*avctx->coded_frame = *pic;
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
pkt_size = ctx->mb_width * ctx->mb_height * 64 * 3 * 12
+ ctx->num_slices * 2 + 200 + FF_MIN_BUFFER_SIZE;
if ((ret = ff_alloc_packet(pkt, pkt_size)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
return ret;
}
orig_buf = pkt->data;
orig_buf += 4;
bytestream_put_be32 (&orig_buf, FRAME_ID);
buf = orig_buf;
tmp = buf;
buf += 2; size will be stored here
bytestream_put_be16 (&buf, 0);
bytestream_put_buffer(&buf, "Lavc", 4);
bytestream_put_be16 (&buf, avctx->width);
bytestream_put_be16 (&buf, avctx->height);
bytestream_put_byte (&buf, ctx->chroma_factor << 6);
bytestream_put_byte (&buf, 0);
bytestream_put_byte (&buf, 0);
bytestream_put_byte (&buf, 0);
bytestream_put_byte (&buf, 6);
bytestream_put_byte (&buf, 0x40);
bytestream_put_byte (&buf, 0);
bytestream_put_byte (&buf, 0x03);
for (i = 0; i < 64; i++)
bytestream_put_byte(&buf, ctx->profile_info->quant[i]);
for (i = 0; i < 64; i++)
bytestream_put_byte(&buf, ctx->profile_info->quant[i]);
bytestream_put_be16 (&tmp, buf - orig_buf);
picture_size_pos = buf + 1;
bytestream_put_byte (&buf, 0x40); size (in bits)
buf += 4;
bytestream_put_be16 (&buf, ctx->num_slices);
bytestream_put_byte (&buf, av_log2(ctx->mbs_per_slice) << 4);
slice_sizes = buf;
buf += ctx->num_slices * 2;
for (y = 0; y < ctx->mb_height; y++) {
mbs_per_slice = ctx->mbs_per_slice;
for (x = mb = 0; x < ctx->mb_width; x += mbs_per_slice, mb++) {
while (ctx->mb_width - x < mbs_per_slice)
mbs_per_slice >>= 1;
q = find_slice_quant(avctx, pic, (mb + 1) * TRELLIS_WIDTH, x, y,
mbs_per_slice);
}
for (x = ctx->slices_width - 1; x >= 0; x--) {
ctx->slice_q[x] = ctx->nodes[q].quant;
q = ctx->nodes[q].prev_node;
}
mbs_per_slice = ctx->mbs_per_slice;
for (x = mb = 0; x < ctx->mb_width; x += mbs_per_slice, mb++) {
q = ctx->slice_q[mb];
while (ctx->mb_width - x < mbs_per_slice)
mbs_per_slice >>= 1;
bytestream_put_byte(&buf, slice_hdr_size << 3);
slice_hdr = buf;
buf += slice_hdr_size - 1;
init_put_bits(&pb, buf, (pkt_size - (buf - orig_buf)) * 8);
encode_slice(avctx, pic, &pb, sizes, x, y, q, mbs_per_slice);
bytestream_put_byte(&slice_hdr, q);
slice_size = slice_hdr_size + sizes[ctx->num_planes - 1];
for (i = 0; i < ctx->num_planes - 1; i++) {
bytestream_put_be16(&slice_hdr, sizes[i]);
slice_size += sizes[i];
}
bytestream_put_be16(&slice_sizes, slice_size);
buf += slice_size - slice_hdr_size;
}
}
orig_buf -= 8;
frame_size = buf - orig_buf;
picture_size = buf - picture_size_pos - 6;
bytestream_put_be32(&orig_buf, frame_size);
bytestream_put_be32(&picture_size_pos, picture_size);
pkt->size = frame_size;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
const AVFrame *VAR_2, int *VAR_3)
{
ProresContext *ctx = VAR_0->priv_data;
uint8_t *orig_buf, *buf, *slice_hdr, *slice_sizes, *tmp;
uint8_t *picture_size_pos;
PutBitContext pb;
int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8 = 0;
int VAR_9[4] = { 0 };
int VAR_10 = 2 + 2 * (ctx->num_planes - 1);
int VAR_11, VAR_12, VAR_13;
int VAR_14 = ctx->VAR_14;
int VAR_15, VAR_16;
*VAR_0->coded_frame = *VAR_2;
VAR_0->coded_frame->pict_type = AV_PICTURE_TYPE_I;
VAR_0->coded_frame->key_frame = 1;
VAR_15 = ctx->mb_width * ctx->mb_height * 64 * 3 * 12
+ ctx->num_slices * 2 + 200 + FF_MIN_BUFFER_SIZE;
if ((VAR_16 = ff_alloc_packet(VAR_1, VAR_15)) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Error getting output packet.\n");
return VAR_16;
}
orig_buf = VAR_1->data;
orig_buf += 4;
bytestream_put_be32 (&orig_buf, FRAME_ID);
buf = orig_buf;
tmp = buf;
buf += 2; size will be stored here
bytestream_put_be16 (&buf, 0);
bytestream_put_buffer(&buf, "Lavc", 4);
bytestream_put_be16 (&buf, VAR_0->width);
bytestream_put_be16 (&buf, VAR_0->height);
bytestream_put_byte (&buf, ctx->chroma_factor << 6);
bytestream_put_byte (&buf, 0);
bytestream_put_byte (&buf, 0);
bytestream_put_byte (&buf, 0);
bytestream_put_byte (&buf, 6);
bytestream_put_byte (&buf, 0x40);
bytestream_put_byte (&buf, 0);
bytestream_put_byte (&buf, 0x03);
for (VAR_6 = 0; VAR_6 < 64; VAR_6++)
bytestream_put_byte(&buf, ctx->profile_info->quant[VAR_6]);
for (VAR_6 = 0; VAR_6 < 64; VAR_6++)
bytestream_put_byte(&buf, ctx->profile_info->quant[VAR_6]);
bytestream_put_be16 (&tmp, buf - orig_buf);
picture_size_pos = buf + 1;
bytestream_put_byte (&buf, 0x40); size (in bits)
buf += 4;
bytestream_put_be16 (&buf, ctx->num_slices);
bytestream_put_byte (&buf, av_log2(ctx->VAR_14) << 4);
slice_sizes = buf;
buf += ctx->num_slices * 2;
for (VAR_5 = 0; VAR_5 < ctx->mb_height; VAR_5++) {
VAR_14 = ctx->VAR_14;
for (VAR_4 = VAR_7 = 0; VAR_4 < ctx->mb_width; VAR_4 += VAR_14, VAR_7++) {
while (ctx->mb_width - VAR_4 < VAR_14)
VAR_14 >>= 1;
VAR_8 = find_slice_quant(VAR_0, VAR_2, (VAR_7 + 1) * TRELLIS_WIDTH, VAR_4, VAR_5,
VAR_14);
}
for (VAR_4 = ctx->slices_width - 1; VAR_4 >= 0; VAR_4--) {
ctx->slice_q[VAR_4] = ctx->nodes[VAR_8].quant;
VAR_8 = ctx->nodes[VAR_8].prev_node;
}
VAR_14 = ctx->VAR_14;
for (VAR_4 = VAR_7 = 0; VAR_4 < ctx->mb_width; VAR_4 += VAR_14, VAR_7++) {
VAR_8 = ctx->slice_q[VAR_7];
while (ctx->mb_width - VAR_4 < VAR_14)
VAR_14 >>= 1;
bytestream_put_byte(&buf, VAR_10 << 3);
slice_hdr = buf;
buf += VAR_10 - 1;
init_put_bits(&pb, buf, (VAR_15 - (buf - orig_buf)) * 8);
encode_slice(VAR_0, VAR_2, &pb, VAR_9, VAR_4, VAR_5, VAR_8, VAR_14);
bytestream_put_byte(&slice_hdr, VAR_8);
VAR_13 = VAR_10 + VAR_9[ctx->num_planes - 1];
for (VAR_6 = 0; VAR_6 < ctx->num_planes - 1; VAR_6++) {
bytestream_put_be16(&slice_hdr, VAR_9[VAR_6]);
VAR_13 += VAR_9[VAR_6];
}
bytestream_put_be16(&slice_sizes, VAR_13);
buf += VAR_13 - VAR_10;
}
}
orig_buf -= 8;
VAR_11 = buf - orig_buf;
VAR_12 = buf - picture_size_pos - 6;
bytestream_put_be32(&orig_buf, VAR_11);
bytestream_put_be32(&picture_size_pos, VAR_12);
VAR_1->size = VAR_11;
VAR_1->flags |= AV_PKT_FLAG_KEY;
*VAR_3 = 1;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,\nconst AVFrame *VAR_2, int *VAR_3)\n{",
"ProresContext *ctx = VAR_0->priv_data;",
"uint8_t *orig_buf, *buf, *slice_hdr, *slice_sizes, *tmp;",
"uint8_t *picture_size_pos;",
"PutBitContext pb;",
"int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8 = 0;",
"int VAR_9[4] = { 0 };",
"int VAR_10 = 2 + 2 * (ctx->num_planes - 1);",
"int VAR_11, VAR_12, VAR_13;",
"int VAR_14 = ctx->VAR_14;",
"int VAR_15, VAR_16;",
"*VAR_0->coded_frame = *VAR_2;",
"VAR_0->coded_frame->pict_type = AV_PICTURE_TYPE_I;",
"VAR_0->coded_frame->key_frame = 1;",
"VAR_15 = ctx->mb_width * ctx->mb_height * 64 * 3 * 12\n+ ctx->num_slices * 2 + 200 + FF_MIN_BUFFER_SIZE;",
"if ((VAR_16 = ff_alloc_packet(VAR_1, VAR_15)) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error getting output packet.\\n\");",
"return VAR_16;",
"}",
"orig_buf = VAR_1->data;",
"orig_buf += 4;",
"bytestream_put_be32 (&orig_buf, FRAME_ID);",
"buf = orig_buf;",
"tmp = buf;",
"buf += 2; size will be stored here",
"bytestream_put_be16 (&buf, 0);",
"bytestream_put_buffer(&buf, \"Lavc\", 4);",
"bytestream_put_be16 (&buf, VAR_0->width);",
"bytestream_put_be16 (&buf, VAR_0->height);",
"bytestream_put_byte (&buf, ctx->chroma_factor << 6);",
"bytestream_put_byte (&buf, 0);",
"bytestream_put_byte (&buf, 0);",
"bytestream_put_byte (&buf, 0);",
"bytestream_put_byte (&buf, 6);",
"bytestream_put_byte (&buf, 0x40);",
"bytestream_put_byte (&buf, 0);",
"bytestream_put_byte (&buf, 0x03);",
"for (VAR_6 = 0; VAR_6 < 64; VAR_6++)",
"bytestream_put_byte(&buf, ctx->profile_info->quant[VAR_6]);",
"for (VAR_6 = 0; VAR_6 < 64; VAR_6++)",
"bytestream_put_byte(&buf, ctx->profile_info->quant[VAR_6]);",
"bytestream_put_be16 (&tmp, buf - orig_buf);",
"picture_size_pos = buf + 1;",
"bytestream_put_byte (&buf, 0x40); size (in bits)",
"buf += 4;",
"bytestream_put_be16 (&buf, ctx->num_slices);",
"bytestream_put_byte (&buf, av_log2(ctx->VAR_14) << 4);",
"slice_sizes = buf;",
"buf += ctx->num_slices * 2;",
"for (VAR_5 = 0; VAR_5 < ctx->mb_height; VAR_5++) {",
"VAR_14 = ctx->VAR_14;",
"for (VAR_4 = VAR_7 = 0; VAR_4 < ctx->mb_width; VAR_4 += VAR_14, VAR_7++) {",
"while (ctx->mb_width - VAR_4 < VAR_14)\nVAR_14 >>= 1;",
"VAR_8 = find_slice_quant(VAR_0, VAR_2, (VAR_7 + 1) * TRELLIS_WIDTH, VAR_4, VAR_5,\nVAR_14);",
"}",
"for (VAR_4 = ctx->slices_width - 1; VAR_4 >= 0; VAR_4--) {",
"ctx->slice_q[VAR_4] = ctx->nodes[VAR_8].quant;",
"VAR_8 = ctx->nodes[VAR_8].prev_node;",
"}",
"VAR_14 = ctx->VAR_14;",
"for (VAR_4 = VAR_7 = 0; VAR_4 < ctx->mb_width; VAR_4 += VAR_14, VAR_7++) {",
"VAR_8 = ctx->slice_q[VAR_7];",
"while (ctx->mb_width - VAR_4 < VAR_14)\nVAR_14 >>= 1;",
"bytestream_put_byte(&buf, VAR_10 << 3);",
"slice_hdr = buf;",
"buf += VAR_10 - 1;",
"init_put_bits(&pb, buf, (VAR_15 - (buf - orig_buf)) * 8);",
"encode_slice(VAR_0, VAR_2, &pb, VAR_9, VAR_4, VAR_5, VAR_8, VAR_14);",
"bytestream_put_byte(&slice_hdr, VAR_8);",
"VAR_13 = VAR_10 + VAR_9[ctx->num_planes - 1];",
"for (VAR_6 = 0; VAR_6 < ctx->num_planes - 1; VAR_6++) {",
"bytestream_put_be16(&slice_hdr, VAR_9[VAR_6]);",
"VAR_13 += VAR_9[VAR_6];",
"}",
"bytestream_put_be16(&slice_sizes, VAR_13);",
"buf += VAR_13 - VAR_10;",
"}",
"}",
"orig_buf -= 8;",
"VAR_11 = buf - orig_buf;",
"VAR_12 = buf - picture_size_pos - 6;",
"bytestream_put_be32(&orig_buf, VAR_11);",
"bytestream_put_be32(&picture_size_pos, VAR_12);",
"VAR_1->size = VAR_11;",
"VAR_1->flags |= AV_PKT_FLAG_KEY;",
"*VAR_3 = 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,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37,
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
59
],
[
61
],
[
63
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
129
],
[
131
],
[
137
],
[
139
],
[
141
],
[
143,
145
],
[
147,
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
173,
175
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
225
],
[
227
],
[
229
],
[
233
],
[
235
]
] |
20,753 | static int epzs_motion_search4(MpegEncContext * s, int block,
int *mx_ptr, int *my_ptr,
int P[6][2], int pred_x, int pred_y,
int xmin, int ymin, int xmax, int ymax, uint8_t *ref_picture)
{
int best[2]={0, 0};
int d, dmin;
UINT8 *new_pic, *old_pic;
const int pic_stride= s->linesize;
const int pic_xy= ((s->mb_y*2 + (block>>1))*pic_stride + s->mb_x*2 + (block&1))*8;
UINT16 *mv_penalty= s->mv_penalty[s->f_code] + MAX_MV; // f_code of the prev frame
int quant= s->qscale; // qscale of the prev frame
const int shift= 1+s->quarter_sample;
new_pic = s->new_picture[0] + pic_xy;
old_pic = ref_picture + pic_xy;
dmin = pix_abs8x8(new_pic, old_pic, pic_stride);
/* first line */
if ((s->mb_y == 0 || s->first_slice_line || s->first_gob_line) && block<2) {
CHECK_MV4(P[1][0]>>shift, P[1][1]>>shift)
}else{
CHECK_MV4(P[4][0]>>shift, P[4][1]>>shift)
if(dmin<Z_THRESHOLD){
*mx_ptr= P[4][0]>>shift;
*my_ptr= P[4][1]>>shift;
//printf("M\n");
return dmin;
}
CHECK_MV4(P[1][0]>>shift, P[1][1]>>shift)
CHECK_MV4(P[2][0]>>shift, P[2][1]>>shift)
CHECK_MV4(P[3][0]>>shift, P[3][1]>>shift)
}
CHECK_MV4(P[0][0]>>shift, P[0][1]>>shift)
CHECK_MV4(P[5][0]>>shift, P[5][1]>>shift)
//check(best[0],best[1],0, b0)
dmin= small_diamond_search4MV(s, best, dmin, new_pic, old_pic, pic_stride,
pred_x, pred_y, mv_penalty, quant, xmin, ymin, xmax, ymax, shift);
//check(best[0],best[1],0, b1)
*mx_ptr= best[0];
*my_ptr= best[1];
// printf("%d %d %d \n", best[0], best[1], dmin);
return dmin;
}
| false | FFmpeg | 0d21a84605bad4e75dacb8196e5859902ed36f01 | static int epzs_motion_search4(MpegEncContext * s, int block,
int *mx_ptr, int *my_ptr,
int P[6][2], int pred_x, int pred_y,
int xmin, int ymin, int xmax, int ymax, uint8_t *ref_picture)
{
int best[2]={0, 0};
int d, dmin;
UINT8 *new_pic, *old_pic;
const int pic_stride= s->linesize;
const int pic_xy= ((s->mb_y*2 + (block>>1))*pic_stride + s->mb_x*2 + (block&1))*8;
UINT16 *mv_penalty= s->mv_penalty[s->f_code] + MAX_MV;
int quant= s->qscale;
const int shift= 1+s->quarter_sample;
new_pic = s->new_picture[0] + pic_xy;
old_pic = ref_picture + pic_xy;
dmin = pix_abs8x8(new_pic, old_pic, pic_stride);
if ((s->mb_y == 0 || s->first_slice_line || s->first_gob_line) && block<2) {
CHECK_MV4(P[1][0]>>shift, P[1][1]>>shift)
}else{
CHECK_MV4(P[4][0]>>shift, P[4][1]>>shift)
if(dmin<Z_THRESHOLD){
*mx_ptr= P[4][0]>>shift;
*my_ptr= P[4][1]>>shift;
return dmin;
}
CHECK_MV4(P[1][0]>>shift, P[1][1]>>shift)
CHECK_MV4(P[2][0]>>shift, P[2][1]>>shift)
CHECK_MV4(P[3][0]>>shift, P[3][1]>>shift)
}
CHECK_MV4(P[0][0]>>shift, P[0][1]>>shift)
CHECK_MV4(P[5][0]>>shift, P[5][1]>>shift)
dmin= small_diamond_search4MV(s, best, dmin, new_pic, old_pic, pic_stride,
pred_x, pred_y, mv_penalty, quant, xmin, ymin, xmax, ymax, shift);
*mx_ptr= best[0];
*my_ptr= best[1];
return dmin;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MpegEncContext * VAR_0, int VAR_1,
int *VAR_2, int *VAR_3,
int VAR_4[6][2], int VAR_5, int VAR_6,
int VAR_7, int VAR_8, int VAR_9, int VAR_10, uint8_t *VAR_11)
{
int VAR_12[2]={0, 0};
int VAR_13, VAR_14;
UINT8 *new_pic, *old_pic;
const int VAR_15= VAR_0->linesize;
const int VAR_16= ((VAR_0->mb_y*2 + (VAR_1>>1))*VAR_15 + VAR_0->mb_x*2 + (VAR_1&1))*8;
UINT16 *mv_penalty= VAR_0->mv_penalty[VAR_0->f_code] + MAX_MV;
int VAR_17= VAR_0->qscale;
const int VAR_18= 1+VAR_0->quarter_sample;
new_pic = VAR_0->new_picture[0] + VAR_16;
old_pic = VAR_11 + VAR_16;
VAR_14 = pix_abs8x8(new_pic, old_pic, VAR_15);
if ((VAR_0->mb_y == 0 || VAR_0->first_slice_line || VAR_0->first_gob_line) && VAR_1<2) {
CHECK_MV4(VAR_4[1][0]>>VAR_18, VAR_4[1][1]>>VAR_18)
}else{
CHECK_MV4(VAR_4[4][0]>>VAR_18, VAR_4[4][1]>>VAR_18)
if(VAR_14<Z_THRESHOLD){
*VAR_2= VAR_4[4][0]>>VAR_18;
*VAR_3= VAR_4[4][1]>>VAR_18;
return VAR_14;
}
CHECK_MV4(VAR_4[1][0]>>VAR_18, VAR_4[1][1]>>VAR_18)
CHECK_MV4(VAR_4[2][0]>>VAR_18, VAR_4[2][1]>>VAR_18)
CHECK_MV4(VAR_4[3][0]>>VAR_18, VAR_4[3][1]>>VAR_18)
}
CHECK_MV4(VAR_4[0][0]>>VAR_18, VAR_4[0][1]>>VAR_18)
CHECK_MV4(VAR_4[5][0]>>VAR_18, VAR_4[5][1]>>VAR_18)
VAR_14= small_diamond_search4MV(VAR_0, VAR_12, VAR_14, new_pic, old_pic, VAR_15,
VAR_5, VAR_6, mv_penalty, VAR_17, VAR_7, VAR_8, VAR_9, VAR_10, VAR_18);
*VAR_2= VAR_12[0];
*VAR_3= VAR_12[1];
return VAR_14;
}
| [
"static int FUNC_0(MpegEncContext * VAR_0, int VAR_1,\nint *VAR_2, int *VAR_3,\nint VAR_4[6][2], int VAR_5, int VAR_6,\nint VAR_7, int VAR_8, int VAR_9, int VAR_10, uint8_t *VAR_11)\n{",
"int VAR_12[2]={0, 0};",
"int VAR_13, VAR_14;",
"UINT8 *new_pic, *old_pic;",
"const int VAR_15= VAR_0->linesize;",
"const int VAR_16= ((VAR_0->mb_y*2 + (VAR_1>>1))*VAR_15 + VAR_0->mb_x*2 + (VAR_1&1))*8;",
"UINT16 *mv_penalty= VAR_0->mv_penalty[VAR_0->f_code] + MAX_MV;",
"int VAR_17= VAR_0->qscale;",
"const int VAR_18= 1+VAR_0->quarter_sample;",
"new_pic = VAR_0->new_picture[0] + VAR_16;",
"old_pic = VAR_11 + VAR_16;",
"VAR_14 = pix_abs8x8(new_pic, old_pic, VAR_15);",
"if ((VAR_0->mb_y == 0 || VAR_0->first_slice_line || VAR_0->first_gob_line) && VAR_1<2) {",
"CHECK_MV4(VAR_4[1][0]>>VAR_18, VAR_4[1][1]>>VAR_18)\n}else{",
"CHECK_MV4(VAR_4[4][0]>>VAR_18, VAR_4[4][1]>>VAR_18)\nif(VAR_14<Z_THRESHOLD){",
"*VAR_2= VAR_4[4][0]>>VAR_18;",
"*VAR_3= VAR_4[4][1]>>VAR_18;",
"return VAR_14;",
"}",
"CHECK_MV4(VAR_4[1][0]>>VAR_18, VAR_4[1][1]>>VAR_18)\nCHECK_MV4(VAR_4[2][0]>>VAR_18, VAR_4[2][1]>>VAR_18)\nCHECK_MV4(VAR_4[3][0]>>VAR_18, VAR_4[3][1]>>VAR_18)\n}",
"CHECK_MV4(VAR_4[0][0]>>VAR_18, VAR_4[0][1]>>VAR_18)\nCHECK_MV4(VAR_4[5][0]>>VAR_18, VAR_4[5][1]>>VAR_18)\nVAR_14= small_diamond_search4MV(VAR_0, VAR_12, VAR_14, new_pic, old_pic, VAR_15,\nVAR_5, VAR_6, mv_penalty, VAR_17, VAR_7, VAR_8, VAR_9, VAR_10, VAR_18);",
"*VAR_2= VAR_12[0];",
"*VAR_3= VAR_12[1];",
"return VAR_14;",
"}"
] | [
0,
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
],
[
35
],
[
41
],
[
43,
45
],
[
47,
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61,
63,
65,
67
],
[
69,
71,
77,
79
],
[
83
],
[
85
],
[
91
],
[
93
]
] |
20,754 | static int ffm_write_write_index(int fd, int64_t pos)
{
uint8_t buf[8];
int i;
for(i=0;i<8;i++)
buf[i] = (pos >> (56 - i * 8)) & 0xff;
lseek(fd, 8, SEEK_SET);
if (write(fd, buf, 8) != 8)
return AVERROR(EIO);
return 8;
}
| false | FFmpeg | 378a5b9c5f1a8b51dee3b954713d18f330fbb027 | static int ffm_write_write_index(int fd, int64_t pos)
{
uint8_t buf[8];
int i;
for(i=0;i<8;i++)
buf[i] = (pos >> (56 - i * 8)) & 0xff;
lseek(fd, 8, SEEK_SET);
if (write(fd, buf, 8) != 8)
return AVERROR(EIO);
return 8;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(int VAR_0, int64_t VAR_1)
{
uint8_t buf[8];
int VAR_2;
for(VAR_2=0;VAR_2<8;VAR_2++)
buf[VAR_2] = (VAR_1 >> (56 - VAR_2 * 8)) & 0xff;
lseek(VAR_0, 8, SEEK_SET);
if (write(VAR_0, buf, 8) != 8)
return AVERROR(EIO);
return 8;
}
| [
"static int FUNC_0(int VAR_0, int64_t VAR_1)\n{",
"uint8_t buf[8];",
"int VAR_2;",
"for(VAR_2=0;VAR_2<8;VAR_2++)",
"buf[VAR_2] = (VAR_1 >> (56 - VAR_2 * 8)) & 0xff;",
"lseek(VAR_0, 8, SEEK_SET);",
"if (write(VAR_0, buf, 8) != 8)\nreturn AVERROR(EIO);",
"return 8;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23
]
] |
20,755 | static void rv34_output_i16x16(RV34DecContext *r, int8_t *intra_types, int cbp)
{
LOCAL_ALIGNED_16(DCTELEM, block16, [16]);
MpegEncContext *s = &r->s;
GetBitContext *gb = &s->gb;
int q_dc = rv34_qscale_tab[ r->luma_dc_quant_i[s->qscale] ],
q_ac = rv34_qscale_tab[s->qscale];
uint8_t *dst = s->dest[0];
DCTELEM *ptr = s->block[0];
int avail[6*8] = {0};
int i, j, itype, has_ac;
memset(block16, 0, 16 * sizeof(*block16));
// Set neighbour information.
if(r->avail_cache[1])
avail[0] = 1;
if(r->avail_cache[2])
avail[1] = avail[2] = 1;
if(r->avail_cache[3])
avail[3] = avail[4] = 1;
if(r->avail_cache[4])
avail[5] = 1;
if(r->avail_cache[5])
avail[8] = avail[16] = 1;
if(r->avail_cache[9])
avail[24] = avail[32] = 1;
has_ac = rv34_decode_block(block16, gb, r->cur_vlcs, 3, 0, q_dc, q_dc, q_ac);
if(has_ac)
r->rdsp.rv34_inv_transform(block16);
else
r->rdsp.rv34_inv_transform_dc(block16);
itype = ittrans16[intra_types[0]];
itype = adjust_pred16(itype, r->avail_cache[6-4], r->avail_cache[6-1]);
r->h.pred16x16[itype](dst, s->linesize);
for(j = 0; j < 4; j++){
for(i = 0; i < 4; i++, cbp >>= 1){
int dc = block16[i + j*4];
if(cbp & 1){
has_ac = rv34_decode_block(ptr, gb, r->cur_vlcs, r->luma_vlc, 0, q_ac, q_ac, q_ac);
}else
has_ac = 0;
if(has_ac){
ptr[0] = dc;
r->rdsp.rv34_idct_add(dst+4*i, s->linesize, ptr);
}else
r->rdsp.rv34_idct_dc_add(dst+4*i, s->linesize, dc);
}
dst += 4*s->linesize;
}
itype = ittrans16[intra_types[0]];
if(itype == PLANE_PRED8x8) itype = DC_PRED8x8;
itype = adjust_pred16(itype, r->avail_cache[6-4], r->avail_cache[6-1]);
q_dc = rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]];
q_ac = rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]];
for(j = 1; j < 3; j++){
dst = s->dest[j];
r->h.pred8x8[itype](dst, s->uvlinesize);
for(i = 0; i < 4; i++, cbp >>= 1){
uint8_t *pdst;
if(!(cbp & 1)) continue;
pdst = dst + (i&1)*4 + (i&2)*2*s->uvlinesize;
rv34_process_block(r, pdst, s->uvlinesize,
r->chroma_vlc, 1, q_dc, q_ac);
}
}
}
| false | FFmpeg | 294c05ce8a7fbe3de74023065c264c1d720ec3cd | static void rv34_output_i16x16(RV34DecContext *r, int8_t *intra_types, int cbp)
{
LOCAL_ALIGNED_16(DCTELEM, block16, [16]);
MpegEncContext *s = &r->s;
GetBitContext *gb = &s->gb;
int q_dc = rv34_qscale_tab[ r->luma_dc_quant_i[s->qscale] ],
q_ac = rv34_qscale_tab[s->qscale];
uint8_t *dst = s->dest[0];
DCTELEM *ptr = s->block[0];
int avail[6*8] = {0};
int i, j, itype, has_ac;
memset(block16, 0, 16 * sizeof(*block16));
if(r->avail_cache[1])
avail[0] = 1;
if(r->avail_cache[2])
avail[1] = avail[2] = 1;
if(r->avail_cache[3])
avail[3] = avail[4] = 1;
if(r->avail_cache[4])
avail[5] = 1;
if(r->avail_cache[5])
avail[8] = avail[16] = 1;
if(r->avail_cache[9])
avail[24] = avail[32] = 1;
has_ac = rv34_decode_block(block16, gb, r->cur_vlcs, 3, 0, q_dc, q_dc, q_ac);
if(has_ac)
r->rdsp.rv34_inv_transform(block16);
else
r->rdsp.rv34_inv_transform_dc(block16);
itype = ittrans16[intra_types[0]];
itype = adjust_pred16(itype, r->avail_cache[6-4], r->avail_cache[6-1]);
r->h.pred16x16[itype](dst, s->linesize);
for(j = 0; j < 4; j++){
for(i = 0; i < 4; i++, cbp >>= 1){
int dc = block16[i + j*4];
if(cbp & 1){
has_ac = rv34_decode_block(ptr, gb, r->cur_vlcs, r->luma_vlc, 0, q_ac, q_ac, q_ac);
}else
has_ac = 0;
if(has_ac){
ptr[0] = dc;
r->rdsp.rv34_idct_add(dst+4*i, s->linesize, ptr);
}else
r->rdsp.rv34_idct_dc_add(dst+4*i, s->linesize, dc);
}
dst += 4*s->linesize;
}
itype = ittrans16[intra_types[0]];
if(itype == PLANE_PRED8x8) itype = DC_PRED8x8;
itype = adjust_pred16(itype, r->avail_cache[6-4], r->avail_cache[6-1]);
q_dc = rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]];
q_ac = rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]];
for(j = 1; j < 3; j++){
dst = s->dest[j];
r->h.pred8x8[itype](dst, s->uvlinesize);
for(i = 0; i < 4; i++, cbp >>= 1){
uint8_t *pdst;
if(!(cbp & 1)) continue;
pdst = dst + (i&1)*4 + (i&2)*2*s->uvlinesize;
rv34_process_block(r, pdst, s->uvlinesize,
r->chroma_vlc, 1, q_dc, q_ac);
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(RV34DecContext *VAR_0, int8_t *VAR_1, int VAR_2)
{
LOCAL_ALIGNED_16(DCTELEM, block16, [16]);
MpegEncContext *s = &VAR_0->s;
GetBitContext *gb = &s->gb;
int VAR_3 = rv34_qscale_tab[ VAR_0->luma_dc_quant_i[s->qscale] ],
VAR_4 = rv34_qscale_tab[s->qscale];
uint8_t *dst = s->dest[0];
DCTELEM *ptr = s->block[0];
int VAR_5[6*8] = {0};
int VAR_6, VAR_7, VAR_8, VAR_9;
memset(block16, 0, 16 * sizeof(*block16));
if(VAR_0->avail_cache[1])
VAR_5[0] = 1;
if(VAR_0->avail_cache[2])
VAR_5[1] = VAR_5[2] = 1;
if(VAR_0->avail_cache[3])
VAR_5[3] = VAR_5[4] = 1;
if(VAR_0->avail_cache[4])
VAR_5[5] = 1;
if(VAR_0->avail_cache[5])
VAR_5[8] = VAR_5[16] = 1;
if(VAR_0->avail_cache[9])
VAR_5[24] = VAR_5[32] = 1;
VAR_9 = rv34_decode_block(block16, gb, VAR_0->cur_vlcs, 3, 0, VAR_3, VAR_3, VAR_4);
if(VAR_9)
VAR_0->rdsp.rv34_inv_transform(block16);
else
VAR_0->rdsp.rv34_inv_transform_dc(block16);
VAR_8 = ittrans16[VAR_1[0]];
VAR_8 = adjust_pred16(VAR_8, VAR_0->avail_cache[6-4], VAR_0->avail_cache[6-1]);
VAR_0->h.pred16x16[VAR_8](dst, s->linesize);
for(VAR_7 = 0; VAR_7 < 4; VAR_7++){
for(VAR_6 = 0; VAR_6 < 4; VAR_6++, VAR_2 >>= 1){
int VAR_10 = block16[VAR_6 + VAR_7*4];
if(VAR_2 & 1){
VAR_9 = rv34_decode_block(ptr, gb, VAR_0->cur_vlcs, VAR_0->luma_vlc, 0, VAR_4, VAR_4, VAR_4);
}else
VAR_9 = 0;
if(VAR_9){
ptr[0] = VAR_10;
VAR_0->rdsp.rv34_idct_add(dst+4*VAR_6, s->linesize, ptr);
}else
VAR_0->rdsp.rv34_idct_dc_add(dst+4*VAR_6, s->linesize, VAR_10);
}
dst += 4*s->linesize;
}
VAR_8 = ittrans16[VAR_1[0]];
if(VAR_8 == PLANE_PRED8x8) VAR_8 = DC_PRED8x8;
VAR_8 = adjust_pred16(VAR_8, VAR_0->avail_cache[6-4], VAR_0->avail_cache[6-1]);
VAR_3 = rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]];
VAR_4 = rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]];
for(VAR_7 = 1; VAR_7 < 3; VAR_7++){
dst = s->dest[VAR_7];
VAR_0->h.pred8x8[VAR_8](dst, s->uvlinesize);
for(VAR_6 = 0; VAR_6 < 4; VAR_6++, VAR_2 >>= 1){
uint8_t *pdst;
if(!(VAR_2 & 1)) continue;
pdst = dst + (VAR_6&1)*4 + (VAR_6&2)*2*s->uvlinesize;
rv34_process_block(VAR_0, pdst, s->uvlinesize,
VAR_0->chroma_vlc, 1, VAR_3, VAR_4);
}
}
}
| [
"static void FUNC_0(RV34DecContext *VAR_0, int8_t *VAR_1, int VAR_2)\n{",
"LOCAL_ALIGNED_16(DCTELEM, block16, [16]);",
"MpegEncContext *s = &VAR_0->s;",
"GetBitContext *gb = &s->gb;",
"int VAR_3 = rv34_qscale_tab[ VAR_0->luma_dc_quant_i[s->qscale] ],\nVAR_4 = rv34_qscale_tab[s->qscale];",
"uint8_t *dst = s->dest[0];",
"DCTELEM *ptr = s->block[0];",
"int VAR_5[6*8] = {0};",
"int VAR_6, VAR_7, VAR_8, VAR_9;",
"memset(block16, 0, 16 * sizeof(*block16));",
"if(VAR_0->avail_cache[1])\nVAR_5[0] = 1;",
"if(VAR_0->avail_cache[2])\nVAR_5[1] = VAR_5[2] = 1;",
"if(VAR_0->avail_cache[3])\nVAR_5[3] = VAR_5[4] = 1;",
"if(VAR_0->avail_cache[4])\nVAR_5[5] = 1;",
"if(VAR_0->avail_cache[5])\nVAR_5[8] = VAR_5[16] = 1;",
"if(VAR_0->avail_cache[9])\nVAR_5[24] = VAR_5[32] = 1;",
"VAR_9 = rv34_decode_block(block16, gb, VAR_0->cur_vlcs, 3, 0, VAR_3, VAR_3, VAR_4);",
"if(VAR_9)\nVAR_0->rdsp.rv34_inv_transform(block16);",
"else\nVAR_0->rdsp.rv34_inv_transform_dc(block16);",
"VAR_8 = ittrans16[VAR_1[0]];",
"VAR_8 = adjust_pred16(VAR_8, VAR_0->avail_cache[6-4], VAR_0->avail_cache[6-1]);",
"VAR_0->h.pred16x16[VAR_8](dst, s->linesize);",
"for(VAR_7 = 0; VAR_7 < 4; VAR_7++){",
"for(VAR_6 = 0; VAR_6 < 4; VAR_6++, VAR_2 >>= 1){",
"int VAR_10 = block16[VAR_6 + VAR_7*4];",
"if(VAR_2 & 1){",
"VAR_9 = rv34_decode_block(ptr, gb, VAR_0->cur_vlcs, VAR_0->luma_vlc, 0, VAR_4, VAR_4, VAR_4);",
"}else",
"VAR_9 = 0;",
"if(VAR_9){",
"ptr[0] = VAR_10;",
"VAR_0->rdsp.rv34_idct_add(dst+4*VAR_6, s->linesize, ptr);",
"}else",
"VAR_0->rdsp.rv34_idct_dc_add(dst+4*VAR_6, s->linesize, VAR_10);",
"}",
"dst += 4*s->linesize;",
"}",
"VAR_8 = ittrans16[VAR_1[0]];",
"if(VAR_8 == PLANE_PRED8x8) VAR_8 = DC_PRED8x8;",
"VAR_8 = adjust_pred16(VAR_8, VAR_0->avail_cache[6-4], VAR_0->avail_cache[6-1]);",
"VAR_3 = rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]];",
"VAR_4 = rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]];",
"for(VAR_7 = 1; VAR_7 < 3; VAR_7++){",
"dst = s->dest[VAR_7];",
"VAR_0->h.pred8x8[VAR_8](dst, s->uvlinesize);",
"for(VAR_6 = 0; VAR_6 < 4; VAR_6++, VAR_2 >>= 1){",
"uint8_t *pdst;",
"if(!(VAR_2 & 1)) continue;",
"pdst = dst + (VAR_6&1)*4 + (VAR_6&2)*2*s->uvlinesize;",
"rv34_process_block(VAR_0, pdst, s->uvlinesize,\nVAR_0->chroma_vlc, 1, VAR_3, VAR_4);",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
31,
33
],
[
35,
37
],
[
39,
41
],
[
43,
45
],
[
47,
49
],
[
51,
53
],
[
57
],
[
59,
61
],
[
63,
65
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145,
147
],
[
149
],
[
151
],
[
153
]
] |
20,756 | STATIC void DEF(put, pixels8_xy2)(uint8_t *block, const uint8_t *pixels,
ptrdiff_t line_size, int h)
{
MOVQ_ZERO(mm7);
SET_RND(mm6); // =2 for rnd and =1 for no_rnd version
__asm__ volatile(
"movq (%1), %%mm0 \n\t"
"movq 1(%1), %%mm4 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm4, %%mm5 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpckhbw %%mm7, %%mm1 \n\t"
"punpckhbw %%mm7, %%mm5 \n\t"
"paddusw %%mm0, %%mm4 \n\t"
"paddusw %%mm1, %%mm5 \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
"add %3, %1 \n\t"
".p2align 3 \n\t"
"1: \n\t"
"movq (%1, %%"REG_a"), %%mm0 \n\t"
"movq 1(%1, %%"REG_a"), %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpckhbw %%mm7, %%mm1 \n\t"
"punpckhbw %%mm7, %%mm3 \n\t"
"paddusw %%mm2, %%mm0 \n\t"
"paddusw %%mm3, %%mm1 \n\t"
"paddusw %%mm6, %%mm4 \n\t"
"paddusw %%mm6, %%mm5 \n\t"
"paddusw %%mm0, %%mm4 \n\t"
"paddusw %%mm1, %%mm5 \n\t"
"psrlw $2, %%mm4 \n\t"
"psrlw $2, %%mm5 \n\t"
"packuswb %%mm5, %%mm4 \n\t"
"movq %%mm4, (%2, %%"REG_a") \n\t"
"add %3, %%"REG_a" \n\t"
"movq (%1, %%"REG_a"), %%mm2 \n\t" // 0 <-> 2 1 <-> 3
"movq 1(%1, %%"REG_a"), %%mm4 \n\t"
"movq %%mm2, %%mm3 \n\t"
"movq %%mm4, %%mm5 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpckhbw %%mm7, %%mm3 \n\t"
"punpckhbw %%mm7, %%mm5 \n\t"
"paddusw %%mm2, %%mm4 \n\t"
"paddusw %%mm3, %%mm5 \n\t"
"paddusw %%mm6, %%mm0 \n\t"
"paddusw %%mm6, %%mm1 \n\t"
"paddusw %%mm4, %%mm0 \n\t"
"paddusw %%mm5, %%mm1 \n\t"
"psrlw $2, %%mm0 \n\t"
"psrlw $2, %%mm1 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"movq %%mm0, (%2, %%"REG_a") \n\t"
"add %3, %%"REG_a" \n\t"
"subl $2, %0 \n\t"
"jnz 1b \n\t"
:"+g"(h), "+S"(pixels)
:"D"(block), "r"((x86_reg)line_size)
:REG_a, "memory");
}
| false | FFmpeg | 308e7484a3b1954072871a4090e5c672d1097fa5 | STATIC void DEF(put, pixels8_xy2)(uint8_t *block, const uint8_t *pixels,
ptrdiff_t line_size, int h)
{
MOVQ_ZERO(mm7);
SET_RND(mm6);
__asm__ volatile(
"movq (%1), %%mm0 \n\t"
"movq 1(%1), %%mm4 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm4, %%mm5 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpckhbw %%mm7, %%mm1 \n\t"
"punpckhbw %%mm7, %%mm5 \n\t"
"paddusw %%mm0, %%mm4 \n\t"
"paddusw %%mm1, %%mm5 \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
"add %3, %1 \n\t"
".p2align 3 \n\t"
"1: \n\t"
"movq (%1, %%"REG_a"), %%mm0 \n\t"
"movq 1(%1, %%"REG_a"), %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpckhbw %%mm7, %%mm1 \n\t"
"punpckhbw %%mm7, %%mm3 \n\t"
"paddusw %%mm2, %%mm0 \n\t"
"paddusw %%mm3, %%mm1 \n\t"
"paddusw %%mm6, %%mm4 \n\t"
"paddusw %%mm6, %%mm5 \n\t"
"paddusw %%mm0, %%mm4 \n\t"
"paddusw %%mm1, %%mm5 \n\t"
"psrlw $2, %%mm4 \n\t"
"psrlw $2, %%mm5 \n\t"
"packuswb %%mm5, %%mm4 \n\t"
"movq %%mm4, (%2, %%"REG_a") \n\t"
"add %3, %%"REG_a" \n\t"
"movq (%1, %%"REG_a"), %%mm2 \n\t"
"movq 1(%1, %%"REG_a"), %%mm4 \n\t"
"movq %%mm2, %%mm3 \n\t"
"movq %%mm4, %%mm5 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpckhbw %%mm7, %%mm3 \n\t"
"punpckhbw %%mm7, %%mm5 \n\t"
"paddusw %%mm2, %%mm4 \n\t"
"paddusw %%mm3, %%mm5 \n\t"
"paddusw %%mm6, %%mm0 \n\t"
"paddusw %%mm6, %%mm1 \n\t"
"paddusw %%mm4, %%mm0 \n\t"
"paddusw %%mm5, %%mm1 \n\t"
"psrlw $2, %%mm0 \n\t"
"psrlw $2, %%mm1 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"movq %%mm0, (%2, %%"REG_a") \n\t"
"add %3, %%"REG_a" \n\t"
"subl $2, %0 \n\t"
"jnz 1b \n\t"
:"+g"(h), "+S"(pixels)
:"D"(block), "r"((x86_reg)line_size)
:REG_a, "memory");
}
| {
"code": [],
"line_no": []
} | STATIC void FUNC_0(put, pixels8_xy2)(uint8_t *block, const uint8_t *pixels,
ptrdiff_t line_size, int h)
{
MOVQ_ZERO(mm7);
SET_RND(mm6);
__asm__ volatile(
"movq (%1), %%mm0 \n\t"
"movq 1(%1), %%mm4 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm4, %%mm5 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpckhbw %%mm7, %%mm1 \n\t"
"punpckhbw %%mm7, %%mm5 \n\t"
"paddusw %%mm0, %%mm4 \n\t"
"paddusw %%mm1, %%mm5 \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
"add %3, %1 \n\t"
".p2align 3 \n\t"
"1: \n\t"
"movq (%1, %%"REG_a"), %%mm0 \n\t"
"movq 1(%1, %%"REG_a"), %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpckhbw %%mm7, %%mm1 \n\t"
"punpckhbw %%mm7, %%mm3 \n\t"
"paddusw %%mm2, %%mm0 \n\t"
"paddusw %%mm3, %%mm1 \n\t"
"paddusw %%mm6, %%mm4 \n\t"
"paddusw %%mm6, %%mm5 \n\t"
"paddusw %%mm0, %%mm4 \n\t"
"paddusw %%mm1, %%mm5 \n\t"
"psrlw $2, %%mm4 \n\t"
"psrlw $2, %%mm5 \n\t"
"packuswb %%mm5, %%mm4 \n\t"
"movq %%mm4, (%2, %%"REG_a") \n\t"
"add %3, %%"REG_a" \n\t"
"movq (%1, %%"REG_a"), %%mm2 \n\t"
"movq 1(%1, %%"REG_a"), %%mm4 \n\t"
"movq %%mm2, %%mm3 \n\t"
"movq %%mm4, %%mm5 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpckhbw %%mm7, %%mm3 \n\t"
"punpckhbw %%mm7, %%mm5 \n\t"
"paddusw %%mm2, %%mm4 \n\t"
"paddusw %%mm3, %%mm5 \n\t"
"paddusw %%mm6, %%mm0 \n\t"
"paddusw %%mm6, %%mm1 \n\t"
"paddusw %%mm4, %%mm0 \n\t"
"paddusw %%mm5, %%mm1 \n\t"
"psrlw $2, %%mm0 \n\t"
"psrlw $2, %%mm1 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"movq %%mm0, (%2, %%"REG_a") \n\t"
"add %3, %%"REG_a" \n\t"
"subl $2, %0 \n\t"
"jnz 1b \n\t"
:"+g"(h), "+S"(pixels)
:"D"(block), "r"((x86_reg)line_size)
:REG_a, "memory");
}
| [
"STATIC void FUNC_0(put, pixels8_xy2)(uint8_t *block, const uint8_t *pixels,\nptrdiff_t line_size, int h)\n{",
"MOVQ_ZERO(mm7);",
"SET_RND(mm6);",
"__asm__ volatile(\n\"movq (%1), %%mm0 \\n\\t\"\n\"movq 1(%1), %%mm4 \\n\\t\"\n\"movq %%mm0, %%mm1 \\n\\t\"\n\"movq %%mm4, %%mm5 \\n\\t\"\n\"punpcklbw %%mm7, %%mm0 \\n\\t\"\n\"punpcklbw %%mm7, %%mm4 \\n\\t\"\n\"punpckhbw %%mm7, %%mm1 \\n\\t\"\n\"punpckhbw %%mm7, %%mm5 \\n\\t\"\n\"paddusw %%mm0, %%mm4 \\n\\t\"\n\"paddusw %%mm1, %%mm5 \\n\\t\"\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\n\"add %3, %1 \\n\\t\"\n\".p2align 3 \\n\\t\"\n\"1: \\n\\t\"\n\"movq (%1, %%\"REG_a\"), %%mm0 \\n\\t\"\n\"movq 1(%1, %%\"REG_a\"), %%mm2 \\n\\t\"\n\"movq %%mm0, %%mm1 \\n\\t\"\n\"movq %%mm2, %%mm3 \\n\\t\"\n\"punpcklbw %%mm7, %%mm0 \\n\\t\"\n\"punpcklbw %%mm7, %%mm2 \\n\\t\"\n\"punpckhbw %%mm7, %%mm1 \\n\\t\"\n\"punpckhbw %%mm7, %%mm3 \\n\\t\"\n\"paddusw %%mm2, %%mm0 \\n\\t\"\n\"paddusw %%mm3, %%mm1 \\n\\t\"\n\"paddusw %%mm6, %%mm4 \\n\\t\"\n\"paddusw %%mm6, %%mm5 \\n\\t\"\n\"paddusw %%mm0, %%mm4 \\n\\t\"\n\"paddusw %%mm1, %%mm5 \\n\\t\"\n\"psrlw $2, %%mm4 \\n\\t\"\n\"psrlw $2, %%mm5 \\n\\t\"\n\"packuswb %%mm5, %%mm4 \\n\\t\"\n\"movq %%mm4, (%2, %%\"REG_a\") \\n\\t\"\n\"add %3, %%\"REG_a\" \\n\\t\"\n\"movq (%1, %%\"REG_a\"), %%mm2 \\n\\t\"\n\"movq 1(%1, %%\"REG_a\"), %%mm4 \\n\\t\"\n\"movq %%mm2, %%mm3 \\n\\t\"\n\"movq %%mm4, %%mm5 \\n\\t\"\n\"punpcklbw %%mm7, %%mm2 \\n\\t\"\n\"punpcklbw %%mm7, %%mm4 \\n\\t\"\n\"punpckhbw %%mm7, %%mm3 \\n\\t\"\n\"punpckhbw %%mm7, %%mm5 \\n\\t\"\n\"paddusw %%mm2, %%mm4 \\n\\t\"\n\"paddusw %%mm3, %%mm5 \\n\\t\"\n\"paddusw %%mm6, %%mm0 \\n\\t\"\n\"paddusw %%mm6, %%mm1 \\n\\t\"\n\"paddusw %%mm4, %%mm0 \\n\\t\"\n\"paddusw %%mm5, %%mm1 \\n\\t\"\n\"psrlw $2, %%mm0 \\n\\t\"\n\"psrlw $2, %%mm1 \\n\\t\"\n\"packuswb %%mm1, %%mm0 \\n\\t\"\n\"movq %%mm0, (%2, %%\"REG_a\") \\n\\t\"\n\"add %3, %%\"REG_a\" \\n\\t\"\n\"subl $2, %0 \\n\\t\"\n\"jnz 1b \\n\\t\"\n:\"+g\"(h), \"+S\"(pixels)\n:\"D\"(block), \"r\"((x86_reg)line_size)\n:REG_a, \"memory\");",
"}"
] | [
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,
81,
83,
85,
87,
89,
91,
93,
95,
97,
99,
101,
103,
105,
107,
109,
111,
113,
115,
117,
121,
123,
125,
127,
129
],
[
131
]
] |
20,757 | static int atrac1_decode_frame(AVCodecContext *avctx, void *data,
int *data_size, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AT1Ctx *q = avctx->priv_data;
int ch, ret, i;
GetBitContext gb;
float* samples = data;
if (buf_size < 212 * q->channels) {
av_log(q,AV_LOG_ERROR,"Not enought data to decode!\n");
return -1;
}
for (ch = 0; ch < q->channels; ch++) {
AT1SUCtx* su = &q->SUs[ch];
init_get_bits(&gb, &buf[212 * ch], 212 * 8);
/* parse block_size_mode, 1st byte */
ret = at1_parse_bsm(&gb, su->log2_block_count);
if (ret < 0)
return ret;
ret = at1_unpack_dequant(&gb, su, q->spec);
if (ret < 0)
return ret;
ret = at1_imdct_block(su, q);
if (ret < 0)
return ret;
at1_subband_synthesis(q, su, q->out_samples[ch]);
}
/* interleave; FIXME, should create/use a DSP function */
if (q->channels == 1) {
/* mono */
memcpy(samples, q->out_samples[0], AT1_SU_SAMPLES * 4);
} else {
/* stereo */
for (i = 0; i < AT1_SU_SAMPLES; i++) {
samples[i * 2] = q->out_samples[0][i];
samples[i * 2 + 1] = q->out_samples[1][i];
}
}
*data_size = q->channels * AT1_SU_SAMPLES * sizeof(*samples);
return avctx->block_align;
}
| false | FFmpeg | 33684b9c12b74c0140fb91e8150263db4a48d55e | static int atrac1_decode_frame(AVCodecContext *avctx, void *data,
int *data_size, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AT1Ctx *q = avctx->priv_data;
int ch, ret, i;
GetBitContext gb;
float* samples = data;
if (buf_size < 212 * q->channels) {
av_log(q,AV_LOG_ERROR,"Not enought data to decode!\n");
return -1;
}
for (ch = 0; ch < q->channels; ch++) {
AT1SUCtx* su = &q->SUs[ch];
init_get_bits(&gb, &buf[212 * ch], 212 * 8);
ret = at1_parse_bsm(&gb, su->log2_block_count);
if (ret < 0)
return ret;
ret = at1_unpack_dequant(&gb, su, q->spec);
if (ret < 0)
return ret;
ret = at1_imdct_block(su, q);
if (ret < 0)
return ret;
at1_subband_synthesis(q, su, q->out_samples[ch]);
}
if (q->channels == 1) {
memcpy(samples, q->out_samples[0], AT1_SU_SAMPLES * 4);
} else {
for (i = 0; i < AT1_SU_SAMPLES; i++) {
samples[i * 2] = q->out_samples[0][i];
samples[i * 2 + 1] = q->out_samples[1][i];
}
}
*data_size = q->channels * AT1_SU_SAMPLES * sizeof(*samples);
return avctx->block_align;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
AT1Ctx *q = VAR_0->priv_data;
int VAR_6, VAR_7, VAR_8;
GetBitContext gb;
float* VAR_9 = VAR_1;
if (VAR_5 < 212 * q->channels) {
av_log(q,AV_LOG_ERROR,"Not enought VAR_1 to decode!\n");
return -1;
}
for (VAR_6 = 0; VAR_6 < q->channels; VAR_6++) {
AT1SUCtx* su = &q->SUs[VAR_6];
init_get_bits(&gb, &VAR_4[212 * VAR_6], 212 * 8);
VAR_7 = at1_parse_bsm(&gb, su->log2_block_count);
if (VAR_7 < 0)
return VAR_7;
VAR_7 = at1_unpack_dequant(&gb, su, q->spec);
if (VAR_7 < 0)
return VAR_7;
VAR_7 = at1_imdct_block(su, q);
if (VAR_7 < 0)
return VAR_7;
at1_subband_synthesis(q, su, q->out_samples[VAR_6]);
}
if (q->channels == 1) {
memcpy(VAR_9, q->out_samples[0], AT1_SU_SAMPLES * 4);
} else {
for (VAR_8 = 0; VAR_8 < AT1_SU_SAMPLES; VAR_8++) {
VAR_9[VAR_8 * 2] = q->out_samples[0][VAR_8];
VAR_9[VAR_8 * 2 + 1] = q->out_samples[1][VAR_8];
}
}
*VAR_2 = q->channels * AT1_SU_SAMPLES * sizeof(*VAR_9);
return VAR_0->block_align;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"AT1Ctx *q = VAR_0->priv_data;",
"int VAR_6, VAR_7, VAR_8;",
"GetBitContext gb;",
"float* VAR_9 = VAR_1;",
"if (VAR_5 < 212 * q->channels) {",
"av_log(q,AV_LOG_ERROR,\"Not enought VAR_1 to decode!\\n\");",
"return -1;",
"}",
"for (VAR_6 = 0; VAR_6 < q->channels; VAR_6++) {",
"AT1SUCtx* su = &q->SUs[VAR_6];",
"init_get_bits(&gb, &VAR_4[212 * VAR_6], 212 * 8);",
"VAR_7 = at1_parse_bsm(&gb, su->log2_block_count);",
"if (VAR_7 < 0)\nreturn VAR_7;",
"VAR_7 = at1_unpack_dequant(&gb, su, q->spec);",
"if (VAR_7 < 0)\nreturn VAR_7;",
"VAR_7 = at1_imdct_block(su, q);",
"if (VAR_7 < 0)\nreturn VAR_7;",
"at1_subband_synthesis(q, su, q->out_samples[VAR_6]);",
"}",
"if (q->channels == 1) {",
"memcpy(VAR_9, q->out_samples[0], AT1_SU_SAMPLES * 4);",
"} else {",
"for (VAR_8 = 0; VAR_8 < AT1_SU_SAMPLES; VAR_8++) {",
"VAR_9[VAR_8 * 2] = q->out_samples[0][VAR_8];",
"VAR_9[VAR_8 * 2 + 1] = q->out_samples[1][VAR_8];",
"}",
"}",
"*VAR_2 = q->channels * AT1_SU_SAMPLES * sizeof(*VAR_9);",
"return VAR_0->block_align;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
39
],
[
45
],
[
47,
49
],
[
53
],
[
55,
57
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
75
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
]
] |
20,758 | static void virgl_cmd_submit_3d(VirtIOGPU *g,
struct virtio_gpu_ctrl_command *cmd)
{
struct virtio_gpu_cmd_submit cs;
void *buf;
size_t s;
VIRTIO_GPU_FILL_CMD(cs);
trace_virtio_gpu_cmd_ctx_submit(cs.hdr.ctx_id, cs.size);
buf = g_malloc(cs.size);
s = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num,
sizeof(cs), buf, cs.size);
if (s != cs.size) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: size mismatch (%zd/%d)",
__func__, s, cs.size);
cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;
return;
}
if (virtio_gpu_stats_enabled(g->conf)) {
g->stats.req_3d++;
g->stats.bytes_3d += cs.size;
}
virgl_renderer_submit_cmd(buf, cs.hdr.ctx_id, cs.size / 4);
g_free(buf);
}
| true | qemu | 8d94c1ca53c638f6ec76840b0cb24677fb7705bf | static void virgl_cmd_submit_3d(VirtIOGPU *g,
struct virtio_gpu_ctrl_command *cmd)
{
struct virtio_gpu_cmd_submit cs;
void *buf;
size_t s;
VIRTIO_GPU_FILL_CMD(cs);
trace_virtio_gpu_cmd_ctx_submit(cs.hdr.ctx_id, cs.size);
buf = g_malloc(cs.size);
s = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num,
sizeof(cs), buf, cs.size);
if (s != cs.size) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: size mismatch (%zd/%d)",
__func__, s, cs.size);
cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;
return;
}
if (virtio_gpu_stats_enabled(g->conf)) {
g->stats.req_3d++;
g->stats.bytes_3d += cs.size;
}
virgl_renderer_submit_cmd(buf, cs.hdr.ctx_id, cs.size / 4);
g_free(buf);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(VirtIOGPU *VAR_0,
struct virtio_gpu_ctrl_command *VAR_1)
{
struct virtio_gpu_cmd_submit VAR_2;
void *VAR_3;
size_t s;
VIRTIO_GPU_FILL_CMD(VAR_2);
trace_virtio_gpu_cmd_ctx_submit(VAR_2.hdr.ctx_id, VAR_2.size);
VAR_3 = g_malloc(VAR_2.size);
s = iov_to_buf(VAR_1->elem.out_sg, VAR_1->elem.out_num,
sizeof(VAR_2), VAR_3, VAR_2.size);
if (s != VAR_2.size) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: size mismatch (%zd/%d)",
__func__, s, VAR_2.size);
VAR_1->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;
return;
}
if (virtio_gpu_stats_enabled(VAR_0->conf)) {
VAR_0->stats.req_3d++;
VAR_0->stats.bytes_3d += VAR_2.size;
}
virgl_renderer_submit_cmd(VAR_3, VAR_2.hdr.ctx_id, VAR_2.size / 4);
g_free(VAR_3);
}
| [
"static void FUNC_0(VirtIOGPU *VAR_0,\nstruct virtio_gpu_ctrl_command *VAR_1)\n{",
"struct virtio_gpu_cmd_submit VAR_2;",
"void *VAR_3;",
"size_t s;",
"VIRTIO_GPU_FILL_CMD(VAR_2);",
"trace_virtio_gpu_cmd_ctx_submit(VAR_2.hdr.ctx_id, VAR_2.size);",
"VAR_3 = g_malloc(VAR_2.size);",
"s = iov_to_buf(VAR_1->elem.out_sg, VAR_1->elem.out_num,\nsizeof(VAR_2), VAR_3, VAR_2.size);",
"if (s != VAR_2.size) {",
"qemu_log_mask(LOG_GUEST_ERROR, \"%s: size mismatch (%zd/%d)\",\n__func__, s, VAR_2.size);",
"VAR_1->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;",
"return;",
"}",
"if (virtio_gpu_stats_enabled(VAR_0->conf)) {",
"VAR_0->stats.req_3d++;",
"VAR_0->stats.bytes_3d += VAR_2.size;",
"}",
"virgl_renderer_submit_cmd(VAR_3, VAR_2.hdr.ctx_id, VAR_2.size / 4);",
"g_free(VAR_3);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23,
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
55
],
[
57
]
] |
20,759 | static int scsi_write_data(SCSIRequest *req)
{
SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req);
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
uint32_t n;
/* No data transfer may already be in progress */
assert(r->req.aiocb == NULL);
n = r->iov.iov_len / 512;
if (n) {
qemu_iovec_init_external(&r->qiov, &r->iov, 1);
r->req.aiocb = bdrv_aio_writev(s->bs, r->sector, &r->qiov, n,
scsi_write_complete, r);
if (r->req.aiocb == NULL) {
scsi_write_complete(r, -EIO);
}
} else {
/* Invoke completion routine to fetch data from host. */
scsi_write_complete(r, 0);
}
return 0;
}
| true | qemu | a1f0cce2ac0243572ff72aa561da67fe3766a395 | static int scsi_write_data(SCSIRequest *req)
{
SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req);
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
uint32_t n;
assert(r->req.aiocb == NULL);
n = r->iov.iov_len / 512;
if (n) {
qemu_iovec_init_external(&r->qiov, &r->iov, 1);
r->req.aiocb = bdrv_aio_writev(s->bs, r->sector, &r->qiov, n,
scsi_write_complete, r);
if (r->req.aiocb == NULL) {
scsi_write_complete(r, -EIO);
}
} else {
scsi_write_complete(r, 0);
}
return 0;
}
| {
"code": [
" scsi_write_complete(r, -EIO);"
],
"line_no": [
31
]
} | static int FUNC_0(SCSIRequest *VAR_0)
{
SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, VAR_0, VAR_0);
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->VAR_0.dev);
uint32_t n;
assert(r->VAR_0.aiocb == NULL);
n = r->iov.iov_len / 512;
if (n) {
qemu_iovec_init_external(&r->qiov, &r->iov, 1);
r->VAR_0.aiocb = bdrv_aio_writev(s->bs, r->sector, &r->qiov, n,
scsi_write_complete, r);
if (r->VAR_0.aiocb == NULL) {
scsi_write_complete(r, -EIO);
}
} else {
scsi_write_complete(r, 0);
}
return 0;
}
| [
"static int FUNC_0(SCSIRequest *VAR_0)\n{",
"SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, VAR_0, VAR_0);",
"SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->VAR_0.dev);",
"uint32_t n;",
"assert(r->VAR_0.aiocb == NULL);",
"n = r->iov.iov_len / 512;",
"if (n) {",
"qemu_iovec_init_external(&r->qiov, &r->iov, 1);",
"r->VAR_0.aiocb = bdrv_aio_writev(s->bs, r->sector, &r->qiov, n,\nscsi_write_complete, r);",
"if (r->VAR_0.aiocb == NULL) {",
"scsi_write_complete(r, -EIO);",
"}",
"} else {",
"scsi_write_complete(r, 0);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47
]
] |
20,760 | static int create_dynamic_disk(BlockBackend *blk, uint8_t *buf,
int64_t total_sectors)
{
VHDDynDiskHeader *dyndisk_header =
(VHDDynDiskHeader *) buf;
size_t block_size, num_bat_entries;
int i;
int ret;
int64_t offset = 0;
// Write the footer (twice: at the beginning and at the end)
block_size = 0x200000;
num_bat_entries = (total_sectors + block_size / 512) / (block_size / 512);
ret = blk_pwrite(blk, offset, buf, HEADER_SIZE);
if (ret) {
goto fail;
}
offset = 1536 + ((num_bat_entries * 4 + 511) & ~511);
ret = blk_pwrite(blk, offset, buf, HEADER_SIZE);
if (ret < 0) {
goto fail;
}
// Write the initial BAT
offset = 3 * 512;
memset(buf, 0xFF, 512);
for (i = 0; i < (num_bat_entries * 4 + 511) / 512; i++) {
ret = blk_pwrite(blk, offset, buf, 512);
if (ret < 0) {
goto fail;
}
offset += 512;
}
// Prepare the Dynamic Disk Header
memset(buf, 0, 1024);
memcpy(dyndisk_header->magic, "cxsparse", 8);
/*
* Note: The spec is actually wrong here for data_offset, it says
* 0xFFFFFFFF, but MS tools expect all 64 bits to be set.
*/
dyndisk_header->data_offset = cpu_to_be64(0xFFFFFFFFFFFFFFFFULL);
dyndisk_header->table_offset = cpu_to_be64(3 * 512);
dyndisk_header->version = cpu_to_be32(0x00010000);
dyndisk_header->block_size = cpu_to_be32(block_size);
dyndisk_header->max_table_entries = cpu_to_be32(num_bat_entries);
dyndisk_header->checksum = cpu_to_be32(vpc_checksum(buf, 1024));
// Write the header
offset = 512;
ret = blk_pwrite(blk, offset, buf, 1024);
if (ret < 0) {
goto fail;
}
fail:
return ret;
}
| true | qemu | 40a99aace3f9ffd65af07a89c381db3550b22316 | static int create_dynamic_disk(BlockBackend *blk, uint8_t *buf,
int64_t total_sectors)
{
VHDDynDiskHeader *dyndisk_header =
(VHDDynDiskHeader *) buf;
size_t block_size, num_bat_entries;
int i;
int ret;
int64_t offset = 0;
block_size = 0x200000;
num_bat_entries = (total_sectors + block_size / 512) / (block_size / 512);
ret = blk_pwrite(blk, offset, buf, HEADER_SIZE);
if (ret) {
goto fail;
}
offset = 1536 + ((num_bat_entries * 4 + 511) & ~511);
ret = blk_pwrite(blk, offset, buf, HEADER_SIZE);
if (ret < 0) {
goto fail;
}
offset = 3 * 512;
memset(buf, 0xFF, 512);
for (i = 0; i < (num_bat_entries * 4 + 511) / 512; i++) {
ret = blk_pwrite(blk, offset, buf, 512);
if (ret < 0) {
goto fail;
}
offset += 512;
}
memset(buf, 0, 1024);
memcpy(dyndisk_header->magic, "cxsparse", 8);
dyndisk_header->data_offset = cpu_to_be64(0xFFFFFFFFFFFFFFFFULL);
dyndisk_header->table_offset = cpu_to_be64(3 * 512);
dyndisk_header->version = cpu_to_be32(0x00010000);
dyndisk_header->block_size = cpu_to_be32(block_size);
dyndisk_header->max_table_entries = cpu_to_be32(num_bat_entries);
dyndisk_header->checksum = cpu_to_be32(vpc_checksum(buf, 1024));
offset = 512;
ret = blk_pwrite(blk, offset, buf, 1024);
if (ret < 0) {
goto fail;
}
fail:
return ret;
}
| {
"code": [
" if (ret) {"
],
"line_no": [
31
]
} | static int FUNC_0(BlockBackend *VAR_0, uint8_t *VAR_1,
int64_t VAR_2)
{
VHDDynDiskHeader *dyndisk_header =
(VHDDynDiskHeader *) VAR_1;
size_t block_size, num_bat_entries;
int VAR_3;
int VAR_4;
int64_t offset = 0;
block_size = 0x200000;
num_bat_entries = (VAR_2 + block_size / 512) / (block_size / 512);
VAR_4 = blk_pwrite(VAR_0, offset, VAR_1, HEADER_SIZE);
if (VAR_4) {
goto fail;
}
offset = 1536 + ((num_bat_entries * 4 + 511) & ~511);
VAR_4 = blk_pwrite(VAR_0, offset, VAR_1, HEADER_SIZE);
if (VAR_4 < 0) {
goto fail;
}
offset = 3 * 512;
memset(VAR_1, 0xFF, 512);
for (VAR_3 = 0; VAR_3 < (num_bat_entries * 4 + 511) / 512; VAR_3++) {
VAR_4 = blk_pwrite(VAR_0, offset, VAR_1, 512);
if (VAR_4 < 0) {
goto fail;
}
offset += 512;
}
memset(VAR_1, 0, 1024);
memcpy(dyndisk_header->magic, "cxsparse", 8);
dyndisk_header->data_offset = cpu_to_be64(0xFFFFFFFFFFFFFFFFULL);
dyndisk_header->table_offset = cpu_to_be64(3 * 512);
dyndisk_header->version = cpu_to_be32(0x00010000);
dyndisk_header->block_size = cpu_to_be32(block_size);
dyndisk_header->max_table_entries = cpu_to_be32(num_bat_entries);
dyndisk_header->checksum = cpu_to_be32(vpc_checksum(VAR_1, 1024));
offset = 512;
VAR_4 = blk_pwrite(VAR_0, offset, VAR_1, 1024);
if (VAR_4 < 0) {
goto fail;
}
fail:
return VAR_4;
}
| [
"static int FUNC_0(BlockBackend *VAR_0, uint8_t *VAR_1,\nint64_t VAR_2)\n{",
"VHDDynDiskHeader *dyndisk_header =\n(VHDDynDiskHeader *) VAR_1;",
"size_t block_size, num_bat_entries;",
"int VAR_3;",
"int VAR_4;",
"int64_t offset = 0;",
"block_size = 0x200000;",
"num_bat_entries = (VAR_2 + block_size / 512) / (block_size / 512);",
"VAR_4 = blk_pwrite(VAR_0, offset, VAR_1, HEADER_SIZE);",
"if (VAR_4) {",
"goto fail;",
"}",
"offset = 1536 + ((num_bat_entries * 4 + 511) & ~511);",
"VAR_4 = blk_pwrite(VAR_0, offset, VAR_1, HEADER_SIZE);",
"if (VAR_4 < 0) {",
"goto fail;",
"}",
"offset = 3 * 512;",
"memset(VAR_1, 0xFF, 512);",
"for (VAR_3 = 0; VAR_3 < (num_bat_entries * 4 + 511) / 512; VAR_3++) {",
"VAR_4 = blk_pwrite(VAR_0, offset, VAR_1, 512);",
"if (VAR_4 < 0) {",
"goto fail;",
"}",
"offset += 512;",
"}",
"memset(VAR_1, 0, 1024);",
"memcpy(dyndisk_header->magic, \"cxsparse\", 8);",
"dyndisk_header->data_offset = cpu_to_be64(0xFFFFFFFFFFFFFFFFULL);",
"dyndisk_header->table_offset = cpu_to_be64(3 * 512);",
"dyndisk_header->version = cpu_to_be32(0x00010000);",
"dyndisk_header->block_size = cpu_to_be32(block_size);",
"dyndisk_header->max_table_entries = cpu_to_be32(num_bat_entries);",
"dyndisk_header->checksum = cpu_to_be32(vpc_checksum(VAR_1, 1024));",
"offset = 512;",
"VAR_4 = blk_pwrite(VAR_0, offset, VAR_1, 1024);",
"if (VAR_4 < 0) {",
"goto fail;",
"}",
"fail:\nreturn VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
77
],
[
81
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125,
127
],
[
129
]
] |
20,762 | static int vmdk_is_cid_valid(BlockDriverState *bs)
{
BDRVVmdkState *s = bs->opaque;
uint32_t cur_pcid;
if (!s->cid_checked && bs->backing) {
BlockDriverState *p_bs = bs->backing->bs;
cur_pcid = vmdk_read_cid(p_bs, 0);
if (s->parent_cid != cur_pcid) {
/* CID not valid */
return 0;
}
}
s->cid_checked = true;
/* CID valid */
return 1;
}
| true | qemu | 9877860e7bd1e26ee70ab9bb5ebc34c92bf23bf5 | static int vmdk_is_cid_valid(BlockDriverState *bs)
{
BDRVVmdkState *s = bs->opaque;
uint32_t cur_pcid;
if (!s->cid_checked && bs->backing) {
BlockDriverState *p_bs = bs->backing->bs;
cur_pcid = vmdk_read_cid(p_bs, 0);
if (s->parent_cid != cur_pcid) {
return 0;
}
}
s->cid_checked = true;
return 1;
}
| {
"code": [
" cur_pcid = vmdk_read_cid(p_bs, 0);"
],
"line_no": [
17
]
} | static int FUNC_0(BlockDriverState *VAR_0)
{
BDRVVmdkState *s = VAR_0->opaque;
uint32_t cur_pcid;
if (!s->cid_checked && VAR_0->backing) {
BlockDriverState *p_bs = VAR_0->backing->VAR_0;
cur_pcid = vmdk_read_cid(p_bs, 0);
if (s->parent_cid != cur_pcid) {
return 0;
}
}
s->cid_checked = true;
return 1;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0)\n{",
"BDRVVmdkState *s = VAR_0->opaque;",
"uint32_t cur_pcid;",
"if (!s->cid_checked && VAR_0->backing) {",
"BlockDriverState *p_bs = VAR_0->backing->VAR_0;",
"cur_pcid = vmdk_read_cid(p_bs, 0);",
"if (s->parent_cid != cur_pcid) {",
"return 0;",
"}",
"}",
"s->cid_checked = true;",
"return 1;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
]
] |
20,763 | static inline int mpeg2_decode_block_intra(MpegEncContext *s, int16_t *block, int n)
{
int level, dc, diff, i, j, run;
int component;
RLTable *rl;
uint8_t * const scantable = s->intra_scantable.permutated;
const uint16_t *quant_matrix;
const int qscale = s->qscale;
int mismatch;
/* DC coefficient */
if (n < 4) {
quant_matrix = s->intra_matrix;
component = 0;
} else {
quant_matrix = s->chroma_intra_matrix;
component = (n & 1) + 1;
}
diff = decode_dc(&s->gb, component);
if (diff >= 0xffff)
return -1;
dc = s->last_dc[component];
dc += diff;
s->last_dc[component] = dc;
block[0] = dc << (3 - s->intra_dc_precision);
av_dlog(s->avctx, "dc=%d\n", block[0]);
mismatch = block[0] ^ 1;
i = 0;
if (s->intra_vlc_format)
rl = &ff_rl_mpeg2;
else
rl = &ff_rl_mpeg1;
{
OPEN_READER(re, &s->gb);
/* now quantify & encode AC coefficients */
for (;;) {
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
if (level == 127) {
break;
} else if (level != 0) {
i += run;
j = scantable[i];
level = (level * qscale * quant_matrix[j]) >> 4;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
} else {
/* escape */
run = SHOW_UBITS(re, &s->gb, 6) + 1; LAST_SKIP_BITS(re, &s->gb, 6);
UPDATE_CACHE(re, &s->gb);
level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
i += run;
j = scantable[i];
if (level < 0) {
level = (-level * qscale * quant_matrix[j]) >> 4;
level = -level;
} else {
level = (level * qscale * quant_matrix[j]) >> 4;
}
}
if (i > 63) {
av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
mismatch ^= level;
block[j] = level;
}
CLOSE_READER(re, &s->gb);
}
block[63] ^= mismatch & 1;
s->block_last_index[n] = i;
return 0;
}
| true | FFmpeg | 6d93307f8df81808f0dcdbc064b848054a6e83b3 | static inline int mpeg2_decode_block_intra(MpegEncContext *s, int16_t *block, int n)
{
int level, dc, diff, i, j, run;
int component;
RLTable *rl;
uint8_t * const scantable = s->intra_scantable.permutated;
const uint16_t *quant_matrix;
const int qscale = s->qscale;
int mismatch;
if (n < 4) {
quant_matrix = s->intra_matrix;
component = 0;
} else {
quant_matrix = s->chroma_intra_matrix;
component = (n & 1) + 1;
}
diff = decode_dc(&s->gb, component);
if (diff >= 0xffff)
return -1;
dc = s->last_dc[component];
dc += diff;
s->last_dc[component] = dc;
block[0] = dc << (3 - s->intra_dc_precision);
av_dlog(s->avctx, "dc=%d\n", block[0]);
mismatch = block[0] ^ 1;
i = 0;
if (s->intra_vlc_format)
rl = &ff_rl_mpeg2;
else
rl = &ff_rl_mpeg1;
{
OPEN_READER(re, &s->gb);
for (;;) {
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
if (level == 127) {
break;
} else if (level != 0) {
i += run;
j = scantable[i];
level = (level * qscale * quant_matrix[j]) >> 4;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
} else {
run = SHOW_UBITS(re, &s->gb, 6) + 1; LAST_SKIP_BITS(re, &s->gb, 6);
UPDATE_CACHE(re, &s->gb);
level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
i += run;
j = scantable[i];
if (level < 0) {
level = (-level * qscale * quant_matrix[j]) >> 4;
level = -level;
} else {
level = (level * qscale * quant_matrix[j]) >> 4;
}
}
if (i > 63) {
av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
mismatch ^= level;
block[j] = level;
}
CLOSE_READER(re, &s->gb);
}
block[63] ^= mismatch & 1;
s->block_last_index[n] = i;
return 0;
}
| {
"code": [
" if (i > 63) {",
" av_log(s->avctx, AV_LOG_ERROR, \"ac-tex damaged at %d %d\\n\", s->mb_x, s->mb_y);",
" return -1;",
" if (i > 63) {",
" av_log(s->avctx, AV_LOG_ERROR, \"ac-tex damaged at %d %d\\n\", s->mb_x, s->mb_y);",
" return -1;",
" if (i > 63) {",
" av_log(s->avctx, AV_LOG_ERROR, \"ac-tex damaged at %d %d\\n\", s->mb_x, s->mb_y);",
" return -1;",
" if (i > 63) {",
" av_log(s->avctx, AV_LOG_ERROR, \"ac-tex damaged at %d %d\\n\", s->mb_x, s->mb_y);",
" return -1;"
],
"line_no": [
125,
127,
129,
125,
127,
129,
125,
127,
129,
125,
127,
129
]
} | static inline int FUNC_0(MpegEncContext *VAR_0, int16_t *VAR_1, int VAR_2)
{
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;
int VAR_9;
RLTable *rl;
uint8_t * const scantable = VAR_0->intra_scantable.permutated;
const uint16_t *VAR_10;
const int VAR_11 = VAR_0->VAR_11;
int VAR_12;
if (VAR_2 < 4) {
VAR_10 = VAR_0->intra_matrix;
VAR_9 = 0;
} else {
VAR_10 = VAR_0->chroma_intra_matrix;
VAR_9 = (VAR_2 & 1) + 1;
}
VAR_5 = decode_dc(&VAR_0->gb, VAR_9);
if (VAR_5 >= 0xffff)
return -1;
VAR_4 = VAR_0->last_dc[VAR_9];
VAR_4 += VAR_5;
VAR_0->last_dc[VAR_9] = VAR_4;
VAR_1[0] = VAR_4 << (3 - VAR_0->intra_dc_precision);
av_dlog(VAR_0->avctx, "VAR_4=%d\VAR_2", VAR_1[0]);
VAR_12 = VAR_1[0] ^ 1;
VAR_6 = 0;
if (VAR_0->intra_vlc_format)
rl = &ff_rl_mpeg2;
else
rl = &ff_rl_mpeg1;
{
OPEN_READER(re, &VAR_0->gb);
for (;;) {
UPDATE_CACHE(re, &VAR_0->gb);
GET_RL_VLC(VAR_3, VAR_8, re, &VAR_0->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
if (VAR_3 == 127) {
break;
} else if (VAR_3 != 0) {
VAR_6 += VAR_8;
VAR_7 = scantable[VAR_6];
VAR_3 = (VAR_3 * VAR_11 * VAR_10[VAR_7]) >> 4;
VAR_3 = (VAR_3 ^ SHOW_SBITS(re, &VAR_0->gb, 1)) - SHOW_SBITS(re, &VAR_0->gb, 1);
LAST_SKIP_BITS(re, &VAR_0->gb, 1);
} else {
VAR_8 = SHOW_UBITS(re, &VAR_0->gb, 6) + 1; LAST_SKIP_BITS(re, &VAR_0->gb, 6);
UPDATE_CACHE(re, &VAR_0->gb);
VAR_3 = SHOW_SBITS(re, &VAR_0->gb, 12); SKIP_BITS(re, &VAR_0->gb, 12);
VAR_6 += VAR_8;
VAR_7 = scantable[VAR_6];
if (VAR_3 < 0) {
VAR_3 = (-VAR_3 * VAR_11 * VAR_10[VAR_7]) >> 4;
VAR_3 = -VAR_3;
} else {
VAR_3 = (VAR_3 * VAR_11 * VAR_10[VAR_7]) >> 4;
}
}
if (VAR_6 > 63) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\VAR_2", VAR_0->mb_x, VAR_0->mb_y);
return -1;
}
VAR_12 ^= VAR_3;
VAR_1[VAR_7] = VAR_3;
}
CLOSE_READER(re, &VAR_0->gb);
}
VAR_1[63] ^= VAR_12 & 1;
VAR_0->block_last_index[VAR_2] = VAR_6;
return 0;
}
| [
"static inline int FUNC_0(MpegEncContext *VAR_0, int16_t *VAR_1, int VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;",
"int VAR_9;",
"RLTable *rl;",
"uint8_t * const scantable = VAR_0->intra_scantable.permutated;",
"const uint16_t *VAR_10;",
"const int VAR_11 = VAR_0->VAR_11;",
"int VAR_12;",
"if (VAR_2 < 4) {",
"VAR_10 = VAR_0->intra_matrix;",
"VAR_9 = 0;",
"} else {",
"VAR_10 = VAR_0->chroma_intra_matrix;",
"VAR_9 = (VAR_2 & 1) + 1;",
"}",
"VAR_5 = decode_dc(&VAR_0->gb, VAR_9);",
"if (VAR_5 >= 0xffff)\nreturn -1;",
"VAR_4 = VAR_0->last_dc[VAR_9];",
"VAR_4 += VAR_5;",
"VAR_0->last_dc[VAR_9] = VAR_4;",
"VAR_1[0] = VAR_4 << (3 - VAR_0->intra_dc_precision);",
"av_dlog(VAR_0->avctx, \"VAR_4=%d\\VAR_2\", VAR_1[0]);",
"VAR_12 = VAR_1[0] ^ 1;",
"VAR_6 = 0;",
"if (VAR_0->intra_vlc_format)\nrl = &ff_rl_mpeg2;",
"else\nrl = &ff_rl_mpeg1;",
"{",
"OPEN_READER(re, &VAR_0->gb);",
"for (;;) {",
"UPDATE_CACHE(re, &VAR_0->gb);",
"GET_RL_VLC(VAR_3, VAR_8, re, &VAR_0->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);",
"if (VAR_3 == 127) {",
"break;",
"} else if (VAR_3 != 0) {",
"VAR_6 += VAR_8;",
"VAR_7 = scantable[VAR_6];",
"VAR_3 = (VAR_3 * VAR_11 * VAR_10[VAR_7]) >> 4;",
"VAR_3 = (VAR_3 ^ SHOW_SBITS(re, &VAR_0->gb, 1)) - SHOW_SBITS(re, &VAR_0->gb, 1);",
"LAST_SKIP_BITS(re, &VAR_0->gb, 1);",
"} else {",
"VAR_8 = SHOW_UBITS(re, &VAR_0->gb, 6) + 1; LAST_SKIP_BITS(re, &VAR_0->gb, 6);",
"UPDATE_CACHE(re, &VAR_0->gb);",
"VAR_3 = SHOW_SBITS(re, &VAR_0->gb, 12); SKIP_BITS(re, &VAR_0->gb, 12);",
"VAR_6 += VAR_8;",
"VAR_7 = scantable[VAR_6];",
"if (VAR_3 < 0) {",
"VAR_3 = (-VAR_3 * VAR_11 * VAR_10[VAR_7]) >> 4;",
"VAR_3 = -VAR_3;",
"} else {",
"VAR_3 = (VAR_3 * VAR_11 * VAR_10[VAR_7]) >> 4;",
"}",
"}",
"if (VAR_6 > 63) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"ac-tex damaged at %d %d\\VAR_2\", VAR_0->mb_x, VAR_0->mb_y);",
"return -1;",
"}",
"VAR_12 ^= VAR_3;",
"VAR_1[VAR_7] = VAR_3;",
"}",
"CLOSE_READER(re, &VAR_0->gb);",
"}",
"VAR_1[63] ^= VAR_12 & 1;",
"VAR_0->block_last_index[VAR_2] = VAR_6;",
"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,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61,
63
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
]
] |
20,764 | PPC_OP(test_ctr_true)
{
T0 = (regs->ctr != 0 && (T0 & PARAM(1)) != 0);
RETURN();
}
| true | qemu | d9bce9d99f4656ae0b0127f7472db9067b8f84ab | PPC_OP(test_ctr_true)
{
T0 = (regs->ctr != 0 && (T0 & PARAM(1)) != 0);
RETURN();
}
| {
"code": [
"PPC_OP(test_ctr_true)",
" T0 = (regs->ctr != 0 && (T0 & PARAM(1)) != 0);",
" RETURN();",
" RETURN();"
],
"line_no": [
1,
5,
7,
7
]
} | FUNC_0(VAR_0)
{
T0 = (regs->ctr != 0 && (T0 & PARAM(1)) != 0);
RETURN();
}
| [
"FUNC_0(VAR_0)\n{",
"T0 = (regs->ctr != 0 && (T0 & PARAM(1)) != 0);",
"RETURN();",
"}"
] | [
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
20,765 | static inline int mov_stsc_index_valid(int index, int count)
{
return index + 1 < count;
}
| true | FFmpeg | 53ea595eec984e3109310e8bb7ff4b5786d91057 | static inline int mov_stsc_index_valid(int index, int count)
{
return index + 1 < count;
}
| {
"code": [
"static inline int mov_stsc_index_valid(int index, int count)",
" return index + 1 < count;"
],
"line_no": [
1,
5
]
} | static inline int FUNC_0(int VAR_0, int VAR_1)
{
return VAR_0 + 1 < VAR_1;
}
| [
"static inline int FUNC_0(int VAR_0, int VAR_1)\n{",
"return VAR_0 + 1 < VAR_1;",
"}"
] | [
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
20,767 | static void init_proc_POWER7 (CPUPPCState *env)
{
gen_spr_ne_601(env);
gen_spr_7xx(env);
/* Time base */
gen_tbl(env);
/* Processor identification */
spr_register(env, SPR_PIR, "PIR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_pir,
0x00000000);
#if !defined(CONFIG_USER_ONLY)
/* PURR & SPURR: Hack - treat these as aliases for the TB for now */
spr_register_kvm(env, SPR_PURR, "PURR",
&spr_read_purr, SPR_NOACCESS,
&spr_read_purr, SPR_NOACCESS,
KVM_REG_PPC_PURR, 0x00000000);
spr_register_kvm(env, SPR_SPURR, "SPURR",
&spr_read_purr, SPR_NOACCESS,
&spr_read_purr, SPR_NOACCESS,
KVM_REG_PPC_SPURR, 0x00000000);
spr_register(env, SPR_CFAR, "SPR_CFAR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_cfar, &spr_write_cfar,
0x00000000);
spr_register_kvm(env, SPR_DSCR, "SPR_DSCR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
KVM_REG_PPC_DSCR, 0x00000000);
#endif /* !CONFIG_USER_ONLY */
/* Memory management */
/* XXX : not implemented */
spr_register(env, SPR_MMUCFG, "MMUCFG",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, SPR_NOACCESS,
0x00000000); /* TOFIX */
/* XXX : not implemented */
spr_register(env, SPR_CTRL, "SPR_CTRLT",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x80800000);
spr_register(env, SPR_UCTRL, "SPR_CTRLF",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x80800000);
spr_register(env, SPR_VRSAVE, "SPR_VRSAVE",
&spr_read_generic, &spr_write_generic,
&spr_read_generic, &spr_write_generic,
0x00000000);
#if !defined(CONFIG_USER_ONLY)
env->slb_nr = 32;
#endif
init_excp_POWER7(env);
env->dcache_line_size = 128;
env->icache_line_size = 128;
/* Allocate hardware IRQ controller */
ppcPOWER7_irq_init(env);
/* Can't find information on what this should be on reset. This
* value is the one used by 74xx processors. */
vscr_init(env, 0x00010000);
} | true | qemu | f80872e21c07edd06eb343eeeefc8af404b518a6 | static void init_proc_POWER7 (CPUPPCState *env)
{
gen_spr_ne_601(env);
gen_spr_7xx(env);
gen_tbl(env);
spr_register(env, SPR_PIR, "PIR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_pir,
0x00000000);
#if !defined(CONFIG_USER_ONLY)
spr_register_kvm(env, SPR_PURR, "PURR",
&spr_read_purr, SPR_NOACCESS,
&spr_read_purr, SPR_NOACCESS,
KVM_REG_PPC_PURR, 0x00000000);
spr_register_kvm(env, SPR_SPURR, "SPURR",
&spr_read_purr, SPR_NOACCESS,
&spr_read_purr, SPR_NOACCESS,
KVM_REG_PPC_SPURR, 0x00000000);
spr_register(env, SPR_CFAR, "SPR_CFAR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_cfar, &spr_write_cfar,
0x00000000);
spr_register_kvm(env, SPR_DSCR, "SPR_DSCR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
KVM_REG_PPC_DSCR, 0x00000000);
#endif
spr_register(env, SPR_MMUCFG, "MMUCFG",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, SPR_NOACCESS,
0x00000000);
spr_register(env, SPR_CTRL, "SPR_CTRLT",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x80800000);
spr_register(env, SPR_UCTRL, "SPR_CTRLF",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x80800000);
spr_register(env, SPR_VRSAVE, "SPR_VRSAVE",
&spr_read_generic, &spr_write_generic,
&spr_read_generic, &spr_write_generic,
0x00000000);
#if !defined(CONFIG_USER_ONLY)
env->slb_nr = 32;
#endif
init_excp_POWER7(env);
env->dcache_line_size = 128;
env->icache_line_size = 128;
ppcPOWER7_irq_init(env);
vscr_init(env, 0x00010000);
} | {
"code": [],
"line_no": []
} | static void FUNC_0 (CPUPPCState *VAR_0)
{
gen_spr_ne_601(VAR_0);
gen_spr_7xx(VAR_0);
gen_tbl(VAR_0);
spr_register(VAR_0, SPR_PIR, "PIR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_pir,
0x00000000);
#if !defined(CONFIG_USER_ONLY)
spr_register_kvm(VAR_0, SPR_PURR, "PURR",
&spr_read_purr, SPR_NOACCESS,
&spr_read_purr, SPR_NOACCESS,
KVM_REG_PPC_PURR, 0x00000000);
spr_register_kvm(VAR_0, SPR_SPURR, "SPURR",
&spr_read_purr, SPR_NOACCESS,
&spr_read_purr, SPR_NOACCESS,
KVM_REG_PPC_SPURR, 0x00000000);
spr_register(VAR_0, SPR_CFAR, "SPR_CFAR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_cfar, &spr_write_cfar,
0x00000000);
spr_register_kvm(VAR_0, SPR_DSCR, "SPR_DSCR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
KVM_REG_PPC_DSCR, 0x00000000);
#endif
spr_register(VAR_0, SPR_MMUCFG, "MMUCFG",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, SPR_NOACCESS,
0x00000000);
spr_register(VAR_0, SPR_CTRL, "SPR_CTRLT",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x80800000);
spr_register(VAR_0, SPR_UCTRL, "SPR_CTRLF",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x80800000);
spr_register(VAR_0, SPR_VRSAVE, "SPR_VRSAVE",
&spr_read_generic, &spr_write_generic,
&spr_read_generic, &spr_write_generic,
0x00000000);
#if !defined(CONFIG_USER_ONLY)
VAR_0->slb_nr = 32;
#endif
init_excp_POWER7(VAR_0);
VAR_0->dcache_line_size = 128;
VAR_0->icache_line_size = 128;
ppcPOWER7_irq_init(VAR_0);
vscr_init(VAR_0, 0x00010000);
} | [
"static void FUNC_0 (CPUPPCState *VAR_0)\n{",
"gen_spr_ne_601(VAR_0);",
"gen_spr_7xx(VAR_0);",
"gen_tbl(VAR_0);",
"spr_register(VAR_0, SPR_PIR, \"PIR\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_pir,\n0x00000000);",
"#if !defined(CONFIG_USER_ONLY)\nspr_register_kvm(VAR_0, SPR_PURR, \"PURR\",\n&spr_read_purr, SPR_NOACCESS,\n&spr_read_purr, SPR_NOACCESS,\nKVM_REG_PPC_PURR, 0x00000000);",
"spr_register_kvm(VAR_0, SPR_SPURR, \"SPURR\",\n&spr_read_purr, SPR_NOACCESS,\n&spr_read_purr, SPR_NOACCESS,\nKVM_REG_PPC_SPURR, 0x00000000);",
"spr_register(VAR_0, SPR_CFAR, \"SPR_CFAR\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_cfar, &spr_write_cfar,\n0x00000000);",
"spr_register_kvm(VAR_0, SPR_DSCR, \"SPR_DSCR\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\nKVM_REG_PPC_DSCR, 0x00000000);",
"#endif\nspr_register(VAR_0, SPR_MMUCFG, \"MMUCFG\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, SPR_NOACCESS,\n0x00000000);",
"spr_register(VAR_0, SPR_CTRL, \"SPR_CTRLT\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\n0x80800000);",
"spr_register(VAR_0, SPR_UCTRL, \"SPR_CTRLF\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\n0x80800000);",
"spr_register(VAR_0, SPR_VRSAVE, \"SPR_VRSAVE\",\n&spr_read_generic, &spr_write_generic,\n&spr_read_generic, &spr_write_generic,\n0x00000000);",
"#if !defined(CONFIG_USER_ONLY)\nVAR_0->slb_nr = 32;",
"#endif\ninit_excp_POWER7(VAR_0);",
"VAR_0->dcache_line_size = 128;",
"VAR_0->icache_line_size = 128;",
"ppcPOWER7_irq_init(VAR_0);",
"vscr_init(VAR_0, 0x00010000);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15,
17,
19,
21
],
[
23,
27,
29,
31,
33
],
[
35,
37,
39,
41
],
[
43,
45,
47,
49
],
[
51,
53,
55,
57
],
[
59,
65,
67,
69,
71
],
[
76,
78,
80,
82
],
[
84,
86,
88,
90
],
[
92,
94,
96,
98
],
[
100,
102
],
[
104,
106
],
[
108
],
[
110
],
[
114
],
[
120
],
[
122
]
] |
20,768 | void spapr_events_init(sPAPREnvironment *spapr)
{
spapr->epow_irq = spapr_allocate_msi(0);
spapr->epow_notifier.notify = spapr_powerdown_req;
qemu_register_powerdown_notifier(&spapr->epow_notifier);
spapr_rtas_register("check-exception", check_exception);
}
| true | qemu | 3a3b8502e6f0c8d30865c5f36d2c3ae4114000b5 | void spapr_events_init(sPAPREnvironment *spapr)
{
spapr->epow_irq = spapr_allocate_msi(0);
spapr->epow_notifier.notify = spapr_powerdown_req;
qemu_register_powerdown_notifier(&spapr->epow_notifier);
spapr_rtas_register("check-exception", check_exception);
}
| {
"code": [
" spapr_rtas_register(\"check-exception\", check_exception);"
],
"line_no": [
11
]
} | void FUNC_0(sPAPREnvironment *VAR_0)
{
VAR_0->epow_irq = spapr_allocate_msi(0);
VAR_0->epow_notifier.notify = spapr_powerdown_req;
qemu_register_powerdown_notifier(&VAR_0->epow_notifier);
spapr_rtas_register("check-exception", check_exception);
}
| [
"void FUNC_0(sPAPREnvironment *VAR_0)\n{",
"VAR_0->epow_irq = spapr_allocate_msi(0);",
"VAR_0->epow_notifier.notify = spapr_powerdown_req;",
"qemu_register_powerdown_notifier(&VAR_0->epow_notifier);",
"spapr_rtas_register(\"check-exception\", check_exception);",
"}"
] | [
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
20,769 | target_ulong helper_add_suov(CPUTriCoreState *env, target_ulong r1,
target_ulong r2)
{
int64_t t1 = extract64(r1, 0, 32);
int64_t t2 = extract64(r2, 0, 32);
int64_t result = t1 + t2;
return suov32(env, result);
}
| true | qemu | 85d604af5f96c32734af9974ec6ddb625b6716a2 | target_ulong helper_add_suov(CPUTriCoreState *env, target_ulong r1,
target_ulong r2)
{
int64_t t1 = extract64(r1, 0, 32);
int64_t t2 = extract64(r2, 0, 32);
int64_t result = t1 + t2;
return suov32(env, result);
}
| {
"code": [
" return suov32(env, result);",
" return suov32(env, result);",
" return suov32(env, result);",
" return suov32(env, result);",
" return suov32(env, result);"
],
"line_no": [
13,
13,
13,
13,
13
]
} | target_ulong FUNC_0(CPUTriCoreState *env, target_ulong r1,
target_ulong r2)
{
int64_t t1 = extract64(r1, 0, 32);
int64_t t2 = extract64(r2, 0, 32);
int64_t result = t1 + t2;
return suov32(env, result);
}
| [
"target_ulong FUNC_0(CPUTriCoreState *env, target_ulong r1,\ntarget_ulong r2)\n{",
"int64_t t1 = extract64(r1, 0, 32);",
"int64_t t2 = extract64(r2, 0, 32);",
"int64_t result = t1 + t2;",
"return suov32(env, result);",
"}"
] | [
0,
0,
0,
0,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
20,770 | static void pcspk_class_initfn(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->realize = pcspk_realizefn;
set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
dc->no_user = 1;
dc->props = pcspk_properties;
}
| true | qemu | efec3dd631d94160288392721a5f9c39e50fb2bc | static void pcspk_class_initfn(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->realize = pcspk_realizefn;
set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
dc->no_user = 1;
dc->props = pcspk_properties;
}
| {
"code": [
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;"
],
"line_no": [
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13
]
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
dc->realize = pcspk_realizefn;
set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
dc->no_user = 1;
dc->props = pcspk_properties;
}
| [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"dc->realize = pcspk_realizefn;",
"set_bit(DEVICE_CATEGORY_SOUND, dc->categories);",
"dc->no_user = 1;",
"dc->props = pcspk_properties;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
20,771 | static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
{
AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
ZmbvContext * const c = avctx->priv_data;
int zret = Z_OK; // Zlib return code
int len = buf_size;
int hi_ver, lo_ver, ret;
uint8_t *tmp;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
/* parse header */
c->flags = buf[0];
buf++; len--;
if (c->flags & ZMBV_KEYFRAME) {
hi_ver = buf[0];
lo_ver = buf[1];
c->comp = buf[2];
c->fmt = buf[3];
c->bw = buf[4];
c->bh = buf[5];
c->decode_intra = NULL;
c->decode_xor = NULL;
buf += 6;
len -= 6;
av_log(avctx, AV_LOG_DEBUG,
"Flags=%X ver=%i.%i comp=%i fmt=%i blk=%ix%i\n",
c->flags,hi_ver,lo_ver,c->comp,c->fmt,c->bw,c->bh);
if (hi_ver != 0 || lo_ver != 1) {
avpriv_request_sample(avctx, "Version %i.%i", hi_ver, lo_ver);
return AVERROR_PATCHWELCOME;
}
if (c->bw == 0 || c->bh == 0) {
avpriv_request_sample(avctx, "Block size %ix%i", c->bw, c->bh);
return AVERROR_PATCHWELCOME;
}
if (c->comp != 0 && c->comp != 1) {
avpriv_request_sample(avctx, "Compression type %i", c->comp);
return AVERROR_PATCHWELCOME;
}
switch (c->fmt) {
case ZMBV_FMT_8BPP:
c->bpp = 8;
c->decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_8;
break;
case ZMBV_FMT_15BPP:
case ZMBV_FMT_16BPP:
c->bpp = 16;
c->decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_16;
break;
#ifdef ZMBV_ENABLE_24BPP
case ZMBV_FMT_24BPP:
c->bpp = 24;
c->decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_24;
break;
#endif //ZMBV_ENABLE_24BPP
case ZMBV_FMT_32BPP:
c->bpp = 32;
c->decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_32;
break;
default:
c->decode_intra = NULL;
c->decode_xor = NULL;
avpriv_request_sample(avctx, "Format %i", c->fmt);
return AVERROR_PATCHWELCOME;
}
zret = inflateReset(&c->zstream);
if (zret != Z_OK) {
av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret);
return AVERROR_UNKNOWN;
}
tmp = av_realloc(c->cur, avctx->width * avctx->height * (c->bpp / 8));
if (!tmp)
return AVERROR(ENOMEM);
c->cur = tmp;
tmp = av_realloc(c->prev, avctx->width * avctx->height * (c->bpp / 8));
if (!tmp)
return AVERROR(ENOMEM);
c->prev = tmp;
c->bx = (c->width + c->bw - 1) / c->bw;
c->by = (c->height + c->bh - 1) / c->bh;
}
if (c->decode_intra == NULL) {
av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n");
return AVERROR_INVALIDDATA;
}
if (c->comp == 0) { //Uncompressed data
if (c->decomp_size < len) {
av_log(avctx, AV_LOG_ERROR, "Buffer too small\n");
return AVERROR_INVALIDDATA;
}
memcpy(c->decomp_buf, buf, len);
} else { // ZLIB-compressed data
c->zstream.total_in = c->zstream.total_out = 0;
c->zstream.next_in = buf;
c->zstream.avail_in = len;
c->zstream.next_out = c->decomp_buf;
c->zstream.avail_out = c->decomp_size;
zret = inflate(&c->zstream, Z_SYNC_FLUSH);
if (zret != Z_OK && zret != Z_STREAM_END) {
av_log(avctx, AV_LOG_ERROR, "inflate error %d\n", zret);
return AVERROR_INVALIDDATA;
}
c->decomp_len = c->zstream.total_out;
}
if (c->flags & ZMBV_KEYFRAME) {
frame->key_frame = 1;
frame->pict_type = AV_PICTURE_TYPE_I;
c->decode_intra(c);
} else {
frame->key_frame = 0;
frame->pict_type = AV_PICTURE_TYPE_P;
if (c->decomp_len)
c->decode_xor(c);
}
/* update frames */
{
uint8_t *out, *src;
int i, j;
out = frame->data[0];
src = c->cur;
switch (c->fmt) {
case ZMBV_FMT_8BPP:
for (j = 0; j < c->height; j++) {
for (i = 0; i < c->width; i++) {
out[i * 3 + 0] = c->pal[(*src) * 3 + 0];
out[i * 3 + 1] = c->pal[(*src) * 3 + 1];
out[i * 3 + 2] = c->pal[(*src) * 3 + 2];
src++;
}
out += frame->linesize[0];
}
break;
case ZMBV_FMT_15BPP:
for (j = 0; j < c->height; j++) {
for (i = 0; i < c->width; i++) {
uint16_t tmp = AV_RL16(src);
src += 2;
out[i * 3 + 0] = (tmp & 0x7C00) >> 7;
out[i * 3 + 1] = (tmp & 0x03E0) >> 2;
out[i * 3 + 2] = (tmp & 0x001F) << 3;
}
out += frame->linesize[0];
}
break;
case ZMBV_FMT_16BPP:
for (j = 0; j < c->height; j++) {
for (i = 0; i < c->width; i++) {
uint16_t tmp = AV_RL16(src);
src += 2;
out[i * 3 + 0] = (tmp & 0xF800) >> 8;
out[i * 3 + 1] = (tmp & 0x07E0) >> 3;
out[i * 3 + 2] = (tmp & 0x001F) << 3;
}
out += frame->linesize[0];
}
break;
#ifdef ZMBV_ENABLE_24BPP
case ZMBV_FMT_24BPP:
for (j = 0; j < c->height; j++) {
memcpy(out, src, c->width * 3);
src += c->width * 3;
out += frame->linesize[0];
}
break;
#endif //ZMBV_ENABLE_24BPP
case ZMBV_FMT_32BPP:
for (j = 0; j < c->height; j++) {
for (i = 0; i < c->width; i++) {
uint32_t tmp = AV_RL32(src);
src += 4;
AV_WB24(out+(i*3), tmp);
}
out += frame->linesize[0];
}
break;
default:
av_log(avctx, AV_LOG_ERROR, "Cannot handle format %i\n", c->fmt);
}
FFSWAP(uint8_t *, c->cur, c->prev);
}
*got_frame = 1;
/* always report that the buffer was completely consumed */
return buf_size;
}
| false | FFmpeg | f929ab0569ff31ed5a59b0b0adb7ce09df3fca39 | static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
{
AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
ZmbvContext * const c = avctx->priv_data;
int zret = Z_OK;
int len = buf_size;
int hi_ver, lo_ver, ret;
uint8_t *tmp;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
c->flags = buf[0];
buf++; len--;
if (c->flags & ZMBV_KEYFRAME) {
hi_ver = buf[0];
lo_ver = buf[1];
c->comp = buf[2];
c->fmt = buf[3];
c->bw = buf[4];
c->bh = buf[5];
c->decode_intra = NULL;
c->decode_xor = NULL;
buf += 6;
len -= 6;
av_log(avctx, AV_LOG_DEBUG,
"Flags=%X ver=%i.%i comp=%i fmt=%i blk=%ix%i\n",
c->flags,hi_ver,lo_ver,c->comp,c->fmt,c->bw,c->bh);
if (hi_ver != 0 || lo_ver != 1) {
avpriv_request_sample(avctx, "Version %i.%i", hi_ver, lo_ver);
return AVERROR_PATCHWELCOME;
}
if (c->bw == 0 || c->bh == 0) {
avpriv_request_sample(avctx, "Block size %ix%i", c->bw, c->bh);
return AVERROR_PATCHWELCOME;
}
if (c->comp != 0 && c->comp != 1) {
avpriv_request_sample(avctx, "Compression type %i", c->comp);
return AVERROR_PATCHWELCOME;
}
switch (c->fmt) {
case ZMBV_FMT_8BPP:
c->bpp = 8;
c->decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_8;
break;
case ZMBV_FMT_15BPP:
case ZMBV_FMT_16BPP:
c->bpp = 16;
c->decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_16;
break;
#ifdef ZMBV_ENABLE_24BPP
case ZMBV_FMT_24BPP:
c->bpp = 24;
c->decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_24;
break;
#endif
case ZMBV_FMT_32BPP:
c->bpp = 32;
c->decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_32;
break;
default:
c->decode_intra = NULL;
c->decode_xor = NULL;
avpriv_request_sample(avctx, "Format %i", c->fmt);
return AVERROR_PATCHWELCOME;
}
zret = inflateReset(&c->zstream);
if (zret != Z_OK) {
av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret);
return AVERROR_UNKNOWN;
}
tmp = av_realloc(c->cur, avctx->width * avctx->height * (c->bpp / 8));
if (!tmp)
return AVERROR(ENOMEM);
c->cur = tmp;
tmp = av_realloc(c->prev, avctx->width * avctx->height * (c->bpp / 8));
if (!tmp)
return AVERROR(ENOMEM);
c->prev = tmp;
c->bx = (c->width + c->bw - 1) / c->bw;
c->by = (c->height + c->bh - 1) / c->bh;
}
if (c->decode_intra == NULL) {
av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n");
return AVERROR_INVALIDDATA;
}
if (c->comp == 0) {
if (c->decomp_size < len) {
av_log(avctx, AV_LOG_ERROR, "Buffer too small\n");
return AVERROR_INVALIDDATA;
}
memcpy(c->decomp_buf, buf, len);
} else {
c->zstream.total_in = c->zstream.total_out = 0;
c->zstream.next_in = buf;
c->zstream.avail_in = len;
c->zstream.next_out = c->decomp_buf;
c->zstream.avail_out = c->decomp_size;
zret = inflate(&c->zstream, Z_SYNC_FLUSH);
if (zret != Z_OK && zret != Z_STREAM_END) {
av_log(avctx, AV_LOG_ERROR, "inflate error %d\n", zret);
return AVERROR_INVALIDDATA;
}
c->decomp_len = c->zstream.total_out;
}
if (c->flags & ZMBV_KEYFRAME) {
frame->key_frame = 1;
frame->pict_type = AV_PICTURE_TYPE_I;
c->decode_intra(c);
} else {
frame->key_frame = 0;
frame->pict_type = AV_PICTURE_TYPE_P;
if (c->decomp_len)
c->decode_xor(c);
}
{
uint8_t *out, *src;
int i, j;
out = frame->data[0];
src = c->cur;
switch (c->fmt) {
case ZMBV_FMT_8BPP:
for (j = 0; j < c->height; j++) {
for (i = 0; i < c->width; i++) {
out[i * 3 + 0] = c->pal[(*src) * 3 + 0];
out[i * 3 + 1] = c->pal[(*src) * 3 + 1];
out[i * 3 + 2] = c->pal[(*src) * 3 + 2];
src++;
}
out += frame->linesize[0];
}
break;
case ZMBV_FMT_15BPP:
for (j = 0; j < c->height; j++) {
for (i = 0; i < c->width; i++) {
uint16_t tmp = AV_RL16(src);
src += 2;
out[i * 3 + 0] = (tmp & 0x7C00) >> 7;
out[i * 3 + 1] = (tmp & 0x03E0) >> 2;
out[i * 3 + 2] = (tmp & 0x001F) << 3;
}
out += frame->linesize[0];
}
break;
case ZMBV_FMT_16BPP:
for (j = 0; j < c->height; j++) {
for (i = 0; i < c->width; i++) {
uint16_t tmp = AV_RL16(src);
src += 2;
out[i * 3 + 0] = (tmp & 0xF800) >> 8;
out[i * 3 + 1] = (tmp & 0x07E0) >> 3;
out[i * 3 + 2] = (tmp & 0x001F) << 3;
}
out += frame->linesize[0];
}
break;
#ifdef ZMBV_ENABLE_24BPP
case ZMBV_FMT_24BPP:
for (j = 0; j < c->height; j++) {
memcpy(out, src, c->width * 3);
src += c->width * 3;
out += frame->linesize[0];
}
break;
#endif
case ZMBV_FMT_32BPP:
for (j = 0; j < c->height; j++) {
for (i = 0; i < c->width; i++) {
uint32_t tmp = AV_RL32(src);
src += 4;
AV_WB24(out+(i*3), tmp);
}
out += frame->linesize[0];
}
break;
default:
av_log(avctx, AV_LOG_ERROR, "Cannot handle format %i\n", c->fmt);
}
FFSWAP(uint8_t *, c->cur, c->prev);
}
*got_frame = 1;
return buf_size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, AVPacket *VAR_3)
{
AVFrame *frame = VAR_1;
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
ZmbvContext * const c = VAR_0->priv_data;
int VAR_6 = Z_OK;
int VAR_7 = VAR_5;
int VAR_8, VAR_9, VAR_10;
uint8_t *tmp;
if ((VAR_10 = ff_get_buffer(VAR_0, frame, 0)) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");
return VAR_10;
}
c->flags = VAR_4[0];
VAR_4++; VAR_7--;
if (c->flags & ZMBV_KEYFRAME) {
VAR_8 = VAR_4[0];
VAR_9 = VAR_4[1];
c->comp = VAR_4[2];
c->fmt = VAR_4[3];
c->bw = VAR_4[4];
c->bh = VAR_4[5];
c->decode_intra = NULL;
c->decode_xor = NULL;
VAR_4 += 6;
VAR_7 -= 6;
av_log(VAR_0, AV_LOG_DEBUG,
"Flags=%X ver=%VAR_11.%VAR_11 comp=%VAR_11 fmt=%VAR_11 blk=%ix%VAR_11\n",
c->flags,VAR_8,VAR_9,c->comp,c->fmt,c->bw,c->bh);
if (VAR_8 != 0 || VAR_9 != 1) {
avpriv_request_sample(VAR_0, "Version %VAR_11.%VAR_11", VAR_8, VAR_9);
return AVERROR_PATCHWELCOME;
}
if (c->bw == 0 || c->bh == 0) {
avpriv_request_sample(VAR_0, "Block size %ix%VAR_11", c->bw, c->bh);
return AVERROR_PATCHWELCOME;
}
if (c->comp != 0 && c->comp != 1) {
avpriv_request_sample(VAR_0, "Compression type %VAR_11", c->comp);
return AVERROR_PATCHWELCOME;
}
switch (c->fmt) {
case ZMBV_FMT_8BPP:
c->bpp = 8;
c->decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_8;
break;
case ZMBV_FMT_15BPP:
case ZMBV_FMT_16BPP:
c->bpp = 16;
c->decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_16;
break;
#ifdef ZMBV_ENABLE_24BPP
case ZMBV_FMT_24BPP:
c->bpp = 24;
c->decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_24;
break;
#endif
case ZMBV_FMT_32BPP:
c->bpp = 32;
c->decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_32;
break;
default:
c->decode_intra = NULL;
c->decode_xor = NULL;
avpriv_request_sample(VAR_0, "Format %VAR_11", c->fmt);
return AVERROR_PATCHWELCOME;
}
VAR_6 = inflateReset(&c->zstream);
if (VAR_6 != Z_OK) {
av_log(VAR_0, AV_LOG_ERROR, "Inflate reset error: %d\n", VAR_6);
return AVERROR_UNKNOWN;
}
tmp = av_realloc(c->cur, VAR_0->width * VAR_0->height * (c->bpp / 8));
if (!tmp)
return AVERROR(ENOMEM);
c->cur = tmp;
tmp = av_realloc(c->prev, VAR_0->width * VAR_0->height * (c->bpp / 8));
if (!tmp)
return AVERROR(ENOMEM);
c->prev = tmp;
c->bx = (c->width + c->bw - 1) / c->bw;
c->by = (c->height + c->bh - 1) / c->bh;
}
if (c->decode_intra == NULL) {
av_log(VAR_0, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n");
return AVERROR_INVALIDDATA;
}
if (c->comp == 0) {
if (c->decomp_size < VAR_7) {
av_log(VAR_0, AV_LOG_ERROR, "Buffer too small\n");
return AVERROR_INVALIDDATA;
}
memcpy(c->decomp_buf, VAR_4, VAR_7);
} else {
c->zstream.total_in = c->zstream.total_out = 0;
c->zstream.next_in = VAR_4;
c->zstream.avail_in = VAR_7;
c->zstream.next_out = c->decomp_buf;
c->zstream.avail_out = c->decomp_size;
VAR_6 = inflate(&c->zstream, Z_SYNC_FLUSH);
if (VAR_6 != Z_OK && VAR_6 != Z_STREAM_END) {
av_log(VAR_0, AV_LOG_ERROR, "inflate error %d\n", VAR_6);
return AVERROR_INVALIDDATA;
}
c->decomp_len = c->zstream.total_out;
}
if (c->flags & ZMBV_KEYFRAME) {
frame->key_frame = 1;
frame->pict_type = AV_PICTURE_TYPE_I;
c->decode_intra(c);
} else {
frame->key_frame = 0;
frame->pict_type = AV_PICTURE_TYPE_P;
if (c->decomp_len)
c->decode_xor(c);
}
{
uint8_t *out, *src;
int VAR_11, VAR_12;
out = frame->VAR_1[0];
src = c->cur;
switch (c->fmt) {
case ZMBV_FMT_8BPP:
for (VAR_12 = 0; VAR_12 < c->height; VAR_12++) {
for (VAR_11 = 0; VAR_11 < c->width; VAR_11++) {
out[VAR_11 * 3 + 0] = c->pal[(*src) * 3 + 0];
out[VAR_11 * 3 + 1] = c->pal[(*src) * 3 + 1];
out[VAR_11 * 3 + 2] = c->pal[(*src) * 3 + 2];
src++;
}
out += frame->linesize[0];
}
break;
case ZMBV_FMT_15BPP:
for (VAR_12 = 0; VAR_12 < c->height; VAR_12++) {
for (VAR_11 = 0; VAR_11 < c->width; VAR_11++) {
uint16_t tmp = AV_RL16(src);
src += 2;
out[VAR_11 * 3 + 0] = (tmp & 0x7C00) >> 7;
out[VAR_11 * 3 + 1] = (tmp & 0x03E0) >> 2;
out[VAR_11 * 3 + 2] = (tmp & 0x001F) << 3;
}
out += frame->linesize[0];
}
break;
case ZMBV_FMT_16BPP:
for (VAR_12 = 0; VAR_12 < c->height; VAR_12++) {
for (VAR_11 = 0; VAR_11 < c->width; VAR_11++) {
uint16_t tmp = AV_RL16(src);
src += 2;
out[VAR_11 * 3 + 0] = (tmp & 0xF800) >> 8;
out[VAR_11 * 3 + 1] = (tmp & 0x07E0) >> 3;
out[VAR_11 * 3 + 2] = (tmp & 0x001F) << 3;
}
out += frame->linesize[0];
}
break;
#ifdef ZMBV_ENABLE_24BPP
case ZMBV_FMT_24BPP:
for (VAR_12 = 0; VAR_12 < c->height; VAR_12++) {
memcpy(out, src, c->width * 3);
src += c->width * 3;
out += frame->linesize[0];
}
break;
#endif
case ZMBV_FMT_32BPP:
for (VAR_12 = 0; VAR_12 < c->height; VAR_12++) {
for (VAR_11 = 0; VAR_11 < c->width; VAR_11++) {
uint32_t tmp = AV_RL32(src);
src += 4;
AV_WB24(out+(VAR_11*3), tmp);
}
out += frame->linesize[0];
}
break;
default:
av_log(VAR_0, AV_LOG_ERROR, "Cannot handle format %VAR_11\n", c->fmt);
}
FFSWAP(uint8_t *, c->cur, c->prev);
}
*VAR_2 = 1;
return VAR_5;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, AVPacket *VAR_3)\n{",
"AVFrame *frame = VAR_1;",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"ZmbvContext * const c = VAR_0->priv_data;",
"int VAR_6 = Z_OK;",
"int VAR_7 = VAR_5;",
"int VAR_8, VAR_9, VAR_10;",
"uint8_t *tmp;",
"if ((VAR_10 = ff_get_buffer(VAR_0, frame, 0)) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\n\");",
"return VAR_10;",
"}",
"c->flags = VAR_4[0];",
"VAR_4++; VAR_7--;",
"if (c->flags & ZMBV_KEYFRAME) {",
"VAR_8 = VAR_4[0];",
"VAR_9 = VAR_4[1];",
"c->comp = VAR_4[2];",
"c->fmt = VAR_4[3];",
"c->bw = VAR_4[4];",
"c->bh = VAR_4[5];",
"c->decode_intra = NULL;",
"c->decode_xor = NULL;",
"VAR_4 += 6;",
"VAR_7 -= 6;",
"av_log(VAR_0, AV_LOG_DEBUG,\n\"Flags=%X ver=%VAR_11.%VAR_11 comp=%VAR_11 fmt=%VAR_11 blk=%ix%VAR_11\\n\",\nc->flags,VAR_8,VAR_9,c->comp,c->fmt,c->bw,c->bh);",
"if (VAR_8 != 0 || VAR_9 != 1) {",
"avpriv_request_sample(VAR_0, \"Version %VAR_11.%VAR_11\", VAR_8, VAR_9);",
"return AVERROR_PATCHWELCOME;",
"}",
"if (c->bw == 0 || c->bh == 0) {",
"avpriv_request_sample(VAR_0, \"Block size %ix%VAR_11\", c->bw, c->bh);",
"return AVERROR_PATCHWELCOME;",
"}",
"if (c->comp != 0 && c->comp != 1) {",
"avpriv_request_sample(VAR_0, \"Compression type %VAR_11\", c->comp);",
"return AVERROR_PATCHWELCOME;",
"}",
"switch (c->fmt) {",
"case ZMBV_FMT_8BPP:\nc->bpp = 8;",
"c->decode_intra = zmbv_decode_intra;",
"c->decode_xor = zmbv_decode_xor_8;",
"break;",
"case ZMBV_FMT_15BPP:\ncase ZMBV_FMT_16BPP:\nc->bpp = 16;",
"c->decode_intra = zmbv_decode_intra;",
"c->decode_xor = zmbv_decode_xor_16;",
"break;",
"#ifdef ZMBV_ENABLE_24BPP\ncase ZMBV_FMT_24BPP:\nc->bpp = 24;",
"c->decode_intra = zmbv_decode_intra;",
"c->decode_xor = zmbv_decode_xor_24;",
"break;",
"#endif\ncase ZMBV_FMT_32BPP:\nc->bpp = 32;",
"c->decode_intra = zmbv_decode_intra;",
"c->decode_xor = zmbv_decode_xor_32;",
"break;",
"default:\nc->decode_intra = NULL;",
"c->decode_xor = NULL;",
"avpriv_request_sample(VAR_0, \"Format %VAR_11\", c->fmt);",
"return AVERROR_PATCHWELCOME;",
"}",
"VAR_6 = inflateReset(&c->zstream);",
"if (VAR_6 != Z_OK) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Inflate reset error: %d\\n\", VAR_6);",
"return AVERROR_UNKNOWN;",
"}",
"tmp = av_realloc(c->cur, VAR_0->width * VAR_0->height * (c->bpp / 8));",
"if (!tmp)\nreturn AVERROR(ENOMEM);",
"c->cur = tmp;",
"tmp = av_realloc(c->prev, VAR_0->width * VAR_0->height * (c->bpp / 8));",
"if (!tmp)\nreturn AVERROR(ENOMEM);",
"c->prev = tmp;",
"c->bx = (c->width + c->bw - 1) / c->bw;",
"c->by = (c->height + c->bh - 1) / c->bh;",
"}",
"if (c->decode_intra == NULL) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error! Got no format or no keyframe!\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (c->comp == 0) {",
"if (c->decomp_size < VAR_7) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Buffer too small\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"memcpy(c->decomp_buf, VAR_4, VAR_7);",
"} else {",
"c->zstream.total_in = c->zstream.total_out = 0;",
"c->zstream.next_in = VAR_4;",
"c->zstream.avail_in = VAR_7;",
"c->zstream.next_out = c->decomp_buf;",
"c->zstream.avail_out = c->decomp_size;",
"VAR_6 = inflate(&c->zstream, Z_SYNC_FLUSH);",
"if (VAR_6 != Z_OK && VAR_6 != Z_STREAM_END) {",
"av_log(VAR_0, AV_LOG_ERROR, \"inflate error %d\\n\", VAR_6);",
"return AVERROR_INVALIDDATA;",
"}",
"c->decomp_len = c->zstream.total_out;",
"}",
"if (c->flags & ZMBV_KEYFRAME) {",
"frame->key_frame = 1;",
"frame->pict_type = AV_PICTURE_TYPE_I;",
"c->decode_intra(c);",
"} else {",
"frame->key_frame = 0;",
"frame->pict_type = AV_PICTURE_TYPE_P;",
"if (c->decomp_len)\nc->decode_xor(c);",
"}",
"{",
"uint8_t *out, *src;",
"int VAR_11, VAR_12;",
"out = frame->VAR_1[0];",
"src = c->cur;",
"switch (c->fmt) {",
"case ZMBV_FMT_8BPP:\nfor (VAR_12 = 0; VAR_12 < c->height; VAR_12++) {",
"for (VAR_11 = 0; VAR_11 < c->width; VAR_11++) {",
"out[VAR_11 * 3 + 0] = c->pal[(*src) * 3 + 0];",
"out[VAR_11 * 3 + 1] = c->pal[(*src) * 3 + 1];",
"out[VAR_11 * 3 + 2] = c->pal[(*src) * 3 + 2];",
"src++;",
"}",
"out += frame->linesize[0];",
"}",
"break;",
"case ZMBV_FMT_15BPP:\nfor (VAR_12 = 0; VAR_12 < c->height; VAR_12++) {",
"for (VAR_11 = 0; VAR_11 < c->width; VAR_11++) {",
"uint16_t tmp = AV_RL16(src);",
"src += 2;",
"out[VAR_11 * 3 + 0] = (tmp & 0x7C00) >> 7;",
"out[VAR_11 * 3 + 1] = (tmp & 0x03E0) >> 2;",
"out[VAR_11 * 3 + 2] = (tmp & 0x001F) << 3;",
"}",
"out += frame->linesize[0];",
"}",
"break;",
"case ZMBV_FMT_16BPP:\nfor (VAR_12 = 0; VAR_12 < c->height; VAR_12++) {",
"for (VAR_11 = 0; VAR_11 < c->width; VAR_11++) {",
"uint16_t tmp = AV_RL16(src);",
"src += 2;",
"out[VAR_11 * 3 + 0] = (tmp & 0xF800) >> 8;",
"out[VAR_11 * 3 + 1] = (tmp & 0x07E0) >> 3;",
"out[VAR_11 * 3 + 2] = (tmp & 0x001F) << 3;",
"}",
"out += frame->linesize[0];",
"}",
"break;",
"#ifdef ZMBV_ENABLE_24BPP\ncase ZMBV_FMT_24BPP:\nfor (VAR_12 = 0; VAR_12 < c->height; VAR_12++) {",
"memcpy(out, src, c->width * 3);",
"src += c->width * 3;",
"out += frame->linesize[0];",
"}",
"break;",
"#endif\ncase ZMBV_FMT_32BPP:\nfor (VAR_12 = 0; VAR_12 < c->height; VAR_12++) {",
"for (VAR_11 = 0; VAR_11 < c->width; VAR_11++) {",
"uint32_t tmp = AV_RL32(src);",
"src += 4;",
"AV_WB24(out+(VAR_11*3), tmp);",
"}",
"out += frame->linesize[0];",
"}",
"break;",
"default:\nav_log(VAR_0, AV_LOG_ERROR, \"Cannot handle format %VAR_11\\n\", c->fmt);",
"}",
"FFSWAP(uint8_t *, c->cur, c->prev);",
"}",
"*VAR_2 = 1;",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
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,
111
],
[
113
],
[
115
],
[
117
],
[
119,
121,
123
],
[
125
],
[
127
],
[
129
],
[
131,
133,
135
],
[
137
],
[
139
],
[
141
],
[
143,
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
171,
173
],
[
175
],
[
177
],
[
179,
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
193
],
[
195
],
[
197
],
[
199
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255,
257
],
[
259
],
[
265
],
[
267
],
[
269
],
[
273
],
[
275
],
[
277
],
[
279,
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301,
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325,
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349,
351,
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365,
367,
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387,
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
403
],
[
405
]
] |
20,774 | static int build_filter(ResampleContext *c, void *filter, double factor, int tap_count, int alloc, int phase_count, int scale,
int filter_type, double kaiser_beta){
int ph, i;
double x, y, w, t;
double *tab = av_malloc_array(tap_count+1, sizeof(*tab));
const int center= (tap_count-1)/2;
if (!tab)
return AVERROR(ENOMEM);
/* if upsampling, only need to interpolate, no filter */
if (factor > 1.0)
factor = 1.0;
av_assert0(phase_count == 1 || phase_count % 2 == 0);
for(ph = 0; ph <= phase_count / 2; ph++) {
double norm = 0;
for(i=0;i<=tap_count;i++) {
x = M_PI * ((double)(i - center) - (double)ph / phase_count) * factor;
if (x == 0) y = 1.0;
else y = sin(x) / x;
switch(filter_type){
case SWR_FILTER_TYPE_CUBIC:{
const float d= -0.5; //first order derivative = -0.5
x = fabs(((double)(i - center) - (double)ph / phase_count) * factor);
if(x<1.0) y= 1 - 3*x*x + 2*x*x*x + d*( -x*x + x*x*x);
else y= d*(-4 + 8*x - 5*x*x + x*x*x);
break;}
case SWR_FILTER_TYPE_BLACKMAN_NUTTALL:
w = 2.0*x / (factor*tap_count) + M_PI;
t = cos(w);
y *= 0.3635819 - 0.4891775 * t + 0.1365995 * (2*t*t-1) - 0.0106411 * (4*t*t*t - 3*t);
break;
case SWR_FILTER_TYPE_KAISER:
w = 2.0*x / (factor*tap_count*M_PI);
y *= bessel(kaiser_beta*sqrt(FFMAX(1-w*w, 0)));
break;
default:
av_assert0(0);
}
tab[i] = y;
if (i < tap_count)
norm += y;
}
/* normalize so that an uniform color remains the same */
switch(c->format){
case AV_SAMPLE_FMT_S16P:
for(i=0;i<tap_count;i++)
((int16_t*)filter)[ph * alloc + i] = av_clip(lrintf(tab[i] * scale / norm), INT16_MIN, INT16_MAX);
if (tap_count % 2 == 0) {
for (i = 0; i < tap_count; i++)
((int16_t*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((int16_t*)filter)[ph * alloc + i];
}
else {
for (i = 1; i <= tap_count; i++)
((int16_t*)filter)[(phase_count-ph) * alloc + tap_count-i] =
av_clip(lrintf(tab[i] * scale / (norm - tab[0] + tab[tap_count])), INT16_MIN, INT16_MAX);
}
break;
case AV_SAMPLE_FMT_S32P:
for(i=0;i<tap_count;i++)
((int32_t*)filter)[ph * alloc + i] = av_clipl_int32(llrint(tab[i] * scale / norm));
if (tap_count % 2 == 0) {
for (i = 0; i < tap_count; i++)
((int32_t*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((int32_t*)filter)[ph * alloc + i];
}
else {
for (i = 1; i <= tap_count; i++)
((int32_t*)filter)[(phase_count-ph) * alloc + tap_count-i] =
av_clipl_int32(llrint(tab[i] * scale / (norm - tab[0] + tab[tap_count])));
}
break;
case AV_SAMPLE_FMT_FLTP:
for(i=0;i<tap_count;i++)
((float*)filter)[ph * alloc + i] = tab[i] * scale / norm;
if (tap_count % 2 == 0) {
for (i = 0; i < tap_count; i++)
((float*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((float*)filter)[ph * alloc + i];
}
else {
for (i = 1; i <= tap_count; i++)
((float*)filter)[(phase_count-ph) * alloc + tap_count-i] = tab[i] * scale / (norm - tab[0] + tab[tap_count]);
}
break;
case AV_SAMPLE_FMT_DBLP:
for(i=0;i<tap_count;i++)
((double*)filter)[ph * alloc + i] = tab[i] * scale / norm;
if (tap_count % 2 == 0) {
for (i = 0; i < tap_count; i++)
((double*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((double*)filter)[ph * alloc + i];
}
else {
for (i = 1; i <= tap_count; i++)
((double*)filter)[(phase_count-ph) * alloc + tap_count-i] = tab[i] * scale / (norm - tab[0] + tab[tap_count]);
}
break;
}
}
#if 0
{
#define LEN 1024
int j,k;
double sine[LEN + tap_count];
double filtered[LEN];
double maxff=-2, minff=2, maxsf=-2, minsf=2;
for(i=0; i<LEN; i++){
double ss=0, sf=0, ff=0;
for(j=0; j<LEN+tap_count; j++)
sine[j]= cos(i*j*M_PI/LEN);
for(j=0; j<LEN; j++){
double sum=0;
ph=0;
for(k=0; k<tap_count; k++)
sum += filter[ph * tap_count + k] * sine[k+j];
filtered[j]= sum / (1<<FILTER_SHIFT);
ss+= sine[j + center] * sine[j + center];
ff+= filtered[j] * filtered[j];
sf+= sine[j + center] * filtered[j];
}
ss= sqrt(2*ss/LEN);
ff= sqrt(2*ff/LEN);
sf= 2*sf/LEN;
maxff= FFMAX(maxff, ff);
minff= FFMIN(minff, ff);
maxsf= FFMAX(maxsf, sf);
minsf= FFMIN(minsf, sf);
if(i%11==0){
av_log(NULL, AV_LOG_ERROR, "i:%4d ss:%f ff:%13.6e-%13.6e sf:%13.6e-%13.6e\n", i, ss, maxff, minff, maxsf, minsf);
minff=minsf= 2;
maxff=maxsf= -2;
}
}
}
#endif
av_free(tab);
return 0;
}
| false | FFmpeg | b87ca4bf25a3b5a0cac76fb8b3a7ab3bc0fd9882 | static int build_filter(ResampleContext *c, void *filter, double factor, int tap_count, int alloc, int phase_count, int scale,
int filter_type, double kaiser_beta){
int ph, i;
double x, y, w, t;
double *tab = av_malloc_array(tap_count+1, sizeof(*tab));
const int center= (tap_count-1)/2;
if (!tab)
return AVERROR(ENOMEM);
if (factor > 1.0)
factor = 1.0;
av_assert0(phase_count == 1 || phase_count % 2 == 0);
for(ph = 0; ph <= phase_count / 2; ph++) {
double norm = 0;
for(i=0;i<=tap_count;i++) {
x = M_PI * ((double)(i - center) - (double)ph / phase_count) * factor;
if (x == 0) y = 1.0;
else y = sin(x) / x;
switch(filter_type){
case SWR_FILTER_TYPE_CUBIC:{
const float d= -0.5;
x = fabs(((double)(i - center) - (double)ph / phase_count) * factor);
if(x<1.0) y= 1 - 3*x*x + 2*x*x*x + d*( -x*x + x*x*x);
else y= d*(-4 + 8*x - 5*x*x + x*x*x);
break;}
case SWR_FILTER_TYPE_BLACKMAN_NUTTALL:
w = 2.0*x / (factor*tap_count) + M_PI;
t = cos(w);
y *= 0.3635819 - 0.4891775 * t + 0.1365995 * (2*t*t-1) - 0.0106411 * (4*t*t*t - 3*t);
break;
case SWR_FILTER_TYPE_KAISER:
w = 2.0*x / (factor*tap_count*M_PI);
y *= bessel(kaiser_beta*sqrt(FFMAX(1-w*w, 0)));
break;
default:
av_assert0(0);
}
tab[i] = y;
if (i < tap_count)
norm += y;
}
switch(c->format){
case AV_SAMPLE_FMT_S16P:
for(i=0;i<tap_count;i++)
((int16_t*)filter)[ph * alloc + i] = av_clip(lrintf(tab[i] * scale / norm), INT16_MIN, INT16_MAX);
if (tap_count % 2 == 0) {
for (i = 0; i < tap_count; i++)
((int16_t*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((int16_t*)filter)[ph * alloc + i];
}
else {
for (i = 1; i <= tap_count; i++)
((int16_t*)filter)[(phase_count-ph) * alloc + tap_count-i] =
av_clip(lrintf(tab[i] * scale / (norm - tab[0] + tab[tap_count])), INT16_MIN, INT16_MAX);
}
break;
case AV_SAMPLE_FMT_S32P:
for(i=0;i<tap_count;i++)
((int32_t*)filter)[ph * alloc + i] = av_clipl_int32(llrint(tab[i] * scale / norm));
if (tap_count % 2 == 0) {
for (i = 0; i < tap_count; i++)
((int32_t*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((int32_t*)filter)[ph * alloc + i];
}
else {
for (i = 1; i <= tap_count; i++)
((int32_t*)filter)[(phase_count-ph) * alloc + tap_count-i] =
av_clipl_int32(llrint(tab[i] * scale / (norm - tab[0] + tab[tap_count])));
}
break;
case AV_SAMPLE_FMT_FLTP:
for(i=0;i<tap_count;i++)
((float*)filter)[ph * alloc + i] = tab[i] * scale / norm;
if (tap_count % 2 == 0) {
for (i = 0; i < tap_count; i++)
((float*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((float*)filter)[ph * alloc + i];
}
else {
for (i = 1; i <= tap_count; i++)
((float*)filter)[(phase_count-ph) * alloc + tap_count-i] = tab[i] * scale / (norm - tab[0] + tab[tap_count]);
}
break;
case AV_SAMPLE_FMT_DBLP:
for(i=0;i<tap_count;i++)
((double*)filter)[ph * alloc + i] = tab[i] * scale / norm;
if (tap_count % 2 == 0) {
for (i = 0; i < tap_count; i++)
((double*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((double*)filter)[ph * alloc + i];
}
else {
for (i = 1; i <= tap_count; i++)
((double*)filter)[(phase_count-ph) * alloc + tap_count-i] = tab[i] * scale / (norm - tab[0] + tab[tap_count]);
}
break;
}
}
#if 0
{
#define LEN 1024
int j,k;
double sine[LEN + tap_count];
double filtered[LEN];
double maxff=-2, minff=2, maxsf=-2, minsf=2;
for(i=0; i<LEN; i++){
double ss=0, sf=0, ff=0;
for(j=0; j<LEN+tap_count; j++)
sine[j]= cos(i*j*M_PI/LEN);
for(j=0; j<LEN; j++){
double sum=0;
ph=0;
for(k=0; k<tap_count; k++)
sum += filter[ph * tap_count + k] * sine[k+j];
filtered[j]= sum / (1<<FILTER_SHIFT);
ss+= sine[j + center] * sine[j + center];
ff+= filtered[j] * filtered[j];
sf+= sine[j + center] * filtered[j];
}
ss= sqrt(2*ss/LEN);
ff= sqrt(2*ff/LEN);
sf= 2*sf/LEN;
maxff= FFMAX(maxff, ff);
minff= FFMIN(minff, ff);
maxsf= FFMAX(maxsf, sf);
minsf= FFMIN(minsf, sf);
if(i%11==0){
av_log(NULL, AV_LOG_ERROR, "i:%4d ss:%f ff:%13.6e-%13.6e sf:%13.6e-%13.6e\n", i, ss, maxff, minff, maxsf, minsf);
minff=minsf= 2;
maxff=maxsf= -2;
}
}
}
#endif
av_free(tab);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(ResampleContext *VAR_0, void *VAR_1, double VAR_2, int VAR_3, int VAR_4, int VAR_5, int VAR_6,
int VAR_7, double VAR_8){
int VAR_9, VAR_10;
double VAR_11, VAR_12, VAR_13, VAR_14;
double *VAR_15 = av_malloc_array(VAR_3+1, sizeof(*VAR_15));
const int VAR_16= (VAR_3-1)/2;
if (!VAR_15)
return AVERROR(ENOMEM);
if (VAR_2 > 1.0)
VAR_2 = 1.0;
av_assert0(VAR_5 == 1 || VAR_5 % 2 == 0);
for(VAR_9 = 0; VAR_9 <= VAR_5 / 2; VAR_9++) {
double VAR_17 = 0;
for(VAR_10=0;VAR_10<=VAR_3;VAR_10++) {
VAR_11 = M_PI * ((double)(VAR_10 - VAR_16) - (double)VAR_9 / VAR_5) * VAR_2;
if (VAR_11 == 0) VAR_12 = 1.0;
else VAR_12 = sin(VAR_11) / VAR_11;
switch(VAR_7){
case SWR_FILTER_TYPE_CUBIC:{
const float VAR_18= -0.5;
VAR_11 = fabs(((double)(VAR_10 - VAR_16) - (double)VAR_9 / VAR_5) * VAR_2);
if(VAR_11<1.0) VAR_12= 1 - 3*VAR_11*VAR_11 + 2*VAR_11*VAR_11*VAR_11 + VAR_18*( -VAR_11*VAR_11 + VAR_11*VAR_11*VAR_11);
else VAR_12= VAR_18*(-4 + 8*VAR_11 - 5*VAR_11*VAR_11 + VAR_11*VAR_11*VAR_11);
break;}
case SWR_FILTER_TYPE_BLACKMAN_NUTTALL:
VAR_13 = 2.0*VAR_11 / (VAR_2*VAR_3) + M_PI;
VAR_14 = cos(VAR_13);
VAR_12 *= 0.3635819 - 0.4891775 * VAR_14 + 0.1365995 * (2*VAR_14*VAR_14-1) - 0.0106411 * (4*VAR_14*VAR_14*VAR_14 - 3*VAR_14);
break;
case SWR_FILTER_TYPE_KAISER:
VAR_13 = 2.0*VAR_11 / (VAR_2*VAR_3*M_PI);
VAR_12 *= bessel(VAR_8*sqrt(FFMAX(1-VAR_13*VAR_13, 0)));
break;
default:
av_assert0(0);
}
VAR_15[VAR_10] = VAR_12;
if (VAR_10 < VAR_3)
VAR_17 += VAR_12;
}
switch(VAR_0->format){
case AV_SAMPLE_FMT_S16P:
for(VAR_10=0;VAR_10<VAR_3;VAR_10++)
((int16_t*)VAR_1)[VAR_9 * VAR_4 + VAR_10] = av_clip(lrintf(VAR_15[VAR_10] * VAR_6 / VAR_17), INT16_MIN, INT16_MAX);
if (VAR_3 % 2 == 0) {
for (VAR_10 = 0; VAR_10 < VAR_3; VAR_10++)
((int16_t*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-1-VAR_10] = ((int16_t*)VAR_1)[VAR_9 * VAR_4 + VAR_10];
}
else {
for (VAR_10 = 1; VAR_10 <= VAR_3; VAR_10++)
((int16_t*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-VAR_10] =
av_clip(lrintf(VAR_15[VAR_10] * VAR_6 / (VAR_17 - VAR_15[0] + VAR_15[VAR_3])), INT16_MIN, INT16_MAX);
}
break;
case AV_SAMPLE_FMT_S32P:
for(VAR_10=0;VAR_10<VAR_3;VAR_10++)
((int32_t*)VAR_1)[VAR_9 * VAR_4 + VAR_10] = av_clipl_int32(llrint(VAR_15[VAR_10] * VAR_6 / VAR_17));
if (VAR_3 % 2 == 0) {
for (VAR_10 = 0; VAR_10 < VAR_3; VAR_10++)
((int32_t*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-1-VAR_10] = ((int32_t*)VAR_1)[VAR_9 * VAR_4 + VAR_10];
}
else {
for (VAR_10 = 1; VAR_10 <= VAR_3; VAR_10++)
((int32_t*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-VAR_10] =
av_clipl_int32(llrint(VAR_15[VAR_10] * VAR_6 / (VAR_17 - VAR_15[0] + VAR_15[VAR_3])));
}
break;
case AV_SAMPLE_FMT_FLTP:
for(VAR_10=0;VAR_10<VAR_3;VAR_10++)
((float*)VAR_1)[VAR_9 * VAR_4 + VAR_10] = VAR_15[VAR_10] * VAR_6 / VAR_17;
if (VAR_3 % 2 == 0) {
for (VAR_10 = 0; VAR_10 < VAR_3; VAR_10++)
((float*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-1-VAR_10] = ((float*)VAR_1)[VAR_9 * VAR_4 + VAR_10];
}
else {
for (VAR_10 = 1; VAR_10 <= VAR_3; VAR_10++)
((float*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-VAR_10] = VAR_15[VAR_10] * VAR_6 / (VAR_17 - VAR_15[0] + VAR_15[VAR_3]);
}
break;
case AV_SAMPLE_FMT_DBLP:
for(VAR_10=0;VAR_10<VAR_3;VAR_10++)
((double*)VAR_1)[VAR_9 * VAR_4 + VAR_10] = VAR_15[VAR_10] * VAR_6 / VAR_17;
if (VAR_3 % 2 == 0) {
for (VAR_10 = 0; VAR_10 < VAR_3; VAR_10++)
((double*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-1-VAR_10] = ((double*)VAR_1)[VAR_9 * VAR_4 + VAR_10];
}
else {
for (VAR_10 = 1; VAR_10 <= VAR_3; VAR_10++)
((double*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-VAR_10] = VAR_15[VAR_10] * VAR_6 / (VAR_17 - VAR_15[0] + VAR_15[VAR_3]);
}
break;
}
}
#if 0
{
#define LEN 1024
int j,k;
double sine[LEN + VAR_3];
double filtered[LEN];
double maxff=-2, minff=2, maxsf=-2, minsf=2;
for(VAR_10=0; VAR_10<LEN; VAR_10++){
double ss=0, sf=0, ff=0;
for(j=0; j<LEN+VAR_3; j++)
sine[j]= cos(VAR_10*j*M_PI/LEN);
for(j=0; j<LEN; j++){
double sum=0;
VAR_9=0;
for(k=0; k<VAR_3; k++)
sum += VAR_1[VAR_9 * VAR_3 + k] * sine[k+j];
filtered[j]= sum / (1<<FILTER_SHIFT);
ss+= sine[j + VAR_16] * sine[j + VAR_16];
ff+= filtered[j] * filtered[j];
sf+= sine[j + VAR_16] * filtered[j];
}
ss= sqrt(2*ss/LEN);
ff= sqrt(2*ff/LEN);
sf= 2*sf/LEN;
maxff= FFMAX(maxff, ff);
minff= FFMIN(minff, ff);
maxsf= FFMAX(maxsf, sf);
minsf= FFMIN(minsf, sf);
if(VAR_10%11==0){
av_log(NULL, AV_LOG_ERROR, "VAR_10:%4d ss:%f ff:%13.6e-%13.6e sf:%13.6e-%13.6e\n", VAR_10, ss, maxff, minff, maxsf, minsf);
minff=minsf= 2;
maxff=maxsf= -2;
}
}
}
#endif
av_free(VAR_15);
return 0;
}
| [
"static int FUNC_0(ResampleContext *VAR_0, void *VAR_1, double VAR_2, int VAR_3, int VAR_4, int VAR_5, int VAR_6,\nint VAR_7, double VAR_8){",
"int VAR_9, VAR_10;",
"double VAR_11, VAR_12, VAR_13, VAR_14;",
"double *VAR_15 = av_malloc_array(VAR_3+1, sizeof(*VAR_15));",
"const int VAR_16= (VAR_3-1)/2;",
"if (!VAR_15)\nreturn AVERROR(ENOMEM);",
"if (VAR_2 > 1.0)\nVAR_2 = 1.0;",
"av_assert0(VAR_5 == 1 || VAR_5 % 2 == 0);",
"for(VAR_9 = 0; VAR_9 <= VAR_5 / 2; VAR_9++) {",
"double VAR_17 = 0;",
"for(VAR_10=0;VAR_10<=VAR_3;VAR_10++) {",
"VAR_11 = M_PI * ((double)(VAR_10 - VAR_16) - (double)VAR_9 / VAR_5) * VAR_2;",
"if (VAR_11 == 0) VAR_12 = 1.0;",
"else VAR_12 = sin(VAR_11) / VAR_11;",
"switch(VAR_7){",
"case SWR_FILTER_TYPE_CUBIC:{",
"const float VAR_18= -0.5;",
"VAR_11 = fabs(((double)(VAR_10 - VAR_16) - (double)VAR_9 / VAR_5) * VAR_2);",
"if(VAR_11<1.0) VAR_12= 1 - 3*VAR_11*VAR_11 + 2*VAR_11*VAR_11*VAR_11 + VAR_18*( -VAR_11*VAR_11 + VAR_11*VAR_11*VAR_11);",
"else VAR_12= VAR_18*(-4 + 8*VAR_11 - 5*VAR_11*VAR_11 + VAR_11*VAR_11*VAR_11);",
"break;}",
"case SWR_FILTER_TYPE_BLACKMAN_NUTTALL:\nVAR_13 = 2.0*VAR_11 / (VAR_2*VAR_3) + M_PI;",
"VAR_14 = cos(VAR_13);",
"VAR_12 *= 0.3635819 - 0.4891775 * VAR_14 + 0.1365995 * (2*VAR_14*VAR_14-1) - 0.0106411 * (4*VAR_14*VAR_14*VAR_14 - 3*VAR_14);",
"break;",
"case SWR_FILTER_TYPE_KAISER:\nVAR_13 = 2.0*VAR_11 / (VAR_2*VAR_3*M_PI);",
"VAR_12 *= bessel(VAR_8*sqrt(FFMAX(1-VAR_13*VAR_13, 0)));",
"break;",
"default:\nav_assert0(0);",
"}",
"VAR_15[VAR_10] = VAR_12;",
"if (VAR_10 < VAR_3)\nVAR_17 += VAR_12;",
"}",
"switch(VAR_0->format){",
"case AV_SAMPLE_FMT_S16P:\nfor(VAR_10=0;VAR_10<VAR_3;VAR_10++)",
"((int16_t*)VAR_1)[VAR_9 * VAR_4 + VAR_10] = av_clip(lrintf(VAR_15[VAR_10] * VAR_6 / VAR_17), INT16_MIN, INT16_MAX);",
"if (VAR_3 % 2 == 0) {",
"for (VAR_10 = 0; VAR_10 < VAR_3; VAR_10++)",
"((int16_t*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-1-VAR_10] = ((int16_t*)VAR_1)[VAR_9 * VAR_4 + VAR_10];",
"}",
"else {",
"for (VAR_10 = 1; VAR_10 <= VAR_3; VAR_10++)",
"((int16_t*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-VAR_10] =\nav_clip(lrintf(VAR_15[VAR_10] * VAR_6 / (VAR_17 - VAR_15[0] + VAR_15[VAR_3])), INT16_MIN, INT16_MAX);",
"}",
"break;",
"case AV_SAMPLE_FMT_S32P:\nfor(VAR_10=0;VAR_10<VAR_3;VAR_10++)",
"((int32_t*)VAR_1)[VAR_9 * VAR_4 + VAR_10] = av_clipl_int32(llrint(VAR_15[VAR_10] * VAR_6 / VAR_17));",
"if (VAR_3 % 2 == 0) {",
"for (VAR_10 = 0; VAR_10 < VAR_3; VAR_10++)",
"((int32_t*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-1-VAR_10] = ((int32_t*)VAR_1)[VAR_9 * VAR_4 + VAR_10];",
"}",
"else {",
"for (VAR_10 = 1; VAR_10 <= VAR_3; VAR_10++)",
"((int32_t*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-VAR_10] =\nav_clipl_int32(llrint(VAR_15[VAR_10] * VAR_6 / (VAR_17 - VAR_15[0] + VAR_15[VAR_3])));",
"}",
"break;",
"case AV_SAMPLE_FMT_FLTP:\nfor(VAR_10=0;VAR_10<VAR_3;VAR_10++)",
"((float*)VAR_1)[VAR_9 * VAR_4 + VAR_10] = VAR_15[VAR_10] * VAR_6 / VAR_17;",
"if (VAR_3 % 2 == 0) {",
"for (VAR_10 = 0; VAR_10 < VAR_3; VAR_10++)",
"((float*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-1-VAR_10] = ((float*)VAR_1)[VAR_9 * VAR_4 + VAR_10];",
"}",
"else {",
"for (VAR_10 = 1; VAR_10 <= VAR_3; VAR_10++)",
"((float*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-VAR_10] = VAR_15[VAR_10] * VAR_6 / (VAR_17 - VAR_15[0] + VAR_15[VAR_3]);",
"}",
"break;",
"case AV_SAMPLE_FMT_DBLP:\nfor(VAR_10=0;VAR_10<VAR_3;VAR_10++)",
"((double*)VAR_1)[VAR_9 * VAR_4 + VAR_10] = VAR_15[VAR_10] * VAR_6 / VAR_17;",
"if (VAR_3 % 2 == 0) {",
"for (VAR_10 = 0; VAR_10 < VAR_3; VAR_10++)",
"((double*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-1-VAR_10] = ((double*)VAR_1)[VAR_9 * VAR_4 + VAR_10];",
"}",
"else {",
"for (VAR_10 = 1; VAR_10 <= VAR_3; VAR_10++)",
"((double*)VAR_1)[(VAR_5-VAR_9) * VAR_4 + VAR_3-VAR_10] = VAR_15[VAR_10] * VAR_6 / (VAR_17 - VAR_15[0] + VAR_15[VAR_3]);",
"}",
"break;",
"}",
"}",
"#if 0\n{",
"#define LEN 1024\nint j,k;",
"double sine[LEN + VAR_3];",
"double filtered[LEN];",
"double maxff=-2, minff=2, maxsf=-2, minsf=2;",
"for(VAR_10=0; VAR_10<LEN; VAR_10++){",
"double ss=0, sf=0, ff=0;",
"for(j=0; j<LEN+VAR_3; j++)",
"sine[j]= cos(VAR_10*j*M_PI/LEN);",
"for(j=0; j<LEN; j++){",
"double sum=0;",
"VAR_9=0;",
"for(k=0; k<VAR_3; k++)",
"sum += VAR_1[VAR_9 * VAR_3 + k] * sine[k+j];",
"filtered[j]= sum / (1<<FILTER_SHIFT);",
"ss+= sine[j + VAR_16] * sine[j + VAR_16];",
"ff+= filtered[j] * filtered[j];",
"sf+= sine[j + VAR_16] * filtered[j];",
"}",
"ss= sqrt(2*ss/LEN);",
"ff= sqrt(2*ff/LEN);",
"sf= 2*sf/LEN;",
"maxff= FFMAX(maxff, ff);",
"minff= FFMIN(minff, ff);",
"maxsf= FFMAX(maxsf, sf);",
"minsf= FFMIN(minsf, sf);",
"if(VAR_10%11==0){",
"av_log(NULL, AV_LOG_ERROR, \"VAR_10:%4d ss:%f ff:%13.6e-%13.6e sf:%13.6e-%13.6e\\n\", VAR_10, ss, maxff, minff, maxsf, minsf);",
"minff=minsf= 2;",
"maxff=maxsf= -2;",
"}",
"}",
"}",
"#endif\nav_free(VAR_15);",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
23,
25
],
[
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
],
[
83
],
[
85,
87
],
[
89
],
[
95
],
[
97,
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
123,
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141,
143
],
[
145
],
[
147
],
[
149,
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173,
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201,
203
],
[
205,
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271,
275
],
[
277
],
[
279
]
] |
20,775 | static void fft_test(AC3MDCTContext *mdct, AVLFG *lfg)
{
IComplex in[FN], in1[FN];
int k, n, i;
float sum_re, sum_im, a;
for (i = 0; i < FN; i++) {
in[i].re = av_lfg_get(lfg) % 65535 - 32767;
in[i].im = av_lfg_get(lfg) % 65535 - 32767;
in1[i] = in[i];
}
fft(mdct, in, 7);
/* do it by hand */
for (k = 0; k < FN; k++) {
sum_re = 0;
sum_im = 0;
for (n = 0; n < FN; n++) {
a = -2 * M_PI * (n * k) / FN;
sum_re += in1[n].re * cos(a) - in1[n].im * sin(a);
sum_im += in1[n].re * sin(a) + in1[n].im * cos(a);
}
av_log(NULL, AV_LOG_DEBUG, "%3d: %6d,%6d %6.0f,%6.0f\n",
k, in[k].re, in[k].im, sum_re / FN, sum_im / FN);
}
}
| false | FFmpeg | 79997def65fd2313b48a5f3c3a884c6149ae9b5d | static void fft_test(AC3MDCTContext *mdct, AVLFG *lfg)
{
IComplex in[FN], in1[FN];
int k, n, i;
float sum_re, sum_im, a;
for (i = 0; i < FN; i++) {
in[i].re = av_lfg_get(lfg) % 65535 - 32767;
in[i].im = av_lfg_get(lfg) % 65535 - 32767;
in1[i] = in[i];
}
fft(mdct, in, 7);
for (k = 0; k < FN; k++) {
sum_re = 0;
sum_im = 0;
for (n = 0; n < FN; n++) {
a = -2 * M_PI * (n * k) / FN;
sum_re += in1[n].re * cos(a) - in1[n].im * sin(a);
sum_im += in1[n].re * sin(a) + in1[n].im * cos(a);
}
av_log(NULL, AV_LOG_DEBUG, "%3d: %6d,%6d %6.0f,%6.0f\n",
k, in[k].re, in[k].im, sum_re / FN, sum_im / FN);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AC3MDCTContext *VAR_0, AVLFG *VAR_1)
{
IComplex in[FN], in1[FN];
int VAR_2, VAR_3, VAR_4;
float VAR_5, VAR_6, VAR_7;
for (VAR_4 = 0; VAR_4 < FN; VAR_4++) {
in[VAR_4].re = av_lfg_get(VAR_1) % 65535 - 32767;
in[VAR_4].im = av_lfg_get(VAR_1) % 65535 - 32767;
in1[VAR_4] = in[VAR_4];
}
fft(VAR_0, in, 7);
for (VAR_2 = 0; VAR_2 < FN; VAR_2++) {
VAR_5 = 0;
VAR_6 = 0;
for (VAR_3 = 0; VAR_3 < FN; VAR_3++) {
VAR_7 = -2 * M_PI * (VAR_3 * VAR_2) / FN;
VAR_5 += in1[VAR_3].re * cos(VAR_7) - in1[VAR_3].im * sin(VAR_7);
VAR_6 += in1[VAR_3].re * sin(VAR_7) + in1[VAR_3].im * cos(VAR_7);
}
av_log(NULL, AV_LOG_DEBUG, "%3d: %6d,%6d %6.0f,%6.0f\VAR_3",
VAR_2, in[VAR_2].re, in[VAR_2].im, VAR_5 / FN, VAR_6 / FN);
}
}
| [
"static void FUNC_0(AC3MDCTContext *VAR_0, AVLFG *VAR_1)\n{",
"IComplex in[FN], in1[FN];",
"int VAR_2, VAR_3, VAR_4;",
"float VAR_5, VAR_6, VAR_7;",
"for (VAR_4 = 0; VAR_4 < FN; VAR_4++) {",
"in[VAR_4].re = av_lfg_get(VAR_1) % 65535 - 32767;",
"in[VAR_4].im = av_lfg_get(VAR_1) % 65535 - 32767;",
"in1[VAR_4] = in[VAR_4];",
"}",
"fft(VAR_0, in, 7);",
"for (VAR_2 = 0; VAR_2 < FN; VAR_2++) {",
"VAR_5 = 0;",
"VAR_6 = 0;",
"for (VAR_3 = 0; VAR_3 < FN; VAR_3++) {",
"VAR_7 = -2 * M_PI * (VAR_3 * VAR_2) / FN;",
"VAR_5 += in1[VAR_3].re * cos(VAR_7) - in1[VAR_3].im * sin(VAR_7);",
"VAR_6 += in1[VAR_3].re * sin(VAR_7) + in1[VAR_3].im * cos(VAR_7);",
"}",
"av_log(NULL, AV_LOG_DEBUG, \"%3d: %6d,%6d %6.0f,%6.0f\\VAR_3\",\nVAR_2, in[VAR_2].re, in[VAR_2].im, VAR_5 / FN, VAR_6 / FN);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
]
] |
20,776 | static void correlate_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand *b, DWTELEM *src, int stride, int inverse, int use_median, int start_y, int end_y){
const int w= b->width;
int x,y;
// START_TIMER
DWTELEM * line;
DWTELEM * prev;
if (start_y != 0)
line = slice_buffer_get_line(sb, ((start_y - 1) * b->stride_line) + b->buf_y_offset) + b->buf_x_offset;
for(y=start_y; y<end_y; y++){
prev = line;
// line = slice_buffer_get_line_from_address(sb, src + (y * stride));
line = slice_buffer_get_line(sb, (y * b->stride_line) + b->buf_y_offset) + b->buf_x_offset;
for(x=0; x<w; x++){
if(x){
if(use_median){
if(y && x+1<w) line[x] += mid_pred(line[x - 1], prev[x], prev[x + 1]);
else line[x] += line[x - 1];
}else{
if(y) line[x] += mid_pred(line[x - 1], prev[x], line[x - 1] + prev[x] - prev[x - 1]);
else line[x] += line[x - 1];
}
}else{
if(y) line[x] += prev[x];
}
}
}
// STOP_TIMER("correlate")
}
| false | FFmpeg | b5bfb9f9de911846c43b52a7469b3cb413055492 | static void correlate_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand *b, DWTELEM *src, int stride, int inverse, int use_median, int start_y, int end_y){
const int w= b->width;
int x,y;
DWTELEM * line;
DWTELEM * prev;
if (start_y != 0)
line = slice_buffer_get_line(sb, ((start_y - 1) * b->stride_line) + b->buf_y_offset) + b->buf_x_offset;
for(y=start_y; y<end_y; y++){
prev = line;
line = slice_buffer_get_line(sb, (y * b->stride_line) + b->buf_y_offset) + b->buf_x_offset;
for(x=0; x<w; x++){
if(x){
if(use_median){
if(y && x+1<w) line[x] += mid_pred(line[x - 1], prev[x], prev[x + 1]);
else line[x] += line[x - 1];
}else{
if(y) line[x] += mid_pred(line[x - 1], prev[x], line[x - 1] + prev[x] - prev[x - 1]);
else line[x] += line[x - 1];
}
}else{
if(y) line[x] += prev[x];
}
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(SnowContext *VAR_0, slice_buffer * VAR_1, SubBand *VAR_2, DWTELEM *VAR_3, int VAR_4, int VAR_5, int VAR_6, int VAR_7, int VAR_8){
const int VAR_9= VAR_2->width;
int VAR_10,VAR_11;
DWTELEM * line;
DWTELEM * prev;
if (VAR_7 != 0)
line = slice_buffer_get_line(VAR_1, ((VAR_7 - 1) * VAR_2->stride_line) + VAR_2->buf_y_offset) + VAR_2->buf_x_offset;
for(VAR_11=VAR_7; VAR_11<VAR_8; VAR_11++){
prev = line;
line = slice_buffer_get_line(VAR_1, (VAR_11 * VAR_2->stride_line) + VAR_2->buf_y_offset) + VAR_2->buf_x_offset;
for(VAR_10=0; VAR_10<VAR_9; VAR_10++){
if(VAR_10){
if(VAR_6){
if(VAR_11 && VAR_10+1<VAR_9) line[VAR_10] += mid_pred(line[VAR_10 - 1], prev[VAR_10], prev[VAR_10 + 1]);
else line[VAR_10] += line[VAR_10 - 1];
}else{
if(VAR_11) line[VAR_10] += mid_pred(line[VAR_10 - 1], prev[VAR_10], line[VAR_10 - 1] + prev[VAR_10] - prev[VAR_10 - 1]);
else line[VAR_10] += line[VAR_10 - 1];
}
}else{
if(VAR_11) line[VAR_10] += prev[VAR_10];
}
}
}
}
| [
"static void FUNC_0(SnowContext *VAR_0, slice_buffer * VAR_1, SubBand *VAR_2, DWTELEM *VAR_3, int VAR_4, int VAR_5, int VAR_6, int VAR_7, int VAR_8){",
"const int VAR_9= VAR_2->width;",
"int VAR_10,VAR_11;",
"DWTELEM * line;",
"DWTELEM * prev;",
"if (VAR_7 != 0)\nline = slice_buffer_get_line(VAR_1, ((VAR_7 - 1) * VAR_2->stride_line) + VAR_2->buf_y_offset) + VAR_2->buf_x_offset;",
"for(VAR_11=VAR_7; VAR_11<VAR_8; VAR_11++){",
"prev = line;",
"line = slice_buffer_get_line(VAR_1, (VAR_11 * VAR_2->stride_line) + VAR_2->buf_y_offset) + VAR_2->buf_x_offset;",
"for(VAR_10=0; VAR_10<VAR_9; VAR_10++){",
"if(VAR_10){",
"if(VAR_6){",
"if(VAR_11 && VAR_10+1<VAR_9) line[VAR_10] += mid_pred(line[VAR_10 - 1], prev[VAR_10], prev[VAR_10 + 1]);",
"else line[VAR_10] += line[VAR_10 - 1];",
"}else{",
"if(VAR_11) line[VAR_10] += mid_pred(line[VAR_10 - 1], prev[VAR_10], line[VAR_10 - 1] + prev[VAR_10] - prev[VAR_10 - 1]);",
"else line[VAR_10] += line[VAR_10 - 1];",
"}",
"}else{",
"if(VAR_11) line[VAR_10] += prev[VAR_10];",
"}",
"}",
"}",
"}"
] | [
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
],
[
13
],
[
15
],
[
19,
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
65
]
] |
20,778 | static void rv34_idct_add_c(uint8_t *dst, ptrdiff_t stride, DCTELEM *block){
int temp[16];
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
int i;
rv34_row_transform(temp, block);
memset(block, 0, 16*sizeof(DCTELEM));
for(i = 0; i < 4; i++){
const int z0 = 13*(temp[4*0+i] + temp[4*2+i]) + 0x200;
const int z1 = 13*(temp[4*0+i] - temp[4*2+i]) + 0x200;
const int z2 = 7* temp[4*1+i] - 17*temp[4*3+i];
const int z3 = 17* temp[4*1+i] + 7*temp[4*3+i];
dst[0] = cm[ dst[0] + ( (z0 + z3) >> 10 ) ];
dst[1] = cm[ dst[1] + ( (z1 + z2) >> 10 ) ];
dst[2] = cm[ dst[2] + ( (z1 - z2) >> 10 ) ];
dst[3] = cm[ dst[3] + ( (z0 - z3) >> 10 ) ];
dst += stride;
}
}
| false | FFmpeg | fd88a257015f183f5ec3bff393a2f6cf7c117c02 | static void rv34_idct_add_c(uint8_t *dst, ptrdiff_t stride, DCTELEM *block){
int temp[16];
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
int i;
rv34_row_transform(temp, block);
memset(block, 0, 16*sizeof(DCTELEM));
for(i = 0; i < 4; i++){
const int z0 = 13*(temp[4*0+i] + temp[4*2+i]) + 0x200;
const int z1 = 13*(temp[4*0+i] - temp[4*2+i]) + 0x200;
const int z2 = 7* temp[4*1+i] - 17*temp[4*3+i];
const int z3 = 17* temp[4*1+i] + 7*temp[4*3+i];
dst[0] = cm[ dst[0] + ( (z0 + z3) >> 10 ) ];
dst[1] = cm[ dst[1] + ( (z1 + z2) >> 10 ) ];
dst[2] = cm[ dst[2] + ( (z1 - z2) >> 10 ) ];
dst[3] = cm[ dst[3] + ( (z0 - z3) >> 10 ) ];
dst += stride;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint8_t *VAR_0, ptrdiff_t VAR_1, DCTELEM *VAR_2){
int VAR_3[16];
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
int VAR_4;
rv34_row_transform(VAR_3, VAR_2);
memset(VAR_2, 0, 16*sizeof(DCTELEM));
for(VAR_4 = 0; VAR_4 < 4; VAR_4++){
const int VAR_5 = 13*(VAR_3[4*0+VAR_4] + VAR_3[4*2+VAR_4]) + 0x200;
const int VAR_6 = 13*(VAR_3[4*0+VAR_4] - VAR_3[4*2+VAR_4]) + 0x200;
const int VAR_7 = 7* VAR_3[4*1+VAR_4] - 17*VAR_3[4*3+VAR_4];
const int VAR_8 = 17* VAR_3[4*1+VAR_4] + 7*VAR_3[4*3+VAR_4];
VAR_0[0] = cm[ VAR_0[0] + ( (VAR_5 + VAR_8) >> 10 ) ];
VAR_0[1] = cm[ VAR_0[1] + ( (VAR_6 + VAR_7) >> 10 ) ];
VAR_0[2] = cm[ VAR_0[2] + ( (VAR_6 - VAR_7) >> 10 ) ];
VAR_0[3] = cm[ VAR_0[3] + ( (VAR_5 - VAR_8) >> 10 ) ];
VAR_0 += VAR_1;
}
}
| [
"static void FUNC_0(uint8_t *VAR_0, ptrdiff_t VAR_1, DCTELEM *VAR_2){",
"int VAR_3[16];",
"uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
"int VAR_4;",
"rv34_row_transform(VAR_3, VAR_2);",
"memset(VAR_2, 0, 16*sizeof(DCTELEM));",
"for(VAR_4 = 0; VAR_4 < 4; VAR_4++){",
"const int VAR_5 = 13*(VAR_3[4*0+VAR_4] + VAR_3[4*2+VAR_4]) + 0x200;",
"const int VAR_6 = 13*(VAR_3[4*0+VAR_4] - VAR_3[4*2+VAR_4]) + 0x200;",
"const int VAR_7 = 7* VAR_3[4*1+VAR_4] - 17*VAR_3[4*3+VAR_4];",
"const int VAR_8 = 17* VAR_3[4*1+VAR_4] + 7*VAR_3[4*3+VAR_4];",
"VAR_0[0] = cm[ VAR_0[0] + ( (VAR_5 + VAR_8) >> 10 ) ];",
"VAR_0[1] = cm[ VAR_0[1] + ( (VAR_6 + VAR_7) >> 10 ) ];",
"VAR_0[2] = cm[ VAR_0[2] + ( (VAR_6 - VAR_7) >> 10 ) ];",
"VAR_0[3] = cm[ VAR_0[3] + ( (VAR_5 - VAR_8) >> 10 ) ];",
"VAR_0 += VAR_1;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
]
] |
20,780 | int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
{
int pqindex, lowquant, status;
if (v->finterpflag)
v->interpfrm = get_bits1(gb);
if (!v->s.avctx->codec)
return -1;
if (v->s.avctx->codec_id == AV_CODEC_ID_MSS2)
v->respic =
v->rangered =
v->multires = get_bits(gb, 2) == 1;
else
skip_bits(gb, 2); //framecnt unused
v->rangeredfrm = 0;
if (v->rangered)
v->rangeredfrm = get_bits1(gb);
v->s.pict_type = get_bits1(gb);
if (v->s.avctx->max_b_frames) {
if (!v->s.pict_type) {
if (get_bits1(gb))
v->s.pict_type = AV_PICTURE_TYPE_I;
else
v->s.pict_type = AV_PICTURE_TYPE_B;
} else
v->s.pict_type = AV_PICTURE_TYPE_P;
} else
v->s.pict_type = v->s.pict_type ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
v->bi_type = 0;
if (v->s.pict_type == AV_PICTURE_TYPE_B) {
if (read_bfraction(v, gb) < 0)
return AVERROR_INVALIDDATA;
if (v->bfraction == 0) {
v->s.pict_type = AV_PICTURE_TYPE_BI;
}
}
if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI)
skip_bits(gb, 7); // skip buffer fullness
if (v->parse_only)
return 0;
/* calculate RND */
if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI)
v->rnd = 1;
if (v->s.pict_type == AV_PICTURE_TYPE_P)
v->rnd ^= 1;
/* Quantizer stuff */
pqindex = get_bits(gb, 5);
if (!pqindex)
return -1;
if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
v->pq = ff_vc1_pquant_table[0][pqindex];
else
v->pq = ff_vc1_pquant_table[1][pqindex];
v->pquantizer = 1;
if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
v->pquantizer = pqindex < 9;
if (v->quantizer_mode == QUANT_NON_UNIFORM)
v->pquantizer = 0;
v->pqindex = pqindex;
if (pqindex < 9)
v->halfpq = get_bits1(gb);
else
v->halfpq = 0;
if (v->quantizer_mode == QUANT_FRAME_EXPLICIT)
v->pquantizer = get_bits1(gb);
v->dquantfrm = 0;
if (v->extended_mv == 1)
v->mvrange = get_unary(gb, 0, 3);
v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13
v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11
v->range_x = 1 << (v->k_x - 1);
v->range_y = 1 << (v->k_y - 1);
if (v->multires && v->s.pict_type != AV_PICTURE_TYPE_B)
v->respic = get_bits(gb, 2);
if (v->res_x8 && (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI)) {
v->x8_type = get_bits1(gb);
} else
v->x8_type = 0;
av_dlog(v->s.avctx, "%c Frame: QP=[%i]%i (+%i/2) %i\n",
(v->s.pict_type == AV_PICTURE_TYPE_P) ? 'P' : ((v->s.pict_type == AV_PICTURE_TYPE_I) ? 'I' : 'B'),
pqindex, v->pq, v->halfpq, v->rangeredfrm);
if (v->first_pic_header_flag)
rotate_luts(v);
switch (v->s.pict_type) {
case AV_PICTURE_TYPE_P:
if (v->pq < 5) v->tt_index = 0;
else if (v->pq < 13) v->tt_index = 1;
else v->tt_index = 2;
lowquant = (v->pq > 12) ? 0 : 1;
v->mv_mode = ff_vc1_mv_pmode_table[lowquant][get_unary(gb, 1, 4)];
if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {
v->mv_mode2 = ff_vc1_mv_pmode_table2[lowquant][get_unary(gb, 1, 3)];
v->lumscale = get_bits(gb, 6);
v->lumshift = get_bits(gb, 6);
v->last_use_ic = 1;
/* fill lookup tables for intensity compensation */
INIT_LUT(v->lumscale, v->lumshift, v->last_luty[0], v->last_lutuv[0], 1);
INIT_LUT(v->lumscale, v->lumshift, v->last_luty[1], v->last_lutuv[1], 1);
}
v->qs_last = v->s.quarter_sample;
if (v->mv_mode == MV_PMODE_1MV_HPEL || v->mv_mode == MV_PMODE_1MV_HPEL_BILIN)
v->s.quarter_sample = 0;
else if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {
if (v->mv_mode2 == MV_PMODE_1MV_HPEL || v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN)
v->s.quarter_sample = 0;
else
v->s.quarter_sample = 1;
} else
v->s.quarter_sample = 1;
v->s.mspel = !(v->mv_mode == MV_PMODE_1MV_HPEL_BILIN || (v->mv_mode == MV_PMODE_INTENSITY_COMP && v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN));
if ((v->mv_mode == MV_PMODE_INTENSITY_COMP &&
v->mv_mode2 == MV_PMODE_MIXED_MV) ||
v->mv_mode == MV_PMODE_MIXED_MV) {
status = bitplane_decoding(v->mv_type_mb_plane, &v->mv_type_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
} else {
v->mv_type_is_raw = 0;
memset(v->mv_type_mb_plane, 0, v->s.mb_stride * v->s.mb_height);
}
status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
/* Hopefully this is correct for P frames */
v->s.mv_table_index = get_bits(gb, 2); //but using ff_vc1_ tables
v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)];
if (v->dquant) {
av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
vop_dquant_decoding(v);
}
v->ttfrm = 0; //FIXME Is that so ?
if (v->vstransform) {
v->ttmbf = get_bits1(gb);
if (v->ttmbf) {
v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)];
}
} else {
v->ttmbf = 1;
v->ttfrm = TT_8X8;
}
break;
case AV_PICTURE_TYPE_B:
if (v->pq < 5) v->tt_index = 0;
else if (v->pq < 13) v->tt_index = 1;
else v->tt_index = 2;
v->mv_mode = get_bits1(gb) ? MV_PMODE_1MV : MV_PMODE_1MV_HPEL_BILIN;
v->qs_last = v->s.quarter_sample;
v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV);
v->s.mspel = v->s.quarter_sample;
status = bitplane_decoding(v->direct_mb_plane, &v->dmb_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
v->s.mv_table_index = get_bits(gb, 2);
v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)];
if (v->dquant) {
av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
vop_dquant_decoding(v);
}
v->ttfrm = 0;
if (v->vstransform) {
v->ttmbf = get_bits1(gb);
if (v->ttmbf) {
v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)];
}
} else {
v->ttmbf = 1;
v->ttfrm = TT_8X8;
}
break;
}
if (!v->x8_type) {
/* AC Syntax */
v->c_ac_table_index = decode012(gb);
if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) {
v->y_ac_table_index = decode012(gb);
}
/* DC Syntax */
v->s.dc_table_index = get_bits1(gb);
}
if (v->s.pict_type == AV_PICTURE_TYPE_BI) {
v->s.pict_type = AV_PICTURE_TYPE_B;
v->bi_type = 1;
}
return 0;
} | true | FFmpeg | b51e9354772de446e8196dabf9aad1567b22f74d | int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
{
int pqindex, lowquant, status;
if (v->finterpflag)
v->interpfrm = get_bits1(gb);
if (!v->s.avctx->codec)
return -1;
if (v->s.avctx->codec_id == AV_CODEC_ID_MSS2)
v->respic =
v->rangered =
v->multires = get_bits(gb, 2) == 1;
else
skip_bits(gb, 2);
v->rangeredfrm = 0;
if (v->rangered)
v->rangeredfrm = get_bits1(gb);
v->s.pict_type = get_bits1(gb);
if (v->s.avctx->max_b_frames) {
if (!v->s.pict_type) {
if (get_bits1(gb))
v->s.pict_type = AV_PICTURE_TYPE_I;
else
v->s.pict_type = AV_PICTURE_TYPE_B;
} else
v->s.pict_type = AV_PICTURE_TYPE_P;
} else
v->s.pict_type = v->s.pict_type ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
v->bi_type = 0;
if (v->s.pict_type == AV_PICTURE_TYPE_B) {
if (read_bfraction(v, gb) < 0)
return AVERROR_INVALIDDATA;
if (v->bfraction == 0) {
v->s.pict_type = AV_PICTURE_TYPE_BI;
}
}
if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI)
skip_bits(gb, 7);
if (v->parse_only)
return 0;
if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI)
v->rnd = 1;
if (v->s.pict_type == AV_PICTURE_TYPE_P)
v->rnd ^= 1;
pqindex = get_bits(gb, 5);
if (!pqindex)
return -1;
if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
v->pq = ff_vc1_pquant_table[0][pqindex];
else
v->pq = ff_vc1_pquant_table[1][pqindex];
v->pquantizer = 1;
if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
v->pquantizer = pqindex < 9;
if (v->quantizer_mode == QUANT_NON_UNIFORM)
v->pquantizer = 0;
v->pqindex = pqindex;
if (pqindex < 9)
v->halfpq = get_bits1(gb);
else
v->halfpq = 0;
if (v->quantizer_mode == QUANT_FRAME_EXPLICIT)
v->pquantizer = get_bits1(gb);
v->dquantfrm = 0;
if (v->extended_mv == 1)
v->mvrange = get_unary(gb, 0, 3);
v->k_x = v->mvrange + 9 + (v->mvrange >> 1);
v->k_y = v->mvrange + 8;
v->range_x = 1 << (v->k_x - 1);
v->range_y = 1 << (v->k_y - 1);
if (v->multires && v->s.pict_type != AV_PICTURE_TYPE_B)
v->respic = get_bits(gb, 2);
if (v->res_x8 && (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI)) {
v->x8_type = get_bits1(gb);
} else
v->x8_type = 0;
av_dlog(v->s.avctx, "%c Frame: QP=[%i]%i (+%i/2) %i\n",
(v->s.pict_type == AV_PICTURE_TYPE_P) ? 'P' : ((v->s.pict_type == AV_PICTURE_TYPE_I) ? 'I' : 'B'),
pqindex, v->pq, v->halfpq, v->rangeredfrm);
if (v->first_pic_header_flag)
rotate_luts(v);
switch (v->s.pict_type) {
case AV_PICTURE_TYPE_P:
if (v->pq < 5) v->tt_index = 0;
else if (v->pq < 13) v->tt_index = 1;
else v->tt_index = 2;
lowquant = (v->pq > 12) ? 0 : 1;
v->mv_mode = ff_vc1_mv_pmode_table[lowquant][get_unary(gb, 1, 4)];
if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {
v->mv_mode2 = ff_vc1_mv_pmode_table2[lowquant][get_unary(gb, 1, 3)];
v->lumscale = get_bits(gb, 6);
v->lumshift = get_bits(gb, 6);
v->last_use_ic = 1;
INIT_LUT(v->lumscale, v->lumshift, v->last_luty[0], v->last_lutuv[0], 1);
INIT_LUT(v->lumscale, v->lumshift, v->last_luty[1], v->last_lutuv[1], 1);
}
v->qs_last = v->s.quarter_sample;
if (v->mv_mode == MV_PMODE_1MV_HPEL || v->mv_mode == MV_PMODE_1MV_HPEL_BILIN)
v->s.quarter_sample = 0;
else if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {
if (v->mv_mode2 == MV_PMODE_1MV_HPEL || v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN)
v->s.quarter_sample = 0;
else
v->s.quarter_sample = 1;
} else
v->s.quarter_sample = 1;
v->s.mspel = !(v->mv_mode == MV_PMODE_1MV_HPEL_BILIN || (v->mv_mode == MV_PMODE_INTENSITY_COMP && v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN));
if ((v->mv_mode == MV_PMODE_INTENSITY_COMP &&
v->mv_mode2 == MV_PMODE_MIXED_MV) ||
v->mv_mode == MV_PMODE_MIXED_MV) {
status = bitplane_decoding(v->mv_type_mb_plane, &v->mv_type_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
} else {
v->mv_type_is_raw = 0;
memset(v->mv_type_mb_plane, 0, v->s.mb_stride * v->s.mb_height);
}
status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
v->s.mv_table_index = get_bits(gb, 2);
v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)];
if (v->dquant) {
av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
vop_dquant_decoding(v);
}
v->ttfrm = 0;
if (v->vstransform) {
v->ttmbf = get_bits1(gb);
if (v->ttmbf) {
v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)];
}
} else {
v->ttmbf = 1;
v->ttfrm = TT_8X8;
}
break;
case AV_PICTURE_TYPE_B:
if (v->pq < 5) v->tt_index = 0;
else if (v->pq < 13) v->tt_index = 1;
else v->tt_index = 2;
v->mv_mode = get_bits1(gb) ? MV_PMODE_1MV : MV_PMODE_1MV_HPEL_BILIN;
v->qs_last = v->s.quarter_sample;
v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV);
v->s.mspel = v->s.quarter_sample;
status = bitplane_decoding(v->direct_mb_plane, &v->dmb_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);
if (status < 0)
return -1;
av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
v->s.mv_table_index = get_bits(gb, 2);
v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)];
if (v->dquant) {
av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
vop_dquant_decoding(v);
}
v->ttfrm = 0;
if (v->vstransform) {
v->ttmbf = get_bits1(gb);
if (v->ttmbf) {
v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)];
}
} else {
v->ttmbf = 1;
v->ttfrm = TT_8X8;
}
break;
}
if (!v->x8_type) {
v->c_ac_table_index = decode012(gb);
if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) {
v->y_ac_table_index = decode012(gb);
}
v->s.dc_table_index = get_bits1(gb);
}
if (v->s.pict_type == AV_PICTURE_TYPE_BI) {
v->s.pict_type = AV_PICTURE_TYPE_B;
v->bi_type = 1;
}
return 0;
} | {
"code": [],
"line_no": []
} | int FUNC_0(VC1Context *VAR_0, GetBitContext* VAR_1)
{
int VAR_2, VAR_3, VAR_4;
if (VAR_0->finterpflag)
VAR_0->interpfrm = get_bits1(VAR_1);
if (!VAR_0->s.avctx->codec)
return -1;
if (VAR_0->s.avctx->codec_id == AV_CODEC_ID_MSS2)
VAR_0->respic =
VAR_0->rangered =
VAR_0->multires = get_bits(VAR_1, 2) == 1;
else
skip_bits(VAR_1, 2);
VAR_0->rangeredfrm = 0;
if (VAR_0->rangered)
VAR_0->rangeredfrm = get_bits1(VAR_1);
VAR_0->s.pict_type = get_bits1(VAR_1);
if (VAR_0->s.avctx->max_b_frames) {
if (!VAR_0->s.pict_type) {
if (get_bits1(VAR_1))
VAR_0->s.pict_type = AV_PICTURE_TYPE_I;
else
VAR_0->s.pict_type = AV_PICTURE_TYPE_B;
} else
VAR_0->s.pict_type = AV_PICTURE_TYPE_P;
} else
VAR_0->s.pict_type = VAR_0->s.pict_type ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
VAR_0->bi_type = 0;
if (VAR_0->s.pict_type == AV_PICTURE_TYPE_B) {
if (read_bfraction(VAR_0, VAR_1) < 0)
return AVERROR_INVALIDDATA;
if (VAR_0->bfraction == 0) {
VAR_0->s.pict_type = AV_PICTURE_TYPE_BI;
}
}
if (VAR_0->s.pict_type == AV_PICTURE_TYPE_I || VAR_0->s.pict_type == AV_PICTURE_TYPE_BI)
skip_bits(VAR_1, 7);
if (VAR_0->parse_only)
return 0;
if (VAR_0->s.pict_type == AV_PICTURE_TYPE_I || VAR_0->s.pict_type == AV_PICTURE_TYPE_BI)
VAR_0->rnd = 1;
if (VAR_0->s.pict_type == AV_PICTURE_TYPE_P)
VAR_0->rnd ^= 1;
VAR_2 = get_bits(VAR_1, 5);
if (!VAR_2)
return -1;
if (VAR_0->quantizer_mode == QUANT_FRAME_IMPLICIT)
VAR_0->pq = ff_vc1_pquant_table[0][VAR_2];
else
VAR_0->pq = ff_vc1_pquant_table[1][VAR_2];
VAR_0->pquantizer = 1;
if (VAR_0->quantizer_mode == QUANT_FRAME_IMPLICIT)
VAR_0->pquantizer = VAR_2 < 9;
if (VAR_0->quantizer_mode == QUANT_NON_UNIFORM)
VAR_0->pquantizer = 0;
VAR_0->VAR_2 = VAR_2;
if (VAR_2 < 9)
VAR_0->halfpq = get_bits1(VAR_1);
else
VAR_0->halfpq = 0;
if (VAR_0->quantizer_mode == QUANT_FRAME_EXPLICIT)
VAR_0->pquantizer = get_bits1(VAR_1);
VAR_0->dquantfrm = 0;
if (VAR_0->extended_mv == 1)
VAR_0->mvrange = get_unary(VAR_1, 0, 3);
VAR_0->k_x = VAR_0->mvrange + 9 + (VAR_0->mvrange >> 1);
VAR_0->k_y = VAR_0->mvrange + 8;
VAR_0->range_x = 1 << (VAR_0->k_x - 1);
VAR_0->range_y = 1 << (VAR_0->k_y - 1);
if (VAR_0->multires && VAR_0->s.pict_type != AV_PICTURE_TYPE_B)
VAR_0->respic = get_bits(VAR_1, 2);
if (VAR_0->res_x8 && (VAR_0->s.pict_type == AV_PICTURE_TYPE_I || VAR_0->s.pict_type == AV_PICTURE_TYPE_BI)) {
VAR_0->x8_type = get_bits1(VAR_1);
} else
VAR_0->x8_type = 0;
av_dlog(VAR_0->s.avctx, "%c Frame: QP=[%i]%i (+%i/2) %i\n",
(VAR_0->s.pict_type == AV_PICTURE_TYPE_P) ? 'P' : ((VAR_0->s.pict_type == AV_PICTURE_TYPE_I) ? 'I' : 'B'),
VAR_2, VAR_0->pq, VAR_0->halfpq, VAR_0->rangeredfrm);
if (VAR_0->first_pic_header_flag)
rotate_luts(VAR_0);
switch (VAR_0->s.pict_type) {
case AV_PICTURE_TYPE_P:
if (VAR_0->pq < 5) VAR_0->tt_index = 0;
else if (VAR_0->pq < 13) VAR_0->tt_index = 1;
else VAR_0->tt_index = 2;
VAR_3 = (VAR_0->pq > 12) ? 0 : 1;
VAR_0->mv_mode = ff_vc1_mv_pmode_table[VAR_3][get_unary(VAR_1, 1, 4)];
if (VAR_0->mv_mode == MV_PMODE_INTENSITY_COMP) {
VAR_0->mv_mode2 = ff_vc1_mv_pmode_table2[VAR_3][get_unary(VAR_1, 1, 3)];
VAR_0->lumscale = get_bits(VAR_1, 6);
VAR_0->lumshift = get_bits(VAR_1, 6);
VAR_0->last_use_ic = 1;
INIT_LUT(VAR_0->lumscale, VAR_0->lumshift, VAR_0->last_luty[0], VAR_0->last_lutuv[0], 1);
INIT_LUT(VAR_0->lumscale, VAR_0->lumshift, VAR_0->last_luty[1], VAR_0->last_lutuv[1], 1);
}
VAR_0->qs_last = VAR_0->s.quarter_sample;
if (VAR_0->mv_mode == MV_PMODE_1MV_HPEL || VAR_0->mv_mode == MV_PMODE_1MV_HPEL_BILIN)
VAR_0->s.quarter_sample = 0;
else if (VAR_0->mv_mode == MV_PMODE_INTENSITY_COMP) {
if (VAR_0->mv_mode2 == MV_PMODE_1MV_HPEL || VAR_0->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN)
VAR_0->s.quarter_sample = 0;
else
VAR_0->s.quarter_sample = 1;
} else
VAR_0->s.quarter_sample = 1;
VAR_0->s.mspel = !(VAR_0->mv_mode == MV_PMODE_1MV_HPEL_BILIN || (VAR_0->mv_mode == MV_PMODE_INTENSITY_COMP && VAR_0->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN));
if ((VAR_0->mv_mode == MV_PMODE_INTENSITY_COMP &&
VAR_0->mv_mode2 == MV_PMODE_MIXED_MV) ||
VAR_0->mv_mode == MV_PMODE_MIXED_MV) {
VAR_4 = bitplane_decoding(VAR_0->mv_type_mb_plane, &VAR_0->mv_type_is_raw, VAR_0);
if (VAR_4 < 0)
return -1;
av_log(VAR_0->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: "
"Imode: %i, Invert: %i\n", VAR_4>>1, VAR_4&1);
} else {
VAR_0->mv_type_is_raw = 0;
memset(VAR_0->mv_type_mb_plane, 0, VAR_0->s.mb_stride * VAR_0->s.mb_height);
}
VAR_4 = bitplane_decoding(VAR_0->s.mbskip_table, &VAR_0->skip_is_raw, VAR_0);
if (VAR_4 < 0)
return -1;
av_log(VAR_0->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
"Imode: %i, Invert: %i\n", VAR_4>>1, VAR_4&1);
VAR_0->s.mv_table_index = get_bits(VAR_1, 2);
VAR_0->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(VAR_1, 2)];
if (VAR_0->dquant) {
av_log(VAR_0->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
vop_dquant_decoding(VAR_0);
}
VAR_0->ttfrm = 0;
if (VAR_0->vstransform) {
VAR_0->ttmbf = get_bits1(VAR_1);
if (VAR_0->ttmbf) {
VAR_0->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(VAR_1, 2)];
}
} else {
VAR_0->ttmbf = 1;
VAR_0->ttfrm = TT_8X8;
}
break;
case AV_PICTURE_TYPE_B:
if (VAR_0->pq < 5) VAR_0->tt_index = 0;
else if (VAR_0->pq < 13) VAR_0->tt_index = 1;
else VAR_0->tt_index = 2;
VAR_0->mv_mode = get_bits1(VAR_1) ? MV_PMODE_1MV : MV_PMODE_1MV_HPEL_BILIN;
VAR_0->qs_last = VAR_0->s.quarter_sample;
VAR_0->s.quarter_sample = (VAR_0->mv_mode == MV_PMODE_1MV);
VAR_0->s.mspel = VAR_0->s.quarter_sample;
VAR_4 = bitplane_decoding(VAR_0->direct_mb_plane, &VAR_0->dmb_is_raw, VAR_0);
if (VAR_4 < 0)
return -1;
av_log(VAR_0->s.avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: "
"Imode: %i, Invert: %i\n", VAR_4>>1, VAR_4&1);
VAR_4 = bitplane_decoding(VAR_0->s.mbskip_table, &VAR_0->skip_is_raw, VAR_0);
if (VAR_4 < 0)
return -1;
av_log(VAR_0->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
"Imode: %i, Invert: %i\n", VAR_4>>1, VAR_4&1);
VAR_0->s.mv_table_index = get_bits(VAR_1, 2);
VAR_0->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(VAR_1, 2)];
if (VAR_0->dquant) {
av_log(VAR_0->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
vop_dquant_decoding(VAR_0);
}
VAR_0->ttfrm = 0;
if (VAR_0->vstransform) {
VAR_0->ttmbf = get_bits1(VAR_1);
if (VAR_0->ttmbf) {
VAR_0->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(VAR_1, 2)];
}
} else {
VAR_0->ttmbf = 1;
VAR_0->ttfrm = TT_8X8;
}
break;
}
if (!VAR_0->x8_type) {
VAR_0->c_ac_table_index = decode012(VAR_1);
if (VAR_0->s.pict_type == AV_PICTURE_TYPE_I || VAR_0->s.pict_type == AV_PICTURE_TYPE_BI) {
VAR_0->y_ac_table_index = decode012(VAR_1);
}
VAR_0->s.dc_table_index = get_bits1(VAR_1);
}
if (VAR_0->s.pict_type == AV_PICTURE_TYPE_BI) {
VAR_0->s.pict_type = AV_PICTURE_TYPE_B;
VAR_0->bi_type = 1;
}
return 0;
} | [
"int FUNC_0(VC1Context *VAR_0, GetBitContext* VAR_1)\n{",
"int VAR_2, VAR_3, VAR_4;",
"if (VAR_0->finterpflag)\nVAR_0->interpfrm = get_bits1(VAR_1);",
"if (!VAR_0->s.avctx->codec)\nreturn -1;",
"if (VAR_0->s.avctx->codec_id == AV_CODEC_ID_MSS2)\nVAR_0->respic =\nVAR_0->rangered =\nVAR_0->multires = get_bits(VAR_1, 2) == 1;",
"else\nskip_bits(VAR_1, 2);",
"VAR_0->rangeredfrm = 0;",
"if (VAR_0->rangered)\nVAR_0->rangeredfrm = get_bits1(VAR_1);",
"VAR_0->s.pict_type = get_bits1(VAR_1);",
"if (VAR_0->s.avctx->max_b_frames) {",
"if (!VAR_0->s.pict_type) {",
"if (get_bits1(VAR_1))\nVAR_0->s.pict_type = AV_PICTURE_TYPE_I;",
"else\nVAR_0->s.pict_type = AV_PICTURE_TYPE_B;",
"} else",
"VAR_0->s.pict_type = AV_PICTURE_TYPE_P;",
"} else",
"VAR_0->s.pict_type = VAR_0->s.pict_type ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;",
"VAR_0->bi_type = 0;",
"if (VAR_0->s.pict_type == AV_PICTURE_TYPE_B) {",
"if (read_bfraction(VAR_0, VAR_1) < 0)\nreturn AVERROR_INVALIDDATA;",
"if (VAR_0->bfraction == 0) {",
"VAR_0->s.pict_type = AV_PICTURE_TYPE_BI;",
"}",
"}",
"if (VAR_0->s.pict_type == AV_PICTURE_TYPE_I || VAR_0->s.pict_type == AV_PICTURE_TYPE_BI)\nskip_bits(VAR_1, 7);",
"if (VAR_0->parse_only)\nreturn 0;",
"if (VAR_0->s.pict_type == AV_PICTURE_TYPE_I || VAR_0->s.pict_type == AV_PICTURE_TYPE_BI)\nVAR_0->rnd = 1;",
"if (VAR_0->s.pict_type == AV_PICTURE_TYPE_P)\nVAR_0->rnd ^= 1;",
"VAR_2 = get_bits(VAR_1, 5);",
"if (!VAR_2)\nreturn -1;",
"if (VAR_0->quantizer_mode == QUANT_FRAME_IMPLICIT)\nVAR_0->pq = ff_vc1_pquant_table[0][VAR_2];",
"else\nVAR_0->pq = ff_vc1_pquant_table[1][VAR_2];",
"VAR_0->pquantizer = 1;",
"if (VAR_0->quantizer_mode == QUANT_FRAME_IMPLICIT)\nVAR_0->pquantizer = VAR_2 < 9;",
"if (VAR_0->quantizer_mode == QUANT_NON_UNIFORM)\nVAR_0->pquantizer = 0;",
"VAR_0->VAR_2 = VAR_2;",
"if (VAR_2 < 9)\nVAR_0->halfpq = get_bits1(VAR_1);",
"else\nVAR_0->halfpq = 0;",
"if (VAR_0->quantizer_mode == QUANT_FRAME_EXPLICIT)\nVAR_0->pquantizer = get_bits1(VAR_1);",
"VAR_0->dquantfrm = 0;",
"if (VAR_0->extended_mv == 1)\nVAR_0->mvrange = get_unary(VAR_1, 0, 3);",
"VAR_0->k_x = VAR_0->mvrange + 9 + (VAR_0->mvrange >> 1);",
"VAR_0->k_y = VAR_0->mvrange + 8;",
"VAR_0->range_x = 1 << (VAR_0->k_x - 1);",
"VAR_0->range_y = 1 << (VAR_0->k_y - 1);",
"if (VAR_0->multires && VAR_0->s.pict_type != AV_PICTURE_TYPE_B)\nVAR_0->respic = get_bits(VAR_1, 2);",
"if (VAR_0->res_x8 && (VAR_0->s.pict_type == AV_PICTURE_TYPE_I || VAR_0->s.pict_type == AV_PICTURE_TYPE_BI)) {",
"VAR_0->x8_type = get_bits1(VAR_1);",
"} else",
"VAR_0->x8_type = 0;",
"av_dlog(VAR_0->s.avctx, \"%c Frame: QP=[%i]%i (+%i/2) %i\\n\",\n(VAR_0->s.pict_type == AV_PICTURE_TYPE_P) ? 'P' : ((VAR_0->s.pict_type == AV_PICTURE_TYPE_I) ? 'I' : 'B'),\nVAR_2, VAR_0->pq, VAR_0->halfpq, VAR_0->rangeredfrm);",
"if (VAR_0->first_pic_header_flag)\nrotate_luts(VAR_0);",
"switch (VAR_0->s.pict_type) {",
"case AV_PICTURE_TYPE_P:\nif (VAR_0->pq < 5) VAR_0->tt_index = 0;",
"else if (VAR_0->pq < 13) VAR_0->tt_index = 1;",
"else VAR_0->tt_index = 2;",
"VAR_3 = (VAR_0->pq > 12) ? 0 : 1;",
"VAR_0->mv_mode = ff_vc1_mv_pmode_table[VAR_3][get_unary(VAR_1, 1, 4)];",
"if (VAR_0->mv_mode == MV_PMODE_INTENSITY_COMP) {",
"VAR_0->mv_mode2 = ff_vc1_mv_pmode_table2[VAR_3][get_unary(VAR_1, 1, 3)];",
"VAR_0->lumscale = get_bits(VAR_1, 6);",
"VAR_0->lumshift = get_bits(VAR_1, 6);",
"VAR_0->last_use_ic = 1;",
"INIT_LUT(VAR_0->lumscale, VAR_0->lumshift, VAR_0->last_luty[0], VAR_0->last_lutuv[0], 1);",
"INIT_LUT(VAR_0->lumscale, VAR_0->lumshift, VAR_0->last_luty[1], VAR_0->last_lutuv[1], 1);",
"}",
"VAR_0->qs_last = VAR_0->s.quarter_sample;",
"if (VAR_0->mv_mode == MV_PMODE_1MV_HPEL || VAR_0->mv_mode == MV_PMODE_1MV_HPEL_BILIN)\nVAR_0->s.quarter_sample = 0;",
"else if (VAR_0->mv_mode == MV_PMODE_INTENSITY_COMP) {",
"if (VAR_0->mv_mode2 == MV_PMODE_1MV_HPEL || VAR_0->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN)\nVAR_0->s.quarter_sample = 0;",
"else\nVAR_0->s.quarter_sample = 1;",
"} else",
"VAR_0->s.quarter_sample = 1;",
"VAR_0->s.mspel = !(VAR_0->mv_mode == MV_PMODE_1MV_HPEL_BILIN || (VAR_0->mv_mode == MV_PMODE_INTENSITY_COMP && VAR_0->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN));",
"if ((VAR_0->mv_mode == MV_PMODE_INTENSITY_COMP &&\nVAR_0->mv_mode2 == MV_PMODE_MIXED_MV) ||\nVAR_0->mv_mode == MV_PMODE_MIXED_MV) {",
"VAR_4 = bitplane_decoding(VAR_0->mv_type_mb_plane, &VAR_0->mv_type_is_raw, VAR_0);",
"if (VAR_4 < 0)\nreturn -1;",
"av_log(VAR_0->s.avctx, AV_LOG_DEBUG, \"MB MV Type plane encoding: \"\n\"Imode: %i, Invert: %i\\n\", VAR_4>>1, VAR_4&1);",
"} else {",
"VAR_0->mv_type_is_raw = 0;",
"memset(VAR_0->mv_type_mb_plane, 0, VAR_0->s.mb_stride * VAR_0->s.mb_height);",
"}",
"VAR_4 = bitplane_decoding(VAR_0->s.mbskip_table, &VAR_0->skip_is_raw, VAR_0);",
"if (VAR_4 < 0)\nreturn -1;",
"av_log(VAR_0->s.avctx, AV_LOG_DEBUG, \"MB Skip plane encoding: \"\n\"Imode: %i, Invert: %i\\n\", VAR_4>>1, VAR_4&1);",
"VAR_0->s.mv_table_index = get_bits(VAR_1, 2);",
"VAR_0->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(VAR_1, 2)];",
"if (VAR_0->dquant) {",
"av_log(VAR_0->s.avctx, AV_LOG_DEBUG, \"VOP DQuant info\\n\");",
"vop_dquant_decoding(VAR_0);",
"}",
"VAR_0->ttfrm = 0;",
"if (VAR_0->vstransform) {",
"VAR_0->ttmbf = get_bits1(VAR_1);",
"if (VAR_0->ttmbf) {",
"VAR_0->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(VAR_1, 2)];",
"}",
"} else {",
"VAR_0->ttmbf = 1;",
"VAR_0->ttfrm = TT_8X8;",
"}",
"break;",
"case AV_PICTURE_TYPE_B:\nif (VAR_0->pq < 5) VAR_0->tt_index = 0;",
"else if (VAR_0->pq < 13) VAR_0->tt_index = 1;",
"else VAR_0->tt_index = 2;",
"VAR_0->mv_mode = get_bits1(VAR_1) ? MV_PMODE_1MV : MV_PMODE_1MV_HPEL_BILIN;",
"VAR_0->qs_last = VAR_0->s.quarter_sample;",
"VAR_0->s.quarter_sample = (VAR_0->mv_mode == MV_PMODE_1MV);",
"VAR_0->s.mspel = VAR_0->s.quarter_sample;",
"VAR_4 = bitplane_decoding(VAR_0->direct_mb_plane, &VAR_0->dmb_is_raw, VAR_0);",
"if (VAR_4 < 0)\nreturn -1;",
"av_log(VAR_0->s.avctx, AV_LOG_DEBUG, \"MB Direct Type plane encoding: \"\n\"Imode: %i, Invert: %i\\n\", VAR_4>>1, VAR_4&1);",
"VAR_4 = bitplane_decoding(VAR_0->s.mbskip_table, &VAR_0->skip_is_raw, VAR_0);",
"if (VAR_4 < 0)\nreturn -1;",
"av_log(VAR_0->s.avctx, AV_LOG_DEBUG, \"MB Skip plane encoding: \"\n\"Imode: %i, Invert: %i\\n\", VAR_4>>1, VAR_4&1);",
"VAR_0->s.mv_table_index = get_bits(VAR_1, 2);",
"VAR_0->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(VAR_1, 2)];",
"if (VAR_0->dquant) {",
"av_log(VAR_0->s.avctx, AV_LOG_DEBUG, \"VOP DQuant info\\n\");",
"vop_dquant_decoding(VAR_0);",
"}",
"VAR_0->ttfrm = 0;",
"if (VAR_0->vstransform) {",
"VAR_0->ttmbf = get_bits1(VAR_1);",
"if (VAR_0->ttmbf) {",
"VAR_0->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(VAR_1, 2)];",
"}",
"} else {",
"VAR_0->ttmbf = 1;",
"VAR_0->ttfrm = TT_8X8;",
"}",
"break;",
"}",
"if (!VAR_0->x8_type) {",
"VAR_0->c_ac_table_index = decode012(VAR_1);",
"if (VAR_0->s.pict_type == AV_PICTURE_TYPE_I || VAR_0->s.pict_type == AV_PICTURE_TYPE_BI) {",
"VAR_0->y_ac_table_index = decode012(VAR_1);",
"}",
"VAR_0->s.dc_table_index = get_bits1(VAR_1);",
"}",
"if (VAR_0->s.pict_type == AV_PICTURE_TYPE_BI) {",
"VAR_0->s.pict_type = AV_PICTURE_TYPE_B;",
"VAR_0->bi_type = 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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
11,
13
],
[
15,
17
],
[
19,
21,
23,
25
],
[
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,
79
],
[
83,
85
],
[
91,
93
],
[
95,
97
],
[
103
],
[
105,
107
],
[
109,
111
],
[
113,
115
],
[
119
],
[
121,
123
],
[
125,
127
],
[
129
],
[
131,
133
],
[
135,
137
],
[
139,
141
],
[
143
],
[
145,
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157,
159
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171,
173,
175
],
[
179,
181
],
[
185
],
[
187,
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221,
223
],
[
225
],
[
227,
229
],
[
231,
233
],
[
235
],
[
237
],
[
239
],
[
243,
245,
247
],
[
249
],
[
251,
253
],
[
255,
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269,
271
],
[
273,
275
],
[
281
],
[
283
],
[
287
],
[
289
],
[
291
],
[
293
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319,
321
],
[
323
],
[
325
],
[
329
],
[
331
],
[
333
],
[
335
],
[
339
],
[
341,
343
],
[
345,
347
],
[
349
],
[
351,
353
],
[
355,
357
],
[
361
],
[
363
],
[
367
],
[
369
],
[
371
],
[
373
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
403
],
[
407
],
[
409
],
[
411
],
[
413
],
[
417
],
[
419
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
]
] |
20,781 | static int mov_preroll_write_stbl_atoms(AVIOContext *pb, MOVTrack *track)
{
struct sgpd_entry {
int count;
int16_t roll_distance;
int group_description_index;
};
struct sgpd_entry *sgpd_entries = NULL;
int entries = -1;
int group = 0;
int i, j;
const int OPUS_SEEK_PREROLL_MS = 80;
int roll_samples = av_rescale_q(OPUS_SEEK_PREROLL_MS,
(AVRational){1, 1000},
(AVRational){1, 48000});
if (track->entry) {
sgpd_entries = av_malloc_array(track->entry, sizeof(*sgpd_entries));
if (!sgpd_entries)
return AVERROR(ENOMEM);
}
av_assert0(track->par->codec_id == AV_CODEC_ID_OPUS);
for (i = 0; i < track->entry; i++) {
int roll_samples_remaining = roll_samples;
int distance = 0;
for (j = i - 1; j >= 0; j--) {
roll_samples_remaining -= get_cluster_duration(track, j);
distance++;
if (roll_samples_remaining <= 0)
break;
}
/* We don't have enough preceeding samples to compute a valid
roll_distance here, so this sample can't be independently
decoded. */
if (roll_samples_remaining > 0)
distance = 0;
/* Verify distance is a minimum of 2 (60ms) packets and a maximum of
32 (2.5ms) packets. */
av_assert0(distance == 0 || (distance >= 2 && distance <= 32));
if (i && distance == sgpd_entries[entries].roll_distance) {
sgpd_entries[entries].count++;
} else {
entries++;
sgpd_entries[entries].count = 1;
sgpd_entries[entries].roll_distance = distance;
sgpd_entries[entries].group_description_index = distance ? ++group : 0;
}
}
entries++;
if (!group)
return 0;
/* Write sgpd tag */
avio_wb32(pb, 24 + (group * 2)); /* size */
ffio_wfourcc(pb, "sgpd");
avio_wb32(pb, 1 << 24); /* fullbox */
ffio_wfourcc(pb, "roll");
avio_wb32(pb, 2); /* default_length */
avio_wb32(pb, group); /* entry_count */
for (i = 0; i < entries; i++) {
if (sgpd_entries[i].group_description_index) {
avio_wb16(pb, -sgpd_entries[i].roll_distance); /* roll_distance */
}
}
/* Write sbgp tag */
avio_wb32(pb, 20 + (entries * 8)); /* size */
ffio_wfourcc(pb, "sbgp");
avio_wb32(pb, 0); /* fullbox */
ffio_wfourcc(pb, "roll");
avio_wb32(pb, entries); /* entry_count */
for (i = 0; i < entries; i++) {
avio_wb32(pb, sgpd_entries[i].count); /* sample_count */
avio_wb32(pb, sgpd_entries[i].group_description_index); /* group_description_index */
}
av_free(sgpd_entries);
return 0;
}
| true | FFmpeg | b905ba5bc18c89c7fccd8621795755644442ef19 | static int mov_preroll_write_stbl_atoms(AVIOContext *pb, MOVTrack *track)
{
struct sgpd_entry {
int count;
int16_t roll_distance;
int group_description_index;
};
struct sgpd_entry *sgpd_entries = NULL;
int entries = -1;
int group = 0;
int i, j;
const int OPUS_SEEK_PREROLL_MS = 80;
int roll_samples = av_rescale_q(OPUS_SEEK_PREROLL_MS,
(AVRational){1, 1000},
(AVRational){1, 48000});
if (track->entry) {
sgpd_entries = av_malloc_array(track->entry, sizeof(*sgpd_entries));
if (!sgpd_entries)
return AVERROR(ENOMEM);
}
av_assert0(track->par->codec_id == AV_CODEC_ID_OPUS);
for (i = 0; i < track->entry; i++) {
int roll_samples_remaining = roll_samples;
int distance = 0;
for (j = i - 1; j >= 0; j--) {
roll_samples_remaining -= get_cluster_duration(track, j);
distance++;
if (roll_samples_remaining <= 0)
break;
}
if (roll_samples_remaining > 0)
distance = 0;
av_assert0(distance == 0 || (distance >= 2 && distance <= 32));
if (i && distance == sgpd_entries[entries].roll_distance) {
sgpd_entries[entries].count++;
} else {
entries++;
sgpd_entries[entries].count = 1;
sgpd_entries[entries].roll_distance = distance;
sgpd_entries[entries].group_description_index = distance ? ++group : 0;
}
}
entries++;
if (!group)
return 0;
avio_wb32(pb, 24 + (group * 2));
ffio_wfourcc(pb, "sgpd");
avio_wb32(pb, 1 << 24);
ffio_wfourcc(pb, "roll");
avio_wb32(pb, 2);
avio_wb32(pb, group);
for (i = 0; i < entries; i++) {
if (sgpd_entries[i].group_description_index) {
avio_wb16(pb, -sgpd_entries[i].roll_distance);
}
}
avio_wb32(pb, 20 + (entries * 8));
ffio_wfourcc(pb, "sbgp");
avio_wb32(pb, 0);
ffio_wfourcc(pb, "roll");
avio_wb32(pb, entries);
for (i = 0; i < entries; i++) {
avio_wb32(pb, sgpd_entries[i].count);
avio_wb32(pb, sgpd_entries[i].group_description_index);
}
av_free(sgpd_entries);
return 0;
}
| {
"code": [
" if (!group)"
],
"line_no": [
109
]
} | static int FUNC_0(AVIOContext *VAR_0, MOVTrack *VAR_1)
{
struct sgpd_entry {
int count;
int16_t roll_distance;
int group_description_index;
};
struct sgpd_entry *VAR_2 = NULL;
int VAR_3 = -1;
int VAR_4 = 0;
int VAR_5, VAR_6;
const int VAR_7 = 80;
int VAR_8 = av_rescale_q(VAR_7,
(AVRational){1, 1000},
(AVRational){1, 48000});
if (VAR_1->entry) {
VAR_2 = av_malloc_array(VAR_1->entry, sizeof(*VAR_2));
if (!VAR_2)
return AVERROR(ENOMEM);
}
av_assert0(VAR_1->par->codec_id == AV_CODEC_ID_OPUS);
for (VAR_5 = 0; VAR_5 < VAR_1->entry; VAR_5++) {
int roll_samples_remaining = VAR_8;
int distance = 0;
for (VAR_6 = VAR_5 - 1; VAR_6 >= 0; VAR_6--) {
roll_samples_remaining -= get_cluster_duration(VAR_1, VAR_6);
distance++;
if (roll_samples_remaining <= 0)
break;
}
if (roll_samples_remaining > 0)
distance = 0;
av_assert0(distance == 0 || (distance >= 2 && distance <= 32));
if (VAR_5 && distance == VAR_2[VAR_3].roll_distance) {
VAR_2[VAR_3].count++;
} else {
VAR_3++;
VAR_2[VAR_3].count = 1;
VAR_2[VAR_3].roll_distance = distance;
VAR_2[VAR_3].group_description_index = distance ? ++VAR_4 : 0;
}
}
VAR_3++;
if (!VAR_4)
return 0;
avio_wb32(VAR_0, 24 + (VAR_4 * 2));
ffio_wfourcc(VAR_0, "sgpd");
avio_wb32(VAR_0, 1 << 24);
ffio_wfourcc(VAR_0, "roll");
avio_wb32(VAR_0, 2);
avio_wb32(VAR_0, VAR_4);
for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++) {
if (VAR_2[VAR_5].group_description_index) {
avio_wb16(VAR_0, -VAR_2[VAR_5].roll_distance);
}
}
avio_wb32(VAR_0, 20 + (VAR_3 * 8));
ffio_wfourcc(VAR_0, "sbgp");
avio_wb32(VAR_0, 0);
ffio_wfourcc(VAR_0, "roll");
avio_wb32(VAR_0, VAR_3);
for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++) {
avio_wb32(VAR_0, VAR_2[VAR_5].count);
avio_wb32(VAR_0, VAR_2[VAR_5].group_description_index);
}
av_free(VAR_2);
return 0;
}
| [
"static int FUNC_0(AVIOContext *VAR_0, MOVTrack *VAR_1)\n{",
"struct sgpd_entry {",
"int count;",
"int16_t roll_distance;",
"int group_description_index;",
"};",
"struct sgpd_entry *VAR_2 = NULL;",
"int VAR_3 = -1;",
"int VAR_4 = 0;",
"int VAR_5, VAR_6;",
"const int VAR_7 = 80;",
"int VAR_8 = av_rescale_q(VAR_7,\n(AVRational){1, 1000},",
"(AVRational){1, 48000});",
"if (VAR_1->entry) {",
"VAR_2 = av_malloc_array(VAR_1->entry, sizeof(*VAR_2));",
"if (!VAR_2)\nreturn AVERROR(ENOMEM);",
"}",
"av_assert0(VAR_1->par->codec_id == AV_CODEC_ID_OPUS);",
"for (VAR_5 = 0; VAR_5 < VAR_1->entry; VAR_5++) {",
"int roll_samples_remaining = VAR_8;",
"int distance = 0;",
"for (VAR_6 = VAR_5 - 1; VAR_6 >= 0; VAR_6--) {",
"roll_samples_remaining -= get_cluster_duration(VAR_1, VAR_6);",
"distance++;",
"if (roll_samples_remaining <= 0)\nbreak;",
"}",
"if (roll_samples_remaining > 0)\ndistance = 0;",
"av_assert0(distance == 0 || (distance >= 2 && distance <= 32));",
"if (VAR_5 && distance == VAR_2[VAR_3].roll_distance) {",
"VAR_2[VAR_3].count++;",
"} else {",
"VAR_3++;",
"VAR_2[VAR_3].count = 1;",
"VAR_2[VAR_3].roll_distance = distance;",
"VAR_2[VAR_3].group_description_index = distance ? ++VAR_4 : 0;",
"}",
"}",
"VAR_3++;",
"if (!VAR_4)\nreturn 0;",
"avio_wb32(VAR_0, 24 + (VAR_4 * 2));",
"ffio_wfourcc(VAR_0, \"sgpd\");",
"avio_wb32(VAR_0, 1 << 24);",
"ffio_wfourcc(VAR_0, \"roll\");",
"avio_wb32(VAR_0, 2);",
"avio_wb32(VAR_0, VAR_4);",
"for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++) {",
"if (VAR_2[VAR_5].group_description_index) {",
"avio_wb16(VAR_0, -VAR_2[VAR_5].roll_distance);",
"}",
"}",
"avio_wb32(VAR_0, 20 + (VAR_3 * 8));",
"ffio_wfourcc(VAR_0, \"sbgp\");",
"avio_wb32(VAR_0, 0);",
"ffio_wfourcc(VAR_0, \"roll\");",
"avio_wb32(VAR_0, VAR_3);",
"for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++) {",
"avio_wb32(VAR_0, VAR_2[VAR_5].count);",
"avio_wb32(VAR_0, VAR_2[VAR_5].group_description_index);",
"}",
"av_free(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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29,
31
],
[
33
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
77,
79
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109,
111
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
163
],
[
165
],
[
167
]
] |
20,782 | static av_always_inline void emulated_edge_mc(uint8_t *buf, const uint8_t *src,
ptrdiff_t linesize_arg,
int block_w, int block_h,
int src_x, int src_y,
int w, int h,
emu_edge_core_func *core_fn)
{
int start_y, start_x, end_y, end_x, src_y_add = 0;
int linesize = linesize_arg;
if(!w || !h)
return;
if (src_y >= h) {
src -= src_y*linesize;
src_y_add = h - 1;
src_y = h - 1;
} else if (src_y <= -block_h) {
src -= src_y*linesize;
src_y_add = 1 - block_h;
src_y = 1 - block_h;
}
if (src_x >= w) {
src += w - 1 - src_x;
src_x = w - 1;
} else if (src_x <= -block_w) {
src += 1 - block_w - src_x;
src_x = 1 - block_w;
}
start_y = FFMAX(0, -src_y);
start_x = FFMAX(0, -src_x);
end_y = FFMIN(block_h, h-src_y);
end_x = FFMIN(block_w, w-src_x);
av_assert2(start_x < end_x && block_w > 0);
av_assert2(start_y < end_y && block_h > 0);
// fill in the to-be-copied part plus all above/below
src += (src_y_add + start_y) * linesize + start_x;
buf += start_x;
core_fn(buf, src, linesize, start_y, end_y,
block_h, start_x, end_x, block_w);
}
| true | FFmpeg | 2ffead98ddd384f61cdf6b1cb3f36592f54cd34a | static av_always_inline void emulated_edge_mc(uint8_t *buf, const uint8_t *src,
ptrdiff_t linesize_arg,
int block_w, int block_h,
int src_x, int src_y,
int w, int h,
emu_edge_core_func *core_fn)
{
int start_y, start_x, end_y, end_x, src_y_add = 0;
int linesize = linesize_arg;
if(!w || !h)
return;
if (src_y >= h) {
src -= src_y*linesize;
src_y_add = h - 1;
src_y = h - 1;
} else if (src_y <= -block_h) {
src -= src_y*linesize;
src_y_add = 1 - block_h;
src_y = 1 - block_h;
}
if (src_x >= w) {
src += w - 1 - src_x;
src_x = w - 1;
} else if (src_x <= -block_w) {
src += 1 - block_w - src_x;
src_x = 1 - block_w;
}
start_y = FFMAX(0, -src_y);
start_x = FFMAX(0, -src_x);
end_y = FFMIN(block_h, h-src_y);
end_x = FFMIN(block_w, w-src_x);
av_assert2(start_x < end_x && block_w > 0);
av_assert2(start_y < end_y && block_h > 0);
src += (src_y_add + start_y) * linesize + start_x;
buf += start_x;
core_fn(buf, src, linesize, start_y, end_y,
block_h, start_x, end_x, block_w);
}
| {
"code": [
" int linesize = linesize_arg;",
" int linesize = linesize_arg;"
],
"line_no": [
17,
17
]
} | static av_always_inline void FUNC_0(uint8_t *buf, const uint8_t *src,
ptrdiff_t linesize_arg,
int block_w, int block_h,
int src_x, int src_y,
int w, int h,
emu_edge_core_func *core_fn)
{
int VAR_0, VAR_1, VAR_2, VAR_3, VAR_4 = 0;
int VAR_5 = linesize_arg;
if(!w || !h)
return;
if (src_y >= h) {
src -= src_y*VAR_5;
VAR_4 = h - 1;
src_y = h - 1;
} else if (src_y <= -block_h) {
src -= src_y*VAR_5;
VAR_4 = 1 - block_h;
src_y = 1 - block_h;
}
if (src_x >= w) {
src += w - 1 - src_x;
src_x = w - 1;
} else if (src_x <= -block_w) {
src += 1 - block_w - src_x;
src_x = 1 - block_w;
}
VAR_0 = FFMAX(0, -src_y);
VAR_1 = FFMAX(0, -src_x);
VAR_2 = FFMIN(block_h, h-src_y);
VAR_3 = FFMIN(block_w, w-src_x);
av_assert2(VAR_1 < VAR_3 && block_w > 0);
av_assert2(VAR_0 < VAR_2 && block_h > 0);
src += (VAR_4 + VAR_0) * VAR_5 + VAR_1;
buf += VAR_1;
core_fn(buf, src, VAR_5, VAR_0, VAR_2,
block_h, VAR_1, VAR_3, block_w);
}
| [
"static av_always_inline void FUNC_0(uint8_t *buf, const uint8_t *src,\nptrdiff_t linesize_arg,\nint block_w, int block_h,\nint src_x, int src_y,\nint w, int h,\nemu_edge_core_func *core_fn)\n{",
"int VAR_0, VAR_1, VAR_2, VAR_3, VAR_4 = 0;",
"int VAR_5 = linesize_arg;",
"if(!w || !h)\nreturn;",
"if (src_y >= h) {",
"src -= src_y*VAR_5;",
"VAR_4 = h - 1;",
"src_y = h - 1;",
"} else if (src_y <= -block_h) {",
"src -= src_y*VAR_5;",
"VAR_4 = 1 - block_h;",
"src_y = 1 - block_h;",
"}",
"if (src_x >= w) {",
"src += w - 1 - src_x;",
"src_x = w - 1;",
"} else if (src_x <= -block_w) {",
"src += 1 - block_w - src_x;",
"src_x = 1 - block_w;",
"}",
"VAR_0 = FFMAX(0, -src_y);",
"VAR_1 = FFMAX(0, -src_x);",
"VAR_2 = FFMIN(block_h, h-src_y);",
"VAR_3 = FFMIN(block_w, w-src_x);",
"av_assert2(VAR_1 < VAR_3 && block_w > 0);",
"av_assert2(VAR_0 < VAR_2 && block_h > 0);",
"src += (VAR_4 + VAR_0) * VAR_5 + VAR_1;",
"buf += VAR_1;",
"core_fn(buf, src, VAR_5, VAR_0, VAR_2,\nblock_h, VAR_1, VAR_3, block_w);",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
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
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
77
],
[
79
],
[
81,
83
],
[
85
]
] |
20,783 | static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent,
Error **errp)
{
int ret;
int l1_size, i;
/* read the L1 table */
l1_size = extent->l1_size * sizeof(uint32_t);
extent->l1_table = g_try_malloc(l1_size);
if (l1_size && extent->l1_table == NULL) {
return -ENOMEM;
}
ret = bdrv_pread(extent->file,
extent->l1_table_offset,
extent->l1_table,
l1_size);
if (ret < 0) {
error_setg_errno(errp, -ret,
"Could not read l1 table from extent '%s'",
extent->file->filename);
goto fail_l1;
}
for (i = 0; i < extent->l1_size; i++) {
le32_to_cpus(&extent->l1_table[i]);
}
if (extent->l1_backup_table_offset) {
extent->l1_backup_table = g_try_malloc(l1_size);
if (l1_size && extent->l1_backup_table == NULL) {
ret = -ENOMEM;
goto fail_l1;
}
ret = bdrv_pread(extent->file,
extent->l1_backup_table_offset,
extent->l1_backup_table,
l1_size);
if (ret < 0) {
error_setg_errno(errp, -ret,
"Could not read l1 backup table from extent '%s'",
extent->file->filename);
goto fail_l1b;
}
for (i = 0; i < extent->l1_size; i++) {
le32_to_cpus(&extent->l1_backup_table[i]);
}
}
extent->l2_cache =
g_new(uint32_t, extent->l2_size * L2_CACHE_SIZE);
return 0;
fail_l1b:
g_free(extent->l1_backup_table);
fail_l1:
g_free(extent->l1_table);
return ret;
}
| true | qemu | 13c4941cdd8685d28c7e3a09e393a5579b58db46 | static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent,
Error **errp)
{
int ret;
int l1_size, i;
l1_size = extent->l1_size * sizeof(uint32_t);
extent->l1_table = g_try_malloc(l1_size);
if (l1_size && extent->l1_table == NULL) {
return -ENOMEM;
}
ret = bdrv_pread(extent->file,
extent->l1_table_offset,
extent->l1_table,
l1_size);
if (ret < 0) {
error_setg_errno(errp, -ret,
"Could not read l1 table from extent '%s'",
extent->file->filename);
goto fail_l1;
}
for (i = 0; i < extent->l1_size; i++) {
le32_to_cpus(&extent->l1_table[i]);
}
if (extent->l1_backup_table_offset) {
extent->l1_backup_table = g_try_malloc(l1_size);
if (l1_size && extent->l1_backup_table == NULL) {
ret = -ENOMEM;
goto fail_l1;
}
ret = bdrv_pread(extent->file,
extent->l1_backup_table_offset,
extent->l1_backup_table,
l1_size);
if (ret < 0) {
error_setg_errno(errp, -ret,
"Could not read l1 backup table from extent '%s'",
extent->file->filename);
goto fail_l1b;
}
for (i = 0; i < extent->l1_size; i++) {
le32_to_cpus(&extent->l1_backup_table[i]);
}
}
extent->l2_cache =
g_new(uint32_t, extent->l2_size * L2_CACHE_SIZE);
return 0;
fail_l1b:
g_free(extent->l1_backup_table);
fail_l1:
g_free(extent->l1_table);
return ret;
}
| {
"code": [
" int l1_size, i;"
],
"line_no": [
9
]
} | static int FUNC_0(BlockDriverState *VAR_0, VmdkExtent *VAR_1,
Error **VAR_2)
{
int VAR_3;
int VAR_4, VAR_5;
VAR_4 = VAR_1->VAR_4 * sizeof(uint32_t);
VAR_1->l1_table = g_try_malloc(VAR_4);
if (VAR_4 && VAR_1->l1_table == NULL) {
return -ENOMEM;
}
VAR_3 = bdrv_pread(VAR_1->file,
VAR_1->l1_table_offset,
VAR_1->l1_table,
VAR_4);
if (VAR_3 < 0) {
error_setg_errno(VAR_2, -VAR_3,
"Could not read l1 table from VAR_1 '%s'",
VAR_1->file->filename);
goto fail_l1;
}
for (VAR_5 = 0; VAR_5 < VAR_1->VAR_4; VAR_5++) {
le32_to_cpus(&VAR_1->l1_table[VAR_5]);
}
if (VAR_1->l1_backup_table_offset) {
VAR_1->l1_backup_table = g_try_malloc(VAR_4);
if (VAR_4 && VAR_1->l1_backup_table == NULL) {
VAR_3 = -ENOMEM;
goto fail_l1;
}
VAR_3 = bdrv_pread(VAR_1->file,
VAR_1->l1_backup_table_offset,
VAR_1->l1_backup_table,
VAR_4);
if (VAR_3 < 0) {
error_setg_errno(VAR_2, -VAR_3,
"Could not read l1 backup table from VAR_1 '%s'",
VAR_1->file->filename);
goto fail_l1b;
}
for (VAR_5 = 0; VAR_5 < VAR_1->VAR_4; VAR_5++) {
le32_to_cpus(&VAR_1->l1_backup_table[VAR_5]);
}
}
VAR_1->l2_cache =
g_new(uint32_t, VAR_1->l2_size * L2_CACHE_SIZE);
return 0;
fail_l1b:
g_free(VAR_1->l1_backup_table);
fail_l1:
g_free(VAR_1->l1_table);
return VAR_3;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, VmdkExtent *VAR_1,\nError **VAR_2)\n{",
"int VAR_3;",
"int VAR_4, VAR_5;",
"VAR_4 = VAR_1->VAR_4 * sizeof(uint32_t);",
"VAR_1->l1_table = g_try_malloc(VAR_4);",
"if (VAR_4 && VAR_1->l1_table == NULL) {",
"return -ENOMEM;",
"}",
"VAR_3 = bdrv_pread(VAR_1->file,\nVAR_1->l1_table_offset,\nVAR_1->l1_table,\nVAR_4);",
"if (VAR_3 < 0) {",
"error_setg_errno(VAR_2, -VAR_3,\n\"Could not read l1 table from VAR_1 '%s'\",\nVAR_1->file->filename);",
"goto fail_l1;",
"}",
"for (VAR_5 = 0; VAR_5 < VAR_1->VAR_4; VAR_5++) {",
"le32_to_cpus(&VAR_1->l1_table[VAR_5]);",
"}",
"if (VAR_1->l1_backup_table_offset) {",
"VAR_1->l1_backup_table = g_try_malloc(VAR_4);",
"if (VAR_4 && VAR_1->l1_backup_table == NULL) {",
"VAR_3 = -ENOMEM;",
"goto fail_l1;",
"}",
"VAR_3 = bdrv_pread(VAR_1->file,\nVAR_1->l1_backup_table_offset,\nVAR_1->l1_backup_table,\nVAR_4);",
"if (VAR_3 < 0) {",
"error_setg_errno(VAR_2, -VAR_3,\n\"Could not read l1 backup table from VAR_1 '%s'\",\nVAR_1->file->filename);",
"goto fail_l1b;",
"}",
"for (VAR_5 = 0; VAR_5 < VAR_1->VAR_4; VAR_5++) {",
"le32_to_cpus(&VAR_1->l1_backup_table[VAR_5]);",
"}",
"}",
"VAR_1->l2_cache =\ng_new(uint32_t, VAR_1->l2_size * L2_CACHE_SIZE);",
"return 0;",
"fail_l1b:\ng_free(VAR_1->l1_backup_table);",
"fail_l1:\ng_free(VAR_1->l1_table);",
"return VAR_3;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27,
29,
31,
33
],
[
35
],
[
37,
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67,
69,
71,
73
],
[
75
],
[
77,
79,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97,
99
],
[
101
],
[
103,
105
],
[
107,
109
],
[
111
],
[
113
]
] |
20,784 | static void bdrv_password_cb(void *opaque, const char *password,
void *readline_opaque)
{
Monitor *mon = opaque;
BlockDriverState *bs = readline_opaque;
int ret = 0;
Error *local_err = NULL;
bdrv_add_key(bs, password, &local_err);
if (local_err) {
error_report_err(local_err);
ret = -EPERM;
}
if (mon->password_completion_cb)
mon->password_completion_cb(mon->password_opaque, ret);
monitor_read_command(mon, 1);
}
| true | qemu | 788cf9f8c8cbda53843e060540f3e91a060eb744 | static void bdrv_password_cb(void *opaque, const char *password,
void *readline_opaque)
{
Monitor *mon = opaque;
BlockDriverState *bs = readline_opaque;
int ret = 0;
Error *local_err = NULL;
bdrv_add_key(bs, password, &local_err);
if (local_err) {
error_report_err(local_err);
ret = -EPERM;
}
if (mon->password_completion_cb)
mon->password_completion_cb(mon->password_opaque, ret);
monitor_read_command(mon, 1);
}
| {
"code": [
"static void bdrv_password_cb(void *opaque, const char *password,",
" void *readline_opaque)",
" Monitor *mon = opaque;",
" BlockDriverState *bs = readline_opaque;",
" int ret = 0;",
" Error *local_err = NULL;",
" bdrv_add_key(bs, password, &local_err);",
" if (local_err) {",
" error_report_err(local_err);",
" ret = -EPERM;",
" if (mon->password_completion_cb)",
" mon->password_completion_cb(mon->password_opaque, ret);",
" monitor_read_command(mon, 1);",
" Error *local_err = NULL;"
],
"line_no": [
1,
3,
7,
9,
11,
13,
17,
19,
21,
23,
27,
29,
33,
13
]
} | static void FUNC_0(void *VAR_0, const char *VAR_1,
void *VAR_2)
{
Monitor *mon = VAR_0;
BlockDriverState *bs = VAR_2;
int VAR_3 = 0;
Error *local_err = NULL;
bdrv_add_key(bs, VAR_1, &local_err);
if (local_err) {
error_report_err(local_err);
VAR_3 = -EPERM;
}
if (mon->password_completion_cb)
mon->password_completion_cb(mon->password_opaque, VAR_3);
monitor_read_command(mon, 1);
}
| [
"static void FUNC_0(void *VAR_0, const char *VAR_1,\nvoid *VAR_2)\n{",
"Monitor *mon = VAR_0;",
"BlockDriverState *bs = VAR_2;",
"int VAR_3 = 0;",
"Error *local_err = NULL;",
"bdrv_add_key(bs, VAR_1, &local_err);",
"if (local_err) {",
"error_report_err(local_err);",
"VAR_3 = -EPERM;",
"}",
"if (mon->password_completion_cb)\nmon->password_completion_cb(mon->password_opaque, VAR_3);",
"monitor_read_command(mon, 1);",
"}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
33
],
[
35
]
] |
20,785 | static int vmdk_L2update(BlockDriverState *bs, VmdkMetaData *m_data)
{
BDRVVmdkState *s = bs->opaque;
/* update L2 table */
if (bdrv_pwrite(bs->file, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(m_data->offset)),
&(m_data->offset), sizeof(m_data->offset)) != sizeof(m_data->offset))
return -1;
/* update backup L2 table */
if (s->l1_backup_table_offset != 0) {
m_data->l2_offset = s->l1_backup_table[m_data->l1_index];
if (bdrv_pwrite(bs->file, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(m_data->offset)),
&(m_data->offset), sizeof(m_data->offset)) != sizeof(m_data->offset))
return -1;
}
return 0;
}
| true | qemu | b8852e87d9d113096342c3e0977266cda0fe9ee5 | static int vmdk_L2update(BlockDriverState *bs, VmdkMetaData *m_data)
{
BDRVVmdkState *s = bs->opaque;
if (bdrv_pwrite(bs->file, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(m_data->offset)),
&(m_data->offset), sizeof(m_data->offset)) != sizeof(m_data->offset))
return -1;
if (s->l1_backup_table_offset != 0) {
m_data->l2_offset = s->l1_backup_table[m_data->l1_index];
if (bdrv_pwrite(bs->file, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(m_data->offset)),
&(m_data->offset), sizeof(m_data->offset)) != sizeof(m_data->offset))
return -1;
}
return 0;
}
| {
"code": [
" if (bdrv_pwrite(bs->file, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(m_data->offset)),",
" &(m_data->offset), sizeof(m_data->offset)) != sizeof(m_data->offset))",
" if (bdrv_pwrite(bs->file, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(m_data->offset)),",
" &(m_data->offset), sizeof(m_data->offset)) != sizeof(m_data->offset))"
],
"line_no": [
11,
13,
23,
25
]
} | static int FUNC_0(BlockDriverState *VAR_0, VmdkMetaData *VAR_1)
{
BDRVVmdkState *s = VAR_0->opaque;
if (bdrv_pwrite(VAR_0->file, ((int64_t)VAR_1->l2_offset * 512) + (VAR_1->l2_index * sizeof(VAR_1->offset)),
&(VAR_1->offset), sizeof(VAR_1->offset)) != sizeof(VAR_1->offset))
return -1;
if (s->l1_backup_table_offset != 0) {
VAR_1->l2_offset = s->l1_backup_table[VAR_1->l1_index];
if (bdrv_pwrite(VAR_0->file, ((int64_t)VAR_1->l2_offset * 512) + (VAR_1->l2_index * sizeof(VAR_1->offset)),
&(VAR_1->offset), sizeof(VAR_1->offset)) != sizeof(VAR_1->offset))
return -1;
}
return 0;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, VmdkMetaData *VAR_1)\n{",
"BDRVVmdkState *s = VAR_0->opaque;",
"if (bdrv_pwrite(VAR_0->file, ((int64_t)VAR_1->l2_offset * 512) + (VAR_1->l2_index * sizeof(VAR_1->offset)),\n&(VAR_1->offset), sizeof(VAR_1->offset)) != sizeof(VAR_1->offset))\nreturn -1;",
"if (s->l1_backup_table_offset != 0) {",
"VAR_1->l2_offset = s->l1_backup_table[VAR_1->l1_index];",
"if (bdrv_pwrite(VAR_0->file, ((int64_t)VAR_1->l2_offset * 512) + (VAR_1->l2_index * sizeof(VAR_1->offset)),\n&(VAR_1->offset), sizeof(VAR_1->offset)) != sizeof(VAR_1->offset))\nreturn -1;",
"}",
"return 0;",
"}"
] | [
0,
0,
1,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
11,
13,
15
],
[
19
],
[
21
],
[
23,
25,
27
],
[
29
],
[
33
],
[
35
]
] |
20,786 | static int bdrv_inactivate_recurse(BlockDriverState *bs,
bool setting_flag)
{
BdrvChild *child, *parent;
int ret;
if (!setting_flag && bs->drv->bdrv_inactivate) {
ret = bs->drv->bdrv_inactivate(bs);
if (ret < 0) {
return ret;
}
}
if (setting_flag) {
uint64_t perm, shared_perm;
bs->open_flags |= BDRV_O_INACTIVE;
QLIST_FOREACH(parent, &bs->parents, next_parent) {
if (parent->role->inactivate) {
ret = parent->role->inactivate(parent);
if (ret < 0) {
bs->open_flags &= ~BDRV_O_INACTIVE;
return ret;
}
}
}
/* Update permissions, they may differ for inactive nodes */
bdrv_get_cumulative_perm(bs, &perm, &shared_perm);
bdrv_check_perm(bs, perm, shared_perm, NULL, &error_abort);
bdrv_set_perm(bs, perm, shared_perm);
}
QLIST_FOREACH(child, &bs->children, next) {
ret = bdrv_inactivate_recurse(child->bs, setting_flag);
if (ret < 0) {
return ret;
}
}
/* At this point persistent bitmaps should be already stored by the format
* driver */
bdrv_release_persistent_dirty_bitmaps(bs);
return 0;
}
| true | qemu | 7d5b5261104235cd6cc86930ab0d0a7372bfe04b | static int bdrv_inactivate_recurse(BlockDriverState *bs,
bool setting_flag)
{
BdrvChild *child, *parent;
int ret;
if (!setting_flag && bs->drv->bdrv_inactivate) {
ret = bs->drv->bdrv_inactivate(bs);
if (ret < 0) {
return ret;
}
}
if (setting_flag) {
uint64_t perm, shared_perm;
bs->open_flags |= BDRV_O_INACTIVE;
QLIST_FOREACH(parent, &bs->parents, next_parent) {
if (parent->role->inactivate) {
ret = parent->role->inactivate(parent);
if (ret < 0) {
bs->open_flags &= ~BDRV_O_INACTIVE;
return ret;
}
}
}
bdrv_get_cumulative_perm(bs, &perm, &shared_perm);
bdrv_check_perm(bs, perm, shared_perm, NULL, &error_abort);
bdrv_set_perm(bs, perm, shared_perm);
}
QLIST_FOREACH(child, &bs->children, next) {
ret = bdrv_inactivate_recurse(child->bs, setting_flag);
if (ret < 0) {
return ret;
}
}
bdrv_release_persistent_dirty_bitmaps(bs);
return 0;
}
| {
"code": [
" if (setting_flag) {",
" bs->open_flags |= BDRV_O_INACTIVE;",
" bs->open_flags &= ~BDRV_O_INACTIVE;"
],
"line_no": [
27,
33,
45
]
} | static int FUNC_0(BlockDriverState *VAR_0,
bool VAR_1)
{
BdrvChild *child, *parent;
int VAR_2;
if (!VAR_1 && VAR_0->drv->bdrv_inactivate) {
VAR_2 = VAR_0->drv->bdrv_inactivate(VAR_0);
if (VAR_2 < 0) {
return VAR_2;
}
}
if (VAR_1) {
uint64_t perm, shared_perm;
VAR_0->open_flags |= BDRV_O_INACTIVE;
QLIST_FOREACH(parent, &VAR_0->parents, next_parent) {
if (parent->role->inactivate) {
VAR_2 = parent->role->inactivate(parent);
if (VAR_2 < 0) {
VAR_0->open_flags &= ~BDRV_O_INACTIVE;
return VAR_2;
}
}
}
bdrv_get_cumulative_perm(VAR_0, &perm, &shared_perm);
bdrv_check_perm(VAR_0, perm, shared_perm, NULL, &error_abort);
bdrv_set_perm(VAR_0, perm, shared_perm);
}
QLIST_FOREACH(child, &VAR_0->children, next) {
VAR_2 = FUNC_0(child->VAR_0, VAR_1);
if (VAR_2 < 0) {
return VAR_2;
}
}
bdrv_release_persistent_dirty_bitmaps(VAR_0);
return 0;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0,\nbool VAR_1)\n{",
"BdrvChild *child, *parent;",
"int VAR_2;",
"if (!VAR_1 && VAR_0->drv->bdrv_inactivate) {",
"VAR_2 = VAR_0->drv->bdrv_inactivate(VAR_0);",
"if (VAR_2 < 0) {",
"return VAR_2;",
"}",
"}",
"if (VAR_1) {",
"uint64_t perm, shared_perm;",
"VAR_0->open_flags |= BDRV_O_INACTIVE;",
"QLIST_FOREACH(parent, &VAR_0->parents, next_parent) {",
"if (parent->role->inactivate) {",
"VAR_2 = parent->role->inactivate(parent);",
"if (VAR_2 < 0) {",
"VAR_0->open_flags &= ~BDRV_O_INACTIVE;",
"return VAR_2;",
"}",
"}",
"}",
"bdrv_get_cumulative_perm(VAR_0, &perm, &shared_perm);",
"bdrv_check_perm(VAR_0, perm, shared_perm, NULL, &error_abort);",
"bdrv_set_perm(VAR_0, perm, shared_perm);",
"}",
"QLIST_FOREACH(child, &VAR_0->children, next) {",
"VAR_2 = FUNC_0(child->VAR_0, VAR_1);",
"if (VAR_2 < 0) {",
"return VAR_2;",
"}",
"}",
"bdrv_release_persistent_dirty_bitmaps(VAR_0);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
87
],
[
91
],
[
93
]
] |
20,787 | int qcow2_read_snapshots(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
QCowSnapshotHeader h;
QCowSnapshotExtraData extra;
QCowSnapshot *sn;
int i, id_str_size, name_size;
int64_t offset;
uint32_t extra_data_size;
int ret;
if (!s->nb_snapshots) {
s->snapshots = NULL;
s->snapshots_size = 0;
return 0;
}
offset = s->snapshots_offset;
s->snapshots = g_malloc0(s->nb_snapshots * sizeof(QCowSnapshot));
for(i = 0; i < s->nb_snapshots; i++) {
/* Read statically sized part of the snapshot header */
offset = align_offset(offset, 8);
ret = bdrv_pread(bs->file, offset, &h, sizeof(h));
if (ret < 0) {
goto fail;
}
offset += sizeof(h);
sn = s->snapshots + i;
sn->l1_table_offset = be64_to_cpu(h.l1_table_offset);
sn->l1_size = be32_to_cpu(h.l1_size);
sn->vm_state_size = be32_to_cpu(h.vm_state_size);
sn->date_sec = be32_to_cpu(h.date_sec);
sn->date_nsec = be32_to_cpu(h.date_nsec);
sn->vm_clock_nsec = be64_to_cpu(h.vm_clock_nsec);
extra_data_size = be32_to_cpu(h.extra_data_size);
id_str_size = be16_to_cpu(h.id_str_size);
name_size = be16_to_cpu(h.name_size);
/* Read extra data */
ret = bdrv_pread(bs->file, offset, &extra,
MIN(sizeof(extra), extra_data_size));
if (ret < 0) {
goto fail;
}
offset += extra_data_size;
if (extra_data_size >= 8) {
sn->vm_state_size = be64_to_cpu(extra.vm_state_size_large);
}
if (extra_data_size >= 16) {
sn->disk_size = be64_to_cpu(extra.disk_size);
} else {
sn->disk_size = bs->total_sectors * BDRV_SECTOR_SIZE;
}
/* Read snapshot ID */
sn->id_str = g_malloc(id_str_size + 1);
ret = bdrv_pread(bs->file, offset, sn->id_str, id_str_size);
if (ret < 0) {
goto fail;
}
offset += id_str_size;
sn->id_str[id_str_size] = '\0';
/* Read snapshot name */
sn->name = g_malloc(name_size + 1);
ret = bdrv_pread(bs->file, offset, sn->name, name_size);
if (ret < 0) {
goto fail;
}
offset += name_size;
sn->name[name_size] = '\0';
if (offset - s->snapshots_offset > QCOW_MAX_SNAPSHOTS_SIZE) {
ret = -EFBIG;
goto fail;
}
}
assert(offset - s->snapshots_offset <= INT_MAX);
s->snapshots_size = offset - s->snapshots_offset;
return 0;
fail:
qcow2_free_snapshots(bs);
return ret;
}
| true | qemu | 5839e53bbc0fec56021d758aab7610df421ed8c8 | int qcow2_read_snapshots(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
QCowSnapshotHeader h;
QCowSnapshotExtraData extra;
QCowSnapshot *sn;
int i, id_str_size, name_size;
int64_t offset;
uint32_t extra_data_size;
int ret;
if (!s->nb_snapshots) {
s->snapshots = NULL;
s->snapshots_size = 0;
return 0;
}
offset = s->snapshots_offset;
s->snapshots = g_malloc0(s->nb_snapshots * sizeof(QCowSnapshot));
for(i = 0; i < s->nb_snapshots; i++) {
offset = align_offset(offset, 8);
ret = bdrv_pread(bs->file, offset, &h, sizeof(h));
if (ret < 0) {
goto fail;
}
offset += sizeof(h);
sn = s->snapshots + i;
sn->l1_table_offset = be64_to_cpu(h.l1_table_offset);
sn->l1_size = be32_to_cpu(h.l1_size);
sn->vm_state_size = be32_to_cpu(h.vm_state_size);
sn->date_sec = be32_to_cpu(h.date_sec);
sn->date_nsec = be32_to_cpu(h.date_nsec);
sn->vm_clock_nsec = be64_to_cpu(h.vm_clock_nsec);
extra_data_size = be32_to_cpu(h.extra_data_size);
id_str_size = be16_to_cpu(h.id_str_size);
name_size = be16_to_cpu(h.name_size);
ret = bdrv_pread(bs->file, offset, &extra,
MIN(sizeof(extra), extra_data_size));
if (ret < 0) {
goto fail;
}
offset += extra_data_size;
if (extra_data_size >= 8) {
sn->vm_state_size = be64_to_cpu(extra.vm_state_size_large);
}
if (extra_data_size >= 16) {
sn->disk_size = be64_to_cpu(extra.disk_size);
} else {
sn->disk_size = bs->total_sectors * BDRV_SECTOR_SIZE;
}
sn->id_str = g_malloc(id_str_size + 1);
ret = bdrv_pread(bs->file, offset, sn->id_str, id_str_size);
if (ret < 0) {
goto fail;
}
offset += id_str_size;
sn->id_str[id_str_size] = '\0';
sn->name = g_malloc(name_size + 1);
ret = bdrv_pread(bs->file, offset, sn->name, name_size);
if (ret < 0) {
goto fail;
}
offset += name_size;
sn->name[name_size] = '\0';
if (offset - s->snapshots_offset > QCOW_MAX_SNAPSHOTS_SIZE) {
ret = -EFBIG;
goto fail;
}
}
assert(offset - s->snapshots_offset <= INT_MAX);
s->snapshots_size = offset - s->snapshots_offset;
return 0;
fail:
qcow2_free_snapshots(bs);
return ret;
}
| {
"code": [
" s->snapshots = g_malloc0(s->nb_snapshots * sizeof(QCowSnapshot));"
],
"line_no": [
37
]
} | int FUNC_0(BlockDriverState *VAR_0)
{
BDRVQcowState *s = VAR_0->opaque;
QCowSnapshotHeader h;
QCowSnapshotExtraData extra;
QCowSnapshot *sn;
int VAR_1, VAR_2, VAR_3;
int64_t offset;
uint32_t extra_data_size;
int VAR_4;
if (!s->nb_snapshots) {
s->snapshots = NULL;
s->snapshots_size = 0;
return 0;
}
offset = s->snapshots_offset;
s->snapshots = g_malloc0(s->nb_snapshots * sizeof(QCowSnapshot));
for(VAR_1 = 0; VAR_1 < s->nb_snapshots; VAR_1++) {
offset = align_offset(offset, 8);
VAR_4 = bdrv_pread(VAR_0->file, offset, &h, sizeof(h));
if (VAR_4 < 0) {
goto fail;
}
offset += sizeof(h);
sn = s->snapshots + VAR_1;
sn->l1_table_offset = be64_to_cpu(h.l1_table_offset);
sn->l1_size = be32_to_cpu(h.l1_size);
sn->vm_state_size = be32_to_cpu(h.vm_state_size);
sn->date_sec = be32_to_cpu(h.date_sec);
sn->date_nsec = be32_to_cpu(h.date_nsec);
sn->vm_clock_nsec = be64_to_cpu(h.vm_clock_nsec);
extra_data_size = be32_to_cpu(h.extra_data_size);
VAR_2 = be16_to_cpu(h.VAR_2);
VAR_3 = be16_to_cpu(h.VAR_3);
VAR_4 = bdrv_pread(VAR_0->file, offset, &extra,
MIN(sizeof(extra), extra_data_size));
if (VAR_4 < 0) {
goto fail;
}
offset += extra_data_size;
if (extra_data_size >= 8) {
sn->vm_state_size = be64_to_cpu(extra.vm_state_size_large);
}
if (extra_data_size >= 16) {
sn->disk_size = be64_to_cpu(extra.disk_size);
} else {
sn->disk_size = VAR_0->total_sectors * BDRV_SECTOR_SIZE;
}
sn->id_str = g_malloc(VAR_2 + 1);
VAR_4 = bdrv_pread(VAR_0->file, offset, sn->id_str, VAR_2);
if (VAR_4 < 0) {
goto fail;
}
offset += VAR_2;
sn->id_str[VAR_2] = '\0';
sn->name = g_malloc(VAR_3 + 1);
VAR_4 = bdrv_pread(VAR_0->file, offset, sn->name, VAR_3);
if (VAR_4 < 0) {
goto fail;
}
offset += VAR_3;
sn->name[VAR_3] = '\0';
if (offset - s->snapshots_offset > QCOW_MAX_SNAPSHOTS_SIZE) {
VAR_4 = -EFBIG;
goto fail;
}
}
assert(offset - s->snapshots_offset <= INT_MAX);
s->snapshots_size = offset - s->snapshots_offset;
return 0;
fail:
qcow2_free_snapshots(VAR_0);
return VAR_4;
}
| [
"int FUNC_0(BlockDriverState *VAR_0)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"QCowSnapshotHeader h;",
"QCowSnapshotExtraData extra;",
"QCowSnapshot *sn;",
"int VAR_1, VAR_2, VAR_3;",
"int64_t offset;",
"uint32_t extra_data_size;",
"int VAR_4;",
"if (!s->nb_snapshots) {",
"s->snapshots = NULL;",
"s->snapshots_size = 0;",
"return 0;",
"}",
"offset = s->snapshots_offset;",
"s->snapshots = g_malloc0(s->nb_snapshots * sizeof(QCowSnapshot));",
"for(VAR_1 = 0; VAR_1 < s->nb_snapshots; VAR_1++) {",
"offset = align_offset(offset, 8);",
"VAR_4 = bdrv_pread(VAR_0->file, offset, &h, sizeof(h));",
"if (VAR_4 < 0) {",
"goto fail;",
"}",
"offset += sizeof(h);",
"sn = s->snapshots + VAR_1;",
"sn->l1_table_offset = be64_to_cpu(h.l1_table_offset);",
"sn->l1_size = be32_to_cpu(h.l1_size);",
"sn->vm_state_size = be32_to_cpu(h.vm_state_size);",
"sn->date_sec = be32_to_cpu(h.date_sec);",
"sn->date_nsec = be32_to_cpu(h.date_nsec);",
"sn->vm_clock_nsec = be64_to_cpu(h.vm_clock_nsec);",
"extra_data_size = be32_to_cpu(h.extra_data_size);",
"VAR_2 = be16_to_cpu(h.VAR_2);",
"VAR_3 = be16_to_cpu(h.VAR_3);",
"VAR_4 = bdrv_pread(VAR_0->file, offset, &extra,\nMIN(sizeof(extra), extra_data_size));",
"if (VAR_4 < 0) {",
"goto fail;",
"}",
"offset += extra_data_size;",
"if (extra_data_size >= 8) {",
"sn->vm_state_size = be64_to_cpu(extra.vm_state_size_large);",
"}",
"if (extra_data_size >= 16) {",
"sn->disk_size = be64_to_cpu(extra.disk_size);",
"} else {",
"sn->disk_size = VAR_0->total_sectors * BDRV_SECTOR_SIZE;",
"}",
"sn->id_str = g_malloc(VAR_2 + 1);",
"VAR_4 = bdrv_pread(VAR_0->file, offset, sn->id_str, VAR_2);",
"if (VAR_4 < 0) {",
"goto fail;",
"}",
"offset += VAR_2;",
"sn->id_str[VAR_2] = '\\0';",
"sn->name = g_malloc(VAR_3 + 1);",
"VAR_4 = bdrv_pread(VAR_0->file, offset, sn->name, VAR_3);",
"if (VAR_4 < 0) {",
"goto fail;",
"}",
"offset += VAR_3;",
"sn->name[VAR_3] = '\\0';",
"if (offset - s->snapshots_offset > QCOW_MAX_SNAPSHOTS_SIZE) {",
"VAR_4 = -EFBIG;",
"goto fail;",
"}",
"}",
"assert(offset - s->snapshots_offset <= INT_MAX);",
"s->snapshots_size = offset - s->snapshots_offset;",
"return 0;",
"fail:\nqcow2_free_snapshots(VAR_0);",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
175,
177
],
[
179
],
[
181
]
] |
20,788 | static abi_long do_fcntl(int fd, int cmd, abi_ulong arg)
{
struct flock fl;
struct target_flock *target_fl;
struct flock64 fl64;
struct target_flock64 *target_fl64;
#ifdef F_GETOWN_EX
struct f_owner_ex fox;
struct target_f_owner_ex *target_fox;
#endif
abi_long ret;
int host_cmd = target_to_host_fcntl_cmd(cmd);
if (host_cmd == -TARGET_EINVAL)
return host_cmd;
switch(cmd) {
case TARGET_F_GETLK:
if (!lock_user_struct(VERIFY_READ, target_fl, arg, 1))
return -TARGET_EFAULT;
fl.l_type =
target_to_host_bitmask(tswap16(target_fl->l_type), flock_tbl);
fl.l_whence = tswap16(target_fl->l_whence);
fl.l_start = tswapal(target_fl->l_start);
fl.l_len = tswapal(target_fl->l_len);
fl.l_pid = tswap32(target_fl->l_pid);
unlock_user_struct(target_fl, arg, 0);
ret = get_errno(fcntl(fd, host_cmd, &fl));
if (ret == 0) {
if (!lock_user_struct(VERIFY_WRITE, target_fl, arg, 0))
return -TARGET_EFAULT;
target_fl->l_type =
host_to_target_bitmask(tswap16(fl.l_type), flock_tbl);
target_fl->l_whence = tswap16(fl.l_whence);
target_fl->l_start = tswapal(fl.l_start);
target_fl->l_len = tswapal(fl.l_len);
target_fl->l_pid = tswap32(fl.l_pid);
unlock_user_struct(target_fl, arg, 1);
}
break;
case TARGET_F_SETLK:
case TARGET_F_SETLKW:
if (!lock_user_struct(VERIFY_READ, target_fl, arg, 1))
return -TARGET_EFAULT;
fl.l_type =
target_to_host_bitmask(tswap16(target_fl->l_type), flock_tbl);
fl.l_whence = tswap16(target_fl->l_whence);
fl.l_start = tswapal(target_fl->l_start);
fl.l_len = tswapal(target_fl->l_len);
fl.l_pid = tswap32(target_fl->l_pid);
unlock_user_struct(target_fl, arg, 0);
ret = get_errno(fcntl(fd, host_cmd, &fl));
break;
case TARGET_F_GETLK64:
if (!lock_user_struct(VERIFY_READ, target_fl64, arg, 1))
return -TARGET_EFAULT;
fl64.l_type =
target_to_host_bitmask(tswap16(target_fl64->l_type), flock_tbl) >> 1;
fl64.l_whence = tswap16(target_fl64->l_whence);
fl64.l_start = tswap64(target_fl64->l_start);
fl64.l_len = tswap64(target_fl64->l_len);
fl64.l_pid = tswap32(target_fl64->l_pid);
unlock_user_struct(target_fl64, arg, 0);
ret = get_errno(fcntl(fd, host_cmd, &fl64));
if (ret == 0) {
if (!lock_user_struct(VERIFY_WRITE, target_fl64, arg, 0))
return -TARGET_EFAULT;
target_fl64->l_type =
host_to_target_bitmask(tswap16(fl64.l_type), flock_tbl) >> 1;
target_fl64->l_whence = tswap16(fl64.l_whence);
target_fl64->l_start = tswap64(fl64.l_start);
target_fl64->l_len = tswap64(fl64.l_len);
target_fl64->l_pid = tswap32(fl64.l_pid);
unlock_user_struct(target_fl64, arg, 1);
}
break;
case TARGET_F_SETLK64:
case TARGET_F_SETLKW64:
if (!lock_user_struct(VERIFY_READ, target_fl64, arg, 1))
return -TARGET_EFAULT;
fl64.l_type =
target_to_host_bitmask(tswap16(target_fl64->l_type), flock_tbl) >> 1;
fl64.l_whence = tswap16(target_fl64->l_whence);
fl64.l_start = tswap64(target_fl64->l_start);
fl64.l_len = tswap64(target_fl64->l_len);
fl64.l_pid = tswap32(target_fl64->l_pid);
unlock_user_struct(target_fl64, arg, 0);
ret = get_errno(fcntl(fd, host_cmd, &fl64));
break;
case TARGET_F_GETFL:
ret = get_errno(fcntl(fd, host_cmd, arg));
if (ret >= 0) {
ret = host_to_target_bitmask(ret, fcntl_flags_tbl);
}
break;
case TARGET_F_SETFL:
ret = get_errno(fcntl(fd, host_cmd, target_to_host_bitmask(arg, fcntl_flags_tbl)));
break;
#ifdef F_GETOWN_EX
case TARGET_F_GETOWN_EX:
ret = get_errno(fcntl(fd, host_cmd, &fox));
if (ret >= 0) {
if (!lock_user_struct(VERIFY_WRITE, target_fox, arg, 0))
return -TARGET_EFAULT;
target_fox->type = tswap32(fox.type);
target_fox->pid = tswap32(fox.pid);
unlock_user_struct(target_fox, arg, 1);
}
break;
#endif
#ifdef F_SETOWN_EX
case TARGET_F_SETOWN_EX:
if (!lock_user_struct(VERIFY_READ, target_fox, arg, 1))
return -TARGET_EFAULT;
fox.type = tswap32(target_fox->type);
fox.pid = tswap32(target_fox->pid);
unlock_user_struct(target_fox, arg, 0);
ret = get_errno(fcntl(fd, host_cmd, &fox));
break;
#endif
case TARGET_F_SETOWN:
case TARGET_F_GETOWN:
case TARGET_F_SETSIG:
case TARGET_F_GETSIG:
case TARGET_F_SETLEASE:
case TARGET_F_GETLEASE:
ret = get_errno(fcntl(fd, host_cmd, arg));
break;
default:
ret = get_errno(fcntl(fd, cmd, arg));
break;
}
return ret;
}
| false | qemu | 213d3e9ea27f7fc55db7272c05255294b52ed3e4 | static abi_long do_fcntl(int fd, int cmd, abi_ulong arg)
{
struct flock fl;
struct target_flock *target_fl;
struct flock64 fl64;
struct target_flock64 *target_fl64;
#ifdef F_GETOWN_EX
struct f_owner_ex fox;
struct target_f_owner_ex *target_fox;
#endif
abi_long ret;
int host_cmd = target_to_host_fcntl_cmd(cmd);
if (host_cmd == -TARGET_EINVAL)
return host_cmd;
switch(cmd) {
case TARGET_F_GETLK:
if (!lock_user_struct(VERIFY_READ, target_fl, arg, 1))
return -TARGET_EFAULT;
fl.l_type =
target_to_host_bitmask(tswap16(target_fl->l_type), flock_tbl);
fl.l_whence = tswap16(target_fl->l_whence);
fl.l_start = tswapal(target_fl->l_start);
fl.l_len = tswapal(target_fl->l_len);
fl.l_pid = tswap32(target_fl->l_pid);
unlock_user_struct(target_fl, arg, 0);
ret = get_errno(fcntl(fd, host_cmd, &fl));
if (ret == 0) {
if (!lock_user_struct(VERIFY_WRITE, target_fl, arg, 0))
return -TARGET_EFAULT;
target_fl->l_type =
host_to_target_bitmask(tswap16(fl.l_type), flock_tbl);
target_fl->l_whence = tswap16(fl.l_whence);
target_fl->l_start = tswapal(fl.l_start);
target_fl->l_len = tswapal(fl.l_len);
target_fl->l_pid = tswap32(fl.l_pid);
unlock_user_struct(target_fl, arg, 1);
}
break;
case TARGET_F_SETLK:
case TARGET_F_SETLKW:
if (!lock_user_struct(VERIFY_READ, target_fl, arg, 1))
return -TARGET_EFAULT;
fl.l_type =
target_to_host_bitmask(tswap16(target_fl->l_type), flock_tbl);
fl.l_whence = tswap16(target_fl->l_whence);
fl.l_start = tswapal(target_fl->l_start);
fl.l_len = tswapal(target_fl->l_len);
fl.l_pid = tswap32(target_fl->l_pid);
unlock_user_struct(target_fl, arg, 0);
ret = get_errno(fcntl(fd, host_cmd, &fl));
break;
case TARGET_F_GETLK64:
if (!lock_user_struct(VERIFY_READ, target_fl64, arg, 1))
return -TARGET_EFAULT;
fl64.l_type =
target_to_host_bitmask(tswap16(target_fl64->l_type), flock_tbl) >> 1;
fl64.l_whence = tswap16(target_fl64->l_whence);
fl64.l_start = tswap64(target_fl64->l_start);
fl64.l_len = tswap64(target_fl64->l_len);
fl64.l_pid = tswap32(target_fl64->l_pid);
unlock_user_struct(target_fl64, arg, 0);
ret = get_errno(fcntl(fd, host_cmd, &fl64));
if (ret == 0) {
if (!lock_user_struct(VERIFY_WRITE, target_fl64, arg, 0))
return -TARGET_EFAULT;
target_fl64->l_type =
host_to_target_bitmask(tswap16(fl64.l_type), flock_tbl) >> 1;
target_fl64->l_whence = tswap16(fl64.l_whence);
target_fl64->l_start = tswap64(fl64.l_start);
target_fl64->l_len = tswap64(fl64.l_len);
target_fl64->l_pid = tswap32(fl64.l_pid);
unlock_user_struct(target_fl64, arg, 1);
}
break;
case TARGET_F_SETLK64:
case TARGET_F_SETLKW64:
if (!lock_user_struct(VERIFY_READ, target_fl64, arg, 1))
return -TARGET_EFAULT;
fl64.l_type =
target_to_host_bitmask(tswap16(target_fl64->l_type), flock_tbl) >> 1;
fl64.l_whence = tswap16(target_fl64->l_whence);
fl64.l_start = tswap64(target_fl64->l_start);
fl64.l_len = tswap64(target_fl64->l_len);
fl64.l_pid = tswap32(target_fl64->l_pid);
unlock_user_struct(target_fl64, arg, 0);
ret = get_errno(fcntl(fd, host_cmd, &fl64));
break;
case TARGET_F_GETFL:
ret = get_errno(fcntl(fd, host_cmd, arg));
if (ret >= 0) {
ret = host_to_target_bitmask(ret, fcntl_flags_tbl);
}
break;
case TARGET_F_SETFL:
ret = get_errno(fcntl(fd, host_cmd, target_to_host_bitmask(arg, fcntl_flags_tbl)));
break;
#ifdef F_GETOWN_EX
case TARGET_F_GETOWN_EX:
ret = get_errno(fcntl(fd, host_cmd, &fox));
if (ret >= 0) {
if (!lock_user_struct(VERIFY_WRITE, target_fox, arg, 0))
return -TARGET_EFAULT;
target_fox->type = tswap32(fox.type);
target_fox->pid = tswap32(fox.pid);
unlock_user_struct(target_fox, arg, 1);
}
break;
#endif
#ifdef F_SETOWN_EX
case TARGET_F_SETOWN_EX:
if (!lock_user_struct(VERIFY_READ, target_fox, arg, 1))
return -TARGET_EFAULT;
fox.type = tswap32(target_fox->type);
fox.pid = tswap32(target_fox->pid);
unlock_user_struct(target_fox, arg, 0);
ret = get_errno(fcntl(fd, host_cmd, &fox));
break;
#endif
case TARGET_F_SETOWN:
case TARGET_F_GETOWN:
case TARGET_F_SETSIG:
case TARGET_F_GETSIG:
case TARGET_F_SETLEASE:
case TARGET_F_GETLEASE:
ret = get_errno(fcntl(fd, host_cmd, arg));
break;
default:
ret = get_errno(fcntl(fd, cmd, arg));
break;
}
return ret;
}
| {
"code": [],
"line_no": []
} | static abi_long FUNC_0(int fd, int cmd, abi_ulong arg)
{
struct flock VAR_0;
struct target_flock *VAR_1;
struct flock64 VAR_2;
struct target_flock64 *VAR_3;
#ifdef F_GETOWN_EX
struct f_owner_ex fox;
struct target_f_owner_ex *target_fox;
#endif
abi_long ret;
int VAR_4 = target_to_host_fcntl_cmd(cmd);
if (VAR_4 == -TARGET_EINVAL)
return VAR_4;
switch(cmd) {
case TARGET_F_GETLK:
if (!lock_user_struct(VERIFY_READ, VAR_1, arg, 1))
return -TARGET_EFAULT;
VAR_0.l_type =
target_to_host_bitmask(tswap16(VAR_1->l_type), flock_tbl);
VAR_0.l_whence = tswap16(VAR_1->l_whence);
VAR_0.l_start = tswapal(VAR_1->l_start);
VAR_0.l_len = tswapal(VAR_1->l_len);
VAR_0.l_pid = tswap32(VAR_1->l_pid);
unlock_user_struct(VAR_1, arg, 0);
ret = get_errno(fcntl(fd, VAR_4, &VAR_0));
if (ret == 0) {
if (!lock_user_struct(VERIFY_WRITE, VAR_1, arg, 0))
return -TARGET_EFAULT;
VAR_1->l_type =
host_to_target_bitmask(tswap16(VAR_0.l_type), flock_tbl);
VAR_1->l_whence = tswap16(VAR_0.l_whence);
VAR_1->l_start = tswapal(VAR_0.l_start);
VAR_1->l_len = tswapal(VAR_0.l_len);
VAR_1->l_pid = tswap32(VAR_0.l_pid);
unlock_user_struct(VAR_1, arg, 1);
}
break;
case TARGET_F_SETLK:
case TARGET_F_SETLKW:
if (!lock_user_struct(VERIFY_READ, VAR_1, arg, 1))
return -TARGET_EFAULT;
VAR_0.l_type =
target_to_host_bitmask(tswap16(VAR_1->l_type), flock_tbl);
VAR_0.l_whence = tswap16(VAR_1->l_whence);
VAR_0.l_start = tswapal(VAR_1->l_start);
VAR_0.l_len = tswapal(VAR_1->l_len);
VAR_0.l_pid = tswap32(VAR_1->l_pid);
unlock_user_struct(VAR_1, arg, 0);
ret = get_errno(fcntl(fd, VAR_4, &VAR_0));
break;
case TARGET_F_GETLK64:
if (!lock_user_struct(VERIFY_READ, VAR_3, arg, 1))
return -TARGET_EFAULT;
VAR_2.l_type =
target_to_host_bitmask(tswap16(VAR_3->l_type), flock_tbl) >> 1;
VAR_2.l_whence = tswap16(VAR_3->l_whence);
VAR_2.l_start = tswap64(VAR_3->l_start);
VAR_2.l_len = tswap64(VAR_3->l_len);
VAR_2.l_pid = tswap32(VAR_3->l_pid);
unlock_user_struct(VAR_3, arg, 0);
ret = get_errno(fcntl(fd, VAR_4, &VAR_2));
if (ret == 0) {
if (!lock_user_struct(VERIFY_WRITE, VAR_3, arg, 0))
return -TARGET_EFAULT;
VAR_3->l_type =
host_to_target_bitmask(tswap16(VAR_2.l_type), flock_tbl) >> 1;
VAR_3->l_whence = tswap16(VAR_2.l_whence);
VAR_3->l_start = tswap64(VAR_2.l_start);
VAR_3->l_len = tswap64(VAR_2.l_len);
VAR_3->l_pid = tswap32(VAR_2.l_pid);
unlock_user_struct(VAR_3, arg, 1);
}
break;
case TARGET_F_SETLK64:
case TARGET_F_SETLKW64:
if (!lock_user_struct(VERIFY_READ, VAR_3, arg, 1))
return -TARGET_EFAULT;
VAR_2.l_type =
target_to_host_bitmask(tswap16(VAR_3->l_type), flock_tbl) >> 1;
VAR_2.l_whence = tswap16(VAR_3->l_whence);
VAR_2.l_start = tswap64(VAR_3->l_start);
VAR_2.l_len = tswap64(VAR_3->l_len);
VAR_2.l_pid = tswap32(VAR_3->l_pid);
unlock_user_struct(VAR_3, arg, 0);
ret = get_errno(fcntl(fd, VAR_4, &VAR_2));
break;
case TARGET_F_GETFL:
ret = get_errno(fcntl(fd, VAR_4, arg));
if (ret >= 0) {
ret = host_to_target_bitmask(ret, fcntl_flags_tbl);
}
break;
case TARGET_F_SETFL:
ret = get_errno(fcntl(fd, VAR_4, target_to_host_bitmask(arg, fcntl_flags_tbl)));
break;
#ifdef F_GETOWN_EX
case TARGET_F_GETOWN_EX:
ret = get_errno(fcntl(fd, VAR_4, &fox));
if (ret >= 0) {
if (!lock_user_struct(VERIFY_WRITE, target_fox, arg, 0))
return -TARGET_EFAULT;
target_fox->type = tswap32(fox.type);
target_fox->pid = tswap32(fox.pid);
unlock_user_struct(target_fox, arg, 1);
}
break;
#endif
#ifdef F_SETOWN_EX
case TARGET_F_SETOWN_EX:
if (!lock_user_struct(VERIFY_READ, target_fox, arg, 1))
return -TARGET_EFAULT;
fox.type = tswap32(target_fox->type);
fox.pid = tswap32(target_fox->pid);
unlock_user_struct(target_fox, arg, 0);
ret = get_errno(fcntl(fd, VAR_4, &fox));
break;
#endif
case TARGET_F_SETOWN:
case TARGET_F_GETOWN:
case TARGET_F_SETSIG:
case TARGET_F_GETSIG:
case TARGET_F_SETLEASE:
case TARGET_F_GETLEASE:
ret = get_errno(fcntl(fd, VAR_4, arg));
break;
default:
ret = get_errno(fcntl(fd, cmd, arg));
break;
}
return ret;
}
| [
"static abi_long FUNC_0(int fd, int cmd, abi_ulong arg)\n{",
"struct flock VAR_0;",
"struct target_flock *VAR_1;",
"struct flock64 VAR_2;",
"struct target_flock64 *VAR_3;",
"#ifdef F_GETOWN_EX\nstruct f_owner_ex fox;",
"struct target_f_owner_ex *target_fox;",
"#endif\nabi_long ret;",
"int VAR_4 = target_to_host_fcntl_cmd(cmd);",
"if (VAR_4 == -TARGET_EINVAL)\nreturn VAR_4;",
"switch(cmd) {",
"case TARGET_F_GETLK:\nif (!lock_user_struct(VERIFY_READ, VAR_1, arg, 1))\nreturn -TARGET_EFAULT;",
"VAR_0.l_type =\ntarget_to_host_bitmask(tswap16(VAR_1->l_type), flock_tbl);",
"VAR_0.l_whence = tswap16(VAR_1->l_whence);",
"VAR_0.l_start = tswapal(VAR_1->l_start);",
"VAR_0.l_len = tswapal(VAR_1->l_len);",
"VAR_0.l_pid = tswap32(VAR_1->l_pid);",
"unlock_user_struct(VAR_1, arg, 0);",
"ret = get_errno(fcntl(fd, VAR_4, &VAR_0));",
"if (ret == 0) {",
"if (!lock_user_struct(VERIFY_WRITE, VAR_1, arg, 0))\nreturn -TARGET_EFAULT;",
"VAR_1->l_type =\nhost_to_target_bitmask(tswap16(VAR_0.l_type), flock_tbl);",
"VAR_1->l_whence = tswap16(VAR_0.l_whence);",
"VAR_1->l_start = tswapal(VAR_0.l_start);",
"VAR_1->l_len = tswapal(VAR_0.l_len);",
"VAR_1->l_pid = tswap32(VAR_0.l_pid);",
"unlock_user_struct(VAR_1, arg, 1);",
"}",
"break;",
"case TARGET_F_SETLK:\ncase TARGET_F_SETLKW:\nif (!lock_user_struct(VERIFY_READ, VAR_1, arg, 1))\nreturn -TARGET_EFAULT;",
"VAR_0.l_type =\ntarget_to_host_bitmask(tswap16(VAR_1->l_type), flock_tbl);",
"VAR_0.l_whence = tswap16(VAR_1->l_whence);",
"VAR_0.l_start = tswapal(VAR_1->l_start);",
"VAR_0.l_len = tswapal(VAR_1->l_len);",
"VAR_0.l_pid = tswap32(VAR_1->l_pid);",
"unlock_user_struct(VAR_1, arg, 0);",
"ret = get_errno(fcntl(fd, VAR_4, &VAR_0));",
"break;",
"case TARGET_F_GETLK64:\nif (!lock_user_struct(VERIFY_READ, VAR_3, arg, 1))\nreturn -TARGET_EFAULT;",
"VAR_2.l_type =\ntarget_to_host_bitmask(tswap16(VAR_3->l_type), flock_tbl) >> 1;",
"VAR_2.l_whence = tswap16(VAR_3->l_whence);",
"VAR_2.l_start = tswap64(VAR_3->l_start);",
"VAR_2.l_len = tswap64(VAR_3->l_len);",
"VAR_2.l_pid = tswap32(VAR_3->l_pid);",
"unlock_user_struct(VAR_3, arg, 0);",
"ret = get_errno(fcntl(fd, VAR_4, &VAR_2));",
"if (ret == 0) {",
"if (!lock_user_struct(VERIFY_WRITE, VAR_3, arg, 0))\nreturn -TARGET_EFAULT;",
"VAR_3->l_type =\nhost_to_target_bitmask(tswap16(VAR_2.l_type), flock_tbl) >> 1;",
"VAR_3->l_whence = tswap16(VAR_2.l_whence);",
"VAR_3->l_start = tswap64(VAR_2.l_start);",
"VAR_3->l_len = tswap64(VAR_2.l_len);",
"VAR_3->l_pid = tswap32(VAR_2.l_pid);",
"unlock_user_struct(VAR_3, arg, 1);",
"}",
"break;",
"case TARGET_F_SETLK64:\ncase TARGET_F_SETLKW64:\nif (!lock_user_struct(VERIFY_READ, VAR_3, arg, 1))\nreturn -TARGET_EFAULT;",
"VAR_2.l_type =\ntarget_to_host_bitmask(tswap16(VAR_3->l_type), flock_tbl) >> 1;",
"VAR_2.l_whence = tswap16(VAR_3->l_whence);",
"VAR_2.l_start = tswap64(VAR_3->l_start);",
"VAR_2.l_len = tswap64(VAR_3->l_len);",
"VAR_2.l_pid = tswap32(VAR_3->l_pid);",
"unlock_user_struct(VAR_3, arg, 0);",
"ret = get_errno(fcntl(fd, VAR_4, &VAR_2));",
"break;",
"case TARGET_F_GETFL:\nret = get_errno(fcntl(fd, VAR_4, arg));",
"if (ret >= 0) {",
"ret = host_to_target_bitmask(ret, fcntl_flags_tbl);",
"}",
"break;",
"case TARGET_F_SETFL:\nret = get_errno(fcntl(fd, VAR_4, target_to_host_bitmask(arg, fcntl_flags_tbl)));",
"break;",
"#ifdef F_GETOWN_EX\ncase TARGET_F_GETOWN_EX:\nret = get_errno(fcntl(fd, VAR_4, &fox));",
"if (ret >= 0) {",
"if (!lock_user_struct(VERIFY_WRITE, target_fox, arg, 0))\nreturn -TARGET_EFAULT;",
"target_fox->type = tswap32(fox.type);",
"target_fox->pid = tswap32(fox.pid);",
"unlock_user_struct(target_fox, arg, 1);",
"}",
"break;",
"#endif\n#ifdef F_SETOWN_EX\ncase TARGET_F_SETOWN_EX:\nif (!lock_user_struct(VERIFY_READ, target_fox, arg, 1))\nreturn -TARGET_EFAULT;",
"fox.type = tswap32(target_fox->type);",
"fox.pid = tswap32(target_fox->pid);",
"unlock_user_struct(target_fox, arg, 0);",
"ret = get_errno(fcntl(fd, VAR_4, &fox));",
"break;",
"#endif\ncase TARGET_F_SETOWN:\ncase TARGET_F_GETOWN:\ncase TARGET_F_SETSIG:\ncase TARGET_F_GETSIG:\ncase TARGET_F_SETLEASE:\ncase TARGET_F_GETLEASE:\nret = get_errno(fcntl(fd, VAR_4, arg));",
"break;",
"default:\nret = get_errno(fcntl(fd, cmd, arg));",
"break;",
"}",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
17
],
[
19,
21
],
[
23
],
[
27,
29
],
[
33
],
[
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,
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111,
113,
115
],
[
117,
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135,
137
],
[
139,
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157,
159,
161,
163
],
[
165,
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
185,
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
199,
201
],
[
203
],
[
207,
209,
211
],
[
213
],
[
215,
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229,
233,
235,
237,
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251,
255,
257,
259,
261,
263,
265,
267
],
[
269
],
[
273,
275
],
[
277
],
[
279
],
[
281
],
[
283
]
] |
20,789 | const uint8_t *avpriv_find_start_code(const uint8_t *av_restrict p,
const uint8_t *end,
uint32_t *av_restrict state)
{
int i;
assert(p <= end);
if (p >= end)
return end;
for (i = 0; i < 3; i++) {
uint32_t tmp = *state << 8;
*state = tmp + *(p++);
if (tmp == 0x100 || p == end)
return p;
}
while (p < end) {
if (p[-1] > 1 ) p += 3;
else if (p[-2] ) p += 2;
else if (p[-3]|(p[-1]-1)) p++;
else {
p++;
break;
}
}
p = FFMIN(p, end) - 4;
*state = AV_RB32(p);
return p + 4;
}
| false | FFmpeg | 55db06af64d1acb7c3e304d61e7a1f265139d27a | const uint8_t *avpriv_find_start_code(const uint8_t *av_restrict p,
const uint8_t *end,
uint32_t *av_restrict state)
{
int i;
assert(p <= end);
if (p >= end)
return end;
for (i = 0; i < 3; i++) {
uint32_t tmp = *state << 8;
*state = tmp + *(p++);
if (tmp == 0x100 || p == end)
return p;
}
while (p < end) {
if (p[-1] > 1 ) p += 3;
else if (p[-2] ) p += 2;
else if (p[-3]|(p[-1]-1)) p++;
else {
p++;
break;
}
}
p = FFMIN(p, end) - 4;
*state = AV_RB32(p);
return p + 4;
}
| {
"code": [],
"line_no": []
} | const uint8_t *FUNC_0(const uint8_t *av_restrict p,
const uint8_t *end,
uint32_t *av_restrict state)
{
int VAR_0;
assert(p <= end);
if (p >= end)
return end;
for (VAR_0 = 0; VAR_0 < 3; VAR_0++) {
uint32_t tmp = *state << 8;
*state = tmp + *(p++);
if (tmp == 0x100 || p == end)
return p;
}
while (p < end) {
if (p[-1] > 1 ) p += 3;
else if (p[-2] ) p += 2;
else if (p[-3]|(p[-1]-1)) p++;
else {
p++;
break;
}
}
p = FFMIN(p, end) - 4;
*state = AV_RB32(p);
return p + 4;
}
| [
"const uint8_t *FUNC_0(const uint8_t *av_restrict p,\nconst uint8_t *end,\nuint32_t *av_restrict state)\n{",
"int VAR_0;",
"assert(p <= end);",
"if (p >= end)\nreturn end;",
"for (VAR_0 = 0; VAR_0 < 3; VAR_0++) {",
"uint32_t tmp = *state << 8;",
"*state = tmp + *(p++);",
"if (tmp == 0x100 || p == end)\nreturn p;",
"}",
"while (p < end) {",
"if (p[-1] > 1 ) p += 3;",
"else if (p[-2] ) p += 2;",
"else if (p[-3]|(p[-1]-1)) p++;",
"else {",
"p++;",
"break;",
"}",
"}",
"p = FFMIN(p, end) - 4;",
"*state = AV_RB32(p);",
"return p + 4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
15,
17
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
61
],
[
63
]
] |
20,790 | static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file,
QDict *options, Error **errp)
{
int ret, open_flags;
const char *filename;
const char *driver_name = NULL;
const char *node_name = NULL;
QemuOpts *opts;
BlockDriver *drv;
Error *local_err = NULL;
assert(bs->file == NULL);
assert(options != NULL && bs->options != options);
opts = qemu_opts_create(&bdrv_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto fail_opts;
}
driver_name = qemu_opt_get(opts, "driver");
drv = bdrv_find_format(driver_name);
assert(drv != NULL);
if (file != NULL) {
filename = file->bs->filename;
} else {
filename = qdict_get_try_str(options, "filename");
}
if (drv->bdrv_needs_filename && !filename) {
error_setg(errp, "The '%s' block driver requires a file name",
drv->format_name);
ret = -EINVAL;
goto fail_opts;
}
trace_bdrv_open_common(bs, filename ?: "", bs->open_flags,
drv->format_name);
node_name = qemu_opt_get(opts, "node-name");
bdrv_assign_node_name(bs, node_name, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto fail_opts;
}
bs->read_only = !(bs->open_flags & BDRV_O_RDWR);
if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) {
error_setg(errp,
!bs->read_only && bdrv_is_whitelisted(drv, true)
? "Driver '%s' can only be used for read-only devices"
: "Driver '%s' is not whitelisted",
drv->format_name);
ret = -ENOTSUP;
goto fail_opts;
}
assert(bs->copy_on_read == 0); /* bdrv_new() and bdrv_close() make it so */
if (bs->open_flags & BDRV_O_COPY_ON_READ) {
if (!bs->read_only) {
bdrv_enable_copy_on_read(bs);
} else {
error_setg(errp, "Can't use copy-on-read on read-only device");
ret = -EINVAL;
goto fail_opts;
}
}
if (filename != NULL) {
pstrcpy(bs->filename, sizeof(bs->filename), filename);
} else {
bs->filename[0] = '\0';
}
pstrcpy(bs->exact_filename, sizeof(bs->exact_filename), bs->filename);
bs->drv = drv;
bs->opaque = g_malloc0(drv->instance_size);
/* Apply cache mode options */
update_flags_from_options(&bs->open_flags, opts);
/* Open the image, either directly or using a protocol */
open_flags = bdrv_open_flags(bs, bs->open_flags);
if (drv->bdrv_file_open) {
assert(file == NULL);
assert(!drv->bdrv_needs_filename || filename != NULL);
ret = drv->bdrv_file_open(bs, options, open_flags, &local_err);
} else {
if (file == NULL) {
error_setg(errp, "Can't use '%s' as a block driver for the "
"protocol level", drv->format_name);
ret = -EINVAL;
goto free_and_fail;
}
bs->file = file;
ret = drv->bdrv_open(bs, options, open_flags, &local_err);
}
if (ret < 0) {
if (local_err) {
error_propagate(errp, local_err);
} else if (bs->filename[0]) {
error_setg_errno(errp, -ret, "Could not open '%s'", bs->filename);
} else {
error_setg_errno(errp, -ret, "Could not open image");
}
goto free_and_fail;
}
ret = refresh_total_sectors(bs, bs->total_sectors);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not refresh total sector count");
goto free_and_fail;
}
bdrv_refresh_limits(bs, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto free_and_fail;
}
assert(bdrv_opt_mem_align(bs) != 0);
assert(bdrv_min_mem_align(bs) != 0);
assert(is_power_of_2(bs->request_alignment) || bdrv_is_sg(bs));
qemu_opts_del(opts);
return 0;
free_and_fail:
bs->file = NULL;
g_free(bs->opaque);
bs->opaque = NULL;
bs->drv = NULL;
fail_opts:
qemu_opts_del(opts);
return ret;
}
| false | qemu | a5b8dd2ce83208cd7d6eb4562339ecf5aae13574 | static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file,
QDict *options, Error **errp)
{
int ret, open_flags;
const char *filename;
const char *driver_name = NULL;
const char *node_name = NULL;
QemuOpts *opts;
BlockDriver *drv;
Error *local_err = NULL;
assert(bs->file == NULL);
assert(options != NULL && bs->options != options);
opts = qemu_opts_create(&bdrv_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto fail_opts;
}
driver_name = qemu_opt_get(opts, "driver");
drv = bdrv_find_format(driver_name);
assert(drv != NULL);
if (file != NULL) {
filename = file->bs->filename;
} else {
filename = qdict_get_try_str(options, "filename");
}
if (drv->bdrv_needs_filename && !filename) {
error_setg(errp, "The '%s' block driver requires a file name",
drv->format_name);
ret = -EINVAL;
goto fail_opts;
}
trace_bdrv_open_common(bs, filename ?: "", bs->open_flags,
drv->format_name);
node_name = qemu_opt_get(opts, "node-name");
bdrv_assign_node_name(bs, node_name, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto fail_opts;
}
bs->read_only = !(bs->open_flags & BDRV_O_RDWR);
if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) {
error_setg(errp,
!bs->read_only && bdrv_is_whitelisted(drv, true)
? "Driver '%s' can only be used for read-only devices"
: "Driver '%s' is not whitelisted",
drv->format_name);
ret = -ENOTSUP;
goto fail_opts;
}
assert(bs->copy_on_read == 0);
if (bs->open_flags & BDRV_O_COPY_ON_READ) {
if (!bs->read_only) {
bdrv_enable_copy_on_read(bs);
} else {
error_setg(errp, "Can't use copy-on-read on read-only device");
ret = -EINVAL;
goto fail_opts;
}
}
if (filename != NULL) {
pstrcpy(bs->filename, sizeof(bs->filename), filename);
} else {
bs->filename[0] = '\0';
}
pstrcpy(bs->exact_filename, sizeof(bs->exact_filename), bs->filename);
bs->drv = drv;
bs->opaque = g_malloc0(drv->instance_size);
update_flags_from_options(&bs->open_flags, opts);
open_flags = bdrv_open_flags(bs, bs->open_flags);
if (drv->bdrv_file_open) {
assert(file == NULL);
assert(!drv->bdrv_needs_filename || filename != NULL);
ret = drv->bdrv_file_open(bs, options, open_flags, &local_err);
} else {
if (file == NULL) {
error_setg(errp, "Can't use '%s' as a block driver for the "
"protocol level", drv->format_name);
ret = -EINVAL;
goto free_and_fail;
}
bs->file = file;
ret = drv->bdrv_open(bs, options, open_flags, &local_err);
}
if (ret < 0) {
if (local_err) {
error_propagate(errp, local_err);
} else if (bs->filename[0]) {
error_setg_errno(errp, -ret, "Could not open '%s'", bs->filename);
} else {
error_setg_errno(errp, -ret, "Could not open image");
}
goto free_and_fail;
}
ret = refresh_total_sectors(bs, bs->total_sectors);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not refresh total sector count");
goto free_and_fail;
}
bdrv_refresh_limits(bs, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto free_and_fail;
}
assert(bdrv_opt_mem_align(bs) != 0);
assert(bdrv_min_mem_align(bs) != 0);
assert(is_power_of_2(bs->request_alignment) || bdrv_is_sg(bs));
qemu_opts_del(opts);
return 0;
free_and_fail:
bs->file = NULL;
g_free(bs->opaque);
bs->opaque = NULL;
bs->drv = NULL;
fail_opts:
qemu_opts_del(opts);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, BdrvChild *VAR_1,
QDict *VAR_2, Error **VAR_3)
{
int VAR_4, VAR_5;
const char *VAR_6;
const char *VAR_7 = NULL;
const char *VAR_8 = NULL;
QemuOpts *opts;
BlockDriver *drv;
Error *local_err = NULL;
assert(VAR_0->VAR_1 == NULL);
assert(VAR_2 != NULL && VAR_0->VAR_2 != VAR_2);
opts = qemu_opts_create(&bdrv_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, VAR_2, &local_err);
if (local_err) {
error_propagate(VAR_3, local_err);
VAR_4 = -EINVAL;
goto fail_opts;
}
VAR_7 = qemu_opt_get(opts, "driver");
drv = bdrv_find_format(VAR_7);
assert(drv != NULL);
if (VAR_1 != NULL) {
VAR_6 = VAR_1->VAR_0->VAR_6;
} else {
VAR_6 = qdict_get_try_str(VAR_2, "VAR_6");
}
if (drv->bdrv_needs_filename && !VAR_6) {
error_setg(VAR_3, "The '%s' block driver requires a VAR_1 name",
drv->format_name);
VAR_4 = -EINVAL;
goto fail_opts;
}
trace_bdrv_open_common(VAR_0, VAR_6 ?: "", VAR_0->VAR_5,
drv->format_name);
VAR_8 = qemu_opt_get(opts, "node-name");
bdrv_assign_node_name(VAR_0, VAR_8, &local_err);
if (local_err) {
error_propagate(VAR_3, local_err);
VAR_4 = -EINVAL;
goto fail_opts;
}
VAR_0->read_only = !(VAR_0->VAR_5 & BDRV_O_RDWR);
if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, VAR_0->read_only)) {
error_setg(VAR_3,
!VAR_0->read_only && bdrv_is_whitelisted(drv, true)
? "Driver '%s' can only be used for read-only devices"
: "Driver '%s' is not whitelisted",
drv->format_name);
VAR_4 = -ENOTSUP;
goto fail_opts;
}
assert(VAR_0->copy_on_read == 0);
if (VAR_0->VAR_5 & BDRV_O_COPY_ON_READ) {
if (!VAR_0->read_only) {
bdrv_enable_copy_on_read(VAR_0);
} else {
error_setg(VAR_3, "Can't use copy-on-read on read-only device");
VAR_4 = -EINVAL;
goto fail_opts;
}
}
if (VAR_6 != NULL) {
pstrcpy(VAR_0->VAR_6, sizeof(VAR_0->VAR_6), VAR_6);
} else {
VAR_0->VAR_6[0] = '\0';
}
pstrcpy(VAR_0->exact_filename, sizeof(VAR_0->exact_filename), VAR_0->VAR_6);
VAR_0->drv = drv;
VAR_0->opaque = g_malloc0(drv->instance_size);
update_flags_from_options(&VAR_0->VAR_5, opts);
VAR_5 = bdrv_open_flags(VAR_0, VAR_0->VAR_5);
if (drv->bdrv_file_open) {
assert(VAR_1 == NULL);
assert(!drv->bdrv_needs_filename || VAR_6 != NULL);
VAR_4 = drv->bdrv_file_open(VAR_0, VAR_2, VAR_5, &local_err);
} else {
if (VAR_1 == NULL) {
error_setg(VAR_3, "Can't use '%s' as a block driver for the "
"protocol level", drv->format_name);
VAR_4 = -EINVAL;
goto free_and_fail;
}
VAR_0->VAR_1 = VAR_1;
VAR_4 = drv->bdrv_open(VAR_0, VAR_2, VAR_5, &local_err);
}
if (VAR_4 < 0) {
if (local_err) {
error_propagate(VAR_3, local_err);
} else if (VAR_0->VAR_6[0]) {
error_setg_errno(VAR_3, -VAR_4, "Could not open '%s'", VAR_0->VAR_6);
} else {
error_setg_errno(VAR_3, -VAR_4, "Could not open image");
}
goto free_and_fail;
}
VAR_4 = refresh_total_sectors(VAR_0, VAR_0->total_sectors);
if (VAR_4 < 0) {
error_setg_errno(VAR_3, -VAR_4, "Could not refresh total sector count");
goto free_and_fail;
}
bdrv_refresh_limits(VAR_0, &local_err);
if (local_err) {
error_propagate(VAR_3, local_err);
VAR_4 = -EINVAL;
goto free_and_fail;
}
assert(bdrv_opt_mem_align(VAR_0) != 0);
assert(bdrv_min_mem_align(VAR_0) != 0);
assert(is_power_of_2(VAR_0->request_alignment) || bdrv_is_sg(VAR_0));
qemu_opts_del(opts);
return 0;
free_and_fail:
VAR_0->VAR_1 = NULL;
g_free(VAR_0->opaque);
VAR_0->opaque = NULL;
VAR_0->drv = NULL;
fail_opts:
qemu_opts_del(opts);
return VAR_4;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, BdrvChild *VAR_1,\nQDict *VAR_2, Error **VAR_3)\n{",
"int VAR_4, VAR_5;",
"const char *VAR_6;",
"const char *VAR_7 = NULL;",
"const char *VAR_8 = NULL;",
"QemuOpts *opts;",
"BlockDriver *drv;",
"Error *local_err = NULL;",
"assert(VAR_0->VAR_1 == NULL);",
"assert(VAR_2 != NULL && VAR_0->VAR_2 != VAR_2);",
"opts = qemu_opts_create(&bdrv_runtime_opts, NULL, 0, &error_abort);",
"qemu_opts_absorb_qdict(opts, VAR_2, &local_err);",
"if (local_err) {",
"error_propagate(VAR_3, local_err);",
"VAR_4 = -EINVAL;",
"goto fail_opts;",
"}",
"VAR_7 = qemu_opt_get(opts, \"driver\");",
"drv = bdrv_find_format(VAR_7);",
"assert(drv != NULL);",
"if (VAR_1 != NULL) {",
"VAR_6 = VAR_1->VAR_0->VAR_6;",
"} else {",
"VAR_6 = qdict_get_try_str(VAR_2, \"VAR_6\");",
"}",
"if (drv->bdrv_needs_filename && !VAR_6) {",
"error_setg(VAR_3, \"The '%s' block driver requires a VAR_1 name\",\ndrv->format_name);",
"VAR_4 = -EINVAL;",
"goto fail_opts;",
"}",
"trace_bdrv_open_common(VAR_0, VAR_6 ?: \"\", VAR_0->VAR_5,\ndrv->format_name);",
"VAR_8 = qemu_opt_get(opts, \"node-name\");",
"bdrv_assign_node_name(VAR_0, VAR_8, &local_err);",
"if (local_err) {",
"error_propagate(VAR_3, local_err);",
"VAR_4 = -EINVAL;",
"goto fail_opts;",
"}",
"VAR_0->read_only = !(VAR_0->VAR_5 & BDRV_O_RDWR);",
"if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, VAR_0->read_only)) {",
"error_setg(VAR_3,\n!VAR_0->read_only && bdrv_is_whitelisted(drv, true)\n? \"Driver '%s' can only be used for read-only devices\"\n: \"Driver '%s' is not whitelisted\",\ndrv->format_name);",
"VAR_4 = -ENOTSUP;",
"goto fail_opts;",
"}",
"assert(VAR_0->copy_on_read == 0);",
"if (VAR_0->VAR_5 & BDRV_O_COPY_ON_READ) {",
"if (!VAR_0->read_only) {",
"bdrv_enable_copy_on_read(VAR_0);",
"} else {",
"error_setg(VAR_3, \"Can't use copy-on-read on read-only device\");",
"VAR_4 = -EINVAL;",
"goto fail_opts;",
"}",
"}",
"if (VAR_6 != NULL) {",
"pstrcpy(VAR_0->VAR_6, sizeof(VAR_0->VAR_6), VAR_6);",
"} else {",
"VAR_0->VAR_6[0] = '\\0';",
"}",
"pstrcpy(VAR_0->exact_filename, sizeof(VAR_0->exact_filename), VAR_0->VAR_6);",
"VAR_0->drv = drv;",
"VAR_0->opaque = g_malloc0(drv->instance_size);",
"update_flags_from_options(&VAR_0->VAR_5, opts);",
"VAR_5 = bdrv_open_flags(VAR_0, VAR_0->VAR_5);",
"if (drv->bdrv_file_open) {",
"assert(VAR_1 == NULL);",
"assert(!drv->bdrv_needs_filename || VAR_6 != NULL);",
"VAR_4 = drv->bdrv_file_open(VAR_0, VAR_2, VAR_5, &local_err);",
"} else {",
"if (VAR_1 == NULL) {",
"error_setg(VAR_3, \"Can't use '%s' as a block driver for the \"\n\"protocol level\", drv->format_name);",
"VAR_4 = -EINVAL;",
"goto free_and_fail;",
"}",
"VAR_0->VAR_1 = VAR_1;",
"VAR_4 = drv->bdrv_open(VAR_0, VAR_2, VAR_5, &local_err);",
"}",
"if (VAR_4 < 0) {",
"if (local_err) {",
"error_propagate(VAR_3, local_err);",
"} else if (VAR_0->VAR_6[0]) {",
"error_setg_errno(VAR_3, -VAR_4, \"Could not open '%s'\", VAR_0->VAR_6);",
"} else {",
"error_setg_errno(VAR_3, -VAR_4, \"Could not open image\");",
"}",
"goto free_and_fail;",
"}",
"VAR_4 = refresh_total_sectors(VAR_0, VAR_0->total_sectors);",
"if (VAR_4 < 0) {",
"error_setg_errno(VAR_3, -VAR_4, \"Could not refresh total sector count\");",
"goto free_and_fail;",
"}",
"bdrv_refresh_limits(VAR_0, &local_err);",
"if (local_err) {",
"error_propagate(VAR_3, local_err);",
"VAR_4 = -EINVAL;",
"goto free_and_fail;",
"}",
"assert(bdrv_opt_mem_align(VAR_0) != 0);",
"assert(bdrv_min_mem_align(VAR_0) != 0);",
"assert(is_power_of_2(VAR_0->request_alignment) || bdrv_is_sg(VAR_0));",
"qemu_opts_del(opts);",
"return 0;",
"free_and_fail:\nVAR_0->VAR_1 = NULL;",
"g_free(VAR_0->opaque);",
"VAR_0->opaque = NULL;",
"VAR_0->drv = NULL;",
"fail_opts:\nqemu_opts_del(opts);",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
79,
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
105
],
[
107,
109,
111,
113,
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
161
],
[
163
],
[
169
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189,
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
255
],
[
257
],
[
259
],
[
263
],
[
265
],
[
269,
271
],
[
273
],
[
275
],
[
277
],
[
279,
281
],
[
283
],
[
285
]
] |
20,791 | static void test_visitor_out_enum_errors(TestOutputVisitorData *data,
const void *unused)
{
EnumOne i, bad_values[] = { ENUM_ONE__MAX, -1 };
Error *err;
for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) {
err = NULL;
visit_type_EnumOne(data->ov, "unused", &bad_values[i], &err);
g_assert(err);
error_free(err);
visitor_reset(data);
}
}
| false | qemu | b3db211f3c80bb996a704d665fe275619f728bd4 | static void test_visitor_out_enum_errors(TestOutputVisitorData *data,
const void *unused)
{
EnumOne i, bad_values[] = { ENUM_ONE__MAX, -1 };
Error *err;
for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) {
err = NULL;
visit_type_EnumOne(data->ov, "unused", &bad_values[i], &err);
g_assert(err);
error_free(err);
visitor_reset(data);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TestOutputVisitorData *VAR_0,
const void *VAR_1)
{
EnumOne i, bad_values[] = { ENUM_ONE__MAX, -1 };
Error *err;
for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) {
err = NULL;
visit_type_EnumOne(VAR_0->ov, "VAR_1", &bad_values[i], &err);
g_assert(err);
error_free(err);
visitor_reset(VAR_0);
}
}
| [
"static void FUNC_0(TestOutputVisitorData *VAR_0,\nconst void *VAR_1)\n{",
"EnumOne i, bad_values[] = { ENUM_ONE__MAX, -1 };",
"Error *err;",
"for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) {",
"err = NULL;",
"visit_type_EnumOne(VAR_0->ov, \"VAR_1\", &bad_values[i], &err);",
"g_assert(err);",
"error_free(err);",
"visitor_reset(VAR_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
]
] |
20,792 | static size_t v9fs_unpack(void *dst, struct iovec *out_sg, int out_num,
size_t offset, size_t size)
{
return v9fs_packunpack(dst, out_sg, out_num, offset, size, 0);
}
| false | qemu | ddca7f86ac022289840e0200fd4050b2b58e9176 | static size_t v9fs_unpack(void *dst, struct iovec *out_sg, int out_num,
size_t offset, size_t size)
{
return v9fs_packunpack(dst, out_sg, out_num, offset, size, 0);
}
| {
"code": [],
"line_no": []
} | static size_t FUNC_0(void *dst, struct iovec *out_sg, int out_num,
size_t offset, size_t size)
{
return v9fs_packunpack(dst, out_sg, out_num, offset, size, 0);
}
| [
"static size_t FUNC_0(void *dst, struct iovec *out_sg, int out_num,\nsize_t offset, size_t size)\n{",
"return v9fs_packunpack(dst, out_sg, out_num, offset, size, 0);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
]
] |
20,793 | print_with_operands (const struct cris_opcode *opcodep,
unsigned int insn,
unsigned char *buffer,
bfd_vma addr,
disassemble_info *info,
/* If a prefix insn was before this insn (and is supposed
to be output as an address), here is a description of
it. */
const struct cris_opcode *prefix_opcodep,
unsigned int prefix_insn,
unsigned char *prefix_buffer,
bfd_boolean with_reg_prefix)
{
/* Get a buffer of somewhat reasonable size where we store
intermediate parts of the insn. */
char temp[sizeof (".d [$r13=$r12-2147483648],$r10") * 2];
char *tp = temp;
static const char mode_char[] = "bwd?";
const char *s;
const char *cs;
struct cris_disasm_data *disdata
= (struct cris_disasm_data *) info->private_data;
/* Print out the name first thing we do. */
(*info->fprintf_func) (info->stream, "%s", opcodep->name);
cs = opcodep->args;
s = cs;
/* Ignore any prefix indicator. */
if (*s == 'p')
s++;
if (*s == 'm' || *s == 'M' || *s == 'z')
{
*tp++ = '.';
/* Get the size-letter. */
*tp++ = *s == 'M'
? (insn & 0x8000 ? 'd'
: insn & 0x4000 ? 'w' : 'b')
: mode_char[(insn >> 4) & (*s == 'z' ? 1 : 3)];
/* Ignore the size and the space character that follows. */
s += 2;
}
/* Add a space if this isn't a long-branch, because for those will add
the condition part of the name later. */
if (opcodep->match != (BRANCH_PC_LOW + BRANCH_INCR_HIGH * 256))
*tp++ = ' ';
/* Fill in the insn-type if deducible from the name (and there's no
better way). */
if (opcodep->name[0] == 'j')
{
if (CONST_STRNEQ (opcodep->name, "jsr"))
/* It's "jsr" or "jsrc". */
info->insn_type = dis_jsr;
else
/* Any other jump-type insn is considered a branch. */
info->insn_type = dis_branch;
}
/* We might know some more fields right now. */
info->branch_delay_insns = opcodep->delayed;
/* Handle operands. */
for (; *s; s++)
{
switch (*s)
{
case 'T':
tp = format_sup_reg ((insn >> 12) & 15, tp, with_reg_prefix);
break;
case 'A':
if (with_reg_prefix)
*tp++ = REGISTER_PREFIX_CHAR;
*tp++ = 'a';
*tp++ = 'c';
*tp++ = 'r';
break;
case '[':
case ']':
case ',':
*tp++ = *s;
break;
case '!':
/* Ignore at this point; used at earlier stages to avoid
recognition if there's a prefix at something that in other
ways looks like a "pop". */
break;
case 'd':
/* Ignore. This is an optional ".d " on the large one of
relaxable insns. */
break;
case 'B':
/* This was the prefix that made this a "push". We've already
handled it by recognizing it, so signal that the prefix is
handled by setting it to NULL. */
prefix_opcodep = NULL;
break;
case 'D':
case 'r':
tp = format_reg (disdata, insn & 15, tp, with_reg_prefix);
break;
case 'R':
tp = format_reg (disdata, (insn >> 12) & 15, tp, with_reg_prefix);
break;
case 'n':
{
/* Like N but pc-relative to the start of the insn. */
unsigned long number
= (buffer[2] + buffer[3] * 256 + buffer[4] * 65536
+ buffer[5] * 0x1000000 + addr);
/* Finish off and output previous formatted bytes. */
*tp = 0;
if (temp[0])
(*info->fprintf_func) (info->stream, "%s", temp);
tp = temp;
(*info->print_address_func) ((bfd_vma) number, info);
}
break;
case 'u':
{
/* Like n but the offset is bits <3:0> in the instruction. */
unsigned long number = (buffer[0] & 0xf) * 2 + addr;
/* Finish off and output previous formatted bytes. */
*tp = 0;
if (temp[0])
(*info->fprintf_func) (info->stream, "%s", temp);
tp = temp;
(*info->print_address_func) ((bfd_vma) number, info);
}
break;
case 'N':
case 'y':
case 'Y':
case 'S':
case 's':
/* Any "normal" memory operand. */
if ((insn & 0x400) && (insn & 15) == 15 && prefix_opcodep == NULL)
{
/* We're looking at [pc+], i.e. we need to output an immediate
number, where the size can depend on different things. */
long number;
int signedp
= ((*cs == 'z' && (insn & 0x20))
|| opcodep->match == BDAP_QUICK_OPCODE);
int nbytes;
if (opcodep->imm_oprnd_size == SIZE_FIX_32)
nbytes = 4;
else if (opcodep->imm_oprnd_size == SIZE_SPEC_REG)
{
const struct cris_spec_reg *sregp
= spec_reg_info ((insn >> 12) & 15, disdata->distype);
/* A NULL return should have been as a non-match earlier,
so catch it as an internal error in the error-case
below. */
if (sregp == NULL)
/* Whatever non-valid size. */
nbytes = 42;
else
/* PC is always incremented by a multiple of two.
For CRISv32, immediates are always 4 bytes for
special registers. */
nbytes = disdata->distype == cris_dis_v32
? 4 : (sregp->reg_size + 1) & ~1;
}
else
{
int mode_size = 1 << ((insn >> 4) & (*cs == 'z' ? 1 : 3));
if (mode_size == 1)
nbytes = 2;
else
nbytes = mode_size;
}
switch (nbytes)
{
case 1:
number = buffer[2];
if (signedp && number > 127)
number -= 256;
break;
case 2:
number = buffer[2] + buffer[3] * 256;
if (signedp && number > 32767)
number -= 65536;
break;
case 4:
number
= buffer[2] + buffer[3] * 256 + buffer[4] * 65536
+ buffer[5] * 0x1000000;
break;
default:
strcpy (tp, "bug");
tp += 3;
number = 42;
}
if ((*cs == 'z' && (insn & 0x20))
|| (opcodep->match == BDAP_QUICK_OPCODE
&& (nbytes <= 2 || buffer[1 + nbytes] == 0)))
tp = format_dec (number, tp, signedp);
else
{
unsigned int highbyte = (number >> 24) & 0xff;
/* Either output this as an address or as a number. If it's
a dword with the same high-byte as the address of the
insn, assume it's an address, and also if it's a non-zero
non-0xff high-byte. If this is a jsr or a jump, then
it's definitely an address. */
if (nbytes == 4
&& (highbyte == ((addr >> 24) & 0xff)
|| (highbyte != 0 && highbyte != 0xff)
|| info->insn_type == dis_branch
|| info->insn_type == dis_jsr))
{
/* Finish off and output previous formatted bytes. */
*tp = 0;
tp = temp;
if (temp[0])
(*info->fprintf_func) (info->stream, "%s", temp);
(*info->print_address_func) ((bfd_vma) number, info);
info->target = number;
}
else
tp = format_hex (number, tp, disdata);
}
}
else
{
/* Not an immediate number. Then this is a (possibly
prefixed) memory operand. */
if (info->insn_type != dis_nonbranch)
{
int mode_size
= 1 << ((insn >> 4)
& (opcodep->args[0] == 'z' ? 1 : 3));
int size;
info->insn_type = dis_dref;
info->flags |= CRIS_DIS_FLAG_MEMREF;
if (opcodep->imm_oprnd_size == SIZE_FIX_32)
size = 4;
else if (opcodep->imm_oprnd_size == SIZE_SPEC_REG)
{
const struct cris_spec_reg *sregp
= spec_reg_info ((insn >> 12) & 15, disdata->distype);
/* FIXME: Improve error handling; should have been caught
earlier. */
if (sregp == NULL)
size = 4;
else
size = sregp->reg_size;
}
else
size = mode_size;
info->data_size = size;
}
*tp++ = '[';
if (prefix_opcodep
/* We don't match dip with a postincremented field
as a side-effect address mode. */
&& ((insn & 0x400) == 0
|| prefix_opcodep->match != DIP_OPCODE))
{
if (insn & 0x400)
{
tp = format_reg (disdata, insn & 15, tp, with_reg_prefix);
*tp++ = '=';
}
/* We mainly ignore the prefix format string when the
address-mode syntax is output. */
switch (prefix_opcodep->match)
{
case DIP_OPCODE:
/* It's [r], [r+] or [pc+]. */
if ((prefix_insn & 0x400) && (prefix_insn & 15) == 15)
{
/* It's [pc+]. This cannot possibly be anything
but an address. */
unsigned long number
= prefix_buffer[2] + prefix_buffer[3] * 256
+ prefix_buffer[4] * 65536
+ prefix_buffer[5] * 0x1000000;
info->target = (bfd_vma) number;
/* Finish off and output previous formatted
data. */
*tp = 0;
tp = temp;
if (temp[0])
(*info->fprintf_func) (info->stream, "%s", temp);
(*info->print_address_func) ((bfd_vma) number, info);
}
else
{
/* For a memref in an address, we use target2.
In this case, target is zero. */
info->flags
|= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
| CRIS_DIS_FLAG_MEM_TARGET2_MEM);
info->target2 = prefix_insn & 15;
*tp++ = '[';
tp = format_reg (disdata, prefix_insn & 15, tp,
with_reg_prefix);
if (prefix_insn & 0x400)
*tp++ = '+';
*tp++ = ']';
}
break;
case BDAP_QUICK_OPCODE:
{
int number;
number = prefix_buffer[0];
if (number > 127)
number -= 256;
/* Output "reg+num" or, if num < 0, "reg-num". */
tp = format_reg (disdata, (prefix_insn >> 12) & 15, tp,
with_reg_prefix);
if (number >= 0)
*tp++ = '+';
tp = format_dec (number, tp, 1);
info->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;
info->target = (prefix_insn >> 12) & 15;
info->target2 = (bfd_vma) number;
break;
}
case BIAP_OPCODE:
/* Output "r+R.m". */
tp = format_reg (disdata, prefix_insn & 15, tp,
with_reg_prefix);
*tp++ = '+';
tp = format_reg (disdata, (prefix_insn >> 12) & 15, tp,
with_reg_prefix);
*tp++ = '.';
*tp++ = mode_char[(prefix_insn >> 4) & 3];
info->flags
|= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
| CRIS_DIS_FLAG_MEM_TARGET_IS_REG
| ((prefix_insn & 0x8000)
? CRIS_DIS_FLAG_MEM_TARGET2_MULT4
: ((prefix_insn & 0x8000)
? CRIS_DIS_FLAG_MEM_TARGET2_MULT2 : 0)));
/* Is it the casejump? It's a "adds.w [pc+r%d.w],pc". */
if (insn == 0xf83f && (prefix_insn & ~0xf000) == 0x55f)
/* Then start interpreting data as offsets. */
case_offset_counter = no_of_case_offsets;
break;
case BDAP_INDIR_OPCODE:
/* Output "r+s.m", or, if "s" is [pc+], "r+s" or
"r-s". */
tp = format_reg (disdata, (prefix_insn >> 12) & 15, tp,
with_reg_prefix);
if ((prefix_insn & 0x400) && (prefix_insn & 15) == 15)
{
long number;
unsigned int nbytes;
/* It's a value. Get its size. */
int mode_size = 1 << ((prefix_insn >> 4) & 3);
if (mode_size == 1)
nbytes = 2;
else
nbytes = mode_size;
switch (nbytes)
{
case 1:
number = prefix_buffer[2];
if (number > 127)
number -= 256;
break;
case 2:
number = prefix_buffer[2] + prefix_buffer[3] * 256;
if (number > 32767)
number -= 65536;
break;
case 4:
number
= prefix_buffer[2] + prefix_buffer[3] * 256
+ prefix_buffer[4] * 65536
+ prefix_buffer[5] * 0x1000000;
break;
default:
strcpy (tp, "bug");
tp += 3;
number = 42;
}
info->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;
info->target2 = (bfd_vma) number;
/* If the size is dword, then assume it's an
address. */
if (nbytes == 4)
{
/* Finish off and output previous formatted
bytes. */
*tp++ = '+';
*tp = 0;
tp = temp;
(*info->fprintf_func) (info->stream, "%s", temp);
(*info->print_address_func) ((bfd_vma) number, info);
}
else
{
if (number >= 0)
*tp++ = '+';
tp = format_dec (number, tp, 1);
}
}
else
{
/* Output "r+[R].m" or "r+[R+].m". */
*tp++ = '+';
*tp++ = '[';
tp = format_reg (disdata, prefix_insn & 15, tp,
with_reg_prefix);
if (prefix_insn & 0x400)
*tp++ = '+';
*tp++ = ']';
*tp++ = '.';
*tp++ = mode_char[(prefix_insn >> 4) & 3];
info->flags
|= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
| CRIS_DIS_FLAG_MEM_TARGET2_MEM
| CRIS_DIS_FLAG_MEM_TARGET_IS_REG
| (((prefix_insn >> 4) == 2)
? 0
: (((prefix_insn >> 4) & 3) == 1
? CRIS_DIS_FLAG_MEM_TARGET2_MEM_WORD
: CRIS_DIS_FLAG_MEM_TARGET2_MEM_BYTE)));
}
break;
default:
(*info->fprintf_func) (info->stream, "?prefix-bug");
}
/* To mark that the prefix is used, reset it. */
prefix_opcodep = NULL;
}
else
{
tp = format_reg (disdata, insn & 15, tp, with_reg_prefix);
info->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;
info->target = insn & 15;
if (insn & 0x400)
*tp++ = '+';
}
*tp++ = ']';
}
break;
case 'x':
tp = format_reg (disdata, (insn >> 12) & 15, tp, with_reg_prefix);
*tp++ = '.';
*tp++ = mode_char[(insn >> 4) & 3];
break;
case 'I':
tp = format_dec (insn & 63, tp, 0);
break;
case 'b':
{
int where = buffer[2] + buffer[3] * 256;
if (where > 32767)
where -= 65536;
where += addr + ((disdata->distype == cris_dis_v32) ? 0 : 4);
if (insn == BA_PC_INCR_OPCODE)
info->insn_type = dis_branch;
else
info->insn_type = dis_condbranch;
info->target = (bfd_vma) where;
*tp = 0;
tp = temp;
(*info->fprintf_func) (info->stream, "%s%s ",
temp, cris_cc_strings[insn >> 12]);
(*info->print_address_func) ((bfd_vma) where, info);
}
break;
case 'c':
tp = format_dec (insn & 31, tp, 0);
break;
case 'C':
tp = format_dec (insn & 15, tp, 0);
break;
case 'o':
{
long offset = insn & 0xfe;
bfd_vma target;
if (insn & 1)
offset |= ~0xff;
if (opcodep->match == BA_QUICK_OPCODE)
info->insn_type = dis_branch;
else
info->insn_type = dis_condbranch;
target = addr + ((disdata->distype == cris_dis_v32) ? 0 : 2) + offset;
info->target = target;
*tp = 0;
tp = temp;
(*info->fprintf_func) (info->stream, "%s", temp);
(*info->print_address_func) (target, info);
}
break;
case 'Q':
case 'O':
{
long number = buffer[0];
if (number > 127)
number = number - 256;
tp = format_dec (number, tp, 1);
*tp++ = ',';
tp = format_reg (disdata, (insn >> 12) & 15, tp, with_reg_prefix);
}
break;
case 'f':
tp = print_flags (disdata, insn, tp);
break;
case 'i':
tp = format_dec ((insn & 32) ? (insn & 31) | ~31L : insn & 31, tp, 1);
break;
case 'P':
{
const struct cris_spec_reg *sregp
= spec_reg_info ((insn >> 12) & 15, disdata->distype);
if (sregp->name == NULL)
/* Should have been caught as a non-match earlier. */
*tp++ = '?';
else
{
if (with_reg_prefix)
*tp++ = REGISTER_PREFIX_CHAR;
strcpy (tp, sregp->name);
tp += strlen (tp);
}
}
break;
default:
strcpy (tp, "???");
tp += 3;
}
}
*tp = 0;
if (prefix_opcodep)
(*info->fprintf_func) (info->stream, " (OOPS unused prefix \"%s: %s\")",
prefix_opcodep->name, prefix_opcodep->args);
(*info->fprintf_func) (info->stream, "%s", temp);
/* Get info for matching case-tables, if we don't have any active.
We assume that the last constant seen is used; either in the insn
itself or in a "move.d const,rN, sub.d rN,rM"-like sequence. */
if (TRACE_CASE && case_offset_counter == 0)
{
if (CONST_STRNEQ (opcodep->name, "sub"))
case_offset = last_immediate;
/* It could also be an "add", if there are negative case-values. */
else if (CONST_STRNEQ (opcodep->name, "add"))
/* The first case is the negated operand to the add. */
case_offset = -last_immediate;
/* A bound insn will tell us the number of cases. */
else if (CONST_STRNEQ (opcodep->name, "bound"))
no_of_case_offsets = last_immediate + 1;
/* A jump or jsr or branch breaks the chain of insns for a
case-table, so assume default first-case again. */
else if (info->insn_type == dis_jsr
|| info->insn_type == dis_branch
|| info->insn_type == dis_condbranch)
case_offset = 0;
}
}
| false | qemu | e11078846996ded6f824868ae63a0c77031ad64c | print_with_operands (const struct cris_opcode *opcodep,
unsigned int insn,
unsigned char *buffer,
bfd_vma addr,
disassemble_info *info,
const struct cris_opcode *prefix_opcodep,
unsigned int prefix_insn,
unsigned char *prefix_buffer,
bfd_boolean with_reg_prefix)
{
char temp[sizeof (".d [$r13=$r12-2147483648],$r10") * 2];
char *tp = temp;
static const char mode_char[] = "bwd?";
const char *s;
const char *cs;
struct cris_disasm_data *disdata
= (struct cris_disasm_data *) info->private_data;
(*info->fprintf_func) (info->stream, "%s", opcodep->name);
cs = opcodep->args;
s = cs;
if (*s == 'p')
s++;
if (*s == 'm' || *s == 'M' || *s == 'z')
{
*tp++ = '.';
*tp++ = *s == 'M'
? (insn & 0x8000 ? 'd'
: insn & 0x4000 ? 'w' : 'b')
: mode_char[(insn >> 4) & (*s == 'z' ? 1 : 3)];
s += 2;
}
if (opcodep->match != (BRANCH_PC_LOW + BRANCH_INCR_HIGH * 256))
*tp++ = ' ';
if (opcodep->name[0] == 'j')
{
if (CONST_STRNEQ (opcodep->name, "jsr"))
info->insn_type = dis_jsr;
else
info->insn_type = dis_branch;
}
info->branch_delay_insns = opcodep->delayed;
for (; *s; s++)
{
switch (*s)
{
case 'T':
tp = format_sup_reg ((insn >> 12) & 15, tp, with_reg_prefix);
break;
case 'A':
if (with_reg_prefix)
*tp++ = REGISTER_PREFIX_CHAR;
*tp++ = 'a';
*tp++ = 'c';
*tp++ = 'r';
break;
case '[':
case ']':
case ',':
*tp++ = *s;
break;
case '!':
break;
case 'd':
break;
case 'B':
prefix_opcodep = NULL;
break;
case 'D':
case 'r':
tp = format_reg (disdata, insn & 15, tp, with_reg_prefix);
break;
case 'R':
tp = format_reg (disdata, (insn >> 12) & 15, tp, with_reg_prefix);
break;
case 'n':
{
unsigned long number
= (buffer[2] + buffer[3] * 256 + buffer[4] * 65536
+ buffer[5] * 0x1000000 + addr);
*tp = 0;
if (temp[0])
(*info->fprintf_func) (info->stream, "%s", temp);
tp = temp;
(*info->print_address_func) ((bfd_vma) number, info);
}
break;
case 'u':
{
unsigned long number = (buffer[0] & 0xf) * 2 + addr;
*tp = 0;
if (temp[0])
(*info->fprintf_func) (info->stream, "%s", temp);
tp = temp;
(*info->print_address_func) ((bfd_vma) number, info);
}
break;
case 'N':
case 'y':
case 'Y':
case 'S':
case 's':
if ((insn & 0x400) && (insn & 15) == 15 && prefix_opcodep == NULL)
{
long number;
int signedp
= ((*cs == 'z' && (insn & 0x20))
|| opcodep->match == BDAP_QUICK_OPCODE);
int nbytes;
if (opcodep->imm_oprnd_size == SIZE_FIX_32)
nbytes = 4;
else if (opcodep->imm_oprnd_size == SIZE_SPEC_REG)
{
const struct cris_spec_reg *sregp
= spec_reg_info ((insn >> 12) & 15, disdata->distype);
if (sregp == NULL)
nbytes = 42;
else
nbytes = disdata->distype == cris_dis_v32
? 4 : (sregp->reg_size + 1) & ~1;
}
else
{
int mode_size = 1 << ((insn >> 4) & (*cs == 'z' ? 1 : 3));
if (mode_size == 1)
nbytes = 2;
else
nbytes = mode_size;
}
switch (nbytes)
{
case 1:
number = buffer[2];
if (signedp && number > 127)
number -= 256;
break;
case 2:
number = buffer[2] + buffer[3] * 256;
if (signedp && number > 32767)
number -= 65536;
break;
case 4:
number
= buffer[2] + buffer[3] * 256 + buffer[4] * 65536
+ buffer[5] * 0x1000000;
break;
default:
strcpy (tp, "bug");
tp += 3;
number = 42;
}
if ((*cs == 'z' && (insn & 0x20))
|| (opcodep->match == BDAP_QUICK_OPCODE
&& (nbytes <= 2 || buffer[1 + nbytes] == 0)))
tp = format_dec (number, tp, signedp);
else
{
unsigned int highbyte = (number >> 24) & 0xff;
if (nbytes == 4
&& (highbyte == ((addr >> 24) & 0xff)
|| (highbyte != 0 && highbyte != 0xff)
|| info->insn_type == dis_branch
|| info->insn_type == dis_jsr))
{
*tp = 0;
tp = temp;
if (temp[0])
(*info->fprintf_func) (info->stream, "%s", temp);
(*info->print_address_func) ((bfd_vma) number, info);
info->target = number;
}
else
tp = format_hex (number, tp, disdata);
}
}
else
{
if (info->insn_type != dis_nonbranch)
{
int mode_size
= 1 << ((insn >> 4)
& (opcodep->args[0] == 'z' ? 1 : 3));
int size;
info->insn_type = dis_dref;
info->flags |= CRIS_DIS_FLAG_MEMREF;
if (opcodep->imm_oprnd_size == SIZE_FIX_32)
size = 4;
else if (opcodep->imm_oprnd_size == SIZE_SPEC_REG)
{
const struct cris_spec_reg *sregp
= spec_reg_info ((insn >> 12) & 15, disdata->distype);
if (sregp == NULL)
size = 4;
else
size = sregp->reg_size;
}
else
size = mode_size;
info->data_size = size;
}
*tp++ = '[';
if (prefix_opcodep
&& ((insn & 0x400) == 0
|| prefix_opcodep->match != DIP_OPCODE))
{
if (insn & 0x400)
{
tp = format_reg (disdata, insn & 15, tp, with_reg_prefix);
*tp++ = '=';
}
switch (prefix_opcodep->match)
{
case DIP_OPCODE:
if ((prefix_insn & 0x400) && (prefix_insn & 15) == 15)
{
unsigned long number
= prefix_buffer[2] + prefix_buffer[3] * 256
+ prefix_buffer[4] * 65536
+ prefix_buffer[5] * 0x1000000;
info->target = (bfd_vma) number;
*tp = 0;
tp = temp;
if (temp[0])
(*info->fprintf_func) (info->stream, "%s", temp);
(*info->print_address_func) ((bfd_vma) number, info);
}
else
{
info->flags
|= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
| CRIS_DIS_FLAG_MEM_TARGET2_MEM);
info->target2 = prefix_insn & 15;
*tp++ = '[';
tp = format_reg (disdata, prefix_insn & 15, tp,
with_reg_prefix);
if (prefix_insn & 0x400)
*tp++ = '+';
*tp++ = ']';
}
break;
case BDAP_QUICK_OPCODE:
{
int number;
number = prefix_buffer[0];
if (number > 127)
number -= 256;
tp = format_reg (disdata, (prefix_insn >> 12) & 15, tp,
with_reg_prefix);
if (number >= 0)
*tp++ = '+';
tp = format_dec (number, tp, 1);
info->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;
info->target = (prefix_insn >> 12) & 15;
info->target2 = (bfd_vma) number;
break;
}
case BIAP_OPCODE:
tp = format_reg (disdata, prefix_insn & 15, tp,
with_reg_prefix);
*tp++ = '+';
tp = format_reg (disdata, (prefix_insn >> 12) & 15, tp,
with_reg_prefix);
*tp++ = '.';
*tp++ = mode_char[(prefix_insn >> 4) & 3];
info->flags
|= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
| CRIS_DIS_FLAG_MEM_TARGET_IS_REG
| ((prefix_insn & 0x8000)
? CRIS_DIS_FLAG_MEM_TARGET2_MULT4
: ((prefix_insn & 0x8000)
? CRIS_DIS_FLAG_MEM_TARGET2_MULT2 : 0)));
if (insn == 0xf83f && (prefix_insn & ~0xf000) == 0x55f)
case_offset_counter = no_of_case_offsets;
break;
case BDAP_INDIR_OPCODE:
tp = format_reg (disdata, (prefix_insn >> 12) & 15, tp,
with_reg_prefix);
if ((prefix_insn & 0x400) && (prefix_insn & 15) == 15)
{
long number;
unsigned int nbytes;
int mode_size = 1 << ((prefix_insn >> 4) & 3);
if (mode_size == 1)
nbytes = 2;
else
nbytes = mode_size;
switch (nbytes)
{
case 1:
number = prefix_buffer[2];
if (number > 127)
number -= 256;
break;
case 2:
number = prefix_buffer[2] + prefix_buffer[3] * 256;
if (number > 32767)
number -= 65536;
break;
case 4:
number
= prefix_buffer[2] + prefix_buffer[3] * 256
+ prefix_buffer[4] * 65536
+ prefix_buffer[5] * 0x1000000;
break;
default:
strcpy (tp, "bug");
tp += 3;
number = 42;
}
info->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;
info->target2 = (bfd_vma) number;
if (nbytes == 4)
{
*tp++ = '+';
*tp = 0;
tp = temp;
(*info->fprintf_func) (info->stream, "%s", temp);
(*info->print_address_func) ((bfd_vma) number, info);
}
else
{
if (number >= 0)
*tp++ = '+';
tp = format_dec (number, tp, 1);
}
}
else
{
*tp++ = '+';
*tp++ = '[';
tp = format_reg (disdata, prefix_insn & 15, tp,
with_reg_prefix);
if (prefix_insn & 0x400)
*tp++ = '+';
*tp++ = ']';
*tp++ = '.';
*tp++ = mode_char[(prefix_insn >> 4) & 3];
info->flags
|= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
| CRIS_DIS_FLAG_MEM_TARGET2_MEM
| CRIS_DIS_FLAG_MEM_TARGET_IS_REG
| (((prefix_insn >> 4) == 2)
? 0
: (((prefix_insn >> 4) & 3) == 1
? CRIS_DIS_FLAG_MEM_TARGET2_MEM_WORD
: CRIS_DIS_FLAG_MEM_TARGET2_MEM_BYTE)));
}
break;
default:
(*info->fprintf_func) (info->stream, "?prefix-bug");
}
prefix_opcodep = NULL;
}
else
{
tp = format_reg (disdata, insn & 15, tp, with_reg_prefix);
info->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;
info->target = insn & 15;
if (insn & 0x400)
*tp++ = '+';
}
*tp++ = ']';
}
break;
case 'x':
tp = format_reg (disdata, (insn >> 12) & 15, tp, with_reg_prefix);
*tp++ = '.';
*tp++ = mode_char[(insn >> 4) & 3];
break;
case 'I':
tp = format_dec (insn & 63, tp, 0);
break;
case 'b':
{
int where = buffer[2] + buffer[3] * 256;
if (where > 32767)
where -= 65536;
where += addr + ((disdata->distype == cris_dis_v32) ? 0 : 4);
if (insn == BA_PC_INCR_OPCODE)
info->insn_type = dis_branch;
else
info->insn_type = dis_condbranch;
info->target = (bfd_vma) where;
*tp = 0;
tp = temp;
(*info->fprintf_func) (info->stream, "%s%s ",
temp, cris_cc_strings[insn >> 12]);
(*info->print_address_func) ((bfd_vma) where, info);
}
break;
case 'c':
tp = format_dec (insn & 31, tp, 0);
break;
case 'C':
tp = format_dec (insn & 15, tp, 0);
break;
case 'o':
{
long offset = insn & 0xfe;
bfd_vma target;
if (insn & 1)
offset |= ~0xff;
if (opcodep->match == BA_QUICK_OPCODE)
info->insn_type = dis_branch;
else
info->insn_type = dis_condbranch;
target = addr + ((disdata->distype == cris_dis_v32) ? 0 : 2) + offset;
info->target = target;
*tp = 0;
tp = temp;
(*info->fprintf_func) (info->stream, "%s", temp);
(*info->print_address_func) (target, info);
}
break;
case 'Q':
case 'O':
{
long number = buffer[0];
if (number > 127)
number = number - 256;
tp = format_dec (number, tp, 1);
*tp++ = ',';
tp = format_reg (disdata, (insn >> 12) & 15, tp, with_reg_prefix);
}
break;
case 'f':
tp = print_flags (disdata, insn, tp);
break;
case 'i':
tp = format_dec ((insn & 32) ? (insn & 31) | ~31L : insn & 31, tp, 1);
break;
case 'P':
{
const struct cris_spec_reg *sregp
= spec_reg_info ((insn >> 12) & 15, disdata->distype);
if (sregp->name == NULL)
*tp++ = '?';
else
{
if (with_reg_prefix)
*tp++ = REGISTER_PREFIX_CHAR;
strcpy (tp, sregp->name);
tp += strlen (tp);
}
}
break;
default:
strcpy (tp, "???");
tp += 3;
}
}
*tp = 0;
if (prefix_opcodep)
(*info->fprintf_func) (info->stream, " (OOPS unused prefix \"%s: %s\")",
prefix_opcodep->name, prefix_opcodep->args);
(*info->fprintf_func) (info->stream, "%s", temp);
if (TRACE_CASE && case_offset_counter == 0)
{
if (CONST_STRNEQ (opcodep->name, "sub"))
case_offset = last_immediate;
else if (CONST_STRNEQ (opcodep->name, "add"))
case_offset = -last_immediate;
else if (CONST_STRNEQ (opcodep->name, "bound"))
no_of_case_offsets = last_immediate + 1;
else if (info->insn_type == dis_jsr
|| info->insn_type == dis_branch
|| info->insn_type == dis_condbranch)
case_offset = 0;
}
}
| {
"code": [],
"line_no": []
} | FUNC_0 (const struct cris_opcode *VAR_0,
unsigned int VAR_1,
unsigned char *VAR_2,
bfd_vma VAR_3,
disassemble_info *VAR_4,
const struct cris_opcode *VAR_5,
unsigned int VAR_6,
unsigned char *VAR_7,
bfd_boolean VAR_8)
{
char VAR_9[sizeof (".d [$r13=$r12-2147483648],$r10") * 2];
char *VAR_10 = VAR_9;
static const char VAR_11[] = "bwd?";
const char *VAR_12;
const char *VAR_13;
struct cris_disasm_data *VAR_14
= (struct cris_disasm_data *) VAR_4->private_data;
(*VAR_4->fprintf_func) (VAR_4->stream, "%VAR_12", VAR_0->name);
VAR_13 = VAR_0->args;
VAR_12 = VAR_13;
if (*VAR_12 == 'p')
VAR_12++;
if (*VAR_12 == 'm' || *VAR_12 == 'M' || *VAR_12 == 'z')
{
*VAR_10++ = '.';
*VAR_10++ = *VAR_12 == 'M'
? (VAR_1 & 0x8000 ? 'd'
: VAR_1 & 0x4000 ? 'w' : 'b')
: VAR_11[(VAR_1 >> 4) & (*VAR_12 == 'z' ? 1 : 3)];
VAR_12 += 2;
}
if (VAR_0->match != (BRANCH_PC_LOW + BRANCH_INCR_HIGH * 256))
*VAR_10++ = ' ';
if (VAR_0->name[0] == 'j')
{
if (CONST_STRNEQ (VAR_0->name, "jsr"))
VAR_4->insn_type = dis_jsr;
else
VAR_4->insn_type = dis_branch;
}
VAR_4->branch_delay_insns = VAR_0->delayed;
for (; *VAR_12; VAR_12++)
{
switch (*VAR_12)
{
case 'T':
VAR_10 = format_sup_reg ((VAR_1 >> 12) & 15, VAR_10, VAR_8);
break;
case 'A':
if (VAR_8)
*VAR_10++ = REGISTER_PREFIX_CHAR;
*VAR_10++ = 'a';
*VAR_10++ = 'c';
*VAR_10++ = 'r';
break;
case '[':
case ']':
case ',':
*VAR_10++ = *VAR_12;
break;
case '!':
break;
case 'd':
break;
case 'B':
VAR_5 = NULL;
break;
case 'D':
case 'r':
VAR_10 = format_reg (VAR_14, VAR_1 & 15, VAR_10, VAR_8);
break;
case 'R':
VAR_10 = format_reg (VAR_14, (VAR_1 >> 12) & 15, VAR_10, VAR_8);
break;
case 'n':
{
unsigned long VAR_24
= (VAR_2[2] + VAR_2[3] * 256 + VAR_2[4] * 65536
+ VAR_2[5] * 0x1000000 + VAR_3);
*VAR_10 = 0;
if (VAR_9[0])
(*VAR_4->fprintf_func) (VAR_4->stream, "%VAR_12", VAR_9);
VAR_10 = VAR_9;
(*VAR_4->print_address_func) ((bfd_vma) VAR_24, VAR_4);
}
break;
case 'u':
{
unsigned long VAR_24 = (VAR_2[0] & 0xf) * 2 + VAR_3;
*VAR_10 = 0;
if (VAR_9[0])
(*VAR_4->fprintf_func) (VAR_4->stream, "%VAR_12", VAR_9);
VAR_10 = VAR_9;
(*VAR_4->print_address_func) ((bfd_vma) VAR_24, VAR_4);
}
break;
case 'N':
case 'y':
case 'Y':
case 'S':
case 'VAR_12':
if ((VAR_1 & 0x400) && (VAR_1 & 15) == 15 && VAR_5 == NULL)
{
long VAR_24;
int VAR_16
= ((*VAR_13 == 'z' && (VAR_1 & 0x20))
|| VAR_0->match == BDAP_QUICK_OPCODE);
int VAR_22;
if (VAR_0->imm_oprnd_size == SIZE_FIX_32)
VAR_22 = 4;
else if (VAR_0->imm_oprnd_size == SIZE_SPEC_REG)
{
const struct cris_spec_reg *VAR_24
= spec_reg_info ((VAR_1 >> 12) & 15, VAR_14->distype);
if (VAR_24 == NULL)
VAR_22 = 42;
else
VAR_22 = VAR_14->distype == cris_dis_v32
? 4 : (VAR_24->reg_size + 1) & ~1;
}
else
{
int VAR_22 = 1 << ((VAR_1 >> 4) & (*VAR_13 == 'z' ? 1 : 3));
if (VAR_22 == 1)
VAR_22 = 2;
else
VAR_22 = VAR_22;
}
switch (VAR_22)
{
case 1:
VAR_24 = VAR_2[2];
if (VAR_16 && VAR_24 > 127)
VAR_24 -= 256;
break;
case 2:
VAR_24 = VAR_2[2] + VAR_2[3] * 256;
if (VAR_16 && VAR_24 > 32767)
VAR_24 -= 65536;
break;
case 4:
VAR_24
= VAR_2[2] + VAR_2[3] * 256 + VAR_2[4] * 65536
+ VAR_2[5] * 0x1000000;
break;
default:
strcpy (VAR_10, "bug");
VAR_10 += 3;
VAR_24 = 42;
}
if ((*VAR_13 == 'z' && (VAR_1 & 0x20))
|| (VAR_0->match == BDAP_QUICK_OPCODE
&& (VAR_22 <= 2 || VAR_2[1 + VAR_22] == 0)))
VAR_10 = format_dec (VAR_24, VAR_10, VAR_16);
else
{
unsigned int VAR_20 = (VAR_24 >> 24) & 0xff;
if (VAR_22 == 4
&& (VAR_20 == ((VAR_3 >> 24) & 0xff)
|| (VAR_20 != 0 && VAR_20 != 0xff)
|| VAR_4->insn_type == dis_branch
|| VAR_4->insn_type == dis_jsr))
{
*VAR_10 = 0;
VAR_10 = VAR_9;
if (VAR_9[0])
(*VAR_4->fprintf_func) (VAR_4->stream, "%VAR_12", VAR_9);
(*VAR_4->print_address_func) ((bfd_vma) VAR_24, VAR_4);
VAR_4->target = VAR_24;
}
else
VAR_10 = format_hex (VAR_24, VAR_10, VAR_14);
}
}
else
{
if (VAR_4->insn_type != dis_nonbranch)
{
int VAR_22
= 1 << ((VAR_1 >> 4)
& (VAR_0->args[0] == 'z' ? 1 : 3));
int VAR_21;
VAR_4->insn_type = dis_dref;
VAR_4->flags |= CRIS_DIS_FLAG_MEMREF;
if (VAR_0->imm_oprnd_size == SIZE_FIX_32)
VAR_21 = 4;
else if (VAR_0->imm_oprnd_size == SIZE_SPEC_REG)
{
const struct cris_spec_reg *VAR_24
= spec_reg_info ((VAR_1 >> 12) & 15, VAR_14->distype);
if (VAR_24 == NULL)
VAR_21 = 4;
else
VAR_21 = VAR_24->reg_size;
}
else
VAR_21 = VAR_22;
VAR_4->data_size = VAR_21;
}
*VAR_10++ = '[';
if (VAR_5
&& ((VAR_1 & 0x400) == 0
|| VAR_5->match != DIP_OPCODE))
{
if (VAR_1 & 0x400)
{
VAR_10 = format_reg (VAR_14, VAR_1 & 15, VAR_10, VAR_8);
*VAR_10++ = '=';
}
switch (VAR_5->match)
{
case DIP_OPCODE:
if ((VAR_6 & 0x400) && (VAR_6 & 15) == 15)
{
unsigned long VAR_24
= VAR_7[2] + VAR_7[3] * 256
+ VAR_7[4] * 65536
+ VAR_7[5] * 0x1000000;
VAR_4->target = (bfd_vma) VAR_24;
*VAR_10 = 0;
VAR_10 = VAR_9;
if (VAR_9[0])
(*VAR_4->fprintf_func) (VAR_4->stream, "%VAR_12", VAR_9);
(*VAR_4->print_address_func) ((bfd_vma) VAR_24, VAR_4);
}
else
{
VAR_4->flags
|= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
| CRIS_DIS_FLAG_MEM_TARGET2_MEM);
VAR_4->target2 = VAR_6 & 15;
*VAR_10++ = '[';
VAR_10 = format_reg (VAR_14, VAR_6 & 15, VAR_10,
VAR_8);
if (VAR_6 & 0x400)
*VAR_10++ = '+';
*VAR_10++ = ']';
}
break;
case BDAP_QUICK_OPCODE:
{
int VAR_24;
VAR_24 = VAR_7[0];
if (VAR_24 > 127)
VAR_24 -= 256;
VAR_10 = format_reg (VAR_14, (VAR_6 >> 12) & 15, VAR_10,
VAR_8);
if (VAR_24 >= 0)
*VAR_10++ = '+';
VAR_10 = format_dec (VAR_24, VAR_10, 1);
VAR_4->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;
VAR_4->target = (VAR_6 >> 12) & 15;
VAR_4->target2 = (bfd_vma) VAR_24;
break;
}
case BIAP_OPCODE:
VAR_10 = format_reg (VAR_14, VAR_6 & 15, VAR_10,
VAR_8);
*VAR_10++ = '+';
VAR_10 = format_reg (VAR_14, (VAR_6 >> 12) & 15, VAR_10,
VAR_8);
*VAR_10++ = '.';
*VAR_10++ = VAR_11[(VAR_6 >> 4) & 3];
VAR_4->flags
|= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
| CRIS_DIS_FLAG_MEM_TARGET_IS_REG
| ((VAR_6 & 0x8000)
? CRIS_DIS_FLAG_MEM_TARGET2_MULT4
: ((VAR_6 & 0x8000)
? CRIS_DIS_FLAG_MEM_TARGET2_MULT2 : 0)));
if (VAR_1 == 0xf83f && (VAR_6 & ~0xf000) == 0x55f)
case_offset_counter = no_of_case_offsets;
break;
case BDAP_INDIR_OPCODE:
VAR_10 = format_reg (VAR_14, (VAR_6 >> 12) & 15, VAR_10,
VAR_8);
if ((VAR_6 & 0x400) && (VAR_6 & 15) == 15)
{
long VAR_24;
unsigned int VAR_22;
int VAR_22 = 1 << ((VAR_6 >> 4) & 3);
if (VAR_22 == 1)
VAR_22 = 2;
else
VAR_22 = VAR_22;
switch (VAR_22)
{
case 1:
VAR_24 = VAR_7[2];
if (VAR_24 > 127)
VAR_24 -= 256;
break;
case 2:
VAR_24 = VAR_7[2] + VAR_7[3] * 256;
if (VAR_24 > 32767)
VAR_24 -= 65536;
break;
case 4:
VAR_24
= VAR_7[2] + VAR_7[3] * 256
+ VAR_7[4] * 65536
+ VAR_7[5] * 0x1000000;
break;
default:
strcpy (VAR_10, "bug");
VAR_10 += 3;
VAR_24 = 42;
}
VAR_4->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;
VAR_4->target2 = (bfd_vma) VAR_24;
if (VAR_22 == 4)
{
*VAR_10++ = '+';
*VAR_10 = 0;
VAR_10 = VAR_9;
(*VAR_4->fprintf_func) (VAR_4->stream, "%VAR_12", VAR_9);
(*VAR_4->print_address_func) ((bfd_vma) VAR_24, VAR_4);
}
else
{
if (VAR_24 >= 0)
*VAR_10++ = '+';
VAR_10 = format_dec (VAR_24, VAR_10, 1);
}
}
else
{
*VAR_10++ = '+';
*VAR_10++ = '[';
VAR_10 = format_reg (VAR_14, VAR_6 & 15, VAR_10,
VAR_8);
if (VAR_6 & 0x400)
*VAR_10++ = '+';
*VAR_10++ = ']';
*VAR_10++ = '.';
*VAR_10++ = VAR_11[(VAR_6 >> 4) & 3];
VAR_4->flags
|= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
| CRIS_DIS_FLAG_MEM_TARGET2_MEM
| CRIS_DIS_FLAG_MEM_TARGET_IS_REG
| (((VAR_6 >> 4) == 2)
? 0
: (((VAR_6 >> 4) & 3) == 1
? CRIS_DIS_FLAG_MEM_TARGET2_MEM_WORD
: CRIS_DIS_FLAG_MEM_TARGET2_MEM_BYTE)));
}
break;
default:
(*VAR_4->fprintf_func) (VAR_4->stream, "?prefix-bug");
}
VAR_5 = NULL;
}
else
{
VAR_10 = format_reg (VAR_14, VAR_1 & 15, VAR_10, VAR_8);
VAR_4->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;
VAR_4->target = VAR_1 & 15;
if (VAR_1 & 0x400)
*VAR_10++ = '+';
}
*VAR_10++ = ']';
}
break;
case 'x':
VAR_10 = format_reg (VAR_14, (VAR_1 >> 12) & 15, VAR_10, VAR_8);
*VAR_10++ = '.';
*VAR_10++ = VAR_11[(VAR_1 >> 4) & 3];
break;
case 'I':
VAR_10 = format_dec (VAR_1 & 63, VAR_10, 0);
break;
case 'b':
{
int VAR_22 = VAR_2[2] + VAR_2[3] * 256;
if (VAR_22 > 32767)
VAR_22 -= 65536;
VAR_22 += VAR_3 + ((VAR_14->distype == cris_dis_v32) ? 0 : 4);
if (VAR_1 == BA_PC_INCR_OPCODE)
VAR_4->insn_type = dis_branch;
else
VAR_4->insn_type = dis_condbranch;
VAR_4->target = (bfd_vma) VAR_22;
*VAR_10 = 0;
VAR_10 = VAR_9;
(*VAR_4->fprintf_func) (VAR_4->stream, "%VAR_12%VAR_12 ",
VAR_9, cris_cc_strings[VAR_1 >> 12]);
(*VAR_4->print_address_func) ((bfd_vma) VAR_22, VAR_4);
}
break;
case 'c':
VAR_10 = format_dec (VAR_1 & 31, VAR_10, 0);
break;
case 'C':
VAR_10 = format_dec (VAR_1 & 15, VAR_10, 0);
break;
case 'o':
{
long VAR_23 = VAR_1 & 0xfe;
bfd_vma target;
if (VAR_1 & 1)
VAR_23 |= ~0xff;
if (VAR_0->match == BA_QUICK_OPCODE)
VAR_4->insn_type = dis_branch;
else
VAR_4->insn_type = dis_condbranch;
target = VAR_3 + ((VAR_14->distype == cris_dis_v32) ? 0 : 2) + VAR_23;
VAR_4->target = target;
*VAR_10 = 0;
VAR_10 = VAR_9;
(*VAR_4->fprintf_func) (VAR_4->stream, "%VAR_12", VAR_9);
(*VAR_4->print_address_func) (target, VAR_4);
}
break;
case 'Q':
case 'O':
{
long VAR_24 = VAR_2[0];
if (VAR_24 > 127)
VAR_24 = VAR_24 - 256;
VAR_10 = format_dec (VAR_24, VAR_10, 1);
*VAR_10++ = ',';
VAR_10 = format_reg (VAR_14, (VAR_1 >> 12) & 15, VAR_10, VAR_8);
}
break;
case 'f':
VAR_10 = print_flags (VAR_14, VAR_1, VAR_10);
break;
case 'i':
VAR_10 = format_dec ((VAR_1 & 32) ? (VAR_1 & 31) | ~31L : VAR_1 & 31, VAR_10, 1);
break;
case 'P':
{
const struct cris_spec_reg *VAR_24
= spec_reg_info ((VAR_1 >> 12) & 15, VAR_14->distype);
if (VAR_24->name == NULL)
*VAR_10++ = '?';
else
{
if (VAR_8)
*VAR_10++ = REGISTER_PREFIX_CHAR;
strcpy (VAR_10, VAR_24->name);
VAR_10 += strlen (VAR_10);
}
}
break;
default:
strcpy (VAR_10, "???");
VAR_10 += 3;
}
}
*VAR_10 = 0;
if (VAR_5)
(*VAR_4->fprintf_func) (VAR_4->stream, " (OOPS unused prefix \"%VAR_12: %VAR_12\")",
VAR_5->name, VAR_5->args);
(*VAR_4->fprintf_func) (VAR_4->stream, "%VAR_12", VAR_9);
if (TRACE_CASE && case_offset_counter == 0)
{
if (CONST_STRNEQ (VAR_0->name, "sub"))
case_offset = last_immediate;
else if (CONST_STRNEQ (VAR_0->name, "add"))
case_offset = -last_immediate;
else if (CONST_STRNEQ (VAR_0->name, "bound"))
no_of_case_offsets = last_immediate + 1;
else if (VAR_4->insn_type == dis_jsr
|| VAR_4->insn_type == dis_branch
|| VAR_4->insn_type == dis_condbranch)
case_offset = 0;
}
}
| [
"FUNC_0 (const struct cris_opcode *VAR_0,\nunsigned int VAR_1,\nunsigned char *VAR_2,\nbfd_vma VAR_3,\ndisassemble_info *VAR_4,\nconst struct cris_opcode *VAR_5,\nunsigned int VAR_6,\nunsigned char *VAR_7,\nbfd_boolean VAR_8)\n{",
"char VAR_9[sizeof (\".d [$r13=$r12-2147483648],$r10\") * 2];",
"char *VAR_10 = VAR_9;",
"static const char VAR_11[] = \"bwd?\";",
"const char *VAR_12;",
"const char *VAR_13;",
"struct cris_disasm_data *VAR_14\n= (struct cris_disasm_data *) VAR_4->private_data;",
"(*VAR_4->fprintf_func) (VAR_4->stream, \"%VAR_12\", VAR_0->name);",
"VAR_13 = VAR_0->args;",
"VAR_12 = VAR_13;",
"if (*VAR_12 == 'p')\nVAR_12++;",
"if (*VAR_12 == 'm' || *VAR_12 == 'M' || *VAR_12 == 'z')\n{",
"*VAR_10++ = '.';",
"*VAR_10++ = *VAR_12 == 'M'\n? (VAR_1 & 0x8000 ? 'd'\n: VAR_1 & 0x4000 ? 'w' : 'b')\n: VAR_11[(VAR_1 >> 4) & (*VAR_12 == 'z' ? 1 : 3)];",
"VAR_12 += 2;",
"}",
"if (VAR_0->match != (BRANCH_PC_LOW + BRANCH_INCR_HIGH * 256))\n*VAR_10++ = ' ';",
"if (VAR_0->name[0] == 'j')\n{",
"if (CONST_STRNEQ (VAR_0->name, \"jsr\"))\nVAR_4->insn_type = dis_jsr;",
"else\nVAR_4->insn_type = dis_branch;",
"}",
"VAR_4->branch_delay_insns = VAR_0->delayed;",
"for (; *VAR_12; VAR_12++)",
"{",
"switch (*VAR_12)\n{",
"case 'T':\nVAR_10 = format_sup_reg ((VAR_1 >> 12) & 15, VAR_10, VAR_8);",
"break;",
"case 'A':\nif (VAR_8)\n*VAR_10++ = REGISTER_PREFIX_CHAR;",
"*VAR_10++ = 'a';",
"*VAR_10++ = 'c';",
"*VAR_10++ = 'r';",
"break;",
"case '[':\ncase ']':\ncase ',':\n*VAR_10++ = *VAR_12;",
"break;",
"case '!':\nbreak;",
"case 'd':\nbreak;",
"case 'B':\nVAR_5 = NULL;",
"break;",
"case 'D':\ncase 'r':\nVAR_10 = format_reg (VAR_14, VAR_1 & 15, VAR_10, VAR_8);",
"break;",
"case 'R':\nVAR_10 = format_reg (VAR_14, (VAR_1 >> 12) & 15, VAR_10, VAR_8);",
"break;",
"case 'n':\n{",
"unsigned long VAR_24\n= (VAR_2[2] + VAR_2[3] * 256 + VAR_2[4] * 65536\n+ VAR_2[5] * 0x1000000 + VAR_3);",
"*VAR_10 = 0;",
"if (VAR_9[0])\n(*VAR_4->fprintf_func) (VAR_4->stream, \"%VAR_12\", VAR_9);",
"VAR_10 = VAR_9;",
"(*VAR_4->print_address_func) ((bfd_vma) VAR_24, VAR_4);",
"}",
"break;",
"case 'u':\n{",
"unsigned long VAR_24 = (VAR_2[0] & 0xf) * 2 + VAR_3;",
"*VAR_10 = 0;",
"if (VAR_9[0])\n(*VAR_4->fprintf_func) (VAR_4->stream, \"%VAR_12\", VAR_9);",
"VAR_10 = VAR_9;",
"(*VAR_4->print_address_func) ((bfd_vma) VAR_24, VAR_4);",
"}",
"break;",
"case 'N':\ncase 'y':\ncase 'Y':\ncase 'S':\ncase 'VAR_12':\nif ((VAR_1 & 0x400) && (VAR_1 & 15) == 15 && VAR_5 == NULL)\n{",
"long VAR_24;",
"int VAR_16\n= ((*VAR_13 == 'z' && (VAR_1 & 0x20))\n|| VAR_0->match == BDAP_QUICK_OPCODE);",
"int VAR_22;",
"if (VAR_0->imm_oprnd_size == SIZE_FIX_32)\nVAR_22 = 4;",
"else if (VAR_0->imm_oprnd_size == SIZE_SPEC_REG)\n{",
"const struct cris_spec_reg *VAR_24\n= spec_reg_info ((VAR_1 >> 12) & 15, VAR_14->distype);",
"if (VAR_24 == NULL)\nVAR_22 = 42;",
"else\nVAR_22 = VAR_14->distype == cris_dis_v32\n? 4 : (VAR_24->reg_size + 1) & ~1;",
"}",
"else\n{",
"int VAR_22 = 1 << ((VAR_1 >> 4) & (*VAR_13 == 'z' ? 1 : 3));",
"if (VAR_22 == 1)\nVAR_22 = 2;",
"else\nVAR_22 = VAR_22;",
"}",
"switch (VAR_22)\n{",
"case 1:\nVAR_24 = VAR_2[2];",
"if (VAR_16 && VAR_24 > 127)\nVAR_24 -= 256;",
"break;",
"case 2:\nVAR_24 = VAR_2[2] + VAR_2[3] * 256;",
"if (VAR_16 && VAR_24 > 32767)\nVAR_24 -= 65536;",
"break;",
"case 4:\nVAR_24\n= VAR_2[2] + VAR_2[3] * 256 + VAR_2[4] * 65536\n+ VAR_2[5] * 0x1000000;",
"break;",
"default:\nstrcpy (VAR_10, \"bug\");",
"VAR_10 += 3;",
"VAR_24 = 42;",
"}",
"if ((*VAR_13 == 'z' && (VAR_1 & 0x20))\n|| (VAR_0->match == BDAP_QUICK_OPCODE\n&& (VAR_22 <= 2 || VAR_2[1 + VAR_22] == 0)))\nVAR_10 = format_dec (VAR_24, VAR_10, VAR_16);",
"else\n{",
"unsigned int VAR_20 = (VAR_24 >> 24) & 0xff;",
"if (VAR_22 == 4\n&& (VAR_20 == ((VAR_3 >> 24) & 0xff)\n|| (VAR_20 != 0 && VAR_20 != 0xff)\n|| VAR_4->insn_type == dis_branch\n|| VAR_4->insn_type == dis_jsr))\n{",
"*VAR_10 = 0;",
"VAR_10 = VAR_9;",
"if (VAR_9[0])\n(*VAR_4->fprintf_func) (VAR_4->stream, \"%VAR_12\", VAR_9);",
"(*VAR_4->print_address_func) ((bfd_vma) VAR_24, VAR_4);",
"VAR_4->target = VAR_24;",
"}",
"else\nVAR_10 = format_hex (VAR_24, VAR_10, VAR_14);",
"}",
"}",
"else\n{",
"if (VAR_4->insn_type != dis_nonbranch)\n{",
"int VAR_22\n= 1 << ((VAR_1 >> 4)\n& (VAR_0->args[0] == 'z' ? 1 : 3));",
"int VAR_21;",
"VAR_4->insn_type = dis_dref;",
"VAR_4->flags |= CRIS_DIS_FLAG_MEMREF;",
"if (VAR_0->imm_oprnd_size == SIZE_FIX_32)\nVAR_21 = 4;",
"else if (VAR_0->imm_oprnd_size == SIZE_SPEC_REG)\n{",
"const struct cris_spec_reg *VAR_24\n= spec_reg_info ((VAR_1 >> 12) & 15, VAR_14->distype);",
"if (VAR_24 == NULL)\nVAR_21 = 4;",
"else\nVAR_21 = VAR_24->reg_size;",
"}",
"else\nVAR_21 = VAR_22;",
"VAR_4->data_size = VAR_21;",
"}",
"*VAR_10++ = '[';",
"if (VAR_5\n&& ((VAR_1 & 0x400) == 0\n|| VAR_5->match != DIP_OPCODE))\n{",
"if (VAR_1 & 0x400)\n{",
"VAR_10 = format_reg (VAR_14, VAR_1 & 15, VAR_10, VAR_8);",
"*VAR_10++ = '=';",
"}",
"switch (VAR_5->match)\n{",
"case DIP_OPCODE:\nif ((VAR_6 & 0x400) && (VAR_6 & 15) == 15)\n{",
"unsigned long VAR_24\n= VAR_7[2] + VAR_7[3] * 256\n+ VAR_7[4] * 65536\n+ VAR_7[5] * 0x1000000;",
"VAR_4->target = (bfd_vma) VAR_24;",
"*VAR_10 = 0;",
"VAR_10 = VAR_9;",
"if (VAR_9[0])\n(*VAR_4->fprintf_func) (VAR_4->stream, \"%VAR_12\", VAR_9);",
"(*VAR_4->print_address_func) ((bfd_vma) VAR_24, VAR_4);",
"}",
"else\n{",
"VAR_4->flags\n|= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG\n| CRIS_DIS_FLAG_MEM_TARGET2_MEM);",
"VAR_4->target2 = VAR_6 & 15;",
"*VAR_10++ = '[';",
"VAR_10 = format_reg (VAR_14, VAR_6 & 15, VAR_10,\nVAR_8);",
"if (VAR_6 & 0x400)\n*VAR_10++ = '+';",
"*VAR_10++ = ']';",
"}",
"break;",
"case BDAP_QUICK_OPCODE:\n{",
"int VAR_24;",
"VAR_24 = VAR_7[0];",
"if (VAR_24 > 127)\nVAR_24 -= 256;",
"VAR_10 = format_reg (VAR_14, (VAR_6 >> 12) & 15, VAR_10,\nVAR_8);",
"if (VAR_24 >= 0)\n*VAR_10++ = '+';",
"VAR_10 = format_dec (VAR_24, VAR_10, 1);",
"VAR_4->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;",
"VAR_4->target = (VAR_6 >> 12) & 15;",
"VAR_4->target2 = (bfd_vma) VAR_24;",
"break;",
"}",
"case BIAP_OPCODE:\nVAR_10 = format_reg (VAR_14, VAR_6 & 15, VAR_10,\nVAR_8);",
"*VAR_10++ = '+';",
"VAR_10 = format_reg (VAR_14, (VAR_6 >> 12) & 15, VAR_10,\nVAR_8);",
"*VAR_10++ = '.';",
"*VAR_10++ = VAR_11[(VAR_6 >> 4) & 3];",
"VAR_4->flags\n|= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG\n| CRIS_DIS_FLAG_MEM_TARGET_IS_REG\n| ((VAR_6 & 0x8000)\n? CRIS_DIS_FLAG_MEM_TARGET2_MULT4\n: ((VAR_6 & 0x8000)\n? CRIS_DIS_FLAG_MEM_TARGET2_MULT2 : 0)));",
"if (VAR_1 == 0xf83f && (VAR_6 & ~0xf000) == 0x55f)\ncase_offset_counter = no_of_case_offsets;",
"break;",
"case BDAP_INDIR_OPCODE:\nVAR_10 = format_reg (VAR_14, (VAR_6 >> 12) & 15, VAR_10,\nVAR_8);",
"if ((VAR_6 & 0x400) && (VAR_6 & 15) == 15)\n{",
"long VAR_24;",
"unsigned int VAR_22;",
"int VAR_22 = 1 << ((VAR_6 >> 4) & 3);",
"if (VAR_22 == 1)\nVAR_22 = 2;",
"else\nVAR_22 = VAR_22;",
"switch (VAR_22)\n{",
"case 1:\nVAR_24 = VAR_7[2];",
"if (VAR_24 > 127)\nVAR_24 -= 256;",
"break;",
"case 2:\nVAR_24 = VAR_7[2] + VAR_7[3] * 256;",
"if (VAR_24 > 32767)\nVAR_24 -= 65536;",
"break;",
"case 4:\nVAR_24\n= VAR_7[2] + VAR_7[3] * 256\n+ VAR_7[4] * 65536\n+ VAR_7[5] * 0x1000000;",
"break;",
"default:\nstrcpy (VAR_10, \"bug\");",
"VAR_10 += 3;",
"VAR_24 = 42;",
"}",
"VAR_4->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;",
"VAR_4->target2 = (bfd_vma) VAR_24;",
"if (VAR_22 == 4)\n{",
"*VAR_10++ = '+';",
"*VAR_10 = 0;",
"VAR_10 = VAR_9;",
"(*VAR_4->fprintf_func) (VAR_4->stream, \"%VAR_12\", VAR_9);",
"(*VAR_4->print_address_func) ((bfd_vma) VAR_24, VAR_4);",
"}",
"else\n{",
"if (VAR_24 >= 0)\n*VAR_10++ = '+';",
"VAR_10 = format_dec (VAR_24, VAR_10, 1);",
"}",
"}",
"else\n{",
"*VAR_10++ = '+';",
"*VAR_10++ = '[';",
"VAR_10 = format_reg (VAR_14, VAR_6 & 15, VAR_10,\nVAR_8);",
"if (VAR_6 & 0x400)\n*VAR_10++ = '+';",
"*VAR_10++ = ']';",
"*VAR_10++ = '.';",
"*VAR_10++ = VAR_11[(VAR_6 >> 4) & 3];",
"VAR_4->flags\n|= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG\n| CRIS_DIS_FLAG_MEM_TARGET2_MEM\n| CRIS_DIS_FLAG_MEM_TARGET_IS_REG\n| (((VAR_6 >> 4) == 2)\n? 0\n: (((VAR_6 >> 4) & 3) == 1\n? CRIS_DIS_FLAG_MEM_TARGET2_MEM_WORD\n: CRIS_DIS_FLAG_MEM_TARGET2_MEM_BYTE)));",
"}",
"break;",
"default:\n(*VAR_4->fprintf_func) (VAR_4->stream, \"?prefix-bug\");",
"}",
"VAR_5 = NULL;",
"}",
"else\n{",
"VAR_10 = format_reg (VAR_14, VAR_1 & 15, VAR_10, VAR_8);",
"VAR_4->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;",
"VAR_4->target = VAR_1 & 15;",
"if (VAR_1 & 0x400)\n*VAR_10++ = '+';",
"}",
"*VAR_10++ = ']';",
"}",
"break;",
"case 'x':\nVAR_10 = format_reg (VAR_14, (VAR_1 >> 12) & 15, VAR_10, VAR_8);",
"*VAR_10++ = '.';",
"*VAR_10++ = VAR_11[(VAR_1 >> 4) & 3];",
"break;",
"case 'I':\nVAR_10 = format_dec (VAR_1 & 63, VAR_10, 0);",
"break;",
"case 'b':\n{",
"int VAR_22 = VAR_2[2] + VAR_2[3] * 256;",
"if (VAR_22 > 32767)\nVAR_22 -= 65536;",
"VAR_22 += VAR_3 + ((VAR_14->distype == cris_dis_v32) ? 0 : 4);",
"if (VAR_1 == BA_PC_INCR_OPCODE)\nVAR_4->insn_type = dis_branch;",
"else\nVAR_4->insn_type = dis_condbranch;",
"VAR_4->target = (bfd_vma) VAR_22;",
"*VAR_10 = 0;",
"VAR_10 = VAR_9;",
"(*VAR_4->fprintf_func) (VAR_4->stream, \"%VAR_12%VAR_12 \",\nVAR_9, cris_cc_strings[VAR_1 >> 12]);",
"(*VAR_4->print_address_func) ((bfd_vma) VAR_22, VAR_4);",
"}",
"break;",
"case 'c':\nVAR_10 = format_dec (VAR_1 & 31, VAR_10, 0);",
"break;",
"case 'C':\nVAR_10 = format_dec (VAR_1 & 15, VAR_10, 0);",
"break;",
"case 'o':\n{",
"long VAR_23 = VAR_1 & 0xfe;",
"bfd_vma target;",
"if (VAR_1 & 1)\nVAR_23 |= ~0xff;",
"if (VAR_0->match == BA_QUICK_OPCODE)\nVAR_4->insn_type = dis_branch;",
"else\nVAR_4->insn_type = dis_condbranch;",
"target = VAR_3 + ((VAR_14->distype == cris_dis_v32) ? 0 : 2) + VAR_23;",
"VAR_4->target = target;",
"*VAR_10 = 0;",
"VAR_10 = VAR_9;",
"(*VAR_4->fprintf_func) (VAR_4->stream, \"%VAR_12\", VAR_9);",
"(*VAR_4->print_address_func) (target, VAR_4);",
"}",
"break;",
"case 'Q':\ncase 'O':\n{",
"long VAR_24 = VAR_2[0];",
"if (VAR_24 > 127)\nVAR_24 = VAR_24 - 256;",
"VAR_10 = format_dec (VAR_24, VAR_10, 1);",
"*VAR_10++ = ',';",
"VAR_10 = format_reg (VAR_14, (VAR_1 >> 12) & 15, VAR_10, VAR_8);",
"}",
"break;",
"case 'f':\nVAR_10 = print_flags (VAR_14, VAR_1, VAR_10);",
"break;",
"case 'i':\nVAR_10 = format_dec ((VAR_1 & 32) ? (VAR_1 & 31) | ~31L : VAR_1 & 31, VAR_10, 1);",
"break;",
"case 'P':\n{",
"const struct cris_spec_reg *VAR_24\n= spec_reg_info ((VAR_1 >> 12) & 15, VAR_14->distype);",
"if (VAR_24->name == NULL)\n*VAR_10++ = '?';",
"else\n{",
"if (VAR_8)\n*VAR_10++ = REGISTER_PREFIX_CHAR;",
"strcpy (VAR_10, VAR_24->name);",
"VAR_10 += strlen (VAR_10);",
"}",
"}",
"break;",
"default:\nstrcpy (VAR_10, \"???\");",
"VAR_10 += 3;",
"}",
"}",
"*VAR_10 = 0;",
"if (VAR_5)\n(*VAR_4->fprintf_func) (VAR_4->stream, \" (OOPS unused prefix \\\"%VAR_12: %VAR_12\\\")\",\nVAR_5->name, VAR_5->args);",
"(*VAR_4->fprintf_func) (VAR_4->stream, \"%VAR_12\", VAR_9);",
"if (TRACE_CASE && case_offset_counter == 0)\n{",
"if (CONST_STRNEQ (VAR_0->name, \"sub\"))\ncase_offset = last_immediate;",
"else if (CONST_STRNEQ (VAR_0->name, \"add\"))\ncase_offset = -last_immediate;",
"else if (CONST_STRNEQ (VAR_0->name, \"bound\"))\nno_of_case_offsets = last_immediate + 1;",
"else if (VAR_4->insn_type == dis_jsr\n|| VAR_4->insn_type == dis_branch\n|| VAR_4->insn_type == dis_condbranch)\ncase_offset = 0;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
17,
19,
21,
23,
25
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
49
],
[
53
],
[
55
],
[
61,
63
],
[
67,
69
],
[
71
],
[
77,
79,
81,
83
],
[
89
],
[
91
],
[
99,
101
],
[
109,
111
],
[
113,
117
],
[
119,
123
],
[
125
],
[
131
],
[
137
],
[
139
],
[
141,
143
],
[
145,
147
],
[
149
],
[
153,
155,
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169,
171,
173,
175
],
[
177
],
[
181,
189
],
[
193,
199
],
[
203,
211
],
[
213
],
[
217,
219,
221
],
[
223
],
[
227,
229
],
[
231
],
[
235,
237
],
[
241,
243,
245
],
[
251
],
[
253,
255
],
[
257
],
[
261
],
[
263
],
[
265
],
[
269,
271
],
[
275
],
[
281
],
[
283,
285
],
[
287
],
[
291
],
[
293
],
[
295
],
[
299,
301,
303,
305,
307,
311,
313
],
[
319
],
[
321,
323,
325
],
[
327
],
[
331,
333
],
[
335,
337
],
[
339,
341
],
[
351,
355
],
[
357,
365,
367
],
[
369
],
[
371,
373
],
[
375
],
[
379,
381
],
[
383,
385
],
[
387
],
[
391,
393
],
[
395,
397
],
[
399,
401
],
[
403
],
[
407,
409
],
[
411,
413
],
[
415
],
[
419,
421,
423,
425
],
[
427
],
[
431,
433
],
[
435
],
[
437
],
[
439
],
[
443,
445,
447,
449
],
[
451,
453
],
[
455
],
[
469,
471,
473,
475,
477,
479
],
[
483
],
[
485
],
[
487,
489
],
[
493
],
[
497
],
[
499
],
[
501,
503
],
[
505
],
[
507
],
[
509,
511
],
[
517,
519
],
[
521,
523,
525
],
[
527
],
[
529
],
[
531
],
[
535,
537
],
[
539,
541
],
[
543,
545
],
[
553,
555
],
[
557,
559
],
[
561
],
[
563,
565
],
[
569
],
[
571
],
[
575
],
[
579,
585,
587,
589
],
[
591,
593
],
[
595
],
[
597
],
[
599
],
[
609,
611
],
[
613,
617,
619
],
[
625,
627,
629,
631
],
[
635
],
[
643
],
[
645
],
[
647,
649
],
[
653
],
[
655
],
[
657,
659
],
[
665,
667,
669
],
[
673
],
[
677
],
[
679,
681
],
[
683,
685
],
[
687
],
[
689
],
[
691
],
[
695,
697
],
[
699
],
[
703
],
[
705,
707
],
[
713,
715
],
[
717,
719
],
[
721
],
[
725
],
[
727
],
[
729
],
[
731
],
[
733
],
[
737,
741,
743
],
[
745
],
[
747,
749
],
[
751
],
[
753
],
[
757,
759,
761,
765,
767,
769,
771
],
[
777,
781
],
[
783
],
[
787,
793,
795
],
[
799,
801
],
[
803
],
[
805
],
[
811
],
[
815,
817
],
[
819,
821
],
[
825,
827
],
[
829,
831
],
[
833,
835
],
[
837
],
[
841,
843
],
[
845,
847
],
[
849
],
[
853,
855,
857,
859,
861
],
[
863
],
[
867,
869
],
[
871
],
[
873
],
[
875
],
[
879
],
[
881
],
[
889,
891
],
[
897
],
[
899
],
[
901
],
[
903
],
[
907
],
[
909
],
[
911,
913
],
[
915,
917
],
[
919
],
[
921
],
[
923
],
[
925,
927
],
[
931
],
[
933
],
[
935,
937
],
[
939,
941
],
[
943
],
[
945
],
[
947
],
[
951,
953,
955,
957,
961,
963,
965,
967,
969
],
[
971
],
[
973
],
[
977,
979
],
[
981
],
[
987
],
[
989
],
[
991,
993
],
[
995
],
[
999
],
[
1001
],
[
1005,
1007
],
[
1009
],
[
1011
],
[
1013
],
[
1015
],
[
1019,
1021
],
[
1023
],
[
1025
],
[
1027
],
[
1031,
1033
],
[
1035
],
[
1039,
1041
],
[
1043
],
[
1047,
1049
],
[
1053
],
[
1057,
1059
],
[
1061,
1063
],
[
1067
],
[
1071
],
[
1073
],
[
1075,
1077
],
[
1081
],
[
1083
],
[
1085
],
[
1089,
1091
],
[
1093
],
[
1097,
1099
],
[
1101
],
[
1105,
1107
],
[
1109
],
[
1111
],
[
1115,
1117
],
[
1121,
1123
],
[
1125,
1127
],
[
1131
],
[
1133
],
[
1135
],
[
1137
],
[
1139
],
[
1141
],
[
1143
],
[
1145
],
[
1149,
1151,
1153
],
[
1155
],
[
1159,
1161
],
[
1165
],
[
1167
],
[
1169
],
[
1171
],
[
1173
],
[
1177,
1179
],
[
1181
],
[
1185,
1187
],
[
1189
],
[
1193,
1195
],
[
1197,
1199
],
[
1203,
1207
],
[
1209,
1211
],
[
1213,
1215
],
[
1217
],
[
1219
],
[
1221
],
[
1223
],
[
1225
],
[
1229,
1231
],
[
1233
],
[
1235
],
[
1237
],
[
1241
],
[
1245,
1247,
1249
],
[
1253
],
[
1263,
1265
],
[
1267,
1269
],
[
1275,
1279
],
[
1285,
1287
],
[
1295,
1297,
1299,
1301
],
[
1303
],
[
1305
]
] |
20,794 | static void socket_start_outgoing_migration(MigrationState *s,
SocketAddressLegacy *saddr,
Error **errp)
{
QIOChannelSocket *sioc = qio_channel_socket_new();
struct SocketConnectData *data = g_new0(struct SocketConnectData, 1);
data->s = s;
if (saddr->type == SOCKET_ADDRESS_LEGACY_KIND_INET) {
data->hostname = g_strdup(saddr->u.inet.data->host);
}
qio_channel_set_name(QIO_CHANNEL(sioc), "migration-socket-outgoing");
qio_channel_socket_connect_async(sioc,
saddr,
socket_outgoing_migration,
data,
socket_connect_data_free);
qapi_free_SocketAddressLegacy(saddr);
}
| false | qemu | bd269ebc82fbaa5fe7ce5bc7c1770ac8acecd884 | static void socket_start_outgoing_migration(MigrationState *s,
SocketAddressLegacy *saddr,
Error **errp)
{
QIOChannelSocket *sioc = qio_channel_socket_new();
struct SocketConnectData *data = g_new0(struct SocketConnectData, 1);
data->s = s;
if (saddr->type == SOCKET_ADDRESS_LEGACY_KIND_INET) {
data->hostname = g_strdup(saddr->u.inet.data->host);
}
qio_channel_set_name(QIO_CHANNEL(sioc), "migration-socket-outgoing");
qio_channel_socket_connect_async(sioc,
saddr,
socket_outgoing_migration,
data,
socket_connect_data_free);
qapi_free_SocketAddressLegacy(saddr);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(MigrationState *VAR_0,
SocketAddressLegacy *VAR_1,
Error **VAR_2)
{
QIOChannelSocket *sioc = qio_channel_socket_new();
struct SocketConnectData *VAR_3 = g_new0(struct SocketConnectData, 1);
VAR_3->VAR_0 = VAR_0;
if (VAR_1->type == SOCKET_ADDRESS_LEGACY_KIND_INET) {
VAR_3->hostname = g_strdup(VAR_1->u.inet.VAR_3->host);
}
qio_channel_set_name(QIO_CHANNEL(sioc), "migration-socket-outgoing");
qio_channel_socket_connect_async(sioc,
VAR_1,
socket_outgoing_migration,
VAR_3,
socket_connect_data_free);
qapi_free_SocketAddressLegacy(VAR_1);
}
| [
"static void FUNC_0(MigrationState *VAR_0,\nSocketAddressLegacy *VAR_1,\nError **VAR_2)\n{",
"QIOChannelSocket *sioc = qio_channel_socket_new();",
"struct SocketConnectData *VAR_3 = g_new0(struct SocketConnectData, 1);",
"VAR_3->VAR_0 = VAR_0;",
"if (VAR_1->type == SOCKET_ADDRESS_LEGACY_KIND_INET) {",
"VAR_3->hostname = g_strdup(VAR_1->u.inet.VAR_3->host);",
"}",
"qio_channel_set_name(QIO_CHANNEL(sioc), \"migration-socket-outgoing\");",
"qio_channel_socket_connect_async(sioc,\nVAR_1,\nsocket_outgoing_migration,\nVAR_3,\nsocket_connect_data_free);",
"qapi_free_SocketAddressLegacy(VAR_1);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27,
29,
31,
33,
35
],
[
37
],
[
39
]
] |
20,795 | static void define_aarch64_debug_regs(ARMCPU *cpu)
{
/* Define breakpoint and watchpoint registers. These do nothing
* but read as written, for now.
*/
int i;
for (i = 0; i < 16; i++) {
ARMCPRegInfo dbgregs[] = {
{ .name = "DBGBVR", .state = ARM_CP_STATE_AA64,
.opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 4,
.access = PL1_RW,
.fieldoffset = offsetof(CPUARMState, cp15.dbgbvr[i]) },
{ .name = "DBGBCR", .state = ARM_CP_STATE_AA64,
.opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 5,
.access = PL1_RW,
.fieldoffset = offsetof(CPUARMState, cp15.dbgbcr[i]) },
{ .name = "DBGWVR", .state = ARM_CP_STATE_AA64,
.opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 6,
.access = PL1_RW,
.fieldoffset = offsetof(CPUARMState, cp15.dbgwvr[i]) },
{ .name = "DBGWCR", .state = ARM_CP_STATE_AA64,
.opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 7,
.access = PL1_RW,
.fieldoffset = offsetof(CPUARMState, cp15.dbgwcr[i]) },
REGINFO_SENTINEL
};
define_arm_cp_regs(cpu, dbgregs);
}
}
| false | qemu | 503006983a19be0b481946afac2cab0bdd21f124 | static void define_aarch64_debug_regs(ARMCPU *cpu)
{
int i;
for (i = 0; i < 16; i++) {
ARMCPRegInfo dbgregs[] = {
{ .name = "DBGBVR", .state = ARM_CP_STATE_AA64,
.opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 4,
.access = PL1_RW,
.fieldoffset = offsetof(CPUARMState, cp15.dbgbvr[i]) },
{ .name = "DBGBCR", .state = ARM_CP_STATE_AA64,
.opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 5,
.access = PL1_RW,
.fieldoffset = offsetof(CPUARMState, cp15.dbgbcr[i]) },
{ .name = "DBGWVR", .state = ARM_CP_STATE_AA64,
.opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 6,
.access = PL1_RW,
.fieldoffset = offsetof(CPUARMState, cp15.dbgwvr[i]) },
{ .name = "DBGWCR", .state = ARM_CP_STATE_AA64,
.opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 7,
.access = PL1_RW,
.fieldoffset = offsetof(CPUARMState, cp15.dbgwcr[i]) },
REGINFO_SENTINEL
};
define_arm_cp_regs(cpu, dbgregs);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(ARMCPU *VAR_0)
{
int VAR_1;
for (VAR_1 = 0; VAR_1 < 16; VAR_1++) {
ARMCPRegInfo dbgregs[] = {
{ .name = "DBGBVR", .state = ARM_CP_STATE_AA64,
.opc0 = 2, .opc1 = 0, .crn = 0, .crm = VAR_1, .opc2 = 4,
.access = PL1_RW,
.fieldoffset = offsetof(CPUARMState, cp15.dbgbvr[VAR_1]) },
{ .name = "DBGBCR", .state = ARM_CP_STATE_AA64,
.opc0 = 2, .opc1 = 0, .crn = 0, .crm = VAR_1, .opc2 = 5,
.access = PL1_RW,
.fieldoffset = offsetof(CPUARMState, cp15.dbgbcr[VAR_1]) },
{ .name = "DBGWVR", .state = ARM_CP_STATE_AA64,
.opc0 = 2, .opc1 = 0, .crn = 0, .crm = VAR_1, .opc2 = 6,
.access = PL1_RW,
.fieldoffset = offsetof(CPUARMState, cp15.dbgwvr[VAR_1]) },
{ .name = "DBGWCR", .state = ARM_CP_STATE_AA64,
.opc0 = 2, .opc1 = 0, .crn = 0, .crm = VAR_1, .opc2 = 7,
.access = PL1_RW,
.fieldoffset = offsetof(CPUARMState, cp15.dbgwcr[VAR_1]) },
REGINFO_SENTINEL
};
define_arm_cp_regs(VAR_0, dbgregs);
}
}
| [
"static void FUNC_0(ARMCPU *VAR_0)\n{",
"int VAR_1;",
"for (VAR_1 = 0; VAR_1 < 16; VAR_1++) {",
"ARMCPRegInfo dbgregs[] = {",
"{ .name = \"DBGBVR\", .state = ARM_CP_STATE_AA64,",
".opc0 = 2, .opc1 = 0, .crn = 0, .crm = VAR_1, .opc2 = 4,\n.access = PL1_RW,\n.fieldoffset = offsetof(CPUARMState, cp15.dbgbvr[VAR_1]) },",
"{ .name = \"DBGBCR\", .state = ARM_CP_STATE_AA64,",
".opc0 = 2, .opc1 = 0, .crn = 0, .crm = VAR_1, .opc2 = 5,\n.access = PL1_RW,\n.fieldoffset = offsetof(CPUARMState, cp15.dbgbcr[VAR_1]) },",
"{ .name = \"DBGWVR\", .state = ARM_CP_STATE_AA64,",
".opc0 = 2, .opc1 = 0, .crn = 0, .crm = VAR_1, .opc2 = 6,\n.access = PL1_RW,\n.fieldoffset = offsetof(CPUARMState, cp15.dbgwvr[VAR_1]) },",
"{ .name = \"DBGWCR\", .state = ARM_CP_STATE_AA64,",
".opc0 = 2, .opc1 = 0, .crn = 0, .crm = VAR_1, .opc2 = 7,\n.access = PL1_RW,\n.fieldoffset = offsetof(CPUARMState, cp15.dbgwcr[VAR_1]) },",
"REGINFO_SENTINEL\n};",
"define_arm_cp_regs(VAR_0, dbgregs);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21,
23,
25
],
[
27
],
[
29,
31,
33
],
[
35
],
[
37,
39,
41
],
[
43
],
[
45,
47,
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
]
] |
20,796 | static void add_pc_test_case(const char *mname)
{
char *path;
PlugTestData *data;
if (!g_str_has_prefix(mname, "pc-")) {
return;
}
data = g_new(PlugTestData, 1);
data->machine = g_strdup(mname);
data->cpu_model = "Haswell"; /* 1.3+ theoretically */
data->sockets = 1;
data->cores = 3;
data->threads = 2;
data->maxcpus = data->sockets * data->cores * data->threads * 2;
if (g_str_has_suffix(mname, "-1.4") ||
(strcmp(mname, "pc-1.3") == 0) ||
(strcmp(mname, "pc-1.2") == 0) ||
(strcmp(mname, "pc-1.1") == 0) ||
(strcmp(mname, "pc-1.0") == 0) ||
(strcmp(mname, "pc-0.15") == 0) ||
(strcmp(mname, "pc-0.14") == 0) ||
(strcmp(mname, "pc-0.13") == 0) ||
(strcmp(mname, "pc-0.12") == 0) ||
(strcmp(mname, "pc-0.11") == 0) ||
(strcmp(mname, "pc-0.10") == 0)) {
path = g_strdup_printf("cpu/%s/init/%ux%ux%u&maxcpus=%u",
mname, data->sockets, data->cores,
data->threads, data->maxcpus);
qtest_add_data_func_full(path, data, test_plug_without_cpu_add,
test_data_free);
g_free(path);
} else {
path = g_strdup_printf("cpu/%s/add/%ux%ux%u&maxcpus=%u",
mname, data->sockets, data->cores,
data->threads, data->maxcpus);
qtest_add_data_func_full(path, data, test_plug_with_cpu_add,
test_data_free);
g_free(path);
}
}
| false | qemu | 80b8c0be748d2cf8a90955e409956cee1c932a38 | static void add_pc_test_case(const char *mname)
{
char *path;
PlugTestData *data;
if (!g_str_has_prefix(mname, "pc-")) {
return;
}
data = g_new(PlugTestData, 1);
data->machine = g_strdup(mname);
data->cpu_model = "Haswell";
data->sockets = 1;
data->cores = 3;
data->threads = 2;
data->maxcpus = data->sockets * data->cores * data->threads * 2;
if (g_str_has_suffix(mname, "-1.4") ||
(strcmp(mname, "pc-1.3") == 0) ||
(strcmp(mname, "pc-1.2") == 0) ||
(strcmp(mname, "pc-1.1") == 0) ||
(strcmp(mname, "pc-1.0") == 0) ||
(strcmp(mname, "pc-0.15") == 0) ||
(strcmp(mname, "pc-0.14") == 0) ||
(strcmp(mname, "pc-0.13") == 0) ||
(strcmp(mname, "pc-0.12") == 0) ||
(strcmp(mname, "pc-0.11") == 0) ||
(strcmp(mname, "pc-0.10") == 0)) {
path = g_strdup_printf("cpu/%s/init/%ux%ux%u&maxcpus=%u",
mname, data->sockets, data->cores,
data->threads, data->maxcpus);
qtest_add_data_func_full(path, data, test_plug_without_cpu_add,
test_data_free);
g_free(path);
} else {
path = g_strdup_printf("cpu/%s/add/%ux%ux%u&maxcpus=%u",
mname, data->sockets, data->cores,
data->threads, data->maxcpus);
qtest_add_data_func_full(path, data, test_plug_with_cpu_add,
test_data_free);
g_free(path);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const char *VAR_0)
{
char *VAR_1;
PlugTestData *data;
if (!g_str_has_prefix(VAR_0, "pc-")) {
return;
}
data = g_new(PlugTestData, 1);
data->machine = g_strdup(VAR_0);
data->cpu_model = "Haswell";
data->sockets = 1;
data->cores = 3;
data->threads = 2;
data->maxcpus = data->sockets * data->cores * data->threads * 2;
if (g_str_has_suffix(VAR_0, "-1.4") ||
(strcmp(VAR_0, "pc-1.3") == 0) ||
(strcmp(VAR_0, "pc-1.2") == 0) ||
(strcmp(VAR_0, "pc-1.1") == 0) ||
(strcmp(VAR_0, "pc-1.0") == 0) ||
(strcmp(VAR_0, "pc-0.15") == 0) ||
(strcmp(VAR_0, "pc-0.14") == 0) ||
(strcmp(VAR_0, "pc-0.13") == 0) ||
(strcmp(VAR_0, "pc-0.12") == 0) ||
(strcmp(VAR_0, "pc-0.11") == 0) ||
(strcmp(VAR_0, "pc-0.10") == 0)) {
VAR_1 = g_strdup_printf("cpu/%s/init/%ux%ux%u&maxcpus=%u",
VAR_0, data->sockets, data->cores,
data->threads, data->maxcpus);
qtest_add_data_func_full(VAR_1, data, test_plug_without_cpu_add,
test_data_free);
g_free(VAR_1);
} else {
VAR_1 = g_strdup_printf("cpu/%s/add/%ux%ux%u&maxcpus=%u",
VAR_0, data->sockets, data->cores,
data->threads, data->maxcpus);
qtest_add_data_func_full(VAR_1, data, test_plug_with_cpu_add,
test_data_free);
g_free(VAR_1);
}
}
| [
"static void FUNC_0(const char *VAR_0)\n{",
"char *VAR_1;",
"PlugTestData *data;",
"if (!g_str_has_prefix(VAR_0, \"pc-\")) {",
"return;",
"}",
"data = g_new(PlugTestData, 1);",
"data->machine = g_strdup(VAR_0);",
"data->cpu_model = \"Haswell\";",
"data->sockets = 1;",
"data->cores = 3;",
"data->threads = 2;",
"data->maxcpus = data->sockets * data->cores * data->threads * 2;",
"if (g_str_has_suffix(VAR_0, \"-1.4\") ||\n(strcmp(VAR_0, \"pc-1.3\") == 0) ||\n(strcmp(VAR_0, \"pc-1.2\") == 0) ||\n(strcmp(VAR_0, \"pc-1.1\") == 0) ||\n(strcmp(VAR_0, \"pc-1.0\") == 0) ||\n(strcmp(VAR_0, \"pc-0.15\") == 0) ||\n(strcmp(VAR_0, \"pc-0.14\") == 0) ||\n(strcmp(VAR_0, \"pc-0.13\") == 0) ||\n(strcmp(VAR_0, \"pc-0.12\") == 0) ||\n(strcmp(VAR_0, \"pc-0.11\") == 0) ||\n(strcmp(VAR_0, \"pc-0.10\") == 0)) {",
"VAR_1 = g_strdup_printf(\"cpu/%s/init/%ux%ux%u&maxcpus=%u\",\nVAR_0, data->sockets, data->cores,\ndata->threads, data->maxcpus);",
"qtest_add_data_func_full(VAR_1, data, test_plug_without_cpu_add,\ntest_data_free);",
"g_free(VAR_1);",
"} else {",
"VAR_1 = g_strdup_printf(\"cpu/%s/add/%ux%ux%u&maxcpus=%u\",\nVAR_0, data->sockets, data->cores,\ndata->threads, data->maxcpus);",
"qtest_add_data_func_full(VAR_1, data, test_plug_with_cpu_add,\ntest_data_free);",
"g_free(VAR_1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51
],
[
53,
55,
57
],
[
59,
61
],
[
63
],
[
65
],
[
67,
69,
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
]
] |
20,798 | void event_notifier_cleanup(EventNotifier *e)
{
close(e->fd);
}
| false | qemu | d0cc2fbfa607678866475383c508be84818ceb64 | void event_notifier_cleanup(EventNotifier *e)
{
close(e->fd);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(EventNotifier *VAR_0)
{
close(VAR_0->fd);
}
| [
"void FUNC_0(EventNotifier *VAR_0)\n{",
"close(VAR_0->fd);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
20,799 | static void alpha_translate_init(void)
{
int i;
char *p;
static int done_init = 0;
if (done_init)
return;
cpu_env = tcg_global_reg_new(TCG_TYPE_PTR, TCG_AREG0, "env");
p = cpu_reg_names;
for (i = 0; i < 31; i++) {
sprintf(p, "ir%d", i);
cpu_ir[i] = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,
offsetof(CPUState, ir[i]), p);
p += (i < 10) ? 4 : 5;
sprintf(p, "fir%d", i);
cpu_fir[i] = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,
offsetof(CPUState, fir[i]), p);
p += (i < 10) ? 5 : 6;
}
cpu_pc = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,
offsetof(CPUState, pc), "pc");
cpu_lock = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,
offsetof(CPUState, lock), "lock");
/* register helpers */
#undef DEF_HELPER
#define DEF_HELPER(ret, name, params) tcg_register_helper(name, #name);
#include "helper.h"
done_init = 1;
}
| false | qemu | a7812ae412311d7d47f8aa85656faadac9d64b56 | static void alpha_translate_init(void)
{
int i;
char *p;
static int done_init = 0;
if (done_init)
return;
cpu_env = tcg_global_reg_new(TCG_TYPE_PTR, TCG_AREG0, "env");
p = cpu_reg_names;
for (i = 0; i < 31; i++) {
sprintf(p, "ir%d", i);
cpu_ir[i] = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,
offsetof(CPUState, ir[i]), p);
p += (i < 10) ? 4 : 5;
sprintf(p, "fir%d", i);
cpu_fir[i] = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,
offsetof(CPUState, fir[i]), p);
p += (i < 10) ? 5 : 6;
}
cpu_pc = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,
offsetof(CPUState, pc), "pc");
cpu_lock = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,
offsetof(CPUState, lock), "lock");
#undef DEF_HELPER
#define DEF_HELPER(ret, name, params) tcg_register_helper(name, #name);
#include "helper.h"
done_init = 1;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
int VAR_0;
char *VAR_1;
static int VAR_2 = 0;
if (VAR_2)
return;
cpu_env = tcg_global_reg_new(TCG_TYPE_PTR, TCG_AREG0, "env");
VAR_1 = cpu_reg_names;
for (VAR_0 = 0; VAR_0 < 31; VAR_0++) {
sprintf(VAR_1, "ir%d", VAR_0);
cpu_ir[VAR_0] = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,
offsetof(CPUState, ir[VAR_0]), VAR_1);
VAR_1 += (VAR_0 < 10) ? 4 : 5;
sprintf(VAR_1, "fir%d", VAR_0);
cpu_fir[VAR_0] = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,
offsetof(CPUState, fir[VAR_0]), VAR_1);
VAR_1 += (VAR_0 < 10) ? 5 : 6;
}
cpu_pc = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,
offsetof(CPUState, pc), "pc");
cpu_lock = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,
offsetof(CPUState, lock), "lock");
#undef DEF_HELPER
#define DEF_HELPER(ret, name, params) tcg_register_helper(name, #name);
#include "helper.h"
VAR_2 = 1;
}
| [
"static void FUNC_0(void)\n{",
"int VAR_0;",
"char *VAR_1;",
"static int VAR_2 = 0;",
"if (VAR_2)\nreturn;",
"cpu_env = tcg_global_reg_new(TCG_TYPE_PTR, TCG_AREG0, \"env\");",
"VAR_1 = cpu_reg_names;",
"for (VAR_0 = 0; VAR_0 < 31; VAR_0++) {",
"sprintf(VAR_1, \"ir%d\", VAR_0);",
"cpu_ir[VAR_0] = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,\noffsetof(CPUState, ir[VAR_0]), VAR_1);",
"VAR_1 += (VAR_0 < 10) ? 4 : 5;",
"sprintf(VAR_1, \"fir%d\", VAR_0);",
"cpu_fir[VAR_0] = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,\noffsetof(CPUState, fir[VAR_0]), VAR_1);",
"VAR_1 += (VAR_0 < 10) ? 5 : 6;",
"}",
"cpu_pc = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,\noffsetof(CPUState, pc), \"pc\");",
"cpu_lock = tcg_global_mem_new(TCG_TYPE_I64, TCG_AREG0,\noffsetof(CPUState, lock), \"lock\");",
"#undef DEF_HELPER\n#define DEF_HELPER(ret, name, params) tcg_register_helper(name, #name);",
"#include \"helper.h\"\nVAR_2 = 1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
49,
51
],
[
55,
57
],
[
63,
65
],
[
67,
71
],
[
73
]
] |
20,800 | static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
RawVideoContext *context = avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int need_copy = !avpkt->buf || context->is_2_4_bpp || context->is_yuv2;
int res;
AVFrame *frame = data;
AVPicture *picture = data;
frame->pict_type = AV_PICTURE_TYPE_I;
frame->key_frame = 1;
frame->reordered_opaque = avctx->reordered_opaque;
frame->pkt_pts = avctx->internal->pkt->pts;
if (buf_size < context->frame_size - (avctx->pix_fmt == AV_PIX_FMT_PAL8 ?
AVPALETTE_SIZE : 0))
return -1;
if (need_copy)
frame->buf[0] = av_buffer_alloc(context->frame_size);
else
frame->buf[0] = av_buffer_ref(avpkt->buf);
if (!frame->buf[0])
return AVERROR(ENOMEM);
//2bpp and 4bpp raw in avi and mov (yes this is ugly ...)
if (context->is_2_4_bpp) {
int i;
uint8_t *dst = frame->buf[0]->data;
buf_size = context->frame_size - AVPALETTE_SIZE;
if (avctx->bits_per_coded_sample == 4) {
for (i = 0; 2 * i + 1 < buf_size; i++) {
dst[2 * i + 0] = buf[i] >> 4;
dst[2 * i + 1] = buf[i] & 15;
}
} else {
for (i = 0; 4 * i + 3 < buf_size; i++) {
dst[4 * i + 0] = buf[i] >> 6;
dst[4 * i + 1] = buf[i] >> 4 & 3;
dst[4 * i + 2] = buf[i] >> 2 & 3;
dst[4 * i + 3] = buf[i] & 3;
}
}
buf = dst;
} else if (need_copy) {
memcpy(frame->buf[0]->data, buf, FFMIN(buf_size, context->frame_size));
buf = frame->buf[0]->data;
}
if (avctx->codec_tag == MKTAG('A', 'V', '1', 'x') ||
avctx->codec_tag == MKTAG('A', 'V', 'u', 'p'))
buf += buf_size - context->frame_size;
if ((res = avpicture_fill(picture, buf, avctx->pix_fmt,
avctx->width, avctx->height)) < 0)
return res;
if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE,
NULL);
if (pal) {
av_buffer_unref(&context->palette);
context->palette = av_buffer_alloc(AVPALETTE_SIZE);
if (!context->palette)
return AVERROR(ENOMEM);
memcpy(context->palette->data, pal, AVPALETTE_SIZE);
frame->palette_has_changed = 1;
}
}
if ((avctx->pix_fmt == AV_PIX_FMT_PAL8 && buf_size < context->frame_size) ||
(desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)) {
frame->buf[1] = av_buffer_ref(context->palette);
if (!frame->buf[1])
return AVERROR(ENOMEM);
frame->data[1] = frame->buf[1]->data;
}
if (avctx->pix_fmt == AV_PIX_FMT_BGR24 &&
((frame->linesize[0] + 3) & ~3) * avctx->height <= buf_size)
frame->linesize[0] = (frame->linesize[0] + 3) & ~3;
if (context->flip)
flip(avctx, picture);
if (avctx->codec_tag == MKTAG('Y', 'V', '1', '2') ||
avctx->codec_tag == MKTAG('Y', 'V', '1', '6') ||
avctx->codec_tag == MKTAG('Y', 'V', '2', '4') ||
avctx->codec_tag == MKTAG('Y', 'V', 'U', '9'))
FFSWAP(uint8_t *, picture->data[1], picture->data[2]);
if (avctx->codec_tag == AV_RL32("yuv2") &&
avctx->pix_fmt == AV_PIX_FMT_YUYV422) {
int x, y;
uint8_t *line = picture->data[0];
for (y = 0; y < avctx->height; y++) {
for (x = 0; x < avctx->width; x++)
line[2 * x + 1] ^= 0x80;
line += picture->linesize[0];
}
}
*got_frame = 1;
return buf_size;
}
| false | FFmpeg | 4a0f6651434c6f213d830140f575b4ec7858519f | static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
RawVideoContext *context = avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int need_copy = !avpkt->buf || context->is_2_4_bpp || context->is_yuv2;
int res;
AVFrame *frame = data;
AVPicture *picture = data;
frame->pict_type = AV_PICTURE_TYPE_I;
frame->key_frame = 1;
frame->reordered_opaque = avctx->reordered_opaque;
frame->pkt_pts = avctx->internal->pkt->pts;
if (buf_size < context->frame_size - (avctx->pix_fmt == AV_PIX_FMT_PAL8 ?
AVPALETTE_SIZE : 0))
return -1;
if (need_copy)
frame->buf[0] = av_buffer_alloc(context->frame_size);
else
frame->buf[0] = av_buffer_ref(avpkt->buf);
if (!frame->buf[0])
return AVERROR(ENOMEM);
if (context->is_2_4_bpp) {
int i;
uint8_t *dst = frame->buf[0]->data;
buf_size = context->frame_size - AVPALETTE_SIZE;
if (avctx->bits_per_coded_sample == 4) {
for (i = 0; 2 * i + 1 < buf_size; i++) {
dst[2 * i + 0] = buf[i] >> 4;
dst[2 * i + 1] = buf[i] & 15;
}
} else {
for (i = 0; 4 * i + 3 < buf_size; i++) {
dst[4 * i + 0] = buf[i] >> 6;
dst[4 * i + 1] = buf[i] >> 4 & 3;
dst[4 * i + 2] = buf[i] >> 2 & 3;
dst[4 * i + 3] = buf[i] & 3;
}
}
buf = dst;
} else if (need_copy) {
memcpy(frame->buf[0]->data, buf, FFMIN(buf_size, context->frame_size));
buf = frame->buf[0]->data;
}
if (avctx->codec_tag == MKTAG('A', 'V', '1', 'x') ||
avctx->codec_tag == MKTAG('A', 'V', 'u', 'p'))
buf += buf_size - context->frame_size;
if ((res = avpicture_fill(picture, buf, avctx->pix_fmt,
avctx->width, avctx->height)) < 0)
return res;
if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE,
NULL);
if (pal) {
av_buffer_unref(&context->palette);
context->palette = av_buffer_alloc(AVPALETTE_SIZE);
if (!context->palette)
return AVERROR(ENOMEM);
memcpy(context->palette->data, pal, AVPALETTE_SIZE);
frame->palette_has_changed = 1;
}
}
if ((avctx->pix_fmt == AV_PIX_FMT_PAL8 && buf_size < context->frame_size) ||
(desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)) {
frame->buf[1] = av_buffer_ref(context->palette);
if (!frame->buf[1])
return AVERROR(ENOMEM);
frame->data[1] = frame->buf[1]->data;
}
if (avctx->pix_fmt == AV_PIX_FMT_BGR24 &&
((frame->linesize[0] + 3) & ~3) * avctx->height <= buf_size)
frame->linesize[0] = (frame->linesize[0] + 3) & ~3;
if (context->flip)
flip(avctx, picture);
if (avctx->codec_tag == MKTAG('Y', 'V', '1', '2') ||
avctx->codec_tag == MKTAG('Y', 'V', '1', '6') ||
avctx->codec_tag == MKTAG('Y', 'V', '2', '4') ||
avctx->codec_tag == MKTAG('Y', 'V', 'U', '9'))
FFSWAP(uint8_t *, picture->data[1], picture->data[2]);
if (avctx->codec_tag == AV_RL32("yuv2") &&
avctx->pix_fmt == AV_PIX_FMT_YUYV422) {
int x, y;
uint8_t *line = picture->data[0];
for (y = 0; y < avctx->height; y++) {
for (x = 0; x < avctx->width; x++)
line[2 * x + 1] ^= 0x80;
line += picture->linesize[0];
}
}
*got_frame = 1;
return buf_size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
const AVPixFmtDescriptor *VAR_4 = av_pix_fmt_desc_get(VAR_0->pix_fmt);
RawVideoContext *context = VAR_0->priv_data;
const uint8_t *VAR_5 = VAR_3->VAR_1;
int VAR_6 = VAR_3->size;
int VAR_7 = !VAR_3->VAR_5 || context->is_2_4_bpp || context->is_yuv2;
int VAR_8;
AVFrame *frame = VAR_1;
AVPicture *picture = VAR_1;
frame->pict_type = AV_PICTURE_TYPE_I;
frame->key_frame = 1;
frame->reordered_opaque = VAR_0->reordered_opaque;
frame->pkt_pts = VAR_0->internal->pkt->pts;
if (VAR_6 < context->frame_size - (VAR_0->pix_fmt == AV_PIX_FMT_PAL8 ?
AVPALETTE_SIZE : 0))
return -1;
if (VAR_7)
frame->VAR_5[0] = av_buffer_alloc(context->frame_size);
else
frame->VAR_5[0] = av_buffer_ref(VAR_3->VAR_5);
if (!frame->VAR_5[0])
return AVERROR(ENOMEM);
if (context->is_2_4_bpp) {
int VAR_9;
uint8_t *dst = frame->VAR_5[0]->VAR_1;
VAR_6 = context->frame_size - AVPALETTE_SIZE;
if (VAR_0->bits_per_coded_sample == 4) {
for (VAR_9 = 0; 2 * VAR_9 + 1 < VAR_6; VAR_9++) {
dst[2 * VAR_9 + 0] = VAR_5[VAR_9] >> 4;
dst[2 * VAR_9 + 1] = VAR_5[VAR_9] & 15;
}
} else {
for (VAR_9 = 0; 4 * VAR_9 + 3 < VAR_6; VAR_9++) {
dst[4 * VAR_9 + 0] = VAR_5[VAR_9] >> 6;
dst[4 * VAR_9 + 1] = VAR_5[VAR_9] >> 4 & 3;
dst[4 * VAR_9 + 2] = VAR_5[VAR_9] >> 2 & 3;
dst[4 * VAR_9 + 3] = VAR_5[VAR_9] & 3;
}
}
VAR_5 = dst;
} else if (VAR_7) {
memcpy(frame->VAR_5[0]->VAR_1, VAR_5, FFMIN(VAR_6, context->frame_size));
VAR_5 = frame->VAR_5[0]->VAR_1;
}
if (VAR_0->codec_tag == MKTAG('A', 'V', '1', 'VAR_11') ||
VAR_0->codec_tag == MKTAG('A', 'V', 'u', 'p'))
VAR_5 += VAR_6 - context->frame_size;
if ((VAR_8 = avpicture_fill(picture, VAR_5, VAR_0->pix_fmt,
VAR_0->width, VAR_0->height)) < 0)
return VAR_8;
if (VAR_0->pix_fmt == AV_PIX_FMT_PAL8) {
const uint8_t *VAR_10 = av_packet_get_side_data(VAR_3, AV_PKT_DATA_PALETTE,
NULL);
if (VAR_10) {
av_buffer_unref(&context->palette);
context->palette = av_buffer_alloc(AVPALETTE_SIZE);
if (!context->palette)
return AVERROR(ENOMEM);
memcpy(context->palette->VAR_1, VAR_10, AVPALETTE_SIZE);
frame->palette_has_changed = 1;
}
}
if ((VAR_0->pix_fmt == AV_PIX_FMT_PAL8 && VAR_6 < context->frame_size) ||
(VAR_4->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)) {
frame->VAR_5[1] = av_buffer_ref(context->palette);
if (!frame->VAR_5[1])
return AVERROR(ENOMEM);
frame->VAR_1[1] = frame->VAR_5[1]->VAR_1;
}
if (VAR_0->pix_fmt == AV_PIX_FMT_BGR24 &&
((frame->linesize[0] + 3) & ~3) * VAR_0->height <= VAR_6)
frame->linesize[0] = (frame->linesize[0] + 3) & ~3;
if (context->flip)
flip(VAR_0, picture);
if (VAR_0->codec_tag == MKTAG('Y', 'V', '1', '2') ||
VAR_0->codec_tag == MKTAG('Y', 'V', '1', '6') ||
VAR_0->codec_tag == MKTAG('Y', 'V', '2', '4') ||
VAR_0->codec_tag == MKTAG('Y', 'V', 'U', '9'))
FFSWAP(uint8_t *, picture->VAR_1[1], picture->VAR_1[2]);
if (VAR_0->codec_tag == AV_RL32("yuv2") &&
VAR_0->pix_fmt == AV_PIX_FMT_YUYV422) {
int VAR_11, VAR_12;
uint8_t *line = picture->VAR_1[0];
for (VAR_12 = 0; VAR_12 < VAR_0->height; VAR_12++) {
for (VAR_11 = 0; VAR_11 < VAR_0->width; VAR_11++)
line[2 * VAR_11 + 1] ^= 0x80;
line += picture->linesize[0];
}
}
*VAR_2 = 1;
return VAR_6;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"const AVPixFmtDescriptor *VAR_4 = av_pix_fmt_desc_get(VAR_0->pix_fmt);",
"RawVideoContext *context = VAR_0->priv_data;",
"const uint8_t *VAR_5 = VAR_3->VAR_1;",
"int VAR_6 = VAR_3->size;",
"int VAR_7 = !VAR_3->VAR_5 || context->is_2_4_bpp || context->is_yuv2;",
"int VAR_8;",
"AVFrame *frame = VAR_1;",
"AVPicture *picture = VAR_1;",
"frame->pict_type = AV_PICTURE_TYPE_I;",
"frame->key_frame = 1;",
"frame->reordered_opaque = VAR_0->reordered_opaque;",
"frame->pkt_pts = VAR_0->internal->pkt->pts;",
"if (VAR_6 < context->frame_size - (VAR_0->pix_fmt == AV_PIX_FMT_PAL8 ?\nAVPALETTE_SIZE : 0))\nreturn -1;",
"if (VAR_7)\nframe->VAR_5[0] = av_buffer_alloc(context->frame_size);",
"else\nframe->VAR_5[0] = av_buffer_ref(VAR_3->VAR_5);",
"if (!frame->VAR_5[0])\nreturn AVERROR(ENOMEM);",
"if (context->is_2_4_bpp) {",
"int VAR_9;",
"uint8_t *dst = frame->VAR_5[0]->VAR_1;",
"VAR_6 = context->frame_size - AVPALETTE_SIZE;",
"if (VAR_0->bits_per_coded_sample == 4) {",
"for (VAR_9 = 0; 2 * VAR_9 + 1 < VAR_6; VAR_9++) {",
"dst[2 * VAR_9 + 0] = VAR_5[VAR_9] >> 4;",
"dst[2 * VAR_9 + 1] = VAR_5[VAR_9] & 15;",
"}",
"} else {",
"for (VAR_9 = 0; 4 * VAR_9 + 3 < VAR_6; VAR_9++) {",
"dst[4 * VAR_9 + 0] = VAR_5[VAR_9] >> 6;",
"dst[4 * VAR_9 + 1] = VAR_5[VAR_9] >> 4 & 3;",
"dst[4 * VAR_9 + 2] = VAR_5[VAR_9] >> 2 & 3;",
"dst[4 * VAR_9 + 3] = VAR_5[VAR_9] & 3;",
"}",
"}",
"VAR_5 = dst;",
"} else if (VAR_7) {",
"memcpy(frame->VAR_5[0]->VAR_1, VAR_5, FFMIN(VAR_6, context->frame_size));",
"VAR_5 = frame->VAR_5[0]->VAR_1;",
"}",
"if (VAR_0->codec_tag == MKTAG('A', 'V', '1', 'VAR_11') ||\nVAR_0->codec_tag == MKTAG('A', 'V', 'u', 'p'))\nVAR_5 += VAR_6 - context->frame_size;",
"if ((VAR_8 = avpicture_fill(picture, VAR_5, VAR_0->pix_fmt,\nVAR_0->width, VAR_0->height)) < 0)\nreturn VAR_8;",
"if (VAR_0->pix_fmt == AV_PIX_FMT_PAL8) {",
"const uint8_t *VAR_10 = av_packet_get_side_data(VAR_3, AV_PKT_DATA_PALETTE,\nNULL);",
"if (VAR_10) {",
"av_buffer_unref(&context->palette);",
"context->palette = av_buffer_alloc(AVPALETTE_SIZE);",
"if (!context->palette)\nreturn AVERROR(ENOMEM);",
"memcpy(context->palette->VAR_1, VAR_10, AVPALETTE_SIZE);",
"frame->palette_has_changed = 1;",
"}",
"}",
"if ((VAR_0->pix_fmt == AV_PIX_FMT_PAL8 && VAR_6 < context->frame_size) ||\n(VAR_4->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)) {",
"frame->VAR_5[1] = av_buffer_ref(context->palette);",
"if (!frame->VAR_5[1])\nreturn AVERROR(ENOMEM);",
"frame->VAR_1[1] = frame->VAR_5[1]->VAR_1;",
"}",
"if (VAR_0->pix_fmt == AV_PIX_FMT_BGR24 &&\n((frame->linesize[0] + 3) & ~3) * VAR_0->height <= VAR_6)\nframe->linesize[0] = (frame->linesize[0] + 3) & ~3;",
"if (context->flip)\nflip(VAR_0, picture);",
"if (VAR_0->codec_tag == MKTAG('Y', 'V', '1', '2') ||\nVAR_0->codec_tag == MKTAG('Y', 'V', '1', '6') ||\nVAR_0->codec_tag == MKTAG('Y', 'V', '2', '4') ||\nVAR_0->codec_tag == MKTAG('Y', 'V', 'U', '9'))\nFFSWAP(uint8_t *, picture->VAR_1[1], picture->VAR_1[2]);",
"if (VAR_0->codec_tag == AV_RL32(\"yuv2\") &&\nVAR_0->pix_fmt == AV_PIX_FMT_YUYV422) {",
"int VAR_11, VAR_12;",
"uint8_t *line = picture->VAR_1[0];",
"for (VAR_12 = 0; VAR_12 < VAR_0->height; VAR_12++) {",
"for (VAR_11 = 0; VAR_11 < VAR_0->width; VAR_11++)",
"line[2 * VAR_11 + 1] ^= 0x80;",
"line += picture->linesize[0];",
"}",
"}",
"*VAR_2 = 1;",
"return VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37,
39,
41
],
[
45,
47
],
[
49,
51
],
[
53,
55
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107,
109,
111
],
[
115,
117,
119
],
[
123
],
[
125,
127
],
[
131
],
[
133
],
[
135
],
[
137,
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
151,
153
],
[
155
],
[
157,
159
],
[
161
],
[
163
],
[
165,
167,
169
],
[
173,
175
],
[
179,
181,
183,
185,
187
],
[
191,
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
213
],
[
215
],
[
217
]
] |
20,801 | static void *data_plane_thread(void *opaque)
{
VirtIOBlockDataPlane *s = opaque;
do {
aio_poll(s->ctx, true);
} while (!s->stopping || s->num_reqs > 0);
return NULL;
}
| false | qemu | bf0da4df83e8af7ec02e3809f3dd30cc0a42e4bc | static void *data_plane_thread(void *opaque)
{
VirtIOBlockDataPlane *s = opaque;
do {
aio_poll(s->ctx, true);
} while (!s->stopping || s->num_reqs > 0);
return NULL;
}
| {
"code": [],
"line_no": []
} | static void *FUNC_0(void *VAR_0)
{
VirtIOBlockDataPlane *s = VAR_0;
do {
aio_poll(s->ctx, true);
} while (!s->stopping || s->num_reqs > 0);
return NULL;
}
| [
"static void *FUNC_0(void *VAR_0)\n{",
"VirtIOBlockDataPlane *s = VAR_0;",
"do {",
"aio_poll(s->ctx, true);",
"} while (!s->stopping || s->num_reqs > 0);",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
20,804 | static int ppc_hash32_check_prot(int prot, int rwx)
{
int ret;
if (rwx == 2) {
if (prot & PAGE_EXEC) {
ret = 0;
} else {
ret = -2;
}
} else if (rwx) {
if (prot & PAGE_WRITE) {
ret = 0;
} else {
ret = -2;
}
} else {
if (prot & PAGE_READ) {
ret = 0;
} else {
ret = -2;
}
}
return ret;
}
| false | qemu | e01b444523e2b0c663b42b3e8f44ef48a6153051 | static int ppc_hash32_check_prot(int prot, int rwx)
{
int ret;
if (rwx == 2) {
if (prot & PAGE_EXEC) {
ret = 0;
} else {
ret = -2;
}
} else if (rwx) {
if (prot & PAGE_WRITE) {
ret = 0;
} else {
ret = -2;
}
} else {
if (prot & PAGE_READ) {
ret = 0;
} else {
ret = -2;
}
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(int VAR_0, int VAR_1)
{
int VAR_2;
if (VAR_1 == 2) {
if (VAR_0 & PAGE_EXEC) {
VAR_2 = 0;
} else {
VAR_2 = -2;
}
} else if (VAR_1) {
if (VAR_0 & PAGE_WRITE) {
VAR_2 = 0;
} else {
VAR_2 = -2;
}
} else {
if (VAR_0 & PAGE_READ) {
VAR_2 = 0;
} else {
VAR_2 = -2;
}
}
return VAR_2;
}
| [
"static int FUNC_0(int VAR_0, int VAR_1)\n{",
"int VAR_2;",
"if (VAR_1 == 2) {",
"if (VAR_0 & PAGE_EXEC) {",
"VAR_2 = 0;",
"} else {",
"VAR_2 = -2;",
"}",
"} else if (VAR_1) {",
"if (VAR_0 & PAGE_WRITE) {",
"VAR_2 = 0;",
"} else {",
"VAR_2 = -2;",
"}",
"} else {",
"if (VAR_0 & PAGE_READ) {",
"VAR_2 = 0;",
"} else {",
"VAR_2 = -2;",
"}",
"}",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
]
] |
20,805 | static void do_inject_mce(Monitor *mon, const QDict *qdict)
{
CPUState *cenv;
int cpu_index = qdict_get_int(qdict, "cpu_index");
int bank = qdict_get_int(qdict, "bank");
uint64_t status = qdict_get_int(qdict, "status");
uint64_t mcg_status = qdict_get_int(qdict, "mcg_status");
uint64_t addr = qdict_get_int(qdict, "addr");
uint64_t misc = qdict_get_int(qdict, "misc");
int broadcast = qdict_get_try_bool(qdict, "broadcast", 0);
for (cenv = first_cpu; cenv != NULL; cenv = cenv->next_cpu) {
if (cenv->cpu_index == cpu_index && cenv->mcg_cap) {
cpu_x86_inject_mce(cenv, bank, status, mcg_status, addr, misc,
broadcast);
break;
}
}
}
| false | qemu | 316378e4d0214b45cfeaa01609aca4dabb18d78b | static void do_inject_mce(Monitor *mon, const QDict *qdict)
{
CPUState *cenv;
int cpu_index = qdict_get_int(qdict, "cpu_index");
int bank = qdict_get_int(qdict, "bank");
uint64_t status = qdict_get_int(qdict, "status");
uint64_t mcg_status = qdict_get_int(qdict, "mcg_status");
uint64_t addr = qdict_get_int(qdict, "addr");
uint64_t misc = qdict_get_int(qdict, "misc");
int broadcast = qdict_get_try_bool(qdict, "broadcast", 0);
for (cenv = first_cpu; cenv != NULL; cenv = cenv->next_cpu) {
if (cenv->cpu_index == cpu_index && cenv->mcg_cap) {
cpu_x86_inject_mce(cenv, bank, status, mcg_status, addr, misc,
broadcast);
break;
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)
{
CPUState *cenv;
int VAR_2 = qdict_get_int(VAR_1, "VAR_2");
int VAR_3 = qdict_get_int(VAR_1, "VAR_3");
uint64_t status = qdict_get_int(VAR_1, "status");
uint64_t mcg_status = qdict_get_int(VAR_1, "mcg_status");
uint64_t addr = qdict_get_int(VAR_1, "addr");
uint64_t misc = qdict_get_int(VAR_1, "misc");
int VAR_4 = qdict_get_try_bool(VAR_1, "VAR_4", 0);
for (cenv = first_cpu; cenv != NULL; cenv = cenv->next_cpu) {
if (cenv->VAR_2 == VAR_2 && cenv->mcg_cap) {
cpu_x86_inject_mce(cenv, VAR_3, status, mcg_status, addr, misc,
VAR_4);
break;
}
}
}
| [
"static void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)\n{",
"CPUState *cenv;",
"int VAR_2 = qdict_get_int(VAR_1, \"VAR_2\");",
"int VAR_3 = qdict_get_int(VAR_1, \"VAR_3\");",
"uint64_t status = qdict_get_int(VAR_1, \"status\");",
"uint64_t mcg_status = qdict_get_int(VAR_1, \"mcg_status\");",
"uint64_t addr = qdict_get_int(VAR_1, \"addr\");",
"uint64_t misc = qdict_get_int(VAR_1, \"misc\");",
"int VAR_4 = qdict_get_try_bool(VAR_1, \"VAR_4\", 0);",
"for (cenv = first_cpu; cenv != NULL; cenv = cenv->next_cpu) {",
"if (cenv->VAR_2 == VAR_2 && cenv->mcg_cap) {",
"cpu_x86_inject_mce(cenv, VAR_3, status, mcg_status, addr, misc,\nVAR_4);",
"break;",
"}",
"}",
"}"
] | [
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
]
] |
20,806 | static void spice_register_types(void)
{
qemu_spice_init();
}
| false | qemu | ad1be89948f88e89708b04ccd782456ccec3a6f0 | static void spice_register_types(void)
{
qemu_spice_init();
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
qemu_spice_init();
}
| [
"static void FUNC_0(void)\n{",
"qemu_spice_init();",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
20,807 | static int pci_grackle_init_device(SysBusDevice *dev)
{
GrackleState *s;
int pci_mem_config, pci_mem_data;
s = FROM_SYSBUS(GrackleState, dev);
pci_mem_config = cpu_register_io_memory(pci_grackle_config_read,
pci_grackle_config_write, s);
pci_mem_data = cpu_register_io_memory(pci_grackle_read,
pci_grackle_write,
&s->host_state);
sysbus_init_mmio(dev, 0x1000, pci_mem_config);
sysbus_init_mmio(dev, 0x1000, pci_mem_data);
register_savevm("grackle", 0, 1, pci_grackle_save, pci_grackle_load,
&s->host_state);
qemu_register_reset(pci_grackle_reset, &s->host_state);
return 0;
}
| false | qemu | 4f5e19e6c570459cd524b29b24374f03860f5149 | static int pci_grackle_init_device(SysBusDevice *dev)
{
GrackleState *s;
int pci_mem_config, pci_mem_data;
s = FROM_SYSBUS(GrackleState, dev);
pci_mem_config = cpu_register_io_memory(pci_grackle_config_read,
pci_grackle_config_write, s);
pci_mem_data = cpu_register_io_memory(pci_grackle_read,
pci_grackle_write,
&s->host_state);
sysbus_init_mmio(dev, 0x1000, pci_mem_config);
sysbus_init_mmio(dev, 0x1000, pci_mem_data);
register_savevm("grackle", 0, 1, pci_grackle_save, pci_grackle_load,
&s->host_state);
qemu_register_reset(pci_grackle_reset, &s->host_state);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(SysBusDevice *VAR_0)
{
GrackleState *s;
int VAR_1, VAR_2;
s = FROM_SYSBUS(GrackleState, VAR_0);
VAR_1 = cpu_register_io_memory(pci_grackle_config_read,
pci_grackle_config_write, s);
VAR_2 = cpu_register_io_memory(pci_grackle_read,
pci_grackle_write,
&s->host_state);
sysbus_init_mmio(VAR_0, 0x1000, VAR_1);
sysbus_init_mmio(VAR_0, 0x1000, VAR_2);
register_savevm("grackle", 0, 1, pci_grackle_save, pci_grackle_load,
&s->host_state);
qemu_register_reset(pci_grackle_reset, &s->host_state);
return 0;
}
| [
"static int FUNC_0(SysBusDevice *VAR_0)\n{",
"GrackleState *s;",
"int VAR_1, VAR_2;",
"s = FROM_SYSBUS(GrackleState, VAR_0);",
"VAR_1 = cpu_register_io_memory(pci_grackle_config_read,\npci_grackle_config_write, s);",
"VAR_2 = cpu_register_io_memory(pci_grackle_read,\npci_grackle_write,\n&s->host_state);",
"sysbus_init_mmio(VAR_0, 0x1000, VAR_1);",
"sysbus_init_mmio(VAR_0, 0x1000, VAR_2);",
"register_savevm(\"grackle\", 0, 1, pci_grackle_save, pci_grackle_load,\n&s->host_state);",
"qemu_register_reset(pci_grackle_reset, &s->host_state);",
"return 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
],
[
31,
33
],
[
35
],
[
37
],
[
39
]
] |
20,808 | int qemu_strtoul(const char *nptr, const char **endptr, int base,
unsigned long *result)
{
char *ep;
int err = 0;
if (!nptr) {
if (endptr) {
*endptr = nptr;
}
err = -EINVAL;
} else {
errno = 0;
*result = strtoul(nptr, &ep, base);
/* Windows returns 1 for negative out-of-range values. */
if (errno == ERANGE) {
*result = -1;
}
err = check_strtox_error(nptr, ep, endptr, errno);
}
return err;
}
| false | qemu | 4baef2679e029c76707be1e2ed54bf3dd21693fe | int qemu_strtoul(const char *nptr, const char **endptr, int base,
unsigned long *result)
{
char *ep;
int err = 0;
if (!nptr) {
if (endptr) {
*endptr = nptr;
}
err = -EINVAL;
} else {
errno = 0;
*result = strtoul(nptr, &ep, base);
if (errno == ERANGE) {
*result = -1;
}
err = check_strtox_error(nptr, ep, endptr, errno);
}
return err;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(const char *VAR_0, const char **VAR_1, int VAR_2,
unsigned long *VAR_3)
{
char *VAR_4;
int VAR_5 = 0;
if (!VAR_0) {
if (VAR_1) {
*VAR_1 = VAR_0;
}
VAR_5 = -EINVAL;
} else {
errno = 0;
*VAR_3 = strtoul(VAR_0, &VAR_4, VAR_2);
if (errno == ERANGE) {
*VAR_3 = -1;
}
VAR_5 = check_strtox_error(VAR_0, VAR_4, VAR_1, errno);
}
return VAR_5;
}
| [
"int FUNC_0(const char *VAR_0, const char **VAR_1, int VAR_2,\nunsigned long *VAR_3)\n{",
"char *VAR_4;",
"int VAR_5 = 0;",
"if (!VAR_0) {",
"if (VAR_1) {",
"*VAR_1 = VAR_0;",
"}",
"VAR_5 = -EINVAL;",
"} else {",
"errno = 0;",
"*VAR_3 = strtoul(VAR_0, &VAR_4, VAR_2);",
"if (errno == ERANGE) {",
"*VAR_3 = -1;",
"}",
"VAR_5 = check_strtox_error(VAR_0, VAR_4, VAR_1, errno);",
"}",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
]
] |
20,809 | static void rtl8139_cleanup(NetClientState *nc)
{
RTL8139State *s = qemu_get_nic_opaque(nc);
s->nic = NULL;
}
| false | qemu | 57407ea44cc0a3d630b9b89a2be011f1955ce5c1 | static void rtl8139_cleanup(NetClientState *nc)
{
RTL8139State *s = qemu_get_nic_opaque(nc);
s->nic = NULL;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(NetClientState *VAR_0)
{
RTL8139State *s = qemu_get_nic_opaque(VAR_0);
s->nic = NULL;
}
| [
"static void FUNC_0(NetClientState *VAR_0)\n{",
"RTL8139State *s = qemu_get_nic_opaque(VAR_0);",
"s->nic = NULL;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
]
] |
20,810 | static int uhci_handle_td(UHCIState *s, UHCI_TD *td, uint32_t *int_mask,
int completion)
{
uint8_t pid;
int len = 0, max_len, err, ret = 0;
/* ??? This is wrong for async completion. */
if (td->ctrl & TD_CTRL_IOC) {
*int_mask |= 0x01;
}
if (!(td->ctrl & TD_CTRL_ACTIVE))
return 1;
/* TD is active */
max_len = ((td->token >> 21) + 1) & 0x7ff;
pid = td->token & 0xff;
if (completion && (s->async_qh || s->async_frame_addr)) {
ret = s->usb_packet.len;
if (ret >= 0) {
len = ret;
if (len > max_len) {
len = max_len;
ret = USB_RET_BABBLE;
}
if (len > 0) {
/* write the data back */
cpu_physical_memory_write(td->buffer, s->usb_buf, len);
}
} else {
len = 0;
}
s->async_qh = 0;
s->async_frame_addr = 0;
} else if (!completion) {
s->usb_packet.pid = pid;
s->usb_packet.devaddr = (td->token >> 8) & 0x7f;
s->usb_packet.devep = (td->token >> 15) & 0xf;
s->usb_packet.data = s->usb_buf;
s->usb_packet.len = max_len;
s->usb_packet.complete_cb = uhci_async_complete_packet;
s->usb_packet.complete_opaque = s;
switch(pid) {
case USB_TOKEN_OUT:
case USB_TOKEN_SETUP:
cpu_physical_memory_read(td->buffer, s->usb_buf, max_len);
ret = uhci_broadcast_packet(s, &s->usb_packet);
len = max_len;
break;
case USB_TOKEN_IN:
ret = uhci_broadcast_packet(s, &s->usb_packet);
if (ret >= 0) {
len = ret;
if (len > max_len) {
len = max_len;
ret = USB_RET_BABBLE;
}
if (len > 0) {
/* write the data back */
cpu_physical_memory_write(td->buffer, s->usb_buf, len);
}
} else {
len = 0;
}
break;
default:
/* invalid pid : frame interrupted */
s->status |= UHCI_STS_HCPERR;
uhci_update_irq(s);
return -1;
}
}
if (ret == USB_RET_ASYNC) {
return 2;
}
if (td->ctrl & TD_CTRL_IOS)
td->ctrl &= ~TD_CTRL_ACTIVE;
if (ret >= 0) {
td->ctrl = (td->ctrl & ~0x7ff) | ((len - 1) & 0x7ff);
/* The NAK bit may have been set by a previous frame, so clear it
here. The docs are somewhat unclear, but win2k relies on this
behavior. */
td->ctrl &= ~(TD_CTRL_ACTIVE | TD_CTRL_NAK);
if (pid == USB_TOKEN_IN &&
(td->ctrl & TD_CTRL_SPD) &&
len < max_len) {
*int_mask |= 0x02;
/* short packet: do not update QH */
return 1;
} else {
/* success */
return 0;
}
} else {
switch(ret) {
default:
case USB_RET_NODEV:
do_timeout:
td->ctrl |= TD_CTRL_TIMEOUT;
err = (td->ctrl >> TD_CTRL_ERROR_SHIFT) & 3;
if (err != 0) {
err--;
if (err == 0) {
td->ctrl &= ~TD_CTRL_ACTIVE;
s->status |= UHCI_STS_USBERR;
uhci_update_irq(s);
}
}
td->ctrl = (td->ctrl & ~(3 << TD_CTRL_ERROR_SHIFT)) |
(err << TD_CTRL_ERROR_SHIFT);
return 1;
case USB_RET_NAK:
td->ctrl |= TD_CTRL_NAK;
if (pid == USB_TOKEN_SETUP)
goto do_timeout;
return 1;
case USB_RET_STALL:
td->ctrl |= TD_CTRL_STALL;
td->ctrl &= ~TD_CTRL_ACTIVE;
return 1;
case USB_RET_BABBLE:
td->ctrl |= TD_CTRL_BABBLE | TD_CTRL_STALL;
td->ctrl &= ~TD_CTRL_ACTIVE;
/* frame interrupted */
return -1;
}
}
}
| false | qemu | 54f254f973a1b2ed0f3571390f4de060adfe23e8 | static int uhci_handle_td(UHCIState *s, UHCI_TD *td, uint32_t *int_mask,
int completion)
{
uint8_t pid;
int len = 0, max_len, err, ret = 0;
if (td->ctrl & TD_CTRL_IOC) {
*int_mask |= 0x01;
}
if (!(td->ctrl & TD_CTRL_ACTIVE))
return 1;
max_len = ((td->token >> 21) + 1) & 0x7ff;
pid = td->token & 0xff;
if (completion && (s->async_qh || s->async_frame_addr)) {
ret = s->usb_packet.len;
if (ret >= 0) {
len = ret;
if (len > max_len) {
len = max_len;
ret = USB_RET_BABBLE;
}
if (len > 0) {
cpu_physical_memory_write(td->buffer, s->usb_buf, len);
}
} else {
len = 0;
}
s->async_qh = 0;
s->async_frame_addr = 0;
} else if (!completion) {
s->usb_packet.pid = pid;
s->usb_packet.devaddr = (td->token >> 8) & 0x7f;
s->usb_packet.devep = (td->token >> 15) & 0xf;
s->usb_packet.data = s->usb_buf;
s->usb_packet.len = max_len;
s->usb_packet.complete_cb = uhci_async_complete_packet;
s->usb_packet.complete_opaque = s;
switch(pid) {
case USB_TOKEN_OUT:
case USB_TOKEN_SETUP:
cpu_physical_memory_read(td->buffer, s->usb_buf, max_len);
ret = uhci_broadcast_packet(s, &s->usb_packet);
len = max_len;
break;
case USB_TOKEN_IN:
ret = uhci_broadcast_packet(s, &s->usb_packet);
if (ret >= 0) {
len = ret;
if (len > max_len) {
len = max_len;
ret = USB_RET_BABBLE;
}
if (len > 0) {
cpu_physical_memory_write(td->buffer, s->usb_buf, len);
}
} else {
len = 0;
}
break;
default:
s->status |= UHCI_STS_HCPERR;
uhci_update_irq(s);
return -1;
}
}
if (ret == USB_RET_ASYNC) {
return 2;
}
if (td->ctrl & TD_CTRL_IOS)
td->ctrl &= ~TD_CTRL_ACTIVE;
if (ret >= 0) {
td->ctrl = (td->ctrl & ~0x7ff) | ((len - 1) & 0x7ff);
td->ctrl &= ~(TD_CTRL_ACTIVE | TD_CTRL_NAK);
if (pid == USB_TOKEN_IN &&
(td->ctrl & TD_CTRL_SPD) &&
len < max_len) {
*int_mask |= 0x02;
return 1;
} else {
return 0;
}
} else {
switch(ret) {
default:
case USB_RET_NODEV:
do_timeout:
td->ctrl |= TD_CTRL_TIMEOUT;
err = (td->ctrl >> TD_CTRL_ERROR_SHIFT) & 3;
if (err != 0) {
err--;
if (err == 0) {
td->ctrl &= ~TD_CTRL_ACTIVE;
s->status |= UHCI_STS_USBERR;
uhci_update_irq(s);
}
}
td->ctrl = (td->ctrl & ~(3 << TD_CTRL_ERROR_SHIFT)) |
(err << TD_CTRL_ERROR_SHIFT);
return 1;
case USB_RET_NAK:
td->ctrl |= TD_CTRL_NAK;
if (pid == USB_TOKEN_SETUP)
goto do_timeout;
return 1;
case USB_RET_STALL:
td->ctrl |= TD_CTRL_STALL;
td->ctrl &= ~TD_CTRL_ACTIVE;
return 1;
case USB_RET_BABBLE:
td->ctrl |= TD_CTRL_BABBLE | TD_CTRL_STALL;
td->ctrl &= ~TD_CTRL_ACTIVE;
return -1;
}
}
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(UHCIState *VAR_0, UHCI_TD *VAR_1, uint32_t *VAR_2,
int VAR_3)
{
uint8_t pid;
int VAR_4 = 0, VAR_5, VAR_6, VAR_7 = 0;
if (VAR_1->ctrl & TD_CTRL_IOC) {
*VAR_2 |= 0x01;
}
if (!(VAR_1->ctrl & TD_CTRL_ACTIVE))
return 1;
VAR_5 = ((VAR_1->token >> 21) + 1) & 0x7ff;
pid = VAR_1->token & 0xff;
if (VAR_3 && (VAR_0->async_qh || VAR_0->async_frame_addr)) {
VAR_7 = VAR_0->usb_packet.VAR_4;
if (VAR_7 >= 0) {
VAR_4 = VAR_7;
if (VAR_4 > VAR_5) {
VAR_4 = VAR_5;
VAR_7 = USB_RET_BABBLE;
}
if (VAR_4 > 0) {
cpu_physical_memory_write(VAR_1->buffer, VAR_0->usb_buf, VAR_4);
}
} else {
VAR_4 = 0;
}
VAR_0->async_qh = 0;
VAR_0->async_frame_addr = 0;
} else if (!VAR_3) {
VAR_0->usb_packet.pid = pid;
VAR_0->usb_packet.devaddr = (VAR_1->token >> 8) & 0x7f;
VAR_0->usb_packet.devep = (VAR_1->token >> 15) & 0xf;
VAR_0->usb_packet.data = VAR_0->usb_buf;
VAR_0->usb_packet.VAR_4 = VAR_5;
VAR_0->usb_packet.complete_cb = uhci_async_complete_packet;
VAR_0->usb_packet.complete_opaque = VAR_0;
switch(pid) {
case USB_TOKEN_OUT:
case USB_TOKEN_SETUP:
cpu_physical_memory_read(VAR_1->buffer, VAR_0->usb_buf, VAR_5);
VAR_7 = uhci_broadcast_packet(VAR_0, &VAR_0->usb_packet);
VAR_4 = VAR_5;
break;
case USB_TOKEN_IN:
VAR_7 = uhci_broadcast_packet(VAR_0, &VAR_0->usb_packet);
if (VAR_7 >= 0) {
VAR_4 = VAR_7;
if (VAR_4 > VAR_5) {
VAR_4 = VAR_5;
VAR_7 = USB_RET_BABBLE;
}
if (VAR_4 > 0) {
cpu_physical_memory_write(VAR_1->buffer, VAR_0->usb_buf, VAR_4);
}
} else {
VAR_4 = 0;
}
break;
default:
VAR_0->status |= UHCI_STS_HCPERR;
uhci_update_irq(VAR_0);
return -1;
}
}
if (VAR_7 == USB_RET_ASYNC) {
return 2;
}
if (VAR_1->ctrl & TD_CTRL_IOS)
VAR_1->ctrl &= ~TD_CTRL_ACTIVE;
if (VAR_7 >= 0) {
VAR_1->ctrl = (VAR_1->ctrl & ~0x7ff) | ((VAR_4 - 1) & 0x7ff);
VAR_1->ctrl &= ~(TD_CTRL_ACTIVE | TD_CTRL_NAK);
if (pid == USB_TOKEN_IN &&
(VAR_1->ctrl & TD_CTRL_SPD) &&
VAR_4 < VAR_5) {
*VAR_2 |= 0x02;
return 1;
} else {
return 0;
}
} else {
switch(VAR_7) {
default:
case USB_RET_NODEV:
do_timeout:
VAR_1->ctrl |= TD_CTRL_TIMEOUT;
VAR_6 = (VAR_1->ctrl >> TD_CTRL_ERROR_SHIFT) & 3;
if (VAR_6 != 0) {
VAR_6--;
if (VAR_6 == 0) {
VAR_1->ctrl &= ~TD_CTRL_ACTIVE;
VAR_0->status |= UHCI_STS_USBERR;
uhci_update_irq(VAR_0);
}
}
VAR_1->ctrl = (VAR_1->ctrl & ~(3 << TD_CTRL_ERROR_SHIFT)) |
(VAR_6 << TD_CTRL_ERROR_SHIFT);
return 1;
case USB_RET_NAK:
VAR_1->ctrl |= TD_CTRL_NAK;
if (pid == USB_TOKEN_SETUP)
goto do_timeout;
return 1;
case USB_RET_STALL:
VAR_1->ctrl |= TD_CTRL_STALL;
VAR_1->ctrl &= ~TD_CTRL_ACTIVE;
return 1;
case USB_RET_BABBLE:
VAR_1->ctrl |= TD_CTRL_BABBLE | TD_CTRL_STALL;
VAR_1->ctrl &= ~TD_CTRL_ACTIVE;
return -1;
}
}
}
| [
"static int FUNC_0(UHCIState *VAR_0, UHCI_TD *VAR_1, uint32_t *VAR_2,\nint VAR_3)\n{",
"uint8_t pid;",
"int VAR_4 = 0, VAR_5, VAR_6, VAR_7 = 0;",
"if (VAR_1->ctrl & TD_CTRL_IOC) {",
"*VAR_2 |= 0x01;",
"}",
"if (!(VAR_1->ctrl & TD_CTRL_ACTIVE))\nreturn 1;",
"VAR_5 = ((VAR_1->token >> 21) + 1) & 0x7ff;",
"pid = VAR_1->token & 0xff;",
"if (VAR_3 && (VAR_0->async_qh || VAR_0->async_frame_addr)) {",
"VAR_7 = VAR_0->usb_packet.VAR_4;",
"if (VAR_7 >= 0) {",
"VAR_4 = VAR_7;",
"if (VAR_4 > VAR_5) {",
"VAR_4 = VAR_5;",
"VAR_7 = USB_RET_BABBLE;",
"}",
"if (VAR_4 > 0) {",
"cpu_physical_memory_write(VAR_1->buffer, VAR_0->usb_buf, VAR_4);",
"}",
"} else {",
"VAR_4 = 0;",
"}",
"VAR_0->async_qh = 0;",
"VAR_0->async_frame_addr = 0;",
"} else if (!VAR_3) {",
"VAR_0->usb_packet.pid = pid;",
"VAR_0->usb_packet.devaddr = (VAR_1->token >> 8) & 0x7f;",
"VAR_0->usb_packet.devep = (VAR_1->token >> 15) & 0xf;",
"VAR_0->usb_packet.data = VAR_0->usb_buf;",
"VAR_0->usb_packet.VAR_4 = VAR_5;",
"VAR_0->usb_packet.complete_cb = uhci_async_complete_packet;",
"VAR_0->usb_packet.complete_opaque = VAR_0;",
"switch(pid) {",
"case USB_TOKEN_OUT:\ncase USB_TOKEN_SETUP:\ncpu_physical_memory_read(VAR_1->buffer, VAR_0->usb_buf, VAR_5);",
"VAR_7 = uhci_broadcast_packet(VAR_0, &VAR_0->usb_packet);",
"VAR_4 = VAR_5;",
"break;",
"case USB_TOKEN_IN:\nVAR_7 = uhci_broadcast_packet(VAR_0, &VAR_0->usb_packet);",
"if (VAR_7 >= 0) {",
"VAR_4 = VAR_7;",
"if (VAR_4 > VAR_5) {",
"VAR_4 = VAR_5;",
"VAR_7 = USB_RET_BABBLE;",
"}",
"if (VAR_4 > 0) {",
"cpu_physical_memory_write(VAR_1->buffer, VAR_0->usb_buf, VAR_4);",
"}",
"} else {",
"VAR_4 = 0;",
"}",
"break;",
"default:\nVAR_0->status |= UHCI_STS_HCPERR;",
"uhci_update_irq(VAR_0);",
"return -1;",
"}",
"}",
"if (VAR_7 == USB_RET_ASYNC) {",
"return 2;",
"}",
"if (VAR_1->ctrl & TD_CTRL_IOS)\nVAR_1->ctrl &= ~TD_CTRL_ACTIVE;",
"if (VAR_7 >= 0) {",
"VAR_1->ctrl = (VAR_1->ctrl & ~0x7ff) | ((VAR_4 - 1) & 0x7ff);",
"VAR_1->ctrl &= ~(TD_CTRL_ACTIVE | TD_CTRL_NAK);",
"if (pid == USB_TOKEN_IN &&\n(VAR_1->ctrl & TD_CTRL_SPD) &&\nVAR_4 < VAR_5) {",
"*VAR_2 |= 0x02;",
"return 1;",
"} else {",
"return 0;",
"}",
"} else {",
"switch(VAR_7) {",
"default:\ncase USB_RET_NODEV:\ndo_timeout:\nVAR_1->ctrl |= TD_CTRL_TIMEOUT;",
"VAR_6 = (VAR_1->ctrl >> TD_CTRL_ERROR_SHIFT) & 3;",
"if (VAR_6 != 0) {",
"VAR_6--;",
"if (VAR_6 == 0) {",
"VAR_1->ctrl &= ~TD_CTRL_ACTIVE;",
"VAR_0->status |= UHCI_STS_USBERR;",
"uhci_update_irq(VAR_0);",
"}",
"}",
"VAR_1->ctrl = (VAR_1->ctrl & ~(3 << TD_CTRL_ERROR_SHIFT)) |\n(VAR_6 << TD_CTRL_ERROR_SHIFT);",
"return 1;",
"case USB_RET_NAK:\nVAR_1->ctrl |= TD_CTRL_NAK;",
"if (pid == USB_TOKEN_SETUP)\ngoto do_timeout;",
"return 1;",
"case USB_RET_STALL:\nVAR_1->ctrl |= TD_CTRL_STALL;",
"VAR_1->ctrl &= ~TD_CTRL_ACTIVE;",
"return 1;",
"case USB_RET_BABBLE:\nVAR_1->ctrl |= TD_CTRL_BABBLE | TD_CTRL_STALL;",
"VAR_1->ctrl &= ~TD_CTRL_ACTIVE;",
"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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
19
],
[
23,
25
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89,
91,
93
],
[
95
],
[
97
],
[
99
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133,
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155,
157
],
[
159
],
[
161
],
[
169
],
[
171,
173,
175
],
[
177
],
[
181
],
[
183
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195,
197,
199,
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221,
223
],
[
225
],
[
227,
229
],
[
231,
233
],
[
235
],
[
237,
239
],
[
241
],
[
243
],
[
245,
247
],
[
249
],
[
253
],
[
255
],
[
257
],
[
259
]
] |
20,813 | static void option_rom_reset(void *_rrd)
{
RomResetData *rrd = _rrd;
cpu_physical_memory_write_rom(rrd->addr, rrd->data, rrd->size);
}
| false | qemu | 45a50b1668822c23afc2a89f724654e176518bc4 | static void option_rom_reset(void *_rrd)
{
RomResetData *rrd = _rrd;
cpu_physical_memory_write_rom(rrd->addr, rrd->data, rrd->size);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
RomResetData *rrd = VAR_0;
cpu_physical_memory_write_rom(rrd->addr, rrd->data, rrd->size);
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"RomResetData *rrd = VAR_0;",
"cpu_physical_memory_write_rom(rrd->addr, rrd->data, rrd->size);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
]
] |
20,814 | static int v9fs_synth_lremovexattr(FsContext *ctx,
V9fsPath *path, const char *name)
{
errno = ENOTSUP;
return -1;
}
| false | qemu | 364031f17932814484657e5551ba12957d993d7e | static int v9fs_synth_lremovexattr(FsContext *ctx,
V9fsPath *path, const char *name)
{
errno = ENOTSUP;
return -1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(FsContext *VAR_0,
V9fsPath *VAR_1, const char *VAR_2)
{
errno = ENOTSUP;
return -1;
}
| [
"static int FUNC_0(FsContext *VAR_0,\nV9fsPath *VAR_1, const char *VAR_2)\n{",
"errno = ENOTSUP;",
"return -1;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
]
] |
20,815 | static inline int get_phys_addr(CPUState *env, uint32_t address,
int access_type, int is_user,
uint32_t *phys_ptr, int *prot,
target_ulong *page_size)
{
/* Fast Context Switch Extension. */
if (address < 0x02000000)
address += env->cp15.c13_fcse;
if ((env->cp15.c1_sys & 1) == 0) {
/* MMU/MPU disabled. */
*phys_ptr = address;
*prot = PAGE_READ | PAGE_WRITE;
*page_size = TARGET_PAGE_SIZE;
return 0;
} else if (arm_feature(env, ARM_FEATURE_MPU)) {
*page_size = TARGET_PAGE_SIZE;
return get_phys_addr_mpu(env, address, access_type, is_user, phys_ptr,
prot);
} else if (env->cp15.c1_sys & (1 << 23)) {
return get_phys_addr_v6(env, address, access_type, is_user, phys_ptr,
prot, page_size);
} else {
return get_phys_addr_v5(env, address, access_type, is_user, phys_ptr,
prot, page_size);
}
}
| false | qemu | 3ad493fc5ea38c005670adc5933058a28ccabdd4 | static inline int get_phys_addr(CPUState *env, uint32_t address,
int access_type, int is_user,
uint32_t *phys_ptr, int *prot,
target_ulong *page_size)
{
if (address < 0x02000000)
address += env->cp15.c13_fcse;
if ((env->cp15.c1_sys & 1) == 0) {
*phys_ptr = address;
*prot = PAGE_READ | PAGE_WRITE;
*page_size = TARGET_PAGE_SIZE;
return 0;
} else if (arm_feature(env, ARM_FEATURE_MPU)) {
*page_size = TARGET_PAGE_SIZE;
return get_phys_addr_mpu(env, address, access_type, is_user, phys_ptr,
prot);
} else if (env->cp15.c1_sys & (1 << 23)) {
return get_phys_addr_v6(env, address, access_type, is_user, phys_ptr,
prot, page_size);
} else {
return get_phys_addr_v5(env, address, access_type, is_user, phys_ptr,
prot, page_size);
}
}
| {
"code": [],
"line_no": []
} | static inline int FUNC_0(CPUState *VAR_0, uint32_t VAR_1,
int VAR_2, int VAR_3,
uint32_t *VAR_4, int *VAR_5,
target_ulong *VAR_6)
{
if (VAR_1 < 0x02000000)
VAR_1 += VAR_0->cp15.c13_fcse;
if ((VAR_0->cp15.c1_sys & 1) == 0) {
*VAR_4 = VAR_1;
*VAR_5 = PAGE_READ | PAGE_WRITE;
*VAR_6 = TARGET_PAGE_SIZE;
return 0;
} else if (arm_feature(VAR_0, ARM_FEATURE_MPU)) {
*VAR_6 = TARGET_PAGE_SIZE;
return get_phys_addr_mpu(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4,
VAR_5);
} else if (VAR_0->cp15.c1_sys & (1 << 23)) {
return get_phys_addr_v6(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4,
VAR_5, VAR_6);
} else {
return get_phys_addr_v5(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4,
VAR_5, VAR_6);
}
}
| [
"static inline int FUNC_0(CPUState *VAR_0, uint32_t VAR_1,\nint VAR_2, int VAR_3,\nuint32_t *VAR_4, int *VAR_5,\ntarget_ulong *VAR_6)\n{",
"if (VAR_1 < 0x02000000)\nVAR_1 += VAR_0->cp15.c13_fcse;",
"if ((VAR_0->cp15.c1_sys & 1) == 0) {",
"*VAR_4 = VAR_1;",
"*VAR_5 = PAGE_READ | PAGE_WRITE;",
"*VAR_6 = TARGET_PAGE_SIZE;",
"return 0;",
"} else if (arm_feature(VAR_0, ARM_FEATURE_MPU)) {",
"*VAR_6 = TARGET_PAGE_SIZE;",
"return get_phys_addr_mpu(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4,\nVAR_5);",
"} else if (VAR_0->cp15.c1_sys & (1 << 23)) {",
"return get_phys_addr_v6(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4,\nVAR_5, VAR_6);",
"} else {",
"return get_phys_addr_v5(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4,\nVAR_5, VAR_6);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
13,
15
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41,
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
]
] |
20,816 | static uint64_t a9_scu_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
a9mp_priv_state *s = (a9mp_priv_state *)opaque;
switch (offset) {
case 0x00: /* Control */
return s->scu_control;
case 0x04: /* Configuration */
return (((1 << s->num_cpu) - 1) << 4) | (s->num_cpu - 1);
case 0x08: /* CPU Power Status */
return s->scu_status;
case 0x09: /* CPU status. */
return s->scu_status >> 8;
case 0x0a: /* CPU status. */
return s->scu_status >> 16;
case 0x0b: /* CPU status. */
return s->scu_status >> 24;
case 0x0c: /* Invalidate All Registers In Secure State */
return 0;
case 0x40: /* Filtering Start Address Register */
case 0x44: /* Filtering End Address Register */
/* RAZ/WI, like an implementation with only one AXI master */
return 0;
case 0x50: /* SCU Access Control Register */
case 0x54: /* SCU Non-secure Access Control Register */
/* unimplemented, fall through */
default:
return 0;
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t a9_scu_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
a9mp_priv_state *s = (a9mp_priv_state *)opaque;
switch (offset) {
case 0x00:
return s->scu_control;
case 0x04:
return (((1 << s->num_cpu) - 1) << 4) | (s->num_cpu - 1);
case 0x08:
return s->scu_status;
case 0x09:
return s->scu_status >> 8;
case 0x0a:
return s->scu_status >> 16;
case 0x0b:
return s->scu_status >> 24;
case 0x0c:
return 0;
case 0x40:
case 0x44:
return 0;
case 0x50:
case 0x54:
default:
return 0;
}
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t offset,
unsigned size)
{
a9mp_priv_state *s = (a9mp_priv_state *)opaque;
switch (offset) {
case 0x00:
return s->scu_control;
case 0x04:
return (((1 << s->num_cpu) - 1) << 4) | (s->num_cpu - 1);
case 0x08:
return s->scu_status;
case 0x09:
return s->scu_status >> 8;
case 0x0a:
return s->scu_status >> 16;
case 0x0b:
return s->scu_status >> 24;
case 0x0c:
return 0;
case 0x40:
case 0x44:
return 0;
case 0x50:
case 0x54:
default:
return 0;
}
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t offset,\nunsigned size)\n{",
"a9mp_priv_state *s = (a9mp_priv_state *)opaque;",
"switch (offset) {",
"case 0x00:\nreturn s->scu_control;",
"case 0x04:\nreturn (((1 << s->num_cpu) - 1) << 4) | (s->num_cpu - 1);",
"case 0x08:\nreturn s->scu_status;",
"case 0x09:\nreturn s->scu_status >> 8;",
"case 0x0a:\nreturn s->scu_status >> 16;",
"case 0x0b:\nreturn s->scu_status >> 24;",
"case 0x0c:\nreturn 0;",
"case 0x40:\ncase 0x44:\nreturn 0;",
"case 0x50:\ncase 0x54:\ndefault:\nreturn 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,
45
],
[
47,
49,
53,
55
],
[
57
],
[
59
]
] |
20,817 | uint32_t ldl_phys(target_phys_addr_t addr)
{
return ldl_phys_internal(addr, DEVICE_NATIVE_ENDIAN);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | uint32_t ldl_phys(target_phys_addr_t addr)
{
return ldl_phys_internal(addr, DEVICE_NATIVE_ENDIAN);
}
| {
"code": [],
"line_no": []
} | uint32_t FUNC_0(target_phys_addr_t addr)
{
return ldl_phys_internal(addr, DEVICE_NATIVE_ENDIAN);
}
| [
"uint32_t FUNC_0(target_phys_addr_t addr)\n{",
"return ldl_phys_internal(addr, DEVICE_NATIVE_ENDIAN);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
20,818 | void virtio_queue_set_host_notifier_fd_handler(VirtQueue *vq, bool assign,
bool set_handler)
{
if (assign && set_handler) {
event_notifier_set_handler(&vq->host_notifier, true,
virtio_queue_host_notifier_read);
} else {
event_notifier_set_handler(&vq->host_notifier, true, NULL);
}
if (!assign) {
/* Test and clear notifier before after disabling event,
* in case poll callback didn't have time to run. */
virtio_queue_host_notifier_read(&vq->host_notifier);
}
}
| false | qemu | 872dd82c83745a603d2e07a03d34313eb6467ae4 | void virtio_queue_set_host_notifier_fd_handler(VirtQueue *vq, bool assign,
bool set_handler)
{
if (assign && set_handler) {
event_notifier_set_handler(&vq->host_notifier, true,
virtio_queue_host_notifier_read);
} else {
event_notifier_set_handler(&vq->host_notifier, true, NULL);
}
if (!assign) {
virtio_queue_host_notifier_read(&vq->host_notifier);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(VirtQueue *VAR_0, bool VAR_1,
bool VAR_2)
{
if (VAR_1 && VAR_2) {
event_notifier_set_handler(&VAR_0->host_notifier, true,
virtio_queue_host_notifier_read);
} else {
event_notifier_set_handler(&VAR_0->host_notifier, true, NULL);
}
if (!VAR_1) {
virtio_queue_host_notifier_read(&VAR_0->host_notifier);
}
}
| [
"void FUNC_0(VirtQueue *VAR_0, bool VAR_1,\nbool VAR_2)\n{",
"if (VAR_1 && VAR_2) {",
"event_notifier_set_handler(&VAR_0->host_notifier, true,\nvirtio_queue_host_notifier_read);",
"} else {",
"event_notifier_set_handler(&VAR_0->host_notifier, true, NULL);",
"}",
"if (!VAR_1) {",
"virtio_queue_host_notifier_read(&VAR_0->host_notifier);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
25
],
[
27
],
[
29
]
] |
20,819 | bool qemu_clock_use_for_deadline(QEMUClockType type)
{
return !(use_icount && (type == QEMU_CLOCK_VIRTUAL));
}
| false | qemu | c2b38b277a7882a592f4f2ec955084b2b756daaa | bool qemu_clock_use_for_deadline(QEMUClockType type)
{
return !(use_icount && (type == QEMU_CLOCK_VIRTUAL));
}
| {
"code": [],
"line_no": []
} | bool FUNC_0(QEMUClockType type)
{
return !(use_icount && (type == QEMU_CLOCK_VIRTUAL));
}
| [
"bool FUNC_0(QEMUClockType type)\n{",
"return !(use_icount && (type == QEMU_CLOCK_VIRTUAL));",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
20,820 | static void term_forward_char(void)
{
if (term_cmd_buf_index < term_cmd_buf_size) {
term_cmd_buf_index++;
}
}
| false | qemu | 7e2515e87c41e2e658aaed466e11cbdf1ea8bcb1 | static void term_forward_char(void)
{
if (term_cmd_buf_index < term_cmd_buf_size) {
term_cmd_buf_index++;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
if (term_cmd_buf_index < term_cmd_buf_size) {
term_cmd_buf_index++;
}
}
| [
"static void FUNC_0(void)\n{",
"if (term_cmd_buf_index < term_cmd_buf_size) {",
"term_cmd_buf_index++;",
"}",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
20,821 | static int input_initialise(struct XenDevice *xendev)
{
struct XenInput *in = container_of(xendev, struct XenInput, c.xendev);
int rc;
if (!in->c.con) {
xen_pv_printf(xendev, 1, "ds not set (yet)\n");
return -1;
}
rc = common_bind(&in->c);
if (rc != 0)
return rc;
qemu_add_kbd_event_handler(xenfb_key_event, in);
return 0;
}
| false | qemu | 9f2130f58d5dd4e1fcb435cca08bf77e7c32e6c6 | static int input_initialise(struct XenDevice *xendev)
{
struct XenInput *in = container_of(xendev, struct XenInput, c.xendev);
int rc;
if (!in->c.con) {
xen_pv_printf(xendev, 1, "ds not set (yet)\n");
return -1;
}
rc = common_bind(&in->c);
if (rc != 0)
return rc;
qemu_add_kbd_event_handler(xenfb_key_event, in);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(struct XenDevice *VAR_0)
{
struct XenInput *VAR_1 = container_of(VAR_0, struct XenInput, c.VAR_0);
int VAR_2;
if (!VAR_1->c.con) {
xen_pv_printf(VAR_0, 1, "ds not set (yet)\n");
return -1;
}
VAR_2 = common_bind(&VAR_1->c);
if (VAR_2 != 0)
return VAR_2;
qemu_add_kbd_event_handler(xenfb_key_event, VAR_1);
return 0;
}
| [
"static int FUNC_0(struct XenDevice *VAR_0)\n{",
"struct XenInput *VAR_1 = container_of(VAR_0, struct XenInput, c.VAR_0);",
"int VAR_2;",
"if (!VAR_1->c.con) {",
"xen_pv_printf(VAR_0, 1, \"ds not set (yet)\\n\");",
"return -1;",
"}",
"VAR_2 = common_bind(&VAR_1->c);",
"if (VAR_2 != 0)\nreturn VAR_2;",
"qemu_add_kbd_event_handler(xenfb_key_event, VAR_1);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23,
25
],
[
29
],
[
31
],
[
33
]
] |
20,822 | int audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int size)
{
HWVoiceIn *hw = sw->hw;
int samples, live, ret = 0, swlim, isamp, osamp, rpos, total = 0;
st_sample_t *src, *dst = sw->buf;
rpos = audio_pcm_sw_get_rpos_in (sw) % hw->samples;
live = hw->total_samples_captured - sw->total_hw_samples_acquired;
if (audio_bug (AUDIO_FUNC, live < 0 || live > hw->samples)) {
dolog ("live_in=%d hw->samples=%d\n", live, hw->samples);
return 0;
}
samples = size >> sw->info.shift;
if (!live) {
return 0;
}
swlim = (live * sw->ratio) >> 32;
swlim = audio_MIN (swlim, samples);
while (swlim) {
src = hw->conv_buf + rpos;
isamp = hw->wpos - rpos;
/* XXX: <= ? */
if (isamp <= 0) {
isamp = hw->samples - rpos;
}
if (!isamp) {
break;
}
osamp = swlim;
if (audio_bug (AUDIO_FUNC, osamp < 0)) {
dolog ("osamp=%d\n", osamp);
return 0;
}
st_rate_flow (sw->rate, src, dst, &isamp, &osamp);
swlim -= osamp;
rpos = (rpos + isamp) % hw->samples;
dst += osamp;
ret += osamp;
total += isamp;
}
sw->clip (buf, sw->buf, ret);
sw->total_hw_samples_acquired += total;
return ret << sw->info.shift;
}
| false | qemu | 1ea879e5580f63414693655fcf0328559cdce138 | int audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int size)
{
HWVoiceIn *hw = sw->hw;
int samples, live, ret = 0, swlim, isamp, osamp, rpos, total = 0;
st_sample_t *src, *dst = sw->buf;
rpos = audio_pcm_sw_get_rpos_in (sw) % hw->samples;
live = hw->total_samples_captured - sw->total_hw_samples_acquired;
if (audio_bug (AUDIO_FUNC, live < 0 || live > hw->samples)) {
dolog ("live_in=%d hw->samples=%d\n", live, hw->samples);
return 0;
}
samples = size >> sw->info.shift;
if (!live) {
return 0;
}
swlim = (live * sw->ratio) >> 32;
swlim = audio_MIN (swlim, samples);
while (swlim) {
src = hw->conv_buf + rpos;
isamp = hw->wpos - rpos;
if (isamp <= 0) {
isamp = hw->samples - rpos;
}
if (!isamp) {
break;
}
osamp = swlim;
if (audio_bug (AUDIO_FUNC, osamp < 0)) {
dolog ("osamp=%d\n", osamp);
return 0;
}
st_rate_flow (sw->rate, src, dst, &isamp, &osamp);
swlim -= osamp;
rpos = (rpos + isamp) % hw->samples;
dst += osamp;
ret += osamp;
total += isamp;
}
sw->clip (buf, sw->buf, ret);
sw->total_hw_samples_acquired += total;
return ret << sw->info.shift;
}
| {
"code": [],
"line_no": []
} | int FUNC_0 (SWVoiceIn *VAR_0, void *VAR_1, int VAR_2)
{
HWVoiceIn *hw = VAR_0->hw;
int VAR_3, VAR_4, VAR_5 = 0, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10 = 0;
st_sample_t *src, *dst = VAR_0->VAR_1;
VAR_9 = audio_pcm_sw_get_rpos_in (VAR_0) % hw->VAR_3;
VAR_4 = hw->total_samples_captured - VAR_0->total_hw_samples_acquired;
if (audio_bug (AUDIO_FUNC, VAR_4 < 0 || VAR_4 > hw->VAR_3)) {
dolog ("live_in=%d hw->VAR_3=%d\n", VAR_4, hw->VAR_3);
return 0;
}
VAR_3 = VAR_2 >> VAR_0->info.shift;
if (!VAR_4) {
return 0;
}
VAR_6 = (VAR_4 * VAR_0->ratio) >> 32;
VAR_6 = audio_MIN (VAR_6, VAR_3);
while (VAR_6) {
src = hw->conv_buf + VAR_9;
VAR_7 = hw->wpos - VAR_9;
if (VAR_7 <= 0) {
VAR_7 = hw->VAR_3 - VAR_9;
}
if (!VAR_7) {
break;
}
VAR_8 = VAR_6;
if (audio_bug (AUDIO_FUNC, VAR_8 < 0)) {
dolog ("VAR_8=%d\n", VAR_8);
return 0;
}
st_rate_flow (VAR_0->rate, src, dst, &VAR_7, &VAR_8);
VAR_6 -= VAR_8;
VAR_9 = (VAR_9 + VAR_7) % hw->VAR_3;
dst += VAR_8;
VAR_5 += VAR_8;
VAR_10 += VAR_7;
}
VAR_0->clip (VAR_1, VAR_0->VAR_1, VAR_5);
VAR_0->total_hw_samples_acquired += VAR_10;
return VAR_5 << VAR_0->info.shift;
}
| [
"int FUNC_0 (SWVoiceIn *VAR_0, void *VAR_1, int VAR_2)\n{",
"HWVoiceIn *hw = VAR_0->hw;",
"int VAR_3, VAR_4, VAR_5 = 0, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10 = 0;",
"st_sample_t *src, *dst = VAR_0->VAR_1;",
"VAR_9 = audio_pcm_sw_get_rpos_in (VAR_0) % hw->VAR_3;",
"VAR_4 = hw->total_samples_captured - VAR_0->total_hw_samples_acquired;",
"if (audio_bug (AUDIO_FUNC, VAR_4 < 0 || VAR_4 > hw->VAR_3)) {",
"dolog (\"live_in=%d hw->VAR_3=%d\\n\", VAR_4, hw->VAR_3);",
"return 0;",
"}",
"VAR_3 = VAR_2 >> VAR_0->info.shift;",
"if (!VAR_4) {",
"return 0;",
"}",
"VAR_6 = (VAR_4 * VAR_0->ratio) >> 32;",
"VAR_6 = audio_MIN (VAR_6, VAR_3);",
"while (VAR_6) {",
"src = hw->conv_buf + VAR_9;",
"VAR_7 = hw->wpos - VAR_9;",
"if (VAR_7 <= 0) {",
"VAR_7 = hw->VAR_3 - VAR_9;",
"}",
"if (!VAR_7) {",
"break;",
"}",
"VAR_8 = VAR_6;",
"if (audio_bug (AUDIO_FUNC, VAR_8 < 0)) {",
"dolog (\"VAR_8=%d\\n\", VAR_8);",
"return 0;",
"}",
"st_rate_flow (VAR_0->rate, src, dst, &VAR_7, &VAR_8);",
"VAR_6 -= VAR_8;",
"VAR_9 = (VAR_9 + VAR_7) % hw->VAR_3;",
"dst += VAR_8;",
"VAR_5 += VAR_8;",
"VAR_10 += VAR_7;",
"}",
"VAR_0->clip (VAR_1, VAR_0->VAR_1, VAR_5);",
"VAR_0->total_hw_samples_acquired += VAR_10;",
"return VAR_5 << VAR_0->info.shift;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
]
] |
20,824 | static void v9fs_wstat_post_chown(V9fsState *s, V9fsWstatState *vs, int err)
{
V9fsFidState *fidp;
if (err < 0) {
goto out;
}
if (vs->v9stat.name.size != 0) {
char *old_name, *new_name;
char *end;
old_name = vs->fidp->path.data;
end = strrchr(old_name, '/');
if (end) {
end++;
} else {
end = old_name;
}
new_name = qemu_mallocz(end - old_name + vs->v9stat.name.size + 1);
memcpy(new_name, old_name, end - old_name);
memcpy(new_name + (end - old_name), vs->v9stat.name.data,
vs->v9stat.name.size);
vs->nname.data = new_name;
vs->nname.size = strlen(new_name);
if (strcmp(new_name, vs->fidp->path.data) != 0) {
if (v9fs_do_rename(s, &vs->fidp->path, &vs->nname)) {
err = -errno;
} else {
/*
* Fixup fid's pointing to the old name to
* start pointing to the new name
*/
for (fidp = s->fid_list; fidp; fidp = fidp->next) {
if (vs->fidp == fidp) {
/*
* we replace name of this fid towards the end
* so that our below strcmp will work
*/
continue;
}
if (!strncmp(vs->fidp->path.data, fidp->path.data,
strlen(vs->fidp->path.data))) {
/* replace the name */
v9fs_fix_path(&fidp->path, &vs->nname,
strlen(vs->fidp->path.data));
}
}
v9fs_string_copy(&vs->fidp->path, &vs->nname);
}
}
}
v9fs_wstat_post_rename(s, vs, err);
return;
out:
v9fs_stat_free(&vs->v9stat);
complete_pdu(s, vs->pdu, err);
qemu_free(vs);
}
| false | qemu | c7b4b0b302709928b84582881a7b4fb6c1e39e2b | static void v9fs_wstat_post_chown(V9fsState *s, V9fsWstatState *vs, int err)
{
V9fsFidState *fidp;
if (err < 0) {
goto out;
}
if (vs->v9stat.name.size != 0) {
char *old_name, *new_name;
char *end;
old_name = vs->fidp->path.data;
end = strrchr(old_name, '/');
if (end) {
end++;
} else {
end = old_name;
}
new_name = qemu_mallocz(end - old_name + vs->v9stat.name.size + 1);
memcpy(new_name, old_name, end - old_name);
memcpy(new_name + (end - old_name), vs->v9stat.name.data,
vs->v9stat.name.size);
vs->nname.data = new_name;
vs->nname.size = strlen(new_name);
if (strcmp(new_name, vs->fidp->path.data) != 0) {
if (v9fs_do_rename(s, &vs->fidp->path, &vs->nname)) {
err = -errno;
} else {
for (fidp = s->fid_list; fidp; fidp = fidp->next) {
if (vs->fidp == fidp) {
continue;
}
if (!strncmp(vs->fidp->path.data, fidp->path.data,
strlen(vs->fidp->path.data))) {
v9fs_fix_path(&fidp->path, &vs->nname,
strlen(vs->fidp->path.data));
}
}
v9fs_string_copy(&vs->fidp->path, &vs->nname);
}
}
}
v9fs_wstat_post_rename(s, vs, err);
return;
out:
v9fs_stat_free(&vs->v9stat);
complete_pdu(s, vs->pdu, err);
qemu_free(vs);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(V9fsState *VAR_0, V9fsWstatState *VAR_1, int VAR_2)
{
V9fsFidState *fidp;
if (VAR_2 < 0) {
goto out;
}
if (VAR_1->v9stat.name.size != 0) {
char *VAR_3, *VAR_4;
char *VAR_5;
VAR_3 = VAR_1->fidp->path.data;
VAR_5 = strrchr(VAR_3, '/');
if (VAR_5) {
VAR_5++;
} else {
VAR_5 = VAR_3;
}
VAR_4 = qemu_mallocz(VAR_5 - VAR_3 + VAR_1->v9stat.name.size + 1);
memcpy(VAR_4, VAR_3, VAR_5 - VAR_3);
memcpy(VAR_4 + (VAR_5 - VAR_3), VAR_1->v9stat.name.data,
VAR_1->v9stat.name.size);
VAR_1->nname.data = VAR_4;
VAR_1->nname.size = strlen(VAR_4);
if (strcmp(VAR_4, VAR_1->fidp->path.data) != 0) {
if (v9fs_do_rename(VAR_0, &VAR_1->fidp->path, &VAR_1->nname)) {
VAR_2 = -errno;
} else {
for (fidp = VAR_0->fid_list; fidp; fidp = fidp->next) {
if (VAR_1->fidp == fidp) {
continue;
}
if (!strncmp(VAR_1->fidp->path.data, fidp->path.data,
strlen(VAR_1->fidp->path.data))) {
v9fs_fix_path(&fidp->path, &VAR_1->nname,
strlen(VAR_1->fidp->path.data));
}
}
v9fs_string_copy(&VAR_1->fidp->path, &VAR_1->nname);
}
}
}
v9fs_wstat_post_rename(VAR_0, VAR_1, VAR_2);
return;
out:
v9fs_stat_free(&VAR_1->v9stat);
complete_pdu(VAR_0, VAR_1->pdu, VAR_2);
qemu_free(VAR_1);
}
| [
"static void FUNC_0(V9fsState *VAR_0, V9fsWstatState *VAR_1, int VAR_2)\n{",
"V9fsFidState *fidp;",
"if (VAR_2 < 0) {",
"goto out;",
"}",
"if (VAR_1->v9stat.name.size != 0) {",
"char *VAR_3, *VAR_4;",
"char *VAR_5;",
"VAR_3 = VAR_1->fidp->path.data;",
"VAR_5 = strrchr(VAR_3, '/');",
"if (VAR_5) {",
"VAR_5++;",
"} else {",
"VAR_5 = VAR_3;",
"}",
"VAR_4 = qemu_mallocz(VAR_5 - VAR_3 + VAR_1->v9stat.name.size + 1);",
"memcpy(VAR_4, VAR_3, VAR_5 - VAR_3);",
"memcpy(VAR_4 + (VAR_5 - VAR_3), VAR_1->v9stat.name.data,\nVAR_1->v9stat.name.size);",
"VAR_1->nname.data = VAR_4;",
"VAR_1->nname.size = strlen(VAR_4);",
"if (strcmp(VAR_4, VAR_1->fidp->path.data) != 0) {",
"if (v9fs_do_rename(VAR_0, &VAR_1->fidp->path, &VAR_1->nname)) {",
"VAR_2 = -errno;",
"} else {",
"for (fidp = VAR_0->fid_list; fidp; fidp = fidp->next) {",
"if (VAR_1->fidp == fidp) {",
"continue;",
"}",
"if (!strncmp(VAR_1->fidp->path.data, fidp->path.data,\nstrlen(VAR_1->fidp->path.data))) {",
"v9fs_fix_path(&fidp->path, &VAR_1->nname,\nstrlen(VAR_1->fidp->path.data));",
"}",
"}",
"v9fs_string_copy(&VAR_1->fidp->path, &VAR_1->nname);",
"}",
"}",
"}",
"v9fs_wstat_post_rename(VAR_0, VAR_1, VAR_2);",
"return;",
"out:\nv9fs_stat_free(&VAR_1->v9stat);",
"complete_pdu(VAR_0, VAR_1->pdu, VAR_2);",
"qemu_free(VAR_1);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
71
],
[
75
],
[
85
],
[
87
],
[
89,
91
],
[
95,
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117,
119
],
[
121
],
[
123
],
[
125
]
] |
20,825 | static int mpeg4video_probe(AVProbeData *probe_packet)
{
uint32_t temp_buffer= -1;
int VO=0, VOL=0, VOP = 0, VISO = 0, res=0;
int i;
for(i=0; i<probe_packet->buf_size; i++){
temp_buffer = (temp_buffer<<8) + probe_packet->buf[i];
if ((temp_buffer & 0xffffff00) != 0x100)
continue;
if (temp_buffer == VOP_START_CODE) VOP++;
else if (temp_buffer == VISUAL_OBJECT_START_CODE) VISO++;
else if (temp_buffer < 0x120) VO++;
else if (temp_buffer < 0x130) VOL++;
else if ( !(0x1AF < temp_buffer && temp_buffer < 0x1B7)
&& !(0x1B9 < temp_buffer && temp_buffer < 0x1C4)) res++;
}
if (VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0 && res==0)
return VOP+VO > 4 ? AVPROBE_SCORE_EXTENSION : AVPROBE_SCORE_EXTENSION/2;
return 0;
}
| false | FFmpeg | 7c1835c52a4be2e4e996f83c91a8d5a147b01100 | static int mpeg4video_probe(AVProbeData *probe_packet)
{
uint32_t temp_buffer= -1;
int VO=0, VOL=0, VOP = 0, VISO = 0, res=0;
int i;
for(i=0; i<probe_packet->buf_size; i++){
temp_buffer = (temp_buffer<<8) + probe_packet->buf[i];
if ((temp_buffer & 0xffffff00) != 0x100)
continue;
if (temp_buffer == VOP_START_CODE) VOP++;
else if (temp_buffer == VISUAL_OBJECT_START_CODE) VISO++;
else if (temp_buffer < 0x120) VO++;
else if (temp_buffer < 0x130) VOL++;
else if ( !(0x1AF < temp_buffer && temp_buffer < 0x1B7)
&& !(0x1B9 < temp_buffer && temp_buffer < 0x1C4)) res++;
}
if (VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0 && res==0)
return VOP+VO > 4 ? AVPROBE_SCORE_EXTENSION : AVPROBE_SCORE_EXTENSION/2;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVProbeData *VAR_0)
{
uint32_t temp_buffer= -1;
int VAR_1=0, VAR_2=0, VAR_3 = 0, VAR_4 = 0, VAR_5=0;
int VAR_6;
for(VAR_6=0; VAR_6<VAR_0->buf_size; VAR_6++){
temp_buffer = (temp_buffer<<8) + VAR_0->buf[VAR_6];
if ((temp_buffer & 0xffffff00) != 0x100)
continue;
if (temp_buffer == VOP_START_CODE) VAR_3++;
else if (temp_buffer == VISUAL_OBJECT_START_CODE) VAR_4++;
else if (temp_buffer < 0x120) VAR_1++;
else if (temp_buffer < 0x130) VAR_2++;
else if ( !(0x1AF < temp_buffer && temp_buffer < 0x1B7)
&& !(0x1B9 < temp_buffer && temp_buffer < 0x1C4)) VAR_5++;
}
if (VAR_3 >= VAR_4 && VAR_3 >= VAR_2 && VAR_1 >= VAR_2 && VAR_2 > 0 && VAR_5==0)
return VAR_3+VAR_1 > 4 ? AVPROBE_SCORE_EXTENSION : AVPROBE_SCORE_EXTENSION/2;
return 0;
}
| [
"static int FUNC_0(AVProbeData *VAR_0)\n{",
"uint32_t temp_buffer= -1;",
"int VAR_1=0, VAR_2=0, VAR_3 = 0, VAR_4 = 0, VAR_5=0;",
"int VAR_6;",
"for(VAR_6=0; VAR_6<VAR_0->buf_size; VAR_6++){",
"temp_buffer = (temp_buffer<<8) + VAR_0->buf[VAR_6];",
"if ((temp_buffer & 0xffffff00) != 0x100)\ncontinue;",
"if (temp_buffer == VOP_START_CODE) VAR_3++;",
"else if (temp_buffer == VISUAL_OBJECT_START_CODE) VAR_4++;",
"else if (temp_buffer < 0x120) VAR_1++;",
"else if (temp_buffer < 0x130) VAR_2++;",
"else if ( !(0x1AF < temp_buffer && temp_buffer < 0x1B7)\n&& !(0x1B9 < temp_buffer && temp_buffer < 0x1C4)) VAR_5++;",
"}",
"if (VAR_3 >= VAR_4 && VAR_3 >= VAR_2 && VAR_1 >= VAR_2 && VAR_2 > 0 && VAR_5==0)\nreturn VAR_3+VAR_1 > 4 ? AVPROBE_SCORE_EXTENSION : AVPROBE_SCORE_EXTENSION/2;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17,
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
39,
41
],
[
43
],
[
45
]
] |
20,827 | static BlockDriverAIOCB *raw_aio_writev(BlockDriverState *bs,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque)
{
BDRVRawState *s = bs->opaque;
return paio_submit(bs, s->hfile, sector_num, qiov, nb_sectors,
cb, opaque, QEMU_AIO_WRITE);
}
| false | qemu | a27365265cc2fed1178bf25a205e8ee02a9c0caf | static BlockDriverAIOCB *raw_aio_writev(BlockDriverState *bs,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque)
{
BDRVRawState *s = bs->opaque;
return paio_submit(bs, s->hfile, sector_num, qiov, nb_sectors,
cb, opaque, QEMU_AIO_WRITE);
}
| {
"code": [],
"line_no": []
} | static BlockDriverAIOCB *FUNC_0(BlockDriverState *bs,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque)
{
BDRVRawState *s = bs->opaque;
return paio_submit(bs, s->hfile, sector_num, qiov, nb_sectors,
cb, opaque, QEMU_AIO_WRITE);
}
| [
"static BlockDriverAIOCB *FUNC_0(BlockDriverState *bs,\nint64_t sector_num, QEMUIOVector *qiov, int nb_sectors,\nBlockDriverCompletionFunc *cb, void *opaque)\n{",
"BDRVRawState *s = bs->opaque;",
"return paio_submit(bs, s->hfile, sector_num, qiov, nb_sectors,\ncb, opaque, QEMU_AIO_WRITE);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11,
13
],
[
15
]
] |
20,828 | static int usb_serial_handle_control(USBDevice *dev, int request, int value,
int index, int length, uint8_t *data)
{
USBSerialState *s = (USBSerialState *)dev;
int ret;
DPRINTF("got control %x, value %x\n",request, value);
ret = usb_desc_handle_control(dev, request, value, index, length, data);
if (ret >= 0) {
return ret;
}
ret = 0;
switch (request) {
case DeviceRequest | USB_REQ_GET_STATUS:
data[0] = (0 << USB_DEVICE_SELF_POWERED) |
(dev->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP);
data[1] = 0x00;
ret = 2;
break;
case DeviceOutRequest | USB_REQ_CLEAR_FEATURE:
if (value == USB_DEVICE_REMOTE_WAKEUP) {
dev->remote_wakeup = 0;
} else {
goto fail;
}
ret = 0;
break;
case DeviceOutRequest | USB_REQ_SET_FEATURE:
if (value == USB_DEVICE_REMOTE_WAKEUP) {
dev->remote_wakeup = 1;
} else {
goto fail;
}
ret = 0;
break;
case DeviceRequest | USB_REQ_GET_CONFIGURATION:
data[0] = 1;
ret = 1;
break;
case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
ret = 0;
break;
case DeviceRequest | USB_REQ_GET_INTERFACE:
data[0] = 0;
ret = 1;
break;
case InterfaceOutRequest | USB_REQ_SET_INTERFACE:
ret = 0;
break;
case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:
ret = 0;
break;
/* Class specific requests. */
case DeviceOutVendor | FTDI_RESET:
switch (value) {
case FTDI_RESET_SIO:
usb_serial_reset(s);
break;
case FTDI_RESET_RX:
s->recv_ptr = 0;
s->recv_used = 0;
/* TODO: purge from char device */
break;
case FTDI_RESET_TX:
/* TODO: purge from char device */
break;
}
break;
case DeviceOutVendor | FTDI_SET_MDM_CTRL:
{
static int flags;
qemu_chr_ioctl(s->cs,CHR_IOCTL_SERIAL_GET_TIOCM, &flags);
if (value & FTDI_SET_RTS) {
if (value & FTDI_RTS)
flags |= CHR_TIOCM_RTS;
else
flags &= ~CHR_TIOCM_RTS;
}
if (value & FTDI_SET_DTR) {
if (value & FTDI_DTR)
flags |= CHR_TIOCM_DTR;
else
flags &= ~CHR_TIOCM_DTR;
}
qemu_chr_ioctl(s->cs,CHR_IOCTL_SERIAL_SET_TIOCM, &flags);
break;
}
case DeviceOutVendor | FTDI_SET_FLOW_CTRL:
/* TODO: ioctl */
break;
case DeviceOutVendor | FTDI_SET_BAUD: {
static const int subdivisors8[8] = { 0, 4, 2, 1, 3, 5, 6, 7 };
int subdivisor8 = subdivisors8[((value & 0xc000) >> 14)
| ((index & 1) << 2)];
int divisor = value & 0x3fff;
/* chip special cases */
if (divisor == 1 && subdivisor8 == 0)
subdivisor8 = 4;
if (divisor == 0 && subdivisor8 == 0)
divisor = 1;
s->params.speed = (48000000 / 2) / (8 * divisor + subdivisor8);
qemu_chr_ioctl(s->cs, CHR_IOCTL_SERIAL_SET_PARAMS, &s->params);
break;
}
case DeviceOutVendor | FTDI_SET_DATA:
switch (value & FTDI_PARITY) {
case 0:
s->params.parity = 'N';
break;
case FTDI_ODD:
s->params.parity = 'O';
break;
case FTDI_EVEN:
s->params.parity = 'E';
break;
default:
DPRINTF("unsupported parity %d\n", value & FTDI_PARITY);
goto fail;
}
switch (value & FTDI_STOP) {
case FTDI_STOP1:
s->params.stop_bits = 1;
break;
case FTDI_STOP2:
s->params.stop_bits = 2;
break;
default:
DPRINTF("unsupported stop bits %d\n", value & FTDI_STOP);
goto fail;
}
qemu_chr_ioctl(s->cs, CHR_IOCTL_SERIAL_SET_PARAMS, &s->params);
/* TODO: TX ON/OFF */
break;
case DeviceInVendor | FTDI_GET_MDM_ST:
data[0] = usb_get_modem_lines(s) | 1;
data[1] = 0;
ret = 2;
break;
case DeviceOutVendor | FTDI_SET_EVENT_CHR:
/* TODO: handle it */
s->event_chr = value;
break;
case DeviceOutVendor | FTDI_SET_ERROR_CHR:
/* TODO: handle it */
s->error_chr = value;
break;
case DeviceOutVendor | FTDI_SET_LATENCY:
s->latency = value;
break;
case DeviceInVendor | FTDI_GET_LATENCY:
data[0] = s->latency;
ret = 1;
break;
default:
fail:
DPRINTF("got unsupported/bogus control %x, value %x\n", request, value);
ret = USB_RET_STALL;
break;
}
return ret;
}
| false | qemu | a980a065fb5e86d6dec337e6cb6ff432f1a143c9 | static int usb_serial_handle_control(USBDevice *dev, int request, int value,
int index, int length, uint8_t *data)
{
USBSerialState *s = (USBSerialState *)dev;
int ret;
DPRINTF("got control %x, value %x\n",request, value);
ret = usb_desc_handle_control(dev, request, value, index, length, data);
if (ret >= 0) {
return ret;
}
ret = 0;
switch (request) {
case DeviceRequest | USB_REQ_GET_STATUS:
data[0] = (0 << USB_DEVICE_SELF_POWERED) |
(dev->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP);
data[1] = 0x00;
ret = 2;
break;
case DeviceOutRequest | USB_REQ_CLEAR_FEATURE:
if (value == USB_DEVICE_REMOTE_WAKEUP) {
dev->remote_wakeup = 0;
} else {
goto fail;
}
ret = 0;
break;
case DeviceOutRequest | USB_REQ_SET_FEATURE:
if (value == USB_DEVICE_REMOTE_WAKEUP) {
dev->remote_wakeup = 1;
} else {
goto fail;
}
ret = 0;
break;
case DeviceRequest | USB_REQ_GET_CONFIGURATION:
data[0] = 1;
ret = 1;
break;
case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
ret = 0;
break;
case DeviceRequest | USB_REQ_GET_INTERFACE:
data[0] = 0;
ret = 1;
break;
case InterfaceOutRequest | USB_REQ_SET_INTERFACE:
ret = 0;
break;
case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:
ret = 0;
break;
case DeviceOutVendor | FTDI_RESET:
switch (value) {
case FTDI_RESET_SIO:
usb_serial_reset(s);
break;
case FTDI_RESET_RX:
s->recv_ptr = 0;
s->recv_used = 0;
break;
case FTDI_RESET_TX:
break;
}
break;
case DeviceOutVendor | FTDI_SET_MDM_CTRL:
{
static int flags;
qemu_chr_ioctl(s->cs,CHR_IOCTL_SERIAL_GET_TIOCM, &flags);
if (value & FTDI_SET_RTS) {
if (value & FTDI_RTS)
flags |= CHR_TIOCM_RTS;
else
flags &= ~CHR_TIOCM_RTS;
}
if (value & FTDI_SET_DTR) {
if (value & FTDI_DTR)
flags |= CHR_TIOCM_DTR;
else
flags &= ~CHR_TIOCM_DTR;
}
qemu_chr_ioctl(s->cs,CHR_IOCTL_SERIAL_SET_TIOCM, &flags);
break;
}
case DeviceOutVendor | FTDI_SET_FLOW_CTRL:
break;
case DeviceOutVendor | FTDI_SET_BAUD: {
static const int subdivisors8[8] = { 0, 4, 2, 1, 3, 5, 6, 7 };
int subdivisor8 = subdivisors8[((value & 0xc000) >> 14)
| ((index & 1) << 2)];
int divisor = value & 0x3fff;
if (divisor == 1 && subdivisor8 == 0)
subdivisor8 = 4;
if (divisor == 0 && subdivisor8 == 0)
divisor = 1;
s->params.speed = (48000000 / 2) / (8 * divisor + subdivisor8);
qemu_chr_ioctl(s->cs, CHR_IOCTL_SERIAL_SET_PARAMS, &s->params);
break;
}
case DeviceOutVendor | FTDI_SET_DATA:
switch (value & FTDI_PARITY) {
case 0:
s->params.parity = 'N';
break;
case FTDI_ODD:
s->params.parity = 'O';
break;
case FTDI_EVEN:
s->params.parity = 'E';
break;
default:
DPRINTF("unsupported parity %d\n", value & FTDI_PARITY);
goto fail;
}
switch (value & FTDI_STOP) {
case FTDI_STOP1:
s->params.stop_bits = 1;
break;
case FTDI_STOP2:
s->params.stop_bits = 2;
break;
default:
DPRINTF("unsupported stop bits %d\n", value & FTDI_STOP);
goto fail;
}
qemu_chr_ioctl(s->cs, CHR_IOCTL_SERIAL_SET_PARAMS, &s->params);
break;
case DeviceInVendor | FTDI_GET_MDM_ST:
data[0] = usb_get_modem_lines(s) | 1;
data[1] = 0;
ret = 2;
break;
case DeviceOutVendor | FTDI_SET_EVENT_CHR:
s->event_chr = value;
break;
case DeviceOutVendor | FTDI_SET_ERROR_CHR:
s->error_chr = value;
break;
case DeviceOutVendor | FTDI_SET_LATENCY:
s->latency = value;
break;
case DeviceInVendor | FTDI_GET_LATENCY:
data[0] = s->latency;
ret = 1;
break;
default:
fail:
DPRINTF("got unsupported/bogus control %x, value %x\n", request, value);
ret = USB_RET_STALL;
break;
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(USBDevice *VAR_0, int VAR_1, int VAR_2,
int VAR_3, int VAR_4, uint8_t *VAR_5)
{
USBSerialState *s = (USBSerialState *)VAR_0;
int VAR_6;
DPRINTF("got control %x, VAR_2 %x\n",VAR_1, VAR_2);
VAR_6 = usb_desc_handle_control(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);
if (VAR_6 >= 0) {
return VAR_6;
}
VAR_6 = 0;
switch (VAR_1) {
case DeviceRequest | USB_REQ_GET_STATUS:
VAR_5[0] = (0 << USB_DEVICE_SELF_POWERED) |
(VAR_0->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP);
VAR_5[1] = 0x00;
VAR_6 = 2;
break;
case DeviceOutRequest | USB_REQ_CLEAR_FEATURE:
if (VAR_2 == USB_DEVICE_REMOTE_WAKEUP) {
VAR_0->remote_wakeup = 0;
} else {
goto fail;
}
VAR_6 = 0;
break;
case DeviceOutRequest | USB_REQ_SET_FEATURE:
if (VAR_2 == USB_DEVICE_REMOTE_WAKEUP) {
VAR_0->remote_wakeup = 1;
} else {
goto fail;
}
VAR_6 = 0;
break;
case DeviceRequest | USB_REQ_GET_CONFIGURATION:
VAR_5[0] = 1;
VAR_6 = 1;
break;
case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
VAR_6 = 0;
break;
case DeviceRequest | USB_REQ_GET_INTERFACE:
VAR_5[0] = 0;
VAR_6 = 1;
break;
case InterfaceOutRequest | USB_REQ_SET_INTERFACE:
VAR_6 = 0;
break;
case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:
VAR_6 = 0;
break;
case DeviceOutVendor | FTDI_RESET:
switch (VAR_2) {
case FTDI_RESET_SIO:
usb_serial_reset(s);
break;
case FTDI_RESET_RX:
s->recv_ptr = 0;
s->recv_used = 0;
break;
case FTDI_RESET_TX:
break;
}
break;
case DeviceOutVendor | FTDI_SET_MDM_CTRL:
{
static int VAR_7;
qemu_chr_ioctl(s->cs,CHR_IOCTL_SERIAL_GET_TIOCM, &VAR_7);
if (VAR_2 & FTDI_SET_RTS) {
if (VAR_2 & FTDI_RTS)
VAR_7 |= CHR_TIOCM_RTS;
else
VAR_7 &= ~CHR_TIOCM_RTS;
}
if (VAR_2 & FTDI_SET_DTR) {
if (VAR_2 & FTDI_DTR)
VAR_7 |= CHR_TIOCM_DTR;
else
VAR_7 &= ~CHR_TIOCM_DTR;
}
qemu_chr_ioctl(s->cs,CHR_IOCTL_SERIAL_SET_TIOCM, &VAR_7);
break;
}
case DeviceOutVendor | FTDI_SET_FLOW_CTRL:
break;
case DeviceOutVendor | FTDI_SET_BAUD: {
static const int VAR_8[8] = { 0, 4, 2, 1, 3, 5, 6, 7 };
int VAR_9 = VAR_8[((VAR_2 & 0xc000) >> 14)
| ((VAR_3 & 1) << 2)];
int VAR_10 = VAR_2 & 0x3fff;
if (VAR_10 == 1 && VAR_9 == 0)
VAR_9 = 4;
if (VAR_10 == 0 && VAR_9 == 0)
VAR_10 = 1;
s->params.speed = (48000000 / 2) / (8 * VAR_10 + VAR_9);
qemu_chr_ioctl(s->cs, CHR_IOCTL_SERIAL_SET_PARAMS, &s->params);
break;
}
case DeviceOutVendor | FTDI_SET_DATA:
switch (VAR_2 & FTDI_PARITY) {
case 0:
s->params.parity = 'N';
break;
case FTDI_ODD:
s->params.parity = 'O';
break;
case FTDI_EVEN:
s->params.parity = 'E';
break;
default:
DPRINTF("unsupported parity %d\n", VAR_2 & FTDI_PARITY);
goto fail;
}
switch (VAR_2 & FTDI_STOP) {
case FTDI_STOP1:
s->params.stop_bits = 1;
break;
case FTDI_STOP2:
s->params.stop_bits = 2;
break;
default:
DPRINTF("unsupported stop bits %d\n", VAR_2 & FTDI_STOP);
goto fail;
}
qemu_chr_ioctl(s->cs, CHR_IOCTL_SERIAL_SET_PARAMS, &s->params);
break;
case DeviceInVendor | FTDI_GET_MDM_ST:
VAR_5[0] = usb_get_modem_lines(s) | 1;
VAR_5[1] = 0;
VAR_6 = 2;
break;
case DeviceOutVendor | FTDI_SET_EVENT_CHR:
s->event_chr = VAR_2;
break;
case DeviceOutVendor | FTDI_SET_ERROR_CHR:
s->error_chr = VAR_2;
break;
case DeviceOutVendor | FTDI_SET_LATENCY:
s->latency = VAR_2;
break;
case DeviceInVendor | FTDI_GET_LATENCY:
VAR_5[0] = s->latency;
VAR_6 = 1;
break;
default:
fail:
DPRINTF("got unsupported/bogus control %x, VAR_2 %x\n", VAR_1, VAR_2);
VAR_6 = USB_RET_STALL;
break;
}
return VAR_6;
}
| [
"static int FUNC_0(USBDevice *VAR_0, int VAR_1, int VAR_2,\nint VAR_3, int VAR_4, uint8_t *VAR_5)\n{",
"USBSerialState *s = (USBSerialState *)VAR_0;",
"int VAR_6;",
"DPRINTF(\"got control %x, VAR_2 %x\\n\",VAR_1, VAR_2);",
"VAR_6 = usb_desc_handle_control(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);",
"if (VAR_6 >= 0) {",
"return VAR_6;",
"}",
"VAR_6 = 0;",
"switch (VAR_1) {",
"case DeviceRequest | USB_REQ_GET_STATUS:\nVAR_5[0] = (0 << USB_DEVICE_SELF_POWERED) |\n(VAR_0->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP);",
"VAR_5[1] = 0x00;",
"VAR_6 = 2;",
"break;",
"case DeviceOutRequest | USB_REQ_CLEAR_FEATURE:\nif (VAR_2 == USB_DEVICE_REMOTE_WAKEUP) {",
"VAR_0->remote_wakeup = 0;",
"} else {",
"goto fail;",
"}",
"VAR_6 = 0;",
"break;",
"case DeviceOutRequest | USB_REQ_SET_FEATURE:\nif (VAR_2 == USB_DEVICE_REMOTE_WAKEUP) {",
"VAR_0->remote_wakeup = 1;",
"} else {",
"goto fail;",
"}",
"VAR_6 = 0;",
"break;",
"case DeviceRequest | USB_REQ_GET_CONFIGURATION:\nVAR_5[0] = 1;",
"VAR_6 = 1;",
"break;",
"case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:\nVAR_6 = 0;",
"break;",
"case DeviceRequest | USB_REQ_GET_INTERFACE:\nVAR_5[0] = 0;",
"VAR_6 = 1;",
"break;",
"case InterfaceOutRequest | USB_REQ_SET_INTERFACE:\nVAR_6 = 0;",
"break;",
"case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:\nVAR_6 = 0;",
"break;",
"case DeviceOutVendor | FTDI_RESET:\nswitch (VAR_2) {",
"case FTDI_RESET_SIO:\nusb_serial_reset(s);",
"break;",
"case FTDI_RESET_RX:\ns->recv_ptr = 0;",
"s->recv_used = 0;",
"break;",
"case FTDI_RESET_TX:\nbreak;",
"}",
"break;",
"case DeviceOutVendor | FTDI_SET_MDM_CTRL:\n{",
"static int VAR_7;",
"qemu_chr_ioctl(s->cs,CHR_IOCTL_SERIAL_GET_TIOCM, &VAR_7);",
"if (VAR_2 & FTDI_SET_RTS) {",
"if (VAR_2 & FTDI_RTS)\nVAR_7 |= CHR_TIOCM_RTS;",
"else\nVAR_7 &= ~CHR_TIOCM_RTS;",
"}",
"if (VAR_2 & FTDI_SET_DTR) {",
"if (VAR_2 & FTDI_DTR)\nVAR_7 |= CHR_TIOCM_DTR;",
"else\nVAR_7 &= ~CHR_TIOCM_DTR;",
"}",
"qemu_chr_ioctl(s->cs,CHR_IOCTL_SERIAL_SET_TIOCM, &VAR_7);",
"break;",
"}",
"case DeviceOutVendor | FTDI_SET_FLOW_CTRL:\nbreak;",
"case DeviceOutVendor | FTDI_SET_BAUD: {",
"static const int VAR_8[8] = { 0, 4, 2, 1, 3, 5, 6, 7 };",
"int VAR_9 = VAR_8[((VAR_2 & 0xc000) >> 14)\n| ((VAR_3 & 1) << 2)];",
"int VAR_10 = VAR_2 & 0x3fff;",
"if (VAR_10 == 1 && VAR_9 == 0)\nVAR_9 = 4;",
"if (VAR_10 == 0 && VAR_9 == 0)\nVAR_10 = 1;",
"s->params.speed = (48000000 / 2) / (8 * VAR_10 + VAR_9);",
"qemu_chr_ioctl(s->cs, CHR_IOCTL_SERIAL_SET_PARAMS, &s->params);",
"break;",
"}",
"case DeviceOutVendor | FTDI_SET_DATA:\nswitch (VAR_2 & FTDI_PARITY) {",
"case 0:\ns->params.parity = 'N';",
"break;",
"case FTDI_ODD:\ns->params.parity = 'O';",
"break;",
"case FTDI_EVEN:\ns->params.parity = 'E';",
"break;",
"default:\nDPRINTF(\"unsupported parity %d\\n\", VAR_2 & FTDI_PARITY);",
"goto fail;",
"}",
"switch (VAR_2 & FTDI_STOP) {",
"case FTDI_STOP1:\ns->params.stop_bits = 1;",
"break;",
"case FTDI_STOP2:\ns->params.stop_bits = 2;",
"break;",
"default:\nDPRINTF(\"unsupported stop bits %d\\n\", VAR_2 & FTDI_STOP);",
"goto fail;",
"}",
"qemu_chr_ioctl(s->cs, CHR_IOCTL_SERIAL_SET_PARAMS, &s->params);",
"break;",
"case DeviceInVendor | FTDI_GET_MDM_ST:\nVAR_5[0] = usb_get_modem_lines(s) | 1;",
"VAR_5[1] = 0;",
"VAR_6 = 2;",
"break;",
"case DeviceOutVendor | FTDI_SET_EVENT_CHR:\ns->event_chr = VAR_2;",
"break;",
"case DeviceOutVendor | FTDI_SET_ERROR_CHR:\ns->error_chr = VAR_2;",
"break;",
"case DeviceOutVendor | FTDI_SET_LATENCY:\ns->latency = VAR_2;",
"break;",
"case DeviceInVendor | FTDI_GET_LATENCY:\nVAR_5[0] = s->latency;",
"VAR_6 = 1;",
"break;",
"default:\nfail:\nDPRINTF(\"got unsupported/bogus control %x, VAR_2 %x\\n\", VAR_1, VAR_2);",
"VAR_6 = USB_RET_STALL;",
"break;",
"}",
"return VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29,
31,
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81,
83
],
[
85
],
[
87,
89
],
[
91
],
[
93
],
[
95,
97
],
[
99
],
[
101,
103
],
[
105
],
[
111,
113
],
[
115,
117
],
[
119
],
[
121,
123
],
[
125
],
[
129
],
[
131,
135
],
[
137
],
[
139
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
151,
153
],
[
155,
157
],
[
159
],
[
161
],
[
163,
165
],
[
167,
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179,
183
],
[
185
],
[
187
],
[
189,
191
],
[
193
],
[
199,
201
],
[
203,
205
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217,
219
],
[
221,
223
],
[
225
],
[
227,
229
],
[
231
],
[
233,
235
],
[
237
],
[
239,
241
],
[
243
],
[
245
],
[
247
],
[
249,
251
],
[
253
],
[
255,
257
],
[
259
],
[
261,
263
],
[
265
],
[
267
],
[
269
],
[
273
],
[
275,
277
],
[
279
],
[
281
],
[
283
],
[
285,
289
],
[
291
],
[
293,
297
],
[
299
],
[
301,
303
],
[
305
],
[
307,
309
],
[
311
],
[
313
],
[
315,
317,
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
]
] |
20,829 | static void test_acpi_piix4_tcg_cphp(void)
{
test_data data;
memset(&data, 0, sizeof(data));
data.machine = MACHINE_PC;
data.variant = ".cphp";
test_acpi_one("-smp 2,cores=3,sockets=2,maxcpus=6"
" -numa node -numa node",
&data);
free_test_data(&data);
}
| false | qemu | fda4096fca83dcdc72e0fc0e4a1ae6e7724fb5e0 | static void test_acpi_piix4_tcg_cphp(void)
{
test_data data;
memset(&data, 0, sizeof(data));
data.machine = MACHINE_PC;
data.variant = ".cphp";
test_acpi_one("-smp 2,cores=3,sockets=2,maxcpus=6"
" -numa node -numa node",
&data);
free_test_data(&data);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
test_data data;
memset(&data, 0, sizeof(data));
data.machine = MACHINE_PC;
data.variant = ".cphp";
test_acpi_one("-smp 2,cores=3,sockets=2,maxcpus=6"
" -numa node -numa node",
&data);
free_test_data(&data);
}
| [
"static void FUNC_0(void)\n{",
"test_data data;",
"memset(&data, 0, sizeof(data));",
"data.machine = MACHINE_PC;",
"data.variant = \".cphp\";",
"test_acpi_one(\"-smp 2,cores=3,sockets=2,maxcpus=6\"\n\" -numa node -numa node\",\n&data);",
"free_test_data(&data);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15,
17,
19
],
[
21
],
[
23
]
] |
20,830 | static void ide_dev_set_bootindex(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
IDEDevice *d = IDE_DEVICE(obj);
int32_t boot_index;
Error *local_err = NULL;
visit_type_int32(v, name, &boot_index, &local_err);
if (local_err) {
goto out;
}
/* check whether bootindex is present in fw_boot_order list */
check_boot_index(boot_index, &local_err);
if (local_err) {
goto out;
}
/* change bootindex to a new one */
d->conf.bootindex = boot_index;
if (d->unit != -1) {
add_boot_device_path(d->conf.bootindex, &d->qdev,
d->unit ? "/disk@1" : "/disk@0");
}
out:
if (local_err) {
error_propagate(errp, local_err);
}
}
| false | qemu | 621ff94d5074d88253a5818c6b9c4db718fbfc65 | static void ide_dev_set_bootindex(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
IDEDevice *d = IDE_DEVICE(obj);
int32_t boot_index;
Error *local_err = NULL;
visit_type_int32(v, name, &boot_index, &local_err);
if (local_err) {
goto out;
}
check_boot_index(boot_index, &local_err);
if (local_err) {
goto out;
}
d->conf.bootindex = boot_index;
if (d->unit != -1) {
add_boot_device_path(d->conf.bootindex, &d->qdev,
d->unit ? "/disk@1" : "/disk@0");
}
out:
if (local_err) {
error_propagate(errp, local_err);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Object *VAR_0, Visitor *VAR_1, const char *VAR_2,
void *VAR_3, Error **VAR_4)
{
IDEDevice *d = IDE_DEVICE(VAR_0);
int32_t boot_index;
Error *local_err = NULL;
visit_type_int32(VAR_1, VAR_2, &boot_index, &local_err);
if (local_err) {
goto out;
}
check_boot_index(boot_index, &local_err);
if (local_err) {
goto out;
}
d->conf.bootindex = boot_index;
if (d->unit != -1) {
add_boot_device_path(d->conf.bootindex, &d->qdev,
d->unit ? "/disk@1" : "/disk@0");
}
out:
if (local_err) {
error_propagate(VAR_4, local_err);
}
}
| [
"static void FUNC_0(Object *VAR_0, Visitor *VAR_1, const char *VAR_2,\nvoid *VAR_3, Error **VAR_4)\n{",
"IDEDevice *d = IDE_DEVICE(VAR_0);",
"int32_t boot_index;",
"Error *local_err = NULL;",
"visit_type_int32(VAR_1, VAR_2, &boot_index, &local_err);",
"if (local_err) {",
"goto out;",
"}",
"check_boot_index(boot_index, &local_err);",
"if (local_err) {",
"goto out;",
"}",
"d->conf.bootindex = boot_index;",
"if (d->unit != -1) {",
"add_boot_device_path(d->conf.bootindex, &d->qdev,\nd->unit ? \"/disk@1\" : \"/disk@0\");",
"}",
"out:\nif (local_err) {",
"error_propagate(VAR_4, local_err);",
"}",
"}"
] | [
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
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
39
],
[
41,
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
]
] |
20,832 | static void virtser_port_device_realize(DeviceState *dev, Error **errp)
{
VirtIOSerialPort *port = VIRTIO_SERIAL_PORT(dev);
VirtIOSerialPortClass *vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port);
VirtIOSerialBus *bus = VIRTIO_SERIAL_BUS(qdev_get_parent_bus(dev));
int max_nr_ports;
bool plugging_port0;
Error *err = NULL;
port->vser = bus->vser;
port->bh = qemu_bh_new(flush_queued_data_bh, port);
assert(vsc->have_data);
/*
* Is the first console port we're seeing? If so, put it up at
* location 0. This is done for backward compatibility (old
* kernel, new qemu).
*/
plugging_port0 = vsc->is_console && !find_port_by_id(port->vser, 0);
if (find_port_by_id(port->vser, port->id)) {
error_setg(errp, "virtio-serial-bus: A port already exists at id %u",
port->id);
return;
}
if (port->name != NULL && find_port_by_name(port->name)) {
error_setg(errp, "virtio-serial-bus: A port already exists by name %s",
port->name);
return;
}
if (port->id == VIRTIO_CONSOLE_BAD_ID) {
if (plugging_port0) {
port->id = 0;
} else {
port->id = find_free_port_id(port->vser);
if (port->id == VIRTIO_CONSOLE_BAD_ID) {
error_setg(errp, "virtio-serial-bus: Maximum port limit for "
"this device reached");
return;
}
}
}
max_nr_ports = port->vser->serial.max_virtserial_ports;
if (port->id >= max_nr_ports) {
error_setg(errp, "virtio-serial-bus: Out-of-range port id specified, "
"max. allowed: %u", max_nr_ports - 1);
return;
}
vsc->realize(dev, &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
port->elem.out_num = 0;
}
| false | qemu | 51b19ebe4320f3dcd93cea71235c1219318ddfd2 | static void virtser_port_device_realize(DeviceState *dev, Error **errp)
{
VirtIOSerialPort *port = VIRTIO_SERIAL_PORT(dev);
VirtIOSerialPortClass *vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port);
VirtIOSerialBus *bus = VIRTIO_SERIAL_BUS(qdev_get_parent_bus(dev));
int max_nr_ports;
bool plugging_port0;
Error *err = NULL;
port->vser = bus->vser;
port->bh = qemu_bh_new(flush_queued_data_bh, port);
assert(vsc->have_data);
plugging_port0 = vsc->is_console && !find_port_by_id(port->vser, 0);
if (find_port_by_id(port->vser, port->id)) {
error_setg(errp, "virtio-serial-bus: A port already exists at id %u",
port->id);
return;
}
if (port->name != NULL && find_port_by_name(port->name)) {
error_setg(errp, "virtio-serial-bus: A port already exists by name %s",
port->name);
return;
}
if (port->id == VIRTIO_CONSOLE_BAD_ID) {
if (plugging_port0) {
port->id = 0;
} else {
port->id = find_free_port_id(port->vser);
if (port->id == VIRTIO_CONSOLE_BAD_ID) {
error_setg(errp, "virtio-serial-bus: Maximum port limit for "
"this device reached");
return;
}
}
}
max_nr_ports = port->vser->serial.max_virtserial_ports;
if (port->id >= max_nr_ports) {
error_setg(errp, "virtio-serial-bus: Out-of-range port id specified, "
"max. allowed: %u", max_nr_ports - 1);
return;
}
vsc->realize(dev, &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
port->elem.out_num = 0;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
VirtIOSerialPort *port = VIRTIO_SERIAL_PORT(VAR_0);
VirtIOSerialPortClass *vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port);
VirtIOSerialBus *bus = VIRTIO_SERIAL_BUS(qdev_get_parent_bus(VAR_0));
int VAR_2;
bool plugging_port0;
Error *err = NULL;
port->vser = bus->vser;
port->bh = qemu_bh_new(flush_queued_data_bh, port);
assert(vsc->have_data);
plugging_port0 = vsc->is_console && !find_port_by_id(port->vser, 0);
if (find_port_by_id(port->vser, port->id)) {
error_setg(VAR_1, "virtio-serial-bus: A port already exists at id %u",
port->id);
return;
}
if (port->name != NULL && find_port_by_name(port->name)) {
error_setg(VAR_1, "virtio-serial-bus: A port already exists by name %s",
port->name);
return;
}
if (port->id == VIRTIO_CONSOLE_BAD_ID) {
if (plugging_port0) {
port->id = 0;
} else {
port->id = find_free_port_id(port->vser);
if (port->id == VIRTIO_CONSOLE_BAD_ID) {
error_setg(VAR_1, "virtio-serial-bus: Maximum port limit for "
"this device reached");
return;
}
}
}
VAR_2 = port->vser->serial.max_virtserial_ports;
if (port->id >= VAR_2) {
error_setg(VAR_1, "virtio-serial-bus: Out-of-range port id specified, "
"max. allowed: %u", VAR_2 - 1);
return;
}
vsc->realize(VAR_0, &err);
if (err != NULL) {
error_propagate(VAR_1, err);
return;
}
port->elem.out_num = 0;
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"VirtIOSerialPort *port = VIRTIO_SERIAL_PORT(VAR_0);",
"VirtIOSerialPortClass *vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port);",
"VirtIOSerialBus *bus = VIRTIO_SERIAL_BUS(qdev_get_parent_bus(VAR_0));",
"int VAR_2;",
"bool plugging_port0;",
"Error *err = NULL;",
"port->vser = bus->vser;",
"port->bh = qemu_bh_new(flush_queued_data_bh, port);",
"assert(vsc->have_data);",
"plugging_port0 = vsc->is_console && !find_port_by_id(port->vser, 0);",
"if (find_port_by_id(port->vser, port->id)) {",
"error_setg(VAR_1, \"virtio-serial-bus: A port already exists at id %u\",\nport->id);",
"return;",
"}",
"if (port->name != NULL && find_port_by_name(port->name)) {",
"error_setg(VAR_1, \"virtio-serial-bus: A port already exists by name %s\",\nport->name);",
"return;",
"}",
"if (port->id == VIRTIO_CONSOLE_BAD_ID) {",
"if (plugging_port0) {",
"port->id = 0;",
"} else {",
"port->id = find_free_port_id(port->vser);",
"if (port->id == VIRTIO_CONSOLE_BAD_ID) {",
"error_setg(VAR_1, \"virtio-serial-bus: Maximum port limit for \"\n\"this device reached\");",
"return;",
"}",
"}",
"}",
"VAR_2 = port->vser->serial.max_virtserial_ports;",
"if (port->id >= VAR_2) {",
"error_setg(VAR_1, \"virtio-serial-bus: Out-of-range port id specified, \"\n\"max. allowed: %u\", VAR_2 - 1);",
"return;",
"}",
"vsc->realize(VAR_0, &err);",
"if (err != NULL) {",
"error_propagate(VAR_1, err);",
"return;",
"}",
"port->elem.out_num = 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
25
],
[
39
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97,
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
]
] |
20,833 | void *av_malloc(unsigned int size)
{
void *ptr = NULL;
#if CONFIG_MEMALIGN_HACK
long diff;
#endif
/* let's disallow possible ambiguous cases */
if(size > (INT_MAX-16) )
return NULL;
#if CONFIG_MEMALIGN_HACK
ptr = malloc(size+16);
if(!ptr)
return ptr;
diff= ((-(long)ptr - 1)&15) + 1;
ptr = (char*)ptr + diff;
((char*)ptr)[-1]= diff;
#elif HAVE_POSIX_MEMALIGN
posix_memalign(&ptr,16,size);
#elif HAVE_MEMALIGN
ptr = memalign(16,size);
/* Why 64?
Indeed, we should align it:
on 4 for 386
on 16 for 486
on 32 for 586, PPro - K6-III
on 64 for K7 (maybe for P3 too).
Because L1 and L2 caches are aligned on those values.
But I don't want to code such logic here!
*/
/* Why 16?
Because some CPUs need alignment, for example SSE2 on P4, & most RISC CPUs
it will just trigger an exception and the unaligned load will be done in the
exception handler or it will just segfault (SSE2 on P4).
Why not larger? Because I did not see a difference in benchmarks ...
*/
/* benchmarks with P3
memalign(64)+1 3071,3051,3032
memalign(64)+2 3051,3032,3041
memalign(64)+4 2911,2896,2915
memalign(64)+8 2545,2554,2550
memalign(64)+16 2543,2572,2563
memalign(64)+32 2546,2545,2571
memalign(64)+64 2570,2533,2558
BTW, malloc seems to do 8-byte alignment by default here.
*/
#else
ptr = malloc(size);
#endif
return ptr;
}
| true | FFmpeg | a90de11dba816f57d01cf10b02eaaf90de24d5bb | void *av_malloc(unsigned int size)
{
void *ptr = NULL;
#if CONFIG_MEMALIGN_HACK
long diff;
#endif
if(size > (INT_MAX-16) )
return NULL;
#if CONFIG_MEMALIGN_HACK
ptr = malloc(size+16);
if(!ptr)
return ptr;
diff= ((-(long)ptr - 1)&15) + 1;
ptr = (char*)ptr + diff;
((char*)ptr)[-1]= diff;
#elif HAVE_POSIX_MEMALIGN
posix_memalign(&ptr,16,size);
#elif HAVE_MEMALIGN
ptr = memalign(16,size);
#else
ptr = malloc(size);
#endif
return ptr;
}
| {
"code": [
" posix_memalign(&ptr,16,size);"
],
"line_no": [
39
]
} | void *FUNC_0(unsigned int VAR_0)
{
void *VAR_1 = NULL;
#if CONFIG_MEMALIGN_HACK
long diff;
#endif
if(VAR_0 > (INT_MAX-16) )
return NULL;
#if CONFIG_MEMALIGN_HACK
VAR_1 = malloc(VAR_0+16);
if(!VAR_1)
return VAR_1;
diff= ((-(long)VAR_1 - 1)&15) + 1;
VAR_1 = (char*)VAR_1 + diff;
((char*)VAR_1)[-1]= diff;
#elif HAVE_POSIX_MEMALIGN
posix_memalign(&VAR_1,16,VAR_0);
#elif HAVE_MEMALIGN
VAR_1 = memalign(16,VAR_0);
#else
VAR_1 = malloc(VAR_0);
#endif
return VAR_1;
}
| [
"void *FUNC_0(unsigned int VAR_0)\n{",
"void *VAR_1 = NULL;",
"#if CONFIG_MEMALIGN_HACK\nlong diff;",
"#endif\nif(VAR_0 > (INT_MAX-16) )\nreturn NULL;",
"#if CONFIG_MEMALIGN_HACK\nVAR_1 = malloc(VAR_0+16);",
"if(!VAR_1)\nreturn VAR_1;",
"diff= ((-(long)VAR_1 - 1)&15) + 1;",
"VAR_1 = (char*)VAR_1 + diff;",
"((char*)VAR_1)[-1]= diff;",
"#elif HAVE_POSIX_MEMALIGN\nposix_memalign(&VAR_1,16,VAR_0);",
"#elif HAVE_MEMALIGN\nVAR_1 = memalign(16,VAR_0);",
"#else\nVAR_1 = malloc(VAR_0);",
"#endif\nreturn VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11,
17,
19
],
[
23,
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41,
43
],
[
97,
99
],
[
101,
103
],
[
105
]
] |
20,834 | static int do_token_in(USBDevice *s, USBPacket *p)
{
int request, value, index;
int ret = 0;
if (p->devep != 0)
return s->info->handle_data(s, p);
request = (s->setup_buf[0] << 8) | s->setup_buf[1];
value = (s->setup_buf[3] << 8) | s->setup_buf[2];
index = (s->setup_buf[5] << 8) | s->setup_buf[4];
switch(s->setup_state) {
case SETUP_STATE_ACK:
if (!(s->setup_buf[0] & USB_DIR_IN)) {
ret = s->info->handle_control(s, p, request, value, index,
s->setup_len, s->data_buf);
if (ret == USB_RET_ASYNC) {
return USB_RET_ASYNC;
}
s->setup_state = SETUP_STATE_IDLE;
if (ret > 0)
return 0;
return ret;
}
/* return 0 byte */
return 0;
case SETUP_STATE_DATA:
if (s->setup_buf[0] & USB_DIR_IN) {
int len = s->setup_len - s->setup_index;
if (len > p->len)
len = p->len;
memcpy(p->data, s->data_buf + s->setup_index, len);
s->setup_index += len;
if (s->setup_index >= s->setup_len)
s->setup_state = SETUP_STATE_ACK;
return len;
}
s->setup_state = SETUP_STATE_IDLE;
return USB_RET_STALL;
default:
return USB_RET_STALL;
}
}
| true | qemu | 4f4321c11ff6e98583846bfd6f0e81954924b003 | static int do_token_in(USBDevice *s, USBPacket *p)
{
int request, value, index;
int ret = 0;
if (p->devep != 0)
return s->info->handle_data(s, p);
request = (s->setup_buf[0] << 8) | s->setup_buf[1];
value = (s->setup_buf[3] << 8) | s->setup_buf[2];
index = (s->setup_buf[5] << 8) | s->setup_buf[4];
switch(s->setup_state) {
case SETUP_STATE_ACK:
if (!(s->setup_buf[0] & USB_DIR_IN)) {
ret = s->info->handle_control(s, p, request, value, index,
s->setup_len, s->data_buf);
if (ret == USB_RET_ASYNC) {
return USB_RET_ASYNC;
}
s->setup_state = SETUP_STATE_IDLE;
if (ret > 0)
return 0;
return ret;
}
return 0;
case SETUP_STATE_DATA:
if (s->setup_buf[0] & USB_DIR_IN) {
int len = s->setup_len - s->setup_index;
if (len > p->len)
len = p->len;
memcpy(p->data, s->data_buf + s->setup_index, len);
s->setup_index += len;
if (s->setup_index >= s->setup_len)
s->setup_state = SETUP_STATE_ACK;
return len;
}
s->setup_state = SETUP_STATE_IDLE;
return USB_RET_STALL;
default:
return USB_RET_STALL;
}
}
| {
"code": [
" if (len > p->len)",
" len = p->len;",
" memcpy(p->data, s->data_buf + s->setup_index, len);",
" if (len > p->len)",
" len = p->len;"
],
"line_no": [
65,
67,
69,
65,
67
]
} | static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)
{
int VAR_2, VAR_3, VAR_4;
int VAR_5 = 0;
if (VAR_1->devep != 0)
return VAR_0->info->handle_data(VAR_0, VAR_1);
VAR_2 = (VAR_0->setup_buf[0] << 8) | VAR_0->setup_buf[1];
VAR_3 = (VAR_0->setup_buf[3] << 8) | VAR_0->setup_buf[2];
VAR_4 = (VAR_0->setup_buf[5] << 8) | VAR_0->setup_buf[4];
switch(VAR_0->setup_state) {
case SETUP_STATE_ACK:
if (!(VAR_0->setup_buf[0] & USB_DIR_IN)) {
VAR_5 = VAR_0->info->handle_control(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4,
VAR_0->setup_len, VAR_0->data_buf);
if (VAR_5 == USB_RET_ASYNC) {
return USB_RET_ASYNC;
}
VAR_0->setup_state = SETUP_STATE_IDLE;
if (VAR_5 > 0)
return 0;
return VAR_5;
}
return 0;
case SETUP_STATE_DATA:
if (VAR_0->setup_buf[0] & USB_DIR_IN) {
int VAR_6 = VAR_0->setup_len - VAR_0->setup_index;
if (VAR_6 > VAR_1->VAR_6)
VAR_6 = VAR_1->VAR_6;
memcpy(VAR_1->data, VAR_0->data_buf + VAR_0->setup_index, VAR_6);
VAR_0->setup_index += VAR_6;
if (VAR_0->setup_index >= VAR_0->setup_len)
VAR_0->setup_state = SETUP_STATE_ACK;
return VAR_6;
}
VAR_0->setup_state = SETUP_STATE_IDLE;
return USB_RET_STALL;
default:
return USB_RET_STALL;
}
}
| [
"static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)\n{",
"int VAR_2, VAR_3, VAR_4;",
"int VAR_5 = 0;",
"if (VAR_1->devep != 0)\nreturn VAR_0->info->handle_data(VAR_0, VAR_1);",
"VAR_2 = (VAR_0->setup_buf[0] << 8) | VAR_0->setup_buf[1];",
"VAR_3 = (VAR_0->setup_buf[3] << 8) | VAR_0->setup_buf[2];",
"VAR_4 = (VAR_0->setup_buf[5] << 8) | VAR_0->setup_buf[4];",
"switch(VAR_0->setup_state) {",
"case SETUP_STATE_ACK:\nif (!(VAR_0->setup_buf[0] & USB_DIR_IN)) {",
"VAR_5 = VAR_0->info->handle_control(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4,\nVAR_0->setup_len, VAR_0->data_buf);",
"if (VAR_5 == USB_RET_ASYNC) {",
"return USB_RET_ASYNC;",
"}",
"VAR_0->setup_state = SETUP_STATE_IDLE;",
"if (VAR_5 > 0)\nreturn 0;",
"return VAR_5;",
"}",
"return 0;",
"case SETUP_STATE_DATA:\nif (VAR_0->setup_buf[0] & USB_DIR_IN) {",
"int VAR_6 = VAR_0->setup_len - VAR_0->setup_index;",
"if (VAR_6 > VAR_1->VAR_6)\nVAR_6 = VAR_1->VAR_6;",
"memcpy(VAR_1->data, VAR_0->data_buf + VAR_0->setup_index, VAR_6);",
"VAR_0->setup_index += VAR_6;",
"if (VAR_0->setup_index >= VAR_0->setup_len)\nVAR_0->setup_state = SETUP_STATE_ACK;",
"return VAR_6;",
"}",
"VAR_0->setup_state = SETUP_STATE_IDLE;",
"return USB_RET_STALL;",
"default:\nreturn USB_RET_STALL;",
"}",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27,
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
55
],
[
59,
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
89,
91
],
[
93
],
[
95
]
] |
20,836 | static int qemu_chr_open_socket(QemuOpts *opts, CharDriverState **_chr)
{
CharDriverState *chr = NULL;
TCPCharDriver *s = NULL;
int fd = -1;
int is_listen;
int is_waitconnect;
int do_nodelay;
int is_unix;
int is_telnet;
int ret;
is_listen = qemu_opt_get_bool(opts, "server", 0);
is_waitconnect = qemu_opt_get_bool(opts, "wait", 1);
is_telnet = qemu_opt_get_bool(opts, "telnet", 0);
do_nodelay = !qemu_opt_get_bool(opts, "delay", 1);
is_unix = qemu_opt_get(opts, "path") != NULL;
if (!is_listen)
is_waitconnect = 0;
chr = g_malloc0(sizeof(CharDriverState));
s = g_malloc0(sizeof(TCPCharDriver));
if (is_unix) {
if (is_listen) {
fd = unix_listen_opts(opts);
} else {
fd = unix_connect_opts(opts);
}
} else {
if (is_listen) {
fd = inet_listen_opts(opts, 0);
} else {
fd = inet_connect_opts(opts);
}
}
if (fd < 0) {
ret = -errno;
goto fail;
}
if (!is_waitconnect)
socket_set_nonblock(fd);
s->connected = 0;
s->fd = -1;
s->listen_fd = -1;
s->msgfd = -1;
s->is_unix = is_unix;
s->do_nodelay = do_nodelay && !is_unix;
chr->opaque = s;
chr->chr_write = tcp_chr_write;
chr->chr_close = tcp_chr_close;
chr->get_msgfd = tcp_get_msgfd;
chr->chr_add_client = tcp_chr_add_client;
if (is_listen) {
s->listen_fd = fd;
qemu_set_fd_handler2(s->listen_fd, NULL, tcp_chr_accept, NULL, chr);
if (is_telnet)
s->do_telnetopt = 1;
} else {
s->connected = 1;
s->fd = fd;
socket_set_nodelay(fd);
tcp_chr_connect(chr);
}
/* for "info chardev" monitor command */
chr->filename = g_malloc(256);
if (is_unix) {
snprintf(chr->filename, 256, "unix:%s%s",
qemu_opt_get(opts, "path"),
qemu_opt_get_bool(opts, "server", 0) ? ",server" : "");
} else if (is_telnet) {
snprintf(chr->filename, 256, "telnet:%s:%s%s",
qemu_opt_get(opts, "host"), qemu_opt_get(opts, "port"),
qemu_opt_get_bool(opts, "server", 0) ? ",server" : "");
} else {
snprintf(chr->filename, 256, "tcp:%s:%s%s",
qemu_opt_get(opts, "host"), qemu_opt_get(opts, "port"),
qemu_opt_get_bool(opts, "server", 0) ? ",server" : "");
}
if (is_listen && is_waitconnect) {
printf("QEMU waiting for connection on: %s\n",
chr->filename);
tcp_chr_accept(chr);
socket_set_nonblock(s->listen_fd);
}
*_chr = chr;
return 0;
fail:
if (fd >= 0)
closesocket(fd);
g_free(s);
g_free(chr);
return ret;
}
| true | qemu | 1f51470d044852592922f91000e741c381582cdc | static int qemu_chr_open_socket(QemuOpts *opts, CharDriverState **_chr)
{
CharDriverState *chr = NULL;
TCPCharDriver *s = NULL;
int fd = -1;
int is_listen;
int is_waitconnect;
int do_nodelay;
int is_unix;
int is_telnet;
int ret;
is_listen = qemu_opt_get_bool(opts, "server", 0);
is_waitconnect = qemu_opt_get_bool(opts, "wait", 1);
is_telnet = qemu_opt_get_bool(opts, "telnet", 0);
do_nodelay = !qemu_opt_get_bool(opts, "delay", 1);
is_unix = qemu_opt_get(opts, "path") != NULL;
if (!is_listen)
is_waitconnect = 0;
chr = g_malloc0(sizeof(CharDriverState));
s = g_malloc0(sizeof(TCPCharDriver));
if (is_unix) {
if (is_listen) {
fd = unix_listen_opts(opts);
} else {
fd = unix_connect_opts(opts);
}
} else {
if (is_listen) {
fd = inet_listen_opts(opts, 0);
} else {
fd = inet_connect_opts(opts);
}
}
if (fd < 0) {
ret = -errno;
goto fail;
}
if (!is_waitconnect)
socket_set_nonblock(fd);
s->connected = 0;
s->fd = -1;
s->listen_fd = -1;
s->msgfd = -1;
s->is_unix = is_unix;
s->do_nodelay = do_nodelay && !is_unix;
chr->opaque = s;
chr->chr_write = tcp_chr_write;
chr->chr_close = tcp_chr_close;
chr->get_msgfd = tcp_get_msgfd;
chr->chr_add_client = tcp_chr_add_client;
if (is_listen) {
s->listen_fd = fd;
qemu_set_fd_handler2(s->listen_fd, NULL, tcp_chr_accept, NULL, chr);
if (is_telnet)
s->do_telnetopt = 1;
} else {
s->connected = 1;
s->fd = fd;
socket_set_nodelay(fd);
tcp_chr_connect(chr);
}
chr->filename = g_malloc(256);
if (is_unix) {
snprintf(chr->filename, 256, "unix:%s%s",
qemu_opt_get(opts, "path"),
qemu_opt_get_bool(opts, "server", 0) ? ",server" : "");
} else if (is_telnet) {
snprintf(chr->filename, 256, "telnet:%s:%s%s",
qemu_opt_get(opts, "host"), qemu_opt_get(opts, "port"),
qemu_opt_get_bool(opts, "server", 0) ? ",server" : "");
} else {
snprintf(chr->filename, 256, "tcp:%s:%s%s",
qemu_opt_get(opts, "host"), qemu_opt_get(opts, "port"),
qemu_opt_get_bool(opts, "server", 0) ? ",server" : "");
}
if (is_listen && is_waitconnect) {
printf("QEMU waiting for connection on: %s\n",
chr->filename);
tcp_chr_accept(chr);
socket_set_nonblock(s->listen_fd);
}
*_chr = chr;
return 0;
fail:
if (fd >= 0)
closesocket(fd);
g_free(s);
g_free(chr);
return ret;
}
| {
"code": [
" *_chr = chr;",
" return 0;",
" *_chr = chr;",
" return 0;",
" *_chr = chr;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" *_chr = chr;",
" return 0;",
" *_chr = chr;",
" return 0;",
" *_chr = chr;",
" return 0;",
" if (fd < 0) {",
" *_chr = chr;",
" return 0;",
" if (fd < 0) {",
" *_chr = chr;",
" return 0;",
" *_chr = chr;",
" return 0;",
" *_chr = chr;",
" return 0;",
" return 0;",
" *_chr = chr;",
" return 0;",
" int ret;",
" ret = -errno;",
" *_chr = chr;",
" return 0;",
" return ret;",
"static int qemu_chr_open_socket(QemuOpts *opts, CharDriverState **_chr)",
" int ret;",
" if (fd < 0) {",
" ret = -errno;",
" *_chr = chr;",
" return 0;",
" return ret;",
" int ret;",
" *_chr = chr;",
" return 0;"
],
"line_no": [
187,
189,
187,
189,
187,
189,
189,
189,
189,
187,
189,
187,
189,
187,
189,
73,
187,
189,
73,
187,
189,
187,
189,
187,
189,
189,
187,
189,
21,
75,
187,
189,
203,
1,
21,
73,
75,
187,
189,
203,
21,
187,
189
]
} | static int FUNC_0(QemuOpts *VAR_0, CharDriverState **VAR_1)
{
CharDriverState *chr = NULL;
TCPCharDriver *s = NULL;
int VAR_2 = -1;
int VAR_3;
int VAR_4;
int VAR_5;
int VAR_6;
int VAR_7;
int VAR_8;
VAR_3 = qemu_opt_get_bool(VAR_0, "server", 0);
VAR_4 = qemu_opt_get_bool(VAR_0, "wait", 1);
VAR_7 = qemu_opt_get_bool(VAR_0, "telnet", 0);
VAR_5 = !qemu_opt_get_bool(VAR_0, "delay", 1);
VAR_6 = qemu_opt_get(VAR_0, "path") != NULL;
if (!VAR_3)
VAR_4 = 0;
chr = g_malloc0(sizeof(CharDriverState));
s = g_malloc0(sizeof(TCPCharDriver));
if (VAR_6) {
if (VAR_3) {
VAR_2 = unix_listen_opts(VAR_0);
} else {
VAR_2 = unix_connect_opts(VAR_0);
}
} else {
if (VAR_3) {
VAR_2 = inet_listen_opts(VAR_0, 0);
} else {
VAR_2 = inet_connect_opts(VAR_0);
}
}
if (VAR_2 < 0) {
VAR_8 = -errno;
goto fail;
}
if (!VAR_4)
socket_set_nonblock(VAR_2);
s->connected = 0;
s->VAR_2 = -1;
s->listen_fd = -1;
s->msgfd = -1;
s->VAR_6 = VAR_6;
s->VAR_5 = VAR_5 && !VAR_6;
chr->opaque = s;
chr->chr_write = tcp_chr_write;
chr->chr_close = tcp_chr_close;
chr->get_msgfd = tcp_get_msgfd;
chr->chr_add_client = tcp_chr_add_client;
if (VAR_3) {
s->listen_fd = VAR_2;
qemu_set_fd_handler2(s->listen_fd, NULL, tcp_chr_accept, NULL, chr);
if (VAR_7)
s->do_telnetopt = 1;
} else {
s->connected = 1;
s->VAR_2 = VAR_2;
socket_set_nodelay(VAR_2);
tcp_chr_connect(chr);
}
chr->filename = g_malloc(256);
if (VAR_6) {
snprintf(chr->filename, 256, "unix:%s%s",
qemu_opt_get(VAR_0, "path"),
qemu_opt_get_bool(VAR_0, "server", 0) ? ",server" : "");
} else if (VAR_7) {
snprintf(chr->filename, 256, "telnet:%s:%s%s",
qemu_opt_get(VAR_0, "host"), qemu_opt_get(VAR_0, "port"),
qemu_opt_get_bool(VAR_0, "server", 0) ? ",server" : "");
} else {
snprintf(chr->filename, 256, "tcp:%s:%s%s",
qemu_opt_get(VAR_0, "host"), qemu_opt_get(VAR_0, "port"),
qemu_opt_get_bool(VAR_0, "server", 0) ? ",server" : "");
}
if (VAR_3 && VAR_4) {
printf("QEMU waiting for connection on: %s\n",
chr->filename);
tcp_chr_accept(chr);
socket_set_nonblock(s->listen_fd);
}
*VAR_1 = chr;
return 0;
fail:
if (VAR_2 >= 0)
closesocket(VAR_2);
g_free(s);
g_free(chr);
return VAR_8;
}
| [
"static int FUNC_0(QemuOpts *VAR_0, CharDriverState **VAR_1)\n{",
"CharDriverState *chr = NULL;",
"TCPCharDriver *s = NULL;",
"int VAR_2 = -1;",
"int VAR_3;",
"int VAR_4;",
"int VAR_5;",
"int VAR_6;",
"int VAR_7;",
"int VAR_8;",
"VAR_3 = qemu_opt_get_bool(VAR_0, \"server\", 0);",
"VAR_4 = qemu_opt_get_bool(VAR_0, \"wait\", 1);",
"VAR_7 = qemu_opt_get_bool(VAR_0, \"telnet\", 0);",
"VAR_5 = !qemu_opt_get_bool(VAR_0, \"delay\", 1);",
"VAR_6 = qemu_opt_get(VAR_0, \"path\") != NULL;",
"if (!VAR_3)\nVAR_4 = 0;",
"chr = g_malloc0(sizeof(CharDriverState));",
"s = g_malloc0(sizeof(TCPCharDriver));",
"if (VAR_6) {",
"if (VAR_3) {",
"VAR_2 = unix_listen_opts(VAR_0);",
"} else {",
"VAR_2 = unix_connect_opts(VAR_0);",
"}",
"} else {",
"if (VAR_3) {",
"VAR_2 = inet_listen_opts(VAR_0, 0);",
"} else {",
"VAR_2 = inet_connect_opts(VAR_0);",
"}",
"}",
"if (VAR_2 < 0) {",
"VAR_8 = -errno;",
"goto fail;",
"}",
"if (!VAR_4)\nsocket_set_nonblock(VAR_2);",
"s->connected = 0;",
"s->VAR_2 = -1;",
"s->listen_fd = -1;",
"s->msgfd = -1;",
"s->VAR_6 = VAR_6;",
"s->VAR_5 = VAR_5 && !VAR_6;",
"chr->opaque = s;",
"chr->chr_write = tcp_chr_write;",
"chr->chr_close = tcp_chr_close;",
"chr->get_msgfd = tcp_get_msgfd;",
"chr->chr_add_client = tcp_chr_add_client;",
"if (VAR_3) {",
"s->listen_fd = VAR_2;",
"qemu_set_fd_handler2(s->listen_fd, NULL, tcp_chr_accept, NULL, chr);",
"if (VAR_7)\ns->do_telnetopt = 1;",
"} else {",
"s->connected = 1;",
"s->VAR_2 = VAR_2;",
"socket_set_nodelay(VAR_2);",
"tcp_chr_connect(chr);",
"}",
"chr->filename = g_malloc(256);",
"if (VAR_6) {",
"snprintf(chr->filename, 256, \"unix:%s%s\",\nqemu_opt_get(VAR_0, \"path\"),\nqemu_opt_get_bool(VAR_0, \"server\", 0) ? \",server\" : \"\");",
"} else if (VAR_7) {",
"snprintf(chr->filename, 256, \"telnet:%s:%s%s\",\nqemu_opt_get(VAR_0, \"host\"), qemu_opt_get(VAR_0, \"port\"),\nqemu_opt_get_bool(VAR_0, \"server\", 0) ? \",server\" : \"\");",
"} else {",
"snprintf(chr->filename, 256, \"tcp:%s:%s%s\",\nqemu_opt_get(VAR_0, \"host\"), qemu_opt_get(VAR_0, \"port\"),\nqemu_opt_get_bool(VAR_0, \"server\", 0) ? \",server\" : \"\");",
"}",
"if (VAR_3 && VAR_4) {",
"printf(\"QEMU waiting for connection on: %s\\n\",\nchr->filename);",
"tcp_chr_accept(chr);",
"socket_set_nonblock(s->listen_fd);",
"}",
"*VAR_1 = chr;",
"return 0;",
"fail:\nif (VAR_2 >= 0)\nclosesocket(VAR_2);",
"g_free(s);",
"g_free(chr);",
"return VAR_8;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83,
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121,
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
143
],
[
145
],
[
147,
149,
151
],
[
153
],
[
155,
157,
159
],
[
161
],
[
163,
165,
167
],
[
169
],
[
173
],
[
175,
177
],
[
179
],
[
181
],
[
183
],
[
187
],
[
189
],
[
193,
195,
197
],
[
199
],
[
201
],
[
203
],
[
205
]
] |
20,837 | static void imx_serial_write(void *opaque, hwaddr offset,
uint64_t value, unsigned size)
{
IMXSerialState *s = (IMXSerialState *)opaque;
unsigned char ch;
DPRINTF("write(offset=0x%" HWADDR_PRIx ", value = 0x%x) to %s\n",
offset, (unsigned int)value, s->chr ? s->chr->label : "NODEV");
switch (offset >> 2) {
case 0x10: /* UTXD */
ch = value;
if (s->ucr2 & UCR2_TXEN) {
if (s->chr) {
qemu_chr_fe_write(s->chr, &ch, 1);
}
s->usr1 &= ~USR1_TRDY;
imx_update(s);
s->usr1 |= USR1_TRDY;
imx_update(s);
}
break;
case 0x20: /* UCR1 */
s->ucr1 = value & 0xffff;
DPRINTF("write(ucr1=%x)\n", (unsigned int)value);
imx_update(s);
break;
case 0x21: /* UCR2 */
/*
* Only a few bits in control register 2 are implemented as yet.
* If it's intended to use a real serial device as a back-end, this
* register will have to be implemented more fully.
*/
if (!(value & UCR2_SRST)) {
imx_serial_reset(s);
imx_update(s);
value |= UCR2_SRST;
}
if (value & UCR2_RXEN) {
if (!(s->ucr2 & UCR2_RXEN)) {
if (s->chr) {
qemu_chr_accept_input(s->chr);
}
}
}
s->ucr2 = value & 0xffff;
break;
case 0x25: /* USR1 */
value &= USR1_AWAKE | USR1_AIRINT | USR1_DTRD | USR1_AGTIM |
USR1_FRAMERR | USR1_ESCF | USR1_RTSD | USR1_PARTYER;
s->usr1 &= ~value;
break;
case 0x26: /* USR2 */
/*
* Writing 1 to some bits clears them; all other
* values are ignored
*/
value &= USR2_ADET | USR2_DTRF | USR2_IDLE | USR2_ACST |
USR2_RIDELT | USR2_IRINT | USR2_WAKE |
USR2_DCDDELT | USR2_RTSF | USR2_BRCD | USR2_ORE;
s->usr2 &= ~value;
break;
/*
* Linux expects to see what it writes to these registers
* We don't currently alter the baud rate
*/
case 0x29: /* UBIR */
s->ubrc = value & 0xffff;
break;
case 0x2a: /* UBMR */
s->ubmr = value & 0xffff;
break;
case 0x2c: /* One ms reg */
s->onems = value & 0xffff;
break;
case 0x24: /* FIFO control register */
s->ufcr = value & 0xffff;
break;
case 0x22: /* UCR3 */
s->ucr3 = value & 0xffff;
break;
case 0x2d: /* UTS1 */
case 0x23: /* UCR4 */
qemu_log_mask(LOG_UNIMP, "[%s]%s: Unimplemented reg 0x%"
HWADDR_PRIx "\n", TYPE_IMX_SERIAL, __func__, offset);
/* TODO */
break;
default:
qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at offset 0x%"
HWADDR_PRIx "\n", TYPE_IMX_SERIAL, __func__, offset);
}
}
| true | qemu | 6ab3fc32ea640026726bc5f9f4db622d0954fb8a | static void imx_serial_write(void *opaque, hwaddr offset,
uint64_t value, unsigned size)
{
IMXSerialState *s = (IMXSerialState *)opaque;
unsigned char ch;
DPRINTF("write(offset=0x%" HWADDR_PRIx ", value = 0x%x) to %s\n",
offset, (unsigned int)value, s->chr ? s->chr->label : "NODEV");
switch (offset >> 2) {
case 0x10:
ch = value;
if (s->ucr2 & UCR2_TXEN) {
if (s->chr) {
qemu_chr_fe_write(s->chr, &ch, 1);
}
s->usr1 &= ~USR1_TRDY;
imx_update(s);
s->usr1 |= USR1_TRDY;
imx_update(s);
}
break;
case 0x20:
s->ucr1 = value & 0xffff;
DPRINTF("write(ucr1=%x)\n", (unsigned int)value);
imx_update(s);
break;
case 0x21:
if (!(value & UCR2_SRST)) {
imx_serial_reset(s);
imx_update(s);
value |= UCR2_SRST;
}
if (value & UCR2_RXEN) {
if (!(s->ucr2 & UCR2_RXEN)) {
if (s->chr) {
qemu_chr_accept_input(s->chr);
}
}
}
s->ucr2 = value & 0xffff;
break;
case 0x25:
value &= USR1_AWAKE | USR1_AIRINT | USR1_DTRD | USR1_AGTIM |
USR1_FRAMERR | USR1_ESCF | USR1_RTSD | USR1_PARTYER;
s->usr1 &= ~value;
break;
case 0x26:
value &= USR2_ADET | USR2_DTRF | USR2_IDLE | USR2_ACST |
USR2_RIDELT | USR2_IRINT | USR2_WAKE |
USR2_DCDDELT | USR2_RTSF | USR2_BRCD | USR2_ORE;
s->usr2 &= ~value;
break;
case 0x29:
s->ubrc = value & 0xffff;
break;
case 0x2a:
s->ubmr = value & 0xffff;
break;
case 0x2c:
s->onems = value & 0xffff;
break;
case 0x24:
s->ufcr = value & 0xffff;
break;
case 0x22:
s->ucr3 = value & 0xffff;
break;
case 0x2d:
case 0x23:
qemu_log_mask(LOG_UNIMP, "[%s]%s: Unimplemented reg 0x%"
HWADDR_PRIx "\n", TYPE_IMX_SERIAL, __func__, offset);
break;
default:
qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at offset 0x%"
HWADDR_PRIx "\n", TYPE_IMX_SERIAL, __func__, offset);
}
}
| {
"code": [
" qemu_chr_fe_write(s->chr, &ch, 1);",
" qemu_chr_fe_write(s->chr, &ch, 1);"
],
"line_no": [
29,
29
]
} | static void FUNC_0(void *VAR_0, hwaddr VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
IMXSerialState *s = (IMXSerialState *)VAR_0;
unsigned char VAR_4;
DPRINTF("write(VAR_1=0x%" HWADDR_PRIx ", VAR_2 = 0x%x) to %s\n",
VAR_1, (unsigned int)VAR_2, s->chr ? s->chr->label : "NODEV");
switch (VAR_1 >> 2) {
case 0x10:
VAR_4 = VAR_2;
if (s->ucr2 & UCR2_TXEN) {
if (s->chr) {
qemu_chr_fe_write(s->chr, &VAR_4, 1);
}
s->usr1 &= ~USR1_TRDY;
imx_update(s);
s->usr1 |= USR1_TRDY;
imx_update(s);
}
break;
case 0x20:
s->ucr1 = VAR_2 & 0xffff;
DPRINTF("write(ucr1=%x)\n", (unsigned int)VAR_2);
imx_update(s);
break;
case 0x21:
if (!(VAR_2 & UCR2_SRST)) {
imx_serial_reset(s);
imx_update(s);
VAR_2 |= UCR2_SRST;
}
if (VAR_2 & UCR2_RXEN) {
if (!(s->ucr2 & UCR2_RXEN)) {
if (s->chr) {
qemu_chr_accept_input(s->chr);
}
}
}
s->ucr2 = VAR_2 & 0xffff;
break;
case 0x25:
VAR_2 &= USR1_AWAKE | USR1_AIRINT | USR1_DTRD | USR1_AGTIM |
USR1_FRAMERR | USR1_ESCF | USR1_RTSD | USR1_PARTYER;
s->usr1 &= ~VAR_2;
break;
case 0x26:
VAR_2 &= USR2_ADET | USR2_DTRF | USR2_IDLE | USR2_ACST |
USR2_RIDELT | USR2_IRINT | USR2_WAKE |
USR2_DCDDELT | USR2_RTSF | USR2_BRCD | USR2_ORE;
s->usr2 &= ~VAR_2;
break;
case 0x29:
s->ubrc = VAR_2 & 0xffff;
break;
case 0x2a:
s->ubmr = VAR_2 & 0xffff;
break;
case 0x2c:
s->onems = VAR_2 & 0xffff;
break;
case 0x24:
s->ufcr = VAR_2 & 0xffff;
break;
case 0x22:
s->ucr3 = VAR_2 & 0xffff;
break;
case 0x2d:
case 0x23:
qemu_log_mask(LOG_UNIMP, "[%s]%s: Unimplemented reg 0x%"
HWADDR_PRIx "\n", TYPE_IMX_SERIAL, __func__, VAR_1);
break;
default:
qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at VAR_1 0x%"
HWADDR_PRIx "\n", TYPE_IMX_SERIAL, __func__, VAR_1);
}
}
| [
"static void FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"IMXSerialState *s = (IMXSerialState *)VAR_0;",
"unsigned char VAR_4;",
"DPRINTF(\"write(VAR_1=0x%\" HWADDR_PRIx \", VAR_2 = 0x%x) to %s\\n\",\nVAR_1, (unsigned int)VAR_2, s->chr ? s->chr->label : \"NODEV\");",
"switch (VAR_1 >> 2) {",
"case 0x10:\nVAR_4 = VAR_2;",
"if (s->ucr2 & UCR2_TXEN) {",
"if (s->chr) {",
"qemu_chr_fe_write(s->chr, &VAR_4, 1);",
"}",
"s->usr1 &= ~USR1_TRDY;",
"imx_update(s);",
"s->usr1 |= USR1_TRDY;",
"imx_update(s);",
"}",
"break;",
"case 0x20:\ns->ucr1 = VAR_2 & 0xffff;",
"DPRINTF(\"write(ucr1=%x)\\n\", (unsigned int)VAR_2);",
"imx_update(s);",
"break;",
"case 0x21:\nif (!(VAR_2 & UCR2_SRST)) {",
"imx_serial_reset(s);",
"imx_update(s);",
"VAR_2 |= UCR2_SRST;",
"}",
"if (VAR_2 & UCR2_RXEN) {",
"if (!(s->ucr2 & UCR2_RXEN)) {",
"if (s->chr) {",
"qemu_chr_accept_input(s->chr);",
"}",
"}",
"}",
"s->ucr2 = VAR_2 & 0xffff;",
"break;",
"case 0x25:\nVAR_2 &= USR1_AWAKE | USR1_AIRINT | USR1_DTRD | USR1_AGTIM |\nUSR1_FRAMERR | USR1_ESCF | USR1_RTSD | USR1_PARTYER;",
"s->usr1 &= ~VAR_2;",
"break;",
"case 0x26:\nVAR_2 &= USR2_ADET | USR2_DTRF | USR2_IDLE | USR2_ACST |\nUSR2_RIDELT | USR2_IRINT | USR2_WAKE |\nUSR2_DCDDELT | USR2_RTSF | USR2_BRCD | USR2_ORE;",
"s->usr2 &= ~VAR_2;",
"break;",
"case 0x29:\ns->ubrc = VAR_2 & 0xffff;",
"break;",
"case 0x2a:\ns->ubmr = VAR_2 & 0xffff;",
"break;",
"case 0x2c:\ns->onems = VAR_2 & 0xffff;",
"break;",
"case 0x24:\ns->ufcr = VAR_2 & 0xffff;",
"break;",
"case 0x22:\ns->ucr3 = VAR_2 & 0xffff;",
"break;",
"case 0x2d:\ncase 0x23:\nqemu_log_mask(LOG_UNIMP, \"[%s]%s: Unimplemented reg 0x%\"\nHWADDR_PRIx \"\\n\", TYPE_IMX_SERIAL, __func__, VAR_1);",
"break;",
"default:\nqemu_log_mask(LOG_GUEST_ERROR, \"[%s]%s: Bad register at VAR_1 0x%\"\nHWADDR_PRIx \"\\n\", TYPE_IMX_SERIAL, __func__, VAR_1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13,
15
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47,
49
],
[
53
],
[
57
],
[
59
],
[
63,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105,
107,
109
],
[
111
],
[
113
],
[
117,
127,
129,
131
],
[
133
],
[
135
],
[
147,
149
],
[
151
],
[
155,
157
],
[
159
],
[
163,
165
],
[
167
],
[
171,
173
],
[
175
],
[
179,
181
],
[
183
],
[
187,
189,
191,
193
],
[
197
],
[
201,
203,
205
],
[
207
],
[
209
]
] |
20,838 | static void numa_add(const char *optarg)
{
char option[128];
char *endptr;
unsigned long long value, endvalue;
unsigned long long nodenr;
value = endvalue = 0ULL;
optarg = get_opt_name(option, 128, optarg, ',');
if (*optarg == ',') {
optarg++;
}
if (!strcmp(option, "node")) {
if (nb_numa_nodes >= MAX_NODES) {
fprintf(stderr, "qemu: too many NUMA nodes\n");
exit(1);
}
if (get_param_value(option, 128, "nodeid", optarg) == 0) {
nodenr = nb_numa_nodes;
} else {
nodenr = strtoull(option, NULL, 10);
}
if (nodenr >= MAX_NODES) {
fprintf(stderr, "qemu: invalid NUMA nodeid: %llu\n", nodenr);
exit(1);
}
if (get_param_value(option, 128, "mem", optarg) == 0) {
node_mem[nodenr] = 0;
} else {
int64_t sval;
sval = strtosz(option, &endptr);
if (sval < 0 || *endptr) {
fprintf(stderr, "qemu: invalid numa mem size: %s\n", optarg);
exit(1);
}
node_mem[nodenr] = sval;
}
if (get_param_value(option, 128, "cpus", optarg) != 0) {
value = strtoull(option, &endptr, 10);
if (*endptr == '-') {
endvalue = strtoull(endptr+1, &endptr, 10);
} else {
endvalue = value;
}
if (!(endvalue < MAX_CPUMASK_BITS)) {
endvalue = MAX_CPUMASK_BITS - 1;
fprintf(stderr,
"A max of %d CPUs are supported in a guest\n",
MAX_CPUMASK_BITS);
}
bitmap_set(node_cpumask[nodenr], value, endvalue-value+1);
}
nb_numa_nodes++;
} else {
fprintf(stderr, "Invalid -numa option: %s\n", option);
exit(1);
}
}
| true | qemu | 5f1399651eaab1b04e49107250d182968a227aa6 | static void numa_add(const char *optarg)
{
char option[128];
char *endptr;
unsigned long long value, endvalue;
unsigned long long nodenr;
value = endvalue = 0ULL;
optarg = get_opt_name(option, 128, optarg, ',');
if (*optarg == ',') {
optarg++;
}
if (!strcmp(option, "node")) {
if (nb_numa_nodes >= MAX_NODES) {
fprintf(stderr, "qemu: too many NUMA nodes\n");
exit(1);
}
if (get_param_value(option, 128, "nodeid", optarg) == 0) {
nodenr = nb_numa_nodes;
} else {
nodenr = strtoull(option, NULL, 10);
}
if (nodenr >= MAX_NODES) {
fprintf(stderr, "qemu: invalid NUMA nodeid: %llu\n", nodenr);
exit(1);
}
if (get_param_value(option, 128, "mem", optarg) == 0) {
node_mem[nodenr] = 0;
} else {
int64_t sval;
sval = strtosz(option, &endptr);
if (sval < 0 || *endptr) {
fprintf(stderr, "qemu: invalid numa mem size: %s\n", optarg);
exit(1);
}
node_mem[nodenr] = sval;
}
if (get_param_value(option, 128, "cpus", optarg) != 0) {
value = strtoull(option, &endptr, 10);
if (*endptr == '-') {
endvalue = strtoull(endptr+1, &endptr, 10);
} else {
endvalue = value;
}
if (!(endvalue < MAX_CPUMASK_BITS)) {
endvalue = MAX_CPUMASK_BITS - 1;
fprintf(stderr,
"A max of %d CPUs are supported in a guest\n",
MAX_CPUMASK_BITS);
}
bitmap_set(node_cpumask[nodenr], value, endvalue-value+1);
}
nb_numa_nodes++;
} else {
fprintf(stderr, "Invalid -numa option: %s\n", option);
exit(1);
}
}
| {
"code": [
" nodenr = strtoull(option, NULL, 10);"
],
"line_no": [
47
]
} | static void FUNC_0(const char *VAR_0)
{
char VAR_1[128];
char *VAR_2;
unsigned long long VAR_3, VAR_4;
unsigned long long VAR_5;
VAR_3 = VAR_4 = 0ULL;
VAR_0 = get_opt_name(VAR_1, 128, VAR_0, ',');
if (*VAR_0 == ',') {
VAR_0++;
}
if (!strcmp(VAR_1, "node")) {
if (nb_numa_nodes >= MAX_NODES) {
fprintf(stderr, "qemu: too many NUMA nodes\n");
exit(1);
}
if (get_param_value(VAR_1, 128, "nodeid", VAR_0) == 0) {
VAR_5 = nb_numa_nodes;
} else {
VAR_5 = strtoull(VAR_1, NULL, 10);
}
if (VAR_5 >= MAX_NODES) {
fprintf(stderr, "qemu: invalid NUMA nodeid: %llu\n", VAR_5);
exit(1);
}
if (get_param_value(VAR_1, 128, "mem", VAR_0) == 0) {
node_mem[VAR_5] = 0;
} else {
int64_t sval;
sval = strtosz(VAR_1, &VAR_2);
if (sval < 0 || *VAR_2) {
fprintf(stderr, "qemu: invalid numa mem size: %s\n", VAR_0);
exit(1);
}
node_mem[VAR_5] = sval;
}
if (get_param_value(VAR_1, 128, "cpus", VAR_0) != 0) {
VAR_3 = strtoull(VAR_1, &VAR_2, 10);
if (*VAR_2 == '-') {
VAR_4 = strtoull(VAR_2+1, &VAR_2, 10);
} else {
VAR_4 = VAR_3;
}
if (!(VAR_4 < MAX_CPUMASK_BITS)) {
VAR_4 = MAX_CPUMASK_BITS - 1;
fprintf(stderr,
"A max of %d CPUs are supported in a guest\n",
MAX_CPUMASK_BITS);
}
bitmap_set(node_cpumask[VAR_5], VAR_3, VAR_4-VAR_3+1);
}
nb_numa_nodes++;
} else {
fprintf(stderr, "Invalid -numa VAR_1: %s\n", VAR_1);
exit(1);
}
}
| [
"static void FUNC_0(const char *VAR_0)\n{",
"char VAR_1[128];",
"char *VAR_2;",
"unsigned long long VAR_3, VAR_4;",
"unsigned long long VAR_5;",
"VAR_3 = VAR_4 = 0ULL;",
"VAR_0 = get_opt_name(VAR_1, 128, VAR_0, ',');",
"if (*VAR_0 == ',') {",
"VAR_0++;",
"}",
"if (!strcmp(VAR_1, \"node\")) {",
"if (nb_numa_nodes >= MAX_NODES) {",
"fprintf(stderr, \"qemu: too many NUMA nodes\\n\");",
"exit(1);",
"}",
"if (get_param_value(VAR_1, 128, \"nodeid\", VAR_0) == 0) {",
"VAR_5 = nb_numa_nodes;",
"} else {",
"VAR_5 = strtoull(VAR_1, NULL, 10);",
"}",
"if (VAR_5 >= MAX_NODES) {",
"fprintf(stderr, \"qemu: invalid NUMA nodeid: %llu\\n\", VAR_5);",
"exit(1);",
"}",
"if (get_param_value(VAR_1, 128, \"mem\", VAR_0) == 0) {",
"node_mem[VAR_5] = 0;",
"} else {",
"int64_t sval;",
"sval = strtosz(VAR_1, &VAR_2);",
"if (sval < 0 || *VAR_2) {",
"fprintf(stderr, \"qemu: invalid numa mem size: %s\\n\", VAR_0);",
"exit(1);",
"}",
"node_mem[VAR_5] = sval;",
"}",
"if (get_param_value(VAR_1, 128, \"cpus\", VAR_0) != 0) {",
"VAR_3 = strtoull(VAR_1, &VAR_2, 10);",
"if (*VAR_2 == '-') {",
"VAR_4 = strtoull(VAR_2+1, &VAR_2, 10);",
"} else {",
"VAR_4 = VAR_3;",
"}",
"if (!(VAR_4 < MAX_CPUMASK_BITS)) {",
"VAR_4 = MAX_CPUMASK_BITS - 1;",
"fprintf(stderr,\n\"A max of %d CPUs are supported in a guest\\n\",\nMAX_CPUMASK_BITS);",
"}",
"bitmap_set(node_cpumask[VAR_5], VAR_3, VAR_4-VAR_3+1);",
"}",
"nb_numa_nodes++;",
"} else {",
"fprintf(stderr, \"Invalid -numa VAR_1: %s\\n\", VAR_1);",
"exit(1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105,
107,
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
]
] |
20,839 | static int sap_read_header(AVFormatContext *s)
{
struct SAPState *sap = s->priv_data;
char host[1024], path[1024], url[1024];
uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
int port;
int ret, i;
AVInputFormat* infmt;
if (!ff_network_init())
return AVERROR(EIO);
av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &port,
path, sizeof(path), s->filename);
if (port < 0)
port = 9875;
if (!host[0]) {
/* Listen for announcements on sap.mcast.net if no host was specified */
av_strlcpy(host, "224.2.127.254", sizeof(host));
}
ff_url_join(url, sizeof(url), "udp", NULL, host, port, "?localport=%d",
port);
ret = ffurl_open(&sap->ann_fd, url, AVIO_FLAG_READ,
&s->interrupt_callback, NULL);
if (ret)
goto fail;
while (1) {
int addr_type, auth_len;
int pos;
ret = ffurl_read(sap->ann_fd, recvbuf, sizeof(recvbuf) - 1);
if (ret == AVERROR(EAGAIN))
continue;
if (ret < 0)
goto fail;
recvbuf[ret] = '\0'; /* Null terminate for easier parsing */
if (ret < 8) {
av_log(s, AV_LOG_WARNING, "Received too short packet\n");
continue;
}
if ((recvbuf[0] & 0xe0) != 0x20) {
av_log(s, AV_LOG_WARNING, "Unsupported SAP version packet "
"received\n");
continue;
}
if (recvbuf[0] & 0x04) {
av_log(s, AV_LOG_WARNING, "Received stream deletion "
"announcement\n");
continue;
}
addr_type = recvbuf[0] & 0x10;
auth_len = recvbuf[1];
sap->hash = AV_RB16(&recvbuf[2]);
pos = 4;
if (addr_type)
pos += 16; /* IPv6 */
else
pos += 4; /* IPv4 */
pos += auth_len * 4;
if (pos + 4 >= ret) {
av_log(s, AV_LOG_WARNING, "Received too short packet\n");
continue;
}
#define MIME "application/sdp"
if (strcmp(&recvbuf[pos], MIME) == 0) {
pos += strlen(MIME) + 1;
} else if (strncmp(&recvbuf[pos], "v=0\r\n", 5) == 0) {
// Direct SDP without a mime type
} else {
av_log(s, AV_LOG_WARNING, "Unsupported mime type %s\n",
&recvbuf[pos]);
continue;
}
sap->sdp = av_strdup(&recvbuf[pos]);
break;
}
av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sap->sdp);
ffio_init_context(&sap->sdp_pb, sap->sdp, strlen(sap->sdp), 0, NULL, NULL,
NULL, NULL);
infmt = av_find_input_format("sdp");
if (!infmt)
goto fail;
sap->sdp_ctx = avformat_alloc_context();
if (!sap->sdp_ctx) {
ret = AVERROR(ENOMEM);
goto fail;
}
sap->sdp_ctx->max_delay = s->max_delay;
sap->sdp_ctx->pb = &sap->sdp_pb;
sap->sdp_ctx->interrupt_callback = s->interrupt_callback;
av_assert0(!sap->sdp_ctx->codec_whitelist && !sap->sdp_ctx->format_whitelist);
sap->sdp_ctx-> codec_whitelist = av_strdup(s->codec_whitelist);
sap->sdp_ctx->format_whitelist = av_strdup(s->format_whitelist);
ret = avformat_open_input(&sap->sdp_ctx, "temp.sdp", infmt, NULL);
if (ret < 0)
goto fail;
if (sap->sdp_ctx->ctx_flags & AVFMTCTX_NOHEADER)
s->ctx_flags |= AVFMTCTX_NOHEADER;
for (i = 0; i < sap->sdp_ctx->nb_streams; i++) {
AVStream *st = avformat_new_stream(s, NULL);
if (!st) {
ret = AVERROR(ENOMEM);
goto fail;
}
st->id = i;
avcodec_copy_context(st->codec, sap->sdp_ctx->streams[i]->codec);
st->time_base = sap->sdp_ctx->streams[i]->time_base;
}
return 0;
fail:
sap_read_close(s);
return ret;
}
| true | FFmpeg | 4641ae352ec587355764ffd5c43dd0d0ebd47654 | static int sap_read_header(AVFormatContext *s)
{
struct SAPState *sap = s->priv_data;
char host[1024], path[1024], url[1024];
uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
int port;
int ret, i;
AVInputFormat* infmt;
if (!ff_network_init())
return AVERROR(EIO);
av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &port,
path, sizeof(path), s->filename);
if (port < 0)
port = 9875;
if (!host[0]) {
av_strlcpy(host, "224.2.127.254", sizeof(host));
}
ff_url_join(url, sizeof(url), "udp", NULL, host, port, "?localport=%d",
port);
ret = ffurl_open(&sap->ann_fd, url, AVIO_FLAG_READ,
&s->interrupt_callback, NULL);
if (ret)
goto fail;
while (1) {
int addr_type, auth_len;
int pos;
ret = ffurl_read(sap->ann_fd, recvbuf, sizeof(recvbuf) - 1);
if (ret == AVERROR(EAGAIN))
continue;
if (ret < 0)
goto fail;
recvbuf[ret] = '\0';
if (ret < 8) {
av_log(s, AV_LOG_WARNING, "Received too short packet\n");
continue;
}
if ((recvbuf[0] & 0xe0) != 0x20) {
av_log(s, AV_LOG_WARNING, "Unsupported SAP version packet "
"received\n");
continue;
}
if (recvbuf[0] & 0x04) {
av_log(s, AV_LOG_WARNING, "Received stream deletion "
"announcement\n");
continue;
}
addr_type = recvbuf[0] & 0x10;
auth_len = recvbuf[1];
sap->hash = AV_RB16(&recvbuf[2]);
pos = 4;
if (addr_type)
pos += 16;
else
pos += 4;
pos += auth_len * 4;
if (pos + 4 >= ret) {
av_log(s, AV_LOG_WARNING, "Received too short packet\n");
continue;
}
#define MIME "application/sdp"
if (strcmp(&recvbuf[pos], MIME) == 0) {
pos += strlen(MIME) + 1;
} else if (strncmp(&recvbuf[pos], "v=0\r\n", 5) == 0) {
} else {
av_log(s, AV_LOG_WARNING, "Unsupported mime type %s\n",
&recvbuf[pos]);
continue;
}
sap->sdp = av_strdup(&recvbuf[pos]);
break;
}
av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sap->sdp);
ffio_init_context(&sap->sdp_pb, sap->sdp, strlen(sap->sdp), 0, NULL, NULL,
NULL, NULL);
infmt = av_find_input_format("sdp");
if (!infmt)
goto fail;
sap->sdp_ctx = avformat_alloc_context();
if (!sap->sdp_ctx) {
ret = AVERROR(ENOMEM);
goto fail;
}
sap->sdp_ctx->max_delay = s->max_delay;
sap->sdp_ctx->pb = &sap->sdp_pb;
sap->sdp_ctx->interrupt_callback = s->interrupt_callback;
av_assert0(!sap->sdp_ctx->codec_whitelist && !sap->sdp_ctx->format_whitelist);
sap->sdp_ctx-> codec_whitelist = av_strdup(s->codec_whitelist);
sap->sdp_ctx->format_whitelist = av_strdup(s->format_whitelist);
ret = avformat_open_input(&sap->sdp_ctx, "temp.sdp", infmt, NULL);
if (ret < 0)
goto fail;
if (sap->sdp_ctx->ctx_flags & AVFMTCTX_NOHEADER)
s->ctx_flags |= AVFMTCTX_NOHEADER;
for (i = 0; i < sap->sdp_ctx->nb_streams; i++) {
AVStream *st = avformat_new_stream(s, NULL);
if (!st) {
ret = AVERROR(ENOMEM);
goto fail;
}
st->id = i;
avcodec_copy_context(st->codec, sap->sdp_ctx->streams[i]->codec);
st->time_base = sap->sdp_ctx->streams[i]->time_base;
}
return 0;
fail:
sap_read_close(s);
return ret;
}
| {
"code": [
" av_assert0(!sap->sdp_ctx->codec_whitelist && !sap->sdp_ctx->format_whitelist);",
" sap->sdp_ctx-> codec_whitelist = av_strdup(s->codec_whitelist);",
" sap->sdp_ctx->format_whitelist = av_strdup(s->format_whitelist);"
],
"line_no": [
199,
201,
203
]
} | static int FUNC_0(AVFormatContext *VAR_0)
{
struct SAPState *VAR_1 = VAR_0->priv_data;
char VAR_2[1024], VAR_3[1024], VAR_4[1024];
uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
int VAR_5;
int VAR_6, VAR_7;
AVInputFormat* infmt;
if (!ff_network_init())
return AVERROR(EIO);
av_url_split(NULL, 0, NULL, 0, VAR_2, sizeof(VAR_2), &VAR_5,
VAR_3, sizeof(VAR_3), VAR_0->filename);
if (VAR_5 < 0)
VAR_5 = 9875;
if (!VAR_2[0]) {
av_strlcpy(VAR_2, "224.2.127.254", sizeof(VAR_2));
}
ff_url_join(VAR_4, sizeof(VAR_4), "udp", NULL, VAR_2, VAR_5, "?localport=%d",
VAR_5);
VAR_6 = ffurl_open(&VAR_1->ann_fd, VAR_4, AVIO_FLAG_READ,
&VAR_0->interrupt_callback, NULL);
if (VAR_6)
goto fail;
while (1) {
int VAR_8, VAR_9;
int VAR_10;
VAR_6 = ffurl_read(VAR_1->ann_fd, recvbuf, sizeof(recvbuf) - 1);
if (VAR_6 == AVERROR(EAGAIN))
continue;
if (VAR_6 < 0)
goto fail;
recvbuf[VAR_6] = '\0';
if (VAR_6 < 8) {
av_log(VAR_0, AV_LOG_WARNING, "Received too short packet\n");
continue;
}
if ((recvbuf[0] & 0xe0) != 0x20) {
av_log(VAR_0, AV_LOG_WARNING, "Unsupported SAP version packet "
"received\n");
continue;
}
if (recvbuf[0] & 0x04) {
av_log(VAR_0, AV_LOG_WARNING, "Received stream deletion "
"announcement\n");
continue;
}
VAR_8 = recvbuf[0] & 0x10;
VAR_9 = recvbuf[1];
VAR_1->hash = AV_RB16(&recvbuf[2]);
VAR_10 = 4;
if (VAR_8)
VAR_10 += 16;
else
VAR_10 += 4;
VAR_10 += VAR_9 * 4;
if (VAR_10 + 4 >= VAR_6) {
av_log(VAR_0, AV_LOG_WARNING, "Received too short packet\n");
continue;
}
#define MIME "application/sdp"
if (strcmp(&recvbuf[VAR_10], MIME) == 0) {
VAR_10 += strlen(MIME) + 1;
} else if (strncmp(&recvbuf[VAR_10], "v=0\r\n", 5) == 0) {
} else {
av_log(VAR_0, AV_LOG_WARNING, "Unsupported mime type %VAR_0\n",
&recvbuf[VAR_10]);
continue;
}
VAR_1->sdp = av_strdup(&recvbuf[VAR_10]);
break;
}
av_log(VAR_0, AV_LOG_VERBOSE, "SDP:\n%VAR_0\n", VAR_1->sdp);
ffio_init_context(&VAR_1->sdp_pb, VAR_1->sdp, strlen(VAR_1->sdp), 0, NULL, NULL,
NULL, NULL);
infmt = av_find_input_format("sdp");
if (!infmt)
goto fail;
VAR_1->sdp_ctx = avformat_alloc_context();
if (!VAR_1->sdp_ctx) {
VAR_6 = AVERROR(ENOMEM);
goto fail;
}
VAR_1->sdp_ctx->max_delay = VAR_0->max_delay;
VAR_1->sdp_ctx->pb = &VAR_1->sdp_pb;
VAR_1->sdp_ctx->interrupt_callback = VAR_0->interrupt_callback;
av_assert0(!VAR_1->sdp_ctx->codec_whitelist && !VAR_1->sdp_ctx->format_whitelist);
VAR_1->sdp_ctx-> codec_whitelist = av_strdup(VAR_0->codec_whitelist);
VAR_1->sdp_ctx->format_whitelist = av_strdup(VAR_0->format_whitelist);
VAR_6 = avformat_open_input(&VAR_1->sdp_ctx, "temp.sdp", infmt, NULL);
if (VAR_6 < 0)
goto fail;
if (VAR_1->sdp_ctx->ctx_flags & AVFMTCTX_NOHEADER)
VAR_0->ctx_flags |= AVFMTCTX_NOHEADER;
for (VAR_7 = 0; VAR_7 < VAR_1->sdp_ctx->nb_streams; VAR_7++) {
AVStream *st = avformat_new_stream(VAR_0, NULL);
if (!st) {
VAR_6 = AVERROR(ENOMEM);
goto fail;
}
st->id = VAR_7;
avcodec_copy_context(st->codec, VAR_1->sdp_ctx->streams[VAR_7]->codec);
st->time_base = VAR_1->sdp_ctx->streams[VAR_7]->time_base;
}
return 0;
fail:
sap_read_close(VAR_0);
return VAR_6;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"struct SAPState *VAR_1 = VAR_0->priv_data;",
"char VAR_2[1024], VAR_3[1024], VAR_4[1024];",
"uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];",
"int VAR_5;",
"int VAR_6, VAR_7;",
"AVInputFormat* infmt;",
"if (!ff_network_init())\nreturn AVERROR(EIO);",
"av_url_split(NULL, 0, NULL, 0, VAR_2, sizeof(VAR_2), &VAR_5,\nVAR_3, sizeof(VAR_3), VAR_0->filename);",
"if (VAR_5 < 0)\nVAR_5 = 9875;",
"if (!VAR_2[0]) {",
"av_strlcpy(VAR_2, \"224.2.127.254\", sizeof(VAR_2));",
"}",
"ff_url_join(VAR_4, sizeof(VAR_4), \"udp\", NULL, VAR_2, VAR_5, \"?localport=%d\",\nVAR_5);",
"VAR_6 = ffurl_open(&VAR_1->ann_fd, VAR_4, AVIO_FLAG_READ,\n&VAR_0->interrupt_callback, NULL);",
"if (VAR_6)\ngoto fail;",
"while (1) {",
"int VAR_8, VAR_9;",
"int VAR_10;",
"VAR_6 = ffurl_read(VAR_1->ann_fd, recvbuf, sizeof(recvbuf) - 1);",
"if (VAR_6 == AVERROR(EAGAIN))\ncontinue;",
"if (VAR_6 < 0)\ngoto fail;",
"recvbuf[VAR_6] = '\\0';",
"if (VAR_6 < 8) {",
"av_log(VAR_0, AV_LOG_WARNING, \"Received too short packet\\n\");",
"continue;",
"}",
"if ((recvbuf[0] & 0xe0) != 0x20) {",
"av_log(VAR_0, AV_LOG_WARNING, \"Unsupported SAP version packet \"\n\"received\\n\");",
"continue;",
"}",
"if (recvbuf[0] & 0x04) {",
"av_log(VAR_0, AV_LOG_WARNING, \"Received stream deletion \"\n\"announcement\\n\");",
"continue;",
"}",
"VAR_8 = recvbuf[0] & 0x10;",
"VAR_9 = recvbuf[1];",
"VAR_1->hash = AV_RB16(&recvbuf[2]);",
"VAR_10 = 4;",
"if (VAR_8)\nVAR_10 += 16;",
"else\nVAR_10 += 4;",
"VAR_10 += VAR_9 * 4;",
"if (VAR_10 + 4 >= VAR_6) {",
"av_log(VAR_0, AV_LOG_WARNING, \"Received too short packet\\n\");",
"continue;",
"}",
"#define MIME \"application/sdp\"\nif (strcmp(&recvbuf[VAR_10], MIME) == 0) {",
"VAR_10 += strlen(MIME) + 1;",
"} else if (strncmp(&recvbuf[VAR_10], \"v=0\\r\\n\", 5) == 0) {",
"} else {",
"av_log(VAR_0, AV_LOG_WARNING, \"Unsupported mime type %VAR_0\\n\",\n&recvbuf[VAR_10]);",
"continue;",
"}",
"VAR_1->sdp = av_strdup(&recvbuf[VAR_10]);",
"break;",
"}",
"av_log(VAR_0, AV_LOG_VERBOSE, \"SDP:\\n%VAR_0\\n\", VAR_1->sdp);",
"ffio_init_context(&VAR_1->sdp_pb, VAR_1->sdp, strlen(VAR_1->sdp), 0, NULL, NULL,\nNULL, NULL);",
"infmt = av_find_input_format(\"sdp\");",
"if (!infmt)\ngoto fail;",
"VAR_1->sdp_ctx = avformat_alloc_context();",
"if (!VAR_1->sdp_ctx) {",
"VAR_6 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"VAR_1->sdp_ctx->max_delay = VAR_0->max_delay;",
"VAR_1->sdp_ctx->pb = &VAR_1->sdp_pb;",
"VAR_1->sdp_ctx->interrupt_callback = VAR_0->interrupt_callback;",
"av_assert0(!VAR_1->sdp_ctx->codec_whitelist && !VAR_1->sdp_ctx->format_whitelist);",
"VAR_1->sdp_ctx-> codec_whitelist = av_strdup(VAR_0->codec_whitelist);",
"VAR_1->sdp_ctx->format_whitelist = av_strdup(VAR_0->format_whitelist);",
"VAR_6 = avformat_open_input(&VAR_1->sdp_ctx, \"temp.sdp\", infmt, NULL);",
"if (VAR_6 < 0)\ngoto fail;",
"if (VAR_1->sdp_ctx->ctx_flags & AVFMTCTX_NOHEADER)\nVAR_0->ctx_flags |= AVFMTCTX_NOHEADER;",
"for (VAR_7 = 0; VAR_7 < VAR_1->sdp_ctx->nb_streams; VAR_7++) {",
"AVStream *st = avformat_new_stream(VAR_0, NULL);",
"if (!st) {",
"VAR_6 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"st->id = VAR_7;",
"avcodec_copy_context(st->codec, VAR_1->sdp_ctx->streams[VAR_7]->codec);",
"st->time_base = VAR_1->sdp_ctx->streams[VAR_7]->time_base;",
"}",
"return 0;",
"fail:\nsap_read_close(VAR_0);",
"return VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
25,
27
],
[
29,
31
],
[
35
],
[
39
],
[
41
],
[
45,
47
],
[
49,
51
],
[
53,
55
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69,
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91,
93
],
[
95
],
[
97
],
[
101
],
[
103,
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119,
121
],
[
123,
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137,
139
],
[
141
],
[
143
],
[
147
],
[
149,
151
],
[
153
],
[
155
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169,
171
],
[
175
],
[
177,
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
199
],
[
201
],
[
203
],
[
207
],
[
209,
211
],
[
213,
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
239
],
[
243,
245
],
[
247
],
[
249
]
] |
20,841 | static void arm_gic_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
ARMGICClass *agc = ARM_GIC_CLASS(klass);
agc->parent_init = sbc->init;
sbc->init = arm_gic_init;
dc->no_user = 1;
}
| true | qemu | 53111180946a56d314a9c1d07d09b9ef91e847b9 | static void arm_gic_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
ARMGICClass *agc = ARM_GIC_CLASS(klass);
agc->parent_init = sbc->init;
sbc->init = arm_gic_init;
dc->no_user = 1;
}
| {
"code": [
" SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);",
" agc->parent_init = sbc->init;",
" sbc->init = arm_gic_init;"
],
"line_no": [
7,
11,
13
]
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(VAR_0);
ARMGICClass *agc = ARM_GIC_CLASS(VAR_0);
agc->parent_init = sbc->init;
sbc->init = arm_gic_init;
dc->no_user = 1;
}
| [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(VAR_0);",
"ARMGICClass *agc = ARM_GIC_CLASS(VAR_0);",
"agc->parent_init = sbc->init;",
"sbc->init = arm_gic_init;",
"dc->no_user = 1;",
"}"
] | [
0,
0,
1,
0,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
20,842 | static inline int l2_unscale_group(int steps, int mant, int scale_factor)
{
int shift, mod, val;
shift = scale_factor_modshift[scale_factor];
mod = shift & 3;
shift >>= 2;
/* XXX: store the result directly */
val = (2 * (mant - (steps >> 1))) * scale_factor_mult2[steps >> 2][mod];
return (val + (1 << (shift - 1))) >> shift;
}
| true | FFmpeg | 8155233413540c63e53a620ff5734fb4b0635611 | static inline int l2_unscale_group(int steps, int mant, int scale_factor)
{
int shift, mod, val;
shift = scale_factor_modshift[scale_factor];
mod = shift & 3;
shift >>= 2;
val = (2 * (mant - (steps >> 1))) * scale_factor_mult2[steps >> 2][mod];
return (val + (1 << (shift - 1))) >> shift;
}
| {
"code": [
" val = (2 * (mant - (steps >> 1))) * scale_factor_mult2[steps >> 2][mod];",
" return (val + (1 << (shift - 1))) >> shift;"
],
"line_no": [
17,
19
]
} | static inline int FUNC_0(int VAR_0, int VAR_1, int VAR_2)
{
int VAR_3, VAR_4, VAR_5;
VAR_3 = scale_factor_modshift[VAR_2];
VAR_4 = VAR_3 & 3;
VAR_3 >>= 2;
VAR_5 = (2 * (VAR_1 - (VAR_0 >> 1))) * scale_factor_mult2[VAR_0 >> 2][VAR_4];
return (VAR_5 + (1 << (VAR_3 - 1))) >> VAR_3;
}
| [
"static inline int FUNC_0(int VAR_0, int VAR_1, int VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5;",
"VAR_3 = scale_factor_modshift[VAR_2];",
"VAR_4 = VAR_3 & 3;",
"VAR_3 >>= 2;",
"VAR_5 = (2 * (VAR_1 - (VAR_0 >> 1))) * scale_factor_mult2[VAR_0 >> 2][VAR_4];",
"return (VAR_5 + (1 << (VAR_3 - 1))) >> VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
]
] |
20,843 | static void init_proc_970 (CPUPPCState *env)
{
gen_spr_ne_601(env);
gen_spr_7xx(env);
/* Time base */
gen_tbl(env);
/* Hardware implementation registers */
/* XXX : not implemented */
spr_register(env, SPR_HID0, "HID0",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_clear,
0x60000000);
/* XXX : not implemented */
spr_register(env, SPR_HID1, "HID1",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
/* XXX : not implemented */
spr_register(env, SPR_750_HID2, "HID2",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
/* XXX : not implemented */
spr_register(env, SPR_970_HID5, "HID5",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
POWERPC970_HID5_INIT);
/* Memory management */
/* XXX: not correct */
gen_low_BATs(env);
/* XXX : not implemented */
spr_register(env, SPR_MMUCFG, "MMUCFG",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, SPR_NOACCESS,
0x00000000); /* TOFIX */
/* XXX : not implemented */
spr_register(env, SPR_MMUCSR0, "MMUCSR0",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000); /* TOFIX */
spr_register(env, SPR_HIOR, "SPR_HIOR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0xFFF00000); /* XXX: This is a hack */
#if !defined(CONFIG_USER_ONLY)
env->excp_prefix = 0xFFF00000;
#endif
#if !defined(CONFIG_USER_ONLY)
env->slb_nr = 32;
#endif
init_excp_970(env);
env->dcache_line_size = 128;
env->icache_line_size = 128;
/* Allocate hardware IRQ controller */
ppc970_irq_init(env);
}
| true | qemu | faadf50e2962dd54175647a80bd6fc4319c91973 | static void init_proc_970 (CPUPPCState *env)
{
gen_spr_ne_601(env);
gen_spr_7xx(env);
gen_tbl(env);
spr_register(env, SPR_HID0, "HID0",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_clear,
0x60000000);
spr_register(env, SPR_HID1, "HID1",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_750_HID2, "HID2",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_970_HID5, "HID5",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
POWERPC970_HID5_INIT);
gen_low_BATs(env);
spr_register(env, SPR_MMUCFG, "MMUCFG",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, SPR_NOACCESS,
0x00000000);
spr_register(env, SPR_MMUCSR0, "MMUCSR0",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_HIOR, "SPR_HIOR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0xFFF00000);
#if !defined(CONFIG_USER_ONLY)
env->excp_prefix = 0xFFF00000;
#endif
#if !defined(CONFIG_USER_ONLY)
env->slb_nr = 32;
#endif
init_excp_970(env);
env->dcache_line_size = 128;
env->icache_line_size = 128;
ppc970_irq_init(env);
}
| {
"code": [
"#endif",
" env->excp_prefix = 0xFFF00000;",
" env->excp_prefix = 0xFFF00000;",
" 0x00000000);",
"#if !defined(CONFIG_USER_ONLY)",
" env->excp_prefix = 0xFFF00000;",
"#endif",
"#if !defined(CONFIG_USER_ONLY)",
" env->excp_prefix = 0xFFF00000;",
"#endif",
"#if !defined(CONFIG_USER_ONLY)",
" env->excp_prefix = 0xFFF00000;",
"#endif",
"#if !defined(CONFIG_USER_ONLY)",
" env->excp_prefix = 0xFFF00000;",
"#endif",
"#endif"
],
"line_no": [
93,
91,
91,
33,
89,
91,
93,
89,
91,
93,
89,
91,
93,
89,
91,
93,
93
]
} | static void FUNC_0 (CPUPPCState *VAR_0)
{
gen_spr_ne_601(VAR_0);
gen_spr_7xx(VAR_0);
gen_tbl(VAR_0);
spr_register(VAR_0, SPR_HID0, "HID0",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_clear,
0x60000000);
spr_register(VAR_0, SPR_HID1, "HID1",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(VAR_0, SPR_750_HID2, "HID2",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(VAR_0, SPR_970_HID5, "HID5",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
POWERPC970_HID5_INIT);
gen_low_BATs(VAR_0);
spr_register(VAR_0, SPR_MMUCFG, "MMUCFG",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, SPR_NOACCESS,
0x00000000);
spr_register(VAR_0, SPR_MMUCSR0, "MMUCSR0",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(VAR_0, SPR_HIOR, "SPR_HIOR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0xFFF00000);
#if !defined(CONFIG_USER_ONLY)
VAR_0->excp_prefix = 0xFFF00000;
#endif
#if !defined(CONFIG_USER_ONLY)
VAR_0->slb_nr = 32;
#endif
init_excp_970(VAR_0);
VAR_0->dcache_line_size = 128;
VAR_0->icache_line_size = 128;
ppc970_irq_init(VAR_0);
}
| [
"static void FUNC_0 (CPUPPCState *VAR_0)\n{",
"gen_spr_ne_601(VAR_0);",
"gen_spr_7xx(VAR_0);",
"gen_tbl(VAR_0);",
"spr_register(VAR_0, SPR_HID0, \"HID0\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_clear,\n0x60000000);",
"spr_register(VAR_0, SPR_HID1, \"HID1\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\n0x00000000);",
"spr_register(VAR_0, SPR_750_HID2, \"HID2\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\n0x00000000);",
"spr_register(VAR_0, SPR_970_HID5, \"HID5\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\nPOWERPC970_HID5_INIT);",
"gen_low_BATs(VAR_0);",
"spr_register(VAR_0, SPR_MMUCFG, \"MMUCFG\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, SPR_NOACCESS,\n0x00000000);",
"spr_register(VAR_0, SPR_MMUCSR0, \"MMUCSR0\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\n0x00000000);",
"spr_register(VAR_0, SPR_HIOR, \"SPR_HIOR\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\n0xFFF00000);",
"#if !defined(CONFIG_USER_ONLY)\nVAR_0->excp_prefix = 0xFFF00000;",
"#endif\n#if !defined(CONFIG_USER_ONLY)\nVAR_0->slb_nr = 32;",
"#endif\ninit_excp_970(VAR_0);",
"VAR_0->dcache_line_size = 128;",
"VAR_0->icache_line_size = 128;",
"ppc970_irq_init(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
17,
19,
21,
23
],
[
27,
29,
31,
33
],
[
37,
39,
41,
43
],
[
47,
49,
51,
53
],
[
59
],
[
63,
65,
67,
69
],
[
73,
75,
77,
79
],
[
81,
83,
85,
87
],
[
89,
91
],
[
93,
95,
97
],
[
99,
101
],
[
103
],
[
105
],
[
109
],
[
111
]
] |
20,844 | static int mov_write_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
MOVMuxContext *mov = s->priv_data;
AVDictionaryEntry *t;
int i, hint_track = 0;
/* Default mode == MP4 */
mov->mode = MODE_MP4;
if (s->oformat != NULL) {
if (!strcmp("3gp", s->oformat->name)) mov->mode = MODE_3GP;
else if (!strcmp("3g2", s->oformat->name)) mov->mode = MODE_3GP|MODE_3G2;
else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV;
else if (!strcmp("psp", s->oformat->name)) mov->mode = MODE_PSP;
else if (!strcmp("ipod",s->oformat->name)) mov->mode = MODE_IPOD;
else if (!strcmp("ismv",s->oformat->name)) mov->mode = MODE_ISM;
}
/* Set the FRAGMENT flag if any of the fragmentation methods are
* enabled. */
if (mov->max_fragment_duration || mov->max_fragment_size ||
mov->mode == MODE_ISM ||
mov->flags & (FF_MOV_FLAG_EMPTY_MOOV |
FF_MOV_FLAG_FRAG_KEYFRAME |
FF_MOV_FLAG_FRAG_CUSTOM))
mov->flags |= FF_MOV_FLAG_FRAGMENT;
/* faststart: moov at the beginning of the file, if supported */
if (mov->flags & FF_MOV_FLAG_FASTSTART) {
if ((mov->flags & FF_MOV_FLAG_FRAGMENT) ||
(s->flags & AVFMT_FLAG_CUSTOM_IO)) {
av_log(s, AV_LOG_WARNING, "The faststart flag is incompatible "
"with fragmentation and custom IO, disabling faststart\n");
mov->flags &= ~FF_MOV_FLAG_FASTSTART;
}
}
/* Non-seekable output is ok if using fragmentation. If ism_lookahead
* is enabled, we don't support non-seekable output at all. */
if (!s->pb->seekable &&
(!(mov->flags & FF_MOV_FLAG_FRAGMENT) || mov->ism_lookahead)) {
av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n");
return -1;
}
mov_write_ftyp_tag(pb,s);
if (mov->mode == MODE_PSP) {
if (s->nb_streams != 2) {
av_log(s, AV_LOG_ERROR, "PSP mode need one video and one audio stream\n");
return -1;
}
mov_write_uuidprof_tag(pb, s);
}
mov->nb_streams = s->nb_streams;
if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && s->nb_chapters)
mov->chapter_track = mov->nb_streams++;
if (mov->flags & FF_MOV_FLAG_RTP_HINT) {
/* Add hint tracks for each audio and video stream */
hint_track = mov->nb_streams;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
mov->nb_streams++;
}
}
}
// Reserve an extra stream for chapters for the case where chapters
// are written in the trailer
mov->tracks = av_mallocz((mov->nb_streams + 1) * sizeof(*mov->tracks));
if (!mov->tracks)
return AVERROR(ENOMEM);
for (i = 0; i < s->nb_streams; i++) {
AVStream *st= s->streams[i];
MOVTrack *track= &mov->tracks[i];
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0);
track->enc = st->codec;
track->language = ff_mov_iso639_to_lang(lang?lang->value:"und", mov->mode!=MODE_MOV);
if (track->language < 0)
track->language = 0;
track->mode = mov->mode;
track->tag = mov_find_codec_tag(s, track);
if (!track->tag) {
av_log(s, AV_LOG_ERROR, "track %d: could not find tag, "
"codec not currently supported in container\n", i);
goto error;
}
/* If hinting of this track is enabled by a later hint track,
* this is updated. */
track->hint_track = -1;
track->start_dts = AV_NOPTS_VALUE;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') ||
track->tag == MKTAG('m','x','4','p') || track->tag == MKTAG('m','x','4','n') ||
track->tag == MKTAG('m','x','5','p') || track->tag == MKTAG('m','x','5','n')) {
if (st->codec->width != 720 || (st->codec->height != 608 && st->codec->height != 512)) {
av_log(s, AV_LOG_ERROR, "D-10/IMX must use 720x608 or 720x512 video resolution\n");
goto error;
}
track->height = track->tag >> 24 == 'n' ? 486 : 576;
}
track->timescale = st->codec->time_base.den;
if (track->mode == MODE_MOV && track->timescale > 100000)
av_log(s, AV_LOG_WARNING,
"WARNING codec timebase is very high. If duration is too long,\n"
"file may not be playable by quicktime. Specify a shorter timebase\n"
"or choose different container.\n");
} else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
track->timescale = st->codec->sample_rate;
/* set sample_size for PCM and ADPCM */
if (av_get_bits_per_sample(st->codec->codec_id) ||
st->codec->codec_id == AV_CODEC_ID_ILBC) {
if (!st->codec->block_align) {
av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set\n", i);
goto error;
}
track->sample_size = st->codec->block_align;
}
/* set audio_vbr for compressed audio */
if (av_get_bits_per_sample(st->codec->codec_id) < 8) {
track->audio_vbr = 1;
}
if (track->mode != MODE_MOV &&
track->enc->codec_id == AV_CODEC_ID_MP3 && track->timescale < 16000) {
av_log(s, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not supported\n",
i, track->enc->sample_rate);
goto error;
}
} else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
track->timescale = st->codec->time_base.den;
} else if (st->codec->codec_type == AVMEDIA_TYPE_DATA) {
track->timescale = st->codec->time_base.den;
}
if (!track->height)
track->height = st->codec->height;
/* The ism specific timescale isn't mandatory, but is assumed by
* some tools, such as mp4split. */
if (mov->mode == MODE_ISM)
track->timescale = 10000000;
avpriv_set_pts_info(st, 64, 1, track->timescale);
/* copy extradata if it exists */
if (st->codec->extradata_size) {
track->vos_len = st->codec->extradata_size;
track->vos_data = av_malloc(track->vos_len);
memcpy(track->vos_data, st->codec->extradata, track->vos_len);
}
}
enable_tracks(s);
if (mov->mode == MODE_ISM) {
/* If no fragmentation options have been set, set a default. */
if (!(mov->flags & (FF_MOV_FLAG_FRAG_KEYFRAME |
FF_MOV_FLAG_FRAG_CUSTOM)) &&
!mov->max_fragment_duration && !mov->max_fragment_size)
mov->max_fragment_duration = 5000000;
mov->flags |= FF_MOV_FLAG_EMPTY_MOOV | FF_MOV_FLAG_SEPARATE_MOOF;
}
if (!(mov->flags & FF_MOV_FLAG_FRAGMENT)) {
if (mov->flags & FF_MOV_FLAG_FASTSTART)
mov->reserved_moov_pos = avio_tell(pb);
mov_write_mdat_tag(pb, mov);
}
if (t = av_dict_get(s->metadata, "creation_time", NULL, 0))
mov->time = ff_iso8601_to_unix_time(t->value);
if (mov->time)
mov->time += 0x7C25B080; // 1970 based -> 1904 based
if (mov->chapter_track)
if (mov_create_chapter_track(s, mov->chapter_track) < 0)
goto error;
if (mov->flags & FF_MOV_FLAG_RTP_HINT) {
/* Initialize the hint tracks for each audio and video stream */
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
ff_mov_init_hinting(s, hint_track, i);
hint_track++;
}
}
}
avio_flush(pb);
if (mov->flags & FF_MOV_FLAG_ISML)
mov_write_isml_manifest(pb, mov);
if (mov->flags & FF_MOV_FLAG_EMPTY_MOOV) {
mov_write_moov_tag(pb, mov, s);
mov->fragments++;
}
return 0;
error:
mov_free(s);
return -1;
}
| true | FFmpeg | a9553bbb336a7186c62b3b14a0499c1b6ba61ebd | static int mov_write_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
MOVMuxContext *mov = s->priv_data;
AVDictionaryEntry *t;
int i, hint_track = 0;
mov->mode = MODE_MP4;
if (s->oformat != NULL) {
if (!strcmp("3gp", s->oformat->name)) mov->mode = MODE_3GP;
else if (!strcmp("3g2", s->oformat->name)) mov->mode = MODE_3GP|MODE_3G2;
else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV;
else if (!strcmp("psp", s->oformat->name)) mov->mode = MODE_PSP;
else if (!strcmp("ipod",s->oformat->name)) mov->mode = MODE_IPOD;
else if (!strcmp("ismv",s->oformat->name)) mov->mode = MODE_ISM;
}
if (mov->max_fragment_duration || mov->max_fragment_size ||
mov->mode == MODE_ISM ||
mov->flags & (FF_MOV_FLAG_EMPTY_MOOV |
FF_MOV_FLAG_FRAG_KEYFRAME |
FF_MOV_FLAG_FRAG_CUSTOM))
mov->flags |= FF_MOV_FLAG_FRAGMENT;
if (mov->flags & FF_MOV_FLAG_FASTSTART) {
if ((mov->flags & FF_MOV_FLAG_FRAGMENT) ||
(s->flags & AVFMT_FLAG_CUSTOM_IO)) {
av_log(s, AV_LOG_WARNING, "The faststart flag is incompatible "
"with fragmentation and custom IO, disabling faststart\n");
mov->flags &= ~FF_MOV_FLAG_FASTSTART;
}
}
if (!s->pb->seekable &&
(!(mov->flags & FF_MOV_FLAG_FRAGMENT) || mov->ism_lookahead)) {
av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n");
return -1;
}
mov_write_ftyp_tag(pb,s);
if (mov->mode == MODE_PSP) {
if (s->nb_streams != 2) {
av_log(s, AV_LOG_ERROR, "PSP mode need one video and one audio stream\n");
return -1;
}
mov_write_uuidprof_tag(pb, s);
}
mov->nb_streams = s->nb_streams;
if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && s->nb_chapters)
mov->chapter_track = mov->nb_streams++;
if (mov->flags & FF_MOV_FLAG_RTP_HINT) {
hint_track = mov->nb_streams;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
mov->nb_streams++;
}
}
}
mov->tracks = av_mallocz((mov->nb_streams + 1) * sizeof(*mov->tracks));
if (!mov->tracks)
return AVERROR(ENOMEM);
for (i = 0; i < s->nb_streams; i++) {
AVStream *st= s->streams[i];
MOVTrack *track= &mov->tracks[i];
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0);
track->enc = st->codec;
track->language = ff_mov_iso639_to_lang(lang?lang->value:"und", mov->mode!=MODE_MOV);
if (track->language < 0)
track->language = 0;
track->mode = mov->mode;
track->tag = mov_find_codec_tag(s, track);
if (!track->tag) {
av_log(s, AV_LOG_ERROR, "track %d: could not find tag, "
"codec not currently supported in container\n", i);
goto error;
}
track->hint_track = -1;
track->start_dts = AV_NOPTS_VALUE;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') ||
track->tag == MKTAG('m','x','4','p') || track->tag == MKTAG('m','x','4','n') ||
track->tag == MKTAG('m','x','5','p') || track->tag == MKTAG('m','x','5','n')) {
if (st->codec->width != 720 || (st->codec->height != 608 && st->codec->height != 512)) {
av_log(s, AV_LOG_ERROR, "D-10/IMX must use 720x608 or 720x512 video resolution\n");
goto error;
}
track->height = track->tag >> 24 == 'n' ? 486 : 576;
}
track->timescale = st->codec->time_base.den;
if (track->mode == MODE_MOV && track->timescale > 100000)
av_log(s, AV_LOG_WARNING,
"WARNING codec timebase is very high. If duration is too long,\n"
"file may not be playable by quicktime. Specify a shorter timebase\n"
"or choose different container.\n");
} else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
track->timescale = st->codec->sample_rate;
if (av_get_bits_per_sample(st->codec->codec_id) ||
st->codec->codec_id == AV_CODEC_ID_ILBC) {
if (!st->codec->block_align) {
av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set\n", i);
goto error;
}
track->sample_size = st->codec->block_align;
}
if (av_get_bits_per_sample(st->codec->codec_id) < 8) {
track->audio_vbr = 1;
}
if (track->mode != MODE_MOV &&
track->enc->codec_id == AV_CODEC_ID_MP3 && track->timescale < 16000) {
av_log(s, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not supported\n",
i, track->enc->sample_rate);
goto error;
}
} else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
track->timescale = st->codec->time_base.den;
} else if (st->codec->codec_type == AVMEDIA_TYPE_DATA) {
track->timescale = st->codec->time_base.den;
}
if (!track->height)
track->height = st->codec->height;
if (mov->mode == MODE_ISM)
track->timescale = 10000000;
avpriv_set_pts_info(st, 64, 1, track->timescale);
if (st->codec->extradata_size) {
track->vos_len = st->codec->extradata_size;
track->vos_data = av_malloc(track->vos_len);
memcpy(track->vos_data, st->codec->extradata, track->vos_len);
}
}
enable_tracks(s);
if (mov->mode == MODE_ISM) {
if (!(mov->flags & (FF_MOV_FLAG_FRAG_KEYFRAME |
FF_MOV_FLAG_FRAG_CUSTOM)) &&
!mov->max_fragment_duration && !mov->max_fragment_size)
mov->max_fragment_duration = 5000000;
mov->flags |= FF_MOV_FLAG_EMPTY_MOOV | FF_MOV_FLAG_SEPARATE_MOOF;
}
if (!(mov->flags & FF_MOV_FLAG_FRAGMENT)) {
if (mov->flags & FF_MOV_FLAG_FASTSTART)
mov->reserved_moov_pos = avio_tell(pb);
mov_write_mdat_tag(pb, mov);
}
if (t = av_dict_get(s->metadata, "creation_time", NULL, 0))
mov->time = ff_iso8601_to_unix_time(t->value);
if (mov->time)
mov->time += 0x7C25B080;
if (mov->chapter_track)
if (mov_create_chapter_track(s, mov->chapter_track) < 0)
goto error;
if (mov->flags & FF_MOV_FLAG_RTP_HINT) {
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
ff_mov_init_hinting(s, hint_track, i);
hint_track++;
}
}
}
avio_flush(pb);
if (mov->flags & FF_MOV_FLAG_ISML)
mov_write_isml_manifest(pb, mov);
if (mov->flags & FF_MOV_FLAG_EMPTY_MOOV) {
mov_write_moov_tag(pb, mov, s);
mov->fragments++;
}
return 0;
error:
mov_free(s);
return -1;
}
| {
"code": [
" mov->mode == MODE_ISM ||",
" mov->flags |= FF_MOV_FLAG_EMPTY_MOOV | FF_MOV_FLAG_SEPARATE_MOOF;"
],
"line_no": [
45,
331
]
} | static int FUNC_0(AVFormatContext *VAR_0)
{
AVIOContext *pb = VAR_0->pb;
MOVMuxContext *mov = VAR_0->priv_data;
AVDictionaryEntry *t;
int VAR_1, VAR_2 = 0;
mov->mode = MODE_MP4;
if (VAR_0->oformat != NULL) {
if (!strcmp("3gp", VAR_0->oformat->name)) mov->mode = MODE_3GP;
else if (!strcmp("3g2", VAR_0->oformat->name)) mov->mode = MODE_3GP|MODE_3G2;
else if (!strcmp("mov", VAR_0->oformat->name)) mov->mode = MODE_MOV;
else if (!strcmp("psp", VAR_0->oformat->name)) mov->mode = MODE_PSP;
else if (!strcmp("ipod",VAR_0->oformat->name)) mov->mode = MODE_IPOD;
else if (!strcmp("ismv",VAR_0->oformat->name)) mov->mode = MODE_ISM;
}
if (mov->max_fragment_duration || mov->max_fragment_size ||
mov->mode == MODE_ISM ||
mov->flags & (FF_MOV_FLAG_EMPTY_MOOV |
FF_MOV_FLAG_FRAG_KEYFRAME |
FF_MOV_FLAG_FRAG_CUSTOM))
mov->flags |= FF_MOV_FLAG_FRAGMENT;
if (mov->flags & FF_MOV_FLAG_FASTSTART) {
if ((mov->flags & FF_MOV_FLAG_FRAGMENT) ||
(VAR_0->flags & AVFMT_FLAG_CUSTOM_IO)) {
av_log(VAR_0, AV_LOG_WARNING, "The faststart flag is incompatible "
"with fragmentation and custom IO, disabling faststart\n");
mov->flags &= ~FF_MOV_FLAG_FASTSTART;
}
}
if (!VAR_0->pb->seekable &&
(!(mov->flags & FF_MOV_FLAG_FRAGMENT) || mov->ism_lookahead)) {
av_log(VAR_0, AV_LOG_ERROR, "muxer does not support non seekable output\n");
return -1;
}
mov_write_ftyp_tag(pb,VAR_0);
if (mov->mode == MODE_PSP) {
if (VAR_0->nb_streams != 2) {
av_log(VAR_0, AV_LOG_ERROR, "PSP mode need one video and one audio stream\n");
return -1;
}
mov_write_uuidprof_tag(pb, VAR_0);
}
mov->nb_streams = VAR_0->nb_streams;
if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && VAR_0->nb_chapters)
mov->chapter_track = mov->nb_streams++;
if (mov->flags & FF_MOV_FLAG_RTP_HINT) {
VAR_2 = mov->nb_streams;
for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {
AVStream *st = VAR_0->streams[VAR_1];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
mov->nb_streams++;
}
}
}
mov->tracks = av_mallocz((mov->nb_streams + 1) * sizeof(*mov->tracks));
if (!mov->tracks)
return AVERROR(ENOMEM);
for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {
AVStream *st= VAR_0->streams[VAR_1];
MOVTrack *track= &mov->tracks[VAR_1];
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0);
track->enc = st->codec;
track->language = ff_mov_iso639_to_lang(lang?lang->value:"und", mov->mode!=MODE_MOV);
if (track->language < 0)
track->language = 0;
track->mode = mov->mode;
track->tag = mov_find_codec_tag(VAR_0, track);
if (!track->tag) {
av_log(VAR_0, AV_LOG_ERROR, "track %d: could not find tag, "
"codec not currently supported in container\n", VAR_1);
goto error;
}
track->VAR_2 = -1;
track->start_dts = AV_NOPTS_VALUE;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') ||
track->tag == MKTAG('m','x','4','p') || track->tag == MKTAG('m','x','4','n') ||
track->tag == MKTAG('m','x','5','p') || track->tag == MKTAG('m','x','5','n')) {
if (st->codec->width != 720 || (st->codec->height != 608 && st->codec->height != 512)) {
av_log(VAR_0, AV_LOG_ERROR, "D-10/IMX must use 720x608 or 720x512 video resolution\n");
goto error;
}
track->height = track->tag >> 24 == 'n' ? 486 : 576;
}
track->timescale = st->codec->time_base.den;
if (track->mode == MODE_MOV && track->timescale > 100000)
av_log(VAR_0, AV_LOG_WARNING,
"WARNING codec timebase is very high. If duration is too long,\n"
"file may not be playable by quicktime. Specify a shorter timebase\n"
"or choose different container.\n");
} else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
track->timescale = st->codec->sample_rate;
if (av_get_bits_per_sample(st->codec->codec_id) ||
st->codec->codec_id == AV_CODEC_ID_ILBC) {
if (!st->codec->block_align) {
av_log(VAR_0, AV_LOG_ERROR, "track %d: codec block align is not set\n", VAR_1);
goto error;
}
track->sample_size = st->codec->block_align;
}
if (av_get_bits_per_sample(st->codec->codec_id) < 8) {
track->audio_vbr = 1;
}
if (track->mode != MODE_MOV &&
track->enc->codec_id == AV_CODEC_ID_MP3 && track->timescale < 16000) {
av_log(VAR_0, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not supported\n",
VAR_1, track->enc->sample_rate);
goto error;
}
} else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
track->timescale = st->codec->time_base.den;
} else if (st->codec->codec_type == AVMEDIA_TYPE_DATA) {
track->timescale = st->codec->time_base.den;
}
if (!track->height)
track->height = st->codec->height;
if (mov->mode == MODE_ISM)
track->timescale = 10000000;
avpriv_set_pts_info(st, 64, 1, track->timescale);
if (st->codec->extradata_size) {
track->vos_len = st->codec->extradata_size;
track->vos_data = av_malloc(track->vos_len);
memcpy(track->vos_data, st->codec->extradata, track->vos_len);
}
}
enable_tracks(VAR_0);
if (mov->mode == MODE_ISM) {
if (!(mov->flags & (FF_MOV_FLAG_FRAG_KEYFRAME |
FF_MOV_FLAG_FRAG_CUSTOM)) &&
!mov->max_fragment_duration && !mov->max_fragment_size)
mov->max_fragment_duration = 5000000;
mov->flags |= FF_MOV_FLAG_EMPTY_MOOV | FF_MOV_FLAG_SEPARATE_MOOF;
}
if (!(mov->flags & FF_MOV_FLAG_FRAGMENT)) {
if (mov->flags & FF_MOV_FLAG_FASTSTART)
mov->reserved_moov_pos = avio_tell(pb);
mov_write_mdat_tag(pb, mov);
}
if (t = av_dict_get(VAR_0->metadata, "creation_time", NULL, 0))
mov->time = ff_iso8601_to_unix_time(t->value);
if (mov->time)
mov->time += 0x7C25B080;
if (mov->chapter_track)
if (mov_create_chapter_track(VAR_0, mov->chapter_track) < 0)
goto error;
if (mov->flags & FF_MOV_FLAG_RTP_HINT) {
for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {
AVStream *st = VAR_0->streams[VAR_1];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
ff_mov_init_hinting(VAR_0, VAR_2, VAR_1);
VAR_2++;
}
}
}
avio_flush(pb);
if (mov->flags & FF_MOV_FLAG_ISML)
mov_write_isml_manifest(pb, mov);
if (mov->flags & FF_MOV_FLAG_EMPTY_MOOV) {
mov_write_moov_tag(pb, mov, VAR_0);
mov->fragments++;
}
return 0;
error:
mov_free(VAR_0);
return -1;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"AVIOContext *pb = VAR_0->pb;",
"MOVMuxContext *mov = VAR_0->priv_data;",
"AVDictionaryEntry *t;",
"int VAR_1, VAR_2 = 0;",
"mov->mode = MODE_MP4;",
"if (VAR_0->oformat != NULL) {",
"if (!strcmp(\"3gp\", VAR_0->oformat->name)) mov->mode = MODE_3GP;",
"else if (!strcmp(\"3g2\", VAR_0->oformat->name)) mov->mode = MODE_3GP|MODE_3G2;",
"else if (!strcmp(\"mov\", VAR_0->oformat->name)) mov->mode = MODE_MOV;",
"else if (!strcmp(\"psp\", VAR_0->oformat->name)) mov->mode = MODE_PSP;",
"else if (!strcmp(\"ipod\",VAR_0->oformat->name)) mov->mode = MODE_IPOD;",
"else if (!strcmp(\"ismv\",VAR_0->oformat->name)) mov->mode = MODE_ISM;",
"}",
"if (mov->max_fragment_duration || mov->max_fragment_size ||\nmov->mode == MODE_ISM ||\nmov->flags & (FF_MOV_FLAG_EMPTY_MOOV |\nFF_MOV_FLAG_FRAG_KEYFRAME |\nFF_MOV_FLAG_FRAG_CUSTOM))\nmov->flags |= FF_MOV_FLAG_FRAGMENT;",
"if (mov->flags & FF_MOV_FLAG_FASTSTART) {",
"if ((mov->flags & FF_MOV_FLAG_FRAGMENT) ||\n(VAR_0->flags & AVFMT_FLAG_CUSTOM_IO)) {",
"av_log(VAR_0, AV_LOG_WARNING, \"The faststart flag is incompatible \"\n\"with fragmentation and custom IO, disabling faststart\\n\");",
"mov->flags &= ~FF_MOV_FLAG_FASTSTART;",
"}",
"}",
"if (!VAR_0->pb->seekable &&\n(!(mov->flags & FF_MOV_FLAG_FRAGMENT) || mov->ism_lookahead)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"muxer does not support non seekable output\\n\");",
"return -1;",
"}",
"mov_write_ftyp_tag(pb,VAR_0);",
"if (mov->mode == MODE_PSP) {",
"if (VAR_0->nb_streams != 2) {",
"av_log(VAR_0, AV_LOG_ERROR, \"PSP mode need one video and one audio stream\\n\");",
"return -1;",
"}",
"mov_write_uuidprof_tag(pb, VAR_0);",
"}",
"mov->nb_streams = VAR_0->nb_streams;",
"if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && VAR_0->nb_chapters)\nmov->chapter_track = mov->nb_streams++;",
"if (mov->flags & FF_MOV_FLAG_RTP_HINT) {",
"VAR_2 = mov->nb_streams;",
"for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {",
"AVStream *st = VAR_0->streams[VAR_1];",
"if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||\nst->codec->codec_type == AVMEDIA_TYPE_AUDIO) {",
"mov->nb_streams++;",
"}",
"}",
"}",
"mov->tracks = av_mallocz((mov->nb_streams + 1) * sizeof(*mov->tracks));",
"if (!mov->tracks)\nreturn AVERROR(ENOMEM);",
"for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {",
"AVStream *st= VAR_0->streams[VAR_1];",
"MOVTrack *track= &mov->tracks[VAR_1];",
"AVDictionaryEntry *lang = av_dict_get(st->metadata, \"language\", NULL,0);",
"track->enc = st->codec;",
"track->language = ff_mov_iso639_to_lang(lang?lang->value:\"und\", mov->mode!=MODE_MOV);",
"if (track->language < 0)\ntrack->language = 0;",
"track->mode = mov->mode;",
"track->tag = mov_find_codec_tag(VAR_0, track);",
"if (!track->tag) {",
"av_log(VAR_0, AV_LOG_ERROR, \"track %d: could not find tag, \"\n\"codec not currently supported in container\\n\", VAR_1);",
"goto error;",
"}",
"track->VAR_2 = -1;",
"track->start_dts = AV_NOPTS_VALUE;",
"if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {",
"if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') ||\ntrack->tag == MKTAG('m','x','4','p') || track->tag == MKTAG('m','x','4','n') ||\ntrack->tag == MKTAG('m','x','5','p') || track->tag == MKTAG('m','x','5','n')) {",
"if (st->codec->width != 720 || (st->codec->height != 608 && st->codec->height != 512)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"D-10/IMX must use 720x608 or 720x512 video resolution\\n\");",
"goto error;",
"}",
"track->height = track->tag >> 24 == 'n' ? 486 : 576;",
"}",
"track->timescale = st->codec->time_base.den;",
"if (track->mode == MODE_MOV && track->timescale > 100000)\nav_log(VAR_0, AV_LOG_WARNING,\n\"WARNING codec timebase is very high. If duration is too long,\\n\"\n\"file may not be playable by quicktime. Specify a shorter timebase\\n\"\n\"or choose different container.\\n\");",
"} else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {",
"track->timescale = st->codec->sample_rate;",
"if (av_get_bits_per_sample(st->codec->codec_id) ||\nst->codec->codec_id == AV_CODEC_ID_ILBC) {",
"if (!st->codec->block_align) {",
"av_log(VAR_0, AV_LOG_ERROR, \"track %d: codec block align is not set\\n\", VAR_1);",
"goto error;",
"}",
"track->sample_size = st->codec->block_align;",
"}",
"if (av_get_bits_per_sample(st->codec->codec_id) < 8) {",
"track->audio_vbr = 1;",
"}",
"if (track->mode != MODE_MOV &&\ntrack->enc->codec_id == AV_CODEC_ID_MP3 && track->timescale < 16000) {",
"av_log(VAR_0, AV_LOG_ERROR, \"track %d: muxing mp3 at %dhz is not supported\\n\",\nVAR_1, track->enc->sample_rate);",
"goto error;",
"}",
"} else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {",
"track->timescale = st->codec->time_base.den;",
"} else if (st->codec->codec_type == AVMEDIA_TYPE_DATA) {",
"track->timescale = st->codec->time_base.den;",
"}",
"if (!track->height)\ntrack->height = st->codec->height;",
"if (mov->mode == MODE_ISM)\ntrack->timescale = 10000000;",
"avpriv_set_pts_info(st, 64, 1, track->timescale);",
"if (st->codec->extradata_size) {",
"track->vos_len = st->codec->extradata_size;",
"track->vos_data = av_malloc(track->vos_len);",
"memcpy(track->vos_data, st->codec->extradata, track->vos_len);",
"}",
"}",
"enable_tracks(VAR_0);",
"if (mov->mode == MODE_ISM) {",
"if (!(mov->flags & (FF_MOV_FLAG_FRAG_KEYFRAME |\nFF_MOV_FLAG_FRAG_CUSTOM)) &&\n!mov->max_fragment_duration && !mov->max_fragment_size)\nmov->max_fragment_duration = 5000000;",
"mov->flags |= FF_MOV_FLAG_EMPTY_MOOV | FF_MOV_FLAG_SEPARATE_MOOF;",
"}",
"if (!(mov->flags & FF_MOV_FLAG_FRAGMENT)) {",
"if (mov->flags & FF_MOV_FLAG_FASTSTART)\nmov->reserved_moov_pos = avio_tell(pb);",
"mov_write_mdat_tag(pb, mov);",
"}",
"if (t = av_dict_get(VAR_0->metadata, \"creation_time\", NULL, 0))\nmov->time = ff_iso8601_to_unix_time(t->value);",
"if (mov->time)\nmov->time += 0x7C25B080;",
"if (mov->chapter_track)\nif (mov_create_chapter_track(VAR_0, mov->chapter_track) < 0)\ngoto error;",
"if (mov->flags & FF_MOV_FLAG_RTP_HINT) {",
"for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {",
"AVStream *st = VAR_0->streams[VAR_1];",
"if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||\nst->codec->codec_type == AVMEDIA_TYPE_AUDIO) {",
"ff_mov_init_hinting(VAR_0, VAR_2, VAR_1);",
"VAR_2++;",
"}",
"}",
"}",
"avio_flush(pb);",
"if (mov->flags & FF_MOV_FLAG_ISML)\nmov_write_isml_manifest(pb, mov);",
"if (mov->flags & FF_MOV_FLAG_EMPTY_MOOV) {",
"mov_write_moov_tag(pb, mov, VAR_0);",
"mov->fragments++;",
"}",
"return 0;",
"error:\nmov_free(VAR_0);",
"return -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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
43,
45,
47,
49,
51,
53
],
[
59
],
[
61,
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115,
117
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131,
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
149
],
[
151,
153
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171,
173
],
[
175
],
[
177
],
[
179
],
[
181,
183
],
[
185
],
[
187
],
[
193
],
[
195
],
[
197
],
[
199,
201,
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219,
221,
223,
225,
227
],
[
229
],
[
231
],
[
235,
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
253
],
[
255
],
[
257
],
[
259,
261
],
[
263,
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281,
283
],
[
289,
291
],
[
295
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
315
],
[
319
],
[
323,
325,
327,
329
],
[
331
],
[
333
],
[
337
],
[
339,
341
],
[
343
],
[
345
],
[
349,
351
],
[
353,
355
],
[
359,
361,
363
],
[
367
],
[
371
],
[
373
],
[
375,
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
391
],
[
395,
397
],
[
401
],
[
403
],
[
405
],
[
407
],
[
411
],
[
413,
415
],
[
417
],
[
419
]
] |
20,845 | static void arith2_normalise(ArithCoder *c)
{
while ((c->high >> 15) - (c->low >> 15) < 2) {
if ((c->low ^ c->high) & 0x10000) {
c->high ^= 0x8000;
c->value ^= 0x8000;
c->low ^= 0x8000;
}
c->high = c->high << 8 & 0xFFFFFF | 0xFF;
c->value = c->value << 8 & 0xFFFFFF | bytestream2_get_byte(c->gbc.gB);
c->low = c->low << 8 & 0xFFFFFF;
}
}
| true | FFmpeg | ce81e47c911fcff4f006b3b14b40a396eaa77696 | static void arith2_normalise(ArithCoder *c)
{
while ((c->high >> 15) - (c->low >> 15) < 2) {
if ((c->low ^ c->high) & 0x10000) {
c->high ^= 0x8000;
c->value ^= 0x8000;
c->low ^= 0x8000;
}
c->high = c->high << 8 & 0xFFFFFF | 0xFF;
c->value = c->value << 8 & 0xFFFFFF | bytestream2_get_byte(c->gbc.gB);
c->low = c->low << 8 & 0xFFFFFF;
}
}
| {
"code": [
" c->high = c->high << 8 & 0xFFFFFF | 0xFF;",
" c->value = c->value << 8 & 0xFFFFFF | bytestream2_get_byte(c->gbc.gB);",
" c->low = c->low << 8 & 0xFFFFFF;"
],
"line_no": [
17,
19,
21
]
} | static void FUNC_0(ArithCoder *VAR_0)
{
while ((VAR_0->high >> 15) - (VAR_0->low >> 15) < 2) {
if ((VAR_0->low ^ VAR_0->high) & 0x10000) {
VAR_0->high ^= 0x8000;
VAR_0->value ^= 0x8000;
VAR_0->low ^= 0x8000;
}
VAR_0->high = VAR_0->high << 8 & 0xFFFFFF | 0xFF;
VAR_0->value = VAR_0->value << 8 & 0xFFFFFF | bytestream2_get_byte(VAR_0->gbc.gB);
VAR_0->low = VAR_0->low << 8 & 0xFFFFFF;
}
}
| [
"static void FUNC_0(ArithCoder *VAR_0)\n{",
"while ((VAR_0->high >> 15) - (VAR_0->low >> 15) < 2) {",
"if ((VAR_0->low ^ VAR_0->high) & 0x10000) {",
"VAR_0->high ^= 0x8000;",
"VAR_0->value ^= 0x8000;",
"VAR_0->low ^= 0x8000;",
"}",
"VAR_0->high = VAR_0->high << 8 & 0xFFFFFF | 0xFF;",
"VAR_0->value = VAR_0->value << 8 & 0xFFFFFF | bytestream2_get_byte(VAR_0->gbc.gB);",
"VAR_0->low = VAR_0->low << 8 & 0xFFFFFF;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
20,846 | static int usb_qdev_init(DeviceState *qdev, DeviceInfo *base)
{
USBDevice *dev = DO_UPCAST(USBDevice, qdev, qdev);
USBDeviceInfo *info = DO_UPCAST(USBDeviceInfo, qdev, base);
int rc;
pstrcpy(dev->product_desc, sizeof(dev->product_desc), info->product_desc);
dev->info = info;
dev->auto_attach = 1;
QLIST_INIT(&dev->strings);
rc = usb_claim_port(dev);
if (rc != 0) {
goto err;
}
rc = dev->info->init(dev);
if (rc != 0) {
goto err;
}
if (dev->auto_attach) {
rc = usb_device_attach(dev);
if (rc != 0) {
goto err;
}
}
return 0;
err:
usb_qdev_exit(qdev);
return rc;
}
| true | qemu | db3a5ed7e4422491dac1f83264ebb01f6667ffc8 | static int usb_qdev_init(DeviceState *qdev, DeviceInfo *base)
{
USBDevice *dev = DO_UPCAST(USBDevice, qdev, qdev);
USBDeviceInfo *info = DO_UPCAST(USBDeviceInfo, qdev, base);
int rc;
pstrcpy(dev->product_desc, sizeof(dev->product_desc), info->product_desc);
dev->info = info;
dev->auto_attach = 1;
QLIST_INIT(&dev->strings);
rc = usb_claim_port(dev);
if (rc != 0) {
goto err;
}
rc = dev->info->init(dev);
if (rc != 0) {
goto err;
}
if (dev->auto_attach) {
rc = usb_device_attach(dev);
if (rc != 0) {
goto err;
}
}
return 0;
err:
usb_qdev_exit(qdev);
return rc;
}
| {
"code": [
" goto err;",
" goto err;",
" goto err;",
"err:",
" usb_qdev_exit(qdev);",
" return rc;"
],
"line_no": [
25,
25,
43,
53,
55,
57
]
} | static int FUNC_0(DeviceState *VAR_0, DeviceInfo *VAR_1)
{
USBDevice *dev = DO_UPCAST(USBDevice, VAR_0, VAR_0);
USBDeviceInfo *info = DO_UPCAST(USBDeviceInfo, VAR_0, VAR_1);
int VAR_2;
pstrcpy(dev->product_desc, sizeof(dev->product_desc), info->product_desc);
dev->info = info;
dev->auto_attach = 1;
QLIST_INIT(&dev->strings);
VAR_2 = usb_claim_port(dev);
if (VAR_2 != 0) {
goto err;
}
VAR_2 = dev->info->init(dev);
if (VAR_2 != 0) {
goto err;
}
if (dev->auto_attach) {
VAR_2 = usb_device_attach(dev);
if (VAR_2 != 0) {
goto err;
}
}
return 0;
err:
usb_qdev_exit(VAR_0);
return VAR_2;
}
| [
"static int FUNC_0(DeviceState *VAR_0, DeviceInfo *VAR_1)\n{",
"USBDevice *dev = DO_UPCAST(USBDevice, VAR_0, VAR_0);",
"USBDeviceInfo *info = DO_UPCAST(USBDeviceInfo, VAR_0, VAR_1);",
"int VAR_2;",
"pstrcpy(dev->product_desc, sizeof(dev->product_desc), info->product_desc);",
"dev->info = info;",
"dev->auto_attach = 1;",
"QLIST_INIT(&dev->strings);",
"VAR_2 = usb_claim_port(dev);",
"if (VAR_2 != 0) {",
"goto err;",
"}",
"VAR_2 = dev->info->init(dev);",
"if (VAR_2 != 0) {",
"goto err;",
"}",
"if (dev->auto_attach) {",
"VAR_2 = usb_device_attach(dev);",
"if (VAR_2 != 0) {",
"goto err;",
"}",
"}",
"return 0;",
"err:\nusb_qdev_exit(VAR_0);",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53,
55
],
[
57
],
[
59
]
] |
20,847 | void ff_eval_coefs(int *coefs, const int *refl)
{
int buffer[LPC_ORDER];
int *b1 = buffer;
int *b2 = coefs;
int i, j;
for (i=0; i < LPC_ORDER; i++) {
b1[i] = refl[i] * 16;
for (j=0; j < i; j++)
b1[j] = ((refl[i] * b2[i-j-1]) >> 12) + b2[j];
FFSWAP(int *, b1, b2);
}
for (i=0; i < LPC_ORDER; i++)
coefs[i] >>= 4;
}
| true | FFmpeg | 71da0a5c9750e9fd0c9609470f610d32952923eb | void ff_eval_coefs(int *coefs, const int *refl)
{
int buffer[LPC_ORDER];
int *b1 = buffer;
int *b2 = coefs;
int i, j;
for (i=0; i < LPC_ORDER; i++) {
b1[i] = refl[i] * 16;
for (j=0; j < i; j++)
b1[j] = ((refl[i] * b2[i-j-1]) >> 12) + b2[j];
FFSWAP(int *, b1, b2);
}
for (i=0; i < LPC_ORDER; i++)
coefs[i] >>= 4;
}
| {
"code": [
" b1[j] = ((refl[i] * b2[i-j-1]) >> 12) + b2[j];"
],
"line_no": [
23
]
} | void FUNC_0(int *VAR_0, const int *VAR_1)
{
int VAR_2[LPC_ORDER];
int *VAR_3 = VAR_2;
int *VAR_4 = VAR_0;
int VAR_5, VAR_6;
for (VAR_5=0; VAR_5 < LPC_ORDER; VAR_5++) {
VAR_3[VAR_5] = VAR_1[VAR_5] * 16;
for (VAR_6=0; VAR_6 < VAR_5; VAR_6++)
VAR_3[VAR_6] = ((VAR_1[VAR_5] * VAR_4[VAR_5-VAR_6-1]) >> 12) + VAR_4[VAR_6];
FFSWAP(int *, VAR_3, VAR_4);
}
for (VAR_5=0; VAR_5 < LPC_ORDER; VAR_5++)
VAR_0[VAR_5] >>= 4;
}
| [
"void FUNC_0(int *VAR_0, const int *VAR_1)\n{",
"int VAR_2[LPC_ORDER];",
"int *VAR_3 = VAR_2;",
"int *VAR_4 = VAR_0;",
"int VAR_5, VAR_6;",
"for (VAR_5=0; VAR_5 < LPC_ORDER; VAR_5++) {",
"VAR_3[VAR_5] = VAR_1[VAR_5] * 16;",
"for (VAR_6=0; VAR_6 < VAR_5; VAR_6++)",
"VAR_3[VAR_6] = ((VAR_1[VAR_5] * VAR_4[VAR_5-VAR_6-1]) >> 12) + VAR_4[VAR_6];",
"FFSWAP(int *, VAR_3, VAR_4);",
"}",
"for (VAR_5=0; VAR_5 < LPC_ORDER; VAR_5++)",
"VAR_0[VAR_5] >>= 4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
]
] |
20,848 | static int decode_hq_slice(DiracContext *s, DiracSlice *slice, uint8_t *tmp_buf)
{
int i, level, orientation, quant_idx;
int qfactor[MAX_DWT_LEVELS][4], qoffset[MAX_DWT_LEVELS][4];
GetBitContext *gb = &slice->gb;
SliceCoeffs coeffs_num[MAX_DWT_LEVELS];
skip_bits_long(gb, 8*s->highquality.prefix_bytes);
quant_idx = get_bits(gb, 8);
if (quant_idx > DIRAC_MAX_QUANT_INDEX) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid quantization index - %i\n", quant_idx);
return AVERROR_INVALIDDATA;
}
/* Slice quantization (slice_quantizers() in the specs) */
for (level = 0; level < s->wavelet_depth; level++) {
for (orientation = !!level; orientation < 4; orientation++) {
const int quant = FFMAX(quant_idx - s->lowdelay.quant[level][orientation], 0);
qfactor[level][orientation] = ff_dirac_qscale_tab[quant];
qoffset[level][orientation] = ff_dirac_qoffset_intra_tab[quant] + 2;
}
}
/* Luma + 2 Chroma planes */
for (i = 0; i < 3; i++) {
int coef_num, coef_par, off = 0;
int64_t length = s->highquality.size_scaler*get_bits(gb, 8);
int64_t bits_end = get_bits_count(gb) + 8*length;
const uint8_t *addr = align_get_bits(gb);
if (length*8 > get_bits_left(gb)) {
av_log(s->avctx, AV_LOG_ERROR, "end too far away\n");
return AVERROR_INVALIDDATA;
}
coef_num = subband_coeffs(s, slice->slice_x, slice->slice_y, i, coeffs_num);
if (s->pshift)
coef_par = ff_dirac_golomb_read_32bit(s->reader_ctx, addr,
length, tmp_buf, coef_num);
else
coef_par = ff_dirac_golomb_read_16bit(s->reader_ctx, addr,
length, tmp_buf, coef_num);
if (coef_num > coef_par) {
const int start_b = coef_par * (1 << (s->pshift + 1));
const int end_b = coef_num * (1 << (s->pshift + 1));
memset(&tmp_buf[start_b], 0, end_b - start_b);
}
for (level = 0; level < s->wavelet_depth; level++) {
const SliceCoeffs *c = &coeffs_num[level];
for (orientation = !!level; orientation < 4; orientation++) {
const SubBand *b1 = &s->plane[i].band[level][orientation];
uint8_t *buf = b1->ibuf + c->top * b1->stride + (c->left << (s->pshift + 1));
/* Change to c->tot_h <= 4 for AVX2 dequantization */
const int qfunc = s->pshift + 2*(c->tot_h <= 2);
s->diracdsp.dequant_subband[qfunc](&tmp_buf[off], buf, b1->stride,
qfactor[level][orientation],
qoffset[level][orientation],
c->tot_v, c->tot_h);
off += c->tot << (s->pshift + 1);
}
}
skip_bits_long(gb, bits_end - get_bits_count(gb));
}
return 0;
}
| true | FFmpeg | b946bd8ef2c7aeee09469a4901182a44f9b67189 | static int decode_hq_slice(DiracContext *s, DiracSlice *slice, uint8_t *tmp_buf)
{
int i, level, orientation, quant_idx;
int qfactor[MAX_DWT_LEVELS][4], qoffset[MAX_DWT_LEVELS][4];
GetBitContext *gb = &slice->gb;
SliceCoeffs coeffs_num[MAX_DWT_LEVELS];
skip_bits_long(gb, 8*s->highquality.prefix_bytes);
quant_idx = get_bits(gb, 8);
if (quant_idx > DIRAC_MAX_QUANT_INDEX) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid quantization index - %i\n", quant_idx);
return AVERROR_INVALIDDATA;
}
for (level = 0; level < s->wavelet_depth; level++) {
for (orientation = !!level; orientation < 4; orientation++) {
const int quant = FFMAX(quant_idx - s->lowdelay.quant[level][orientation], 0);
qfactor[level][orientation] = ff_dirac_qscale_tab[quant];
qoffset[level][orientation] = ff_dirac_qoffset_intra_tab[quant] + 2;
}
}
for (i = 0; i < 3; i++) {
int coef_num, coef_par, off = 0;
int64_t length = s->highquality.size_scaler*get_bits(gb, 8);
int64_t bits_end = get_bits_count(gb) + 8*length;
const uint8_t *addr = align_get_bits(gb);
if (length*8 > get_bits_left(gb)) {
av_log(s->avctx, AV_LOG_ERROR, "end too far away\n");
return AVERROR_INVALIDDATA;
}
coef_num = subband_coeffs(s, slice->slice_x, slice->slice_y, i, coeffs_num);
if (s->pshift)
coef_par = ff_dirac_golomb_read_32bit(s->reader_ctx, addr,
length, tmp_buf, coef_num);
else
coef_par = ff_dirac_golomb_read_16bit(s->reader_ctx, addr,
length, tmp_buf, coef_num);
if (coef_num > coef_par) {
const int start_b = coef_par * (1 << (s->pshift + 1));
const int end_b = coef_num * (1 << (s->pshift + 1));
memset(&tmp_buf[start_b], 0, end_b - start_b);
}
for (level = 0; level < s->wavelet_depth; level++) {
const SliceCoeffs *c = &coeffs_num[level];
for (orientation = !!level; orientation < 4; orientation++) {
const SubBand *b1 = &s->plane[i].band[level][orientation];
uint8_t *buf = b1->ibuf + c->top * b1->stride + (c->left << (s->pshift + 1));
const int qfunc = s->pshift + 2*(c->tot_h <= 2);
s->diracdsp.dequant_subband[qfunc](&tmp_buf[off], buf, b1->stride,
qfactor[level][orientation],
qoffset[level][orientation],
c->tot_v, c->tot_h);
off += c->tot << (s->pshift + 1);
}
}
skip_bits_long(gb, bits_end - get_bits_count(gb));
}
return 0;
}
| {
"code": [
" if (quant_idx > DIRAC_MAX_QUANT_INDEX) {"
],
"line_no": [
21
]
} | static int FUNC_0(DiracContext *VAR_0, DiracSlice *VAR_1, uint8_t *VAR_2)
{
int VAR_3, VAR_4, VAR_5, VAR_6;
int VAR_7[MAX_DWT_LEVELS][4], qoffset[MAX_DWT_LEVELS][4];
GetBitContext *gb = &VAR_1->gb;
SliceCoeffs coeffs_num[MAX_DWT_LEVELS];
skip_bits_long(gb, 8*VAR_0->highquality.prefix_bytes);
VAR_6 = get_bits(gb, 8);
if (VAR_6 > DIRAC_MAX_QUANT_INDEX) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid quantization index - %VAR_3\n", VAR_6);
return AVERROR_INVALIDDATA;
}
for (VAR_4 = 0; VAR_4 < VAR_0->wavelet_depth; VAR_4++) {
for (VAR_5 = !!VAR_4; VAR_5 < 4; VAR_5++) {
const int quant = FFMAX(VAR_6 - VAR_0->lowdelay.quant[VAR_4][VAR_5], 0);
VAR_7[VAR_4][VAR_5] = ff_dirac_qscale_tab[quant];
qoffset[VAR_4][VAR_5] = ff_dirac_qoffset_intra_tab[quant] + 2;
}
}
for (VAR_3 = 0; VAR_3 < 3; VAR_3++) {
int VAR_8, VAR_9, VAR_10 = 0;
int64_t length = VAR_0->highquality.size_scaler*get_bits(gb, 8);
int64_t bits_end = get_bits_count(gb) + 8*length;
const uint8_t *VAR_11 = align_get_bits(gb);
if (length*8 > get_bits_left(gb)) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "end too far away\n");
return AVERROR_INVALIDDATA;
}
VAR_8 = subband_coeffs(VAR_0, VAR_1->slice_x, VAR_1->slice_y, VAR_3, coeffs_num);
if (VAR_0->pshift)
VAR_9 = ff_dirac_golomb_read_32bit(VAR_0->reader_ctx, VAR_11,
length, VAR_2, VAR_8);
else
VAR_9 = ff_dirac_golomb_read_16bit(VAR_0->reader_ctx, VAR_11,
length, VAR_2, VAR_8);
if (VAR_8 > VAR_9) {
const int VAR_12 = VAR_9 * (1 << (VAR_0->pshift + 1));
const int VAR_13 = VAR_8 * (1 << (VAR_0->pshift + 1));
memset(&VAR_2[VAR_12], 0, VAR_13 - VAR_12);
}
for (VAR_4 = 0; VAR_4 < VAR_0->wavelet_depth; VAR_4++) {
const SliceCoeffs *c = &coeffs_num[VAR_4];
for (VAR_5 = !!VAR_4; VAR_5 < 4; VAR_5++) {
const SubBand *b1 = &VAR_0->plane[VAR_3].band[VAR_4][VAR_5];
uint8_t *buf = b1->ibuf + c->top * b1->stride + (c->left << (VAR_0->pshift + 1));
const int qfunc = VAR_0->pshift + 2*(c->tot_h <= 2);
VAR_0->diracdsp.dequant_subband[qfunc](&VAR_2[VAR_10], buf, b1->stride,
VAR_7[VAR_4][VAR_5],
qoffset[VAR_4][VAR_5],
c->tot_v, c->tot_h);
VAR_10 += c->tot << (VAR_0->pshift + 1);
}
}
skip_bits_long(gb, bits_end - get_bits_count(gb));
}
return 0;
}
| [
"static int FUNC_0(DiracContext *VAR_0, DiracSlice *VAR_1, uint8_t *VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5, VAR_6;",
"int VAR_7[MAX_DWT_LEVELS][4], qoffset[MAX_DWT_LEVELS][4];",
"GetBitContext *gb = &VAR_1->gb;",
"SliceCoeffs coeffs_num[MAX_DWT_LEVELS];",
"skip_bits_long(gb, 8*VAR_0->highquality.prefix_bytes);",
"VAR_6 = get_bits(gb, 8);",
"if (VAR_6 > DIRAC_MAX_QUANT_INDEX) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid quantization index - %VAR_3\\n\", VAR_6);",
"return AVERROR_INVALIDDATA;",
"}",
"for (VAR_4 = 0; VAR_4 < VAR_0->wavelet_depth; VAR_4++) {",
"for (VAR_5 = !!VAR_4; VAR_5 < 4; VAR_5++) {",
"const int quant = FFMAX(VAR_6 - VAR_0->lowdelay.quant[VAR_4][VAR_5], 0);",
"VAR_7[VAR_4][VAR_5] = ff_dirac_qscale_tab[quant];",
"qoffset[VAR_4][VAR_5] = ff_dirac_qoffset_intra_tab[quant] + 2;",
"}",
"}",
"for (VAR_3 = 0; VAR_3 < 3; VAR_3++) {",
"int VAR_8, VAR_9, VAR_10 = 0;",
"int64_t length = VAR_0->highquality.size_scaler*get_bits(gb, 8);",
"int64_t bits_end = get_bits_count(gb) + 8*length;",
"const uint8_t *VAR_11 = align_get_bits(gb);",
"if (length*8 > get_bits_left(gb)) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"end too far away\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_8 = subband_coeffs(VAR_0, VAR_1->slice_x, VAR_1->slice_y, VAR_3, coeffs_num);",
"if (VAR_0->pshift)\nVAR_9 = ff_dirac_golomb_read_32bit(VAR_0->reader_ctx, VAR_11,\nlength, VAR_2, VAR_8);",
"else\nVAR_9 = ff_dirac_golomb_read_16bit(VAR_0->reader_ctx, VAR_11,\nlength, VAR_2, VAR_8);",
"if (VAR_8 > VAR_9) {",
"const int VAR_12 = VAR_9 * (1 << (VAR_0->pshift + 1));",
"const int VAR_13 = VAR_8 * (1 << (VAR_0->pshift + 1));",
"memset(&VAR_2[VAR_12], 0, VAR_13 - VAR_12);",
"}",
"for (VAR_4 = 0; VAR_4 < VAR_0->wavelet_depth; VAR_4++) {",
"const SliceCoeffs *c = &coeffs_num[VAR_4];",
"for (VAR_5 = !!VAR_4; VAR_5 < 4; VAR_5++) {",
"const SubBand *b1 = &VAR_0->plane[VAR_3].band[VAR_4][VAR_5];",
"uint8_t *buf = b1->ibuf + c->top * b1->stride + (c->left << (VAR_0->pshift + 1));",
"const int qfunc = VAR_0->pshift + 2*(c->tot_h <= 2);",
"VAR_0->diracdsp.dequant_subband[qfunc](&VAR_2[VAR_10], buf, b1->stride,\nVAR_7[VAR_4][VAR_5],\nqoffset[VAR_4][VAR_5],\nc->tot_v, c->tot_h);",
"VAR_10 += c->tot << (VAR_0->pshift + 1);",
"}",
"}",
"skip_bits_long(gb, bits_end - get_bits_count(gb));",
"}",
"return 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
77,
79,
81
],
[
83,
85,
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
117
],
[
119,
121,
123,
125
],
[
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
143
],
[
145
]
] |
20,849 | static int ff_h261_resync(H261Context *h){
MpegEncContext * const s = &h->s;
int left, ret;
if(show_bits(&s->gb, 15)==0){
ret= h261_decode_gob_header(h);
if(ret>=0)
return 0;
}
//ok, its not where its supposed to be ...
s->gb= s->last_resync_gb;
align_get_bits(&s->gb);
left= s->gb.size_in_bits - get_bits_count(&s->gb);
for(;left>15+1+4+5; left-=8){
if(show_bits(&s->gb, 15)==0){
GetBitContext bak= s->gb;
ret= h261_decode_gob_header(h);
if(ret>=0)
return 0;
s->gb= bak;
}
skip_bits(&s->gb, 8);
}
return -1;
}
| true | FFmpeg | 49e5dcbce5f9e08ec375fd54c413148beb81f1d7 | static int ff_h261_resync(H261Context *h){
MpegEncContext * const s = &h->s;
int left, ret;
if(show_bits(&s->gb, 15)==0){
ret= h261_decode_gob_header(h);
if(ret>=0)
return 0;
}
s->gb= s->last_resync_gb;
align_get_bits(&s->gb);
left= s->gb.size_in_bits - get_bits_count(&s->gb);
for(;left>15+1+4+5; left-=8){
if(show_bits(&s->gb, 15)==0){
GetBitContext bak= s->gb;
ret= h261_decode_gob_header(h);
if(ret>=0)
return 0;
s->gb= bak;
}
skip_bits(&s->gb, 8);
}
return -1;
}
| {
"code": [
" if(show_bits(&s->gb, 15)==0){",
" s->gb= s->last_resync_gb;",
" align_get_bits(&s->gb);",
" left= s->gb.size_in_bits - get_bits_count(&s->gb);",
" for(;left>15+1+4+5; left-=8){",
" GetBitContext bak= s->gb;",
" s->gb= bak;",
" skip_bits(&s->gb, 8);"
],
"line_no": [
9,
21,
23,
25,
29,
33,
45,
49
]
} | static int FUNC_0(H261Context *VAR_0){
MpegEncContext * const s = &VAR_0->s;
int VAR_1, VAR_2;
if(show_bits(&s->gb, 15)==0){
VAR_2= h261_decode_gob_header(VAR_0);
if(VAR_2>=0)
return 0;
}
s->gb= s->last_resync_gb;
align_get_bits(&s->gb);
VAR_1= s->gb.size_in_bits - get_bits_count(&s->gb);
for(;VAR_1>15+1+4+5; VAR_1-=8){
if(show_bits(&s->gb, 15)==0){
GetBitContext bak= s->gb;
VAR_2= h261_decode_gob_header(VAR_0);
if(VAR_2>=0)
return 0;
s->gb= bak;
}
skip_bits(&s->gb, 8);
}
return -1;
}
| [
"static int FUNC_0(H261Context *VAR_0){",
"MpegEncContext * const s = &VAR_0->s;",
"int VAR_1, VAR_2;",
"if(show_bits(&s->gb, 15)==0){",
"VAR_2= h261_decode_gob_header(VAR_0);",
"if(VAR_2>=0)\nreturn 0;",
"}",
"s->gb= s->last_resync_gb;",
"align_get_bits(&s->gb);",
"VAR_1= s->gb.size_in_bits - get_bits_count(&s->gb);",
"for(;VAR_1>15+1+4+5; VAR_1-=8){",
"if(show_bits(&s->gb, 15)==0){",
"GetBitContext bak= s->gb;",
"VAR_2= h261_decode_gob_header(VAR_0);",
"if(VAR_2>=0)\nreturn 0;",
"s->gb= bak;",
"}",
"skip_bits(&s->gb, 8);",
"}",
"return -1;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
1,
1,
1,
1,
0,
1,
0,
0,
1,
0,
1,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
9
],
[
11
],
[
13,
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39,
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
]
] |
20,850 | static int epic_decode_tile(ePICContext *dc, uint8_t *out, int tile_height,
int tile_width, int stride)
{
int x, y;
uint32_t pix;
uint32_t *curr_row = NULL, *above_row = NULL, *above2_row;
for (y = 0; y < tile_height; y++, out += stride) {
above2_row = above_row;
above_row = curr_row;
curr_row = (uint32_t *) out;
for (x = 0, dc->next_run_pos = 0; x < tile_width;) {
if (dc->els_ctx.err)
return AVERROR_INVALIDDATA; // bail out in the case of ELS overflow
pix = curr_row[x - 1]; // get W pixel
if (y >= 1 && x >= 2 &&
pix != curr_row[x - 2] && pix != above_row[x - 1] &&
pix != above_row[x - 2] && pix != above_row[x] &&
!epic_cache_entries_for_pixel(&dc->hash, pix)) {
curr_row[x] = epic_decode_pixel_pred(dc, x, y, curr_row, above_row);
x++;
} else {
int got_pixel, run;
dc->stack_pos = 0; // empty stack
if (y < 2 || x < 2 || x == tile_width - 1) {
run = 1;
got_pixel = epic_handle_edges(dc, x, y, curr_row, above_row, &pix);
} else
got_pixel = epic_decode_run_length(dc, x, y, tile_width,
curr_row, above_row,
above2_row, &pix, &run);
if (!got_pixel && !epic_predict_from_NW_NE(dc, x, y, run,
tile_width, curr_row,
above_row, &pix)) {
uint32_t ref_pix = curr_row[x - 1];
if (!x || !epic_decode_from_cache(dc, ref_pix, &pix)) {
pix = epic_decode_pixel_pred(dc, x, y, curr_row, above_row);
if (x) {
int ret = epic_add_pixel_to_cache(&dc->hash,
ref_pix,
pix);
if (ret)
return ret;
}
}
}
for (; run > 0; x++, run--)
curr_row[x] = pix;
}
}
}
return 0;
}
| true | FFmpeg | 030c7f0309ec0e3cadb990408b4bb9b7fd739425 | static int epic_decode_tile(ePICContext *dc, uint8_t *out, int tile_height,
int tile_width, int stride)
{
int x, y;
uint32_t pix;
uint32_t *curr_row = NULL, *above_row = NULL, *above2_row;
for (y = 0; y < tile_height; y++, out += stride) {
above2_row = above_row;
above_row = curr_row;
curr_row = (uint32_t *) out;
for (x = 0, dc->next_run_pos = 0; x < tile_width;) {
if (dc->els_ctx.err)
return AVERROR_INVALIDDATA;
pix = curr_row[x - 1];
if (y >= 1 && x >= 2 &&
pix != curr_row[x - 2] && pix != above_row[x - 1] &&
pix != above_row[x - 2] && pix != above_row[x] &&
!epic_cache_entries_for_pixel(&dc->hash, pix)) {
curr_row[x] = epic_decode_pixel_pred(dc, x, y, curr_row, above_row);
x++;
} else {
int got_pixel, run;
dc->stack_pos = 0;
if (y < 2 || x < 2 || x == tile_width - 1) {
run = 1;
got_pixel = epic_handle_edges(dc, x, y, curr_row, above_row, &pix);
} else
got_pixel = epic_decode_run_length(dc, x, y, tile_width,
curr_row, above_row,
above2_row, &pix, &run);
if (!got_pixel && !epic_predict_from_NW_NE(dc, x, y, run,
tile_width, curr_row,
above_row, &pix)) {
uint32_t ref_pix = curr_row[x - 1];
if (!x || !epic_decode_from_cache(dc, ref_pix, &pix)) {
pix = epic_decode_pixel_pred(dc, x, y, curr_row, above_row);
if (x) {
int ret = epic_add_pixel_to_cache(&dc->hash,
ref_pix,
pix);
if (ret)
return ret;
}
}
}
for (; run > 0; x++, run--)
curr_row[x] = pix;
}
}
}
return 0;
}
| {
"code": [
" } else"
],
"line_no": [
63
]
} | static int FUNC_0(ePICContext *VAR_0, uint8_t *VAR_1, int VAR_2,
int VAR_3, int VAR_4)
{
int VAR_5, VAR_6;
uint32_t pix;
uint32_t *curr_row = NULL, *above_row = NULL, *above2_row;
for (VAR_6 = 0; VAR_6 < VAR_2; VAR_6++, VAR_1 += VAR_4) {
above2_row = above_row;
above_row = curr_row;
curr_row = (uint32_t *) VAR_1;
for (VAR_5 = 0, VAR_0->next_run_pos = 0; VAR_5 < VAR_3;) {
if (VAR_0->els_ctx.err)
return AVERROR_INVALIDDATA;
pix = curr_row[VAR_5 - 1];
if (VAR_6 >= 1 && VAR_5 >= 2 &&
pix != curr_row[VAR_5 - 2] && pix != above_row[VAR_5 - 1] &&
pix != above_row[VAR_5 - 2] && pix != above_row[VAR_5] &&
!epic_cache_entries_for_pixel(&VAR_0->hash, pix)) {
curr_row[VAR_5] = epic_decode_pixel_pred(VAR_0, VAR_5, VAR_6, curr_row, above_row);
VAR_5++;
} else {
int VAR_7, VAR_8;
VAR_0->stack_pos = 0;
if (VAR_6 < 2 || VAR_5 < 2 || VAR_5 == VAR_3 - 1) {
VAR_8 = 1;
VAR_7 = epic_handle_edges(VAR_0, VAR_5, VAR_6, curr_row, above_row, &pix);
} else
VAR_7 = epic_decode_run_length(VAR_0, VAR_5, VAR_6, VAR_3,
curr_row, above_row,
above2_row, &pix, &VAR_8);
if (!VAR_7 && !epic_predict_from_NW_NE(VAR_0, VAR_5, VAR_6, VAR_8,
VAR_3, curr_row,
above_row, &pix)) {
uint32_t ref_pix = curr_row[VAR_5 - 1];
if (!VAR_5 || !epic_decode_from_cache(VAR_0, ref_pix, &pix)) {
pix = epic_decode_pixel_pred(VAR_0, VAR_5, VAR_6, curr_row, above_row);
if (VAR_5) {
int VAR_9 = epic_add_pixel_to_cache(&VAR_0->hash,
ref_pix,
pix);
if (VAR_9)
return VAR_9;
}
}
}
for (; VAR_8 > 0; VAR_5++, VAR_8--)
curr_row[VAR_5] = pix;
}
}
}
return 0;
}
| [
"static int FUNC_0(ePICContext *VAR_0, uint8_t *VAR_1, int VAR_2,\nint VAR_3, int VAR_4)\n{",
"int VAR_5, VAR_6;",
"uint32_t pix;",
"uint32_t *curr_row = NULL, *above_row = NULL, *above2_row;",
"for (VAR_6 = 0; VAR_6 < VAR_2; VAR_6++, VAR_1 += VAR_4) {",
"above2_row = above_row;",
"above_row = curr_row;",
"curr_row = (uint32_t *) VAR_1;",
"for (VAR_5 = 0, VAR_0->next_run_pos = 0; VAR_5 < VAR_3;) {",
"if (VAR_0->els_ctx.err)\nreturn AVERROR_INVALIDDATA;",
"pix = curr_row[VAR_5 - 1];",
"if (VAR_6 >= 1 && VAR_5 >= 2 &&\npix != curr_row[VAR_5 - 2] && pix != above_row[VAR_5 - 1] &&\npix != above_row[VAR_5 - 2] && pix != above_row[VAR_5] &&\n!epic_cache_entries_for_pixel(&VAR_0->hash, pix)) {",
"curr_row[VAR_5] = epic_decode_pixel_pred(VAR_0, VAR_5, VAR_6, curr_row, above_row);",
"VAR_5++;",
"} else {",
"int VAR_7, VAR_8;",
"VAR_0->stack_pos = 0;",
"if (VAR_6 < 2 || VAR_5 < 2 || VAR_5 == VAR_3 - 1) {",
"VAR_8 = 1;",
"VAR_7 = epic_handle_edges(VAR_0, VAR_5, VAR_6, curr_row, above_row, &pix);",
"} else",
"VAR_7 = epic_decode_run_length(VAR_0, VAR_5, VAR_6, VAR_3,\ncurr_row, above_row,\nabove2_row, &pix, &VAR_8);",
"if (!VAR_7 && !epic_predict_from_NW_NE(VAR_0, VAR_5, VAR_6, VAR_8,\nVAR_3, curr_row,\nabove_row, &pix)) {",
"uint32_t ref_pix = curr_row[VAR_5 - 1];",
"if (!VAR_5 || !epic_decode_from_cache(VAR_0, ref_pix, &pix)) {",
"pix = epic_decode_pixel_pred(VAR_0, VAR_5, VAR_6, curr_row, above_row);",
"if (VAR_5) {",
"int VAR_9 = epic_add_pixel_to_cache(&VAR_0->hash,\nref_pix,\npix);",
"if (VAR_9)\nreturn VAR_9;",
"}",
"}",
"}",
"for (; VAR_8 > 0; VAR_5++, VAR_8--)",
"curr_row[VAR_5] = pix;",
"}",
"}",
"}",
"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
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27,
29
],
[
33
],
[
37,
39,
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
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
],
[
115
],
[
117
]
] |
20,851 | int ff_h264_context_init(H264Context *h)
{
ERContext *er = &h->er;
int mb_array_size = h->mb_height * h->mb_stride;
int y_size = (2 * h->mb_width + 1) * (2 * h->mb_height + 1);
int c_size = h->mb_stride * (h->mb_height + 1);
int yc_size = y_size + 2 * c_size;
int x, y, i;
FF_ALLOCZ_OR_GOTO(h->avctx, h->top_borders[0],
h->mb_width * 16 * 3 * sizeof(uint8_t) * 2, fail)
FF_ALLOCZ_OR_GOTO(h->avctx, h->top_borders[1],
h->mb_width * 16 * 3 * sizeof(uint8_t) * 2, fail)
h->ref_cache[0][scan8[5] + 1] =
h->ref_cache[0][scan8[7] + 1] =
h->ref_cache[0][scan8[13] + 1] =
h->ref_cache[1][scan8[5] + 1] =
h->ref_cache[1][scan8[7] + 1] =
h->ref_cache[1][scan8[13] + 1] = PART_NOT_AVAILABLE;
if (CONFIG_ERROR_RESILIENCE) {
/* init ER */
er->avctx = h->avctx;
er->mecc = &h->mecc;
er->decode_mb = h264_er_decode_mb;
er->opaque = h;
er->quarter_sample = 1;
er->mb_num = h->mb_num;
er->mb_width = h->mb_width;
er->mb_height = h->mb_height;
er->mb_stride = h->mb_stride;
er->b8_stride = h->mb_width * 2 + 1;
// error resilience code looks cleaner with this
FF_ALLOCZ_OR_GOTO(h->avctx, er->mb_index2xy,
(h->mb_num + 1) * sizeof(int), fail);
for (y = 0; y < h->mb_height; y++)
for (x = 0; x < h->mb_width; x++)
er->mb_index2xy[x + y * h->mb_width] = x + y * h->mb_stride;
er->mb_index2xy[h->mb_height * h->mb_width] = (h->mb_height - 1) *
h->mb_stride + h->mb_width;
FF_ALLOCZ_OR_GOTO(h->avctx, er->error_status_table,
mb_array_size * sizeof(uint8_t), fail);
FF_ALLOC_OR_GOTO(h->avctx, er->mbintra_table, mb_array_size, fail);
memset(er->mbintra_table, 1, mb_array_size);
FF_ALLOCZ_OR_GOTO(h->avctx, er->mbskip_table, mb_array_size + 2, fail);
FF_ALLOC_OR_GOTO(h->avctx, er->er_temp_buffer,
h->mb_height * h->mb_stride, fail);
FF_ALLOCZ_OR_GOTO(h->avctx, h->dc_val_base,
yc_size * sizeof(int16_t), fail);
er->dc_val[0] = h->dc_val_base + h->mb_width * 2 + 2;
er->dc_val[1] = h->dc_val_base + y_size + h->mb_stride + 1;
er->dc_val[2] = er->dc_val[1] + c_size;
for (i = 0; i < yc_size; i++)
h->dc_val_base[i] = 1024;
}
return 0;
fail:
return AVERROR(ENOMEM); // ff_h264_free_tables will clean up for us
}
| false | FFmpeg | cf1e0786ed64e69614760bfb4ecd7adbde8e6094 | int ff_h264_context_init(H264Context *h)
{
ERContext *er = &h->er;
int mb_array_size = h->mb_height * h->mb_stride;
int y_size = (2 * h->mb_width + 1) * (2 * h->mb_height + 1);
int c_size = h->mb_stride * (h->mb_height + 1);
int yc_size = y_size + 2 * c_size;
int x, y, i;
FF_ALLOCZ_OR_GOTO(h->avctx, h->top_borders[0],
h->mb_width * 16 * 3 * sizeof(uint8_t) * 2, fail)
FF_ALLOCZ_OR_GOTO(h->avctx, h->top_borders[1],
h->mb_width * 16 * 3 * sizeof(uint8_t) * 2, fail)
h->ref_cache[0][scan8[5] + 1] =
h->ref_cache[0][scan8[7] + 1] =
h->ref_cache[0][scan8[13] + 1] =
h->ref_cache[1][scan8[5] + 1] =
h->ref_cache[1][scan8[7] + 1] =
h->ref_cache[1][scan8[13] + 1] = PART_NOT_AVAILABLE;
if (CONFIG_ERROR_RESILIENCE) {
er->avctx = h->avctx;
er->mecc = &h->mecc;
er->decode_mb = h264_er_decode_mb;
er->opaque = h;
er->quarter_sample = 1;
er->mb_num = h->mb_num;
er->mb_width = h->mb_width;
er->mb_height = h->mb_height;
er->mb_stride = h->mb_stride;
er->b8_stride = h->mb_width * 2 + 1;
FF_ALLOCZ_OR_GOTO(h->avctx, er->mb_index2xy,
(h->mb_num + 1) * sizeof(int), fail);
for (y = 0; y < h->mb_height; y++)
for (x = 0; x < h->mb_width; x++)
er->mb_index2xy[x + y * h->mb_width] = x + y * h->mb_stride;
er->mb_index2xy[h->mb_height * h->mb_width] = (h->mb_height - 1) *
h->mb_stride + h->mb_width;
FF_ALLOCZ_OR_GOTO(h->avctx, er->error_status_table,
mb_array_size * sizeof(uint8_t), fail);
FF_ALLOC_OR_GOTO(h->avctx, er->mbintra_table, mb_array_size, fail);
memset(er->mbintra_table, 1, mb_array_size);
FF_ALLOCZ_OR_GOTO(h->avctx, er->mbskip_table, mb_array_size + 2, fail);
FF_ALLOC_OR_GOTO(h->avctx, er->er_temp_buffer,
h->mb_height * h->mb_stride, fail);
FF_ALLOCZ_OR_GOTO(h->avctx, h->dc_val_base,
yc_size * sizeof(int16_t), fail);
er->dc_val[0] = h->dc_val_base + h->mb_width * 2 + 2;
er->dc_val[1] = h->dc_val_base + y_size + h->mb_stride + 1;
er->dc_val[2] = er->dc_val[1] + c_size;
for (i = 0; i < yc_size; i++)
h->dc_val_base[i] = 1024;
}
return 0;
fail:
return AVERROR(ENOMEM);
}
| {
"code": [],
"line_no": []
} | int FUNC_0(H264Context *VAR_0)
{
ERContext *er = &VAR_0->er;
int VAR_1 = VAR_0->mb_height * VAR_0->mb_stride;
int VAR_2 = (2 * VAR_0->mb_width + 1) * (2 * VAR_0->mb_height + 1);
int VAR_3 = VAR_0->mb_stride * (VAR_0->mb_height + 1);
int VAR_4 = VAR_2 + 2 * VAR_3;
int VAR_5, VAR_6, VAR_7;
FF_ALLOCZ_OR_GOTO(VAR_0->avctx, VAR_0->top_borders[0],
VAR_0->mb_width * 16 * 3 * sizeof(uint8_t) * 2, fail)
FF_ALLOCZ_OR_GOTO(VAR_0->avctx, VAR_0->top_borders[1],
VAR_0->mb_width * 16 * 3 * sizeof(uint8_t) * 2, fail)
VAR_0->ref_cache[0][scan8[5] + 1] =
VAR_0->ref_cache[0][scan8[7] + 1] =
VAR_0->ref_cache[0][scan8[13] + 1] =
VAR_0->ref_cache[1][scan8[5] + 1] =
VAR_0->ref_cache[1][scan8[7] + 1] =
VAR_0->ref_cache[1][scan8[13] + 1] = PART_NOT_AVAILABLE;
if (CONFIG_ERROR_RESILIENCE) {
er->avctx = VAR_0->avctx;
er->mecc = &VAR_0->mecc;
er->decode_mb = h264_er_decode_mb;
er->opaque = VAR_0;
er->quarter_sample = 1;
er->mb_num = VAR_0->mb_num;
er->mb_width = VAR_0->mb_width;
er->mb_height = VAR_0->mb_height;
er->mb_stride = VAR_0->mb_stride;
er->b8_stride = VAR_0->mb_width * 2 + 1;
FF_ALLOCZ_OR_GOTO(VAR_0->avctx, er->mb_index2xy,
(VAR_0->mb_num + 1) * sizeof(int), fail);
for (VAR_6 = 0; VAR_6 < VAR_0->mb_height; VAR_6++)
for (VAR_5 = 0; VAR_5 < VAR_0->mb_width; VAR_5++)
er->mb_index2xy[VAR_5 + VAR_6 * VAR_0->mb_width] = VAR_5 + VAR_6 * VAR_0->mb_stride;
er->mb_index2xy[VAR_0->mb_height * VAR_0->mb_width] = (VAR_0->mb_height - 1) *
VAR_0->mb_stride + VAR_0->mb_width;
FF_ALLOCZ_OR_GOTO(VAR_0->avctx, er->error_status_table,
VAR_1 * sizeof(uint8_t), fail);
FF_ALLOC_OR_GOTO(VAR_0->avctx, er->mbintra_table, VAR_1, fail);
memset(er->mbintra_table, 1, VAR_1);
FF_ALLOCZ_OR_GOTO(VAR_0->avctx, er->mbskip_table, VAR_1 + 2, fail);
FF_ALLOC_OR_GOTO(VAR_0->avctx, er->er_temp_buffer,
VAR_0->mb_height * VAR_0->mb_stride, fail);
FF_ALLOCZ_OR_GOTO(VAR_0->avctx, VAR_0->dc_val_base,
VAR_4 * sizeof(int16_t), fail);
er->dc_val[0] = VAR_0->dc_val_base + VAR_0->mb_width * 2 + 2;
er->dc_val[1] = VAR_0->dc_val_base + VAR_2 + VAR_0->mb_stride + 1;
er->dc_val[2] = er->dc_val[1] + VAR_3;
for (VAR_7 = 0; VAR_7 < VAR_4; VAR_7++)
VAR_0->dc_val_base[VAR_7] = 1024;
}
return 0;
fail:
return AVERROR(ENOMEM);
}
| [
"int FUNC_0(H264Context *VAR_0)\n{",
"ERContext *er = &VAR_0->er;",
"int VAR_1 = VAR_0->mb_height * VAR_0->mb_stride;",
"int VAR_2 = (2 * VAR_0->mb_width + 1) * (2 * VAR_0->mb_height + 1);",
"int VAR_3 = VAR_0->mb_stride * (VAR_0->mb_height + 1);",
"int VAR_4 = VAR_2 + 2 * VAR_3;",
"int VAR_5, VAR_6, VAR_7;",
"FF_ALLOCZ_OR_GOTO(VAR_0->avctx, VAR_0->top_borders[0],\nVAR_0->mb_width * 16 * 3 * sizeof(uint8_t) * 2, fail)\nFF_ALLOCZ_OR_GOTO(VAR_0->avctx, VAR_0->top_borders[1],\nVAR_0->mb_width * 16 * 3 * sizeof(uint8_t) * 2, fail)\nVAR_0->ref_cache[0][scan8[5] + 1] =\nVAR_0->ref_cache[0][scan8[7] + 1] =\nVAR_0->ref_cache[0][scan8[13] + 1] =\nVAR_0->ref_cache[1][scan8[5] + 1] =\nVAR_0->ref_cache[1][scan8[7] + 1] =\nVAR_0->ref_cache[1][scan8[13] + 1] = PART_NOT_AVAILABLE;",
"if (CONFIG_ERROR_RESILIENCE) {",
"er->avctx = VAR_0->avctx;",
"er->mecc = &VAR_0->mecc;",
"er->decode_mb = h264_er_decode_mb;",
"er->opaque = VAR_0;",
"er->quarter_sample = 1;",
"er->mb_num = VAR_0->mb_num;",
"er->mb_width = VAR_0->mb_width;",
"er->mb_height = VAR_0->mb_height;",
"er->mb_stride = VAR_0->mb_stride;",
"er->b8_stride = VAR_0->mb_width * 2 + 1;",
"FF_ALLOCZ_OR_GOTO(VAR_0->avctx, er->mb_index2xy,\n(VAR_0->mb_num + 1) * sizeof(int), fail);",
"for (VAR_6 = 0; VAR_6 < VAR_0->mb_height; VAR_6++)",
"for (VAR_5 = 0; VAR_5 < VAR_0->mb_width; VAR_5++)",
"er->mb_index2xy[VAR_5 + VAR_6 * VAR_0->mb_width] = VAR_5 + VAR_6 * VAR_0->mb_stride;",
"er->mb_index2xy[VAR_0->mb_height * VAR_0->mb_width] = (VAR_0->mb_height - 1) *\nVAR_0->mb_stride + VAR_0->mb_width;",
"FF_ALLOCZ_OR_GOTO(VAR_0->avctx, er->error_status_table,\nVAR_1 * sizeof(uint8_t), fail);",
"FF_ALLOC_OR_GOTO(VAR_0->avctx, er->mbintra_table, VAR_1, fail);",
"memset(er->mbintra_table, 1, VAR_1);",
"FF_ALLOCZ_OR_GOTO(VAR_0->avctx, er->mbskip_table, VAR_1 + 2, fail);",
"FF_ALLOC_OR_GOTO(VAR_0->avctx, er->er_temp_buffer,\nVAR_0->mb_height * VAR_0->mb_stride, fail);",
"FF_ALLOCZ_OR_GOTO(VAR_0->avctx, VAR_0->dc_val_base,\nVAR_4 * sizeof(int16_t), fail);",
"er->dc_val[0] = VAR_0->dc_val_base + VAR_0->mb_width * 2 + 2;",
"er->dc_val[1] = VAR_0->dc_val_base + VAR_2 + VAR_0->mb_stride + 1;",
"er->dc_val[2] = er->dc_val[1] + VAR_3;",
"for (VAR_7 = 0; VAR_7 < VAR_4; VAR_7++)",
"VAR_0->dc_val_base[VAR_7] = 1024;",
"}",
"return 0;",
"fail:\nreturn AVERROR(ENOMEM);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21,
23,
25,
29,
31,
33,
35,
37,
39
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
73,
75
],
[
79
],
[
81
],
[
83
],
[
87,
89
],
[
93,
95
],
[
99
],
[
101
],
[
105
],
[
109,
111
],
[
115,
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
137,
139
],
[
141
]
] |
20,852 | static int thp_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
ThpDemuxContext *thp = s->priv_data;
AVIOContext *pb = s->pb;
unsigned int size;
int ret;
if (thp->audiosize == 0) {
/* Terminate when last frame is reached. */
if (thp->frame >= thp->framecnt)
return AVERROR_EOF;
avio_seek(pb, thp->next_frame, SEEK_SET);
/* Locate the next frame and read out its size. */
thp->next_frame += thp->next_framesz;
thp->next_framesz = avio_rb32(pb);
avio_rb32(pb); /* Previous total size. */
size = avio_rb32(pb); /* Total size of this frame. */
/* Store the audiosize so the next time this function is called,
the audio can be read. */
if (thp->has_audio)
thp->audiosize = avio_rb32(pb); /* Audio size. */
else
thp->frame++;
ret = av_get_packet(pb, pkt, size);
if (ret != size) {
av_free_packet(pkt);
return AVERROR(EIO);
}
pkt->stream_index = thp->video_stream_index;
} else {
ret = av_get_packet(pb, pkt, thp->audiosize);
if (ret != thp->audiosize) {
av_free_packet(pkt);
return AVERROR(EIO);
}
pkt->stream_index = thp->audio_stream_index;
if (thp->audiosize >= 8)
pkt->duration = AV_RB32(&pkt->data[4]);
thp->audiosize = 0;
thp->frame++;
}
return 0;
}
| false | FFmpeg | 6c4b87d3d6ae08a6da16b4616626b4d2a726afbf | static int thp_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
ThpDemuxContext *thp = s->priv_data;
AVIOContext *pb = s->pb;
unsigned int size;
int ret;
if (thp->audiosize == 0) {
if (thp->frame >= thp->framecnt)
return AVERROR_EOF;
avio_seek(pb, thp->next_frame, SEEK_SET);
thp->next_frame += thp->next_framesz;
thp->next_framesz = avio_rb32(pb);
avio_rb32(pb);
size = avio_rb32(pb);
if (thp->has_audio)
thp->audiosize = avio_rb32(pb);
else
thp->frame++;
ret = av_get_packet(pb, pkt, size);
if (ret != size) {
av_free_packet(pkt);
return AVERROR(EIO);
}
pkt->stream_index = thp->video_stream_index;
} else {
ret = av_get_packet(pb, pkt, thp->audiosize);
if (ret != thp->audiosize) {
av_free_packet(pkt);
return AVERROR(EIO);
}
pkt->stream_index = thp->audio_stream_index;
if (thp->audiosize >= 8)
pkt->duration = AV_RB32(&pkt->data[4]);
thp->audiosize = 0;
thp->frame++;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0,
AVPacket *VAR_1)
{
ThpDemuxContext *thp = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
unsigned int VAR_2;
int VAR_3;
if (thp->audiosize == 0) {
if (thp->frame >= thp->framecnt)
return AVERROR_EOF;
avio_seek(pb, thp->next_frame, SEEK_SET);
thp->next_frame += thp->next_framesz;
thp->next_framesz = avio_rb32(pb);
avio_rb32(pb);
VAR_2 = avio_rb32(pb);
if (thp->has_audio)
thp->audiosize = avio_rb32(pb);
else
thp->frame++;
VAR_3 = av_get_packet(pb, VAR_1, VAR_2);
if (VAR_3 != VAR_2) {
av_free_packet(VAR_1);
return AVERROR(EIO);
}
VAR_1->stream_index = thp->video_stream_index;
} else {
VAR_3 = av_get_packet(pb, VAR_1, thp->audiosize);
if (VAR_3 != thp->audiosize) {
av_free_packet(VAR_1);
return AVERROR(EIO);
}
VAR_1->stream_index = thp->audio_stream_index;
if (thp->audiosize >= 8)
VAR_1->duration = AV_RB32(&VAR_1->data[4]);
thp->audiosize = 0;
thp->frame++;
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0,\nAVPacket *VAR_1)\n{",
"ThpDemuxContext *thp = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"unsigned int VAR_2;",
"int VAR_3;",
"if (thp->audiosize == 0) {",
"if (thp->frame >= thp->framecnt)\nreturn AVERROR_EOF;",
"avio_seek(pb, thp->next_frame, SEEK_SET);",
"thp->next_frame += thp->next_framesz;",
"thp->next_framesz = avio_rb32(pb);",
"avio_rb32(pb);",
"VAR_2 = avio_rb32(pb);",
"if (thp->has_audio)\nthp->audiosize = avio_rb32(pb);",
"else\nthp->frame++;",
"VAR_3 = av_get_packet(pb, VAR_1, VAR_2);",
"if (VAR_3 != VAR_2) {",
"av_free_packet(VAR_1);",
"return AVERROR(EIO);",
"}",
"VAR_1->stream_index = thp->video_stream_index;",
"} else {",
"VAR_3 = av_get_packet(pb, VAR_1, thp->audiosize);",
"if (VAR_3 != thp->audiosize) {",
"av_free_packet(VAR_1);",
"return AVERROR(EIO);",
"}",
"VAR_1->stream_index = thp->audio_stream_index;",
"if (thp->audiosize >= 8)\nVAR_1->duration = AV_RB32(&VAR_1->data[4]);",
"thp->audiosize = 0;",
"thp->frame++;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21,
23
],
[
27
],
[
33
],
[
35
],
[
39
],
[
41
],
[
49,
51
],
[
53,
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89,
91
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
]
] |
20,853 | static int execute_code(AVCodecContext * avctx, int c)
{
AnsiContext *s = avctx->priv_data;
int ret, i, width, height;
switch(c) {
case 'A': //Cursor Up
s->y = FFMAX(s->y - (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), 0);
break;
case 'B': //Cursor Down
s->y = FFMIN(s->y + (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), avctx->height - s->font_height);
break;
case 'C': //Cursor Right
s->x = FFMIN(s->x + (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), avctx->width - FONT_WIDTH);
break;
case 'D': //Cursor Left
s->x = FFMAX(s->x - (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), 0);
break;
case 'H': //Cursor Position
case 'f': //Horizontal and Vertical Position
s->y = s->nb_args > 0 ? av_clip((s->args[0] - 1)*s->font_height, 0, avctx->height - s->font_height) : 0;
s->x = s->nb_args > 1 ? av_clip((s->args[1] - 1)*FONT_WIDTH, 0, avctx->width - FONT_WIDTH) : 0;
break;
case 'h': //set creen mode
case 'l': //reset screen mode
if (s->nb_args < 2)
s->args[0] = DEFAULT_SCREEN_MODE;
width = avctx->width;
height = avctx->height;
switch(s->args[0]) {
case 0: case 1: case 4: case 5: case 13: case 19: //320x200 (25 rows)
s->font = avpriv_cga_font;
s->font_height = 8;
width = 40<<3;
height = 25<<3;
break;
case 2: case 3: //640x400 (25 rows)
s->font = avpriv_vga16_font;
s->font_height = 16;
width = 80<<3;
height = 25<<4;
break;
case 6: case 14: //640x200 (25 rows)
s->font = avpriv_cga_font;
s->font_height = 8;
width = 80<<3;
height = 25<<3;
break;
case 7: //set line wrapping
break;
case 15: case 16: //640x350 (43 rows)
s->font = avpriv_cga_font;
s->font_height = 8;
width = 80<<3;
height = 43<<3;
break;
case 17: case 18: //640x480 (60 rows)
s->font = avpriv_cga_font;
s->font_height = 8;
width = 80<<3;
height = 60<<4;
break;
default:
av_log_ask_for_sample(avctx, "unsupported screen mode\n");
}
if (width != avctx->width || height != avctx->height) {
if (s->frame.data[0])
avctx->release_buffer(avctx, &s->frame);
avcodec_set_dimensions(avctx, width, height);
ret = avctx->get_buffer(avctx, &s->frame);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
s->frame.pict_type = AV_PICTURE_TYPE_I;
s->frame.palette_has_changed = 1;
set_palette((uint32_t *)s->frame.data[1]);
erase_screen(avctx);
} else if (c == 'l') {
erase_screen(avctx);
}
break;
case 'J': //Erase in Page
switch (s->args[0]) {
case 0:
erase_line(avctx, s->x, avctx->width - s->x);
if (s->y < avctx->height - s->font_height)
memset(s->frame.data[0] + (s->y + s->font_height)*s->frame.linesize[0],
DEFAULT_BG_COLOR, (avctx->height - s->y - s->font_height)*s->frame.linesize[0]);
break;
case 1:
erase_line(avctx, 0, s->x);
if (s->y > 0)
memset(s->frame.data[0], DEFAULT_BG_COLOR, s->y * s->frame.linesize[0]);
break;
case 2:
erase_screen(avctx);
}
break;
case 'K': //Erase in Line
switch(s->args[0]) {
case 0:
erase_line(avctx, s->x, avctx->width - s->x);
break;
case 1:
erase_line(avctx, 0, s->x);
break;
case 2:
erase_line(avctx, 0, avctx->width);
}
break;
case 'm': //Select Graphics Rendition
if (s->nb_args == 0) {
s->nb_args = 1;
s->args[0] = 0;
}
for (i = 0; i < FFMIN(s->nb_args, MAX_NB_ARGS); i++) {
int m = s->args[i];
if (m == 0) {
s->attributes = 0;
s->fg = DEFAULT_FG_COLOR;
s->bg = DEFAULT_BG_COLOR;
} else if (m == 1 || m == 2 || m == 4 || m == 5 || m == 7 || m == 8) {
s->attributes |= 1 << (m - 1);
} else if (m >= 30 && m <= 37) {
s->fg = ansi_to_cga[m - 30];
} else if (m == 38 && i + 2 < s->nb_args && s->args[i + 1] == 5 && s->args[i + 2] < 256) {
int index = s->args[i + 2];
s->fg = index < 16 ? ansi_to_cga[index] : index;
i += 2;
} else if (m == 39) {
s->fg = ansi_to_cga[DEFAULT_FG_COLOR];
} else if (m >= 40 && m <= 47) {
s->bg = ansi_to_cga[m - 40];
} else if (m == 48 && i + 2 < s->nb_args && s->args[i + 1] == 5 && s->args[i + 2] < 256) {
int index = s->args[i + 2];
s->bg = index < 16 ? ansi_to_cga[index] : index;
i += 2;
} else if (m == 49) {
s->fg = ansi_to_cga[DEFAULT_BG_COLOR];
} else {
av_log_ask_for_sample(avctx, "unsupported rendition parameter\n");
}
}
break;
case 'n': //Device Status Report
case 'R': //report current line and column
/* ignore */
break;
case 's': //Save Cursor Position
s->sx = s->x;
s->sy = s->y;
break;
case 'u': //Restore Cursor Position
s->x = av_clip(s->sx, 0, avctx->width - FONT_WIDTH);
s->y = av_clip(s->sy, 0, avctx->height - s->font_height);
break;
default:
av_log_ask_for_sample(avctx, "unsupported escape code\n");
break;
}
return 0;
}
| false | FFmpeg | 0ea55365b91c250012ac8a80be5f0ebacd4fd55d | static int execute_code(AVCodecContext * avctx, int c)
{
AnsiContext *s = avctx->priv_data;
int ret, i, width, height;
switch(c) {
case 'A':
s->y = FFMAX(s->y - (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), 0);
break;
case 'B':
s->y = FFMIN(s->y + (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), avctx->height - s->font_height);
break;
case 'C':
s->x = FFMIN(s->x + (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), avctx->width - FONT_WIDTH);
break;
case 'D':
s->x = FFMAX(s->x - (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), 0);
break;
case 'H':
case 'f':
s->y = s->nb_args > 0 ? av_clip((s->args[0] - 1)*s->font_height, 0, avctx->height - s->font_height) : 0;
s->x = s->nb_args > 1 ? av_clip((s->args[1] - 1)*FONT_WIDTH, 0, avctx->width - FONT_WIDTH) : 0;
break;
case 'h':
case 'l':
if (s->nb_args < 2)
s->args[0] = DEFAULT_SCREEN_MODE;
width = avctx->width;
height = avctx->height;
switch(s->args[0]) {
case 0: case 1: case 4: case 5: case 13: case 19:
s->font = avpriv_cga_font;
s->font_height = 8;
width = 40<<3;
height = 25<<3;
break;
case 2: case 3:
s->font = avpriv_vga16_font;
s->font_height = 16;
width = 80<<3;
height = 25<<4;
break;
case 6: case 14:
s->font = avpriv_cga_font;
s->font_height = 8;
width = 80<<3;
height = 25<<3;
break;
case 7:
break;
case 15: case 16:
s->font = avpriv_cga_font;
s->font_height = 8;
width = 80<<3;
height = 43<<3;
break;
case 17: case 18:
s->font = avpriv_cga_font;
s->font_height = 8;
width = 80<<3;
height = 60<<4;
break;
default:
av_log_ask_for_sample(avctx, "unsupported screen mode\n");
}
if (width != avctx->width || height != avctx->height) {
if (s->frame.data[0])
avctx->release_buffer(avctx, &s->frame);
avcodec_set_dimensions(avctx, width, height);
ret = avctx->get_buffer(avctx, &s->frame);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
s->frame.pict_type = AV_PICTURE_TYPE_I;
s->frame.palette_has_changed = 1;
set_palette((uint32_t *)s->frame.data[1]);
erase_screen(avctx);
} else if (c == 'l') {
erase_screen(avctx);
}
break;
case 'J':
switch (s->args[0]) {
case 0:
erase_line(avctx, s->x, avctx->width - s->x);
if (s->y < avctx->height - s->font_height)
memset(s->frame.data[0] + (s->y + s->font_height)*s->frame.linesize[0],
DEFAULT_BG_COLOR, (avctx->height - s->y - s->font_height)*s->frame.linesize[0]);
break;
case 1:
erase_line(avctx, 0, s->x);
if (s->y > 0)
memset(s->frame.data[0], DEFAULT_BG_COLOR, s->y * s->frame.linesize[0]);
break;
case 2:
erase_screen(avctx);
}
break;
case 'K':
switch(s->args[0]) {
case 0:
erase_line(avctx, s->x, avctx->width - s->x);
break;
case 1:
erase_line(avctx, 0, s->x);
break;
case 2:
erase_line(avctx, 0, avctx->width);
}
break;
case 'm':
if (s->nb_args == 0) {
s->nb_args = 1;
s->args[0] = 0;
}
for (i = 0; i < FFMIN(s->nb_args, MAX_NB_ARGS); i++) {
int m = s->args[i];
if (m == 0) {
s->attributes = 0;
s->fg = DEFAULT_FG_COLOR;
s->bg = DEFAULT_BG_COLOR;
} else if (m == 1 || m == 2 || m == 4 || m == 5 || m == 7 || m == 8) {
s->attributes |= 1 << (m - 1);
} else if (m >= 30 && m <= 37) {
s->fg = ansi_to_cga[m - 30];
} else if (m == 38 && i + 2 < s->nb_args && s->args[i + 1] == 5 && s->args[i + 2] < 256) {
int index = s->args[i + 2];
s->fg = index < 16 ? ansi_to_cga[index] : index;
i += 2;
} else if (m == 39) {
s->fg = ansi_to_cga[DEFAULT_FG_COLOR];
} else if (m >= 40 && m <= 47) {
s->bg = ansi_to_cga[m - 40];
} else if (m == 48 && i + 2 < s->nb_args && s->args[i + 1] == 5 && s->args[i + 2] < 256) {
int index = s->args[i + 2];
s->bg = index < 16 ? ansi_to_cga[index] : index;
i += 2;
} else if (m == 49) {
s->fg = ansi_to_cga[DEFAULT_BG_COLOR];
} else {
av_log_ask_for_sample(avctx, "unsupported rendition parameter\n");
}
}
break;
case 'n':
case 'R':
break;
case 's':
s->sx = s->x;
s->sy = s->y;
break;
case 'u':
s->x = av_clip(s->sx, 0, avctx->width - FONT_WIDTH);
s->y = av_clip(s->sy, 0, avctx->height - s->font_height);
break;
default:
av_log_ask_for_sample(avctx, "unsupported escape code\n");
break;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext * VAR_0, int VAR_1)
{
AnsiContext *s = VAR_0->priv_data;
int VAR_2, VAR_3, VAR_4, VAR_5;
switch(VAR_1) {
case 'A':
s->y = FFMAX(s->y - (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), 0);
break;
case 'B':
s->y = FFMIN(s->y + (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), VAR_0->VAR_5 - s->font_height);
break;
case 'C':
s->x = FFMIN(s->x + (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), VAR_0->VAR_4 - FONT_WIDTH);
break;
case 'D':
s->x = FFMAX(s->x - (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), 0);
break;
case 'H':
case 'f':
s->y = s->nb_args > 0 ? av_clip((s->args[0] - 1)*s->font_height, 0, VAR_0->VAR_5 - s->font_height) : 0;
s->x = s->nb_args > 1 ? av_clip((s->args[1] - 1)*FONT_WIDTH, 0, VAR_0->VAR_4 - FONT_WIDTH) : 0;
break;
case 'h':
case 'l':
if (s->nb_args < 2)
s->args[0] = DEFAULT_SCREEN_MODE;
VAR_4 = VAR_0->VAR_4;
VAR_5 = VAR_0->VAR_5;
switch(s->args[0]) {
case 0: case 1: case 4: case 5: case 13: case 19:
s->font = avpriv_cga_font;
s->font_height = 8;
VAR_4 = 40<<3;
VAR_5 = 25<<3;
break;
case 2: case 3:
s->font = avpriv_vga16_font;
s->font_height = 16;
VAR_4 = 80<<3;
VAR_5 = 25<<4;
break;
case 6: case 14:
s->font = avpriv_cga_font;
s->font_height = 8;
VAR_4 = 80<<3;
VAR_5 = 25<<3;
break;
case 7:
break;
case 15: case 16:
s->font = avpriv_cga_font;
s->font_height = 8;
VAR_4 = 80<<3;
VAR_5 = 43<<3;
break;
case 17: case 18:
s->font = avpriv_cga_font;
s->font_height = 8;
VAR_4 = 80<<3;
VAR_5 = 60<<4;
break;
default:
av_log_ask_for_sample(VAR_0, "unsupported screen mode\n");
}
if (VAR_4 != VAR_0->VAR_4 || VAR_5 != VAR_0->VAR_5) {
if (s->frame.data[0])
VAR_0->release_buffer(VAR_0, &s->frame);
avcodec_set_dimensions(VAR_0, VAR_4, VAR_5);
VAR_2 = VAR_0->get_buffer(VAR_0, &s->frame);
if (VAR_2 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");
return VAR_2;
}
s->frame.pict_type = AV_PICTURE_TYPE_I;
s->frame.palette_has_changed = 1;
set_palette((uint32_t *)s->frame.data[1]);
erase_screen(VAR_0);
} else if (VAR_1 == 'l') {
erase_screen(VAR_0);
}
break;
case 'J':
switch (s->args[0]) {
case 0:
erase_line(VAR_0, s->x, VAR_0->VAR_4 - s->x);
if (s->y < VAR_0->VAR_5 - s->font_height)
memset(s->frame.data[0] + (s->y + s->font_height)*s->frame.linesize[0],
DEFAULT_BG_COLOR, (VAR_0->VAR_5 - s->y - s->font_height)*s->frame.linesize[0]);
break;
case 1:
erase_line(VAR_0, 0, s->x);
if (s->y > 0)
memset(s->frame.data[0], DEFAULT_BG_COLOR, s->y * s->frame.linesize[0]);
break;
case 2:
erase_screen(VAR_0);
}
break;
case 'K':
switch(s->args[0]) {
case 0:
erase_line(VAR_0, s->x, VAR_0->VAR_4 - s->x);
break;
case 1:
erase_line(VAR_0, 0, s->x);
break;
case 2:
erase_line(VAR_0, 0, VAR_0->VAR_4);
}
break;
case 'm':
if (s->nb_args == 0) {
s->nb_args = 1;
s->args[0] = 0;
}
for (VAR_3 = 0; VAR_3 < FFMIN(s->nb_args, MAX_NB_ARGS); VAR_3++) {
int m = s->args[VAR_3];
if (m == 0) {
s->attributes = 0;
s->fg = DEFAULT_FG_COLOR;
s->bg = DEFAULT_BG_COLOR;
} else if (m == 1 || m == 2 || m == 4 || m == 5 || m == 7 || m == 8) {
s->attributes |= 1 << (m - 1);
} else if (m >= 30 && m <= 37) {
s->fg = ansi_to_cga[m - 30];
} else if (m == 38 && VAR_3 + 2 < s->nb_args && s->args[VAR_3 + 1] == 5 && s->args[VAR_3 + 2] < 256) {
int index = s->args[VAR_3 + 2];
s->fg = index < 16 ? ansi_to_cga[index] : index;
VAR_3 += 2;
} else if (m == 39) {
s->fg = ansi_to_cga[DEFAULT_FG_COLOR];
} else if (m >= 40 && m <= 47) {
s->bg = ansi_to_cga[m - 40];
} else if (m == 48 && VAR_3 + 2 < s->nb_args && s->args[VAR_3 + 1] == 5 && s->args[VAR_3 + 2] < 256) {
int index = s->args[VAR_3 + 2];
s->bg = index < 16 ? ansi_to_cga[index] : index;
VAR_3 += 2;
} else if (m == 49) {
s->fg = ansi_to_cga[DEFAULT_BG_COLOR];
} else {
av_log_ask_for_sample(VAR_0, "unsupported rendition parameter\n");
}
}
break;
case 'n':
case 'R':
break;
case 's':
s->sx = s->x;
s->sy = s->y;
break;
case 'u':
s->x = av_clip(s->sx, 0, VAR_0->VAR_4 - FONT_WIDTH);
s->y = av_clip(s->sy, 0, VAR_0->VAR_5 - s->font_height);
break;
default:
av_log_ask_for_sample(VAR_0, "unsupported escape code\n");
break;
}
return 0;
}
| [
"static int FUNC_0(AVCodecContext * VAR_0, int VAR_1)\n{",
"AnsiContext *s = VAR_0->priv_data;",
"int VAR_2, VAR_3, VAR_4, VAR_5;",
"switch(VAR_1) {",
"case 'A':\ns->y = FFMAX(s->y - (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), 0);",
"break;",
"case 'B':\ns->y = FFMIN(s->y + (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), VAR_0->VAR_5 - s->font_height);",
"break;",
"case 'C':\ns->x = FFMIN(s->x + (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), VAR_0->VAR_4 - FONT_WIDTH);",
"break;",
"case 'D':\ns->x = FFMAX(s->x - (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), 0);",
"break;",
"case 'H':\ncase 'f':\ns->y = s->nb_args > 0 ? av_clip((s->args[0] - 1)*s->font_height, 0, VAR_0->VAR_5 - s->font_height) : 0;",
"s->x = s->nb_args > 1 ? av_clip((s->args[1] - 1)*FONT_WIDTH, 0, VAR_0->VAR_4 - FONT_WIDTH) : 0;",
"break;",
"case 'h':\ncase 'l':\nif (s->nb_args < 2)\ns->args[0] = DEFAULT_SCREEN_MODE;",
"VAR_4 = VAR_0->VAR_4;",
"VAR_5 = VAR_0->VAR_5;",
"switch(s->args[0]) {",
"case 0: case 1: case 4: case 5: case 13: case 19:\ns->font = avpriv_cga_font;",
"s->font_height = 8;",
"VAR_4 = 40<<3;",
"VAR_5 = 25<<3;",
"break;",
"case 2: case 3:\ns->font = avpriv_vga16_font;",
"s->font_height = 16;",
"VAR_4 = 80<<3;",
"VAR_5 = 25<<4;",
"break;",
"case 6: case 14:\ns->font = avpriv_cga_font;",
"s->font_height = 8;",
"VAR_4 = 80<<3;",
"VAR_5 = 25<<3;",
"break;",
"case 7:\nbreak;",
"case 15: case 16:\ns->font = avpriv_cga_font;",
"s->font_height = 8;",
"VAR_4 = 80<<3;",
"VAR_5 = 43<<3;",
"break;",
"case 17: case 18:\ns->font = avpriv_cga_font;",
"s->font_height = 8;",
"VAR_4 = 80<<3;",
"VAR_5 = 60<<4;",
"break;",
"default:\nav_log_ask_for_sample(VAR_0, \"unsupported screen mode\\n\");",
"}",
"if (VAR_4 != VAR_0->VAR_4 || VAR_5 != VAR_0->VAR_5) {",
"if (s->frame.data[0])\nVAR_0->release_buffer(VAR_0, &s->frame);",
"avcodec_set_dimensions(VAR_0, VAR_4, VAR_5);",
"VAR_2 = VAR_0->get_buffer(VAR_0, &s->frame);",
"if (VAR_2 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\n\");",
"return VAR_2;",
"}",
"s->frame.pict_type = AV_PICTURE_TYPE_I;",
"s->frame.palette_has_changed = 1;",
"set_palette((uint32_t *)s->frame.data[1]);",
"erase_screen(VAR_0);",
"} else if (VAR_1 == 'l') {",
"erase_screen(VAR_0);",
"}",
"break;",
"case 'J':\nswitch (s->args[0]) {",
"case 0:\nerase_line(VAR_0, s->x, VAR_0->VAR_4 - s->x);",
"if (s->y < VAR_0->VAR_5 - s->font_height)\nmemset(s->frame.data[0] + (s->y + s->font_height)*s->frame.linesize[0],\nDEFAULT_BG_COLOR, (VAR_0->VAR_5 - s->y - s->font_height)*s->frame.linesize[0]);",
"break;",
"case 1:\nerase_line(VAR_0, 0, s->x);",
"if (s->y > 0)\nmemset(s->frame.data[0], DEFAULT_BG_COLOR, s->y * s->frame.linesize[0]);",
"break;",
"case 2:\nerase_screen(VAR_0);",
"}",
"break;",
"case 'K':\nswitch(s->args[0]) {",
"case 0:\nerase_line(VAR_0, s->x, VAR_0->VAR_4 - s->x);",
"break;",
"case 1:\nerase_line(VAR_0, 0, s->x);",
"break;",
"case 2:\nerase_line(VAR_0, 0, VAR_0->VAR_4);",
"}",
"break;",
"case 'm':\nif (s->nb_args == 0) {",
"s->nb_args = 1;",
"s->args[0] = 0;",
"}",
"for (VAR_3 = 0; VAR_3 < FFMIN(s->nb_args, MAX_NB_ARGS); VAR_3++) {",
"int m = s->args[VAR_3];",
"if (m == 0) {",
"s->attributes = 0;",
"s->fg = DEFAULT_FG_COLOR;",
"s->bg = DEFAULT_BG_COLOR;",
"} else if (m == 1 || m == 2 || m == 4 || m == 5 || m == 7 || m == 8) {",
"s->attributes |= 1 << (m - 1);",
"} else if (m >= 30 && m <= 37) {",
"s->fg = ansi_to_cga[m - 30];",
"} else if (m == 38 && VAR_3 + 2 < s->nb_args && s->args[VAR_3 + 1] == 5 && s->args[VAR_3 + 2] < 256) {",
"int index = s->args[VAR_3 + 2];",
"s->fg = index < 16 ? ansi_to_cga[index] : index;",
"VAR_3 += 2;",
"} else if (m == 39) {",
"s->fg = ansi_to_cga[DEFAULT_FG_COLOR];",
"} else if (m >= 40 && m <= 47) {",
"s->bg = ansi_to_cga[m - 40];",
"} else if (m == 48 && VAR_3 + 2 < s->nb_args && s->args[VAR_3 + 1] == 5 && s->args[VAR_3 + 2] < 256) {",
"int index = s->args[VAR_3 + 2];",
"s->bg = index < 16 ? ansi_to_cga[index] : index;",
"VAR_3 += 2;",
"} else if (m == 49) {",
"s->fg = ansi_to_cga[DEFAULT_BG_COLOR];",
"} else {",
"av_log_ask_for_sample(VAR_0, \"unsupported rendition parameter\\n\");",
"}",
"}",
"break;",
"case 'n':\ncase 'R':\nbreak;",
"case 's':\ns->sx = s->x;",
"s->sy = s->y;",
"break;",
"case 'u':\ns->x = av_clip(s->sx, 0, VAR_0->VAR_4 - FONT_WIDTH);",
"s->y = av_clip(s->sy, 0, VAR_0->VAR_5 - s->font_height);",
"break;",
"default:\nav_log_ask_for_sample(VAR_0, \"unsupported escape code\\n\");",
"break;",
"}",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
15
],
[
17,
19
],
[
21
],
[
23,
25
],
[
27
],
[
29,
31
],
[
33
],
[
35,
37,
39
],
[
41
],
[
43
],
[
45,
47,
49,
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95,
97
],
[
99,
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123,
125
],
[
127
],
[
129
],
[
131,
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163,
165
],
[
167,
169
],
[
171,
173,
175
],
[
177
],
[
179,
181
],
[
183,
185
],
[
187
],
[
189,
191
],
[
193
],
[
195
],
[
197,
199
],
[
201,
203
],
[
205
],
[
207,
209
],
[
211
],
[
213,
215
],
[
217
],
[
219
],
[
221,
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289,
291,
295
],
[
297,
299
],
[
301
],
[
303
],
[
305,
307
],
[
309
],
[
311
],
[
313,
315
],
[
317
],
[
319
],
[
321
],
[
323
]
] |
20,854 | void ff_h264_filter_mb(H264Context *h, H264SliceContext *sl,
int mb_x, int mb_y,
uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr,
unsigned int linesize, unsigned int uvlinesize)
{
const int mb_xy= mb_x + mb_y*h->mb_stride;
const int mb_type = h->cur_pic.mb_type[mb_xy];
const int mvy_limit = IS_INTERLACED(mb_type) ? 2 : 4;
int first_vertical_edge_done = 0;
int chroma = !(CONFIG_GRAY && (h->flags&CODEC_FLAG_GRAY));
int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
int a = 52 + h->slice_alpha_c0_offset - qp_bd_offset;
int b = 52 + h->slice_beta_offset - qp_bd_offset;
if (FRAME_MBAFF(h)
// and current and left pair do not have the same interlaced type
&& IS_INTERLACED(mb_type ^ sl->left_type[LTOP])
// and left mb is in available to us
&& sl->left_type[LTOP]) {
/* First vertical edge is different in MBAFF frames
* There are 8 different bS to compute and 2 different Qp
*/
DECLARE_ALIGNED(8, int16_t, bS)[8];
int qp[2];
int bqp[2];
int rqp[2];
int mb_qp, mbn0_qp, mbn1_qp;
int i;
first_vertical_edge_done = 1;
if( IS_INTRA(mb_type) ) {
AV_WN64A(&bS[0], 0x0004000400040004ULL);
AV_WN64A(&bS[4], 0x0004000400040004ULL);
} else {
static const uint8_t offset[2][2][8]={
{
{3+4*0, 3+4*0, 3+4*0, 3+4*0, 3+4*1, 3+4*1, 3+4*1, 3+4*1},
{3+4*2, 3+4*2, 3+4*2, 3+4*2, 3+4*3, 3+4*3, 3+4*3, 3+4*3},
},{
{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
}
};
const uint8_t *off= offset[MB_FIELD(h)][mb_y&1];
for( i = 0; i < 8; i++ ) {
int j= MB_FIELD(h) ? i>>2 : i&1;
int mbn_xy = sl->left_mb_xy[LEFT(j)];
int mbn_type = sl->left_type[LEFT(j)];
if( IS_INTRA( mbn_type ) )
bS[i] = 4;
else{
bS[i] = 1 + !!(sl->non_zero_count_cache[12+8*(i>>1)] |
((!h->pps.cabac && IS_8x8DCT(mbn_type)) ?
(h->cbp_table[mbn_xy] & (((MB_FIELD(h) ? (i&2) : (mb_y&1)) ? 8 : 2) << 12))
:
h->non_zero_count[mbn_xy][ off[i] ]));
}
}
}
mb_qp = h->cur_pic.qscale_table[mb_xy];
mbn0_qp = h->cur_pic.qscale_table[sl->left_mb_xy[0]];
mbn1_qp = h->cur_pic.qscale_table[sl->left_mb_xy[1]];
qp[0] = ( mb_qp + mbn0_qp + 1 ) >> 1;
bqp[0] = ( get_chroma_qp( h, 0, mb_qp ) +
get_chroma_qp( h, 0, mbn0_qp ) + 1 ) >> 1;
rqp[0] = ( get_chroma_qp( h, 1, mb_qp ) +
get_chroma_qp( h, 1, mbn0_qp ) + 1 ) >> 1;
qp[1] = ( mb_qp + mbn1_qp + 1 ) >> 1;
bqp[1] = ( get_chroma_qp( h, 0, mb_qp ) +
get_chroma_qp( h, 0, mbn1_qp ) + 1 ) >> 1;
rqp[1] = ( get_chroma_qp( h, 1, mb_qp ) +
get_chroma_qp( h, 1, mbn1_qp ) + 1 ) >> 1;
/* Filter edge */
tprintf(h->avctx, "filter mb:%d/%d MBAFF, QPy:%d/%d, QPb:%d/%d QPr:%d/%d ls:%d uvls:%d", mb_x, mb_y, qp[0], qp[1], bqp[0], bqp[1], rqp[0], rqp[1], linesize, uvlinesize);
{ int i; for (i = 0; i < 8; i++) tprintf(h->avctx, " bS[%d]:%d", i, bS[i]); tprintf(h->avctx, "\n"); }
if (MB_FIELD(h)) {
filter_mb_mbaff_edgev ( h, img_y , linesize, bS , 1, qp [0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_y + 8* linesize, linesize, bS+4, 1, qp [1], a, b, 1 );
if (chroma){
if (CHROMA444(h)) {
filter_mb_mbaff_edgev ( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 );
} else if (CHROMA422(h)) {
filter_mb_mbaff_edgecv(h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1);
filter_mb_mbaff_edgecv(h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1);
filter_mb_mbaff_edgecv(h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1);
filter_mb_mbaff_edgecv(h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1);
}else{
filter_mb_mbaff_edgecv( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cb + 4*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr + 4*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 );
}
}
}else{
filter_mb_mbaff_edgev ( h, img_y , 2* linesize, bS , 2, qp [0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_y + linesize, 2* linesize, bS+1, 2, qp [1], a, b, 1 );
if (chroma){
if (CHROMA444(h)) {
filter_mb_mbaff_edgev ( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 );
}else{
filter_mb_mbaff_edgecv( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 );
}
}
}
}
#if CONFIG_SMALL
{
int dir;
for (dir = 0; dir < 2; dir++)
filter_mb_dir(h, sl, mb_x, mb_y, img_y, img_cb, img_cr, linesize,
uvlinesize, mb_xy, mb_type, mvy_limit,
dir ? 0 : first_vertical_edge_done, a, b,
chroma, dir);
}
#else
filter_mb_dir(h, sl, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, first_vertical_edge_done, a, b, chroma, 0);
filter_mb_dir(h, sl, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, 0, a, b, chroma, 1);
#endif
}
| false | FFmpeg | e6c90ce94f1b07f50cea2babf7471af455cca0ff | void ff_h264_filter_mb(H264Context *h, H264SliceContext *sl,
int mb_x, int mb_y,
uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr,
unsigned int linesize, unsigned int uvlinesize)
{
const int mb_xy= mb_x + mb_y*h->mb_stride;
const int mb_type = h->cur_pic.mb_type[mb_xy];
const int mvy_limit = IS_INTERLACED(mb_type) ? 2 : 4;
int first_vertical_edge_done = 0;
int chroma = !(CONFIG_GRAY && (h->flags&CODEC_FLAG_GRAY));
int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
int a = 52 + h->slice_alpha_c0_offset - qp_bd_offset;
int b = 52 + h->slice_beta_offset - qp_bd_offset;
if (FRAME_MBAFF(h)
&& IS_INTERLACED(mb_type ^ sl->left_type[LTOP])
&& sl->left_type[LTOP]) {
DECLARE_ALIGNED(8, int16_t, bS)[8];
int qp[2];
int bqp[2];
int rqp[2];
int mb_qp, mbn0_qp, mbn1_qp;
int i;
first_vertical_edge_done = 1;
if( IS_INTRA(mb_type) ) {
AV_WN64A(&bS[0], 0x0004000400040004ULL);
AV_WN64A(&bS[4], 0x0004000400040004ULL);
} else {
static const uint8_t offset[2][2][8]={
{
{3+4*0, 3+4*0, 3+4*0, 3+4*0, 3+4*1, 3+4*1, 3+4*1, 3+4*1},
{3+4*2, 3+4*2, 3+4*2, 3+4*2, 3+4*3, 3+4*3, 3+4*3, 3+4*3},
},{
{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
}
};
const uint8_t *off= offset[MB_FIELD(h)][mb_y&1];
for( i = 0; i < 8; i++ ) {
int j= MB_FIELD(h) ? i>>2 : i&1;
int mbn_xy = sl->left_mb_xy[LEFT(j)];
int mbn_type = sl->left_type[LEFT(j)];
if( IS_INTRA( mbn_type ) )
bS[i] = 4;
else{
bS[i] = 1 + !!(sl->non_zero_count_cache[12+8*(i>>1)] |
((!h->pps.cabac && IS_8x8DCT(mbn_type)) ?
(h->cbp_table[mbn_xy] & (((MB_FIELD(h) ? (i&2) : (mb_y&1)) ? 8 : 2) << 12))
:
h->non_zero_count[mbn_xy][ off[i] ]));
}
}
}
mb_qp = h->cur_pic.qscale_table[mb_xy];
mbn0_qp = h->cur_pic.qscale_table[sl->left_mb_xy[0]];
mbn1_qp = h->cur_pic.qscale_table[sl->left_mb_xy[1]];
qp[0] = ( mb_qp + mbn0_qp + 1 ) >> 1;
bqp[0] = ( get_chroma_qp( h, 0, mb_qp ) +
get_chroma_qp( h, 0, mbn0_qp ) + 1 ) >> 1;
rqp[0] = ( get_chroma_qp( h, 1, mb_qp ) +
get_chroma_qp( h, 1, mbn0_qp ) + 1 ) >> 1;
qp[1] = ( mb_qp + mbn1_qp + 1 ) >> 1;
bqp[1] = ( get_chroma_qp( h, 0, mb_qp ) +
get_chroma_qp( h, 0, mbn1_qp ) + 1 ) >> 1;
rqp[1] = ( get_chroma_qp( h, 1, mb_qp ) +
get_chroma_qp( h, 1, mbn1_qp ) + 1 ) >> 1;
tprintf(h->avctx, "filter mb:%d/%d MBAFF, QPy:%d/%d, QPb:%d/%d QPr:%d/%d ls:%d uvls:%d", mb_x, mb_y, qp[0], qp[1], bqp[0], bqp[1], rqp[0], rqp[1], linesize, uvlinesize);
{ int i; for (i = 0; i < 8; i++) tprintf(h->avctx, " bS[%d]:%d", i, bS[i]); tprintf(h->avctx, "\n"); }
if (MB_FIELD(h)) {
filter_mb_mbaff_edgev ( h, img_y , linesize, bS , 1, qp [0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_y + 8* linesize, linesize, bS+4, 1, qp [1], a, b, 1 );
if (chroma){
if (CHROMA444(h)) {
filter_mb_mbaff_edgev ( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 );
} else if (CHROMA422(h)) {
filter_mb_mbaff_edgecv(h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1);
filter_mb_mbaff_edgecv(h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1);
filter_mb_mbaff_edgecv(h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1);
filter_mb_mbaff_edgecv(h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1);
}else{
filter_mb_mbaff_edgecv( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cb + 4*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr + 4*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 );
}
}
}else{
filter_mb_mbaff_edgev ( h, img_y , 2* linesize, bS , 2, qp [0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_y + linesize, 2* linesize, bS+1, 2, qp [1], a, b, 1 );
if (chroma){
if (CHROMA444(h)) {
filter_mb_mbaff_edgev ( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 );
}else{
filter_mb_mbaff_edgecv( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 );
}
}
}
}
#if CONFIG_SMALL
{
int dir;
for (dir = 0; dir < 2; dir++)
filter_mb_dir(h, sl, mb_x, mb_y, img_y, img_cb, img_cr, linesize,
uvlinesize, mb_xy, mb_type, mvy_limit,
dir ? 0 : first_vertical_edge_done, a, b,
chroma, dir);
}
#else
filter_mb_dir(h, sl, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, first_vertical_edge_done, a, b, chroma, 0);
filter_mb_dir(h, sl, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, 0, a, b, chroma, 1);
#endif
}
| {
"code": [],
"line_no": []
} | void FUNC_0(H264Context *VAR_0, H264SliceContext *VAR_1,
int VAR_2, int VAR_3,
uint8_t *VAR_4, uint8_t *VAR_5, uint8_t *VAR_6,
unsigned int VAR_7, unsigned int VAR_8)
{
const int VAR_9= VAR_2 + VAR_3*VAR_0->mb_stride;
const int VAR_10 = VAR_0->cur_pic.VAR_10[VAR_9];
const int VAR_11 = IS_INTERLACED(VAR_10) ? 2 : 4;
int VAR_12 = 0;
int VAR_13 = !(CONFIG_GRAY && (VAR_0->flags&CODEC_FLAG_GRAY));
int VAR_14 = 6 * (VAR_0->sps.bit_depth_luma - 8);
int VAR_15 = 52 + VAR_0->slice_alpha_c0_offset - VAR_14;
int VAR_16 = 52 + VAR_0->slice_beta_offset - VAR_14;
if (FRAME_MBAFF(VAR_0)
&& IS_INTERLACED(VAR_10 ^ VAR_1->left_type[LTOP])
&& VAR_1->left_type[LTOP]) {
DECLARE_ALIGNED(8, int16_t, bS)[8];
int VAR_17[2];
int VAR_18[2];
int VAR_19[2];
int VAR_20, VAR_21, VAR_22;
int VAR_29;
VAR_12 = 1;
if( IS_INTRA(VAR_10) ) {
AV_WN64A(&bS[0], 0x0004000400040004ULL);
AV_WN64A(&bS[4], 0x0004000400040004ULL);
} else {
static const uint8_t VAR_24[2][2][8]={
{
{3+4*0, 3+4*0, 3+4*0, 3+4*0, 3+4*1, 3+4*1, 3+4*1, 3+4*1},
{3+4*2, 3+4*2, 3+4*2, 3+4*2, 3+4*3, 3+4*3, 3+4*3, 3+4*3},
},{
{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
}
};
const uint8_t *VAR_25= VAR_24[MB_FIELD(VAR_0)][VAR_3&1];
for( VAR_29 = 0; VAR_29 < 8; VAR_29++ ) {
int VAR_26= MB_FIELD(VAR_0) ? VAR_29>>2 : VAR_29&1;
int VAR_27 = VAR_1->left_mb_xy[LEFT(VAR_26)];
int VAR_28 = VAR_1->left_type[LEFT(VAR_26)];
if( IS_INTRA( VAR_28 ) )
bS[VAR_29] = 4;
else{
bS[VAR_29] = 1 + !!(VAR_1->non_zero_count_cache[12+8*(VAR_29>>1)] |
((!VAR_0->pps.cabac && IS_8x8DCT(VAR_28)) ?
(VAR_0->cbp_table[VAR_27] & (((MB_FIELD(VAR_0) ? (VAR_29&2) : (VAR_3&1)) ? 8 : 2) << 12))
:
VAR_0->non_zero_count[VAR_27][ VAR_25[VAR_29] ]));
}
}
}
VAR_20 = VAR_0->cur_pic.qscale_table[VAR_9];
VAR_21 = VAR_0->cur_pic.qscale_table[VAR_1->left_mb_xy[0]];
VAR_22 = VAR_0->cur_pic.qscale_table[VAR_1->left_mb_xy[1]];
VAR_17[0] = ( VAR_20 + VAR_21 + 1 ) >> 1;
VAR_18[0] = ( get_chroma_qp( VAR_0, 0, VAR_20 ) +
get_chroma_qp( VAR_0, 0, VAR_21 ) + 1 ) >> 1;
VAR_19[0] = ( get_chroma_qp( VAR_0, 1, VAR_20 ) +
get_chroma_qp( VAR_0, 1, VAR_21 ) + 1 ) >> 1;
VAR_17[1] = ( VAR_20 + VAR_22 + 1 ) >> 1;
VAR_18[1] = ( get_chroma_qp( VAR_0, 0, VAR_20 ) +
get_chroma_qp( VAR_0, 0, VAR_22 ) + 1 ) >> 1;
VAR_19[1] = ( get_chroma_qp( VAR_0, 1, VAR_20 ) +
get_chroma_qp( VAR_0, 1, VAR_22 ) + 1 ) >> 1;
tprintf(VAR_0->avctx, "filter mb:%d/%d MBAFF, QPy:%d/%d, QPb:%d/%d QPr:%d/%d ls:%d uvls:%d", VAR_2, VAR_3, VAR_17[0], VAR_17[1], VAR_18[0], VAR_18[1], VAR_19[0], VAR_19[1], VAR_7, VAR_8);
{ int VAR_29; for (VAR_29 = 0; VAR_29 < 8; VAR_29++) tprintf(VAR_0->avctx, " bS[%d]:%d", VAR_29, bS[VAR_29]); tprintf(VAR_0->avctx, "\n"); }
if (MB_FIELD(VAR_0)) {
filter_mb_mbaff_edgev ( VAR_0, VAR_4 , VAR_7, bS , 1, VAR_17 [0], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_4 + 8* VAR_7, VAR_7, bS+4, 1, VAR_17 [1], VAR_15, VAR_16, 1 );
if (VAR_13){
if (CHROMA444(VAR_0)) {
filter_mb_mbaff_edgev ( VAR_0, VAR_5, VAR_8, bS , 1, VAR_18[0], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_5 + 8*VAR_8, VAR_8, bS+4, 1, VAR_18[1], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_6, VAR_8, bS , 1, VAR_19[0], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_6 + 8*VAR_8, VAR_8, bS+4, 1, VAR_19[1], VAR_15, VAR_16, 1 );
} else if (CHROMA422(VAR_0)) {
filter_mb_mbaff_edgecv(VAR_0, VAR_5, VAR_8, bS , 1, VAR_18[0], VAR_15, VAR_16, 1);
filter_mb_mbaff_edgecv(VAR_0, VAR_5 + 8*VAR_8, VAR_8, bS+4, 1, VAR_18[1], VAR_15, VAR_16, 1);
filter_mb_mbaff_edgecv(VAR_0, VAR_6, VAR_8, bS , 1, VAR_19[0], VAR_15, VAR_16, 1);
filter_mb_mbaff_edgecv(VAR_0, VAR_6 + 8*VAR_8, VAR_8, bS+4, 1, VAR_19[1], VAR_15, VAR_16, 1);
}else{
filter_mb_mbaff_edgecv( VAR_0, VAR_5, VAR_8, bS , 1, VAR_18[0], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgecv( VAR_0, VAR_5 + 4*VAR_8, VAR_8, bS+4, 1, VAR_18[1], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgecv( VAR_0, VAR_6, VAR_8, bS , 1, VAR_19[0], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgecv( VAR_0, VAR_6 + 4*VAR_8, VAR_8, bS+4, 1, VAR_19[1], VAR_15, VAR_16, 1 );
}
}
}else{
filter_mb_mbaff_edgev ( VAR_0, VAR_4 , 2* VAR_7, bS , 2, VAR_17 [0], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_4 + VAR_7, 2* VAR_7, bS+1, 2, VAR_17 [1], VAR_15, VAR_16, 1 );
if (VAR_13){
if (CHROMA444(VAR_0)) {
filter_mb_mbaff_edgev ( VAR_0, VAR_5, 2*VAR_8, bS , 2, VAR_18[0], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_5 + VAR_8, 2*VAR_8, bS+1, 2, VAR_18[1], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_6, 2*VAR_8, bS , 2, VAR_19[0], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_6 + VAR_8, 2*VAR_8, bS+1, 2, VAR_19[1], VAR_15, VAR_16, 1 );
}else{
filter_mb_mbaff_edgecv( VAR_0, VAR_5, 2*VAR_8, bS , 2, VAR_18[0], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgecv( VAR_0, VAR_5 + VAR_8, 2*VAR_8, bS+1, 2, VAR_18[1], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgecv( VAR_0, VAR_6, 2*VAR_8, bS , 2, VAR_19[0], VAR_15, VAR_16, 1 );
filter_mb_mbaff_edgecv( VAR_0, VAR_6 + VAR_8, 2*VAR_8, bS+1, 2, VAR_19[1], VAR_15, VAR_16, 1 );
}
}
}
}
#if CONFIG_SMALL
{
int dir;
for (dir = 0; dir < 2; dir++)
filter_mb_dir(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7,
VAR_8, VAR_9, VAR_10, VAR_11,
dir ? 0 : VAR_12, VAR_15, VAR_16,
VAR_13, dir);
}
#else
filter_mb_dir(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_15, VAR_16, VAR_13, 0);
filter_mb_dir(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, 0, VAR_15, VAR_16, VAR_13, 1);
#endif
}
| [
"void FUNC_0(H264Context *VAR_0, H264SliceContext *VAR_1,\nint VAR_2, int VAR_3,\nuint8_t *VAR_4, uint8_t *VAR_5, uint8_t *VAR_6,\nunsigned int VAR_7, unsigned int VAR_8)\n{",
"const int VAR_9= VAR_2 + VAR_3*VAR_0->mb_stride;",
"const int VAR_10 = VAR_0->cur_pic.VAR_10[VAR_9];",
"const int VAR_11 = IS_INTERLACED(VAR_10) ? 2 : 4;",
"int VAR_12 = 0;",
"int VAR_13 = !(CONFIG_GRAY && (VAR_0->flags&CODEC_FLAG_GRAY));",
"int VAR_14 = 6 * (VAR_0->sps.bit_depth_luma - 8);",
"int VAR_15 = 52 + VAR_0->slice_alpha_c0_offset - VAR_14;",
"int VAR_16 = 52 + VAR_0->slice_beta_offset - VAR_14;",
"if (FRAME_MBAFF(VAR_0)\n&& IS_INTERLACED(VAR_10 ^ VAR_1->left_type[LTOP])\n&& VAR_1->left_type[LTOP]) {",
"DECLARE_ALIGNED(8, int16_t, bS)[8];",
"int VAR_17[2];",
"int VAR_18[2];",
"int VAR_19[2];",
"int VAR_20, VAR_21, VAR_22;",
"int VAR_29;",
"VAR_12 = 1;",
"if( IS_INTRA(VAR_10) ) {",
"AV_WN64A(&bS[0], 0x0004000400040004ULL);",
"AV_WN64A(&bS[4], 0x0004000400040004ULL);",
"} else {",
"static const uint8_t VAR_24[2][2][8]={",
"{",
"{3+4*0, 3+4*0, 3+4*0, 3+4*0, 3+4*1, 3+4*1, 3+4*1, 3+4*1},",
"{3+4*2, 3+4*2, 3+4*2, 3+4*2, 3+4*3, 3+4*3, 3+4*3, 3+4*3},",
"},{",
"{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},",
"{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},",
"}",
"};",
"const uint8_t *VAR_25= VAR_24[MB_FIELD(VAR_0)][VAR_3&1];",
"for( VAR_29 = 0; VAR_29 < 8; VAR_29++ ) {",
"int VAR_26= MB_FIELD(VAR_0) ? VAR_29>>2 : VAR_29&1;",
"int VAR_27 = VAR_1->left_mb_xy[LEFT(VAR_26)];",
"int VAR_28 = VAR_1->left_type[LEFT(VAR_26)];",
"if( IS_INTRA( VAR_28 ) )\nbS[VAR_29] = 4;",
"else{",
"bS[VAR_29] = 1 + !!(VAR_1->non_zero_count_cache[12+8*(VAR_29>>1)] |\n((!VAR_0->pps.cabac && IS_8x8DCT(VAR_28)) ?\n(VAR_0->cbp_table[VAR_27] & (((MB_FIELD(VAR_0) ? (VAR_29&2) : (VAR_3&1)) ? 8 : 2) << 12))\n:\nVAR_0->non_zero_count[VAR_27][ VAR_25[VAR_29] ]));",
"}",
"}",
"}",
"VAR_20 = VAR_0->cur_pic.qscale_table[VAR_9];",
"VAR_21 = VAR_0->cur_pic.qscale_table[VAR_1->left_mb_xy[0]];",
"VAR_22 = VAR_0->cur_pic.qscale_table[VAR_1->left_mb_xy[1]];",
"VAR_17[0] = ( VAR_20 + VAR_21 + 1 ) >> 1;",
"VAR_18[0] = ( get_chroma_qp( VAR_0, 0, VAR_20 ) +\nget_chroma_qp( VAR_0, 0, VAR_21 ) + 1 ) >> 1;",
"VAR_19[0] = ( get_chroma_qp( VAR_0, 1, VAR_20 ) +\nget_chroma_qp( VAR_0, 1, VAR_21 ) + 1 ) >> 1;",
"VAR_17[1] = ( VAR_20 + VAR_22 + 1 ) >> 1;",
"VAR_18[1] = ( get_chroma_qp( VAR_0, 0, VAR_20 ) +\nget_chroma_qp( VAR_0, 0, VAR_22 ) + 1 ) >> 1;",
"VAR_19[1] = ( get_chroma_qp( VAR_0, 1, VAR_20 ) +\nget_chroma_qp( VAR_0, 1, VAR_22 ) + 1 ) >> 1;",
"tprintf(VAR_0->avctx, \"filter mb:%d/%d MBAFF, QPy:%d/%d, QPb:%d/%d QPr:%d/%d ls:%d uvls:%d\", VAR_2, VAR_3, VAR_17[0], VAR_17[1], VAR_18[0], VAR_18[1], VAR_19[0], VAR_19[1], VAR_7, VAR_8);",
"{ int VAR_29; for (VAR_29 = 0; VAR_29 < 8; VAR_29++) tprintf(VAR_0->avctx, \" bS[%d]:%d\", VAR_29, bS[VAR_29]); tprintf(VAR_0->avctx, \"\\n\"); }",
"if (MB_FIELD(VAR_0)) {",
"filter_mb_mbaff_edgev ( VAR_0, VAR_4 , VAR_7, bS , 1, VAR_17 [0], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_4 + 8* VAR_7, VAR_7, bS+4, 1, VAR_17 [1], VAR_15, VAR_16, 1 );",
"if (VAR_13){",
"if (CHROMA444(VAR_0)) {",
"filter_mb_mbaff_edgev ( VAR_0, VAR_5, VAR_8, bS , 1, VAR_18[0], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_5 + 8*VAR_8, VAR_8, bS+4, 1, VAR_18[1], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_6, VAR_8, bS , 1, VAR_19[0], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_6 + 8*VAR_8, VAR_8, bS+4, 1, VAR_19[1], VAR_15, VAR_16, 1 );",
"} else if (CHROMA422(VAR_0)) {",
"filter_mb_mbaff_edgecv(VAR_0, VAR_5, VAR_8, bS , 1, VAR_18[0], VAR_15, VAR_16, 1);",
"filter_mb_mbaff_edgecv(VAR_0, VAR_5 + 8*VAR_8, VAR_8, bS+4, 1, VAR_18[1], VAR_15, VAR_16, 1);",
"filter_mb_mbaff_edgecv(VAR_0, VAR_6, VAR_8, bS , 1, VAR_19[0], VAR_15, VAR_16, 1);",
"filter_mb_mbaff_edgecv(VAR_0, VAR_6 + 8*VAR_8, VAR_8, bS+4, 1, VAR_19[1], VAR_15, VAR_16, 1);",
"}else{",
"filter_mb_mbaff_edgecv( VAR_0, VAR_5, VAR_8, bS , 1, VAR_18[0], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgecv( VAR_0, VAR_5 + 4*VAR_8, VAR_8, bS+4, 1, VAR_18[1], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgecv( VAR_0, VAR_6, VAR_8, bS , 1, VAR_19[0], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgecv( VAR_0, VAR_6 + 4*VAR_8, VAR_8, bS+4, 1, VAR_19[1], VAR_15, VAR_16, 1 );",
"}",
"}",
"}else{",
"filter_mb_mbaff_edgev ( VAR_0, VAR_4 , 2* VAR_7, bS , 2, VAR_17 [0], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_4 + VAR_7, 2* VAR_7, bS+1, 2, VAR_17 [1], VAR_15, VAR_16, 1 );",
"if (VAR_13){",
"if (CHROMA444(VAR_0)) {",
"filter_mb_mbaff_edgev ( VAR_0, VAR_5, 2*VAR_8, bS , 2, VAR_18[0], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_5 + VAR_8, 2*VAR_8, bS+1, 2, VAR_18[1], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_6, 2*VAR_8, bS , 2, VAR_19[0], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_6 + VAR_8, 2*VAR_8, bS+1, 2, VAR_19[1], VAR_15, VAR_16, 1 );",
"}else{",
"filter_mb_mbaff_edgecv( VAR_0, VAR_5, 2*VAR_8, bS , 2, VAR_18[0], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgecv( VAR_0, VAR_5 + VAR_8, 2*VAR_8, bS+1, 2, VAR_18[1], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgecv( VAR_0, VAR_6, 2*VAR_8, bS , 2, VAR_19[0], VAR_15, VAR_16, 1 );",
"filter_mb_mbaff_edgecv( VAR_0, VAR_6 + VAR_8, 2*VAR_8, bS+1, 2, VAR_19[1], VAR_15, VAR_16, 1 );",
"}",
"}",
"}",
"}",
"#if CONFIG_SMALL\n{",
"int dir;",
"for (dir = 0; dir < 2; dir++)",
"filter_mb_dir(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7,\nVAR_8, VAR_9, VAR_10, VAR_11,\ndir ? 0 : VAR_12, VAR_15, VAR_16,\nVAR_13, dir);",
"}",
"#else\nfilter_mb_dir(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_15, VAR_16, VAR_13, 0);",
"filter_mb_dir(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, 0, VAR_15, VAR_16, VAR_13, 1);",
"#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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
33,
37
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99,
101
],
[
103
],
[
105,
107,
109,
111,
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131,
133
],
[
135,
137
],
[
139
],
[
141,
143
],
[
145,
147
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
237,
239
],
[
241
],
[
243
],
[
245,
247,
249,
251
],
[
253
],
[
255,
257
],
[
259
],
[
261,
263
]
] |
20,855 | e1000_set_link_status(VLANClientState *nc)
{
E1000State *s = DO_UPCAST(NICState, nc, nc)->opaque;
uint32_t old_status = s->mac_reg[STATUS];
if (nc->link_down)
s->mac_reg[STATUS] &= ~E1000_STATUS_LU;
else
s->mac_reg[STATUS] |= E1000_STATUS_LU;
if (s->mac_reg[STATUS] != old_status)
set_ics(s, 0, E1000_ICR_LSC);
}
| true | qemu | d4044c2a6b9ba4a00dd653f515a4b0ebfcb7e125 | e1000_set_link_status(VLANClientState *nc)
{
E1000State *s = DO_UPCAST(NICState, nc, nc)->opaque;
uint32_t old_status = s->mac_reg[STATUS];
if (nc->link_down)
s->mac_reg[STATUS] &= ~E1000_STATUS_LU;
else
s->mac_reg[STATUS] |= E1000_STATUS_LU;
if (s->mac_reg[STATUS] != old_status)
set_ics(s, 0, E1000_ICR_LSC);
}
| {
"code": [
" if (nc->link_down)"
],
"line_no": [
11
]
} | FUNC_0(VLANClientState *VAR_0)
{
E1000State *s = DO_UPCAST(NICState, VAR_0, VAR_0)->opaque;
uint32_t old_status = s->mac_reg[STATUS];
if (VAR_0->link_down)
s->mac_reg[STATUS] &= ~E1000_STATUS_LU;
else
s->mac_reg[STATUS] |= E1000_STATUS_LU;
if (s->mac_reg[STATUS] != old_status)
set_ics(s, 0, E1000_ICR_LSC);
}
| [
"FUNC_0(VLANClientState *VAR_0)\n{",
"E1000State *s = DO_UPCAST(NICState, VAR_0, VAR_0)->opaque;",
"uint32_t old_status = s->mac_reg[STATUS];",
"if (VAR_0->link_down)\ns->mac_reg[STATUS] &= ~E1000_STATUS_LU;",
"else\ns->mac_reg[STATUS] |= E1000_STATUS_LU;",
"if (s->mac_reg[STATUS] != old_status)\nset_ics(s, 0, E1000_ICR_LSC);",
"}"
] | [
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15,
17
],
[
21,
23
],
[
25
]
] |
20,857 | static void tcx_initfn(Object *obj)
{
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
TCXState *s = TCX(obj);
memory_region_init_ram(&s->rom, NULL, "tcx.prom", FCODE_MAX_ROM_SIZE,
&error_abort);
memory_region_set_readonly(&s->rom, true);
sysbus_init_mmio(sbd, &s->rom);
/* 2/STIP : Stippler */
memory_region_init_io(&s->stip, OBJECT(s), &tcx_stip_ops, s, "tcx.stip",
TCX_STIP_NREGS);
sysbus_init_mmio(sbd, &s->stip);
/* 3/BLIT : Blitter */
memory_region_init_io(&s->blit, OBJECT(s), &tcx_blit_ops, s, "tcx.blit",
TCX_BLIT_NREGS);
sysbus_init_mmio(sbd, &s->blit);
/* 5/RSTIP : Raw Stippler */
memory_region_init_io(&s->rstip, OBJECT(s), &tcx_rstip_ops, s, "tcx.rstip",
TCX_RSTIP_NREGS);
sysbus_init_mmio(sbd, &s->rstip);
/* 6/RBLIT : Raw Blitter */
memory_region_init_io(&s->rblit, OBJECT(s), &tcx_rblit_ops, s, "tcx.rblit",
TCX_RBLIT_NREGS);
sysbus_init_mmio(sbd, &s->rblit);
/* 7/TEC : ??? */
memory_region_init_io(&s->tec, OBJECT(s), &tcx_dummy_ops, s,
"tcx.tec", TCX_TEC_NREGS);
sysbus_init_mmio(sbd, &s->tec);
/* 8/CMAP : DAC */
memory_region_init_io(&s->dac, OBJECT(s), &tcx_dac_ops, s,
"tcx.dac", TCX_DAC_NREGS);
sysbus_init_mmio(sbd, &s->dac);
/* 9/THC : Cursor */
memory_region_init_io(&s->thc, OBJECT(s), &tcx_thc_ops, s, "tcx.thc",
TCX_THC_NREGS);
sysbus_init_mmio(sbd, &s->thc);
/* 11/DHC : ??? */
memory_region_init_io(&s->dhc, OBJECT(s), &tcx_dummy_ops, s, "tcx.dhc",
TCX_DHC_NREGS);
sysbus_init_mmio(sbd, &s->dhc);
/* 12/ALT : ??? */
memory_region_init_io(&s->alt, OBJECT(s), &tcx_dummy_ops, s, "tcx.alt",
TCX_ALT_NREGS);
sysbus_init_mmio(sbd, &s->alt);
return;
}
| true | qemu | f8ed85ac992c48814d916d5df4d44f9a971c5de4 | static void tcx_initfn(Object *obj)
{
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
TCXState *s = TCX(obj);
memory_region_init_ram(&s->rom, NULL, "tcx.prom", FCODE_MAX_ROM_SIZE,
&error_abort);
memory_region_set_readonly(&s->rom, true);
sysbus_init_mmio(sbd, &s->rom);
memory_region_init_io(&s->stip, OBJECT(s), &tcx_stip_ops, s, "tcx.stip",
TCX_STIP_NREGS);
sysbus_init_mmio(sbd, &s->stip);
memory_region_init_io(&s->blit, OBJECT(s), &tcx_blit_ops, s, "tcx.blit",
TCX_BLIT_NREGS);
sysbus_init_mmio(sbd, &s->blit);
memory_region_init_io(&s->rstip, OBJECT(s), &tcx_rstip_ops, s, "tcx.rstip",
TCX_RSTIP_NREGS);
sysbus_init_mmio(sbd, &s->rstip);
memory_region_init_io(&s->rblit, OBJECT(s), &tcx_rblit_ops, s, "tcx.rblit",
TCX_RBLIT_NREGS);
sysbus_init_mmio(sbd, &s->rblit);
memory_region_init_io(&s->tec, OBJECT(s), &tcx_dummy_ops, s,
"tcx.tec", TCX_TEC_NREGS);
sysbus_init_mmio(sbd, &s->tec);
memory_region_init_io(&s->dac, OBJECT(s), &tcx_dac_ops, s,
"tcx.dac", TCX_DAC_NREGS);
sysbus_init_mmio(sbd, &s->dac);
memory_region_init_io(&s->thc, OBJECT(s), &tcx_thc_ops, s, "tcx.thc",
TCX_THC_NREGS);
sysbus_init_mmio(sbd, &s->thc);
memory_region_init_io(&s->dhc, OBJECT(s), &tcx_dummy_ops, s, "tcx.dhc",
TCX_DHC_NREGS);
sysbus_init_mmio(sbd, &s->dhc);
memory_region_init_io(&s->alt, OBJECT(s), &tcx_dummy_ops, s, "tcx.alt",
TCX_ALT_NREGS);
sysbus_init_mmio(sbd, &s->alt);
return;
}
| {
"code": [
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);"
],
"line_no": [
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13
]
} | static void FUNC_0(Object *VAR_0)
{
SysBusDevice *sbd = SYS_BUS_DEVICE(VAR_0);
TCXState *s = TCX(VAR_0);
memory_region_init_ram(&s->rom, NULL, "tcx.prom", FCODE_MAX_ROM_SIZE,
&error_abort);
memory_region_set_readonly(&s->rom, true);
sysbus_init_mmio(sbd, &s->rom);
memory_region_init_io(&s->stip, OBJECT(s), &tcx_stip_ops, s, "tcx.stip",
TCX_STIP_NREGS);
sysbus_init_mmio(sbd, &s->stip);
memory_region_init_io(&s->blit, OBJECT(s), &tcx_blit_ops, s, "tcx.blit",
TCX_BLIT_NREGS);
sysbus_init_mmio(sbd, &s->blit);
memory_region_init_io(&s->rstip, OBJECT(s), &tcx_rstip_ops, s, "tcx.rstip",
TCX_RSTIP_NREGS);
sysbus_init_mmio(sbd, &s->rstip);
memory_region_init_io(&s->rblit, OBJECT(s), &tcx_rblit_ops, s, "tcx.rblit",
TCX_RBLIT_NREGS);
sysbus_init_mmio(sbd, &s->rblit);
memory_region_init_io(&s->tec, OBJECT(s), &tcx_dummy_ops, s,
"tcx.tec", TCX_TEC_NREGS);
sysbus_init_mmio(sbd, &s->tec);
memory_region_init_io(&s->dac, OBJECT(s), &tcx_dac_ops, s,
"tcx.dac", TCX_DAC_NREGS);
sysbus_init_mmio(sbd, &s->dac);
memory_region_init_io(&s->thc, OBJECT(s), &tcx_thc_ops, s, "tcx.thc",
TCX_THC_NREGS);
sysbus_init_mmio(sbd, &s->thc);
memory_region_init_io(&s->dhc, OBJECT(s), &tcx_dummy_ops, s, "tcx.dhc",
TCX_DHC_NREGS);
sysbus_init_mmio(sbd, &s->dhc);
memory_region_init_io(&s->alt, OBJECT(s), &tcx_dummy_ops, s, "tcx.alt",
TCX_ALT_NREGS);
sysbus_init_mmio(sbd, &s->alt);
return;
}
| [
"static void FUNC_0(Object *VAR_0)\n{",
"SysBusDevice *sbd = SYS_BUS_DEVICE(VAR_0);",
"TCXState *s = TCX(VAR_0);",
"memory_region_init_ram(&s->rom, NULL, \"tcx.prom\", FCODE_MAX_ROM_SIZE,\n&error_abort);",
"memory_region_set_readonly(&s->rom, true);",
"sysbus_init_mmio(sbd, &s->rom);",
"memory_region_init_io(&s->stip, OBJECT(s), &tcx_stip_ops, s, \"tcx.stip\",\nTCX_STIP_NREGS);",
"sysbus_init_mmio(sbd, &s->stip);",
"memory_region_init_io(&s->blit, OBJECT(s), &tcx_blit_ops, s, \"tcx.blit\",\nTCX_BLIT_NREGS);",
"sysbus_init_mmio(sbd, &s->blit);",
"memory_region_init_io(&s->rstip, OBJECT(s), &tcx_rstip_ops, s, \"tcx.rstip\",\nTCX_RSTIP_NREGS);",
"sysbus_init_mmio(sbd, &s->rstip);",
"memory_region_init_io(&s->rblit, OBJECT(s), &tcx_rblit_ops, s, \"tcx.rblit\",\nTCX_RBLIT_NREGS);",
"sysbus_init_mmio(sbd, &s->rblit);",
"memory_region_init_io(&s->tec, OBJECT(s), &tcx_dummy_ops, s,\n\"tcx.tec\", TCX_TEC_NREGS);",
"sysbus_init_mmio(sbd, &s->tec);",
"memory_region_init_io(&s->dac, OBJECT(s), &tcx_dac_ops, s,\n\"tcx.dac\", TCX_DAC_NREGS);",
"sysbus_init_mmio(sbd, &s->dac);",
"memory_region_init_io(&s->thc, OBJECT(s), &tcx_thc_ops, s, \"tcx.thc\",\nTCX_THC_NREGS);",
"sysbus_init_mmio(sbd, &s->thc);",
"memory_region_init_io(&s->dhc, OBJECT(s), &tcx_dummy_ops, s, \"tcx.dhc\",\nTCX_DHC_NREGS);",
"sysbus_init_mmio(sbd, &s->dhc);",
"memory_region_init_io(&s->alt, OBJECT(s), &tcx_dummy_ops, s, \"tcx.alt\",\nTCX_ALT_NREGS);",
"sysbus_init_mmio(sbd, &s->alt);",
"return;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15
],
[
17
],
[
23,
25
],
[
27
],
[
33,
35
],
[
37
],
[
43,
45
],
[
47
],
[
53,
55
],
[
57
],
[
63,
65
],
[
67
],
[
73,
75
],
[
77
],
[
83,
85
],
[
87
],
[
93,
95
],
[
97
],
[
103,
105
],
[
107
],
[
111
],
[
113
]
] |
20,858 | static int alloc_buffer(AVCodecContext *s, InputStream *ist, FrameBuffer **pbuf)
{
FrameBuffer *buf = av_mallocz(sizeof(*buf));
int i, ret;
const int pixel_size = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1+1;
int h_chroma_shift, v_chroma_shift;
int edge = 32; // XXX should be avcodec_get_edge_width(), but that fails on svq1
int w = s->width, h = s->height;
if (!buf)
return AVERROR(ENOMEM);
if (!(s->flags & CODEC_FLAG_EMU_EDGE)) {
w += 2*edge;
h += 2*edge;
}
avcodec_align_dimensions(s, &w, &h);
if ((ret = av_image_alloc(buf->base, buf->linesize, w, h,
s->pix_fmt, 32)) < 0) {
av_freep(&buf);
return ret;
}
/* XXX this shouldn't be needed, but some tests break without this line
* those decoders are buggy and need to be fixed.
* the following tests fail:
* bethsoft-vid, cdgraphics, ansi, aasc, fraps-v1, qtrle-1bit
*/
memset(buf->base[0], 128, ret);
avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);
for (i = 0; i < FF_ARRAY_ELEMS(buf->data); i++) {
const int h_shift = i==0 ? 0 : h_chroma_shift;
const int v_shift = i==0 ? 0 : v_chroma_shift;
if (s->flags & CODEC_FLAG_EMU_EDGE)
buf->data[i] = buf->base[i];
else
buf->data[i] = buf->base[i] +
FFALIGN((buf->linesize[i]*edge >> v_shift) +
(pixel_size*edge >> h_shift), 32);
}
buf->w = s->width;
buf->h = s->height;
buf->pix_fmt = s->pix_fmt;
buf->ist = ist;
*pbuf = buf;
return 0;
}
| true | FFmpeg | 60991ad6ae61e131085891c37e8e517b5014ce21 | static int alloc_buffer(AVCodecContext *s, InputStream *ist, FrameBuffer **pbuf)
{
FrameBuffer *buf = av_mallocz(sizeof(*buf));
int i, ret;
const int pixel_size = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1+1;
int h_chroma_shift, v_chroma_shift;
int edge = 32;
int w = s->width, h = s->height;
if (!buf)
return AVERROR(ENOMEM);
if (!(s->flags & CODEC_FLAG_EMU_EDGE)) {
w += 2*edge;
h += 2*edge;
}
avcodec_align_dimensions(s, &w, &h);
if ((ret = av_image_alloc(buf->base, buf->linesize, w, h,
s->pix_fmt, 32)) < 0) {
av_freep(&buf);
return ret;
}
memset(buf->base[0], 128, ret);
avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);
for (i = 0; i < FF_ARRAY_ELEMS(buf->data); i++) {
const int h_shift = i==0 ? 0 : h_chroma_shift;
const int v_shift = i==0 ? 0 : v_chroma_shift;
if (s->flags & CODEC_FLAG_EMU_EDGE)
buf->data[i] = buf->base[i];
else
buf->data[i] = buf->base[i] +
FFALIGN((buf->linesize[i]*edge >> v_shift) +
(pixel_size*edge >> h_shift), 32);
}
buf->w = s->width;
buf->h = s->height;
buf->pix_fmt = s->pix_fmt;
buf->ist = ist;
*pbuf = buf;
return 0;
}
| {
"code": [
" if (s->flags & CODEC_FLAG_EMU_EDGE)"
],
"line_no": [
69
]
} | static int FUNC_0(AVCodecContext *VAR_0, InputStream *VAR_1, FrameBuffer **VAR_2)
{
FrameBuffer *buf = av_mallocz(sizeof(*buf));
int VAR_3, VAR_4;
const int VAR_5 = av_pix_fmt_descriptors[VAR_0->pix_fmt].comp[0].step_minus1+1;
int VAR_6, VAR_7;
int VAR_8 = 32;
int VAR_9 = VAR_0->width, VAR_10 = VAR_0->height;
if (!buf)
return AVERROR(ENOMEM);
if (!(VAR_0->flags & CODEC_FLAG_EMU_EDGE)) {
VAR_9 += 2*VAR_8;
VAR_10 += 2*VAR_8;
}
avcodec_align_dimensions(VAR_0, &VAR_9, &VAR_10);
if ((VAR_4 = av_image_alloc(buf->base, buf->linesize, VAR_9, VAR_10,
VAR_0->pix_fmt, 32)) < 0) {
av_freep(&buf);
return VAR_4;
}
memset(buf->base[0], 128, VAR_4);
avcodec_get_chroma_sub_sample(VAR_0->pix_fmt, &VAR_6, &VAR_7);
for (VAR_3 = 0; VAR_3 < FF_ARRAY_ELEMS(buf->data); VAR_3++) {
const int h_shift = VAR_3==0 ? 0 : VAR_6;
const int v_shift = VAR_3==0 ? 0 : VAR_7;
if (VAR_0->flags & CODEC_FLAG_EMU_EDGE)
buf->data[VAR_3] = buf->base[VAR_3];
else
buf->data[VAR_3] = buf->base[VAR_3] +
FFALIGN((buf->linesize[VAR_3]*VAR_8 >> v_shift) +
(VAR_5*VAR_8 >> h_shift), 32);
}
buf->VAR_9 = VAR_0->width;
buf->VAR_10 = VAR_0->height;
buf->pix_fmt = VAR_0->pix_fmt;
buf->VAR_1 = VAR_1;
*VAR_2 = buf;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, InputStream *VAR_1, FrameBuffer **VAR_2)\n{",
"FrameBuffer *buf = av_mallocz(sizeof(*buf));",
"int VAR_3, VAR_4;",
"const int VAR_5 = av_pix_fmt_descriptors[VAR_0->pix_fmt].comp[0].step_minus1+1;",
"int VAR_6, VAR_7;",
"int VAR_8 = 32;",
"int VAR_9 = VAR_0->width, VAR_10 = VAR_0->height;",
"if (!buf)\nreturn AVERROR(ENOMEM);",
"if (!(VAR_0->flags & CODEC_FLAG_EMU_EDGE)) {",
"VAR_9 += 2*VAR_8;",
"VAR_10 += 2*VAR_8;",
"}",
"avcodec_align_dimensions(VAR_0, &VAR_9, &VAR_10);",
"if ((VAR_4 = av_image_alloc(buf->base, buf->linesize, VAR_9, VAR_10,\nVAR_0->pix_fmt, 32)) < 0) {",
"av_freep(&buf);",
"return VAR_4;",
"}",
"memset(buf->base[0], 128, VAR_4);",
"avcodec_get_chroma_sub_sample(VAR_0->pix_fmt, &VAR_6, &VAR_7);",
"for (VAR_3 = 0; VAR_3 < FF_ARRAY_ELEMS(buf->data); VAR_3++) {",
"const int h_shift = VAR_3==0 ? 0 : VAR_6;",
"const int v_shift = VAR_3==0 ? 0 : VAR_7;",
"if (VAR_0->flags & CODEC_FLAG_EMU_EDGE)\nbuf->data[VAR_3] = buf->base[VAR_3];",
"else\nbuf->data[VAR_3] = buf->base[VAR_3] +\nFFALIGN((buf->linesize[VAR_3]*VAR_8 >> v_shift) +\n(VAR_5*VAR_8 >> h_shift), 32);",
"}",
"buf->VAR_9 = VAR_0->width;",
"buf->VAR_10 = VAR_0->height;",
"buf->pix_fmt = VAR_0->pix_fmt;",
"buf->VAR_1 = VAR_1;",
"*VAR_2 = buf;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73,
75,
77,
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
]
] |
20,859 | static void x86_cpu_initfn(Object *obj)
{
CPUState *cs = CPU(obj);
X86CPU *cpu = X86_CPU(obj);
X86CPUClass *xcc = X86_CPU_GET_CLASS(obj);
CPUX86State *env = &cpu->env;
FeatureWord w;
cs->env_ptr = env;
object_property_add(obj, "family", "int",
x86_cpuid_version_get_family,
x86_cpuid_version_set_family, NULL, NULL, NULL);
object_property_add(obj, "model", "int",
x86_cpuid_version_get_model,
x86_cpuid_version_set_model, NULL, NULL, NULL);
object_property_add(obj, "stepping", "int",
x86_cpuid_version_get_stepping,
x86_cpuid_version_set_stepping, NULL, NULL, NULL);
object_property_add_str(obj, "vendor",
x86_cpuid_get_vendor,
x86_cpuid_set_vendor, NULL);
object_property_add_str(obj, "model-id",
x86_cpuid_get_model_id,
x86_cpuid_set_model_id, NULL);
object_property_add(obj, "tsc-frequency", "int",
x86_cpuid_get_tsc_freq,
x86_cpuid_set_tsc_freq, NULL, NULL, NULL);
object_property_add(obj, "feature-words", "X86CPUFeatureWordInfo",
x86_cpu_get_feature_words,
NULL, NULL, (void *)env->features, NULL);
object_property_add(obj, "filtered-features", "X86CPUFeatureWordInfo",
x86_cpu_get_feature_words,
NULL, NULL, (void *)cpu->filtered_features, NULL);
cpu->hyperv_spinlock_attempts = HYPERV_SPINLOCK_NEVER_RETRY;
for (w = 0; w < FEATURE_WORDS; w++) {
int bitnr;
for (bitnr = 0; bitnr < 32; bitnr++) {
x86_cpu_register_feature_bit_props(cpu, w, bitnr);
}
}
object_property_add_alias(obj, "sse3", obj, "pni", &error_abort);
object_property_add_alias(obj, "pclmuldq", obj, "pclmulqdq", &error_abort);
object_property_add_alias(obj, "sse4-1", obj, "sse4.1", &error_abort);
object_property_add_alias(obj, "sse4-2", obj, "sse4.2", &error_abort);
object_property_add_alias(obj, "xd", obj, "nx", &error_abort);
object_property_add_alias(obj, "ffxsr", obj, "fxsr-opt", &error_abort);
object_property_add_alias(obj, "i64", obj, "lm", &error_abort);
object_property_add_alias(obj, "ds_cpl", obj, "ds-cpl", &error_abort);
object_property_add_alias(obj, "tsc_adjust", obj, "tsc-adjust", &error_abort);
object_property_add_alias(obj, "fxsr_opt", obj, "fxsr-opt", &error_abort);
object_property_add_alias(obj, "lahf_lm", obj, "lahf-lm", &error_abort);
object_property_add_alias(obj, "cmp_legacy", obj, "cmp-legacy", &error_abort);
object_property_add_alias(obj, "nodeid_msr", obj, "nodeid-msr", &error_abort);
object_property_add_alias(obj, "perfctr_core", obj, "perfctr-core", &error_abort);
object_property_add_alias(obj, "perfctr_nb", obj, "perfctr-nb", &error_abort);
object_property_add_alias(obj, "kvm_nopiodelay", obj, "kvm-nopiodelay", &error_abort);
object_property_add_alias(obj, "kvm_mmu", obj, "kvm-mmu", &error_abort);
object_property_add_alias(obj, "kvm_asyncpf", obj, "kvm-asyncpf", &error_abort);
object_property_add_alias(obj, "kvm_steal_time", obj, "kvm-steal-time", &error_abort);
object_property_add_alias(obj, "kvm_pv_eoi", obj, "kvm-pv-eoi", &error_abort);
object_property_add_alias(obj, "kvm_pv_unhalt", obj, "kvm-pv-unhalt", &error_abort);
object_property_add_alias(obj, "svm_lock", obj, "svm-lock", &error_abort);
object_property_add_alias(obj, "nrip_save", obj, "nrip-save", &error_abort);
object_property_add_alias(obj, "tsc_scale", obj, "tsc-scale", &error_abort);
object_property_add_alias(obj, "vmcb_clean", obj, "vmcb-clean", &error_abort);
object_property_add_alias(obj, "pause_filter", obj, "pause-filter", &error_abort);
object_property_add_alias(obj, "sse4_1", obj, "sse4.1", &error_abort);
object_property_add_alias(obj, "sse4_2", obj, "sse4.2", &error_abort);
x86_cpu_load_def(cpu, xcc->cpu_def, &error_abort);
} | true | qemu | d187e08dc4d0793dab1a9747b72b17a1cf0d3e43 | static void x86_cpu_initfn(Object *obj)
{
CPUState *cs = CPU(obj);
X86CPU *cpu = X86_CPU(obj);
X86CPUClass *xcc = X86_CPU_GET_CLASS(obj);
CPUX86State *env = &cpu->env;
FeatureWord w;
cs->env_ptr = env;
object_property_add(obj, "family", "int",
x86_cpuid_version_get_family,
x86_cpuid_version_set_family, NULL, NULL, NULL);
object_property_add(obj, "model", "int",
x86_cpuid_version_get_model,
x86_cpuid_version_set_model, NULL, NULL, NULL);
object_property_add(obj, "stepping", "int",
x86_cpuid_version_get_stepping,
x86_cpuid_version_set_stepping, NULL, NULL, NULL);
object_property_add_str(obj, "vendor",
x86_cpuid_get_vendor,
x86_cpuid_set_vendor, NULL);
object_property_add_str(obj, "model-id",
x86_cpuid_get_model_id,
x86_cpuid_set_model_id, NULL);
object_property_add(obj, "tsc-frequency", "int",
x86_cpuid_get_tsc_freq,
x86_cpuid_set_tsc_freq, NULL, NULL, NULL);
object_property_add(obj, "feature-words", "X86CPUFeatureWordInfo",
x86_cpu_get_feature_words,
NULL, NULL, (void *)env->features, NULL);
object_property_add(obj, "filtered-features", "X86CPUFeatureWordInfo",
x86_cpu_get_feature_words,
NULL, NULL, (void *)cpu->filtered_features, NULL);
cpu->hyperv_spinlock_attempts = HYPERV_SPINLOCK_NEVER_RETRY;
for (w = 0; w < FEATURE_WORDS; w++) {
int bitnr;
for (bitnr = 0; bitnr < 32; bitnr++) {
x86_cpu_register_feature_bit_props(cpu, w, bitnr);
}
}
object_property_add_alias(obj, "sse3", obj, "pni", &error_abort);
object_property_add_alias(obj, "pclmuldq", obj, "pclmulqdq", &error_abort);
object_property_add_alias(obj, "sse4-1", obj, "sse4.1", &error_abort);
object_property_add_alias(obj, "sse4-2", obj, "sse4.2", &error_abort);
object_property_add_alias(obj, "xd", obj, "nx", &error_abort);
object_property_add_alias(obj, "ffxsr", obj, "fxsr-opt", &error_abort);
object_property_add_alias(obj, "i64", obj, "lm", &error_abort);
object_property_add_alias(obj, "ds_cpl", obj, "ds-cpl", &error_abort);
object_property_add_alias(obj, "tsc_adjust", obj, "tsc-adjust", &error_abort);
object_property_add_alias(obj, "fxsr_opt", obj, "fxsr-opt", &error_abort);
object_property_add_alias(obj, "lahf_lm", obj, "lahf-lm", &error_abort);
object_property_add_alias(obj, "cmp_legacy", obj, "cmp-legacy", &error_abort);
object_property_add_alias(obj, "nodeid_msr", obj, "nodeid-msr", &error_abort);
object_property_add_alias(obj, "perfctr_core", obj, "perfctr-core", &error_abort);
object_property_add_alias(obj, "perfctr_nb", obj, "perfctr-nb", &error_abort);
object_property_add_alias(obj, "kvm_nopiodelay", obj, "kvm-nopiodelay", &error_abort);
object_property_add_alias(obj, "kvm_mmu", obj, "kvm-mmu", &error_abort);
object_property_add_alias(obj, "kvm_asyncpf", obj, "kvm-asyncpf", &error_abort);
object_property_add_alias(obj, "kvm_steal_time", obj, "kvm-steal-time", &error_abort);
object_property_add_alias(obj, "kvm_pv_eoi", obj, "kvm-pv-eoi", &error_abort);
object_property_add_alias(obj, "kvm_pv_unhalt", obj, "kvm-pv-unhalt", &error_abort);
object_property_add_alias(obj, "svm_lock", obj, "svm-lock", &error_abort);
object_property_add_alias(obj, "nrip_save", obj, "nrip-save", &error_abort);
object_property_add_alias(obj, "tsc_scale", obj, "tsc-scale", &error_abort);
object_property_add_alias(obj, "vmcb_clean", obj, "vmcb-clean", &error_abort);
object_property_add_alias(obj, "pause_filter", obj, "pause-filter", &error_abort);
object_property_add_alias(obj, "sse4_1", obj, "sse4.1", &error_abort);
object_property_add_alias(obj, "sse4_2", obj, "sse4.2", &error_abort);
x86_cpu_load_def(cpu, xcc->cpu_def, &error_abort);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(Object *VAR_0)
{
CPUState *cs = CPU(VAR_0);
X86CPU *cpu = X86_CPU(VAR_0);
X86CPUClass *xcc = X86_CPU_GET_CLASS(VAR_0);
CPUX86State *env = &cpu->env;
FeatureWord w;
cs->env_ptr = env;
object_property_add(VAR_0, "family", "int",
x86_cpuid_version_get_family,
x86_cpuid_version_set_family, NULL, NULL, NULL);
object_property_add(VAR_0, "model", "int",
x86_cpuid_version_get_model,
x86_cpuid_version_set_model, NULL, NULL, NULL);
object_property_add(VAR_0, "stepping", "int",
x86_cpuid_version_get_stepping,
x86_cpuid_version_set_stepping, NULL, NULL, NULL);
object_property_add_str(VAR_0, "vendor",
x86_cpuid_get_vendor,
x86_cpuid_set_vendor, NULL);
object_property_add_str(VAR_0, "model-id",
x86_cpuid_get_model_id,
x86_cpuid_set_model_id, NULL);
object_property_add(VAR_0, "tsc-frequency", "int",
x86_cpuid_get_tsc_freq,
x86_cpuid_set_tsc_freq, NULL, NULL, NULL);
object_property_add(VAR_0, "feature-words", "X86CPUFeatureWordInfo",
x86_cpu_get_feature_words,
NULL, NULL, (void *)env->features, NULL);
object_property_add(VAR_0, "filtered-features", "X86CPUFeatureWordInfo",
x86_cpu_get_feature_words,
NULL, NULL, (void *)cpu->filtered_features, NULL);
cpu->hyperv_spinlock_attempts = HYPERV_SPINLOCK_NEVER_RETRY;
for (w = 0; w < FEATURE_WORDS; w++) {
int bitnr;
for (bitnr = 0; bitnr < 32; bitnr++) {
x86_cpu_register_feature_bit_props(cpu, w, bitnr);
}
}
object_property_add_alias(VAR_0, "sse3", VAR_0, "pni", &error_abort);
object_property_add_alias(VAR_0, "pclmuldq", VAR_0, "pclmulqdq", &error_abort);
object_property_add_alias(VAR_0, "sse4-1", VAR_0, "sse4.1", &error_abort);
object_property_add_alias(VAR_0, "sse4-2", VAR_0, "sse4.2", &error_abort);
object_property_add_alias(VAR_0, "xd", VAR_0, "nx", &error_abort);
object_property_add_alias(VAR_0, "ffxsr", VAR_0, "fxsr-opt", &error_abort);
object_property_add_alias(VAR_0, "i64", VAR_0, "lm", &error_abort);
object_property_add_alias(VAR_0, "ds_cpl", VAR_0, "ds-cpl", &error_abort);
object_property_add_alias(VAR_0, "tsc_adjust", VAR_0, "tsc-adjust", &error_abort);
object_property_add_alias(VAR_0, "fxsr_opt", VAR_0, "fxsr-opt", &error_abort);
object_property_add_alias(VAR_0, "lahf_lm", VAR_0, "lahf-lm", &error_abort);
object_property_add_alias(VAR_0, "cmp_legacy", VAR_0, "cmp-legacy", &error_abort);
object_property_add_alias(VAR_0, "nodeid_msr", VAR_0, "nodeid-msr", &error_abort);
object_property_add_alias(VAR_0, "perfctr_core", VAR_0, "perfctr-core", &error_abort);
object_property_add_alias(VAR_0, "perfctr_nb", VAR_0, "perfctr-nb", &error_abort);
object_property_add_alias(VAR_0, "kvm_nopiodelay", VAR_0, "kvm-nopiodelay", &error_abort);
object_property_add_alias(VAR_0, "kvm_mmu", VAR_0, "kvm-mmu", &error_abort);
object_property_add_alias(VAR_0, "kvm_asyncpf", VAR_0, "kvm-asyncpf", &error_abort);
object_property_add_alias(VAR_0, "kvm_steal_time", VAR_0, "kvm-steal-time", &error_abort);
object_property_add_alias(VAR_0, "kvm_pv_eoi", VAR_0, "kvm-pv-eoi", &error_abort);
object_property_add_alias(VAR_0, "kvm_pv_unhalt", VAR_0, "kvm-pv-unhalt", &error_abort);
object_property_add_alias(VAR_0, "svm_lock", VAR_0, "svm-lock", &error_abort);
object_property_add_alias(VAR_0, "nrip_save", VAR_0, "nrip-save", &error_abort);
object_property_add_alias(VAR_0, "tsc_scale", VAR_0, "tsc-scale", &error_abort);
object_property_add_alias(VAR_0, "vmcb_clean", VAR_0, "vmcb-clean", &error_abort);
object_property_add_alias(VAR_0, "pause_filter", VAR_0, "pause-filter", &error_abort);
object_property_add_alias(VAR_0, "sse4_1", VAR_0, "sse4.1", &error_abort);
object_property_add_alias(VAR_0, "sse4_2", VAR_0, "sse4.2", &error_abort);
x86_cpu_load_def(cpu, xcc->cpu_def, &error_abort);
} | [
"static void FUNC_0(Object *VAR_0)\n{",
"CPUState *cs = CPU(VAR_0);",
"X86CPU *cpu = X86_CPU(VAR_0);",
"X86CPUClass *xcc = X86_CPU_GET_CLASS(VAR_0);",
"CPUX86State *env = &cpu->env;",
"FeatureWord w;",
"cs->env_ptr = env;",
"object_property_add(VAR_0, \"family\", \"int\",\nx86_cpuid_version_get_family,\nx86_cpuid_version_set_family, NULL, NULL, NULL);",
"object_property_add(VAR_0, \"model\", \"int\",\nx86_cpuid_version_get_model,\nx86_cpuid_version_set_model, NULL, NULL, NULL);",
"object_property_add(VAR_0, \"stepping\", \"int\",\nx86_cpuid_version_get_stepping,\nx86_cpuid_version_set_stepping, NULL, NULL, NULL);",
"object_property_add_str(VAR_0, \"vendor\",\nx86_cpuid_get_vendor,\nx86_cpuid_set_vendor, NULL);",
"object_property_add_str(VAR_0, \"model-id\",\nx86_cpuid_get_model_id,\nx86_cpuid_set_model_id, NULL);",
"object_property_add(VAR_0, \"tsc-frequency\", \"int\",\nx86_cpuid_get_tsc_freq,\nx86_cpuid_set_tsc_freq, NULL, NULL, NULL);",
"object_property_add(VAR_0, \"feature-words\", \"X86CPUFeatureWordInfo\",\nx86_cpu_get_feature_words,\nNULL, NULL, (void *)env->features, NULL);",
"object_property_add(VAR_0, \"filtered-features\", \"X86CPUFeatureWordInfo\",\nx86_cpu_get_feature_words,\nNULL, NULL, (void *)cpu->filtered_features, NULL);",
"cpu->hyperv_spinlock_attempts = HYPERV_SPINLOCK_NEVER_RETRY;",
"for (w = 0; w < FEATURE_WORDS; w++) {",
"int bitnr;",
"for (bitnr = 0; bitnr < 32; bitnr++) {",
"x86_cpu_register_feature_bit_props(cpu, w, bitnr);",
"}",
"}",
"object_property_add_alias(VAR_0, \"sse3\", VAR_0, \"pni\", &error_abort);",
"object_property_add_alias(VAR_0, \"pclmuldq\", VAR_0, \"pclmulqdq\", &error_abort);",
"object_property_add_alias(VAR_0, \"sse4-1\", VAR_0, \"sse4.1\", &error_abort);",
"object_property_add_alias(VAR_0, \"sse4-2\", VAR_0, \"sse4.2\", &error_abort);",
"object_property_add_alias(VAR_0, \"xd\", VAR_0, \"nx\", &error_abort);",
"object_property_add_alias(VAR_0, \"ffxsr\", VAR_0, \"fxsr-opt\", &error_abort);",
"object_property_add_alias(VAR_0, \"i64\", VAR_0, \"lm\", &error_abort);",
"object_property_add_alias(VAR_0, \"ds_cpl\", VAR_0, \"ds-cpl\", &error_abort);",
"object_property_add_alias(VAR_0, \"tsc_adjust\", VAR_0, \"tsc-adjust\", &error_abort);",
"object_property_add_alias(VAR_0, \"fxsr_opt\", VAR_0, \"fxsr-opt\", &error_abort);",
"object_property_add_alias(VAR_0, \"lahf_lm\", VAR_0, \"lahf-lm\", &error_abort);",
"object_property_add_alias(VAR_0, \"cmp_legacy\", VAR_0, \"cmp-legacy\", &error_abort);",
"object_property_add_alias(VAR_0, \"nodeid_msr\", VAR_0, \"nodeid-msr\", &error_abort);",
"object_property_add_alias(VAR_0, \"perfctr_core\", VAR_0, \"perfctr-core\", &error_abort);",
"object_property_add_alias(VAR_0, \"perfctr_nb\", VAR_0, \"perfctr-nb\", &error_abort);",
"object_property_add_alias(VAR_0, \"kvm_nopiodelay\", VAR_0, \"kvm-nopiodelay\", &error_abort);",
"object_property_add_alias(VAR_0, \"kvm_mmu\", VAR_0, \"kvm-mmu\", &error_abort);",
"object_property_add_alias(VAR_0, \"kvm_asyncpf\", VAR_0, \"kvm-asyncpf\", &error_abort);",
"object_property_add_alias(VAR_0, \"kvm_steal_time\", VAR_0, \"kvm-steal-time\", &error_abort);",
"object_property_add_alias(VAR_0, \"kvm_pv_eoi\", VAR_0, \"kvm-pv-eoi\", &error_abort);",
"object_property_add_alias(VAR_0, \"kvm_pv_unhalt\", VAR_0, \"kvm-pv-unhalt\", &error_abort);",
"object_property_add_alias(VAR_0, \"svm_lock\", VAR_0, \"svm-lock\", &error_abort);",
"object_property_add_alias(VAR_0, \"nrip_save\", VAR_0, \"nrip-save\", &error_abort);",
"object_property_add_alias(VAR_0, \"tsc_scale\", VAR_0, \"tsc-scale\", &error_abort);",
"object_property_add_alias(VAR_0, \"vmcb_clean\", VAR_0, \"vmcb-clean\", &error_abort);",
"object_property_add_alias(VAR_0, \"pause_filter\", VAR_0, \"pause-filter\", &error_abort);",
"object_property_add_alias(VAR_0, \"sse4_1\", VAR_0, \"sse4.1\", &error_abort);",
"object_property_add_alias(VAR_0, \"sse4_2\", VAR_0, \"sse4.2\", &error_abort);",
"x86_cpu_load_def(cpu, xcc->cpu_def, &error_abort);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
50
],
[
51
],
[
52
],
[
53
],
[
54
],
[
55
],
[
56
],
[
57
],
[
58
],
[
59
],
[
60
],
[
61
],
[
62
],
[
63
],
[
64
],
[
65
],
[
66
],
[
67
],
[
68
],
[
69
]
] |
20,860 | static void video_refresh_timer(void *opaque)
{
VideoState *is = opaque;
VideoPicture *vp;
SubPicture *sp, *sp2;
if (is->video_st) {
if (is->pictq_size == 0) {
/* if no picture, need to wait */
schedule_refresh(is, 1);
} else {
/* dequeue the picture */
vp = &is->pictq[is->pictq_rindex];
/* update current video pts */
is->video_current_pts = vp->pts;
is->video_current_pts_time = av_gettime();
/* launch timer for next picture */
schedule_refresh(is, (int)(compute_frame_delay(vp->pts, is) * 1000 + 0.5));
if(is->subtitle_st) {
if (is->subtitle_stream_changed) {
SDL_LockMutex(is->subpq_mutex);
while (is->subpq_size) {
free_subpicture(&is->subpq[is->subpq_rindex]);
/* update queue size and signal for next picture */
if (++is->subpq_rindex == SUBPICTURE_QUEUE_SIZE)
is->subpq_rindex = 0;
is->subpq_size--;
}
is->subtitle_stream_changed = 0;
SDL_CondSignal(is->subpq_cond);
SDL_UnlockMutex(is->subpq_mutex);
} else {
if (is->subpq_size > 0) {
sp = &is->subpq[is->subpq_rindex];
if (is->subpq_size > 1)
sp2 = &is->subpq[(is->subpq_rindex + 1) % SUBPICTURE_QUEUE_SIZE];
else
sp2 = NULL;
if ((is->video_current_pts > (sp->pts + ((float) sp->sub.end_display_time / 1000)))
|| (sp2 && is->video_current_pts > (sp2->pts + ((float) sp2->sub.start_display_time / 1000))))
{
free_subpicture(sp);
/* update queue size and signal for next picture */
if (++is->subpq_rindex == SUBPICTURE_QUEUE_SIZE)
is->subpq_rindex = 0;
SDL_LockMutex(is->subpq_mutex);
is->subpq_size--;
SDL_CondSignal(is->subpq_cond);
SDL_UnlockMutex(is->subpq_mutex);
}
}
}
}
/* display picture */
video_display(is);
/* update queue size and signal for next picture */
if (++is->pictq_rindex == VIDEO_PICTURE_QUEUE_SIZE)
is->pictq_rindex = 0;
SDL_LockMutex(is->pictq_mutex);
is->pictq_size--;
SDL_CondSignal(is->pictq_cond);
SDL_UnlockMutex(is->pictq_mutex);
}
} else if (is->audio_st) {
/* draw the next audio frame */
schedule_refresh(is, 40);
/* if only audio stream, then display the audio bars (better
than nothing, just to test the implementation */
/* display picture */
video_display(is);
} else {
schedule_refresh(is, 100);
}
if (show_status) {
static int64_t last_time;
int64_t cur_time;
int aqsize, vqsize, sqsize;
double av_diff;
cur_time = av_gettime();
if (!last_time || (cur_time - last_time) >= 30000) {
aqsize = 0;
vqsize = 0;
sqsize = 0;
if (is->audio_st)
aqsize = is->audioq.size;
if (is->video_st)
vqsize = is->videoq.size;
if (is->subtitle_st)
sqsize = is->subtitleq.size;
av_diff = 0;
if (is->audio_st && is->video_st)
av_diff = get_audio_clock(is) - get_video_clock(is);
printf("%7.2f A-V:%7.3f aq=%5dKB vq=%5dKB sq=%5dB f=%Ld/%Ld \r",
get_master_clock(is), av_diff, aqsize / 1024, vqsize / 1024, sqsize, is->faulty_dts, is->faulty_pts);
fflush(stdout);
last_time = cur_time;
}
}
}
| true | FFmpeg | 68aefbe81cb3b9dd002108782bb8d798e1c12806 | static void video_refresh_timer(void *opaque)
{
VideoState *is = opaque;
VideoPicture *vp;
SubPicture *sp, *sp2;
if (is->video_st) {
if (is->pictq_size == 0) {
schedule_refresh(is, 1);
} else {
vp = &is->pictq[is->pictq_rindex];
is->video_current_pts = vp->pts;
is->video_current_pts_time = av_gettime();
schedule_refresh(is, (int)(compute_frame_delay(vp->pts, is) * 1000 + 0.5));
if(is->subtitle_st) {
if (is->subtitle_stream_changed) {
SDL_LockMutex(is->subpq_mutex);
while (is->subpq_size) {
free_subpicture(&is->subpq[is->subpq_rindex]);
if (++is->subpq_rindex == SUBPICTURE_QUEUE_SIZE)
is->subpq_rindex = 0;
is->subpq_size--;
}
is->subtitle_stream_changed = 0;
SDL_CondSignal(is->subpq_cond);
SDL_UnlockMutex(is->subpq_mutex);
} else {
if (is->subpq_size > 0) {
sp = &is->subpq[is->subpq_rindex];
if (is->subpq_size > 1)
sp2 = &is->subpq[(is->subpq_rindex + 1) % SUBPICTURE_QUEUE_SIZE];
else
sp2 = NULL;
if ((is->video_current_pts > (sp->pts + ((float) sp->sub.end_display_time / 1000)))
|| (sp2 && is->video_current_pts > (sp2->pts + ((float) sp2->sub.start_display_time / 1000))))
{
free_subpicture(sp);
if (++is->subpq_rindex == SUBPICTURE_QUEUE_SIZE)
is->subpq_rindex = 0;
SDL_LockMutex(is->subpq_mutex);
is->subpq_size--;
SDL_CondSignal(is->subpq_cond);
SDL_UnlockMutex(is->subpq_mutex);
}
}
}
}
video_display(is);
if (++is->pictq_rindex == VIDEO_PICTURE_QUEUE_SIZE)
is->pictq_rindex = 0;
SDL_LockMutex(is->pictq_mutex);
is->pictq_size--;
SDL_CondSignal(is->pictq_cond);
SDL_UnlockMutex(is->pictq_mutex);
}
} else if (is->audio_st) {
schedule_refresh(is, 40);
video_display(is);
} else {
schedule_refresh(is, 100);
}
if (show_status) {
static int64_t last_time;
int64_t cur_time;
int aqsize, vqsize, sqsize;
double av_diff;
cur_time = av_gettime();
if (!last_time || (cur_time - last_time) >= 30000) {
aqsize = 0;
vqsize = 0;
sqsize = 0;
if (is->audio_st)
aqsize = is->audioq.size;
if (is->video_st)
vqsize = is->videoq.size;
if (is->subtitle_st)
sqsize = is->subtitleq.size;
av_diff = 0;
if (is->audio_st && is->video_st)
av_diff = get_audio_clock(is) - get_video_clock(is);
printf("%7.2f A-V:%7.3f aq=%5dKB vq=%5dKB sq=%5dB f=%Ld/%Ld \r",
get_master_clock(is), av_diff, aqsize / 1024, vqsize / 1024, sqsize, is->faulty_dts, is->faulty_pts);
fflush(stdout);
last_time = cur_time;
}
}
}
| {
"code": [
" is->video_current_pts_time = av_gettime();"
],
"line_no": [
35
]
} | static void FUNC_0(void *VAR_0)
{
VideoState *is = VAR_0;
VideoPicture *vp;
SubPicture *sp, *sp2;
if (is->video_st) {
if (is->pictq_size == 0) {
schedule_refresh(is, 1);
} else {
vp = &is->pictq[is->pictq_rindex];
is->video_current_pts = vp->pts;
is->video_current_pts_time = av_gettime();
schedule_refresh(is, (int)(compute_frame_delay(vp->pts, is) * 1000 + 0.5));
if(is->subtitle_st) {
if (is->subtitle_stream_changed) {
SDL_LockMutex(is->subpq_mutex);
while (is->subpq_size) {
free_subpicture(&is->subpq[is->subpq_rindex]);
if (++is->subpq_rindex == SUBPICTURE_QUEUE_SIZE)
is->subpq_rindex = 0;
is->subpq_size--;
}
is->subtitle_stream_changed = 0;
SDL_CondSignal(is->subpq_cond);
SDL_UnlockMutex(is->subpq_mutex);
} else {
if (is->subpq_size > 0) {
sp = &is->subpq[is->subpq_rindex];
if (is->subpq_size > 1)
sp2 = &is->subpq[(is->subpq_rindex + 1) % SUBPICTURE_QUEUE_SIZE];
else
sp2 = NULL;
if ((is->video_current_pts > (sp->pts + ((float) sp->sub.end_display_time / 1000)))
|| (sp2 && is->video_current_pts > (sp2->pts + ((float) sp2->sub.start_display_time / 1000))))
{
free_subpicture(sp);
if (++is->subpq_rindex == SUBPICTURE_QUEUE_SIZE)
is->subpq_rindex = 0;
SDL_LockMutex(is->subpq_mutex);
is->subpq_size--;
SDL_CondSignal(is->subpq_cond);
SDL_UnlockMutex(is->subpq_mutex);
}
}
}
}
video_display(is);
if (++is->pictq_rindex == VIDEO_PICTURE_QUEUE_SIZE)
is->pictq_rindex = 0;
SDL_LockMutex(is->pictq_mutex);
is->pictq_size--;
SDL_CondSignal(is->pictq_cond);
SDL_UnlockMutex(is->pictq_mutex);
}
} else if (is->audio_st) {
schedule_refresh(is, 40);
video_display(is);
} else {
schedule_refresh(is, 100);
}
if (show_status) {
static int64_t VAR_1;
int64_t cur_time;
int VAR_2, VAR_3, VAR_4;
double VAR_5;
cur_time = av_gettime();
if (!VAR_1 || (cur_time - VAR_1) >= 30000) {
VAR_2 = 0;
VAR_3 = 0;
VAR_4 = 0;
if (is->audio_st)
VAR_2 = is->audioq.size;
if (is->video_st)
VAR_3 = is->videoq.size;
if (is->subtitle_st)
VAR_4 = is->subtitleq.size;
VAR_5 = 0;
if (is->audio_st && is->video_st)
VAR_5 = get_audio_clock(is) - get_video_clock(is);
printf("%7.2f A-V:%7.3f aq=%5dKB vq=%5dKB sq=%5dB f=%Ld/%Ld \r",
get_master_clock(is), VAR_5, VAR_2 / 1024, VAR_3 / 1024, VAR_4, is->faulty_dts, is->faulty_pts);
fflush(stdout);
VAR_1 = cur_time;
}
}
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"VideoState *is = VAR_0;",
"VideoPicture *vp;",
"SubPicture *sp, *sp2;",
"if (is->video_st) {",
"if (is->pictq_size == 0) {",
"schedule_refresh(is, 1);",
"} else {",
"vp = &is->pictq[is->pictq_rindex];",
"is->video_current_pts = vp->pts;",
"is->video_current_pts_time = av_gettime();",
"schedule_refresh(is, (int)(compute_frame_delay(vp->pts, is) * 1000 + 0.5));",
"if(is->subtitle_st) {",
"if (is->subtitle_stream_changed) {",
"SDL_LockMutex(is->subpq_mutex);",
"while (is->subpq_size) {",
"free_subpicture(&is->subpq[is->subpq_rindex]);",
"if (++is->subpq_rindex == SUBPICTURE_QUEUE_SIZE)\nis->subpq_rindex = 0;",
"is->subpq_size--;",
"}",
"is->subtitle_stream_changed = 0;",
"SDL_CondSignal(is->subpq_cond);",
"SDL_UnlockMutex(is->subpq_mutex);",
"} else {",
"if (is->subpq_size > 0) {",
"sp = &is->subpq[is->subpq_rindex];",
"if (is->subpq_size > 1)\nsp2 = &is->subpq[(is->subpq_rindex + 1) % SUBPICTURE_QUEUE_SIZE];",
"else\nsp2 = NULL;",
"if ((is->video_current_pts > (sp->pts + ((float) sp->sub.end_display_time / 1000)))\n|| (sp2 && is->video_current_pts > (sp2->pts + ((float) sp2->sub.start_display_time / 1000))))\n{",
"free_subpicture(sp);",
"if (++is->subpq_rindex == SUBPICTURE_QUEUE_SIZE)\nis->subpq_rindex = 0;",
"SDL_LockMutex(is->subpq_mutex);",
"is->subpq_size--;",
"SDL_CondSignal(is->subpq_cond);",
"SDL_UnlockMutex(is->subpq_mutex);",
"}",
"}",
"}",
"}",
"video_display(is);",
"if (++is->pictq_rindex == VIDEO_PICTURE_QUEUE_SIZE)\nis->pictq_rindex = 0;",
"SDL_LockMutex(is->pictq_mutex);",
"is->pictq_size--;",
"SDL_CondSignal(is->pictq_cond);",
"SDL_UnlockMutex(is->pictq_mutex);",
"}",
"} else if (is->audio_st) {",
"schedule_refresh(is, 40);",
"video_display(is);",
"} else {",
"schedule_refresh(is, 100);",
"}",
"if (show_status) {",
"static int64_t VAR_1;",
"int64_t cur_time;",
"int VAR_2, VAR_3, VAR_4;",
"double VAR_5;",
"cur_time = av_gettime();",
"if (!VAR_1 || (cur_time - VAR_1) >= 30000) {",
"VAR_2 = 0;",
"VAR_3 = 0;",
"VAR_4 = 0;",
"if (is->audio_st)\nVAR_2 = is->audioq.size;",
"if (is->video_st)\nVAR_3 = is->videoq.size;",
"if (is->subtitle_st)\nVAR_4 = is->subtitleq.size;",
"VAR_5 = 0;",
"if (is->audio_st && is->video_st)\nVAR_5 = get_audio_clock(is) - get_video_clock(is);",
"printf(\"%7.2f A-V:%7.3f aq=%5dKB vq=%5dKB sq=%5dB f=%Ld/%Ld \\r\",\nget_master_clock(is), VAR_5, VAR_2 / 1024, VAR_3 / 1024, VAR_4, is->faulty_dts, is->faulty_pts);",
"fflush(stdout);",
"VAR_1 = cur_time;",
"}",
"}",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27
],
[
33
],
[
35
],
[
41
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
61,
63
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87,
89
],
[
91,
93
],
[
97,
99,
101
],
[
103
],
[
109,
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
135
],
[
141,
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
163
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205,
207
],
[
209,
211
],
[
213,
215
],
[
217
],
[
219,
221
],
[
223,
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
]
] |
20,861 | static int usb_net_handle_data(USBDevice *dev, USBPacket *p)
{
USBNetState *s = (USBNetState *) dev;
int ret = 0;
switch(p->pid) {
case USB_TOKEN_IN:
switch (p->devep) {
case 1:
ret = usb_net_handle_statusin(s, p);
break;
case 2:
ret = usb_net_handle_datain(s, p);
break;
default:
goto fail;
}
break;
case USB_TOKEN_OUT:
switch (p->devep) {
case 2:
ret = usb_net_handle_dataout(s, p);
break;
default:
goto fail;
}
break;
default:
fail:
ret = USB_RET_STALL;
break;
}
if (ret == USB_RET_STALL)
fprintf(stderr, "usbnet: failed data transaction: "
"pid 0x%x ep 0x%x len 0x%x\n",
p->pid, p->devep, p->len);
return ret;
}
| true | qemu | 4f4321c11ff6e98583846bfd6f0e81954924b003 | static int usb_net_handle_data(USBDevice *dev, USBPacket *p)
{
USBNetState *s = (USBNetState *) dev;
int ret = 0;
switch(p->pid) {
case USB_TOKEN_IN:
switch (p->devep) {
case 1:
ret = usb_net_handle_statusin(s, p);
break;
case 2:
ret = usb_net_handle_datain(s, p);
break;
default:
goto fail;
}
break;
case USB_TOKEN_OUT:
switch (p->devep) {
case 2:
ret = usb_net_handle_dataout(s, p);
break;
default:
goto fail;
}
break;
default:
fail:
ret = USB_RET_STALL;
break;
}
if (ret == USB_RET_STALL)
fprintf(stderr, "usbnet: failed data transaction: "
"pid 0x%x ep 0x%x len 0x%x\n",
p->pid, p->devep, p->len);
return ret;
}
| {
"code": [
" \"pid 0x%x ep 0x%x len 0x%x\\n\",",
" p->pid, p->devep, p->len);"
],
"line_no": [
79,
81
]
} | static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)
{
USBNetState *s = (USBNetState *) VAR_0;
int VAR_2 = 0;
switch(VAR_1->pid) {
case USB_TOKEN_IN:
switch (VAR_1->devep) {
case 1:
VAR_2 = usb_net_handle_statusin(s, VAR_1);
break;
case 2:
VAR_2 = usb_net_handle_datain(s, VAR_1);
break;
default:
goto fail;
}
break;
case USB_TOKEN_OUT:
switch (VAR_1->devep) {
case 2:
VAR_2 = usb_net_handle_dataout(s, VAR_1);
break;
default:
goto fail;
}
break;
default:
fail:
VAR_2 = USB_RET_STALL;
break;
}
if (VAR_2 == USB_RET_STALL)
fprintf(stderr, "usbnet: failed data transaction: "
"pid 0x%x ep 0x%x len 0x%x\n",
VAR_1->pid, VAR_1->devep, VAR_1->len);
return VAR_2;
}
| [
"static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)\n{",
"USBNetState *s = (USBNetState *) VAR_0;",
"int VAR_2 = 0;",
"switch(VAR_1->pid) {",
"case USB_TOKEN_IN:\nswitch (VAR_1->devep) {",
"case 1:\nVAR_2 = usb_net_handle_statusin(s, VAR_1);",
"break;",
"case 2:\nVAR_2 = usb_net_handle_datain(s, VAR_1);",
"break;",
"default:\ngoto fail;",
"}",
"break;",
"case USB_TOKEN_OUT:\nswitch (VAR_1->devep) {",
"case 2:\nVAR_2 = usb_net_handle_dataout(s, VAR_1);",
"break;",
"default:\ngoto fail;",
"}",
"break;",
"default:\nfail:\nVAR_2 = USB_RET_STALL;",
"break;",
"}",
"if (VAR_2 == USB_RET_STALL)\nfprintf(stderr, \"usbnet: failed data transaction: \"\n\"pid 0x%x ep 0x%x len 0x%x\\n\",\nVAR_1->pid, VAR_1->devep, VAR_1->len);",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
17,
19
],
[
21
],
[
25,
27
],
[
29
],
[
33,
35
],
[
37
],
[
39
],
[
43,
45
],
[
47,
49
],
[
51
],
[
55,
57
],
[
59
],
[
61
],
[
65,
67,
69
],
[
71
],
[
73
],
[
75,
77,
79,
81
],
[
83
],
[
85
]
] |
20,862 | int net_init_bridge(QemuOpts *opts, const char *name, VLANState *vlan)
{
TAPState *s;
int fd, vnet_hdr;
if (!qemu_opt_get(opts, "br")) {
qemu_opt_set(opts, "br", DEFAULT_BRIDGE_INTERFACE);
}
if (!qemu_opt_get(opts, "helper")) {
qemu_opt_set(opts, "helper", DEFAULT_BRIDGE_HELPER);
}
fd = net_bridge_run_helper(qemu_opt_get(opts, "helper"),
qemu_opt_get(opts, "br"));
if (fd == -1) {
return -1;
}
fcntl(fd, F_SETFL, O_NONBLOCK);
vnet_hdr = tap_probe_vnet_hdr(fd);
s = net_tap_fd_init(vlan, "bridge", name, fd, vnet_hdr);
if (!s) {
close(fd);
return -1;
}
snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=%s,br=%s",
qemu_opt_get(opts, "helper"), qemu_opt_get(opts, "br"));
return 0;
}
| true | qemu | 6687b79d636cd60ed9adb1177d0d946b58fa7717 | int net_init_bridge(QemuOpts *opts, const char *name, VLANState *vlan)
{
TAPState *s;
int fd, vnet_hdr;
if (!qemu_opt_get(opts, "br")) {
qemu_opt_set(opts, "br", DEFAULT_BRIDGE_INTERFACE);
}
if (!qemu_opt_get(opts, "helper")) {
qemu_opt_set(opts, "helper", DEFAULT_BRIDGE_HELPER);
}
fd = net_bridge_run_helper(qemu_opt_get(opts, "helper"),
qemu_opt_get(opts, "br"));
if (fd == -1) {
return -1;
}
fcntl(fd, F_SETFL, O_NONBLOCK);
vnet_hdr = tap_probe_vnet_hdr(fd);
s = net_tap_fd_init(vlan, "bridge", name, fd, vnet_hdr);
if (!s) {
close(fd);
return -1;
}
snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=%s,br=%s",
qemu_opt_get(opts, "helper"), qemu_opt_get(opts, "br"));
return 0;
}
| {
"code": [
" return -1;",
"int net_init_bridge(QemuOpts *opts, const char *name, VLANState *vlan)"
],
"line_no": [
31,
1
]
} | int FUNC_0(QemuOpts *VAR_0, const char *VAR_1, VLANState *VAR_2)
{
TAPState *s;
int VAR_3, VAR_4;
if (!qemu_opt_get(VAR_0, "br")) {
qemu_opt_set(VAR_0, "br", DEFAULT_BRIDGE_INTERFACE);
}
if (!qemu_opt_get(VAR_0, "helper")) {
qemu_opt_set(VAR_0, "helper", DEFAULT_BRIDGE_HELPER);
}
VAR_3 = net_bridge_run_helper(qemu_opt_get(VAR_0, "helper"),
qemu_opt_get(VAR_0, "br"));
if (VAR_3 == -1) {
return -1;
}
fcntl(VAR_3, F_SETFL, O_NONBLOCK);
VAR_4 = tap_probe_vnet_hdr(VAR_3);
s = net_tap_fd_init(VAR_2, "bridge", VAR_1, VAR_3, VAR_4);
if (!s) {
close(VAR_3);
return -1;
}
snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=%s,br=%s",
qemu_opt_get(VAR_0, "helper"), qemu_opt_get(VAR_0, "br"));
return 0;
}
| [
"int FUNC_0(QemuOpts *VAR_0, const char *VAR_1, VLANState *VAR_2)\n{",
"TAPState *s;",
"int VAR_3, VAR_4;",
"if (!qemu_opt_get(VAR_0, \"br\")) {",
"qemu_opt_set(VAR_0, \"br\", DEFAULT_BRIDGE_INTERFACE);",
"}",
"if (!qemu_opt_get(VAR_0, \"helper\")) {",
"qemu_opt_set(VAR_0, \"helper\", DEFAULT_BRIDGE_HELPER);",
"}",
"VAR_3 = net_bridge_run_helper(qemu_opt_get(VAR_0, \"helper\"),\nqemu_opt_get(VAR_0, \"br\"));",
"if (VAR_3 == -1) {",
"return -1;",
"}",
"fcntl(VAR_3, F_SETFL, O_NONBLOCK);",
"VAR_4 = tap_probe_vnet_hdr(VAR_3);",
"s = net_tap_fd_init(VAR_2, \"bridge\", VAR_1, VAR_3, VAR_4);",
"if (!s) {",
"close(VAR_3);",
"return -1;",
"}",
"snprintf(s->nc.info_str, sizeof(s->nc.info_str), \"helper=%s,br=%s\",\nqemu_opt_get(VAR_0, \"helper\"), qemu_opt_get(VAR_0, \"br\"));",
"return 0;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57,
59
],
[
63
],
[
65
]
] |
20,863 | static int vfio_setup_pcie_cap(VFIOPCIDevice *vdev, int pos, uint8_t size,
Error **errp)
{
uint16_t flags;
uint8_t type;
flags = pci_get_word(vdev->pdev.config + pos + PCI_CAP_FLAGS);
type = (flags & PCI_EXP_FLAGS_TYPE) >> 4;
if (type != PCI_EXP_TYPE_ENDPOINT &&
type != PCI_EXP_TYPE_LEG_END &&
type != PCI_EXP_TYPE_RC_END) {
error_setg(errp, "assignment of PCIe type 0x%x "
"devices is not currently supported", type);
return -EINVAL;
if (!pci_bus_is_express(vdev->pdev.bus)) {
PCIBus *bus = vdev->pdev.bus;
PCIDevice *bridge;
* Traditionally PCI device assignment exposes the PCIe capability
* as-is on non-express buses. The reason being that some drivers
* simply assume that it's there, for example tg3. However when
* we're running on a native PCIe machine type, like Q35, we need
* to hide the PCIe capability. The reason for this is twofold;
* first Windows guests get a Code 10 error when the PCIe capability
* is exposed in this configuration. Therefore express devices won't
* work at all unless they're attached to express buses in the VM.
* Second, a native PCIe machine introduces the possibility of fine
* granularity IOMMUs supporting both translation and isolation.
* Guest code to discover the IOMMU visibility of a device, such as
* IOMMU grouping code on Linux, is very aware of device types and
* valid transitions between bus types. An express device on a non-
* express bus is not a valid combination on bare metal systems.
*
* Drivers that require a PCIe capability to make the device
* functional are simply going to need to have their devices placed
* on a PCIe bus in the VM.
while (!pci_bus_is_root(bus)) {
bridge = pci_bridge_get_device(bus);
bus = bridge->bus;
if (pci_bus_is_express(bus)) {
return 0;
} else if (pci_bus_is_root(vdev->pdev.bus)) {
* On a Root Complex bus Endpoints become Root Complex Integrated
* Endpoints, which changes the type and clears the LNK & LNK2 fields.
if (type == PCI_EXP_TYPE_ENDPOINT) {
PCI_EXP_TYPE_RC_END << 4,
PCI_EXP_FLAGS_TYPE);
/* Link Capabilities, Status, and Control goes away */
if (size > PCI_EXP_LNKCTL) {
vfio_add_emulated_long(vdev, pos + PCI_EXP_LNKCAP, 0, ~0);
vfio_add_emulated_word(vdev, pos + PCI_EXP_LNKCTL, 0, ~0);
vfio_add_emulated_word(vdev, pos + PCI_EXP_LNKSTA, 0, ~0);
#ifndef PCI_EXP_LNKCAP2
#define PCI_EXP_LNKCAP2 44
#endif
#ifndef PCI_EXP_LNKSTA2
#define PCI_EXP_LNKSTA2 50
#endif
/* Link 2 Capabilities, Status, and Control goes away */
if (size > PCI_EXP_LNKCAP2) {
vfio_add_emulated_long(vdev, pos + PCI_EXP_LNKCAP2, 0, ~0);
vfio_add_emulated_word(vdev, pos + PCI_EXP_LNKCTL2, 0, ~0);
vfio_add_emulated_word(vdev, pos + PCI_EXP_LNKSTA2, 0, ~0);
} else if (type == PCI_EXP_TYPE_LEG_END) {
* Legacy endpoints don't belong on the root complex. Windows
* seems to be happier with devices if we skip the capability.
return 0;
} else {
* Convert Root Complex Integrated Endpoints to regular endpoints.
* These devices don't support LNK/LNK2 capabilities, so make them up.
if (type == PCI_EXP_TYPE_RC_END) {
PCI_EXP_TYPE_ENDPOINT << 4,
PCI_EXP_FLAGS_TYPE);
vfio_add_emulated_long(vdev, pos + PCI_EXP_LNKCAP,
PCI_EXP_LNK_MLW_1 | PCI_EXP_LNK_LS_25, ~0);
vfio_add_emulated_word(vdev, pos + PCI_EXP_LNKCTL, 0, ~0);
/* Mark the Link Status bits as emulated to allow virtual negotiation */
vfio_add_emulated_word(vdev, pos + PCI_EXP_LNKSTA,
pci_get_word(vdev->pdev.config + pos +
PCI_EXP_LNKSTA),
PCI_EXP_LNKCAP_MLW | PCI_EXP_LNKCAP_SLS);
pos = pci_add_capability(&vdev->pdev, PCI_CAP_ID_EXP, pos, size,
errp);
if (pos < 0) {
return pos;
vdev->pdev.exp.exp_cap = pos;
return pos; | true | qemu | 47985727e383eee191a39cc007541c17cd8680ee | static int vfio_setup_pcie_cap(VFIOPCIDevice *vdev, int pos, uint8_t size,
Error **errp)
{
uint16_t flags;
uint8_t type;
flags = pci_get_word(vdev->pdev.config + pos + PCI_CAP_FLAGS);
type = (flags & PCI_EXP_FLAGS_TYPE) >> 4;
if (type != PCI_EXP_TYPE_ENDPOINT &&
type != PCI_EXP_TYPE_LEG_END &&
type != PCI_EXP_TYPE_RC_END) {
error_setg(errp, "assignment of PCIe type 0x%x "
"devices is not currently supported", type);
return -EINVAL;
if (!pci_bus_is_express(vdev->pdev.bus)) {
PCIBus *bus = vdev->pdev.bus;
PCIDevice *bridge;
* Traditionally PCI device assignment exposes the PCIe capability
* as-is on non-express buses. The reason being that some drivers
* simply assume that it's there, for example tg3. However when
* we're running on a native PCIe machine type, like Q35, we need
* to hide the PCIe capability. The reason for this is twofold;
* first Windows guests get a Code 10 error when the PCIe capability
* is exposed in this configuration. Therefore express devices won't
* work at all unless they're attached to express buses in the VM.
* Second, a native PCIe machine introduces the possibility of fine
* granularity IOMMUs supporting both translation and isolation.
* Guest code to discover the IOMMU visibility of a device, such as
* IOMMU grouping code on Linux, is very aware of device types and
* valid transitions between bus types. An express device on a non-
* express bus is not a valid combination on bare metal systems.
*
* Drivers that require a PCIe capability to make the device
* functional are simply going to need to have their devices placed
* on a PCIe bus in the VM.
while (!pci_bus_is_root(bus)) {
bridge = pci_bridge_get_device(bus);
bus = bridge->bus;
if (pci_bus_is_express(bus)) {
return 0;
} else if (pci_bus_is_root(vdev->pdev.bus)) {
* On a Root Complex bus Endpoints become Root Complex Integrated
* Endpoints, which changes the type and clears the LNK & LNK2 fields.
if (type == PCI_EXP_TYPE_ENDPOINT) {
PCI_EXP_TYPE_RC_END << 4,
PCI_EXP_FLAGS_TYPE);
if (size > PCI_EXP_LNKCTL) {
vfio_add_emulated_long(vdev, pos + PCI_EXP_LNKCAP, 0, ~0);
vfio_add_emulated_word(vdev, pos + PCI_EXP_LNKCTL, 0, ~0);
vfio_add_emulated_word(vdev, pos + PCI_EXP_LNKSTA, 0, ~0);
#ifndef PCI_EXP_LNKCAP2
#define PCI_EXP_LNKCAP2 44
#endif
#ifndef PCI_EXP_LNKSTA2
#define PCI_EXP_LNKSTA2 50
#endif
if (size > PCI_EXP_LNKCAP2) {
vfio_add_emulated_long(vdev, pos + PCI_EXP_LNKCAP2, 0, ~0);
vfio_add_emulated_word(vdev, pos + PCI_EXP_LNKCTL2, 0, ~0);
vfio_add_emulated_word(vdev, pos + PCI_EXP_LNKSTA2, 0, ~0);
} else if (type == PCI_EXP_TYPE_LEG_END) {
* Legacy endpoints don't belong on the root complex. Windows
* seems to be happier with devices if we skip the capability.
return 0;
} else {
* Convert Root Complex Integrated Endpoints to regular endpoints.
* These devices don't support LNK/LNK2 capabilities, so make them up.
if (type == PCI_EXP_TYPE_RC_END) {
PCI_EXP_TYPE_ENDPOINT << 4,
PCI_EXP_FLAGS_TYPE);
vfio_add_emulated_long(vdev, pos + PCI_EXP_LNKCAP,
PCI_EXP_LNK_MLW_1 | PCI_EXP_LNK_LS_25, ~0);
vfio_add_emulated_word(vdev, pos + PCI_EXP_LNKCTL, 0, ~0);
vfio_add_emulated_word(vdev, pos + PCI_EXP_LNKSTA,
pci_get_word(vdev->pdev.config + pos +
PCI_EXP_LNKSTA),
PCI_EXP_LNKCAP_MLW | PCI_EXP_LNKCAP_SLS);
pos = pci_add_capability(&vdev->pdev, PCI_CAP_ID_EXP, pos, size,
errp);
if (pos < 0) {
return pos;
vdev->pdev.exp.exp_cap = pos;
return pos; | {
"code": [],
"line_no": []
} | static int FUNC_0(VFIOPCIDevice *VAR_0, int VAR_1, uint8_t VAR_2,
Error **VAR_3)
{
uint16_t flags;
uint8_t type;
flags = pci_get_word(VAR_0->pdev.config + VAR_1 + PCI_CAP_FLAGS);
type = (flags & PCI_EXP_FLAGS_TYPE) >> 4;
if (type != PCI_EXP_TYPE_ENDPOINT &&
type != PCI_EXP_TYPE_LEG_END &&
type != PCI_EXP_TYPE_RC_END) {
error_setg(VAR_3, "assignment of PCIe type 0x%x "
"devices is not currently supported", type);
return -EINVAL;
if (!pci_bus_is_express(VAR_0->pdev.bus)) {
PCIBus *bus = VAR_0->pdev.bus;
PCIDevice *bridge;
* Traditionally PCI device assignment exposes the PCIe capability
* as-is on non-express buses. The reason being that some drivers
* simply assume that it's there, for example tg3. However when
* we're running on a native PCIe machine type, like Q35, we need
* to hide the PCIe capability. The reason for this is twofold;
* first Windows guests get a Code 10 error when the PCIe capability
* is exposed in this configuration. Therefore express devices won't
* work at all unless they're attached to express buses in the VM.
* Second, a native PCIe machine introduces the possibility of fine
* granularity IOMMUs supporting both translation and isolation.
* Guest code to discover the IOMMU visibility of a device, such as
* IOMMU grouping code on Linux, is very aware of device types and
* valid transitions between bus types. An express device on a non-
* express bus is not a valid combination on bare metal systems.
*
* Drivers that require a PCIe capability to make the device
* functional are simply going to need to have their devices placed
* on a PCIe bus in the VM.
while (!pci_bus_is_root(bus)) {
bridge = pci_bridge_get_device(bus);
bus = bridge->bus;
if (pci_bus_is_express(bus)) {
return 0;
} else if (pci_bus_is_root(VAR_0->pdev.bus)) {
* On a Root Complex bus Endpoints become Root Complex Integrated
* Endpoints, which changes the type and clears the LNK & LNK2 fields.
if (type == PCI_EXP_TYPE_ENDPOINT) {
PCI_EXP_TYPE_RC_END << 4,
PCI_EXP_FLAGS_TYPE);
if (VAR_2 > PCI_EXP_LNKCTL) {
vfio_add_emulated_long(VAR_0, VAR_1 + PCI_EXP_LNKCAP, 0, ~0);
vfio_add_emulated_word(VAR_0, VAR_1 + PCI_EXP_LNKCTL, 0, ~0);
vfio_add_emulated_word(VAR_0, VAR_1 + PCI_EXP_LNKSTA, 0, ~0);
#ifndef PCI_EXP_LNKCAP2
#define PCI_EXP_LNKCAP2 44
#endif
#ifndef PCI_EXP_LNKSTA2
#define PCI_EXP_LNKSTA2 50
#endif
if (VAR_2 > PCI_EXP_LNKCAP2) {
vfio_add_emulated_long(VAR_0, VAR_1 + PCI_EXP_LNKCAP2, 0, ~0);
vfio_add_emulated_word(VAR_0, VAR_1 + PCI_EXP_LNKCTL2, 0, ~0);
vfio_add_emulated_word(VAR_0, VAR_1 + PCI_EXP_LNKSTA2, 0, ~0);
} else if (type == PCI_EXP_TYPE_LEG_END) {
* Legacy endpoints don't belong on the root complex. Windows
* seems to be happier with devices if we skip the capability.
return 0;
} else {
* Convert Root Complex Integrated Endpoints to regular endpoints.
* These devices don't support LNK/LNK2 capabilities, so make them up.
if (type == PCI_EXP_TYPE_RC_END) {
PCI_EXP_TYPE_ENDPOINT << 4,
PCI_EXP_FLAGS_TYPE);
vfio_add_emulated_long(VAR_0, VAR_1 + PCI_EXP_LNKCAP,
PCI_EXP_LNK_MLW_1 | PCI_EXP_LNK_LS_25, ~0);
vfio_add_emulated_word(VAR_0, VAR_1 + PCI_EXP_LNKCTL, 0, ~0);
vfio_add_emulated_word(VAR_0, VAR_1 + PCI_EXP_LNKSTA,
pci_get_word(VAR_0->pdev.config + VAR_1 +
PCI_EXP_LNKSTA),
PCI_EXP_LNKCAP_MLW | PCI_EXP_LNKCAP_SLS);
VAR_1 = pci_add_capability(&VAR_0->pdev, PCI_CAP_ID_EXP, VAR_1, VAR_2,
VAR_3);
if (VAR_1 < 0) {
return VAR_1;
VAR_0->pdev.exp.exp_cap = VAR_1;
return VAR_1; | [
"static int FUNC_0(VFIOPCIDevice *VAR_0, int VAR_1, uint8_t VAR_2,\nError **VAR_3)\n{",
"uint16_t flags;",
"uint8_t type;",
"flags = pci_get_word(VAR_0->pdev.config + VAR_1 + PCI_CAP_FLAGS);",
"type = (flags & PCI_EXP_FLAGS_TYPE) >> 4;",
"if (type != PCI_EXP_TYPE_ENDPOINT &&\ntype != PCI_EXP_TYPE_LEG_END &&\ntype != PCI_EXP_TYPE_RC_END) {",
"error_setg(VAR_3, \"assignment of PCIe type 0x%x \"\n\"devices is not currently supported\", type);",
"return -EINVAL;",
"if (!pci_bus_is_express(VAR_0->pdev.bus)) {",
"PCIBus *bus = VAR_0->pdev.bus;",
"PCIDevice *bridge;",
"* Traditionally PCI device assignment exposes the PCIe capability\n* as-is on non-express buses. The reason being that some drivers\n* simply assume that it's there, for example tg3. However when\n* we're running on a native PCIe machine type, like Q35, we need\n* to hide the PCIe capability. The reason for this is twofold;",
"* first Windows guests get a Code 10 error when the PCIe capability\n* is exposed in this configuration. Therefore express devices won't\n* work at all unless they're attached to express buses in the VM.\n* Second, a native PCIe machine introduces the possibility of fine\n* granularity IOMMUs supporting both translation and isolation.\n* Guest code to discover the IOMMU visibility of a device, such as\n* IOMMU grouping code on Linux, is very aware of device types and\n* valid transitions between bus types. An express device on a non-\n* express bus is not a valid combination on bare metal systems.\n*\n* Drivers that require a PCIe capability to make the device\n* functional are simply going to need to have their devices placed\n* on a PCIe bus in the VM.\nwhile (!pci_bus_is_root(bus)) {",
"bridge = pci_bridge_get_device(bus);",
"bus = bridge->bus;",
"if (pci_bus_is_express(bus)) {",
"return 0;",
"} else if (pci_bus_is_root(VAR_0->pdev.bus)) {",
"* On a Root Complex bus Endpoints become Root Complex Integrated\n* Endpoints, which changes the type and clears the LNK & LNK2 fields.\nif (type == PCI_EXP_TYPE_ENDPOINT) {",
"PCI_EXP_TYPE_RC_END << 4,\nPCI_EXP_FLAGS_TYPE);",
"if (VAR_2 > PCI_EXP_LNKCTL) {",
"vfio_add_emulated_long(VAR_0, VAR_1 + PCI_EXP_LNKCAP, 0, ~0);",
"vfio_add_emulated_word(VAR_0, VAR_1 + PCI_EXP_LNKCTL, 0, ~0);",
"vfio_add_emulated_word(VAR_0, VAR_1 + PCI_EXP_LNKSTA, 0, ~0);",
"#ifndef PCI_EXP_LNKCAP2\n#define PCI_EXP_LNKCAP2 44\n#endif\n#ifndef PCI_EXP_LNKSTA2\n#define PCI_EXP_LNKSTA2 50\n#endif\nif (VAR_2 > PCI_EXP_LNKCAP2) {",
"vfio_add_emulated_long(VAR_0, VAR_1 + PCI_EXP_LNKCAP2, 0, ~0);",
"vfio_add_emulated_word(VAR_0, VAR_1 + PCI_EXP_LNKCTL2, 0, ~0);",
"vfio_add_emulated_word(VAR_0, VAR_1 + PCI_EXP_LNKSTA2, 0, ~0);",
"} else if (type == PCI_EXP_TYPE_LEG_END) {",
"* Legacy endpoints don't belong on the root complex. Windows\n* seems to be happier with devices if we skip the capability.\nreturn 0;",
"} else {",
"* Convert Root Complex Integrated Endpoints to regular endpoints.\n* These devices don't support LNK/LNK2 capabilities, so make them up.\nif (type == PCI_EXP_TYPE_RC_END) {",
"PCI_EXP_TYPE_ENDPOINT << 4,\nPCI_EXP_FLAGS_TYPE);",
"vfio_add_emulated_long(VAR_0, VAR_1 + PCI_EXP_LNKCAP,\nPCI_EXP_LNK_MLW_1 | PCI_EXP_LNK_LS_25, ~0);",
"vfio_add_emulated_word(VAR_0, VAR_1 + PCI_EXP_LNKCTL, 0, ~0);",
"vfio_add_emulated_word(VAR_0, VAR_1 + PCI_EXP_LNKSTA,\npci_get_word(VAR_0->pdev.config + VAR_1 +\nPCI_EXP_LNKSTA),\nPCI_EXP_LNKCAP_MLW | PCI_EXP_LNKCAP_SLS);",
"VAR_1 = pci_add_capability(&VAR_0->pdev, PCI_CAP_ID_EXP, VAR_1, VAR_2,\nVAR_3);",
"if (VAR_1 < 0) {",
"return VAR_1;",
"VAR_0->pdev.exp.exp_cap = VAR_1;",
"return VAR_1;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
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
],
[
47
],
[
48
],
[
49
],
[
50
],
[
51,
52,
53,
54,
55,
56,
58
],
[
59
],
[
60
],
[
61
],
[
62
],
[
63,
64,
65
],
[
66
],
[
67,
68,
69
],
[
70,
71
],
[
72,
73
],
[
74
],
[
76,
77,
78,
79
],
[
80,
81
],
[
82
],
[
83
],
[
84
],
[
85
]
] |
20,864 | static int nsv_read_close(AVFormatContext *s)
{
/* int i; */
NSVContext *nsv = s->priv_data;
av_freep(&nsv->nsvs_file_offset);
av_freep(&nsv->nsvs_timestamps);
#if 0
for(i=0;i<s->nb_streams;i++) {
AVStream *st = s->streams[i];
NSVStream *ast = st->priv_data;
if(ast){
av_free(ast->index_entries);
av_free(ast);
}
av_free(st->codec->palctrl);
}
#endif
return 0;
} | true | FFmpeg | 1f6d0d42c53cde5e33e92c4529b774c256157f89 | static int nsv_read_close(AVFormatContext *s)
{
NSVContext *nsv = s->priv_data;
av_freep(&nsv->nsvs_file_offset);
av_freep(&nsv->nsvs_timestamps);
#if 0
for(i=0;i<s->nb_streams;i++) {
AVStream *st = s->streams[i];
NSVStream *ast = st->priv_data;
if(ast){
av_free(ast->index_entries);
av_free(ast);
}
av_free(st->codec->palctrl);
}
#endif
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
NSVContext *nsv = VAR_0->priv_data;
av_freep(&nsv->nsvs_file_offset);
av_freep(&nsv->nsvs_timestamps);
#if 0
for(i=0;i<VAR_0->nb_streams;i++) {
AVStream *st = VAR_0->streams[i];
NSVStream *ast = st->priv_data;
if(ast){
av_free(ast->index_entries);
av_free(ast);
}
av_free(st->codec->palctrl);
}
#endif
return 0;
} | [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"NSVContext *nsv = VAR_0->priv_data;",
"av_freep(&nsv->nsvs_file_offset);",
"av_freep(&nsv->nsvs_timestamps);",
"#if 0\nfor(i=0;i<VAR_0->nb_streams;i++) {",
"AVStream *st = VAR_0->streams[i];",
"NSVStream *ast = st->priv_data;",
"if(ast){",
"av_free(ast->index_entries);",
"av_free(ast);",
"}",
"av_free(st->codec->palctrl);",
"}",
"#endif\nreturn 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
11
],
[
13
],
[
21,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45,
47
],
[
49
]
] |
20,865 | static int create_vorbis_context(vorbis_enc_context *venc,
AVCodecContext *avctx)
{
vorbis_enc_floor *fc;
vorbis_enc_residue *rc;
vorbis_enc_mapping *mc;
int i, book, ret;
venc->channels = avctx->channels;
venc->sample_rate = avctx->sample_rate;
venc->log2_blocksize[0] = venc->log2_blocksize[1] = 11;
venc->ncodebooks = FF_ARRAY_ELEMS(cvectors);
venc->codebooks = av_malloc(sizeof(vorbis_enc_codebook) * venc->ncodebooks);
if (!venc->codebooks)
return AVERROR(ENOMEM);
// codebook 0..14 - floor1 book, values 0..255
// codebook 15 residue masterbook
// codebook 16..29 residue
for (book = 0; book < venc->ncodebooks; book++) {
vorbis_enc_codebook *cb = &venc->codebooks[book];
int vals;
cb->ndimensions = cvectors[book].dim;
cb->nentries = cvectors[book].real_len;
cb->min = cvectors[book].min;
cb->delta = cvectors[book].delta;
cb->lookup = cvectors[book].lookup;
cb->seq_p = 0;
cb->lens = av_malloc_array(cb->nentries, sizeof(uint8_t));
cb->codewords = av_malloc_array(cb->nentries, sizeof(uint32_t));
if (!cb->lens || !cb->codewords)
return AVERROR(ENOMEM);
memcpy(cb->lens, cvectors[book].clens, cvectors[book].len);
memset(cb->lens + cvectors[book].len, 0, cb->nentries - cvectors[book].len);
if (cb->lookup) {
vals = cb_lookup_vals(cb->lookup, cb->ndimensions, cb->nentries);
cb->quantlist = av_malloc_array(vals, sizeof(int));
if (!cb->quantlist)
return AVERROR(ENOMEM);
for (i = 0; i < vals; i++)
cb->quantlist[i] = cvectors[book].quant[i];
} else {
cb->quantlist = NULL;
}
if ((ret = ready_codebook(cb)) < 0)
return ret;
}
venc->nfloors = 1;
venc->floors = av_malloc(sizeof(vorbis_enc_floor) * venc->nfloors);
if (!venc->floors)
return AVERROR(ENOMEM);
// just 1 floor
fc = &venc->floors[0];
fc->partitions = NUM_FLOOR_PARTITIONS;
fc->partition_to_class = av_malloc(sizeof(int) * fc->partitions);
if (!fc->partition_to_class)
return AVERROR(ENOMEM);
fc->nclasses = 0;
for (i = 0; i < fc->partitions; i++) {
static const int a[] = {0, 1, 2, 2, 3, 3, 4, 4};
fc->partition_to_class[i] = a[i];
fc->nclasses = FFMAX(fc->nclasses, fc->partition_to_class[i]);
}
fc->nclasses++;
fc->classes = av_malloc_array(fc->nclasses, sizeof(vorbis_enc_floor_class));
if (!fc->classes)
return AVERROR(ENOMEM);
for (i = 0; i < fc->nclasses; i++) {
vorbis_enc_floor_class * c = &fc->classes[i];
int j, books;
c->dim = floor_classes[i].dim;
c->subclass = floor_classes[i].subclass;
c->masterbook = floor_classes[i].masterbook;
books = (1 << c->subclass);
c->books = av_malloc_array(books, sizeof(int));
if (!c->books)
return AVERROR(ENOMEM);
for (j = 0; j < books; j++)
c->books[j] = floor_classes[i].nbooks[j];
}
fc->multiplier = 2;
fc->rangebits = venc->log2_blocksize[0] - 1;
fc->values = 2;
for (i = 0; i < fc->partitions; i++)
fc->values += fc->classes[fc->partition_to_class[i]].dim;
fc->list = av_malloc_array(fc->values, sizeof(vorbis_floor1_entry));
if (!fc->list)
return AVERROR(ENOMEM);
fc->list[0].x = 0;
fc->list[1].x = 1 << fc->rangebits;
for (i = 2; i < fc->values; i++) {
static const int a[] = {
93, 23,372, 6, 46,186,750, 14, 33, 65,
130,260,556, 3, 10, 18, 28, 39, 55, 79,
111,158,220,312,464,650,850
};
fc->list[i].x = a[i - 2];
}
if (ff_vorbis_ready_floor1_list(avctx, fc->list, fc->values))
return AVERROR_BUG;
venc->nresidues = 1;
venc->residues = av_malloc(sizeof(vorbis_enc_residue) * venc->nresidues);
if (!venc->residues)
return AVERROR(ENOMEM);
// single residue
rc = &venc->residues[0];
rc->type = 2;
rc->begin = 0;
rc->end = 1600;
rc->partition_size = 32;
rc->classifications = 10;
rc->classbook = 15;
rc->books = av_malloc(sizeof(*rc->books) * rc->classifications);
if (!rc->books)
return AVERROR(ENOMEM);
{
static const int8_t a[10][8] = {
{ -1, -1, -1, -1, -1, -1, -1, -1, },
{ -1, -1, 16, -1, -1, -1, -1, -1, },
{ -1, -1, 17, -1, -1, -1, -1, -1, },
{ -1, -1, 18, -1, -1, -1, -1, -1, },
{ -1, -1, 19, -1, -1, -1, -1, -1, },
{ -1, -1, 20, -1, -1, -1, -1, -1, },
{ -1, -1, 21, -1, -1, -1, -1, -1, },
{ 22, 23, -1, -1, -1, -1, -1, -1, },
{ 24, 25, -1, -1, -1, -1, -1, -1, },
{ 26, 27, 28, -1, -1, -1, -1, -1, },
};
memcpy(rc->books, a, sizeof a);
}
if ((ret = ready_residue(rc, venc)) < 0)
return ret;
venc->nmappings = 1;
venc->mappings = av_malloc(sizeof(vorbis_enc_mapping) * venc->nmappings);
if (!venc->mappings)
return AVERROR(ENOMEM);
// single mapping
mc = &venc->mappings[0];
mc->submaps = 1;
mc->mux = av_malloc(sizeof(int) * venc->channels);
if (!mc->mux)
return AVERROR(ENOMEM);
for (i = 0; i < venc->channels; i++)
mc->mux[i] = 0;
mc->floor = av_malloc(sizeof(int) * mc->submaps);
mc->residue = av_malloc(sizeof(int) * mc->submaps);
if (!mc->floor || !mc->residue)
return AVERROR(ENOMEM);
for (i = 0; i < mc->submaps; i++) {
mc->floor[i] = 0;
mc->residue[i] = 0;
}
mc->coupling_steps = venc->channels == 2 ? 1 : 0;
mc->magnitude = av_malloc(sizeof(int) * mc->coupling_steps);
mc->angle = av_malloc(sizeof(int) * mc->coupling_steps);
if (!mc->magnitude || !mc->angle)
return AVERROR(ENOMEM);
if (mc->coupling_steps) {
mc->magnitude[0] = 0;
mc->angle[0] = 1;
}
venc->nmodes = 1;
venc->modes = av_malloc(sizeof(vorbis_enc_mode) * venc->nmodes);
if (!venc->modes)
return AVERROR(ENOMEM);
// single mode
venc->modes[0].blockflag = 0;
venc->modes[0].mapping = 0;
venc->have_saved = 0;
venc->saved = av_malloc_array(sizeof(float) * venc->channels, (1 << venc->log2_blocksize[1]) / 2);
venc->samples = av_malloc_array(sizeof(float) * venc->channels, (1 << venc->log2_blocksize[1]));
venc->floor = av_malloc_array(sizeof(float) * venc->channels, (1 << venc->log2_blocksize[1]) / 2);
venc->coeffs = av_malloc_array(sizeof(float) * venc->channels, (1 << venc->log2_blocksize[1]) / 2);
if (!venc->saved || !venc->samples || !venc->floor || !venc->coeffs)
return AVERROR(ENOMEM);
if ((ret = dsp_init(avctx, venc)) < 0)
return ret;
return 0;
}
| true | FFmpeg | 34c52005605d68f7cd1957b169b6732c7d2447d9 | static int create_vorbis_context(vorbis_enc_context *venc,
AVCodecContext *avctx)
{
vorbis_enc_floor *fc;
vorbis_enc_residue *rc;
vorbis_enc_mapping *mc;
int i, book, ret;
venc->channels = avctx->channels;
venc->sample_rate = avctx->sample_rate;
venc->log2_blocksize[0] = venc->log2_blocksize[1] = 11;
venc->ncodebooks = FF_ARRAY_ELEMS(cvectors);
venc->codebooks = av_malloc(sizeof(vorbis_enc_codebook) * venc->ncodebooks);
if (!venc->codebooks)
return AVERROR(ENOMEM);
for (book = 0; book < venc->ncodebooks; book++) {
vorbis_enc_codebook *cb = &venc->codebooks[book];
int vals;
cb->ndimensions = cvectors[book].dim;
cb->nentries = cvectors[book].real_len;
cb->min = cvectors[book].min;
cb->delta = cvectors[book].delta;
cb->lookup = cvectors[book].lookup;
cb->seq_p = 0;
cb->lens = av_malloc_array(cb->nentries, sizeof(uint8_t));
cb->codewords = av_malloc_array(cb->nentries, sizeof(uint32_t));
if (!cb->lens || !cb->codewords)
return AVERROR(ENOMEM);
memcpy(cb->lens, cvectors[book].clens, cvectors[book].len);
memset(cb->lens + cvectors[book].len, 0, cb->nentries - cvectors[book].len);
if (cb->lookup) {
vals = cb_lookup_vals(cb->lookup, cb->ndimensions, cb->nentries);
cb->quantlist = av_malloc_array(vals, sizeof(int));
if (!cb->quantlist)
return AVERROR(ENOMEM);
for (i = 0; i < vals; i++)
cb->quantlist[i] = cvectors[book].quant[i];
} else {
cb->quantlist = NULL;
}
if ((ret = ready_codebook(cb)) < 0)
return ret;
}
venc->nfloors = 1;
venc->floors = av_malloc(sizeof(vorbis_enc_floor) * venc->nfloors);
if (!venc->floors)
return AVERROR(ENOMEM);
fc = &venc->floors[0];
fc->partitions = NUM_FLOOR_PARTITIONS;
fc->partition_to_class = av_malloc(sizeof(int) * fc->partitions);
if (!fc->partition_to_class)
return AVERROR(ENOMEM);
fc->nclasses = 0;
for (i = 0; i < fc->partitions; i++) {
static const int a[] = {0, 1, 2, 2, 3, 3, 4, 4};
fc->partition_to_class[i] = a[i];
fc->nclasses = FFMAX(fc->nclasses, fc->partition_to_class[i]);
}
fc->nclasses++;
fc->classes = av_malloc_array(fc->nclasses, sizeof(vorbis_enc_floor_class));
if (!fc->classes)
return AVERROR(ENOMEM);
for (i = 0; i < fc->nclasses; i++) {
vorbis_enc_floor_class * c = &fc->classes[i];
int j, books;
c->dim = floor_classes[i].dim;
c->subclass = floor_classes[i].subclass;
c->masterbook = floor_classes[i].masterbook;
books = (1 << c->subclass);
c->books = av_malloc_array(books, sizeof(int));
if (!c->books)
return AVERROR(ENOMEM);
for (j = 0; j < books; j++)
c->books[j] = floor_classes[i].nbooks[j];
}
fc->multiplier = 2;
fc->rangebits = venc->log2_blocksize[0] - 1;
fc->values = 2;
for (i = 0; i < fc->partitions; i++)
fc->values += fc->classes[fc->partition_to_class[i]].dim;
fc->list = av_malloc_array(fc->values, sizeof(vorbis_floor1_entry));
if (!fc->list)
return AVERROR(ENOMEM);
fc->list[0].x = 0;
fc->list[1].x = 1 << fc->rangebits;
for (i = 2; i < fc->values; i++) {
static const int a[] = {
93, 23,372, 6, 46,186,750, 14, 33, 65,
130,260,556, 3, 10, 18, 28, 39, 55, 79,
111,158,220,312,464,650,850
};
fc->list[i].x = a[i - 2];
}
if (ff_vorbis_ready_floor1_list(avctx, fc->list, fc->values))
return AVERROR_BUG;
venc->nresidues = 1;
venc->residues = av_malloc(sizeof(vorbis_enc_residue) * venc->nresidues);
if (!venc->residues)
return AVERROR(ENOMEM);
rc = &venc->residues[0];
rc->type = 2;
rc->begin = 0;
rc->end = 1600;
rc->partition_size = 32;
rc->classifications = 10;
rc->classbook = 15;
rc->books = av_malloc(sizeof(*rc->books) * rc->classifications);
if (!rc->books)
return AVERROR(ENOMEM);
{
static const int8_t a[10][8] = {
{ -1, -1, -1, -1, -1, -1, -1, -1, },
{ -1, -1, 16, -1, -1, -1, -1, -1, },
{ -1, -1, 17, -1, -1, -1, -1, -1, },
{ -1, -1, 18, -1, -1, -1, -1, -1, },
{ -1, -1, 19, -1, -1, -1, -1, -1, },
{ -1, -1, 20, -1, -1, -1, -1, -1, },
{ -1, -1, 21, -1, -1, -1, -1, -1, },
{ 22, 23, -1, -1, -1, -1, -1, -1, },
{ 24, 25, -1, -1, -1, -1, -1, -1, },
{ 26, 27, 28, -1, -1, -1, -1, -1, },
};
memcpy(rc->books, a, sizeof a);
}
if ((ret = ready_residue(rc, venc)) < 0)
return ret;
venc->nmappings = 1;
venc->mappings = av_malloc(sizeof(vorbis_enc_mapping) * venc->nmappings);
if (!venc->mappings)
return AVERROR(ENOMEM);
mc = &venc->mappings[0];
mc->submaps = 1;
mc->mux = av_malloc(sizeof(int) * venc->channels);
if (!mc->mux)
return AVERROR(ENOMEM);
for (i = 0; i < venc->channels; i++)
mc->mux[i] = 0;
mc->floor = av_malloc(sizeof(int) * mc->submaps);
mc->residue = av_malloc(sizeof(int) * mc->submaps);
if (!mc->floor || !mc->residue)
return AVERROR(ENOMEM);
for (i = 0; i < mc->submaps; i++) {
mc->floor[i] = 0;
mc->residue[i] = 0;
}
mc->coupling_steps = venc->channels == 2 ? 1 : 0;
mc->magnitude = av_malloc(sizeof(int) * mc->coupling_steps);
mc->angle = av_malloc(sizeof(int) * mc->coupling_steps);
if (!mc->magnitude || !mc->angle)
return AVERROR(ENOMEM);
if (mc->coupling_steps) {
mc->magnitude[0] = 0;
mc->angle[0] = 1;
}
venc->nmodes = 1;
venc->modes = av_malloc(sizeof(vorbis_enc_mode) * venc->nmodes);
if (!venc->modes)
return AVERROR(ENOMEM);
venc->modes[0].blockflag = 0;
venc->modes[0].mapping = 0;
venc->have_saved = 0;
venc->saved = av_malloc_array(sizeof(float) * venc->channels, (1 << venc->log2_blocksize[1]) / 2);
venc->samples = av_malloc_array(sizeof(float) * venc->channels, (1 << venc->log2_blocksize[1]));
venc->floor = av_malloc_array(sizeof(float) * venc->channels, (1 << venc->log2_blocksize[1]) / 2);
venc->coeffs = av_malloc_array(sizeof(float) * venc->channels, (1 << venc->log2_blocksize[1]) / 2);
if (!venc->saved || !venc->samples || !venc->floor || !venc->coeffs)
return AVERROR(ENOMEM);
if ((ret = dsp_init(avctx, venc)) < 0)
return ret;
return 0;
}
| {
"code": [
" if (!venc->saved || !venc->samples || !venc->floor || !venc->coeffs)",
" return AVERROR(ENOMEM);"
],
"line_no": [
375,
31
]
} | static int FUNC_0(vorbis_enc_context *VAR_0,
AVCodecContext *VAR_1)
{
vorbis_enc_floor *fc;
vorbis_enc_residue *rc;
vorbis_enc_mapping *mc;
int VAR_2, VAR_3, VAR_4;
VAR_0->channels = VAR_1->channels;
VAR_0->sample_rate = VAR_1->sample_rate;
VAR_0->log2_blocksize[0] = VAR_0->log2_blocksize[1] = 11;
VAR_0->ncodebooks = FF_ARRAY_ELEMS(cvectors);
VAR_0->codebooks = av_malloc(sizeof(vorbis_enc_codebook) * VAR_0->ncodebooks);
if (!VAR_0->codebooks)
return AVERROR(ENOMEM);
for (VAR_3 = 0; VAR_3 < VAR_0->ncodebooks; VAR_3++) {
vorbis_enc_codebook *cb = &VAR_0->codebooks[VAR_3];
int vals;
cb->ndimensions = cvectors[VAR_3].dim;
cb->nentries = cvectors[VAR_3].real_len;
cb->min = cvectors[VAR_3].min;
cb->delta = cvectors[VAR_3].delta;
cb->lookup = cvectors[VAR_3].lookup;
cb->seq_p = 0;
cb->lens = av_malloc_array(cb->nentries, sizeof(uint8_t));
cb->codewords = av_malloc_array(cb->nentries, sizeof(uint32_t));
if (!cb->lens || !cb->codewords)
return AVERROR(ENOMEM);
memcpy(cb->lens, cvectors[VAR_3].clens, cvectors[VAR_3].len);
memset(cb->lens + cvectors[VAR_3].len, 0, cb->nentries - cvectors[VAR_3].len);
if (cb->lookup) {
vals = cb_lookup_vals(cb->lookup, cb->ndimensions, cb->nentries);
cb->quantlist = av_malloc_array(vals, sizeof(int));
if (!cb->quantlist)
return AVERROR(ENOMEM);
for (VAR_2 = 0; VAR_2 < vals; VAR_2++)
cb->quantlist[VAR_2] = cvectors[VAR_3].quant[VAR_2];
} else {
cb->quantlist = NULL;
}
if ((VAR_4 = ready_codebook(cb)) < 0)
return VAR_4;
}
VAR_0->nfloors = 1;
VAR_0->floors = av_malloc(sizeof(vorbis_enc_floor) * VAR_0->nfloors);
if (!VAR_0->floors)
return AVERROR(ENOMEM);
fc = &VAR_0->floors[0];
fc->partitions = NUM_FLOOR_PARTITIONS;
fc->partition_to_class = av_malloc(sizeof(int) * fc->partitions);
if (!fc->partition_to_class)
return AVERROR(ENOMEM);
fc->nclasses = 0;
for (VAR_2 = 0; VAR_2 < fc->partitions; VAR_2++) {
static const int VAR_5[] = {0, 1, 2, 2, 3, 3, 4, 4};
fc->partition_to_class[VAR_2] = VAR_5[VAR_2];
fc->nclasses = FFMAX(fc->nclasses, fc->partition_to_class[VAR_2]);
}
fc->nclasses++;
fc->classes = av_malloc_array(fc->nclasses, sizeof(vorbis_enc_floor_class));
if (!fc->classes)
return AVERROR(ENOMEM);
for (VAR_2 = 0; VAR_2 < fc->nclasses; VAR_2++) {
vorbis_enc_floor_class * c = &fc->classes[VAR_2];
int j, books;
c->dim = floor_classes[VAR_2].dim;
c->subclass = floor_classes[VAR_2].subclass;
c->masterbook = floor_classes[VAR_2].masterbook;
books = (1 << c->subclass);
c->books = av_malloc_array(books, sizeof(int));
if (!c->books)
return AVERROR(ENOMEM);
for (j = 0; j < books; j++)
c->books[j] = floor_classes[VAR_2].nbooks[j];
}
fc->multiplier = 2;
fc->rangebits = VAR_0->log2_blocksize[0] - 1;
fc->values = 2;
for (VAR_2 = 0; VAR_2 < fc->partitions; VAR_2++)
fc->values += fc->classes[fc->partition_to_class[VAR_2]].dim;
fc->list = av_malloc_array(fc->values, sizeof(vorbis_floor1_entry));
if (!fc->list)
return AVERROR(ENOMEM);
fc->list[0].x = 0;
fc->list[1].x = 1 << fc->rangebits;
for (VAR_2 = 2; VAR_2 < fc->values; VAR_2++) {
static const int VAR_5[] = {
93, 23,372, 6, 46,186,750, 14, 33, 65,
130,260,556, 3, 10, 18, 28, 39, 55, 79,
111,158,220,312,464,650,850
};
fc->list[VAR_2].x = VAR_5[VAR_2 - 2];
}
if (ff_vorbis_ready_floor1_list(VAR_1, fc->list, fc->values))
return AVERROR_BUG;
VAR_0->nresidues = 1;
VAR_0->residues = av_malloc(sizeof(vorbis_enc_residue) * VAR_0->nresidues);
if (!VAR_0->residues)
return AVERROR(ENOMEM);
rc = &VAR_0->residues[0];
rc->type = 2;
rc->begin = 0;
rc->end = 1600;
rc->partition_size = 32;
rc->classifications = 10;
rc->classbook = 15;
rc->books = av_malloc(sizeof(*rc->books) * rc->classifications);
if (!rc->books)
return AVERROR(ENOMEM);
{
static const int8_t VAR_5[10][8] = {
{ -1, -1, -1, -1, -1, -1, -1, -1, },
{ -1, -1, 16, -1, -1, -1, -1, -1, },
{ -1, -1, 17, -1, -1, -1, -1, -1, },
{ -1, -1, 18, -1, -1, -1, -1, -1, },
{ -1, -1, 19, -1, -1, -1, -1, -1, },
{ -1, -1, 20, -1, -1, -1, -1, -1, },
{ -1, -1, 21, -1, -1, -1, -1, -1, },
{ 22, 23, -1, -1, -1, -1, -1, -1, },
{ 24, 25, -1, -1, -1, -1, -1, -1, },
{ 26, 27, 28, -1, -1, -1, -1, -1, },
};
memcpy(rc->books, VAR_5, sizeof VAR_5);
}
if ((VAR_4 = ready_residue(rc, VAR_0)) < 0)
return VAR_4;
VAR_0->nmappings = 1;
VAR_0->mappings = av_malloc(sizeof(vorbis_enc_mapping) * VAR_0->nmappings);
if (!VAR_0->mappings)
return AVERROR(ENOMEM);
mc = &VAR_0->mappings[0];
mc->submaps = 1;
mc->mux = av_malloc(sizeof(int) * VAR_0->channels);
if (!mc->mux)
return AVERROR(ENOMEM);
for (VAR_2 = 0; VAR_2 < VAR_0->channels; VAR_2++)
mc->mux[VAR_2] = 0;
mc->floor = av_malloc(sizeof(int) * mc->submaps);
mc->residue = av_malloc(sizeof(int) * mc->submaps);
if (!mc->floor || !mc->residue)
return AVERROR(ENOMEM);
for (VAR_2 = 0; VAR_2 < mc->submaps; VAR_2++) {
mc->floor[VAR_2] = 0;
mc->residue[VAR_2] = 0;
}
mc->coupling_steps = VAR_0->channels == 2 ? 1 : 0;
mc->magnitude = av_malloc(sizeof(int) * mc->coupling_steps);
mc->angle = av_malloc(sizeof(int) * mc->coupling_steps);
if (!mc->magnitude || !mc->angle)
return AVERROR(ENOMEM);
if (mc->coupling_steps) {
mc->magnitude[0] = 0;
mc->angle[0] = 1;
}
VAR_0->nmodes = 1;
VAR_0->modes = av_malloc(sizeof(vorbis_enc_mode) * VAR_0->nmodes);
if (!VAR_0->modes)
return AVERROR(ENOMEM);
VAR_0->modes[0].blockflag = 0;
VAR_0->modes[0].mapping = 0;
VAR_0->have_saved = 0;
VAR_0->saved = av_malloc_array(sizeof(float) * VAR_0->channels, (1 << VAR_0->log2_blocksize[1]) / 2);
VAR_0->samples = av_malloc_array(sizeof(float) * VAR_0->channels, (1 << VAR_0->log2_blocksize[1]));
VAR_0->floor = av_malloc_array(sizeof(float) * VAR_0->channels, (1 << VAR_0->log2_blocksize[1]) / 2);
VAR_0->coeffs = av_malloc_array(sizeof(float) * VAR_0->channels, (1 << VAR_0->log2_blocksize[1]) / 2);
if (!VAR_0->saved || !VAR_0->samples || !VAR_0->floor || !VAR_0->coeffs)
return AVERROR(ENOMEM);
if ((VAR_4 = dsp_init(VAR_1, VAR_0)) < 0)
return VAR_4;
return 0;
}
| [
"static int FUNC_0(vorbis_enc_context *VAR_0,\nAVCodecContext *VAR_1)\n{",
"vorbis_enc_floor *fc;",
"vorbis_enc_residue *rc;",
"vorbis_enc_mapping *mc;",
"int VAR_2, VAR_3, VAR_4;",
"VAR_0->channels = VAR_1->channels;",
"VAR_0->sample_rate = VAR_1->sample_rate;",
"VAR_0->log2_blocksize[0] = VAR_0->log2_blocksize[1] = 11;",
"VAR_0->ncodebooks = FF_ARRAY_ELEMS(cvectors);",
"VAR_0->codebooks = av_malloc(sizeof(vorbis_enc_codebook) * VAR_0->ncodebooks);",
"if (!VAR_0->codebooks)\nreturn AVERROR(ENOMEM);",
"for (VAR_3 = 0; VAR_3 < VAR_0->ncodebooks; VAR_3++) {",
"vorbis_enc_codebook *cb = &VAR_0->codebooks[VAR_3];",
"int vals;",
"cb->ndimensions = cvectors[VAR_3].dim;",
"cb->nentries = cvectors[VAR_3].real_len;",
"cb->min = cvectors[VAR_3].min;",
"cb->delta = cvectors[VAR_3].delta;",
"cb->lookup = cvectors[VAR_3].lookup;",
"cb->seq_p = 0;",
"cb->lens = av_malloc_array(cb->nentries, sizeof(uint8_t));",
"cb->codewords = av_malloc_array(cb->nentries, sizeof(uint32_t));",
"if (!cb->lens || !cb->codewords)\nreturn AVERROR(ENOMEM);",
"memcpy(cb->lens, cvectors[VAR_3].clens, cvectors[VAR_3].len);",
"memset(cb->lens + cvectors[VAR_3].len, 0, cb->nentries - cvectors[VAR_3].len);",
"if (cb->lookup) {",
"vals = cb_lookup_vals(cb->lookup, cb->ndimensions, cb->nentries);",
"cb->quantlist = av_malloc_array(vals, sizeof(int));",
"if (!cb->quantlist)\nreturn AVERROR(ENOMEM);",
"for (VAR_2 = 0; VAR_2 < vals; VAR_2++)",
"cb->quantlist[VAR_2] = cvectors[VAR_3].quant[VAR_2];",
"} else {",
"cb->quantlist = NULL;",
"}",
"if ((VAR_4 = ready_codebook(cb)) < 0)\nreturn VAR_4;",
"}",
"VAR_0->nfloors = 1;",
"VAR_0->floors = av_malloc(sizeof(vorbis_enc_floor) * VAR_0->nfloors);",
"if (!VAR_0->floors)\nreturn AVERROR(ENOMEM);",
"fc = &VAR_0->floors[0];",
"fc->partitions = NUM_FLOOR_PARTITIONS;",
"fc->partition_to_class = av_malloc(sizeof(int) * fc->partitions);",
"if (!fc->partition_to_class)\nreturn AVERROR(ENOMEM);",
"fc->nclasses = 0;",
"for (VAR_2 = 0; VAR_2 < fc->partitions; VAR_2++) {",
"static const int VAR_5[] = {0, 1, 2, 2, 3, 3, 4, 4};",
"fc->partition_to_class[VAR_2] = VAR_5[VAR_2];",
"fc->nclasses = FFMAX(fc->nclasses, fc->partition_to_class[VAR_2]);",
"}",
"fc->nclasses++;",
"fc->classes = av_malloc_array(fc->nclasses, sizeof(vorbis_enc_floor_class));",
"if (!fc->classes)\nreturn AVERROR(ENOMEM);",
"for (VAR_2 = 0; VAR_2 < fc->nclasses; VAR_2++) {",
"vorbis_enc_floor_class * c = &fc->classes[VAR_2];",
"int j, books;",
"c->dim = floor_classes[VAR_2].dim;",
"c->subclass = floor_classes[VAR_2].subclass;",
"c->masterbook = floor_classes[VAR_2].masterbook;",
"books = (1 << c->subclass);",
"c->books = av_malloc_array(books, sizeof(int));",
"if (!c->books)\nreturn AVERROR(ENOMEM);",
"for (j = 0; j < books; j++)",
"c->books[j] = floor_classes[VAR_2].nbooks[j];",
"}",
"fc->multiplier = 2;",
"fc->rangebits = VAR_0->log2_blocksize[0] - 1;",
"fc->values = 2;",
"for (VAR_2 = 0; VAR_2 < fc->partitions; VAR_2++)",
"fc->values += fc->classes[fc->partition_to_class[VAR_2]].dim;",
"fc->list = av_malloc_array(fc->values, sizeof(vorbis_floor1_entry));",
"if (!fc->list)\nreturn AVERROR(ENOMEM);",
"fc->list[0].x = 0;",
"fc->list[1].x = 1 << fc->rangebits;",
"for (VAR_2 = 2; VAR_2 < fc->values; VAR_2++) {",
"static const int VAR_5[] = {",
"93, 23,372, 6, 46,186,750, 14, 33, 65,\n130,260,556, 3, 10, 18, 28, 39, 55, 79,\n111,158,220,312,464,650,850\n};",
"fc->list[VAR_2].x = VAR_5[VAR_2 - 2];",
"}",
"if (ff_vorbis_ready_floor1_list(VAR_1, fc->list, fc->values))\nreturn AVERROR_BUG;",
"VAR_0->nresidues = 1;",
"VAR_0->residues = av_malloc(sizeof(vorbis_enc_residue) * VAR_0->nresidues);",
"if (!VAR_0->residues)\nreturn AVERROR(ENOMEM);",
"rc = &VAR_0->residues[0];",
"rc->type = 2;",
"rc->begin = 0;",
"rc->end = 1600;",
"rc->partition_size = 32;",
"rc->classifications = 10;",
"rc->classbook = 15;",
"rc->books = av_malloc(sizeof(*rc->books) * rc->classifications);",
"if (!rc->books)\nreturn AVERROR(ENOMEM);",
"{",
"static const int8_t VAR_5[10][8] = {",
"{ -1, -1, -1, -1, -1, -1, -1, -1, },",
"{ -1, -1, 16, -1, -1, -1, -1, -1, },",
"{ -1, -1, 17, -1, -1, -1, -1, -1, },",
"{ -1, -1, 18, -1, -1, -1, -1, -1, },",
"{ -1, -1, 19, -1, -1, -1, -1, -1, },",
"{ -1, -1, 20, -1, -1, -1, -1, -1, },",
"{ -1, -1, 21, -1, -1, -1, -1, -1, },",
"{ 22, 23, -1, -1, -1, -1, -1, -1, },",
"{ 24, 25, -1, -1, -1, -1, -1, -1, },",
"{ 26, 27, 28, -1, -1, -1, -1, -1, },",
"};",
"memcpy(rc->books, VAR_5, sizeof VAR_5);",
"}",
"if ((VAR_4 = ready_residue(rc, VAR_0)) < 0)\nreturn VAR_4;",
"VAR_0->nmappings = 1;",
"VAR_0->mappings = av_malloc(sizeof(vorbis_enc_mapping) * VAR_0->nmappings);",
"if (!VAR_0->mappings)\nreturn AVERROR(ENOMEM);",
"mc = &VAR_0->mappings[0];",
"mc->submaps = 1;",
"mc->mux = av_malloc(sizeof(int) * VAR_0->channels);",
"if (!mc->mux)\nreturn AVERROR(ENOMEM);",
"for (VAR_2 = 0; VAR_2 < VAR_0->channels; VAR_2++)",
"mc->mux[VAR_2] = 0;",
"mc->floor = av_malloc(sizeof(int) * mc->submaps);",
"mc->residue = av_malloc(sizeof(int) * mc->submaps);",
"if (!mc->floor || !mc->residue)\nreturn AVERROR(ENOMEM);",
"for (VAR_2 = 0; VAR_2 < mc->submaps; VAR_2++) {",
"mc->floor[VAR_2] = 0;",
"mc->residue[VAR_2] = 0;",
"}",
"mc->coupling_steps = VAR_0->channels == 2 ? 1 : 0;",
"mc->magnitude = av_malloc(sizeof(int) * mc->coupling_steps);",
"mc->angle = av_malloc(sizeof(int) * mc->coupling_steps);",
"if (!mc->magnitude || !mc->angle)\nreturn AVERROR(ENOMEM);",
"if (mc->coupling_steps) {",
"mc->magnitude[0] = 0;",
"mc->angle[0] = 1;",
"}",
"VAR_0->nmodes = 1;",
"VAR_0->modes = av_malloc(sizeof(vorbis_enc_mode) * VAR_0->nmodes);",
"if (!VAR_0->modes)\nreturn AVERROR(ENOMEM);",
"VAR_0->modes[0].blockflag = 0;",
"VAR_0->modes[0].mapping = 0;",
"VAR_0->have_saved = 0;",
"VAR_0->saved = av_malloc_array(sizeof(float) * VAR_0->channels, (1 << VAR_0->log2_blocksize[1]) / 2);",
"VAR_0->samples = av_malloc_array(sizeof(float) * VAR_0->channels, (1 << VAR_0->log2_blocksize[1]));",
"VAR_0->floor = av_malloc_array(sizeof(float) * VAR_0->channels, (1 << VAR_0->log2_blocksize[1]) / 2);",
"VAR_0->coeffs = av_malloc_array(sizeof(float) * VAR_0->channels, (1 << VAR_0->log2_blocksize[1]) / 2);",
"if (!VAR_0->saved || !VAR_0->samples || !VAR_0->floor || !VAR_0->coeffs)\nreturn AVERROR(ENOMEM);",
"if ((VAR_4 = dsp_init(VAR_1, VAR_0)) < 0)\nreturn VAR_4;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29,
31
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95,
97
],
[
99
],
[
103
],
[
105
],
[
107,
109
],
[
115
],
[
117
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161,
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
177
],
[
179
],
[
181
],
[
185
],
[
187,
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199,
201,
203,
205
],
[
207
],
[
209
],
[
211,
213
],
[
217
],
[
219
],
[
221,
223
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245,
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279,
281
],
[
285
],
[
287
],
[
289,
291
],
[
297
],
[
299
],
[
301
],
[
303,
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315,
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333,
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
347
],
[
349
],
[
351,
353
],
[
359
],
[
361
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375,
377
],
[
381,
383
],
[
387
],
[
389
]
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.