id
int32 0
27.3k
| func
stringlengths 26
142k
| target
bool 2
classes | project
stringclasses 2
values | commit_id
stringlengths 40
40
| func_clean
stringlengths 26
131k
| vul_lines
dict | normalized_func
stringlengths 24
132k
| lines
listlengths 1
2.8k
| label
listlengths 1
2.8k
| line_no
listlengths 1
2.8k
|
|---|---|---|---|---|---|---|---|---|---|---|
12,845
|
void block_job_sleep_ns(BlockJob *job, QEMUClockType type, int64_t ns)
{
assert(job->busy);
/* Check cancellation *before* setting busy = false, too! */
if (block_job_is_cancelled(job)) {
return;
}
job->busy = false;
if (block_job_is_paused(job)) {
qemu_coroutine_yield();
} else {
co_aio_sleep_ns(blk_get_aio_context(job->blk), type, ns);
}
job->busy = true;
}
| false
|
qemu
|
0824afda0cd20045ffe87d58e142774514b61026
|
void block_job_sleep_ns(BlockJob *job, QEMUClockType type, int64_t ns)
{
assert(job->busy);
if (block_job_is_cancelled(job)) {
return;
}
job->busy = false;
if (block_job_is_paused(job)) {
qemu_coroutine_yield();
} else {
co_aio_sleep_ns(blk_get_aio_context(job->blk), type, ns);
}
job->busy = true;
}
|
{
"code": [],
"line_no": []
}
|
void FUNC_0(BlockJob *VAR_0, QEMUClockType VAR_1, int64_t VAR_2)
{
assert(VAR_0->busy);
if (block_job_is_cancelled(VAR_0)) {
return;
}
VAR_0->busy = false;
if (block_job_is_paused(VAR_0)) {
qemu_coroutine_yield();
} else {
co_aio_sleep_ns(blk_get_aio_context(VAR_0->blk), VAR_1, VAR_2);
}
VAR_0->busy = true;
}
|
[
"void FUNC_0(BlockJob *VAR_0, QEMUClockType VAR_1, int64_t VAR_2)\n{",
"assert(VAR_0->busy);",
"if (block_job_is_cancelled(VAR_0)) {",
"return;",
"}",
"VAR_0->busy = false;",
"if (block_job_is_paused(VAR_0)) {",
"qemu_coroutine_yield();",
"} else {",
"co_aio_sleep_ns(blk_get_aio_context(VAR_0->blk), VAR_1, VAR_2);",
"}",
"VAR_0->busy = true;",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
]
] |
12,847
|
void mixeng_clear (st_sample_t *buf, int len)
{
memset (buf, 0, len * sizeof (st_sample_t));
}
| false
|
qemu
|
1ea879e5580f63414693655fcf0328559cdce138
|
void mixeng_clear (st_sample_t *buf, int len)
{
memset (buf, 0, len * sizeof (st_sample_t));
}
|
{
"code": [],
"line_no": []
}
|
void FUNC_0 (st_sample_t *VAR_0, int VAR_1)
{
memset (VAR_0, 0, VAR_1 * sizeof (st_sample_t));
}
|
[
"void FUNC_0 (st_sample_t *VAR_0, int VAR_1)\n{",
"memset (VAR_0, 0, VAR_1 * sizeof (st_sample_t));",
"}"
] |
[
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
]
] |
12,848
|
static void slavio_set_timer_irq_cpu(void *opaque, int cpu, int level)
{
SLAVIO_INTCTLState *s = opaque;
DPRINTF("Set cpu %d local level %d\n", cpu, level);
if (!s->cpu_envs[cpu])
return;
if (level) {
s->intreg_pending[cpu] |= s->cputimer_bit;
} else {
s->intreg_pending[cpu] &= ~s->cputimer_bit;
}
slavio_check_interrupts(s);
}
| false
|
qemu
|
b3a2319792ad5c0f0f8c3d2f4d02b95fd7efbc69
|
static void slavio_set_timer_irq_cpu(void *opaque, int cpu, int level)
{
SLAVIO_INTCTLState *s = opaque;
DPRINTF("Set cpu %d local level %d\n", cpu, level);
if (!s->cpu_envs[cpu])
return;
if (level) {
s->intreg_pending[cpu] |= s->cputimer_bit;
} else {
s->intreg_pending[cpu] &= ~s->cputimer_bit;
}
slavio_check_interrupts(s);
}
|
{
"code": [],
"line_no": []
}
|
static void FUNC_0(void *VAR_0, int VAR_1, int VAR_2)
{
SLAVIO_INTCTLState *s = VAR_0;
DPRINTF("Set VAR_1 %d local VAR_2 %d\n", VAR_1, VAR_2);
if (!s->cpu_envs[VAR_1])
return;
if (VAR_2) {
s->intreg_pending[VAR_1] |= s->cputimer_bit;
} else {
s->intreg_pending[VAR_1] &= ~s->cputimer_bit;
}
slavio_check_interrupts(s);
}
|
[
"static void FUNC_0(void *VAR_0, int VAR_1, int VAR_2)\n{",
"SLAVIO_INTCTLState *s = VAR_0;",
"DPRINTF(\"Set VAR_1 %d local VAR_2 %d\\n\", VAR_1, VAR_2);",
"if (!s->cpu_envs[VAR_1])\nreturn;",
"if (VAR_2) {",
"s->intreg_pending[VAR_1] |= s->cputimer_bit;",
"} else {",
"s->intreg_pending[VAR_1] &= ~s->cputimer_bit;",
"}",
"slavio_check_interrupts(s);",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
]
] |
12,849
|
void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name)
{
if (QTAILQ_EMPTY(&address_spaces)) {
memory_init();
}
memory_region_transaction_begin();
as->root = root;
as->current_map = g_new(FlatView, 1);
flatview_init(as->current_map);
as->ioeventfd_nb = 0;
as->ioeventfds = NULL;
QTAILQ_INSERT_TAIL(&address_spaces, as, address_spaces_link);
as->name = g_strdup(name ? name : "anonymous");
address_space_init_dispatch(as);
memory_region_update_pending |= root->enabled;
memory_region_transaction_commit();
}
| false
|
qemu
|
374f2981d1f10bc4307f250f24b2a7ddb9b14be0
|
void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name)
{
if (QTAILQ_EMPTY(&address_spaces)) {
memory_init();
}
memory_region_transaction_begin();
as->root = root;
as->current_map = g_new(FlatView, 1);
flatview_init(as->current_map);
as->ioeventfd_nb = 0;
as->ioeventfds = NULL;
QTAILQ_INSERT_TAIL(&address_spaces, as, address_spaces_link);
as->name = g_strdup(name ? name : "anonymous");
address_space_init_dispatch(as);
memory_region_update_pending |= root->enabled;
memory_region_transaction_commit();
}
|
{
"code": [],
"line_no": []
}
|
void FUNC_0(AddressSpace *VAR_0, MemoryRegion *VAR_1, const char *VAR_2)
{
if (QTAILQ_EMPTY(&address_spaces)) {
memory_init();
}
memory_region_transaction_begin();
VAR_0->VAR_1 = VAR_1;
VAR_0->current_map = g_new(FlatView, 1);
flatview_init(VAR_0->current_map);
VAR_0->ioeventfd_nb = 0;
VAR_0->ioeventfds = NULL;
QTAILQ_INSERT_TAIL(&address_spaces, VAR_0, address_spaces_link);
VAR_0->VAR_2 = g_strdup(VAR_2 ? VAR_2 : "anonymous");
address_space_init_dispatch(VAR_0);
memory_region_update_pending |= VAR_1->enabled;
memory_region_transaction_commit();
}
|
[
"void FUNC_0(AddressSpace *VAR_0, MemoryRegion *VAR_1, const char *VAR_2)\n{",
"if (QTAILQ_EMPTY(&address_spaces)) {",
"memory_init();",
"}",
"memory_region_transaction_begin();",
"VAR_0->VAR_1 = VAR_1;",
"VAR_0->current_map = g_new(FlatView, 1);",
"flatview_init(VAR_0->current_map);",
"VAR_0->ioeventfd_nb = 0;",
"VAR_0->ioeventfds = NULL;",
"QTAILQ_INSERT_TAIL(&address_spaces, VAR_0, address_spaces_link);",
"VAR_0->VAR_2 = g_strdup(VAR_2 ? VAR_2 : \"anonymous\");",
"address_space_init_dispatch(VAR_0);",
"memory_region_update_pending |= VAR_1->enabled;",
"memory_region_transaction_commit();",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
]
] |
12,850
|
int avpriv_dca_parse_core_frame_header(GetBitContext *gb, DCACoreFrameHeader *h)
{
if (get_bits_long(gb, 32) != DCA_SYNCWORD_CORE_BE)
return DCA_PARSE_ERROR_SYNC_WORD;
h->normal_frame = get_bits1(gb);
h->deficit_samples = get_bits(gb, 5) + 1;
if (h->deficit_samples != DCA_PCMBLOCK_SAMPLES)
return DCA_PARSE_ERROR_DEFICIT_SAMPLES;
h->crc_present = get_bits1(gb);
h->npcmblocks = get_bits(gb, 7) + 1;
if (h->npcmblocks & (DCA_SUBBAND_SAMPLES - 1))
return DCA_PARSE_ERROR_PCM_BLOCKS;
h->frame_size = get_bits(gb, 14) + 1;
if (h->frame_size < 96)
return DCA_PARSE_ERROR_FRAME_SIZE;
h->audio_mode = get_bits(gb, 6);
if (h->audio_mode >= DCA_AMODE_COUNT)
return DCA_PARSE_ERROR_AMODE;
h->sr_code = get_bits(gb, 4);
if (!avpriv_dca_sample_rates[h->sr_code])
return DCA_PARSE_ERROR_SAMPLE_RATE;
h->br_code = get_bits(gb, 5);
if (get_bits1(gb))
return DCA_PARSE_ERROR_RESERVED_BIT;
h->drc_present = get_bits1(gb);
h->ts_present = get_bits1(gb);
h->aux_present = get_bits1(gb);
h->hdcd_master = get_bits1(gb);
h->ext_audio_type = get_bits(gb, 3);
h->ext_audio_present = get_bits1(gb);
h->sync_ssf = get_bits1(gb);
h->lfe_present = get_bits(gb, 2);
if (h->lfe_present == DCA_LFE_FLAG_INVALID)
return DCA_PARSE_ERROR_LFE_FLAG;
h->predictor_history = get_bits1(gb);
if (h->crc_present)
skip_bits(gb, 16);
h->filter_perfect = get_bits1(gb);
h->encoder_rev = get_bits(gb, 4);
h->copy_hist = get_bits(gb, 2);
h->pcmr_code = get_bits(gb, 3);
if (!ff_dca_bits_per_sample[h->pcmr_code])
return DCA_PARSE_ERROR_PCM_RES;
h->sumdiff_front = get_bits1(gb);
h->sumdiff_surround = get_bits1(gb);
h->dn_code = get_bits(gb, 4);
return 0;
}
| false
|
FFmpeg
|
7c9d2ad45f4e46ad2c3b2e93051efbe1e0d0529e
|
int avpriv_dca_parse_core_frame_header(GetBitContext *gb, DCACoreFrameHeader *h)
{
if (get_bits_long(gb, 32) != DCA_SYNCWORD_CORE_BE)
return DCA_PARSE_ERROR_SYNC_WORD;
h->normal_frame = get_bits1(gb);
h->deficit_samples = get_bits(gb, 5) + 1;
if (h->deficit_samples != DCA_PCMBLOCK_SAMPLES)
return DCA_PARSE_ERROR_DEFICIT_SAMPLES;
h->crc_present = get_bits1(gb);
h->npcmblocks = get_bits(gb, 7) + 1;
if (h->npcmblocks & (DCA_SUBBAND_SAMPLES - 1))
return DCA_PARSE_ERROR_PCM_BLOCKS;
h->frame_size = get_bits(gb, 14) + 1;
if (h->frame_size < 96)
return DCA_PARSE_ERROR_FRAME_SIZE;
h->audio_mode = get_bits(gb, 6);
if (h->audio_mode >= DCA_AMODE_COUNT)
return DCA_PARSE_ERROR_AMODE;
h->sr_code = get_bits(gb, 4);
if (!avpriv_dca_sample_rates[h->sr_code])
return DCA_PARSE_ERROR_SAMPLE_RATE;
h->br_code = get_bits(gb, 5);
if (get_bits1(gb))
return DCA_PARSE_ERROR_RESERVED_BIT;
h->drc_present = get_bits1(gb);
h->ts_present = get_bits1(gb);
h->aux_present = get_bits1(gb);
h->hdcd_master = get_bits1(gb);
h->ext_audio_type = get_bits(gb, 3);
h->ext_audio_present = get_bits1(gb);
h->sync_ssf = get_bits1(gb);
h->lfe_present = get_bits(gb, 2);
if (h->lfe_present == DCA_LFE_FLAG_INVALID)
return DCA_PARSE_ERROR_LFE_FLAG;
h->predictor_history = get_bits1(gb);
if (h->crc_present)
skip_bits(gb, 16);
h->filter_perfect = get_bits1(gb);
h->encoder_rev = get_bits(gb, 4);
h->copy_hist = get_bits(gb, 2);
h->pcmr_code = get_bits(gb, 3);
if (!ff_dca_bits_per_sample[h->pcmr_code])
return DCA_PARSE_ERROR_PCM_RES;
h->sumdiff_front = get_bits1(gb);
h->sumdiff_surround = get_bits1(gb);
h->dn_code = get_bits(gb, 4);
return 0;
}
|
{
"code": [],
"line_no": []
}
|
int FUNC_0(GetBitContext *VAR_0, DCACoreFrameHeader *VAR_1)
{
if (get_bits_long(VAR_0, 32) != DCA_SYNCWORD_CORE_BE)
return DCA_PARSE_ERROR_SYNC_WORD;
VAR_1->normal_frame = get_bits1(VAR_0);
VAR_1->deficit_samples = get_bits(VAR_0, 5) + 1;
if (VAR_1->deficit_samples != DCA_PCMBLOCK_SAMPLES)
return DCA_PARSE_ERROR_DEFICIT_SAMPLES;
VAR_1->crc_present = get_bits1(VAR_0);
VAR_1->npcmblocks = get_bits(VAR_0, 7) + 1;
if (VAR_1->npcmblocks & (DCA_SUBBAND_SAMPLES - 1))
return DCA_PARSE_ERROR_PCM_BLOCKS;
VAR_1->frame_size = get_bits(VAR_0, 14) + 1;
if (VAR_1->frame_size < 96)
return DCA_PARSE_ERROR_FRAME_SIZE;
VAR_1->audio_mode = get_bits(VAR_0, 6);
if (VAR_1->audio_mode >= DCA_AMODE_COUNT)
return DCA_PARSE_ERROR_AMODE;
VAR_1->sr_code = get_bits(VAR_0, 4);
if (!avpriv_dca_sample_rates[VAR_1->sr_code])
return DCA_PARSE_ERROR_SAMPLE_RATE;
VAR_1->br_code = get_bits(VAR_0, 5);
if (get_bits1(VAR_0))
return DCA_PARSE_ERROR_RESERVED_BIT;
VAR_1->drc_present = get_bits1(VAR_0);
VAR_1->ts_present = get_bits1(VAR_0);
VAR_1->aux_present = get_bits1(VAR_0);
VAR_1->hdcd_master = get_bits1(VAR_0);
VAR_1->ext_audio_type = get_bits(VAR_0, 3);
VAR_1->ext_audio_present = get_bits1(VAR_0);
VAR_1->sync_ssf = get_bits1(VAR_0);
VAR_1->lfe_present = get_bits(VAR_0, 2);
if (VAR_1->lfe_present == DCA_LFE_FLAG_INVALID)
return DCA_PARSE_ERROR_LFE_FLAG;
VAR_1->predictor_history = get_bits1(VAR_0);
if (VAR_1->crc_present)
skip_bits(VAR_0, 16);
VAR_1->filter_perfect = get_bits1(VAR_0);
VAR_1->encoder_rev = get_bits(VAR_0, 4);
VAR_1->copy_hist = get_bits(VAR_0, 2);
VAR_1->pcmr_code = get_bits(VAR_0, 3);
if (!ff_dca_bits_per_sample[VAR_1->pcmr_code])
return DCA_PARSE_ERROR_PCM_RES;
VAR_1->sumdiff_front = get_bits1(VAR_0);
VAR_1->sumdiff_surround = get_bits1(VAR_0);
VAR_1->dn_code = get_bits(VAR_0, 4);
return 0;
}
|
[
"int FUNC_0(GetBitContext *VAR_0, DCACoreFrameHeader *VAR_1)\n{",
"if (get_bits_long(VAR_0, 32) != DCA_SYNCWORD_CORE_BE)\nreturn DCA_PARSE_ERROR_SYNC_WORD;",
"VAR_1->normal_frame = get_bits1(VAR_0);",
"VAR_1->deficit_samples = get_bits(VAR_0, 5) + 1;",
"if (VAR_1->deficit_samples != DCA_PCMBLOCK_SAMPLES)\nreturn DCA_PARSE_ERROR_DEFICIT_SAMPLES;",
"VAR_1->crc_present = get_bits1(VAR_0);",
"VAR_1->npcmblocks = get_bits(VAR_0, 7) + 1;",
"if (VAR_1->npcmblocks & (DCA_SUBBAND_SAMPLES - 1))\nreturn DCA_PARSE_ERROR_PCM_BLOCKS;",
"VAR_1->frame_size = get_bits(VAR_0, 14) + 1;",
"if (VAR_1->frame_size < 96)\nreturn DCA_PARSE_ERROR_FRAME_SIZE;",
"VAR_1->audio_mode = get_bits(VAR_0, 6);",
"if (VAR_1->audio_mode >= DCA_AMODE_COUNT)\nreturn DCA_PARSE_ERROR_AMODE;",
"VAR_1->sr_code = get_bits(VAR_0, 4);",
"if (!avpriv_dca_sample_rates[VAR_1->sr_code])\nreturn DCA_PARSE_ERROR_SAMPLE_RATE;",
"VAR_1->br_code = get_bits(VAR_0, 5);",
"if (get_bits1(VAR_0))\nreturn DCA_PARSE_ERROR_RESERVED_BIT;",
"VAR_1->drc_present = get_bits1(VAR_0);",
"VAR_1->ts_present = get_bits1(VAR_0);",
"VAR_1->aux_present = get_bits1(VAR_0);",
"VAR_1->hdcd_master = get_bits1(VAR_0);",
"VAR_1->ext_audio_type = get_bits(VAR_0, 3);",
"VAR_1->ext_audio_present = get_bits1(VAR_0);",
"VAR_1->sync_ssf = get_bits1(VAR_0);",
"VAR_1->lfe_present = get_bits(VAR_0, 2);",
"if (VAR_1->lfe_present == DCA_LFE_FLAG_INVALID)\nreturn DCA_PARSE_ERROR_LFE_FLAG;",
"VAR_1->predictor_history = get_bits1(VAR_0);",
"if (VAR_1->crc_present)\nskip_bits(VAR_0, 16);",
"VAR_1->filter_perfect = get_bits1(VAR_0);",
"VAR_1->encoder_rev = get_bits(VAR_0, 4);",
"VAR_1->copy_hist = get_bits(VAR_0, 2);",
"VAR_1->pcmr_code = get_bits(VAR_0, 3);",
"if (!ff_dca_bits_per_sample[VAR_1->pcmr_code])\nreturn DCA_PARSE_ERROR_PCM_RES;",
"VAR_1->sumdiff_front = get_bits1(VAR_0);",
"VAR_1->sumdiff_surround = get_bits1(VAR_0);",
"VAR_1->dn_code = get_bits(VAR_0, 4);",
"return 0;",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5,
7
],
[
11
],
[
13
],
[
15,
17
],
[
21
],
[
23
],
[
25,
27
],
[
31
],
[
33,
35
],
[
39
],
[
41,
43
],
[
47
],
[
49,
51
],
[
55
],
[
57,
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79,
81
],
[
85
],
[
87,
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99,
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
]
] |
12,851
|
static void padzero(unsigned long elf_bss)
{
unsigned long nbyte;
char * fpnt;
nbyte = elf_bss & (host_page_size-1); /* was TARGET_PAGE_SIZE - JRP */
if (nbyte) {
nbyte = host_page_size - nbyte;
fpnt = (char *) elf_bss;
do {
*fpnt++ = 0;
} while (--nbyte);
}
}
| false
|
qemu
|
853d6f7a835ff33cf53f2922e4039d4cfad8ac17
|
static void padzero(unsigned long elf_bss)
{
unsigned long nbyte;
char * fpnt;
nbyte = elf_bss & (host_page_size-1);
if (nbyte) {
nbyte = host_page_size - nbyte;
fpnt = (char *) elf_bss;
do {
*fpnt++ = 0;
} while (--nbyte);
}
}
|
{
"code": [],
"line_no": []
}
|
static void FUNC_0(unsigned long VAR_0)
{
unsigned long VAR_1;
char * VAR_2;
VAR_1 = VAR_0 & (host_page_size-1);
if (VAR_1) {
VAR_1 = host_page_size - VAR_1;
VAR_2 = (char *) VAR_0;
do {
*VAR_2++ = 0;
} while (--VAR_1);
}
}
|
[
"static void FUNC_0(unsigned long VAR_0)\n{",
"unsigned long VAR_1;",
"char * VAR_2;",
"VAR_1 = VAR_0 & (host_page_size-1);",
"if (VAR_1) {",
"VAR_1 = host_page_size - VAR_1;",
"VAR_2 = (char *) VAR_0;",
"do {",
"*VAR_2++ = 0;",
"} while (--VAR_1);",
"}",
"}"
] |
[
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
]
] |
12,852
|
static int vmdk_open(BlockDriverState *bs, int flags)
{
int ret;
BDRVVmdkState *s = bs->opaque;
if (vmdk_open_sparse(bs, bs->file, flags) == 0) {
s->desc_offset = 0x200;
} else {
ret = vmdk_open_desc_file(bs, flags, 0);
if (ret) {
goto fail;
}
}
/* try to open parent images, if exist */
ret = vmdk_parent_open(bs);
if (ret) {
goto fail;
}
s->parent_cid = vmdk_read_cid(bs, 1);
qemu_co_mutex_init(&s->lock);
return ret;
fail:
vmdk_free_extents(bs);
return ret;
}
| false
|
qemu
|
2bc3166c22aeeb5cd7b8f21104f4744f08c7a288
|
static int vmdk_open(BlockDriverState *bs, int flags)
{
int ret;
BDRVVmdkState *s = bs->opaque;
if (vmdk_open_sparse(bs, bs->file, flags) == 0) {
s->desc_offset = 0x200;
} else {
ret = vmdk_open_desc_file(bs, flags, 0);
if (ret) {
goto fail;
}
}
ret = vmdk_parent_open(bs);
if (ret) {
goto fail;
}
s->parent_cid = vmdk_read_cid(bs, 1);
qemu_co_mutex_init(&s->lock);
return ret;
fail:
vmdk_free_extents(bs);
return ret;
}
|
{
"code": [],
"line_no": []
}
|
static int FUNC_0(BlockDriverState *VAR_0, int VAR_1)
{
int VAR_2;
BDRVVmdkState *s = VAR_0->opaque;
if (vmdk_open_sparse(VAR_0, VAR_0->file, VAR_1) == 0) {
s->desc_offset = 0x200;
} else {
VAR_2 = vmdk_open_desc_file(VAR_0, VAR_1, 0);
if (VAR_2) {
goto fail;
}
}
VAR_2 = vmdk_parent_open(VAR_0);
if (VAR_2) {
goto fail;
}
s->parent_cid = vmdk_read_cid(VAR_0, 1);
qemu_co_mutex_init(&s->lock);
return VAR_2;
fail:
vmdk_free_extents(VAR_0);
return VAR_2;
}
|
[
"static int FUNC_0(BlockDriverState *VAR_0, int VAR_1)\n{",
"int VAR_2;",
"BDRVVmdkState *s = VAR_0->opaque;",
"if (vmdk_open_sparse(VAR_0, VAR_0->file, VAR_1) == 0) {",
"s->desc_offset = 0x200;",
"} else {",
"VAR_2 = vmdk_open_desc_file(VAR_0, VAR_1, 0);",
"if (VAR_2) {",
"goto fail;",
"}",
"}",
"VAR_2 = vmdk_parent_open(VAR_0);",
"if (VAR_2) {",
"goto fail;",
"}",
"s->parent_cid = vmdk_read_cid(VAR_0, 1);",
"qemu_co_mutex_init(&s->lock);",
"return VAR_2;",
"fail:\nvmdk_free_extents(VAR_0);",
"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,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45,
47
],
[
49
],
[
51
]
] |
12,855
|
static void coroutine_fn pdu_complete(V9fsPDU *pdu, ssize_t len)
{
int8_t id = pdu->id + 1; /* Response */
V9fsState *s = pdu->s;
if (len < 0) {
int err = -len;
len = 7;
if (s->proto_version != V9FS_PROTO_2000L) {
V9fsString str;
str.data = strerror(err);
str.size = strlen(str.data);
len += pdu_marshal(pdu, len, "s", &str);
id = P9_RERROR;
}
len += pdu_marshal(pdu, len, "d", err);
if (s->proto_version == V9FS_PROTO_2000L) {
id = P9_RLERROR;
}
trace_v9fs_rerror(pdu->tag, pdu->id, err); /* Trace ERROR */
}
/* fill out the header */
pdu_marshal(pdu, 0, "dbw", (int32_t)len, id, pdu->tag);
/* keep these in sync */
pdu->size = len;
pdu->id = id;
pdu_push_and_notify(pdu);
/* Now wakeup anybody waiting in flush for this request */
qemu_co_queue_next(&pdu->complete);
pdu_free(pdu);
}
| false
|
qemu
|
f74e27bf0f07425aba6cb812aa7f5aa98bb68542
|
static void coroutine_fn pdu_complete(V9fsPDU *pdu, ssize_t len)
{
int8_t id = pdu->id + 1;
V9fsState *s = pdu->s;
if (len < 0) {
int err = -len;
len = 7;
if (s->proto_version != V9FS_PROTO_2000L) {
V9fsString str;
str.data = strerror(err);
str.size = strlen(str.data);
len += pdu_marshal(pdu, len, "s", &str);
id = P9_RERROR;
}
len += pdu_marshal(pdu, len, "d", err);
if (s->proto_version == V9FS_PROTO_2000L) {
id = P9_RLERROR;
}
trace_v9fs_rerror(pdu->tag, pdu->id, err);
}
pdu_marshal(pdu, 0, "dbw", (int32_t)len, id, pdu->tag);
pdu->size = len;
pdu->id = id;
pdu_push_and_notify(pdu);
qemu_co_queue_next(&pdu->complete);
pdu_free(pdu);
}
|
{
"code": [],
"line_no": []
}
|
static void VAR_0 pdu_complete(V9fsPDU *pdu, ssize_t len)
{
int8_t id = pdu->id + 1;
V9fsState *s = pdu->s;
if (len < 0) {
int err = -len;
len = 7;
if (s->proto_version != V9FS_PROTO_2000L) {
V9fsString str;
str.data = strerror(err);
str.size = strlen(str.data);
len += pdu_marshal(pdu, len, "s", &str);
id = P9_RERROR;
}
len += pdu_marshal(pdu, len, "d", err);
if (s->proto_version == V9FS_PROTO_2000L) {
id = P9_RLERROR;
}
trace_v9fs_rerror(pdu->tag, pdu->id, err);
}
pdu_marshal(pdu, 0, "dbw", (int32_t)len, id, pdu->tag);
pdu->size = len;
pdu->id = id;
pdu_push_and_notify(pdu);
qemu_co_queue_next(&pdu->complete);
pdu_free(pdu);
}
|
[
"static void VAR_0 pdu_complete(V9fsPDU *pdu, ssize_t len)\n{",
"int8_t id = pdu->id + 1;",
"V9fsState *s = pdu->s;",
"if (len < 0) {",
"int err = -len;",
"len = 7;",
"if (s->proto_version != V9FS_PROTO_2000L) {",
"V9fsString str;",
"str.data = strerror(err);",
"str.size = strlen(str.data);",
"len += pdu_marshal(pdu, len, \"s\", &str);",
"id = P9_RERROR;",
"}",
"len += pdu_marshal(pdu, len, \"d\", err);",
"if (s->proto_version == V9FS_PROTO_2000L) {",
"id = P9_RLERROR;",
"}",
"trace_v9fs_rerror(pdu->tag, pdu->id, err);",
"}",
"pdu_marshal(pdu, 0, \"dbw\", (int32_t)len, id, pdu->tag);",
"pdu->size = len;",
"pdu->id = id;",
"pdu_push_and_notify(pdu);",
"qemu_co_queue_next(&pdu->complete);",
"pdu_free(pdu);",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
57
],
[
63
],
[
65
],
[
69
],
[
75
],
[
79
],
[
81
]
] |
12,856
|
static QDict *parse_json_filename(const char *filename, Error **errp)
{
QObject *options_obj;
QDict *options;
int ret;
ret = strstart(filename, "json:", &filename);
assert(ret);
options_obj = qobject_from_json(filename);
if (!options_obj) {
error_setg(errp, "Could not parse the JSON options");
return NULL;
}
if (qobject_type(options_obj) != QTYPE_QDICT) {
qobject_decref(options_obj);
error_setg(errp, "Invalid JSON object given");
return NULL;
}
options = qobject_to_qdict(options_obj);
qdict_flatten(options);
return options;
}
| false
|
qemu
|
ca6b6e1e68ac44b2e8895da10dd1c80dc03d08b7
|
static QDict *parse_json_filename(const char *filename, Error **errp)
{
QObject *options_obj;
QDict *options;
int ret;
ret = strstart(filename, "json:", &filename);
assert(ret);
options_obj = qobject_from_json(filename);
if (!options_obj) {
error_setg(errp, "Could not parse the JSON options");
return NULL;
}
if (qobject_type(options_obj) != QTYPE_QDICT) {
qobject_decref(options_obj);
error_setg(errp, "Invalid JSON object given");
return NULL;
}
options = qobject_to_qdict(options_obj);
qdict_flatten(options);
return options;
}
|
{
"code": [],
"line_no": []
}
|
static QDict *FUNC_0(const char *filename, Error **errp)
{
QObject *options_obj;
QDict *options;
int VAR_0;
VAR_0 = strstart(filename, "json:", &filename);
assert(VAR_0);
options_obj = qobject_from_json(filename);
if (!options_obj) {
error_setg(errp, "Could not parse the JSON options");
return NULL;
}
if (qobject_type(options_obj) != QTYPE_QDICT) {
qobject_decref(options_obj);
error_setg(errp, "Invalid JSON object given");
return NULL;
}
options = qobject_to_qdict(options_obj);
qdict_flatten(options);
return options;
}
|
[
"static QDict *FUNC_0(const char *filename, Error **errp)\n{",
"QObject *options_obj;",
"QDict *options;",
"int VAR_0;",
"VAR_0 = strstart(filename, \"json:\", &filename);",
"assert(VAR_0);",
"options_obj = qobject_from_json(filename);",
"if (!options_obj) {",
"error_setg(errp, \"Could not parse the JSON options\");",
"return NULL;",
"}",
"if (qobject_type(options_obj) != QTYPE_QDICT) {",
"qobject_decref(options_obj);",
"error_setg(errp, \"Invalid JSON object given\");",
"return NULL;",
"}",
"options = qobject_to_qdict(options_obj);",
"qdict_flatten(options);",
"return options;",
"}"
] |
[
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
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
49
],
[
51
]
] |
12,857
|
static void gen_rlwnm(DisasContext *ctx)
{
uint32_t mb, me;
mb = MB(ctx->opcode);
me = ME(ctx->opcode);
if (likely(mb == 0 && me == 31)) {
TCGv_i32 t0, t1;
t0 = tcg_temp_new_i32();
t1 = tcg_temp_new_i32();
tcg_gen_trunc_tl_i32(t0, cpu_gpr[rB(ctx->opcode)]);
tcg_gen_trunc_tl_i32(t1, cpu_gpr[rS(ctx->opcode)]);
tcg_gen_andi_i32(t0, t0, 0x1f);
tcg_gen_rotl_i32(t1, t1, t0);
tcg_gen_extu_i32_tl(cpu_gpr[rA(ctx->opcode)], t1);
tcg_temp_free_i32(t0);
tcg_temp_free_i32(t1);
} else {
TCGv t0;
#if defined(TARGET_PPC64)
TCGv t1;
#endif
t0 = tcg_temp_new();
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x1f);
#if defined(TARGET_PPC64)
t1 = tcg_temp_new_i64();
tcg_gen_deposit_i64(t1, cpu_gpr[rS(ctx->opcode)],
cpu_gpr[rS(ctx->opcode)], 32, 32);
tcg_gen_rotl_i64(t0, t1, t0);
tcg_temp_free_i64(t1);
#else
tcg_gen_rotl_i32(t0, cpu_gpr[rS(ctx->opcode)], t0);
#endif
if (unlikely(mb != 0 || me != 31)) {
#if defined(TARGET_PPC64)
mb += 32;
me += 32;
#endif
tcg_gen_andi_tl(cpu_gpr[rA(ctx->opcode)], t0, MASK(mb, me));
} else {
tcg_gen_andi_tl(t0, t0, MASK(32, 63));
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], t0);
}
tcg_temp_free(t0);
}
if (unlikely(Rc(ctx->opcode) != 0))
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
}
| false
|
qemu
|
63ae0915f8ec9746d17a25c27f64cf65550627ab
|
static void gen_rlwnm(DisasContext *ctx)
{
uint32_t mb, me;
mb = MB(ctx->opcode);
me = ME(ctx->opcode);
if (likely(mb == 0 && me == 31)) {
TCGv_i32 t0, t1;
t0 = tcg_temp_new_i32();
t1 = tcg_temp_new_i32();
tcg_gen_trunc_tl_i32(t0, cpu_gpr[rB(ctx->opcode)]);
tcg_gen_trunc_tl_i32(t1, cpu_gpr[rS(ctx->opcode)]);
tcg_gen_andi_i32(t0, t0, 0x1f);
tcg_gen_rotl_i32(t1, t1, t0);
tcg_gen_extu_i32_tl(cpu_gpr[rA(ctx->opcode)], t1);
tcg_temp_free_i32(t0);
tcg_temp_free_i32(t1);
} else {
TCGv t0;
#if defined(TARGET_PPC64)
TCGv t1;
#endif
t0 = tcg_temp_new();
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x1f);
#if defined(TARGET_PPC64)
t1 = tcg_temp_new_i64();
tcg_gen_deposit_i64(t1, cpu_gpr[rS(ctx->opcode)],
cpu_gpr[rS(ctx->opcode)], 32, 32);
tcg_gen_rotl_i64(t0, t1, t0);
tcg_temp_free_i64(t1);
#else
tcg_gen_rotl_i32(t0, cpu_gpr[rS(ctx->opcode)], t0);
#endif
if (unlikely(mb != 0 || me != 31)) {
#if defined(TARGET_PPC64)
mb += 32;
me += 32;
#endif
tcg_gen_andi_tl(cpu_gpr[rA(ctx->opcode)], t0, MASK(mb, me));
} else {
tcg_gen_andi_tl(t0, t0, MASK(32, 63));
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], t0);
}
tcg_temp_free(t0);
}
if (unlikely(Rc(ctx->opcode) != 0))
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
}
|
{
"code": [],
"line_no": []
}
|
static void FUNC_0(DisasContext *VAR_0)
{
uint32_t mb, me;
mb = MB(VAR_0->opcode);
me = ME(VAR_0->opcode);
if (likely(mb == 0 && me == 31)) {
TCGv_i32 t0, t1;
t0 = tcg_temp_new_i32();
t1 = tcg_temp_new_i32();
tcg_gen_trunc_tl_i32(t0, cpu_gpr[rB(VAR_0->opcode)]);
tcg_gen_trunc_tl_i32(t1, cpu_gpr[rS(VAR_0->opcode)]);
tcg_gen_andi_i32(t0, t0, 0x1f);
tcg_gen_rotl_i32(t1, t1, t0);
tcg_gen_extu_i32_tl(cpu_gpr[rA(VAR_0->opcode)], t1);
tcg_temp_free_i32(t0);
tcg_temp_free_i32(t1);
} else {
TCGv t0;
#if defined(TARGET_PPC64)
TCGv t1;
#endif
t0 = tcg_temp_new();
tcg_gen_andi_tl(t0, cpu_gpr[rB(VAR_0->opcode)], 0x1f);
#if defined(TARGET_PPC64)
t1 = tcg_temp_new_i64();
tcg_gen_deposit_i64(t1, cpu_gpr[rS(VAR_0->opcode)],
cpu_gpr[rS(VAR_0->opcode)], 32, 32);
tcg_gen_rotl_i64(t0, t1, t0);
tcg_temp_free_i64(t1);
#else
tcg_gen_rotl_i32(t0, cpu_gpr[rS(VAR_0->opcode)], t0);
#endif
if (unlikely(mb != 0 || me != 31)) {
#if defined(TARGET_PPC64)
mb += 32;
me += 32;
#endif
tcg_gen_andi_tl(cpu_gpr[rA(VAR_0->opcode)], t0, MASK(mb, me));
} else {
tcg_gen_andi_tl(t0, t0, MASK(32, 63));
tcg_gen_mov_tl(cpu_gpr[rA(VAR_0->opcode)], t0);
}
tcg_temp_free(t0);
}
if (unlikely(Rc(VAR_0->opcode) != 0))
gen_set_Rc0(VAR_0, cpu_gpr[rA(VAR_0->opcode)]);
}
|
[
"static void FUNC_0(DisasContext *VAR_0)\n{",
"uint32_t mb, me;",
"mb = MB(VAR_0->opcode);",
"me = ME(VAR_0->opcode);",
"if (likely(mb == 0 && me == 31)) {",
"TCGv_i32 t0, t1;",
"t0 = tcg_temp_new_i32();",
"t1 = tcg_temp_new_i32();",
"tcg_gen_trunc_tl_i32(t0, cpu_gpr[rB(VAR_0->opcode)]);",
"tcg_gen_trunc_tl_i32(t1, cpu_gpr[rS(VAR_0->opcode)]);",
"tcg_gen_andi_i32(t0, t0, 0x1f);",
"tcg_gen_rotl_i32(t1, t1, t0);",
"tcg_gen_extu_i32_tl(cpu_gpr[rA(VAR_0->opcode)], t1);",
"tcg_temp_free_i32(t0);",
"tcg_temp_free_i32(t1);",
"} else {",
"TCGv t0;",
"#if defined(TARGET_PPC64)\nTCGv t1;",
"#endif\nt0 = tcg_temp_new();",
"tcg_gen_andi_tl(t0, cpu_gpr[rB(VAR_0->opcode)], 0x1f);",
"#if defined(TARGET_PPC64)\nt1 = tcg_temp_new_i64();",
"tcg_gen_deposit_i64(t1, cpu_gpr[rS(VAR_0->opcode)],\ncpu_gpr[rS(VAR_0->opcode)], 32, 32);",
"tcg_gen_rotl_i64(t0, t1, t0);",
"tcg_temp_free_i64(t1);",
"#else\ntcg_gen_rotl_i32(t0, cpu_gpr[rS(VAR_0->opcode)], t0);",
"#endif\nif (unlikely(mb != 0 || me != 31)) {",
"#if defined(TARGET_PPC64)\nmb += 32;",
"me += 32;",
"#endif\ntcg_gen_andi_tl(cpu_gpr[rA(VAR_0->opcode)], t0, MASK(mb, me));",
"} else {",
"tcg_gen_andi_tl(t0, t0, MASK(32, 63));",
"tcg_gen_mov_tl(cpu_gpr[rA(VAR_0->opcode)], t0);",
"}",
"tcg_temp_free(t0);",
"}",
"if (unlikely(Rc(VAR_0->opcode) != 0))\ngen_set_Rc0(VAR_0, cpu_gpr[rA(VAR_0->opcode)]);",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43,
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
]
] |
12,858
|
static void test_native_list(TestOutputVisitorData *data,
const void *unused,
UserDefNativeListUnionKind kind)
{
UserDefNativeListUnion *cvalue = g_new0(UserDefNativeListUnion, 1);
QObject *obj;
cvalue->type = kind;
init_native_list(cvalue);
visit_type_UserDefNativeListUnion(data->ov, NULL, &cvalue, &error_abort);
obj = visitor_get(data);
check_native_list(obj, cvalue->type);
qapi_free_UserDefNativeListUnion(cvalue);
}
| false
|
qemu
|
b3db211f3c80bb996a704d665fe275619f728bd4
|
static void test_native_list(TestOutputVisitorData *data,
const void *unused,
UserDefNativeListUnionKind kind)
{
UserDefNativeListUnion *cvalue = g_new0(UserDefNativeListUnion, 1);
QObject *obj;
cvalue->type = kind;
init_native_list(cvalue);
visit_type_UserDefNativeListUnion(data->ov, NULL, &cvalue, &error_abort);
obj = visitor_get(data);
check_native_list(obj, cvalue->type);
qapi_free_UserDefNativeListUnion(cvalue);
}
|
{
"code": [],
"line_no": []
}
|
static void FUNC_0(TestOutputVisitorData *VAR_0,
const void *VAR_1,
UserDefNativeListUnionKind VAR_2)
{
UserDefNativeListUnion *cvalue = g_new0(UserDefNativeListUnion, 1);
QObject *obj;
cvalue->type = VAR_2;
init_native_list(cvalue);
visit_type_UserDefNativeListUnion(VAR_0->ov, NULL, &cvalue, &error_abort);
obj = visitor_get(VAR_0);
check_native_list(obj, cvalue->type);
qapi_free_UserDefNativeListUnion(cvalue);
}
|
[
"static void FUNC_0(TestOutputVisitorData *VAR_0,\nconst void *VAR_1,\nUserDefNativeListUnionKind VAR_2)\n{",
"UserDefNativeListUnion *cvalue = g_new0(UserDefNativeListUnion, 1);",
"QObject *obj;",
"cvalue->type = VAR_2;",
"init_native_list(cvalue);",
"visit_type_UserDefNativeListUnion(VAR_0->ov, NULL, &cvalue, &error_abort);",
"obj = visitor_get(VAR_0);",
"check_native_list(obj, cvalue->type);",
"qapi_free_UserDefNativeListUnion(cvalue);",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
]
] |
12,859
|
static void FUNCC(pred8x8l_horizontal_add)(uint8_t *_pix, const int16_t *_block,
ptrdiff_t stride)
{
int i;
pixel *pix = (pixel*)_pix;
const dctcoef *block = (const dctcoef*)_block;
stride >>= sizeof(pixel)-1;
for(i=0; i<8; i++){
pixel v = pix[-1];
pix[0]= v += block[0];
pix[1]= v += block[1];
pix[2]= v += block[2];
pix[3]= v += block[3];
pix[4]= v += block[4];
pix[5]= v += block[5];
pix[6]= v += block[6];
pix[7]= v + block[7];
pix+= stride;
block+= 8;
}
}
| false
|
FFmpeg
|
1acd7d594c15aa491729c837ad3519d3469e620a
|
static void FUNCC(pred8x8l_horizontal_add)(uint8_t *_pix, const int16_t *_block,
ptrdiff_t stride)
{
int i;
pixel *pix = (pixel*)_pix;
const dctcoef *block = (const dctcoef*)_block;
stride >>= sizeof(pixel)-1;
for(i=0; i<8; i++){
pixel v = pix[-1];
pix[0]= v += block[0];
pix[1]= v += block[1];
pix[2]= v += block[2];
pix[3]= v += block[3];
pix[4]= v += block[4];
pix[5]= v += block[5];
pix[6]= v += block[6];
pix[7]= v + block[7];
pix+= stride;
block+= 8;
}
}
|
{
"code": [],
"line_no": []
}
|
static void FUNC_0(pred8x8l_horizontal_add)(uint8_t *_pix, const int16_t *_block,
ptrdiff_t stride)
{
int VAR_0;
pixel *pix = (pixel*)_pix;
const dctcoef *VAR_1 = (const dctcoef*)_block;
stride >>= sizeof(pixel)-1;
for(VAR_0=0; VAR_0<8; VAR_0++){
pixel v = pix[-1];
pix[0]= v += VAR_1[0];
pix[1]= v += VAR_1[1];
pix[2]= v += VAR_1[2];
pix[3]= v += VAR_1[3];
pix[4]= v += VAR_1[4];
pix[5]= v += VAR_1[5];
pix[6]= v += VAR_1[6];
pix[7]= v + VAR_1[7];
pix+= stride;
VAR_1+= 8;
}
}
|
[
"static void FUNC_0(pred8x8l_horizontal_add)(uint8_t *_pix, const int16_t *_block,\nptrdiff_t stride)\n{",
"int VAR_0;",
"pixel *pix = (pixel*)_pix;",
"const dctcoef *VAR_1 = (const dctcoef*)_block;",
"stride >>= sizeof(pixel)-1;",
"for(VAR_0=0; VAR_0<8; VAR_0++){",
"pixel v = pix[-1];",
"pix[0]= v += VAR_1[0];",
"pix[1]= v += VAR_1[1];",
"pix[2]= v += VAR_1[2];",
"pix[3]= v += VAR_1[3];",
"pix[4]= v += VAR_1[4];",
"pix[5]= v += VAR_1[5];",
"pix[6]= v += VAR_1[6];",
"pix[7]= v + VAR_1[7];",
"pix+= stride;",
"VAR_1+= 8;",
"}",
"}"
] |
[
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
]
] |
12,860
|
static int vtenc_create_encoder(AVCodecContext *avctx,
CMVideoCodecType codec_type,
CFStringRef profile_level,
CFNumberRef gamma_level,
CFDictionaryRef enc_info,
CFDictionaryRef pixel_buffer_info,
VTCompressionSessionRef *session)
{
VTEncContext *vtctx = avctx->priv_data;
SInt32 bit_rate = avctx->bit_rate;
CFNumberRef bit_rate_num;
int status = VTCompressionSessionCreate(kCFAllocatorDefault,
avctx->width,
avctx->height,
codec_type,
enc_info,
pixel_buffer_info,
kCFAllocatorDefault,
vtenc_output_callback,
avctx,
session);
if (status || !vtctx->session) {
av_log(avctx, AV_LOG_ERROR, "Error: cannot create compression session: %d\n", status);
#if !TARGET_OS_IPHONE
if (!vtctx->allow_sw) {
av_log(avctx, AV_LOG_ERROR, "Try -allow_sw 1. The hardware encoder may be busy, or not supported.\n");
}
#endif
return AVERROR_EXTERNAL;
}
bit_rate_num = CFNumberCreate(kCFAllocatorDefault,
kCFNumberSInt32Type,
&bit_rate);
if (!bit_rate_num) return AVERROR(ENOMEM);
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_AverageBitRate,
bit_rate_num);
CFRelease(bit_rate_num);
if (status) {
av_log(avctx, AV_LOG_ERROR, "Error setting bitrate property: %d\n", status);
return AVERROR_EXTERNAL;
}
if (profile_level) {
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_ProfileLevel,
profile_level);
if (status) {
av_log(avctx, AV_LOG_ERROR, "Error setting profile/level property: %d\n", status);
return AVERROR_EXTERNAL;
}
}
if (avctx->gop_size > 0) {
CFNumberRef interval = CFNumberCreate(kCFAllocatorDefault,
kCFNumberIntType,
&avctx->gop_size);
if (!interval) {
return AVERROR(ENOMEM);
}
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_MaxKeyFrameInterval,
interval);
CFRelease(interval);
if (status) {
av_log(avctx, AV_LOG_ERROR, "Error setting 'max key-frame interval' property: %d\n", status);
return AVERROR_EXTERNAL;
}
}
if (vtctx->frames_before) {
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_MoreFramesBeforeStart,
kCFBooleanTrue);
if (status == kVTPropertyNotSupportedErr) {
av_log(avctx, AV_LOG_WARNING, "frames_before property is not supported on this device. Ignoring.\n");
} else if (status) {
av_log(avctx, AV_LOG_ERROR, "Error setting frames_before property: %d\n", status);
}
}
if (vtctx->frames_after) {
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_MoreFramesAfterEnd,
kCFBooleanTrue);
if (status == kVTPropertyNotSupportedErr) {
av_log(avctx, AV_LOG_WARNING, "frames_after property is not supported on this device. Ignoring.\n");
} else if (status) {
av_log(avctx, AV_LOG_ERROR, "Error setting frames_after property: %d\n", status);
}
}
if (avctx->sample_aspect_ratio.num != 0) {
CFNumberRef num;
CFNumberRef den;
CFMutableDictionaryRef par;
AVRational *avpar = &avctx->sample_aspect_ratio;
av_reduce(&avpar->num, &avpar->den,
avpar->num, avpar->den,
0xFFFFFFFF);
num = CFNumberCreate(kCFAllocatorDefault,
kCFNumberIntType,
&avpar->num);
den = CFNumberCreate(kCFAllocatorDefault,
kCFNumberIntType,
&avpar->den);
par = CFDictionaryCreateMutable(kCFAllocatorDefault,
2,
&kCFCopyStringDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
if (!par || !num || !den) {
if (par) CFRelease(par);
if (num) CFRelease(num);
if (den) CFRelease(den);
return AVERROR(ENOMEM);
}
CFDictionarySetValue(
par,
kCMFormatDescriptionKey_PixelAspectRatioHorizontalSpacing,
num);
CFDictionarySetValue(
par,
kCMFormatDescriptionKey_PixelAspectRatioVerticalSpacing,
den);
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_PixelAspectRatio,
par);
CFRelease(par);
CFRelease(num);
CFRelease(den);
if (status) {
av_log(avctx,
AV_LOG_ERROR,
"Error setting pixel aspect ratio to %d:%d: %d.\n",
avctx->sample_aspect_ratio.num,
avctx->sample_aspect_ratio.den,
status);
return AVERROR_EXTERNAL;
}
}
if (vtctx->transfer_function) {
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_TransferFunction,
vtctx->transfer_function);
if (status) {
av_log(avctx, AV_LOG_WARNING, "Could not set transfer function: %d\n", status);
}
}
if (vtctx->ycbcr_matrix) {
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_YCbCrMatrix,
vtctx->ycbcr_matrix);
if (status) {
av_log(avctx, AV_LOG_WARNING, "Could not set ycbcr matrix: %d\n", status);
}
}
if (vtctx->color_primaries) {
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_ColorPrimaries,
vtctx->color_primaries);
if (status) {
av_log(avctx, AV_LOG_WARNING, "Could not set color primaries: %d\n", status);
}
}
if (gamma_level) {
status = VTSessionSetProperty(vtctx->session,
kCVImageBufferGammaLevelKey,
gamma_level);
if (status) {
av_log(avctx, AV_LOG_WARNING, "Could not set gamma level: %d\n", status);
}
}
if (!vtctx->has_b_frames) {
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_AllowFrameReordering,
kCFBooleanFalse);
if (status) {
av_log(avctx, AV_LOG_ERROR, "Error setting 'allow frame reordering' property: %d\n", status);
return AVERROR_EXTERNAL;
}
}
if (vtctx->entropy != VT_ENTROPY_NOT_SET) {
CFStringRef entropy = vtctx->entropy == VT_CABAC ?
kVTH264EntropyMode_CABAC:
kVTH264EntropyMode_CAVLC;
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_H264EntropyMode,
entropy);
if (status) {
av_log(avctx, AV_LOG_ERROR, "Error setting entropy property: %d\n", status);
return AVERROR_EXTERNAL;
}
}
if (vtctx->realtime) {
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_RealTime,
kCFBooleanTrue);
if (status) {
av_log(avctx, AV_LOG_ERROR, "Error setting realtime property: %d\n", status);
}
}
status = VTCompressionSessionPrepareToEncodeFrames(vtctx->session);
if (status) {
av_log(avctx, AV_LOG_ERROR, "Error: cannot prepare encoder: %d\n", status);
return AVERROR_EXTERNAL;
}
return 0;
}
| false
|
FFmpeg
|
dcd3418a35aab7ef283b68ed9997ce4ac204094e
|
static int vtenc_create_encoder(AVCodecContext *avctx,
CMVideoCodecType codec_type,
CFStringRef profile_level,
CFNumberRef gamma_level,
CFDictionaryRef enc_info,
CFDictionaryRef pixel_buffer_info,
VTCompressionSessionRef *session)
{
VTEncContext *vtctx = avctx->priv_data;
SInt32 bit_rate = avctx->bit_rate;
CFNumberRef bit_rate_num;
int status = VTCompressionSessionCreate(kCFAllocatorDefault,
avctx->width,
avctx->height,
codec_type,
enc_info,
pixel_buffer_info,
kCFAllocatorDefault,
vtenc_output_callback,
avctx,
session);
if (status || !vtctx->session) {
av_log(avctx, AV_LOG_ERROR, "Error: cannot create compression session: %d\n", status);
#if !TARGET_OS_IPHONE
if (!vtctx->allow_sw) {
av_log(avctx, AV_LOG_ERROR, "Try -allow_sw 1. The hardware encoder may be busy, or not supported.\n");
}
#endif
return AVERROR_EXTERNAL;
}
bit_rate_num = CFNumberCreate(kCFAllocatorDefault,
kCFNumberSInt32Type,
&bit_rate);
if (!bit_rate_num) return AVERROR(ENOMEM);
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_AverageBitRate,
bit_rate_num);
CFRelease(bit_rate_num);
if (status) {
av_log(avctx, AV_LOG_ERROR, "Error setting bitrate property: %d\n", status);
return AVERROR_EXTERNAL;
}
if (profile_level) {
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_ProfileLevel,
profile_level);
if (status) {
av_log(avctx, AV_LOG_ERROR, "Error setting profile/level property: %d\n", status);
return AVERROR_EXTERNAL;
}
}
if (avctx->gop_size > 0) {
CFNumberRef interval = CFNumberCreate(kCFAllocatorDefault,
kCFNumberIntType,
&avctx->gop_size);
if (!interval) {
return AVERROR(ENOMEM);
}
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_MaxKeyFrameInterval,
interval);
CFRelease(interval);
if (status) {
av_log(avctx, AV_LOG_ERROR, "Error setting 'max key-frame interval' property: %d\n", status);
return AVERROR_EXTERNAL;
}
}
if (vtctx->frames_before) {
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_MoreFramesBeforeStart,
kCFBooleanTrue);
if (status == kVTPropertyNotSupportedErr) {
av_log(avctx, AV_LOG_WARNING, "frames_before property is not supported on this device. Ignoring.\n");
} else if (status) {
av_log(avctx, AV_LOG_ERROR, "Error setting frames_before property: %d\n", status);
}
}
if (vtctx->frames_after) {
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_MoreFramesAfterEnd,
kCFBooleanTrue);
if (status == kVTPropertyNotSupportedErr) {
av_log(avctx, AV_LOG_WARNING, "frames_after property is not supported on this device. Ignoring.\n");
} else if (status) {
av_log(avctx, AV_LOG_ERROR, "Error setting frames_after property: %d\n", status);
}
}
if (avctx->sample_aspect_ratio.num != 0) {
CFNumberRef num;
CFNumberRef den;
CFMutableDictionaryRef par;
AVRational *avpar = &avctx->sample_aspect_ratio;
av_reduce(&avpar->num, &avpar->den,
avpar->num, avpar->den,
0xFFFFFFFF);
num = CFNumberCreate(kCFAllocatorDefault,
kCFNumberIntType,
&avpar->num);
den = CFNumberCreate(kCFAllocatorDefault,
kCFNumberIntType,
&avpar->den);
par = CFDictionaryCreateMutable(kCFAllocatorDefault,
2,
&kCFCopyStringDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
if (!par || !num || !den) {
if (par) CFRelease(par);
if (num) CFRelease(num);
if (den) CFRelease(den);
return AVERROR(ENOMEM);
}
CFDictionarySetValue(
par,
kCMFormatDescriptionKey_PixelAspectRatioHorizontalSpacing,
num);
CFDictionarySetValue(
par,
kCMFormatDescriptionKey_PixelAspectRatioVerticalSpacing,
den);
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_PixelAspectRatio,
par);
CFRelease(par);
CFRelease(num);
CFRelease(den);
if (status) {
av_log(avctx,
AV_LOG_ERROR,
"Error setting pixel aspect ratio to %d:%d: %d.\n",
avctx->sample_aspect_ratio.num,
avctx->sample_aspect_ratio.den,
status);
return AVERROR_EXTERNAL;
}
}
if (vtctx->transfer_function) {
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_TransferFunction,
vtctx->transfer_function);
if (status) {
av_log(avctx, AV_LOG_WARNING, "Could not set transfer function: %d\n", status);
}
}
if (vtctx->ycbcr_matrix) {
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_YCbCrMatrix,
vtctx->ycbcr_matrix);
if (status) {
av_log(avctx, AV_LOG_WARNING, "Could not set ycbcr matrix: %d\n", status);
}
}
if (vtctx->color_primaries) {
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_ColorPrimaries,
vtctx->color_primaries);
if (status) {
av_log(avctx, AV_LOG_WARNING, "Could not set color primaries: %d\n", status);
}
}
if (gamma_level) {
status = VTSessionSetProperty(vtctx->session,
kCVImageBufferGammaLevelKey,
gamma_level);
if (status) {
av_log(avctx, AV_LOG_WARNING, "Could not set gamma level: %d\n", status);
}
}
if (!vtctx->has_b_frames) {
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_AllowFrameReordering,
kCFBooleanFalse);
if (status) {
av_log(avctx, AV_LOG_ERROR, "Error setting 'allow frame reordering' property: %d\n", status);
return AVERROR_EXTERNAL;
}
}
if (vtctx->entropy != VT_ENTROPY_NOT_SET) {
CFStringRef entropy = vtctx->entropy == VT_CABAC ?
kVTH264EntropyMode_CABAC:
kVTH264EntropyMode_CAVLC;
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_H264EntropyMode,
entropy);
if (status) {
av_log(avctx, AV_LOG_ERROR, "Error setting entropy property: %d\n", status);
return AVERROR_EXTERNAL;
}
}
if (vtctx->realtime) {
status = VTSessionSetProperty(vtctx->session,
kVTCompressionPropertyKey_RealTime,
kCFBooleanTrue);
if (status) {
av_log(avctx, AV_LOG_ERROR, "Error setting realtime property: %d\n", status);
}
}
status = VTCompressionSessionPrepareToEncodeFrames(vtctx->session);
if (status) {
av_log(avctx, AV_LOG_ERROR, "Error: cannot prepare encoder: %d\n", status);
return AVERROR_EXTERNAL;
}
return 0;
}
|
{
"code": [],
"line_no": []
}
|
static int FUNC_0(AVCodecContext *VAR_0,
CMVideoCodecType VAR_1,
CFStringRef VAR_2,
CFNumberRef VAR_3,
CFDictionaryRef VAR_4,
CFDictionaryRef VAR_5,
VTCompressionSessionRef *VAR_6)
{
VTEncContext *vtctx = VAR_0->priv_data;
SInt32 bit_rate = VAR_0->bit_rate;
CFNumberRef bit_rate_num;
int VAR_7 = VTCompressionSessionCreate(kCFAllocatorDefault,
VAR_0->width,
VAR_0->height,
VAR_1,
VAR_4,
VAR_5,
kCFAllocatorDefault,
vtenc_output_callback,
VAR_0,
VAR_6);
if (VAR_7 || !vtctx->VAR_6) {
av_log(VAR_0, AV_LOG_ERROR, "Error: cannot create compression VAR_6: %d\n", VAR_7);
#if !TARGET_OS_IPHONE
if (!vtctx->allow_sw) {
av_log(VAR_0, AV_LOG_ERROR, "Try -allow_sw 1. The hardware encoder may be busy, or not supported.\n");
}
#endif
return AVERROR_EXTERNAL;
}
bit_rate_num = CFNumberCreate(kCFAllocatorDefault,
kCFNumberSInt32Type,
&bit_rate);
if (!bit_rate_num) return AVERROR(ENOMEM);
VAR_7 = VTSessionSetProperty(vtctx->VAR_6,
kVTCompressionPropertyKey_AverageBitRate,
bit_rate_num);
CFRelease(bit_rate_num);
if (VAR_7) {
av_log(VAR_0, AV_LOG_ERROR, "Error setting bitrate property: %d\n", VAR_7);
return AVERROR_EXTERNAL;
}
if (VAR_2) {
VAR_7 = VTSessionSetProperty(vtctx->VAR_6,
kVTCompressionPropertyKey_ProfileLevel,
VAR_2);
if (VAR_7) {
av_log(VAR_0, AV_LOG_ERROR, "Error setting profile/level property: %d\n", VAR_7);
return AVERROR_EXTERNAL;
}
}
if (VAR_0->gop_size > 0) {
CFNumberRef interval = CFNumberCreate(kCFAllocatorDefault,
kCFNumberIntType,
&VAR_0->gop_size);
if (!interval) {
return AVERROR(ENOMEM);
}
VAR_7 = VTSessionSetProperty(vtctx->VAR_6,
kVTCompressionPropertyKey_MaxKeyFrameInterval,
interval);
CFRelease(interval);
if (VAR_7) {
av_log(VAR_0, AV_LOG_ERROR, "Error setting 'max key-frame interval' property: %d\n", VAR_7);
return AVERROR_EXTERNAL;
}
}
if (vtctx->frames_before) {
VAR_7 = VTSessionSetProperty(vtctx->VAR_6,
kVTCompressionPropertyKey_MoreFramesBeforeStart,
kCFBooleanTrue);
if (VAR_7 == kVTPropertyNotSupportedErr) {
av_log(VAR_0, AV_LOG_WARNING, "frames_before property is not supported on this device. Ignoring.\n");
} else if (VAR_7) {
av_log(VAR_0, AV_LOG_ERROR, "Error setting frames_before property: %d\n", VAR_7);
}
}
if (vtctx->frames_after) {
VAR_7 = VTSessionSetProperty(vtctx->VAR_6,
kVTCompressionPropertyKey_MoreFramesAfterEnd,
kCFBooleanTrue);
if (VAR_7 == kVTPropertyNotSupportedErr) {
av_log(VAR_0, AV_LOG_WARNING, "frames_after property is not supported on this device. Ignoring.\n");
} else if (VAR_7) {
av_log(VAR_0, AV_LOG_ERROR, "Error setting frames_after property: %d\n", VAR_7);
}
}
if (VAR_0->sample_aspect_ratio.num != 0) {
CFNumberRef num;
CFNumberRef den;
CFMutableDictionaryRef par;
AVRational *avpar = &VAR_0->sample_aspect_ratio;
av_reduce(&avpar->num, &avpar->den,
avpar->num, avpar->den,
0xFFFFFFFF);
num = CFNumberCreate(kCFAllocatorDefault,
kCFNumberIntType,
&avpar->num);
den = CFNumberCreate(kCFAllocatorDefault,
kCFNumberIntType,
&avpar->den);
par = CFDictionaryCreateMutable(kCFAllocatorDefault,
2,
&kCFCopyStringDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
if (!par || !num || !den) {
if (par) CFRelease(par);
if (num) CFRelease(num);
if (den) CFRelease(den);
return AVERROR(ENOMEM);
}
CFDictionarySetValue(
par,
kCMFormatDescriptionKey_PixelAspectRatioHorizontalSpacing,
num);
CFDictionarySetValue(
par,
kCMFormatDescriptionKey_PixelAspectRatioVerticalSpacing,
den);
VAR_7 = VTSessionSetProperty(vtctx->VAR_6,
kVTCompressionPropertyKey_PixelAspectRatio,
par);
CFRelease(par);
CFRelease(num);
CFRelease(den);
if (VAR_7) {
av_log(VAR_0,
AV_LOG_ERROR,
"Error setting pixel aspect ratio to %d:%d: %d.\n",
VAR_0->sample_aspect_ratio.num,
VAR_0->sample_aspect_ratio.den,
VAR_7);
return AVERROR_EXTERNAL;
}
}
if (vtctx->transfer_function) {
VAR_7 = VTSessionSetProperty(vtctx->VAR_6,
kVTCompressionPropertyKey_TransferFunction,
vtctx->transfer_function);
if (VAR_7) {
av_log(VAR_0, AV_LOG_WARNING, "Could not set transfer function: %d\n", VAR_7);
}
}
if (vtctx->ycbcr_matrix) {
VAR_7 = VTSessionSetProperty(vtctx->VAR_6,
kVTCompressionPropertyKey_YCbCrMatrix,
vtctx->ycbcr_matrix);
if (VAR_7) {
av_log(VAR_0, AV_LOG_WARNING, "Could not set ycbcr matrix: %d\n", VAR_7);
}
}
if (vtctx->color_primaries) {
VAR_7 = VTSessionSetProperty(vtctx->VAR_6,
kVTCompressionPropertyKey_ColorPrimaries,
vtctx->color_primaries);
if (VAR_7) {
av_log(VAR_0, AV_LOG_WARNING, "Could not set color primaries: %d\n", VAR_7);
}
}
if (VAR_3) {
VAR_7 = VTSessionSetProperty(vtctx->VAR_6,
kCVImageBufferGammaLevelKey,
VAR_3);
if (VAR_7) {
av_log(VAR_0, AV_LOG_WARNING, "Could not set gamma level: %d\n", VAR_7);
}
}
if (!vtctx->has_b_frames) {
VAR_7 = VTSessionSetProperty(vtctx->VAR_6,
kVTCompressionPropertyKey_AllowFrameReordering,
kCFBooleanFalse);
if (VAR_7) {
av_log(VAR_0, AV_LOG_ERROR, "Error setting 'allow frame reordering' property: %d\n", VAR_7);
return AVERROR_EXTERNAL;
}
}
if (vtctx->entropy != VT_ENTROPY_NOT_SET) {
CFStringRef entropy = vtctx->entropy == VT_CABAC ?
kVTH264EntropyMode_CABAC:
kVTH264EntropyMode_CAVLC;
VAR_7 = VTSessionSetProperty(vtctx->VAR_6,
kVTCompressionPropertyKey_H264EntropyMode,
entropy);
if (VAR_7) {
av_log(VAR_0, AV_LOG_ERROR, "Error setting entropy property: %d\n", VAR_7);
return AVERROR_EXTERNAL;
}
}
if (vtctx->realtime) {
VAR_7 = VTSessionSetProperty(vtctx->VAR_6,
kVTCompressionPropertyKey_RealTime,
kCFBooleanTrue);
if (VAR_7) {
av_log(VAR_0, AV_LOG_ERROR, "Error setting realtime property: %d\n", VAR_7);
}
}
VAR_7 = VTCompressionSessionPrepareToEncodeFrames(vtctx->VAR_6);
if (VAR_7) {
av_log(VAR_0, AV_LOG_ERROR, "Error: cannot prepare encoder: %d\n", VAR_7);
return AVERROR_EXTERNAL;
}
return 0;
}
|
[
"static int FUNC_0(AVCodecContext *VAR_0,\nCMVideoCodecType VAR_1,\nCFStringRef VAR_2,\nCFNumberRef VAR_3,\nCFDictionaryRef VAR_4,\nCFDictionaryRef VAR_5,\nVTCompressionSessionRef *VAR_6)\n{",
"VTEncContext *vtctx = VAR_0->priv_data;",
"SInt32 bit_rate = VAR_0->bit_rate;",
"CFNumberRef bit_rate_num;",
"int VAR_7 = VTCompressionSessionCreate(kCFAllocatorDefault,\nVAR_0->width,\nVAR_0->height,\nVAR_1,\nVAR_4,\nVAR_5,\nkCFAllocatorDefault,\nvtenc_output_callback,\nVAR_0,\nVAR_6);",
"if (VAR_7 || !vtctx->VAR_6) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error: cannot create compression VAR_6: %d\\n\", VAR_7);",
"#if !TARGET_OS_IPHONE\nif (!vtctx->allow_sw) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Try -allow_sw 1. The hardware encoder may be busy, or not supported.\\n\");",
"}",
"#endif\nreturn AVERROR_EXTERNAL;",
"}",
"bit_rate_num = CFNumberCreate(kCFAllocatorDefault,\nkCFNumberSInt32Type,\n&bit_rate);",
"if (!bit_rate_num) return AVERROR(ENOMEM);",
"VAR_7 = VTSessionSetProperty(vtctx->VAR_6,\nkVTCompressionPropertyKey_AverageBitRate,\nbit_rate_num);",
"CFRelease(bit_rate_num);",
"if (VAR_7) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error setting bitrate property: %d\\n\", VAR_7);",
"return AVERROR_EXTERNAL;",
"}",
"if (VAR_2) {",
"VAR_7 = VTSessionSetProperty(vtctx->VAR_6,\nkVTCompressionPropertyKey_ProfileLevel,\nVAR_2);",
"if (VAR_7) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error setting profile/level property: %d\\n\", VAR_7);",
"return AVERROR_EXTERNAL;",
"}",
"}",
"if (VAR_0->gop_size > 0) {",
"CFNumberRef interval = CFNumberCreate(kCFAllocatorDefault,\nkCFNumberIntType,\n&VAR_0->gop_size);",
"if (!interval) {",
"return AVERROR(ENOMEM);",
"}",
"VAR_7 = VTSessionSetProperty(vtctx->VAR_6,\nkVTCompressionPropertyKey_MaxKeyFrameInterval,\ninterval);",
"CFRelease(interval);",
"if (VAR_7) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error setting 'max key-frame interval' property: %d\\n\", VAR_7);",
"return AVERROR_EXTERNAL;",
"}",
"}",
"if (vtctx->frames_before) {",
"VAR_7 = VTSessionSetProperty(vtctx->VAR_6,\nkVTCompressionPropertyKey_MoreFramesBeforeStart,\nkCFBooleanTrue);",
"if (VAR_7 == kVTPropertyNotSupportedErr) {",
"av_log(VAR_0, AV_LOG_WARNING, \"frames_before property is not supported on this device. Ignoring.\\n\");",
"} else if (VAR_7) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error setting frames_before property: %d\\n\", VAR_7);",
"}",
"}",
"if (vtctx->frames_after) {",
"VAR_7 = VTSessionSetProperty(vtctx->VAR_6,\nkVTCompressionPropertyKey_MoreFramesAfterEnd,\nkCFBooleanTrue);",
"if (VAR_7 == kVTPropertyNotSupportedErr) {",
"av_log(VAR_0, AV_LOG_WARNING, \"frames_after property is not supported on this device. Ignoring.\\n\");",
"} else if (VAR_7) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error setting frames_after property: %d\\n\", VAR_7);",
"}",
"}",
"if (VAR_0->sample_aspect_ratio.num != 0) {",
"CFNumberRef num;",
"CFNumberRef den;",
"CFMutableDictionaryRef par;",
"AVRational *avpar = &VAR_0->sample_aspect_ratio;",
"av_reduce(&avpar->num, &avpar->den,\navpar->num, avpar->den,\n0xFFFFFFFF);",
"num = CFNumberCreate(kCFAllocatorDefault,\nkCFNumberIntType,\n&avpar->num);",
"den = CFNumberCreate(kCFAllocatorDefault,\nkCFNumberIntType,\n&avpar->den);",
"par = CFDictionaryCreateMutable(kCFAllocatorDefault,\n2,\n&kCFCopyStringDictionaryKeyCallBacks,\n&kCFTypeDictionaryValueCallBacks);",
"if (!par || !num || !den) {",
"if (par) CFRelease(par);",
"if (num) CFRelease(num);",
"if (den) CFRelease(den);",
"return AVERROR(ENOMEM);",
"}",
"CFDictionarySetValue(\npar,\nkCMFormatDescriptionKey_PixelAspectRatioHorizontalSpacing,\nnum);",
"CFDictionarySetValue(\npar,\nkCMFormatDescriptionKey_PixelAspectRatioVerticalSpacing,\nden);",
"VAR_7 = VTSessionSetProperty(vtctx->VAR_6,\nkVTCompressionPropertyKey_PixelAspectRatio,\npar);",
"CFRelease(par);",
"CFRelease(num);",
"CFRelease(den);",
"if (VAR_7) {",
"av_log(VAR_0,\nAV_LOG_ERROR,\n\"Error setting pixel aspect ratio to %d:%d: %d.\\n\",\nVAR_0->sample_aspect_ratio.num,\nVAR_0->sample_aspect_ratio.den,\nVAR_7);",
"return AVERROR_EXTERNAL;",
"}",
"}",
"if (vtctx->transfer_function) {",
"VAR_7 = VTSessionSetProperty(vtctx->VAR_6,\nkVTCompressionPropertyKey_TransferFunction,\nvtctx->transfer_function);",
"if (VAR_7) {",
"av_log(VAR_0, AV_LOG_WARNING, \"Could not set transfer function: %d\\n\", VAR_7);",
"}",
"}",
"if (vtctx->ycbcr_matrix) {",
"VAR_7 = VTSessionSetProperty(vtctx->VAR_6,\nkVTCompressionPropertyKey_YCbCrMatrix,\nvtctx->ycbcr_matrix);",
"if (VAR_7) {",
"av_log(VAR_0, AV_LOG_WARNING, \"Could not set ycbcr matrix: %d\\n\", VAR_7);",
"}",
"}",
"if (vtctx->color_primaries) {",
"VAR_7 = VTSessionSetProperty(vtctx->VAR_6,\nkVTCompressionPropertyKey_ColorPrimaries,\nvtctx->color_primaries);",
"if (VAR_7) {",
"av_log(VAR_0, AV_LOG_WARNING, \"Could not set color primaries: %d\\n\", VAR_7);",
"}",
"}",
"if (VAR_3) {",
"VAR_7 = VTSessionSetProperty(vtctx->VAR_6,\nkCVImageBufferGammaLevelKey,\nVAR_3);",
"if (VAR_7) {",
"av_log(VAR_0, AV_LOG_WARNING, \"Could not set gamma level: %d\\n\", VAR_7);",
"}",
"}",
"if (!vtctx->has_b_frames) {",
"VAR_7 = VTSessionSetProperty(vtctx->VAR_6,\nkVTCompressionPropertyKey_AllowFrameReordering,\nkCFBooleanFalse);",
"if (VAR_7) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error setting 'allow frame reordering' property: %d\\n\", VAR_7);",
"return AVERROR_EXTERNAL;",
"}",
"}",
"if (vtctx->entropy != VT_ENTROPY_NOT_SET) {",
"CFStringRef entropy = vtctx->entropy == VT_CABAC ?\nkVTH264EntropyMode_CABAC:\nkVTH264EntropyMode_CAVLC;",
"VAR_7 = VTSessionSetProperty(vtctx->VAR_6,\nkVTCompressionPropertyKey_H264EntropyMode,\nentropy);",
"if (VAR_7) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error setting entropy property: %d\\n\", VAR_7);",
"return AVERROR_EXTERNAL;",
"}",
"}",
"if (vtctx->realtime) {",
"VAR_7 = VTSessionSetProperty(vtctx->VAR_6,\nkVTCompressionPropertyKey_RealTime,\nkCFBooleanTrue);",
"if (VAR_7) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error setting realtime property: %d\\n\", VAR_7);",
"}",
"}",
"VAR_7 = VTCompressionSessionPrepareToEncodeFrames(vtctx->VAR_6);",
"if (VAR_7) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error: cannot prepare encoder: %d\\n\", VAR_7);",
"return AVERROR_EXTERNAL;",
"}",
"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
] |
[
[
1,
3,
5,
7,
9,
11,
13,
15
],
[
17
],
[
19
],
[
21
],
[
25,
27,
29,
31,
33,
35,
37,
39,
41,
43
],
[
47
],
[
49
],
[
53,
55
],
[
57
],
[
59
],
[
61,
65
],
[
67
],
[
71,
73,
75
],
[
77
],
[
81,
83,
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103,
105,
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123,
125,
127
],
[
129
],
[
131
],
[
133
],
[
137,
139,
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159
],
[
161,
163,
165
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
183
],
[
185,
187,
189
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
219,
221,
223
],
[
227,
229,
231
],
[
235,
237,
239
],
[
247,
249,
251,
253
],
[
257
],
[
259
],
[
261
],
[
263
],
[
267
],
[
269
],
[
273,
275,
277,
279
],
[
283,
285,
287,
289
],
[
293,
295,
297
],
[
301
],
[
303
],
[
305
],
[
309
],
[
311,
313,
315,
317,
319,
321
],
[
325
],
[
327
],
[
329
],
[
335
],
[
337,
339,
341
],
[
345
],
[
347
],
[
349
],
[
351
],
[
357
],
[
359,
361,
363
],
[
367
],
[
369
],
[
371
],
[
373
],
[
379
],
[
381,
383,
385
],
[
389
],
[
391
],
[
393
],
[
395
],
[
399
],
[
401,
403,
405
],
[
409
],
[
411
],
[
413
],
[
415
],
[
419
],
[
421,
423,
425
],
[
429
],
[
431
],
[
433
],
[
435
],
[
437
],
[
441
],
[
443,
445,
447
],
[
451,
453,
455
],
[
459
],
[
461
],
[
463
],
[
465
],
[
467
],
[
471
],
[
473,
475,
477
],
[
481
],
[
483
],
[
485
],
[
487
],
[
491
],
[
493
],
[
495
],
[
497
],
[
499
],
[
503
],
[
505
]
] |
12,861
|
static av_cold int libspeex_decode_init(AVCodecContext *avctx)
{
LibSpeexContext *s = avctx->priv_data;
const SpeexMode *mode;
// defaults in the case of a missing header
if (avctx->sample_rate <= 8000)
mode = &speex_nb_mode;
else if (avctx->sample_rate <= 16000)
mode = &speex_wb_mode;
else
mode = &speex_uwb_mode;
if (avctx->extradata_size >= 80)
s->header = speex_packet_to_header(avctx->extradata, avctx->extradata_size);
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
if (s->header) {
avctx->sample_rate = s->header->rate;
avctx->channels = s->header->nb_channels;
s->frame_size = s->header->frame_size;
mode = speex_lib_get_mode(s->header->mode);
if (!mode) {
av_log(avctx, AV_LOG_ERROR, "Unknown Speex mode %d", s->header->mode);
return AVERROR_INVALIDDATA;
}
} else
av_log(avctx, AV_LOG_INFO, "Missing Speex header, assuming defaults.\n");
if (avctx->channels > 2) {
av_log(avctx, AV_LOG_ERROR, "Only stereo and mono are supported.\n");
return AVERROR(EINVAL);
}
speex_bits_init(&s->bits);
s->dec_state = speex_decoder_init(mode);
if (!s->dec_state) {
av_log(avctx, AV_LOG_ERROR, "Error initializing libspeex decoder.\n");
return -1;
}
if (!s->header) {
speex_decoder_ctl(s->dec_state, SPEEX_GET_FRAME_SIZE, &s->frame_size);
}
if (avctx->channels == 2) {
SpeexCallback callback;
callback.callback_id = SPEEX_INBAND_STEREO;
callback.func = speex_std_stereo_request_handler;
callback.data = &s->stereo;
s->stereo = (SpeexStereoState)SPEEX_STEREO_STATE_INIT;
speex_decoder_ctl(s->dec_state, SPEEX_SET_HANDLER, &callback);
}
avcodec_get_frame_defaults(&s->frame);
avctx->coded_frame = &s->frame;
return 0;
}
| false
|
FFmpeg
|
3b061c5e10f78caaf3b2a45cf7a92e50d4d20bfb
|
static av_cold int libspeex_decode_init(AVCodecContext *avctx)
{
LibSpeexContext *s = avctx->priv_data;
const SpeexMode *mode;
if (avctx->sample_rate <= 8000)
mode = &speex_nb_mode;
else if (avctx->sample_rate <= 16000)
mode = &speex_wb_mode;
else
mode = &speex_uwb_mode;
if (avctx->extradata_size >= 80)
s->header = speex_packet_to_header(avctx->extradata, avctx->extradata_size);
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
if (s->header) {
avctx->sample_rate = s->header->rate;
avctx->channels = s->header->nb_channels;
s->frame_size = s->header->frame_size;
mode = speex_lib_get_mode(s->header->mode);
if (!mode) {
av_log(avctx, AV_LOG_ERROR, "Unknown Speex mode %d", s->header->mode);
return AVERROR_INVALIDDATA;
}
} else
av_log(avctx, AV_LOG_INFO, "Missing Speex header, assuming defaults.\n");
if (avctx->channels > 2) {
av_log(avctx, AV_LOG_ERROR, "Only stereo and mono are supported.\n");
return AVERROR(EINVAL);
}
speex_bits_init(&s->bits);
s->dec_state = speex_decoder_init(mode);
if (!s->dec_state) {
av_log(avctx, AV_LOG_ERROR, "Error initializing libspeex decoder.\n");
return -1;
}
if (!s->header) {
speex_decoder_ctl(s->dec_state, SPEEX_GET_FRAME_SIZE, &s->frame_size);
}
if (avctx->channels == 2) {
SpeexCallback callback;
callback.callback_id = SPEEX_INBAND_STEREO;
callback.func = speex_std_stereo_request_handler;
callback.data = &s->stereo;
s->stereo = (SpeexStereoState)SPEEX_STEREO_STATE_INIT;
speex_decoder_ctl(s->dec_state, SPEEX_SET_HANDLER, &callback);
}
avcodec_get_frame_defaults(&s->frame);
avctx->coded_frame = &s->frame;
return 0;
}
|
{
"code": [],
"line_no": []
}
|
static av_cold int FUNC_0(AVCodecContext *avctx)
{
LibSpeexContext *s = avctx->priv_data;
const SpeexMode *VAR_0;
if (avctx->sample_rate <= 8000)
VAR_0 = &speex_nb_mode;
else if (avctx->sample_rate <= 16000)
VAR_0 = &speex_wb_mode;
else
VAR_0 = &speex_uwb_mode;
if (avctx->extradata_size >= 80)
s->header = speex_packet_to_header(avctx->extradata, avctx->extradata_size);
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
if (s->header) {
avctx->sample_rate = s->header->rate;
avctx->channels = s->header->nb_channels;
s->frame_size = s->header->frame_size;
VAR_0 = speex_lib_get_mode(s->header->VAR_0);
if (!VAR_0) {
av_log(avctx, AV_LOG_ERROR, "Unknown Speex VAR_0 %d", s->header->VAR_0);
return AVERROR_INVALIDDATA;
}
} else
av_log(avctx, AV_LOG_INFO, "Missing Speex header, assuming defaults.\n");
if (avctx->channels > 2) {
av_log(avctx, AV_LOG_ERROR, "Only stereo and mono are supported.\n");
return AVERROR(EINVAL);
}
speex_bits_init(&s->bits);
s->dec_state = speex_decoder_init(VAR_0);
if (!s->dec_state) {
av_log(avctx, AV_LOG_ERROR, "Error initializing libspeex decoder.\n");
return -1;
}
if (!s->header) {
speex_decoder_ctl(s->dec_state, SPEEX_GET_FRAME_SIZE, &s->frame_size);
}
if (avctx->channels == 2) {
SpeexCallback callback;
callback.callback_id = SPEEX_INBAND_STEREO;
callback.func = speex_std_stereo_request_handler;
callback.data = &s->stereo;
s->stereo = (SpeexStereoState)SPEEX_STEREO_STATE_INIT;
speex_decoder_ctl(s->dec_state, SPEEX_SET_HANDLER, &callback);
}
avcodec_get_frame_defaults(&s->frame);
avctx->coded_frame = &s->frame;
return 0;
}
|
[
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"LibSpeexContext *s = avctx->priv_data;",
"const SpeexMode *VAR_0;",
"if (avctx->sample_rate <= 8000)\nVAR_0 = &speex_nb_mode;",
"else if (avctx->sample_rate <= 16000)\nVAR_0 = &speex_wb_mode;",
"else\nVAR_0 = &speex_uwb_mode;",
"if (avctx->extradata_size >= 80)\ns->header = speex_packet_to_header(avctx->extradata, avctx->extradata_size);",
"avctx->sample_fmt = AV_SAMPLE_FMT_S16;",
"if (s->header) {",
"avctx->sample_rate = s->header->rate;",
"avctx->channels = s->header->nb_channels;",
"s->frame_size = s->header->frame_size;",
"VAR_0 = speex_lib_get_mode(s->header->VAR_0);",
"if (!VAR_0) {",
"av_log(avctx, AV_LOG_ERROR, \"Unknown Speex VAR_0 %d\", s->header->VAR_0);",
"return AVERROR_INVALIDDATA;",
"}",
"} else",
"av_log(avctx, AV_LOG_INFO, \"Missing Speex header, assuming defaults.\\n\");",
"if (avctx->channels > 2) {",
"av_log(avctx, AV_LOG_ERROR, \"Only stereo and mono are supported.\\n\");",
"return AVERROR(EINVAL);",
"}",
"speex_bits_init(&s->bits);",
"s->dec_state = speex_decoder_init(VAR_0);",
"if (!s->dec_state) {",
"av_log(avctx, AV_LOG_ERROR, \"Error initializing libspeex decoder.\\n\");",
"return -1;",
"}",
"if (!s->header) {",
"speex_decoder_ctl(s->dec_state, SPEEX_GET_FRAME_SIZE, &s->frame_size);",
"}",
"if (avctx->channels == 2) {",
"SpeexCallback callback;",
"callback.callback_id = SPEEX_INBAND_STEREO;",
"callback.func = speex_std_stereo_request_handler;",
"callback.data = &s->stereo;",
"s->stereo = (SpeexStereoState)SPEEX_STEREO_STATE_INIT;",
"speex_decoder_ctl(s->dec_state, SPEEX_SET_HANDLER, &callback);",
"}",
"avcodec_get_frame_defaults(&s->frame);",
"avctx->coded_frame = &s->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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
13,
15
],
[
17,
19
],
[
21,
23
],
[
27,
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
117
],
[
119
]
] |
12,863
|
static int mpegts_set_stream_info(AVStream *st, PESContext *pes,
uint32_t stream_type, uint32_t prog_reg_desc)
{
int old_codec_type= st->codec->codec_type;
int old_codec_id = st->codec->codec_id;
if (old_codec_id != AV_CODEC_ID_NONE && avcodec_is_open(st->codec)) {
av_log(pes->stream, AV_LOG_DEBUG, "cannot set stream info, codec is open\n");
return 0;
}
avpriv_set_pts_info(st, 33, 1, 90000);
st->priv_data = pes;
st->codec->codec_type = AVMEDIA_TYPE_DATA;
st->codec->codec_id = AV_CODEC_ID_NONE;
st->need_parsing = AVSTREAM_PARSE_FULL;
pes->st = st;
pes->stream_type = stream_type;
av_log(pes->stream, AV_LOG_DEBUG,
"stream=%d stream_type=%x pid=%x prog_reg_desc=%.4s\n",
st->index, pes->stream_type, pes->pid, (char*)&prog_reg_desc);
st->codec->codec_tag = pes->stream_type;
mpegts_find_stream_type(st, pes->stream_type, ISO_types);
if ((prog_reg_desc == AV_RL32("HDMV") ||
prog_reg_desc == AV_RL32("HDPR")) &&
st->codec->codec_id == AV_CODEC_ID_NONE) {
mpegts_find_stream_type(st, pes->stream_type, HDMV_types);
if (pes->stream_type == 0x83) {
// HDMV TrueHD streams also contain an AC3 coded version of the
// audio track - add a second stream for this
AVStream *sub_st;
// priv_data cannot be shared between streams
PESContext *sub_pes = av_malloc(sizeof(*sub_pes));
if (!sub_pes)
return AVERROR(ENOMEM);
memcpy(sub_pes, pes, sizeof(*sub_pes));
sub_st = avformat_new_stream(pes->stream, NULL);
if (!sub_st) {
av_free(sub_pes);
return AVERROR(ENOMEM);
}
sub_st->id = pes->pid;
avpriv_set_pts_info(sub_st, 33, 1, 90000);
sub_st->priv_data = sub_pes;
sub_st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
sub_st->codec->codec_id = AV_CODEC_ID_AC3;
sub_st->need_parsing = AVSTREAM_PARSE_FULL;
sub_pes->sub_st = pes->sub_st = sub_st;
}
}
if (st->codec->codec_id == AV_CODEC_ID_NONE)
mpegts_find_stream_type(st, pes->stream_type, MISC_types);
if (st->codec->codec_id == AV_CODEC_ID_NONE){
st->codec->codec_id = old_codec_id;
st->codec->codec_type= old_codec_type;
}
return 0;
}
| false
|
FFmpeg
|
8897b5aa4c09906e4d43157fdcd7042f47fe15cf
|
static int mpegts_set_stream_info(AVStream *st, PESContext *pes,
uint32_t stream_type, uint32_t prog_reg_desc)
{
int old_codec_type= st->codec->codec_type;
int old_codec_id = st->codec->codec_id;
if (old_codec_id != AV_CODEC_ID_NONE && avcodec_is_open(st->codec)) {
av_log(pes->stream, AV_LOG_DEBUG, "cannot set stream info, codec is open\n");
return 0;
}
avpriv_set_pts_info(st, 33, 1, 90000);
st->priv_data = pes;
st->codec->codec_type = AVMEDIA_TYPE_DATA;
st->codec->codec_id = AV_CODEC_ID_NONE;
st->need_parsing = AVSTREAM_PARSE_FULL;
pes->st = st;
pes->stream_type = stream_type;
av_log(pes->stream, AV_LOG_DEBUG,
"stream=%d stream_type=%x pid=%x prog_reg_desc=%.4s\n",
st->index, pes->stream_type, pes->pid, (char*)&prog_reg_desc);
st->codec->codec_tag = pes->stream_type;
mpegts_find_stream_type(st, pes->stream_type, ISO_types);
if ((prog_reg_desc == AV_RL32("HDMV") ||
prog_reg_desc == AV_RL32("HDPR")) &&
st->codec->codec_id == AV_CODEC_ID_NONE) {
mpegts_find_stream_type(st, pes->stream_type, HDMV_types);
if (pes->stream_type == 0x83) {
AVStream *sub_st;
PESContext *sub_pes = av_malloc(sizeof(*sub_pes));
if (!sub_pes)
return AVERROR(ENOMEM);
memcpy(sub_pes, pes, sizeof(*sub_pes));
sub_st = avformat_new_stream(pes->stream, NULL);
if (!sub_st) {
av_free(sub_pes);
return AVERROR(ENOMEM);
}
sub_st->id = pes->pid;
avpriv_set_pts_info(sub_st, 33, 1, 90000);
sub_st->priv_data = sub_pes;
sub_st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
sub_st->codec->codec_id = AV_CODEC_ID_AC3;
sub_st->need_parsing = AVSTREAM_PARSE_FULL;
sub_pes->sub_st = pes->sub_st = sub_st;
}
}
if (st->codec->codec_id == AV_CODEC_ID_NONE)
mpegts_find_stream_type(st, pes->stream_type, MISC_types);
if (st->codec->codec_id == AV_CODEC_ID_NONE){
st->codec->codec_id = old_codec_id;
st->codec->codec_type= old_codec_type;
}
return 0;
}
|
{
"code": [],
"line_no": []
}
|
static int FUNC_0(AVStream *VAR_0, PESContext *VAR_1,
uint32_t VAR_2, uint32_t VAR_3)
{
int VAR_4= VAR_0->codec->codec_type;
int VAR_5 = VAR_0->codec->codec_id;
if (VAR_5 != AV_CODEC_ID_NONE && avcodec_is_open(VAR_0->codec)) {
av_log(VAR_1->stream, AV_LOG_DEBUG, "cannot set stream info, codec is open\n");
return 0;
}
avpriv_set_pts_info(VAR_0, 33, 1, 90000);
VAR_0->priv_data = VAR_1;
VAR_0->codec->codec_type = AVMEDIA_TYPE_DATA;
VAR_0->codec->codec_id = AV_CODEC_ID_NONE;
VAR_0->need_parsing = AVSTREAM_PARSE_FULL;
VAR_1->VAR_0 = VAR_0;
VAR_1->VAR_2 = VAR_2;
av_log(VAR_1->stream, AV_LOG_DEBUG,
"stream=%d VAR_2=%x pid=%x VAR_3=%.4s\n",
VAR_0->index, VAR_1->VAR_2, VAR_1->pid, (char*)&VAR_3);
VAR_0->codec->codec_tag = VAR_1->VAR_2;
mpegts_find_stream_type(VAR_0, VAR_1->VAR_2, ISO_types);
if ((VAR_3 == AV_RL32("HDMV") ||
VAR_3 == AV_RL32("HDPR")) &&
VAR_0->codec->codec_id == AV_CODEC_ID_NONE) {
mpegts_find_stream_type(VAR_0, VAR_1->VAR_2, HDMV_types);
if (VAR_1->VAR_2 == 0x83) {
AVStream *sub_st;
PESContext *sub_pes = av_malloc(sizeof(*sub_pes));
if (!sub_pes)
return AVERROR(ENOMEM);
memcpy(sub_pes, VAR_1, sizeof(*sub_pes));
sub_st = avformat_new_stream(VAR_1->stream, NULL);
if (!sub_st) {
av_free(sub_pes);
return AVERROR(ENOMEM);
}
sub_st->id = VAR_1->pid;
avpriv_set_pts_info(sub_st, 33, 1, 90000);
sub_st->priv_data = sub_pes;
sub_st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
sub_st->codec->codec_id = AV_CODEC_ID_AC3;
sub_st->need_parsing = AVSTREAM_PARSE_FULL;
sub_pes->sub_st = VAR_1->sub_st = sub_st;
}
}
if (VAR_0->codec->codec_id == AV_CODEC_ID_NONE)
mpegts_find_stream_type(VAR_0, VAR_1->VAR_2, MISC_types);
if (VAR_0->codec->codec_id == AV_CODEC_ID_NONE){
VAR_0->codec->codec_id = VAR_5;
VAR_0->codec->codec_type= VAR_4;
}
return 0;
}
|
[
"static int FUNC_0(AVStream *VAR_0, PESContext *VAR_1,\nuint32_t VAR_2, uint32_t VAR_3)\n{",
"int VAR_4= VAR_0->codec->codec_type;",
"int VAR_5 = VAR_0->codec->codec_id;",
"if (VAR_5 != AV_CODEC_ID_NONE && avcodec_is_open(VAR_0->codec)) {",
"av_log(VAR_1->stream, AV_LOG_DEBUG, \"cannot set stream info, codec is open\\n\");",
"return 0;",
"}",
"avpriv_set_pts_info(VAR_0, 33, 1, 90000);",
"VAR_0->priv_data = VAR_1;",
"VAR_0->codec->codec_type = AVMEDIA_TYPE_DATA;",
"VAR_0->codec->codec_id = AV_CODEC_ID_NONE;",
"VAR_0->need_parsing = AVSTREAM_PARSE_FULL;",
"VAR_1->VAR_0 = VAR_0;",
"VAR_1->VAR_2 = VAR_2;",
"av_log(VAR_1->stream, AV_LOG_DEBUG,\n\"stream=%d VAR_2=%x pid=%x VAR_3=%.4s\\n\",\nVAR_0->index, VAR_1->VAR_2, VAR_1->pid, (char*)&VAR_3);",
"VAR_0->codec->codec_tag = VAR_1->VAR_2;",
"mpegts_find_stream_type(VAR_0, VAR_1->VAR_2, ISO_types);",
"if ((VAR_3 == AV_RL32(\"HDMV\") ||\nVAR_3 == AV_RL32(\"HDPR\")) &&\nVAR_0->codec->codec_id == AV_CODEC_ID_NONE) {",
"mpegts_find_stream_type(VAR_0, VAR_1->VAR_2, HDMV_types);",
"if (VAR_1->VAR_2 == 0x83) {",
"AVStream *sub_st;",
"PESContext *sub_pes = av_malloc(sizeof(*sub_pes));",
"if (!sub_pes)\nreturn AVERROR(ENOMEM);",
"memcpy(sub_pes, VAR_1, sizeof(*sub_pes));",
"sub_st = avformat_new_stream(VAR_1->stream, NULL);",
"if (!sub_st) {",
"av_free(sub_pes);",
"return AVERROR(ENOMEM);",
"}",
"sub_st->id = VAR_1->pid;",
"avpriv_set_pts_info(sub_st, 33, 1, 90000);",
"sub_st->priv_data = sub_pes;",
"sub_st->codec->codec_type = AVMEDIA_TYPE_AUDIO;",
"sub_st->codec->codec_id = AV_CODEC_ID_AC3;",
"sub_st->need_parsing = AVSTREAM_PARSE_FULL;",
"sub_pes->sub_st = VAR_1->sub_st = sub_st;",
"}",
"}",
"if (VAR_0->codec->codec_id == AV_CODEC_ID_NONE)\nmpegts_find_stream_type(VAR_0, VAR_1->VAR_2, MISC_types);",
"if (VAR_0->codec->codec_id == AV_CODEC_ID_NONE){",
"VAR_0->codec->codec_id = VAR_5;",
"VAR_0->codec->codec_type= VAR_4;",
"}",
"return 0;",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39,
41,
43
],
[
47
],
[
51
],
[
53,
55,
57
],
[
59
],
[
61
],
[
67
],
[
71
],
[
73,
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
]
] |
12,864
|
void ff_cavs_init_top_lines(AVSContext *h) {
/* alloc top line of predictors */
h->top_qp = av_malloc( h->mb_width);
h->top_mv[0] = av_malloc((h->mb_width*2+1)*sizeof(cavs_vector));
h->top_mv[1] = av_malloc((h->mb_width*2+1)*sizeof(cavs_vector));
h->top_pred_Y = av_malloc( h->mb_width*2*sizeof(*h->top_pred_Y));
h->top_border_y = av_malloc((h->mb_width+1)*16);
h->top_border_u = av_malloc( h->mb_width * 10);
h->top_border_v = av_malloc( h->mb_width * 10);
/* alloc space for co-located MVs and types */
h->col_mv = av_malloc( h->mb_width*h->mb_height*4*sizeof(cavs_vector));
h->col_type_base = av_malloc(h->mb_width*h->mb_height);
h->block = av_mallocz(64*sizeof(DCTELEM));
}
| false
|
FFmpeg
|
280beebd399b2d2c9bf58438c2aa2a22a0a53282
|
void ff_cavs_init_top_lines(AVSContext *h) {
h->top_qp = av_malloc( h->mb_width);
h->top_mv[0] = av_malloc((h->mb_width*2+1)*sizeof(cavs_vector));
h->top_mv[1] = av_malloc((h->mb_width*2+1)*sizeof(cavs_vector));
h->top_pred_Y = av_malloc( h->mb_width*2*sizeof(*h->top_pred_Y));
h->top_border_y = av_malloc((h->mb_width+1)*16);
h->top_border_u = av_malloc( h->mb_width * 10);
h->top_border_v = av_malloc( h->mb_width * 10);
h->col_mv = av_malloc( h->mb_width*h->mb_height*4*sizeof(cavs_vector));
h->col_type_base = av_malloc(h->mb_width*h->mb_height);
h->block = av_mallocz(64*sizeof(DCTELEM));
}
|
{
"code": [],
"line_no": []
}
|
void FUNC_0(AVSContext *VAR_0) {
VAR_0->top_qp = av_malloc( VAR_0->mb_width);
VAR_0->top_mv[0] = av_malloc((VAR_0->mb_width*2+1)*sizeof(cavs_vector));
VAR_0->top_mv[1] = av_malloc((VAR_0->mb_width*2+1)*sizeof(cavs_vector));
VAR_0->top_pred_Y = av_malloc( VAR_0->mb_width*2*sizeof(*VAR_0->top_pred_Y));
VAR_0->top_border_y = av_malloc((VAR_0->mb_width+1)*16);
VAR_0->top_border_u = av_malloc( VAR_0->mb_width * 10);
VAR_0->top_border_v = av_malloc( VAR_0->mb_width * 10);
VAR_0->col_mv = av_malloc( VAR_0->mb_width*VAR_0->mb_height*4*sizeof(cavs_vector));
VAR_0->col_type_base = av_malloc(VAR_0->mb_width*VAR_0->mb_height);
VAR_0->block = av_mallocz(64*sizeof(DCTELEM));
}
|
[
"void FUNC_0(AVSContext *VAR_0) {",
"VAR_0->top_qp = av_malloc( VAR_0->mb_width);",
"VAR_0->top_mv[0] = av_malloc((VAR_0->mb_width*2+1)*sizeof(cavs_vector));",
"VAR_0->top_mv[1] = av_malloc((VAR_0->mb_width*2+1)*sizeof(cavs_vector));",
"VAR_0->top_pred_Y = av_malloc( VAR_0->mb_width*2*sizeof(*VAR_0->top_pred_Y));",
"VAR_0->top_border_y = av_malloc((VAR_0->mb_width+1)*16);",
"VAR_0->top_border_u = av_malloc( VAR_0->mb_width * 10);",
"VAR_0->top_border_v = av_malloc( VAR_0->mb_width * 10);",
"VAR_0->col_mv = av_malloc( VAR_0->mb_width*VAR_0->mb_height*4*sizeof(cavs_vector));",
"VAR_0->col_type_base = av_malloc(VAR_0->mb_width*VAR_0->mb_height);",
"VAR_0->block = av_mallocz(64*sizeof(DCTELEM));",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
12,865
|
static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
{
const char *rn = "invalid";
if (sel != 0)
check_insn(env, ctx, ISA_MIPS64);
switch (reg) {
case 0:
switch (sel) {
case 0:
gen_op_mfc0_index();
rn = "Index";
break;
case 1:
check_mips_mt(env, ctx);
gen_op_mfc0_mvpcontrol();
rn = "MVPControl";
break;
case 2:
check_mips_mt(env, ctx);
gen_op_mfc0_mvpconf0();
rn = "MVPConf0";
break;
case 3:
check_mips_mt(env, ctx);
gen_op_mfc0_mvpconf1();
rn = "MVPConf1";
break;
default:
goto die;
}
break;
case 1:
switch (sel) {
case 0:
gen_op_mfc0_random();
rn = "Random";
break;
case 1:
check_mips_mt(env, ctx);
gen_op_mfc0_vpecontrol();
rn = "VPEControl";
break;
case 2:
check_mips_mt(env, ctx);
gen_op_mfc0_vpeconf0();
rn = "VPEConf0";
break;
case 3:
check_mips_mt(env, ctx);
gen_op_mfc0_vpeconf1();
rn = "VPEConf1";
break;
case 4:
check_mips_mt(env, ctx);
gen_op_dmfc0_yqmask();
rn = "YQMask";
break;
case 5:
check_mips_mt(env, ctx);
gen_op_dmfc0_vpeschedule();
rn = "VPESchedule";
break;
case 6:
check_mips_mt(env, ctx);
gen_op_dmfc0_vpeschefback();
rn = "VPEScheFBack";
break;
case 7:
check_mips_mt(env, ctx);
gen_op_mfc0_vpeopt();
rn = "VPEOpt";
break;
default:
goto die;
}
break;
case 2:
switch (sel) {
case 0:
gen_op_dmfc0_entrylo0();
rn = "EntryLo0";
break;
case 1:
check_mips_mt(env, ctx);
gen_op_mfc0_tcstatus();
rn = "TCStatus";
break;
case 2:
check_mips_mt(env, ctx);
gen_op_mfc0_tcbind();
rn = "TCBind";
break;
case 3:
check_mips_mt(env, ctx);
gen_op_dmfc0_tcrestart();
rn = "TCRestart";
break;
case 4:
check_mips_mt(env, ctx);
gen_op_dmfc0_tchalt();
rn = "TCHalt";
break;
case 5:
check_mips_mt(env, ctx);
gen_op_dmfc0_tccontext();
rn = "TCContext";
break;
case 6:
check_mips_mt(env, ctx);
gen_op_dmfc0_tcschedule();
rn = "TCSchedule";
break;
case 7:
check_mips_mt(env, ctx);
gen_op_dmfc0_tcschefback();
rn = "TCScheFBack";
break;
default:
goto die;
}
break;
case 3:
switch (sel) {
case 0:
gen_op_dmfc0_entrylo1();
rn = "EntryLo1";
break;
default:
goto die;
}
break;
case 4:
switch (sel) {
case 0:
gen_op_dmfc0_context();
rn = "Context";
break;
case 1:
// gen_op_dmfc0_contextconfig(); /* SmartMIPS ASE */
rn = "ContextConfig";
// break;
default:
goto die;
}
break;
case 5:
switch (sel) {
case 0:
gen_op_mfc0_pagemask();
rn = "PageMask";
break;
case 1:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_pagegrain();
rn = "PageGrain";
break;
default:
goto die;
}
break;
case 6:
switch (sel) {
case 0:
gen_op_mfc0_wired();
rn = "Wired";
break;
case 1:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_srsconf0();
rn = "SRSConf0";
break;
case 2:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_srsconf1();
rn = "SRSConf1";
break;
case 3:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_srsconf2();
rn = "SRSConf2";
break;
case 4:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_srsconf3();
rn = "SRSConf3";
break;
case 5:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_srsconf4();
rn = "SRSConf4";
break;
default:
goto die;
}
break;
case 7:
switch (sel) {
case 0:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_hwrena();
rn = "HWREna";
break;
default:
goto die;
}
break;
case 8:
switch (sel) {
case 0:
gen_op_dmfc0_badvaddr();
rn = "BadVaddr";
break;
default:
goto die;
}
break;
case 9:
switch (sel) {
case 0:
gen_op_mfc0_count();
rn = "Count";
break;
/* 6,7 are implementation dependent */
default:
goto die;
}
break;
case 10:
switch (sel) {
case 0:
gen_op_dmfc0_entryhi();
rn = "EntryHi";
break;
default:
goto die;
}
break;
case 11:
switch (sel) {
case 0:
gen_op_mfc0_compare();
rn = "Compare";
break;
/* 6,7 are implementation dependent */
default:
goto die;
}
break;
case 12:
switch (sel) {
case 0:
gen_op_mfc0_status();
rn = "Status";
break;
case 1:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_intctl();
rn = "IntCtl";
break;
case 2:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_srsctl();
rn = "SRSCtl";
break;
case 3:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_srsmap();
rn = "SRSMap";
break;
default:
goto die;
}
break;
case 13:
switch (sel) {
case 0:
gen_op_mfc0_cause();
rn = "Cause";
break;
default:
goto die;
}
break;
case 14:
switch (sel) {
case 0:
gen_op_dmfc0_epc();
rn = "EPC";
break;
default:
goto die;
}
break;
case 15:
switch (sel) {
case 0:
gen_op_mfc0_prid();
rn = "PRid";
break;
case 1:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_ebase();
rn = "EBase";
break;
default:
goto die;
}
break;
case 16:
switch (sel) {
case 0:
gen_op_mfc0_config0();
rn = "Config";
break;
case 1:
gen_op_mfc0_config1();
rn = "Config1";
break;
case 2:
gen_op_mfc0_config2();
rn = "Config2";
break;
case 3:
gen_op_mfc0_config3();
rn = "Config3";
break;
/* 6,7 are implementation dependent */
default:
goto die;
}
break;
case 17:
switch (sel) {
case 0:
gen_op_dmfc0_lladdr();
rn = "LLAddr";
break;
default:
goto die;
}
break;
case 18:
switch (sel) {
case 0 ... 7:
gen_op_dmfc0_watchlo(sel);
rn = "WatchLo";
break;
default:
goto die;
}
break;
case 19:
switch (sel) {
case 0 ... 7:
gen_op_mfc0_watchhi(sel);
rn = "WatchHi";
break;
default:
goto die;
}
break;
case 20:
switch (sel) {
case 0:
check_insn(env, ctx, ISA_MIPS3);
gen_op_dmfc0_xcontext();
rn = "XContext";
break;
default:
goto die;
}
break;
case 21:
/* Officially reserved, but sel 0 is used for R1x000 framemask */
switch (sel) {
case 0:
gen_op_mfc0_framemask();
rn = "Framemask";
break;
default:
goto die;
}
break;
case 22:
/* ignored */
rn = "'Diagnostic"; /* implementation dependent */
break;
case 23:
switch (sel) {
case 0:
gen_op_mfc0_debug(); /* EJTAG support */
rn = "Debug";
break;
case 1:
// gen_op_dmfc0_tracecontrol(); /* PDtrace support */
rn = "TraceControl";
// break;
case 2:
// gen_op_dmfc0_tracecontrol2(); /* PDtrace support */
rn = "TraceControl2";
// break;
case 3:
// gen_op_dmfc0_usertracedata(); /* PDtrace support */
rn = "UserTraceData";
// break;
case 4:
// gen_op_dmfc0_debug(); /* PDtrace support */
rn = "TraceBPC";
// break;
default:
goto die;
}
break;
case 24:
switch (sel) {
case 0:
gen_op_dmfc0_depc(); /* EJTAG support */
rn = "DEPC";
break;
default:
goto die;
}
break;
case 25:
switch (sel) {
case 0:
gen_op_mfc0_performance0();
rn = "Performance0";
break;
case 1:
// gen_op_dmfc0_performance1();
rn = "Performance1";
// break;
case 2:
// gen_op_dmfc0_performance2();
rn = "Performance2";
// break;
case 3:
// gen_op_dmfc0_performance3();
rn = "Performance3";
// break;
case 4:
// gen_op_dmfc0_performance4();
rn = "Performance4";
// break;
case 5:
// gen_op_dmfc0_performance5();
rn = "Performance5";
// break;
case 6:
// gen_op_dmfc0_performance6();
rn = "Performance6";
// break;
case 7:
// gen_op_dmfc0_performance7();
rn = "Performance7";
// break;
default:
goto die;
}
break;
case 26:
rn = "ECC";
break;
case 27:
switch (sel) {
/* ignored */
case 0 ... 3:
rn = "CacheErr";
break;
default:
goto die;
}
break;
case 28:
switch (sel) {
case 0:
case 2:
case 4:
case 6:
gen_op_mfc0_taglo();
rn = "TagLo";
break;
case 1:
case 3:
case 5:
case 7:
gen_op_mfc0_datalo();
rn = "DataLo";
break;
default:
goto die;
}
break;
case 29:
switch (sel) {
case 0:
case 2:
case 4:
case 6:
gen_op_mfc0_taghi();
rn = "TagHi";
break;
case 1:
case 3:
case 5:
case 7:
gen_op_mfc0_datahi();
rn = "DataHi";
break;
default:
goto die;
}
break;
case 30:
switch (sel) {
case 0:
gen_op_dmfc0_errorepc();
rn = "ErrorEPC";
break;
default:
goto die;
}
break;
case 31:
switch (sel) {
case 0:
gen_op_mfc0_desave(); /* EJTAG support */
rn = "DESAVE";
break;
default:
goto die;
}
break;
default:
goto die;
}
#if defined MIPS_DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "dmfc0 %s (reg %d sel %d)\n",
rn, reg, sel);
}
#endif
return;
die:
#if defined MIPS_DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "dmfc0 %s (reg %d sel %d)\n",
rn, reg, sel);
}
#endif
generate_exception(ctx, EXCP_RI);
}
| false
|
qemu
|
7385ac0ba2456159a52b9b2cbb5f6c71921d0c23
|
static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
{
const char *rn = "invalid";
if (sel != 0)
check_insn(env, ctx, ISA_MIPS64);
switch (reg) {
case 0:
switch (sel) {
case 0:
gen_op_mfc0_index();
rn = "Index";
break;
case 1:
check_mips_mt(env, ctx);
gen_op_mfc0_mvpcontrol();
rn = "MVPControl";
break;
case 2:
check_mips_mt(env, ctx);
gen_op_mfc0_mvpconf0();
rn = "MVPConf0";
break;
case 3:
check_mips_mt(env, ctx);
gen_op_mfc0_mvpconf1();
rn = "MVPConf1";
break;
default:
goto die;
}
break;
case 1:
switch (sel) {
case 0:
gen_op_mfc0_random();
rn = "Random";
break;
case 1:
check_mips_mt(env, ctx);
gen_op_mfc0_vpecontrol();
rn = "VPEControl";
break;
case 2:
check_mips_mt(env, ctx);
gen_op_mfc0_vpeconf0();
rn = "VPEConf0";
break;
case 3:
check_mips_mt(env, ctx);
gen_op_mfc0_vpeconf1();
rn = "VPEConf1";
break;
case 4:
check_mips_mt(env, ctx);
gen_op_dmfc0_yqmask();
rn = "YQMask";
break;
case 5:
check_mips_mt(env, ctx);
gen_op_dmfc0_vpeschedule();
rn = "VPESchedule";
break;
case 6:
check_mips_mt(env, ctx);
gen_op_dmfc0_vpeschefback();
rn = "VPEScheFBack";
break;
case 7:
check_mips_mt(env, ctx);
gen_op_mfc0_vpeopt();
rn = "VPEOpt";
break;
default:
goto die;
}
break;
case 2:
switch (sel) {
case 0:
gen_op_dmfc0_entrylo0();
rn = "EntryLo0";
break;
case 1:
check_mips_mt(env, ctx);
gen_op_mfc0_tcstatus();
rn = "TCStatus";
break;
case 2:
check_mips_mt(env, ctx);
gen_op_mfc0_tcbind();
rn = "TCBind";
break;
case 3:
check_mips_mt(env, ctx);
gen_op_dmfc0_tcrestart();
rn = "TCRestart";
break;
case 4:
check_mips_mt(env, ctx);
gen_op_dmfc0_tchalt();
rn = "TCHalt";
break;
case 5:
check_mips_mt(env, ctx);
gen_op_dmfc0_tccontext();
rn = "TCContext";
break;
case 6:
check_mips_mt(env, ctx);
gen_op_dmfc0_tcschedule();
rn = "TCSchedule";
break;
case 7:
check_mips_mt(env, ctx);
gen_op_dmfc0_tcschefback();
rn = "TCScheFBack";
break;
default:
goto die;
}
break;
case 3:
switch (sel) {
case 0:
gen_op_dmfc0_entrylo1();
rn = "EntryLo1";
break;
default:
goto die;
}
break;
case 4:
switch (sel) {
case 0:
gen_op_dmfc0_context();
rn = "Context";
break;
case 1:
rn = "ContextConfig";
default:
goto die;
}
break;
case 5:
switch (sel) {
case 0:
gen_op_mfc0_pagemask();
rn = "PageMask";
break;
case 1:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_pagegrain();
rn = "PageGrain";
break;
default:
goto die;
}
break;
case 6:
switch (sel) {
case 0:
gen_op_mfc0_wired();
rn = "Wired";
break;
case 1:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_srsconf0();
rn = "SRSConf0";
break;
case 2:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_srsconf1();
rn = "SRSConf1";
break;
case 3:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_srsconf2();
rn = "SRSConf2";
break;
case 4:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_srsconf3();
rn = "SRSConf3";
break;
case 5:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_srsconf4();
rn = "SRSConf4";
break;
default:
goto die;
}
break;
case 7:
switch (sel) {
case 0:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_hwrena();
rn = "HWREna";
break;
default:
goto die;
}
break;
case 8:
switch (sel) {
case 0:
gen_op_dmfc0_badvaddr();
rn = "BadVaddr";
break;
default:
goto die;
}
break;
case 9:
switch (sel) {
case 0:
gen_op_mfc0_count();
rn = "Count";
break;
default:
goto die;
}
break;
case 10:
switch (sel) {
case 0:
gen_op_dmfc0_entryhi();
rn = "EntryHi";
break;
default:
goto die;
}
break;
case 11:
switch (sel) {
case 0:
gen_op_mfc0_compare();
rn = "Compare";
break;
default:
goto die;
}
break;
case 12:
switch (sel) {
case 0:
gen_op_mfc0_status();
rn = "Status";
break;
case 1:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_intctl();
rn = "IntCtl";
break;
case 2:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_srsctl();
rn = "SRSCtl";
break;
case 3:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_srsmap();
rn = "SRSMap";
break;
default:
goto die;
}
break;
case 13:
switch (sel) {
case 0:
gen_op_mfc0_cause();
rn = "Cause";
break;
default:
goto die;
}
break;
case 14:
switch (sel) {
case 0:
gen_op_dmfc0_epc();
rn = "EPC";
break;
default:
goto die;
}
break;
case 15:
switch (sel) {
case 0:
gen_op_mfc0_prid();
rn = "PRid";
break;
case 1:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_ebase();
rn = "EBase";
break;
default:
goto die;
}
break;
case 16:
switch (sel) {
case 0:
gen_op_mfc0_config0();
rn = "Config";
break;
case 1:
gen_op_mfc0_config1();
rn = "Config1";
break;
case 2:
gen_op_mfc0_config2();
rn = "Config2";
break;
case 3:
gen_op_mfc0_config3();
rn = "Config3";
break;
default:
goto die;
}
break;
case 17:
switch (sel) {
case 0:
gen_op_dmfc0_lladdr();
rn = "LLAddr";
break;
default:
goto die;
}
break;
case 18:
switch (sel) {
case 0 ... 7:
gen_op_dmfc0_watchlo(sel);
rn = "WatchLo";
break;
default:
goto die;
}
break;
case 19:
switch (sel) {
case 0 ... 7:
gen_op_mfc0_watchhi(sel);
rn = "WatchHi";
break;
default:
goto die;
}
break;
case 20:
switch (sel) {
case 0:
check_insn(env, ctx, ISA_MIPS3);
gen_op_dmfc0_xcontext();
rn = "XContext";
break;
default:
goto die;
}
break;
case 21:
switch (sel) {
case 0:
gen_op_mfc0_framemask();
rn = "Framemask";
break;
default:
goto die;
}
break;
case 22:
rn = "'Diagnostic";
break;
case 23:
switch (sel) {
case 0:
gen_op_mfc0_debug();
rn = "Debug";
break;
case 1:
rn = "TraceControl";
case 2:
rn = "TraceControl2";
case 3:
rn = "UserTraceData";
case 4:
rn = "TraceBPC";
default:
goto die;
}
break;
case 24:
switch (sel) {
case 0:
gen_op_dmfc0_depc();
rn = "DEPC";
break;
default:
goto die;
}
break;
case 25:
switch (sel) {
case 0:
gen_op_mfc0_performance0();
rn = "Performance0";
break;
case 1:
rn = "Performance1";
case 2:
rn = "Performance2";
case 3:
rn = "Performance3";
case 4:
rn = "Performance4";
case 5:
rn = "Performance5";
case 6:
rn = "Performance6";
case 7:
rn = "Performance7";
default:
goto die;
}
break;
case 26:
rn = "ECC";
break;
case 27:
switch (sel) {
case 0 ... 3:
rn = "CacheErr";
break;
default:
goto die;
}
break;
case 28:
switch (sel) {
case 0:
case 2:
case 4:
case 6:
gen_op_mfc0_taglo();
rn = "TagLo";
break;
case 1:
case 3:
case 5:
case 7:
gen_op_mfc0_datalo();
rn = "DataLo";
break;
default:
goto die;
}
break;
case 29:
switch (sel) {
case 0:
case 2:
case 4:
case 6:
gen_op_mfc0_taghi();
rn = "TagHi";
break;
case 1:
case 3:
case 5:
case 7:
gen_op_mfc0_datahi();
rn = "DataHi";
break;
default:
goto die;
}
break;
case 30:
switch (sel) {
case 0:
gen_op_dmfc0_errorepc();
rn = "ErrorEPC";
break;
default:
goto die;
}
break;
case 31:
switch (sel) {
case 0:
gen_op_mfc0_desave();
rn = "DESAVE";
break;
default:
goto die;
}
break;
default:
goto die;
}
#if defined MIPS_DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "dmfc0 %s (reg %d sel %d)\n",
rn, reg, sel);
}
#endif
return;
die:
#if defined MIPS_DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "dmfc0 %s (reg %d sel %d)\n",
rn, reg, sel);
}
#endif
generate_exception(ctx, EXCP_RI);
}
|
{
"code": [],
"line_no": []
}
|
static void FUNC_0 (CPUState *VAR_0, DisasContext *VAR_1, int VAR_2, int VAR_3)
{
const char *VAR_4 = "invalid";
if (VAR_3 != 0)
check_insn(VAR_0, VAR_1, ISA_MIPS64);
switch (VAR_2) {
case 0:
switch (VAR_3) {
case 0:
gen_op_mfc0_index();
VAR_4 = "Index";
break;
case 1:
check_mips_mt(VAR_0, VAR_1);
gen_op_mfc0_mvpcontrol();
VAR_4 = "MVPControl";
break;
case 2:
check_mips_mt(VAR_0, VAR_1);
gen_op_mfc0_mvpconf0();
VAR_4 = "MVPConf0";
break;
case 3:
check_mips_mt(VAR_0, VAR_1);
gen_op_mfc0_mvpconf1();
VAR_4 = "MVPConf1";
break;
default:
goto die;
}
break;
case 1:
switch (VAR_3) {
case 0:
gen_op_mfc0_random();
VAR_4 = "Random";
break;
case 1:
check_mips_mt(VAR_0, VAR_1);
gen_op_mfc0_vpecontrol();
VAR_4 = "VPEControl";
break;
case 2:
check_mips_mt(VAR_0, VAR_1);
gen_op_mfc0_vpeconf0();
VAR_4 = "VPEConf0";
break;
case 3:
check_mips_mt(VAR_0, VAR_1);
gen_op_mfc0_vpeconf1();
VAR_4 = "VPEConf1";
break;
case 4:
check_mips_mt(VAR_0, VAR_1);
gen_op_dmfc0_yqmask();
VAR_4 = "YQMask";
break;
case 5:
check_mips_mt(VAR_0, VAR_1);
gen_op_dmfc0_vpeschedule();
VAR_4 = "VPESchedule";
break;
case 6:
check_mips_mt(VAR_0, VAR_1);
gen_op_dmfc0_vpeschefback();
VAR_4 = "VPEScheFBack";
break;
case 7:
check_mips_mt(VAR_0, VAR_1);
gen_op_mfc0_vpeopt();
VAR_4 = "VPEOpt";
break;
default:
goto die;
}
break;
case 2:
switch (VAR_3) {
case 0:
gen_op_dmfc0_entrylo0();
VAR_4 = "EntryLo0";
break;
case 1:
check_mips_mt(VAR_0, VAR_1);
gen_op_mfc0_tcstatus();
VAR_4 = "TCStatus";
break;
case 2:
check_mips_mt(VAR_0, VAR_1);
gen_op_mfc0_tcbind();
VAR_4 = "TCBind";
break;
case 3:
check_mips_mt(VAR_0, VAR_1);
gen_op_dmfc0_tcrestart();
VAR_4 = "TCRestart";
break;
case 4:
check_mips_mt(VAR_0, VAR_1);
gen_op_dmfc0_tchalt();
VAR_4 = "TCHalt";
break;
case 5:
check_mips_mt(VAR_0, VAR_1);
gen_op_dmfc0_tccontext();
VAR_4 = "TCContext";
break;
case 6:
check_mips_mt(VAR_0, VAR_1);
gen_op_dmfc0_tcschedule();
VAR_4 = "TCSchedule";
break;
case 7:
check_mips_mt(VAR_0, VAR_1);
gen_op_dmfc0_tcschefback();
VAR_4 = "TCScheFBack";
break;
default:
goto die;
}
break;
case 3:
switch (VAR_3) {
case 0:
gen_op_dmfc0_entrylo1();
VAR_4 = "EntryLo1";
break;
default:
goto die;
}
break;
case 4:
switch (VAR_3) {
case 0:
gen_op_dmfc0_context();
VAR_4 = "Context";
break;
case 1:
VAR_4 = "ContextConfig";
default:
goto die;
}
break;
case 5:
switch (VAR_3) {
case 0:
gen_op_mfc0_pagemask();
VAR_4 = "PageMask";
break;
case 1:
check_insn(VAR_0, VAR_1, ISA_MIPS32R2);
gen_op_mfc0_pagegrain();
VAR_4 = "PageGrain";
break;
default:
goto die;
}
break;
case 6:
switch (VAR_3) {
case 0:
gen_op_mfc0_wired();
VAR_4 = "Wired";
break;
case 1:
check_insn(VAR_0, VAR_1, ISA_MIPS32R2);
gen_op_mfc0_srsconf0();
VAR_4 = "SRSConf0";
break;
case 2:
check_insn(VAR_0, VAR_1, ISA_MIPS32R2);
gen_op_mfc0_srsconf1();
VAR_4 = "SRSConf1";
break;
case 3:
check_insn(VAR_0, VAR_1, ISA_MIPS32R2);
gen_op_mfc0_srsconf2();
VAR_4 = "SRSConf2";
break;
case 4:
check_insn(VAR_0, VAR_1, ISA_MIPS32R2);
gen_op_mfc0_srsconf3();
VAR_4 = "SRSConf3";
break;
case 5:
check_insn(VAR_0, VAR_1, ISA_MIPS32R2);
gen_op_mfc0_srsconf4();
VAR_4 = "SRSConf4";
break;
default:
goto die;
}
break;
case 7:
switch (VAR_3) {
case 0:
check_insn(VAR_0, VAR_1, ISA_MIPS32R2);
gen_op_mfc0_hwrena();
VAR_4 = "HWREna";
break;
default:
goto die;
}
break;
case 8:
switch (VAR_3) {
case 0:
gen_op_dmfc0_badvaddr();
VAR_4 = "BadVaddr";
break;
default:
goto die;
}
break;
case 9:
switch (VAR_3) {
case 0:
gen_op_mfc0_count();
VAR_4 = "Count";
break;
default:
goto die;
}
break;
case 10:
switch (VAR_3) {
case 0:
gen_op_dmfc0_entryhi();
VAR_4 = "EntryHi";
break;
default:
goto die;
}
break;
case 11:
switch (VAR_3) {
case 0:
gen_op_mfc0_compare();
VAR_4 = "Compare";
break;
default:
goto die;
}
break;
case 12:
switch (VAR_3) {
case 0:
gen_op_mfc0_status();
VAR_4 = "Status";
break;
case 1:
check_insn(VAR_0, VAR_1, ISA_MIPS32R2);
gen_op_mfc0_intctl();
VAR_4 = "IntCtl";
break;
case 2:
check_insn(VAR_0, VAR_1, ISA_MIPS32R2);
gen_op_mfc0_srsctl();
VAR_4 = "SRSCtl";
break;
case 3:
check_insn(VAR_0, VAR_1, ISA_MIPS32R2);
gen_op_mfc0_srsmap();
VAR_4 = "SRSMap";
break;
default:
goto die;
}
break;
case 13:
switch (VAR_3) {
case 0:
gen_op_mfc0_cause();
VAR_4 = "Cause";
break;
default:
goto die;
}
break;
case 14:
switch (VAR_3) {
case 0:
gen_op_dmfc0_epc();
VAR_4 = "EPC";
break;
default:
goto die;
}
break;
case 15:
switch (VAR_3) {
case 0:
gen_op_mfc0_prid();
VAR_4 = "PRid";
break;
case 1:
check_insn(VAR_0, VAR_1, ISA_MIPS32R2);
gen_op_mfc0_ebase();
VAR_4 = "EBase";
break;
default:
goto die;
}
break;
case 16:
switch (VAR_3) {
case 0:
gen_op_mfc0_config0();
VAR_4 = "Config";
break;
case 1:
gen_op_mfc0_config1();
VAR_4 = "Config1";
break;
case 2:
gen_op_mfc0_config2();
VAR_4 = "Config2";
break;
case 3:
gen_op_mfc0_config3();
VAR_4 = "Config3";
break;
default:
goto die;
}
break;
case 17:
switch (VAR_3) {
case 0:
gen_op_dmfc0_lladdr();
VAR_4 = "LLAddr";
break;
default:
goto die;
}
break;
case 18:
switch (VAR_3) {
case 0 ... 7:
gen_op_dmfc0_watchlo(VAR_3);
VAR_4 = "WatchLo";
break;
default:
goto die;
}
break;
case 19:
switch (VAR_3) {
case 0 ... 7:
gen_op_mfc0_watchhi(VAR_3);
VAR_4 = "WatchHi";
break;
default:
goto die;
}
break;
case 20:
switch (VAR_3) {
case 0:
check_insn(VAR_0, VAR_1, ISA_MIPS3);
gen_op_dmfc0_xcontext();
VAR_4 = "XContext";
break;
default:
goto die;
}
break;
case 21:
switch (VAR_3) {
case 0:
gen_op_mfc0_framemask();
VAR_4 = "Framemask";
break;
default:
goto die;
}
break;
case 22:
VAR_4 = "'Diagnostic";
break;
case 23:
switch (VAR_3) {
case 0:
gen_op_mfc0_debug();
VAR_4 = "Debug";
break;
case 1:
VAR_4 = "TraceControl";
case 2:
VAR_4 = "TraceControl2";
case 3:
VAR_4 = "UserTraceData";
case 4:
VAR_4 = "TraceBPC";
default:
goto die;
}
break;
case 24:
switch (VAR_3) {
case 0:
gen_op_dmfc0_depc();
VAR_4 = "DEPC";
break;
default:
goto die;
}
break;
case 25:
switch (VAR_3) {
case 0:
gen_op_mfc0_performance0();
VAR_4 = "Performance0";
break;
case 1:
VAR_4 = "Performance1";
case 2:
VAR_4 = "Performance2";
case 3:
VAR_4 = "Performance3";
case 4:
VAR_4 = "Performance4";
case 5:
VAR_4 = "Performance5";
case 6:
VAR_4 = "Performance6";
case 7:
VAR_4 = "Performance7";
default:
goto die;
}
break;
case 26:
VAR_4 = "ECC";
break;
case 27:
switch (VAR_3) {
case 0 ... 3:
VAR_4 = "CacheErr";
break;
default:
goto die;
}
break;
case 28:
switch (VAR_3) {
case 0:
case 2:
case 4:
case 6:
gen_op_mfc0_taglo();
VAR_4 = "TagLo";
break;
case 1:
case 3:
case 5:
case 7:
gen_op_mfc0_datalo();
VAR_4 = "DataLo";
break;
default:
goto die;
}
break;
case 29:
switch (VAR_3) {
case 0:
case 2:
case 4:
case 6:
gen_op_mfc0_taghi();
VAR_4 = "TagHi";
break;
case 1:
case 3:
case 5:
case 7:
gen_op_mfc0_datahi();
VAR_4 = "DataHi";
break;
default:
goto die;
}
break;
case 30:
switch (VAR_3) {
case 0:
gen_op_dmfc0_errorepc();
VAR_4 = "ErrorEPC";
break;
default:
goto die;
}
break;
case 31:
switch (VAR_3) {
case 0:
gen_op_mfc0_desave();
VAR_4 = "DESAVE";
break;
default:
goto die;
}
break;
default:
goto die;
}
#if defined MIPS_DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "dmfc0 %s (VAR_2 %d VAR_3 %d)\n",
VAR_4, VAR_2, VAR_3);
}
#endif
return;
die:
#if defined MIPS_DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "dmfc0 %s (VAR_2 %d VAR_3 %d)\n",
VAR_4, VAR_2, VAR_3);
}
#endif
generate_exception(VAR_1, EXCP_RI);
}
|
[
"static void FUNC_0 (CPUState *VAR_0, DisasContext *VAR_1, int VAR_2, int VAR_3)\n{",
"const char *VAR_4 = \"invalid\";",
"if (VAR_3 != 0)\ncheck_insn(VAR_0, VAR_1, ISA_MIPS64);",
"switch (VAR_2) {",
"case 0:\nswitch (VAR_3) {",
"case 0:\ngen_op_mfc0_index();",
"VAR_4 = \"Index\";",
"break;",
"case 1:\ncheck_mips_mt(VAR_0, VAR_1);",
"gen_op_mfc0_mvpcontrol();",
"VAR_4 = \"MVPControl\";",
"break;",
"case 2:\ncheck_mips_mt(VAR_0, VAR_1);",
"gen_op_mfc0_mvpconf0();",
"VAR_4 = \"MVPConf0\";",
"break;",
"case 3:\ncheck_mips_mt(VAR_0, VAR_1);",
"gen_op_mfc0_mvpconf1();",
"VAR_4 = \"MVPConf1\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 1:\nswitch (VAR_3) {",
"case 0:\ngen_op_mfc0_random();",
"VAR_4 = \"Random\";",
"break;",
"case 1:\ncheck_mips_mt(VAR_0, VAR_1);",
"gen_op_mfc0_vpecontrol();",
"VAR_4 = \"VPEControl\";",
"break;",
"case 2:\ncheck_mips_mt(VAR_0, VAR_1);",
"gen_op_mfc0_vpeconf0();",
"VAR_4 = \"VPEConf0\";",
"break;",
"case 3:\ncheck_mips_mt(VAR_0, VAR_1);",
"gen_op_mfc0_vpeconf1();",
"VAR_4 = \"VPEConf1\";",
"break;",
"case 4:\ncheck_mips_mt(VAR_0, VAR_1);",
"gen_op_dmfc0_yqmask();",
"VAR_4 = \"YQMask\";",
"break;",
"case 5:\ncheck_mips_mt(VAR_0, VAR_1);",
"gen_op_dmfc0_vpeschedule();",
"VAR_4 = \"VPESchedule\";",
"break;",
"case 6:\ncheck_mips_mt(VAR_0, VAR_1);",
"gen_op_dmfc0_vpeschefback();",
"VAR_4 = \"VPEScheFBack\";",
"break;",
"case 7:\ncheck_mips_mt(VAR_0, VAR_1);",
"gen_op_mfc0_vpeopt();",
"VAR_4 = \"VPEOpt\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 2:\nswitch (VAR_3) {",
"case 0:\ngen_op_dmfc0_entrylo0();",
"VAR_4 = \"EntryLo0\";",
"break;",
"case 1:\ncheck_mips_mt(VAR_0, VAR_1);",
"gen_op_mfc0_tcstatus();",
"VAR_4 = \"TCStatus\";",
"break;",
"case 2:\ncheck_mips_mt(VAR_0, VAR_1);",
"gen_op_mfc0_tcbind();",
"VAR_4 = \"TCBind\";",
"break;",
"case 3:\ncheck_mips_mt(VAR_0, VAR_1);",
"gen_op_dmfc0_tcrestart();",
"VAR_4 = \"TCRestart\";",
"break;",
"case 4:\ncheck_mips_mt(VAR_0, VAR_1);",
"gen_op_dmfc0_tchalt();",
"VAR_4 = \"TCHalt\";",
"break;",
"case 5:\ncheck_mips_mt(VAR_0, VAR_1);",
"gen_op_dmfc0_tccontext();",
"VAR_4 = \"TCContext\";",
"break;",
"case 6:\ncheck_mips_mt(VAR_0, VAR_1);",
"gen_op_dmfc0_tcschedule();",
"VAR_4 = \"TCSchedule\";",
"break;",
"case 7:\ncheck_mips_mt(VAR_0, VAR_1);",
"gen_op_dmfc0_tcschefback();",
"VAR_4 = \"TCScheFBack\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 3:\nswitch (VAR_3) {",
"case 0:\ngen_op_dmfc0_entrylo1();",
"VAR_4 = \"EntryLo1\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 4:\nswitch (VAR_3) {",
"case 0:\ngen_op_dmfc0_context();",
"VAR_4 = \"Context\";",
"break;",
"case 1:\nVAR_4 = \"ContextConfig\";",
"default:\ngoto die;",
"}",
"break;",
"case 5:\nswitch (VAR_3) {",
"case 0:\ngen_op_mfc0_pagemask();",
"VAR_4 = \"PageMask\";",
"break;",
"case 1:\ncheck_insn(VAR_0, VAR_1, ISA_MIPS32R2);",
"gen_op_mfc0_pagegrain();",
"VAR_4 = \"PageGrain\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 6:\nswitch (VAR_3) {",
"case 0:\ngen_op_mfc0_wired();",
"VAR_4 = \"Wired\";",
"break;",
"case 1:\ncheck_insn(VAR_0, VAR_1, ISA_MIPS32R2);",
"gen_op_mfc0_srsconf0();",
"VAR_4 = \"SRSConf0\";",
"break;",
"case 2:\ncheck_insn(VAR_0, VAR_1, ISA_MIPS32R2);",
"gen_op_mfc0_srsconf1();",
"VAR_4 = \"SRSConf1\";",
"break;",
"case 3:\ncheck_insn(VAR_0, VAR_1, ISA_MIPS32R2);",
"gen_op_mfc0_srsconf2();",
"VAR_4 = \"SRSConf2\";",
"break;",
"case 4:\ncheck_insn(VAR_0, VAR_1, ISA_MIPS32R2);",
"gen_op_mfc0_srsconf3();",
"VAR_4 = \"SRSConf3\";",
"break;",
"case 5:\ncheck_insn(VAR_0, VAR_1, ISA_MIPS32R2);",
"gen_op_mfc0_srsconf4();",
"VAR_4 = \"SRSConf4\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 7:\nswitch (VAR_3) {",
"case 0:\ncheck_insn(VAR_0, VAR_1, ISA_MIPS32R2);",
"gen_op_mfc0_hwrena();",
"VAR_4 = \"HWREna\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 8:\nswitch (VAR_3) {",
"case 0:\ngen_op_dmfc0_badvaddr();",
"VAR_4 = \"BadVaddr\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 9:\nswitch (VAR_3) {",
"case 0:\ngen_op_mfc0_count();",
"VAR_4 = \"Count\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 10:\nswitch (VAR_3) {",
"case 0:\ngen_op_dmfc0_entryhi();",
"VAR_4 = \"EntryHi\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 11:\nswitch (VAR_3) {",
"case 0:\ngen_op_mfc0_compare();",
"VAR_4 = \"Compare\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 12:\nswitch (VAR_3) {",
"case 0:\ngen_op_mfc0_status();",
"VAR_4 = \"Status\";",
"break;",
"case 1:\ncheck_insn(VAR_0, VAR_1, ISA_MIPS32R2);",
"gen_op_mfc0_intctl();",
"VAR_4 = \"IntCtl\";",
"break;",
"case 2:\ncheck_insn(VAR_0, VAR_1, ISA_MIPS32R2);",
"gen_op_mfc0_srsctl();",
"VAR_4 = \"SRSCtl\";",
"break;",
"case 3:\ncheck_insn(VAR_0, VAR_1, ISA_MIPS32R2);",
"gen_op_mfc0_srsmap();",
"VAR_4 = \"SRSMap\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 13:\nswitch (VAR_3) {",
"case 0:\ngen_op_mfc0_cause();",
"VAR_4 = \"Cause\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 14:\nswitch (VAR_3) {",
"case 0:\ngen_op_dmfc0_epc();",
"VAR_4 = \"EPC\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 15:\nswitch (VAR_3) {",
"case 0:\ngen_op_mfc0_prid();",
"VAR_4 = \"PRid\";",
"break;",
"case 1:\ncheck_insn(VAR_0, VAR_1, ISA_MIPS32R2);",
"gen_op_mfc0_ebase();",
"VAR_4 = \"EBase\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 16:\nswitch (VAR_3) {",
"case 0:\ngen_op_mfc0_config0();",
"VAR_4 = \"Config\";",
"break;",
"case 1:\ngen_op_mfc0_config1();",
"VAR_4 = \"Config1\";",
"break;",
"case 2:\ngen_op_mfc0_config2();",
"VAR_4 = \"Config2\";",
"break;",
"case 3:\ngen_op_mfc0_config3();",
"VAR_4 = \"Config3\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 17:\nswitch (VAR_3) {",
"case 0:\ngen_op_dmfc0_lladdr();",
"VAR_4 = \"LLAddr\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 18:\nswitch (VAR_3) {",
"case 0 ... 7:\ngen_op_dmfc0_watchlo(VAR_3);",
"VAR_4 = \"WatchLo\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 19:\nswitch (VAR_3) {",
"case 0 ... 7:\ngen_op_mfc0_watchhi(VAR_3);",
"VAR_4 = \"WatchHi\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 20:\nswitch (VAR_3) {",
"case 0:\ncheck_insn(VAR_0, VAR_1, ISA_MIPS3);",
"gen_op_dmfc0_xcontext();",
"VAR_4 = \"XContext\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 21:\nswitch (VAR_3) {",
"case 0:\ngen_op_mfc0_framemask();",
"VAR_4 = \"Framemask\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 22:\nVAR_4 = \"'Diagnostic\";",
"break;",
"case 23:\nswitch (VAR_3) {",
"case 0:\ngen_op_mfc0_debug();",
"VAR_4 = \"Debug\";",
"break;",
"case 1:\nVAR_4 = \"TraceControl\";",
"case 2:\nVAR_4 = \"TraceControl2\";",
"case 3:\nVAR_4 = \"UserTraceData\";",
"case 4:\nVAR_4 = \"TraceBPC\";",
"default:\ngoto die;",
"}",
"break;",
"case 24:\nswitch (VAR_3) {",
"case 0:\ngen_op_dmfc0_depc();",
"VAR_4 = \"DEPC\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 25:\nswitch (VAR_3) {",
"case 0:\ngen_op_mfc0_performance0();",
"VAR_4 = \"Performance0\";",
"break;",
"case 1:\nVAR_4 = \"Performance1\";",
"case 2:\nVAR_4 = \"Performance2\";",
"case 3:\nVAR_4 = \"Performance3\";",
"case 4:\nVAR_4 = \"Performance4\";",
"case 5:\nVAR_4 = \"Performance5\";",
"case 6:\nVAR_4 = \"Performance6\";",
"case 7:\nVAR_4 = \"Performance7\";",
"default:\ngoto die;",
"}",
"break;",
"case 26:\nVAR_4 = \"ECC\";",
"break;",
"case 27:\nswitch (VAR_3) {",
"case 0 ... 3:\nVAR_4 = \"CacheErr\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 28:\nswitch (VAR_3) {",
"case 0:\ncase 2:\ncase 4:\ncase 6:\ngen_op_mfc0_taglo();",
"VAR_4 = \"TagLo\";",
"break;",
"case 1:\ncase 3:\ncase 5:\ncase 7:\ngen_op_mfc0_datalo();",
"VAR_4 = \"DataLo\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 29:\nswitch (VAR_3) {",
"case 0:\ncase 2:\ncase 4:\ncase 6:\ngen_op_mfc0_taghi();",
"VAR_4 = \"TagHi\";",
"break;",
"case 1:\ncase 3:\ncase 5:\ncase 7:\ngen_op_mfc0_datahi();",
"VAR_4 = \"DataHi\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 30:\nswitch (VAR_3) {",
"case 0:\ngen_op_dmfc0_errorepc();",
"VAR_4 = \"ErrorEPC\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 31:\nswitch (VAR_3) {",
"case 0:\ngen_op_mfc0_desave();",
"VAR_4 = \"DESAVE\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"default:\ngoto die;",
"}",
"#if defined MIPS_DEBUG_DISAS\nif (loglevel & CPU_LOG_TB_IN_ASM) {",
"fprintf(logfile, \"dmfc0 %s (VAR_2 %d VAR_3 %d)\\n\",\nVAR_4, VAR_2, VAR_3);",
"}",
"#endif\nreturn;",
"die:\n#if defined MIPS_DEBUG_DISAS\nif (loglevel & CPU_LOG_TB_IN_ASM) {",
"fprintf(logfile, \"dmfc0 %s (VAR_2 %d VAR_3 %d)\\n\",\nVAR_4, VAR_2, VAR_3);",
"}",
"#endif\ngenerate_exception(VAR_1, EXCP_RI);",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
9,
11
],
[
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,
283
],
[
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
],
[
399,
401
],
[
403
],
[
405
],
[
407
],
[
409,
411
],
[
413
],
[
415
],
[
417,
419
],
[
421,
423
],
[
425
],
[
427
],
[
429,
431
],
[
433
],
[
435
],
[
437,
439
],
[
441,
443
],
[
445
],
[
447
],
[
451,
453
],
[
455
],
[
457
],
[
459,
461
],
[
463,
465
],
[
467
],
[
469
],
[
471,
473
],
[
475
],
[
477
],
[
479,
481
],
[
483,
485
],
[
487
],
[
489
],
[
493,
495
],
[
497
],
[
499
],
[
501,
503
],
[
505,
507
],
[
509
],
[
511
],
[
513,
515
],
[
517
],
[
519
],
[
521
],
[
523,
525
],
[
527
],
[
529
],
[
531
],
[
533,
535
],
[
537
],
[
539
],
[
541
],
[
543,
545
],
[
547
],
[
549
],
[
551,
553
],
[
555,
557
],
[
559
],
[
561
],
[
563,
565
],
[
567
],
[
569
],
[
571,
573
],
[
575,
577
],
[
579
],
[
581
],
[
583,
585
],
[
587
],
[
589
],
[
591,
593
],
[
595,
597
],
[
599
],
[
601
],
[
603,
605
],
[
607
],
[
609
],
[
611
],
[
613,
615
],
[
617
],
[
619
],
[
621,
623
],
[
625,
627
],
[
629
],
[
631
],
[
633,
635
],
[
637
],
[
639
],
[
641,
643
],
[
645
],
[
647
],
[
649,
651
],
[
653
],
[
655
],
[
659,
661
],
[
663
],
[
665
],
[
667,
669
],
[
671,
673
],
[
675
],
[
677
],
[
679,
681
],
[
683
],
[
685
],
[
687,
689
],
[
691,
693
],
[
695
],
[
697
],
[
699,
701
],
[
703
],
[
705
],
[
707,
709
],
[
711,
713
],
[
715
],
[
717
],
[
719,
721
],
[
723
],
[
725
],
[
727,
729
],
[
731,
733
],
[
735
],
[
737
],
[
739
],
[
741,
743
],
[
745
],
[
747
],
[
749,
753
],
[
755,
757
],
[
759
],
[
761
],
[
763,
765
],
[
767
],
[
769
],
[
771,
775
],
[
777
],
[
779,
781
],
[
783,
785
],
[
787
],
[
789
],
[
791,
795
],
[
799,
803
],
[
807,
811
],
[
815,
819
],
[
823,
825
],
[
827
],
[
829
],
[
831,
833
],
[
835,
837
],
[
839
],
[
841
],
[
843,
845
],
[
847
],
[
849
],
[
851,
853
],
[
855,
857
],
[
859
],
[
861
],
[
863,
867
],
[
871,
875
],
[
879,
883
],
[
887,
891
],
[
895,
899
],
[
903,
907
],
[
911,
915
],
[
919,
921
],
[
923
],
[
925
],
[
927,
929
],
[
931
],
[
933,
935
],
[
939,
941
],
[
943
],
[
945,
947
],
[
949
],
[
951
],
[
953,
955
],
[
957,
959,
961,
963,
965
],
[
967
],
[
969
],
[
971,
973,
975,
977,
979
],
[
981
],
[
983
],
[
985,
987
],
[
989
],
[
991
],
[
993,
995
],
[
997,
999,
1001,
1003,
1005
],
[
1007
],
[
1009
],
[
1011,
1013,
1015,
1017,
1019
],
[
1021
],
[
1023
],
[
1025,
1027
],
[
1029
],
[
1031
],
[
1033,
1035
],
[
1037,
1039
],
[
1041
],
[
1043
],
[
1045,
1047
],
[
1049
],
[
1051
],
[
1053,
1055
],
[
1057,
1059
],
[
1061
],
[
1063
],
[
1065,
1067
],
[
1069
],
[
1071
],
[
1073,
1075
],
[
1077
],
[
1079,
1081
],
[
1083,
1085
],
[
1087
],
[
1089,
1091
],
[
1095,
1097,
1099
],
[
1101,
1103
],
[
1105
],
[
1107,
1109
],
[
1111
]
] |
12,866
|
static BlockBackend *img_open(const char *id, const char *filename,
const char *fmt, int flags,
bool require_io, bool quiet)
{
BlockBackend *blk;
BlockDriverState *bs;
char password[256];
Error *local_err = NULL;
QDict *options = NULL;
if (fmt) {
options = qdict_new();
qdict_put(options, "driver", qstring_from_str(fmt));
}
blk = blk_new_open(id, filename, NULL, options, flags, &local_err);
if (!blk) {
error_report("Could not open '%s': %s", filename,
error_get_pretty(local_err));
error_free(local_err);
goto fail;
}
bs = blk_bs(blk);
if (bdrv_is_encrypted(bs) && require_io) {
qprintf(quiet, "Disk image '%s' is encrypted.\n", filename);
if (read_password(password, sizeof(password)) < 0) {
error_report("No password given");
goto fail;
}
if (bdrv_set_key(bs, password) < 0) {
error_report("invalid password");
goto fail;
}
}
return blk;
fail:
blk_unref(blk);
return NULL;
}
| false
|
qemu
|
d57e4e482e3997b1382625c84149ad0b69155fc0
|
static BlockBackend *img_open(const char *id, const char *filename,
const char *fmt, int flags,
bool require_io, bool quiet)
{
BlockBackend *blk;
BlockDriverState *bs;
char password[256];
Error *local_err = NULL;
QDict *options = NULL;
if (fmt) {
options = qdict_new();
qdict_put(options, "driver", qstring_from_str(fmt));
}
blk = blk_new_open(id, filename, NULL, options, flags, &local_err);
if (!blk) {
error_report("Could not open '%s': %s", filename,
error_get_pretty(local_err));
error_free(local_err);
goto fail;
}
bs = blk_bs(blk);
if (bdrv_is_encrypted(bs) && require_io) {
qprintf(quiet, "Disk image '%s' is encrypted.\n", filename);
if (read_password(password, sizeof(password)) < 0) {
error_report("No password given");
goto fail;
}
if (bdrv_set_key(bs, password) < 0) {
error_report("invalid password");
goto fail;
}
}
return blk;
fail:
blk_unref(blk);
return NULL;
}
|
{
"code": [],
"line_no": []
}
|
static BlockBackend *FUNC_0(const char *id, const char *filename,
const char *fmt, int flags,
bool require_io, bool quiet)
{
BlockBackend *blk;
BlockDriverState *bs;
char VAR_0[256];
Error *local_err = NULL;
QDict *options = NULL;
if (fmt) {
options = qdict_new();
qdict_put(options, "driver", qstring_from_str(fmt));
}
blk = blk_new_open(id, filename, NULL, options, flags, &local_err);
if (!blk) {
error_report("Could not open '%s': %s", filename,
error_get_pretty(local_err));
error_free(local_err);
goto fail;
}
bs = blk_bs(blk);
if (bdrv_is_encrypted(bs) && require_io) {
qprintf(quiet, "Disk image '%s' is encrypted.\n", filename);
if (read_password(VAR_0, sizeof(VAR_0)) < 0) {
error_report("No VAR_0 given");
goto fail;
}
if (bdrv_set_key(bs, VAR_0) < 0) {
error_report("invalid VAR_0");
goto fail;
}
}
return blk;
fail:
blk_unref(blk);
return NULL;
}
|
[
"static BlockBackend *FUNC_0(const char *id, const char *filename,\nconst char *fmt, int flags,\nbool require_io, bool quiet)\n{",
"BlockBackend *blk;",
"BlockDriverState *bs;",
"char VAR_0[256];",
"Error *local_err = NULL;",
"QDict *options = NULL;",
"if (fmt) {",
"options = qdict_new();",
"qdict_put(options, \"driver\", qstring_from_str(fmt));",
"}",
"blk = blk_new_open(id, filename, NULL, options, flags, &local_err);",
"if (!blk) {",
"error_report(\"Could not open '%s': %s\", filename,\nerror_get_pretty(local_err));",
"error_free(local_err);",
"goto fail;",
"}",
"bs = blk_bs(blk);",
"if (bdrv_is_encrypted(bs) && require_io) {",
"qprintf(quiet, \"Disk image '%s' is encrypted.\\n\", filename);",
"if (read_password(VAR_0, sizeof(VAR_0)) < 0) {",
"error_report(\"No VAR_0 given\");",
"goto fail;",
"}",
"if (bdrv_set_key(bs, VAR_0) < 0) {",
"error_report(\"invalid VAR_0\");",
"goto fail;",
"}",
"}",
"return blk;",
"fail:\nblk_unref(blk);",
"return NULL;",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
]
] |
12,867
|
static void do_boot_set(Monitor *mon, const QDict *qdict)
{
int res;
const char *bootdevice = qdict_get_str(qdict, "bootdevice");
res = qemu_boot_set(bootdevice);
if (res == 0) {
monitor_printf(mon, "boot device list now set to %s\n", bootdevice);
} else if (res > 0) {
monitor_printf(mon, "setting boot device list failed\n");
} else {
monitor_printf(mon, "no function defined to set boot device list for "
"this architecture\n");
}
}
| false
|
qemu
|
f1839938b090b28537d9be2c1b255b834f3cfbb8
|
static void do_boot_set(Monitor *mon, const QDict *qdict)
{
int res;
const char *bootdevice = qdict_get_str(qdict, "bootdevice");
res = qemu_boot_set(bootdevice);
if (res == 0) {
monitor_printf(mon, "boot device list now set to %s\n", bootdevice);
} else if (res > 0) {
monitor_printf(mon, "setting boot device list failed\n");
} else {
monitor_printf(mon, "no function defined to set boot device list for "
"this architecture\n");
}
}
|
{
"code": [],
"line_no": []
}
|
static void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)
{
int VAR_2;
const char *VAR_3 = qdict_get_str(VAR_1, "VAR_3");
VAR_2 = qemu_boot_set(VAR_3);
if (VAR_2 == 0) {
monitor_printf(VAR_0, "boot device list now set to %s\n", VAR_3);
} else if (VAR_2 > 0) {
monitor_printf(VAR_0, "setting boot device list failed\n");
} else {
monitor_printf(VAR_0, "no function defined to set boot device list for "
"this architecture\n");
}
}
|
[
"static void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)\n{",
"int VAR_2;",
"const char *VAR_3 = qdict_get_str(VAR_1, \"VAR_3\");",
"VAR_2 = qemu_boot_set(VAR_3);",
"if (VAR_2 == 0) {",
"monitor_printf(VAR_0, \"boot device list now set to %s\\n\", VAR_3);",
"} else if (VAR_2 > 0) {",
"monitor_printf(VAR_0, \"setting boot device list failed\\n\");",
"} else {",
"monitor_printf(VAR_0, \"no function defined to set boot device list for \"\n\"this architecture\\n\");",
"}",
"}"
] |
[
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
]
] |
12,868
|
void restore_state_to_opc(CPUARMState *env, TranslationBlock *tb, int pc_pos)
{
if (is_a64(env)) {
env->pc = tcg_ctx.gen_opc_pc[pc_pos];
} else {
env->regs[15] = tcg_ctx.gen_opc_pc[pc_pos];
}
env->condexec_bits = gen_opc_condexec_bits[pc_pos];
}
| false
|
qemu
|
40f860cd6c1aa0d3399e3f8158f20bdc5b2bfbfe
|
void restore_state_to_opc(CPUARMState *env, TranslationBlock *tb, int pc_pos)
{
if (is_a64(env)) {
env->pc = tcg_ctx.gen_opc_pc[pc_pos];
} else {
env->regs[15] = tcg_ctx.gen_opc_pc[pc_pos];
}
env->condexec_bits = gen_opc_condexec_bits[pc_pos];
}
|
{
"code": [],
"line_no": []
}
|
void FUNC_0(CPUARMState *VAR_0, TranslationBlock *VAR_1, int VAR_2)
{
if (is_a64(VAR_0)) {
VAR_0->pc = tcg_ctx.gen_opc_pc[VAR_2];
} else {
VAR_0->regs[15] = tcg_ctx.gen_opc_pc[VAR_2];
}
VAR_0->condexec_bits = gen_opc_condexec_bits[VAR_2];
}
|
[
"void FUNC_0(CPUARMState *VAR_0, TranslationBlock *VAR_1, int VAR_2)\n{",
"if (is_a64(VAR_0)) {",
"VAR_0->pc = tcg_ctx.gen_opc_pc[VAR_2];",
"} else {",
"VAR_0->regs[15] = tcg_ctx.gen_opc_pc[VAR_2];",
"}",
"VAR_0->condexec_bits = gen_opc_condexec_bits[VAR_2];",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
12,870
|
void kvm_set_phys_mem(target_phys_addr_t start_addr,
ram_addr_t size,
ram_addr_t phys_offset)
{
KVMState *s = kvm_state;
ram_addr_t flags = phys_offset & ~TARGET_PAGE_MASK;
KVMSlot *mem;
/* KVM does not support read-only slots */
phys_offset &= ~IO_MEM_ROM;
mem = kvm_lookup_slot(s, start_addr);
if (mem) {
if (flags == IO_MEM_UNASSIGNED) {
mem->memory_size = 0;
mem->guest_phys_addr = start_addr;
mem->userspace_addr = 0;
mem->flags = 0;
kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, mem);
} else if (start_addr >= mem->guest_phys_addr &&
(start_addr + size) <= (mem->guest_phys_addr + mem->memory_size))
return;
}
/* KVM does not need to know about this memory */
if (flags >= IO_MEM_UNASSIGNED)
return;
mem = kvm_alloc_slot(s);
mem->memory_size = size;
mem->guest_phys_addr = start_addr;
mem->userspace_addr = (unsigned long)(phys_ram_base + phys_offset);
mem->flags = 0;
kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, mem);
/* FIXME deal with errors */
}
| false
|
qemu
|
62d60e8cc4c4c8aebdfd97f10087456d2690c0a0
|
void kvm_set_phys_mem(target_phys_addr_t start_addr,
ram_addr_t size,
ram_addr_t phys_offset)
{
KVMState *s = kvm_state;
ram_addr_t flags = phys_offset & ~TARGET_PAGE_MASK;
KVMSlot *mem;
phys_offset &= ~IO_MEM_ROM;
mem = kvm_lookup_slot(s, start_addr);
if (mem) {
if (flags == IO_MEM_UNASSIGNED) {
mem->memory_size = 0;
mem->guest_phys_addr = start_addr;
mem->userspace_addr = 0;
mem->flags = 0;
kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, mem);
} else if (start_addr >= mem->guest_phys_addr &&
(start_addr + size) <= (mem->guest_phys_addr + mem->memory_size))
return;
}
if (flags >= IO_MEM_UNASSIGNED)
return;
mem = kvm_alloc_slot(s);
mem->memory_size = size;
mem->guest_phys_addr = start_addr;
mem->userspace_addr = (unsigned long)(phys_ram_base + phys_offset);
mem->flags = 0;
kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, mem);
}
|
{
"code": [],
"line_no": []
}
|
void FUNC_0(target_phys_addr_t VAR_0,
ram_addr_t VAR_1,
ram_addr_t VAR_2)
{
KVMState *s = kvm_state;
ram_addr_t flags = VAR_2 & ~TARGET_PAGE_MASK;
KVMSlot *mem;
VAR_2 &= ~IO_MEM_ROM;
mem = kvm_lookup_slot(s, VAR_0);
if (mem) {
if (flags == IO_MEM_UNASSIGNED) {
mem->memory_size = 0;
mem->guest_phys_addr = VAR_0;
mem->userspace_addr = 0;
mem->flags = 0;
kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, mem);
} else if (VAR_0 >= mem->guest_phys_addr &&
(VAR_0 + VAR_1) <= (mem->guest_phys_addr + mem->memory_size))
return;
}
if (flags >= IO_MEM_UNASSIGNED)
return;
mem = kvm_alloc_slot(s);
mem->memory_size = VAR_1;
mem->guest_phys_addr = VAR_0;
mem->userspace_addr = (unsigned long)(phys_ram_base + VAR_2);
mem->flags = 0;
kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, mem);
}
|
[
"void FUNC_0(target_phys_addr_t VAR_0,\nram_addr_t VAR_1,\nram_addr_t VAR_2)\n{",
"KVMState *s = kvm_state;",
"ram_addr_t flags = VAR_2 & ~TARGET_PAGE_MASK;",
"KVMSlot *mem;",
"VAR_2 &= ~IO_MEM_ROM;",
"mem = kvm_lookup_slot(s, VAR_0);",
"if (mem) {",
"if (flags == IO_MEM_UNASSIGNED) {",
"mem->memory_size = 0;",
"mem->guest_phys_addr = VAR_0;",
"mem->userspace_addr = 0;",
"mem->flags = 0;",
"kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, mem);",
"} else if (VAR_0 >= mem->guest_phys_addr &&",
"(VAR_0 + VAR_1) <= (mem->guest_phys_addr + mem->memory_size))\nreturn;",
"}",
"if (flags >= IO_MEM_UNASSIGNED)\nreturn;",
"mem = kvm_alloc_slot(s);",
"mem->memory_size = VAR_1;",
"mem->guest_phys_addr = VAR_0;",
"mem->userspace_addr = (unsigned long)(phys_ram_base + VAR_2);",
"mem->flags = 0;",
"kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, mem);",
"}"
] |
[
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
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
53,
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
75
]
] |
12,872
|
static int virtio_pci_set_host_notifier(void *opaque, int n, bool assign)
{
VirtIOPCIProxy *proxy = opaque;
VirtQueue *vq = virtio_get_queue(proxy->vdev, n);
EventNotifier *notifier = virtio_queue_get_host_notifier(vq);
int r;
if (assign) {
r = event_notifier_init(notifier, 1);
if (r < 0) {
return r;
}
r = kvm_set_ioeventfd_pio_word(event_notifier_get_fd(notifier),
proxy->addr + VIRTIO_PCI_QUEUE_NOTIFY,
n, assign);
if (r < 0) {
event_notifier_cleanup(notifier);
}
} else {
r = kvm_set_ioeventfd_pio_word(event_notifier_get_fd(notifier),
proxy->addr + VIRTIO_PCI_QUEUE_NOTIFY,
n, assign);
if (r < 0) {
return r;
}
event_notifier_cleanup(notifier);
}
return r;
}
| false
|
qemu
|
25db9ebe15125deb32958c6df74996f745edf1f9
|
static int virtio_pci_set_host_notifier(void *opaque, int n, bool assign)
{
VirtIOPCIProxy *proxy = opaque;
VirtQueue *vq = virtio_get_queue(proxy->vdev, n);
EventNotifier *notifier = virtio_queue_get_host_notifier(vq);
int r;
if (assign) {
r = event_notifier_init(notifier, 1);
if (r < 0) {
return r;
}
r = kvm_set_ioeventfd_pio_word(event_notifier_get_fd(notifier),
proxy->addr + VIRTIO_PCI_QUEUE_NOTIFY,
n, assign);
if (r < 0) {
event_notifier_cleanup(notifier);
}
} else {
r = kvm_set_ioeventfd_pio_word(event_notifier_get_fd(notifier),
proxy->addr + VIRTIO_PCI_QUEUE_NOTIFY,
n, assign);
if (r < 0) {
return r;
}
event_notifier_cleanup(notifier);
}
return r;
}
|
{
"code": [],
"line_no": []
}
|
static int FUNC_0(void *VAR_0, int VAR_1, bool VAR_2)
{
VirtIOPCIProxy *proxy = VAR_0;
VirtQueue *vq = virtio_get_queue(proxy->vdev, VAR_1);
EventNotifier *notifier = virtio_queue_get_host_notifier(vq);
int VAR_3;
if (VAR_2) {
VAR_3 = event_notifier_init(notifier, 1);
if (VAR_3 < 0) {
return VAR_3;
}
VAR_3 = kvm_set_ioeventfd_pio_word(event_notifier_get_fd(notifier),
proxy->addr + VIRTIO_PCI_QUEUE_NOTIFY,
VAR_1, VAR_2);
if (VAR_3 < 0) {
event_notifier_cleanup(notifier);
}
} else {
VAR_3 = kvm_set_ioeventfd_pio_word(event_notifier_get_fd(notifier),
proxy->addr + VIRTIO_PCI_QUEUE_NOTIFY,
VAR_1, VAR_2);
if (VAR_3 < 0) {
return VAR_3;
}
event_notifier_cleanup(notifier);
}
return VAR_3;
}
|
[
"static int FUNC_0(void *VAR_0, int VAR_1, bool VAR_2)\n{",
"VirtIOPCIProxy *proxy = VAR_0;",
"VirtQueue *vq = virtio_get_queue(proxy->vdev, VAR_1);",
"EventNotifier *notifier = virtio_queue_get_host_notifier(vq);",
"int VAR_3;",
"if (VAR_2) {",
"VAR_3 = event_notifier_init(notifier, 1);",
"if (VAR_3 < 0) {",
"return VAR_3;",
"}",
"VAR_3 = kvm_set_ioeventfd_pio_word(event_notifier_get_fd(notifier),\nproxy->addr + VIRTIO_PCI_QUEUE_NOTIFY,\nVAR_1, VAR_2);",
"if (VAR_3 < 0) {",
"event_notifier_cleanup(notifier);",
"}",
"} else {",
"VAR_3 = kvm_set_ioeventfd_pio_word(event_notifier_get_fd(notifier),\nproxy->addr + VIRTIO_PCI_QUEUE_NOTIFY,\nVAR_1, VAR_2);",
"if (VAR_3 < 0) {",
"return VAR_3;",
"}",
"event_notifier_cleanup(notifier);",
"}",
"return VAR_3;",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
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
]
] |
12,873
|
static inline void neon_load_reg64(TCGv var, int reg)
{
tcg_gen_ld_i64(var, cpu_env, vfp_reg_offset(1, reg));
}
| false
|
qemu
|
a7812ae412311d7d47f8aa85656faadac9d64b56
|
static inline void neon_load_reg64(TCGv var, int reg)
{
tcg_gen_ld_i64(var, cpu_env, vfp_reg_offset(1, reg));
}
|
{
"code": [],
"line_no": []
}
|
static inline void FUNC_0(TCGv VAR_0, int VAR_1)
{
tcg_gen_ld_i64(VAR_0, cpu_env, vfp_reg_offset(1, VAR_1));
}
|
[
"static inline void FUNC_0(TCGv VAR_0, int VAR_1)\n{",
"tcg_gen_ld_i64(VAR_0, cpu_env, vfp_reg_offset(1, VAR_1));",
"}"
] |
[
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
]
] |
12,874
|
static void encode_sigpass(Jpeg2000T1Context *t1, int width, int height, int bandno, int *nmsedec, int bpno)
{
int y0, x, y, mask = 1 << (bpno + NMSEDEC_FRACBITS);
for (y0 = 0; y0 < height; y0 += 4)
for (x = 0; x < width; x++)
for (y = y0; y < height && y < y0+4; y++){
if (!(t1->flags[y+1][x+1] & JPEG2000_T1_SIG) && (t1->flags[y+1][x+1] & JPEG2000_T1_SIG_NB)){
int ctxno = ff_jpeg2000_getsigctxno(t1->flags[y+1][x+1], bandno),
bit = t1->data[y][x] & mask ? 1 : 0;
ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, bit);
if (bit){
int xorbit;
int ctxno = ff_jpeg2000_getsgnctxno(t1->flags[y+1][x+1], &xorbit);
ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, (t1->flags[y+1][x+1] >> 15) ^ xorbit);
*nmsedec += getnmsedec_sig(t1->data[y][x], bpno + NMSEDEC_FRACBITS);
ff_jpeg2000_set_significance(t1, x, y, t1->flags[y+1][x+1] >> 15);
}
t1->flags[y+1][x+1] |= JPEG2000_T1_VIS;
}
}
}
| false
|
FFmpeg
|
f1e173049ecc9de03817385ba8962d14cba779db
|
static void encode_sigpass(Jpeg2000T1Context *t1, int width, int height, int bandno, int *nmsedec, int bpno)
{
int y0, x, y, mask = 1 << (bpno + NMSEDEC_FRACBITS);
for (y0 = 0; y0 < height; y0 += 4)
for (x = 0; x < width; x++)
for (y = y0; y < height && y < y0+4; y++){
if (!(t1->flags[y+1][x+1] & JPEG2000_T1_SIG) && (t1->flags[y+1][x+1] & JPEG2000_T1_SIG_NB)){
int ctxno = ff_jpeg2000_getsigctxno(t1->flags[y+1][x+1], bandno),
bit = t1->data[y][x] & mask ? 1 : 0;
ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, bit);
if (bit){
int xorbit;
int ctxno = ff_jpeg2000_getsgnctxno(t1->flags[y+1][x+1], &xorbit);
ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, (t1->flags[y+1][x+1] >> 15) ^ xorbit);
*nmsedec += getnmsedec_sig(t1->data[y][x], bpno + NMSEDEC_FRACBITS);
ff_jpeg2000_set_significance(t1, x, y, t1->flags[y+1][x+1] >> 15);
}
t1->flags[y+1][x+1] |= JPEG2000_T1_VIS;
}
}
}
|
{
"code": [],
"line_no": []
}
|
static void FUNC_0(Jpeg2000T1Context *VAR_0, int VAR_1, int VAR_2, int VAR_3, int *VAR_4, int VAR_5)
{
int VAR_6, VAR_7, VAR_8, VAR_9 = 1 << (VAR_5 + NMSEDEC_FRACBITS);
for (VAR_6 = 0; VAR_6 < VAR_2; VAR_6 += 4)
for (VAR_7 = 0; VAR_7 < VAR_1; VAR_7++)
for (VAR_8 = VAR_6; VAR_8 < VAR_2 && VAR_8 < VAR_6+4; VAR_8++){
if (!(VAR_0->flags[VAR_8+1][VAR_7+1] & JPEG2000_T1_SIG) && (VAR_0->flags[VAR_8+1][VAR_7+1] & JPEG2000_T1_SIG_NB)){
int VAR_13 = ff_jpeg2000_getsigctxno(VAR_0->flags[VAR_8+1][VAR_7+1], VAR_3),
VAR_11 = VAR_0->data[VAR_8][VAR_7] & VAR_9 ? 1 : 0;
ff_mqc_encode(&VAR_0->mqc, VAR_0->mqc.cx_states + VAR_13, VAR_11);
if (VAR_11){
int VAR_12;
int VAR_13 = ff_jpeg2000_getsgnctxno(VAR_0->flags[VAR_8+1][VAR_7+1], &VAR_12);
ff_mqc_encode(&VAR_0->mqc, VAR_0->mqc.cx_states + VAR_13, (VAR_0->flags[VAR_8+1][VAR_7+1] >> 15) ^ VAR_12);
*VAR_4 += getnmsedec_sig(VAR_0->data[VAR_8][VAR_7], VAR_5 + NMSEDEC_FRACBITS);
ff_jpeg2000_set_significance(VAR_0, VAR_7, VAR_8, VAR_0->flags[VAR_8+1][VAR_7+1] >> 15);
}
VAR_0->flags[VAR_8+1][VAR_7+1] |= JPEG2000_T1_VIS;
}
}
}
|
[
"static void FUNC_0(Jpeg2000T1Context *VAR_0, int VAR_1, int VAR_2, int VAR_3, int *VAR_4, int VAR_5)\n{",
"int VAR_6, VAR_7, VAR_8, VAR_9 = 1 << (VAR_5 + NMSEDEC_FRACBITS);",
"for (VAR_6 = 0; VAR_6 < VAR_2; VAR_6 += 4)",
"for (VAR_7 = 0; VAR_7 < VAR_1; VAR_7++)",
"for (VAR_8 = VAR_6; VAR_8 < VAR_2 && VAR_8 < VAR_6+4; VAR_8++){",
"if (!(VAR_0->flags[VAR_8+1][VAR_7+1] & JPEG2000_T1_SIG) && (VAR_0->flags[VAR_8+1][VAR_7+1] & JPEG2000_T1_SIG_NB)){",
"int VAR_13 = ff_jpeg2000_getsigctxno(VAR_0->flags[VAR_8+1][VAR_7+1], VAR_3),\nVAR_11 = VAR_0->data[VAR_8][VAR_7] & VAR_9 ? 1 : 0;",
"ff_mqc_encode(&VAR_0->mqc, VAR_0->mqc.cx_states + VAR_13, VAR_11);",
"if (VAR_11){",
"int VAR_12;",
"int VAR_13 = ff_jpeg2000_getsgnctxno(VAR_0->flags[VAR_8+1][VAR_7+1], &VAR_12);",
"ff_mqc_encode(&VAR_0->mqc, VAR_0->mqc.cx_states + VAR_13, (VAR_0->flags[VAR_8+1][VAR_7+1] >> 15) ^ VAR_12);",
"*VAR_4 += getnmsedec_sig(VAR_0->data[VAR_8][VAR_7], VAR_5 + NMSEDEC_FRACBITS);",
"ff_jpeg2000_set_significance(VAR_0, VAR_7, VAR_8, VAR_0->flags[VAR_8+1][VAR_7+1] >> 15);",
"}",
"VAR_0->flags[VAR_8+1][VAR_7+1] |= JPEG2000_T1_VIS;",
"}",
"}",
"}"
] |
[
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
]
] |
12,875
|
static void qdev_set_legacy_property(DeviceState *dev, Visitor *v, void *opaque,
const char *name, Error **errp)
{
Property *prop = opaque;
if (dev->state != DEV_STATE_CREATED) {
error_set(errp, QERR_PERMISSION_DENIED);
return;
}
if (prop->info->parse) {
Error *local_err = NULL;
char *ptr = NULL;
visit_type_str(v, &ptr, name, &local_err);
if (!local_err) {
int ret;
ret = prop->info->parse(dev, prop, ptr);
if (ret != 0) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE,
name, prop->info->name);
}
g_free(ptr);
} else {
error_propagate(errp, local_err);
}
} else {
error_set(errp, QERR_PERMISSION_DENIED);
}
}
| false
|
qemu
|
e3cb6ba65d265f2cc1313ee26e879407ff24663c
|
static void qdev_set_legacy_property(DeviceState *dev, Visitor *v, void *opaque,
const char *name, Error **errp)
{
Property *prop = opaque;
if (dev->state != DEV_STATE_CREATED) {
error_set(errp, QERR_PERMISSION_DENIED);
return;
}
if (prop->info->parse) {
Error *local_err = NULL;
char *ptr = NULL;
visit_type_str(v, &ptr, name, &local_err);
if (!local_err) {
int ret;
ret = prop->info->parse(dev, prop, ptr);
if (ret != 0) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE,
name, prop->info->name);
}
g_free(ptr);
} else {
error_propagate(errp, local_err);
}
} else {
error_set(errp, QERR_PERMISSION_DENIED);
}
}
|
{
"code": [],
"line_no": []
}
|
static void FUNC_0(DeviceState *VAR_0, Visitor *VAR_1, void *VAR_2,
const char *VAR_3, Error **VAR_4)
{
Property *prop = VAR_2;
if (VAR_0->state != DEV_STATE_CREATED) {
error_set(VAR_4, QERR_PERMISSION_DENIED);
return;
}
if (prop->info->parse) {
Error *local_err = NULL;
char *VAR_5 = NULL;
visit_type_str(VAR_1, &VAR_5, VAR_3, &local_err);
if (!local_err) {
int VAR_6;
VAR_6 = prop->info->parse(VAR_0, prop, VAR_5);
if (VAR_6 != 0) {
error_set(VAR_4, QERR_INVALID_PARAMETER_VALUE,
VAR_3, prop->info->VAR_3);
}
g_free(VAR_5);
} else {
error_propagate(VAR_4, local_err);
}
} else {
error_set(VAR_4, QERR_PERMISSION_DENIED);
}
}
|
[
"static void FUNC_0(DeviceState *VAR_0, Visitor *VAR_1, void *VAR_2,\nconst char *VAR_3, Error **VAR_4)\n{",
"Property *prop = VAR_2;",
"if (VAR_0->state != DEV_STATE_CREATED) {",
"error_set(VAR_4, QERR_PERMISSION_DENIED);",
"return;",
"}",
"if (prop->info->parse) {",
"Error *local_err = NULL;",
"char *VAR_5 = NULL;",
"visit_type_str(VAR_1, &VAR_5, VAR_3, &local_err);",
"if (!local_err) {",
"int VAR_6;",
"VAR_6 = prop->info->parse(VAR_0, prop, VAR_5);",
"if (VAR_6 != 0) {",
"error_set(VAR_4, QERR_INVALID_PARAMETER_VALUE,\nVAR_3, prop->info->VAR_3);",
"}",
"g_free(VAR_5);",
"} else {",
"error_propagate(VAR_4, local_err);",
"}",
"} else {",
"error_set(VAR_4, QERR_PERMISSION_DENIED);",
"}",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
]
] |
12,876
|
static void channel_load_d(struct fs_dma_ctrl *ctrl, int c)
{
target_phys_addr_t addr = channel_reg(ctrl, c, RW_SAVED_DATA);
/* Load and decode. FIXME: handle endianness. */
D(printf("%s ch=%d addr=" TARGET_FMT_plx "\n", __func__, c, addr));
cpu_physical_memory_read (addr,
(void *) &ctrl->channels[c].current_d,
sizeof ctrl->channels[c].current_d);
D(dump_d(c, &ctrl->channels[c].current_d));
ctrl->channels[c].regs[RW_DATA] = addr;
}
| false
|
qemu
|
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
|
static void channel_load_d(struct fs_dma_ctrl *ctrl, int c)
{
target_phys_addr_t addr = channel_reg(ctrl, c, RW_SAVED_DATA);
D(printf("%s ch=%d addr=" TARGET_FMT_plx "\n", __func__, c, addr));
cpu_physical_memory_read (addr,
(void *) &ctrl->channels[c].current_d,
sizeof ctrl->channels[c].current_d);
D(dump_d(c, &ctrl->channels[c].current_d));
ctrl->channels[c].regs[RW_DATA] = addr;
}
|
{
"code": [],
"line_no": []
}
|
static void FUNC_0(struct fs_dma_ctrl *VAR_0, int VAR_1)
{
target_phys_addr_t addr = channel_reg(VAR_0, VAR_1, RW_SAVED_DATA);
D(printf("%s ch=%d addr=" TARGET_FMT_plx "\n", __func__, VAR_1, addr));
cpu_physical_memory_read (addr,
(void *) &VAR_0->channels[VAR_1].current_d,
sizeof VAR_0->channels[VAR_1].current_d);
D(dump_d(VAR_1, &VAR_0->channels[VAR_1].current_d));
VAR_0->channels[VAR_1].regs[RW_DATA] = addr;
}
|
[
"static void FUNC_0(struct fs_dma_ctrl *VAR_0, int VAR_1)\n{",
"target_phys_addr_t addr = channel_reg(VAR_0, VAR_1, RW_SAVED_DATA);",
"D(printf(\"%s ch=%d addr=\" TARGET_FMT_plx \"\\n\", __func__, VAR_1, addr));",
"cpu_physical_memory_read (addr,\n(void *) &VAR_0->channels[VAR_1].current_d,\nsizeof VAR_0->channels[VAR_1].current_d);",
"D(dump_d(VAR_1, &VAR_0->channels[VAR_1].current_d));",
"VAR_0->channels[VAR_1].regs[RW_DATA] = addr;",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
11
],
[
13,
15,
17
],
[
21
],
[
23
],
[
25
]
] |
12,877
|
static int xenfb_map_fb(struct XenFB *xenfb)
{
struct xenfb_page *page = xenfb->c.page;
char *protocol = xenfb->c.xendev.protocol;
int n_fbdirs;
unsigned long *pgmfns = NULL;
unsigned long *fbmfns = NULL;
void *map, *pd;
int mode, ret = -1;
/* default to native */
pd = page->pd;
mode = sizeof(unsigned long) * 8;
if (!protocol) {
/*
* Undefined protocol, some guesswork needed.
*
* Old frontends which don't set the protocol use
* one page directory only, thus pd[1] must be zero.
* pd[1] of the 32bit struct layout and the lower
* 32 bits of pd[0] of the 64bit struct layout have
* the same location, so we can check that ...
*/
uint32_t *ptr32 = NULL;
uint32_t *ptr64 = NULL;
#if defined(__i386__)
ptr32 = (void*)page->pd;
ptr64 = ((void*)page->pd) + 4;
#elif defined(__x86_64__)
ptr32 = ((void*)page->pd) - 4;
ptr64 = (void*)page->pd;
#endif
if (ptr32) {
if (ptr32[1] == 0) {
mode = 32;
pd = ptr32;
} else {
mode = 64;
pd = ptr64;
}
}
#if defined(__x86_64__)
} else if (strcmp(protocol, XEN_IO_PROTO_ABI_X86_32) == 0) {
/* 64bit dom0, 32bit domU */
mode = 32;
pd = ((void*)page->pd) - 4;
#elif defined(__i386__)
} else if (strcmp(protocol, XEN_IO_PROTO_ABI_X86_64) == 0) {
/* 32bit dom0, 64bit domU */
mode = 64;
pd = ((void*)page->pd) + 4;
#endif
}
if (xenfb->pixels) {
munmap(xenfb->pixels, xenfb->fbpages * XC_PAGE_SIZE);
xenfb->pixels = NULL;
}
xenfb->fbpages = (xenfb->fb_len + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE;
n_fbdirs = xenfb->fbpages * mode / 8;
n_fbdirs = (n_fbdirs + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE;
pgmfns = g_malloc0(sizeof(unsigned long) * n_fbdirs);
fbmfns = g_malloc0(sizeof(unsigned long) * xenfb->fbpages);
xenfb_copy_mfns(mode, n_fbdirs, pgmfns, pd);
map = xc_map_foreign_pages(xen_xc, xenfb->c.xendev.dom,
PROT_READ, pgmfns, n_fbdirs);
if (map == NULL)
goto out;
xenfb_copy_mfns(mode, xenfb->fbpages, fbmfns, map);
munmap(map, n_fbdirs * XC_PAGE_SIZE);
xenfb->pixels = xc_map_foreign_pages(xen_xc, xenfb->c.xendev.dom,
PROT_READ | PROT_WRITE, fbmfns, xenfb->fbpages);
if (xenfb->pixels == NULL)
goto out;
ret = 0; /* all is fine */
out:
g_free(pgmfns);
g_free(fbmfns);
return ret;
}
| false
|
qemu
|
0193c62c94643a837832f2b5ccc133434ee740cb
|
static int xenfb_map_fb(struct XenFB *xenfb)
{
struct xenfb_page *page = xenfb->c.page;
char *protocol = xenfb->c.xendev.protocol;
int n_fbdirs;
unsigned long *pgmfns = NULL;
unsigned long *fbmfns = NULL;
void *map, *pd;
int mode, ret = -1;
pd = page->pd;
mode = sizeof(unsigned long) * 8;
if (!protocol) {
uint32_t *ptr32 = NULL;
uint32_t *ptr64 = NULL;
#if defined(__i386__)
ptr32 = (void*)page->pd;
ptr64 = ((void*)page->pd) + 4;
#elif defined(__x86_64__)
ptr32 = ((void*)page->pd) - 4;
ptr64 = (void*)page->pd;
#endif
if (ptr32) {
if (ptr32[1] == 0) {
mode = 32;
pd = ptr32;
} else {
mode = 64;
pd = ptr64;
}
}
#if defined(__x86_64__)
} else if (strcmp(protocol, XEN_IO_PROTO_ABI_X86_32) == 0) {
mode = 32;
pd = ((void*)page->pd) - 4;
#elif defined(__i386__)
} else if (strcmp(protocol, XEN_IO_PROTO_ABI_X86_64) == 0) {
mode = 64;
pd = ((void*)page->pd) + 4;
#endif
}
if (xenfb->pixels) {
munmap(xenfb->pixels, xenfb->fbpages * XC_PAGE_SIZE);
xenfb->pixels = NULL;
}
xenfb->fbpages = (xenfb->fb_len + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE;
n_fbdirs = xenfb->fbpages * mode / 8;
n_fbdirs = (n_fbdirs + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE;
pgmfns = g_malloc0(sizeof(unsigned long) * n_fbdirs);
fbmfns = g_malloc0(sizeof(unsigned long) * xenfb->fbpages);
xenfb_copy_mfns(mode, n_fbdirs, pgmfns, pd);
map = xc_map_foreign_pages(xen_xc, xenfb->c.xendev.dom,
PROT_READ, pgmfns, n_fbdirs);
if (map == NULL)
goto out;
xenfb_copy_mfns(mode, xenfb->fbpages, fbmfns, map);
munmap(map, n_fbdirs * XC_PAGE_SIZE);
xenfb->pixels = xc_map_foreign_pages(xen_xc, xenfb->c.xendev.dom,
PROT_READ | PROT_WRITE, fbmfns, xenfb->fbpages);
if (xenfb->pixels == NULL)
goto out;
ret = 0;
out:
g_free(pgmfns);
g_free(fbmfns);
return ret;
}
|
{
"code": [],
"line_no": []
}
|
static int FUNC_0(struct XenFB *VAR_0)
{
struct xenfb_page *VAR_1 = VAR_0->c.VAR_1;
char *VAR_2 = VAR_0->c.xendev.VAR_2;
int VAR_3;
unsigned long *VAR_4 = NULL;
unsigned long *VAR_5 = NULL;
void *VAR_6, *VAR_7;
int VAR_8, VAR_9 = -1;
VAR_7 = VAR_1->VAR_7;
VAR_8 = sizeof(unsigned long) * 8;
if (!VAR_2) {
uint32_t *ptr32 = NULL;
uint32_t *ptr64 = NULL;
#if defined(__i386__)
ptr32 = (void*)VAR_1->VAR_7;
ptr64 = ((void*)VAR_1->VAR_7) + 4;
#elif defined(__x86_64__)
ptr32 = ((void*)VAR_1->VAR_7) - 4;
ptr64 = (void*)VAR_1->VAR_7;
#endif
if (ptr32) {
if (ptr32[1] == 0) {
VAR_8 = 32;
VAR_7 = ptr32;
} else {
VAR_8 = 64;
VAR_7 = ptr64;
}
}
#if defined(__x86_64__)
} else if (strcmp(VAR_2, XEN_IO_PROTO_ABI_X86_32) == 0) {
VAR_8 = 32;
VAR_7 = ((void*)VAR_1->VAR_7) - 4;
#elif defined(__i386__)
} else if (strcmp(VAR_2, XEN_IO_PROTO_ABI_X86_64) == 0) {
VAR_8 = 64;
VAR_7 = ((void*)VAR_1->VAR_7) + 4;
#endif
}
if (VAR_0->pixels) {
munmap(VAR_0->pixels, VAR_0->fbpages * XC_PAGE_SIZE);
VAR_0->pixels = NULL;
}
VAR_0->fbpages = (VAR_0->fb_len + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE;
VAR_3 = VAR_0->fbpages * VAR_8 / 8;
VAR_3 = (VAR_3 + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE;
VAR_4 = g_malloc0(sizeof(unsigned long) * VAR_3);
VAR_5 = g_malloc0(sizeof(unsigned long) * VAR_0->fbpages);
xenfb_copy_mfns(VAR_8, VAR_3, VAR_4, VAR_7);
VAR_6 = xc_map_foreign_pages(xen_xc, VAR_0->c.xendev.dom,
PROT_READ, VAR_4, VAR_3);
if (VAR_6 == NULL)
goto out;
xenfb_copy_mfns(VAR_8, VAR_0->fbpages, VAR_5, VAR_6);
munmap(VAR_6, VAR_3 * XC_PAGE_SIZE);
VAR_0->pixels = xc_map_foreign_pages(xen_xc, VAR_0->c.xendev.dom,
PROT_READ | PROT_WRITE, VAR_5, VAR_0->fbpages);
if (VAR_0->pixels == NULL)
goto out;
VAR_9 = 0;
out:
g_free(VAR_4);
g_free(VAR_5);
return VAR_9;
}
|
[
"static int FUNC_0(struct XenFB *VAR_0)\n{",
"struct xenfb_page *VAR_1 = VAR_0->c.VAR_1;",
"char *VAR_2 = VAR_0->c.xendev.VAR_2;",
"int VAR_3;",
"unsigned long *VAR_4 = NULL;",
"unsigned long *VAR_5 = NULL;",
"void *VAR_6, *VAR_7;",
"int VAR_8, VAR_9 = -1;",
"VAR_7 = VAR_1->VAR_7;",
"VAR_8 = sizeof(unsigned long) * 8;",
"if (!VAR_2) {",
"uint32_t *ptr32 = NULL;",
"uint32_t *ptr64 = NULL;",
"#if defined(__i386__)\nptr32 = (void*)VAR_1->VAR_7;",
"ptr64 = ((void*)VAR_1->VAR_7) + 4;",
"#elif defined(__x86_64__)\nptr32 = ((void*)VAR_1->VAR_7) - 4;",
"ptr64 = (void*)VAR_1->VAR_7;",
"#endif\nif (ptr32) {",
"if (ptr32[1] == 0) {",
"VAR_8 = 32;",
"VAR_7 = ptr32;",
"} else {",
"VAR_8 = 64;",
"VAR_7 = ptr64;",
"}",
"}",
"#if defined(__x86_64__)\n} else if (strcmp(VAR_2, XEN_IO_PROTO_ABI_X86_32) == 0) {",
"VAR_8 = 32;",
"VAR_7 = ((void*)VAR_1->VAR_7) - 4;",
"#elif defined(__i386__)\n} else if (strcmp(VAR_2, XEN_IO_PROTO_ABI_X86_64) == 0) {",
"VAR_8 = 64;",
"VAR_7 = ((void*)VAR_1->VAR_7) + 4;",
"#endif\n}",
"if (VAR_0->pixels) {",
"munmap(VAR_0->pixels, VAR_0->fbpages * XC_PAGE_SIZE);",
"VAR_0->pixels = NULL;",
"}",
"VAR_0->fbpages = (VAR_0->fb_len + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE;",
"VAR_3 = VAR_0->fbpages * VAR_8 / 8;",
"VAR_3 = (VAR_3 + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE;",
"VAR_4 = g_malloc0(sizeof(unsigned long) * VAR_3);",
"VAR_5 = g_malloc0(sizeof(unsigned long) * VAR_0->fbpages);",
"xenfb_copy_mfns(VAR_8, VAR_3, VAR_4, VAR_7);",
"VAR_6 = xc_map_foreign_pages(xen_xc, VAR_0->c.xendev.dom,\nPROT_READ, VAR_4, VAR_3);",
"if (VAR_6 == NULL)\ngoto out;",
"xenfb_copy_mfns(VAR_8, VAR_0->fbpages, VAR_5, VAR_6);",
"munmap(VAR_6, VAR_3 * XC_PAGE_SIZE);",
"VAR_0->pixels = xc_map_foreign_pages(xen_xc, VAR_0->c.xendev.dom,\nPROT_READ | PROT_WRITE, VAR_5, VAR_0->fbpages);",
"if (VAR_0->pixels == NULL)\ngoto out;",
"VAR_9 = 0;",
"out:\ng_free(VAR_4);",
"g_free(VAR_5);",
"return VAR_9;",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
],
[
29
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59,
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85,
87
],
[
91
],
[
93
],
[
95,
97
],
[
101
],
[
103
],
[
105,
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
135
],
[
137,
139
],
[
141,
143
],
[
145
],
[
147
],
[
151,
153
],
[
155,
157
],
[
161
],
[
165,
167
],
[
169
],
[
171
],
[
173
]
] |
12,878
|
static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)
{
if (n < 32) {
GET_REGL(env->active_tc.gpr[n]);
}
if (env->CP0_Config1 & (1 << CP0C1_FP)) {
if (n >= 38 && n < 70) {
if (env->CP0_Status & (1 << CP0St_FR))
GET_REGL(env->active_fpu.fpr[n - 38].d);
else
GET_REGL(env->active_fpu.fpr[n - 38].w[FP_ENDIAN_IDX]);
}
switch (n) {
case 70: GET_REGL((int32_t)env->active_fpu.fcr31);
case 71: GET_REGL((int32_t)env->active_fpu.fcr0);
}
}
switch (n) {
case 32: GET_REGL((int32_t)env->CP0_Status);
case 33: GET_REGL(env->active_tc.LO[0]);
case 34: GET_REGL(env->active_tc.HI[0]);
case 35: GET_REGL(env->CP0_BadVAddr);
case 36: GET_REGL((int32_t)env->CP0_Cause);
case 37: GET_REGL(env->active_tc.PC);
case 72: GET_REGL(0); /* fp */
case 89: GET_REGL((int32_t)env->CP0_PRid);
}
if (n >= 73 && n <= 88) {
/* 16 embedded regs. */
GET_REGL(0);
}
return 0;
}
| false
|
qemu
|
ff1d1977ffe1c276f5937a6ad4b6a5b6d2b1c6ae
|
static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)
{
if (n < 32) {
GET_REGL(env->active_tc.gpr[n]);
}
if (env->CP0_Config1 & (1 << CP0C1_FP)) {
if (n >= 38 && n < 70) {
if (env->CP0_Status & (1 << CP0St_FR))
GET_REGL(env->active_fpu.fpr[n - 38].d);
else
GET_REGL(env->active_fpu.fpr[n - 38].w[FP_ENDIAN_IDX]);
}
switch (n) {
case 70: GET_REGL((int32_t)env->active_fpu.fcr31);
case 71: GET_REGL((int32_t)env->active_fpu.fcr0);
}
}
switch (n) {
case 32: GET_REGL((int32_t)env->CP0_Status);
case 33: GET_REGL(env->active_tc.LO[0]);
case 34: GET_REGL(env->active_tc.HI[0]);
case 35: GET_REGL(env->CP0_BadVAddr);
case 36: GET_REGL((int32_t)env->CP0_Cause);
case 37: GET_REGL(env->active_tc.PC);
case 72: GET_REGL(0);
case 89: GET_REGL((int32_t)env->CP0_PRid);
}
if (n >= 73 && n <= 88) {
GET_REGL(0);
}
return 0;
}
|
{
"code": [],
"line_no": []
}
|
static int FUNC_0(CPUState *VAR_0, uint8_t *VAR_1, int VAR_2)
{
if (VAR_2 < 32) {
GET_REGL(VAR_0->active_tc.gpr[VAR_2]);
}
if (VAR_0->CP0_Config1 & (1 << CP0C1_FP)) {
if (VAR_2 >= 38 && VAR_2 < 70) {
if (VAR_0->CP0_Status & (1 << CP0St_FR))
GET_REGL(VAR_0->active_fpu.fpr[VAR_2 - 38].d);
else
GET_REGL(VAR_0->active_fpu.fpr[VAR_2 - 38].w[FP_ENDIAN_IDX]);
}
switch (VAR_2) {
case 70: GET_REGL((int32_t)VAR_0->active_fpu.fcr31);
case 71: GET_REGL((int32_t)VAR_0->active_fpu.fcr0);
}
}
switch (VAR_2) {
case 32: GET_REGL((int32_t)VAR_0->CP0_Status);
case 33: GET_REGL(VAR_0->active_tc.LO[0]);
case 34: GET_REGL(VAR_0->active_tc.HI[0]);
case 35: GET_REGL(VAR_0->CP0_BadVAddr);
case 36: GET_REGL((int32_t)VAR_0->CP0_Cause);
case 37: GET_REGL(VAR_0->active_tc.PC);
case 72: GET_REGL(0);
case 89: GET_REGL((int32_t)VAR_0->CP0_PRid);
}
if (VAR_2 >= 73 && VAR_2 <= 88) {
GET_REGL(0);
}
return 0;
}
|
[
"static int FUNC_0(CPUState *VAR_0, uint8_t *VAR_1, int VAR_2)\n{",
"if (VAR_2 < 32) {",
"GET_REGL(VAR_0->active_tc.gpr[VAR_2]);",
"}",
"if (VAR_0->CP0_Config1 & (1 << CP0C1_FP)) {",
"if (VAR_2 >= 38 && VAR_2 < 70) {",
"if (VAR_0->CP0_Status & (1 << CP0St_FR))\nGET_REGL(VAR_0->active_fpu.fpr[VAR_2 - 38].d);",
"else\nGET_REGL(VAR_0->active_fpu.fpr[VAR_2 - 38].w[FP_ENDIAN_IDX]);",
"}",
"switch (VAR_2) {",
"case 70: GET_REGL((int32_t)VAR_0->active_fpu.fcr31);",
"case 71: GET_REGL((int32_t)VAR_0->active_fpu.fcr0);",
"}",
"}",
"switch (VAR_2) {",
"case 32: GET_REGL((int32_t)VAR_0->CP0_Status);",
"case 33: GET_REGL(VAR_0->active_tc.LO[0]);",
"case 34: GET_REGL(VAR_0->active_tc.HI[0]);",
"case 35: GET_REGL(VAR_0->CP0_BadVAddr);",
"case 36: GET_REGL((int32_t)VAR_0->CP0_Cause);",
"case 37: GET_REGL(VAR_0->active_tc.PC);",
"case 72: GET_REGL(0);",
"case 89: GET_REGL((int32_t)VAR_0->CP0_PRid);",
"}",
"if (VAR_2 >= 73 && VAR_2 <= 88) {",
"GET_REGL(0);",
"}",
"return 0;",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15,
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
65
],
[
67
]
] |
12,879
|
static int update_rom_mapping(VAPICROMState *s, CPUX86State *env, target_ulong ip)
{
target_phys_addr_t paddr;
uint32_t rom_state_vaddr;
uint32_t pos, patch, offset;
/* nothing to do if already activated */
if (s->state == VAPIC_ACTIVE) {
return 0;
}
/* bail out if ROM init code was not executed (missing ROM?) */
if (s->state == VAPIC_INACTIVE) {
return -1;
}
/* find out virtual address of the ROM */
rom_state_vaddr = s->rom_state_paddr + (ip & 0xf0000000);
paddr = cpu_get_phys_page_debug(env, rom_state_vaddr);
if (paddr == -1) {
return -1;
}
paddr += rom_state_vaddr & ~TARGET_PAGE_MASK;
if (paddr != s->rom_state_paddr) {
return -1;
}
read_guest_rom_state(s);
if (memcmp(s->rom_state.signature, "kvm aPiC", 8) != 0) {
return -1;
}
s->rom_state_vaddr = rom_state_vaddr;
/* fixup addresses in ROM if needed */
if (rom_state_vaddr == le32_to_cpu(s->rom_state.vaddr)) {
return 0;
}
for (pos = le32_to_cpu(s->rom_state.fixup_start);
pos < le32_to_cpu(s->rom_state.fixup_end);
pos += 4) {
cpu_physical_memory_rw(paddr + pos - s->rom_state.vaddr,
(void *)&offset, sizeof(offset), 0);
offset = le32_to_cpu(offset);
cpu_physical_memory_rw(paddr + offset, (void *)&patch,
sizeof(patch), 0);
patch = le32_to_cpu(patch);
patch += rom_state_vaddr - le32_to_cpu(s->rom_state.vaddr);
patch = cpu_to_le32(patch);
cpu_physical_memory_rw(paddr + offset, (void *)&patch,
sizeof(patch), 1);
}
read_guest_rom_state(s);
s->vapic_paddr = paddr + le32_to_cpu(s->rom_state.vapic_vaddr) -
le32_to_cpu(s->rom_state.vaddr);
return 0;
}
| false
|
qemu
|
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
|
static int update_rom_mapping(VAPICROMState *s, CPUX86State *env, target_ulong ip)
{
target_phys_addr_t paddr;
uint32_t rom_state_vaddr;
uint32_t pos, patch, offset;
if (s->state == VAPIC_ACTIVE) {
return 0;
}
if (s->state == VAPIC_INACTIVE) {
return -1;
}
rom_state_vaddr = s->rom_state_paddr + (ip & 0xf0000000);
paddr = cpu_get_phys_page_debug(env, rom_state_vaddr);
if (paddr == -1) {
return -1;
}
paddr += rom_state_vaddr & ~TARGET_PAGE_MASK;
if (paddr != s->rom_state_paddr) {
return -1;
}
read_guest_rom_state(s);
if (memcmp(s->rom_state.signature, "kvm aPiC", 8) != 0) {
return -1;
}
s->rom_state_vaddr = rom_state_vaddr;
if (rom_state_vaddr == le32_to_cpu(s->rom_state.vaddr)) {
return 0;
}
for (pos = le32_to_cpu(s->rom_state.fixup_start);
pos < le32_to_cpu(s->rom_state.fixup_end);
pos += 4) {
cpu_physical_memory_rw(paddr + pos - s->rom_state.vaddr,
(void *)&offset, sizeof(offset), 0);
offset = le32_to_cpu(offset);
cpu_physical_memory_rw(paddr + offset, (void *)&patch,
sizeof(patch), 0);
patch = le32_to_cpu(patch);
patch += rom_state_vaddr - le32_to_cpu(s->rom_state.vaddr);
patch = cpu_to_le32(patch);
cpu_physical_memory_rw(paddr + offset, (void *)&patch,
sizeof(patch), 1);
}
read_guest_rom_state(s);
s->vapic_paddr = paddr + le32_to_cpu(s->rom_state.vapic_vaddr) -
le32_to_cpu(s->rom_state.vaddr);
return 0;
}
|
{
"code": [],
"line_no": []
}
|
static int FUNC_0(VAPICROMState *VAR_0, CPUX86State *VAR_1, target_ulong VAR_2)
{
target_phys_addr_t paddr;
uint32_t rom_state_vaddr;
uint32_t pos, patch, offset;
if (VAR_0->state == VAPIC_ACTIVE) {
return 0;
}
if (VAR_0->state == VAPIC_INACTIVE) {
return -1;
}
rom_state_vaddr = VAR_0->rom_state_paddr + (VAR_2 & 0xf0000000);
paddr = cpu_get_phys_page_debug(VAR_1, rom_state_vaddr);
if (paddr == -1) {
return -1;
}
paddr += rom_state_vaddr & ~TARGET_PAGE_MASK;
if (paddr != VAR_0->rom_state_paddr) {
return -1;
}
read_guest_rom_state(VAR_0);
if (memcmp(VAR_0->rom_state.signature, "kvm aPiC", 8) != 0) {
return -1;
}
VAR_0->rom_state_vaddr = rom_state_vaddr;
if (rom_state_vaddr == le32_to_cpu(VAR_0->rom_state.vaddr)) {
return 0;
}
for (pos = le32_to_cpu(VAR_0->rom_state.fixup_start);
pos < le32_to_cpu(VAR_0->rom_state.fixup_end);
pos += 4) {
cpu_physical_memory_rw(paddr + pos - VAR_0->rom_state.vaddr,
(void *)&offset, sizeof(offset), 0);
offset = le32_to_cpu(offset);
cpu_physical_memory_rw(paddr + offset, (void *)&patch,
sizeof(patch), 0);
patch = le32_to_cpu(patch);
patch += rom_state_vaddr - le32_to_cpu(VAR_0->rom_state.vaddr);
patch = cpu_to_le32(patch);
cpu_physical_memory_rw(paddr + offset, (void *)&patch,
sizeof(patch), 1);
}
read_guest_rom_state(VAR_0);
VAR_0->vapic_paddr = paddr + le32_to_cpu(VAR_0->rom_state.vapic_vaddr) -
le32_to_cpu(VAR_0->rom_state.vaddr);
return 0;
}
|
[
"static int FUNC_0(VAPICROMState *VAR_0, CPUX86State *VAR_1, target_ulong VAR_2)\n{",
"target_phys_addr_t paddr;",
"uint32_t rom_state_vaddr;",
"uint32_t pos, patch, offset;",
"if (VAR_0->state == VAPIC_ACTIVE) {",
"return 0;",
"}",
"if (VAR_0->state == VAPIC_INACTIVE) {",
"return -1;",
"}",
"rom_state_vaddr = VAR_0->rom_state_paddr + (VAR_2 & 0xf0000000);",
"paddr = cpu_get_phys_page_debug(VAR_1, rom_state_vaddr);",
"if (paddr == -1) {",
"return -1;",
"}",
"paddr += rom_state_vaddr & ~TARGET_PAGE_MASK;",
"if (paddr != VAR_0->rom_state_paddr) {",
"return -1;",
"}",
"read_guest_rom_state(VAR_0);",
"if (memcmp(VAR_0->rom_state.signature, \"kvm aPiC\", 8) != 0) {",
"return -1;",
"}",
"VAR_0->rom_state_vaddr = rom_state_vaddr;",
"if (rom_state_vaddr == le32_to_cpu(VAR_0->rom_state.vaddr)) {",
"return 0;",
"}",
"for (pos = le32_to_cpu(VAR_0->rom_state.fixup_start);",
"pos < le32_to_cpu(VAR_0->rom_state.fixup_end);",
"pos += 4) {",
"cpu_physical_memory_rw(paddr + pos - VAR_0->rom_state.vaddr,\n(void *)&offset, sizeof(offset), 0);",
"offset = le32_to_cpu(offset);",
"cpu_physical_memory_rw(paddr + offset, (void *)&patch,\nsizeof(patch), 0);",
"patch = le32_to_cpu(patch);",
"patch += rom_state_vaddr - le32_to_cpu(VAR_0->rom_state.vaddr);",
"patch = cpu_to_le32(patch);",
"cpu_physical_memory_rw(paddr + offset, (void *)&patch,\nsizeof(patch), 1);",
"}",
"read_guest_rom_state(VAR_0);",
"VAR_0->vapic_paddr = paddr + le32_to_cpu(VAR_0->rom_state.vapic_vaddr) -\nle32_to_cpu(VAR_0->rom_state.vaddr);",
"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
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
19
],
[
25
],
[
27
],
[
29
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79,
81
],
[
83
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
95,
97
],
[
99
],
[
101
],
[
103,
105
],
[
109
],
[
111
]
] |
12,880
|
void omap_badwidth_write32(void *opaque, target_phys_addr_t addr,
uint32_t value)
{
OMAP_32B_REG(addr);
cpu_physical_memory_write(addr, (void *) &value, 4);
}
| false
|
qemu
|
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
|
void omap_badwidth_write32(void *opaque, target_phys_addr_t addr,
uint32_t value)
{
OMAP_32B_REG(addr);
cpu_physical_memory_write(addr, (void *) &value, 4);
}
|
{
"code": [],
"line_no": []
}
|
void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint32_t VAR_2)
{
OMAP_32B_REG(VAR_1);
cpu_physical_memory_write(VAR_1, (void *) &VAR_2, 4);
}
|
[
"void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint32_t VAR_2)\n{",
"OMAP_32B_REG(VAR_1);",
"cpu_physical_memory_write(VAR_1, (void *) &VAR_2, 4);",
"}"
] |
[
0,
0,
0,
0
] |
[
[
1,
3,
5
],
[
7
],
[
9
],
[
11
]
] |
12,881
|
static void file_put_buffer(void *opaque, const uint8_t *buf,
int64_t pos, int size)
{
QEMUFileStdio *s = opaque;
fseek(s->outfile, pos, SEEK_SET);
fwrite(buf, 1, size, s->outfile);
}
| false
|
qemu
|
871d2f079661323a7645b388eb5ae8d7eeb3117c
|
static void file_put_buffer(void *opaque, const uint8_t *buf,
int64_t pos, int size)
{
QEMUFileStdio *s = opaque;
fseek(s->outfile, pos, SEEK_SET);
fwrite(buf, 1, size, s->outfile);
}
|
{
"code": [],
"line_no": []
}
|
static void FUNC_0(void *VAR_0, const uint8_t *VAR_1,
int64_t VAR_2, int VAR_3)
{
QEMUFileStdio *s = VAR_0;
fseek(s->outfile, VAR_2, SEEK_SET);
fwrite(VAR_1, 1, VAR_3, s->outfile);
}
|
[
"static void FUNC_0(void *VAR_0, const uint8_t *VAR_1,\nint64_t VAR_2, int VAR_3)\n{",
"QEMUFileStdio *s = VAR_0;",
"fseek(s->outfile, VAR_2, SEEK_SET);",
"fwrite(VAR_1, 1, VAR_3, s->outfile);",
"}"
] |
[
0,
0,
0,
0,
0
] |
[
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
12,882
|
void qio_channel_socket_connect_async(QIOChannelSocket *ioc,
SocketAddress *addr,
QIOTaskFunc callback,
gpointer opaque,
GDestroyNotify destroy)
{
QIOTask *task = qio_task_new(
OBJECT(ioc), callback, opaque, destroy);
SocketAddress *addrCopy;
addrCopy = QAPI_CLONE(SocketAddress, addr);
/* socket_connect() does a non-blocking connect(), but it
* still blocks in DNS lookups, so we must use a thread */
trace_qio_channel_socket_connect_async(ioc, addr);
qio_task_run_in_thread(task,
qio_channel_socket_connect_worker,
addrCopy,
(GDestroyNotify)qapi_free_SocketAddress);
}
| false
|
qemu
|
dfd100f242370886bb6732f70f1f7cbd8eb9fedc
|
void qio_channel_socket_connect_async(QIOChannelSocket *ioc,
SocketAddress *addr,
QIOTaskFunc callback,
gpointer opaque,
GDestroyNotify destroy)
{
QIOTask *task = qio_task_new(
OBJECT(ioc), callback, opaque, destroy);
SocketAddress *addrCopy;
addrCopy = QAPI_CLONE(SocketAddress, addr);
trace_qio_channel_socket_connect_async(ioc, addr);
qio_task_run_in_thread(task,
qio_channel_socket_connect_worker,
addrCopy,
(GDestroyNotify)qapi_free_SocketAddress);
}
|
{
"code": [],
"line_no": []
}
|
void FUNC_0(QIOChannelSocket *VAR_0,
SocketAddress *VAR_1,
QIOTaskFunc VAR_2,
gpointer VAR_3,
GDestroyNotify VAR_4)
{
QIOTask *task = qio_task_new(
OBJECT(VAR_0), VAR_2, VAR_3, VAR_4);
SocketAddress *addrCopy;
addrCopy = QAPI_CLONE(SocketAddress, VAR_1);
trace_qio_channel_socket_connect_async(VAR_0, VAR_1);
qio_task_run_in_thread(task,
qio_channel_socket_connect_worker,
addrCopy,
(GDestroyNotify)qapi_free_SocketAddress);
}
|
[
"void FUNC_0(QIOChannelSocket *VAR_0,\nSocketAddress *VAR_1,\nQIOTaskFunc VAR_2,\ngpointer VAR_3,\nGDestroyNotify VAR_4)\n{",
"QIOTask *task = qio_task_new(\nOBJECT(VAR_0), VAR_2, VAR_3, VAR_4);",
"SocketAddress *addrCopy;",
"addrCopy = QAPI_CLONE(SocketAddress, VAR_1);",
"trace_qio_channel_socket_connect_async(VAR_0, VAR_1);",
"qio_task_run_in_thread(task,\nqio_channel_socket_connect_worker,\naddrCopy,\n(GDestroyNotify)qapi_free_SocketAddress);",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3,
5,
7,
9,
11
],
[
13,
15
],
[
17
],
[
21
],
[
29
],
[
31,
33,
35,
37
],
[
39
]
] |
12,883
|
connect_to_qemu(
const char *host,
const char *port
) {
struct addrinfo hints;
struct addrinfo *server;
int ret, sock;
sock = qemu_socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0) {
/* Error */
fprintf(stderr, "Error opening socket!\n");
return -1;
}
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = 0;
hints.ai_protocol = 0; /* Any protocol */
ret = getaddrinfo(host, port, &hints, &server);
if (ret != 0) {
/* Error */
fprintf(stderr, "getaddrinfo failed\n");
goto cleanup_socket;
}
if (connect(sock, server->ai_addr, server->ai_addrlen) < 0) {
/* Error */
fprintf(stderr, "Could not connect\n");
goto cleanup_socket;
}
if (verbose) {
printf("Connected (sizeof Header=%zd)!\n", sizeof(VSCMsgHeader));
}
return sock;
cleanup_socket:
closesocket(sock);
return -1;
}
| false
|
qemu
|
2a0c46da967e5dc8cfe73b1b6fe7a1600c04f461
|
connect_to_qemu(
const char *host,
const char *port
) {
struct addrinfo hints;
struct addrinfo *server;
int ret, sock;
sock = qemu_socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0) {
fprintf(stderr, "Error opening socket!\n");
return -1;
}
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = 0;
hints.ai_protocol = 0;
ret = getaddrinfo(host, port, &hints, &server);
if (ret != 0) {
fprintf(stderr, "getaddrinfo failed\n");
goto cleanup_socket;
}
if (connect(sock, server->ai_addr, server->ai_addrlen) < 0) {
fprintf(stderr, "Could not connect\n");
goto cleanup_socket;
}
if (verbose) {
printf("Connected (sizeof Header=%zd)!\n", sizeof(VSCMsgHeader));
}
return sock;
cleanup_socket:
closesocket(sock);
return -1;
}
|
{
"code": [],
"line_no": []
}
|
FUNC_0(
const char *VAR_0,
const char *VAR_1
) {
struct addrinfo VAR_2;
struct addrinfo *VAR_3;
int VAR_4, VAR_5;
VAR_5 = qemu_socket(AF_INET, SOCK_STREAM, 0);
if (VAR_5 < 0) {
fprintf(stderr, "Error opening socket!\n");
return -1;
}
memset(&VAR_2, 0, sizeof(struct addrinfo));
VAR_2.ai_family = AF_UNSPEC;
VAR_2.ai_socktype = SOCK_STREAM;
VAR_2.ai_flags = 0;
VAR_2.ai_protocol = 0;
VAR_4 = getaddrinfo(VAR_0, VAR_1, &VAR_2, &VAR_3);
if (VAR_4 != 0) {
fprintf(stderr, "getaddrinfo failed\n");
goto cleanup_socket;
}
if (connect(VAR_5, VAR_3->ai_addr, VAR_3->ai_addrlen) < 0) {
fprintf(stderr, "Could not connect\n");
goto cleanup_socket;
}
if (verbose) {
printf("Connected (sizeof Header=%zd)!\n", sizeof(VSCMsgHeader));
}
return VAR_5;
cleanup_socket:
closesocket(VAR_5);
return -1;
}
|
[
"FUNC_0(\nconst char *VAR_0,\nconst char *VAR_1\n) {",
"struct addrinfo VAR_2;",
"struct addrinfo *VAR_3;",
"int VAR_4, VAR_5;",
"VAR_5 = qemu_socket(AF_INET, SOCK_STREAM, 0);",
"if (VAR_5 < 0) {",
"fprintf(stderr, \"Error opening socket!\\n\");",
"return -1;",
"}",
"memset(&VAR_2, 0, sizeof(struct addrinfo));",
"VAR_2.ai_family = AF_UNSPEC;",
"VAR_2.ai_socktype = SOCK_STREAM;",
"VAR_2.ai_flags = 0;",
"VAR_2.ai_protocol = 0;",
"VAR_4 = getaddrinfo(VAR_0, VAR_1, &VAR_2, &VAR_3);",
"if (VAR_4 != 0) {",
"fprintf(stderr, \"getaddrinfo failed\\n\");",
"goto cleanup_socket;",
"}",
"if (connect(VAR_5, VAR_3->ai_addr, VAR_3->ai_addrlen) < 0) {",
"fprintf(stderr, \"Could not connect\\n\");",
"goto cleanup_socket;",
"}",
"if (verbose) {",
"printf(\"Connected (sizeof Header=%zd)!\\n\", sizeof(VSCMsgHeader));",
"}",
"return VAR_5;",
"cleanup_socket:\nclosesocket(VAR_5);",
"return -1;",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
47
],
[
51
],
[
53
],
[
55
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79,
81
],
[
83
],
[
85
]
] |
12,884
|
static inline uint32_t efsctuiz(uint32_t val)
{
CPU_FloatU u;
u.l = val;
/* NaN are not treated the same way IEEE 754 does */
if (unlikely(float32_is_nan(u.f)))
return 0;
return float32_to_uint32_round_to_zero(u.f, &env->vec_status);
}
| false
|
qemu
|
185698715dfb18c82ad2a5dbc169908602d43e81
|
static inline uint32_t efsctuiz(uint32_t val)
{
CPU_FloatU u;
u.l = val;
if (unlikely(float32_is_nan(u.f)))
return 0;
return float32_to_uint32_round_to_zero(u.f, &env->vec_status);
}
|
{
"code": [],
"line_no": []
}
|
static inline uint32_t FUNC_0(uint32_t val)
{
CPU_FloatU u;
u.l = val;
if (unlikely(float32_is_nan(u.f)))
return 0;
return float32_to_uint32_round_to_zero(u.f, &env->vec_status);
}
|
[
"static inline uint32_t FUNC_0(uint32_t val)\n{",
"CPU_FloatU u;",
"u.l = val;",
"if (unlikely(float32_is_nan(u.f)))\nreturn 0;",
"return float32_to_uint32_round_to_zero(u.f, &env->vec_status);",
"}"
] |
[
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
9
],
[
13,
15
],
[
19
],
[
21
]
] |
12,885
|
static int escape(char **dst, const char *src, const char *special_chars,
enum EscapeMode mode)
{
AVBPrint dstbuf;
av_bprint_init(&dstbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
switch (mode) {
case ESCAPE_MODE_FULL:
case ESCAPE_MODE_LAZY:
/* \-escape characters */
if (mode == ESCAPE_MODE_LAZY && strchr(WHITESPACES, *src))
av_bprintf(&dstbuf, "\\%c", *src++);
for (; *src; src++) {
if ((special_chars && strchr(special_chars, *src)) ||
strchr("'\\", *src) ||
(mode == ESCAPE_MODE_FULL && strchr(WHITESPACES, *src)))
av_bprintf(&dstbuf, "\\%c", *src);
else
av_bprint_chars(&dstbuf, *src, 1);
}
if (mode == ESCAPE_MODE_LAZY && strchr(WHITESPACES, dstbuf.str[dstbuf.len-1])) {
char c = dstbuf.str[dstbuf.len-1];
dstbuf.str[dstbuf.len-1] = '\\';
av_bprint_chars(&dstbuf, c, 1);
}
break;
case ESCAPE_MODE_QUOTE:
/* enclose between '' the string */
av_bprint_chars(&dstbuf, '\'', 1);
for (; *src; src++) {
if (*src == '\'')
av_bprintf(&dstbuf, "'\\''");
else
av_bprint_chars(&dstbuf, *src, 1);
}
av_bprint_chars(&dstbuf, '\'', 1);
break;
default:
/* unknown escape mode */
return AVERROR(EINVAL);
}
if (!av_bprint_is_complete(&dstbuf)) {
av_bprint_finalize(&dstbuf, NULL);
return AVERROR(ENOMEM);
} else {
av_bprint_finalize(&dstbuf, dst);
return 0;
}
}
| false
|
FFmpeg
|
9767ec6b865c35f68cb6642fefeacc009f17e638
|
static int escape(char **dst, const char *src, const char *special_chars,
enum EscapeMode mode)
{
AVBPrint dstbuf;
av_bprint_init(&dstbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
switch (mode) {
case ESCAPE_MODE_FULL:
case ESCAPE_MODE_LAZY:
if (mode == ESCAPE_MODE_LAZY && strchr(WHITESPACES, *src))
av_bprintf(&dstbuf, "\\%c", *src++);
for (; *src; src++) {
if ((special_chars && strchr(special_chars, *src)) ||
strchr("'\\", *src) ||
(mode == ESCAPE_MODE_FULL && strchr(WHITESPACES, *src)))
av_bprintf(&dstbuf, "\\%c", *src);
else
av_bprint_chars(&dstbuf, *src, 1);
}
if (mode == ESCAPE_MODE_LAZY && strchr(WHITESPACES, dstbuf.str[dstbuf.len-1])) {
char c = dstbuf.str[dstbuf.len-1];
dstbuf.str[dstbuf.len-1] = '\\';
av_bprint_chars(&dstbuf, c, 1);
}
break;
case ESCAPE_MODE_QUOTE:
av_bprint_chars(&dstbuf, '\'', 1);
for (; *src; src++) {
if (*src == '\'')
av_bprintf(&dstbuf, "'\\''");
else
av_bprint_chars(&dstbuf, *src, 1);
}
av_bprint_chars(&dstbuf, '\'', 1);
break;
default:
return AVERROR(EINVAL);
}
if (!av_bprint_is_complete(&dstbuf)) {
av_bprint_finalize(&dstbuf, NULL);
return AVERROR(ENOMEM);
} else {
av_bprint_finalize(&dstbuf, dst);
return 0;
}
}
|
{
"code": [],
"line_no": []
}
|
static int FUNC_0(char **VAR_0, const char *VAR_1, const char *VAR_2,
enum EscapeMode VAR_3)
{
AVBPrint dstbuf;
av_bprint_init(&dstbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
switch (VAR_3) {
case ESCAPE_MODE_FULL:
case ESCAPE_MODE_LAZY:
if (VAR_3 == ESCAPE_MODE_LAZY && strchr(WHITESPACES, *VAR_1))
av_bprintf(&dstbuf, "\\%VAR_4", *VAR_1++);
for (; *VAR_1; VAR_1++) {
if ((VAR_2 && strchr(VAR_2, *VAR_1)) ||
strchr("'\\", *VAR_1) ||
(VAR_3 == ESCAPE_MODE_FULL && strchr(WHITESPACES, *VAR_1)))
av_bprintf(&dstbuf, "\\%VAR_4", *VAR_1);
else
av_bprint_chars(&dstbuf, *VAR_1, 1);
}
if (VAR_3 == ESCAPE_MODE_LAZY && strchr(WHITESPACES, dstbuf.str[dstbuf.len-1])) {
char VAR_4 = dstbuf.str[dstbuf.len-1];
dstbuf.str[dstbuf.len-1] = '\\';
av_bprint_chars(&dstbuf, VAR_4, 1);
}
break;
case ESCAPE_MODE_QUOTE:
av_bprint_chars(&dstbuf, '\'', 1);
for (; *VAR_1; VAR_1++) {
if (*VAR_1 == '\'')
av_bprintf(&dstbuf, "'\\''");
else
av_bprint_chars(&dstbuf, *VAR_1, 1);
}
av_bprint_chars(&dstbuf, '\'', 1);
break;
default:
return AVERROR(EINVAL);
}
if (!av_bprint_is_complete(&dstbuf)) {
av_bprint_finalize(&dstbuf, NULL);
return AVERROR(ENOMEM);
} else {
av_bprint_finalize(&dstbuf, VAR_0);
return 0;
}
}
|
[
"static int FUNC_0(char **VAR_0, const char *VAR_1, const char *VAR_2,\nenum EscapeMode VAR_3)\n{",
"AVBPrint dstbuf;",
"av_bprint_init(&dstbuf, 1, AV_BPRINT_SIZE_UNLIMITED);",
"switch (VAR_3) {",
"case ESCAPE_MODE_FULL:\ncase ESCAPE_MODE_LAZY:\nif (VAR_3 == ESCAPE_MODE_LAZY && strchr(WHITESPACES, *VAR_1))\nav_bprintf(&dstbuf, \"\\\\%VAR_4\", *VAR_1++);",
"for (; *VAR_1; VAR_1++) {",
"if ((VAR_2 && strchr(VAR_2, *VAR_1)) ||\nstrchr(\"'\\\\\", *VAR_1) ||\n(VAR_3 == ESCAPE_MODE_FULL && strchr(WHITESPACES, *VAR_1)))\nav_bprintf(&dstbuf, \"\\\\%VAR_4\", *VAR_1);",
"else\nav_bprint_chars(&dstbuf, *VAR_1, 1);",
"}",
"if (VAR_3 == ESCAPE_MODE_LAZY && strchr(WHITESPACES, dstbuf.str[dstbuf.len-1])) {",
"char VAR_4 = dstbuf.str[dstbuf.len-1];",
"dstbuf.str[dstbuf.len-1] = '\\\\';",
"av_bprint_chars(&dstbuf, VAR_4, 1);",
"}",
"break;",
"case ESCAPE_MODE_QUOTE:\nav_bprint_chars(&dstbuf, '\\'', 1);",
"for (; *VAR_1; VAR_1++) {",
"if (*VAR_1 == '\\'')\nav_bprintf(&dstbuf, \"'\\\\''\");",
"else\nav_bprint_chars(&dstbuf, *VAR_1, 1);",
"}",
"av_bprint_chars(&dstbuf, '\\'', 1);",
"break;",
"default:\nreturn AVERROR(EINVAL);",
"}",
"if (!av_bprint_is_complete(&dstbuf)) {",
"av_bprint_finalize(&dstbuf, NULL);",
"return AVERROR(ENOMEM);",
"} else {",
"av_bprint_finalize(&dstbuf, VAR_0);",
"return 0;",
"}",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3,
5
],
[
7
],
[
11
],
[
15
],
[
17,
19,
25,
27
],
[
31
],
[
33,
35,
37,
39
],
[
41,
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63,
67
],
[
69
],
[
71,
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
87,
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
]
] |
12,886
|
static void spapr_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(oc);
FWPathProviderClass *fwc = FW_PATH_PROVIDER_CLASS(oc);
NMIClass *nc = NMI_CLASS(oc);
HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
mc->desc = "pSeries Logical Partition (PAPR compliant)";
/*
* We set up the default / latest behaviour here. The class_init
* functions for the specific versioned machine types can override
* these details for backwards compatibility
*/
mc->init = ppc_spapr_init;
mc->reset = ppc_spapr_reset;
mc->block_default_type = IF_SCSI;
mc->max_cpus = MAX_CPUMASK_BITS;
mc->no_parallel = 1;
mc->default_boot_order = "";
mc->default_ram_size = 512 * M_BYTE;
mc->kvm_type = spapr_kvm_type;
mc->has_dynamic_sysbus = true;
mc->pci_allow_0_address = true;
mc->get_hotplug_handler = spapr_get_hotplug_handler;
hc->pre_plug = spapr_machine_device_pre_plug;
hc->plug = spapr_machine_device_plug;
hc->unplug = spapr_machine_device_unplug;
mc->cpu_index_to_socket_id = spapr_cpu_index_to_socket_id;
smc->dr_lmb_enabled = true;
smc->tcg_default_cpu = "POWER8";
mc->query_hotpluggable_cpus = spapr_query_hotpluggable_cpus;
fwc->get_dev_path = spapr_get_fw_dev_path;
nc->nmi_monitor_handler = spapr_nmi;
smc->phb_placement = spapr_phb_placement;
}
| false
|
qemu
|
079019f2e319bd1279681b6c1d7dde785d09e69e
|
static void spapr_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(oc);
FWPathProviderClass *fwc = FW_PATH_PROVIDER_CLASS(oc);
NMIClass *nc = NMI_CLASS(oc);
HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
mc->desc = "pSeries Logical Partition (PAPR compliant)";
mc->init = ppc_spapr_init;
mc->reset = ppc_spapr_reset;
mc->block_default_type = IF_SCSI;
mc->max_cpus = MAX_CPUMASK_BITS;
mc->no_parallel = 1;
mc->default_boot_order = "";
mc->default_ram_size = 512 * M_BYTE;
mc->kvm_type = spapr_kvm_type;
mc->has_dynamic_sysbus = true;
mc->pci_allow_0_address = true;
mc->get_hotplug_handler = spapr_get_hotplug_handler;
hc->pre_plug = spapr_machine_device_pre_plug;
hc->plug = spapr_machine_device_plug;
hc->unplug = spapr_machine_device_unplug;
mc->cpu_index_to_socket_id = spapr_cpu_index_to_socket_id;
smc->dr_lmb_enabled = true;
smc->tcg_default_cpu = "POWER8";
mc->query_hotpluggable_cpus = spapr_query_hotpluggable_cpus;
fwc->get_dev_path = spapr_get_fw_dev_path;
nc->nmi_monitor_handler = spapr_nmi;
smc->phb_placement = spapr_phb_placement;
}
|
{
"code": [],
"line_no": []
}
|
static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
MachineClass *mc = MACHINE_CLASS(VAR_0);
sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(VAR_0);
FWPathProviderClass *fwc = FW_PATH_PROVIDER_CLASS(VAR_0);
NMIClass *nc = NMI_CLASS(VAR_0);
HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(VAR_0);
mc->desc = "pSeries Logical Partition (PAPR compliant)";
mc->init = ppc_spapr_init;
mc->reset = ppc_spapr_reset;
mc->block_default_type = IF_SCSI;
mc->max_cpus = MAX_CPUMASK_BITS;
mc->no_parallel = 1;
mc->default_boot_order = "";
mc->default_ram_size = 512 * M_BYTE;
mc->kvm_type = spapr_kvm_type;
mc->has_dynamic_sysbus = true;
mc->pci_allow_0_address = true;
mc->get_hotplug_handler = spapr_get_hotplug_handler;
hc->pre_plug = spapr_machine_device_pre_plug;
hc->plug = spapr_machine_device_plug;
hc->unplug = spapr_machine_device_unplug;
mc->cpu_index_to_socket_id = spapr_cpu_index_to_socket_id;
smc->dr_lmb_enabled = true;
smc->tcg_default_cpu = "POWER8";
mc->query_hotpluggable_cpus = spapr_query_hotpluggable_cpus;
fwc->get_dev_path = spapr_get_fw_dev_path;
nc->nmi_monitor_handler = spapr_nmi;
smc->phb_placement = spapr_phb_placement;
}
|
[
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"MachineClass *mc = MACHINE_CLASS(VAR_0);",
"sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(VAR_0);",
"FWPathProviderClass *fwc = FW_PATH_PROVIDER_CLASS(VAR_0);",
"NMIClass *nc = NMI_CLASS(VAR_0);",
"HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(VAR_0);",
"mc->desc = \"pSeries Logical Partition (PAPR compliant)\";",
"mc->init = ppc_spapr_init;",
"mc->reset = ppc_spapr_reset;",
"mc->block_default_type = IF_SCSI;",
"mc->max_cpus = MAX_CPUMASK_BITS;",
"mc->no_parallel = 1;",
"mc->default_boot_order = \"\";",
"mc->default_ram_size = 512 * M_BYTE;",
"mc->kvm_type = spapr_kvm_type;",
"mc->has_dynamic_sysbus = true;",
"mc->pci_allow_0_address = true;",
"mc->get_hotplug_handler = spapr_get_hotplug_handler;",
"hc->pre_plug = spapr_machine_device_pre_plug;",
"hc->plug = spapr_machine_device_plug;",
"hc->unplug = spapr_machine_device_unplug;",
"mc->cpu_index_to_socket_id = spapr_cpu_index_to_socket_id;",
"smc->dr_lmb_enabled = true;",
"smc->tcg_default_cpu = \"POWER8\";",
"mc->query_hotpluggable_cpus = spapr_query_hotpluggable_cpus;",
"fwc->get_dev_path = spapr_get_fw_dev_path;",
"nc->nmi_monitor_handler = spapr_nmi;",
"smc->phb_placement = spapr_phb_placement;",
"}"
] |
[
0,
0,
0,
0,
0,
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
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
]
] |
12,888
|
static void xen_config_cleanup_dir(char *dir)
{
struct xs_dirs *d;
d = qemu_malloc(sizeof(*d));
d->xs_dir = dir;
TAILQ_INSERT_TAIL(&xs_cleanup, d, list);
}
| false
|
qemu
|
72cf2d4f0e181d0d3a3122e04129c58a95da713e
|
static void xen_config_cleanup_dir(char *dir)
{
struct xs_dirs *d;
d = qemu_malloc(sizeof(*d));
d->xs_dir = dir;
TAILQ_INSERT_TAIL(&xs_cleanup, d, list);
}
|
{
"code": [],
"line_no": []
}
|
static void FUNC_0(char *VAR_0)
{
struct xs_dirs *VAR_1;
VAR_1 = qemu_malloc(sizeof(*VAR_1));
VAR_1->xs_dir = VAR_0;
TAILQ_INSERT_TAIL(&xs_cleanup, VAR_1, list);
}
|
[
"static void FUNC_0(char *VAR_0)\n{",
"struct xs_dirs *VAR_1;",
"VAR_1 = qemu_malloc(sizeof(*VAR_1));",
"VAR_1->xs_dir = VAR_0;",
"TAILQ_INSERT_TAIL(&xs_cleanup, VAR_1, list);",
"}"
] |
[
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
12,889
|
void gen_intermediate_code(CPUSH4State * env, struct TranslationBlock *tb)
{
SuperHCPU *cpu = sh_env_get_cpu(env);
CPUState *cs = CPU(cpu);
DisasContext ctx;
target_ulong pc_start;
int num_insns;
int max_insns;
pc_start = tb->pc;
ctx.pc = pc_start;
ctx.tbflags = (uint32_t)tb->flags;
ctx.envflags = tb->flags & DELAY_SLOT_MASK;
ctx.bstate = BS_NONE;
ctx.memidx = (ctx.tbflags & (1u << SR_MD)) == 0 ? 1 : 0;
/* We don't know if the delayed pc came from a dynamic or static branch,
so assume it is a dynamic branch. */
ctx.delayed_pc = -1; /* use delayed pc from env pointer */
ctx.tb = tb;
ctx.singlestep_enabled = cs->singlestep_enabled;
ctx.features = env->features;
ctx.has_movcal = (ctx.tbflags & TB_FLAG_PENDING_MOVCA);
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0) {
max_insns = CF_COUNT_MASK;
}
if (max_insns > TCG_MAX_INSNS) {
max_insns = TCG_MAX_INSNS;
}
gen_tb_start(tb);
while (ctx.bstate == BS_NONE && !tcg_op_buf_full()) {
tcg_gen_insn_start(ctx.pc, ctx.envflags);
num_insns++;
if (unlikely(cpu_breakpoint_test(cs, ctx.pc, BP_ANY))) {
/* We have hit a breakpoint - make sure PC is up-to-date */
gen_save_cpu_state(&ctx, true);
gen_helper_debug(cpu_env);
ctx.bstate = BS_EXCP;
/* The address covered by the breakpoint must be included in
[tb->pc, tb->pc + tb->size) in order to for it to be
properly cleared -- thus we increment the PC here so that
the logic setting tb->size below does the right thing. */
ctx.pc += 2;
break;
}
if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
}
ctx.opcode = cpu_lduw_code(env, ctx.pc);
decode_opc(&ctx);
ctx.pc += 2;
if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0)
break;
if (cs->singlestep_enabled) {
break;
}
if (num_insns >= max_insns)
break;
if (singlestep)
break;
}
if (tb->cflags & CF_LAST_IO)
gen_io_end();
if (cs->singlestep_enabled) {
gen_save_cpu_state(&ctx, true);
gen_helper_debug(cpu_env);
} else {
switch (ctx.bstate) {
case BS_STOP:
gen_save_cpu_state(&ctx, true);
tcg_gen_exit_tb(0);
break;
case BS_NONE:
gen_save_cpu_state(&ctx, false);
gen_goto_tb(&ctx, 0, ctx.pc);
break;
case BS_EXCP:
/* fall through */
case BS_BRANCH:
default:
break;
}
}
gen_tb_end(tb, num_insns);
tb->size = ctx.pc - pc_start;
tb->icount = num_insns;
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(pc_start)) {
qemu_log_lock();
qemu_log("IN:\n"); /* , lookup_symbol(pc_start)); */
log_target_disas(cs, pc_start, ctx.pc - pc_start, 0);
qemu_log("\n");
qemu_log_unlock();
}
#endif
}
| false
|
qemu
|
4448a83606b5861cfa11528c0395868fc2b0e99e
|
void gen_intermediate_code(CPUSH4State * env, struct TranslationBlock *tb)
{
SuperHCPU *cpu = sh_env_get_cpu(env);
CPUState *cs = CPU(cpu);
DisasContext ctx;
target_ulong pc_start;
int num_insns;
int max_insns;
pc_start = tb->pc;
ctx.pc = pc_start;
ctx.tbflags = (uint32_t)tb->flags;
ctx.envflags = tb->flags & DELAY_SLOT_MASK;
ctx.bstate = BS_NONE;
ctx.memidx = (ctx.tbflags & (1u << SR_MD)) == 0 ? 1 : 0;
ctx.delayed_pc = -1;
ctx.tb = tb;
ctx.singlestep_enabled = cs->singlestep_enabled;
ctx.features = env->features;
ctx.has_movcal = (ctx.tbflags & TB_FLAG_PENDING_MOVCA);
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0) {
max_insns = CF_COUNT_MASK;
}
if (max_insns > TCG_MAX_INSNS) {
max_insns = TCG_MAX_INSNS;
}
gen_tb_start(tb);
while (ctx.bstate == BS_NONE && !tcg_op_buf_full()) {
tcg_gen_insn_start(ctx.pc, ctx.envflags);
num_insns++;
if (unlikely(cpu_breakpoint_test(cs, ctx.pc, BP_ANY))) {
gen_save_cpu_state(&ctx, true);
gen_helper_debug(cpu_env);
ctx.bstate = BS_EXCP;
ctx.pc += 2;
break;
}
if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
}
ctx.opcode = cpu_lduw_code(env, ctx.pc);
decode_opc(&ctx);
ctx.pc += 2;
if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0)
break;
if (cs->singlestep_enabled) {
break;
}
if (num_insns >= max_insns)
break;
if (singlestep)
break;
}
if (tb->cflags & CF_LAST_IO)
gen_io_end();
if (cs->singlestep_enabled) {
gen_save_cpu_state(&ctx, true);
gen_helper_debug(cpu_env);
} else {
switch (ctx.bstate) {
case BS_STOP:
gen_save_cpu_state(&ctx, true);
tcg_gen_exit_tb(0);
break;
case BS_NONE:
gen_save_cpu_state(&ctx, false);
gen_goto_tb(&ctx, 0, ctx.pc);
break;
case BS_EXCP:
case BS_BRANCH:
default:
break;
}
}
gen_tb_end(tb, num_insns);
tb->size = ctx.pc - pc_start;
tb->icount = num_insns;
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(pc_start)) {
qemu_log_lock();
qemu_log("IN:\n");
log_target_disas(cs, pc_start, ctx.pc - pc_start, 0);
qemu_log("\n");
qemu_log_unlock();
}
#endif
}
|
{
"code": [],
"line_no": []
}
|
void FUNC_0(CPUSH4State * VAR_0, struct TranslationBlock *VAR_1)
{
SuperHCPU *cpu = sh_env_get_cpu(VAR_0);
CPUState *cs = CPU(cpu);
DisasContext ctx;
target_ulong pc_start;
int VAR_2;
int VAR_3;
pc_start = VAR_1->pc;
ctx.pc = pc_start;
ctx.tbflags = (uint32_t)VAR_1->flags;
ctx.envflags = VAR_1->flags & DELAY_SLOT_MASK;
ctx.bstate = BS_NONE;
ctx.memidx = (ctx.tbflags & (1u << SR_MD)) == 0 ? 1 : 0;
ctx.delayed_pc = -1;
ctx.VAR_1 = VAR_1;
ctx.singlestep_enabled = cs->singlestep_enabled;
ctx.features = VAR_0->features;
ctx.has_movcal = (ctx.tbflags & TB_FLAG_PENDING_MOVCA);
VAR_2 = 0;
VAR_3 = VAR_1->cflags & CF_COUNT_MASK;
if (VAR_3 == 0) {
VAR_3 = CF_COUNT_MASK;
}
if (VAR_3 > TCG_MAX_INSNS) {
VAR_3 = TCG_MAX_INSNS;
}
gen_tb_start(VAR_1);
while (ctx.bstate == BS_NONE && !tcg_op_buf_full()) {
tcg_gen_insn_start(ctx.pc, ctx.envflags);
VAR_2++;
if (unlikely(cpu_breakpoint_test(cs, ctx.pc, BP_ANY))) {
gen_save_cpu_state(&ctx, true);
gen_helper_debug(cpu_env);
ctx.bstate = BS_EXCP;
ctx.pc += 2;
break;
}
if (VAR_2 == VAR_3 && (VAR_1->cflags & CF_LAST_IO)) {
gen_io_start();
}
ctx.opcode = cpu_lduw_code(VAR_0, ctx.pc);
decode_opc(&ctx);
ctx.pc += 2;
if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0)
break;
if (cs->singlestep_enabled) {
break;
}
if (VAR_2 >= VAR_3)
break;
if (singlestep)
break;
}
if (VAR_1->cflags & CF_LAST_IO)
gen_io_end();
if (cs->singlestep_enabled) {
gen_save_cpu_state(&ctx, true);
gen_helper_debug(cpu_env);
} else {
switch (ctx.bstate) {
case BS_STOP:
gen_save_cpu_state(&ctx, true);
tcg_gen_exit_tb(0);
break;
case BS_NONE:
gen_save_cpu_state(&ctx, false);
gen_goto_tb(&ctx, 0, ctx.pc);
break;
case BS_EXCP:
case BS_BRANCH:
default:
break;
}
}
gen_tb_end(VAR_1, VAR_2);
VAR_1->size = ctx.pc - pc_start;
VAR_1->icount = VAR_2;
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(pc_start)) {
qemu_log_lock();
qemu_log("IN:\n");
log_target_disas(cs, pc_start, ctx.pc - pc_start, 0);
qemu_log("\n");
qemu_log_unlock();
}
#endif
}
|
[
"void FUNC_0(CPUSH4State * VAR_0, struct TranslationBlock *VAR_1)\n{",
"SuperHCPU *cpu = sh_env_get_cpu(VAR_0);",
"CPUState *cs = CPU(cpu);",
"DisasContext ctx;",
"target_ulong pc_start;",
"int VAR_2;",
"int VAR_3;",
"pc_start = VAR_1->pc;",
"ctx.pc = pc_start;",
"ctx.tbflags = (uint32_t)VAR_1->flags;",
"ctx.envflags = VAR_1->flags & DELAY_SLOT_MASK;",
"ctx.bstate = BS_NONE;",
"ctx.memidx = (ctx.tbflags & (1u << SR_MD)) == 0 ? 1 : 0;",
"ctx.delayed_pc = -1;",
"ctx.VAR_1 = VAR_1;",
"ctx.singlestep_enabled = cs->singlestep_enabled;",
"ctx.features = VAR_0->features;",
"ctx.has_movcal = (ctx.tbflags & TB_FLAG_PENDING_MOVCA);",
"VAR_2 = 0;",
"VAR_3 = VAR_1->cflags & CF_COUNT_MASK;",
"if (VAR_3 == 0) {",
"VAR_3 = CF_COUNT_MASK;",
"}",
"if (VAR_3 > TCG_MAX_INSNS) {",
"VAR_3 = TCG_MAX_INSNS;",
"}",
"gen_tb_start(VAR_1);",
"while (ctx.bstate == BS_NONE && !tcg_op_buf_full()) {",
"tcg_gen_insn_start(ctx.pc, ctx.envflags);",
"VAR_2++;",
"if (unlikely(cpu_breakpoint_test(cs, ctx.pc, BP_ANY))) {",
"gen_save_cpu_state(&ctx, true);",
"gen_helper_debug(cpu_env);",
"ctx.bstate = BS_EXCP;",
"ctx.pc += 2;",
"break;",
"}",
"if (VAR_2 == VAR_3 && (VAR_1->cflags & CF_LAST_IO)) {",
"gen_io_start();",
"}",
"ctx.opcode = cpu_lduw_code(VAR_0, ctx.pc);",
"decode_opc(&ctx);",
"ctx.pc += 2;",
"if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0)\nbreak;",
"if (cs->singlestep_enabled) {",
"break;",
"}",
"if (VAR_2 >= VAR_3)\nbreak;",
"if (singlestep)\nbreak;",
"}",
"if (VAR_1->cflags & CF_LAST_IO)\ngen_io_end();",
"if (cs->singlestep_enabled) {",
"gen_save_cpu_state(&ctx, true);",
"gen_helper_debug(cpu_env);",
"} else {",
"switch (ctx.bstate) {",
"case BS_STOP:\ngen_save_cpu_state(&ctx, true);",
"tcg_gen_exit_tb(0);",
"break;",
"case BS_NONE:\ngen_save_cpu_state(&ctx, false);",
"gen_goto_tb(&ctx, 0, ctx.pc);",
"break;",
"case BS_EXCP:\ncase BS_BRANCH:\ndefault:\nbreak;",
"}",
"}",
"gen_tb_end(VAR_1, VAR_2);",
"VAR_1->size = ctx.pc - pc_start;",
"VAR_1->icount = VAR_2;",
"#ifdef DEBUG_DISAS\nif (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)\n&& qemu_log_in_addr_range(pc_start)) {",
"qemu_log_lock();",
"qemu_log(\"IN:\\n\");",
"log_target_disas(cs, pc_start, ctx.pc - pc_start, 0);",
"qemu_log(\"\\n\");",
"qemu_log_unlock();",
"}",
"#endif\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
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
79
],
[
81
],
[
83
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
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,
169,
171,
173
],
[
175
],
[
177
],
[
181
],
[
185
],
[
187
],
[
191,
193,
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209,
211
]
] |
12,890
|
void OPPROTO op_cli(void)
{
raise_exception(EXCP0D_GPF);
}
| false
|
qemu
|
504e56ebdca53bf8e8d379aa994e90a2e3b0d564
|
void OPPROTO op_cli(void)
{
raise_exception(EXCP0D_GPF);
}
|
{
"code": [],
"line_no": []
}
|
void VAR_0 op_cli(void)
{
raise_exception(EXCP0D_GPF);
}
|
[
"void VAR_0 op_cli(void)\n{",
"raise_exception(EXCP0D_GPF);",
"}"
] |
[
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
]
] |
12,891
|
static void tgen_ext16u(TCGContext *s, TCGType type, TCGReg dest, TCGReg src)
{
if (facilities & FACILITY_EXT_IMM) {
tcg_out_insn(s, RRE, LLGHR, dest, src);
return;
}
if (dest == src) {
tcg_out_movi(s, type, TCG_TMP0, 0xffff);
src = TCG_TMP0;
} else {
tcg_out_movi(s, type, dest, 0xffff);
}
if (type == TCG_TYPE_I32) {
tcg_out_insn(s, RR, NR, dest, src);
} else {
tcg_out_insn(s, RRE, NGR, dest, src);
}
}
| false
|
qemu
|
b2c98d9d392c87c9b9e975d30f79924719d9cbbe
|
static void tgen_ext16u(TCGContext *s, TCGType type, TCGReg dest, TCGReg src)
{
if (facilities & FACILITY_EXT_IMM) {
tcg_out_insn(s, RRE, LLGHR, dest, src);
return;
}
if (dest == src) {
tcg_out_movi(s, type, TCG_TMP0, 0xffff);
src = TCG_TMP0;
} else {
tcg_out_movi(s, type, dest, 0xffff);
}
if (type == TCG_TYPE_I32) {
tcg_out_insn(s, RR, NR, dest, src);
} else {
tcg_out_insn(s, RRE, NGR, dest, src);
}
}
|
{
"code": [],
"line_no": []
}
|
static void FUNC_0(TCGContext *VAR_0, TCGType VAR_1, TCGReg VAR_2, TCGReg VAR_3)
{
if (facilities & FACILITY_EXT_IMM) {
tcg_out_insn(VAR_0, RRE, LLGHR, VAR_2, VAR_3);
return;
}
if (VAR_2 == VAR_3) {
tcg_out_movi(VAR_0, VAR_1, TCG_TMP0, 0xffff);
VAR_3 = TCG_TMP0;
} else {
tcg_out_movi(VAR_0, VAR_1, VAR_2, 0xffff);
}
if (VAR_1 == TCG_TYPE_I32) {
tcg_out_insn(VAR_0, RR, NR, VAR_2, VAR_3);
} else {
tcg_out_insn(VAR_0, RRE, NGR, VAR_2, VAR_3);
}
}
|
[
"static void FUNC_0(TCGContext *VAR_0, TCGType VAR_1, TCGReg VAR_2, TCGReg VAR_3)\n{",
"if (facilities & FACILITY_EXT_IMM) {",
"tcg_out_insn(VAR_0, RRE, LLGHR, VAR_2, VAR_3);",
"return;",
"}",
"if (VAR_2 == VAR_3) {",
"tcg_out_movi(VAR_0, VAR_1, TCG_TMP0, 0xffff);",
"VAR_3 = TCG_TMP0;",
"} else {",
"tcg_out_movi(VAR_0, VAR_1, VAR_2, 0xffff);",
"}",
"if (VAR_1 == TCG_TYPE_I32) {",
"tcg_out_insn(VAR_0, RR, NR, VAR_2, VAR_3);",
"} else {",
"tcg_out_insn(VAR_0, RRE, NGR, VAR_2, VAR_3);",
"}",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
12,892
|
void mips_malta_init(QEMUMachineInitArgs *args)
{
ram_addr_t ram_size = args->ram_size;
const char *cpu_model = args->cpu_model;
const char *kernel_filename = args->kernel_filename;
const char *kernel_cmdline = args->kernel_cmdline;
const char *initrd_filename = args->initrd_filename;
char *filename;
pflash_t *fl;
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *bios, *bios_copy = g_new(MemoryRegion, 1);
target_long bios_size = FLASH_SIZE;
int64_t kernel_entry;
PCIBus *pci_bus;
ISABus *isa_bus;
MIPSCPU *cpu;
CPUMIPSState *env;
qemu_irq *isa_irq;
qemu_irq *cpu_exit_irq;
int piix4_devfn;
i2c_bus *smbus;
int i;
DriveInfo *dinfo;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *fd[MAX_FD];
int fl_idx = 0;
int fl_sectors = bios_size >> 16;
int be;
DeviceState *dev = qdev_create(NULL, TYPE_MIPS_MALTA);
MaltaState *s = MIPS_MALTA(dev);
qdev_init_nofail(dev);
/* Make sure the first 3 serial ports are associated with a device. */
for(i = 0; i < 3; i++) {
if (!serial_hds[i]) {
char label[32];
snprintf(label, sizeof(label), "serial%d", i);
serial_hds[i] = qemu_chr_new(label, "null", NULL);
}
}
/* init CPUs */
if (cpu_model == NULL) {
#ifdef TARGET_MIPS64
cpu_model = "20Kc";
#else
cpu_model = "24Kf";
#endif
}
for (i = 0; i < smp_cpus; i++) {
cpu = cpu_mips_init(cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
env = &cpu->env;
/* Init internal devices */
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
qemu_register_reset(main_cpu_reset, cpu);
}
cpu = MIPS_CPU(first_cpu);
env = &cpu->env;
/* allocate RAM */
if (ram_size > (256 << 20)) {
fprintf(stderr,
"qemu: Too much memory for this machine: %d MB, maximum 256 MB\n",
((unsigned int)ram_size / (1 << 20)));
exit(1);
}
memory_region_init_ram(ram, NULL, "mips_malta.ram", ram_size);
vmstate_register_ram_global(ram);
memory_region_add_subregion(system_memory, 0, ram);
/* generate SPD EEPROM data */
eeprom_generate(&eeprom, ram_size);
#ifdef TARGET_WORDS_BIGENDIAN
be = 1;
#else
be = 0;
#endif
/* FPGA */
/* The CBUS UART is attached to the MIPS CPU INT2 pin, ie interrupt 4 */
malta_fpga_init(system_memory, FPGA_ADDRESS, env->irq[4], serial_hds[2]);
/* Load firmware in flash / BIOS. */
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
#ifdef DEBUG_BOARD_INIT
if (dinfo) {
printf("Register parallel flash %d size " TARGET_FMT_lx " at "
"addr %08llx '%s' %x\n",
fl_idx, bios_size, FLASH_ADDRESS,
bdrv_get_device_name(dinfo->bdrv), fl_sectors);
}
#endif
fl = pflash_cfi01_register(FLASH_ADDRESS, NULL, "mips_malta.bios",
BIOS_SIZE, dinfo ? dinfo->bdrv : NULL,
65536, fl_sectors,
4, 0x0000, 0x0000, 0x0000, 0x0000, be);
bios = pflash_cfi01_get_memory(fl);
fl_idx++;
if (kernel_filename) {
/* Write a small bootloader to the flash location. */
loaderparams.ram_size = ram_size;
loaderparams.kernel_filename = kernel_filename;
loaderparams.kernel_cmdline = kernel_cmdline;
loaderparams.initrd_filename = initrd_filename;
kernel_entry = load_kernel();
write_bootloader(env, memory_region_get_ram_ptr(bios), kernel_entry);
} else {
/* Load firmware from flash. */
if (!dinfo) {
/* Load a BIOS image. */
if (bios_name == NULL) {
bios_name = BIOS_FILENAME;
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_image_targphys(filename, FLASH_ADDRESS,
BIOS_SIZE);
g_free(filename);
} else {
bios_size = -1;
}
if ((bios_size < 0 || bios_size > BIOS_SIZE) && !kernel_filename) {
fprintf(stderr,
"qemu: Warning, could not load MIPS bios '%s', and no -kernel argument was specified\n",
bios_name);
}
}
/* In little endian mode the 32bit words in the bios are swapped,
a neat trick which allows bi-endian firmware. */
#ifndef TARGET_WORDS_BIGENDIAN
{
uint32_t *end, *addr = rom_ptr(FLASH_ADDRESS);
if (!addr) {
addr = memory_region_get_ram_ptr(bios);
}
end = (void *)addr + MIN(bios_size, 0x3e0000);
while (addr < end) {
bswap32s(addr);
addr++;
}
}
#endif
}
/*
* Map the BIOS at a 2nd physical location, as on the real board.
* Copy it so that we can patch in the MIPS revision, which cannot be
* handled by an overlapping region as the resulting ROM code subpage
* regions are not executable.
*/
memory_region_init_ram(bios_copy, NULL, "bios.1fc", BIOS_SIZE);
if (!rom_copy(memory_region_get_ram_ptr(bios_copy),
FLASH_ADDRESS, bios_size)) {
memcpy(memory_region_get_ram_ptr(bios_copy),
memory_region_get_ram_ptr(bios), bios_size);
}
memory_region_set_readonly(bios_copy, true);
memory_region_add_subregion(system_memory, RESET_ADDRESS, bios_copy);
/* Board ID = 0x420 (Malta Board with CoreLV) */
stl_p(memory_region_get_ram_ptr(bios_copy) + 0x10, 0x00000420);
/* Init internal devices */
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
/*
* We have a circular dependency problem: pci_bus depends on isa_irq,
* isa_irq is provided by i8259, i8259 depends on ISA, ISA depends
* on piix4, and piix4 depends on pci_bus. To stop the cycle we have
* qemu_irq_proxy() adds an extra bit of indirection, allowing us
* to resolve the isa_irq -> i8259 dependency after i8259 is initialized.
*/
isa_irq = qemu_irq_proxy(&s->i8259, 16);
/* Northbridge */
pci_bus = gt64120_register(isa_irq);
/* Southbridge */
ide_drive_get(hd, MAX_IDE_BUS);
piix4_devfn = piix4_init(pci_bus, &isa_bus, 80);
/* Interrupt controller */
/* The 8259 is attached to the MIPS CPU INT0 pin, ie interrupt 2 */
s->i8259 = i8259_init(isa_bus, env->irq[2]);
isa_bus_irqs(isa_bus, s->i8259);
pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1);
pci_create_simple(pci_bus, piix4_devfn + 2, "piix4-usb-uhci");
smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100,
isa_get_irq(NULL, 9), NULL, 0, NULL);
/* TODO: Populate SPD eeprom data. */
smbus_eeprom_init(smbus, 8, NULL, 0);
pit = pit_init(isa_bus, 0x40, 0, NULL);
cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
DMA_init(0, cpu_exit_irq);
/* Super I/O */
isa_create_simple(isa_bus, "i8042");
rtc_init(isa_bus, 2000, NULL);
serial_isa_init(isa_bus, 0, serial_hds[0]);
serial_isa_init(isa_bus, 1, serial_hds[1]);
if (parallel_hds[0])
parallel_init(isa_bus, 0, parallel_hds[0]);
for(i = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
}
fdctrl_init_isa(isa_bus, fd);
/* Network card */
network_init(pci_bus);
/* Optional PCI video card */
pci_vga_init(pci_bus);
}
| false
|
qemu
|
35c648078aa493c3b976840eb7cf2e53ab5b7a2d
|
void mips_malta_init(QEMUMachineInitArgs *args)
{
ram_addr_t ram_size = args->ram_size;
const char *cpu_model = args->cpu_model;
const char *kernel_filename = args->kernel_filename;
const char *kernel_cmdline = args->kernel_cmdline;
const char *initrd_filename = args->initrd_filename;
char *filename;
pflash_t *fl;
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *bios, *bios_copy = g_new(MemoryRegion, 1);
target_long bios_size = FLASH_SIZE;
int64_t kernel_entry;
PCIBus *pci_bus;
ISABus *isa_bus;
MIPSCPU *cpu;
CPUMIPSState *env;
qemu_irq *isa_irq;
qemu_irq *cpu_exit_irq;
int piix4_devfn;
i2c_bus *smbus;
int i;
DriveInfo *dinfo;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *fd[MAX_FD];
int fl_idx = 0;
int fl_sectors = bios_size >> 16;
int be;
DeviceState *dev = qdev_create(NULL, TYPE_MIPS_MALTA);
MaltaState *s = MIPS_MALTA(dev);
qdev_init_nofail(dev);
for(i = 0; i < 3; i++) {
if (!serial_hds[i]) {
char label[32];
snprintf(label, sizeof(label), "serial%d", i);
serial_hds[i] = qemu_chr_new(label, "null", NULL);
}
}
if (cpu_model == NULL) {
#ifdef TARGET_MIPS64
cpu_model = "20Kc";
#else
cpu_model = "24Kf";
#endif
}
for (i = 0; i < smp_cpus; i++) {
cpu = cpu_mips_init(cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
env = &cpu->env;
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
qemu_register_reset(main_cpu_reset, cpu);
}
cpu = MIPS_CPU(first_cpu);
env = &cpu->env;
if (ram_size > (256 << 20)) {
fprintf(stderr,
"qemu: Too much memory for this machine: %d MB, maximum 256 MB\n",
((unsigned int)ram_size / (1 << 20)));
exit(1);
}
memory_region_init_ram(ram, NULL, "mips_malta.ram", ram_size);
vmstate_register_ram_global(ram);
memory_region_add_subregion(system_memory, 0, ram);
eeprom_generate(&eeprom, ram_size);
#ifdef TARGET_WORDS_BIGENDIAN
be = 1;
#else
be = 0;
#endif
malta_fpga_init(system_memory, FPGA_ADDRESS, env->irq[4], serial_hds[2]);
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
#ifdef DEBUG_BOARD_INIT
if (dinfo) {
printf("Register parallel flash %d size " TARGET_FMT_lx " at "
"addr %08llx '%s' %x\n",
fl_idx, bios_size, FLASH_ADDRESS,
bdrv_get_device_name(dinfo->bdrv), fl_sectors);
}
#endif
fl = pflash_cfi01_register(FLASH_ADDRESS, NULL, "mips_malta.bios",
BIOS_SIZE, dinfo ? dinfo->bdrv : NULL,
65536, fl_sectors,
4, 0x0000, 0x0000, 0x0000, 0x0000, be);
bios = pflash_cfi01_get_memory(fl);
fl_idx++;
if (kernel_filename) {
loaderparams.ram_size = ram_size;
loaderparams.kernel_filename = kernel_filename;
loaderparams.kernel_cmdline = kernel_cmdline;
loaderparams.initrd_filename = initrd_filename;
kernel_entry = load_kernel();
write_bootloader(env, memory_region_get_ram_ptr(bios), kernel_entry);
} else {
if (!dinfo) {
if (bios_name == NULL) {
bios_name = BIOS_FILENAME;
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_image_targphys(filename, FLASH_ADDRESS,
BIOS_SIZE);
g_free(filename);
} else {
bios_size = -1;
}
if ((bios_size < 0 || bios_size > BIOS_SIZE) && !kernel_filename) {
fprintf(stderr,
"qemu: Warning, could not load MIPS bios '%s', and no -kernel argument was specified\n",
bios_name);
}
}
#ifndef TARGET_WORDS_BIGENDIAN
{
uint32_t *end, *addr = rom_ptr(FLASH_ADDRESS);
if (!addr) {
addr = memory_region_get_ram_ptr(bios);
}
end = (void *)addr + MIN(bios_size, 0x3e0000);
while (addr < end) {
bswap32s(addr);
addr++;
}
}
#endif
}
memory_region_init_ram(bios_copy, NULL, "bios.1fc", BIOS_SIZE);
if (!rom_copy(memory_region_get_ram_ptr(bios_copy),
FLASH_ADDRESS, bios_size)) {
memcpy(memory_region_get_ram_ptr(bios_copy),
memory_region_get_ram_ptr(bios), bios_size);
}
memory_region_set_readonly(bios_copy, true);
memory_region_add_subregion(system_memory, RESET_ADDRESS, bios_copy);
stl_p(memory_region_get_ram_ptr(bios_copy) + 0x10, 0x00000420);
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
isa_irq = qemu_irq_proxy(&s->i8259, 16);
pci_bus = gt64120_register(isa_irq);
ide_drive_get(hd, MAX_IDE_BUS);
piix4_devfn = piix4_init(pci_bus, &isa_bus, 80);
s->i8259 = i8259_init(isa_bus, env->irq[2]);
isa_bus_irqs(isa_bus, s->i8259);
pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1);
pci_create_simple(pci_bus, piix4_devfn + 2, "piix4-usb-uhci");
smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100,
isa_get_irq(NULL, 9), NULL, 0, NULL);
smbus_eeprom_init(smbus, 8, NULL, 0);
pit = pit_init(isa_bus, 0x40, 0, NULL);
cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
DMA_init(0, cpu_exit_irq);
isa_create_simple(isa_bus, "i8042");
rtc_init(isa_bus, 2000, NULL);
serial_isa_init(isa_bus, 0, serial_hds[0]);
serial_isa_init(isa_bus, 1, serial_hds[1]);
if (parallel_hds[0])
parallel_init(isa_bus, 0, parallel_hds[0]);
for(i = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
}
fdctrl_init_isa(isa_bus, fd);
network_init(pci_bus);
pci_vga_init(pci_bus);
}
|
{
"code": [],
"line_no": []
}
|
void FUNC_0(QEMUMachineInitArgs *VAR_0)
{
ram_addr_t ram_size = VAR_0->ram_size;
const char *VAR_1 = VAR_0->VAR_1;
const char *VAR_2 = VAR_0->VAR_2;
const char *VAR_3 = VAR_0->VAR_3;
const char *VAR_4 = VAR_0->VAR_4;
char *VAR_5;
pflash_t *fl;
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *bios, *bios_copy = g_new(MemoryRegion, 1);
target_long bios_size = FLASH_SIZE;
int64_t kernel_entry;
PCIBus *pci_bus;
ISABus *isa_bus;
MIPSCPU *cpu;
CPUMIPSState *env;
qemu_irq *isa_irq;
qemu_irq *cpu_exit_irq;
int VAR_6;
i2c_bus *smbus;
int VAR_7;
DriveInfo *dinfo;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *fd[MAX_FD];
int VAR_8 = 0;
int VAR_9 = bios_size >> 16;
int VAR_10;
DeviceState *dev = qdev_create(NULL, TYPE_MIPS_MALTA);
MaltaState *s = MIPS_MALTA(dev);
qdev_init_nofail(dev);
for(VAR_7 = 0; VAR_7 < 3; VAR_7++) {
if (!serial_hds[VAR_7]) {
char VAR_11[32];
snprintf(VAR_11, sizeof(VAR_11), "serial%d", VAR_7);
serial_hds[VAR_7] = qemu_chr_new(VAR_11, "null", NULL);
}
}
if (VAR_1 == NULL) {
#ifdef TARGET_MIPS64
VAR_1 = "20Kc";
#else
VAR_1 = "24Kf";
#endif
}
for (VAR_7 = 0; VAR_7 < smp_cpus; VAR_7++) {
cpu = cpu_mips_init(VAR_1);
if (cpu == NULL) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
env = &cpu->env;
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
qemu_register_reset(main_cpu_reset, cpu);
}
cpu = MIPS_CPU(first_cpu);
env = &cpu->env;
if (ram_size > (256 << 20)) {
fprintf(stderr,
"qemu: Too much memory for this machine: %d MB, maximum 256 MB\n",
((unsigned int)ram_size / (1 << 20)));
exit(1);
}
memory_region_init_ram(ram, NULL, "mips_malta.ram", ram_size);
vmstate_register_ram_global(ram);
memory_region_add_subregion(system_memory, 0, ram);
eeprom_generate(&eeprom, ram_size);
#ifdef TARGET_WORDS_BIGENDIAN
VAR_10 = 1;
#else
VAR_10 = 0;
#endif
malta_fpga_init(system_memory, FPGA_ADDRESS, env->irq[4], serial_hds[2]);
dinfo = drive_get(IF_PFLASH, 0, VAR_8);
#ifdef DEBUG_BOARD_INIT
if (dinfo) {
printf("Register parallel flash %d size " TARGET_FMT_lx " at "
"addr %08llx '%s' %x\n",
VAR_8, bios_size, FLASH_ADDRESS,
bdrv_get_device_name(dinfo->bdrv), VAR_9);
}
#endif
fl = pflash_cfi01_register(FLASH_ADDRESS, NULL, "mips_malta.bios",
BIOS_SIZE, dinfo ? dinfo->bdrv : NULL,
65536, VAR_9,
4, 0x0000, 0x0000, 0x0000, 0x0000, VAR_10);
bios = pflash_cfi01_get_memory(fl);
VAR_8++;
if (VAR_2) {
loaderparams.ram_size = ram_size;
loaderparams.VAR_2 = VAR_2;
loaderparams.VAR_3 = VAR_3;
loaderparams.VAR_4 = VAR_4;
kernel_entry = load_kernel();
write_bootloader(env, memory_region_get_ram_ptr(bios), kernel_entry);
} else {
if (!dinfo) {
if (bios_name == NULL) {
bios_name = BIOS_FILENAME;
}
VAR_5 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (VAR_5) {
bios_size = load_image_targphys(VAR_5, FLASH_ADDRESS,
BIOS_SIZE);
g_free(VAR_5);
} else {
bios_size = -1;
}
if ((bios_size < 0 || bios_size > BIOS_SIZE) && !VAR_2) {
fprintf(stderr,
"qemu: Warning, could not load MIPS bios '%s', and no -kernel argument was specified\n",
bios_name);
}
}
#ifndef TARGET_WORDS_BIGENDIAN
{
uint32_t *end, *addr = rom_ptr(FLASH_ADDRESS);
if (!addr) {
addr = memory_region_get_ram_ptr(bios);
}
end = (void *)addr + MIN(bios_size, 0x3e0000);
while (addr < end) {
bswap32s(addr);
addr++;
}
}
#endif
}
memory_region_init_ram(bios_copy, NULL, "bios.1fc", BIOS_SIZE);
if (!rom_copy(memory_region_get_ram_ptr(bios_copy),
FLASH_ADDRESS, bios_size)) {
memcpy(memory_region_get_ram_ptr(bios_copy),
memory_region_get_ram_ptr(bios), bios_size);
}
memory_region_set_readonly(bios_copy, true);
memory_region_add_subregion(system_memory, RESET_ADDRESS, bios_copy);
stl_p(memory_region_get_ram_ptr(bios_copy) + 0x10, 0x00000420);
cpu_mips_irq_init_cpu(env);
cpu_mips_clock_init(env);
isa_irq = qemu_irq_proxy(&s->i8259, 16);
pci_bus = gt64120_register(isa_irq);
ide_drive_get(hd, MAX_IDE_BUS);
VAR_6 = piix4_init(pci_bus, &isa_bus, 80);
s->i8259 = i8259_init(isa_bus, env->irq[2]);
isa_bus_irqs(isa_bus, s->i8259);
pci_piix4_ide_init(pci_bus, hd, VAR_6 + 1);
pci_create_simple(pci_bus, VAR_6 + 2, "piix4-usb-uhci");
smbus = piix4_pm_init(pci_bus, VAR_6 + 3, 0x1100,
isa_get_irq(NULL, 9), NULL, 0, NULL);
smbus_eeprom_init(smbus, 8, NULL, 0);
pit = pit_init(isa_bus, 0x40, 0, NULL);
cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
DMA_init(0, cpu_exit_irq);
isa_create_simple(isa_bus, "i8042");
rtc_init(isa_bus, 2000, NULL);
serial_isa_init(isa_bus, 0, serial_hds[0]);
serial_isa_init(isa_bus, 1, serial_hds[1]);
if (parallel_hds[0])
parallel_init(isa_bus, 0, parallel_hds[0]);
for(VAR_7 = 0; VAR_7 < MAX_FD; VAR_7++) {
fd[VAR_7] = drive_get(IF_FLOPPY, 0, VAR_7);
}
fdctrl_init_isa(isa_bus, fd);
network_init(pci_bus);
pci_vga_init(pci_bus);
}
|
[
"void FUNC_0(QEMUMachineInitArgs *VAR_0)\n{",
"ram_addr_t ram_size = VAR_0->ram_size;",
"const char *VAR_1 = VAR_0->VAR_1;",
"const char *VAR_2 = VAR_0->VAR_2;",
"const char *VAR_3 = VAR_0->VAR_3;",
"const char *VAR_4 = VAR_0->VAR_4;",
"char *VAR_5;",
"pflash_t *fl;",
"MemoryRegion *system_memory = get_system_memory();",
"MemoryRegion *ram = g_new(MemoryRegion, 1);",
"MemoryRegion *bios, *bios_copy = g_new(MemoryRegion, 1);",
"target_long bios_size = FLASH_SIZE;",
"int64_t kernel_entry;",
"PCIBus *pci_bus;",
"ISABus *isa_bus;",
"MIPSCPU *cpu;",
"CPUMIPSState *env;",
"qemu_irq *isa_irq;",
"qemu_irq *cpu_exit_irq;",
"int VAR_6;",
"i2c_bus *smbus;",
"int VAR_7;",
"DriveInfo *dinfo;",
"DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];",
"DriveInfo *fd[MAX_FD];",
"int VAR_8 = 0;",
"int VAR_9 = bios_size >> 16;",
"int VAR_10;",
"DeviceState *dev = qdev_create(NULL, TYPE_MIPS_MALTA);",
"MaltaState *s = MIPS_MALTA(dev);",
"qdev_init_nofail(dev);",
"for(VAR_7 = 0; VAR_7 < 3; VAR_7++) {",
"if (!serial_hds[VAR_7]) {",
"char VAR_11[32];",
"snprintf(VAR_11, sizeof(VAR_11), \"serial%d\", VAR_7);",
"serial_hds[VAR_7] = qemu_chr_new(VAR_11, \"null\", NULL);",
"}",
"}",
"if (VAR_1 == NULL) {",
"#ifdef TARGET_MIPS64\nVAR_1 = \"20Kc\";",
"#else\nVAR_1 = \"24Kf\";",
"#endif\n}",
"for (VAR_7 = 0; VAR_7 < smp_cpus; VAR_7++) {",
"cpu = cpu_mips_init(VAR_1);",
"if (cpu == NULL) {",
"fprintf(stderr, \"Unable to find CPU definition\\n\");",
"exit(1);",
"}",
"env = &cpu->env;",
"cpu_mips_irq_init_cpu(env);",
"cpu_mips_clock_init(env);",
"qemu_register_reset(main_cpu_reset, cpu);",
"}",
"cpu = MIPS_CPU(first_cpu);",
"env = &cpu->env;",
"if (ram_size > (256 << 20)) {",
"fprintf(stderr,\n\"qemu: Too much memory for this machine: %d MB, maximum 256 MB\\n\",\n((unsigned int)ram_size / (1 << 20)));",
"exit(1);",
"}",
"memory_region_init_ram(ram, NULL, \"mips_malta.ram\", ram_size);",
"vmstate_register_ram_global(ram);",
"memory_region_add_subregion(system_memory, 0, ram);",
"eeprom_generate(&eeprom, ram_size);",
"#ifdef TARGET_WORDS_BIGENDIAN\nVAR_10 = 1;",
"#else\nVAR_10 = 0;",
"#endif\nmalta_fpga_init(system_memory, FPGA_ADDRESS, env->irq[4], serial_hds[2]);",
"dinfo = drive_get(IF_PFLASH, 0, VAR_8);",
"#ifdef DEBUG_BOARD_INIT\nif (dinfo) {",
"printf(\"Register parallel flash %d size \" TARGET_FMT_lx \" at \"\n\"addr %08llx '%s' %x\\n\",\nVAR_8, bios_size, FLASH_ADDRESS,\nbdrv_get_device_name(dinfo->bdrv), VAR_9);",
"}",
"#endif\nfl = pflash_cfi01_register(FLASH_ADDRESS, NULL, \"mips_malta.bios\",\nBIOS_SIZE, dinfo ? dinfo->bdrv : NULL,\n65536, VAR_9,\n4, 0x0000, 0x0000, 0x0000, 0x0000, VAR_10);",
"bios = pflash_cfi01_get_memory(fl);",
"VAR_8++;",
"if (VAR_2) {",
"loaderparams.ram_size = ram_size;",
"loaderparams.VAR_2 = VAR_2;",
"loaderparams.VAR_3 = VAR_3;",
"loaderparams.VAR_4 = VAR_4;",
"kernel_entry = load_kernel();",
"write_bootloader(env, memory_region_get_ram_ptr(bios), kernel_entry);",
"} else {",
"if (!dinfo) {",
"if (bios_name == NULL) {",
"bios_name = BIOS_FILENAME;",
"}",
"VAR_5 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);",
"if (VAR_5) {",
"bios_size = load_image_targphys(VAR_5, FLASH_ADDRESS,\nBIOS_SIZE);",
"g_free(VAR_5);",
"} else {",
"bios_size = -1;",
"}",
"if ((bios_size < 0 || bios_size > BIOS_SIZE) && !VAR_2) {",
"fprintf(stderr,\n\"qemu: Warning, could not load MIPS bios '%s', and no -kernel argument was specified\\n\",\nbios_name);",
"}",
"}",
"#ifndef TARGET_WORDS_BIGENDIAN\n{",
"uint32_t *end, *addr = rom_ptr(FLASH_ADDRESS);",
"if (!addr) {",
"addr = memory_region_get_ram_ptr(bios);",
"}",
"end = (void *)addr + MIN(bios_size, 0x3e0000);",
"while (addr < end) {",
"bswap32s(addr);",
"addr++;",
"}",
"}",
"#endif\n}",
"memory_region_init_ram(bios_copy, NULL, \"bios.1fc\", BIOS_SIZE);",
"if (!rom_copy(memory_region_get_ram_ptr(bios_copy),\nFLASH_ADDRESS, bios_size)) {",
"memcpy(memory_region_get_ram_ptr(bios_copy),\nmemory_region_get_ram_ptr(bios), bios_size);",
"}",
"memory_region_set_readonly(bios_copy, true);",
"memory_region_add_subregion(system_memory, RESET_ADDRESS, bios_copy);",
"stl_p(memory_region_get_ram_ptr(bios_copy) + 0x10, 0x00000420);",
"cpu_mips_irq_init_cpu(env);",
"cpu_mips_clock_init(env);",
"isa_irq = qemu_irq_proxy(&s->i8259, 16);",
"pci_bus = gt64120_register(isa_irq);",
"ide_drive_get(hd, MAX_IDE_BUS);",
"VAR_6 = piix4_init(pci_bus, &isa_bus, 80);",
"s->i8259 = i8259_init(isa_bus, env->irq[2]);",
"isa_bus_irqs(isa_bus, s->i8259);",
"pci_piix4_ide_init(pci_bus, hd, VAR_6 + 1);",
"pci_create_simple(pci_bus, VAR_6 + 2, \"piix4-usb-uhci\");",
"smbus = piix4_pm_init(pci_bus, VAR_6 + 3, 0x1100,\nisa_get_irq(NULL, 9), NULL, 0, NULL);",
"smbus_eeprom_init(smbus, 8, NULL, 0);",
"pit = pit_init(isa_bus, 0x40, 0, NULL);",
"cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);",
"DMA_init(0, cpu_exit_irq);",
"isa_create_simple(isa_bus, \"i8042\");",
"rtc_init(isa_bus, 2000, NULL);",
"serial_isa_init(isa_bus, 0, serial_hds[0]);",
"serial_isa_init(isa_bus, 1, serial_hds[1]);",
"if (parallel_hds[0])\nparallel_init(isa_bus, 0, parallel_hds[0]);",
"for(VAR_7 = 0; VAR_7 < MAX_FD; VAR_7++) {",
"fd[VAR_7] = drive_get(IF_FLOPPY, 0, VAR_7);",
"}",
"fdctrl_init_isa(isa_bus, fd);",
"network_init(pci_bus);",
"pci_vga_init(pci_bus);",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
61
],
[
63
],
[
67
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
91
],
[
93,
95
],
[
97,
99
],
[
101,
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
141
],
[
143,
145,
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
163
],
[
167,
169
],
[
171,
173
],
[
175,
181
],
[
187
],
[
189,
191
],
[
193,
195,
197,
199
],
[
201
],
[
203,
205,
207,
209,
211
],
[
213
],
[
215
],
[
217
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
237
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251,
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265,
267,
269
],
[
271
],
[
273
],
[
279,
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303,
305
],
[
321
],
[
323,
325
],
[
327,
329
],
[
331
],
[
333
],
[
335
],
[
341
],
[
347
],
[
349
],
[
367
],
[
373
],
[
379
],
[
383
],
[
391
],
[
395
],
[
397
],
[
399
],
[
401,
403
],
[
407
],
[
409
],
[
411
],
[
413
],
[
419
],
[
423
],
[
425
],
[
427
],
[
429,
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
445
],
[
451
],
[
453
]
] |
12,893
|
static void test_pci_enable(void)
{
AHCIQState *ahci;
ahci = ahci_boot();
ahci_pci_enable(ahci);
ahci_shutdown(ahci);
}
| false
|
qemu
|
debaaa114a8877a939533ba846e64168fb287b7b
|
static void test_pci_enable(void)
{
AHCIQState *ahci;
ahci = ahci_boot();
ahci_pci_enable(ahci);
ahci_shutdown(ahci);
}
|
{
"code": [],
"line_no": []
}
|
static void FUNC_0(void)
{
AHCIQState *ahci;
ahci = ahci_boot();
ahci_pci_enable(ahci);
ahci_shutdown(ahci);
}
|
[
"static void FUNC_0(void)\n{",
"AHCIQState *ahci;",
"ahci = ahci_boot();",
"ahci_pci_enable(ahci);",
"ahci_shutdown(ahci);",
"}"
] |
[
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
12,895
|
static int fill_psinfo(struct target_elf_prpsinfo *psinfo, const TaskState *ts)
{
char *filename, *base_filename;
unsigned int i, len;
(void) memset(psinfo, 0, sizeof (*psinfo));
len = ts->info->arg_end - ts->info->arg_start;
if (len >= ELF_PRARGSZ)
len = ELF_PRARGSZ - 1;
if (copy_from_user(&psinfo->pr_psargs, ts->info->arg_start, len))
return -EFAULT;
for (i = 0; i < len; i++)
if (psinfo->pr_psargs[i] == 0)
psinfo->pr_psargs[i] = ' ';
psinfo->pr_psargs[len] = 0;
psinfo->pr_pid = getpid();
psinfo->pr_ppid = getppid();
psinfo->pr_pgrp = getpgrp();
psinfo->pr_sid = getsid(0);
psinfo->pr_uid = getuid();
psinfo->pr_gid = getgid();
filename = strdup(ts->bprm->filename);
base_filename = strdup(basename(filename));
(void) strncpy(psinfo->pr_fname, base_filename,
sizeof(psinfo->pr_fname));
free(base_filename);
free(filename);
#ifdef BSWAP_NEEDED
bswap_psinfo(psinfo);
#endif
return (0);
}
| false
|
qemu
|
991f8f0c91d65cebf51fa931450e02b0d5209012
|
static int fill_psinfo(struct target_elf_prpsinfo *psinfo, const TaskState *ts)
{
char *filename, *base_filename;
unsigned int i, len;
(void) memset(psinfo, 0, sizeof (*psinfo));
len = ts->info->arg_end - ts->info->arg_start;
if (len >= ELF_PRARGSZ)
len = ELF_PRARGSZ - 1;
if (copy_from_user(&psinfo->pr_psargs, ts->info->arg_start, len))
return -EFAULT;
for (i = 0; i < len; i++)
if (psinfo->pr_psargs[i] == 0)
psinfo->pr_psargs[i] = ' ';
psinfo->pr_psargs[len] = 0;
psinfo->pr_pid = getpid();
psinfo->pr_ppid = getppid();
psinfo->pr_pgrp = getpgrp();
psinfo->pr_sid = getsid(0);
psinfo->pr_uid = getuid();
psinfo->pr_gid = getgid();
filename = strdup(ts->bprm->filename);
base_filename = strdup(basename(filename));
(void) strncpy(psinfo->pr_fname, base_filename,
sizeof(psinfo->pr_fname));
free(base_filename);
free(filename);
#ifdef BSWAP_NEEDED
bswap_psinfo(psinfo);
#endif
return (0);
}
|
{
"code": [],
"line_no": []
}
|
static int FUNC_0(struct target_elf_prpsinfo *VAR_0, const TaskState *VAR_1)
{
char *VAR_2, *VAR_3;
unsigned int VAR_4, VAR_5;
(void) memset(VAR_0, 0, sizeof (*VAR_0));
VAR_5 = VAR_1->info->arg_end - VAR_1->info->arg_start;
if (VAR_5 >= ELF_PRARGSZ)
VAR_5 = ELF_PRARGSZ - 1;
if (copy_from_user(&VAR_0->pr_psargs, VAR_1->info->arg_start, VAR_5))
return -EFAULT;
for (VAR_4 = 0; VAR_4 < VAR_5; VAR_4++)
if (VAR_0->pr_psargs[VAR_4] == 0)
VAR_0->pr_psargs[VAR_4] = ' ';
VAR_0->pr_psargs[VAR_5] = 0;
VAR_0->pr_pid = getpid();
VAR_0->pr_ppid = getppid();
VAR_0->pr_pgrp = getpgrp();
VAR_0->pr_sid = getsid(0);
VAR_0->pr_uid = getuid();
VAR_0->pr_gid = getgid();
VAR_2 = strdup(VAR_1->bprm->VAR_2);
VAR_3 = strdup(basename(VAR_2));
(void) strncpy(VAR_0->pr_fname, VAR_3,
sizeof(VAR_0->pr_fname));
free(VAR_3);
free(VAR_2);
#ifdef BSWAP_NEEDED
bswap_psinfo(VAR_0);
#endif
return (0);
}
|
[
"static int FUNC_0(struct target_elf_prpsinfo *VAR_0, const TaskState *VAR_1)\n{",
"char *VAR_2, *VAR_3;",
"unsigned int VAR_4, VAR_5;",
"(void) memset(VAR_0, 0, sizeof (*VAR_0));",
"VAR_5 = VAR_1->info->arg_end - VAR_1->info->arg_start;",
"if (VAR_5 >= ELF_PRARGSZ)\nVAR_5 = ELF_PRARGSZ - 1;",
"if (copy_from_user(&VAR_0->pr_psargs, VAR_1->info->arg_start, VAR_5))\nreturn -EFAULT;",
"for (VAR_4 = 0; VAR_4 < VAR_5; VAR_4++)",
"if (VAR_0->pr_psargs[VAR_4] == 0)\nVAR_0->pr_psargs[VAR_4] = ' ';",
"VAR_0->pr_psargs[VAR_5] = 0;",
"VAR_0->pr_pid = getpid();",
"VAR_0->pr_ppid = getppid();",
"VAR_0->pr_pgrp = getpgrp();",
"VAR_0->pr_sid = getsid(0);",
"VAR_0->pr_uid = getuid();",
"VAR_0->pr_gid = getgid();",
"VAR_2 = strdup(VAR_1->bprm->VAR_2);",
"VAR_3 = strdup(basename(VAR_2));",
"(void) strncpy(VAR_0->pr_fname, VAR_3,\nsizeof(VAR_0->pr_fname));",
"free(VAR_3);",
"free(VAR_2);",
"#ifdef BSWAP_NEEDED\nbswap_psinfo(VAR_0);",
"#endif\nreturn (0);",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17,
19
],
[
21,
23
],
[
25
],
[
27,
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
63,
65
],
[
67,
69
],
[
71
]
] |
12,896
|
static void do_exit(void)
{
if (cur_stream) {
stream_close(cur_stream);
cur_stream = NULL;
}
uninit_opts();
#if CONFIG_AVFILTER
avfilter_uninit();
#endif
avformat_network_deinit();
if (show_status)
printf("\n");
SDL_Quit();
av_log(NULL, AV_LOG_QUIET, "");
exit(0);
}
| false
|
FFmpeg
|
fa2a34cd40d124161c748bb0f430dc63c94dd0da
|
static void do_exit(void)
{
if (cur_stream) {
stream_close(cur_stream);
cur_stream = NULL;
}
uninit_opts();
#if CONFIG_AVFILTER
avfilter_uninit();
#endif
avformat_network_deinit();
if (show_status)
printf("\n");
SDL_Quit();
av_log(NULL, AV_LOG_QUIET, "");
exit(0);
}
|
{
"code": [],
"line_no": []
}
|
static void FUNC_0(void)
{
if (cur_stream) {
stream_close(cur_stream);
cur_stream = NULL;
}
uninit_opts();
#if CONFIG_AVFILTER
avfilter_uninit();
#endif
avformat_network_deinit();
if (show_status)
printf("\n");
SDL_Quit();
av_log(NULL, AV_LOG_QUIET, "");
exit(0);
}
|
[
"static void FUNC_0(void)\n{",
"if (cur_stream) {",
"stream_close(cur_stream);",
"cur_stream = NULL;",
"}",
"uninit_opts();",
"#if CONFIG_AVFILTER\navfilter_uninit();",
"#endif\navformat_network_deinit();",
"if (show_status)\nprintf(\"\\n\");",
"SDL_Quit();",
"av_log(NULL, AV_LOG_QUIET, \"\");",
"exit(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
]
] |
12,897
|
static TileExcp decode_y0(DisasContext *dc, tilegx_bundle_bits bundle)
{
unsigned opc = get_Opcode_Y0(bundle);
unsigned ext = get_RRROpcodeExtension_Y0(bundle);
unsigned dest = get_Dest_Y0(bundle);
unsigned srca = get_SrcA_Y0(bundle);
unsigned srcb;
int imm;
switch (opc) {
case RRR_1_OPCODE_Y0:
if (ext == UNARY_RRR_1_OPCODE_Y0) {
ext = get_UnaryOpcodeExtension_Y0(bundle);
return gen_rr_opcode(dc, OE(opc, ext, Y0), dest, srca);
}
/* fallthru */
case RRR_0_OPCODE_Y0:
case RRR_2_OPCODE_Y0:
case RRR_3_OPCODE_Y0:
case RRR_4_OPCODE_Y0:
case RRR_5_OPCODE_Y0:
case RRR_6_OPCODE_Y0:
case RRR_7_OPCODE_Y0:
case RRR_8_OPCODE_Y0:
case RRR_9_OPCODE_Y0:
srcb = get_SrcB_Y0(bundle);
return gen_rrr_opcode(dc, OE(opc, ext, Y0), dest, srca, srcb);
case SHIFT_OPCODE_Y0:
ext = get_ShiftOpcodeExtension_Y0(bundle);
imm = get_ShAmt_Y0(bundle);
return gen_rri_opcode(dc, OE(opc, ext, Y0), dest, srca, imm);
case ADDI_OPCODE_Y0:
case ADDXI_OPCODE_Y0:
case ANDI_OPCODE_Y0:
case CMPEQI_OPCODE_Y0:
case CMPLTSI_OPCODE_Y0:
imm = (int8_t)get_Imm8_Y0(bundle);
return gen_rri_opcode(dc, OE(opc, 0, Y0), dest, srca, imm);
default:
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
}
}
| false
|
qemu
|
dd8070d865ad1b32876931f812a80645f97112ff
|
static TileExcp decode_y0(DisasContext *dc, tilegx_bundle_bits bundle)
{
unsigned opc = get_Opcode_Y0(bundle);
unsigned ext = get_RRROpcodeExtension_Y0(bundle);
unsigned dest = get_Dest_Y0(bundle);
unsigned srca = get_SrcA_Y0(bundle);
unsigned srcb;
int imm;
switch (opc) {
case RRR_1_OPCODE_Y0:
if (ext == UNARY_RRR_1_OPCODE_Y0) {
ext = get_UnaryOpcodeExtension_Y0(bundle);
return gen_rr_opcode(dc, OE(opc, ext, Y0), dest, srca);
}
case RRR_0_OPCODE_Y0:
case RRR_2_OPCODE_Y0:
case RRR_3_OPCODE_Y0:
case RRR_4_OPCODE_Y0:
case RRR_5_OPCODE_Y0:
case RRR_6_OPCODE_Y0:
case RRR_7_OPCODE_Y0:
case RRR_8_OPCODE_Y0:
case RRR_9_OPCODE_Y0:
srcb = get_SrcB_Y0(bundle);
return gen_rrr_opcode(dc, OE(opc, ext, Y0), dest, srca, srcb);
case SHIFT_OPCODE_Y0:
ext = get_ShiftOpcodeExtension_Y0(bundle);
imm = get_ShAmt_Y0(bundle);
return gen_rri_opcode(dc, OE(opc, ext, Y0), dest, srca, imm);
case ADDI_OPCODE_Y0:
case ADDXI_OPCODE_Y0:
case ANDI_OPCODE_Y0:
case CMPEQI_OPCODE_Y0:
case CMPLTSI_OPCODE_Y0:
imm = (int8_t)get_Imm8_Y0(bundle);
return gen_rri_opcode(dc, OE(opc, 0, Y0), dest, srca, imm);
default:
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
}
}
|
{
"code": [],
"line_no": []
}
|
static TileExcp FUNC_0(DisasContext *dc, tilegx_bundle_bits bundle)
{
unsigned VAR_0 = get_Opcode_Y0(bundle);
unsigned VAR_1 = get_RRROpcodeExtension_Y0(bundle);
unsigned VAR_2 = get_Dest_Y0(bundle);
unsigned VAR_3 = get_SrcA_Y0(bundle);
unsigned VAR_4;
int VAR_5;
switch (VAR_0) {
case RRR_1_OPCODE_Y0:
if (VAR_1 == UNARY_RRR_1_OPCODE_Y0) {
VAR_1 = get_UnaryOpcodeExtension_Y0(bundle);
return gen_rr_opcode(dc, OE(VAR_0, VAR_1, Y0), VAR_2, VAR_3);
}
case RRR_0_OPCODE_Y0:
case RRR_2_OPCODE_Y0:
case RRR_3_OPCODE_Y0:
case RRR_4_OPCODE_Y0:
case RRR_5_OPCODE_Y0:
case RRR_6_OPCODE_Y0:
case RRR_7_OPCODE_Y0:
case RRR_8_OPCODE_Y0:
case RRR_9_OPCODE_Y0:
VAR_4 = get_SrcB_Y0(bundle);
return gen_rrr_opcode(dc, OE(VAR_0, VAR_1, Y0), VAR_2, VAR_3, VAR_4);
case SHIFT_OPCODE_Y0:
VAR_1 = get_ShiftOpcodeExtension_Y0(bundle);
VAR_5 = get_ShAmt_Y0(bundle);
return gen_rri_opcode(dc, OE(VAR_0, VAR_1, Y0), VAR_2, VAR_3, VAR_5);
case ADDI_OPCODE_Y0:
case ADDXI_OPCODE_Y0:
case ANDI_OPCODE_Y0:
case CMPEQI_OPCODE_Y0:
case CMPLTSI_OPCODE_Y0:
VAR_5 = (int8_t)get_Imm8_Y0(bundle);
return gen_rri_opcode(dc, OE(VAR_0, 0, Y0), VAR_2, VAR_3, VAR_5);
default:
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
}
}
|
[
"static TileExcp FUNC_0(DisasContext *dc, tilegx_bundle_bits bundle)\n{",
"unsigned VAR_0 = get_Opcode_Y0(bundle);",
"unsigned VAR_1 = get_RRROpcodeExtension_Y0(bundle);",
"unsigned VAR_2 = get_Dest_Y0(bundle);",
"unsigned VAR_3 = get_SrcA_Y0(bundle);",
"unsigned VAR_4;",
"int VAR_5;",
"switch (VAR_0) {",
"case RRR_1_OPCODE_Y0:\nif (VAR_1 == UNARY_RRR_1_OPCODE_Y0) {",
"VAR_1 = get_UnaryOpcodeExtension_Y0(bundle);",
"return gen_rr_opcode(dc, OE(VAR_0, VAR_1, Y0), VAR_2, VAR_3);",
"}",
"case RRR_0_OPCODE_Y0:\ncase RRR_2_OPCODE_Y0:\ncase RRR_3_OPCODE_Y0:\ncase RRR_4_OPCODE_Y0:\ncase RRR_5_OPCODE_Y0:\ncase RRR_6_OPCODE_Y0:\ncase RRR_7_OPCODE_Y0:\ncase RRR_8_OPCODE_Y0:\ncase RRR_9_OPCODE_Y0:\nVAR_4 = get_SrcB_Y0(bundle);",
"return gen_rrr_opcode(dc, OE(VAR_0, VAR_1, Y0), VAR_2, VAR_3, VAR_4);",
"case SHIFT_OPCODE_Y0:\nVAR_1 = get_ShiftOpcodeExtension_Y0(bundle);",
"VAR_5 = get_ShAmt_Y0(bundle);",
"return gen_rri_opcode(dc, OE(VAR_0, VAR_1, Y0), VAR_2, VAR_3, VAR_5);",
"case ADDI_OPCODE_Y0:\ncase ADDXI_OPCODE_Y0:\ncase ANDI_OPCODE_Y0:\ncase CMPEQI_OPCODE_Y0:\ncase CMPLTSI_OPCODE_Y0:\nVAR_5 = (int8_t)get_Imm8_Y0(bundle);",
"return gen_rri_opcode(dc, OE(VAR_0, 0, Y0), VAR_2, VAR_3, VAR_5);",
"default:\nreturn TILEGX_EXCP_OPCODE_UNIMPLEMENTED;",
"}",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
33,
35,
37,
39,
41,
43,
45,
47,
49,
51
],
[
53
],
[
57,
59
],
[
61
],
[
63
],
[
67,
69,
71,
73,
75,
77
],
[
79
],
[
83,
85
],
[
87
],
[
89
]
] |
12,898
|
void ioinst_handle_schm(S390CPU *cpu, uint64_t reg1, uint64_t reg2,
uint32_t ipb)
{
uint8_t mbk;
int update;
int dct;
CPUS390XState *env = &cpu->env;
trace_ioinst("schm");
if (SCHM_REG1_RES(reg1)) {
program_interrupt(env, PGM_OPERAND, 2);
return;
}
mbk = SCHM_REG1_MBK(reg1);
update = SCHM_REG1_UPD(reg1);
dct = SCHM_REG1_DCT(reg1);
if (update && (reg2 & 0x000000000000001f)) {
program_interrupt(env, PGM_OPERAND, 2);
return;
}
css_do_schm(mbk, update, dct, update ? reg2 : 0);
}
| false
|
qemu
|
7e01376daea75e888c370aab521a7d4aeaf2ffd1
|
void ioinst_handle_schm(S390CPU *cpu, uint64_t reg1, uint64_t reg2,
uint32_t ipb)
{
uint8_t mbk;
int update;
int dct;
CPUS390XState *env = &cpu->env;
trace_ioinst("schm");
if (SCHM_REG1_RES(reg1)) {
program_interrupt(env, PGM_OPERAND, 2);
return;
}
mbk = SCHM_REG1_MBK(reg1);
update = SCHM_REG1_UPD(reg1);
dct = SCHM_REG1_DCT(reg1);
if (update && (reg2 & 0x000000000000001f)) {
program_interrupt(env, PGM_OPERAND, 2);
return;
}
css_do_schm(mbk, update, dct, update ? reg2 : 0);
}
|
{
"code": [],
"line_no": []
}
|
void FUNC_0(S390CPU *VAR_0, uint64_t VAR_1, uint64_t VAR_2,
uint32_t VAR_3)
{
uint8_t mbk;
int VAR_4;
int VAR_5;
CPUS390XState *env = &VAR_0->env;
trace_ioinst("schm");
if (SCHM_REG1_RES(VAR_1)) {
program_interrupt(env, PGM_OPERAND, 2);
return;
}
mbk = SCHM_REG1_MBK(VAR_1);
VAR_4 = SCHM_REG1_UPD(VAR_1);
VAR_5 = SCHM_REG1_DCT(VAR_1);
if (VAR_4 && (VAR_2 & 0x000000000000001f)) {
program_interrupt(env, PGM_OPERAND, 2);
return;
}
css_do_schm(mbk, VAR_4, VAR_5, VAR_4 ? VAR_2 : 0);
}
|
[
"void FUNC_0(S390CPU *VAR_0, uint64_t VAR_1, uint64_t VAR_2,\nuint32_t VAR_3)\n{",
"uint8_t mbk;",
"int VAR_4;",
"int VAR_5;",
"CPUS390XState *env = &VAR_0->env;",
"trace_ioinst(\"schm\");",
"if (SCHM_REG1_RES(VAR_1)) {",
"program_interrupt(env, PGM_OPERAND, 2);",
"return;",
"}",
"mbk = SCHM_REG1_MBK(VAR_1);",
"VAR_4 = SCHM_REG1_UPD(VAR_1);",
"VAR_5 = SCHM_REG1_DCT(VAR_1);",
"if (VAR_4 && (VAR_2 & 0x000000000000001f)) {",
"program_interrupt(env, PGM_OPERAND, 2);",
"return;",
"}",
"css_do_schm(mbk, VAR_4, VAR_5, VAR_4 ? VAR_2 : 0);",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
]
] |
12,899
|
QPCIBus *qpci_init_spapr(QGuestAllocator *alloc)
{
QPCIBusSPAPR *ret;
ret = g_malloc(sizeof(*ret));
ret->alloc = alloc;
ret->bus.io_readb = qpci_spapr_io_readb;
ret->bus.io_readw = qpci_spapr_io_readw;
ret->bus.io_readl = qpci_spapr_io_readl;
ret->bus.io_writeb = qpci_spapr_io_writeb;
ret->bus.io_writew = qpci_spapr_io_writew;
ret->bus.io_writel = qpci_spapr_io_writel;
ret->bus.config_readb = qpci_spapr_config_readb;
ret->bus.config_readw = qpci_spapr_config_readw;
ret->bus.config_readl = qpci_spapr_config_readl;
ret->bus.config_writeb = qpci_spapr_config_writeb;
ret->bus.config_writew = qpci_spapr_config_writew;
ret->bus.config_writel = qpci_spapr_config_writel;
ret->bus.iomap = qpci_spapr_iomap;
ret->bus.iounmap = qpci_spapr_iounmap;
/* FIXME: We assume the default location of the PHB for now.
* Ideally we'd parse the device tree deposited in the guest to
* get the window locations */
ret->buid = 0x800000020000000ULL;
ret->pio_cpu_base = SPAPR_PCI_WINDOW_BASE + SPAPR_PCI_IO_WIN_OFF;
ret->pio.pci_base = 0;
ret->pio.size = SPAPR_PCI_IO_WIN_SIZE;
ret->mmio_cpu_base = SPAPR_PCI_WINDOW_BASE + SPAPR_PCI_MMIO_WIN_OFF;
ret->mmio.pci_base = SPAPR_PCI_MEM_WIN_BUS_OFFSET;
ret->mmio.size = SPAPR_PCI_MMIO_WIN_SIZE;
ret->pci_hole_start = 0xC0000000;
ret->pci_hole_size =
ret->mmio.pci_base + ret->mmio.size - ret->pci_hole_start;
ret->pci_hole_alloc = 0;
ret->pci_iohole_start = 0xc000;
ret->pci_iohole_size =
ret->pio.pci_base + ret->pio.size - ret->pci_iohole_start;
ret->pci_iohole_alloc = 0;
return &ret->bus;
}
| false
|
qemu
|
8360544a6d3a54df1fce80f55ba4ad075a8ded54
|
QPCIBus *qpci_init_spapr(QGuestAllocator *alloc)
{
QPCIBusSPAPR *ret;
ret = g_malloc(sizeof(*ret));
ret->alloc = alloc;
ret->bus.io_readb = qpci_spapr_io_readb;
ret->bus.io_readw = qpci_spapr_io_readw;
ret->bus.io_readl = qpci_spapr_io_readl;
ret->bus.io_writeb = qpci_spapr_io_writeb;
ret->bus.io_writew = qpci_spapr_io_writew;
ret->bus.io_writel = qpci_spapr_io_writel;
ret->bus.config_readb = qpci_spapr_config_readb;
ret->bus.config_readw = qpci_spapr_config_readw;
ret->bus.config_readl = qpci_spapr_config_readl;
ret->bus.config_writeb = qpci_spapr_config_writeb;
ret->bus.config_writew = qpci_spapr_config_writew;
ret->bus.config_writel = qpci_spapr_config_writel;
ret->bus.iomap = qpci_spapr_iomap;
ret->bus.iounmap = qpci_spapr_iounmap;
ret->buid = 0x800000020000000ULL;
ret->pio_cpu_base = SPAPR_PCI_WINDOW_BASE + SPAPR_PCI_IO_WIN_OFF;
ret->pio.pci_base = 0;
ret->pio.size = SPAPR_PCI_IO_WIN_SIZE;
ret->mmio_cpu_base = SPAPR_PCI_WINDOW_BASE + SPAPR_PCI_MMIO_WIN_OFF;
ret->mmio.pci_base = SPAPR_PCI_MEM_WIN_BUS_OFFSET;
ret->mmio.size = SPAPR_PCI_MMIO_WIN_SIZE;
ret->pci_hole_start = 0xC0000000;
ret->pci_hole_size =
ret->mmio.pci_base + ret->mmio.size - ret->pci_hole_start;
ret->pci_hole_alloc = 0;
ret->pci_iohole_start = 0xc000;
ret->pci_iohole_size =
ret->pio.pci_base + ret->pio.size - ret->pci_iohole_start;
ret->pci_iohole_alloc = 0;
return &ret->bus;
}
|
{
"code": [],
"line_no": []
}
|
QPCIBus *FUNC_0(QGuestAllocator *alloc)
{
QPCIBusSPAPR *ret;
ret = g_malloc(sizeof(*ret));
ret->alloc = alloc;
ret->bus.io_readb = qpci_spapr_io_readb;
ret->bus.io_readw = qpci_spapr_io_readw;
ret->bus.io_readl = qpci_spapr_io_readl;
ret->bus.io_writeb = qpci_spapr_io_writeb;
ret->bus.io_writew = qpci_spapr_io_writew;
ret->bus.io_writel = qpci_spapr_io_writel;
ret->bus.config_readb = qpci_spapr_config_readb;
ret->bus.config_readw = qpci_spapr_config_readw;
ret->bus.config_readl = qpci_spapr_config_readl;
ret->bus.config_writeb = qpci_spapr_config_writeb;
ret->bus.config_writew = qpci_spapr_config_writew;
ret->bus.config_writel = qpci_spapr_config_writel;
ret->bus.iomap = qpci_spapr_iomap;
ret->bus.iounmap = qpci_spapr_iounmap;
ret->buid = 0x800000020000000ULL;
ret->pio_cpu_base = SPAPR_PCI_WINDOW_BASE + SPAPR_PCI_IO_WIN_OFF;
ret->pio.pci_base = 0;
ret->pio.size = SPAPR_PCI_IO_WIN_SIZE;
ret->mmio_cpu_base = SPAPR_PCI_WINDOW_BASE + SPAPR_PCI_MMIO_WIN_OFF;
ret->mmio.pci_base = SPAPR_PCI_MEM_WIN_BUS_OFFSET;
ret->mmio.size = SPAPR_PCI_MMIO_WIN_SIZE;
ret->pci_hole_start = 0xC0000000;
ret->pci_hole_size =
ret->mmio.pci_base + ret->mmio.size - ret->pci_hole_start;
ret->pci_hole_alloc = 0;
ret->pci_iohole_start = 0xc000;
ret->pci_iohole_size =
ret->pio.pci_base + ret->pio.size - ret->pci_iohole_start;
ret->pci_iohole_alloc = 0;
return &ret->bus;
}
|
[
"QPCIBus *FUNC_0(QGuestAllocator *alloc)\n{",
"QPCIBusSPAPR *ret;",
"ret = g_malloc(sizeof(*ret));",
"ret->alloc = alloc;",
"ret->bus.io_readb = qpci_spapr_io_readb;",
"ret->bus.io_readw = qpci_spapr_io_readw;",
"ret->bus.io_readl = qpci_spapr_io_readl;",
"ret->bus.io_writeb = qpci_spapr_io_writeb;",
"ret->bus.io_writew = qpci_spapr_io_writew;",
"ret->bus.io_writel = qpci_spapr_io_writel;",
"ret->bus.config_readb = qpci_spapr_config_readb;",
"ret->bus.config_readw = qpci_spapr_config_readw;",
"ret->bus.config_readl = qpci_spapr_config_readl;",
"ret->bus.config_writeb = qpci_spapr_config_writeb;",
"ret->bus.config_writew = qpci_spapr_config_writew;",
"ret->bus.config_writel = qpci_spapr_config_writel;",
"ret->bus.iomap = qpci_spapr_iomap;",
"ret->bus.iounmap = qpci_spapr_iounmap;",
"ret->buid = 0x800000020000000ULL;",
"ret->pio_cpu_base = SPAPR_PCI_WINDOW_BASE + SPAPR_PCI_IO_WIN_OFF;",
"ret->pio.pci_base = 0;",
"ret->pio.size = SPAPR_PCI_IO_WIN_SIZE;",
"ret->mmio_cpu_base = SPAPR_PCI_WINDOW_BASE + SPAPR_PCI_MMIO_WIN_OFF;",
"ret->mmio.pci_base = SPAPR_PCI_MEM_WIN_BUS_OFFSET;",
"ret->mmio.size = SPAPR_PCI_MMIO_WIN_SIZE;",
"ret->pci_hole_start = 0xC0000000;",
"ret->pci_hole_size =\nret->mmio.pci_base + ret->mmio.size - ret->pci_hole_start;",
"ret->pci_hole_alloc = 0;",
"ret->pci_iohole_start = 0xc000;",
"ret->pci_iohole_size =\nret->pio.pci_base + ret->pio.size - ret->pci_iohole_start;",
"ret->pci_iohole_alloc = 0;",
"return &ret->bus;",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
61
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83,
85
],
[
87
],
[
91
],
[
93,
95
],
[
97
],
[
101
],
[
103
]
] |
12,900
|
static void icount_warp_rt(void *opaque)
{
if (vm_clock_warp_start == -1) {
return;
}
if (runstate_is_running()) {
int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
int64_t warp_delta = clock - vm_clock_warp_start;
if (use_icount == 1) {
qemu_icount_bias += warp_delta;
} else {
/*
* In adaptive mode, do not let QEMU_CLOCK_VIRTUAL run too
* far ahead of real time.
*/
int64_t cur_time = cpu_get_clock();
int64_t cur_icount = cpu_get_icount();
int64_t delta = cur_time - cur_icount;
qemu_icount_bias += MIN(warp_delta, delta);
}
if (qemu_clock_expired(QEMU_CLOCK_VIRTUAL)) {
qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
}
}
vm_clock_warp_start = -1;
}
| false
|
qemu
|
8ed961d95708ee6cadac22fba7762724d533a5b4
|
static void icount_warp_rt(void *opaque)
{
if (vm_clock_warp_start == -1) {
return;
}
if (runstate_is_running()) {
int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
int64_t warp_delta = clock - vm_clock_warp_start;
if (use_icount == 1) {
qemu_icount_bias += warp_delta;
} else {
int64_t cur_time = cpu_get_clock();
int64_t cur_icount = cpu_get_icount();
int64_t delta = cur_time - cur_icount;
qemu_icount_bias += MIN(warp_delta, delta);
}
if (qemu_clock_expired(QEMU_CLOCK_VIRTUAL)) {
qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
}
}
vm_clock_warp_start = -1;
}
|
{
"code": [],
"line_no": []
}
|
static void FUNC_0(void *VAR_0)
{
if (vm_clock_warp_start == -1) {
return;
}
if (runstate_is_running()) {
int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
int64_t warp_delta = clock - vm_clock_warp_start;
if (use_icount == 1) {
qemu_icount_bias += warp_delta;
} else {
int64_t cur_time = cpu_get_clock();
int64_t cur_icount = cpu_get_icount();
int64_t delta = cur_time - cur_icount;
qemu_icount_bias += MIN(warp_delta, delta);
}
if (qemu_clock_expired(QEMU_CLOCK_VIRTUAL)) {
qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
}
}
vm_clock_warp_start = -1;
}
|
[
"static void FUNC_0(void *VAR_0)\n{",
"if (vm_clock_warp_start == -1) {",
"return;",
"}",
"if (runstate_is_running()) {",
"int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);",
"int64_t warp_delta = clock - vm_clock_warp_start;",
"if (use_icount == 1) {",
"qemu_icount_bias += warp_delta;",
"} else {",
"int64_t cur_time = cpu_get_clock();",
"int64_t cur_icount = cpu_get_icount();",
"int64_t delta = cur_time - cur_icount;",
"qemu_icount_bias += MIN(warp_delta, delta);",
"}",
"if (qemu_clock_expired(QEMU_CLOCK_VIRTUAL)) {",
"qemu_clock_notify(QEMU_CLOCK_VIRTUAL);",
"}",
"}",
"vm_clock_warp_start = -1;",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
]
] |
12,901
|
static abi_long do_sendrecvmsg(int fd, abi_ulong target_msg,
int flags, int send)
{
abi_long ret, len;
struct target_msghdr *msgp;
struct msghdr msg;
int count;
struct iovec *vec;
abi_ulong target_vec;
/* FIXME */
if (!lock_user_struct(send ? VERIFY_READ : VERIFY_WRITE,
msgp,
target_msg,
send ? 1 : 0))
return -TARGET_EFAULT;
if (msgp->msg_name) {
msg.msg_namelen = tswap32(msgp->msg_namelen);
msg.msg_name = alloca(msg.msg_namelen);
ret = target_to_host_sockaddr(msg.msg_name, tswapal(msgp->msg_name),
msg.msg_namelen);
if (ret) {
unlock_user_struct(msgp, target_msg, send ? 0 : 1);
return ret;
}
} else {
msg.msg_name = NULL;
msg.msg_namelen = 0;
}
msg.msg_controllen = 2 * tswapal(msgp->msg_controllen);
msg.msg_control = alloca(msg.msg_controllen);
msg.msg_flags = tswap32(msgp->msg_flags);
count = tswapal(msgp->msg_iovlen);
vec = alloca(count * sizeof(struct iovec));
target_vec = tswapal(msgp->msg_iov);
lock_iovec(send ? VERIFY_READ : VERIFY_WRITE, vec, target_vec, count, send);
msg.msg_iovlen = count;
msg.msg_iov = vec;
if (send) {
ret = target_to_host_cmsg(&msg, msgp);
if (ret == 0)
ret = get_errno(sendmsg(fd, &msg, flags));
} else {
ret = get_errno(recvmsg(fd, &msg, flags));
if (!is_error(ret)) {
len = ret;
ret = host_to_target_cmsg(msgp, &msg);
if (!is_error(ret)) {
msgp->msg_namelen = tswap32(msg.msg_namelen);
if (msg.msg_name != NULL) {
ret = host_to_target_sockaddr(tswapal(msgp->msg_name),
msg.msg_name, msg.msg_namelen);
if (ret) {
goto out;
}
}
ret = len;
}
}
}
out:
unlock_iovec(vec, target_vec, count, !send);
unlock_user_struct(msgp, target_msg, send ? 0 : 1);
return ret;
}
| false
|
qemu
|
f287b2c2d4d20d35880ab6dca44bda0476e67dce
|
static abi_long do_sendrecvmsg(int fd, abi_ulong target_msg,
int flags, int send)
{
abi_long ret, len;
struct target_msghdr *msgp;
struct msghdr msg;
int count;
struct iovec *vec;
abi_ulong target_vec;
if (!lock_user_struct(send ? VERIFY_READ : VERIFY_WRITE,
msgp,
target_msg,
send ? 1 : 0))
return -TARGET_EFAULT;
if (msgp->msg_name) {
msg.msg_namelen = tswap32(msgp->msg_namelen);
msg.msg_name = alloca(msg.msg_namelen);
ret = target_to_host_sockaddr(msg.msg_name, tswapal(msgp->msg_name),
msg.msg_namelen);
if (ret) {
unlock_user_struct(msgp, target_msg, send ? 0 : 1);
return ret;
}
} else {
msg.msg_name = NULL;
msg.msg_namelen = 0;
}
msg.msg_controllen = 2 * tswapal(msgp->msg_controllen);
msg.msg_control = alloca(msg.msg_controllen);
msg.msg_flags = tswap32(msgp->msg_flags);
count = tswapal(msgp->msg_iovlen);
vec = alloca(count * sizeof(struct iovec));
target_vec = tswapal(msgp->msg_iov);
lock_iovec(send ? VERIFY_READ : VERIFY_WRITE, vec, target_vec, count, send);
msg.msg_iovlen = count;
msg.msg_iov = vec;
if (send) {
ret = target_to_host_cmsg(&msg, msgp);
if (ret == 0)
ret = get_errno(sendmsg(fd, &msg, flags));
} else {
ret = get_errno(recvmsg(fd, &msg, flags));
if (!is_error(ret)) {
len = ret;
ret = host_to_target_cmsg(msgp, &msg);
if (!is_error(ret)) {
msgp->msg_namelen = tswap32(msg.msg_namelen);
if (msg.msg_name != NULL) {
ret = host_to_target_sockaddr(tswapal(msgp->msg_name),
msg.msg_name, msg.msg_namelen);
if (ret) {
goto out;
}
}
ret = len;
}
}
}
out:
unlock_iovec(vec, target_vec, count, !send);
unlock_user_struct(msgp, target_msg, send ? 0 : 1);
return ret;
}
|
{
"code": [],
"line_no": []
}
|
static abi_long FUNC_0(int fd, abi_ulong target_msg,
int flags, int send)
{
abi_long ret, len;
struct target_msghdr *VAR_0;
struct msghdr VAR_1;
int VAR_2;
struct iovec *VAR_3;
abi_ulong target_vec;
if (!lock_user_struct(send ? VERIFY_READ : VERIFY_WRITE,
VAR_0,
target_msg,
send ? 1 : 0))
return -TARGET_EFAULT;
if (VAR_0->msg_name) {
VAR_1.msg_namelen = tswap32(VAR_0->msg_namelen);
VAR_1.msg_name = alloca(VAR_1.msg_namelen);
ret = target_to_host_sockaddr(VAR_1.msg_name, tswapal(VAR_0->msg_name),
VAR_1.msg_namelen);
if (ret) {
unlock_user_struct(VAR_0, target_msg, send ? 0 : 1);
return ret;
}
} else {
VAR_1.msg_name = NULL;
VAR_1.msg_namelen = 0;
}
VAR_1.msg_controllen = 2 * tswapal(VAR_0->msg_controllen);
VAR_1.msg_control = alloca(VAR_1.msg_controllen);
VAR_1.msg_flags = tswap32(VAR_0->msg_flags);
VAR_2 = tswapal(VAR_0->msg_iovlen);
VAR_3 = alloca(VAR_2 * sizeof(struct iovec));
target_vec = tswapal(VAR_0->msg_iov);
lock_iovec(send ? VERIFY_READ : VERIFY_WRITE, VAR_3, target_vec, VAR_2, send);
VAR_1.msg_iovlen = VAR_2;
VAR_1.msg_iov = VAR_3;
if (send) {
ret = target_to_host_cmsg(&VAR_1, VAR_0);
if (ret == 0)
ret = get_errno(sendmsg(fd, &VAR_1, flags));
} else {
ret = get_errno(recvmsg(fd, &VAR_1, flags));
if (!is_error(ret)) {
len = ret;
ret = host_to_target_cmsg(VAR_0, &VAR_1);
if (!is_error(ret)) {
VAR_0->msg_namelen = tswap32(VAR_1.msg_namelen);
if (VAR_1.msg_name != NULL) {
ret = host_to_target_sockaddr(tswapal(VAR_0->msg_name),
VAR_1.msg_name, VAR_1.msg_namelen);
if (ret) {
goto out;
}
}
ret = len;
}
}
}
out:
unlock_iovec(VAR_3, target_vec, VAR_2, !send);
unlock_user_struct(VAR_0, target_msg, send ? 0 : 1);
return ret;
}
|
[
"static abi_long FUNC_0(int fd, abi_ulong target_msg,\nint flags, int send)\n{",
"abi_long ret, len;",
"struct target_msghdr *VAR_0;",
"struct msghdr VAR_1;",
"int VAR_2;",
"struct iovec *VAR_3;",
"abi_ulong target_vec;",
"if (!lock_user_struct(send ? VERIFY_READ : VERIFY_WRITE,\nVAR_0,\ntarget_msg,\nsend ? 1 : 0))\nreturn -TARGET_EFAULT;",
"if (VAR_0->msg_name) {",
"VAR_1.msg_namelen = tswap32(VAR_0->msg_namelen);",
"VAR_1.msg_name = alloca(VAR_1.msg_namelen);",
"ret = target_to_host_sockaddr(VAR_1.msg_name, tswapal(VAR_0->msg_name),\nVAR_1.msg_namelen);",
"if (ret) {",
"unlock_user_struct(VAR_0, target_msg, send ? 0 : 1);",
"return ret;",
"}",
"} else {",
"VAR_1.msg_name = NULL;",
"VAR_1.msg_namelen = 0;",
"}",
"VAR_1.msg_controllen = 2 * tswapal(VAR_0->msg_controllen);",
"VAR_1.msg_control = alloca(VAR_1.msg_controllen);",
"VAR_1.msg_flags = tswap32(VAR_0->msg_flags);",
"VAR_2 = tswapal(VAR_0->msg_iovlen);",
"VAR_3 = alloca(VAR_2 * sizeof(struct iovec));",
"target_vec = tswapal(VAR_0->msg_iov);",
"lock_iovec(send ? VERIFY_READ : VERIFY_WRITE, VAR_3, target_vec, VAR_2, send);",
"VAR_1.msg_iovlen = VAR_2;",
"VAR_1.msg_iov = VAR_3;",
"if (send) {",
"ret = target_to_host_cmsg(&VAR_1, VAR_0);",
"if (ret == 0)\nret = get_errno(sendmsg(fd, &VAR_1, flags));",
"} else {",
"ret = get_errno(recvmsg(fd, &VAR_1, flags));",
"if (!is_error(ret)) {",
"len = ret;",
"ret = host_to_target_cmsg(VAR_0, &VAR_1);",
"if (!is_error(ret)) {",
"VAR_0->msg_namelen = tswap32(VAR_1.msg_namelen);",
"if (VAR_1.msg_name != NULL) {",
"ret = host_to_target_sockaddr(tswapal(VAR_0->msg_name),\nVAR_1.msg_name, VAR_1.msg_namelen);",
"if (ret) {",
"goto out;",
"}",
"}",
"ret = len;",
"}",
"}",
"}",
"out:\nunlock_iovec(VAR_3, target_vec, VAR_2, !send);",
"unlock_user_struct(VAR_0, target_msg, send ? 0 : 1);",
"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
] |
[
[
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
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105,
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129,
131
],
[
133
],
[
135
],
[
137
]
] |
12,902
|
void av_image_copy_plane(uint8_t *dst, int dst_linesize,
const uint8_t *src, int src_linesize,
int bytewidth, int height)
{
if (!dst || !src)
return;
for (;height > 0; height--) {
memcpy(dst, src, bytewidth);
dst += dst_linesize;
src += src_linesize;
}
}
| true
|
FFmpeg
|
252746d052652b48f7bc0652e7c1601b1e997d9c
|
void av_image_copy_plane(uint8_t *dst, int dst_linesize,
const uint8_t *src, int src_linesize,
int bytewidth, int height)
{
if (!dst || !src)
return;
for (;height > 0; height--) {
memcpy(dst, src, bytewidth);
dst += dst_linesize;
src += src_linesize;
}
}
|
{
"code": [],
"line_no": []
}
|
void FUNC_0(uint8_t *VAR_0, int VAR_1,
const uint8_t *VAR_2, int VAR_3,
int VAR_4, int VAR_5)
{
if (!VAR_0 || !VAR_2)
return;
for (;VAR_5 > 0; VAR_5--) {
memcpy(VAR_0, VAR_2, VAR_4);
VAR_0 += VAR_1;
VAR_2 += VAR_3;
}
}
|
[
"void FUNC_0(uint8_t *VAR_0, int VAR_1,\nconst uint8_t *VAR_2, int VAR_3,\nint VAR_4, int VAR_5)\n{",
"if (!VAR_0 || !VAR_2)\nreturn;",
"for (;VAR_5 > 0; VAR_5--) {",
"memcpy(VAR_0, VAR_2, VAR_4);",
"VAR_0 += VAR_1;",
"VAR_2 += VAR_3;",
"}",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3,
5,
7
],
[
9,
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
12,903
|
static int latm_decode_frame(AVCodecContext *avctx, void *out,
int *got_frame_ptr, AVPacket *avpkt)
{
struct LATMContext *latmctx = avctx->priv_data;
int muxlength, err;
GetBitContext gb;
if ((err = init_get_bits8(&gb, avpkt->data, avpkt->size)) < 0)
return err;
// check for LOAS sync word
if (get_bits(&gb, 11) != LOAS_SYNC_WORD)
return AVERROR_INVALIDDATA;
muxlength = get_bits(&gb, 13) + 3;
// not enough data, the parser should have sorted this out
if (muxlength > avpkt->size)
return AVERROR_INVALIDDATA;
if ((err = read_audio_mux_element(latmctx, &gb)) < 0)
return err;
if (!latmctx->initialized) {
if (!avctx->extradata) {
*got_frame_ptr = 0;
return avpkt->size;
} else {
push_output_configuration(&latmctx->aac_ctx);
if ((err = decode_audio_specific_config(
&latmctx->aac_ctx, avctx, &latmctx->aac_ctx.oc[1].m4ac,
avctx->extradata, avctx->extradata_size*8, 1)) < 0) {
pop_output_configuration(&latmctx->aac_ctx);
return err;
}
latmctx->initialized = 1;
}
}
if (show_bits(&gb, 12) == 0xfff) {
av_log(latmctx->aac_ctx.avctx, AV_LOG_ERROR,
"ADTS header detected, probably as result of configuration "
"misparsing\n");
return AVERROR_INVALIDDATA;
}
switch (latmctx->aac_ctx.oc[1].m4ac.object_type) {
case AOT_ER_AAC_LC:
case AOT_ER_AAC_LTP:
case AOT_ER_AAC_LD:
case AOT_ER_AAC_ELD:
err = aac_decode_er_frame(avctx, out, got_frame_ptr, &gb);
break;
default:
err = aac_decode_frame_int(avctx, out, got_frame_ptr, &gb, avpkt);
}
if (err < 0)
return err;
return muxlength;
}
| true
|
FFmpeg
|
7f46a641bf2540b8cf1293d5e50c0c0e34264254
|
static int latm_decode_frame(AVCodecContext *avctx, void *out,
int *got_frame_ptr, AVPacket *avpkt)
{
struct LATMContext *latmctx = avctx->priv_data;
int muxlength, err;
GetBitContext gb;
if ((err = init_get_bits8(&gb, avpkt->data, avpkt->size)) < 0)
return err;
if (get_bits(&gb, 11) != LOAS_SYNC_WORD)
return AVERROR_INVALIDDATA;
muxlength = get_bits(&gb, 13) + 3;
if (muxlength > avpkt->size)
return AVERROR_INVALIDDATA;
if ((err = read_audio_mux_element(latmctx, &gb)) < 0)
return err;
if (!latmctx->initialized) {
if (!avctx->extradata) {
*got_frame_ptr = 0;
return avpkt->size;
} else {
push_output_configuration(&latmctx->aac_ctx);
if ((err = decode_audio_specific_config(
&latmctx->aac_ctx, avctx, &latmctx->aac_ctx.oc[1].m4ac,
avctx->extradata, avctx->extradata_size*8, 1)) < 0) {
pop_output_configuration(&latmctx->aac_ctx);
return err;
}
latmctx->initialized = 1;
}
}
if (show_bits(&gb, 12) == 0xfff) {
av_log(latmctx->aac_ctx.avctx, AV_LOG_ERROR,
"ADTS header detected, probably as result of configuration "
"misparsing\n");
return AVERROR_INVALIDDATA;
}
switch (latmctx->aac_ctx.oc[1].m4ac.object_type) {
case AOT_ER_AAC_LC:
case AOT_ER_AAC_LTP:
case AOT_ER_AAC_LD:
case AOT_ER_AAC_ELD:
err = aac_decode_er_frame(avctx, out, got_frame_ptr, &gb);
break;
default:
err = aac_decode_frame_int(avctx, out, got_frame_ptr, &gb, avpkt);
}
if (err < 0)
return err;
return muxlength;
}
|
{
"code": [
" avctx->extradata, avctx->extradata_size*8, 1)) < 0) {"
],
"line_no": [
61
]
}
|
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
struct LATMContext *VAR_4 = VAR_0->priv_data;
int VAR_5, VAR_6;
GetBitContext gb;
if ((VAR_6 = init_get_bits8(&gb, VAR_3->data, VAR_3->size)) < 0)
return VAR_6;
if (get_bits(&gb, 11) != LOAS_SYNC_WORD)
return AVERROR_INVALIDDATA;
VAR_5 = get_bits(&gb, 13) + 3;
if (VAR_5 > VAR_3->size)
return AVERROR_INVALIDDATA;
if ((VAR_6 = read_audio_mux_element(VAR_4, &gb)) < 0)
return VAR_6;
if (!VAR_4->initialized) {
if (!VAR_0->extradata) {
*VAR_2 = 0;
return VAR_3->size;
} else {
push_output_configuration(&VAR_4->aac_ctx);
if ((VAR_6 = decode_audio_specific_config(
&VAR_4->aac_ctx, VAR_0, &VAR_4->aac_ctx.oc[1].m4ac,
VAR_0->extradata, VAR_0->extradata_size*8, 1)) < 0) {
pop_output_configuration(&VAR_4->aac_ctx);
return VAR_6;
}
VAR_4->initialized = 1;
}
}
if (show_bits(&gb, 12) == 0xfff) {
av_log(VAR_4->aac_ctx.VAR_0, AV_LOG_ERROR,
"ADTS header detected, probably as result of configuration "
"misparsing\n");
return AVERROR_INVALIDDATA;
}
switch (VAR_4->aac_ctx.oc[1].m4ac.object_type) {
case AOT_ER_AAC_LC:
case AOT_ER_AAC_LTP:
case AOT_ER_AAC_LD:
case AOT_ER_AAC_ELD:
VAR_6 = aac_decode_er_frame(VAR_0, VAR_1, VAR_2, &gb);
break;
default:
VAR_6 = aac_decode_frame_int(VAR_0, VAR_1, VAR_2, &gb, VAR_3);
}
if (VAR_6 < 0)
return VAR_6;
return VAR_5;
}
|
[
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"struct LATMContext *VAR_4 = VAR_0->priv_data;",
"int VAR_5, VAR_6;",
"GetBitContext gb;",
"if ((VAR_6 = init_get_bits8(&gb, VAR_3->data, VAR_3->size)) < 0)\nreturn VAR_6;",
"if (get_bits(&gb, 11) != LOAS_SYNC_WORD)\nreturn AVERROR_INVALIDDATA;",
"VAR_5 = get_bits(&gb, 13) + 3;",
"if (VAR_5 > VAR_3->size)\nreturn AVERROR_INVALIDDATA;",
"if ((VAR_6 = read_audio_mux_element(VAR_4, &gb)) < 0)\nreturn VAR_6;",
"if (!VAR_4->initialized) {",
"if (!VAR_0->extradata) {",
"*VAR_2 = 0;",
"return VAR_3->size;",
"} else {",
"push_output_configuration(&VAR_4->aac_ctx);",
"if ((VAR_6 = decode_audio_specific_config(\n&VAR_4->aac_ctx, VAR_0, &VAR_4->aac_ctx.oc[1].m4ac,\nVAR_0->extradata, VAR_0->extradata_size*8, 1)) < 0) {",
"pop_output_configuration(&VAR_4->aac_ctx);",
"return VAR_6;",
"}",
"VAR_4->initialized = 1;",
"}",
"}",
"if (show_bits(&gb, 12) == 0xfff) {",
"av_log(VAR_4->aac_ctx.VAR_0, AV_LOG_ERROR,\n\"ADTS header detected, probably as result of configuration \"\n\"misparsing\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"switch (VAR_4->aac_ctx.oc[1].m4ac.object_type) {",
"case AOT_ER_AAC_LC:\ncase AOT_ER_AAC_LTP:\ncase AOT_ER_AAC_LD:\ncase AOT_ER_AAC_ELD:\nVAR_6 = aac_decode_er_frame(VAR_0, VAR_1, VAR_2, &gb);",
"break;",
"default:\nVAR_6 = aac_decode_frame_int(VAR_0, VAR_1, VAR_2, &gb, VAR_3);",
"}",
"if (VAR_6 < 0)\nreturn VAR_6;",
"return VAR_5;",
"}"
] |
[
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
] |
[
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
23,
25
],
[
29
],
[
33,
35
],
[
39,
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57,
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79,
81,
83
],
[
85
],
[
87
],
[
91
],
[
93,
95,
97,
99,
101
],
[
103
],
[
105,
107
],
[
109
],
[
111,
113
],
[
117
],
[
119
]
] |
12,904
|
static int ioreq_runio_qemu_aio(struct ioreq *ioreq)
{
struct XenBlkDev *blkdev = ioreq->blkdev;
if (ioreq->req.nr_segments && ioreq_map(ioreq) == -1)
goto err;
ioreq->aio_inflight++;
if (ioreq->presync)
bdrv_flush(blkdev->bs); /* FIXME: aio_flush() ??? */
switch (ioreq->req.operation) {
case BLKIF_OP_READ:
ioreq->aio_inflight++;
bdrv_aio_readv(blkdev->bs, ioreq->start / BLOCK_SIZE,
&ioreq->v, ioreq->v.size / BLOCK_SIZE,
qemu_aio_complete, ioreq);
break;
case BLKIF_OP_WRITE:
case BLKIF_OP_WRITE_BARRIER:
ioreq->aio_inflight++;
if (!ioreq->req.nr_segments)
break;
bdrv_aio_writev(blkdev->bs, ioreq->start / BLOCK_SIZE,
&ioreq->v, ioreq->v.size / BLOCK_SIZE,
qemu_aio_complete, ioreq);
break;
default:
/* unknown operation (shouldn't happen -- parse catches this) */
goto err;
}
if (ioreq->postsync)
bdrv_flush(blkdev->bs); /* FIXME: aio_flush() ??? */
qemu_aio_complete(ioreq, 0);
return 0;
err:
ioreq->status = BLKIF_RSP_ERROR;
return -1;
}
| true
|
qemu
|
209bef3e014ba1613759575e2c10f0ef8d64eb84
|
static int ioreq_runio_qemu_aio(struct ioreq *ioreq)
{
struct XenBlkDev *blkdev = ioreq->blkdev;
if (ioreq->req.nr_segments && ioreq_map(ioreq) == -1)
goto err;
ioreq->aio_inflight++;
if (ioreq->presync)
bdrv_flush(blkdev->bs);
switch (ioreq->req.operation) {
case BLKIF_OP_READ:
ioreq->aio_inflight++;
bdrv_aio_readv(blkdev->bs, ioreq->start / BLOCK_SIZE,
&ioreq->v, ioreq->v.size / BLOCK_SIZE,
qemu_aio_complete, ioreq);
break;
case BLKIF_OP_WRITE:
case BLKIF_OP_WRITE_BARRIER:
ioreq->aio_inflight++;
if (!ioreq->req.nr_segments)
break;
bdrv_aio_writev(blkdev->bs, ioreq->start / BLOCK_SIZE,
&ioreq->v, ioreq->v.size / BLOCK_SIZE,
qemu_aio_complete, ioreq);
break;
default:
goto err;
}
if (ioreq->postsync)
bdrv_flush(blkdev->bs);
qemu_aio_complete(ioreq, 0);
return 0;
err:
ioreq->status = BLKIF_RSP_ERROR;
return -1;
}
|
{
"code": [
" ioreq->aio_inflight++;"
],
"line_no": [
27
]
}
|
static int FUNC_0(struct VAR_0 *VAR_0)
{
struct XenBlkDev *VAR_1 = VAR_0->VAR_1;
if (VAR_0->req.nr_segments && ioreq_map(VAR_0) == -1)
goto err;
VAR_0->aio_inflight++;
if (VAR_0->presync)
bdrv_flush(VAR_1->bs);
switch (VAR_0->req.operation) {
case BLKIF_OP_READ:
VAR_0->aio_inflight++;
bdrv_aio_readv(VAR_1->bs, VAR_0->start / BLOCK_SIZE,
&VAR_0->v, VAR_0->v.size / BLOCK_SIZE,
qemu_aio_complete, VAR_0);
break;
case BLKIF_OP_WRITE:
case BLKIF_OP_WRITE_BARRIER:
VAR_0->aio_inflight++;
if (!VAR_0->req.nr_segments)
break;
bdrv_aio_writev(VAR_1->bs, VAR_0->start / BLOCK_SIZE,
&VAR_0->v, VAR_0->v.size / BLOCK_SIZE,
qemu_aio_complete, VAR_0);
break;
default:
goto err;
}
if (VAR_0->postsync)
bdrv_flush(VAR_1->bs);
qemu_aio_complete(VAR_0, 0);
return 0;
err:
VAR_0->status = BLKIF_RSP_ERROR;
return -1;
}
|
[
"static int FUNC_0(struct VAR_0 *VAR_0)\n{",
"struct XenBlkDev *VAR_1 = VAR_0->VAR_1;",
"if (VAR_0->req.nr_segments && ioreq_map(VAR_0) == -1)\ngoto err;",
"VAR_0->aio_inflight++;",
"if (VAR_0->presync)\nbdrv_flush(VAR_1->bs);",
"switch (VAR_0->req.operation) {",
"case BLKIF_OP_READ:\nVAR_0->aio_inflight++;",
"bdrv_aio_readv(VAR_1->bs, VAR_0->start / BLOCK_SIZE,\n&VAR_0->v, VAR_0->v.size / BLOCK_SIZE,\nqemu_aio_complete, VAR_0);",
"break;",
"case BLKIF_OP_WRITE:\ncase BLKIF_OP_WRITE_BARRIER:\nVAR_0->aio_inflight++;",
"if (!VAR_0->req.nr_segments)\nbreak;",
"bdrv_aio_writev(VAR_1->bs, VAR_0->start / BLOCK_SIZE,\n&VAR_0->v, VAR_0->v.size / BLOCK_SIZE,\nqemu_aio_complete, VAR_0);",
"break;",
"default:\ngoto err;",
"}",
"if (VAR_0->postsync)\nbdrv_flush(VAR_1->bs);",
"qemu_aio_complete(VAR_0, 0);",
"return 0;",
"err:\nVAR_0->status = BLKIF_RSP_ERROR;",
"return -1;",
"}"
] |
[
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
9,
11
],
[
15
],
[
17,
19
],
[
23
],
[
25,
27
],
[
29,
31,
33
],
[
35
],
[
37,
39,
41
],
[
43,
45
],
[
47,
49,
51
],
[
53
],
[
55,
59
],
[
61
],
[
65,
67
],
[
69
],
[
73
],
[
77,
79
],
[
81
],
[
83
]
] |
12,905
|
int attribute_align_arg avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
const AVFrame *pict)
{
AVPacket pkt;
int ret, got_packet = 0;
if (buf_size < FF_MIN_BUFFER_SIZE) {
av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n");
return -1;
}
av_init_packet(&pkt);
pkt.data = buf;
pkt.size = buf_size;
ret = avcodec_encode_video2(avctx, &pkt, pict, &got_packet);
if (!ret && got_packet && avctx->coded_frame) {
avctx->coded_frame->pts = pkt.pts;
avctx->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY);
}
/* free any side data since we cannot return it */
if (pkt.side_data_elems > 0) {
int i;
for (i = 0; i < pkt.side_data_elems; i++)
av_free(pkt.side_data[i].data);
av_freep(&pkt.side_data);
pkt.side_data_elems = 0;
}
return ret ? ret : pkt.size;
}
| true
|
FFmpeg
|
d32547a24a3fcc8286b318353f43805838b84775
|
int attribute_align_arg avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
const AVFrame *pict)
{
AVPacket pkt;
int ret, got_packet = 0;
if (buf_size < FF_MIN_BUFFER_SIZE) {
av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n");
return -1;
}
av_init_packet(&pkt);
pkt.data = buf;
pkt.size = buf_size;
ret = avcodec_encode_video2(avctx, &pkt, pict, &got_packet);
if (!ret && got_packet && avctx->coded_frame) {
avctx->coded_frame->pts = pkt.pts;
avctx->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY);
}
if (pkt.side_data_elems > 0) {
int i;
for (i = 0; i < pkt.side_data_elems; i++)
av_free(pkt.side_data[i].data);
av_freep(&pkt.side_data);
pkt.side_data_elems = 0;
}
return ret ? ret : pkt.size;
}
|
{
"code": [],
"line_no": []
}
|
int VAR_0 avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
const AVFrame *pict)
{
AVPacket pkt;
int ret, got_packet = 0;
if (buf_size < FF_MIN_BUFFER_SIZE) {
av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n");
return -1;
}
av_init_packet(&pkt);
pkt.data = buf;
pkt.size = buf_size;
ret = avcodec_encode_video2(avctx, &pkt, pict, &got_packet);
if (!ret && got_packet && avctx->coded_frame) {
avctx->coded_frame->pts = pkt.pts;
avctx->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY);
}
if (pkt.side_data_elems > 0) {
int i;
for (i = 0; i < pkt.side_data_elems; i++)
av_free(pkt.side_data[i].data);
av_freep(&pkt.side_data);
pkt.side_data_elems = 0;
}
return ret ? ret : pkt.size;
}
|
[
"int VAR_0 avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,\nconst AVFrame *pict)\n{",
"AVPacket pkt;",
"int ret, got_packet = 0;",
"if (buf_size < FF_MIN_BUFFER_SIZE) {",
"av_log(avctx, AV_LOG_ERROR, \"buffer smaller than minimum size\\n\");",
"return -1;",
"}",
"av_init_packet(&pkt);",
"pkt.data = buf;",
"pkt.size = buf_size;",
"ret = avcodec_encode_video2(avctx, &pkt, pict, &got_packet);",
"if (!ret && got_packet && avctx->coded_frame) {",
"avctx->coded_frame->pts = pkt.pts;",
"avctx->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY);",
"}",
"if (pkt.side_data_elems > 0) {",
"int i;",
"for (i = 0; i < pkt.side_data_elems; i++)",
"av_free(pkt.side_data[i].data);",
"av_freep(&pkt.side_data);",
"pkt.side_data_elems = 0;",
"}",
"return ret ? ret : pkt.size;",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
]
] |
12,906
|
static void spapr_pci_pre_save(void *opaque)
{
sPAPRPHBState *sphb = opaque;
GHashTableIter iter;
gpointer key, value;
int i;
g_free(sphb->msi_devs);
sphb->msi_devs = NULL;
sphb->msi_devs_num = g_hash_table_size(sphb->msi);
if (!sphb->msi_devs_num) {
return;
}
sphb->msi_devs = g_malloc(sphb->msi_devs_num * sizeof(spapr_pci_msi_mig));
g_hash_table_iter_init(&iter, sphb->msi);
for (i = 0; g_hash_table_iter_next(&iter, &key, &value); ++i) {
sphb->msi_devs[i].key = *(uint32_t *) key;
sphb->msi_devs[i].value = *(spapr_pci_msi *) value;
}
if (sphb->pre_2_8_migration) {
sphb->mig_liobn = sphb->dma_liobn[0];
sphb->mig_mem_win_addr = sphb->mem_win_addr;
sphb->mig_mem_win_size = sphb->mem_win_size;
sphb->mig_io_win_addr = sphb->io_win_addr;
sphb->mig_io_win_size = sphb->io_win_size;
if ((sphb->mem64_win_size != 0)
&& (sphb->mem64_win_addr
== (sphb->mem_win_addr + sphb->mem_win_size))) {
sphb->mig_mem_win_size += sphb->mem64_win_size;
}
}
}
| true
|
qemu
|
e806b4db1477a1c6bfda7bba28c7f26c47f18e1e
|
static void spapr_pci_pre_save(void *opaque)
{
sPAPRPHBState *sphb = opaque;
GHashTableIter iter;
gpointer key, value;
int i;
g_free(sphb->msi_devs);
sphb->msi_devs = NULL;
sphb->msi_devs_num = g_hash_table_size(sphb->msi);
if (!sphb->msi_devs_num) {
return;
}
sphb->msi_devs = g_malloc(sphb->msi_devs_num * sizeof(spapr_pci_msi_mig));
g_hash_table_iter_init(&iter, sphb->msi);
for (i = 0; g_hash_table_iter_next(&iter, &key, &value); ++i) {
sphb->msi_devs[i].key = *(uint32_t *) key;
sphb->msi_devs[i].value = *(spapr_pci_msi *) value;
}
if (sphb->pre_2_8_migration) {
sphb->mig_liobn = sphb->dma_liobn[0];
sphb->mig_mem_win_addr = sphb->mem_win_addr;
sphb->mig_mem_win_size = sphb->mem_win_size;
sphb->mig_io_win_addr = sphb->io_win_addr;
sphb->mig_io_win_size = sphb->io_win_size;
if ((sphb->mem64_win_size != 0)
&& (sphb->mem64_win_addr
== (sphb->mem_win_addr + sphb->mem_win_size))) {
sphb->mig_mem_win_size += sphb->mem64_win_size;
}
}
}
|
{
"code": [
" g_free(sphb->msi_devs);",
" sphb->msi_devs = NULL;",
" sphb->msi_devs_num = g_hash_table_size(sphb->msi);",
" if (!sphb->msi_devs_num) {",
" sphb->msi_devs = g_malloc(sphb->msi_devs_num * sizeof(spapr_pci_msi_mig));",
" g_hash_table_iter_init(&iter, sphb->msi);",
" for (i = 0; g_hash_table_iter_next(&iter, &key, &value); ++i) {",
" sphb->msi_devs[i].key = *(uint32_t *) key;",
" sphb->msi_devs[i].value = *(spapr_pci_msi *) value;"
],
"line_no": [
15,
17,
19,
21,
27,
31,
33,
35,
37
]
}
|
static void FUNC_0(void *VAR_0)
{
sPAPRPHBState *sphb = VAR_0;
GHashTableIter iter;
gpointer key, value;
int VAR_1;
g_free(sphb->msi_devs);
sphb->msi_devs = NULL;
sphb->msi_devs_num = g_hash_table_size(sphb->msi);
if (!sphb->msi_devs_num) {
return;
}
sphb->msi_devs = g_malloc(sphb->msi_devs_num * sizeof(spapr_pci_msi_mig));
g_hash_table_iter_init(&iter, sphb->msi);
for (VAR_1 = 0; g_hash_table_iter_next(&iter, &key, &value); ++VAR_1) {
sphb->msi_devs[VAR_1].key = *(uint32_t *) key;
sphb->msi_devs[VAR_1].value = *(spapr_pci_msi *) value;
}
if (sphb->pre_2_8_migration) {
sphb->mig_liobn = sphb->dma_liobn[0];
sphb->mig_mem_win_addr = sphb->mem_win_addr;
sphb->mig_mem_win_size = sphb->mem_win_size;
sphb->mig_io_win_addr = sphb->io_win_addr;
sphb->mig_io_win_size = sphb->io_win_size;
if ((sphb->mem64_win_size != 0)
&& (sphb->mem64_win_addr
== (sphb->mem_win_addr + sphb->mem_win_size))) {
sphb->mig_mem_win_size += sphb->mem64_win_size;
}
}
}
|
[
"static void FUNC_0(void *VAR_0)\n{",
"sPAPRPHBState *sphb = VAR_0;",
"GHashTableIter iter;",
"gpointer key, value;",
"int VAR_1;",
"g_free(sphb->msi_devs);",
"sphb->msi_devs = NULL;",
"sphb->msi_devs_num = g_hash_table_size(sphb->msi);",
"if (!sphb->msi_devs_num) {",
"return;",
"}",
"sphb->msi_devs = g_malloc(sphb->msi_devs_num * sizeof(spapr_pci_msi_mig));",
"g_hash_table_iter_init(&iter, sphb->msi);",
"for (VAR_1 = 0; g_hash_table_iter_next(&iter, &key, &value); ++VAR_1) {",
"sphb->msi_devs[VAR_1].key = *(uint32_t *) key;",
"sphb->msi_devs[VAR_1].value = *(spapr_pci_msi *) value;",
"}",
"if (sphb->pre_2_8_migration) {",
"sphb->mig_liobn = sphb->dma_liobn[0];",
"sphb->mig_mem_win_addr = sphb->mem_win_addr;",
"sphb->mig_mem_win_size = sphb->mem_win_size;",
"sphb->mig_io_win_addr = sphb->io_win_addr;",
"sphb->mig_io_win_size = sphb->io_win_size;",
"if ((sphb->mem64_win_size != 0)\n&& (sphb->mem64_win_addr\n== (sphb->mem_win_addr + sphb->mem_win_size))) {",
"sphb->mig_mem_win_size += sphb->mem64_win_size;",
"}",
"}",
"}"
] |
[
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57,
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
]
] |
12,907
|
static void print_report(AVFormatContext **output_files,
AVOutputStream **ost_table, int nb_ostreams,
int is_last_report)
{
char buf[1024];
AVOutputStream *ost;
AVFormatContext *oc, *os;
int64_t total_size;
AVCodecContext *enc;
int frame_number, vid, i;
double bitrate, ti1, pts;
static int64_t last_time = -1;
static int qp_histogram[52];
if (!is_last_report) {
int64_t cur_time;
/* display the report every 0.5 seconds */
cur_time = av_gettime();
if (last_time == -1) {
last_time = cur_time;
return;
}
if ((cur_time - last_time) < 500000)
return;
last_time = cur_time;
}
oc = output_files[0];
total_size = url_fsize(oc->pb);
if(total_size<0) // FIXME improve url_fsize() so it works with non seekable output too
total_size= url_ftell(oc->pb);
buf[0] = '\0';
ti1 = 1e10;
vid = 0;
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
os = output_files[ost->file_index];
enc = ost->st->codec;
if (vid && enc->codec_type == CODEC_TYPE_VIDEO) {
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ",
enc->coded_frame->quality/(float)FF_QP2LAMBDA);
}
if (!vid && enc->codec_type == CODEC_TYPE_VIDEO) {
float t = (av_gettime()-timer_start) / 1000000.0;
frame_number = ost->frame_number;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d fps=%3d q=%3.1f ",
frame_number, (t>1)?(int)(frame_number/t+0.5) : 0,
enc->coded_frame ? enc->coded_frame->quality/(float)FF_QP2LAMBDA : -1);
if(is_last_report)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "L");
if(qp_hist && enc->coded_frame){
int j;
int qp= lrintf(enc->coded_frame->quality/(float)FF_QP2LAMBDA);
if(qp>=0 && qp<sizeof(qp_histogram)/sizeof(int))
qp_histogram[qp]++;
for(j=0; j<32; j++)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%X", (int)lrintf(log(qp_histogram[j]+1)/log(2)));
}
if (enc->flags&CODEC_FLAG_PSNR){
int j;
double error, error_sum=0;
double scale, scale_sum=0;
char type[3]= {'Y','U','V'};
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "PSNR=");
for(j=0; j<3; j++){
if(is_last_report){
error= enc->error[j];
scale= enc->width*enc->height*255.0*255.0*frame_number;
}else{
error= enc->coded_frame->error[j];
scale= enc->width*enc->height*255.0*255.0;
}
if(j) scale/=4;
error_sum += error;
scale_sum += scale;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%c:%2.2f ", type[j], psnr(error/scale));
}
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "*:%2.2f ", psnr(error_sum/scale_sum));
}
vid = 1;
}
/* compute min output value */
pts = (double)ost->st->pts.val * av_q2d(ost->st->time_base);
if ((pts < ti1) && (pts > 0))
ti1 = pts;
}
if (ti1 < 0.01)
ti1 = 0.01;
if (verbose || is_last_report) {
bitrate = (double)(total_size * 8) / ti1 / 1000.0;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
"size=%8.0fkB time=%0.1f bitrate=%6.1fkbits/s",
(double)total_size / 1024, ti1, bitrate);
if (verbose > 1)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " dup=%d drop=%d",
nb_frames_dup, nb_frames_drop);
if (verbose >= 0)
fprintf(stderr, "%s \r", buf);
fflush(stderr);
}
if (is_last_report && verbose >= 0){
int64_t raw= audio_size + video_size + extra_size;
fprintf(stderr, "\n");
fprintf(stderr, "video:%1.0fkB audio:%1.0fkB global headers:%1.0fkB muxing overhead %f%%\n",
video_size/1024.0,
audio_size/1024.0,
extra_size/1024.0,
100.0*(total_size - raw)/raw
);
}
}
| true
|
FFmpeg
|
99fb79b55ad9e6be52c16f2fd794f350bd76154a
|
static void print_report(AVFormatContext **output_files,
AVOutputStream **ost_table, int nb_ostreams,
int is_last_report)
{
char buf[1024];
AVOutputStream *ost;
AVFormatContext *oc, *os;
int64_t total_size;
AVCodecContext *enc;
int frame_number, vid, i;
double bitrate, ti1, pts;
static int64_t last_time = -1;
static int qp_histogram[52];
if (!is_last_report) {
int64_t cur_time;
cur_time = av_gettime();
if (last_time == -1) {
last_time = cur_time;
return;
}
if ((cur_time - last_time) < 500000)
return;
last_time = cur_time;
}
oc = output_files[0];
total_size = url_fsize(oc->pb);
if(total_size<0)
total_size= url_ftell(oc->pb);
buf[0] = '\0';
ti1 = 1e10;
vid = 0;
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
os = output_files[ost->file_index];
enc = ost->st->codec;
if (vid && enc->codec_type == CODEC_TYPE_VIDEO) {
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ",
enc->coded_frame->quality/(float)FF_QP2LAMBDA);
}
if (!vid && enc->codec_type == CODEC_TYPE_VIDEO) {
float t = (av_gettime()-timer_start) / 1000000.0;
frame_number = ost->frame_number;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d fps=%3d q=%3.1f ",
frame_number, (t>1)?(int)(frame_number/t+0.5) : 0,
enc->coded_frame ? enc->coded_frame->quality/(float)FF_QP2LAMBDA : -1);
if(is_last_report)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "L");
if(qp_hist && enc->coded_frame){
int j;
int qp= lrintf(enc->coded_frame->quality/(float)FF_QP2LAMBDA);
if(qp>=0 && qp<sizeof(qp_histogram)/sizeof(int))
qp_histogram[qp]++;
for(j=0; j<32; j++)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%X", (int)lrintf(log(qp_histogram[j]+1)/log(2)));
}
if (enc->flags&CODEC_FLAG_PSNR){
int j;
double error, error_sum=0;
double scale, scale_sum=0;
char type[3]= {'Y','U','V'};
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "PSNR=");
for(j=0; j<3; j++){
if(is_last_report){
error= enc->error[j];
scale= enc->width*enc->height*255.0*255.0*frame_number;
}else{
error= enc->coded_frame->error[j];
scale= enc->width*enc->height*255.0*255.0;
}
if(j) scale/=4;
error_sum += error;
scale_sum += scale;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%c:%2.2f ", type[j], psnr(error/scale));
}
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "*:%2.2f ", psnr(error_sum/scale_sum));
}
vid = 1;
}
pts = (double)ost->st->pts.val * av_q2d(ost->st->time_base);
if ((pts < ti1) && (pts > 0))
ti1 = pts;
}
if (ti1 < 0.01)
ti1 = 0.01;
if (verbose || is_last_report) {
bitrate = (double)(total_size * 8) / ti1 / 1000.0;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
"size=%8.0fkB time=%0.1f bitrate=%6.1fkbits/s",
(double)total_size / 1024, ti1, bitrate);
if (verbose > 1)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " dup=%d drop=%d",
nb_frames_dup, nb_frames_drop);
if (verbose >= 0)
fprintf(stderr, "%s \r", buf);
fflush(stderr);
}
if (is_last_report && verbose >= 0){
int64_t raw= audio_size + video_size + extra_size;
fprintf(stderr, "\n");
fprintf(stderr, "video:%1.0fkB audio:%1.0fkB global headers:%1.0fkB muxing overhead %f%%\n",
video_size/1024.0,
audio_size/1024.0,
extra_size/1024.0,
100.0*(total_size - raw)/raw
);
}
}
|
{
"code": [
" enc->coded_frame->quality/(float)FF_QP2LAMBDA);",
" enc->coded_frame ? enc->coded_frame->quality/(float)FF_QP2LAMBDA : -1);"
],
"line_no": [
87,
103
]
}
|
static void FUNC_0(AVFormatContext **VAR_0,
AVOutputStream **VAR_1, int VAR_2,
int VAR_3)
{
char VAR_4[1024];
AVOutputStream *ost;
AVFormatContext *oc, *os;
int64_t total_size;
AVCodecContext *enc;
int VAR_5, VAR_6, VAR_7;
double VAR_8, VAR_9, VAR_10;
static int64_t VAR_11 = -1;
static int VAR_12[52];
if (!VAR_3) {
int64_t cur_time;
cur_time = av_gettime();
if (VAR_11 == -1) {
VAR_11 = cur_time;
return;
}
if ((cur_time - VAR_11) < 500000)
return;
VAR_11 = cur_time;
}
oc = VAR_0[0];
total_size = url_fsize(oc->pb);
if(total_size<0)
total_size= url_ftell(oc->pb);
VAR_4[0] = '\0';
VAR_9 = 1e10;
VAR_6 = 0;
for(VAR_7=0;VAR_7<VAR_2;VAR_7++) {
ost = VAR_1[VAR_7];
os = VAR_0[ost->file_index];
enc = ost->st->codec;
if (VAR_6 && enc->codec_type == CODEC_TYPE_VIDEO) {
snprintf(VAR_4 + strlen(VAR_4), sizeof(VAR_4) - strlen(VAR_4), "q=%2.1f ",
enc->coded_frame->quality/(float)FF_QP2LAMBDA);
}
if (!VAR_6 && enc->codec_type == CODEC_TYPE_VIDEO) {
float VAR_13 = (av_gettime()-timer_start) / 1000000.0;
VAR_5 = ost->VAR_5;
snprintf(VAR_4 + strlen(VAR_4), sizeof(VAR_4) - strlen(VAR_4), "frame=%5d fps=%3d q=%3.1f ",
VAR_5, (VAR_13>1)?(int)(VAR_5/VAR_13+0.5) : 0,
enc->coded_frame ? enc->coded_frame->quality/(float)FF_QP2LAMBDA : -1);
if(VAR_3)
snprintf(VAR_4 + strlen(VAR_4), sizeof(VAR_4) - strlen(VAR_4), "L");
if(qp_hist && enc->coded_frame){
int VAR_16;
int VAR_15= lrintf(enc->coded_frame->quality/(float)FF_QP2LAMBDA);
if(VAR_15>=0 && VAR_15<sizeof(VAR_12)/sizeof(int))
VAR_12[VAR_15]++;
for(VAR_16=0; VAR_16<32; VAR_16++)
snprintf(VAR_4 + strlen(VAR_4), sizeof(VAR_4) - strlen(VAR_4), "%X", (int)lrintf(log(VAR_12[VAR_16]+1)/log(2)));
}
if (enc->flags&CODEC_FLAG_PSNR){
int VAR_16;
double VAR_16, VAR_17=0;
double VAR_18, VAR_19=0;
char VAR_20[3]= {'Y','U','V'};
snprintf(VAR_4 + strlen(VAR_4), sizeof(VAR_4) - strlen(VAR_4), "PSNR=");
for(VAR_16=0; VAR_16<3; VAR_16++){
if(VAR_3){
VAR_16= enc->VAR_16[VAR_16];
VAR_18= enc->width*enc->height*255.0*255.0*VAR_5;
}else{
VAR_16= enc->coded_frame->VAR_16[VAR_16];
VAR_18= enc->width*enc->height*255.0*255.0;
}
if(VAR_16) VAR_18/=4;
VAR_17 += VAR_16;
VAR_19 += VAR_18;
snprintf(VAR_4 + strlen(VAR_4), sizeof(VAR_4) - strlen(VAR_4), "%c:%2.2f ", VAR_20[VAR_16], psnr(VAR_16/VAR_18));
}
snprintf(VAR_4 + strlen(VAR_4), sizeof(VAR_4) - strlen(VAR_4), "*:%2.2f ", psnr(VAR_17/VAR_19));
}
VAR_6 = 1;
}
VAR_10 = (double)ost->st->VAR_10.val * av_q2d(ost->st->time_base);
if ((VAR_10 < VAR_9) && (VAR_10 > 0))
VAR_9 = VAR_10;
}
if (VAR_9 < 0.01)
VAR_9 = 0.01;
if (verbose || VAR_3) {
VAR_8 = (double)(total_size * 8) / VAR_9 / 1000.0;
snprintf(VAR_4 + strlen(VAR_4), sizeof(VAR_4) - strlen(VAR_4),
"size=%8.0fkB time=%0.1f VAR_8=%6.1fkbits/s",
(double)total_size / 1024, VAR_9, VAR_8);
if (verbose > 1)
snprintf(VAR_4 + strlen(VAR_4), sizeof(VAR_4) - strlen(VAR_4), " dup=%d drop=%d",
nb_frames_dup, nb_frames_drop);
if (verbose >= 0)
fprintf(stderr, "%s \r", VAR_4);
fflush(stderr);
}
if (VAR_3 && verbose >= 0){
int64_t raw= audio_size + video_size + extra_size;
fprintf(stderr, "\n");
fprintf(stderr, "video:%1.0fkB audio:%1.0fkB global headers:%1.0fkB muxing overhead %f%%\n",
video_size/1024.0,
audio_size/1024.0,
extra_size/1024.0,
100.0*(total_size - raw)/raw
);
}
}
|
[
"static void FUNC_0(AVFormatContext **VAR_0,\nAVOutputStream **VAR_1, int VAR_2,\nint VAR_3)\n{",
"char VAR_4[1024];",
"AVOutputStream *ost;",
"AVFormatContext *oc, *os;",
"int64_t total_size;",
"AVCodecContext *enc;",
"int VAR_5, VAR_6, VAR_7;",
"double VAR_8, VAR_9, VAR_10;",
"static int64_t VAR_11 = -1;",
"static int VAR_12[52];",
"if (!VAR_3) {",
"int64_t cur_time;",
"cur_time = av_gettime();",
"if (VAR_11 == -1) {",
"VAR_11 = cur_time;",
"return;",
"}",
"if ((cur_time - VAR_11) < 500000)\nreturn;",
"VAR_11 = cur_time;",
"}",
"oc = VAR_0[0];",
"total_size = url_fsize(oc->pb);",
"if(total_size<0)\ntotal_size= url_ftell(oc->pb);",
"VAR_4[0] = '\\0';",
"VAR_9 = 1e10;",
"VAR_6 = 0;",
"for(VAR_7=0;VAR_7<VAR_2;VAR_7++) {",
"ost = VAR_1[VAR_7];",
"os = VAR_0[ost->file_index];",
"enc = ost->st->codec;",
"if (VAR_6 && enc->codec_type == CODEC_TYPE_VIDEO) {",
"snprintf(VAR_4 + strlen(VAR_4), sizeof(VAR_4) - strlen(VAR_4), \"q=%2.1f \",\nenc->coded_frame->quality/(float)FF_QP2LAMBDA);",
"}",
"if (!VAR_6 && enc->codec_type == CODEC_TYPE_VIDEO) {",
"float VAR_13 = (av_gettime()-timer_start) / 1000000.0;",
"VAR_5 = ost->VAR_5;",
"snprintf(VAR_4 + strlen(VAR_4), sizeof(VAR_4) - strlen(VAR_4), \"frame=%5d fps=%3d q=%3.1f \",\nVAR_5, (VAR_13>1)?(int)(VAR_5/VAR_13+0.5) : 0,\nenc->coded_frame ? enc->coded_frame->quality/(float)FF_QP2LAMBDA : -1);",
"if(VAR_3)\nsnprintf(VAR_4 + strlen(VAR_4), sizeof(VAR_4) - strlen(VAR_4), \"L\");",
"if(qp_hist && enc->coded_frame){",
"int VAR_16;",
"int VAR_15= lrintf(enc->coded_frame->quality/(float)FF_QP2LAMBDA);",
"if(VAR_15>=0 && VAR_15<sizeof(VAR_12)/sizeof(int))\nVAR_12[VAR_15]++;",
"for(VAR_16=0; VAR_16<32; VAR_16++)",
"snprintf(VAR_4 + strlen(VAR_4), sizeof(VAR_4) - strlen(VAR_4), \"%X\", (int)lrintf(log(VAR_12[VAR_16]+1)/log(2)));",
"}",
"if (enc->flags&CODEC_FLAG_PSNR){",
"int VAR_16;",
"double VAR_16, VAR_17=0;",
"double VAR_18, VAR_19=0;",
"char VAR_20[3]= {'Y','U','V'};",
"snprintf(VAR_4 + strlen(VAR_4), sizeof(VAR_4) - strlen(VAR_4), \"PSNR=\");",
"for(VAR_16=0; VAR_16<3; VAR_16++){",
"if(VAR_3){",
"VAR_16= enc->VAR_16[VAR_16];",
"VAR_18= enc->width*enc->height*255.0*255.0*VAR_5;",
"}else{",
"VAR_16= enc->coded_frame->VAR_16[VAR_16];",
"VAR_18= enc->width*enc->height*255.0*255.0;",
"}",
"if(VAR_16) VAR_18/=4;",
"VAR_17 += VAR_16;",
"VAR_19 += VAR_18;",
"snprintf(VAR_4 + strlen(VAR_4), sizeof(VAR_4) - strlen(VAR_4), \"%c:%2.2f \", VAR_20[VAR_16], psnr(VAR_16/VAR_18));",
"}",
"snprintf(VAR_4 + strlen(VAR_4), sizeof(VAR_4) - strlen(VAR_4), \"*:%2.2f \", psnr(VAR_17/VAR_19));",
"}",
"VAR_6 = 1;",
"}",
"VAR_10 = (double)ost->st->VAR_10.val * av_q2d(ost->st->time_base);",
"if ((VAR_10 < VAR_9) && (VAR_10 > 0))\nVAR_9 = VAR_10;",
"}",
"if (VAR_9 < 0.01)\nVAR_9 = 0.01;",
"if (verbose || VAR_3) {",
"VAR_8 = (double)(total_size * 8) / VAR_9 / 1000.0;",
"snprintf(VAR_4 + strlen(VAR_4), sizeof(VAR_4) - strlen(VAR_4),\n\"size=%8.0fkB time=%0.1f VAR_8=%6.1fkbits/s\",\n(double)total_size / 1024, VAR_9, VAR_8);",
"if (verbose > 1)\nsnprintf(VAR_4 + strlen(VAR_4), sizeof(VAR_4) - strlen(VAR_4), \" dup=%d drop=%d\",\nnb_frames_dup, nb_frames_drop);",
"if (verbose >= 0)\nfprintf(stderr, \"%s \\r\", VAR_4);",
"fflush(stderr);",
"}",
"if (VAR_3 && verbose >= 0){",
"int64_t raw= audio_size + video_size + extra_size;",
"fprintf(stderr, \"\\n\");",
"fprintf(stderr, \"video:%1.0fkB audio:%1.0fkB global headers:%1.0fkB muxing overhead %f%%\\n\",\nvideo_size/1024.0,\naudio_size/1024.0,\nextra_size/1024.0,\n100.0*(total_size - raw)/raw\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,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
57
],
[
61
],
[
63,
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
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
],
[
173
],
[
175,
177
],
[
179
],
[
181,
183
],
[
187
],
[
189
],
[
193,
195,
197
],
[
201,
203,
205
],
[
209,
211
],
[
215
],
[
217
],
[
221
],
[
223
],
[
225
],
[
227,
229,
231,
233,
235,
237
],
[
239
],
[
241
]
] |
12,908
|
static void decode_opc(DisasContext * ctx)
{
uint32_t old_flags = ctx->envflags;
_decode_opc(ctx);
if (old_flags & DELAY_SLOT_MASK) {
/* go out of the delay slot */
ctx->envflags &= ~DELAY_SLOT_MASK;
tcg_gen_movi_i32(cpu_flags, ctx->envflags);
ctx->bstate = BS_BRANCH;
if (old_flags & DELAY_SLOT_CONDITIONAL) {
gen_delayed_conditional_jump(ctx);
} else if (old_flags & DELAY_SLOT) {
gen_jump(ctx);
}
}
}
| true
|
qemu
|
be53081a619443dc4512039d89345475ef7d9a46
|
static void decode_opc(DisasContext * ctx)
{
uint32_t old_flags = ctx->envflags;
_decode_opc(ctx);
if (old_flags & DELAY_SLOT_MASK) {
ctx->envflags &= ~DELAY_SLOT_MASK;
tcg_gen_movi_i32(cpu_flags, ctx->envflags);
ctx->bstate = BS_BRANCH;
if (old_flags & DELAY_SLOT_CONDITIONAL) {
gen_delayed_conditional_jump(ctx);
} else if (old_flags & DELAY_SLOT) {
gen_jump(ctx);
}
}
}
|
{
"code": [
" } else if (old_flags & DELAY_SLOT) {"
],
"line_no": [
27
]
}
|
static void FUNC_0(DisasContext * VAR_0)
{
uint32_t old_flags = VAR_0->envflags;
_decode_opc(VAR_0);
if (old_flags & DELAY_SLOT_MASK) {
VAR_0->envflags &= ~DELAY_SLOT_MASK;
tcg_gen_movi_i32(cpu_flags, VAR_0->envflags);
VAR_0->bstate = BS_BRANCH;
if (old_flags & DELAY_SLOT_CONDITIONAL) {
gen_delayed_conditional_jump(VAR_0);
} else if (old_flags & DELAY_SLOT) {
gen_jump(VAR_0);
}
}
}
|
[
"static void FUNC_0(DisasContext * VAR_0)\n{",
"uint32_t old_flags = VAR_0->envflags;",
"_decode_opc(VAR_0);",
"if (old_flags & DELAY_SLOT_MASK) {",
"VAR_0->envflags &= ~DELAY_SLOT_MASK;",
"tcg_gen_movi_i32(cpu_flags, VAR_0->envflags);",
"VAR_0->bstate = BS_BRANCH;",
"if (old_flags & DELAY_SLOT_CONDITIONAL) {",
"gen_delayed_conditional_jump(VAR_0);",
"} else if (old_flags & DELAY_SLOT) {",
"gen_jump(VAR_0);",
"}",
"}",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
]
] |
12,909
|
grlib_apbuart_writel(void *opaque, target_phys_addr_t addr, uint32_t value)
{
UART *uart = opaque;
unsigned char c = 0;
addr &= 0xff;
/* Unit registers */
switch (addr) {
case DATA_OFFSET:
c = value & 0xFF;
qemu_chr_write(uart->chr, &c, 1);
return;
case STATUS_OFFSET:
/* Read Only */
return;
case CONTROL_OFFSET:
/* Not supported */
return;
case SCALER_OFFSET:
/* Not supported */
return;
default:
break;
}
trace_grlib_apbuart_unknown_register("write", addr);
}
| true
|
qemu
|
b4548fcc0314f5e118ed45b5774e9cd99f9a97d3
|
grlib_apbuart_writel(void *opaque, target_phys_addr_t addr, uint32_t value)
{
UART *uart = opaque;
unsigned char c = 0;
addr &= 0xff;
switch (addr) {
case DATA_OFFSET:
c = value & 0xFF;
qemu_chr_write(uart->chr, &c, 1);
return;
case STATUS_OFFSET:
return;
case CONTROL_OFFSET:
return;
case SCALER_OFFSET:
return;
default:
break;
}
trace_grlib_apbuart_unknown_register("write", addr);
}
|
{
"code": [
" trace_grlib_apbuart_unknown_register(\"write\", addr);"
],
"line_no": [
61
]
}
|
FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint32_t VAR_2)
{
UART *uart = VAR_0;
unsigned char VAR_3 = 0;
VAR_1 &= 0xff;
switch (VAR_1) {
case DATA_OFFSET:
VAR_3 = VAR_2 & 0xFF;
qemu_chr_write(uart->chr, &VAR_3, 1);
return;
case STATUS_OFFSET:
return;
case CONTROL_OFFSET:
return;
case SCALER_OFFSET:
return;
default:
break;
}
trace_grlib_apbuart_unknown_register("write", VAR_1);
}
|
[
"FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint32_t VAR_2)\n{",
"UART *uart = VAR_0;",
"unsigned char VAR_3 = 0;",
"VAR_1 &= 0xff;",
"switch (VAR_1) {",
"case DATA_OFFSET:\nVAR_3 = VAR_2 & 0xFF;",
"qemu_chr_write(uart->chr, &VAR_3, 1);",
"return;",
"case STATUS_OFFSET:\nreturn;",
"case CONTROL_OFFSET:\nreturn;",
"case SCALER_OFFSET:\nreturn;",
"default:\nbreak;",
"}",
"trace_grlib_apbuart_unknown_register(\"write\", VAR_1);",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
29,
33
],
[
37,
41
],
[
45,
49
],
[
53,
55
],
[
57
],
[
61
],
[
63
]
] |
12,910
|
static void vhost_set_memory(MemoryListener *listener,
MemoryRegionSection *section,
bool add)
{
struct vhost_dev *dev = container_of(listener, struct vhost_dev,
memory_listener);
hwaddr start_addr = section->offset_within_address_space;
ram_addr_t size = int128_get64(section->size);
bool log_dirty =
memory_region_get_dirty_log_mask(section->mr) & ~(1 << DIRTY_MEMORY_MIGRATION);
int s = offsetof(struct vhost_memory, regions) +
(dev->mem->nregions + 1) * sizeof dev->mem->regions[0];
void *ram;
dev->mem = g_realloc(dev->mem, s);
if (log_dirty) {
add = false;
}
assert(size);
/* Optimize no-change case. At least cirrus_vga does this a lot at this time. */
ram = memory_region_get_ram_ptr(section->mr) + section->offset_within_region;
if (add) {
if (!vhost_dev_cmp_memory(dev, start_addr, size, (uintptr_t)ram)) {
/* Region exists with same address. Nothing to do. */
return;
}
} else {
if (!vhost_dev_find_reg(dev, start_addr, size)) {
/* Removing region that we don't access. Nothing to do. */
return;
}
}
vhost_dev_unassign_memory(dev, start_addr, size);
if (add) {
/* Add given mapping, merging adjacent regions if any */
vhost_dev_assign_memory(dev, start_addr, size, (uintptr_t)ram);
} else {
/* Remove old mapping for this memory, if any. */
vhost_dev_unassign_memory(dev, start_addr, size);
}
dev->mem_changed_start_addr = MIN(dev->mem_changed_start_addr, start_addr);
dev->mem_changed_end_addr = MAX(dev->mem_changed_end_addr, start_addr + size - 1);
dev->memory_changed = true;
}
| true
|
qemu
|
2ce68e4cf5be9b5176a3c3c372948d6340724d2d
|
static void vhost_set_memory(MemoryListener *listener,
MemoryRegionSection *section,
bool add)
{
struct vhost_dev *dev = container_of(listener, struct vhost_dev,
memory_listener);
hwaddr start_addr = section->offset_within_address_space;
ram_addr_t size = int128_get64(section->size);
bool log_dirty =
memory_region_get_dirty_log_mask(section->mr) & ~(1 << DIRTY_MEMORY_MIGRATION);
int s = offsetof(struct vhost_memory, regions) +
(dev->mem->nregions + 1) * sizeof dev->mem->regions[0];
void *ram;
dev->mem = g_realloc(dev->mem, s);
if (log_dirty) {
add = false;
}
assert(size);
ram = memory_region_get_ram_ptr(section->mr) + section->offset_within_region;
if (add) {
if (!vhost_dev_cmp_memory(dev, start_addr, size, (uintptr_t)ram)) {
return;
}
} else {
if (!vhost_dev_find_reg(dev, start_addr, size)) {
return;
}
}
vhost_dev_unassign_memory(dev, start_addr, size);
if (add) {
vhost_dev_assign_memory(dev, start_addr, size, (uintptr_t)ram);
} else {
vhost_dev_unassign_memory(dev, start_addr, size);
}
dev->mem_changed_start_addr = MIN(dev->mem_changed_start_addr, start_addr);
dev->mem_changed_end_addr = MAX(dev->mem_changed_end_addr, start_addr + size - 1);
dev->memory_changed = true;
}
|
{
"code": [],
"line_no": []
}
|
static void FUNC_0(MemoryListener *VAR_0,
MemoryRegionSection *VAR_1,
bool VAR_2)
{
struct vhost_dev *VAR_3 = container_of(VAR_0, struct vhost_dev,
memory_listener);
hwaddr start_addr = VAR_1->offset_within_address_space;
ram_addr_t size = int128_get64(VAR_1->size);
bool log_dirty =
memory_region_get_dirty_log_mask(VAR_1->mr) & ~(1 << DIRTY_MEMORY_MIGRATION);
int VAR_4 = offsetof(struct vhost_memory, regions) +
(VAR_3->mem->nregions + 1) * sizeof VAR_3->mem->regions[0];
void *VAR_5;
VAR_3->mem = g_realloc(VAR_3->mem, VAR_4);
if (log_dirty) {
VAR_2 = false;
}
assert(size);
VAR_5 = memory_region_get_ram_ptr(VAR_1->mr) + VAR_1->offset_within_region;
if (VAR_2) {
if (!vhost_dev_cmp_memory(VAR_3, start_addr, size, (uintptr_t)VAR_5)) {
return;
}
} else {
if (!vhost_dev_find_reg(VAR_3, start_addr, size)) {
return;
}
}
vhost_dev_unassign_memory(VAR_3, start_addr, size);
if (VAR_2) {
vhost_dev_assign_memory(VAR_3, start_addr, size, (uintptr_t)VAR_5);
} else {
vhost_dev_unassign_memory(VAR_3, start_addr, size);
}
VAR_3->mem_changed_start_addr = MIN(VAR_3->mem_changed_start_addr, start_addr);
VAR_3->mem_changed_end_addr = MAX(VAR_3->mem_changed_end_addr, start_addr + size - 1);
VAR_3->memory_changed = true;
}
|
[
"static void FUNC_0(MemoryListener *VAR_0,\nMemoryRegionSection *VAR_1,\nbool VAR_2)\n{",
"struct vhost_dev *VAR_3 = container_of(VAR_0, struct vhost_dev,\nmemory_listener);",
"hwaddr start_addr = VAR_1->offset_within_address_space;",
"ram_addr_t size = int128_get64(VAR_1->size);",
"bool log_dirty =\nmemory_region_get_dirty_log_mask(VAR_1->mr) & ~(1 << DIRTY_MEMORY_MIGRATION);",
"int VAR_4 = offsetof(struct vhost_memory, regions) +\n(VAR_3->mem->nregions + 1) * sizeof VAR_3->mem->regions[0];",
"void *VAR_5;",
"VAR_3->mem = g_realloc(VAR_3->mem, VAR_4);",
"if (log_dirty) {",
"VAR_2 = false;",
"}",
"assert(size);",
"VAR_5 = memory_region_get_ram_ptr(VAR_1->mr) + VAR_1->offset_within_region;",
"if (VAR_2) {",
"if (!vhost_dev_cmp_memory(VAR_3, start_addr, size, (uintptr_t)VAR_5)) {",
"return;",
"}",
"} else {",
"if (!vhost_dev_find_reg(VAR_3, start_addr, size)) {",
"return;",
"}",
"}",
"vhost_dev_unassign_memory(VAR_3, start_addr, size);",
"if (VAR_2) {",
"vhost_dev_assign_memory(VAR_3, start_addr, size, (uintptr_t)VAR_5);",
"} else {",
"vhost_dev_unassign_memory(VAR_3, start_addr, size);",
"}",
"VAR_3->mem_changed_start_addr = MIN(VAR_3->mem_changed_start_addr, start_addr);",
"VAR_3->mem_changed_end_addr = MAX(VAR_3->mem_changed_end_addr, start_addr + size - 1);",
"VAR_3->memory_changed = true;",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
35
],
[
37
],
[
41
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
96
]
] |
12,911
|
void do_tw (int flags)
{
if (!likely(!((Ts0 < Ts1 && (flags & 0x10)) ||
(Ts0 > Ts1 && (flags & 0x08)) ||
(Ts0 == Ts1 && (flags & 0x04)) ||
(T0 < T1 && (flags & 0x02)) ||
(T0 > T1 && (flags & 0x01)))))
do_raise_exception_err(EXCP_PROGRAM, EXCP_TRAP);
}
| true
|
qemu
|
d9bce9d99f4656ae0b0127f7472db9067b8f84ab
|
void do_tw (int flags)
{
if (!likely(!((Ts0 < Ts1 && (flags & 0x10)) ||
(Ts0 > Ts1 && (flags & 0x08)) ||
(Ts0 == Ts1 && (flags & 0x04)) ||
(T0 < T1 && (flags & 0x02)) ||
(T0 > T1 && (flags & 0x01)))))
do_raise_exception_err(EXCP_PROGRAM, EXCP_TRAP);
}
|
{
"code": [
" if (!likely(!((Ts0 < Ts1 && (flags & 0x10)) ||",
" (Ts0 > Ts1 && (flags & 0x08)) ||",
" (Ts0 == Ts1 && (flags & 0x04)) ||",
" (T0 < T1 && (flags & 0x02)) ||",
" (T0 > T1 && (flags & 0x01)))))"
],
"line_no": [
5,
7,
9,
11,
13
]
}
|
void FUNC_0 (int VAR_0)
{
if (!likely(!((Ts0 < Ts1 && (VAR_0 & 0x10)) ||
(Ts0 > Ts1 && (VAR_0 & 0x08)) ||
(Ts0 == Ts1 && (VAR_0 & 0x04)) ||
(T0 < T1 && (VAR_0 & 0x02)) ||
(T0 > T1 && (VAR_0 & 0x01)))))
do_raise_exception_err(EXCP_PROGRAM, EXCP_TRAP);
}
|
[
"void FUNC_0 (int VAR_0)\n{",
"if (!likely(!((Ts0 < Ts1 && (VAR_0 & 0x10)) ||\n(Ts0 > Ts1 && (VAR_0 & 0x08)) ||\n(Ts0 == Ts1 && (VAR_0 & 0x04)) ||\n(T0 < T1 && (VAR_0 & 0x02)) ||\n(T0 > T1 && (VAR_0 & 0x01)))))\ndo_raise_exception_err(EXCP_PROGRAM, EXCP_TRAP);",
"}"
] |
[
0,
1,
0
] |
[
[
1,
3
],
[
5,
7,
9,
11,
13,
15
],
[
17
]
] |
12,912
|
static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MSS2Context *ctx = avctx->priv_data;
MSS12Context *c = &ctx->c;
AVFrame *frame = data;
GetBitContext gb;
GetByteContext gB;
ArithCoder acoder;
int keyframe, has_wmv9, has_mv, is_rle, is_555, ret;
Rectangle wmv9rects[MAX_WMV9_RECTANGLES], *r;
int used_rects = 0, i, implicit_rect = 0, av_uninit(wmv9_mask);
if ((ret = init_get_bits8(&gb, buf, buf_size)) < 0)
return ret;
if (keyframe = get_bits1(&gb))
skip_bits(&gb, 7);
has_wmv9 = get_bits1(&gb);
has_mv = keyframe ? 0 : get_bits1(&gb);
is_rle = get_bits1(&gb);
is_555 = is_rle && get_bits1(&gb);
if (c->slice_split > 0)
ctx->split_position = c->slice_split;
else if (c->slice_split < 0) {
if (get_bits1(&gb)) {
if (get_bits1(&gb)) {
if (get_bits1(&gb))
ctx->split_position = get_bits(&gb, 16);
else
ctx->split_position = get_bits(&gb, 12);
} else
ctx->split_position = get_bits(&gb, 8) << 4;
} else {
if (keyframe)
ctx->split_position = avctx->height / 2;
}
} else
ctx->split_position = avctx->height;
if (c->slice_split && (ctx->split_position < 1 - is_555 ||
ctx->split_position > avctx->height - 1))
return AVERROR_INVALIDDATA;
align_get_bits(&gb);
buf += get_bits_count(&gb) >> 3;
buf_size -= get_bits_count(&gb) >> 3;
if (buf_size < 1)
return AVERROR_INVALIDDATA;
if (is_555 && (has_wmv9 || has_mv || c->slice_split && ctx->split_position))
return AVERROR_INVALIDDATA;
avctx->pix_fmt = is_555 ? AV_PIX_FMT_RGB555 : AV_PIX_FMT_RGB24;
if (ctx->last_pic->format != avctx->pix_fmt)
av_frame_unref(ctx->last_pic);
if (has_wmv9) {
bytestream2_init(&gB, buf, buf_size + ARITH2_PADDING);
arith2_init(&acoder, &gB);
implicit_rect = !arith2_get_bit(&acoder);
while (arith2_get_bit(&acoder)) {
if (used_rects == MAX_WMV9_RECTANGLES)
return AVERROR_INVALIDDATA;
r = &wmv9rects[used_rects];
if (!used_rects)
r->x = arith2_get_number(&acoder, avctx->width);
else
r->x = arith2_get_number(&acoder, avctx->width -
wmv9rects[used_rects - 1].x) +
wmv9rects[used_rects - 1].x;
r->y = arith2_get_number(&acoder, avctx->height);
r->w = arith2_get_number(&acoder, avctx->width - r->x) + 1;
r->h = arith2_get_number(&acoder, avctx->height - r->y) + 1;
used_rects++;
}
if (implicit_rect && used_rects) {
av_log(avctx, AV_LOG_ERROR, "implicit_rect && used_rects > 0\n");
return AVERROR_INVALIDDATA;
}
if (implicit_rect) {
wmv9rects[0].x = 0;
wmv9rects[0].y = 0;
wmv9rects[0].w = avctx->width;
wmv9rects[0].h = avctx->height;
used_rects = 1;
}
for (i = 0; i < used_rects; i++) {
if (!implicit_rect && arith2_get_bit(&acoder)) {
av_log(avctx, AV_LOG_ERROR, "Unexpected grandchildren\n");
return AVERROR_INVALIDDATA;
}
if (!i) {
wmv9_mask = arith2_get_bit(&acoder) - 1;
if (!wmv9_mask)
wmv9_mask = arith2_get_number(&acoder, 256);
}
wmv9rects[i].coded = arith2_get_number(&acoder, 2);
}
buf += arith2_get_consumed_bytes(&acoder);
buf_size -= arith2_get_consumed_bytes(&acoder);
if (buf_size < 1)
return AVERROR_INVALIDDATA;
}
c->mvX = c->mvY = 0;
if (keyframe && !is_555) {
if ((i = decode_pal_v2(c, buf, buf_size)) < 0)
return AVERROR_INVALIDDATA;
buf += i;
buf_size -= i;
} else if (has_mv) {
buf += 4;
buf_size -= 4;
if (buf_size < 1)
return AVERROR_INVALIDDATA;
c->mvX = AV_RB16(buf - 4) - avctx->width;
c->mvY = AV_RB16(buf - 2) - avctx->height;
}
if (c->mvX < 0 || c->mvY < 0) {
FFSWAP(uint8_t *, c->pal_pic, c->last_pal_pic);
if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
return ret;
if (ctx->last_pic->data[0]) {
av_assert0(frame->linesize[0] == ctx->last_pic->linesize[0]);
c->last_rgb_pic = ctx->last_pic->data[0] +
ctx->last_pic->linesize[0] * (avctx->height - 1);
} else {
av_log(avctx, AV_LOG_ERROR, "Missing keyframe\n");
return AVERROR_INVALIDDATA;
}
} else {
if ((ret = ff_reget_buffer(avctx, ctx->last_pic)) < 0)
return ret;
if ((ret = av_frame_ref(frame, ctx->last_pic)) < 0)
return ret;
c->last_rgb_pic = NULL;
}
c->rgb_pic = frame->data[0] +
frame->linesize[0] * (avctx->height - 1);
c->rgb_stride = -frame->linesize[0];
frame->key_frame = keyframe;
frame->pict_type = keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
if (is_555) {
bytestream2_init(&gB, buf, buf_size);
if (decode_555(&gB, (uint16_t *)c->rgb_pic, c->rgb_stride >> 1,
keyframe, avctx->width, avctx->height))
return AVERROR_INVALIDDATA;
buf_size -= bytestream2_tell(&gB);
} else {
if (keyframe) {
c->corrupted = 0;
ff_mss12_slicecontext_reset(&ctx->sc[0]);
if (c->slice_split)
ff_mss12_slicecontext_reset(&ctx->sc[1]);
}
if (is_rle) {
if ((ret = init_get_bits8(&gb, buf, buf_size)) < 0)
return ret;
if (ret = decode_rle(&gb, c->pal_pic, c->pal_stride,
c->rgb_pic, c->rgb_stride, c->pal, keyframe,
ctx->split_position, 0,
avctx->width, avctx->height))
return ret;
align_get_bits(&gb);
if (c->slice_split)
if (ret = decode_rle(&gb, c->pal_pic, c->pal_stride,
c->rgb_pic, c->rgb_stride, c->pal, keyframe,
ctx->split_position, 1,
avctx->width, avctx->height))
return ret;
align_get_bits(&gb);
buf += get_bits_count(&gb) >> 3;
buf_size -= get_bits_count(&gb) >> 3;
} else if (!implicit_rect || wmv9_mask != -1) {
if (c->corrupted)
return AVERROR_INVALIDDATA;
bytestream2_init(&gB, buf, buf_size + ARITH2_PADDING);
arith2_init(&acoder, &gB);
c->keyframe = keyframe;
if (c->corrupted = ff_mss12_decode_rect(&ctx->sc[0], &acoder, 0, 0,
avctx->width,
ctx->split_position))
return AVERROR_INVALIDDATA;
buf += arith2_get_consumed_bytes(&acoder);
buf_size -= arith2_get_consumed_bytes(&acoder);
if (c->slice_split) {
if (buf_size < 1)
return AVERROR_INVALIDDATA;
bytestream2_init(&gB, buf, buf_size + ARITH2_PADDING);
arith2_init(&acoder, &gB);
if (c->corrupted = ff_mss12_decode_rect(&ctx->sc[1], &acoder, 0,
ctx->split_position,
avctx->width,
avctx->height - ctx->split_position))
return AVERROR_INVALIDDATA;
buf += arith2_get_consumed_bytes(&acoder);
buf_size -= arith2_get_consumed_bytes(&acoder);
}
} else
memset(c->pal_pic, 0, c->pal_stride * avctx->height);
}
if (has_wmv9) {
for (i = 0; i < used_rects; i++) {
int x = wmv9rects[i].x;
int y = wmv9rects[i].y;
int w = wmv9rects[i].w;
int h = wmv9rects[i].h;
if (wmv9rects[i].coded) {
int WMV9codedFrameSize;
if (buf_size < 4 || !(WMV9codedFrameSize = AV_RL24(buf)))
return AVERROR_INVALIDDATA;
if (ret = decode_wmv9(avctx, buf + 3, buf_size - 3,
x, y, w, h, wmv9_mask))
return ret;
buf += WMV9codedFrameSize + 3;
buf_size -= WMV9codedFrameSize + 3;
} else {
uint8_t *dst = c->rgb_pic + y * c->rgb_stride + x * 3;
if (wmv9_mask != -1) {
ctx->dsp.mss2_gray_fill_masked(dst, c->rgb_stride,
wmv9_mask,
c->pal_pic + y * c->pal_stride + x,
c->pal_stride,
w, h);
} else {
do {
memset(dst, 0x80, w * 3);
dst += c->rgb_stride;
} while (--h);
}
}
}
}
if (buf_size)
av_log(avctx, AV_LOG_WARNING, "buffer not fully consumed\n");
if (c->mvX < 0 || c->mvY < 0) {
av_frame_unref(ctx->last_pic);
ret = av_frame_ref(ctx->last_pic, frame);
if (ret < 0)
return ret;
}
*got_frame = 1;
return avpkt->size;
}
| false
|
FFmpeg
|
149268b47c4b0f9c584771e41d266d10cf7e3bf0
|
static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MSS2Context *ctx = avctx->priv_data;
MSS12Context *c = &ctx->c;
AVFrame *frame = data;
GetBitContext gb;
GetByteContext gB;
ArithCoder acoder;
int keyframe, has_wmv9, has_mv, is_rle, is_555, ret;
Rectangle wmv9rects[MAX_WMV9_RECTANGLES], *r;
int used_rects = 0, i, implicit_rect = 0, av_uninit(wmv9_mask);
if ((ret = init_get_bits8(&gb, buf, buf_size)) < 0)
return ret;
if (keyframe = get_bits1(&gb))
skip_bits(&gb, 7);
has_wmv9 = get_bits1(&gb);
has_mv = keyframe ? 0 : get_bits1(&gb);
is_rle = get_bits1(&gb);
is_555 = is_rle && get_bits1(&gb);
if (c->slice_split > 0)
ctx->split_position = c->slice_split;
else if (c->slice_split < 0) {
if (get_bits1(&gb)) {
if (get_bits1(&gb)) {
if (get_bits1(&gb))
ctx->split_position = get_bits(&gb, 16);
else
ctx->split_position = get_bits(&gb, 12);
} else
ctx->split_position = get_bits(&gb, 8) << 4;
} else {
if (keyframe)
ctx->split_position = avctx->height / 2;
}
} else
ctx->split_position = avctx->height;
if (c->slice_split && (ctx->split_position < 1 - is_555 ||
ctx->split_position > avctx->height - 1))
return AVERROR_INVALIDDATA;
align_get_bits(&gb);
buf += get_bits_count(&gb) >> 3;
buf_size -= get_bits_count(&gb) >> 3;
if (buf_size < 1)
return AVERROR_INVALIDDATA;
if (is_555 && (has_wmv9 || has_mv || c->slice_split && ctx->split_position))
return AVERROR_INVALIDDATA;
avctx->pix_fmt = is_555 ? AV_PIX_FMT_RGB555 : AV_PIX_FMT_RGB24;
if (ctx->last_pic->format != avctx->pix_fmt)
av_frame_unref(ctx->last_pic);
if (has_wmv9) {
bytestream2_init(&gB, buf, buf_size + ARITH2_PADDING);
arith2_init(&acoder, &gB);
implicit_rect = !arith2_get_bit(&acoder);
while (arith2_get_bit(&acoder)) {
if (used_rects == MAX_WMV9_RECTANGLES)
return AVERROR_INVALIDDATA;
r = &wmv9rects[used_rects];
if (!used_rects)
r->x = arith2_get_number(&acoder, avctx->width);
else
r->x = arith2_get_number(&acoder, avctx->width -
wmv9rects[used_rects - 1].x) +
wmv9rects[used_rects - 1].x;
r->y = arith2_get_number(&acoder, avctx->height);
r->w = arith2_get_number(&acoder, avctx->width - r->x) + 1;
r->h = arith2_get_number(&acoder, avctx->height - r->y) + 1;
used_rects++;
}
if (implicit_rect && used_rects) {
av_log(avctx, AV_LOG_ERROR, "implicit_rect && used_rects > 0\n");
return AVERROR_INVALIDDATA;
}
if (implicit_rect) {
wmv9rects[0].x = 0;
wmv9rects[0].y = 0;
wmv9rects[0].w = avctx->width;
wmv9rects[0].h = avctx->height;
used_rects = 1;
}
for (i = 0; i < used_rects; i++) {
if (!implicit_rect && arith2_get_bit(&acoder)) {
av_log(avctx, AV_LOG_ERROR, "Unexpected grandchildren\n");
return AVERROR_INVALIDDATA;
}
if (!i) {
wmv9_mask = arith2_get_bit(&acoder) - 1;
if (!wmv9_mask)
wmv9_mask = arith2_get_number(&acoder, 256);
}
wmv9rects[i].coded = arith2_get_number(&acoder, 2);
}
buf += arith2_get_consumed_bytes(&acoder);
buf_size -= arith2_get_consumed_bytes(&acoder);
if (buf_size < 1)
return AVERROR_INVALIDDATA;
}
c->mvX = c->mvY = 0;
if (keyframe && !is_555) {
if ((i = decode_pal_v2(c, buf, buf_size)) < 0)
return AVERROR_INVALIDDATA;
buf += i;
buf_size -= i;
} else if (has_mv) {
buf += 4;
buf_size -= 4;
if (buf_size < 1)
return AVERROR_INVALIDDATA;
c->mvX = AV_RB16(buf - 4) - avctx->width;
c->mvY = AV_RB16(buf - 2) - avctx->height;
}
if (c->mvX < 0 || c->mvY < 0) {
FFSWAP(uint8_t *, c->pal_pic, c->last_pal_pic);
if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
return ret;
if (ctx->last_pic->data[0]) {
av_assert0(frame->linesize[0] == ctx->last_pic->linesize[0]);
c->last_rgb_pic = ctx->last_pic->data[0] +
ctx->last_pic->linesize[0] * (avctx->height - 1);
} else {
av_log(avctx, AV_LOG_ERROR, "Missing keyframe\n");
return AVERROR_INVALIDDATA;
}
} else {
if ((ret = ff_reget_buffer(avctx, ctx->last_pic)) < 0)
return ret;
if ((ret = av_frame_ref(frame, ctx->last_pic)) < 0)
return ret;
c->last_rgb_pic = NULL;
}
c->rgb_pic = frame->data[0] +
frame->linesize[0] * (avctx->height - 1);
c->rgb_stride = -frame->linesize[0];
frame->key_frame = keyframe;
frame->pict_type = keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
if (is_555) {
bytestream2_init(&gB, buf, buf_size);
if (decode_555(&gB, (uint16_t *)c->rgb_pic, c->rgb_stride >> 1,
keyframe, avctx->width, avctx->height))
return AVERROR_INVALIDDATA;
buf_size -= bytestream2_tell(&gB);
} else {
if (keyframe) {
c->corrupted = 0;
ff_mss12_slicecontext_reset(&ctx->sc[0]);
if (c->slice_split)
ff_mss12_slicecontext_reset(&ctx->sc[1]);
}
if (is_rle) {
if ((ret = init_get_bits8(&gb, buf, buf_size)) < 0)
return ret;
if (ret = decode_rle(&gb, c->pal_pic, c->pal_stride,
c->rgb_pic, c->rgb_stride, c->pal, keyframe,
ctx->split_position, 0,
avctx->width, avctx->height))
return ret;
align_get_bits(&gb);
if (c->slice_split)
if (ret = decode_rle(&gb, c->pal_pic, c->pal_stride,
c->rgb_pic, c->rgb_stride, c->pal, keyframe,
ctx->split_position, 1,
avctx->width, avctx->height))
return ret;
align_get_bits(&gb);
buf += get_bits_count(&gb) >> 3;
buf_size -= get_bits_count(&gb) >> 3;
} else if (!implicit_rect || wmv9_mask != -1) {
if (c->corrupted)
return AVERROR_INVALIDDATA;
bytestream2_init(&gB, buf, buf_size + ARITH2_PADDING);
arith2_init(&acoder, &gB);
c->keyframe = keyframe;
if (c->corrupted = ff_mss12_decode_rect(&ctx->sc[0], &acoder, 0, 0,
avctx->width,
ctx->split_position))
return AVERROR_INVALIDDATA;
buf += arith2_get_consumed_bytes(&acoder);
buf_size -= arith2_get_consumed_bytes(&acoder);
if (c->slice_split) {
if (buf_size < 1)
return AVERROR_INVALIDDATA;
bytestream2_init(&gB, buf, buf_size + ARITH2_PADDING);
arith2_init(&acoder, &gB);
if (c->corrupted = ff_mss12_decode_rect(&ctx->sc[1], &acoder, 0,
ctx->split_position,
avctx->width,
avctx->height - ctx->split_position))
return AVERROR_INVALIDDATA;
buf += arith2_get_consumed_bytes(&acoder);
buf_size -= arith2_get_consumed_bytes(&acoder);
}
} else
memset(c->pal_pic, 0, c->pal_stride * avctx->height);
}
if (has_wmv9) {
for (i = 0; i < used_rects; i++) {
int x = wmv9rects[i].x;
int y = wmv9rects[i].y;
int w = wmv9rects[i].w;
int h = wmv9rects[i].h;
if (wmv9rects[i].coded) {
int WMV9codedFrameSize;
if (buf_size < 4 || !(WMV9codedFrameSize = AV_RL24(buf)))
return AVERROR_INVALIDDATA;
if (ret = decode_wmv9(avctx, buf + 3, buf_size - 3,
x, y, w, h, wmv9_mask))
return ret;
buf += WMV9codedFrameSize + 3;
buf_size -= WMV9codedFrameSize + 3;
} else {
uint8_t *dst = c->rgb_pic + y * c->rgb_stride + x * 3;
if (wmv9_mask != -1) {
ctx->dsp.mss2_gray_fill_masked(dst, c->rgb_stride,
wmv9_mask,
c->pal_pic + y * c->pal_stride + x,
c->pal_stride,
w, h);
} else {
do {
memset(dst, 0x80, w * 3);
dst += c->rgb_stride;
} while (--h);
}
}
}
}
if (buf_size)
av_log(avctx, AV_LOG_WARNING, "buffer not fully consumed\n");
if (c->mvX < 0 || c->mvY < 0) {
av_frame_unref(ctx->last_pic);
ret = av_frame_ref(ctx->last_pic, frame);
if (ret < 0)
return ret;
}
*got_frame = 1;
return avpkt->size;
}
|
{
"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;
MSS2Context *ctx = VAR_0->priv_data;
MSS12Context *c = &ctx->c;
AVFrame *frame = VAR_1;
GetBitContext gb;
GetByteContext gB;
ArithCoder acoder;
int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;
Rectangle wmv9rects[MAX_WMV9_RECTANGLES], *r;
int VAR_12 = 0, VAR_13, VAR_14 = 0, FUNC_1(wmv9_mask);
if ((VAR_11 = init_get_bits8(&gb, VAR_4, VAR_5)) < 0)
return VAR_11;
if (VAR_6 = get_bits1(&gb))
skip_bits(&gb, 7);
VAR_7 = get_bits1(&gb);
VAR_8 = VAR_6 ? 0 : get_bits1(&gb);
VAR_9 = get_bits1(&gb);
VAR_10 = VAR_9 && get_bits1(&gb);
if (c->slice_split > 0)
ctx->split_position = c->slice_split;
else if (c->slice_split < 0) {
if (get_bits1(&gb)) {
if (get_bits1(&gb)) {
if (get_bits1(&gb))
ctx->split_position = get_bits(&gb, 16);
else
ctx->split_position = get_bits(&gb, 12);
} else
ctx->split_position = get_bits(&gb, 8) << 4;
} else {
if (VAR_6)
ctx->split_position = VAR_0->height / 2;
}
} else
ctx->split_position = VAR_0->height;
if (c->slice_split && (ctx->split_position < 1 - VAR_10 ||
ctx->split_position > VAR_0->height - 1))
return AVERROR_INVALIDDATA;
align_get_bits(&gb);
VAR_4 += get_bits_count(&gb) >> 3;
VAR_5 -= get_bits_count(&gb) >> 3;
if (VAR_5 < 1)
return AVERROR_INVALIDDATA;
if (VAR_10 && (VAR_7 || VAR_8 || c->slice_split && ctx->split_position))
return AVERROR_INVALIDDATA;
VAR_0->pix_fmt = VAR_10 ? AV_PIX_FMT_RGB555 : AV_PIX_FMT_RGB24;
if (ctx->last_pic->format != VAR_0->pix_fmt)
av_frame_unref(ctx->last_pic);
if (VAR_7) {
bytestream2_init(&gB, VAR_4, VAR_5 + ARITH2_PADDING);
arith2_init(&acoder, &gB);
VAR_14 = !arith2_get_bit(&acoder);
while (arith2_get_bit(&acoder)) {
if (VAR_12 == MAX_WMV9_RECTANGLES)
return AVERROR_INVALIDDATA;
r = &wmv9rects[VAR_12];
if (!VAR_12)
r->VAR_15 = arith2_get_number(&acoder, VAR_0->width);
else
r->VAR_15 = arith2_get_number(&acoder, VAR_0->width -
wmv9rects[VAR_12 - 1].VAR_15) +
wmv9rects[VAR_12 - 1].VAR_15;
r->VAR_16 = arith2_get_number(&acoder, VAR_0->height);
r->VAR_17 = arith2_get_number(&acoder, VAR_0->width - r->VAR_15) + 1;
r->VAR_18 = arith2_get_number(&acoder, VAR_0->height - r->VAR_16) + 1;
VAR_12++;
}
if (VAR_14 && VAR_12) {
av_log(VAR_0, AV_LOG_ERROR, "VAR_14 && VAR_12 > 0\n");
return AVERROR_INVALIDDATA;
}
if (VAR_14) {
wmv9rects[0].VAR_15 = 0;
wmv9rects[0].VAR_16 = 0;
wmv9rects[0].VAR_17 = VAR_0->width;
wmv9rects[0].VAR_18 = VAR_0->height;
VAR_12 = 1;
}
for (VAR_13 = 0; VAR_13 < VAR_12; VAR_13++) {
if (!VAR_14 && arith2_get_bit(&acoder)) {
av_log(VAR_0, AV_LOG_ERROR, "Unexpected grandchildren\n");
return AVERROR_INVALIDDATA;
}
if (!VAR_13) {
wmv9_mask = arith2_get_bit(&acoder) - 1;
if (!wmv9_mask)
wmv9_mask = arith2_get_number(&acoder, 256);
}
wmv9rects[VAR_13].coded = arith2_get_number(&acoder, 2);
}
VAR_4 += arith2_get_consumed_bytes(&acoder);
VAR_5 -= arith2_get_consumed_bytes(&acoder);
if (VAR_5 < 1)
return AVERROR_INVALIDDATA;
}
c->mvX = c->mvY = 0;
if (VAR_6 && !VAR_10) {
if ((VAR_13 = decode_pal_v2(c, VAR_4, VAR_5)) < 0)
return AVERROR_INVALIDDATA;
VAR_4 += VAR_13;
VAR_5 -= VAR_13;
} else if (VAR_8) {
VAR_4 += 4;
VAR_5 -= 4;
if (VAR_5 < 1)
return AVERROR_INVALIDDATA;
c->mvX = AV_RB16(VAR_4 - 4) - VAR_0->width;
c->mvY = AV_RB16(VAR_4 - 2) - VAR_0->height;
}
if (c->mvX < 0 || c->mvY < 0) {
FFSWAP(uint8_t *, c->pal_pic, c->last_pal_pic);
if ((VAR_11 = ff_get_buffer(VAR_0, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
return VAR_11;
if (ctx->last_pic->VAR_1[0]) {
av_assert0(frame->linesize[0] == ctx->last_pic->linesize[0]);
c->last_rgb_pic = ctx->last_pic->VAR_1[0] +
ctx->last_pic->linesize[0] * (VAR_0->height - 1);
} else {
av_log(VAR_0, AV_LOG_ERROR, "Missing VAR_6\n");
return AVERROR_INVALIDDATA;
}
} else {
if ((VAR_11 = ff_reget_buffer(VAR_0, ctx->last_pic)) < 0)
return VAR_11;
if ((VAR_11 = av_frame_ref(frame, ctx->last_pic)) < 0)
return VAR_11;
c->last_rgb_pic = NULL;
}
c->rgb_pic = frame->VAR_1[0] +
frame->linesize[0] * (VAR_0->height - 1);
c->rgb_stride = -frame->linesize[0];
frame->key_frame = VAR_6;
frame->pict_type = VAR_6 ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
if (VAR_10) {
bytestream2_init(&gB, VAR_4, VAR_5);
if (decode_555(&gB, (uint16_t *)c->rgb_pic, c->rgb_stride >> 1,
VAR_6, VAR_0->width, VAR_0->height))
return AVERROR_INVALIDDATA;
VAR_5 -= bytestream2_tell(&gB);
} else {
if (VAR_6) {
c->corrupted = 0;
ff_mss12_slicecontext_reset(&ctx->sc[0]);
if (c->slice_split)
ff_mss12_slicecontext_reset(&ctx->sc[1]);
}
if (VAR_9) {
if ((VAR_11 = init_get_bits8(&gb, VAR_4, VAR_5)) < 0)
return VAR_11;
if (VAR_11 = decode_rle(&gb, c->pal_pic, c->pal_stride,
c->rgb_pic, c->rgb_stride, c->pal, VAR_6,
ctx->split_position, 0,
VAR_0->width, VAR_0->height))
return VAR_11;
align_get_bits(&gb);
if (c->slice_split)
if (VAR_11 = decode_rle(&gb, c->pal_pic, c->pal_stride,
c->rgb_pic, c->rgb_stride, c->pal, VAR_6,
ctx->split_position, 1,
VAR_0->width, VAR_0->height))
return VAR_11;
align_get_bits(&gb);
VAR_4 += get_bits_count(&gb) >> 3;
VAR_5 -= get_bits_count(&gb) >> 3;
} else if (!VAR_14 || wmv9_mask != -1) {
if (c->corrupted)
return AVERROR_INVALIDDATA;
bytestream2_init(&gB, VAR_4, VAR_5 + ARITH2_PADDING);
arith2_init(&acoder, &gB);
c->VAR_6 = VAR_6;
if (c->corrupted = ff_mss12_decode_rect(&ctx->sc[0], &acoder, 0, 0,
VAR_0->width,
ctx->split_position))
return AVERROR_INVALIDDATA;
VAR_4 += arith2_get_consumed_bytes(&acoder);
VAR_5 -= arith2_get_consumed_bytes(&acoder);
if (c->slice_split) {
if (VAR_5 < 1)
return AVERROR_INVALIDDATA;
bytestream2_init(&gB, VAR_4, VAR_5 + ARITH2_PADDING);
arith2_init(&acoder, &gB);
if (c->corrupted = ff_mss12_decode_rect(&ctx->sc[1], &acoder, 0,
ctx->split_position,
VAR_0->width,
VAR_0->height - ctx->split_position))
return AVERROR_INVALIDDATA;
VAR_4 += arith2_get_consumed_bytes(&acoder);
VAR_5 -= arith2_get_consumed_bytes(&acoder);
}
} else
memset(c->pal_pic, 0, c->pal_stride * VAR_0->height);
}
if (VAR_7) {
for (VAR_13 = 0; VAR_13 < VAR_12; VAR_13++) {
int VAR_15 = wmv9rects[VAR_13].VAR_15;
int VAR_16 = wmv9rects[VAR_13].VAR_16;
int VAR_17 = wmv9rects[VAR_13].VAR_17;
int VAR_18 = wmv9rects[VAR_13].VAR_18;
if (wmv9rects[VAR_13].coded) {
int VAR_19;
if (VAR_5 < 4 || !(VAR_19 = AV_RL24(VAR_4)))
return AVERROR_INVALIDDATA;
if (VAR_11 = decode_wmv9(VAR_0, VAR_4 + 3, VAR_5 - 3,
VAR_15, VAR_16, VAR_17, VAR_18, wmv9_mask))
return VAR_11;
VAR_4 += VAR_19 + 3;
VAR_5 -= VAR_19 + 3;
} else {
uint8_t *dst = c->rgb_pic + VAR_16 * c->rgb_stride + VAR_15 * 3;
if (wmv9_mask != -1) {
ctx->dsp.mss2_gray_fill_masked(dst, c->rgb_stride,
wmv9_mask,
c->pal_pic + VAR_16 * c->pal_stride + VAR_15,
c->pal_stride,
VAR_17, VAR_18);
} else {
do {
memset(dst, 0x80, VAR_17 * 3);
dst += c->rgb_stride;
} while (--VAR_18);
}
}
}
}
if (VAR_5)
av_log(VAR_0, AV_LOG_WARNING, "buffer not fully consumed\n");
if (c->mvX < 0 || c->mvY < 0) {
av_frame_unref(ctx->last_pic);
VAR_11 = av_frame_ref(ctx->last_pic, frame);
if (VAR_11 < 0)
return VAR_11;
}
*VAR_2 = 1;
return VAR_3->size;
}
|
[
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"MSS2Context *ctx = VAR_0->priv_data;",
"MSS12Context *c = &ctx->c;",
"AVFrame *frame = VAR_1;",
"GetBitContext gb;",
"GetByteContext gB;",
"ArithCoder acoder;",
"int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;",
"Rectangle wmv9rects[MAX_WMV9_RECTANGLES], *r;",
"int VAR_12 = 0, VAR_13, VAR_14 = 0, FUNC_1(wmv9_mask);",
"if ((VAR_11 = init_get_bits8(&gb, VAR_4, VAR_5)) < 0)\nreturn VAR_11;",
"if (VAR_6 = get_bits1(&gb))\nskip_bits(&gb, 7);",
"VAR_7 = get_bits1(&gb);",
"VAR_8 = VAR_6 ? 0 : get_bits1(&gb);",
"VAR_9 = get_bits1(&gb);",
"VAR_10 = VAR_9 && get_bits1(&gb);",
"if (c->slice_split > 0)\nctx->split_position = c->slice_split;",
"else if (c->slice_split < 0) {",
"if (get_bits1(&gb)) {",
"if (get_bits1(&gb)) {",
"if (get_bits1(&gb))\nctx->split_position = get_bits(&gb, 16);",
"else\nctx->split_position = get_bits(&gb, 12);",
"} else",
"ctx->split_position = get_bits(&gb, 8) << 4;",
"} else {",
"if (VAR_6)\nctx->split_position = VAR_0->height / 2;",
"}",
"} else",
"ctx->split_position = VAR_0->height;",
"if (c->slice_split && (ctx->split_position < 1 - VAR_10 ||\nctx->split_position > VAR_0->height - 1))\nreturn AVERROR_INVALIDDATA;",
"align_get_bits(&gb);",
"VAR_4 += get_bits_count(&gb) >> 3;",
"VAR_5 -= get_bits_count(&gb) >> 3;",
"if (VAR_5 < 1)\nreturn AVERROR_INVALIDDATA;",
"if (VAR_10 && (VAR_7 || VAR_8 || c->slice_split && ctx->split_position))\nreturn AVERROR_INVALIDDATA;",
"VAR_0->pix_fmt = VAR_10 ? AV_PIX_FMT_RGB555 : AV_PIX_FMT_RGB24;",
"if (ctx->last_pic->format != VAR_0->pix_fmt)\nav_frame_unref(ctx->last_pic);",
"if (VAR_7) {",
"bytestream2_init(&gB, VAR_4, VAR_5 + ARITH2_PADDING);",
"arith2_init(&acoder, &gB);",
"VAR_14 = !arith2_get_bit(&acoder);",
"while (arith2_get_bit(&acoder)) {",
"if (VAR_12 == MAX_WMV9_RECTANGLES)\nreturn AVERROR_INVALIDDATA;",
"r = &wmv9rects[VAR_12];",
"if (!VAR_12)\nr->VAR_15 = arith2_get_number(&acoder, VAR_0->width);",
"else\nr->VAR_15 = arith2_get_number(&acoder, VAR_0->width -\nwmv9rects[VAR_12 - 1].VAR_15) +\nwmv9rects[VAR_12 - 1].VAR_15;",
"r->VAR_16 = arith2_get_number(&acoder, VAR_0->height);",
"r->VAR_17 = arith2_get_number(&acoder, VAR_0->width - r->VAR_15) + 1;",
"r->VAR_18 = arith2_get_number(&acoder, VAR_0->height - r->VAR_16) + 1;",
"VAR_12++;",
"}",
"if (VAR_14 && VAR_12) {",
"av_log(VAR_0, AV_LOG_ERROR, \"VAR_14 && VAR_12 > 0\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_14) {",
"wmv9rects[0].VAR_15 = 0;",
"wmv9rects[0].VAR_16 = 0;",
"wmv9rects[0].VAR_17 = VAR_0->width;",
"wmv9rects[0].VAR_18 = VAR_0->height;",
"VAR_12 = 1;",
"}",
"for (VAR_13 = 0; VAR_13 < VAR_12; VAR_13++) {",
"if (!VAR_14 && arith2_get_bit(&acoder)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Unexpected grandchildren\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (!VAR_13) {",
"wmv9_mask = arith2_get_bit(&acoder) - 1;",
"if (!wmv9_mask)\nwmv9_mask = arith2_get_number(&acoder, 256);",
"}",
"wmv9rects[VAR_13].coded = arith2_get_number(&acoder, 2);",
"}",
"VAR_4 += arith2_get_consumed_bytes(&acoder);",
"VAR_5 -= arith2_get_consumed_bytes(&acoder);",
"if (VAR_5 < 1)\nreturn AVERROR_INVALIDDATA;",
"}",
"c->mvX = c->mvY = 0;",
"if (VAR_6 && !VAR_10) {",
"if ((VAR_13 = decode_pal_v2(c, VAR_4, VAR_5)) < 0)\nreturn AVERROR_INVALIDDATA;",
"VAR_4 += VAR_13;",
"VAR_5 -= VAR_13;",
"} else if (VAR_8) {",
"VAR_4 += 4;",
"VAR_5 -= 4;",
"if (VAR_5 < 1)\nreturn AVERROR_INVALIDDATA;",
"c->mvX = AV_RB16(VAR_4 - 4) - VAR_0->width;",
"c->mvY = AV_RB16(VAR_4 - 2) - VAR_0->height;",
"}",
"if (c->mvX < 0 || c->mvY < 0) {",
"FFSWAP(uint8_t *, c->pal_pic, c->last_pal_pic);",
"if ((VAR_11 = ff_get_buffer(VAR_0, frame, AV_GET_BUFFER_FLAG_REF)) < 0)\nreturn VAR_11;",
"if (ctx->last_pic->VAR_1[0]) {",
"av_assert0(frame->linesize[0] == ctx->last_pic->linesize[0]);",
"c->last_rgb_pic = ctx->last_pic->VAR_1[0] +\nctx->last_pic->linesize[0] * (VAR_0->height - 1);",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR, \"Missing VAR_6\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"} else {",
"if ((VAR_11 = ff_reget_buffer(VAR_0, ctx->last_pic)) < 0)\nreturn VAR_11;",
"if ((VAR_11 = av_frame_ref(frame, ctx->last_pic)) < 0)\nreturn VAR_11;",
"c->last_rgb_pic = NULL;",
"}",
"c->rgb_pic = frame->VAR_1[0] +\nframe->linesize[0] * (VAR_0->height - 1);",
"c->rgb_stride = -frame->linesize[0];",
"frame->key_frame = VAR_6;",
"frame->pict_type = VAR_6 ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;",
"if (VAR_10) {",
"bytestream2_init(&gB, VAR_4, VAR_5);",
"if (decode_555(&gB, (uint16_t *)c->rgb_pic, c->rgb_stride >> 1,\nVAR_6, VAR_0->width, VAR_0->height))\nreturn AVERROR_INVALIDDATA;",
"VAR_5 -= bytestream2_tell(&gB);",
"} else {",
"if (VAR_6) {",
"c->corrupted = 0;",
"ff_mss12_slicecontext_reset(&ctx->sc[0]);",
"if (c->slice_split)\nff_mss12_slicecontext_reset(&ctx->sc[1]);",
"}",
"if (VAR_9) {",
"if ((VAR_11 = init_get_bits8(&gb, VAR_4, VAR_5)) < 0)\nreturn VAR_11;",
"if (VAR_11 = decode_rle(&gb, c->pal_pic, c->pal_stride,\nc->rgb_pic, c->rgb_stride, c->pal, VAR_6,\nctx->split_position, 0,\nVAR_0->width, VAR_0->height))\nreturn VAR_11;",
"align_get_bits(&gb);",
"if (c->slice_split)\nif (VAR_11 = decode_rle(&gb, c->pal_pic, c->pal_stride,\nc->rgb_pic, c->rgb_stride, c->pal, VAR_6,\nctx->split_position, 1,\nVAR_0->width, VAR_0->height))\nreturn VAR_11;",
"align_get_bits(&gb);",
"VAR_4 += get_bits_count(&gb) >> 3;",
"VAR_5 -= get_bits_count(&gb) >> 3;",
"} else if (!VAR_14 || wmv9_mask != -1) {",
"if (c->corrupted)\nreturn AVERROR_INVALIDDATA;",
"bytestream2_init(&gB, VAR_4, VAR_5 + ARITH2_PADDING);",
"arith2_init(&acoder, &gB);",
"c->VAR_6 = VAR_6;",
"if (c->corrupted = ff_mss12_decode_rect(&ctx->sc[0], &acoder, 0, 0,\nVAR_0->width,\nctx->split_position))\nreturn AVERROR_INVALIDDATA;",
"VAR_4 += arith2_get_consumed_bytes(&acoder);",
"VAR_5 -= arith2_get_consumed_bytes(&acoder);",
"if (c->slice_split) {",
"if (VAR_5 < 1)\nreturn AVERROR_INVALIDDATA;",
"bytestream2_init(&gB, VAR_4, VAR_5 + ARITH2_PADDING);",
"arith2_init(&acoder, &gB);",
"if (c->corrupted = ff_mss12_decode_rect(&ctx->sc[1], &acoder, 0,\nctx->split_position,\nVAR_0->width,\nVAR_0->height - ctx->split_position))\nreturn AVERROR_INVALIDDATA;",
"VAR_4 += arith2_get_consumed_bytes(&acoder);",
"VAR_5 -= arith2_get_consumed_bytes(&acoder);",
"}",
"} else",
"memset(c->pal_pic, 0, c->pal_stride * VAR_0->height);",
"}",
"if (VAR_7) {",
"for (VAR_13 = 0; VAR_13 < VAR_12; VAR_13++) {",
"int VAR_15 = wmv9rects[VAR_13].VAR_15;",
"int VAR_16 = wmv9rects[VAR_13].VAR_16;",
"int VAR_17 = wmv9rects[VAR_13].VAR_17;",
"int VAR_18 = wmv9rects[VAR_13].VAR_18;",
"if (wmv9rects[VAR_13].coded) {",
"int VAR_19;",
"if (VAR_5 < 4 || !(VAR_19 = AV_RL24(VAR_4)))\nreturn AVERROR_INVALIDDATA;",
"if (VAR_11 = decode_wmv9(VAR_0, VAR_4 + 3, VAR_5 - 3,\nVAR_15, VAR_16, VAR_17, VAR_18, wmv9_mask))\nreturn VAR_11;",
"VAR_4 += VAR_19 + 3;",
"VAR_5 -= VAR_19 + 3;",
"} else {",
"uint8_t *dst = c->rgb_pic + VAR_16 * c->rgb_stride + VAR_15 * 3;",
"if (wmv9_mask != -1) {",
"ctx->dsp.mss2_gray_fill_masked(dst, c->rgb_stride,\nwmv9_mask,\nc->pal_pic + VAR_16 * c->pal_stride + VAR_15,\nc->pal_stride,\nVAR_17, VAR_18);",
"} else {",
"do {",
"memset(dst, 0x80, VAR_17 * 3);",
"dst += c->rgb_stride;",
"} while (--VAR_18);",
"}",
"}",
"}",
"}",
"if (VAR_5)\nav_log(VAR_0, AV_LOG_WARNING, \"buffer not fully consumed\\n\");",
"if (c->mvX < 0 || c->mvY < 0) {",
"av_frame_unref(ctx->last_pic);",
"VAR_11 = av_frame_ref(ctx->last_pic, frame);",
"if (VAR_11 < 0)\nreturn VAR_11;",
"}",
"*VAR_2 = 1;",
"return VAR_3->size;",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
35,
37
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63,
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
85
],
[
89,
91,
93
],
[
97
],
[
99
],
[
101
],
[
105,
107
],
[
111,
113
],
[
117
],
[
119,
121
],
[
125
],
[
127
],
[
129
],
[
133
],
[
137
],
[
139,
141
],
[
143
],
[
145,
147
],
[
149,
151,
153,
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
171
],
[
173
],
[
175
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209,
211
],
[
213
],
[
215
],
[
217
],
[
221
],
[
223
],
[
225,
227
],
[
229
],
[
233
],
[
235
],
[
237,
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251,
253
],
[
255
],
[
257
],
[
259
],
[
263
],
[
265
],
[
269,
271
],
[
275
],
[
277
],
[
279,
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293,
295
],
[
297,
299
],
[
303
],
[
305
],
[
307,
309
],
[
311
],
[
315
],
[
317
],
[
321
],
[
323
],
[
327,
329,
331
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345,
347
],
[
349
],
[
351
],
[
353,
355
],
[
357,
359,
361,
363,
365
],
[
367
],
[
371,
373,
375,
377,
379,
381
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393,
395
],
[
397
],
[
399
],
[
401
],
[
403,
405,
407,
409
],
[
413
],
[
415
],
[
417
],
[
419,
421
],
[
423
],
[
425
],
[
427,
429,
431,
433,
435
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449
],
[
453
],
[
455
],
[
457
],
[
459
],
[
461
],
[
463
],
[
465
],
[
467
],
[
469,
471
],
[
473,
475,
477
],
[
479
],
[
481
],
[
483
],
[
485
],
[
487
],
[
489,
491,
493,
495,
497
],
[
499
],
[
501
],
[
503
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513
],
[
515
],
[
519,
521
],
[
525
],
[
527
],
[
529
],
[
531,
533
],
[
535
],
[
539
],
[
543
],
[
545
]
] |
12,913
|
static int output_packet(InputStream *ist, int ist_index,
OutputStream *ost_table, int nb_ostreams,
const AVPacket *pkt)
{
AVFormatContext *os;
OutputStream *ost;
int ret, i;
int got_output;
void *buffer_to_free = NULL;
static unsigned int samples_size= 0;
AVSubtitle subtitle, *subtitle_to_free;
int64_t pkt_pts = AV_NOPTS_VALUE;
#if CONFIG_AVFILTER
int frame_available;
#endif
float quality;
AVPacket avpkt;
int bps = av_get_bytes_per_sample(ist->st->codec->sample_fmt);
if(ist->next_pts == AV_NOPTS_VALUE)
ist->next_pts= ist->pts;
if (pkt == NULL) {
/* EOF handling */
av_init_packet(&avpkt);
avpkt.data = NULL;
avpkt.size = 0;
goto handle_eof;
} else {
avpkt = *pkt;
}
if(pkt->dts != AV_NOPTS_VALUE)
ist->next_pts = ist->pts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q);
if(pkt->pts != AV_NOPTS_VALUE)
pkt_pts = av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q);
//while we have more to decode or while the decoder did output something on EOF
while (avpkt.size > 0 || (!pkt && got_output)) {
uint8_t *data_buf, *decoded_data_buf;
int data_size, decoded_data_size;
AVFrame *decoded_frame, *filtered_frame;
handle_eof:
ist->pts= ist->next_pts;
if(avpkt.size && avpkt.size != pkt->size)
av_log(NULL, ist->showed_multi_packet_warning ? AV_LOG_VERBOSE : AV_LOG_WARNING,
"Multiple frames in a packet from stream %d\n", pkt->stream_index);
ist->showed_multi_packet_warning=1;
/* decode the packet if needed */
decoded_frame = filtered_frame = NULL;
decoded_data_buf = NULL; /* fail safe */
decoded_data_size= 0;
data_buf = avpkt.data;
data_size = avpkt.size;
subtitle_to_free = NULL;
if (ist->decoding_needed) {
switch(ist->st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:{
if(pkt && samples_size < FFMAX(pkt->size*sizeof(*samples), AVCODEC_MAX_AUDIO_FRAME_SIZE)) {
samples_size = FFMAX(pkt->size*sizeof(*samples), AVCODEC_MAX_AUDIO_FRAME_SIZE);
av_free(samples);
samples= av_malloc(samples_size);
}
decoded_data_size= samples_size;
/* XXX: could avoid copy if PCM 16 bits with same
endianness as CPU */
ret = avcodec_decode_audio3(ist->st->codec, samples, &decoded_data_size,
&avpkt);
if (ret < 0)
return ret;
avpkt.data += ret;
avpkt.size -= ret;
data_size = ret;
got_output = decoded_data_size > 0;
/* Some bug in mpeg audio decoder gives */
/* decoded_data_size < 0, it seems they are overflows */
if (!got_output) {
/* no audio frame */
continue;
}
decoded_data_buf = (uint8_t *)samples;
ist->next_pts += ((int64_t)AV_TIME_BASE/bps * decoded_data_size) /
(ist->st->codec->sample_rate * ist->st->codec->channels);
break;}
case AVMEDIA_TYPE_VIDEO:
decoded_data_size = (ist->st->codec->width * ist->st->codec->height * 3) / 2;
if (!(decoded_frame = avcodec_alloc_frame()))
return AVERROR(ENOMEM);
avpkt.pts = pkt_pts;
avpkt.dts = ist->pts;
pkt_pts = AV_NOPTS_VALUE;
ret = avcodec_decode_video2(ist->st->codec,
decoded_frame, &got_output, &avpkt);
quality = same_quant ? decoded_frame->quality : 0;
if (ret < 0)
goto fail;
if (!got_output) {
/* no picture yet */
av_freep(&decoded_frame);
goto discard_packet;
}
ist->next_pts = ist->pts = decoded_frame->best_effort_timestamp;
if (ist->st->codec->time_base.num != 0) {
int ticks= ist->st->parser ? ist->st->parser->repeat_pict+1 : ist->st->codec->ticks_per_frame;
ist->next_pts += ((int64_t)AV_TIME_BASE *
ist->st->codec->time_base.num * ticks) /
ist->st->codec->time_base.den;
}
avpkt.size = 0;
buffer_to_free = NULL;
pre_process_video_frame(ist, (AVPicture *)decoded_frame, &buffer_to_free);
break;
case AVMEDIA_TYPE_SUBTITLE:
ret = avcodec_decode_subtitle2(ist->st->codec,
&subtitle, &got_output, &avpkt);
if (ret < 0)
return ret;
if (!got_output) {
goto discard_packet;
}
subtitle_to_free = &subtitle;
avpkt.size = 0;
break;
default:
return -1;
}
} else {
switch(ist->st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
ist->next_pts += ((int64_t)AV_TIME_BASE * ist->st->codec->frame_size) /
ist->st->codec->sample_rate;
break;
case AVMEDIA_TYPE_VIDEO:
if (ist->st->codec->time_base.num != 0) {
int ticks= ist->st->parser ? ist->st->parser->repeat_pict+1 : ist->st->codec->ticks_per_frame;
ist->next_pts += ((int64_t)AV_TIME_BASE *
ist->st->codec->time_base.num * ticks) /
ist->st->codec->time_base.den;
}
break;
}
avpkt.size = 0;
}
#if CONFIG_AVFILTER
if(ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
for(i=0;i<nb_ostreams;i++) {
OutputFile *of = &output_files[ost_table[i].file_index];
if (of->start_time == 0 || ist->pts >= of->start_time) {
ost = &ost_table[i];
if (ost->input_video_filter && ost->source_index == ist_index) {
if (!decoded_frame->sample_aspect_ratio.num)
decoded_frame->sample_aspect_ratio = ist->st->sample_aspect_ratio;
decoded_frame->pts = ist->pts;
av_vsrc_buffer_add_frame(ost->input_video_filter, decoded_frame, AV_VSRC_BUF_FLAG_OVERWRITE);
}
}
}
#endif
// preprocess audio (volume)
if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if (audio_volume != 256) {
short *volp;
volp = samples;
for(i=0;i<(decoded_data_size / sizeof(short));i++) {
int v = ((*volp) * audio_volume + 128) >> 8;
*volp++ = av_clip_int16(v);
}
}
}
/* frame rate emulation */
if (input_files[ist->file_index].rate_emu) {
int64_t pts = av_rescale(ist->pts, 1000000, AV_TIME_BASE);
int64_t now = av_gettime() - ist->start;
if (pts > now)
usleep(pts - now);
}
/* if output time reached then transcode raw format,
encode packets and output them */
for (i = 0; i < nb_ostreams; i++) {
OutputFile *of = &output_files[ost_table[i].file_index];
int frame_size;
ost = &ost_table[i];
if (ost->source_index != ist_index)
continue;
if (of->start_time && ist->pts < of->start_time)
continue;
if (of->recording_time != INT64_MAX &&
av_compare_ts(ist->pts, AV_TIME_BASE_Q, of->recording_time + of->start_time,
(AVRational){1, 1000000}) >= 0) {
ost->is_past_recording_time = 1;
continue;
}
#if CONFIG_AVFILTER
frame_available = ist->st->codec->codec_type != AVMEDIA_TYPE_VIDEO ||
!ost->output_video_filter || avfilter_poll_frame(ost->output_video_filter->inputs[0]);
while (frame_available) {
if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ost->output_video_filter) {
AVRational ist_pts_tb = ost->output_video_filter->inputs[0]->time_base;
if (av_buffersink_get_buffer_ref(ost->output_video_filter, &ost->picref, 0) < 0)
goto cont;
if (!filtered_frame && !(filtered_frame = avcodec_alloc_frame())) {
ret = AVERROR(ENOMEM);
goto fail;
}
*filtered_frame= *decoded_frame; //for me_threshold
if (ost->picref) {
avfilter_fill_frame_from_video_buffer_ref(filtered_frame, ost->picref);
ist->pts = av_rescale_q(ost->picref->pts, ist_pts_tb, AV_TIME_BASE_Q);
}
}
#else
filtered_frame = decoded_frame;
#endif
os = output_files[ost->file_index].ctx;
/* set the input output pts pairs */
//ost->sync_ipts = (double)(ist->pts + input_files[ist->file_index].ts_offset - start_time)/ AV_TIME_BASE;
if (ost->encoding_needed) {
av_assert0(ist->decoding_needed);
switch(ost->st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
do_audio_out(os, ost, ist, decoded_data_buf, decoded_data_size);
break;
case AVMEDIA_TYPE_VIDEO:
#if CONFIG_AVFILTER
if (ost->picref->video && !ost->frame_aspect_ratio)
ost->st->codec->sample_aspect_ratio = ost->picref->video->sample_aspect_ratio;
#endif
do_video_out(os, ost, ist, filtered_frame, &frame_size,
same_quant ? quality : ost->st->codec->global_quality);
if (vstats_filename && frame_size)
do_video_stats(os, ost, frame_size);
break;
case AVMEDIA_TYPE_SUBTITLE:
do_subtitle_out(os, ost, ist, &subtitle,
pkt->pts);
break;
default:
abort();
}
} else {
AVPicture pict;
AVPacket opkt;
int64_t ost_tb_start_time= av_rescale_q(of->start_time, AV_TIME_BASE_Q, ost->st->time_base);
av_init_packet(&opkt);
if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) && !copy_initial_nonkeyframes)
#if !CONFIG_AVFILTER
continue;
#else
goto cont;
#endif
/* no reencoding needed : output the packet directly */
/* force the input stream PTS */
if(ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
audio_size += data_size;
else if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
video_size += data_size;
ost->sync_opts++;
}
opkt.stream_index= ost->index;
if(pkt->pts != AV_NOPTS_VALUE)
opkt.pts= av_rescale_q(pkt->pts, ist->st->time_base, ost->st->time_base) - ost_tb_start_time;
else
opkt.pts= AV_NOPTS_VALUE;
if (pkt->dts == AV_NOPTS_VALUE)
opkt.dts = av_rescale_q(ist->pts, AV_TIME_BASE_Q, ost->st->time_base);
else
opkt.dts = av_rescale_q(pkt->dts, ist->st->time_base, ost->st->time_base);
opkt.dts -= ost_tb_start_time;
opkt.duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->st->time_base);
opkt.flags= pkt->flags;
//FIXME remove the following 2 lines they shall be replaced by the bitstream filters
if( ost->st->codec->codec_id != CODEC_ID_H264
&& ost->st->codec->codec_id != CODEC_ID_MPEG1VIDEO
&& ost->st->codec->codec_id != CODEC_ID_MPEG2VIDEO
) {
if(av_parser_change(ist->st->parser, ost->st->codec, &opkt.data, &opkt.size, data_buf, data_size, pkt->flags & AV_PKT_FLAG_KEY))
opkt.destruct= av_destruct_packet;
} else {
opkt.data = data_buf;
opkt.size = data_size;
}
if (os->oformat->flags & AVFMT_RAWPICTURE) {
/* store AVPicture in AVPacket, as expected by the output format */
avpicture_fill(&pict, opkt.data, ost->st->codec->pix_fmt, ost->st->codec->width, ost->st->codec->height);
opkt.data = (uint8_t *)&pict;
opkt.size = sizeof(AVPicture);
opkt.flags |= AV_PKT_FLAG_KEY;
}
write_frame(os, &opkt, ost->st->codec, ost->bitstream_filters);
ost->st->codec->frame_number++;
ost->frame_number++;
av_free_packet(&opkt);
}
#if CONFIG_AVFILTER
cont:
frame_available = (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) &&
ost->output_video_filter && avfilter_poll_frame(ost->output_video_filter->inputs[0]);
avfilter_unref_buffer(ost->picref);
}
av_freep(&filtered_frame);
#endif
}
fail:
av_free(buffer_to_free);
/* XXX: allocate the subtitles in the codec ? */
if (subtitle_to_free) {
avsubtitle_free(subtitle_to_free);
subtitle_to_free = NULL;
}
av_freep(&decoded_frame);
if (ret < 0)
return ret;
}
discard_packet:
return 0;
}
| true
|
FFmpeg
|
2f3dd904f4d3b2df5ea36ab5720d8f8834c54817
|
static int output_packet(InputStream *ist, int ist_index,
OutputStream *ost_table, int nb_ostreams,
const AVPacket *pkt)
{
AVFormatContext *os;
OutputStream *ost;
int ret, i;
int got_output;
void *buffer_to_free = NULL;
static unsigned int samples_size= 0;
AVSubtitle subtitle, *subtitle_to_free;
int64_t pkt_pts = AV_NOPTS_VALUE;
#if CONFIG_AVFILTER
int frame_available;
#endif
float quality;
AVPacket avpkt;
int bps = av_get_bytes_per_sample(ist->st->codec->sample_fmt);
if(ist->next_pts == AV_NOPTS_VALUE)
ist->next_pts= ist->pts;
if (pkt == NULL) {
av_init_packet(&avpkt);
avpkt.data = NULL;
avpkt.size = 0;
goto handle_eof;
} else {
avpkt = *pkt;
}
if(pkt->dts != AV_NOPTS_VALUE)
ist->next_pts = ist->pts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q);
if(pkt->pts != AV_NOPTS_VALUE)
pkt_pts = av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q);
while (avpkt.size > 0 || (!pkt && got_output)) {
uint8_t *data_buf, *decoded_data_buf;
int data_size, decoded_data_size;
AVFrame *decoded_frame, *filtered_frame;
handle_eof:
ist->pts= ist->next_pts;
if(avpkt.size && avpkt.size != pkt->size)
av_log(NULL, ist->showed_multi_packet_warning ? AV_LOG_VERBOSE : AV_LOG_WARNING,
"Multiple frames in a packet from stream %d\n", pkt->stream_index);
ist->showed_multi_packet_warning=1;
decoded_frame = filtered_frame = NULL;
decoded_data_buf = NULL;
decoded_data_size= 0;
data_buf = avpkt.data;
data_size = avpkt.size;
subtitle_to_free = NULL;
if (ist->decoding_needed) {
switch(ist->st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:{
if(pkt && samples_size < FFMAX(pkt->size*sizeof(*samples), AVCODEC_MAX_AUDIO_FRAME_SIZE)) {
samples_size = FFMAX(pkt->size*sizeof(*samples), AVCODEC_MAX_AUDIO_FRAME_SIZE);
av_free(samples);
samples= av_malloc(samples_size);
}
decoded_data_size= samples_size;
ret = avcodec_decode_audio3(ist->st->codec, samples, &decoded_data_size,
&avpkt);
if (ret < 0)
return ret;
avpkt.data += ret;
avpkt.size -= ret;
data_size = ret;
got_output = decoded_data_size > 0;
if (!got_output) {
continue;
}
decoded_data_buf = (uint8_t *)samples;
ist->next_pts += ((int64_t)AV_TIME_BASE/bps * decoded_data_size) /
(ist->st->codec->sample_rate * ist->st->codec->channels);
break;}
case AVMEDIA_TYPE_VIDEO:
decoded_data_size = (ist->st->codec->width * ist->st->codec->height * 3) / 2;
if (!(decoded_frame = avcodec_alloc_frame()))
return AVERROR(ENOMEM);
avpkt.pts = pkt_pts;
avpkt.dts = ist->pts;
pkt_pts = AV_NOPTS_VALUE;
ret = avcodec_decode_video2(ist->st->codec,
decoded_frame, &got_output, &avpkt);
quality = same_quant ? decoded_frame->quality : 0;
if (ret < 0)
goto fail;
if (!got_output) {
av_freep(&decoded_frame);
goto discard_packet;
}
ist->next_pts = ist->pts = decoded_frame->best_effort_timestamp;
if (ist->st->codec->time_base.num != 0) {
int ticks= ist->st->parser ? ist->st->parser->repeat_pict+1 : ist->st->codec->ticks_per_frame;
ist->next_pts += ((int64_t)AV_TIME_BASE *
ist->st->codec->time_base.num * ticks) /
ist->st->codec->time_base.den;
}
avpkt.size = 0;
buffer_to_free = NULL;
pre_process_video_frame(ist, (AVPicture *)decoded_frame, &buffer_to_free);
break;
case AVMEDIA_TYPE_SUBTITLE:
ret = avcodec_decode_subtitle2(ist->st->codec,
&subtitle, &got_output, &avpkt);
if (ret < 0)
return ret;
if (!got_output) {
goto discard_packet;
}
subtitle_to_free = &subtitle;
avpkt.size = 0;
break;
default:
return -1;
}
} else {
switch(ist->st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
ist->next_pts += ((int64_t)AV_TIME_BASE * ist->st->codec->frame_size) /
ist->st->codec->sample_rate;
break;
case AVMEDIA_TYPE_VIDEO:
if (ist->st->codec->time_base.num != 0) {
int ticks= ist->st->parser ? ist->st->parser->repeat_pict+1 : ist->st->codec->ticks_per_frame;
ist->next_pts += ((int64_t)AV_TIME_BASE *
ist->st->codec->time_base.num * ticks) /
ist->st->codec->time_base.den;
}
break;
}
avpkt.size = 0;
}
#if CONFIG_AVFILTER
if(ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
for(i=0;i<nb_ostreams;i++) {
OutputFile *of = &output_files[ost_table[i].file_index];
if (of->start_time == 0 || ist->pts >= of->start_time) {
ost = &ost_table[i];
if (ost->input_video_filter && ost->source_index == ist_index) {
if (!decoded_frame->sample_aspect_ratio.num)
decoded_frame->sample_aspect_ratio = ist->st->sample_aspect_ratio;
decoded_frame->pts = ist->pts;
av_vsrc_buffer_add_frame(ost->input_video_filter, decoded_frame, AV_VSRC_BUF_FLAG_OVERWRITE);
}
}
}
#endif
if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if (audio_volume != 256) {
short *volp;
volp = samples;
for(i=0;i<(decoded_data_size / sizeof(short));i++) {
int v = ((*volp) * audio_volume + 128) >> 8;
*volp++ = av_clip_int16(v);
}
}
}
if (input_files[ist->file_index].rate_emu) {
int64_t pts = av_rescale(ist->pts, 1000000, AV_TIME_BASE);
int64_t now = av_gettime() - ist->start;
if (pts > now)
usleep(pts - now);
}
for (i = 0; i < nb_ostreams; i++) {
OutputFile *of = &output_files[ost_table[i].file_index];
int frame_size;
ost = &ost_table[i];
if (ost->source_index != ist_index)
continue;
if (of->start_time && ist->pts < of->start_time)
continue;
if (of->recording_time != INT64_MAX &&
av_compare_ts(ist->pts, AV_TIME_BASE_Q, of->recording_time + of->start_time,
(AVRational){1, 1000000}) >= 0) {
ost->is_past_recording_time = 1;
continue;
}
#if CONFIG_AVFILTER
frame_available = ist->st->codec->codec_type != AVMEDIA_TYPE_VIDEO ||
!ost->output_video_filter || avfilter_poll_frame(ost->output_video_filter->inputs[0]);
while (frame_available) {
if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ost->output_video_filter) {
AVRational ist_pts_tb = ost->output_video_filter->inputs[0]->time_base;
if (av_buffersink_get_buffer_ref(ost->output_video_filter, &ost->picref, 0) < 0)
goto cont;
if (!filtered_frame && !(filtered_frame = avcodec_alloc_frame())) {
ret = AVERROR(ENOMEM);
goto fail;
}
*filtered_frame= *decoded_frame;
if (ost->picref) {
avfilter_fill_frame_from_video_buffer_ref(filtered_frame, ost->picref);
ist->pts = av_rescale_q(ost->picref->pts, ist_pts_tb, AV_TIME_BASE_Q);
}
}
#else
filtered_frame = decoded_frame;
#endif
os = output_files[ost->file_index].ctx;
if (ost->encoding_needed) {
av_assert0(ist->decoding_needed);
switch(ost->st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
do_audio_out(os, ost, ist, decoded_data_buf, decoded_data_size);
break;
case AVMEDIA_TYPE_VIDEO:
#if CONFIG_AVFILTER
if (ost->picref->video && !ost->frame_aspect_ratio)
ost->st->codec->sample_aspect_ratio = ost->picref->video->sample_aspect_ratio;
#endif
do_video_out(os, ost, ist, filtered_frame, &frame_size,
same_quant ? quality : ost->st->codec->global_quality);
if (vstats_filename && frame_size)
do_video_stats(os, ost, frame_size);
break;
case AVMEDIA_TYPE_SUBTITLE:
do_subtitle_out(os, ost, ist, &subtitle,
pkt->pts);
break;
default:
abort();
}
} else {
AVPicture pict;
AVPacket opkt;
int64_t ost_tb_start_time= av_rescale_q(of->start_time, AV_TIME_BASE_Q, ost->st->time_base);
av_init_packet(&opkt);
if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) && !copy_initial_nonkeyframes)
#if !CONFIG_AVFILTER
continue;
#else
goto cont;
#endif
if(ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
audio_size += data_size;
else if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
video_size += data_size;
ost->sync_opts++;
}
opkt.stream_index= ost->index;
if(pkt->pts != AV_NOPTS_VALUE)
opkt.pts= av_rescale_q(pkt->pts, ist->st->time_base, ost->st->time_base) - ost_tb_start_time;
else
opkt.pts= AV_NOPTS_VALUE;
if (pkt->dts == AV_NOPTS_VALUE)
opkt.dts = av_rescale_q(ist->pts, AV_TIME_BASE_Q, ost->st->time_base);
else
opkt.dts = av_rescale_q(pkt->dts, ist->st->time_base, ost->st->time_base);
opkt.dts -= ost_tb_start_time;
opkt.duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->st->time_base);
opkt.flags= pkt->flags;
if( ost->st->codec->codec_id != CODEC_ID_H264
&& ost->st->codec->codec_id != CODEC_ID_MPEG1VIDEO
&& ost->st->codec->codec_id != CODEC_ID_MPEG2VIDEO
) {
if(av_parser_change(ist->st->parser, ost->st->codec, &opkt.data, &opkt.size, data_buf, data_size, pkt->flags & AV_PKT_FLAG_KEY))
opkt.destruct= av_destruct_packet;
} else {
opkt.data = data_buf;
opkt.size = data_size;
}
if (os->oformat->flags & AVFMT_RAWPICTURE) {
avpicture_fill(&pict, opkt.data, ost->st->codec->pix_fmt, ost->st->codec->width, ost->st->codec->height);
opkt.data = (uint8_t *)&pict;
opkt.size = sizeof(AVPicture);
opkt.flags |= AV_PKT_FLAG_KEY;
}
write_frame(os, &opkt, ost->st->codec, ost->bitstream_filters);
ost->st->codec->frame_number++;
ost->frame_number++;
av_free_packet(&opkt);
}
#if CONFIG_AVFILTER
cont:
frame_available = (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) &&
ost->output_video_filter && avfilter_poll_frame(ost->output_video_filter->inputs[0]);
avfilter_unref_buffer(ost->picref);
}
av_freep(&filtered_frame);
#endif
}
fail:
av_free(buffer_to_free);
if (subtitle_to_free) {
avsubtitle_free(subtitle_to_free);
subtitle_to_free = NULL;
}
av_freep(&decoded_frame);
if (ret < 0)
return ret;
}
discard_packet:
return 0;
}
|
{
"code": [
" if (!decoded_frame->sample_aspect_ratio.num)",
" decoded_frame->sample_aspect_ratio = ist->st->sample_aspect_ratio;",
" decoded_frame->pts = ist->pts;",
" av_vsrc_buffer_add_frame(ost->input_video_filter, decoded_frame, AV_VSRC_BUF_FLAG_OVERWRITE);"
],
"line_no": [
311,
313,
315,
319
]
}
|
static int FUNC_0(InputStream *VAR_0, int VAR_1,
OutputStream *VAR_2, int VAR_3,
const AVPacket *VAR_4)
{
AVFormatContext *os;
OutputStream *ost;
int VAR_5, VAR_6;
int VAR_7;
void *VAR_8 = NULL;
static unsigned int VAR_9= 0;
AVSubtitle subtitle, *subtitle_to_free;
int64_t pkt_pts = AV_NOPTS_VALUE;
#if CONFIG_AVFILTER
int frame_available;
#endif
float VAR_10;
AVPacket avpkt;
int VAR_11 = av_get_bytes_per_sample(VAR_0->st->codec->sample_fmt);
if(VAR_0->next_pts == AV_NOPTS_VALUE)
VAR_0->next_pts= VAR_0->pts;
if (VAR_4 == NULL) {
av_init_packet(&avpkt);
avpkt.data = NULL;
avpkt.size = 0;
goto handle_eof;
} else {
avpkt = *VAR_4;
}
if(VAR_4->dts != AV_NOPTS_VALUE)
VAR_0->next_pts = VAR_0->pts = av_rescale_q(VAR_4->dts, VAR_0->st->time_base, AV_TIME_BASE_Q);
if(VAR_4->pts != AV_NOPTS_VALUE)
pkt_pts = av_rescale_q(VAR_4->pts, VAR_0->st->time_base, AV_TIME_BASE_Q);
while (avpkt.size > 0 || (!VAR_4 && VAR_7)) {
uint8_t *data_buf, *decoded_data_buf;
int VAR_12, VAR_13;
AVFrame *decoded_frame, *filtered_frame;
handle_eof:
VAR_0->pts= VAR_0->next_pts;
if(avpkt.size && avpkt.size != VAR_4->size)
av_log(NULL, VAR_0->showed_multi_packet_warning ? AV_LOG_VERBOSE : AV_LOG_WARNING,
"Multiple frames in a packet from stream %d\n", VAR_4->stream_index);
VAR_0->showed_multi_packet_warning=1;
decoded_frame = filtered_frame = NULL;
decoded_data_buf = NULL;
VAR_13= 0;
data_buf = avpkt.data;
VAR_12 = avpkt.size;
subtitle_to_free = NULL;
if (VAR_0->decoding_needed) {
switch(VAR_0->st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:{
if(VAR_4 && VAR_9 < FFMAX(VAR_4->size*sizeof(*samples), AVCODEC_MAX_AUDIO_FRAME_SIZE)) {
VAR_9 = FFMAX(VAR_4->size*sizeof(*samples), AVCODEC_MAX_AUDIO_FRAME_SIZE);
av_free(samples);
samples= av_malloc(VAR_9);
}
VAR_13= VAR_9;
VAR_5 = avcodec_decode_audio3(VAR_0->st->codec, samples, &VAR_13,
&avpkt);
if (VAR_5 < 0)
return VAR_5;
avpkt.data += VAR_5;
avpkt.size -= VAR_5;
VAR_12 = VAR_5;
VAR_7 = VAR_13 > 0;
if (!VAR_7) {
continue;
}
decoded_data_buf = (uint8_t *)samples;
VAR_0->next_pts += ((int64_t)AV_TIME_BASE/VAR_11 * VAR_13) /
(VAR_0->st->codec->sample_rate * VAR_0->st->codec->channels);
break;}
case AVMEDIA_TYPE_VIDEO:
VAR_13 = (VAR_0->st->codec->width * VAR_0->st->codec->height * 3) / 2;
if (!(decoded_frame = avcodec_alloc_frame()))
return AVERROR(ENOMEM);
avpkt.pts = pkt_pts;
avpkt.dts = VAR_0->pts;
pkt_pts = AV_NOPTS_VALUE;
VAR_5 = avcodec_decode_video2(VAR_0->st->codec,
decoded_frame, &VAR_7, &avpkt);
VAR_10 = same_quant ? decoded_frame->VAR_10 : 0;
if (VAR_5 < 0)
goto fail;
if (!VAR_7) {
av_freep(&decoded_frame);
goto discard_packet;
}
VAR_0->next_pts = VAR_0->pts = decoded_frame->best_effort_timestamp;
if (VAR_0->st->codec->time_base.num != 0) {
int VAR_15= VAR_0->st->parser ? VAR_0->st->parser->repeat_pict+1 : VAR_0->st->codec->ticks_per_frame;
VAR_0->next_pts += ((int64_t)AV_TIME_BASE *
VAR_0->st->codec->time_base.num * VAR_15) /
VAR_0->st->codec->time_base.den;
}
avpkt.size = 0;
VAR_8 = NULL;
pre_process_video_frame(VAR_0, (AVPicture *)decoded_frame, &VAR_8);
break;
case AVMEDIA_TYPE_SUBTITLE:
VAR_5 = avcodec_decode_subtitle2(VAR_0->st->codec,
&subtitle, &VAR_7, &avpkt);
if (VAR_5 < 0)
return VAR_5;
if (!VAR_7) {
goto discard_packet;
}
subtitle_to_free = &subtitle;
avpkt.size = 0;
break;
default:
return -1;
}
} else {
switch(VAR_0->st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
VAR_0->next_pts += ((int64_t)AV_TIME_BASE * VAR_0->st->codec->VAR_17) /
VAR_0->st->codec->sample_rate;
break;
case AVMEDIA_TYPE_VIDEO:
if (VAR_0->st->codec->time_base.num != 0) {
int VAR_15= VAR_0->st->parser ? VAR_0->st->parser->repeat_pict+1 : VAR_0->st->codec->ticks_per_frame;
VAR_0->next_pts += ((int64_t)AV_TIME_BASE *
VAR_0->st->codec->time_base.num * VAR_15) /
VAR_0->st->codec->time_base.den;
}
break;
}
avpkt.size = 0;
}
#if CONFIG_AVFILTER
if(VAR_0->st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
for(VAR_6=0;VAR_6<VAR_3;VAR_6++) {
OutputFile *of = &output_files[VAR_2[VAR_6].file_index];
if (of->start_time == 0 || VAR_0->pts >= of->start_time) {
ost = &VAR_2[VAR_6];
if (ost->input_video_filter && ost->source_index == VAR_1) {
if (!decoded_frame->sample_aspect_ratio.num)
decoded_frame->sample_aspect_ratio = VAR_0->st->sample_aspect_ratio;
decoded_frame->pts = VAR_0->pts;
av_vsrc_buffer_add_frame(ost->input_video_filter, decoded_frame, AV_VSRC_BUF_FLAG_OVERWRITE);
}
}
}
#endif
if (VAR_0->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if (audio_volume != 256) {
short *VAR_15;
VAR_15 = samples;
for(VAR_6=0;VAR_6<(VAR_13 / sizeof(short));VAR_6++) {
int VAR_16 = ((*VAR_15) * audio_volume + 128) >> 8;
*VAR_15++ = av_clip_int16(VAR_16);
}
}
}
if (input_files[VAR_0->file_index].rate_emu) {
int64_t pts = av_rescale(VAR_0->pts, 1000000, AV_TIME_BASE);
int64_t now = av_gettime() - VAR_0->start;
if (pts > now)
usleep(pts - now);
}
for (VAR_6 = 0; VAR_6 < VAR_3; VAR_6++) {
OutputFile *of = &output_files[VAR_2[VAR_6].file_index];
int VAR_17;
ost = &VAR_2[VAR_6];
if (ost->source_index != VAR_1)
continue;
if (of->start_time && VAR_0->pts < of->start_time)
continue;
if (of->recording_time != INT64_MAX &&
av_compare_ts(VAR_0->pts, AV_TIME_BASE_Q, of->recording_time + of->start_time,
(AVRational){1, 1000000}) >= 0) {
ost->is_past_recording_time = 1;
continue;
}
#if CONFIG_AVFILTER
frame_available = VAR_0->st->codec->codec_type != AVMEDIA_TYPE_VIDEO ||
!ost->output_video_filter || avfilter_poll_frame(ost->output_video_filter->inputs[0]);
while (frame_available) {
if (VAR_0->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ost->output_video_filter) {
AVRational ist_pts_tb = ost->output_video_filter->inputs[0]->time_base;
if (av_buffersink_get_buffer_ref(ost->output_video_filter, &ost->picref, 0) < 0)
goto cont;
if (!filtered_frame && !(filtered_frame = avcodec_alloc_frame())) {
VAR_5 = AVERROR(ENOMEM);
goto fail;
}
*filtered_frame= *decoded_frame;
if (ost->picref) {
avfilter_fill_frame_from_video_buffer_ref(filtered_frame, ost->picref);
VAR_0->pts = av_rescale_q(ost->picref->pts, ist_pts_tb, AV_TIME_BASE_Q);
}
}
#else
filtered_frame = decoded_frame;
#endif
os = output_files[ost->file_index].ctx;
if (ost->encoding_needed) {
av_assert0(VAR_0->decoding_needed);
switch(ost->st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
do_audio_out(os, ost, VAR_0, decoded_data_buf, VAR_13);
break;
case AVMEDIA_TYPE_VIDEO:
#if CONFIG_AVFILTER
if (ost->picref->video && !ost->frame_aspect_ratio)
ost->st->codec->sample_aspect_ratio = ost->picref->video->sample_aspect_ratio;
#endif
do_video_out(os, ost, VAR_0, filtered_frame, &VAR_17,
same_quant ? VAR_10 : ost->st->codec->global_quality);
if (vstats_filename && VAR_17)
do_video_stats(os, ost, VAR_17);
break;
case AVMEDIA_TYPE_SUBTITLE:
do_subtitle_out(os, ost, VAR_0, &subtitle,
VAR_4->pts);
break;
default:
abort();
}
} else {
AVPicture pict;
AVPacket opkt;
int64_t ost_tb_start_time= av_rescale_q(of->start_time, AV_TIME_BASE_Q, ost->st->time_base);
av_init_packet(&opkt);
if ((!ost->frame_number && !(VAR_4->flags & AV_PKT_FLAG_KEY)) && !copy_initial_nonkeyframes)
#if !CONFIG_AVFILTER
continue;
#else
goto cont;
#endif
if(ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
audio_size += VAR_12;
else if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
video_size += VAR_12;
ost->sync_opts++;
}
opkt.stream_index= ost->index;
if(VAR_4->pts != AV_NOPTS_VALUE)
opkt.pts= av_rescale_q(VAR_4->pts, VAR_0->st->time_base, ost->st->time_base) - ost_tb_start_time;
else
opkt.pts= AV_NOPTS_VALUE;
if (VAR_4->dts == AV_NOPTS_VALUE)
opkt.dts = av_rescale_q(VAR_0->pts, AV_TIME_BASE_Q, ost->st->time_base);
else
opkt.dts = av_rescale_q(VAR_4->dts, VAR_0->st->time_base, ost->st->time_base);
opkt.dts -= ost_tb_start_time;
opkt.duration = av_rescale_q(VAR_4->duration, VAR_0->st->time_base, ost->st->time_base);
opkt.flags= VAR_4->flags;
if( ost->st->codec->codec_id != CODEC_ID_H264
&& ost->st->codec->codec_id != CODEC_ID_MPEG1VIDEO
&& ost->st->codec->codec_id != CODEC_ID_MPEG2VIDEO
) {
if(av_parser_change(VAR_0->st->parser, ost->st->codec, &opkt.data, &opkt.size, data_buf, VAR_12, VAR_4->flags & AV_PKT_FLAG_KEY))
opkt.destruct= av_destruct_packet;
} else {
opkt.data = data_buf;
opkt.size = VAR_12;
}
if (os->oformat->flags & AVFMT_RAWPICTURE) {
avpicture_fill(&pict, opkt.data, ost->st->codec->pix_fmt, ost->st->codec->width, ost->st->codec->height);
opkt.data = (uint8_t *)&pict;
opkt.size = sizeof(AVPicture);
opkt.flags |= AV_PKT_FLAG_KEY;
}
write_frame(os, &opkt, ost->st->codec, ost->bitstream_filters);
ost->st->codec->frame_number++;
ost->frame_number++;
av_free_packet(&opkt);
}
#if CONFIG_AVFILTER
cont:
frame_available = (VAR_0->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) &&
ost->output_video_filter && avfilter_poll_frame(ost->output_video_filter->inputs[0]);
avfilter_unref_buffer(ost->picref);
}
av_freep(&filtered_frame);
#endif
}
fail:
av_free(VAR_8);
if (subtitle_to_free) {
avsubtitle_free(subtitle_to_free);
subtitle_to_free = NULL;
}
av_freep(&decoded_frame);
if (VAR_5 < 0)
return VAR_5;
}
discard_packet:
return 0;
}
|
[
"static int FUNC_0(InputStream *VAR_0, int VAR_1,\nOutputStream *VAR_2, int VAR_3,\nconst AVPacket *VAR_4)\n{",
"AVFormatContext *os;",
"OutputStream *ost;",
"int VAR_5, VAR_6;",
"int VAR_7;",
"void *VAR_8 = NULL;",
"static unsigned int VAR_9= 0;",
"AVSubtitle subtitle, *subtitle_to_free;",
"int64_t pkt_pts = AV_NOPTS_VALUE;",
"#if CONFIG_AVFILTER\nint frame_available;",
"#endif\nfloat VAR_10;",
"AVPacket avpkt;",
"int VAR_11 = av_get_bytes_per_sample(VAR_0->st->codec->sample_fmt);",
"if(VAR_0->next_pts == AV_NOPTS_VALUE)\nVAR_0->next_pts= VAR_0->pts;",
"if (VAR_4 == NULL) {",
"av_init_packet(&avpkt);",
"avpkt.data = NULL;",
"avpkt.size = 0;",
"goto handle_eof;",
"} else {",
"avpkt = *VAR_4;",
"}",
"if(VAR_4->dts != AV_NOPTS_VALUE)\nVAR_0->next_pts = VAR_0->pts = av_rescale_q(VAR_4->dts, VAR_0->st->time_base, AV_TIME_BASE_Q);",
"if(VAR_4->pts != AV_NOPTS_VALUE)\npkt_pts = av_rescale_q(VAR_4->pts, VAR_0->st->time_base, AV_TIME_BASE_Q);",
"while (avpkt.size > 0 || (!VAR_4 && VAR_7)) {",
"uint8_t *data_buf, *decoded_data_buf;",
"int VAR_12, VAR_13;",
"AVFrame *decoded_frame, *filtered_frame;",
"handle_eof:\nVAR_0->pts= VAR_0->next_pts;",
"if(avpkt.size && avpkt.size != VAR_4->size)\nav_log(NULL, VAR_0->showed_multi_packet_warning ? AV_LOG_VERBOSE : AV_LOG_WARNING,\n\"Multiple frames in a packet from stream %d\\n\", VAR_4->stream_index);",
"VAR_0->showed_multi_packet_warning=1;",
"decoded_frame = filtered_frame = NULL;",
"decoded_data_buf = NULL;",
"VAR_13= 0;",
"data_buf = avpkt.data;",
"VAR_12 = avpkt.size;",
"subtitle_to_free = NULL;",
"if (VAR_0->decoding_needed) {",
"switch(VAR_0->st->codec->codec_type) {",
"case AVMEDIA_TYPE_AUDIO:{",
"if(VAR_4 && VAR_9 < FFMAX(VAR_4->size*sizeof(*samples), AVCODEC_MAX_AUDIO_FRAME_SIZE)) {",
"VAR_9 = FFMAX(VAR_4->size*sizeof(*samples), AVCODEC_MAX_AUDIO_FRAME_SIZE);",
"av_free(samples);",
"samples= av_malloc(VAR_9);",
"}",
"VAR_13= VAR_9;",
"VAR_5 = avcodec_decode_audio3(VAR_0->st->codec, samples, &VAR_13,\n&avpkt);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"avpkt.data += VAR_5;",
"avpkt.size -= VAR_5;",
"VAR_12 = VAR_5;",
"VAR_7 = VAR_13 > 0;",
"if (!VAR_7) {",
"continue;",
"}",
"decoded_data_buf = (uint8_t *)samples;",
"VAR_0->next_pts += ((int64_t)AV_TIME_BASE/VAR_11 * VAR_13) /\n(VAR_0->st->codec->sample_rate * VAR_0->st->codec->channels);",
"break;}",
"case AVMEDIA_TYPE_VIDEO:\nVAR_13 = (VAR_0->st->codec->width * VAR_0->st->codec->height * 3) / 2;",
"if (!(decoded_frame = avcodec_alloc_frame()))\nreturn AVERROR(ENOMEM);",
"avpkt.pts = pkt_pts;",
"avpkt.dts = VAR_0->pts;",
"pkt_pts = AV_NOPTS_VALUE;",
"VAR_5 = avcodec_decode_video2(VAR_0->st->codec,\ndecoded_frame, &VAR_7, &avpkt);",
"VAR_10 = same_quant ? decoded_frame->VAR_10 : 0;",
"if (VAR_5 < 0)\ngoto fail;",
"if (!VAR_7) {",
"av_freep(&decoded_frame);",
"goto discard_packet;",
"}",
"VAR_0->next_pts = VAR_0->pts = decoded_frame->best_effort_timestamp;",
"if (VAR_0->st->codec->time_base.num != 0) {",
"int VAR_15= VAR_0->st->parser ? VAR_0->st->parser->repeat_pict+1 : VAR_0->st->codec->ticks_per_frame;",
"VAR_0->next_pts += ((int64_t)AV_TIME_BASE *\nVAR_0->st->codec->time_base.num * VAR_15) /\nVAR_0->st->codec->time_base.den;",
"}",
"avpkt.size = 0;",
"VAR_8 = NULL;",
"pre_process_video_frame(VAR_0, (AVPicture *)decoded_frame, &VAR_8);",
"break;",
"case AVMEDIA_TYPE_SUBTITLE:\nVAR_5 = avcodec_decode_subtitle2(VAR_0->st->codec,\n&subtitle, &VAR_7, &avpkt);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"if (!VAR_7) {",
"goto discard_packet;",
"}",
"subtitle_to_free = &subtitle;",
"avpkt.size = 0;",
"break;",
"default:\nreturn -1;",
"}",
"} else {",
"switch(VAR_0->st->codec->codec_type) {",
"case AVMEDIA_TYPE_AUDIO:\nVAR_0->next_pts += ((int64_t)AV_TIME_BASE * VAR_0->st->codec->VAR_17) /\nVAR_0->st->codec->sample_rate;",
"break;",
"case AVMEDIA_TYPE_VIDEO:\nif (VAR_0->st->codec->time_base.num != 0) {",
"int VAR_15= VAR_0->st->parser ? VAR_0->st->parser->repeat_pict+1 : VAR_0->st->codec->ticks_per_frame;",
"VAR_0->next_pts += ((int64_t)AV_TIME_BASE *\nVAR_0->st->codec->time_base.num * VAR_15) /\nVAR_0->st->codec->time_base.den;",
"}",
"break;",
"}",
"avpkt.size = 0;",
"}",
"#if CONFIG_AVFILTER\nif(VAR_0->st->codec->codec_type == AVMEDIA_TYPE_VIDEO)\nfor(VAR_6=0;VAR_6<VAR_3;VAR_6++) {",
"OutputFile *of = &output_files[VAR_2[VAR_6].file_index];",
"if (of->start_time == 0 || VAR_0->pts >= of->start_time) {",
"ost = &VAR_2[VAR_6];",
"if (ost->input_video_filter && ost->source_index == VAR_1) {",
"if (!decoded_frame->sample_aspect_ratio.num)\ndecoded_frame->sample_aspect_ratio = VAR_0->st->sample_aspect_ratio;",
"decoded_frame->pts = VAR_0->pts;",
"av_vsrc_buffer_add_frame(ost->input_video_filter, decoded_frame, AV_VSRC_BUF_FLAG_OVERWRITE);",
"}",
"}",
"}",
"#endif\nif (VAR_0->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {",
"if (audio_volume != 256) {",
"short *VAR_15;",
"VAR_15 = samples;",
"for(VAR_6=0;VAR_6<(VAR_13 / sizeof(short));VAR_6++) {",
"int VAR_16 = ((*VAR_15) * audio_volume + 128) >> 8;",
"*VAR_15++ = av_clip_int16(VAR_16);",
"}",
"}",
"}",
"if (input_files[VAR_0->file_index].rate_emu) {",
"int64_t pts = av_rescale(VAR_0->pts, 1000000, AV_TIME_BASE);",
"int64_t now = av_gettime() - VAR_0->start;",
"if (pts > now)\nusleep(pts - now);",
"}",
"for (VAR_6 = 0; VAR_6 < VAR_3; VAR_6++) {",
"OutputFile *of = &output_files[VAR_2[VAR_6].file_index];",
"int VAR_17;",
"ost = &VAR_2[VAR_6];",
"if (ost->source_index != VAR_1)\ncontinue;",
"if (of->start_time && VAR_0->pts < of->start_time)\ncontinue;",
"if (of->recording_time != INT64_MAX &&\nav_compare_ts(VAR_0->pts, AV_TIME_BASE_Q, of->recording_time + of->start_time,\n(AVRational){1, 1000000}) >= 0) {",
"ost->is_past_recording_time = 1;",
"continue;",
"}",
"#if CONFIG_AVFILTER\nframe_available = VAR_0->st->codec->codec_type != AVMEDIA_TYPE_VIDEO ||\n!ost->output_video_filter || avfilter_poll_frame(ost->output_video_filter->inputs[0]);",
"while (frame_available) {",
"if (VAR_0->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ost->output_video_filter) {",
"AVRational ist_pts_tb = ost->output_video_filter->inputs[0]->time_base;",
"if (av_buffersink_get_buffer_ref(ost->output_video_filter, &ost->picref, 0) < 0)\ngoto cont;",
"if (!filtered_frame && !(filtered_frame = avcodec_alloc_frame())) {",
"VAR_5 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"*filtered_frame= *decoded_frame;",
"if (ost->picref) {",
"avfilter_fill_frame_from_video_buffer_ref(filtered_frame, ost->picref);",
"VAR_0->pts = av_rescale_q(ost->picref->pts, ist_pts_tb, AV_TIME_BASE_Q);",
"}",
"}",
"#else\nfiltered_frame = decoded_frame;",
"#endif\nos = output_files[ost->file_index].ctx;",
"if (ost->encoding_needed) {",
"av_assert0(VAR_0->decoding_needed);",
"switch(ost->st->codec->codec_type) {",
"case AVMEDIA_TYPE_AUDIO:\ndo_audio_out(os, ost, VAR_0, decoded_data_buf, VAR_13);",
"break;",
"case AVMEDIA_TYPE_VIDEO:\n#if CONFIG_AVFILTER\nif (ost->picref->video && !ost->frame_aspect_ratio)\nost->st->codec->sample_aspect_ratio = ost->picref->video->sample_aspect_ratio;",
"#endif\ndo_video_out(os, ost, VAR_0, filtered_frame, &VAR_17,\nsame_quant ? VAR_10 : ost->st->codec->global_quality);",
"if (vstats_filename && VAR_17)\ndo_video_stats(os, ost, VAR_17);",
"break;",
"case AVMEDIA_TYPE_SUBTITLE:\ndo_subtitle_out(os, ost, VAR_0, &subtitle,\nVAR_4->pts);",
"break;",
"default:\nabort();",
"}",
"} else {",
"AVPicture pict;",
"AVPacket opkt;",
"int64_t ost_tb_start_time= av_rescale_q(of->start_time, AV_TIME_BASE_Q, ost->st->time_base);",
"av_init_packet(&opkt);",
"if ((!ost->frame_number && !(VAR_4->flags & AV_PKT_FLAG_KEY)) && !copy_initial_nonkeyframes)\n#if !CONFIG_AVFILTER\ncontinue;",
"#else\ngoto cont;",
"#endif\nif(ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO)\naudio_size += VAR_12;",
"else if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {",
"video_size += VAR_12;",
"ost->sync_opts++;",
"}",
"opkt.stream_index= ost->index;",
"if(VAR_4->pts != AV_NOPTS_VALUE)\nopkt.pts= av_rescale_q(VAR_4->pts, VAR_0->st->time_base, ost->st->time_base) - ost_tb_start_time;",
"else\nopkt.pts= AV_NOPTS_VALUE;",
"if (VAR_4->dts == AV_NOPTS_VALUE)\nopkt.dts = av_rescale_q(VAR_0->pts, AV_TIME_BASE_Q, ost->st->time_base);",
"else\nopkt.dts = av_rescale_q(VAR_4->dts, VAR_0->st->time_base, ost->st->time_base);",
"opkt.dts -= ost_tb_start_time;",
"opkt.duration = av_rescale_q(VAR_4->duration, VAR_0->st->time_base, ost->st->time_base);",
"opkt.flags= VAR_4->flags;",
"if( ost->st->codec->codec_id != CODEC_ID_H264\n&& ost->st->codec->codec_id != CODEC_ID_MPEG1VIDEO\n&& ost->st->codec->codec_id != CODEC_ID_MPEG2VIDEO\n) {",
"if(av_parser_change(VAR_0->st->parser, ost->st->codec, &opkt.data, &opkt.size, data_buf, VAR_12, VAR_4->flags & AV_PKT_FLAG_KEY))\nopkt.destruct= av_destruct_packet;",
"} else {",
"opkt.data = data_buf;",
"opkt.size = VAR_12;",
"}",
"if (os->oformat->flags & AVFMT_RAWPICTURE) {",
"avpicture_fill(&pict, opkt.data, ost->st->codec->pix_fmt, ost->st->codec->width, ost->st->codec->height);",
"opkt.data = (uint8_t *)&pict;",
"opkt.size = sizeof(AVPicture);",
"opkt.flags |= AV_PKT_FLAG_KEY;",
"}",
"write_frame(os, &opkt, ost->st->codec, ost->bitstream_filters);",
"ost->st->codec->frame_number++;",
"ost->frame_number++;",
"av_free_packet(&opkt);",
"}",
"#if CONFIG_AVFILTER\ncont:\nframe_available = (VAR_0->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) &&\nost->output_video_filter && avfilter_poll_frame(ost->output_video_filter->inputs[0]);",
"avfilter_unref_buffer(ost->picref);",
"}",
"av_freep(&filtered_frame);",
"#endif\n}",
"fail:\nav_free(VAR_8);",
"if (subtitle_to_free) {",
"avsubtitle_free(subtitle_to_free);",
"subtitle_to_free = NULL;",
"}",
"av_freep(&decoded_frame);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"}",
"discard_packet:\nreturn 0;",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29,
31
],
[
35
],
[
37
],
[
41,
43
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67,
69
],
[
71,
73
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87,
89
],
[
93,
95,
97
],
[
99
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
139,
141
],
[
143,
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
159
],
[
163
],
[
165
],
[
167
],
[
169,
171
],
[
173
],
[
175,
177
],
[
179,
181
],
[
183
],
[
185
],
[
187
],
[
191,
193
],
[
195
],
[
197,
199
],
[
201
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217,
219,
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233,
235,
237
],
[
239,
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255,
257
],
[
259
],
[
261
],
[
263
],
[
265,
267,
269
],
[
271
],
[
273,
275
],
[
277
],
[
279,
281,
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
297,
299,
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311,
313
],
[
315
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327,
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
357
],
[
359
],
[
361
],
[
363,
365
],
[
367
],
[
373
],
[
375
],
[
377
],
[
381
],
[
383,
385
],
[
389,
391
],
[
395,
397,
399
],
[
401
],
[
403
],
[
405
],
[
409,
411,
413
],
[
415
],
[
417
],
[
419
],
[
421,
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443
],
[
445,
447
],
[
449,
451
],
[
461
],
[
463
],
[
465
],
[
467,
469
],
[
471
],
[
473,
475,
477,
479
],
[
481,
483,
485
],
[
487,
489
],
[
491
],
[
493,
495,
497
],
[
499
],
[
501,
503
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513
],
[
515
],
[
519,
521,
523
],
[
525,
527
],
[
529,
539,
541
],
[
543
],
[
545
],
[
547
],
[
549
],
[
553
],
[
555,
557
],
[
559,
561
],
[
565,
567
],
[
569,
571
],
[
573
],
[
577
],
[
579
],
[
585,
587,
589,
591
],
[
593,
595
],
[
597
],
[
599
],
[
601
],
[
603
],
[
607
],
[
611
],
[
613
],
[
615
],
[
617
],
[
619
],
[
621
],
[
623
],
[
625
],
[
627
],
[
629
],
[
631,
633,
635,
637
],
[
639
],
[
641
],
[
643
],
[
645,
647
],
[
651,
653
],
[
657
],
[
659
],
[
661
],
[
663
],
[
665
],
[
667,
669
],
[
671
],
[
673,
677
],
[
679
]
] |
12,914
|
void wdt_i6300esb_init(void)
{
watchdog_add_model(&model);
}
| true
|
qemu
|
09aaa1602f9381c0e0fb539390b1793e51bdfc7b
|
void wdt_i6300esb_init(void)
{
watchdog_add_model(&model);
}
|
{
"code": [
"void wdt_i6300esb_init(void)"
],
"line_no": [
1
]
}
|
void FUNC_0(void)
{
watchdog_add_model(&model);
}
|
[
"void FUNC_0(void)\n{",
"watchdog_add_model(&model);",
"}"
] |
[
1,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
]
] |
12,915
|
static int decode_frame(AVCodecContext * avctx,
void *data, int *data_size,
UINT8 * buf, int buf_size)
{
MPADecodeContext *s = avctx->priv_data;
UINT32 header;
UINT8 *buf_ptr;
int len, out_size;
short *out_samples = data;
*data_size = 0;
buf_ptr = buf;
while (buf_size > 0) {
len = s->inbuf_ptr - s->inbuf;
if (s->frame_size == 0) {
/* special case for next header for first frame in free
format case (XXX: find a simpler method) */
if (s->free_format_next_header != 0) {
s->inbuf[0] = s->free_format_next_header >> 24;
s->inbuf[1] = s->free_format_next_header >> 16;
s->inbuf[2] = s->free_format_next_header >> 8;
s->inbuf[3] = s->free_format_next_header;
s->inbuf_ptr = s->inbuf + 4;
s->free_format_next_header = 0;
goto got_header;
}
/* no header seen : find one. We need at least HEADER_SIZE
bytes to parse it */
len = HEADER_SIZE - len;
if (len > buf_size)
len = buf_size;
else if (len > 0) {
memcpy(s->inbuf_ptr, buf_ptr, len);
buf_ptr += len;
buf_size -= len;
s->inbuf_ptr += len;
}
if ((s->inbuf_ptr - s->inbuf) >= HEADER_SIZE) {
got_header:
header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
(s->inbuf[2] << 8) | s->inbuf[3];
if (check_header(header) < 0) {
/* no sync found : move by one byte (inefficient, but simple!) */
memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf);
s->inbuf_ptr--;
dprintf("skip %x\n", header);
/* reset free format frame size to give a chance
to get a new bitrate */
s->free_format_frame_size = 0;
} else {
if (decode_header(s, header) == 1) {
/* free format: compute frame size */
s->frame_size = -1;
memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf);
s->inbuf_ptr--;
} else {
/* update codec info */
avctx->sample_rate = s->sample_rate;
avctx->channels = s->nb_channels;
avctx->bit_rate = s->bit_rate;
}
}
}
} else if (s->frame_size == -1) {
/* free format : find next sync to compute frame size */
len = MPA_MAX_CODED_FRAME_SIZE - len;
if (len > buf_size)
len = buf_size;
if (len == 0) {
/* frame too long: resync */
s->frame_size = 0;
} else {
UINT8 *p, *pend;
UINT32 header1;
int padding;
memcpy(s->inbuf_ptr, buf_ptr, len);
/* check for header */
p = s->inbuf_ptr - 3;
pend = s->inbuf_ptr + len - 4;
while (p <= pend) {
header = (p[0] << 24) | (p[1] << 16) |
(p[2] << 8) | p[3];
header1 = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
(s->inbuf[2] << 8) | s->inbuf[3];
/* check with high probability that we have a
valid header */
if ((header & SAME_HEADER_MASK) ==
(header1 & SAME_HEADER_MASK)) {
/* header found: update pointers */
len = (p + 4) - s->inbuf_ptr;
buf_ptr += len;
buf_size -= len;
s->inbuf_ptr = p;
/* compute frame size */
s->free_format_next_header = header;
s->free_format_frame_size = s->inbuf_ptr - s->inbuf;
padding = (header1 >> 9) & 1;
if (s->layer == 1)
s->free_format_frame_size -= padding * 4;
else
s->free_format_frame_size -= padding;
dprintf("free frame size=%d padding=%d\n",
s->free_format_frame_size, padding);
decode_header(s, header1);
goto next_data;
}
p++;
}
/* not found: simply increase pointers */
buf_ptr += len;
s->inbuf_ptr += len;
buf_size -= len;
}
} else if (len < s->frame_size) {
if (s->frame_size > MPA_MAX_CODED_FRAME_SIZE)
s->frame_size = MPA_MAX_CODED_FRAME_SIZE;
len = s->frame_size - len;
if (len > buf_size)
len = buf_size;
else if (len > 0)
{
memcpy(s->inbuf_ptr, buf_ptr, len);
buf_ptr += len;
s->inbuf_ptr += len;
buf_size -= len;
}
} else {
out_size = mp_decode_frame(s, out_samples);
s->inbuf_ptr = s->inbuf;
s->frame_size = 0;
*data_size = out_size;
break;
}
next_data:
}
return buf_ptr - buf;
}
| true
|
FFmpeg
|
2d83f323d63332e5ecaa481d8f9301c0ea92b6ba
|
static int decode_frame(AVCodecContext * avctx,
void *data, int *data_size,
UINT8 * buf, int buf_size)
{
MPADecodeContext *s = avctx->priv_data;
UINT32 header;
UINT8 *buf_ptr;
int len, out_size;
short *out_samples = data;
*data_size = 0;
buf_ptr = buf;
while (buf_size > 0) {
len = s->inbuf_ptr - s->inbuf;
if (s->frame_size == 0) {
if (s->free_format_next_header != 0) {
s->inbuf[0] = s->free_format_next_header >> 24;
s->inbuf[1] = s->free_format_next_header >> 16;
s->inbuf[2] = s->free_format_next_header >> 8;
s->inbuf[3] = s->free_format_next_header;
s->inbuf_ptr = s->inbuf + 4;
s->free_format_next_header = 0;
goto got_header;
}
len = HEADER_SIZE - len;
if (len > buf_size)
len = buf_size;
else if (len > 0) {
memcpy(s->inbuf_ptr, buf_ptr, len);
buf_ptr += len;
buf_size -= len;
s->inbuf_ptr += len;
}
if ((s->inbuf_ptr - s->inbuf) >= HEADER_SIZE) {
got_header:
header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
(s->inbuf[2] << 8) | s->inbuf[3];
if (check_header(header) < 0) {
memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf);
s->inbuf_ptr--;
dprintf("skip %x\n", header);
s->free_format_frame_size = 0;
} else {
if (decode_header(s, header) == 1) {
s->frame_size = -1;
memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf);
s->inbuf_ptr--;
} else {
avctx->sample_rate = s->sample_rate;
avctx->channels = s->nb_channels;
avctx->bit_rate = s->bit_rate;
}
}
}
} else if (s->frame_size == -1) {
len = MPA_MAX_CODED_FRAME_SIZE - len;
if (len > buf_size)
len = buf_size;
if (len == 0) {
s->frame_size = 0;
} else {
UINT8 *p, *pend;
UINT32 header1;
int padding;
memcpy(s->inbuf_ptr, buf_ptr, len);
p = s->inbuf_ptr - 3;
pend = s->inbuf_ptr + len - 4;
while (p <= pend) {
header = (p[0] << 24) | (p[1] << 16) |
(p[2] << 8) | p[3];
header1 = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
(s->inbuf[2] << 8) | s->inbuf[3];
if ((header & SAME_HEADER_MASK) ==
(header1 & SAME_HEADER_MASK)) {
len = (p + 4) - s->inbuf_ptr;
buf_ptr += len;
buf_size -= len;
s->inbuf_ptr = p;
s->free_format_next_header = header;
s->free_format_frame_size = s->inbuf_ptr - s->inbuf;
padding = (header1 >> 9) & 1;
if (s->layer == 1)
s->free_format_frame_size -= padding * 4;
else
s->free_format_frame_size -= padding;
dprintf("free frame size=%d padding=%d\n",
s->free_format_frame_size, padding);
decode_header(s, header1);
goto next_data;
}
p++;
}
buf_ptr += len;
s->inbuf_ptr += len;
buf_size -= len;
}
} else if (len < s->frame_size) {
if (s->frame_size > MPA_MAX_CODED_FRAME_SIZE)
s->frame_size = MPA_MAX_CODED_FRAME_SIZE;
len = s->frame_size - len;
if (len > buf_size)
len = buf_size;
else if (len > 0)
{
memcpy(s->inbuf_ptr, buf_ptr, len);
buf_ptr += len;
s->inbuf_ptr += len;
buf_size -= len;
}
} else {
out_size = mp_decode_frame(s, out_samples);
s->inbuf_ptr = s->inbuf;
s->frame_size = 0;
*data_size = out_size;
break;
}
next_data:
}
return buf_ptr - buf;
}
|
{
"code": [
"\t memcpy(s->inbuf_ptr, buf_ptr, len);",
"\t buf_ptr += len;",
"\t buf_size -= len;",
"\t\t memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf);",
" s->frame_size = -1;",
"\t\t\tmemcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf);",
" avctx->bit_rate = s->bit_rate;",
"\t else if (len > 0)"
],
"line_no": [
65,
67,
69,
87,
105,
107,
119,
241
]
}
|
static int FUNC_0(AVCodecContext * VAR_0,
void *VAR_1, int *VAR_2,
UINT8 * VAR_3, int VAR_4)
{
MPADecodeContext *s = VAR_0->priv_data;
UINT32 header;
UINT8 *buf_ptr;
int VAR_5, VAR_6;
short *VAR_7 = VAR_1;
*VAR_2 = 0;
buf_ptr = VAR_3;
while (VAR_4 > 0) {
VAR_5 = s->inbuf_ptr - s->inbuf;
if (s->frame_size == 0) {
if (s->free_format_next_header != 0) {
s->inbuf[0] = s->free_format_next_header >> 24;
s->inbuf[1] = s->free_format_next_header >> 16;
s->inbuf[2] = s->free_format_next_header >> 8;
s->inbuf[3] = s->free_format_next_header;
s->inbuf_ptr = s->inbuf + 4;
s->free_format_next_header = 0;
goto got_header;
}
VAR_5 = HEADER_SIZE - VAR_5;
if (VAR_5 > VAR_4)
VAR_5 = VAR_4;
else if (VAR_5 > 0) {
memcpy(s->inbuf_ptr, buf_ptr, VAR_5);
buf_ptr += VAR_5;
VAR_4 -= VAR_5;
s->inbuf_ptr += VAR_5;
}
if ((s->inbuf_ptr - s->inbuf) >= HEADER_SIZE) {
got_header:
header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
(s->inbuf[2] << 8) | s->inbuf[3];
if (check_header(header) < 0) {
memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf);
s->inbuf_ptr--;
dprintf("skip %x\n", header);
s->free_format_frame_size = 0;
} else {
if (decode_header(s, header) == 1) {
s->frame_size = -1;
memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf);
s->inbuf_ptr--;
} else {
VAR_0->sample_rate = s->sample_rate;
VAR_0->channels = s->nb_channels;
VAR_0->bit_rate = s->bit_rate;
}
}
}
} else if (s->frame_size == -1) {
VAR_5 = MPA_MAX_CODED_FRAME_SIZE - VAR_5;
if (VAR_5 > VAR_4)
VAR_5 = VAR_4;
if (VAR_5 == 0) {
s->frame_size = 0;
} else {
UINT8 *p, *pend;
UINT32 header1;
int VAR_8;
memcpy(s->inbuf_ptr, buf_ptr, VAR_5);
p = s->inbuf_ptr - 3;
pend = s->inbuf_ptr + VAR_5 - 4;
while (p <= pend) {
header = (p[0] << 24) | (p[1] << 16) |
(p[2] << 8) | p[3];
header1 = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
(s->inbuf[2] << 8) | s->inbuf[3];
if ((header & SAME_HEADER_MASK) ==
(header1 & SAME_HEADER_MASK)) {
VAR_5 = (p + 4) - s->inbuf_ptr;
buf_ptr += VAR_5;
VAR_4 -= VAR_5;
s->inbuf_ptr = p;
s->free_format_next_header = header;
s->free_format_frame_size = s->inbuf_ptr - s->inbuf;
VAR_8 = (header1 >> 9) & 1;
if (s->layer == 1)
s->free_format_frame_size -= VAR_8 * 4;
else
s->free_format_frame_size -= VAR_8;
dprintf("free frame size=%d VAR_8=%d\n",
s->free_format_frame_size, VAR_8);
decode_header(s, header1);
goto next_data;
}
p++;
}
buf_ptr += VAR_5;
s->inbuf_ptr += VAR_5;
VAR_4 -= VAR_5;
}
} else if (VAR_5 < s->frame_size) {
if (s->frame_size > MPA_MAX_CODED_FRAME_SIZE)
s->frame_size = MPA_MAX_CODED_FRAME_SIZE;
VAR_5 = s->frame_size - VAR_5;
if (VAR_5 > VAR_4)
VAR_5 = VAR_4;
else if (VAR_5 > 0)
{
memcpy(s->inbuf_ptr, buf_ptr, VAR_5);
buf_ptr += VAR_5;
s->inbuf_ptr += VAR_5;
VAR_4 -= VAR_5;
}
} else {
VAR_6 = mp_decode_frame(s, VAR_7);
s->inbuf_ptr = s->inbuf;
s->frame_size = 0;
*VAR_2 = VAR_6;
break;
}
next_data:
}
return buf_ptr - VAR_3;
}
|
[
"static int FUNC_0(AVCodecContext * VAR_0,\nvoid *VAR_1, int *VAR_2,\nUINT8 * VAR_3, int VAR_4)\n{",
"MPADecodeContext *s = VAR_0->priv_data;",
"UINT32 header;",
"UINT8 *buf_ptr;",
"int VAR_5, VAR_6;",
"short *VAR_7 = VAR_1;",
"*VAR_2 = 0;",
"buf_ptr = VAR_3;",
"while (VAR_4 > 0) {",
"VAR_5 = s->inbuf_ptr - s->inbuf;",
"if (s->frame_size == 0) {",
"if (s->free_format_next_header != 0) {",
"s->inbuf[0] = s->free_format_next_header >> 24;",
"s->inbuf[1] = s->free_format_next_header >> 16;",
"s->inbuf[2] = s->free_format_next_header >> 8;",
"s->inbuf[3] = s->free_format_next_header;",
"s->inbuf_ptr = s->inbuf + 4;",
"s->free_format_next_header = 0;",
"goto got_header;",
"}",
"VAR_5 = HEADER_SIZE - VAR_5;",
"if (VAR_5 > VAR_4)\nVAR_5 = VAR_4;",
"else if (VAR_5 > 0) {",
"memcpy(s->inbuf_ptr, buf_ptr, VAR_5);",
"buf_ptr += VAR_5;",
"VAR_4 -= VAR_5;",
"s->inbuf_ptr += VAR_5;",
"}",
"if ((s->inbuf_ptr - s->inbuf) >= HEADER_SIZE) {",
"got_header:\nheader = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |\n(s->inbuf[2] << 8) | s->inbuf[3];",
"if (check_header(header) < 0) {",
"memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf);",
"s->inbuf_ptr--;",
"dprintf(\"skip %x\\n\", header);",
"s->free_format_frame_size = 0;",
"} else {",
"if (decode_header(s, header) == 1) {",
"s->frame_size = -1;",
"memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf);",
"s->inbuf_ptr--;",
"} else {",
"VAR_0->sample_rate = s->sample_rate;",
"VAR_0->channels = s->nb_channels;",
"VAR_0->bit_rate = s->bit_rate;",
"}",
"}",
"}",
"} else if (s->frame_size == -1) {",
"VAR_5 = MPA_MAX_CODED_FRAME_SIZE - VAR_5;",
"if (VAR_5 > VAR_4)\nVAR_5 = VAR_4;",
"if (VAR_5 == 0) {",
"s->frame_size = 0;",
"} else {",
"UINT8 *p, *pend;",
"UINT32 header1;",
"int VAR_8;",
"memcpy(s->inbuf_ptr, buf_ptr, VAR_5);",
"p = s->inbuf_ptr - 3;",
"pend = s->inbuf_ptr + VAR_5 - 4;",
"while (p <= pend) {",
"header = (p[0] << 24) | (p[1] << 16) |\n(p[2] << 8) | p[3];",
"header1 = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |\n(s->inbuf[2] << 8) | s->inbuf[3];",
"if ((header & SAME_HEADER_MASK) ==\n(header1 & SAME_HEADER_MASK)) {",
"VAR_5 = (p + 4) - s->inbuf_ptr;",
"buf_ptr += VAR_5;",
"VAR_4 -= VAR_5;",
"s->inbuf_ptr = p;",
"s->free_format_next_header = header;",
"s->free_format_frame_size = s->inbuf_ptr - s->inbuf;",
"VAR_8 = (header1 >> 9) & 1;",
"if (s->layer == 1)\ns->free_format_frame_size -= VAR_8 * 4;",
"else\ns->free_format_frame_size -= VAR_8;",
"dprintf(\"free frame size=%d VAR_8=%d\\n\",\ns->free_format_frame_size, VAR_8);",
"decode_header(s, header1);",
"goto next_data;",
"}",
"p++;",
"}",
"buf_ptr += VAR_5;",
"s->inbuf_ptr += VAR_5;",
"VAR_4 -= VAR_5;",
"}",
"} else if (VAR_5 < s->frame_size) {",
"if (s->frame_size > MPA_MAX_CODED_FRAME_SIZE)\ns->frame_size = MPA_MAX_CODED_FRAME_SIZE;",
"VAR_5 = s->frame_size - VAR_5;",
"if (VAR_5 > VAR_4)\nVAR_5 = VAR_4;",
"else if (VAR_5 > 0)\n{",
"memcpy(s->inbuf_ptr, buf_ptr, VAR_5);",
"buf_ptr += VAR_5;",
"s->inbuf_ptr += VAR_5;",
"VAR_4 -= VAR_5;",
"}",
"} else {",
"VAR_6 = mp_decode_frame(s, VAR_7);",
"s->inbuf_ptr = s->inbuf;",
"s->frame_size = 0;",
"*VAR_2 = VAR_6;",
"break;",
"}",
"next_data:\n}",
"return buf_ptr - VAR_3;",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
79,
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133,
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
157
],
[
159
],
[
161
],
[
163,
165
],
[
167,
169
],
[
175,
177
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191
],
[
193
],
[
195
],
[
197,
199
],
[
201,
203
],
[
205,
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
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
]
] |
12,917
|
static int mpegps_read_seek(AVFormatContext *s,
int stream_index, int64_t timestamp)
{
int64_t pos_min, pos_max, pos;
int64_t dts_min, dts_max, dts;
timestamp = (timestamp * 90000) / AV_TIME_BASE;
#ifdef DEBUG_SEEK
printf("read_seek: %d %0.3f\n", stream_index, timestamp / 90000.0);
#endif
/* XXX: find stream_index by looking at the first PES packet found */
if (stream_index < 0) {
stream_index = find_stream_index(s);
if (stream_index < 0)
return -1;
}
pos_min = 0;
dts_min = mpegps_read_dts(s, stream_index, &pos_min, 1);
if (dts_min == AV_NOPTS_VALUE) {
/* we can reach this case only if no PTS are present in
the whole stream */
return -1;
}
pos_max = url_filesize(url_fileno(&s->pb)) - 1;
dts_max = mpegps_read_dts(s, stream_index, &pos_max, 0);
while (pos_min <= pos_max) {
#ifdef DEBUG_SEEK
printf("pos_min=0x%llx pos_max=0x%llx dts_min=%0.3f dts_max=%0.3f\n",
pos_min, pos_max,
dts_min / 90000.0, dts_max / 90000.0);
#endif
if (timestamp <= dts_min) {
pos = pos_min;
goto found;
} else if (timestamp >= dts_max) {
pos = pos_max;
goto found;
} else {
/* interpolate position (better than dichotomy) */
pos = (int64_t)((double)(pos_max - pos_min) *
(double)(timestamp - dts_min) /
(double)(dts_max - dts_min)) + pos_min;
}
#ifdef DEBUG_SEEK
printf("pos=0x%llx\n", pos);
#endif
/* read the next timestamp */
dts = mpegps_read_dts(s, stream_index, &pos, 1);
/* check if we are lucky */
if (dts == AV_NOPTS_VALUE) {
/* should never happen */
pos = pos_min;
goto found;
} else if (timestamp == dts) {
goto found;
} else if (timestamp < dts) {
pos_max = pos;
dts_max = mpegps_read_dts(s, stream_index, &pos_max, 0);
if (dts_max == AV_NOPTS_VALUE) {
/* should never happen */
break;
} else if (timestamp >= dts_max) {
pos = pos_max;
goto found;
}
} else {
pos_min = pos + 1;
dts_min = mpegps_read_dts(s, stream_index, &pos_min, 1);
if (dts_min == AV_NOPTS_VALUE) {
/* should never happen */
goto found;
} else if (timestamp <= dts_min) {
goto found;
}
}
}
pos = pos_min;
found:
#ifdef DEBUG_SEEK
pos_min = pos;
dts_min = mpegps_read_dts(s, stream_index, &pos_min, 1);
pos_min++;
dts_max = mpegps_read_dts(s, stream_index, &pos_min, 1);
printf("pos=0x%llx %0.3f<=%0.3f<=%0.3f\n",
pos, dts_min / 90000.0, timestamp / 90000.0, dts_max / 90000.0);
#endif
/* do the seek */
url_fseek(&s->pb, pos, SEEK_SET);
return 0;
}
| false
|
FFmpeg
|
b754978a3b0aa17e7794f64c69bf4491762797fd
|
static int mpegps_read_seek(AVFormatContext *s,
int stream_index, int64_t timestamp)
{
int64_t pos_min, pos_max, pos;
int64_t dts_min, dts_max, dts;
timestamp = (timestamp * 90000) / AV_TIME_BASE;
#ifdef DEBUG_SEEK
printf("read_seek: %d %0.3f\n", stream_index, timestamp / 90000.0);
#endif
if (stream_index < 0) {
stream_index = find_stream_index(s);
if (stream_index < 0)
return -1;
}
pos_min = 0;
dts_min = mpegps_read_dts(s, stream_index, &pos_min, 1);
if (dts_min == AV_NOPTS_VALUE) {
return -1;
}
pos_max = url_filesize(url_fileno(&s->pb)) - 1;
dts_max = mpegps_read_dts(s, stream_index, &pos_max, 0);
while (pos_min <= pos_max) {
#ifdef DEBUG_SEEK
printf("pos_min=0x%llx pos_max=0x%llx dts_min=%0.3f dts_max=%0.3f\n",
pos_min, pos_max,
dts_min / 90000.0, dts_max / 90000.0);
#endif
if (timestamp <= dts_min) {
pos = pos_min;
goto found;
} else if (timestamp >= dts_max) {
pos = pos_max;
goto found;
} else {
pos = (int64_t)((double)(pos_max - pos_min) *
(double)(timestamp - dts_min) /
(double)(dts_max - dts_min)) + pos_min;
}
#ifdef DEBUG_SEEK
printf("pos=0x%llx\n", pos);
#endif
dts = mpegps_read_dts(s, stream_index, &pos, 1);
if (dts == AV_NOPTS_VALUE) {
pos = pos_min;
goto found;
} else if (timestamp == dts) {
goto found;
} else if (timestamp < dts) {
pos_max = pos;
dts_max = mpegps_read_dts(s, stream_index, &pos_max, 0);
if (dts_max == AV_NOPTS_VALUE) {
break;
} else if (timestamp >= dts_max) {
pos = pos_max;
goto found;
}
} else {
pos_min = pos + 1;
dts_min = mpegps_read_dts(s, stream_index, &pos_min, 1);
if (dts_min == AV_NOPTS_VALUE) {
goto found;
} else if (timestamp <= dts_min) {
goto found;
}
}
}
pos = pos_min;
found:
#ifdef DEBUG_SEEK
pos_min = pos;
dts_min = mpegps_read_dts(s, stream_index, &pos_min, 1);
pos_min++;
dts_max = mpegps_read_dts(s, stream_index, &pos_min, 1);
printf("pos=0x%llx %0.3f<=%0.3f<=%0.3f\n",
pos, dts_min / 90000.0, timestamp / 90000.0, dts_max / 90000.0);
#endif
url_fseek(&s->pb, pos, SEEK_SET);
return 0;
}
|
{
"code": [],
"line_no": []
}
|
static int FUNC_0(AVFormatContext *VAR_0,
int VAR_1, int64_t VAR_2)
{
int64_t pos_min, pos_max, pos;
int64_t dts_min, dts_max, dts;
VAR_2 = (VAR_2 * 90000) / AV_TIME_BASE;
#ifdef DEBUG_SEEK
printf("read_seek: %d %0.3f\n", VAR_1, VAR_2 / 90000.0);
#endif
if (VAR_1 < 0) {
VAR_1 = find_stream_index(VAR_0);
if (VAR_1 < 0)
return -1;
}
pos_min = 0;
dts_min = mpegps_read_dts(VAR_0, VAR_1, &pos_min, 1);
if (dts_min == AV_NOPTS_VALUE) {
return -1;
}
pos_max = url_filesize(url_fileno(&VAR_0->pb)) - 1;
dts_max = mpegps_read_dts(VAR_0, VAR_1, &pos_max, 0);
while (pos_min <= pos_max) {
#ifdef DEBUG_SEEK
printf("pos_min=0x%llx pos_max=0x%llx dts_min=%0.3f dts_max=%0.3f\n",
pos_min, pos_max,
dts_min / 90000.0, dts_max / 90000.0);
#endif
if (VAR_2 <= dts_min) {
pos = pos_min;
goto found;
} else if (VAR_2 >= dts_max) {
pos = pos_max;
goto found;
} else {
pos = (int64_t)((double)(pos_max - pos_min) *
(double)(VAR_2 - dts_min) /
(double)(dts_max - dts_min)) + pos_min;
}
#ifdef DEBUG_SEEK
printf("pos=0x%llx\n", pos);
#endif
dts = mpegps_read_dts(VAR_0, VAR_1, &pos, 1);
if (dts == AV_NOPTS_VALUE) {
pos = pos_min;
goto found;
} else if (VAR_2 == dts) {
goto found;
} else if (VAR_2 < dts) {
pos_max = pos;
dts_max = mpegps_read_dts(VAR_0, VAR_1, &pos_max, 0);
if (dts_max == AV_NOPTS_VALUE) {
break;
} else if (VAR_2 >= dts_max) {
pos = pos_max;
goto found;
}
} else {
pos_min = pos + 1;
dts_min = mpegps_read_dts(VAR_0, VAR_1, &pos_min, 1);
if (dts_min == AV_NOPTS_VALUE) {
goto found;
} else if (VAR_2 <= dts_min) {
goto found;
}
}
}
pos = pos_min;
found:
#ifdef DEBUG_SEEK
pos_min = pos;
dts_min = mpegps_read_dts(VAR_0, VAR_1, &pos_min, 1);
pos_min++;
dts_max = mpegps_read_dts(VAR_0, VAR_1, &pos_min, 1);
printf("pos=0x%llx %0.3f<=%0.3f<=%0.3f\n",
pos, dts_min / 90000.0, VAR_2 / 90000.0, dts_max / 90000.0);
#endif
url_fseek(&VAR_0->pb, pos, SEEK_SET);
return 0;
}
|
[
"static int FUNC_0(AVFormatContext *VAR_0,\nint VAR_1, int64_t VAR_2)\n{",
"int64_t pos_min, pos_max, pos;",
"int64_t dts_min, dts_max, dts;",
"VAR_2 = (VAR_2 * 90000) / AV_TIME_BASE;",
"#ifdef DEBUG_SEEK\nprintf(\"read_seek: %d %0.3f\\n\", VAR_1, VAR_2 / 90000.0);",
"#endif\nif (VAR_1 < 0) {",
"VAR_1 = find_stream_index(VAR_0);",
"if (VAR_1 < 0)\nreturn -1;",
"}",
"pos_min = 0;",
"dts_min = mpegps_read_dts(VAR_0, VAR_1, &pos_min, 1);",
"if (dts_min == AV_NOPTS_VALUE) {",
"return -1;",
"}",
"pos_max = url_filesize(url_fileno(&VAR_0->pb)) - 1;",
"dts_max = mpegps_read_dts(VAR_0, VAR_1, &pos_max, 0);",
"while (pos_min <= pos_max) {",
"#ifdef DEBUG_SEEK\nprintf(\"pos_min=0x%llx pos_max=0x%llx dts_min=%0.3f dts_max=%0.3f\\n\",\npos_min, pos_max,\ndts_min / 90000.0, dts_max / 90000.0);",
"#endif\nif (VAR_2 <= dts_min) {",
"pos = pos_min;",
"goto found;",
"} else if (VAR_2 >= dts_max) {",
"pos = pos_max;",
"goto found;",
"} else {",
"pos = (int64_t)((double)(pos_max - pos_min) *\n(double)(VAR_2 - dts_min) /\n(double)(dts_max - dts_min)) + pos_min;",
"}",
"#ifdef DEBUG_SEEK\nprintf(\"pos=0x%llx\\n\", pos);",
"#endif\ndts = mpegps_read_dts(VAR_0, VAR_1, &pos, 1);",
"if (dts == AV_NOPTS_VALUE) {",
"pos = pos_min;",
"goto found;",
"} else if (VAR_2 == dts) {",
"goto found;",
"} else if (VAR_2 < dts) {",
"pos_max = pos;",
"dts_max = mpegps_read_dts(VAR_0, VAR_1, &pos_max, 0);",
"if (dts_max == AV_NOPTS_VALUE) {",
"break;",
"} else if (VAR_2 >= dts_max) {",
"pos = pos_max;",
"goto found;",
"}",
"} else {",
"pos_min = pos + 1;",
"dts_min = mpegps_read_dts(VAR_0, VAR_1, &pos_min, 1);",
"if (dts_min == AV_NOPTS_VALUE) {",
"goto found;",
"} else if (VAR_2 <= dts_min) {",
"goto found;",
"}",
"}",
"}",
"pos = pos_min;",
"found:\n#ifdef DEBUG_SEEK\npos_min = pos;",
"dts_min = mpegps_read_dts(VAR_0, VAR_1, &pos_min, 1);",
"pos_min++;",
"dts_max = mpegps_read_dts(VAR_0, VAR_1, &pos_min, 1);",
"printf(\"pos=0x%llx %0.3f<=%0.3f<=%0.3f\\n\",\npos, dts_min / 90000.0, VAR_2 / 90000.0, dts_max / 90000.0);",
"#endif\nurl_fseek(&VAR_0->pb, pos, SEEK_SET);",
"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
] |
[
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17,
19
],
[
21,
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59,
61,
63,
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85,
87,
89
],
[
91
],
[
93,
95
],
[
97,
101
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161,
163,
165
],
[
167
],
[
169
],
[
171
],
[
173,
175
],
[
177,
181
],
[
183
],
[
185
]
] |
12,918
|
static void dxva2_uninit(AVCodecContext *s)
{
InputStream *ist = s->opaque;
DXVA2Context *ctx = ist->hwaccel_ctx;
ist->hwaccel_uninit = NULL;
ist->hwaccel_get_buffer = NULL;
ist->hwaccel_retrieve_data = NULL;
if (ctx->decoder_service)
IDirectXVideoDecoderService_Release(ctx->decoder_service);
av_buffer_unref(&ctx->hw_frames_ctx);
av_buffer_unref(&ctx->hw_device_ctx);
av_frame_free(&ctx->tmp_frame);
av_freep(&ist->hwaccel_ctx);
av_freep(&s->hwaccel_context);
}
| false
|
FFmpeg
|
70143a3954e1c4412efb2bf1a3a818adea2d3abf
|
static void dxva2_uninit(AVCodecContext *s)
{
InputStream *ist = s->opaque;
DXVA2Context *ctx = ist->hwaccel_ctx;
ist->hwaccel_uninit = NULL;
ist->hwaccel_get_buffer = NULL;
ist->hwaccel_retrieve_data = NULL;
if (ctx->decoder_service)
IDirectXVideoDecoderService_Release(ctx->decoder_service);
av_buffer_unref(&ctx->hw_frames_ctx);
av_buffer_unref(&ctx->hw_device_ctx);
av_frame_free(&ctx->tmp_frame);
av_freep(&ist->hwaccel_ctx);
av_freep(&s->hwaccel_context);
}
|
{
"code": [],
"line_no": []
}
|
static void FUNC_0(AVCodecContext *VAR_0)
{
InputStream *ist = VAR_0->opaque;
DXVA2Context *ctx = ist->hwaccel_ctx;
ist->hwaccel_uninit = NULL;
ist->hwaccel_get_buffer = NULL;
ist->hwaccel_retrieve_data = NULL;
if (ctx->decoder_service)
IDirectXVideoDecoderService_Release(ctx->decoder_service);
av_buffer_unref(&ctx->hw_frames_ctx);
av_buffer_unref(&ctx->hw_device_ctx);
av_frame_free(&ctx->tmp_frame);
av_freep(&ist->hwaccel_ctx);
av_freep(&VAR_0->hwaccel_context);
}
|
[
"static void FUNC_0(AVCodecContext *VAR_0)\n{",
"InputStream *ist = VAR_0->opaque;",
"DXVA2Context *ctx = ist->hwaccel_ctx;",
"ist->hwaccel_uninit = NULL;",
"ist->hwaccel_get_buffer = NULL;",
"ist->hwaccel_retrieve_data = NULL;",
"if (ctx->decoder_service)\nIDirectXVideoDecoderService_Release(ctx->decoder_service);",
"av_buffer_unref(&ctx->hw_frames_ctx);",
"av_buffer_unref(&ctx->hw_device_ctx);",
"av_frame_free(&ctx->tmp_frame);",
"av_freep(&ist->hwaccel_ctx);",
"av_freep(&VAR_0->hwaccel_context);",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
25
],
[
27
],
[
31
],
[
35
],
[
37
],
[
39
]
] |
12,919
|
static av_cold int xvid_encode_close(AVCodecContext *avctx)
{
struct xvid_context *x = avctx->priv_data;
if (x->encoder_handle) {
xvid_encore(x->encoder_handle, XVID_ENC_DESTROY, NULL, NULL);
x->encoder_handle = NULL;
}
av_frame_free(&avctx->coded_frame);
av_freep(&avctx->extradata);
if (x->twopassbuffer) {
av_free(x->twopassbuffer);
av_free(x->old_twopassbuffer);
}
av_free(x->twopassfile);
av_free(x->intra_matrix);
av_free(x->inter_matrix);
return 0;
}
| false
|
FFmpeg
|
d6604b29ef544793479d7fb4e05ef6622bb3e534
|
static av_cold int xvid_encode_close(AVCodecContext *avctx)
{
struct xvid_context *x = avctx->priv_data;
if (x->encoder_handle) {
xvid_encore(x->encoder_handle, XVID_ENC_DESTROY, NULL, NULL);
x->encoder_handle = NULL;
}
av_frame_free(&avctx->coded_frame);
av_freep(&avctx->extradata);
if (x->twopassbuffer) {
av_free(x->twopassbuffer);
av_free(x->old_twopassbuffer);
}
av_free(x->twopassfile);
av_free(x->intra_matrix);
av_free(x->inter_matrix);
return 0;
}
|
{
"code": [],
"line_no": []
}
|
static av_cold int FUNC_0(AVCodecContext *avctx)
{
struct xvid_context *VAR_0 = avctx->priv_data;
if (VAR_0->encoder_handle) {
xvid_encore(VAR_0->encoder_handle, XVID_ENC_DESTROY, NULL, NULL);
VAR_0->encoder_handle = NULL;
}
av_frame_free(&avctx->coded_frame);
av_freep(&avctx->extradata);
if (VAR_0->twopassbuffer) {
av_free(VAR_0->twopassbuffer);
av_free(VAR_0->old_twopassbuffer);
}
av_free(VAR_0->twopassfile);
av_free(VAR_0->intra_matrix);
av_free(VAR_0->inter_matrix);
return 0;
}
|
[
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"struct xvid_context *VAR_0 = avctx->priv_data;",
"if (VAR_0->encoder_handle) {",
"xvid_encore(VAR_0->encoder_handle, XVID_ENC_DESTROY, NULL, NULL);",
"VAR_0->encoder_handle = NULL;",
"}",
"av_frame_free(&avctx->coded_frame);",
"av_freep(&avctx->extradata);",
"if (VAR_0->twopassbuffer) {",
"av_free(VAR_0->twopassbuffer);",
"av_free(VAR_0->old_twopassbuffer);",
"}",
"av_free(VAR_0->twopassfile);",
"av_free(VAR_0->intra_matrix);",
"av_free(VAR_0->inter_matrix);",
"return 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
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
]
] |
12,920
|
static void single_quote_string(void)
{
int i;
struct {
const char *encoded;
const char *decoded;
} test_cases[] = {
{ "'hello world'", "hello world" },
{ "'the quick brown fox \\' jumped over the fence'",
"the quick brown fox ' jumped over the fence" },
{}
};
for (i = 0; test_cases[i].encoded; i++) {
QObject *obj;
QString *str;
obj = qobject_from_json(test_cases[i].encoded, NULL);
str = qobject_to_qstring(obj);
g_assert(str);
g_assert(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0);
QDECREF(str);
}
}
| true
|
qemu
|
aec4b054ea36c53c8b887da99f20010133b84378
|
static void single_quote_string(void)
{
int i;
struct {
const char *encoded;
const char *decoded;
} test_cases[] = {
{ "'hello world'", "hello world" },
{ "'the quick brown fox \\' jumped over the fence'",
"the quick brown fox ' jumped over the fence" },
{}
};
for (i = 0; test_cases[i].encoded; i++) {
QObject *obj;
QString *str;
obj = qobject_from_json(test_cases[i].encoded, NULL);
str = qobject_to_qstring(obj);
g_assert(str);
g_assert(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0);
QDECREF(str);
}
}
|
{
"code": [
" obj = qobject_from_json(test_cases[i].encoded, NULL);",
" obj = qobject_from_json(test_cases[i].encoded, NULL);",
" obj = qobject_from_json(test_cases[i].encoded, NULL);",
" obj = qobject_from_json(test_cases[i].encoded, NULL);",
" obj = qobject_from_json(test_cases[i].encoded, NULL);",
" obj = qobject_from_json(test_cases[i].encoded, NULL);",
" obj = qobject_from_json(test_cases[i].encoded, NULL);"
],
"line_no": [
35,
35,
35,
35,
35,
35,
35
]
}
|
static void FUNC_0(void)
{
int VAR_0;
struct {
const char *encoded;
const char *decoded;
} VAR_1[] = {
{ "'hello world'", "hello world" },
{ "'the quick brown fox \\' jumped over the fence'",
"the quick brown fox ' jumped over the fence" },
{}
};
for (VAR_0 = 0; VAR_1[VAR_0].encoded; VAR_0++) {
QObject *obj;
QString *str;
obj = qobject_from_json(VAR_1[VAR_0].encoded, NULL);
str = qobject_to_qstring(obj);
g_assert(str);
g_assert(strcmp(qstring_get_str(str), VAR_1[VAR_0].decoded) == 0);
QDECREF(str);
}
}
|
[
"static void FUNC_0(void)\n{",
"int VAR_0;",
"struct {",
"const char *encoded;",
"const char *decoded;",
"} VAR_1[] = {",
"{ \"'hello world'\", \"hello world\" },",
"{ \"'the quick brown fox \\\\' jumped over the fence'\",",
"\"the quick brown fox ' jumped over the fence\" },",
"{}",
"};",
"for (VAR_0 = 0; VAR_1[VAR_0].encoded; VAR_0++) {",
"QObject *obj;",
"QString *str;",
"obj = qobject_from_json(VAR_1[VAR_0].encoded, NULL);",
"str = qobject_to_qstring(obj);",
"g_assert(str);",
"g_assert(strcmp(qstring_get_str(str), VAR_1[VAR_0].decoded) == 0);",
"QDECREF(str);",
"}",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
]
] |
12,922
|
static void calculate_code_lengths(uint8_t *lengths, uint32_t *counts)
{
uint32_t nr_nodes, nr_heap, node1, node2;
int i, j;
int32_t k;
/* Heap and node entries start from 1 */
uint32_t weights[512];
uint32_t heap[512];
int32_t parents[512];
/* Set initial weights */
for (i = 0; i < 256; i++)
weights[i + 1] = (counts[i] ? counts[i] : 1) << 8;
nr_nodes = 256;
nr_heap = 0;
heap[0] = 0;
weights[0] = 0;
parents[0] = -2;
/* Create initial nodes */
for (i = 1; i <= 256; i++) {
parents[i] = -1;
heap[++nr_heap] = i;
up_heap(nr_heap, heap, weights);
}
/* Build the tree */
while (nr_heap > 1) {
node1 = heap[1];
heap[1] = heap[nr_heap--];
down_heap(nr_heap, heap, weights);
node2 = heap[1];
heap[1] = heap[nr_heap--];
down_heap(nr_heap, heap, weights);
nr_nodes++;
parents[node1] = parents[node2] = nr_nodes;
weights[nr_nodes] = add_weights(weights[node1], weights[node2]);
parents[nr_nodes] = -1;
heap[++nr_heap] = nr_nodes;
up_heap(nr_heap, heap, weights);
}
/* Generate lengths */
for (i = 1; i <= 256; i++) {
j = 0;
k = i;
while (parents[k] >= 0) {
k = parents[k];
j++;
}
lengths[i - 1] = j;
}
}
| true
|
FFmpeg
|
f92f4935acd7d974adfd1deebdf1bb06cbe107ca
|
static void calculate_code_lengths(uint8_t *lengths, uint32_t *counts)
{
uint32_t nr_nodes, nr_heap, node1, node2;
int i, j;
int32_t k;
uint32_t weights[512];
uint32_t heap[512];
int32_t parents[512];
for (i = 0; i < 256; i++)
weights[i + 1] = (counts[i] ? counts[i] : 1) << 8;
nr_nodes = 256;
nr_heap = 0;
heap[0] = 0;
weights[0] = 0;
parents[0] = -2;
for (i = 1; i <= 256; i++) {
parents[i] = -1;
heap[++nr_heap] = i;
up_heap(nr_heap, heap, weights);
}
while (nr_heap > 1) {
node1 = heap[1];
heap[1] = heap[nr_heap--];
down_heap(nr_heap, heap, weights);
node2 = heap[1];
heap[1] = heap[nr_heap--];
down_heap(nr_heap, heap, weights);
nr_nodes++;
parents[node1] = parents[node2] = nr_nodes;
weights[nr_nodes] = add_weights(weights[node1], weights[node2]);
parents[nr_nodes] = -1;
heap[++nr_heap] = nr_nodes;
up_heap(nr_heap, heap, weights);
}
for (i = 1; i <= 256; i++) {
j = 0;
k = i;
while (parents[k] >= 0) {
k = parents[k];
j++;
}
lengths[i - 1] = j;
}
}
|
{
"code": [
"static void calculate_code_lengths(uint8_t *lengths, uint32_t *counts)",
" uint32_t nr_nodes, nr_heap, node1, node2;",
" int i, j;",
" int32_t k;",
" uint32_t weights[512];",
" uint32_t heap[512];",
" int32_t parents[512];",
" for (i = 0; i < 256; i++)",
" weights[i + 1] = (counts[i] ? counts[i] : 1) << 8;",
" nr_nodes = 256;",
" nr_heap = 0;",
" heap[0] = 0;",
" weights[0] = 0;",
" parents[0] = -2;",
" for (i = 1; i <= 256; i++) {",
" parents[i] = -1;",
" heap[++nr_heap] = i;",
" up_heap(nr_heap, heap, weights);",
" while (nr_heap > 1) {",
" node1 = heap[1];",
" heap[1] = heap[nr_heap--];",
" down_heap(nr_heap, heap, weights);",
" node2 = heap[1];",
" heap[1] = heap[nr_heap--];",
" down_heap(nr_heap, heap, weights);",
" nr_nodes++;",
" parents[node1] = parents[node2] = nr_nodes;",
" weights[nr_nodes] = add_weights(weights[node1], weights[node2]);",
" parents[nr_nodes] = -1;",
" heap[++nr_heap] = nr_nodes;",
" up_heap(nr_heap, heap, weights);",
" for (i = 1; i <= 256; i++) {",
" j = 0;",
" k = i;",
" while (parents[k] >= 0) {",
" k = parents[k];",
" j++;",
" lengths[i - 1] = j;"
],
"line_no": [
1,
5,
7,
9,
15,
17,
19,
25,
27,
31,
33,
37,
39,
41,
47,
49,
53,
55,
63,
65,
67,
71,
75,
67,
71,
85,
89,
91,
93,
97,
55,
47,
111,
113,
117,
119,
121,
127
]
}
|
static void FUNC_0(uint8_t *VAR_0, uint32_t *VAR_1)
{
uint32_t nr_nodes, nr_heap, node1, node2;
int VAR_2, VAR_3;
int32_t k;
uint32_t weights[512];
uint32_t heap[512];
int32_t parents[512];
for (VAR_2 = 0; VAR_2 < 256; VAR_2++)
weights[VAR_2 + 1] = (VAR_1[VAR_2] ? VAR_1[VAR_2] : 1) << 8;
nr_nodes = 256;
nr_heap = 0;
heap[0] = 0;
weights[0] = 0;
parents[0] = -2;
for (VAR_2 = 1; VAR_2 <= 256; VAR_2++) {
parents[VAR_2] = -1;
heap[++nr_heap] = VAR_2;
up_heap(nr_heap, heap, weights);
}
while (nr_heap > 1) {
node1 = heap[1];
heap[1] = heap[nr_heap--];
down_heap(nr_heap, heap, weights);
node2 = heap[1];
heap[1] = heap[nr_heap--];
down_heap(nr_heap, heap, weights);
nr_nodes++;
parents[node1] = parents[node2] = nr_nodes;
weights[nr_nodes] = add_weights(weights[node1], weights[node2]);
parents[nr_nodes] = -1;
heap[++nr_heap] = nr_nodes;
up_heap(nr_heap, heap, weights);
}
for (VAR_2 = 1; VAR_2 <= 256; VAR_2++) {
VAR_3 = 0;
k = VAR_2;
while (parents[k] >= 0) {
k = parents[k];
VAR_3++;
}
VAR_0[VAR_2 - 1] = VAR_3;
}
}
|
[
"static void FUNC_0(uint8_t *VAR_0, uint32_t *VAR_1)\n{",
"uint32_t nr_nodes, nr_heap, node1, node2;",
"int VAR_2, VAR_3;",
"int32_t k;",
"uint32_t weights[512];",
"uint32_t heap[512];",
"int32_t parents[512];",
"for (VAR_2 = 0; VAR_2 < 256; VAR_2++)",
"weights[VAR_2 + 1] = (VAR_1[VAR_2] ? VAR_1[VAR_2] : 1) << 8;",
"nr_nodes = 256;",
"nr_heap = 0;",
"heap[0] = 0;",
"weights[0] = 0;",
"parents[0] = -2;",
"for (VAR_2 = 1; VAR_2 <= 256; VAR_2++) {",
"parents[VAR_2] = -1;",
"heap[++nr_heap] = VAR_2;",
"up_heap(nr_heap, heap, weights);",
"}",
"while (nr_heap > 1) {",
"node1 = heap[1];",
"heap[1] = heap[nr_heap--];",
"down_heap(nr_heap, heap, weights);",
"node2 = heap[1];",
"heap[1] = heap[nr_heap--];",
"down_heap(nr_heap, heap, weights);",
"nr_nodes++;",
"parents[node1] = parents[node2] = nr_nodes;",
"weights[nr_nodes] = add_weights(weights[node1], weights[node2]);",
"parents[nr_nodes] = -1;",
"heap[++nr_heap] = nr_nodes;",
"up_heap(nr_heap, heap, weights);",
"}",
"for (VAR_2 = 1; VAR_2 <= 256; VAR_2++) {",
"VAR_3 = 0;",
"k = VAR_2;",
"while (parents[k] >= 0) {",
"k = parents[k];",
"VAR_3++;",
"}",
"VAR_0[VAR_2 - 1] = VAR_3;",
"}",
"}"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
0,
0,
1,
1,
1,
1,
1,
0,
0,
0,
1,
1,
1,
1,
1,
0,
1,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
19
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
63
],
[
65
],
[
67
],
[
71
],
[
75
],
[
77
],
[
81
],
[
85
],
[
89
],
[
91
],
[
93
],
[
97
],
[
101
],
[
103
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
]
] |
12,923
|
static av_always_inline void autocorrelate(const int x[40][2], SoftFloat phi[3][2][2], int lag)
{
int i;
int64_t real_sum, imag_sum;
int64_t accu_re = 0, accu_im = 0;
if (lag) {
for (i = 1; i < 38; i++) {
accu_re += (int64_t)x[i][0] * x[i+lag][0];
accu_re += (int64_t)x[i][1] * x[i+lag][1];
accu_im += (int64_t)x[i][0] * x[i+lag][1];
accu_im -= (int64_t)x[i][1] * x[i+lag][0];
}
real_sum = accu_re;
imag_sum = accu_im;
accu_re += (int64_t)x[ 0][0] * x[lag][0];
accu_re += (int64_t)x[ 0][1] * x[lag][1];
accu_im += (int64_t)x[ 0][0] * x[lag][1];
accu_im -= (int64_t)x[ 0][1] * x[lag][0];
phi[2-lag][1][0] = autocorr_calc(accu_re);
phi[2-lag][1][1] = autocorr_calc(accu_im);
if (lag == 1) {
accu_re = real_sum;
accu_im = imag_sum;
accu_re += (int64_t)x[38][0] * x[39][0];
accu_re += (int64_t)x[38][1] * x[39][1];
accu_im += (int64_t)x[38][0] * x[39][1];
accu_im -= (int64_t)x[38][1] * x[39][0];
phi[0][0][0] = autocorr_calc(accu_re);
phi[0][0][1] = autocorr_calc(accu_im);
}
} else {
for (i = 1; i < 38; i++) {
accu_re += (int64_t)x[i][0] * x[i][0];
accu_re += (int64_t)x[i][1] * x[i][1];
}
real_sum = accu_re;
accu_re += (int64_t)x[ 0][0] * x[ 0][0];
accu_re += (int64_t)x[ 0][1] * x[ 0][1];
phi[2][1][0] = autocorr_calc(accu_re);
accu_re = real_sum;
accu_re += (int64_t)x[38][0] * x[38][0];
accu_re += (int64_t)x[38][1] * x[38][1];
phi[1][0][0] = autocorr_calc(accu_re);
}
}
| true
|
FFmpeg
|
eefb68c9c335dda423c9115ba11dc4bb3e73e3f9
|
static av_always_inline void autocorrelate(const int x[40][2], SoftFloat phi[3][2][2], int lag)
{
int i;
int64_t real_sum, imag_sum;
int64_t accu_re = 0, accu_im = 0;
if (lag) {
for (i = 1; i < 38; i++) {
accu_re += (int64_t)x[i][0] * x[i+lag][0];
accu_re += (int64_t)x[i][1] * x[i+lag][1];
accu_im += (int64_t)x[i][0] * x[i+lag][1];
accu_im -= (int64_t)x[i][1] * x[i+lag][0];
}
real_sum = accu_re;
imag_sum = accu_im;
accu_re += (int64_t)x[ 0][0] * x[lag][0];
accu_re += (int64_t)x[ 0][1] * x[lag][1];
accu_im += (int64_t)x[ 0][0] * x[lag][1];
accu_im -= (int64_t)x[ 0][1] * x[lag][0];
phi[2-lag][1][0] = autocorr_calc(accu_re);
phi[2-lag][1][1] = autocorr_calc(accu_im);
if (lag == 1) {
accu_re = real_sum;
accu_im = imag_sum;
accu_re += (int64_t)x[38][0] * x[39][0];
accu_re += (int64_t)x[38][1] * x[39][1];
accu_im += (int64_t)x[38][0] * x[39][1];
accu_im -= (int64_t)x[38][1] * x[39][0];
phi[0][0][0] = autocorr_calc(accu_re);
phi[0][0][1] = autocorr_calc(accu_im);
}
} else {
for (i = 1; i < 38; i++) {
accu_re += (int64_t)x[i][0] * x[i][0];
accu_re += (int64_t)x[i][1] * x[i][1];
}
real_sum = accu_re;
accu_re += (int64_t)x[ 0][0] * x[ 0][0];
accu_re += (int64_t)x[ 0][1] * x[ 0][1];
phi[2][1][0] = autocorr_calc(accu_re);
accu_re = real_sum;
accu_re += (int64_t)x[38][0] * x[38][0];
accu_re += (int64_t)x[38][1] * x[38][1];
phi[1][0][0] = autocorr_calc(accu_re);
}
}
|
{
"code": [
" accu_re += (int64_t)x[i][0] * x[i+lag][0];",
" accu_re += (int64_t)x[i][1] * x[i+lag][1];",
" accu_im += (int64_t)x[i][0] * x[i+lag][1];",
" accu_im -= (int64_t)x[i][1] * x[i+lag][0];",
" accu_re += (int64_t)x[ 0][0] * x[lag][0];",
" accu_re += (int64_t)x[ 0][1] * x[lag][1];",
" accu_im += (int64_t)x[ 0][0] * x[lag][1];",
" accu_im -= (int64_t)x[ 0][1] * x[lag][0];",
" accu_re += (int64_t)x[38][0] * x[39][0];",
" accu_re += (int64_t)x[38][1] * x[39][1];",
" accu_im += (int64_t)x[38][0] * x[39][1];",
" accu_im -= (int64_t)x[38][1] * x[39][0];",
" accu_re += (int64_t)x[i][0] * x[i][0];",
" accu_re += (int64_t)x[i][1] * x[i][1];",
" accu_re += (int64_t)x[ 0][0] * x[ 0][0];",
" accu_re += (int64_t)x[ 0][1] * x[ 0][1];",
" accu_re += (int64_t)x[38][0] * x[38][0];",
" accu_re += (int64_t)x[38][1] * x[38][1];"
],
"line_no": [
17,
19,
21,
23,
35,
37,
39,
41,
57,
59,
61,
63,
77,
79,
85,
87,
97,
99
]
}
|
static av_always_inline void FUNC_0(const int x[40][2], SoftFloat phi[3][2][2], int lag)
{
int VAR_0;
int64_t real_sum, imag_sum;
int64_t accu_re = 0, accu_im = 0;
if (lag) {
for (VAR_0 = 1; VAR_0 < 38; VAR_0++) {
accu_re += (int64_t)x[VAR_0][0] * x[VAR_0+lag][0];
accu_re += (int64_t)x[VAR_0][1] * x[VAR_0+lag][1];
accu_im += (int64_t)x[VAR_0][0] * x[VAR_0+lag][1];
accu_im -= (int64_t)x[VAR_0][1] * x[VAR_0+lag][0];
}
real_sum = accu_re;
imag_sum = accu_im;
accu_re += (int64_t)x[ 0][0] * x[lag][0];
accu_re += (int64_t)x[ 0][1] * x[lag][1];
accu_im += (int64_t)x[ 0][0] * x[lag][1];
accu_im -= (int64_t)x[ 0][1] * x[lag][0];
phi[2-lag][1][0] = autocorr_calc(accu_re);
phi[2-lag][1][1] = autocorr_calc(accu_im);
if (lag == 1) {
accu_re = real_sum;
accu_im = imag_sum;
accu_re += (int64_t)x[38][0] * x[39][0];
accu_re += (int64_t)x[38][1] * x[39][1];
accu_im += (int64_t)x[38][0] * x[39][1];
accu_im -= (int64_t)x[38][1] * x[39][0];
phi[0][0][0] = autocorr_calc(accu_re);
phi[0][0][1] = autocorr_calc(accu_im);
}
} else {
for (VAR_0 = 1; VAR_0 < 38; VAR_0++) {
accu_re += (int64_t)x[VAR_0][0] * x[VAR_0][0];
accu_re += (int64_t)x[VAR_0][1] * x[VAR_0][1];
}
real_sum = accu_re;
accu_re += (int64_t)x[ 0][0] * x[ 0][0];
accu_re += (int64_t)x[ 0][1] * x[ 0][1];
phi[2][1][0] = autocorr_calc(accu_re);
accu_re = real_sum;
accu_re += (int64_t)x[38][0] * x[38][0];
accu_re += (int64_t)x[38][1] * x[38][1];
phi[1][0][0] = autocorr_calc(accu_re);
}
}
|
[
"static av_always_inline void FUNC_0(const int x[40][2], SoftFloat phi[3][2][2], int lag)\n{",
"int VAR_0;",
"int64_t real_sum, imag_sum;",
"int64_t accu_re = 0, accu_im = 0;",
"if (lag) {",
"for (VAR_0 = 1; VAR_0 < 38; VAR_0++) {",
"accu_re += (int64_t)x[VAR_0][0] * x[VAR_0+lag][0];",
"accu_re += (int64_t)x[VAR_0][1] * x[VAR_0+lag][1];",
"accu_im += (int64_t)x[VAR_0][0] * x[VAR_0+lag][1];",
"accu_im -= (int64_t)x[VAR_0][1] * x[VAR_0+lag][0];",
"}",
"real_sum = accu_re;",
"imag_sum = accu_im;",
"accu_re += (int64_t)x[ 0][0] * x[lag][0];",
"accu_re += (int64_t)x[ 0][1] * x[lag][1];",
"accu_im += (int64_t)x[ 0][0] * x[lag][1];",
"accu_im -= (int64_t)x[ 0][1] * x[lag][0];",
"phi[2-lag][1][0] = autocorr_calc(accu_re);",
"phi[2-lag][1][1] = autocorr_calc(accu_im);",
"if (lag == 1) {",
"accu_re = real_sum;",
"accu_im = imag_sum;",
"accu_re += (int64_t)x[38][0] * x[39][0];",
"accu_re += (int64_t)x[38][1] * x[39][1];",
"accu_im += (int64_t)x[38][0] * x[39][1];",
"accu_im -= (int64_t)x[38][1] * x[39][0];",
"phi[0][0][0] = autocorr_calc(accu_re);",
"phi[0][0][1] = autocorr_calc(accu_im);",
"}",
"} else {",
"for (VAR_0 = 1; VAR_0 < 38; VAR_0++) {",
"accu_re += (int64_t)x[VAR_0][0] * x[VAR_0][0];",
"accu_re += (int64_t)x[VAR_0][1] * x[VAR_0][1];",
"}",
"real_sum = accu_re;",
"accu_re += (int64_t)x[ 0][0] * x[ 0][0];",
"accu_re += (int64_t)x[ 0][1] * x[ 0][1];",
"phi[2][1][0] = autocorr_calc(accu_re);",
"accu_re = real_sum;",
"accu_re += (int64_t)x[38][0] * x[38][0];",
"accu_re += (int64_t)x[38][1] * x[38][1];",
"phi[1][0][0] = autocorr_calc(accu_re);",
"}",
"}"
] |
[
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
1,
1,
0,
0,
1,
1,
0,
0,
1,
1,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
]
] |
12,924
|
static int oma_read_seek(struct AVFormatContext *s,
int stream_index, int64_t timestamp, int flags)
{
OMAContext *oc = s->priv_data;
int err = ff_pcm_read_seek(s, stream_index, timestamp, flags);
if (!oc->encrypted)
return err;
/* readjust IV for CBC */
if (err || avio_tell(s->pb) < oc->content_start)
goto wipe;
if ((err = avio_seek(s->pb, -8, SEEK_CUR)) < 0)
goto wipe;
if ((err = avio_read(s->pb, oc->iv, 8)) < 8) {
if (err >= 0)
err = AVERROR_EOF;
goto wipe;
}
return 0;
wipe:
memset(oc->iv, 0, 8);
return err;
}
| true
|
FFmpeg
|
0f55bc29d41585d110b126cb4ed4b395fd46d7ac
|
static int oma_read_seek(struct AVFormatContext *s,
int stream_index, int64_t timestamp, int flags)
{
OMAContext *oc = s->priv_data;
int err = ff_pcm_read_seek(s, stream_index, timestamp, flags);
if (!oc->encrypted)
return err;
if (err || avio_tell(s->pb) < oc->content_start)
goto wipe;
if ((err = avio_seek(s->pb, -8, SEEK_CUR)) < 0)
goto wipe;
if ((err = avio_read(s->pb, oc->iv, 8)) < 8) {
if (err >= 0)
err = AVERROR_EOF;
goto wipe;
}
return 0;
wipe:
memset(oc->iv, 0, 8);
return err;
}
|
{
"code": [
" int err = ff_pcm_read_seek(s, stream_index, timestamp, flags);"
],
"line_no": [
9
]
}
|
static int FUNC_0(struct AVFormatContext *VAR_0,
int VAR_1, int64_t VAR_2, int VAR_3)
{
OMAContext *oc = VAR_0->priv_data;
int VAR_4 = ff_pcm_read_seek(VAR_0, VAR_1, VAR_2, VAR_3);
if (!oc->encrypted)
return VAR_4;
if (VAR_4 || avio_tell(VAR_0->pb) < oc->content_start)
goto wipe;
if ((VAR_4 = avio_seek(VAR_0->pb, -8, SEEK_CUR)) < 0)
goto wipe;
if ((VAR_4 = avio_read(VAR_0->pb, oc->iv, 8)) < 8) {
if (VAR_4 >= 0)
VAR_4 = AVERROR_EOF;
goto wipe;
}
return 0;
wipe:
memset(oc->iv, 0, 8);
return VAR_4;
}
|
[
"static int FUNC_0(struct AVFormatContext *VAR_0,\nint VAR_1, int64_t VAR_2, int VAR_3)\n{",
"OMAContext *oc = VAR_0->priv_data;",
"int VAR_4 = ff_pcm_read_seek(VAR_0, VAR_1, VAR_2, VAR_3);",
"if (!oc->encrypted)\nreturn VAR_4;",
"if (VAR_4 || avio_tell(VAR_0->pb) < oc->content_start)\ngoto wipe;",
"if ((VAR_4 = avio_seek(VAR_0->pb, -8, SEEK_CUR)) < 0)\ngoto wipe;",
"if ((VAR_4 = avio_read(VAR_0->pb, oc->iv, 8)) < 8) {",
"if (VAR_4 >= 0)\nVAR_4 = AVERROR_EOF;",
"goto wipe;",
"}",
"return 0;",
"wipe:\nmemset(oc->iv, 0, 8);",
"return VAR_4;",
"}"
] |
[
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3,
5
],
[
7
],
[
9
],
[
13,
15
],
[
21,
23
],
[
25,
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
41
],
[
43,
45
],
[
47
],
[
49
]
] |
12,925
|
int pci_piix3_xen_ide_unplug(DeviceState *dev)
{
PCIIDEState *pci_ide;
DriveInfo *di;
int i = 0;
pci_ide = PCI_IDE(dev);
for (; i < 3; i++) {
di = drive_get_by_index(IF_IDE, i);
if (di != NULL && !di->media_cd) {
BlockBackend *blk = blk_by_legacy_dinfo(di);
DeviceState *ds = blk_get_attached_dev(blk);
if (ds) {
blk_detach_dev(blk, ds);
}
pci_ide->bus[di->bus].ifs[di->unit].blk = NULL;
blk_unref(blk);
}
}
qdev_reset_all(DEVICE(dev));
return 0;
}
| true
|
qemu
|
d4f9e806c20607cafe7bb0d9eba14ccb160390a1
|
int pci_piix3_xen_ide_unplug(DeviceState *dev)
{
PCIIDEState *pci_ide;
DriveInfo *di;
int i = 0;
pci_ide = PCI_IDE(dev);
for (; i < 3; i++) {
di = drive_get_by_index(IF_IDE, i);
if (di != NULL && !di->media_cd) {
BlockBackend *blk = blk_by_legacy_dinfo(di);
DeviceState *ds = blk_get_attached_dev(blk);
if (ds) {
blk_detach_dev(blk, ds);
}
pci_ide->bus[di->bus].ifs[di->unit].blk = NULL;
blk_unref(blk);
}
}
qdev_reset_all(DEVICE(dev));
return 0;
}
|
{
"code": [
" int i = 0;",
" for (; i < 3; i++) {"
],
"line_no": [
9,
17
]
}
|
int FUNC_0(DeviceState *VAR_0)
{
PCIIDEState *pci_ide;
DriveInfo *di;
int VAR_1 = 0;
pci_ide = PCI_IDE(VAR_0);
for (; VAR_1 < 3; VAR_1++) {
di = drive_get_by_index(IF_IDE, VAR_1);
if (di != NULL && !di->media_cd) {
BlockBackend *blk = blk_by_legacy_dinfo(di);
DeviceState *ds = blk_get_attached_dev(blk);
if (ds) {
blk_detach_dev(blk, ds);
}
pci_ide->bus[di->bus].ifs[di->unit].blk = NULL;
blk_unref(blk);
}
}
qdev_reset_all(DEVICE(VAR_0));
return 0;
}
|
[
"int FUNC_0(DeviceState *VAR_0)\n{",
"PCIIDEState *pci_ide;",
"DriveInfo *di;",
"int VAR_1 = 0;",
"pci_ide = PCI_IDE(VAR_0);",
"for (; VAR_1 < 3; VAR_1++) {",
"di = drive_get_by_index(IF_IDE, VAR_1);",
"if (di != NULL && !di->media_cd) {",
"BlockBackend *blk = blk_by_legacy_dinfo(di);",
"DeviceState *ds = blk_get_attached_dev(blk);",
"if (ds) {",
"blk_detach_dev(blk, ds);",
"}",
"pci_ide->bus[di->bus].ifs[di->unit].blk = NULL;",
"blk_unref(blk);",
"}",
"}",
"qdev_reset_all(DEVICE(VAR_0));",
"return 0;",
"}"
] |
[
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
]
] |
12,926
|
int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
{
const AVCodec *orig_codec = dest->codec;
uint8_t *orig_priv_data = dest->priv_data;
if (avcodec_is_open(dest)) { // check that the dest context is uninitialized
av_log(dest, AV_LOG_ERROR,
"Tried to copy AVCodecContext %p into already-initialized %p\n",
src, dest);
return AVERROR(EINVAL);
}
copy_context_reset(dest);
memcpy(dest, src, sizeof(*dest));
av_opt_copy(dest, src);
dest->priv_data = orig_priv_data;
dest->codec = orig_codec;
if (orig_priv_data && src->codec && src->codec->priv_class &&
dest->codec && dest->codec->priv_class)
av_opt_copy(orig_priv_data, src->priv_data);
/* set values specific to opened codecs back to their default state */
dest->slice_offset = NULL;
dest->hwaccel = NULL;
dest->internal = NULL;
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
dest->coded_frame = NULL;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
/* reallocate values that should be allocated separately */
dest->extradata = NULL;
dest->intra_matrix = NULL;
dest->inter_matrix = NULL;
dest->rc_override = NULL;
dest->subtitle_header = NULL;
dest->hw_frames_ctx = NULL;
#define alloc_and_copy_or_fail(obj, size, pad) \
if (src->obj && size > 0) { \
dest->obj = av_malloc(size + pad); \
if (!dest->obj) \
goto fail; \
memcpy(dest->obj, src->obj, size); \
if (pad) \
memset(((uint8_t *) dest->obj) + size, 0, pad); \
}
alloc_and_copy_or_fail(extradata, src->extradata_size,
AV_INPUT_BUFFER_PADDING_SIZE);
dest->extradata_size = src->extradata_size;
alloc_and_copy_or_fail(intra_matrix, 64 * sizeof(int16_t), 0);
alloc_and_copy_or_fail(inter_matrix, 64 * sizeof(int16_t), 0);
alloc_and_copy_or_fail(rc_override, src->rc_override_count * sizeof(*src->rc_override), 0);
alloc_and_copy_or_fail(subtitle_header, src->subtitle_header_size, 1);
av_assert0(dest->subtitle_header_size == src->subtitle_header_size);
#undef alloc_and_copy_or_fail
if (src->hw_frames_ctx) {
dest->hw_frames_ctx = av_buffer_ref(src->hw_frames_ctx);
if (!dest->hw_frames_ctx)
goto fail;
}
return 0;
fail:
copy_context_reset(dest);
return AVERROR(ENOMEM);
}
| true
|
FFmpeg
|
cac8de2da5c4935773128335c11b806faa73e19d
|
int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
{
const AVCodec *orig_codec = dest->codec;
uint8_t *orig_priv_data = dest->priv_data;
if (avcodec_is_open(dest)) {
av_log(dest, AV_LOG_ERROR,
"Tried to copy AVCodecContext %p into already-initialized %p\n",
src, dest);
return AVERROR(EINVAL);
}
copy_context_reset(dest);
memcpy(dest, src, sizeof(*dest));
av_opt_copy(dest, src);
dest->priv_data = orig_priv_data;
dest->codec = orig_codec;
if (orig_priv_data && src->codec && src->codec->priv_class &&
dest->codec && dest->codec->priv_class)
av_opt_copy(orig_priv_data, src->priv_data);
dest->slice_offset = NULL;
dest->hwaccel = NULL;
dest->internal = NULL;
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
dest->coded_frame = NULL;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
dest->extradata = NULL;
dest->intra_matrix = NULL;
dest->inter_matrix = NULL;
dest->rc_override = NULL;
dest->subtitle_header = NULL;
dest->hw_frames_ctx = NULL;
#define alloc_and_copy_or_fail(obj, size, pad) \
if (src->obj && size > 0) { \
dest->obj = av_malloc(size + pad); \
if (!dest->obj) \
goto fail; \
memcpy(dest->obj, src->obj, size); \
if (pad) \
memset(((uint8_t *) dest->obj) + size, 0, pad); \
}
alloc_and_copy_or_fail(extradata, src->extradata_size,
AV_INPUT_BUFFER_PADDING_SIZE);
dest->extradata_size = src->extradata_size;
alloc_and_copy_or_fail(intra_matrix, 64 * sizeof(int16_t), 0);
alloc_and_copy_or_fail(inter_matrix, 64 * sizeof(int16_t), 0);
alloc_and_copy_or_fail(rc_override, src->rc_override_count * sizeof(*src->rc_override), 0);
alloc_and_copy_or_fail(subtitle_header, src->subtitle_header_size, 1);
av_assert0(dest->subtitle_header_size == src->subtitle_header_size);
#undef alloc_and_copy_or_fail
if (src->hw_frames_ctx) {
dest->hw_frames_ctx = av_buffer_ref(src->hw_frames_ctx);
if (!dest->hw_frames_ctx)
goto fail;
}
return 0;
fail:
copy_context_reset(dest);
return AVERROR(ENOMEM);
}
|
{
"code": [],
"line_no": []
}
|
int FUNC_0(AVCodecContext *VAR_0, const AVCodecContext *VAR_1)
{
const AVCodec *VAR_2 = VAR_0->codec;
uint8_t *orig_priv_data = VAR_0->priv_data;
if (avcodec_is_open(VAR_0)) {
av_log(VAR_0, AV_LOG_ERROR,
"Tried to copy AVCodecContext %p into already-initialized %p\n",
VAR_1, VAR_0);
return AVERROR(EINVAL);
}
copy_context_reset(VAR_0);
memcpy(VAR_0, VAR_1, sizeof(*VAR_0));
av_opt_copy(VAR_0, VAR_1);
VAR_0->priv_data = orig_priv_data;
VAR_0->codec = VAR_2;
if (orig_priv_data && VAR_1->codec && VAR_1->codec->priv_class &&
VAR_0->codec && VAR_0->codec->priv_class)
av_opt_copy(orig_priv_data, VAR_1->priv_data);
VAR_0->slice_offset = NULL;
VAR_0->hwaccel = NULL;
VAR_0->internal = NULL;
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
VAR_0->coded_frame = NULL;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
VAR_0->extradata = NULL;
VAR_0->intra_matrix = NULL;
VAR_0->inter_matrix = NULL;
VAR_0->rc_override = NULL;
VAR_0->subtitle_header = NULL;
VAR_0->hw_frames_ctx = NULL;
#define alloc_and_copy_or_fail(obj, size, pad) \
if (VAR_1->obj && size > 0) { \
VAR_0->obj = av_malloc(size + pad); \
if (!VAR_0->obj) \
goto fail; \
memcpy(VAR_0->obj, VAR_1->obj, size); \
if (pad) \
memset(((uint8_t *) VAR_0->obj) + size, 0, pad); \
}
alloc_and_copy_or_fail(extradata, VAR_1->extradata_size,
AV_INPUT_BUFFER_PADDING_SIZE);
VAR_0->extradata_size = VAR_1->extradata_size;
alloc_and_copy_or_fail(intra_matrix, 64 * sizeof(int16_t), 0);
alloc_and_copy_or_fail(inter_matrix, 64 * sizeof(int16_t), 0);
alloc_and_copy_or_fail(rc_override, VAR_1->rc_override_count * sizeof(*VAR_1->rc_override), 0);
alloc_and_copy_or_fail(subtitle_header, VAR_1->subtitle_header_size, 1);
av_assert0(VAR_0->subtitle_header_size == VAR_1->subtitle_header_size);
#undef alloc_and_copy_or_fail
if (VAR_1->hw_frames_ctx) {
VAR_0->hw_frames_ctx = av_buffer_ref(VAR_1->hw_frames_ctx);
if (!VAR_0->hw_frames_ctx)
goto fail;
}
return 0;
fail:
copy_context_reset(VAR_0);
return AVERROR(ENOMEM);
}
|
[
"int FUNC_0(AVCodecContext *VAR_0, const AVCodecContext *VAR_1)\n{",
"const AVCodec *VAR_2 = VAR_0->codec;",
"uint8_t *orig_priv_data = VAR_0->priv_data;",
"if (avcodec_is_open(VAR_0)) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Tried to copy AVCodecContext %p into already-initialized %p\\n\",\nVAR_1, VAR_0);",
"return AVERROR(EINVAL);",
"}",
"copy_context_reset(VAR_0);",
"memcpy(VAR_0, VAR_1, sizeof(*VAR_0));",
"av_opt_copy(VAR_0, VAR_1);",
"VAR_0->priv_data = orig_priv_data;",
"VAR_0->codec = VAR_2;",
"if (orig_priv_data && VAR_1->codec && VAR_1->codec->priv_class &&\nVAR_0->codec && VAR_0->codec->priv_class)\nav_opt_copy(orig_priv_data, VAR_1->priv_data);",
"VAR_0->slice_offset = NULL;",
"VAR_0->hwaccel = NULL;",
"VAR_0->internal = NULL;",
"#if FF_API_CODED_FRAME\nFF_DISABLE_DEPRECATION_WARNINGS\nVAR_0->coded_frame = NULL;",
"FF_ENABLE_DEPRECATION_WARNINGS\n#endif\nVAR_0->extradata = NULL;",
"VAR_0->intra_matrix = NULL;",
"VAR_0->inter_matrix = NULL;",
"VAR_0->rc_override = NULL;",
"VAR_0->subtitle_header = NULL;",
"VAR_0->hw_frames_ctx = NULL;",
"#define alloc_and_copy_or_fail(obj, size, pad) \\\nif (VAR_1->obj && size > 0) { \\",
"VAR_0->obj = av_malloc(size + pad); \\",
"if (!VAR_0->obj) \\\ngoto fail; \\",
"memcpy(VAR_0->obj, VAR_1->obj, size); \\",
"if (pad) \\\nmemset(((uint8_t *) VAR_0->obj) + size, 0, pad); \\",
"}",
"alloc_and_copy_or_fail(extradata, VAR_1->extradata_size,\nAV_INPUT_BUFFER_PADDING_SIZE);",
"VAR_0->extradata_size = VAR_1->extradata_size;",
"alloc_and_copy_or_fail(intra_matrix, 64 * sizeof(int16_t), 0);",
"alloc_and_copy_or_fail(inter_matrix, 64 * sizeof(int16_t), 0);",
"alloc_and_copy_or_fail(rc_override, VAR_1->rc_override_count * sizeof(*VAR_1->rc_override), 0);",
"alloc_and_copy_or_fail(subtitle_header, VAR_1->subtitle_header_size, 1);",
"av_assert0(VAR_0->subtitle_header_size == VAR_1->subtitle_header_size);",
"#undef alloc_and_copy_or_fail\nif (VAR_1->hw_frames_ctx) {",
"VAR_0->hw_frames_ctx = av_buffer_ref(VAR_1->hw_frames_ctx);",
"if (!VAR_0->hw_frames_ctx)\ngoto fail;",
"}",
"return 0;",
"fail:\ncopy_context_reset(VAR_0);",
"return AVERROR(ENOMEM);",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15,
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
35
],
[
37
],
[
41,
43,
45
],
[
53
],
[
55
],
[
57
],
[
59,
61,
63
],
[
65,
67,
73
],
[
76
],
[
78
],
[
80
],
[
82
],
[
84
],
[
90,
92
],
[
94
],
[
96,
98
],
[
100
],
[
102,
104
],
[
106
],
[
108,
110
],
[
112
],
[
114
],
[
116
],
[
118
],
[
120
],
[
122
],
[
124,
128
],
[
130
],
[
132,
134
],
[
136
],
[
140
],
[
144,
146
],
[
148
],
[
150
]
] |
12,928
|
static int ftp_open(URLContext *h, const char *url, int flags)
{
char proto[10], path[MAX_URL_SIZE];
int err;
FTPContext *s = h->priv_data;
av_dlog(h, "ftp protocol open\n");
s->state = DISCONNECTED;
s->filesize = -1;
s->position = 0;
av_url_split(proto, sizeof(proto),
s->credencials, sizeof(s->credencials),
s->hostname, sizeof(s->hostname),
&s->server_control_port,
path, sizeof(path),
url);
if (s->server_control_port < 0 || s->server_control_port > 65535)
s->server_control_port = 21;
if ((err = ftp_connect_control_connection(h)) < 0)
goto fail;
if ((err = ftp_current_dir(s)) < 0)
goto fail;
av_strlcat(s->path, path, sizeof(s->path));
if (ftp_restart(s, 0) < 0) {
h->is_streamed = 1;
} else {
if (ftp_file_size(s) < 0 && flags & AVIO_FLAG_READ)
h->is_streamed = 1;
if (s->write_seekable != 1 && flags & AVIO_FLAG_WRITE)
h->is_streamed = 1;
}
return 0;
fail:
av_log(h, AV_LOG_ERROR, "FTP open failed\n");
ffurl_closep(&s->conn_control);
ffurl_closep(&s->conn_data);
return err;
}
| false
|
FFmpeg
|
c043def91f92da398fe04874191c8d4d7b6cf0e0
|
static int ftp_open(URLContext *h, const char *url, int flags)
{
char proto[10], path[MAX_URL_SIZE];
int err;
FTPContext *s = h->priv_data;
av_dlog(h, "ftp protocol open\n");
s->state = DISCONNECTED;
s->filesize = -1;
s->position = 0;
av_url_split(proto, sizeof(proto),
s->credencials, sizeof(s->credencials),
s->hostname, sizeof(s->hostname),
&s->server_control_port,
path, sizeof(path),
url);
if (s->server_control_port < 0 || s->server_control_port > 65535)
s->server_control_port = 21;
if ((err = ftp_connect_control_connection(h)) < 0)
goto fail;
if ((err = ftp_current_dir(s)) < 0)
goto fail;
av_strlcat(s->path, path, sizeof(s->path));
if (ftp_restart(s, 0) < 0) {
h->is_streamed = 1;
} else {
if (ftp_file_size(s) < 0 && flags & AVIO_FLAG_READ)
h->is_streamed = 1;
if (s->write_seekable != 1 && flags & AVIO_FLAG_WRITE)
h->is_streamed = 1;
}
return 0;
fail:
av_log(h, AV_LOG_ERROR, "FTP open failed\n");
ffurl_closep(&s->conn_control);
ffurl_closep(&s->conn_data);
return err;
}
|
{
"code": [],
"line_no": []
}
|
static int FUNC_0(URLContext *VAR_0, const char *VAR_1, int VAR_2)
{
char VAR_3[10], path[MAX_URL_SIZE];
int VAR_4;
FTPContext *s = VAR_0->priv_data;
av_dlog(VAR_0, "ftp protocol open\n");
s->state = DISCONNECTED;
s->filesize = -1;
s->position = 0;
av_url_split(VAR_3, sizeof(VAR_3),
s->credencials, sizeof(s->credencials),
s->hostname, sizeof(s->hostname),
&s->server_control_port,
path, sizeof(path),
VAR_1);
if (s->server_control_port < 0 || s->server_control_port > 65535)
s->server_control_port = 21;
if ((VAR_4 = ftp_connect_control_connection(VAR_0)) < 0)
goto fail;
if ((VAR_4 = ftp_current_dir(s)) < 0)
goto fail;
av_strlcat(s->path, path, sizeof(s->path));
if (ftp_restart(s, 0) < 0) {
VAR_0->is_streamed = 1;
} else {
if (ftp_file_size(s) < 0 && VAR_2 & AVIO_FLAG_READ)
VAR_0->is_streamed = 1;
if (s->write_seekable != 1 && VAR_2 & AVIO_FLAG_WRITE)
VAR_0->is_streamed = 1;
}
return 0;
fail:
av_log(VAR_0, AV_LOG_ERROR, "FTP open failed\n");
ffurl_closep(&s->conn_control);
ffurl_closep(&s->conn_data);
return VAR_4;
}
|
[
"static int FUNC_0(URLContext *VAR_0, const char *VAR_1, int VAR_2)\n{",
"char VAR_3[10], path[MAX_URL_SIZE];",
"int VAR_4;",
"FTPContext *s = VAR_0->priv_data;",
"av_dlog(VAR_0, \"ftp protocol open\\n\");",
"s->state = DISCONNECTED;",
"s->filesize = -1;",
"s->position = 0;",
"av_url_split(VAR_3, sizeof(VAR_3),\ns->credencials, sizeof(s->credencials),\ns->hostname, sizeof(s->hostname),\n&s->server_control_port,\npath, sizeof(path),\nVAR_1);",
"if (s->server_control_port < 0 || s->server_control_port > 65535)\ns->server_control_port = 21;",
"if ((VAR_4 = ftp_connect_control_connection(VAR_0)) < 0)\ngoto fail;",
"if ((VAR_4 = ftp_current_dir(s)) < 0)\ngoto fail;",
"av_strlcat(s->path, path, sizeof(s->path));",
"if (ftp_restart(s, 0) < 0) {",
"VAR_0->is_streamed = 1;",
"} else {",
"if (ftp_file_size(s) < 0 && VAR_2 & AVIO_FLAG_READ)\nVAR_0->is_streamed = 1;",
"if (s->write_seekable != 1 && VAR_2 & AVIO_FLAG_WRITE)\nVAR_0->is_streamed = 1;",
"}",
"return 0;",
"fail:\nav_log(VAR_0, AV_LOG_ERROR, \"FTP open failed\\n\");",
"ffurl_closep(&s->conn_control);",
"ffurl_closep(&s->conn_data);",
"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
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25,
27,
29,
31,
33,
35
],
[
39,
41
],
[
45,
47
],
[
51,
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69,
71
],
[
73
],
[
77
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
91
]
] |
12,929
|
static void vnc_convert_pixel(VncState *vs, uint8_t *buf, uint32_t v)
{
uint8_t r, g, b;
r = ((v >> vs->server_red_shift) & vs->server_red_max) * (vs->client_red_max + 1) /
(vs->server_red_max + 1);
g = ((v >> vs->server_green_shift) & vs->server_green_max) * (vs->client_green_max + 1) /
(vs->server_green_max + 1);
b = ((v >> vs->server_blue_shift) & vs->server_blue_max) * (vs->client_blue_max + 1) /
(vs->server_blue_max + 1);
v = (r << vs->client_red_shift) |
(g << vs->client_green_shift) |
(b << vs->client_blue_shift);
switch(vs->pix_bpp) {
case 1:
buf[0] = v;
break;
case 2:
if (vs->pix_big_endian) {
buf[0] = v >> 8;
buf[1] = v;
} else {
buf[1] = v >> 8;
buf[0] = v;
}
break;
default:
case 4:
if (vs->pix_big_endian) {
buf[0] = v >> 24;
buf[1] = v >> 16;
buf[2] = v >> 8;
buf[3] = v;
} else {
buf[3] = v >> 24;
buf[2] = v >> 16;
buf[1] = v >> 8;
buf[0] = v;
}
break;
}
}
| true
|
qemu
|
6cec5487990bf3f1f22b3fcb871978255e92ae0d
|
static void vnc_convert_pixel(VncState *vs, uint8_t *buf, uint32_t v)
{
uint8_t r, g, b;
r = ((v >> vs->server_red_shift) & vs->server_red_max) * (vs->client_red_max + 1) /
(vs->server_red_max + 1);
g = ((v >> vs->server_green_shift) & vs->server_green_max) * (vs->client_green_max + 1) /
(vs->server_green_max + 1);
b = ((v >> vs->server_blue_shift) & vs->server_blue_max) * (vs->client_blue_max + 1) /
(vs->server_blue_max + 1);
v = (r << vs->client_red_shift) |
(g << vs->client_green_shift) |
(b << vs->client_blue_shift);
switch(vs->pix_bpp) {
case 1:
buf[0] = v;
break;
case 2:
if (vs->pix_big_endian) {
buf[0] = v >> 8;
buf[1] = v;
} else {
buf[1] = v >> 8;
buf[0] = v;
}
break;
default:
case 4:
if (vs->pix_big_endian) {
buf[0] = v >> 24;
buf[1] = v >> 16;
buf[2] = v >> 8;
buf[3] = v;
} else {
buf[3] = v >> 24;
buf[2] = v >> 16;
buf[1] = v >> 8;
buf[0] = v;
}
break;
}
}
|
{
"code": [
" r = ((v >> vs->server_red_shift) & vs->server_red_max) * (vs->client_red_max + 1) /",
" (vs->server_red_max + 1);",
" g = ((v >> vs->server_green_shift) & vs->server_green_max) * (vs->client_green_max + 1) /",
" (vs->server_green_max + 1);",
" b = ((v >> vs->server_blue_shift) & vs->server_blue_max) * (vs->client_blue_max + 1) /",
" (vs->server_blue_max + 1);",
" v = (r << vs->client_red_shift) |",
" (g << vs->client_green_shift) |",
" (b << vs->client_blue_shift);",
" switch(vs->pix_bpp) {",
" if (vs->pix_big_endian) {",
" if (vs->pix_big_endian) {",
" } else {",
" } else {"
],
"line_no": [
9,
11,
13,
15,
17,
19,
21,
23,
25,
27,
37,
37,
43,
43
]
}
|
static void FUNC_0(VncState *VAR_0, uint8_t *VAR_1, uint32_t VAR_2)
{
uint8_t r, g, b;
r = ((VAR_2 >> VAR_0->server_red_shift) & VAR_0->server_red_max) * (VAR_0->client_red_max + 1) /
(VAR_0->server_red_max + 1);
g = ((VAR_2 >> VAR_0->server_green_shift) & VAR_0->server_green_max) * (VAR_0->client_green_max + 1) /
(VAR_0->server_green_max + 1);
b = ((VAR_2 >> VAR_0->server_blue_shift) & VAR_0->server_blue_max) * (VAR_0->client_blue_max + 1) /
(VAR_0->server_blue_max + 1);
VAR_2 = (r << VAR_0->client_red_shift) |
(g << VAR_0->client_green_shift) |
(b << VAR_0->client_blue_shift);
switch(VAR_0->pix_bpp) {
case 1:
VAR_1[0] = VAR_2;
break;
case 2:
if (VAR_0->pix_big_endian) {
VAR_1[0] = VAR_2 >> 8;
VAR_1[1] = VAR_2;
} else {
VAR_1[1] = VAR_2 >> 8;
VAR_1[0] = VAR_2;
}
break;
default:
case 4:
if (VAR_0->pix_big_endian) {
VAR_1[0] = VAR_2 >> 24;
VAR_1[1] = VAR_2 >> 16;
VAR_1[2] = VAR_2 >> 8;
VAR_1[3] = VAR_2;
} else {
VAR_1[3] = VAR_2 >> 24;
VAR_1[2] = VAR_2 >> 16;
VAR_1[1] = VAR_2 >> 8;
VAR_1[0] = VAR_2;
}
break;
}
}
|
[
"static void FUNC_0(VncState *VAR_0, uint8_t *VAR_1, uint32_t VAR_2)\n{",
"uint8_t r, g, b;",
"r = ((VAR_2 >> VAR_0->server_red_shift) & VAR_0->server_red_max) * (VAR_0->client_red_max + 1) /\n(VAR_0->server_red_max + 1);",
"g = ((VAR_2 >> VAR_0->server_green_shift) & VAR_0->server_green_max) * (VAR_0->client_green_max + 1) /\n(VAR_0->server_green_max + 1);",
"b = ((VAR_2 >> VAR_0->server_blue_shift) & VAR_0->server_blue_max) * (VAR_0->client_blue_max + 1) /\n(VAR_0->server_blue_max + 1);",
"VAR_2 = (r << VAR_0->client_red_shift) |\n(g << VAR_0->client_green_shift) |\n(b << VAR_0->client_blue_shift);",
"switch(VAR_0->pix_bpp) {",
"case 1:\nVAR_1[0] = VAR_2;",
"break;",
"case 2:\nif (VAR_0->pix_big_endian) {",
"VAR_1[0] = VAR_2 >> 8;",
"VAR_1[1] = VAR_2;",
"} else {",
"VAR_1[1] = VAR_2 >> 8;",
"VAR_1[0] = VAR_2;",
"}",
"break;",
"default:\ncase 4:\nif (VAR_0->pix_big_endian) {",
"VAR_1[0] = VAR_2 >> 24;",
"VAR_1[1] = VAR_2 >> 16;",
"VAR_1[2] = VAR_2 >> 8;",
"VAR_1[3] = VAR_2;",
"} else {",
"VAR_1[3] = VAR_2 >> 24;",
"VAR_1[2] = VAR_2 >> 16;",
"VAR_1[1] = VAR_2 >> 8;",
"VAR_1[0] = VAR_2;",
"}",
"break;",
"}",
"}"
] |
[
0,
0,
1,
1,
1,
1,
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
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
]
] |
12,930
|
static int thread_execute(AVFilterContext *ctx, avfilter_action_func *func,
void *arg, int *ret, int nb_jobs)
{
ThreadContext *c = ctx->graph->internal->thread;
int dummy_ret;
if (nb_jobs <= 0)
return 0;
pthread_mutex_lock(&c->current_job_lock);
c->current_job = c->nb_threads;
c->nb_jobs = nb_jobs;
c->ctx = ctx;
c->arg = arg;
c->func = func;
if (ret) {
c->rets = ret;
c->nb_rets = nb_jobs;
} else {
c->rets = &dummy_ret;
c->nb_rets = 1;
}
c->current_execute++;
pthread_cond_broadcast(&c->current_job_cond);
slice_thread_park_workers(c);
return 0;
}
| true
|
FFmpeg
|
473f0f75a16b4d37bdaa943f75e4ae249212c1ba
|
static int thread_execute(AVFilterContext *ctx, avfilter_action_func *func,
void *arg, int *ret, int nb_jobs)
{
ThreadContext *c = ctx->graph->internal->thread;
int dummy_ret;
if (nb_jobs <= 0)
return 0;
pthread_mutex_lock(&c->current_job_lock);
c->current_job = c->nb_threads;
c->nb_jobs = nb_jobs;
c->ctx = ctx;
c->arg = arg;
c->func = func;
if (ret) {
c->rets = ret;
c->nb_rets = nb_jobs;
} else {
c->rets = &dummy_ret;
c->nb_rets = 1;
}
c->current_execute++;
pthread_cond_broadcast(&c->current_job_cond);
slice_thread_park_workers(c);
return 0;
}
|
{
"code": [
" int dummy_ret;",
" if (ret) {",
" c->rets = ret;",
" c->nb_rets = nb_jobs;",
" } else {",
" c->rets = &dummy_ret;",
" c->nb_rets = 1;"
],
"line_no": [
9,
33,
35,
37,
39,
41,
43
]
}
|
static int FUNC_0(AVFilterContext *VAR_0, avfilter_action_func *VAR_1,
void *VAR_2, int *VAR_3, int VAR_4)
{
ThreadContext *c = VAR_0->graph->internal->thread;
int VAR_5;
if (VAR_4 <= 0)
return 0;
pthread_mutex_lock(&c->current_job_lock);
c->current_job = c->nb_threads;
c->VAR_4 = VAR_4;
c->VAR_0 = VAR_0;
c->VAR_2 = VAR_2;
c->VAR_1 = VAR_1;
if (VAR_3) {
c->rets = VAR_3;
c->nb_rets = VAR_4;
} else {
c->rets = &VAR_5;
c->nb_rets = 1;
}
c->current_execute++;
pthread_cond_broadcast(&c->current_job_cond);
slice_thread_park_workers(c);
return 0;
}
|
[
"static int FUNC_0(AVFilterContext *VAR_0, avfilter_action_func *VAR_1,\nvoid *VAR_2, int *VAR_3, int VAR_4)\n{",
"ThreadContext *c = VAR_0->graph->internal->thread;",
"int VAR_5;",
"if (VAR_4 <= 0)\nreturn 0;",
"pthread_mutex_lock(&c->current_job_lock);",
"c->current_job = c->nb_threads;",
"c->VAR_4 = VAR_4;",
"c->VAR_0 = VAR_0;",
"c->VAR_2 = VAR_2;",
"c->VAR_1 = VAR_1;",
"if (VAR_3) {",
"c->rets = VAR_3;",
"c->nb_rets = VAR_4;",
"} else {",
"c->rets = &VAR_5;",
"c->nb_rets = 1;",
"}",
"c->current_execute++;",
"pthread_cond_broadcast(&c->current_job_cond);",
"slice_thread_park_workers(c);",
"return 0;",
"}"
] |
[
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
1,
1,
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
],
[
51
],
[
55
],
[
59
],
[
61
]
] |
12,931
|
static int asf_read_payload(AVFormatContext *s, AVPacket *pkt)
{
ASFContext *asf = s->priv_data;
AVIOContext *pb = s->pb;
int ret, i;
ASFPacket *asf_pkt = NULL;
if (!asf->sub_left) {
uint32_t off_len, media_len;
uint8_t stream_num;
stream_num = avio_r8(pb);
asf->stream_index = stream_num & ASF_STREAM_NUM;
for (i = 0; i < asf->nb_streams; i++) {
if (asf->stream_index == asf->asf_st[i]->stream_index) {
asf_pkt = &asf->asf_st[i]->pkt;
asf_pkt->stream_index = asf->asf_st[i]->index;
break;
}
}
if (!asf_pkt)
return AVERROR_INVALIDDATA;
if (stream_num >> 7)
asf_pkt->flags |= AV_PKT_FLAG_KEY;
READ_LEN(asf->prop_flags & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE,
ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_, media_len);
READ_LEN(asf->prop_flags & ASF_PL_MASK_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_SIZE,
ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_, off_len);
READ_LEN(asf->prop_flags & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE,
ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_, asf->rep_data_len);
if (asf_pkt->size_left && (asf_pkt->frame_num != media_len)) {
av_log(s, AV_LOG_WARNING, "Unfinished frame will be ignored\n");
reset_packet(asf_pkt);
}
asf_pkt->frame_num = media_len;
asf->sub_dts = off_len;
if (asf->nb_mult_left) {
if ((ret = asf_read_multiple_payload(s, pkt, asf_pkt)) < 0)
return ret;
} else if (asf->rep_data_len == 1) {
asf->sub_left = 1;
asf->state = READ_SINGLE;
pkt->flags = asf_pkt->flags;
if ((ret = asf_read_subpayload(s, pkt, 1)) < 0)
return ret;
} else {
if ((ret = asf_read_single_payload(s, pkt, asf_pkt)) < 0)
return ret;
}
} else {
for (i = 0; i <= asf->nb_streams; i++) {
if (asf->stream_index == asf->asf_st[i]->stream_index) {
asf_pkt = &asf->asf_st[i]->pkt;
break;
}
}
if (!asf_pkt)
return AVERROR_INVALIDDATA;
pkt->flags = asf_pkt->flags;
pkt->dts = asf_pkt->dts;
pkt->stream_index = asf->asf_st[i]->index;
if ((ret = asf_read_subpayload(s, pkt, 0)) < 0) // read subpayload without its header
return ret;
}
return 0;
}
| true
|
FFmpeg
|
8375dc1dd101d51baa430f34c0bcadfa37873896
|
static int asf_read_payload(AVFormatContext *s, AVPacket *pkt)
{
ASFContext *asf = s->priv_data;
AVIOContext *pb = s->pb;
int ret, i;
ASFPacket *asf_pkt = NULL;
if (!asf->sub_left) {
uint32_t off_len, media_len;
uint8_t stream_num;
stream_num = avio_r8(pb);
asf->stream_index = stream_num & ASF_STREAM_NUM;
for (i = 0; i < asf->nb_streams; i++) {
if (asf->stream_index == asf->asf_st[i]->stream_index) {
asf_pkt = &asf->asf_st[i]->pkt;
asf_pkt->stream_index = asf->asf_st[i]->index;
break;
}
}
if (!asf_pkt)
return AVERROR_INVALIDDATA;
if (stream_num >> 7)
asf_pkt->flags |= AV_PKT_FLAG_KEY;
READ_LEN(asf->prop_flags & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE,
ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_, media_len);
READ_LEN(asf->prop_flags & ASF_PL_MASK_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_SIZE,
ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_, off_len);
READ_LEN(asf->prop_flags & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE,
ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_, asf->rep_data_len);
if (asf_pkt->size_left && (asf_pkt->frame_num != media_len)) {
av_log(s, AV_LOG_WARNING, "Unfinished frame will be ignored\n");
reset_packet(asf_pkt);
}
asf_pkt->frame_num = media_len;
asf->sub_dts = off_len;
if (asf->nb_mult_left) {
if ((ret = asf_read_multiple_payload(s, pkt, asf_pkt)) < 0)
return ret;
} else if (asf->rep_data_len == 1) {
asf->sub_left = 1;
asf->state = READ_SINGLE;
pkt->flags = asf_pkt->flags;
if ((ret = asf_read_subpayload(s, pkt, 1)) < 0)
return ret;
} else {
if ((ret = asf_read_single_payload(s, pkt, asf_pkt)) < 0)
return ret;
}
} else {
for (i = 0; i <= asf->nb_streams; i++) {
if (asf->stream_index == asf->asf_st[i]->stream_index) {
asf_pkt = &asf->asf_st[i]->pkt;
break;
}
}
if (!asf_pkt)
return AVERROR_INVALIDDATA;
pkt->flags = asf_pkt->flags;
pkt->dts = asf_pkt->dts;
pkt->stream_index = asf->asf_st[i]->index;
if ((ret = asf_read_subpayload(s, pkt, 0)) < 0)
return ret;
}
return 0;
}
|
{
"code": [
" if (!asf_pkt)",
" return AVERROR_INVALIDDATA;"
],
"line_no": [
41,
43
]
}
|
static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
ASFContext *asf = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
int VAR_2, VAR_3;
ASFPacket *asf_pkt = NULL;
if (!asf->sub_left) {
uint32_t off_len, media_len;
uint8_t stream_num;
stream_num = avio_r8(pb);
asf->stream_index = stream_num & ASF_STREAM_NUM;
for (VAR_3 = 0; VAR_3 < asf->nb_streams; VAR_3++) {
if (asf->stream_index == asf->asf_st[VAR_3]->stream_index) {
asf_pkt = &asf->asf_st[VAR_3]->VAR_1;
asf_pkt->stream_index = asf->asf_st[VAR_3]->index;
break;
}
}
if (!asf_pkt)
return AVERROR_INVALIDDATA;
if (stream_num >> 7)
asf_pkt->flags |= AV_PKT_FLAG_KEY;
READ_LEN(asf->prop_flags & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE,
ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_, media_len);
READ_LEN(asf->prop_flags & ASF_PL_MASK_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_SIZE,
ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_, off_len);
READ_LEN(asf->prop_flags & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE,
ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_, asf->rep_data_len);
if (asf_pkt->size_left && (asf_pkt->frame_num != media_len)) {
av_log(VAR_0, AV_LOG_WARNING, "Unfinished frame will be ignored\n");
reset_packet(asf_pkt);
}
asf_pkt->frame_num = media_len;
asf->sub_dts = off_len;
if (asf->nb_mult_left) {
if ((VAR_2 = asf_read_multiple_payload(VAR_0, VAR_1, asf_pkt)) < 0)
return VAR_2;
} else if (asf->rep_data_len == 1) {
asf->sub_left = 1;
asf->state = READ_SINGLE;
VAR_1->flags = asf_pkt->flags;
if ((VAR_2 = asf_read_subpayload(VAR_0, VAR_1, 1)) < 0)
return VAR_2;
} else {
if ((VAR_2 = asf_read_single_payload(VAR_0, VAR_1, asf_pkt)) < 0)
return VAR_2;
}
} else {
for (VAR_3 = 0; VAR_3 <= asf->nb_streams; VAR_3++) {
if (asf->stream_index == asf->asf_st[VAR_3]->stream_index) {
asf_pkt = &asf->asf_st[VAR_3]->VAR_1;
break;
}
}
if (!asf_pkt)
return AVERROR_INVALIDDATA;
VAR_1->flags = asf_pkt->flags;
VAR_1->dts = asf_pkt->dts;
VAR_1->stream_index = asf->asf_st[VAR_3]->index;
if ((VAR_2 = asf_read_subpayload(VAR_0, VAR_1, 0)) < 0)
return VAR_2;
}
return 0;
}
|
[
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"ASFContext *asf = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"int VAR_2, VAR_3;",
"ASFPacket *asf_pkt = NULL;",
"if (!asf->sub_left) {",
"uint32_t off_len, media_len;",
"uint8_t stream_num;",
"stream_num = avio_r8(pb);",
"asf->stream_index = stream_num & ASF_STREAM_NUM;",
"for (VAR_3 = 0; VAR_3 < asf->nb_streams; VAR_3++) {",
"if (asf->stream_index == asf->asf_st[VAR_3]->stream_index) {",
"asf_pkt = &asf->asf_st[VAR_3]->VAR_1;",
"asf_pkt->stream_index = asf->asf_st[VAR_3]->index;",
"break;",
"}",
"}",
"if (!asf_pkt)\nreturn AVERROR_INVALIDDATA;",
"if (stream_num >> 7)\nasf_pkt->flags |= AV_PKT_FLAG_KEY;",
"READ_LEN(asf->prop_flags & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE,\nASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_, media_len);",
"READ_LEN(asf->prop_flags & ASF_PL_MASK_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_SIZE,\nASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_, off_len);",
"READ_LEN(asf->prop_flags & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE,\nASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_, asf->rep_data_len);",
"if (asf_pkt->size_left && (asf_pkt->frame_num != media_len)) {",
"av_log(VAR_0, AV_LOG_WARNING, \"Unfinished frame will be ignored\\n\");",
"reset_packet(asf_pkt);",
"}",
"asf_pkt->frame_num = media_len;",
"asf->sub_dts = off_len;",
"if (asf->nb_mult_left) {",
"if ((VAR_2 = asf_read_multiple_payload(VAR_0, VAR_1, asf_pkt)) < 0)\nreturn VAR_2;",
"} else if (asf->rep_data_len == 1) {",
"asf->sub_left = 1;",
"asf->state = READ_SINGLE;",
"VAR_1->flags = asf_pkt->flags;",
"if ((VAR_2 = asf_read_subpayload(VAR_0, VAR_1, 1)) < 0)\nreturn VAR_2;",
"} else {",
"if ((VAR_2 = asf_read_single_payload(VAR_0, VAR_1, asf_pkt)) < 0)\nreturn VAR_2;",
"}",
"} else {",
"for (VAR_3 = 0; VAR_3 <= asf->nb_streams; VAR_3++) {",
"if (asf->stream_index == asf->asf_st[VAR_3]->stream_index) {",
"asf_pkt = &asf->asf_st[VAR_3]->VAR_1;",
"break;",
"}",
"}",
"if (!asf_pkt)\nreturn AVERROR_INVALIDDATA;",
"VAR_1->flags = asf_pkt->flags;",
"VAR_1->dts = asf_pkt->dts;",
"VAR_1->stream_index = asf->asf_st[VAR_3]->index;",
"if ((VAR_2 = asf_read_subpayload(VAR_0, VAR_1, 0)) < 0)\nreturn VAR_2;",
"}",
"return 0;",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45,
47
],
[
49,
51
],
[
53,
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87,
89
],
[
91
],
[
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113,
115
],
[
117
],
[
119
],
[
121
],
[
123,
125
],
[
127
],
[
131
],
[
133
]
] |
12,932
|
static void pred8x8_dc_rv40_c(uint8_t *src, int stride){
int i;
int dc0=0;
for(i=0;i<4; i++){
dc0+= src[-1+i*stride] + src[i-stride];
dc0+= src[4+i-stride];
dc0+= src[-1+(i+4)*stride];
}
dc0= 0x01010101*((dc0 + 8)>>4);
for(i=0; i<4; i++){
((uint32_t*)(src+i*stride))[0]= dc0;
((uint32_t*)(src+i*stride))[1]= dc0;
}
for(i=4; i<8; i++){
((uint32_t*)(src+i*stride))[0]= dc0;
((uint32_t*)(src+i*stride))[1]= dc0;
}
}
| true
|
FFmpeg
|
60f10e0ad37418cc697765d85b0bc22db70f726a
|
static void pred8x8_dc_rv40_c(uint8_t *src, int stride){
int i;
int dc0=0;
for(i=0;i<4; i++){
dc0+= src[-1+i*stride] + src[i-stride];
dc0+= src[4+i-stride];
dc0+= src[-1+(i+4)*stride];
}
dc0= 0x01010101*((dc0 + 8)>>4);
for(i=0; i<4; i++){
((uint32_t*)(src+i*stride))[0]= dc0;
((uint32_t*)(src+i*stride))[1]= dc0;
}
for(i=4; i<8; i++){
((uint32_t*)(src+i*stride))[0]= dc0;
((uint32_t*)(src+i*stride))[1]= dc0;
}
}
|
{
"code": [
" int dc0=0;"
],
"line_no": [
5
]
}
|
static void FUNC_0(uint8_t *VAR_0, int VAR_1){
int VAR_2;
int VAR_3=0;
for(VAR_2=0;VAR_2<4; VAR_2++){
VAR_3+= VAR_0[-1+VAR_2*VAR_1] + VAR_0[VAR_2-VAR_1];
VAR_3+= VAR_0[4+VAR_2-VAR_1];
VAR_3+= VAR_0[-1+(VAR_2+4)*VAR_1];
}
VAR_3= 0x01010101*((VAR_3 + 8)>>4);
for(VAR_2=0; VAR_2<4; VAR_2++){
((uint32_t*)(VAR_0+VAR_2*VAR_1))[0]= VAR_3;
((uint32_t*)(VAR_0+VAR_2*VAR_1))[1]= VAR_3;
}
for(VAR_2=4; VAR_2<8; VAR_2++){
((uint32_t*)(VAR_0+VAR_2*VAR_1))[0]= VAR_3;
((uint32_t*)(VAR_0+VAR_2*VAR_1))[1]= VAR_3;
}
}
|
[
"static void FUNC_0(uint8_t *VAR_0, int VAR_1){",
"int VAR_2;",
"int VAR_3=0;",
"for(VAR_2=0;VAR_2<4; VAR_2++){",
"VAR_3+= VAR_0[-1+VAR_2*VAR_1] + VAR_0[VAR_2-VAR_1];",
"VAR_3+= VAR_0[4+VAR_2-VAR_1];",
"VAR_3+= VAR_0[-1+(VAR_2+4)*VAR_1];",
"}",
"VAR_3= 0x01010101*((VAR_3 + 8)>>4);",
"for(VAR_2=0; VAR_2<4; VAR_2++){",
"((uint32_t*)(VAR_0+VAR_2*VAR_1))[0]= VAR_3;",
"((uint32_t*)(VAR_0+VAR_2*VAR_1))[1]= VAR_3;",
"}",
"for(VAR_2=4; VAR_2<8; VAR_2++){",
"((uint32_t*)(VAR_0+VAR_2*VAR_1))[0]= VAR_3;",
"((uint32_t*)(VAR_0+VAR_2*VAR_1))[1]= VAR_3;",
"}",
"}"
] |
[
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1
],
[
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
]
] |
12,933
|
static int set_expr(AVExpr **pexpr, const char *expr, void *log_ctx)
{
int ret;
AVExpr *old = NULL;
if (*pexpr)
old = *pexpr;
ret = av_expr_parse(pexpr, expr, var_names,
NULL, NULL, NULL, NULL, 0, log_ctx);
if (ret < 0) {
av_log(log_ctx, AV_LOG_ERROR,
"Error when evaluating the expression '%s'\n", expr);
*pexpr = old;
return ret;
}
av_expr_free(old);
return 0;
}
| false
|
FFmpeg
|
9da369604ecf31d9dce2dee21ed214b8c43264c6
|
static int set_expr(AVExpr **pexpr, const char *expr, void *log_ctx)
{
int ret;
AVExpr *old = NULL;
if (*pexpr)
old = *pexpr;
ret = av_expr_parse(pexpr, expr, var_names,
NULL, NULL, NULL, NULL, 0, log_ctx);
if (ret < 0) {
av_log(log_ctx, AV_LOG_ERROR,
"Error when evaluating the expression '%s'\n", expr);
*pexpr = old;
return ret;
}
av_expr_free(old);
return 0;
}
|
{
"code": [],
"line_no": []
}
|
static int FUNC_0(AVExpr **VAR_0, const char *VAR_1, void *VAR_2)
{
int VAR_3;
AVExpr *old = NULL;
if (*VAR_0)
old = *VAR_0;
VAR_3 = av_expr_parse(VAR_0, VAR_1, var_names,
NULL, NULL, NULL, NULL, 0, VAR_2);
if (VAR_3 < 0) {
av_log(VAR_2, AV_LOG_ERROR,
"Error when evaluating the expression '%s'\n", VAR_1);
*VAR_0 = old;
return VAR_3;
}
av_expr_free(old);
return 0;
}
|
[
"static int FUNC_0(AVExpr **VAR_0, const char *VAR_1, void *VAR_2)\n{",
"int VAR_3;",
"AVExpr *old = NULL;",
"if (*VAR_0)\nold = *VAR_0;",
"VAR_3 = av_expr_parse(VAR_0, VAR_1, var_names,\nNULL, NULL, NULL, NULL, 0, VAR_2);",
"if (VAR_3 < 0) {",
"av_log(VAR_2, AV_LOG_ERROR,\n\"Error when evaluating the expression '%s'\\n\", VAR_1);",
"*VAR_0 = old;",
"return VAR_3;",
"}",
"av_expr_free(old);",
"return 0;",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15,
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
]
] |
12,934
|
static void av_estimate_timings_from_pts(AVFormatContext *ic, offset_t old_offset)
{
AVPacket pkt1, *pkt = &pkt1;
AVStream *st;
int read_size, i, ret;
int64_t end_time;
int64_t filesize, offset, duration;
/* free previous packet */
if (ic->cur_st && ic->cur_st->parser)
av_free_packet(&ic->cur_pkt);
ic->cur_st = NULL;
/* flush packet queue */
flush_packet_queue(ic);
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
if (st->parser) {
av_parser_close(st->parser);
st->parser= NULL;
}
}
/* we read the first packets to get the first PTS (not fully
accurate, but it is enough now) */
url_fseek(&ic->pb, 0, SEEK_SET);
read_size = 0;
for(;;) {
if (read_size >= DURATION_MAX_READ_SIZE)
break;
/* if all info is available, we can stop */
for(i = 0;i < ic->nb_streams; i++) {
st = ic->streams[i];
if (st->start_time == AV_NOPTS_VALUE)
break;
}
if (i == ic->nb_streams)
break;
ret = av_read_packet(ic, pkt);
if (ret != 0)
break;
read_size += pkt->size;
st = ic->streams[pkt->stream_index];
if (pkt->pts != AV_NOPTS_VALUE) {
if (st->start_time == AV_NOPTS_VALUE)
st->start_time = pkt->pts;
}
av_free_packet(pkt);
}
/* estimate the end time (duration) */
/* XXX: may need to support wrapping */
filesize = ic->file_size;
offset = filesize - DURATION_MAX_READ_SIZE;
if (offset < 0)
offset = 0;
url_fseek(&ic->pb, offset, SEEK_SET);
read_size = 0;
for(;;) {
if (read_size >= DURATION_MAX_READ_SIZE)
break;
/* if all info is available, we can stop */
for(i = 0;i < ic->nb_streams; i++) {
st = ic->streams[i];
if (st->duration == AV_NOPTS_VALUE)
break;
}
if (i == ic->nb_streams)
break;
ret = av_read_packet(ic, pkt);
if (ret != 0)
break;
read_size += pkt->size;
st = ic->streams[pkt->stream_index];
if (pkt->pts != AV_NOPTS_VALUE) {
end_time = pkt->pts;
duration = end_time - st->start_time;
if (duration > 0) {
if (st->duration == AV_NOPTS_VALUE ||
st->duration < duration)
st->duration = duration;
}
}
av_free_packet(pkt);
}
fill_all_stream_timings(ic);
url_fseek(&ic->pb, old_offset, SEEK_SET);
for(i=0; i<ic->nb_streams; i++){
st= ic->streams[i];
st->cur_dts= st->first_dts;
}
}
| false
|
FFmpeg
|
bf494092b03f107e35ab6ad70be324f23a193c2b
|
static void av_estimate_timings_from_pts(AVFormatContext *ic, offset_t old_offset)
{
AVPacket pkt1, *pkt = &pkt1;
AVStream *st;
int read_size, i, ret;
int64_t end_time;
int64_t filesize, offset, duration;
if (ic->cur_st && ic->cur_st->parser)
av_free_packet(&ic->cur_pkt);
ic->cur_st = NULL;
flush_packet_queue(ic);
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
if (st->parser) {
av_parser_close(st->parser);
st->parser= NULL;
}
}
url_fseek(&ic->pb, 0, SEEK_SET);
read_size = 0;
for(;;) {
if (read_size >= DURATION_MAX_READ_SIZE)
break;
for(i = 0;i < ic->nb_streams; i++) {
st = ic->streams[i];
if (st->start_time == AV_NOPTS_VALUE)
break;
}
if (i == ic->nb_streams)
break;
ret = av_read_packet(ic, pkt);
if (ret != 0)
break;
read_size += pkt->size;
st = ic->streams[pkt->stream_index];
if (pkt->pts != AV_NOPTS_VALUE) {
if (st->start_time == AV_NOPTS_VALUE)
st->start_time = pkt->pts;
}
av_free_packet(pkt);
}
filesize = ic->file_size;
offset = filesize - DURATION_MAX_READ_SIZE;
if (offset < 0)
offset = 0;
url_fseek(&ic->pb, offset, SEEK_SET);
read_size = 0;
for(;;) {
if (read_size >= DURATION_MAX_READ_SIZE)
break;
for(i = 0;i < ic->nb_streams; i++) {
st = ic->streams[i];
if (st->duration == AV_NOPTS_VALUE)
break;
}
if (i == ic->nb_streams)
break;
ret = av_read_packet(ic, pkt);
if (ret != 0)
break;
read_size += pkt->size;
st = ic->streams[pkt->stream_index];
if (pkt->pts != AV_NOPTS_VALUE) {
end_time = pkt->pts;
duration = end_time - st->start_time;
if (duration > 0) {
if (st->duration == AV_NOPTS_VALUE ||
st->duration < duration)
st->duration = duration;
}
}
av_free_packet(pkt);
}
fill_all_stream_timings(ic);
url_fseek(&ic->pb, old_offset, SEEK_SET);
for(i=0; i<ic->nb_streams; i++){
st= ic->streams[i];
st->cur_dts= st->first_dts;
}
}
|
{
"code": [],
"line_no": []
}
|
static void FUNC_0(AVFormatContext *VAR_0, offset_t VAR_1)
{
AVPacket pkt1, *pkt = &pkt1;
AVStream *st;
int VAR_2, VAR_3, VAR_4;
int64_t end_time;
int64_t filesize, offset, duration;
if (VAR_0->cur_st && VAR_0->cur_st->parser)
av_free_packet(&VAR_0->cur_pkt);
VAR_0->cur_st = NULL;
flush_packet_queue(VAR_0);
for(VAR_3=0;VAR_3<VAR_0->nb_streams;VAR_3++) {
st = VAR_0->streams[VAR_3];
if (st->parser) {
av_parser_close(st->parser);
st->parser= NULL;
}
}
url_fseek(&VAR_0->pb, 0, SEEK_SET);
VAR_2 = 0;
for(;;) {
if (VAR_2 >= DURATION_MAX_READ_SIZE)
break;
for(VAR_3 = 0;VAR_3 < VAR_0->nb_streams; VAR_3++) {
st = VAR_0->streams[VAR_3];
if (st->start_time == AV_NOPTS_VALUE)
break;
}
if (VAR_3 == VAR_0->nb_streams)
break;
VAR_4 = av_read_packet(VAR_0, pkt);
if (VAR_4 != 0)
break;
VAR_2 += pkt->size;
st = VAR_0->streams[pkt->stream_index];
if (pkt->pts != AV_NOPTS_VALUE) {
if (st->start_time == AV_NOPTS_VALUE)
st->start_time = pkt->pts;
}
av_free_packet(pkt);
}
filesize = VAR_0->file_size;
offset = filesize - DURATION_MAX_READ_SIZE;
if (offset < 0)
offset = 0;
url_fseek(&VAR_0->pb, offset, SEEK_SET);
VAR_2 = 0;
for(;;) {
if (VAR_2 >= DURATION_MAX_READ_SIZE)
break;
for(VAR_3 = 0;VAR_3 < VAR_0->nb_streams; VAR_3++) {
st = VAR_0->streams[VAR_3];
if (st->duration == AV_NOPTS_VALUE)
break;
}
if (VAR_3 == VAR_0->nb_streams)
break;
VAR_4 = av_read_packet(VAR_0, pkt);
if (VAR_4 != 0)
break;
VAR_2 += pkt->size;
st = VAR_0->streams[pkt->stream_index];
if (pkt->pts != AV_NOPTS_VALUE) {
end_time = pkt->pts;
duration = end_time - st->start_time;
if (duration > 0) {
if (st->duration == AV_NOPTS_VALUE ||
st->duration < duration)
st->duration = duration;
}
}
av_free_packet(pkt);
}
fill_all_stream_timings(VAR_0);
url_fseek(&VAR_0->pb, VAR_1, SEEK_SET);
for(VAR_3=0; VAR_3<VAR_0->nb_streams; VAR_3++){
st= VAR_0->streams[VAR_3];
st->cur_dts= st->first_dts;
}
}
|
[
"static void FUNC_0(AVFormatContext *VAR_0, offset_t VAR_1)\n{",
"AVPacket pkt1, *pkt = &pkt1;",
"AVStream *st;",
"int VAR_2, VAR_3, VAR_4;",
"int64_t end_time;",
"int64_t filesize, offset, duration;",
"if (VAR_0->cur_st && VAR_0->cur_st->parser)\nav_free_packet(&VAR_0->cur_pkt);",
"VAR_0->cur_st = NULL;",
"flush_packet_queue(VAR_0);",
"for(VAR_3=0;VAR_3<VAR_0->nb_streams;VAR_3++) {",
"st = VAR_0->streams[VAR_3];",
"if (st->parser) {",
"av_parser_close(st->parser);",
"st->parser= NULL;",
"}",
"}",
"url_fseek(&VAR_0->pb, 0, SEEK_SET);",
"VAR_2 = 0;",
"for(;;) {",
"if (VAR_2 >= DURATION_MAX_READ_SIZE)\nbreak;",
"for(VAR_3 = 0;VAR_3 < VAR_0->nb_streams; VAR_3++) {",
"st = VAR_0->streams[VAR_3];",
"if (st->start_time == AV_NOPTS_VALUE)\nbreak;",
"}",
"if (VAR_3 == VAR_0->nb_streams)\nbreak;",
"VAR_4 = av_read_packet(VAR_0, pkt);",
"if (VAR_4 != 0)\nbreak;",
"VAR_2 += pkt->size;",
"st = VAR_0->streams[pkt->stream_index];",
"if (pkt->pts != AV_NOPTS_VALUE) {",
"if (st->start_time == AV_NOPTS_VALUE)\nst->start_time = pkt->pts;",
"}",
"av_free_packet(pkt);",
"}",
"filesize = VAR_0->file_size;",
"offset = filesize - DURATION_MAX_READ_SIZE;",
"if (offset < 0)\noffset = 0;",
"url_fseek(&VAR_0->pb, offset, SEEK_SET);",
"VAR_2 = 0;",
"for(;;) {",
"if (VAR_2 >= DURATION_MAX_READ_SIZE)\nbreak;",
"for(VAR_3 = 0;VAR_3 < VAR_0->nb_streams; VAR_3++) {",
"st = VAR_0->streams[VAR_3];",
"if (st->duration == AV_NOPTS_VALUE)\nbreak;",
"}",
"if (VAR_3 == VAR_0->nb_streams)\nbreak;",
"VAR_4 = av_read_packet(VAR_0, pkt);",
"if (VAR_4 != 0)\nbreak;",
"VAR_2 += pkt->size;",
"st = VAR_0->streams[pkt->stream_index];",
"if (pkt->pts != AV_NOPTS_VALUE) {",
"end_time = pkt->pts;",
"duration = end_time - st->start_time;",
"if (duration > 0) {",
"if (st->duration == AV_NOPTS_VALUE ||\nst->duration < duration)\nst->duration = duration;",
"}",
"}",
"av_free_packet(pkt);",
"}",
"fill_all_stream_timings(VAR_0);",
"url_fseek(&VAR_0->pb, VAR_1, SEEK_SET);",
"for(VAR_3=0; VAR_3<VAR_0->nb_streams; VAR_3++){",
"st= VAR_0->streams[VAR_3];",
"st->cur_dts= st->first_dts;",
"}",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
19,
21
],
[
23
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75,
77
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
91
],
[
93,
95
],
[
97
],
[
99
],
[
101
],
[
109
],
[
111
],
[
113,
115
],
[
119
],
[
121
],
[
123
],
[
125,
127
],
[
131
],
[
133
],
[
135,
137
],
[
139
],
[
141,
143
],
[
147
],
[
149,
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165,
167,
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
181
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
]
] |
12,935
|
static inline void RENAME(rgb32tobgr16)(const uint8_t *src, uint8_t *dst, unsigned int src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_16mask),"m"(green_16mask));
mm_end = end - 15;
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 4%1, %%mm3\n\t"
"punpckldq 8%1, %%mm0\n\t"
"punpckldq 12%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psllq $8, %%mm0\n\t"
"psllq $8, %%mm3\n\t"
"pand %%mm7, %%mm0\n\t"
"pand %%mm7, %%mm3\n\t"
"psrlq $5, %%mm1\n\t"
"psrlq $5, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $19, %%mm2\n\t"
"psrlq $19, %%mm5\n\t"
"pand %2, %%mm2\n\t"
"pand %2, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*s),"m"(blue_16mask):"memory");
d += 4;
s += 16;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
const int src= *((uint32_t*)s)++;
*d++ = ((src&0xF8)<<8) + ((src&0xFC00)>>5) + ((src&0xF80000)>>19);
}
}
| false
|
FFmpeg
|
ae4cffd9fc5bc495692920d646d7d1462315cfa6
|
static inline void RENAME(rgb32tobgr16)(const uint8_t *src, uint8_t *dst, unsigned int src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_16mask),"m"(green_16mask));
mm_end = end - 15;
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 4%1, %%mm3\n\t"
"punpckldq 8%1, %%mm0\n\t"
"punpckldq 12%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psllq $8, %%mm0\n\t"
"psllq $8, %%mm3\n\t"
"pand %%mm7, %%mm0\n\t"
"pand %%mm7, %%mm3\n\t"
"psrlq $5, %%mm1\n\t"
"psrlq $5, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $19, %%mm2\n\t"
"psrlq $19, %%mm5\n\t"
"pand %2, %%mm2\n\t"
"pand %2, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*s),"m"(blue_16mask):"memory");
d += 4;
s += 16;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
const int src= *((uint32_t*)s)++;
*d++ = ((src&0xF8)<<8) + ((src&0xFC00)>>5) + ((src&0xF80000)>>19);
}
}
|
{
"code": [],
"line_no": []
}
|
static inline void FUNC_0(rgb32tobgr16)(const uint8_t *VAR_2, uint8_t *dst, unsigned int src_size)
{
const uint8_t *VAR_0 = VAR_2;
const uint8_t *VAR_1;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
VAR_1 = VAR_0 + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*VAR_2):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_16mask),"m"(green_16mask));
mm_end = VAR_1 - 15;
while(VAR_0 < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 4%1, %%mm3\n\t"
"punpckldq 8%1, %%mm0\n\t"
"punpckldq 12%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psllq $8, %%mm0\n\t"
"psllq $8, %%mm3\n\t"
"pand %%mm7, %%mm0\n\t"
"pand %%mm7, %%mm3\n\t"
"psrlq $5, %%mm1\n\t"
"psrlq $5, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $19, %%mm2\n\t"
"psrlq $19, %%mm5\n\t"
"pand %2, %%mm2\n\t"
"pand %2, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*VAR_0),"m"(blue_16mask):"memory");
d += 4;
VAR_0 += 16;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(VAR_0 < VAR_1)
{
const int VAR_2= *((uint32_t*)VAR_0)++;
*d++ = ((VAR_2&0xF8)<<8) + ((VAR_2&0xFC00)>>5) + ((VAR_2&0xF80000)>>19);
}
}
|
[
"static inline void FUNC_0(rgb32tobgr16)(const uint8_t *VAR_2, uint8_t *dst, unsigned int src_size)\n{",
"const uint8_t *VAR_0 = VAR_2;",
"const uint8_t *VAR_1;",
"#ifdef HAVE_MMX\nconst uint8_t *mm_end;",
"#endif\nuint16_t *d = (uint16_t *)dst;",
"VAR_1 = VAR_0 + src_size;",
"#ifdef HAVE_MMX\n__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*VAR_2):\"memory\");",
"__asm __volatile(\n\"movq\t%0, %%mm7\\n\\t\"\n\"movq\t%1, %%mm6\\n\\t\"\n::\"m\"(red_16mask),\"m\"(green_16mask));",
"mm_end = VAR_1 - 15;",
"while(VAR_0 < mm_end)\n{",
"__asm __volatile(\nPREFETCH\" 32%1\\n\\t\"\n\"movd\t%1, %%mm0\\n\\t\"\n\"movd\t4%1, %%mm3\\n\\t\"\n\"punpckldq 8%1, %%mm0\\n\\t\"\n\"punpckldq 12%1, %%mm3\\n\\t\"\n\"movq\t%%mm0, %%mm1\\n\\t\"\n\"movq\t%%mm0, %%mm2\\n\\t\"\n\"movq\t%%mm3, %%mm4\\n\\t\"\n\"movq\t%%mm3, %%mm5\\n\\t\"\n\"psllq\t$8, %%mm0\\n\\t\"\n\"psllq\t$8, %%mm3\\n\\t\"\n\"pand\t%%mm7, %%mm0\\n\\t\"\n\"pand\t%%mm7, %%mm3\\n\\t\"\n\"psrlq\t$5, %%mm1\\n\\t\"\n\"psrlq\t$5, %%mm4\\n\\t\"\n\"pand\t%%mm6, %%mm1\\n\\t\"\n\"pand\t%%mm6, %%mm4\\n\\t\"\n\"psrlq\t$19, %%mm2\\n\\t\"\n\"psrlq\t$19, %%mm5\\n\\t\"\n\"pand\t%2, %%mm2\\n\\t\"\n\"pand\t%2, %%mm5\\n\\t\"\n\"por\t%%mm1, %%mm0\\n\\t\"\n\"por\t%%mm4, %%mm3\\n\\t\"\n\"por\t%%mm2, %%mm0\\n\\t\"\n\"por\t%%mm5, %%mm3\\n\\t\"\n\"psllq\t$16, %%mm3\\n\\t\"\n\"por\t%%mm3, %%mm0\\n\\t\"\nMOVNTQ\"\t%%mm0, %0\\n\\t\"\n:\"=m\"(*d):\"m\"(*VAR_0),\"m\"(blue_16mask):\"memory\");",
"d += 4;",
"VAR_0 += 16;",
"}",
"__asm __volatile(SFENCE:::\"memory\");",
"__asm __volatile(EMMS:::\"memory\");",
"#endif\nwhile(VAR_0 < VAR_1)\n{",
"const int VAR_2= *((uint32_t*)VAR_0)++;",
"*d++ = ((VAR_2&0xF8)<<8) + ((VAR_2&0xFC00)>>5) + ((VAR_2&0xF80000)>>19);",
"}",
"}"
] |
[
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
]
] |
12,937
|
static int dv_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
RawDVContext *c = s->priv_data;
c->dv_demux = dv_init_demux(s);
return c->dv_demux ? 0 : -1;
}
| false
|
FFmpeg
|
c4e554701ec27b31b1b6396130b8bb2aaa0d4ad0
|
static int dv_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
RawDVContext *c = s->priv_data;
c->dv_demux = dv_init_demux(s);
return c->dv_demux ? 0 : -1;
}
|
{
"code": [],
"line_no": []
}
|
static int FUNC_0(AVFormatContext *VAR_0,
AVFormatParameters *VAR_1)
{
RawDVContext *c = VAR_0->priv_data;
c->dv_demux = dv_init_demux(VAR_0);
return c->dv_demux ? 0 : -1;
}
|
[
"static int FUNC_0(AVFormatContext *VAR_0,\nAVFormatParameters *VAR_1)\n{",
"RawDVContext *c = VAR_0->priv_data;",
"c->dv_demux = dv_init_demux(VAR_0);",
"return c->dv_demux ? 0 : -1;",
"}"
] |
[
0,
0,
0,
0,
0
] |
[
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
]
] |
12,939
|
static void vfio_map_bar(VFIOPCIDevice *vdev, int nr)
{
VFIOBAR *bar = &vdev->bars[nr];
uint64_t size = bar->region.size;
char name[64];
uint32_t pci_bar;
uint8_t type;
int ret;
/* Skip both unimplemented BARs and the upper half of 64bit BARS. */
if (!size) {
return;
}
snprintf(name, sizeof(name), "VFIO %04x:%02x:%02x.%x BAR %d",
vdev->host.domain, vdev->host.bus, vdev->host.slot,
vdev->host.function, nr);
/* Determine what type of BAR this is for registration */
ret = pread(vdev->vbasedev.fd, &pci_bar, sizeof(pci_bar),
vdev->config_offset + PCI_BASE_ADDRESS_0 + (4 * nr));
if (ret != sizeof(pci_bar)) {
error_report("vfio: Failed to read BAR %d (%m)", nr);
return;
}
pci_bar = le32_to_cpu(pci_bar);
bar->ioport = (pci_bar & PCI_BASE_ADDRESS_SPACE_IO);
bar->mem64 = bar->ioport ? 0 : (pci_bar & PCI_BASE_ADDRESS_MEM_TYPE_64);
type = pci_bar & (bar->ioport ? ~PCI_BASE_ADDRESS_IO_MASK :
~PCI_BASE_ADDRESS_MEM_MASK);
/* A "slow" read/write mapping underlies all BARs */
memory_region_init_io(&bar->region.mem, OBJECT(vdev), &vfio_region_ops,
bar, name, size);
pci_register_bar(&vdev->pdev, nr, type, &bar->region.mem);
/*
* We can't mmap areas overlapping the MSIX vector table, so we
* potentially insert a direct-mapped subregion before and after it.
*/
if (vdev->msix && vdev->msix->table_bar == nr) {
size = vdev->msix->table_offset & qemu_host_page_mask;
}
strncat(name, " mmap", sizeof(name) - strlen(name) - 1);
if (vfio_mmap_region(OBJECT(vdev), &bar->region, &bar->region.mem,
&bar->region.mmap_mem, &bar->region.mmap,
size, 0, name)) {
error_report("%s unsupported. Performance may be slow", name);
}
if (vdev->msix && vdev->msix->table_bar == nr) {
uint64_t start;
start = HOST_PAGE_ALIGN(vdev->msix->table_offset +
(vdev->msix->entries * PCI_MSIX_ENTRY_SIZE));
size = start < bar->region.size ? bar->region.size - start : 0;
strncat(name, " msix-hi", sizeof(name) - strlen(name) - 1);
/* VFIOMSIXInfo contains another MemoryRegion for this mapping */
if (vfio_mmap_region(OBJECT(vdev), &bar->region, &bar->region.mem,
&vdev->msix->mmap_mem,
&vdev->msix->mmap, size, start, name)) {
error_report("%s unsupported. Performance may be slow", name);
}
}
vfio_bar_quirk_setup(vdev, nr);
}
| true
|
qemu
|
07ceaf98800519ef9c5dc893af00f1fe1f9144e4
|
static void vfio_map_bar(VFIOPCIDevice *vdev, int nr)
{
VFIOBAR *bar = &vdev->bars[nr];
uint64_t size = bar->region.size;
char name[64];
uint32_t pci_bar;
uint8_t type;
int ret;
if (!size) {
return;
}
snprintf(name, sizeof(name), "VFIO %04x:%02x:%02x.%x BAR %d",
vdev->host.domain, vdev->host.bus, vdev->host.slot,
vdev->host.function, nr);
ret = pread(vdev->vbasedev.fd, &pci_bar, sizeof(pci_bar),
vdev->config_offset + PCI_BASE_ADDRESS_0 + (4 * nr));
if (ret != sizeof(pci_bar)) {
error_report("vfio: Failed to read BAR %d (%m)", nr);
return;
}
pci_bar = le32_to_cpu(pci_bar);
bar->ioport = (pci_bar & PCI_BASE_ADDRESS_SPACE_IO);
bar->mem64 = bar->ioport ? 0 : (pci_bar & PCI_BASE_ADDRESS_MEM_TYPE_64);
type = pci_bar & (bar->ioport ? ~PCI_BASE_ADDRESS_IO_MASK :
~PCI_BASE_ADDRESS_MEM_MASK);
memory_region_init_io(&bar->region.mem, OBJECT(vdev), &vfio_region_ops,
bar, name, size);
pci_register_bar(&vdev->pdev, nr, type, &bar->region.mem);
if (vdev->msix && vdev->msix->table_bar == nr) {
size = vdev->msix->table_offset & qemu_host_page_mask;
}
strncat(name, " mmap", sizeof(name) - strlen(name) - 1);
if (vfio_mmap_region(OBJECT(vdev), &bar->region, &bar->region.mem,
&bar->region.mmap_mem, &bar->region.mmap,
size, 0, name)) {
error_report("%s unsupported. Performance may be slow", name);
}
if (vdev->msix && vdev->msix->table_bar == nr) {
uint64_t start;
start = HOST_PAGE_ALIGN(vdev->msix->table_offset +
(vdev->msix->entries * PCI_MSIX_ENTRY_SIZE));
size = start < bar->region.size ? bar->region.size - start : 0;
strncat(name, " msix-hi", sizeof(name) - strlen(name) - 1);
if (vfio_mmap_region(OBJECT(vdev), &bar->region, &bar->region.mem,
&vdev->msix->mmap_mem,
&vdev->msix->mmap, size, start, name)) {
error_report("%s unsupported. Performance may be slow", name);
}
}
vfio_bar_quirk_setup(vdev, nr);
}
|
{
"code": [
" start = HOST_PAGE_ALIGN(vdev->msix->table_offset +"
],
"line_no": [
111
]
}
|
static void FUNC_0(VFIOPCIDevice *VAR_0, int VAR_1)
{
VFIOBAR *bar = &VAR_0->bars[VAR_1];
uint64_t size = bar->region.size;
char VAR_2[64];
uint32_t pci_bar;
uint8_t type;
int VAR_3;
if (!size) {
return;
}
snprintf(VAR_2, sizeof(VAR_2), "VFIO %04x:%02x:%02x.%x BAR %d",
VAR_0->host.domain, VAR_0->host.bus, VAR_0->host.slot,
VAR_0->host.function, VAR_1);
VAR_3 = pread(VAR_0->vbasedev.fd, &pci_bar, sizeof(pci_bar),
VAR_0->config_offset + PCI_BASE_ADDRESS_0 + (4 * VAR_1));
if (VAR_3 != sizeof(pci_bar)) {
error_report("vfio: Failed to read BAR %d (%m)", VAR_1);
return;
}
pci_bar = le32_to_cpu(pci_bar);
bar->ioport = (pci_bar & PCI_BASE_ADDRESS_SPACE_IO);
bar->mem64 = bar->ioport ? 0 : (pci_bar & PCI_BASE_ADDRESS_MEM_TYPE_64);
type = pci_bar & (bar->ioport ? ~PCI_BASE_ADDRESS_IO_MASK :
~PCI_BASE_ADDRESS_MEM_MASK);
memory_region_init_io(&bar->region.mem, OBJECT(VAR_0), &vfio_region_ops,
bar, VAR_2, size);
pci_register_bar(&VAR_0->pdev, VAR_1, type, &bar->region.mem);
if (VAR_0->msix && VAR_0->msix->table_bar == VAR_1) {
size = VAR_0->msix->table_offset & qemu_host_page_mask;
}
strncat(VAR_2, " mmap", sizeof(VAR_2) - strlen(VAR_2) - 1);
if (vfio_mmap_region(OBJECT(VAR_0), &bar->region, &bar->region.mem,
&bar->region.mmap_mem, &bar->region.mmap,
size, 0, VAR_2)) {
error_report("%s unsupported. Performance may be slow", VAR_2);
}
if (VAR_0->msix && VAR_0->msix->table_bar == VAR_1) {
uint64_t start;
start = HOST_PAGE_ALIGN(VAR_0->msix->table_offset +
(VAR_0->msix->entries * PCI_MSIX_ENTRY_SIZE));
size = start < bar->region.size ? bar->region.size - start : 0;
strncat(VAR_2, " msix-hi", sizeof(VAR_2) - strlen(VAR_2) - 1);
if (vfio_mmap_region(OBJECT(VAR_0), &bar->region, &bar->region.mem,
&VAR_0->msix->mmap_mem,
&VAR_0->msix->mmap, size, start, VAR_2)) {
error_report("%s unsupported. Performance may be slow", VAR_2);
}
}
vfio_bar_quirk_setup(VAR_0, VAR_1);
}
|
[
"static void FUNC_0(VFIOPCIDevice *VAR_0, int VAR_1)\n{",
"VFIOBAR *bar = &VAR_0->bars[VAR_1];",
"uint64_t size = bar->region.size;",
"char VAR_2[64];",
"uint32_t pci_bar;",
"uint8_t type;",
"int VAR_3;",
"if (!size) {",
"return;",
"}",
"snprintf(VAR_2, sizeof(VAR_2), \"VFIO %04x:%02x:%02x.%x BAR %d\",\nVAR_0->host.domain, VAR_0->host.bus, VAR_0->host.slot,\nVAR_0->host.function, VAR_1);",
"VAR_3 = pread(VAR_0->vbasedev.fd, &pci_bar, sizeof(pci_bar),\nVAR_0->config_offset + PCI_BASE_ADDRESS_0 + (4 * VAR_1));",
"if (VAR_3 != sizeof(pci_bar)) {",
"error_report(\"vfio: Failed to read BAR %d (%m)\", VAR_1);",
"return;",
"}",
"pci_bar = le32_to_cpu(pci_bar);",
"bar->ioport = (pci_bar & PCI_BASE_ADDRESS_SPACE_IO);",
"bar->mem64 = bar->ioport ? 0 : (pci_bar & PCI_BASE_ADDRESS_MEM_TYPE_64);",
"type = pci_bar & (bar->ioport ? ~PCI_BASE_ADDRESS_IO_MASK :\n~PCI_BASE_ADDRESS_MEM_MASK);",
"memory_region_init_io(&bar->region.mem, OBJECT(VAR_0), &vfio_region_ops,\nbar, VAR_2, size);",
"pci_register_bar(&VAR_0->pdev, VAR_1, type, &bar->region.mem);",
"if (VAR_0->msix && VAR_0->msix->table_bar == VAR_1) {",
"size = VAR_0->msix->table_offset & qemu_host_page_mask;",
"}",
"strncat(VAR_2, \" mmap\", sizeof(VAR_2) - strlen(VAR_2) - 1);",
"if (vfio_mmap_region(OBJECT(VAR_0), &bar->region, &bar->region.mem,\n&bar->region.mmap_mem, &bar->region.mmap,\nsize, 0, VAR_2)) {",
"error_report(\"%s unsupported. Performance may be slow\", VAR_2);",
"}",
"if (VAR_0->msix && VAR_0->msix->table_bar == VAR_1) {",
"uint64_t start;",
"start = HOST_PAGE_ALIGN(VAR_0->msix->table_offset +\n(VAR_0->msix->entries * PCI_MSIX_ENTRY_SIZE));",
"size = start < bar->region.size ? bar->region.size - start : 0;",
"strncat(VAR_2, \" msix-hi\", sizeof(VAR_2) - strlen(VAR_2) - 1);",
"if (vfio_mmap_region(OBJECT(VAR_0), &bar->region, &bar->region.mem,\n&VAR_0->msix->mmap_mem,\n&VAR_0->msix->mmap, size, start, VAR_2)) {",
"error_report(\"%s unsupported. Performance may be slow\", VAR_2);",
"}",
"}",
"vfio_bar_quirk_setup(VAR_0, 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,
1,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
21
],
[
23
],
[
25
],
[
29,
31,
33
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
67,
69
],
[
71
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93,
95,
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
111,
113
],
[
117
],
[
119
],
[
123,
125,
127
],
[
129
],
[
131
],
[
133
],
[
137
],
[
139
]
] |
12,941
|
static void cpu_common_reset(CPUState *cpu)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
int i;
if (qemu_loglevel_mask(CPU_LOG_RESET)) {
qemu_log("CPU Reset (CPU %d)\n", cpu->cpu_index);
log_cpu_state(cpu, cc->reset_dump_flags);
}
cpu->interrupt_request = 0;
cpu->halted = 0;
cpu->mem_io_pc = 0;
cpu->mem_io_vaddr = 0;
cpu->icount_extra = 0;
cpu->icount_decr.u32 = 0;
cpu->can_do_io = 1;
cpu->exception_index = -1;
cpu->crash_occurred = false;
if (tcg_enabled()) {
for (i = 0; i < TB_JMP_CACHE_SIZE; ++i) {
atomic_set(&cpu->tb_jmp_cache[i], NULL);
}
#ifdef CONFIG_SOFTMMU
tlb_flush(cpu, 0);
#endif
}
}
| true
|
qemu
|
f3ced3c59287dabc253f83f0c70aa4934470c15e
|
static void cpu_common_reset(CPUState *cpu)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
int i;
if (qemu_loglevel_mask(CPU_LOG_RESET)) {
qemu_log("CPU Reset (CPU %d)\n", cpu->cpu_index);
log_cpu_state(cpu, cc->reset_dump_flags);
}
cpu->interrupt_request = 0;
cpu->halted = 0;
cpu->mem_io_pc = 0;
cpu->mem_io_vaddr = 0;
cpu->icount_extra = 0;
cpu->icount_decr.u32 = 0;
cpu->can_do_io = 1;
cpu->exception_index = -1;
cpu->crash_occurred = false;
if (tcg_enabled()) {
for (i = 0; i < TB_JMP_CACHE_SIZE; ++i) {
atomic_set(&cpu->tb_jmp_cache[i], NULL);
}
#ifdef CONFIG_SOFTMMU
tlb_flush(cpu, 0);
#endif
}
}
|
{
"code": [
" for (i = 0; i < TB_JMP_CACHE_SIZE; ++i) {",
" atomic_set(&cpu->tb_jmp_cache[i], NULL);",
" int i;",
" for (i = 0; i < TB_JMP_CACHE_SIZE; ++i) {",
" atomic_set(&cpu->tb_jmp_cache[i], NULL);"
],
"line_no": [
43,
45,
7,
43,
45
]
}
|
static void FUNC_0(CPUState *VAR_0)
{
CPUClass *cc = CPU_GET_CLASS(VAR_0);
int VAR_1;
if (qemu_loglevel_mask(CPU_LOG_RESET)) {
qemu_log("CPU Reset (CPU %d)\n", VAR_0->cpu_index);
log_cpu_state(VAR_0, cc->reset_dump_flags);
}
VAR_0->interrupt_request = 0;
VAR_0->halted = 0;
VAR_0->mem_io_pc = 0;
VAR_0->mem_io_vaddr = 0;
VAR_0->icount_extra = 0;
VAR_0->icount_decr.u32 = 0;
VAR_0->can_do_io = 1;
VAR_0->exception_index = -1;
VAR_0->crash_occurred = false;
if (tcg_enabled()) {
for (VAR_1 = 0; VAR_1 < TB_JMP_CACHE_SIZE; ++VAR_1) {
atomic_set(&VAR_0->tb_jmp_cache[VAR_1], NULL);
}
#ifdef CONFIG_SOFTMMU
tlb_flush(VAR_0, 0);
#endif
}
}
|
[
"static void FUNC_0(CPUState *VAR_0)\n{",
"CPUClass *cc = CPU_GET_CLASS(VAR_0);",
"int VAR_1;",
"if (qemu_loglevel_mask(CPU_LOG_RESET)) {",
"qemu_log(\"CPU Reset (CPU %d)\\n\", VAR_0->cpu_index);",
"log_cpu_state(VAR_0, cc->reset_dump_flags);",
"}",
"VAR_0->interrupt_request = 0;",
"VAR_0->halted = 0;",
"VAR_0->mem_io_pc = 0;",
"VAR_0->mem_io_vaddr = 0;",
"VAR_0->icount_extra = 0;",
"VAR_0->icount_decr.u32 = 0;",
"VAR_0->can_do_io = 1;",
"VAR_0->exception_index = -1;",
"VAR_0->crash_occurred = false;",
"if (tcg_enabled()) {",
"for (VAR_1 = 0; VAR_1 < TB_JMP_CACHE_SIZE; ++VAR_1) {",
"atomic_set(&VAR_0->tb_jmp_cache[VAR_1], NULL);",
"}",
"#ifdef CONFIG_SOFTMMU\ntlb_flush(VAR_0, 0);",
"#endif\n}",
"}"
] |
[
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51,
53
],
[
55,
57
],
[
59
]
] |
12,942
|
static void string_output_append_range(StringOutputVisitor *sov,
int64_t s, int64_t e)
{
Range *r = g_malloc0(sizeof(*r));
r->begin = s;
r->end = e + 1;
sov->ranges = g_list_insert_sorted_merged(sov->ranges, r, range_compare);
}
| true
|
qemu
|
7c47959d0cb05db43014141a156ada0b6d53a750
|
static void string_output_append_range(StringOutputVisitor *sov,
int64_t s, int64_t e)
{
Range *r = g_malloc0(sizeof(*r));
r->begin = s;
r->end = e + 1;
sov->ranges = g_list_insert_sorted_merged(sov->ranges, r, range_compare);
}
|
{
"code": [
" sov->ranges = g_list_insert_sorted_merged(sov->ranges, r, range_compare);",
" sov->ranges = g_list_insert_sorted_merged(sov->ranges, r, range_compare);"
],
"line_no": [
13,
13
]
}
|
static void FUNC_0(StringOutputVisitor *VAR_0,
int64_t VAR_1, int64_t VAR_2)
{
Range *r = g_malloc0(sizeof(*r));
r->begin = VAR_1;
r->end = VAR_2 + 1;
VAR_0->ranges = g_list_insert_sorted_merged(VAR_0->ranges, r, range_compare);
}
|
[
"static void FUNC_0(StringOutputVisitor *VAR_0,\nint64_t VAR_1, int64_t VAR_2)\n{",
"Range *r = g_malloc0(sizeof(*r));",
"r->begin = VAR_1;",
"r->end = VAR_2 + 1;",
"VAR_0->ranges = g_list_insert_sorted_merged(VAR_0->ranges, r, range_compare);",
"}"
] |
[
0,
0,
0,
0,
1,
0
] |
[
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
12,943
|
int ff_rtsp_connect(AVFormatContext *s)
{
RTSPState *rt = s->priv_data;
char host[1024], path[1024], tcpname[1024], cmd[2048], auth[128];
char *option_list, *option, *filename;
URLContext *rtsp_hd, *rtsp_hd_out;
int port, err, tcp_fd;
RTSPMessageHeader reply1 = {}, *reply = &reply1;
int lower_transport_mask = 0;
char real_challenge[64];
struct sockaddr_storage peer;
socklen_t peer_len = sizeof(peer);
if (!ff_network_init())
return AVERROR(EIO);
redirect:
rt->control_transport = RTSP_MODE_PLAIN;
/* extract hostname and port */
ff_url_split(NULL, 0, auth, sizeof(auth),
host, sizeof(host), &port, path, sizeof(path), s->filename);
if (*auth) {
av_strlcpy(rt->auth, auth, sizeof(rt->auth));
}
if (port < 0)
port = RTSP_DEFAULT_PORT;
/* search for options */
option_list = strrchr(path, '?');
if (option_list) {
/* Strip out the RTSP specific options, write out the rest of
* the options back into the same string. */
filename = option_list;
while (option_list) {
/* move the option pointer */
option = ++option_list;
option_list = strchr(option_list, '&');
if (option_list)
*option_list = 0;
/* handle the options */
if (!strcmp(option, "udp")) {
lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_UDP);
} else if (!strcmp(option, "multicast")) {
lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_UDP_MULTICAST);
} else if (!strcmp(option, "tcp")) {
lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_TCP);
} else if(!strcmp(option, "http")) {
lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_TCP);
rt->control_transport = RTSP_MODE_TUNNEL;
} else {
/* Write options back into the buffer, using memmove instead
* of strcpy since the strings may overlap. */
int len = strlen(option);
memmove(++filename, option, len);
filename += len;
if (option_list) *filename = '&';
}
}
*filename = 0;
}
if (!lower_transport_mask)
lower_transport_mask = (1 << RTSP_LOWER_TRANSPORT_NB) - 1;
if (s->oformat) {
/* Only UDP or TCP - UDP multicast isn't supported. */
lower_transport_mask &= (1 << RTSP_LOWER_TRANSPORT_UDP) |
(1 << RTSP_LOWER_TRANSPORT_TCP);
if (!lower_transport_mask || rt->control_transport == RTSP_MODE_TUNNEL) {
av_log(s, AV_LOG_ERROR, "Unsupported lower transport method, "
"only UDP and TCP are supported for output.\n");
err = AVERROR(EINVAL);
goto fail;
}
}
/* Construct the URI used in request; this is similar to s->filename,
* but with authentication credentials removed and RTSP specific options
* stripped out. */
ff_url_join(rt->control_uri, sizeof(rt->control_uri), "rtsp", NULL,
host, port, "%s", path);
if (rt->control_transport == RTSP_MODE_TUNNEL) {
/* set up initial handshake for tunneling */
char httpname[1024];
char sessioncookie[17];
char headers[1024];
ff_url_join(httpname, sizeof(httpname), "http", NULL, host, port, "%s", path);
snprintf(sessioncookie, sizeof(sessioncookie), "%08x%08x",
av_get_random_seed(), av_get_random_seed());
/* GET requests */
if (url_open(&rtsp_hd, httpname, URL_RDONLY) < 0) {
err = AVERROR(EIO);
goto fail;
}
/* generate GET headers */
snprintf(headers, sizeof(headers),
"x-sessioncookie: %s\r\n"
"Accept: application/x-rtsp-tunnelled\r\n"
"Pragma: no-cache\r\n"
"Cache-Control: no-cache\r\n",
sessioncookie);
ff_http_set_headers(rtsp_hd, headers);
/* complete the connection */
if (url_read(rtsp_hd, NULL, 0)) {
err = AVERROR(EIO);
goto fail;
}
/* POST requests */
if (url_open(&rtsp_hd_out, httpname, URL_WRONLY) < 0 ) {
err = AVERROR(EIO);
goto fail;
}
/* generate POST headers */
snprintf(headers, sizeof(headers),
"x-sessioncookie: %s\r\n"
"Content-Type: application/x-rtsp-tunnelled\r\n"
"Pragma: no-cache\r\n"
"Cache-Control: no-cache\r\n"
"Content-Length: 32767\r\n"
"Expires: Sun, 9 Jan 1972 00:00:00 GMT\r\n",
sessioncookie);
ff_http_set_headers(rtsp_hd_out, headers);
ff_http_set_chunked_transfer_encoding(rtsp_hd_out, 0);
} else {
/* open the tcp connection */
ff_url_join(tcpname, sizeof(tcpname), "tcp", NULL, host, port, NULL);
if (url_open(&rtsp_hd, tcpname, URL_RDWR) < 0) {
err = AVERROR(EIO);
goto fail;
}
rtsp_hd_out = rtsp_hd;
}
rt->rtsp_hd = rtsp_hd;
rt->rtsp_hd_out = rtsp_hd_out;
rt->seq = 0;
tcp_fd = url_get_file_handle(rtsp_hd);
if (!getpeername(tcp_fd, (struct sockaddr*) &peer, &peer_len)) {
getnameinfo((struct sockaddr*) &peer, peer_len, host, sizeof(host),
NULL, 0, NI_NUMERICHOST);
}
/* request options supported by the server; this also detects server
* type */
for (rt->server_type = RTSP_SERVER_RTP;;) {
cmd[0] = 0;
if (rt->server_type == RTSP_SERVER_REAL)
av_strlcat(cmd,
/**
* The following entries are required for proper
* streaming from a Realmedia server. They are
* interdependent in some way although we currently
* don't quite understand how. Values were copied
* from mplayer SVN r23589.
* @param CompanyID is a 16-byte ID in base64
* @param ClientChallenge is a 16-byte ID in hex
*/
"ClientChallenge: 9e26d33f2984236010ef6253fb1887f7\r\n"
"PlayerStarttime: [28/03/2003:22:50:23 00:00]\r\n"
"CompanyID: KnKV4M4I/B2FjJ1TToLycw==\r\n"
"GUID: 00000000-0000-0000-0000-000000000000\r\n",
sizeof(cmd));
ff_rtsp_send_cmd(s, "OPTIONS", rt->control_uri, cmd, reply, NULL);
if (reply->status_code != RTSP_STATUS_OK) {
err = AVERROR_INVALIDDATA;
goto fail;
}
/* detect server type if not standard-compliant RTP */
if (rt->server_type != RTSP_SERVER_REAL && reply->real_challenge[0]) {
rt->server_type = RTSP_SERVER_REAL;
continue;
} else if (!strncasecmp(reply->server, "WMServer/", 9)) {
rt->server_type = RTSP_SERVER_WMS;
} else if (rt->server_type == RTSP_SERVER_REAL)
strcpy(real_challenge, reply->real_challenge);
break;
}
if (s->iformat)
err = rtsp_setup_input_streams(s, reply);
else
err = rtsp_setup_output_streams(s, host);
if (err)
goto fail;
do {
int lower_transport = ff_log2_tab[lower_transport_mask &
~(lower_transport_mask - 1)];
err = make_setup_request(s, host, port, lower_transport,
rt->server_type == RTSP_SERVER_REAL ?
real_challenge : NULL);
if (err < 0)
goto fail;
lower_transport_mask &= ~(1 << lower_transport);
if (lower_transport_mask == 0 && err == 1) {
err = FF_NETERROR(EPROTONOSUPPORT);
goto fail;
}
} while (err);
rt->state = RTSP_STATE_IDLE;
rt->seek_timestamp = 0; /* default is to start stream at position zero */
return 0;
fail:
ff_rtsp_close_streams(s);
ff_rtsp_close_connections(s);
if (reply->status_code >=300 && reply->status_code < 400 && s->iformat) {
av_strlcpy(s->filename, reply->location, sizeof(s->filename));
av_log(s, AV_LOG_INFO, "Status %d: Redirecting to %s\n",
reply->status_code,
s->filename);
goto redirect;
}
ff_network_close();
return err;
}
| true
|
FFmpeg
|
d3f84dfc0e65201983e88c99b7544d5a60d0165e
|
int ff_rtsp_connect(AVFormatContext *s)
{
RTSPState *rt = s->priv_data;
char host[1024], path[1024], tcpname[1024], cmd[2048], auth[128];
char *option_list, *option, *filename;
URLContext *rtsp_hd, *rtsp_hd_out;
int port, err, tcp_fd;
RTSPMessageHeader reply1 = {}, *reply = &reply1;
int lower_transport_mask = 0;
char real_challenge[64];
struct sockaddr_storage peer;
socklen_t peer_len = sizeof(peer);
if (!ff_network_init())
return AVERROR(EIO);
redirect:
rt->control_transport = RTSP_MODE_PLAIN;
ff_url_split(NULL, 0, auth, sizeof(auth),
host, sizeof(host), &port, path, sizeof(path), s->filename);
if (*auth) {
av_strlcpy(rt->auth, auth, sizeof(rt->auth));
}
if (port < 0)
port = RTSP_DEFAULT_PORT;
option_list = strrchr(path, '?');
if (option_list) {
filename = option_list;
while (option_list) {
option = ++option_list;
option_list = strchr(option_list, '&');
if (option_list)
*option_list = 0;
if (!strcmp(option, "udp")) {
lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_UDP);
} else if (!strcmp(option, "multicast")) {
lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_UDP_MULTICAST);
} else if (!strcmp(option, "tcp")) {
lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_TCP);
} else if(!strcmp(option, "http")) {
lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_TCP);
rt->control_transport = RTSP_MODE_TUNNEL;
} else {
int len = strlen(option);
memmove(++filename, option, len);
filename += len;
if (option_list) *filename = '&';
}
}
*filename = 0;
}
if (!lower_transport_mask)
lower_transport_mask = (1 << RTSP_LOWER_TRANSPORT_NB) - 1;
if (s->oformat) {
lower_transport_mask &= (1 << RTSP_LOWER_TRANSPORT_UDP) |
(1 << RTSP_LOWER_TRANSPORT_TCP);
if (!lower_transport_mask || rt->control_transport == RTSP_MODE_TUNNEL) {
av_log(s, AV_LOG_ERROR, "Unsupported lower transport method, "
"only UDP and TCP are supported for output.\n");
err = AVERROR(EINVAL);
goto fail;
}
}
ff_url_join(rt->control_uri, sizeof(rt->control_uri), "rtsp", NULL,
host, port, "%s", path);
if (rt->control_transport == RTSP_MODE_TUNNEL) {
char httpname[1024];
char sessioncookie[17];
char headers[1024];
ff_url_join(httpname, sizeof(httpname), "http", NULL, host, port, "%s", path);
snprintf(sessioncookie, sizeof(sessioncookie), "%08x%08x",
av_get_random_seed(), av_get_random_seed());
if (url_open(&rtsp_hd, httpname, URL_RDONLY) < 0) {
err = AVERROR(EIO);
goto fail;
}
snprintf(headers, sizeof(headers),
"x-sessioncookie: %s\r\n"
"Accept: application/x-rtsp-tunnelled\r\n"
"Pragma: no-cache\r\n"
"Cache-Control: no-cache\r\n",
sessioncookie);
ff_http_set_headers(rtsp_hd, headers);
if (url_read(rtsp_hd, NULL, 0)) {
err = AVERROR(EIO);
goto fail;
}
if (url_open(&rtsp_hd_out, httpname, URL_WRONLY) < 0 ) {
err = AVERROR(EIO);
goto fail;
}
snprintf(headers, sizeof(headers),
"x-sessioncookie: %s\r\n"
"Content-Type: application/x-rtsp-tunnelled\r\n"
"Pragma: no-cache\r\n"
"Cache-Control: no-cache\r\n"
"Content-Length: 32767\r\n"
"Expires: Sun, 9 Jan 1972 00:00:00 GMT\r\n",
sessioncookie);
ff_http_set_headers(rtsp_hd_out, headers);
ff_http_set_chunked_transfer_encoding(rtsp_hd_out, 0);
} else {
ff_url_join(tcpname, sizeof(tcpname), "tcp", NULL, host, port, NULL);
if (url_open(&rtsp_hd, tcpname, URL_RDWR) < 0) {
err = AVERROR(EIO);
goto fail;
}
rtsp_hd_out = rtsp_hd;
}
rt->rtsp_hd = rtsp_hd;
rt->rtsp_hd_out = rtsp_hd_out;
rt->seq = 0;
tcp_fd = url_get_file_handle(rtsp_hd);
if (!getpeername(tcp_fd, (struct sockaddr*) &peer, &peer_len)) {
getnameinfo((struct sockaddr*) &peer, peer_len, host, sizeof(host),
NULL, 0, NI_NUMERICHOST);
}
for (rt->server_type = RTSP_SERVER_RTP;;) {
cmd[0] = 0;
if (rt->server_type == RTSP_SERVER_REAL)
av_strlcat(cmd,
"ClientChallenge: 9e26d33f2984236010ef6253fb1887f7\r\n"
"PlayerStarttime: [28/03/2003:22:50:23 00:00]\r\n"
"CompanyID: KnKV4M4I/B2FjJ1TToLycw==\r\n"
"GUID: 00000000-0000-0000-0000-000000000000\r\n",
sizeof(cmd));
ff_rtsp_send_cmd(s, "OPTIONS", rt->control_uri, cmd, reply, NULL);
if (reply->status_code != RTSP_STATUS_OK) {
err = AVERROR_INVALIDDATA;
goto fail;
}
if (rt->server_type != RTSP_SERVER_REAL && reply->real_challenge[0]) {
rt->server_type = RTSP_SERVER_REAL;
continue;
} else if (!strncasecmp(reply->server, "WMServer/", 9)) {
rt->server_type = RTSP_SERVER_WMS;
} else if (rt->server_type == RTSP_SERVER_REAL)
strcpy(real_challenge, reply->real_challenge);
break;
}
if (s->iformat)
err = rtsp_setup_input_streams(s, reply);
else
err = rtsp_setup_output_streams(s, host);
if (err)
goto fail;
do {
int lower_transport = ff_log2_tab[lower_transport_mask &
~(lower_transport_mask - 1)];
err = make_setup_request(s, host, port, lower_transport,
rt->server_type == RTSP_SERVER_REAL ?
real_challenge : NULL);
if (err < 0)
goto fail;
lower_transport_mask &= ~(1 << lower_transport);
if (lower_transport_mask == 0 && err == 1) {
err = FF_NETERROR(EPROTONOSUPPORT);
goto fail;
}
} while (err);
rt->state = RTSP_STATE_IDLE;
rt->seek_timestamp = 0;
return 0;
fail:
ff_rtsp_close_streams(s);
ff_rtsp_close_connections(s);
if (reply->status_code >=300 && reply->status_code < 400 && s->iformat) {
av_strlcpy(s->filename, reply->location, sizeof(s->filename));
av_log(s, AV_LOG_INFO, "Status %d: Redirecting to %s\n",
reply->status_code,
s->filename);
goto redirect;
}
ff_network_close();
return err;
}
|
{
"code": [],
"line_no": []
}
|
int FUNC_0(AVFormatContext *VAR_0)
{
RTSPState *rt = VAR_0->priv_data;
char VAR_1[1024], VAR_2[1024], VAR_3[1024], VAR_4[2048], VAR_5[128];
char *VAR_6, *VAR_7, *VAR_8;
URLContext *rtsp_hd, *rtsp_hd_out;
int VAR_9, VAR_10, VAR_11;
RTSPMessageHeader reply1 = {}, *reply = &reply1;
int VAR_12 = 0;
char VAR_13[64];
struct sockaddr_storage VAR_14;
socklen_t peer_len = sizeof(VAR_14);
if (!ff_network_init())
return AVERROR(EIO);
redirect:
rt->control_transport = RTSP_MODE_PLAIN;
ff_url_split(NULL, 0, VAR_5, sizeof(VAR_5),
VAR_1, sizeof(VAR_1), &VAR_9, VAR_2, sizeof(VAR_2), VAR_0->VAR_8);
if (*VAR_5) {
av_strlcpy(rt->VAR_5, VAR_5, sizeof(rt->VAR_5));
}
if (VAR_9 < 0)
VAR_9 = RTSP_DEFAULT_PORT;
VAR_6 = strrchr(VAR_2, '?');
if (VAR_6) {
VAR_8 = VAR_6;
while (VAR_6) {
VAR_7 = ++VAR_6;
VAR_6 = strchr(VAR_6, '&');
if (VAR_6)
*VAR_6 = 0;
if (!strcmp(VAR_7, "udp")) {
VAR_12 |= (1<< RTSP_LOWER_TRANSPORT_UDP);
} else if (!strcmp(VAR_7, "multicast")) {
VAR_12 |= (1<< RTSP_LOWER_TRANSPORT_UDP_MULTICAST);
} else if (!strcmp(VAR_7, "tcp")) {
VAR_12 |= (1<< RTSP_LOWER_TRANSPORT_TCP);
} else if(!strcmp(VAR_7, "http")) {
VAR_12 |= (1<< RTSP_LOWER_TRANSPORT_TCP);
rt->control_transport = RTSP_MODE_TUNNEL;
} else {
int VAR_15 = strlen(VAR_7);
memmove(++VAR_8, VAR_7, VAR_15);
VAR_8 += VAR_15;
if (VAR_6) *VAR_8 = '&';
}
}
*VAR_8 = 0;
}
if (!VAR_12)
VAR_12 = (1 << RTSP_LOWER_TRANSPORT_NB) - 1;
if (VAR_0->oformat) {
VAR_12 &= (1 << RTSP_LOWER_TRANSPORT_UDP) |
(1 << RTSP_LOWER_TRANSPORT_TCP);
if (!VAR_12 || rt->control_transport == RTSP_MODE_TUNNEL) {
av_log(VAR_0, AV_LOG_ERROR, "Unsupported lower transport method, "
"only UDP and TCP are supported for output.\n");
VAR_10 = AVERROR(EINVAL);
goto fail;
}
}
ff_url_join(rt->control_uri, sizeof(rt->control_uri), "rtsp", NULL,
VAR_1, VAR_9, "%VAR_0", VAR_2);
if (rt->control_transport == RTSP_MODE_TUNNEL) {
char VAR_16[1024];
char VAR_17[17];
char VAR_18[1024];
ff_url_join(VAR_16, sizeof(VAR_16), "http", NULL, VAR_1, VAR_9, "%VAR_0", VAR_2);
snprintf(VAR_17, sizeof(VAR_17), "%08x%08x",
av_get_random_seed(), av_get_random_seed());
if (url_open(&rtsp_hd, VAR_16, URL_RDONLY) < 0) {
VAR_10 = AVERROR(EIO);
goto fail;
}
snprintf(VAR_18, sizeof(VAR_18),
"x-VAR_17: %VAR_0\r\n"
"Accept: application/x-rtsp-tunnelled\r\n"
"Pragma: no-cache\r\n"
"Cache-Control: no-cache\r\n",
VAR_17);
ff_http_set_headers(rtsp_hd, VAR_18);
if (url_read(rtsp_hd, NULL, 0)) {
VAR_10 = AVERROR(EIO);
goto fail;
}
if (url_open(&rtsp_hd_out, VAR_16, URL_WRONLY) < 0 ) {
VAR_10 = AVERROR(EIO);
goto fail;
}
snprintf(VAR_18, sizeof(VAR_18),
"x-VAR_17: %VAR_0\r\n"
"Content-Type: application/x-rtsp-tunnelled\r\n"
"Pragma: no-cache\r\n"
"Cache-Control: no-cache\r\n"
"Content-Length: 32767\r\n"
"Expires: Sun, 9 Jan 1972 00:00:00 GMT\r\n",
VAR_17);
ff_http_set_headers(rtsp_hd_out, VAR_18);
ff_http_set_chunked_transfer_encoding(rtsp_hd_out, 0);
} else {
ff_url_join(VAR_3, sizeof(VAR_3), "tcp", NULL, VAR_1, VAR_9, NULL);
if (url_open(&rtsp_hd, VAR_3, URL_RDWR) < 0) {
VAR_10 = AVERROR(EIO);
goto fail;
}
rtsp_hd_out = rtsp_hd;
}
rt->rtsp_hd = rtsp_hd;
rt->rtsp_hd_out = rtsp_hd_out;
rt->seq = 0;
VAR_11 = url_get_file_handle(rtsp_hd);
if (!getpeername(VAR_11, (struct sockaddr*) &VAR_14, &peer_len)) {
getnameinfo((struct sockaddr*) &VAR_14, peer_len, VAR_1, sizeof(VAR_1),
NULL, 0, NI_NUMERICHOST);
}
for (rt->server_type = RTSP_SERVER_RTP;;) {
VAR_4[0] = 0;
if (rt->server_type == RTSP_SERVER_REAL)
av_strlcat(VAR_4,
"ClientChallenge: 9e26d33f2984236010ef6253fb1887f7\r\n"
"PlayerStarttime: [28/03/2003:22:50:23 00:00]\r\n"
"CompanyID: KnKV4M4I/B2FjJ1TToLycw==\r\n"
"GUID: 00000000-0000-0000-0000-000000000000\r\n",
sizeof(VAR_4));
ff_rtsp_send_cmd(VAR_0, "OPTIONS", rt->control_uri, VAR_4, reply, NULL);
if (reply->status_code != RTSP_STATUS_OK) {
VAR_10 = AVERROR_INVALIDDATA;
goto fail;
}
if (rt->server_type != RTSP_SERVER_REAL && reply->VAR_13[0]) {
rt->server_type = RTSP_SERVER_REAL;
continue;
} else if (!strncasecmp(reply->server, "WMServer/", 9)) {
rt->server_type = RTSP_SERVER_WMS;
} else if (rt->server_type == RTSP_SERVER_REAL)
strcpy(VAR_13, reply->VAR_13);
break;
}
if (VAR_0->iformat)
VAR_10 = rtsp_setup_input_streams(VAR_0, reply);
else
VAR_10 = rtsp_setup_output_streams(VAR_0, VAR_1);
if (VAR_10)
goto fail;
do {
int VAR_19 = ff_log2_tab[VAR_12 &
~(VAR_12 - 1)];
VAR_10 = make_setup_request(VAR_0, VAR_1, VAR_9, VAR_19,
rt->server_type == RTSP_SERVER_REAL ?
VAR_13 : NULL);
if (VAR_10 < 0)
goto fail;
VAR_12 &= ~(1 << VAR_19);
if (VAR_12 == 0 && VAR_10 == 1) {
VAR_10 = FF_NETERROR(EPROTONOSUPPORT);
goto fail;
}
} while (VAR_10);
rt->state = RTSP_STATE_IDLE;
rt->seek_timestamp = 0;
return 0;
fail:
ff_rtsp_close_streams(VAR_0);
ff_rtsp_close_connections(VAR_0);
if (reply->status_code >=300 && reply->status_code < 400 && VAR_0->iformat) {
av_strlcpy(VAR_0->VAR_8, reply->location, sizeof(VAR_0->VAR_8));
av_log(VAR_0, AV_LOG_INFO, "Status %d: Redirecting to %VAR_0\n",
reply->status_code,
VAR_0->VAR_8);
goto redirect;
}
ff_network_close();
return VAR_10;
}
|
[
"int FUNC_0(AVFormatContext *VAR_0)\n{",
"RTSPState *rt = VAR_0->priv_data;",
"char VAR_1[1024], VAR_2[1024], VAR_3[1024], VAR_4[2048], VAR_5[128];",
"char *VAR_6, *VAR_7, *VAR_8;",
"URLContext *rtsp_hd, *rtsp_hd_out;",
"int VAR_9, VAR_10, VAR_11;",
"RTSPMessageHeader reply1 = {}, *reply = &reply1;",
"int VAR_12 = 0;",
"char VAR_13[64];",
"struct sockaddr_storage VAR_14;",
"socklen_t peer_len = sizeof(VAR_14);",
"if (!ff_network_init())\nreturn AVERROR(EIO);",
"redirect:\nrt->control_transport = RTSP_MODE_PLAIN;",
"ff_url_split(NULL, 0, VAR_5, sizeof(VAR_5),\nVAR_1, sizeof(VAR_1), &VAR_9, VAR_2, sizeof(VAR_2), VAR_0->VAR_8);",
"if (*VAR_5) {",
"av_strlcpy(rt->VAR_5, VAR_5, sizeof(rt->VAR_5));",
"}",
"if (VAR_9 < 0)\nVAR_9 = RTSP_DEFAULT_PORT;",
"VAR_6 = strrchr(VAR_2, '?');",
"if (VAR_6) {",
"VAR_8 = VAR_6;",
"while (VAR_6) {",
"VAR_7 = ++VAR_6;",
"VAR_6 = strchr(VAR_6, '&');",
"if (VAR_6)\n*VAR_6 = 0;",
"if (!strcmp(VAR_7, \"udp\")) {",
"VAR_12 |= (1<< RTSP_LOWER_TRANSPORT_UDP);",
"} else if (!strcmp(VAR_7, \"multicast\")) {",
"VAR_12 |= (1<< RTSP_LOWER_TRANSPORT_UDP_MULTICAST);",
"} else if (!strcmp(VAR_7, \"tcp\")) {",
"VAR_12 |= (1<< RTSP_LOWER_TRANSPORT_TCP);",
"} else if(!strcmp(VAR_7, \"http\")) {",
"VAR_12 |= (1<< RTSP_LOWER_TRANSPORT_TCP);",
"rt->control_transport = RTSP_MODE_TUNNEL;",
"} else {",
"int VAR_15 = strlen(VAR_7);",
"memmove(++VAR_8, VAR_7, VAR_15);",
"VAR_8 += VAR_15;",
"if (VAR_6) *VAR_8 = '&';",
"}",
"}",
"*VAR_8 = 0;",
"}",
"if (!VAR_12)\nVAR_12 = (1 << RTSP_LOWER_TRANSPORT_NB) - 1;",
"if (VAR_0->oformat) {",
"VAR_12 &= (1 << RTSP_LOWER_TRANSPORT_UDP) |\n(1 << RTSP_LOWER_TRANSPORT_TCP);",
"if (!VAR_12 || rt->control_transport == RTSP_MODE_TUNNEL) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Unsupported lower transport method, \"\n\"only UDP and TCP are supported for output.\\n\");",
"VAR_10 = AVERROR(EINVAL);",
"goto fail;",
"}",
"}",
"ff_url_join(rt->control_uri, sizeof(rt->control_uri), \"rtsp\", NULL,\nVAR_1, VAR_9, \"%VAR_0\", VAR_2);",
"if (rt->control_transport == RTSP_MODE_TUNNEL) {",
"char VAR_16[1024];",
"char VAR_17[17];",
"char VAR_18[1024];",
"ff_url_join(VAR_16, sizeof(VAR_16), \"http\", NULL, VAR_1, VAR_9, \"%VAR_0\", VAR_2);",
"snprintf(VAR_17, sizeof(VAR_17), \"%08x%08x\",\nav_get_random_seed(), av_get_random_seed());",
"if (url_open(&rtsp_hd, VAR_16, URL_RDONLY) < 0) {",
"VAR_10 = AVERROR(EIO);",
"goto fail;",
"}",
"snprintf(VAR_18, sizeof(VAR_18),\n\"x-VAR_17: %VAR_0\\r\\n\"\n\"Accept: application/x-rtsp-tunnelled\\r\\n\"\n\"Pragma: no-cache\\r\\n\"\n\"Cache-Control: no-cache\\r\\n\",\nVAR_17);",
"ff_http_set_headers(rtsp_hd, VAR_18);",
"if (url_read(rtsp_hd, NULL, 0)) {",
"VAR_10 = AVERROR(EIO);",
"goto fail;",
"}",
"if (url_open(&rtsp_hd_out, VAR_16, URL_WRONLY) < 0 ) {",
"VAR_10 = AVERROR(EIO);",
"goto fail;",
"}",
"snprintf(VAR_18, sizeof(VAR_18),\n\"x-VAR_17: %VAR_0\\r\\n\"\n\"Content-Type: application/x-rtsp-tunnelled\\r\\n\"\n\"Pragma: no-cache\\r\\n\"\n\"Cache-Control: no-cache\\r\\n\"\n\"Content-Length: 32767\\r\\n\"\n\"Expires: Sun, 9 Jan 1972 00:00:00 GMT\\r\\n\",\nVAR_17);",
"ff_http_set_headers(rtsp_hd_out, VAR_18);",
"ff_http_set_chunked_transfer_encoding(rtsp_hd_out, 0);",
"} else {",
"ff_url_join(VAR_3, sizeof(VAR_3), \"tcp\", NULL, VAR_1, VAR_9, NULL);",
"if (url_open(&rtsp_hd, VAR_3, URL_RDWR) < 0) {",
"VAR_10 = AVERROR(EIO);",
"goto fail;",
"}",
"rtsp_hd_out = rtsp_hd;",
"}",
"rt->rtsp_hd = rtsp_hd;",
"rt->rtsp_hd_out = rtsp_hd_out;",
"rt->seq = 0;",
"VAR_11 = url_get_file_handle(rtsp_hd);",
"if (!getpeername(VAR_11, (struct sockaddr*) &VAR_14, &peer_len)) {",
"getnameinfo((struct sockaddr*) &VAR_14, peer_len, VAR_1, sizeof(VAR_1),\nNULL, 0, NI_NUMERICHOST);",
"}",
"for (rt->server_type = RTSP_SERVER_RTP;;) {",
"VAR_4[0] = 0;",
"if (rt->server_type == RTSP_SERVER_REAL)\nav_strlcat(VAR_4,\n\"ClientChallenge: 9e26d33f2984236010ef6253fb1887f7\\r\\n\"\n\"PlayerStarttime: [28/03/2003:22:50:23 00:00]\\r\\n\"\n\"CompanyID: KnKV4M4I/B2FjJ1TToLycw==\\r\\n\"\n\"GUID: 00000000-0000-0000-0000-000000000000\\r\\n\",\nsizeof(VAR_4));",
"ff_rtsp_send_cmd(VAR_0, \"OPTIONS\", rt->control_uri, VAR_4, reply, NULL);",
"if (reply->status_code != RTSP_STATUS_OK) {",
"VAR_10 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"if (rt->server_type != RTSP_SERVER_REAL && reply->VAR_13[0]) {",
"rt->server_type = RTSP_SERVER_REAL;",
"continue;",
"} else if (!strncasecmp(reply->server, \"WMServer/\", 9)) {",
"rt->server_type = RTSP_SERVER_WMS;",
"} else if (rt->server_type == RTSP_SERVER_REAL)",
"strcpy(VAR_13, reply->VAR_13);",
"break;",
"}",
"if (VAR_0->iformat)\nVAR_10 = rtsp_setup_input_streams(VAR_0, reply);",
"else\nVAR_10 = rtsp_setup_output_streams(VAR_0, VAR_1);",
"if (VAR_10)\ngoto fail;",
"do {",
"int VAR_19 = ff_log2_tab[VAR_12 &\n~(VAR_12 - 1)];",
"VAR_10 = make_setup_request(VAR_0, VAR_1, VAR_9, VAR_19,\nrt->server_type == RTSP_SERVER_REAL ?\nVAR_13 : NULL);",
"if (VAR_10 < 0)\ngoto fail;",
"VAR_12 &= ~(1 << VAR_19);",
"if (VAR_12 == 0 && VAR_10 == 1) {",
"VAR_10 = FF_NETERROR(EPROTONOSUPPORT);",
"goto fail;",
"}",
"} while (VAR_10);",
"rt->state = RTSP_STATE_IDLE;",
"rt->seek_timestamp = 0;",
"return 0;",
"fail:\nff_rtsp_close_streams(VAR_0);",
"ff_rtsp_close_connections(VAR_0);",
"if (reply->status_code >=300 && reply->status_code < 400 && VAR_0->iformat) {",
"av_strlcpy(VAR_0->VAR_8, reply->location, sizeof(VAR_0->VAR_8));",
"av_log(VAR_0, AV_LOG_INFO, \"Status %d: Redirecting to %VAR_0\\n\",\nreply->status_code,\nVAR_0->VAR_8);",
"goto redirect;",
"}",
"ff_network_close();",
"return 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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27,
29
],
[
31,
33
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
55
],
[
57
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73,
75
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123,
125
],
[
129
],
[
133,
135
],
[
137
],
[
139,
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
159,
161
],
[
165
],
[
169
],
[
171
],
[
173
],
[
177
],
[
179,
181
],
[
187
],
[
189
],
[
191
],
[
193
],
[
199,
201,
203,
205,
207,
209
],
[
211
],
[
217
],
[
220
],
[
222
],
[
224
],
[
230
],
[
233
],
[
235
],
[
237
],
[
243,
245,
247,
249,
251,
253,
255,
257
],
[
259
],
[
261
],
[
265
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
291
],
[
293
],
[
295,
297
],
[
299
],
[
307
],
[
309
],
[
311,
313,
333,
335,
337,
339,
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
377,
379
],
[
381,
383
],
[
385,
387
],
[
391
],
[
393,
395
],
[
399,
401,
403
],
[
405,
407
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
423
],
[
425
],
[
427
],
[
429,
431
],
[
433
],
[
435
],
[
437
],
[
439,
441,
443
],
[
445
],
[
447
],
[
449
],
[
451
],
[
453
]
] |
12,944
|
static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts)
{
ASFContext *asf = s->priv_data;
AVStream *st;
AVPacket pkt1, *pkt;
int block_align;
int64_t pos;
int64_t pos_min, pos_max, pts_min, pts_max, cur_pts;
pkt = &pkt1;
// Validate pts
if (pts < 0)
pts = 0;
if (stream_index == -1)
stream_index= av_find_default_stream_index(s);
st = s->streams[stream_index];
// ASF files have fixed block sizes, store this to determine offset
block_align = asf->packet_size;
if (block_align <= 0)
return -1;
pos_min = 0;
pts_min = asf_read_pts(s, &pos_min, stream_index);
if (pts_min == AV_NOPTS_VALUE) return -1;
pos_max = asf_align(s, url_filesize(url_fileno(&s->pb)) - 1 - s->data_offset); //FIXME wrong
pts_max = pts_min + s->duration;
while (pos_min <= pos_max) {
if (pts <= pts_min) {
pos = pos_min;
goto found;
} else if (pts >= pts_max) {
pos = pos_max;
goto found;
} else {
// interpolate position (better than dichotomy)
pos = (int64_t)((double)(pos_max - pos_min) *
(double)(pts - pts_min) /
(double)(pts_max - pts_min)) + pos_min;
pos= asf_align(s, pos);
}
// read the next timestamp
cur_pts = asf_read_pts(s, &pos, stream_index);
/* check if we are lucky */
if (pts == cur_pts) {
goto found;
} else if (cur_pts == AV_NOPTS_VALUE) {
return -1;
} else if (pts < cur_pts) {
pos_max = pos;
pts_max = asf_read_pts(s, &pos_max, stream_index); //FIXME wrong, must do backward search, or change this somehow
if (pts >= pts_max) {
pos = pos_max;
goto found;
}
} else {
pos_min = pos + asf->packet_size;
pts_min = asf_read_pts(s, &pos_min, stream_index);
if (pts <= pts_min) {
goto found;
}
}
}
pos = pos_min;
found:
url_fseek(&s->pb, pos + s->data_offset, SEEK_SET);
asf_reset_header(s);
return 0;
}
| true
|
FFmpeg
|
82b9e4a286e904dd402ddf6c914756963b2e2c4d
|
static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts)
{
ASFContext *asf = s->priv_data;
AVStream *st;
AVPacket pkt1, *pkt;
int block_align;
int64_t pos;
int64_t pos_min, pos_max, pts_min, pts_max, cur_pts;
pkt = &pkt1;
if (pts < 0)
pts = 0;
if (stream_index == -1)
stream_index= av_find_default_stream_index(s);
st = s->streams[stream_index];
block_align = asf->packet_size;
if (block_align <= 0)
return -1;
pos_min = 0;
pts_min = asf_read_pts(s, &pos_min, stream_index);
if (pts_min == AV_NOPTS_VALUE) return -1;
pos_max = asf_align(s, url_filesize(url_fileno(&s->pb)) - 1 - s->data_offset);
pts_max = pts_min + s->duration;
while (pos_min <= pos_max) {
if (pts <= pts_min) {
pos = pos_min;
goto found;
} else if (pts >= pts_max) {
pos = pos_max;
goto found;
} else {
pos = (int64_t)((double)(pos_max - pos_min) *
(double)(pts - pts_min) /
(double)(pts_max - pts_min)) + pos_min;
pos= asf_align(s, pos);
}
cur_pts = asf_read_pts(s, &pos, stream_index);
if (pts == cur_pts) {
goto found;
} else if (cur_pts == AV_NOPTS_VALUE) {
return -1;
} else if (pts < cur_pts) {
pos_max = pos;
pts_max = asf_read_pts(s, &pos_max, stream_index); , must do backward search, or change this somehow
if (pts >= pts_max) {
pos = pos_max;
goto found;
}
} else {
pos_min = pos + asf->packet_size;
pts_min = asf_read_pts(s, &pos_min, stream_index);
if (pts <= pts_min) {
goto found;
}
}
}
pos = pos_min;
found:
url_fseek(&s->pb, pos + s->data_offset, SEEK_SET);
asf_reset_header(s);
return 0;
}
|
{
"code": [
" int64_t pos_min, pos_max, pts_min, pts_max, cur_pts;",
" while (pos_min <= pos_max) {",
" if (pts <= pts_min) {",
" pos = pos_min;",
" goto found;",
" } else if (pts >= pts_max) {",
" pos = pos_max;",
" goto found;",
" } else {",
" pos = (int64_t)((double)(pos_max - pos_min) *",
" (double)(pts - pts_min) /",
" (double)(pts_max - pts_min)) + pos_min;",
" pos= asf_align(s, pos);",
" if (pts == cur_pts) {",
" goto found;",
" } else if (cur_pts == AV_NOPTS_VALUE) {",
"\t return -1;",
" if (pts >= pts_max) {",
" pos = pos_max;",
" goto found;",
" pos_min = pos + asf->packet_size;",
"\t pts_min = asf_read_pts(s, &pos_min, stream_index);",
" if (pts <= pts_min) {",
" goto found;",
"found:"
],
"line_no": [
15,
67,
71,
73,
75,
77,
79,
75,
83,
87,
89,
91,
93,
107,
75,
111,
113,
121,
123,
125,
131,
133,
135,
125,
147
]
}
|
static int FUNC_0(AVFormatContext *VAR_0, int VAR_1, int64_t VAR_2)
{
ASFContext *asf = VAR_0->priv_data;
AVStream *st;
AVPacket pkt1, *pkt;
int VAR_3;
int64_t pos;
int64_t pos_min, pos_max, pts_min, pts_max, cur_pts;
pkt = &pkt1;
if (VAR_2 < 0)
VAR_2 = 0;
if (VAR_1 == -1)
VAR_1= av_find_default_stream_index(VAR_0);
st = VAR_0->streams[VAR_1];
VAR_3 = asf->packet_size;
if (VAR_3 <= 0)
return -1;
pos_min = 0;
pts_min = asf_read_pts(VAR_0, &pos_min, VAR_1);
if (pts_min == AV_NOPTS_VALUE) return -1;
pos_max = asf_align(VAR_0, url_filesize(url_fileno(&VAR_0->pb)) - 1 - VAR_0->data_offset);
pts_max = pts_min + VAR_0->duration;
while (pos_min <= pos_max) {
if (VAR_2 <= pts_min) {
pos = pos_min;
goto found;
} else if (VAR_2 >= pts_max) {
pos = pos_max;
goto found;
} else {
pos = (int64_t)((double)(pos_max - pos_min) *
(double)(VAR_2 - pts_min) /
(double)(pts_max - pts_min)) + pos_min;
pos= asf_align(VAR_0, pos);
}
cur_pts = asf_read_pts(VAR_0, &pos, VAR_1);
if (VAR_2 == cur_pts) {
goto found;
} else if (cur_pts == AV_NOPTS_VALUE) {
return -1;
} else if (VAR_2 < cur_pts) {
pos_max = pos;
pts_max = asf_read_pts(VAR_0, &pos_max, VAR_1); , must do backward search, or change this somehow
if (VAR_2 >= pts_max) {
pos = pos_max;
goto found;
}
} else {
pos_min = pos + asf->packet_size;
pts_min = asf_read_pts(VAR_0, &pos_min, VAR_1);
if (VAR_2 <= pts_min) {
goto found;
}
}
}
pos = pos_min;
found:
url_fseek(&VAR_0->pb, pos + VAR_0->data_offset, SEEK_SET);
asf_reset_header(VAR_0);
return 0;
}
|
[
"static int FUNC_0(AVFormatContext *VAR_0, int VAR_1, int64_t VAR_2)\n{",
"ASFContext *asf = VAR_0->priv_data;",
"AVStream *st;",
"AVPacket pkt1, *pkt;",
"int VAR_3;",
"int64_t pos;",
"int64_t pos_min, pos_max, pts_min, pts_max, cur_pts;",
"pkt = &pkt1;",
"if (VAR_2 < 0)\nVAR_2 = 0;",
"if (VAR_1 == -1)\nVAR_1= av_find_default_stream_index(VAR_0);",
"st = VAR_0->streams[VAR_1];",
"VAR_3 = asf->packet_size;",
"if (VAR_3 <= 0)\nreturn -1;",
"pos_min = 0;",
"pts_min = asf_read_pts(VAR_0, &pos_min, VAR_1);",
"if (pts_min == AV_NOPTS_VALUE) return -1;",
"pos_max = asf_align(VAR_0, url_filesize(url_fileno(&VAR_0->pb)) - 1 - VAR_0->data_offset);",
"pts_max = pts_min + VAR_0->duration;",
"while (pos_min <= pos_max) {",
"if (VAR_2 <= pts_min) {",
"pos = pos_min;",
"goto found;",
"} else if (VAR_2 >= pts_max) {",
"pos = pos_max;",
"goto found;",
"} else {",
"pos = (int64_t)((double)(pos_max - pos_min) *\n(double)(VAR_2 - pts_min) /\n(double)(pts_max - pts_min)) + pos_min;",
"pos= asf_align(VAR_0, pos);",
"}",
"cur_pts = asf_read_pts(VAR_0, &pos, VAR_1);",
"if (VAR_2 == cur_pts) {",
"goto found;",
"} else if (cur_pts == AV_NOPTS_VALUE) {",
"return -1;",
"} else if (VAR_2 < cur_pts) {",
"pos_max = pos;",
"pts_max = asf_read_pts(VAR_0, &pos_max, VAR_1); , must do backward search, or change this somehow",
"if (VAR_2 >= pts_max) {",
"pos = pos_max;",
"goto found;",
"}",
"} else {",
"pos_min = pos + asf->packet_size;",
"pts_min = asf_read_pts(VAR_0, &pos_min, VAR_1);",
"if (VAR_2 <= pts_min) {",
"goto found;",
"}",
"}",
"}",
"pos = pos_min;",
"found:\nurl_fseek(&VAR_0->pb, pos + VAR_0->data_offset, SEEK_SET);",
"asf_reset_header(VAR_0);",
"return 0;",
"}"
] |
[
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
0,
0,
1,
1,
0,
0,
1,
0,
1,
1,
0,
0,
0,
1,
1,
1,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
1,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
25,
27
],
[
31,
33
],
[
37
],
[
43
],
[
47,
49
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87,
89,
91
],
[
93
],
[
95
],
[
101
],
[
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
]
] |
12,945
|
static void decode_src_opc(CPUTriCoreState *env, DisasContext *ctx, int op1)
{
int r1;
int32_t const4;
TCGv temp, temp2;
r1 = MASK_OP_SRC_S1D(ctx->opcode);
const4 = MASK_OP_SRC_CONST4_SEXT(ctx->opcode);
switch (op1) {
case OPC1_16_SRC_ADD:
gen_addi_d(cpu_gpr_d[r1], cpu_gpr_d[r1], const4);
break;
case OPC1_16_SRC_ADD_A15:
gen_addi_d(cpu_gpr_d[r1], cpu_gpr_d[15], const4);
break;
case OPC1_16_SRC_ADD_15A:
gen_addi_d(cpu_gpr_d[15], cpu_gpr_d[r1], const4);
break;
case OPC1_16_SRC_ADD_A:
tcg_gen_addi_tl(cpu_gpr_a[r1], cpu_gpr_a[r1], const4);
break;
case OPC1_16_SRC_CADD:
gen_condi_add(TCG_COND_NE, cpu_gpr_d[r1], const4, cpu_gpr_d[r1],
cpu_gpr_d[15]);
break;
case OPC1_16_SRC_CADDN:
gen_condi_add(TCG_COND_EQ, cpu_gpr_d[r1], const4, cpu_gpr_d[r1],
cpu_gpr_d[15]);
break;
case OPC1_16_SRC_CMOV:
temp = tcg_const_tl(0);
temp2 = tcg_const_tl(const4);
tcg_gen_movcond_tl(TCG_COND_NE, cpu_gpr_d[r1], cpu_gpr_d[15], temp,
temp2, cpu_gpr_d[r1]);
tcg_temp_free(temp);
tcg_temp_free(temp2);
break;
case OPC1_16_SRC_CMOVN:
temp = tcg_const_tl(0);
temp2 = tcg_const_tl(const4);
tcg_gen_movcond_tl(TCG_COND_EQ, cpu_gpr_d[r1], cpu_gpr_d[15], temp,
temp2, cpu_gpr_d[r1]);
tcg_temp_free(temp);
tcg_temp_free(temp2);
break;
case OPC1_16_SRC_EQ:
tcg_gen_setcondi_tl(TCG_COND_EQ, cpu_gpr_d[15], cpu_gpr_d[r1],
const4);
break;
case OPC1_16_SRC_LT:
tcg_gen_setcondi_tl(TCG_COND_LT, cpu_gpr_d[15], cpu_gpr_d[r1],
const4);
break;
case OPC1_16_SRC_MOV:
tcg_gen_movi_tl(cpu_gpr_d[r1], const4);
break;
case OPC1_16_SRC_MOV_A:
const4 = MASK_OP_SRC_CONST4(ctx->opcode);
tcg_gen_movi_tl(cpu_gpr_a[r1], const4);
break;
case OPC1_16_SRC_MOV_E:
if (tricore_feature(env, TRICORE_FEATURE_16)) {
tcg_gen_movi_tl(cpu_gpr_d[r1], const4);
tcg_gen_sari_tl(cpu_gpr_d[r1+1], cpu_gpr_d[r1], 31);
} /* TODO: else raise illegal opcode trap */
break;
case OPC1_16_SRC_SH:
gen_shi(cpu_gpr_d[r1], cpu_gpr_d[r1], const4);
break;
case OPC1_16_SRC_SHA:
gen_shaci(cpu_gpr_d[r1], cpu_gpr_d[r1], const4);
break;
}
}
| true
|
qemu
|
f678f671ba654d4610f0e43d175c8c1b2fad10df
|
static void decode_src_opc(CPUTriCoreState *env, DisasContext *ctx, int op1)
{
int r1;
int32_t const4;
TCGv temp, temp2;
r1 = MASK_OP_SRC_S1D(ctx->opcode);
const4 = MASK_OP_SRC_CONST4_SEXT(ctx->opcode);
switch (op1) {
case OPC1_16_SRC_ADD:
gen_addi_d(cpu_gpr_d[r1], cpu_gpr_d[r1], const4);
break;
case OPC1_16_SRC_ADD_A15:
gen_addi_d(cpu_gpr_d[r1], cpu_gpr_d[15], const4);
break;
case OPC1_16_SRC_ADD_15A:
gen_addi_d(cpu_gpr_d[15], cpu_gpr_d[r1], const4);
break;
case OPC1_16_SRC_ADD_A:
tcg_gen_addi_tl(cpu_gpr_a[r1], cpu_gpr_a[r1], const4);
break;
case OPC1_16_SRC_CADD:
gen_condi_add(TCG_COND_NE, cpu_gpr_d[r1], const4, cpu_gpr_d[r1],
cpu_gpr_d[15]);
break;
case OPC1_16_SRC_CADDN:
gen_condi_add(TCG_COND_EQ, cpu_gpr_d[r1], const4, cpu_gpr_d[r1],
cpu_gpr_d[15]);
break;
case OPC1_16_SRC_CMOV:
temp = tcg_const_tl(0);
temp2 = tcg_const_tl(const4);
tcg_gen_movcond_tl(TCG_COND_NE, cpu_gpr_d[r1], cpu_gpr_d[15], temp,
temp2, cpu_gpr_d[r1]);
tcg_temp_free(temp);
tcg_temp_free(temp2);
break;
case OPC1_16_SRC_CMOVN:
temp = tcg_const_tl(0);
temp2 = tcg_const_tl(const4);
tcg_gen_movcond_tl(TCG_COND_EQ, cpu_gpr_d[r1], cpu_gpr_d[15], temp,
temp2, cpu_gpr_d[r1]);
tcg_temp_free(temp);
tcg_temp_free(temp2);
break;
case OPC1_16_SRC_EQ:
tcg_gen_setcondi_tl(TCG_COND_EQ, cpu_gpr_d[15], cpu_gpr_d[r1],
const4);
break;
case OPC1_16_SRC_LT:
tcg_gen_setcondi_tl(TCG_COND_LT, cpu_gpr_d[15], cpu_gpr_d[r1],
const4);
break;
case OPC1_16_SRC_MOV:
tcg_gen_movi_tl(cpu_gpr_d[r1], const4);
break;
case OPC1_16_SRC_MOV_A:
const4 = MASK_OP_SRC_CONST4(ctx->opcode);
tcg_gen_movi_tl(cpu_gpr_a[r1], const4);
break;
case OPC1_16_SRC_MOV_E:
if (tricore_feature(env, TRICORE_FEATURE_16)) {
tcg_gen_movi_tl(cpu_gpr_d[r1], const4);
tcg_gen_sari_tl(cpu_gpr_d[r1+1], cpu_gpr_d[r1], 31);
}
break;
case OPC1_16_SRC_SH:
gen_shi(cpu_gpr_d[r1], cpu_gpr_d[r1], const4);
break;
case OPC1_16_SRC_SHA:
gen_shaci(cpu_gpr_d[r1], cpu_gpr_d[r1], const4);
break;
}
}
|
{
"code": [],
"line_no": []
}
|
static void FUNC_0(CPUTriCoreState *VAR_0, DisasContext *VAR_1, int VAR_2)
{
int VAR_3;
int32_t const4;
TCGv temp, temp2;
VAR_3 = MASK_OP_SRC_S1D(VAR_1->opcode);
const4 = MASK_OP_SRC_CONST4_SEXT(VAR_1->opcode);
switch (VAR_2) {
case OPC1_16_SRC_ADD:
gen_addi_d(cpu_gpr_d[VAR_3], cpu_gpr_d[VAR_3], const4);
break;
case OPC1_16_SRC_ADD_A15:
gen_addi_d(cpu_gpr_d[VAR_3], cpu_gpr_d[15], const4);
break;
case OPC1_16_SRC_ADD_15A:
gen_addi_d(cpu_gpr_d[15], cpu_gpr_d[VAR_3], const4);
break;
case OPC1_16_SRC_ADD_A:
tcg_gen_addi_tl(cpu_gpr_a[VAR_3], cpu_gpr_a[VAR_3], const4);
break;
case OPC1_16_SRC_CADD:
gen_condi_add(TCG_COND_NE, cpu_gpr_d[VAR_3], const4, cpu_gpr_d[VAR_3],
cpu_gpr_d[15]);
break;
case OPC1_16_SRC_CADDN:
gen_condi_add(TCG_COND_EQ, cpu_gpr_d[VAR_3], const4, cpu_gpr_d[VAR_3],
cpu_gpr_d[15]);
break;
case OPC1_16_SRC_CMOV:
temp = tcg_const_tl(0);
temp2 = tcg_const_tl(const4);
tcg_gen_movcond_tl(TCG_COND_NE, cpu_gpr_d[VAR_3], cpu_gpr_d[15], temp,
temp2, cpu_gpr_d[VAR_3]);
tcg_temp_free(temp);
tcg_temp_free(temp2);
break;
case OPC1_16_SRC_CMOVN:
temp = tcg_const_tl(0);
temp2 = tcg_const_tl(const4);
tcg_gen_movcond_tl(TCG_COND_EQ, cpu_gpr_d[VAR_3], cpu_gpr_d[15], temp,
temp2, cpu_gpr_d[VAR_3]);
tcg_temp_free(temp);
tcg_temp_free(temp2);
break;
case OPC1_16_SRC_EQ:
tcg_gen_setcondi_tl(TCG_COND_EQ, cpu_gpr_d[15], cpu_gpr_d[VAR_3],
const4);
break;
case OPC1_16_SRC_LT:
tcg_gen_setcondi_tl(TCG_COND_LT, cpu_gpr_d[15], cpu_gpr_d[VAR_3],
const4);
break;
case OPC1_16_SRC_MOV:
tcg_gen_movi_tl(cpu_gpr_d[VAR_3], const4);
break;
case OPC1_16_SRC_MOV_A:
const4 = MASK_OP_SRC_CONST4(VAR_1->opcode);
tcg_gen_movi_tl(cpu_gpr_a[VAR_3], const4);
break;
case OPC1_16_SRC_MOV_E:
if (tricore_feature(VAR_0, TRICORE_FEATURE_16)) {
tcg_gen_movi_tl(cpu_gpr_d[VAR_3], const4);
tcg_gen_sari_tl(cpu_gpr_d[VAR_3+1], cpu_gpr_d[VAR_3], 31);
}
break;
case OPC1_16_SRC_SH:
gen_shi(cpu_gpr_d[VAR_3], cpu_gpr_d[VAR_3], const4);
break;
case OPC1_16_SRC_SHA:
gen_shaci(cpu_gpr_d[VAR_3], cpu_gpr_d[VAR_3], const4);
break;
}
}
|
[
"static void FUNC_0(CPUTriCoreState *VAR_0, DisasContext *VAR_1, int VAR_2)\n{",
"int VAR_3;",
"int32_t const4;",
"TCGv temp, temp2;",
"VAR_3 = MASK_OP_SRC_S1D(VAR_1->opcode);",
"const4 = MASK_OP_SRC_CONST4_SEXT(VAR_1->opcode);",
"switch (VAR_2) {",
"case OPC1_16_SRC_ADD:\ngen_addi_d(cpu_gpr_d[VAR_3], cpu_gpr_d[VAR_3], const4);",
"break;",
"case OPC1_16_SRC_ADD_A15:\ngen_addi_d(cpu_gpr_d[VAR_3], cpu_gpr_d[15], const4);",
"break;",
"case OPC1_16_SRC_ADD_15A:\ngen_addi_d(cpu_gpr_d[15], cpu_gpr_d[VAR_3], const4);",
"break;",
"case OPC1_16_SRC_ADD_A:\ntcg_gen_addi_tl(cpu_gpr_a[VAR_3], cpu_gpr_a[VAR_3], const4);",
"break;",
"case OPC1_16_SRC_CADD:\ngen_condi_add(TCG_COND_NE, cpu_gpr_d[VAR_3], const4, cpu_gpr_d[VAR_3],\ncpu_gpr_d[15]);",
"break;",
"case OPC1_16_SRC_CADDN:\ngen_condi_add(TCG_COND_EQ, cpu_gpr_d[VAR_3], const4, cpu_gpr_d[VAR_3],\ncpu_gpr_d[15]);",
"break;",
"case OPC1_16_SRC_CMOV:\ntemp = tcg_const_tl(0);",
"temp2 = tcg_const_tl(const4);",
"tcg_gen_movcond_tl(TCG_COND_NE, cpu_gpr_d[VAR_3], cpu_gpr_d[15], temp,\ntemp2, cpu_gpr_d[VAR_3]);",
"tcg_temp_free(temp);",
"tcg_temp_free(temp2);",
"break;",
"case OPC1_16_SRC_CMOVN:\ntemp = tcg_const_tl(0);",
"temp2 = tcg_const_tl(const4);",
"tcg_gen_movcond_tl(TCG_COND_EQ, cpu_gpr_d[VAR_3], cpu_gpr_d[15], temp,\ntemp2, cpu_gpr_d[VAR_3]);",
"tcg_temp_free(temp);",
"tcg_temp_free(temp2);",
"break;",
"case OPC1_16_SRC_EQ:\ntcg_gen_setcondi_tl(TCG_COND_EQ, cpu_gpr_d[15], cpu_gpr_d[VAR_3],\nconst4);",
"break;",
"case OPC1_16_SRC_LT:\ntcg_gen_setcondi_tl(TCG_COND_LT, cpu_gpr_d[15], cpu_gpr_d[VAR_3],\nconst4);",
"break;",
"case OPC1_16_SRC_MOV:\ntcg_gen_movi_tl(cpu_gpr_d[VAR_3], const4);",
"break;",
"case OPC1_16_SRC_MOV_A:\nconst4 = MASK_OP_SRC_CONST4(VAR_1->opcode);",
"tcg_gen_movi_tl(cpu_gpr_a[VAR_3], const4);",
"break;",
"case OPC1_16_SRC_MOV_E:\nif (tricore_feature(VAR_0, TRICORE_FEATURE_16)) {",
"tcg_gen_movi_tl(cpu_gpr_d[VAR_3], const4);",
"tcg_gen_sari_tl(cpu_gpr_d[VAR_3+1], cpu_gpr_d[VAR_3], 31);",
"}",
"break;",
"case OPC1_16_SRC_SH:\ngen_shi(cpu_gpr_d[VAR_3], cpu_gpr_d[VAR_3], const4);",
"break;",
"case OPC1_16_SRC_SHA:\ngen_shaci(cpu_gpr_d[VAR_3], cpu_gpr_d[VAR_3], const4);",
"break;",
"}",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19
],
[
21,
23
],
[
25
],
[
27,
29
],
[
31
],
[
33,
35
],
[
37
],
[
39,
41
],
[
43
],
[
45,
47,
49
],
[
51
],
[
53,
55,
57
],
[
59
],
[
61,
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
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
]
] |
12,947
|
int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, unsigned char **data)
{
if (s->buf_end - s->buf_ptr >= size && !s->write_flag) {
*data = s->buf_ptr;
s->buf_ptr += size;
return size;
} else {
*data = buf;
return avio_read(s, buf, size);
}
}
| true
|
FFmpeg
|
5afe1d27912be9b643ffb4ddc21f6d920260dbb0
|
int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, unsigned char **data)
{
if (s->buf_end - s->buf_ptr >= size && !s->write_flag) {
*data = s->buf_ptr;
s->buf_ptr += size;
return size;
} else {
*data = buf;
return avio_read(s, buf, size);
}
}
|
{
"code": [
"int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, unsigned char **data)"
],
"line_no": [
1
]
}
|
int FUNC_0(AVIOContext *VAR_0, unsigned char *VAR_1, int VAR_2, unsigned char **VAR_3)
{
if (VAR_0->buf_end - VAR_0->buf_ptr >= VAR_2 && !VAR_0->write_flag) {
*VAR_3 = VAR_0->buf_ptr;
VAR_0->buf_ptr += VAR_2;
return VAR_2;
} else {
*VAR_3 = VAR_1;
return avio_read(VAR_0, VAR_1, VAR_2);
}
}
|
[
"int FUNC_0(AVIOContext *VAR_0, unsigned char *VAR_1, int VAR_2, unsigned char **VAR_3)\n{",
"if (VAR_0->buf_end - VAR_0->buf_ptr >= VAR_2 && !VAR_0->write_flag) {",
"*VAR_3 = VAR_0->buf_ptr;",
"VAR_0->buf_ptr += VAR_2;",
"return VAR_2;",
"} else {",
"*VAR_3 = VAR_1;",
"return avio_read(VAR_0, VAR_1, VAR_2);",
"}",
"}"
] |
[
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
12,948
|
int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
AVFilterInOut **open_inputs_ptr, AVFilterInOut **open_outputs_ptr,
void *log_ctx)
{
int index = 0, ret = 0;
char chr = 0;
AVFilterInOut *curr_inputs = NULL;
AVFilterInOut *open_inputs = open_inputs_ptr ? *open_inputs_ptr : NULL;
AVFilterInOut *open_outputs = open_outputs_ptr ? *open_outputs_ptr : NULL;
do {
AVFilterContext *filter;
const char *filterchain = filters;
filters += strspn(filters, WHITESPACES);
if ((ret = parse_inputs(&filters, &curr_inputs, &open_outputs, log_ctx)) < 0)
goto end;
if ((ret = parse_filter(&filter, &filters, graph, index, log_ctx)) < 0)
goto end;
if (filter->input_count == 1 && !curr_inputs && !index) {
/* First input pad, assume it is "[in]" if not specified */
const char *tmp = "[in]";
if ((ret = parse_inputs(&tmp, &curr_inputs, &open_outputs, log_ctx)) < 0)
goto end;
}
if ((ret = link_filter_inouts(filter, &curr_inputs, &open_inputs, log_ctx)) < 0)
goto end;
if ((ret = parse_outputs(&filters, &curr_inputs, &open_inputs, &open_outputs,
log_ctx)) < 0)
goto end;
filters += strspn(filters, WHITESPACES);
chr = *filters++;
if (chr == ';' && curr_inputs) {
av_log(log_ctx, AV_LOG_ERROR,
"Invalid filterchain containing an unlabelled output pad: \"%s\"\n",
filterchain);
ret = AVERROR(EINVAL);
goto end;
}
index++;
} while (chr == ',' || chr == ';');
if (chr) {
av_log(log_ctx, AV_LOG_ERROR,
"Unable to parse graph description substring: \"%s\"\n",
filters - 1);
ret = AVERROR(EINVAL);
goto end;
}
if (open_inputs && !strcmp(open_inputs->name, "out") && curr_inputs) {
/* Last output pad, assume it is "[out]" if not specified */
const char *tmp = "[out]";
if ((ret = parse_outputs(&tmp, &curr_inputs, &open_inputs, &open_outputs,
log_ctx)) < 0)
goto end;
}
end:
/* clear open_in/outputs only if not passed as parameters */
if (open_inputs_ptr) *open_inputs_ptr = open_inputs;
else avfilter_inout_free(&open_inputs);
if (open_outputs_ptr) *open_outputs_ptr = open_outputs;
else avfilter_inout_free(&open_outputs);
avfilter_inout_free(&curr_inputs);
if (ret < 0) {
for (; graph->filter_count > 0; graph->filter_count--)
avfilter_free(graph->filters[graph->filter_count - 1]);
av_freep(&graph->filters);
}
return ret;
}
| false
|
FFmpeg
|
2420763638bef385c8116a44ff5c0d2c15589494
|
int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
AVFilterInOut **open_inputs_ptr, AVFilterInOut **open_outputs_ptr,
void *log_ctx)
{
int index = 0, ret = 0;
char chr = 0;
AVFilterInOut *curr_inputs = NULL;
AVFilterInOut *open_inputs = open_inputs_ptr ? *open_inputs_ptr : NULL;
AVFilterInOut *open_outputs = open_outputs_ptr ? *open_outputs_ptr : NULL;
do {
AVFilterContext *filter;
const char *filterchain = filters;
filters += strspn(filters, WHITESPACES);
if ((ret = parse_inputs(&filters, &curr_inputs, &open_outputs, log_ctx)) < 0)
goto end;
if ((ret = parse_filter(&filter, &filters, graph, index, log_ctx)) < 0)
goto end;
if (filter->input_count == 1 && !curr_inputs && !index) {
const char *tmp = "[in]";
if ((ret = parse_inputs(&tmp, &curr_inputs, &open_outputs, log_ctx)) < 0)
goto end;
}
if ((ret = link_filter_inouts(filter, &curr_inputs, &open_inputs, log_ctx)) < 0)
goto end;
if ((ret = parse_outputs(&filters, &curr_inputs, &open_inputs, &open_outputs,
log_ctx)) < 0)
goto end;
filters += strspn(filters, WHITESPACES);
chr = *filters++;
if (chr == ';' && curr_inputs) {
av_log(log_ctx, AV_LOG_ERROR,
"Invalid filterchain containing an unlabelled output pad: \"%s\"\n",
filterchain);
ret = AVERROR(EINVAL);
goto end;
}
index++;
} while (chr == ',' || chr == ';');
if (chr) {
av_log(log_ctx, AV_LOG_ERROR,
"Unable to parse graph description substring: \"%s\"\n",
filters - 1);
ret = AVERROR(EINVAL);
goto end;
}
if (open_inputs && !strcmp(open_inputs->name, "out") && curr_inputs) {
const char *tmp = "[out]";
if ((ret = parse_outputs(&tmp, &curr_inputs, &open_inputs, &open_outputs,
log_ctx)) < 0)
goto end;
}
end:
if (open_inputs_ptr) *open_inputs_ptr = open_inputs;
else avfilter_inout_free(&open_inputs);
if (open_outputs_ptr) *open_outputs_ptr = open_outputs;
else avfilter_inout_free(&open_outputs);
avfilter_inout_free(&curr_inputs);
if (ret < 0) {
for (; graph->filter_count > 0; graph->filter_count--)
avfilter_free(graph->filters[graph->filter_count - 1]);
av_freep(&graph->filters);
}
return ret;
}
|
{
"code": [],
"line_no": []
}
|
int FUNC_0(AVFilterGraph *VAR_0, const char *VAR_1,
AVFilterInOut **VAR_2, AVFilterInOut **VAR_3,
void *VAR_4)
{
int VAR_5 = 0, VAR_6 = 0;
char VAR_7 = 0;
AVFilterInOut *curr_inputs = NULL;
AVFilterInOut *open_inputs = VAR_2 ? *VAR_2 : NULL;
AVFilterInOut *open_outputs = VAR_3 ? *VAR_3 : NULL;
do {
AVFilterContext *filter;
const char *VAR_8 = VAR_1;
VAR_1 += strspn(VAR_1, WHITESPACES);
if ((VAR_6 = parse_inputs(&VAR_1, &curr_inputs, &open_outputs, VAR_4)) < 0)
goto end;
if ((VAR_6 = parse_filter(&filter, &VAR_1, VAR_0, VAR_5, VAR_4)) < 0)
goto end;
if (filter->input_count == 1 && !curr_inputs && !VAR_5) {
const char *VAR_10 = "[in]";
if ((VAR_6 = parse_inputs(&VAR_10, &curr_inputs, &open_outputs, VAR_4)) < 0)
goto end;
}
if ((VAR_6 = link_filter_inouts(filter, &curr_inputs, &open_inputs, VAR_4)) < 0)
goto end;
if ((VAR_6 = parse_outputs(&VAR_1, &curr_inputs, &open_inputs, &open_outputs,
VAR_4)) < 0)
goto end;
VAR_1 += strspn(VAR_1, WHITESPACES);
VAR_7 = *VAR_1++;
if (VAR_7 == ';' && curr_inputs) {
av_log(VAR_4, AV_LOG_ERROR,
"Invalid VAR_8 containing an unlabelled output pad: \"%s\"\n",
VAR_8);
VAR_6 = AVERROR(EINVAL);
goto end;
}
VAR_5++;
} while (VAR_7 == ',' || VAR_7 == ';');
if (VAR_7) {
av_log(VAR_4, AV_LOG_ERROR,
"Unable to parse VAR_0 description substring: \"%s\"\n",
VAR_1 - 1);
VAR_6 = AVERROR(EINVAL);
goto end;
}
if (open_inputs && !strcmp(open_inputs->name, "out") && curr_inputs) {
const char *VAR_10 = "[out]";
if ((VAR_6 = parse_outputs(&VAR_10, &curr_inputs, &open_inputs, &open_outputs,
VAR_4)) < 0)
goto end;
}
end:
if (VAR_2) *VAR_2 = open_inputs;
else avfilter_inout_free(&open_inputs);
if (VAR_3) *VAR_3 = open_outputs;
else avfilter_inout_free(&open_outputs);
avfilter_inout_free(&curr_inputs);
if (VAR_6 < 0) {
for (; VAR_0->filter_count > 0; VAR_0->filter_count--)
avfilter_free(VAR_0->VAR_1[VAR_0->filter_count - 1]);
av_freep(&VAR_0->VAR_1);
}
return VAR_6;
}
|
[
"int FUNC_0(AVFilterGraph *VAR_0, const char *VAR_1,\nAVFilterInOut **VAR_2, AVFilterInOut **VAR_3,\nvoid *VAR_4)\n{",
"int VAR_5 = 0, VAR_6 = 0;",
"char VAR_7 = 0;",
"AVFilterInOut *curr_inputs = NULL;",
"AVFilterInOut *open_inputs = VAR_2 ? *VAR_2 : NULL;",
"AVFilterInOut *open_outputs = VAR_3 ? *VAR_3 : NULL;",
"do {",
"AVFilterContext *filter;",
"const char *VAR_8 = VAR_1;",
"VAR_1 += strspn(VAR_1, WHITESPACES);",
"if ((VAR_6 = parse_inputs(&VAR_1, &curr_inputs, &open_outputs, VAR_4)) < 0)\ngoto end;",
"if ((VAR_6 = parse_filter(&filter, &VAR_1, VAR_0, VAR_5, VAR_4)) < 0)\ngoto end;",
"if (filter->input_count == 1 && !curr_inputs && !VAR_5) {",
"const char *VAR_10 = \"[in]\";",
"if ((VAR_6 = parse_inputs(&VAR_10, &curr_inputs, &open_outputs, VAR_4)) < 0)\ngoto end;",
"}",
"if ((VAR_6 = link_filter_inouts(filter, &curr_inputs, &open_inputs, VAR_4)) < 0)\ngoto end;",
"if ((VAR_6 = parse_outputs(&VAR_1, &curr_inputs, &open_inputs, &open_outputs,\nVAR_4)) < 0)\ngoto end;",
"VAR_1 += strspn(VAR_1, WHITESPACES);",
"VAR_7 = *VAR_1++;",
"if (VAR_7 == ';' && curr_inputs) {",
"av_log(VAR_4, AV_LOG_ERROR,\n\"Invalid VAR_8 containing an unlabelled output pad: \\\"%s\\\"\\n\",\nVAR_8);",
"VAR_6 = AVERROR(EINVAL);",
"goto end;",
"}",
"VAR_5++;",
"} while (VAR_7 == ',' || VAR_7 == ';');",
"if (VAR_7) {",
"av_log(VAR_4, AV_LOG_ERROR,\n\"Unable to parse VAR_0 description substring: \\\"%s\\\"\\n\",\nVAR_1 - 1);",
"VAR_6 = AVERROR(EINVAL);",
"goto end;",
"}",
"if (open_inputs && !strcmp(open_inputs->name, \"out\") && curr_inputs) {",
"const char *VAR_10 = \"[out]\";",
"if ((VAR_6 = parse_outputs(&VAR_10, &curr_inputs, &open_inputs, &open_outputs,\nVAR_4)) < 0)\ngoto end;",
"}",
"end:\nif (VAR_2) *VAR_2 = open_inputs;",
"else avfilter_inout_free(&open_inputs);",
"if (VAR_3) *VAR_3 = open_outputs;",
"else avfilter_inout_free(&open_outputs);",
"avfilter_inout_free(&curr_inputs);",
"if (VAR_6 < 0) {",
"for (; VAR_0->filter_count > 0; VAR_0->filter_count--)",
"avfilter_free(VAR_0->VAR_1[VAR_0->filter_count - 1]);",
"av_freep(&VAR_0->VAR_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
] |
[
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33,
35
],
[
39,
41
],
[
45
],
[
49
],
[
51,
53
],
[
55
],
[
59,
61
],
[
65,
67,
69
],
[
73
],
[
75
],
[
79
],
[
81,
83,
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101,
103,
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
119
],
[
121,
123,
125
],
[
127
],
[
131,
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
]
] |
12,950
|
static inline int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr,
unsigned ch,
uint8_t *do_not_decode,
float *vec, unsigned vlen)
{
if (vr->type == 2)
return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 2);
else if (vr->type == 1)
return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 1);
else if (vr->type == 0)
return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 0);
else {
av_log(vc->avccontext, AV_LOG_ERROR, " Invalid residue type while residue decode?! \n");
return AVERROR_INVALIDDATA;
}
}
| true
|
FFmpeg
|
afb2aa537954db537d54358997b68f46561fd5a7
|
static inline int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr,
unsigned ch,
uint8_t *do_not_decode,
float *vec, unsigned vlen)
{
if (vr->type == 2)
return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 2);
else if (vr->type == 1)
return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 1);
else if (vr->type == 0)
return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 0);
else {
av_log(vc->avccontext, AV_LOG_ERROR, " Invalid residue type while residue decode?! \n");
return AVERROR_INVALIDDATA;
}
}
|
{
"code": [
" float *vec, unsigned vlen)",
" return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 2);",
" return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 1);",
" return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 0);"
],
"line_no": [
7,
13,
17,
21
]
}
|
static inline int FUNC_0(vorbis_context *VAR_0, vorbis_residue *VAR_1,
unsigned VAR_2,
uint8_t *VAR_3,
float *VAR_4, unsigned VAR_5)
{
if (VAR_1->type == 2)
return vorbis_residue_decode_internal(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, 2);
else if (VAR_1->type == 1)
return vorbis_residue_decode_internal(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, 1);
else if (VAR_1->type == 0)
return vorbis_residue_decode_internal(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, 0);
else {
av_log(VAR_0->avccontext, AV_LOG_ERROR, " Invalid residue type while residue decode?! \n");
return AVERROR_INVALIDDATA;
}
}
|
[
"static inline int FUNC_0(vorbis_context *VAR_0, vorbis_residue *VAR_1,\nunsigned VAR_2,\nuint8_t *VAR_3,\nfloat *VAR_4, unsigned VAR_5)\n{",
"if (VAR_1->type == 2)\nreturn vorbis_residue_decode_internal(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, 2);",
"else if (VAR_1->type == 1)\nreturn vorbis_residue_decode_internal(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, 1);",
"else if (VAR_1->type == 0)\nreturn vorbis_residue_decode_internal(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, 0);",
"else {",
"av_log(VAR_0->avccontext, AV_LOG_ERROR, \" Invalid residue type while residue decode?! \\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"}"
] |
[
1,
1,
1,
1,
0,
0,
0,
0,
0
] |
[
[
1,
3,
5,
7,
9
],
[
11,
13
],
[
15,
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
] |
12,952
|
static void common_end(FFV1Context *s){
int i;
for(i=0; i<s->plane_count; i++){
PlaneContext *p= &s->plane[i];
av_freep(&p->state);
}
}
| true
|
FFmpeg
|
0c2aaa882d124f05b7bf0a4a4abba3293f4d6d84
|
static void common_end(FFV1Context *s){
int i;
for(i=0; i<s->plane_count; i++){
PlaneContext *p= &s->plane[i];
av_freep(&p->state);
}
}
|
{
"code": [
"static void common_end(FFV1Context *s){"
],
"line_no": [
1
]
}
|
static void FUNC_0(FFV1Context *VAR_0){
int VAR_1;
for(VAR_1=0; VAR_1<VAR_0->plane_count; VAR_1++){
PlaneContext *p= &VAR_0->plane[VAR_1];
av_freep(&p->state);
}
}
|
[
"static void FUNC_0(FFV1Context *VAR_0){",
"int VAR_1;",
"for(VAR_1=0; VAR_1<VAR_0->plane_count; VAR_1++){",
"PlaneContext *p= &VAR_0->plane[VAR_1];",
"av_freep(&p->state);",
"}",
"}"
] |
[
1,
0,
0,
0,
0,
0,
0
] |
[
[
1
],
[
3
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
]
] |
12,953
|
static av_cold int ape_decode_close(AVCodecContext * avctx)
{
APEContext *s = avctx->priv_data;
int i;
for (i = 0; i < APE_FILTER_LEVELS; i++)
av_freep(&s->filterbuf[i]);
av_freep(&s->data);
return 0;
}
| true
|
FFmpeg
|
7500781313d11b37772c05a28da20fbc112db478
|
static av_cold int ape_decode_close(AVCodecContext * avctx)
{
APEContext *s = avctx->priv_data;
int i;
for (i = 0; i < APE_FILTER_LEVELS; i++)
av_freep(&s->filterbuf[i]);
av_freep(&s->data);
return 0;
}
|
{
"code": [
"static av_cold int ape_decode_close(AVCodecContext * avctx)",
" APEContext *s = avctx->priv_data;",
" int i;",
" for (i = 0; i < APE_FILTER_LEVELS; i++)",
" av_freep(&s->filterbuf[i]);",
" av_freep(&s->data);",
" return 0;"
],
"line_no": [
1,
5,
7,
11,
13,
17,
19
]
}
|
static av_cold int FUNC_0(AVCodecContext * avctx)
{
APEContext *s = avctx->priv_data;
int VAR_0;
for (VAR_0 = 0; VAR_0 < APE_FILTER_LEVELS; VAR_0++)
av_freep(&s->filterbuf[VAR_0]);
av_freep(&s->data);
return 0;
}
|
[
"static av_cold int FUNC_0(AVCodecContext * avctx)\n{",
"APEContext *s = avctx->priv_data;",
"int VAR_0;",
"for (VAR_0 = 0; VAR_0 < APE_FILTER_LEVELS; VAR_0++)",
"av_freep(&s->filterbuf[VAR_0]);",
"av_freep(&s->data);",
"return 0;",
"}"
] |
[
1,
1,
1,
1,
1,
1,
1,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
]
] |
12,954
|
static int qemu_chr_open_file_out(QemuOpts *opts, CharDriverState **_chr)
{
int fd_out;
TFR(fd_out = qemu_open(qemu_opt_get(opts, "path"),
O_WRONLY | O_TRUNC | O_CREAT | O_BINARY, 0666));
if (fd_out < 0) {
return -errno;
}
*_chr = qemu_chr_open_fd(-1, fd_out);
return 0;
}
| true
|
qemu
|
1f51470d044852592922f91000e741c381582cdc
|
static int qemu_chr_open_file_out(QemuOpts *opts, CharDriverState **_chr)
{
int fd_out;
TFR(fd_out = qemu_open(qemu_opt_get(opts, "path"),
O_WRONLY | O_TRUNC | O_CREAT | O_BINARY, 0666));
if (fd_out < 0) {
return -errno;
}
*_chr = qemu_chr_open_fd(-1, fd_out);
return 0;
}
|
{
"code": [
" return 0;",
" return 0;",
" return 0;",
" return 0;",
"static int qemu_chr_open_file_out(QemuOpts *opts, CharDriverState **_chr)",
" if (fd_out < 0) {",
" return -errno;",
" *_chr = qemu_chr_open_fd(-1, fd_out);",
" return 0;",
" return 0;",
" return 0;",
" return -errno;",
" return 0;",
" return -errno;",
" return 0;",
" return -errno;",
" return -errno;",
" return 0;",
" return -errno;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;"
],
"line_no": [
23,
23,
23,
23,
1,
13,
15,
21,
23,
23,
23,
15,
23,
15,
23,
15,
15,
23,
15,
23,
23,
23,
23,
23,
23,
23,
23
]
}
|
static int FUNC_0(QemuOpts *VAR_0, CharDriverState **VAR_1)
{
int VAR_2;
TFR(VAR_2 = qemu_open(qemu_opt_get(VAR_0, "path"),
O_WRONLY | O_TRUNC | O_CREAT | O_BINARY, 0666));
if (VAR_2 < 0) {
return -errno;
}
*VAR_1 = qemu_chr_open_fd(-1, VAR_2);
return 0;
}
|
[
"static int FUNC_0(QemuOpts *VAR_0, CharDriverState **VAR_1)\n{",
"int VAR_2;",
"TFR(VAR_2 = qemu_open(qemu_opt_get(VAR_0, \"path\"),\nO_WRONLY | O_TRUNC | O_CREAT | O_BINARY, 0666));",
"if (VAR_2 < 0) {",
"return -errno;",
"}",
"*VAR_1 = qemu_chr_open_fd(-1, VAR_2);",
"return 0;",
"}"
] |
[
1,
0,
0,
1,
1,
0,
1,
1,
0
] |
[
[
1,
3
],
[
5
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
]
] |
12,955
|
static int con_initialise(struct XenDevice *xendev)
{
struct XenConsole *con = container_of(xendev, struct XenConsole, xendev);
int limit;
if (xenstore_read_int(con->console, "ring-ref", &con->ring_ref) == -1)
return -1;
if (xenstore_read_int(con->console, "port", &con->xendev.remote_port) == -1)
return -1;
if (xenstore_read_int(con->console, "limit", &limit) == 0)
con->buffer.max_capacity = limit;
if (!xendev->dev) {
con->sring = xc_map_foreign_range(xen_xc, con->xendev.dom,
XC_PAGE_SIZE,
PROT_READ|PROT_WRITE,
con->ring_ref);
} else {
con->sring = xengnttab_map_grant_ref(xendev->gnttabdev, con->xendev.dom,
con->ring_ref,
PROT_READ|PROT_WRITE);
}
if (!con->sring)
return -1;
xen_be_bind_evtchn(&con->xendev);
if (con->chr) {
if (qemu_chr_fe_claim(con->chr) == 0) {
qemu_chr_add_handlers(con->chr, xencons_can_receive,
xencons_receive, NULL, con);
} else {
xen_be_printf(xendev, 0,
"xen_console_init error chardev %s already used\n",
con->chr->label);
con->chr = NULL;
}
}
xen_be_printf(xendev, 1, "ring mfn %d, remote port %d, local port %d, limit %zd\n",
con->ring_ref,
con->xendev.remote_port,
con->xendev.local_port,
con->buffer.max_capacity);
return 0;
}
| true
|
qemu
|
9ed257d1d1c65dbe5a08f207e5106e98384e1860
|
static int con_initialise(struct XenDevice *xendev)
{
struct XenConsole *con = container_of(xendev, struct XenConsole, xendev);
int limit;
if (xenstore_read_int(con->console, "ring-ref", &con->ring_ref) == -1)
return -1;
if (xenstore_read_int(con->console, "port", &con->xendev.remote_port) == -1)
return -1;
if (xenstore_read_int(con->console, "limit", &limit) == 0)
con->buffer.max_capacity = limit;
if (!xendev->dev) {
con->sring = xc_map_foreign_range(xen_xc, con->xendev.dom,
XC_PAGE_SIZE,
PROT_READ|PROT_WRITE,
con->ring_ref);
} else {
con->sring = xengnttab_map_grant_ref(xendev->gnttabdev, con->xendev.dom,
con->ring_ref,
PROT_READ|PROT_WRITE);
}
if (!con->sring)
return -1;
xen_be_bind_evtchn(&con->xendev);
if (con->chr) {
if (qemu_chr_fe_claim(con->chr) == 0) {
qemu_chr_add_handlers(con->chr, xencons_can_receive,
xencons_receive, NULL, con);
} else {
xen_be_printf(xendev, 0,
"xen_console_init error chardev %s already used\n",
con->chr->label);
con->chr = NULL;
}
}
xen_be_printf(xendev, 1, "ring mfn %d, remote port %d, local port %d, limit %zd\n",
con->ring_ref,
con->xendev.remote_port,
con->xendev.local_port,
con->buffer.max_capacity);
return 0;
}
|
{
"code": [
" con->sring = xc_map_foreign_range(xen_xc, con->xendev.dom,",
" XC_PAGE_SIZE,",
" PROT_READ|PROT_WRITE,",
" con->ring_ref);"
],
"line_no": [
27,
29,
31,
33
]
}
|
static int FUNC_0(struct XenDevice *VAR_0)
{
struct XenConsole *VAR_1 = container_of(VAR_0, struct XenConsole, VAR_0);
int VAR_2;
if (xenstore_read_int(VAR_1->console, "ring-ref", &VAR_1->ring_ref) == -1)
return -1;
if (xenstore_read_int(VAR_1->console, "port", &VAR_1->VAR_0.remote_port) == -1)
return -1;
if (xenstore_read_int(VAR_1->console, "VAR_2", &VAR_2) == 0)
VAR_1->buffer.max_capacity = VAR_2;
if (!VAR_0->dev) {
VAR_1->sring = xc_map_foreign_range(xen_xc, VAR_1->VAR_0.dom,
XC_PAGE_SIZE,
PROT_READ|PROT_WRITE,
VAR_1->ring_ref);
} else {
VAR_1->sring = xengnttab_map_grant_ref(VAR_0->gnttabdev, VAR_1->VAR_0.dom,
VAR_1->ring_ref,
PROT_READ|PROT_WRITE);
}
if (!VAR_1->sring)
return -1;
xen_be_bind_evtchn(&VAR_1->VAR_0);
if (VAR_1->chr) {
if (qemu_chr_fe_claim(VAR_1->chr) == 0) {
qemu_chr_add_handlers(VAR_1->chr, xencons_can_receive,
xencons_receive, NULL, VAR_1);
} else {
xen_be_printf(VAR_0, 0,
"xen_console_init error chardev %s already used\n",
VAR_1->chr->label);
VAR_1->chr = NULL;
}
}
xen_be_printf(VAR_0, 1, "ring mfn %d, remote port %d, local port %d, VAR_2 %zd\n",
VAR_1->ring_ref,
VAR_1->VAR_0.remote_port,
VAR_1->VAR_0.local_port,
VAR_1->buffer.max_capacity);
return 0;
}
|
[
"static int FUNC_0(struct XenDevice *VAR_0)\n{",
"struct XenConsole *VAR_1 = container_of(VAR_0, struct XenConsole, VAR_0);",
"int VAR_2;",
"if (xenstore_read_int(VAR_1->console, \"ring-ref\", &VAR_1->ring_ref) == -1)\nreturn -1;",
"if (xenstore_read_int(VAR_1->console, \"port\", &VAR_1->VAR_0.remote_port) == -1)\nreturn -1;",
"if (xenstore_read_int(VAR_1->console, \"VAR_2\", &VAR_2) == 0)\nVAR_1->buffer.max_capacity = VAR_2;",
"if (!VAR_0->dev) {",
"VAR_1->sring = xc_map_foreign_range(xen_xc, VAR_1->VAR_0.dom,\nXC_PAGE_SIZE,\nPROT_READ|PROT_WRITE,\nVAR_1->ring_ref);",
"} else {",
"VAR_1->sring = xengnttab_map_grant_ref(VAR_0->gnttabdev, VAR_1->VAR_0.dom,\nVAR_1->ring_ref,\nPROT_READ|PROT_WRITE);",
"}",
"if (!VAR_1->sring)\nreturn -1;",
"xen_be_bind_evtchn(&VAR_1->VAR_0);",
"if (VAR_1->chr) {",
"if (qemu_chr_fe_claim(VAR_1->chr) == 0) {",
"qemu_chr_add_handlers(VAR_1->chr, xencons_can_receive,\nxencons_receive, NULL, VAR_1);",
"} else {",
"xen_be_printf(VAR_0, 0,\n\"xen_console_init error chardev %s already used\\n\",\nVAR_1->chr->label);",
"VAR_1->chr = NULL;",
"}",
"}",
"xen_be_printf(VAR_0, 1, \"ring mfn %d, remote port %d, local port %d, VAR_2 %zd\\n\",\nVAR_1->ring_ref,\nVAR_1->VAR_0.remote_port,\nVAR_1->VAR_0.local_port,\nVAR_1->buffer.max_capacity);",
"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
] |
[
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15,
17
],
[
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
],
[
77,
79,
81,
83,
85
],
[
87
],
[
89
]
] |
12,956
|
static void writer_close(WriterContext **wctx)
{
int i;
if (!*wctx)
return;
if ((*wctx)->writer->uninit)
(*wctx)->writer->uninit(*wctx);
for (i = 0; i < SECTION_MAX_NB_LEVELS; i++)
av_bprint_finalize(&(*wctx)->section_pbuf[i], NULL);
if ((*wctx)->writer->priv_class)
av_opt_free((*wctx)->priv);
av_freep(&((*wctx)->priv));
av_freep(wctx);
}
| true
|
FFmpeg
|
704cc5e75df3a1dc68581d3857a06d502d8662b6
|
static void writer_close(WriterContext **wctx)
{
int i;
if (!*wctx)
return;
if ((*wctx)->writer->uninit)
(*wctx)->writer->uninit(*wctx);
for (i = 0; i < SECTION_MAX_NB_LEVELS; i++)
av_bprint_finalize(&(*wctx)->section_pbuf[i], NULL);
if ((*wctx)->writer->priv_class)
av_opt_free((*wctx)->priv);
av_freep(&((*wctx)->priv));
av_freep(wctx);
}
|
{
"code": [],
"line_no": []
}
|
static void FUNC_0(WriterContext **VAR_0)
{
int VAR_1;
if (!*VAR_0)
return;
if ((*VAR_0)->writer->uninit)
(*VAR_0)->writer->uninit(*VAR_0);
for (VAR_1 = 0; VAR_1 < SECTION_MAX_NB_LEVELS; VAR_1++)
av_bprint_finalize(&(*VAR_0)->section_pbuf[VAR_1], NULL);
if ((*VAR_0)->writer->priv_class)
av_opt_free((*VAR_0)->priv);
av_freep(&((*VAR_0)->priv));
av_freep(VAR_0);
}
|
[
"static void FUNC_0(WriterContext **VAR_0)\n{",
"int VAR_1;",
"if (!*VAR_0)\nreturn;",
"if ((*VAR_0)->writer->uninit)\n(*VAR_0)->writer->uninit(*VAR_0);",
"for (VAR_1 = 0; VAR_1 < SECTION_MAX_NB_LEVELS; VAR_1++)",
"av_bprint_finalize(&(*VAR_0)->section_pbuf[VAR_1], NULL);",
"if ((*VAR_0)->writer->priv_class)\nav_opt_free((*VAR_0)->priv);",
"av_freep(&((*VAR_0)->priv));",
"av_freep(VAR_0);",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
9,
11
],
[
15,
17
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
30
],
[
32
]
] |
12,957
|
static int avi_read_tag(AVFormatContext *s, AVStream *st, uint32_t tag, uint32_t size)
{
AVIOContext *pb = s->pb;
char key[5] = {0}, *value;
size += (size & 1);
if (size == UINT_MAX)
return -1;
value = av_malloc(size+1);
if (!value)
return -1;
avio_read(pb, value, size);
value[size]=0;
AV_WL32(key, tag);
return av_dict_set(st ? &st->metadata : &s->metadata, key, value,
AV_DICT_DONT_STRDUP_VAL);
}
| false
|
FFmpeg
|
570a4a0189946c2c983da41d37fdd67fa13266e7
|
static int avi_read_tag(AVFormatContext *s, AVStream *st, uint32_t tag, uint32_t size)
{
AVIOContext *pb = s->pb;
char key[5] = {0}, *value;
size += (size & 1);
if (size == UINT_MAX)
return -1;
value = av_malloc(size+1);
if (!value)
return -1;
avio_read(pb, value, size);
value[size]=0;
AV_WL32(key, tag);
return av_dict_set(st ? &st->metadata : &s->metadata, key, value,
AV_DICT_DONT_STRDUP_VAL);
}
|
{
"code": [],
"line_no": []
}
|
static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, uint32_t VAR_2, uint32_t VAR_3)
{
AVIOContext *pb = VAR_0->pb;
char VAR_4[5] = {0}, *VAR_5;
VAR_3 += (VAR_3 & 1);
if (VAR_3 == UINT_MAX)
return -1;
VAR_5 = av_malloc(VAR_3+1);
if (!VAR_5)
return -1;
avio_read(pb, VAR_5, VAR_3);
VAR_5[VAR_3]=0;
AV_WL32(VAR_4, VAR_2);
return av_dict_set(VAR_1 ? &VAR_1->metadata : &VAR_0->metadata, VAR_4, VAR_5,
AV_DICT_DONT_STRDUP_VAL);
}
|
[
"static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, uint32_t VAR_2, uint32_t VAR_3)\n{",
"AVIOContext *pb = VAR_0->pb;",
"char VAR_4[5] = {0}, *VAR_5;",
"VAR_3 += (VAR_3 & 1);",
"if (VAR_3 == UINT_MAX)\nreturn -1;",
"VAR_5 = av_malloc(VAR_3+1);",
"if (!VAR_5)\nreturn -1;",
"avio_read(pb, VAR_5, VAR_3);",
"VAR_5[VAR_3]=0;",
"AV_WL32(VAR_4, VAR_2);",
"return av_dict_set(VAR_1 ? &VAR_1->metadata : &VAR_0->metadata, VAR_4, VAR_5,\nAV_DICT_DONT_STRDUP_VAL);",
"}"
] |
[
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
],
[
35,
37
],
[
39
]
] |
12,958
|
static void set_dirty_tracking(void)
{
BlkMigDevState *bmds;
QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
bmds->dirty_bitmap = bdrv_create_dirty_bitmap(bmds->bs, BLOCK_SIZE);
}
}
| true
|
qemu
|
b8afb520e479e693c227aa39c2fb7670743e104f
|
static void set_dirty_tracking(void)
{
BlkMigDevState *bmds;
QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
bmds->dirty_bitmap = bdrv_create_dirty_bitmap(bmds->bs, BLOCK_SIZE);
}
}
|
{
"code": [
"static void set_dirty_tracking(void)",
" bmds->dirty_bitmap = bdrv_create_dirty_bitmap(bmds->bs, BLOCK_SIZE);"
],
"line_no": [
1,
11
]
}
|
static void FUNC_0(void)
{
BlkMigDevState *bmds;
QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
bmds->dirty_bitmap = bdrv_create_dirty_bitmap(bmds->bs, BLOCK_SIZE);
}
}
|
[
"static void FUNC_0(void)\n{",
"BlkMigDevState *bmds;",
"QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {",
"bmds->dirty_bitmap = bdrv_create_dirty_bitmap(bmds->bs, BLOCK_SIZE);",
"}",
"}"
] |
[
1,
0,
0,
1,
0,
0
] |
[
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
12,959
|
static inline void RENAME(nvXXtoUV)(uint8_t *dst1, uint8_t *dst2,
const uint8_t *src, int width)
{
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(
"movq "MANGLE(bm01010101)", %%mm4 \n\t"
"mov %0, %%"REG_a" \n\t"
"1: \n\t"
"movq (%1, %%"REG_a",2), %%mm0 \n\t"
"movq 8(%1, %%"REG_a",2), %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq %%mm1, %%mm3 \n\t"
"pand %%mm4, %%mm0 \n\t"
"pand %%mm4, %%mm1 \n\t"
"psrlw $8, %%mm2 \n\t"
"psrlw $8, %%mm3 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"packuswb %%mm3, %%mm2 \n\t"
"movq %%mm0, (%2, %%"REG_a") \n\t"
"movq %%mm2, (%3, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
" js 1b \n\t"
: : "g" ((x86_reg)-width), "r" (src+width*2), "r" (dst1+width), "r" (dst2+width)
: "%"REG_a
);
#else
int i;
for (i = 0; i < width; i++) {
dst1[i] = src[2*i+0];
dst2[i] = src[2*i+1];
}
#endif
}
| true
|
FFmpeg
|
c3ab0004ae4dffc32494ae84dd15cfaa909a7884
|
static inline void RENAME(nvXXtoUV)(uint8_t *dst1, uint8_t *dst2,
const uint8_t *src, int width)
{
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(
"movq "MANGLE(bm01010101)", %%mm4 \n\t"
"mov %0, %%"REG_a" \n\t"
"1: \n\t"
"movq (%1, %%"REG_a",2), %%mm0 \n\t"
"movq 8(%1, %%"REG_a",2), %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq %%mm1, %%mm3 \n\t"
"pand %%mm4, %%mm0 \n\t"
"pand %%mm4, %%mm1 \n\t"
"psrlw $8, %%mm2 \n\t"
"psrlw $8, %%mm3 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"packuswb %%mm3, %%mm2 \n\t"
"movq %%mm0, (%2, %%"REG_a") \n\t"
"movq %%mm2, (%3, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
" js 1b \n\t"
: : "g" ((x86_reg)-width), "r" (src+width*2), "r" (dst1+width), "r" (dst2+width)
: "%"REG_a
);
#else
int i;
for (i = 0; i < width; i++) {
dst1[i] = src[2*i+0];
dst2[i] = src[2*i+1];
}
#endif
}
|
{
"code": [
" const uint8_t *src, int width)"
],
"line_no": [
3
]
}
|
static inline void FUNC_0(nvXXtoUV)(uint8_t *dst1, uint8_t *dst2,
const uint8_t *src, int width)
{
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(
"movq "MANGLE(bm01010101)", %%mm4 \n\t"
"mov %0, %%"REG_a" \n\t"
"1: \n\t"
"movq (%1, %%"REG_a",2), %%mm0 \n\t"
"movq 8(%1, %%"REG_a",2), %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq %%mm1, %%mm3 \n\t"
"pand %%mm4, %%mm0 \n\t"
"pand %%mm4, %%mm1 \n\t"
"psrlw $8, %%mm2 \n\t"
"psrlw $8, %%mm3 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"packuswb %%mm3, %%mm2 \n\t"
"movq %%mm0, (%2, %%"REG_a") \n\t"
"movq %%mm2, (%3, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
" js 1b \n\t"
: : "g" ((x86_reg)-width), "r" (src+width*2), "r" (dst1+width), "r" (dst2+width)
: "%"REG_a
);
#else
int VAR_0;
for (VAR_0 = 0; VAR_0 < width; VAR_0++) {
dst1[VAR_0] = src[2*VAR_0+0];
dst2[VAR_0] = src[2*VAR_0+1];
}
#endif
}
|
[
"static inline void FUNC_0(nvXXtoUV)(uint8_t *dst1, uint8_t *dst2,\nconst uint8_t *src, int width)\n{",
"#if COMPILE_TEMPLATE_MMX\n__asm__ volatile(\n\"movq \"MANGLE(bm01010101)\", %%mm4 \\n\\t\"\n\"mov %0, %%\"REG_a\" \\n\\t\"\n\"1: \\n\\t\"\n\"movq (%1, %%\"REG_a\",2), %%mm0 \\n\\t\"\n\"movq 8(%1, %%\"REG_a\",2), %%mm1 \\n\\t\"\n\"movq %%mm0, %%mm2 \\n\\t\"\n\"movq %%mm1, %%mm3 \\n\\t\"\n\"pand %%mm4, %%mm0 \\n\\t\"\n\"pand %%mm4, %%mm1 \\n\\t\"\n\"psrlw $8, %%mm2 \\n\\t\"\n\"psrlw $8, %%mm3 \\n\\t\"\n\"packuswb %%mm1, %%mm0 \\n\\t\"\n\"packuswb %%mm3, %%mm2 \\n\\t\"\n\"movq %%mm0, (%2, %%\"REG_a\") \\n\\t\"\n\"movq %%mm2, (%3, %%\"REG_a\") \\n\\t\"\n\"add $8, %%\"REG_a\" \\n\\t\"\n\" js 1b \\n\\t\"\n: : \"g\" ((x86_reg)-width), \"r\" (src+width*2), \"r\" (dst1+width), \"r\" (dst2+width)\n: \"%\"REG_a\n);",
"#else\nint VAR_0;",
"for (VAR_0 = 0; VAR_0 < width; VAR_0++) {",
"dst1[VAR_0] = src[2*VAR_0+0];",
"dst2[VAR_0] = src[2*VAR_0+1];",
"}",
"#endif\n}"
] |
[
1,
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
]
] |
12,960
|
static int frame_copy_props(AVFrame *dst, const AVFrame *src, int force_copy)
{
int i;
dst->key_frame = src->key_frame;
dst->pict_type = src->pict_type;
dst->sample_aspect_ratio = src->sample_aspect_ratio;
dst->pts = src->pts;
dst->repeat_pict = src->repeat_pict;
dst->interlaced_frame = src->interlaced_frame;
dst->top_field_first = src->top_field_first;
dst->palette_has_changed = src->palette_has_changed;
dst->sample_rate = src->sample_rate;
dst->opaque = src->opaque;
#if FF_API_PKT_PTS
FF_DISABLE_DEPRECATION_WARNINGS
dst->pkt_pts = src->pkt_pts;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
dst->pkt_dts = src->pkt_dts;
dst->pkt_pos = src->pkt_pos;
dst->pkt_size = src->pkt_size;
dst->pkt_duration = src->pkt_duration;
dst->reordered_opaque = src->reordered_opaque;
dst->quality = src->quality;
dst->best_effort_timestamp = src->best_effort_timestamp;
dst->coded_picture_number = src->coded_picture_number;
dst->display_picture_number = src->display_picture_number;
dst->flags = src->flags;
dst->decode_error_flags = src->decode_error_flags;
dst->color_primaries = src->color_primaries;
dst->color_trc = src->color_trc;
dst->colorspace = src->colorspace;
dst->color_range = src->color_range;
dst->chroma_location = src->chroma_location;
av_dict_copy(&dst->metadata, src->metadata, 0);
#if FF_API_ERROR_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
memcpy(dst->error, src->error, sizeof(dst->error));
FF_ENABLE_DEPRECATION_WARNINGS
#endif
for (i = 0; i < src->nb_side_data; i++) {
const AVFrameSideData *sd_src = src->side_data[i];
AVFrameSideData *sd_dst;
if ( sd_src->type == AV_FRAME_DATA_PANSCAN
&& (src->width != dst->width || src->height != dst->height))
continue;
if (force_copy) {
sd_dst = av_frame_new_side_data(dst, sd_src->type,
sd_src->size);
if (!sd_dst) {
wipe_side_data(dst);
return AVERROR(ENOMEM);
memcpy(sd_dst->data, sd_src->data, sd_src->size);
} else {
sd_dst = av_frame_new_side_data(dst, sd_src->type, 0);
if (!sd_dst) {
wipe_side_data(dst);
return AVERROR(ENOMEM);
if (sd_src->buf) {
sd_dst->buf = av_buffer_ref(sd_src->buf);
if (!sd_dst->buf) {
wipe_side_data(dst);
return AVERROR(ENOMEM);
sd_dst->data = sd_dst->buf->data;
sd_dst->size = sd_dst->buf->size;
av_dict_copy(&sd_dst->metadata, sd_src->metadata, 0);
#if FF_API_FRAME_QP
FF_DISABLE_DEPRECATION_WARNINGS
dst->qscale_table = NULL;
dst->qstride = 0;
dst->qscale_type = 0;
av_buffer_unref(&dst->qp_table_buf);
if (src->qp_table_buf) {
dst->qp_table_buf = av_buffer_ref(src->qp_table_buf);
if (dst->qp_table_buf) {
dst->qscale_table = dst->qp_table_buf->data;
dst->qstride = src->qstride;
dst->qscale_type = src->qscale_type;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
return 0;
| true
|
FFmpeg
|
2acee08a4a53b6c8f5fc160e6d6da92f77208a06
|
static int frame_copy_props(AVFrame *dst, const AVFrame *src, int force_copy)
{
int i;
dst->key_frame = src->key_frame;
dst->pict_type = src->pict_type;
dst->sample_aspect_ratio = src->sample_aspect_ratio;
dst->pts = src->pts;
dst->repeat_pict = src->repeat_pict;
dst->interlaced_frame = src->interlaced_frame;
dst->top_field_first = src->top_field_first;
dst->palette_has_changed = src->palette_has_changed;
dst->sample_rate = src->sample_rate;
dst->opaque = src->opaque;
#if FF_API_PKT_PTS
FF_DISABLE_DEPRECATION_WARNINGS
dst->pkt_pts = src->pkt_pts;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
dst->pkt_dts = src->pkt_dts;
dst->pkt_pos = src->pkt_pos;
dst->pkt_size = src->pkt_size;
dst->pkt_duration = src->pkt_duration;
dst->reordered_opaque = src->reordered_opaque;
dst->quality = src->quality;
dst->best_effort_timestamp = src->best_effort_timestamp;
dst->coded_picture_number = src->coded_picture_number;
dst->display_picture_number = src->display_picture_number;
dst->flags = src->flags;
dst->decode_error_flags = src->decode_error_flags;
dst->color_primaries = src->color_primaries;
dst->color_trc = src->color_trc;
dst->colorspace = src->colorspace;
dst->color_range = src->color_range;
dst->chroma_location = src->chroma_location;
av_dict_copy(&dst->metadata, src->metadata, 0);
#if FF_API_ERROR_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
memcpy(dst->error, src->error, sizeof(dst->error));
FF_ENABLE_DEPRECATION_WARNINGS
#endif
for (i = 0; i < src->nb_side_data; i++) {
const AVFrameSideData *sd_src = src->side_data[i];
AVFrameSideData *sd_dst;
if ( sd_src->type == AV_FRAME_DATA_PANSCAN
&& (src->width != dst->width || src->height != dst->height))
continue;
if (force_copy) {
sd_dst = av_frame_new_side_data(dst, sd_src->type,
sd_src->size);
if (!sd_dst) {
wipe_side_data(dst);
return AVERROR(ENOMEM);
memcpy(sd_dst->data, sd_src->data, sd_src->size);
} else {
sd_dst = av_frame_new_side_data(dst, sd_src->type, 0);
if (!sd_dst) {
wipe_side_data(dst);
return AVERROR(ENOMEM);
if (sd_src->buf) {
sd_dst->buf = av_buffer_ref(sd_src->buf);
if (!sd_dst->buf) {
wipe_side_data(dst);
return AVERROR(ENOMEM);
sd_dst->data = sd_dst->buf->data;
sd_dst->size = sd_dst->buf->size;
av_dict_copy(&sd_dst->metadata, sd_src->metadata, 0);
#if FF_API_FRAME_QP
FF_DISABLE_DEPRECATION_WARNINGS
dst->qscale_table = NULL;
dst->qstride = 0;
dst->qscale_type = 0;
av_buffer_unref(&dst->qp_table_buf);
if (src->qp_table_buf) {
dst->qp_table_buf = av_buffer_ref(src->qp_table_buf);
if (dst->qp_table_buf) {
dst->qscale_table = dst->qp_table_buf->data;
dst->qstride = src->qstride;
dst->qscale_type = src->qscale_type;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
return 0;
|
{
"code": [],
"line_no": []
}
|
static int FUNC_0(AVFrame *VAR_0, const AVFrame *VAR_1, int VAR_2)
{
int VAR_3;
VAR_0->key_frame = VAR_1->key_frame;
VAR_0->pict_type = VAR_1->pict_type;
VAR_0->sample_aspect_ratio = VAR_1->sample_aspect_ratio;
VAR_0->pts = VAR_1->pts;
VAR_0->repeat_pict = VAR_1->repeat_pict;
VAR_0->interlaced_frame = VAR_1->interlaced_frame;
VAR_0->top_field_first = VAR_1->top_field_first;
VAR_0->palette_has_changed = VAR_1->palette_has_changed;
VAR_0->sample_rate = VAR_1->sample_rate;
VAR_0->opaque = VAR_1->opaque;
#if FF_API_PKT_PTS
FF_DISABLE_DEPRECATION_WARNINGS
VAR_0->pkt_pts = VAR_1->pkt_pts;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
VAR_0->pkt_dts = VAR_1->pkt_dts;
VAR_0->pkt_pos = VAR_1->pkt_pos;
VAR_0->pkt_size = VAR_1->pkt_size;
VAR_0->pkt_duration = VAR_1->pkt_duration;
VAR_0->reordered_opaque = VAR_1->reordered_opaque;
VAR_0->quality = VAR_1->quality;
VAR_0->best_effort_timestamp = VAR_1->best_effort_timestamp;
VAR_0->coded_picture_number = VAR_1->coded_picture_number;
VAR_0->display_picture_number = VAR_1->display_picture_number;
VAR_0->flags = VAR_1->flags;
VAR_0->decode_error_flags = VAR_1->decode_error_flags;
VAR_0->color_primaries = VAR_1->color_primaries;
VAR_0->color_trc = VAR_1->color_trc;
VAR_0->colorspace = VAR_1->colorspace;
VAR_0->color_range = VAR_1->color_range;
VAR_0->chroma_location = VAR_1->chroma_location;
av_dict_copy(&VAR_0->metadata, VAR_1->metadata, 0);
#if FF_API_ERROR_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
memcpy(VAR_0->error, VAR_1->error, sizeof(VAR_0->error));
FF_ENABLE_DEPRECATION_WARNINGS
#endif
for (VAR_3 = 0; VAR_3 < VAR_1->nb_side_data; VAR_3++) {
const AVFrameSideData *sd_src = VAR_1->side_data[VAR_3];
AVFrameSideData *sd_dst;
if ( sd_src->type == AV_FRAME_DATA_PANSCAN
&& (VAR_1->width != VAR_0->width || VAR_1->height != VAR_0->height))
continue;
if (VAR_2) {
sd_dst = av_frame_new_side_data(VAR_0, sd_src->type,
sd_src->size);
if (!sd_dst) {
wipe_side_data(VAR_0);
return AVERROR(ENOMEM);
memcpy(sd_dst->data, sd_src->data, sd_src->size);
} else {
sd_dst = av_frame_new_side_data(VAR_0, sd_src->type, 0);
if (!sd_dst) {
wipe_side_data(VAR_0);
return AVERROR(ENOMEM);
if (sd_src->buf) {
sd_dst->buf = av_buffer_ref(sd_src->buf);
if (!sd_dst->buf) {
wipe_side_data(VAR_0);
return AVERROR(ENOMEM);
sd_dst->data = sd_dst->buf->data;
sd_dst->size = sd_dst->buf->size;
av_dict_copy(&sd_dst->metadata, sd_src->metadata, 0);
#if FF_API_FRAME_QP
FF_DISABLE_DEPRECATION_WARNINGS
VAR_0->qscale_table = NULL;
VAR_0->qstride = 0;
VAR_0->qscale_type = 0;
av_buffer_unref(&VAR_0->qp_table_buf);
if (VAR_1->qp_table_buf) {
VAR_0->qp_table_buf = av_buffer_ref(VAR_1->qp_table_buf);
if (VAR_0->qp_table_buf) {
VAR_0->qscale_table = VAR_0->qp_table_buf->data;
VAR_0->qstride = VAR_1->qstride;
VAR_0->qscale_type = VAR_1->qscale_type;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
return 0;
|
[
"static int FUNC_0(AVFrame *VAR_0, const AVFrame *VAR_1, int VAR_2)\n{",
"int VAR_3;",
"VAR_0->key_frame = VAR_1->key_frame;",
"VAR_0->pict_type = VAR_1->pict_type;",
"VAR_0->sample_aspect_ratio = VAR_1->sample_aspect_ratio;",
"VAR_0->pts = VAR_1->pts;",
"VAR_0->repeat_pict = VAR_1->repeat_pict;",
"VAR_0->interlaced_frame = VAR_1->interlaced_frame;",
"VAR_0->top_field_first = VAR_1->top_field_first;",
"VAR_0->palette_has_changed = VAR_1->palette_has_changed;",
"VAR_0->sample_rate = VAR_1->sample_rate;",
"VAR_0->opaque = VAR_1->opaque;",
"#if FF_API_PKT_PTS\nFF_DISABLE_DEPRECATION_WARNINGS\nVAR_0->pkt_pts = VAR_1->pkt_pts;",
"FF_ENABLE_DEPRECATION_WARNINGS\n#endif\nVAR_0->pkt_dts = VAR_1->pkt_dts;",
"VAR_0->pkt_pos = VAR_1->pkt_pos;",
"VAR_0->pkt_size = VAR_1->pkt_size;",
"VAR_0->pkt_duration = VAR_1->pkt_duration;",
"VAR_0->reordered_opaque = VAR_1->reordered_opaque;",
"VAR_0->quality = VAR_1->quality;",
"VAR_0->best_effort_timestamp = VAR_1->best_effort_timestamp;",
"VAR_0->coded_picture_number = VAR_1->coded_picture_number;",
"VAR_0->display_picture_number = VAR_1->display_picture_number;",
"VAR_0->flags = VAR_1->flags;",
"VAR_0->decode_error_flags = VAR_1->decode_error_flags;",
"VAR_0->color_primaries = VAR_1->color_primaries;",
"VAR_0->color_trc = VAR_1->color_trc;",
"VAR_0->colorspace = VAR_1->colorspace;",
"VAR_0->color_range = VAR_1->color_range;",
"VAR_0->chroma_location = VAR_1->chroma_location;",
"av_dict_copy(&VAR_0->metadata, VAR_1->metadata, 0);",
"#if FF_API_ERROR_FRAME\nFF_DISABLE_DEPRECATION_WARNINGS\nmemcpy(VAR_0->error, VAR_1->error, sizeof(VAR_0->error));",
"FF_ENABLE_DEPRECATION_WARNINGS\n#endif\nfor (VAR_3 = 0; VAR_3 < VAR_1->nb_side_data; VAR_3++) {",
"const AVFrameSideData *sd_src = VAR_1->side_data[VAR_3];",
"AVFrameSideData *sd_dst;",
"if ( sd_src->type == AV_FRAME_DATA_PANSCAN\n&& (VAR_1->width != VAR_0->width || VAR_1->height != VAR_0->height))\ncontinue;",
"if (VAR_2) {",
"sd_dst = av_frame_new_side_data(VAR_0, sd_src->type,\nsd_src->size);",
"if (!sd_dst) {",
"wipe_side_data(VAR_0);",
"return AVERROR(ENOMEM);",
"memcpy(sd_dst->data, sd_src->data, sd_src->size);",
"} else {",
"sd_dst = av_frame_new_side_data(VAR_0, sd_src->type, 0);",
"if (!sd_dst) {",
"wipe_side_data(VAR_0);",
"return AVERROR(ENOMEM);",
"if (sd_src->buf) {",
"sd_dst->buf = av_buffer_ref(sd_src->buf);",
"if (!sd_dst->buf) {",
"wipe_side_data(VAR_0);",
"return AVERROR(ENOMEM);",
"sd_dst->data = sd_dst->buf->data;",
"sd_dst->size = sd_dst->buf->size;",
"av_dict_copy(&sd_dst->metadata, sd_src->metadata, 0);",
"#if FF_API_FRAME_QP\nFF_DISABLE_DEPRECATION_WARNINGS\nVAR_0->qscale_table = NULL;",
"VAR_0->qstride = 0;",
"VAR_0->qscale_type = 0;",
"av_buffer_unref(&VAR_0->qp_table_buf);",
"if (VAR_1->qp_table_buf) {",
"VAR_0->qp_table_buf = av_buffer_ref(VAR_1->qp_table_buf);",
"if (VAR_0->qp_table_buf) {",
"VAR_0->qscale_table = VAR_0->qp_table_buf->data;",
"VAR_0->qstride = VAR_1->qstride;",
"VAR_0->qscale_type = VAR_1->qscale_type;",
"FF_ENABLE_DEPRECATION_WARNINGS\n#endif\nreturn 0;"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
31,
33
],
[
35,
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
77,
79,
81
],
[
83,
85,
89
],
[
91
],
[
93
],
[
95,
97,
99
],
[
101
],
[
103,
105
],
[
107
],
[
109
],
[
111
],
[
114
],
[
116
],
[
118
],
[
120
],
[
122
],
[
124
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
138
],
[
140
],
[
144
],
[
149,
151,
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175,
177,
181
]
] |
12,961
|
static int img_create(int argc, char **argv)
{
int c, ret = 0;
uint64_t img_size = -1;
const char *fmt = "raw";
const char *base_fmt = NULL;
const char *filename;
const char *base_filename = NULL;
char *options = NULL;
for(;;) {
c = getopt(argc, argv, "F:b:f:he6o:");
if (c == -1) {
break;
}
switch(c) {
case '?':
case 'h':
help();
break;
case 'F':
base_fmt = optarg;
break;
case 'b':
base_filename = optarg;
break;
case 'f':
fmt = optarg;
break;
case 'e':
error_report("option -e is deprecated, please use \'-o "
"encryption\' instead!");
return 1;
case '6':
error_report("option -6 is deprecated, please use \'-o "
"compat6\' instead!");
return 1;
case 'o':
options = optarg;
break;
}
}
/* Get the filename */
if (optind >= argc) {
help();
}
filename = argv[optind++];
/* Get image size, if specified */
if (optind < argc) {
int64_t sval;
char *end;
sval = strtosz_suffix(argv[optind++], &end, STRTOSZ_DEFSUFFIX_B);
if (sval < 0 || *end) {
error_report("Invalid image size specified! You may use k, M, G or "
"T suffixes for ");
error_report("kilobytes, megabytes, gigabytes and terabytes.");
ret = -1;
goto out;
}
img_size = (uint64_t)sval;
}
if (options && !strcmp(options, "?")) {
ret = print_block_option_help(filename, fmt);
goto out;
}
ret = bdrv_img_create(filename, fmt, base_filename, base_fmt,
options, img_size, BDRV_O_FLAGS);
out:
if (ret) {
return 1;
}
return 0;
}
| true
|
qemu
|
c8057f951d64de93bfd01569c0a725baa9f94372
|
static int img_create(int argc, char **argv)
{
int c, ret = 0;
uint64_t img_size = -1;
const char *fmt = "raw";
const char *base_fmt = NULL;
const char *filename;
const char *base_filename = NULL;
char *options = NULL;
for(;;) {
c = getopt(argc, argv, "F:b:f:he6o:");
if (c == -1) {
break;
}
switch(c) {
case '?':
case 'h':
help();
break;
case 'F':
base_fmt = optarg;
break;
case 'b':
base_filename = optarg;
break;
case 'f':
fmt = optarg;
break;
case 'e':
error_report("option -e is deprecated, please use \'-o "
"encryption\' instead!");
return 1;
case '6':
error_report("option -6 is deprecated, please use \'-o "
"compat6\' instead!");
return 1;
case 'o':
options = optarg;
break;
}
}
if (optind >= argc) {
help();
}
filename = argv[optind++];
if (optind < argc) {
int64_t sval;
char *end;
sval = strtosz_suffix(argv[optind++], &end, STRTOSZ_DEFSUFFIX_B);
if (sval < 0 || *end) {
error_report("Invalid image size specified! You may use k, M, G or "
"T suffixes for ");
error_report("kilobytes, megabytes, gigabytes and terabytes.");
ret = -1;
goto out;
}
img_size = (uint64_t)sval;
}
if (options && !strcmp(options, "?")) {
ret = print_block_option_help(filename, fmt);
goto out;
}
ret = bdrv_img_create(filename, fmt, base_filename, base_fmt,
options, img_size, BDRV_O_FLAGS);
out:
if (ret) {
return 1;
}
return 0;
}
|
{
"code": [
" if (options && !strcmp(options, \"?\")) {",
" if (options && !strcmp(options, \"?\")) {"
],
"line_no": [
129,
129
]
}
|
static int FUNC_0(int VAR_0, char **VAR_1)
{
int VAR_2, VAR_3 = 0;
uint64_t img_size = -1;
const char *VAR_4 = "raw";
const char *VAR_5 = NULL;
const char *VAR_6;
const char *VAR_7 = NULL;
char *VAR_8 = NULL;
for(;;) {
VAR_2 = getopt(VAR_0, VAR_1, "F:b:f:he6o:");
if (VAR_2 == -1) {
break;
}
switch(VAR_2) {
case '?':
case 'h':
help();
break;
case 'F':
VAR_5 = optarg;
break;
case 'b':
VAR_7 = optarg;
break;
case 'f':
VAR_4 = optarg;
break;
case 'e':
error_report("option -e is deprecated, please use \'-o "
"encryption\' instead!");
return 1;
case '6':
error_report("option -6 is deprecated, please use \'-o "
"compat6\' instead!");
return 1;
case 'o':
VAR_8 = optarg;
break;
}
}
if (optind >= VAR_0) {
help();
}
VAR_6 = VAR_1[optind++];
if (optind < VAR_0) {
int64_t sval;
char *VAR_9;
sval = strtosz_suffix(VAR_1[optind++], &VAR_9, STRTOSZ_DEFSUFFIX_B);
if (sval < 0 || *VAR_9) {
error_report("Invalid image size specified! You may use k, M, G or "
"T suffixes for ");
error_report("kilobytes, megabytes, gigabytes and terabytes.");
VAR_3 = -1;
goto out;
}
img_size = (uint64_t)sval;
}
if (VAR_8 && !strcmp(VAR_8, "?")) {
VAR_3 = print_block_option_help(VAR_6, VAR_4);
goto out;
}
VAR_3 = bdrv_img_create(VAR_6, VAR_4, VAR_7, VAR_5,
VAR_8, img_size, BDRV_O_FLAGS);
out:
if (VAR_3) {
return 1;
}
return 0;
}
|
[
"static int FUNC_0(int VAR_0, char **VAR_1)\n{",
"int VAR_2, VAR_3 = 0;",
"uint64_t img_size = -1;",
"const char *VAR_4 = \"raw\";",
"const char *VAR_5 = NULL;",
"const char *VAR_6;",
"const char *VAR_7 = NULL;",
"char *VAR_8 = NULL;",
"for(;;) {",
"VAR_2 = getopt(VAR_0, VAR_1, \"F:b:f:he6o:\");",
"if (VAR_2 == -1) {",
"break;",
"}",
"switch(VAR_2) {",
"case '?':\ncase 'h':\nhelp();",
"break;",
"case 'F':\nVAR_5 = optarg;",
"break;",
"case 'b':\nVAR_7 = optarg;",
"break;",
"case 'f':\nVAR_4 = optarg;",
"break;",
"case 'e':\nerror_report(\"option -e is deprecated, please use \\'-o \"\n\"encryption\\' instead!\");",
"return 1;",
"case '6':\nerror_report(\"option -6 is deprecated, please use \\'-o \"\n\"compat6\\' instead!\");",
"return 1;",
"case 'o':\nVAR_8 = optarg;",
"break;",
"}",
"}",
"if (optind >= VAR_0) {",
"help();",
"}",
"VAR_6 = VAR_1[optind++];",
"if (optind < VAR_0) {",
"int64_t sval;",
"char *VAR_9;",
"sval = strtosz_suffix(VAR_1[optind++], &VAR_9, STRTOSZ_DEFSUFFIX_B);",
"if (sval < 0 || *VAR_9) {",
"error_report(\"Invalid image size specified! You may use k, M, G or \"\n\"T suffixes for \");",
"error_report(\"kilobytes, megabytes, gigabytes and terabytes.\");",
"VAR_3 = -1;",
"goto out;",
"}",
"img_size = (uint64_t)sval;",
"}",
"if (VAR_8 && !strcmp(VAR_8, \"?\")) {",
"VAR_3 = print_block_option_help(VAR_6, VAR_4);",
"goto out;",
"}",
"VAR_3 = bdrv_img_create(VAR_6, VAR_4, VAR_7, VAR_5,\nVAR_8, img_size, BDRV_O_FLAGS);",
"out:\nif (VAR_3) {",
"return 1;",
"}",
"return 0;",
"}"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33,
35,
37
],
[
39
],
[
41,
43
],
[
45
],
[
47,
49
],
[
51
],
[
53,
55
],
[
57
],
[
59,
61,
63
],
[
65
],
[
67,
69,
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
89
],
[
91
],
[
93
],
[
95
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
139,
141
],
[
143,
145
],
[
147
],
[
149
],
[
151
],
[
153
]
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.