id
int32 0
27.3k
| func
stringlengths 26
142k
| target
bool 2
classes | project
stringclasses 2
values | commit_id
stringlengths 40
40
| func_clean
stringlengths 26
131k
| vul_lines
dict | normalized_func
stringlengths 24
132k
| lines
sequencelengths 1
2.8k
| label
sequencelengths 1
2.8k
| line_no
sequencelengths 1
2.8k
|
---|---|---|---|---|---|---|---|---|---|---|
24,891 | void ff_mpeg_flush(AVCodecContext *avctx){
int i;
MpegEncContext *s = avctx->priv_data;
if(s==NULL || s->picture==NULL)
return;
for(i=0; i<MAX_PICTURE_COUNT; i++){
if(s->picture[i].data[0] && ( s->picture[i].type == FF_BUFFER_TYPE_INTERNAL
|| s->picture[i].type == FF_BUFFER_TYPE_USER))
avctx->release_buffer(avctx, (AVFrame*)&s->picture[i]);
}
s->current_picture_ptr = s->last_picture_ptr = s->next_picture_ptr = NULL;
s->mb_x= s->mb_y= 0;
s->parse_context.state= -1;
s->parse_context.frame_start_found= 0;
s->parse_context.overread= 0;
s->parse_context.overread_index= 0;
s->parse_context.index= 0;
s->parse_context.last_index= 0;
s->bitstream_buffer_size=0;
} | true | FFmpeg | 2d0bcfb412a618e8130fbfea15df76eb0f7dac45 | void ff_mpeg_flush(AVCodecContext *avctx){
int i;
MpegEncContext *s = avctx->priv_data;
if(s==NULL || s->picture==NULL)
return;
for(i=0; i<MAX_PICTURE_COUNT; i++){
if(s->picture[i].data[0] && ( s->picture[i].type == FF_BUFFER_TYPE_INTERNAL
|| s->picture[i].type == FF_BUFFER_TYPE_USER))
avctx->release_buffer(avctx, (AVFrame*)&s->picture[i]);
}
s->current_picture_ptr = s->last_picture_ptr = s->next_picture_ptr = NULL;
s->mb_x= s->mb_y= 0;
s->parse_context.state= -1;
s->parse_context.frame_start_found= 0;
s->parse_context.overread= 0;
s->parse_context.overread_index= 0;
s->parse_context.index= 0;
s->parse_context.last_index= 0;
s->bitstream_buffer_size=0;
} | {
"code": [],
"line_no": []
} | void FUNC_0(AVCodecContext *VAR_0){
int VAR_1;
MpegEncContext *s = VAR_0->priv_data;
if(s==NULL || s->picture==NULL)
return;
for(VAR_1=0; VAR_1<MAX_PICTURE_COUNT; VAR_1++){
if(s->picture[VAR_1].data[0] && ( s->picture[VAR_1].type == FF_BUFFER_TYPE_INTERNAL
|| s->picture[VAR_1].type == FF_BUFFER_TYPE_USER))
VAR_0->release_buffer(VAR_0, (AVFrame*)&s->picture[VAR_1]);
}
s->current_picture_ptr = s->last_picture_ptr = s->next_picture_ptr = NULL;
s->mb_x= s->mb_y= 0;
s->parse_context.state= -1;
s->parse_context.frame_start_found= 0;
s->parse_context.overread= 0;
s->parse_context.overread_index= 0;
s->parse_context.index= 0;
s->parse_context.last_index= 0;
s->bitstream_buffer_size=0;
} | [
"void FUNC_0(AVCodecContext *VAR_0){",
"int VAR_1;",
"MpegEncContext *s = VAR_0->priv_data;",
"if(s==NULL || s->picture==NULL)\nreturn;",
"for(VAR_1=0; VAR_1<MAX_PICTURE_COUNT; VAR_1++){",
"if(s->picture[VAR_1].data[0] && ( s->picture[VAR_1].type == FF_BUFFER_TYPE_INTERNAL\n|| s->picture[VAR_1].type == FF_BUFFER_TYPE_USER))\nVAR_0->release_buffer(VAR_0, (AVFrame*)&s->picture[VAR_1]);",
"}",
"s->current_picture_ptr = s->last_picture_ptr = s->next_picture_ptr = NULL;",
"s->mb_x= s->mb_y= 0;",
"s->parse_context.state= -1;",
"s->parse_context.frame_start_found= 0;",
"s->parse_context.overread= 0;",
"s->parse_context.overread_index= 0;",
"s->parse_context.index= 0;",
"s->parse_context.last_index= 0;",
"s->bitstream_buffer_size=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
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
48
]
] |
24,892 | void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t window_size, int *pfd)
{
struct kvm_create_spapr_tce args = {
.liobn = liobn,
.window_size = window_size,
};
long len;
int fd;
void *table;
/* Must set fd to -1 so we don't try to munmap when called for
* destroying the table, which the upper layers -will- do
*/
*pfd = -1;
if (!cap_spapr_tce) {
return NULL;
}
fd = kvm_vm_ioctl(kvm_state, KVM_CREATE_SPAPR_TCE, &args);
if (fd < 0) {
fprintf(stderr, "KVM: Failed to create TCE table for liobn 0x%x\n",
liobn);
return NULL;
}
len = (window_size / SPAPR_VIO_TCE_PAGE_SIZE) * sizeof(VIOsPAPR_RTCE);
/* FIXME: round this up to page size */
table = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
if (table == MAP_FAILED) {
fprintf(stderr, "KVM: Failed to map TCE table for liobn 0x%x\n",
liobn);
close(fd);
return NULL;
}
*pfd = fd;
return table;
}
| true | qemu | ad0ebb91cd8b5fdc4a583b03645677771f420a46 | void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t window_size, int *pfd)
{
struct kvm_create_spapr_tce args = {
.liobn = liobn,
.window_size = window_size,
};
long len;
int fd;
void *table;
*pfd = -1;
if (!cap_spapr_tce) {
return NULL;
}
fd = kvm_vm_ioctl(kvm_state, KVM_CREATE_SPAPR_TCE, &args);
if (fd < 0) {
fprintf(stderr, "KVM: Failed to create TCE table for liobn 0x%x\n",
liobn);
return NULL;
}
len = (window_size / SPAPR_VIO_TCE_PAGE_SIZE) * sizeof(VIOsPAPR_RTCE);
table = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
if (table == MAP_FAILED) {
fprintf(stderr, "KVM: Failed to map TCE table for liobn 0x%x\n",
liobn);
close(fd);
return NULL;
}
*pfd = fd;
return table;
}
| {
"code": [
" len = (window_size / SPAPR_VIO_TCE_PAGE_SIZE) * sizeof(VIOsPAPR_RTCE);"
],
"line_no": [
51
]
} | void *FUNC_0(uint32_t VAR_0, uint32_t VAR_1, int *VAR_2)
{
struct kvm_create_spapr_tce VAR_3 = {
.VAR_0 = VAR_0,
.VAR_1 = VAR_1,
};
long VAR_4;
int VAR_5;
void *VAR_6;
*VAR_2 = -1;
if (!cap_spapr_tce) {
return NULL;
}
VAR_5 = kvm_vm_ioctl(kvm_state, KVM_CREATE_SPAPR_TCE, &VAR_3);
if (VAR_5 < 0) {
fprintf(stderr, "KVM: Failed to create TCE VAR_6 for VAR_0 0x%x\n",
VAR_0);
return NULL;
}
VAR_4 = (VAR_1 / SPAPR_VIO_TCE_PAGE_SIZE) * sizeof(VIOsPAPR_RTCE);
VAR_6 = mmap(NULL, VAR_4, PROT_READ|PROT_WRITE, MAP_SHARED, VAR_5, 0);
if (VAR_6 == MAP_FAILED) {
fprintf(stderr, "KVM: Failed to map TCE VAR_6 for VAR_0 0x%x\n",
VAR_0);
close(VAR_5);
return NULL;
}
*VAR_2 = VAR_5;
return VAR_6;
}
| [
"void *FUNC_0(uint32_t VAR_0, uint32_t VAR_1, int *VAR_2)\n{",
"struct kvm_create_spapr_tce VAR_3 = {",
".VAR_0 = VAR_0,\n.VAR_1 = VAR_1,\n};",
"long VAR_4;",
"int VAR_5;",
"void *VAR_6;",
"*VAR_2 = -1;",
"if (!cap_spapr_tce) {",
"return NULL;",
"}",
"VAR_5 = kvm_vm_ioctl(kvm_state, KVM_CREATE_SPAPR_TCE, &VAR_3);",
"if (VAR_5 < 0) {",
"fprintf(stderr, \"KVM: Failed to create TCE VAR_6 for VAR_0 0x%x\\n\",\nVAR_0);",
"return NULL;",
"}",
"VAR_4 = (VAR_1 / SPAPR_VIO_TCE_PAGE_SIZE) * sizeof(VIOsPAPR_RTCE);",
"VAR_6 = mmap(NULL, VAR_4, PROT_READ|PROT_WRITE, MAP_SHARED, VAR_5, 0);",
"if (VAR_6 == MAP_FAILED) {",
"fprintf(stderr, \"KVM: Failed to map TCE VAR_6 for VAR_0 0x%x\\n\",\nVAR_0);",
"close(VAR_5);",
"return NULL;",
"}",
"*VAR_2 = VAR_5;",
"return VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
51
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
]
] |
24,893 | long do_rt_sigreturn(CPUM68KState *env)
{
struct target_rt_sigframe *frame;
abi_ulong frame_addr = env->aregs[7] - 4;
target_sigset_t target_set;
sigset_t set;
trace_user_do_rt_sigreturn(env, frame_addr);
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
target_to_host_sigset_internal(&set, &target_set);
set_sigmask(&set);
/* restore registers */
if (target_rt_restore_ucontext(env, &frame->uc))
goto badframe;
if (do_sigaltstack(frame_addr +
offsetof(struct target_rt_sigframe, uc.tuc_stack),
0, get_sp_from_cpustate(env)) == -EFAULT)
goto badframe;
unlock_user_struct(frame, frame_addr, 0);
return -TARGET_QEMU_ESIGRETURN;
badframe:
unlock_user_struct(frame, frame_addr, 0);
force_sig(TARGET_SIGSEGV);
return 0;
}
| true | qemu | c599d4d6d6e9bfdb64e54c33a22cb26e3496b96d | long do_rt_sigreturn(CPUM68KState *env)
{
struct target_rt_sigframe *frame;
abi_ulong frame_addr = env->aregs[7] - 4;
target_sigset_t target_set;
sigset_t set;
trace_user_do_rt_sigreturn(env, frame_addr);
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
target_to_host_sigset_internal(&set, &target_set);
set_sigmask(&set);
if (target_rt_restore_ucontext(env, &frame->uc))
goto badframe;
if (do_sigaltstack(frame_addr +
offsetof(struct target_rt_sigframe, uc.tuc_stack),
0, get_sp_from_cpustate(env)) == -EFAULT)
goto badframe;
unlock_user_struct(frame, frame_addr, 0);
return -TARGET_QEMU_ESIGRETURN;
badframe:
unlock_user_struct(frame, frame_addr, 0);
force_sig(TARGET_SIGSEGV);
return 0;
}
| {
"code": [
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;",
" return 0;"
],
"line_no": [
61,
61,
61,
61,
61,
61,
61,
61,
61,
61,
61,
61,
61,
61,
61,
61,
61
]
} | long FUNC_0(CPUM68KState *VAR_0)
{
struct target_rt_sigframe *VAR_1;
abi_ulong frame_addr = VAR_0->aregs[7] - 4;
target_sigset_t target_set;
sigset_t set;
trace_user_do_rt_sigreturn(VAR_0, frame_addr);
if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1))
goto badframe;
target_to_host_sigset_internal(&set, &target_set);
set_sigmask(&set);
if (target_rt_restore_ucontext(VAR_0, &VAR_1->uc))
goto badframe;
if (do_sigaltstack(frame_addr +
offsetof(struct target_rt_sigframe, uc.tuc_stack),
0, get_sp_from_cpustate(VAR_0)) == -EFAULT)
goto badframe;
unlock_user_struct(VAR_1, frame_addr, 0);
return -TARGET_QEMU_ESIGRETURN;
badframe:
unlock_user_struct(VAR_1, frame_addr, 0);
force_sig(TARGET_SIGSEGV);
return 0;
}
| [
"long FUNC_0(CPUM68KState *VAR_0)\n{",
"struct target_rt_sigframe *VAR_1;",
"abi_ulong frame_addr = VAR_0->aregs[7] - 4;",
"target_sigset_t target_set;",
"sigset_t set;",
"trace_user_do_rt_sigreturn(VAR_0, frame_addr);",
"if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1))\ngoto badframe;",
"target_to_host_sigset_internal(&set, &target_set);",
"set_sigmask(&set);",
"if (target_rt_restore_ucontext(VAR_0, &VAR_1->uc))\ngoto badframe;",
"if (do_sigaltstack(frame_addr +\noffsetof(struct target_rt_sigframe, uc.tuc_stack),\n0, get_sp_from_cpustate(VAR_0)) == -EFAULT)\ngoto badframe;",
"unlock_user_struct(VAR_1, frame_addr, 0);",
"return -TARGET_QEMU_ESIGRETURN;",
"badframe:\nunlock_user_struct(VAR_1, frame_addr, 0);",
"force_sig(TARGET_SIGSEGV);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17,
19
],
[
23
],
[
25
],
[
33,
35
],
[
39,
41,
43,
45
],
[
49
],
[
51
],
[
55,
57
],
[
59
],
[
61
],
[
63
]
] |
24,894 | static BlockAIOCB *bdrv_co_aio_prw_vector(BdrvChild *child,
int64_t offset,
QEMUIOVector *qiov,
BdrvRequestFlags flags,
BlockCompletionFunc *cb,
void *opaque,
bool is_write)
{
Coroutine *co;
BlockAIOCBCoroutine *acb;
/* Matched by bdrv_co_complete's bdrv_dec_in_flight. */
bdrv_inc_in_flight(child->bs);
acb = qemu_aio_get(&bdrv_em_co_aiocb_info, child->bs, cb, opaque);
acb->child = child;
acb->need_bh = true;
acb->req.error = -EINPROGRESS;
acb->req.offset = offset;
acb->req.qiov = qiov;
acb->req.flags = flags;
acb->is_write = is_write;
co = qemu_coroutine_create(bdrv_co_do_rw, acb);
qemu_coroutine_enter(co);
bdrv_co_maybe_schedule_bh(acb);
return &acb->common;
}
| true | qemu | e92f0e1910f0655a0edd8d87c5a7262d36517a89 | static BlockAIOCB *bdrv_co_aio_prw_vector(BdrvChild *child,
int64_t offset,
QEMUIOVector *qiov,
BdrvRequestFlags flags,
BlockCompletionFunc *cb,
void *opaque,
bool is_write)
{
Coroutine *co;
BlockAIOCBCoroutine *acb;
bdrv_inc_in_flight(child->bs);
acb = qemu_aio_get(&bdrv_em_co_aiocb_info, child->bs, cb, opaque);
acb->child = child;
acb->need_bh = true;
acb->req.error = -EINPROGRESS;
acb->req.offset = offset;
acb->req.qiov = qiov;
acb->req.flags = flags;
acb->is_write = is_write;
co = qemu_coroutine_create(bdrv_co_do_rw, acb);
qemu_coroutine_enter(co);
bdrv_co_maybe_schedule_bh(acb);
return &acb->common;
}
| {
"code": [
" qemu_coroutine_enter(co);",
" qemu_coroutine_enter(co);",
" qemu_coroutine_enter(co);"
],
"line_no": [
49,
49,
49
]
} | static BlockAIOCB *FUNC_0(BdrvChild *child,
int64_t offset,
QEMUIOVector *qiov,
BdrvRequestFlags flags,
BlockCompletionFunc *cb,
void *opaque,
bool is_write)
{
Coroutine *co;
BlockAIOCBCoroutine *acb;
bdrv_inc_in_flight(child->bs);
acb = qemu_aio_get(&bdrv_em_co_aiocb_info, child->bs, cb, opaque);
acb->child = child;
acb->need_bh = true;
acb->req.error = -EINPROGRESS;
acb->req.offset = offset;
acb->req.qiov = qiov;
acb->req.flags = flags;
acb->is_write = is_write;
co = qemu_coroutine_create(bdrv_co_do_rw, acb);
qemu_coroutine_enter(co);
bdrv_co_maybe_schedule_bh(acb);
return &acb->common;
}
| [
"static BlockAIOCB *FUNC_0(BdrvChild *child,\nint64_t offset,\nQEMUIOVector *qiov,\nBdrvRequestFlags flags,\nBlockCompletionFunc *cb,\nvoid *opaque,\nbool is_write)\n{",
"Coroutine *co;",
"BlockAIOCBCoroutine *acb;",
"bdrv_inc_in_flight(child->bs);",
"acb = qemu_aio_get(&bdrv_em_co_aiocb_info, child->bs, cb, opaque);",
"acb->child = child;",
"acb->need_bh = true;",
"acb->req.error = -EINPROGRESS;",
"acb->req.offset = offset;",
"acb->req.qiov = qiov;",
"acb->req.flags = flags;",
"acb->is_write = is_write;",
"co = qemu_coroutine_create(bdrv_co_do_rw, acb);",
"qemu_coroutine_enter(co);",
"bdrv_co_maybe_schedule_bh(acb);",
"return &acb->common;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13,
15
],
[
17
],
[
19
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
]
] |
24,898 | static void ahci_port_write(AHCIState *s, int port, int offset, uint32_t val)
{
AHCIPortRegs *pr = &s->dev[port].port_regs;
DPRINTF(port, "offset: 0x%x val: 0x%x\n", offset, val);
switch (offset) {
case PORT_LST_ADDR:
pr->lst_addr = val;
map_page(s->as, &s->dev[port].lst,
((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr, 1024);
s->dev[port].cur_cmd = NULL;
break;
case PORT_LST_ADDR_HI:
pr->lst_addr_hi = val;
map_page(s->as, &s->dev[port].lst,
((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr, 1024);
s->dev[port].cur_cmd = NULL;
break;
case PORT_FIS_ADDR:
pr->fis_addr = val;
map_page(s->as, &s->dev[port].res_fis,
((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr, 256);
break;
case PORT_FIS_ADDR_HI:
pr->fis_addr_hi = val;
map_page(s->as, &s->dev[port].res_fis,
((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr, 256);
break;
case PORT_IRQ_STAT:
pr->irq_stat &= ~val;
ahci_check_irq(s);
break;
case PORT_IRQ_MASK:
pr->irq_mask = val & 0xfdc000ff;
ahci_check_irq(s);
break;
case PORT_CMD:
pr->cmd = val & ~(PORT_CMD_LIST_ON | PORT_CMD_FIS_ON);
if (pr->cmd & PORT_CMD_START) {
pr->cmd |= PORT_CMD_LIST_ON;
}
if (pr->cmd & PORT_CMD_FIS_RX) {
pr->cmd |= PORT_CMD_FIS_ON;
}
/* XXX usually the FIS would be pending on the bus here and
issuing deferred until the OS enables FIS receival.
Instead, we only submit it once - which works in most
cases, but is a hack. */
if ((pr->cmd & PORT_CMD_FIS_ON) &&
!s->dev[port].init_d2h_sent) {
ahci_init_d2h(&s->dev[port]);
s->dev[port].init_d2h_sent = true;
}
check_cmd(s, port);
break;
case PORT_TFDATA:
s->dev[port].port.ifs[0].error = (val >> 8) & 0xff;
s->dev[port].port.ifs[0].status = val & 0xff;
break;
case PORT_SIG:
pr->sig = val;
break;
case PORT_SCR_STAT:
pr->scr_stat = val;
break;
case PORT_SCR_CTL:
if (((pr->scr_ctl & AHCI_SCR_SCTL_DET) == 1) &&
((val & AHCI_SCR_SCTL_DET) == 0)) {
ahci_reset_port(s, port);
}
pr->scr_ctl = val;
break;
case PORT_SCR_ERR:
pr->scr_err &= ~val;
break;
case PORT_SCR_ACT:
/* RW1 */
pr->scr_act |= val;
break;
case PORT_CMD_ISSUE:
pr->cmd_issue |= val;
check_cmd(s, port);
break;
default:
break;
}
}
| true | qemu | fac7aa7fc2ebc26803b0a7b44b010f47ce3e1dd8 | static void ahci_port_write(AHCIState *s, int port, int offset, uint32_t val)
{
AHCIPortRegs *pr = &s->dev[port].port_regs;
DPRINTF(port, "offset: 0x%x val: 0x%x\n", offset, val);
switch (offset) {
case PORT_LST_ADDR:
pr->lst_addr = val;
map_page(s->as, &s->dev[port].lst,
((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr, 1024);
s->dev[port].cur_cmd = NULL;
break;
case PORT_LST_ADDR_HI:
pr->lst_addr_hi = val;
map_page(s->as, &s->dev[port].lst,
((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr, 1024);
s->dev[port].cur_cmd = NULL;
break;
case PORT_FIS_ADDR:
pr->fis_addr = val;
map_page(s->as, &s->dev[port].res_fis,
((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr, 256);
break;
case PORT_FIS_ADDR_HI:
pr->fis_addr_hi = val;
map_page(s->as, &s->dev[port].res_fis,
((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr, 256);
break;
case PORT_IRQ_STAT:
pr->irq_stat &= ~val;
ahci_check_irq(s);
break;
case PORT_IRQ_MASK:
pr->irq_mask = val & 0xfdc000ff;
ahci_check_irq(s);
break;
case PORT_CMD:
pr->cmd = val & ~(PORT_CMD_LIST_ON | PORT_CMD_FIS_ON);
if (pr->cmd & PORT_CMD_START) {
pr->cmd |= PORT_CMD_LIST_ON;
}
if (pr->cmd & PORT_CMD_FIS_RX) {
pr->cmd |= PORT_CMD_FIS_ON;
}
if ((pr->cmd & PORT_CMD_FIS_ON) &&
!s->dev[port].init_d2h_sent) {
ahci_init_d2h(&s->dev[port]);
s->dev[port].init_d2h_sent = true;
}
check_cmd(s, port);
break;
case PORT_TFDATA:
s->dev[port].port.ifs[0].error = (val >> 8) & 0xff;
s->dev[port].port.ifs[0].status = val & 0xff;
break;
case PORT_SIG:
pr->sig = val;
break;
case PORT_SCR_STAT:
pr->scr_stat = val;
break;
case PORT_SCR_CTL:
if (((pr->scr_ctl & AHCI_SCR_SCTL_DET) == 1) &&
((val & AHCI_SCR_SCTL_DET) == 0)) {
ahci_reset_port(s, port);
}
pr->scr_ctl = val;
break;
case PORT_SCR_ERR:
pr->scr_err &= ~val;
break;
case PORT_SCR_ACT:
pr->scr_act |= val;
break;
case PORT_CMD_ISSUE:
pr->cmd_issue |= val;
check_cmd(s, port);
break;
default:
break;
}
}
| {
"code": [
" s->dev[port].port.ifs[0].error = (val >> 8) & 0xff;",
" s->dev[port].port.ifs[0].status = val & 0xff;",
" pr->sig = val;",
" pr->scr_stat = val;",
" AHCIPortRegs *pr = &s->dev[port].port_regs;"
],
"line_no": [
121,
123,
129,
135,
5
]
} | static void FUNC_0(AHCIState *VAR_0, int VAR_1, int VAR_2, uint32_t VAR_3)
{
AHCIPortRegs *pr = &VAR_0->dev[VAR_1].port_regs;
DPRINTF(VAR_1, "VAR_2: 0x%x VAR_3: 0x%x\n", VAR_2, VAR_3);
switch (VAR_2) {
case PORT_LST_ADDR:
pr->lst_addr = VAR_3;
map_page(VAR_0->as, &VAR_0->dev[VAR_1].lst,
((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr, 1024);
VAR_0->dev[VAR_1].cur_cmd = NULL;
break;
case PORT_LST_ADDR_HI:
pr->lst_addr_hi = VAR_3;
map_page(VAR_0->as, &VAR_0->dev[VAR_1].lst,
((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr, 1024);
VAR_0->dev[VAR_1].cur_cmd = NULL;
break;
case PORT_FIS_ADDR:
pr->fis_addr = VAR_3;
map_page(VAR_0->as, &VAR_0->dev[VAR_1].res_fis,
((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr, 256);
break;
case PORT_FIS_ADDR_HI:
pr->fis_addr_hi = VAR_3;
map_page(VAR_0->as, &VAR_0->dev[VAR_1].res_fis,
((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr, 256);
break;
case PORT_IRQ_STAT:
pr->irq_stat &= ~VAR_3;
ahci_check_irq(VAR_0);
break;
case PORT_IRQ_MASK:
pr->irq_mask = VAR_3 & 0xfdc000ff;
ahci_check_irq(VAR_0);
break;
case PORT_CMD:
pr->cmd = VAR_3 & ~(PORT_CMD_LIST_ON | PORT_CMD_FIS_ON);
if (pr->cmd & PORT_CMD_START) {
pr->cmd |= PORT_CMD_LIST_ON;
}
if (pr->cmd & PORT_CMD_FIS_RX) {
pr->cmd |= PORT_CMD_FIS_ON;
}
if ((pr->cmd & PORT_CMD_FIS_ON) &&
!VAR_0->dev[VAR_1].init_d2h_sent) {
ahci_init_d2h(&VAR_0->dev[VAR_1]);
VAR_0->dev[VAR_1].init_d2h_sent = true;
}
check_cmd(VAR_0, VAR_1);
break;
case PORT_TFDATA:
VAR_0->dev[VAR_1].VAR_1.ifs[0].error = (VAR_3 >> 8) & 0xff;
VAR_0->dev[VAR_1].VAR_1.ifs[0].status = VAR_3 & 0xff;
break;
case PORT_SIG:
pr->sig = VAR_3;
break;
case PORT_SCR_STAT:
pr->scr_stat = VAR_3;
break;
case PORT_SCR_CTL:
if (((pr->scr_ctl & AHCI_SCR_SCTL_DET) == 1) &&
((VAR_3 & AHCI_SCR_SCTL_DET) == 0)) {
ahci_reset_port(VAR_0, VAR_1);
}
pr->scr_ctl = VAR_3;
break;
case PORT_SCR_ERR:
pr->scr_err &= ~VAR_3;
break;
case PORT_SCR_ACT:
pr->scr_act |= VAR_3;
break;
case PORT_CMD_ISSUE:
pr->cmd_issue |= VAR_3;
check_cmd(VAR_0, VAR_1);
break;
default:
break;
}
}
| [
"static void FUNC_0(AHCIState *VAR_0, int VAR_1, int VAR_2, uint32_t VAR_3)\n{",
"AHCIPortRegs *pr = &VAR_0->dev[VAR_1].port_regs;",
"DPRINTF(VAR_1, \"VAR_2: 0x%x VAR_3: 0x%x\\n\", VAR_2, VAR_3);",
"switch (VAR_2) {",
"case PORT_LST_ADDR:\npr->lst_addr = VAR_3;",
"map_page(VAR_0->as, &VAR_0->dev[VAR_1].lst,\n((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr, 1024);",
"VAR_0->dev[VAR_1].cur_cmd = NULL;",
"break;",
"case PORT_LST_ADDR_HI:\npr->lst_addr_hi = VAR_3;",
"map_page(VAR_0->as, &VAR_0->dev[VAR_1].lst,\n((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr, 1024);",
"VAR_0->dev[VAR_1].cur_cmd = NULL;",
"break;",
"case PORT_FIS_ADDR:\npr->fis_addr = VAR_3;",
"map_page(VAR_0->as, &VAR_0->dev[VAR_1].res_fis,\n((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr, 256);",
"break;",
"case PORT_FIS_ADDR_HI:\npr->fis_addr_hi = VAR_3;",
"map_page(VAR_0->as, &VAR_0->dev[VAR_1].res_fis,\n((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr, 256);",
"break;",
"case PORT_IRQ_STAT:\npr->irq_stat &= ~VAR_3;",
"ahci_check_irq(VAR_0);",
"break;",
"case PORT_IRQ_MASK:\npr->irq_mask = VAR_3 & 0xfdc000ff;",
"ahci_check_irq(VAR_0);",
"break;",
"case PORT_CMD:\npr->cmd = VAR_3 & ~(PORT_CMD_LIST_ON | PORT_CMD_FIS_ON);",
"if (pr->cmd & PORT_CMD_START) {",
"pr->cmd |= PORT_CMD_LIST_ON;",
"}",
"if (pr->cmd & PORT_CMD_FIS_RX) {",
"pr->cmd |= PORT_CMD_FIS_ON;",
"}",
"if ((pr->cmd & PORT_CMD_FIS_ON) &&\n!VAR_0->dev[VAR_1].init_d2h_sent) {",
"ahci_init_d2h(&VAR_0->dev[VAR_1]);",
"VAR_0->dev[VAR_1].init_d2h_sent = true;",
"}",
"check_cmd(VAR_0, VAR_1);",
"break;",
"case PORT_TFDATA:\nVAR_0->dev[VAR_1].VAR_1.ifs[0].error = (VAR_3 >> 8) & 0xff;",
"VAR_0->dev[VAR_1].VAR_1.ifs[0].status = VAR_3 & 0xff;",
"break;",
"case PORT_SIG:\npr->sig = VAR_3;",
"break;",
"case PORT_SCR_STAT:\npr->scr_stat = VAR_3;",
"break;",
"case PORT_SCR_CTL:\nif (((pr->scr_ctl & AHCI_SCR_SCTL_DET) == 1) &&\n((VAR_3 & AHCI_SCR_SCTL_DET) == 0)) {",
"ahci_reset_port(VAR_0, VAR_1);",
"}",
"pr->scr_ctl = VAR_3;",
"break;",
"case PORT_SCR_ERR:\npr->scr_err &= ~VAR_3;",
"break;",
"case PORT_SCR_ACT:\npr->scr_act |= VAR_3;",
"break;",
"case PORT_CMD_ISSUE:\npr->cmd_issue |= VAR_3;",
"check_cmd(VAR_0, VAR_1);",
"break;",
"default:\nbreak;",
"}",
"}"
] | [
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,
1,
0,
1,
0,
1,
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
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
103,
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119,
121
],
[
123
],
[
125
],
[
127,
129
],
[
131
],
[
133,
135
],
[
137
],
[
139,
141,
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153,
155
],
[
157
],
[
159,
163
],
[
165
],
[
167,
169
],
[
171
],
[
173
],
[
175,
177
],
[
179
],
[
181
]
] |
24,900 | static int jacosub_read_header(AVFormatContext *s)
{
AVBPrint header;
AVIOContext *pb = s->pb;
char line[JSS_MAX_LINESIZE];
JACOsubContext *jacosub = s->priv_data;
int shift_set = 0; // only the first shift matters
int merge_line = 0;
int i, ret;
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, 100);
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->codec->codec_id = AV_CODEC_ID_JACOSUB;
jacosub->timeres = 30;
av_bprint_init(&header, 1024+FF_INPUT_BUFFER_PADDING_SIZE, 4096);
while (!avio_feof(pb)) {
int cmd_len;
const char *p = line;
int64_t pos = avio_tell(pb);
int len = ff_get_line(pb, line, sizeof(line));
p = jss_skip_whitespace(p);
/* queue timed line */
if (merge_line || timed_line(p)) {
AVPacket *sub;
sub = ff_subtitles_queue_insert(&jacosub->q, line, len, merge_line);
if (!sub)
return AVERROR(ENOMEM);
sub->pos = pos;
merge_line = len > 1 && !strcmp(&line[len - 2], "\\\n");
continue;
}
/* skip all non-compiler commands and focus on the command */
if (*p != '#')
continue;
p++;
i = get_jss_cmd(p[0]);
if (i == -1)
continue;
/* trim command + spaces */
cmd_len = strlen(cmds[i]);
if (av_strncasecmp(p, cmds[i], cmd_len) == 0)
p += cmd_len;
else
p++;
p = jss_skip_whitespace(p);
/* handle commands which affect the whole script */
switch (cmds[i][0]) {
case 'S': // SHIFT command affect the whole script...
if (!shift_set) {
jacosub->shift = get_shift(jacosub->timeres, p);
shift_set = 1;
}
av_bprintf(&header, "#S %s", p);
break;
case 'T': // ...but must be placed after TIMERES
jacosub->timeres = strtol(p, NULL, 10);
if (!jacosub->timeres)
jacosub->timeres = 30;
else
av_bprintf(&header, "#T %s", p);
break;
}
}
/* general/essential directives in the extradata */
ret = avpriv_bprint_to_extradata(st->codec, &header);
if (ret < 0)
return ret;
/* SHIFT and TIMERES affect the whole script so packet timing can only be
* done in a second pass */
for (i = 0; i < jacosub->q.nb_subs; i++) {
AVPacket *sub = &jacosub->q.subs[i];
read_ts(jacosub, sub->data, &sub->pts, &sub->duration);
}
ff_subtitles_queue_finalize(&jacosub->q);
return 0;
}
| true | FFmpeg | 8cd80b5fcbfaefdb92faa8f3ed0b7f5651f38481 | static int jacosub_read_header(AVFormatContext *s)
{
AVBPrint header;
AVIOContext *pb = s->pb;
char line[JSS_MAX_LINESIZE];
JACOsubContext *jacosub = s->priv_data;
int shift_set = 0;
int merge_line = 0;
int i, ret;
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, 100);
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->codec->codec_id = AV_CODEC_ID_JACOSUB;
jacosub->timeres = 30;
av_bprint_init(&header, 1024+FF_INPUT_BUFFER_PADDING_SIZE, 4096);
while (!avio_feof(pb)) {
int cmd_len;
const char *p = line;
int64_t pos = avio_tell(pb);
int len = ff_get_line(pb, line, sizeof(line));
p = jss_skip_whitespace(p);
if (merge_line || timed_line(p)) {
AVPacket *sub;
sub = ff_subtitles_queue_insert(&jacosub->q, line, len, merge_line);
if (!sub)
return AVERROR(ENOMEM);
sub->pos = pos;
merge_line = len > 1 && !strcmp(&line[len - 2], "\\\n");
continue;
}
if (*p != '#')
continue;
p++;
i = get_jss_cmd(p[0]);
if (i == -1)
continue;
cmd_len = strlen(cmds[i]);
if (av_strncasecmp(p, cmds[i], cmd_len) == 0)
p += cmd_len;
else
p++;
p = jss_skip_whitespace(p);
switch (cmds[i][0]) {
case 'S':
if (!shift_set) {
jacosub->shift = get_shift(jacosub->timeres, p);
shift_set = 1;
}
av_bprintf(&header, "#S %s", p);
break;
case 'T':
jacosub->timeres = strtol(p, NULL, 10);
if (!jacosub->timeres)
jacosub->timeres = 30;
else
av_bprintf(&header, "#T %s", p);
break;
}
}
ret = avpriv_bprint_to_extradata(st->codec, &header);
if (ret < 0)
return ret;
for (i = 0; i < jacosub->q.nb_subs; i++) {
AVPacket *sub = &jacosub->q.subs[i];
read_ts(jacosub, sub->data, &sub->pts, &sub->duration);
}
ff_subtitles_queue_finalize(&jacosub->q);
return 0;
}
| {
"code": [
" return ret;"
],
"line_no": [
159
]
} | static int FUNC_0(AVFormatContext *VAR_0)
{
AVBPrint header;
AVIOContext *pb = VAR_0->pb;
char VAR_1[JSS_MAX_LINESIZE];
JACOsubContext *jacosub = VAR_0->priv_data;
int VAR_2 = 0;
int VAR_3 = 0;
int VAR_4, VAR_5;
AVStream *st = avformat_new_stream(VAR_0, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, 100);
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->codec->codec_id = AV_CODEC_ID_JACOSUB;
jacosub->timeres = 30;
av_bprint_init(&header, 1024+FF_INPUT_BUFFER_PADDING_SIZE, 4096);
while (!avio_feof(pb)) {
int VAR_6;
const char *VAR_7 = VAR_1;
int64_t pos = avio_tell(pb);
int VAR_8 = ff_get_line(pb, VAR_1, sizeof(VAR_1));
VAR_7 = jss_skip_whitespace(VAR_7);
if (VAR_3 || timed_line(VAR_7)) {
AVPacket *sub;
sub = ff_subtitles_queue_insert(&jacosub->q, VAR_1, VAR_8, VAR_3);
if (!sub)
return AVERROR(ENOMEM);
sub->pos = pos;
VAR_3 = VAR_8 > 1 && !strcmp(&VAR_1[VAR_8 - 2], "\\\n");
continue;
}
if (*VAR_7 != '#')
continue;
VAR_7++;
VAR_4 = get_jss_cmd(VAR_7[0]);
if (VAR_4 == -1)
continue;
VAR_6 = strlen(cmds[VAR_4]);
if (av_strncasecmp(VAR_7, cmds[VAR_4], VAR_6) == 0)
VAR_7 += VAR_6;
else
VAR_7++;
VAR_7 = jss_skip_whitespace(VAR_7);
switch (cmds[VAR_4][0]) {
case 'S':
if (!VAR_2) {
jacosub->shift = get_shift(jacosub->timeres, VAR_7);
VAR_2 = 1;
}
av_bprintf(&header, "#S %VAR_0", VAR_7);
break;
case 'T':
jacosub->timeres = strtol(VAR_7, NULL, 10);
if (!jacosub->timeres)
jacosub->timeres = 30;
else
av_bprintf(&header, "#T %VAR_0", VAR_7);
break;
}
}
VAR_5 = avpriv_bprint_to_extradata(st->codec, &header);
if (VAR_5 < 0)
return VAR_5;
for (VAR_4 = 0; VAR_4 < jacosub->q.nb_subs; VAR_4++) {
AVPacket *sub = &jacosub->q.subs[VAR_4];
read_ts(jacosub, sub->data, &sub->pts, &sub->duration);
}
ff_subtitles_queue_finalize(&jacosub->q);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"AVBPrint header;",
"AVIOContext *pb = VAR_0->pb;",
"char VAR_1[JSS_MAX_LINESIZE];",
"JACOsubContext *jacosub = VAR_0->priv_data;",
"int VAR_2 = 0;",
"int VAR_3 = 0;",
"int VAR_4, VAR_5;",
"AVStream *st = avformat_new_stream(VAR_0, NULL);",
"if (!st)\nreturn AVERROR(ENOMEM);",
"avpriv_set_pts_info(st, 64, 1, 100);",
"st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;",
"st->codec->codec_id = AV_CODEC_ID_JACOSUB;",
"jacosub->timeres = 30;",
"av_bprint_init(&header, 1024+FF_INPUT_BUFFER_PADDING_SIZE, 4096);",
"while (!avio_feof(pb)) {",
"int VAR_6;",
"const char *VAR_7 = VAR_1;",
"int64_t pos = avio_tell(pb);",
"int VAR_8 = ff_get_line(pb, VAR_1, sizeof(VAR_1));",
"VAR_7 = jss_skip_whitespace(VAR_7);",
"if (VAR_3 || timed_line(VAR_7)) {",
"AVPacket *sub;",
"sub = ff_subtitles_queue_insert(&jacosub->q, VAR_1, VAR_8, VAR_3);",
"if (!sub)\nreturn AVERROR(ENOMEM);",
"sub->pos = pos;",
"VAR_3 = VAR_8 > 1 && !strcmp(&VAR_1[VAR_8 - 2], \"\\\\\\n\");",
"continue;",
"}",
"if (*VAR_7 != '#')\ncontinue;",
"VAR_7++;",
"VAR_4 = get_jss_cmd(VAR_7[0]);",
"if (VAR_4 == -1)\ncontinue;",
"VAR_6 = strlen(cmds[VAR_4]);",
"if (av_strncasecmp(VAR_7, cmds[VAR_4], VAR_6) == 0)\nVAR_7 += VAR_6;",
"else\nVAR_7++;",
"VAR_7 = jss_skip_whitespace(VAR_7);",
"switch (cmds[VAR_4][0]) {",
"case 'S':\nif (!VAR_2) {",
"jacosub->shift = get_shift(jacosub->timeres, VAR_7);",
"VAR_2 = 1;",
"}",
"av_bprintf(&header, \"#S %VAR_0\", VAR_7);",
"break;",
"case 'T':\njacosub->timeres = strtol(VAR_7, NULL, 10);",
"if (!jacosub->timeres)\njacosub->timeres = 30;",
"else\nav_bprintf(&header, \"#T %VAR_0\", VAR_7);",
"break;",
"}",
"}",
"VAR_5 = avpriv_bprint_to_extradata(st->codec, &header);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"for (VAR_4 = 0; VAR_4 < jacosub->q.nb_subs; VAR_4++) {",
"AVPacket *sub = &jacosub->q.subs[VAR_4];",
"read_ts(jacosub, sub->data, &sub->pts, &sub->duration);",
"}",
"ff_subtitles_queue_finalize(&jacosub->q);",
"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,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
61
],
[
63
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
85,
87
],
[
89
],
[
91
],
[
93,
95
],
[
101
],
[
103,
105
],
[
107,
109
],
[
111
],
[
117
],
[
119,
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133,
135
],
[
137,
139
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
155
],
[
157,
159
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
179
],
[
181
]
] |
24,901 | static int get_packet_payload_size(AVFormatContext *ctx, int stream_index,
int64_t pts, int64_t dts)
{
MpegMuxContext *s = ctx->priv_data;
int buf_index;
StreamInfo *stream;
stream = ctx->streams[stream_index]->priv_data;
buf_index = 0;
if (((s->packet_number % s->pack_header_freq) == 0)) {
/* pack header size */
if (s->is_mpeg2)
buf_index += 14;
else
buf_index += 12;
if (s->is_vcd) {
/* there is exactly one system header for each stream in a VCD MPEG,
One in the very first video packet and one in the very first
audio packet (see VCD standard p. IV-7 and IV-8).*/
if (stream->packet_number==0)
/* The system headers refer only to the stream they occur in,
so they have a constant size.*/
buf_index += 15;
} else {
if ((s->packet_number % s->system_header_freq) == 0)
buf_index += s->system_header_size;
}
}
if (s->is_vcd && stream->packet_number==0)
/* the first pack of each stream contains only the pack header,
the system header and some padding (see VCD standard p. IV-6)
Add the padding size, so that the actual payload becomes 0.*/
buf_index += s->packet_size - buf_index;
else {
/* packet header size */
buf_index += 6;
if (s->is_mpeg2)
buf_index += 3;
if (pts != AV_NOPTS_VALUE) {
if (dts != pts)
buf_index += 5 + 5;
else
buf_index += 5;
} else {
if (!s->is_mpeg2)
buf_index++;
}
if (stream->id < 0xc0) {
/* AC3/LPCM private data header */
buf_index += 4;
if (stream->id >= 0xa0) {
int n;
buf_index += 3;
/* NOTE: we round the payload size to an integer number of
LPCM samples */
n = (s->packet_size - buf_index) % stream->lpcm_align;
if (n)
buf_index += (stream->lpcm_align - n);
}
}
if (s->is_vcd && stream->id == AUDIO_ID)
/* The VCD standard demands that 20 zero bytes follow
each audio packet (see standard p. IV-8).*/
buf_index+=20;
}
return s->packet_size - buf_index;
}
| false | FFmpeg | 224944895efe6ac23e3b8f9d35abfee9f5c6c440 | static int get_packet_payload_size(AVFormatContext *ctx, int stream_index,
int64_t pts, int64_t dts)
{
MpegMuxContext *s = ctx->priv_data;
int buf_index;
StreamInfo *stream;
stream = ctx->streams[stream_index]->priv_data;
buf_index = 0;
if (((s->packet_number % s->pack_header_freq) == 0)) {
if (s->is_mpeg2)
buf_index += 14;
else
buf_index += 12;
if (s->is_vcd) {
if (stream->packet_number==0)
buf_index += 15;
} else {
if ((s->packet_number % s->system_header_freq) == 0)
buf_index += s->system_header_size;
}
}
if (s->is_vcd && stream->packet_number==0)
buf_index += s->packet_size - buf_index;
else {
buf_index += 6;
if (s->is_mpeg2)
buf_index += 3;
if (pts != AV_NOPTS_VALUE) {
if (dts != pts)
buf_index += 5 + 5;
else
buf_index += 5;
} else {
if (!s->is_mpeg2)
buf_index++;
}
if (stream->id < 0xc0) {
buf_index += 4;
if (stream->id >= 0xa0) {
int n;
buf_index += 3;
n = (s->packet_size - buf_index) % stream->lpcm_align;
if (n)
buf_index += (stream->lpcm_align - n);
}
}
if (s->is_vcd && stream->id == AUDIO_ID)
buf_index+=20;
}
return s->packet_size - buf_index;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,
int64_t VAR_2, int64_t VAR_3)
{
MpegMuxContext *s = VAR_0->priv_data;
int VAR_4;
StreamInfo *stream;
stream = VAR_0->streams[VAR_1]->priv_data;
VAR_4 = 0;
if (((s->packet_number % s->pack_header_freq) == 0)) {
if (s->is_mpeg2)
VAR_4 += 14;
else
VAR_4 += 12;
if (s->is_vcd) {
if (stream->packet_number==0)
VAR_4 += 15;
} else {
if ((s->packet_number % s->system_header_freq) == 0)
VAR_4 += s->system_header_size;
}
}
if (s->is_vcd && stream->packet_number==0)
VAR_4 += s->packet_size - VAR_4;
else {
VAR_4 += 6;
if (s->is_mpeg2)
VAR_4 += 3;
if (VAR_2 != AV_NOPTS_VALUE) {
if (VAR_3 != VAR_2)
VAR_4 += 5 + 5;
else
VAR_4 += 5;
} else {
if (!s->is_mpeg2)
VAR_4++;
}
if (stream->id < 0xc0) {
VAR_4 += 4;
if (stream->id >= 0xa0) {
int VAR_5;
VAR_4 += 3;
VAR_5 = (s->packet_size - VAR_4) % stream->lpcm_align;
if (VAR_5)
VAR_4 += (stream->lpcm_align - VAR_5);
}
}
if (s->is_vcd && stream->id == AUDIO_ID)
VAR_4+=20;
}
return s->packet_size - VAR_4;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,\nint64_t VAR_2, int64_t VAR_3)\n{",
"MpegMuxContext *s = VAR_0->priv_data;",
"int VAR_4;",
"StreamInfo *stream;",
"stream = VAR_0->streams[VAR_1]->priv_data;",
"VAR_4 = 0;",
"if (((s->packet_number % s->pack_header_freq) == 0)) {",
"if (s->is_mpeg2)\nVAR_4 += 14;",
"else\nVAR_4 += 12;",
"if (s->is_vcd) {",
"if (stream->packet_number==0)\nVAR_4 += 15;",
"} else {",
"if ((s->packet_number % s->system_header_freq) == 0)\nVAR_4 += s->system_header_size;",
"}",
"}",
"if (s->is_vcd && stream->packet_number==0)\nVAR_4 += s->packet_size - VAR_4;",
"else {",
"VAR_4 += 6;",
"if (s->is_mpeg2)\nVAR_4 += 3;",
"if (VAR_2 != AV_NOPTS_VALUE) {",
"if (VAR_3 != VAR_2)\nVAR_4 += 5 + 5;",
"else\nVAR_4 += 5;",
"} else {",
"if (!s->is_mpeg2)\nVAR_4++;",
"}",
"if (stream->id < 0xc0) {",
"VAR_4 += 4;",
"if (stream->id >= 0xa0) {",
"int VAR_5;",
"VAR_4 += 3;",
"VAR_5 = (s->packet_size - VAR_4) % stream->lpcm_align;",
"if (VAR_5)\nVAR_4 += (stream->lpcm_align - VAR_5);",
"}",
"}",
"if (s->is_vcd && stream->id == AUDIO_ID)\nVAR_4+=20;",
"}",
"return s->packet_size - VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
25,
27
],
[
29,
31
],
[
35
],
[
45,
51
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
67,
75
],
[
77
],
[
81
],
[
83,
85
],
[
87
],
[
89,
91
],
[
93,
95
],
[
99
],
[
101,
103
],
[
105
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
125
],
[
127,
129
],
[
131
],
[
133
],
[
137,
143
],
[
145
],
[
147
],
[
149
]
] |
24,904 | ogm_header(AVFormatContext *s, int idx)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
AVStream *st = s->streams[idx];
const uint8_t *p = os->buf + os->pstart;
uint64_t time_unit;
uint64_t spu;
uint32_t size;
if(!(*p & 1))
return 0;
if(*p == 1) {
p++;
if(*p == 'v'){
int tag;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
p += 8;
tag = bytestream_get_le32(&p);
st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag);
st->codec->codec_tag = tag;
} else if (*p == 't') {
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->codec->codec_id = CODEC_ID_TEXT;
p += 12;
} else {
uint8_t acid[5];
int cid;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
p += 8;
bytestream_get_buffer(&p, acid, 4);
acid[4] = 0;
cid = strtol(acid, NULL, 16);
st->codec->codec_id = ff_codec_get_id(ff_codec_wav_tags, cid);
// our parser completely breaks AAC in Ogg
if (st->codec->codec_id != CODEC_ID_AAC)
st->need_parsing = AVSTREAM_PARSE_FULL;
}
size = bytestream_get_le32(&p);
size = FFMIN(size, os->psize);
time_unit = bytestream_get_le64(&p);
spu = bytestream_get_le64(&p);
p += 4; /* default_len */
p += 8; /* buffersize + bits_per_sample */
if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){
st->codec->width = bytestream_get_le32(&p);
st->codec->height = bytestream_get_le32(&p);
avpriv_set_pts_info(st, 64, time_unit, spu * 10000000);
} else {
st->codec->channels = bytestream_get_le16(&p);
p += 2; /* block_align */
st->codec->bit_rate = bytestream_get_le32(&p) * 8;
st->codec->sample_rate = spu * 10000000 / time_unit;
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
if (size >= 56 && st->codec->codec_id == CODEC_ID_AAC) {
p += 4;
size -= 4;
}
if (size > 52) {
av_assert0(FF_INPUT_BUFFER_PADDING_SIZE <= 52);
size -= 52;
st->codec->extradata_size = size;
st->codec->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
bytestream_get_buffer(&p, st->codec->extradata, size);
}
}
} else if (*p == 3) {
if (os->psize > 8)
ff_vorbis_comment(s, &st->metadata, p+7, os->psize-8);
}
return 1;
}
| true | FFmpeg | 9ed388f5985992a0a6a43fdc0b1732962b6b5619 | ogm_header(AVFormatContext *s, int idx)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
AVStream *st = s->streams[idx];
const uint8_t *p = os->buf + os->pstart;
uint64_t time_unit;
uint64_t spu;
uint32_t size;
if(!(*p & 1))
return 0;
if(*p == 1) {
p++;
if(*p == 'v'){
int tag;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
p += 8;
tag = bytestream_get_le32(&p);
st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag);
st->codec->codec_tag = tag;
} else if (*p == 't') {
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->codec->codec_id = CODEC_ID_TEXT;
p += 12;
} else {
uint8_t acid[5];
int cid;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
p += 8;
bytestream_get_buffer(&p, acid, 4);
acid[4] = 0;
cid = strtol(acid, NULL, 16);
st->codec->codec_id = ff_codec_get_id(ff_codec_wav_tags, cid);
if (st->codec->codec_id != CODEC_ID_AAC)
st->need_parsing = AVSTREAM_PARSE_FULL;
}
size = bytestream_get_le32(&p);
size = FFMIN(size, os->psize);
time_unit = bytestream_get_le64(&p);
spu = bytestream_get_le64(&p);
p += 4;
p += 8;
if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){
st->codec->width = bytestream_get_le32(&p);
st->codec->height = bytestream_get_le32(&p);
avpriv_set_pts_info(st, 64, time_unit, spu * 10000000);
} else {
st->codec->channels = bytestream_get_le16(&p);
p += 2;
st->codec->bit_rate = bytestream_get_le32(&p) * 8;
st->codec->sample_rate = spu * 10000000 / time_unit;
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
if (size >= 56 && st->codec->codec_id == CODEC_ID_AAC) {
p += 4;
size -= 4;
}
if (size > 52) {
av_assert0(FF_INPUT_BUFFER_PADDING_SIZE <= 52);
size -= 52;
st->codec->extradata_size = size;
st->codec->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
bytestream_get_buffer(&p, st->codec->extradata, size);
}
}
} else if (*p == 3) {
if (os->psize > 8)
ff_vorbis_comment(s, &st->metadata, p+7, os->psize-8);
}
return 1;
}
| {
"code": [
" st->codec->sample_rate = spu * 10000000 / time_unit;"
],
"line_no": [
113
]
} | FUNC_0(AVFormatContext *VAR_0, int VAR_1)
{
struct VAR_2 *VAR_2 = VAR_0->priv_data;
struct ogg_stream *VAR_3 = VAR_2->streams + VAR_1;
AVStream *st = VAR_0->streams[VAR_1];
const uint8_t *VAR_4 = VAR_3->buf + VAR_3->pstart;
uint64_t time_unit;
uint64_t spu;
uint32_t size;
if(!(*VAR_4 & 1))
return 0;
if(*VAR_4 == 1) {
VAR_4++;
if(*VAR_4 == 'v'){
int VAR_5;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
VAR_4 += 8;
VAR_5 = bytestream_get_le32(&VAR_4);
st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, VAR_5);
st->codec->codec_tag = VAR_5;
} else if (*VAR_4 == 't') {
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->codec->codec_id = CODEC_ID_TEXT;
VAR_4 += 12;
} else {
uint8_t acid[5];
int VAR_6;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
VAR_4 += 8;
bytestream_get_buffer(&VAR_4, acid, 4);
acid[4] = 0;
VAR_6 = strtol(acid, NULL, 16);
st->codec->codec_id = ff_codec_get_id(ff_codec_wav_tags, VAR_6);
if (st->codec->codec_id != CODEC_ID_AAC)
st->need_parsing = AVSTREAM_PARSE_FULL;
}
size = bytestream_get_le32(&VAR_4);
size = FFMIN(size, VAR_3->psize);
time_unit = bytestream_get_le64(&VAR_4);
spu = bytestream_get_le64(&VAR_4);
VAR_4 += 4;
VAR_4 += 8;
if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){
st->codec->width = bytestream_get_le32(&VAR_4);
st->codec->height = bytestream_get_le32(&VAR_4);
avpriv_set_pts_info(st, 64, time_unit, spu * 10000000);
} else {
st->codec->channels = bytestream_get_le16(&VAR_4);
VAR_4 += 2;
st->codec->bit_rate = bytestream_get_le32(&VAR_4) * 8;
st->codec->sample_rate = spu * 10000000 / time_unit;
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
if (size >= 56 && st->codec->codec_id == CODEC_ID_AAC) {
VAR_4 += 4;
size -= 4;
}
if (size > 52) {
av_assert0(FF_INPUT_BUFFER_PADDING_SIZE <= 52);
size -= 52;
st->codec->extradata_size = size;
st->codec->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
bytestream_get_buffer(&VAR_4, st->codec->extradata, size);
}
}
} else if (*VAR_4 == 3) {
if (VAR_3->psize > 8)
ff_vorbis_comment(VAR_0, &st->metadata, VAR_4+7, VAR_3->psize-8);
}
return 1;
}
| [
"FUNC_0(AVFormatContext *VAR_0, int VAR_1)\n{",
"struct VAR_2 *VAR_2 = VAR_0->priv_data;",
"struct ogg_stream *VAR_3 = VAR_2->streams + VAR_1;",
"AVStream *st = VAR_0->streams[VAR_1];",
"const uint8_t *VAR_4 = VAR_3->buf + VAR_3->pstart;",
"uint64_t time_unit;",
"uint64_t spu;",
"uint32_t size;",
"if(!(*VAR_4 & 1))\nreturn 0;",
"if(*VAR_4 == 1) {",
"VAR_4++;",
"if(*VAR_4 == 'v'){",
"int VAR_5;",
"st->codec->codec_type = AVMEDIA_TYPE_VIDEO;",
"VAR_4 += 8;",
"VAR_5 = bytestream_get_le32(&VAR_4);",
"st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, VAR_5);",
"st->codec->codec_tag = VAR_5;",
"} else if (*VAR_4 == 't') {",
"st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;",
"st->codec->codec_id = CODEC_ID_TEXT;",
"VAR_4 += 12;",
"} else {",
"uint8_t acid[5];",
"int VAR_6;",
"st->codec->codec_type = AVMEDIA_TYPE_AUDIO;",
"VAR_4 += 8;",
"bytestream_get_buffer(&VAR_4, acid, 4);",
"acid[4] = 0;",
"VAR_6 = strtol(acid, NULL, 16);",
"st->codec->codec_id = ff_codec_get_id(ff_codec_wav_tags, VAR_6);",
"if (st->codec->codec_id != CODEC_ID_AAC)\nst->need_parsing = AVSTREAM_PARSE_FULL;",
"}",
"size = bytestream_get_le32(&VAR_4);",
"size = FFMIN(size, VAR_3->psize);",
"time_unit = bytestream_get_le64(&VAR_4);",
"spu = bytestream_get_le64(&VAR_4);",
"VAR_4 += 4;",
"VAR_4 += 8;",
"if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){",
"st->codec->width = bytestream_get_le32(&VAR_4);",
"st->codec->height = bytestream_get_le32(&VAR_4);",
"avpriv_set_pts_info(st, 64, time_unit, spu * 10000000);",
"} else {",
"st->codec->channels = bytestream_get_le16(&VAR_4);",
"VAR_4 += 2;",
"st->codec->bit_rate = bytestream_get_le32(&VAR_4) * 8;",
"st->codec->sample_rate = spu * 10000000 / time_unit;",
"avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);",
"if (size >= 56 && st->codec->codec_id == CODEC_ID_AAC) {",
"VAR_4 += 4;",
"size -= 4;",
"}",
"if (size > 52) {",
"av_assert0(FF_INPUT_BUFFER_PADDING_SIZE <= 52);",
"size -= 52;",
"st->codec->extradata_size = size;",
"st->codec->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);",
"bytestream_get_buffer(&VAR_4, st->codec->extradata, size);",
"}",
"}",
"} else if (*VAR_4 == 3) {",
"if (VAR_3->psize > 8)\nff_vorbis_comment(VAR_0, &st->metadata, VAR_4+7, VAR_3->psize-8);",
"}",
"return 1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21,
23
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75,
77
],
[
79
],
[
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
],
[
151
],
[
153
]
] |
24,905 | static int ape_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
APEContext *s = avctx->priv_data;
uint8_t *sample8;
int16_t *sample16;
int32_t *sample24;
int i, ch, ret;
int blockstodecode;
/* this should never be negative, but bad things will happen if it is, so
check it just to make sure. */
av_assert0(s->samples >= 0);
if(!s->samples){
uint32_t nblocks, offset;
int buf_size;
if (!avpkt->size) {
*got_frame_ptr = 0;
return 0;
}
if (avpkt->size < 8) {
av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
return AVERROR_INVALIDDATA;
}
buf_size = avpkt->size & ~3;
if (buf_size != avpkt->size) {
av_log(avctx, AV_LOG_WARNING, "packet size is not a multiple of 4. "
"extra bytes at the end will be skipped.\n");
}
if (s->fileversion < 3950) // previous versions overread two bytes
buf_size += 2;
av_fast_malloc(&s->data, &s->data_size, buf_size);
if (!s->data)
return AVERROR(ENOMEM);
s->dsp.bswap_buf((uint32_t*)s->data, (const uint32_t*)buf, buf_size >> 2);
memset(s->data + (buf_size & ~3), 0, buf_size & 3);
s->ptr = s->data;
s->data_end = s->data + buf_size;
nblocks = bytestream_get_be32(&s->ptr);
offset = bytestream_get_be32(&s->ptr);
if (s->fileversion >= 3900) {
if (offset > 3) {
av_log(avctx, AV_LOG_ERROR, "Incorrect offset passed\n");
s->data = NULL;
return AVERROR_INVALIDDATA;
}
if (s->data_end - s->ptr < offset) {
av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
return AVERROR_INVALIDDATA;
}
s->ptr += offset;
} else {
if ((ret = init_get_bits8(&s->gb, s->ptr, s->data_end - s->ptr)) < 0)
return ret;
if (s->fileversion > 3800)
skip_bits_long(&s->gb, offset * 8);
else
skip_bits_long(&s->gb, offset);
}
if (!nblocks || nblocks > INT_MAX) {
av_log(avctx, AV_LOG_ERROR, "Invalid sample count: %u.\n", nblocks);
return AVERROR_INVALIDDATA;
}
s->samples = nblocks;
/* Initialize the frame decoder */
if (init_frame_decoder(s) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error reading frame header\n");
return AVERROR_INVALIDDATA;
}
}
if (!s->data) {
*got_frame_ptr = 0;
return avpkt->size;
}
blockstodecode = FFMIN(s->blocks_per_loop, s->samples);
// for old files coefficients were not interleaved,
// so we need to decode all of them at once
if (s->fileversion < 3930)
blockstodecode = s->samples;
/* reallocate decoded sample buffer if needed */
av_fast_malloc(&s->decoded_buffer, &s->decoded_size,
2 * FFALIGN(blockstodecode, 8) * sizeof(*s->decoded_buffer));
if (!s->decoded_buffer)
return AVERROR(ENOMEM);
memset(s->decoded_buffer, 0, s->decoded_size);
s->decoded[0] = s->decoded_buffer;
s->decoded[1] = s->decoded_buffer + FFALIGN(blockstodecode, 8);
/* get output buffer */
frame->nb_samples = blockstodecode;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
s->error=0;
if ((s->channels == 1) || (s->frameflags & APE_FRAMECODE_PSEUDO_STEREO))
ape_unpack_mono(s, blockstodecode);
else
ape_unpack_stereo(s, blockstodecode);
emms_c();
if (s->error) {
s->samples=0;
av_log(avctx, AV_LOG_ERROR, "Error decoding frame\n");
return AVERROR_INVALIDDATA;
}
switch (s->bps) {
case 8:
for (ch = 0; ch < s->channels; ch++) {
sample8 = (uint8_t *)frame->data[ch];
for (i = 0; i < blockstodecode; i++)
*sample8++ = (s->decoded[ch][i] + 0x80) & 0xff;
}
break;
case 16:
for (ch = 0; ch < s->channels; ch++) {
sample16 = (int16_t *)frame->data[ch];
for (i = 0; i < blockstodecode; i++)
*sample16++ = s->decoded[ch][i];
}
break;
case 24:
for (ch = 0; ch < s->channels; ch++) {
sample24 = (int32_t *)frame->data[ch];
for (i = 0; i < blockstodecode; i++)
*sample24++ = s->decoded[ch][i] << 8;
}
break;
}
s->samples -= blockstodecode;
*got_frame_ptr = 1;
return !s->samples ? avpkt->size : 0;
}
| true | FFmpeg | 99978320c0dcf16c34bdba19ff8f0cd61628cc41 | static int ape_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
APEContext *s = avctx->priv_data;
uint8_t *sample8;
int16_t *sample16;
int32_t *sample24;
int i, ch, ret;
int blockstodecode;
av_assert0(s->samples >= 0);
if(!s->samples){
uint32_t nblocks, offset;
int buf_size;
if (!avpkt->size) {
*got_frame_ptr = 0;
return 0;
}
if (avpkt->size < 8) {
av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
return AVERROR_INVALIDDATA;
}
buf_size = avpkt->size & ~3;
if (buf_size != avpkt->size) {
av_log(avctx, AV_LOG_WARNING, "packet size is not a multiple of 4. "
"extra bytes at the end will be skipped.\n");
}
if (s->fileversion < 3950)
buf_size += 2;
av_fast_malloc(&s->data, &s->data_size, buf_size);
if (!s->data)
return AVERROR(ENOMEM);
s->dsp.bswap_buf((uint32_t*)s->data, (const uint32_t*)buf, buf_size >> 2);
memset(s->data + (buf_size & ~3), 0, buf_size & 3);
s->ptr = s->data;
s->data_end = s->data + buf_size;
nblocks = bytestream_get_be32(&s->ptr);
offset = bytestream_get_be32(&s->ptr);
if (s->fileversion >= 3900) {
if (offset > 3) {
av_log(avctx, AV_LOG_ERROR, "Incorrect offset passed\n");
s->data = NULL;
return AVERROR_INVALIDDATA;
}
if (s->data_end - s->ptr < offset) {
av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
return AVERROR_INVALIDDATA;
}
s->ptr += offset;
} else {
if ((ret = init_get_bits8(&s->gb, s->ptr, s->data_end - s->ptr)) < 0)
return ret;
if (s->fileversion > 3800)
skip_bits_long(&s->gb, offset * 8);
else
skip_bits_long(&s->gb, offset);
}
if (!nblocks || nblocks > INT_MAX) {
av_log(avctx, AV_LOG_ERROR, "Invalid sample count: %u.\n", nblocks);
return AVERROR_INVALIDDATA;
}
s->samples = nblocks;
if (init_frame_decoder(s) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error reading frame header\n");
return AVERROR_INVALIDDATA;
}
}
if (!s->data) {
*got_frame_ptr = 0;
return avpkt->size;
}
blockstodecode = FFMIN(s->blocks_per_loop, s->samples);
if (s->fileversion < 3930)
blockstodecode = s->samples;
av_fast_malloc(&s->decoded_buffer, &s->decoded_size,
2 * FFALIGN(blockstodecode, 8) * sizeof(*s->decoded_buffer));
if (!s->decoded_buffer)
return AVERROR(ENOMEM);
memset(s->decoded_buffer, 0, s->decoded_size);
s->decoded[0] = s->decoded_buffer;
s->decoded[1] = s->decoded_buffer + FFALIGN(blockstodecode, 8);
frame->nb_samples = blockstodecode;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
s->error=0;
if ((s->channels == 1) || (s->frameflags & APE_FRAMECODE_PSEUDO_STEREO))
ape_unpack_mono(s, blockstodecode);
else
ape_unpack_stereo(s, blockstodecode);
emms_c();
if (s->error) {
s->samples=0;
av_log(avctx, AV_LOG_ERROR, "Error decoding frame\n");
return AVERROR_INVALIDDATA;
}
switch (s->bps) {
case 8:
for (ch = 0; ch < s->channels; ch++) {
sample8 = (uint8_t *)frame->data[ch];
for (i = 0; i < blockstodecode; i++)
*sample8++ = (s->decoded[ch][i] + 0x80) & 0xff;
}
break;
case 16:
for (ch = 0; ch < s->channels; ch++) {
sample16 = (int16_t *)frame->data[ch];
for (i = 0; i < blockstodecode; i++)
*sample16++ = s->decoded[ch][i];
}
break;
case 24:
for (ch = 0; ch < s->channels; ch++) {
sample24 = (int32_t *)frame->data[ch];
for (i = 0; i < blockstodecode; i++)
*sample24++ = s->decoded[ch][i] << 8;
}
break;
}
s->samples -= blockstodecode;
*got_frame_ptr = 1;
return !s->samples ? avpkt->size : 0;
}
| {
"code": [
" av_fast_malloc(&s->data, &s->data_size, buf_size);"
],
"line_no": [
71
]
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
AVFrame *frame = VAR_1;
const uint8_t *VAR_4 = VAR_3->VAR_1;
APEContext *s = VAR_0->priv_data;
uint8_t *sample8;
int16_t *sample16;
int32_t *sample24;
int VAR_5, VAR_6, VAR_7;
int VAR_8;
av_assert0(s->samples >= 0);
if(!s->samples){
uint32_t nblocks, offset;
int VAR_9;
if (!VAR_3->size) {
*VAR_2 = 0;
return 0;
}
if (VAR_3->size < 8) {
av_log(VAR_0, AV_LOG_ERROR, "Packet is too small\n");
return AVERROR_INVALIDDATA;
}
VAR_9 = VAR_3->size & ~3;
if (VAR_9 != VAR_3->size) {
av_log(VAR_0, AV_LOG_WARNING, "packet size is not a multiple of 4. "
"extra bytes at the end will be skipped.\n");
}
if (s->fileversion < 3950)
VAR_9 += 2;
av_fast_malloc(&s->VAR_1, &s->data_size, VAR_9);
if (!s->VAR_1)
return AVERROR(ENOMEM);
s->dsp.bswap_buf((uint32_t*)s->VAR_1, (const uint32_t*)VAR_4, VAR_9 >> 2);
memset(s->VAR_1 + (VAR_9 & ~3), 0, VAR_9 & 3);
s->ptr = s->VAR_1;
s->data_end = s->VAR_1 + VAR_9;
nblocks = bytestream_get_be32(&s->ptr);
offset = bytestream_get_be32(&s->ptr);
if (s->fileversion >= 3900) {
if (offset > 3) {
av_log(VAR_0, AV_LOG_ERROR, "Incorrect offset passed\n");
s->VAR_1 = NULL;
return AVERROR_INVALIDDATA;
}
if (s->data_end - s->ptr < offset) {
av_log(VAR_0, AV_LOG_ERROR, "Packet is too small\n");
return AVERROR_INVALIDDATA;
}
s->ptr += offset;
} else {
if ((VAR_7 = init_get_bits8(&s->gb, s->ptr, s->data_end - s->ptr)) < 0)
return VAR_7;
if (s->fileversion > 3800)
skip_bits_long(&s->gb, offset * 8);
else
skip_bits_long(&s->gb, offset);
}
if (!nblocks || nblocks > INT_MAX) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid sample count: %u.\n", nblocks);
return AVERROR_INVALIDDATA;
}
s->samples = nblocks;
if (init_frame_decoder(s) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Error reading frame header\n");
return AVERROR_INVALIDDATA;
}
}
if (!s->VAR_1) {
*VAR_2 = 0;
return VAR_3->size;
}
VAR_8 = FFMIN(s->blocks_per_loop, s->samples);
if (s->fileversion < 3930)
VAR_8 = s->samples;
av_fast_malloc(&s->decoded_buffer, &s->decoded_size,
2 * FFALIGN(VAR_8, 8) * sizeof(*s->decoded_buffer));
if (!s->decoded_buffer)
return AVERROR(ENOMEM);
memset(s->decoded_buffer, 0, s->decoded_size);
s->decoded[0] = s->decoded_buffer;
s->decoded[1] = s->decoded_buffer + FFALIGN(VAR_8, 8);
frame->nb_samples = VAR_8;
if ((VAR_7 = ff_get_buffer(VAR_0, frame, 0)) < 0)
return VAR_7;
s->error=0;
if ((s->channels == 1) || (s->frameflags & APE_FRAMECODE_PSEUDO_STEREO))
ape_unpack_mono(s, VAR_8);
else
ape_unpack_stereo(s, VAR_8);
emms_c();
if (s->error) {
s->samples=0;
av_log(VAR_0, AV_LOG_ERROR, "Error decoding frame\n");
return AVERROR_INVALIDDATA;
}
switch (s->bps) {
case 8:
for (VAR_6 = 0; VAR_6 < s->channels; VAR_6++) {
sample8 = (uint8_t *)frame->VAR_1[VAR_6];
for (VAR_5 = 0; VAR_5 < VAR_8; VAR_5++)
*sample8++ = (s->decoded[VAR_6][VAR_5] + 0x80) & 0xff;
}
break;
case 16:
for (VAR_6 = 0; VAR_6 < s->channels; VAR_6++) {
sample16 = (int16_t *)frame->VAR_1[VAR_6];
for (VAR_5 = 0; VAR_5 < VAR_8; VAR_5++)
*sample16++ = s->decoded[VAR_6][VAR_5];
}
break;
case 24:
for (VAR_6 = 0; VAR_6 < s->channels; VAR_6++) {
sample24 = (int32_t *)frame->VAR_1[VAR_6];
for (VAR_5 = 0; VAR_5 < VAR_8; VAR_5++)
*sample24++ = s->decoded[VAR_6][VAR_5] << 8;
}
break;
}
s->samples -= VAR_8;
*VAR_2 = 1;
return !s->samples ? VAR_3->size : 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"AVFrame *frame = VAR_1;",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"APEContext *s = VAR_0->priv_data;",
"uint8_t *sample8;",
"int16_t *sample16;",
"int32_t *sample24;",
"int VAR_5, VAR_6, VAR_7;",
"int VAR_8;",
"av_assert0(s->samples >= 0);",
"if(!s->samples){",
"uint32_t nblocks, offset;",
"int VAR_9;",
"if (!VAR_3->size) {",
"*VAR_2 = 0;",
"return 0;",
"}",
"if (VAR_3->size < 8) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Packet is too small\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_9 = VAR_3->size & ~3;",
"if (VAR_9 != VAR_3->size) {",
"av_log(VAR_0, AV_LOG_WARNING, \"packet size is not a multiple of 4. \"\n\"extra bytes at the end will be skipped.\\n\");",
"}",
"if (s->fileversion < 3950)\nVAR_9 += 2;",
"av_fast_malloc(&s->VAR_1, &s->data_size, VAR_9);",
"if (!s->VAR_1)\nreturn AVERROR(ENOMEM);",
"s->dsp.bswap_buf((uint32_t*)s->VAR_1, (const uint32_t*)VAR_4, VAR_9 >> 2);",
"memset(s->VAR_1 + (VAR_9 & ~3), 0, VAR_9 & 3);",
"s->ptr = s->VAR_1;",
"s->data_end = s->VAR_1 + VAR_9;",
"nblocks = bytestream_get_be32(&s->ptr);",
"offset = bytestream_get_be32(&s->ptr);",
"if (s->fileversion >= 3900) {",
"if (offset > 3) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Incorrect offset passed\\n\");",
"s->VAR_1 = NULL;",
"return AVERROR_INVALIDDATA;",
"}",
"if (s->data_end - s->ptr < offset) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Packet is too small\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"s->ptr += offset;",
"} else {",
"if ((VAR_7 = init_get_bits8(&s->gb, s->ptr, s->data_end - s->ptr)) < 0)\nreturn VAR_7;",
"if (s->fileversion > 3800)\nskip_bits_long(&s->gb, offset * 8);",
"else\nskip_bits_long(&s->gb, offset);",
"}",
"if (!nblocks || nblocks > INT_MAX) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid sample count: %u.\\n\", nblocks);",
"return AVERROR_INVALIDDATA;",
"}",
"s->samples = nblocks;",
"if (init_frame_decoder(s) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error reading frame header\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"if (!s->VAR_1) {",
"*VAR_2 = 0;",
"return VAR_3->size;",
"}",
"VAR_8 = FFMIN(s->blocks_per_loop, s->samples);",
"if (s->fileversion < 3930)\nVAR_8 = s->samples;",
"av_fast_malloc(&s->decoded_buffer, &s->decoded_size,\n2 * FFALIGN(VAR_8, 8) * sizeof(*s->decoded_buffer));",
"if (!s->decoded_buffer)\nreturn AVERROR(ENOMEM);",
"memset(s->decoded_buffer, 0, s->decoded_size);",
"s->decoded[0] = s->decoded_buffer;",
"s->decoded[1] = s->decoded_buffer + FFALIGN(VAR_8, 8);",
"frame->nb_samples = VAR_8;",
"if ((VAR_7 = ff_get_buffer(VAR_0, frame, 0)) < 0)\nreturn VAR_7;",
"s->error=0;",
"if ((s->channels == 1) || (s->frameflags & APE_FRAMECODE_PSEUDO_STEREO))\nape_unpack_mono(s, VAR_8);",
"else\nape_unpack_stereo(s, VAR_8);",
"emms_c();",
"if (s->error) {",
"s->samples=0;",
"av_log(VAR_0, AV_LOG_ERROR, \"Error decoding frame\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"switch (s->bps) {",
"case 8:\nfor (VAR_6 = 0; VAR_6 < s->channels; VAR_6++) {",
"sample8 = (uint8_t *)frame->VAR_1[VAR_6];",
"for (VAR_5 = 0; VAR_5 < VAR_8; VAR_5++)",
"*sample8++ = (s->decoded[VAR_6][VAR_5] + 0x80) & 0xff;",
"}",
"break;",
"case 16:\nfor (VAR_6 = 0; VAR_6 < s->channels; VAR_6++) {",
"sample16 = (int16_t *)frame->VAR_1[VAR_6];",
"for (VAR_5 = 0; VAR_5 < VAR_8; VAR_5++)",
"*sample16++ = s->decoded[VAR_6][VAR_5];",
"}",
"break;",
"case 24:\nfor (VAR_6 = 0; VAR_6 < s->channels; VAR_6++) {",
"sample24 = (int32_t *)frame->VAR_1[VAR_6];",
"for (VAR_5 = 0; VAR_5 < VAR_8; VAR_5++)",
"*sample24++ = s->decoded[VAR_6][VAR_5] << 8;",
"}",
"break;",
"}",
"s->samples -= VAR_8;",
"*VAR_2 = 1;",
"return !s->samples ? 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,
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
29
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67,
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115,
117
],
[
119,
121
],
[
123,
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
173,
175
],
[
181,
183
],
[
185,
187
],
[
189
],
[
191
],
[
193
],
[
199
],
[
201,
203
],
[
207
],
[
211,
213
],
[
215,
217
],
[
219
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
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
],
[
291
],
[
293
]
] |
24,906 | e1000_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt)
{
E1000State *s = qemu_get_nic_opaque(nc);
PCIDevice *d = PCI_DEVICE(s);
struct e1000_rx_desc desc;
dma_addr_t base;
unsigned int n, rdt;
uint32_t rdh_start;
uint16_t vlan_special = 0;
uint8_t vlan_status = 0;
uint8_t min_buf[MIN_BUF_SIZE];
struct iovec min_iov;
uint8_t *filter_buf = iov->iov_base;
size_t size = iov_size(iov, iovcnt);
size_t iov_ofs = 0;
size_t desc_offset;
size_t desc_size;
size_t total_size;
static const int PRCregs[6] = { PRC64, PRC127, PRC255, PRC511,
PRC1023, PRC1522 };
if (!(s->mac_reg[STATUS] & E1000_STATUS_LU)) {
return -1;
}
if (!(s->mac_reg[RCTL] & E1000_RCTL_EN)) {
return -1;
}
/* Pad to minimum Ethernet frame length */
if (size < sizeof(min_buf)) {
iov_to_buf(iov, iovcnt, 0, min_buf, size);
memset(&min_buf[size], 0, sizeof(min_buf) - size);
inc_reg_if_not_full(s, RUC);
min_iov.iov_base = filter_buf = min_buf;
min_iov.iov_len = size = sizeof(min_buf);
iovcnt = 1;
iov = &min_iov;
} else if (iov->iov_len < MAXIMUM_ETHERNET_HDR_LEN) {
/* This is very unlikely, but may happen. */
iov_to_buf(iov, iovcnt, 0, min_buf, MAXIMUM_ETHERNET_HDR_LEN);
filter_buf = min_buf;
}
/* Discard oversized packets if !LPE and !SBP. */
if ((size > MAXIMUM_ETHERNET_LPE_SIZE ||
(size > MAXIMUM_ETHERNET_VLAN_SIZE
&& !(s->mac_reg[RCTL] & E1000_RCTL_LPE)))
&& !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
inc_reg_if_not_full(s, ROC);
return size;
}
if (!receive_filter(s, filter_buf, size)) {
return size;
}
if (vlan_enabled(s) && is_vlan_packet(s, filter_buf)) {
vlan_special = cpu_to_le16(be16_to_cpup((uint16_t *)(filter_buf
+ 14)));
iov_ofs = 4;
if (filter_buf == iov->iov_base) {
memmove(filter_buf + 4, filter_buf, 12);
} else {
iov_from_buf(iov, iovcnt, 4, filter_buf, 12);
while (iov->iov_len <= iov_ofs) {
iov_ofs -= iov->iov_len;
iov++;
}
}
vlan_status = E1000_RXD_STAT_VP;
size -= 4;
}
rdh_start = s->mac_reg[RDH];
desc_offset = 0;
total_size = size + fcs_len(s);
if (!e1000_has_rxbufs(s, total_size)) {
set_ics(s, 0, E1000_ICS_RXO);
return -1;
}
do {
desc_size = total_size - desc_offset;
if (desc_size > s->rxbuf_size) {
desc_size = s->rxbuf_size;
}
base = rx_desc_base(s) + sizeof(desc) * s->mac_reg[RDH];
pci_dma_read(d, base, &desc, sizeof(desc));
desc.special = vlan_special;
desc.status |= (vlan_status | E1000_RXD_STAT_DD);
if (desc.buffer_addr) {
if (desc_offset < size) {
size_t iov_copy;
hwaddr ba = le64_to_cpu(desc.buffer_addr);
size_t copy_size = size - desc_offset;
if (copy_size > s->rxbuf_size) {
copy_size = s->rxbuf_size;
}
do {
iov_copy = MIN(copy_size, iov->iov_len - iov_ofs);
pci_dma_write(d, ba, iov->iov_base + iov_ofs, iov_copy);
copy_size -= iov_copy;
ba += iov_copy;
iov_ofs += iov_copy;
if (iov_ofs == iov->iov_len) {
iov++;
iov_ofs = 0;
}
} while (copy_size);
}
desc_offset += desc_size;
desc.length = cpu_to_le16(desc_size);
if (desc_offset >= total_size) {
desc.status |= E1000_RXD_STAT_EOP | E1000_RXD_STAT_IXSM;
} else {
/* Guest zeroing out status is not a hardware requirement.
Clear EOP in case guest didn't do it. */
desc.status &= ~E1000_RXD_STAT_EOP;
}
} else { // as per intel docs; skip descriptors with null buf addr
DBGOUT(RX, "Null RX descriptor!!\n");
}
pci_dma_write(d, base, &desc, sizeof(desc));
if (++s->mac_reg[RDH] * sizeof(desc) >= s->mac_reg[RDLEN])
s->mac_reg[RDH] = 0;
/* see comment in start_xmit; same here */
if (s->mac_reg[RDH] == rdh_start) {
DBGOUT(RXERR, "RDH wraparound @%x, RDT %x, RDLEN %x\n",
rdh_start, s->mac_reg[RDT], s->mac_reg[RDLEN]);
set_ics(s, 0, E1000_ICS_RXO);
return -1;
}
} while (desc_offset < total_size);
increase_size_stats(s, PRCregs, total_size);
inc_reg_if_not_full(s, TPR);
s->mac_reg[GPRC] = s->mac_reg[TPR];
/* TOR - Total Octets Received:
* This register includes bytes received in a packet from the <Destination
* Address> field through the <CRC> field, inclusively.
* Always include FCS length (4) in size.
*/
grow_8reg_if_not_full(s, TORL, size+4);
s->mac_reg[GORCL] = s->mac_reg[TORL];
s->mac_reg[GORCH] = s->mac_reg[TORH];
n = E1000_ICS_RXT0;
if ((rdt = s->mac_reg[RDT]) < s->mac_reg[RDH])
rdt += s->mac_reg[RDLEN] / sizeof(desc);
if (((rdt - s->mac_reg[RDH]) * sizeof(desc)) <= s->mac_reg[RDLEN] >>
s->rxbuf_min_shift)
n |= E1000_ICS_RXDMT0;
set_ics(s, 0, n);
return size;
}
| true | qemu | dd793a74882477ca38d49e191110c17dfee51dcc | e1000_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt)
{
E1000State *s = qemu_get_nic_opaque(nc);
PCIDevice *d = PCI_DEVICE(s);
struct e1000_rx_desc desc;
dma_addr_t base;
unsigned int n, rdt;
uint32_t rdh_start;
uint16_t vlan_special = 0;
uint8_t vlan_status = 0;
uint8_t min_buf[MIN_BUF_SIZE];
struct iovec min_iov;
uint8_t *filter_buf = iov->iov_base;
size_t size = iov_size(iov, iovcnt);
size_t iov_ofs = 0;
size_t desc_offset;
size_t desc_size;
size_t total_size;
static const int PRCregs[6] = { PRC64, PRC127, PRC255, PRC511,
PRC1023, PRC1522 };
if (!(s->mac_reg[STATUS] & E1000_STATUS_LU)) {
return -1;
}
if (!(s->mac_reg[RCTL] & E1000_RCTL_EN)) {
return -1;
}
if (size < sizeof(min_buf)) {
iov_to_buf(iov, iovcnt, 0, min_buf, size);
memset(&min_buf[size], 0, sizeof(min_buf) - size);
inc_reg_if_not_full(s, RUC);
min_iov.iov_base = filter_buf = min_buf;
min_iov.iov_len = size = sizeof(min_buf);
iovcnt = 1;
iov = &min_iov;
} else if (iov->iov_len < MAXIMUM_ETHERNET_HDR_LEN) {
iov_to_buf(iov, iovcnt, 0, min_buf, MAXIMUM_ETHERNET_HDR_LEN);
filter_buf = min_buf;
}
if ((size > MAXIMUM_ETHERNET_LPE_SIZE ||
(size > MAXIMUM_ETHERNET_VLAN_SIZE
&& !(s->mac_reg[RCTL] & E1000_RCTL_LPE)))
&& !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
inc_reg_if_not_full(s, ROC);
return size;
}
if (!receive_filter(s, filter_buf, size)) {
return size;
}
if (vlan_enabled(s) && is_vlan_packet(s, filter_buf)) {
vlan_special = cpu_to_le16(be16_to_cpup((uint16_t *)(filter_buf
+ 14)));
iov_ofs = 4;
if (filter_buf == iov->iov_base) {
memmove(filter_buf + 4, filter_buf, 12);
} else {
iov_from_buf(iov, iovcnt, 4, filter_buf, 12);
while (iov->iov_len <= iov_ofs) {
iov_ofs -= iov->iov_len;
iov++;
}
}
vlan_status = E1000_RXD_STAT_VP;
size -= 4;
}
rdh_start = s->mac_reg[RDH];
desc_offset = 0;
total_size = size + fcs_len(s);
if (!e1000_has_rxbufs(s, total_size)) {
set_ics(s, 0, E1000_ICS_RXO);
return -1;
}
do {
desc_size = total_size - desc_offset;
if (desc_size > s->rxbuf_size) {
desc_size = s->rxbuf_size;
}
base = rx_desc_base(s) + sizeof(desc) * s->mac_reg[RDH];
pci_dma_read(d, base, &desc, sizeof(desc));
desc.special = vlan_special;
desc.status |= (vlan_status | E1000_RXD_STAT_DD);
if (desc.buffer_addr) {
if (desc_offset < size) {
size_t iov_copy;
hwaddr ba = le64_to_cpu(desc.buffer_addr);
size_t copy_size = size - desc_offset;
if (copy_size > s->rxbuf_size) {
copy_size = s->rxbuf_size;
}
do {
iov_copy = MIN(copy_size, iov->iov_len - iov_ofs);
pci_dma_write(d, ba, iov->iov_base + iov_ofs, iov_copy);
copy_size -= iov_copy;
ba += iov_copy;
iov_ofs += iov_copy;
if (iov_ofs == iov->iov_len) {
iov++;
iov_ofs = 0;
}
} while (copy_size);
}
desc_offset += desc_size;
desc.length = cpu_to_le16(desc_size);
if (desc_offset >= total_size) {
desc.status |= E1000_RXD_STAT_EOP | E1000_RXD_STAT_IXSM;
} else {
desc.status &= ~E1000_RXD_STAT_EOP;
}
} else {
DBGOUT(RX, "Null RX descriptor!!\n");
}
pci_dma_write(d, base, &desc, sizeof(desc));
if (++s->mac_reg[RDH] * sizeof(desc) >= s->mac_reg[RDLEN])
s->mac_reg[RDH] = 0;
if (s->mac_reg[RDH] == rdh_start) {
DBGOUT(RXERR, "RDH wraparound @%x, RDT %x, RDLEN %x\n",
rdh_start, s->mac_reg[RDT], s->mac_reg[RDLEN]);
set_ics(s, 0, E1000_ICS_RXO);
return -1;
}
} while (desc_offset < total_size);
increase_size_stats(s, PRCregs, total_size);
inc_reg_if_not_full(s, TPR);
s->mac_reg[GPRC] = s->mac_reg[TPR];
grow_8reg_if_not_full(s, TORL, size+4);
s->mac_reg[GORCL] = s->mac_reg[TORL];
s->mac_reg[GORCH] = s->mac_reg[TORH];
n = E1000_ICS_RXT0;
if ((rdt = s->mac_reg[RDT]) < s->mac_reg[RDH])
rdt += s->mac_reg[RDLEN] / sizeof(desc);
if (((rdt - s->mac_reg[RDH]) * sizeof(desc)) <= s->mac_reg[RDLEN] >>
s->rxbuf_min_shift)
n |= E1000_ICS_RXDMT0;
set_ics(s, 0, n);
return size;
}
| {
"code": [
" if (s->mac_reg[RDH] == rdh_start) {"
],
"line_no": [
255
]
} | FUNC_0(NetClientState *VAR_0, const struct iovec *VAR_1, int VAR_2)
{
E1000State *s = qemu_get_nic_opaque(VAR_0);
PCIDevice *d = PCI_DEVICE(s);
struct e1000_rx_desc VAR_3;
dma_addr_t base;
unsigned int VAR_4, VAR_5;
uint32_t rdh_start;
uint16_t vlan_special = 0;
uint8_t vlan_status = 0;
uint8_t min_buf[MIN_BUF_SIZE];
struct iovec VAR_6;
uint8_t *filter_buf = VAR_1->iov_base;
size_t size = iov_size(VAR_1, VAR_2);
size_t iov_ofs = 0;
size_t desc_offset;
size_t desc_size;
size_t total_size;
static const int VAR_7[6] = { PRC64, PRC127, PRC255, PRC511,
PRC1023, PRC1522 };
if (!(s->mac_reg[STATUS] & E1000_STATUS_LU)) {
return -1;
}
if (!(s->mac_reg[RCTL] & E1000_RCTL_EN)) {
return -1;
}
if (size < sizeof(min_buf)) {
iov_to_buf(VAR_1, VAR_2, 0, min_buf, size);
memset(&min_buf[size], 0, sizeof(min_buf) - size);
inc_reg_if_not_full(s, RUC);
VAR_6.iov_base = filter_buf = min_buf;
VAR_6.iov_len = size = sizeof(min_buf);
VAR_2 = 1;
VAR_1 = &VAR_6;
} else if (VAR_1->iov_len < MAXIMUM_ETHERNET_HDR_LEN) {
iov_to_buf(VAR_1, VAR_2, 0, min_buf, MAXIMUM_ETHERNET_HDR_LEN);
filter_buf = min_buf;
}
if ((size > MAXIMUM_ETHERNET_LPE_SIZE ||
(size > MAXIMUM_ETHERNET_VLAN_SIZE
&& !(s->mac_reg[RCTL] & E1000_RCTL_LPE)))
&& !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
inc_reg_if_not_full(s, ROC);
return size;
}
if (!receive_filter(s, filter_buf, size)) {
return size;
}
if (vlan_enabled(s) && is_vlan_packet(s, filter_buf)) {
vlan_special = cpu_to_le16(be16_to_cpup((uint16_t *)(filter_buf
+ 14)));
iov_ofs = 4;
if (filter_buf == VAR_1->iov_base) {
memmove(filter_buf + 4, filter_buf, 12);
} else {
iov_from_buf(VAR_1, VAR_2, 4, filter_buf, 12);
while (VAR_1->iov_len <= iov_ofs) {
iov_ofs -= VAR_1->iov_len;
VAR_1++;
}
}
vlan_status = E1000_RXD_STAT_VP;
size -= 4;
}
rdh_start = s->mac_reg[RDH];
desc_offset = 0;
total_size = size + fcs_len(s);
if (!e1000_has_rxbufs(s, total_size)) {
set_ics(s, 0, E1000_ICS_RXO);
return -1;
}
do {
desc_size = total_size - desc_offset;
if (desc_size > s->rxbuf_size) {
desc_size = s->rxbuf_size;
}
base = rx_desc_base(s) + sizeof(VAR_3) * s->mac_reg[RDH];
pci_dma_read(d, base, &VAR_3, sizeof(VAR_3));
VAR_3.special = vlan_special;
VAR_3.status |= (vlan_status | E1000_RXD_STAT_DD);
if (VAR_3.buffer_addr) {
if (desc_offset < size) {
size_t iov_copy;
hwaddr ba = le64_to_cpu(VAR_3.buffer_addr);
size_t copy_size = size - desc_offset;
if (copy_size > s->rxbuf_size) {
copy_size = s->rxbuf_size;
}
do {
iov_copy = MIN(copy_size, VAR_1->iov_len - iov_ofs);
pci_dma_write(d, ba, VAR_1->iov_base + iov_ofs, iov_copy);
copy_size -= iov_copy;
ba += iov_copy;
iov_ofs += iov_copy;
if (iov_ofs == VAR_1->iov_len) {
VAR_1++;
iov_ofs = 0;
}
} while (copy_size);
}
desc_offset += desc_size;
VAR_3.length = cpu_to_le16(desc_size);
if (desc_offset >= total_size) {
VAR_3.status |= E1000_RXD_STAT_EOP | E1000_RXD_STAT_IXSM;
} else {
VAR_3.status &= ~E1000_RXD_STAT_EOP;
}
} else {
DBGOUT(RX, "Null RX descriptor!!\VAR_4");
}
pci_dma_write(d, base, &VAR_3, sizeof(VAR_3));
if (++s->mac_reg[RDH] * sizeof(VAR_3) >= s->mac_reg[RDLEN])
s->mac_reg[RDH] = 0;
if (s->mac_reg[RDH] == rdh_start) {
DBGOUT(RXERR, "RDH wraparound @%x, RDT %x, RDLEN %x\VAR_4",
rdh_start, s->mac_reg[RDT], s->mac_reg[RDLEN]);
set_ics(s, 0, E1000_ICS_RXO);
return -1;
}
} while (desc_offset < total_size);
increase_size_stats(s, VAR_7, total_size);
inc_reg_if_not_full(s, TPR);
s->mac_reg[GPRC] = s->mac_reg[TPR];
grow_8reg_if_not_full(s, TORL, size+4);
s->mac_reg[GORCL] = s->mac_reg[TORL];
s->mac_reg[GORCH] = s->mac_reg[TORH];
VAR_4 = E1000_ICS_RXT0;
if ((VAR_5 = s->mac_reg[RDT]) < s->mac_reg[RDH])
VAR_5 += s->mac_reg[RDLEN] / sizeof(VAR_3);
if (((VAR_5 - s->mac_reg[RDH]) * sizeof(VAR_3)) <= s->mac_reg[RDLEN] >>
s->rxbuf_min_shift)
VAR_4 |= E1000_ICS_RXDMT0;
set_ics(s, 0, VAR_4);
return size;
}
| [
"FUNC_0(NetClientState *VAR_0, const struct iovec *VAR_1, int VAR_2)\n{",
"E1000State *s = qemu_get_nic_opaque(VAR_0);",
"PCIDevice *d = PCI_DEVICE(s);",
"struct e1000_rx_desc VAR_3;",
"dma_addr_t base;",
"unsigned int VAR_4, VAR_5;",
"uint32_t rdh_start;",
"uint16_t vlan_special = 0;",
"uint8_t vlan_status = 0;",
"uint8_t min_buf[MIN_BUF_SIZE];",
"struct iovec VAR_6;",
"uint8_t *filter_buf = VAR_1->iov_base;",
"size_t size = iov_size(VAR_1, VAR_2);",
"size_t iov_ofs = 0;",
"size_t desc_offset;",
"size_t desc_size;",
"size_t total_size;",
"static const int VAR_7[6] = { PRC64, PRC127, PRC255, PRC511,",
"PRC1023, PRC1522 };",
"if (!(s->mac_reg[STATUS] & E1000_STATUS_LU)) {",
"return -1;",
"}",
"if (!(s->mac_reg[RCTL] & E1000_RCTL_EN)) {",
"return -1;",
"}",
"if (size < sizeof(min_buf)) {",
"iov_to_buf(VAR_1, VAR_2, 0, min_buf, size);",
"memset(&min_buf[size], 0, sizeof(min_buf) - size);",
"inc_reg_if_not_full(s, RUC);",
"VAR_6.iov_base = filter_buf = min_buf;",
"VAR_6.iov_len = size = sizeof(min_buf);",
"VAR_2 = 1;",
"VAR_1 = &VAR_6;",
"} else if (VAR_1->iov_len < MAXIMUM_ETHERNET_HDR_LEN) {",
"iov_to_buf(VAR_1, VAR_2, 0, min_buf, MAXIMUM_ETHERNET_HDR_LEN);",
"filter_buf = min_buf;",
"}",
"if ((size > MAXIMUM_ETHERNET_LPE_SIZE ||\n(size > MAXIMUM_ETHERNET_VLAN_SIZE\n&& !(s->mac_reg[RCTL] & E1000_RCTL_LPE)))\n&& !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {",
"inc_reg_if_not_full(s, ROC);",
"return size;",
"}",
"if (!receive_filter(s, filter_buf, size)) {",
"return size;",
"}",
"if (vlan_enabled(s) && is_vlan_packet(s, filter_buf)) {",
"vlan_special = cpu_to_le16(be16_to_cpup((uint16_t *)(filter_buf\n+ 14)));",
"iov_ofs = 4;",
"if (filter_buf == VAR_1->iov_base) {",
"memmove(filter_buf + 4, filter_buf, 12);",
"} else {",
"iov_from_buf(VAR_1, VAR_2, 4, filter_buf, 12);",
"while (VAR_1->iov_len <= iov_ofs) {",
"iov_ofs -= VAR_1->iov_len;",
"VAR_1++;",
"}",
"}",
"vlan_status = E1000_RXD_STAT_VP;",
"size -= 4;",
"}",
"rdh_start = s->mac_reg[RDH];",
"desc_offset = 0;",
"total_size = size + fcs_len(s);",
"if (!e1000_has_rxbufs(s, total_size)) {",
"set_ics(s, 0, E1000_ICS_RXO);",
"return -1;",
"}",
"do {",
"desc_size = total_size - desc_offset;",
"if (desc_size > s->rxbuf_size) {",
"desc_size = s->rxbuf_size;",
"}",
"base = rx_desc_base(s) + sizeof(VAR_3) * s->mac_reg[RDH];",
"pci_dma_read(d, base, &VAR_3, sizeof(VAR_3));",
"VAR_3.special = vlan_special;",
"VAR_3.status |= (vlan_status | E1000_RXD_STAT_DD);",
"if (VAR_3.buffer_addr) {",
"if (desc_offset < size) {",
"size_t iov_copy;",
"hwaddr ba = le64_to_cpu(VAR_3.buffer_addr);",
"size_t copy_size = size - desc_offset;",
"if (copy_size > s->rxbuf_size) {",
"copy_size = s->rxbuf_size;",
"}",
"do {",
"iov_copy = MIN(copy_size, VAR_1->iov_len - iov_ofs);",
"pci_dma_write(d, ba, VAR_1->iov_base + iov_ofs, iov_copy);",
"copy_size -= iov_copy;",
"ba += iov_copy;",
"iov_ofs += iov_copy;",
"if (iov_ofs == VAR_1->iov_len) {",
"VAR_1++;",
"iov_ofs = 0;",
"}",
"} while (copy_size);",
"}",
"desc_offset += desc_size;",
"VAR_3.length = cpu_to_le16(desc_size);",
"if (desc_offset >= total_size) {",
"VAR_3.status |= E1000_RXD_STAT_EOP | E1000_RXD_STAT_IXSM;",
"} else {",
"VAR_3.status &= ~E1000_RXD_STAT_EOP;",
"}",
"} else {",
"DBGOUT(RX, \"Null RX descriptor!!\\VAR_4\");",
"}",
"pci_dma_write(d, base, &VAR_3, sizeof(VAR_3));",
"if (++s->mac_reg[RDH] * sizeof(VAR_3) >= s->mac_reg[RDLEN])\ns->mac_reg[RDH] = 0;",
"if (s->mac_reg[RDH] == rdh_start) {",
"DBGOUT(RXERR, \"RDH wraparound @%x, RDT %x, RDLEN %x\\VAR_4\",\nrdh_start, s->mac_reg[RDT], s->mac_reg[RDLEN]);",
"set_ics(s, 0, E1000_ICS_RXO);",
"return -1;",
"}",
"} while (desc_offset < total_size);",
"increase_size_stats(s, VAR_7, total_size);",
"inc_reg_if_not_full(s, TPR);",
"s->mac_reg[GPRC] = s->mac_reg[TPR];",
"grow_8reg_if_not_full(s, TORL, size+4);",
"s->mac_reg[GORCL] = s->mac_reg[TORL];",
"s->mac_reg[GORCH] = s->mac_reg[TORH];",
"VAR_4 = E1000_ICS_RXT0;",
"if ((VAR_5 = s->mac_reg[RDT]) < s->mac_reg[RDH])\nVAR_5 += s->mac_reg[RDLEN] / sizeof(VAR_3);",
"if (((VAR_5 - s->mac_reg[RDH]) * sizeof(VAR_3)) <= s->mac_reg[RDLEN] >>\ns->rxbuf_min_shift)\nVAR_4 |= E1000_ICS_RXDMT0;",
"set_ics(s, 0, VAR_4);",
"return 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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
91,
93,
95,
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117,
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
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
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
249,
251
],
[
255
],
[
257,
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
271
],
[
273
],
[
275
],
[
287
],
[
289
],
[
291
],
[
295
],
[
297,
299
],
[
301,
303,
305
],
[
309
],
[
313
],
[
315
]
] |
24,907 | static void close_peer_eventfds(IVShmemState *s, int posn)
{
int i, n;
if (!ivshmem_has_feature(s, IVSHMEM_IOEVENTFD)) {
return;
}
if (posn < 0 || posn >= s->nb_peers) {
error_report("invalid peer %d", posn);
return;
}
n = s->peers[posn].nb_eventfds;
memory_region_transaction_begin();
for (i = 0; i < n; i++) {
ivshmem_del_eventfd(s, posn, i);
}
memory_region_transaction_commit();
for (i = 0; i < n; i++) {
event_notifier_cleanup(&s->peers[posn].eventfds[i]);
}
g_free(s->peers[posn].eventfds);
s->peers[posn].nb_eventfds = 0;
}
| true | qemu | 9db51b4d64ded01536b3851a5a50e484ac2f7899 | static void close_peer_eventfds(IVShmemState *s, int posn)
{
int i, n;
if (!ivshmem_has_feature(s, IVSHMEM_IOEVENTFD)) {
return;
}
if (posn < 0 || posn >= s->nb_peers) {
error_report("invalid peer %d", posn);
return;
}
n = s->peers[posn].nb_eventfds;
memory_region_transaction_begin();
for (i = 0; i < n; i++) {
ivshmem_del_eventfd(s, posn, i);
}
memory_region_transaction_commit();
for (i = 0; i < n; i++) {
event_notifier_cleanup(&s->peers[posn].eventfds[i]);
}
g_free(s->peers[posn].eventfds);
s->peers[posn].nb_eventfds = 0;
}
| {
"code": [
" if (!ivshmem_has_feature(s, IVSHMEM_IOEVENTFD)) {",
" if (posn < 0 || posn >= s->nb_peers) {",
" error_report(\"invalid peer %d\", posn);",
" memory_region_transaction_begin();",
" for (i = 0; i < n; i++) {",
" ivshmem_del_eventfd(s, posn, i);",
" memory_region_transaction_commit();"
],
"line_no": [
9,
15,
17,
29,
31,
33,
37
]
} | static void FUNC_0(IVShmemState *VAR_0, int VAR_1)
{
int VAR_2, VAR_3;
if (!ivshmem_has_feature(VAR_0, IVSHMEM_IOEVENTFD)) {
return;
}
if (VAR_1 < 0 || VAR_1 >= VAR_0->nb_peers) {
error_report("invalid peer %d", VAR_1);
return;
}
VAR_3 = VAR_0->peers[VAR_1].nb_eventfds;
memory_region_transaction_begin();
for (VAR_2 = 0; VAR_2 < VAR_3; VAR_2++) {
ivshmem_del_eventfd(VAR_0, VAR_1, VAR_2);
}
memory_region_transaction_commit();
for (VAR_2 = 0; VAR_2 < VAR_3; VAR_2++) {
event_notifier_cleanup(&VAR_0->peers[VAR_1].eventfds[VAR_2]);
}
g_free(VAR_0->peers[VAR_1].eventfds);
VAR_0->peers[VAR_1].nb_eventfds = 0;
}
| [
"static void FUNC_0(IVShmemState *VAR_0, int VAR_1)\n{",
"int VAR_2, VAR_3;",
"if (!ivshmem_has_feature(VAR_0, IVSHMEM_IOEVENTFD)) {",
"return;",
"}",
"if (VAR_1 < 0 || VAR_1 >= VAR_0->nb_peers) {",
"error_report(\"invalid peer %d\", VAR_1);",
"return;",
"}",
"VAR_3 = VAR_0->peers[VAR_1].nb_eventfds;",
"memory_region_transaction_begin();",
"for (VAR_2 = 0; VAR_2 < VAR_3; VAR_2++) {",
"ivshmem_del_eventfd(VAR_0, VAR_1, VAR_2);",
"}",
"memory_region_transaction_commit();",
"for (VAR_2 = 0; VAR_2 < VAR_3; VAR_2++) {",
"event_notifier_cleanup(&VAR_0->peers[VAR_1].eventfds[VAR_2]);",
"}",
"g_free(VAR_0->peers[VAR_1].eventfds);",
"VAR_0->peers[VAR_1].nb_eventfds = 0;",
"}"
] | [
0,
0,
1,
0,
0,
1,
1,
0,
0,
0,
1,
1,
1,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
]
] |
24,908 | static void pci_ivshmem_exit(PCIDevice *dev)
{
IVShmemState *s = IVSHMEM(dev);
int i;
fifo8_destroy(&s->incoming_fifo);
if (s->migration_blocker) {
migrate_del_blocker(s->migration_blocker);
error_free(s->migration_blocker);
}
if (s->shm_fd >= 0) {
void *addr = memory_region_get_ram_ptr(&s->ivshmem);
vmstate_unregister_ram(&s->ivshmem, DEVICE(dev));
memory_region_del_subregion(&s->bar, &s->ivshmem);
if (munmap(addr, s->ivshmem_size) == -1) {
error_report("Failed to munmap shared memory %s", strerror(errno));
}
}
if (s->eventfd_chr) {
for (i = 0; i < s->vectors; i++) {
if (s->eventfd_chr[i]) {
qemu_chr_free(s->eventfd_chr[i]);
}
}
g_free(s->eventfd_chr);
}
if (s->peers) {
for (i = 0; i < s->nb_peers; i++) {
close_peer_eventfds(s, i);
}
g_free(s->peers);
}
if (ivshmem_has_feature(s, IVSHMEM_MSI)) {
msix_uninit_exclusive_bar(dev);
}
g_free(s->eventfd_table);
}
| true | qemu | f689d2811a36894618087e1e2cc3ade78e758e94 | static void pci_ivshmem_exit(PCIDevice *dev)
{
IVShmemState *s = IVSHMEM(dev);
int i;
fifo8_destroy(&s->incoming_fifo);
if (s->migration_blocker) {
migrate_del_blocker(s->migration_blocker);
error_free(s->migration_blocker);
}
if (s->shm_fd >= 0) {
void *addr = memory_region_get_ram_ptr(&s->ivshmem);
vmstate_unregister_ram(&s->ivshmem, DEVICE(dev));
memory_region_del_subregion(&s->bar, &s->ivshmem);
if (munmap(addr, s->ivshmem_size) == -1) {
error_report("Failed to munmap shared memory %s", strerror(errno));
}
}
if (s->eventfd_chr) {
for (i = 0; i < s->vectors; i++) {
if (s->eventfd_chr[i]) {
qemu_chr_free(s->eventfd_chr[i]);
}
}
g_free(s->eventfd_chr);
}
if (s->peers) {
for (i = 0; i < s->nb_peers; i++) {
close_peer_eventfds(s, i);
}
g_free(s->peers);
}
if (ivshmem_has_feature(s, IVSHMEM_MSI)) {
msix_uninit_exclusive_bar(dev);
}
g_free(s->eventfd_table);
}
| {
"code": [
" if (s->shm_fd >= 0) {"
],
"line_no": [
25
]
} | static void FUNC_0(PCIDevice *VAR_0)
{
IVShmemState *s = IVSHMEM(VAR_0);
int VAR_1;
fifo8_destroy(&s->incoming_fifo);
if (s->migration_blocker) {
migrate_del_blocker(s->migration_blocker);
error_free(s->migration_blocker);
}
if (s->shm_fd >= 0) {
void *VAR_2 = memory_region_get_ram_ptr(&s->ivshmem);
vmstate_unregister_ram(&s->ivshmem, DEVICE(VAR_0));
memory_region_del_subregion(&s->bar, &s->ivshmem);
if (munmap(VAR_2, s->ivshmem_size) == -1) {
error_report("Failed to munmap shared memory %s", strerror(errno));
}
}
if (s->eventfd_chr) {
for (VAR_1 = 0; VAR_1 < s->vectors; VAR_1++) {
if (s->eventfd_chr[VAR_1]) {
qemu_chr_free(s->eventfd_chr[VAR_1]);
}
}
g_free(s->eventfd_chr);
}
if (s->peers) {
for (VAR_1 = 0; VAR_1 < s->nb_peers; VAR_1++) {
close_peer_eventfds(s, VAR_1);
}
g_free(s->peers);
}
if (ivshmem_has_feature(s, IVSHMEM_MSI)) {
msix_uninit_exclusive_bar(VAR_0);
}
g_free(s->eventfd_table);
}
| [
"static void FUNC_0(PCIDevice *VAR_0)\n{",
"IVShmemState *s = IVSHMEM(VAR_0);",
"int VAR_1;",
"fifo8_destroy(&s->incoming_fifo);",
"if (s->migration_blocker) {",
"migrate_del_blocker(s->migration_blocker);",
"error_free(s->migration_blocker);",
"}",
"if (s->shm_fd >= 0) {",
"void *VAR_2 = memory_region_get_ram_ptr(&s->ivshmem);",
"vmstate_unregister_ram(&s->ivshmem, DEVICE(VAR_0));",
"memory_region_del_subregion(&s->bar, &s->ivshmem);",
"if (munmap(VAR_2, s->ivshmem_size) == -1) {",
"error_report(\"Failed to munmap shared memory %s\", strerror(errno));",
"}",
"}",
"if (s->eventfd_chr) {",
"for (VAR_1 = 0; VAR_1 < s->vectors; VAR_1++) {",
"if (s->eventfd_chr[VAR_1]) {",
"qemu_chr_free(s->eventfd_chr[VAR_1]);",
"}",
"}",
"g_free(s->eventfd_chr);",
"}",
"if (s->peers) {",
"for (VAR_1 = 0; VAR_1 < s->nb_peers; VAR_1++) {",
"close_peer_eventfds(s, VAR_1);",
"}",
"g_free(s->peers);",
"}",
"if (ivshmem_has_feature(s, IVSHMEM_MSI)) {",
"msix_uninit_exclusive_bar(VAR_0);",
"}",
"g_free(s->eventfd_table);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
]
] |
24,909 | static inline void RENAME(rgb32tobgr16)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#if COMPILE_TEMPLATE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#if COMPILE_TEMPLATE_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) {
register int rgb = *(const uint32_t*)s; s += 4;
*d++ = ((rgb&0xF8)<<8) + ((rgb&0xFC00)>>5) + ((rgb&0xF80000)>>19);
}
}
| false | FFmpeg | d1adad3cca407f493c3637e20ecd4f7124e69212 | static inline void RENAME(rgb32tobgr16)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#if COMPILE_TEMPLATE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#if COMPILE_TEMPLATE_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) {
register int rgb = *(const uint32_t*)s; s += 4;
*d++ = ((rgb&0xF8)<<8) + ((rgb&0xFC00)>>5) + ((rgb&0xF80000)>>19);
}
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(rgb32tobgr16)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint8_t *VAR_0 = src;
const uint8_t *VAR_1;
#if COMPILE_TEMPLATE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
VAR_1 = VAR_0 + src_size;
#if COMPILE_TEMPLATE_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 = 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) {
register int VAR_2 = *(const uint32_t*)VAR_0; VAR_0 += 4;
*d++ = ((VAR_2&0xF8)<<8) + ((VAR_2&0xFC00)>>5) + ((VAR_2&0xF80000)>>19);
}
}
| [
"static inline void FUNC_0(rgb32tobgr16)(const uint8_t *src, uint8_t *dst, long src_size)\n{",
"const uint8_t *VAR_0 = src;",
"const uint8_t *VAR_1;",
"#if COMPILE_TEMPLATE_MMX\nconst uint8_t *mm_end;",
"#endif\nuint16_t *d = (uint16_t *)dst;",
"VAR_1 = VAR_0 + src_size;",
"#if COMPILE_TEMPLATE_MMX\n__asm__ volatile(PREFETCH\" %0\"::\"m\"(*src):\"memory\");",
"__asm__ volatile(\n\"movq %0, %%mm7 \\n\\t\"\n\"movq %1, %%mm6 \\n\\t\"\n::\"m\"(red_16mask),\"m\"(green_16mask));",
"mm_end = VAR_1 - 15;",
"while (VAR_0 < mm_end) {",
"__asm__ volatile(\nPREFETCH\" 32%1 \\n\\t\"\n\"movd %1, %%mm0 \\n\\t\"\n\"movd 4%1, %%mm3 \\n\\t\"\n\"punpckldq 8%1, %%mm0 \\n\\t\"\n\"punpckldq 12%1, %%mm3 \\n\\t\"\n\"movq %%mm0, %%mm1 \\n\\t\"\n\"movq %%mm0, %%mm2 \\n\\t\"\n\"movq %%mm3, %%mm4 \\n\\t\"\n\"movq %%mm3, %%mm5 \\n\\t\"\n\"psllq $8, %%mm0 \\n\\t\"\n\"psllq $8, %%mm3 \\n\\t\"\n\"pand %%mm7, %%mm0 \\n\\t\"\n\"pand %%mm7, %%mm3 \\n\\t\"\n\"psrlq $5, %%mm1 \\n\\t\"\n\"psrlq $5, %%mm4 \\n\\t\"\n\"pand %%mm6, %%mm1 \\n\\t\"\n\"pand %%mm6, %%mm4 \\n\\t\"\n\"psrlq $19, %%mm2 \\n\\t\"\n\"psrlq $19, %%mm5 \\n\\t\"\n\"pand %2, %%mm2 \\n\\t\"\n\"pand %2, %%mm5 \\n\\t\"\n\"por %%mm1, %%mm0 \\n\\t\"\n\"por %%mm4, %%mm3 \\n\\t\"\n\"por %%mm2, %%mm0 \\n\\t\"\n\"por %%mm5, %%mm3 \\n\\t\"\n\"psllq $16, %%mm3 \\n\\t\"\n\"por %%mm3, %%mm0 \\n\\t\"\nMOVNTQ\" %%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) {",
"register int VAR_2 = *(const uint32_t*)VAR_0; VAR_0 += 4;",
"*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
]
] |
24,910 | static int truemotion1_decode_header(TrueMotion1Context *s)
{
int i;
int width_shift = 0;
int new_pix_fmt;
struct frame_header header;
uint8_t header_buffer[128]; /* logical maximum size of the header */
const uint8_t *sel_vector_table;
header.header_size = ((s->buf[0] >> 5) | (s->buf[0] << 3)) & 0x7f;
if (s->buf[0] < 0x10)
{
av_log(s->avctx, AV_LOG_ERROR, "invalid header size (%d)\n", s->buf[0]);
return -1;
}
/* unscramble the header bytes with a XOR operation */
memset(header_buffer, 0, 128);
for (i = 1; i < header.header_size; i++)
header_buffer[i - 1] = s->buf[i] ^ s->buf[i + 1];
header.compression = header_buffer[0];
header.deltaset = header_buffer[1];
header.vectable = header_buffer[2];
header.ysize = AV_RL16(&header_buffer[3]);
header.xsize = AV_RL16(&header_buffer[5]);
header.checksum = AV_RL16(&header_buffer[7]);
header.version = header_buffer[9];
header.header_type = header_buffer[10];
header.flags = header_buffer[11];
header.control = header_buffer[12];
/* Version 2 */
if (header.version >= 2)
{
if (header.header_type > 3)
{
av_log(s->avctx, AV_LOG_ERROR, "invalid header type (%d)\n", header.header_type);
return -1;
} else if ((header.header_type == 2) || (header.header_type == 3)) {
s->flags = header.flags;
if (!(s->flags & FLAG_INTERFRAME))
s->flags |= FLAG_KEYFRAME;
} else
s->flags = FLAG_KEYFRAME;
} else /* Version 1 */
s->flags = FLAG_KEYFRAME;
if (s->flags & FLAG_SPRITE) {
av_log(s->avctx, AV_LOG_INFO, "SPRITE frame found, please report the sample to the developers\n");
/* FIXME header.width, height, xoffset and yoffset aren't initialized */
#if 0
s->w = header.width;
s->h = header.height;
s->x = header.xoffset;
s->y = header.yoffset;
#else
return -1;
#endif
} else {
s->w = header.xsize;
s->h = header.ysize;
if (header.header_type < 2) {
if ((s->w < 213) && (s->h >= 176))
{
s->flags |= FLAG_INTERPOLATED;
av_log(s->avctx, AV_LOG_INFO, "INTERPOLATION selected, please report the sample to the developers\n");
}
}
}
if (header.compression >= 17) {
av_log(s->avctx, AV_LOG_ERROR, "invalid compression type (%d)\n", header.compression);
return -1;
}
if ((header.deltaset != s->last_deltaset) ||
(header.vectable != s->last_vectable))
select_delta_tables(s, header.deltaset);
if ((header.compression & 1) && header.header_type)
sel_vector_table = pc_tbl2;
else {
if (header.vectable < 4)
sel_vector_table = tables[header.vectable - 1];
else {
av_log(s->avctx, AV_LOG_ERROR, "invalid vector table id (%d)\n", header.vectable);
return -1;
}
}
if (compression_types[header.compression].algorithm == ALGO_RGB24H) {
new_pix_fmt = PIX_FMT_RGB32;
width_shift = 1;
} else
new_pix_fmt = PIX_FMT_RGB555; // RGB565 is supported as well
s->w >>= width_shift;
if (av_image_check_size(s->w, s->h, 0, s->avctx) < 0)
return -1;
if (s->w != s->avctx->width || s->h != s->avctx->height ||
new_pix_fmt != s->avctx->pix_fmt) {
if (s->frame.data[0])
s->avctx->release_buffer(s->avctx, &s->frame);
s->avctx->sample_aspect_ratio = (AVRational){ 1 << width_shift, 1 };
s->avctx->pix_fmt = new_pix_fmt;
avcodec_set_dimensions(s->avctx, s->w, s->h);
av_fast_malloc(&s->vert_pred, &s->vert_pred_size, s->avctx->width * sizeof(unsigned int));
}
/* There is 1 change bit per 4 pixels, so each change byte represents
* 32 pixels; divide width by 4 to obtain the number of change bits and
* then round up to the nearest byte. */
s->mb_change_bits_row_size = ((s->avctx->width >> (2 - width_shift)) + 7) >> 3;
if ((header.deltaset != s->last_deltaset) || (header.vectable != s->last_vectable))
{
if (compression_types[header.compression].algorithm == ALGO_RGB24H)
gen_vector_table24(s, sel_vector_table);
else
if (s->avctx->pix_fmt == PIX_FMT_RGB555)
gen_vector_table15(s, sel_vector_table);
else
gen_vector_table16(s, sel_vector_table);
}
/* set up pointers to the other key data chunks */
s->mb_change_bits = s->buf + header.header_size;
if (s->flags & FLAG_KEYFRAME) {
/* no change bits specified for a keyframe; only index bytes */
s->index_stream = s->mb_change_bits;
} else {
/* one change bit per 4x4 block */
s->index_stream = s->mb_change_bits +
(s->mb_change_bits_row_size * (s->avctx->height >> 2));
}
s->index_stream_size = s->size - (s->index_stream - s->buf);
s->last_deltaset = header.deltaset;
s->last_vectable = header.vectable;
s->compression = header.compression;
s->block_width = compression_types[header.compression].block_width;
s->block_height = compression_types[header.compression].block_height;
s->block_type = compression_types[header.compression].block_type;
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_INFO, "tables: %d / %d c:%d %dx%d t:%d %s%s%s%s\n",
s->last_deltaset, s->last_vectable, s->compression, s->block_width,
s->block_height, s->block_type,
s->flags & FLAG_KEYFRAME ? " KEY" : "",
s->flags & FLAG_INTERFRAME ? " INTER" : "",
s->flags & FLAG_SPRITE ? " SPRITE" : "",
s->flags & FLAG_INTERPOLATED ? " INTERPOL" : "");
return header.header_size;
}
| false | FFmpeg | 8e37a1deb30c51e2e2ef5726f550b698303bc029 | static int truemotion1_decode_header(TrueMotion1Context *s)
{
int i;
int width_shift = 0;
int new_pix_fmt;
struct frame_header header;
uint8_t header_buffer[128];
const uint8_t *sel_vector_table;
header.header_size = ((s->buf[0] >> 5) | (s->buf[0] << 3)) & 0x7f;
if (s->buf[0] < 0x10)
{
av_log(s->avctx, AV_LOG_ERROR, "invalid header size (%d)\n", s->buf[0]);
return -1;
}
memset(header_buffer, 0, 128);
for (i = 1; i < header.header_size; i++)
header_buffer[i - 1] = s->buf[i] ^ s->buf[i + 1];
header.compression = header_buffer[0];
header.deltaset = header_buffer[1];
header.vectable = header_buffer[2];
header.ysize = AV_RL16(&header_buffer[3]);
header.xsize = AV_RL16(&header_buffer[5]);
header.checksum = AV_RL16(&header_buffer[7]);
header.version = header_buffer[9];
header.header_type = header_buffer[10];
header.flags = header_buffer[11];
header.control = header_buffer[12];
if (header.version >= 2)
{
if (header.header_type > 3)
{
av_log(s->avctx, AV_LOG_ERROR, "invalid header type (%d)\n", header.header_type);
return -1;
} else if ((header.header_type == 2) || (header.header_type == 3)) {
s->flags = header.flags;
if (!(s->flags & FLAG_INTERFRAME))
s->flags |= FLAG_KEYFRAME;
} else
s->flags = FLAG_KEYFRAME;
} else
s->flags = FLAG_KEYFRAME;
if (s->flags & FLAG_SPRITE) {
av_log(s->avctx, AV_LOG_INFO, "SPRITE frame found, please report the sample to the developers\n");
#if 0
s->w = header.width;
s->h = header.height;
s->x = header.xoffset;
s->y = header.yoffset;
#else
return -1;
#endif
} else {
s->w = header.xsize;
s->h = header.ysize;
if (header.header_type < 2) {
if ((s->w < 213) && (s->h >= 176))
{
s->flags |= FLAG_INTERPOLATED;
av_log(s->avctx, AV_LOG_INFO, "INTERPOLATION selected, please report the sample to the developers\n");
}
}
}
if (header.compression >= 17) {
av_log(s->avctx, AV_LOG_ERROR, "invalid compression type (%d)\n", header.compression);
return -1;
}
if ((header.deltaset != s->last_deltaset) ||
(header.vectable != s->last_vectable))
select_delta_tables(s, header.deltaset);
if ((header.compression & 1) && header.header_type)
sel_vector_table = pc_tbl2;
else {
if (header.vectable < 4)
sel_vector_table = tables[header.vectable - 1];
else {
av_log(s->avctx, AV_LOG_ERROR, "invalid vector table id (%d)\n", header.vectable);
return -1;
}
}
if (compression_types[header.compression].algorithm == ALGO_RGB24H) {
new_pix_fmt = PIX_FMT_RGB32;
width_shift = 1;
} else
new_pix_fmt = PIX_FMT_RGB555;
s->w >>= width_shift;
if (av_image_check_size(s->w, s->h, 0, s->avctx) < 0)
return -1;
if (s->w != s->avctx->width || s->h != s->avctx->height ||
new_pix_fmt != s->avctx->pix_fmt) {
if (s->frame.data[0])
s->avctx->release_buffer(s->avctx, &s->frame);
s->avctx->sample_aspect_ratio = (AVRational){ 1 << width_shift, 1 };
s->avctx->pix_fmt = new_pix_fmt;
avcodec_set_dimensions(s->avctx, s->w, s->h);
av_fast_malloc(&s->vert_pred, &s->vert_pred_size, s->avctx->width * sizeof(unsigned int));
}
s->mb_change_bits_row_size = ((s->avctx->width >> (2 - width_shift)) + 7) >> 3;
if ((header.deltaset != s->last_deltaset) || (header.vectable != s->last_vectable))
{
if (compression_types[header.compression].algorithm == ALGO_RGB24H)
gen_vector_table24(s, sel_vector_table);
else
if (s->avctx->pix_fmt == PIX_FMT_RGB555)
gen_vector_table15(s, sel_vector_table);
else
gen_vector_table16(s, sel_vector_table);
}
s->mb_change_bits = s->buf + header.header_size;
if (s->flags & FLAG_KEYFRAME) {
s->index_stream = s->mb_change_bits;
} else {
s->index_stream = s->mb_change_bits +
(s->mb_change_bits_row_size * (s->avctx->height >> 2));
}
s->index_stream_size = s->size - (s->index_stream - s->buf);
s->last_deltaset = header.deltaset;
s->last_vectable = header.vectable;
s->compression = header.compression;
s->block_width = compression_types[header.compression].block_width;
s->block_height = compression_types[header.compression].block_height;
s->block_type = compression_types[header.compression].block_type;
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_INFO, "tables: %d / %d c:%d %dx%d t:%d %s%s%s%s\n",
s->last_deltaset, s->last_vectable, s->compression, s->block_width,
s->block_height, s->block_type,
s->flags & FLAG_KEYFRAME ? " KEY" : "",
s->flags & FLAG_INTERFRAME ? " INTER" : "",
s->flags & FLAG_SPRITE ? " SPRITE" : "",
s->flags & FLAG_INTERPOLATED ? " INTERPOL" : "");
return header.header_size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(TrueMotion1Context *VAR_0)
{
int VAR_1;
int VAR_2 = 0;
int VAR_3;
struct frame_header VAR_4;
uint8_t header_buffer[128];
const uint8_t *VAR_5;
VAR_4.header_size = ((VAR_0->buf[0] >> 5) | (VAR_0->buf[0] << 3)) & 0x7f;
if (VAR_0->buf[0] < 0x10)
{
av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid VAR_4 size (%d)\n", VAR_0->buf[0]);
return -1;
}
memset(header_buffer, 0, 128);
for (VAR_1 = 1; VAR_1 < VAR_4.header_size; VAR_1++)
header_buffer[VAR_1 - 1] = VAR_0->buf[VAR_1] ^ VAR_0->buf[VAR_1 + 1];
VAR_4.compression = header_buffer[0];
VAR_4.deltaset = header_buffer[1];
VAR_4.vectable = header_buffer[2];
VAR_4.ysize = AV_RL16(&header_buffer[3]);
VAR_4.xsize = AV_RL16(&header_buffer[5]);
VAR_4.checksum = AV_RL16(&header_buffer[7]);
VAR_4.version = header_buffer[9];
VAR_4.header_type = header_buffer[10];
VAR_4.flags = header_buffer[11];
VAR_4.control = header_buffer[12];
if (VAR_4.version >= 2)
{
if (VAR_4.header_type > 3)
{
av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid VAR_4 type (%d)\n", VAR_4.header_type);
return -1;
} else if ((VAR_4.header_type == 2) || (VAR_4.header_type == 3)) {
VAR_0->flags = VAR_4.flags;
if (!(VAR_0->flags & FLAG_INTERFRAME))
VAR_0->flags |= FLAG_KEYFRAME;
} else
VAR_0->flags = FLAG_KEYFRAME;
} else
VAR_0->flags = FLAG_KEYFRAME;
if (VAR_0->flags & FLAG_SPRITE) {
av_log(VAR_0->avctx, AV_LOG_INFO, "SPRITE frame found, please report the sample to the developers\n");
#if 0
VAR_0->w = VAR_4.width;
VAR_0->h = VAR_4.height;
VAR_0->x = VAR_4.xoffset;
VAR_0->y = VAR_4.yoffset;
#else
return -1;
#endif
} else {
VAR_0->w = VAR_4.xsize;
VAR_0->h = VAR_4.ysize;
if (VAR_4.header_type < 2) {
if ((VAR_0->w < 213) && (VAR_0->h >= 176))
{
VAR_0->flags |= FLAG_INTERPOLATED;
av_log(VAR_0->avctx, AV_LOG_INFO, "INTERPOLATION selected, please report the sample to the developers\n");
}
}
}
if (VAR_4.compression >= 17) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid compression type (%d)\n", VAR_4.compression);
return -1;
}
if ((VAR_4.deltaset != VAR_0->last_deltaset) ||
(VAR_4.vectable != VAR_0->last_vectable))
select_delta_tables(VAR_0, VAR_4.deltaset);
if ((VAR_4.compression & 1) && VAR_4.header_type)
VAR_5 = pc_tbl2;
else {
if (VAR_4.vectable < 4)
VAR_5 = tables[VAR_4.vectable - 1];
else {
av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid vector table id (%d)\n", VAR_4.vectable);
return -1;
}
}
if (compression_types[VAR_4.compression].algorithm == ALGO_RGB24H) {
VAR_3 = PIX_FMT_RGB32;
VAR_2 = 1;
} else
VAR_3 = PIX_FMT_RGB555;
VAR_0->w >>= VAR_2;
if (av_image_check_size(VAR_0->w, VAR_0->h, 0, VAR_0->avctx) < 0)
return -1;
if (VAR_0->w != VAR_0->avctx->width || VAR_0->h != VAR_0->avctx->height ||
VAR_3 != VAR_0->avctx->pix_fmt) {
if (VAR_0->frame.data[0])
VAR_0->avctx->release_buffer(VAR_0->avctx, &VAR_0->frame);
VAR_0->avctx->sample_aspect_ratio = (AVRational){ 1 << VAR_2, 1 };
VAR_0->avctx->pix_fmt = VAR_3;
avcodec_set_dimensions(VAR_0->avctx, VAR_0->w, VAR_0->h);
av_fast_malloc(&VAR_0->vert_pred, &VAR_0->vert_pred_size, VAR_0->avctx->width * sizeof(unsigned int));
}
VAR_0->mb_change_bits_row_size = ((VAR_0->avctx->width >> (2 - VAR_2)) + 7) >> 3;
if ((VAR_4.deltaset != VAR_0->last_deltaset) || (VAR_4.vectable != VAR_0->last_vectable))
{
if (compression_types[VAR_4.compression].algorithm == ALGO_RGB24H)
gen_vector_table24(VAR_0, VAR_5);
else
if (VAR_0->avctx->pix_fmt == PIX_FMT_RGB555)
gen_vector_table15(VAR_0, VAR_5);
else
gen_vector_table16(VAR_0, VAR_5);
}
VAR_0->mb_change_bits = VAR_0->buf + VAR_4.header_size;
if (VAR_0->flags & FLAG_KEYFRAME) {
VAR_0->index_stream = VAR_0->mb_change_bits;
} else {
VAR_0->index_stream = VAR_0->mb_change_bits +
(VAR_0->mb_change_bits_row_size * (VAR_0->avctx->height >> 2));
}
VAR_0->index_stream_size = VAR_0->size - (VAR_0->index_stream - VAR_0->buf);
VAR_0->last_deltaset = VAR_4.deltaset;
VAR_0->last_vectable = VAR_4.vectable;
VAR_0->compression = VAR_4.compression;
VAR_0->block_width = compression_types[VAR_4.compression].block_width;
VAR_0->block_height = compression_types[VAR_4.compression].block_height;
VAR_0->block_type = compression_types[VAR_4.compression].block_type;
if (VAR_0->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(VAR_0->avctx, AV_LOG_INFO, "tables: %d / %d c:%d %dx%d t:%d %VAR_0%VAR_0%VAR_0%VAR_0\n",
VAR_0->last_deltaset, VAR_0->last_vectable, VAR_0->compression, VAR_0->block_width,
VAR_0->block_height, VAR_0->block_type,
VAR_0->flags & FLAG_KEYFRAME ? " KEY" : "",
VAR_0->flags & FLAG_INTERFRAME ? " INTER" : "",
VAR_0->flags & FLAG_SPRITE ? " SPRITE" : "",
VAR_0->flags & FLAG_INTERPOLATED ? " INTERPOL" : "");
return VAR_4.header_size;
}
| [
"static int FUNC_0(TrueMotion1Context *VAR_0)\n{",
"int VAR_1;",
"int VAR_2 = 0;",
"int VAR_3;",
"struct frame_header VAR_4;",
"uint8_t header_buffer[128];",
"const uint8_t *VAR_5;",
"VAR_4.header_size = ((VAR_0->buf[0] >> 5) | (VAR_0->buf[0] << 3)) & 0x7f;",
"if (VAR_0->buf[0] < 0x10)\n{",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"invalid VAR_4 size (%d)\\n\", VAR_0->buf[0]);",
"return -1;",
"}",
"memset(header_buffer, 0, 128);",
"for (VAR_1 = 1; VAR_1 < VAR_4.header_size; VAR_1++)",
"header_buffer[VAR_1 - 1] = VAR_0->buf[VAR_1] ^ VAR_0->buf[VAR_1 + 1];",
"VAR_4.compression = header_buffer[0];",
"VAR_4.deltaset = header_buffer[1];",
"VAR_4.vectable = header_buffer[2];",
"VAR_4.ysize = AV_RL16(&header_buffer[3]);",
"VAR_4.xsize = AV_RL16(&header_buffer[5]);",
"VAR_4.checksum = AV_RL16(&header_buffer[7]);",
"VAR_4.version = header_buffer[9];",
"VAR_4.header_type = header_buffer[10];",
"VAR_4.flags = header_buffer[11];",
"VAR_4.control = header_buffer[12];",
"if (VAR_4.version >= 2)\n{",
"if (VAR_4.header_type > 3)\n{",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"invalid VAR_4 type (%d)\\n\", VAR_4.header_type);",
"return -1;",
"} else if ((VAR_4.header_type == 2) || (VAR_4.header_type == 3)) {",
"VAR_0->flags = VAR_4.flags;",
"if (!(VAR_0->flags & FLAG_INTERFRAME))\nVAR_0->flags |= FLAG_KEYFRAME;",
"} else",
"VAR_0->flags = FLAG_KEYFRAME;",
"} else",
"VAR_0->flags = FLAG_KEYFRAME;",
"if (VAR_0->flags & FLAG_SPRITE) {",
"av_log(VAR_0->avctx, AV_LOG_INFO, \"SPRITE frame found, please report the sample to the developers\\n\");",
"#if 0\nVAR_0->w = VAR_4.width;",
"VAR_0->h = VAR_4.height;",
"VAR_0->x = VAR_4.xoffset;",
"VAR_0->y = VAR_4.yoffset;",
"#else\nreturn -1;",
"#endif\n} else {",
"VAR_0->w = VAR_4.xsize;",
"VAR_0->h = VAR_4.ysize;",
"if (VAR_4.header_type < 2) {",
"if ((VAR_0->w < 213) && (VAR_0->h >= 176))\n{",
"VAR_0->flags |= FLAG_INTERPOLATED;",
"av_log(VAR_0->avctx, AV_LOG_INFO, \"INTERPOLATION selected, please report the sample to the developers\\n\");",
"}",
"}",
"}",
"if (VAR_4.compression >= 17) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"invalid compression type (%d)\\n\", VAR_4.compression);",
"return -1;",
"}",
"if ((VAR_4.deltaset != VAR_0->last_deltaset) ||\n(VAR_4.vectable != VAR_0->last_vectable))\nselect_delta_tables(VAR_0, VAR_4.deltaset);",
"if ((VAR_4.compression & 1) && VAR_4.header_type)\nVAR_5 = pc_tbl2;",
"else {",
"if (VAR_4.vectable < 4)\nVAR_5 = tables[VAR_4.vectable - 1];",
"else {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"invalid vector table id (%d)\\n\", VAR_4.vectable);",
"return -1;",
"}",
"}",
"if (compression_types[VAR_4.compression].algorithm == ALGO_RGB24H) {",
"VAR_3 = PIX_FMT_RGB32;",
"VAR_2 = 1;",
"} else",
"VAR_3 = PIX_FMT_RGB555;",
"VAR_0->w >>= VAR_2;",
"if (av_image_check_size(VAR_0->w, VAR_0->h, 0, VAR_0->avctx) < 0)\nreturn -1;",
"if (VAR_0->w != VAR_0->avctx->width || VAR_0->h != VAR_0->avctx->height ||\nVAR_3 != VAR_0->avctx->pix_fmt) {",
"if (VAR_0->frame.data[0])\nVAR_0->avctx->release_buffer(VAR_0->avctx, &VAR_0->frame);",
"VAR_0->avctx->sample_aspect_ratio = (AVRational){ 1 << VAR_2, 1 };",
"VAR_0->avctx->pix_fmt = VAR_3;",
"avcodec_set_dimensions(VAR_0->avctx, VAR_0->w, VAR_0->h);",
"av_fast_malloc(&VAR_0->vert_pred, &VAR_0->vert_pred_size, VAR_0->avctx->width * sizeof(unsigned int));",
"}",
"VAR_0->mb_change_bits_row_size = ((VAR_0->avctx->width >> (2 - VAR_2)) + 7) >> 3;",
"if ((VAR_4.deltaset != VAR_0->last_deltaset) || (VAR_4.vectable != VAR_0->last_vectable))\n{",
"if (compression_types[VAR_4.compression].algorithm == ALGO_RGB24H)\ngen_vector_table24(VAR_0, VAR_5);",
"else\nif (VAR_0->avctx->pix_fmt == PIX_FMT_RGB555)\ngen_vector_table15(VAR_0, VAR_5);",
"else\ngen_vector_table16(VAR_0, VAR_5);",
"}",
"VAR_0->mb_change_bits = VAR_0->buf + VAR_4.header_size;",
"if (VAR_0->flags & FLAG_KEYFRAME) {",
"VAR_0->index_stream = VAR_0->mb_change_bits;",
"} else {",
"VAR_0->index_stream = VAR_0->mb_change_bits +\n(VAR_0->mb_change_bits_row_size * (VAR_0->avctx->height >> 2));",
"}",
"VAR_0->index_stream_size = VAR_0->size - (VAR_0->index_stream - VAR_0->buf);",
"VAR_0->last_deltaset = VAR_4.deltaset;",
"VAR_0->last_vectable = VAR_4.vectable;",
"VAR_0->compression = VAR_4.compression;",
"VAR_0->block_width = compression_types[VAR_4.compression].block_width;",
"VAR_0->block_height = compression_types[VAR_4.compression].block_height;",
"VAR_0->block_type = compression_types[VAR_4.compression].block_type;",
"if (VAR_0->avctx->debug & FF_DEBUG_PICT_INFO)\nav_log(VAR_0->avctx, AV_LOG_INFO, \"tables: %d / %d c:%d %dx%d t:%d %VAR_0%VAR_0%VAR_0%VAR_0\\n\",\nVAR_0->last_deltaset, VAR_0->last_vectable, VAR_0->compression, VAR_0->block_width,\nVAR_0->block_height, VAR_0->block_type,\nVAR_0->flags & FLAG_KEYFRAME ? \" KEY\" : \"\",\nVAR_0->flags & FLAG_INTERFRAME ? \" INTER\" : \"\",\nVAR_0->flags & FLAG_SPRITE ? \" SPRITE\" : \"\",\nVAR_0->flags & FLAG_INTERPOLATED ? \" INTERPOL\" : \"\");",
"return VAR_4.header_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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
67,
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
103,
105
],
[
107
],
[
109
],
[
111
],
[
113,
115
],
[
117,
119
],
[
121
],
[
123
],
[
125
],
[
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153,
155,
157
],
[
161,
163
],
[
165
],
[
167,
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197,
199
],
[
203,
205
],
[
207,
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
229
],
[
233,
235
],
[
237,
239
],
[
241,
243,
245
],
[
247,
249
],
[
251
],
[
257
],
[
259
],
[
263
],
[
265
],
[
269,
271
],
[
273
],
[
275
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
293,
295,
297,
299,
301,
303,
305,
307
],
[
311
],
[
313
]
] |
24,911 | static int opt_input_ts_scale(const char *opt, const char *arg)
{
unsigned int stream;
double scale;
char *p;
stream = strtol(arg, &p, 0);
if (*p)
p++;
scale= strtod(p, &p);
if(stream >= MAX_STREAMS)
ffmpeg_exit(1);
ts_scale = grow_array(ts_scale, sizeof(*ts_scale), &nb_ts_scale, stream + 1);
ts_scale[stream] = scale;
return 0;
}
| false | FFmpeg | c7dd3e7e43555b2922481a9242a306c5b138d69c | static int opt_input_ts_scale(const char *opt, const char *arg)
{
unsigned int stream;
double scale;
char *p;
stream = strtol(arg, &p, 0);
if (*p)
p++;
scale= strtod(p, &p);
if(stream >= MAX_STREAMS)
ffmpeg_exit(1);
ts_scale = grow_array(ts_scale, sizeof(*ts_scale), &nb_ts_scale, stream + 1);
ts_scale[stream] = scale;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(const char *VAR_0, const char *VAR_1)
{
unsigned int VAR_2;
double VAR_3;
char *VAR_4;
VAR_2 = strtol(VAR_1, &VAR_4, 0);
if (*VAR_4)
VAR_4++;
VAR_3= strtod(VAR_4, &VAR_4);
if(VAR_2 >= MAX_STREAMS)
ffmpeg_exit(1);
ts_scale = grow_array(ts_scale, sizeof(*ts_scale), &nb_ts_scale, VAR_2 + 1);
ts_scale[VAR_2] = VAR_3;
return 0;
}
| [
"static int FUNC_0(const char *VAR_0, const char *VAR_1)\n{",
"unsigned int VAR_2;",
"double VAR_3;",
"char *VAR_4;",
"VAR_2 = strtol(VAR_1, &VAR_4, 0);",
"if (*VAR_4)\nVAR_4++;",
"VAR_3= strtod(VAR_4, &VAR_4);",
"if(VAR_2 >= MAX_STREAMS)\nffmpeg_exit(1);",
"ts_scale = grow_array(ts_scale, sizeof(*ts_scale), &nb_ts_scale, VAR_2 + 1);",
"ts_scale[VAR_2] = VAR_3;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
23,
25
],
[
29
],
[
31
],
[
33
],
[
35
]
] |
24,912 | static av_always_inline int normal_limit(uint8_t *p, int stride, int E, int I)
{
LOAD_PIXELS
return simple_limit(p, stride, 2*E+I)
&& FFABS(p3-p2) <= I && FFABS(p2-p1) <= I && FFABS(p1-p0) <= I
&& FFABS(q3-q2) <= I && FFABS(q2-q1) <= I && FFABS(q1-q0) <= I;
}
| false | FFmpeg | 5245c04da332ab9585133ad55f8ec7a06d43b0b0 | static av_always_inline int normal_limit(uint8_t *p, int stride, int E, int I)
{
LOAD_PIXELS
return simple_limit(p, stride, 2*E+I)
&& FFABS(p3-p2) <= I && FFABS(p2-p1) <= I && FFABS(p1-p0) <= I
&& FFABS(q3-q2) <= I && FFABS(q2-q1) <= I && FFABS(q1-q0) <= I;
}
| {
"code": [],
"line_no": []
} | static av_always_inline int FUNC_0(uint8_t *p, int stride, int E, int I)
{
LOAD_PIXELS
return simple_limit(p, stride, 2*E+I)
&& FFABS(p3-p2) <= I && FFABS(p2-p1) <= I && FFABS(p1-p0) <= I
&& FFABS(q3-q2) <= I && FFABS(q2-q1) <= I && FFABS(q1-q0) <= I;
}
| [
"static av_always_inline int FUNC_0(uint8_t *p, int stride, int E, int I)\n{",
"LOAD_PIXELS\nreturn simple_limit(p, stride, 2*E+I)\n&& FFABS(p3-p2) <= I && FFABS(p2-p1) <= I && FFABS(p1-p0) <= I\n&& FFABS(q3-q2) <= I && FFABS(q2-q1) <= I && FFABS(q1-q0) <= I;",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5,
7,
9,
11
],
[
13
]
] |
24,913 | static int mov_open_dref(AVIOContext **pb, const char *src, MOVDref *ref,
AVIOInterruptCB *int_cb, int use_absolute_path, AVFormatContext *fc)
{
/* try relative path, we do not try the absolute because it can leak information about our
system to an attacker */
if (ref->nlvl_to > 0 && ref->nlvl_from > 0) {
char filename[1024];
const char *src_path;
int i, l;
/* find a source dir */
src_path = strrchr(src, '/');
if (src_path)
src_path++;
else
src_path = src;
/* find a next level down to target */
for (i = 0, l = strlen(ref->path) - 1; l >= 0; l--)
if (ref->path[l] == '/') {
if (i == ref->nlvl_to - 1)
break;
else
i++;
}
/* compose filename if next level down to target was found */
if (i == ref->nlvl_to - 1 && src_path - src < sizeof(filename)) {
memcpy(filename, src, src_path - src);
filename[src_path - src] = 0;
for (i = 1; i < ref->nlvl_from; i++)
av_strlcat(filename, "../", sizeof(filename));
av_strlcat(filename, ref->path + l + 1, sizeof(filename));
if (!avio_open2(pb, filename, AVIO_FLAG_READ, int_cb, NULL))
return 0;
}
} else if (use_absolute_path) {
av_log(fc, AV_LOG_WARNING, "Using absolute path on user request, "
"this is a possible security issue\n");
if (!avio_open2(pb, ref->path, AVIO_FLAG_READ, int_cb, NULL))
return 0;
}
return AVERROR(ENOENT);
}
| false | FFmpeg | 8003816e1619e77d8de051883264aa090e0d78cc | static int mov_open_dref(AVIOContext **pb, const char *src, MOVDref *ref,
AVIOInterruptCB *int_cb, int use_absolute_path, AVFormatContext *fc)
{
if (ref->nlvl_to > 0 && ref->nlvl_from > 0) {
char filename[1024];
const char *src_path;
int i, l;
src_path = strrchr(src, '/');
if (src_path)
src_path++;
else
src_path = src;
for (i = 0, l = strlen(ref->path) - 1; l >= 0; l--)
if (ref->path[l] == '/') {
if (i == ref->nlvl_to - 1)
break;
else
i++;
}
if (i == ref->nlvl_to - 1 && src_path - src < sizeof(filename)) {
memcpy(filename, src, src_path - src);
filename[src_path - src] = 0;
for (i = 1; i < ref->nlvl_from; i++)
av_strlcat(filename, "../", sizeof(filename));
av_strlcat(filename, ref->path + l + 1, sizeof(filename));
if (!avio_open2(pb, filename, AVIO_FLAG_READ, int_cb, NULL))
return 0;
}
} else if (use_absolute_path) {
av_log(fc, AV_LOG_WARNING, "Using absolute path on user request, "
"this is a possible security issue\n");
if (!avio_open2(pb, ref->path, AVIO_FLAG_READ, int_cb, NULL))
return 0;
}
return AVERROR(ENOENT);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVIOContext **VAR_0, const char *VAR_1, MOVDref *VAR_2,
AVIOInterruptCB *VAR_3, int VAR_4, AVFormatContext *VAR_5)
{
if (VAR_2->nlvl_to > 0 && VAR_2->nlvl_from > 0) {
char VAR_6[1024];
const char *VAR_7;
int VAR_8, VAR_9;
VAR_7 = strrchr(VAR_1, '/');
if (VAR_7)
VAR_7++;
else
VAR_7 = VAR_1;
for (VAR_8 = 0, VAR_9 = strlen(VAR_2->path) - 1; VAR_9 >= 0; VAR_9--)
if (VAR_2->path[VAR_9] == '/') {
if (VAR_8 == VAR_2->nlvl_to - 1)
break;
else
VAR_8++;
}
if (VAR_8 == VAR_2->nlvl_to - 1 && VAR_7 - VAR_1 < sizeof(VAR_6)) {
memcpy(VAR_6, VAR_1, VAR_7 - VAR_1);
VAR_6[VAR_7 - VAR_1] = 0;
for (VAR_8 = 1; VAR_8 < VAR_2->nlvl_from; VAR_8++)
av_strlcat(VAR_6, "../", sizeof(VAR_6));
av_strlcat(VAR_6, VAR_2->path + VAR_9 + 1, sizeof(VAR_6));
if (!avio_open2(VAR_0, VAR_6, AVIO_FLAG_READ, VAR_3, NULL))
return 0;
}
} else if (VAR_4) {
av_log(VAR_5, AV_LOG_WARNING, "Using absolute path on user request, "
"this is a possible security issue\n");
if (!avio_open2(VAR_0, VAR_2->path, AVIO_FLAG_READ, VAR_3, NULL))
return 0;
}
return AVERROR(ENOENT);
}
| [
"static int FUNC_0(AVIOContext **VAR_0, const char *VAR_1, MOVDref *VAR_2,\nAVIOInterruptCB *VAR_3, int VAR_4, AVFormatContext *VAR_5)\n{",
"if (VAR_2->nlvl_to > 0 && VAR_2->nlvl_from > 0) {",
"char VAR_6[1024];",
"const char *VAR_7;",
"int VAR_8, VAR_9;",
"VAR_7 = strrchr(VAR_1, '/');",
"if (VAR_7)\nVAR_7++;",
"else\nVAR_7 = VAR_1;",
"for (VAR_8 = 0, VAR_9 = strlen(VAR_2->path) - 1; VAR_9 >= 0; VAR_9--)",
"if (VAR_2->path[VAR_9] == '/') {",
"if (VAR_8 == VAR_2->nlvl_to - 1)\nbreak;",
"else\nVAR_8++;",
"}",
"if (VAR_8 == VAR_2->nlvl_to - 1 && VAR_7 - VAR_1 < sizeof(VAR_6)) {",
"memcpy(VAR_6, VAR_1, VAR_7 - VAR_1);",
"VAR_6[VAR_7 - VAR_1] = 0;",
"for (VAR_8 = 1; VAR_8 < VAR_2->nlvl_from; VAR_8++)",
"av_strlcat(VAR_6, \"../\", sizeof(VAR_6));",
"av_strlcat(VAR_6, VAR_2->path + VAR_9 + 1, sizeof(VAR_6));",
"if (!avio_open2(VAR_0, VAR_6, AVIO_FLAG_READ, VAR_3, NULL))\nreturn 0;",
"}",
"} else if (VAR_4) {",
"av_log(VAR_5, AV_LOG_WARNING, \"Using absolute path on user request, \"\n\"this is a possible security issue\\n\");",
"if (!avio_open2(VAR_0, VAR_2->path, AVIO_FLAG_READ, VAR_3, NULL))\nreturn 0;",
"}",
"return AVERROR(ENOENT);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25,
27
],
[
29,
31
],
[
37
],
[
39
],
[
41,
43
],
[
45,
47
],
[
49
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
69
],
[
73,
75
],
[
77
],
[
79
],
[
81,
83
],
[
85,
87
],
[
89
],
[
93
],
[
95
]
] |
24,914 | static int swScale(SwsContext *c, const uint8_t* src[],
int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[])
{
/* load a few things into local vars to make the code more readable? and faster */
const int srcW= c->srcW;
const int dstW= c->dstW;
const int dstH= c->dstH;
const int chrDstW= c->chrDstW;
const int chrSrcW= c->chrSrcW;
const int lumXInc= c->lumXInc;
const int chrXInc= c->chrXInc;
const enum PixelFormat dstFormat= c->dstFormat;
const int flags= c->flags;
int16_t *vLumFilterPos= c->vLumFilterPos;
int16_t *vChrFilterPos= c->vChrFilterPos;
int16_t *hLumFilterPos= c->hLumFilterPos;
int16_t *hChrFilterPos= c->hChrFilterPos;
int16_t *vLumFilter= c->vLumFilter;
int16_t *vChrFilter= c->vChrFilter;
int16_t *hLumFilter= c->hLumFilter;
int16_t *hChrFilter= c->hChrFilter;
int32_t *lumMmxFilter= c->lumMmxFilter;
int32_t *chrMmxFilter= c->chrMmxFilter;
int32_t av_unused *alpMmxFilter= c->alpMmxFilter;
const int vLumFilterSize= c->vLumFilterSize;
const int vChrFilterSize= c->vChrFilterSize;
const int hLumFilterSize= c->hLumFilterSize;
const int hChrFilterSize= c->hChrFilterSize;
int16_t **lumPixBuf= c->lumPixBuf;
int16_t **chrUPixBuf= c->chrUPixBuf;
int16_t **chrVPixBuf= c->chrVPixBuf;
int16_t **alpPixBuf= c->alpPixBuf;
const int vLumBufSize= c->vLumBufSize;
const int vChrBufSize= c->vChrBufSize;
uint8_t *formatConvBuffer= c->formatConvBuffer;
const int chrSrcSliceY= srcSliceY >> c->chrSrcVSubSample;
const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample);
int lastDstY;
uint32_t *pal=c->pal_yuv;
yuv2planar1_fn yuv2yuv1 = c->yuv2yuv1;
yuv2planarX_fn yuv2yuvX = c->yuv2yuvX;
yuv2packed1_fn yuv2packed1 = c->yuv2packed1;
yuv2packed2_fn yuv2packed2 = c->yuv2packed2;
yuv2packedX_fn yuv2packedX = c->yuv2packedX;
/* vars which will change and which we need to store back in the context */
int dstY= c->dstY;
int lumBufIndex= c->lumBufIndex;
int chrBufIndex= c->chrBufIndex;
int lastInLumBuf= c->lastInLumBuf;
int lastInChrBuf= c->lastInChrBuf;
if (isPacked(c->srcFormat)) {
src[0]=
src[1]=
src[2]=
src[3]= src[0];
srcStride[0]=
srcStride[1]=
srcStride[2]=
srcStride[3]= srcStride[0];
}
srcStride[1]<<= c->vChrDrop;
srcStride[2]<<= c->vChrDrop;
DEBUG_BUFFERS("swScale() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\n",
src[0], srcStride[0], src[1], srcStride[1], src[2], srcStride[2], src[3], srcStride[3],
dst[0], dstStride[0], dst[1], dstStride[1], dst[2], dstStride[2], dst[3], dstStride[3]);
DEBUG_BUFFERS("srcSliceY: %d srcSliceH: %d dstY: %d dstH: %d\n",
srcSliceY, srcSliceH, dstY, dstH);
DEBUG_BUFFERS("vLumFilterSize: %d vLumBufSize: %d vChrFilterSize: %d vChrBufSize: %d\n",
vLumFilterSize, vLumBufSize, vChrFilterSize, vChrBufSize);
if (dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0 || dstStride[3]%8 != 0) {
static int warnedAlready=0; //FIXME move this into the context perhaps
if (flags & SWS_PRINT_INFO && !warnedAlready) {
av_log(c, AV_LOG_WARNING, "Warning: dstStride is not aligned!\n"
" ->cannot do aligned memory accesses anymore\n");
warnedAlready=1;
}
}
/* Note the user might start scaling the picture in the middle so this
will not get executed. This is not really intended but works
currently, so people might do it. */
if (srcSliceY ==0) {
lumBufIndex=-1;
chrBufIndex=-1;
dstY=0;
lastInLumBuf= -1;
lastInChrBuf= -1;
}
lastDstY= dstY;
for (;dstY < dstH; dstY++) {
unsigned char *dest =dst[0]+dstStride[0]*dstY;
const int chrDstY= dstY>>c->chrDstVSubSample;
unsigned char *uDest=dst[1]+dstStride[1]*chrDstY;
unsigned char *vDest=dst[2]+dstStride[2]*chrDstY;
unsigned char *aDest=(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3]+dstStride[3]*dstY : NULL;
const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input
const int firstLumSrcY2= vLumFilterPos[FFMIN(dstY | ((1<<c->chrDstVSubSample) - 1), dstH-1)];
const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input
int lastLumSrcY= firstLumSrcY + vLumFilterSize -1; // Last line needed as input
int lastLumSrcY2=firstLumSrcY2+ vLumFilterSize -1; // Last line needed as input
int lastChrSrcY= firstChrSrcY + vChrFilterSize -1; // Last line needed as input
int enough_lines;
//handle holes (FAST_BILINEAR & weird filters)
if (firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1;
if (firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1;
assert(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1);
assert(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1);
DEBUG_BUFFERS("dstY: %d\n", dstY);
DEBUG_BUFFERS("\tfirstLumSrcY: %d lastLumSrcY: %d lastInLumBuf: %d\n",
firstLumSrcY, lastLumSrcY, lastInLumBuf);
DEBUG_BUFFERS("\tfirstChrSrcY: %d lastChrSrcY: %d lastInChrBuf: %d\n",
firstChrSrcY, lastChrSrcY, lastInChrBuf);
// Do we have enough lines in this slice to output the dstY line
enough_lines = lastLumSrcY2 < srcSliceY + srcSliceH && lastChrSrcY < -((-srcSliceY - srcSliceH)>>c->chrSrcVSubSample);
if (!enough_lines) {
lastLumSrcY = srcSliceY + srcSliceH - 1;
lastChrSrcY = chrSrcSliceY + chrSrcSliceH - 1;
DEBUG_BUFFERS("buffering slice: lastLumSrcY %d lastChrSrcY %d\n",
lastLumSrcY, lastChrSrcY);
}
//Do horizontal scaling
while(lastInLumBuf < lastLumSrcY) {
const uint8_t *src1= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0];
const uint8_t *src2= src[3]+(lastInLumBuf + 1 - srcSliceY)*srcStride[3];
lumBufIndex++;
assert(lumBufIndex < 2*vLumBufSize);
assert(lastInLumBuf + 1 - srcSliceY < srcSliceH);
assert(lastInLumBuf + 1 - srcSliceY >= 0);
hyscale(c, lumPixBuf[ lumBufIndex ], dstW, src1, srcW, lumXInc,
hLumFilter, hLumFilterPos, hLumFilterSize,
formatConvBuffer,
pal, 0);
if (CONFIG_SWSCALE_ALPHA && alpPixBuf)
hyscale(c, alpPixBuf[ lumBufIndex ], dstW, src2, srcW,
lumXInc, hLumFilter, hLumFilterPos, hLumFilterSize,
formatConvBuffer,
pal, 1);
lastInLumBuf++;
DEBUG_BUFFERS("\t\tlumBufIndex %d: lastInLumBuf: %d\n",
lumBufIndex, lastInLumBuf);
}
while(lastInChrBuf < lastChrSrcY) {
const uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1];
const uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2];
chrBufIndex++;
assert(chrBufIndex < 2*vChrBufSize);
assert(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH));
assert(lastInChrBuf + 1 - chrSrcSliceY >= 0);
//FIXME replace parameters through context struct (some at least)
if (c->needs_hcscale)
hcscale(c, chrUPixBuf[chrBufIndex], chrVPixBuf[chrBufIndex],
chrDstW, src1, src2, chrSrcW, chrXInc,
hChrFilter, hChrFilterPos, hChrFilterSize,
formatConvBuffer, pal);
lastInChrBuf++;
DEBUG_BUFFERS("\t\tchrBufIndex %d: lastInChrBuf: %d\n",
chrBufIndex, lastInChrBuf);
}
//wrap buf index around to stay inside the ring buffer
if (lumBufIndex >= vLumBufSize) lumBufIndex-= vLumBufSize;
if (chrBufIndex >= vChrBufSize) chrBufIndex-= vChrBufSize;
if (!enough_lines)
break; //we can't output a dstY line so let's try with the next slice
#if HAVE_MMX
updateMMXDitherTables(c, dstY, lumBufIndex, chrBufIndex, lastInLumBuf, lastInChrBuf);
#endif
if (dstY >= dstH-2) {
// hmm looks like we can't use MMX here without overwriting this array's tail
find_c_packed_planar_out_funcs(c, &yuv2yuv1, &yuv2yuvX,
&yuv2packed1, &yuv2packed2,
&yuv2packedX);
}
{
const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
const int16_t **chrUSrcPtr= (const int16_t **) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
const int16_t **chrVSrcPtr= (const int16_t **) chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 like
const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi
if (c->yuv2yuv1 && vLumFilterSize == 1 && vChrFilterSize == 1) { // unscaled YV12
const int16_t *lumBuf = lumSrcPtr[0];
const int16_t *chrUBuf= chrUSrcPtr[0];
const int16_t *chrVBuf= chrVSrcPtr[0];
const int16_t *alpBuf= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpSrcPtr[0] : NULL;
yuv2yuv1(c, lumBuf, chrUBuf, chrVBuf, alpBuf, dest,
uDest, vDest, aDest, dstW, chrDstW);
} else { //General YV12
yuv2yuvX(c,
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+chrDstY*vChrFilterSize, chrUSrcPtr,
chrVSrcPtr, vChrFilterSize,
alpSrcPtr, dest, uDest, vDest, aDest, dstW, chrDstW);
}
} else {
assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2);
assert(chrUSrcPtr + vChrFilterSize - 1 < chrUPixBuf + vChrBufSize*2);
if (c->yuv2packed1 && vLumFilterSize == 1 && vChrFilterSize == 2) { //unscaled RGB
int chrAlpha= vChrFilter[2*dstY+1];
yuv2packed1(c, *lumSrcPtr, *chrUSrcPtr, *(chrUSrcPtr+1),
*chrVSrcPtr, *(chrVSrcPtr+1),
alpPixBuf ? *alpSrcPtr : NULL,
dest, dstW, chrAlpha, dstFormat, flags, dstY);
} else if (c->yuv2packed2 && vLumFilterSize == 2 && vChrFilterSize == 2) { //bilinear upscale RGB
int lumAlpha= vLumFilter[2*dstY+1];
int chrAlpha= vChrFilter[2*dstY+1];
lumMmxFilter[2]=
lumMmxFilter[3]= vLumFilter[2*dstY ]*0x10001;
chrMmxFilter[2]=
chrMmxFilter[3]= vChrFilter[2*chrDstY]*0x10001;
yuv2packed2(c, *lumSrcPtr, *(lumSrcPtr+1), *chrUSrcPtr, *(chrUSrcPtr+1),
*chrVSrcPtr, *(chrVSrcPtr+1),
alpPixBuf ? *alpSrcPtr : NULL, alpPixBuf ? *(alpSrcPtr+1) : NULL,
dest, dstW, lumAlpha, chrAlpha, dstY);
} else { //general RGB
yuv2packedX(c,
vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize,
alpSrcPtr, dest, dstW, dstY);
}
}
}
}
if ((dstFormat == PIX_FMT_YUVA420P) && !alpPixBuf)
fillPlane(dst[3], dstStride[3], dstW, dstY-lastDstY, lastDstY, 255);
#if HAVE_MMX2
if (av_get_cpu_flags() & AV_CPU_FLAG_MMX2)
__asm__ volatile("sfence":::"memory");
#endif
emms_c();
/* store changed local vars back in the context */
c->dstY= dstY;
c->lumBufIndex= lumBufIndex;
c->chrBufIndex= chrBufIndex;
c->lastInLumBuf= lastInLumBuf;
c->lastInChrBuf= lastInChrBuf;
return dstY - lastDstY;
}
| false | FFmpeg | 13a099799e89a76eb921ca452e1b04a7a28a9855 | static int swScale(SwsContext *c, const uint8_t* src[],
int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[])
{
const int srcW= c->srcW;
const int dstW= c->dstW;
const int dstH= c->dstH;
const int chrDstW= c->chrDstW;
const int chrSrcW= c->chrSrcW;
const int lumXInc= c->lumXInc;
const int chrXInc= c->chrXInc;
const enum PixelFormat dstFormat= c->dstFormat;
const int flags= c->flags;
int16_t *vLumFilterPos= c->vLumFilterPos;
int16_t *vChrFilterPos= c->vChrFilterPos;
int16_t *hLumFilterPos= c->hLumFilterPos;
int16_t *hChrFilterPos= c->hChrFilterPos;
int16_t *vLumFilter= c->vLumFilter;
int16_t *vChrFilter= c->vChrFilter;
int16_t *hLumFilter= c->hLumFilter;
int16_t *hChrFilter= c->hChrFilter;
int32_t *lumMmxFilter= c->lumMmxFilter;
int32_t *chrMmxFilter= c->chrMmxFilter;
int32_t av_unused *alpMmxFilter= c->alpMmxFilter;
const int vLumFilterSize= c->vLumFilterSize;
const int vChrFilterSize= c->vChrFilterSize;
const int hLumFilterSize= c->hLumFilterSize;
const int hChrFilterSize= c->hChrFilterSize;
int16_t **lumPixBuf= c->lumPixBuf;
int16_t **chrUPixBuf= c->chrUPixBuf;
int16_t **chrVPixBuf= c->chrVPixBuf;
int16_t **alpPixBuf= c->alpPixBuf;
const int vLumBufSize= c->vLumBufSize;
const int vChrBufSize= c->vChrBufSize;
uint8_t *formatConvBuffer= c->formatConvBuffer;
const int chrSrcSliceY= srcSliceY >> c->chrSrcVSubSample;
const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample);
int lastDstY;
uint32_t *pal=c->pal_yuv;
yuv2planar1_fn yuv2yuv1 = c->yuv2yuv1;
yuv2planarX_fn yuv2yuvX = c->yuv2yuvX;
yuv2packed1_fn yuv2packed1 = c->yuv2packed1;
yuv2packed2_fn yuv2packed2 = c->yuv2packed2;
yuv2packedX_fn yuv2packedX = c->yuv2packedX;
int dstY= c->dstY;
int lumBufIndex= c->lumBufIndex;
int chrBufIndex= c->chrBufIndex;
int lastInLumBuf= c->lastInLumBuf;
int lastInChrBuf= c->lastInChrBuf;
if (isPacked(c->srcFormat)) {
src[0]=
src[1]=
src[2]=
src[3]= src[0];
srcStride[0]=
srcStride[1]=
srcStride[2]=
srcStride[3]= srcStride[0];
}
srcStride[1]<<= c->vChrDrop;
srcStride[2]<<= c->vChrDrop;
DEBUG_BUFFERS("swScale() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\n",
src[0], srcStride[0], src[1], srcStride[1], src[2], srcStride[2], src[3], srcStride[3],
dst[0], dstStride[0], dst[1], dstStride[1], dst[2], dstStride[2], dst[3], dstStride[3]);
DEBUG_BUFFERS("srcSliceY: %d srcSliceH: %d dstY: %d dstH: %d\n",
srcSliceY, srcSliceH, dstY, dstH);
DEBUG_BUFFERS("vLumFilterSize: %d vLumBufSize: %d vChrFilterSize: %d vChrBufSize: %d\n",
vLumFilterSize, vLumBufSize, vChrFilterSize, vChrBufSize);
if (dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0 || dstStride[3]%8 != 0) {
static int warnedAlready=0;
if (flags & SWS_PRINT_INFO && !warnedAlready) {
av_log(c, AV_LOG_WARNING, "Warning: dstStride is not aligned!\n"
" ->cannot do aligned memory accesses anymore\n");
warnedAlready=1;
}
}
if (srcSliceY ==0) {
lumBufIndex=-1;
chrBufIndex=-1;
dstY=0;
lastInLumBuf= -1;
lastInChrBuf= -1;
}
lastDstY= dstY;
for (;dstY < dstH; dstY++) {
unsigned char *dest =dst[0]+dstStride[0]*dstY;
const int chrDstY= dstY>>c->chrDstVSubSample;
unsigned char *uDest=dst[1]+dstStride[1]*chrDstY;
unsigned char *vDest=dst[2]+dstStride[2]*chrDstY;
unsigned char *aDest=(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3]+dstStride[3]*dstY : NULL;
const int firstLumSrcY= vLumFilterPos[dstY];
const int firstLumSrcY2= vLumFilterPos[FFMIN(dstY | ((1<<c->chrDstVSubSample) - 1), dstH-1)];
const int firstChrSrcY= vChrFilterPos[chrDstY];
int lastLumSrcY= firstLumSrcY + vLumFilterSize -1;
int lastLumSrcY2=firstLumSrcY2+ vLumFilterSize -1;
int lastChrSrcY= firstChrSrcY + vChrFilterSize -1;
int enough_lines;
if (firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1;
if (firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1;
assert(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1);
assert(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1);
DEBUG_BUFFERS("dstY: %d\n", dstY);
DEBUG_BUFFERS("\tfirstLumSrcY: %d lastLumSrcY: %d lastInLumBuf: %d\n",
firstLumSrcY, lastLumSrcY, lastInLumBuf);
DEBUG_BUFFERS("\tfirstChrSrcY: %d lastChrSrcY: %d lastInChrBuf: %d\n",
firstChrSrcY, lastChrSrcY, lastInChrBuf);
enough_lines = lastLumSrcY2 < srcSliceY + srcSliceH && lastChrSrcY < -((-srcSliceY - srcSliceH)>>c->chrSrcVSubSample);
if (!enough_lines) {
lastLumSrcY = srcSliceY + srcSliceH - 1;
lastChrSrcY = chrSrcSliceY + chrSrcSliceH - 1;
DEBUG_BUFFERS("buffering slice: lastLumSrcY %d lastChrSrcY %d\n",
lastLumSrcY, lastChrSrcY);
}
while(lastInLumBuf < lastLumSrcY) {
const uint8_t *src1= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0];
const uint8_t *src2= src[3]+(lastInLumBuf + 1 - srcSliceY)*srcStride[3];
lumBufIndex++;
assert(lumBufIndex < 2*vLumBufSize);
assert(lastInLumBuf + 1 - srcSliceY < srcSliceH);
assert(lastInLumBuf + 1 - srcSliceY >= 0);
hyscale(c, lumPixBuf[ lumBufIndex ], dstW, src1, srcW, lumXInc,
hLumFilter, hLumFilterPos, hLumFilterSize,
formatConvBuffer,
pal, 0);
if (CONFIG_SWSCALE_ALPHA && alpPixBuf)
hyscale(c, alpPixBuf[ lumBufIndex ], dstW, src2, srcW,
lumXInc, hLumFilter, hLumFilterPos, hLumFilterSize,
formatConvBuffer,
pal, 1);
lastInLumBuf++;
DEBUG_BUFFERS("\t\tlumBufIndex %d: lastInLumBuf: %d\n",
lumBufIndex, lastInLumBuf);
}
while(lastInChrBuf < lastChrSrcY) {
const uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1];
const uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2];
chrBufIndex++;
assert(chrBufIndex < 2*vChrBufSize);
assert(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH));
assert(lastInChrBuf + 1 - chrSrcSliceY >= 0);
if (c->needs_hcscale)
hcscale(c, chrUPixBuf[chrBufIndex], chrVPixBuf[chrBufIndex],
chrDstW, src1, src2, chrSrcW, chrXInc,
hChrFilter, hChrFilterPos, hChrFilterSize,
formatConvBuffer, pal);
lastInChrBuf++;
DEBUG_BUFFERS("\t\tchrBufIndex %d: lastInChrBuf: %d\n",
chrBufIndex, lastInChrBuf);
}
if (lumBufIndex >= vLumBufSize) lumBufIndex-= vLumBufSize;
if (chrBufIndex >= vChrBufSize) chrBufIndex-= vChrBufSize;
if (!enough_lines)
break;
#if HAVE_MMX
updateMMXDitherTables(c, dstY, lumBufIndex, chrBufIndex, lastInLumBuf, lastInChrBuf);
#endif
if (dstY >= dstH-2) {
find_c_packed_planar_out_funcs(c, &yuv2yuv1, &yuv2yuvX,
&yuv2packed1, &yuv2packed2,
&yuv2packedX);
}
{
const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
const int16_t **chrUSrcPtr= (const int16_t **) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
const int16_t **chrVSrcPtr= (const int16_t **) chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) {
const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL;
if (c->yuv2yuv1 && vLumFilterSize == 1 && vChrFilterSize == 1) {
const int16_t *lumBuf = lumSrcPtr[0];
const int16_t *chrUBuf= chrUSrcPtr[0];
const int16_t *chrVBuf= chrVSrcPtr[0];
const int16_t *alpBuf= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpSrcPtr[0] : NULL;
yuv2yuv1(c, lumBuf, chrUBuf, chrVBuf, alpBuf, dest,
uDest, vDest, aDest, dstW, chrDstW);
} else {
yuv2yuvX(c,
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+chrDstY*vChrFilterSize, chrUSrcPtr,
chrVSrcPtr, vChrFilterSize,
alpSrcPtr, dest, uDest, vDest, aDest, dstW, chrDstW);
}
} else {
assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2);
assert(chrUSrcPtr + vChrFilterSize - 1 < chrUPixBuf + vChrBufSize*2);
if (c->yuv2packed1 && vLumFilterSize == 1 && vChrFilterSize == 2) {
int chrAlpha= vChrFilter[2*dstY+1];
yuv2packed1(c, *lumSrcPtr, *chrUSrcPtr, *(chrUSrcPtr+1),
*chrVSrcPtr, *(chrVSrcPtr+1),
alpPixBuf ? *alpSrcPtr : NULL,
dest, dstW, chrAlpha, dstFormat, flags, dstY);
} else if (c->yuv2packed2 && vLumFilterSize == 2 && vChrFilterSize == 2) {
int lumAlpha= vLumFilter[2*dstY+1];
int chrAlpha= vChrFilter[2*dstY+1];
lumMmxFilter[2]=
lumMmxFilter[3]= vLumFilter[2*dstY ]*0x10001;
chrMmxFilter[2]=
chrMmxFilter[3]= vChrFilter[2*chrDstY]*0x10001;
yuv2packed2(c, *lumSrcPtr, *(lumSrcPtr+1), *chrUSrcPtr, *(chrUSrcPtr+1),
*chrVSrcPtr, *(chrVSrcPtr+1),
alpPixBuf ? *alpSrcPtr : NULL, alpPixBuf ? *(alpSrcPtr+1) : NULL,
dest, dstW, lumAlpha, chrAlpha, dstY);
} else {
yuv2packedX(c,
vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize,
alpSrcPtr, dest, dstW, dstY);
}
}
}
}
if ((dstFormat == PIX_FMT_YUVA420P) && !alpPixBuf)
fillPlane(dst[3], dstStride[3], dstW, dstY-lastDstY, lastDstY, 255);
#if HAVE_MMX2
if (av_get_cpu_flags() & AV_CPU_FLAG_MMX2)
__asm__ volatile("sfence":::"memory");
#endif
emms_c();
c->dstY= dstY;
c->lumBufIndex= lumBufIndex;
c->chrBufIndex= chrBufIndex;
c->lastInLumBuf= lastInLumBuf;
c->lastInChrBuf= lastInChrBuf;
return dstY - lastDstY;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(SwsContext *VAR_0, const uint8_t* VAR_1[],
int VAR_2[], int VAR_3,
int VAR_4, uint8_t* VAR_5[], int VAR_6[])
{
const int VAR_7= VAR_0->VAR_7;
const int VAR_8= VAR_0->VAR_8;
const int VAR_9= VAR_0->VAR_9;
const int VAR_10= VAR_0->VAR_10;
const int VAR_11= VAR_0->VAR_11;
const int VAR_12= VAR_0->VAR_12;
const int VAR_13= VAR_0->VAR_13;
const enum PixelFormat VAR_14= VAR_0->VAR_14;
const int VAR_15= VAR_0->VAR_15;
int16_t *vLumFilterPos= VAR_0->vLumFilterPos;
int16_t *vChrFilterPos= VAR_0->vChrFilterPos;
int16_t *hLumFilterPos= VAR_0->hLumFilterPos;
int16_t *hChrFilterPos= VAR_0->hChrFilterPos;
int16_t *vLumFilter= VAR_0->vLumFilter;
int16_t *vChrFilter= VAR_0->vChrFilter;
int16_t *hLumFilter= VAR_0->hLumFilter;
int16_t *hChrFilter= VAR_0->hChrFilter;
int32_t *lumMmxFilter= VAR_0->lumMmxFilter;
int32_t *chrMmxFilter= VAR_0->chrMmxFilter;
int32_t av_unused *alpMmxFilter= VAR_0->alpMmxFilter;
const int VAR_16= VAR_0->VAR_16;
const int VAR_17= VAR_0->VAR_17;
const int VAR_18= VAR_0->VAR_18;
const int VAR_19= VAR_0->VAR_19;
int16_t **lumPixBuf= VAR_0->lumPixBuf;
int16_t **chrUPixBuf= VAR_0->chrUPixBuf;
int16_t **chrVPixBuf= VAR_0->chrVPixBuf;
int16_t **alpPixBuf= VAR_0->alpPixBuf;
const int VAR_20= VAR_0->VAR_20;
const int VAR_21= VAR_0->VAR_21;
uint8_t *formatConvBuffer= VAR_0->formatConvBuffer;
const int VAR_22= VAR_3 >> VAR_0->chrSrcVSubSample;
const int VAR_23= -((-VAR_4) >> VAR_0->chrSrcVSubSample);
int VAR_24;
uint32_t *pal=VAR_0->pal_yuv;
yuv2planar1_fn yuv2yuv1 = VAR_0->yuv2yuv1;
yuv2planarX_fn yuv2yuvX = VAR_0->yuv2yuvX;
yuv2packed1_fn yuv2packed1 = VAR_0->yuv2packed1;
yuv2packed2_fn yuv2packed2 = VAR_0->yuv2packed2;
yuv2packedX_fn yuv2packedX = VAR_0->yuv2packedX;
int VAR_25= VAR_0->VAR_25;
int VAR_26= VAR_0->VAR_26;
int VAR_27= VAR_0->VAR_27;
int VAR_28= VAR_0->VAR_28;
int VAR_29= VAR_0->VAR_29;
if (isPacked(VAR_0->srcFormat)) {
VAR_1[0]=
VAR_1[1]=
VAR_1[2]=
VAR_1[3]= VAR_1[0];
VAR_2[0]=
VAR_2[1]=
VAR_2[2]=
VAR_2[3]= VAR_2[0];
}
VAR_2[1]<<= VAR_0->vChrDrop;
VAR_2[2]<<= VAR_0->vChrDrop;
DEBUG_BUFFERS("FUNC_0() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\n",
VAR_1[0], VAR_2[0], VAR_1[1], VAR_2[1], VAR_1[2], VAR_2[2], VAR_1[3], VAR_2[3],
VAR_5[0], VAR_6[0], VAR_5[1], VAR_6[1], VAR_5[2], VAR_6[2], VAR_5[3], VAR_6[3]);
DEBUG_BUFFERS("VAR_3: %d VAR_4: %d VAR_25: %d VAR_9: %d\n",
VAR_3, VAR_4, VAR_25, VAR_9);
DEBUG_BUFFERS("VAR_16: %d VAR_20: %d VAR_17: %d VAR_21: %d\n",
VAR_16, VAR_20, VAR_17, VAR_21);
if (VAR_6[0]%8 !=0 || VAR_6[1]%8 !=0 || VAR_6[2]%8 !=0 || VAR_6[3]%8 != 0) {
static int VAR_30=0;
if (VAR_15 & SWS_PRINT_INFO && !VAR_30) {
av_log(VAR_0, AV_LOG_WARNING, "Warning: VAR_6 is not aligned!\n"
" ->cannot do aligned memory accesses anymore\n");
VAR_30=1;
}
}
if (VAR_3 ==0) {
VAR_26=-1;
VAR_27=-1;
VAR_25=0;
VAR_28= -1;
VAR_29= -1;
}
VAR_24= VAR_25;
for (;VAR_25 < VAR_9; VAR_25++) {
unsigned char *VAR_31 =VAR_5[0]+VAR_6[0]*VAR_25;
const int VAR_32= VAR_25>>VAR_0->chrDstVSubSample;
unsigned char *VAR_33=VAR_5[1]+VAR_6[1]*VAR_32;
unsigned char *VAR_34=VAR_5[2]+VAR_6[2]*VAR_32;
unsigned char *VAR_35=(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? VAR_5[3]+VAR_6[3]*VAR_25 : NULL;
const int VAR_36= vLumFilterPos[VAR_25];
const int VAR_37= vLumFilterPos[FFMIN(VAR_25 | ((1<<VAR_0->chrDstVSubSample) - 1), VAR_9-1)];
const int VAR_38= vChrFilterPos[VAR_32];
int VAR_39= VAR_36 + VAR_16 -1;
int VAR_40=VAR_37+ VAR_16 -1;
int VAR_41= VAR_38 + VAR_17 -1;
int VAR_42;
if (VAR_36 > VAR_28) VAR_28= VAR_36-1;
if (VAR_38 > VAR_29) VAR_29= VAR_38-1;
assert(VAR_36 >= VAR_28 - VAR_20 + 1);
assert(VAR_38 >= VAR_29 - VAR_21 + 1);
DEBUG_BUFFERS("VAR_25: %d\n", VAR_25);
DEBUG_BUFFERS("\tfirstLumSrcY: %d VAR_39: %d VAR_28: %d\n",
VAR_36, VAR_39, VAR_28);
DEBUG_BUFFERS("\tfirstChrSrcY: %d VAR_41: %d VAR_29: %d\n",
VAR_38, VAR_41, VAR_29);
VAR_42 = VAR_40 < VAR_3 + VAR_4 && VAR_41 < -((-VAR_3 - VAR_4)>>VAR_0->chrSrcVSubSample);
if (!VAR_42) {
VAR_39 = VAR_3 + VAR_4 - 1;
VAR_41 = VAR_22 + VAR_23 - 1;
DEBUG_BUFFERS("buffering slice: VAR_39 %d VAR_41 %d\n",
VAR_39, VAR_41);
}
while(VAR_28 < VAR_39) {
const uint8_t *VAR_45= VAR_1[0]+(VAR_28 + 1 - VAR_3)*VAR_2[0];
const uint8_t *VAR_45= VAR_1[3]+(VAR_28 + 1 - VAR_3)*VAR_2[3];
VAR_26++;
assert(VAR_26 < 2*VAR_20);
assert(VAR_28 + 1 - VAR_3 < VAR_4);
assert(VAR_28 + 1 - VAR_3 >= 0);
hyscale(VAR_0, lumPixBuf[ VAR_26 ], VAR_8, VAR_45, VAR_7, VAR_12,
hLumFilter, hLumFilterPos, VAR_18,
formatConvBuffer,
pal, 0);
if (CONFIG_SWSCALE_ALPHA && alpPixBuf)
hyscale(VAR_0, alpPixBuf[ VAR_26 ], VAR_8, VAR_45, VAR_7,
VAR_12, hLumFilter, hLumFilterPos, VAR_18,
formatConvBuffer,
pal, 1);
VAR_28++;
DEBUG_BUFFERS("\t\tlumBufIndex %d: VAR_28: %d\n",
VAR_26, VAR_28);
}
while(VAR_29 < VAR_41) {
const uint8_t *VAR_45= VAR_1[1]+(VAR_29 + 1 - VAR_22)*VAR_2[1];
const uint8_t *VAR_45= VAR_1[2]+(VAR_29 + 1 - VAR_22)*VAR_2[2];
VAR_27++;
assert(VAR_27 < 2*VAR_21);
assert(VAR_29 + 1 - VAR_22 < (VAR_23));
assert(VAR_29 + 1 - VAR_22 >= 0);
if (VAR_0->needs_hcscale)
hcscale(VAR_0, chrUPixBuf[VAR_27], chrVPixBuf[VAR_27],
VAR_10, VAR_45, VAR_45, VAR_11, VAR_13,
hChrFilter, hChrFilterPos, VAR_19,
formatConvBuffer, pal);
VAR_29++;
DEBUG_BUFFERS("\t\tchrBufIndex %d: VAR_29: %d\n",
VAR_27, VAR_29);
}
if (VAR_26 >= VAR_20) VAR_26-= VAR_20;
if (VAR_27 >= VAR_21) VAR_27-= VAR_21;
if (!VAR_42)
break;
#if HAVE_MMX
updateMMXDitherTables(VAR_0, VAR_25, VAR_26, VAR_27, VAR_28, VAR_29);
#endif
if (VAR_25 >= VAR_9-2) {
find_c_packed_planar_out_funcs(VAR_0, &yuv2yuv1, &yuv2yuvX,
&yuv2packed1, &yuv2packed2,
&yuv2packedX);
}
{
const int16_t **VAR_45= (const int16_t **) lumPixBuf + VAR_26 + VAR_36 - VAR_28 + VAR_20;
const int16_t **VAR_46= (const int16_t **) chrUPixBuf + VAR_27 + VAR_38 - VAR_29 + VAR_21;
const int16_t **VAR_47= (const int16_t **) chrVPixBuf + VAR_27 + VAR_38 - VAR_29 + VAR_21;
const int16_t **VAR_48= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + VAR_26 + VAR_36 - VAR_28 + VAR_20 : NULL;
if (isPlanarYUV(VAR_14) || VAR_14==PIX_FMT_GRAY8) {
const int VAR_49= (1<<VAR_0->chrDstVSubSample)-1;
if ((VAR_25&VAR_49) || isGray(VAR_14)) VAR_33=VAR_34= NULL;
if (VAR_0->yuv2yuv1 && VAR_16 == 1 && VAR_17 == 1) {
const int16_t *VAR_50 = VAR_45[0];
const int16_t *VAR_51= VAR_46[0];
const int16_t *VAR_52= VAR_47[0];
const int16_t *VAR_53= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? VAR_48[0] : NULL;
yuv2yuv1(VAR_0, VAR_50, VAR_51, VAR_52, VAR_53, VAR_31,
VAR_33, VAR_34, VAR_35, VAR_8, VAR_10);
} else {
yuv2yuvX(VAR_0,
vLumFilter+VAR_25*VAR_16 , VAR_45, VAR_16,
vChrFilter+VAR_32*VAR_17, VAR_46,
VAR_47, VAR_17,
VAR_48, VAR_31, VAR_33, VAR_34, VAR_35, VAR_8, VAR_10);
}
} else {
assert(VAR_45 + VAR_16 - 1 < lumPixBuf + VAR_20*2);
assert(VAR_46 + VAR_17 - 1 < chrUPixBuf + VAR_21*2);
if (VAR_0->yuv2packed1 && VAR_16 == 1 && VAR_17 == 2) {
int VAR_56= vChrFilter[2*VAR_25+1];
yuv2packed1(VAR_0, *VAR_45, *VAR_46, *(VAR_46+1),
*VAR_47, *(VAR_47+1),
alpPixBuf ? *VAR_48 : NULL,
VAR_31, VAR_8, VAR_56, VAR_14, VAR_15, VAR_25);
} else if (VAR_0->yuv2packed2 && VAR_16 == 2 && VAR_17 == 2) {
int VAR_55= vLumFilter[2*VAR_25+1];
int VAR_56= vChrFilter[2*VAR_25+1];
lumMmxFilter[2]=
lumMmxFilter[3]= vLumFilter[2*VAR_25 ]*0x10001;
chrMmxFilter[2]=
chrMmxFilter[3]= vChrFilter[2*VAR_32]*0x10001;
yuv2packed2(VAR_0, *VAR_45, *(VAR_45+1), *VAR_46, *(VAR_46+1),
*VAR_47, *(VAR_47+1),
alpPixBuf ? *VAR_48 : NULL, alpPixBuf ? *(VAR_48+1) : NULL,
VAR_31, VAR_8, VAR_55, VAR_56, VAR_25);
} else {
yuv2packedX(VAR_0,
vLumFilter+VAR_25*VAR_16, VAR_45, VAR_16,
vChrFilter+VAR_25*VAR_17, VAR_46, VAR_47, VAR_17,
VAR_48, VAR_31, VAR_8, VAR_25);
}
}
}
}
if ((VAR_14 == PIX_FMT_YUVA420P) && !alpPixBuf)
fillPlane(VAR_5[3], VAR_6[3], VAR_8, VAR_25-VAR_24, VAR_24, 255);
#if HAVE_MMX2
if (av_get_cpu_flags() & AV_CPU_FLAG_MMX2)
__asm__ volatile("sfence":::"memory");
#endif
emms_c();
VAR_0->VAR_25= VAR_25;
VAR_0->VAR_26= VAR_26;
VAR_0->VAR_27= VAR_27;
VAR_0->VAR_28= VAR_28;
VAR_0->VAR_29= VAR_29;
return VAR_25 - VAR_24;
}
| [
"static int FUNC_0(SwsContext *VAR_0, const uint8_t* VAR_1[],\nint VAR_2[], int VAR_3,\nint VAR_4, uint8_t* VAR_5[], int VAR_6[])\n{",
"const int VAR_7= VAR_0->VAR_7;",
"const int VAR_8= VAR_0->VAR_8;",
"const int VAR_9= VAR_0->VAR_9;",
"const int VAR_10= VAR_0->VAR_10;",
"const int VAR_11= VAR_0->VAR_11;",
"const int VAR_12= VAR_0->VAR_12;",
"const int VAR_13= VAR_0->VAR_13;",
"const enum PixelFormat VAR_14= VAR_0->VAR_14;",
"const int VAR_15= VAR_0->VAR_15;",
"int16_t *vLumFilterPos= VAR_0->vLumFilterPos;",
"int16_t *vChrFilterPos= VAR_0->vChrFilterPos;",
"int16_t *hLumFilterPos= VAR_0->hLumFilterPos;",
"int16_t *hChrFilterPos= VAR_0->hChrFilterPos;",
"int16_t *vLumFilter= VAR_0->vLumFilter;",
"int16_t *vChrFilter= VAR_0->vChrFilter;",
"int16_t *hLumFilter= VAR_0->hLumFilter;",
"int16_t *hChrFilter= VAR_0->hChrFilter;",
"int32_t *lumMmxFilter= VAR_0->lumMmxFilter;",
"int32_t *chrMmxFilter= VAR_0->chrMmxFilter;",
"int32_t av_unused *alpMmxFilter= VAR_0->alpMmxFilter;",
"const int VAR_16= VAR_0->VAR_16;",
"const int VAR_17= VAR_0->VAR_17;",
"const int VAR_18= VAR_0->VAR_18;",
"const int VAR_19= VAR_0->VAR_19;",
"int16_t **lumPixBuf= VAR_0->lumPixBuf;",
"int16_t **chrUPixBuf= VAR_0->chrUPixBuf;",
"int16_t **chrVPixBuf= VAR_0->chrVPixBuf;",
"int16_t **alpPixBuf= VAR_0->alpPixBuf;",
"const int VAR_20= VAR_0->VAR_20;",
"const int VAR_21= VAR_0->VAR_21;",
"uint8_t *formatConvBuffer= VAR_0->formatConvBuffer;",
"const int VAR_22= VAR_3 >> VAR_0->chrSrcVSubSample;",
"const int VAR_23= -((-VAR_4) >> VAR_0->chrSrcVSubSample);",
"int VAR_24;",
"uint32_t *pal=VAR_0->pal_yuv;",
"yuv2planar1_fn yuv2yuv1 = VAR_0->yuv2yuv1;",
"yuv2planarX_fn yuv2yuvX = VAR_0->yuv2yuvX;",
"yuv2packed1_fn yuv2packed1 = VAR_0->yuv2packed1;",
"yuv2packed2_fn yuv2packed2 = VAR_0->yuv2packed2;",
"yuv2packedX_fn yuv2packedX = VAR_0->yuv2packedX;",
"int VAR_25= VAR_0->VAR_25;",
"int VAR_26= VAR_0->VAR_26;",
"int VAR_27= VAR_0->VAR_27;",
"int VAR_28= VAR_0->VAR_28;",
"int VAR_29= VAR_0->VAR_29;",
"if (isPacked(VAR_0->srcFormat)) {",
"VAR_1[0]=\nVAR_1[1]=\nVAR_1[2]=\nVAR_1[3]= VAR_1[0];",
"VAR_2[0]=\nVAR_2[1]=\nVAR_2[2]=\nVAR_2[3]= VAR_2[0];",
"}",
"VAR_2[1]<<= VAR_0->vChrDrop;",
"VAR_2[2]<<= VAR_0->vChrDrop;",
"DEBUG_BUFFERS(\"FUNC_0() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\\n\",\nVAR_1[0], VAR_2[0], VAR_1[1], VAR_2[1], VAR_1[2], VAR_2[2], VAR_1[3], VAR_2[3],\nVAR_5[0], VAR_6[0], VAR_5[1], VAR_6[1], VAR_5[2], VAR_6[2], VAR_5[3], VAR_6[3]);",
"DEBUG_BUFFERS(\"VAR_3: %d VAR_4: %d VAR_25: %d VAR_9: %d\\n\",\nVAR_3, VAR_4, VAR_25, VAR_9);",
"DEBUG_BUFFERS(\"VAR_16: %d VAR_20: %d VAR_17: %d VAR_21: %d\\n\",\nVAR_16, VAR_20, VAR_17, VAR_21);",
"if (VAR_6[0]%8 !=0 || VAR_6[1]%8 !=0 || VAR_6[2]%8 !=0 || VAR_6[3]%8 != 0) {",
"static int VAR_30=0;",
"if (VAR_15 & SWS_PRINT_INFO && !VAR_30) {",
"av_log(VAR_0, AV_LOG_WARNING, \"Warning: VAR_6 is not aligned!\\n\"\n\" ->cannot do aligned memory accesses anymore\\n\");",
"VAR_30=1;",
"}",
"}",
"if (VAR_3 ==0) {",
"VAR_26=-1;",
"VAR_27=-1;",
"VAR_25=0;",
"VAR_28= -1;",
"VAR_29= -1;",
"}",
"VAR_24= VAR_25;",
"for (;VAR_25 < VAR_9; VAR_25++) {",
"unsigned char *VAR_31 =VAR_5[0]+VAR_6[0]*VAR_25;",
"const int VAR_32= VAR_25>>VAR_0->chrDstVSubSample;",
"unsigned char *VAR_33=VAR_5[1]+VAR_6[1]*VAR_32;",
"unsigned char *VAR_34=VAR_5[2]+VAR_6[2]*VAR_32;",
"unsigned char *VAR_35=(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? VAR_5[3]+VAR_6[3]*VAR_25 : NULL;",
"const int VAR_36= vLumFilterPos[VAR_25];",
"const int VAR_37= vLumFilterPos[FFMIN(VAR_25 | ((1<<VAR_0->chrDstVSubSample) - 1), VAR_9-1)];",
"const int VAR_38= vChrFilterPos[VAR_32];",
"int VAR_39= VAR_36 + VAR_16 -1;",
"int VAR_40=VAR_37+ VAR_16 -1;",
"int VAR_41= VAR_38 + VAR_17 -1;",
"int VAR_42;",
"if (VAR_36 > VAR_28) VAR_28= VAR_36-1;",
"if (VAR_38 > VAR_29) VAR_29= VAR_38-1;",
"assert(VAR_36 >= VAR_28 - VAR_20 + 1);",
"assert(VAR_38 >= VAR_29 - VAR_21 + 1);",
"DEBUG_BUFFERS(\"VAR_25: %d\\n\", VAR_25);",
"DEBUG_BUFFERS(\"\\tfirstLumSrcY: %d VAR_39: %d VAR_28: %d\\n\",\nVAR_36, VAR_39, VAR_28);",
"DEBUG_BUFFERS(\"\\tfirstChrSrcY: %d VAR_41: %d VAR_29: %d\\n\",\nVAR_38, VAR_41, VAR_29);",
"VAR_42 = VAR_40 < VAR_3 + VAR_4 && VAR_41 < -((-VAR_3 - VAR_4)>>VAR_0->chrSrcVSubSample);",
"if (!VAR_42) {",
"VAR_39 = VAR_3 + VAR_4 - 1;",
"VAR_41 = VAR_22 + VAR_23 - 1;",
"DEBUG_BUFFERS(\"buffering slice: VAR_39 %d VAR_41 %d\\n\",\nVAR_39, VAR_41);",
"}",
"while(VAR_28 < VAR_39) {",
"const uint8_t *VAR_45= VAR_1[0]+(VAR_28 + 1 - VAR_3)*VAR_2[0];",
"const uint8_t *VAR_45= VAR_1[3]+(VAR_28 + 1 - VAR_3)*VAR_2[3];",
"VAR_26++;",
"assert(VAR_26 < 2*VAR_20);",
"assert(VAR_28 + 1 - VAR_3 < VAR_4);",
"assert(VAR_28 + 1 - VAR_3 >= 0);",
"hyscale(VAR_0, lumPixBuf[ VAR_26 ], VAR_8, VAR_45, VAR_7, VAR_12,\nhLumFilter, hLumFilterPos, VAR_18,\nformatConvBuffer,\npal, 0);",
"if (CONFIG_SWSCALE_ALPHA && alpPixBuf)\nhyscale(VAR_0, alpPixBuf[ VAR_26 ], VAR_8, VAR_45, VAR_7,\nVAR_12, hLumFilter, hLumFilterPos, VAR_18,\nformatConvBuffer,\npal, 1);",
"VAR_28++;",
"DEBUG_BUFFERS(\"\\t\\tlumBufIndex %d: VAR_28: %d\\n\",\nVAR_26, VAR_28);",
"}",
"while(VAR_29 < VAR_41) {",
"const uint8_t *VAR_45= VAR_1[1]+(VAR_29 + 1 - VAR_22)*VAR_2[1];",
"const uint8_t *VAR_45= VAR_1[2]+(VAR_29 + 1 - VAR_22)*VAR_2[2];",
"VAR_27++;",
"assert(VAR_27 < 2*VAR_21);",
"assert(VAR_29 + 1 - VAR_22 < (VAR_23));",
"assert(VAR_29 + 1 - VAR_22 >= 0);",
"if (VAR_0->needs_hcscale)\nhcscale(VAR_0, chrUPixBuf[VAR_27], chrVPixBuf[VAR_27],\nVAR_10, VAR_45, VAR_45, VAR_11, VAR_13,\nhChrFilter, hChrFilterPos, VAR_19,\nformatConvBuffer, pal);",
"VAR_29++;",
"DEBUG_BUFFERS(\"\\t\\tchrBufIndex %d: VAR_29: %d\\n\",\nVAR_27, VAR_29);",
"}",
"if (VAR_26 >= VAR_20) VAR_26-= VAR_20;",
"if (VAR_27 >= VAR_21) VAR_27-= VAR_21;",
"if (!VAR_42)\nbreak;",
"#if HAVE_MMX\nupdateMMXDitherTables(VAR_0, VAR_25, VAR_26, VAR_27, VAR_28, VAR_29);",
"#endif\nif (VAR_25 >= VAR_9-2) {",
"find_c_packed_planar_out_funcs(VAR_0, &yuv2yuv1, &yuv2yuvX,\n&yuv2packed1, &yuv2packed2,\n&yuv2packedX);",
"}",
"{",
"const int16_t **VAR_45= (const int16_t **) lumPixBuf + VAR_26 + VAR_36 - VAR_28 + VAR_20;",
"const int16_t **VAR_46= (const int16_t **) chrUPixBuf + VAR_27 + VAR_38 - VAR_29 + VAR_21;",
"const int16_t **VAR_47= (const int16_t **) chrVPixBuf + VAR_27 + VAR_38 - VAR_29 + VAR_21;",
"const int16_t **VAR_48= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + VAR_26 + VAR_36 - VAR_28 + VAR_20 : NULL;",
"if (isPlanarYUV(VAR_14) || VAR_14==PIX_FMT_GRAY8) {",
"const int VAR_49= (1<<VAR_0->chrDstVSubSample)-1;",
"if ((VAR_25&VAR_49) || isGray(VAR_14)) VAR_33=VAR_34= NULL;",
"if (VAR_0->yuv2yuv1 && VAR_16 == 1 && VAR_17 == 1) {",
"const int16_t *VAR_50 = VAR_45[0];",
"const int16_t *VAR_51= VAR_46[0];",
"const int16_t *VAR_52= VAR_47[0];",
"const int16_t *VAR_53= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? VAR_48[0] : NULL;",
"yuv2yuv1(VAR_0, VAR_50, VAR_51, VAR_52, VAR_53, VAR_31,\nVAR_33, VAR_34, VAR_35, VAR_8, VAR_10);",
"} else {",
"yuv2yuvX(VAR_0,\nvLumFilter+VAR_25*VAR_16 , VAR_45, VAR_16,\nvChrFilter+VAR_32*VAR_17, VAR_46,\nVAR_47, VAR_17,\nVAR_48, VAR_31, VAR_33, VAR_34, VAR_35, VAR_8, VAR_10);",
"}",
"} else {",
"assert(VAR_45 + VAR_16 - 1 < lumPixBuf + VAR_20*2);",
"assert(VAR_46 + VAR_17 - 1 < chrUPixBuf + VAR_21*2);",
"if (VAR_0->yuv2packed1 && VAR_16 == 1 && VAR_17 == 2) {",
"int VAR_56= vChrFilter[2*VAR_25+1];",
"yuv2packed1(VAR_0, *VAR_45, *VAR_46, *(VAR_46+1),\n*VAR_47, *(VAR_47+1),\nalpPixBuf ? *VAR_48 : NULL,\nVAR_31, VAR_8, VAR_56, VAR_14, VAR_15, VAR_25);",
"} else if (VAR_0->yuv2packed2 && VAR_16 == 2 && VAR_17 == 2) {",
"int VAR_55= vLumFilter[2*VAR_25+1];",
"int VAR_56= vChrFilter[2*VAR_25+1];",
"lumMmxFilter[2]=\nlumMmxFilter[3]= vLumFilter[2*VAR_25 ]*0x10001;",
"chrMmxFilter[2]=\nchrMmxFilter[3]= vChrFilter[2*VAR_32]*0x10001;",
"yuv2packed2(VAR_0, *VAR_45, *(VAR_45+1), *VAR_46, *(VAR_46+1),\n*VAR_47, *(VAR_47+1),\nalpPixBuf ? *VAR_48 : NULL, alpPixBuf ? *(VAR_48+1) : NULL,\nVAR_31, VAR_8, VAR_55, VAR_56, VAR_25);",
"} else {",
"yuv2packedX(VAR_0,\nvLumFilter+VAR_25*VAR_16, VAR_45, VAR_16,\nvChrFilter+VAR_25*VAR_17, VAR_46, VAR_47, VAR_17,\nVAR_48, VAR_31, VAR_8, VAR_25);",
"}",
"}",
"}",
"}",
"if ((VAR_14 == PIX_FMT_YUVA420P) && !alpPixBuf)\nfillPlane(VAR_5[3], VAR_6[3], VAR_8, VAR_25-VAR_24, VAR_24, 255);",
"#if HAVE_MMX2\nif (av_get_cpu_flags() & AV_CPU_FLAG_MMX2)\n__asm__ volatile(\"sfence\":::\"memory\");",
"#endif\nemms_c();",
"VAR_0->VAR_25= VAR_25;",
"VAR_0->VAR_26= VAR_26;",
"VAR_0->VAR_27= VAR_27;",
"VAR_0->VAR_28= VAR_28;",
"VAR_0->VAR_29= VAR_29;",
"return VAR_25 - VAR_24;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
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
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109,
111,
113,
115
],
[
117,
119,
121,
123
],
[
125
],
[
127
],
[
129
],
[
133,
135,
137
],
[
139,
141
],
[
143,
145
],
[
149
],
[
151
],
[
153
],
[
155,
157
],
[
159
],
[
161
],
[
163
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
189
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
225
],
[
227
],
[
229
],
[
231
],
[
235
],
[
237,
239
],
[
241,
243
],
[
249
],
[
253
],
[
255
],
[
257
],
[
259,
261
],
[
263
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283,
285,
287,
289
],
[
291,
293,
295,
297,
299
],
[
301
],
[
303,
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
327,
329,
331,
333,
335
],
[
337
],
[
339,
341
],
[
343
],
[
347
],
[
349
],
[
351,
353
],
[
357,
359
],
[
361,
363
],
[
367,
369,
371
],
[
373
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403,
405
],
[
407
],
[
409,
411,
413,
415,
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431,
433,
435,
437
],
[
439
],
[
441
],
[
443
],
[
445,
447
],
[
449,
451
],
[
453,
455,
457,
459
],
[
461
],
[
463,
465,
467,
469
],
[
471
],
[
473
],
[
475
],
[
477
],
[
481,
483
],
[
487,
489,
491
],
[
493,
495
],
[
501
],
[
503
],
[
505
],
[
507
],
[
509
],
[
513
],
[
515
]
] |
24,915 | int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
int srcRange, const int table[4], int dstRange,
int brightness, int contrast, int saturation)
{
const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->dstFormat);
const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(c->srcFormat);
memcpy(c->srcColorspaceTable, inv_table, sizeof(int) * 4);
memcpy(c->dstColorspaceTable, table, sizeof(int) * 4);
c->brightness = brightness;
c->contrast = contrast;
c->saturation = saturation;
c->srcRange = srcRange;
c->dstRange = dstRange;
if (isYUV(c->dstFormat) || isGray(c->dstFormat))
return -1;
c->dstFormatBpp = av_get_bits_per_pixel(desc_dst);
c->srcFormatBpp = av_get_bits_per_pixel(desc_src);
ff_yuv2rgb_c_init_tables(c, inv_table, srcRange, brightness,
contrast, saturation);
// FIXME factorize
if (HAVE_ALTIVEC && av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)
ff_yuv2rgb_init_tables_altivec(c, inv_table, brightness,
contrast, saturation);
return 0;
}
| false | FFmpeg | f61bece684d9685b07895508e6c1c733b5564ccf | int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
int srcRange, const int table[4], int dstRange,
int brightness, int contrast, int saturation)
{
const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->dstFormat);
const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(c->srcFormat);
memcpy(c->srcColorspaceTable, inv_table, sizeof(int) * 4);
memcpy(c->dstColorspaceTable, table, sizeof(int) * 4);
c->brightness = brightness;
c->contrast = contrast;
c->saturation = saturation;
c->srcRange = srcRange;
c->dstRange = dstRange;
if (isYUV(c->dstFormat) || isGray(c->dstFormat))
return -1;
c->dstFormatBpp = av_get_bits_per_pixel(desc_dst);
c->srcFormatBpp = av_get_bits_per_pixel(desc_src);
ff_yuv2rgb_c_init_tables(c, inv_table, srcRange, brightness,
contrast, saturation);
if (HAVE_ALTIVEC && av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)
ff_yuv2rgb_init_tables_altivec(c, inv_table, brightness,
contrast, saturation);
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(struct SwsContext *VAR_0, const int VAR_1[4],
int VAR_2, const int VAR_3[4], int VAR_4,
int VAR_5, int VAR_6, int VAR_7)
{
const AVPixFmtDescriptor *VAR_8 = av_pix_fmt_desc_get(VAR_0->dstFormat);
const AVPixFmtDescriptor *VAR_9 = av_pix_fmt_desc_get(VAR_0->srcFormat);
memcpy(VAR_0->srcColorspaceTable, VAR_1, sizeof(int) * 4);
memcpy(VAR_0->dstColorspaceTable, VAR_3, sizeof(int) * 4);
VAR_0->VAR_5 = VAR_5;
VAR_0->VAR_6 = VAR_6;
VAR_0->VAR_7 = VAR_7;
VAR_0->VAR_2 = VAR_2;
VAR_0->VAR_4 = VAR_4;
if (isYUV(VAR_0->dstFormat) || isGray(VAR_0->dstFormat))
return -1;
VAR_0->dstFormatBpp = av_get_bits_per_pixel(VAR_8);
VAR_0->srcFormatBpp = av_get_bits_per_pixel(VAR_9);
ff_yuv2rgb_c_init_tables(VAR_0, VAR_1, VAR_2, VAR_5,
VAR_6, VAR_7);
if (HAVE_ALTIVEC && av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)
ff_yuv2rgb_init_tables_altivec(VAR_0, VAR_1, VAR_5,
VAR_6, VAR_7);
return 0;
}
| [
"int FUNC_0(struct SwsContext *VAR_0, const int VAR_1[4],\nint VAR_2, const int VAR_3[4], int VAR_4,\nint VAR_5, int VAR_6, int VAR_7)\n{",
"const AVPixFmtDescriptor *VAR_8 = av_pix_fmt_desc_get(VAR_0->dstFormat);",
"const AVPixFmtDescriptor *VAR_9 = av_pix_fmt_desc_get(VAR_0->srcFormat);",
"memcpy(VAR_0->srcColorspaceTable, VAR_1, sizeof(int) * 4);",
"memcpy(VAR_0->dstColorspaceTable, VAR_3, sizeof(int) * 4);",
"VAR_0->VAR_5 = VAR_5;",
"VAR_0->VAR_6 = VAR_6;",
"VAR_0->VAR_7 = VAR_7;",
"VAR_0->VAR_2 = VAR_2;",
"VAR_0->VAR_4 = VAR_4;",
"if (isYUV(VAR_0->dstFormat) || isGray(VAR_0->dstFormat))\nreturn -1;",
"VAR_0->dstFormatBpp = av_get_bits_per_pixel(VAR_8);",
"VAR_0->srcFormatBpp = av_get_bits_per_pixel(VAR_9);",
"ff_yuv2rgb_c_init_tables(VAR_0, VAR_1, VAR_2, VAR_5,\nVAR_6, VAR_7);",
"if (HAVE_ALTIVEC && av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)\nff_yuv2rgb_init_tables_altivec(VAR_0, VAR_1, VAR_5,\nVAR_6, VAR_7);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
31
],
[
35
],
[
37
],
[
41,
43
],
[
49,
51,
53
],
[
55
],
[
57
]
] |
24,916 | static void alpha_cpu_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
CPUClass *cc = CPU_CLASS(oc);
AlphaCPUClass *acc = ALPHA_CPU_CLASS(oc);
acc->parent_realize = dc->realize;
dc->realize = alpha_cpu_realizefn;
cc->class_by_name = alpha_cpu_class_by_name;
cc->has_work = alpha_cpu_has_work;
cc->do_interrupt = alpha_cpu_do_interrupt;
cc->cpu_exec_interrupt = alpha_cpu_exec_interrupt;
cc->dump_state = alpha_cpu_dump_state;
cc->set_pc = alpha_cpu_set_pc;
cc->gdb_read_register = alpha_cpu_gdb_read_register;
cc->gdb_write_register = alpha_cpu_gdb_write_register;
#ifdef CONFIG_USER_ONLY
cc->handle_mmu_fault = alpha_cpu_handle_mmu_fault;
#else
cc->do_unassigned_access = alpha_cpu_unassigned_access;
cc->do_unaligned_access = alpha_cpu_do_unaligned_access;
cc->get_phys_page_debug = alpha_cpu_get_phys_page_debug;
dc->vmsd = &vmstate_alpha_cpu;
#endif
cc->disas_set_info = alpha_cpu_disas_set_info;
cc->gdb_num_core_regs = 67;
/*
* Reason: alpha_cpu_initfn() calls cpu_exec_init(), which saves
* the object in cpus -> dangling pointer after final
* object_unref().
*/
dc->cannot_destroy_with_object_finalize_yet = true;
}
| true | qemu | ce5b1bbf624b977a55ff7f85bb3871682d03baff | static void alpha_cpu_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
CPUClass *cc = CPU_CLASS(oc);
AlphaCPUClass *acc = ALPHA_CPU_CLASS(oc);
acc->parent_realize = dc->realize;
dc->realize = alpha_cpu_realizefn;
cc->class_by_name = alpha_cpu_class_by_name;
cc->has_work = alpha_cpu_has_work;
cc->do_interrupt = alpha_cpu_do_interrupt;
cc->cpu_exec_interrupt = alpha_cpu_exec_interrupt;
cc->dump_state = alpha_cpu_dump_state;
cc->set_pc = alpha_cpu_set_pc;
cc->gdb_read_register = alpha_cpu_gdb_read_register;
cc->gdb_write_register = alpha_cpu_gdb_write_register;
#ifdef CONFIG_USER_ONLY
cc->handle_mmu_fault = alpha_cpu_handle_mmu_fault;
#else
cc->do_unassigned_access = alpha_cpu_unassigned_access;
cc->do_unaligned_access = alpha_cpu_do_unaligned_access;
cc->get_phys_page_debug = alpha_cpu_get_phys_page_debug;
dc->vmsd = &vmstate_alpha_cpu;
#endif
cc->disas_set_info = alpha_cpu_disas_set_info;
cc->gdb_num_core_regs = 67;
dc->cannot_destroy_with_object_finalize_yet = true;
}
| {
"code": [
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;",
" dc->cannot_destroy_with_object_finalize_yet = true;"
],
"line_no": [
69,
69,
69,
69,
69,
69,
69,
69,
69,
69,
69,
69,
69,
69,
69,
69
]
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
CPUClass *cc = CPU_CLASS(VAR_0);
AlphaCPUClass *acc = ALPHA_CPU_CLASS(VAR_0);
acc->parent_realize = dc->realize;
dc->realize = alpha_cpu_realizefn;
cc->class_by_name = alpha_cpu_class_by_name;
cc->has_work = alpha_cpu_has_work;
cc->do_interrupt = alpha_cpu_do_interrupt;
cc->cpu_exec_interrupt = alpha_cpu_exec_interrupt;
cc->dump_state = alpha_cpu_dump_state;
cc->set_pc = alpha_cpu_set_pc;
cc->gdb_read_register = alpha_cpu_gdb_read_register;
cc->gdb_write_register = alpha_cpu_gdb_write_register;
#ifdef CONFIG_USER_ONLY
cc->handle_mmu_fault = alpha_cpu_handle_mmu_fault;
#else
cc->do_unassigned_access = alpha_cpu_unassigned_access;
cc->do_unaligned_access = alpha_cpu_do_unaligned_access;
cc->get_phys_page_debug = alpha_cpu_get_phys_page_debug;
dc->vmsd = &vmstate_alpha_cpu;
#endif
cc->disas_set_info = alpha_cpu_disas_set_info;
cc->gdb_num_core_regs = 67;
dc->cannot_destroy_with_object_finalize_yet = true;
}
| [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"CPUClass *cc = CPU_CLASS(VAR_0);",
"AlphaCPUClass *acc = ALPHA_CPU_CLASS(VAR_0);",
"acc->parent_realize = dc->realize;",
"dc->realize = alpha_cpu_realizefn;",
"cc->class_by_name = alpha_cpu_class_by_name;",
"cc->has_work = alpha_cpu_has_work;",
"cc->do_interrupt = alpha_cpu_do_interrupt;",
"cc->cpu_exec_interrupt = alpha_cpu_exec_interrupt;",
"cc->dump_state = alpha_cpu_dump_state;",
"cc->set_pc = alpha_cpu_set_pc;",
"cc->gdb_read_register = alpha_cpu_gdb_read_register;",
"cc->gdb_write_register = alpha_cpu_gdb_write_register;",
"#ifdef CONFIG_USER_ONLY\ncc->handle_mmu_fault = alpha_cpu_handle_mmu_fault;",
"#else\ncc->do_unassigned_access = alpha_cpu_unassigned_access;",
"cc->do_unaligned_access = alpha_cpu_do_unaligned_access;",
"cc->get_phys_page_debug = alpha_cpu_get_phys_page_debug;",
"dc->vmsd = &vmstate_alpha_cpu;",
"#endif\ncc->disas_set_info = alpha_cpu_disas_set_info;",
"cc->gdb_num_core_regs = 67;",
"dc->cannot_destroy_with_object_finalize_yet = true;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
55
],
[
69
],
[
71
]
] |
24,917 | static void rtas_ibm_write_pci_config(sPAPREnvironment *spapr,
uint32_t token, uint32_t nargs,
target_ulong args,
uint32_t nret, target_ulong rets)
{
uint32_t val, size, addr;
uint64_t buid = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 2);
PCIDevice *dev = find_dev(spapr, buid, rtas_ld(args, 0));
if (!dev) {
rtas_st(rets, 0, -1);
return;
}
val = rtas_ld(args, 4);
size = rtas_ld(args, 3);
addr = rtas_pci_cfgaddr(rtas_ld(args, 0));
pci_default_write_config(dev, addr, val, size);
rtas_st(rets, 0, 0);
}
| true | qemu | c9c3c80af71dd2b7813d1ada9b14cb51df584221 | static void rtas_ibm_write_pci_config(sPAPREnvironment *spapr,
uint32_t token, uint32_t nargs,
target_ulong args,
uint32_t nret, target_ulong rets)
{
uint32_t val, size, addr;
uint64_t buid = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 2);
PCIDevice *dev = find_dev(spapr, buid, rtas_ld(args, 0));
if (!dev) {
rtas_st(rets, 0, -1);
return;
}
val = rtas_ld(args, 4);
size = rtas_ld(args, 3);
addr = rtas_pci_cfgaddr(rtas_ld(args, 0));
pci_default_write_config(dev, addr, val, size);
rtas_st(rets, 0, 0);
}
| {
"code": [
" pci_default_write_config(dev, addr, val, size);",
" pci_default_write_config(dev, addr, val, size);"
],
"line_no": [
33,
33
]
} | static void FUNC_0(sPAPREnvironment *VAR_0,
uint32_t VAR_1, uint32_t VAR_2,
target_ulong VAR_3,
uint32_t VAR_4, target_ulong VAR_5)
{
uint32_t val, size, addr;
uint64_t buid = ((uint64_t)rtas_ld(VAR_3, 1) << 32) | rtas_ld(VAR_3, 2);
PCIDevice *dev = find_dev(VAR_0, buid, rtas_ld(VAR_3, 0));
if (!dev) {
rtas_st(VAR_5, 0, -1);
return;
}
val = rtas_ld(VAR_3, 4);
size = rtas_ld(VAR_3, 3);
addr = rtas_pci_cfgaddr(rtas_ld(VAR_3, 0));
pci_default_write_config(dev, addr, val, size);
rtas_st(VAR_5, 0, 0);
}
| [
"static void FUNC_0(sPAPREnvironment *VAR_0,\nuint32_t VAR_1, uint32_t VAR_2,\ntarget_ulong VAR_3,\nuint32_t VAR_4, target_ulong VAR_5)\n{",
"uint32_t val, size, addr;",
"uint64_t buid = ((uint64_t)rtas_ld(VAR_3, 1) << 32) | rtas_ld(VAR_3, 2);",
"PCIDevice *dev = find_dev(VAR_0, buid, rtas_ld(VAR_3, 0));",
"if (!dev) {",
"rtas_st(VAR_5, 0, -1);",
"return;",
"}",
"val = rtas_ld(VAR_3, 4);",
"size = rtas_ld(VAR_3, 3);",
"addr = rtas_pci_cfgaddr(rtas_ld(VAR_3, 0));",
"pci_default_write_config(dev, addr, val, size);",
"rtas_st(VAR_5, 0, 0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
24,919 | static int submit_stats(AVCodecContext *avctx)
{
#ifdef TH_ENCCTL_2PASS_IN
TheoraContext *h = avctx->priv_data;
int bytes;
if (!avctx->stats_in) {
av_log(avctx, AV_LOG_ERROR, "No statsfile for second pass\n");
return AVERROR(EINVAL);
h->stats_size = strlen(avctx->stats_in) * 3/4;
h->stats = av_malloc(h->stats_size);
h->stats_size = av_base64_decode(h->stats, avctx->stats_in, h->stats_size);
while (h->stats_size - h->stats_offset > 0) {
bytes = th_encode_ctl(h->t_state, TH_ENCCTL_2PASS_IN,
h->stats + h->stats_offset,
h->stats_size - h->stats_offset);
if (bytes < 0) {
av_log(avctx, AV_LOG_ERROR, "Error submitting stats\n");
return AVERROR_EXTERNAL;
if (!bytes)
return 0;
h->stats_offset += bytes;
return 0;
#else
av_log(avctx, AV_LOG_ERROR, "libtheora too old to support 2pass\n");
return AVERROR(ENOSUP);
#endif
| true | FFmpeg | 27216bf314c62125c408be1a5a79e5c9dba88e76 | static int submit_stats(AVCodecContext *avctx)
{
#ifdef TH_ENCCTL_2PASS_IN
TheoraContext *h = avctx->priv_data;
int bytes;
if (!avctx->stats_in) {
av_log(avctx, AV_LOG_ERROR, "No statsfile for second pass\n");
return AVERROR(EINVAL);
h->stats_size = strlen(avctx->stats_in) * 3/4;
h->stats = av_malloc(h->stats_size);
h->stats_size = av_base64_decode(h->stats, avctx->stats_in, h->stats_size);
while (h->stats_size - h->stats_offset > 0) {
bytes = th_encode_ctl(h->t_state, TH_ENCCTL_2PASS_IN,
h->stats + h->stats_offset,
h->stats_size - h->stats_offset);
if (bytes < 0) {
av_log(avctx, AV_LOG_ERROR, "Error submitting stats\n");
return AVERROR_EXTERNAL;
if (!bytes)
return 0;
h->stats_offset += bytes;
return 0;
#else
av_log(avctx, AV_LOG_ERROR, "libtheora too old to support 2pass\n");
return AVERROR(ENOSUP);
#endif
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0)
{
#ifdef TH_ENCCTL_2PASS_IN
TheoraContext *h = VAR_0->priv_data;
int bytes;
if (!VAR_0->stats_in) {
av_log(VAR_0, AV_LOG_ERROR, "No statsfile for second pass\n");
return AVERROR(EINVAL);
h->stats_size = strlen(VAR_0->stats_in) * 3/4;
h->stats = av_malloc(h->stats_size);
h->stats_size = av_base64_decode(h->stats, VAR_0->stats_in, h->stats_size);
while (h->stats_size - h->stats_offset > 0) {
bytes = th_encode_ctl(h->t_state, TH_ENCCTL_2PASS_IN,
h->stats + h->stats_offset,
h->stats_size - h->stats_offset);
if (bytes < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Error submitting stats\n");
return AVERROR_EXTERNAL;
if (!bytes)
return 0;
h->stats_offset += bytes;
return 0;
#else
av_log(VAR_0, AV_LOG_ERROR, "libtheora too old to support 2pass\n");
return AVERROR(ENOSUP);
#endif
| [
"static int FUNC_0(AVCodecContext *VAR_0)\n{",
"#ifdef TH_ENCCTL_2PASS_IN\nTheoraContext *h = VAR_0->priv_data;",
"int bytes;",
"if (!VAR_0->stats_in) {",
"av_log(VAR_0, AV_LOG_ERROR, \"No statsfile for second pass\\n\");",
"return AVERROR(EINVAL);",
"h->stats_size = strlen(VAR_0->stats_in) * 3/4;",
"h->stats = av_malloc(h->stats_size);",
"h->stats_size = av_base64_decode(h->stats, VAR_0->stats_in, h->stats_size);",
"while (h->stats_size - h->stats_offset > 0) {",
"bytes = th_encode_ctl(h->t_state, TH_ENCCTL_2PASS_IN,\nh->stats + h->stats_offset,\nh->stats_size - h->stats_offset);",
"if (bytes < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error submitting stats\\n\");",
"return AVERROR_EXTERNAL;",
"if (!bytes)\nreturn 0;",
"h->stats_offset += bytes;",
"return 0;",
"#else\nav_log(VAR_0, AV_LOG_ERROR, \"libtheora too old to support 2pass\\n\");",
"return AVERROR(ENOSUP);"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
12
],
[
14
],
[
16
],
[
19
],
[
21
],
[
27
],
[
30
],
[
32,
34,
36
],
[
38
],
[
40
],
[
42
],
[
45,
47
],
[
49
],
[
52
],
[
54,
56
],
[
58
]
] |
24,920 | static int encode_plane(AVCodecContext *avctx, uint8_t *src,
uint8_t *dst, int stride,
int width, int height, PutByteContext *pb)
{
UtvideoContext *c = avctx->priv_data;
uint8_t lengths[256];
uint64_t counts[256] = { 0 };
HuffEntry he[256];
uint32_t offset = 0, slice_len = 0;
int i, sstart, send = 0;
int symbol;
/* Do prediction / make planes */
switch (c->frame_pred) {
case PRED_NONE:
for (i = 0; i < c->slices; i++) {
sstart = send;
send = height * (i + 1) / c->slices;
write_plane(src + sstart * stride, dst + sstart * width,
stride, width, send - sstart);
}
break;
case PRED_LEFT:
for (i = 0; i < c->slices; i++) {
sstart = send;
send = height * (i + 1) / c->slices;
left_predict(src + sstart * stride, dst + sstart * width,
stride, width, send - sstart);
}
break;
case PRED_MEDIAN:
for (i = 0; i < c->slices; i++) {
sstart = send;
send = height * (i + 1) / c->slices;
median_predict(c, src + sstart * stride, dst + sstart * width,
stride, width, send - sstart);
}
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown prediction mode: %d\n",
c->frame_pred);
return AVERROR_OPTION_NOT_FOUND;
}
/* Count the usage of values */
count_usage(dst, width, height, counts);
/* Check for a special case where only one symbol was used */
for (symbol = 0; symbol < 256; symbol++) {
/* If non-zero count is found, see if it matches width * height */
if (counts[symbol]) {
/* Special case if only one symbol was used */
if (counts[symbol] == width * height) {
/*
* Write a zero for the single symbol
* used in the plane, else 0xFF.
*/
for (i = 0; i < 256; i++) {
if (i == symbol)
bytestream2_put_byte(pb, 0);
else
bytestream2_put_byte(pb, 0xFF);
}
/* Write zeroes for lengths */
for (i = 0; i < c->slices; i++)
bytestream2_put_le32(pb, 0);
/* And that's all for that plane folks */
return 0;
}
break;
}
}
/* Calculate huffman lengths */
ff_huff_gen_len_table(lengths, counts);
/*
* Write the plane's header into the output packet:
* - huffman code lengths (256 bytes)
* - slice end offsets (gotten from the slice lengths)
*/
for (i = 0; i < 256; i++) {
bytestream2_put_byte(pb, lengths[i]);
he[i].len = lengths[i];
he[i].sym = i;
}
/* Calculate the huffman codes themselves */
calculate_codes(he);
send = 0;
for (i = 0; i < c->slices; i++) {
sstart = send;
send = height * (i + 1) / c->slices;
/*
* Write the huffman codes to a buffer,
* get the offset in bits and convert to bytes.
*/
offset += write_huff_codes(dst + sstart * width, c->slice_bits,
width * (send - sstart), width,
send - sstart, he) >> 3;
slice_len = offset - slice_len;
/* Byteswap the written huffman codes */
c->dsp.bswap_buf((uint32_t *) c->slice_bits,
(uint32_t *) c->slice_bits,
slice_len >> 2);
/* Write the offset to the stream */
bytestream2_put_le32(pb, offset);
/* Seek to the data part of the packet */
bytestream2_seek_p(pb, 4 * (c->slices - i - 1) +
offset - slice_len, SEEK_CUR);
/* Write the slices' data into the output packet */
bytestream2_put_buffer(pb, c->slice_bits, slice_len);
/* Seek back to the slice offsets */
bytestream2_seek_p(pb, -4 * (c->slices - i - 1) - offset,
SEEK_CUR);
slice_len = offset;
}
/* And at the end seek to the end of written slice(s) */
bytestream2_seek_p(pb, offset, SEEK_CUR);
return 0;
}
| true | FFmpeg | 0fa26bd4703cf8ee84ae9b9859be2b4e0e77d42f | static int encode_plane(AVCodecContext *avctx, uint8_t *src,
uint8_t *dst, int stride,
int width, int height, PutByteContext *pb)
{
UtvideoContext *c = avctx->priv_data;
uint8_t lengths[256];
uint64_t counts[256] = { 0 };
HuffEntry he[256];
uint32_t offset = 0, slice_len = 0;
int i, sstart, send = 0;
int symbol;
switch (c->frame_pred) {
case PRED_NONE:
for (i = 0; i < c->slices; i++) {
sstart = send;
send = height * (i + 1) / c->slices;
write_plane(src + sstart * stride, dst + sstart * width,
stride, width, send - sstart);
}
break;
case PRED_LEFT:
for (i = 0; i < c->slices; i++) {
sstart = send;
send = height * (i + 1) / c->slices;
left_predict(src + sstart * stride, dst + sstart * width,
stride, width, send - sstart);
}
break;
case PRED_MEDIAN:
for (i = 0; i < c->slices; i++) {
sstart = send;
send = height * (i + 1) / c->slices;
median_predict(c, src + sstart * stride, dst + sstart * width,
stride, width, send - sstart);
}
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown prediction mode: %d\n",
c->frame_pred);
return AVERROR_OPTION_NOT_FOUND;
}
count_usage(dst, width, height, counts);
for (symbol = 0; symbol < 256; symbol++) {
if (counts[symbol]) {
if (counts[symbol] == width * height) {
for (i = 0; i < 256; i++) {
if (i == symbol)
bytestream2_put_byte(pb, 0);
else
bytestream2_put_byte(pb, 0xFF);
}
for (i = 0; i < c->slices; i++)
bytestream2_put_le32(pb, 0);
return 0;
}
break;
}
}
ff_huff_gen_len_table(lengths, counts);
for (i = 0; i < 256; i++) {
bytestream2_put_byte(pb, lengths[i]);
he[i].len = lengths[i];
he[i].sym = i;
}
calculate_codes(he);
send = 0;
for (i = 0; i < c->slices; i++) {
sstart = send;
send = height * (i + 1) / c->slices;
offset += write_huff_codes(dst + sstart * width, c->slice_bits,
width * (send - sstart), width,
send - sstart, he) >> 3;
slice_len = offset - slice_len;
c->dsp.bswap_buf((uint32_t *) c->slice_bits,
(uint32_t *) c->slice_bits,
slice_len >> 2);
bytestream2_put_le32(pb, offset);
bytestream2_seek_p(pb, 4 * (c->slices - i - 1) +
offset - slice_len, SEEK_CUR);
bytestream2_put_buffer(pb, c->slice_bits, slice_len);
bytestream2_seek_p(pb, -4 * (c->slices - i - 1) - offset,
SEEK_CUR);
slice_len = offset;
}
bytestream2_seek_p(pb, offset, SEEK_CUR);
return 0;
}
| {
"code": [
" if (counts[symbol] == width * height) {"
],
"line_no": [
109
]
} | static int FUNC_0(AVCodecContext *VAR_0, uint8_t *VAR_1,
uint8_t *VAR_2, int VAR_3,
int VAR_4, int VAR_5, PutByteContext *VAR_6)
{
UtvideoContext *c = VAR_0->priv_data;
uint8_t lengths[256];
uint64_t counts[256] = { 0 };
HuffEntry he[256];
uint32_t offset = 0, slice_len = 0;
int VAR_7, VAR_8, VAR_9 = 0;
int VAR_10;
switch (c->frame_pred) {
case PRED_NONE:
for (VAR_7 = 0; VAR_7 < c->slices; VAR_7++) {
VAR_8 = VAR_9;
VAR_9 = VAR_5 * (VAR_7 + 1) / c->slices;
write_plane(VAR_1 + VAR_8 * VAR_3, VAR_2 + VAR_8 * VAR_4,
VAR_3, VAR_4, VAR_9 - VAR_8);
}
break;
case PRED_LEFT:
for (VAR_7 = 0; VAR_7 < c->slices; VAR_7++) {
VAR_8 = VAR_9;
VAR_9 = VAR_5 * (VAR_7 + 1) / c->slices;
left_predict(VAR_1 + VAR_8 * VAR_3, VAR_2 + VAR_8 * VAR_4,
VAR_3, VAR_4, VAR_9 - VAR_8);
}
break;
case PRED_MEDIAN:
for (VAR_7 = 0; VAR_7 < c->slices; VAR_7++) {
VAR_8 = VAR_9;
VAR_9 = VAR_5 * (VAR_7 + 1) / c->slices;
median_predict(c, VAR_1 + VAR_8 * VAR_3, VAR_2 + VAR_8 * VAR_4,
VAR_3, VAR_4, VAR_9 - VAR_8);
}
break;
default:
av_log(VAR_0, AV_LOG_ERROR, "Unknown prediction mode: %d\n",
c->frame_pred);
return AVERROR_OPTION_NOT_FOUND;
}
count_usage(VAR_2, VAR_4, VAR_5, counts);
for (VAR_10 = 0; VAR_10 < 256; VAR_10++) {
if (counts[VAR_10]) {
if (counts[VAR_10] == VAR_4 * VAR_5) {
for (VAR_7 = 0; VAR_7 < 256; VAR_7++) {
if (VAR_7 == VAR_10)
bytestream2_put_byte(VAR_6, 0);
else
bytestream2_put_byte(VAR_6, 0xFF);
}
for (VAR_7 = 0; VAR_7 < c->slices; VAR_7++)
bytestream2_put_le32(VAR_6, 0);
return 0;
}
break;
}
}
ff_huff_gen_len_table(lengths, counts);
for (VAR_7 = 0; VAR_7 < 256; VAR_7++) {
bytestream2_put_byte(VAR_6, lengths[VAR_7]);
he[VAR_7].len = lengths[VAR_7];
he[VAR_7].sym = VAR_7;
}
calculate_codes(he);
VAR_9 = 0;
for (VAR_7 = 0; VAR_7 < c->slices; VAR_7++) {
VAR_8 = VAR_9;
VAR_9 = VAR_5 * (VAR_7 + 1) / c->slices;
offset += write_huff_codes(VAR_2 + VAR_8 * VAR_4, c->slice_bits,
VAR_4 * (VAR_9 - VAR_8), VAR_4,
VAR_9 - VAR_8, he) >> 3;
slice_len = offset - slice_len;
c->dsp.bswap_buf((uint32_t *) c->slice_bits,
(uint32_t *) c->slice_bits,
slice_len >> 2);
bytestream2_put_le32(VAR_6, offset);
bytestream2_seek_p(VAR_6, 4 * (c->slices - VAR_7 - 1) +
offset - slice_len, SEEK_CUR);
bytestream2_put_buffer(VAR_6, c->slice_bits, slice_len);
bytestream2_seek_p(VAR_6, -4 * (c->slices - VAR_7 - 1) - offset,
SEEK_CUR);
slice_len = offset;
}
bytestream2_seek_p(VAR_6, offset, SEEK_CUR);
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, uint8_t *VAR_1,\nuint8_t *VAR_2, int VAR_3,\nint VAR_4, int VAR_5, PutByteContext *VAR_6)\n{",
"UtvideoContext *c = VAR_0->priv_data;",
"uint8_t lengths[256];",
"uint64_t counts[256] = { 0 };",
"HuffEntry he[256];",
"uint32_t offset = 0, slice_len = 0;",
"int VAR_7, VAR_8, VAR_9 = 0;",
"int VAR_10;",
"switch (c->frame_pred) {",
"case PRED_NONE:\nfor (VAR_7 = 0; VAR_7 < c->slices; VAR_7++) {",
"VAR_8 = VAR_9;",
"VAR_9 = VAR_5 * (VAR_7 + 1) / c->slices;",
"write_plane(VAR_1 + VAR_8 * VAR_3, VAR_2 + VAR_8 * VAR_4,\nVAR_3, VAR_4, VAR_9 - VAR_8);",
"}",
"break;",
"case PRED_LEFT:\nfor (VAR_7 = 0; VAR_7 < c->slices; VAR_7++) {",
"VAR_8 = VAR_9;",
"VAR_9 = VAR_5 * (VAR_7 + 1) / c->slices;",
"left_predict(VAR_1 + VAR_8 * VAR_3, VAR_2 + VAR_8 * VAR_4,\nVAR_3, VAR_4, VAR_9 - VAR_8);",
"}",
"break;",
"case PRED_MEDIAN:\nfor (VAR_7 = 0; VAR_7 < c->slices; VAR_7++) {",
"VAR_8 = VAR_9;",
"VAR_9 = VAR_5 * (VAR_7 + 1) / c->slices;",
"median_predict(c, VAR_1 + VAR_8 * VAR_3, VAR_2 + VAR_8 * VAR_4,\nVAR_3, VAR_4, VAR_9 - VAR_8);",
"}",
"break;",
"default:\nav_log(VAR_0, AV_LOG_ERROR, \"Unknown prediction mode: %d\\n\",\nc->frame_pred);",
"return AVERROR_OPTION_NOT_FOUND;",
"}",
"count_usage(VAR_2, VAR_4, VAR_5, counts);",
"for (VAR_10 = 0; VAR_10 < 256; VAR_10++) {",
"if (counts[VAR_10]) {",
"if (counts[VAR_10] == VAR_4 * VAR_5) {",
"for (VAR_7 = 0; VAR_7 < 256; VAR_7++) {",
"if (VAR_7 == VAR_10)\nbytestream2_put_byte(VAR_6, 0);",
"else\nbytestream2_put_byte(VAR_6, 0xFF);",
"}",
"for (VAR_7 = 0; VAR_7 < c->slices; VAR_7++)",
"bytestream2_put_le32(VAR_6, 0);",
"return 0;",
"}",
"break;",
"}",
"}",
"ff_huff_gen_len_table(lengths, counts);",
"for (VAR_7 = 0; VAR_7 < 256; VAR_7++) {",
"bytestream2_put_byte(VAR_6, lengths[VAR_7]);",
"he[VAR_7].len = lengths[VAR_7];",
"he[VAR_7].sym = VAR_7;",
"}",
"calculate_codes(he);",
"VAR_9 = 0;",
"for (VAR_7 = 0; VAR_7 < c->slices; VAR_7++) {",
"VAR_8 = VAR_9;",
"VAR_9 = VAR_5 * (VAR_7 + 1) / c->slices;",
"offset += write_huff_codes(VAR_2 + VAR_8 * VAR_4, c->slice_bits,\nVAR_4 * (VAR_9 - VAR_8), VAR_4,\nVAR_9 - VAR_8, he) >> 3;",
"slice_len = offset - slice_len;",
"c->dsp.bswap_buf((uint32_t *) c->slice_bits,\n(uint32_t *) c->slice_bits,\nslice_len >> 2);",
"bytestream2_put_le32(VAR_6, offset);",
"bytestream2_seek_p(VAR_6, 4 * (c->slices - VAR_7 - 1) +\noffset - slice_len, SEEK_CUR);",
"bytestream2_put_buffer(VAR_6, c->slice_bits, slice_len);",
"bytestream2_seek_p(VAR_6, -4 * (c->slices - VAR_7 - 1) - offset,\nSEEK_CUR);",
"slice_len = offset;",
"}",
"bytestream2_seek_p(VAR_6, offset, SEEK_CUR);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
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
],
[
95
],
[
101
],
[
105
],
[
109
],
[
119
],
[
121,
123
],
[
125,
127
],
[
129
],
[
135
],
[
137
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
157
],
[
171
],
[
173
],
[
177
],
[
179
],
[
181
],
[
187
],
[
191
],
[
193
],
[
195
],
[
197
],
[
209,
211,
213
],
[
217
],
[
223,
225,
227
],
[
233
],
[
239,
241
],
[
247
],
[
253,
255
],
[
259
],
[
261
],
[
267
],
[
271
],
[
273
]
] |
24,922 | static int vhdx_create(const char *filename, QEMUOptionParameter *options,
Error **errp)
{
int ret = 0;
uint64_t image_size = (uint64_t) 2 * GiB;
uint32_t log_size = 1 * MiB;
uint32_t block_size = 0;
uint64_t signature;
uint64_t metadata_offset;
bool use_zero_blocks = false;
gunichar2 *creator = NULL;
glong creator_items;
BlockDriverState *bs;
const char *type = NULL;
VHDXImageType image_type;
Error *local_err = NULL;
while (options && options->name) {
if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
image_size = options->value.n;
} else if (!strcmp(options->name, VHDX_BLOCK_OPT_LOG_SIZE)) {
log_size = options->value.n;
} else if (!strcmp(options->name, VHDX_BLOCK_OPT_BLOCK_SIZE)) {
block_size = options->value.n;
} else if (!strcmp(options->name, BLOCK_OPT_SUBFMT)) {
type = options->value.s;
} else if (!strcmp(options->name, VHDX_BLOCK_OPT_ZERO)) {
use_zero_blocks = options->value.n != 0;
}
options++;
}
if (image_size > VHDX_MAX_IMAGE_SIZE) {
error_setg_errno(errp, EINVAL, "Image size too large; max of 64TB");
ret = -EINVAL;
goto exit;
}
if (type == NULL) {
type = "dynamic";
}
if (!strcmp(type, "dynamic")) {
image_type = VHDX_TYPE_DYNAMIC;
} else if (!strcmp(type, "fixed")) {
image_type = VHDX_TYPE_FIXED;
} else if (!strcmp(type, "differencing")) {
error_setg_errno(errp, ENOTSUP,
"Differencing files not yet supported");
ret = -ENOTSUP;
goto exit;
} else {
ret = -EINVAL;
goto exit;
}
/* These are pretty arbitrary, and mainly designed to keep the BAT
* size reasonable to load into RAM */
if (block_size == 0) {
if (image_size > 32 * TiB) {
block_size = 64 * MiB;
} else if (image_size > (uint64_t) 100 * GiB) {
block_size = 32 * MiB;
} else if (image_size > 1 * GiB) {
block_size = 16 * MiB;
} else {
block_size = 8 * MiB;
}
}
/* make the log size close to what was specified, but must be
* min 1MB, and multiple of 1MB */
log_size = ROUND_UP(log_size, MiB);
block_size = ROUND_UP(block_size, MiB);
block_size = block_size > VHDX_BLOCK_SIZE_MAX ? VHDX_BLOCK_SIZE_MAX :
block_size;
ret = bdrv_create_file(filename, options, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
goto exit;
}
ret = bdrv_file_open(&bs, filename, NULL, NULL, BDRV_O_RDWR, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
goto exit;
}
/* Create (A) */
/* The creator field is optional, but may be useful for
* debugging / diagnostics */
creator = g_utf8_to_utf16("QEMU v" QEMU_VERSION, -1, NULL,
&creator_items, NULL);
signature = cpu_to_le64(VHDX_FILE_SIGNATURE);
bdrv_pwrite(bs, VHDX_FILE_ID_OFFSET, &signature, sizeof(signature));
if (ret < 0) {
goto delete_and_exit;
}
if (creator) {
bdrv_pwrite(bs, VHDX_FILE_ID_OFFSET + sizeof(signature), creator,
creator_items * sizeof(gunichar2));
if (ret < 0) {
goto delete_and_exit;
}
}
/* Creates (B),(C) */
ret = vhdx_create_new_headers(bs, image_size, log_size);
if (ret < 0) {
goto delete_and_exit;
}
/* Creates (D),(E),(G) explicitly. (F) created as by-product */
ret = vhdx_create_new_region_table(bs, image_size, block_size, 512,
log_size, use_zero_blocks, image_type,
&metadata_offset);
if (ret < 0) {
goto delete_and_exit;
}
/* Creates (H) */
ret = vhdx_create_new_metadata(bs, image_size, block_size, 512,
metadata_offset, image_type);
if (ret < 0) {
goto delete_and_exit;
}
delete_and_exit:
bdrv_unref(bs);
exit:
g_free(creator);
return ret;
}
| false | qemu | f50159fa9b5a0ad82e30c123643ec39a1df81d9a | static int vhdx_create(const char *filename, QEMUOptionParameter *options,
Error **errp)
{
int ret = 0;
uint64_t image_size = (uint64_t) 2 * GiB;
uint32_t log_size = 1 * MiB;
uint32_t block_size = 0;
uint64_t signature;
uint64_t metadata_offset;
bool use_zero_blocks = false;
gunichar2 *creator = NULL;
glong creator_items;
BlockDriverState *bs;
const char *type = NULL;
VHDXImageType image_type;
Error *local_err = NULL;
while (options && options->name) {
if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
image_size = options->value.n;
} else if (!strcmp(options->name, VHDX_BLOCK_OPT_LOG_SIZE)) {
log_size = options->value.n;
} else if (!strcmp(options->name, VHDX_BLOCK_OPT_BLOCK_SIZE)) {
block_size = options->value.n;
} else if (!strcmp(options->name, BLOCK_OPT_SUBFMT)) {
type = options->value.s;
} else if (!strcmp(options->name, VHDX_BLOCK_OPT_ZERO)) {
use_zero_blocks = options->value.n != 0;
}
options++;
}
if (image_size > VHDX_MAX_IMAGE_SIZE) {
error_setg_errno(errp, EINVAL, "Image size too large; max of 64TB");
ret = -EINVAL;
goto exit;
}
if (type == NULL) {
type = "dynamic";
}
if (!strcmp(type, "dynamic")) {
image_type = VHDX_TYPE_DYNAMIC;
} else if (!strcmp(type, "fixed")) {
image_type = VHDX_TYPE_FIXED;
} else if (!strcmp(type, "differencing")) {
error_setg_errno(errp, ENOTSUP,
"Differencing files not yet supported");
ret = -ENOTSUP;
goto exit;
} else {
ret = -EINVAL;
goto exit;
}
if (block_size == 0) {
if (image_size > 32 * TiB) {
block_size = 64 * MiB;
} else if (image_size > (uint64_t) 100 * GiB) {
block_size = 32 * MiB;
} else if (image_size > 1 * GiB) {
block_size = 16 * MiB;
} else {
block_size = 8 * MiB;
}
}
log_size = ROUND_UP(log_size, MiB);
block_size = ROUND_UP(block_size, MiB);
block_size = block_size > VHDX_BLOCK_SIZE_MAX ? VHDX_BLOCK_SIZE_MAX :
block_size;
ret = bdrv_create_file(filename, options, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
goto exit;
}
ret = bdrv_file_open(&bs, filename, NULL, NULL, BDRV_O_RDWR, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
goto exit;
}
creator = g_utf8_to_utf16("QEMU v" QEMU_VERSION, -1, NULL,
&creator_items, NULL);
signature = cpu_to_le64(VHDX_FILE_SIGNATURE);
bdrv_pwrite(bs, VHDX_FILE_ID_OFFSET, &signature, sizeof(signature));
if (ret < 0) {
goto delete_and_exit;
}
if (creator) {
bdrv_pwrite(bs, VHDX_FILE_ID_OFFSET + sizeof(signature), creator,
creator_items * sizeof(gunichar2));
if (ret < 0) {
goto delete_and_exit;
}
}
ret = vhdx_create_new_headers(bs, image_size, log_size);
if (ret < 0) {
goto delete_and_exit;
}
ret = vhdx_create_new_region_table(bs, image_size, block_size, 512,
log_size, use_zero_blocks, image_type,
&metadata_offset);
if (ret < 0) {
goto delete_and_exit;
}
ret = vhdx_create_new_metadata(bs, image_size, block_size, 512,
metadata_offset, image_type);
if (ret < 0) {
goto delete_and_exit;
}
delete_and_exit:
bdrv_unref(bs);
exit:
g_free(creator);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(const char *VAR_0, QEMUOptionParameter *VAR_1,
Error **VAR_2)
{
int VAR_3 = 0;
uint64_t image_size = (uint64_t) 2 * GiB;
uint32_t log_size = 1 * MiB;
uint32_t block_size = 0;
uint64_t signature;
uint64_t metadata_offset;
bool use_zero_blocks = false;
gunichar2 *creator = NULL;
glong creator_items;
BlockDriverState *bs;
const char *VAR_4 = NULL;
VHDXImageType image_type;
Error *local_err = NULL;
while (VAR_1 && VAR_1->name) {
if (!strcmp(VAR_1->name, BLOCK_OPT_SIZE)) {
image_size = VAR_1->value.n;
} else if (!strcmp(VAR_1->name, VHDX_BLOCK_OPT_LOG_SIZE)) {
log_size = VAR_1->value.n;
} else if (!strcmp(VAR_1->name, VHDX_BLOCK_OPT_BLOCK_SIZE)) {
block_size = VAR_1->value.n;
} else if (!strcmp(VAR_1->name, BLOCK_OPT_SUBFMT)) {
VAR_4 = VAR_1->value.s;
} else if (!strcmp(VAR_1->name, VHDX_BLOCK_OPT_ZERO)) {
use_zero_blocks = VAR_1->value.n != 0;
}
VAR_1++;
}
if (image_size > VHDX_MAX_IMAGE_SIZE) {
error_setg_errno(VAR_2, EINVAL, "Image size too large; max of 64TB");
VAR_3 = -EINVAL;
goto exit;
}
if (VAR_4 == NULL) {
VAR_4 = "dynamic";
}
if (!strcmp(VAR_4, "dynamic")) {
image_type = VHDX_TYPE_DYNAMIC;
} else if (!strcmp(VAR_4, "fixed")) {
image_type = VHDX_TYPE_FIXED;
} else if (!strcmp(VAR_4, "differencing")) {
error_setg_errno(VAR_2, ENOTSUP,
"Differencing files not yet supported");
VAR_3 = -ENOTSUP;
goto exit;
} else {
VAR_3 = -EINVAL;
goto exit;
}
if (block_size == 0) {
if (image_size > 32 * TiB) {
block_size = 64 * MiB;
} else if (image_size > (uint64_t) 100 * GiB) {
block_size = 32 * MiB;
} else if (image_size > 1 * GiB) {
block_size = 16 * MiB;
} else {
block_size = 8 * MiB;
}
}
log_size = ROUND_UP(log_size, MiB);
block_size = ROUND_UP(block_size, MiB);
block_size = block_size > VHDX_BLOCK_SIZE_MAX ? VHDX_BLOCK_SIZE_MAX :
block_size;
VAR_3 = bdrv_create_file(VAR_0, VAR_1, &local_err);
if (VAR_3 < 0) {
error_propagate(VAR_2, local_err);
goto exit;
}
VAR_3 = bdrv_file_open(&bs, VAR_0, NULL, NULL, BDRV_O_RDWR, &local_err);
if (VAR_3 < 0) {
error_propagate(VAR_2, local_err);
goto exit;
}
creator = g_utf8_to_utf16("QEMU v" QEMU_VERSION, -1, NULL,
&creator_items, NULL);
signature = cpu_to_le64(VHDX_FILE_SIGNATURE);
bdrv_pwrite(bs, VHDX_FILE_ID_OFFSET, &signature, sizeof(signature));
if (VAR_3 < 0) {
goto delete_and_exit;
}
if (creator) {
bdrv_pwrite(bs, VHDX_FILE_ID_OFFSET + sizeof(signature), creator,
creator_items * sizeof(gunichar2));
if (VAR_3 < 0) {
goto delete_and_exit;
}
}
VAR_3 = vhdx_create_new_headers(bs, image_size, log_size);
if (VAR_3 < 0) {
goto delete_and_exit;
}
VAR_3 = vhdx_create_new_region_table(bs, image_size, block_size, 512,
log_size, use_zero_blocks, image_type,
&metadata_offset);
if (VAR_3 < 0) {
goto delete_and_exit;
}
VAR_3 = vhdx_create_new_metadata(bs, image_size, block_size, 512,
metadata_offset, image_type);
if (VAR_3 < 0) {
goto delete_and_exit;
}
delete_and_exit:
bdrv_unref(bs);
exit:
g_free(creator);
return VAR_3;
}
| [
"static int FUNC_0(const char *VAR_0, QEMUOptionParameter *VAR_1,\nError **VAR_2)\n{",
"int VAR_3 = 0;",
"uint64_t image_size = (uint64_t) 2 * GiB;",
"uint32_t log_size = 1 * MiB;",
"uint32_t block_size = 0;",
"uint64_t signature;",
"uint64_t metadata_offset;",
"bool use_zero_blocks = false;",
"gunichar2 *creator = NULL;",
"glong creator_items;",
"BlockDriverState *bs;",
"const char *VAR_4 = NULL;",
"VHDXImageType image_type;",
"Error *local_err = NULL;",
"while (VAR_1 && VAR_1->name) {",
"if (!strcmp(VAR_1->name, BLOCK_OPT_SIZE)) {",
"image_size = VAR_1->value.n;",
"} else if (!strcmp(VAR_1->name, VHDX_BLOCK_OPT_LOG_SIZE)) {",
"log_size = VAR_1->value.n;",
"} else if (!strcmp(VAR_1->name, VHDX_BLOCK_OPT_BLOCK_SIZE)) {",
"block_size = VAR_1->value.n;",
"} else if (!strcmp(VAR_1->name, BLOCK_OPT_SUBFMT)) {",
"VAR_4 = VAR_1->value.s;",
"} else if (!strcmp(VAR_1->name, VHDX_BLOCK_OPT_ZERO)) {",
"use_zero_blocks = VAR_1->value.n != 0;",
"}",
"VAR_1++;",
"}",
"if (image_size > VHDX_MAX_IMAGE_SIZE) {",
"error_setg_errno(VAR_2, EINVAL, \"Image size too large; max of 64TB\");",
"VAR_3 = -EINVAL;",
"goto exit;",
"}",
"if (VAR_4 == NULL) {",
"VAR_4 = \"dynamic\";",
"}",
"if (!strcmp(VAR_4, \"dynamic\")) {",
"image_type = VHDX_TYPE_DYNAMIC;",
"} else if (!strcmp(VAR_4, \"fixed\")) {",
"image_type = VHDX_TYPE_FIXED;",
"} else if (!strcmp(VAR_4, \"differencing\")) {",
"error_setg_errno(VAR_2, ENOTSUP,\n\"Differencing files not yet supported\");",
"VAR_3 = -ENOTSUP;",
"goto exit;",
"} else {",
"VAR_3 = -EINVAL;",
"goto exit;",
"}",
"if (block_size == 0) {",
"if (image_size > 32 * TiB) {",
"block_size = 64 * MiB;",
"} else if (image_size > (uint64_t) 100 * GiB) {",
"block_size = 32 * MiB;",
"} else if (image_size > 1 * GiB) {",
"block_size = 16 * MiB;",
"} else {",
"block_size = 8 * MiB;",
"}",
"}",
"log_size = ROUND_UP(log_size, MiB);",
"block_size = ROUND_UP(block_size, MiB);",
"block_size = block_size > VHDX_BLOCK_SIZE_MAX ? VHDX_BLOCK_SIZE_MAX :\nblock_size;",
"VAR_3 = bdrv_create_file(VAR_0, VAR_1, &local_err);",
"if (VAR_3 < 0) {",
"error_propagate(VAR_2, local_err);",
"goto exit;",
"}",
"VAR_3 = bdrv_file_open(&bs, VAR_0, NULL, NULL, BDRV_O_RDWR, &local_err);",
"if (VAR_3 < 0) {",
"error_propagate(VAR_2, local_err);",
"goto exit;",
"}",
"creator = g_utf8_to_utf16(\"QEMU v\" QEMU_VERSION, -1, NULL,\n&creator_items, NULL);",
"signature = cpu_to_le64(VHDX_FILE_SIGNATURE);",
"bdrv_pwrite(bs, VHDX_FILE_ID_OFFSET, &signature, sizeof(signature));",
"if (VAR_3 < 0) {",
"goto delete_and_exit;",
"}",
"if (creator) {",
"bdrv_pwrite(bs, VHDX_FILE_ID_OFFSET + sizeof(signature), creator,\ncreator_items * sizeof(gunichar2));",
"if (VAR_3 < 0) {",
"goto delete_and_exit;",
"}",
"}",
"VAR_3 = vhdx_create_new_headers(bs, image_size, log_size);",
"if (VAR_3 < 0) {",
"goto delete_and_exit;",
"}",
"VAR_3 = vhdx_create_new_region_table(bs, image_size, block_size, 512,\nlog_size, use_zero_blocks, image_type,\n&metadata_offset);",
"if (VAR_3 < 0) {",
"goto delete_and_exit;",
"}",
"VAR_3 = vhdx_create_new_metadata(bs, image_size, block_size, 512,\nmetadata_offset, image_type);",
"if (VAR_3 < 0) {",
"goto delete_and_exit;",
"}",
"delete_and_exit:\nbdrv_unref(bs);",
"exit:\ng_free(creator);",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97,
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
149
],
[
153
],
[
155,
157
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
193,
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209,
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
227
],
[
229
],
[
231
],
[
233
],
[
239,
241,
243
],
[
245
],
[
247
],
[
249
],
[
255,
257
],
[
259
],
[
261
],
[
263
],
[
271,
273
],
[
275,
277
],
[
279
],
[
281
]
] |
24,923 | static int zero_single_l2(BlockDriverState *bs, uint64_t offset,
uint64_t nb_clusters, int flags)
{
BDRVQcow2State *s = bs->opaque;
uint64_t *l2_table;
int l2_index;
int ret;
int i;
ret = get_cluster_table(bs, offset, &l2_table, &l2_index);
if (ret < 0) {
return ret;
}
/* Limit nb_clusters to one L2 table */
nb_clusters = MIN(nb_clusters, s->l2_size - l2_index);
assert(nb_clusters <= INT_MAX);
for (i = 0; i < nb_clusters; i++) {
uint64_t old_offset;
old_offset = be64_to_cpu(l2_table[l2_index + i]);
/* Update L2 entries */
qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table);
if (old_offset & QCOW_OFLAG_COMPRESSED || flags & BDRV_REQ_MAY_UNMAP) {
l2_table[l2_index + i] = cpu_to_be64(QCOW_OFLAG_ZERO);
qcow2_free_any_clusters(bs, old_offset, 1, QCOW2_DISCARD_REQUEST);
} else {
l2_table[l2_index + i] |= cpu_to_be64(QCOW_OFLAG_ZERO);
}
}
qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table);
return nb_clusters;
}
| false | qemu | 06cc5e2b2d01cb778c966e1b4135062556b3b054 | static int zero_single_l2(BlockDriverState *bs, uint64_t offset,
uint64_t nb_clusters, int flags)
{
BDRVQcow2State *s = bs->opaque;
uint64_t *l2_table;
int l2_index;
int ret;
int i;
ret = get_cluster_table(bs, offset, &l2_table, &l2_index);
if (ret < 0) {
return ret;
}
nb_clusters = MIN(nb_clusters, s->l2_size - l2_index);
assert(nb_clusters <= INT_MAX);
for (i = 0; i < nb_clusters; i++) {
uint64_t old_offset;
old_offset = be64_to_cpu(l2_table[l2_index + i]);
qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table);
if (old_offset & QCOW_OFLAG_COMPRESSED || flags & BDRV_REQ_MAY_UNMAP) {
l2_table[l2_index + i] = cpu_to_be64(QCOW_OFLAG_ZERO);
qcow2_free_any_clusters(bs, old_offset, 1, QCOW2_DISCARD_REQUEST);
} else {
l2_table[l2_index + i] |= cpu_to_be64(QCOW_OFLAG_ZERO);
}
}
qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table);
return nb_clusters;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,
uint64_t VAR_2, int VAR_3)
{
BDRVQcow2State *s = VAR_0->opaque;
uint64_t *l2_table;
int VAR_4;
int VAR_5;
int VAR_6;
VAR_5 = get_cluster_table(VAR_0, VAR_1, &l2_table, &VAR_4);
if (VAR_5 < 0) {
return VAR_5;
}
VAR_2 = MIN(VAR_2, s->l2_size - VAR_4);
assert(VAR_2 <= INT_MAX);
for (VAR_6 = 0; VAR_6 < VAR_2; VAR_6++) {
uint64_t old_offset;
old_offset = be64_to_cpu(l2_table[VAR_4 + VAR_6]);
qcow2_cache_entry_mark_dirty(VAR_0, s->l2_table_cache, l2_table);
if (old_offset & QCOW_OFLAG_COMPRESSED || VAR_3 & BDRV_REQ_MAY_UNMAP) {
l2_table[VAR_4 + VAR_6] = cpu_to_be64(QCOW_OFLAG_ZERO);
qcow2_free_any_clusters(VAR_0, old_offset, 1, QCOW2_DISCARD_REQUEST);
} else {
l2_table[VAR_4 + VAR_6] |= cpu_to_be64(QCOW_OFLAG_ZERO);
}
}
qcow2_cache_put(VAR_0, s->l2_table_cache, (void **) &l2_table);
return VAR_2;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,\nuint64_t VAR_2, int VAR_3)\n{",
"BDRVQcow2State *s = VAR_0->opaque;",
"uint64_t *l2_table;",
"int VAR_4;",
"int VAR_5;",
"int VAR_6;",
"VAR_5 = get_cluster_table(VAR_0, VAR_1, &l2_table, &VAR_4);",
"if (VAR_5 < 0) {",
"return VAR_5;",
"}",
"VAR_2 = MIN(VAR_2, s->l2_size - VAR_4);",
"assert(VAR_2 <= INT_MAX);",
"for (VAR_6 = 0; VAR_6 < VAR_2; VAR_6++) {",
"uint64_t old_offset;",
"old_offset = be64_to_cpu(l2_table[VAR_4 + VAR_6]);",
"qcow2_cache_entry_mark_dirty(VAR_0, s->l2_table_cache, l2_table);",
"if (old_offset & QCOW_OFLAG_COMPRESSED || VAR_3 & BDRV_REQ_MAY_UNMAP) {",
"l2_table[VAR_4 + VAR_6] = cpu_to_be64(QCOW_OFLAG_ZERO);",
"qcow2_free_any_clusters(VAR_0, old_offset, 1, QCOW2_DISCARD_REQUEST);",
"} else {",
"l2_table[VAR_4 + VAR_6] |= cpu_to_be64(QCOW_OFLAG_ZERO);",
"}",
"}",
"qcow2_cache_put(VAR_0, s->l2_table_cache, (void **) &l2_table);",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
31
],
[
33
],
[
37
],
[
39
],
[
43
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
71
],
[
73
]
] |
24,924 | static int megasas_dcmd_set_properties(MegasasState *s, MegasasCmd *cmd)
{
struct mfi_ctrl_props info;
size_t dcmd_size = sizeof(info);
if (cmd->iov_size < dcmd_size) {
trace_megasas_dcmd_invalid_xfer_len(cmd->index, cmd->iov_size,
dcmd_size);
return MFI_STAT_INVALID_PARAMETER;
}
dma_buf_write((uint8_t *)&info, cmd->iov_size, &cmd->qsg);
trace_megasas_dcmd_unsupported(cmd->index, cmd->iov_size);
return MFI_STAT_OK;
}
| false | qemu | 1b85898025c4cd95dce673d15e67e60e98e91731 | static int megasas_dcmd_set_properties(MegasasState *s, MegasasCmd *cmd)
{
struct mfi_ctrl_props info;
size_t dcmd_size = sizeof(info);
if (cmd->iov_size < dcmd_size) {
trace_megasas_dcmd_invalid_xfer_len(cmd->index, cmd->iov_size,
dcmd_size);
return MFI_STAT_INVALID_PARAMETER;
}
dma_buf_write((uint8_t *)&info, cmd->iov_size, &cmd->qsg);
trace_megasas_dcmd_unsupported(cmd->index, cmd->iov_size);
return MFI_STAT_OK;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MegasasState *VAR_0, MegasasCmd *VAR_1)
{
struct mfi_ctrl_props VAR_2;
size_t dcmd_size = sizeof(VAR_2);
if (VAR_1->iov_size < dcmd_size) {
trace_megasas_dcmd_invalid_xfer_len(VAR_1->index, VAR_1->iov_size,
dcmd_size);
return MFI_STAT_INVALID_PARAMETER;
}
dma_buf_write((uint8_t *)&VAR_2, VAR_1->iov_size, &VAR_1->qsg);
trace_megasas_dcmd_unsupported(VAR_1->index, VAR_1->iov_size);
return MFI_STAT_OK;
}
| [
"static int FUNC_0(MegasasState *VAR_0, MegasasCmd *VAR_1)\n{",
"struct mfi_ctrl_props VAR_2;",
"size_t dcmd_size = sizeof(VAR_2);",
"if (VAR_1->iov_size < dcmd_size) {",
"trace_megasas_dcmd_invalid_xfer_len(VAR_1->index, VAR_1->iov_size,\ndcmd_size);",
"return MFI_STAT_INVALID_PARAMETER;",
"}",
"dma_buf_write((uint8_t *)&VAR_2, VAR_1->iov_size, &VAR_1->qsg);",
"trace_megasas_dcmd_unsupported(VAR_1->index, VAR_1->iov_size);",
"return MFI_STAT_OK;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
24,925 | static int fd_open(BlockDriverState *bs)
{
BDRVRawState *s = bs->opaque;
int last_media_present;
if (s->type != FTYPE_FD)
return 0;
last_media_present = (s->fd >= 0);
if (s->fd >= 0 &&
(qemu_get_clock(rt_clock) - s->fd_open_time) >= FD_OPEN_TIMEOUT) {
close(s->fd);
s->fd = -1;
raw_close_fd_pool(s);
#ifdef DEBUG_FLOPPY
printf("Floppy closed\n");
#endif
}
if (s->fd < 0) {
if (s->fd_got_error &&
(qemu_get_clock(rt_clock) - s->fd_error_time) < FD_OPEN_TIMEOUT) {
#ifdef DEBUG_FLOPPY
printf("No floppy (open delayed)\n");
#endif
return -EIO;
}
s->fd = open(bs->filename, s->fd_open_flags);
if (s->fd < 0) {
s->fd_error_time = qemu_get_clock(rt_clock);
s->fd_got_error = 1;
if (last_media_present)
s->fd_media_changed = 1;
#ifdef DEBUG_FLOPPY
printf("No floppy\n");
#endif
return -EIO;
}
#ifdef DEBUG_FLOPPY
printf("Floppy opened\n");
#endif
}
if (!last_media_present)
s->fd_media_changed = 1;
s->fd_open_time = qemu_get_clock(rt_clock);
s->fd_got_error = 0;
return 0;
}
| false | qemu | 3c529d935923a70519557d420db1d5a09a65086a | static int fd_open(BlockDriverState *bs)
{
BDRVRawState *s = bs->opaque;
int last_media_present;
if (s->type != FTYPE_FD)
return 0;
last_media_present = (s->fd >= 0);
if (s->fd >= 0 &&
(qemu_get_clock(rt_clock) - s->fd_open_time) >= FD_OPEN_TIMEOUT) {
close(s->fd);
s->fd = -1;
raw_close_fd_pool(s);
#ifdef DEBUG_FLOPPY
printf("Floppy closed\n");
#endif
}
if (s->fd < 0) {
if (s->fd_got_error &&
(qemu_get_clock(rt_clock) - s->fd_error_time) < FD_OPEN_TIMEOUT) {
#ifdef DEBUG_FLOPPY
printf("No floppy (open delayed)\n");
#endif
return -EIO;
}
s->fd = open(bs->filename, s->fd_open_flags);
if (s->fd < 0) {
s->fd_error_time = qemu_get_clock(rt_clock);
s->fd_got_error = 1;
if (last_media_present)
s->fd_media_changed = 1;
#ifdef DEBUG_FLOPPY
printf("No floppy\n");
#endif
return -EIO;
}
#ifdef DEBUG_FLOPPY
printf("Floppy opened\n");
#endif
}
if (!last_media_present)
s->fd_media_changed = 1;
s->fd_open_time = qemu_get_clock(rt_clock);
s->fd_got_error = 0;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0)
{
BDRVRawState *s = VAR_0->opaque;
int VAR_1;
if (s->type != FTYPE_FD)
return 0;
VAR_1 = (s->fd >= 0);
if (s->fd >= 0 &&
(qemu_get_clock(rt_clock) - s->fd_open_time) >= FD_OPEN_TIMEOUT) {
close(s->fd);
s->fd = -1;
raw_close_fd_pool(s);
#ifdef DEBUG_FLOPPY
printf("Floppy closed\n");
#endif
}
if (s->fd < 0) {
if (s->fd_got_error &&
(qemu_get_clock(rt_clock) - s->fd_error_time) < FD_OPEN_TIMEOUT) {
#ifdef DEBUG_FLOPPY
printf("No floppy (open delayed)\n");
#endif
return -EIO;
}
s->fd = open(VAR_0->filename, s->fd_open_flags);
if (s->fd < 0) {
s->fd_error_time = qemu_get_clock(rt_clock);
s->fd_got_error = 1;
if (VAR_1)
s->fd_media_changed = 1;
#ifdef DEBUG_FLOPPY
printf("No floppy\n");
#endif
return -EIO;
}
#ifdef DEBUG_FLOPPY
printf("Floppy opened\n");
#endif
}
if (!VAR_1)
s->fd_media_changed = 1;
s->fd_open_time = qemu_get_clock(rt_clock);
s->fd_got_error = 0;
return 0;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0)\n{",
"BDRVRawState *s = VAR_0->opaque;",
"int VAR_1;",
"if (s->type != FTYPE_FD)\nreturn 0;",
"VAR_1 = (s->fd >= 0);",
"if (s->fd >= 0 &&\n(qemu_get_clock(rt_clock) - s->fd_open_time) >= FD_OPEN_TIMEOUT) {",
"close(s->fd);",
"s->fd = -1;",
"raw_close_fd_pool(s);",
"#ifdef DEBUG_FLOPPY\nprintf(\"Floppy closed\\n\");",
"#endif\n}",
"if (s->fd < 0) {",
"if (s->fd_got_error &&\n(qemu_get_clock(rt_clock) - s->fd_error_time) < FD_OPEN_TIMEOUT) {",
"#ifdef DEBUG_FLOPPY\nprintf(\"No floppy (open delayed)\\n\");",
"#endif\nreturn -EIO;",
"}",
"s->fd = open(VAR_0->filename, s->fd_open_flags);",
"if (s->fd < 0) {",
"s->fd_error_time = qemu_get_clock(rt_clock);",
"s->fd_got_error = 1;",
"if (VAR_1)\ns->fd_media_changed = 1;",
"#ifdef DEBUG_FLOPPY\nprintf(\"No floppy\\n\");",
"#endif\nreturn -EIO;",
"}",
"#ifdef DEBUG_FLOPPY\nprintf(\"Floppy opened\\n\");",
"#endif\n}",
"if (!VAR_1)\ns->fd_media_changed = 1;",
"s->fd_open_time = qemu_get_clock(rt_clock);",
"s->fd_got_error = 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31,
33
],
[
35
],
[
37,
39
],
[
41,
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63,
65
],
[
67,
69
],
[
71
],
[
73,
75
],
[
77,
79
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
91
]
] |
24,926 | static void qdev_print(Monitor *mon, DeviceState *dev, int indent)
{
BusState *child;
qdev_printf("dev: %s, id \"%s\"\n", dev->info->name,
dev->id ? dev->id : "");
indent += 2;
if (dev->num_gpio_in) {
qdev_printf("gpio-in %d\n", dev->num_gpio_in);
}
if (dev->num_gpio_out) {
qdev_printf("gpio-out %d\n", dev->num_gpio_out);
}
qdev_print_props(mon, dev, dev->info->props, "dev", indent);
qdev_print_props(mon, dev, dev->parent_bus->info->props, "bus", indent);
if (dev->parent_bus->info->print_dev)
dev->parent_bus->info->print_dev(mon, dev, indent);
LIST_FOREACH(child, &dev->child_bus, sibling) {
qbus_print(mon, child, indent);
}
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | static void qdev_print(Monitor *mon, DeviceState *dev, int indent)
{
BusState *child;
qdev_printf("dev: %s, id \"%s\"\n", dev->info->name,
dev->id ? dev->id : "");
indent += 2;
if (dev->num_gpio_in) {
qdev_printf("gpio-in %d\n", dev->num_gpio_in);
}
if (dev->num_gpio_out) {
qdev_printf("gpio-out %d\n", dev->num_gpio_out);
}
qdev_print_props(mon, dev, dev->info->props, "dev", indent);
qdev_print_props(mon, dev, dev->parent_bus->info->props, "bus", indent);
if (dev->parent_bus->info->print_dev)
dev->parent_bus->info->print_dev(mon, dev, indent);
LIST_FOREACH(child, &dev->child_bus, sibling) {
qbus_print(mon, child, indent);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Monitor *VAR_0, DeviceState *VAR_1, int VAR_2)
{
BusState *child;
qdev_printf("VAR_1: %s, id \"%s\"\n", VAR_1->info->name,
VAR_1->id ? VAR_1->id : "");
VAR_2 += 2;
if (VAR_1->num_gpio_in) {
qdev_printf("gpio-in %d\n", VAR_1->num_gpio_in);
}
if (VAR_1->num_gpio_out) {
qdev_printf("gpio-out %d\n", VAR_1->num_gpio_out);
}
qdev_print_props(VAR_0, VAR_1, VAR_1->info->props, "VAR_1", VAR_2);
qdev_print_props(VAR_0, VAR_1, VAR_1->parent_bus->info->props, "bus", VAR_2);
if (VAR_1->parent_bus->info->print_dev)
VAR_1->parent_bus->info->print_dev(VAR_0, VAR_1, VAR_2);
LIST_FOREACH(child, &VAR_1->child_bus, sibling) {
qbus_print(VAR_0, child, VAR_2);
}
}
| [
"static void FUNC_0(Monitor *VAR_0, DeviceState *VAR_1, int VAR_2)\n{",
"BusState *child;",
"qdev_printf(\"VAR_1: %s, id \\\"%s\\\"\\n\", VAR_1->info->name,\nVAR_1->id ? VAR_1->id : \"\");",
"VAR_2 += 2;",
"if (VAR_1->num_gpio_in) {",
"qdev_printf(\"gpio-in %d\\n\", VAR_1->num_gpio_in);",
"}",
"if (VAR_1->num_gpio_out) {",
"qdev_printf(\"gpio-out %d\\n\", VAR_1->num_gpio_out);",
"}",
"qdev_print_props(VAR_0, VAR_1, VAR_1->info->props, \"VAR_1\", VAR_2);",
"qdev_print_props(VAR_0, VAR_1, VAR_1->parent_bus->info->props, \"bus\", VAR_2);",
"if (VAR_1->parent_bus->info->print_dev)\nVAR_1->parent_bus->info->print_dev(VAR_0, VAR_1, VAR_2);",
"LIST_FOREACH(child, &VAR_1->child_bus, sibling) {",
"qbus_print(VAR_0, child, VAR_2);",
"}",
"}"
] | [
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
]
] |
24,927 | static int qcow2_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
int64_t pos)
{
BDRVQcow2State *s = bs->opaque;
bool zero_beyond_eof = bs->zero_beyond_eof;
int ret;
BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_LOAD);
bs->zero_beyond_eof = false;
ret = bdrv_preadv(bs, qcow2_vm_state_offset(s) + pos, qiov);
bs->zero_beyond_eof = zero_beyond_eof;
return ret;
}
| false | qemu | 734a77584ae13d36113a7a7cd8b54beb49a8a48e | static int qcow2_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
int64_t pos)
{
BDRVQcow2State *s = bs->opaque;
bool zero_beyond_eof = bs->zero_beyond_eof;
int ret;
BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_LOAD);
bs->zero_beyond_eof = false;
ret = bdrv_preadv(bs, qcow2_vm_state_offset(s) + pos, qiov);
bs->zero_beyond_eof = zero_beyond_eof;
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, QEMUIOVector *VAR_1,
int64_t VAR_2)
{
BDRVQcow2State *s = VAR_0->opaque;
bool zero_beyond_eof = VAR_0->zero_beyond_eof;
int VAR_3;
BLKDBG_EVENT(VAR_0->file, BLKDBG_VMSTATE_LOAD);
VAR_0->zero_beyond_eof = false;
VAR_3 = bdrv_preadv(VAR_0, qcow2_vm_state_offset(s) + VAR_2, VAR_1);
VAR_0->zero_beyond_eof = zero_beyond_eof;
return VAR_3;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, QEMUIOVector *VAR_1,\nint64_t VAR_2)\n{",
"BDRVQcow2State *s = VAR_0->opaque;",
"bool zero_beyond_eof = VAR_0->zero_beyond_eof;",
"int VAR_3;",
"BLKDBG_EVENT(VAR_0->file, BLKDBG_VMSTATE_LOAD);",
"VAR_0->zero_beyond_eof = false;",
"VAR_3 = bdrv_preadv(VAR_0, qcow2_vm_state_offset(s) + VAR_2, VAR_1);",
"VAR_0->zero_beyond_eof = zero_beyond_eof;",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
]
] |
24,928 | static av_cold int g726_encode_init(AVCodecContext *avctx)
{
G726Context* c = avctx->priv_data;
if (avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL &&
avctx->sample_rate != 8000) {
av_log(avctx, AV_LOG_ERROR, "Sample rates other than 8kHz are not "
"allowed when the compliance level is higher than unofficial. "
"Resample or reduce the compliance level.\n");
return AVERROR(EINVAL);
}
av_assert0(avctx->sample_rate > 0);
if(avctx->channels != 1){
av_log(avctx, AV_LOG_ERROR, "Only mono is supported\n");
return -1;
}
if (avctx->bit_rate % avctx->sample_rate) {
av_log(avctx, AV_LOG_ERROR, "Bitrate - Samplerate combination is invalid\n");
return AVERROR(EINVAL);
}
c->code_size = (avctx->bit_rate + avctx->sample_rate/2) / avctx->sample_rate;
if (c->code_size < 2 || c->code_size > 5) {
av_log(avctx, AV_LOG_ERROR, "Invalid number of bits %d\n", c->code_size);
return AVERROR(EINVAL);
}
avctx->bits_per_coded_sample = c->code_size;
g726_reset(c, c->code_size - 2);
avctx->coded_frame = avcodec_alloc_frame();
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
avctx->coded_frame->key_frame = 1;
/* select a frame size that will end on a byte boundary and have a size of
approximately 1024 bytes */
avctx->frame_size = ((int[]){ 4096, 2736, 2048, 1640 })[c->code_size - 2];
return 0;
}
| false | FFmpeg | 50969c0f46ce60a32c292b8375b4a442cc908c64 | static av_cold int g726_encode_init(AVCodecContext *avctx)
{
G726Context* c = avctx->priv_data;
if (avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL &&
avctx->sample_rate != 8000) {
av_log(avctx, AV_LOG_ERROR, "Sample rates other than 8kHz are not "
"allowed when the compliance level is higher than unofficial. "
"Resample or reduce the compliance level.\n");
return AVERROR(EINVAL);
}
av_assert0(avctx->sample_rate > 0);
if(avctx->channels != 1){
av_log(avctx, AV_LOG_ERROR, "Only mono is supported\n");
return -1;
}
if (avctx->bit_rate % avctx->sample_rate) {
av_log(avctx, AV_LOG_ERROR, "Bitrate - Samplerate combination is invalid\n");
return AVERROR(EINVAL);
}
c->code_size = (avctx->bit_rate + avctx->sample_rate/2) / avctx->sample_rate;
if (c->code_size < 2 || c->code_size > 5) {
av_log(avctx, AV_LOG_ERROR, "Invalid number of bits %d\n", c->code_size);
return AVERROR(EINVAL);
}
avctx->bits_per_coded_sample = c->code_size;
g726_reset(c, c->code_size - 2);
avctx->coded_frame = avcodec_alloc_frame();
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
avctx->coded_frame->key_frame = 1;
avctx->frame_size = ((int[]){ 4096, 2736, 2048, 1640 })[c->code_size - 2];
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
G726Context* c = avctx->priv_data;
if (avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL &&
avctx->sample_rate != 8000) {
av_log(avctx, AV_LOG_ERROR, "Sample rates other than 8kHz are not "
"allowed when the compliance level is higher than unofficial. "
"Resample or reduce the compliance level.\n");
return AVERROR(EINVAL);
}
av_assert0(avctx->sample_rate > 0);
if(avctx->channels != 1){
av_log(avctx, AV_LOG_ERROR, "Only mono is supported\n");
return -1;
}
if (avctx->bit_rate % avctx->sample_rate) {
av_log(avctx, AV_LOG_ERROR, "Bitrate - Samplerate combination is invalid\n");
return AVERROR(EINVAL);
}
c->code_size = (avctx->bit_rate + avctx->sample_rate/2) / avctx->sample_rate;
if (c->code_size < 2 || c->code_size > 5) {
av_log(avctx, AV_LOG_ERROR, "Invalid number of bits %d\n", c->code_size);
return AVERROR(EINVAL);
}
avctx->bits_per_coded_sample = c->code_size;
g726_reset(c, c->code_size - 2);
avctx->coded_frame = avcodec_alloc_frame();
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
avctx->coded_frame->key_frame = 1;
avctx->frame_size = ((int[]){ 4096, 2736, 2048, 1640 })[c->code_size - 2];
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"G726Context* c = avctx->priv_data;",
"if (avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL &&\navctx->sample_rate != 8000) {",
"av_log(avctx, AV_LOG_ERROR, \"Sample rates other than 8kHz are not \"\n\"allowed when the compliance level is higher than unofficial. \"\n\"Resample or reduce the compliance level.\\n\");",
"return AVERROR(EINVAL);",
"}",
"av_assert0(avctx->sample_rate > 0);",
"if(avctx->channels != 1){",
"av_log(avctx, AV_LOG_ERROR, \"Only mono is supported\\n\");",
"return -1;",
"}",
"if (avctx->bit_rate % avctx->sample_rate) {",
"av_log(avctx, AV_LOG_ERROR, \"Bitrate - Samplerate combination is invalid\\n\");",
"return AVERROR(EINVAL);",
"}",
"c->code_size = (avctx->bit_rate + avctx->sample_rate/2) / avctx->sample_rate;",
"if (c->code_size < 2 || c->code_size > 5) {",
"av_log(avctx, AV_LOG_ERROR, \"Invalid number of bits %d\\n\", c->code_size);",
"return AVERROR(EINVAL);",
"}",
"avctx->bits_per_coded_sample = c->code_size;",
"g726_reset(c, c->code_size - 2);",
"avctx->coded_frame = avcodec_alloc_frame();",
"if (!avctx->coded_frame)\nreturn AVERROR(ENOMEM);",
"avctx->coded_frame->key_frame = 1;",
"avctx->frame_size = ((int[]){ 4096, 2736, 2048, 1640 })[c->code_size - 2];",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
13,
15,
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
63
],
[
65,
67
],
[
69
],
[
77
],
[
81
],
[
83
]
] |
24,929 | int qemu_acl_insert(qemu_acl *acl,
int deny,
const char *match,
int index)
{
qemu_acl_entry *entry;
qemu_acl_entry *tmp;
int i = 0;
if (index <= 0)
return -1;
if (index >= acl->nentries)
return qemu_acl_append(acl, deny, match);
entry = qemu_malloc(sizeof(*entry));
entry->match = qemu_strdup(match);
entry->deny = deny;
TAILQ_FOREACH(tmp, &acl->entries, next) {
i++;
if (i == index) {
TAILQ_INSERT_BEFORE(tmp, entry, next);
acl->nentries++;
break;
}
}
return i;
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | int qemu_acl_insert(qemu_acl *acl,
int deny,
const char *match,
int index)
{
qemu_acl_entry *entry;
qemu_acl_entry *tmp;
int i = 0;
if (index <= 0)
return -1;
if (index >= acl->nentries)
return qemu_acl_append(acl, deny, match);
entry = qemu_malloc(sizeof(*entry));
entry->match = qemu_strdup(match);
entry->deny = deny;
TAILQ_FOREACH(tmp, &acl->entries, next) {
i++;
if (i == index) {
TAILQ_INSERT_BEFORE(tmp, entry, next);
acl->nentries++;
break;
}
}
return i;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(qemu_acl *VAR_0,
int VAR_1,
const char *VAR_2,
int VAR_3)
{
qemu_acl_entry *entry;
qemu_acl_entry *tmp;
int VAR_4 = 0;
if (VAR_3 <= 0)
return -1;
if (VAR_3 >= VAR_0->nentries)
return qemu_acl_append(VAR_0, VAR_1, VAR_2);
entry = qemu_malloc(sizeof(*entry));
entry->VAR_2 = qemu_strdup(VAR_2);
entry->VAR_1 = VAR_1;
TAILQ_FOREACH(tmp, &VAR_0->entries, next) {
VAR_4++;
if (VAR_4 == VAR_3) {
TAILQ_INSERT_BEFORE(tmp, entry, next);
VAR_0->nentries++;
break;
}
}
return VAR_4;
}
| [
"int FUNC_0(qemu_acl *VAR_0,\nint VAR_1,\nconst char *VAR_2,\nint VAR_3)\n{",
"qemu_acl_entry *entry;",
"qemu_acl_entry *tmp;",
"int VAR_4 = 0;",
"if (VAR_3 <= 0)\nreturn -1;",
"if (VAR_3 >= VAR_0->nentries)\nreturn qemu_acl_append(VAR_0, VAR_1, VAR_2);",
"entry = qemu_malloc(sizeof(*entry));",
"entry->VAR_2 = qemu_strdup(VAR_2);",
"entry->VAR_1 = VAR_1;",
"TAILQ_FOREACH(tmp, &VAR_0->entries, next) {",
"VAR_4++;",
"if (VAR_4 == VAR_3) {",
"TAILQ_INSERT_BEFORE(tmp, entry, next);",
"VAR_0->nentries++;",
"break;",
"}",
"}",
"return VAR_4;",
"}"
] | [
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
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
]
] |
24,930 | int64_t bdrv_get_block_status(BlockDriverState *bs,
int64_t sector_num,
int nb_sectors, int *pnum,
BlockDriverState **file)
{
return bdrv_get_block_status_above(bs, backing_bs(bs),
sector_num, nb_sectors, pnum, file);
}
| false | qemu | 237d78f8fc62e62f62246883ecf62e44ed35fb80 | int64_t bdrv_get_block_status(BlockDriverState *bs,
int64_t sector_num,
int nb_sectors, int *pnum,
BlockDriverState **file)
{
return bdrv_get_block_status_above(bs, backing_bs(bs),
sector_num, nb_sectors, pnum, file);
}
| {
"code": [],
"line_no": []
} | int64_t FUNC_0(BlockDriverState *bs,
int64_t sector_num,
int nb_sectors, int *pnum,
BlockDriverState **file)
{
return bdrv_get_block_status_above(bs, backing_bs(bs),
sector_num, nb_sectors, pnum, file);
}
| [
"int64_t FUNC_0(BlockDriverState *bs,\nint64_t sector_num,\nint nb_sectors, int *pnum,\nBlockDriverState **file)\n{",
"return bdrv_get_block_status_above(bs, backing_bs(bs),\nsector_num, nb_sectors, pnum, file);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11,
13
],
[
15
]
] |
24,931 | static int vmdk_probe(const uint8_t *buf, int buf_size, const char *filename)
{
uint32_t magic;
if (buf_size < 4)
return 0;
magic = be32_to_cpu(*(uint32_t *)buf);
if (magic == VMDK3_MAGIC ||
magic == VMDK4_MAGIC) {
return 100;
} else {
const char *p = (const char *)buf;
const char *end = p + buf_size;
while (p < end) {
if (*p == '#') {
/* skip comment line */
while (p < end && *p != '\n') {
p++;
}
p++;
continue;
}
if (*p == ' ') {
while (p < end && *p == ' ') {
p++;
}
/* skip '\r' if windows line endings used. */
if (p < end && *p == '\r') {
p++;
}
/* only accept blank lines before 'version=' line */
if (p == end || *p != '\n') {
return 0;
}
p++;
continue;
}
if (end - p >= strlen("version=X\n")) {
if (strncmp("version=1\n", p, strlen("version=1\n")) == 0 ||
strncmp("version=2\n", p, strlen("version=2\n")) == 0) {
return 100;
}
}
if (end - p >= strlen("version=X\r\n")) {
if (strncmp("version=1\r\n", p, strlen("version=1\r\n")) == 0 ||
strncmp("version=2\r\n", p, strlen("version=2\r\n")) == 0) {
return 100;
}
}
return 0;
}
return 0;
}
}
| false | qemu | ae261c86aaed62e7acddafab8262a2bf286d40b7 | static int vmdk_probe(const uint8_t *buf, int buf_size, const char *filename)
{
uint32_t magic;
if (buf_size < 4)
return 0;
magic = be32_to_cpu(*(uint32_t *)buf);
if (magic == VMDK3_MAGIC ||
magic == VMDK4_MAGIC) {
return 100;
} else {
const char *p = (const char *)buf;
const char *end = p + buf_size;
while (p < end) {
if (*p == '#') {
while (p < end && *p != '\n') {
p++;
}
p++;
continue;
}
if (*p == ' ') {
while (p < end && *p == ' ') {
p++;
}
if (p < end && *p == '\r') {
p++;
}
if (p == end || *p != '\n') {
return 0;
}
p++;
continue;
}
if (end - p >= strlen("version=X\n")) {
if (strncmp("version=1\n", p, strlen("version=1\n")) == 0 ||
strncmp("version=2\n", p, strlen("version=2\n")) == 0) {
return 100;
}
}
if (end - p >= strlen("version=X\r\n")) {
if (strncmp("version=1\r\n", p, strlen("version=1\r\n")) == 0 ||
strncmp("version=2\r\n", p, strlen("version=2\r\n")) == 0) {
return 100;
}
}
return 0;
}
return 0;
}
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(const uint8_t *VAR_0, int VAR_1, const char *VAR_2)
{
uint32_t magic;
if (VAR_1 < 4)
return 0;
magic = be32_to_cpu(*(uint32_t *)VAR_0);
if (magic == VMDK3_MAGIC ||
magic == VMDK4_MAGIC) {
return 100;
} else {
const char *VAR_3 = (const char *)VAR_0;
const char *VAR_4 = VAR_3 + VAR_1;
while (VAR_3 < VAR_4) {
if (*VAR_3 == '#') {
while (VAR_3 < VAR_4 && *VAR_3 != '\n') {
VAR_3++;
}
VAR_3++;
continue;
}
if (*VAR_3 == ' ') {
while (VAR_3 < VAR_4 && *VAR_3 == ' ') {
VAR_3++;
}
if (VAR_3 < VAR_4 && *VAR_3 == '\r') {
VAR_3++;
}
if (VAR_3 == VAR_4 || *VAR_3 != '\n') {
return 0;
}
VAR_3++;
continue;
}
if (VAR_4 - VAR_3 >= strlen("version=X\n")) {
if (strncmp("version=1\n", VAR_3, strlen("version=1\n")) == 0 ||
strncmp("version=2\n", VAR_3, strlen("version=2\n")) == 0) {
return 100;
}
}
if (VAR_4 - VAR_3 >= strlen("version=X\r\n")) {
if (strncmp("version=1\r\n", VAR_3, strlen("version=1\r\n")) == 0 ||
strncmp("version=2\r\n", VAR_3, strlen("version=2\r\n")) == 0) {
return 100;
}
}
return 0;
}
return 0;
}
}
| [
"static int FUNC_0(const uint8_t *VAR_0, int VAR_1, const char *VAR_2)\n{",
"uint32_t magic;",
"if (VAR_1 < 4)\nreturn 0;",
"magic = be32_to_cpu(*(uint32_t *)VAR_0);",
"if (magic == VMDK3_MAGIC ||\nmagic == VMDK4_MAGIC) {",
"return 100;",
"} else {",
"const char *VAR_3 = (const char *)VAR_0;",
"const char *VAR_4 = VAR_3 + VAR_1;",
"while (VAR_3 < VAR_4) {",
"if (*VAR_3 == '#') {",
"while (VAR_3 < VAR_4 && *VAR_3 != '\\n') {",
"VAR_3++;",
"}",
"VAR_3++;",
"continue;",
"}",
"if (*VAR_3 == ' ') {",
"while (VAR_3 < VAR_4 && *VAR_3 == ' ') {",
"VAR_3++;",
"}",
"if (VAR_3 < VAR_4 && *VAR_3 == '\\r') {",
"VAR_3++;",
"}",
"if (VAR_3 == VAR_4 || *VAR_3 != '\\n') {",
"return 0;",
"}",
"VAR_3++;",
"continue;",
"}",
"if (VAR_4 - VAR_3 >= strlen(\"version=X\\n\")) {",
"if (strncmp(\"version=1\\n\", VAR_3, strlen(\"version=1\\n\")) == 0 ||\nstrncmp(\"version=2\\n\", VAR_3, strlen(\"version=2\\n\")) == 0) {",
"return 100;",
"}",
"}",
"if (VAR_4 - VAR_3 >= strlen(\"version=X\\r\\n\")) {",
"if (strncmp(\"version=1\\r\\n\", VAR_3, strlen(\"version=1\\r\\n\")) == 0 ||\nstrncmp(\"version=2\\r\\n\", VAR_3, strlen(\"version=2\\r\\n\")) == 0) {",
"return 100;",
"}",
"}",
"return 0;",
"}",
"return 0;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89,
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
]
] |
24,932 | static int write_elf64_note(DumpState *s)
{
Elf64_Phdr phdr;
int endian = s->dump_info.d_endian;
target_phys_addr_t begin = s->memory_offset - s->note_size;
int ret;
memset(&phdr, 0, sizeof(Elf64_Phdr));
phdr.p_type = cpu_convert_to_target32(PT_NOTE, endian);
phdr.p_offset = cpu_convert_to_target64(begin, endian);
phdr.p_paddr = 0;
phdr.p_filesz = cpu_convert_to_target64(s->note_size, endian);
phdr.p_memsz = cpu_convert_to_target64(s->note_size, endian);
phdr.p_vaddr = 0;
ret = fd_write_vmcore(&phdr, sizeof(Elf64_Phdr), s);
if (ret < 0) {
dump_error(s, "dump: failed to write program header table.\n");
return -1;
}
return 0;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static int write_elf64_note(DumpState *s)
{
Elf64_Phdr phdr;
int endian = s->dump_info.d_endian;
target_phys_addr_t begin = s->memory_offset - s->note_size;
int ret;
memset(&phdr, 0, sizeof(Elf64_Phdr));
phdr.p_type = cpu_convert_to_target32(PT_NOTE, endian);
phdr.p_offset = cpu_convert_to_target64(begin, endian);
phdr.p_paddr = 0;
phdr.p_filesz = cpu_convert_to_target64(s->note_size, endian);
phdr.p_memsz = cpu_convert_to_target64(s->note_size, endian);
phdr.p_vaddr = 0;
ret = fd_write_vmcore(&phdr, sizeof(Elf64_Phdr), s);
if (ret < 0) {
dump_error(s, "dump: failed to write program header table.\n");
return -1;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(DumpState *VAR_0)
{
Elf64_Phdr phdr;
int VAR_1 = VAR_0->dump_info.d_endian;
target_phys_addr_t begin = VAR_0->memory_offset - VAR_0->note_size;
int VAR_2;
memset(&phdr, 0, sizeof(Elf64_Phdr));
phdr.p_type = cpu_convert_to_target32(PT_NOTE, VAR_1);
phdr.p_offset = cpu_convert_to_target64(begin, VAR_1);
phdr.p_paddr = 0;
phdr.p_filesz = cpu_convert_to_target64(VAR_0->note_size, VAR_1);
phdr.p_memsz = cpu_convert_to_target64(VAR_0->note_size, VAR_1);
phdr.p_vaddr = 0;
VAR_2 = fd_write_vmcore(&phdr, sizeof(Elf64_Phdr), VAR_0);
if (VAR_2 < 0) {
dump_error(VAR_0, "dump: failed to write program header table.\n");
return -1;
}
return 0;
}
| [
"static int FUNC_0(DumpState *VAR_0)\n{",
"Elf64_Phdr phdr;",
"int VAR_1 = VAR_0->dump_info.d_endian;",
"target_phys_addr_t begin = VAR_0->memory_offset - VAR_0->note_size;",
"int VAR_2;",
"memset(&phdr, 0, sizeof(Elf64_Phdr));",
"phdr.p_type = cpu_convert_to_target32(PT_NOTE, VAR_1);",
"phdr.p_offset = cpu_convert_to_target64(begin, VAR_1);",
"phdr.p_paddr = 0;",
"phdr.p_filesz = cpu_convert_to_target64(VAR_0->note_size, VAR_1);",
"phdr.p_memsz = cpu_convert_to_target64(VAR_0->note_size, VAR_1);",
"phdr.p_vaddr = 0;",
"VAR_2 = fd_write_vmcore(&phdr, sizeof(Elf64_Phdr), VAR_0);",
"if (VAR_2 < 0) {",
"dump_error(VAR_0, \"dump: failed to write program header table.\\n\");",
"return -1;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
]
] |
24,934 | void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top)
{
assert(!bdrv_requests_pending(bs_top));
assert(!bdrv_requests_pending(bs_new));
bdrv_ref(bs_top);
change_parent_backing_link(bs_top, bs_new);
bdrv_set_backing_hd(bs_new, bs_top);
bdrv_unref(bs_top);
/* bs_new is now referenced by its new parents, we don't need the
* additional reference any more. */
bdrv_unref(bs_new);
}
| false | qemu | dd65a52e4aa4a0adfedf0ed9a35da1960f359fe1 | void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top)
{
assert(!bdrv_requests_pending(bs_top));
assert(!bdrv_requests_pending(bs_new));
bdrv_ref(bs_top);
change_parent_backing_link(bs_top, bs_new);
bdrv_set_backing_hd(bs_new, bs_top);
bdrv_unref(bs_top);
bdrv_unref(bs_new);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1)
{
assert(!bdrv_requests_pending(VAR_1));
assert(!bdrv_requests_pending(VAR_0));
bdrv_ref(VAR_1);
change_parent_backing_link(VAR_1, VAR_0);
bdrv_set_backing_hd(VAR_0, VAR_1);
bdrv_unref(VAR_1);
bdrv_unref(VAR_0);
}
| [
"void FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1)\n{",
"assert(!bdrv_requests_pending(VAR_1));",
"assert(!bdrv_requests_pending(VAR_0));",
"bdrv_ref(VAR_1);",
"change_parent_backing_link(VAR_1, VAR_0);",
"bdrv_set_backing_hd(VAR_0, VAR_1);",
"bdrv_unref(VAR_1);",
"bdrv_unref(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
27
],
[
29
]
] |
24,936 | static void restore_sigcontext(CPUSH4State *regs, struct target_sigcontext *sc,
target_ulong *r0_p)
{
int i;
#define COPY(x) __get_user(regs->x, &sc->sc_##x)
COPY(gregs[1]);
COPY(gregs[2]); COPY(gregs[3]);
COPY(gregs[4]); COPY(gregs[5]);
COPY(gregs[6]); COPY(gregs[7]);
COPY(gregs[8]); COPY(gregs[9]);
COPY(gregs[10]); COPY(gregs[11]);
COPY(gregs[12]); COPY(gregs[13]);
COPY(gregs[14]); COPY(gregs[15]);
COPY(gbr); COPY(mach);
COPY(macl); COPY(pr);
COPY(sr); COPY(pc);
#undef COPY
for (i=0; i<16; i++) {
__get_user(regs->fregs[i], &sc->sc_fpregs[i]);
}
__get_user(regs->fpscr, &sc->sc_fpscr);
__get_user(regs->fpul, &sc->sc_fpul);
regs->tra = -1; /* disable syscall checks */
__get_user(*r0_p, &sc->sc_gregs[0]);
}
| false | qemu | ba41249678f8c1504bf07706ddb0eda0d36cccc2 | static void restore_sigcontext(CPUSH4State *regs, struct target_sigcontext *sc,
target_ulong *r0_p)
{
int i;
#define COPY(x) __get_user(regs->x, &sc->sc_##x)
COPY(gregs[1]);
COPY(gregs[2]); COPY(gregs[3]);
COPY(gregs[4]); COPY(gregs[5]);
COPY(gregs[6]); COPY(gregs[7]);
COPY(gregs[8]); COPY(gregs[9]);
COPY(gregs[10]); COPY(gregs[11]);
COPY(gregs[12]); COPY(gregs[13]);
COPY(gregs[14]); COPY(gregs[15]);
COPY(gbr); COPY(mach);
COPY(macl); COPY(pr);
COPY(sr); COPY(pc);
#undef COPY
for (i=0; i<16; i++) {
__get_user(regs->fregs[i], &sc->sc_fpregs[i]);
}
__get_user(regs->fpscr, &sc->sc_fpscr);
__get_user(regs->fpul, &sc->sc_fpul);
regs->tra = -1;
__get_user(*r0_p, &sc->sc_gregs[0]);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(CPUSH4State *VAR_0, struct target_sigcontext *VAR_1,
target_ulong *VAR_2)
{
int VAR_3;
#define COPY(x) __get_user(VAR_0->x, &VAR_1->sc_##x)
COPY(gregs[1]);
COPY(gregs[2]); COPY(gregs[3]);
COPY(gregs[4]); COPY(gregs[5]);
COPY(gregs[6]); COPY(gregs[7]);
COPY(gregs[8]); COPY(gregs[9]);
COPY(gregs[10]); COPY(gregs[11]);
COPY(gregs[12]); COPY(gregs[13]);
COPY(gregs[14]); COPY(gregs[15]);
COPY(gbr); COPY(mach);
COPY(macl); COPY(pr);
COPY(sr); COPY(pc);
#undef COPY
for (VAR_3=0; VAR_3<16; VAR_3++) {
__get_user(VAR_0->fregs[VAR_3], &VAR_1->sc_fpregs[VAR_3]);
}
__get_user(VAR_0->fpscr, &VAR_1->sc_fpscr);
__get_user(VAR_0->fpul, &VAR_1->sc_fpul);
VAR_0->tra = -1;
__get_user(*VAR_2, &VAR_1->sc_gregs[0]);
}
| [
"static void FUNC_0(CPUSH4State *VAR_0, struct target_sigcontext *VAR_1,\ntarget_ulong *VAR_2)\n{",
"int VAR_3;",
"#define COPY(x) __get_user(VAR_0->x, &VAR_1->sc_##x)\nCOPY(gregs[1]);",
"COPY(gregs[2]); COPY(gregs[3]);",
"COPY(gregs[4]); COPY(gregs[5]);",
"COPY(gregs[6]); COPY(gregs[7]);",
"COPY(gregs[8]); COPY(gregs[9]);",
"COPY(gregs[10]); COPY(gregs[11]);",
"COPY(gregs[12]); COPY(gregs[13]);",
"COPY(gregs[14]); COPY(gregs[15]);",
"COPY(gbr); COPY(mach);",
"COPY(macl); COPY(pr);",
"COPY(sr); COPY(pc);",
"#undef COPY\nfor (VAR_3=0; VAR_3<16; VAR_3++) {",
"__get_user(VAR_0->fregs[VAR_3], &VAR_1->sc_fpregs[VAR_3]);",
"}",
"__get_user(VAR_0->fpscr, &VAR_1->sc_fpscr);",
"__get_user(VAR_0->fpul, &VAR_1->sc_fpul);",
"VAR_0->tra = -1;",
"__get_user(*VAR_2, &VAR_1->sc_gregs[0]);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
]
] |
24,940 | static void vtd_update_iotlb(IntelIOMMUState *s, uint16_t source_id,
uint16_t domain_id, hwaddr addr, uint64_t slpte,
bool read_flags, bool write_flags)
{
VTDIOTLBEntry *entry = g_malloc(sizeof(*entry));
uint64_t *key = g_malloc(sizeof(*key));
uint64_t gfn = addr >> VTD_PAGE_SHIFT_4K;
VTD_DPRINTF(CACHE, "update iotlb sid 0x%"PRIx16 " gpa 0x%"PRIx64
" slpte 0x%"PRIx64 " did 0x%"PRIx16, source_id, addr, slpte,
domain_id);
if (g_hash_table_size(s->iotlb) >= VTD_IOTLB_MAX_SIZE) {
VTD_DPRINTF(CACHE, "iotlb exceeds size limit, forced to reset");
vtd_reset_iotlb(s);
}
entry->gfn = gfn;
entry->domain_id = domain_id;
entry->slpte = slpte;
entry->read_flags = read_flags;
entry->write_flags = write_flags;
*key = gfn | ((uint64_t)(source_id) << VTD_IOTLB_SID_SHIFT);
g_hash_table_replace(s->iotlb, key, entry);
}
| false | qemu | d66b969b0d9c8eefdcbff4b48535b0fe1501d139 | static void vtd_update_iotlb(IntelIOMMUState *s, uint16_t source_id,
uint16_t domain_id, hwaddr addr, uint64_t slpte,
bool read_flags, bool write_flags)
{
VTDIOTLBEntry *entry = g_malloc(sizeof(*entry));
uint64_t *key = g_malloc(sizeof(*key));
uint64_t gfn = addr >> VTD_PAGE_SHIFT_4K;
VTD_DPRINTF(CACHE, "update iotlb sid 0x%"PRIx16 " gpa 0x%"PRIx64
" slpte 0x%"PRIx64 " did 0x%"PRIx16, source_id, addr, slpte,
domain_id);
if (g_hash_table_size(s->iotlb) >= VTD_IOTLB_MAX_SIZE) {
VTD_DPRINTF(CACHE, "iotlb exceeds size limit, forced to reset");
vtd_reset_iotlb(s);
}
entry->gfn = gfn;
entry->domain_id = domain_id;
entry->slpte = slpte;
entry->read_flags = read_flags;
entry->write_flags = write_flags;
*key = gfn | ((uint64_t)(source_id) << VTD_IOTLB_SID_SHIFT);
g_hash_table_replace(s->iotlb, key, entry);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(IntelIOMMUState *VAR_0, uint16_t VAR_1,
uint16_t VAR_2, hwaddr VAR_3, uint64_t VAR_4,
bool VAR_5, bool VAR_6)
{
VTDIOTLBEntry *entry = g_malloc(sizeof(*entry));
uint64_t *key = g_malloc(sizeof(*key));
uint64_t gfn = VAR_3 >> VTD_PAGE_SHIFT_4K;
VTD_DPRINTF(CACHE, "update iotlb sid 0x%"PRIx16 " gpa 0x%"PRIx64
" VAR_4 0x%"PRIx64 " did 0x%"PRIx16, VAR_1, VAR_3, VAR_4,
VAR_2);
if (g_hash_table_size(VAR_0->iotlb) >= VTD_IOTLB_MAX_SIZE) {
VTD_DPRINTF(CACHE, "iotlb exceeds size limit, forced to reset");
vtd_reset_iotlb(VAR_0);
}
entry->gfn = gfn;
entry->VAR_2 = VAR_2;
entry->VAR_4 = VAR_4;
entry->VAR_5 = VAR_5;
entry->VAR_6 = VAR_6;
*key = gfn | ((uint64_t)(VAR_1) << VTD_IOTLB_SID_SHIFT);
g_hash_table_replace(VAR_0->iotlb, key, entry);
}
| [
"static void FUNC_0(IntelIOMMUState *VAR_0, uint16_t VAR_1,\nuint16_t VAR_2, hwaddr VAR_3, uint64_t VAR_4,\nbool VAR_5, bool VAR_6)\n{",
"VTDIOTLBEntry *entry = g_malloc(sizeof(*entry));",
"uint64_t *key = g_malloc(sizeof(*key));",
"uint64_t gfn = VAR_3 >> VTD_PAGE_SHIFT_4K;",
"VTD_DPRINTF(CACHE, \"update iotlb sid 0x%\"PRIx16 \" gpa 0x%\"PRIx64\n\" VAR_4 0x%\"PRIx64 \" did 0x%\"PRIx16, VAR_1, VAR_3, VAR_4,\nVAR_2);",
"if (g_hash_table_size(VAR_0->iotlb) >= VTD_IOTLB_MAX_SIZE) {",
"VTD_DPRINTF(CACHE, \"iotlb exceeds size limit, forced to reset\");",
"vtd_reset_iotlb(VAR_0);",
"}",
"entry->gfn = gfn;",
"entry->VAR_2 = VAR_2;",
"entry->VAR_4 = VAR_4;",
"entry->VAR_5 = VAR_5;",
"entry->VAR_6 = VAR_6;",
"*key = gfn | ((uint64_t)(VAR_1) << VTD_IOTLB_SID_SHIFT);",
"g_hash_table_replace(VAR_0->iotlb, key, entry);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17,
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
]
] |
24,941 | static void armv7m_nvic_init(SysBusDevice *dev)
{
nvic_state *s= FROM_SYSBUSGIC(nvic_state, dev);
CPUState *env;
env = qdev_get_prop_ptr(&dev->qdev, "cpu");
gic_init(&s->gic);
cpu_register_physical_memory(0xe000e000, 0x1000, s->gic.iomemtype);
s->systick.timer = qemu_new_timer(vm_clock, systick_timer_tick, s);
if (env->v7m.nvic)
hw_error("CPU can only have one NVIC\n");
env->v7m.nvic = s;
register_savevm("armv7m_nvic", -1, 1, nvic_save, nvic_load, s);
}
| false | qemu | bdb11366b9370e97fb436444c697c01fe839dc11 | static void armv7m_nvic_init(SysBusDevice *dev)
{
nvic_state *s= FROM_SYSBUSGIC(nvic_state, dev);
CPUState *env;
env = qdev_get_prop_ptr(&dev->qdev, "cpu");
gic_init(&s->gic);
cpu_register_physical_memory(0xe000e000, 0x1000, s->gic.iomemtype);
s->systick.timer = qemu_new_timer(vm_clock, systick_timer_tick, s);
if (env->v7m.nvic)
hw_error("CPU can only have one NVIC\n");
env->v7m.nvic = s;
register_savevm("armv7m_nvic", -1, 1, nvic_save, nvic_load, s);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(SysBusDevice *VAR_0)
{
nvic_state *s= FROM_SYSBUSGIC(nvic_state, VAR_0);
CPUState *env;
env = qdev_get_prop_ptr(&VAR_0->qdev, "cpu");
gic_init(&s->gic);
cpu_register_physical_memory(0xe000e000, 0x1000, s->gic.iomemtype);
s->systick.timer = qemu_new_timer(vm_clock, systick_timer_tick, s);
if (env->v7m.nvic)
hw_error("CPU can only have one NVIC\n");
env->v7m.nvic = s;
register_savevm("armv7m_nvic", -1, 1, nvic_save, nvic_load, s);
}
| [
"static void FUNC_0(SysBusDevice *VAR_0)\n{",
"nvic_state *s= FROM_SYSBUSGIC(nvic_state, VAR_0);",
"CPUState *env;",
"env = qdev_get_prop_ptr(&VAR_0->qdev, \"cpu\");",
"gic_init(&s->gic);",
"cpu_register_physical_memory(0xe000e000, 0x1000, s->gic.iomemtype);",
"s->systick.timer = qemu_new_timer(vm_clock, systick_timer_tick, s);",
"if (env->v7m.nvic)\nhw_error(\"CPU can only have one NVIC\\n\");",
"env->v7m.nvic = s;",
"register_savevm(\"armv7m_nvic\", -1, 1, nvic_save, nvic_load, s);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
]
] |
24,942 | lookup_scalar(const OptsVisitor *ov, const char *name, Error **errp)
{
if (ov->repeated_opts == NULL) {
GQueue *list;
/* the last occurrence of any QemuOpt takes effect when queried by name
*/
list = lookup_distinct(ov, name, errp);
return list ? g_queue_peek_tail(list) : NULL;
}
return g_queue_peek_head(ov->repeated_opts);
}
| false | qemu | d95704341280fc521dc2b16bbbc5858f6647e2c3 | lookup_scalar(const OptsVisitor *ov, const char *name, Error **errp)
{
if (ov->repeated_opts == NULL) {
GQueue *list;
list = lookup_distinct(ov, name, errp);
return list ? g_queue_peek_tail(list) : NULL;
}
return g_queue_peek_head(ov->repeated_opts);
}
| {
"code": [],
"line_no": []
} | FUNC_0(const OptsVisitor *VAR_0, const char *VAR_1, Error **VAR_2)
{
if (VAR_0->repeated_opts == NULL) {
GQueue *list;
list = lookup_distinct(VAR_0, VAR_1, VAR_2);
return list ? g_queue_peek_tail(list) : NULL;
}
return g_queue_peek_head(VAR_0->repeated_opts);
}
| [
"FUNC_0(const OptsVisitor *VAR_0, const char *VAR_1, Error **VAR_2)\n{",
"if (VAR_0->repeated_opts == NULL) {",
"GQueue *list;",
"list = lookup_distinct(VAR_0, VAR_1, VAR_2);",
"return list ? g_queue_peek_tail(list) : NULL;",
"}",
"return g_queue_peek_head(VAR_0->repeated_opts);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
24,943 | static void hextile_enc_cord(uint8_t *ptr, int x, int y, int w, int h)
{
ptr[0] = ((x & 0x0F) << 4) | (y & 0x0F);
ptr[1] = (((w - 1) & 0x0F) << 4) | ((h - 1) & 0x0F);
}
| false | qemu | 245f7b51c0ea04fb2224b1127430a096c91aee70 | static void hextile_enc_cord(uint8_t *ptr, int x, int y, int w, int h)
{
ptr[0] = ((x & 0x0F) << 4) | (y & 0x0F);
ptr[1] = (((w - 1) & 0x0F) << 4) | ((h - 1) & 0x0F);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint8_t *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4)
{
VAR_0[0] = ((VAR_1 & 0x0F) << 4) | (VAR_2 & 0x0F);
VAR_0[1] = (((VAR_3 - 1) & 0x0F) << 4) | ((VAR_4 - 1) & 0x0F);
}
| [
"static void FUNC_0(uint8_t *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4)\n{",
"VAR_0[0] = ((VAR_1 & 0x0F) << 4) | (VAR_2 & 0x0F);",
"VAR_0[1] = (((VAR_3 - 1) & 0x0F) << 4) | ((VAR_4 - 1) & 0x0F);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
24,944 | static void RENAME(hyscale_fast)(SwsContext *c, int16_t *dst,
int dstWidth, const uint8_t *src,
int srcW, int xInc)
{
int16_t *filterPos = c->hLumFilterPos;
int16_t *filter = c->hLumFilter;
void *mmx2FilterCode= c->lumMmx2FilterCode;
int i;
#if defined(PIC)
uint64_t ebxsave;
#endif
#if ARCH_X86_64
uint64_t retsave;
#endif
__asm__ volatile(
#if defined(PIC)
"mov %%"REG_b", %5 \n\t"
#if ARCH_X86_64
"mov -8(%%rsp), %%"REG_a" \n\t"
"mov %%"REG_a", %6 \n\t"
#endif
#else
#if ARCH_X86_64
"mov -8(%%rsp), %%"REG_a" \n\t"
"mov %%"REG_a", %5 \n\t"
#endif
#endif
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t" // i
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
#if ARCH_X86_64
#define CALL_MMX2_FILTER_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"movl (%%"REG_b", %%"REG_a"), %%esi \n\t"\
"add %%"REG_S", %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#else
#define CALL_MMX2_FILTER_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"addl (%%"REG_b", %%"REG_a"), %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#endif /* ARCH_X86_64 */
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
#if defined(PIC)
"mov %5, %%"REG_b" \n\t"
#if ARCH_X86_64
"mov %6, %%"REG_a" \n\t"
"mov %%"REG_a", -8(%%rsp) \n\t"
#endif
#else
#if ARCH_X86_64
"mov %5, %%"REG_a" \n\t"
"mov %%"REG_a", -8(%%rsp) \n\t"
#endif
#endif
:: "m" (src), "m" (dst), "m" (filter), "m" (filterPos),
"m" (mmx2FilterCode)
#if defined(PIC)
,"m" (ebxsave)
#endif
#if ARCH_X86_64
,"m"(retsave)
#endif
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
#if !defined(PIC)
,"%"REG_b
#endif
);
for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--)
dst[i] = src[srcW-1]*128;
}
| true | FFmpeg | 2254b559cbcfc0418135f09add37c0a5866b1981 | static void RENAME(hyscale_fast)(SwsContext *c, int16_t *dst,
int dstWidth, const uint8_t *src,
int srcW, int xInc)
{
int16_t *filterPos = c->hLumFilterPos;
int16_t *filter = c->hLumFilter;
void *mmx2FilterCode= c->lumMmx2FilterCode;
int i;
#if defined(PIC)
uint64_t ebxsave;
#endif
#if ARCH_X86_64
uint64_t retsave;
#endif
__asm__ volatile(
#if defined(PIC)
"mov %%"REG_b", %5 \n\t"
#if ARCH_X86_64
"mov -8(%%rsp), %%"REG_a" \n\t"
"mov %%"REG_a", %6 \n\t"
#endif
#else
#if ARCH_X86_64
"mov -8(%%rsp), %%"REG_a" \n\t"
"mov %%"REG_a", %5 \n\t"
#endif
#endif
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
#if ARCH_X86_64
#define CALL_MMX2_FILTER_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"movl (%%"REG_b", %%"REG_a"), %%esi \n\t"\
"add %%"REG_S", %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#else
#define CALL_MMX2_FILTER_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"addl (%%"REG_b", %%"REG_a"), %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#endif
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
#if defined(PIC)
"mov %5, %%"REG_b" \n\t"
#if ARCH_X86_64
"mov %6, %%"REG_a" \n\t"
"mov %%"REG_a", -8(%%rsp) \n\t"
#endif
#else
#if ARCH_X86_64
"mov %5, %%"REG_a" \n\t"
"mov %%"REG_a", -8(%%rsp) \n\t"
#endif
#endif
:: "m" (src), "m" (dst), "m" (filter), "m" (filterPos),
"m" (mmx2FilterCode)
#if defined(PIC)
,"m" (ebxsave)
#endif
#if ARCH_X86_64
,"m"(retsave)
#endif
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
#if !defined(PIC)
,"%"REG_b
#endif
);
for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--)
dst[i] = src[srcW-1]*128;
}
| {
"code": [
" int16_t *filterPos = c->hLumFilterPos;"
],
"line_no": [
9
]
} | static void FUNC_0(hyscale_fast)(SwsContext *c, int16_t *dst,
int dstWidth, const uint8_t *src,
int srcW, int xInc)
{
int16_t *filterPos = c->hLumFilterPos;
int16_t *filter = c->hLumFilter;
void *VAR_0= c->lumMmx2FilterCode;
int VAR_1;
#if defined(PIC)
uint64_t ebxsave;
#endif
#if ARCH_X86_64
uint64_t retsave;
#endif
__asm__ volatile(
#if defined(PIC)
"mov %%"REG_b", %5 \n\t"
#if ARCH_X86_64
"mov -8(%%rsp), %%"REG_a" \n\t"
"mov %%"REG_a", %6 \n\t"
#endif
#else
#if ARCH_X86_64
"mov -8(%%rsp), %%"REG_a" \n\t"
"mov %%"REG_a", %5 \n\t"
#endif
#endif
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
#if ARCH_X86_64
#define CALL_MMX2_FILTER_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"movl (%%"REG_b", %%"REG_a"), %%esi \n\t"\
"add %%"REG_S", %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#else
#define CALL_MMX2_FILTER_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"addl (%%"REG_b", %%"REG_a"), %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#endif
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
#if defined(PIC)
"mov %5, %%"REG_b" \n\t"
#if ARCH_X86_64
"mov %6, %%"REG_a" \n\t"
"mov %%"REG_a", -8(%%rsp) \n\t"
#endif
#else
#if ARCH_X86_64
"mov %5, %%"REG_a" \n\t"
"mov %%"REG_a", -8(%%rsp) \n\t"
#endif
#endif
:: "m" (src), "m" (dst), "m" (filter), "m" (filterPos),
"m" (VAR_0)
#if defined(PIC)
,"m" (ebxsave)
#endif
#if ARCH_X86_64
,"m"(retsave)
#endif
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
#if !defined(PIC)
,"%"REG_b
#endif
);
for (VAR_1=dstWidth-1; (VAR_1*xInc)>>16 >=srcW-1; VAR_1--)
dst[VAR_1] = src[srcW-1]*128;
}
| [
"static void FUNC_0(hyscale_fast)(SwsContext *c, int16_t *dst,\nint dstWidth, const uint8_t *src,\nint srcW, int xInc)\n{",
"int16_t *filterPos = c->hLumFilterPos;",
"int16_t *filter = c->hLumFilter;",
"void *VAR_0= c->lumMmx2FilterCode;",
"int VAR_1;",
"#if defined(PIC)\nuint64_t ebxsave;",
"#endif\n#if ARCH_X86_64\nuint64_t retsave;",
"#endif\n__asm__ volatile(\n#if defined(PIC)\n\"mov %%\"REG_b\", %5 \\n\\t\"\n#if ARCH_X86_64\n\"mov -8(%%rsp), %%\"REG_a\" \\n\\t\"\n\"mov %%\"REG_a\", %6 \\n\\t\"\n#endif\n#else\n#if ARCH_X86_64\n\"mov -8(%%rsp), %%\"REG_a\" \\n\\t\"\n\"mov %%\"REG_a\", %5 \\n\\t\"\n#endif\n#endif\n\"pxor %%mm7, %%mm7 \\n\\t\"\n\"mov %0, %%\"REG_c\" \\n\\t\"\n\"mov %1, %%\"REG_D\" \\n\\t\"\n\"mov %2, %%\"REG_d\" \\n\\t\"\n\"mov %3, %%\"REG_b\" \\n\\t\"\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\nPREFETCH\" (%%\"REG_c\") \\n\\t\"\nPREFETCH\" 32(%%\"REG_c\") \\n\\t\"\nPREFETCH\" 64(%%\"REG_c\") \\n\\t\"\n#if ARCH_X86_64\n#define CALL_MMX2_FILTER_CODE \\\n\"movl (%%\"REG_b\"), %%esi \\n\\t\"\\\n\"call *%4 \\n\\t\"\\\n\"movl (%%\"REG_b\", %%\"REG_a\"), %%esi \\n\\t\"\\\n\"add %%\"REG_S\", %%\"REG_c\" \\n\\t\"\\\n\"add %%\"REG_a\", %%\"REG_D\" \\n\\t\"\\\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\\\n#else\n#define CALL_MMX2_FILTER_CODE \\\n\"movl (%%\"REG_b\"), %%esi \\n\\t\"\\\n\"call *%4 \\n\\t\"\\\n\"addl (%%\"REG_b\", %%\"REG_a\"), %%\"REG_c\" \\n\\t\"\\\n\"add %%\"REG_a\", %%\"REG_D\" \\n\\t\"\\\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\\\n#endif\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\n#if defined(PIC)\n\"mov %5, %%\"REG_b\" \\n\\t\"\n#if ARCH_X86_64\n\"mov %6, %%\"REG_a\" \\n\\t\"\n\"mov %%\"REG_a\", -8(%%rsp) \\n\\t\"\n#endif\n#else\n#if ARCH_X86_64\n\"mov %5, %%\"REG_a\" \\n\\t\"\n\"mov %%\"REG_a\", -8(%%rsp) \\n\\t\"\n#endif\n#endif\n:: \"m\" (src), \"m\" (dst), \"m\" (filter), \"m\" (filterPos),\n\"m\" (VAR_0)\n#if defined(PIC)\n,\"m\" (ebxsave)\n#endif\n#if ARCH_X86_64\n,\"m\"(retsave)\n#endif\n: \"%\"REG_a, \"%\"REG_c, \"%\"REG_d, \"%\"REG_S, \"%\"REG_D\n#if !defined(PIC)\n,\"%\"REG_b\n#endif\n);",
"for (VAR_1=dstWidth-1; (VAR_1*xInc)>>16 >=srcW-1; VAR_1--)",
"dst[VAR_1] = src[srcW-1]*128;",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17,
19
],
[
21,
23,
25
],
[
27,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
77,
79,
81,
83,
85,
87,
89,
91,
95,
97,
99,
101,
103,
105,
107,
111,
115,
117,
119,
121,
123,
125,
127,
129,
133,
135,
137,
139,
141,
143,
145,
147,
149,
151,
153,
155,
157,
159,
161,
163,
165,
167,
169,
171,
173,
175,
177,
179,
181
],
[
185
],
[
187
],
[
189
]
] |
24,945 | static int decode_dc_progressive(MJpegDecodeContext *s, int16_t *block,
int component, int dc_index,
uint16_t *quant_matrix, int Al)
{
int val;
s->bdsp.clear_block(block);
val = mjpeg_decode_dc(s, dc_index);
if (val == 0xfffff) {
av_log(s->avctx, AV_LOG_ERROR, "error dc\n");
return AVERROR_INVALIDDATA;
}
val = (val * (quant_matrix[0] << Al)) + s->last_dc[component];
s->last_dc[component] = val;
block[0] = val;
return 0;
}
| true | FFmpeg | 40fa6a2fa2c255293a780a194eecae5df52644a1 | static int decode_dc_progressive(MJpegDecodeContext *s, int16_t *block,
int component, int dc_index,
uint16_t *quant_matrix, int Al)
{
int val;
s->bdsp.clear_block(block);
val = mjpeg_decode_dc(s, dc_index);
if (val == 0xfffff) {
av_log(s->avctx, AV_LOG_ERROR, "error dc\n");
return AVERROR_INVALIDDATA;
}
val = (val * (quant_matrix[0] << Al)) + s->last_dc[component];
s->last_dc[component] = val;
block[0] = val;
return 0;
}
| {
"code": [
" int val;"
],
"line_no": [
9
]
} | static int FUNC_0(MJpegDecodeContext *VAR_0, int16_t *VAR_1,
int VAR_2, int VAR_3,
uint16_t *VAR_4, int VAR_5)
{
int VAR_6;
VAR_0->bdsp.clear_block(VAR_1);
VAR_6 = mjpeg_decode_dc(VAR_0, VAR_3);
if (VAR_6 == 0xfffff) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "error dc\n");
return AVERROR_INVALIDDATA;
}
VAR_6 = (VAR_6 * (VAR_4[0] << VAR_5)) + VAR_0->last_dc[VAR_2];
VAR_0->last_dc[VAR_2] = VAR_6;
VAR_1[0] = VAR_6;
return 0;
}
| [
"static int FUNC_0(MJpegDecodeContext *VAR_0, int16_t *VAR_1,\nint VAR_2, int VAR_3,\nuint16_t *VAR_4, int VAR_5)\n{",
"int VAR_6;",
"VAR_0->bdsp.clear_block(VAR_1);",
"VAR_6 = mjpeg_decode_dc(VAR_0, VAR_3);",
"if (VAR_6 == 0xfffff) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"error dc\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_6 = (VAR_6 * (VAR_4[0] << VAR_5)) + VAR_0->last_dc[VAR_2];",
"VAR_0->last_dc[VAR_2] = VAR_6;",
"VAR_1[0] = VAR_6;",
"return 0;",
"}"
] | [
0,
1,
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
]
] |
24,946 | static void vga_screen_dump_common(VGAState *s, const char *filename,
int w, int h)
{
DisplayState *saved_ds, ds1, *ds = &ds1;
DisplayChangeListener dcl;
/* XXX: this is a little hackish */
vga_invalidate_display(s);
saved_ds = s->ds;
memset(ds, 0, sizeof(DisplayState));
memset(&dcl, 0, sizeof(DisplayChangeListener));
dcl.dpy_update = vga_save_dpy_update;
dcl.dpy_resize = vga_save_dpy_resize;
dcl.dpy_refresh = vga_save_dpy_refresh;
register_displaychangelistener(ds, &dcl);
ds->surface = qemu_create_displaysurface(ds, w, h);
s->ds = ds;
s->graphic_mode = -1;
vga_update_display(s);
ppm_save(filename, ds->surface);
qemu_free_displaysurface(ds);
s->ds = saved_ds;
} | true | qemu | 81f099ad3266eede194bcb80f44e9ffe1772f257 | static void vga_screen_dump_common(VGAState *s, const char *filename,
int w, int h)
{
DisplayState *saved_ds, ds1, *ds = &ds1;
DisplayChangeListener dcl;
vga_invalidate_display(s);
saved_ds = s->ds;
memset(ds, 0, sizeof(DisplayState));
memset(&dcl, 0, sizeof(DisplayChangeListener));
dcl.dpy_update = vga_save_dpy_update;
dcl.dpy_resize = vga_save_dpy_resize;
dcl.dpy_refresh = vga_save_dpy_refresh;
register_displaychangelistener(ds, &dcl);
ds->surface = qemu_create_displaysurface(ds, w, h);
s->ds = ds;
s->graphic_mode = -1;
vga_update_display(s);
ppm_save(filename, ds->surface);
qemu_free_displaysurface(ds);
s->ds = saved_ds;
} | {
"code": [],
"line_no": []
} | static void FUNC_0(VGAState *VAR_0, const char *VAR_1,
int VAR_2, int VAR_3)
{
DisplayState *saved_ds, ds1, *ds = &ds1;
DisplayChangeListener dcl;
vga_invalidate_display(VAR_0);
saved_ds = VAR_0->ds;
memset(ds, 0, sizeof(DisplayState));
memset(&dcl, 0, sizeof(DisplayChangeListener));
dcl.dpy_update = vga_save_dpy_update;
dcl.dpy_resize = vga_save_dpy_resize;
dcl.dpy_refresh = vga_save_dpy_refresh;
register_displaychangelistener(ds, &dcl);
ds->surface = qemu_create_displaysurface(ds, VAR_2, VAR_3);
VAR_0->ds = ds;
VAR_0->graphic_mode = -1;
vga_update_display(VAR_0);
ppm_save(VAR_1, ds->surface);
qemu_free_displaysurface(ds);
VAR_0->ds = saved_ds;
} | [
"static void FUNC_0(VGAState *VAR_0, const char *VAR_1,\nint VAR_2, int VAR_3)\n{",
"DisplayState *saved_ds, ds1, *ds = &ds1;",
"DisplayChangeListener dcl;",
"vga_invalidate_display(VAR_0);",
"saved_ds = VAR_0->ds;",
"memset(ds, 0, sizeof(DisplayState));",
"memset(&dcl, 0, sizeof(DisplayChangeListener));",
"dcl.dpy_update = vga_save_dpy_update;",
"dcl.dpy_resize = vga_save_dpy_resize;",
"dcl.dpy_refresh = vga_save_dpy_refresh;",
"register_displaychangelistener(ds, &dcl);",
"ds->surface = qemu_create_displaysurface(ds, VAR_2, VAR_3);",
"VAR_0->ds = ds;",
"VAR_0->graphic_mode = -1;",
"vga_update_display(VAR_0);",
"ppm_save(VAR_1, ds->surface);",
"qemu_free_displaysurface(ds);",
"VAR_0->ds = saved_ds;",
"}"
] | [
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
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
34
],
[
38
],
[
40
],
[
42
],
[
46
],
[
50
],
[
52
],
[
54
]
] |
24,947 | static int ehci_state_execute(EHCIQueue *q)
{
EHCIPacket *p = QTAILQ_FIRST(&q->packets);
int again = 0;
assert(p != NULL);
assert(p->qtdaddr == q->qtdaddr);
if (ehci_qh_do_overlay(q) != 0) {
return -1;
}
// TODO verify enough time remains in the uframe as in 4.4.1.1
// TODO write back ptr to async list when done or out of time
// TODO Windows does not seem to ever set the MULT field
if (!q->async) {
int transactCtr = get_field(q->qh.epcap, QH_EPCAP_MULT);
if (!transactCtr) {
ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);
again = 1;
goto out;
}
}
if (q->async) {
ehci_set_usbsts(q->ehci, USBSTS_REC);
}
p->usb_status = ehci_execute(p, "process");
if (p->usb_status == USB_RET_PROCERR) {
again = -1;
goto out;
}
if (p->usb_status == USB_RET_ASYNC) {
ehci_flush_qh(q);
trace_usb_ehci_packet_action(p->queue, p, "async");
p->async = EHCI_ASYNC_INFLIGHT;
ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);
again = (ehci_fill_queue(p) == USB_RET_PROCERR) ? -1 : 1;
goto out;
}
ehci_set_state(q->ehci, q->async, EST_EXECUTING);
again = 1;
out:
return again;
}
| true | qemu | cae5d3f4b3fbe9b681c0c4046008af424bd1d6a5 | static int ehci_state_execute(EHCIQueue *q)
{
EHCIPacket *p = QTAILQ_FIRST(&q->packets);
int again = 0;
assert(p != NULL);
assert(p->qtdaddr == q->qtdaddr);
if (ehci_qh_do_overlay(q) != 0) {
return -1;
}
if (!q->async) {
int transactCtr = get_field(q->qh.epcap, QH_EPCAP_MULT);
if (!transactCtr) {
ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);
again = 1;
goto out;
}
}
if (q->async) {
ehci_set_usbsts(q->ehci, USBSTS_REC);
}
p->usb_status = ehci_execute(p, "process");
if (p->usb_status == USB_RET_PROCERR) {
again = -1;
goto out;
}
if (p->usb_status == USB_RET_ASYNC) {
ehci_flush_qh(q);
trace_usb_ehci_packet_action(p->queue, p, "async");
p->async = EHCI_ASYNC_INFLIGHT;
ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);
again = (ehci_fill_queue(p) == USB_RET_PROCERR) ? -1 : 1;
goto out;
}
ehci_set_state(q->ehci, q->async, EST_EXECUTING);
again = 1;
out:
return again;
}
| {
"code": [
" if (!q->async) {",
" int transactCtr = get_field(q->qh.epcap, QH_EPCAP_MULT);",
" if (!transactCtr) {",
" ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);",
" again = 1;",
" goto out;",
" again = (ehci_fill_queue(p) == USB_RET_PROCERR) ? -1 : 1;",
" if (!q->async) {",
" int transactCtr = get_field(q->qh.epcap, QH_EPCAP_MULT);"
],
"line_no": [
33,
35,
37,
39,
41,
43,
79,
33,
35
]
} | static int FUNC_0(EHCIQueue *VAR_0)
{
EHCIPacket *p = QTAILQ_FIRST(&VAR_0->packets);
int VAR_1 = 0;
assert(p != NULL);
assert(p->qtdaddr == VAR_0->qtdaddr);
if (ehci_qh_do_overlay(VAR_0) != 0) {
return -1;
}
if (!VAR_0->async) {
int VAR_2 = get_field(VAR_0->qh.epcap, QH_EPCAP_MULT);
if (!VAR_2) {
ehci_set_state(VAR_0->ehci, VAR_0->async, EST_HORIZONTALQH);
VAR_1 = 1;
goto out;
}
}
if (VAR_0->async) {
ehci_set_usbsts(VAR_0->ehci, USBSTS_REC);
}
p->usb_status = ehci_execute(p, "process");
if (p->usb_status == USB_RET_PROCERR) {
VAR_1 = -1;
goto out;
}
if (p->usb_status == USB_RET_ASYNC) {
ehci_flush_qh(VAR_0);
trace_usb_ehci_packet_action(p->queue, p, "async");
p->async = EHCI_ASYNC_INFLIGHT;
ehci_set_state(VAR_0->ehci, VAR_0->async, EST_HORIZONTALQH);
VAR_1 = (ehci_fill_queue(p) == USB_RET_PROCERR) ? -1 : 1;
goto out;
}
ehci_set_state(VAR_0->ehci, VAR_0->async, EST_EXECUTING);
VAR_1 = 1;
out:
return VAR_1;
}
| [
"static int FUNC_0(EHCIQueue *VAR_0)\n{",
"EHCIPacket *p = QTAILQ_FIRST(&VAR_0->packets);",
"int VAR_1 = 0;",
"assert(p != NULL);",
"assert(p->qtdaddr == VAR_0->qtdaddr);",
"if (ehci_qh_do_overlay(VAR_0) != 0) {",
"return -1;",
"}",
"if (!VAR_0->async) {",
"int VAR_2 = get_field(VAR_0->qh.epcap, QH_EPCAP_MULT);",
"if (!VAR_2) {",
"ehci_set_state(VAR_0->ehci, VAR_0->async, EST_HORIZONTALQH);",
"VAR_1 = 1;",
"goto out;",
"}",
"}",
"if (VAR_0->async) {",
"ehci_set_usbsts(VAR_0->ehci, USBSTS_REC);",
"}",
"p->usb_status = ehci_execute(p, \"process\");",
"if (p->usb_status == USB_RET_PROCERR) {",
"VAR_1 = -1;",
"goto out;",
"}",
"if (p->usb_status == USB_RET_ASYNC) {",
"ehci_flush_qh(VAR_0);",
"trace_usb_ehci_packet_action(p->queue, p, \"async\");",
"p->async = EHCI_ASYNC_INFLIGHT;",
"ehci_set_state(VAR_0->ehci, VAR_0->async, EST_HORIZONTALQH);",
"VAR_1 = (ehci_fill_queue(p) == USB_RET_PROCERR) ? -1 : 1;",
"goto out;",
"}",
"ehci_set_state(VAR_0->ehci, VAR_0->async, EST_EXECUTING);",
"VAR_1 = 1;",
"out:\nreturn VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
0,
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
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
93,
95
],
[
97
]
] |
24,948 | static void update_msix_table_msg_data(S390PCIBusDevice *pbdev, uint64_t offset,
uint64_t *data, uint8_t len)
{
uint32_t val;
uint8_t *msg_data;
if (offset % PCI_MSIX_ENTRY_SIZE != 8) {
return;
}
if (len != 4) {
DPRINTF("access msix table msg data but len is %d\n", len);
return;
}
msg_data = (uint8_t *)data - offset % PCI_MSIX_ENTRY_SIZE +
PCI_MSIX_ENTRY_VECTOR_CTRL;
val = pci_get_long(msg_data) | (pbdev->fid << ZPCI_MSI_VEC_BITS);
pci_set_long(msg_data, val);
DPRINTF("update msix msg_data to 0x%" PRIx64 "\n", *data);
}
| true | qemu | cdd85eb2804018ab46a742ebf64dc5366b9fae73 | static void update_msix_table_msg_data(S390PCIBusDevice *pbdev, uint64_t offset,
uint64_t *data, uint8_t len)
{
uint32_t val;
uint8_t *msg_data;
if (offset % PCI_MSIX_ENTRY_SIZE != 8) {
return;
}
if (len != 4) {
DPRINTF("access msix table msg data but len is %d\n", len);
return;
}
msg_data = (uint8_t *)data - offset % PCI_MSIX_ENTRY_SIZE +
PCI_MSIX_ENTRY_VECTOR_CTRL;
val = pci_get_long(msg_data) | (pbdev->fid << ZPCI_MSI_VEC_BITS);
pci_set_long(msg_data, val);
DPRINTF("update msix msg_data to 0x%" PRIx64 "\n", *data);
}
| {
"code": [
" val = pci_get_long(msg_data) | (pbdev->fid << ZPCI_MSI_VEC_BITS);"
],
"line_no": [
35
]
} | static void FUNC_0(S390PCIBusDevice *VAR_0, uint64_t VAR_1,
uint64_t *VAR_2, uint8_t VAR_3)
{
uint32_t val;
uint8_t *msg_data;
if (VAR_1 % PCI_MSIX_ENTRY_SIZE != 8) {
return;
}
if (VAR_3 != 4) {
DPRINTF("access msix table msg VAR_2 but VAR_3 is %d\n", VAR_3);
return;
}
msg_data = (uint8_t *)VAR_2 - VAR_1 % PCI_MSIX_ENTRY_SIZE +
PCI_MSIX_ENTRY_VECTOR_CTRL;
val = pci_get_long(msg_data) | (VAR_0->fid << ZPCI_MSI_VEC_BITS);
pci_set_long(msg_data, val);
DPRINTF("update msix msg_data to 0x%" PRIx64 "\n", *VAR_2);
}
| [
"static void FUNC_0(S390PCIBusDevice *VAR_0, uint64_t VAR_1,\nuint64_t *VAR_2, uint8_t VAR_3)\n{",
"uint32_t val;",
"uint8_t *msg_data;",
"if (VAR_1 % PCI_MSIX_ENTRY_SIZE != 8) {",
"return;",
"}",
"if (VAR_3 != 4) {",
"DPRINTF(\"access msix table msg VAR_2 but VAR_3 is %d\\n\", VAR_3);",
"return;",
"}",
"msg_data = (uint8_t *)VAR_2 - VAR_1 % PCI_MSIX_ENTRY_SIZE +\nPCI_MSIX_ENTRY_VECTOR_CTRL;",
"val = pci_get_long(msg_data) | (VAR_0->fid << ZPCI_MSI_VEC_BITS);",
"pci_set_long(msg_data, val);",
"DPRINTF(\"update msix msg_data to 0x%\" PRIx64 \"\\n\", *VAR_2);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
]
] |
24,949 | static void vp7_idct_add_c(uint8_t *dst, int16_t block[16], ptrdiff_t stride)
{
int i, a1, b1, c1, d1;
int16_t tmp[16];
for (i = 0; i < 4; i++) {
a1 = (block[i * 4 + 0] + block[i * 4 + 2]) * 23170;
b1 = (block[i * 4 + 0] - block[i * 4 + 2]) * 23170;
c1 = block[i * 4 + 1] * 12540 - block[i * 4 + 3] * 30274;
d1 = block[i * 4 + 1] * 30274 + block[i * 4 + 3] * 12540;
AV_ZERO64(block + i * 4);
tmp[i * 4 + 0] = (a1 + d1) >> 14;
tmp[i * 4 + 3] = (a1 - d1) >> 14;
tmp[i * 4 + 1] = (b1 + c1) >> 14;
tmp[i * 4 + 2] = (b1 - c1) >> 14;
}
for (i = 0; i < 4; i++) {
a1 = (tmp[i + 0] + tmp[i + 8]) * 23170;
b1 = (tmp[i + 0] - tmp[i + 8]) * 23170;
c1 = tmp[i + 4] * 12540 - tmp[i + 12] * 30274;
d1 = tmp[i + 4] * 30274 + tmp[i + 12] * 12540;
dst[0 * stride + i] = av_clip_uint8(dst[0 * stride + i] +
((a1 + d1 + 0x20000) >> 18));
dst[3 * stride + i] = av_clip_uint8(dst[3 * stride + i] +
((a1 - d1 + 0x20000) >> 18));
dst[1 * stride + i] = av_clip_uint8(dst[1 * stride + i] +
((b1 + c1 + 0x20000) >> 18));
dst[2 * stride + i] = av_clip_uint8(dst[2 * stride + i] +
((b1 - c1 + 0x20000) >> 18));
}
}
| true | FFmpeg | 8824b7370a9fb72f9c699c3751a5ceb56e0cc41d | static void vp7_idct_add_c(uint8_t *dst, int16_t block[16], ptrdiff_t stride)
{
int i, a1, b1, c1, d1;
int16_t tmp[16];
for (i = 0; i < 4; i++) {
a1 = (block[i * 4 + 0] + block[i * 4 + 2]) * 23170;
b1 = (block[i * 4 + 0] - block[i * 4 + 2]) * 23170;
c1 = block[i * 4 + 1] * 12540 - block[i * 4 + 3] * 30274;
d1 = block[i * 4 + 1] * 30274 + block[i * 4 + 3] * 12540;
AV_ZERO64(block + i * 4);
tmp[i * 4 + 0] = (a1 + d1) >> 14;
tmp[i * 4 + 3] = (a1 - d1) >> 14;
tmp[i * 4 + 1] = (b1 + c1) >> 14;
tmp[i * 4 + 2] = (b1 - c1) >> 14;
}
for (i = 0; i < 4; i++) {
a1 = (tmp[i + 0] + tmp[i + 8]) * 23170;
b1 = (tmp[i + 0] - tmp[i + 8]) * 23170;
c1 = tmp[i + 4] * 12540 - tmp[i + 12] * 30274;
d1 = tmp[i + 4] * 30274 + tmp[i + 12] * 12540;
dst[0 * stride + i] = av_clip_uint8(dst[0 * stride + i] +
((a1 + d1 + 0x20000) >> 18));
dst[3 * stride + i] = av_clip_uint8(dst[3 * stride + i] +
((a1 - d1 + 0x20000) >> 18));
dst[1 * stride + i] = av_clip_uint8(dst[1 * stride + i] +
((b1 + c1 + 0x20000) >> 18));
dst[2 * stride + i] = av_clip_uint8(dst[2 * stride + i] +
((b1 - c1 + 0x20000) >> 18));
}
}
| {
"code": [
" int i, a1, b1, c1, d1;",
" tmp[i * 4 + 0] = (a1 + d1) >> 14;",
" tmp[i * 4 + 3] = (a1 - d1) >> 14;",
" tmp[i * 4 + 1] = (b1 + c1) >> 14;",
" tmp[i * 4 + 2] = (b1 - c1) >> 14;",
" ((a1 + d1 + 0x20000) >> 18));",
" ((a1 - d1 + 0x20000) >> 18));",
" ((b1 + c1 + 0x20000) >> 18));",
" ((b1 - c1 + 0x20000) >> 18));"
],
"line_no": [
5,
23,
25,
27,
29,
47,
51,
55,
59
]
} | static void FUNC_0(uint8_t *VAR_0, int16_t VAR_1[16], ptrdiff_t VAR_2)
{
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;
int16_t tmp[16];
for (VAR_3 = 0; VAR_3 < 4; VAR_3++) {
VAR_4 = (VAR_1[VAR_3 * 4 + 0] + VAR_1[VAR_3 * 4 + 2]) * 23170;
VAR_5 = (VAR_1[VAR_3 * 4 + 0] - VAR_1[VAR_3 * 4 + 2]) * 23170;
VAR_6 = VAR_1[VAR_3 * 4 + 1] * 12540 - VAR_1[VAR_3 * 4 + 3] * 30274;
VAR_7 = VAR_1[VAR_3 * 4 + 1] * 30274 + VAR_1[VAR_3 * 4 + 3] * 12540;
AV_ZERO64(VAR_1 + VAR_3 * 4);
tmp[VAR_3 * 4 + 0] = (VAR_4 + VAR_7) >> 14;
tmp[VAR_3 * 4 + 3] = (VAR_4 - VAR_7) >> 14;
tmp[VAR_3 * 4 + 1] = (VAR_5 + VAR_6) >> 14;
tmp[VAR_3 * 4 + 2] = (VAR_5 - VAR_6) >> 14;
}
for (VAR_3 = 0; VAR_3 < 4; VAR_3++) {
VAR_4 = (tmp[VAR_3 + 0] + tmp[VAR_3 + 8]) * 23170;
VAR_5 = (tmp[VAR_3 + 0] - tmp[VAR_3 + 8]) * 23170;
VAR_6 = tmp[VAR_3 + 4] * 12540 - tmp[VAR_3 + 12] * 30274;
VAR_7 = tmp[VAR_3 + 4] * 30274 + tmp[VAR_3 + 12] * 12540;
VAR_0[0 * VAR_2 + VAR_3] = av_clip_uint8(VAR_0[0 * VAR_2 + VAR_3] +
((VAR_4 + VAR_7 + 0x20000) >> 18));
VAR_0[3 * VAR_2 + VAR_3] = av_clip_uint8(VAR_0[3 * VAR_2 + VAR_3] +
((VAR_4 - VAR_7 + 0x20000) >> 18));
VAR_0[1 * VAR_2 + VAR_3] = av_clip_uint8(VAR_0[1 * VAR_2 + VAR_3] +
((VAR_5 + VAR_6 + 0x20000) >> 18));
VAR_0[2 * VAR_2 + VAR_3] = av_clip_uint8(VAR_0[2 * VAR_2 + VAR_3] +
((VAR_5 - VAR_6 + 0x20000) >> 18));
}
}
| [
"static void FUNC_0(uint8_t *VAR_0, int16_t VAR_1[16], ptrdiff_t VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;",
"int16_t tmp[16];",
"for (VAR_3 = 0; VAR_3 < 4; VAR_3++) {",
"VAR_4 = (VAR_1[VAR_3 * 4 + 0] + VAR_1[VAR_3 * 4 + 2]) * 23170;",
"VAR_5 = (VAR_1[VAR_3 * 4 + 0] - VAR_1[VAR_3 * 4 + 2]) * 23170;",
"VAR_6 = VAR_1[VAR_3 * 4 + 1] * 12540 - VAR_1[VAR_3 * 4 + 3] * 30274;",
"VAR_7 = VAR_1[VAR_3 * 4 + 1] * 30274 + VAR_1[VAR_3 * 4 + 3] * 12540;",
"AV_ZERO64(VAR_1 + VAR_3 * 4);",
"tmp[VAR_3 * 4 + 0] = (VAR_4 + VAR_7) >> 14;",
"tmp[VAR_3 * 4 + 3] = (VAR_4 - VAR_7) >> 14;",
"tmp[VAR_3 * 4 + 1] = (VAR_5 + VAR_6) >> 14;",
"tmp[VAR_3 * 4 + 2] = (VAR_5 - VAR_6) >> 14;",
"}",
"for (VAR_3 = 0; VAR_3 < 4; VAR_3++) {",
"VAR_4 = (tmp[VAR_3 + 0] + tmp[VAR_3 + 8]) * 23170;",
"VAR_5 = (tmp[VAR_3 + 0] - tmp[VAR_3 + 8]) * 23170;",
"VAR_6 = tmp[VAR_3 + 4] * 12540 - tmp[VAR_3 + 12] * 30274;",
"VAR_7 = tmp[VAR_3 + 4] * 30274 + tmp[VAR_3 + 12] * 12540;",
"VAR_0[0 * VAR_2 + VAR_3] = av_clip_uint8(VAR_0[0 * VAR_2 + VAR_3] +\n((VAR_4 + VAR_7 + 0x20000) >> 18));",
"VAR_0[3 * VAR_2 + VAR_3] = av_clip_uint8(VAR_0[3 * VAR_2 + VAR_3] +\n((VAR_4 - VAR_7 + 0x20000) >> 18));",
"VAR_0[1 * VAR_2 + VAR_3] = av_clip_uint8(VAR_0[1 * VAR_2 + VAR_3] +\n((VAR_5 + VAR_6 + 0x20000) >> 18));",
"VAR_0[2 * VAR_2 + VAR_3] = av_clip_uint8(VAR_0[2 * VAR_2 + VAR_3] +\n((VAR_5 - VAR_6 + 0x20000) >> 18));",
"}",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49,
51
],
[
53,
55
],
[
57,
59
],
[
61
],
[
63
]
] |
24,951 | void ff_er_add_slice(ERContext *s, int startx, int starty,
int endx, int endy, int status)
{
const int start_i = av_clip(startx + starty * s->mb_width, 0, s->mb_num - 1);
const int end_i = av_clip(endx + endy * s->mb_width, 0, s->mb_num);
const int start_xy = s->mb_index2xy[start_i];
const int end_xy = s->mb_index2xy[end_i];
int mask = -1;
if (s->avctx->hwaccel && s->avctx->hwaccel->decode_slice)
return;
if (start_i > end_i || start_xy > end_xy) {
av_log(s->avctx, AV_LOG_ERROR,
"internal error, slice end before start\n");
return;
}
if (!s->avctx->error_concealment)
return;
mask &= ~VP_START;
if (status & (ER_AC_ERROR | ER_AC_END)) {
mask &= ~(ER_AC_ERROR | ER_AC_END);
s->error_count -= end_i - start_i + 1;
}
if (status & (ER_DC_ERROR | ER_DC_END)) {
mask &= ~(ER_DC_ERROR | ER_DC_END);
s->error_count -= end_i - start_i + 1;
}
if (status & (ER_MV_ERROR | ER_MV_END)) {
mask &= ~(ER_MV_ERROR | ER_MV_END);
s->error_count -= end_i - start_i + 1;
}
if (status & ER_MB_ERROR) {
s->error_occurred = 1;
s->error_count = INT_MAX;
}
if (mask == ~0x7F) {
memset(&s->error_status_table[start_xy], 0,
(end_xy - start_xy) * sizeof(uint8_t));
} else {
int i;
for (i = start_xy; i < end_xy; i++)
s->error_status_table[i] &= mask;
}
if (end_i == s->mb_num)
s->error_count = INT_MAX;
else {
s->error_status_table[end_xy] &= mask;
s->error_status_table[end_xy] |= status;
}
s->error_status_table[start_xy] |= VP_START;
if (start_xy > 0 && !(s->avctx->active_thread_type & FF_THREAD_SLICE) &&
er_supported(s) && s->avctx->skip_top * s->mb_width < start_i) {
int prev_status = s->error_status_table[s->mb_index2xy[start_i - 1]];
prev_status &= ~ VP_START;
if (prev_status != (ER_MV_END | ER_DC_END | ER_AC_END)) {
s->error_occurred = 1;
s->error_count = INT_MAX;
}
}
}
| true | FFmpeg | cf880ccb6a82476e1b944d5d0e742b63de21283a | void ff_er_add_slice(ERContext *s, int startx, int starty,
int endx, int endy, int status)
{
const int start_i = av_clip(startx + starty * s->mb_width, 0, s->mb_num - 1);
const int end_i = av_clip(endx + endy * s->mb_width, 0, s->mb_num);
const int start_xy = s->mb_index2xy[start_i];
const int end_xy = s->mb_index2xy[end_i];
int mask = -1;
if (s->avctx->hwaccel && s->avctx->hwaccel->decode_slice)
return;
if (start_i > end_i || start_xy > end_xy) {
av_log(s->avctx, AV_LOG_ERROR,
"internal error, slice end before start\n");
return;
}
if (!s->avctx->error_concealment)
return;
mask &= ~VP_START;
if (status & (ER_AC_ERROR | ER_AC_END)) {
mask &= ~(ER_AC_ERROR | ER_AC_END);
s->error_count -= end_i - start_i + 1;
}
if (status & (ER_DC_ERROR | ER_DC_END)) {
mask &= ~(ER_DC_ERROR | ER_DC_END);
s->error_count -= end_i - start_i + 1;
}
if (status & (ER_MV_ERROR | ER_MV_END)) {
mask &= ~(ER_MV_ERROR | ER_MV_END);
s->error_count -= end_i - start_i + 1;
}
if (status & ER_MB_ERROR) {
s->error_occurred = 1;
s->error_count = INT_MAX;
}
if (mask == ~0x7F) {
memset(&s->error_status_table[start_xy], 0,
(end_xy - start_xy) * sizeof(uint8_t));
} else {
int i;
for (i = start_xy; i < end_xy; i++)
s->error_status_table[i] &= mask;
}
if (end_i == s->mb_num)
s->error_count = INT_MAX;
else {
s->error_status_table[end_xy] &= mask;
s->error_status_table[end_xy] |= status;
}
s->error_status_table[start_xy] |= VP_START;
if (start_xy > 0 && !(s->avctx->active_thread_type & FF_THREAD_SLICE) &&
er_supported(s) && s->avctx->skip_top * s->mb_width < start_i) {
int prev_status = s->error_status_table[s->mb_index2xy[start_i - 1]];
prev_status &= ~ VP_START;
if (prev_status != (ER_MV_END | ER_DC_END | ER_AC_END)) {
s->error_occurred = 1;
s->error_count = INT_MAX;
}
}
}
| {
"code": [
" s->error_count -= end_i - start_i + 1;",
" s->error_count -= end_i - start_i + 1;",
" s->error_count -= end_i - start_i + 1;",
" s->error_count = INT_MAX;",
" s->error_count = INT_MAX;",
" s->error_count = INT_MAX;"
],
"line_no": [
49,
49,
49,
75,
101,
131
]
} | void FUNC_0(ERContext *VAR_0, int VAR_1, int VAR_2,
int VAR_3, int VAR_4, int VAR_5)
{
const int VAR_6 = av_clip(VAR_1 + VAR_2 * VAR_0->mb_width, 0, VAR_0->mb_num - 1);
const int VAR_7 = av_clip(VAR_3 + VAR_4 * VAR_0->mb_width, 0, VAR_0->mb_num);
const int VAR_8 = VAR_0->mb_index2xy[VAR_6];
const int VAR_9 = VAR_0->mb_index2xy[VAR_7];
int VAR_10 = -1;
if (VAR_0->avctx->hwaccel && VAR_0->avctx->hwaccel->decode_slice)
return;
if (VAR_6 > VAR_7 || VAR_8 > VAR_9) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"internal error, slice end before start\n");
return;
}
if (!VAR_0->avctx->error_concealment)
return;
VAR_10 &= ~VP_START;
if (VAR_5 & (ER_AC_ERROR | ER_AC_END)) {
VAR_10 &= ~(ER_AC_ERROR | ER_AC_END);
VAR_0->error_count -= VAR_7 - VAR_6 + 1;
}
if (VAR_5 & (ER_DC_ERROR | ER_DC_END)) {
VAR_10 &= ~(ER_DC_ERROR | ER_DC_END);
VAR_0->error_count -= VAR_7 - VAR_6 + 1;
}
if (VAR_5 & (ER_MV_ERROR | ER_MV_END)) {
VAR_10 &= ~(ER_MV_ERROR | ER_MV_END);
VAR_0->error_count -= VAR_7 - VAR_6 + 1;
}
if (VAR_5 & ER_MB_ERROR) {
VAR_0->error_occurred = 1;
VAR_0->error_count = INT_MAX;
}
if (VAR_10 == ~0x7F) {
memset(&VAR_0->error_status_table[VAR_8], 0,
(VAR_9 - VAR_8) * sizeof(uint8_t));
} else {
int VAR_11;
for (VAR_11 = VAR_8; VAR_11 < VAR_9; VAR_11++)
VAR_0->error_status_table[VAR_11] &= VAR_10;
}
if (VAR_7 == VAR_0->mb_num)
VAR_0->error_count = INT_MAX;
else {
VAR_0->error_status_table[VAR_9] &= VAR_10;
VAR_0->error_status_table[VAR_9] |= VAR_5;
}
VAR_0->error_status_table[VAR_8] |= VP_START;
if (VAR_8 > 0 && !(VAR_0->avctx->active_thread_type & FF_THREAD_SLICE) &&
er_supported(VAR_0) && VAR_0->avctx->skip_top * VAR_0->mb_width < VAR_6) {
int VAR_12 = VAR_0->error_status_table[VAR_0->mb_index2xy[VAR_6 - 1]];
VAR_12 &= ~ VP_START;
if (VAR_12 != (ER_MV_END | ER_DC_END | ER_AC_END)) {
VAR_0->error_occurred = 1;
VAR_0->error_count = INT_MAX;
}
}
}
| [
"void FUNC_0(ERContext *VAR_0, int VAR_1, int VAR_2,\nint VAR_3, int VAR_4, int VAR_5)\n{",
"const int VAR_6 = av_clip(VAR_1 + VAR_2 * VAR_0->mb_width, 0, VAR_0->mb_num - 1);",
"const int VAR_7 = av_clip(VAR_3 + VAR_4 * VAR_0->mb_width, 0, VAR_0->mb_num);",
"const int VAR_8 = VAR_0->mb_index2xy[VAR_6];",
"const int VAR_9 = VAR_0->mb_index2xy[VAR_7];",
"int VAR_10 = -1;",
"if (VAR_0->avctx->hwaccel && VAR_0->avctx->hwaccel->decode_slice)\nreturn;",
"if (VAR_6 > VAR_7 || VAR_8 > VAR_9) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"internal error, slice end before start\\n\");",
"return;",
"}",
"if (!VAR_0->avctx->error_concealment)\nreturn;",
"VAR_10 &= ~VP_START;",
"if (VAR_5 & (ER_AC_ERROR | ER_AC_END)) {",
"VAR_10 &= ~(ER_AC_ERROR | ER_AC_END);",
"VAR_0->error_count -= VAR_7 - VAR_6 + 1;",
"}",
"if (VAR_5 & (ER_DC_ERROR | ER_DC_END)) {",
"VAR_10 &= ~(ER_DC_ERROR | ER_DC_END);",
"VAR_0->error_count -= VAR_7 - VAR_6 + 1;",
"}",
"if (VAR_5 & (ER_MV_ERROR | ER_MV_END)) {",
"VAR_10 &= ~(ER_MV_ERROR | ER_MV_END);",
"VAR_0->error_count -= VAR_7 - VAR_6 + 1;",
"}",
"if (VAR_5 & ER_MB_ERROR) {",
"VAR_0->error_occurred = 1;",
"VAR_0->error_count = INT_MAX;",
"}",
"if (VAR_10 == ~0x7F) {",
"memset(&VAR_0->error_status_table[VAR_8], 0,\n(VAR_9 - VAR_8) * sizeof(uint8_t));",
"} else {",
"int VAR_11;",
"for (VAR_11 = VAR_8; VAR_11 < VAR_9; VAR_11++)",
"VAR_0->error_status_table[VAR_11] &= VAR_10;",
"}",
"if (VAR_7 == VAR_0->mb_num)\nVAR_0->error_count = INT_MAX;",
"else {",
"VAR_0->error_status_table[VAR_9] &= VAR_10;",
"VAR_0->error_status_table[VAR_9] |= VAR_5;",
"}",
"VAR_0->error_status_table[VAR_8] |= VP_START;",
"if (VAR_8 > 0 && !(VAR_0->avctx->active_thread_type & FF_THREAD_SLICE) &&\ner_supported(VAR_0) && VAR_0->avctx->skip_top * VAR_0->mb_width < VAR_6) {",
"int VAR_12 = VAR_0->error_status_table[VAR_0->mb_index2xy[VAR_6 - 1]];",
"VAR_12 &= ~ VP_START;",
"if (VAR_12 != (ER_MV_END | ER_DC_END | ER_AC_END)) {",
"VAR_0->error_occurred = 1;",
"VAR_0->error_count = INT_MAX;",
"}",
"}",
"}"
] | [
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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
37,
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99,
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
117,
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
]
] |
24,952 | static inline void RENAME(yuv2yuvX)(SwsContext *c, const int16_t *lumFilter,
const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrUSrc,
const int16_t **chrVSrc,
int chrFilterSize, const int16_t **alpSrc,
uint8_t *dest, uint8_t *uDest, uint8_t *vDest,
uint8_t *aDest, long dstW, long chrDstW)
{
if (uDest) {
YSCALEYUV2YV12X(CHR_MMX_FILTER_OFFSET, uDest, chrDstW, 0)
YSCALEYUV2YV12X(CHR_MMX_FILTER_OFFSET, vDest, chrDstW + c->uv_off, c->uv_off)
}
if (CONFIG_SWSCALE_ALPHA && aDest) {
YSCALEYUV2YV12X(ALP_MMX_FILTER_OFFSET, aDest, dstW, 0)
}
YSCALEYUV2YV12X(LUM_MMX_FILTER_OFFSET, dest, dstW, 0)
}
| true | FFmpeg | 39d607e5bbc25ad9629683702b510e865434ef21 | static inline void RENAME(yuv2yuvX)(SwsContext *c, const int16_t *lumFilter,
const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrUSrc,
const int16_t **chrVSrc,
int chrFilterSize, const int16_t **alpSrc,
uint8_t *dest, uint8_t *uDest, uint8_t *vDest,
uint8_t *aDest, long dstW, long chrDstW)
{
if (uDest) {
YSCALEYUV2YV12X(CHR_MMX_FILTER_OFFSET, uDest, chrDstW, 0)
YSCALEYUV2YV12X(CHR_MMX_FILTER_OFFSET, vDest, chrDstW + c->uv_off, c->uv_off)
}
if (CONFIG_SWSCALE_ALPHA && aDest) {
YSCALEYUV2YV12X(ALP_MMX_FILTER_OFFSET, aDest, dstW, 0)
}
YSCALEYUV2YV12X(LUM_MMX_FILTER_OFFSET, dest, dstW, 0)
}
| {
"code": [
" YSCALEYUV2YV12X(CHR_MMX_FILTER_OFFSET, vDest, chrDstW + c->uv_off, c->uv_off)"
],
"line_no": [
21
]
} | static inline void FUNC_0(yuv2yuvX)(SwsContext *c, const int16_t *lumFilter,
const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrUSrc,
const int16_t **chrVSrc,
int chrFilterSize, const int16_t **alpSrc,
uint8_t *dest, uint8_t *uDest, uint8_t *vDest,
uint8_t *aDest, long dstW, long chrDstW)
{
if (uDest) {
YSCALEYUV2YV12X(CHR_MMX_FILTER_OFFSET, uDest, chrDstW, 0)
YSCALEYUV2YV12X(CHR_MMX_FILTER_OFFSET, vDest, chrDstW + c->uv_off, c->uv_off)
}
if (CONFIG_SWSCALE_ALPHA && aDest) {
YSCALEYUV2YV12X(ALP_MMX_FILTER_OFFSET, aDest, dstW, 0)
}
YSCALEYUV2YV12X(LUM_MMX_FILTER_OFFSET, dest, dstW, 0)
}
| [
"static inline void FUNC_0(yuv2yuvX)(SwsContext *c, const int16_t *lumFilter,\nconst int16_t **lumSrc, int lumFilterSize,\nconst int16_t *chrFilter, const int16_t **chrUSrc,\nconst int16_t **chrVSrc,\nint chrFilterSize, const int16_t **alpSrc,\nuint8_t *dest, uint8_t *uDest, uint8_t *vDest,\nuint8_t *aDest, long dstW, long chrDstW)\n{",
"if (uDest) {",
"YSCALEYUV2YV12X(CHR_MMX_FILTER_OFFSET, uDest, chrDstW, 0)\nYSCALEYUV2YV12X(CHR_MMX_FILTER_OFFSET, vDest, chrDstW + c->uv_off, c->uv_off)\n}",
"if (CONFIG_SWSCALE_ALPHA && aDest) {",
"YSCALEYUV2YV12X(ALP_MMX_FILTER_OFFSET, aDest, dstW, 0)\n}",
"YSCALEYUV2YV12X(LUM_MMX_FILTER_OFFSET, dest, dstW, 0)\n}"
] | [
0,
0,
1,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13,
15
],
[
17
],
[
19,
21,
23
],
[
25
],
[
27,
29
],
[
33,
35
]
] |
24,954 | void bitmap_clear(unsigned long *map, long start, long nr)
{
unsigned long *p = map + BIT_WORD(start);
const long size = start + nr;
int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);
unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);
while (nr - bits_to_clear >= 0) {
*p &= ~mask_to_clear;
nr -= bits_to_clear;
bits_to_clear = BITS_PER_LONG;
mask_to_clear = ~0UL;
p++;
}
if (nr) {
mask_to_clear &= BITMAP_LAST_WORD_MASK(size);
*p &= ~mask_to_clear;
}
} | true | qemu | e12ed72e5c00dd3375b8bd107200e4d7e950276a | void bitmap_clear(unsigned long *map, long start, long nr)
{
unsigned long *p = map + BIT_WORD(start);
const long size = start + nr;
int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);
unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);
while (nr - bits_to_clear >= 0) {
*p &= ~mask_to_clear;
nr -= bits_to_clear;
bits_to_clear = BITS_PER_LONG;
mask_to_clear = ~0UL;
p++;
}
if (nr) {
mask_to_clear &= BITMAP_LAST_WORD_MASK(size);
*p &= ~mask_to_clear;
}
} | {
"code": [],
"line_no": []
} | void FUNC_0(unsigned long *VAR_0, long VAR_1, long VAR_2)
{
unsigned long *VAR_3 = VAR_0 + BIT_WORD(VAR_1);
const long VAR_4 = VAR_1 + VAR_2;
int VAR_5 = BITS_PER_LONG - (VAR_1 % BITS_PER_LONG);
unsigned long VAR_6 = BITMAP_FIRST_WORD_MASK(VAR_1);
while (VAR_2 - VAR_5 >= 0) {
*VAR_3 &= ~VAR_6;
VAR_2 -= VAR_5;
VAR_5 = BITS_PER_LONG;
VAR_6 = ~0UL;
VAR_3++;
}
if (VAR_2) {
VAR_6 &= BITMAP_LAST_WORD_MASK(VAR_4);
*VAR_3 &= ~VAR_6;
}
} | [
"void FUNC_0(unsigned long *VAR_0, long VAR_1, long VAR_2)\n{",
"unsigned long *VAR_3 = VAR_0 + BIT_WORD(VAR_1);",
"const long VAR_4 = VAR_1 + VAR_2;",
"int VAR_5 = BITS_PER_LONG - (VAR_1 % BITS_PER_LONG);",
"unsigned long VAR_6 = BITMAP_FIRST_WORD_MASK(VAR_1);",
"while (VAR_2 - VAR_5 >= 0) {",
"*VAR_3 &= ~VAR_6;",
"VAR_2 -= VAR_5;",
"VAR_5 = BITS_PER_LONG;",
"VAR_6 = ~0UL;",
"VAR_3++;",
"}",
"if (VAR_2) {",
"VAR_6 &= BITMAP_LAST_WORD_MASK(VAR_4);",
"*VAR_3 &= ~VAR_6;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
]
] |
24,955 | static inline void tcg_temp_free_internal(int idx)
{
TCGContext *s = &tcg_ctx;
TCGTemp *ts;
int k;
assert(idx >= s->nb_globals && idx < s->nb_temps);
ts = &s->temps[idx];
assert(ts->temp_allocated != 0);
ts->temp_allocated = 0;
k = ts->base_type;
if (ts->temp_local)
k += TCG_TYPE_COUNT;
ts->next_free_temp = s->first_free_temp[k];
s->first_free_temp[k] = idx; | true | qemu | 27bfd83c336283d1f7a5345ee386c4cd7b80db61 | static inline void tcg_temp_free_internal(int idx)
{
TCGContext *s = &tcg_ctx;
TCGTemp *ts;
int k;
assert(idx >= s->nb_globals && idx < s->nb_temps);
ts = &s->temps[idx];
assert(ts->temp_allocated != 0);
ts->temp_allocated = 0;
k = ts->base_type;
if (ts->temp_local)
k += TCG_TYPE_COUNT;
ts->next_free_temp = s->first_free_temp[k];
s->first_free_temp[k] = idx; | {
"code": [],
"line_no": []
} | static inline void FUNC_0(int VAR_0)
{
TCGContext *s = &tcg_ctx;
TCGTemp *ts;
int VAR_1;
assert(VAR_0 >= s->nb_globals && VAR_0 < s->nb_temps);
ts = &s->temps[VAR_0];
assert(ts->temp_allocated != 0);
ts->temp_allocated = 0;
VAR_1 = ts->base_type;
if (ts->temp_local)
VAR_1 += TCG_TYPE_COUNT;
ts->next_free_temp = s->first_free_temp[VAR_1];
s->first_free_temp[VAR_1] = VAR_0; | [
"static inline void FUNC_0(int VAR_0)\n{",
"TCGContext *s = &tcg_ctx;",
"TCGTemp *ts;",
"int VAR_1;",
"assert(VAR_0 >= s->nb_globals && VAR_0 < s->nb_temps);",
"ts = &s->temps[VAR_0];",
"assert(ts->temp_allocated != 0);",
"ts->temp_allocated = 0;",
"VAR_1 = ts->base_type;",
"if (ts->temp_local)\nVAR_1 += TCG_TYPE_COUNT;",
"ts->next_free_temp = s->first_free_temp[VAR_1];",
"s->first_free_temp[VAR_1] = VAR_0;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11,
12
],
[
13
],
[
14
]
] |
24,956 | static void mcf_uart_do_tx(mcf_uart_state *s)
{
if (s->tx_enabled && (s->sr & MCF_UART_TxEMP) == 0) {
if (s->chr)
qemu_chr_fe_write(s->chr, (unsigned char *)&s->tb, 1);
s->sr |= MCF_UART_TxEMP;
}
if (s->tx_enabled) {
s->sr |= MCF_UART_TxRDY;
} else {
s->sr &= ~MCF_UART_TxRDY;
}
}
| true | qemu | 6ab3fc32ea640026726bc5f9f4db622d0954fb8a | static void mcf_uart_do_tx(mcf_uart_state *s)
{
if (s->tx_enabled && (s->sr & MCF_UART_TxEMP) == 0) {
if (s->chr)
qemu_chr_fe_write(s->chr, (unsigned char *)&s->tb, 1);
s->sr |= MCF_UART_TxEMP;
}
if (s->tx_enabled) {
s->sr |= MCF_UART_TxRDY;
} else {
s->sr &= ~MCF_UART_TxRDY;
}
}
| {
"code": [
" qemu_chr_fe_write(s->chr, (unsigned char *)&s->tb, 1);"
],
"line_no": [
9
]
} | static void FUNC_0(mcf_uart_state *VAR_0)
{
if (VAR_0->tx_enabled && (VAR_0->sr & MCF_UART_TxEMP) == 0) {
if (VAR_0->chr)
qemu_chr_fe_write(VAR_0->chr, (unsigned char *)&VAR_0->tb, 1);
VAR_0->sr |= MCF_UART_TxEMP;
}
if (VAR_0->tx_enabled) {
VAR_0->sr |= MCF_UART_TxRDY;
} else {
VAR_0->sr &= ~MCF_UART_TxRDY;
}
}
| [
"static void FUNC_0(mcf_uart_state *VAR_0)\n{",
"if (VAR_0->tx_enabled && (VAR_0->sr & MCF_UART_TxEMP) == 0) {",
"if (VAR_0->chr)\nqemu_chr_fe_write(VAR_0->chr, (unsigned char *)&VAR_0->tb, 1);",
"VAR_0->sr |= MCF_UART_TxEMP;",
"}",
"if (VAR_0->tx_enabled) {",
"VAR_0->sr |= MCF_UART_TxRDY;",
"} else {",
"VAR_0->sr &= ~MCF_UART_TxRDY;",
"}",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
24,957 | int av_cold ff_mlp_init_crc2D(AVCodecParserContext *s)
{
if (!crc_init_2D) {
av_crc_init(crc_2D, 0, 16, 0x002D, sizeof(crc_2D));
crc_init_2D = 1;
}
return 0;
}
| false | FFmpeg | 7a2efd2e447d5e7c7c0af61417a838b042fb7d0a | int av_cold ff_mlp_init_crc2D(AVCodecParserContext *s)
{
if (!crc_init_2D) {
av_crc_init(crc_2D, 0, 16, 0x002D, sizeof(crc_2D));
crc_init_2D = 1;
}
return 0;
}
| {
"code": [],
"line_no": []
} | int VAR_0 ff_mlp_init_crc2D(AVCodecParserContext *s)
{
if (!crc_init_2D) {
av_crc_init(crc_2D, 0, 16, 0x002D, sizeof(crc_2D));
crc_init_2D = 1;
}
return 0;
}
| [
"int VAR_0 ff_mlp_init_crc2D(AVCodecParserContext *s)\n{",
"if (!crc_init_2D) {",
"av_crc_init(crc_2D, 0, 16, 0x002D, sizeof(crc_2D));",
"crc_init_2D = 1;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
]
] |
24,958 | static void mainstone_common_init(MemoryRegion *address_space_mem,
MachineState *machine,
enum mainstone_model_e model, int arm_id)
{
uint32_t sector_len = 256 * 1024;
hwaddr mainstone_flash_base[] = { MST_FLASH_0, MST_FLASH_1 };
PXA2xxState *mpu;
DeviceState *mst_irq;
DriveInfo *dinfo;
int i;
int be;
MemoryRegion *rom = g_new(MemoryRegion, 1);
const char *cpu_model = machine->cpu_model;
if (!cpu_model)
cpu_model = "pxa270-c5";
/* Setup CPU & memory */
mpu = pxa270_init(address_space_mem, mainstone_binfo.ram_size, cpu_model);
memory_region_init_ram(rom, NULL, "mainstone.rom", MAINSTONE_ROM,
&error_abort);
vmstate_register_ram_global(rom);
memory_region_set_readonly(rom, true);
memory_region_add_subregion(address_space_mem, 0, rom);
#ifdef TARGET_WORDS_BIGENDIAN
be = 1;
#else
be = 0;
#endif
/* There are two 32MiB flash devices on the board */
for (i = 0; i < 2; i ++) {
dinfo = drive_get(IF_PFLASH, 0, i);
if (!dinfo) {
if (qtest_enabled()) {
break;
}
fprintf(stderr, "Two flash images must be given with the "
"'pflash' parameter\n");
exit(1);
}
if (!pflash_cfi01_register(mainstone_flash_base[i], NULL,
i ? "mainstone.flash1" : "mainstone.flash0",
MAINSTONE_FLASH,
blk_by_legacy_dinfo(dinfo),
sector_len, MAINSTONE_FLASH / sector_len,
4, 0, 0, 0, 0, be)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
exit(1);
}
}
mst_irq = sysbus_create_simple("mainstone-fpga", MST_FPGA_PHYS,
qdev_get_gpio_in(mpu->gpio, 0));
/* setup keypad */
pxa27x_register_keypad(mpu->kp, map, 0xe0);
/* MMC/SD host */
pxa2xx_mmci_handlers(mpu->mmc, NULL, qdev_get_gpio_in(mst_irq, MMC_IRQ));
pxa2xx_pcmcia_set_irq_cb(mpu->pcmcia[0],
qdev_get_gpio_in(mst_irq, S0_IRQ),
qdev_get_gpio_in(mst_irq, S0_CD_IRQ));
pxa2xx_pcmcia_set_irq_cb(mpu->pcmcia[1],
qdev_get_gpio_in(mst_irq, S1_IRQ),
qdev_get_gpio_in(mst_irq, S1_CD_IRQ));
smc91c111_init(&nd_table[0], MST_ETH_PHYS,
qdev_get_gpio_in(mst_irq, ETHERNET_IRQ));
mainstone_binfo.kernel_filename = machine->kernel_filename;
mainstone_binfo.kernel_cmdline = machine->kernel_cmdline;
mainstone_binfo.initrd_filename = machine->initrd_filename;
mainstone_binfo.board_id = arm_id;
arm_load_kernel(mpu->cpu, &mainstone_binfo);
}
| true | qemu | f8ed85ac992c48814d916d5df4d44f9a971c5de4 | static void mainstone_common_init(MemoryRegion *address_space_mem,
MachineState *machine,
enum mainstone_model_e model, int arm_id)
{
uint32_t sector_len = 256 * 1024;
hwaddr mainstone_flash_base[] = { MST_FLASH_0, MST_FLASH_1 };
PXA2xxState *mpu;
DeviceState *mst_irq;
DriveInfo *dinfo;
int i;
int be;
MemoryRegion *rom = g_new(MemoryRegion, 1);
const char *cpu_model = machine->cpu_model;
if (!cpu_model)
cpu_model = "pxa270-c5";
mpu = pxa270_init(address_space_mem, mainstone_binfo.ram_size, cpu_model);
memory_region_init_ram(rom, NULL, "mainstone.rom", MAINSTONE_ROM,
&error_abort);
vmstate_register_ram_global(rom);
memory_region_set_readonly(rom, true);
memory_region_add_subregion(address_space_mem, 0, rom);
#ifdef TARGET_WORDS_BIGENDIAN
be = 1;
#else
be = 0;
#endif
for (i = 0; i < 2; i ++) {
dinfo = drive_get(IF_PFLASH, 0, i);
if (!dinfo) {
if (qtest_enabled()) {
break;
}
fprintf(stderr, "Two flash images must be given with the "
"'pflash' parameter\n");
exit(1);
}
if (!pflash_cfi01_register(mainstone_flash_base[i], NULL,
i ? "mainstone.flash1" : "mainstone.flash0",
MAINSTONE_FLASH,
blk_by_legacy_dinfo(dinfo),
sector_len, MAINSTONE_FLASH / sector_len,
4, 0, 0, 0, 0, be)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
exit(1);
}
}
mst_irq = sysbus_create_simple("mainstone-fpga", MST_FPGA_PHYS,
qdev_get_gpio_in(mpu->gpio, 0));
pxa27x_register_keypad(mpu->kp, map, 0xe0);
pxa2xx_mmci_handlers(mpu->mmc, NULL, qdev_get_gpio_in(mst_irq, MMC_IRQ));
pxa2xx_pcmcia_set_irq_cb(mpu->pcmcia[0],
qdev_get_gpio_in(mst_irq, S0_IRQ),
qdev_get_gpio_in(mst_irq, S0_CD_IRQ));
pxa2xx_pcmcia_set_irq_cb(mpu->pcmcia[1],
qdev_get_gpio_in(mst_irq, S1_IRQ),
qdev_get_gpio_in(mst_irq, S1_CD_IRQ));
smc91c111_init(&nd_table[0], MST_ETH_PHYS,
qdev_get_gpio_in(mst_irq, ETHERNET_IRQ));
mainstone_binfo.kernel_filename = machine->kernel_filename;
mainstone_binfo.kernel_cmdline = machine->kernel_cmdline;
mainstone_binfo.initrd_filename = machine->initrd_filename;
mainstone_binfo.board_id = arm_id;
arm_load_kernel(mpu->cpu, &mainstone_binfo);
}
| {
"code": [
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);",
" &error_abort);"
],
"line_no": [
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41
]
} | static void FUNC_0(MemoryRegion *VAR_0,
MachineState *VAR_1,
enum mainstone_model_e VAR_2, int VAR_3)
{
uint32_t sector_len = 256 * 1024;
hwaddr mainstone_flash_base[] = { MST_FLASH_0, MST_FLASH_1 };
PXA2xxState *mpu;
DeviceState *mst_irq;
DriveInfo *dinfo;
int VAR_4;
int VAR_5;
MemoryRegion *rom = g_new(MemoryRegion, 1);
const char *VAR_6 = VAR_1->VAR_6;
if (!VAR_6)
VAR_6 = "pxa270-c5";
mpu = pxa270_init(VAR_0, mainstone_binfo.ram_size, VAR_6);
memory_region_init_ram(rom, NULL, "mainstone.rom", MAINSTONE_ROM,
&error_abort);
vmstate_register_ram_global(rom);
memory_region_set_readonly(rom, true);
memory_region_add_subregion(VAR_0, 0, rom);
#ifdef TARGET_WORDS_BIGENDIAN
VAR_5 = 1;
#else
VAR_5 = 0;
#endif
for (VAR_4 = 0; VAR_4 < 2; VAR_4 ++) {
dinfo = drive_get(IF_PFLASH, 0, VAR_4);
if (!dinfo) {
if (qtest_enabled()) {
break;
}
fprintf(stderr, "Two flash images must VAR_5 given with the "
"'pflash' parameter\n");
exit(1);
}
if (!pflash_cfi01_register(mainstone_flash_base[VAR_4], NULL,
VAR_4 ? "mainstone.flash1" : "mainstone.flash0",
MAINSTONE_FLASH,
blk_by_legacy_dinfo(dinfo),
sector_len, MAINSTONE_FLASH / sector_len,
4, 0, 0, 0, 0, VAR_5)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
exit(1);
}
}
mst_irq = sysbus_create_simple("mainstone-fpga", MST_FPGA_PHYS,
qdev_get_gpio_in(mpu->gpio, 0));
pxa27x_register_keypad(mpu->kp, map, 0xe0);
pxa2xx_mmci_handlers(mpu->mmc, NULL, qdev_get_gpio_in(mst_irq, MMC_IRQ));
pxa2xx_pcmcia_set_irq_cb(mpu->pcmcia[0],
qdev_get_gpio_in(mst_irq, S0_IRQ),
qdev_get_gpio_in(mst_irq, S0_CD_IRQ));
pxa2xx_pcmcia_set_irq_cb(mpu->pcmcia[1],
qdev_get_gpio_in(mst_irq, S1_IRQ),
qdev_get_gpio_in(mst_irq, S1_CD_IRQ));
smc91c111_init(&nd_table[0], MST_ETH_PHYS,
qdev_get_gpio_in(mst_irq, ETHERNET_IRQ));
mainstone_binfo.kernel_filename = VAR_1->kernel_filename;
mainstone_binfo.kernel_cmdline = VAR_1->kernel_cmdline;
mainstone_binfo.initrd_filename = VAR_1->initrd_filename;
mainstone_binfo.board_id = VAR_3;
arm_load_kernel(mpu->cpu, &mainstone_binfo);
}
| [
"static void FUNC_0(MemoryRegion *VAR_0,\nMachineState *VAR_1,\nenum mainstone_model_e VAR_2, int VAR_3)\n{",
"uint32_t sector_len = 256 * 1024;",
"hwaddr mainstone_flash_base[] = { MST_FLASH_0, MST_FLASH_1 };",
"PXA2xxState *mpu;",
"DeviceState *mst_irq;",
"DriveInfo *dinfo;",
"int VAR_4;",
"int VAR_5;",
"MemoryRegion *rom = g_new(MemoryRegion, 1);",
"const char *VAR_6 = VAR_1->VAR_6;",
"if (!VAR_6)\nVAR_6 = \"pxa270-c5\";",
"mpu = pxa270_init(VAR_0, mainstone_binfo.ram_size, VAR_6);",
"memory_region_init_ram(rom, NULL, \"mainstone.rom\", MAINSTONE_ROM,\n&error_abort);",
"vmstate_register_ram_global(rom);",
"memory_region_set_readonly(rom, true);",
"memory_region_add_subregion(VAR_0, 0, rom);",
"#ifdef TARGET_WORDS_BIGENDIAN\nVAR_5 = 1;",
"#else\nVAR_5 = 0;",
"#endif\nfor (VAR_4 = 0; VAR_4 < 2; VAR_4 ++) {",
"dinfo = drive_get(IF_PFLASH, 0, VAR_4);",
"if (!dinfo) {",
"if (qtest_enabled()) {",
"break;",
"}",
"fprintf(stderr, \"Two flash images must VAR_5 given with the \"\n\"'pflash' parameter\\n\");",
"exit(1);",
"}",
"if (!pflash_cfi01_register(mainstone_flash_base[VAR_4], NULL,\nVAR_4 ? \"mainstone.flash1\" : \"mainstone.flash0\",\nMAINSTONE_FLASH,\nblk_by_legacy_dinfo(dinfo),\nsector_len, MAINSTONE_FLASH / sector_len,\n4, 0, 0, 0, 0, VAR_5)) {",
"fprintf(stderr, \"qemu: Error registering flash memory.\\n\");",
"exit(1);",
"}",
"}",
"mst_irq = sysbus_create_simple(\"mainstone-fpga\", MST_FPGA_PHYS,\nqdev_get_gpio_in(mpu->gpio, 0));",
"pxa27x_register_keypad(mpu->kp, map, 0xe0);",
"pxa2xx_mmci_handlers(mpu->mmc, NULL, qdev_get_gpio_in(mst_irq, MMC_IRQ));",
"pxa2xx_pcmcia_set_irq_cb(mpu->pcmcia[0],\nqdev_get_gpio_in(mst_irq, S0_IRQ),\nqdev_get_gpio_in(mst_irq, S0_CD_IRQ));",
"pxa2xx_pcmcia_set_irq_cb(mpu->pcmcia[1],\nqdev_get_gpio_in(mst_irq, S1_IRQ),\nqdev_get_gpio_in(mst_irq, S1_CD_IRQ));",
"smc91c111_init(&nd_table[0], MST_ETH_PHYS,\nqdev_get_gpio_in(mst_irq, ETHERNET_IRQ));",
"mainstone_binfo.kernel_filename = VAR_1->kernel_filename;",
"mainstone_binfo.kernel_cmdline = VAR_1->kernel_cmdline;",
"mainstone_binfo.initrd_filename = VAR_1->initrd_filename;",
"mainstone_binfo.board_id = VAR_3;",
"arm_load_kernel(mpu->cpu, &mainstone_binfo);",
"}"
] | [
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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29,
31
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
51,
53
],
[
55,
57
],
[
59,
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
85,
87,
89,
91,
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107,
109
],
[
115
],
[
121
],
[
125,
127,
129
],
[
131,
133,
135
],
[
139,
141
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
]
] |
24,959 | Visitor *validate_test_init(TestInputVisitorData *data,
const char *json_string, ...)
{
Visitor *v;
va_list ap;
va_start(ap, json_string);
data->obj = qobject_from_jsonv(json_string, &ap);
va_end(ap);
g_assert(data->obj != NULL);
data->qiv = qmp_input_visitor_new_strict(data->obj);
g_assert(data->qiv != NULL);
v = qmp_input_get_visitor(data->qiv);
g_assert(v != NULL);
return v;
}
| true | qemu | 0920a17199d23b3def3a60fa1fbbdeadcdda452d | Visitor *validate_test_init(TestInputVisitorData *data,
const char *json_string, ...)
{
Visitor *v;
va_list ap;
va_start(ap, json_string);
data->obj = qobject_from_jsonv(json_string, &ap);
va_end(ap);
g_assert(data->obj != NULL);
data->qiv = qmp_input_visitor_new_strict(data->obj);
g_assert(data->qiv != NULL);
v = qmp_input_get_visitor(data->qiv);
g_assert(v != NULL);
return v;
}
| {
"code": [
" data->obj = qobject_from_jsonv(json_string, &ap);",
" g_assert(data->obj != NULL);",
" data->qiv = qmp_input_visitor_new_strict(data->obj);",
" g_assert(data->qiv != NULL);",
" v = qmp_input_get_visitor(data->qiv);",
" g_assert(v != NULL);",
" Visitor *v;",
" g_assert(data->obj != NULL);",
" data->qiv = qmp_input_visitor_new_strict(data->obj);",
" g_assert(data->qiv != NULL);",
" v = qmp_input_get_visitor(data->qiv);",
" g_assert(v != NULL);",
" return v;",
" data->obj = qobject_from_jsonv(json_string, &ap);",
" g_assert(data->obj != NULL);",
" g_assert(data->qiv != NULL);",
" v = qmp_input_get_visitor(data->qiv);",
" g_assert(v != NULL);",
" Visitor *v;",
" g_assert(data->obj != NULL);",
" g_assert(data->qiv != NULL);",
" v = qmp_input_get_visitor(data->qiv);",
" g_assert(v != NULL);",
" return v;"
],
"line_no": [
15,
21,
25,
27,
31,
33,
7,
21,
25,
27,
31,
33,
37,
15,
21,
27,
31,
33,
7,
21,
27,
31,
33,
37
]
} | Visitor *FUNC_0(TestInputVisitorData *data,
const char *json_string, ...)
{
Visitor *v;
va_list ap;
va_start(ap, json_string);
data->obj = qobject_from_jsonv(json_string, &ap);
va_end(ap);
g_assert(data->obj != NULL);
data->qiv = qmp_input_visitor_new_strict(data->obj);
g_assert(data->qiv != NULL);
v = qmp_input_get_visitor(data->qiv);
g_assert(v != NULL);
return v;
}
| [
"Visitor *FUNC_0(TestInputVisitorData *data,\nconst char *json_string, ...)\n{",
"Visitor *v;",
"va_list ap;",
"va_start(ap, json_string);",
"data->obj = qobject_from_jsonv(json_string, &ap);",
"va_end(ap);",
"g_assert(data->obj != NULL);",
"data->qiv = qmp_input_visitor_new_strict(data->obj);",
"g_assert(data->qiv != NULL);",
"v = qmp_input_get_visitor(data->qiv);",
"g_assert(v != NULL);",
"return v;",
"}"
] | [
0,
1,
0,
0,
1,
0,
1,
1,
1,
1,
1,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
]
] |
24,960 | void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
void *opaque, QJSON *vmdesc)
{
VMStateField *field = vmsd->fields;
trace_vmstate_save_state_top(vmsd->name);
if (vmsd->pre_save) {
vmsd->pre_save(opaque);
}
if (vmdesc) {
json_prop_str(vmdesc, "vmsd_name", vmsd->name);
json_prop_int(vmdesc, "version", vmsd->version_id);
json_start_array(vmdesc, "fields");
}
while (field->name) {
if (!field->field_exists ||
field->field_exists(opaque, vmsd->version_id)) {
void *first_elem = opaque + field->offset;
int i, n_elems = vmstate_n_elems(opaque, field);
int size = vmstate_size(opaque, field);
int64_t old_offset, written_bytes;
QJSON *vmdesc_loop = vmdesc;
trace_vmstate_save_state_loop(vmsd->name, field->name, n_elems);
if (field->flags & VMS_POINTER) {
first_elem = *(void **)first_elem;
assert(first_elem || !n_elems);
}
for (i = 0; i < n_elems; i++) {
void *curr_elem = first_elem + size * i;
vmsd_desc_field_start(vmsd, vmdesc_loop, field, i, n_elems);
old_offset = qemu_ftell_fast(f);
if (field->flags & VMS_ARRAY_OF_POINTER) {
assert(curr_elem);
curr_elem = *(void **)curr_elem;
}
if (field->flags & VMS_STRUCT) {
vmstate_save_state(f, field->vmsd, curr_elem, vmdesc_loop);
} else {
field->info->put(f, curr_elem, size, field, vmdesc_loop);
}
written_bytes = qemu_ftell_fast(f) - old_offset;
vmsd_desc_field_end(vmsd, vmdesc_loop, field, written_bytes, i);
/* Compressed arrays only care about the first element */
if (vmdesc_loop && vmsd_can_compress(field)) {
vmdesc_loop = NULL;
}
}
} else {
if (field->flags & VMS_MUST_EXIST) {
error_report("Output state validation failed: %s/%s",
vmsd->name, field->name);
assert(!(field->flags & VMS_MUST_EXIST));
}
}
field++;
}
if (vmdesc) {
json_end_array(vmdesc);
}
vmstate_subsection_save(f, vmsd, opaque, vmdesc);
}
| true | qemu | 07d4e69147b4957e617812206a62a86f03294ad3 | void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
void *opaque, QJSON *vmdesc)
{
VMStateField *field = vmsd->fields;
trace_vmstate_save_state_top(vmsd->name);
if (vmsd->pre_save) {
vmsd->pre_save(opaque);
}
if (vmdesc) {
json_prop_str(vmdesc, "vmsd_name", vmsd->name);
json_prop_int(vmdesc, "version", vmsd->version_id);
json_start_array(vmdesc, "fields");
}
while (field->name) {
if (!field->field_exists ||
field->field_exists(opaque, vmsd->version_id)) {
void *first_elem = opaque + field->offset;
int i, n_elems = vmstate_n_elems(opaque, field);
int size = vmstate_size(opaque, field);
int64_t old_offset, written_bytes;
QJSON *vmdesc_loop = vmdesc;
trace_vmstate_save_state_loop(vmsd->name, field->name, n_elems);
if (field->flags & VMS_POINTER) {
first_elem = *(void **)first_elem;
assert(first_elem || !n_elems);
}
for (i = 0; i < n_elems; i++) {
void *curr_elem = first_elem + size * i;
vmsd_desc_field_start(vmsd, vmdesc_loop, field, i, n_elems);
old_offset = qemu_ftell_fast(f);
if (field->flags & VMS_ARRAY_OF_POINTER) {
assert(curr_elem);
curr_elem = *(void **)curr_elem;
}
if (field->flags & VMS_STRUCT) {
vmstate_save_state(f, field->vmsd, curr_elem, vmdesc_loop);
} else {
field->info->put(f, curr_elem, size, field, vmdesc_loop);
}
written_bytes = qemu_ftell_fast(f) - old_offset;
vmsd_desc_field_end(vmsd, vmdesc_loop, field, written_bytes, i);
if (vmdesc_loop && vmsd_can_compress(field)) {
vmdesc_loop = NULL;
}
}
} else {
if (field->flags & VMS_MUST_EXIST) {
error_report("Output state validation failed: %s/%s",
vmsd->name, field->name);
assert(!(field->flags & VMS_MUST_EXIST));
}
}
field++;
}
if (vmdesc) {
json_end_array(vmdesc);
}
vmstate_subsection_save(f, vmsd, opaque, vmdesc);
}
| {
"code": [
" if (field->flags & VMS_STRUCT) {",
" if (field->flags & VMS_STRUCT) {"
],
"line_no": [
81,
81
]
} | void FUNC_0(QEMUFile *VAR_0, const VMStateDescription *VAR_1,
void *VAR_2, QJSON *VAR_3)
{
VMStateField *field = VAR_1->fields;
trace_vmstate_save_state_top(VAR_1->name);
if (VAR_1->pre_save) {
VAR_1->pre_save(VAR_2);
}
if (VAR_3) {
json_prop_str(VAR_3, "vmsd_name", VAR_1->name);
json_prop_int(VAR_3, "version", VAR_1->version_id);
json_start_array(VAR_3, "fields");
}
while (field->name) {
if (!field->field_exists ||
field->field_exists(VAR_2, VAR_1->version_id)) {
void *VAR_4 = VAR_2 + field->offset;
int VAR_5, VAR_6 = vmstate_n_elems(VAR_2, field);
int VAR_7 = vmstate_size(VAR_2, field);
int64_t old_offset, written_bytes;
QJSON *vmdesc_loop = VAR_3;
trace_vmstate_save_state_loop(VAR_1->name, field->name, VAR_6);
if (field->flags & VMS_POINTER) {
VAR_4 = *(void **)VAR_4;
assert(VAR_4 || !VAR_6);
}
for (VAR_5 = 0; VAR_5 < VAR_6; VAR_5++) {
void *VAR_8 = VAR_4 + VAR_7 * VAR_5;
vmsd_desc_field_start(VAR_1, vmdesc_loop, field, VAR_5, VAR_6);
old_offset = qemu_ftell_fast(VAR_0);
if (field->flags & VMS_ARRAY_OF_POINTER) {
assert(VAR_8);
VAR_8 = *(void **)VAR_8;
}
if (field->flags & VMS_STRUCT) {
FUNC_0(VAR_0, field->VAR_1, VAR_8, vmdesc_loop);
} else {
field->info->put(VAR_0, VAR_8, VAR_7, field, vmdesc_loop);
}
written_bytes = qemu_ftell_fast(VAR_0) - old_offset;
vmsd_desc_field_end(VAR_1, vmdesc_loop, field, written_bytes, VAR_5);
if (vmdesc_loop && vmsd_can_compress(field)) {
vmdesc_loop = NULL;
}
}
} else {
if (field->flags & VMS_MUST_EXIST) {
error_report("Output state validation failed: %s/%s",
VAR_1->name, field->name);
assert(!(field->flags & VMS_MUST_EXIST));
}
}
field++;
}
if (VAR_3) {
json_end_array(VAR_3);
}
vmstate_subsection_save(VAR_0, VAR_1, VAR_2, VAR_3);
}
| [
"void FUNC_0(QEMUFile *VAR_0, const VMStateDescription *VAR_1,\nvoid *VAR_2, QJSON *VAR_3)\n{",
"VMStateField *field = VAR_1->fields;",
"trace_vmstate_save_state_top(VAR_1->name);",
"if (VAR_1->pre_save) {",
"VAR_1->pre_save(VAR_2);",
"}",
"if (VAR_3) {",
"json_prop_str(VAR_3, \"vmsd_name\", VAR_1->name);",
"json_prop_int(VAR_3, \"version\", VAR_1->version_id);",
"json_start_array(VAR_3, \"fields\");",
"}",
"while (field->name) {",
"if (!field->field_exists ||\nfield->field_exists(VAR_2, VAR_1->version_id)) {",
"void *VAR_4 = VAR_2 + field->offset;",
"int VAR_5, VAR_6 = vmstate_n_elems(VAR_2, field);",
"int VAR_7 = vmstate_size(VAR_2, field);",
"int64_t old_offset, written_bytes;",
"QJSON *vmdesc_loop = VAR_3;",
"trace_vmstate_save_state_loop(VAR_1->name, field->name, VAR_6);",
"if (field->flags & VMS_POINTER) {",
"VAR_4 = *(void **)VAR_4;",
"assert(VAR_4 || !VAR_6);",
"}",
"for (VAR_5 = 0; VAR_5 < VAR_6; VAR_5++) {",
"void *VAR_8 = VAR_4 + VAR_7 * VAR_5;",
"vmsd_desc_field_start(VAR_1, vmdesc_loop, field, VAR_5, VAR_6);",
"old_offset = qemu_ftell_fast(VAR_0);",
"if (field->flags & VMS_ARRAY_OF_POINTER) {",
"assert(VAR_8);",
"VAR_8 = *(void **)VAR_8;",
"}",
"if (field->flags & VMS_STRUCT) {",
"FUNC_0(VAR_0, field->VAR_1, VAR_8, vmdesc_loop);",
"} else {",
"field->info->put(VAR_0, VAR_8, VAR_7, field, vmdesc_loop);",
"}",
"written_bytes = qemu_ftell_fast(VAR_0) - old_offset;",
"vmsd_desc_field_end(VAR_1, vmdesc_loop, field, written_bytes, VAR_5);",
"if (vmdesc_loop && vmsd_can_compress(field)) {",
"vmdesc_loop = NULL;",
"}",
"}",
"} else {",
"if (field->flags & VMS_MUST_EXIST) {",
"error_report(\"Output state validation failed: %s/%s\",\nVAR_1->name, field->name);",
"assert(!(field->flags & VMS_MUST_EXIST));",
"}",
"}",
"field++;",
"}",
"if (VAR_3) {",
"json_end_array(VAR_3);",
"}",
"vmstate_subsection_save(VAR_0, VAR_1, VAR_2, VAR_3);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113,
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
137
],
[
139
]
] |
24,961 | static AVStream *add_av_stream1(FFServerStream *stream,
AVCodecContext *codec, int copy)
{
AVStream *fst;
if(stream->nb_streams >= FF_ARRAY_ELEMS(stream->streams))
return NULL;
fst = av_mallocz(sizeof(AVStream));
if (!fst)
return NULL;
if (copy) {
fst->codec = avcodec_alloc_context3(codec->codec);
if (!fst->codec) {
av_free(fst);
return NULL;
}
avcodec_copy_context(fst->codec, codec);
} else
/* live streams must use the actual feed's codec since it may be
* updated later to carry extradata needed by them.
*/
fst->codec = codec;
fst->priv_data = av_mallocz(sizeof(FeedData));
fst->index = stream->nb_streams;
avpriv_set_pts_info(fst, 33, 1, 90000);
fst->sample_aspect_ratio = codec->sample_aspect_ratio;
stream->streams[stream->nb_streams++] = fst;
return fst;
} | true | FFmpeg | 5a31f2318b8fed1f4711cb86eab6d9b679946878 | static AVStream *add_av_stream1(FFServerStream *stream,
AVCodecContext *codec, int copy)
{
AVStream *fst;
if(stream->nb_streams >= FF_ARRAY_ELEMS(stream->streams))
return NULL;
fst = av_mallocz(sizeof(AVStream));
if (!fst)
return NULL;
if (copy) {
fst->codec = avcodec_alloc_context3(codec->codec);
if (!fst->codec) {
av_free(fst);
return NULL;
}
avcodec_copy_context(fst->codec, codec);
} else
fst->codec = codec;
fst->priv_data = av_mallocz(sizeof(FeedData));
fst->index = stream->nb_streams;
avpriv_set_pts_info(fst, 33, 1, 90000);
fst->sample_aspect_ratio = codec->sample_aspect_ratio;
stream->streams[stream->nb_streams++] = fst;
return fst;
} | {
"code": [],
"line_no": []
} | static AVStream *FUNC_0(FFServerStream *stream,
AVCodecContext *codec, int copy)
{
AVStream *fst;
if(stream->nb_streams >= FF_ARRAY_ELEMS(stream->streams))
return NULL;
fst = av_mallocz(sizeof(AVStream));
if (!fst)
return NULL;
if (copy) {
fst->codec = avcodec_alloc_context3(codec->codec);
if (!fst->codec) {
av_free(fst);
return NULL;
}
avcodec_copy_context(fst->codec, codec);
} else
fst->codec = codec;
fst->priv_data = av_mallocz(sizeof(FeedData));
fst->index = stream->nb_streams;
avpriv_set_pts_info(fst, 33, 1, 90000);
fst->sample_aspect_ratio = codec->sample_aspect_ratio;
stream->streams[stream->nb_streams++] = fst;
return fst;
} | [
"static AVStream *FUNC_0(FFServerStream *stream,\nAVCodecContext *codec, int copy)\n{",
"AVStream *fst;",
"if(stream->nb_streams >= FF_ARRAY_ELEMS(stream->streams))\nreturn NULL;",
"fst = av_mallocz(sizeof(AVStream));",
"if (!fst)\nreturn NULL;",
"if (copy) {",
"fst->codec = avcodec_alloc_context3(codec->codec);",
"if (!fst->codec) {",
"av_free(fst);",
"return NULL;",
"}",
"avcodec_copy_context(fst->codec, codec);",
"} else",
"fst->codec = codec;",
"fst->priv_data = av_mallocz(sizeof(FeedData));",
"fst->index = stream->nb_streams;",
"avpriv_set_pts_info(fst, 33, 1, 90000);",
"fst->sample_aspect_ratio = codec->sample_aspect_ratio;",
"stream->streams[stream->nb_streams++] = fst;",
"return fst;",
"}"
] | [
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
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
45
],
[
49
],
[
52
],
[
54
],
[
56
],
[
58
],
[
60
],
[
62
]
] |
24,962 | static av_cold int vp3_decode_init(AVCodecContext *avctx)
{
Vp3DecodeContext *s = avctx->priv_data;
int i, inter, plane;
int c_width;
int c_height;
int y_fragment_count, c_fragment_count;
if (avctx->codec_tag == MKTAG('V','P','3','0'))
s->version = 0;
else
s->version = 1;
s->avctx = avctx;
s->width = FFALIGN(avctx->width, 16);
s->height = FFALIGN(avctx->height, 16);
if (avctx->pix_fmt == PIX_FMT_NONE)
avctx->pix_fmt = PIX_FMT_YUV420P;
avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
if(avctx->idct_algo==FF_IDCT_AUTO)
avctx->idct_algo=FF_IDCT_VP3;
ff_dsputil_init(&s->dsp, avctx);
ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct);
/* initialize to an impossible value which will force a recalculation
* in the first frame decode */
for (i = 0; i < 3; i++)
s->qps[i] = -1;
avcodec_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_x_shift, &s->chroma_y_shift);
s->y_superblock_width = (s->width + 31) / 32;
s->y_superblock_height = (s->height + 31) / 32;
s->y_superblock_count = s->y_superblock_width * s->y_superblock_height;
/* work out the dimensions for the C planes */
c_width = s->width >> s->chroma_x_shift;
c_height = s->height >> s->chroma_y_shift;
s->c_superblock_width = (c_width + 31) / 32;
s->c_superblock_height = (c_height + 31) / 32;
s->c_superblock_count = s->c_superblock_width * s->c_superblock_height;
s->superblock_count = s->y_superblock_count + (s->c_superblock_count * 2);
s->u_superblock_start = s->y_superblock_count;
s->v_superblock_start = s->u_superblock_start + s->c_superblock_count;
s->macroblock_width = (s->width + 15) / 16;
s->macroblock_height = (s->height + 15) / 16;
s->macroblock_count = s->macroblock_width * s->macroblock_height;
s->fragment_width[0] = s->width / FRAGMENT_PIXELS;
s->fragment_height[0] = s->height / FRAGMENT_PIXELS;
s->fragment_width[1] = s->fragment_width[0] >> s->chroma_x_shift;
s->fragment_height[1] = s->fragment_height[0] >> s->chroma_y_shift;
/* fragment count covers all 8x8 blocks for all 3 planes */
y_fragment_count = s->fragment_width[0] * s->fragment_height[0];
c_fragment_count = s->fragment_width[1] * s->fragment_height[1];
s->fragment_count = y_fragment_count + 2*c_fragment_count;
s->fragment_start[1] = y_fragment_count;
s->fragment_start[2] = y_fragment_count + c_fragment_count;
if (!s->theora_tables)
{
for (i = 0; i < 64; i++) {
s->coded_dc_scale_factor[i] = vp31_dc_scale_factor[i];
s->coded_ac_scale_factor[i] = vp31_ac_scale_factor[i];
s->base_matrix[0][i] = vp31_intra_y_dequant[i];
s->base_matrix[1][i] = vp31_intra_c_dequant[i];
s->base_matrix[2][i] = vp31_inter_dequant[i];
s->filter_limit_values[i] = vp31_filter_limit_values[i];
}
for(inter=0; inter<2; inter++){
for(plane=0; plane<3; plane++){
s->qr_count[inter][plane]= 1;
s->qr_size [inter][plane][0]= 63;
s->qr_base [inter][plane][0]=
s->qr_base [inter][plane][1]= 2*inter + (!!plane)*!inter;
}
}
/* init VLC tables */
for (i = 0; i < 16; i++) {
/* DC histograms */
init_vlc(&s->dc_vlc[i], 11, 32,
&dc_bias[i][0][1], 4, 2,
&dc_bias[i][0][0], 4, 2, 0);
/* group 1 AC histograms */
init_vlc(&s->ac_vlc_1[i], 11, 32,
&ac_bias_0[i][0][1], 4, 2,
&ac_bias_0[i][0][0], 4, 2, 0);
/* group 2 AC histograms */
init_vlc(&s->ac_vlc_2[i], 11, 32,
&ac_bias_1[i][0][1], 4, 2,
&ac_bias_1[i][0][0], 4, 2, 0);
/* group 3 AC histograms */
init_vlc(&s->ac_vlc_3[i], 11, 32,
&ac_bias_2[i][0][1], 4, 2,
&ac_bias_2[i][0][0], 4, 2, 0);
/* group 4 AC histograms */
init_vlc(&s->ac_vlc_4[i], 11, 32,
&ac_bias_3[i][0][1], 4, 2,
&ac_bias_3[i][0][0], 4, 2, 0);
}
} else {
for (i = 0; i < 16; i++) {
/* DC histograms */
if (init_vlc(&s->dc_vlc[i], 11, 32,
&s->huffman_table[i][0][1], 8, 4,
&s->huffman_table[i][0][0], 8, 4, 0) < 0)
goto vlc_fail;
/* group 1 AC histograms */
if (init_vlc(&s->ac_vlc_1[i], 11, 32,
&s->huffman_table[i+16][0][1], 8, 4,
&s->huffman_table[i+16][0][0], 8, 4, 0) < 0)
goto vlc_fail;
/* group 2 AC histograms */
if (init_vlc(&s->ac_vlc_2[i], 11, 32,
&s->huffman_table[i+16*2][0][1], 8, 4,
&s->huffman_table[i+16*2][0][0], 8, 4, 0) < 0)
goto vlc_fail;
/* group 3 AC histograms */
if (init_vlc(&s->ac_vlc_3[i], 11, 32,
&s->huffman_table[i+16*3][0][1], 8, 4,
&s->huffman_table[i+16*3][0][0], 8, 4, 0) < 0)
goto vlc_fail;
/* group 4 AC histograms */
if (init_vlc(&s->ac_vlc_4[i], 11, 32,
&s->huffman_table[i+16*4][0][1], 8, 4,
&s->huffman_table[i+16*4][0][0], 8, 4, 0) < 0)
goto vlc_fail;
}
}
init_vlc(&s->superblock_run_length_vlc, 6, 34,
&superblock_run_length_vlc_table[0][1], 4, 2,
&superblock_run_length_vlc_table[0][0], 4, 2, 0);
init_vlc(&s->fragment_run_length_vlc, 5, 30,
&fragment_run_length_vlc_table[0][1], 4, 2,
&fragment_run_length_vlc_table[0][0], 4, 2, 0);
init_vlc(&s->mode_code_vlc, 3, 8,
&mode_code_vlc_table[0][1], 2, 1,
&mode_code_vlc_table[0][0], 2, 1, 0);
init_vlc(&s->motion_vector_vlc, 6, 63,
&motion_vector_vlc_table[0][1], 2, 1,
&motion_vector_vlc_table[0][0], 2, 1, 0);
for (i = 0; i < 3; i++) {
s->current_frame.data[i] = NULL;
s->last_frame.data[i] = NULL;
s->golden_frame.data[i] = NULL;
}
return allocate_tables(avctx);
vlc_fail:
av_log(avctx, AV_LOG_FATAL, "Invalid huffman table\n");
return -1;
}
| true | FFmpeg | 1125606a1f8bdcabbdd9107831d20e86f0dfeeae | static av_cold int vp3_decode_init(AVCodecContext *avctx)
{
Vp3DecodeContext *s = avctx->priv_data;
int i, inter, plane;
int c_width;
int c_height;
int y_fragment_count, c_fragment_count;
if (avctx->codec_tag == MKTAG('V','P','3','0'))
s->version = 0;
else
s->version = 1;
s->avctx = avctx;
s->width = FFALIGN(avctx->width, 16);
s->height = FFALIGN(avctx->height, 16);
if (avctx->pix_fmt == PIX_FMT_NONE)
avctx->pix_fmt = PIX_FMT_YUV420P;
avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
if(avctx->idct_algo==FF_IDCT_AUTO)
avctx->idct_algo=FF_IDCT_VP3;
ff_dsputil_init(&s->dsp, avctx);
ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct);
for (i = 0; i < 3; i++)
s->qps[i] = -1;
avcodec_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_x_shift, &s->chroma_y_shift);
s->y_superblock_width = (s->width + 31) / 32;
s->y_superblock_height = (s->height + 31) / 32;
s->y_superblock_count = s->y_superblock_width * s->y_superblock_height;
c_width = s->width >> s->chroma_x_shift;
c_height = s->height >> s->chroma_y_shift;
s->c_superblock_width = (c_width + 31) / 32;
s->c_superblock_height = (c_height + 31) / 32;
s->c_superblock_count = s->c_superblock_width * s->c_superblock_height;
s->superblock_count = s->y_superblock_count + (s->c_superblock_count * 2);
s->u_superblock_start = s->y_superblock_count;
s->v_superblock_start = s->u_superblock_start + s->c_superblock_count;
s->macroblock_width = (s->width + 15) / 16;
s->macroblock_height = (s->height + 15) / 16;
s->macroblock_count = s->macroblock_width * s->macroblock_height;
s->fragment_width[0] = s->width / FRAGMENT_PIXELS;
s->fragment_height[0] = s->height / FRAGMENT_PIXELS;
s->fragment_width[1] = s->fragment_width[0] >> s->chroma_x_shift;
s->fragment_height[1] = s->fragment_height[0] >> s->chroma_y_shift;
y_fragment_count = s->fragment_width[0] * s->fragment_height[0];
c_fragment_count = s->fragment_width[1] * s->fragment_height[1];
s->fragment_count = y_fragment_count + 2*c_fragment_count;
s->fragment_start[1] = y_fragment_count;
s->fragment_start[2] = y_fragment_count + c_fragment_count;
if (!s->theora_tables)
{
for (i = 0; i < 64; i++) {
s->coded_dc_scale_factor[i] = vp31_dc_scale_factor[i];
s->coded_ac_scale_factor[i] = vp31_ac_scale_factor[i];
s->base_matrix[0][i] = vp31_intra_y_dequant[i];
s->base_matrix[1][i] = vp31_intra_c_dequant[i];
s->base_matrix[2][i] = vp31_inter_dequant[i];
s->filter_limit_values[i] = vp31_filter_limit_values[i];
}
for(inter=0; inter<2; inter++){
for(plane=0; plane<3; plane++){
s->qr_count[inter][plane]= 1;
s->qr_size [inter][plane][0]= 63;
s->qr_base [inter][plane][0]=
s->qr_base [inter][plane][1]= 2*inter + (!!plane)*!inter;
}
}
for (i = 0; i < 16; i++) {
init_vlc(&s->dc_vlc[i], 11, 32,
&dc_bias[i][0][1], 4, 2,
&dc_bias[i][0][0], 4, 2, 0);
init_vlc(&s->ac_vlc_1[i], 11, 32,
&ac_bias_0[i][0][1], 4, 2,
&ac_bias_0[i][0][0], 4, 2, 0);
init_vlc(&s->ac_vlc_2[i], 11, 32,
&ac_bias_1[i][0][1], 4, 2,
&ac_bias_1[i][0][0], 4, 2, 0);
init_vlc(&s->ac_vlc_3[i], 11, 32,
&ac_bias_2[i][0][1], 4, 2,
&ac_bias_2[i][0][0], 4, 2, 0);
init_vlc(&s->ac_vlc_4[i], 11, 32,
&ac_bias_3[i][0][1], 4, 2,
&ac_bias_3[i][0][0], 4, 2, 0);
}
} else {
for (i = 0; i < 16; i++) {
if (init_vlc(&s->dc_vlc[i], 11, 32,
&s->huffman_table[i][0][1], 8, 4,
&s->huffman_table[i][0][0], 8, 4, 0) < 0)
goto vlc_fail;
if (init_vlc(&s->ac_vlc_1[i], 11, 32,
&s->huffman_table[i+16][0][1], 8, 4,
&s->huffman_table[i+16][0][0], 8, 4, 0) < 0)
goto vlc_fail;
if (init_vlc(&s->ac_vlc_2[i], 11, 32,
&s->huffman_table[i+16*2][0][1], 8, 4,
&s->huffman_table[i+16*2][0][0], 8, 4, 0) < 0)
goto vlc_fail;
if (init_vlc(&s->ac_vlc_3[i], 11, 32,
&s->huffman_table[i+16*3][0][1], 8, 4,
&s->huffman_table[i+16*3][0][0], 8, 4, 0) < 0)
goto vlc_fail;
if (init_vlc(&s->ac_vlc_4[i], 11, 32,
&s->huffman_table[i+16*4][0][1], 8, 4,
&s->huffman_table[i+16*4][0][0], 8, 4, 0) < 0)
goto vlc_fail;
}
}
init_vlc(&s->superblock_run_length_vlc, 6, 34,
&superblock_run_length_vlc_table[0][1], 4, 2,
&superblock_run_length_vlc_table[0][0], 4, 2, 0);
init_vlc(&s->fragment_run_length_vlc, 5, 30,
&fragment_run_length_vlc_table[0][1], 4, 2,
&fragment_run_length_vlc_table[0][0], 4, 2, 0);
init_vlc(&s->mode_code_vlc, 3, 8,
&mode_code_vlc_table[0][1], 2, 1,
&mode_code_vlc_table[0][0], 2, 1, 0);
init_vlc(&s->motion_vector_vlc, 6, 63,
&motion_vector_vlc_table[0][1], 2, 1,
&motion_vector_vlc_table[0][0], 2, 1, 0);
for (i = 0; i < 3; i++) {
s->current_frame.data[i] = NULL;
s->last_frame.data[i] = NULL;
s->golden_frame.data[i] = NULL;
}
return allocate_tables(avctx);
vlc_fail:
av_log(avctx, AV_LOG_FATAL, "Invalid huffman table\n");
return -1;
}
| {
"code": [
" if (avctx->pix_fmt == PIX_FMT_NONE)"
],
"line_no": [
33
]
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
Vp3DecodeContext *s = avctx->priv_data;
int VAR_0, VAR_1, VAR_2;
int VAR_3;
int VAR_4;
int VAR_5, VAR_6;
if (avctx->codec_tag == MKTAG('V','P','3','0'))
s->version = 0;
else
s->version = 1;
s->avctx = avctx;
s->width = FFALIGN(avctx->width, 16);
s->height = FFALIGN(avctx->height, 16);
if (avctx->pix_fmt == PIX_FMT_NONE)
avctx->pix_fmt = PIX_FMT_YUV420P;
avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
if(avctx->idct_algo==FF_IDCT_AUTO)
avctx->idct_algo=FF_IDCT_VP3;
ff_dsputil_init(&s->dsp, avctx);
ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct);
for (VAR_0 = 0; VAR_0 < 3; VAR_0++)
s->qps[VAR_0] = -1;
avcodec_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_x_shift, &s->chroma_y_shift);
s->y_superblock_width = (s->width + 31) / 32;
s->y_superblock_height = (s->height + 31) / 32;
s->y_superblock_count = s->y_superblock_width * s->y_superblock_height;
VAR_3 = s->width >> s->chroma_x_shift;
VAR_4 = s->height >> s->chroma_y_shift;
s->c_superblock_width = (VAR_3 + 31) / 32;
s->c_superblock_height = (VAR_4 + 31) / 32;
s->c_superblock_count = s->c_superblock_width * s->c_superblock_height;
s->superblock_count = s->y_superblock_count + (s->c_superblock_count * 2);
s->u_superblock_start = s->y_superblock_count;
s->v_superblock_start = s->u_superblock_start + s->c_superblock_count;
s->macroblock_width = (s->width + 15) / 16;
s->macroblock_height = (s->height + 15) / 16;
s->macroblock_count = s->macroblock_width * s->macroblock_height;
s->fragment_width[0] = s->width / FRAGMENT_PIXELS;
s->fragment_height[0] = s->height / FRAGMENT_PIXELS;
s->fragment_width[1] = s->fragment_width[0] >> s->chroma_x_shift;
s->fragment_height[1] = s->fragment_height[0] >> s->chroma_y_shift;
VAR_5 = s->fragment_width[0] * s->fragment_height[0];
VAR_6 = s->fragment_width[1] * s->fragment_height[1];
s->fragment_count = VAR_5 + 2*VAR_6;
s->fragment_start[1] = VAR_5;
s->fragment_start[2] = VAR_5 + VAR_6;
if (!s->theora_tables)
{
for (VAR_0 = 0; VAR_0 < 64; VAR_0++) {
s->coded_dc_scale_factor[VAR_0] = vp31_dc_scale_factor[VAR_0];
s->coded_ac_scale_factor[VAR_0] = vp31_ac_scale_factor[VAR_0];
s->base_matrix[0][VAR_0] = vp31_intra_y_dequant[VAR_0];
s->base_matrix[1][VAR_0] = vp31_intra_c_dequant[VAR_0];
s->base_matrix[2][VAR_0] = vp31_inter_dequant[VAR_0];
s->filter_limit_values[VAR_0] = vp31_filter_limit_values[VAR_0];
}
for(VAR_1=0; VAR_1<2; VAR_1++){
for(VAR_2=0; VAR_2<3; VAR_2++){
s->qr_count[VAR_1][VAR_2]= 1;
s->qr_size [VAR_1][VAR_2][0]= 63;
s->qr_base [VAR_1][VAR_2][0]=
s->qr_base [VAR_1][VAR_2][1]= 2*VAR_1 + (!!VAR_2)*!VAR_1;
}
}
for (VAR_0 = 0; VAR_0 < 16; VAR_0++) {
init_vlc(&s->dc_vlc[VAR_0], 11, 32,
&dc_bias[VAR_0][0][1], 4, 2,
&dc_bias[VAR_0][0][0], 4, 2, 0);
init_vlc(&s->ac_vlc_1[VAR_0], 11, 32,
&ac_bias_0[VAR_0][0][1], 4, 2,
&ac_bias_0[VAR_0][0][0], 4, 2, 0);
init_vlc(&s->ac_vlc_2[VAR_0], 11, 32,
&ac_bias_1[VAR_0][0][1], 4, 2,
&ac_bias_1[VAR_0][0][0], 4, 2, 0);
init_vlc(&s->ac_vlc_3[VAR_0], 11, 32,
&ac_bias_2[VAR_0][0][1], 4, 2,
&ac_bias_2[VAR_0][0][0], 4, 2, 0);
init_vlc(&s->ac_vlc_4[VAR_0], 11, 32,
&ac_bias_3[VAR_0][0][1], 4, 2,
&ac_bias_3[VAR_0][0][0], 4, 2, 0);
}
} else {
for (VAR_0 = 0; VAR_0 < 16; VAR_0++) {
if (init_vlc(&s->dc_vlc[VAR_0], 11, 32,
&s->huffman_table[VAR_0][0][1], 8, 4,
&s->huffman_table[VAR_0][0][0], 8, 4, 0) < 0)
goto vlc_fail;
if (init_vlc(&s->ac_vlc_1[VAR_0], 11, 32,
&s->huffman_table[VAR_0+16][0][1], 8, 4,
&s->huffman_table[VAR_0+16][0][0], 8, 4, 0) < 0)
goto vlc_fail;
if (init_vlc(&s->ac_vlc_2[VAR_0], 11, 32,
&s->huffman_table[VAR_0+16*2][0][1], 8, 4,
&s->huffman_table[VAR_0+16*2][0][0], 8, 4, 0) < 0)
goto vlc_fail;
if (init_vlc(&s->ac_vlc_3[VAR_0], 11, 32,
&s->huffman_table[VAR_0+16*3][0][1], 8, 4,
&s->huffman_table[VAR_0+16*3][0][0], 8, 4, 0) < 0)
goto vlc_fail;
if (init_vlc(&s->ac_vlc_4[VAR_0], 11, 32,
&s->huffman_table[VAR_0+16*4][0][1], 8, 4,
&s->huffman_table[VAR_0+16*4][0][0], 8, 4, 0) < 0)
goto vlc_fail;
}
}
init_vlc(&s->superblock_run_length_vlc, 6, 34,
&superblock_run_length_vlc_table[0][1], 4, 2,
&superblock_run_length_vlc_table[0][0], 4, 2, 0);
init_vlc(&s->fragment_run_length_vlc, 5, 30,
&fragment_run_length_vlc_table[0][1], 4, 2,
&fragment_run_length_vlc_table[0][0], 4, 2, 0);
init_vlc(&s->mode_code_vlc, 3, 8,
&mode_code_vlc_table[0][1], 2, 1,
&mode_code_vlc_table[0][0], 2, 1, 0);
init_vlc(&s->motion_vector_vlc, 6, 63,
&motion_vector_vlc_table[0][1], 2, 1,
&motion_vector_vlc_table[0][0], 2, 1, 0);
for (VAR_0 = 0; VAR_0 < 3; VAR_0++) {
s->current_frame.data[VAR_0] = NULL;
s->last_frame.data[VAR_0] = NULL;
s->golden_frame.data[VAR_0] = NULL;
}
return allocate_tables(avctx);
vlc_fail:
av_log(avctx, AV_LOG_FATAL, "Invalid huffman table\n");
return -1;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"Vp3DecodeContext *s = avctx->priv_data;",
"int VAR_0, VAR_1, VAR_2;",
"int VAR_3;",
"int VAR_4;",
"int VAR_5, VAR_6;",
"if (avctx->codec_tag == MKTAG('V','P','3','0'))\ns->version = 0;",
"else\ns->version = 1;",
"s->avctx = avctx;",
"s->width = FFALIGN(avctx->width, 16);",
"s->height = FFALIGN(avctx->height, 16);",
"if (avctx->pix_fmt == PIX_FMT_NONE)\navctx->pix_fmt = PIX_FMT_YUV420P;",
"avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;",
"if(avctx->idct_algo==FF_IDCT_AUTO)\navctx->idct_algo=FF_IDCT_VP3;",
"ff_dsputil_init(&s->dsp, avctx);",
"ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct);",
"for (VAR_0 = 0; VAR_0 < 3; VAR_0++)",
"s->qps[VAR_0] = -1;",
"avcodec_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_x_shift, &s->chroma_y_shift);",
"s->y_superblock_width = (s->width + 31) / 32;",
"s->y_superblock_height = (s->height + 31) / 32;",
"s->y_superblock_count = s->y_superblock_width * s->y_superblock_height;",
"VAR_3 = s->width >> s->chroma_x_shift;",
"VAR_4 = s->height >> s->chroma_y_shift;",
"s->c_superblock_width = (VAR_3 + 31) / 32;",
"s->c_superblock_height = (VAR_4 + 31) / 32;",
"s->c_superblock_count = s->c_superblock_width * s->c_superblock_height;",
"s->superblock_count = s->y_superblock_count + (s->c_superblock_count * 2);",
"s->u_superblock_start = s->y_superblock_count;",
"s->v_superblock_start = s->u_superblock_start + s->c_superblock_count;",
"s->macroblock_width = (s->width + 15) / 16;",
"s->macroblock_height = (s->height + 15) / 16;",
"s->macroblock_count = s->macroblock_width * s->macroblock_height;",
"s->fragment_width[0] = s->width / FRAGMENT_PIXELS;",
"s->fragment_height[0] = s->height / FRAGMENT_PIXELS;",
"s->fragment_width[1] = s->fragment_width[0] >> s->chroma_x_shift;",
"s->fragment_height[1] = s->fragment_height[0] >> s->chroma_y_shift;",
"VAR_5 = s->fragment_width[0] * s->fragment_height[0];",
"VAR_6 = s->fragment_width[1] * s->fragment_height[1];",
"s->fragment_count = VAR_5 + 2*VAR_6;",
"s->fragment_start[1] = VAR_5;",
"s->fragment_start[2] = VAR_5 + VAR_6;",
"if (!s->theora_tables)\n{",
"for (VAR_0 = 0; VAR_0 < 64; VAR_0++) {",
"s->coded_dc_scale_factor[VAR_0] = vp31_dc_scale_factor[VAR_0];",
"s->coded_ac_scale_factor[VAR_0] = vp31_ac_scale_factor[VAR_0];",
"s->base_matrix[0][VAR_0] = vp31_intra_y_dequant[VAR_0];",
"s->base_matrix[1][VAR_0] = vp31_intra_c_dequant[VAR_0];",
"s->base_matrix[2][VAR_0] = vp31_inter_dequant[VAR_0];",
"s->filter_limit_values[VAR_0] = vp31_filter_limit_values[VAR_0];",
"}",
"for(VAR_1=0; VAR_1<2; VAR_1++){",
"for(VAR_2=0; VAR_2<3; VAR_2++){",
"s->qr_count[VAR_1][VAR_2]= 1;",
"s->qr_size [VAR_1][VAR_2][0]= 63;",
"s->qr_base [VAR_1][VAR_2][0]=\ns->qr_base [VAR_1][VAR_2][1]= 2*VAR_1 + (!!VAR_2)*!VAR_1;",
"}",
"}",
"for (VAR_0 = 0; VAR_0 < 16; VAR_0++) {",
"init_vlc(&s->dc_vlc[VAR_0], 11, 32,\n&dc_bias[VAR_0][0][1], 4, 2,\n&dc_bias[VAR_0][0][0], 4, 2, 0);",
"init_vlc(&s->ac_vlc_1[VAR_0], 11, 32,\n&ac_bias_0[VAR_0][0][1], 4, 2,\n&ac_bias_0[VAR_0][0][0], 4, 2, 0);",
"init_vlc(&s->ac_vlc_2[VAR_0], 11, 32,\n&ac_bias_1[VAR_0][0][1], 4, 2,\n&ac_bias_1[VAR_0][0][0], 4, 2, 0);",
"init_vlc(&s->ac_vlc_3[VAR_0], 11, 32,\n&ac_bias_2[VAR_0][0][1], 4, 2,\n&ac_bias_2[VAR_0][0][0], 4, 2, 0);",
"init_vlc(&s->ac_vlc_4[VAR_0], 11, 32,\n&ac_bias_3[VAR_0][0][1], 4, 2,\n&ac_bias_3[VAR_0][0][0], 4, 2, 0);",
"}",
"} else {",
"for (VAR_0 = 0; VAR_0 < 16; VAR_0++) {",
"if (init_vlc(&s->dc_vlc[VAR_0], 11, 32,\n&s->huffman_table[VAR_0][0][1], 8, 4,\n&s->huffman_table[VAR_0][0][0], 8, 4, 0) < 0)\ngoto vlc_fail;",
"if (init_vlc(&s->ac_vlc_1[VAR_0], 11, 32,\n&s->huffman_table[VAR_0+16][0][1], 8, 4,\n&s->huffman_table[VAR_0+16][0][0], 8, 4, 0) < 0)\ngoto vlc_fail;",
"if (init_vlc(&s->ac_vlc_2[VAR_0], 11, 32,\n&s->huffman_table[VAR_0+16*2][0][1], 8, 4,\n&s->huffman_table[VAR_0+16*2][0][0], 8, 4, 0) < 0)\ngoto vlc_fail;",
"if (init_vlc(&s->ac_vlc_3[VAR_0], 11, 32,\n&s->huffman_table[VAR_0+16*3][0][1], 8, 4,\n&s->huffman_table[VAR_0+16*3][0][0], 8, 4, 0) < 0)\ngoto vlc_fail;",
"if (init_vlc(&s->ac_vlc_4[VAR_0], 11, 32,\n&s->huffman_table[VAR_0+16*4][0][1], 8, 4,\n&s->huffman_table[VAR_0+16*4][0][0], 8, 4, 0) < 0)\ngoto vlc_fail;",
"}",
"}",
"init_vlc(&s->superblock_run_length_vlc, 6, 34,\n&superblock_run_length_vlc_table[0][1], 4, 2,\n&superblock_run_length_vlc_table[0][0], 4, 2, 0);",
"init_vlc(&s->fragment_run_length_vlc, 5, 30,\n&fragment_run_length_vlc_table[0][1], 4, 2,\n&fragment_run_length_vlc_table[0][0], 4, 2, 0);",
"init_vlc(&s->mode_code_vlc, 3, 8,\n&mode_code_vlc_table[0][1], 2, 1,\n&mode_code_vlc_table[0][0], 2, 1, 0);",
"init_vlc(&s->motion_vector_vlc, 6, 63,\n&motion_vector_vlc_table[0][1], 2, 1,\n&motion_vector_vlc_table[0][0], 2, 1, 0);",
"for (VAR_0 = 0; VAR_0 < 3; VAR_0++) {",
"s->current_frame.data[VAR_0] = NULL;",
"s->last_frame.data[VAR_0] = NULL;",
"s->golden_frame.data[VAR_0] = NULL;",
"}",
"return allocate_tables(avctx);",
"vlc_fail:\nav_log(avctx, AV_LOG_FATAL, \"Invalid huffman table\\n\");",
"return -1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17,
19
],
[
21,
23
],
[
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39,
41
],
[
43
],
[
47
],
[
55
],
[
57
],
[
61
],
[
65
],
[
67
],
[
69
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157,
159
],
[
161
],
[
163
],
[
169
],
[
175,
177,
179
],
[
185,
187,
189
],
[
195,
197,
199
],
[
205,
207,
209
],
[
215,
217,
219
],
[
221
],
[
223
],
[
227
],
[
231,
233,
235,
237
],
[
243,
245,
247,
249
],
[
255,
257,
259,
261
],
[
267,
269,
271,
273
],
[
279,
281,
283,
285
],
[
287
],
[
289
],
[
293,
295,
297
],
[
301,
303,
305
],
[
309,
311,
313
],
[
317,
319,
321
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
337
],
[
341,
343
],
[
345
],
[
347
]
] |
24,963 | static inline void RENAME(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width)
{
#ifdef HAVE_MMX
asm volatile(
"mov %4, %%"REG_a" \n\t"
"movq "MANGLE(w1111)", %%mm5 \n\t"
"movq "MANGLE(bgr2UCoeff)", %%mm6 \n\t"
"pxor %%mm7, %%mm7 \n\t"
"lea (%%"REG_a", %%"REG_a", 2), %%"REG_b" \n\t"
"add %%"REG_b", %%"REG_b" \n\t"
ASMALIGN16
"1: \n\t"
PREFETCH" 64(%0, %%"REG_b") \n\t"
PREFETCH" 64(%1, %%"REG_b") \n\t"
#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
"movq (%0, %%"REG_b"), %%mm0 \n\t"
"movq (%1, %%"REG_b"), %%mm1 \n\t"
"movq 6(%0, %%"REG_b"), %%mm2 \n\t"
"movq 6(%1, %%"REG_b"), %%mm3 \n\t"
PAVGB(%%mm1, %%mm0)
PAVGB(%%mm3, %%mm2)
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"psrlq $24, %%mm0 \n\t"
"psrlq $24, %%mm2 \n\t"
PAVGB(%%mm1, %%mm0)
PAVGB(%%mm3, %%mm2)
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
#else
"movd (%0, %%"REG_b"), %%mm0 \n\t"
"movd (%1, %%"REG_b"), %%mm1 \n\t"
"movd 3(%0, %%"REG_b"), %%mm2 \n\t"
"movd 3(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm0 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm2, %%mm0 \n\t"
"movd 6(%0, %%"REG_b"), %%mm4 \n\t"
"movd 6(%1, %%"REG_b"), %%mm1 \n\t"
"movd 9(%0, %%"REG_b"), %%mm2 \n\t"
"movd 9(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm4 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm4, %%mm2 \n\t"
"psrlw $2, %%mm0 \n\t"
"psrlw $2, %%mm2 \n\t"
#endif
"movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t"
"movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t"
"pmaddwd %%mm0, %%mm1 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"pmaddwd %%mm6, %%mm0 \n\t"
"pmaddwd %%mm6, %%mm2 \n\t"
#ifndef FAST_BGR2YV12
"psrad $8, %%mm0 \n\t"
"psrad $8, %%mm1 \n\t"
"psrad $8, %%mm2 \n\t"
"psrad $8, %%mm3 \n\t"
#endif
"packssdw %%mm2, %%mm0 \n\t"
"packssdw %%mm3, %%mm1 \n\t"
"pmaddwd %%mm5, %%mm0 \n\t"
"pmaddwd %%mm5, %%mm1 \n\t"
"packssdw %%mm1, %%mm0 \n\t" // V1 V0 U1 U0
"psraw $7, %%mm0 \n\t"
#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
"movq 12(%0, %%"REG_b"), %%mm4 \n\t"
"movq 12(%1, %%"REG_b"), %%mm1 \n\t"
"movq 18(%0, %%"REG_b"), %%mm2 \n\t"
"movq 18(%1, %%"REG_b"), %%mm3 \n\t"
PAVGB(%%mm1, %%mm4)
PAVGB(%%mm3, %%mm2)
"movq %%mm4, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"psrlq $24, %%mm4 \n\t"
"psrlq $24, %%mm2 \n\t"
PAVGB(%%mm1, %%mm4)
PAVGB(%%mm3, %%mm2)
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
#else
"movd 12(%0, %%"REG_b"), %%mm4 \n\t"
"movd 12(%1, %%"REG_b"), %%mm1 \n\t"
"movd 15(%0, %%"REG_b"), %%mm2 \n\t"
"movd 15(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm4 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm2, %%mm4 \n\t"
"movd 18(%0, %%"REG_b"), %%mm5 \n\t"
"movd 18(%1, %%"REG_b"), %%mm1 \n\t"
"movd 21(%0, %%"REG_b"), %%mm2 \n\t"
"movd 21(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm5 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm5 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm5, %%mm2 \n\t"
"movq "MANGLE(w1111)", %%mm5 \n\t"
"psrlw $2, %%mm4 \n\t"
"psrlw $2, %%mm2 \n\t"
#endif
"movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t"
"movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t"
"pmaddwd %%mm4, %%mm1 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"pmaddwd %%mm6, %%mm4 \n\t"
"pmaddwd %%mm6, %%mm2 \n\t"
#ifndef FAST_BGR2YV12
"psrad $8, %%mm4 \n\t"
"psrad $8, %%mm1 \n\t"
"psrad $8, %%mm2 \n\t"
"psrad $8, %%mm3 \n\t"
#endif
"packssdw %%mm2, %%mm4 \n\t"
"packssdw %%mm3, %%mm1 \n\t"
"pmaddwd %%mm5, %%mm4 \n\t"
"pmaddwd %%mm5, %%mm1 \n\t"
"add $24, %%"REG_b" \n\t"
"packssdw %%mm1, %%mm4 \n\t" // V3 V2 U3 U2
"psraw $7, %%mm4 \n\t"
"movq %%mm0, %%mm1 \n\t"
"punpckldq %%mm4, %%mm0 \n\t"
"punpckhdq %%mm4, %%mm1 \n\t"
"packsswb %%mm1, %%mm0 \n\t"
"paddb "MANGLE(bgr2UVOffset)", %%mm0 \n\t"
"movd %%mm0, (%2, %%"REG_a") \n\t"
"punpckhdq %%mm0, %%mm0 \n\t"
"movd %%mm0, (%3, %%"REG_a") \n\t"
"add $4, %%"REG_a" \n\t"
" js 1b \n\t"
: : "r" (src1+width*6), "r" (src2+width*6), "r" (dstU+width), "r" (dstV+width), "g" (-width)
: "%"REG_a, "%"REG_b
);
#else
int i;
for(i=0; i<width; i++)
{
int b= src1[6*i + 0] + src1[6*i + 3] + src2[6*i + 0] + src2[6*i + 3];
int g= src1[6*i + 1] + src1[6*i + 4] + src2[6*i + 1] + src2[6*i + 4];
int r= src1[6*i + 2] + src1[6*i + 5] + src2[6*i + 2] + src2[6*i + 5];
dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128;
dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128;
}
#endif
}
| false | FFmpeg | 4bff9ef9d0781c4de228bf1f85634d2706fc589b | static inline void RENAME(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width)
{
#ifdef HAVE_MMX
asm volatile(
"mov %4, %%"REG_a" \n\t"
"movq "MANGLE(w1111)", %%mm5 \n\t"
"movq "MANGLE(bgr2UCoeff)", %%mm6 \n\t"
"pxor %%mm7, %%mm7 \n\t"
"lea (%%"REG_a", %%"REG_a", 2), %%"REG_b" \n\t"
"add %%"REG_b", %%"REG_b" \n\t"
ASMALIGN16
"1: \n\t"
PREFETCH" 64(%0, %%"REG_b") \n\t"
PREFETCH" 64(%1, %%"REG_b") \n\t"
#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
"movq (%0, %%"REG_b"), %%mm0 \n\t"
"movq (%1, %%"REG_b"), %%mm1 \n\t"
"movq 6(%0, %%"REG_b"), %%mm2 \n\t"
"movq 6(%1, %%"REG_b"), %%mm3 \n\t"
PAVGB(%%mm1, %%mm0)
PAVGB(%%mm3, %%mm2)
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"psrlq $24, %%mm0 \n\t"
"psrlq $24, %%mm2 \n\t"
PAVGB(%%mm1, %%mm0)
PAVGB(%%mm3, %%mm2)
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
#else
"movd (%0, %%"REG_b"), %%mm0 \n\t"
"movd (%1, %%"REG_b"), %%mm1 \n\t"
"movd 3(%0, %%"REG_b"), %%mm2 \n\t"
"movd 3(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm0 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm2, %%mm0 \n\t"
"movd 6(%0, %%"REG_b"), %%mm4 \n\t"
"movd 6(%1, %%"REG_b"), %%mm1 \n\t"
"movd 9(%0, %%"REG_b"), %%mm2 \n\t"
"movd 9(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm4 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm4, %%mm2 \n\t"
"psrlw $2, %%mm0 \n\t"
"psrlw $2, %%mm2 \n\t"
#endif
"movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t"
"movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t"
"pmaddwd %%mm0, %%mm1 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"pmaddwd %%mm6, %%mm0 \n\t"
"pmaddwd %%mm6, %%mm2 \n\t"
#ifndef FAST_BGR2YV12
"psrad $8, %%mm0 \n\t"
"psrad $8, %%mm1 \n\t"
"psrad $8, %%mm2 \n\t"
"psrad $8, %%mm3 \n\t"
#endif
"packssdw %%mm2, %%mm0 \n\t"
"packssdw %%mm3, %%mm1 \n\t"
"pmaddwd %%mm5, %%mm0 \n\t"
"pmaddwd %%mm5, %%mm1 \n\t"
"packssdw %%mm1, %%mm0 \n\t"
"psraw $7, %%mm0 \n\t"
#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
"movq 12(%0, %%"REG_b"), %%mm4 \n\t"
"movq 12(%1, %%"REG_b"), %%mm1 \n\t"
"movq 18(%0, %%"REG_b"), %%mm2 \n\t"
"movq 18(%1, %%"REG_b"), %%mm3 \n\t"
PAVGB(%%mm1, %%mm4)
PAVGB(%%mm3, %%mm2)
"movq %%mm4, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"psrlq $24, %%mm4 \n\t"
"psrlq $24, %%mm2 \n\t"
PAVGB(%%mm1, %%mm4)
PAVGB(%%mm3, %%mm2)
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
#else
"movd 12(%0, %%"REG_b"), %%mm4 \n\t"
"movd 12(%1, %%"REG_b"), %%mm1 \n\t"
"movd 15(%0, %%"REG_b"), %%mm2 \n\t"
"movd 15(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm4 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm2, %%mm4 \n\t"
"movd 18(%0, %%"REG_b"), %%mm5 \n\t"
"movd 18(%1, %%"REG_b"), %%mm1 \n\t"
"movd 21(%0, %%"REG_b"), %%mm2 \n\t"
"movd 21(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm5 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm5 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm5, %%mm2 \n\t"
"movq "MANGLE(w1111)", %%mm5 \n\t"
"psrlw $2, %%mm4 \n\t"
"psrlw $2, %%mm2 \n\t"
#endif
"movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t"
"movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t"
"pmaddwd %%mm4, %%mm1 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"pmaddwd %%mm6, %%mm4 \n\t"
"pmaddwd %%mm6, %%mm2 \n\t"
#ifndef FAST_BGR2YV12
"psrad $8, %%mm4 \n\t"
"psrad $8, %%mm1 \n\t"
"psrad $8, %%mm2 \n\t"
"psrad $8, %%mm3 \n\t"
#endif
"packssdw %%mm2, %%mm4 \n\t"
"packssdw %%mm3, %%mm1 \n\t"
"pmaddwd %%mm5, %%mm4 \n\t"
"pmaddwd %%mm5, %%mm1 \n\t"
"add $24, %%"REG_b" \n\t"
"packssdw %%mm1, %%mm4 \n\t"
"psraw $7, %%mm4 \n\t"
"movq %%mm0, %%mm1 \n\t"
"punpckldq %%mm4, %%mm0 \n\t"
"punpckhdq %%mm4, %%mm1 \n\t"
"packsswb %%mm1, %%mm0 \n\t"
"paddb "MANGLE(bgr2UVOffset)", %%mm0 \n\t"
"movd %%mm0, (%2, %%"REG_a") \n\t"
"punpckhdq %%mm0, %%mm0 \n\t"
"movd %%mm0, (%3, %%"REG_a") \n\t"
"add $4, %%"REG_a" \n\t"
" js 1b \n\t"
: : "r" (src1+width*6), "r" (src2+width*6), "r" (dstU+width), "r" (dstV+width), "g" (-width)
: "%"REG_a, "%"REG_b
);
#else
int i;
for(i=0; i<width; i++)
{
int b= src1[6*i + 0] + src1[6*i + 3] + src2[6*i + 0] + src2[6*i + 3];
int g= src1[6*i + 1] + src1[6*i + 4] + src2[6*i + 1] + src2[6*i + 4];
int r= src1[6*i + 2] + src1[6*i + 5] + src2[6*i + 2] + src2[6*i + 5];
dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128;
dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128;
}
#endif
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width)
{
#ifdef HAVE_MMX
asm volatile(
"mov %4, %%"REG_a" \n\t"
"movq "MANGLE(w1111)", %%mm5 \n\t"
"movq "MANGLE(bgr2UCoeff)", %%mm6 \n\t"
"pxor %%mm7, %%mm7 \n\t"
"lea (%%"REG_a", %%"REG_a", 2), %%"REG_b" \n\t"
"add %%"REG_b", %%"REG_b" \n\t"
ASMALIGN16
"1: \n\t"
PREFETCH" 64(%0, %%"REG_b") \n\t"
PREFETCH" 64(%1, %%"REG_b") \n\t"
#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
"movq (%0, %%"REG_b"), %%mm0 \n\t"
"movq (%1, %%"REG_b"), %%mm1 \n\t"
"movq 6(%0, %%"REG_b"), %%mm2 \n\t"
"movq 6(%1, %%"REG_b"), %%mm3 \n\t"
PAVGB(%%mm1, %%mm0)
PAVGB(%%mm3, %%mm2)
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"psrlq $24, %%mm0 \n\t"
"psrlq $24, %%mm2 \n\t"
PAVGB(%%mm1, %%mm0)
PAVGB(%%mm3, %%mm2)
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
#else
"movd (%0, %%"REG_b"), %%mm0 \n\t"
"movd (%1, %%"REG_b"), %%mm1 \n\t"
"movd 3(%0, %%"REG_b"), %%mm2 \n\t"
"movd 3(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm0 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm2, %%mm0 \n\t"
"movd 6(%0, %%"REG_b"), %%mm4 \n\t"
"movd 6(%1, %%"REG_b"), %%mm1 \n\t"
"movd 9(%0, %%"REG_b"), %%mm2 \n\t"
"movd 9(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm4 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm4, %%mm2 \n\t"
"psrlw $2, %%mm0 \n\t"
"psrlw $2, %%mm2 \n\t"
#endif
"movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t"
"movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t"
"pmaddwd %%mm0, %%mm1 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"pmaddwd %%mm6, %%mm0 \n\t"
"pmaddwd %%mm6, %%mm2 \n\t"
#ifndef FAST_BGR2YV12
"psrad $8, %%mm0 \n\t"
"psrad $8, %%mm1 \n\t"
"psrad $8, %%mm2 \n\t"
"psrad $8, %%mm3 \n\t"
#endif
"packssdw %%mm2, %%mm0 \n\t"
"packssdw %%mm3, %%mm1 \n\t"
"pmaddwd %%mm5, %%mm0 \n\t"
"pmaddwd %%mm5, %%mm1 \n\t"
"packssdw %%mm1, %%mm0 \n\t"
"psraw $7, %%mm0 \n\t"
#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
"movq 12(%0, %%"REG_b"), %%mm4 \n\t"
"movq 12(%1, %%"REG_b"), %%mm1 \n\t"
"movq 18(%0, %%"REG_b"), %%mm2 \n\t"
"movq 18(%1, %%"REG_b"), %%mm3 \n\t"
PAVGB(%%mm1, %%mm4)
PAVGB(%%mm3, %%mm2)
"movq %%mm4, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"psrlq $24, %%mm4 \n\t"
"psrlq $24, %%mm2 \n\t"
PAVGB(%%mm1, %%mm4)
PAVGB(%%mm3, %%mm2)
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
#else
"movd 12(%0, %%"REG_b"), %%mm4 \n\t"
"movd 12(%1, %%"REG_b"), %%mm1 \n\t"
"movd 15(%0, %%"REG_b"), %%mm2 \n\t"
"movd 15(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm4 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm2, %%mm4 \n\t"
"movd 18(%0, %%"REG_b"), %%mm5 \n\t"
"movd 18(%1, %%"REG_b"), %%mm1 \n\t"
"movd 21(%0, %%"REG_b"), %%mm2 \n\t"
"movd 21(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm5 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm5 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm5, %%mm2 \n\t"
"movq "MANGLE(w1111)", %%mm5 \n\t"
"psrlw $2, %%mm4 \n\t"
"psrlw $2, %%mm2 \n\t"
#endif
"movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t"
"movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t"
"pmaddwd %%mm4, %%mm1 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"pmaddwd %%mm6, %%mm4 \n\t"
"pmaddwd %%mm6, %%mm2 \n\t"
#ifndef FAST_BGR2YV12
"psrad $8, %%mm4 \n\t"
"psrad $8, %%mm1 \n\t"
"psrad $8, %%mm2 \n\t"
"psrad $8, %%mm3 \n\t"
#endif
"packssdw %%mm2, %%mm4 \n\t"
"packssdw %%mm3, %%mm1 \n\t"
"pmaddwd %%mm5, %%mm4 \n\t"
"pmaddwd %%mm5, %%mm1 \n\t"
"add $24, %%"REG_b" \n\t"
"packssdw %%mm1, %%mm4 \n\t"
"psraw $7, %%mm4 \n\t"
"movq %%mm0, %%mm1 \n\t"
"punpckldq %%mm4, %%mm0 \n\t"
"punpckhdq %%mm4, %%mm1 \n\t"
"packsswb %%mm1, %%mm0 \n\t"
"paddb "MANGLE(bgr2UVOffset)", %%mm0 \n\t"
"movd %%mm0, (%2, %%"REG_a") \n\t"
"punpckhdq %%mm0, %%mm0 \n\t"
"movd %%mm0, (%3, %%"REG_a") \n\t"
"add $4, %%"REG_a" \n\t"
" js 1b \n\t"
: : "r" (src1+width*6), "r" (src2+width*6), "r" (dstU+width), "r" (dstV+width), "g" (-width)
: "%"REG_a, "%"REG_b
);
#else
int VAR_0;
for(VAR_0=0; VAR_0<width; VAR_0++)
{
int b= src1[6*VAR_0 + 0] + src1[6*VAR_0 + 3] + src2[6*VAR_0 + 0] + src2[6*VAR_0 + 3];
int g= src1[6*VAR_0 + 1] + src1[6*VAR_0 + 4] + src2[6*VAR_0 + 1] + src2[6*VAR_0 + 4];
int r= src1[6*VAR_0 + 2] + src1[6*VAR_0 + 5] + src2[6*VAR_0 + 2] + src2[6*VAR_0 + 5];
dstU[VAR_0]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128;
dstV[VAR_0]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128;
}
#endif
}
| [
"static inline void FUNC_0(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width)\n{",
"#ifdef HAVE_MMX\nasm volatile(\n\"mov %4, %%\"REG_a\"\t\t\\n\\t\"\n\"movq \"MANGLE(w1111)\", %%mm5\t\t\\n\\t\"\n\"movq \"MANGLE(bgr2UCoeff)\", %%mm6\t\t\\n\\t\"\n\"pxor %%mm7, %%mm7\t\t\\n\\t\"\n\"lea (%%\"REG_a\", %%\"REG_a\", 2), %%\"REG_b\"\t\\n\\t\"\n\"add %%\"REG_b\", %%\"REG_b\"\t\\n\\t\"\nASMALIGN16\n\"1:\t\t\t\t\\n\\t\"\nPREFETCH\" 64(%0, %%\"REG_b\")\t\\n\\t\"\nPREFETCH\" 64(%1, %%\"REG_b\")\t\\n\\t\"\n#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)\n\"movq (%0, %%\"REG_b\"), %%mm0\t\\n\\t\"\n\"movq (%1, %%\"REG_b\"), %%mm1\t\\n\\t\"\n\"movq 6(%0, %%\"REG_b\"), %%mm2\t\\n\\t\"\n\"movq 6(%1, %%\"REG_b\"), %%mm3\t\\n\\t\"\nPAVGB(%%mm1, %%mm0)\nPAVGB(%%mm3, %%mm2)\n\"movq %%mm0, %%mm1\t\t\\n\\t\"\n\"movq %%mm2, %%mm3\t\t\\n\\t\"\n\"psrlq $24, %%mm0\t\t\\n\\t\"\n\"psrlq $24, %%mm2\t\t\\n\\t\"\nPAVGB(%%mm1, %%mm0)\nPAVGB(%%mm3, %%mm2)\n\"punpcklbw %%mm7, %%mm0\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"\n#else\n\"movd (%0, %%\"REG_b\"), %%mm0\t\\n\\t\"\n\"movd (%1, %%\"REG_b\"), %%mm1\t\\n\\t\"\n\"movd 3(%0, %%\"REG_b\"), %%mm2\t\\n\\t\"\n\"movd 3(%1, %%\"REG_b\"), %%mm3\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm0\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm1\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm3\t\t\\n\\t\"\n\"paddw %%mm1, %%mm0\t\t\\n\\t\"\n\"paddw %%mm3, %%mm2\t\t\\n\\t\"\n\"paddw %%mm2, %%mm0\t\t\\n\\t\"\n\"movd 6(%0, %%\"REG_b\"), %%mm4\t\\n\\t\"\n\"movd 6(%1, %%\"REG_b\"), %%mm1\t\\n\\t\"\n\"movd 9(%0, %%\"REG_b\"), %%mm2\t\\n\\t\"\n\"movd 9(%1, %%\"REG_b\"), %%mm3\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm4\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm1\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm3\t\t\\n\\t\"\n\"paddw %%mm1, %%mm4\t\t\\n\\t\"\n\"paddw %%mm3, %%mm2\t\t\\n\\t\"\n\"paddw %%mm4, %%mm2\t\t\\n\\t\"\n\"psrlw $2, %%mm0\t\t\\n\\t\"\n\"psrlw $2, %%mm2\t\t\\n\\t\"\n#endif\n\"movq \"MANGLE(bgr2VCoeff)\", %%mm1\t\t\\n\\t\"\n\"movq \"MANGLE(bgr2VCoeff)\", %%mm3\t\t\\n\\t\"\n\"pmaddwd %%mm0, %%mm1\t\t\\n\\t\"\n\"pmaddwd %%mm2, %%mm3\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm0\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm2\t\t\\n\\t\"\n#ifndef FAST_BGR2YV12\n\"psrad $8, %%mm0\t\t\\n\\t\"\n\"psrad $8, %%mm1\t\t\\n\\t\"\n\"psrad $8, %%mm2\t\t\\n\\t\"\n\"psrad $8, %%mm3\t\t\\n\\t\"\n#endif\n\"packssdw %%mm2, %%mm0\t\t\\n\\t\"\n\"packssdw %%mm3, %%mm1\t\t\\n\\t\"\n\"pmaddwd %%mm5, %%mm0\t\t\\n\\t\"\n\"pmaddwd %%mm5, %%mm1\t\t\\n\\t\"\n\"packssdw %%mm1, %%mm0\t\t\\n\\t\"\n\"psraw $7, %%mm0\t\t\\n\\t\"\n#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)\n\"movq 12(%0, %%\"REG_b\"), %%mm4\t\\n\\t\"\n\"movq 12(%1, %%\"REG_b\"), %%mm1\t\\n\\t\"\n\"movq 18(%0, %%\"REG_b\"), %%mm2\t\\n\\t\"\n\"movq 18(%1, %%\"REG_b\"), %%mm3\t\\n\\t\"\nPAVGB(%%mm1, %%mm4)\nPAVGB(%%mm3, %%mm2)\n\"movq %%mm4, %%mm1\t\t\\n\\t\"\n\"movq %%mm2, %%mm3\t\t\\n\\t\"\n\"psrlq $24, %%mm4\t\t\\n\\t\"\n\"psrlq $24, %%mm2\t\t\\n\\t\"\nPAVGB(%%mm1, %%mm4)\nPAVGB(%%mm3, %%mm2)\n\"punpcklbw %%mm7, %%mm4\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"\n#else\n\"movd 12(%0, %%\"REG_b\"), %%mm4\t\\n\\t\"\n\"movd 12(%1, %%\"REG_b\"), %%mm1\t\\n\\t\"\n\"movd 15(%0, %%\"REG_b\"), %%mm2\t\\n\\t\"\n\"movd 15(%1, %%\"REG_b\"), %%mm3\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm4\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm1\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm3\t\t\\n\\t\"\n\"paddw %%mm1, %%mm4\t\t\\n\\t\"\n\"paddw %%mm3, %%mm2\t\t\\n\\t\"\n\"paddw %%mm2, %%mm4\t\t\\n\\t\"\n\"movd 18(%0, %%\"REG_b\"), %%mm5\t\\n\\t\"\n\"movd 18(%1, %%\"REG_b\"), %%mm1\t\\n\\t\"\n\"movd 21(%0, %%\"REG_b\"), %%mm2\t\\n\\t\"\n\"movd 21(%1, %%\"REG_b\"), %%mm3\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm5\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm1\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm2\t\t\\n\\t\"\n\"punpcklbw %%mm7, %%mm3\t\t\\n\\t\"\n\"paddw %%mm1, %%mm5\t\t\\n\\t\"\n\"paddw %%mm3, %%mm2\t\t\\n\\t\"\n\"paddw %%mm5, %%mm2\t\t\\n\\t\"\n\"movq \"MANGLE(w1111)\", %%mm5\t\t\\n\\t\"\n\"psrlw $2, %%mm4\t\t\\n\\t\"\n\"psrlw $2, %%mm2\t\t\\n\\t\"\n#endif\n\"movq \"MANGLE(bgr2VCoeff)\", %%mm1\t\t\\n\\t\"\n\"movq \"MANGLE(bgr2VCoeff)\", %%mm3\t\t\\n\\t\"\n\"pmaddwd %%mm4, %%mm1\t\t\\n\\t\"\n\"pmaddwd %%mm2, %%mm3\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm4\t\t\\n\\t\"\n\"pmaddwd %%mm6, %%mm2\t\t\\n\\t\"\n#ifndef FAST_BGR2YV12\n\"psrad $8, %%mm4\t\t\\n\\t\"\n\"psrad $8, %%mm1\t\t\\n\\t\"\n\"psrad $8, %%mm2\t\t\\n\\t\"\n\"psrad $8, %%mm3\t\t\\n\\t\"\n#endif\n\"packssdw %%mm2, %%mm4\t\t\\n\\t\"\n\"packssdw %%mm3, %%mm1\t\t\\n\\t\"\n\"pmaddwd %%mm5, %%mm4\t\t\\n\\t\"\n\"pmaddwd %%mm5, %%mm1\t\t\\n\\t\"\n\"add $24, %%\"REG_b\"\t\t\\n\\t\"\n\"packssdw %%mm1, %%mm4\t\t\\n\\t\"\n\"psraw $7, %%mm4\t\t\\n\\t\"\n\"movq %%mm0, %%mm1\t\t\\n\\t\"\n\"punpckldq %%mm4, %%mm0\t\t\\n\\t\"\n\"punpckhdq %%mm4, %%mm1\t\t\\n\\t\"\n\"packsswb %%mm1, %%mm0\t\t\\n\\t\"\n\"paddb \"MANGLE(bgr2UVOffset)\", %%mm0\t\\n\\t\"\n\"movd %%mm0, (%2, %%\"REG_a\")\t\\n\\t\"\n\"punpckhdq %%mm0, %%mm0\t\t\\n\\t\"\n\"movd %%mm0, (%3, %%\"REG_a\")\t\\n\\t\"\n\"add $4, %%\"REG_a\"\t\t\\n\\t\"\n\" js 1b\t\t\t\t\\n\\t\"\n: : \"r\" (src1+width*6), \"r\" (src2+width*6), \"r\" (dstU+width), \"r\" (dstV+width), \"g\" (-width)\n: \"%\"REG_a, \"%\"REG_b\n);",
"#else\nint VAR_0;",
"for(VAR_0=0; VAR_0<width; VAR_0++)",
"{",
"int b= src1[6*VAR_0 + 0] + src1[6*VAR_0 + 3] + src2[6*VAR_0 + 0] + src2[6*VAR_0 + 3];",
"int g= src1[6*VAR_0 + 1] + src1[6*VAR_0 + 4] + src2[6*VAR_0 + 1] + src2[6*VAR_0 + 4];",
"int r= src1[6*VAR_0 + 2] + src1[6*VAR_0 + 5] + src2[6*VAR_0 + 2] + src2[6*VAR_0 + 5];",
"dstU[VAR_0]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128;",
"dstV[VAR_0]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128;",
"}",
"#endif\n}"
] | [
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,
117,
119,
121,
123,
125,
127,
129,
131,
133,
135,
137,
139,
141,
143,
145,
147,
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,
241,
243,
245,
247,
249,
251,
253,
255,
257,
259,
261,
263,
265,
267,
269,
271,
273,
277,
279,
281,
283,
285,
289,
291,
293,
295,
297,
299,
301,
303
],
[
305,
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
321
],
[
323
],
[
325
],
[
327,
329
]
] |
24,964 | static av_cold int fbdev_write_header(AVFormatContext *h)
{
FBDevContext *fbdev = h->priv_data;
enum AVPixelFormat pix_fmt;
AVStream *st = NULL;
int ret, flags = O_RDWR;
int i;
for (i = 0; i < h->nb_streams; i++) {
if (h->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (!st) {
fbdev->index = i;
st = h->streams[i];
} else {
av_log(h, AV_LOG_WARNING, "More than one video stream found. First one is used.\n");
break;
}
}
}
if (!st) {
av_log(h, AV_LOG_ERROR, "No video stream found.\n");
return AVERROR(EINVAL);
}
if ((fbdev->fd = avpriv_open(h->filename, flags)) == -1) {
ret = AVERROR(errno);
av_log(h, AV_LOG_ERROR,
"Could not open framebuffer device '%s': %s\n",
h->filename, av_err2str(ret));
return ret;
}
if (ioctl(fbdev->fd, FBIOGET_VSCREENINFO, &fbdev->varinfo) < 0) {
ret = AVERROR(errno);
av_log(h, AV_LOG_ERROR, "FBIOGET_VSCREENINFO: %s\n", av_err2str(ret));
goto fail;
}
if (ioctl(fbdev->fd, FBIOGET_FSCREENINFO, &fbdev->fixinfo) < 0) {
ret = AVERROR(errno);
av_log(h, AV_LOG_ERROR, "FBIOGET_FSCREENINFO: %s\n", av_err2str(ret));
goto fail;
}
pix_fmt = ff_get_pixfmt_from_fb_varinfo(&fbdev->varinfo);
if (pix_fmt == AV_PIX_FMT_NONE) {
ret = AVERROR(EINVAL);
av_log(h, AV_LOG_ERROR, "Framebuffer pixel format not supported.\n");
goto fail;
}
fbdev->data = mmap(NULL, fbdev->fixinfo.smem_len, PROT_WRITE, MAP_SHARED, fbdev->fd, 0);
if (fbdev->data == MAP_FAILED) {
ret = AVERROR(errno);
av_log(h, AV_LOG_ERROR, "Error in mmap(): %s\n", av_err2str(ret));
goto fail;
}
return 0;
fail:
close(fbdev->fd);
return ret;
}
| false | FFmpeg | b04af34600d01502ac844551d157d83f7ae5db26 | static av_cold int fbdev_write_header(AVFormatContext *h)
{
FBDevContext *fbdev = h->priv_data;
enum AVPixelFormat pix_fmt;
AVStream *st = NULL;
int ret, flags = O_RDWR;
int i;
for (i = 0; i < h->nb_streams; i++) {
if (h->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (!st) {
fbdev->index = i;
st = h->streams[i];
} else {
av_log(h, AV_LOG_WARNING, "More than one video stream found. First one is used.\n");
break;
}
}
}
if (!st) {
av_log(h, AV_LOG_ERROR, "No video stream found.\n");
return AVERROR(EINVAL);
}
if ((fbdev->fd = avpriv_open(h->filename, flags)) == -1) {
ret = AVERROR(errno);
av_log(h, AV_LOG_ERROR,
"Could not open framebuffer device '%s': %s\n",
h->filename, av_err2str(ret));
return ret;
}
if (ioctl(fbdev->fd, FBIOGET_VSCREENINFO, &fbdev->varinfo) < 0) {
ret = AVERROR(errno);
av_log(h, AV_LOG_ERROR, "FBIOGET_VSCREENINFO: %s\n", av_err2str(ret));
goto fail;
}
if (ioctl(fbdev->fd, FBIOGET_FSCREENINFO, &fbdev->fixinfo) < 0) {
ret = AVERROR(errno);
av_log(h, AV_LOG_ERROR, "FBIOGET_FSCREENINFO: %s\n", av_err2str(ret));
goto fail;
}
pix_fmt = ff_get_pixfmt_from_fb_varinfo(&fbdev->varinfo);
if (pix_fmt == AV_PIX_FMT_NONE) {
ret = AVERROR(EINVAL);
av_log(h, AV_LOG_ERROR, "Framebuffer pixel format not supported.\n");
goto fail;
}
fbdev->data = mmap(NULL, fbdev->fixinfo.smem_len, PROT_WRITE, MAP_SHARED, fbdev->fd, 0);
if (fbdev->data == MAP_FAILED) {
ret = AVERROR(errno);
av_log(h, AV_LOG_ERROR, "Error in mmap(): %s\n", av_err2str(ret));
goto fail;
}
return 0;
fail:
close(fbdev->fd);
return ret;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVFormatContext *h)
{
FBDevContext *fbdev = h->priv_data;
enum AVPixelFormat VAR_0;
AVStream *st = NULL;
int VAR_1, VAR_2 = O_RDWR;
int VAR_3;
for (VAR_3 = 0; VAR_3 < h->nb_streams; VAR_3++) {
if (h->streams[VAR_3]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (!st) {
fbdev->index = VAR_3;
st = h->streams[VAR_3];
} else {
av_log(h, AV_LOG_WARNING, "More than one video stream found. First one is used.\n");
break;
}
}
}
if (!st) {
av_log(h, AV_LOG_ERROR, "No video stream found.\n");
return AVERROR(EINVAL);
}
if ((fbdev->fd = avpriv_open(h->filename, VAR_2)) == -1) {
VAR_1 = AVERROR(errno);
av_log(h, AV_LOG_ERROR,
"Could not open framebuffer device '%s': %s\n",
h->filename, av_err2str(VAR_1));
return VAR_1;
}
if (ioctl(fbdev->fd, FBIOGET_VSCREENINFO, &fbdev->varinfo) < 0) {
VAR_1 = AVERROR(errno);
av_log(h, AV_LOG_ERROR, "FBIOGET_VSCREENINFO: %s\n", av_err2str(VAR_1));
goto fail;
}
if (ioctl(fbdev->fd, FBIOGET_FSCREENINFO, &fbdev->fixinfo) < 0) {
VAR_1 = AVERROR(errno);
av_log(h, AV_LOG_ERROR, "FBIOGET_FSCREENINFO: %s\n", av_err2str(VAR_1));
goto fail;
}
VAR_0 = ff_get_pixfmt_from_fb_varinfo(&fbdev->varinfo);
if (VAR_0 == AV_PIX_FMT_NONE) {
VAR_1 = AVERROR(EINVAL);
av_log(h, AV_LOG_ERROR, "Framebuffer pixel format not supported.\n");
goto fail;
}
fbdev->data = mmap(NULL, fbdev->fixinfo.smem_len, PROT_WRITE, MAP_SHARED, fbdev->fd, 0);
if (fbdev->data == MAP_FAILED) {
VAR_1 = AVERROR(errno);
av_log(h, AV_LOG_ERROR, "Error in mmap(): %s\n", av_err2str(VAR_1));
goto fail;
}
return 0;
fail:
close(fbdev->fd);
return VAR_1;
}
| [
"static av_cold int FUNC_0(AVFormatContext *h)\n{",
"FBDevContext *fbdev = h->priv_data;",
"enum AVPixelFormat VAR_0;",
"AVStream *st = NULL;",
"int VAR_1, VAR_2 = O_RDWR;",
"int VAR_3;",
"for (VAR_3 = 0; VAR_3 < h->nb_streams; VAR_3++) {",
"if (h->streams[VAR_3]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {",
"if (!st) {",
"fbdev->index = VAR_3;",
"st = h->streams[VAR_3];",
"} else {",
"av_log(h, AV_LOG_WARNING, \"More than one video stream found. First one is used.\\n\");",
"break;",
"}",
"}",
"}",
"if (!st) {",
"av_log(h, AV_LOG_ERROR, \"No video stream found.\\n\");",
"return AVERROR(EINVAL);",
"}",
"if ((fbdev->fd = avpriv_open(h->filename, VAR_2)) == -1) {",
"VAR_1 = AVERROR(errno);",
"av_log(h, AV_LOG_ERROR,\n\"Could not open framebuffer device '%s': %s\\n\",\nh->filename, av_err2str(VAR_1));",
"return VAR_1;",
"}",
"if (ioctl(fbdev->fd, FBIOGET_VSCREENINFO, &fbdev->varinfo) < 0) {",
"VAR_1 = AVERROR(errno);",
"av_log(h, AV_LOG_ERROR, \"FBIOGET_VSCREENINFO: %s\\n\", av_err2str(VAR_1));",
"goto fail;",
"}",
"if (ioctl(fbdev->fd, FBIOGET_FSCREENINFO, &fbdev->fixinfo) < 0) {",
"VAR_1 = AVERROR(errno);",
"av_log(h, AV_LOG_ERROR, \"FBIOGET_FSCREENINFO: %s\\n\", av_err2str(VAR_1));",
"goto fail;",
"}",
"VAR_0 = ff_get_pixfmt_from_fb_varinfo(&fbdev->varinfo);",
"if (VAR_0 == AV_PIX_FMT_NONE) {",
"VAR_1 = AVERROR(EINVAL);",
"av_log(h, AV_LOG_ERROR, \"Framebuffer pixel format not supported.\\n\");",
"goto fail;",
"}",
"fbdev->data = mmap(NULL, fbdev->fixinfo.smem_len, PROT_WRITE, MAP_SHARED, fbdev->fd, 0);",
"if (fbdev->data == MAP_FAILED) {",
"VAR_1 = AVERROR(errno);",
"av_log(h, AV_LOG_ERROR, \"Error in mmap(): %s\\n\", av_err2str(VAR_1));",
"goto fail;",
"}",
"return 0;",
"fail:\nclose(fbdev->fd);",
"return VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53,
55,
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119,
121
],
[
123
],
[
125
]
] |
24,967 | static int qcow2_truncate(BlockDriverState *bs, int64_t offset)
{
BDRVQcowState *s = bs->opaque;
int ret, new_l1_size;
if (offset & 511) {
return -EINVAL;
}
/* cannot proceed if image has snapshots */
if (s->nb_snapshots) {
return -ENOTSUP;
}
/* shrinking is currently not supported */
if (offset < bs->total_sectors * 512) {
return -ENOTSUP;
}
new_l1_size = size_to_l1(s, offset);
ret = qcow2_grow_l1_table(bs, new_l1_size);
if (ret < 0) {
return ret;
}
/* write updated header.size */
offset = cpu_to_be64(offset);
ret = bdrv_pwrite(bs->file, offsetof(QCowHeader, size),
&offset, sizeof(uint64_t));
if (ret < 0) {
return ret;
}
s->l1_vm_state_index = new_l1_size;
return 0;
}
| true | qemu | 8b3b720620a1137a1b794fc3ed64734236f94e06 | static int qcow2_truncate(BlockDriverState *bs, int64_t offset)
{
BDRVQcowState *s = bs->opaque;
int ret, new_l1_size;
if (offset & 511) {
return -EINVAL;
}
if (s->nb_snapshots) {
return -ENOTSUP;
}
if (offset < bs->total_sectors * 512) {
return -ENOTSUP;
}
new_l1_size = size_to_l1(s, offset);
ret = qcow2_grow_l1_table(bs, new_l1_size);
if (ret < 0) {
return ret;
}
offset = cpu_to_be64(offset);
ret = bdrv_pwrite(bs->file, offsetof(QCowHeader, size),
&offset, sizeof(uint64_t));
if (ret < 0) {
return ret;
}
s->l1_vm_state_index = new_l1_size;
return 0;
}
| {
"code": [
" ret = bdrv_pwrite(bs->file, offsetof(QCowHeader, size),",
" &offset, sizeof(uint64_t));"
],
"line_no": [
55,
57
]
} | static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1)
{
BDRVQcowState *s = VAR_0->opaque;
int VAR_2, VAR_3;
if (VAR_1 & 511) {
return -EINVAL;
}
if (s->nb_snapshots) {
return -ENOTSUP;
}
if (VAR_1 < VAR_0->total_sectors * 512) {
return -ENOTSUP;
}
VAR_3 = size_to_l1(s, VAR_1);
VAR_2 = qcow2_grow_l1_table(VAR_0, VAR_3);
if (VAR_2 < 0) {
return VAR_2;
}
VAR_1 = cpu_to_be64(VAR_1);
VAR_2 = bdrv_pwrite(VAR_0->file, offsetof(QCowHeader, size),
&VAR_1, sizeof(uint64_t));
if (VAR_2 < 0) {
return VAR_2;
}
s->l1_vm_state_index = VAR_3;
return 0;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"int VAR_2, VAR_3;",
"if (VAR_1 & 511) {",
"return -EINVAL;",
"}",
"if (s->nb_snapshots) {",
"return -ENOTSUP;",
"}",
"if (VAR_1 < VAR_0->total_sectors * 512) {",
"return -ENOTSUP;",
"}",
"VAR_3 = size_to_l1(s, VAR_1);",
"VAR_2 = qcow2_grow_l1_table(VAR_0, VAR_3);",
"if (VAR_2 < 0) {",
"return VAR_2;",
"}",
"VAR_1 = cpu_to_be64(VAR_1);",
"VAR_2 = bdrv_pwrite(VAR_0->file, offsetof(QCowHeader, size),\n&VAR_1, sizeof(uint64_t));",
"if (VAR_2 < 0) {",
"return VAR_2;",
"}",
"s->l1_vm_state_index = VAR_3;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
21
],
[
23
],
[
25
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
]
] |
24,969 | int qemu_mutex_trylock(QemuMutex *mutex)
{
int owned;
owned = TryEnterCriticalSection(&mutex->lock);
if (owned) {
assert(mutex->owner == 0);
mutex->owner = GetCurrentThreadId();
}
return !owned;
}
| true | qemu | 12f8def0e02232d7c6416ad9b66640f973c531d1 | int qemu_mutex_trylock(QemuMutex *mutex)
{
int owned;
owned = TryEnterCriticalSection(&mutex->lock);
if (owned) {
assert(mutex->owner == 0);
mutex->owner = GetCurrentThreadId();
}
return !owned;
}
| {
"code": [
" owned = TryEnterCriticalSection(&mutex->lock);",
" if (owned) {",
" assert(mutex->owner == 0);",
" mutex->owner = GetCurrentThreadId();"
],
"line_no": [
9,
11,
13,
15
]
} | int FUNC_0(QemuMutex *VAR_0)
{
int VAR_1;
VAR_1 = TryEnterCriticalSection(&VAR_0->lock);
if (VAR_1) {
assert(VAR_0->owner == 0);
VAR_0->owner = GetCurrentThreadId();
}
return !VAR_1;
}
| [
"int FUNC_0(QemuMutex *VAR_0)\n{",
"int VAR_1;",
"VAR_1 = TryEnterCriticalSection(&VAR_0->lock);",
"if (VAR_1) {",
"assert(VAR_0->owner == 0);",
"VAR_0->owner = GetCurrentThreadId();",
"}",
"return !VAR_1;",
"}"
] | [
0,
0,
1,
1,
1,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
24,970 | static void nic_reset(void *opaque)
{
EEPRO100State *s = opaque;
TRACE(OTHER, logout("%p\n", s));
/* TODO: Clearing of multicast table for selective reset, too? */
memset(&s->mult[0], 0, sizeof(s->mult));
nic_selective_reset(s);
}
| true | qemu | 010ec6293409f10b88631c36145944b9c3277ce1 | static void nic_reset(void *opaque)
{
EEPRO100State *s = opaque;
TRACE(OTHER, logout("%p\n", s));
memset(&s->mult[0], 0, sizeof(s->mult));
nic_selective_reset(s);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
EEPRO100State *s = VAR_0;
TRACE(OTHER, logout("%p\n", s));
memset(&s->mult[0], 0, sizeof(s->mult));
nic_selective_reset(s);
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"EEPRO100State *s = VAR_0;",
"TRACE(OTHER, logout(\"%p\\n\", s));",
"memset(&s->mult[0], 0, sizeof(s->mult));",
"nic_selective_reset(s);",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
]
] |
24,971 | static void usb_mtp_object_readdir(MTPState *s, MTPObject *o)
{
struct dirent *entry;
DIR *dir;
if (o->have_children) {
return;
}
o->have_children = true;
dir = opendir(o->path);
if (!dir) {
return;
}
#ifdef __linux__
int watchfd = usb_mtp_add_watch(s->inotifyfd, o->path);
if (watchfd == -1) {
fprintf(stderr, "usb-mtp: failed to add watch for %s\n", o->path);
} else {
trace_usb_mtp_inotify_event(s->dev.addr, o->path,
0, "Watch Added");
o->watchfd = watchfd;
}
#endif
while ((entry = readdir(dir)) != NULL) {
usb_mtp_add_child(s, o, entry->d_name);
}
closedir(dir);
}
| true | qemu | 983bff3530782d51c46c8d7c0e17e2a9dfe5fb77 | static void usb_mtp_object_readdir(MTPState *s, MTPObject *o)
{
struct dirent *entry;
DIR *dir;
if (o->have_children) {
return;
}
o->have_children = true;
dir = opendir(o->path);
if (!dir) {
return;
}
#ifdef __linux__
int watchfd = usb_mtp_add_watch(s->inotifyfd, o->path);
if (watchfd == -1) {
fprintf(stderr, "usb-mtp: failed to add watch for %s\n", o->path);
} else {
trace_usb_mtp_inotify_event(s->dev.addr, o->path,
0, "Watch Added");
o->watchfd = watchfd;
}
#endif
while ((entry = readdir(dir)) != NULL) {
usb_mtp_add_child(s, o, entry->d_name);
}
closedir(dir);
}
| {
"code": [
"#ifdef __linux__",
"#ifdef __linux__",
"#ifdef __linux__",
"#ifdef __linux__",
"#ifdef __linux__",
"#ifdef __linux__",
"#ifdef __linux__",
"#ifdef __linux__",
"#ifdef __linux__",
"#ifdef __linux__"
],
"line_no": [
29,
29,
29,
29,
29,
29,
29,
29,
29,
29
]
} | static void FUNC_0(MTPState *VAR_0, MTPObject *VAR_1)
{
struct dirent *VAR_2;
DIR *dir;
if (VAR_1->have_children) {
return;
}
VAR_1->have_children = true;
dir = opendir(VAR_1->path);
if (!dir) {
return;
}
#ifdef __linux__
int watchfd = usb_mtp_add_watch(VAR_0->inotifyfd, VAR_1->path);
if (watchfd == -1) {
fprintf(stderr, "usb-mtp: failed to add watch for %VAR_0\n", VAR_1->path);
} else {
trace_usb_mtp_inotify_event(VAR_0->dev.addr, VAR_1->path,
0, "Watch Added");
VAR_1->watchfd = watchfd;
}
#endif
while ((VAR_2 = readdir(dir)) != NULL) {
usb_mtp_add_child(VAR_0, VAR_1, VAR_2->d_name);
}
closedir(dir);
}
| [
"static void FUNC_0(MTPState *VAR_0, MTPObject *VAR_1)\n{",
"struct dirent *VAR_2;",
"DIR *dir;",
"if (VAR_1->have_children) {",
"return;",
"}",
"VAR_1->have_children = true;",
"dir = opendir(VAR_1->path);",
"if (!dir) {",
"return;",
"}",
"#ifdef __linux__\nint watchfd = usb_mtp_add_watch(VAR_0->inotifyfd, VAR_1->path);",
"if (watchfd == -1) {",
"fprintf(stderr, \"usb-mtp: failed to add watch for %VAR_0\\n\", VAR_1->path);",
"} else {",
"trace_usb_mtp_inotify_event(VAR_0->dev.addr, VAR_1->path,\n0, \"Watch Added\");",
"VAR_1->watchfd = watchfd;",
"}",
"#endif\nwhile ((VAR_2 = readdir(dir)) != NULL) {",
"usb_mtp_add_child(VAR_0, VAR_1, VAR_2->d_name);",
"}",
"closedir(dir);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
]
] |
24,972 | static int swScale(SwsContext *c, const uint8_t *src[],
int srcStride[], int srcSliceY,
int srcSliceH, uint8_t *dst[], int dstStride[])
{
/* load a few things into local vars to make the code more readable?
* and faster */
const int srcW = c->srcW;
const int dstW = c->dstW;
const int dstH = c->dstH;
const int chrDstW = c->chrDstW;
const int chrSrcW = c->chrSrcW;
const int lumXInc = c->lumXInc;
const int chrXInc = c->chrXInc;
const enum PixelFormat dstFormat = c->dstFormat;
const int flags = c->flags;
int32_t *vLumFilterPos = c->vLumFilterPos;
int32_t *vChrFilterPos = c->vChrFilterPos;
int32_t *hLumFilterPos = c->hLumFilterPos;
int32_t *hChrFilterPos = c->hChrFilterPos;
int16_t *vLumFilter = c->vLumFilter;
int16_t *vChrFilter = c->vChrFilter;
int16_t *hLumFilter = c->hLumFilter;
int16_t *hChrFilter = c->hChrFilter;
int32_t *lumMmxFilter = c->lumMmxFilter;
int32_t *chrMmxFilter = c->chrMmxFilter;
const int vLumFilterSize = c->vLumFilterSize;
const int vChrFilterSize = c->vChrFilterSize;
const int hLumFilterSize = c->hLumFilterSize;
const int hChrFilterSize = c->hChrFilterSize;
int16_t **lumPixBuf = c->lumPixBuf;
int16_t **chrUPixBuf = c->chrUPixBuf;
int16_t **chrVPixBuf = c->chrVPixBuf;
int16_t **alpPixBuf = c->alpPixBuf;
const int vLumBufSize = c->vLumBufSize;
const int vChrBufSize = c->vChrBufSize;
uint8_t *formatConvBuffer = c->formatConvBuffer;
uint32_t *pal = c->pal_yuv;
yuv2planar1_fn yuv2plane1 = c->yuv2plane1;
yuv2planarX_fn yuv2planeX = c->yuv2planeX;
yuv2interleavedX_fn yuv2nv12cX = c->yuv2nv12cX;
yuv2packed1_fn yuv2packed1 = c->yuv2packed1;
yuv2packed2_fn yuv2packed2 = c->yuv2packed2;
yuv2packedX_fn yuv2packedX = c->yuv2packedX;
const int chrSrcSliceY = srcSliceY >> c->chrSrcVSubSample;
const int chrSrcSliceH = -((-srcSliceH) >> c->chrSrcVSubSample);
int should_dither = is9_OR_10BPS(c->srcFormat) ||
is16BPS(c->srcFormat);
int lastDstY;
/* vars which will change and which we need to store back in the context */
int dstY = c->dstY;
int lumBufIndex = c->lumBufIndex;
int chrBufIndex = c->chrBufIndex;
int lastInLumBuf = c->lastInLumBuf;
int lastInChrBuf = c->lastInChrBuf;
if (isPacked(c->srcFormat)) {
src[0] =
src[1] =
src[2] =
src[3] = src[0];
srcStride[0] =
srcStride[1] =
srcStride[2] =
srcStride[3] = srcStride[0];
}
srcStride[1] <<= c->vChrDrop;
srcStride[2] <<= c->vChrDrop;
DEBUG_BUFFERS("swScale() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\n",
src[0], srcStride[0], src[1], srcStride[1],
src[2], srcStride[2], src[3], srcStride[3],
dst[0], dstStride[0], dst[1], dstStride[1],
dst[2], dstStride[2], dst[3], dstStride[3]);
DEBUG_BUFFERS("srcSliceY: %d srcSliceH: %d dstY: %d dstH: %d\n",
srcSliceY, srcSliceH, dstY, dstH);
DEBUG_BUFFERS("vLumFilterSize: %d vLumBufSize: %d vChrFilterSize: %d vChrBufSize: %d\n",
vLumFilterSize, vLumBufSize, vChrFilterSize, vChrBufSize);
if (dstStride[0] % 8 != 0 || dstStride[1] % 8 != 0 ||
dstStride[2] % 8 != 0 || dstStride[3] % 8 != 0) {
static int warnedAlready = 0; // FIXME maybe move this into the context
if (flags & SWS_PRINT_INFO && !warnedAlready) {
av_log(c, AV_LOG_WARNING,
"Warning: dstStride is not aligned!\n"
" ->cannot do aligned memory accesses anymore\n");
warnedAlready = 1;
}
}
/* Note the user might start scaling the picture in the middle so this
* will not get executed. This is not really intended but works
* currently, so people might do it. */
if (srcSliceY == 0) {
lumBufIndex = -1;
chrBufIndex = -1;
dstY = 0;
lastInLumBuf = -1;
lastInChrBuf = -1;
}
if (!should_dither) {
c->chrDither8 = c->lumDither8 = ff_sws_pb_64;
}
lastDstY = dstY;
for (; dstY < dstH; dstY++) {
const int chrDstY = dstY >> c->chrDstVSubSample;
uint8_t *dest[4] = {
dst[0] + dstStride[0] * dstY,
dst[1] + dstStride[1] * chrDstY,
dst[2] + dstStride[2] * chrDstY,
(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3] + dstStride[3] * dstY : NULL,
};
// First line needed as input
const int firstLumSrcY = FFMAX(1 - vLumFilterSize, vLumFilterPos[dstY]);
const int firstLumSrcY2 = FFMAX(1 - vLumFilterSize, vLumFilterPos[FFMIN(dstY | ((1 << c->chrDstVSubSample) - 1), dstH - 1)]);
// First line needed as input
const int firstChrSrcY = FFMAX(1 - vChrFilterSize, vChrFilterPos[chrDstY]);
// Last line needed as input
int lastLumSrcY = FFMIN(c->srcH, firstLumSrcY + vLumFilterSize) - 1;
int lastLumSrcY2 = FFMIN(c->srcH, firstLumSrcY2 + vLumFilterSize) - 1;
int lastChrSrcY = FFMIN(c->chrSrcH, firstChrSrcY + vChrFilterSize) - 1;
int enough_lines;
// handle holes (FAST_BILINEAR & weird filters)
if (firstLumSrcY > lastInLumBuf)
lastInLumBuf = firstLumSrcY - 1;
if (firstChrSrcY > lastInChrBuf)
lastInChrBuf = firstChrSrcY - 1;
assert(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1);
assert(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1);
DEBUG_BUFFERS("dstY: %d\n", dstY);
DEBUG_BUFFERS("\tfirstLumSrcY: %d lastLumSrcY: %d lastInLumBuf: %d\n",
firstLumSrcY, lastLumSrcY, lastInLumBuf);
DEBUG_BUFFERS("\tfirstChrSrcY: %d lastChrSrcY: %d lastInChrBuf: %d\n",
firstChrSrcY, lastChrSrcY, lastInChrBuf);
// Do we have enough lines in this slice to output the dstY line
enough_lines = lastLumSrcY2 < srcSliceY + srcSliceH &&
lastChrSrcY < -((-srcSliceY - srcSliceH) >> c->chrSrcVSubSample);
if (!enough_lines) {
lastLumSrcY = srcSliceY + srcSliceH - 1;
lastChrSrcY = chrSrcSliceY + chrSrcSliceH - 1;
DEBUG_BUFFERS("buffering slice: lastLumSrcY %d lastChrSrcY %d\n",
lastLumSrcY, lastChrSrcY);
}
// Do horizontal scaling
while (lastInLumBuf < lastLumSrcY) {
const uint8_t *src1[4] = {
src[0] + (lastInLumBuf + 1 - srcSliceY) * srcStride[0],
src[1] + (lastInLumBuf + 1 - srcSliceY) * srcStride[1],
src[2] + (lastInLumBuf + 1 - srcSliceY) * srcStride[2],
src[3] + (lastInLumBuf + 1 - srcSliceY) * srcStride[3],
};
lumBufIndex++;
assert(lumBufIndex < 2 * vLumBufSize);
assert(lastInLumBuf + 1 - srcSliceY < srcSliceH);
assert(lastInLumBuf + 1 - srcSliceY >= 0);
hyscale(c, lumPixBuf[lumBufIndex], dstW, src1, srcW, lumXInc,
hLumFilter, hLumFilterPos, hLumFilterSize,
formatConvBuffer, pal, 0);
if (CONFIG_SWSCALE_ALPHA && alpPixBuf)
hyscale(c, alpPixBuf[lumBufIndex], dstW, src1, srcW,
lumXInc, hLumFilter, hLumFilterPos, hLumFilterSize,
formatConvBuffer, pal, 1);
lastInLumBuf++;
DEBUG_BUFFERS("\t\tlumBufIndex %d: lastInLumBuf: %d\n",
lumBufIndex, lastInLumBuf);
}
while (lastInChrBuf < lastChrSrcY) {
const uint8_t *src1[4] = {
src[0] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[0],
src[1] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[1],
src[2] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[2],
src[3] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[3],
};
chrBufIndex++;
assert(chrBufIndex < 2 * vChrBufSize);
assert(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH));
assert(lastInChrBuf + 1 - chrSrcSliceY >= 0);
// FIXME replace parameters through context struct (some at least)
if (c->needs_hcscale)
hcscale(c, chrUPixBuf[chrBufIndex], chrVPixBuf[chrBufIndex],
chrDstW, src1, chrSrcW, chrXInc,
hChrFilter, hChrFilterPos, hChrFilterSize,
formatConvBuffer, pal);
lastInChrBuf++;
DEBUG_BUFFERS("\t\tchrBufIndex %d: lastInChrBuf: %d\n",
chrBufIndex, lastInChrBuf);
}
// wrap buf index around to stay inside the ring buffer
if (lumBufIndex >= vLumBufSize)
lumBufIndex -= vLumBufSize;
if (chrBufIndex >= vChrBufSize)
chrBufIndex -= vChrBufSize;
if (!enough_lines)
break; // we can't output a dstY line so let's try with the next slice
#if HAVE_MMX
updateMMXDitherTables(c, dstY, lumBufIndex, chrBufIndex,
lastInLumBuf, lastInChrBuf);
#endif
if (should_dither) {
c->chrDither8 = dither_8x8_128[chrDstY & 7];
c->lumDither8 = dither_8x8_128[dstY & 7];
}
if (dstY >= dstH - 2) {
/* hmm looks like we can't use MMX here without overwriting
* this array's tail */
ff_sws_init_output_funcs(c, &yuv2plane1, &yuv2planeX, &yuv2nv12cX,
&yuv2packed1, &yuv2packed2, &yuv2packedX);
}
{
const int16_t **lumSrcPtr = (const int16_t **)lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
const int16_t **chrUSrcPtr = (const int16_t **)chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
const int16_t **chrVSrcPtr = (const int16_t **)chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
const int16_t **alpSrcPtr = (CONFIG_SWSCALE_ALPHA && alpPixBuf) ?
(const int16_t **)alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
if (firstLumSrcY < 0 || firstLumSrcY + vLumFilterSize > c->srcH) {
const int16_t **tmpY = (const int16_t **)lumPixBuf +
2 * vLumBufSize;
int neg = -firstLumSrcY, i;
int end = FFMIN(c->srcH - firstLumSrcY, vLumFilterSize);
for (i = 0; i < neg; i++)
tmpY[i] = lumSrcPtr[neg];
for (; i < end; i++)
tmpY[i] = lumSrcPtr[i];
for (; i < vLumFilterSize; i++)
tmpY[i] = tmpY[i - 1];
lumSrcPtr = tmpY;
if (alpSrcPtr) {
const int16_t **tmpA = (const int16_t **)alpPixBuf +
2 * vLumBufSize;
for (i = 0; i < neg; i++)
tmpA[i] = alpSrcPtr[neg];
for (; i < end; i++)
tmpA[i] = alpSrcPtr[i];
for (; i < vLumFilterSize; i++)
tmpA[i] = tmpA[i - 1];
alpSrcPtr = tmpA;
}
}
if (firstChrSrcY < 0 ||
firstChrSrcY + vChrFilterSize > c->chrSrcH) {
const int16_t **tmpU = (const int16_t **)chrUPixBuf + 2 * vChrBufSize,
**tmpV = (const int16_t **)chrVPixBuf + 2 * vChrBufSize;
int neg = -firstChrSrcY, i;
int end = FFMIN(c->chrSrcH - firstChrSrcY, vChrFilterSize);
for (i = 0; i < neg; i++) {
tmpU[i] = chrUSrcPtr[neg];
tmpV[i] = chrVSrcPtr[neg];
}
for (; i < end; i++) {
tmpU[i] = chrUSrcPtr[i];
tmpV[i] = chrVSrcPtr[i];
}
for (; i < vChrFilterSize; i++) {
tmpU[i] = tmpU[i - 1];
tmpV[i] = tmpV[i - 1];
}
chrUSrcPtr = tmpU;
chrVSrcPtr = tmpV;
}
if (isPlanarYUV(dstFormat) ||
(isGray(dstFormat) && !isALPHA(dstFormat))) { // YV12 like
const int chrSkipMask = (1 << c->chrDstVSubSample) - 1;
if (vLumFilterSize == 1) {
yuv2plane1(lumSrcPtr[0], dest[0], dstW, c->lumDither8, 0);
} else {
yuv2planeX(vLumFilter + dstY * vLumFilterSize,
vLumFilterSize, lumSrcPtr, dest[0],
dstW, c->lumDither8, 0);
}
if (!((dstY & chrSkipMask) || isGray(dstFormat))) {
if (yuv2nv12cX) {
yuv2nv12cX(c, vChrFilter + chrDstY * vChrFilterSize,
vChrFilterSize, chrUSrcPtr, chrVSrcPtr,
dest[1], chrDstW);
} else if (vChrFilterSize == 1) {
yuv2plane1(chrUSrcPtr[0], dest[1], chrDstW, c->chrDither8, 0);
yuv2plane1(chrVSrcPtr[0], dest[2], chrDstW, c->chrDither8, 3);
} else {
yuv2planeX(vChrFilter + chrDstY * vChrFilterSize,
vChrFilterSize, chrUSrcPtr, dest[1],
chrDstW, c->chrDither8, 0);
yuv2planeX(vChrFilter + chrDstY * vChrFilterSize,
vChrFilterSize, chrVSrcPtr, dest[2],
chrDstW, c->chrDither8, 3);
}
}
if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
if (vLumFilterSize == 1) {
yuv2plane1(alpSrcPtr[0], dest[3], dstW,
c->lumDither8, 0);
} else {
yuv2planeX(vLumFilter + dstY * vLumFilterSize,
vLumFilterSize, alpSrcPtr, dest[3],
dstW, c->lumDither8, 0);
}
}
} else {
assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize * 2);
assert(chrUSrcPtr + vChrFilterSize - 1 < chrUPixBuf + vChrBufSize * 2);
if (c->yuv2packed1 && vLumFilterSize == 1 &&
vChrFilterSize <= 2) { // unscaled RGB
int chrAlpha = vChrFilterSize == 1 ? 0 : vChrFilter[2 * dstY + 1];
yuv2packed1(c, *lumSrcPtr, chrUSrcPtr, chrVSrcPtr,
alpPixBuf ? *alpSrcPtr : NULL,
dest[0], dstW, chrAlpha, dstY);
} else if (c->yuv2packed2 && vLumFilterSize == 2 &&
vChrFilterSize == 2) { // bilinear upscale RGB
int lumAlpha = vLumFilter[2 * dstY + 1];
int chrAlpha = vChrFilter[2 * dstY + 1];
lumMmxFilter[2] =
lumMmxFilter[3] = vLumFilter[2 * dstY] * 0x10001;
chrMmxFilter[2] =
chrMmxFilter[3] = vChrFilter[2 * chrDstY] * 0x10001;
yuv2packed2(c, lumSrcPtr, chrUSrcPtr, chrVSrcPtr,
alpPixBuf ? alpSrcPtr : NULL,
dest[0], dstW, lumAlpha, chrAlpha, dstY);
} else { // general RGB
yuv2packedX(c, vLumFilter + dstY * vLumFilterSize,
lumSrcPtr, vLumFilterSize,
vChrFilter + dstY * vChrFilterSize,
chrUSrcPtr, chrVSrcPtr, vChrFilterSize,
alpSrcPtr, dest[0], dstW, dstY);
}
}
}
}
if (isPlanar(dstFormat) && isALPHA(dstFormat) && !alpPixBuf)
fillPlane(dst[3], dstStride[3], dstW, dstY - lastDstY, lastDstY, 255);
#if HAVE_MMX2
if (av_get_cpu_flags() & AV_CPU_FLAG_MMX2)
__asm__ volatile ("sfence" ::: "memory");
#endif
emms_c();
/* store changed local vars back in the context */
c->dstY = dstY;
c->lumBufIndex = lumBufIndex;
c->chrBufIndex = chrBufIndex;
c->lastInLumBuf = lastInLumBuf;
c->lastInChrBuf = lastInChrBuf;
return dstY - lastDstY;
}
| false | FFmpeg | 3b175384bb6491ecd44761e5282ae4c79567db57 | static int swScale(SwsContext *c, const uint8_t *src[],
int srcStride[], int srcSliceY,
int srcSliceH, uint8_t *dst[], int dstStride[])
{
const int srcW = c->srcW;
const int dstW = c->dstW;
const int dstH = c->dstH;
const int chrDstW = c->chrDstW;
const int chrSrcW = c->chrSrcW;
const int lumXInc = c->lumXInc;
const int chrXInc = c->chrXInc;
const enum PixelFormat dstFormat = c->dstFormat;
const int flags = c->flags;
int32_t *vLumFilterPos = c->vLumFilterPos;
int32_t *vChrFilterPos = c->vChrFilterPos;
int32_t *hLumFilterPos = c->hLumFilterPos;
int32_t *hChrFilterPos = c->hChrFilterPos;
int16_t *vLumFilter = c->vLumFilter;
int16_t *vChrFilter = c->vChrFilter;
int16_t *hLumFilter = c->hLumFilter;
int16_t *hChrFilter = c->hChrFilter;
int32_t *lumMmxFilter = c->lumMmxFilter;
int32_t *chrMmxFilter = c->chrMmxFilter;
const int vLumFilterSize = c->vLumFilterSize;
const int vChrFilterSize = c->vChrFilterSize;
const int hLumFilterSize = c->hLumFilterSize;
const int hChrFilterSize = c->hChrFilterSize;
int16_t **lumPixBuf = c->lumPixBuf;
int16_t **chrUPixBuf = c->chrUPixBuf;
int16_t **chrVPixBuf = c->chrVPixBuf;
int16_t **alpPixBuf = c->alpPixBuf;
const int vLumBufSize = c->vLumBufSize;
const int vChrBufSize = c->vChrBufSize;
uint8_t *formatConvBuffer = c->formatConvBuffer;
uint32_t *pal = c->pal_yuv;
yuv2planar1_fn yuv2plane1 = c->yuv2plane1;
yuv2planarX_fn yuv2planeX = c->yuv2planeX;
yuv2interleavedX_fn yuv2nv12cX = c->yuv2nv12cX;
yuv2packed1_fn yuv2packed1 = c->yuv2packed1;
yuv2packed2_fn yuv2packed2 = c->yuv2packed2;
yuv2packedX_fn yuv2packedX = c->yuv2packedX;
const int chrSrcSliceY = srcSliceY >> c->chrSrcVSubSample;
const int chrSrcSliceH = -((-srcSliceH) >> c->chrSrcVSubSample);
int should_dither = is9_OR_10BPS(c->srcFormat) ||
is16BPS(c->srcFormat);
int lastDstY;
int dstY = c->dstY;
int lumBufIndex = c->lumBufIndex;
int chrBufIndex = c->chrBufIndex;
int lastInLumBuf = c->lastInLumBuf;
int lastInChrBuf = c->lastInChrBuf;
if (isPacked(c->srcFormat)) {
src[0] =
src[1] =
src[2] =
src[3] = src[0];
srcStride[0] =
srcStride[1] =
srcStride[2] =
srcStride[3] = srcStride[0];
}
srcStride[1] <<= c->vChrDrop;
srcStride[2] <<= c->vChrDrop;
DEBUG_BUFFERS("swScale() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\n",
src[0], srcStride[0], src[1], srcStride[1],
src[2], srcStride[2], src[3], srcStride[3],
dst[0], dstStride[0], dst[1], dstStride[1],
dst[2], dstStride[2], dst[3], dstStride[3]);
DEBUG_BUFFERS("srcSliceY: %d srcSliceH: %d dstY: %d dstH: %d\n",
srcSliceY, srcSliceH, dstY, dstH);
DEBUG_BUFFERS("vLumFilterSize: %d vLumBufSize: %d vChrFilterSize: %d vChrBufSize: %d\n",
vLumFilterSize, vLumBufSize, vChrFilterSize, vChrBufSize);
if (dstStride[0] % 8 != 0 || dstStride[1] % 8 != 0 ||
dstStride[2] % 8 != 0 || dstStride[3] % 8 != 0) {
static int warnedAlready = 0;
if (flags & SWS_PRINT_INFO && !warnedAlready) {
av_log(c, AV_LOG_WARNING,
"Warning: dstStride is not aligned!\n"
" ->cannot do aligned memory accesses anymore\n");
warnedAlready = 1;
}
}
if (srcSliceY == 0) {
lumBufIndex = -1;
chrBufIndex = -1;
dstY = 0;
lastInLumBuf = -1;
lastInChrBuf = -1;
}
if (!should_dither) {
c->chrDither8 = c->lumDither8 = ff_sws_pb_64;
}
lastDstY = dstY;
for (; dstY < dstH; dstY++) {
const int chrDstY = dstY >> c->chrDstVSubSample;
uint8_t *dest[4] = {
dst[0] + dstStride[0] * dstY,
dst[1] + dstStride[1] * chrDstY,
dst[2] + dstStride[2] * chrDstY,
(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3] + dstStride[3] * dstY : NULL,
};
const int firstLumSrcY = FFMAX(1 - vLumFilterSize, vLumFilterPos[dstY]);
const int firstLumSrcY2 = FFMAX(1 - vLumFilterSize, vLumFilterPos[FFMIN(dstY | ((1 << c->chrDstVSubSample) - 1), dstH - 1)]);
const int firstChrSrcY = FFMAX(1 - vChrFilterSize, vChrFilterPos[chrDstY]);
int lastLumSrcY = FFMIN(c->srcH, firstLumSrcY + vLumFilterSize) - 1;
int lastLumSrcY2 = FFMIN(c->srcH, firstLumSrcY2 + vLumFilterSize) - 1;
int lastChrSrcY = FFMIN(c->chrSrcH, firstChrSrcY + vChrFilterSize) - 1;
int enough_lines;
if (firstLumSrcY > lastInLumBuf)
lastInLumBuf = firstLumSrcY - 1;
if (firstChrSrcY > lastInChrBuf)
lastInChrBuf = firstChrSrcY - 1;
assert(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1);
assert(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1);
DEBUG_BUFFERS("dstY: %d\n", dstY);
DEBUG_BUFFERS("\tfirstLumSrcY: %d lastLumSrcY: %d lastInLumBuf: %d\n",
firstLumSrcY, lastLumSrcY, lastInLumBuf);
DEBUG_BUFFERS("\tfirstChrSrcY: %d lastChrSrcY: %d lastInChrBuf: %d\n",
firstChrSrcY, lastChrSrcY, lastInChrBuf);
enough_lines = lastLumSrcY2 < srcSliceY + srcSliceH &&
lastChrSrcY < -((-srcSliceY - srcSliceH) >> c->chrSrcVSubSample);
if (!enough_lines) {
lastLumSrcY = srcSliceY + srcSliceH - 1;
lastChrSrcY = chrSrcSliceY + chrSrcSliceH - 1;
DEBUG_BUFFERS("buffering slice: lastLumSrcY %d lastChrSrcY %d\n",
lastLumSrcY, lastChrSrcY);
}
while (lastInLumBuf < lastLumSrcY) {
const uint8_t *src1[4] = {
src[0] + (lastInLumBuf + 1 - srcSliceY) * srcStride[0],
src[1] + (lastInLumBuf + 1 - srcSliceY) * srcStride[1],
src[2] + (lastInLumBuf + 1 - srcSliceY) * srcStride[2],
src[3] + (lastInLumBuf + 1 - srcSliceY) * srcStride[3],
};
lumBufIndex++;
assert(lumBufIndex < 2 * vLumBufSize);
assert(lastInLumBuf + 1 - srcSliceY < srcSliceH);
assert(lastInLumBuf + 1 - srcSliceY >= 0);
hyscale(c, lumPixBuf[lumBufIndex], dstW, src1, srcW, lumXInc,
hLumFilter, hLumFilterPos, hLumFilterSize,
formatConvBuffer, pal, 0);
if (CONFIG_SWSCALE_ALPHA && alpPixBuf)
hyscale(c, alpPixBuf[lumBufIndex], dstW, src1, srcW,
lumXInc, hLumFilter, hLumFilterPos, hLumFilterSize,
formatConvBuffer, pal, 1);
lastInLumBuf++;
DEBUG_BUFFERS("\t\tlumBufIndex %d: lastInLumBuf: %d\n",
lumBufIndex, lastInLumBuf);
}
while (lastInChrBuf < lastChrSrcY) {
const uint8_t *src1[4] = {
src[0] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[0],
src[1] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[1],
src[2] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[2],
src[3] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[3],
};
chrBufIndex++;
assert(chrBufIndex < 2 * vChrBufSize);
assert(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH));
assert(lastInChrBuf + 1 - chrSrcSliceY >= 0);
if (c->needs_hcscale)
hcscale(c, chrUPixBuf[chrBufIndex], chrVPixBuf[chrBufIndex],
chrDstW, src1, chrSrcW, chrXInc,
hChrFilter, hChrFilterPos, hChrFilterSize,
formatConvBuffer, pal);
lastInChrBuf++;
DEBUG_BUFFERS("\t\tchrBufIndex %d: lastInChrBuf: %d\n",
chrBufIndex, lastInChrBuf);
}
if (lumBufIndex >= vLumBufSize)
lumBufIndex -= vLumBufSize;
if (chrBufIndex >= vChrBufSize)
chrBufIndex -= vChrBufSize;
if (!enough_lines)
break;
#if HAVE_MMX
updateMMXDitherTables(c, dstY, lumBufIndex, chrBufIndex,
lastInLumBuf, lastInChrBuf);
#endif
if (should_dither) {
c->chrDither8 = dither_8x8_128[chrDstY & 7];
c->lumDither8 = dither_8x8_128[dstY & 7];
}
if (dstY >= dstH - 2) {
ff_sws_init_output_funcs(c, &yuv2plane1, &yuv2planeX, &yuv2nv12cX,
&yuv2packed1, &yuv2packed2, &yuv2packedX);
}
{
const int16_t **lumSrcPtr = (const int16_t **)lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
const int16_t **chrUSrcPtr = (const int16_t **)chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
const int16_t **chrVSrcPtr = (const int16_t **)chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
const int16_t **alpSrcPtr = (CONFIG_SWSCALE_ALPHA && alpPixBuf) ?
(const int16_t **)alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
if (firstLumSrcY < 0 || firstLumSrcY + vLumFilterSize > c->srcH) {
const int16_t **tmpY = (const int16_t **)lumPixBuf +
2 * vLumBufSize;
int neg = -firstLumSrcY, i;
int end = FFMIN(c->srcH - firstLumSrcY, vLumFilterSize);
for (i = 0; i < neg; i++)
tmpY[i] = lumSrcPtr[neg];
for (; i < end; i++)
tmpY[i] = lumSrcPtr[i];
for (; i < vLumFilterSize; i++)
tmpY[i] = tmpY[i - 1];
lumSrcPtr = tmpY;
if (alpSrcPtr) {
const int16_t **tmpA = (const int16_t **)alpPixBuf +
2 * vLumBufSize;
for (i = 0; i < neg; i++)
tmpA[i] = alpSrcPtr[neg];
for (; i < end; i++)
tmpA[i] = alpSrcPtr[i];
for (; i < vLumFilterSize; i++)
tmpA[i] = tmpA[i - 1];
alpSrcPtr = tmpA;
}
}
if (firstChrSrcY < 0 ||
firstChrSrcY + vChrFilterSize > c->chrSrcH) {
const int16_t **tmpU = (const int16_t **)chrUPixBuf + 2 * vChrBufSize,
**tmpV = (const int16_t **)chrVPixBuf + 2 * vChrBufSize;
int neg = -firstChrSrcY, i;
int end = FFMIN(c->chrSrcH - firstChrSrcY, vChrFilterSize);
for (i = 0; i < neg; i++) {
tmpU[i] = chrUSrcPtr[neg];
tmpV[i] = chrVSrcPtr[neg];
}
for (; i < end; i++) {
tmpU[i] = chrUSrcPtr[i];
tmpV[i] = chrVSrcPtr[i];
}
for (; i < vChrFilterSize; i++) {
tmpU[i] = tmpU[i - 1];
tmpV[i] = tmpV[i - 1];
}
chrUSrcPtr = tmpU;
chrVSrcPtr = tmpV;
}
if (isPlanarYUV(dstFormat) ||
(isGray(dstFormat) && !isALPHA(dstFormat))) {
const int chrSkipMask = (1 << c->chrDstVSubSample) - 1;
if (vLumFilterSize == 1) {
yuv2plane1(lumSrcPtr[0], dest[0], dstW, c->lumDither8, 0);
} else {
yuv2planeX(vLumFilter + dstY * vLumFilterSize,
vLumFilterSize, lumSrcPtr, dest[0],
dstW, c->lumDither8, 0);
}
if (!((dstY & chrSkipMask) || isGray(dstFormat))) {
if (yuv2nv12cX) {
yuv2nv12cX(c, vChrFilter + chrDstY * vChrFilterSize,
vChrFilterSize, chrUSrcPtr, chrVSrcPtr,
dest[1], chrDstW);
} else if (vChrFilterSize == 1) {
yuv2plane1(chrUSrcPtr[0], dest[1], chrDstW, c->chrDither8, 0);
yuv2plane1(chrVSrcPtr[0], dest[2], chrDstW, c->chrDither8, 3);
} else {
yuv2planeX(vChrFilter + chrDstY * vChrFilterSize,
vChrFilterSize, chrUSrcPtr, dest[1],
chrDstW, c->chrDither8, 0);
yuv2planeX(vChrFilter + chrDstY * vChrFilterSize,
vChrFilterSize, chrVSrcPtr, dest[2],
chrDstW, c->chrDither8, 3);
}
}
if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
if (vLumFilterSize == 1) {
yuv2plane1(alpSrcPtr[0], dest[3], dstW,
c->lumDither8, 0);
} else {
yuv2planeX(vLumFilter + dstY * vLumFilterSize,
vLumFilterSize, alpSrcPtr, dest[3],
dstW, c->lumDither8, 0);
}
}
} else {
assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize * 2);
assert(chrUSrcPtr + vChrFilterSize - 1 < chrUPixBuf + vChrBufSize * 2);
if (c->yuv2packed1 && vLumFilterSize == 1 &&
vChrFilterSize <= 2) {
int chrAlpha = vChrFilterSize == 1 ? 0 : vChrFilter[2 * dstY + 1];
yuv2packed1(c, *lumSrcPtr, chrUSrcPtr, chrVSrcPtr,
alpPixBuf ? *alpSrcPtr : NULL,
dest[0], dstW, chrAlpha, dstY);
} else if (c->yuv2packed2 && vLumFilterSize == 2 &&
vChrFilterSize == 2) {
int lumAlpha = vLumFilter[2 * dstY + 1];
int chrAlpha = vChrFilter[2 * dstY + 1];
lumMmxFilter[2] =
lumMmxFilter[3] = vLumFilter[2 * dstY] * 0x10001;
chrMmxFilter[2] =
chrMmxFilter[3] = vChrFilter[2 * chrDstY] * 0x10001;
yuv2packed2(c, lumSrcPtr, chrUSrcPtr, chrVSrcPtr,
alpPixBuf ? alpSrcPtr : NULL,
dest[0], dstW, lumAlpha, chrAlpha, dstY);
} else {
yuv2packedX(c, vLumFilter + dstY * vLumFilterSize,
lumSrcPtr, vLumFilterSize,
vChrFilter + dstY * vChrFilterSize,
chrUSrcPtr, chrVSrcPtr, vChrFilterSize,
alpSrcPtr, dest[0], dstW, dstY);
}
}
}
}
if (isPlanar(dstFormat) && isALPHA(dstFormat) && !alpPixBuf)
fillPlane(dst[3], dstStride[3], dstW, dstY - lastDstY, lastDstY, 255);
#if HAVE_MMX2
if (av_get_cpu_flags() & AV_CPU_FLAG_MMX2)
__asm__ volatile ("sfence" ::: "memory");
#endif
emms_c();
c->dstY = dstY;
c->lumBufIndex = lumBufIndex;
c->chrBufIndex = chrBufIndex;
c->lastInLumBuf = lastInLumBuf;
c->lastInChrBuf = lastInChrBuf;
return dstY - lastDstY;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(SwsContext *VAR_0, const uint8_t *VAR_1[],
int VAR_2[], int VAR_3,
int VAR_4, uint8_t *VAR_5[], int VAR_6[])
{
const int VAR_7 = VAR_0->VAR_7;
const int VAR_8 = VAR_0->VAR_8;
const int VAR_9 = VAR_0->VAR_9;
const int VAR_10 = VAR_0->VAR_10;
const int VAR_11 = VAR_0->VAR_11;
const int VAR_12 = VAR_0->VAR_12;
const int VAR_13 = VAR_0->VAR_13;
const enum PixelFormat VAR_14 = VAR_0->VAR_14;
const int VAR_15 = VAR_0->VAR_15;
int32_t *vLumFilterPos = VAR_0->vLumFilterPos;
int32_t *vChrFilterPos = VAR_0->vChrFilterPos;
int32_t *hLumFilterPos = VAR_0->hLumFilterPos;
int32_t *hChrFilterPos = VAR_0->hChrFilterPos;
int16_t *vLumFilter = VAR_0->vLumFilter;
int16_t *vChrFilter = VAR_0->vChrFilter;
int16_t *hLumFilter = VAR_0->hLumFilter;
int16_t *hChrFilter = VAR_0->hChrFilter;
int32_t *lumMmxFilter = VAR_0->lumMmxFilter;
int32_t *chrMmxFilter = VAR_0->chrMmxFilter;
const int VAR_16 = VAR_0->VAR_16;
const int VAR_17 = VAR_0->VAR_17;
const int VAR_18 = VAR_0->VAR_18;
const int VAR_19 = VAR_0->VAR_19;
int16_t **lumPixBuf = VAR_0->lumPixBuf;
int16_t **chrUPixBuf = VAR_0->chrUPixBuf;
int16_t **chrVPixBuf = VAR_0->chrVPixBuf;
int16_t **alpPixBuf = VAR_0->alpPixBuf;
const int VAR_20 = VAR_0->VAR_20;
const int VAR_21 = VAR_0->VAR_21;
uint8_t *formatConvBuffer = VAR_0->formatConvBuffer;
uint32_t *pal = VAR_0->pal_yuv;
yuv2planar1_fn yuv2plane1 = VAR_0->yuv2plane1;
yuv2planarX_fn yuv2planeX = VAR_0->yuv2planeX;
yuv2interleavedX_fn yuv2nv12cX = VAR_0->yuv2nv12cX;
yuv2packed1_fn yuv2packed1 = VAR_0->yuv2packed1;
yuv2packed2_fn yuv2packed2 = VAR_0->yuv2packed2;
yuv2packedX_fn yuv2packedX = VAR_0->yuv2packedX;
const int VAR_22 = VAR_3 >> VAR_0->chrSrcVSubSample;
const int VAR_23 = -((-VAR_4) >> VAR_0->chrSrcVSubSample);
int VAR_24 = is9_OR_10BPS(VAR_0->srcFormat) ||
is16BPS(VAR_0->srcFormat);
int VAR_25;
int VAR_26 = VAR_0->VAR_26;
int VAR_27 = VAR_0->VAR_27;
int VAR_28 = VAR_0->VAR_28;
int VAR_29 = VAR_0->VAR_29;
int VAR_30 = VAR_0->VAR_30;
if (isPacked(VAR_0->srcFormat)) {
VAR_1[0] =
VAR_1[1] =
VAR_1[2] =
VAR_1[3] = VAR_1[0];
VAR_2[0] =
VAR_2[1] =
VAR_2[2] =
VAR_2[3] = VAR_2[0];
}
VAR_2[1] <<= VAR_0->vChrDrop;
VAR_2[2] <<= VAR_0->vChrDrop;
DEBUG_BUFFERS("FUNC_0() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\n",
VAR_1[0], VAR_2[0], VAR_1[1], VAR_2[1],
VAR_1[2], VAR_2[2], VAR_1[3], VAR_2[3],
VAR_5[0], VAR_6[0], VAR_5[1], VAR_6[1],
VAR_5[2], VAR_6[2], VAR_5[3], VAR_6[3]);
DEBUG_BUFFERS("VAR_3: %d VAR_4: %d VAR_26: %d VAR_9: %d\n",
VAR_3, VAR_4, VAR_26, VAR_9);
DEBUG_BUFFERS("VAR_16: %d VAR_20: %d VAR_17: %d VAR_21: %d\n",
VAR_16, VAR_20, VAR_17, VAR_21);
if (VAR_6[0] % 8 != 0 || VAR_6[1] % 8 != 0 ||
VAR_6[2] % 8 != 0 || VAR_6[3] % 8 != 0) {
static int VAR_31 = 0;
if (VAR_15 & SWS_PRINT_INFO && !VAR_31) {
av_log(VAR_0, AV_LOG_WARNING,
"Warning: VAR_6 is not aligned!\n"
" ->cannot do aligned memory accesses anymore\n");
VAR_31 = 1;
}
}
if (VAR_3 == 0) {
VAR_27 = -1;
VAR_28 = -1;
VAR_26 = 0;
VAR_29 = -1;
VAR_30 = -1;
}
if (!VAR_24) {
VAR_0->chrDither8 = VAR_0->lumDither8 = ff_sws_pb_64;
}
VAR_25 = VAR_26;
for (; VAR_26 < VAR_9; VAR_26++) {
const int VAR_32 = VAR_26 >> VAR_0->chrDstVSubSample;
uint8_t *dest[4] = {
VAR_5[0] + VAR_6[0] * VAR_26,
VAR_5[1] + VAR_6[1] * VAR_32,
VAR_5[2] + VAR_6[2] * VAR_32,
(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? VAR_5[3] + VAR_6[3] * VAR_26 : NULL,
};
const int VAR_33 = FFMAX(1 - VAR_16, vLumFilterPos[VAR_26]);
const int VAR_34 = FFMAX(1 - VAR_16, vLumFilterPos[FFMIN(VAR_26 | ((1 << VAR_0->chrDstVSubSample) - 1), VAR_9 - 1)]);
const int VAR_35 = FFMAX(1 - VAR_17, vChrFilterPos[VAR_32]);
int VAR_36 = FFMIN(VAR_0->srcH, VAR_33 + VAR_16) - 1;
int VAR_37 = FFMIN(VAR_0->srcH, VAR_34 + VAR_16) - 1;
int VAR_38 = FFMIN(VAR_0->chrSrcH, VAR_35 + VAR_17) - 1;
int VAR_39;
if (VAR_33 > VAR_29)
VAR_29 = VAR_33 - 1;
if (VAR_35 > VAR_30)
VAR_30 = VAR_35 - 1;
assert(VAR_33 >= VAR_29 - VAR_20 + 1);
assert(VAR_35 >= VAR_30 - VAR_21 + 1);
DEBUG_BUFFERS("VAR_26: %d\n", VAR_26);
DEBUG_BUFFERS("\tfirstLumSrcY: %d VAR_36: %d VAR_29: %d\n",
VAR_33, VAR_36, VAR_29);
DEBUG_BUFFERS("\tfirstChrSrcY: %d VAR_38: %d VAR_30: %d\n",
VAR_35, VAR_38, VAR_30);
VAR_39 = VAR_37 < VAR_3 + VAR_4 &&
VAR_38 < -((-VAR_3 - VAR_4) >> VAR_0->chrSrcVSubSample);
if (!VAR_39) {
VAR_36 = VAR_3 + VAR_4 - 1;
VAR_38 = VAR_22 + VAR_23 - 1;
DEBUG_BUFFERS("buffering slice: VAR_36 %d VAR_38 %d\n",
VAR_36, VAR_38);
}
while (VAR_29 < VAR_36) {
const uint8_t *VAR_41[4] = {
VAR_1[0] + (VAR_29 + 1 - VAR_3) * VAR_2[0],
VAR_1[1] + (VAR_29 + 1 - VAR_3) * VAR_2[1],
VAR_1[2] + (VAR_29 + 1 - VAR_3) * VAR_2[2],
VAR_1[3] + (VAR_29 + 1 - VAR_3) * VAR_2[3],
};
VAR_27++;
assert(VAR_27 < 2 * VAR_20);
assert(VAR_29 + 1 - VAR_3 < VAR_4);
assert(VAR_29 + 1 - VAR_3 >= 0);
hyscale(VAR_0, lumPixBuf[VAR_27], VAR_8, VAR_41, VAR_7, VAR_12,
hLumFilter, hLumFilterPos, VAR_18,
formatConvBuffer, pal, 0);
if (CONFIG_SWSCALE_ALPHA && alpPixBuf)
hyscale(VAR_0, alpPixBuf[VAR_27], VAR_8, VAR_41, VAR_7,
VAR_12, hLumFilter, hLumFilterPos, VAR_18,
formatConvBuffer, pal, 1);
VAR_29++;
DEBUG_BUFFERS("\t\tlumBufIndex %d: VAR_29: %d\n",
VAR_27, VAR_29);
}
while (VAR_30 < VAR_38) {
const uint8_t *VAR_41[4] = {
VAR_1[0] + (VAR_30 + 1 - VAR_22) * VAR_2[0],
VAR_1[1] + (VAR_30 + 1 - VAR_22) * VAR_2[1],
VAR_1[2] + (VAR_30 + 1 - VAR_22) * VAR_2[2],
VAR_1[3] + (VAR_30 + 1 - VAR_22) * VAR_2[3],
};
VAR_28++;
assert(VAR_28 < 2 * VAR_21);
assert(VAR_30 + 1 - VAR_22 < (VAR_23));
assert(VAR_30 + 1 - VAR_22 >= 0);
if (VAR_0->needs_hcscale)
hcscale(VAR_0, chrUPixBuf[VAR_28], chrVPixBuf[VAR_28],
VAR_10, VAR_41, VAR_11, VAR_13,
hChrFilter, hChrFilterPos, VAR_19,
formatConvBuffer, pal);
VAR_30++;
DEBUG_BUFFERS("\t\tchrBufIndex %d: VAR_30: %d\n",
VAR_28, VAR_30);
}
if (VAR_27 >= VAR_20)
VAR_27 -= VAR_20;
if (VAR_28 >= VAR_21)
VAR_28 -= VAR_21;
if (!VAR_39)
break;
#if HAVE_MMX
updateMMXDitherTables(VAR_0, VAR_26, VAR_27, VAR_28,
VAR_29, VAR_30);
#endif
if (VAR_24) {
VAR_0->chrDither8 = dither_8x8_128[VAR_32 & 7];
VAR_0->lumDither8 = dither_8x8_128[VAR_26 & 7];
}
if (VAR_26 >= VAR_9 - 2) {
ff_sws_init_output_funcs(VAR_0, &yuv2plane1, &yuv2planeX, &yuv2nv12cX,
&yuv2packed1, &yuv2packed2, &yuv2packedX);
}
{
const int16_t **VAR_41 = (const int16_t **)lumPixBuf + VAR_27 + VAR_33 - VAR_29 + VAR_20;
const int16_t **VAR_42 = (const int16_t **)chrUPixBuf + VAR_28 + VAR_35 - VAR_30 + VAR_21;
const int16_t **VAR_43 = (const int16_t **)chrVPixBuf + VAR_28 + VAR_35 - VAR_30 + VAR_21;
const int16_t **VAR_44 = (CONFIG_SWSCALE_ALPHA && alpPixBuf) ?
(const int16_t **)alpPixBuf + VAR_27 + VAR_33 - VAR_29 + VAR_20 : NULL;
if (VAR_33 < 0 || VAR_33 + VAR_16 > VAR_0->srcH) {
const int16_t **VAR_45 = (const int16_t **)lumPixBuf +
2 * VAR_20;
int VAR_51 = -VAR_33, VAR_51;
int VAR_51 = FFMIN(VAR_0->srcH - VAR_33, VAR_16);
for (VAR_51 = 0; VAR_51 < VAR_51; VAR_51++)
VAR_45[VAR_51] = VAR_41[VAR_51];
for (; VAR_51 < VAR_51; VAR_51++)
VAR_45[VAR_51] = VAR_41[VAR_51];
for (; VAR_51 < VAR_16; VAR_51++)
VAR_45[VAR_51] = VAR_45[VAR_51 - 1];
VAR_41 = VAR_45;
if (VAR_44) {
const int16_t **VAR_49 = (const int16_t **)alpPixBuf +
2 * VAR_20;
for (VAR_51 = 0; VAR_51 < VAR_51; VAR_51++)
VAR_49[VAR_51] = VAR_44[VAR_51];
for (; VAR_51 < VAR_51; VAR_51++)
VAR_49[VAR_51] = VAR_44[VAR_51];
for (; VAR_51 < VAR_16; VAR_51++)
VAR_49[VAR_51] = VAR_49[VAR_51 - 1];
VAR_44 = VAR_49;
}
}
if (VAR_35 < 0 ||
VAR_35 + VAR_17 > VAR_0->chrSrcH) {
const int16_t **VAR_50 = (const int16_t **)chrUPixBuf + 2 * VAR_21,
**tmpV = (const int16_t **)chrVPixBuf + 2 * VAR_21;
int VAR_51 = -VAR_35, VAR_51;
int VAR_51 = FFMIN(VAR_0->chrSrcH - VAR_35, VAR_17);
for (VAR_51 = 0; VAR_51 < VAR_51; VAR_51++) {
VAR_50[VAR_51] = VAR_42[VAR_51];
tmpV[VAR_51] = VAR_43[VAR_51];
}
for (; VAR_51 < VAR_51; VAR_51++) {
VAR_50[VAR_51] = VAR_42[VAR_51];
tmpV[VAR_51] = VAR_43[VAR_51];
}
for (; VAR_51 < VAR_17; VAR_51++) {
VAR_50[VAR_51] = VAR_50[VAR_51 - 1];
tmpV[VAR_51] = tmpV[VAR_51 - 1];
}
VAR_42 = VAR_50;
VAR_43 = tmpV;
}
if (isPlanarYUV(VAR_14) ||
(isGray(VAR_14) && !isALPHA(VAR_14))) {
const int VAR_51 = (1 << VAR_0->chrDstVSubSample) - 1;
if (VAR_16 == 1) {
yuv2plane1(VAR_41[0], dest[0], VAR_8, VAR_0->lumDither8, 0);
} else {
yuv2planeX(vLumFilter + VAR_26 * VAR_16,
VAR_16, VAR_41, dest[0],
VAR_8, VAR_0->lumDither8, 0);
}
if (!((VAR_26 & VAR_51) || isGray(VAR_14))) {
if (yuv2nv12cX) {
yuv2nv12cX(VAR_0, vChrFilter + VAR_32 * VAR_17,
VAR_17, VAR_42, VAR_43,
dest[1], VAR_10);
} else if (VAR_17 == 1) {
yuv2plane1(VAR_42[0], dest[1], VAR_10, VAR_0->chrDither8, 0);
yuv2plane1(VAR_43[0], dest[2], VAR_10, VAR_0->chrDither8, 3);
} else {
yuv2planeX(vChrFilter + VAR_32 * VAR_17,
VAR_17, VAR_42, dest[1],
VAR_10, VAR_0->chrDither8, 0);
yuv2planeX(vChrFilter + VAR_32 * VAR_17,
VAR_17, VAR_43, dest[2],
VAR_10, VAR_0->chrDither8, 3);
}
}
if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
if (VAR_16 == 1) {
yuv2plane1(VAR_44[0], dest[3], VAR_8,
VAR_0->lumDither8, 0);
} else {
yuv2planeX(vLumFilter + VAR_26 * VAR_16,
VAR_16, VAR_44, dest[3],
VAR_8, VAR_0->lumDither8, 0);
}
}
} else {
assert(VAR_41 + VAR_16 - 1 < lumPixBuf + VAR_20 * 2);
assert(VAR_42 + VAR_17 - 1 < chrUPixBuf + VAR_21 * 2);
if (VAR_0->yuv2packed1 && VAR_16 == 1 &&
VAR_17 <= 2) {
int VAR_54 = VAR_17 == 1 ? 0 : vChrFilter[2 * VAR_26 + 1];
yuv2packed1(VAR_0, *VAR_41, VAR_42, VAR_43,
alpPixBuf ? *VAR_44 : NULL,
dest[0], VAR_8, VAR_54, VAR_26);
} else if (VAR_0->yuv2packed2 && VAR_16 == 2 &&
VAR_17 == 2) {
int VAR_53 = vLumFilter[2 * VAR_26 + 1];
int VAR_54 = vChrFilter[2 * VAR_26 + 1];
lumMmxFilter[2] =
lumMmxFilter[3] = vLumFilter[2 * VAR_26] * 0x10001;
chrMmxFilter[2] =
chrMmxFilter[3] = vChrFilter[2 * VAR_32] * 0x10001;
yuv2packed2(VAR_0, VAR_41, VAR_42, VAR_43,
alpPixBuf ? VAR_44 : NULL,
dest[0], VAR_8, VAR_53, VAR_54, VAR_26);
} else {
yuv2packedX(VAR_0, vLumFilter + VAR_26 * VAR_16,
VAR_41, VAR_16,
vChrFilter + VAR_26 * VAR_17,
VAR_42, VAR_43, VAR_17,
VAR_44, dest[0], VAR_8, VAR_26);
}
}
}
}
if (isPlanar(VAR_14) && isALPHA(VAR_14) && !alpPixBuf)
fillPlane(VAR_5[3], VAR_6[3], VAR_8, VAR_26 - VAR_25, VAR_25, 255);
#if HAVE_MMX2
if (av_get_cpu_flags() & AV_CPU_FLAG_MMX2)
__asm__ volatile ("sfence" ::: "memory");
#endif
emms_c();
VAR_0->VAR_26 = VAR_26;
VAR_0->VAR_27 = VAR_27;
VAR_0->VAR_28 = VAR_28;
VAR_0->VAR_29 = VAR_29;
VAR_0->VAR_30 = VAR_30;
return VAR_26 - VAR_25;
}
| [
"static int FUNC_0(SwsContext *VAR_0, const uint8_t *VAR_1[],\nint VAR_2[], int VAR_3,\nint VAR_4, uint8_t *VAR_5[], int VAR_6[])\n{",
"const int VAR_7 = VAR_0->VAR_7;",
"const int VAR_8 = VAR_0->VAR_8;",
"const int VAR_9 = VAR_0->VAR_9;",
"const int VAR_10 = VAR_0->VAR_10;",
"const int VAR_11 = VAR_0->VAR_11;",
"const int VAR_12 = VAR_0->VAR_12;",
"const int VAR_13 = VAR_0->VAR_13;",
"const enum PixelFormat VAR_14 = VAR_0->VAR_14;",
"const int VAR_15 = VAR_0->VAR_15;",
"int32_t *vLumFilterPos = VAR_0->vLumFilterPos;",
"int32_t *vChrFilterPos = VAR_0->vChrFilterPos;",
"int32_t *hLumFilterPos = VAR_0->hLumFilterPos;",
"int32_t *hChrFilterPos = VAR_0->hChrFilterPos;",
"int16_t *vLumFilter = VAR_0->vLumFilter;",
"int16_t *vChrFilter = VAR_0->vChrFilter;",
"int16_t *hLumFilter = VAR_0->hLumFilter;",
"int16_t *hChrFilter = VAR_0->hChrFilter;",
"int32_t *lumMmxFilter = VAR_0->lumMmxFilter;",
"int32_t *chrMmxFilter = VAR_0->chrMmxFilter;",
"const int VAR_16 = VAR_0->VAR_16;",
"const int VAR_17 = VAR_0->VAR_17;",
"const int VAR_18 = VAR_0->VAR_18;",
"const int VAR_19 = VAR_0->VAR_19;",
"int16_t **lumPixBuf = VAR_0->lumPixBuf;",
"int16_t **chrUPixBuf = VAR_0->chrUPixBuf;",
"int16_t **chrVPixBuf = VAR_0->chrVPixBuf;",
"int16_t **alpPixBuf = VAR_0->alpPixBuf;",
"const int VAR_20 = VAR_0->VAR_20;",
"const int VAR_21 = VAR_0->VAR_21;",
"uint8_t *formatConvBuffer = VAR_0->formatConvBuffer;",
"uint32_t *pal = VAR_0->pal_yuv;",
"yuv2planar1_fn yuv2plane1 = VAR_0->yuv2plane1;",
"yuv2planarX_fn yuv2planeX = VAR_0->yuv2planeX;",
"yuv2interleavedX_fn yuv2nv12cX = VAR_0->yuv2nv12cX;",
"yuv2packed1_fn yuv2packed1 = VAR_0->yuv2packed1;",
"yuv2packed2_fn yuv2packed2 = VAR_0->yuv2packed2;",
"yuv2packedX_fn yuv2packedX = VAR_0->yuv2packedX;",
"const int VAR_22 = VAR_3 >> VAR_0->chrSrcVSubSample;",
"const int VAR_23 = -((-VAR_4) >> VAR_0->chrSrcVSubSample);",
"int VAR_24 = is9_OR_10BPS(VAR_0->srcFormat) ||\nis16BPS(VAR_0->srcFormat);",
"int VAR_25;",
"int VAR_26 = VAR_0->VAR_26;",
"int VAR_27 = VAR_0->VAR_27;",
"int VAR_28 = VAR_0->VAR_28;",
"int VAR_29 = VAR_0->VAR_29;",
"int VAR_30 = VAR_0->VAR_30;",
"if (isPacked(VAR_0->srcFormat)) {",
"VAR_1[0] =\nVAR_1[1] =\nVAR_1[2] =\nVAR_1[3] = VAR_1[0];",
"VAR_2[0] =\nVAR_2[1] =\nVAR_2[2] =\nVAR_2[3] = VAR_2[0];",
"}",
"VAR_2[1] <<= VAR_0->vChrDrop;",
"VAR_2[2] <<= VAR_0->vChrDrop;",
"DEBUG_BUFFERS(\"FUNC_0() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\\n\",\nVAR_1[0], VAR_2[0], VAR_1[1], VAR_2[1],\nVAR_1[2], VAR_2[2], VAR_1[3], VAR_2[3],\nVAR_5[0], VAR_6[0], VAR_5[1], VAR_6[1],\nVAR_5[2], VAR_6[2], VAR_5[3], VAR_6[3]);",
"DEBUG_BUFFERS(\"VAR_3: %d VAR_4: %d VAR_26: %d VAR_9: %d\\n\",\nVAR_3, VAR_4, VAR_26, VAR_9);",
"DEBUG_BUFFERS(\"VAR_16: %d VAR_20: %d VAR_17: %d VAR_21: %d\\n\",\nVAR_16, VAR_20, VAR_17, VAR_21);",
"if (VAR_6[0] % 8 != 0 || VAR_6[1] % 8 != 0 ||\nVAR_6[2] % 8 != 0 || VAR_6[3] % 8 != 0) {",
"static int VAR_31 = 0;",
"if (VAR_15 & SWS_PRINT_INFO && !VAR_31) {",
"av_log(VAR_0, AV_LOG_WARNING,\n\"Warning: VAR_6 is not aligned!\\n\"\n\" ->cannot do aligned memory accesses anymore\\n\");",
"VAR_31 = 1;",
"}",
"}",
"if (VAR_3 == 0) {",
"VAR_27 = -1;",
"VAR_28 = -1;",
"VAR_26 = 0;",
"VAR_29 = -1;",
"VAR_30 = -1;",
"}",
"if (!VAR_24) {",
"VAR_0->chrDither8 = VAR_0->lumDither8 = ff_sws_pb_64;",
"}",
"VAR_25 = VAR_26;",
"for (; VAR_26 < VAR_9; VAR_26++) {",
"const int VAR_32 = VAR_26 >> VAR_0->chrDstVSubSample;",
"uint8_t *dest[4] = {",
"VAR_5[0] + VAR_6[0] * VAR_26,\nVAR_5[1] + VAR_6[1] * VAR_32,\nVAR_5[2] + VAR_6[2] * VAR_32,\n(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? VAR_5[3] + VAR_6[3] * VAR_26 : NULL,\n};",
"const int VAR_33 = FFMAX(1 - VAR_16, vLumFilterPos[VAR_26]);",
"const int VAR_34 = FFMAX(1 - VAR_16, vLumFilterPos[FFMIN(VAR_26 | ((1 << VAR_0->chrDstVSubSample) - 1), VAR_9 - 1)]);",
"const int VAR_35 = FFMAX(1 - VAR_17, vChrFilterPos[VAR_32]);",
"int VAR_36 = FFMIN(VAR_0->srcH, VAR_33 + VAR_16) - 1;",
"int VAR_37 = FFMIN(VAR_0->srcH, VAR_34 + VAR_16) - 1;",
"int VAR_38 = FFMIN(VAR_0->chrSrcH, VAR_35 + VAR_17) - 1;",
"int VAR_39;",
"if (VAR_33 > VAR_29)\nVAR_29 = VAR_33 - 1;",
"if (VAR_35 > VAR_30)\nVAR_30 = VAR_35 - 1;",
"assert(VAR_33 >= VAR_29 - VAR_20 + 1);",
"assert(VAR_35 >= VAR_30 - VAR_21 + 1);",
"DEBUG_BUFFERS(\"VAR_26: %d\\n\", VAR_26);",
"DEBUG_BUFFERS(\"\\tfirstLumSrcY: %d VAR_36: %d VAR_29: %d\\n\",\nVAR_33, VAR_36, VAR_29);",
"DEBUG_BUFFERS(\"\\tfirstChrSrcY: %d VAR_38: %d VAR_30: %d\\n\",\nVAR_35, VAR_38, VAR_30);",
"VAR_39 = VAR_37 < VAR_3 + VAR_4 &&\nVAR_38 < -((-VAR_3 - VAR_4) >> VAR_0->chrSrcVSubSample);",
"if (!VAR_39) {",
"VAR_36 = VAR_3 + VAR_4 - 1;",
"VAR_38 = VAR_22 + VAR_23 - 1;",
"DEBUG_BUFFERS(\"buffering slice: VAR_36 %d VAR_38 %d\\n\",\nVAR_36, VAR_38);",
"}",
"while (VAR_29 < VAR_36) {",
"const uint8_t *VAR_41[4] = {",
"VAR_1[0] + (VAR_29 + 1 - VAR_3) * VAR_2[0],\nVAR_1[1] + (VAR_29 + 1 - VAR_3) * VAR_2[1],\nVAR_1[2] + (VAR_29 + 1 - VAR_3) * VAR_2[2],\nVAR_1[3] + (VAR_29 + 1 - VAR_3) * VAR_2[3],\n};",
"VAR_27++;",
"assert(VAR_27 < 2 * VAR_20);",
"assert(VAR_29 + 1 - VAR_3 < VAR_4);",
"assert(VAR_29 + 1 - VAR_3 >= 0);",
"hyscale(VAR_0, lumPixBuf[VAR_27], VAR_8, VAR_41, VAR_7, VAR_12,\nhLumFilter, hLumFilterPos, VAR_18,\nformatConvBuffer, pal, 0);",
"if (CONFIG_SWSCALE_ALPHA && alpPixBuf)\nhyscale(VAR_0, alpPixBuf[VAR_27], VAR_8, VAR_41, VAR_7,\nVAR_12, hLumFilter, hLumFilterPos, VAR_18,\nformatConvBuffer, pal, 1);",
"VAR_29++;",
"DEBUG_BUFFERS(\"\\t\\tlumBufIndex %d: VAR_29: %d\\n\",\nVAR_27, VAR_29);",
"}",
"while (VAR_30 < VAR_38) {",
"const uint8_t *VAR_41[4] = {",
"VAR_1[0] + (VAR_30 + 1 - VAR_22) * VAR_2[0],\nVAR_1[1] + (VAR_30 + 1 - VAR_22) * VAR_2[1],\nVAR_1[2] + (VAR_30 + 1 - VAR_22) * VAR_2[2],\nVAR_1[3] + (VAR_30 + 1 - VAR_22) * VAR_2[3],\n};",
"VAR_28++;",
"assert(VAR_28 < 2 * VAR_21);",
"assert(VAR_30 + 1 - VAR_22 < (VAR_23));",
"assert(VAR_30 + 1 - VAR_22 >= 0);",
"if (VAR_0->needs_hcscale)\nhcscale(VAR_0, chrUPixBuf[VAR_28], chrVPixBuf[VAR_28],\nVAR_10, VAR_41, VAR_11, VAR_13,\nhChrFilter, hChrFilterPos, VAR_19,\nformatConvBuffer, pal);",
"VAR_30++;",
"DEBUG_BUFFERS(\"\\t\\tchrBufIndex %d: VAR_30: %d\\n\",\nVAR_28, VAR_30);",
"}",
"if (VAR_27 >= VAR_20)\nVAR_27 -= VAR_20;",
"if (VAR_28 >= VAR_21)\nVAR_28 -= VAR_21;",
"if (!VAR_39)\nbreak;",
"#if HAVE_MMX\nupdateMMXDitherTables(VAR_0, VAR_26, VAR_27, VAR_28,\nVAR_29, VAR_30);",
"#endif\nif (VAR_24) {",
"VAR_0->chrDither8 = dither_8x8_128[VAR_32 & 7];",
"VAR_0->lumDither8 = dither_8x8_128[VAR_26 & 7];",
"}",
"if (VAR_26 >= VAR_9 - 2) {",
"ff_sws_init_output_funcs(VAR_0, &yuv2plane1, &yuv2planeX, &yuv2nv12cX,\n&yuv2packed1, &yuv2packed2, &yuv2packedX);",
"}",
"{",
"const int16_t **VAR_41 = (const int16_t **)lumPixBuf + VAR_27 + VAR_33 - VAR_29 + VAR_20;",
"const int16_t **VAR_42 = (const int16_t **)chrUPixBuf + VAR_28 + VAR_35 - VAR_30 + VAR_21;",
"const int16_t **VAR_43 = (const int16_t **)chrVPixBuf + VAR_28 + VAR_35 - VAR_30 + VAR_21;",
"const int16_t **VAR_44 = (CONFIG_SWSCALE_ALPHA && alpPixBuf) ?\n(const int16_t **)alpPixBuf + VAR_27 + VAR_33 - VAR_29 + VAR_20 : NULL;",
"if (VAR_33 < 0 || VAR_33 + VAR_16 > VAR_0->srcH) {",
"const int16_t **VAR_45 = (const int16_t **)lumPixBuf +\n2 * VAR_20;",
"int VAR_51 = -VAR_33, VAR_51;",
"int VAR_51 = FFMIN(VAR_0->srcH - VAR_33, VAR_16);",
"for (VAR_51 = 0; VAR_51 < VAR_51; VAR_51++)",
"VAR_45[VAR_51] = VAR_41[VAR_51];",
"for (; VAR_51 < VAR_51; VAR_51++)",
"VAR_45[VAR_51] = VAR_41[VAR_51];",
"for (; VAR_51 < VAR_16; VAR_51++)",
"VAR_45[VAR_51] = VAR_45[VAR_51 - 1];",
"VAR_41 = VAR_45;",
"if (VAR_44) {",
"const int16_t **VAR_49 = (const int16_t **)alpPixBuf +\n2 * VAR_20;",
"for (VAR_51 = 0; VAR_51 < VAR_51; VAR_51++)",
"VAR_49[VAR_51] = VAR_44[VAR_51];",
"for (; VAR_51 < VAR_51; VAR_51++)",
"VAR_49[VAR_51] = VAR_44[VAR_51];",
"for (; VAR_51 < VAR_16; VAR_51++)",
"VAR_49[VAR_51] = VAR_49[VAR_51 - 1];",
"VAR_44 = VAR_49;",
"}",
"}",
"if (VAR_35 < 0 ||\nVAR_35 + VAR_17 > VAR_0->chrSrcH) {",
"const int16_t **VAR_50 = (const int16_t **)chrUPixBuf + 2 * VAR_21,\n**tmpV = (const int16_t **)chrVPixBuf + 2 * VAR_21;",
"int VAR_51 = -VAR_35, VAR_51;",
"int VAR_51 = FFMIN(VAR_0->chrSrcH - VAR_35, VAR_17);",
"for (VAR_51 = 0; VAR_51 < VAR_51; VAR_51++) {",
"VAR_50[VAR_51] = VAR_42[VAR_51];",
"tmpV[VAR_51] = VAR_43[VAR_51];",
"}",
"for (; VAR_51 < VAR_51; VAR_51++) {",
"VAR_50[VAR_51] = VAR_42[VAR_51];",
"tmpV[VAR_51] = VAR_43[VAR_51];",
"}",
"for (; VAR_51 < VAR_17; VAR_51++) {",
"VAR_50[VAR_51] = VAR_50[VAR_51 - 1];",
"tmpV[VAR_51] = tmpV[VAR_51 - 1];",
"}",
"VAR_42 = VAR_50;",
"VAR_43 = tmpV;",
"}",
"if (isPlanarYUV(VAR_14) ||\n(isGray(VAR_14) && !isALPHA(VAR_14))) {",
"const int VAR_51 = (1 << VAR_0->chrDstVSubSample) - 1;",
"if (VAR_16 == 1) {",
"yuv2plane1(VAR_41[0], dest[0], VAR_8, VAR_0->lumDither8, 0);",
"} else {",
"yuv2planeX(vLumFilter + VAR_26 * VAR_16,\nVAR_16, VAR_41, dest[0],\nVAR_8, VAR_0->lumDither8, 0);",
"}",
"if (!((VAR_26 & VAR_51) || isGray(VAR_14))) {",
"if (yuv2nv12cX) {",
"yuv2nv12cX(VAR_0, vChrFilter + VAR_32 * VAR_17,\nVAR_17, VAR_42, VAR_43,\ndest[1], VAR_10);",
"} else if (VAR_17 == 1) {",
"yuv2plane1(VAR_42[0], dest[1], VAR_10, VAR_0->chrDither8, 0);",
"yuv2plane1(VAR_43[0], dest[2], VAR_10, VAR_0->chrDither8, 3);",
"} else {",
"yuv2planeX(vChrFilter + VAR_32 * VAR_17,\nVAR_17, VAR_42, dest[1],\nVAR_10, VAR_0->chrDither8, 0);",
"yuv2planeX(vChrFilter + VAR_32 * VAR_17,\nVAR_17, VAR_43, dest[2],\nVAR_10, VAR_0->chrDither8, 3);",
"}",
"}",
"if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {",
"if (VAR_16 == 1) {",
"yuv2plane1(VAR_44[0], dest[3], VAR_8,\nVAR_0->lumDither8, 0);",
"} else {",
"yuv2planeX(vLumFilter + VAR_26 * VAR_16,\nVAR_16, VAR_44, dest[3],\nVAR_8, VAR_0->lumDither8, 0);",
"}",
"}",
"} else {",
"assert(VAR_41 + VAR_16 - 1 < lumPixBuf + VAR_20 * 2);",
"assert(VAR_42 + VAR_17 - 1 < chrUPixBuf + VAR_21 * 2);",
"if (VAR_0->yuv2packed1 && VAR_16 == 1 &&\nVAR_17 <= 2) {",
"int VAR_54 = VAR_17 == 1 ? 0 : vChrFilter[2 * VAR_26 + 1];",
"yuv2packed1(VAR_0, *VAR_41, VAR_42, VAR_43,\nalpPixBuf ? *VAR_44 : NULL,\ndest[0], VAR_8, VAR_54, VAR_26);",
"} else if (VAR_0->yuv2packed2 && VAR_16 == 2 &&",
"VAR_17 == 2) {",
"int VAR_53 = vLumFilter[2 * VAR_26 + 1];",
"int VAR_54 = vChrFilter[2 * VAR_26 + 1];",
"lumMmxFilter[2] =\nlumMmxFilter[3] = vLumFilter[2 * VAR_26] * 0x10001;",
"chrMmxFilter[2] =\nchrMmxFilter[3] = vChrFilter[2 * VAR_32] * 0x10001;",
"yuv2packed2(VAR_0, VAR_41, VAR_42, VAR_43,\nalpPixBuf ? VAR_44 : NULL,\ndest[0], VAR_8, VAR_53, VAR_54, VAR_26);",
"} else {",
"yuv2packedX(VAR_0, vLumFilter + VAR_26 * VAR_16,\nVAR_41, VAR_16,\nvChrFilter + VAR_26 * VAR_17,\nVAR_42, VAR_43, VAR_17,\nVAR_44, dest[0], VAR_8, VAR_26);",
"}",
"}",
"}",
"}",
"if (isPlanar(VAR_14) && isALPHA(VAR_14) && !alpPixBuf)\nfillPlane(VAR_5[3], VAR_6[3], VAR_8, VAR_26 - VAR_25, VAR_25, 255);",
"#if HAVE_MMX2\nif (av_get_cpu_flags() & AV_CPU_FLAG_MMX2)\n__asm__ volatile (\"sfence\" ::: \"memory\");",
"#endif\nemms_c();",
"VAR_0->VAR_26 = VAR_26;",
"VAR_0->VAR_27 = VAR_27;",
"VAR_0->VAR_28 = VAR_28;",
"VAR_0->VAR_29 = VAR_29;",
"VAR_0->VAR_30 = VAR_30;",
"return VAR_26 - VAR_25;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
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
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115,
117,
119,
121
],
[
123,
125,
127,
129
],
[
131
],
[
133
],
[
135
],
[
139,
141,
143,
145,
147
],
[
149,
151
],
[
153,
155
],
[
159,
161
],
[
163
],
[
165
],
[
167,
169,
171
],
[
173
],
[
175
],
[
177
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
203
],
[
205
],
[
207
],
[
209
],
[
213
],
[
215
],
[
217
],
[
219,
221,
223,
225,
227
],
[
233
],
[
235
],
[
239
],
[
245
],
[
247
],
[
249
],
[
251
],
[
257,
259
],
[
261,
263
],
[
265
],
[
267
],
[
271
],
[
273,
275
],
[
277,
279
],
[
285,
287
],
[
291
],
[
293
],
[
295
],
[
297,
299
],
[
301
],
[
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
],
[
377,
379,
381,
383,
385
],
[
387
],
[
389,
391
],
[
393
],
[
397,
399
],
[
401,
403
],
[
405,
407
],
[
411,
413,
415
],
[
417,
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
433,
435
],
[
437
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449,
451
],
[
455
],
[
457,
459
],
[
461
],
[
463
],
[
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
477
],
[
481
],
[
483,
485
],
[
487
],
[
489
],
[
491
],
[
493
],
[
495
],
[
497
],
[
499
],
[
501
],
[
503
],
[
505,
507
],
[
509,
511
],
[
513
],
[
515
],
[
517
],
[
519
],
[
521
],
[
523
],
[
525
],
[
527
],
[
529
],
[
531
],
[
533
],
[
535
],
[
537
],
[
539
],
[
541
],
[
543
],
[
545
],
[
549,
551
],
[
553
],
[
557
],
[
559
],
[
561
],
[
563,
565,
567
],
[
569
],
[
573
],
[
575
],
[
577,
579,
581
],
[
583
],
[
585
],
[
587
],
[
589
],
[
591,
593,
595
],
[
597,
599,
601
],
[
603
],
[
605
],
[
609
],
[
611
],
[
613,
615
],
[
617
],
[
619,
621,
623
],
[
625
],
[
627
],
[
629
],
[
631
],
[
633
],
[
635,
637
],
[
639
],
[
641,
643,
645
],
[
647
],
[
649
],
[
651
],
[
653
],
[
655,
657
],
[
659,
661
],
[
663,
665,
667
],
[
669
],
[
671,
673,
675,
677,
679
],
[
681
],
[
683
],
[
685
],
[
687
],
[
691,
693
],
[
697,
699,
701
],
[
703,
705
],
[
711
],
[
713
],
[
715
],
[
717
],
[
719
],
[
723
],
[
725
]
] |
24,973 | static inline int spx_strategy(AC3DecodeContext *s, int blk)
{
GetBitContext *bc = &s->gbc;
int fbw_channels = s->fbw_channels;
int dst_start_freq, dst_end_freq, src_start_freq,
start_subband, end_subband, ch;
/* determine which channels use spx */
if (s->channel_mode == AC3_CHMODE_MONO) {
s->channel_uses_spx[1] = 1;
} else {
for (ch = 1; ch <= fbw_channels; ch++)
s->channel_uses_spx[ch] = get_bits1(bc);
}
/* get the frequency bins of the spx copy region and the spx start
and end subbands */
dst_start_freq = get_bits(bc, 2);
start_subband = get_bits(bc, 3) + 2;
if (start_subband > 7)
start_subband += start_subband - 7;
end_subband = get_bits(bc, 3) + 5;
#if USE_FIXED
s->spx_dst_end_freq = end_freq_inv_tab[end_subband-5];
#endif
if (end_subband > 7)
end_subband += end_subband - 7;
dst_start_freq = dst_start_freq * 12 + 25;
src_start_freq = start_subband * 12 + 25;
dst_end_freq = end_subband * 12 + 25;
/* check validity of spx ranges */
if (start_subband >= end_subband) {
av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension "
"range (%d >= %d)\n", start_subband, end_subband);
return AVERROR_INVALIDDATA;
}
if (dst_start_freq >= src_start_freq) {
av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension "
"copy start bin (%d >= %d)\n", dst_start_freq, src_start_freq);
return AVERROR_INVALIDDATA;
}
s->spx_dst_start_freq = dst_start_freq;
s->spx_src_start_freq = src_start_freq;
if (!USE_FIXED)
s->spx_dst_end_freq = dst_end_freq;
decode_band_structure(bc, blk, s->eac3, 0,
start_subband, end_subband,
ff_eac3_default_spx_band_struct,
&s->num_spx_bands,
s->spx_band_sizes);
return 0;
}
| true | FFmpeg | 9351a156de724edb69ba6e1f05884fe806a13a21 | static inline int spx_strategy(AC3DecodeContext *s, int blk)
{
GetBitContext *bc = &s->gbc;
int fbw_channels = s->fbw_channels;
int dst_start_freq, dst_end_freq, src_start_freq,
start_subband, end_subband, ch;
if (s->channel_mode == AC3_CHMODE_MONO) {
s->channel_uses_spx[1] = 1;
} else {
for (ch = 1; ch <= fbw_channels; ch++)
s->channel_uses_spx[ch] = get_bits1(bc);
}
dst_start_freq = get_bits(bc, 2);
start_subband = get_bits(bc, 3) + 2;
if (start_subband > 7)
start_subband += start_subband - 7;
end_subband = get_bits(bc, 3) + 5;
#if USE_FIXED
s->spx_dst_end_freq = end_freq_inv_tab[end_subband-5];
#endif
if (end_subband > 7)
end_subband += end_subband - 7;
dst_start_freq = dst_start_freq * 12 + 25;
src_start_freq = start_subband * 12 + 25;
dst_end_freq = end_subband * 12 + 25;
if (start_subband >= end_subband) {
av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension "
"range (%d >= %d)\n", start_subband, end_subband);
return AVERROR_INVALIDDATA;
}
if (dst_start_freq >= src_start_freq) {
av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension "
"copy start bin (%d >= %d)\n", dst_start_freq, src_start_freq);
return AVERROR_INVALIDDATA;
}
s->spx_dst_start_freq = dst_start_freq;
s->spx_src_start_freq = src_start_freq;
if (!USE_FIXED)
s->spx_dst_end_freq = dst_end_freq;
decode_band_structure(bc, blk, s->eac3, 0,
start_subband, end_subband,
ff_eac3_default_spx_band_struct,
&s->num_spx_bands,
s->spx_band_sizes);
return 0;
}
| {
"code": [
" } else {",
" s->spx_band_sizes);"
],
"line_no": [
21,
105
]
} | static inline int FUNC_0(AC3DecodeContext *VAR_0, int VAR_1)
{
GetBitContext *bc = &VAR_0->gbc;
int VAR_2 = VAR_0->VAR_2;
int VAR_3, VAR_4, VAR_5,
VAR_6, VAR_7, VAR_8;
if (VAR_0->channel_mode == AC3_CHMODE_MONO) {
VAR_0->channel_uses_spx[1] = 1;
} else {
for (VAR_8 = 1; VAR_8 <= VAR_2; VAR_8++)
VAR_0->channel_uses_spx[VAR_8] = get_bits1(bc);
}
VAR_3 = get_bits(bc, 2);
VAR_6 = get_bits(bc, 3) + 2;
if (VAR_6 > 7)
VAR_6 += VAR_6 - 7;
VAR_7 = get_bits(bc, 3) + 5;
#if USE_FIXED
VAR_0->spx_dst_end_freq = end_freq_inv_tab[VAR_7-5];
#endif
if (VAR_7 > 7)
VAR_7 += VAR_7 - 7;
VAR_3 = VAR_3 * 12 + 25;
VAR_5 = VAR_6 * 12 + 25;
VAR_4 = VAR_7 * 12 + 25;
if (VAR_6 >= VAR_7) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid spectral extension "
"range (%d >= %d)\n", VAR_6, VAR_7);
return AVERROR_INVALIDDATA;
}
if (VAR_3 >= VAR_5) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid spectral extension "
"copy start bin (%d >= %d)\n", VAR_3, VAR_5);
return AVERROR_INVALIDDATA;
}
VAR_0->spx_dst_start_freq = VAR_3;
VAR_0->spx_src_start_freq = VAR_5;
if (!USE_FIXED)
VAR_0->spx_dst_end_freq = VAR_4;
decode_band_structure(bc, VAR_1, VAR_0->eac3, 0,
VAR_6, VAR_7,
ff_eac3_default_spx_band_struct,
&VAR_0->num_spx_bands,
VAR_0->spx_band_sizes);
return 0;
}
| [
"static inline int FUNC_0(AC3DecodeContext *VAR_0, int VAR_1)\n{",
"GetBitContext *bc = &VAR_0->gbc;",
"int VAR_2 = VAR_0->VAR_2;",
"int VAR_3, VAR_4, VAR_5,\nVAR_6, VAR_7, VAR_8;",
"if (VAR_0->channel_mode == AC3_CHMODE_MONO) {",
"VAR_0->channel_uses_spx[1] = 1;",
"} else {",
"for (VAR_8 = 1; VAR_8 <= VAR_2; VAR_8++)",
"VAR_0->channel_uses_spx[VAR_8] = get_bits1(bc);",
"}",
"VAR_3 = get_bits(bc, 2);",
"VAR_6 = get_bits(bc, 3) + 2;",
"if (VAR_6 > 7)\nVAR_6 += VAR_6 - 7;",
"VAR_7 = get_bits(bc, 3) + 5;",
"#if USE_FIXED\nVAR_0->spx_dst_end_freq = end_freq_inv_tab[VAR_7-5];",
"#endif\nif (VAR_7 > 7)\nVAR_7 += VAR_7 - 7;",
"VAR_3 = VAR_3 * 12 + 25;",
"VAR_5 = VAR_6 * 12 + 25;",
"VAR_4 = VAR_7 * 12 + 25;",
"if (VAR_6 >= VAR_7) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"invalid spectral extension \"\n\"range (%d >= %d)\\n\", VAR_6, VAR_7);",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_3 >= VAR_5) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"invalid spectral extension \"\n\"copy start bin (%d >= %d)\\n\", VAR_3, VAR_5);",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->spx_dst_start_freq = VAR_3;",
"VAR_0->spx_src_start_freq = VAR_5;",
"if (!USE_FIXED)\nVAR_0->spx_dst_end_freq = VAR_4;",
"decode_band_structure(bc, VAR_1, VAR_0->eac3, 0,\nVAR_6, VAR_7,\nff_eac3_default_spx_band_struct,\n&VAR_0->num_spx_bands,\nVAR_0->spx_band_sizes);",
"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,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45,
47
],
[
49,
51,
53
],
[
55
],
[
57
],
[
59
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91,
93
],
[
97,
99,
101,
103,
105
],
[
107
],
[
109
]
] |
24,974 | TPMInfo *tpm_backend_query_tpm(TPMBackend *s)
{
TPMInfo *info = g_new0(TPMInfo, 1);
TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
TPMIfClass *tic = TPM_IF_GET_CLASS(s->tpmif);
info->id = g_strdup(s->id);
info->model = tic->model;
if (k->get_tpm_options) {
info->options = k->get_tpm_options(s);
}
return info;
}
| true | qemu | ebca2df783a5a742bb93784524336d8cbb9e662b | TPMInfo *tpm_backend_query_tpm(TPMBackend *s)
{
TPMInfo *info = g_new0(TPMInfo, 1);
TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
TPMIfClass *tic = TPM_IF_GET_CLASS(s->tpmif);
info->id = g_strdup(s->id);
info->model = tic->model;
if (k->get_tpm_options) {
info->options = k->get_tpm_options(s);
}
return info;
}
| {
"code": [
" if (k->get_tpm_options) {",
" info->options = k->get_tpm_options(s);"
],
"line_no": [
17,
19
]
} | TPMInfo *FUNC_0(TPMBackend *s)
{
TPMInfo *info = g_new0(TPMInfo, 1);
TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
TPMIfClass *tic = TPM_IF_GET_CLASS(s->tpmif);
info->id = g_strdup(s->id);
info->model = tic->model;
if (k->get_tpm_options) {
info->options = k->get_tpm_options(s);
}
return info;
}
| [
"TPMInfo *FUNC_0(TPMBackend *s)\n{",
"TPMInfo *info = g_new0(TPMInfo, 1);",
"TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);",
"TPMIfClass *tic = TPM_IF_GET_CLASS(s->tpmif);",
"info->id = g_strdup(s->id);",
"info->model = tic->model;",
"if (k->get_tpm_options) {",
"info->options = k->get_tpm_options(s);",
"}",
"return info;",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
]
] |
24,975 | static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestamp)
{
if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE) {
int64_t addend;
int delta_timestamp;
/* compute pts from timestamp with received ntp_time */
delta_timestamp = timestamp - s->last_rtcp_timestamp;
/* convert to the PTS timebase */
addend = av_rescale(s->last_rtcp_ntp_time - s->first_rtcp_ntp_time, s->st->time_base.den, (uint64_t)s->st->time_base.num << 32);
pkt->pts = addend + delta_timestamp;
}
}
| true | FFmpeg | fc78b0cb7e115ae494861c37a9928cff74df8db9 | static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestamp)
{
if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE) {
int64_t addend;
int delta_timestamp;
delta_timestamp = timestamp - s->last_rtcp_timestamp;
addend = av_rescale(s->last_rtcp_ntp_time - s->first_rtcp_ntp_time, s->st->time_base.den, (uint64_t)s->st->time_base.num << 32);
pkt->pts = addend + delta_timestamp;
}
}
| {
"code": [
" addend = av_rescale(s->last_rtcp_ntp_time - s->first_rtcp_ntp_time, s->st->time_base.den, (uint64_t)s->st->time_base.num << 32);"
],
"line_no": [
19
]
} | static void FUNC_0(RTPDemuxContext *VAR_0, AVPacket *VAR_1, uint32_t VAR_2)
{
if (VAR_0->last_rtcp_ntp_time != AV_NOPTS_VALUE) {
int64_t addend;
int VAR_3;
VAR_3 = VAR_2 - VAR_0->last_rtcp_timestamp;
addend = av_rescale(VAR_0->last_rtcp_ntp_time - VAR_0->first_rtcp_ntp_time, VAR_0->st->time_base.den, (uint64_t)VAR_0->st->time_base.num << 32);
VAR_1->pts = addend + VAR_3;
}
}
| [
"static void FUNC_0(RTPDemuxContext *VAR_0, AVPacket *VAR_1, uint32_t VAR_2)\n{",
"if (VAR_0->last_rtcp_ntp_time != AV_NOPTS_VALUE) {",
"int64_t addend;",
"int VAR_3;",
"VAR_3 = VAR_2 - VAR_0->last_rtcp_timestamp;",
"addend = av_rescale(VAR_0->last_rtcp_ntp_time - VAR_0->first_rtcp_ntp_time, VAR_0->st->time_base.den, (uint64_t)VAR_0->st->time_base.num << 32);",
"VAR_1->pts = addend + VAR_3;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
24,977 | static void h264_v_loop_filter_chroma_intra_c(uint8_t *pix, int stride, int alpha, int beta)
{
h264_loop_filter_chroma_intra_c(pix, stride, 1, alpha, beta);
}
| false | FFmpeg | dd561441b1e849df7d8681c6f32af82d4088dafd | static void h264_v_loop_filter_chroma_intra_c(uint8_t *pix, int stride, int alpha, int beta)
{
h264_loop_filter_chroma_intra_c(pix, stride, 1, alpha, beta);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint8_t *VAR_0, int VAR_1, int VAR_2, int VAR_3)
{
h264_loop_filter_chroma_intra_c(VAR_0, VAR_1, 1, VAR_2, VAR_3);
}
| [
"static void FUNC_0(uint8_t *VAR_0, int VAR_1, int VAR_2, int VAR_3)\n{",
"h264_loop_filter_chroma_intra_c(VAR_0, VAR_1, 1, VAR_2, VAR_3);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
24,979 | static void v9fs_remove(void *opaque)
{
int32_t fid;
int err = 0;
size_t offset = 7;
V9fsFidState *fidp;
V9fsPDU *pdu = opaque;
pdu_unmarshal(pdu, offset, "d", &fid);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
err = -EINVAL;
goto out_nofid;
}
/* if fs driver is not path based, return EOPNOTSUPP */
if (!pdu->s->ctx.flags & PATHNAME_FSCONTEXT) {
err = -EOPNOTSUPP;
goto out_err;
}
/*
* IF the file is unlinked, we cannot reopen
* the file later. So don't reclaim fd
*/
err = v9fs_mark_fids_unreclaim(pdu, &fidp->path);
if (err < 0) {
goto out_err;
}
err = v9fs_co_remove(pdu, &fidp->path);
if (!err) {
err = offset;
}
out_err:
/* For TREMOVE we need to clunk the fid even on failed remove */
clunk_fid(pdu->s, fidp->fid);
put_fid(pdu, fidp);
out_nofid:
complete_pdu(pdu->s, pdu, err);
} | true | qemu | c572f23a3e7180dbeab5e86583e43ea2afed6271 | static void v9fs_remove(void *opaque)
{
int32_t fid;
int err = 0;
size_t offset = 7;
V9fsFidState *fidp;
V9fsPDU *pdu = opaque;
pdu_unmarshal(pdu, offset, "d", &fid);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
err = -EINVAL;
goto out_nofid;
}
if (!pdu->s->ctx.flags & PATHNAME_FSCONTEXT) {
err = -EOPNOTSUPP;
goto out_err;
}
err = v9fs_mark_fids_unreclaim(pdu, &fidp->path);
if (err < 0) {
goto out_err;
}
err = v9fs_co_remove(pdu, &fidp->path);
if (!err) {
err = offset;
}
out_err:
clunk_fid(pdu->s, fidp->fid);
put_fid(pdu, fidp);
out_nofid:
complete_pdu(pdu->s, pdu, err);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
int32_t fid;
int VAR_1 = 0;
size_t offset = 7;
V9fsFidState *fidp;
V9fsPDU *pdu = VAR_0;
pdu_unmarshal(pdu, offset, "d", &fid);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
VAR_1 = -EINVAL;
goto out_nofid;
}
if (!pdu->s->ctx.flags & PATHNAME_FSCONTEXT) {
VAR_1 = -EOPNOTSUPP;
goto out_err;
}
VAR_1 = v9fs_mark_fids_unreclaim(pdu, &fidp->path);
if (VAR_1 < 0) {
goto out_err;
}
VAR_1 = v9fs_co_remove(pdu, &fidp->path);
if (!VAR_1) {
VAR_1 = offset;
}
out_err:
clunk_fid(pdu->s, fidp->fid);
put_fid(pdu, fidp);
out_nofid:
complete_pdu(pdu->s, pdu, VAR_1);
} | [
"static void FUNC_0(void *VAR_0)\n{",
"int32_t fid;",
"int VAR_1 = 0;",
"size_t offset = 7;",
"V9fsFidState *fidp;",
"V9fsPDU *pdu = VAR_0;",
"pdu_unmarshal(pdu, offset, \"d\", &fid);",
"fidp = get_fid(pdu, fid);",
"if (fidp == NULL) {",
"VAR_1 = -EINVAL;",
"goto out_nofid;",
"}",
"if (!pdu->s->ctx.flags & PATHNAME_FSCONTEXT) {",
"VAR_1 = -EOPNOTSUPP;",
"goto out_err;",
"}",
"VAR_1 = v9fs_mark_fids_unreclaim(pdu, &fidp->path);",
"if (VAR_1 < 0) {",
"goto out_err;",
"}",
"VAR_1 = v9fs_co_remove(pdu, &fidp->path);",
"if (!VAR_1) {",
"VAR_1 = offset;",
"}",
"out_err:\nclunk_fid(pdu->s, fidp->fid);",
"put_fid(pdu, fidp);",
"out_nofid:\ncomplete_pdu(pdu->s, pdu, 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
22
],
[
24
],
[
26
],
[
28
],
[
30
],
[
34
],
[
36
],
[
38
],
[
40
],
[
50
],
[
52
],
[
54
],
[
56
],
[
58
],
[
60
],
[
62
],
[
64
],
[
66,
70
],
[
72
],
[
74,
76
],
[
78
]
] |
24,980 | static void gen_msgclr(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
GEN_PRIV;
#else
CHK_SV;
gen_helper_msgclr(cpu_env, cpu_gpr[rB(ctx->opcode)]);
#endif /* defined(CONFIG_USER_ONLY) */
}
| true | qemu | ebca5e6d5ec2f1cf6c886a114e161261af28dc0a | static void gen_msgclr(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
GEN_PRIV;
#else
CHK_SV;
gen_helper_msgclr(cpu_env, cpu_gpr[rB(ctx->opcode)]);
#endif
}
| {
"code": [
" CHK_SV;",
" CHK_SV;"
],
"line_no": [
11,
11
]
} | static void FUNC_0(DisasContext *VAR_0)
{
#if defined(CONFIG_USER_ONLY)
GEN_PRIV;
#else
CHK_SV;
gen_helper_msgclr(cpu_env, cpu_gpr[rB(VAR_0->opcode)]);
#endif
}
| [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"#if defined(CONFIG_USER_ONLY)\nGEN_PRIV;",
"#else\nCHK_SV;",
"gen_helper_msgclr(cpu_env, cpu_gpr[rB(VAR_0->opcode)]);",
"#endif\n}"
] | [
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9,
11
],
[
13
],
[
15,
17
]
] |
24,981 | static av_always_inline int small_diamond_search(MpegEncContext * s, int *best, int dmin,
int src_index, int ref_index, int const penalty_factor,
int size, int h, int flags)
{
MotionEstContext * const c= &s->me;
me_cmp_func cmpf, chroma_cmpf;
int next_dir=-1;
LOAD_COMMON
LOAD_COMMON2
unsigned map_generation = c->map_generation;
cmpf = s->mecc.me_cmp[size];
chroma_cmpf = s->mecc.me_cmp[size + 1];
{ /* ensure that the best point is in the MAP as h/qpel refinement needs it */
const unsigned key = (best[1]<<ME_MAP_MV_BITS) + best[0] + map_generation;
const int index= ((best[1]<<ME_MAP_SHIFT) + best[0])&(ME_MAP_SIZE-1);
if(map[index]!=key){ //this will be executed only very rarey
score_map[index]= cmp(s, best[0], best[1], 0, 0, size, h, ref_index, src_index, cmpf, chroma_cmpf, flags);
map[index]= key;
}
}
for(;;){
int d;
const int dir= next_dir;
const int x= best[0];
const int y= best[1];
next_dir=-1;
if(dir!=2 && x>xmin) CHECK_MV_DIR(x-1, y , 0)
if(dir!=3 && y>ymin) CHECK_MV_DIR(x , y-1, 1)
if(dir!=0 && x<xmax) CHECK_MV_DIR(x+1, y , 2)
if(dir!=1 && y<ymax) CHECK_MV_DIR(x , y+1, 3)
if(next_dir==-1){
return dmin;
}
}
}
| true | FFmpeg | e71ca21f308432cac3deaabe522ac1b856471162 | static av_always_inline int small_diamond_search(MpegEncContext * s, int *best, int dmin,
int src_index, int ref_index, int const penalty_factor,
int size, int h, int flags)
{
MotionEstContext * const c= &s->me;
me_cmp_func cmpf, chroma_cmpf;
int next_dir=-1;
LOAD_COMMON
LOAD_COMMON2
unsigned map_generation = c->map_generation;
cmpf = s->mecc.me_cmp[size];
chroma_cmpf = s->mecc.me_cmp[size + 1];
{
const unsigned key = (best[1]<<ME_MAP_MV_BITS) + best[0] + map_generation;
const int index= ((best[1]<<ME_MAP_SHIFT) + best[0])&(ME_MAP_SIZE-1);
if(map[index]!=key){
score_map[index]= cmp(s, best[0], best[1], 0, 0, size, h, ref_index, src_index, cmpf, chroma_cmpf, flags);
map[index]= key;
}
}
for(;;){
int d;
const int dir= next_dir;
const int x= best[0];
const int y= best[1];
next_dir=-1;
if(dir!=2 && x>xmin) CHECK_MV_DIR(x-1, y , 0)
if(dir!=3 && y>ymin) CHECK_MV_DIR(x , y-1, 1)
if(dir!=0 && x<xmax) CHECK_MV_DIR(x+1, y , 2)
if(dir!=1 && y<ymax) CHECK_MV_DIR(x , y+1, 3)
if(next_dir==-1){
return dmin;
}
}
}
| {
"code": [
" const unsigned key = (best[1]<<ME_MAP_MV_BITS) + best[0] + map_generation;",
" const int index= ((best[1]<<ME_MAP_SHIFT) + best[0])&(ME_MAP_SIZE-1);"
],
"line_no": [
31,
33
]
} | static av_always_inline int FUNC_0(MpegEncContext * s, int *best, int dmin,
int src_index, int ref_index, int const penalty_factor,
int size, int h, int flags)
{
MotionEstContext * const c= &s->me;
me_cmp_func cmpf, chroma_cmpf;
int VAR_0=-1;
LOAD_COMMON
LOAD_COMMON2
unsigned map_generation = c->map_generation;
cmpf = s->mecc.me_cmp[size];
chroma_cmpf = s->mecc.me_cmp[size + 1];
{
const unsigned VAR_1 = (best[1]<<ME_MAP_MV_BITS) + best[0] + map_generation;
const int VAR_2= ((best[1]<<ME_MAP_SHIFT) + best[0])&(ME_MAP_SIZE-1);
if(map[VAR_2]!=VAR_1){
score_map[VAR_2]= cmp(s, best[0], best[1], 0, 0, size, h, ref_index, src_index, cmpf, chroma_cmpf, flags);
map[VAR_2]= VAR_1;
}
}
for(;;){
int VAR_3;
const int VAR_4= VAR_0;
const int VAR_5= best[0];
const int VAR_6= best[1];
VAR_0=-1;
if(VAR_4!=2 && VAR_5>xmin) CHECK_MV_DIR(VAR_5-1, VAR_6 , 0)
if(VAR_4!=3 && VAR_6>ymin) CHECK_MV_DIR(VAR_5 , VAR_6-1, 1)
if(VAR_4!=0 && VAR_5<xmax) CHECK_MV_DIR(VAR_5+1, VAR_6 , 2)
if(VAR_4!=1 && VAR_6<ymax) CHECK_MV_DIR(VAR_5 , VAR_6+1, 3)
if(VAR_0==-1){
return dmin;
}
}
}
| [
"static av_always_inline int FUNC_0(MpegEncContext * s, int *best, int dmin,\nint src_index, int ref_index, int const penalty_factor,\nint size, int h, int flags)\n{",
"MotionEstContext * const c= &s->me;",
"me_cmp_func cmpf, chroma_cmpf;",
"int VAR_0=-1;",
"LOAD_COMMON\nLOAD_COMMON2\nunsigned map_generation = c->map_generation;",
"cmpf = s->mecc.me_cmp[size];",
"chroma_cmpf = s->mecc.me_cmp[size + 1];",
"{",
"const unsigned VAR_1 = (best[1]<<ME_MAP_MV_BITS) + best[0] + map_generation;",
"const int VAR_2= ((best[1]<<ME_MAP_SHIFT) + best[0])&(ME_MAP_SIZE-1);",
"if(map[VAR_2]!=VAR_1){",
"score_map[VAR_2]= cmp(s, best[0], best[1], 0, 0, size, h, ref_index, src_index, cmpf, chroma_cmpf, flags);",
"map[VAR_2]= VAR_1;",
"}",
"}",
"for(;;){",
"int VAR_3;",
"const int VAR_4= VAR_0;",
"const int VAR_5= best[0];",
"const int VAR_6= best[1];",
"VAR_0=-1;",
"if(VAR_4!=2 && VAR_5>xmin) CHECK_MV_DIR(VAR_5-1, VAR_6 , 0)\nif(VAR_4!=3 && VAR_6>ymin) CHECK_MV_DIR(VAR_5 , VAR_6-1, 1)\nif(VAR_4!=0 && VAR_5<xmax) CHECK_MV_DIR(VAR_5+1, VAR_6 , 2)\nif(VAR_4!=1 && VAR_6<ymax) CHECK_MV_DIR(VAR_5 , VAR_6+1, 3)\nif(VAR_0==-1){",
"return dmin;",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15,
17,
19
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61,
63,
65,
67,
71
],
[
73
],
[
75
],
[
77
],
[
79
]
] |
24,982 | void mips_cpu_do_interrupt(CPUState *cs)
{
#if !defined(CONFIG_USER_ONLY)
MIPSCPU *cpu = MIPS_CPU(cs);
CPUMIPSState *env = &cpu->env;
target_ulong offset;
int cause = -1;
const char *name;
if (qemu_log_enabled() && cs->exception_index != EXCP_EXT_INTERRUPT) {
if (cs->exception_index < 0 || cs->exception_index > EXCP_LAST) {
name = "unknown";
} else {
name = excp_names[cs->exception_index];
}
qemu_log("%s enter: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " %s exception\n",
__func__, env->active_tc.PC, env->CP0_EPC, name);
}
if (cs->exception_index == EXCP_EXT_INTERRUPT &&
(env->hflags & MIPS_HFLAG_DM)) {
cs->exception_index = EXCP_DINT;
}
offset = 0x180;
switch (cs->exception_index) {
case EXCP_DSS:
env->CP0_Debug |= 1 << CP0DB_DSS;
/* Debug single step cannot be raised inside a delay slot and
resume will always occur on the next instruction
(but we assume the pc has always been updated during
code translation). */
env->CP0_DEPC = env->active_tc.PC | !!(env->hflags & MIPS_HFLAG_M16);
goto enter_debug_mode;
case EXCP_DINT:
env->CP0_Debug |= 1 << CP0DB_DINT;
goto set_DEPC;
case EXCP_DIB:
env->CP0_Debug |= 1 << CP0DB_DIB;
goto set_DEPC;
case EXCP_DBp:
env->CP0_Debug |= 1 << CP0DB_DBp;
goto set_DEPC;
case EXCP_DDBS:
env->CP0_Debug |= 1 << CP0DB_DDBS;
goto set_DEPC;
case EXCP_DDBL:
env->CP0_Debug |= 1 << CP0DB_DDBL;
set_DEPC:
env->CP0_DEPC = exception_resume_pc(env);
env->hflags &= ~MIPS_HFLAG_BMASK;
enter_debug_mode:
env->hflags |= MIPS_HFLAG_DM | MIPS_HFLAG_64 | MIPS_HFLAG_CP0;
env->hflags &= ~(MIPS_HFLAG_KSU);
/* EJTAG probe trap enable is not implemented... */
if (!(env->CP0_Status & (1 << CP0St_EXL)))
env->CP0_Cause &= ~(1 << CP0Ca_BD);
env->active_tc.PC = (int32_t)0xBFC00480;
set_hflags_for_handler(env);
break;
case EXCP_RESET:
cpu_reset(CPU(cpu));
break;
case EXCP_SRESET:
env->CP0_Status |= (1 << CP0St_SR);
memset(env->CP0_WatchLo, 0, sizeof(*env->CP0_WatchLo));
goto set_error_EPC;
case EXCP_NMI:
env->CP0_Status |= (1 << CP0St_NMI);
set_error_EPC:
env->CP0_ErrorEPC = exception_resume_pc(env);
env->hflags &= ~MIPS_HFLAG_BMASK;
env->CP0_Status |= (1 << CP0St_ERL) | (1 << CP0St_BEV);
env->hflags |= MIPS_HFLAG_64 | MIPS_HFLAG_CP0;
env->hflags &= ~(MIPS_HFLAG_KSU);
if (!(env->CP0_Status & (1 << CP0St_EXL)))
env->CP0_Cause &= ~(1 << CP0Ca_BD);
env->active_tc.PC = (int32_t)0xBFC00000;
set_hflags_for_handler(env);
break;
case EXCP_EXT_INTERRUPT:
cause = 0;
if (env->CP0_Cause & (1 << CP0Ca_IV))
offset = 0x200;
if (env->CP0_Config3 & ((1 << CP0C3_VInt) | (1 << CP0C3_VEIC))) {
/* Vectored Interrupts. */
unsigned int spacing;
unsigned int vector;
unsigned int pending = (env->CP0_Cause & CP0Ca_IP_mask) >> 8;
pending &= env->CP0_Status >> 8;
/* Compute the Vector Spacing. */
spacing = (env->CP0_IntCtl >> CP0IntCtl_VS) & ((1 << 6) - 1);
spacing <<= 5;
if (env->CP0_Config3 & (1 << CP0C3_VInt)) {
/* For VInt mode, the MIPS computes the vector internally. */
for (vector = 7; vector > 0; vector--) {
if (pending & (1 << vector)) {
/* Found it. */
break;
}
}
} else {
/* For VEIC mode, the external interrupt controller feeds the
vector through the CP0Cause IP lines. */
vector = pending;
}
offset = 0x200 + vector * spacing;
}
goto set_EPC;
case EXCP_LTLBL:
cause = 1;
goto set_EPC;
case EXCP_TLBL:
cause = 2;
if (env->error_code == 1 && !(env->CP0_Status & (1 << CP0St_EXL))) {
#if defined(TARGET_MIPS64)
int R = env->CP0_BadVAddr >> 62;
int UX = (env->CP0_Status & (1 << CP0St_UX)) != 0;
int SX = (env->CP0_Status & (1 << CP0St_SX)) != 0;
int KX = (env->CP0_Status & (1 << CP0St_KX)) != 0;
if (((R == 0 && UX) || (R == 1 && SX) || (R == 3 && KX)) &&
(!(env->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F))))
offset = 0x080;
else
#endif
offset = 0x000;
}
goto set_EPC;
case EXCP_TLBS:
cause = 3;
if (env->error_code == 1 && !(env->CP0_Status & (1 << CP0St_EXL))) {
#if defined(TARGET_MIPS64)
int R = env->CP0_BadVAddr >> 62;
int UX = (env->CP0_Status & (1 << CP0St_UX)) != 0;
int SX = (env->CP0_Status & (1 << CP0St_SX)) != 0;
int KX = (env->CP0_Status & (1 << CP0St_KX)) != 0;
if (((R == 0 && UX) || (R == 1 && SX) || (R == 3 && KX)) &&
(!(env->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F))))
offset = 0x080;
else
#endif
offset = 0x000;
}
goto set_EPC;
case EXCP_AdEL:
cause = 4;
goto set_EPC;
case EXCP_AdES:
cause = 5;
goto set_EPC;
case EXCP_IBE:
cause = 6;
goto set_EPC;
case EXCP_DBE:
cause = 7;
goto set_EPC;
case EXCP_SYSCALL:
cause = 8;
goto set_EPC;
case EXCP_BREAK:
cause = 9;
goto set_EPC;
case EXCP_RI:
cause = 10;
goto set_EPC;
case EXCP_CpU:
cause = 11;
env->CP0_Cause = (env->CP0_Cause & ~(0x3 << CP0Ca_CE)) |
(env->error_code << CP0Ca_CE);
goto set_EPC;
case EXCP_OVERFLOW:
cause = 12;
goto set_EPC;
case EXCP_TRAP:
cause = 13;
goto set_EPC;
case EXCP_FPE:
cause = 15;
goto set_EPC;
case EXCP_C2E:
cause = 18;
goto set_EPC;
case EXCP_MDMX:
cause = 22;
goto set_EPC;
case EXCP_DWATCH:
cause = 23;
/* XXX: TODO: manage defered watch exceptions */
goto set_EPC;
case EXCP_MCHECK:
cause = 24;
goto set_EPC;
case EXCP_THREAD:
cause = 25;
goto set_EPC;
case EXCP_DSPDIS:
cause = 26;
goto set_EPC;
case EXCP_CACHE:
cause = 30;
if (env->CP0_Status & (1 << CP0St_BEV)) {
offset = 0x100;
} else {
offset = 0x20000100;
}
set_EPC:
if (!(env->CP0_Status & (1 << CP0St_EXL))) {
env->CP0_EPC = exception_resume_pc(env);
if (env->hflags & MIPS_HFLAG_BMASK) {
env->CP0_Cause |= (1 << CP0Ca_BD);
} else {
env->CP0_Cause &= ~(1 << CP0Ca_BD);
}
env->CP0_Status |= (1 << CP0St_EXL);
env->hflags |= MIPS_HFLAG_64 | MIPS_HFLAG_CP0;
env->hflags &= ~(MIPS_HFLAG_KSU);
}
env->hflags &= ~MIPS_HFLAG_BMASK;
if (env->CP0_Status & (1 << CP0St_BEV)) {
env->active_tc.PC = (int32_t)0xBFC00200;
} else {
env->active_tc.PC = (int32_t)(env->CP0_EBase & ~0x3ff);
}
env->active_tc.PC += offset;
set_hflags_for_handler(env);
env->CP0_Cause = (env->CP0_Cause & ~(0x1f << CP0Ca_EC)) | (cause << CP0Ca_EC);
break;
default:
qemu_log("Invalid MIPS exception %d. Exiting\n", cs->exception_index);
printf("Invalid MIPS exception %d. Exiting\n", cs->exception_index);
exit(1);
}
if (qemu_log_enabled() && cs->exception_index != EXCP_EXT_INTERRUPT) {
qemu_log("%s: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " cause %d\n"
" S %08x C %08x A " TARGET_FMT_lx " D " TARGET_FMT_lx "\n",
__func__, env->active_tc.PC, env->CP0_EPC, cause,
env->CP0_Status, env->CP0_Cause, env->CP0_BadVAddr,
env->CP0_DEPC);
}
#endif
cs->exception_index = EXCP_NONE;
}
| true | qemu | f45cb2f43f5bb0a4122a64e61c746048b59a84ed | void mips_cpu_do_interrupt(CPUState *cs)
{
#if !defined(CONFIG_USER_ONLY)
MIPSCPU *cpu = MIPS_CPU(cs);
CPUMIPSState *env = &cpu->env;
target_ulong offset;
int cause = -1;
const char *name;
if (qemu_log_enabled() && cs->exception_index != EXCP_EXT_INTERRUPT) {
if (cs->exception_index < 0 || cs->exception_index > EXCP_LAST) {
name = "unknown";
} else {
name = excp_names[cs->exception_index];
}
qemu_log("%s enter: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " %s exception\n",
__func__, env->active_tc.PC, env->CP0_EPC, name);
}
if (cs->exception_index == EXCP_EXT_INTERRUPT &&
(env->hflags & MIPS_HFLAG_DM)) {
cs->exception_index = EXCP_DINT;
}
offset = 0x180;
switch (cs->exception_index) {
case EXCP_DSS:
env->CP0_Debug |= 1 << CP0DB_DSS;
env->CP0_DEPC = env->active_tc.PC | !!(env->hflags & MIPS_HFLAG_M16);
goto enter_debug_mode;
case EXCP_DINT:
env->CP0_Debug |= 1 << CP0DB_DINT;
goto set_DEPC;
case EXCP_DIB:
env->CP0_Debug |= 1 << CP0DB_DIB;
goto set_DEPC;
case EXCP_DBp:
env->CP0_Debug |= 1 << CP0DB_DBp;
goto set_DEPC;
case EXCP_DDBS:
env->CP0_Debug |= 1 << CP0DB_DDBS;
goto set_DEPC;
case EXCP_DDBL:
env->CP0_Debug |= 1 << CP0DB_DDBL;
set_DEPC:
env->CP0_DEPC = exception_resume_pc(env);
env->hflags &= ~MIPS_HFLAG_BMASK;
enter_debug_mode:
env->hflags |= MIPS_HFLAG_DM | MIPS_HFLAG_64 | MIPS_HFLAG_CP0;
env->hflags &= ~(MIPS_HFLAG_KSU);
if (!(env->CP0_Status & (1 << CP0St_EXL)))
env->CP0_Cause &= ~(1 << CP0Ca_BD);
env->active_tc.PC = (int32_t)0xBFC00480;
set_hflags_for_handler(env);
break;
case EXCP_RESET:
cpu_reset(CPU(cpu));
break;
case EXCP_SRESET:
env->CP0_Status |= (1 << CP0St_SR);
memset(env->CP0_WatchLo, 0, sizeof(*env->CP0_WatchLo));
goto set_error_EPC;
case EXCP_NMI:
env->CP0_Status |= (1 << CP0St_NMI);
set_error_EPC:
env->CP0_ErrorEPC = exception_resume_pc(env);
env->hflags &= ~MIPS_HFLAG_BMASK;
env->CP0_Status |= (1 << CP0St_ERL) | (1 << CP0St_BEV);
env->hflags |= MIPS_HFLAG_64 | MIPS_HFLAG_CP0;
env->hflags &= ~(MIPS_HFLAG_KSU);
if (!(env->CP0_Status & (1 << CP0St_EXL)))
env->CP0_Cause &= ~(1 << CP0Ca_BD);
env->active_tc.PC = (int32_t)0xBFC00000;
set_hflags_for_handler(env);
break;
case EXCP_EXT_INTERRUPT:
cause = 0;
if (env->CP0_Cause & (1 << CP0Ca_IV))
offset = 0x200;
if (env->CP0_Config3 & ((1 << CP0C3_VInt) | (1 << CP0C3_VEIC))) {
unsigned int spacing;
unsigned int vector;
unsigned int pending = (env->CP0_Cause & CP0Ca_IP_mask) >> 8;
pending &= env->CP0_Status >> 8;
spacing = (env->CP0_IntCtl >> CP0IntCtl_VS) & ((1 << 6) - 1);
spacing <<= 5;
if (env->CP0_Config3 & (1 << CP0C3_VInt)) {
for (vector = 7; vector > 0; vector--) {
if (pending & (1 << vector)) {
break;
}
}
} else {
vector = pending;
}
offset = 0x200 + vector * spacing;
}
goto set_EPC;
case EXCP_LTLBL:
cause = 1;
goto set_EPC;
case EXCP_TLBL:
cause = 2;
if (env->error_code == 1 && !(env->CP0_Status & (1 << CP0St_EXL))) {
#if defined(TARGET_MIPS64)
int R = env->CP0_BadVAddr >> 62;
int UX = (env->CP0_Status & (1 << CP0St_UX)) != 0;
int SX = (env->CP0_Status & (1 << CP0St_SX)) != 0;
int KX = (env->CP0_Status & (1 << CP0St_KX)) != 0;
if (((R == 0 && UX) || (R == 1 && SX) || (R == 3 && KX)) &&
(!(env->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F))))
offset = 0x080;
else
#endif
offset = 0x000;
}
goto set_EPC;
case EXCP_TLBS:
cause = 3;
if (env->error_code == 1 && !(env->CP0_Status & (1 << CP0St_EXL))) {
#if defined(TARGET_MIPS64)
int R = env->CP0_BadVAddr >> 62;
int UX = (env->CP0_Status & (1 << CP0St_UX)) != 0;
int SX = (env->CP0_Status & (1 << CP0St_SX)) != 0;
int KX = (env->CP0_Status & (1 << CP0St_KX)) != 0;
if (((R == 0 && UX) || (R == 1 && SX) || (R == 3 && KX)) &&
(!(env->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F))))
offset = 0x080;
else
#endif
offset = 0x000;
}
goto set_EPC;
case EXCP_AdEL:
cause = 4;
goto set_EPC;
case EXCP_AdES:
cause = 5;
goto set_EPC;
case EXCP_IBE:
cause = 6;
goto set_EPC;
case EXCP_DBE:
cause = 7;
goto set_EPC;
case EXCP_SYSCALL:
cause = 8;
goto set_EPC;
case EXCP_BREAK:
cause = 9;
goto set_EPC;
case EXCP_RI:
cause = 10;
goto set_EPC;
case EXCP_CpU:
cause = 11;
env->CP0_Cause = (env->CP0_Cause & ~(0x3 << CP0Ca_CE)) |
(env->error_code << CP0Ca_CE);
goto set_EPC;
case EXCP_OVERFLOW:
cause = 12;
goto set_EPC;
case EXCP_TRAP:
cause = 13;
goto set_EPC;
case EXCP_FPE:
cause = 15;
goto set_EPC;
case EXCP_C2E:
cause = 18;
goto set_EPC;
case EXCP_MDMX:
cause = 22;
goto set_EPC;
case EXCP_DWATCH:
cause = 23;
goto set_EPC;
case EXCP_MCHECK:
cause = 24;
goto set_EPC;
case EXCP_THREAD:
cause = 25;
goto set_EPC;
case EXCP_DSPDIS:
cause = 26;
goto set_EPC;
case EXCP_CACHE:
cause = 30;
if (env->CP0_Status & (1 << CP0St_BEV)) {
offset = 0x100;
} else {
offset = 0x20000100;
}
set_EPC:
if (!(env->CP0_Status & (1 << CP0St_EXL))) {
env->CP0_EPC = exception_resume_pc(env);
if (env->hflags & MIPS_HFLAG_BMASK) {
env->CP0_Cause |= (1 << CP0Ca_BD);
} else {
env->CP0_Cause &= ~(1 << CP0Ca_BD);
}
env->CP0_Status |= (1 << CP0St_EXL);
env->hflags |= MIPS_HFLAG_64 | MIPS_HFLAG_CP0;
env->hflags &= ~(MIPS_HFLAG_KSU);
}
env->hflags &= ~MIPS_HFLAG_BMASK;
if (env->CP0_Status & (1 << CP0St_BEV)) {
env->active_tc.PC = (int32_t)0xBFC00200;
} else {
env->active_tc.PC = (int32_t)(env->CP0_EBase & ~0x3ff);
}
env->active_tc.PC += offset;
set_hflags_for_handler(env);
env->CP0_Cause = (env->CP0_Cause & ~(0x1f << CP0Ca_EC)) | (cause << CP0Ca_EC);
break;
default:
qemu_log("Invalid MIPS exception %d. Exiting\n", cs->exception_index);
printf("Invalid MIPS exception %d. Exiting\n", cs->exception_index);
exit(1);
}
if (qemu_log_enabled() && cs->exception_index != EXCP_EXT_INTERRUPT) {
qemu_log("%s: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " cause %d\n"
" S %08x C %08x A " TARGET_FMT_lx " D " TARGET_FMT_lx "\n",
__func__, env->active_tc.PC, env->CP0_EPC, cause,
env->CP0_Status, env->CP0_Cause, env->CP0_BadVAddr,
env->CP0_DEPC);
}
#endif
cs->exception_index = EXCP_NONE;
}
| {
"code": [
" env->CP0_Cause &= ~(1 << CP0Ca_BD);",
" env->CP0_Cause &= ~(1 << CP0Ca_BD);",
" env->CP0_Cause |= (1 << CP0Ca_BD);",
" env->CP0_Cause &= ~(1 << CP0Ca_BD);"
],
"line_no": [
111,
111,
427,
431
]
} | void FUNC_0(CPUState *VAR_0)
{
#if !defined(CONFIG_USER_ONLY)
MIPSCPU *cpu = MIPS_CPU(VAR_0);
CPUMIPSState *env = &cpu->env;
target_ulong offset;
int VAR_1 = -1;
const char *VAR_2;
if (qemu_log_enabled() && VAR_0->exception_index != EXCP_EXT_INTERRUPT) {
if (VAR_0->exception_index < 0 || VAR_0->exception_index > EXCP_LAST) {
VAR_2 = "unknown";
} else {
VAR_2 = excp_names[VAR_0->exception_index];
}
qemu_log("%s enter: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " %s exception\n",
__func__, env->active_tc.PC, env->CP0_EPC, VAR_2);
}
if (VAR_0->exception_index == EXCP_EXT_INTERRUPT &&
(env->hflags & MIPS_HFLAG_DM)) {
VAR_0->exception_index = EXCP_DINT;
}
offset = 0x180;
switch (VAR_0->exception_index) {
case EXCP_DSS:
env->CP0_Debug |= 1 << CP0DB_DSS;
env->CP0_DEPC = env->active_tc.PC | !!(env->hflags & MIPS_HFLAG_M16);
goto enter_debug_mode;
case EXCP_DINT:
env->CP0_Debug |= 1 << CP0DB_DINT;
goto set_DEPC;
case EXCP_DIB:
env->CP0_Debug |= 1 << CP0DB_DIB;
goto set_DEPC;
case EXCP_DBp:
env->CP0_Debug |= 1 << CP0DB_DBp;
goto set_DEPC;
case EXCP_DDBS:
env->CP0_Debug |= 1 << CP0DB_DDBS;
goto set_DEPC;
case EXCP_DDBL:
env->CP0_Debug |= 1 << CP0DB_DDBL;
set_DEPC:
env->CP0_DEPC = exception_resume_pc(env);
env->hflags &= ~MIPS_HFLAG_BMASK;
enter_debug_mode:
env->hflags |= MIPS_HFLAG_DM | MIPS_HFLAG_64 | MIPS_HFLAG_CP0;
env->hflags &= ~(MIPS_HFLAG_KSU);
if (!(env->CP0_Status & (1 << CP0St_EXL)))
env->CP0_Cause &= ~(1 << CP0Ca_BD);
env->active_tc.PC = (int32_t)0xBFC00480;
set_hflags_for_handler(env);
break;
case EXCP_RESET:
cpu_reset(CPU(cpu));
break;
case EXCP_SRESET:
env->CP0_Status |= (1 << CP0St_SR);
memset(env->CP0_WatchLo, 0, sizeof(*env->CP0_WatchLo));
goto set_error_EPC;
case EXCP_NMI:
env->CP0_Status |= (1 << CP0St_NMI);
set_error_EPC:
env->CP0_ErrorEPC = exception_resume_pc(env);
env->hflags &= ~MIPS_HFLAG_BMASK;
env->CP0_Status |= (1 << CP0St_ERL) | (1 << CP0St_BEV);
env->hflags |= MIPS_HFLAG_64 | MIPS_HFLAG_CP0;
env->hflags &= ~(MIPS_HFLAG_KSU);
if (!(env->CP0_Status & (1 << CP0St_EXL)))
env->CP0_Cause &= ~(1 << CP0Ca_BD);
env->active_tc.PC = (int32_t)0xBFC00000;
set_hflags_for_handler(env);
break;
case EXCP_EXT_INTERRUPT:
VAR_1 = 0;
if (env->CP0_Cause & (1 << CP0Ca_IV))
offset = 0x200;
if (env->CP0_Config3 & ((1 << CP0C3_VInt) | (1 << CP0C3_VEIC))) {
unsigned int VAR_3;
unsigned int VAR_4;
unsigned int VAR_5 = (env->CP0_Cause & CP0Ca_IP_mask) >> 8;
VAR_5 &= env->CP0_Status >> 8;
VAR_3 = (env->CP0_IntCtl >> CP0IntCtl_VS) & ((1 << 6) - 1);
VAR_3 <<= 5;
if (env->CP0_Config3 & (1 << CP0C3_VInt)) {
for (VAR_4 = 7; VAR_4 > 0; VAR_4--) {
if (VAR_5 & (1 << VAR_4)) {
break;
}
}
} else {
VAR_4 = VAR_5;
}
offset = 0x200 + VAR_4 * VAR_3;
}
goto set_EPC;
case EXCP_LTLBL:
VAR_1 = 1;
goto set_EPC;
case EXCP_TLBL:
VAR_1 = 2;
if (env->error_code == 1 && !(env->CP0_Status & (1 << CP0St_EXL))) {
#if defined(TARGET_MIPS64)
int R = env->CP0_BadVAddr >> 62;
int UX = (env->CP0_Status & (1 << CP0St_UX)) != 0;
int SX = (env->CP0_Status & (1 << CP0St_SX)) != 0;
int KX = (env->CP0_Status & (1 << CP0St_KX)) != 0;
if (((R == 0 && UX) || (R == 1 && SX) || (R == 3 && KX)) &&
(!(env->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F))))
offset = 0x080;
else
#endif
offset = 0x000;
}
goto set_EPC;
case EXCP_TLBS:
VAR_1 = 3;
if (env->error_code == 1 && !(env->CP0_Status & (1 << CP0St_EXL))) {
#if defined(TARGET_MIPS64)
int R = env->CP0_BadVAddr >> 62;
int UX = (env->CP0_Status & (1 << CP0St_UX)) != 0;
int SX = (env->CP0_Status & (1 << CP0St_SX)) != 0;
int KX = (env->CP0_Status & (1 << CP0St_KX)) != 0;
if (((R == 0 && UX) || (R == 1 && SX) || (R == 3 && KX)) &&
(!(env->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F))))
offset = 0x080;
else
#endif
offset = 0x000;
}
goto set_EPC;
case EXCP_AdEL:
VAR_1 = 4;
goto set_EPC;
case EXCP_AdES:
VAR_1 = 5;
goto set_EPC;
case EXCP_IBE:
VAR_1 = 6;
goto set_EPC;
case EXCP_DBE:
VAR_1 = 7;
goto set_EPC;
case EXCP_SYSCALL:
VAR_1 = 8;
goto set_EPC;
case EXCP_BREAK:
VAR_1 = 9;
goto set_EPC;
case EXCP_RI:
VAR_1 = 10;
goto set_EPC;
case EXCP_CpU:
VAR_1 = 11;
env->CP0_Cause = (env->CP0_Cause & ~(0x3 << CP0Ca_CE)) |
(env->error_code << CP0Ca_CE);
goto set_EPC;
case EXCP_OVERFLOW:
VAR_1 = 12;
goto set_EPC;
case EXCP_TRAP:
VAR_1 = 13;
goto set_EPC;
case EXCP_FPE:
VAR_1 = 15;
goto set_EPC;
case EXCP_C2E:
VAR_1 = 18;
goto set_EPC;
case EXCP_MDMX:
VAR_1 = 22;
goto set_EPC;
case EXCP_DWATCH:
VAR_1 = 23;
goto set_EPC;
case EXCP_MCHECK:
VAR_1 = 24;
goto set_EPC;
case EXCP_THREAD:
VAR_1 = 25;
goto set_EPC;
case EXCP_DSPDIS:
VAR_1 = 26;
goto set_EPC;
case EXCP_CACHE:
VAR_1 = 30;
if (env->CP0_Status & (1 << CP0St_BEV)) {
offset = 0x100;
} else {
offset = 0x20000100;
}
set_EPC:
if (!(env->CP0_Status & (1 << CP0St_EXL))) {
env->CP0_EPC = exception_resume_pc(env);
if (env->hflags & MIPS_HFLAG_BMASK) {
env->CP0_Cause |= (1 << CP0Ca_BD);
} else {
env->CP0_Cause &= ~(1 << CP0Ca_BD);
}
env->CP0_Status |= (1 << CP0St_EXL);
env->hflags |= MIPS_HFLAG_64 | MIPS_HFLAG_CP0;
env->hflags &= ~(MIPS_HFLAG_KSU);
}
env->hflags &= ~MIPS_HFLAG_BMASK;
if (env->CP0_Status & (1 << CP0St_BEV)) {
env->active_tc.PC = (int32_t)0xBFC00200;
} else {
env->active_tc.PC = (int32_t)(env->CP0_EBase & ~0x3ff);
}
env->active_tc.PC += offset;
set_hflags_for_handler(env);
env->CP0_Cause = (env->CP0_Cause & ~(0x1f << CP0Ca_EC)) | (VAR_1 << CP0Ca_EC);
break;
default:
qemu_log("Invalid MIPS exception %d. Exiting\n", VAR_0->exception_index);
printf("Invalid MIPS exception %d. Exiting\n", VAR_0->exception_index);
exit(1);
}
if (qemu_log_enabled() && VAR_0->exception_index != EXCP_EXT_INTERRUPT) {
qemu_log("%s: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " VAR_1 %d\n"
" S %08x C %08x A " TARGET_FMT_lx " D " TARGET_FMT_lx "\n",
__func__, env->active_tc.PC, env->CP0_EPC, VAR_1,
env->CP0_Status, env->CP0_Cause, env->CP0_BadVAddr,
env->CP0_DEPC);
}
#endif
VAR_0->exception_index = EXCP_NONE;
}
| [
"void FUNC_0(CPUState *VAR_0)\n{",
"#if !defined(CONFIG_USER_ONLY)\nMIPSCPU *cpu = MIPS_CPU(VAR_0);",
"CPUMIPSState *env = &cpu->env;",
"target_ulong offset;",
"int VAR_1 = -1;",
"const char *VAR_2;",
"if (qemu_log_enabled() && VAR_0->exception_index != EXCP_EXT_INTERRUPT) {",
"if (VAR_0->exception_index < 0 || VAR_0->exception_index > EXCP_LAST) {",
"VAR_2 = \"unknown\";",
"} else {",
"VAR_2 = excp_names[VAR_0->exception_index];",
"}",
"qemu_log(\"%s enter: PC \" TARGET_FMT_lx \" EPC \" TARGET_FMT_lx \" %s exception\\n\",\n__func__, env->active_tc.PC, env->CP0_EPC, VAR_2);",
"}",
"if (VAR_0->exception_index == EXCP_EXT_INTERRUPT &&\n(env->hflags & MIPS_HFLAG_DM)) {",
"VAR_0->exception_index = EXCP_DINT;",
"}",
"offset = 0x180;",
"switch (VAR_0->exception_index) {",
"case EXCP_DSS:\nenv->CP0_Debug |= 1 << CP0DB_DSS;",
"env->CP0_DEPC = env->active_tc.PC | !!(env->hflags & MIPS_HFLAG_M16);",
"goto enter_debug_mode;",
"case EXCP_DINT:\nenv->CP0_Debug |= 1 << CP0DB_DINT;",
"goto set_DEPC;",
"case EXCP_DIB:\nenv->CP0_Debug |= 1 << CP0DB_DIB;",
"goto set_DEPC;",
"case EXCP_DBp:\nenv->CP0_Debug |= 1 << CP0DB_DBp;",
"goto set_DEPC;",
"case EXCP_DDBS:\nenv->CP0_Debug |= 1 << CP0DB_DDBS;",
"goto set_DEPC;",
"case EXCP_DDBL:\nenv->CP0_Debug |= 1 << CP0DB_DDBL;",
"set_DEPC:\nenv->CP0_DEPC = exception_resume_pc(env);",
"env->hflags &= ~MIPS_HFLAG_BMASK;",
"enter_debug_mode:\nenv->hflags |= MIPS_HFLAG_DM | MIPS_HFLAG_64 | MIPS_HFLAG_CP0;",
"env->hflags &= ~(MIPS_HFLAG_KSU);",
"if (!(env->CP0_Status & (1 << CP0St_EXL)))\nenv->CP0_Cause &= ~(1 << CP0Ca_BD);",
"env->active_tc.PC = (int32_t)0xBFC00480;",
"set_hflags_for_handler(env);",
"break;",
"case EXCP_RESET:\ncpu_reset(CPU(cpu));",
"break;",
"case EXCP_SRESET:\nenv->CP0_Status |= (1 << CP0St_SR);",
"memset(env->CP0_WatchLo, 0, sizeof(*env->CP0_WatchLo));",
"goto set_error_EPC;",
"case EXCP_NMI:\nenv->CP0_Status |= (1 << CP0St_NMI);",
"set_error_EPC:\nenv->CP0_ErrorEPC = exception_resume_pc(env);",
"env->hflags &= ~MIPS_HFLAG_BMASK;",
"env->CP0_Status |= (1 << CP0St_ERL) | (1 << CP0St_BEV);",
"env->hflags |= MIPS_HFLAG_64 | MIPS_HFLAG_CP0;",
"env->hflags &= ~(MIPS_HFLAG_KSU);",
"if (!(env->CP0_Status & (1 << CP0St_EXL)))\nenv->CP0_Cause &= ~(1 << CP0Ca_BD);",
"env->active_tc.PC = (int32_t)0xBFC00000;",
"set_hflags_for_handler(env);",
"break;",
"case EXCP_EXT_INTERRUPT:\nVAR_1 = 0;",
"if (env->CP0_Cause & (1 << CP0Ca_IV))\noffset = 0x200;",
"if (env->CP0_Config3 & ((1 << CP0C3_VInt) | (1 << CP0C3_VEIC))) {",
"unsigned int VAR_3;",
"unsigned int VAR_4;",
"unsigned int VAR_5 = (env->CP0_Cause & CP0Ca_IP_mask) >> 8;",
"VAR_5 &= env->CP0_Status >> 8;",
"VAR_3 = (env->CP0_IntCtl >> CP0IntCtl_VS) & ((1 << 6) - 1);",
"VAR_3 <<= 5;",
"if (env->CP0_Config3 & (1 << CP0C3_VInt)) {",
"for (VAR_4 = 7; VAR_4 > 0; VAR_4--) {",
"if (VAR_5 & (1 << VAR_4)) {",
"break;",
"}",
"}",
"} else {",
"VAR_4 = VAR_5;",
"}",
"offset = 0x200 + VAR_4 * VAR_3;",
"}",
"goto set_EPC;",
"case EXCP_LTLBL:\nVAR_1 = 1;",
"goto set_EPC;",
"case EXCP_TLBL:\nVAR_1 = 2;",
"if (env->error_code == 1 && !(env->CP0_Status & (1 << CP0St_EXL))) {",
"#if defined(TARGET_MIPS64)\nint R = env->CP0_BadVAddr >> 62;",
"int UX = (env->CP0_Status & (1 << CP0St_UX)) != 0;",
"int SX = (env->CP0_Status & (1 << CP0St_SX)) != 0;",
"int KX = (env->CP0_Status & (1 << CP0St_KX)) != 0;",
"if (((R == 0 && UX) || (R == 1 && SX) || (R == 3 && KX)) &&\n(!(env->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F))))\noffset = 0x080;",
"else\n#endif\noffset = 0x000;",
"}",
"goto set_EPC;",
"case EXCP_TLBS:\nVAR_1 = 3;",
"if (env->error_code == 1 && !(env->CP0_Status & (1 << CP0St_EXL))) {",
"#if defined(TARGET_MIPS64)\nint R = env->CP0_BadVAddr >> 62;",
"int UX = (env->CP0_Status & (1 << CP0St_UX)) != 0;",
"int SX = (env->CP0_Status & (1 << CP0St_SX)) != 0;",
"int KX = (env->CP0_Status & (1 << CP0St_KX)) != 0;",
"if (((R == 0 && UX) || (R == 1 && SX) || (R == 3 && KX)) &&\n(!(env->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F))))\noffset = 0x080;",
"else\n#endif\noffset = 0x000;",
"}",
"goto set_EPC;",
"case EXCP_AdEL:\nVAR_1 = 4;",
"goto set_EPC;",
"case EXCP_AdES:\nVAR_1 = 5;",
"goto set_EPC;",
"case EXCP_IBE:\nVAR_1 = 6;",
"goto set_EPC;",
"case EXCP_DBE:\nVAR_1 = 7;",
"goto set_EPC;",
"case EXCP_SYSCALL:\nVAR_1 = 8;",
"goto set_EPC;",
"case EXCP_BREAK:\nVAR_1 = 9;",
"goto set_EPC;",
"case EXCP_RI:\nVAR_1 = 10;",
"goto set_EPC;",
"case EXCP_CpU:\nVAR_1 = 11;",
"env->CP0_Cause = (env->CP0_Cause & ~(0x3 << CP0Ca_CE)) |\n(env->error_code << CP0Ca_CE);",
"goto set_EPC;",
"case EXCP_OVERFLOW:\nVAR_1 = 12;",
"goto set_EPC;",
"case EXCP_TRAP:\nVAR_1 = 13;",
"goto set_EPC;",
"case EXCP_FPE:\nVAR_1 = 15;",
"goto set_EPC;",
"case EXCP_C2E:\nVAR_1 = 18;",
"goto set_EPC;",
"case EXCP_MDMX:\nVAR_1 = 22;",
"goto set_EPC;",
"case EXCP_DWATCH:\nVAR_1 = 23;",
"goto set_EPC;",
"case EXCP_MCHECK:\nVAR_1 = 24;",
"goto set_EPC;",
"case EXCP_THREAD:\nVAR_1 = 25;",
"goto set_EPC;",
"case EXCP_DSPDIS:\nVAR_1 = 26;",
"goto set_EPC;",
"case EXCP_CACHE:\nVAR_1 = 30;",
"if (env->CP0_Status & (1 << CP0St_BEV)) {",
"offset = 0x100;",
"} else {",
"offset = 0x20000100;",
"}",
"set_EPC:\nif (!(env->CP0_Status & (1 << CP0St_EXL))) {",
"env->CP0_EPC = exception_resume_pc(env);",
"if (env->hflags & MIPS_HFLAG_BMASK) {",
"env->CP0_Cause |= (1 << CP0Ca_BD);",
"} else {",
"env->CP0_Cause &= ~(1 << CP0Ca_BD);",
"}",
"env->CP0_Status |= (1 << CP0St_EXL);",
"env->hflags |= MIPS_HFLAG_64 | MIPS_HFLAG_CP0;",
"env->hflags &= ~(MIPS_HFLAG_KSU);",
"}",
"env->hflags &= ~MIPS_HFLAG_BMASK;",
"if (env->CP0_Status & (1 << CP0St_BEV)) {",
"env->active_tc.PC = (int32_t)0xBFC00200;",
"} else {",
"env->active_tc.PC = (int32_t)(env->CP0_EBase & ~0x3ff);",
"}",
"env->active_tc.PC += offset;",
"set_hflags_for_handler(env);",
"env->CP0_Cause = (env->CP0_Cause & ~(0x1f << CP0Ca_EC)) | (VAR_1 << CP0Ca_EC);",
"break;",
"default:\nqemu_log(\"Invalid MIPS exception %d. Exiting\\n\", VAR_0->exception_index);",
"printf(\"Invalid MIPS exception %d. Exiting\\n\", VAR_0->exception_index);",
"exit(1);",
"}",
"if (qemu_log_enabled() && VAR_0->exception_index != EXCP_EXT_INTERRUPT) {",
"qemu_log(\"%s: PC \" TARGET_FMT_lx \" EPC \" TARGET_FMT_lx \" VAR_1 %d\\n\"\n\" S %08x C %08x A \" TARGET_FMT_lx \" D \" TARGET_FMT_lx \"\\n\",\n__func__, env->active_tc.PC, env->CP0_EPC, VAR_1,\nenv->CP0_Status, env->CP0_Cause, env->CP0_BadVAddr,\nenv->CP0_DEPC);",
"}",
"#endif\nVAR_0->exception_index = EXCP_NONE;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
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
],
[
33,
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73,
75
],
[
77
],
[
79,
81
],
[
83
],
[
85,
87
],
[
89
],
[
91,
93
],
[
95,
97
],
[
99
],
[
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
],
[
173
],
[
175
],
[
177
],
[
181
],
[
185
],
[
187
],
[
191
],
[
195
],
[
197
],
[
201
],
[
203
],
[
205
],
[
207
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223,
225
],
[
227
],
[
229,
231
],
[
233
],
[
235,
237
],
[
239
],
[
241
],
[
243
],
[
247,
249,
251
],
[
253,
255,
257
],
[
259
],
[
261
],
[
263,
265
],
[
267
],
[
269,
271
],
[
273
],
[
275
],
[
277
],
[
281,
283,
285
],
[
287,
289,
291
],
[
293
],
[
295
],
[
297,
299
],
[
301
],
[
303,
305
],
[
307
],
[
309,
311
],
[
313
],
[
315,
317
],
[
319
],
[
321,
323
],
[
325
],
[
327,
329
],
[
331
],
[
333,
335
],
[
337
],
[
339,
341
],
[
343,
345
],
[
347
],
[
349,
351
],
[
353
],
[
355,
357
],
[
359
],
[
361,
363
],
[
365
],
[
367,
369
],
[
371
],
[
373,
375
],
[
377
],
[
379,
381
],
[
385
],
[
387,
389
],
[
391
],
[
393,
395
],
[
397
],
[
399,
401
],
[
403
],
[
405,
407
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419,
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
457
],
[
459
],
[
461
],
[
463,
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475,
477,
479,
481,
483
],
[
485
],
[
487,
489
],
[
491
]
] |
24,983 | void qmp_drive_mirror(const char *device, const char *target,
bool has_format, const char *format,
enum MirrorSyncMode sync,
bool has_mode, enum NewImageMode mode,
bool has_speed, int64_t speed,
bool has_granularity, uint32_t granularity,
bool has_buf_size, int64_t buf_size,
bool has_on_source_error, BlockdevOnError on_source_error,
bool has_on_target_error, BlockdevOnError on_target_error,
Error **errp)
{
BlockDriverState *bs;
BlockDriverState *source, *target_bs;
BlockDriver *drv = NULL;
Error *local_err = NULL;
int flags;
int64_t size;
int ret;
if (!has_speed) {
speed = 0;
}
if (!has_on_source_error) {
on_source_error = BLOCKDEV_ON_ERROR_REPORT;
}
if (!has_on_target_error) {
on_target_error = BLOCKDEV_ON_ERROR_REPORT;
}
if (!has_mode) {
mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
}
if (!has_granularity) {
granularity = 0;
}
if (!has_buf_size) {
buf_size = DEFAULT_MIRROR_BUF_SIZE;
}
if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) {
error_set(errp, QERR_INVALID_PARAMETER, device);
return;
}
if (granularity & (granularity - 1)) {
error_set(errp, QERR_INVALID_PARAMETER, device);
return;
}
bs = bdrv_find(device);
if (!bs) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return;
}
if (!bdrv_is_inserted(bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return;
}
if (!has_format) {
format = mode == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name;
}
if (format) {
drv = bdrv_find_format(format);
if (!drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
return;
}
}
if (bdrv_in_use(bs)) {
error_set(errp, QERR_DEVICE_IN_USE, device);
return;
}
flags = bs->open_flags | BDRV_O_RDWR;
source = bs->backing_hd;
if (!source && sync == MIRROR_SYNC_MODE_TOP) {
sync = MIRROR_SYNC_MODE_FULL;
}
size = bdrv_getlength(bs);
if (size < 0) {
error_setg_errno(errp, -size, "bdrv_getlength failed");
return;
}
if (sync == MIRROR_SYNC_MODE_FULL && mode != NEW_IMAGE_MODE_EXISTING) {
/* create new image w/o backing file */
assert(format && drv);
bdrv_img_create(target, format,
NULL, NULL, NULL, size, flags, &local_err, false);
} else {
switch (mode) {
case NEW_IMAGE_MODE_EXISTING:
break;
case NEW_IMAGE_MODE_ABSOLUTE_PATHS:
/* create new image with backing file */
bdrv_img_create(target, format,
source->filename,
source->drv->format_name,
NULL, size, flags, &local_err, false);
break;
default:
abort();
}
}
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
return;
}
/* Mirroring takes care of copy-on-write using the source's backing
* file.
*/
target_bs = bdrv_new("");
ret = bdrv_open(target_bs, target, NULL, flags | BDRV_O_NO_BACKING, drv,
&local_err);
if (ret < 0) {
bdrv_unref(target_bs);
error_propagate(errp, local_err);
return;
}
mirror_start(bs, target_bs, speed, granularity, buf_size, sync,
on_source_error, on_target_error,
block_job_cb, bs, &local_err);
if (local_err != NULL) {
bdrv_unref(target_bs);
error_propagate(errp, local_err);
return;
}
}
| true | qemu | 1452686495922b81d6cf43edf025c1aef15965c0 | void qmp_drive_mirror(const char *device, const char *target,
bool has_format, const char *format,
enum MirrorSyncMode sync,
bool has_mode, enum NewImageMode mode,
bool has_speed, int64_t speed,
bool has_granularity, uint32_t granularity,
bool has_buf_size, int64_t buf_size,
bool has_on_source_error, BlockdevOnError on_source_error,
bool has_on_target_error, BlockdevOnError on_target_error,
Error **errp)
{
BlockDriverState *bs;
BlockDriverState *source, *target_bs;
BlockDriver *drv = NULL;
Error *local_err = NULL;
int flags;
int64_t size;
int ret;
if (!has_speed) {
speed = 0;
}
if (!has_on_source_error) {
on_source_error = BLOCKDEV_ON_ERROR_REPORT;
}
if (!has_on_target_error) {
on_target_error = BLOCKDEV_ON_ERROR_REPORT;
}
if (!has_mode) {
mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
}
if (!has_granularity) {
granularity = 0;
}
if (!has_buf_size) {
buf_size = DEFAULT_MIRROR_BUF_SIZE;
}
if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) {
error_set(errp, QERR_INVALID_PARAMETER, device);
return;
}
if (granularity & (granularity - 1)) {
error_set(errp, QERR_INVALID_PARAMETER, device);
return;
}
bs = bdrv_find(device);
if (!bs) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return;
}
if (!bdrv_is_inserted(bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return;
}
if (!has_format) {
format = mode == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name;
}
if (format) {
drv = bdrv_find_format(format);
if (!drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
return;
}
}
if (bdrv_in_use(bs)) {
error_set(errp, QERR_DEVICE_IN_USE, device);
return;
}
flags = bs->open_flags | BDRV_O_RDWR;
source = bs->backing_hd;
if (!source && sync == MIRROR_SYNC_MODE_TOP) {
sync = MIRROR_SYNC_MODE_FULL;
}
size = bdrv_getlength(bs);
if (size < 0) {
error_setg_errno(errp, -size, "bdrv_getlength failed");
return;
}
if (sync == MIRROR_SYNC_MODE_FULL && mode != NEW_IMAGE_MODE_EXISTING) {
assert(format && drv);
bdrv_img_create(target, format,
NULL, NULL, NULL, size, flags, &local_err, false);
} else {
switch (mode) {
case NEW_IMAGE_MODE_EXISTING:
break;
case NEW_IMAGE_MODE_ABSOLUTE_PATHS:
bdrv_img_create(target, format,
source->filename,
source->drv->format_name,
NULL, size, flags, &local_err, false);
break;
default:
abort();
}
}
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
return;
}
target_bs = bdrv_new("");
ret = bdrv_open(target_bs, target, NULL, flags | BDRV_O_NO_BACKING, drv,
&local_err);
if (ret < 0) {
bdrv_unref(target_bs);
error_propagate(errp, local_err);
return;
}
mirror_start(bs, target_bs, speed, granularity, buf_size, sync,
on_source_error, on_target_error,
block_job_cb, bs, &local_err);
if (local_err != NULL) {
bdrv_unref(target_bs);
error_propagate(errp, local_err);
return;
}
}
| {
"code": [
" if (sync == MIRROR_SYNC_MODE_FULL && mode != NEW_IMAGE_MODE_EXISTING) {"
],
"line_no": [
173
]
} | void FUNC_0(const char *VAR_0, const char *VAR_1,
bool VAR_2, const char *VAR_3,
enum MirrorSyncMode VAR_4,
bool VAR_5, enum NewImageMode VAR_6,
bool VAR_7, int64_t VAR_8,
bool VAR_9, uint32_t VAR_10,
bool VAR_11, int64_t VAR_12,
bool VAR_13, BlockdevOnError VAR_14,
bool VAR_15, BlockdevOnError VAR_16,
Error **VAR_17)
{
BlockDriverState *bs;
BlockDriverState *source, *target_bs;
BlockDriver *drv = NULL;
Error *local_err = NULL;
int VAR_18;
int64_t size;
int VAR_19;
if (!VAR_7) {
VAR_8 = 0;
}
if (!VAR_13) {
VAR_14 = BLOCKDEV_ON_ERROR_REPORT;
}
if (!VAR_15) {
VAR_16 = BLOCKDEV_ON_ERROR_REPORT;
}
if (!VAR_5) {
VAR_6 = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
}
if (!VAR_9) {
VAR_10 = 0;
}
if (!VAR_11) {
VAR_12 = DEFAULT_MIRROR_BUF_SIZE;
}
if (VAR_10 != 0 && (VAR_10 < 512 || VAR_10 > 1048576 * 64)) {
error_set(VAR_17, QERR_INVALID_PARAMETER, VAR_0);
return;
}
if (VAR_10 & (VAR_10 - 1)) {
error_set(VAR_17, QERR_INVALID_PARAMETER, VAR_0);
return;
}
bs = bdrv_find(VAR_0);
if (!bs) {
error_set(VAR_17, QERR_DEVICE_NOT_FOUND, VAR_0);
return;
}
if (!bdrv_is_inserted(bs)) {
error_set(VAR_17, QERR_DEVICE_HAS_NO_MEDIUM, VAR_0);
return;
}
if (!VAR_2) {
VAR_3 = VAR_6 == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name;
}
if (VAR_3) {
drv = bdrv_find_format(VAR_3);
if (!drv) {
error_set(VAR_17, QERR_INVALID_BLOCK_FORMAT, VAR_3);
return;
}
}
if (bdrv_in_use(bs)) {
error_set(VAR_17, QERR_DEVICE_IN_USE, VAR_0);
return;
}
VAR_18 = bs->open_flags | BDRV_O_RDWR;
source = bs->backing_hd;
if (!source && VAR_4 == MIRROR_SYNC_MODE_TOP) {
VAR_4 = MIRROR_SYNC_MODE_FULL;
}
size = bdrv_getlength(bs);
if (size < 0) {
error_setg_errno(VAR_17, -size, "bdrv_getlength failed");
return;
}
if (VAR_4 == MIRROR_SYNC_MODE_FULL && VAR_6 != NEW_IMAGE_MODE_EXISTING) {
assert(VAR_3 && drv);
bdrv_img_create(VAR_1, VAR_3,
NULL, NULL, NULL, size, VAR_18, &local_err, false);
} else {
switch (VAR_6) {
case NEW_IMAGE_MODE_EXISTING:
break;
case NEW_IMAGE_MODE_ABSOLUTE_PATHS:
bdrv_img_create(VAR_1, VAR_3,
source->filename,
source->drv->format_name,
NULL, size, VAR_18, &local_err, false);
break;
default:
abort();
}
}
if (error_is_set(&local_err)) {
error_propagate(VAR_17, local_err);
return;
}
target_bs = bdrv_new("");
VAR_19 = bdrv_open(target_bs, VAR_1, NULL, VAR_18 | BDRV_O_NO_BACKING, drv,
&local_err);
if (VAR_19 < 0) {
bdrv_unref(target_bs);
error_propagate(VAR_17, local_err);
return;
}
mirror_start(bs, target_bs, VAR_8, VAR_10, VAR_12, VAR_4,
VAR_14, VAR_16,
block_job_cb, bs, &local_err);
if (local_err != NULL) {
bdrv_unref(target_bs);
error_propagate(VAR_17, local_err);
return;
}
}
| [
"void FUNC_0(const char *VAR_0, const char *VAR_1,\nbool VAR_2, const char *VAR_3,\nenum MirrorSyncMode VAR_4,\nbool VAR_5, enum NewImageMode VAR_6,\nbool VAR_7, int64_t VAR_8,\nbool VAR_9, uint32_t VAR_10,\nbool VAR_11, int64_t VAR_12,\nbool VAR_13, BlockdevOnError VAR_14,\nbool VAR_15, BlockdevOnError VAR_16,\nError **VAR_17)\n{",
"BlockDriverState *bs;",
"BlockDriverState *source, *target_bs;",
"BlockDriver *drv = NULL;",
"Error *local_err = NULL;",
"int VAR_18;",
"int64_t size;",
"int VAR_19;",
"if (!VAR_7) {",
"VAR_8 = 0;",
"}",
"if (!VAR_13) {",
"VAR_14 = BLOCKDEV_ON_ERROR_REPORT;",
"}",
"if (!VAR_15) {",
"VAR_16 = BLOCKDEV_ON_ERROR_REPORT;",
"}",
"if (!VAR_5) {",
"VAR_6 = NEW_IMAGE_MODE_ABSOLUTE_PATHS;",
"}",
"if (!VAR_9) {",
"VAR_10 = 0;",
"}",
"if (!VAR_11) {",
"VAR_12 = DEFAULT_MIRROR_BUF_SIZE;",
"}",
"if (VAR_10 != 0 && (VAR_10 < 512 || VAR_10 > 1048576 * 64)) {",
"error_set(VAR_17, QERR_INVALID_PARAMETER, VAR_0);",
"return;",
"}",
"if (VAR_10 & (VAR_10 - 1)) {",
"error_set(VAR_17, QERR_INVALID_PARAMETER, VAR_0);",
"return;",
"}",
"bs = bdrv_find(VAR_0);",
"if (!bs) {",
"error_set(VAR_17, QERR_DEVICE_NOT_FOUND, VAR_0);",
"return;",
"}",
"if (!bdrv_is_inserted(bs)) {",
"error_set(VAR_17, QERR_DEVICE_HAS_NO_MEDIUM, VAR_0);",
"return;",
"}",
"if (!VAR_2) {",
"VAR_3 = VAR_6 == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name;",
"}",
"if (VAR_3) {",
"drv = bdrv_find_format(VAR_3);",
"if (!drv) {",
"error_set(VAR_17, QERR_INVALID_BLOCK_FORMAT, VAR_3);",
"return;",
"}",
"}",
"if (bdrv_in_use(bs)) {",
"error_set(VAR_17, QERR_DEVICE_IN_USE, VAR_0);",
"return;",
"}",
"VAR_18 = bs->open_flags | BDRV_O_RDWR;",
"source = bs->backing_hd;",
"if (!source && VAR_4 == MIRROR_SYNC_MODE_TOP) {",
"VAR_4 = MIRROR_SYNC_MODE_FULL;",
"}",
"size = bdrv_getlength(bs);",
"if (size < 0) {",
"error_setg_errno(VAR_17, -size, \"bdrv_getlength failed\");",
"return;",
"}",
"if (VAR_4 == MIRROR_SYNC_MODE_FULL && VAR_6 != NEW_IMAGE_MODE_EXISTING) {",
"assert(VAR_3 && drv);",
"bdrv_img_create(VAR_1, VAR_3,\nNULL, NULL, NULL, size, VAR_18, &local_err, false);",
"} else {",
"switch (VAR_6) {",
"case NEW_IMAGE_MODE_EXISTING:\nbreak;",
"case NEW_IMAGE_MODE_ABSOLUTE_PATHS:\nbdrv_img_create(VAR_1, VAR_3,\nsource->filename,\nsource->drv->format_name,\nNULL, size, VAR_18, &local_err, false);",
"break;",
"default:\nabort();",
"}",
"}",
"if (error_is_set(&local_err)) {",
"error_propagate(VAR_17, local_err);",
"return;",
"}",
"target_bs = bdrv_new(\"\");",
"VAR_19 = bdrv_open(target_bs, VAR_1, NULL, VAR_18 | BDRV_O_NO_BACKING, drv,\n&local_err);",
"if (VAR_19 < 0) {",
"bdrv_unref(target_bs);",
"error_propagate(VAR_17, local_err);",
"return;",
"}",
"mirror_start(bs, target_bs, VAR_8, VAR_10, VAR_12, VAR_4,\nVAR_14, VAR_16,\nblock_job_cb, bs, &local_err);",
"if (local_err != NULL) {",
"bdrv_unref(target_bs);",
"error_propagate(VAR_17, local_err);",
"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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13,
15,
17,
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173
],
[
177
],
[
179,
181
],
[
183
],
[
185
],
[
187,
189
],
[
191,
195,
197,
199,
201
],
[
203
],
[
205,
207
],
[
209
],
[
211
],
[
215
],
[
217
],
[
219
],
[
221
],
[
231
],
[
233,
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
249,
251,
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
]
] |
24,984 | static void opt_frame_aspect_ratio(const char *arg)
{
int x = 0, y = 0;
double ar = 0;
const char *p;
char *end;
p = strchr(arg, ':');
if (p) {
x = strtol(arg, &end, 10);
if (end == p)
y = strtol(end+1, &end, 10);
if (x > 0 && y > 0)
ar = (double)x / (double)y;
} else
ar = strtod(arg, NULL);
if (!ar) {
fprintf(stderr, "Incorrect aspect ratio specification.\n");
ffmpeg_exit(1);
}
frame_aspect_ratio = ar;
x = vfilters ? strlen(vfilters) : 0;
vfilters = av_realloc(vfilters, x+100);
snprintf(vfilters+x, x+100, "%csetdar=%f\n", x?',':' ', ar);
}
| true | FFmpeg | 0886267e3cc4ce12bcd48b712d8affa8c953bc38 | static void opt_frame_aspect_ratio(const char *arg)
{
int x = 0, y = 0;
double ar = 0;
const char *p;
char *end;
p = strchr(arg, ':');
if (p) {
x = strtol(arg, &end, 10);
if (end == p)
y = strtol(end+1, &end, 10);
if (x > 0 && y > 0)
ar = (double)x / (double)y;
} else
ar = strtod(arg, NULL);
if (!ar) {
fprintf(stderr, "Incorrect aspect ratio specification.\n");
ffmpeg_exit(1);
}
frame_aspect_ratio = ar;
x = vfilters ? strlen(vfilters) : 0;
vfilters = av_realloc(vfilters, x+100);
snprintf(vfilters+x, x+100, "%csetdar=%f\n", x?',':' ', ar);
}
| {
"code": [
" x = vfilters ? strlen(vfilters) : 0;",
" vfilters = av_realloc(vfilters, x+100);",
" snprintf(vfilters+x, x+100, \"%csetdar=%f\\n\", x?',':' ', ar);"
],
"line_no": [
47,
49,
51
]
} | static void FUNC_0(const char *VAR_0)
{
int VAR_1 = 0, VAR_2 = 0;
double VAR_3 = 0;
const char *VAR_4;
char *VAR_5;
VAR_4 = strchr(VAR_0, ':');
if (VAR_4) {
VAR_1 = strtol(VAR_0, &VAR_5, 10);
if (VAR_5 == VAR_4)
VAR_2 = strtol(VAR_5+1, &VAR_5, 10);
if (VAR_1 > 0 && VAR_2 > 0)
VAR_3 = (double)VAR_1 / (double)VAR_2;
} else
VAR_3 = strtod(VAR_0, NULL);
if (!VAR_3) {
fprintf(stderr, "Incorrect aspect ratio specification.\n");
ffmpeg_exit(1);
}
frame_aspect_ratio = VAR_3;
VAR_1 = vfilters ? strlen(vfilters) : 0;
vfilters = av_realloc(vfilters, VAR_1+100);
snprintf(vfilters+VAR_1, VAR_1+100, "%csetdar=%f\n", VAR_1?',':' ', VAR_3);
}
| [
"static void FUNC_0(const char *VAR_0)\n{",
"int VAR_1 = 0, VAR_2 = 0;",
"double VAR_3 = 0;",
"const char *VAR_4;",
"char *VAR_5;",
"VAR_4 = strchr(VAR_0, ':');",
"if (VAR_4) {",
"VAR_1 = strtol(VAR_0, &VAR_5, 10);",
"if (VAR_5 == VAR_4)\nVAR_2 = strtol(VAR_5+1, &VAR_5, 10);",
"if (VAR_1 > 0 && VAR_2 > 0)\nVAR_3 = (double)VAR_1 / (double)VAR_2;",
"} else",
"VAR_3 = strtod(VAR_0, NULL);",
"if (!VAR_3) {",
"fprintf(stderr, \"Incorrect aspect ratio specification.\\n\");",
"ffmpeg_exit(1);",
"}",
"frame_aspect_ratio = VAR_3;",
"VAR_1 = vfilters ? strlen(vfilters) : 0;",
"vfilters = av_realloc(vfilters, VAR_1+100);",
"snprintf(vfilters+VAR_1, VAR_1+100, \"%csetdar=%f\\n\", VAR_1?',':' ', VAR_3);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25,
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
]
] |
24,986 | static int tcp_write(URLContext *h, uint8_t *buf, int size)
{
TCPContext *s = h->priv_data;
int ret, size1, fd_max;
fd_set wfds;
struct timeval tv;
size1 = size;
while (size > 0) {
if (url_interrupt_cb())
return -EINTR;
fd_max = s->fd;
FD_ZERO(&wfds);
FD_SET(s->fd, &wfds);
tv.tv_sec = 0;
tv.tv_usec = 100 * 1000;
select(fd_max + 1, NULL, &wfds, NULL, &tv);
#ifdef __BEOS__
ret = send(s->fd, buf, size, 0);
#else
ret = write(s->fd, buf, size);
#endif
if (ret < 0) {
if (errno != EINTR && errno != EAGAIN) {
#ifdef __BEOS__
return errno;
#else
return -errno;
#endif
}
continue;
}
size -= ret;
buf += ret;
}
return size1 - size;
}
| false | FFmpeg | b51469a0c54b30079eecc4891cc050778f343683 | static int tcp_write(URLContext *h, uint8_t *buf, int size)
{
TCPContext *s = h->priv_data;
int ret, size1, fd_max;
fd_set wfds;
struct timeval tv;
size1 = size;
while (size > 0) {
if (url_interrupt_cb())
return -EINTR;
fd_max = s->fd;
FD_ZERO(&wfds);
FD_SET(s->fd, &wfds);
tv.tv_sec = 0;
tv.tv_usec = 100 * 1000;
select(fd_max + 1, NULL, &wfds, NULL, &tv);
#ifdef __BEOS__
ret = send(s->fd, buf, size, 0);
#else
ret = write(s->fd, buf, size);
#endif
if (ret < 0) {
if (errno != EINTR && errno != EAGAIN) {
#ifdef __BEOS__
return errno;
#else
return -errno;
#endif
}
continue;
}
size -= ret;
buf += ret;
}
return size1 - size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(URLContext *VAR_0, uint8_t *VAR_1, int VAR_2)
{
TCPContext *s = VAR_0->priv_data;
int VAR_3, VAR_4, VAR_5;
fd_set wfds;
struct timeval VAR_6;
VAR_4 = VAR_2;
while (VAR_2 > 0) {
if (url_interrupt_cb())
return -EINTR;
VAR_5 = s->fd;
FD_ZERO(&wfds);
FD_SET(s->fd, &wfds);
VAR_6.tv_sec = 0;
VAR_6.tv_usec = 100 * 1000;
select(VAR_5 + 1, NULL, &wfds, NULL, &VAR_6);
#ifdef __BEOS__
VAR_3 = send(s->fd, VAR_1, VAR_2, 0);
#else
VAR_3 = write(s->fd, VAR_1, VAR_2);
#endif
if (VAR_3 < 0) {
if (errno != EINTR && errno != EAGAIN) {
#ifdef __BEOS__
return errno;
#else
return -errno;
#endif
}
continue;
}
VAR_2 -= VAR_3;
VAR_1 += VAR_3;
}
return VAR_4 - VAR_2;
}
| [
"static int FUNC_0(URLContext *VAR_0, uint8_t *VAR_1, int VAR_2)\n{",
"TCPContext *s = VAR_0->priv_data;",
"int VAR_3, VAR_4, VAR_5;",
"fd_set wfds;",
"struct timeval VAR_6;",
"VAR_4 = VAR_2;",
"while (VAR_2 > 0) {",
"if (url_interrupt_cb())\nreturn -EINTR;",
"VAR_5 = s->fd;",
"FD_ZERO(&wfds);",
"FD_SET(s->fd, &wfds);",
"VAR_6.tv_sec = 0;",
"VAR_6.tv_usec = 100 * 1000;",
"select(VAR_5 + 1, NULL, &wfds, NULL, &VAR_6);",
"#ifdef __BEOS__\nVAR_3 = send(s->fd, VAR_1, VAR_2, 0);",
"#else\nVAR_3 = write(s->fd, VAR_1, VAR_2);",
"#endif\nif (VAR_3 < 0) {",
"if (errno != EINTR && errno != EAGAIN) {",
"#ifdef __BEOS__\nreturn errno;",
"#else\nreturn -errno;",
"#endif\n}",
"continue;",
"}",
"VAR_2 -= VAR_3;",
"VAR_1 += VAR_3;",
"}",
"return VAR_4 - VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
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
]
] |
24,987 | static void glfs_clear_preopened(glfs_t *fs)
{
ListElement *entry = NULL;
if (fs == NULL) {
return;
}
QLIST_FOREACH(entry, &glfs_list, list) {
if (entry->saved.fs == fs) {
if (--entry->saved.ref) {
return;
}
QLIST_REMOVE(entry, list);
glfs_fini(entry->saved.fs);
g_free(entry->saved.volume);
g_free(entry);
}
}
}
| true | qemu | 668c0e441d761a79f33eae11c120e01a29f9d4dd | static void glfs_clear_preopened(glfs_t *fs)
{
ListElement *entry = NULL;
if (fs == NULL) {
return;
}
QLIST_FOREACH(entry, &glfs_list, list) {
if (entry->saved.fs == fs) {
if (--entry->saved.ref) {
return;
}
QLIST_REMOVE(entry, list);
glfs_fini(entry->saved.fs);
g_free(entry->saved.volume);
g_free(entry);
}
}
}
| {
"code": [
" QLIST_FOREACH(entry, &glfs_list, list) {"
],
"line_no": [
17
]
} | static void FUNC_0(glfs_t *VAR_0)
{
ListElement *entry = NULL;
if (VAR_0 == NULL) {
return;
}
QLIST_FOREACH(entry, &glfs_list, list) {
if (entry->saved.VAR_0 == VAR_0) {
if (--entry->saved.ref) {
return;
}
QLIST_REMOVE(entry, list);
glfs_fini(entry->saved.VAR_0);
g_free(entry->saved.volume);
g_free(entry);
}
}
}
| [
"static void FUNC_0(glfs_t *VAR_0)\n{",
"ListElement *entry = NULL;",
"if (VAR_0 == NULL) {",
"return;",
"}",
"QLIST_FOREACH(entry, &glfs_list, list) {",
"if (entry->saved.VAR_0 == VAR_0) {",
"if (--entry->saved.ref) {",
"return;",
"}",
"QLIST_REMOVE(entry, list);",
"glfs_fini(entry->saved.VAR_0);",
"g_free(entry->saved.volume);",
"g_free(entry);",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
]
] |
24,988 | static av_cold int mm_decode_init(AVCodecContext *avctx)
{
MmContext *s = avctx->priv_data;
s->avctx = avctx;
avctx->pix_fmt = AV_PIX_FMT_PAL8;
s->frame = av_frame_alloc();
if (!s->frame)
return AVERROR(ENOMEM);
return 0; | true | FFmpeg | 17ba719d9ba30c970f65747f42d5fbb1e447ca28 | static av_cold int mm_decode_init(AVCodecContext *avctx)
{
MmContext *s = avctx->priv_data;
s->avctx = avctx;
avctx->pix_fmt = AV_PIX_FMT_PAL8;
s->frame = av_frame_alloc();
if (!s->frame)
return AVERROR(ENOMEM);
return 0; | {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
MmContext *s = avctx->priv_data;
s->avctx = avctx;
avctx->pix_fmt = AV_PIX_FMT_PAL8;
s->frame = av_frame_alloc();
if (!s->frame)
return AVERROR(ENOMEM);
return 0; | [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"MmContext *s = avctx->priv_data;",
"s->avctx = avctx;",
"avctx->pix_fmt = AV_PIX_FMT_PAL8;",
"s->frame = av_frame_alloc();",
"if (!s->frame)\nreturn AVERROR(ENOMEM);",
"return 0;"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7,
8
],
[
9
]
] |
24,989 | static void uhci_process_frame(UHCIState *s)
{
uint32_t frame_addr, link, old_td_ctrl, val, int_mask;
uint32_t curr_qh, td_count = 0;
int cnt, ret;
UHCI_TD td;
UHCI_QH qh;
QhDb qhdb;
frame_addr = s->fl_base_addr + ((s->frnum & 0x3ff) << 2);
pci_dma_read(&s->dev, frame_addr, &link, 4);
le32_to_cpus(&link);
int_mask = 0;
curr_qh = 0;
qhdb_reset(&qhdb);
for (cnt = FRAME_MAX_LOOPS; is_valid(link) && cnt; cnt--) {
if (s->frame_bytes >= s->frame_bandwidth) {
/* We've reached the usb 1.1 bandwidth, which is
1280 bytes/frame, stop processing */
trace_usb_uhci_frame_stop_bandwidth();
break;
}
if (is_qh(link)) {
/* QH */
trace_usb_uhci_qh_load(link & ~0xf);
if (qhdb_insert(&qhdb, link)) {
/*
* We're going in circles. Which is not a bug because
* HCD is allowed to do that as part of the BW management.
*
* Stop processing here if no transaction has been done
* since we've been here last time.
*/
if (td_count == 0) {
trace_usb_uhci_frame_loop_stop_idle();
break;
} else {
trace_usb_uhci_frame_loop_continue();
td_count = 0;
qhdb_reset(&qhdb);
qhdb_insert(&qhdb, link);
}
}
pci_dma_read(&s->dev, link & ~0xf, &qh, sizeof(qh));
le32_to_cpus(&qh.link);
le32_to_cpus(&qh.el_link);
if (!is_valid(qh.el_link)) {
/* QH w/o elements */
curr_qh = 0;
link = qh.link;
} else {
/* QH with elements */
curr_qh = link;
link = qh.el_link;
}
continue;
}
/* TD */
uhci_read_td(s, &td, link);
trace_usb_uhci_td_load(curr_qh & ~0xf, link & ~0xf, td.ctrl, td.token);
old_td_ctrl = td.ctrl;
ret = uhci_handle_td(s, NULL, &td, link, &int_mask);
if (old_td_ctrl != td.ctrl) {
/* update the status bits of the TD */
val = cpu_to_le32(td.ctrl);
pci_dma_write(&s->dev, (link & ~0xf) + 4, &val, sizeof(val));
}
switch (ret) {
case TD_RESULT_STOP_FRAME: /* interrupted frame */
goto out;
case TD_RESULT_NEXT_QH:
case TD_RESULT_ASYNC_CONT:
trace_usb_uhci_td_nextqh(curr_qh & ~0xf, link & ~0xf);
link = curr_qh ? qh.link : td.link;
continue;
case TD_RESULT_ASYNC_START:
trace_usb_uhci_td_async(curr_qh & ~0xf, link & ~0xf);
link = curr_qh ? qh.link : td.link;
continue;
case TD_RESULT_COMPLETE:
trace_usb_uhci_td_complete(curr_qh & ~0xf, link & ~0xf);
link = td.link;
td_count++;
s->frame_bytes += (td.ctrl & 0x7ff) + 1;
if (curr_qh) {
/* update QH element link */
qh.el_link = link;
val = cpu_to_le32(qh.el_link);
pci_dma_write(&s->dev, (curr_qh & ~0xf) + 4, &val, sizeof(val));
if (!depth_first(link)) {
/* done with this QH */
curr_qh = 0;
link = qh.link;
}
}
break;
default:
assert(!"unknown return code");
}
/* go to the next entry */
}
out:
s->pending_int_mask |= int_mask;
}
| true | qemu | 66a08cbe6ad1aebec8eecf58b3ba042e19dd1649 | static void uhci_process_frame(UHCIState *s)
{
uint32_t frame_addr, link, old_td_ctrl, val, int_mask;
uint32_t curr_qh, td_count = 0;
int cnt, ret;
UHCI_TD td;
UHCI_QH qh;
QhDb qhdb;
frame_addr = s->fl_base_addr + ((s->frnum & 0x3ff) << 2);
pci_dma_read(&s->dev, frame_addr, &link, 4);
le32_to_cpus(&link);
int_mask = 0;
curr_qh = 0;
qhdb_reset(&qhdb);
for (cnt = FRAME_MAX_LOOPS; is_valid(link) && cnt; cnt--) {
if (s->frame_bytes >= s->frame_bandwidth) {
trace_usb_uhci_frame_stop_bandwidth();
break;
}
if (is_qh(link)) {
trace_usb_uhci_qh_load(link & ~0xf);
if (qhdb_insert(&qhdb, link)) {
if (td_count == 0) {
trace_usb_uhci_frame_loop_stop_idle();
break;
} else {
trace_usb_uhci_frame_loop_continue();
td_count = 0;
qhdb_reset(&qhdb);
qhdb_insert(&qhdb, link);
}
}
pci_dma_read(&s->dev, link & ~0xf, &qh, sizeof(qh));
le32_to_cpus(&qh.link);
le32_to_cpus(&qh.el_link);
if (!is_valid(qh.el_link)) {
curr_qh = 0;
link = qh.link;
} else {
curr_qh = link;
link = qh.el_link;
}
continue;
}
uhci_read_td(s, &td, link);
trace_usb_uhci_td_load(curr_qh & ~0xf, link & ~0xf, td.ctrl, td.token);
old_td_ctrl = td.ctrl;
ret = uhci_handle_td(s, NULL, &td, link, &int_mask);
if (old_td_ctrl != td.ctrl) {
val = cpu_to_le32(td.ctrl);
pci_dma_write(&s->dev, (link & ~0xf) + 4, &val, sizeof(val));
}
switch (ret) {
case TD_RESULT_STOP_FRAME:
goto out;
case TD_RESULT_NEXT_QH:
case TD_RESULT_ASYNC_CONT:
trace_usb_uhci_td_nextqh(curr_qh & ~0xf, link & ~0xf);
link = curr_qh ? qh.link : td.link;
continue;
case TD_RESULT_ASYNC_START:
trace_usb_uhci_td_async(curr_qh & ~0xf, link & ~0xf);
link = curr_qh ? qh.link : td.link;
continue;
case TD_RESULT_COMPLETE:
trace_usb_uhci_td_complete(curr_qh & ~0xf, link & ~0xf);
link = td.link;
td_count++;
s->frame_bytes += (td.ctrl & 0x7ff) + 1;
if (curr_qh) {
qh.el_link = link;
val = cpu_to_le32(qh.el_link);
pci_dma_write(&s->dev, (curr_qh & ~0xf) + 4, &val, sizeof(val));
if (!depth_first(link)) {
curr_qh = 0;
link = qh.link;
}
}
break;
default:
assert(!"unknown return code");
}
}
out:
s->pending_int_mask |= int_mask;
}
| {
"code": [
" ret = uhci_handle_td(s, NULL, &td, link, &int_mask);"
],
"line_no": [
141
]
} | static void FUNC_0(UHCIState *VAR_0)
{
uint32_t frame_addr, link, old_td_ctrl, val, int_mask;
uint32_t curr_qh, td_count = 0;
int VAR_1, VAR_2;
UHCI_TD td;
UHCI_QH qh;
QhDb qhdb;
frame_addr = VAR_0->fl_base_addr + ((VAR_0->frnum & 0x3ff) << 2);
pci_dma_read(&VAR_0->dev, frame_addr, &link, 4);
le32_to_cpus(&link);
int_mask = 0;
curr_qh = 0;
qhdb_reset(&qhdb);
for (VAR_1 = FRAME_MAX_LOOPS; is_valid(link) && VAR_1; VAR_1--) {
if (VAR_0->frame_bytes >= VAR_0->frame_bandwidth) {
trace_usb_uhci_frame_stop_bandwidth();
break;
}
if (is_qh(link)) {
trace_usb_uhci_qh_load(link & ~0xf);
if (qhdb_insert(&qhdb, link)) {
if (td_count == 0) {
trace_usb_uhci_frame_loop_stop_idle();
break;
} else {
trace_usb_uhci_frame_loop_continue();
td_count = 0;
qhdb_reset(&qhdb);
qhdb_insert(&qhdb, link);
}
}
pci_dma_read(&VAR_0->dev, link & ~0xf, &qh, sizeof(qh));
le32_to_cpus(&qh.link);
le32_to_cpus(&qh.el_link);
if (!is_valid(qh.el_link)) {
curr_qh = 0;
link = qh.link;
} else {
curr_qh = link;
link = qh.el_link;
}
continue;
}
uhci_read_td(VAR_0, &td, link);
trace_usb_uhci_td_load(curr_qh & ~0xf, link & ~0xf, td.ctrl, td.token);
old_td_ctrl = td.ctrl;
VAR_2 = uhci_handle_td(VAR_0, NULL, &td, link, &int_mask);
if (old_td_ctrl != td.ctrl) {
val = cpu_to_le32(td.ctrl);
pci_dma_write(&VAR_0->dev, (link & ~0xf) + 4, &val, sizeof(val));
}
switch (VAR_2) {
case TD_RESULT_STOP_FRAME:
goto out;
case TD_RESULT_NEXT_QH:
case TD_RESULT_ASYNC_CONT:
trace_usb_uhci_td_nextqh(curr_qh & ~0xf, link & ~0xf);
link = curr_qh ? qh.link : td.link;
continue;
case TD_RESULT_ASYNC_START:
trace_usb_uhci_td_async(curr_qh & ~0xf, link & ~0xf);
link = curr_qh ? qh.link : td.link;
continue;
case TD_RESULT_COMPLETE:
trace_usb_uhci_td_complete(curr_qh & ~0xf, link & ~0xf);
link = td.link;
td_count++;
VAR_0->frame_bytes += (td.ctrl & 0x7ff) + 1;
if (curr_qh) {
qh.el_link = link;
val = cpu_to_le32(qh.el_link);
pci_dma_write(&VAR_0->dev, (curr_qh & ~0xf) + 4, &val, sizeof(val));
if (!depth_first(link)) {
curr_qh = 0;
link = qh.link;
}
}
break;
default:
assert(!"unknown return code");
}
}
out:
VAR_0->pending_int_mask |= int_mask;
}
| [
"static void FUNC_0(UHCIState *VAR_0)\n{",
"uint32_t frame_addr, link, old_td_ctrl, val, int_mask;",
"uint32_t curr_qh, td_count = 0;",
"int VAR_1, VAR_2;",
"UHCI_TD td;",
"UHCI_QH qh;",
"QhDb qhdb;",
"frame_addr = VAR_0->fl_base_addr + ((VAR_0->frnum & 0x3ff) << 2);",
"pci_dma_read(&VAR_0->dev, frame_addr, &link, 4);",
"le32_to_cpus(&link);",
"int_mask = 0;",
"curr_qh = 0;",
"qhdb_reset(&qhdb);",
"for (VAR_1 = FRAME_MAX_LOOPS; is_valid(link) && VAR_1; VAR_1--) {",
"if (VAR_0->frame_bytes >= VAR_0->frame_bandwidth) {",
"trace_usb_uhci_frame_stop_bandwidth();",
"break;",
"}",
"if (is_qh(link)) {",
"trace_usb_uhci_qh_load(link & ~0xf);",
"if (qhdb_insert(&qhdb, link)) {",
"if (td_count == 0) {",
"trace_usb_uhci_frame_loop_stop_idle();",
"break;",
"} else {",
"trace_usb_uhci_frame_loop_continue();",
"td_count = 0;",
"qhdb_reset(&qhdb);",
"qhdb_insert(&qhdb, link);",
"}",
"}",
"pci_dma_read(&VAR_0->dev, link & ~0xf, &qh, sizeof(qh));",
"le32_to_cpus(&qh.link);",
"le32_to_cpus(&qh.el_link);",
"if (!is_valid(qh.el_link)) {",
"curr_qh = 0;",
"link = qh.link;",
"} else {",
"curr_qh = link;",
"link = qh.el_link;",
"}",
"continue;",
"}",
"uhci_read_td(VAR_0, &td, link);",
"trace_usb_uhci_td_load(curr_qh & ~0xf, link & ~0xf, td.ctrl, td.token);",
"old_td_ctrl = td.ctrl;",
"VAR_2 = uhci_handle_td(VAR_0, NULL, &td, link, &int_mask);",
"if (old_td_ctrl != td.ctrl) {",
"val = cpu_to_le32(td.ctrl);",
"pci_dma_write(&VAR_0->dev, (link & ~0xf) + 4, &val, sizeof(val));",
"}",
"switch (VAR_2) {",
"case TD_RESULT_STOP_FRAME:\ngoto out;",
"case TD_RESULT_NEXT_QH:\ncase TD_RESULT_ASYNC_CONT:\ntrace_usb_uhci_td_nextqh(curr_qh & ~0xf, link & ~0xf);",
"link = curr_qh ? qh.link : td.link;",
"continue;",
"case TD_RESULT_ASYNC_START:\ntrace_usb_uhci_td_async(curr_qh & ~0xf, link & ~0xf);",
"link = curr_qh ? qh.link : td.link;",
"continue;",
"case TD_RESULT_COMPLETE:\ntrace_usb_uhci_td_complete(curr_qh & ~0xf, link & ~0xf);",
"link = td.link;",
"td_count++;",
"VAR_0->frame_bytes += (td.ctrl & 0x7ff) + 1;",
"if (curr_qh) {",
"qh.el_link = link;",
"val = cpu_to_le32(qh.el_link);",
"pci_dma_write(&VAR_0->dev, (curr_qh & ~0xf) + 4, &val, sizeof(val));",
"if (!depth_first(link)) {",
"curr_qh = 0;",
"link = qh.link;",
"}",
"}",
"break;",
"default:\nassert(!\"unknown return code\");",
"}",
"}",
"out:\nVAR_0->pending_int_mask |= int_mask;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
29
],
[
31
],
[
35
],
[
39
],
[
41
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
61
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
107
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
133
],
[
135
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157,
159
],
[
163,
165,
167
],
[
169
],
[
171
],
[
175,
177
],
[
179
],
[
181
],
[
185,
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
201
],
[
203
],
[
205
],
[
209
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
225,
227
],
[
229
],
[
235
],
[
239,
241
],
[
243
]
] |
24,990 | static void test_validate_fail_alternate(TestInputVisitorData *data,
const void *unused)
{
UserDefAlternate *tmp;
Visitor *v;
Error *err = NULL;
v = validate_test_init(data, "3.14");
visit_type_UserDefAlternate(v, NULL, &tmp, &err);
error_free_or_abort(&err);
g_assert(!tmp);
}
| false | qemu | b3db211f3c80bb996a704d665fe275619f728bd4 | static void test_validate_fail_alternate(TestInputVisitorData *data,
const void *unused)
{
UserDefAlternate *tmp;
Visitor *v;
Error *err = NULL;
v = validate_test_init(data, "3.14");
visit_type_UserDefAlternate(v, NULL, &tmp, &err);
error_free_or_abort(&err);
g_assert(!tmp);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TestInputVisitorData *VAR_0,
const void *VAR_1)
{
UserDefAlternate *tmp;
Visitor *v;
Error *err = NULL;
v = validate_test_init(VAR_0, "3.14");
visit_type_UserDefAlternate(v, NULL, &tmp, &err);
error_free_or_abort(&err);
g_assert(!tmp);
}
| [
"static void FUNC_0(TestInputVisitorData *VAR_0,\nconst void *VAR_1)\n{",
"UserDefAlternate *tmp;",
"Visitor *v;",
"Error *err = NULL;",
"v = validate_test_init(VAR_0, \"3.14\");",
"visit_type_UserDefAlternate(v, NULL, &tmp, &err);",
"error_free_or_abort(&err);",
"g_assert(!tmp);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
24,991 | void sclp_print(const char *str)
{
int len = _strlen(str);
WriteEventData *sccb = (void*)_sccb;
sccb->h.length = sizeof(WriteEventData) + len;
sccb->h.function_code = SCLP_FC_NORMAL_WRITE;
sccb->ebh.length = sizeof(EventBufferHeader) + len;
sccb->ebh.type = SCLP_EVENT_ASCII_CONSOLE_DATA;
sccb->ebh.flags = 0;
_memcpy(sccb->data, str, len);
sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb);
}
| false | qemu | abd696e4f74a9d30801c6ae2693efe4e5979c2f2 | void sclp_print(const char *str)
{
int len = _strlen(str);
WriteEventData *sccb = (void*)_sccb;
sccb->h.length = sizeof(WriteEventData) + len;
sccb->h.function_code = SCLP_FC_NORMAL_WRITE;
sccb->ebh.length = sizeof(EventBufferHeader) + len;
sccb->ebh.type = SCLP_EVENT_ASCII_CONSOLE_DATA;
sccb->ebh.flags = 0;
_memcpy(sccb->data, str, len);
sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(const char *VAR_0)
{
int VAR_1 = _strlen(VAR_0);
WriteEventData *sccb = (void*)_sccb;
sccb->h.length = sizeof(WriteEventData) + VAR_1;
sccb->h.function_code = SCLP_FC_NORMAL_WRITE;
sccb->ebh.length = sizeof(EventBufferHeader) + VAR_1;
sccb->ebh.type = SCLP_EVENT_ASCII_CONSOLE_DATA;
sccb->ebh.flags = 0;
_memcpy(sccb->data, VAR_0, VAR_1);
sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb);
}
| [
"void FUNC_0(const char *VAR_0)\n{",
"int VAR_1 = _strlen(VAR_0);",
"WriteEventData *sccb = (void*)_sccb;",
"sccb->h.length = sizeof(WriteEventData) + VAR_1;",
"sccb->h.function_code = SCLP_FC_NORMAL_WRITE;",
"sccb->ebh.length = sizeof(EventBufferHeader) + VAR_1;",
"sccb->ebh.type = SCLP_EVENT_ASCII_CONSOLE_DATA;",
"sccb->ebh.flags = 0;",
"_memcpy(sccb->data, VAR_0, VAR_1);",
"sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
]
] |
24,992 | float64 helper_fstod(CPUSPARCState *env, float32 src)
{
float64 ret;
clear_float_exceptions(env);
ret = float32_to_float64(src, &env->fp_status);
check_ieee_exceptions(env);
return ret;
}
| false | qemu | 7385aed20db5d83979f683b9d0048674411e963c | float64 helper_fstod(CPUSPARCState *env, float32 src)
{
float64 ret;
clear_float_exceptions(env);
ret = float32_to_float64(src, &env->fp_status);
check_ieee_exceptions(env);
return ret;
}
| {
"code": [],
"line_no": []
} | float64 FUNC_0(CPUSPARCState *env, float32 src)
{
float64 ret;
clear_float_exceptions(env);
ret = float32_to_float64(src, &env->fp_status);
check_ieee_exceptions(env);
return ret;
}
| [
"float64 FUNC_0(CPUSPARCState *env, float32 src)\n{",
"float64 ret;",
"clear_float_exceptions(env);",
"ret = float32_to_float64(src, &env->fp_status);",
"check_ieee_exceptions(env);",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
24,993 | static void do_log(int loglevel, const char *format, ...)
{
va_list ap;
va_start(ap, format);
if (is_daemon) {
vsyslog(LOG_CRIT, format, ap);
} else {
vfprintf(stderr, format, ap);
}
va_end(ap);
}
| false | qemu | c5c7d3f0a79a977955e9df436cf9ca17269b8783 | static void do_log(int loglevel, const char *format, ...)
{
va_list ap;
va_start(ap, format);
if (is_daemon) {
vsyslog(LOG_CRIT, format, ap);
} else {
vfprintf(stderr, format, ap);
}
va_end(ap);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(int VAR_0, const char *VAR_1, ...)
{
va_list ap;
va_start(ap, VAR_1);
if (is_daemon) {
vsyslog(LOG_CRIT, VAR_1, ap);
} else {
vfprintf(stderr, VAR_1, ap);
}
va_end(ap);
}
| [
"static void FUNC_0(int VAR_0, const char *VAR_1, ...)\n{",
"va_list ap;",
"va_start(ap, VAR_1);",
"if (is_daemon) {",
"vsyslog(LOG_CRIT, VAR_1, ap);",
"} else {",
"vfprintf(stderr, VAR_1, ap);",
"}",
"va_end(ap);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
24,994 | static void gic_reset(gic_state *s)
{
int i;
memset(s->irq_state, 0, GIC_NIRQ * sizeof(gic_irq_state));
for (i = 0 ; i < NUM_CPU(s); i++) {
s->priority_mask[i] = 0xf0;
s->current_pending[i] = 1023;
s->running_irq[i] = 1023;
s->running_priority[i] = 0x100;
#ifdef NVIC
/* The NVIC doesn't have per-cpu interfaces, so enable by default. */
s->cpu_enabled[i] = 1;
#else
s->cpu_enabled[i] = 0;
#endif
}
for (i = 0; i < 16; i++) {
GIC_SET_ENABLED(i);
GIC_SET_TRIGGER(i);
}
#ifdef NVIC
/* The NVIC is always enabled. */
s->enabled = 1;
#else
s->enabled = 0;
#endif
}
| false | qemu | 41bf234d8e35e9273290df278e2aeb88c0c50a4f | static void gic_reset(gic_state *s)
{
int i;
memset(s->irq_state, 0, GIC_NIRQ * sizeof(gic_irq_state));
for (i = 0 ; i < NUM_CPU(s); i++) {
s->priority_mask[i] = 0xf0;
s->current_pending[i] = 1023;
s->running_irq[i] = 1023;
s->running_priority[i] = 0x100;
#ifdef NVIC
s->cpu_enabled[i] = 1;
#else
s->cpu_enabled[i] = 0;
#endif
}
for (i = 0; i < 16; i++) {
GIC_SET_ENABLED(i);
GIC_SET_TRIGGER(i);
}
#ifdef NVIC
s->enabled = 1;
#else
s->enabled = 0;
#endif
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(gic_state *VAR_0)
{
int VAR_1;
memset(VAR_0->irq_state, 0, GIC_NIRQ * sizeof(gic_irq_state));
for (VAR_1 = 0 ; VAR_1 < NUM_CPU(VAR_0); VAR_1++) {
VAR_0->priority_mask[VAR_1] = 0xf0;
VAR_0->current_pending[VAR_1] = 1023;
VAR_0->running_irq[VAR_1] = 1023;
VAR_0->running_priority[VAR_1] = 0x100;
#ifdef NVIC
VAR_0->cpu_enabled[VAR_1] = 1;
#else
VAR_0->cpu_enabled[VAR_1] = 0;
#endif
}
for (VAR_1 = 0; VAR_1 < 16; VAR_1++) {
GIC_SET_ENABLED(VAR_1);
GIC_SET_TRIGGER(VAR_1);
}
#ifdef NVIC
VAR_0->enabled = 1;
#else
VAR_0->enabled = 0;
#endif
}
| [
"static void FUNC_0(gic_state *VAR_0)\n{",
"int VAR_1;",
"memset(VAR_0->irq_state, 0, GIC_NIRQ * sizeof(gic_irq_state));",
"for (VAR_1 = 0 ; VAR_1 < NUM_CPU(VAR_0); VAR_1++) {",
"VAR_0->priority_mask[VAR_1] = 0xf0;",
"VAR_0->current_pending[VAR_1] = 1023;",
"VAR_0->running_irq[VAR_1] = 1023;",
"VAR_0->running_priority[VAR_1] = 0x100;",
"#ifdef NVIC\nVAR_0->cpu_enabled[VAR_1] = 1;",
"#else\nVAR_0->cpu_enabled[VAR_1] = 0;",
"#endif\n}",
"for (VAR_1 = 0; VAR_1 < 16; VAR_1++) {",
"GIC_SET_ENABLED(VAR_1);",
"GIC_SET_TRIGGER(VAR_1);",
"}",
"#ifdef NVIC\nVAR_0->enabled = 1;",
"#else\nVAR_0->enabled = 0;",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19,
23
],
[
25,
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
45
],
[
47,
49
],
[
51,
53
]
] |
24,995 | static void xhci_er_reset(XHCIState *xhci, int v)
{
XHCIInterrupter *intr = &xhci->intr[v];
XHCIEvRingSeg seg;
if (intr->erstsz == 0) {
/* disabled */
intr->er_start = 0;
intr->er_size = 0;
return;
}
/* cache the (sole) event ring segment location */
if (intr->erstsz != 1) {
DPRINTF("xhci: invalid value for ERSTSZ: %d\n", intr->erstsz);
xhci_die(xhci);
return;
}
dma_addr_t erstba = xhci_addr64(intr->erstba_low, intr->erstba_high);
pci_dma_read(PCI_DEVICE(xhci), erstba, &seg, sizeof(seg));
le32_to_cpus(&seg.addr_low);
le32_to_cpus(&seg.addr_high);
le32_to_cpus(&seg.size);
if (seg.size < 16 || seg.size > 4096) {
DPRINTF("xhci: invalid value for segment size: %d\n", seg.size);
xhci_die(xhci);
return;
}
intr->er_start = xhci_addr64(seg.addr_low, seg.addr_high);
intr->er_size = seg.size;
intr->er_ep_idx = 0;
intr->er_pcs = 1;
DPRINTF("xhci: event ring[%d]:" DMA_ADDR_FMT " [%d]\n",
v, intr->er_start, intr->er_size);
}
| false | qemu | 6100dda70d84be83d131c3b35cb9c00f7b07db15 | static void xhci_er_reset(XHCIState *xhci, int v)
{
XHCIInterrupter *intr = &xhci->intr[v];
XHCIEvRingSeg seg;
if (intr->erstsz == 0) {
intr->er_start = 0;
intr->er_size = 0;
return;
}
if (intr->erstsz != 1) {
DPRINTF("xhci: invalid value for ERSTSZ: %d\n", intr->erstsz);
xhci_die(xhci);
return;
}
dma_addr_t erstba = xhci_addr64(intr->erstba_low, intr->erstba_high);
pci_dma_read(PCI_DEVICE(xhci), erstba, &seg, sizeof(seg));
le32_to_cpus(&seg.addr_low);
le32_to_cpus(&seg.addr_high);
le32_to_cpus(&seg.size);
if (seg.size < 16 || seg.size > 4096) {
DPRINTF("xhci: invalid value for segment size: %d\n", seg.size);
xhci_die(xhci);
return;
}
intr->er_start = xhci_addr64(seg.addr_low, seg.addr_high);
intr->er_size = seg.size;
intr->er_ep_idx = 0;
intr->er_pcs = 1;
DPRINTF("xhci: event ring[%d]:" DMA_ADDR_FMT " [%d]\n",
v, intr->er_start, intr->er_size);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(XHCIState *VAR_0, int VAR_1)
{
XHCIInterrupter *intr = &VAR_0->intr[VAR_1];
XHCIEvRingSeg seg;
if (intr->erstsz == 0) {
intr->er_start = 0;
intr->er_size = 0;
return;
}
if (intr->erstsz != 1) {
DPRINTF("VAR_0: invalid value for ERSTSZ: %d\n", intr->erstsz);
xhci_die(VAR_0);
return;
}
dma_addr_t erstba = xhci_addr64(intr->erstba_low, intr->erstba_high);
pci_dma_read(PCI_DEVICE(VAR_0), erstba, &seg, sizeof(seg));
le32_to_cpus(&seg.addr_low);
le32_to_cpus(&seg.addr_high);
le32_to_cpus(&seg.size);
if (seg.size < 16 || seg.size > 4096) {
DPRINTF("VAR_0: invalid value for segment size: %d\n", seg.size);
xhci_die(VAR_0);
return;
}
intr->er_start = xhci_addr64(seg.addr_low, seg.addr_high);
intr->er_size = seg.size;
intr->er_ep_idx = 0;
intr->er_pcs = 1;
DPRINTF("VAR_0: event ring[%d]:" DMA_ADDR_FMT " [%d]\n",
VAR_1, intr->er_start, intr->er_size);
}
| [
"static void FUNC_0(XHCIState *VAR_0, int VAR_1)\n{",
"XHCIInterrupter *intr = &VAR_0->intr[VAR_1];",
"XHCIEvRingSeg seg;",
"if (intr->erstsz == 0) {",
"intr->er_start = 0;",
"intr->er_size = 0;",
"return;",
"}",
"if (intr->erstsz != 1) {",
"DPRINTF(\"VAR_0: invalid value for ERSTSZ: %d\\n\", intr->erstsz);",
"xhci_die(VAR_0);",
"return;",
"}",
"dma_addr_t erstba = xhci_addr64(intr->erstba_low, intr->erstba_high);",
"pci_dma_read(PCI_DEVICE(VAR_0), erstba, &seg, sizeof(seg));",
"le32_to_cpus(&seg.addr_low);",
"le32_to_cpus(&seg.addr_high);",
"le32_to_cpus(&seg.size);",
"if (seg.size < 16 || seg.size > 4096) {",
"DPRINTF(\"VAR_0: invalid value for segment size: %d\\n\", seg.size);",
"xhci_die(VAR_0);",
"return;",
"}",
"intr->er_start = xhci_addr64(seg.addr_low, seg.addr_high);",
"intr->er_size = seg.size;",
"intr->er_ep_idx = 0;",
"intr->er_pcs = 1;",
"DPRINTF(\"VAR_0: event ring[%d]:\" DMA_ADDR_FMT \" [%d]\\n\",\nVAR_1, intr->er_start, intr->er_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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
67,
69
],
[
71
]
] |
24,996 | static void pxa2xx_cm_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
{
PXA2xxState *s = (PXA2xxState *) opaque;
switch (addr) {
case CCCR:
case CKEN:
s->cm_regs[addr >> 2] = value;
break;
case OSCC:
s->cm_regs[addr >> 2] &= ~0x6c;
s->cm_regs[addr >> 2] |= value & 0x6e;
if ((value >> 1) & 1) /* OON */
s->cm_regs[addr >> 2] |= 1 << 0; /* Oscillator is now stable */
break;
default:
printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr);
break;
}
}
| false | qemu | a89f364ae8740dfc31b321eed9ee454e996dc3c1 | static void pxa2xx_cm_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
{
PXA2xxState *s = (PXA2xxState *) opaque;
switch (addr) {
case CCCR:
case CKEN:
s->cm_regs[addr >> 2] = value;
break;
case OSCC:
s->cm_regs[addr >> 2] &= ~0x6c;
s->cm_regs[addr >> 2] |= value & 0x6e;
if ((value >> 1) & 1)
s->cm_regs[addr >> 2] |= 1 << 0;
break;
default:
printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr);
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, hwaddr VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
PXA2xxState *s = (PXA2xxState *) VAR_0;
switch (VAR_1) {
case CCCR:
case CKEN:
s->cm_regs[VAR_1 >> 2] = VAR_2;
break;
case OSCC:
s->cm_regs[VAR_1 >> 2] &= ~0x6c;
s->cm_regs[VAR_1 >> 2] |= VAR_2 & 0x6e;
if ((VAR_2 >> 1) & 1)
s->cm_regs[VAR_1 >> 2] |= 1 << 0;
break;
default:
printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, VAR_1);
break;
}
}
| [
"static void FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"PXA2xxState *s = (PXA2xxState *) VAR_0;",
"switch (VAR_1) {",
"case CCCR:\ncase CKEN:\ns->cm_regs[VAR_1 >> 2] = VAR_2;",
"break;",
"case OSCC:\ns->cm_regs[VAR_1 >> 2] &= ~0x6c;",
"s->cm_regs[VAR_1 >> 2] |= VAR_2 & 0x6e;",
"if ((VAR_2 >> 1) & 1)\ns->cm_regs[VAR_1 >> 2] |= 1 << 0;",
"break;",
"default:\nprintf(\"%s: Bad register \" REG_FMT \"\\n\", __FUNCTION__, VAR_1);",
"break;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13,
15,
17
],
[
19
],
[
23,
25
],
[
27
],
[
29,
31
],
[
33
],
[
37,
39
],
[
41
],
[
43
],
[
45
]
] |
24,997 | static void do_mac_write(lan9118_state *s, int reg, uint32_t val)
{
switch (reg) {
case MAC_CR:
if ((s->mac_cr & MAC_CR_RXEN) != 0 && (val & MAC_CR_RXEN) == 0) {
s->int_sts |= RXSTOP_INT;
}
s->mac_cr = val & ~MAC_CR_RESERVED;
DPRINTF("MAC_CR: %08x\n", val);
break;
case MAC_ADDRH:
s->conf.macaddr.a[4] = val & 0xff;
s->conf.macaddr.a[5] = (val >> 8) & 0xff;
lan9118_mac_changed(s);
break;
case MAC_ADDRL:
s->conf.macaddr.a[0] = val & 0xff;
s->conf.macaddr.a[1] = (val >> 8) & 0xff;
s->conf.macaddr.a[2] = (val >> 16) & 0xff;
s->conf.macaddr.a[3] = (val >> 24) & 0xff;
lan9118_mac_changed(s);
break;
case MAC_HASHH:
s->mac_hashh = val;
break;
case MAC_HASHL:
s->mac_hashl = val;
break;
case MAC_MII_ACC:
s->mac_mii_acc = val & 0xffc2;
if (val & 2) {
DPRINTF("PHY write %d = 0x%04x\n",
(val >> 6) & 0x1f, s->mac_mii_data);
do_phy_write(s, (val >> 6) & 0x1f, s->mac_mii_data);
} else {
s->mac_mii_data = do_phy_read(s, (val >> 6) & 0x1f);
DPRINTF("PHY read %d = 0x%04x\n",
(val >> 6) & 0x1f, s->mac_mii_data);
}
break;
case MAC_MII_DATA:
s->mac_mii_data = val & 0xffff;
break;
case MAC_FLOW:
s->mac_flow = val & 0xffff0000;
break;
case MAC_VLAN1:
/* Writing to this register changes a condition for
* FrameTooLong bit in rx_status. Since we do not set
* FrameTooLong anyway, just ignore write to this.
*/
break;
default:
hw_error("lan9118: Unimplemented MAC register write: %d = 0x%x\n",
s->mac_cmd & 0xf, val);
}
}
| false | qemu | 52b4bb7383b32e4e7512f98c57738c8fc9cb35ba | static void do_mac_write(lan9118_state *s, int reg, uint32_t val)
{
switch (reg) {
case MAC_CR:
if ((s->mac_cr & MAC_CR_RXEN) != 0 && (val & MAC_CR_RXEN) == 0) {
s->int_sts |= RXSTOP_INT;
}
s->mac_cr = val & ~MAC_CR_RESERVED;
DPRINTF("MAC_CR: %08x\n", val);
break;
case MAC_ADDRH:
s->conf.macaddr.a[4] = val & 0xff;
s->conf.macaddr.a[5] = (val >> 8) & 0xff;
lan9118_mac_changed(s);
break;
case MAC_ADDRL:
s->conf.macaddr.a[0] = val & 0xff;
s->conf.macaddr.a[1] = (val >> 8) & 0xff;
s->conf.macaddr.a[2] = (val >> 16) & 0xff;
s->conf.macaddr.a[3] = (val >> 24) & 0xff;
lan9118_mac_changed(s);
break;
case MAC_HASHH:
s->mac_hashh = val;
break;
case MAC_HASHL:
s->mac_hashl = val;
break;
case MAC_MII_ACC:
s->mac_mii_acc = val & 0xffc2;
if (val & 2) {
DPRINTF("PHY write %d = 0x%04x\n",
(val >> 6) & 0x1f, s->mac_mii_data);
do_phy_write(s, (val >> 6) & 0x1f, s->mac_mii_data);
} else {
s->mac_mii_data = do_phy_read(s, (val >> 6) & 0x1f);
DPRINTF("PHY read %d = 0x%04x\n",
(val >> 6) & 0x1f, s->mac_mii_data);
}
break;
case MAC_MII_DATA:
s->mac_mii_data = val & 0xffff;
break;
case MAC_FLOW:
s->mac_flow = val & 0xffff0000;
break;
case MAC_VLAN1:
break;
default:
hw_error("lan9118: Unimplemented MAC register write: %d = 0x%x\n",
s->mac_cmd & 0xf, val);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(lan9118_state *VAR_0, int VAR_1, uint32_t VAR_2)
{
switch (VAR_1) {
case MAC_CR:
if ((VAR_0->mac_cr & MAC_CR_RXEN) != 0 && (VAR_2 & MAC_CR_RXEN) == 0) {
VAR_0->int_sts |= RXSTOP_INT;
}
VAR_0->mac_cr = VAR_2 & ~MAC_CR_RESERVED;
DPRINTF("MAC_CR: %08x\n", VAR_2);
break;
case MAC_ADDRH:
VAR_0->conf.macaddr.a[4] = VAR_2 & 0xff;
VAR_0->conf.macaddr.a[5] = (VAR_2 >> 8) & 0xff;
lan9118_mac_changed(VAR_0);
break;
case MAC_ADDRL:
VAR_0->conf.macaddr.a[0] = VAR_2 & 0xff;
VAR_0->conf.macaddr.a[1] = (VAR_2 >> 8) & 0xff;
VAR_0->conf.macaddr.a[2] = (VAR_2 >> 16) & 0xff;
VAR_0->conf.macaddr.a[3] = (VAR_2 >> 24) & 0xff;
lan9118_mac_changed(VAR_0);
break;
case MAC_HASHH:
VAR_0->mac_hashh = VAR_2;
break;
case MAC_HASHL:
VAR_0->mac_hashl = VAR_2;
break;
case MAC_MII_ACC:
VAR_0->mac_mii_acc = VAR_2 & 0xffc2;
if (VAR_2 & 2) {
DPRINTF("PHY write %d = 0x%04x\n",
(VAR_2 >> 6) & 0x1f, VAR_0->mac_mii_data);
do_phy_write(VAR_0, (VAR_2 >> 6) & 0x1f, VAR_0->mac_mii_data);
} else {
VAR_0->mac_mii_data = do_phy_read(VAR_0, (VAR_2 >> 6) & 0x1f);
DPRINTF("PHY read %d = 0x%04x\n",
(VAR_2 >> 6) & 0x1f, VAR_0->mac_mii_data);
}
break;
case MAC_MII_DATA:
VAR_0->mac_mii_data = VAR_2 & 0xffff;
break;
case MAC_FLOW:
VAR_0->mac_flow = VAR_2 & 0xffff0000;
break;
case MAC_VLAN1:
break;
default:
hw_error("lan9118: Unimplemented MAC register write: %d = 0x%x\n",
VAR_0->mac_cmd & 0xf, VAR_2);
}
}
| [
"static void FUNC_0(lan9118_state *VAR_0, int VAR_1, uint32_t VAR_2)\n{",
"switch (VAR_1) {",
"case MAC_CR:\nif ((VAR_0->mac_cr & MAC_CR_RXEN) != 0 && (VAR_2 & MAC_CR_RXEN) == 0) {",
"VAR_0->int_sts |= RXSTOP_INT;",
"}",
"VAR_0->mac_cr = VAR_2 & ~MAC_CR_RESERVED;",
"DPRINTF(\"MAC_CR: %08x\\n\", VAR_2);",
"break;",
"case MAC_ADDRH:\nVAR_0->conf.macaddr.a[4] = VAR_2 & 0xff;",
"VAR_0->conf.macaddr.a[5] = (VAR_2 >> 8) & 0xff;",
"lan9118_mac_changed(VAR_0);",
"break;",
"case MAC_ADDRL:\nVAR_0->conf.macaddr.a[0] = VAR_2 & 0xff;",
"VAR_0->conf.macaddr.a[1] = (VAR_2 >> 8) & 0xff;",
"VAR_0->conf.macaddr.a[2] = (VAR_2 >> 16) & 0xff;",
"VAR_0->conf.macaddr.a[3] = (VAR_2 >> 24) & 0xff;",
"lan9118_mac_changed(VAR_0);",
"break;",
"case MAC_HASHH:\nVAR_0->mac_hashh = VAR_2;",
"break;",
"case MAC_HASHL:\nVAR_0->mac_hashl = VAR_2;",
"break;",
"case MAC_MII_ACC:\nVAR_0->mac_mii_acc = VAR_2 & 0xffc2;",
"if (VAR_2 & 2) {",
"DPRINTF(\"PHY write %d = 0x%04x\\n\",\n(VAR_2 >> 6) & 0x1f, VAR_0->mac_mii_data);",
"do_phy_write(VAR_0, (VAR_2 >> 6) & 0x1f, VAR_0->mac_mii_data);",
"} else {",
"VAR_0->mac_mii_data = do_phy_read(VAR_0, (VAR_2 >> 6) & 0x1f);",
"DPRINTF(\"PHY read %d = 0x%04x\\n\",\n(VAR_2 >> 6) & 0x1f, VAR_0->mac_mii_data);",
"}",
"break;",
"case MAC_MII_DATA:\nVAR_0->mac_mii_data = VAR_2 & 0xffff;",
"break;",
"case MAC_FLOW:\nVAR_0->mac_flow = VAR_2 & 0xffff0000;",
"break;",
"case MAC_VLAN1:\nbreak;",
"default:\nhw_error(\"lan9118: Unimplemented MAC register write: %d = 0x%x\\n\",\nVAR_0->mac_cmd & 0xf, VAR_2);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
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,
103
],
[
105,
107,
109
],
[
111
],
[
113
]
] |
24,998 | static void decode_rrr_divide(CPUTriCoreState *env, DisasContext *ctx)
{
uint32_t op2;
int r1, r2, r3, r4;
op2 = MASK_OP_RRR_OP2(ctx->opcode);
r1 = MASK_OP_RRR_S1(ctx->opcode);
r2 = MASK_OP_RRR_S2(ctx->opcode);
r3 = MASK_OP_RRR_S3(ctx->opcode);
r4 = MASK_OP_RRR_D(ctx->opcode);
CHECK_REG_PAIR(r3);
switch (op2) {
case OPC2_32_RRR_DVADJ:
CHECK_REG_PAIR(r4);
GEN_HELPER_RRR(dvadj, cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r2]);
break;
case OPC2_32_RRR_DVSTEP:
CHECK_REG_PAIR(r4);
GEN_HELPER_RRR(dvstep, cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r2]);
break;
case OPC2_32_RRR_DVSTEP_U:
CHECK_REG_PAIR(r4);
GEN_HELPER_RRR(dvstep_u, cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r2]);
break;
case OPC2_32_RRR_IXMAX:
CHECK_REG_PAIR(r4);
GEN_HELPER_RRR(ixmax, cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r2]);
break;
case OPC2_32_RRR_IXMAX_U:
CHECK_REG_PAIR(r4);
GEN_HELPER_RRR(ixmax_u, cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r2]);
break;
case OPC2_32_RRR_IXMIN:
CHECK_REG_PAIR(r4);
GEN_HELPER_RRR(ixmin, cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r2]);
break;
case OPC2_32_RRR_IXMIN_U:
CHECK_REG_PAIR(r4);
GEN_HELPER_RRR(ixmin_u, cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r2]);
break;
case OPC2_32_RRR_PACK:
gen_helper_pack(cpu_gpr_d[r4], cpu_PSW_C, cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r1]);
break;
default:
generate_trap(ctx, TRAPC_INSN_ERR, TIN2_IOPC);
}
}
| false | qemu | c433a17141fb2a400ecb656e55d8d21caa2e2390 | static void decode_rrr_divide(CPUTriCoreState *env, DisasContext *ctx)
{
uint32_t op2;
int r1, r2, r3, r4;
op2 = MASK_OP_RRR_OP2(ctx->opcode);
r1 = MASK_OP_RRR_S1(ctx->opcode);
r2 = MASK_OP_RRR_S2(ctx->opcode);
r3 = MASK_OP_RRR_S3(ctx->opcode);
r4 = MASK_OP_RRR_D(ctx->opcode);
CHECK_REG_PAIR(r3);
switch (op2) {
case OPC2_32_RRR_DVADJ:
CHECK_REG_PAIR(r4);
GEN_HELPER_RRR(dvadj, cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r2]);
break;
case OPC2_32_RRR_DVSTEP:
CHECK_REG_PAIR(r4);
GEN_HELPER_RRR(dvstep, cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r2]);
break;
case OPC2_32_RRR_DVSTEP_U:
CHECK_REG_PAIR(r4);
GEN_HELPER_RRR(dvstep_u, cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r2]);
break;
case OPC2_32_RRR_IXMAX:
CHECK_REG_PAIR(r4);
GEN_HELPER_RRR(ixmax, cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r2]);
break;
case OPC2_32_RRR_IXMAX_U:
CHECK_REG_PAIR(r4);
GEN_HELPER_RRR(ixmax_u, cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r2]);
break;
case OPC2_32_RRR_IXMIN:
CHECK_REG_PAIR(r4);
GEN_HELPER_RRR(ixmin, cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r2]);
break;
case OPC2_32_RRR_IXMIN_U:
CHECK_REG_PAIR(r4);
GEN_HELPER_RRR(ixmin_u, cpu_gpr_d[r4], cpu_gpr_d[r4+1], cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r2]);
break;
case OPC2_32_RRR_PACK:
gen_helper_pack(cpu_gpr_d[r4], cpu_PSW_C, cpu_gpr_d[r3],
cpu_gpr_d[r3+1], cpu_gpr_d[r1]);
break;
default:
generate_trap(ctx, TRAPC_INSN_ERR, TIN2_IOPC);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(CPUTriCoreState *VAR_0, DisasContext *VAR_1)
{
uint32_t op2;
int VAR_2, VAR_3, VAR_4, VAR_5;
op2 = MASK_OP_RRR_OP2(VAR_1->opcode);
VAR_2 = MASK_OP_RRR_S1(VAR_1->opcode);
VAR_3 = MASK_OP_RRR_S2(VAR_1->opcode);
VAR_4 = MASK_OP_RRR_S3(VAR_1->opcode);
VAR_5 = MASK_OP_RRR_D(VAR_1->opcode);
CHECK_REG_PAIR(VAR_4);
switch (op2) {
case OPC2_32_RRR_DVADJ:
CHECK_REG_PAIR(VAR_5);
GEN_HELPER_RRR(dvadj, cpu_gpr_d[VAR_5], cpu_gpr_d[VAR_5+1], cpu_gpr_d[VAR_4],
cpu_gpr_d[VAR_4+1], cpu_gpr_d[VAR_3]);
break;
case OPC2_32_RRR_DVSTEP:
CHECK_REG_PAIR(VAR_5);
GEN_HELPER_RRR(dvstep, cpu_gpr_d[VAR_5], cpu_gpr_d[VAR_5+1], cpu_gpr_d[VAR_4],
cpu_gpr_d[VAR_4+1], cpu_gpr_d[VAR_3]);
break;
case OPC2_32_RRR_DVSTEP_U:
CHECK_REG_PAIR(VAR_5);
GEN_HELPER_RRR(dvstep_u, cpu_gpr_d[VAR_5], cpu_gpr_d[VAR_5+1], cpu_gpr_d[VAR_4],
cpu_gpr_d[VAR_4+1], cpu_gpr_d[VAR_3]);
break;
case OPC2_32_RRR_IXMAX:
CHECK_REG_PAIR(VAR_5);
GEN_HELPER_RRR(ixmax, cpu_gpr_d[VAR_5], cpu_gpr_d[VAR_5+1], cpu_gpr_d[VAR_4],
cpu_gpr_d[VAR_4+1], cpu_gpr_d[VAR_3]);
break;
case OPC2_32_RRR_IXMAX_U:
CHECK_REG_PAIR(VAR_5);
GEN_HELPER_RRR(ixmax_u, cpu_gpr_d[VAR_5], cpu_gpr_d[VAR_5+1], cpu_gpr_d[VAR_4],
cpu_gpr_d[VAR_4+1], cpu_gpr_d[VAR_3]);
break;
case OPC2_32_RRR_IXMIN:
CHECK_REG_PAIR(VAR_5);
GEN_HELPER_RRR(ixmin, cpu_gpr_d[VAR_5], cpu_gpr_d[VAR_5+1], cpu_gpr_d[VAR_4],
cpu_gpr_d[VAR_4+1], cpu_gpr_d[VAR_3]);
break;
case OPC2_32_RRR_IXMIN_U:
CHECK_REG_PAIR(VAR_5);
GEN_HELPER_RRR(ixmin_u, cpu_gpr_d[VAR_5], cpu_gpr_d[VAR_5+1], cpu_gpr_d[VAR_4],
cpu_gpr_d[VAR_4+1], cpu_gpr_d[VAR_3]);
break;
case OPC2_32_RRR_PACK:
gen_helper_pack(cpu_gpr_d[VAR_5], cpu_PSW_C, cpu_gpr_d[VAR_4],
cpu_gpr_d[VAR_4+1], cpu_gpr_d[VAR_2]);
break;
default:
generate_trap(VAR_1, TRAPC_INSN_ERR, TIN2_IOPC);
}
}
| [
"static void FUNC_0(CPUTriCoreState *VAR_0, DisasContext *VAR_1)\n{",
"uint32_t op2;",
"int VAR_2, VAR_3, VAR_4, VAR_5;",
"op2 = MASK_OP_RRR_OP2(VAR_1->opcode);",
"VAR_2 = MASK_OP_RRR_S1(VAR_1->opcode);",
"VAR_3 = MASK_OP_RRR_S2(VAR_1->opcode);",
"VAR_4 = MASK_OP_RRR_S3(VAR_1->opcode);",
"VAR_5 = MASK_OP_RRR_D(VAR_1->opcode);",
"CHECK_REG_PAIR(VAR_4);",
"switch (op2) {",
"case OPC2_32_RRR_DVADJ:\nCHECK_REG_PAIR(VAR_5);",
"GEN_HELPER_RRR(dvadj, cpu_gpr_d[VAR_5], cpu_gpr_d[VAR_5+1], cpu_gpr_d[VAR_4],\ncpu_gpr_d[VAR_4+1], cpu_gpr_d[VAR_3]);",
"break;",
"case OPC2_32_RRR_DVSTEP:\nCHECK_REG_PAIR(VAR_5);",
"GEN_HELPER_RRR(dvstep, cpu_gpr_d[VAR_5], cpu_gpr_d[VAR_5+1], cpu_gpr_d[VAR_4],\ncpu_gpr_d[VAR_4+1], cpu_gpr_d[VAR_3]);",
"break;",
"case OPC2_32_RRR_DVSTEP_U:\nCHECK_REG_PAIR(VAR_5);",
"GEN_HELPER_RRR(dvstep_u, cpu_gpr_d[VAR_5], cpu_gpr_d[VAR_5+1], cpu_gpr_d[VAR_4],\ncpu_gpr_d[VAR_4+1], cpu_gpr_d[VAR_3]);",
"break;",
"case OPC2_32_RRR_IXMAX:\nCHECK_REG_PAIR(VAR_5);",
"GEN_HELPER_RRR(ixmax, cpu_gpr_d[VAR_5], cpu_gpr_d[VAR_5+1], cpu_gpr_d[VAR_4],\ncpu_gpr_d[VAR_4+1], cpu_gpr_d[VAR_3]);",
"break;",
"case OPC2_32_RRR_IXMAX_U:\nCHECK_REG_PAIR(VAR_5);",
"GEN_HELPER_RRR(ixmax_u, cpu_gpr_d[VAR_5], cpu_gpr_d[VAR_5+1], cpu_gpr_d[VAR_4],\ncpu_gpr_d[VAR_4+1], cpu_gpr_d[VAR_3]);",
"break;",
"case OPC2_32_RRR_IXMIN:\nCHECK_REG_PAIR(VAR_5);",
"GEN_HELPER_RRR(ixmin, cpu_gpr_d[VAR_5], cpu_gpr_d[VAR_5+1], cpu_gpr_d[VAR_4],\ncpu_gpr_d[VAR_4+1], cpu_gpr_d[VAR_3]);",
"break;",
"case OPC2_32_RRR_IXMIN_U:\nCHECK_REG_PAIR(VAR_5);",
"GEN_HELPER_RRR(ixmin_u, cpu_gpr_d[VAR_5], cpu_gpr_d[VAR_5+1], cpu_gpr_d[VAR_4],\ncpu_gpr_d[VAR_4+1], cpu_gpr_d[VAR_3]);",
"break;",
"case OPC2_32_RRR_PACK:\ngen_helper_pack(cpu_gpr_d[VAR_5], cpu_PSW_C, cpu_gpr_d[VAR_4],\ncpu_gpr_d[VAR_4+1], cpu_gpr_d[VAR_2]);",
"break;",
"default:\ngenerate_trap(VAR_1, TRAPC_INSN_ERR, TIN2_IOPC);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31,
33
],
[
35,
37
],
[
39
],
[
41,
43
],
[
45,
47
],
[
49
],
[
51,
53
],
[
55,
57
],
[
59
],
[
61,
63
],
[
65,
67
],
[
69
],
[
71,
73
],
[
75,
77
],
[
79
],
[
81,
83
],
[
85,
87
],
[
89
],
[
91,
93
],
[
95,
97
],
[
99
],
[
101,
103,
105
],
[
107
],
[
109,
111
],
[
113
],
[
115
]
] |
24,999 | static void qemu_input_transform_abs_rotate(InputEvent *evt)
{
InputMoveEvent *move = evt->u.abs;
switch (graphic_rotate) {
case 90:
if (move->axis == INPUT_AXIS_X) {
move->axis = INPUT_AXIS_Y;
} else if (move->axis == INPUT_AXIS_Y) {
move->axis = INPUT_AXIS_X;
move->value = INPUT_EVENT_ABS_SIZE - 1 - move->value;
}
break;
case 180:
move->value = INPUT_EVENT_ABS_SIZE - 1 - move->value;
break;
case 270:
if (move->axis == INPUT_AXIS_X) {
move->axis = INPUT_AXIS_Y;
move->value = INPUT_EVENT_ABS_SIZE - 1 - move->value;
} else if (move->axis == INPUT_AXIS_Y) {
move->axis = INPUT_AXIS_X;
}
break;
}
}
| false | qemu | 32bafa8fdd098d52fbf1102d5a5e48d29398c0aa | static void qemu_input_transform_abs_rotate(InputEvent *evt)
{
InputMoveEvent *move = evt->u.abs;
switch (graphic_rotate) {
case 90:
if (move->axis == INPUT_AXIS_X) {
move->axis = INPUT_AXIS_Y;
} else if (move->axis == INPUT_AXIS_Y) {
move->axis = INPUT_AXIS_X;
move->value = INPUT_EVENT_ABS_SIZE - 1 - move->value;
}
break;
case 180:
move->value = INPUT_EVENT_ABS_SIZE - 1 - move->value;
break;
case 270:
if (move->axis == INPUT_AXIS_X) {
move->axis = INPUT_AXIS_Y;
move->value = INPUT_EVENT_ABS_SIZE - 1 - move->value;
} else if (move->axis == INPUT_AXIS_Y) {
move->axis = INPUT_AXIS_X;
}
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(InputEvent *VAR_0)
{
InputMoveEvent *move = VAR_0->u.abs;
switch (graphic_rotate) {
case 90:
if (move->axis == INPUT_AXIS_X) {
move->axis = INPUT_AXIS_Y;
} else if (move->axis == INPUT_AXIS_Y) {
move->axis = INPUT_AXIS_X;
move->value = INPUT_EVENT_ABS_SIZE - 1 - move->value;
}
break;
case 180:
move->value = INPUT_EVENT_ABS_SIZE - 1 - move->value;
break;
case 270:
if (move->axis == INPUT_AXIS_X) {
move->axis = INPUT_AXIS_Y;
move->value = INPUT_EVENT_ABS_SIZE - 1 - move->value;
} else if (move->axis == INPUT_AXIS_Y) {
move->axis = INPUT_AXIS_X;
}
break;
}
}
| [
"static void FUNC_0(InputEvent *VAR_0)\n{",
"InputMoveEvent *move = VAR_0->u.abs;",
"switch (graphic_rotate) {",
"case 90:\nif (move->axis == INPUT_AXIS_X) {",
"move->axis = INPUT_AXIS_Y;",
"} else if (move->axis == INPUT_AXIS_Y) {",
"move->axis = INPUT_AXIS_X;",
"move->value = INPUT_EVENT_ABS_SIZE - 1 - move->value;",
"}",
"break;",
"case 180:\nmove->value = INPUT_EVENT_ABS_SIZE - 1 - move->value;",
"break;",
"case 270:\nif (move->axis == INPUT_AXIS_X) {",
"move->axis = INPUT_AXIS_Y;",
"move->value = INPUT_EVENT_ABS_SIZE - 1 - move->value;",
"} else if (move->axis == INPUT_AXIS_Y) {",
"move->axis = INPUT_AXIS_X;",
"}",
"break;",
"}",
"}"
] | [
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
]
] |
25,000 | static int split_init(AVFilterContext *ctx, const char *args, void *opaque)
{
int i, nb_outputs = 2;
if (args) {
nb_outputs = strtol(args, NULL, 0);
if (nb_outputs <= 0) {
av_log(ctx, AV_LOG_ERROR, "Invalid number of outputs specified: %d.\n",
nb_outputs);
return AVERROR(EINVAL);
}
}
for (i = 0; i < nb_outputs; i++) {
char name[32];
AVFilterPad pad = { 0 };
snprintf(name, sizeof(name), "output%d", i);
pad.type = !strcmp(ctx->name, "split") ? AVMEDIA_TYPE_VIDEO : AVMEDIA_TYPE_AUDIO;
pad.name = av_strdup(name);
avfilter_insert_outpad(ctx, i, &pad);
}
return 0;
}
| false | FFmpeg | 3d2515a8f3ba35f10a69d077936770955b5394da | static int split_init(AVFilterContext *ctx, const char *args, void *opaque)
{
int i, nb_outputs = 2;
if (args) {
nb_outputs = strtol(args, NULL, 0);
if (nb_outputs <= 0) {
av_log(ctx, AV_LOG_ERROR, "Invalid number of outputs specified: %d.\n",
nb_outputs);
return AVERROR(EINVAL);
}
}
for (i = 0; i < nb_outputs; i++) {
char name[32];
AVFilterPad pad = { 0 };
snprintf(name, sizeof(name), "output%d", i);
pad.type = !strcmp(ctx->name, "split") ? AVMEDIA_TYPE_VIDEO : AVMEDIA_TYPE_AUDIO;
pad.name = av_strdup(name);
avfilter_insert_outpad(ctx, i, &pad);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFilterContext *VAR_0, const char *VAR_1, void *VAR_2)
{
int VAR_3, VAR_4 = 2;
if (VAR_1) {
VAR_4 = strtol(VAR_1, NULL, 0);
if (VAR_4 <= 0) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid number of outputs specified: %d.\n",
VAR_4);
return AVERROR(EINVAL);
}
}
for (VAR_3 = 0; VAR_3 < VAR_4; VAR_3++) {
char VAR_5[32];
AVFilterPad pad = { 0 };
snprintf(VAR_5, sizeof(VAR_5), "output%d", VAR_3);
pad.type = !strcmp(VAR_0->VAR_5, "split") ? AVMEDIA_TYPE_VIDEO : AVMEDIA_TYPE_AUDIO;
pad.VAR_5 = av_strdup(VAR_5);
avfilter_insert_outpad(VAR_0, VAR_3, &pad);
}
return 0;
}
| [
"static int FUNC_0(AVFilterContext *VAR_0, const char *VAR_1, void *VAR_2)\n{",
"int VAR_3, VAR_4 = 2;",
"if (VAR_1) {",
"VAR_4 = strtol(VAR_1, NULL, 0);",
"if (VAR_4 <= 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid number of outputs specified: %d.\\n\",\nVAR_4);",
"return AVERROR(EINVAL);",
"}",
"}",
"for (VAR_3 = 0; VAR_3 < VAR_4; VAR_3++) {",
"char VAR_5[32];",
"AVFilterPad pad = { 0 };",
"snprintf(VAR_5, sizeof(VAR_5), \"output%d\", VAR_3);",
"pad.type = !strcmp(VAR_0->VAR_5, \"split\") ? AVMEDIA_TYPE_VIDEO : AVMEDIA_TYPE_AUDIO;",
"pad.VAR_5 = av_strdup(VAR_5);",
"avfilter_insert_outpad(VAR_0, VAR_3, &pad);",
"}",
"return 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
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
49
],
[
51
]
] |
25,001 | static int mcf_fec_can_receive(void *opaque)
{
mcf_fec_state *s = (mcf_fec_state *)opaque;
return s->rx_enabled;
}
| false | qemu | e3f5ec2b5e92706e3b807059f79b1fb5d936e567 | static int mcf_fec_can_receive(void *opaque)
{
mcf_fec_state *s = (mcf_fec_state *)opaque;
return s->rx_enabled;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(void *VAR_0)
{
mcf_fec_state *s = (mcf_fec_state *)VAR_0;
return s->rx_enabled;
}
| [
"static int FUNC_0(void *VAR_0)\n{",
"mcf_fec_state *s = (mcf_fec_state *)VAR_0;",
"return s->rx_enabled;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
25,002 | static void qxl_realize_common(PCIQXLDevice *qxl, Error **errp)
{
uint8_t* config = qxl->pci.config;
uint32_t pci_device_rev;
uint32_t io_size;
qxl->mode = QXL_MODE_UNDEFINED;
qxl->generation = 1;
qxl->num_memslots = NUM_MEMSLOTS;
qemu_mutex_init(&qxl->track_lock);
qemu_mutex_init(&qxl->async_lock);
qxl->current_async = QXL_UNDEFINED_IO;
qxl->guest_bug = 0;
switch (qxl->revision) {
case 1: /* spice 0.4 -- qxl-1 */
pci_device_rev = QXL_REVISION_STABLE_V04;
io_size = 8;
break;
case 2: /* spice 0.6 -- qxl-2 */
pci_device_rev = QXL_REVISION_STABLE_V06;
io_size = 16;
break;
case 3: /* qxl-3 */
pci_device_rev = QXL_REVISION_STABLE_V10;
io_size = 32; /* PCI region size must be pow2 */
break;
case 4: /* qxl-4 */
pci_device_rev = QXL_REVISION_STABLE_V12;
io_size = pow2ceil(QXL_IO_RANGE_SIZE);
break;
default:
error_setg(errp, "Invalid revision %d for qxl device (max %d)",
qxl->revision, QXL_DEFAULT_REVISION);
return;
}
pci_set_byte(&config[PCI_REVISION_ID], pci_device_rev);
pci_set_byte(&config[PCI_INTERRUPT_PIN], 1);
qxl->rom_size = qxl_rom_size();
memory_region_init_ram(&qxl->rom_bar, OBJECT(qxl), "qxl.vrom",
qxl->rom_size, &error_fatal);
vmstate_register_ram(&qxl->rom_bar, &qxl->pci.qdev);
init_qxl_rom(qxl);
init_qxl_ram(qxl);
qxl->guest_surfaces.cmds = g_new0(QXLPHYSICAL, qxl->ssd.num_surfaces);
memory_region_init_ram(&qxl->vram_bar, OBJECT(qxl), "qxl.vram",
qxl->vram_size, &error_fatal);
vmstate_register_ram(&qxl->vram_bar, &qxl->pci.qdev);
memory_region_init_alias(&qxl->vram32_bar, OBJECT(qxl), "qxl.vram32",
&qxl->vram_bar, 0, qxl->vram32_size);
memory_region_init_io(&qxl->io_bar, OBJECT(qxl), &qxl_io_ops, qxl,
"qxl-ioports", io_size);
if (qxl->id == 0) {
vga_dirty_log_start(&qxl->vga);
}
memory_region_set_flush_coalesced(&qxl->io_bar);
pci_register_bar(&qxl->pci, QXL_IO_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_IO, &qxl->io_bar);
pci_register_bar(&qxl->pci, QXL_ROM_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->rom_bar);
pci_register_bar(&qxl->pci, QXL_RAM_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->vga.vram);
pci_register_bar(&qxl->pci, QXL_VRAM_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->vram32_bar);
if (qxl->vram32_size < qxl->vram_size) {
/*
* Make the 64bit vram bar show up only in case it is
* configured to be larger than the 32bit vram bar.
*/
pci_register_bar(&qxl->pci, QXL_VRAM64_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_TYPE_64 |
PCI_BASE_ADDRESS_MEM_PREFETCH,
&qxl->vram_bar);
}
/* print pci bar details */
dprint(qxl, 1, "ram/%s: %d MB [region 0]\n",
qxl->id == 0 ? "pri" : "sec",
qxl->vga.vram_size / (1024*1024));
dprint(qxl, 1, "vram/32: %d MB [region 1]\n",
qxl->vram32_size / (1024*1024));
dprint(qxl, 1, "vram/64: %d MB %s\n",
qxl->vram_size / (1024*1024),
qxl->vram32_size < qxl->vram_size ? "[region 4]" : "[unmapped]");
qxl->ssd.qxl.base.sif = &qxl_interface.base;
if (qemu_spice_add_display_interface(&qxl->ssd.qxl, qxl->vga.con) != 0) {
error_setg(errp, "qxl interface %d.%d not supported by spice-server",
SPICE_INTERFACE_QXL_MAJOR, SPICE_INTERFACE_QXL_MINOR);
return;
}
qemu_add_vm_change_state_handler(qxl_vm_change_state_handler, qxl);
qxl->update_irq = qemu_bh_new(qxl_update_irq_bh, qxl);
qxl_reset_state(qxl);
qxl->update_area_bh = qemu_bh_new(qxl_render_update_area_bh, qxl);
qxl->ssd.cursor_bh = qemu_bh_new(qemu_spice_cursor_refresh_bh, &qxl->ssd);
}
| false | qemu | de1b9b85eff3dca42fe2cabe6e026cd2a2d5c769 | static void qxl_realize_common(PCIQXLDevice *qxl, Error **errp)
{
uint8_t* config = qxl->pci.config;
uint32_t pci_device_rev;
uint32_t io_size;
qxl->mode = QXL_MODE_UNDEFINED;
qxl->generation = 1;
qxl->num_memslots = NUM_MEMSLOTS;
qemu_mutex_init(&qxl->track_lock);
qemu_mutex_init(&qxl->async_lock);
qxl->current_async = QXL_UNDEFINED_IO;
qxl->guest_bug = 0;
switch (qxl->revision) {
case 1:
pci_device_rev = QXL_REVISION_STABLE_V04;
io_size = 8;
break;
case 2:
pci_device_rev = QXL_REVISION_STABLE_V06;
io_size = 16;
break;
case 3:
pci_device_rev = QXL_REVISION_STABLE_V10;
io_size = 32;
break;
case 4:
pci_device_rev = QXL_REVISION_STABLE_V12;
io_size = pow2ceil(QXL_IO_RANGE_SIZE);
break;
default:
error_setg(errp, "Invalid revision %d for qxl device (max %d)",
qxl->revision, QXL_DEFAULT_REVISION);
return;
}
pci_set_byte(&config[PCI_REVISION_ID], pci_device_rev);
pci_set_byte(&config[PCI_INTERRUPT_PIN], 1);
qxl->rom_size = qxl_rom_size();
memory_region_init_ram(&qxl->rom_bar, OBJECT(qxl), "qxl.vrom",
qxl->rom_size, &error_fatal);
vmstate_register_ram(&qxl->rom_bar, &qxl->pci.qdev);
init_qxl_rom(qxl);
init_qxl_ram(qxl);
qxl->guest_surfaces.cmds = g_new0(QXLPHYSICAL, qxl->ssd.num_surfaces);
memory_region_init_ram(&qxl->vram_bar, OBJECT(qxl), "qxl.vram",
qxl->vram_size, &error_fatal);
vmstate_register_ram(&qxl->vram_bar, &qxl->pci.qdev);
memory_region_init_alias(&qxl->vram32_bar, OBJECT(qxl), "qxl.vram32",
&qxl->vram_bar, 0, qxl->vram32_size);
memory_region_init_io(&qxl->io_bar, OBJECT(qxl), &qxl_io_ops, qxl,
"qxl-ioports", io_size);
if (qxl->id == 0) {
vga_dirty_log_start(&qxl->vga);
}
memory_region_set_flush_coalesced(&qxl->io_bar);
pci_register_bar(&qxl->pci, QXL_IO_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_IO, &qxl->io_bar);
pci_register_bar(&qxl->pci, QXL_ROM_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->rom_bar);
pci_register_bar(&qxl->pci, QXL_RAM_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->vga.vram);
pci_register_bar(&qxl->pci, QXL_VRAM_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->vram32_bar);
if (qxl->vram32_size < qxl->vram_size) {
pci_register_bar(&qxl->pci, QXL_VRAM64_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_TYPE_64 |
PCI_BASE_ADDRESS_MEM_PREFETCH,
&qxl->vram_bar);
}
dprint(qxl, 1, "ram/%s: %d MB [region 0]\n",
qxl->id == 0 ? "pri" : "sec",
qxl->vga.vram_size / (1024*1024));
dprint(qxl, 1, "vram/32: %d MB [region 1]\n",
qxl->vram32_size / (1024*1024));
dprint(qxl, 1, "vram/64: %d MB %s\n",
qxl->vram_size / (1024*1024),
qxl->vram32_size < qxl->vram_size ? "[region 4]" : "[unmapped]");
qxl->ssd.qxl.base.sif = &qxl_interface.base;
if (qemu_spice_add_display_interface(&qxl->ssd.qxl, qxl->vga.con) != 0) {
error_setg(errp, "qxl interface %d.%d not supported by spice-server",
SPICE_INTERFACE_QXL_MAJOR, SPICE_INTERFACE_QXL_MINOR);
return;
}
qemu_add_vm_change_state_handler(qxl_vm_change_state_handler, qxl);
qxl->update_irq = qemu_bh_new(qxl_update_irq_bh, qxl);
qxl_reset_state(qxl);
qxl->update_area_bh = qemu_bh_new(qxl_render_update_area_bh, qxl);
qxl->ssd.cursor_bh = qemu_bh_new(qemu_spice_cursor_refresh_bh, &qxl->ssd);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(PCIQXLDevice *VAR_0, Error **VAR_1)
{
uint8_t* config = VAR_0->pci.config;
uint32_t pci_device_rev;
uint32_t io_size;
VAR_0->mode = QXL_MODE_UNDEFINED;
VAR_0->generation = 1;
VAR_0->num_memslots = NUM_MEMSLOTS;
qemu_mutex_init(&VAR_0->track_lock);
qemu_mutex_init(&VAR_0->async_lock);
VAR_0->current_async = QXL_UNDEFINED_IO;
VAR_0->guest_bug = 0;
switch (VAR_0->revision) {
case 1:
pci_device_rev = QXL_REVISION_STABLE_V04;
io_size = 8;
break;
case 2:
pci_device_rev = QXL_REVISION_STABLE_V06;
io_size = 16;
break;
case 3:
pci_device_rev = QXL_REVISION_STABLE_V10;
io_size = 32;
break;
case 4:
pci_device_rev = QXL_REVISION_STABLE_V12;
io_size = pow2ceil(QXL_IO_RANGE_SIZE);
break;
default:
error_setg(VAR_1, "Invalid revision %d for VAR_0 device (max %d)",
VAR_0->revision, QXL_DEFAULT_REVISION);
return;
}
pci_set_byte(&config[PCI_REVISION_ID], pci_device_rev);
pci_set_byte(&config[PCI_INTERRUPT_PIN], 1);
VAR_0->rom_size = qxl_rom_size();
memory_region_init_ram(&VAR_0->rom_bar, OBJECT(VAR_0), "VAR_0.vrom",
VAR_0->rom_size, &error_fatal);
vmstate_register_ram(&VAR_0->rom_bar, &VAR_0->pci.qdev);
init_qxl_rom(VAR_0);
init_qxl_ram(VAR_0);
VAR_0->guest_surfaces.cmds = g_new0(QXLPHYSICAL, VAR_0->ssd.num_surfaces);
memory_region_init_ram(&VAR_0->vram_bar, OBJECT(VAR_0), "VAR_0.vram",
VAR_0->vram_size, &error_fatal);
vmstate_register_ram(&VAR_0->vram_bar, &VAR_0->pci.qdev);
memory_region_init_alias(&VAR_0->vram32_bar, OBJECT(VAR_0), "VAR_0.vram32",
&VAR_0->vram_bar, 0, VAR_0->vram32_size);
memory_region_init_io(&VAR_0->io_bar, OBJECT(VAR_0), &qxl_io_ops, VAR_0,
"VAR_0-ioports", io_size);
if (VAR_0->id == 0) {
vga_dirty_log_start(&VAR_0->vga);
}
memory_region_set_flush_coalesced(&VAR_0->io_bar);
pci_register_bar(&VAR_0->pci, QXL_IO_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_IO, &VAR_0->io_bar);
pci_register_bar(&VAR_0->pci, QXL_ROM_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY, &VAR_0->rom_bar);
pci_register_bar(&VAR_0->pci, QXL_RAM_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY, &VAR_0->vga.vram);
pci_register_bar(&VAR_0->pci, QXL_VRAM_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY, &VAR_0->vram32_bar);
if (VAR_0->vram32_size < VAR_0->vram_size) {
pci_register_bar(&VAR_0->pci, QXL_VRAM64_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_TYPE_64 |
PCI_BASE_ADDRESS_MEM_PREFETCH,
&VAR_0->vram_bar);
}
dprint(VAR_0, 1, "ram/%s: %d MB [region 0]\n",
VAR_0->id == 0 ? "pri" : "sec",
VAR_0->vga.vram_size / (1024*1024));
dprint(VAR_0, 1, "vram/32: %d MB [region 1]\n",
VAR_0->vram32_size / (1024*1024));
dprint(VAR_0, 1, "vram/64: %d MB %s\n",
VAR_0->vram_size / (1024*1024),
VAR_0->vram32_size < VAR_0->vram_size ? "[region 4]" : "[unmapped]");
VAR_0->ssd.VAR_0.base.sif = &qxl_interface.base;
if (qemu_spice_add_display_interface(&VAR_0->ssd.VAR_0, VAR_0->vga.con) != 0) {
error_setg(VAR_1, "VAR_0 interface %d.%d not supported by spice-server",
SPICE_INTERFACE_QXL_MAJOR, SPICE_INTERFACE_QXL_MINOR);
return;
}
qemu_add_vm_change_state_handler(qxl_vm_change_state_handler, VAR_0);
VAR_0->update_irq = qemu_bh_new(qxl_update_irq_bh, VAR_0);
qxl_reset_state(VAR_0);
VAR_0->update_area_bh = qemu_bh_new(qxl_render_update_area_bh, VAR_0);
VAR_0->ssd.cursor_bh = qemu_bh_new(qemu_spice_cursor_refresh_bh, &VAR_0->ssd);
}
| [
"static void FUNC_0(PCIQXLDevice *VAR_0, Error **VAR_1)\n{",
"uint8_t* config = VAR_0->pci.config;",
"uint32_t pci_device_rev;",
"uint32_t io_size;",
"VAR_0->mode = QXL_MODE_UNDEFINED;",
"VAR_0->generation = 1;",
"VAR_0->num_memslots = NUM_MEMSLOTS;",
"qemu_mutex_init(&VAR_0->track_lock);",
"qemu_mutex_init(&VAR_0->async_lock);",
"VAR_0->current_async = QXL_UNDEFINED_IO;",
"VAR_0->guest_bug = 0;",
"switch (VAR_0->revision) {",
"case 1:\npci_device_rev = QXL_REVISION_STABLE_V04;",
"io_size = 8;",
"break;",
"case 2:\npci_device_rev = QXL_REVISION_STABLE_V06;",
"io_size = 16;",
"break;",
"case 3:\npci_device_rev = QXL_REVISION_STABLE_V10;",
"io_size = 32;",
"break;",
"case 4:\npci_device_rev = QXL_REVISION_STABLE_V12;",
"io_size = pow2ceil(QXL_IO_RANGE_SIZE);",
"break;",
"default:\nerror_setg(VAR_1, \"Invalid revision %d for VAR_0 device (max %d)\",\nVAR_0->revision, QXL_DEFAULT_REVISION);",
"return;",
"}",
"pci_set_byte(&config[PCI_REVISION_ID], pci_device_rev);",
"pci_set_byte(&config[PCI_INTERRUPT_PIN], 1);",
"VAR_0->rom_size = qxl_rom_size();",
"memory_region_init_ram(&VAR_0->rom_bar, OBJECT(VAR_0), \"VAR_0.vrom\",\nVAR_0->rom_size, &error_fatal);",
"vmstate_register_ram(&VAR_0->rom_bar, &VAR_0->pci.qdev);",
"init_qxl_rom(VAR_0);",
"init_qxl_ram(VAR_0);",
"VAR_0->guest_surfaces.cmds = g_new0(QXLPHYSICAL, VAR_0->ssd.num_surfaces);",
"memory_region_init_ram(&VAR_0->vram_bar, OBJECT(VAR_0), \"VAR_0.vram\",\nVAR_0->vram_size, &error_fatal);",
"vmstate_register_ram(&VAR_0->vram_bar, &VAR_0->pci.qdev);",
"memory_region_init_alias(&VAR_0->vram32_bar, OBJECT(VAR_0), \"VAR_0.vram32\",\n&VAR_0->vram_bar, 0, VAR_0->vram32_size);",
"memory_region_init_io(&VAR_0->io_bar, OBJECT(VAR_0), &qxl_io_ops, VAR_0,\n\"VAR_0-ioports\", io_size);",
"if (VAR_0->id == 0) {",
"vga_dirty_log_start(&VAR_0->vga);",
"}",
"memory_region_set_flush_coalesced(&VAR_0->io_bar);",
"pci_register_bar(&VAR_0->pci, QXL_IO_RANGE_INDEX,\nPCI_BASE_ADDRESS_SPACE_IO, &VAR_0->io_bar);",
"pci_register_bar(&VAR_0->pci, QXL_ROM_RANGE_INDEX,\nPCI_BASE_ADDRESS_SPACE_MEMORY, &VAR_0->rom_bar);",
"pci_register_bar(&VAR_0->pci, QXL_RAM_RANGE_INDEX,\nPCI_BASE_ADDRESS_SPACE_MEMORY, &VAR_0->vga.vram);",
"pci_register_bar(&VAR_0->pci, QXL_VRAM_RANGE_INDEX,\nPCI_BASE_ADDRESS_SPACE_MEMORY, &VAR_0->vram32_bar);",
"if (VAR_0->vram32_size < VAR_0->vram_size) {",
"pci_register_bar(&VAR_0->pci, QXL_VRAM64_RANGE_INDEX,\nPCI_BASE_ADDRESS_SPACE_MEMORY |\nPCI_BASE_ADDRESS_MEM_TYPE_64 |\nPCI_BASE_ADDRESS_MEM_PREFETCH,\n&VAR_0->vram_bar);",
"}",
"dprint(VAR_0, 1, \"ram/%s: %d MB [region 0]\\n\",\nVAR_0->id == 0 ? \"pri\" : \"sec\",\nVAR_0->vga.vram_size / (1024*1024));",
"dprint(VAR_0, 1, \"vram/32: %d MB [region 1]\\n\",\nVAR_0->vram32_size / (1024*1024));",
"dprint(VAR_0, 1, \"vram/64: %d MB %s\\n\",\nVAR_0->vram_size / (1024*1024),\nVAR_0->vram32_size < VAR_0->vram_size ? \"[region 4]\" : \"[unmapped]\");",
"VAR_0->ssd.VAR_0.base.sif = &qxl_interface.base;",
"if (qemu_spice_add_display_interface(&VAR_0->ssd.VAR_0, VAR_0->vga.con) != 0) {",
"error_setg(VAR_1, \"VAR_0 interface %d.%d not supported by spice-server\",\nSPICE_INTERFACE_QXL_MAJOR, SPICE_INTERFACE_QXL_MINOR);",
"return;",
"}",
"qemu_add_vm_change_state_handler(qxl_vm_change_state_handler, VAR_0);",
"VAR_0->update_irq = qemu_bh_new(qxl_update_irq_bh, VAR_0);",
"qxl_reset_state(VAR_0);",
"VAR_0->update_area_bh = qemu_bh_new(qxl_render_update_area_bh, VAR_0);",
"VAR_0->ssd.cursor_bh = qemu_bh_new(qemu_spice_cursor_refresh_bh, &VAR_0->ssd);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63,
65,
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97,
99
],
[
101
],
[
103,
105
],
[
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
125,
127
],
[
131,
133
],
[
137,
139
],
[
143,
145
],
[
149
],
[
159,
161,
163,
165,
167
],
[
169
],
[
175,
177,
179
],
[
181,
183
],
[
185,
187,
189
],
[
193
],
[
195
],
[
197,
199
],
[
201
],
[
203
],
[
205
],
[
209
],
[
211
],
[
215
],
[
217
],
[
219
]
] |
25,003 | static int css_interpret_ccw(SubchDev *sch, hwaddr ccw_addr,
bool suspend_allowed)
{
int ret;
bool check_len;
int len;
CCW1 ccw;
if (!ccw_addr) {
return -EIO;
}
/* Check doubleword aligned and 31 or 24 (fmt 0) bit addressable. */
if (ccw_addr & (sch->ccw_fmt_1 ? 0x80000007 : 0xff000007)) {
return -EINVAL;
}
/* Translate everything to format-1 ccws - the information is the same. */
ccw = copy_ccw_from_guest(ccw_addr, sch->ccw_fmt_1);
/* Check for invalid command codes. */
if ((ccw.cmd_code & 0x0f) == 0) {
return -EINVAL;
}
if (((ccw.cmd_code & 0x0f) == CCW_CMD_TIC) &&
((ccw.cmd_code & 0xf0) != 0)) {
return -EINVAL;
}
if (!sch->ccw_fmt_1 && (ccw.count == 0) &&
(ccw.cmd_code != CCW_CMD_TIC)) {
return -EINVAL;
}
/* We don't support MIDA. */
if (ccw.flags & CCW_FLAG_MIDA) {
return -EINVAL;
}
if (ccw.flags & CCW_FLAG_SUSPEND) {
return suspend_allowed ? -EINPROGRESS : -EINVAL;
}
check_len = !((ccw.flags & CCW_FLAG_SLI) && !(ccw.flags & CCW_FLAG_DC));
if (!ccw.cda) {
if (sch->ccw_no_data_cnt == 255) {
return -EINVAL;
}
sch->ccw_no_data_cnt++;
}
/* Look at the command. */
switch (ccw.cmd_code) {
case CCW_CMD_NOOP:
/* Nothing to do. */
ret = 0;
break;
case CCW_CMD_BASIC_SENSE:
if (check_len) {
if (ccw.count != sizeof(sch->sense_data)) {
ret = -EINVAL;
break;
}
}
len = MIN(ccw.count, sizeof(sch->sense_data));
cpu_physical_memory_write(ccw.cda, sch->sense_data, len);
sch->curr_status.scsw.count = ccw.count - len;
memset(sch->sense_data, 0, sizeof(sch->sense_data));
ret = 0;
break;
case CCW_CMD_SENSE_ID:
{
SenseId sense_id;
copy_sense_id_to_guest(&sense_id, &sch->id);
/* Sense ID information is device specific. */
if (check_len) {
if (ccw.count != sizeof(sense_id)) {
ret = -EINVAL;
break;
}
}
len = MIN(ccw.count, sizeof(sense_id));
/*
* Only indicate 0xff in the first sense byte if we actually
* have enough place to store at least bytes 0-3.
*/
if (len >= 4) {
sense_id.reserved = 0xff;
} else {
sense_id.reserved = 0;
}
cpu_physical_memory_write(ccw.cda, &sense_id, len);
sch->curr_status.scsw.count = ccw.count - len;
ret = 0;
break;
}
case CCW_CMD_TIC:
if (sch->last_cmd_valid && (sch->last_cmd.cmd_code == CCW_CMD_TIC)) {
ret = -EINVAL;
break;
}
if (ccw.flags & (CCW_FLAG_CC | CCW_FLAG_DC)) {
ret = -EINVAL;
break;
}
sch->channel_prog = ccw.cda;
ret = -EAGAIN;
break;
default:
if (sch->ccw_cb) {
/* Handle device specific commands. */
ret = sch->ccw_cb(sch, ccw);
} else {
ret = -ENOSYS;
}
break;
}
sch->last_cmd = ccw;
sch->last_cmd_valid = true;
if (ret == 0) {
if (ccw.flags & CCW_FLAG_CC) {
sch->channel_prog += 8;
ret = -EAGAIN;
}
}
return ret;
}
| false | qemu | 4add0da64942d83e0564147c0876b01074bde9cb | static int css_interpret_ccw(SubchDev *sch, hwaddr ccw_addr,
bool suspend_allowed)
{
int ret;
bool check_len;
int len;
CCW1 ccw;
if (!ccw_addr) {
return -EIO;
}
if (ccw_addr & (sch->ccw_fmt_1 ? 0x80000007 : 0xff000007)) {
return -EINVAL;
}
ccw = copy_ccw_from_guest(ccw_addr, sch->ccw_fmt_1);
if ((ccw.cmd_code & 0x0f) == 0) {
return -EINVAL;
}
if (((ccw.cmd_code & 0x0f) == CCW_CMD_TIC) &&
((ccw.cmd_code & 0xf0) != 0)) {
return -EINVAL;
}
if (!sch->ccw_fmt_1 && (ccw.count == 0) &&
(ccw.cmd_code != CCW_CMD_TIC)) {
return -EINVAL;
}
if (ccw.flags & CCW_FLAG_MIDA) {
return -EINVAL;
}
if (ccw.flags & CCW_FLAG_SUSPEND) {
return suspend_allowed ? -EINPROGRESS : -EINVAL;
}
check_len = !((ccw.flags & CCW_FLAG_SLI) && !(ccw.flags & CCW_FLAG_DC));
if (!ccw.cda) {
if (sch->ccw_no_data_cnt == 255) {
return -EINVAL;
}
sch->ccw_no_data_cnt++;
}
switch (ccw.cmd_code) {
case CCW_CMD_NOOP:
ret = 0;
break;
case CCW_CMD_BASIC_SENSE:
if (check_len) {
if (ccw.count != sizeof(sch->sense_data)) {
ret = -EINVAL;
break;
}
}
len = MIN(ccw.count, sizeof(sch->sense_data));
cpu_physical_memory_write(ccw.cda, sch->sense_data, len);
sch->curr_status.scsw.count = ccw.count - len;
memset(sch->sense_data, 0, sizeof(sch->sense_data));
ret = 0;
break;
case CCW_CMD_SENSE_ID:
{
SenseId sense_id;
copy_sense_id_to_guest(&sense_id, &sch->id);
if (check_len) {
if (ccw.count != sizeof(sense_id)) {
ret = -EINVAL;
break;
}
}
len = MIN(ccw.count, sizeof(sense_id));
if (len >= 4) {
sense_id.reserved = 0xff;
} else {
sense_id.reserved = 0;
}
cpu_physical_memory_write(ccw.cda, &sense_id, len);
sch->curr_status.scsw.count = ccw.count - len;
ret = 0;
break;
}
case CCW_CMD_TIC:
if (sch->last_cmd_valid && (sch->last_cmd.cmd_code == CCW_CMD_TIC)) {
ret = -EINVAL;
break;
}
if (ccw.flags & (CCW_FLAG_CC | CCW_FLAG_DC)) {
ret = -EINVAL;
break;
}
sch->channel_prog = ccw.cda;
ret = -EAGAIN;
break;
default:
if (sch->ccw_cb) {
ret = sch->ccw_cb(sch, ccw);
} else {
ret = -ENOSYS;
}
break;
}
sch->last_cmd = ccw;
sch->last_cmd_valid = true;
if (ret == 0) {
if (ccw.flags & CCW_FLAG_CC) {
sch->channel_prog += 8;
ret = -EAGAIN;
}
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(SubchDev *VAR_0, hwaddr VAR_1,
bool VAR_2)
{
int VAR_3;
bool check_len;
int VAR_4;
CCW1 ccw;
if (!VAR_1) {
return -EIO;
}
if (VAR_1 & (VAR_0->ccw_fmt_1 ? 0x80000007 : 0xff000007)) {
return -EINVAL;
}
ccw = copy_ccw_from_guest(VAR_1, VAR_0->ccw_fmt_1);
if ((ccw.cmd_code & 0x0f) == 0) {
return -EINVAL;
}
if (((ccw.cmd_code & 0x0f) == CCW_CMD_TIC) &&
((ccw.cmd_code & 0xf0) != 0)) {
return -EINVAL;
}
if (!VAR_0->ccw_fmt_1 && (ccw.count == 0) &&
(ccw.cmd_code != CCW_CMD_TIC)) {
return -EINVAL;
}
if (ccw.flags & CCW_FLAG_MIDA) {
return -EINVAL;
}
if (ccw.flags & CCW_FLAG_SUSPEND) {
return VAR_2 ? -EINPROGRESS : -EINVAL;
}
check_len = !((ccw.flags & CCW_FLAG_SLI) && !(ccw.flags & CCW_FLAG_DC));
if (!ccw.cda) {
if (VAR_0->ccw_no_data_cnt == 255) {
return -EINVAL;
}
VAR_0->ccw_no_data_cnt++;
}
switch (ccw.cmd_code) {
case CCW_CMD_NOOP:
VAR_3 = 0;
break;
case CCW_CMD_BASIC_SENSE:
if (check_len) {
if (ccw.count != sizeof(VAR_0->sense_data)) {
VAR_3 = -EINVAL;
break;
}
}
VAR_4 = MIN(ccw.count, sizeof(VAR_0->sense_data));
cpu_physical_memory_write(ccw.cda, VAR_0->sense_data, VAR_4);
VAR_0->curr_status.scsw.count = ccw.count - VAR_4;
memset(VAR_0->sense_data, 0, sizeof(VAR_0->sense_data));
VAR_3 = 0;
break;
case CCW_CMD_SENSE_ID:
{
SenseId sense_id;
copy_sense_id_to_guest(&sense_id, &VAR_0->id);
if (check_len) {
if (ccw.count != sizeof(sense_id)) {
VAR_3 = -EINVAL;
break;
}
}
VAR_4 = MIN(ccw.count, sizeof(sense_id));
if (VAR_4 >= 4) {
sense_id.reserved = 0xff;
} else {
sense_id.reserved = 0;
}
cpu_physical_memory_write(ccw.cda, &sense_id, VAR_4);
VAR_0->curr_status.scsw.count = ccw.count - VAR_4;
VAR_3 = 0;
break;
}
case CCW_CMD_TIC:
if (VAR_0->last_cmd_valid && (VAR_0->last_cmd.cmd_code == CCW_CMD_TIC)) {
VAR_3 = -EINVAL;
break;
}
if (ccw.flags & (CCW_FLAG_CC | CCW_FLAG_DC)) {
VAR_3 = -EINVAL;
break;
}
VAR_0->channel_prog = ccw.cda;
VAR_3 = -EAGAIN;
break;
default:
if (VAR_0->ccw_cb) {
VAR_3 = VAR_0->ccw_cb(VAR_0, ccw);
} else {
VAR_3 = -ENOSYS;
}
break;
}
VAR_0->last_cmd = ccw;
VAR_0->last_cmd_valid = true;
if (VAR_3 == 0) {
if (ccw.flags & CCW_FLAG_CC) {
VAR_0->channel_prog += 8;
VAR_3 = -EAGAIN;
}
}
return VAR_3;
}
| [
"static int FUNC_0(SubchDev *VAR_0, hwaddr VAR_1,\nbool VAR_2)\n{",
"int VAR_3;",
"bool check_len;",
"int VAR_4;",
"CCW1 ccw;",
"if (!VAR_1) {",
"return -EIO;",
"}",
"if (VAR_1 & (VAR_0->ccw_fmt_1 ? 0x80000007 : 0xff000007)) {",
"return -EINVAL;",
"}",
"ccw = copy_ccw_from_guest(VAR_1, VAR_0->ccw_fmt_1);",
"if ((ccw.cmd_code & 0x0f) == 0) {",
"return -EINVAL;",
"}",
"if (((ccw.cmd_code & 0x0f) == CCW_CMD_TIC) &&\n((ccw.cmd_code & 0xf0) != 0)) {",
"return -EINVAL;",
"}",
"if (!VAR_0->ccw_fmt_1 && (ccw.count == 0) &&\n(ccw.cmd_code != CCW_CMD_TIC)) {",
"return -EINVAL;",
"}",
"if (ccw.flags & CCW_FLAG_MIDA) {",
"return -EINVAL;",
"}",
"if (ccw.flags & CCW_FLAG_SUSPEND) {",
"return VAR_2 ? -EINPROGRESS : -EINVAL;",
"}",
"check_len = !((ccw.flags & CCW_FLAG_SLI) && !(ccw.flags & CCW_FLAG_DC));",
"if (!ccw.cda) {",
"if (VAR_0->ccw_no_data_cnt == 255) {",
"return -EINVAL;",
"}",
"VAR_0->ccw_no_data_cnt++;",
"}",
"switch (ccw.cmd_code) {",
"case CCW_CMD_NOOP:\nVAR_3 = 0;",
"break;",
"case CCW_CMD_BASIC_SENSE:\nif (check_len) {",
"if (ccw.count != sizeof(VAR_0->sense_data)) {",
"VAR_3 = -EINVAL;",
"break;",
"}",
"}",
"VAR_4 = MIN(ccw.count, sizeof(VAR_0->sense_data));",
"cpu_physical_memory_write(ccw.cda, VAR_0->sense_data, VAR_4);",
"VAR_0->curr_status.scsw.count = ccw.count - VAR_4;",
"memset(VAR_0->sense_data, 0, sizeof(VAR_0->sense_data));",
"VAR_3 = 0;",
"break;",
"case CCW_CMD_SENSE_ID:\n{",
"SenseId sense_id;",
"copy_sense_id_to_guest(&sense_id, &VAR_0->id);",
"if (check_len) {",
"if (ccw.count != sizeof(sense_id)) {",
"VAR_3 = -EINVAL;",
"break;",
"}",
"}",
"VAR_4 = MIN(ccw.count, sizeof(sense_id));",
"if (VAR_4 >= 4) {",
"sense_id.reserved = 0xff;",
"} else {",
"sense_id.reserved = 0;",
"}",
"cpu_physical_memory_write(ccw.cda, &sense_id, VAR_4);",
"VAR_0->curr_status.scsw.count = ccw.count - VAR_4;",
"VAR_3 = 0;",
"break;",
"}",
"case CCW_CMD_TIC:\nif (VAR_0->last_cmd_valid && (VAR_0->last_cmd.cmd_code == CCW_CMD_TIC)) {",
"VAR_3 = -EINVAL;",
"break;",
"}",
"if (ccw.flags & (CCW_FLAG_CC | CCW_FLAG_DC)) {",
"VAR_3 = -EINVAL;",
"break;",
"}",
"VAR_0->channel_prog = ccw.cda;",
"VAR_3 = -EAGAIN;",
"break;",
"default:\nif (VAR_0->ccw_cb) {",
"VAR_3 = VAR_0->ccw_cb(VAR_0, ccw);",
"} else {",
"VAR_3 = -ENOSYS;",
"}",
"break;",
"}",
"VAR_0->last_cmd = ccw;",
"VAR_0->last_cmd_valid = true;",
"if (VAR_3 == 0) {",
"if (ccw.flags & CCW_FLAG_CC) {",
"VAR_0->channel_prog += 8;",
"VAR_3 = -EAGAIN;",
"}",
"}",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
35
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
103
],
[
105,
109
],
[
111
],
[
113,
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139,
141
],
[
143
],
[
147
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193,
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217,
219
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
253
],
[
255
]
] |
25,004 | static void bdrv_detach_child(BdrvChild *child)
{
if (child->next.le_prev) {
QLIST_REMOVE(child, next);
child->next.le_prev = NULL;
}
bdrv_replace_child(child, NULL, false);
g_free(child->name);
g_free(child);
}
| false | qemu | 466787fbca9b25b47365b3d2c09d308df67a61db | static void bdrv_detach_child(BdrvChild *child)
{
if (child->next.le_prev) {
QLIST_REMOVE(child, next);
child->next.le_prev = NULL;
}
bdrv_replace_child(child, NULL, false);
g_free(child->name);
g_free(child);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BdrvChild *VAR_0)
{
if (VAR_0->next.le_prev) {
QLIST_REMOVE(VAR_0, next);
VAR_0->next.le_prev = NULL;
}
bdrv_replace_child(VAR_0, NULL, false);
g_free(VAR_0->name);
g_free(VAR_0);
}
| [
"static void FUNC_0(BdrvChild *VAR_0)\n{",
"if (VAR_0->next.le_prev) {",
"QLIST_REMOVE(VAR_0, next);",
"VAR_0->next.le_prev = NULL;",
"}",
"bdrv_replace_child(VAR_0, NULL, false);",
"g_free(VAR_0->name);",
"g_free(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
]
] |
25,006 | RTCState *rtc_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq,
int base_year)
{
RTCState *s;
int io_memory;
s = qemu_mallocz(sizeof(RTCState));
s->irq = irq;
s->cmos_data[RTC_REG_A] = 0x26;
s->cmos_data[RTC_REG_B] = 0x02;
s->cmos_data[RTC_REG_C] = 0x00;
s->cmos_data[RTC_REG_D] = 0x80;
s->base_year = base_year;
rtc_set_date_from_host(s);
s->periodic_timer = qemu_new_timer(rtc_clock, rtc_periodic_timer, s);
s->second_timer = qemu_new_timer(rtc_clock, rtc_update_second, s);
s->second_timer2 = qemu_new_timer(rtc_clock, rtc_update_second2, s);
s->next_second_time =
qemu_get_clock(rtc_clock) + (get_ticks_per_sec() * 99) / 100;
qemu_mod_timer(s->second_timer2, s->next_second_time);
io_memory = cpu_register_io_memory(rtc_mm_read, rtc_mm_write, s);
cpu_register_physical_memory(base, 2 << it_shift, io_memory);
register_savevm("mc146818rtc", base, 1, rtc_save, rtc_load, s);
#ifdef TARGET_I386
if (rtc_td_hack)
register_savevm("mc146818rtc-td", base, 1, rtc_save_td, rtc_load_td, s);
#endif
qemu_register_reset(rtc_reset, s);
return s;
}
| false | qemu | 048c74c4379789d03c857cea038ec00d95b68eaf | RTCState *rtc_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq,
int base_year)
{
RTCState *s;
int io_memory;
s = qemu_mallocz(sizeof(RTCState));
s->irq = irq;
s->cmos_data[RTC_REG_A] = 0x26;
s->cmos_data[RTC_REG_B] = 0x02;
s->cmos_data[RTC_REG_C] = 0x00;
s->cmos_data[RTC_REG_D] = 0x80;
s->base_year = base_year;
rtc_set_date_from_host(s);
s->periodic_timer = qemu_new_timer(rtc_clock, rtc_periodic_timer, s);
s->second_timer = qemu_new_timer(rtc_clock, rtc_update_second, s);
s->second_timer2 = qemu_new_timer(rtc_clock, rtc_update_second2, s);
s->next_second_time =
qemu_get_clock(rtc_clock) + (get_ticks_per_sec() * 99) / 100;
qemu_mod_timer(s->second_timer2, s->next_second_time);
io_memory = cpu_register_io_memory(rtc_mm_read, rtc_mm_write, s);
cpu_register_physical_memory(base, 2 << it_shift, io_memory);
register_savevm("mc146818rtc", base, 1, rtc_save, rtc_load, s);
#ifdef TARGET_I386
if (rtc_td_hack)
register_savevm("mc146818rtc-td", base, 1, rtc_save_td, rtc_load_td, s);
#endif
qemu_register_reset(rtc_reset, s);
return s;
}
| {
"code": [],
"line_no": []
} | RTCState *FUNC_0(target_phys_addr_t base, int it_shift, qemu_irq irq,
int base_year)
{
RTCState *s;
int VAR_0;
s = qemu_mallocz(sizeof(RTCState));
s->irq = irq;
s->cmos_data[RTC_REG_A] = 0x26;
s->cmos_data[RTC_REG_B] = 0x02;
s->cmos_data[RTC_REG_C] = 0x00;
s->cmos_data[RTC_REG_D] = 0x80;
s->base_year = base_year;
rtc_set_date_from_host(s);
s->periodic_timer = qemu_new_timer(rtc_clock, rtc_periodic_timer, s);
s->second_timer = qemu_new_timer(rtc_clock, rtc_update_second, s);
s->second_timer2 = qemu_new_timer(rtc_clock, rtc_update_second2, s);
s->next_second_time =
qemu_get_clock(rtc_clock) + (get_ticks_per_sec() * 99) / 100;
qemu_mod_timer(s->second_timer2, s->next_second_time);
VAR_0 = cpu_register_io_memory(rtc_mm_read, rtc_mm_write, s);
cpu_register_physical_memory(base, 2 << it_shift, VAR_0);
register_savevm("mc146818rtc", base, 1, rtc_save, rtc_load, s);
#ifdef TARGET_I386
if (rtc_td_hack)
register_savevm("mc146818rtc-td", base, 1, rtc_save_td, rtc_load_td, s);
#endif
qemu_register_reset(rtc_reset, s);
return s;
}
| [
"RTCState *FUNC_0(target_phys_addr_t base, int it_shift, qemu_irq irq,\nint base_year)\n{",
"RTCState *s;",
"int VAR_0;",
"s = qemu_mallocz(sizeof(RTCState));",
"s->irq = irq;",
"s->cmos_data[RTC_REG_A] = 0x26;",
"s->cmos_data[RTC_REG_B] = 0x02;",
"s->cmos_data[RTC_REG_C] = 0x00;",
"s->cmos_data[RTC_REG_D] = 0x80;",
"s->base_year = base_year;",
"rtc_set_date_from_host(s);",
"s->periodic_timer = qemu_new_timer(rtc_clock, rtc_periodic_timer, s);",
"s->second_timer = qemu_new_timer(rtc_clock, rtc_update_second, s);",
"s->second_timer2 = qemu_new_timer(rtc_clock, rtc_update_second2, s);",
"s->next_second_time =\nqemu_get_clock(rtc_clock) + (get_ticks_per_sec() * 99) / 100;",
"qemu_mod_timer(s->second_timer2, s->next_second_time);",
"VAR_0 = cpu_register_io_memory(rtc_mm_read, rtc_mm_write, s);",
"cpu_register_physical_memory(base, 2 << it_shift, VAR_0);",
"register_savevm(\"mc146818rtc\", base, 1, rtc_save, rtc_load, s);",
"#ifdef TARGET_I386\nif (rtc_td_hack)\nregister_savevm(\"mc146818rtc-td\", base, 1, rtc_save_td, rtc_load_td, s);",
"#endif\nqemu_register_reset(rtc_reset, s);",
"return s;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
43,
45
],
[
47
],
[
51
],
[
53
],
[
57
],
[
59,
61,
63
],
[
65,
67
],
[
69
],
[
71
]
] |
25,008 | INLINE float64 packFloat64( flag zSign, int16 zExp, bits64 zSig )
{
return ( ( (bits64) zSign )<<63 ) + ( ( (bits64) zExp )<<52 ) + zSig;
}
| false | qemu | f090c9d4ad5812fb92843d6470a1111c15190c4c | INLINE float64 packFloat64( flag zSign, int16 zExp, bits64 zSig )
{
return ( ( (bits64) zSign )<<63 ) + ( ( (bits64) zExp )<<52 ) + zSig;
}
| {
"code": [],
"line_no": []
} | INLINE VAR_0 packFloat64( flag zSign, int16 zExp, bits64 zSig )
{
return ( ( (bits64) zSign )<<63 ) + ( ( (bits64) zExp )<<52 ) + zSig;
}
| [
"INLINE VAR_0 packFloat64( flag zSign, int16 zExp, bits64 zSig )\n{",
"return ( ( (bits64) zSign )<<63 ) + ( ( (bits64) zExp )<<52 ) + zSig;",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
11
]
] |
25,009 | static int qcow_create2(const char *filename, int64_t total_size,
const char *backing_file, const char *backing_format,
int flags, size_t cluster_size, int prealloc)
{
int fd, header_size, backing_filename_len, l1_size, i, shift, l2_bits;
int ref_clusters, backing_format_len = 0;
QCowHeader header;
uint64_t tmp, offset;
QCowCreateState s1, *s = &s1;
QCowExtension ext_bf = {0, 0};
memset(s, 0, sizeof(*s));
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
if (fd < 0)
return -1;
memset(&header, 0, sizeof(header));
header.magic = cpu_to_be32(QCOW_MAGIC);
header.version = cpu_to_be32(QCOW_VERSION);
header.size = cpu_to_be64(total_size * 512);
header_size = sizeof(header);
backing_filename_len = 0;
if (backing_file) {
if (backing_format) {
ext_bf.magic = QCOW_EXT_MAGIC_BACKING_FORMAT;
backing_format_len = strlen(backing_format);
ext_bf.len = (backing_format_len + 7) & ~7;
header_size += ((sizeof(ext_bf) + ext_bf.len + 7) & ~7);
}
header.backing_file_offset = cpu_to_be64(header_size);
backing_filename_len = strlen(backing_file);
header.backing_file_size = cpu_to_be32(backing_filename_len);
header_size += backing_filename_len;
}
/* Cluster size */
s->cluster_bits = get_bits_from_size(cluster_size);
if (s->cluster_bits < MIN_CLUSTER_BITS ||
s->cluster_bits > MAX_CLUSTER_BITS)
{
fprintf(stderr, "Cluster size must be a power of two between "
"%d and %dk\n",
1 << MIN_CLUSTER_BITS,
1 << (MAX_CLUSTER_BITS - 10));
return -EINVAL;
}
s->cluster_size = 1 << s->cluster_bits;
header.cluster_bits = cpu_to_be32(s->cluster_bits);
header_size = (header_size + 7) & ~7;
if (flags & BLOCK_FLAG_ENCRYPT) {
header.crypt_method = cpu_to_be32(QCOW_CRYPT_AES);
} else {
header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE);
}
l2_bits = s->cluster_bits - 3;
shift = s->cluster_bits + l2_bits;
l1_size = (((total_size * 512) + (1LL << shift) - 1) >> shift);
offset = align_offset(header_size, s->cluster_size);
s->l1_table_offset = offset;
header.l1_table_offset = cpu_to_be64(s->l1_table_offset);
header.l1_size = cpu_to_be32(l1_size);
offset += align_offset(l1_size * sizeof(uint64_t), s->cluster_size);
s->refcount_table = qemu_mallocz(s->cluster_size);
s->refcount_table_offset = offset;
header.refcount_table_offset = cpu_to_be64(offset);
header.refcount_table_clusters = cpu_to_be32(1);
offset += s->cluster_size;
s->refcount_block_offset = offset;
/* count how many refcount blocks needed */
tmp = offset >> s->cluster_bits;
ref_clusters = (tmp >> (s->cluster_bits - REFCOUNT_SHIFT)) + 1;
for (i=0; i < ref_clusters; i++) {
s->refcount_table[i] = cpu_to_be64(offset);
offset += s->cluster_size;
}
s->refcount_block = qemu_mallocz(ref_clusters * s->cluster_size);
/* update refcounts */
qcow2_create_refcount_update(s, 0, header_size);
qcow2_create_refcount_update(s, s->l1_table_offset,
l1_size * sizeof(uint64_t));
qcow2_create_refcount_update(s, s->refcount_table_offset, s->cluster_size);
qcow2_create_refcount_update(s, s->refcount_block_offset,
ref_clusters * s->cluster_size);
/* write all the data */
write(fd, &header, sizeof(header));
if (backing_file) {
if (backing_format_len) {
char zero[16];
int d = ext_bf.len - backing_format_len;
memset(zero, 0, sizeof(zero));
cpu_to_be32s(&ext_bf.magic);
cpu_to_be32s(&ext_bf.len);
write(fd, &ext_bf, sizeof(ext_bf));
write(fd, backing_format, backing_format_len);
if (d>0) {
write(fd, zero, d);
}
}
write(fd, backing_file, backing_filename_len);
}
lseek(fd, s->l1_table_offset, SEEK_SET);
tmp = 0;
for(i = 0;i < l1_size; i++) {
write(fd, &tmp, sizeof(tmp));
}
lseek(fd, s->refcount_table_offset, SEEK_SET);
write(fd, s->refcount_table, s->cluster_size);
lseek(fd, s->refcount_block_offset, SEEK_SET);
write(fd, s->refcount_block, ref_clusters * s->cluster_size);
qemu_free(s->refcount_table);
qemu_free(s->refcount_block);
close(fd);
/* Preallocate metadata */
if (prealloc) {
BlockDriverState *bs;
bs = bdrv_new("");
bdrv_open(bs, filename, BDRV_O_CACHE_WB);
preallocate(bs);
bdrv_close(bs);
}
return 0;
}
| false | qemu | e1c7f0e3f998866bedc9bdb53d247859b7beb5ce | static int qcow_create2(const char *filename, int64_t total_size,
const char *backing_file, const char *backing_format,
int flags, size_t cluster_size, int prealloc)
{
int fd, header_size, backing_filename_len, l1_size, i, shift, l2_bits;
int ref_clusters, backing_format_len = 0;
QCowHeader header;
uint64_t tmp, offset;
QCowCreateState s1, *s = &s1;
QCowExtension ext_bf = {0, 0};
memset(s, 0, sizeof(*s));
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
if (fd < 0)
return -1;
memset(&header, 0, sizeof(header));
header.magic = cpu_to_be32(QCOW_MAGIC);
header.version = cpu_to_be32(QCOW_VERSION);
header.size = cpu_to_be64(total_size * 512);
header_size = sizeof(header);
backing_filename_len = 0;
if (backing_file) {
if (backing_format) {
ext_bf.magic = QCOW_EXT_MAGIC_BACKING_FORMAT;
backing_format_len = strlen(backing_format);
ext_bf.len = (backing_format_len + 7) & ~7;
header_size += ((sizeof(ext_bf) + ext_bf.len + 7) & ~7);
}
header.backing_file_offset = cpu_to_be64(header_size);
backing_filename_len = strlen(backing_file);
header.backing_file_size = cpu_to_be32(backing_filename_len);
header_size += backing_filename_len;
}
s->cluster_bits = get_bits_from_size(cluster_size);
if (s->cluster_bits < MIN_CLUSTER_BITS ||
s->cluster_bits > MAX_CLUSTER_BITS)
{
fprintf(stderr, "Cluster size must be a power of two between "
"%d and %dk\n",
1 << MIN_CLUSTER_BITS,
1 << (MAX_CLUSTER_BITS - 10));
return -EINVAL;
}
s->cluster_size = 1 << s->cluster_bits;
header.cluster_bits = cpu_to_be32(s->cluster_bits);
header_size = (header_size + 7) & ~7;
if (flags & BLOCK_FLAG_ENCRYPT) {
header.crypt_method = cpu_to_be32(QCOW_CRYPT_AES);
} else {
header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE);
}
l2_bits = s->cluster_bits - 3;
shift = s->cluster_bits + l2_bits;
l1_size = (((total_size * 512) + (1LL << shift) - 1) >> shift);
offset = align_offset(header_size, s->cluster_size);
s->l1_table_offset = offset;
header.l1_table_offset = cpu_to_be64(s->l1_table_offset);
header.l1_size = cpu_to_be32(l1_size);
offset += align_offset(l1_size * sizeof(uint64_t), s->cluster_size);
s->refcount_table = qemu_mallocz(s->cluster_size);
s->refcount_table_offset = offset;
header.refcount_table_offset = cpu_to_be64(offset);
header.refcount_table_clusters = cpu_to_be32(1);
offset += s->cluster_size;
s->refcount_block_offset = offset;
tmp = offset >> s->cluster_bits;
ref_clusters = (tmp >> (s->cluster_bits - REFCOUNT_SHIFT)) + 1;
for (i=0; i < ref_clusters; i++) {
s->refcount_table[i] = cpu_to_be64(offset);
offset += s->cluster_size;
}
s->refcount_block = qemu_mallocz(ref_clusters * s->cluster_size);
qcow2_create_refcount_update(s, 0, header_size);
qcow2_create_refcount_update(s, s->l1_table_offset,
l1_size * sizeof(uint64_t));
qcow2_create_refcount_update(s, s->refcount_table_offset, s->cluster_size);
qcow2_create_refcount_update(s, s->refcount_block_offset,
ref_clusters * s->cluster_size);
write(fd, &header, sizeof(header));
if (backing_file) {
if (backing_format_len) {
char zero[16];
int d = ext_bf.len - backing_format_len;
memset(zero, 0, sizeof(zero));
cpu_to_be32s(&ext_bf.magic);
cpu_to_be32s(&ext_bf.len);
write(fd, &ext_bf, sizeof(ext_bf));
write(fd, backing_format, backing_format_len);
if (d>0) {
write(fd, zero, d);
}
}
write(fd, backing_file, backing_filename_len);
}
lseek(fd, s->l1_table_offset, SEEK_SET);
tmp = 0;
for(i = 0;i < l1_size; i++) {
write(fd, &tmp, sizeof(tmp));
}
lseek(fd, s->refcount_table_offset, SEEK_SET);
write(fd, s->refcount_table, s->cluster_size);
lseek(fd, s->refcount_block_offset, SEEK_SET);
write(fd, s->refcount_block, ref_clusters * s->cluster_size);
qemu_free(s->refcount_table);
qemu_free(s->refcount_block);
close(fd);
if (prealloc) {
BlockDriverState *bs;
bs = bdrv_new("");
bdrv_open(bs, filename, BDRV_O_CACHE_WB);
preallocate(bs);
bdrv_close(bs);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(const char *VAR_0, int64_t VAR_1,
const char *VAR_2, const char *VAR_3,
int VAR_4, size_t VAR_5, int VAR_6)
{
int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;
int VAR_14, VAR_15 = 0;
QCowHeader header;
uint64_t tmp, offset;
QCowCreateState s1, *s = &s1;
QCowExtension ext_bf = {0, 0};
memset(s, 0, sizeof(*s));
VAR_7 = open(VAR_0, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
if (VAR_7 < 0)
return -1;
memset(&header, 0, sizeof(header));
header.magic = cpu_to_be32(QCOW_MAGIC);
header.version = cpu_to_be32(QCOW_VERSION);
header.size = cpu_to_be64(VAR_1 * 512);
VAR_8 = sizeof(header);
VAR_9 = 0;
if (VAR_2) {
if (VAR_3) {
ext_bf.magic = QCOW_EXT_MAGIC_BACKING_FORMAT;
VAR_15 = strlen(VAR_3);
ext_bf.len = (VAR_15 + 7) & ~7;
VAR_8 += ((sizeof(ext_bf) + ext_bf.len + 7) & ~7);
}
header.backing_file_offset = cpu_to_be64(VAR_8);
VAR_9 = strlen(VAR_2);
header.backing_file_size = cpu_to_be32(VAR_9);
VAR_8 += VAR_9;
}
s->cluster_bits = get_bits_from_size(VAR_5);
if (s->cluster_bits < MIN_CLUSTER_BITS ||
s->cluster_bits > MAX_CLUSTER_BITS)
{
fprintf(stderr, "Cluster size must be a power of two between "
"%VAR_17 and %dk\n",
1 << MIN_CLUSTER_BITS,
1 << (MAX_CLUSTER_BITS - 10));
return -EINVAL;
}
s->VAR_5 = 1 << s->cluster_bits;
header.cluster_bits = cpu_to_be32(s->cluster_bits);
VAR_8 = (VAR_8 + 7) & ~7;
if (VAR_4 & BLOCK_FLAG_ENCRYPT) {
header.crypt_method = cpu_to_be32(QCOW_CRYPT_AES);
} else {
header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE);
}
VAR_13 = s->cluster_bits - 3;
VAR_12 = s->cluster_bits + VAR_13;
VAR_10 = (((VAR_1 * 512) + (1LL << VAR_12) - 1) >> VAR_12);
offset = align_offset(VAR_8, s->VAR_5);
s->l1_table_offset = offset;
header.l1_table_offset = cpu_to_be64(s->l1_table_offset);
header.VAR_10 = cpu_to_be32(VAR_10);
offset += align_offset(VAR_10 * sizeof(uint64_t), s->VAR_5);
s->refcount_table = qemu_mallocz(s->VAR_5);
s->refcount_table_offset = offset;
header.refcount_table_offset = cpu_to_be64(offset);
header.refcount_table_clusters = cpu_to_be32(1);
offset += s->VAR_5;
s->refcount_block_offset = offset;
tmp = offset >> s->cluster_bits;
VAR_14 = (tmp >> (s->cluster_bits - REFCOUNT_SHIFT)) + 1;
for (VAR_11=0; VAR_11 < VAR_14; VAR_11++) {
s->refcount_table[VAR_11] = cpu_to_be64(offset);
offset += s->VAR_5;
}
s->refcount_block = qemu_mallocz(VAR_14 * s->VAR_5);
qcow2_create_refcount_update(s, 0, VAR_8);
qcow2_create_refcount_update(s, s->l1_table_offset,
VAR_10 * sizeof(uint64_t));
qcow2_create_refcount_update(s, s->refcount_table_offset, s->VAR_5);
qcow2_create_refcount_update(s, s->refcount_block_offset,
VAR_14 * s->VAR_5);
write(VAR_7, &header, sizeof(header));
if (VAR_2) {
if (VAR_15) {
char VAR_16[16];
int VAR_17 = ext_bf.len - VAR_15;
memset(VAR_16, 0, sizeof(VAR_16));
cpu_to_be32s(&ext_bf.magic);
cpu_to_be32s(&ext_bf.len);
write(VAR_7, &ext_bf, sizeof(ext_bf));
write(VAR_7, VAR_3, VAR_15);
if (VAR_17>0) {
write(VAR_7, VAR_16, VAR_17);
}
}
write(VAR_7, VAR_2, VAR_9);
}
lseek(VAR_7, s->l1_table_offset, SEEK_SET);
tmp = 0;
for(VAR_11 = 0;VAR_11 < VAR_10; VAR_11++) {
write(VAR_7, &tmp, sizeof(tmp));
}
lseek(VAR_7, s->refcount_table_offset, SEEK_SET);
write(VAR_7, s->refcount_table, s->VAR_5);
lseek(VAR_7, s->refcount_block_offset, SEEK_SET);
write(VAR_7, s->refcount_block, VAR_14 * s->VAR_5);
qemu_free(s->refcount_table);
qemu_free(s->refcount_block);
close(VAR_7);
if (VAR_6) {
BlockDriverState *bs;
bs = bdrv_new("");
bdrv_open(bs, VAR_0, BDRV_O_CACHE_WB);
preallocate(bs);
bdrv_close(bs);
}
return 0;
}
| [
"static int FUNC_0(const char *VAR_0, int64_t VAR_1,\nconst char *VAR_2, const char *VAR_3,\nint VAR_4, size_t VAR_5, int VAR_6)\n{",
"int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;",
"int VAR_14, VAR_15 = 0;",
"QCowHeader header;",
"uint64_t tmp, offset;",
"QCowCreateState s1, *s = &s1;",
"QCowExtension ext_bf = {0, 0};",
"memset(s, 0, sizeof(*s));",
"VAR_7 = open(VAR_0, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);",
"if (VAR_7 < 0)\nreturn -1;",
"memset(&header, 0, sizeof(header));",
"header.magic = cpu_to_be32(QCOW_MAGIC);",
"header.version = cpu_to_be32(QCOW_VERSION);",
"header.size = cpu_to_be64(VAR_1 * 512);",
"VAR_8 = sizeof(header);",
"VAR_9 = 0;",
"if (VAR_2) {",
"if (VAR_3) {",
"ext_bf.magic = QCOW_EXT_MAGIC_BACKING_FORMAT;",
"VAR_15 = strlen(VAR_3);",
"ext_bf.len = (VAR_15 + 7) & ~7;",
"VAR_8 += ((sizeof(ext_bf) + ext_bf.len + 7) & ~7);",
"}",
"header.backing_file_offset = cpu_to_be64(VAR_8);",
"VAR_9 = strlen(VAR_2);",
"header.backing_file_size = cpu_to_be32(VAR_9);",
"VAR_8 += VAR_9;",
"}",
"s->cluster_bits = get_bits_from_size(VAR_5);",
"if (s->cluster_bits < MIN_CLUSTER_BITS ||\ns->cluster_bits > MAX_CLUSTER_BITS)\n{",
"fprintf(stderr, \"Cluster size must be a power of two between \"\n\"%VAR_17 and %dk\\n\",\n1 << MIN_CLUSTER_BITS,\n1 << (MAX_CLUSTER_BITS - 10));",
"return -EINVAL;",
"}",
"s->VAR_5 = 1 << s->cluster_bits;",
"header.cluster_bits = cpu_to_be32(s->cluster_bits);",
"VAR_8 = (VAR_8 + 7) & ~7;",
"if (VAR_4 & BLOCK_FLAG_ENCRYPT) {",
"header.crypt_method = cpu_to_be32(QCOW_CRYPT_AES);",
"} else {",
"header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE);",
"}",
"VAR_13 = s->cluster_bits - 3;",
"VAR_12 = s->cluster_bits + VAR_13;",
"VAR_10 = (((VAR_1 * 512) + (1LL << VAR_12) - 1) >> VAR_12);",
"offset = align_offset(VAR_8, s->VAR_5);",
"s->l1_table_offset = offset;",
"header.l1_table_offset = cpu_to_be64(s->l1_table_offset);",
"header.VAR_10 = cpu_to_be32(VAR_10);",
"offset += align_offset(VAR_10 * sizeof(uint64_t), s->VAR_5);",
"s->refcount_table = qemu_mallocz(s->VAR_5);",
"s->refcount_table_offset = offset;",
"header.refcount_table_offset = cpu_to_be64(offset);",
"header.refcount_table_clusters = cpu_to_be32(1);",
"offset += s->VAR_5;",
"s->refcount_block_offset = offset;",
"tmp = offset >> s->cluster_bits;",
"VAR_14 = (tmp >> (s->cluster_bits - REFCOUNT_SHIFT)) + 1;",
"for (VAR_11=0; VAR_11 < VAR_14; VAR_11++) {",
"s->refcount_table[VAR_11] = cpu_to_be64(offset);",
"offset += s->VAR_5;",
"}",
"s->refcount_block = qemu_mallocz(VAR_14 * s->VAR_5);",
"qcow2_create_refcount_update(s, 0, VAR_8);",
"qcow2_create_refcount_update(s, s->l1_table_offset,\nVAR_10 * sizeof(uint64_t));",
"qcow2_create_refcount_update(s, s->refcount_table_offset, s->VAR_5);",
"qcow2_create_refcount_update(s, s->refcount_block_offset,\nVAR_14 * s->VAR_5);",
"write(VAR_7, &header, sizeof(header));",
"if (VAR_2) {",
"if (VAR_15) {",
"char VAR_16[16];",
"int VAR_17 = ext_bf.len - VAR_15;",
"memset(VAR_16, 0, sizeof(VAR_16));",
"cpu_to_be32s(&ext_bf.magic);",
"cpu_to_be32s(&ext_bf.len);",
"write(VAR_7, &ext_bf, sizeof(ext_bf));",
"write(VAR_7, VAR_3, VAR_15);",
"if (VAR_17>0) {",
"write(VAR_7, VAR_16, VAR_17);",
"}",
"}",
"write(VAR_7, VAR_2, VAR_9);",
"}",
"lseek(VAR_7, s->l1_table_offset, SEEK_SET);",
"tmp = 0;",
"for(VAR_11 = 0;VAR_11 < VAR_10; VAR_11++) {",
"write(VAR_7, &tmp, sizeof(tmp));",
"}",
"lseek(VAR_7, s->refcount_table_offset, SEEK_SET);",
"write(VAR_7, s->refcount_table, s->VAR_5);",
"lseek(VAR_7, s->refcount_block_offset, SEEK_SET);",
"write(VAR_7, s->refcount_block, VAR_14 * s->VAR_5);",
"qemu_free(s->refcount_table);",
"qemu_free(s->refcount_block);",
"close(VAR_7);",
"if (VAR_6) {",
"BlockDriverState *bs;",
"bs = bdrv_new(\"\");",
"bdrv_open(bs, VAR_0, BDRV_O_CACHE_WB);",
"preallocate(bs);",
"bdrv_close(bs);",
"}",
"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
] | [
[
1,
3,
5,
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
27
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
77
],
[
79,
81,
83
],
[
85,
87,
89,
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
171
],
[
173,
175
],
[
177
],
[
179,
181
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
237
],
[
239
],
[
243
],
[
245
],
[
247
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
269
],
[
271
]
] |
25,010 | static void scsi_cd_change_media_cb(void *opaque, bool load)
{
SCSIDiskState *s = opaque;
/*
* When a CD gets changed, we have to report an ejected state and
* then a loaded state to guests so that they detect tray
* open/close and media change events. Guests that do not use
* GET_EVENT_STATUS_NOTIFICATION to detect such tray open/close
* states rely on this behavior.
*
* media_changed governs the state machine used for unit attention
* report. media_event is used by GET EVENT STATUS NOTIFICATION.
*/
s->media_changed = load;
s->tray_open = !load;
s->qdev.unit_attention = SENSE_CODE(UNIT_ATTENTION_NO_MEDIUM);
s->media_event = true;
s->eject_request = false;
}
| false | qemu | e48e84ea80cb2e7fe6e48196ce187cfba6e3eb2c | static void scsi_cd_change_media_cb(void *opaque, bool load)
{
SCSIDiskState *s = opaque;
s->media_changed = load;
s->tray_open = !load;
s->qdev.unit_attention = SENSE_CODE(UNIT_ATTENTION_NO_MEDIUM);
s->media_event = true;
s->eject_request = false;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, bool VAR_1)
{
SCSIDiskState *s = VAR_0;
s->media_changed = VAR_1;
s->tray_open = !VAR_1;
s->qdev.unit_attention = SENSE_CODE(UNIT_ATTENTION_NO_MEDIUM);
s->media_event = true;
s->eject_request = false;
}
| [
"static void FUNC_0(void *VAR_0, bool VAR_1)\n{",
"SCSIDiskState *s = VAR_0;",
"s->media_changed = VAR_1;",
"s->tray_open = !VAR_1;",
"s->qdev.unit_attention = SENSE_CODE(UNIT_ATTENTION_NO_MEDIUM);",
"s->media_event = true;",
"s->eject_request = false;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
]
] |
25,012 | static int check_directory_consistency(BDRVVVFATState *s,
int cluster_num, const char* path)
{
int ret = 0;
unsigned char* cluster = g_malloc(s->cluster_size);
direntry_t* direntries = (direntry_t*)cluster;
mapping_t* mapping = find_mapping_for_cluster(s, cluster_num);
long_file_name lfn;
int path_len = strlen(path);
char path2[PATH_MAX];
assert(path_len < PATH_MAX); /* len was tested before! */
pstrcpy(path2, sizeof(path2), path);
path2[path_len] = '/';
path2[path_len + 1] = '\0';
if (mapping) {
const char* basename = get_basename(mapping->path);
const char* basename2 = get_basename(path);
assert(mapping->mode & MODE_DIRECTORY);
assert(mapping->mode & MODE_DELETED);
mapping->mode &= ~MODE_DELETED;
if (strcmp(basename, basename2))
schedule_rename(s, cluster_num, g_strdup(path));
} else
/* new directory */
schedule_mkdir(s, cluster_num, g_strdup(path));
lfn_init(&lfn);
do {
int i;
int subret = 0;
ret++;
if (s->used_clusters[cluster_num] & USED_ANY) {
fprintf(stderr, "cluster %d used more than once\n", (int)cluster_num);
return 0;
}
s->used_clusters[cluster_num] = USED_DIRECTORY;
DLOG(fprintf(stderr, "read cluster %d (sector %d)\n", (int)cluster_num, (int)cluster2sector(s, cluster_num)));
subret = vvfat_read(s->bs, cluster2sector(s, cluster_num), cluster,
s->sectors_per_cluster);
if (subret) {
fprintf(stderr, "Error fetching direntries\n");
fail:
free(cluster);
return 0;
}
for (i = 0; i < 0x10 * s->sectors_per_cluster; i++) {
int cluster_count = 0;
DLOG(fprintf(stderr, "check direntry %d: \n", i); print_direntry(direntries + i));
if (is_volume_label(direntries + i) || is_dot(direntries + i) ||
is_free(direntries + i))
continue;
subret = parse_long_name(&lfn, direntries + i);
if (subret < 0) {
fprintf(stderr, "Error in long name\n");
goto fail;
}
if (subret == 0 || is_free(direntries + i))
continue;
if (fat_chksum(direntries+i) != lfn.checksum) {
subret = parse_short_name(s, &lfn, direntries + i);
if (subret < 0) {
fprintf(stderr, "Error in short name (%d)\n", subret);
goto fail;
}
if (subret > 0 || !strcmp((char*)lfn.name, ".")
|| !strcmp((char*)lfn.name, ".."))
continue;
}
lfn.checksum = 0x100; /* cannot use long name twice */
if (path_len + 1 + lfn.len >= PATH_MAX) {
fprintf(stderr, "Name too long: %s/%s\n", path, lfn.name);
goto fail;
}
pstrcpy(path2 + path_len + 1, sizeof(path2) - path_len - 1,
(char*)lfn.name);
if (is_directory(direntries + i)) {
if (begin_of_direntry(direntries + i) == 0) {
DLOG(fprintf(stderr, "invalid begin for directory: %s\n", path2); print_direntry(direntries + i));
goto fail;
}
cluster_count = check_directory_consistency(s,
begin_of_direntry(direntries + i), path2);
if (cluster_count == 0) {
DLOG(fprintf(stderr, "problem in directory %s:\n", path2); print_direntry(direntries + i));
goto fail;
}
} else if (is_file(direntries + i)) {
/* check file size with FAT */
cluster_count = get_cluster_count_for_direntry(s, direntries + i, path2);
if (cluster_count !=
(le32_to_cpu(direntries[i].size) + s->cluster_size
- 1) / s->cluster_size) {
DLOG(fprintf(stderr, "Cluster count mismatch\n"));
goto fail;
}
} else
abort(); /* cluster_count = 0; */
ret += cluster_count;
}
cluster_num = modified_fat_get(s, cluster_num);
} while(!fat_eof(s, cluster_num));
free(cluster);
return ret;
}
| false | qemu | b2bedb214469af55179d907a60cd67fed6b0779e | static int check_directory_consistency(BDRVVVFATState *s,
int cluster_num, const char* path)
{
int ret = 0;
unsigned char* cluster = g_malloc(s->cluster_size);
direntry_t* direntries = (direntry_t*)cluster;
mapping_t* mapping = find_mapping_for_cluster(s, cluster_num);
long_file_name lfn;
int path_len = strlen(path);
char path2[PATH_MAX];
assert(path_len < PATH_MAX);
pstrcpy(path2, sizeof(path2), path);
path2[path_len] = '/';
path2[path_len + 1] = '\0';
if (mapping) {
const char* basename = get_basename(mapping->path);
const char* basename2 = get_basename(path);
assert(mapping->mode & MODE_DIRECTORY);
assert(mapping->mode & MODE_DELETED);
mapping->mode &= ~MODE_DELETED;
if (strcmp(basename, basename2))
schedule_rename(s, cluster_num, g_strdup(path));
} else
schedule_mkdir(s, cluster_num, g_strdup(path));
lfn_init(&lfn);
do {
int i;
int subret = 0;
ret++;
if (s->used_clusters[cluster_num] & USED_ANY) {
fprintf(stderr, "cluster %d used more than once\n", (int)cluster_num);
return 0;
}
s->used_clusters[cluster_num] = USED_DIRECTORY;
DLOG(fprintf(stderr, "read cluster %d (sector %d)\n", (int)cluster_num, (int)cluster2sector(s, cluster_num)));
subret = vvfat_read(s->bs, cluster2sector(s, cluster_num), cluster,
s->sectors_per_cluster);
if (subret) {
fprintf(stderr, "Error fetching direntries\n");
fail:
free(cluster);
return 0;
}
for (i = 0; i < 0x10 * s->sectors_per_cluster; i++) {
int cluster_count = 0;
DLOG(fprintf(stderr, "check direntry %d: \n", i); print_direntry(direntries + i));
if (is_volume_label(direntries + i) || is_dot(direntries + i) ||
is_free(direntries + i))
continue;
subret = parse_long_name(&lfn, direntries + i);
if (subret < 0) {
fprintf(stderr, "Error in long name\n");
goto fail;
}
if (subret == 0 || is_free(direntries + i))
continue;
if (fat_chksum(direntries+i) != lfn.checksum) {
subret = parse_short_name(s, &lfn, direntries + i);
if (subret < 0) {
fprintf(stderr, "Error in short name (%d)\n", subret);
goto fail;
}
if (subret > 0 || !strcmp((char*)lfn.name, ".")
|| !strcmp((char*)lfn.name, ".."))
continue;
}
lfn.checksum = 0x100;
if (path_len + 1 + lfn.len >= PATH_MAX) {
fprintf(stderr, "Name too long: %s/%s\n", path, lfn.name);
goto fail;
}
pstrcpy(path2 + path_len + 1, sizeof(path2) - path_len - 1,
(char*)lfn.name);
if (is_directory(direntries + i)) {
if (begin_of_direntry(direntries + i) == 0) {
DLOG(fprintf(stderr, "invalid begin for directory: %s\n", path2); print_direntry(direntries + i));
goto fail;
}
cluster_count = check_directory_consistency(s,
begin_of_direntry(direntries + i), path2);
if (cluster_count == 0) {
DLOG(fprintf(stderr, "problem in directory %s:\n", path2); print_direntry(direntries + i));
goto fail;
}
} else if (is_file(direntries + i)) {
cluster_count = get_cluster_count_for_direntry(s, direntries + i, path2);
if (cluster_count !=
(le32_to_cpu(direntries[i].size) + s->cluster_size
- 1) / s->cluster_size) {
DLOG(fprintf(stderr, "Cluster count mismatch\n"));
goto fail;
}
} else
abort();
ret += cluster_count;
}
cluster_num = modified_fat_get(s, cluster_num);
} while(!fat_eof(s, cluster_num));
free(cluster);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BDRVVVFATState *VAR_0,
int VAR_1, const char* VAR_2)
{
int VAR_3 = 0;
unsigned char* VAR_4 = g_malloc(VAR_0->cluster_size);
direntry_t* direntries = (direntry_t*)VAR_4;
mapping_t* mapping = find_mapping_for_cluster(VAR_0, VAR_1);
long_file_name lfn;
int VAR_5 = strlen(VAR_2);
char VAR_6[PATH_MAX];
assert(VAR_5 < PATH_MAX);
pstrcpy(VAR_6, sizeof(VAR_6), VAR_2);
VAR_6[VAR_5] = '/';
VAR_6[VAR_5 + 1] = '\0';
if (mapping) {
const char* VAR_7 = get_basename(mapping->VAR_2);
const char* VAR_8 = get_basename(VAR_2);
assert(mapping->mode & MODE_DIRECTORY);
assert(mapping->mode & MODE_DELETED);
mapping->mode &= ~MODE_DELETED;
if (strcmp(VAR_7, VAR_8))
schedule_rename(VAR_0, VAR_1, g_strdup(VAR_2));
} else
schedule_mkdir(VAR_0, VAR_1, g_strdup(VAR_2));
lfn_init(&lfn);
do {
int VAR_9;
int VAR_10 = 0;
VAR_3++;
if (VAR_0->used_clusters[VAR_1] & USED_ANY) {
fprintf(stderr, "VAR_4 %d used more than once\n", (int)VAR_1);
return 0;
}
VAR_0->used_clusters[VAR_1] = USED_DIRECTORY;
DLOG(fprintf(stderr, "read VAR_4 %d (sector %d)\n", (int)VAR_1, (int)cluster2sector(VAR_0, VAR_1)));
VAR_10 = vvfat_read(VAR_0->bs, cluster2sector(VAR_0, VAR_1), VAR_4,
VAR_0->sectors_per_cluster);
if (VAR_10) {
fprintf(stderr, "Error fetching direntries\n");
fail:
free(VAR_4);
return 0;
}
for (VAR_9 = 0; VAR_9 < 0x10 * VAR_0->sectors_per_cluster; VAR_9++) {
int cluster_count = 0;
DLOG(fprintf(stderr, "check direntry %d: \n", VAR_9); print_direntry(direntries + VAR_9));
if (is_volume_label(direntries + VAR_9) || is_dot(direntries + VAR_9) ||
is_free(direntries + VAR_9))
continue;
VAR_10 = parse_long_name(&lfn, direntries + VAR_9);
if (VAR_10 < 0) {
fprintf(stderr, "Error in long name\n");
goto fail;
}
if (VAR_10 == 0 || is_free(direntries + VAR_9))
continue;
if (fat_chksum(direntries+VAR_9) != lfn.checksum) {
VAR_10 = parse_short_name(VAR_0, &lfn, direntries + VAR_9);
if (VAR_10 < 0) {
fprintf(stderr, "Error in short name (%d)\n", VAR_10);
goto fail;
}
if (VAR_10 > 0 || !strcmp((char*)lfn.name, ".")
|| !strcmp((char*)lfn.name, ".."))
continue;
}
lfn.checksum = 0x100;
if (VAR_5 + 1 + lfn.len >= PATH_MAX) {
fprintf(stderr, "Name too long: %VAR_0/%VAR_0\n", VAR_2, lfn.name);
goto fail;
}
pstrcpy(VAR_6 + VAR_5 + 1, sizeof(VAR_6) - VAR_5 - 1,
(char*)lfn.name);
if (is_directory(direntries + VAR_9)) {
if (begin_of_direntry(direntries + VAR_9) == 0) {
DLOG(fprintf(stderr, "invalid begin for directory: %VAR_0\n", VAR_6); print_direntry(direntries + VAR_9));
goto fail;
}
cluster_count = FUNC_0(VAR_0,
begin_of_direntry(direntries + VAR_9), VAR_6);
if (cluster_count == 0) {
DLOG(fprintf(stderr, "problem in directory %VAR_0:\n", VAR_6); print_direntry(direntries + VAR_9));
goto fail;
}
} else if (is_file(direntries + VAR_9)) {
cluster_count = get_cluster_count_for_direntry(VAR_0, direntries + VAR_9, VAR_6);
if (cluster_count !=
(le32_to_cpu(direntries[VAR_9].size) + VAR_0->cluster_size
- 1) / VAR_0->cluster_size) {
DLOG(fprintf(stderr, "Cluster count mismatch\n"));
goto fail;
}
} else
abort();
VAR_3 += cluster_count;
}
VAR_1 = modified_fat_get(VAR_0, VAR_1);
} while(!fat_eof(VAR_0, VAR_1));
free(VAR_4);
return VAR_3;
}
| [
"static int FUNC_0(BDRVVVFATState *VAR_0,\nint VAR_1, const char* VAR_2)\n{",
"int VAR_3 = 0;",
"unsigned char* VAR_4 = g_malloc(VAR_0->cluster_size);",
"direntry_t* direntries = (direntry_t*)VAR_4;",
"mapping_t* mapping = find_mapping_for_cluster(VAR_0, VAR_1);",
"long_file_name lfn;",
"int VAR_5 = strlen(VAR_2);",
"char VAR_6[PATH_MAX];",
"assert(VAR_5 < PATH_MAX);",
"pstrcpy(VAR_6, sizeof(VAR_6), VAR_2);",
"VAR_6[VAR_5] = '/';",
"VAR_6[VAR_5 + 1] = '\\0';",
"if (mapping) {",
"const char* VAR_7 = get_basename(mapping->VAR_2);",
"const char* VAR_8 = get_basename(VAR_2);",
"assert(mapping->mode & MODE_DIRECTORY);",
"assert(mapping->mode & MODE_DELETED);",
"mapping->mode &= ~MODE_DELETED;",
"if (strcmp(VAR_7, VAR_8))\nschedule_rename(VAR_0, VAR_1, g_strdup(VAR_2));",
"} else",
"schedule_mkdir(VAR_0, VAR_1, g_strdup(VAR_2));",
"lfn_init(&lfn);",
"do {",
"int VAR_9;",
"int VAR_10 = 0;",
"VAR_3++;",
"if (VAR_0->used_clusters[VAR_1] & USED_ANY) {",
"fprintf(stderr, \"VAR_4 %d used more than once\\n\", (int)VAR_1);",
"return 0;",
"}",
"VAR_0->used_clusters[VAR_1] = USED_DIRECTORY;",
"DLOG(fprintf(stderr, \"read VAR_4 %d (sector %d)\\n\", (int)VAR_1, (int)cluster2sector(VAR_0, VAR_1)));",
"VAR_10 = vvfat_read(VAR_0->bs, cluster2sector(VAR_0, VAR_1), VAR_4,\nVAR_0->sectors_per_cluster);",
"if (VAR_10) {",
"fprintf(stderr, \"Error fetching direntries\\n\");",
"fail:\nfree(VAR_4);",
"return 0;",
"}",
"for (VAR_9 = 0; VAR_9 < 0x10 * VAR_0->sectors_per_cluster; VAR_9++) {",
"int cluster_count = 0;",
"DLOG(fprintf(stderr, \"check direntry %d: \\n\", VAR_9); print_direntry(direntries + VAR_9));",
"if (is_volume_label(direntries + VAR_9) || is_dot(direntries + VAR_9) ||\nis_free(direntries + VAR_9))\ncontinue;",
"VAR_10 = parse_long_name(&lfn, direntries + VAR_9);",
"if (VAR_10 < 0) {",
"fprintf(stderr, \"Error in long name\\n\");",
"goto fail;",
"}",
"if (VAR_10 == 0 || is_free(direntries + VAR_9))\ncontinue;",
"if (fat_chksum(direntries+VAR_9) != lfn.checksum) {",
"VAR_10 = parse_short_name(VAR_0, &lfn, direntries + VAR_9);",
"if (VAR_10 < 0) {",
"fprintf(stderr, \"Error in short name (%d)\\n\", VAR_10);",
"goto fail;",
"}",
"if (VAR_10 > 0 || !strcmp((char*)lfn.name, \".\")\n|| !strcmp((char*)lfn.name, \"..\"))\ncontinue;",
"}",
"lfn.checksum = 0x100;",
"if (VAR_5 + 1 + lfn.len >= PATH_MAX) {",
"fprintf(stderr, \"Name too long: %VAR_0/%VAR_0\\n\", VAR_2, lfn.name);",
"goto fail;",
"}",
"pstrcpy(VAR_6 + VAR_5 + 1, sizeof(VAR_6) - VAR_5 - 1,\n(char*)lfn.name);",
"if (is_directory(direntries + VAR_9)) {",
"if (begin_of_direntry(direntries + VAR_9) == 0) {",
"DLOG(fprintf(stderr, \"invalid begin for directory: %VAR_0\\n\", VAR_6); print_direntry(direntries + VAR_9));",
"goto fail;",
"}",
"cluster_count = FUNC_0(VAR_0,\nbegin_of_direntry(direntries + VAR_9), VAR_6);",
"if (cluster_count == 0) {",
"DLOG(fprintf(stderr, \"problem in directory %VAR_0:\\n\", VAR_6); print_direntry(direntries + VAR_9));",
"goto fail;",
"}",
"} else if (is_file(direntries + VAR_9)) {",
"cluster_count = get_cluster_count_for_direntry(VAR_0, direntries + VAR_9, VAR_6);",
"if (cluster_count !=\n(le32_to_cpu(direntries[VAR_9].size) + VAR_0->cluster_size\n- 1) / VAR_0->cluster_size) {",
"DLOG(fprintf(stderr, \"Cluster count mismatch\\n\"));",
"goto fail;",
"}",
"} else",
"abort();",
"VAR_3 += cluster_count;",
"}",
"VAR_1 = modified_fat_get(VAR_0, VAR_1);",
"} while(!fat_eof(VAR_0, VAR_1));",
"free(VAR_4);",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
43
],
[
47
],
[
49
],
[
53,
55
],
[
57
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93,
95
],
[
97
],
[
99
],
[
101,
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
117
],
[
119,
121,
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137,
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155,
157,
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175,
177
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191,
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
209,
211,
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
227
],
[
229
],
[
233
],
[
235
],
[
239
],
[
241
],
[
243
]
] |
25,013 | static void scsi_disk_emulate_write_data(SCSIRequest *req)
{
SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req);
if (r->iov.iov_len) {
int buflen = r->iov.iov_len;
DPRINTF("Write buf_len=%zd\n", buflen);
r->iov.iov_len = 0;
scsi_req_data(&r->req, buflen);
return;
}
switch (req->cmd.buf[0]) {
case MODE_SELECT:
case MODE_SELECT_10:
/* This also clears the sense buffer for REQUEST SENSE. */
scsi_req_complete(&r->req, GOOD);
break;
default:
abort();
}
}
| false | qemu | 380feaffb0fcc8e5f615ed8e86d2e93717a6f2c6 | static void scsi_disk_emulate_write_data(SCSIRequest *req)
{
SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req);
if (r->iov.iov_len) {
int buflen = r->iov.iov_len;
DPRINTF("Write buf_len=%zd\n", buflen);
r->iov.iov_len = 0;
scsi_req_data(&r->req, buflen);
return;
}
switch (req->cmd.buf[0]) {
case MODE_SELECT:
case MODE_SELECT_10:
scsi_req_complete(&r->req, GOOD);
break;
default:
abort();
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(SCSIRequest *VAR_0)
{
SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, VAR_0, VAR_0);
if (r->iov.iov_len) {
int VAR_1 = r->iov.iov_len;
DPRINTF("Write buf_len=%zd\n", VAR_1);
r->iov.iov_len = 0;
scsi_req_data(&r->VAR_0, VAR_1);
return;
}
switch (VAR_0->cmd.buf[0]) {
case MODE_SELECT:
case MODE_SELECT_10:
scsi_req_complete(&r->VAR_0, GOOD);
break;
default:
abort();
}
}
| [
"static void FUNC_0(SCSIRequest *VAR_0)\n{",
"SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, VAR_0, VAR_0);",
"if (r->iov.iov_len) {",
"int VAR_1 = r->iov.iov_len;",
"DPRINTF(\"Write buf_len=%zd\\n\", VAR_1);",
"r->iov.iov_len = 0;",
"scsi_req_data(&r->VAR_0, VAR_1);",
"return;",
"}",
"switch (VAR_0->cmd.buf[0]) {",
"case MODE_SELECT:\ncase MODE_SELECT_10:\nscsi_req_complete(&r->VAR_0, GOOD);",
"break;",
"default:\nabort();",
"}",
"}"
] | [
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
],
[
25
],
[
27,
29,
33
],
[
35
],
[
39,
41
],
[
43
],
[
45
]
] |
25,014 | bool tcg_cpu_exec(void)
{
int ret = 0;
if (next_cpu == NULL)
next_cpu = first_cpu;
for (; next_cpu != NULL; next_cpu = next_cpu->next_cpu) {
CPUState *env = cur_cpu = next_cpu;
qemu_clock_enable(vm_clock,
(cur_cpu->singlestep_enabled & SSTEP_NOTIMER) == 0);
if (qemu_alarm_pending())
break;
if (cpu_can_run(env))
ret = qemu_cpu_exec(env);
else if (env->stop)
break;
if (ret == EXCP_DEBUG) {
gdb_set_stop_cpu(env);
debug_requested = EXCP_DEBUG;
break;
}
}
return tcg_has_work();
}
| false | qemu | c629a4bc9725a1ec64c4c89894ef27c758024516 | bool tcg_cpu_exec(void)
{
int ret = 0;
if (next_cpu == NULL)
next_cpu = first_cpu;
for (; next_cpu != NULL; next_cpu = next_cpu->next_cpu) {
CPUState *env = cur_cpu = next_cpu;
qemu_clock_enable(vm_clock,
(cur_cpu->singlestep_enabled & SSTEP_NOTIMER) == 0);
if (qemu_alarm_pending())
break;
if (cpu_can_run(env))
ret = qemu_cpu_exec(env);
else if (env->stop)
break;
if (ret == EXCP_DEBUG) {
gdb_set_stop_cpu(env);
debug_requested = EXCP_DEBUG;
break;
}
}
return tcg_has_work();
}
| {
"code": [],
"line_no": []
} | bool FUNC_0(void)
{
int VAR_0 = 0;
if (next_cpu == NULL)
next_cpu = first_cpu;
for (; next_cpu != NULL; next_cpu = next_cpu->next_cpu) {
CPUState *env = cur_cpu = next_cpu;
qemu_clock_enable(vm_clock,
(cur_cpu->singlestep_enabled & SSTEP_NOTIMER) == 0);
if (qemu_alarm_pending())
break;
if (cpu_can_run(env))
VAR_0 = qemu_cpu_exec(env);
else if (env->stop)
break;
if (VAR_0 == EXCP_DEBUG) {
gdb_set_stop_cpu(env);
debug_requested = EXCP_DEBUG;
break;
}
}
return tcg_has_work();
}
| [
"bool FUNC_0(void)\n{",
"int VAR_0 = 0;",
"if (next_cpu == NULL)\nnext_cpu = first_cpu;",
"for (; next_cpu != NULL; next_cpu = next_cpu->next_cpu) {",
"CPUState *env = cur_cpu = next_cpu;",
"qemu_clock_enable(vm_clock,\n(cur_cpu->singlestep_enabled & SSTEP_NOTIMER) == 0);",
"if (qemu_alarm_pending())\nbreak;",
"if (cpu_can_run(env))\nVAR_0 = qemu_cpu_exec(env);",
"else if (env->stop)\nbreak;",
"if (VAR_0 == EXCP_DEBUG) {",
"gdb_set_stop_cpu(env);",
"debug_requested = EXCP_DEBUG;",
"break;",
"}",
"}",
"return tcg_has_work();",
"}"
] | [
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
],
[
25,
27
],
[
29,
31
],
[
33,
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
]
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.