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
|
---|---|---|---|---|---|---|---|---|---|---|
18,237 | static inline uint64_t vtd_get_slpte_addr(uint64_t slpte)
{
return slpte & VTD_SL_PT_BASE_ADDR_MASK(VTD_HOST_ADDRESS_WIDTH);
}
| false | qemu | 37f51384ae05bd50f83308339dbffa3e78404874 | static inline uint64_t vtd_get_slpte_addr(uint64_t slpte)
{
return slpte & VTD_SL_PT_BASE_ADDR_MASK(VTD_HOST_ADDRESS_WIDTH);
}
| {
"code": [],
"line_no": []
} | static inline uint64_t FUNC_0(uint64_t slpte)
{
return slpte & VTD_SL_PT_BASE_ADDR_MASK(VTD_HOST_ADDRESS_WIDTH);
}
| [
"static inline uint64_t FUNC_0(uint64_t slpte)\n{",
"return slpte & VTD_SL_PT_BASE_ADDR_MASK(VTD_HOST_ADDRESS_WIDTH);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
18,239 | static void open_eth_cleanup(NetClientState *nc)
{
}
| false | qemu | 57407ea44cc0a3d630b9b89a2be011f1955ce5c1 | static void open_eth_cleanup(NetClientState *nc)
{
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(NetClientState *VAR_0)
{
}
| [
"static void FUNC_0(NetClientState *VAR_0)\n{",
"}"
] | [
0,
0
] | [
[
1,
3
],
[
5
]
] |
18,240 | void HELPER(wsr_lbeg)(uint32_t v)
{
if (env->sregs[LBEG] != v) {
tb_invalidate_phys_page_range(
env->sregs[LEND] - 1, env->sregs[LEND], 0);
env->sregs[LBEG] = v;
}
}
| false | qemu | 3d0be8a5c135dadcfbd68ed354007a8cece98849 | void HELPER(wsr_lbeg)(uint32_t v)
{
if (env->sregs[LBEG] != v) {
tb_invalidate_phys_page_range(
env->sregs[LEND] - 1, env->sregs[LEND], 0);
env->sregs[LBEG] = v;
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(wsr_lbeg)(uint32_t v)
{
if (env->sregs[LBEG] != v) {
tb_invalidate_phys_page_range(
env->sregs[LEND] - 1, env->sregs[LEND], 0);
env->sregs[LBEG] = v;
}
}
| [
"void FUNC_0(wsr_lbeg)(uint32_t v)\n{",
"if (env->sregs[LBEG] != v) {",
"tb_invalidate_phys_page_range(\nenv->sregs[LEND] - 1, env->sregs[LEND], 0);",
"env->sregs[LBEG] = v;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
],
[
13
],
[
15
]
] |
18,241 | void mips_cpu_do_interrupt(CPUState *cs)
{
#if !defined(CONFIG_USER_ONLY)
MIPSCPU *cpu = MIPS_CPU(cs);
CPUMIPSState *env = &cpu->env;
bool update_badinstr = 0;
target_ulong offset;
int cause = -1;
const char *name;
if (qemu_loglevel_mask(CPU_LOG_INT)
&& 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:
if (env->insn_flags & ISA_MIPS3) {
env->hflags |= MIPS_HFLAG_64;
if (!(env->insn_flags & ISA_MIPS64R6) ||
env->CP0_Status & (1 << CP0St_KX)) {
env->hflags &= ~MIPS_HFLAG_AWRAP;
}
}
env->hflags |= MIPS_HFLAG_DM | 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 &= ~(1U << 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);
if (env->insn_flags & ISA_MIPS3) {
env->hflags |= MIPS_HFLAG_64;
if (!(env->insn_flags & ISA_MIPS64R6) ||
env->CP0_Status & (1 << CP0St_KX)) {
env->hflags &= ~MIPS_HFLAG_AWRAP;
}
}
env->hflags |= MIPS_HFLAG_CP0;
env->hflags &= ~(MIPS_HFLAG_KSU);
if (!(env->CP0_Status & (1 << CP0St_EXL)))
env->CP0_Cause &= ~(1U << 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)) {
uint32_t spacing = (env->CP0_IntCtl >> CP0IntCtl_VS) & 0x1f;
if ((env->CP0_Status & (1 << CP0St_BEV)) || spacing == 0) {
offset = 0x200;
} else {
uint32_t vector = 0;
uint32_t pending = (env->CP0_Cause & CP0Ca_IP_mask) >> CP0Ca_IP;
if (env->CP0_Config3 & (1 << CP0C3_VEIC)) {
/* For VEIC mode, the external interrupt controller feeds
* the vector through the CP0Cause IP lines. */
vector = pending;
} else {
/* Vectored Interrupts
* Mask with Status.IM7-IM0 to get enabled interrupts. */
pending &= (env->CP0_Status >> CP0St_IM) & 0xff;
/* Find the highest-priority interrupt. */
while (pending >>= 1) {
vector++;
}
}
offset = 0x200 + (vector * (spacing << 5));
}
}
goto set_EPC;
case EXCP_LTLBL:
cause = 1;
update_badinstr = !(env->error_code & EXCP_INST_NOTAVAIL);
goto set_EPC;
case EXCP_TLBL:
cause = 2;
update_badinstr = !(env->error_code & EXCP_INST_NOTAVAIL);
if ((env->error_code & EXCP_TLB_NOMATCH) &&
!(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;
update_badinstr = 1;
if ((env->error_code & EXCP_TLB_NOMATCH) &&
!(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;
update_badinstr = !(env->error_code & EXCP_INST_NOTAVAIL);
goto set_EPC;
case EXCP_AdES:
cause = 5;
update_badinstr = 1;
goto set_EPC;
case EXCP_IBE:
cause = 6;
goto set_EPC;
case EXCP_DBE:
cause = 7;
goto set_EPC;
case EXCP_SYSCALL:
cause = 8;
update_badinstr = 1;
goto set_EPC;
case EXCP_BREAK:
cause = 9;
update_badinstr = 1;
goto set_EPC;
case EXCP_RI:
cause = 10;
update_badinstr = 1;
goto set_EPC;
case EXCP_CpU:
cause = 11;
update_badinstr = 1;
env->CP0_Cause = (env->CP0_Cause & ~(0x3 << CP0Ca_CE)) |
(env->error_code << CP0Ca_CE);
goto set_EPC;
case EXCP_OVERFLOW:
cause = 12;
update_badinstr = 1;
goto set_EPC;
case EXCP_TRAP:
cause = 13;
update_badinstr = 1;
goto set_EPC;
case EXCP_MSAFPE:
cause = 14;
update_badinstr = 1;
goto set_EPC;
case EXCP_FPE:
cause = 15;
update_badinstr = 1;
goto set_EPC;
case EXCP_C2E:
cause = 18;
goto set_EPC;
case EXCP_TLBRI:
cause = 19;
update_badinstr = 1;
goto set_EPC;
case EXCP_TLBXI:
cause = 20;
goto set_EPC;
case EXCP_MSADIS:
cause = 21;
update_badinstr = 1;
goto set_EPC;
case EXCP_MDMX:
cause = 22;
goto set_EPC;
case EXCP_DWATCH:
cause = 23;
/* XXX: TODO: manage deferred 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 (update_badinstr) {
set_badinstr_registers(env);
}
if (env->hflags & MIPS_HFLAG_BMASK) {
env->CP0_Cause |= (1U << CP0Ca_BD);
} else {
env->CP0_Cause &= ~(1U << CP0Ca_BD);
}
env->CP0_Status |= (1 << CP0St_EXL);
if (env->insn_flags & ISA_MIPS3) {
env->hflags |= MIPS_HFLAG_64;
if (!(env->insn_flags & ISA_MIPS64R6) ||
env->CP0_Status & (1 << CP0St_KX)) {
env->hflags &= ~MIPS_HFLAG_AWRAP;
}
}
env->hflags |= 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:
abort();
}
if (qemu_loglevel_mask(CPU_LOG_INT)
&& 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;
}
| false | qemu | 89777fd10fc3dd573c3b4d1b2efdd10af823c001 | void mips_cpu_do_interrupt(CPUState *cs)
{
#if !defined(CONFIG_USER_ONLY)
MIPSCPU *cpu = MIPS_CPU(cs);
CPUMIPSState *env = &cpu->env;
bool update_badinstr = 0;
target_ulong offset;
int cause = -1;
const char *name;
if (qemu_loglevel_mask(CPU_LOG_INT)
&& 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:
if (env->insn_flags & ISA_MIPS3) {
env->hflags |= MIPS_HFLAG_64;
if (!(env->insn_flags & ISA_MIPS64R6) ||
env->CP0_Status & (1 << CP0St_KX)) {
env->hflags &= ~MIPS_HFLAG_AWRAP;
}
}
env->hflags |= MIPS_HFLAG_DM | MIPS_HFLAG_CP0;
env->hflags &= ~(MIPS_HFLAG_KSU);
if (!(env->CP0_Status & (1 << CP0St_EXL)))
env->CP0_Cause &= ~(1U << 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);
if (env->insn_flags & ISA_MIPS3) {
env->hflags |= MIPS_HFLAG_64;
if (!(env->insn_flags & ISA_MIPS64R6) ||
env->CP0_Status & (1 << CP0St_KX)) {
env->hflags &= ~MIPS_HFLAG_AWRAP;
}
}
env->hflags |= MIPS_HFLAG_CP0;
env->hflags &= ~(MIPS_HFLAG_KSU);
if (!(env->CP0_Status & (1 << CP0St_EXL)))
env->CP0_Cause &= ~(1U << 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)) {
uint32_t spacing = (env->CP0_IntCtl >> CP0IntCtl_VS) & 0x1f;
if ((env->CP0_Status & (1 << CP0St_BEV)) || spacing == 0) {
offset = 0x200;
} else {
uint32_t vector = 0;
uint32_t pending = (env->CP0_Cause & CP0Ca_IP_mask) >> CP0Ca_IP;
if (env->CP0_Config3 & (1 << CP0C3_VEIC)) {
vector = pending;
} else {
pending &= (env->CP0_Status >> CP0St_IM) & 0xff;
while (pending >>= 1) {
vector++;
}
}
offset = 0x200 + (vector * (spacing << 5));
}
}
goto set_EPC;
case EXCP_LTLBL:
cause = 1;
update_badinstr = !(env->error_code & EXCP_INST_NOTAVAIL);
goto set_EPC;
case EXCP_TLBL:
cause = 2;
update_badinstr = !(env->error_code & EXCP_INST_NOTAVAIL);
if ((env->error_code & EXCP_TLB_NOMATCH) &&
!(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;
update_badinstr = 1;
if ((env->error_code & EXCP_TLB_NOMATCH) &&
!(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;
update_badinstr = !(env->error_code & EXCP_INST_NOTAVAIL);
goto set_EPC;
case EXCP_AdES:
cause = 5;
update_badinstr = 1;
goto set_EPC;
case EXCP_IBE:
cause = 6;
goto set_EPC;
case EXCP_DBE:
cause = 7;
goto set_EPC;
case EXCP_SYSCALL:
cause = 8;
update_badinstr = 1;
goto set_EPC;
case EXCP_BREAK:
cause = 9;
update_badinstr = 1;
goto set_EPC;
case EXCP_RI:
cause = 10;
update_badinstr = 1;
goto set_EPC;
case EXCP_CpU:
cause = 11;
update_badinstr = 1;
env->CP0_Cause = (env->CP0_Cause & ~(0x3 << CP0Ca_CE)) |
(env->error_code << CP0Ca_CE);
goto set_EPC;
case EXCP_OVERFLOW:
cause = 12;
update_badinstr = 1;
goto set_EPC;
case EXCP_TRAP:
cause = 13;
update_badinstr = 1;
goto set_EPC;
case EXCP_MSAFPE:
cause = 14;
update_badinstr = 1;
goto set_EPC;
case EXCP_FPE:
cause = 15;
update_badinstr = 1;
goto set_EPC;
case EXCP_C2E:
cause = 18;
goto set_EPC;
case EXCP_TLBRI:
cause = 19;
update_badinstr = 1;
goto set_EPC;
case EXCP_TLBXI:
cause = 20;
goto set_EPC;
case EXCP_MSADIS:
cause = 21;
update_badinstr = 1;
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 (update_badinstr) {
set_badinstr_registers(env);
}
if (env->hflags & MIPS_HFLAG_BMASK) {
env->CP0_Cause |= (1U << CP0Ca_BD);
} else {
env->CP0_Cause &= ~(1U << CP0Ca_BD);
}
env->CP0_Status |= (1 << CP0St_EXL);
if (env->insn_flags & ISA_MIPS3) {
env->hflags |= MIPS_HFLAG_64;
if (!(env->insn_flags & ISA_MIPS64R6) ||
env->CP0_Status & (1 << CP0St_KX)) {
env->hflags &= ~MIPS_HFLAG_AWRAP;
}
}
env->hflags |= 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:
abort();
}
if (qemu_loglevel_mask(CPU_LOG_INT)
&& 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": [],
"line_no": []
} | void FUNC_0(CPUState *VAR_0)
{
#if !defined(CONFIG_USER_ONLY)
MIPSCPU *cpu = MIPS_CPU(VAR_0);
CPUMIPSState *env = &cpu->env;
bool update_badinstr = 0;
target_ulong offset;
int VAR_1 = -1;
const char *VAR_2;
if (qemu_loglevel_mask(CPU_LOG_INT)
&& 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:
if (env->insn_flags & ISA_MIPS3) {
env->hflags |= MIPS_HFLAG_64;
if (!(env->insn_flags & ISA_MIPS64R6) ||
env->CP0_Status & (1 << CP0St_KX)) {
env->hflags &= ~MIPS_HFLAG_AWRAP;
}
}
env->hflags |= MIPS_HFLAG_DM | MIPS_HFLAG_CP0;
env->hflags &= ~(MIPS_HFLAG_KSU);
if (!(env->CP0_Status & (1 << CP0St_EXL)))
env->CP0_Cause &= ~(1U << 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);
if (env->insn_flags & ISA_MIPS3) {
env->hflags |= MIPS_HFLAG_64;
if (!(env->insn_flags & ISA_MIPS64R6) ||
env->CP0_Status & (1 << CP0St_KX)) {
env->hflags &= ~MIPS_HFLAG_AWRAP;
}
}
env->hflags |= MIPS_HFLAG_CP0;
env->hflags &= ~(MIPS_HFLAG_KSU);
if (!(env->CP0_Status & (1 << CP0St_EXL)))
env->CP0_Cause &= ~(1U << 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)) {
uint32_t spacing = (env->CP0_IntCtl >> CP0IntCtl_VS) & 0x1f;
if ((env->CP0_Status & (1 << CP0St_BEV)) || spacing == 0) {
offset = 0x200;
} else {
uint32_t vector = 0;
uint32_t pending = (env->CP0_Cause & CP0Ca_IP_mask) >> CP0Ca_IP;
if (env->CP0_Config3 & (1 << CP0C3_VEIC)) {
vector = pending;
} else {
pending &= (env->CP0_Status >> CP0St_IM) & 0xff;
while (pending >>= 1) {
vector++;
}
}
offset = 0x200 + (vector * (spacing << 5));
}
}
goto set_EPC;
case EXCP_LTLBL:
VAR_1 = 1;
update_badinstr = !(env->error_code & EXCP_INST_NOTAVAIL);
goto set_EPC;
case EXCP_TLBL:
VAR_1 = 2;
update_badinstr = !(env->error_code & EXCP_INST_NOTAVAIL);
if ((env->error_code & EXCP_TLB_NOMATCH) &&
!(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;
update_badinstr = 1;
if ((env->error_code & EXCP_TLB_NOMATCH) &&
!(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;
update_badinstr = !(env->error_code & EXCP_INST_NOTAVAIL);
goto set_EPC;
case EXCP_AdES:
VAR_1 = 5;
update_badinstr = 1;
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;
update_badinstr = 1;
goto set_EPC;
case EXCP_BREAK:
VAR_1 = 9;
update_badinstr = 1;
goto set_EPC;
case EXCP_RI:
VAR_1 = 10;
update_badinstr = 1;
goto set_EPC;
case EXCP_CpU:
VAR_1 = 11;
update_badinstr = 1;
env->CP0_Cause = (env->CP0_Cause & ~(0x3 << CP0Ca_CE)) |
(env->error_code << CP0Ca_CE);
goto set_EPC;
case EXCP_OVERFLOW:
VAR_1 = 12;
update_badinstr = 1;
goto set_EPC;
case EXCP_TRAP:
VAR_1 = 13;
update_badinstr = 1;
goto set_EPC;
case EXCP_MSAFPE:
VAR_1 = 14;
update_badinstr = 1;
goto set_EPC;
case EXCP_FPE:
VAR_1 = 15;
update_badinstr = 1;
goto set_EPC;
case EXCP_C2E:
VAR_1 = 18;
goto set_EPC;
case EXCP_TLBRI:
VAR_1 = 19;
update_badinstr = 1;
goto set_EPC;
case EXCP_TLBXI:
VAR_1 = 20;
goto set_EPC;
case EXCP_MSADIS:
VAR_1 = 21;
update_badinstr = 1;
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 (update_badinstr) {
set_badinstr_registers(env);
}
if (env->hflags & MIPS_HFLAG_BMASK) {
env->CP0_Cause |= (1U << CP0Ca_BD);
} else {
env->CP0_Cause &= ~(1U << CP0Ca_BD);
}
env->CP0_Status |= (1 << CP0St_EXL);
if (env->insn_flags & ISA_MIPS3) {
env->hflags |= MIPS_HFLAG_64;
if (!(env->insn_flags & ISA_MIPS64R6) ||
env->CP0_Status & (1 << CP0St_KX)) {
env->hflags &= ~MIPS_HFLAG_AWRAP;
}
}
env->hflags |= 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:
abort();
}
if (qemu_loglevel_mask(CPU_LOG_INT)
&& 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;",
"bool update_badinstr = 0;",
"target_ulong offset;",
"int VAR_1 = -1;",
"const char *VAR_2;",
"if (qemu_loglevel_mask(CPU_LOG_INT)\n&& 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\n\" %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:\nif (env->insn_flags & ISA_MIPS3) {",
"env->hflags |= MIPS_HFLAG_64;",
"if (!(env->insn_flags & ISA_MIPS64R6) ||\nenv->CP0_Status & (1 << CP0St_KX)) {",
"env->hflags &= ~MIPS_HFLAG_AWRAP;",
"}",
"}",
"env->hflags |= MIPS_HFLAG_DM | MIPS_HFLAG_CP0;",
"env->hflags &= ~(MIPS_HFLAG_KSU);",
"if (!(env->CP0_Status & (1 << CP0St_EXL)))\nenv->CP0_Cause &= ~(1U << 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);",
"if (env->insn_flags & ISA_MIPS3) {",
"env->hflags |= MIPS_HFLAG_64;",
"if (!(env->insn_flags & ISA_MIPS64R6) ||\nenv->CP0_Status & (1 << CP0St_KX)) {",
"env->hflags &= ~MIPS_HFLAG_AWRAP;",
"}",
"}",
"env->hflags |= MIPS_HFLAG_CP0;",
"env->hflags &= ~(MIPS_HFLAG_KSU);",
"if (!(env->CP0_Status & (1 << CP0St_EXL)))\nenv->CP0_Cause &= ~(1U << 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)) {",
"uint32_t spacing = (env->CP0_IntCtl >> CP0IntCtl_VS) & 0x1f;",
"if ((env->CP0_Status & (1 << CP0St_BEV)) || spacing == 0) {",
"offset = 0x200;",
"} else {",
"uint32_t vector = 0;",
"uint32_t pending = (env->CP0_Cause & CP0Ca_IP_mask) >> CP0Ca_IP;",
"if (env->CP0_Config3 & (1 << CP0C3_VEIC)) {",
"vector = pending;",
"} else {",
"pending &= (env->CP0_Status >> CP0St_IM) & 0xff;",
"while (pending >>= 1) {",
"vector++;",
"}",
"}",
"offset = 0x200 + (vector * (spacing << 5));",
"}",
"}",
"goto set_EPC;",
"case EXCP_LTLBL:\nVAR_1 = 1;",
"update_badinstr = !(env->error_code & EXCP_INST_NOTAVAIL);",
"goto set_EPC;",
"case EXCP_TLBL:\nVAR_1 = 2;",
"update_badinstr = !(env->error_code & EXCP_INST_NOTAVAIL);",
"if ((env->error_code & EXCP_TLB_NOMATCH) &&\n!(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;",
"update_badinstr = 1;",
"if ((env->error_code & EXCP_TLB_NOMATCH) &&\n!(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;",
"update_badinstr = !(env->error_code & EXCP_INST_NOTAVAIL);",
"goto set_EPC;",
"case EXCP_AdES:\nVAR_1 = 5;",
"update_badinstr = 1;",
"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;",
"update_badinstr = 1;",
"goto set_EPC;",
"case EXCP_BREAK:\nVAR_1 = 9;",
"update_badinstr = 1;",
"goto set_EPC;",
"case EXCP_RI:\nVAR_1 = 10;",
"update_badinstr = 1;",
"goto set_EPC;",
"case EXCP_CpU:\nVAR_1 = 11;",
"update_badinstr = 1;",
"env->CP0_Cause = (env->CP0_Cause & ~(0x3 << CP0Ca_CE)) |\n(env->error_code << CP0Ca_CE);",
"goto set_EPC;",
"case EXCP_OVERFLOW:\nVAR_1 = 12;",
"update_badinstr = 1;",
"goto set_EPC;",
"case EXCP_TRAP:\nVAR_1 = 13;",
"update_badinstr = 1;",
"goto set_EPC;",
"case EXCP_MSAFPE:\nVAR_1 = 14;",
"update_badinstr = 1;",
"goto set_EPC;",
"case EXCP_FPE:\nVAR_1 = 15;",
"update_badinstr = 1;",
"goto set_EPC;",
"case EXCP_C2E:\nVAR_1 = 18;",
"goto set_EPC;",
"case EXCP_TLBRI:\nVAR_1 = 19;",
"update_badinstr = 1;",
"goto set_EPC;",
"case EXCP_TLBXI:\nVAR_1 = 20;",
"goto set_EPC;",
"case EXCP_MSADIS:\nVAR_1 = 21;",
"update_badinstr = 1;",
"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 (update_badinstr) {",
"set_badinstr_registers(env);",
"}",
"if (env->hflags & MIPS_HFLAG_BMASK) {",
"env->CP0_Cause |= (1U << CP0Ca_BD);",
"} else {",
"env->CP0_Cause &= ~(1U << CP0Ca_BD);",
"}",
"env->CP0_Status |= (1 << CP0St_EXL);",
"if (env->insn_flags & ISA_MIPS3) {",
"env->hflags |= MIPS_HFLAG_64;",
"if (!(env->insn_flags & ISA_MIPS64R6) ||\nenv->CP0_Status & (1 << CP0St_KX)) {",
"env->hflags &= ~MIPS_HFLAG_AWRAP;",
"}",
"}",
"env->hflags |= 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:\nabort();",
"}",
"if (qemu_loglevel_mask(CPU_LOG_INT)\n&& 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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37,
39,
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
79,
81
],
[
83
],
[
85,
87
],
[
89
],
[
91,
93
],
[
95
],
[
97,
99
],
[
101,
103
],
[
105
],
[
107,
109
],
[
111
],
[
113,
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129,
131
],
[
133
],
[
135
],
[
137
],
[
139,
141
],
[
143
],
[
145,
147
],
[
149
],
[
151
],
[
153,
155
],
[
157,
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169,
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183,
185
],
[
187
],
[
189
],
[
191
],
[
193,
195
],
[
197
],
[
199
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
215
],
[
221
],
[
223
],
[
229
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249,
251
],
[
253
],
[
255
],
[
257,
259
],
[
261
],
[
263,
265
],
[
267,
269
],
[
271
],
[
273
],
[
275
],
[
279,
281,
283
],
[
285,
287,
289
],
[
291
],
[
293
],
[
295,
297
],
[
299
],
[
301,
303
],
[
305,
307
],
[
309
],
[
311
],
[
313
],
[
317,
319,
321
],
[
323,
325,
327
],
[
329
],
[
331
],
[
333,
335
],
[
337
],
[
339
],
[
341,
343
],
[
345
],
[
347
],
[
349,
351
],
[
353
],
[
355,
357
],
[
359
],
[
361,
363
],
[
365
],
[
367
],
[
369,
371
],
[
373
],
[
375
],
[
377,
379
],
[
381
],
[
383
],
[
385,
387
],
[
389
],
[
391,
393
],
[
395
],
[
397,
399
],
[
401
],
[
403
],
[
405,
407
],
[
409
],
[
411
],
[
413,
415
],
[
417
],
[
419
],
[
421,
423
],
[
425
],
[
427
],
[
429,
431
],
[
433
],
[
435,
437
],
[
439
],
[
441
],
[
443,
445
],
[
447
],
[
449,
451
],
[
453
],
[
455
],
[
457,
459
],
[
461
],
[
463,
465
],
[
469
],
[
471,
473
],
[
475
],
[
477,
479
],
[
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
],
[
547
],
[
549
],
[
551
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563
],
[
565
],
[
567,
569
],
[
571
],
[
573,
575
],
[
577,
579,
581,
583,
585
],
[
587
],
[
589,
591
],
[
593
]
] |
18,242 | uri_resolve_relative (const char *uri, const char * base)
{
char *val = NULL;
int ret;
int ix;
int pos = 0;
int nbslash = 0;
int len;
URI *ref = NULL;
URI *bas = NULL;
char *bptr, *uptr, *vptr;
int remove_path = 0;
if ((uri == NULL) || (*uri == 0))
return NULL;
/*
* First parse URI into a standard form
*/
ref = uri_new ();
/* If URI not already in "relative" form */
if (uri[0] != '.') {
ret = uri_parse_into (ref, uri);
if (ret != 0)
goto done; /* Error in URI, return NULL */
} else
ref->path = g_strdup(uri);
/*
* Next parse base into the same standard form
*/
if ((base == NULL) || (*base == 0)) {
val = g_strdup (uri);
goto done;
}
bas = uri_new ();
if (base[0] != '.') {
ret = uri_parse_into (bas, base);
if (ret != 0)
goto done; /* Error in base, return NULL */
} else
bas->path = g_strdup(base);
/*
* If the scheme / server on the URI differs from the base,
* just return the URI
*/
if ((ref->scheme != NULL) &&
((bas->scheme == NULL) ||
(strcmp (bas->scheme, ref->scheme)) ||
(strcmp (bas->server, ref->server)))) {
val = g_strdup (uri);
goto done;
}
if (!strcmp(bas->path, ref->path)) {
val = g_strdup("");
goto done;
}
if (bas->path == NULL) {
val = g_strdup(ref->path);
goto done;
}
if (ref->path == NULL) {
ref->path = (char *) "/";
remove_path = 1;
}
/*
* At this point (at last!) we can compare the two paths
*
* First we take care of the special case where either of the
* two path components may be missing (bug 316224)
*/
if (bas->path == NULL) {
if (ref->path != NULL) {
uptr = ref->path;
if (*uptr == '/')
uptr++;
/* exception characters from uri_to_string */
val = uri_string_escape(uptr, "/;&=+$,");
}
goto done;
}
bptr = bas->path;
if (ref->path == NULL) {
for (ix = 0; bptr[ix] != 0; ix++) {
if (bptr[ix] == '/')
nbslash++;
}
uptr = NULL;
len = 1; /* this is for a string terminator only */
} else {
/*
* Next we compare the two strings and find where they first differ
*/
if ((ref->path[pos] == '.') && (ref->path[pos+1] == '/'))
pos += 2;
if ((*bptr == '.') && (bptr[1] == '/'))
bptr += 2;
else if ((*bptr == '/') && (ref->path[pos] != '/'))
bptr++;
while ((bptr[pos] == ref->path[pos]) && (bptr[pos] != 0))
pos++;
if (bptr[pos] == ref->path[pos]) {
val = g_strdup("");
goto done; /* (I can't imagine why anyone would do this) */
}
/*
* In URI, "back up" to the last '/' encountered. This will be the
* beginning of the "unique" suffix of URI
*/
ix = pos;
if ((ref->path[ix] == '/') && (ix > 0))
ix--;
else if ((ref->path[ix] == 0) && (ix > 1) && (ref->path[ix - 1] == '/'))
ix -= 2;
for (; ix > 0; ix--) {
if (ref->path[ix] == '/')
break;
}
if (ix == 0) {
uptr = ref->path;
} else {
ix++;
uptr = &ref->path[ix];
}
/*
* In base, count the number of '/' from the differing point
*/
if (bptr[pos] != ref->path[pos]) {/* check for trivial URI == base */
for (; bptr[ix] != 0; ix++) {
if (bptr[ix] == '/')
nbslash++;
}
}
len = strlen (uptr) + 1;
}
if (nbslash == 0) {
if (uptr != NULL)
/* exception characters from uri_to_string */
val = uri_string_escape(uptr, "/;&=+$,");
goto done;
}
/*
* Allocate just enough space for the returned string -
* length of the remainder of the URI, plus enough space
* for the "../" groups, plus one for the terminator
*/
val = g_malloc (len + 3 * nbslash);
vptr = val;
/*
* Put in as many "../" as needed
*/
for (; nbslash>0; nbslash--) {
*vptr++ = '.';
*vptr++ = '.';
*vptr++ = '/';
}
/*
* Finish up with the end of the URI
*/
if (uptr != NULL) {
if ((vptr > val) && (len > 0) &&
(uptr[0] == '/') && (vptr[-1] == '/')) {
memcpy (vptr, uptr + 1, len - 1);
vptr[len - 2] = 0;
} else {
memcpy (vptr, uptr, len);
vptr[len - 1] = 0;
}
} else {
vptr[len - 1] = 0;
}
/* escape the freshly-built path */
vptr = val;
/* exception characters from uri_to_string */
val = uri_string_escape(vptr, "/;&=+$,");
g_free(vptr);
done:
/*
* Free the working variables
*/
if (remove_path != 0)
ref->path = NULL;
if (ref != NULL)
uri_free (ref);
if (bas != NULL)
uri_free (bas);
return val;
}
| false | qemu | afb30dde3ad71349fc65726946d58e5d3c61f8af | uri_resolve_relative (const char *uri, const char * base)
{
char *val = NULL;
int ret;
int ix;
int pos = 0;
int nbslash = 0;
int len;
URI *ref = NULL;
URI *bas = NULL;
char *bptr, *uptr, *vptr;
int remove_path = 0;
if ((uri == NULL) || (*uri == 0))
return NULL;
ref = uri_new ();
if (uri[0] != '.') {
ret = uri_parse_into (ref, uri);
if (ret != 0)
goto done;
} else
ref->path = g_strdup(uri);
if ((base == NULL) || (*base == 0)) {
val = g_strdup (uri);
goto done;
}
bas = uri_new ();
if (base[0] != '.') {
ret = uri_parse_into (bas, base);
if (ret != 0)
goto done;
} else
bas->path = g_strdup(base);
if ((ref->scheme != NULL) &&
((bas->scheme == NULL) ||
(strcmp (bas->scheme, ref->scheme)) ||
(strcmp (bas->server, ref->server)))) {
val = g_strdup (uri);
goto done;
}
if (!strcmp(bas->path, ref->path)) {
val = g_strdup("");
goto done;
}
if (bas->path == NULL) {
val = g_strdup(ref->path);
goto done;
}
if (ref->path == NULL) {
ref->path = (char *) "/";
remove_path = 1;
}
if (bas->path == NULL) {
if (ref->path != NULL) {
uptr = ref->path;
if (*uptr == '/')
uptr++;
val = uri_string_escape(uptr, "/;&=+$,");
}
goto done;
}
bptr = bas->path;
if (ref->path == NULL) {
for (ix = 0; bptr[ix] != 0; ix++) {
if (bptr[ix] == '/')
nbslash++;
}
uptr = NULL;
len = 1;
} else {
if ((ref->path[pos] == '.') && (ref->path[pos+1] == '/'))
pos += 2;
if ((*bptr == '.') && (bptr[1] == '/'))
bptr += 2;
else if ((*bptr == '/') && (ref->path[pos] != '/'))
bptr++;
while ((bptr[pos] == ref->path[pos]) && (bptr[pos] != 0))
pos++;
if (bptr[pos] == ref->path[pos]) {
val = g_strdup("");
goto done;
}
ix = pos;
if ((ref->path[ix] == '/') && (ix > 0))
ix--;
else if ((ref->path[ix] == 0) && (ix > 1) && (ref->path[ix - 1] == '/'))
ix -= 2;
for (; ix > 0; ix--) {
if (ref->path[ix] == '/')
break;
}
if (ix == 0) {
uptr = ref->path;
} else {
ix++;
uptr = &ref->path[ix];
}
if (bptr[pos] != ref->path[pos]) {
for (; bptr[ix] != 0; ix++) {
if (bptr[ix] == '/')
nbslash++;
}
}
len = strlen (uptr) + 1;
}
if (nbslash == 0) {
if (uptr != NULL)
val = uri_string_escape(uptr, "/;&=+$,");
goto done;
}
val = g_malloc (len + 3 * nbslash);
vptr = val;
for (; nbslash>0; nbslash--) {
*vptr++ = '.';
*vptr++ = '.';
*vptr++ = '/';
}
if (uptr != NULL) {
if ((vptr > val) && (len > 0) &&
(uptr[0] == '/') && (vptr[-1] == '/')) {
memcpy (vptr, uptr + 1, len - 1);
vptr[len - 2] = 0;
} else {
memcpy (vptr, uptr, len);
vptr[len - 1] = 0;
}
} else {
vptr[len - 1] = 0;
}
vptr = val;
val = uri_string_escape(vptr, "/;&=+$,");
g_free(vptr);
done:
if (remove_path != 0)
ref->path = NULL;
if (ref != NULL)
uri_free (ref);
if (bas != NULL)
uri_free (bas);
return val;
}
| {
"code": [],
"line_no": []
} | FUNC_0 (const char *VAR_0, const char * VAR_1)
{
char *VAR_2 = NULL;
int VAR_3;
int VAR_4;
int VAR_5 = 0;
int VAR_6 = 0;
int VAR_7;
URI *ref = NULL;
URI *bas = NULL;
char *VAR_8, *VAR_9, *VAR_10;
int VAR_11 = 0;
if ((VAR_0 == NULL) || (*VAR_0 == 0))
return NULL;
ref = uri_new ();
if (VAR_0[0] != '.') {
VAR_3 = uri_parse_into (ref, VAR_0);
if (VAR_3 != 0)
goto done;
} else
ref->path = g_strdup(VAR_0);
if ((VAR_1 == NULL) || (*VAR_1 == 0)) {
VAR_2 = g_strdup (VAR_0);
goto done;
}
bas = uri_new ();
if (VAR_1[0] != '.') {
VAR_3 = uri_parse_into (bas, VAR_1);
if (VAR_3 != 0)
goto done;
} else
bas->path = g_strdup(VAR_1);
if ((ref->scheme != NULL) &&
((bas->scheme == NULL) ||
(strcmp (bas->scheme, ref->scheme)) ||
(strcmp (bas->server, ref->server)))) {
VAR_2 = g_strdup (VAR_0);
goto done;
}
if (!strcmp(bas->path, ref->path)) {
VAR_2 = g_strdup("");
goto done;
}
if (bas->path == NULL) {
VAR_2 = g_strdup(ref->path);
goto done;
}
if (ref->path == NULL) {
ref->path = (char *) "/";
VAR_11 = 1;
}
if (bas->path == NULL) {
if (ref->path != NULL) {
VAR_9 = ref->path;
if (*VAR_9 == '/')
VAR_9++;
VAR_2 = uri_string_escape(VAR_9, "/;&=+$,");
}
goto done;
}
VAR_8 = bas->path;
if (ref->path == NULL) {
for (VAR_4 = 0; VAR_8[VAR_4] != 0; VAR_4++) {
if (VAR_8[VAR_4] == '/')
VAR_6++;
}
VAR_9 = NULL;
VAR_7 = 1;
} else {
if ((ref->path[VAR_5] == '.') && (ref->path[VAR_5+1] == '/'))
VAR_5 += 2;
if ((*VAR_8 == '.') && (VAR_8[1] == '/'))
VAR_8 += 2;
else if ((*VAR_8 == '/') && (ref->path[VAR_5] != '/'))
VAR_8++;
while ((VAR_8[VAR_5] == ref->path[VAR_5]) && (VAR_8[VAR_5] != 0))
VAR_5++;
if (VAR_8[VAR_5] == ref->path[VAR_5]) {
VAR_2 = g_strdup("");
goto done;
}
VAR_4 = VAR_5;
if ((ref->path[VAR_4] == '/') && (VAR_4 > 0))
VAR_4--;
else if ((ref->path[VAR_4] == 0) && (VAR_4 > 1) && (ref->path[VAR_4 - 1] == '/'))
VAR_4 -= 2;
for (; VAR_4 > 0; VAR_4--) {
if (ref->path[VAR_4] == '/')
break;
}
if (VAR_4 == 0) {
VAR_9 = ref->path;
} else {
VAR_4++;
VAR_9 = &ref->path[VAR_4];
}
if (VAR_8[VAR_5] != ref->path[VAR_5]) {
for (; VAR_8[VAR_4] != 0; VAR_4++) {
if (VAR_8[VAR_4] == '/')
VAR_6++;
}
}
VAR_7 = strlen (VAR_9) + 1;
}
if (VAR_6 == 0) {
if (VAR_9 != NULL)
VAR_2 = uri_string_escape(VAR_9, "/;&=+$,");
goto done;
}
VAR_2 = g_malloc (VAR_7 + 3 * VAR_6);
VAR_10 = VAR_2;
for (; VAR_6>0; VAR_6--) {
*VAR_10++ = '.';
*VAR_10++ = '.';
*VAR_10++ = '/';
}
if (VAR_9 != NULL) {
if ((VAR_10 > VAR_2) && (VAR_7 > 0) &&
(VAR_9[0] == '/') && (VAR_10[-1] == '/')) {
memcpy (VAR_10, VAR_9 + 1, VAR_7 - 1);
VAR_10[VAR_7 - 2] = 0;
} else {
memcpy (VAR_10, VAR_9, VAR_7);
VAR_10[VAR_7 - 1] = 0;
}
} else {
VAR_10[VAR_7 - 1] = 0;
}
VAR_10 = VAR_2;
VAR_2 = uri_string_escape(VAR_10, "/;&=+$,");
g_free(VAR_10);
done:
if (VAR_11 != 0)
ref->path = NULL;
if (ref != NULL)
uri_free (ref);
if (bas != NULL)
uri_free (bas);
return VAR_2;
}
| [
"FUNC_0 (const char *VAR_0, const char * VAR_1)\n{",
"char *VAR_2 = NULL;",
"int VAR_3;",
"int VAR_4;",
"int VAR_5 = 0;",
"int VAR_6 = 0;",
"int VAR_7;",
"URI *ref = NULL;",
"URI *bas = NULL;",
"char *VAR_8, *VAR_9, *VAR_10;",
"int VAR_11 = 0;",
"if ((VAR_0 == NULL) || (*VAR_0 == 0))\nreturn NULL;",
"ref = uri_new ();",
"if (VAR_0[0] != '.') {",
"VAR_3 = uri_parse_into (ref, VAR_0);",
"if (VAR_3 != 0)\ngoto done;",
"} else",
"ref->path = g_strdup(VAR_0);",
"if ((VAR_1 == NULL) || (*VAR_1 == 0)) {",
"VAR_2 = g_strdup (VAR_0);",
"goto done;",
"}",
"bas = uri_new ();",
"if (VAR_1[0] != '.') {",
"VAR_3 = uri_parse_into (bas, VAR_1);",
"if (VAR_3 != 0)\ngoto done;",
"} else",
"bas->path = g_strdup(VAR_1);",
"if ((ref->scheme != NULL) &&\n((bas->scheme == NULL) ||\n(strcmp (bas->scheme, ref->scheme)) ||\n(strcmp (bas->server, ref->server)))) {",
"VAR_2 = g_strdup (VAR_0);",
"goto done;",
"}",
"if (!strcmp(bas->path, ref->path)) {",
"VAR_2 = g_strdup(\"\");",
"goto done;",
"}",
"if (bas->path == NULL) {",
"VAR_2 = g_strdup(ref->path);",
"goto done;",
"}",
"if (ref->path == NULL) {",
"ref->path = (char *) \"/\";",
"VAR_11 = 1;",
"}",
"if (bas->path == NULL) {",
"if (ref->path != NULL) {",
"VAR_9 = ref->path;",
"if (*VAR_9 == '/')\nVAR_9++;",
"VAR_2 = uri_string_escape(VAR_9, \"/;&=+$,\");",
"}",
"goto done;",
"}",
"VAR_8 = bas->path;",
"if (ref->path == NULL) {",
"for (VAR_4 = 0; VAR_8[VAR_4] != 0; VAR_4++) {",
"if (VAR_8[VAR_4] == '/')\nVAR_6++;",
"}",
"VAR_9 = NULL;",
"VAR_7 = 1;",
"} else {",
"if ((ref->path[VAR_5] == '.') && (ref->path[VAR_5+1] == '/'))\nVAR_5 += 2;",
"if ((*VAR_8 == '.') && (VAR_8[1] == '/'))\nVAR_8 += 2;",
"else if ((*VAR_8 == '/') && (ref->path[VAR_5] != '/'))\nVAR_8++;",
"while ((VAR_8[VAR_5] == ref->path[VAR_5]) && (VAR_8[VAR_5] != 0))\nVAR_5++;",
"if (VAR_8[VAR_5] == ref->path[VAR_5]) {",
"VAR_2 = g_strdup(\"\");",
"goto done;",
"}",
"VAR_4 = VAR_5;",
"if ((ref->path[VAR_4] == '/') && (VAR_4 > 0))\nVAR_4--;",
"else if ((ref->path[VAR_4] == 0) && (VAR_4 > 1) && (ref->path[VAR_4 - 1] == '/'))\nVAR_4 -= 2;",
"for (; VAR_4 > 0; VAR_4--) {",
"if (ref->path[VAR_4] == '/')\nbreak;",
"}",
"if (VAR_4 == 0) {",
"VAR_9 = ref->path;",
"} else {",
"VAR_4++;",
"VAR_9 = &ref->path[VAR_4];",
"}",
"if (VAR_8[VAR_5] != ref->path[VAR_5]) {",
"for (; VAR_8[VAR_4] != 0; VAR_4++) {",
"if (VAR_8[VAR_4] == '/')\nVAR_6++;",
"}",
"}",
"VAR_7 = strlen (VAR_9) + 1;",
"}",
"if (VAR_6 == 0) {",
"if (VAR_9 != NULL)\nVAR_2 = uri_string_escape(VAR_9, \"/;&=+$,\");",
"goto done;",
"}",
"VAR_2 = g_malloc (VAR_7 + 3 * VAR_6);",
"VAR_10 = VAR_2;",
"for (; VAR_6>0; VAR_6--) {",
"*VAR_10++ = '.';",
"*VAR_10++ = '.';",
"*VAR_10++ = '/';",
"}",
"if (VAR_9 != NULL) {",
"if ((VAR_10 > VAR_2) && (VAR_7 > 0) &&\n(VAR_9[0] == '/') && (VAR_10[-1] == '/')) {",
"memcpy (VAR_10, VAR_9 + 1, VAR_7 - 1);",
"VAR_10[VAR_7 - 2] = 0;",
"} else {",
"memcpy (VAR_10, VAR_9, VAR_7);",
"VAR_10[VAR_7 - 1] = 0;",
"}",
"} else {",
"VAR_10[VAR_7 - 1] = 0;",
"}",
"VAR_10 = VAR_2;",
"VAR_2 = uri_string_escape(VAR_10, \"/;&=+$,\");",
"g_free(VAR_10);",
"done:\nif (VAR_11 != 0)\nref->path = NULL;",
"if (ref != NULL)\nuri_free (ref);",
"if (bas != NULL)\nuri_free (bas);",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27,
29
],
[
39
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
95,
97,
99,
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
147
],
[
149
],
[
151
],
[
153,
155
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173,
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
191,
193
],
[
195,
197
],
[
199,
201
],
[
203,
205
],
[
209
],
[
211
],
[
213
],
[
215
],
[
227
],
[
229,
231
],
[
233,
235
],
[
237
],
[
239,
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
265
],
[
267
],
[
269,
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
283
],
[
285,
289
],
[
291
],
[
293
],
[
307
],
[
309
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
333
],
[
335,
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
361
],
[
365
],
[
367
],
[
371,
379,
381
],
[
383,
385
],
[
387,
389
],
[
393
],
[
395
]
] |
18,243 | static uint64_t omap_sti_fifo_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
OMAP_BAD_REG(addr);
return 0;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t omap_sti_fifo_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
OMAP_BAD_REG(addr);
return 0;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,
unsigned size)
{
OMAP_BAD_REG(addr);
return 0;
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{",
"OMAP_BAD_REG(addr);",
"return 0;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
]
] |
18,244 | static inline uint64_t hpet_calculate_diff(HPETTimer *t, uint64_t current)
{
if (t->config & HPET_TN_32BIT) {
uint32_t diff, cmp;
cmp = (uint32_t)t->cmp;
diff = cmp - (uint32_t)current;
diff = (int32_t)diff > 0 ? diff : (uint32_t)0;
return (uint64_t)diff;
} else {
uint64_t diff, cmp;
cmp = t->cmp;
diff = cmp - current;
diff = (int64_t)diff > 0 ? diff : (uint64_t)0;
return diff;
}
}
| false | qemu | 4f61927a41a098d06e642ffdea5fc285dc3a0e6b | static inline uint64_t hpet_calculate_diff(HPETTimer *t, uint64_t current)
{
if (t->config & HPET_TN_32BIT) {
uint32_t diff, cmp;
cmp = (uint32_t)t->cmp;
diff = cmp - (uint32_t)current;
diff = (int32_t)diff > 0 ? diff : (uint32_t)0;
return (uint64_t)diff;
} else {
uint64_t diff, cmp;
cmp = t->cmp;
diff = cmp - current;
diff = (int64_t)diff > 0 ? diff : (uint64_t)0;
return diff;
}
}
| {
"code": [],
"line_no": []
} | static inline uint64_t FUNC_0(HPETTimer *t, uint64_t current)
{
if (t->config & HPET_TN_32BIT) {
uint32_t diff, cmp;
cmp = (uint32_t)t->cmp;
diff = cmp - (uint32_t)current;
diff = (int32_t)diff > 0 ? diff : (uint32_t)0;
return (uint64_t)diff;
} else {
uint64_t diff, cmp;
cmp = t->cmp;
diff = cmp - current;
diff = (int64_t)diff > 0 ? diff : (uint64_t)0;
return diff;
}
}
| [
"static inline uint64_t FUNC_0(HPETTimer *t, uint64_t current)\n{",
"if (t->config & HPET_TN_32BIT) {",
"uint32_t diff, cmp;",
"cmp = (uint32_t)t->cmp;",
"diff = cmp - (uint32_t)current;",
"diff = (int32_t)diff > 0 ? diff : (uint32_t)0;",
"return (uint64_t)diff;",
"} else {",
"uint64_t diff, cmp;",
"cmp = t->cmp;",
"diff = cmp - current;",
"diff = (int64_t)diff > 0 ? diff : (uint64_t)0;",
"return diff;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
18,245 | static int mpc8_decode_frame(AVCodecContext * avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MPCContext *c = avctx->priv_data;
GetBitContext gb2, *gb = &gb2;
int i, j, k, ch, cnt, res, t;
Band *bands = c->bands;
int off;
int maxband, keyframe;
int last[2];
/* get output buffer */
c->frame.nb_samples = MPC_FRAME_SIZE;
if ((res = avctx->get_buffer(avctx, &c->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return res;
}
keyframe = c->cur_frame == 0;
if(keyframe){
memset(c->Q, 0, sizeof(c->Q));
c->last_bits_used = 0;
}
init_get_bits(gb, buf, buf_size * 8);
skip_bits(gb, c->last_bits_used & 7);
if(keyframe)
maxband = mpc8_get_mod_golomb(gb, c->maxbands + 1);
else{
maxband = c->last_max_band + get_vlc2(gb, band_vlc.table, MPC8_BANDS_BITS, 2);
if(maxband > 32) maxband -= 33;
}
if(maxband > c->maxbands + 1 || maxband >= BANDS) {
av_log(avctx, AV_LOG_ERROR, "maxband %d too large\n",maxband);
return AVERROR_INVALIDDATA;
}
c->last_max_band = maxband;
/* read subband indexes */
if(maxband){
last[0] = last[1] = 0;
for(i = maxband - 1; i >= 0; i--){
for(ch = 0; ch < 2; ch++){
last[ch] = get_vlc2(gb, res_vlc[last[ch] > 2].table, MPC8_RES_BITS, 2) + last[ch];
if(last[ch] > 15) last[ch] -= 17;
bands[i].res[ch] = last[ch];
}
}
if(c->MSS){
int mask;
cnt = 0;
for(i = 0; i < maxband; i++)
if(bands[i].res[0] || bands[i].res[1])
cnt++;
t = mpc8_get_mod_golomb(gb, cnt);
mask = mpc8_get_mask(gb, cnt, t);
for(i = maxband - 1; i >= 0; i--)
if(bands[i].res[0] || bands[i].res[1]){
bands[i].msf = mask & 1;
mask >>= 1;
}
}
}
for(i = maxband; i < c->maxbands; i++)
bands[i].res[0] = bands[i].res[1] = 0;
if(keyframe){
for(i = 0; i < 32; i++)
c->oldDSCF[0][i] = c->oldDSCF[1][i] = 1;
}
for(i = 0; i < maxband; i++){
if(bands[i].res[0] || bands[i].res[1]){
cnt = !!bands[i].res[0] + !!bands[i].res[1] - 1;
if(cnt >= 0){
t = get_vlc2(gb, scfi_vlc[cnt].table, scfi_vlc[cnt].bits, 1);
if(bands[i].res[0]) bands[i].scfi[0] = t >> (2 * cnt);
if(bands[i].res[1]) bands[i].scfi[1] = t & 3;
}
}
}
for(i = 0; i < maxband; i++){
for(ch = 0; ch < 2; ch++){
if(!bands[i].res[ch]) continue;
if(c->oldDSCF[ch][i]){
bands[i].scf_idx[ch][0] = get_bits(gb, 7) - 6;
c->oldDSCF[ch][i] = 0;
}else{
t = get_vlc2(gb, dscf_vlc[1].table, MPC8_DSCF1_BITS, 2);
if(t == 64)
t += get_bits(gb, 6);
bands[i].scf_idx[ch][0] = ((bands[i].scf_idx[ch][2] + t - 25) & 0x7F) - 6;
}
for(j = 0; j < 2; j++){
if((bands[i].scfi[ch] << j) & 2)
bands[i].scf_idx[ch][j + 1] = bands[i].scf_idx[ch][j];
else{
t = get_vlc2(gb, dscf_vlc[0].table, MPC8_DSCF0_BITS, 2);
if(t == 31)
t = 64 + get_bits(gb, 6);
bands[i].scf_idx[ch][j + 1] = ((bands[i].scf_idx[ch][j] + t - 25) & 0x7F) - 6;
}
}
}
}
for(i = 0, off = 0; i < maxband; i++, off += SAMPLES_PER_BAND){
for(ch = 0; ch < 2; ch++){
res = bands[i].res[ch];
switch(res){
case -1:
for(j = 0; j < SAMPLES_PER_BAND; j++)
c->Q[ch][off + j] = (av_lfg_get(&c->rnd) & 0x3FC) - 510;
break;
case 0:
break;
case 1:
for(j = 0; j < SAMPLES_PER_BAND; j += SAMPLES_PER_BAND / 2){
cnt = get_vlc2(gb, q1_vlc.table, MPC8_Q1_BITS, 2);
t = mpc8_get_mask(gb, 18, cnt);
for(k = 0; k < SAMPLES_PER_BAND / 2; k++, t <<= 1)
c->Q[ch][off + j + k] = (t & 0x20000) ? (get_bits1(gb) << 1) - 1 : 0;
}
break;
case 2:
cnt = 6;//2*mpc8_thres[res]
for(j = 0; j < SAMPLES_PER_BAND; j += 3){
t = get_vlc2(gb, q2_vlc[cnt > 3].table, MPC8_Q2_BITS, 2);
c->Q[ch][off + j + 0] = mpc8_idx50[t];
c->Q[ch][off + j + 1] = mpc8_idx51[t];
c->Q[ch][off + j + 2] = mpc8_idx52[t];
cnt = (cnt >> 1) + mpc8_huffq2[t];
}
break;
case 3:
case 4:
for(j = 0; j < SAMPLES_PER_BAND; j += 2){
t = get_vlc2(gb, q3_vlc[res - 3].table, MPC8_Q3_BITS, 2) + q3_offsets[res - 3];
c->Q[ch][off + j + 1] = t >> 4;
c->Q[ch][off + j + 0] = (t & 8) ? (t & 0xF) - 16 : (t & 0xF);
}
break;
case 5:
case 6:
case 7:
case 8:
cnt = 2 * mpc8_thres[res];
for(j = 0; j < SAMPLES_PER_BAND; j++){
t = get_vlc2(gb, quant_vlc[res - 5][cnt > mpc8_thres[res]].table, quant_vlc[res - 5][cnt > mpc8_thres[res]].bits, 2) + quant_offsets[res - 5];
c->Q[ch][off + j] = t;
cnt = (cnt >> 1) + FFABS(c->Q[ch][off + j]);
}
break;
default:
for(j = 0; j < SAMPLES_PER_BAND; j++){
c->Q[ch][off + j] = get_vlc2(gb, q9up_vlc.table, MPC8_Q9UP_BITS, 2);
if(res != 9){
c->Q[ch][off + j] <<= res - 9;
c->Q[ch][off + j] |= get_bits(gb, res - 9);
}
c->Q[ch][off + j] -= (1 << (res - 2)) - 1;
}
}
}
}
ff_mpc_dequantize_and_synth(c, maxband - 1, c->frame.data[0],
avctx->channels);
c->cur_frame++;
c->last_bits_used = get_bits_count(gb);
if(c->cur_frame >= c->frames)
c->cur_frame = 0;
*got_frame_ptr = 1;
*(AVFrame *)data = c->frame;
return c->cur_frame ? c->last_bits_used >> 3 : buf_size;
}
| false | FFmpeg | bb321245777a89426aa2131887497bd5eead1d2e | static int mpc8_decode_frame(AVCodecContext * avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MPCContext *c = avctx->priv_data;
GetBitContext gb2, *gb = &gb2;
int i, j, k, ch, cnt, res, t;
Band *bands = c->bands;
int off;
int maxband, keyframe;
int last[2];
c->frame.nb_samples = MPC_FRAME_SIZE;
if ((res = avctx->get_buffer(avctx, &c->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return res;
}
keyframe = c->cur_frame == 0;
if(keyframe){
memset(c->Q, 0, sizeof(c->Q));
c->last_bits_used = 0;
}
init_get_bits(gb, buf, buf_size * 8);
skip_bits(gb, c->last_bits_used & 7);
if(keyframe)
maxband = mpc8_get_mod_golomb(gb, c->maxbands + 1);
else{
maxband = c->last_max_band + get_vlc2(gb, band_vlc.table, MPC8_BANDS_BITS, 2);
if(maxband > 32) maxband -= 33;
}
if(maxband > c->maxbands + 1 || maxband >= BANDS) {
av_log(avctx, AV_LOG_ERROR, "maxband %d too large\n",maxband);
return AVERROR_INVALIDDATA;
}
c->last_max_band = maxband;
if(maxband){
last[0] = last[1] = 0;
for(i = maxband - 1; i >= 0; i--){
for(ch = 0; ch < 2; ch++){
last[ch] = get_vlc2(gb, res_vlc[last[ch] > 2].table, MPC8_RES_BITS, 2) + last[ch];
if(last[ch] > 15) last[ch] -= 17;
bands[i].res[ch] = last[ch];
}
}
if(c->MSS){
int mask;
cnt = 0;
for(i = 0; i < maxband; i++)
if(bands[i].res[0] || bands[i].res[1])
cnt++;
t = mpc8_get_mod_golomb(gb, cnt);
mask = mpc8_get_mask(gb, cnt, t);
for(i = maxband - 1; i >= 0; i--)
if(bands[i].res[0] || bands[i].res[1]){
bands[i].msf = mask & 1;
mask >>= 1;
}
}
}
for(i = maxband; i < c->maxbands; i++)
bands[i].res[0] = bands[i].res[1] = 0;
if(keyframe){
for(i = 0; i < 32; i++)
c->oldDSCF[0][i] = c->oldDSCF[1][i] = 1;
}
for(i = 0; i < maxband; i++){
if(bands[i].res[0] || bands[i].res[1]){
cnt = !!bands[i].res[0] + !!bands[i].res[1] - 1;
if(cnt >= 0){
t = get_vlc2(gb, scfi_vlc[cnt].table, scfi_vlc[cnt].bits, 1);
if(bands[i].res[0]) bands[i].scfi[0] = t >> (2 * cnt);
if(bands[i].res[1]) bands[i].scfi[1] = t & 3;
}
}
}
for(i = 0; i < maxband; i++){
for(ch = 0; ch < 2; ch++){
if(!bands[i].res[ch]) continue;
if(c->oldDSCF[ch][i]){
bands[i].scf_idx[ch][0] = get_bits(gb, 7) - 6;
c->oldDSCF[ch][i] = 0;
}else{
t = get_vlc2(gb, dscf_vlc[1].table, MPC8_DSCF1_BITS, 2);
if(t == 64)
t += get_bits(gb, 6);
bands[i].scf_idx[ch][0] = ((bands[i].scf_idx[ch][2] + t - 25) & 0x7F) - 6;
}
for(j = 0; j < 2; j++){
if((bands[i].scfi[ch] << j) & 2)
bands[i].scf_idx[ch][j + 1] = bands[i].scf_idx[ch][j];
else{
t = get_vlc2(gb, dscf_vlc[0].table, MPC8_DSCF0_BITS, 2);
if(t == 31)
t = 64 + get_bits(gb, 6);
bands[i].scf_idx[ch][j + 1] = ((bands[i].scf_idx[ch][j] + t - 25) & 0x7F) - 6;
}
}
}
}
for(i = 0, off = 0; i < maxband; i++, off += SAMPLES_PER_BAND){
for(ch = 0; ch < 2; ch++){
res = bands[i].res[ch];
switch(res){
case -1:
for(j = 0; j < SAMPLES_PER_BAND; j++)
c->Q[ch][off + j] = (av_lfg_get(&c->rnd) & 0x3FC) - 510;
break;
case 0:
break;
case 1:
for(j = 0; j < SAMPLES_PER_BAND; j += SAMPLES_PER_BAND / 2){
cnt = get_vlc2(gb, q1_vlc.table, MPC8_Q1_BITS, 2);
t = mpc8_get_mask(gb, 18, cnt);
for(k = 0; k < SAMPLES_PER_BAND / 2; k++, t <<= 1)
c->Q[ch][off + j + k] = (t & 0x20000) ? (get_bits1(gb) << 1) - 1 : 0;
}
break;
case 2:
cnt = 6;
for(j = 0; j < SAMPLES_PER_BAND; j += 3){
t = get_vlc2(gb, q2_vlc[cnt > 3].table, MPC8_Q2_BITS, 2);
c->Q[ch][off + j + 0] = mpc8_idx50[t];
c->Q[ch][off + j + 1] = mpc8_idx51[t];
c->Q[ch][off + j + 2] = mpc8_idx52[t];
cnt = (cnt >> 1) + mpc8_huffq2[t];
}
break;
case 3:
case 4:
for(j = 0; j < SAMPLES_PER_BAND; j += 2){
t = get_vlc2(gb, q3_vlc[res - 3].table, MPC8_Q3_BITS, 2) + q3_offsets[res - 3];
c->Q[ch][off + j + 1] = t >> 4;
c->Q[ch][off + j + 0] = (t & 8) ? (t & 0xF) - 16 : (t & 0xF);
}
break;
case 5:
case 6:
case 7:
case 8:
cnt = 2 * mpc8_thres[res];
for(j = 0; j < SAMPLES_PER_BAND; j++){
t = get_vlc2(gb, quant_vlc[res - 5][cnt > mpc8_thres[res]].table, quant_vlc[res - 5][cnt > mpc8_thres[res]].bits, 2) + quant_offsets[res - 5];
c->Q[ch][off + j] = t;
cnt = (cnt >> 1) + FFABS(c->Q[ch][off + j]);
}
break;
default:
for(j = 0; j < SAMPLES_PER_BAND; j++){
c->Q[ch][off + j] = get_vlc2(gb, q9up_vlc.table, MPC8_Q9UP_BITS, 2);
if(res != 9){
c->Q[ch][off + j] <<= res - 9;
c->Q[ch][off + j] |= get_bits(gb, res - 9);
}
c->Q[ch][off + j] -= (1 << (res - 2)) - 1;
}
}
}
}
ff_mpc_dequantize_and_synth(c, maxband - 1, c->frame.data[0],
avctx->channels);
c->cur_frame++;
c->last_bits_used = get_bits_count(gb);
if(c->cur_frame >= c->frames)
c->cur_frame = 0;
*got_frame_ptr = 1;
*(AVFrame *)data = c->frame;
return c->cur_frame ? c->last_bits_used >> 3 : buf_size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext * VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
MPCContext *c = VAR_0->priv_data;
GetBitContext gb2, *gb = &gb2;
int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;
Band *bands = c->bands;
int VAR_13;
int VAR_14, VAR_15;
int VAR_16[2];
c->frame.nb_samples = MPC_FRAME_SIZE;
if ((VAR_11 = VAR_0->get_buffer(VAR_0, &c->frame)) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");
return VAR_11;
}
VAR_15 = c->cur_frame == 0;
if(VAR_15){
memset(c->Q, 0, sizeof(c->Q));
c->last_bits_used = 0;
}
init_get_bits(gb, VAR_4, VAR_5 * 8);
skip_bits(gb, c->last_bits_used & 7);
if(VAR_15)
VAR_14 = mpc8_get_mod_golomb(gb, c->maxbands + 1);
else{
VAR_14 = c->last_max_band + get_vlc2(gb, band_vlc.table, MPC8_BANDS_BITS, 2);
if(VAR_14 > 32) VAR_14 -= 33;
}
if(VAR_14 > c->maxbands + 1 || VAR_14 >= BANDS) {
av_log(VAR_0, AV_LOG_ERROR, "VAR_14 %d too large\n",VAR_14);
return AVERROR_INVALIDDATA;
}
c->last_max_band = VAR_14;
if(VAR_14){
VAR_16[0] = VAR_16[1] = 0;
for(VAR_6 = VAR_14 - 1; VAR_6 >= 0; VAR_6--){
for(VAR_9 = 0; VAR_9 < 2; VAR_9++){
VAR_16[VAR_9] = get_vlc2(gb, res_vlc[VAR_16[VAR_9] > 2].table, MPC8_RES_BITS, 2) + VAR_16[VAR_9];
if(VAR_16[VAR_9] > 15) VAR_16[VAR_9] -= 17;
bands[VAR_6].VAR_11[VAR_9] = VAR_16[VAR_9];
}
}
if(c->MSS){
int VAR_17;
VAR_10 = 0;
for(VAR_6 = 0; VAR_6 < VAR_14; VAR_6++)
if(bands[VAR_6].VAR_11[0] || bands[VAR_6].VAR_11[1])
VAR_10++;
VAR_12 = mpc8_get_mod_golomb(gb, VAR_10);
VAR_17 = mpc8_get_mask(gb, VAR_10, VAR_12);
for(VAR_6 = VAR_14 - 1; VAR_6 >= 0; VAR_6--)
if(bands[VAR_6].VAR_11[0] || bands[VAR_6].VAR_11[1]){
bands[VAR_6].msf = VAR_17 & 1;
VAR_17 >>= 1;
}
}
}
for(VAR_6 = VAR_14; VAR_6 < c->maxbands; VAR_6++)
bands[VAR_6].VAR_11[0] = bands[VAR_6].VAR_11[1] = 0;
if(VAR_15){
for(VAR_6 = 0; VAR_6 < 32; VAR_6++)
c->oldDSCF[0][VAR_6] = c->oldDSCF[1][VAR_6] = 1;
}
for(VAR_6 = 0; VAR_6 < VAR_14; VAR_6++){
if(bands[VAR_6].VAR_11[0] || bands[VAR_6].VAR_11[1]){
VAR_10 = !!bands[VAR_6].VAR_11[0] + !!bands[VAR_6].VAR_11[1] - 1;
if(VAR_10 >= 0){
VAR_12 = get_vlc2(gb, scfi_vlc[VAR_10].table, scfi_vlc[VAR_10].bits, 1);
if(bands[VAR_6].VAR_11[0]) bands[VAR_6].scfi[0] = VAR_12 >> (2 * VAR_10);
if(bands[VAR_6].VAR_11[1]) bands[VAR_6].scfi[1] = VAR_12 & 3;
}
}
}
for(VAR_6 = 0; VAR_6 < VAR_14; VAR_6++){
for(VAR_9 = 0; VAR_9 < 2; VAR_9++){
if(!bands[VAR_6].VAR_11[VAR_9]) continue;
if(c->oldDSCF[VAR_9][VAR_6]){
bands[VAR_6].scf_idx[VAR_9][0] = get_bits(gb, 7) - 6;
c->oldDSCF[VAR_9][VAR_6] = 0;
}else{
VAR_12 = get_vlc2(gb, dscf_vlc[1].table, MPC8_DSCF1_BITS, 2);
if(VAR_12 == 64)
VAR_12 += get_bits(gb, 6);
bands[VAR_6].scf_idx[VAR_9][0] = ((bands[VAR_6].scf_idx[VAR_9][2] + VAR_12 - 25) & 0x7F) - 6;
}
for(VAR_7 = 0; VAR_7 < 2; VAR_7++){
if((bands[VAR_6].scfi[VAR_9] << VAR_7) & 2)
bands[VAR_6].scf_idx[VAR_9][VAR_7 + 1] = bands[VAR_6].scf_idx[VAR_9][VAR_7];
else{
VAR_12 = get_vlc2(gb, dscf_vlc[0].table, MPC8_DSCF0_BITS, 2);
if(VAR_12 == 31)
VAR_12 = 64 + get_bits(gb, 6);
bands[VAR_6].scf_idx[VAR_9][VAR_7 + 1] = ((bands[VAR_6].scf_idx[VAR_9][VAR_7] + VAR_12 - 25) & 0x7F) - 6;
}
}
}
}
for(VAR_6 = 0, VAR_13 = 0; VAR_6 < VAR_14; VAR_6++, VAR_13 += SAMPLES_PER_BAND){
for(VAR_9 = 0; VAR_9 < 2; VAR_9++){
VAR_11 = bands[VAR_6].VAR_11[VAR_9];
switch(VAR_11){
case -1:
for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7++)
c->Q[VAR_9][VAR_13 + VAR_7] = (av_lfg_get(&c->rnd) & 0x3FC) - 510;
break;
case 0:
break;
case 1:
for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7 += SAMPLES_PER_BAND / 2){
VAR_10 = get_vlc2(gb, q1_vlc.table, MPC8_Q1_BITS, 2);
VAR_12 = mpc8_get_mask(gb, 18, VAR_10);
for(VAR_8 = 0; VAR_8 < SAMPLES_PER_BAND / 2; VAR_8++, VAR_12 <<= 1)
c->Q[VAR_9][VAR_13 + VAR_7 + VAR_8] = (VAR_12 & 0x20000) ? (get_bits1(gb) << 1) - 1 : 0;
}
break;
case 2:
VAR_10 = 6;
for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7 += 3){
VAR_12 = get_vlc2(gb, q2_vlc[VAR_10 > 3].table, MPC8_Q2_BITS, 2);
c->Q[VAR_9][VAR_13 + VAR_7 + 0] = mpc8_idx50[VAR_12];
c->Q[VAR_9][VAR_13 + VAR_7 + 1] = mpc8_idx51[VAR_12];
c->Q[VAR_9][VAR_13 + VAR_7 + 2] = mpc8_idx52[VAR_12];
VAR_10 = (VAR_10 >> 1) + mpc8_huffq2[VAR_12];
}
break;
case 3:
case 4:
for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7 += 2){
VAR_12 = get_vlc2(gb, q3_vlc[VAR_11 - 3].table, MPC8_Q3_BITS, 2) + q3_offsets[VAR_11 - 3];
c->Q[VAR_9][VAR_13 + VAR_7 + 1] = VAR_12 >> 4;
c->Q[VAR_9][VAR_13 + VAR_7 + 0] = (VAR_12 & 8) ? (VAR_12 & 0xF) - 16 : (VAR_12 & 0xF);
}
break;
case 5:
case 6:
case 7:
case 8:
VAR_10 = 2 * mpc8_thres[VAR_11];
for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7++){
VAR_12 = get_vlc2(gb, quant_vlc[VAR_11 - 5][VAR_10 > mpc8_thres[VAR_11]].table, quant_vlc[VAR_11 - 5][VAR_10 > mpc8_thres[VAR_11]].bits, 2) + quant_offsets[VAR_11 - 5];
c->Q[VAR_9][VAR_13 + VAR_7] = VAR_12;
VAR_10 = (VAR_10 >> 1) + FFABS(c->Q[VAR_9][VAR_13 + VAR_7]);
}
break;
default:
for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7++){
c->Q[VAR_9][VAR_13 + VAR_7] = get_vlc2(gb, q9up_vlc.table, MPC8_Q9UP_BITS, 2);
if(VAR_11 != 9){
c->Q[VAR_9][VAR_13 + VAR_7] <<= VAR_11 - 9;
c->Q[VAR_9][VAR_13 + VAR_7] |= get_bits(gb, VAR_11 - 9);
}
c->Q[VAR_9][VAR_13 + VAR_7] -= (1 << (VAR_11 - 2)) - 1;
}
}
}
}
ff_mpc_dequantize_and_synth(c, VAR_14 - 1, c->frame.VAR_1[0],
VAR_0->channels);
c->cur_frame++;
c->last_bits_used = get_bits_count(gb);
if(c->cur_frame >= c->frames)
c->cur_frame = 0;
*VAR_2 = 1;
*(AVFrame *)VAR_1 = c->frame;
return c->cur_frame ? c->last_bits_used >> 3 : VAR_5;
}
| [
"static int FUNC_0(AVCodecContext * VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"MPCContext *c = VAR_0->priv_data;",
"GetBitContext gb2, *gb = &gb2;",
"int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;",
"Band *bands = c->bands;",
"int VAR_13;",
"int VAR_14, VAR_15;",
"int VAR_16[2];",
"c->frame.nb_samples = MPC_FRAME_SIZE;",
"if ((VAR_11 = VAR_0->get_buffer(VAR_0, &c->frame)) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\n\");",
"return VAR_11;",
"}",
"VAR_15 = c->cur_frame == 0;",
"if(VAR_15){",
"memset(c->Q, 0, sizeof(c->Q));",
"c->last_bits_used = 0;",
"}",
"init_get_bits(gb, VAR_4, VAR_5 * 8);",
"skip_bits(gb, c->last_bits_used & 7);",
"if(VAR_15)\nVAR_14 = mpc8_get_mod_golomb(gb, c->maxbands + 1);",
"else{",
"VAR_14 = c->last_max_band + get_vlc2(gb, band_vlc.table, MPC8_BANDS_BITS, 2);",
"if(VAR_14 > 32) VAR_14 -= 33;",
"}",
"if(VAR_14 > c->maxbands + 1 || VAR_14 >= BANDS) {",
"av_log(VAR_0, AV_LOG_ERROR, \"VAR_14 %d too large\\n\",VAR_14);",
"return AVERROR_INVALIDDATA;",
"}",
"c->last_max_band = VAR_14;",
"if(VAR_14){",
"VAR_16[0] = VAR_16[1] = 0;",
"for(VAR_6 = VAR_14 - 1; VAR_6 >= 0; VAR_6--){",
"for(VAR_9 = 0; VAR_9 < 2; VAR_9++){",
"VAR_16[VAR_9] = get_vlc2(gb, res_vlc[VAR_16[VAR_9] > 2].table, MPC8_RES_BITS, 2) + VAR_16[VAR_9];",
"if(VAR_16[VAR_9] > 15) VAR_16[VAR_9] -= 17;",
"bands[VAR_6].VAR_11[VAR_9] = VAR_16[VAR_9];",
"}",
"}",
"if(c->MSS){",
"int VAR_17;",
"VAR_10 = 0;",
"for(VAR_6 = 0; VAR_6 < VAR_14; VAR_6++)",
"if(bands[VAR_6].VAR_11[0] || bands[VAR_6].VAR_11[1])\nVAR_10++;",
"VAR_12 = mpc8_get_mod_golomb(gb, VAR_10);",
"VAR_17 = mpc8_get_mask(gb, VAR_10, VAR_12);",
"for(VAR_6 = VAR_14 - 1; VAR_6 >= 0; VAR_6--)",
"if(bands[VAR_6].VAR_11[0] || bands[VAR_6].VAR_11[1]){",
"bands[VAR_6].msf = VAR_17 & 1;",
"VAR_17 >>= 1;",
"}",
"}",
"}",
"for(VAR_6 = VAR_14; VAR_6 < c->maxbands; VAR_6++)",
"bands[VAR_6].VAR_11[0] = bands[VAR_6].VAR_11[1] = 0;",
"if(VAR_15){",
"for(VAR_6 = 0; VAR_6 < 32; VAR_6++)",
"c->oldDSCF[0][VAR_6] = c->oldDSCF[1][VAR_6] = 1;",
"}",
"for(VAR_6 = 0; VAR_6 < VAR_14; VAR_6++){",
"if(bands[VAR_6].VAR_11[0] || bands[VAR_6].VAR_11[1]){",
"VAR_10 = !!bands[VAR_6].VAR_11[0] + !!bands[VAR_6].VAR_11[1] - 1;",
"if(VAR_10 >= 0){",
"VAR_12 = get_vlc2(gb, scfi_vlc[VAR_10].table, scfi_vlc[VAR_10].bits, 1);",
"if(bands[VAR_6].VAR_11[0]) bands[VAR_6].scfi[0] = VAR_12 >> (2 * VAR_10);",
"if(bands[VAR_6].VAR_11[1]) bands[VAR_6].scfi[1] = VAR_12 & 3;",
"}",
"}",
"}",
"for(VAR_6 = 0; VAR_6 < VAR_14; VAR_6++){",
"for(VAR_9 = 0; VAR_9 < 2; VAR_9++){",
"if(!bands[VAR_6].VAR_11[VAR_9]) continue;",
"if(c->oldDSCF[VAR_9][VAR_6]){",
"bands[VAR_6].scf_idx[VAR_9][0] = get_bits(gb, 7) - 6;",
"c->oldDSCF[VAR_9][VAR_6] = 0;",
"}else{",
"VAR_12 = get_vlc2(gb, dscf_vlc[1].table, MPC8_DSCF1_BITS, 2);",
"if(VAR_12 == 64)\nVAR_12 += get_bits(gb, 6);",
"bands[VAR_6].scf_idx[VAR_9][0] = ((bands[VAR_6].scf_idx[VAR_9][2] + VAR_12 - 25) & 0x7F) - 6;",
"}",
"for(VAR_7 = 0; VAR_7 < 2; VAR_7++){",
"if((bands[VAR_6].scfi[VAR_9] << VAR_7) & 2)\nbands[VAR_6].scf_idx[VAR_9][VAR_7 + 1] = bands[VAR_6].scf_idx[VAR_9][VAR_7];",
"else{",
"VAR_12 = get_vlc2(gb, dscf_vlc[0].table, MPC8_DSCF0_BITS, 2);",
"if(VAR_12 == 31)\nVAR_12 = 64 + get_bits(gb, 6);",
"bands[VAR_6].scf_idx[VAR_9][VAR_7 + 1] = ((bands[VAR_6].scf_idx[VAR_9][VAR_7] + VAR_12 - 25) & 0x7F) - 6;",
"}",
"}",
"}",
"}",
"for(VAR_6 = 0, VAR_13 = 0; VAR_6 < VAR_14; VAR_6++, VAR_13 += SAMPLES_PER_BAND){",
"for(VAR_9 = 0; VAR_9 < 2; VAR_9++){",
"VAR_11 = bands[VAR_6].VAR_11[VAR_9];",
"switch(VAR_11){",
"case -1:\nfor(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7++)",
"c->Q[VAR_9][VAR_13 + VAR_7] = (av_lfg_get(&c->rnd) & 0x3FC) - 510;",
"break;",
"case 0:\nbreak;",
"case 1:\nfor(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7 += SAMPLES_PER_BAND / 2){",
"VAR_10 = get_vlc2(gb, q1_vlc.table, MPC8_Q1_BITS, 2);",
"VAR_12 = mpc8_get_mask(gb, 18, VAR_10);",
"for(VAR_8 = 0; VAR_8 < SAMPLES_PER_BAND / 2; VAR_8++, VAR_12 <<= 1)",
"c->Q[VAR_9][VAR_13 + VAR_7 + VAR_8] = (VAR_12 & 0x20000) ? (get_bits1(gb) << 1) - 1 : 0;",
"}",
"break;",
"case 2:\nVAR_10 = 6;",
"for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7 += 3){",
"VAR_12 = get_vlc2(gb, q2_vlc[VAR_10 > 3].table, MPC8_Q2_BITS, 2);",
"c->Q[VAR_9][VAR_13 + VAR_7 + 0] = mpc8_idx50[VAR_12];",
"c->Q[VAR_9][VAR_13 + VAR_7 + 1] = mpc8_idx51[VAR_12];",
"c->Q[VAR_9][VAR_13 + VAR_7 + 2] = mpc8_idx52[VAR_12];",
"VAR_10 = (VAR_10 >> 1) + mpc8_huffq2[VAR_12];",
"}",
"break;",
"case 3:\ncase 4:\nfor(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7 += 2){",
"VAR_12 = get_vlc2(gb, q3_vlc[VAR_11 - 3].table, MPC8_Q3_BITS, 2) + q3_offsets[VAR_11 - 3];",
"c->Q[VAR_9][VAR_13 + VAR_7 + 1] = VAR_12 >> 4;",
"c->Q[VAR_9][VAR_13 + VAR_7 + 0] = (VAR_12 & 8) ? (VAR_12 & 0xF) - 16 : (VAR_12 & 0xF);",
"}",
"break;",
"case 5:\ncase 6:\ncase 7:\ncase 8:\nVAR_10 = 2 * mpc8_thres[VAR_11];",
"for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7++){",
"VAR_12 = get_vlc2(gb, quant_vlc[VAR_11 - 5][VAR_10 > mpc8_thres[VAR_11]].table, quant_vlc[VAR_11 - 5][VAR_10 > mpc8_thres[VAR_11]].bits, 2) + quant_offsets[VAR_11 - 5];",
"c->Q[VAR_9][VAR_13 + VAR_7] = VAR_12;",
"VAR_10 = (VAR_10 >> 1) + FFABS(c->Q[VAR_9][VAR_13 + VAR_7]);",
"}",
"break;",
"default:\nfor(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7++){",
"c->Q[VAR_9][VAR_13 + VAR_7] = get_vlc2(gb, q9up_vlc.table, MPC8_Q9UP_BITS, 2);",
"if(VAR_11 != 9){",
"c->Q[VAR_9][VAR_13 + VAR_7] <<= VAR_11 - 9;",
"c->Q[VAR_9][VAR_13 + VAR_7] |= get_bits(gb, VAR_11 - 9);",
"}",
"c->Q[VAR_9][VAR_13 + VAR_7] -= (1 << (VAR_11 - 2)) - 1;",
"}",
"}",
"}",
"}",
"ff_mpc_dequantize_and_synth(c, VAR_14 - 1, c->frame.VAR_1[0],\nVAR_0->channels);",
"c->cur_frame++;",
"c->last_bits_used = get_bits_count(gb);",
"if(c->cur_frame >= c->frames)\nc->cur_frame = 0;",
"*VAR_2 = 1;",
"*(AVFrame *)VAR_1 = c->frame;",
"return c->cur_frame ? c->last_bits_used >> 3 : VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193,
195
],
[
197
],
[
199
],
[
201
],
[
203,
205
],
[
207
],
[
209
],
[
211,
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235,
237
],
[
239
],
[
241
],
[
243,
245
],
[
247,
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263,
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283,
285,
287
],
[
289
],
[
291
],
[
293
],
[
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
],
[
347,
349
],
[
353
],
[
357
],
[
359,
361
],
[
365
],
[
367
],
[
371
],
[
373
]
] |
18,246 | int configure_accelerator(MachineState *ms)
{
const char *p;
char buf[10];
int ret;
bool accel_initialised = false;
bool init_failed = false;
AccelClass *acc = NULL;
p = qemu_opt_get(qemu_get_machine_opts(), "accel");
if (p == NULL) {
/* Use the default "accelerator", tcg */
p = "tcg";
}
while (!accel_initialised && *p != '\0') {
if (*p == ':') {
p++;
}
p = get_opt_name(buf, sizeof(buf), p, ':');
acc = accel_find(buf);
if (!acc) {
fprintf(stderr, "\"%s\" accelerator not found.\n", buf);
continue;
}
if (acc->available && !acc->available()) {
printf("%s not supported for this target\n",
acc->name);
continue;
}
ret = accel_init_machine(acc, ms);
if (ret < 0) {
init_failed = true;
fprintf(stderr, "failed to initialize %s: %s\n",
acc->name,
strerror(-ret));
} else {
accel_initialised = true;
}
}
if (!accel_initialised) {
if (!init_failed) {
fprintf(stderr, "No accelerator found!\n");
}
exit(1);
}
if (init_failed) {
fprintf(stderr, "Back to %s accelerator.\n", acc->name);
}
return !accel_initialised;
}
| false | qemu | bdc3f61dec2f9c227235bb5f677a0272e1184c82 | int configure_accelerator(MachineState *ms)
{
const char *p;
char buf[10];
int ret;
bool accel_initialised = false;
bool init_failed = false;
AccelClass *acc = NULL;
p = qemu_opt_get(qemu_get_machine_opts(), "accel");
if (p == NULL) {
p = "tcg";
}
while (!accel_initialised && *p != '\0') {
if (*p == ':') {
p++;
}
p = get_opt_name(buf, sizeof(buf), p, ':');
acc = accel_find(buf);
if (!acc) {
fprintf(stderr, "\"%s\" accelerator not found.\n", buf);
continue;
}
if (acc->available && !acc->available()) {
printf("%s not supported for this target\n",
acc->name);
continue;
}
ret = accel_init_machine(acc, ms);
if (ret < 0) {
init_failed = true;
fprintf(stderr, "failed to initialize %s: %s\n",
acc->name,
strerror(-ret));
} else {
accel_initialised = true;
}
}
if (!accel_initialised) {
if (!init_failed) {
fprintf(stderr, "No accelerator found!\n");
}
exit(1);
}
if (init_failed) {
fprintf(stderr, "Back to %s accelerator.\n", acc->name);
}
return !accel_initialised;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(MachineState *VAR_0)
{
const char *VAR_1;
char VAR_2[10];
int VAR_3;
bool accel_initialised = false;
bool init_failed = false;
AccelClass *acc = NULL;
VAR_1 = qemu_opt_get(qemu_get_machine_opts(), "accel");
if (VAR_1 == NULL) {
VAR_1 = "tcg";
}
while (!accel_initialised && *VAR_1 != '\0') {
if (*VAR_1 == ':') {
VAR_1++;
}
VAR_1 = get_opt_name(VAR_2, sizeof(VAR_2), VAR_1, ':');
acc = accel_find(VAR_2);
if (!acc) {
fprintf(stderr, "\"%s\" accelerator not found.\n", VAR_2);
continue;
}
if (acc->available && !acc->available()) {
printf("%s not supported for this target\n",
acc->name);
continue;
}
VAR_3 = accel_init_machine(acc, VAR_0);
if (VAR_3 < 0) {
init_failed = true;
fprintf(stderr, "failed to initialize %s: %s\n",
acc->name,
strerror(-VAR_3));
} else {
accel_initialised = true;
}
}
if (!accel_initialised) {
if (!init_failed) {
fprintf(stderr, "No accelerator found!\n");
}
exit(1);
}
if (init_failed) {
fprintf(stderr, "Back to %s accelerator.\n", acc->name);
}
return !accel_initialised;
}
| [
"int FUNC_0(MachineState *VAR_0)\n{",
"const char *VAR_1;",
"char VAR_2[10];",
"int VAR_3;",
"bool accel_initialised = false;",
"bool init_failed = false;",
"AccelClass *acc = NULL;",
"VAR_1 = qemu_opt_get(qemu_get_machine_opts(), \"accel\");",
"if (VAR_1 == NULL) {",
"VAR_1 = \"tcg\";",
"}",
"while (!accel_initialised && *VAR_1 != '\\0') {",
"if (*VAR_1 == ':') {",
"VAR_1++;",
"}",
"VAR_1 = get_opt_name(VAR_2, sizeof(VAR_2), VAR_1, ':');",
"acc = accel_find(VAR_2);",
"if (!acc) {",
"fprintf(stderr, \"\\\"%s\\\" accelerator not found.\\n\", VAR_2);",
"continue;",
"}",
"if (acc->available && !acc->available()) {",
"printf(\"%s not supported for this target\\n\",\nacc->name);",
"continue;",
"}",
"VAR_3 = accel_init_machine(acc, VAR_0);",
"if (VAR_3 < 0) {",
"init_failed = true;",
"fprintf(stderr, \"failed to initialize %s: %s\\n\",\nacc->name,\nstrerror(-VAR_3));",
"} else {",
"accel_initialised = true;",
"}",
"}",
"if (!accel_initialised) {",
"if (!init_failed) {",
"fprintf(stderr, \"No accelerator found!\\n\");",
"}",
"exit(1);",
"}",
"if (init_failed) {",
"fprintf(stderr, \"Back to %s accelerator.\\n\", acc->name);",
"}",
"return !accel_initialised;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67,
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
]
] |
18,247 | int bdrv_snapshot_goto(BlockDriverState *bs,
const char *snapshot_id,
Error **errp)
{
BlockDriver *drv = bs->drv;
int ret, open_ret;
int64_t len;
if (!drv) {
error_setg(errp, "Block driver is closed");
return -ENOMEDIUM;
}
len = bdrv_getlength(bs);
if (len < 0) {
error_setg_errno(errp, -len, "Cannot get block device size");
return len;
}
/* We should set all bits in all enabled dirty bitmaps, because dirty
* bitmaps reflect active state of disk and snapshot switch operation
* actually dirties active state.
* TODO: It may make sense not to set all bits but analyze block status of
* current state and destination snapshot and do not set bits corresponding
* to both-zero or both-unallocated areas. */
bdrv_set_dirty(bs, 0, len);
if (drv->bdrv_snapshot_goto) {
ret = drv->bdrv_snapshot_goto(bs, snapshot_id);
if (ret < 0) {
error_setg_errno(errp, -ret, "Failed to load snapshot");
}
return ret;
}
if (bs->file) {
BlockDriverState *file;
QDict *options = qdict_clone_shallow(bs->options);
QDict *file_options;
Error *local_err = NULL;
file = bs->file->bs;
/* Prevent it from getting deleted when detached from bs */
bdrv_ref(file);
qdict_extract_subqdict(options, &file_options, "file.");
QDECREF(file_options);
qdict_put_str(options, "file", bdrv_get_node_name(file));
drv->bdrv_close(bs);
bdrv_unref_child(bs, bs->file);
bs->file = NULL;
ret = bdrv_snapshot_goto(file, snapshot_id, errp);
open_ret = drv->bdrv_open(bs, options, bs->open_flags, &local_err);
QDECREF(options);
if (open_ret < 0) {
bdrv_unref(file);
bs->drv = NULL;
/* A bdrv_snapshot_goto() error takes precedence */
error_propagate(errp, local_err);
return ret < 0 ? ret : open_ret;
}
assert(bs->file->bs == file);
bdrv_unref(file);
return ret;
}
error_setg(errp, "Block driver does not support snapshots");
return -ENOTSUP;
}
| false | qemu | 70a5afedd64c3f0d3b5feae6b40b30f3e8d13e4b | int bdrv_snapshot_goto(BlockDriverState *bs,
const char *snapshot_id,
Error **errp)
{
BlockDriver *drv = bs->drv;
int ret, open_ret;
int64_t len;
if (!drv) {
error_setg(errp, "Block driver is closed");
return -ENOMEDIUM;
}
len = bdrv_getlength(bs);
if (len < 0) {
error_setg_errno(errp, -len, "Cannot get block device size");
return len;
}
bdrv_set_dirty(bs, 0, len);
if (drv->bdrv_snapshot_goto) {
ret = drv->bdrv_snapshot_goto(bs, snapshot_id);
if (ret < 0) {
error_setg_errno(errp, -ret, "Failed to load snapshot");
}
return ret;
}
if (bs->file) {
BlockDriverState *file;
QDict *options = qdict_clone_shallow(bs->options);
QDict *file_options;
Error *local_err = NULL;
file = bs->file->bs;
bdrv_ref(file);
qdict_extract_subqdict(options, &file_options, "file.");
QDECREF(file_options);
qdict_put_str(options, "file", bdrv_get_node_name(file));
drv->bdrv_close(bs);
bdrv_unref_child(bs, bs->file);
bs->file = NULL;
ret = bdrv_snapshot_goto(file, snapshot_id, errp);
open_ret = drv->bdrv_open(bs, options, bs->open_flags, &local_err);
QDECREF(options);
if (open_ret < 0) {
bdrv_unref(file);
bs->drv = NULL;
error_propagate(errp, local_err);
return ret < 0 ? ret : open_ret;
}
assert(bs->file->bs == file);
bdrv_unref(file);
return ret;
}
error_setg(errp, "Block driver does not support snapshots");
return -ENOTSUP;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(BlockDriverState *VAR_0,
const char *VAR_1,
Error **VAR_2)
{
BlockDriver *drv = VAR_0->drv;
int VAR_3, VAR_4;
int64_t len;
if (!drv) {
error_setg(VAR_2, "Block driver is closed");
return -ENOMEDIUM;
}
len = bdrv_getlength(VAR_0);
if (len < 0) {
error_setg_errno(VAR_2, -len, "Cannot get block device size");
return len;
}
bdrv_set_dirty(VAR_0, 0, len);
if (drv->FUNC_0) {
VAR_3 = drv->FUNC_0(VAR_0, VAR_1);
if (VAR_3 < 0) {
error_setg_errno(VAR_2, -VAR_3, "Failed to load snapshot");
}
return VAR_3;
}
if (VAR_0->file) {
BlockDriverState *file;
QDict *options = qdict_clone_shallow(VAR_0->options);
QDict *file_options;
Error *local_err = NULL;
file = VAR_0->file->VAR_0;
bdrv_ref(file);
qdict_extract_subqdict(options, &file_options, "file.");
QDECREF(file_options);
qdict_put_str(options, "file", bdrv_get_node_name(file));
drv->bdrv_close(VAR_0);
bdrv_unref_child(VAR_0, VAR_0->file);
VAR_0->file = NULL;
VAR_3 = FUNC_0(file, VAR_1, VAR_2);
VAR_4 = drv->bdrv_open(VAR_0, options, VAR_0->open_flags, &local_err);
QDECREF(options);
if (VAR_4 < 0) {
bdrv_unref(file);
VAR_0->drv = NULL;
error_propagate(VAR_2, local_err);
return VAR_3 < 0 ? VAR_3 : VAR_4;
}
assert(VAR_0->file->VAR_0 == file);
bdrv_unref(file);
return VAR_3;
}
error_setg(VAR_2, "Block driver does not support snapshots");
return -ENOTSUP;
}
| [
"int FUNC_0(BlockDriverState *VAR_0,\nconst char *VAR_1,\nError **VAR_2)\n{",
"BlockDriver *drv = VAR_0->drv;",
"int VAR_3, VAR_4;",
"int64_t len;",
"if (!drv) {",
"error_setg(VAR_2, \"Block driver is closed\");",
"return -ENOMEDIUM;",
"}",
"len = bdrv_getlength(VAR_0);",
"if (len < 0) {",
"error_setg_errno(VAR_2, -len, \"Cannot get block device size\");",
"return len;",
"}",
"bdrv_set_dirty(VAR_0, 0, len);",
"if (drv->FUNC_0) {",
"VAR_3 = drv->FUNC_0(VAR_0, VAR_1);",
"if (VAR_3 < 0) {",
"error_setg_errno(VAR_2, -VAR_3, \"Failed to load snapshot\");",
"}",
"return VAR_3;",
"}",
"if (VAR_0->file) {",
"BlockDriverState *file;",
"QDict *options = qdict_clone_shallow(VAR_0->options);",
"QDict *file_options;",
"Error *local_err = NULL;",
"file = VAR_0->file->VAR_0;",
"bdrv_ref(file);",
"qdict_extract_subqdict(options, &file_options, \"file.\");",
"QDECREF(file_options);",
"qdict_put_str(options, \"file\", bdrv_get_node_name(file));",
"drv->bdrv_close(VAR_0);",
"bdrv_unref_child(VAR_0, VAR_0->file);",
"VAR_0->file = NULL;",
"VAR_3 = FUNC_0(file, VAR_1, VAR_2);",
"VAR_4 = drv->bdrv_open(VAR_0, options, VAR_0->open_flags, &local_err);",
"QDECREF(options);",
"if (VAR_4 < 0) {",
"bdrv_unref(file);",
"VAR_0->drv = NULL;",
"error_propagate(VAR_2, local_err);",
"return VAR_3 < 0 ? VAR_3 : VAR_4;",
"}",
"assert(VAR_0->file->VAR_0 == file);",
"bdrv_unref(file);",
"return VAR_3;",
"}",
"error_setg(VAR_2, \"Block driver does not support snapshots\");",
"return -ENOTSUP;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
85
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
141
]
] |
18,248 | static void test_qemu_strtoull_negative(void)
{
const char *str = " \t -321";
char f = 'X';
const char *endptr = &f;
uint64_t res = 999;
int err;
err = qemu_strtoull(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, -321);
g_assert(endptr == str + strlen(str));
}
| false | qemu | bc7c08a2c375acb7ae4d433054415588b176d34c | static void test_qemu_strtoull_negative(void)
{
const char *str = " \t -321";
char f = 'X';
const char *endptr = &f;
uint64_t res = 999;
int err;
err = qemu_strtoull(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, -321);
g_assert(endptr == str + strlen(str));
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
const char *VAR_0 = " \t -321";
char VAR_1 = 'X';
const char *VAR_2 = &VAR_1;
uint64_t res = 999;
int VAR_3;
VAR_3 = qemu_strtoull(VAR_0, &VAR_2, 0, &res);
g_assert_cmpint(VAR_3, ==, 0);
g_assert_cmpint(res, ==, -321);
g_assert(VAR_2 == VAR_0 + strlen(VAR_0));
}
| [
"static void FUNC_0(void)\n{",
"const char *VAR_0 = \" \\t -321\";",
"char VAR_1 = 'X';",
"const char *VAR_2 = &VAR_1;",
"uint64_t res = 999;",
"int VAR_3;",
"VAR_3 = qemu_strtoull(VAR_0, &VAR_2, 0, &res);",
"g_assert_cmpint(VAR_3, ==, 0);",
"g_assert_cmpint(res, ==, -321);",
"g_assert(VAR_2 == VAR_0 + strlen(VAR_0));",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
18,249 | static void omap_clkdsp_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
uint16_t diff;
if (size != 2) {
return omap_badwidth_write16(opaque, addr, value);
}
switch (addr) {
case 0x04: /* DSP_IDLECT1 */
diff = s->clkm.dsp_idlect1 ^ value;
s->clkm.dsp_idlect1 = value & 0x01f7;
omap_clkdsp_idlect1_update(s, diff, value);
break;
case 0x08: /* DSP_IDLECT2 */
s->clkm.dsp_idlect2 = value & 0x0037;
diff = s->clkm.dsp_idlect1 ^ value;
omap_clkdsp_idlect2_update(s, diff, value);
break;
case 0x14: /* DSP_RSTCT2 */
s->clkm.dsp_rstct2 = value & 0x0001;
break;
case 0x18: /* DSP_SYSST */
s->clkm.cold_start &= value & 0x3f;
break;
default:
OMAP_BAD_REG(addr);
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void omap_clkdsp_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
uint16_t diff;
if (size != 2) {
return omap_badwidth_write16(opaque, addr, value);
}
switch (addr) {
case 0x04:
diff = s->clkm.dsp_idlect1 ^ value;
s->clkm.dsp_idlect1 = value & 0x01f7;
omap_clkdsp_idlect1_update(s, diff, value);
break;
case 0x08:
s->clkm.dsp_idlect2 = value & 0x0037;
diff = s->clkm.dsp_idlect1 ^ value;
omap_clkdsp_idlect2_update(s, diff, value);
break;
case 0x14:
s->clkm.dsp_rstct2 = value & 0x0001;
break;
case 0x18:
s->clkm.cold_start &= value & 0x3f;
break;
default:
OMAP_BAD_REG(addr);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
struct omap_mpu_state_s *VAR_4 = (struct omap_mpu_state_s *) VAR_0;
uint16_t diff;
if (VAR_3 != 2) {
return omap_badwidth_write16(VAR_0, VAR_1, VAR_2);
}
switch (VAR_1) {
case 0x04:
diff = VAR_4->clkm.dsp_idlect1 ^ VAR_2;
VAR_4->clkm.dsp_idlect1 = VAR_2 & 0x01f7;
omap_clkdsp_idlect1_update(VAR_4, diff, VAR_2);
break;
case 0x08:
VAR_4->clkm.dsp_idlect2 = VAR_2 & 0x0037;
diff = VAR_4->clkm.dsp_idlect1 ^ VAR_2;
omap_clkdsp_idlect2_update(VAR_4, diff, VAR_2);
break;
case 0x14:
VAR_4->clkm.dsp_rstct2 = VAR_2 & 0x0001;
break;
case 0x18:
VAR_4->clkm.cold_start &= VAR_2 & 0x3f;
break;
default:
OMAP_BAD_REG(VAR_1);
}
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"struct omap_mpu_state_s *VAR_4 = (struct omap_mpu_state_s *) VAR_0;",
"uint16_t diff;",
"if (VAR_3 != 2) {",
"return omap_badwidth_write16(VAR_0, VAR_1, VAR_2);",
"}",
"switch (VAR_1) {",
"case 0x04:\ndiff = VAR_4->clkm.dsp_idlect1 ^ VAR_2;",
"VAR_4->clkm.dsp_idlect1 = VAR_2 & 0x01f7;",
"omap_clkdsp_idlect1_update(VAR_4, diff, VAR_2);",
"break;",
"case 0x08:\nVAR_4->clkm.dsp_idlect2 = VAR_2 & 0x0037;",
"diff = VAR_4->clkm.dsp_idlect1 ^ VAR_2;",
"omap_clkdsp_idlect2_update(VAR_4, diff, VAR_2);",
"break;",
"case 0x14:\nVAR_4->clkm.dsp_rstct2 = VAR_2 & 0x0001;",
"break;",
"case 0x18:\nVAR_4->clkm.cold_start &= VAR_2 & 0x3f;",
"break;",
"default:\nOMAP_BAD_REG(VAR_1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
47,
49
],
[
51
],
[
55,
57
],
[
59
],
[
63,
65
],
[
67
],
[
69
]
] |
18,250 | uint64_t helper_frsqrte (uint64_t arg)
{
CPU_DoubleU fone, farg;
fone.ll = 0x3FF0000000000000ULL; /* 1.0 */
farg.ll = arg;
if (unlikely(float64_is_signaling_nan(farg.d))) {
/* sNaN reciprocal square root */
farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN);
} else if (unlikely(float64_is_neg(farg.d) && !float64_is_zero(farg.d))) {
/* Reciprocal square root of a negative nonzero number */
farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSQRT);
} else if (likely(isnormal(farg.d))) {
farg.d = float64_sqrt(farg.d, &env->fp_status);
farg.d = float32_div(fone.d, farg.d, &env->fp_status);
} else {
if (farg.ll == 0x8000000000000000ULL) {
farg.ll = 0xFFF0000000000000ULL;
} else if (farg.ll == 0x0000000000000000ULL) {
farg.ll = 0x7FF0000000000000ULL;
} else if (float64_is_nan(farg.d)) {
farg.ll |= 0x000FFFFFFFFFFFFFULL;
} else if (float64_is_neg(farg.d)) {
farg.ll = 0x7FF8000000000000ULL;
} else {
farg.ll = 0x0000000000000000ULL;
}
}
return farg.ll;
}
| false | qemu | 6c01bf6c7ba7539460fcaeb99fbe1776ba137aa8 | uint64_t helper_frsqrte (uint64_t arg)
{
CPU_DoubleU fone, farg;
fone.ll = 0x3FF0000000000000ULL;
farg.ll = arg;
if (unlikely(float64_is_signaling_nan(farg.d))) {
farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN);
} else if (unlikely(float64_is_neg(farg.d) && !float64_is_zero(farg.d))) {
farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSQRT);
} else if (likely(isnormal(farg.d))) {
farg.d = float64_sqrt(farg.d, &env->fp_status);
farg.d = float32_div(fone.d, farg.d, &env->fp_status);
} else {
if (farg.ll == 0x8000000000000000ULL) {
farg.ll = 0xFFF0000000000000ULL;
} else if (farg.ll == 0x0000000000000000ULL) {
farg.ll = 0x7FF0000000000000ULL;
} else if (float64_is_nan(farg.d)) {
farg.ll |= 0x000FFFFFFFFFFFFFULL;
} else if (float64_is_neg(farg.d)) {
farg.ll = 0x7FF8000000000000ULL;
} else {
farg.ll = 0x0000000000000000ULL;
}
}
return farg.ll;
}
| {
"code": [],
"line_no": []
} | uint64_t FUNC_0 (uint64_t arg)
{
CPU_DoubleU fone, farg;
fone.ll = 0x3FF0000000000000ULL;
farg.ll = arg;
if (unlikely(float64_is_signaling_nan(farg.d))) {
farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN);
} else if (unlikely(float64_is_neg(farg.d) && !float64_is_zero(farg.d))) {
farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSQRT);
} else if (likely(isnormal(farg.d))) {
farg.d = float64_sqrt(farg.d, &env->fp_status);
farg.d = float32_div(fone.d, farg.d, &env->fp_status);
} else {
if (farg.ll == 0x8000000000000000ULL) {
farg.ll = 0xFFF0000000000000ULL;
} else if (farg.ll == 0x0000000000000000ULL) {
farg.ll = 0x7FF0000000000000ULL;
} else if (float64_is_nan(farg.d)) {
farg.ll |= 0x000FFFFFFFFFFFFFULL;
} else if (float64_is_neg(farg.d)) {
farg.ll = 0x7FF8000000000000ULL;
} else {
farg.ll = 0x0000000000000000ULL;
}
}
return farg.ll;
}
| [
"uint64_t FUNC_0 (uint64_t arg)\n{",
"CPU_DoubleU fone, farg;",
"fone.ll = 0x3FF0000000000000ULL;",
"farg.ll = arg;",
"if (unlikely(float64_is_signaling_nan(farg.d))) {",
"farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN);",
"} else if (unlikely(float64_is_neg(farg.d) && !float64_is_zero(farg.d))) {",
"farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSQRT);",
"} else if (likely(isnormal(farg.d))) {",
"farg.d = float64_sqrt(farg.d, &env->fp_status);",
"farg.d = float32_div(fone.d, farg.d, &env->fp_status);",
"} else {",
"if (farg.ll == 0x8000000000000000ULL) {",
"farg.ll = 0xFFF0000000000000ULL;",
"} else if (farg.ll == 0x0000000000000000ULL) {",
"farg.ll = 0x7FF0000000000000ULL;",
"} else if (float64_is_nan(farg.d)) {",
"farg.ll |= 0x000FFFFFFFFFFFFFULL;",
"} else if (float64_is_neg(farg.d)) {",
"farg.ll = 0x7FF8000000000000ULL;",
"} else {",
"farg.ll = 0x0000000000000000ULL;",
"}",
"}",
"return farg.ll;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
]
] |
18,251 | static void gen_compute_compact_branch(DisasContext *ctx, uint32_t opc,
int rs, int rt, int32_t offset)
{
int bcond_compute = 0;
TCGv t0 = tcg_temp_new();
TCGv t1 = tcg_temp_new();
if (ctx->hflags & MIPS_HFLAG_BMASK) {
#ifdef MIPS_DEBUG_DISAS
LOG_DISAS("Branch in delay / forbidden slot at PC 0x" TARGET_FMT_lx
"\n", ctx->pc);
#endif
generate_exception(ctx, EXCP_RI);
goto out;
}
/* Load needed operands and calculate btarget */
switch (opc) {
/* compact branch */
case OPC_BOVC: /* OPC_BEQZALC, OPC_BEQC */
case OPC_BNVC: /* OPC_BNEZALC, OPC_BNEC */
gen_load_gpr(t0, rs);
gen_load_gpr(t1, rt);
bcond_compute = 1;
ctx->btarget = addr_add(ctx, ctx->pc + 4, offset);
if (rs <= rt && rs == 0) {
/* OPC_BEQZALC, OPC_BNEZALC */
tcg_gen_movi_tl(cpu_gpr[31], ctx->pc + 4);
}
break;
case OPC_BLEZC: /* OPC_BGEZC, OPC_BGEC */
case OPC_BGTZC: /* OPC_BLTZC, OPC_BLTC */
gen_load_gpr(t0, rs);
gen_load_gpr(t1, rt);
bcond_compute = 1;
ctx->btarget = addr_add(ctx, ctx->pc + 4, offset);
break;
case OPC_BLEZALC: /* OPC_BGEZALC, OPC_BGEUC */
case OPC_BGTZALC: /* OPC_BLTZALC, OPC_BLTUC */
if (rs == 0 || rs == rt) {
/* OPC_BLEZALC, OPC_BGEZALC */
/* OPC_BGTZALC, OPC_BLTZALC */
tcg_gen_movi_tl(cpu_gpr[31], ctx->pc + 4);
}
gen_load_gpr(t0, rs);
gen_load_gpr(t1, rt);
bcond_compute = 1;
ctx->btarget = addr_add(ctx, ctx->pc + 4, offset);
break;
case OPC_BC:
case OPC_BALC:
ctx->btarget = addr_add(ctx, ctx->pc + 4, offset);
break;
case OPC_BEQZC:
case OPC_BNEZC:
if (rs != 0) {
/* OPC_BEQZC, OPC_BNEZC */
gen_load_gpr(t0, rs);
bcond_compute = 1;
ctx->btarget = addr_add(ctx, ctx->pc + 4, offset);
} else {
/* OPC_JIC, OPC_JIALC */
TCGv tbase = tcg_temp_new();
TCGv toffset = tcg_temp_new();
gen_load_gpr(tbase, rt);
tcg_gen_movi_tl(toffset, offset);
gen_op_addr_add(ctx, btarget, tbase, toffset);
tcg_temp_free(tbase);
tcg_temp_free(toffset);
}
break;
default:
MIPS_INVAL("Compact branch/jump");
generate_exception(ctx, EXCP_RI);
goto out;
}
if (bcond_compute == 0) {
/* Uncoditional compact branch */
switch (opc) {
case OPC_JIALC:
tcg_gen_movi_tl(cpu_gpr[31], ctx->pc + 4);
/* Fallthrough */
case OPC_JIC:
ctx->hflags |= MIPS_HFLAG_BR;
break;
case OPC_BALC:
tcg_gen_movi_tl(cpu_gpr[31], ctx->pc + 4);
/* Fallthrough */
case OPC_BC:
ctx->hflags |= MIPS_HFLAG_B;
break;
default:
MIPS_INVAL("Compact branch/jump");
generate_exception(ctx, EXCP_RI);
goto out;
}
/* Generating branch here as compact branches don't have delay slot */
gen_branch(ctx, 4);
} else {
/* Conditional compact branch */
int fs = gen_new_label();
save_cpu_state(ctx, 0);
switch (opc) {
case OPC_BLEZALC: /* OPC_BGEZALC, OPC_BGEUC */
if (rs == 0 && rt != 0) {
/* OPC_BLEZALC */
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LE), t1, 0, fs);
} else if (rs != 0 && rt != 0 && rs == rt) {
/* OPC_BGEZALC */
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GE), t1, 0, fs);
} else {
/* OPC_BGEUC */
tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_GEU), t0, t1, fs);
}
break;
case OPC_BGTZALC: /* OPC_BLTZALC, OPC_BLTUC */
if (rs == 0 && rt != 0) {
/* OPC_BGTZALC */
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GT), t1, 0, fs);
} else if (rs != 0 && rt != 0 && rs == rt) {
/* OPC_BLTZALC */
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LT), t1, 0, fs);
} else {
/* OPC_BLTUC */
tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_LTU), t0, t1, fs);
}
break;
case OPC_BLEZC: /* OPC_BGEZC, OPC_BGEC */
if (rs == 0 && rt != 0) {
/* OPC_BLEZC */
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LE), t1, 0, fs);
} else if (rs != 0 && rt != 0 && rs == rt) {
/* OPC_BGEZC */
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GE), t1, 0, fs);
} else {
/* OPC_BGEC */
tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_GE), t0, t1, fs);
}
break;
case OPC_BGTZC: /* OPC_BLTZC, OPC_BLTC */
if (rs == 0 && rt != 0) {
/* OPC_BGTZC */
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GT), t1, 0, fs);
} else if (rs != 0 && rt != 0 && rs == rt) {
/* OPC_BLTZC */
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LT), t1, 0, fs);
} else {
/* OPC_BLTC */
tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_LT), t0, t1, fs);
}
break;
case OPC_BOVC: /* OPC_BEQZALC, OPC_BEQC */
case OPC_BNVC: /* OPC_BNEZALC, OPC_BNEC */
if (rs >= rt) {
/* OPC_BOVC, OPC_BNVC */
TCGv t2 = tcg_temp_new();
TCGv t3 = tcg_temp_new();
TCGv t4 = tcg_temp_new();
TCGv input_overflow = tcg_temp_new();
gen_load_gpr(t0, rs);
gen_load_gpr(t1, rt);
tcg_gen_ext32s_tl(t2, t0);
tcg_gen_setcond_tl(TCG_COND_NE, input_overflow, t2, t0);
tcg_gen_ext32s_tl(t3, t1);
tcg_gen_setcond_tl(TCG_COND_NE, t4, t3, t1);
tcg_gen_or_tl(input_overflow, input_overflow, t4);
tcg_gen_add_tl(t4, t2, t3);
tcg_gen_ext32s_tl(t4, t4);
tcg_gen_xor_tl(t2, t2, t3);
tcg_gen_xor_tl(t3, t4, t3);
tcg_gen_andc_tl(t2, t3, t2);
tcg_gen_setcondi_tl(TCG_COND_LT, t4, t2, 0);
tcg_gen_or_tl(t4, t4, input_overflow);
if (opc == OPC_BOVC) {
/* OPC_BOVC */
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_NE), t4, 0, fs);
} else {
/* OPC_BNVC */
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_EQ), t4, 0, fs);
}
tcg_temp_free(input_overflow);
tcg_temp_free(t4);
tcg_temp_free(t3);
tcg_temp_free(t2);
} else if (rs < rt && rs == 0) {
/* OPC_BEQZALC, OPC_BNEZALC */
if (opc == OPC_BEQZALC) {
/* OPC_BEQZALC */
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_EQ), t1, 0, fs);
} else {
/* OPC_BNEZALC */
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_NE), t1, 0, fs);
}
} else {
/* OPC_BEQC, OPC_BNEC */
if (opc == OPC_BEQC) {
/* OPC_BEQC */
tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_EQ), t0, t1, fs);
} else {
/* OPC_BNEC */
tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_NE), t0, t1, fs);
}
}
break;
case OPC_BEQZC:
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_EQ), t0, 0, fs);
break;
case OPC_BNEZC:
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_NE), t0, 0, fs);
break;
default:
MIPS_INVAL("Compact conditional branch/jump");
generate_exception(ctx, EXCP_RI);
goto out;
}
/* Generating branch here as compact branches don't have delay slot */
gen_goto_tb(ctx, 1, ctx->btarget);
gen_set_label(fs);
ctx->hflags |= MIPS_HFLAG_FBNSLOT;
MIPS_DEBUG("Compact conditional branch");
}
out:
tcg_temp_free(t0);
tcg_temp_free(t1);
}
| false | qemu | 42a268c241183877192c376d03bd9b6d527407c7 | static void gen_compute_compact_branch(DisasContext *ctx, uint32_t opc,
int rs, int rt, int32_t offset)
{
int bcond_compute = 0;
TCGv t0 = tcg_temp_new();
TCGv t1 = tcg_temp_new();
if (ctx->hflags & MIPS_HFLAG_BMASK) {
#ifdef MIPS_DEBUG_DISAS
LOG_DISAS("Branch in delay / forbidden slot at PC 0x" TARGET_FMT_lx
"\n", ctx->pc);
#endif
generate_exception(ctx, EXCP_RI);
goto out;
}
switch (opc) {
case OPC_BOVC:
case OPC_BNVC:
gen_load_gpr(t0, rs);
gen_load_gpr(t1, rt);
bcond_compute = 1;
ctx->btarget = addr_add(ctx, ctx->pc + 4, offset);
if (rs <= rt && rs == 0) {
tcg_gen_movi_tl(cpu_gpr[31], ctx->pc + 4);
}
break;
case OPC_BLEZC:
case OPC_BGTZC:
gen_load_gpr(t0, rs);
gen_load_gpr(t1, rt);
bcond_compute = 1;
ctx->btarget = addr_add(ctx, ctx->pc + 4, offset);
break;
case OPC_BLEZALC:
case OPC_BGTZALC:
if (rs == 0 || rs == rt) {
tcg_gen_movi_tl(cpu_gpr[31], ctx->pc + 4);
}
gen_load_gpr(t0, rs);
gen_load_gpr(t1, rt);
bcond_compute = 1;
ctx->btarget = addr_add(ctx, ctx->pc + 4, offset);
break;
case OPC_BC:
case OPC_BALC:
ctx->btarget = addr_add(ctx, ctx->pc + 4, offset);
break;
case OPC_BEQZC:
case OPC_BNEZC:
if (rs != 0) {
gen_load_gpr(t0, rs);
bcond_compute = 1;
ctx->btarget = addr_add(ctx, ctx->pc + 4, offset);
} else {
TCGv tbase = tcg_temp_new();
TCGv toffset = tcg_temp_new();
gen_load_gpr(tbase, rt);
tcg_gen_movi_tl(toffset, offset);
gen_op_addr_add(ctx, btarget, tbase, toffset);
tcg_temp_free(tbase);
tcg_temp_free(toffset);
}
break;
default:
MIPS_INVAL("Compact branch/jump");
generate_exception(ctx, EXCP_RI);
goto out;
}
if (bcond_compute == 0) {
switch (opc) {
case OPC_JIALC:
tcg_gen_movi_tl(cpu_gpr[31], ctx->pc + 4);
case OPC_JIC:
ctx->hflags |= MIPS_HFLAG_BR;
break;
case OPC_BALC:
tcg_gen_movi_tl(cpu_gpr[31], ctx->pc + 4);
case OPC_BC:
ctx->hflags |= MIPS_HFLAG_B;
break;
default:
MIPS_INVAL("Compact branch/jump");
generate_exception(ctx, EXCP_RI);
goto out;
}
gen_branch(ctx, 4);
} else {
int fs = gen_new_label();
save_cpu_state(ctx, 0);
switch (opc) {
case OPC_BLEZALC:
if (rs == 0 && rt != 0) {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LE), t1, 0, fs);
} else if (rs != 0 && rt != 0 && rs == rt) {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GE), t1, 0, fs);
} else {
tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_GEU), t0, t1, fs);
}
break;
case OPC_BGTZALC:
if (rs == 0 && rt != 0) {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GT), t1, 0, fs);
} else if (rs != 0 && rt != 0 && rs == rt) {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LT), t1, 0, fs);
} else {
tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_LTU), t0, t1, fs);
}
break;
case OPC_BLEZC:
if (rs == 0 && rt != 0) {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LE), t1, 0, fs);
} else if (rs != 0 && rt != 0 && rs == rt) {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GE), t1, 0, fs);
} else {
tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_GE), t0, t1, fs);
}
break;
case OPC_BGTZC:
if (rs == 0 && rt != 0) {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GT), t1, 0, fs);
} else if (rs != 0 && rt != 0 && rs == rt) {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LT), t1, 0, fs);
} else {
tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_LT), t0, t1, fs);
}
break;
case OPC_BOVC:
case OPC_BNVC:
if (rs >= rt) {
TCGv t2 = tcg_temp_new();
TCGv t3 = tcg_temp_new();
TCGv t4 = tcg_temp_new();
TCGv input_overflow = tcg_temp_new();
gen_load_gpr(t0, rs);
gen_load_gpr(t1, rt);
tcg_gen_ext32s_tl(t2, t0);
tcg_gen_setcond_tl(TCG_COND_NE, input_overflow, t2, t0);
tcg_gen_ext32s_tl(t3, t1);
tcg_gen_setcond_tl(TCG_COND_NE, t4, t3, t1);
tcg_gen_or_tl(input_overflow, input_overflow, t4);
tcg_gen_add_tl(t4, t2, t3);
tcg_gen_ext32s_tl(t4, t4);
tcg_gen_xor_tl(t2, t2, t3);
tcg_gen_xor_tl(t3, t4, t3);
tcg_gen_andc_tl(t2, t3, t2);
tcg_gen_setcondi_tl(TCG_COND_LT, t4, t2, 0);
tcg_gen_or_tl(t4, t4, input_overflow);
if (opc == OPC_BOVC) {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_NE), t4, 0, fs);
} else {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_EQ), t4, 0, fs);
}
tcg_temp_free(input_overflow);
tcg_temp_free(t4);
tcg_temp_free(t3);
tcg_temp_free(t2);
} else if (rs < rt && rs == 0) {
if (opc == OPC_BEQZALC) {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_EQ), t1, 0, fs);
} else {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_NE), t1, 0, fs);
}
} else {
if (opc == OPC_BEQC) {
tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_EQ), t0, t1, fs);
} else {
tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_NE), t0, t1, fs);
}
}
break;
case OPC_BEQZC:
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_EQ), t0, 0, fs);
break;
case OPC_BNEZC:
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_NE), t0, 0, fs);
break;
default:
MIPS_INVAL("Compact conditional branch/jump");
generate_exception(ctx, EXCP_RI);
goto out;
}
gen_goto_tb(ctx, 1, ctx->btarget);
gen_set_label(fs);
ctx->hflags |= MIPS_HFLAG_FBNSLOT;
MIPS_DEBUG("Compact conditional branch");
}
out:
tcg_temp_free(t0);
tcg_temp_free(t1);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1,
int VAR_2, int VAR_3, int32_t VAR_4)
{
int VAR_5 = 0;
TCGv t0 = tcg_temp_new();
TCGv t1 = tcg_temp_new();
if (VAR_0->hflags & MIPS_HFLAG_BMASK) {
#ifdef MIPS_DEBUG_DISAS
LOG_DISAS("Branch in delay / forbidden slot at PC 0x" TARGET_FMT_lx
"\n", VAR_0->pc);
#endif
generate_exception(VAR_0, EXCP_RI);
goto out;
}
switch (VAR_1) {
case OPC_BOVC:
case OPC_BNVC:
gen_load_gpr(t0, VAR_2);
gen_load_gpr(t1, VAR_3);
VAR_5 = 1;
VAR_0->btarget = addr_add(VAR_0, VAR_0->pc + 4, VAR_4);
if (VAR_2 <= VAR_3 && VAR_2 == 0) {
tcg_gen_movi_tl(cpu_gpr[31], VAR_0->pc + 4);
}
break;
case OPC_BLEZC:
case OPC_BGTZC:
gen_load_gpr(t0, VAR_2);
gen_load_gpr(t1, VAR_3);
VAR_5 = 1;
VAR_0->btarget = addr_add(VAR_0, VAR_0->pc + 4, VAR_4);
break;
case OPC_BLEZALC:
case OPC_BGTZALC:
if (VAR_2 == 0 || VAR_2 == VAR_3) {
tcg_gen_movi_tl(cpu_gpr[31], VAR_0->pc + 4);
}
gen_load_gpr(t0, VAR_2);
gen_load_gpr(t1, VAR_3);
VAR_5 = 1;
VAR_0->btarget = addr_add(VAR_0, VAR_0->pc + 4, VAR_4);
break;
case OPC_BC:
case OPC_BALC:
VAR_0->btarget = addr_add(VAR_0, VAR_0->pc + 4, VAR_4);
break;
case OPC_BEQZC:
case OPC_BNEZC:
if (VAR_2 != 0) {
gen_load_gpr(t0, VAR_2);
VAR_5 = 1;
VAR_0->btarget = addr_add(VAR_0, VAR_0->pc + 4, VAR_4);
} else {
TCGv tbase = tcg_temp_new();
TCGv toffset = tcg_temp_new();
gen_load_gpr(tbase, VAR_3);
tcg_gen_movi_tl(toffset, VAR_4);
gen_op_addr_add(VAR_0, btarget, tbase, toffset);
tcg_temp_free(tbase);
tcg_temp_free(toffset);
}
break;
default:
MIPS_INVAL("Compact branch/jump");
generate_exception(VAR_0, EXCP_RI);
goto out;
}
if (VAR_5 == 0) {
switch (VAR_1) {
case OPC_JIALC:
tcg_gen_movi_tl(cpu_gpr[31], VAR_0->pc + 4);
case OPC_JIC:
VAR_0->hflags |= MIPS_HFLAG_BR;
break;
case OPC_BALC:
tcg_gen_movi_tl(cpu_gpr[31], VAR_0->pc + 4);
case OPC_BC:
VAR_0->hflags |= MIPS_HFLAG_B;
break;
default:
MIPS_INVAL("Compact branch/jump");
generate_exception(VAR_0, EXCP_RI);
goto out;
}
gen_branch(VAR_0, 4);
} else {
int VAR_6 = gen_new_label();
save_cpu_state(VAR_0, 0);
switch (VAR_1) {
case OPC_BLEZALC:
if (VAR_2 == 0 && VAR_3 != 0) {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LE), t1, 0, VAR_6);
} else if (VAR_2 != 0 && VAR_3 != 0 && VAR_2 == VAR_3) {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GE), t1, 0, VAR_6);
} else {
tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_GEU), t0, t1, VAR_6);
}
break;
case OPC_BGTZALC:
if (VAR_2 == 0 && VAR_3 != 0) {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GT), t1, 0, VAR_6);
} else if (VAR_2 != 0 && VAR_3 != 0 && VAR_2 == VAR_3) {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LT), t1, 0, VAR_6);
} else {
tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_LTU), t0, t1, VAR_6);
}
break;
case OPC_BLEZC:
if (VAR_2 == 0 && VAR_3 != 0) {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LE), t1, 0, VAR_6);
} else if (VAR_2 != 0 && VAR_3 != 0 && VAR_2 == VAR_3) {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GE), t1, 0, VAR_6);
} else {
tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_GE), t0, t1, VAR_6);
}
break;
case OPC_BGTZC:
if (VAR_2 == 0 && VAR_3 != 0) {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GT), t1, 0, VAR_6);
} else if (VAR_2 != 0 && VAR_3 != 0 && VAR_2 == VAR_3) {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LT), t1, 0, VAR_6);
} else {
tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_LT), t0, t1, VAR_6);
}
break;
case OPC_BOVC:
case OPC_BNVC:
if (VAR_2 >= VAR_3) {
TCGv t2 = tcg_temp_new();
TCGv t3 = tcg_temp_new();
TCGv t4 = tcg_temp_new();
TCGv input_overflow = tcg_temp_new();
gen_load_gpr(t0, VAR_2);
gen_load_gpr(t1, VAR_3);
tcg_gen_ext32s_tl(t2, t0);
tcg_gen_setcond_tl(TCG_COND_NE, input_overflow, t2, t0);
tcg_gen_ext32s_tl(t3, t1);
tcg_gen_setcond_tl(TCG_COND_NE, t4, t3, t1);
tcg_gen_or_tl(input_overflow, input_overflow, t4);
tcg_gen_add_tl(t4, t2, t3);
tcg_gen_ext32s_tl(t4, t4);
tcg_gen_xor_tl(t2, t2, t3);
tcg_gen_xor_tl(t3, t4, t3);
tcg_gen_andc_tl(t2, t3, t2);
tcg_gen_setcondi_tl(TCG_COND_LT, t4, t2, 0);
tcg_gen_or_tl(t4, t4, input_overflow);
if (VAR_1 == OPC_BOVC) {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_NE), t4, 0, VAR_6);
} else {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_EQ), t4, 0, VAR_6);
}
tcg_temp_free(input_overflow);
tcg_temp_free(t4);
tcg_temp_free(t3);
tcg_temp_free(t2);
} else if (VAR_2 < VAR_3 && VAR_2 == 0) {
if (VAR_1 == OPC_BEQZALC) {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_EQ), t1, 0, VAR_6);
} else {
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_NE), t1, 0, VAR_6);
}
} else {
if (VAR_1 == OPC_BEQC) {
tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_EQ), t0, t1, VAR_6);
} else {
tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_NE), t0, t1, VAR_6);
}
}
break;
case OPC_BEQZC:
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_EQ), t0, 0, VAR_6);
break;
case OPC_BNEZC:
tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_NE), t0, 0, VAR_6);
break;
default:
MIPS_INVAL("Compact conditional branch/jump");
generate_exception(VAR_0, EXCP_RI);
goto out;
}
gen_goto_tb(VAR_0, 1, VAR_0->btarget);
gen_set_label(VAR_6);
VAR_0->hflags |= MIPS_HFLAG_FBNSLOT;
MIPS_DEBUG("Compact conditional branch");
}
out:
tcg_temp_free(t0);
tcg_temp_free(t1);
}
| [
"static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1,\nint VAR_2, int VAR_3, int32_t VAR_4)\n{",
"int VAR_5 = 0;",
"TCGv t0 = tcg_temp_new();",
"TCGv t1 = tcg_temp_new();",
"if (VAR_0->hflags & MIPS_HFLAG_BMASK) {",
"#ifdef MIPS_DEBUG_DISAS\nLOG_DISAS(\"Branch in delay / forbidden slot at PC 0x\" TARGET_FMT_lx\n\"\\n\", VAR_0->pc);",
"#endif\ngenerate_exception(VAR_0, EXCP_RI);",
"goto out;",
"}",
"switch (VAR_1) {",
"case OPC_BOVC:\ncase OPC_BNVC:\ngen_load_gpr(t0, VAR_2);",
"gen_load_gpr(t1, VAR_3);",
"VAR_5 = 1;",
"VAR_0->btarget = addr_add(VAR_0, VAR_0->pc + 4, VAR_4);",
"if (VAR_2 <= VAR_3 && VAR_2 == 0) {",
"tcg_gen_movi_tl(cpu_gpr[31], VAR_0->pc + 4);",
"}",
"break;",
"case OPC_BLEZC:\ncase OPC_BGTZC:\ngen_load_gpr(t0, VAR_2);",
"gen_load_gpr(t1, VAR_3);",
"VAR_5 = 1;",
"VAR_0->btarget = addr_add(VAR_0, VAR_0->pc + 4, VAR_4);",
"break;",
"case OPC_BLEZALC:\ncase OPC_BGTZALC:\nif (VAR_2 == 0 || VAR_2 == VAR_3) {",
"tcg_gen_movi_tl(cpu_gpr[31], VAR_0->pc + 4);",
"}",
"gen_load_gpr(t0, VAR_2);",
"gen_load_gpr(t1, VAR_3);",
"VAR_5 = 1;",
"VAR_0->btarget = addr_add(VAR_0, VAR_0->pc + 4, VAR_4);",
"break;",
"case OPC_BC:\ncase OPC_BALC:\nVAR_0->btarget = addr_add(VAR_0, VAR_0->pc + 4, VAR_4);",
"break;",
"case OPC_BEQZC:\ncase OPC_BNEZC:\nif (VAR_2 != 0) {",
"gen_load_gpr(t0, VAR_2);",
"VAR_5 = 1;",
"VAR_0->btarget = addr_add(VAR_0, VAR_0->pc + 4, VAR_4);",
"} else {",
"TCGv tbase = tcg_temp_new();",
"TCGv toffset = tcg_temp_new();",
"gen_load_gpr(tbase, VAR_3);",
"tcg_gen_movi_tl(toffset, VAR_4);",
"gen_op_addr_add(VAR_0, btarget, tbase, toffset);",
"tcg_temp_free(tbase);",
"tcg_temp_free(toffset);",
"}",
"break;",
"default:\nMIPS_INVAL(\"Compact branch/jump\");",
"generate_exception(VAR_0, EXCP_RI);",
"goto out;",
"}",
"if (VAR_5 == 0) {",
"switch (VAR_1) {",
"case OPC_JIALC:\ntcg_gen_movi_tl(cpu_gpr[31], VAR_0->pc + 4);",
"case OPC_JIC:\nVAR_0->hflags |= MIPS_HFLAG_BR;",
"break;",
"case OPC_BALC:\ntcg_gen_movi_tl(cpu_gpr[31], VAR_0->pc + 4);",
"case OPC_BC:\nVAR_0->hflags |= MIPS_HFLAG_B;",
"break;",
"default:\nMIPS_INVAL(\"Compact branch/jump\");",
"generate_exception(VAR_0, EXCP_RI);",
"goto out;",
"}",
"gen_branch(VAR_0, 4);",
"} else {",
"int VAR_6 = gen_new_label();",
"save_cpu_state(VAR_0, 0);",
"switch (VAR_1) {",
"case OPC_BLEZALC:\nif (VAR_2 == 0 && VAR_3 != 0) {",
"tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LE), t1, 0, VAR_6);",
"} else if (VAR_2 != 0 && VAR_3 != 0 && VAR_2 == VAR_3) {",
"tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GE), t1, 0, VAR_6);",
"} else {",
"tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_GEU), t0, t1, VAR_6);",
"}",
"break;",
"case OPC_BGTZALC:\nif (VAR_2 == 0 && VAR_3 != 0) {",
"tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GT), t1, 0, VAR_6);",
"} else if (VAR_2 != 0 && VAR_3 != 0 && VAR_2 == VAR_3) {",
"tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LT), t1, 0, VAR_6);",
"} else {",
"tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_LTU), t0, t1, VAR_6);",
"}",
"break;",
"case OPC_BLEZC:\nif (VAR_2 == 0 && VAR_3 != 0) {",
"tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LE), t1, 0, VAR_6);",
"} else if (VAR_2 != 0 && VAR_3 != 0 && VAR_2 == VAR_3) {",
"tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GE), t1, 0, VAR_6);",
"} else {",
"tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_GE), t0, t1, VAR_6);",
"}",
"break;",
"case OPC_BGTZC:\nif (VAR_2 == 0 && VAR_3 != 0) {",
"tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GT), t1, 0, VAR_6);",
"} else if (VAR_2 != 0 && VAR_3 != 0 && VAR_2 == VAR_3) {",
"tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LT), t1, 0, VAR_6);",
"} else {",
"tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_LT), t0, t1, VAR_6);",
"}",
"break;",
"case OPC_BOVC:\ncase OPC_BNVC:\nif (VAR_2 >= VAR_3) {",
"TCGv t2 = tcg_temp_new();",
"TCGv t3 = tcg_temp_new();",
"TCGv t4 = tcg_temp_new();",
"TCGv input_overflow = tcg_temp_new();",
"gen_load_gpr(t0, VAR_2);",
"gen_load_gpr(t1, VAR_3);",
"tcg_gen_ext32s_tl(t2, t0);",
"tcg_gen_setcond_tl(TCG_COND_NE, input_overflow, t2, t0);",
"tcg_gen_ext32s_tl(t3, t1);",
"tcg_gen_setcond_tl(TCG_COND_NE, t4, t3, t1);",
"tcg_gen_or_tl(input_overflow, input_overflow, t4);",
"tcg_gen_add_tl(t4, t2, t3);",
"tcg_gen_ext32s_tl(t4, t4);",
"tcg_gen_xor_tl(t2, t2, t3);",
"tcg_gen_xor_tl(t3, t4, t3);",
"tcg_gen_andc_tl(t2, t3, t2);",
"tcg_gen_setcondi_tl(TCG_COND_LT, t4, t2, 0);",
"tcg_gen_or_tl(t4, t4, input_overflow);",
"if (VAR_1 == OPC_BOVC) {",
"tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_NE), t4, 0, VAR_6);",
"} else {",
"tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_EQ), t4, 0, VAR_6);",
"}",
"tcg_temp_free(input_overflow);",
"tcg_temp_free(t4);",
"tcg_temp_free(t3);",
"tcg_temp_free(t2);",
"} else if (VAR_2 < VAR_3 && VAR_2 == 0) {",
"if (VAR_1 == OPC_BEQZALC) {",
"tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_EQ), t1, 0, VAR_6);",
"} else {",
"tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_NE), t1, 0, VAR_6);",
"}",
"} else {",
"if (VAR_1 == OPC_BEQC) {",
"tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_EQ), t0, t1, VAR_6);",
"} else {",
"tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_NE), t0, t1, VAR_6);",
"}",
"}",
"break;",
"case OPC_BEQZC:\ntcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_EQ), t0, 0, VAR_6);",
"break;",
"case OPC_BNEZC:\ntcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_NE), t0, 0, VAR_6);",
"break;",
"default:\nMIPS_INVAL(\"Compact conditional branch/jump\");",
"generate_exception(VAR_0, EXCP_RI);",
"goto out;",
"}",
"gen_goto_tb(VAR_0, 1, VAR_0->btarget);",
"gen_set_label(VAR_6);",
"VAR_0->hflags |= MIPS_HFLAG_FBNSLOT;",
"MIPS_DEBUG(\"Compact conditional branch\");",
"}",
"out:\ntcg_temp_free(t0);",
"tcg_temp_free(t1);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
35
],
[
39,
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61,
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75,
77,
79
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99,
101,
103
],
[
105
],
[
107,
109,
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145,
147
],
[
149
],
[
151
],
[
153
],
[
157
],
[
161
],
[
163,
165
],
[
169,
171
],
[
173
],
[
175,
177
],
[
181,
183
],
[
185
],
[
187,
189
],
[
191
],
[
193
],
[
195
],
[
201
],
[
203
],
[
207
],
[
209
],
[
213
],
[
215,
217
],
[
221
],
[
223
],
[
227
],
[
229
],
[
233
],
[
235
],
[
237
],
[
239,
241
],
[
245
],
[
247
],
[
251
],
[
253
],
[
257
],
[
259
],
[
261
],
[
263,
265
],
[
269
],
[
271
],
[
275
],
[
277
],
[
281
],
[
283
],
[
285
],
[
287,
289
],
[
293
],
[
295
],
[
299
],
[
301
],
[
305
],
[
307
],
[
309
],
[
311,
313,
315
],
[
319
],
[
321
],
[
323
],
[
325
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
363
],
[
365
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
385
],
[
389
],
[
391
],
[
395
],
[
397
],
[
399
],
[
403
],
[
407
],
[
409
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421,
423
],
[
425
],
[
427,
429
],
[
431
],
[
433,
435
],
[
437
],
[
439
],
[
441
],
[
447
],
[
449
],
[
453
],
[
455
],
[
457
],
[
461,
463
],
[
465
],
[
467
]
] |
18,252 | int qemu_chr_fe_get_msgfd(CharDriverState *s)
{
int fd;
return (qemu_chr_fe_get_msgfds(s, &fd, 1) == 1) ? fd : -1;
}
| false | qemu | 33577b47c64435fcc2a1bc01c7e82534256f1fc3 | int qemu_chr_fe_get_msgfd(CharDriverState *s)
{
int fd;
return (qemu_chr_fe_get_msgfds(s, &fd, 1) == 1) ? fd : -1;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(CharDriverState *VAR_0)
{
int VAR_1;
return (qemu_chr_fe_get_msgfds(VAR_0, &VAR_1, 1) == 1) ? VAR_1 : -1;
}
| [
"int FUNC_0(CharDriverState *VAR_0)\n{",
"int VAR_1;",
"return (qemu_chr_fe_get_msgfds(VAR_0, &VAR_1, 1) == 1) ? VAR_1 : -1;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
18,253 | static void vnc_client_write_locked(void *opaque)
{
VncState *vs = opaque;
#ifdef CONFIG_VNC_SASL
if (vs->sasl.conn &&
vs->sasl.runSSF &&
!vs->sasl.waitWriteSSF) {
vnc_client_write_sasl(vs);
} else
#endif /* CONFIG_VNC_SASL */
{
#ifdef CONFIG_VNC_WS
if (vs->encode_ws) {
vnc_client_write_ws(vs);
} else
#endif /* CONFIG_VNC_WS */
{
vnc_client_write_plain(vs);
}
}
}
| false | qemu | 8e9b0d24fb986d4241ae3b77752eca5dab4cb486 | static void vnc_client_write_locked(void *opaque)
{
VncState *vs = opaque;
#ifdef CONFIG_VNC_SASL
if (vs->sasl.conn &&
vs->sasl.runSSF &&
!vs->sasl.waitWriteSSF) {
vnc_client_write_sasl(vs);
} else
#endif
{
#ifdef CONFIG_VNC_WS
if (vs->encode_ws) {
vnc_client_write_ws(vs);
} else
#endif
{
vnc_client_write_plain(vs);
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
VncState *vs = VAR_0;
#ifdef CONFIG_VNC_SASL
if (vs->sasl.conn &&
vs->sasl.runSSF &&
!vs->sasl.waitWriteSSF) {
vnc_client_write_sasl(vs);
} else
#endif
{
#ifdef CONFIG_VNC_WS
if (vs->encode_ws) {
vnc_client_write_ws(vs);
} else
#endif
{
vnc_client_write_plain(vs);
}
}
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"VncState *vs = VAR_0;",
"#ifdef CONFIG_VNC_SASL\nif (vs->sasl.conn &&\nvs->sasl.runSSF &&\n!vs->sasl.waitWriteSSF) {",
"vnc_client_write_sasl(vs);",
"} else",
"#endif\n{",
"#ifdef CONFIG_VNC_WS\nif (vs->encode_ws) {",
"vnc_client_write_ws(vs);",
"} else",
"#endif\n{",
"vnc_client_write_plain(vs);",
"}",
"}",
"}"
] | [
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
]
] |
18,255 | iscsi_aio_write16_cb(struct iscsi_context *iscsi, int status,
void *command_data, void *opaque)
{
IscsiAIOCB *acb = opaque;
trace_iscsi_aio_write16_cb(iscsi, status, acb, acb->canceled);
g_free(acb->buf);
acb->buf = NULL;
if (acb->canceled != 0) {
return;
}
acb->status = 0;
if (status < 0) {
error_report("Failed to write16 data to iSCSI lun. %s",
iscsi_get_error(iscsi));
acb->status = -EIO;
}
iscsi_schedule_bh(acb);
}
| false | qemu | 1dde716ed6719c341c1bfa427781f0715af90cbc | iscsi_aio_write16_cb(struct iscsi_context *iscsi, int status,
void *command_data, void *opaque)
{
IscsiAIOCB *acb = opaque;
trace_iscsi_aio_write16_cb(iscsi, status, acb, acb->canceled);
g_free(acb->buf);
acb->buf = NULL;
if (acb->canceled != 0) {
return;
}
acb->status = 0;
if (status < 0) {
error_report("Failed to write16 data to iSCSI lun. %s",
iscsi_get_error(iscsi));
acb->status = -EIO;
}
iscsi_schedule_bh(acb);
}
| {
"code": [],
"line_no": []
} | FUNC_0(struct iscsi_context *VAR_0, int VAR_1,
void *VAR_2, void *VAR_3)
{
IscsiAIOCB *acb = VAR_3;
trace_iscsi_aio_write16_cb(VAR_0, VAR_1, acb, acb->canceled);
g_free(acb->buf);
acb->buf = NULL;
if (acb->canceled != 0) {
return;
}
acb->VAR_1 = 0;
if (VAR_1 < 0) {
error_report("Failed to write16 data to iSCSI lun. %s",
iscsi_get_error(VAR_0));
acb->VAR_1 = -EIO;
}
iscsi_schedule_bh(acb);
}
| [
"FUNC_0(struct iscsi_context *VAR_0, int VAR_1,\nvoid *VAR_2, void *VAR_3)\n{",
"IscsiAIOCB *acb = VAR_3;",
"trace_iscsi_aio_write16_cb(VAR_0, VAR_1, acb, acb->canceled);",
"g_free(acb->buf);",
"acb->buf = NULL;",
"if (acb->canceled != 0) {",
"return;",
"}",
"acb->VAR_1 = 0;",
"if (VAR_1 < 0) {",
"error_report(\"Failed to write16 data to iSCSI lun. %s\",\niscsi_get_error(VAR_0));",
"acb->VAR_1 = -EIO;",
"}",
"iscsi_schedule_bh(acb);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
43
],
[
45
]
] |
18,256 | static void spr_write_40x_sler (void *opaque, int sprn)
{
DisasContext *ctx = opaque;
gen_op_store_40x_sler();
/* We must stop the translation as we may have changed
* some regions endianness
*/
RET_STOP(ctx);
}
| false | qemu | e1833e1f96456fd8fc17463246fe0b2050e68efb | static void spr_write_40x_sler (void *opaque, int sprn)
{
DisasContext *ctx = opaque;
gen_op_store_40x_sler();
RET_STOP(ctx);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (void *VAR_0, int VAR_1)
{
DisasContext *ctx = VAR_0;
gen_op_store_40x_sler();
RET_STOP(ctx);
}
| [
"static void FUNC_0 (void *VAR_0, int VAR_1)\n{",
"DisasContext *ctx = VAR_0;",
"gen_op_store_40x_sler();",
"RET_STOP(ctx);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
17
],
[
19
]
] |
18,258 | static void sclp_execute(SCLPDevice *sclp, SCCB *sccb, uint32_t code)
{
SCLPDeviceClass *sclp_c = SCLP_GET_CLASS(sclp);
SCLPEventFacility *ef = sclp->event_facility;
SCLPEventFacilityClass *efc = EVENT_FACILITY_GET_CLASS(ef);
switch (code & SCLP_CMD_CODE_MASK) {
case SCLP_CMDW_READ_SCP_INFO:
case SCLP_CMDW_READ_SCP_INFO_FORCED:
sclp_c->read_SCP_info(sclp, sccb);
break;
case SCLP_CMDW_READ_CPU_INFO:
sclp_c->read_cpu_info(sclp, sccb);
break;
case SCLP_READ_STORAGE_ELEMENT_INFO:
if (code & 0xff00) {
sclp_c->read_storage_element1_info(sclp, sccb);
} else {
sclp_c->read_storage_element0_info(sclp, sccb);
}
break;
case SCLP_ATTACH_STORAGE_ELEMENT:
sclp_c->attach_storage_element(sclp, sccb, (code & 0xff00) >> 8);
break;
case SCLP_ASSIGN_STORAGE:
sclp_c->assign_storage(sclp, sccb);
break;
case SCLP_UNASSIGN_STORAGE:
sclp_c->unassign_storage(sclp, sccb);
break;
case SCLP_CMDW_CONFIGURE_PCI:
s390_pci_sclp_configure(sccb);
break;
case SCLP_CMDW_DECONFIGURE_PCI:
s390_pci_sclp_deconfigure(sccb);
break;
default:
efc->command_handler(ef, sccb, code);
break;
}
}
| false | qemu | 80b7a265362c870f95fb5ca1f7e7a02c0fa0db3e | static void sclp_execute(SCLPDevice *sclp, SCCB *sccb, uint32_t code)
{
SCLPDeviceClass *sclp_c = SCLP_GET_CLASS(sclp);
SCLPEventFacility *ef = sclp->event_facility;
SCLPEventFacilityClass *efc = EVENT_FACILITY_GET_CLASS(ef);
switch (code & SCLP_CMD_CODE_MASK) {
case SCLP_CMDW_READ_SCP_INFO:
case SCLP_CMDW_READ_SCP_INFO_FORCED:
sclp_c->read_SCP_info(sclp, sccb);
break;
case SCLP_CMDW_READ_CPU_INFO:
sclp_c->read_cpu_info(sclp, sccb);
break;
case SCLP_READ_STORAGE_ELEMENT_INFO:
if (code & 0xff00) {
sclp_c->read_storage_element1_info(sclp, sccb);
} else {
sclp_c->read_storage_element0_info(sclp, sccb);
}
break;
case SCLP_ATTACH_STORAGE_ELEMENT:
sclp_c->attach_storage_element(sclp, sccb, (code & 0xff00) >> 8);
break;
case SCLP_ASSIGN_STORAGE:
sclp_c->assign_storage(sclp, sccb);
break;
case SCLP_UNASSIGN_STORAGE:
sclp_c->unassign_storage(sclp, sccb);
break;
case SCLP_CMDW_CONFIGURE_PCI:
s390_pci_sclp_configure(sccb);
break;
case SCLP_CMDW_DECONFIGURE_PCI:
s390_pci_sclp_deconfigure(sccb);
break;
default:
efc->command_handler(ef, sccb, code);
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(SCLPDevice *VAR_0, SCCB *VAR_1, uint32_t VAR_2)
{
SCLPDeviceClass *sclp_c = SCLP_GET_CLASS(VAR_0);
SCLPEventFacility *ef = VAR_0->event_facility;
SCLPEventFacilityClass *efc = EVENT_FACILITY_GET_CLASS(ef);
switch (VAR_2 & SCLP_CMD_CODE_MASK) {
case SCLP_CMDW_READ_SCP_INFO:
case SCLP_CMDW_READ_SCP_INFO_FORCED:
sclp_c->read_SCP_info(VAR_0, VAR_1);
break;
case SCLP_CMDW_READ_CPU_INFO:
sclp_c->read_cpu_info(VAR_0, VAR_1);
break;
case SCLP_READ_STORAGE_ELEMENT_INFO:
if (VAR_2 & 0xff00) {
sclp_c->read_storage_element1_info(VAR_0, VAR_1);
} else {
sclp_c->read_storage_element0_info(VAR_0, VAR_1);
}
break;
case SCLP_ATTACH_STORAGE_ELEMENT:
sclp_c->attach_storage_element(VAR_0, VAR_1, (VAR_2 & 0xff00) >> 8);
break;
case SCLP_ASSIGN_STORAGE:
sclp_c->assign_storage(VAR_0, VAR_1);
break;
case SCLP_UNASSIGN_STORAGE:
sclp_c->unassign_storage(VAR_0, VAR_1);
break;
case SCLP_CMDW_CONFIGURE_PCI:
s390_pci_sclp_configure(VAR_1);
break;
case SCLP_CMDW_DECONFIGURE_PCI:
s390_pci_sclp_deconfigure(VAR_1);
break;
default:
efc->command_handler(ef, VAR_1, VAR_2);
break;
}
}
| [
"static void FUNC_0(SCLPDevice *VAR_0, SCCB *VAR_1, uint32_t VAR_2)\n{",
"SCLPDeviceClass *sclp_c = SCLP_GET_CLASS(VAR_0);",
"SCLPEventFacility *ef = VAR_0->event_facility;",
"SCLPEventFacilityClass *efc = EVENT_FACILITY_GET_CLASS(ef);",
"switch (VAR_2 & SCLP_CMD_CODE_MASK) {",
"case SCLP_CMDW_READ_SCP_INFO:\ncase SCLP_CMDW_READ_SCP_INFO_FORCED:\nsclp_c->read_SCP_info(VAR_0, VAR_1);",
"break;",
"case SCLP_CMDW_READ_CPU_INFO:\nsclp_c->read_cpu_info(VAR_0, VAR_1);",
"break;",
"case SCLP_READ_STORAGE_ELEMENT_INFO:\nif (VAR_2 & 0xff00) {",
"sclp_c->read_storage_element1_info(VAR_0, VAR_1);",
"} else {",
"sclp_c->read_storage_element0_info(VAR_0, VAR_1);",
"}",
"break;",
"case SCLP_ATTACH_STORAGE_ELEMENT:\nsclp_c->attach_storage_element(VAR_0, VAR_1, (VAR_2 & 0xff00) >> 8);",
"break;",
"case SCLP_ASSIGN_STORAGE:\nsclp_c->assign_storage(VAR_0, VAR_1);",
"break;",
"case SCLP_UNASSIGN_STORAGE:\nsclp_c->unassign_storage(VAR_0, VAR_1);",
"break;",
"case SCLP_CMDW_CONFIGURE_PCI:\ns390_pci_sclp_configure(VAR_1);",
"break;",
"case SCLP_CMDW_DECONFIGURE_PCI:\ns390_pci_sclp_deconfigure(VAR_1);",
"break;",
"default:\nefc->command_handler(ef, VAR_1, VAR_2);",
"break;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15,
17,
19
],
[
21
],
[
23,
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49,
51
],
[
53
],
[
55,
57
],
[
59
],
[
61,
63
],
[
65
],
[
67,
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
]
] |
18,259 | static void smbios_build_type_0_fields(const char *t)
{
char buf[1024];
unsigned char major, minor;
if (get_param_value(buf, sizeof(buf), "vendor", t))
smbios_add_field(0, offsetof(struct smbios_type_0, vendor_str),
buf, strlen(buf) + 1);
if (get_param_value(buf, sizeof(buf), "version", t))
smbios_add_field(0, offsetof(struct smbios_type_0, bios_version_str),
buf, strlen(buf) + 1);
if (get_param_value(buf, sizeof(buf), "date", t))
smbios_add_field(0, offsetof(struct smbios_type_0,
bios_release_date_str),
buf, strlen(buf) + 1);
if (get_param_value(buf, sizeof(buf), "release", t)) {
sscanf(buf, "%hhu.%hhu", &major, &minor);
smbios_add_field(0, offsetof(struct smbios_type_0,
system_bios_major_release),
&major, 1);
smbios_add_field(0, offsetof(struct smbios_type_0,
system_bios_minor_release),
&minor, 1);
}
}
| false | qemu | 6e5c4540d18d1e9a5253104df161a7e0d408ca95 | static void smbios_build_type_0_fields(const char *t)
{
char buf[1024];
unsigned char major, minor;
if (get_param_value(buf, sizeof(buf), "vendor", t))
smbios_add_field(0, offsetof(struct smbios_type_0, vendor_str),
buf, strlen(buf) + 1);
if (get_param_value(buf, sizeof(buf), "version", t))
smbios_add_field(0, offsetof(struct smbios_type_0, bios_version_str),
buf, strlen(buf) + 1);
if (get_param_value(buf, sizeof(buf), "date", t))
smbios_add_field(0, offsetof(struct smbios_type_0,
bios_release_date_str),
buf, strlen(buf) + 1);
if (get_param_value(buf, sizeof(buf), "release", t)) {
sscanf(buf, "%hhu.%hhu", &major, &minor);
smbios_add_field(0, offsetof(struct smbios_type_0,
system_bios_major_release),
&major, 1);
smbios_add_field(0, offsetof(struct smbios_type_0,
system_bios_minor_release),
&minor, 1);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const char *VAR_0)
{
char VAR_1[1024];
unsigned char VAR_2, VAR_3;
if (get_param_value(VAR_1, sizeof(VAR_1), "vendor", VAR_0))
smbios_add_field(0, offsetof(struct smbios_type_0, vendor_str),
VAR_1, strlen(VAR_1) + 1);
if (get_param_value(VAR_1, sizeof(VAR_1), "version", VAR_0))
smbios_add_field(0, offsetof(struct smbios_type_0, bios_version_str),
VAR_1, strlen(VAR_1) + 1);
if (get_param_value(VAR_1, sizeof(VAR_1), "date", VAR_0))
smbios_add_field(0, offsetof(struct smbios_type_0,
bios_release_date_str),
VAR_1, strlen(VAR_1) + 1);
if (get_param_value(VAR_1, sizeof(VAR_1), "release", VAR_0)) {
sscanf(VAR_1, "%hhu.%hhu", &VAR_2, &VAR_3);
smbios_add_field(0, offsetof(struct smbios_type_0,
system_bios_major_release),
&VAR_2, 1);
smbios_add_field(0, offsetof(struct smbios_type_0,
system_bios_minor_release),
&VAR_3, 1);
}
}
| [
"static void FUNC_0(const char *VAR_0)\n{",
"char VAR_1[1024];",
"unsigned char VAR_2, VAR_3;",
"if (get_param_value(VAR_1, sizeof(VAR_1), \"vendor\", VAR_0))\nsmbios_add_field(0, offsetof(struct smbios_type_0, vendor_str),\nVAR_1, strlen(VAR_1) + 1);",
"if (get_param_value(VAR_1, sizeof(VAR_1), \"version\", VAR_0))\nsmbios_add_field(0, offsetof(struct smbios_type_0, bios_version_str),\nVAR_1, strlen(VAR_1) + 1);",
"if (get_param_value(VAR_1, sizeof(VAR_1), \"date\", VAR_0))\nsmbios_add_field(0, offsetof(struct smbios_type_0,\nbios_release_date_str),\nVAR_1, strlen(VAR_1) + 1);",
"if (get_param_value(VAR_1, sizeof(VAR_1), \"release\", VAR_0)) {",
"sscanf(VAR_1, \"%hhu.%hhu\", &VAR_2, &VAR_3);",
"smbios_add_field(0, offsetof(struct smbios_type_0,\nsystem_bios_major_release),\n&VAR_2, 1);",
"smbios_add_field(0, offsetof(struct smbios_type_0,\nsystem_bios_minor_release),\n&VAR_3, 1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13,
15
],
[
17,
19,
21
],
[
23,
25,
27,
29
],
[
31
],
[
33
],
[
35,
37,
39
],
[
41,
43,
45
],
[
47
],
[
49
]
] |
18,260 | truncate_f(int argc, char **argv)
{
int64_t offset;
int ret;
offset = cvtnum(argv[1]);
if (offset < 0) {
printf("non-numeric truncate argument -- %s\n", argv[1]);
return 0;
}
ret = bdrv_truncate(bs, offset);
if (ret < 0) {
printf("truncate: %s", strerror(ret));
return 0;
}
return 0;
}
| false | qemu | 0923c577f993d61eeaf41f66db1e1010fa113976 | truncate_f(int argc, char **argv)
{
int64_t offset;
int ret;
offset = cvtnum(argv[1]);
if (offset < 0) {
printf("non-numeric truncate argument -- %s\n", argv[1]);
return 0;
}
ret = bdrv_truncate(bs, offset);
if (ret < 0) {
printf("truncate: %s", strerror(ret));
return 0;
}
return 0;
}
| {
"code": [],
"line_no": []
} | FUNC_0(int VAR_0, char **VAR_1)
{
int64_t offset;
int VAR_2;
offset = cvtnum(VAR_1[1]);
if (offset < 0) {
printf("non-numeric truncate argument -- %s\n", VAR_1[1]);
return 0;
}
VAR_2 = bdrv_truncate(bs, offset);
if (VAR_2 < 0) {
printf("truncate: %s", strerror(VAR_2));
return 0;
}
return 0;
}
| [
"FUNC_0(int VAR_0, char **VAR_1)\n{",
"int64_t offset;",
"int VAR_2;",
"offset = cvtnum(VAR_1[1]);",
"if (offset < 0) {",
"printf(\"non-numeric truncate argument -- %s\\n\", VAR_1[1]);",
"return 0;",
"}",
"VAR_2 = bdrv_truncate(bs, offset);",
"if (VAR_2 < 0) {",
"printf(\"truncate: %s\", strerror(VAR_2));",
"return 0;",
"}",
"return 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
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
]
] |
18,261 | static inline void *host_from_stream_offset(QEMUFile *f,
ram_addr_t offset,
int flags)
{
static RAMBlock *block = NULL;
char id[256];
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
if (!block || block->max_length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
return block->host + offset;
}
len = qemu_get_byte(f);
qemu_get_buffer(f, (uint8_t *)id, len);
id[len] = 0;
QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {
if (!strncmp(id, block->idstr, sizeof(id)) &&
block->max_length > offset) {
return block->host + offset;
}
}
error_report("Can't find block %s!", id);
return NULL;
}
| false | qemu | e3dd74934f2d2c8c67083995928ff68e8c1d0030 | static inline void *host_from_stream_offset(QEMUFile *f,
ram_addr_t offset,
int flags)
{
static RAMBlock *block = NULL;
char id[256];
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
if (!block || block->max_length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
return block->host + offset;
}
len = qemu_get_byte(f);
qemu_get_buffer(f, (uint8_t *)id, len);
id[len] = 0;
QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {
if (!strncmp(id, block->idstr, sizeof(id)) &&
block->max_length > offset) {
return block->host + offset;
}
}
error_report("Can't find block %s!", id);
return NULL;
}
| {
"code": [],
"line_no": []
} | static inline void *FUNC_0(QEMUFile *VAR_0,
ram_addr_t VAR_1,
int VAR_2)
{
static RAMBlock *VAR_3 = NULL;
char VAR_4[256];
uint8_t len;
if (VAR_2 & RAM_SAVE_FLAG_CONTINUE) {
if (!VAR_3 || VAR_3->max_length <= VAR_1) {
error_report("Ack, bad migration stream!");
return NULL;
}
return VAR_3->host + VAR_1;
}
len = qemu_get_byte(VAR_0);
qemu_get_buffer(VAR_0, (uint8_t *)VAR_4, len);
VAR_4[len] = 0;
QLIST_FOREACH_RCU(VAR_3, &ram_list.blocks, next) {
if (!strncmp(VAR_4, VAR_3->idstr, sizeof(VAR_4)) &&
VAR_3->max_length > VAR_1) {
return VAR_3->host + VAR_1;
}
}
error_report("Can't find VAR_3 %s!", VAR_4);
return NULL;
}
| [
"static inline void *FUNC_0(QEMUFile *VAR_0,\nram_addr_t VAR_1,\nint VAR_2)\n{",
"static RAMBlock *VAR_3 = NULL;",
"char VAR_4[256];",
"uint8_t len;",
"if (VAR_2 & RAM_SAVE_FLAG_CONTINUE) {",
"if (!VAR_3 || VAR_3->max_length <= VAR_1) {",
"error_report(\"Ack, bad migration stream!\");",
"return NULL;",
"}",
"return VAR_3->host + VAR_1;",
"}",
"len = qemu_get_byte(VAR_0);",
"qemu_get_buffer(VAR_0, (uint8_t *)VAR_4, len);",
"VAR_4[len] = 0;",
"QLIST_FOREACH_RCU(VAR_3, &ram_list.blocks, next) {",
"if (!strncmp(VAR_4, VAR_3->idstr, sizeof(VAR_4)) &&\nVAR_3->max_length > VAR_1) {",
"return VAR_3->host + VAR_1;",
"}",
"}",
"error_report(\"Can't find VAR_3 %s!\", VAR_4);",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
]
] |
18,262 | int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar)
{
CPUS390XState *env = &cpu->env;
uint8_t oc, dmaas;
uint32_t fh;
ZpciFib fib;
S390PCIBusDevice *pbdev;
uint64_t cc = ZPCI_PCI_LS_OK;
if (env->psw.mask & PSW_MASK_PSTATE) {
program_interrupt(env, PGM_PRIVILEGED, 6);
return 0;
}
oc = env->regs[r1] & 0xff;
dmaas = (env->regs[r1] >> 16) & 0xff;
fh = env->regs[r1] >> 32;
if (fiba & 0x7) {
program_interrupt(env, PGM_SPECIFICATION, 6);
return 0;
}
pbdev = s390_pci_find_dev_by_fh(fh);
if (!pbdev || !(pbdev->fh & FH_MASK_ENABLE)) {
DPRINTF("mpcifc no pci dev fh 0x%x\n", fh);
setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
}
if (s390_cpu_virt_mem_read(cpu, fiba, ar, (uint8_t *)&fib, sizeof(fib))) {
return 0;
}
if (fib.fmt != 0) {
program_interrupt(env, PGM_OPERAND, 6);
return 0;
}
switch (oc) {
case ZPCI_MOD_FC_REG_INT:
if (pbdev->summary_ind) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE);
} else if (reg_irqs(env, pbdev, fib)) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_RES_NOT_AVAIL);
}
break;
case ZPCI_MOD_FC_DEREG_INT:
if (!pbdev->summary_ind) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE);
} else {
pci_dereg_irqs(pbdev);
}
break;
case ZPCI_MOD_FC_REG_IOAT:
if (dmaas != 0) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_DMAAS_INVAL);
} else if (pbdev->iommu_enabled) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE);
} else if (reg_ioat(env, pbdev, fib)) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_INSUF_RES);
}
break;
case ZPCI_MOD_FC_DEREG_IOAT:
if (dmaas != 0) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_DMAAS_INVAL);
} else if (!pbdev->iommu_enabled) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE);
} else {
pci_dereg_ioat(pbdev);
}
break;
case ZPCI_MOD_FC_REREG_IOAT:
if (dmaas != 0) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_DMAAS_INVAL);
} else if (!pbdev->iommu_enabled) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE);
} else {
pci_dereg_ioat(pbdev);
if (reg_ioat(env, pbdev, fib)) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_INSUF_RES);
}
}
break;
case ZPCI_MOD_FC_RESET_ERROR:
pbdev->error_state = false;
pbdev->lgstg_blocked = false;
break;
case ZPCI_MOD_FC_RESET_BLOCK:
pbdev->lgstg_blocked = false;
break;
case ZPCI_MOD_FC_SET_MEASURE:
pbdev->fmb_addr = ldq_p(&fib.fmb_addr);
break;
default:
program_interrupt(&cpu->env, PGM_OPERAND, 6);
cc = ZPCI_PCI_LS_ERR;
}
setcc(cpu, cc);
return 0;
}
| false | qemu | 5d1abf234462d13bef3617cc2c55b6815703ddf2 | int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar)
{
CPUS390XState *env = &cpu->env;
uint8_t oc, dmaas;
uint32_t fh;
ZpciFib fib;
S390PCIBusDevice *pbdev;
uint64_t cc = ZPCI_PCI_LS_OK;
if (env->psw.mask & PSW_MASK_PSTATE) {
program_interrupt(env, PGM_PRIVILEGED, 6);
return 0;
}
oc = env->regs[r1] & 0xff;
dmaas = (env->regs[r1] >> 16) & 0xff;
fh = env->regs[r1] >> 32;
if (fiba & 0x7) {
program_interrupt(env, PGM_SPECIFICATION, 6);
return 0;
}
pbdev = s390_pci_find_dev_by_fh(fh);
if (!pbdev || !(pbdev->fh & FH_MASK_ENABLE)) {
DPRINTF("mpcifc no pci dev fh 0x%x\n", fh);
setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
}
if (s390_cpu_virt_mem_read(cpu, fiba, ar, (uint8_t *)&fib, sizeof(fib))) {
return 0;
}
if (fib.fmt != 0) {
program_interrupt(env, PGM_OPERAND, 6);
return 0;
}
switch (oc) {
case ZPCI_MOD_FC_REG_INT:
if (pbdev->summary_ind) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE);
} else if (reg_irqs(env, pbdev, fib)) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_RES_NOT_AVAIL);
}
break;
case ZPCI_MOD_FC_DEREG_INT:
if (!pbdev->summary_ind) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE);
} else {
pci_dereg_irqs(pbdev);
}
break;
case ZPCI_MOD_FC_REG_IOAT:
if (dmaas != 0) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_DMAAS_INVAL);
} else if (pbdev->iommu_enabled) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE);
} else if (reg_ioat(env, pbdev, fib)) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_INSUF_RES);
}
break;
case ZPCI_MOD_FC_DEREG_IOAT:
if (dmaas != 0) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_DMAAS_INVAL);
} else if (!pbdev->iommu_enabled) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE);
} else {
pci_dereg_ioat(pbdev);
}
break;
case ZPCI_MOD_FC_REREG_IOAT:
if (dmaas != 0) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_DMAAS_INVAL);
} else if (!pbdev->iommu_enabled) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE);
} else {
pci_dereg_ioat(pbdev);
if (reg_ioat(env, pbdev, fib)) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_INSUF_RES);
}
}
break;
case ZPCI_MOD_FC_RESET_ERROR:
pbdev->error_state = false;
pbdev->lgstg_blocked = false;
break;
case ZPCI_MOD_FC_RESET_BLOCK:
pbdev->lgstg_blocked = false;
break;
case ZPCI_MOD_FC_SET_MEASURE:
pbdev->fmb_addr = ldq_p(&fib.fmb_addr);
break;
default:
program_interrupt(&cpu->env, PGM_OPERAND, 6);
cc = ZPCI_PCI_LS_ERR;
}
setcc(cpu, cc);
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(S390CPU *VAR_0, uint8_t VAR_1, uint64_t VAR_2, uint8_t VAR_3)
{
CPUS390XState *env = &VAR_0->env;
uint8_t oc, dmaas;
uint32_t fh;
ZpciFib fib;
S390PCIBusDevice *pbdev;
uint64_t cc = ZPCI_PCI_LS_OK;
if (env->psw.mask & PSW_MASK_PSTATE) {
program_interrupt(env, PGM_PRIVILEGED, 6);
return 0;
}
oc = env->regs[VAR_1] & 0xff;
dmaas = (env->regs[VAR_1] >> 16) & 0xff;
fh = env->regs[VAR_1] >> 32;
if (VAR_2 & 0x7) {
program_interrupt(env, PGM_SPECIFICATION, 6);
return 0;
}
pbdev = s390_pci_find_dev_by_fh(fh);
if (!pbdev || !(pbdev->fh & FH_MASK_ENABLE)) {
DPRINTF("mpcifc no pci dev fh 0x%x\n", fh);
setcc(VAR_0, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
}
if (s390_cpu_virt_mem_read(VAR_0, VAR_2, VAR_3, (uint8_t *)&fib, sizeof(fib))) {
return 0;
}
if (fib.fmt != 0) {
program_interrupt(env, PGM_OPERAND, 6);
return 0;
}
switch (oc) {
case ZPCI_MOD_FC_REG_INT:
if (pbdev->summary_ind) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, VAR_1, ZPCI_MOD_ST_SEQUENCE);
} else if (reg_irqs(env, pbdev, fib)) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, VAR_1, ZPCI_MOD_ST_RES_NOT_AVAIL);
}
break;
case ZPCI_MOD_FC_DEREG_INT:
if (!pbdev->summary_ind) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, VAR_1, ZPCI_MOD_ST_SEQUENCE);
} else {
pci_dereg_irqs(pbdev);
}
break;
case ZPCI_MOD_FC_REG_IOAT:
if (dmaas != 0) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, VAR_1, ZPCI_MOD_ST_DMAAS_INVAL);
} else if (pbdev->iommu_enabled) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, VAR_1, ZPCI_MOD_ST_SEQUENCE);
} else if (reg_ioat(env, pbdev, fib)) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, VAR_1, ZPCI_MOD_ST_INSUF_RES);
}
break;
case ZPCI_MOD_FC_DEREG_IOAT:
if (dmaas != 0) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, VAR_1, ZPCI_MOD_ST_DMAAS_INVAL);
} else if (!pbdev->iommu_enabled) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, VAR_1, ZPCI_MOD_ST_SEQUENCE);
} else {
pci_dereg_ioat(pbdev);
}
break;
case ZPCI_MOD_FC_REREG_IOAT:
if (dmaas != 0) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, VAR_1, ZPCI_MOD_ST_DMAAS_INVAL);
} else if (!pbdev->iommu_enabled) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, VAR_1, ZPCI_MOD_ST_SEQUENCE);
} else {
pci_dereg_ioat(pbdev);
if (reg_ioat(env, pbdev, fib)) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, VAR_1, ZPCI_MOD_ST_INSUF_RES);
}
}
break;
case ZPCI_MOD_FC_RESET_ERROR:
pbdev->error_state = false;
pbdev->lgstg_blocked = false;
break;
case ZPCI_MOD_FC_RESET_BLOCK:
pbdev->lgstg_blocked = false;
break;
case ZPCI_MOD_FC_SET_MEASURE:
pbdev->fmb_addr = ldq_p(&fib.fmb_addr);
break;
default:
program_interrupt(&VAR_0->env, PGM_OPERAND, 6);
cc = ZPCI_PCI_LS_ERR;
}
setcc(VAR_0, cc);
return 0;
}
| [
"int FUNC_0(S390CPU *VAR_0, uint8_t VAR_1, uint64_t VAR_2, uint8_t VAR_3)\n{",
"CPUS390XState *env = &VAR_0->env;",
"uint8_t oc, dmaas;",
"uint32_t fh;",
"ZpciFib fib;",
"S390PCIBusDevice *pbdev;",
"uint64_t cc = ZPCI_PCI_LS_OK;",
"if (env->psw.mask & PSW_MASK_PSTATE) {",
"program_interrupt(env, PGM_PRIVILEGED, 6);",
"return 0;",
"}",
"oc = env->regs[VAR_1] & 0xff;",
"dmaas = (env->regs[VAR_1] >> 16) & 0xff;",
"fh = env->regs[VAR_1] >> 32;",
"if (VAR_2 & 0x7) {",
"program_interrupt(env, PGM_SPECIFICATION, 6);",
"return 0;",
"}",
"pbdev = s390_pci_find_dev_by_fh(fh);",
"if (!pbdev || !(pbdev->fh & FH_MASK_ENABLE)) {",
"DPRINTF(\"mpcifc no pci dev fh 0x%x\\n\", fh);",
"setcc(VAR_0, ZPCI_PCI_LS_INVAL_HANDLE);",
"return 0;",
"}",
"if (s390_cpu_virt_mem_read(VAR_0, VAR_2, VAR_3, (uint8_t *)&fib, sizeof(fib))) {",
"return 0;",
"}",
"if (fib.fmt != 0) {",
"program_interrupt(env, PGM_OPERAND, 6);",
"return 0;",
"}",
"switch (oc) {",
"case ZPCI_MOD_FC_REG_INT:\nif (pbdev->summary_ind) {",
"cc = ZPCI_PCI_LS_ERR;",
"s390_set_status_code(env, VAR_1, ZPCI_MOD_ST_SEQUENCE);",
"} else if (reg_irqs(env, pbdev, fib)) {",
"cc = ZPCI_PCI_LS_ERR;",
"s390_set_status_code(env, VAR_1, ZPCI_MOD_ST_RES_NOT_AVAIL);",
"}",
"break;",
"case ZPCI_MOD_FC_DEREG_INT:\nif (!pbdev->summary_ind) {",
"cc = ZPCI_PCI_LS_ERR;",
"s390_set_status_code(env, VAR_1, ZPCI_MOD_ST_SEQUENCE);",
"} else {",
"pci_dereg_irqs(pbdev);",
"}",
"break;",
"case ZPCI_MOD_FC_REG_IOAT:\nif (dmaas != 0) {",
"cc = ZPCI_PCI_LS_ERR;",
"s390_set_status_code(env, VAR_1, ZPCI_MOD_ST_DMAAS_INVAL);",
"} else if (pbdev->iommu_enabled) {",
"cc = ZPCI_PCI_LS_ERR;",
"s390_set_status_code(env, VAR_1, ZPCI_MOD_ST_SEQUENCE);",
"} else if (reg_ioat(env, pbdev, fib)) {",
"cc = ZPCI_PCI_LS_ERR;",
"s390_set_status_code(env, VAR_1, ZPCI_MOD_ST_INSUF_RES);",
"}",
"break;",
"case ZPCI_MOD_FC_DEREG_IOAT:\nif (dmaas != 0) {",
"cc = ZPCI_PCI_LS_ERR;",
"s390_set_status_code(env, VAR_1, ZPCI_MOD_ST_DMAAS_INVAL);",
"} else if (!pbdev->iommu_enabled) {",
"cc = ZPCI_PCI_LS_ERR;",
"s390_set_status_code(env, VAR_1, ZPCI_MOD_ST_SEQUENCE);",
"} else {",
"pci_dereg_ioat(pbdev);",
"}",
"break;",
"case ZPCI_MOD_FC_REREG_IOAT:\nif (dmaas != 0) {",
"cc = ZPCI_PCI_LS_ERR;",
"s390_set_status_code(env, VAR_1, ZPCI_MOD_ST_DMAAS_INVAL);",
"} else if (!pbdev->iommu_enabled) {",
"cc = ZPCI_PCI_LS_ERR;",
"s390_set_status_code(env, VAR_1, ZPCI_MOD_ST_SEQUENCE);",
"} else {",
"pci_dereg_ioat(pbdev);",
"if (reg_ioat(env, pbdev, fib)) {",
"cc = ZPCI_PCI_LS_ERR;",
"s390_set_status_code(env, VAR_1, ZPCI_MOD_ST_INSUF_RES);",
"}",
"}",
"break;",
"case ZPCI_MOD_FC_RESET_ERROR:\npbdev->error_state = false;",
"pbdev->lgstg_blocked = false;",
"break;",
"case ZPCI_MOD_FC_RESET_BLOCK:\npbdev->lgstg_blocked = false;",
"break;",
"case ZPCI_MOD_FC_SET_MEASURE:\npbdev->fmb_addr = ldq_p(&fib.fmb_addr);",
"break;",
"default:\nprogram_interrupt(&VAR_0->env, PGM_OPERAND, 6);",
"cc = ZPCI_PCI_LS_ERR;",
"}",
"setcc(VAR_0, cc);",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139,
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161,
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191,
193
],
[
195
],
[
197
],
[
199,
201
],
[
203
],
[
205,
207
],
[
209
],
[
211,
213
],
[
215
],
[
217
],
[
221
],
[
223
],
[
225
]
] |
18,263 | static void s390_cpu_plug(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
gchar *name;
S390CPU *cpu = S390_CPU(dev);
CPUState *cs = CPU(dev);
name = g_strdup_printf("cpu[%i]", cpu->env.cpu_num);
object_property_set_link(OBJECT(hotplug_dev), OBJECT(cs), name,
errp);
g_free(name);
}
| false | qemu | ca5c1457d614fec718aaec7bdf3663dec37e1e50 | static void s390_cpu_plug(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
gchar *name;
S390CPU *cpu = S390_CPU(dev);
CPUState *cs = CPU(dev);
name = g_strdup_printf("cpu[%i]", cpu->env.cpu_num);
object_property_set_link(OBJECT(hotplug_dev), OBJECT(cs), name,
errp);
g_free(name);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(HotplugHandler *VAR_0,
DeviceState *VAR_1, Error **VAR_2)
{
gchar *name;
S390CPU *cpu = S390_CPU(VAR_1);
CPUState *cs = CPU(VAR_1);
name = g_strdup_printf("cpu[%i]", cpu->env.cpu_num);
object_property_set_link(OBJECT(VAR_0), OBJECT(cs), name,
VAR_2);
g_free(name);
}
| [
"static void FUNC_0(HotplugHandler *VAR_0,\nDeviceState *VAR_1, Error **VAR_2)\n{",
"gchar *name;",
"S390CPU *cpu = S390_CPU(VAR_1);",
"CPUState *cs = CPU(VAR_1);",
"name = g_strdup_printf(\"cpu[%i]\", cpu->env.cpu_num);",
"object_property_set_link(OBJECT(VAR_0), OBJECT(cs), name,\nVAR_2);",
"g_free(name);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17,
19
],
[
21
],
[
23
]
] |
18,264 | static void gen_maskg(DisasContext *ctx)
{
int l1 = gen_new_label();
TCGv t0 = tcg_temp_new();
TCGv t1 = tcg_temp_new();
TCGv t2 = tcg_temp_new();
TCGv t3 = tcg_temp_new();
tcg_gen_movi_tl(t3, 0xFFFFFFFF);
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x1F);
tcg_gen_andi_tl(t1, cpu_gpr[rS(ctx->opcode)], 0x1F);
tcg_gen_addi_tl(t2, t0, 1);
tcg_gen_shr_tl(t2, t3, t2);
tcg_gen_shr_tl(t3, t3, t1);
tcg_gen_xor_tl(cpu_gpr[rA(ctx->opcode)], t2, t3);
tcg_gen_brcond_tl(TCG_COND_GE, t0, t1, l1);
tcg_gen_neg_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
gen_set_label(l1);
tcg_temp_free(t0);
tcg_temp_free(t1);
tcg_temp_free(t2);
tcg_temp_free(t3);
if (unlikely(Rc(ctx->opcode) != 0))
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
}
| false | qemu | 42a268c241183877192c376d03bd9b6d527407c7 | static void gen_maskg(DisasContext *ctx)
{
int l1 = gen_new_label();
TCGv t0 = tcg_temp_new();
TCGv t1 = tcg_temp_new();
TCGv t2 = tcg_temp_new();
TCGv t3 = tcg_temp_new();
tcg_gen_movi_tl(t3, 0xFFFFFFFF);
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x1F);
tcg_gen_andi_tl(t1, cpu_gpr[rS(ctx->opcode)], 0x1F);
tcg_gen_addi_tl(t2, t0, 1);
tcg_gen_shr_tl(t2, t3, t2);
tcg_gen_shr_tl(t3, t3, t1);
tcg_gen_xor_tl(cpu_gpr[rA(ctx->opcode)], t2, t3);
tcg_gen_brcond_tl(TCG_COND_GE, t0, t1, l1);
tcg_gen_neg_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
gen_set_label(l1);
tcg_temp_free(t0);
tcg_temp_free(t1);
tcg_temp_free(t2);
tcg_temp_free(t3);
if (unlikely(Rc(ctx->opcode) != 0))
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0)
{
int VAR_1 = gen_new_label();
TCGv t0 = tcg_temp_new();
TCGv t1 = tcg_temp_new();
TCGv t2 = tcg_temp_new();
TCGv t3 = tcg_temp_new();
tcg_gen_movi_tl(t3, 0xFFFFFFFF);
tcg_gen_andi_tl(t0, cpu_gpr[rB(VAR_0->opcode)], 0x1F);
tcg_gen_andi_tl(t1, cpu_gpr[rS(VAR_0->opcode)], 0x1F);
tcg_gen_addi_tl(t2, t0, 1);
tcg_gen_shr_tl(t2, t3, t2);
tcg_gen_shr_tl(t3, t3, t1);
tcg_gen_xor_tl(cpu_gpr[rA(VAR_0->opcode)], t2, t3);
tcg_gen_brcond_tl(TCG_COND_GE, t0, t1, VAR_1);
tcg_gen_neg_tl(cpu_gpr[rA(VAR_0->opcode)], cpu_gpr[rA(VAR_0->opcode)]);
gen_set_label(VAR_1);
tcg_temp_free(t0);
tcg_temp_free(t1);
tcg_temp_free(t2);
tcg_temp_free(t3);
if (unlikely(Rc(VAR_0->opcode) != 0))
gen_set_Rc0(VAR_0, cpu_gpr[rA(VAR_0->opcode)]);
}
| [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"int VAR_1 = gen_new_label();",
"TCGv t0 = tcg_temp_new();",
"TCGv t1 = tcg_temp_new();",
"TCGv t2 = tcg_temp_new();",
"TCGv t3 = tcg_temp_new();",
"tcg_gen_movi_tl(t3, 0xFFFFFFFF);",
"tcg_gen_andi_tl(t0, cpu_gpr[rB(VAR_0->opcode)], 0x1F);",
"tcg_gen_andi_tl(t1, cpu_gpr[rS(VAR_0->opcode)], 0x1F);",
"tcg_gen_addi_tl(t2, t0, 1);",
"tcg_gen_shr_tl(t2, t3, t2);",
"tcg_gen_shr_tl(t3, t3, t1);",
"tcg_gen_xor_tl(cpu_gpr[rA(VAR_0->opcode)], t2, t3);",
"tcg_gen_brcond_tl(TCG_COND_GE, t0, t1, VAR_1);",
"tcg_gen_neg_tl(cpu_gpr[rA(VAR_0->opcode)], cpu_gpr[rA(VAR_0->opcode)]);",
"gen_set_label(VAR_1);",
"tcg_temp_free(t0);",
"tcg_temp_free(t1);",
"tcg_temp_free(t2);",
"tcg_temp_free(t3);",
"if (unlikely(Rc(VAR_0->opcode) != 0))\ngen_set_Rc0(VAR_0, cpu_gpr[rA(VAR_0->opcode)]);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
]
] |
18,265 | uint64_t qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
int *num)
{
BDRVQcowState *s = bs->opaque;
unsigned int l1_index, l2_index;
uint64_t l2_offset, *l2_table, cluster_offset;
int l1_bits, c;
unsigned int index_in_cluster, nb_clusters;
uint64_t nb_available, nb_needed;
index_in_cluster = (offset >> 9) & (s->cluster_sectors - 1);
nb_needed = *num + index_in_cluster;
l1_bits = s->l2_bits + s->cluster_bits;
/* compute how many bytes there are between the offset and
* the end of the l1 entry
*/
nb_available = (1ULL << l1_bits) - (offset & ((1ULL << l1_bits) - 1));
/* compute the number of available sectors */
nb_available = (nb_available >> 9) + index_in_cluster;
if (nb_needed > nb_available) {
nb_needed = nb_available;
}
cluster_offset = 0;
/* seek the the l2 offset in the l1 table */
l1_index = offset >> l1_bits;
if (l1_index >= s->l1_size)
goto out;
l2_offset = s->l1_table[l1_index];
/* seek the l2 table of the given l2 offset */
if (!l2_offset)
goto out;
/* load the l2 table in memory */
l2_offset &= ~QCOW_OFLAG_COPIED;
l2_table = l2_load(bs, l2_offset);
if (l2_table == NULL)
return 0;
/* find the cluster offset for the given disk offset */
l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
cluster_offset = be64_to_cpu(l2_table[l2_index]);
nb_clusters = size_to_clusters(s, nb_needed << 9);
if (!cluster_offset) {
/* how many empty clusters ? */
c = count_contiguous_free_clusters(nb_clusters, &l2_table[l2_index]);
} else {
/* how many allocated clusters ? */
c = count_contiguous_clusters(nb_clusters, s->cluster_size,
&l2_table[l2_index], 0, QCOW_OFLAG_COPIED);
}
nb_available = (c * s->cluster_sectors);
out:
if (nb_available > nb_needed)
nb_available = nb_needed;
*num = nb_available - index_in_cluster;
return cluster_offset & ~QCOW_OFLAG_COPIED;
}
| false | qemu | 1c46efaa0a175e468772405385ca26a1e35dd94c | uint64_t qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
int *num)
{
BDRVQcowState *s = bs->opaque;
unsigned int l1_index, l2_index;
uint64_t l2_offset, *l2_table, cluster_offset;
int l1_bits, c;
unsigned int index_in_cluster, nb_clusters;
uint64_t nb_available, nb_needed;
index_in_cluster = (offset >> 9) & (s->cluster_sectors - 1);
nb_needed = *num + index_in_cluster;
l1_bits = s->l2_bits + s->cluster_bits;
nb_available = (1ULL << l1_bits) - (offset & ((1ULL << l1_bits) - 1));
nb_available = (nb_available >> 9) + index_in_cluster;
if (nb_needed > nb_available) {
nb_needed = nb_available;
}
cluster_offset = 0;
l1_index = offset >> l1_bits;
if (l1_index >= s->l1_size)
goto out;
l2_offset = s->l1_table[l1_index];
if (!l2_offset)
goto out;
l2_offset &= ~QCOW_OFLAG_COPIED;
l2_table = l2_load(bs, l2_offset);
if (l2_table == NULL)
return 0;
l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
cluster_offset = be64_to_cpu(l2_table[l2_index]);
nb_clusters = size_to_clusters(s, nb_needed << 9);
if (!cluster_offset) {
c = count_contiguous_free_clusters(nb_clusters, &l2_table[l2_index]);
} else {
c = count_contiguous_clusters(nb_clusters, s->cluster_size,
&l2_table[l2_index], 0, QCOW_OFLAG_COPIED);
}
nb_available = (c * s->cluster_sectors);
out:
if (nb_available > nb_needed)
nb_available = nb_needed;
*num = nb_available - index_in_cluster;
return cluster_offset & ~QCOW_OFLAG_COPIED;
}
| {
"code": [],
"line_no": []
} | uint64_t FUNC_0(BlockDriverState *bs, uint64_t offset,
int *num)
{
BDRVQcowState *s = bs->opaque;
unsigned int VAR_0, VAR_1;
uint64_t l2_offset, *l2_table, cluster_offset;
int VAR_2, VAR_3;
unsigned int VAR_4, VAR_5;
uint64_t nb_available, nb_needed;
VAR_4 = (offset >> 9) & (s->cluster_sectors - 1);
nb_needed = *num + VAR_4;
VAR_2 = s->l2_bits + s->cluster_bits;
nb_available = (1ULL << VAR_2) - (offset & ((1ULL << VAR_2) - 1));
nb_available = (nb_available >> 9) + VAR_4;
if (nb_needed > nb_available) {
nb_needed = nb_available;
}
cluster_offset = 0;
VAR_0 = offset >> VAR_2;
if (VAR_0 >= s->l1_size)
goto out;
l2_offset = s->l1_table[VAR_0];
if (!l2_offset)
goto out;
l2_offset &= ~QCOW_OFLAG_COPIED;
l2_table = l2_load(bs, l2_offset);
if (l2_table == NULL)
return 0;
VAR_1 = (offset >> s->cluster_bits) & (s->l2_size - 1);
cluster_offset = be64_to_cpu(l2_table[VAR_1]);
VAR_5 = size_to_clusters(s, nb_needed << 9);
if (!cluster_offset) {
VAR_3 = count_contiguous_free_clusters(VAR_5, &l2_table[VAR_1]);
} else {
VAR_3 = count_contiguous_clusters(VAR_5, s->cluster_size,
&l2_table[VAR_1], 0, QCOW_OFLAG_COPIED);
}
nb_available = (VAR_3 * s->cluster_sectors);
out:
if (nb_available > nb_needed)
nb_available = nb_needed;
*num = nb_available - VAR_4;
return cluster_offset & ~QCOW_OFLAG_COPIED;
}
| [
"uint64_t FUNC_0(BlockDriverState *bs, uint64_t offset,\nint *num)\n{",
"BDRVQcowState *s = bs->opaque;",
"unsigned int VAR_0, VAR_1;",
"uint64_t l2_offset, *l2_table, cluster_offset;",
"int VAR_2, VAR_3;",
"unsigned int VAR_4, VAR_5;",
"uint64_t nb_available, nb_needed;",
"VAR_4 = (offset >> 9) & (s->cluster_sectors - 1);",
"nb_needed = *num + VAR_4;",
"VAR_2 = s->l2_bits + s->cluster_bits;",
"nb_available = (1ULL << VAR_2) - (offset & ((1ULL << VAR_2) - 1));",
"nb_available = (nb_available >> 9) + VAR_4;",
"if (nb_needed > nb_available) {",
"nb_needed = nb_available;",
"}",
"cluster_offset = 0;",
"VAR_0 = offset >> VAR_2;",
"if (VAR_0 >= s->l1_size)\ngoto out;",
"l2_offset = s->l1_table[VAR_0];",
"if (!l2_offset)\ngoto out;",
"l2_offset &= ~QCOW_OFLAG_COPIED;",
"l2_table = l2_load(bs, l2_offset);",
"if (l2_table == NULL)\nreturn 0;",
"VAR_1 = (offset >> s->cluster_bits) & (s->l2_size - 1);",
"cluster_offset = be64_to_cpu(l2_table[VAR_1]);",
"VAR_5 = size_to_clusters(s, nb_needed << 9);",
"if (!cluster_offset) {",
"VAR_3 = count_contiguous_free_clusters(VAR_5, &l2_table[VAR_1]);",
"} else {",
"VAR_3 = count_contiguous_clusters(VAR_5, s->cluster_size,\n&l2_table[VAR_1], 0, QCOW_OFLAG_COPIED);",
"}",
"nb_available = (VAR_3 * s->cluster_sectors);",
"out:\nif (nb_available > nb_needed)\nnb_available = nb_needed;",
"*num = nb_available - VAR_4;",
"return cluster_offset & ~QCOW_OFLAG_COPIED;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27
],
[
39
],
[
47
],
[
51
],
[
53
],
[
55
],
[
59
],
[
67
],
[
69,
71
],
[
75
],
[
83,
85
],
[
93
],
[
95
],
[
97,
99
],
[
107
],
[
109
],
[
111
],
[
115
],
[
119
],
[
121
],
[
125,
127
],
[
129
],
[
133
],
[
135,
137,
139
],
[
143
],
[
147
],
[
149
]
] |
18,266 | static bool lowprot_enabled(const CPUS390XState *env)
{
if (!(env->cregs[0] & CR0_LOWPROT)) {
return false;
}
if (!(env->psw.mask & PSW_MASK_DAT)) {
return true;
}
/* Check the private-space control bit */
switch (env->psw.mask & PSW_MASK_ASC) {
case PSW_ASC_PRIMARY:
return !(env->cregs[1] & _ASCE_PRIVATE_SPACE);
case PSW_ASC_SECONDARY:
return !(env->cregs[7] & _ASCE_PRIVATE_SPACE);
case PSW_ASC_HOME:
return !(env->cregs[13] & _ASCE_PRIVATE_SPACE);
default:
/* We don't support access register mode */
error_report("unsupported addressing mode");
exit(1);
}
}
| false | qemu | 2bcf018340cbf233f7145e643fc1bb367f23fd90 | static bool lowprot_enabled(const CPUS390XState *env)
{
if (!(env->cregs[0] & CR0_LOWPROT)) {
return false;
}
if (!(env->psw.mask & PSW_MASK_DAT)) {
return true;
}
switch (env->psw.mask & PSW_MASK_ASC) {
case PSW_ASC_PRIMARY:
return !(env->cregs[1] & _ASCE_PRIVATE_SPACE);
case PSW_ASC_SECONDARY:
return !(env->cregs[7] & _ASCE_PRIVATE_SPACE);
case PSW_ASC_HOME:
return !(env->cregs[13] & _ASCE_PRIVATE_SPACE);
default:
error_report("unsupported addressing mode");
exit(1);
}
}
| {
"code": [],
"line_no": []
} | static bool FUNC_0(const CPUS390XState *env)
{
if (!(env->cregs[0] & CR0_LOWPROT)) {
return false;
}
if (!(env->psw.mask & PSW_MASK_DAT)) {
return true;
}
switch (env->psw.mask & PSW_MASK_ASC) {
case PSW_ASC_PRIMARY:
return !(env->cregs[1] & _ASCE_PRIVATE_SPACE);
case PSW_ASC_SECONDARY:
return !(env->cregs[7] & _ASCE_PRIVATE_SPACE);
case PSW_ASC_HOME:
return !(env->cregs[13] & _ASCE_PRIVATE_SPACE);
default:
error_report("unsupported addressing mode");
exit(1);
}
}
| [
"static bool FUNC_0(const CPUS390XState *env)\n{",
"if (!(env->cregs[0] & CR0_LOWPROT)) {",
"return false;",
"}",
"if (!(env->psw.mask & PSW_MASK_DAT)) {",
"return true;",
"}",
"switch (env->psw.mask & PSW_MASK_ASC) {",
"case PSW_ASC_PRIMARY:\nreturn !(env->cregs[1] & _ASCE_PRIVATE_SPACE);",
"case PSW_ASC_SECONDARY:\nreturn !(env->cregs[7] & _ASCE_PRIVATE_SPACE);",
"case PSW_ASC_HOME:\nreturn !(env->cregs[13] & _ASCE_PRIVATE_SPACE);",
"default:\nerror_report(\"unsupported addressing mode\");",
"exit(1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
21
],
[
23,
25
],
[
27,
29
],
[
31,
33
],
[
35,
39
],
[
41
],
[
43
],
[
45
]
] |
18,269 | static int net_slirp_init(VLANState *vlan, const char *model, const char *name,
int restricted, const char *ip)
{
if (slirp_in_use) {
/* slirp only supports a single instance so far */
return -1;
}
if (!slirp_inited) {
slirp_inited = 1;
slirp_init(restricted, ip);
while (slirp_redirs) {
struct slirp_config_str *config = slirp_redirs;
slirp_redirection(NULL, config->str);
slirp_redirs = config->next;
qemu_free(config);
}
#ifndef _WIN32
if (slirp_smb_export) {
slirp_smb(slirp_smb_export);
}
#endif
}
slirp_vc = qemu_new_vlan_client(vlan, model, name, NULL, slirp_receive,
NULL, net_slirp_cleanup, NULL);
slirp_vc->info_str[0] = '\0';
slirp_in_use = 1;
return 0;
}
| false | qemu | ad196a9d0c14f681f010bb4b979030ec125ba976 | static int net_slirp_init(VLANState *vlan, const char *model, const char *name,
int restricted, const char *ip)
{
if (slirp_in_use) {
return -1;
}
if (!slirp_inited) {
slirp_inited = 1;
slirp_init(restricted, ip);
while (slirp_redirs) {
struct slirp_config_str *config = slirp_redirs;
slirp_redirection(NULL, config->str);
slirp_redirs = config->next;
qemu_free(config);
}
#ifndef _WIN32
if (slirp_smb_export) {
slirp_smb(slirp_smb_export);
}
#endif
}
slirp_vc = qemu_new_vlan_client(vlan, model, name, NULL, slirp_receive,
NULL, net_slirp_cleanup, NULL);
slirp_vc->info_str[0] = '\0';
slirp_in_use = 1;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(VLANState *VAR_0, const char *VAR_1, const char *VAR_2,
int VAR_3, const char *VAR_4)
{
if (slirp_in_use) {
return -1;
}
if (!slirp_inited) {
slirp_inited = 1;
slirp_init(VAR_3, VAR_4);
while (slirp_redirs) {
struct slirp_config_str *VAR_5 = slirp_redirs;
slirp_redirection(NULL, VAR_5->str);
slirp_redirs = VAR_5->next;
qemu_free(VAR_5);
}
#ifndef _WIN32
if (slirp_smb_export) {
slirp_smb(slirp_smb_export);
}
#endif
}
slirp_vc = qemu_new_vlan_client(VAR_0, VAR_1, VAR_2, NULL, slirp_receive,
NULL, net_slirp_cleanup, NULL);
slirp_vc->info_str[0] = '\0';
slirp_in_use = 1;
return 0;
}
| [
"static int FUNC_0(VLANState *VAR_0, const char *VAR_1, const char *VAR_2,\nint VAR_3, const char *VAR_4)\n{",
"if (slirp_in_use) {",
"return -1;",
"}",
"if (!slirp_inited) {",
"slirp_inited = 1;",
"slirp_init(VAR_3, VAR_4);",
"while (slirp_redirs) {",
"struct slirp_config_str *VAR_5 = slirp_redirs;",
"slirp_redirection(NULL, VAR_5->str);",
"slirp_redirs = VAR_5->next;",
"qemu_free(VAR_5);",
"}",
"#ifndef _WIN32\nif (slirp_smb_export) {",
"slirp_smb(slirp_smb_export);",
"}",
"#endif\n}",
"slirp_vc = qemu_new_vlan_client(VAR_0, VAR_1, VAR_2, NULL, slirp_receive,\nNULL, net_slirp_cleanup, NULL);",
"slirp_vc->info_str[0] = '\\0';",
"slirp_in_use = 1;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45,
47
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
61
]
] |
18,270 | static uint64_t hpdmc_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
MilkymistHpdmcState *s = opaque;
uint32_t r = 0;
addr >>= 2;
switch (addr) {
case R_SYSTEM:
case R_BYPASS:
case R_TIMING:
case R_IODELAY:
r = s->regs[addr];
break;
default:
error_report("milkymist_hpdmc: read access to unknown register 0x"
TARGET_FMT_plx, addr << 2);
break;
}
trace_milkymist_hpdmc_memory_read(addr << 2, r);
return r;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t hpdmc_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
MilkymistHpdmcState *s = opaque;
uint32_t r = 0;
addr >>= 2;
switch (addr) {
case R_SYSTEM:
case R_BYPASS:
case R_TIMING:
case R_IODELAY:
r = s->regs[addr];
break;
default:
error_report("milkymist_hpdmc: read access to unknown register 0x"
TARGET_FMT_plx, addr << 2);
break;
}
trace_milkymist_hpdmc_memory_read(addr << 2, r);
return r;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,
unsigned size)
{
MilkymistHpdmcState *s = opaque;
uint32_t r = 0;
addr >>= 2;
switch (addr) {
case R_SYSTEM:
case R_BYPASS:
case R_TIMING:
case R_IODELAY:
r = s->regs[addr];
break;
default:
error_report("milkymist_hpdmc: read access to unknown register 0x"
TARGET_FMT_plx, addr << 2);
break;
}
trace_milkymist_hpdmc_memory_read(addr << 2, r);
return r;
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{",
"MilkymistHpdmcState *s = opaque;",
"uint32_t r = 0;",
"addr >>= 2;",
"switch (addr) {",
"case R_SYSTEM:\ncase R_BYPASS:\ncase R_TIMING:\ncase R_IODELAY:\nr = s->regs[addr];",
"break;",
"default:\nerror_report(\"milkymist_hpdmc: read access to unknown register 0x\"\nTARGET_FMT_plx, addr << 2);",
"break;",
"}",
"trace_milkymist_hpdmc_memory_read(addr << 2, r);",
"return r;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17,
19,
21,
23,
25
],
[
27
],
[
31,
33,
35
],
[
37
],
[
39
],
[
43
],
[
47
],
[
49
]
] |
18,271 | int qemu_init_main_loop(Error **errp)
{
int ret;
GSource *src;
Error *local_error = NULL;
init_clocks();
ret = qemu_signal_init();
if (ret) {
return ret;
}
qemu_aio_context = aio_context_new(&local_error);
if (!qemu_aio_context) {
error_propagate(errp, local_error);
return -EMFILE;
}
qemu_notify_bh = qemu_bh_new(notify_event_cb, NULL);
gpollfds = g_array_new(FALSE, FALSE, sizeof(GPollFD));
src = aio_get_g_source(qemu_aio_context);
g_source_set_name(src, "aio-context");
g_source_attach(src, NULL);
g_source_unref(src);
src = iohandler_get_g_source();
g_source_set_name(src, "io-handler");
g_source_attach(src, NULL);
g_source_unref(src);
return 0;
}
| false | qemu | c2b38b277a7882a592f4f2ec955084b2b756daaa | int qemu_init_main_loop(Error **errp)
{
int ret;
GSource *src;
Error *local_error = NULL;
init_clocks();
ret = qemu_signal_init();
if (ret) {
return ret;
}
qemu_aio_context = aio_context_new(&local_error);
if (!qemu_aio_context) {
error_propagate(errp, local_error);
return -EMFILE;
}
qemu_notify_bh = qemu_bh_new(notify_event_cb, NULL);
gpollfds = g_array_new(FALSE, FALSE, sizeof(GPollFD));
src = aio_get_g_source(qemu_aio_context);
g_source_set_name(src, "aio-context");
g_source_attach(src, NULL);
g_source_unref(src);
src = iohandler_get_g_source();
g_source_set_name(src, "io-handler");
g_source_attach(src, NULL);
g_source_unref(src);
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(Error **VAR_0)
{
int VAR_1;
GSource *src;
Error *local_error = NULL;
init_clocks();
VAR_1 = qemu_signal_init();
if (VAR_1) {
return VAR_1;
}
qemu_aio_context = aio_context_new(&local_error);
if (!qemu_aio_context) {
error_propagate(VAR_0, local_error);
return -EMFILE;
}
qemu_notify_bh = qemu_bh_new(notify_event_cb, NULL);
gpollfds = g_array_new(FALSE, FALSE, sizeof(GPollFD));
src = aio_get_g_source(qemu_aio_context);
g_source_set_name(src, "aio-context");
g_source_attach(src, NULL);
g_source_unref(src);
src = iohandler_get_g_source();
g_source_set_name(src, "io-handler");
g_source_attach(src, NULL);
g_source_unref(src);
return 0;
}
| [
"int FUNC_0(Error **VAR_0)\n{",
"int VAR_1;",
"GSource *src;",
"Error *local_error = NULL;",
"init_clocks();",
"VAR_1 = qemu_signal_init();",
"if (VAR_1) {",
"return VAR_1;",
"}",
"qemu_aio_context = aio_context_new(&local_error);",
"if (!qemu_aio_context) {",
"error_propagate(VAR_0, local_error);",
"return -EMFILE;",
"}",
"qemu_notify_bh = qemu_bh_new(notify_event_cb, NULL);",
"gpollfds = g_array_new(FALSE, FALSE, sizeof(GPollFD));",
"src = aio_get_g_source(qemu_aio_context);",
"g_source_set_name(src, \"aio-context\");",
"g_source_attach(src, NULL);",
"g_source_unref(src);",
"src = iohandler_get_g_source();",
"g_source_set_name(src, \"io-handler\");",
"g_source_attach(src, NULL);",
"g_source_unref(src);",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
]
] |
18,273 | static int os_host_main_loop_wait(uint32_t timeout)
{
int ret;
glib_select_fill(&nfds, &rfds, &wfds, &xfds, &timeout);
if (timeout > 0) {
qemu_mutex_unlock_iothread();
}
/* We'll eventually drop fd_set completely. But for now we still have
* *_fill() and *_poll() functions that use rfds/wfds/xfds.
*/
gpollfds_from_select();
ret = g_poll((GPollFD *)gpollfds->data, gpollfds->len, timeout);
gpollfds_to_select(ret);
if (timeout > 0) {
qemu_mutex_lock_iothread();
}
glib_select_poll(&rfds, &wfds, &xfds, (ret < 0));
return ret;
}
| false | qemu | 48ce11ff972c733afaed3e2a2613a2e56081ec92 | static int os_host_main_loop_wait(uint32_t timeout)
{
int ret;
glib_select_fill(&nfds, &rfds, &wfds, &xfds, &timeout);
if (timeout > 0) {
qemu_mutex_unlock_iothread();
}
gpollfds_from_select();
ret = g_poll((GPollFD *)gpollfds->data, gpollfds->len, timeout);
gpollfds_to_select(ret);
if (timeout > 0) {
qemu_mutex_lock_iothread();
}
glib_select_poll(&rfds, &wfds, &xfds, (ret < 0));
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(uint32_t VAR_0)
{
int VAR_1;
glib_select_fill(&nfds, &rfds, &wfds, &xfds, &VAR_0);
if (VAR_0 > 0) {
qemu_mutex_unlock_iothread();
}
gpollfds_from_select();
VAR_1 = g_poll((GPollFD *)gpollfds->data, gpollfds->len, VAR_0);
gpollfds_to_select(VAR_1);
if (VAR_0 > 0) {
qemu_mutex_lock_iothread();
}
glib_select_poll(&rfds, &wfds, &xfds, (VAR_1 < 0));
return VAR_1;
}
| [
"static int FUNC_0(uint32_t VAR_0)\n{",
"int VAR_1;",
"glib_select_fill(&nfds, &rfds, &wfds, &xfds, &VAR_0);",
"if (VAR_0 > 0) {",
"qemu_mutex_unlock_iothread();",
"}",
"gpollfds_from_select();",
"VAR_1 = g_poll((GPollFD *)gpollfds->data, gpollfds->len, VAR_0);",
"gpollfds_to_select(VAR_1);",
"if (VAR_0 > 0) {",
"qemu_mutex_lock_iothread();",
"}",
"glib_select_poll(&rfds, &wfds, &xfds, (VAR_1 < 0));",
"return VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
27
],
[
31
],
[
35
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
]
] |
18,274 | static int cris_mmu_segmented_addr(int seg, uint32_t rw_mm_cfg)
{
return (1 << seg) & rw_mm_cfg;
}
| false | qemu | ef29a70d18c2d551cf4bb74b8aa9638caac3391b | static int cris_mmu_segmented_addr(int seg, uint32_t rw_mm_cfg)
{
return (1 << seg) & rw_mm_cfg;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(int VAR_0, uint32_t VAR_1)
{
return (1 << VAR_0) & VAR_1;
}
| [
"static int FUNC_0(int VAR_0, uint32_t VAR_1)\n{",
"return (1 << VAR_0) & VAR_1;",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
18,275 | static uint64_t pfpu_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
MilkymistPFPUState *s = opaque;
uint32_t r = 0;
addr >>= 2;
switch (addr) {
case R_CTL:
case R_MESHBASE:
case R_HMESHLAST:
case R_VMESHLAST:
case R_CODEPAGE:
case R_VERTICES:
case R_COLLISIONS:
case R_STRAYWRITES:
case R_LASTDMA:
case R_PC:
case R_DREGBASE:
case R_CODEBASE:
r = s->regs[addr];
break;
case GPR_BEGIN ... GPR_END:
r = s->gp_regs[addr - GPR_BEGIN];
break;
case MICROCODE_BEGIN ... MICROCODE_END:
r = s->microcode[get_microcode_address(s, addr)];
break;
default:
error_report("milkymist_pfpu: read access to unknown register 0x"
TARGET_FMT_plx, addr << 2);
break;
}
trace_milkymist_pfpu_memory_read(addr << 2, r);
return r;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t pfpu_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
MilkymistPFPUState *s = opaque;
uint32_t r = 0;
addr >>= 2;
switch (addr) {
case R_CTL:
case R_MESHBASE:
case R_HMESHLAST:
case R_VMESHLAST:
case R_CODEPAGE:
case R_VERTICES:
case R_COLLISIONS:
case R_STRAYWRITES:
case R_LASTDMA:
case R_PC:
case R_DREGBASE:
case R_CODEBASE:
r = s->regs[addr];
break;
case GPR_BEGIN ... GPR_END:
r = s->gp_regs[addr - GPR_BEGIN];
break;
case MICROCODE_BEGIN ... MICROCODE_END:
r = s->microcode[get_microcode_address(s, addr)];
break;
default:
error_report("milkymist_pfpu: read access to unknown register 0x"
TARGET_FMT_plx, addr << 2);
break;
}
trace_milkymist_pfpu_memory_read(addr << 2, r);
return r;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,
unsigned size)
{
MilkymistPFPUState *s = opaque;
uint32_t r = 0;
addr >>= 2;
switch (addr) {
case R_CTL:
case R_MESHBASE:
case R_HMESHLAST:
case R_VMESHLAST:
case R_CODEPAGE:
case R_VERTICES:
case R_COLLISIONS:
case R_STRAYWRITES:
case R_LASTDMA:
case R_PC:
case R_DREGBASE:
case R_CODEBASE:
r = s->regs[addr];
break;
case GPR_BEGIN ... GPR_END:
r = s->gp_regs[addr - GPR_BEGIN];
break;
case MICROCODE_BEGIN ... MICROCODE_END:
r = s->microcode[get_microcode_address(s, addr)];
break;
default:
error_report("milkymist_pfpu: read access to unknown register 0x"
TARGET_FMT_plx, addr << 2);
break;
}
trace_milkymist_pfpu_memory_read(addr << 2, r);
return r;
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{",
"MilkymistPFPUState *s = opaque;",
"uint32_t r = 0;",
"addr >>= 2;",
"switch (addr) {",
"case R_CTL:\ncase R_MESHBASE:\ncase R_HMESHLAST:\ncase R_VMESHLAST:\ncase R_CODEPAGE:\ncase R_VERTICES:\ncase R_COLLISIONS:\ncase R_STRAYWRITES:\ncase R_LASTDMA:\ncase R_PC:\ncase R_DREGBASE:\ncase R_CODEBASE:\nr = s->regs[addr];",
"break;",
"case GPR_BEGIN ... GPR_END:\nr = s->gp_regs[addr - GPR_BEGIN];",
"break;",
"case MICROCODE_BEGIN ... MICROCODE_END:\nr = s->microcode[get_microcode_address(s, addr)];",
"break;",
"default:\nerror_report(\"milkymist_pfpu: read access to unknown register 0x\"\nTARGET_FMT_plx, addr << 2);",
"break;",
"}",
"trace_milkymist_pfpu_memory_read(addr << 2, r);",
"return r;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17,
19,
21,
23,
25,
27,
29,
31,
33,
35,
37,
39,
41
],
[
43
],
[
45,
47
],
[
49
],
[
51,
53
],
[
55
],
[
59,
61,
63
],
[
65
],
[
67
],
[
71
],
[
75
],
[
77
]
] |
18,276 | static void qdev_reset(void *opaque)
{
DeviceState *dev = opaque;
if (dev->info->reset)
dev->info->reset(dev);
}
| false | qemu | ec990eb622ad46df5ddcb1e94c418c271894d416 | static void qdev_reset(void *opaque)
{
DeviceState *dev = opaque;
if (dev->info->reset)
dev->info->reset(dev);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
DeviceState *dev = VAR_0;
if (dev->info->reset)
dev->info->reset(dev);
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"DeviceState *dev = VAR_0;",
"if (dev->info->reset)\ndev->info->reset(dev);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
]
] |
18,277 | static void disas_cond_b_imm(DisasContext *s, uint32_t insn)
{
unsigned int cond;
uint64_t addr;
if ((insn & (1 << 4)) || (insn & (1 << 24))) {
unallocated_encoding(s);
return;
}
addr = s->pc + sextract32(insn, 5, 19) * 4 - 4;
cond = extract32(insn, 0, 4);
if (cond < 0x0e) {
/* genuinely conditional branches */
int label_match = gen_new_label();
arm_gen_test_cc(cond, label_match);
gen_goto_tb(s, 0, s->pc);
gen_set_label(label_match);
gen_goto_tb(s, 1, addr);
} else {
/* 0xe and 0xf are both "always" conditions */
gen_goto_tb(s, 0, addr);
}
}
| false | qemu | 42a268c241183877192c376d03bd9b6d527407c7 | static void disas_cond_b_imm(DisasContext *s, uint32_t insn)
{
unsigned int cond;
uint64_t addr;
if ((insn & (1 << 4)) || (insn & (1 << 24))) {
unallocated_encoding(s);
return;
}
addr = s->pc + sextract32(insn, 5, 19) * 4 - 4;
cond = extract32(insn, 0, 4);
if (cond < 0x0e) {
int label_match = gen_new_label();
arm_gen_test_cc(cond, label_match);
gen_goto_tb(s, 0, s->pc);
gen_set_label(label_match);
gen_goto_tb(s, 1, addr);
} else {
gen_goto_tb(s, 0, addr);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1)
{
unsigned int VAR_2;
uint64_t addr;
if ((VAR_1 & (1 << 4)) || (VAR_1 & (1 << 24))) {
unallocated_encoding(VAR_0);
return;
}
addr = VAR_0->pc + sextract32(VAR_1, 5, 19) * 4 - 4;
VAR_2 = extract32(VAR_1, 0, 4);
if (VAR_2 < 0x0e) {
int VAR_3 = gen_new_label();
arm_gen_test_cc(VAR_2, VAR_3);
gen_goto_tb(VAR_0, 0, VAR_0->pc);
gen_set_label(VAR_3);
gen_goto_tb(VAR_0, 1, addr);
} else {
gen_goto_tb(VAR_0, 0, addr);
}
}
| [
"static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1)\n{",
"unsigned int VAR_2;",
"uint64_t addr;",
"if ((VAR_1 & (1 << 4)) || (VAR_1 & (1 << 24))) {",
"unallocated_encoding(VAR_0);",
"return;",
"}",
"addr = VAR_0->pc + sextract32(VAR_1, 5, 19) * 4 - 4;",
"VAR_2 = extract32(VAR_1, 0, 4);",
"if (VAR_2 < 0x0e) {",
"int VAR_3 = gen_new_label();",
"arm_gen_test_cc(VAR_2, VAR_3);",
"gen_goto_tb(VAR_0, 0, VAR_0->pc);",
"gen_set_label(VAR_3);",
"gen_goto_tb(VAR_0, 1, addr);",
"} else {",
"gen_goto_tb(VAR_0, 0, addr);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
]
] |
18,280 | void tcg_gen_atomic_cmpxchg_i64(TCGv_i64 retv, TCGv addr, TCGv_i64 cmpv,
TCGv_i64 newv, TCGArg idx, TCGMemOp memop)
{
memop = tcg_canonicalize_memop(memop, 1, 0);
if (!parallel_cpus) {
TCGv_i64 t1 = tcg_temp_new_i64();
TCGv_i64 t2 = tcg_temp_new_i64();
tcg_gen_ext_i64(t2, cmpv, memop & MO_SIZE);
tcg_gen_qemu_ld_i64(t1, addr, idx, memop & ~MO_SIGN);
tcg_gen_movcond_i64(TCG_COND_EQ, t2, t1, t2, newv, t1);
tcg_gen_qemu_st_i64(t2, addr, idx, memop);
tcg_temp_free_i64(t2);
if (memop & MO_SIGN) {
tcg_gen_ext_i64(retv, t1, memop);
} else {
tcg_gen_mov_i64(retv, t1);
}
tcg_temp_free_i64(t1);
} else if ((memop & MO_SIZE) == MO_64) {
#ifdef CONFIG_ATOMIC64
gen_atomic_cx_i64 gen;
gen = table_cmpxchg[memop & (MO_SIZE | MO_BSWAP)];
tcg_debug_assert(gen != NULL);
#ifdef CONFIG_SOFTMMU
{
TCGv_i32 oi = tcg_const_i32(make_memop_idx(memop, idx));
gen(retv, tcg_ctx.tcg_env, addr, cmpv, newv, oi);
tcg_temp_free_i32(oi);
}
#else
gen(retv, tcg_ctx.tcg_env, addr, cmpv, newv);
#endif
#else
gen_helper_exit_atomic(tcg_ctx.tcg_env);
/* Produce a result, so that we have a well-formed opcode stream
with respect to uses of the result in the (dead) code following. */
tcg_gen_movi_i64(retv, 0);
#endif /* CONFIG_ATOMIC64 */
} else {
TCGv_i32 c32 = tcg_temp_new_i32();
TCGv_i32 n32 = tcg_temp_new_i32();
TCGv_i32 r32 = tcg_temp_new_i32();
tcg_gen_extrl_i64_i32(c32, cmpv);
tcg_gen_extrl_i64_i32(n32, newv);
tcg_gen_atomic_cmpxchg_i32(r32, addr, c32, n32, idx, memop & ~MO_SIGN);
tcg_temp_free_i32(c32);
tcg_temp_free_i32(n32);
tcg_gen_extu_i32_i64(retv, r32);
tcg_temp_free_i32(r32);
if (memop & MO_SIGN) {
tcg_gen_ext_i64(retv, retv, memop);
}
}
}
| false | qemu | e82d5a2460b0e176128027651ff9b104e4bdf5cc | void tcg_gen_atomic_cmpxchg_i64(TCGv_i64 retv, TCGv addr, TCGv_i64 cmpv,
TCGv_i64 newv, TCGArg idx, TCGMemOp memop)
{
memop = tcg_canonicalize_memop(memop, 1, 0);
if (!parallel_cpus) {
TCGv_i64 t1 = tcg_temp_new_i64();
TCGv_i64 t2 = tcg_temp_new_i64();
tcg_gen_ext_i64(t2, cmpv, memop & MO_SIZE);
tcg_gen_qemu_ld_i64(t1, addr, idx, memop & ~MO_SIGN);
tcg_gen_movcond_i64(TCG_COND_EQ, t2, t1, t2, newv, t1);
tcg_gen_qemu_st_i64(t2, addr, idx, memop);
tcg_temp_free_i64(t2);
if (memop & MO_SIGN) {
tcg_gen_ext_i64(retv, t1, memop);
} else {
tcg_gen_mov_i64(retv, t1);
}
tcg_temp_free_i64(t1);
} else if ((memop & MO_SIZE) == MO_64) {
#ifdef CONFIG_ATOMIC64
gen_atomic_cx_i64 gen;
gen = table_cmpxchg[memop & (MO_SIZE | MO_BSWAP)];
tcg_debug_assert(gen != NULL);
#ifdef CONFIG_SOFTMMU
{
TCGv_i32 oi = tcg_const_i32(make_memop_idx(memop, idx));
gen(retv, tcg_ctx.tcg_env, addr, cmpv, newv, oi);
tcg_temp_free_i32(oi);
}
#else
gen(retv, tcg_ctx.tcg_env, addr, cmpv, newv);
#endif
#else
gen_helper_exit_atomic(tcg_ctx.tcg_env);
tcg_gen_movi_i64(retv, 0);
#endif
} else {
TCGv_i32 c32 = tcg_temp_new_i32();
TCGv_i32 n32 = tcg_temp_new_i32();
TCGv_i32 r32 = tcg_temp_new_i32();
tcg_gen_extrl_i64_i32(c32, cmpv);
tcg_gen_extrl_i64_i32(n32, newv);
tcg_gen_atomic_cmpxchg_i32(r32, addr, c32, n32, idx, memop & ~MO_SIGN);
tcg_temp_free_i32(c32);
tcg_temp_free_i32(n32);
tcg_gen_extu_i32_i64(retv, r32);
tcg_temp_free_i32(r32);
if (memop & MO_SIGN) {
tcg_gen_ext_i64(retv, retv, memop);
}
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(TCGv_i64 VAR_0, TCGv VAR_1, TCGv_i64 VAR_2,
TCGv_i64 VAR_3, TCGArg VAR_4, TCGMemOp VAR_5)
{
VAR_5 = tcg_canonicalize_memop(VAR_5, 1, 0);
if (!parallel_cpus) {
TCGv_i64 t1 = tcg_temp_new_i64();
TCGv_i64 t2 = tcg_temp_new_i64();
tcg_gen_ext_i64(t2, VAR_2, VAR_5 & MO_SIZE);
tcg_gen_qemu_ld_i64(t1, VAR_1, VAR_4, VAR_5 & ~MO_SIGN);
tcg_gen_movcond_i64(TCG_COND_EQ, t2, t1, t2, VAR_3, t1);
tcg_gen_qemu_st_i64(t2, VAR_1, VAR_4, VAR_5);
tcg_temp_free_i64(t2);
if (VAR_5 & MO_SIGN) {
tcg_gen_ext_i64(VAR_0, t1, VAR_5);
} else {
tcg_gen_mov_i64(VAR_0, t1);
}
tcg_temp_free_i64(t1);
} else if ((VAR_5 & MO_SIZE) == MO_64) {
#ifdef CONFIG_ATOMIC64
gen_atomic_cx_i64 gen;
gen = table_cmpxchg[VAR_5 & (MO_SIZE | MO_BSWAP)];
tcg_debug_assert(gen != NULL);
#ifdef CONFIG_SOFTMMU
{
TCGv_i32 oi = tcg_const_i32(make_memop_idx(VAR_5, VAR_4));
gen(VAR_0, tcg_ctx.tcg_env, VAR_1, VAR_2, VAR_3, oi);
tcg_temp_free_i32(oi);
}
#else
gen(VAR_0, tcg_ctx.tcg_env, VAR_1, VAR_2, VAR_3);
#endif
#else
gen_helper_exit_atomic(tcg_ctx.tcg_env);
tcg_gen_movi_i64(VAR_0, 0);
#endif
} else {
TCGv_i32 c32 = tcg_temp_new_i32();
TCGv_i32 n32 = tcg_temp_new_i32();
TCGv_i32 r32 = tcg_temp_new_i32();
tcg_gen_extrl_i64_i32(c32, VAR_2);
tcg_gen_extrl_i64_i32(n32, VAR_3);
tcg_gen_atomic_cmpxchg_i32(r32, VAR_1, c32, n32, VAR_4, VAR_5 & ~MO_SIGN);
tcg_temp_free_i32(c32);
tcg_temp_free_i32(n32);
tcg_gen_extu_i32_i64(VAR_0, r32);
tcg_temp_free_i32(r32);
if (VAR_5 & MO_SIGN) {
tcg_gen_ext_i64(VAR_0, VAR_0, VAR_5);
}
}
}
| [
"void FUNC_0(TCGv_i64 VAR_0, TCGv VAR_1, TCGv_i64 VAR_2,\nTCGv_i64 VAR_3, TCGArg VAR_4, TCGMemOp VAR_5)\n{",
"VAR_5 = tcg_canonicalize_memop(VAR_5, 1, 0);",
"if (!parallel_cpus) {",
"TCGv_i64 t1 = tcg_temp_new_i64();",
"TCGv_i64 t2 = tcg_temp_new_i64();",
"tcg_gen_ext_i64(t2, VAR_2, VAR_5 & MO_SIZE);",
"tcg_gen_qemu_ld_i64(t1, VAR_1, VAR_4, VAR_5 & ~MO_SIGN);",
"tcg_gen_movcond_i64(TCG_COND_EQ, t2, t1, t2, VAR_3, t1);",
"tcg_gen_qemu_st_i64(t2, VAR_1, VAR_4, VAR_5);",
"tcg_temp_free_i64(t2);",
"if (VAR_5 & MO_SIGN) {",
"tcg_gen_ext_i64(VAR_0, t1, VAR_5);",
"} else {",
"tcg_gen_mov_i64(VAR_0, t1);",
"}",
"tcg_temp_free_i64(t1);",
"} else if ((VAR_5 & MO_SIZE) == MO_64) {",
"#ifdef CONFIG_ATOMIC64\ngen_atomic_cx_i64 gen;",
"gen = table_cmpxchg[VAR_5 & (MO_SIZE | MO_BSWAP)];",
"tcg_debug_assert(gen != NULL);",
"#ifdef CONFIG_SOFTMMU\n{",
"TCGv_i32 oi = tcg_const_i32(make_memop_idx(VAR_5, VAR_4));",
"gen(VAR_0, tcg_ctx.tcg_env, VAR_1, VAR_2, VAR_3, oi);",
"tcg_temp_free_i32(oi);",
"}",
"#else\ngen(VAR_0, tcg_ctx.tcg_env, VAR_1, VAR_2, VAR_3);",
"#endif\n#else\ngen_helper_exit_atomic(tcg_ctx.tcg_env);",
"tcg_gen_movi_i64(VAR_0, 0);",
"#endif\n} else {",
"TCGv_i32 c32 = tcg_temp_new_i32();",
"TCGv_i32 n32 = tcg_temp_new_i32();",
"TCGv_i32 r32 = tcg_temp_new_i32();",
"tcg_gen_extrl_i64_i32(c32, VAR_2);",
"tcg_gen_extrl_i64_i32(n32, VAR_3);",
"tcg_gen_atomic_cmpxchg_i32(r32, VAR_1, c32, n32, VAR_4, VAR_5 & ~MO_SIGN);",
"tcg_temp_free_i32(c32);",
"tcg_temp_free_i32(n32);",
"tcg_gen_extu_i32_i64(VAR_0, r32);",
"tcg_temp_free_i32(r32);",
"if (VAR_5 & MO_SIGN) {",
"tcg_gen_ext_i64(VAR_0, VAR_0, VAR_5);",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
53
],
[
55
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75,
77,
79
],
[
85
],
[
87,
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
]
] |
18,281 | static void scsi_disk_unit_attention_reported(SCSIDevice *dev)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
if (s->media_changed) {
s->media_changed = false;
s->qdev.unit_attention = SENSE_CODE(MEDIUM_CHANGED);
}
}
| false | qemu | e48e84ea80cb2e7fe6e48196ce187cfba6e3eb2c | static void scsi_disk_unit_attention_reported(SCSIDevice *dev)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
if (s->media_changed) {
s->media_changed = false;
s->qdev.unit_attention = SENSE_CODE(MEDIUM_CHANGED);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(SCSIDevice *VAR_0)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, VAR_0);
if (s->media_changed) {
s->media_changed = false;
s->qdev.unit_attention = SENSE_CODE(MEDIUM_CHANGED);
}
}
| [
"static void FUNC_0(SCSIDevice *VAR_0)\n{",
"SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, VAR_0);",
"if (s->media_changed) {",
"s->media_changed = false;",
"s->qdev.unit_attention = SENSE_CODE(MEDIUM_CHANGED);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
18,284 | static void lsi_command_complete(SCSIBus *bus, int reason, uint32_t tag,
uint32_t arg)
{
LSIState *s = DO_UPCAST(LSIState, dev.qdev, bus->qbus.parent);
int out;
out = (s->sstat1 & PHASE_MASK) == PHASE_DO;
if (reason == SCSI_REASON_DONE) {
DPRINTF("Command complete status=%d\n", (int)arg);
s->status = arg;
s->command_complete = 2;
if (s->waiting && s->dbc != 0) {
/* Raise phase mismatch for short transfers. */
lsi_bad_phase(s, out, PHASE_ST);
} else {
lsi_set_phase(s, PHASE_ST);
}
qemu_free(s->current);
s->current = NULL;
lsi_resume_script(s);
return;
}
if (s->waiting == 1 || !s->current || tag != s->current->tag ||
(lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON))) {
if (lsi_queue_tag(s, tag, arg))
return;
}
/* host adapter (re)connected */
DPRINTF("Data ready tag=0x%x len=%d\n", tag, arg);
s->current->dma_len = arg;
s->command_complete = 1;
if (!s->waiting)
return;
if (s->waiting == 1 || s->dbc == 0) {
lsi_resume_script(s);
} else {
lsi_do_dma(s, out);
}
}
| true | qemu | 5c6c0e513600ba57c3e73b7151d3c0664438f7b5 | static void lsi_command_complete(SCSIBus *bus, int reason, uint32_t tag,
uint32_t arg)
{
LSIState *s = DO_UPCAST(LSIState, dev.qdev, bus->qbus.parent);
int out;
out = (s->sstat1 & PHASE_MASK) == PHASE_DO;
if (reason == SCSI_REASON_DONE) {
DPRINTF("Command complete status=%d\n", (int)arg);
s->status = arg;
s->command_complete = 2;
if (s->waiting && s->dbc != 0) {
lsi_bad_phase(s, out, PHASE_ST);
} else {
lsi_set_phase(s, PHASE_ST);
}
qemu_free(s->current);
s->current = NULL;
lsi_resume_script(s);
return;
}
if (s->waiting == 1 || !s->current || tag != s->current->tag ||
(lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON))) {
if (lsi_queue_tag(s, tag, arg))
return;
}
DPRINTF("Data ready tag=0x%x len=%d\n", tag, arg);
s->current->dma_len = arg;
s->command_complete = 1;
if (!s->waiting)
return;
if (s->waiting == 1 || s->dbc == 0) {
lsi_resume_script(s);
} else {
lsi_do_dma(s, out);
}
}
| {
"code": [
" uint32_t arg)",
"static void lsi_command_complete(SCSIBus *bus, int reason, uint32_t tag,",
" uint32_t arg)",
" LSIState *s = DO_UPCAST(LSIState, dev.qdev, bus->qbus.parent);",
" qemu_free(s->current);",
" s->current = NULL;",
" if (s->waiting == 1 || !s->current || tag != s->current->tag ||",
" if (lsi_queue_tag(s, tag, arg))",
" DPRINTF(\"Data ready tag=0x%x len=%d\\n\", tag, arg);"
],
"line_no": [
3,
1,
3,
7,
37,
39,
51,
55,
65
]
} | static void FUNC_0(SCSIBus *VAR_0, int VAR_1, uint32_t VAR_2,
uint32_t VAR_3)
{
LSIState *s = DO_UPCAST(LSIState, dev.qdev, VAR_0->qbus.parent);
int VAR_4;
VAR_4 = (s->sstat1 & PHASE_MASK) == PHASE_DO;
if (VAR_1 == SCSI_REASON_DONE) {
DPRINTF("Command complete status=%d\n", (int)VAR_3);
s->status = VAR_3;
s->command_complete = 2;
if (s->waiting && s->dbc != 0) {
lsi_bad_phase(s, VAR_4, PHASE_ST);
} else {
lsi_set_phase(s, PHASE_ST);
}
qemu_free(s->current);
s->current = NULL;
lsi_resume_script(s);
return;
}
if (s->waiting == 1 || !s->current || VAR_2 != s->current->VAR_2 ||
(lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON))) {
if (lsi_queue_tag(s, VAR_2, VAR_3))
return;
}
DPRINTF("Data ready VAR_2=0x%x len=%d\n", VAR_2, VAR_3);
s->current->dma_len = VAR_3;
s->command_complete = 1;
if (!s->waiting)
return;
if (s->waiting == 1 || s->dbc == 0) {
lsi_resume_script(s);
} else {
lsi_do_dma(s, VAR_4);
}
}
| [
"static void FUNC_0(SCSIBus *VAR_0, int VAR_1, uint32_t VAR_2,\nuint32_t VAR_3)\n{",
"LSIState *s = DO_UPCAST(LSIState, dev.qdev, VAR_0->qbus.parent);",
"int VAR_4;",
"VAR_4 = (s->sstat1 & PHASE_MASK) == PHASE_DO;",
"if (VAR_1 == SCSI_REASON_DONE) {",
"DPRINTF(\"Command complete status=%d\\n\", (int)VAR_3);",
"s->status = VAR_3;",
"s->command_complete = 2;",
"if (s->waiting && s->dbc != 0) {",
"lsi_bad_phase(s, VAR_4, PHASE_ST);",
"} else {",
"lsi_set_phase(s, PHASE_ST);",
"}",
"qemu_free(s->current);",
"s->current = NULL;",
"lsi_resume_script(s);",
"return;",
"}",
"if (s->waiting == 1 || !s->current || VAR_2 != s->current->VAR_2 ||\n(lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON))) {",
"if (lsi_queue_tag(s, VAR_2, VAR_3))\nreturn;",
"}",
"DPRINTF(\"Data ready VAR_2=0x%x len=%d\\n\", VAR_2, VAR_3);",
"s->current->dma_len = VAR_3;",
"s->command_complete = 1;",
"if (!s->waiting)\nreturn;",
"if (s->waiting == 1 || s->dbc == 0) {",
"lsi_resume_script(s);",
"} else {",
"lsi_do_dma(s, VAR_4);",
"}",
"}"
] | [
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
1,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
51,
53
],
[
55,
57
],
[
59
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
]
] |
18,286 | static void xenstore_record_dm_state(struct xs_handle *xs, const char *state)
{
char path[50];
if (xs == NULL) {
fprintf(stderr, "xenstore connection not initialized\n");
exit(1);
}
snprintf(path, sizeof (path), "/local/domain/0/device-model/%u/state", xen_domid);
if (!xs_write(xs, XBT_NULL, path, state, strlen(state))) {
fprintf(stderr, "error recording dm state\n");
exit(1);
}
}
| true | qemu | 33876dfad64bc481f59c5e9ccf60db78624c4b93 | static void xenstore_record_dm_state(struct xs_handle *xs, const char *state)
{
char path[50];
if (xs == NULL) {
fprintf(stderr, "xenstore connection not initialized\n");
exit(1);
}
snprintf(path, sizeof (path), "/local/domain/0/device-model/%u/state", xen_domid);
if (!xs_write(xs, XBT_NULL, path, state, strlen(state))) {
fprintf(stderr, "error recording dm state\n");
exit(1);
}
}
| {
"code": [
" snprintf(path, sizeof (path), \"/local/domain/0/device-model/%u/state\", xen_domid);"
],
"line_no": [
19
]
} | static void FUNC_0(struct xs_handle *VAR_0, const char *VAR_1)
{
char VAR_2[50];
if (VAR_0 == NULL) {
fprintf(stderr, "xenstore connection not initialized\n");
exit(1);
}
snprintf(VAR_2, sizeof (VAR_2), "/local/domain/0/device-model/%u/VAR_1", xen_domid);
if (!xs_write(VAR_0, XBT_NULL, VAR_2, VAR_1, strlen(VAR_1))) {
fprintf(stderr, "error recording dm VAR_1\n");
exit(1);
}
}
| [
"static void FUNC_0(struct xs_handle *VAR_0, const char *VAR_1)\n{",
"char VAR_2[50];",
"if (VAR_0 == NULL) {",
"fprintf(stderr, \"xenstore connection not initialized\\n\");",
"exit(1);",
"}",
"snprintf(VAR_2, sizeof (VAR_2), \"/local/domain/0/device-model/%u/VAR_1\", xen_domid);",
"if (!xs_write(VAR_0, XBT_NULL, VAR_2, VAR_1, strlen(VAR_1))) {",
"fprintf(stderr, \"error recording dm VAR_1\\n\");",
"exit(1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
18,287 | static void *ff_realloc_static(void *ptr, unsigned int size)
{
int i;
if(!ptr)
return av_mallocz_static(size);
/* Look for the old ptr */
for(i = 0; i < last_static; i++) {
if(array_static[i] == ptr) {
array_static[i] = av_realloc(array_static[i], size);
return array_static[i];
}
}
return NULL;
}
| true | FFmpeg | b9c8388710a06544812739eedc0a40d3451491dc | static void *ff_realloc_static(void *ptr, unsigned int size)
{
int i;
if(!ptr)
return av_mallocz_static(size);
for(i = 0; i < last_static; i++) {
if(array_static[i] == ptr) {
array_static[i] = av_realloc(array_static[i], size);
return array_static[i];
}
}
return NULL;
}
| {
"code": [
" int i;",
" if(!ptr)",
" return av_mallocz_static(size);",
" for(i = 0; i < last_static; i++) {",
" if(array_static[i] == ptr) {",
" array_static[i] = av_realloc(array_static[i], size);",
" return array_static[i];",
" return NULL;"
],
"line_no": [
5,
7,
9,
13,
15,
17,
19,
25
]
} | static void *FUNC_0(void *VAR_0, unsigned int VAR_1)
{
int VAR_2;
if(!VAR_0)
return av_mallocz_static(VAR_1);
for(VAR_2 = 0; VAR_2 < last_static; VAR_2++) {
if(array_static[VAR_2] == VAR_0) {
array_static[VAR_2] = av_realloc(array_static[VAR_2], VAR_1);
return array_static[VAR_2];
}
}
return NULL;
}
| [
"static void *FUNC_0(void *VAR_0, unsigned int VAR_1)\n{",
"int VAR_2;",
"if(!VAR_0)\nreturn av_mallocz_static(VAR_1);",
"for(VAR_2 = 0; VAR_2 < last_static; VAR_2++) {",
"if(array_static[VAR_2] == VAR_0) {",
"array_static[VAR_2] = av_realloc(array_static[VAR_2], VAR_1);",
"return array_static[VAR_2];",
"}",
"}",
"return NULL;",
"}"
] | [
0,
1,
1,
1,
1,
1,
1,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
]
] |
18,288 | static int vhdx_log_read_desc(BlockDriverState *bs, BDRVVHDXState *s,
VHDXLogEntries *log, VHDXLogDescEntries **buffer,
bool convert_endian)
{
int ret = 0;
uint32_t desc_sectors;
uint32_t sectors_read;
VHDXLogEntryHeader hdr;
VHDXLogDescEntries *desc_entries = NULL;
VHDXLogDescriptor desc;
int i;
assert(*buffer == NULL);
ret = vhdx_log_peek_hdr(bs, log, &hdr);
if (ret < 0) {
goto exit;
}
if (vhdx_log_hdr_is_valid(log, &hdr, s) == false) {
ret = -EINVAL;
goto exit;
}
desc_sectors = vhdx_compute_desc_sectors(hdr.descriptor_count);
desc_entries = qemu_blockalign(bs, desc_sectors * VHDX_LOG_SECTOR_SIZE);
ret = vhdx_log_read_sectors(bs, log, §ors_read, desc_entries,
desc_sectors, false);
if (ret < 0) {
goto free_and_exit;
}
if (sectors_read != desc_sectors) {
ret = -EINVAL;
goto free_and_exit;
}
/* put in proper endianness, and validate each desc */
for (i = 0; i < hdr.descriptor_count; i++) {
desc = desc_entries->desc[i];
vhdx_log_desc_le_import(&desc);
if (convert_endian) {
desc_entries->desc[i] = desc;
}
if (vhdx_log_desc_is_valid(&desc, &hdr) == false) {
ret = -EINVAL;
goto free_and_exit;
}
}
if (convert_endian) {
desc_entries->hdr = hdr;
}
*buffer = desc_entries;
goto exit;
free_and_exit:
qemu_vfree(desc_entries);
exit:
return ret;
}
| true | qemu | a67e128a4f40cf07abd86f92d0d3c913db2ad885 | static int vhdx_log_read_desc(BlockDriverState *bs, BDRVVHDXState *s,
VHDXLogEntries *log, VHDXLogDescEntries **buffer,
bool convert_endian)
{
int ret = 0;
uint32_t desc_sectors;
uint32_t sectors_read;
VHDXLogEntryHeader hdr;
VHDXLogDescEntries *desc_entries = NULL;
VHDXLogDescriptor desc;
int i;
assert(*buffer == NULL);
ret = vhdx_log_peek_hdr(bs, log, &hdr);
if (ret < 0) {
goto exit;
}
if (vhdx_log_hdr_is_valid(log, &hdr, s) == false) {
ret = -EINVAL;
goto exit;
}
desc_sectors = vhdx_compute_desc_sectors(hdr.descriptor_count);
desc_entries = qemu_blockalign(bs, desc_sectors * VHDX_LOG_SECTOR_SIZE);
ret = vhdx_log_read_sectors(bs, log, §ors_read, desc_entries,
desc_sectors, false);
if (ret < 0) {
goto free_and_exit;
}
if (sectors_read != desc_sectors) {
ret = -EINVAL;
goto free_and_exit;
}
for (i = 0; i < hdr.descriptor_count; i++) {
desc = desc_entries->desc[i];
vhdx_log_desc_le_import(&desc);
if (convert_endian) {
desc_entries->desc[i] = desc;
}
if (vhdx_log_desc_is_valid(&desc, &hdr) == false) {
ret = -EINVAL;
goto free_and_exit;
}
}
if (convert_endian) {
desc_entries->hdr = hdr;
}
*buffer = desc_entries;
goto exit;
free_and_exit:
qemu_vfree(desc_entries);
exit:
return ret;
}
| {
"code": [
" desc_entries = qemu_blockalign(bs, desc_sectors * VHDX_LOG_SECTOR_SIZE);"
],
"line_no": [
51
]
} | static int FUNC_0(BlockDriverState *VAR_0, BDRVVHDXState *VAR_1,
VHDXLogEntries *VAR_2, VHDXLogDescEntries **VAR_3,
bool VAR_4)
{
int VAR_5 = 0;
uint32_t desc_sectors;
uint32_t sectors_read;
VHDXLogEntryHeader hdr;
VHDXLogDescEntries *desc_entries = NULL;
VHDXLogDescriptor desc;
int VAR_6;
assert(*VAR_3 == NULL);
VAR_5 = vhdx_log_peek_hdr(VAR_0, VAR_2, &hdr);
if (VAR_5 < 0) {
goto exit;
}
if (vhdx_log_hdr_is_valid(VAR_2, &hdr, VAR_1) == false) {
VAR_5 = -EINVAL;
goto exit;
}
desc_sectors = vhdx_compute_desc_sectors(hdr.descriptor_count);
desc_entries = qemu_blockalign(VAR_0, desc_sectors * VHDX_LOG_SECTOR_SIZE);
VAR_5 = vhdx_log_read_sectors(VAR_0, VAR_2, §ors_read, desc_entries,
desc_sectors, false);
if (VAR_5 < 0) {
goto free_and_exit;
}
if (sectors_read != desc_sectors) {
VAR_5 = -EINVAL;
goto free_and_exit;
}
for (VAR_6 = 0; VAR_6 < hdr.descriptor_count; VAR_6++) {
desc = desc_entries->desc[VAR_6];
vhdx_log_desc_le_import(&desc);
if (VAR_4) {
desc_entries->desc[VAR_6] = desc;
}
if (vhdx_log_desc_is_valid(&desc, &hdr) == false) {
VAR_5 = -EINVAL;
goto free_and_exit;
}
}
if (VAR_4) {
desc_entries->hdr = hdr;
}
*VAR_3 = desc_entries;
goto exit;
free_and_exit:
qemu_vfree(desc_entries);
exit:
return VAR_5;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, BDRVVHDXState *VAR_1,\nVHDXLogEntries *VAR_2, VHDXLogDescEntries **VAR_3,\nbool VAR_4)\n{",
"int VAR_5 = 0;",
"uint32_t desc_sectors;",
"uint32_t sectors_read;",
"VHDXLogEntryHeader hdr;",
"VHDXLogDescEntries *desc_entries = NULL;",
"VHDXLogDescriptor desc;",
"int VAR_6;",
"assert(*VAR_3 == NULL);",
"VAR_5 = vhdx_log_peek_hdr(VAR_0, VAR_2, &hdr);",
"if (VAR_5 < 0) {",
"goto exit;",
"}",
"if (vhdx_log_hdr_is_valid(VAR_2, &hdr, VAR_1) == false) {",
"VAR_5 = -EINVAL;",
"goto exit;",
"}",
"desc_sectors = vhdx_compute_desc_sectors(hdr.descriptor_count);",
"desc_entries = qemu_blockalign(VAR_0, desc_sectors * VHDX_LOG_SECTOR_SIZE);",
"VAR_5 = vhdx_log_read_sectors(VAR_0, VAR_2, §ors_read, desc_entries,\ndesc_sectors, false);",
"if (VAR_5 < 0) {",
"goto free_and_exit;",
"}",
"if (sectors_read != desc_sectors) {",
"VAR_5 = -EINVAL;",
"goto free_and_exit;",
"}",
"for (VAR_6 = 0; VAR_6 < hdr.descriptor_count; VAR_6++) {",
"desc = desc_entries->desc[VAR_6];",
"vhdx_log_desc_le_import(&desc);",
"if (VAR_4) {",
"desc_entries->desc[VAR_6] = desc;",
"}",
"if (vhdx_log_desc_is_valid(&desc, &hdr) == false) {",
"VAR_5 = -EINVAL;",
"goto free_and_exit;",
"}",
"}",
"if (VAR_4) {",
"desc_entries->hdr = hdr;",
"}",
"*VAR_3 = desc_entries;",
"goto exit;",
"free_and_exit:\nqemu_vfree(desc_entries);",
"exit:\nreturn VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
113,
115
],
[
117,
119
],
[
121
]
] |
18,289 | static int irq_cpu_hotplug_init(SCLPEvent *event)
{
irq_cpu_hotplug = *qemu_allocate_irqs(trigger_signal, event, 1);
return 0;
}
| true | qemu | 7b53f2940e3bf43ae50c929330a4837ca4da7a94 | static int irq_cpu_hotplug_init(SCLPEvent *event)
{
irq_cpu_hotplug = *qemu_allocate_irqs(trigger_signal, event, 1);
return 0;
}
| {
"code": [
" irq_cpu_hotplug = *qemu_allocate_irqs(trigger_signal, event, 1);"
],
"line_no": [
5
]
} | static int FUNC_0(SCLPEvent *VAR_0)
{
irq_cpu_hotplug = *qemu_allocate_irqs(trigger_signal, VAR_0, 1);
return 0;
}
| [
"static int FUNC_0(SCLPEvent *VAR_0)\n{",
"irq_cpu_hotplug = *qemu_allocate_irqs(trigger_signal, VAR_0, 1);",
"return 0;",
"}"
] | [
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
18,291 | static int escape124_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
int buf_size = avpkt->size;
Escape124Context *s = avctx->priv_data;
AVFrame *frame = data;
GetBitContext gb;
unsigned frame_flags, frame_size;
unsigned i;
unsigned superblock_index, cb_index = 1,
superblock_col_index = 0,
superblocks_per_row = avctx->width / 8, skip = -1;
uint16_t* old_frame_data, *new_frame_data;
unsigned old_stride, new_stride;
int ret;
if ((ret = init_get_bits8(&gb, avpkt->data, avpkt->size)) < 0)
return ret;
// This call also guards the potential depth reads for the
// codebook unpacking.
if (!can_safely_read(&gb, 64))
return -1;
frame_flags = get_bits_long(&gb, 32);
frame_size = get_bits_long(&gb, 32);
// Leave last frame unchanged
// FIXME: Is this necessary? I haven't seen it in any real samples
if (!(frame_flags & 0x114) || !(frame_flags & 0x7800000)) {
if (!s->frame.data[0])
return AVERROR_INVALIDDATA;
av_log(avctx, AV_LOG_DEBUG, "Skipping frame\n");
*got_frame = 1;
if ((ret = av_frame_ref(frame, &s->frame)) < 0)
return ret;
return frame_size;
}
for (i = 0; i < 3; i++) {
if (frame_flags & (1 << (17 + i))) {
unsigned cb_depth, cb_size;
if (i == 2) {
// This codebook can be cut off at places other than
// powers of 2, leaving some of the entries undefined.
cb_size = get_bits_long(&gb, 20);
cb_depth = av_log2(cb_size - 1) + 1;
} else {
cb_depth = get_bits(&gb, 4);
if (i == 0) {
// This is the most basic codebook: pow(2,depth) entries
// for a depth-length key
cb_size = 1 << cb_depth;
} else {
// This codebook varies per superblock
// FIXME: I don't think this handles integer overflow
// properly
cb_size = s->num_superblocks << cb_depth;
}
}
av_free(s->codebooks[i].blocks);
s->codebooks[i] = unpack_codebook(&gb, cb_depth, cb_size);
if (!s->codebooks[i].blocks)
return -1;
}
}
if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
return ret;
new_frame_data = (uint16_t*)frame->data[0];
new_stride = frame->linesize[0] / 2;
old_frame_data = (uint16_t*)s->frame.data[0];
old_stride = s->frame.linesize[0] / 2;
for (superblock_index = 0; superblock_index < s->num_superblocks;
superblock_index++) {
MacroBlock mb;
SuperBlock sb;
unsigned multi_mask = 0;
if (skip == -1) {
// Note that this call will make us skip the rest of the blocks
// if the frame prematurely ends
skip = decode_skip_count(&gb);
}
if (skip) {
copy_superblock(new_frame_data, new_stride,
old_frame_data, old_stride);
} else {
copy_superblock(sb.pixels, 8,
old_frame_data, old_stride);
while (can_safely_read(&gb, 1) && !get_bits1(&gb)) {
unsigned mask;
mb = decode_macroblock(s, &gb, &cb_index, superblock_index);
mask = get_bits(&gb, 16);
multi_mask |= mask;
for (i = 0; i < 16; i++) {
if (mask & mask_matrix[i]) {
insert_mb_into_sb(&sb, mb, i);
}
}
}
if (can_safely_read(&gb, 1) && !get_bits1(&gb)) {
unsigned inv_mask = get_bits(&gb, 4);
for (i = 0; i < 4; i++) {
if (inv_mask & (1 << i)) {
multi_mask ^= 0xF << i*4;
} else {
multi_mask ^= get_bits(&gb, 4) << i*4;
}
}
for (i = 0; i < 16; i++) {
if (multi_mask & mask_matrix[i]) {
if (!can_safely_read(&gb, 1))
break;
mb = decode_macroblock(s, &gb, &cb_index,
superblock_index);
insert_mb_into_sb(&sb, mb, i);
}
}
} else if (frame_flags & (1 << 16)) {
while (can_safely_read(&gb, 1) && !get_bits1(&gb)) {
mb = decode_macroblock(s, &gb, &cb_index, superblock_index);
insert_mb_into_sb(&sb, mb, get_bits(&gb, 4));
}
}
copy_superblock(new_frame_data, new_stride, sb.pixels, 8);
}
superblock_col_index++;
new_frame_data += 8;
if (old_frame_data)
old_frame_data += 8;
if (superblock_col_index == superblocks_per_row) {
new_frame_data += new_stride * 8 - superblocks_per_row * 8;
if (old_frame_data)
old_frame_data += old_stride * 8 - superblocks_per_row * 8;
superblock_col_index = 0;
}
skip--;
}
av_log(avctx, AV_LOG_DEBUG,
"Escape sizes: %i, %i, %i\n",
frame_size, buf_size, get_bits_count(&gb) / 8);
av_frame_unref(&s->frame);
if ((ret = av_frame_ref(&s->frame, frame)) < 0)
return ret;
*got_frame = 1;
return frame_size;
}
| false | FFmpeg | e494f44c051d7dccc038a603ab22532b87dd1705 | static int escape124_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
int buf_size = avpkt->size;
Escape124Context *s = avctx->priv_data;
AVFrame *frame = data;
GetBitContext gb;
unsigned frame_flags, frame_size;
unsigned i;
unsigned superblock_index, cb_index = 1,
superblock_col_index = 0,
superblocks_per_row = avctx->width / 8, skip = -1;
uint16_t* old_frame_data, *new_frame_data;
unsigned old_stride, new_stride;
int ret;
if ((ret = init_get_bits8(&gb, avpkt->data, avpkt->size)) < 0)
return ret;
if (!can_safely_read(&gb, 64))
return -1;
frame_flags = get_bits_long(&gb, 32);
frame_size = get_bits_long(&gb, 32);
if (!(frame_flags & 0x114) || !(frame_flags & 0x7800000)) {
if (!s->frame.data[0])
return AVERROR_INVALIDDATA;
av_log(avctx, AV_LOG_DEBUG, "Skipping frame\n");
*got_frame = 1;
if ((ret = av_frame_ref(frame, &s->frame)) < 0)
return ret;
return frame_size;
}
for (i = 0; i < 3; i++) {
if (frame_flags & (1 << (17 + i))) {
unsigned cb_depth, cb_size;
if (i == 2) {
cb_size = get_bits_long(&gb, 20);
cb_depth = av_log2(cb_size - 1) + 1;
} else {
cb_depth = get_bits(&gb, 4);
if (i == 0) {
cb_size = 1 << cb_depth;
} else {
cb_size = s->num_superblocks << cb_depth;
}
}
av_free(s->codebooks[i].blocks);
s->codebooks[i] = unpack_codebook(&gb, cb_depth, cb_size);
if (!s->codebooks[i].blocks)
return -1;
}
}
if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
return ret;
new_frame_data = (uint16_t*)frame->data[0];
new_stride = frame->linesize[0] / 2;
old_frame_data = (uint16_t*)s->frame.data[0];
old_stride = s->frame.linesize[0] / 2;
for (superblock_index = 0; superblock_index < s->num_superblocks;
superblock_index++) {
MacroBlock mb;
SuperBlock sb;
unsigned multi_mask = 0;
if (skip == -1) {
skip = decode_skip_count(&gb);
}
if (skip) {
copy_superblock(new_frame_data, new_stride,
old_frame_data, old_stride);
} else {
copy_superblock(sb.pixels, 8,
old_frame_data, old_stride);
while (can_safely_read(&gb, 1) && !get_bits1(&gb)) {
unsigned mask;
mb = decode_macroblock(s, &gb, &cb_index, superblock_index);
mask = get_bits(&gb, 16);
multi_mask |= mask;
for (i = 0; i < 16; i++) {
if (mask & mask_matrix[i]) {
insert_mb_into_sb(&sb, mb, i);
}
}
}
if (can_safely_read(&gb, 1) && !get_bits1(&gb)) {
unsigned inv_mask = get_bits(&gb, 4);
for (i = 0; i < 4; i++) {
if (inv_mask & (1 << i)) {
multi_mask ^= 0xF << i*4;
} else {
multi_mask ^= get_bits(&gb, 4) << i*4;
}
}
for (i = 0; i < 16; i++) {
if (multi_mask & mask_matrix[i]) {
if (!can_safely_read(&gb, 1))
break;
mb = decode_macroblock(s, &gb, &cb_index,
superblock_index);
insert_mb_into_sb(&sb, mb, i);
}
}
} else if (frame_flags & (1 << 16)) {
while (can_safely_read(&gb, 1) && !get_bits1(&gb)) {
mb = decode_macroblock(s, &gb, &cb_index, superblock_index);
insert_mb_into_sb(&sb, mb, get_bits(&gb, 4));
}
}
copy_superblock(new_frame_data, new_stride, sb.pixels, 8);
}
superblock_col_index++;
new_frame_data += 8;
if (old_frame_data)
old_frame_data += 8;
if (superblock_col_index == superblocks_per_row) {
new_frame_data += new_stride * 8 - superblocks_per_row * 8;
if (old_frame_data)
old_frame_data += old_stride * 8 - superblocks_per_row * 8;
superblock_col_index = 0;
}
skip--;
}
av_log(avctx, AV_LOG_DEBUG,
"Escape sizes: %i, %i, %i\n",
frame_size, buf_size, get_bits_count(&gb) / 8);
av_frame_unref(&s->frame);
if ((ret = av_frame_ref(&s->frame, frame)) < 0)
return ret;
*got_frame = 1;
return frame_size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
int VAR_4 = VAR_3->size;
Escape124Context *s = VAR_0->priv_data;
AVFrame *frame = VAR_1;
GetBitContext gb;
unsigned VAR_5, VAR_6;
unsigned VAR_7;
unsigned VAR_8, VAR_9 = 1,
VAR_10 = 0,
VAR_11 = VAR_0->width / 8, VAR_12 = -1;
uint16_t* old_frame_data, *new_frame_data;
unsigned VAR_13, VAR_14;
int VAR_15;
if ((VAR_15 = init_get_bits8(&gb, VAR_3->VAR_1, VAR_3->size)) < 0)
return VAR_15;
if (!can_safely_read(&gb, 64))
return -1;
VAR_5 = get_bits_long(&gb, 32);
VAR_6 = get_bits_long(&gb, 32);
if (!(VAR_5 & 0x114) || !(VAR_5 & 0x7800000)) {
if (!s->frame.VAR_1[0])
return AVERROR_INVALIDDATA;
av_log(VAR_0, AV_LOG_DEBUG, "Skipping frame\n");
*VAR_2 = 1;
if ((VAR_15 = av_frame_ref(frame, &s->frame)) < 0)
return VAR_15;
return VAR_6;
}
for (VAR_7 = 0; VAR_7 < 3; VAR_7++) {
if (VAR_5 & (1 << (17 + VAR_7))) {
unsigned VAR_16, VAR_17;
if (VAR_7 == 2) {
VAR_17 = get_bits_long(&gb, 20);
VAR_16 = av_log2(VAR_17 - 1) + 1;
} else {
VAR_16 = get_bits(&gb, 4);
if (VAR_7 == 0) {
VAR_17 = 1 << VAR_16;
} else {
VAR_17 = s->num_superblocks << VAR_16;
}
}
av_free(s->codebooks[VAR_7].blocks);
s->codebooks[VAR_7] = unpack_codebook(&gb, VAR_16, VAR_17);
if (!s->codebooks[VAR_7].blocks)
return -1;
}
}
if ((VAR_15 = ff_get_buffer(VAR_0, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
return VAR_15;
new_frame_data = (uint16_t*)frame->VAR_1[0];
VAR_14 = frame->linesize[0] / 2;
old_frame_data = (uint16_t*)s->frame.VAR_1[0];
VAR_13 = s->frame.linesize[0] / 2;
for (VAR_8 = 0; VAR_8 < s->num_superblocks;
VAR_8++) {
MacroBlock mb;
SuperBlock sb;
unsigned multi_mask = 0;
if (VAR_12 == -1) {
VAR_12 = decode_skip_count(&gb);
}
if (VAR_12) {
copy_superblock(new_frame_data, VAR_14,
old_frame_data, VAR_13);
} else {
copy_superblock(sb.pixels, 8,
old_frame_data, VAR_13);
while (can_safely_read(&gb, 1) && !get_bits1(&gb)) {
unsigned mask;
mb = decode_macroblock(s, &gb, &VAR_9, VAR_8);
mask = get_bits(&gb, 16);
multi_mask |= mask;
for (VAR_7 = 0; VAR_7 < 16; VAR_7++) {
if (mask & mask_matrix[VAR_7]) {
insert_mb_into_sb(&sb, mb, VAR_7);
}
}
}
if (can_safely_read(&gb, 1) && !get_bits1(&gb)) {
unsigned inv_mask = get_bits(&gb, 4);
for (VAR_7 = 0; VAR_7 < 4; VAR_7++) {
if (inv_mask & (1 << VAR_7)) {
multi_mask ^= 0xF << VAR_7*4;
} else {
multi_mask ^= get_bits(&gb, 4) << VAR_7*4;
}
}
for (VAR_7 = 0; VAR_7 < 16; VAR_7++) {
if (multi_mask & mask_matrix[VAR_7]) {
if (!can_safely_read(&gb, 1))
break;
mb = decode_macroblock(s, &gb, &VAR_9,
VAR_8);
insert_mb_into_sb(&sb, mb, VAR_7);
}
}
} else if (VAR_5 & (1 << 16)) {
while (can_safely_read(&gb, 1) && !get_bits1(&gb)) {
mb = decode_macroblock(s, &gb, &VAR_9, VAR_8);
insert_mb_into_sb(&sb, mb, get_bits(&gb, 4));
}
}
copy_superblock(new_frame_data, VAR_14, sb.pixels, 8);
}
VAR_10++;
new_frame_data += 8;
if (old_frame_data)
old_frame_data += 8;
if (VAR_10 == VAR_11) {
new_frame_data += VAR_14 * 8 - VAR_11 * 8;
if (old_frame_data)
old_frame_data += VAR_13 * 8 - VAR_11 * 8;
VAR_10 = 0;
}
VAR_12--;
}
av_log(VAR_0, AV_LOG_DEBUG,
"Escape sizes: %VAR_7, %VAR_7, %VAR_7\n",
VAR_6, VAR_4, get_bits_count(&gb) / 8);
av_frame_unref(&s->frame);
if ((VAR_15 = av_frame_ref(&s->frame, frame)) < 0)
return VAR_15;
*VAR_2 = 1;
return VAR_6;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"int VAR_4 = VAR_3->size;",
"Escape124Context *s = VAR_0->priv_data;",
"AVFrame *frame = VAR_1;",
"GetBitContext gb;",
"unsigned VAR_5, VAR_6;",
"unsigned VAR_7;",
"unsigned VAR_8, VAR_9 = 1,\nVAR_10 = 0,\nVAR_11 = VAR_0->width / 8, VAR_12 = -1;",
"uint16_t* old_frame_data, *new_frame_data;",
"unsigned VAR_13, VAR_14;",
"int VAR_15;",
"if ((VAR_15 = init_get_bits8(&gb, VAR_3->VAR_1, VAR_3->size)) < 0)\nreturn VAR_15;",
"if (!can_safely_read(&gb, 64))\nreturn -1;",
"VAR_5 = get_bits_long(&gb, 32);",
"VAR_6 = get_bits_long(&gb, 32);",
"if (!(VAR_5 & 0x114) || !(VAR_5 & 0x7800000)) {",
"if (!s->frame.VAR_1[0])\nreturn AVERROR_INVALIDDATA;",
"av_log(VAR_0, AV_LOG_DEBUG, \"Skipping frame\\n\");",
"*VAR_2 = 1;",
"if ((VAR_15 = av_frame_ref(frame, &s->frame)) < 0)\nreturn VAR_15;",
"return VAR_6;",
"}",
"for (VAR_7 = 0; VAR_7 < 3; VAR_7++) {",
"if (VAR_5 & (1 << (17 + VAR_7))) {",
"unsigned VAR_16, VAR_17;",
"if (VAR_7 == 2) {",
"VAR_17 = get_bits_long(&gb, 20);",
"VAR_16 = av_log2(VAR_17 - 1) + 1;",
"} else {",
"VAR_16 = get_bits(&gb, 4);",
"if (VAR_7 == 0) {",
"VAR_17 = 1 << VAR_16;",
"} else {",
"VAR_17 = s->num_superblocks << VAR_16;",
"}",
"}",
"av_free(s->codebooks[VAR_7].blocks);",
"s->codebooks[VAR_7] = unpack_codebook(&gb, VAR_16, VAR_17);",
"if (!s->codebooks[VAR_7].blocks)\nreturn -1;",
"}",
"}",
"if ((VAR_15 = ff_get_buffer(VAR_0, frame, AV_GET_BUFFER_FLAG_REF)) < 0)\nreturn VAR_15;",
"new_frame_data = (uint16_t*)frame->VAR_1[0];",
"VAR_14 = frame->linesize[0] / 2;",
"old_frame_data = (uint16_t*)s->frame.VAR_1[0];",
"VAR_13 = s->frame.linesize[0] / 2;",
"for (VAR_8 = 0; VAR_8 < s->num_superblocks;",
"VAR_8++) {",
"MacroBlock mb;",
"SuperBlock sb;",
"unsigned multi_mask = 0;",
"if (VAR_12 == -1) {",
"VAR_12 = decode_skip_count(&gb);",
"}",
"if (VAR_12) {",
"copy_superblock(new_frame_data, VAR_14,\nold_frame_data, VAR_13);",
"} else {",
"copy_superblock(sb.pixels, 8,\nold_frame_data, VAR_13);",
"while (can_safely_read(&gb, 1) && !get_bits1(&gb)) {",
"unsigned mask;",
"mb = decode_macroblock(s, &gb, &VAR_9, VAR_8);",
"mask = get_bits(&gb, 16);",
"multi_mask |= mask;",
"for (VAR_7 = 0; VAR_7 < 16; VAR_7++) {",
"if (mask & mask_matrix[VAR_7]) {",
"insert_mb_into_sb(&sb, mb, VAR_7);",
"}",
"}",
"}",
"if (can_safely_read(&gb, 1) && !get_bits1(&gb)) {",
"unsigned inv_mask = get_bits(&gb, 4);",
"for (VAR_7 = 0; VAR_7 < 4; VAR_7++) {",
"if (inv_mask & (1 << VAR_7)) {",
"multi_mask ^= 0xF << VAR_7*4;",
"} else {",
"multi_mask ^= get_bits(&gb, 4) << VAR_7*4;",
"}",
"}",
"for (VAR_7 = 0; VAR_7 < 16; VAR_7++) {",
"if (multi_mask & mask_matrix[VAR_7]) {",
"if (!can_safely_read(&gb, 1))\nbreak;",
"mb = decode_macroblock(s, &gb, &VAR_9,\nVAR_8);",
"insert_mb_into_sb(&sb, mb, VAR_7);",
"}",
"}",
"} else if (VAR_5 & (1 << 16)) {",
"while (can_safely_read(&gb, 1) && !get_bits1(&gb)) {",
"mb = decode_macroblock(s, &gb, &VAR_9, VAR_8);",
"insert_mb_into_sb(&sb, mb, get_bits(&gb, 4));",
"}",
"}",
"copy_superblock(new_frame_data, VAR_14, sb.pixels, 8);",
"}",
"VAR_10++;",
"new_frame_data += 8;",
"if (old_frame_data)\nold_frame_data += 8;",
"if (VAR_10 == VAR_11) {",
"new_frame_data += VAR_14 * 8 - VAR_11 * 8;",
"if (old_frame_data)\nold_frame_data += VAR_13 * 8 - VAR_11 * 8;",
"VAR_10 = 0;",
"}",
"VAR_12--;",
"}",
"av_log(VAR_0, AV_LOG_DEBUG,\n\"Escape sizes: %VAR_7, %VAR_7, %VAR_7\\n\",\nVAR_6, VAR_4, get_bits_count(&gb) / 8);",
"av_frame_unref(&s->frame);",
"if ((VAR_15 = av_frame_ref(&s->frame, frame)) < 0)\nreturn VAR_15;",
"*VAR_2 = 1;",
"return VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
33
],
[
35
],
[
39
],
[
43,
45
],
[
53,
55
],
[
59
],
[
61
],
[
69
],
[
71,
73
],
[
77
],
[
81
],
[
83,
85
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
121
],
[
123
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141,
143
],
[
145
],
[
147
],
[
151,
153
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
179
],
[
185
],
[
187
],
[
191
],
[
193,
195
],
[
197
],
[
199,
201
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
249
],
[
251
],
[
253,
255
],
[
257,
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
281
],
[
283
],
[
287
],
[
289
],
[
291,
293
],
[
295
],
[
297
],
[
299,
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
313,
315,
317
],
[
321
],
[
323,
325
],
[
329
],
[
333
],
[
335
]
] |
18,292 | static int adx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf0 = avpkt->data;
int buf_size = avpkt->size;
ADXContext *c = avctx->priv_data;
int16_t *samples = data;
const uint8_t *buf = buf0;
int rest = buf_size;
if (!c->header_parsed) {
int hdrsize = adx_decode_header(avctx, buf, rest);
if (!hdrsize)
return -1;
c->header_parsed = 1;
buf += hdrsize;
rest -= hdrsize;
}
/* 18 bytes of data are expanded into 32*2 bytes of audio,
so guard against buffer overflows */
if (rest / 18 > *data_size / 64)
rest = (*data_size / 64) * 18;
if (c->in_temp) {
int copysize = 18 * avctx->channels - c->in_temp;
memcpy(c->dec_temp + c->in_temp, buf, copysize);
rest -= copysize;
buf += copysize;
if (avctx->channels == 1) {
adx_decode(samples, c->dec_temp, c->prev);
samples += 32;
} else {
adx_decode_stereo(samples, c->dec_temp, c->prev);
samples += 32*2;
}
}
if (avctx->channels == 1) {
while (rest >= 18) {
adx_decode(samples, buf, c->prev);
rest -= 18;
buf += 18;
samples += 32;
}
} else {
while (rest >= 18 * 2) {
adx_decode_stereo(samples, buf, c->prev);
rest -= 18 * 2;
buf += 18 * 2;
samples += 32 * 2;
}
}
c->in_temp = rest;
if (rest) {
memcpy(c->dec_temp, buf, rest);
buf += rest;
}
*data_size = (uint8_t*)samples - (uint8_t*)data;
return buf - buf0;
}
| false | FFmpeg | e2d1eace00a80c4b53998397d38ea4e08c5d47f0 | static int adx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf0 = avpkt->data;
int buf_size = avpkt->size;
ADXContext *c = avctx->priv_data;
int16_t *samples = data;
const uint8_t *buf = buf0;
int rest = buf_size;
if (!c->header_parsed) {
int hdrsize = adx_decode_header(avctx, buf, rest);
if (!hdrsize)
return -1;
c->header_parsed = 1;
buf += hdrsize;
rest -= hdrsize;
}
if (rest / 18 > *data_size / 64)
rest = (*data_size / 64) * 18;
if (c->in_temp) {
int copysize = 18 * avctx->channels - c->in_temp;
memcpy(c->dec_temp + c->in_temp, buf, copysize);
rest -= copysize;
buf += copysize;
if (avctx->channels == 1) {
adx_decode(samples, c->dec_temp, c->prev);
samples += 32;
} else {
adx_decode_stereo(samples, c->dec_temp, c->prev);
samples += 32*2;
}
}
if (avctx->channels == 1) {
while (rest >= 18) {
adx_decode(samples, buf, c->prev);
rest -= 18;
buf += 18;
samples += 32;
}
} else {
while (rest >= 18 * 2) {
adx_decode_stereo(samples, buf, c->prev);
rest -= 18 * 2;
buf += 18 * 2;
samples += 32 * 2;
}
}
c->in_temp = rest;
if (rest) {
memcpy(c->dec_temp, buf, rest);
buf += rest;
}
*data_size = (uint8_t*)samples - (uint8_t*)data;
return buf - buf0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
ADXContext *c = VAR_0->priv_data;
int16_t *samples = VAR_1;
const uint8_t *VAR_6 = VAR_4;
int VAR_7 = VAR_5;
if (!c->header_parsed) {
int VAR_8 = adx_decode_header(VAR_0, VAR_6, VAR_7);
if (!VAR_8)
return -1;
c->header_parsed = 1;
VAR_6 += VAR_8;
VAR_7 -= VAR_8;
}
if (VAR_7 / 18 > *VAR_2 / 64)
VAR_7 = (*VAR_2 / 64) * 18;
if (c->in_temp) {
int VAR_9 = 18 * VAR_0->channels - c->in_temp;
memcpy(c->dec_temp + c->in_temp, VAR_6, VAR_9);
VAR_7 -= VAR_9;
VAR_6 += VAR_9;
if (VAR_0->channels == 1) {
adx_decode(samples, c->dec_temp, c->prev);
samples += 32;
} else {
adx_decode_stereo(samples, c->dec_temp, c->prev);
samples += 32*2;
}
}
if (VAR_0->channels == 1) {
while (VAR_7 >= 18) {
adx_decode(samples, VAR_6, c->prev);
VAR_7 -= 18;
VAR_6 += 18;
samples += 32;
}
} else {
while (VAR_7 >= 18 * 2) {
adx_decode_stereo(samples, VAR_6, c->prev);
VAR_7 -= 18 * 2;
VAR_6 += 18 * 2;
samples += 32 * 2;
}
}
c->in_temp = VAR_7;
if (VAR_7) {
memcpy(c->dec_temp, VAR_6, VAR_7);
VAR_6 += VAR_7;
}
*VAR_2 = (uint8_t*)samples - (uint8_t*)VAR_1;
return VAR_6 - VAR_4;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"ADXContext *c = VAR_0->priv_data;",
"int16_t *samples = VAR_1;",
"const uint8_t *VAR_6 = VAR_4;",
"int VAR_7 = VAR_5;",
"if (!c->header_parsed) {",
"int VAR_8 = adx_decode_header(VAR_0, VAR_6, VAR_7);",
"if (!VAR_8)\nreturn -1;",
"c->header_parsed = 1;",
"VAR_6 += VAR_8;",
"VAR_7 -= VAR_8;",
"}",
"if (VAR_7 / 18 > *VAR_2 / 64)\nVAR_7 = (*VAR_2 / 64) * 18;",
"if (c->in_temp) {",
"int VAR_9 = 18 * VAR_0->channels - c->in_temp;",
"memcpy(c->dec_temp + c->in_temp, VAR_6, VAR_9);",
"VAR_7 -= VAR_9;",
"VAR_6 += VAR_9;",
"if (VAR_0->channels == 1) {",
"adx_decode(samples, c->dec_temp, c->prev);",
"samples += 32;",
"} else {",
"adx_decode_stereo(samples, c->dec_temp, c->prev);",
"samples += 32*2;",
"}",
"}",
"if (VAR_0->channels == 1) {",
"while (VAR_7 >= 18) {",
"adx_decode(samples, VAR_6, c->prev);",
"VAR_7 -= 18;",
"VAR_6 += 18;",
"samples += 32;",
"}",
"} else {",
"while (VAR_7 >= 18 * 2) {",
"adx_decode_stereo(samples, VAR_6, c->prev);",
"VAR_7 -= 18 * 2;",
"VAR_6 += 18 * 2;",
"samples += 32 * 2;",
"}",
"}",
"c->in_temp = VAR_7;",
"if (VAR_7) {",
"memcpy(c->dec_temp, VAR_6, VAR_7);",
"VAR_6 += VAR_7;",
"}",
"*VAR_2 = (uint8_t*)samples - (uint8_t*)VAR_1;",
"return VAR_6 - VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
43,
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
]
] |
18,293 | static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, int coded, int codingset, int mquant)
{
GetBitContext *gb = &v->s.gb;
MpegEncContext *s = &v->s;
int dc_pred_dir = 0; /* Direction of the DC prediction used */
int run_diff, i;
int16_t *dc_val;
int16_t *ac_val, *ac_val2;
int dcdiff;
int a_avail = v->a_avail, c_avail = v->c_avail;
int use_pred = s->ac_pred;
int scale;
int q1, q2 = 0;
int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
/* Get DC differential */
if (n < 4) {
dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
} else {
dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
}
if (dcdiff < 0){
av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n");
return -1;
}
if (dcdiff)
{
if (dcdiff == 119 /* ESC index value */)
{
/* TODO: Optimize */
if (mquant == 1) dcdiff = get_bits(gb, 10);
else if (mquant == 2) dcdiff = get_bits(gb, 9);
else dcdiff = get_bits(gb, 8);
}
else
{
if (mquant == 1)
dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3;
else if (mquant == 2)
dcdiff = (dcdiff<<1) + get_bits(gb, 1) - 1;
}
if (get_bits(gb, 1))
dcdiff = -dcdiff;
}
/* Prediction */
dcdiff += vc1_pred_dc(&v->s, v->overlap, mquant, n, v->a_avail, v->c_avail, &dc_val, &dc_pred_dir);
*dc_val = dcdiff;
/* Store the quantized DC coeff, used for prediction */
if (n < 4) {
block[0] = dcdiff * s->y_dc_scale;
} else {
block[0] = dcdiff * s->c_dc_scale;
}
/* Skip ? */
run_diff = 0;
i = 0;
//AC Decoding
i = 1;
/* check if AC is needed at all and adjust direction if needed */
if(!a_avail) dc_pred_dir = 1;
if(!c_avail) dc_pred_dir = 0;
if(!a_avail && !c_avail) use_pred = 0;
ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
ac_val2 = ac_val;
scale = mquant * 2 + v->halfpq;
if(dc_pred_dir) //left
ac_val -= 16;
else //top
ac_val -= 16 * s->block_wrap[n];
q1 = s->current_picture.qscale_table[mb_pos];
if(dc_pred_dir && c_avail) q2 = s->current_picture.qscale_table[mb_pos - 1];
if(!dc_pred_dir && a_avail) q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride];
if(n && n<4) q2 = q1;
if(coded) {
int last = 0, skip, value;
const int8_t *zz_table;
int k;
if(v->s.ac_pred) {
if(!dc_pred_dir)
zz_table = vc1_horizontal_zz;
else
zz_table = vc1_vertical_zz;
} else
zz_table = vc1_normal_zz;
while (!last) {
vc1_decode_ac_coeff(v, &last, &skip, &value, codingset);
i += skip;
if(i > 63)
break;
block[zz_table[i++]] = value;
}
/* apply AC prediction if needed */
if(use_pred) {
/* scale predictors if needed*/
if(q2 && q1!=q2) {
q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++)
block[k << 3] += (ac_val[k] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18;
} else { //top
for(k = 1; k < 8; k++)
block[k] += (ac_val[k + 8] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
} else {
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++)
block[k << 3] += ac_val[k];
} else { //top
for(k = 1; k < 8; k++)
block[k] += ac_val[k + 8];
}
}
}
/* save AC coeffs for further prediction */
for(k = 1; k < 8; k++) {
ac_val2[k] = block[k << 3];
ac_val2[k + 8] = block[k];
}
/* scale AC coeffs */
for(k = 1; k < 64; k++)
if(block[k]) {
block[k] *= scale;
if(!v->pquantizer)
block[k] += (block[k] < 0) ? -mquant : mquant;
}
if(use_pred) i = 63;
} else { // no AC coeffs
int k;
memset(ac_val2, 0, 16 * 2);
if(dc_pred_dir) {//left
if(use_pred) {
memcpy(ac_val2, ac_val, 8 * 2);
if(q2 && q1!=q2) {
q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
for(k = 1; k < 8; k++)
ac_val2[k] = (ac_val2[k] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
}
} else {//top
if(use_pred) {
memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
if(q2 && q1!=q2) {
q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
for(k = 1; k < 8; k++)
ac_val2[k + 8] = (ac_val2[k + 8] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
}
}
/* apply AC prediction if needed */
if(use_pred) {
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++) {
block[k << 3] = ac_val2[k] * scale;
if(!v->pquantizer && block[k << 3])
block[k << 3] += (block[k << 3] < 0) ? -mquant : mquant;
}
} else { //top
for(k = 1; k < 8; k++) {
block[k] = ac_val2[k + 8] * scale;
if(!v->pquantizer && block[k])
block[k] += (block[k] < 0) ? -mquant : mquant;
}
}
i = 63;
}
}
s->block_last_index[n] = i;
return 0;
}
| true | FFmpeg | b956373b6f62bfc72b71070b50f1f053225cab8a | static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, int coded, int codingset, int mquant)
{
GetBitContext *gb = &v->s.gb;
MpegEncContext *s = &v->s;
int dc_pred_dir = 0;
int run_diff, i;
int16_t *dc_val;
int16_t *ac_val, *ac_val2;
int dcdiff;
int a_avail = v->a_avail, c_avail = v->c_avail;
int use_pred = s->ac_pred;
int scale;
int q1, q2 = 0;
int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
if (n < 4) {
dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
} else {
dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
}
if (dcdiff < 0){
av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n");
return -1;
}
if (dcdiff)
{
if (dcdiff == 119 )
{
if (mquant == 1) dcdiff = get_bits(gb, 10);
else if (mquant == 2) dcdiff = get_bits(gb, 9);
else dcdiff = get_bits(gb, 8);
}
else
{
if (mquant == 1)
dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3;
else if (mquant == 2)
dcdiff = (dcdiff<<1) + get_bits(gb, 1) - 1;
}
if (get_bits(gb, 1))
dcdiff = -dcdiff;
}
dcdiff += vc1_pred_dc(&v->s, v->overlap, mquant, n, v->a_avail, v->c_avail, &dc_val, &dc_pred_dir);
*dc_val = dcdiff;
if (n < 4) {
block[0] = dcdiff * s->y_dc_scale;
} else {
block[0] = dcdiff * s->c_dc_scale;
}
run_diff = 0;
i = 0;
i = 1;
if(!a_avail) dc_pred_dir = 1;
if(!c_avail) dc_pred_dir = 0;
if(!a_avail && !c_avail) use_pred = 0;
ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
ac_val2 = ac_val;
scale = mquant * 2 + v->halfpq;
if(dc_pred_dir)
ac_val -= 16;
else
ac_val -= 16 * s->block_wrap[n];
q1 = s->current_picture.qscale_table[mb_pos];
if(dc_pred_dir && c_avail) q2 = s->current_picture.qscale_table[mb_pos - 1];
if(!dc_pred_dir && a_avail) q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride];
if(n && n<4) q2 = q1;
if(coded) {
int last = 0, skip, value;
const int8_t *zz_table;
int k;
if(v->s.ac_pred) {
if(!dc_pred_dir)
zz_table = vc1_horizontal_zz;
else
zz_table = vc1_vertical_zz;
} else
zz_table = vc1_normal_zz;
while (!last) {
vc1_decode_ac_coeff(v, &last, &skip, &value, codingset);
i += skip;
if(i > 63)
break;
block[zz_table[i++]] = value;
}
if(use_pred) {
if(q2 && q1!=q2) {
q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
if(dc_pred_dir) {
for(k = 1; k < 8; k++)
block[k << 3] += (ac_val[k] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18;
} else {
for(k = 1; k < 8; k++)
block[k] += (ac_val[k + 8] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
} else {
if(dc_pred_dir) {
for(k = 1; k < 8; k++)
block[k << 3] += ac_val[k];
} else {
for(k = 1; k < 8; k++)
block[k] += ac_val[k + 8];
}
}
}
for(k = 1; k < 8; k++) {
ac_val2[k] = block[k << 3];
ac_val2[k + 8] = block[k];
}
for(k = 1; k < 64; k++)
if(block[k]) {
block[k] *= scale;
if(!v->pquantizer)
block[k] += (block[k] < 0) ? -mquant : mquant;
}
if(use_pred) i = 63;
} else {
int k;
memset(ac_val2, 0, 16 * 2);
if(dc_pred_dir) {
if(use_pred) {
memcpy(ac_val2, ac_val, 8 * 2);
if(q2 && q1!=q2) {
q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
for(k = 1; k < 8; k++)
ac_val2[k] = (ac_val2[k] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
}
} else {
if(use_pred) {
memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
if(q2 && q1!=q2) {
q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
for(k = 1; k < 8; k++)
ac_val2[k + 8] = (ac_val2[k + 8] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
}
}
if(use_pred) {
if(dc_pred_dir) {
for(k = 1; k < 8; k++) {
block[k << 3] = ac_val2[k] * scale;
if(!v->pquantizer && block[k << 3])
block[k << 3] += (block[k << 3] < 0) ? -mquant : mquant;
}
} else {
for(k = 1; k < 8; k++) {
block[k] = ac_val2[k + 8] * scale;
if(!v->pquantizer && block[k])
block[k] += (block[k] < 0) ? -mquant : mquant;
}
}
i = 63;
}
}
s->block_last_index[n] = i;
return 0;
}
| {
"code": [
" if(dc_pred_dir && c_avail) q2 = s->current_picture.qscale_table[mb_pos - 1];",
" if(!dc_pred_dir && a_avail) q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride];"
],
"line_no": [
155,
157
]
} | static int FUNC_0(VC1Context *VAR_0, DCTELEM VAR_1[64], int VAR_2, int VAR_3, int VAR_4, int VAR_5)
{
GetBitContext *gb = &VAR_0->s.gb;
MpegEncContext *s = &VAR_0->s;
int VAR_6 = 0;
int VAR_7, VAR_8;
int16_t *dc_val;
int16_t *ac_val, *ac_val2;
int VAR_9;
int VAR_10 = VAR_0->VAR_10, VAR_11 = VAR_0->VAR_11;
int VAR_12 = s->ac_pred;
int VAR_13;
int VAR_14, VAR_15 = 0;
int VAR_16 = s->mb_x + s->mb_y * s->mb_stride;
if (VAR_2 < 4) {
VAR_9 = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
} else {
VAR_9 = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
}
if (VAR_9 < 0){
av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\VAR_2");
return -1;
}
if (VAR_9)
{
if (VAR_9 == 119 )
{
if (VAR_5 == 1) VAR_9 = get_bits(gb, 10);
else if (VAR_5 == 2) VAR_9 = get_bits(gb, 9);
else VAR_9 = get_bits(gb, 8);
}
else
{
if (VAR_5 == 1)
VAR_9 = (VAR_9<<2) + get_bits(gb, 2) - 3;
else if (VAR_5 == 2)
VAR_9 = (VAR_9<<1) + get_bits(gb, 1) - 1;
}
if (get_bits(gb, 1))
VAR_9 = -VAR_9;
}
VAR_9 += vc1_pred_dc(&VAR_0->s, VAR_0->overlap, VAR_5, VAR_2, VAR_0->VAR_10, VAR_0->VAR_11, &dc_val, &VAR_6);
*dc_val = VAR_9;
if (VAR_2 < 4) {
VAR_1[0] = VAR_9 * s->y_dc_scale;
} else {
VAR_1[0] = VAR_9 * s->c_dc_scale;
}
VAR_7 = 0;
VAR_8 = 0;
VAR_8 = 1;
if(!VAR_10) VAR_6 = 1;
if(!VAR_11) VAR_6 = 0;
if(!VAR_10 && !VAR_11) VAR_12 = 0;
ac_val = s->ac_val[0][0] + s->block_index[VAR_2] * 16;
ac_val2 = ac_val;
VAR_13 = VAR_5 * 2 + VAR_0->halfpq;
if(VAR_6)
ac_val -= 16;
else
ac_val -= 16 * s->block_wrap[VAR_2];
VAR_14 = s->current_picture.qscale_table[VAR_16];
if(VAR_6 && VAR_11) VAR_15 = s->current_picture.qscale_table[VAR_16 - 1];
if(!VAR_6 && VAR_10) VAR_15 = s->current_picture.qscale_table[VAR_16 - s->mb_stride];
if(VAR_2 && VAR_2<4) VAR_15 = VAR_14;
if(VAR_3) {
int VAR_17 = 0, VAR_18, VAR_19;
const int8_t *VAR_20;
int VAR_22;
if(VAR_0->s.ac_pred) {
if(!VAR_6)
VAR_20 = vc1_horizontal_zz;
else
VAR_20 = vc1_vertical_zz;
} else
VAR_20 = vc1_normal_zz;
while (!VAR_17) {
vc1_decode_ac_coeff(VAR_0, &VAR_17, &VAR_18, &VAR_19, VAR_4);
VAR_8 += VAR_18;
if(VAR_8 > 63)
break;
VAR_1[VAR_20[VAR_8++]] = VAR_19;
}
if(VAR_12) {
if(VAR_15 && VAR_14!=VAR_15) {
VAR_14 = VAR_14 * 2 + ((VAR_14 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;
VAR_15 = VAR_15 * 2 + ((VAR_15 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;
if(VAR_6) {
for(VAR_22 = 1; VAR_22 < 8; VAR_22++)
VAR_1[VAR_22 << 3] += (ac_val[VAR_22] * VAR_15 * vc1_dqscale[VAR_14 - 1] + 0x20000) >> 18;
} else {
for(VAR_22 = 1; VAR_22 < 8; VAR_22++)
VAR_1[VAR_22] += (ac_val[VAR_22 + 8] * VAR_15 * vc1_dqscale[VAR_14 - 1] + 0x20000) >> 18;
}
} else {
if(VAR_6) {
for(VAR_22 = 1; VAR_22 < 8; VAR_22++)
VAR_1[VAR_22 << 3] += ac_val[VAR_22];
} else {
for(VAR_22 = 1; VAR_22 < 8; VAR_22++)
VAR_1[VAR_22] += ac_val[VAR_22 + 8];
}
}
}
for(VAR_22 = 1; VAR_22 < 8; VAR_22++) {
ac_val2[VAR_22] = VAR_1[VAR_22 << 3];
ac_val2[VAR_22 + 8] = VAR_1[VAR_22];
}
for(VAR_22 = 1; VAR_22 < 64; VAR_22++)
if(VAR_1[VAR_22]) {
VAR_1[VAR_22] *= VAR_13;
if(!VAR_0->pquantizer)
VAR_1[VAR_22] += (VAR_1[VAR_22] < 0) ? -VAR_5 : VAR_5;
}
if(VAR_12) VAR_8 = 63;
} else {
int VAR_22;
memset(ac_val2, 0, 16 * 2);
if(VAR_6) {
if(VAR_12) {
memcpy(ac_val2, ac_val, 8 * 2);
if(VAR_15 && VAR_14!=VAR_15) {
VAR_14 = VAR_14 * 2 + ((VAR_14 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;
VAR_15 = VAR_15 * 2 + ((VAR_15 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;
for(VAR_22 = 1; VAR_22 < 8; VAR_22++)
ac_val2[VAR_22] = (ac_val2[VAR_22] * VAR_15 * vc1_dqscale[VAR_14 - 1] + 0x20000) >> 18;
}
}
} else {
if(VAR_12) {
memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
if(VAR_15 && VAR_14!=VAR_15) {
VAR_14 = VAR_14 * 2 + ((VAR_14 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;
VAR_15 = VAR_15 * 2 + ((VAR_15 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;
for(VAR_22 = 1; VAR_22 < 8; VAR_22++)
ac_val2[VAR_22 + 8] = (ac_val2[VAR_22 + 8] * VAR_15 * vc1_dqscale[VAR_14 - 1] + 0x20000) >> 18;
}
}
}
if(VAR_12) {
if(VAR_6) {
for(VAR_22 = 1; VAR_22 < 8; VAR_22++) {
VAR_1[VAR_22 << 3] = ac_val2[VAR_22] * VAR_13;
if(!VAR_0->pquantizer && VAR_1[VAR_22 << 3])
VAR_1[VAR_22 << 3] += (VAR_1[VAR_22 << 3] < 0) ? -VAR_5 : VAR_5;
}
} else {
for(VAR_22 = 1; VAR_22 < 8; VAR_22++) {
VAR_1[VAR_22] = ac_val2[VAR_22 + 8] * VAR_13;
if(!VAR_0->pquantizer && VAR_1[VAR_22])
VAR_1[VAR_22] += (VAR_1[VAR_22] < 0) ? -VAR_5 : VAR_5;
}
}
VAR_8 = 63;
}
}
s->block_last_index[VAR_2] = VAR_8;
return 0;
}
| [
"static int FUNC_0(VC1Context *VAR_0, DCTELEM VAR_1[64], int VAR_2, int VAR_3, int VAR_4, int VAR_5)\n{",
"GetBitContext *gb = &VAR_0->s.gb;",
"MpegEncContext *s = &VAR_0->s;",
"int VAR_6 = 0;",
"int VAR_7, VAR_8;",
"int16_t *dc_val;",
"int16_t *ac_val, *ac_val2;",
"int VAR_9;",
"int VAR_10 = VAR_0->VAR_10, VAR_11 = VAR_0->VAR_11;",
"int VAR_12 = s->ac_pred;",
"int VAR_13;",
"int VAR_14, VAR_15 = 0;",
"int VAR_16 = s->mb_x + s->mb_y * s->mb_stride;",
"if (VAR_2 < 4) {",
"VAR_9 = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);",
"} else {",
"VAR_9 = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);",
"}",
"if (VAR_9 < 0){",
"av_log(s->avctx, AV_LOG_ERROR, \"Illegal DC VLC\\VAR_2\");",
"return -1;",
"}",
"if (VAR_9)\n{",
"if (VAR_9 == 119 )\n{",
"if (VAR_5 == 1) VAR_9 = get_bits(gb, 10);",
"else if (VAR_5 == 2) VAR_9 = get_bits(gb, 9);",
"else VAR_9 = get_bits(gb, 8);",
"}",
"else\n{",
"if (VAR_5 == 1)\nVAR_9 = (VAR_9<<2) + get_bits(gb, 2) - 3;",
"else if (VAR_5 == 2)\nVAR_9 = (VAR_9<<1) + get_bits(gb, 1) - 1;",
"}",
"if (get_bits(gb, 1))\nVAR_9 = -VAR_9;",
"}",
"VAR_9 += vc1_pred_dc(&VAR_0->s, VAR_0->overlap, VAR_5, VAR_2, VAR_0->VAR_10, VAR_0->VAR_11, &dc_val, &VAR_6);",
"*dc_val = VAR_9;",
"if (VAR_2 < 4) {",
"VAR_1[0] = VAR_9 * s->y_dc_scale;",
"} else {",
"VAR_1[0] = VAR_9 * s->c_dc_scale;",
"}",
"VAR_7 = 0;",
"VAR_8 = 0;",
"VAR_8 = 1;",
"if(!VAR_10) VAR_6 = 1;",
"if(!VAR_11) VAR_6 = 0;",
"if(!VAR_10 && !VAR_11) VAR_12 = 0;",
"ac_val = s->ac_val[0][0] + s->block_index[VAR_2] * 16;",
"ac_val2 = ac_val;",
"VAR_13 = VAR_5 * 2 + VAR_0->halfpq;",
"if(VAR_6)\nac_val -= 16;",
"else\nac_val -= 16 * s->block_wrap[VAR_2];",
"VAR_14 = s->current_picture.qscale_table[VAR_16];",
"if(VAR_6 && VAR_11) VAR_15 = s->current_picture.qscale_table[VAR_16 - 1];",
"if(!VAR_6 && VAR_10) VAR_15 = s->current_picture.qscale_table[VAR_16 - s->mb_stride];",
"if(VAR_2 && VAR_2<4) VAR_15 = VAR_14;",
"if(VAR_3) {",
"int VAR_17 = 0, VAR_18, VAR_19;",
"const int8_t *VAR_20;",
"int VAR_22;",
"if(VAR_0->s.ac_pred) {",
"if(!VAR_6)\nVAR_20 = vc1_horizontal_zz;",
"else\nVAR_20 = vc1_vertical_zz;",
"} else",
"VAR_20 = vc1_normal_zz;",
"while (!VAR_17) {",
"vc1_decode_ac_coeff(VAR_0, &VAR_17, &VAR_18, &VAR_19, VAR_4);",
"VAR_8 += VAR_18;",
"if(VAR_8 > 63)\nbreak;",
"VAR_1[VAR_20[VAR_8++]] = VAR_19;",
"}",
"if(VAR_12) {",
"if(VAR_15 && VAR_14!=VAR_15) {",
"VAR_14 = VAR_14 * 2 + ((VAR_14 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;",
"VAR_15 = VAR_15 * 2 + ((VAR_15 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;",
"if(VAR_6) {",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++)",
"VAR_1[VAR_22 << 3] += (ac_val[VAR_22] * VAR_15 * vc1_dqscale[VAR_14 - 1] + 0x20000) >> 18;",
"} else {",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++)",
"VAR_1[VAR_22] += (ac_val[VAR_22 + 8] * VAR_15 * vc1_dqscale[VAR_14 - 1] + 0x20000) >> 18;",
"}",
"} else {",
"if(VAR_6) {",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++)",
"VAR_1[VAR_22 << 3] += ac_val[VAR_22];",
"} else {",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++)",
"VAR_1[VAR_22] += ac_val[VAR_22 + 8];",
"}",
"}",
"}",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++) {",
"ac_val2[VAR_22] = VAR_1[VAR_22 << 3];",
"ac_val2[VAR_22 + 8] = VAR_1[VAR_22];",
"}",
"for(VAR_22 = 1; VAR_22 < 64; VAR_22++)",
"if(VAR_1[VAR_22]) {",
"VAR_1[VAR_22] *= VAR_13;",
"if(!VAR_0->pquantizer)\nVAR_1[VAR_22] += (VAR_1[VAR_22] < 0) ? -VAR_5 : VAR_5;",
"}",
"if(VAR_12) VAR_8 = 63;",
"} else {",
"int VAR_22;",
"memset(ac_val2, 0, 16 * 2);",
"if(VAR_6) {",
"if(VAR_12) {",
"memcpy(ac_val2, ac_val, 8 * 2);",
"if(VAR_15 && VAR_14!=VAR_15) {",
"VAR_14 = VAR_14 * 2 + ((VAR_14 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;",
"VAR_15 = VAR_15 * 2 + ((VAR_15 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++)",
"ac_val2[VAR_22] = (ac_val2[VAR_22] * VAR_15 * vc1_dqscale[VAR_14 - 1] + 0x20000) >> 18;",
"}",
"}",
"} else {",
"if(VAR_12) {",
"memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);",
"if(VAR_15 && VAR_14!=VAR_15) {",
"VAR_14 = VAR_14 * 2 + ((VAR_14 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;",
"VAR_15 = VAR_15 * 2 + ((VAR_15 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++)",
"ac_val2[VAR_22 + 8] = (ac_val2[VAR_22 + 8] * VAR_15 * vc1_dqscale[VAR_14 - 1] + 0x20000) >> 18;",
"}",
"}",
"}",
"if(VAR_12) {",
"if(VAR_6) {",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++) {",
"VAR_1[VAR_22 << 3] = ac_val2[VAR_22] * VAR_13;",
"if(!VAR_0->pquantizer && VAR_1[VAR_22 << 3])\nVAR_1[VAR_22 << 3] += (VAR_1[VAR_22 << 3] < 0) ? -VAR_5 : VAR_5;",
"}",
"} else {",
"for(VAR_22 = 1; VAR_22 < 8; VAR_22++) {",
"VAR_1[VAR_22] = ac_val2[VAR_22 + 8] * VAR_13;",
"if(!VAR_0->pquantizer && VAR_1[VAR_22])\nVAR_1[VAR_22] += (VAR_1[VAR_22] < 0) ? -VAR_5 : VAR_5;",
"}",
"}",
"VAR_8 = 63;",
"}",
"}",
"s->block_last_index[VAR_2] = VAR_8;",
"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,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
55,
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73,
75
],
[
77,
79
],
[
81
],
[
83,
85
],
[
87
],
[
93
],
[
95
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
121
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
139
],
[
143,
145
],
[
147,
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173
],
[
175,
177
],
[
179,
181
],
[
183
],
[
185
],
[
189
],
[
191
],
[
193
],
[
195,
197
],
[
199
],
[
201
],
[
207
],
[
211
],
[
213
],
[
215
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
255
],
[
257
],
[
259
],
[
261
],
[
267
],
[
269
],
[
271
],
[
273,
275
],
[
277
],
[
281
],
[
283
],
[
285
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345,
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357,
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
375
],
[
377
]
] |
18,294 | int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset,
int nb_clusters)
{
BDRVQcowState *s = bs->opaque;
uint64_t cluster_index;
uint64_t old_free_cluster_index;
int i, refcount, ret;
/* Check how many clusters there are free */
cluster_index = offset >> s->cluster_bits;
for(i = 0; i < nb_clusters; i++) {
refcount = get_refcount(bs, cluster_index++);
if (refcount < 0) {
return refcount;
} else if (refcount != 0) {
break;
}
}
/* And then allocate them */
ret = update_refcount(bs, offset, i << s->cluster_bits, 1);
if (ret < 0) {
return ret;
}
return i;
} | true | qemu | f24423bd902bce29bc546cf8d030bfa369726ab1 | int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset,
int nb_clusters)
{
BDRVQcowState *s = bs->opaque;
uint64_t cluster_index;
uint64_t old_free_cluster_index;
int i, refcount, ret;
cluster_index = offset >> s->cluster_bits;
for(i = 0; i < nb_clusters; i++) {
refcount = get_refcount(bs, cluster_index++);
if (refcount < 0) {
return refcount;
} else if (refcount != 0) {
break;
}
}
ret = update_refcount(bs, offset, i << s->cluster_bits, 1);
if (ret < 0) {
return ret;
}
return i;
} | {
"code": [],
"line_no": []
} | int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,
int VAR_2)
{
BDRVQcowState *s = VAR_0->opaque;
uint64_t cluster_index;
uint64_t old_free_cluster_index;
int VAR_3, VAR_4, VAR_5;
cluster_index = VAR_1 >> s->cluster_bits;
for(VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) {
VAR_4 = get_refcount(VAR_0, cluster_index++);
if (VAR_4 < 0) {
return VAR_4;
} else if (VAR_4 != 0) {
break;
}
}
VAR_5 = update_refcount(VAR_0, VAR_1, VAR_3 << s->cluster_bits, 1);
if (VAR_5 < 0) {
return VAR_5;
}
return VAR_3;
} | [
"int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,\nint VAR_2)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"uint64_t cluster_index;",
"uint64_t old_free_cluster_index;",
"int VAR_3, VAR_4, VAR_5;",
"cluster_index = VAR_1 >> s->cluster_bits;",
"for(VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) {",
"VAR_4 = get_refcount(VAR_0, cluster_index++);",
"if (VAR_4 < 0) {",
"return VAR_4;",
"} else if (VAR_4 != 0) {",
"break;",
"}",
"}",
"VAR_5 = update_refcount(VAR_0, VAR_1, VAR_3 << s->cluster_bits, 1);",
"if (VAR_5 < 0) {",
"return VAR_5;",
"}",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2,
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
19
],
[
20
],
[
21
],
[
22
],
[
23
],
[
24
]
] |
18,295 | static void oledate_to_iso8601(char *buf, int buf_size, int64_t value)
{
time_t t = 631112400LL + 86400*av_int2dbl(value);
strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", gmtime(&t));
}
| true | FFmpeg | 8acab7ae5bbcb589c556425453ac3d851d35021f | static void oledate_to_iso8601(char *buf, int buf_size, int64_t value)
{
time_t t = 631112400LL + 86400*av_int2dbl(value);
strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", gmtime(&t));
}
| {
"code": [
"static void oledate_to_iso8601(char *buf, int buf_size, int64_t value)",
" strftime(buf, buf_size, \"%Y-%m-%d %H:%M:%S\", gmtime(&t));"
],
"line_no": [
1,
7
]
} | static void FUNC_0(char *VAR_0, int VAR_1, int64_t VAR_2)
{
time_t t = 631112400LL + 86400*av_int2dbl(VAR_2);
strftime(VAR_0, VAR_1, "%Y-%m-%d %H:%M:%S", gmtime(&t));
}
| [
"static void FUNC_0(char *VAR_0, int VAR_1, int64_t VAR_2)\n{",
"time_t t = 631112400LL + 86400*av_int2dbl(VAR_2);",
"strftime(VAR_0, VAR_1, \"%Y-%m-%d %H:%M:%S\", gmtime(&t));",
"}"
] | [
1,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
18,296 | const char *get_register_name_32(unsigned int reg)
{
if (reg > CPU_NB_REGS32) {
return NULL;
}
return x86_reg_info_32[reg].name;
}
| true | qemu | 31ccdde298d98b08526dc23059071c9086dec6c2 | const char *get_register_name_32(unsigned int reg)
{
if (reg > CPU_NB_REGS32) {
return NULL;
}
return x86_reg_info_32[reg].name;
}
| {
"code": [
" if (reg > CPU_NB_REGS32) {"
],
"line_no": [
5
]
} | const char *FUNC_0(unsigned int VAR_0)
{
if (VAR_0 > CPU_NB_REGS32) {
return NULL;
}
return x86_reg_info_32[VAR_0].name;
}
| [
"const char *FUNC_0(unsigned int VAR_0)\n{",
"if (VAR_0 > CPU_NB_REGS32) {",
"return NULL;",
"}",
"return x86_reg_info_32[VAR_0].name;",
"}"
] | [
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
18,297 | struct pxa2xx_state_s *pxa255_init(unsigned int sdram_size,
DisplayState *ds)
{
struct pxa2xx_state_s *s;
struct pxa2xx_ssp_s *ssp;
int iomemtype, i;
s = (struct pxa2xx_state_s *) qemu_mallocz(sizeof(struct pxa2xx_state_s));
s->env = cpu_init();
cpu_arm_set_model(s->env, "pxa255");
register_savevm("cpu", 0, 0, cpu_save, cpu_load, s->env);
/* SDRAM & Internal Memory Storage */
cpu_register_physical_memory(PXA2XX_SDRAM_BASE, sdram_size,
qemu_ram_alloc(sdram_size) | IO_MEM_RAM);
cpu_register_physical_memory(PXA2XX_INTERNAL_BASE, PXA2XX_INTERNAL_SIZE,
qemu_ram_alloc(PXA2XX_INTERNAL_SIZE) | IO_MEM_RAM);
s->pic = pxa2xx_pic_init(0x40d00000, s->env);
s->dma = pxa255_dma_init(0x40000000, s->pic[PXA2XX_PIC_DMA]);
pxa25x_timer_init(0x40a00000, &s->pic[PXA2XX_PIC_OST_0]);
s->gpio = pxa2xx_gpio_init(0x40e00000, s->env, s->pic, 85);
s->mmc = pxa2xx_mmci_init(0x41100000, s->pic[PXA2XX_PIC_MMC], s->dma);
for (i = 0; pxa255_serial[i].io_base; i ++)
if (serial_hds[i])
serial_mm_init(pxa255_serial[i].io_base, 2,
s->pic[pxa255_serial[i].irqn], serial_hds[i], 1);
else
break;
if (serial_hds[i])
s->fir = pxa2xx_fir_init(0x40800000, s->pic[PXA2XX_PIC_ICP],
s->dma, serial_hds[i]);
if (ds)
s->lcd = pxa2xx_lcdc_init(0x44000000, s->pic[PXA2XX_PIC_LCD], ds);
s->cm_base = 0x41300000;
s->cm_regs[CCCR >> 4] = 0x02000210; /* 416.0 MHz */
s->clkcfg = 0x00000009; /* Turbo mode active */
iomemtype = cpu_register_io_memory(0, pxa2xx_cm_readfn,
pxa2xx_cm_writefn, s);
cpu_register_physical_memory(s->cm_base, 0xfff, iomemtype);
register_savevm("pxa2xx_cm", 0, 0, pxa2xx_cm_save, pxa2xx_cm_load, s);
cpu_arm_set_cp_io(s->env, 14, pxa2xx_cp14_read, pxa2xx_cp14_write, s);
s->mm_base = 0x48000000;
s->mm_regs[MDMRS >> 2] = 0x00020002;
s->mm_regs[MDREFR >> 2] = 0x03ca4000;
s->mm_regs[MECR >> 2] = 0x00000001; /* Two PC Card sockets */
iomemtype = cpu_register_io_memory(0, pxa2xx_mm_readfn,
pxa2xx_mm_writefn, s);
cpu_register_physical_memory(s->mm_base, 0xfff, iomemtype);
register_savevm("pxa2xx_mm", 0, 0, pxa2xx_mm_save, pxa2xx_mm_load, s);
s->pm_base = 0x40f00000;
iomemtype = cpu_register_io_memory(0, pxa2xx_pm_readfn,
pxa2xx_pm_writefn, s);
cpu_register_physical_memory(s->pm_base, 0xff, iomemtype);
register_savevm("pxa2xx_pm", 0, 0, pxa2xx_pm_save, pxa2xx_pm_load, s);
for (i = 0; pxa255_ssp[i].io_base; i ++);
s->ssp = (struct pxa2xx_ssp_s **)
qemu_mallocz(sizeof(struct pxa2xx_ssp_s *) * i);
ssp = (struct pxa2xx_ssp_s *)
qemu_mallocz(sizeof(struct pxa2xx_ssp_s) * i);
for (i = 0; pxa255_ssp[i].io_base; i ++) {
s->ssp[i] = &ssp[i];
ssp[i].base = pxa255_ssp[i].io_base;
ssp[i].irq = s->pic[pxa255_ssp[i].irqn];
iomemtype = cpu_register_io_memory(0, pxa2xx_ssp_readfn,
pxa2xx_ssp_writefn, &ssp[i]);
cpu_register_physical_memory(ssp[i].base, 0xfff, iomemtype);
register_savevm("pxa2xx_ssp", i, 0,
pxa2xx_ssp_save, pxa2xx_ssp_load, s);
}
if (usb_enabled) {
usb_ohci_init_pxa(0x4c000000, 3, -1, s->pic[PXA2XX_PIC_USBH1]);
}
s->pcmcia[0] = pxa2xx_pcmcia_init(0x20000000);
s->pcmcia[1] = pxa2xx_pcmcia_init(0x30000000);
s->rtc_base = 0x40900000;
iomemtype = cpu_register_io_memory(0, pxa2xx_rtc_readfn,
pxa2xx_rtc_writefn, s);
cpu_register_physical_memory(s->rtc_base, 0xfff, iomemtype);
pxa2xx_rtc_init(s);
register_savevm("pxa2xx_rtc", 0, 0, pxa2xx_rtc_save, pxa2xx_rtc_load, s);
s->i2c[0] = pxa2xx_i2c_init(0x40301600, s->pic[PXA2XX_PIC_I2C], 0xffff);
s->i2c[1] = pxa2xx_i2c_init(0x40f00100, s->pic[PXA2XX_PIC_PWRI2C], 0xff);
s->i2s = pxa2xx_i2s_init(0x40400000, s->pic[PXA2XX_PIC_I2S], s->dma);
/* GPIO1 resets the processor */
/* The handler can be overriden by board-specific code */
pxa2xx_gpio_handler_set(s->gpio, 1, pxa2xx_reset, s);
return s;
}
| true | qemu | 187337f8b0ec0813dd3876d1efe37d415fb81c2e | struct pxa2xx_state_s *pxa255_init(unsigned int sdram_size,
DisplayState *ds)
{
struct pxa2xx_state_s *s;
struct pxa2xx_ssp_s *ssp;
int iomemtype, i;
s = (struct pxa2xx_state_s *) qemu_mallocz(sizeof(struct pxa2xx_state_s));
s->env = cpu_init();
cpu_arm_set_model(s->env, "pxa255");
register_savevm("cpu", 0, 0, cpu_save, cpu_load, s->env);
cpu_register_physical_memory(PXA2XX_SDRAM_BASE, sdram_size,
qemu_ram_alloc(sdram_size) | IO_MEM_RAM);
cpu_register_physical_memory(PXA2XX_INTERNAL_BASE, PXA2XX_INTERNAL_SIZE,
qemu_ram_alloc(PXA2XX_INTERNAL_SIZE) | IO_MEM_RAM);
s->pic = pxa2xx_pic_init(0x40d00000, s->env);
s->dma = pxa255_dma_init(0x40000000, s->pic[PXA2XX_PIC_DMA]);
pxa25x_timer_init(0x40a00000, &s->pic[PXA2XX_PIC_OST_0]);
s->gpio = pxa2xx_gpio_init(0x40e00000, s->env, s->pic, 85);
s->mmc = pxa2xx_mmci_init(0x41100000, s->pic[PXA2XX_PIC_MMC], s->dma);
for (i = 0; pxa255_serial[i].io_base; i ++)
if (serial_hds[i])
serial_mm_init(pxa255_serial[i].io_base, 2,
s->pic[pxa255_serial[i].irqn], serial_hds[i], 1);
else
break;
if (serial_hds[i])
s->fir = pxa2xx_fir_init(0x40800000, s->pic[PXA2XX_PIC_ICP],
s->dma, serial_hds[i]);
if (ds)
s->lcd = pxa2xx_lcdc_init(0x44000000, s->pic[PXA2XX_PIC_LCD], ds);
s->cm_base = 0x41300000;
s->cm_regs[CCCR >> 4] = 0x02000210;
s->clkcfg = 0x00000009;
iomemtype = cpu_register_io_memory(0, pxa2xx_cm_readfn,
pxa2xx_cm_writefn, s);
cpu_register_physical_memory(s->cm_base, 0xfff, iomemtype);
register_savevm("pxa2xx_cm", 0, 0, pxa2xx_cm_save, pxa2xx_cm_load, s);
cpu_arm_set_cp_io(s->env, 14, pxa2xx_cp14_read, pxa2xx_cp14_write, s);
s->mm_base = 0x48000000;
s->mm_regs[MDMRS >> 2] = 0x00020002;
s->mm_regs[MDREFR >> 2] = 0x03ca4000;
s->mm_regs[MECR >> 2] = 0x00000001;
iomemtype = cpu_register_io_memory(0, pxa2xx_mm_readfn,
pxa2xx_mm_writefn, s);
cpu_register_physical_memory(s->mm_base, 0xfff, iomemtype);
register_savevm("pxa2xx_mm", 0, 0, pxa2xx_mm_save, pxa2xx_mm_load, s);
s->pm_base = 0x40f00000;
iomemtype = cpu_register_io_memory(0, pxa2xx_pm_readfn,
pxa2xx_pm_writefn, s);
cpu_register_physical_memory(s->pm_base, 0xff, iomemtype);
register_savevm("pxa2xx_pm", 0, 0, pxa2xx_pm_save, pxa2xx_pm_load, s);
for (i = 0; pxa255_ssp[i].io_base; i ++);
s->ssp = (struct pxa2xx_ssp_s **)
qemu_mallocz(sizeof(struct pxa2xx_ssp_s *) * i);
ssp = (struct pxa2xx_ssp_s *)
qemu_mallocz(sizeof(struct pxa2xx_ssp_s) * i);
for (i = 0; pxa255_ssp[i].io_base; i ++) {
s->ssp[i] = &ssp[i];
ssp[i].base = pxa255_ssp[i].io_base;
ssp[i].irq = s->pic[pxa255_ssp[i].irqn];
iomemtype = cpu_register_io_memory(0, pxa2xx_ssp_readfn,
pxa2xx_ssp_writefn, &ssp[i]);
cpu_register_physical_memory(ssp[i].base, 0xfff, iomemtype);
register_savevm("pxa2xx_ssp", i, 0,
pxa2xx_ssp_save, pxa2xx_ssp_load, s);
}
if (usb_enabled) {
usb_ohci_init_pxa(0x4c000000, 3, -1, s->pic[PXA2XX_PIC_USBH1]);
}
s->pcmcia[0] = pxa2xx_pcmcia_init(0x20000000);
s->pcmcia[1] = pxa2xx_pcmcia_init(0x30000000);
s->rtc_base = 0x40900000;
iomemtype = cpu_register_io_memory(0, pxa2xx_rtc_readfn,
pxa2xx_rtc_writefn, s);
cpu_register_physical_memory(s->rtc_base, 0xfff, iomemtype);
pxa2xx_rtc_init(s);
register_savevm("pxa2xx_rtc", 0, 0, pxa2xx_rtc_save, pxa2xx_rtc_load, s);
s->i2c[0] = pxa2xx_i2c_init(0x40301600, s->pic[PXA2XX_PIC_I2C], 0xffff);
s->i2c[1] = pxa2xx_i2c_init(0x40f00100, s->pic[PXA2XX_PIC_PWRI2C], 0xff);
s->i2s = pxa2xx_i2s_init(0x40400000, s->pic[PXA2XX_PIC_I2S], s->dma);
pxa2xx_gpio_handler_set(s->gpio, 1, pxa2xx_reset, s);
return s;
}
| {
"code": [
" cpu_register_physical_memory(s->cm_base, 0xfff, iomemtype);",
" cpu_register_physical_memory(s->mm_base, 0xfff, iomemtype);",
" cpu_register_physical_memory(s->pm_base, 0xff, iomemtype);",
" cpu_register_physical_memory(ssp[i].base, 0xfff, iomemtype);",
" cpu_register_physical_memory(s->rtc_base, 0xfff, iomemtype);",
" cpu_register_physical_memory(s->cm_base, 0xfff, iomemtype);",
" cpu_register_physical_memory(s->mm_base, 0xfff, iomemtype);",
" cpu_register_physical_memory(s->pm_base, 0xff, iomemtype);",
" cpu_register_physical_memory(ssp[i].base, 0xfff, iomemtype);",
" cpu_register_physical_memory(s->rtc_base, 0xfff, iomemtype);"
],
"line_no": [
93,
115,
127,
157,
187,
93,
115,
127,
157,
187
]
} | struct pxa2xx_state_s *FUNC_0(unsigned int VAR_0,
DisplayState *VAR_1)
{
struct pxa2xx_state_s *VAR_2;
struct pxa2xx_ssp_s *VAR_3;
int VAR_4, VAR_5;
VAR_2 = (struct pxa2xx_state_s *) qemu_mallocz(sizeof(struct pxa2xx_state_s));
VAR_2->env = cpu_init();
cpu_arm_set_model(VAR_2->env, "pxa255");
register_savevm("cpu", 0, 0, cpu_save, cpu_load, VAR_2->env);
cpu_register_physical_memory(PXA2XX_SDRAM_BASE, VAR_0,
qemu_ram_alloc(VAR_0) | IO_MEM_RAM);
cpu_register_physical_memory(PXA2XX_INTERNAL_BASE, PXA2XX_INTERNAL_SIZE,
qemu_ram_alloc(PXA2XX_INTERNAL_SIZE) | IO_MEM_RAM);
VAR_2->pic = pxa2xx_pic_init(0x40d00000, VAR_2->env);
VAR_2->dma = pxa255_dma_init(0x40000000, VAR_2->pic[PXA2XX_PIC_DMA]);
pxa25x_timer_init(0x40a00000, &VAR_2->pic[PXA2XX_PIC_OST_0]);
VAR_2->gpio = pxa2xx_gpio_init(0x40e00000, VAR_2->env, VAR_2->pic, 85);
VAR_2->mmc = pxa2xx_mmci_init(0x41100000, VAR_2->pic[PXA2XX_PIC_MMC], VAR_2->dma);
for (VAR_5 = 0; pxa255_serial[VAR_5].io_base; VAR_5 ++)
if (serial_hds[VAR_5])
serial_mm_init(pxa255_serial[VAR_5].io_base, 2,
VAR_2->pic[pxa255_serial[VAR_5].irqn], serial_hds[VAR_5], 1);
else
break;
if (serial_hds[VAR_5])
VAR_2->fir = pxa2xx_fir_init(0x40800000, VAR_2->pic[PXA2XX_PIC_ICP],
VAR_2->dma, serial_hds[VAR_5]);
if (VAR_1)
VAR_2->lcd = pxa2xx_lcdc_init(0x44000000, VAR_2->pic[PXA2XX_PIC_LCD], VAR_1);
VAR_2->cm_base = 0x41300000;
VAR_2->cm_regs[CCCR >> 4] = 0x02000210;
VAR_2->clkcfg = 0x00000009;
VAR_4 = cpu_register_io_memory(0, pxa2xx_cm_readfn,
pxa2xx_cm_writefn, VAR_2);
cpu_register_physical_memory(VAR_2->cm_base, 0xfff, VAR_4);
register_savevm("pxa2xx_cm", 0, 0, pxa2xx_cm_save, pxa2xx_cm_load, VAR_2);
cpu_arm_set_cp_io(VAR_2->env, 14, pxa2xx_cp14_read, pxa2xx_cp14_write, VAR_2);
VAR_2->mm_base = 0x48000000;
VAR_2->mm_regs[MDMRS >> 2] = 0x00020002;
VAR_2->mm_regs[MDREFR >> 2] = 0x03ca4000;
VAR_2->mm_regs[MECR >> 2] = 0x00000001;
VAR_4 = cpu_register_io_memory(0, pxa2xx_mm_readfn,
pxa2xx_mm_writefn, VAR_2);
cpu_register_physical_memory(VAR_2->mm_base, 0xfff, VAR_4);
register_savevm("pxa2xx_mm", 0, 0, pxa2xx_mm_save, pxa2xx_mm_load, VAR_2);
VAR_2->pm_base = 0x40f00000;
VAR_4 = cpu_register_io_memory(0, pxa2xx_pm_readfn,
pxa2xx_pm_writefn, VAR_2);
cpu_register_physical_memory(VAR_2->pm_base, 0xff, VAR_4);
register_savevm("pxa2xx_pm", 0, 0, pxa2xx_pm_save, pxa2xx_pm_load, VAR_2);
for (VAR_5 = 0; pxa255_ssp[VAR_5].io_base; VAR_5 ++);
VAR_2->VAR_3 = (struct pxa2xx_ssp_s **)
qemu_mallocz(sizeof(struct pxa2xx_ssp_s *) * VAR_5);
VAR_3 = (struct pxa2xx_ssp_s *)
qemu_mallocz(sizeof(struct pxa2xx_ssp_s) * VAR_5);
for (VAR_5 = 0; pxa255_ssp[VAR_5].io_base; VAR_5 ++) {
VAR_2->VAR_3[VAR_5] = &VAR_3[VAR_5];
VAR_3[VAR_5].base = pxa255_ssp[VAR_5].io_base;
VAR_3[VAR_5].irq = VAR_2->pic[pxa255_ssp[VAR_5].irqn];
VAR_4 = cpu_register_io_memory(0, pxa2xx_ssp_readfn,
pxa2xx_ssp_writefn, &VAR_3[VAR_5]);
cpu_register_physical_memory(VAR_3[VAR_5].base, 0xfff, VAR_4);
register_savevm("pxa2xx_ssp", VAR_5, 0,
pxa2xx_ssp_save, pxa2xx_ssp_load, VAR_2);
}
if (usb_enabled) {
usb_ohci_init_pxa(0x4c000000, 3, -1, VAR_2->pic[PXA2XX_PIC_USBH1]);
}
VAR_2->pcmcia[0] = pxa2xx_pcmcia_init(0x20000000);
VAR_2->pcmcia[1] = pxa2xx_pcmcia_init(0x30000000);
VAR_2->rtc_base = 0x40900000;
VAR_4 = cpu_register_io_memory(0, pxa2xx_rtc_readfn,
pxa2xx_rtc_writefn, VAR_2);
cpu_register_physical_memory(VAR_2->rtc_base, 0xfff, VAR_4);
pxa2xx_rtc_init(VAR_2);
register_savevm("pxa2xx_rtc", 0, 0, pxa2xx_rtc_save, pxa2xx_rtc_load, VAR_2);
VAR_2->i2c[0] = pxa2xx_i2c_init(0x40301600, VAR_2->pic[PXA2XX_PIC_I2C], 0xffff);
VAR_2->i2c[1] = pxa2xx_i2c_init(0x40f00100, VAR_2->pic[PXA2XX_PIC_PWRI2C], 0xff);
VAR_2->i2s = pxa2xx_i2s_init(0x40400000, VAR_2->pic[PXA2XX_PIC_I2S], VAR_2->dma);
pxa2xx_gpio_handler_set(VAR_2->gpio, 1, pxa2xx_reset, VAR_2);
return VAR_2;
}
| [
"struct pxa2xx_state_s *FUNC_0(unsigned int VAR_0,\nDisplayState *VAR_1)\n{",
"struct pxa2xx_state_s *VAR_2;",
"struct pxa2xx_ssp_s *VAR_3;",
"int VAR_4, VAR_5;",
"VAR_2 = (struct pxa2xx_state_s *) qemu_mallocz(sizeof(struct pxa2xx_state_s));",
"VAR_2->env = cpu_init();",
"cpu_arm_set_model(VAR_2->env, \"pxa255\");",
"register_savevm(\"cpu\", 0, 0, cpu_save, cpu_load, VAR_2->env);",
"cpu_register_physical_memory(PXA2XX_SDRAM_BASE, VAR_0,\nqemu_ram_alloc(VAR_0) | IO_MEM_RAM);",
"cpu_register_physical_memory(PXA2XX_INTERNAL_BASE, PXA2XX_INTERNAL_SIZE,\nqemu_ram_alloc(PXA2XX_INTERNAL_SIZE) | IO_MEM_RAM);",
"VAR_2->pic = pxa2xx_pic_init(0x40d00000, VAR_2->env);",
"VAR_2->dma = pxa255_dma_init(0x40000000, VAR_2->pic[PXA2XX_PIC_DMA]);",
"pxa25x_timer_init(0x40a00000, &VAR_2->pic[PXA2XX_PIC_OST_0]);",
"VAR_2->gpio = pxa2xx_gpio_init(0x40e00000, VAR_2->env, VAR_2->pic, 85);",
"VAR_2->mmc = pxa2xx_mmci_init(0x41100000, VAR_2->pic[PXA2XX_PIC_MMC], VAR_2->dma);",
"for (VAR_5 = 0; pxa255_serial[VAR_5].io_base; VAR_5 ++)",
"if (serial_hds[VAR_5])\nserial_mm_init(pxa255_serial[VAR_5].io_base, 2,\nVAR_2->pic[pxa255_serial[VAR_5].irqn], serial_hds[VAR_5], 1);",
"else\nbreak;",
"if (serial_hds[VAR_5])\nVAR_2->fir = pxa2xx_fir_init(0x40800000, VAR_2->pic[PXA2XX_PIC_ICP],\nVAR_2->dma, serial_hds[VAR_5]);",
"if (VAR_1)\nVAR_2->lcd = pxa2xx_lcdc_init(0x44000000, VAR_2->pic[PXA2XX_PIC_LCD], VAR_1);",
"VAR_2->cm_base = 0x41300000;",
"VAR_2->cm_regs[CCCR >> 4] = 0x02000210;",
"VAR_2->clkcfg = 0x00000009;",
"VAR_4 = cpu_register_io_memory(0, pxa2xx_cm_readfn,\npxa2xx_cm_writefn, VAR_2);",
"cpu_register_physical_memory(VAR_2->cm_base, 0xfff, VAR_4);",
"register_savevm(\"pxa2xx_cm\", 0, 0, pxa2xx_cm_save, pxa2xx_cm_load, VAR_2);",
"cpu_arm_set_cp_io(VAR_2->env, 14, pxa2xx_cp14_read, pxa2xx_cp14_write, VAR_2);",
"VAR_2->mm_base = 0x48000000;",
"VAR_2->mm_regs[MDMRS >> 2] = 0x00020002;",
"VAR_2->mm_regs[MDREFR >> 2] = 0x03ca4000;",
"VAR_2->mm_regs[MECR >> 2] = 0x00000001;",
"VAR_4 = cpu_register_io_memory(0, pxa2xx_mm_readfn,\npxa2xx_mm_writefn, VAR_2);",
"cpu_register_physical_memory(VAR_2->mm_base, 0xfff, VAR_4);",
"register_savevm(\"pxa2xx_mm\", 0, 0, pxa2xx_mm_save, pxa2xx_mm_load, VAR_2);",
"VAR_2->pm_base = 0x40f00000;",
"VAR_4 = cpu_register_io_memory(0, pxa2xx_pm_readfn,\npxa2xx_pm_writefn, VAR_2);",
"cpu_register_physical_memory(VAR_2->pm_base, 0xff, VAR_4);",
"register_savevm(\"pxa2xx_pm\", 0, 0, pxa2xx_pm_save, pxa2xx_pm_load, VAR_2);",
"for (VAR_5 = 0; pxa255_ssp[VAR_5].io_base; VAR_5 ++);",
"VAR_2->VAR_3 = (struct pxa2xx_ssp_s **)\nqemu_mallocz(sizeof(struct pxa2xx_ssp_s *) * VAR_5);",
"VAR_3 = (struct pxa2xx_ssp_s *)\nqemu_mallocz(sizeof(struct pxa2xx_ssp_s) * VAR_5);",
"for (VAR_5 = 0; pxa255_ssp[VAR_5].io_base; VAR_5 ++) {",
"VAR_2->VAR_3[VAR_5] = &VAR_3[VAR_5];",
"VAR_3[VAR_5].base = pxa255_ssp[VAR_5].io_base;",
"VAR_3[VAR_5].irq = VAR_2->pic[pxa255_ssp[VAR_5].irqn];",
"VAR_4 = cpu_register_io_memory(0, pxa2xx_ssp_readfn,\npxa2xx_ssp_writefn, &VAR_3[VAR_5]);",
"cpu_register_physical_memory(VAR_3[VAR_5].base, 0xfff, VAR_4);",
"register_savevm(\"pxa2xx_ssp\", VAR_5, 0,\npxa2xx_ssp_save, pxa2xx_ssp_load, VAR_2);",
"}",
"if (usb_enabled) {",
"usb_ohci_init_pxa(0x4c000000, 3, -1, VAR_2->pic[PXA2XX_PIC_USBH1]);",
"}",
"VAR_2->pcmcia[0] = pxa2xx_pcmcia_init(0x20000000);",
"VAR_2->pcmcia[1] = pxa2xx_pcmcia_init(0x30000000);",
"VAR_2->rtc_base = 0x40900000;",
"VAR_4 = cpu_register_io_memory(0, pxa2xx_rtc_readfn,\npxa2xx_rtc_writefn, VAR_2);",
"cpu_register_physical_memory(VAR_2->rtc_base, 0xfff, VAR_4);",
"pxa2xx_rtc_init(VAR_2);",
"register_savevm(\"pxa2xx_rtc\", 0, 0, pxa2xx_rtc_save, pxa2xx_rtc_load, VAR_2);",
"VAR_2->i2c[0] = pxa2xx_i2c_init(0x40301600, VAR_2->pic[PXA2XX_PIC_I2C], 0xffff);",
"VAR_2->i2c[1] = pxa2xx_i2c_init(0x40f00100, VAR_2->pic[PXA2XX_PIC_PWRI2C], 0xff);",
"VAR_2->i2s = pxa2xx_i2s_init(0x40400000, VAR_2->pic[PXA2XX_PIC_I2S], VAR_2->dma);",
"pxa2xx_gpio_handler_set(VAR_2->gpio, 1, pxa2xx_reset, VAR_2);",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
27,
29
],
[
31,
33
],
[
37
],
[
41
],
[
45
],
[
49
],
[
53
],
[
57
],
[
59,
61,
63
],
[
65,
67
],
[
69,
71,
73
],
[
77,
79
],
[
83
],
[
85
],
[
87
],
[
89,
91
],
[
93
],
[
95
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
121
],
[
123,
125
],
[
127
],
[
129
],
[
133
],
[
135,
137
],
[
139,
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153,
155
],
[
157
],
[
159,
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
181
],
[
183,
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
201
],
[
209
],
[
211
],
[
213
]
] |
18,299 | int av_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, i;
AVStream *st;
for(;;){
AVPacketList *pktl = s->raw_packet_buffer;
if (pktl) {
*pkt = pktl->pkt;
if(s->streams[pkt->stream_index]->codec->codec_id != CODEC_ID_PROBE ||
!s->streams[pkt->stream_index]->probe_packets){
s->raw_packet_buffer = pktl->next;
av_free(pktl);
return 0;
}
}
av_init_packet(pkt);
ret= s->iformat->read_packet(s, pkt);
if (ret < 0) {
if (!pktl || ret == AVERROR(EAGAIN))
return ret;
for (i = 0; i < s->nb_streams; i++)
s->streams[i]->probe_packets = 0;
continue;
}
st= s->streams[pkt->stream_index];
switch(st->codec->codec_type){
case CODEC_TYPE_VIDEO:
if(s->video_codec_id) st->codec->codec_id= s->video_codec_id;
break;
case CODEC_TYPE_AUDIO:
if(s->audio_codec_id) st->codec->codec_id= s->audio_codec_id;
break;
case CODEC_TYPE_SUBTITLE:
if(s->subtitle_codec_id)st->codec->codec_id= s->subtitle_codec_id;
break;
}
if(!pktl && (st->codec->codec_id != CODEC_ID_PROBE ||
!st->probe_packets))
return ret;
add_to_pktbuf(&s->raw_packet_buffer, pkt, &s->raw_packet_buffer_end);
if(st->codec->codec_id == CODEC_ID_PROBE){
AVProbeData *pd = &st->probe_data;
--st->probe_packets;
pd->buf = av_realloc(pd->buf, pd->buf_size+pkt->size+AVPROBE_PADDING_SIZE);
memcpy(pd->buf+pd->buf_size, pkt->data, pkt->size);
pd->buf_size += pkt->size;
memset(pd->buf+pd->buf_size, 0, AVPROBE_PADDING_SIZE);
if(av_log2(pd->buf_size) != av_log2(pd->buf_size - pkt->size)){
set_codec_from_probe_data(st, pd, 1);
if(st->codec->codec_id != CODEC_ID_PROBE){
pd->buf_size=0;
av_freep(&pd->buf);
}
}
}
}
}
| false | FFmpeg | af122d6a80686d9c786b4b46213ef1f5a9699b3e | int av_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, i;
AVStream *st;
for(;;){
AVPacketList *pktl = s->raw_packet_buffer;
if (pktl) {
*pkt = pktl->pkt;
if(s->streams[pkt->stream_index]->codec->codec_id != CODEC_ID_PROBE ||
!s->streams[pkt->stream_index]->probe_packets){
s->raw_packet_buffer = pktl->next;
av_free(pktl);
return 0;
}
}
av_init_packet(pkt);
ret= s->iformat->read_packet(s, pkt);
if (ret < 0) {
if (!pktl || ret == AVERROR(EAGAIN))
return ret;
for (i = 0; i < s->nb_streams; i++)
s->streams[i]->probe_packets = 0;
continue;
}
st= s->streams[pkt->stream_index];
switch(st->codec->codec_type){
case CODEC_TYPE_VIDEO:
if(s->video_codec_id) st->codec->codec_id= s->video_codec_id;
break;
case CODEC_TYPE_AUDIO:
if(s->audio_codec_id) st->codec->codec_id= s->audio_codec_id;
break;
case CODEC_TYPE_SUBTITLE:
if(s->subtitle_codec_id)st->codec->codec_id= s->subtitle_codec_id;
break;
}
if(!pktl && (st->codec->codec_id != CODEC_ID_PROBE ||
!st->probe_packets))
return ret;
add_to_pktbuf(&s->raw_packet_buffer, pkt, &s->raw_packet_buffer_end);
if(st->codec->codec_id == CODEC_ID_PROBE){
AVProbeData *pd = &st->probe_data;
--st->probe_packets;
pd->buf = av_realloc(pd->buf, pd->buf_size+pkt->size+AVPROBE_PADDING_SIZE);
memcpy(pd->buf+pd->buf_size, pkt->data, pkt->size);
pd->buf_size += pkt->size;
memset(pd->buf+pd->buf_size, 0, AVPROBE_PADDING_SIZE);
if(av_log2(pd->buf_size) != av_log2(pd->buf_size - pkt->size)){
set_codec_from_probe_data(st, pd, 1);
if(st->codec->codec_id != CODEC_ID_PROBE){
pd->buf_size=0;
av_freep(&pd->buf);
}
}
}
}
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
int VAR_2, VAR_3;
AVStream *st;
for(;;){
AVPacketList *pktl = VAR_0->raw_packet_buffer;
if (pktl) {
*VAR_1 = pktl->VAR_1;
if(VAR_0->streams[VAR_1->stream_index]->codec->codec_id != CODEC_ID_PROBE ||
!VAR_0->streams[VAR_1->stream_index]->probe_packets){
VAR_0->raw_packet_buffer = pktl->next;
av_free(pktl);
return 0;
}
}
av_init_packet(VAR_1);
VAR_2= VAR_0->iformat->read_packet(VAR_0, VAR_1);
if (VAR_2 < 0) {
if (!pktl || VAR_2 == AVERROR(EAGAIN))
return VAR_2;
for (VAR_3 = 0; VAR_3 < VAR_0->nb_streams; VAR_3++)
VAR_0->streams[VAR_3]->probe_packets = 0;
continue;
}
st= VAR_0->streams[VAR_1->stream_index];
switch(st->codec->codec_type){
case CODEC_TYPE_VIDEO:
if(VAR_0->video_codec_id) st->codec->codec_id= VAR_0->video_codec_id;
break;
case CODEC_TYPE_AUDIO:
if(VAR_0->audio_codec_id) st->codec->codec_id= VAR_0->audio_codec_id;
break;
case CODEC_TYPE_SUBTITLE:
if(VAR_0->subtitle_codec_id)st->codec->codec_id= VAR_0->subtitle_codec_id;
break;
}
if(!pktl && (st->codec->codec_id != CODEC_ID_PROBE ||
!st->probe_packets))
return VAR_2;
add_to_pktbuf(&VAR_0->raw_packet_buffer, VAR_1, &VAR_0->raw_packet_buffer_end);
if(st->codec->codec_id == CODEC_ID_PROBE){
AVProbeData *pd = &st->probe_data;
--st->probe_packets;
pd->buf = av_realloc(pd->buf, pd->buf_size+VAR_1->size+AVPROBE_PADDING_SIZE);
memcpy(pd->buf+pd->buf_size, VAR_1->data, VAR_1->size);
pd->buf_size += VAR_1->size;
memset(pd->buf+pd->buf_size, 0, AVPROBE_PADDING_SIZE);
if(av_log2(pd->buf_size) != av_log2(pd->buf_size - VAR_1->size)){
set_codec_from_probe_data(st, pd, 1);
if(st->codec->codec_id != CODEC_ID_PROBE){
pd->buf_size=0;
av_freep(&pd->buf);
}
}
}
}
}
| [
"int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"int VAR_2, VAR_3;",
"AVStream *st;",
"for(;;){",
"AVPacketList *pktl = VAR_0->raw_packet_buffer;",
"if (pktl) {",
"*VAR_1 = pktl->VAR_1;",
"if(VAR_0->streams[VAR_1->stream_index]->codec->codec_id != CODEC_ID_PROBE ||\n!VAR_0->streams[VAR_1->stream_index]->probe_packets){",
"VAR_0->raw_packet_buffer = pktl->next;",
"av_free(pktl);",
"return 0;",
"}",
"}",
"av_init_packet(VAR_1);",
"VAR_2= VAR_0->iformat->read_packet(VAR_0, VAR_1);",
"if (VAR_2 < 0) {",
"if (!pktl || VAR_2 == AVERROR(EAGAIN))\nreturn VAR_2;",
"for (VAR_3 = 0; VAR_3 < VAR_0->nb_streams; VAR_3++)",
"VAR_0->streams[VAR_3]->probe_packets = 0;",
"continue;",
"}",
"st= VAR_0->streams[VAR_1->stream_index];",
"switch(st->codec->codec_type){",
"case CODEC_TYPE_VIDEO:\nif(VAR_0->video_codec_id) st->codec->codec_id= VAR_0->video_codec_id;",
"break;",
"case CODEC_TYPE_AUDIO:\nif(VAR_0->audio_codec_id) st->codec->codec_id= VAR_0->audio_codec_id;",
"break;",
"case CODEC_TYPE_SUBTITLE:\nif(VAR_0->subtitle_codec_id)st->codec->codec_id= VAR_0->subtitle_codec_id;",
"break;",
"}",
"if(!pktl && (st->codec->codec_id != CODEC_ID_PROBE ||\n!st->probe_packets))\nreturn VAR_2;",
"add_to_pktbuf(&VAR_0->raw_packet_buffer, VAR_1, &VAR_0->raw_packet_buffer_end);",
"if(st->codec->codec_id == CODEC_ID_PROBE){",
"AVProbeData *pd = &st->probe_data;",
"--st->probe_packets;",
"pd->buf = av_realloc(pd->buf, pd->buf_size+VAR_1->size+AVPROBE_PADDING_SIZE);",
"memcpy(pd->buf+pd->buf_size, VAR_1->data, VAR_1->size);",
"pd->buf_size += VAR_1->size;",
"memset(pd->buf+pd->buf_size, 0, AVPROBE_PADDING_SIZE);",
"if(av_log2(pd->buf_size) != av_log2(pd->buf_size - VAR_1->size)){",
"set_codec_from_probe_data(st, pd, 1);",
"if(st->codec->codec_id != CODEC_ID_PROBE){",
"pd->buf_size=0;",
"av_freep(&pd->buf);",
"}",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61,
63
],
[
65
],
[
67,
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
83,
85,
87
],
[
91
],
[
95
],
[
97
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
]
] |
18,301 | void nbd_export_close(NBDExport *exp)
{
NBDClient *client, *next;
nbd_export_get(exp);
QTAILQ_FOREACH_SAFE(client, &exp->clients, next, next) {
client_close(client);
}
nbd_export_set_name(exp, NULL);
nbd_export_put(exp);
if (exp->blk) {
blk_remove_aio_context_notifier(exp->blk, blk_aio_attached,
blk_aio_detach, exp);
blk_unref(exp->blk);
exp->blk = NULL;
}
}
| true | qemu | d6268348493f32ecc096caa637620757472a1196 | void nbd_export_close(NBDExport *exp)
{
NBDClient *client, *next;
nbd_export_get(exp);
QTAILQ_FOREACH_SAFE(client, &exp->clients, next, next) {
client_close(client);
}
nbd_export_set_name(exp, NULL);
nbd_export_put(exp);
if (exp->blk) {
blk_remove_aio_context_notifier(exp->blk, blk_aio_attached,
blk_aio_detach, exp);
blk_unref(exp->blk);
exp->blk = NULL;
}
}
| {
"code": [
" if (exp->blk) {",
" blk_remove_aio_context_notifier(exp->blk, blk_aio_attached,",
" blk_aio_detach, exp);",
" blk_unref(exp->blk);",
" exp->blk = NULL;"
],
"line_no": [
21,
23,
25,
27,
29
]
} | void FUNC_0(NBDExport *VAR_0)
{
NBDClient *client, *next;
nbd_export_get(VAR_0);
QTAILQ_FOREACH_SAFE(client, &VAR_0->clients, next, next) {
client_close(client);
}
nbd_export_set_name(VAR_0, NULL);
nbd_export_put(VAR_0);
if (VAR_0->blk) {
blk_remove_aio_context_notifier(VAR_0->blk, blk_aio_attached,
blk_aio_detach, VAR_0);
blk_unref(VAR_0->blk);
VAR_0->blk = NULL;
}
}
| [
"void FUNC_0(NBDExport *VAR_0)\n{",
"NBDClient *client, *next;",
"nbd_export_get(VAR_0);",
"QTAILQ_FOREACH_SAFE(client, &VAR_0->clients, next, next) {",
"client_close(client);",
"}",
"nbd_export_set_name(VAR_0, NULL);",
"nbd_export_put(VAR_0);",
"if (VAR_0->blk) {",
"blk_remove_aio_context_notifier(VAR_0->blk, blk_aio_attached,\nblk_aio_detach, VAR_0);",
"blk_unref(VAR_0->blk);",
"VAR_0->blk = NULL;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
]
] |
18,302 | void iothread_stop(IOThread *iothread)
{
if (!iothread->ctx || iothread->stopping) {
return;
}
iothread->stopping = true;
aio_notify(iothread->ctx);
if (atomic_read(&iothread->main_loop)) {
g_main_loop_quit(iothread->main_loop);
}
qemu_thread_join(&iothread->thread);
}
| true | qemu | 2362a28ea11c145e1a13ae79342d76dc118a72a6 | void iothread_stop(IOThread *iothread)
{
if (!iothread->ctx || iothread->stopping) {
return;
}
iothread->stopping = true;
aio_notify(iothread->ctx);
if (atomic_read(&iothread->main_loop)) {
g_main_loop_quit(iothread->main_loop);
}
qemu_thread_join(&iothread->thread);
}
| {
"code": [
" aio_notify(iothread->ctx);",
" if (atomic_read(&iothread->main_loop)) {",
" g_main_loop_quit(iothread->main_loop);"
],
"line_no": [
13,
15,
17
]
} | void FUNC_0(IOThread *VAR_0)
{
if (!VAR_0->ctx || VAR_0->stopping) {
return;
}
VAR_0->stopping = true;
aio_notify(VAR_0->ctx);
if (atomic_read(&VAR_0->main_loop)) {
g_main_loop_quit(VAR_0->main_loop);
}
qemu_thread_join(&VAR_0->thread);
}
| [
"void FUNC_0(IOThread *VAR_0)\n{",
"if (!VAR_0->ctx || VAR_0->stopping) {",
"return;",
"}",
"VAR_0->stopping = true;",
"aio_notify(VAR_0->ctx);",
"if (atomic_read(&VAR_0->main_loop)) {",
"g_main_loop_quit(VAR_0->main_loop);",
"}",
"qemu_thread_join(&VAR_0->thread);",
"}"
] | [
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
18,303 | void qmp_stop(Error **errp)
{
vm_stop(RUN_STATE_PAUSED);
}
| true | qemu | 1e9981465f05a0f103d7e09afd975c9c0ff6d132 | void qmp_stop(Error **errp)
{
vm_stop(RUN_STATE_PAUSED);
}
| {
"code": [
" vm_stop(RUN_STATE_PAUSED);"
],
"line_no": [
5
]
} | void FUNC_0(Error **VAR_0)
{
vm_stop(RUN_STATE_PAUSED);
}
| [
"void FUNC_0(Error **VAR_0)\n{",
"vm_stop(RUN_STATE_PAUSED);",
"}"
] | [
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
18,305 | const char *postproc_configuration(void)
{
return FFMPEG_CONFIGURATION;
}
| false | FFmpeg | 29ba091136a5e04574f7bfc1b17536c923958f6f | const char *postproc_configuration(void)
{
return FFMPEG_CONFIGURATION;
}
| {
"code": [],
"line_no": []
} | const char *FUNC_0(void)
{
return FFMPEG_CONFIGURATION;
}
| [
"const char *FUNC_0(void)\n{",
"return FFMPEG_CONFIGURATION;",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
18,306 | static void qdm2_decode_fft_packets(QDM2Context *q)
{
int i, j, min, max, value, type, unknown_flag;
GetBitContext gb;
if (q->sub_packet_list_B[0].packet == NULL)
return;
/* reset minimum indexes for FFT coefficients */
q->fft_coefs_index = 0;
for (i = 0; i < 5; i++)
q->fft_coefs_min_index[i] = -1;
/* process subpackets ordered by type, largest type first */
for (i = 0, max = 256; i < q->sub_packets_B; i++) {
QDM2SubPacket *packet = NULL;
/* find subpacket with largest type less than max */
for (j = 0, min = 0; j < q->sub_packets_B; j++) {
value = q->sub_packet_list_B[j].packet->type;
if (value > min && value < max) {
min = value;
packet = q->sub_packet_list_B[j].packet;
}
}
max = min;
/* check for errors (?) */
if (!packet)
return;
if (i == 0 &&
(packet->type < 16 || packet->type >= 48 ||
fft_subpackets[packet->type - 16]))
return;
/* decode FFT tones */
init_get_bits(&gb, packet->data, packet->size * 8);
if (packet->type >= 32 && packet->type < 48 && !fft_subpackets[packet->type - 16])
unknown_flag = 1;
else
unknown_flag = 0;
type = packet->type;
if ((type >= 17 && type < 24) || (type >= 33 && type < 40)) {
int duration = q->sub_sampling + 5 - (type & 15);
if (duration >= 0 && duration < 4)
qdm2_fft_decode_tones(q, duration, &gb, unknown_flag);
} else if (type == 31) {
for (j = 0; j < 4; j++)
qdm2_fft_decode_tones(q, j, &gb, unknown_flag);
} else if (type == 46) {
for (j = 0; j < 6; j++)
q->fft_level_exp[j] = get_bits(&gb, 6);
for (j = 0; j < 4; j++)
qdm2_fft_decode_tones(q, j, &gb, unknown_flag);
}
} // Loop on B packets
/* calculate maximum indexes for FFT coefficients */
for (i = 0, j = -1; i < 5; i++)
if (q->fft_coefs_min_index[i] >= 0) {
if (j >= 0)
q->fft_coefs_max_index[j] = q->fft_coefs_min_index[i];
j = i;
}
if (j >= 0)
q->fft_coefs_max_index[j] = q->fft_coefs_index;
}
| false | FFmpeg | f929ab0569ff31ed5a59b0b0adb7ce09df3fca39 | static void qdm2_decode_fft_packets(QDM2Context *q)
{
int i, j, min, max, value, type, unknown_flag;
GetBitContext gb;
if (q->sub_packet_list_B[0].packet == NULL)
return;
q->fft_coefs_index = 0;
for (i = 0; i < 5; i++)
q->fft_coefs_min_index[i] = -1;
for (i = 0, max = 256; i < q->sub_packets_B; i++) {
QDM2SubPacket *packet = NULL;
for (j = 0, min = 0; j < q->sub_packets_B; j++) {
value = q->sub_packet_list_B[j].packet->type;
if (value > min && value < max) {
min = value;
packet = q->sub_packet_list_B[j].packet;
}
}
max = min;
if (!packet)
return;
if (i == 0 &&
(packet->type < 16 || packet->type >= 48 ||
fft_subpackets[packet->type - 16]))
return;
init_get_bits(&gb, packet->data, packet->size * 8);
if (packet->type >= 32 && packet->type < 48 && !fft_subpackets[packet->type - 16])
unknown_flag = 1;
else
unknown_flag = 0;
type = packet->type;
if ((type >= 17 && type < 24) || (type >= 33 && type < 40)) {
int duration = q->sub_sampling + 5 - (type & 15);
if (duration >= 0 && duration < 4)
qdm2_fft_decode_tones(q, duration, &gb, unknown_flag);
} else if (type == 31) {
for (j = 0; j < 4; j++)
qdm2_fft_decode_tones(q, j, &gb, unknown_flag);
} else if (type == 46) {
for (j = 0; j < 6; j++)
q->fft_level_exp[j] = get_bits(&gb, 6);
for (j = 0; j < 4; j++)
qdm2_fft_decode_tones(q, j, &gb, unknown_flag);
}
}
for (i = 0, j = -1; i < 5; i++)
if (q->fft_coefs_min_index[i] >= 0) {
if (j >= 0)
q->fft_coefs_max_index[j] = q->fft_coefs_min_index[i];
j = i;
}
if (j >= 0)
q->fft_coefs_max_index[j] = q->fft_coefs_index;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(QDM2Context *VAR_0)
{
int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;
GetBitContext gb;
if (VAR_0->sub_packet_list_B[0].packet == NULL)
return;
VAR_0->fft_coefs_index = 0;
for (VAR_1 = 0; VAR_1 < 5; VAR_1++)
VAR_0->fft_coefs_min_index[VAR_1] = -1;
for (VAR_1 = 0, VAR_4 = 256; VAR_1 < VAR_0->sub_packets_B; VAR_1++) {
QDM2SubPacket *packet = NULL;
for (VAR_2 = 0, VAR_3 = 0; VAR_2 < VAR_0->sub_packets_B; VAR_2++) {
VAR_5 = VAR_0->sub_packet_list_B[VAR_2].packet->VAR_6;
if (VAR_5 > VAR_3 && VAR_5 < VAR_4) {
VAR_3 = VAR_5;
packet = VAR_0->sub_packet_list_B[VAR_2].packet;
}
}
VAR_4 = VAR_3;
if (!packet)
return;
if (VAR_1 == 0 &&
(packet->VAR_6 < 16 || packet->VAR_6 >= 48 ||
fft_subpackets[packet->VAR_6 - 16]))
return;
init_get_bits(&gb, packet->data, packet->size * 8);
if (packet->VAR_6 >= 32 && packet->VAR_6 < 48 && !fft_subpackets[packet->VAR_6 - 16])
VAR_7 = 1;
else
VAR_7 = 0;
VAR_6 = packet->VAR_6;
if ((VAR_6 >= 17 && VAR_6 < 24) || (VAR_6 >= 33 && VAR_6 < 40)) {
int duration = VAR_0->sub_sampling + 5 - (VAR_6 & 15);
if (duration >= 0 && duration < 4)
qdm2_fft_decode_tones(VAR_0, duration, &gb, VAR_7);
} else if (VAR_6 == 31) {
for (VAR_2 = 0; VAR_2 < 4; VAR_2++)
qdm2_fft_decode_tones(VAR_0, VAR_2, &gb, VAR_7);
} else if (VAR_6 == 46) {
for (VAR_2 = 0; VAR_2 < 6; VAR_2++)
VAR_0->fft_level_exp[VAR_2] = get_bits(&gb, 6);
for (VAR_2 = 0; VAR_2 < 4; VAR_2++)
qdm2_fft_decode_tones(VAR_0, VAR_2, &gb, VAR_7);
}
}
for (VAR_1 = 0, VAR_2 = -1; VAR_1 < 5; VAR_1++)
if (VAR_0->fft_coefs_min_index[VAR_1] >= 0) {
if (VAR_2 >= 0)
VAR_0->fft_coefs_max_index[VAR_2] = VAR_0->fft_coefs_min_index[VAR_1];
VAR_2 = VAR_1;
}
if (VAR_2 >= 0)
VAR_0->fft_coefs_max_index[VAR_2] = VAR_0->fft_coefs_index;
}
| [
"static void FUNC_0(QDM2Context *VAR_0)\n{",
"int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;",
"GetBitContext gb;",
"if (VAR_0->sub_packet_list_B[0].packet == NULL)\nreturn;",
"VAR_0->fft_coefs_index = 0;",
"for (VAR_1 = 0; VAR_1 < 5; VAR_1++)",
"VAR_0->fft_coefs_min_index[VAR_1] = -1;",
"for (VAR_1 = 0, VAR_4 = 256; VAR_1 < VAR_0->sub_packets_B; VAR_1++) {",
"QDM2SubPacket *packet = NULL;",
"for (VAR_2 = 0, VAR_3 = 0; VAR_2 < VAR_0->sub_packets_B; VAR_2++) {",
"VAR_5 = VAR_0->sub_packet_list_B[VAR_2].packet->VAR_6;",
"if (VAR_5 > VAR_3 && VAR_5 < VAR_4) {",
"VAR_3 = VAR_5;",
"packet = VAR_0->sub_packet_list_B[VAR_2].packet;",
"}",
"}",
"VAR_4 = VAR_3;",
"if (!packet)\nreturn;",
"if (VAR_1 == 0 &&\n(packet->VAR_6 < 16 || packet->VAR_6 >= 48 ||\nfft_subpackets[packet->VAR_6 - 16]))\nreturn;",
"init_get_bits(&gb, packet->data, packet->size * 8);",
"if (packet->VAR_6 >= 32 && packet->VAR_6 < 48 && !fft_subpackets[packet->VAR_6 - 16])\nVAR_7 = 1;",
"else\nVAR_7 = 0;",
"VAR_6 = packet->VAR_6;",
"if ((VAR_6 >= 17 && VAR_6 < 24) || (VAR_6 >= 33 && VAR_6 < 40)) {",
"int duration = VAR_0->sub_sampling + 5 - (VAR_6 & 15);",
"if (duration >= 0 && duration < 4)\nqdm2_fft_decode_tones(VAR_0, duration, &gb, VAR_7);",
"} else if (VAR_6 == 31) {",
"for (VAR_2 = 0; VAR_2 < 4; VAR_2++)",
"qdm2_fft_decode_tones(VAR_0, VAR_2, &gb, VAR_7);",
"} else if (VAR_6 == 46) {",
"for (VAR_2 = 0; VAR_2 < 6; VAR_2++)",
"VAR_0->fft_level_exp[VAR_2] = get_bits(&gb, 6);",
"for (VAR_2 = 0; VAR_2 < 4; VAR_2++)",
"qdm2_fft_decode_tones(VAR_0, VAR_2, &gb, VAR_7);",
"}",
"}",
"for (VAR_1 = 0, VAR_2 = -1; VAR_1 < 5; VAR_1++)",
"if (VAR_0->fft_coefs_min_index[VAR_1] >= 0) {",
"if (VAR_2 >= 0)\nVAR_0->fft_coefs_max_index[VAR_2] = VAR_0->fft_coefs_min_index[VAR_1];",
"VAR_2 = VAR_1;",
"}",
"if (VAR_2 >= 0)\nVAR_0->fft_coefs_max_index[VAR_2] = VAR_0->fft_coefs_index;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
19
],
[
21
],
[
23
],
[
29
],
[
31
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
59,
61
],
[
65,
67,
69,
71
],
[
77
],
[
81,
83
],
[
85,
87
],
[
91
],
[
95
],
[
97
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
129
],
[
131
],
[
133,
135
],
[
137
],
[
139
],
[
141,
143
],
[
145
]
] |
18,307 | void ff_avg_h264_qpel16_mc22_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_mid_and_aver_dst_16x16_msa(src - (2 * stride) - 2,
stride, dst, stride);
}
| false | FFmpeg | 1181d93231e9b807965724587d363c1cfd5a1d0d | void ff_avg_h264_qpel16_mc22_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_mid_and_aver_dst_16x16_msa(src - (2 * stride) - 2,
stride, dst, stride);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,
ptrdiff_t VAR_2)
{
avc_luma_mid_and_aver_dst_16x16_msa(VAR_1 - (2 * VAR_2) - 2,
VAR_2, VAR_0, VAR_2);
}
| [
"void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,\nptrdiff_t VAR_2)\n{",
"avc_luma_mid_and_aver_dst_16x16_msa(VAR_1 - (2 * VAR_2) - 2,\nVAR_2, VAR_0, VAR_2);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5
],
[
7,
9
],
[
11
]
] |
18,308 | int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name)
{
AVFilterContext *ret;
*filter_ctx = NULL;
if (!filter)
return AVERROR(EINVAL);
ret = av_mallocz(sizeof(AVFilterContext));
ret->av_class = &avfilter_class;
ret->filter = filter;
ret->name = inst_name ? av_strdup(inst_name) : NULL;
if (filter->priv_size)
ret->priv = av_mallocz(filter->priv_size);
ret->input_count = pad_count(filter->inputs);
if (ret->input_count) {
ret->input_pads = av_malloc(sizeof(AVFilterPad) * ret->input_count);
memcpy(ret->input_pads, filter->inputs, sizeof(AVFilterPad) * ret->input_count);
ret->inputs = av_mallocz(sizeof(AVFilterLink*) * ret->input_count);
}
ret->output_count = pad_count(filter->outputs);
if (ret->output_count) {
ret->output_pads = av_malloc(sizeof(AVFilterPad) * ret->output_count);
memcpy(ret->output_pads, filter->outputs, sizeof(AVFilterPad) * ret->output_count);
ret->outputs = av_mallocz(sizeof(AVFilterLink*) * ret->output_count);
}
*filter_ctx = ret;
return 0;
}
| false | FFmpeg | 0699dbb8478886826dedb1c33a0b74142a1cd863 | int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name)
{
AVFilterContext *ret;
*filter_ctx = NULL;
if (!filter)
return AVERROR(EINVAL);
ret = av_mallocz(sizeof(AVFilterContext));
ret->av_class = &avfilter_class;
ret->filter = filter;
ret->name = inst_name ? av_strdup(inst_name) : NULL;
if (filter->priv_size)
ret->priv = av_mallocz(filter->priv_size);
ret->input_count = pad_count(filter->inputs);
if (ret->input_count) {
ret->input_pads = av_malloc(sizeof(AVFilterPad) * ret->input_count);
memcpy(ret->input_pads, filter->inputs, sizeof(AVFilterPad) * ret->input_count);
ret->inputs = av_mallocz(sizeof(AVFilterLink*) * ret->input_count);
}
ret->output_count = pad_count(filter->outputs);
if (ret->output_count) {
ret->output_pads = av_malloc(sizeof(AVFilterPad) * ret->output_count);
memcpy(ret->output_pads, filter->outputs, sizeof(AVFilterPad) * ret->output_count);
ret->outputs = av_mallocz(sizeof(AVFilterLink*) * ret->output_count);
}
*filter_ctx = ret;
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVFilterContext **VAR_0, AVFilter *VAR_1, const char *VAR_2)
{
AVFilterContext *ret;
*VAR_0 = NULL;
if (!VAR_1)
return AVERROR(EINVAL);
ret = av_mallocz(sizeof(AVFilterContext));
ret->av_class = &avfilter_class;
ret->VAR_1 = VAR_1;
ret->name = VAR_2 ? av_strdup(VAR_2) : NULL;
if (VAR_1->priv_size)
ret->priv = av_mallocz(VAR_1->priv_size);
ret->input_count = pad_count(VAR_1->inputs);
if (ret->input_count) {
ret->input_pads = av_malloc(sizeof(AVFilterPad) * ret->input_count);
memcpy(ret->input_pads, VAR_1->inputs, sizeof(AVFilterPad) * ret->input_count);
ret->inputs = av_mallocz(sizeof(AVFilterLink*) * ret->input_count);
}
ret->output_count = pad_count(VAR_1->outputs);
if (ret->output_count) {
ret->output_pads = av_malloc(sizeof(AVFilterPad) * ret->output_count);
memcpy(ret->output_pads, VAR_1->outputs, sizeof(AVFilterPad) * ret->output_count);
ret->outputs = av_mallocz(sizeof(AVFilterLink*) * ret->output_count);
}
*VAR_0 = ret;
return 0;
}
| [
"int FUNC_0(AVFilterContext **VAR_0, AVFilter *VAR_1, const char *VAR_2)\n{",
"AVFilterContext *ret;",
"*VAR_0 = NULL;",
"if (!VAR_1)\nreturn AVERROR(EINVAL);",
"ret = av_mallocz(sizeof(AVFilterContext));",
"ret->av_class = &avfilter_class;",
"ret->VAR_1 = VAR_1;",
"ret->name = VAR_2 ? av_strdup(VAR_2) : NULL;",
"if (VAR_1->priv_size)\nret->priv = av_mallocz(VAR_1->priv_size);",
"ret->input_count = pad_count(VAR_1->inputs);",
"if (ret->input_count) {",
"ret->input_pads = av_malloc(sizeof(AVFilterPad) * ret->input_count);",
"memcpy(ret->input_pads, VAR_1->inputs, sizeof(AVFilterPad) * ret->input_count);",
"ret->inputs = av_mallocz(sizeof(AVFilterLink*) * ret->input_count);",
"}",
"ret->output_count = pad_count(VAR_1->outputs);",
"if (ret->output_count) {",
"ret->output_pads = av_malloc(sizeof(AVFilterPad) * ret->output_count);",
"memcpy(ret->output_pads, VAR_1->outputs, sizeof(AVFilterPad) * ret->output_count);",
"ret->outputs = av_mallocz(sizeof(AVFilterLink*) * ret->output_count);",
"}",
"*VAR_0 = ret;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
]
] |
18,309 | static void test_panic(void)
{
uint8_t val;
QDict *response, *data;
val = inb(0x505);
g_assert_cmpuint(val, ==, 1);
outb(0x505, 0x1);
response = qmp_receive();
g_assert(qdict_haskey(response, "event"));
g_assert_cmpstr(qdict_get_str(response, "event"), ==, "GUEST_PANICKED");
g_assert(qdict_haskey(response, "data"));
data = qdict_get_qdict(response, "data");
g_assert(qdict_haskey(data, "action"));
g_assert_cmpstr(qdict_get_str(data, "action"), ==, "pause");
} | true | qemu | dc491fead04a92a612df93b85b0ebf9dcc3f6684 | static void test_panic(void)
{
uint8_t val;
QDict *response, *data;
val = inb(0x505);
g_assert_cmpuint(val, ==, 1);
outb(0x505, 0x1);
response = qmp_receive();
g_assert(qdict_haskey(response, "event"));
g_assert_cmpstr(qdict_get_str(response, "event"), ==, "GUEST_PANICKED");
g_assert(qdict_haskey(response, "data"));
data = qdict_get_qdict(response, "data");
g_assert(qdict_haskey(data, "action"));
g_assert_cmpstr(qdict_get_str(data, "action"), ==, "pause");
} | {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
uint8_t val;
QDict *response, *data;
val = inb(0x505);
g_assert_cmpuint(val, ==, 1);
outb(0x505, 0x1);
response = qmp_receive();
g_assert(qdict_haskey(response, "event"));
g_assert_cmpstr(qdict_get_str(response, "event"), ==, "GUEST_PANICKED");
g_assert(qdict_haskey(response, "data"));
data = qdict_get_qdict(response, "data");
g_assert(qdict_haskey(data, "action"));
g_assert_cmpstr(qdict_get_str(data, "action"), ==, "pause");
} | [
"static void FUNC_0(void)\n{",
"uint8_t val;",
"QDict *response, *data;",
"val = inb(0x505);",
"g_assert_cmpuint(val, ==, 1);",
"outb(0x505, 0x1);",
"response = qmp_receive();",
"g_assert(qdict_haskey(response, \"event\"));",
"g_assert_cmpstr(qdict_get_str(response, \"event\"), ==, \"GUEST_PANICKED\");",
"g_assert(qdict_haskey(response, \"data\"));",
"data = qdict_get_qdict(response, \"data\");",
"g_assert(qdict_haskey(data, \"action\"));",
"g_assert_cmpstr(qdict_get_str(data, \"action\"), ==, \"pause\");",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
36
]
] |
18,310 | static void spr_write_decr(DisasContext *ctx, int sprn, int gprn)
{
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_store_decr(cpu_env, cpu_gpr[gprn]);
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_end();
gen_stop_exception(ctx);
}
}
| true | qemu | c5a49c63fa26e8825ad101dfe86339ae4c216539 | static void spr_write_decr(DisasContext *ctx, int sprn, int gprn)
{
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_store_decr(cpu_env, cpu_gpr[gprn]);
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_end();
gen_stop_exception(ctx);
}
}
| {
"code": [
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {"
],
"line_no": [
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
]
} | static void FUNC_0(DisasContext *VAR_0, int VAR_1, int VAR_2)
{
if (VAR_0->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_store_decr(cpu_env, cpu_gpr[VAR_2]);
if (VAR_0->tb->cflags & CF_USE_ICOUNT) {
gen_io_end();
gen_stop_exception(VAR_0);
}
}
| [
"static void FUNC_0(DisasContext *VAR_0, int VAR_1, int VAR_2)\n{",
"if (VAR_0->tb->cflags & CF_USE_ICOUNT) {",
"gen_io_start();",
"}",
"gen_helper_store_decr(cpu_env, cpu_gpr[VAR_2]);",
"if (VAR_0->tb->cflags & CF_USE_ICOUNT) {",
"gen_io_end();",
"gen_stop_exception(VAR_0);",
"}",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
18,312 | PPC_OP(b_T1)
{
regs->nip = T1 & ~3;
RETURN();
}
| true | qemu | d9bce9d99f4656ae0b0127f7472db9067b8f84ab | PPC_OP(b_T1)
{
regs->nip = T1 & ~3;
RETURN();
}
| {
"code": [
"PPC_OP(b_T1)",
" regs->nip = T1 & ~3;",
" RETURN();",
" RETURN();"
],
"line_no": [
1,
5,
7,
7
]
} | FUNC_0(VAR_0)
{
regs->nip = T1 & ~3;
RETURN();
}
| [
"FUNC_0(VAR_0)\n{",
"regs->nip = T1 & ~3;",
"RETURN();",
"}"
] | [
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
18,313 | static int make_cdt15_entry(int p1, int p2, int16_t *cdt)
{
int r, b, lo;
b = cdt[p2];
r = cdt[p1] * 1024;
lo = b + r;
return (lo + (lo * (1 << 16))) * 2;
}
| true | FFmpeg | e45226adc46e513a1bb39ec2b09fb7c77515ab14 | static int make_cdt15_entry(int p1, int p2, int16_t *cdt)
{
int r, b, lo;
b = cdt[p2];
r = cdt[p1] * 1024;
lo = b + r;
return (lo + (lo * (1 << 16))) * 2;
}
| {
"code": [
" return (lo + (lo * (1 << 16))) * 2;"
],
"line_no": [
15
]
} | static int FUNC_0(int VAR_0, int VAR_1, int16_t *VAR_2)
{
int VAR_3, VAR_4, VAR_5;
VAR_4 = VAR_2[VAR_1];
VAR_3 = VAR_2[VAR_0] * 1024;
VAR_5 = VAR_4 + VAR_3;
return (VAR_5 + (VAR_5 * (1 << 16))) * 2;
}
| [
"static int FUNC_0(int VAR_0, int VAR_1, int16_t *VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5;",
"VAR_4 = VAR_2[VAR_1];",
"VAR_3 = VAR_2[VAR_0] * 1024;",
"VAR_5 = VAR_4 + VAR_3;",
"return (VAR_5 + (VAR_5 * (1 << 16))) * 2;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
18,314 | static int ogg_build_flac_headers(AVCodecContext *avctx,
OGGStreamContext *oggstream, int bitexact)
{
const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
enum FLACExtradataFormat format;
uint8_t *streaminfo;
uint8_t *p;
if (!ff_flac_is_extradata_valid(avctx, &format, &streaminfo))
return -1;
oggstream->header_len[0] = 51;
oggstream->header[0] = av_mallocz(51); // per ogg flac specs
p = oggstream->header[0];
bytestream_put_byte(&p, 0x7F);
bytestream_put_buffer(&p, "FLAC", 4);
bytestream_put_byte(&p, 1); // major version
bytestream_put_byte(&p, 0); // minor version
bytestream_put_be16(&p, 1); // headers packets without this one
bytestream_put_buffer(&p, "fLaC", 4);
bytestream_put_byte(&p, 0x00); // streaminfo
bytestream_put_be24(&p, 34);
bytestream_put_buffer(&p, streaminfo, FLAC_STREAMINFO_SIZE);
oggstream->header_len[1] = 1+3+4+strlen(vendor)+4;
oggstream->header[1] = av_mallocz(oggstream->header_len[1]);
p = oggstream->header[1];
bytestream_put_byte(&p, 0x84); // last metadata block and vorbis comment
bytestream_put_be24(&p, oggstream->header_len[1] - 4);
bytestream_put_le32(&p, strlen(vendor));
bytestream_put_buffer(&p, vendor, strlen(vendor));
bytestream_put_le32(&p, 0); // user comment list length
return 0;
} | true | FFmpeg | e9a32230c3e05deff257cbfa1e5e3d86dc0e94e6 | static int ogg_build_flac_headers(AVCodecContext *avctx,
OGGStreamContext *oggstream, int bitexact)
{
const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
enum FLACExtradataFormat format;
uint8_t *streaminfo;
uint8_t *p;
if (!ff_flac_is_extradata_valid(avctx, &format, &streaminfo))
return -1;
oggstream->header_len[0] = 51;
oggstream->header[0] = av_mallocz(51);
p = oggstream->header[0];
bytestream_put_byte(&p, 0x7F);
bytestream_put_buffer(&p, "FLAC", 4);
bytestream_put_byte(&p, 1);
bytestream_put_byte(&p, 0);
bytestream_put_be16(&p, 1);
bytestream_put_buffer(&p, "fLaC", 4);
bytestream_put_byte(&p, 0x00);
bytestream_put_be24(&p, 34);
bytestream_put_buffer(&p, streaminfo, FLAC_STREAMINFO_SIZE);
oggstream->header_len[1] = 1+3+4+strlen(vendor)+4;
oggstream->header[1] = av_mallocz(oggstream->header_len[1]);
p = oggstream->header[1];
bytestream_put_byte(&p, 0x84);
bytestream_put_be24(&p, oggstream->header_len[1] - 4);
bytestream_put_le32(&p, strlen(vendor));
bytestream_put_buffer(&p, vendor, strlen(vendor));
bytestream_put_le32(&p, 0);
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
OGGStreamContext *VAR_1, int VAR_2)
{
const char *VAR_3 = VAR_2 ? "ffmpeg" : LIBAVFORMAT_IDENT;
enum FLACExtradataFormat VAR_4;
uint8_t *streaminfo;
uint8_t *p;
if (!ff_flac_is_extradata_valid(VAR_0, &VAR_4, &streaminfo))
return -1;
VAR_1->header_len[0] = 51;
VAR_1->header[0] = av_mallocz(51);
p = VAR_1->header[0];
bytestream_put_byte(&p, 0x7F);
bytestream_put_buffer(&p, "FLAC", 4);
bytestream_put_byte(&p, 1);
bytestream_put_byte(&p, 0);
bytestream_put_be16(&p, 1);
bytestream_put_buffer(&p, "fLaC", 4);
bytestream_put_byte(&p, 0x00);
bytestream_put_be24(&p, 34);
bytestream_put_buffer(&p, streaminfo, FLAC_STREAMINFO_SIZE);
VAR_1->header_len[1] = 1+3+4+strlen(VAR_3)+4;
VAR_1->header[1] = av_mallocz(VAR_1->header_len[1]);
p = VAR_1->header[1];
bytestream_put_byte(&p, 0x84);
bytestream_put_be24(&p, VAR_1->header_len[1] - 4);
bytestream_put_le32(&p, strlen(VAR_3));
bytestream_put_buffer(&p, VAR_3, strlen(VAR_3));
bytestream_put_le32(&p, 0);
return 0;
} | [
"static int FUNC_0(AVCodecContext *VAR_0,\nOGGStreamContext *VAR_1, int VAR_2)\n{",
"const char *VAR_3 = VAR_2 ? \"ffmpeg\" : LIBAVFORMAT_IDENT;",
"enum FLACExtradataFormat VAR_4;",
"uint8_t *streaminfo;",
"uint8_t *p;",
"if (!ff_flac_is_extradata_valid(VAR_0, &VAR_4, &streaminfo))\nreturn -1;",
"VAR_1->header_len[0] = 51;",
"VAR_1->header[0] = av_mallocz(51);",
"p = VAR_1->header[0];",
"bytestream_put_byte(&p, 0x7F);",
"bytestream_put_buffer(&p, \"FLAC\", 4);",
"bytestream_put_byte(&p, 1);",
"bytestream_put_byte(&p, 0);",
"bytestream_put_be16(&p, 1);",
"bytestream_put_buffer(&p, \"fLaC\", 4);",
"bytestream_put_byte(&p, 0x00);",
"bytestream_put_be24(&p, 34);",
"bytestream_put_buffer(&p, streaminfo, FLAC_STREAMINFO_SIZE);",
"VAR_1->header_len[1] = 1+3+4+strlen(VAR_3)+4;",
"VAR_1->header[1] = av_mallocz(VAR_1->header_len[1]);",
"p = VAR_1->header[1];",
"bytestream_put_byte(&p, 0x84);",
"bytestream_put_be24(&p, VAR_1->header_len[1] - 4);",
"bytestream_put_le32(&p, strlen(VAR_3));",
"bytestream_put_buffer(&p, VAR_3, strlen(VAR_3));",
"bytestream_put_le32(&p, 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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
]
] |
18,315 | void qmp_netdev_del(const char *id, Error **errp)
{
NetClientState *nc;
nc = qemu_find_netdev(id);
if (!nc) {
error_set(errp, QERR_DEVICE_NOT_FOUND, id);
return;
}
qemu_del_net_client(nc);
qemu_opts_del(qemu_opts_find(qemu_find_opts_err("netdev", errp), id));
}
| true | qemu | 645c9496f7083c105ecd32f32532496af6aadf62 | void qmp_netdev_del(const char *id, Error **errp)
{
NetClientState *nc;
nc = qemu_find_netdev(id);
if (!nc) {
error_set(errp, QERR_DEVICE_NOT_FOUND, id);
return;
}
qemu_del_net_client(nc);
qemu_opts_del(qemu_opts_find(qemu_find_opts_err("netdev", errp), id));
}
| {
"code": [
" qemu_opts_del(qemu_opts_find(qemu_find_opts_err(\"netdev\", errp), id));"
],
"line_no": [
23
]
} | void FUNC_0(const char *VAR_0, Error **VAR_1)
{
NetClientState *nc;
nc = qemu_find_netdev(VAR_0);
if (!nc) {
error_set(VAR_1, QERR_DEVICE_NOT_FOUND, VAR_0);
return;
}
qemu_del_net_client(nc);
qemu_opts_del(qemu_opts_find(qemu_find_opts_err("netdev", VAR_1), VAR_0));
}
| [
"void FUNC_0(const char *VAR_0, Error **VAR_1)\n{",
"NetClientState *nc;",
"nc = qemu_find_netdev(VAR_0);",
"if (!nc) {",
"error_set(VAR_1, QERR_DEVICE_NOT_FOUND, VAR_0);",
"return;",
"}",
"qemu_del_net_client(nc);",
"qemu_opts_del(qemu_opts_find(qemu_find_opts_err(\"netdev\", VAR_1), VAR_0));",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
]
] |
18,316 | int qemu_savevm_state_iterate(QEMUFile *f)
{
SaveStateEntry *se;
int ret = 1;
trace_savevm_state_iterate();
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
if (!se->ops || !se->ops->save_live_iterate) {
continue;
}
if (se->ops && se->ops->is_active) {
if (!se->ops->is_active(se->opaque)) {
continue;
}
}
if (qemu_file_rate_limit(f)) {
return 0;
}
trace_savevm_section_start(se->idstr, se->section_id);
save_section_header(f, se, QEMU_VM_SECTION_PART);
ret = se->ops->save_live_iterate(f, se->opaque);
trace_savevm_section_end(se->idstr, se->section_id, ret);
if (ret < 0) {
qemu_file_set_error(f, ret);
}
if (ret <= 0) {
/* Do not proceed to the next vmstate before this one reported
completion of the current stage. This serializes the migration
and reduces the probability that a faster changing state is
synchronized over and over again. */
break;
}
}
return ret;
} | true | qemu | f68945d42bab700d95b87f62e0898606ce2421ed | int qemu_savevm_state_iterate(QEMUFile *f)
{
SaveStateEntry *se;
int ret = 1;
trace_savevm_state_iterate();
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
if (!se->ops || !se->ops->save_live_iterate) {
continue;
}
if (se->ops && se->ops->is_active) {
if (!se->ops->is_active(se->opaque)) {
continue;
}
}
if (qemu_file_rate_limit(f)) {
return 0;
}
trace_savevm_section_start(se->idstr, se->section_id);
save_section_header(f, se, QEMU_VM_SECTION_PART);
ret = se->ops->save_live_iterate(f, se->opaque);
trace_savevm_section_end(se->idstr, se->section_id, ret);
if (ret < 0) {
qemu_file_set_error(f, ret);
}
if (ret <= 0) {
break;
}
}
return ret;
} | {
"code": [],
"line_no": []
} | int FUNC_0(QEMUFile *VAR_0)
{
SaveStateEntry *se;
int VAR_1 = 1;
trace_savevm_state_iterate();
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
if (!se->ops || !se->ops->save_live_iterate) {
continue;
}
if (se->ops && se->ops->is_active) {
if (!se->ops->is_active(se->opaque)) {
continue;
}
}
if (qemu_file_rate_limit(VAR_0)) {
return 0;
}
trace_savevm_section_start(se->idstr, se->section_id);
save_section_header(VAR_0, se, QEMU_VM_SECTION_PART);
VAR_1 = se->ops->save_live_iterate(VAR_0, se->opaque);
trace_savevm_section_end(se->idstr, se->section_id, VAR_1);
if (VAR_1 < 0) {
qemu_file_set_error(VAR_0, VAR_1);
}
if (VAR_1 <= 0) {
break;
}
}
return VAR_1;
} | [
"int FUNC_0(QEMUFile *VAR_0)\n{",
"SaveStateEntry *se;",
"int VAR_1 = 1;",
"trace_savevm_state_iterate();",
"QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {",
"if (!se->ops || !se->ops->save_live_iterate) {",
"continue;",
"}",
"if (se->ops && se->ops->is_active) {",
"if (!se->ops->is_active(se->opaque)) {",
"continue;",
"}",
"}",
"if (qemu_file_rate_limit(VAR_0)) {",
"return 0;",
"}",
"trace_savevm_section_start(se->idstr, se->section_id);",
"save_section_header(VAR_0, se, QEMU_VM_SECTION_PART);",
"VAR_1 = se->ops->save_live_iterate(VAR_0, se->opaque);",
"trace_savevm_section_end(se->idstr, se->section_id, VAR_1);",
"if (VAR_1 < 0) {",
"qemu_file_set_error(VAR_0, VAR_1);",
"}",
"if (VAR_1 <= 0) {",
"break;",
"}",
"}",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45
],
[
47
],
[
52
],
[
54
],
[
56
],
[
58
],
[
68
],
[
70
],
[
72
],
[
74
],
[
76
]
] |
18,317 | yuv2rgba64_2_c_template(SwsContext *c, const int32_t *buf[2],
const int32_t *ubuf[2], const int32_t *vbuf[2],
const int32_t *abuf[2], uint16_t *dest, int dstW,
int yalpha, int uvalpha, int y,
enum AVPixelFormat target, int hasAlpha)
{
const int32_t *buf0 = buf[0], *buf1 = buf[1],
*ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
*vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
*abuf0 = hasAlpha ? abuf[0] : NULL,
*abuf1 = hasAlpha ? abuf[1] : NULL;
int yalpha1 = 4096 - yalpha;
int uvalpha1 = 4096 - uvalpha;
int i;
for (i = 0; i < ((dstW + 1) >> 1); i++) {
int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 14;
int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 14;
int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha + (-128 << 23)) >> 14;
int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha + (-128 << 23)) >> 14;
int A1, A2;
int R, G, B;
Y1 -= c->yuv2rgb_y_offset;
Y2 -= c->yuv2rgb_y_offset;
Y1 *= c->yuv2rgb_y_coeff;
Y2 *= c->yuv2rgb_y_coeff;
Y1 += 1 << 13;
Y2 += 1 << 13;
R = V * c->yuv2rgb_v2r_coeff;
G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
B = U * c->yuv2rgb_u2b_coeff;
if (hasAlpha) {
A1 = (abuf0[i * 2 ] * yalpha1 + abuf1[i * 2 ] * yalpha) >> 1;
A2 = (abuf0[i * 2 + 1] * yalpha1 + abuf1[i * 2 + 1] * yalpha) >> 1;
A1 += 1 << 13;
A2 += 1 << 13;
}
output_pixel(&dest[0], av_clip_uintp2(B_R + Y1, 30) >> 14);
output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
output_pixel(&dest[2], av_clip_uintp2(R_B + Y1, 30) >> 14);
output_pixel(&dest[3], av_clip_uintp2(A1 , 30) >> 14);
output_pixel(&dest[4], av_clip_uintp2(B_R + Y2, 30) >> 14);
output_pixel(&dest[5], av_clip_uintp2( G + Y2, 30) >> 14);
output_pixel(&dest[6], av_clip_uintp2(R_B + Y2, 30) >> 14);
output_pixel(&dest[7], av_clip_uintp2(A2 , 30) >> 14);
dest += 8;
}
}
| true | FFmpeg | e751481cd82d610cf93c6104a41396bd6338d073 | yuv2rgba64_2_c_template(SwsContext *c, const int32_t *buf[2],
const int32_t *ubuf[2], const int32_t *vbuf[2],
const int32_t *abuf[2], uint16_t *dest, int dstW,
int yalpha, int uvalpha, int y,
enum AVPixelFormat target, int hasAlpha)
{
const int32_t *buf0 = buf[0], *buf1 = buf[1],
*ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
*vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
*abuf0 = hasAlpha ? abuf[0] : NULL,
*abuf1 = hasAlpha ? abuf[1] : NULL;
int yalpha1 = 4096 - yalpha;
int uvalpha1 = 4096 - uvalpha;
int i;
for (i = 0; i < ((dstW + 1) >> 1); i++) {
int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 14;
int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 14;
int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha + (-128 << 23)) >> 14;
int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha + (-128 << 23)) >> 14;
int A1, A2;
int R, G, B;
Y1 -= c->yuv2rgb_y_offset;
Y2 -= c->yuv2rgb_y_offset;
Y1 *= c->yuv2rgb_y_coeff;
Y2 *= c->yuv2rgb_y_coeff;
Y1 += 1 << 13;
Y2 += 1 << 13;
R = V * c->yuv2rgb_v2r_coeff;
G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
B = U * c->yuv2rgb_u2b_coeff;
if (hasAlpha) {
A1 = (abuf0[i * 2 ] * yalpha1 + abuf1[i * 2 ] * yalpha) >> 1;
A2 = (abuf0[i * 2 + 1] * yalpha1 + abuf1[i * 2 + 1] * yalpha) >> 1;
A1 += 1 << 13;
A2 += 1 << 13;
}
output_pixel(&dest[0], av_clip_uintp2(B_R + Y1, 30) >> 14);
output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
output_pixel(&dest[2], av_clip_uintp2(R_B + Y1, 30) >> 14);
output_pixel(&dest[3], av_clip_uintp2(A1 , 30) >> 14);
output_pixel(&dest[4], av_clip_uintp2(B_R + Y2, 30) >> 14);
output_pixel(&dest[5], av_clip_uintp2( G + Y2, 30) >> 14);
output_pixel(&dest[6], av_clip_uintp2(R_B + Y2, 30) >> 14);
output_pixel(&dest[7], av_clip_uintp2(A2 , 30) >> 14);
dest += 8;
}
}
| {
"code": [
" int A1, A2;"
],
"line_no": [
41
]
} | FUNC_0(SwsContext *VAR_0, const int32_t *VAR_1[2],
const int32_t *VAR_2[2], const int32_t *VAR_3[2],
const int32_t *VAR_4[2], uint16_t *VAR_5, int VAR_6,
int VAR_7, int VAR_8, int VAR_9,
enum AVPixelFormat VAR_10, int VAR_11)
{
const int32_t *VAR_12 = VAR_1[0], *buf1 = VAR_1[1],
*ubuf0 = VAR_2[0], *ubuf1 = VAR_2[1],
*vbuf0 = VAR_3[0], *vbuf1 = VAR_3[1],
*abuf0 = VAR_11 ? VAR_4[0] : NULL,
*abuf1 = VAR_11 ? VAR_4[1] : NULL;
int VAR_13 = 4096 - VAR_7;
int VAR_14 = 4096 - VAR_8;
int VAR_15;
for (VAR_15 = 0; VAR_15 < ((VAR_6 + 1) >> 1); VAR_15++) {
int VAR_16 = (VAR_12[VAR_15 * 2] * VAR_13 + buf1[VAR_15 * 2] * VAR_7) >> 14;
int VAR_17 = (VAR_12[VAR_15 * 2 + 1] * VAR_13 + buf1[VAR_15 * 2 + 1] * VAR_7) >> 14;
int VAR_18 = (ubuf0[VAR_15] * VAR_14 + ubuf1[VAR_15] * VAR_8 + (-128 << 23)) >> 14;
int VAR_19 = (vbuf0[VAR_15] * VAR_14 + vbuf1[VAR_15] * VAR_8 + (-128 << 23)) >> 14;
int VAR_20, VAR_21;
int VAR_22, VAR_23, VAR_24;
VAR_16 -= VAR_0->yuv2rgb_y_offset;
VAR_17 -= VAR_0->yuv2rgb_y_offset;
VAR_16 *= VAR_0->yuv2rgb_y_coeff;
VAR_17 *= VAR_0->yuv2rgb_y_coeff;
VAR_16 += 1 << 13;
VAR_17 += 1 << 13;
VAR_22 = VAR_19 * VAR_0->yuv2rgb_v2r_coeff;
VAR_23 = VAR_19 * VAR_0->yuv2rgb_v2g_coeff + VAR_18 * VAR_0->yuv2rgb_u2g_coeff;
VAR_24 = VAR_18 * VAR_0->yuv2rgb_u2b_coeff;
if (VAR_11) {
VAR_20 = (abuf0[VAR_15 * 2 ] * VAR_13 + abuf1[VAR_15 * 2 ] * VAR_7) >> 1;
VAR_21 = (abuf0[VAR_15 * 2 + 1] * VAR_13 + abuf1[VAR_15 * 2 + 1] * VAR_7) >> 1;
VAR_20 += 1 << 13;
VAR_21 += 1 << 13;
}
output_pixel(&VAR_5[0], av_clip_uintp2(B_R + VAR_16, 30) >> 14);
output_pixel(&VAR_5[1], av_clip_uintp2( VAR_23 + VAR_16, 30) >> 14);
output_pixel(&VAR_5[2], av_clip_uintp2(R_B + VAR_16, 30) >> 14);
output_pixel(&VAR_5[3], av_clip_uintp2(VAR_20 , 30) >> 14);
output_pixel(&VAR_5[4], av_clip_uintp2(B_R + VAR_17, 30) >> 14);
output_pixel(&VAR_5[5], av_clip_uintp2( VAR_23 + VAR_17, 30) >> 14);
output_pixel(&VAR_5[6], av_clip_uintp2(R_B + VAR_17, 30) >> 14);
output_pixel(&VAR_5[7], av_clip_uintp2(VAR_21 , 30) >> 14);
VAR_5 += 8;
}
}
| [
"FUNC_0(SwsContext *VAR_0, const int32_t *VAR_1[2],\nconst int32_t *VAR_2[2], const int32_t *VAR_3[2],\nconst int32_t *VAR_4[2], uint16_t *VAR_5, int VAR_6,\nint VAR_7, int VAR_8, int VAR_9,\nenum AVPixelFormat VAR_10, int VAR_11)\n{",
"const int32_t *VAR_12 = VAR_1[0], *buf1 = VAR_1[1],\n*ubuf0 = VAR_2[0], *ubuf1 = VAR_2[1],\n*vbuf0 = VAR_3[0], *vbuf1 = VAR_3[1],\n*abuf0 = VAR_11 ? VAR_4[0] : NULL,\n*abuf1 = VAR_11 ? VAR_4[1] : NULL;",
"int VAR_13 = 4096 - VAR_7;",
"int VAR_14 = 4096 - VAR_8;",
"int VAR_15;",
"for (VAR_15 = 0; VAR_15 < ((VAR_6 + 1) >> 1); VAR_15++) {",
"int VAR_16 = (VAR_12[VAR_15 * 2] * VAR_13 + buf1[VAR_15 * 2] * VAR_7) >> 14;",
"int VAR_17 = (VAR_12[VAR_15 * 2 + 1] * VAR_13 + buf1[VAR_15 * 2 + 1] * VAR_7) >> 14;",
"int VAR_18 = (ubuf0[VAR_15] * VAR_14 + ubuf1[VAR_15] * VAR_8 + (-128 << 23)) >> 14;",
"int VAR_19 = (vbuf0[VAR_15] * VAR_14 + vbuf1[VAR_15] * VAR_8 + (-128 << 23)) >> 14;",
"int VAR_20, VAR_21;",
"int VAR_22, VAR_23, VAR_24;",
"VAR_16 -= VAR_0->yuv2rgb_y_offset;",
"VAR_17 -= VAR_0->yuv2rgb_y_offset;",
"VAR_16 *= VAR_0->yuv2rgb_y_coeff;",
"VAR_17 *= VAR_0->yuv2rgb_y_coeff;",
"VAR_16 += 1 << 13;",
"VAR_17 += 1 << 13;",
"VAR_22 = VAR_19 * VAR_0->yuv2rgb_v2r_coeff;",
"VAR_23 = VAR_19 * VAR_0->yuv2rgb_v2g_coeff + VAR_18 * VAR_0->yuv2rgb_u2g_coeff;",
"VAR_24 = VAR_18 * VAR_0->yuv2rgb_u2b_coeff;",
"if (VAR_11) {",
"VAR_20 = (abuf0[VAR_15 * 2 ] * VAR_13 + abuf1[VAR_15 * 2 ] * VAR_7) >> 1;",
"VAR_21 = (abuf0[VAR_15 * 2 + 1] * VAR_13 + abuf1[VAR_15 * 2 + 1] * VAR_7) >> 1;",
"VAR_20 += 1 << 13;",
"VAR_21 += 1 << 13;",
"}",
"output_pixel(&VAR_5[0], av_clip_uintp2(B_R + VAR_16, 30) >> 14);",
"output_pixel(&VAR_5[1], av_clip_uintp2( VAR_23 + VAR_16, 30) >> 14);",
"output_pixel(&VAR_5[2], av_clip_uintp2(R_B + VAR_16, 30) >> 14);",
"output_pixel(&VAR_5[3], av_clip_uintp2(VAR_20 , 30) >> 14);",
"output_pixel(&VAR_5[4], av_clip_uintp2(B_R + VAR_17, 30) >> 14);",
"output_pixel(&VAR_5[5], av_clip_uintp2( VAR_23 + VAR_17, 30) >> 14);",
"output_pixel(&VAR_5[6], av_clip_uintp2(R_B + VAR_17, 30) >> 14);",
"output_pixel(&VAR_5[7], av_clip_uintp2(VAR_21 , 30) >> 14);",
"VAR_5 += 8;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11
],
[
13,
15,
17,
19,
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
]
] |
18,318 | static int ogg_restore(AVFormatContext *s)
{
struct ogg *ogg = s->priv_data;
AVIOContext *bc = s->pb;
struct ogg_state *ost = ogg->state;
int i, err;
if (!ost)
return 0;
ogg->state = ost->next;
for (i = 0; i < ogg->nstreams; i++)
av_freep(&ogg->streams[i].buf);
avio_seek(bc, ost->pos, SEEK_SET);
ogg->page_pos = -1;
ogg->curidx = ost->curidx;
ogg->nstreams = ost->nstreams;
if ((err = av_reallocp_array(&ogg->streams, ogg->nstreams,
sizeof(*ogg->streams))) < 0) {
ogg->nstreams = 0;
return err;
} else
memcpy(ogg->streams, ost->streams,
ost->nstreams * sizeof(*ogg->streams));
av_free(ost);
return 0;
}
| true | FFmpeg | e46ab997506e8aa84344c29553ebacca7993904c | static int ogg_restore(AVFormatContext *s)
{
struct ogg *ogg = s->priv_data;
AVIOContext *bc = s->pb;
struct ogg_state *ost = ogg->state;
int i, err;
if (!ost)
return 0;
ogg->state = ost->next;
for (i = 0; i < ogg->nstreams; i++)
av_freep(&ogg->streams[i].buf);
avio_seek(bc, ost->pos, SEEK_SET);
ogg->page_pos = -1;
ogg->curidx = ost->curidx;
ogg->nstreams = ost->nstreams;
if ((err = av_reallocp_array(&ogg->streams, ogg->nstreams,
sizeof(*ogg->streams))) < 0) {
ogg->nstreams = 0;
return err;
} else
memcpy(ogg->streams, ost->streams,
ost->nstreams * sizeof(*ogg->streams));
av_free(ost);
return 0;
}
| {
"code": [
" for (i = 0; i < ogg->nstreams; i++)"
],
"line_no": [
25
]
} | static int FUNC_0(AVFormatContext *VAR_0)
{
struct VAR_1 *VAR_1 = VAR_0->priv_data;
AVIOContext *bc = VAR_0->pb;
struct ogg_state *VAR_2 = VAR_1->state;
int VAR_3, VAR_4;
if (!VAR_2)
return 0;
VAR_1->state = VAR_2->next;
for (VAR_3 = 0; VAR_3 < VAR_1->nstreams; VAR_3++)
av_freep(&VAR_1->streams[VAR_3].buf);
avio_seek(bc, VAR_2->pos, SEEK_SET);
VAR_1->page_pos = -1;
VAR_1->curidx = VAR_2->curidx;
VAR_1->nstreams = VAR_2->nstreams;
if ((VAR_4 = av_reallocp_array(&VAR_1->streams, VAR_1->nstreams,
sizeof(*VAR_1->streams))) < 0) {
VAR_1->nstreams = 0;
return VAR_4;
} else
memcpy(VAR_1->streams, VAR_2->streams,
VAR_2->nstreams * sizeof(*VAR_1->streams));
av_free(VAR_2);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"struct VAR_1 *VAR_1 = VAR_0->priv_data;",
"AVIOContext *bc = VAR_0->pb;",
"struct ogg_state *VAR_2 = VAR_1->state;",
"int VAR_3, VAR_4;",
"if (!VAR_2)\nreturn 0;",
"VAR_1->state = VAR_2->next;",
"for (VAR_3 = 0; VAR_3 < VAR_1->nstreams; VAR_3++)",
"av_freep(&VAR_1->streams[VAR_3].buf);",
"avio_seek(bc, VAR_2->pos, SEEK_SET);",
"VAR_1->page_pos = -1;",
"VAR_1->curidx = VAR_2->curidx;",
"VAR_1->nstreams = VAR_2->nstreams;",
"if ((VAR_4 = av_reallocp_array(&VAR_1->streams, VAR_1->nstreams,\nsizeof(*VAR_1->streams))) < 0) {",
"VAR_1->nstreams = 0;",
"return VAR_4;",
"} else",
"memcpy(VAR_1->streams, VAR_2->streams,\nVAR_2->nstreams * sizeof(*VAR_1->streams));",
"av_free(VAR_2);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
55
],
[
59
],
[
61
]
] |
18,319 | static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx,
DECODER_BUFFER_DESC *bs,
DECODER_BUFFER_DESC *sc)
{
const H264Context *h = avctx->priv_data;
const unsigned mb_count = h->mb_width * h->mb_height;
AVDXVAContext *ctx = avctx->hwaccel_context;
const H264Picture *current_picture = h->cur_pic_ptr;
struct dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private;
DXVA_Slice_H264_Short *slice = NULL;
void *dxva_data_ptr;
uint8_t *dxva_data, *current, *end;
unsigned dxva_size;
void *slice_data;
unsigned slice_size;
unsigned padding;
unsigned i;
unsigned type;
/* Create an annex B bitstream buffer with only slice NAL and finalize slice */
#if CONFIG_D3D11VA
if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) {
type = D3D11_VIDEO_DECODER_BUFFER_BITSTREAM;
if (FAILED(ID3D11VideoContext_GetDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context,
D3D11VA_CONTEXT(ctx)->decoder,
type,
&dxva_size, &dxva_data_ptr)))
return -1;
}
#endif
#if CONFIG_DXVA2
if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
type = DXVA2_BitStreamDateBufferType;
if (FAILED(IDirectXVideoDecoder_GetBuffer(DXVA2_CONTEXT(ctx)->decoder,
type,
&dxva_data_ptr, &dxva_size)))
return -1;
}
#endif
dxva_data = dxva_data_ptr;
current = dxva_data;
end = dxva_data + dxva_size;
for (i = 0; i < ctx_pic->slice_count; i++) {
static const uint8_t start_code[] = { 0, 0, 1 };
static const unsigned start_code_size = sizeof(start_code);
unsigned position, size;
assert(offsetof(DXVA_Slice_H264_Short, BSNALunitDataLocation) ==
offsetof(DXVA_Slice_H264_Long, BSNALunitDataLocation));
assert(offsetof(DXVA_Slice_H264_Short, SliceBytesInBuffer) ==
offsetof(DXVA_Slice_H264_Long, SliceBytesInBuffer));
if (is_slice_short(avctx, ctx))
slice = &ctx_pic->slice_short[i];
else
slice = (DXVA_Slice_H264_Short*)&ctx_pic->slice_long[i];
position = slice->BSNALunitDataLocation;
size = slice->SliceBytesInBuffer;
if (start_code_size + size > end - current) {
av_log(avctx, AV_LOG_ERROR, "Failed to build bitstream");
break;
}
slice->BSNALunitDataLocation = current - dxva_data;
slice->SliceBytesInBuffer = start_code_size + size;
if (!is_slice_short(avctx, ctx)) {
DXVA_Slice_H264_Long *slice_long = (DXVA_Slice_H264_Long*)slice;
if (i < ctx_pic->slice_count - 1)
slice_long->NumMbsForSlice =
slice_long[1].first_mb_in_slice - slice_long[0].first_mb_in_slice;
else
slice_long->NumMbsForSlice = mb_count - slice_long->first_mb_in_slice;
}
memcpy(current, start_code, start_code_size);
current += start_code_size;
memcpy(current, &ctx_pic->bitstream[position], size);
current += size;
}
padding = FFMIN(128 - ((current - dxva_data) & 127), end - current);
if (slice && padding > 0) {
memset(current, 0, padding);
current += padding;
slice->SliceBytesInBuffer += padding;
}
#if CONFIG_D3D11VA
if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD)
if (FAILED(ID3D11VideoContext_ReleaseDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, type)))
return -1;
#endif
#if CONFIG_DXVA2
if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
if (FAILED(IDirectXVideoDecoder_ReleaseBuffer(DXVA2_CONTEXT(ctx)->decoder, type)))
return -1;
#endif
if (i < ctx_pic->slice_count)
return -1;
#if CONFIG_D3D11VA
if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) {
D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = bs;
memset(dsc11, 0, sizeof(*dsc11));
dsc11->BufferType = type;
dsc11->DataSize = current - dxva_data;
dsc11->NumMBsInBuffer = mb_count;
type = D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL;
}
#endif
#if CONFIG_DXVA2
if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
DXVA2_DecodeBufferDesc *dsc2 = bs;
memset(dsc2, 0, sizeof(*dsc2));
dsc2->CompressedBufferType = type;
dsc2->DataSize = current - dxva_data;
dsc2->NumMBsInBuffer = mb_count;
type = DXVA2_SliceControlBufferType;
}
#endif
if (is_slice_short(avctx, ctx)) {
slice_data = ctx_pic->slice_short;
slice_size = ctx_pic->slice_count * sizeof(*ctx_pic->slice_short);
} else {
slice_data = ctx_pic->slice_long;
slice_size = ctx_pic->slice_count * sizeof(*ctx_pic->slice_long);
}
assert((bs->DataSize & 127) == 0);
return ff_dxva2_commit_buffer(avctx, ctx, sc,
type,
slice_data, slice_size, mb_count);
}
| true | FFmpeg | 5cddfc53570fe10fa7fe6d0f166f6f0e090466f6 | static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx,
DECODER_BUFFER_DESC *bs,
DECODER_BUFFER_DESC *sc)
{
const H264Context *h = avctx->priv_data;
const unsigned mb_count = h->mb_width * h->mb_height;
AVDXVAContext *ctx = avctx->hwaccel_context;
const H264Picture *current_picture = h->cur_pic_ptr;
struct dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private;
DXVA_Slice_H264_Short *slice = NULL;
void *dxva_data_ptr;
uint8_t *dxva_data, *current, *end;
unsigned dxva_size;
void *slice_data;
unsigned slice_size;
unsigned padding;
unsigned i;
unsigned type;
#if CONFIG_D3D11VA
if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) {
type = D3D11_VIDEO_DECODER_BUFFER_BITSTREAM;
if (FAILED(ID3D11VideoContext_GetDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context,
D3D11VA_CONTEXT(ctx)->decoder,
type,
&dxva_size, &dxva_data_ptr)))
return -1;
}
#endif
#if CONFIG_DXVA2
if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
type = DXVA2_BitStreamDateBufferType;
if (FAILED(IDirectXVideoDecoder_GetBuffer(DXVA2_CONTEXT(ctx)->decoder,
type,
&dxva_data_ptr, &dxva_size)))
return -1;
}
#endif
dxva_data = dxva_data_ptr;
current = dxva_data;
end = dxva_data + dxva_size;
for (i = 0; i < ctx_pic->slice_count; i++) {
static const uint8_t start_code[] = { 0, 0, 1 };
static const unsigned start_code_size = sizeof(start_code);
unsigned position, size;
assert(offsetof(DXVA_Slice_H264_Short, BSNALunitDataLocation) ==
offsetof(DXVA_Slice_H264_Long, BSNALunitDataLocation));
assert(offsetof(DXVA_Slice_H264_Short, SliceBytesInBuffer) ==
offsetof(DXVA_Slice_H264_Long, SliceBytesInBuffer));
if (is_slice_short(avctx, ctx))
slice = &ctx_pic->slice_short[i];
else
slice = (DXVA_Slice_H264_Short*)&ctx_pic->slice_long[i];
position = slice->BSNALunitDataLocation;
size = slice->SliceBytesInBuffer;
if (start_code_size + size > end - current) {
av_log(avctx, AV_LOG_ERROR, "Failed to build bitstream");
break;
}
slice->BSNALunitDataLocation = current - dxva_data;
slice->SliceBytesInBuffer = start_code_size + size;
if (!is_slice_short(avctx, ctx)) {
DXVA_Slice_H264_Long *slice_long = (DXVA_Slice_H264_Long*)slice;
if (i < ctx_pic->slice_count - 1)
slice_long->NumMbsForSlice =
slice_long[1].first_mb_in_slice - slice_long[0].first_mb_in_slice;
else
slice_long->NumMbsForSlice = mb_count - slice_long->first_mb_in_slice;
}
memcpy(current, start_code, start_code_size);
current += start_code_size;
memcpy(current, &ctx_pic->bitstream[position], size);
current += size;
}
padding = FFMIN(128 - ((current - dxva_data) & 127), end - current);
if (slice && padding > 0) {
memset(current, 0, padding);
current += padding;
slice->SliceBytesInBuffer += padding;
}
#if CONFIG_D3D11VA
if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD)
if (FAILED(ID3D11VideoContext_ReleaseDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, type)))
return -1;
#endif
#if CONFIG_DXVA2
if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
if (FAILED(IDirectXVideoDecoder_ReleaseBuffer(DXVA2_CONTEXT(ctx)->decoder, type)))
return -1;
#endif
if (i < ctx_pic->slice_count)
return -1;
#if CONFIG_D3D11VA
if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) {
D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = bs;
memset(dsc11, 0, sizeof(*dsc11));
dsc11->BufferType = type;
dsc11->DataSize = current - dxva_data;
dsc11->NumMBsInBuffer = mb_count;
type = D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL;
}
#endif
#if CONFIG_DXVA2
if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
DXVA2_DecodeBufferDesc *dsc2 = bs;
memset(dsc2, 0, sizeof(*dsc2));
dsc2->CompressedBufferType = type;
dsc2->DataSize = current - dxva_data;
dsc2->NumMBsInBuffer = mb_count;
type = DXVA2_SliceControlBufferType;
}
#endif
if (is_slice_short(avctx, ctx)) {
slice_data = ctx_pic->slice_short;
slice_size = ctx_pic->slice_count * sizeof(*ctx_pic->slice_short);
} else {
slice_data = ctx_pic->slice_long;
slice_size = ctx_pic->slice_count * sizeof(*ctx_pic->slice_long);
}
assert((bs->DataSize & 127) == 0);
return ff_dxva2_commit_buffer(avctx, ctx, sc,
type,
slice_data, slice_size, mb_count);
}
| {
"code": [
" void *dxva_data_ptr;",
" unsigned dxva_size;"
],
"line_no": [
21,
25
]
} | static int FUNC_0(AVCodecContext *VAR_0,
DECODER_BUFFER_DESC *VAR_1,
DECODER_BUFFER_DESC *VAR_2)
{
const H264Context *VAR_3 = VAR_0->priv_data;
const unsigned VAR_4 = VAR_3->mb_width * VAR_3->mb_height;
AVDXVAContext *ctx = VAR_0->hwaccel_context;
const H264Picture *VAR_5 = VAR_3->cur_pic_ptr;
struct dxva2_picture_context *VAR_6 = VAR_5->hwaccel_picture_private;
DXVA_Slice_H264_Short *slice = NULL;
void *VAR_7;
uint8_t *dxva_data, *current, *end;
unsigned VAR_8;
void *VAR_9;
unsigned VAR_10;
unsigned VAR_11;
unsigned VAR_12;
unsigned VAR_13;
#if CONFIG_D3D11VA
if (VAR_0->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) {
VAR_13 = D3D11_VIDEO_DECODER_BUFFER_BITSTREAM;
if (FAILED(ID3D11VideoContext_GetDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context,
D3D11VA_CONTEXT(ctx)->decoder,
VAR_13,
&VAR_8, &VAR_7)))
return -1;
}
#endif
#if CONFIG_DXVA2
if (VAR_0->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
VAR_13 = DXVA2_BitStreamDateBufferType;
if (FAILED(IDirectXVideoDecoder_GetBuffer(DXVA2_CONTEXT(ctx)->decoder,
VAR_13,
&VAR_7, &VAR_8)))
return -1;
}
#endif
dxva_data = VAR_7;
current = dxva_data;
end = dxva_data + VAR_8;
for (VAR_12 = 0; VAR_12 < VAR_6->slice_count; VAR_12++) {
static const uint8_t VAR_14[] = { 0, 0, 1 };
static const unsigned VAR_15 = sizeof(VAR_14);
unsigned VAR_16, VAR_17;
assert(offsetof(DXVA_Slice_H264_Short, BSNALunitDataLocation) ==
offsetof(DXVA_Slice_H264_Long, BSNALunitDataLocation));
assert(offsetof(DXVA_Slice_H264_Short, SliceBytesInBuffer) ==
offsetof(DXVA_Slice_H264_Long, SliceBytesInBuffer));
if (is_slice_short(VAR_0, ctx))
slice = &VAR_6->slice_short[VAR_12];
else
slice = (DXVA_Slice_H264_Short*)&VAR_6->slice_long[VAR_12];
VAR_16 = slice->BSNALunitDataLocation;
VAR_17 = slice->SliceBytesInBuffer;
if (VAR_15 + VAR_17 > end - current) {
av_log(VAR_0, AV_LOG_ERROR, "Failed to build bitstream");
break;
}
slice->BSNALunitDataLocation = current - dxva_data;
slice->SliceBytesInBuffer = VAR_15 + VAR_17;
if (!is_slice_short(VAR_0, ctx)) {
DXVA_Slice_H264_Long *slice_long = (DXVA_Slice_H264_Long*)slice;
if (VAR_12 < VAR_6->slice_count - 1)
slice_long->NumMbsForSlice =
slice_long[1].first_mb_in_slice - slice_long[0].first_mb_in_slice;
else
slice_long->NumMbsForSlice = VAR_4 - slice_long->first_mb_in_slice;
}
memcpy(current, VAR_14, VAR_15);
current += VAR_15;
memcpy(current, &VAR_6->bitstream[VAR_16], VAR_17);
current += VAR_17;
}
VAR_11 = FFMIN(128 - ((current - dxva_data) & 127), end - current);
if (slice && VAR_11 > 0) {
memset(current, 0, VAR_11);
current += VAR_11;
slice->SliceBytesInBuffer += VAR_11;
}
#if CONFIG_D3D11VA
if (VAR_0->pix_fmt == AV_PIX_FMT_D3D11VA_VLD)
if (FAILED(ID3D11VideoContext_ReleaseDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, VAR_13)))
return -1;
#endif
#if CONFIG_DXVA2
if (VAR_0->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
if (FAILED(IDirectXVideoDecoder_ReleaseBuffer(DXVA2_CONTEXT(ctx)->decoder, VAR_13)))
return -1;
#endif
if (VAR_12 < VAR_6->slice_count)
return -1;
#if CONFIG_D3D11VA
if (VAR_0->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) {
D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = VAR_1;
memset(dsc11, 0, sizeof(*dsc11));
dsc11->BufferType = VAR_13;
dsc11->DataSize = current - dxva_data;
dsc11->NumMBsInBuffer = VAR_4;
VAR_13 = D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL;
}
#endif
#if CONFIG_DXVA2
if (VAR_0->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
DXVA2_DecodeBufferDesc *dsc2 = VAR_1;
memset(dsc2, 0, sizeof(*dsc2));
dsc2->CompressedBufferType = VAR_13;
dsc2->DataSize = current - dxva_data;
dsc2->NumMBsInBuffer = VAR_4;
VAR_13 = DXVA2_SliceControlBufferType;
}
#endif
if (is_slice_short(VAR_0, ctx)) {
VAR_9 = VAR_6->slice_short;
VAR_10 = VAR_6->slice_count * sizeof(*VAR_6->slice_short);
} else {
VAR_9 = VAR_6->slice_long;
VAR_10 = VAR_6->slice_count * sizeof(*VAR_6->slice_long);
}
assert((VAR_1->DataSize & 127) == 0);
return ff_dxva2_commit_buffer(VAR_0, ctx, VAR_2,
VAR_13,
VAR_9, VAR_10, VAR_4);
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nDECODER_BUFFER_DESC *VAR_1,\nDECODER_BUFFER_DESC *VAR_2)\n{",
"const H264Context *VAR_3 = VAR_0->priv_data;",
"const unsigned VAR_4 = VAR_3->mb_width * VAR_3->mb_height;",
"AVDXVAContext *ctx = VAR_0->hwaccel_context;",
"const H264Picture *VAR_5 = VAR_3->cur_pic_ptr;",
"struct dxva2_picture_context *VAR_6 = VAR_5->hwaccel_picture_private;",
"DXVA_Slice_H264_Short *slice = NULL;",
"void *VAR_7;",
"uint8_t *dxva_data, *current, *end;",
"unsigned VAR_8;",
"void *VAR_9;",
"unsigned VAR_10;",
"unsigned VAR_11;",
"unsigned VAR_12;",
"unsigned VAR_13;",
"#if CONFIG_D3D11VA\nif (VAR_0->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) {",
"VAR_13 = D3D11_VIDEO_DECODER_BUFFER_BITSTREAM;",
"if (FAILED(ID3D11VideoContext_GetDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context,\nD3D11VA_CONTEXT(ctx)->decoder,\nVAR_13,\n&VAR_8, &VAR_7)))\nreturn -1;",
"}",
"#endif\n#if CONFIG_DXVA2\nif (VAR_0->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {",
"VAR_13 = DXVA2_BitStreamDateBufferType;",
"if (FAILED(IDirectXVideoDecoder_GetBuffer(DXVA2_CONTEXT(ctx)->decoder,\nVAR_13,\n&VAR_7, &VAR_8)))\nreturn -1;",
"}",
"#endif\ndxva_data = VAR_7;",
"current = dxva_data;",
"end = dxva_data + VAR_8;",
"for (VAR_12 = 0; VAR_12 < VAR_6->slice_count; VAR_12++) {",
"static const uint8_t VAR_14[] = { 0, 0, 1 };",
"static const unsigned VAR_15 = sizeof(VAR_14);",
"unsigned VAR_16, VAR_17;",
"assert(offsetof(DXVA_Slice_H264_Short, BSNALunitDataLocation) ==\noffsetof(DXVA_Slice_H264_Long, BSNALunitDataLocation));",
"assert(offsetof(DXVA_Slice_H264_Short, SliceBytesInBuffer) ==\noffsetof(DXVA_Slice_H264_Long, SliceBytesInBuffer));",
"if (is_slice_short(VAR_0, ctx))\nslice = &VAR_6->slice_short[VAR_12];",
"else\nslice = (DXVA_Slice_H264_Short*)&VAR_6->slice_long[VAR_12];",
"VAR_16 = slice->BSNALunitDataLocation;",
"VAR_17 = slice->SliceBytesInBuffer;",
"if (VAR_15 + VAR_17 > end - current) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Failed to build bitstream\");",
"break;",
"}",
"slice->BSNALunitDataLocation = current - dxva_data;",
"slice->SliceBytesInBuffer = VAR_15 + VAR_17;",
"if (!is_slice_short(VAR_0, ctx)) {",
"DXVA_Slice_H264_Long *slice_long = (DXVA_Slice_H264_Long*)slice;",
"if (VAR_12 < VAR_6->slice_count - 1)\nslice_long->NumMbsForSlice =\nslice_long[1].first_mb_in_slice - slice_long[0].first_mb_in_slice;",
"else\nslice_long->NumMbsForSlice = VAR_4 - slice_long->first_mb_in_slice;",
"}",
"memcpy(current, VAR_14, VAR_15);",
"current += VAR_15;",
"memcpy(current, &VAR_6->bitstream[VAR_16], VAR_17);",
"current += VAR_17;",
"}",
"VAR_11 = FFMIN(128 - ((current - dxva_data) & 127), end - current);",
"if (slice && VAR_11 > 0) {",
"memset(current, 0, VAR_11);",
"current += VAR_11;",
"slice->SliceBytesInBuffer += VAR_11;",
"}",
"#if CONFIG_D3D11VA\nif (VAR_0->pix_fmt == AV_PIX_FMT_D3D11VA_VLD)\nif (FAILED(ID3D11VideoContext_ReleaseDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, VAR_13)))\nreturn -1;",
"#endif\n#if CONFIG_DXVA2\nif (VAR_0->pix_fmt == AV_PIX_FMT_DXVA2_VLD)\nif (FAILED(IDirectXVideoDecoder_ReleaseBuffer(DXVA2_CONTEXT(ctx)->decoder, VAR_13)))\nreturn -1;",
"#endif\nif (VAR_12 < VAR_6->slice_count)\nreturn -1;",
"#if CONFIG_D3D11VA\nif (VAR_0->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) {",
"D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = VAR_1;",
"memset(dsc11, 0, sizeof(*dsc11));",
"dsc11->BufferType = VAR_13;",
"dsc11->DataSize = current - dxva_data;",
"dsc11->NumMBsInBuffer = VAR_4;",
"VAR_13 = D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL;",
"}",
"#endif\n#if CONFIG_DXVA2\nif (VAR_0->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {",
"DXVA2_DecodeBufferDesc *dsc2 = VAR_1;",
"memset(dsc2, 0, sizeof(*dsc2));",
"dsc2->CompressedBufferType = VAR_13;",
"dsc2->DataSize = current - dxva_data;",
"dsc2->NumMBsInBuffer = VAR_4;",
"VAR_13 = DXVA2_SliceControlBufferType;",
"}",
"#endif\nif (is_slice_short(VAR_0, ctx)) {",
"VAR_9 = VAR_6->slice_short;",
"VAR_10 = VAR_6->slice_count * sizeof(*VAR_6->slice_short);",
"} else {",
"VAR_9 = VAR_6->slice_long;",
"VAR_10 = VAR_6->slice_count * sizeof(*VAR_6->slice_long);",
"}",
"assert((VAR_1->DataSize & 127) == 0);",
"return ff_dxva2_commit_buffer(VAR_0, ctx, VAR_2,\nVAR_13,\nVAR_9, VAR_10, VAR_4);",
"}"
] | [
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
41,
43
],
[
45
],
[
47,
49,
51,
53,
55
],
[
57
],
[
59,
61,
63
],
[
65
],
[
67,
69,
71,
73
],
[
75
],
[
77,
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99,
101
],
[
103,
105
],
[
109,
111
],
[
113,
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135
],
[
139
],
[
141
],
[
143,
145,
147
],
[
149,
151
],
[
153
],
[
157
],
[
159
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
179
],
[
181
],
[
183,
185,
187,
189
],
[
191,
193,
195,
197,
199
],
[
201,
203,
205
],
[
209,
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
225
],
[
227
],
[
229,
231,
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
247
],
[
249
],
[
251,
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271,
273,
275
],
[
277
]
] |
18,321 | static int qtrle_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
QtrleContext *s = avctx->priv_data;
int header, start_line;
int height, row_ptr;
int has_palette = 0;
int ret;
bytestream2_init(&s->g, avpkt->data, avpkt->size);
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
return ret;
/* check if this frame is even supposed to change */
if (avpkt->size < 8)
goto done;
/* start after the chunk size */
bytestream2_seek(&s->g, 4, SEEK_SET);
/* fetch the header */
header = bytestream2_get_be16(&s->g);
/* if a header is present, fetch additional decoding parameters */
if (header & 0x0008) {
if (avpkt->size < 14)
goto done;
start_line = bytestream2_get_be16(&s->g);
bytestream2_skip(&s->g, 2);
height = bytestream2_get_be16(&s->g);
bytestream2_skip(&s->g, 2);
if (height > s->avctx->height - start_line)
goto done;
} else {
start_line = 0;
height = s->avctx->height;
}
row_ptr = s->frame->linesize[0] * start_line;
switch (avctx->bits_per_coded_sample) {
case 1:
case 33:
qtrle_decode_1bpp(s, row_ptr, height);
has_palette = 1;
break;
case 2:
case 34:
qtrle_decode_2n4bpp(s, row_ptr, height, 2);
has_palette = 1;
break;
case 4:
case 36:
qtrle_decode_2n4bpp(s, row_ptr, height, 4);
has_palette = 1;
break;
case 8:
case 40:
qtrle_decode_8bpp(s, row_ptr, height);
has_palette = 1;
break;
case 16:
qtrle_decode_16bpp(s, row_ptr, height);
break;
case 24:
qtrle_decode_24bpp(s, row_ptr, height);
break;
case 32:
qtrle_decode_32bpp(s, row_ptr, height);
break;
default:
av_log (s->avctx, AV_LOG_ERROR, "Unsupported colorspace: %d bits/sample?\n",
avctx->bits_per_coded_sample);
break;
}
if(has_palette) {
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
if (pal) {
s->frame->palette_has_changed = 1;
memcpy(s->pal, pal, AVPALETTE_SIZE);
}
/* make the palette available on the way out */
memcpy(s->frame->data[1], s->pal, AVPALETTE_SIZE);
}
done:
if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
*got_frame = 1;
/* always report that the buffer was completely consumed */
return avpkt->size;
}
| false | FFmpeg | 7d196f2a5a48faf25fd904b33b1fd239daae9840 | static int qtrle_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
QtrleContext *s = avctx->priv_data;
int header, start_line;
int height, row_ptr;
int has_palette = 0;
int ret;
bytestream2_init(&s->g, avpkt->data, avpkt->size);
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
return ret;
if (avpkt->size < 8)
goto done;
bytestream2_seek(&s->g, 4, SEEK_SET);
header = bytestream2_get_be16(&s->g);
if (header & 0x0008) {
if (avpkt->size < 14)
goto done;
start_line = bytestream2_get_be16(&s->g);
bytestream2_skip(&s->g, 2);
height = bytestream2_get_be16(&s->g);
bytestream2_skip(&s->g, 2);
if (height > s->avctx->height - start_line)
goto done;
} else {
start_line = 0;
height = s->avctx->height;
}
row_ptr = s->frame->linesize[0] * start_line;
switch (avctx->bits_per_coded_sample) {
case 1:
case 33:
qtrle_decode_1bpp(s, row_ptr, height);
has_palette = 1;
break;
case 2:
case 34:
qtrle_decode_2n4bpp(s, row_ptr, height, 2);
has_palette = 1;
break;
case 4:
case 36:
qtrle_decode_2n4bpp(s, row_ptr, height, 4);
has_palette = 1;
break;
case 8:
case 40:
qtrle_decode_8bpp(s, row_ptr, height);
has_palette = 1;
break;
case 16:
qtrle_decode_16bpp(s, row_ptr, height);
break;
case 24:
qtrle_decode_24bpp(s, row_ptr, height);
break;
case 32:
qtrle_decode_32bpp(s, row_ptr, height);
break;
default:
av_log (s->avctx, AV_LOG_ERROR, "Unsupported colorspace: %d bits/sample?\n",
avctx->bits_per_coded_sample);
break;
}
if(has_palette) {
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
if (pal) {
s->frame->palette_has_changed = 1;
memcpy(s->pal, pal, AVPALETTE_SIZE);
}
memcpy(s->frame->data[1], s->pal, AVPALETTE_SIZE);
}
done:
if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
*got_frame = 1;
return avpkt->size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
QtrleContext *s = VAR_0->priv_data;
int VAR_4, VAR_5;
int VAR_6, VAR_7;
int VAR_8 = 0;
int VAR_9;
bytestream2_init(&s->g, VAR_3->VAR_1, VAR_3->size);
if ((VAR_9 = ff_reget_buffer(VAR_0, s->frame)) < 0)
return VAR_9;
if (VAR_3->size < 8)
goto done;
bytestream2_seek(&s->g, 4, SEEK_SET);
VAR_4 = bytestream2_get_be16(&s->g);
if (VAR_4 & 0x0008) {
if (VAR_3->size < 14)
goto done;
VAR_5 = bytestream2_get_be16(&s->g);
bytestream2_skip(&s->g, 2);
VAR_6 = bytestream2_get_be16(&s->g);
bytestream2_skip(&s->g, 2);
if (VAR_6 > s->VAR_0->VAR_6 - VAR_5)
goto done;
} else {
VAR_5 = 0;
VAR_6 = s->VAR_0->VAR_6;
}
VAR_7 = s->frame->linesize[0] * VAR_5;
switch (VAR_0->bits_per_coded_sample) {
case 1:
case 33:
qtrle_decode_1bpp(s, VAR_7, VAR_6);
VAR_8 = 1;
break;
case 2:
case 34:
qtrle_decode_2n4bpp(s, VAR_7, VAR_6, 2);
VAR_8 = 1;
break;
case 4:
case 36:
qtrle_decode_2n4bpp(s, VAR_7, VAR_6, 4);
VAR_8 = 1;
break;
case 8:
case 40:
qtrle_decode_8bpp(s, VAR_7, VAR_6);
VAR_8 = 1;
break;
case 16:
qtrle_decode_16bpp(s, VAR_7, VAR_6);
break;
case 24:
qtrle_decode_24bpp(s, VAR_7, VAR_6);
break;
case 32:
qtrle_decode_32bpp(s, VAR_7, VAR_6);
break;
default:
av_log (s->VAR_0, AV_LOG_ERROR, "Unsupported colorspace: %d bits/sample?\n",
VAR_0->bits_per_coded_sample);
break;
}
if(VAR_8) {
const uint8_t *VAR_10 = av_packet_get_side_data(VAR_3, AV_PKT_DATA_PALETTE, NULL);
if (VAR_10) {
s->frame->palette_has_changed = 1;
memcpy(s->VAR_10, VAR_10, AVPALETTE_SIZE);
}
memcpy(s->frame->VAR_1[1], s->VAR_10, AVPALETTE_SIZE);
}
done:
if ((VAR_9 = av_frame_ref(VAR_1, s->frame)) < 0)
return VAR_9;
*VAR_2 = 1;
return VAR_3->size;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"QtrleContext *s = VAR_0->priv_data;",
"int VAR_4, VAR_5;",
"int VAR_6, VAR_7;",
"int VAR_8 = 0;",
"int VAR_9;",
"bytestream2_init(&s->g, VAR_3->VAR_1, VAR_3->size);",
"if ((VAR_9 = ff_reget_buffer(VAR_0, s->frame)) < 0)\nreturn VAR_9;",
"if (VAR_3->size < 8)\ngoto done;",
"bytestream2_seek(&s->g, 4, SEEK_SET);",
"VAR_4 = bytestream2_get_be16(&s->g);",
"if (VAR_4 & 0x0008) {",
"if (VAR_3->size < 14)\ngoto done;",
"VAR_5 = bytestream2_get_be16(&s->g);",
"bytestream2_skip(&s->g, 2);",
"VAR_6 = bytestream2_get_be16(&s->g);",
"bytestream2_skip(&s->g, 2);",
"if (VAR_6 > s->VAR_0->VAR_6 - VAR_5)\ngoto done;",
"} else {",
"VAR_5 = 0;",
"VAR_6 = s->VAR_0->VAR_6;",
"}",
"VAR_7 = s->frame->linesize[0] * VAR_5;",
"switch (VAR_0->bits_per_coded_sample) {",
"case 1:\ncase 33:\nqtrle_decode_1bpp(s, VAR_7, VAR_6);",
"VAR_8 = 1;",
"break;",
"case 2:\ncase 34:\nqtrle_decode_2n4bpp(s, VAR_7, VAR_6, 2);",
"VAR_8 = 1;",
"break;",
"case 4:\ncase 36:\nqtrle_decode_2n4bpp(s, VAR_7, VAR_6, 4);",
"VAR_8 = 1;",
"break;",
"case 8:\ncase 40:\nqtrle_decode_8bpp(s, VAR_7, VAR_6);",
"VAR_8 = 1;",
"break;",
"case 16:\nqtrle_decode_16bpp(s, VAR_7, VAR_6);",
"break;",
"case 24:\nqtrle_decode_24bpp(s, VAR_7, VAR_6);",
"break;",
"case 32:\nqtrle_decode_32bpp(s, VAR_7, VAR_6);",
"break;",
"default:\nav_log (s->VAR_0, AV_LOG_ERROR, \"Unsupported colorspace: %d bits/sample?\\n\",\nVAR_0->bits_per_coded_sample);",
"break;",
"}",
"if(VAR_8) {",
"const uint8_t *VAR_10 = av_packet_get_side_data(VAR_3, AV_PKT_DATA_PALETTE, NULL);",
"if (VAR_10) {",
"s->frame->palette_has_changed = 1;",
"memcpy(s->VAR_10, VAR_10, AVPALETTE_SIZE);",
"}",
"memcpy(s->frame->VAR_1[1], s->VAR_10, AVPALETTE_SIZE);",
"}",
"done:\nif ((VAR_9 = av_frame_ref(VAR_1, s->frame)) < 0)\nreturn VAR_9;",
"*VAR_2 = 1;",
"return VAR_3->size;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23,
25
],
[
31,
33
],
[
39
],
[
45
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83,
85,
87
],
[
89
],
[
91
],
[
95,
97,
99
],
[
101
],
[
103
],
[
107,
109,
111
],
[
113
],
[
115
],
[
119,
121,
123
],
[
125
],
[
127
],
[
131,
133
],
[
135
],
[
139,
141
],
[
143
],
[
147,
149
],
[
151
],
[
155,
157,
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
173
],
[
175
],
[
177
],
[
179
],
[
185
],
[
187
],
[
191,
193,
195
],
[
197
],
[
203
],
[
205
]
] |
18,322 | int ffio_open2_wrapper(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags,
const AVIOInterruptCB *int_cb, AVDictionary **options)
{
return avio_open2(pb, url, flags, int_cb, options);
}
| false | FFmpeg | 1dba8371d93cf1c83bcd5c432d921905206a60f3 | int ffio_open2_wrapper(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags,
const AVIOInterruptCB *int_cb, AVDictionary **options)
{
return avio_open2(pb, url, flags, int_cb, options);
}
| {
"code": [],
"line_no": []
} | int FUNC_0(struct AVFormatContext *VAR_0, AVIOContext **VAR_1, const char *VAR_2, int VAR_3,
const AVIOInterruptCB *VAR_4, AVDictionary **VAR_5)
{
return avio_open2(VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);
}
| [
"int FUNC_0(struct AVFormatContext *VAR_0, AVIOContext **VAR_1, const char *VAR_2, int VAR_3,\nconst AVIOInterruptCB *VAR_4, AVDictionary **VAR_5)\n{",
"return avio_open2(VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
]
] |
18,325 | static void rbd_finish_aiocb(rbd_completion_t c, RADOSCB *rcb)
{
int ret;
rcb->ret = rbd_aio_get_return_value(c);
rbd_aio_release(c);
ret = qemu_rbd_send_pipe(rcb->s, rcb);
if (ret < 0) {
error_report("failed writing to acb->s->fds");
g_free(rcb);
}
}
| true | qemu | e04fb07fd1676e9facd7f3f878c1bbe03bccd26b | static void rbd_finish_aiocb(rbd_completion_t c, RADOSCB *rcb)
{
int ret;
rcb->ret = rbd_aio_get_return_value(c);
rbd_aio_release(c);
ret = qemu_rbd_send_pipe(rcb->s, rcb);
if (ret < 0) {
error_report("failed writing to acb->s->fds");
g_free(rcb);
}
}
| {
"code": [
" int ret;",
" ret = qemu_rbd_send_pipe(rcb->s, rcb);",
" if (ret < 0) {",
" error_report(\"failed writing to acb->s->fds\");",
" g_free(rcb);"
],
"line_no": [
5,
11,
13,
15,
17
]
} | static void FUNC_0(rbd_completion_t VAR_0, RADOSCB *VAR_1)
{
int VAR_2;
VAR_1->VAR_2 = rbd_aio_get_return_value(VAR_0);
rbd_aio_release(VAR_0);
VAR_2 = qemu_rbd_send_pipe(VAR_1->s, VAR_1);
if (VAR_2 < 0) {
error_report("failed writing to acb->s->fds");
g_free(VAR_1);
}
}
| [
"static void FUNC_0(rbd_completion_t VAR_0, RADOSCB *VAR_1)\n{",
"int VAR_2;",
"VAR_1->VAR_2 = rbd_aio_get_return_value(VAR_0);",
"rbd_aio_release(VAR_0);",
"VAR_2 = qemu_rbd_send_pipe(VAR_1->s, VAR_1);",
"if (VAR_2 < 0) {",
"error_report(\"failed writing to acb->s->fds\");",
"g_free(VAR_1);",
"}",
"}"
] | [
0,
1,
0,
0,
1,
1,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
18,327 | static void pcihotplug_write(void *opaque, uint32_t addr, uint32_t val)
{
struct pci_status *g = opaque;
switch (addr) {
case PCI_BASE:
g->up = val;
break;
case PCI_BASE + 4:
g->down = val;
break;
}
PIIX4_DPRINTF("pcihotplug write %x <== %d\n", addr, val);
}
| true | qemu | ba737541edddf9d0026460eb7b1d1c599b4c8ae9 | static void pcihotplug_write(void *opaque, uint32_t addr, uint32_t val)
{
struct pci_status *g = opaque;
switch (addr) {
case PCI_BASE:
g->up = val;
break;
case PCI_BASE + 4:
g->down = val;
break;
}
PIIX4_DPRINTF("pcihotplug write %x <== %d\n", addr, val);
}
| {
"code": [
" struct pci_status *g = opaque;",
" switch (addr) {",
" case PCI_BASE:",
" break;",
" case PCI_BASE + 4:",
" break;",
" break;",
"static void pcihotplug_write(void *opaque, uint32_t addr, uint32_t val)",
" struct pci_status *g = opaque;",
" switch (addr) {",
" case PCI_BASE:",
" g->up = val;",
" break;",
" case PCI_BASE + 4:",
" g->down = val;",
" break;",
" PIIX4_DPRINTF(\"pcihotplug write %x <== %d\\n\", addr, val);"
],
"line_no": [
5,
7,
9,
13,
15,
13,
13,
1,
5,
7,
9,
11,
13,
15,
17,
13,
25
]
} | static void FUNC_0(void *VAR_0, uint32_t VAR_1, uint32_t VAR_2)
{
struct pci_status *VAR_3 = VAR_0;
switch (VAR_1) {
case PCI_BASE:
VAR_3->up = VAR_2;
break;
case PCI_BASE + 4:
VAR_3->down = VAR_2;
break;
}
PIIX4_DPRINTF("pcihotplug write %x <== %d\n", VAR_1, VAR_2);
}
| [
"static void FUNC_0(void *VAR_0, uint32_t VAR_1, uint32_t VAR_2)\n{",
"struct pci_status *VAR_3 = VAR_0;",
"switch (VAR_1) {",
"case PCI_BASE:\nVAR_3->up = VAR_2;",
"break;",
"case PCI_BASE + 4:\nVAR_3->down = VAR_2;",
"break;",
"}",
"PIIX4_DPRINTF(\"pcihotplug write %x <== %d\\n\", VAR_1, VAR_2);",
"}"
] | [
1,
1,
1,
1,
1,
1,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
25
],
[
27
]
] |
18,330 | static void put_pixels_clamped2_c(const DCTELEM *block, uint8_t *restrict pixels,
int line_size)
{
int i;
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
/* read the pixels */
for(i=0;i<2;i++) {
pixels[0] = cm[block[0]];
pixels[1] = cm[block[1]];
pixels += line_size;
block += 8;
}
}
| true | FFmpeg | c23acbaed40101c677dfcfbbfe0d2c230a8e8f44 | static void put_pixels_clamped2_c(const DCTELEM *block, uint8_t *restrict pixels,
int line_size)
{
int i;
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
for(i=0;i<2;i++) {
pixels[0] = cm[block[0]];
pixels[1] = cm[block[1]];
pixels += line_size;
block += 8;
}
}
| {
"code": [
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" pixels[0] = cm[block[0]];",
" pixels[1] = cm[block[1]];",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" pixels[0] = cm[block[0]];",
" pixels[1] = cm[block[1]];",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" pixels[0] = cm[block[0]];",
" pixels[1] = cm[block[1]];",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
" uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;"
],
"line_no": [
9,
17,
19,
9,
17,
19,
9,
17,
19,
9,
9,
9,
9,
9,
9,
9,
9,
9,
9
]
} | static void FUNC_0(const DCTELEM *VAR_0, uint8_t *restrict VAR_1,
int VAR_2)
{
int VAR_3;
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
for(VAR_3=0;VAR_3<2;VAR_3++) {
VAR_1[0] = cm[VAR_0[0]];
VAR_1[1] = cm[VAR_0[1]];
VAR_1 += VAR_2;
VAR_0 += 8;
}
}
| [
"static void FUNC_0(const DCTELEM *VAR_0, uint8_t *restrict VAR_1,\nint VAR_2)\n{",
"int VAR_3;",
"uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;",
"for(VAR_3=0;VAR_3<2;VAR_3++) {",
"VAR_1[0] = cm[VAR_0[0]];",
"VAR_1[1] = cm[VAR_0[1]];",
"VAR_1 += VAR_2;",
"VAR_0 += 8;",
"}",
"}"
] | [
0,
0,
1,
0,
1,
1,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
18,331 | bool qemu_file_is_writable(QEMUFile *f)
{
return f->ops->writev_buffer || f->ops->put_buffer;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | bool qemu_file_is_writable(QEMUFile *f)
{
return f->ops->writev_buffer || f->ops->put_buffer;
}
| {
"code": [],
"line_no": []
} | bool FUNC_0(QEMUFile *f)
{
return f->ops->writev_buffer || f->ops->put_buffer;
}
| [
"bool FUNC_0(QEMUFile *f)\n{",
"return f->ops->writev_buffer || f->ops->put_buffer;",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
18,332 | static int encode_thread(AVCodecContext *c, void *arg){
MpegEncContext *s= *(void**)arg;
int mb_x, mb_y, pdif = 0;
int chr_h= 16>>s->chroma_y_shift;
int i, j;
MpegEncContext best_s, backup_s;
uint8_t bit_buf[2][MAX_MB_BYTES];
uint8_t bit_buf2[2][MAX_MB_BYTES];
uint8_t bit_buf_tex[2][MAX_MB_BYTES];
PutBitContext pb[2], pb2[2], tex_pb[2];
for(i=0; i<2; i++){
init_put_bits(&pb [i], bit_buf [i], MAX_MB_BYTES);
init_put_bits(&pb2 [i], bit_buf2 [i], MAX_MB_BYTES);
init_put_bits(&tex_pb[i], bit_buf_tex[i], MAX_MB_BYTES);
}
s->last_bits= put_bits_count(&s->pb);
s->mv_bits=0;
s->misc_bits=0;
s->i_tex_bits=0;
s->p_tex_bits=0;
s->i_count=0;
s->f_count=0;
s->b_count=0;
s->skip_count=0;
for(i=0; i<3; i++){
/* init last dc values */
/* note: quant matrix value (8) is implied here */
s->last_dc[i] = 128 << s->intra_dc_precision;
s->current_picture.f.error[i] = 0;
}
s->mb_skip_run = 0;
memset(s->last_mv, 0, sizeof(s->last_mv));
s->last_mv_dir = 0;
switch(s->codec_id){
case AV_CODEC_ID_H263:
case AV_CODEC_ID_H263P:
case AV_CODEC_ID_FLV1:
if (CONFIG_H263_ENCODER)
s->gob_index = ff_h263_get_gob_height(s);
break;
case AV_CODEC_ID_MPEG4:
if(CONFIG_MPEG4_ENCODER && s->partitioned_frame)
ff_mpeg4_init_partitions(s);
break;
}
s->resync_mb_x=0;
s->resync_mb_y=0;
s->first_slice_line = 1;
s->ptr_lastgob = s->pb.buf;
for(mb_y= s->start_mb_y; mb_y < s->end_mb_y; mb_y++) {
s->mb_x=0;
s->mb_y= mb_y;
ff_set_qscale(s, s->qscale);
ff_init_block_index(s);
for(mb_x=0; mb_x < s->mb_width; mb_x++) {
int xy= mb_y*s->mb_stride + mb_x; // removed const, H261 needs to adjust this
int mb_type= s->mb_type[xy];
// int d;
int dmin= INT_MAX;
int dir;
if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < MAX_MB_BYTES){
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
}
if(s->data_partitioning){
if( s->pb2 .buf_end - s->pb2 .buf - (put_bits_count(&s-> pb2)>>3) < MAX_MB_BYTES
|| s->tex_pb.buf_end - s->tex_pb.buf - (put_bits_count(&s->tex_pb )>>3) < MAX_MB_BYTES){
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
}
}
s->mb_x = mb_x;
s->mb_y = mb_y; // moved into loop, can get changed by H.261
ff_update_block_index(s);
if(CONFIG_H261_ENCODER && s->codec_id == AV_CODEC_ID_H261){
ff_h261_reorder_mb_index(s);
xy= s->mb_y*s->mb_stride + s->mb_x;
mb_type= s->mb_type[xy];
}
/* write gob / video packet header */
if(s->rtp_mode){
int current_packet_size, is_gob_start;
current_packet_size= ((put_bits_count(&s->pb)+7)>>3) - (s->ptr_lastgob - s->pb.buf);
is_gob_start= s->avctx->rtp_payload_size && current_packet_size >= s->avctx->rtp_payload_size && mb_y + mb_x>0;
if(s->start_mb_y == mb_y && mb_y > 0 && mb_x==0) is_gob_start=1;
switch(s->codec_id){
case AV_CODEC_ID_H263:
case AV_CODEC_ID_H263P:
if(!s->h263_slice_structured)
if(s->mb_x || s->mb_y%s->gob_index) is_gob_start=0;
break;
case AV_CODEC_ID_MPEG2VIDEO:
if(s->mb_x==0 && s->mb_y!=0) is_gob_start=1;
case AV_CODEC_ID_MPEG1VIDEO:
if(s->mb_skip_run) is_gob_start=0;
break;
}
if(is_gob_start){
if(s->start_mb_y != mb_y || mb_x!=0){
write_slice_end(s);
if(CONFIG_MPEG4_ENCODER && s->codec_id==AV_CODEC_ID_MPEG4 && s->partitioned_frame){
ff_mpeg4_init_partitions(s);
}
}
assert((put_bits_count(&s->pb)&7) == 0);
current_packet_size= put_bits_ptr(&s->pb) - s->ptr_lastgob;
if (s->error_rate && s->resync_mb_x + s->resync_mb_y > 0) {
int r= put_bits_count(&s->pb)/8 + s->picture_number + 16 + s->mb_x + s->mb_y;
int d = 100 / s->error_rate;
if(r % d == 0){
current_packet_size=0;
s->pb.buf_ptr= s->ptr_lastgob;
assert(put_bits_ptr(&s->pb) == s->ptr_lastgob);
}
}
if (s->avctx->rtp_callback){
int number_mb = (mb_y - s->resync_mb_y)*s->mb_width + mb_x - s->resync_mb_x;
s->avctx->rtp_callback(s->avctx, s->ptr_lastgob, current_packet_size, number_mb);
}
update_mb_info(s, 1);
switch(s->codec_id){
case AV_CODEC_ID_MPEG4:
if (CONFIG_MPEG4_ENCODER) {
ff_mpeg4_encode_video_packet_header(s);
ff_mpeg4_clean_buffers(s);
}
break;
case AV_CODEC_ID_MPEG1VIDEO:
case AV_CODEC_ID_MPEG2VIDEO:
if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER) {
ff_mpeg1_encode_slice_header(s);
ff_mpeg1_clean_buffers(s);
}
break;
case AV_CODEC_ID_H263:
case AV_CODEC_ID_H263P:
if (CONFIG_H263_ENCODER)
ff_h263_encode_gob_header(s, mb_y);
break;
}
if(s->flags&CODEC_FLAG_PASS1){
int bits= put_bits_count(&s->pb);
s->misc_bits+= bits - s->last_bits;
s->last_bits= bits;
}
s->ptr_lastgob += current_packet_size;
s->first_slice_line=1;
s->resync_mb_x=mb_x;
s->resync_mb_y=mb_y;
}
}
if( (s->resync_mb_x == s->mb_x)
&& s->resync_mb_y+1 == s->mb_y){
s->first_slice_line=0;
}
s->mb_skipped=0;
s->dquant=0; //only for QP_RD
update_mb_info(s, 0);
if (mb_type & (mb_type-1) || (s->mpv_flags & FF_MPV_FLAG_QP_RD)) { // more than 1 MB type possible or FF_MPV_FLAG_QP_RD
int next_block=0;
int pb_bits_count, pb2_bits_count, tex_pb_bits_count;
copy_context_before_encode(&backup_s, s, -1);
backup_s.pb= s->pb;
best_s.data_partitioning= s->data_partitioning;
best_s.partitioned_frame= s->partitioned_frame;
if(s->data_partitioning){
backup_s.pb2= s->pb2;
backup_s.tex_pb= s->tex_pb;
}
if(mb_type&CANDIDATE_MB_TYPE_INTER){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = s->p_mv_table[xy][0];
s->mv[0][0][1] = s->p_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_INTER_I){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[0][i] = s->p_field_select_table[i][xy];
s->mv[0][i][0] = s->p_field_mv_table[i][j][xy][0];
s->mv[0][i][1] = s->p_field_mv_table[i][j][xy][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_SKIPPED){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_SKIPPED, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_INTER4V){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_8X8;
s->mb_intra= 0;
for(i=0; i<4; i++){
s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0];
s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER4V, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_FORWARD){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = s->b_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_forw_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_BACKWARD){
s->mv_dir = MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[1][0][0] = s->b_back_mv_table[xy][0];
s->mv[1][0][1] = s->b_back_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[1][0][0], s->mv[1][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_BIDIR){
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1];
s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0];
s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_FORWARD_I){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[0][i] = s->b_field_select_table[0][i][xy];
s->mv[0][i][0] = s->b_field_mv_table[0][i][j][xy][0];
s->mv[0][i][1] = s->b_field_mv_table[0][i][j][xy][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_BACKWARD_I){
s->mv_dir = MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[1][i] = s->b_field_select_table[1][i][xy];
s->mv[1][i][0] = s->b_field_mv_table[1][i][j][xy][0];
s->mv[1][i][1] = s->b_field_mv_table[1][i][j][xy][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_BIDIR_I){
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(dir=0; dir<2; dir++){
for(i=0; i<2; i++){
j= s->field_select[dir][i] = s->b_field_select_table[dir][i][xy];
s->mv[dir][i][0] = s->b_field_mv_table[dir][i][j][xy][0];
s->mv[dir][i][1] = s->b_field_mv_table[dir][i][j][xy][1];
}
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_INTRA){
s->mv_dir = 0;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 1;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTRA, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
if(s->h263_pred || s->h263_aic){
if(best_s.mb_intra)
s->mbintra_table[mb_x + mb_y*s->mb_stride]=1;
else
ff_clean_intra_table_entries(s); //old mode?
}
}
if ((s->mpv_flags & FF_MPV_FLAG_QP_RD) && dmin < INT_MAX) {
if(best_s.mv_type==MV_TYPE_16X16){ //FIXME move 4mv after QPRD
const int last_qp= backup_s.qscale;
int qpi, qp, dc[6];
int16_t ac[6][16];
const int mvdir= (best_s.mv_dir&MV_DIR_BACKWARD) ? 1 : 0;
static const int dquant_tab[4]={-1,1,-2,2};
assert(backup_s.dquant == 0);
//FIXME intra
s->mv_dir= best_s.mv_dir;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= best_s.mb_intra;
s->mv[0][0][0] = best_s.mv[0][0][0];
s->mv[0][0][1] = best_s.mv[0][0][1];
s->mv[1][0][0] = best_s.mv[1][0][0];
s->mv[1][0][1] = best_s.mv[1][0][1];
qpi = s->pict_type == AV_PICTURE_TYPE_B ? 2 : 0;
for(; qpi<4; qpi++){
int dquant= dquant_tab[qpi];
qp= last_qp + dquant;
if(qp < s->avctx->qmin || qp > s->avctx->qmax)
continue;
backup_s.dquant= dquant;
if(s->mb_intra && s->dc_val[0]){
for(i=0; i<6; i++){
dc[i]= s->dc_val[0][ s->block_index[i] ];
memcpy(ac[i], s->ac_val[0][s->block_index[i]], sizeof(int16_t)*16);
}
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER /* wrong but unused */, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[mvdir][0][0], s->mv[mvdir][0][1]);
if(best_s.qscale != qp){
if(s->mb_intra && s->dc_val[0]){
for(i=0; i<6; i++){
s->dc_val[0][ s->block_index[i] ]= dc[i];
memcpy(s->ac_val[0][s->block_index[i]], ac[i], sizeof(int16_t)*16);
}
}
}
}
}
}
if(CONFIG_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT){
int mx= s->b_direct_mv_table[xy][0];
int my= s->b_direct_mv_table[xy][1];
backup_s.dquant = 0;
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
s->mb_intra= 0;
ff_mpeg4_set_direct_mv(s, mx, my);
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,
&dmin, &next_block, mx, my);
}
if(CONFIG_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT0){
backup_s.dquant = 0;
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
s->mb_intra= 0;
ff_mpeg4_set_direct_mv(s, 0, 0);
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if (!best_s.mb_intra && s->mpv_flags & FF_MPV_FLAG_SKIP_RD) {
int coded=0;
for(i=0; i<6; i++)
coded |= s->block_last_index[i];
if(coded){
int mx,my;
memcpy(s->mv, best_s.mv, sizeof(s->mv));
if(CONFIG_MPEG4_ENCODER && best_s.mv_dir & MV_DIRECT){
mx=my=0; //FIXME find the one we actually used
ff_mpeg4_set_direct_mv(s, mx, my);
}else if(best_s.mv_dir&MV_DIR_BACKWARD){
mx= s->mv[1][0][0];
my= s->mv[1][0][1];
}else{
mx= s->mv[0][0][0];
my= s->mv[0][0][1];
}
s->mv_dir= best_s.mv_dir;
s->mv_type = best_s.mv_type;
s->mb_intra= 0;
/* s->mv[0][0][0] = best_s.mv[0][0][0];
s->mv[0][0][1] = best_s.mv[0][0][1];
s->mv[1][0][0] = best_s.mv[1][0][0];
s->mv[1][0][1] = best_s.mv[1][0][1];*/
backup_s.dquant= 0;
s->skipdct=1;
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER /* wrong but unused */, pb, pb2, tex_pb,
&dmin, &next_block, mx, my);
s->skipdct=0;
}
}
s->current_picture.qscale_table[xy] = best_s.qscale;
copy_context_after_encode(s, &best_s, -1);
pb_bits_count= put_bits_count(&s->pb);
flush_put_bits(&s->pb);
avpriv_copy_bits(&backup_s.pb, bit_buf[next_block^1], pb_bits_count);
s->pb= backup_s.pb;
if(s->data_partitioning){
pb2_bits_count= put_bits_count(&s->pb2);
flush_put_bits(&s->pb2);
avpriv_copy_bits(&backup_s.pb2, bit_buf2[next_block^1], pb2_bits_count);
s->pb2= backup_s.pb2;
tex_pb_bits_count= put_bits_count(&s->tex_pb);
flush_put_bits(&s->tex_pb);
avpriv_copy_bits(&backup_s.tex_pb, bit_buf_tex[next_block^1], tex_pb_bits_count);
s->tex_pb= backup_s.tex_pb;
}
s->last_bits= put_bits_count(&s->pb);
if (CONFIG_H263_ENCODER &&
s->out_format == FMT_H263 && s->pict_type!=AV_PICTURE_TYPE_B)
ff_h263_update_motion_val(s);
if(next_block==0){ //FIXME 16 vs linesize16
s->hdsp.put_pixels_tab[0][0](s->dest[0], s->rd_scratchpad , s->linesize ,16);
s->hdsp.put_pixels_tab[1][0](s->dest[1], s->rd_scratchpad + 16*s->linesize , s->uvlinesize, 8);
s->hdsp.put_pixels_tab[1][0](s->dest[2], s->rd_scratchpad + 16*s->linesize + 8, s->uvlinesize, 8);
}
if(s->avctx->mb_decision == FF_MB_DECISION_BITS)
ff_MPV_decode_mb(s, s->block);
} else {
int motion_x = 0, motion_y = 0;
s->mv_type=MV_TYPE_16X16;
// only one MB-Type possible
switch(mb_type){
case CANDIDATE_MB_TYPE_INTRA:
s->mv_dir = 0;
s->mb_intra= 1;
motion_x= s->mv[0][0][0] = 0;
motion_y= s->mv[0][0][1] = 0;
break;
case CANDIDATE_MB_TYPE_INTER:
s->mv_dir = MV_DIR_FORWARD;
s->mb_intra= 0;
motion_x= s->mv[0][0][0] = s->p_mv_table[xy][0];
motion_y= s->mv[0][0][1] = s->p_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_INTER_I:
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[0][i] = s->p_field_select_table[i][xy];
s->mv[0][i][0] = s->p_field_mv_table[i][j][xy][0];
s->mv[0][i][1] = s->p_field_mv_table[i][j][xy][1];
}
break;
case CANDIDATE_MB_TYPE_INTER4V:
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_8X8;
s->mb_intra= 0;
for(i=0; i<4; i++){
s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0];
s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1];
}
break;
case CANDIDATE_MB_TYPE_DIRECT:
if (CONFIG_MPEG4_ENCODER) {
s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD|MV_DIRECT;
s->mb_intra= 0;
motion_x=s->b_direct_mv_table[xy][0];
motion_y=s->b_direct_mv_table[xy][1];
ff_mpeg4_set_direct_mv(s, motion_x, motion_y);
}
break;
case CANDIDATE_MB_TYPE_DIRECT0:
if (CONFIG_MPEG4_ENCODER) {
s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD|MV_DIRECT;
s->mb_intra= 0;
ff_mpeg4_set_direct_mv(s, 0, 0);
}
break;
case CANDIDATE_MB_TYPE_BIDIR:
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mb_intra= 0;
s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1];
s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0];
s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_BACKWARD:
s->mv_dir = MV_DIR_BACKWARD;
s->mb_intra= 0;
motion_x= s->mv[1][0][0] = s->b_back_mv_table[xy][0];
motion_y= s->mv[1][0][1] = s->b_back_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_FORWARD:
s->mv_dir = MV_DIR_FORWARD;
s->mb_intra= 0;
motion_x= s->mv[0][0][0] = s->b_forw_mv_table[xy][0];
motion_y= s->mv[0][0][1] = s->b_forw_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_FORWARD_I:
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[0][i] = s->b_field_select_table[0][i][xy];
s->mv[0][i][0] = s->b_field_mv_table[0][i][j][xy][0];
s->mv[0][i][1] = s->b_field_mv_table[0][i][j][xy][1];
}
break;
case CANDIDATE_MB_TYPE_BACKWARD_I:
s->mv_dir = MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[1][i] = s->b_field_select_table[1][i][xy];
s->mv[1][i][0] = s->b_field_mv_table[1][i][j][xy][0];
s->mv[1][i][1] = s->b_field_mv_table[1][i][j][xy][1];
}
break;
case CANDIDATE_MB_TYPE_BIDIR_I:
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(dir=0; dir<2; dir++){
for(i=0; i<2; i++){
j= s->field_select[dir][i] = s->b_field_select_table[dir][i][xy];
s->mv[dir][i][0] = s->b_field_mv_table[dir][i][j][xy][0];
s->mv[dir][i][1] = s->b_field_mv_table[dir][i][j][xy][1];
}
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "illegal MB type\n");
}
encode_mb(s, motion_x, motion_y);
// RAL: Update last macroblock type
s->last_mv_dir = s->mv_dir;
if (CONFIG_H263_ENCODER &&
s->out_format == FMT_H263 && s->pict_type!=AV_PICTURE_TYPE_B)
ff_h263_update_motion_val(s);
ff_MPV_decode_mb(s, s->block);
}
/* clean the MV table in IPS frames for direct mode in B frames */
if(s->mb_intra /* && I,P,S_TYPE */){
s->p_mv_table[xy][0]=0;
s->p_mv_table[xy][1]=0;
}
if(s->flags&CODEC_FLAG_PSNR){
int w= 16;
int h= 16;
if(s->mb_x*16 + 16 > s->width ) w= s->width - s->mb_x*16;
if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16;
s->current_picture.f.error[0] += sse(
s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16,
s->dest[0], w, h, s->linesize);
s->current_picture.f.error[1] += sse(
s, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h,
s->dest[1], w>>1, h>>s->chroma_y_shift, s->uvlinesize);
s->current_picture.f.error[2] += sse(
s, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h,
s->dest[2], w>>1, h>>s->chroma_y_shift, s->uvlinesize);
}
if(s->loop_filter){
if(CONFIG_H263_ENCODER && s->out_format == FMT_H263)
ff_h263_loop_filter(s);
}
av_dlog(s->avctx, "MB %d %d bits\n",
s->mb_x + s->mb_y * s->mb_stride, put_bits_count(&s->pb));
}
}
//not beautiful here but we must write it before flushing so it has to be here
if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type == AV_PICTURE_TYPE_I)
ff_msmpeg4_encode_ext_header(s);
write_slice_end(s);
/* Send the last GOB if RTP */
if (s->avctx->rtp_callback) {
int number_mb = (mb_y - s->resync_mb_y)*s->mb_width - s->resync_mb_x;
pdif = put_bits_ptr(&s->pb) - s->ptr_lastgob;
/* Call the RTP callback to send the last GOB */
emms_c();
s->avctx->rtp_callback(s->avctx, s->ptr_lastgob, pdif, number_mb);
}
return 0;
}
| true | FFmpeg | f6774f905fb3cfdc319523ac640be30b14c1bc55 | static int encode_thread(AVCodecContext *c, void *arg){
MpegEncContext *s= *(void**)arg;
int mb_x, mb_y, pdif = 0;
int chr_h= 16>>s->chroma_y_shift;
int i, j;
MpegEncContext best_s, backup_s;
uint8_t bit_buf[2][MAX_MB_BYTES];
uint8_t bit_buf2[2][MAX_MB_BYTES];
uint8_t bit_buf_tex[2][MAX_MB_BYTES];
PutBitContext pb[2], pb2[2], tex_pb[2];
for(i=0; i<2; i++){
init_put_bits(&pb [i], bit_buf [i], MAX_MB_BYTES);
init_put_bits(&pb2 [i], bit_buf2 [i], MAX_MB_BYTES);
init_put_bits(&tex_pb[i], bit_buf_tex[i], MAX_MB_BYTES);
}
s->last_bits= put_bits_count(&s->pb);
s->mv_bits=0;
s->misc_bits=0;
s->i_tex_bits=0;
s->p_tex_bits=0;
s->i_count=0;
s->f_count=0;
s->b_count=0;
s->skip_count=0;
for(i=0; i<3; i++){
s->last_dc[i] = 128 << s->intra_dc_precision;
s->current_picture.f.error[i] = 0;
}
s->mb_skip_run = 0;
memset(s->last_mv, 0, sizeof(s->last_mv));
s->last_mv_dir = 0;
switch(s->codec_id){
case AV_CODEC_ID_H263:
case AV_CODEC_ID_H263P:
case AV_CODEC_ID_FLV1:
if (CONFIG_H263_ENCODER)
s->gob_index = ff_h263_get_gob_height(s);
break;
case AV_CODEC_ID_MPEG4:
if(CONFIG_MPEG4_ENCODER && s->partitioned_frame)
ff_mpeg4_init_partitions(s);
break;
}
s->resync_mb_x=0;
s->resync_mb_y=0;
s->first_slice_line = 1;
s->ptr_lastgob = s->pb.buf;
for(mb_y= s->start_mb_y; mb_y < s->end_mb_y; mb_y++) {
s->mb_x=0;
s->mb_y= mb_y;
ff_set_qscale(s, s->qscale);
ff_init_block_index(s);
for(mb_x=0; mb_x < s->mb_width; mb_x++) {
int xy= mb_y*s->mb_stride + mb_x;
int mb_type= s->mb_type[xy];
int dmin= INT_MAX;
int dir;
if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < MAX_MB_BYTES){
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
}
if(s->data_partitioning){
if( s->pb2 .buf_end - s->pb2 .buf - (put_bits_count(&s-> pb2)>>3) < MAX_MB_BYTES
|| s->tex_pb.buf_end - s->tex_pb.buf - (put_bits_count(&s->tex_pb )>>3) < MAX_MB_BYTES){
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
}
}
s->mb_x = mb_x;
s->mb_y = mb_y;
ff_update_block_index(s);
if(CONFIG_H261_ENCODER && s->codec_id == AV_CODEC_ID_H261){
ff_h261_reorder_mb_index(s);
xy= s->mb_y*s->mb_stride + s->mb_x;
mb_type= s->mb_type[xy];
}
if(s->rtp_mode){
int current_packet_size, is_gob_start;
current_packet_size= ((put_bits_count(&s->pb)+7)>>3) - (s->ptr_lastgob - s->pb.buf);
is_gob_start= s->avctx->rtp_payload_size && current_packet_size >= s->avctx->rtp_payload_size && mb_y + mb_x>0;
if(s->start_mb_y == mb_y && mb_y > 0 && mb_x==0) is_gob_start=1;
switch(s->codec_id){
case AV_CODEC_ID_H263:
case AV_CODEC_ID_H263P:
if(!s->h263_slice_structured)
if(s->mb_x || s->mb_y%s->gob_index) is_gob_start=0;
break;
case AV_CODEC_ID_MPEG2VIDEO:
if(s->mb_x==0 && s->mb_y!=0) is_gob_start=1;
case AV_CODEC_ID_MPEG1VIDEO:
if(s->mb_skip_run) is_gob_start=0;
break;
}
if(is_gob_start){
if(s->start_mb_y != mb_y || mb_x!=0){
write_slice_end(s);
if(CONFIG_MPEG4_ENCODER && s->codec_id==AV_CODEC_ID_MPEG4 && s->partitioned_frame){
ff_mpeg4_init_partitions(s);
}
}
assert((put_bits_count(&s->pb)&7) == 0);
current_packet_size= put_bits_ptr(&s->pb) - s->ptr_lastgob;
if (s->error_rate && s->resync_mb_x + s->resync_mb_y > 0) {
int r= put_bits_count(&s->pb)/8 + s->picture_number + 16 + s->mb_x + s->mb_y;
int d = 100 / s->error_rate;
if(r % d == 0){
current_packet_size=0;
s->pb.buf_ptr= s->ptr_lastgob;
assert(put_bits_ptr(&s->pb) == s->ptr_lastgob);
}
}
if (s->avctx->rtp_callback){
int number_mb = (mb_y - s->resync_mb_y)*s->mb_width + mb_x - s->resync_mb_x;
s->avctx->rtp_callback(s->avctx, s->ptr_lastgob, current_packet_size, number_mb);
}
update_mb_info(s, 1);
switch(s->codec_id){
case AV_CODEC_ID_MPEG4:
if (CONFIG_MPEG4_ENCODER) {
ff_mpeg4_encode_video_packet_header(s);
ff_mpeg4_clean_buffers(s);
}
break;
case AV_CODEC_ID_MPEG1VIDEO:
case AV_CODEC_ID_MPEG2VIDEO:
if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER) {
ff_mpeg1_encode_slice_header(s);
ff_mpeg1_clean_buffers(s);
}
break;
case AV_CODEC_ID_H263:
case AV_CODEC_ID_H263P:
if (CONFIG_H263_ENCODER)
ff_h263_encode_gob_header(s, mb_y);
break;
}
if(s->flags&CODEC_FLAG_PASS1){
int bits= put_bits_count(&s->pb);
s->misc_bits+= bits - s->last_bits;
s->last_bits= bits;
}
s->ptr_lastgob += current_packet_size;
s->first_slice_line=1;
s->resync_mb_x=mb_x;
s->resync_mb_y=mb_y;
}
}
if( (s->resync_mb_x == s->mb_x)
&& s->resync_mb_y+1 == s->mb_y){
s->first_slice_line=0;
}
s->mb_skipped=0;
s->dquant=0;
update_mb_info(s, 0);
if (mb_type & (mb_type-1) || (s->mpv_flags & FF_MPV_FLAG_QP_RD)) {
int next_block=0;
int pb_bits_count, pb2_bits_count, tex_pb_bits_count;
copy_context_before_encode(&backup_s, s, -1);
backup_s.pb= s->pb;
best_s.data_partitioning= s->data_partitioning;
best_s.partitioned_frame= s->partitioned_frame;
if(s->data_partitioning){
backup_s.pb2= s->pb2;
backup_s.tex_pb= s->tex_pb;
}
if(mb_type&CANDIDATE_MB_TYPE_INTER){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = s->p_mv_table[xy][0];
s->mv[0][0][1] = s->p_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_INTER_I){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[0][i] = s->p_field_select_table[i][xy];
s->mv[0][i][0] = s->p_field_mv_table[i][j][xy][0];
s->mv[0][i][1] = s->p_field_mv_table[i][j][xy][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_SKIPPED){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_SKIPPED, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_INTER4V){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_8X8;
s->mb_intra= 0;
for(i=0; i<4; i++){
s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0];
s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER4V, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_FORWARD){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = s->b_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_forw_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_BACKWARD){
s->mv_dir = MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[1][0][0] = s->b_back_mv_table[xy][0];
s->mv[1][0][1] = s->b_back_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[1][0][0], s->mv[1][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_BIDIR){
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1];
s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0];
s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_FORWARD_I){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[0][i] = s->b_field_select_table[0][i][xy];
s->mv[0][i][0] = s->b_field_mv_table[0][i][j][xy][0];
s->mv[0][i][1] = s->b_field_mv_table[0][i][j][xy][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_BACKWARD_I){
s->mv_dir = MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[1][i] = s->b_field_select_table[1][i][xy];
s->mv[1][i][0] = s->b_field_mv_table[1][i][j][xy][0];
s->mv[1][i][1] = s->b_field_mv_table[1][i][j][xy][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_BIDIR_I){
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(dir=0; dir<2; dir++){
for(i=0; i<2; i++){
j= s->field_select[dir][i] = s->b_field_select_table[dir][i][xy];
s->mv[dir][i][0] = s->b_field_mv_table[dir][i][j][xy][0];
s->mv[dir][i][1] = s->b_field_mv_table[dir][i][j][xy][1];
}
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_INTRA){
s->mv_dir = 0;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 1;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTRA, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
if(s->h263_pred || s->h263_aic){
if(best_s.mb_intra)
s->mbintra_table[mb_x + mb_y*s->mb_stride]=1;
else
ff_clean_intra_table_entries(s);
}
}
if ((s->mpv_flags & FF_MPV_FLAG_QP_RD) && dmin < INT_MAX) {
if(best_s.mv_type==MV_TYPE_16X16){
const int last_qp= backup_s.qscale;
int qpi, qp, dc[6];
int16_t ac[6][16];
const int mvdir= (best_s.mv_dir&MV_DIR_BACKWARD) ? 1 : 0;
static const int dquant_tab[4]={-1,1,-2,2};
assert(backup_s.dquant == 0);
s->mv_dir= best_s.mv_dir;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= best_s.mb_intra;
s->mv[0][0][0] = best_s.mv[0][0][0];
s->mv[0][0][1] = best_s.mv[0][0][1];
s->mv[1][0][0] = best_s.mv[1][0][0];
s->mv[1][0][1] = best_s.mv[1][0][1];
qpi = s->pict_type == AV_PICTURE_TYPE_B ? 2 : 0;
for(; qpi<4; qpi++){
int dquant= dquant_tab[qpi];
qp= last_qp + dquant;
if(qp < s->avctx->qmin || qp > s->avctx->qmax)
continue;
backup_s.dquant= dquant;
if(s->mb_intra && s->dc_val[0]){
for(i=0; i<6; i++){
dc[i]= s->dc_val[0][ s->block_index[i] ];
memcpy(ac[i], s->ac_val[0][s->block_index[i]], sizeof(int16_t)*16);
}
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER , pb, pb2, tex_pb,
&dmin, &next_block, s->mv[mvdir][0][0], s->mv[mvdir][0][1]);
if(best_s.qscale != qp){
if(s->mb_intra && s->dc_val[0]){
for(i=0; i<6; i++){
s->dc_val[0][ s->block_index[i] ]= dc[i];
memcpy(s->ac_val[0][s->block_index[i]], ac[i], sizeof(int16_t)*16);
}
}
}
}
}
}
if(CONFIG_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT){
int mx= s->b_direct_mv_table[xy][0];
int my= s->b_direct_mv_table[xy][1];
backup_s.dquant = 0;
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
s->mb_intra= 0;
ff_mpeg4_set_direct_mv(s, mx, my);
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,
&dmin, &next_block, mx, my);
}
if(CONFIG_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT0){
backup_s.dquant = 0;
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
s->mb_intra= 0;
ff_mpeg4_set_direct_mv(s, 0, 0);
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if (!best_s.mb_intra && s->mpv_flags & FF_MPV_FLAG_SKIP_RD) {
int coded=0;
for(i=0; i<6; i++)
coded |= s->block_last_index[i];
if(coded){
int mx,my;
memcpy(s->mv, best_s.mv, sizeof(s->mv));
if(CONFIG_MPEG4_ENCODER && best_s.mv_dir & MV_DIRECT){
mx=my=0;
ff_mpeg4_set_direct_mv(s, mx, my);
}else if(best_s.mv_dir&MV_DIR_BACKWARD){
mx= s->mv[1][0][0];
my= s->mv[1][0][1];
}else{
mx= s->mv[0][0][0];
my= s->mv[0][0][1];
}
s->mv_dir= best_s.mv_dir;
s->mv_type = best_s.mv_type;
s->mb_intra= 0;
backup_s.dquant= 0;
s->skipdct=1;
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER , pb, pb2, tex_pb,
&dmin, &next_block, mx, my);
s->skipdct=0;
}
}
s->current_picture.qscale_table[xy] = best_s.qscale;
copy_context_after_encode(s, &best_s, -1);
pb_bits_count= put_bits_count(&s->pb);
flush_put_bits(&s->pb);
avpriv_copy_bits(&backup_s.pb, bit_buf[next_block^1], pb_bits_count);
s->pb= backup_s.pb;
if(s->data_partitioning){
pb2_bits_count= put_bits_count(&s->pb2);
flush_put_bits(&s->pb2);
avpriv_copy_bits(&backup_s.pb2, bit_buf2[next_block^1], pb2_bits_count);
s->pb2= backup_s.pb2;
tex_pb_bits_count= put_bits_count(&s->tex_pb);
flush_put_bits(&s->tex_pb);
avpriv_copy_bits(&backup_s.tex_pb, bit_buf_tex[next_block^1], tex_pb_bits_count);
s->tex_pb= backup_s.tex_pb;
}
s->last_bits= put_bits_count(&s->pb);
if (CONFIG_H263_ENCODER &&
s->out_format == FMT_H263 && s->pict_type!=AV_PICTURE_TYPE_B)
ff_h263_update_motion_val(s);
if(next_block==0){
s->hdsp.put_pixels_tab[0][0](s->dest[0], s->rd_scratchpad , s->linesize ,16);
s->hdsp.put_pixels_tab[1][0](s->dest[1], s->rd_scratchpad + 16*s->linesize , s->uvlinesize, 8);
s->hdsp.put_pixels_tab[1][0](s->dest[2], s->rd_scratchpad + 16*s->linesize + 8, s->uvlinesize, 8);
}
if(s->avctx->mb_decision == FF_MB_DECISION_BITS)
ff_MPV_decode_mb(s, s->block);
} else {
int motion_x = 0, motion_y = 0;
s->mv_type=MV_TYPE_16X16;
switch(mb_type){
case CANDIDATE_MB_TYPE_INTRA:
s->mv_dir = 0;
s->mb_intra= 1;
motion_x= s->mv[0][0][0] = 0;
motion_y= s->mv[0][0][1] = 0;
break;
case CANDIDATE_MB_TYPE_INTER:
s->mv_dir = MV_DIR_FORWARD;
s->mb_intra= 0;
motion_x= s->mv[0][0][0] = s->p_mv_table[xy][0];
motion_y= s->mv[0][0][1] = s->p_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_INTER_I:
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[0][i] = s->p_field_select_table[i][xy];
s->mv[0][i][0] = s->p_field_mv_table[i][j][xy][0];
s->mv[0][i][1] = s->p_field_mv_table[i][j][xy][1];
}
break;
case CANDIDATE_MB_TYPE_INTER4V:
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_8X8;
s->mb_intra= 0;
for(i=0; i<4; i++){
s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0];
s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1];
}
break;
case CANDIDATE_MB_TYPE_DIRECT:
if (CONFIG_MPEG4_ENCODER) {
s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD|MV_DIRECT;
s->mb_intra= 0;
motion_x=s->b_direct_mv_table[xy][0];
motion_y=s->b_direct_mv_table[xy][1];
ff_mpeg4_set_direct_mv(s, motion_x, motion_y);
}
break;
case CANDIDATE_MB_TYPE_DIRECT0:
if (CONFIG_MPEG4_ENCODER) {
s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD|MV_DIRECT;
s->mb_intra= 0;
ff_mpeg4_set_direct_mv(s, 0, 0);
}
break;
case CANDIDATE_MB_TYPE_BIDIR:
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mb_intra= 0;
s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1];
s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0];
s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_BACKWARD:
s->mv_dir = MV_DIR_BACKWARD;
s->mb_intra= 0;
motion_x= s->mv[1][0][0] = s->b_back_mv_table[xy][0];
motion_y= s->mv[1][0][1] = s->b_back_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_FORWARD:
s->mv_dir = MV_DIR_FORWARD;
s->mb_intra= 0;
motion_x= s->mv[0][0][0] = s->b_forw_mv_table[xy][0];
motion_y= s->mv[0][0][1] = s->b_forw_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_FORWARD_I:
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[0][i] = s->b_field_select_table[0][i][xy];
s->mv[0][i][0] = s->b_field_mv_table[0][i][j][xy][0];
s->mv[0][i][1] = s->b_field_mv_table[0][i][j][xy][1];
}
break;
case CANDIDATE_MB_TYPE_BACKWARD_I:
s->mv_dir = MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(i=0; i<2; i++){
j= s->field_select[1][i] = s->b_field_select_table[1][i][xy];
s->mv[1][i][0] = s->b_field_mv_table[1][i][j][xy][0];
s->mv[1][i][1] = s->b_field_mv_table[1][i][j][xy][1];
}
break;
case CANDIDATE_MB_TYPE_BIDIR_I:
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(dir=0; dir<2; dir++){
for(i=0; i<2; i++){
j= s->field_select[dir][i] = s->b_field_select_table[dir][i][xy];
s->mv[dir][i][0] = s->b_field_mv_table[dir][i][j][xy][0];
s->mv[dir][i][1] = s->b_field_mv_table[dir][i][j][xy][1];
}
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "illegal MB type\n");
}
encode_mb(s, motion_x, motion_y);
s->last_mv_dir = s->mv_dir;
if (CONFIG_H263_ENCODER &&
s->out_format == FMT_H263 && s->pict_type!=AV_PICTURE_TYPE_B)
ff_h263_update_motion_val(s);
ff_MPV_decode_mb(s, s->block);
}
if(s->mb_intra ){
s->p_mv_table[xy][0]=0;
s->p_mv_table[xy][1]=0;
}
if(s->flags&CODEC_FLAG_PSNR){
int w= 16;
int h= 16;
if(s->mb_x*16 + 16 > s->width ) w= s->width - s->mb_x*16;
if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16;
s->current_picture.f.error[0] += sse(
s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16,
s->dest[0], w, h, s->linesize);
s->current_picture.f.error[1] += sse(
s, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h,
s->dest[1], w>>1, h>>s->chroma_y_shift, s->uvlinesize);
s->current_picture.f.error[2] += sse(
s, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h,
s->dest[2], w>>1, h>>s->chroma_y_shift, s->uvlinesize);
}
if(s->loop_filter){
if(CONFIG_H263_ENCODER && s->out_format == FMT_H263)
ff_h263_loop_filter(s);
}
av_dlog(s->avctx, "MB %d %d bits\n",
s->mb_x + s->mb_y * s->mb_stride, put_bits_count(&s->pb));
}
}
if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type == AV_PICTURE_TYPE_I)
ff_msmpeg4_encode_ext_header(s);
write_slice_end(s);
if (s->avctx->rtp_callback) {
int number_mb = (mb_y - s->resync_mb_y)*s->mb_width - s->resync_mb_x;
pdif = put_bits_ptr(&s->pb) - s->ptr_lastgob;
emms_c();
s->avctx->rtp_callback(s->avctx, s->ptr_lastgob, pdif, number_mb);
}
return 0;
}
| {
"code": [
" s->current_picture.f.error[i] = 0;",
" s->current_picture.f.error[0] += sse(",
" s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16,",
" s->current_picture.f.error[1] += sse(",
" s, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h,",
" s->current_picture.f.error[2] += sse(",
" s, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h,"
],
"line_no": [
65,
1181,
1183,
1187,
1189,
1193,
1195
]
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1){
MpegEncContext *s= *(void**)VAR_1;
int VAR_2, VAR_3, VAR_4 = 0;
int VAR_5= 16>>s->chroma_y_shift;
int VAR_6, VAR_7;
MpegEncContext best_s, backup_s;
uint8_t bit_buf[2][MAX_MB_BYTES];
uint8_t bit_buf2[2][MAX_MB_BYTES];
uint8_t bit_buf_tex[2][MAX_MB_BYTES];
PutBitContext pb[2], pb2[2], tex_pb[2];
for(VAR_6=0; VAR_6<2; VAR_6++){
init_put_bits(&pb [VAR_6], bit_buf [VAR_6], MAX_MB_BYTES);
init_put_bits(&pb2 [VAR_6], bit_buf2 [VAR_6], MAX_MB_BYTES);
init_put_bits(&tex_pb[VAR_6], bit_buf_tex[VAR_6], MAX_MB_BYTES);
}
s->last_bits= put_bits_count(&s->pb);
s->mv_bits=0;
s->misc_bits=0;
s->i_tex_bits=0;
s->p_tex_bits=0;
s->i_count=0;
s->f_count=0;
s->b_count=0;
s->skip_count=0;
for(VAR_6=0; VAR_6<3; VAR_6++){
s->last_dc[VAR_6] = 128 << s->intra_dc_precision;
s->current_picture.f.error[VAR_6] = 0;
}
s->mb_skip_run = 0;
memset(s->last_mv, 0, sizeof(s->last_mv));
s->last_mv_dir = 0;
switch(s->codec_id){
case AV_CODEC_ID_H263:
case AV_CODEC_ID_H263P:
case AV_CODEC_ID_FLV1:
if (CONFIG_H263_ENCODER)
s->gob_index = ff_h263_get_gob_height(s);
break;
case AV_CODEC_ID_MPEG4:
if(CONFIG_MPEG4_ENCODER && s->partitioned_frame)
ff_mpeg4_init_partitions(s);
break;
}
s->resync_mb_x=0;
s->resync_mb_y=0;
s->first_slice_line = 1;
s->ptr_lastgob = s->pb.buf;
for(VAR_3= s->start_mb_y; VAR_3 < s->end_mb_y; VAR_3++) {
s->VAR_2=0;
s->VAR_3= VAR_3;
ff_set_qscale(s, s->qscale);
ff_init_block_index(s);
for(VAR_2=0; VAR_2 < s->mb_width; VAR_2++) {
int xy= VAR_3*s->mb_stride + VAR_2;
int mb_type= s->mb_type[xy];
int dmin= INT_MAX;
int dir;
if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < MAX_MB_BYTES){
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
}
if(s->data_partitioning){
if( s->pb2 .buf_end - s->pb2 .buf - (put_bits_count(&s-> pb2)>>3) < MAX_MB_BYTES
|| s->tex_pb.buf_end - s->tex_pb.buf - (put_bits_count(&s->tex_pb )>>3) < MAX_MB_BYTES){
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
}
}
s->VAR_2 = VAR_2;
s->VAR_3 = VAR_3;
ff_update_block_index(s);
if(CONFIG_H261_ENCODER && s->codec_id == AV_CODEC_ID_H261){
ff_h261_reorder_mb_index(s);
xy= s->VAR_3*s->mb_stride + s->VAR_2;
mb_type= s->mb_type[xy];
}
if(s->rtp_mode){
int current_packet_size, is_gob_start;
current_packet_size= ((put_bits_count(&s->pb)+7)>>3) - (s->ptr_lastgob - s->pb.buf);
is_gob_start= s->avctx->rtp_payload_size && current_packet_size >= s->avctx->rtp_payload_size && VAR_3 + VAR_2>0;
if(s->start_mb_y == VAR_3 && VAR_3 > 0 && VAR_2==0) is_gob_start=1;
switch(s->codec_id){
case AV_CODEC_ID_H263:
case AV_CODEC_ID_H263P:
if(!s->h263_slice_structured)
if(s->VAR_2 || s->VAR_3%s->gob_index) is_gob_start=0;
break;
case AV_CODEC_ID_MPEG2VIDEO:
if(s->VAR_2==0 && s->VAR_3!=0) is_gob_start=1;
case AV_CODEC_ID_MPEG1VIDEO:
if(s->mb_skip_run) is_gob_start=0;
break;
}
if(is_gob_start){
if(s->start_mb_y != VAR_3 || VAR_2!=0){
write_slice_end(s);
if(CONFIG_MPEG4_ENCODER && s->codec_id==AV_CODEC_ID_MPEG4 && s->partitioned_frame){
ff_mpeg4_init_partitions(s);
}
}
assert((put_bits_count(&s->pb)&7) == 0);
current_packet_size= put_bits_ptr(&s->pb) - s->ptr_lastgob;
if (s->error_rate && s->resync_mb_x + s->resync_mb_y > 0) {
int r= put_bits_count(&s->pb)/8 + s->picture_number + 16 + s->VAR_2 + s->VAR_3;
int d = 100 / s->error_rate;
if(r % d == 0){
current_packet_size=0;
s->pb.buf_ptr= s->ptr_lastgob;
assert(put_bits_ptr(&s->pb) == s->ptr_lastgob);
}
}
if (s->avctx->rtp_callback){
int VAR_8 = (VAR_3 - s->resync_mb_y)*s->mb_width + VAR_2 - s->resync_mb_x;
s->avctx->rtp_callback(s->avctx, s->ptr_lastgob, current_packet_size, VAR_8);
}
update_mb_info(s, 1);
switch(s->codec_id){
case AV_CODEC_ID_MPEG4:
if (CONFIG_MPEG4_ENCODER) {
ff_mpeg4_encode_video_packet_header(s);
ff_mpeg4_clean_buffers(s);
}
break;
case AV_CODEC_ID_MPEG1VIDEO:
case AV_CODEC_ID_MPEG2VIDEO:
if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER) {
ff_mpeg1_encode_slice_header(s);
ff_mpeg1_clean_buffers(s);
}
break;
case AV_CODEC_ID_H263:
case AV_CODEC_ID_H263P:
if (CONFIG_H263_ENCODER)
ff_h263_encode_gob_header(s, VAR_3);
break;
}
if(s->flags&CODEC_FLAG_PASS1){
int bits= put_bits_count(&s->pb);
s->misc_bits+= bits - s->last_bits;
s->last_bits= bits;
}
s->ptr_lastgob += current_packet_size;
s->first_slice_line=1;
s->resync_mb_x=VAR_2;
s->resync_mb_y=VAR_3;
}
}
if( (s->resync_mb_x == s->VAR_2)
&& s->resync_mb_y+1 == s->VAR_3){
s->first_slice_line=0;
}
s->mb_skipped=0;
s->dquant=0;
update_mb_info(s, 0);
if (mb_type & (mb_type-1) || (s->mpv_flags & FF_MPV_FLAG_QP_RD)) {
int next_block=0;
int pb_bits_count, pb2_bits_count, tex_pb_bits_count;
copy_context_before_encode(&backup_s, s, -1);
backup_s.pb= s->pb;
best_s.data_partitioning= s->data_partitioning;
best_s.partitioned_frame= s->partitioned_frame;
if(s->data_partitioning){
backup_s.pb2= s->pb2;
backup_s.tex_pb= s->tex_pb;
}
if(mb_type&CANDIDATE_MB_TYPE_INTER){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = s->p_mv_table[xy][0];
s->mv[0][0][1] = s->p_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_INTER_I){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(VAR_6=0; VAR_6<2; VAR_6++){
VAR_7= s->field_select[0][VAR_6] = s->p_field_select_table[VAR_6][xy];
s->mv[0][VAR_6][0] = s->p_field_mv_table[VAR_6][VAR_7][xy][0];
s->mv[0][VAR_6][1] = s->p_field_mv_table[VAR_6][VAR_7][xy][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_SKIPPED){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_SKIPPED, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_INTER4V){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_8X8;
s->mb_intra= 0;
for(VAR_6=0; VAR_6<4; VAR_6++){
s->mv[0][VAR_6][0] = s->current_picture.motion_val[0][s->block_index[VAR_6]][0];
s->mv[0][VAR_6][1] = s->current_picture.motion_val[0][s->block_index[VAR_6]][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER4V, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_FORWARD){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = s->b_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_forw_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_BACKWARD){
s->mv_dir = MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[1][0][0] = s->b_back_mv_table[xy][0];
s->mv[1][0][1] = s->b_back_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[1][0][0], s->mv[1][0][1]);
}
if(mb_type&CANDIDATE_MB_TYPE_BIDIR){
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1];
s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0];
s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_FORWARD_I){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(VAR_6=0; VAR_6<2; VAR_6++){
VAR_7= s->field_select[0][VAR_6] = s->b_field_select_table[0][VAR_6][xy];
s->mv[0][VAR_6][0] = s->b_field_mv_table[0][VAR_6][VAR_7][xy][0];
s->mv[0][VAR_6][1] = s->b_field_mv_table[0][VAR_6][VAR_7][xy][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_BACKWARD_I){
s->mv_dir = MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(VAR_6=0; VAR_6<2; VAR_6++){
VAR_7= s->field_select[1][VAR_6] = s->b_field_select_table[1][VAR_6][xy];
s->mv[1][VAR_6][0] = s->b_field_mv_table[1][VAR_6][VAR_7][xy][0];
s->mv[1][VAR_6][1] = s->b_field_mv_table[1][VAR_6][VAR_7][xy][1];
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_BIDIR_I){
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(dir=0; dir<2; dir++){
for(VAR_6=0; VAR_6<2; VAR_6++){
VAR_7= s->field_select[dir][VAR_6] = s->b_field_select_table[dir][VAR_6][xy];
s->mv[dir][VAR_6][0] = s->b_field_mv_table[dir][VAR_6][VAR_7][xy][0];
s->mv[dir][VAR_6][1] = s->b_field_mv_table[dir][VAR_6][VAR_7][xy][1];
}
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR_I, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&CANDIDATE_MB_TYPE_INTRA){
s->mv_dir = 0;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 1;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTRA, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
if(s->h263_pred || s->h263_aic){
if(best_s.mb_intra)
s->mbintra_table[VAR_2 + VAR_3*s->mb_stride]=1;
else
ff_clean_intra_table_entries(s);
}
}
if ((s->mpv_flags & FF_MPV_FLAG_QP_RD) && dmin < INT_MAX) {
if(best_s.mv_type==MV_TYPE_16X16){
const int last_qp= backup_s.qscale;
int qpi, qp, dc[6];
int16_t ac[6][16];
const int mvdir= (best_s.mv_dir&MV_DIR_BACKWARD) ? 1 : 0;
static const int dquant_tab[4]={-1,1,-2,2};
assert(backup_s.dquant == 0);
s->mv_dir= best_s.mv_dir;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= best_s.mb_intra;
s->mv[0][0][0] = best_s.mv[0][0][0];
s->mv[0][0][1] = best_s.mv[0][0][1];
s->mv[1][0][0] = best_s.mv[1][0][0];
s->mv[1][0][1] = best_s.mv[1][0][1];
qpi = s->pict_type == AV_PICTURE_TYPE_B ? 2 : 0;
for(; qpi<4; qpi++){
int dquant= dquant_tab[qpi];
qp= last_qp + dquant;
if(qp < s->avctx->qmin || qp > s->avctx->qmax)
continue;
backup_s.dquant= dquant;
if(s->mb_intra && s->dc_val[0]){
for(VAR_6=0; VAR_6<6; VAR_6++){
dc[VAR_6]= s->dc_val[0][ s->block_index[VAR_6] ];
memcpy(ac[VAR_6], s->ac_val[0][s->block_index[VAR_6]], sizeof(int16_t)*16);
}
}
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER , pb, pb2, tex_pb,
&dmin, &next_block, s->mv[mvdir][0][0], s->mv[mvdir][0][1]);
if(best_s.qscale != qp){
if(s->mb_intra && s->dc_val[0]){
for(VAR_6=0; VAR_6<6; VAR_6++){
s->dc_val[0][ s->block_index[VAR_6] ]= dc[VAR_6];
memcpy(s->ac_val[0][s->block_index[VAR_6]], ac[VAR_6], sizeof(int16_t)*16);
}
}
}
}
}
}
if(CONFIG_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT){
int mx= s->b_direct_mv_table[xy][0];
int my= s->b_direct_mv_table[xy][1];
backup_s.dquant = 0;
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
s->mb_intra= 0;
ff_mpeg4_set_direct_mv(s, mx, my);
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,
&dmin, &next_block, mx, my);
}
if(CONFIG_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT0){
backup_s.dquant = 0;
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
s->mb_intra= 0;
ff_mpeg4_set_direct_mv(s, 0, 0);
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if (!best_s.mb_intra && s->mpv_flags & FF_MPV_FLAG_SKIP_RD) {
int coded=0;
for(VAR_6=0; VAR_6<6; VAR_6++)
coded |= s->block_last_index[VAR_6];
if(coded){
int mx,my;
memcpy(s->mv, best_s.mv, sizeof(s->mv));
if(CONFIG_MPEG4_ENCODER && best_s.mv_dir & MV_DIRECT){
mx=my=0;
ff_mpeg4_set_direct_mv(s, mx, my);
}else if(best_s.mv_dir&MV_DIR_BACKWARD){
mx= s->mv[1][0][0];
my= s->mv[1][0][1];
}else{
mx= s->mv[0][0][0];
my= s->mv[0][0][1];
}
s->mv_dir= best_s.mv_dir;
s->mv_type = best_s.mv_type;
s->mb_intra= 0;
backup_s.dquant= 0;
s->skipdct=1;
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER , pb, pb2, tex_pb,
&dmin, &next_block, mx, my);
s->skipdct=0;
}
}
s->current_picture.qscale_table[xy] = best_s.qscale;
copy_context_after_encode(s, &best_s, -1);
pb_bits_count= put_bits_count(&s->pb);
flush_put_bits(&s->pb);
avpriv_copy_bits(&backup_s.pb, bit_buf[next_block^1], pb_bits_count);
s->pb= backup_s.pb;
if(s->data_partitioning){
pb2_bits_count= put_bits_count(&s->pb2);
flush_put_bits(&s->pb2);
avpriv_copy_bits(&backup_s.pb2, bit_buf2[next_block^1], pb2_bits_count);
s->pb2= backup_s.pb2;
tex_pb_bits_count= put_bits_count(&s->tex_pb);
flush_put_bits(&s->tex_pb);
avpriv_copy_bits(&backup_s.tex_pb, bit_buf_tex[next_block^1], tex_pb_bits_count);
s->tex_pb= backup_s.tex_pb;
}
s->last_bits= put_bits_count(&s->pb);
if (CONFIG_H263_ENCODER &&
s->out_format == FMT_H263 && s->pict_type!=AV_PICTURE_TYPE_B)
ff_h263_update_motion_val(s);
if(next_block==0){
s->hdsp.put_pixels_tab[0][0](s->dest[0], s->rd_scratchpad , s->linesize ,16);
s->hdsp.put_pixels_tab[1][0](s->dest[1], s->rd_scratchpad + 16*s->linesize , s->uvlinesize, 8);
s->hdsp.put_pixels_tab[1][0](s->dest[2], s->rd_scratchpad + 16*s->linesize + 8, s->uvlinesize, 8);
}
if(s->avctx->mb_decision == FF_MB_DECISION_BITS)
ff_MPV_decode_mb(s, s->block);
} else {
int motion_x = 0, motion_y = 0;
s->mv_type=MV_TYPE_16X16;
switch(mb_type){
case CANDIDATE_MB_TYPE_INTRA:
s->mv_dir = 0;
s->mb_intra= 1;
motion_x= s->mv[0][0][0] = 0;
motion_y= s->mv[0][0][1] = 0;
break;
case CANDIDATE_MB_TYPE_INTER:
s->mv_dir = MV_DIR_FORWARD;
s->mb_intra= 0;
motion_x= s->mv[0][0][0] = s->p_mv_table[xy][0];
motion_y= s->mv[0][0][1] = s->p_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_INTER_I:
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(VAR_6=0; VAR_6<2; VAR_6++){
VAR_7= s->field_select[0][VAR_6] = s->p_field_select_table[VAR_6][xy];
s->mv[0][VAR_6][0] = s->p_field_mv_table[VAR_6][VAR_7][xy][0];
s->mv[0][VAR_6][1] = s->p_field_mv_table[VAR_6][VAR_7][xy][1];
}
break;
case CANDIDATE_MB_TYPE_INTER4V:
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_8X8;
s->mb_intra= 0;
for(VAR_6=0; VAR_6<4; VAR_6++){
s->mv[0][VAR_6][0] = s->current_picture.motion_val[0][s->block_index[VAR_6]][0];
s->mv[0][VAR_6][1] = s->current_picture.motion_val[0][s->block_index[VAR_6]][1];
}
break;
case CANDIDATE_MB_TYPE_DIRECT:
if (CONFIG_MPEG4_ENCODER) {
s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD|MV_DIRECT;
s->mb_intra= 0;
motion_x=s->b_direct_mv_table[xy][0];
motion_y=s->b_direct_mv_table[xy][1];
ff_mpeg4_set_direct_mv(s, motion_x, motion_y);
}
break;
case CANDIDATE_MB_TYPE_DIRECT0:
if (CONFIG_MPEG4_ENCODER) {
s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD|MV_DIRECT;
s->mb_intra= 0;
ff_mpeg4_set_direct_mv(s, 0, 0);
}
break;
case CANDIDATE_MB_TYPE_BIDIR:
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mb_intra= 0;
s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1];
s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0];
s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_BACKWARD:
s->mv_dir = MV_DIR_BACKWARD;
s->mb_intra= 0;
motion_x= s->mv[1][0][0] = s->b_back_mv_table[xy][0];
motion_y= s->mv[1][0][1] = s->b_back_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_FORWARD:
s->mv_dir = MV_DIR_FORWARD;
s->mb_intra= 0;
motion_x= s->mv[0][0][0] = s->b_forw_mv_table[xy][0];
motion_y= s->mv[0][0][1] = s->b_forw_mv_table[xy][1];
break;
case CANDIDATE_MB_TYPE_FORWARD_I:
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(VAR_6=0; VAR_6<2; VAR_6++){
VAR_7= s->field_select[0][VAR_6] = s->b_field_select_table[0][VAR_6][xy];
s->mv[0][VAR_6][0] = s->b_field_mv_table[0][VAR_6][VAR_7][xy][0];
s->mv[0][VAR_6][1] = s->b_field_mv_table[0][VAR_6][VAR_7][xy][1];
}
break;
case CANDIDATE_MB_TYPE_BACKWARD_I:
s->mv_dir = MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(VAR_6=0; VAR_6<2; VAR_6++){
VAR_7= s->field_select[1][VAR_6] = s->b_field_select_table[1][VAR_6][xy];
s->mv[1][VAR_6][0] = s->b_field_mv_table[1][VAR_6][VAR_7][xy][0];
s->mv[1][VAR_6][1] = s->b_field_mv_table[1][VAR_6][VAR_7][xy][1];
}
break;
case CANDIDATE_MB_TYPE_BIDIR_I:
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_FIELD;
s->mb_intra= 0;
for(dir=0; dir<2; dir++){
for(VAR_6=0; VAR_6<2; VAR_6++){
VAR_7= s->field_select[dir][VAR_6] = s->b_field_select_table[dir][VAR_6][xy];
s->mv[dir][VAR_6][0] = s->b_field_mv_table[dir][VAR_6][VAR_7][xy][0];
s->mv[dir][VAR_6][1] = s->b_field_mv_table[dir][VAR_6][VAR_7][xy][1];
}
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "illegal MB type\n");
}
encode_mb(s, motion_x, motion_y);
s->last_mv_dir = s->mv_dir;
if (CONFIG_H263_ENCODER &&
s->out_format == FMT_H263 && s->pict_type!=AV_PICTURE_TYPE_B)
ff_h263_update_motion_val(s);
ff_MPV_decode_mb(s, s->block);
}
if(s->mb_intra ){
s->p_mv_table[xy][0]=0;
s->p_mv_table[xy][1]=0;
}
if(s->flags&CODEC_FLAG_PSNR){
int w= 16;
int h= 16;
if(s->VAR_2*16 + 16 > s->width ) w= s->width - s->VAR_2*16;
if(s->VAR_3*16 + 16 > s->height) h= s->height- s->VAR_3*16;
s->current_picture.f.error[0] += sse(
s, s->new_picture.f.data[0] + s->VAR_2*16 + s->VAR_3*s->linesize*16,
s->dest[0], w, h, s->linesize);
s->current_picture.f.error[1] += sse(
s, s->new_picture.f.data[1] + s->VAR_2*8 + s->VAR_3*s->uvlinesize*VAR_5,
s->dest[1], w>>1, h>>s->chroma_y_shift, s->uvlinesize);
s->current_picture.f.error[2] += sse(
s, s->new_picture.f.data[2] + s->VAR_2*8 + s->VAR_3*s->uvlinesize*VAR_5,
s->dest[2], w>>1, h>>s->chroma_y_shift, s->uvlinesize);
}
if(s->loop_filter){
if(CONFIG_H263_ENCODER && s->out_format == FMT_H263)
ff_h263_loop_filter(s);
}
av_dlog(s->avctx, "MB %d %d bits\n",
s->VAR_2 + s->VAR_3 * s->mb_stride, put_bits_count(&s->pb));
}
}
if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type == AV_PICTURE_TYPE_I)
ff_msmpeg4_encode_ext_header(s);
write_slice_end(s);
if (s->avctx->rtp_callback) {
int VAR_8 = (VAR_3 - s->resync_mb_y)*s->mb_width - s->resync_mb_x;
VAR_4 = put_bits_ptr(&s->pb) - s->ptr_lastgob;
emms_c();
s->avctx->rtp_callback(s->avctx, s->ptr_lastgob, VAR_4, VAR_8);
}
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1){",
"MpegEncContext *s= *(void**)VAR_1;",
"int VAR_2, VAR_3, VAR_4 = 0;",
"int VAR_5= 16>>s->chroma_y_shift;",
"int VAR_6, VAR_7;",
"MpegEncContext best_s, backup_s;",
"uint8_t bit_buf[2][MAX_MB_BYTES];",
"uint8_t bit_buf2[2][MAX_MB_BYTES];",
"uint8_t bit_buf_tex[2][MAX_MB_BYTES];",
"PutBitContext pb[2], pb2[2], tex_pb[2];",
"for(VAR_6=0; VAR_6<2; VAR_6++){",
"init_put_bits(&pb [VAR_6], bit_buf [VAR_6], MAX_MB_BYTES);",
"init_put_bits(&pb2 [VAR_6], bit_buf2 [VAR_6], MAX_MB_BYTES);",
"init_put_bits(&tex_pb[VAR_6], bit_buf_tex[VAR_6], MAX_MB_BYTES);",
"}",
"s->last_bits= put_bits_count(&s->pb);",
"s->mv_bits=0;",
"s->misc_bits=0;",
"s->i_tex_bits=0;",
"s->p_tex_bits=0;",
"s->i_count=0;",
"s->f_count=0;",
"s->b_count=0;",
"s->skip_count=0;",
"for(VAR_6=0; VAR_6<3; VAR_6++){",
"s->last_dc[VAR_6] = 128 << s->intra_dc_precision;",
"s->current_picture.f.error[VAR_6] = 0;",
"}",
"s->mb_skip_run = 0;",
"memset(s->last_mv, 0, sizeof(s->last_mv));",
"s->last_mv_dir = 0;",
"switch(s->codec_id){",
"case AV_CODEC_ID_H263:\ncase AV_CODEC_ID_H263P:\ncase AV_CODEC_ID_FLV1:\nif (CONFIG_H263_ENCODER)\ns->gob_index = ff_h263_get_gob_height(s);",
"break;",
"case AV_CODEC_ID_MPEG4:\nif(CONFIG_MPEG4_ENCODER && s->partitioned_frame)\nff_mpeg4_init_partitions(s);",
"break;",
"}",
"s->resync_mb_x=0;",
"s->resync_mb_y=0;",
"s->first_slice_line = 1;",
"s->ptr_lastgob = s->pb.buf;",
"for(VAR_3= s->start_mb_y; VAR_3 < s->end_mb_y; VAR_3++) {",
"s->VAR_2=0;",
"s->VAR_3= VAR_3;",
"ff_set_qscale(s, s->qscale);",
"ff_init_block_index(s);",
"for(VAR_2=0; VAR_2 < s->mb_width; VAR_2++) {",
"int xy= VAR_3*s->mb_stride + VAR_2;",
"int mb_type= s->mb_type[xy];",
"int dmin= INT_MAX;",
"int dir;",
"if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < MAX_MB_BYTES){",
"av_log(s->avctx, AV_LOG_ERROR, \"encoded frame too large\\n\");",
"return -1;",
"}",
"if(s->data_partitioning){",
"if( s->pb2 .buf_end - s->pb2 .buf - (put_bits_count(&s-> pb2)>>3) < MAX_MB_BYTES\n|| s->tex_pb.buf_end - s->tex_pb.buf - (put_bits_count(&s->tex_pb )>>3) < MAX_MB_BYTES){",
"av_log(s->avctx, AV_LOG_ERROR, \"encoded frame too large\\n\");",
"return -1;",
"}",
"}",
"s->VAR_2 = VAR_2;",
"s->VAR_3 = VAR_3;",
"ff_update_block_index(s);",
"if(CONFIG_H261_ENCODER && s->codec_id == AV_CODEC_ID_H261){",
"ff_h261_reorder_mb_index(s);",
"xy= s->VAR_3*s->mb_stride + s->VAR_2;",
"mb_type= s->mb_type[xy];",
"}",
"if(s->rtp_mode){",
"int current_packet_size, is_gob_start;",
"current_packet_size= ((put_bits_count(&s->pb)+7)>>3) - (s->ptr_lastgob - s->pb.buf);",
"is_gob_start= s->avctx->rtp_payload_size && current_packet_size >= s->avctx->rtp_payload_size && VAR_3 + VAR_2>0;",
"if(s->start_mb_y == VAR_3 && VAR_3 > 0 && VAR_2==0) is_gob_start=1;",
"switch(s->codec_id){",
"case AV_CODEC_ID_H263:\ncase AV_CODEC_ID_H263P:\nif(!s->h263_slice_structured)\nif(s->VAR_2 || s->VAR_3%s->gob_index) is_gob_start=0;",
"break;",
"case AV_CODEC_ID_MPEG2VIDEO:\nif(s->VAR_2==0 && s->VAR_3!=0) is_gob_start=1;",
"case AV_CODEC_ID_MPEG1VIDEO:\nif(s->mb_skip_run) is_gob_start=0;",
"break;",
"}",
"if(is_gob_start){",
"if(s->start_mb_y != VAR_3 || VAR_2!=0){",
"write_slice_end(s);",
"if(CONFIG_MPEG4_ENCODER && s->codec_id==AV_CODEC_ID_MPEG4 && s->partitioned_frame){",
"ff_mpeg4_init_partitions(s);",
"}",
"}",
"assert((put_bits_count(&s->pb)&7) == 0);",
"current_packet_size= put_bits_ptr(&s->pb) - s->ptr_lastgob;",
"if (s->error_rate && s->resync_mb_x + s->resync_mb_y > 0) {",
"int r= put_bits_count(&s->pb)/8 + s->picture_number + 16 + s->VAR_2 + s->VAR_3;",
"int d = 100 / s->error_rate;",
"if(r % d == 0){",
"current_packet_size=0;",
"s->pb.buf_ptr= s->ptr_lastgob;",
"assert(put_bits_ptr(&s->pb) == s->ptr_lastgob);",
"}",
"}",
"if (s->avctx->rtp_callback){",
"int VAR_8 = (VAR_3 - s->resync_mb_y)*s->mb_width + VAR_2 - s->resync_mb_x;",
"s->avctx->rtp_callback(s->avctx, s->ptr_lastgob, current_packet_size, VAR_8);",
"}",
"update_mb_info(s, 1);",
"switch(s->codec_id){",
"case AV_CODEC_ID_MPEG4:\nif (CONFIG_MPEG4_ENCODER) {",
"ff_mpeg4_encode_video_packet_header(s);",
"ff_mpeg4_clean_buffers(s);",
"}",
"break;",
"case AV_CODEC_ID_MPEG1VIDEO:\ncase AV_CODEC_ID_MPEG2VIDEO:\nif (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER) {",
"ff_mpeg1_encode_slice_header(s);",
"ff_mpeg1_clean_buffers(s);",
"}",
"break;",
"case AV_CODEC_ID_H263:\ncase AV_CODEC_ID_H263P:\nif (CONFIG_H263_ENCODER)\nff_h263_encode_gob_header(s, VAR_3);",
"break;",
"}",
"if(s->flags&CODEC_FLAG_PASS1){",
"int bits= put_bits_count(&s->pb);",
"s->misc_bits+= bits - s->last_bits;",
"s->last_bits= bits;",
"}",
"s->ptr_lastgob += current_packet_size;",
"s->first_slice_line=1;",
"s->resync_mb_x=VAR_2;",
"s->resync_mb_y=VAR_3;",
"}",
"}",
"if( (s->resync_mb_x == s->VAR_2)\n&& s->resync_mb_y+1 == s->VAR_3){",
"s->first_slice_line=0;",
"}",
"s->mb_skipped=0;",
"s->dquant=0;",
"update_mb_info(s, 0);",
"if (mb_type & (mb_type-1) || (s->mpv_flags & FF_MPV_FLAG_QP_RD)) {",
"int next_block=0;",
"int pb_bits_count, pb2_bits_count, tex_pb_bits_count;",
"copy_context_before_encode(&backup_s, s, -1);",
"backup_s.pb= s->pb;",
"best_s.data_partitioning= s->data_partitioning;",
"best_s.partitioned_frame= s->partitioned_frame;",
"if(s->data_partitioning){",
"backup_s.pb2= s->pb2;",
"backup_s.tex_pb= s->tex_pb;",
"}",
"if(mb_type&CANDIDATE_MB_TYPE_INTER){",
"s->mv_dir = MV_DIR_FORWARD;",
"s->mv_type = MV_TYPE_16X16;",
"s->mb_intra= 0;",
"s->mv[0][0][0] = s->p_mv_table[xy][0];",
"s->mv[0][0][1] = s->p_mv_table[xy][1];",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER, pb, pb2, tex_pb,\n&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);",
"}",
"if(mb_type&CANDIDATE_MB_TYPE_INTER_I){",
"s->mv_dir = MV_DIR_FORWARD;",
"s->mv_type = MV_TYPE_FIELD;",
"s->mb_intra= 0;",
"for(VAR_6=0; VAR_6<2; VAR_6++){",
"VAR_7= s->field_select[0][VAR_6] = s->p_field_select_table[VAR_6][xy];",
"s->mv[0][VAR_6][0] = s->p_field_mv_table[VAR_6][VAR_7][xy][0];",
"s->mv[0][VAR_6][1] = s->p_field_mv_table[VAR_6][VAR_7][xy][1];",
"}",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER_I, pb, pb2, tex_pb,\n&dmin, &next_block, 0, 0);",
"}",
"if(mb_type&CANDIDATE_MB_TYPE_SKIPPED){",
"s->mv_dir = MV_DIR_FORWARD;",
"s->mv_type = MV_TYPE_16X16;",
"s->mb_intra= 0;",
"s->mv[0][0][0] = 0;",
"s->mv[0][0][1] = 0;",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_SKIPPED, pb, pb2, tex_pb,\n&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);",
"}",
"if(mb_type&CANDIDATE_MB_TYPE_INTER4V){",
"s->mv_dir = MV_DIR_FORWARD;",
"s->mv_type = MV_TYPE_8X8;",
"s->mb_intra= 0;",
"for(VAR_6=0; VAR_6<4; VAR_6++){",
"s->mv[0][VAR_6][0] = s->current_picture.motion_val[0][s->block_index[VAR_6]][0];",
"s->mv[0][VAR_6][1] = s->current_picture.motion_val[0][s->block_index[VAR_6]][1];",
"}",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER4V, pb, pb2, tex_pb,\n&dmin, &next_block, 0, 0);",
"}",
"if(mb_type&CANDIDATE_MB_TYPE_FORWARD){",
"s->mv_dir = MV_DIR_FORWARD;",
"s->mv_type = MV_TYPE_16X16;",
"s->mb_intra= 0;",
"s->mv[0][0][0] = s->b_forw_mv_table[xy][0];",
"s->mv[0][0][1] = s->b_forw_mv_table[xy][1];",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD, pb, pb2, tex_pb,\n&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);",
"}",
"if(mb_type&CANDIDATE_MB_TYPE_BACKWARD){",
"s->mv_dir = MV_DIR_BACKWARD;",
"s->mv_type = MV_TYPE_16X16;",
"s->mb_intra= 0;",
"s->mv[1][0][0] = s->b_back_mv_table[xy][0];",
"s->mv[1][0][1] = s->b_back_mv_table[xy][1];",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD, pb, pb2, tex_pb,\n&dmin, &next_block, s->mv[1][0][0], s->mv[1][0][1]);",
"}",
"if(mb_type&CANDIDATE_MB_TYPE_BIDIR){",
"s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;",
"s->mv_type = MV_TYPE_16X16;",
"s->mb_intra= 0;",
"s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0];",
"s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1];",
"s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0];",
"s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1];",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR, pb, pb2, tex_pb,\n&dmin, &next_block, 0, 0);",
"}",
"if(mb_type&CANDIDATE_MB_TYPE_FORWARD_I){",
"s->mv_dir = MV_DIR_FORWARD;",
"s->mv_type = MV_TYPE_FIELD;",
"s->mb_intra= 0;",
"for(VAR_6=0; VAR_6<2; VAR_6++){",
"VAR_7= s->field_select[0][VAR_6] = s->b_field_select_table[0][VAR_6][xy];",
"s->mv[0][VAR_6][0] = s->b_field_mv_table[0][VAR_6][VAR_7][xy][0];",
"s->mv[0][VAR_6][1] = s->b_field_mv_table[0][VAR_6][VAR_7][xy][1];",
"}",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD_I, pb, pb2, tex_pb,\n&dmin, &next_block, 0, 0);",
"}",
"if(mb_type&CANDIDATE_MB_TYPE_BACKWARD_I){",
"s->mv_dir = MV_DIR_BACKWARD;",
"s->mv_type = MV_TYPE_FIELD;",
"s->mb_intra= 0;",
"for(VAR_6=0; VAR_6<2; VAR_6++){",
"VAR_7= s->field_select[1][VAR_6] = s->b_field_select_table[1][VAR_6][xy];",
"s->mv[1][VAR_6][0] = s->b_field_mv_table[1][VAR_6][VAR_7][xy][0];",
"s->mv[1][VAR_6][1] = s->b_field_mv_table[1][VAR_6][VAR_7][xy][1];",
"}",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD_I, pb, pb2, tex_pb,\n&dmin, &next_block, 0, 0);",
"}",
"if(mb_type&CANDIDATE_MB_TYPE_BIDIR_I){",
"s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;",
"s->mv_type = MV_TYPE_FIELD;",
"s->mb_intra= 0;",
"for(dir=0; dir<2; dir++){",
"for(VAR_6=0; VAR_6<2; VAR_6++){",
"VAR_7= s->field_select[dir][VAR_6] = s->b_field_select_table[dir][VAR_6][xy];",
"s->mv[dir][VAR_6][0] = s->b_field_mv_table[dir][VAR_6][VAR_7][xy][0];",
"s->mv[dir][VAR_6][1] = s->b_field_mv_table[dir][VAR_6][VAR_7][xy][1];",
"}",
"}",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR_I, pb, pb2, tex_pb,\n&dmin, &next_block, 0, 0);",
"}",
"if(mb_type&CANDIDATE_MB_TYPE_INTRA){",
"s->mv_dir = 0;",
"s->mv_type = MV_TYPE_16X16;",
"s->mb_intra= 1;",
"s->mv[0][0][0] = 0;",
"s->mv[0][0][1] = 0;",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTRA, pb, pb2, tex_pb,\n&dmin, &next_block, 0, 0);",
"if(s->h263_pred || s->h263_aic){",
"if(best_s.mb_intra)\ns->mbintra_table[VAR_2 + VAR_3*s->mb_stride]=1;",
"else\nff_clean_intra_table_entries(s);",
"}",
"}",
"if ((s->mpv_flags & FF_MPV_FLAG_QP_RD) && dmin < INT_MAX) {",
"if(best_s.mv_type==MV_TYPE_16X16){",
"const int last_qp= backup_s.qscale;",
"int qpi, qp, dc[6];",
"int16_t ac[6][16];",
"const int mvdir= (best_s.mv_dir&MV_DIR_BACKWARD) ? 1 : 0;",
"static const int dquant_tab[4]={-1,1,-2,2};",
"assert(backup_s.dquant == 0);",
"s->mv_dir= best_s.mv_dir;",
"s->mv_type = MV_TYPE_16X16;",
"s->mb_intra= best_s.mb_intra;",
"s->mv[0][0][0] = best_s.mv[0][0][0];",
"s->mv[0][0][1] = best_s.mv[0][0][1];",
"s->mv[1][0][0] = best_s.mv[1][0][0];",
"s->mv[1][0][1] = best_s.mv[1][0][1];",
"qpi = s->pict_type == AV_PICTURE_TYPE_B ? 2 : 0;",
"for(; qpi<4; qpi++){",
"int dquant= dquant_tab[qpi];",
"qp= last_qp + dquant;",
"if(qp < s->avctx->qmin || qp > s->avctx->qmax)\ncontinue;",
"backup_s.dquant= dquant;",
"if(s->mb_intra && s->dc_val[0]){",
"for(VAR_6=0; VAR_6<6; VAR_6++){",
"dc[VAR_6]= s->dc_val[0][ s->block_index[VAR_6] ];",
"memcpy(ac[VAR_6], s->ac_val[0][s->block_index[VAR_6]], sizeof(int16_t)*16);",
"}",
"}",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER , pb, pb2, tex_pb,\n&dmin, &next_block, s->mv[mvdir][0][0], s->mv[mvdir][0][1]);",
"if(best_s.qscale != qp){",
"if(s->mb_intra && s->dc_val[0]){",
"for(VAR_6=0; VAR_6<6; VAR_6++){",
"s->dc_val[0][ s->block_index[VAR_6] ]= dc[VAR_6];",
"memcpy(s->ac_val[0][s->block_index[VAR_6]], ac[VAR_6], sizeof(int16_t)*16);",
"}",
"}",
"}",
"}",
"}",
"}",
"if(CONFIG_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT){",
"int mx= s->b_direct_mv_table[xy][0];",
"int my= s->b_direct_mv_table[xy][1];",
"backup_s.dquant = 0;",
"s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;",
"s->mb_intra= 0;",
"ff_mpeg4_set_direct_mv(s, mx, my);",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,\n&dmin, &next_block, mx, my);",
"}",
"if(CONFIG_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT0){",
"backup_s.dquant = 0;",
"s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;",
"s->mb_intra= 0;",
"ff_mpeg4_set_direct_mv(s, 0, 0);",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,\n&dmin, &next_block, 0, 0);",
"}",
"if (!best_s.mb_intra && s->mpv_flags & FF_MPV_FLAG_SKIP_RD) {",
"int coded=0;",
"for(VAR_6=0; VAR_6<6; VAR_6++)",
"coded |= s->block_last_index[VAR_6];",
"if(coded){",
"int mx,my;",
"memcpy(s->mv, best_s.mv, sizeof(s->mv));",
"if(CONFIG_MPEG4_ENCODER && best_s.mv_dir & MV_DIRECT){",
"mx=my=0;",
"ff_mpeg4_set_direct_mv(s, mx, my);",
"}else if(best_s.mv_dir&MV_DIR_BACKWARD){",
"mx= s->mv[1][0][0];",
"my= s->mv[1][0][1];",
"}else{",
"mx= s->mv[0][0][0];",
"my= s->mv[0][0][1];",
"}",
"s->mv_dir= best_s.mv_dir;",
"s->mv_type = best_s.mv_type;",
"s->mb_intra= 0;",
"backup_s.dquant= 0;",
"s->skipdct=1;",
"encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER , pb, pb2, tex_pb,\n&dmin, &next_block, mx, my);",
"s->skipdct=0;",
"}",
"}",
"s->current_picture.qscale_table[xy] = best_s.qscale;",
"copy_context_after_encode(s, &best_s, -1);",
"pb_bits_count= put_bits_count(&s->pb);",
"flush_put_bits(&s->pb);",
"avpriv_copy_bits(&backup_s.pb, bit_buf[next_block^1], pb_bits_count);",
"s->pb= backup_s.pb;",
"if(s->data_partitioning){",
"pb2_bits_count= put_bits_count(&s->pb2);",
"flush_put_bits(&s->pb2);",
"avpriv_copy_bits(&backup_s.pb2, bit_buf2[next_block^1], pb2_bits_count);",
"s->pb2= backup_s.pb2;",
"tex_pb_bits_count= put_bits_count(&s->tex_pb);",
"flush_put_bits(&s->tex_pb);",
"avpriv_copy_bits(&backup_s.tex_pb, bit_buf_tex[next_block^1], tex_pb_bits_count);",
"s->tex_pb= backup_s.tex_pb;",
"}",
"s->last_bits= put_bits_count(&s->pb);",
"if (CONFIG_H263_ENCODER &&\ns->out_format == FMT_H263 && s->pict_type!=AV_PICTURE_TYPE_B)\nff_h263_update_motion_val(s);",
"if(next_block==0){",
"s->hdsp.put_pixels_tab[0][0](s->dest[0], s->rd_scratchpad , s->linesize ,16);",
"s->hdsp.put_pixels_tab[1][0](s->dest[1], s->rd_scratchpad + 16*s->linesize , s->uvlinesize, 8);",
"s->hdsp.put_pixels_tab[1][0](s->dest[2], s->rd_scratchpad + 16*s->linesize + 8, s->uvlinesize, 8);",
"}",
"if(s->avctx->mb_decision == FF_MB_DECISION_BITS)\nff_MPV_decode_mb(s, s->block);",
"} else {",
"int motion_x = 0, motion_y = 0;",
"s->mv_type=MV_TYPE_16X16;",
"switch(mb_type){",
"case CANDIDATE_MB_TYPE_INTRA:\ns->mv_dir = 0;",
"s->mb_intra= 1;",
"motion_x= s->mv[0][0][0] = 0;",
"motion_y= s->mv[0][0][1] = 0;",
"break;",
"case CANDIDATE_MB_TYPE_INTER:\ns->mv_dir = MV_DIR_FORWARD;",
"s->mb_intra= 0;",
"motion_x= s->mv[0][0][0] = s->p_mv_table[xy][0];",
"motion_y= s->mv[0][0][1] = s->p_mv_table[xy][1];",
"break;",
"case CANDIDATE_MB_TYPE_INTER_I:\ns->mv_dir = MV_DIR_FORWARD;",
"s->mv_type = MV_TYPE_FIELD;",
"s->mb_intra= 0;",
"for(VAR_6=0; VAR_6<2; VAR_6++){",
"VAR_7= s->field_select[0][VAR_6] = s->p_field_select_table[VAR_6][xy];",
"s->mv[0][VAR_6][0] = s->p_field_mv_table[VAR_6][VAR_7][xy][0];",
"s->mv[0][VAR_6][1] = s->p_field_mv_table[VAR_6][VAR_7][xy][1];",
"}",
"break;",
"case CANDIDATE_MB_TYPE_INTER4V:\ns->mv_dir = MV_DIR_FORWARD;",
"s->mv_type = MV_TYPE_8X8;",
"s->mb_intra= 0;",
"for(VAR_6=0; VAR_6<4; VAR_6++){",
"s->mv[0][VAR_6][0] = s->current_picture.motion_val[0][s->block_index[VAR_6]][0];",
"s->mv[0][VAR_6][1] = s->current_picture.motion_val[0][s->block_index[VAR_6]][1];",
"}",
"break;",
"case CANDIDATE_MB_TYPE_DIRECT:\nif (CONFIG_MPEG4_ENCODER) {",
"s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD|MV_DIRECT;",
"s->mb_intra= 0;",
"motion_x=s->b_direct_mv_table[xy][0];",
"motion_y=s->b_direct_mv_table[xy][1];",
"ff_mpeg4_set_direct_mv(s, motion_x, motion_y);",
"}",
"break;",
"case CANDIDATE_MB_TYPE_DIRECT0:\nif (CONFIG_MPEG4_ENCODER) {",
"s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD|MV_DIRECT;",
"s->mb_intra= 0;",
"ff_mpeg4_set_direct_mv(s, 0, 0);",
"}",
"break;",
"case CANDIDATE_MB_TYPE_BIDIR:\ns->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;",
"s->mb_intra= 0;",
"s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0];",
"s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1];",
"s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0];",
"s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1];",
"break;",
"case CANDIDATE_MB_TYPE_BACKWARD:\ns->mv_dir = MV_DIR_BACKWARD;",
"s->mb_intra= 0;",
"motion_x= s->mv[1][0][0] = s->b_back_mv_table[xy][0];",
"motion_y= s->mv[1][0][1] = s->b_back_mv_table[xy][1];",
"break;",
"case CANDIDATE_MB_TYPE_FORWARD:\ns->mv_dir = MV_DIR_FORWARD;",
"s->mb_intra= 0;",
"motion_x= s->mv[0][0][0] = s->b_forw_mv_table[xy][0];",
"motion_y= s->mv[0][0][1] = s->b_forw_mv_table[xy][1];",
"break;",
"case CANDIDATE_MB_TYPE_FORWARD_I:\ns->mv_dir = MV_DIR_FORWARD;",
"s->mv_type = MV_TYPE_FIELD;",
"s->mb_intra= 0;",
"for(VAR_6=0; VAR_6<2; VAR_6++){",
"VAR_7= s->field_select[0][VAR_6] = s->b_field_select_table[0][VAR_6][xy];",
"s->mv[0][VAR_6][0] = s->b_field_mv_table[0][VAR_6][VAR_7][xy][0];",
"s->mv[0][VAR_6][1] = s->b_field_mv_table[0][VAR_6][VAR_7][xy][1];",
"}",
"break;",
"case CANDIDATE_MB_TYPE_BACKWARD_I:\ns->mv_dir = MV_DIR_BACKWARD;",
"s->mv_type = MV_TYPE_FIELD;",
"s->mb_intra= 0;",
"for(VAR_6=0; VAR_6<2; VAR_6++){",
"VAR_7= s->field_select[1][VAR_6] = s->b_field_select_table[1][VAR_6][xy];",
"s->mv[1][VAR_6][0] = s->b_field_mv_table[1][VAR_6][VAR_7][xy][0];",
"s->mv[1][VAR_6][1] = s->b_field_mv_table[1][VAR_6][VAR_7][xy][1];",
"}",
"break;",
"case CANDIDATE_MB_TYPE_BIDIR_I:\ns->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;",
"s->mv_type = MV_TYPE_FIELD;",
"s->mb_intra= 0;",
"for(dir=0; dir<2; dir++){",
"for(VAR_6=0; VAR_6<2; VAR_6++){",
"VAR_7= s->field_select[dir][VAR_6] = s->b_field_select_table[dir][VAR_6][xy];",
"s->mv[dir][VAR_6][0] = s->b_field_mv_table[dir][VAR_6][VAR_7][xy][0];",
"s->mv[dir][VAR_6][1] = s->b_field_mv_table[dir][VAR_6][VAR_7][xy][1];",
"}",
"}",
"break;",
"default:\nav_log(s->avctx, AV_LOG_ERROR, \"illegal MB type\\n\");",
"}",
"encode_mb(s, motion_x, motion_y);",
"s->last_mv_dir = s->mv_dir;",
"if (CONFIG_H263_ENCODER &&\ns->out_format == FMT_H263 && s->pict_type!=AV_PICTURE_TYPE_B)\nff_h263_update_motion_val(s);",
"ff_MPV_decode_mb(s, s->block);",
"}",
"if(s->mb_intra ){",
"s->p_mv_table[xy][0]=0;",
"s->p_mv_table[xy][1]=0;",
"}",
"if(s->flags&CODEC_FLAG_PSNR){",
"int w= 16;",
"int h= 16;",
"if(s->VAR_2*16 + 16 > s->width ) w= s->width - s->VAR_2*16;",
"if(s->VAR_3*16 + 16 > s->height) h= s->height- s->VAR_3*16;",
"s->current_picture.f.error[0] += sse(\ns, s->new_picture.f.data[0] + s->VAR_2*16 + s->VAR_3*s->linesize*16,\ns->dest[0], w, h, s->linesize);",
"s->current_picture.f.error[1] += sse(\ns, s->new_picture.f.data[1] + s->VAR_2*8 + s->VAR_3*s->uvlinesize*VAR_5,\ns->dest[1], w>>1, h>>s->chroma_y_shift, s->uvlinesize);",
"s->current_picture.f.error[2] += sse(\ns, s->new_picture.f.data[2] + s->VAR_2*8 + s->VAR_3*s->uvlinesize*VAR_5,\ns->dest[2], w>>1, h>>s->chroma_y_shift, s->uvlinesize);",
"}",
"if(s->loop_filter){",
"if(CONFIG_H263_ENCODER && s->out_format == FMT_H263)\nff_h263_loop_filter(s);",
"}",
"av_dlog(s->avctx, \"MB %d %d bits\\n\",\ns->VAR_2 + s->VAR_3 * s->mb_stride, put_bits_count(&s->pb));",
"}",
"}",
"if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type == AV_PICTURE_TYPE_I)\nff_msmpeg4_encode_ext_header(s);",
"write_slice_end(s);",
"if (s->avctx->rtp_callback) {",
"int VAR_8 = (VAR_3 - s->resync_mb_y)*s->mb_width - s->resync_mb_x;",
"VAR_4 = put_bits_ptr(&s->pb) - s->ptr_lastgob;",
"emms_c();",
"s->avctx->rtp_callback(s->avctx, s->ptr_lastgob, VAR_4, VAR_8);",
"}",
"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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
79
],
[
81,
83,
85,
87,
89
],
[
91
],
[
93,
95,
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151,
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
187
],
[
189
],
[
193
],
[
197
],
[
201
],
[
205
],
[
207,
209,
211,
213
],
[
215
],
[
217,
219
],
[
221,
223
],
[
225
],
[
227
],
[
231
],
[
233
],
[
235
],
[
239
],
[
241
],
[
243
],
[
245
],
[
249
],
[
251
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
287
],
[
289,
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301,
303,
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315,
317,
319,
321
],
[
323
],
[
325
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
355,
357
],
[
359
],
[
361
],
[
365
],
[
367
],
[
371
],
[
375
],
[
377
],
[
379
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
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
],
[
493
],
[
495,
497
],
[
499
],
[
501
],
[
503
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513,
515
],
[
517
],
[
519
],
[
521
],
[
523
],
[
525
],
[
527
],
[
529
],
[
531
],
[
533
],
[
535,
537
],
[
539
],
[
541
],
[
543
],
[
545
],
[
547
],
[
549
],
[
551
],
[
553
],
[
555
],
[
557
],
[
559,
561
],
[
563
],
[
565
],
[
567
],
[
569
],
[
571
],
[
573
],
[
575
],
[
577
],
[
579
],
[
581
],
[
583,
585
],
[
587
],
[
589
],
[
591
],
[
593
],
[
595
],
[
597
],
[
599
],
[
601
],
[
603
],
[
605
],
[
607
],
[
609
],
[
611,
613
],
[
615
],
[
617
],
[
619
],
[
621
],
[
623
],
[
625
],
[
627
],
[
629,
631
],
[
633
],
[
635,
637
],
[
639,
641
],
[
643
],
[
645
],
[
649
],
[
651
],
[
653
],
[
655
],
[
657
],
[
659
],
[
661
],
[
665
],
[
671
],
[
673
],
[
675
],
[
677
],
[
679
],
[
681
],
[
683
],
[
687
],
[
689
],
[
691
],
[
693
],
[
695,
697
],
[
699
],
[
701
],
[
703
],
[
705
],
[
707
],
[
709
],
[
711
],
[
715,
717
],
[
719
],
[
721
],
[
723
],
[
725
],
[
727
],
[
729
],
[
731
],
[
733
],
[
735
],
[
737
],
[
739
],
[
741
],
[
743
],
[
745
],
[
749
],
[
751
],
[
753
],
[
755
],
[
757,
759
],
[
761
],
[
763
],
[
765
],
[
767
],
[
769
],
[
771
],
[
773,
775
],
[
777
],
[
779
],
[
781
],
[
783
],
[
785
],
[
787
],
[
789
],
[
791
],
[
793
],
[
795
],
[
797
],
[
799
],
[
801
],
[
803
],
[
805
],
[
807
],
[
809
],
[
811
],
[
815
],
[
817
],
[
819
],
[
829
],
[
831
],
[
833,
835
],
[
837
],
[
839
],
[
841
],
[
845
],
[
849
],
[
853
],
[
855
],
[
857
],
[
859
],
[
863
],
[
865
],
[
867
],
[
869
],
[
871
],
[
875
],
[
877
],
[
879
],
[
881
],
[
883
],
[
885
],
[
889,
891,
893
],
[
897
],
[
899
],
[
901
],
[
903
],
[
905
],
[
909,
911
],
[
913
],
[
915
],
[
917
],
[
923
],
[
925,
927
],
[
929
],
[
931
],
[
933
],
[
935
],
[
937,
939
],
[
941
],
[
943
],
[
945
],
[
947
],
[
949,
951
],
[
953
],
[
955
],
[
957
],
[
959
],
[
961
],
[
963
],
[
965
],
[
967
],
[
969,
971
],
[
973
],
[
975
],
[
977
],
[
979
],
[
981
],
[
983
],
[
985
],
[
987,
989
],
[
991
],
[
993
],
[
995
],
[
997
],
[
999
],
[
1001
],
[
1003
],
[
1005,
1007
],
[
1009
],
[
1011
],
[
1013
],
[
1015
],
[
1017
],
[
1019,
1021
],
[
1023
],
[
1025
],
[
1027
],
[
1029
],
[
1031
],
[
1033
],
[
1035,
1037
],
[
1039
],
[
1041
],
[
1043
],
[
1045
],
[
1047,
1049
],
[
1051
],
[
1053
],
[
1055
],
[
1057
],
[
1059,
1061
],
[
1063
],
[
1065
],
[
1067
],
[
1069
],
[
1071
],
[
1073
],
[
1075
],
[
1077
],
[
1079,
1081
],
[
1083
],
[
1085
],
[
1087
],
[
1089
],
[
1091
],
[
1093
],
[
1095
],
[
1097
],
[
1099,
1101
],
[
1103
],
[
1105
],
[
1107
],
[
1109
],
[
1111
],
[
1113
],
[
1115
],
[
1117
],
[
1119
],
[
1121
],
[
1123,
1125
],
[
1127
],
[
1131
],
[
1137
],
[
1141,
1143,
1145
],
[
1149
],
[
1151
],
[
1157
],
[
1159
],
[
1161
],
[
1163
],
[
1167
],
[
1169
],
[
1171
],
[
1175
],
[
1177
],
[
1181,
1183,
1185
],
[
1187,
1189,
1191
],
[
1193,
1195,
1197
],
[
1199
],
[
1201
],
[
1203,
1205
],
[
1207
],
[
1209,
1211
],
[
1213
],
[
1215
],
[
1221,
1223
],
[
1227
],
[
1233
],
[
1235
],
[
1237
],
[
1241
],
[
1243
],
[
1245
],
[
1249
],
[
1251
]
] |
18,333 | static int bdrv_check_request(BlockDriverState *bs, int64_t sector_num,
int nb_sectors)
{
return bdrv_check_byte_request(bs, sector_num * BDRV_SECTOR_SIZE,
nb_sectors * BDRV_SECTOR_SIZE); | true | qemu | 8f4754ede56e3f9ea3fd7207f4a7c4453e59285b | static int bdrv_check_request(BlockDriverState *bs, int64_t sector_num,
int nb_sectors)
{
return bdrv_check_byte_request(bs, sector_num * BDRV_SECTOR_SIZE,
nb_sectors * BDRV_SECTOR_SIZE); | {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,
int VAR_2)
{
return bdrv_check_byte_request(VAR_0, VAR_1 * BDRV_SECTOR_SIZE,
VAR_2 * BDRV_SECTOR_SIZE); | [
"static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,\nint VAR_2)\n{",
"return bdrv_check_byte_request(VAR_0, VAR_1 * BDRV_SECTOR_SIZE,\nVAR_2 * BDRV_SECTOR_SIZE);"
] | [
0,
0
] | [
[
1,
2,
3
],
[
4,
5
]
] |
18,334 | int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext *avccontext) {
if(avccontext->coded_frame->quality) /* VBR requested */
return vorbis_encode_init_vbr(vi, avccontext->channels,
avccontext->sample_rate, (float)avccontext->coded_frame->quality / 1000) ;
return vorbis_encode_init(vi, avccontext->channels,
avccontext->sample_rate, -1, avccontext->bit_rate, -1) ;
}
| true | FFmpeg | c55427f8c8348af12b77b9601479769d701d8c99 | int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext *avccontext) {
if(avccontext->coded_frame->quality)
return vorbis_encode_init_vbr(vi, avccontext->channels,
avccontext->sample_rate, (float)avccontext->coded_frame->quality / 1000) ;
return vorbis_encode_init(vi, avccontext->channels,
avccontext->sample_rate, -1, avccontext->bit_rate, -1) ;
}
| {
"code": [
"\treturn vorbis_encode_init_vbr(vi, avccontext->channels,",
"\t\t avccontext->sample_rate, (float)avccontext->coded_frame->quality / 1000) ;"
],
"line_no": [
5,
7
]
} | int FUNC_0(vorbis_info *VAR_0, AVCodecContext *VAR_1) {
if(VAR_1->coded_frame->quality)
return vorbis_encode_init_vbr(VAR_0, VAR_1->channels,
VAR_1->sample_rate, (float)VAR_1->coded_frame->quality / 1000) ;
return vorbis_encode_init(VAR_0, VAR_1->channels,
VAR_1->sample_rate, -1, VAR_1->bit_rate, -1) ;
}
| [
"int FUNC_0(vorbis_info *VAR_0, AVCodecContext *VAR_1) {",
"if(VAR_1->coded_frame->quality)\nreturn vorbis_encode_init_vbr(VAR_0, VAR_1->channels,\nVAR_1->sample_rate, (float)VAR_1->coded_frame->quality / 1000) ;",
"return vorbis_encode_init(VAR_0, VAR_1->channels,\nVAR_1->sample_rate, -1, VAR_1->bit_rate, -1) ;",
"}"
] | [
0,
1,
0,
0
] | [
[
1
],
[
3,
5,
7
],
[
11,
13
],
[
15
]
] |
18,335 | static void gt_ctl_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value)
{
ARMCPU *cpu = arm_env_get_cpu(env);
int timeridx = ri->crm & 1;
uint32_t oldval = env->cp15.c14_timer[timeridx].ctl;
env->cp15.c14_timer[timeridx].ctl = value & 3;
if ((oldval ^ value) & 1) {
/* Enable toggled */
gt_recalc_timer(cpu, timeridx);
} else if ((oldval & value) & 2) {
/* IMASK toggled: don't need to recalculate,
* just set the interrupt line based on ISTATUS
*/
qemu_set_irq(cpu->gt_timer_outputs[timeridx],
(oldval & 4) && (value & 2));
}
}
| true | qemu | d3afacc7269fee45d54d1501a46b51f12ea7bb15 | static void gt_ctl_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value)
{
ARMCPU *cpu = arm_env_get_cpu(env);
int timeridx = ri->crm & 1;
uint32_t oldval = env->cp15.c14_timer[timeridx].ctl;
env->cp15.c14_timer[timeridx].ctl = value & 3;
if ((oldval ^ value) & 1) {
gt_recalc_timer(cpu, timeridx);
} else if ((oldval & value) & 2) {
qemu_set_irq(cpu->gt_timer_outputs[timeridx],
(oldval & 4) && (value & 2));
}
}
| {
"code": [
" env->cp15.c14_timer[timeridx].ctl = value & 3;",
" } else if ((oldval & value) & 2) {",
" (oldval & 4) && (value & 2));"
],
"line_no": [
15,
23,
33
]
} | static void FUNC_0(CPUARMState *VAR_0, const ARMCPRegInfo *VAR_1,
uint64_t VAR_2)
{
ARMCPU *cpu = arm_env_get_cpu(VAR_0);
int VAR_3 = VAR_1->crm & 1;
uint32_t oldval = VAR_0->cp15.c14_timer[VAR_3].ctl;
VAR_0->cp15.c14_timer[VAR_3].ctl = VAR_2 & 3;
if ((oldval ^ VAR_2) & 1) {
gt_recalc_timer(cpu, VAR_3);
} else if ((oldval & VAR_2) & 2) {
qemu_set_irq(cpu->gt_timer_outputs[VAR_3],
(oldval & 4) && (VAR_2 & 2));
}
}
| [
"static void FUNC_0(CPUARMState *VAR_0, const ARMCPRegInfo *VAR_1,\nuint64_t VAR_2)\n{",
"ARMCPU *cpu = arm_env_get_cpu(VAR_0);",
"int VAR_3 = VAR_1->crm & 1;",
"uint32_t oldval = VAR_0->cp15.c14_timer[VAR_3].ctl;",
"VAR_0->cp15.c14_timer[VAR_3].ctl = VAR_2 & 3;",
"if ((oldval ^ VAR_2) & 1) {",
"gt_recalc_timer(cpu, VAR_3);",
"} else if ((oldval & VAR_2) & 2) {",
"qemu_set_irq(cpu->gt_timer_outputs[VAR_3],\n(oldval & 4) && (VAR_2 & 2));",
"}",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
1,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
31,
33
],
[
35
],
[
37
]
] |
18,336 | static av_cold int vp8_decode_free(AVCodecContext *avctx)
{
vp8_decode_flush_impl(avctx, 0, 1);
release_queued_segmaps(avctx->priv_data, 1);
return 0;
}
| true | FFmpeg | bfa0f96586fe2c257cfa574ffb991da493a54da1 | static av_cold int vp8_decode_free(AVCodecContext *avctx)
{
vp8_decode_flush_impl(avctx, 0, 1);
release_queued_segmaps(avctx->priv_data, 1);
return 0;
}
| {
"code": [
" vp8_decode_flush_impl(avctx, 0, 1);"
],
"line_no": [
5
]
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
vp8_decode_flush_impl(avctx, 0, 1);
release_queued_segmaps(avctx->priv_data, 1);
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"vp8_decode_flush_impl(avctx, 0, 1);",
"release_queued_segmaps(avctx->priv_data, 1);",
"return 0;",
"}"
] | [
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
18,337 | static int a64_write_header(AVFormatContext *s)
{
AVCodecContext *avctx = s->streams[0]->codec;
uint8_t header[5] = {
0x00, //load
0x40, //address
0x00, //mode
0x00, //charset_lifetime (multi only)
0x00 //fps in 50/fps;
};
if (avctx->extradata_size < 4) {
av_log(s, AV_LOG_ERROR, "Missing extradata\n");
return AVERROR(EINVAL);
}
switch (avctx->codec->id) {
case AV_CODEC_ID_A64_MULTI:
header[2] = 0x00;
header[3] = AV_RB32(avctx->extradata+0);
header[4] = 2;
break;
case AV_CODEC_ID_A64_MULTI5:
header[2] = 0x01;
header[3] = AV_RB32(avctx->extradata+0);
header[4] = 3;
break;
default:
return AVERROR(EINVAL);
}
avio_write(s->pb, header, 2);
return 0;
}
| false | FFmpeg | 0528226a05cc08b74197547fba0b1939bf68990d | static int a64_write_header(AVFormatContext *s)
{
AVCodecContext *avctx = s->streams[0]->codec;
uint8_t header[5] = {
0x00,
0x40,
0x00,
0x00,
0x00
};
if (avctx->extradata_size < 4) {
av_log(s, AV_LOG_ERROR, "Missing extradata\n");
return AVERROR(EINVAL);
}
switch (avctx->codec->id) {
case AV_CODEC_ID_A64_MULTI:
header[2] = 0x00;
header[3] = AV_RB32(avctx->extradata+0);
header[4] = 2;
break;
case AV_CODEC_ID_A64_MULTI5:
header[2] = 0x01;
header[3] = AV_RB32(avctx->extradata+0);
header[4] = 3;
break;
default:
return AVERROR(EINVAL);
}
avio_write(s->pb, header, 2);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
AVCodecContext *avctx = VAR_0->streams[0]->codec;
uint8_t header[5] = {
0x00,
0x40,
0x00,
0x00,
0x00
};
if (avctx->extradata_size < 4) {
av_log(VAR_0, AV_LOG_ERROR, "Missing extradata\n");
return AVERROR(EINVAL);
}
switch (avctx->codec->id) {
case AV_CODEC_ID_A64_MULTI:
header[2] = 0x00;
header[3] = AV_RB32(avctx->extradata+0);
header[4] = 2;
break;
case AV_CODEC_ID_A64_MULTI5:
header[2] = 0x01;
header[3] = AV_RB32(avctx->extradata+0);
header[4] = 3;
break;
default:
return AVERROR(EINVAL);
}
avio_write(VAR_0->pb, header, 2);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"AVCodecContext *avctx = VAR_0->streams[0]->codec;",
"uint8_t header[5] = {",
"0x00,\n0x40,\n0x00,\n0x00,\n0x00\n};",
"if (avctx->extradata_size < 4) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Missing extradata\\n\");",
"return AVERROR(EINVAL);",
"}",
"switch (avctx->codec->id) {",
"case AV_CODEC_ID_A64_MULTI:\nheader[2] = 0x00;",
"header[3] = AV_RB32(avctx->extradata+0);",
"header[4] = 2;",
"break;",
"case AV_CODEC_ID_A64_MULTI5:\nheader[2] = 0x01;",
"header[3] = AV_RB32(avctx->extradata+0);",
"header[4] = 3;",
"break;",
"default:\nreturn AVERROR(EINVAL);",
"}",
"avio_write(VAR_0->pb, header, 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11,
13,
15,
17,
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
]
] |
18,338 | static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num)
{
BDRVBochsState *s = bs->opaque;
uint64_t offset = sector_num * 512;
uint64_t extent_index, extent_offset, bitmap_offset;
char bitmap_entry;
// seek to sector
extent_index = offset / s->extent_size;
extent_offset = (offset % s->extent_size) / 512;
if (s->catalog_bitmap[extent_index] == 0xffffffff) {
return -1; /* not allocated */
}
bitmap_offset = s->data_offset +
(512 * (uint64_t) s->catalog_bitmap[extent_index] *
(s->extent_blocks + s->bitmap_blocks));
/* read in bitmap for current extent */
if (bdrv_pread(bs->file, bitmap_offset + (extent_offset / 8),
&bitmap_entry, 1) != 1) {
return -1;
}
if (!((bitmap_entry >> (extent_offset % 8)) & 1)) {
return -1; /* not allocated */
}
return bitmap_offset + (512 * (s->bitmap_blocks + extent_offset));
}
| false | qemu | e1b42f456fad6e797eaf795ed2e400c4e47d5eb4 | static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num)
{
BDRVBochsState *s = bs->opaque;
uint64_t offset = sector_num * 512;
uint64_t extent_index, extent_offset, bitmap_offset;
char bitmap_entry;
extent_index = offset / s->extent_size;
extent_offset = (offset % s->extent_size) / 512;
if (s->catalog_bitmap[extent_index] == 0xffffffff) {
return -1;
}
bitmap_offset = s->data_offset +
(512 * (uint64_t) s->catalog_bitmap[extent_index] *
(s->extent_blocks + s->bitmap_blocks));
if (bdrv_pread(bs->file, bitmap_offset + (extent_offset / 8),
&bitmap_entry, 1) != 1) {
return -1;
}
if (!((bitmap_entry >> (extent_offset % 8)) & 1)) {
return -1;
}
return bitmap_offset + (512 * (s->bitmap_blocks + extent_offset));
}
| {
"code": [],
"line_no": []
} | static int64_t FUNC_0(BlockDriverState *bs, int64_t sector_num)
{
BDRVBochsState *s = bs->opaque;
uint64_t offset = sector_num * 512;
uint64_t extent_index, extent_offset, bitmap_offset;
char VAR_0;
extent_index = offset / s->extent_size;
extent_offset = (offset % s->extent_size) / 512;
if (s->catalog_bitmap[extent_index] == 0xffffffff) {
return -1;
}
bitmap_offset = s->data_offset +
(512 * (uint64_t) s->catalog_bitmap[extent_index] *
(s->extent_blocks + s->bitmap_blocks));
if (bdrv_pread(bs->file, bitmap_offset + (extent_offset / 8),
&VAR_0, 1) != 1) {
return -1;
}
if (!((VAR_0 >> (extent_offset % 8)) & 1)) {
return -1;
}
return bitmap_offset + (512 * (s->bitmap_blocks + extent_offset));
}
| [
"static int64_t FUNC_0(BlockDriverState *bs, int64_t sector_num)\n{",
"BDRVBochsState *s = bs->opaque;",
"uint64_t offset = sector_num * 512;",
"uint64_t extent_index, extent_offset, bitmap_offset;",
"char VAR_0;",
"extent_index = offset / s->extent_size;",
"extent_offset = (offset % s->extent_size) / 512;",
"if (s->catalog_bitmap[extent_index] == 0xffffffff) {",
"return -1;",
"}",
"bitmap_offset = s->data_offset +\n(512 * (uint64_t) s->catalog_bitmap[extent_index] *\n(s->extent_blocks + s->bitmap_blocks));",
"if (bdrv_pread(bs->file, bitmap_offset + (extent_offset / 8),\n&VAR_0, 1) != 1) {",
"return -1;",
"}",
"if (!((VAR_0 >> (extent_offset % 8)) & 1)) {",
"return -1;",
"}",
"return bitmap_offset + (512 * (s->bitmap_blocks + extent_offset));",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
31,
33,
35
],
[
41,
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
]
] |
18,339 | static void slirp_bootp_save(QEMUFile *f, Slirp *slirp)
{
int i;
for (i = 0; i < NB_BOOTP_CLIENTS; i++) {
qemu_put_be16(f, slirp->bootp_clients[i].allocated);
qemu_put_buffer(f, slirp->bootp_clients[i].macaddr, 6);
}
}
| false | qemu | eb5d4f5329df83ea15244b47f7fbca21adaae41b | static void slirp_bootp_save(QEMUFile *f, Slirp *slirp)
{
int i;
for (i = 0; i < NB_BOOTP_CLIENTS; i++) {
qemu_put_be16(f, slirp->bootp_clients[i].allocated);
qemu_put_buffer(f, slirp->bootp_clients[i].macaddr, 6);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(QEMUFile *VAR_0, Slirp *VAR_1)
{
int VAR_2;
for (VAR_2 = 0; VAR_2 < NB_BOOTP_CLIENTS; VAR_2++) {
qemu_put_be16(VAR_0, VAR_1->bootp_clients[VAR_2].allocated);
qemu_put_buffer(VAR_0, VAR_1->bootp_clients[VAR_2].macaddr, 6);
}
}
| [
"static void FUNC_0(QEMUFile *VAR_0, Slirp *VAR_1)\n{",
"int VAR_2;",
"for (VAR_2 = 0; VAR_2 < NB_BOOTP_CLIENTS; VAR_2++) {",
"qemu_put_be16(VAR_0, VAR_1->bootp_clients[VAR_2].allocated);",
"qemu_put_buffer(VAR_0, VAR_1->bootp_clients[VAR_2].macaddr, 6);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
18,340 | int qemu_opts_id_wellformed(const char *id)
{
int i;
if (!qemu_isalpha(id[0])) {
return 0;
}
for (i = 1; id[i]; i++) {
if (!qemu_isalnum(id[i]) && !strchr("-._", id[i])) {
return 0;
}
}
return 1;
}
| false | qemu | f5bebbbb28dc7a149a891f0f1e112fb50bb72664 | int qemu_opts_id_wellformed(const char *id)
{
int i;
if (!qemu_isalpha(id[0])) {
return 0;
}
for (i = 1; id[i]; i++) {
if (!qemu_isalnum(id[i]) && !strchr("-._", id[i])) {
return 0;
}
}
return 1;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(const char *VAR_0)
{
int VAR_1;
if (!qemu_isalpha(VAR_0[0])) {
return 0;
}
for (VAR_1 = 1; VAR_0[VAR_1]; VAR_1++) {
if (!qemu_isalnum(VAR_0[VAR_1]) && !strchr("-._", VAR_0[VAR_1])) {
return 0;
}
}
return 1;
}
| [
"int FUNC_0(const char *VAR_0)\n{",
"int VAR_1;",
"if (!qemu_isalpha(VAR_0[0])) {",
"return 0;",
"}",
"for (VAR_1 = 1; VAR_0[VAR_1]; VAR_1++) {",
"if (!qemu_isalnum(VAR_0[VAR_1]) && !strchr(\"-._\", VAR_0[VAR_1])) {",
"return 0;",
"}",
"}",
"return 1;",
"}"
] | [
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
]
] |
18,341 | ssize_t slirp_send(struct socket *so, const void *buf, size_t len, int flags)
{
if (so->s == -1 && so->extra) {
qemu_chr_fe_write(so->extra, buf, len);
return len;
}
return send(so->s, buf, len, flags);
}
| false | qemu | cf1d078e4ea094e516faab49678fbea3a34b7848 | ssize_t slirp_send(struct socket *so, const void *buf, size_t len, int flags)
{
if (so->s == -1 && so->extra) {
qemu_chr_fe_write(so->extra, buf, len);
return len;
}
return send(so->s, buf, len, flags);
}
| {
"code": [],
"line_no": []
} | ssize_t FUNC_0(struct socket *so, const void *buf, size_t len, int flags)
{
if (so->s == -1 && so->extra) {
qemu_chr_fe_write(so->extra, buf, len);
return len;
}
return send(so->s, buf, len, flags);
}
| [
"ssize_t FUNC_0(struct socket *so, const void *buf, size_t len, int flags)\n{",
"if (so->s == -1 && so->extra) {",
"qemu_chr_fe_write(so->extra, buf, len);",
"return len;",
"}",
"return send(so->s, buf, len, flags);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
]
] |
18,343 | int nbd_init(int fd, int csock, uint32_t flags, off_t size, size_t blocksize)
{
TRACE("Setting NBD socket");
if (ioctl(fd, NBD_SET_SOCK, csock) < 0) {
int serrno = errno;
LOG("Failed to set NBD socket");
errno = serrno;
return -1;
}
TRACE("Setting block size to %lu", (unsigned long)blocksize);
if (ioctl(fd, NBD_SET_BLKSIZE, blocksize) < 0) {
int serrno = errno;
LOG("Failed setting NBD block size");
errno = serrno;
return -1;
}
TRACE("Setting size to %zd block(s)", (size_t)(size / blocksize));
if (ioctl(fd, NBD_SET_SIZE_BLOCKS, size / blocksize) < 0) {
int serrno = errno;
LOG("Failed setting size (in blocks)");
errno = serrno;
return -1;
}
if (flags & NBD_FLAG_READ_ONLY) {
int read_only = 1;
TRACE("Setting readonly attribute");
if (ioctl(fd, BLKROSET, (unsigned long) &read_only) < 0) {
int serrno = errno;
LOG("Failed setting read-only attribute");
errno = serrno;
return -1;
}
}
if (ioctl(fd, NBD_SET_FLAGS, flags) < 0
&& errno != ENOTTY) {
int serrno = errno;
LOG("Failed setting flags");
errno = serrno;
return -1;
}
TRACE("Negotiation ended");
return 0;
}
| false | qemu | 185b43386ad999c80bdc58e41b87f05e5b3e8463 | int nbd_init(int fd, int csock, uint32_t flags, off_t size, size_t blocksize)
{
TRACE("Setting NBD socket");
if (ioctl(fd, NBD_SET_SOCK, csock) < 0) {
int serrno = errno;
LOG("Failed to set NBD socket");
errno = serrno;
return -1;
}
TRACE("Setting block size to %lu", (unsigned long)blocksize);
if (ioctl(fd, NBD_SET_BLKSIZE, blocksize) < 0) {
int serrno = errno;
LOG("Failed setting NBD block size");
errno = serrno;
return -1;
}
TRACE("Setting size to %zd block(s)", (size_t)(size / blocksize));
if (ioctl(fd, NBD_SET_SIZE_BLOCKS, size / blocksize) < 0) {
int serrno = errno;
LOG("Failed setting size (in blocks)");
errno = serrno;
return -1;
}
if (flags & NBD_FLAG_READ_ONLY) {
int read_only = 1;
TRACE("Setting readonly attribute");
if (ioctl(fd, BLKROSET, (unsigned long) &read_only) < 0) {
int serrno = errno;
LOG("Failed setting read-only attribute");
errno = serrno;
return -1;
}
}
if (ioctl(fd, NBD_SET_FLAGS, flags) < 0
&& errno != ENOTTY) {
int serrno = errno;
LOG("Failed setting flags");
errno = serrno;
return -1;
}
TRACE("Negotiation ended");
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(int VAR_0, int VAR_1, uint32_t VAR_2, off_t VAR_3, size_t VAR_4)
{
TRACE("Setting NBD socket");
if (ioctl(VAR_0, NBD_SET_SOCK, VAR_1) < 0) {
int VAR_7 = errno;
LOG("Failed to set NBD socket");
errno = VAR_7;
return -1;
}
TRACE("Setting block VAR_3 to %lu", (unsigned long)VAR_4);
if (ioctl(VAR_0, NBD_SET_BLKSIZE, VAR_4) < 0) {
int VAR_7 = errno;
LOG("Failed setting NBD block VAR_3");
errno = VAR_7;
return -1;
}
TRACE("Setting VAR_3 to %zd block(s)", (size_t)(VAR_3 / VAR_4));
if (ioctl(VAR_0, NBD_SET_SIZE_BLOCKS, VAR_3 / VAR_4) < 0) {
int VAR_7 = errno;
LOG("Failed setting VAR_3 (in blocks)");
errno = VAR_7;
return -1;
}
if (VAR_2 & NBD_FLAG_READ_ONLY) {
int VAR_6 = 1;
TRACE("Setting readonly attribute");
if (ioctl(VAR_0, BLKROSET, (unsigned long) &VAR_6) < 0) {
int VAR_7 = errno;
LOG("Failed setting read-only attribute");
errno = VAR_7;
return -1;
}
}
if (ioctl(VAR_0, NBD_SET_FLAGS, VAR_2) < 0
&& errno != ENOTTY) {
int VAR_7 = errno;
LOG("Failed setting VAR_2");
errno = VAR_7;
return -1;
}
TRACE("Negotiation ended");
return 0;
}
| [
"int FUNC_0(int VAR_0, int VAR_1, uint32_t VAR_2, off_t VAR_3, size_t VAR_4)\n{",
"TRACE(\"Setting NBD socket\");",
"if (ioctl(VAR_0, NBD_SET_SOCK, VAR_1) < 0) {",
"int VAR_7 = errno;",
"LOG(\"Failed to set NBD socket\");",
"errno = VAR_7;",
"return -1;",
"}",
"TRACE(\"Setting block VAR_3 to %lu\", (unsigned long)VAR_4);",
"if (ioctl(VAR_0, NBD_SET_BLKSIZE, VAR_4) < 0) {",
"int VAR_7 = errno;",
"LOG(\"Failed setting NBD block VAR_3\");",
"errno = VAR_7;",
"return -1;",
"}",
"TRACE(\"Setting VAR_3 to %zd block(s)\", (size_t)(VAR_3 / VAR_4));",
"if (ioctl(VAR_0, NBD_SET_SIZE_BLOCKS, VAR_3 / VAR_4) < 0) {",
"int VAR_7 = errno;",
"LOG(\"Failed setting VAR_3 (in blocks)\");",
"errno = VAR_7;",
"return -1;",
"}",
"if (VAR_2 & NBD_FLAG_READ_ONLY) {",
"int VAR_6 = 1;",
"TRACE(\"Setting readonly attribute\");",
"if (ioctl(VAR_0, BLKROSET, (unsigned long) &VAR_6) < 0) {",
"int VAR_7 = errno;",
"LOG(\"Failed setting read-only attribute\");",
"errno = VAR_7;",
"return -1;",
"}",
"}",
"if (ioctl(VAR_0, NBD_SET_FLAGS, VAR_2) < 0\n&& errno != ENOTTY) {",
"int VAR_7 = errno;",
"LOG(\"Failed setting VAR_2\");",
"errno = VAR_7;",
"return -1;",
"}",
"TRACE(\"Negotiation ended\");",
"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
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83,
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
103
],
[
105
]
] |
18,346 | static void rgb24_to_yuvj420p(AVPicture *dst, AVPicture *src,
int width, int height)
{
int wrap, wrap3, width2;
int r, g, b, r1, g1, b1, w;
uint8_t *lum, *cb, *cr;
const uint8_t *p;
lum = dst->data[0];
cb = dst->data[1];
cr = dst->data[2];
width2 = (width + 1) >> 1;
wrap = dst->linesize[0];
wrap3 = src->linesize[0];
p = src->data[0];
for(;height>=2;height -= 2) {
for(w = width; w >= 2; w -= 2) {
RGB_IN(r, g, b, p);
r1 = r;
g1 = g;
b1 = b;
lum[0] = RGB_TO_Y(r, g, b);
RGB_IN(r, g, b, p + BPP);
r1 += r;
g1 += g;
b1 += b;
lum[1] = RGB_TO_Y(r, g, b);
p += wrap3;
lum += wrap;
RGB_IN(r, g, b, p);
r1 += r;
g1 += g;
b1 += b;
lum[0] = RGB_TO_Y(r, g, b);
RGB_IN(r, g, b, p + BPP);
r1 += r;
g1 += g;
b1 += b;
lum[1] = RGB_TO_Y(r, g, b);
cb[0] = RGB_TO_U(r1, g1, b1, 2);
cr[0] = RGB_TO_V(r1, g1, b1, 2);
cb++;
cr++;
p += -wrap3 + 2 * BPP;
lum += -wrap + 2;
}
if (w) {
RGB_IN(r, g, b, p);
r1 = r;
g1 = g;
b1 = b;
lum[0] = RGB_TO_Y(r, g, b);
p += wrap3;
lum += wrap;
RGB_IN(r, g, b, p);
r1 += r;
g1 += g;
b1 += b;
lum[0] = RGB_TO_Y(r, g, b);
cb[0] = RGB_TO_U(r1, g1, b1, 1);
cr[0] = RGB_TO_V(r1, g1, b1, 1);
cb++;
cr++;
p += -wrap3 + BPP;
lum += -wrap + 1;
}
p += wrap3 + (wrap3 - width * BPP);
lum += wrap + (wrap - width);
cb += dst->linesize[1] - width2;
cr += dst->linesize[2] - width2;
}
/* handle odd height */
if (height) {
for(w = width; w >= 2; w -= 2) {
RGB_IN(r, g, b, p);
r1 = r;
g1 = g;
b1 = b;
lum[0] = RGB_TO_Y(r, g, b);
RGB_IN(r, g, b, p + BPP);
r1 += r;
g1 += g;
b1 += b;
lum[1] = RGB_TO_Y(r, g, b);
cb[0] = RGB_TO_U(r1, g1, b1, 1);
cr[0] = RGB_TO_V(r1, g1, b1, 1);
cb++;
cr++;
p += 2 * BPP;
lum += 2;
}
if (w) {
RGB_IN(r, g, b, p);
lum[0] = RGB_TO_Y(r, g, b);
cb[0] = RGB_TO_U(r, g, b, 0);
cr[0] = RGB_TO_V(r, g, b, 0);
}
}
}
| false | FFmpeg | 7e7e59409294af9caa63808e56c5cc824c98b4fc | static void rgb24_to_yuvj420p(AVPicture *dst, AVPicture *src,
int width, int height)
{
int wrap, wrap3, width2;
int r, g, b, r1, g1, b1, w;
uint8_t *lum, *cb, *cr;
const uint8_t *p;
lum = dst->data[0];
cb = dst->data[1];
cr = dst->data[2];
width2 = (width + 1) >> 1;
wrap = dst->linesize[0];
wrap3 = src->linesize[0];
p = src->data[0];
for(;height>=2;height -= 2) {
for(w = width; w >= 2; w -= 2) {
RGB_IN(r, g, b, p);
r1 = r;
g1 = g;
b1 = b;
lum[0] = RGB_TO_Y(r, g, b);
RGB_IN(r, g, b, p + BPP);
r1 += r;
g1 += g;
b1 += b;
lum[1] = RGB_TO_Y(r, g, b);
p += wrap3;
lum += wrap;
RGB_IN(r, g, b, p);
r1 += r;
g1 += g;
b1 += b;
lum[0] = RGB_TO_Y(r, g, b);
RGB_IN(r, g, b, p + BPP);
r1 += r;
g1 += g;
b1 += b;
lum[1] = RGB_TO_Y(r, g, b);
cb[0] = RGB_TO_U(r1, g1, b1, 2);
cr[0] = RGB_TO_V(r1, g1, b1, 2);
cb++;
cr++;
p += -wrap3 + 2 * BPP;
lum += -wrap + 2;
}
if (w) {
RGB_IN(r, g, b, p);
r1 = r;
g1 = g;
b1 = b;
lum[0] = RGB_TO_Y(r, g, b);
p += wrap3;
lum += wrap;
RGB_IN(r, g, b, p);
r1 += r;
g1 += g;
b1 += b;
lum[0] = RGB_TO_Y(r, g, b);
cb[0] = RGB_TO_U(r1, g1, b1, 1);
cr[0] = RGB_TO_V(r1, g1, b1, 1);
cb++;
cr++;
p += -wrap3 + BPP;
lum += -wrap + 1;
}
p += wrap3 + (wrap3 - width * BPP);
lum += wrap + (wrap - width);
cb += dst->linesize[1] - width2;
cr += dst->linesize[2] - width2;
}
if (height) {
for(w = width; w >= 2; w -= 2) {
RGB_IN(r, g, b, p);
r1 = r;
g1 = g;
b1 = b;
lum[0] = RGB_TO_Y(r, g, b);
RGB_IN(r, g, b, p + BPP);
r1 += r;
g1 += g;
b1 += b;
lum[1] = RGB_TO_Y(r, g, b);
cb[0] = RGB_TO_U(r1, g1, b1, 1);
cr[0] = RGB_TO_V(r1, g1, b1, 1);
cb++;
cr++;
p += 2 * BPP;
lum += 2;
}
if (w) {
RGB_IN(r, g, b, p);
lum[0] = RGB_TO_Y(r, g, b);
cb[0] = RGB_TO_U(r, g, b, 0);
cr[0] = RGB_TO_V(r, g, b, 0);
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVPicture *VAR_0, AVPicture *VAR_1,
int VAR_2, int VAR_3)
{
int VAR_4, VAR_5, VAR_6;
int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;
uint8_t *lum, *cb, *cr;
const uint8_t *VAR_14;
lum = VAR_0->data[0];
cb = VAR_0->data[1];
cr = VAR_0->data[2];
VAR_6 = (VAR_2 + 1) >> 1;
VAR_4 = VAR_0->linesize[0];
VAR_5 = VAR_1->linesize[0];
VAR_14 = VAR_1->data[0];
for(;VAR_3>=2;VAR_3 -= 2) {
for(VAR_13 = VAR_2; VAR_13 >= 2; VAR_13 -= 2) {
RGB_IN(VAR_7, VAR_8, VAR_9, VAR_14);
VAR_10 = VAR_7;
VAR_11 = VAR_8;
VAR_12 = VAR_9;
lum[0] = RGB_TO_Y(VAR_7, VAR_8, VAR_9);
RGB_IN(VAR_7, VAR_8, VAR_9, VAR_14 + BPP);
VAR_10 += VAR_7;
VAR_11 += VAR_8;
VAR_12 += VAR_9;
lum[1] = RGB_TO_Y(VAR_7, VAR_8, VAR_9);
VAR_14 += VAR_5;
lum += VAR_4;
RGB_IN(VAR_7, VAR_8, VAR_9, VAR_14);
VAR_10 += VAR_7;
VAR_11 += VAR_8;
VAR_12 += VAR_9;
lum[0] = RGB_TO_Y(VAR_7, VAR_8, VAR_9);
RGB_IN(VAR_7, VAR_8, VAR_9, VAR_14 + BPP);
VAR_10 += VAR_7;
VAR_11 += VAR_8;
VAR_12 += VAR_9;
lum[1] = RGB_TO_Y(VAR_7, VAR_8, VAR_9);
cb[0] = RGB_TO_U(VAR_10, VAR_11, VAR_12, 2);
cr[0] = RGB_TO_V(VAR_10, VAR_11, VAR_12, 2);
cb++;
cr++;
VAR_14 += -VAR_5 + 2 * BPP;
lum += -VAR_4 + 2;
}
if (VAR_13) {
RGB_IN(VAR_7, VAR_8, VAR_9, VAR_14);
VAR_10 = VAR_7;
VAR_11 = VAR_8;
VAR_12 = VAR_9;
lum[0] = RGB_TO_Y(VAR_7, VAR_8, VAR_9);
VAR_14 += VAR_5;
lum += VAR_4;
RGB_IN(VAR_7, VAR_8, VAR_9, VAR_14);
VAR_10 += VAR_7;
VAR_11 += VAR_8;
VAR_12 += VAR_9;
lum[0] = RGB_TO_Y(VAR_7, VAR_8, VAR_9);
cb[0] = RGB_TO_U(VAR_10, VAR_11, VAR_12, 1);
cr[0] = RGB_TO_V(VAR_10, VAR_11, VAR_12, 1);
cb++;
cr++;
VAR_14 += -VAR_5 + BPP;
lum += -VAR_4 + 1;
}
VAR_14 += VAR_5 + (VAR_5 - VAR_2 * BPP);
lum += VAR_4 + (VAR_4 - VAR_2);
cb += VAR_0->linesize[1] - VAR_6;
cr += VAR_0->linesize[2] - VAR_6;
}
if (VAR_3) {
for(VAR_13 = VAR_2; VAR_13 >= 2; VAR_13 -= 2) {
RGB_IN(VAR_7, VAR_8, VAR_9, VAR_14);
VAR_10 = VAR_7;
VAR_11 = VAR_8;
VAR_12 = VAR_9;
lum[0] = RGB_TO_Y(VAR_7, VAR_8, VAR_9);
RGB_IN(VAR_7, VAR_8, VAR_9, VAR_14 + BPP);
VAR_10 += VAR_7;
VAR_11 += VAR_8;
VAR_12 += VAR_9;
lum[1] = RGB_TO_Y(VAR_7, VAR_8, VAR_9);
cb[0] = RGB_TO_U(VAR_10, VAR_11, VAR_12, 1);
cr[0] = RGB_TO_V(VAR_10, VAR_11, VAR_12, 1);
cb++;
cr++;
VAR_14 += 2 * BPP;
lum += 2;
}
if (VAR_13) {
RGB_IN(VAR_7, VAR_8, VAR_9, VAR_14);
lum[0] = RGB_TO_Y(VAR_7, VAR_8, VAR_9);
cb[0] = RGB_TO_U(VAR_7, VAR_8, VAR_9, 0);
cr[0] = RGB_TO_V(VAR_7, VAR_8, VAR_9, 0);
}
}
}
| [
"static void FUNC_0(AVPicture *VAR_0, AVPicture *VAR_1,\nint VAR_2, int VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6;",
"int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;",
"uint8_t *lum, *cb, *cr;",
"const uint8_t *VAR_14;",
"lum = VAR_0->data[0];",
"cb = VAR_0->data[1];",
"cr = VAR_0->data[2];",
"VAR_6 = (VAR_2 + 1) >> 1;",
"VAR_4 = VAR_0->linesize[0];",
"VAR_5 = VAR_1->linesize[0];",
"VAR_14 = VAR_1->data[0];",
"for(;VAR_3>=2;VAR_3 -= 2) {",
"for(VAR_13 = VAR_2; VAR_13 >= 2; VAR_13 -= 2) {",
"RGB_IN(VAR_7, VAR_8, VAR_9, VAR_14);",
"VAR_10 = VAR_7;",
"VAR_11 = VAR_8;",
"VAR_12 = VAR_9;",
"lum[0] = RGB_TO_Y(VAR_7, VAR_8, VAR_9);",
"RGB_IN(VAR_7, VAR_8, VAR_9, VAR_14 + BPP);",
"VAR_10 += VAR_7;",
"VAR_11 += VAR_8;",
"VAR_12 += VAR_9;",
"lum[1] = RGB_TO_Y(VAR_7, VAR_8, VAR_9);",
"VAR_14 += VAR_5;",
"lum += VAR_4;",
"RGB_IN(VAR_7, VAR_8, VAR_9, VAR_14);",
"VAR_10 += VAR_7;",
"VAR_11 += VAR_8;",
"VAR_12 += VAR_9;",
"lum[0] = RGB_TO_Y(VAR_7, VAR_8, VAR_9);",
"RGB_IN(VAR_7, VAR_8, VAR_9, VAR_14 + BPP);",
"VAR_10 += VAR_7;",
"VAR_11 += VAR_8;",
"VAR_12 += VAR_9;",
"lum[1] = RGB_TO_Y(VAR_7, VAR_8, VAR_9);",
"cb[0] = RGB_TO_U(VAR_10, VAR_11, VAR_12, 2);",
"cr[0] = RGB_TO_V(VAR_10, VAR_11, VAR_12, 2);",
"cb++;",
"cr++;",
"VAR_14 += -VAR_5 + 2 * BPP;",
"lum += -VAR_4 + 2;",
"}",
"if (VAR_13) {",
"RGB_IN(VAR_7, VAR_8, VAR_9, VAR_14);",
"VAR_10 = VAR_7;",
"VAR_11 = VAR_8;",
"VAR_12 = VAR_9;",
"lum[0] = RGB_TO_Y(VAR_7, VAR_8, VAR_9);",
"VAR_14 += VAR_5;",
"lum += VAR_4;",
"RGB_IN(VAR_7, VAR_8, VAR_9, VAR_14);",
"VAR_10 += VAR_7;",
"VAR_11 += VAR_8;",
"VAR_12 += VAR_9;",
"lum[0] = RGB_TO_Y(VAR_7, VAR_8, VAR_9);",
"cb[0] = RGB_TO_U(VAR_10, VAR_11, VAR_12, 1);",
"cr[0] = RGB_TO_V(VAR_10, VAR_11, VAR_12, 1);",
"cb++;",
"cr++;",
"VAR_14 += -VAR_5 + BPP;",
"lum += -VAR_4 + 1;",
"}",
"VAR_14 += VAR_5 + (VAR_5 - VAR_2 * BPP);",
"lum += VAR_4 + (VAR_4 - VAR_2);",
"cb += VAR_0->linesize[1] - VAR_6;",
"cr += VAR_0->linesize[2] - VAR_6;",
"}",
"if (VAR_3) {",
"for(VAR_13 = VAR_2; VAR_13 >= 2; VAR_13 -= 2) {",
"RGB_IN(VAR_7, VAR_8, VAR_9, VAR_14);",
"VAR_10 = VAR_7;",
"VAR_11 = VAR_8;",
"VAR_12 = VAR_9;",
"lum[0] = RGB_TO_Y(VAR_7, VAR_8, VAR_9);",
"RGB_IN(VAR_7, VAR_8, VAR_9, VAR_14 + BPP);",
"VAR_10 += VAR_7;",
"VAR_11 += VAR_8;",
"VAR_12 += VAR_9;",
"lum[1] = RGB_TO_Y(VAR_7, VAR_8, VAR_9);",
"cb[0] = RGB_TO_U(VAR_10, VAR_11, VAR_12, 1);",
"cr[0] = RGB_TO_V(VAR_10, VAR_11, VAR_12, 1);",
"cb++;",
"cr++;",
"VAR_14 += 2 * BPP;",
"lum += 2;",
"}",
"if (VAR_13) {",
"RGB_IN(VAR_7, VAR_8, VAR_9, VAR_14);",
"lum[0] = RGB_TO_Y(VAR_7, VAR_8, VAR_9);",
"cb[0] = RGB_TO_U(VAR_7, VAR_8, VAR_9, 0);",
"cr[0] = RGB_TO_V(VAR_7, VAR_8, VAR_9, 0);",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
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
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
]
] |
18,348 | static void do_multiwrite(BlockDriverState *bs, BlockRequest *blkreq,
int num_writes)
{
int i, ret;
ret = bdrv_aio_multiwrite(bs, blkreq, num_writes);
if (ret != 0) {
for (i = 0; i < num_writes; i++) {
if (blkreq[i].error) {
virtio_blk_rw_complete(blkreq[i].opaque, -EIO);
}
}
}
}
| false | qemu | c20fd872257fb9abd2ce99741937c0f65aa162b7 | static void do_multiwrite(BlockDriverState *bs, BlockRequest *blkreq,
int num_writes)
{
int i, ret;
ret = bdrv_aio_multiwrite(bs, blkreq, num_writes);
if (ret != 0) {
for (i = 0; i < num_writes; i++) {
if (blkreq[i].error) {
virtio_blk_rw_complete(blkreq[i].opaque, -EIO);
}
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BlockDriverState *VAR_0, BlockRequest *VAR_1,
int VAR_2)
{
int VAR_3, VAR_4;
VAR_4 = bdrv_aio_multiwrite(VAR_0, VAR_1, VAR_2);
if (VAR_4 != 0) {
for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) {
if (VAR_1[VAR_3].error) {
virtio_blk_rw_complete(VAR_1[VAR_3].opaque, -EIO);
}
}
}
}
| [
"static void FUNC_0(BlockDriverState *VAR_0, BlockRequest *VAR_1,\nint VAR_2)\n{",
"int VAR_3, VAR_4;",
"VAR_4 = bdrv_aio_multiwrite(VAR_0, VAR_1, VAR_2);",
"if (VAR_4 != 0) {",
"for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) {",
"if (VAR_1[VAR_3].error) {",
"virtio_blk_rw_complete(VAR_1[VAR_3].opaque, -EIO);",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
18,350 | static void qjson_register_types(void)
{
type_register_static(&qjson_type_info);
}
| false | qemu | 17b74b98676aee5bc470b173b1e528d2fce2cf18 | static void qjson_register_types(void)
{
type_register_static(&qjson_type_info);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
type_register_static(&qjson_type_info);
}
| [
"static void FUNC_0(void)\n{",
"type_register_static(&qjson_type_info);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
18,352 | void css_generate_sch_crws(uint8_t cssid, uint8_t ssid, uint16_t schid,
int hotplugged, int add)
{
uint8_t guest_cssid;
bool chain_crw;
if (add && !hotplugged) {
return;
}
if (channel_subsys.max_cssid == 0) {
/* Default cssid shows up as 0. */
guest_cssid = (cssid == channel_subsys.default_cssid) ? 0 : cssid;
} else {
/* Show real cssid to the guest. */
guest_cssid = cssid;
}
/*
* Only notify for higher subchannel sets/channel subsystems if the
* guest has enabled it.
*/
if ((ssid > channel_subsys.max_ssid) ||
(guest_cssid > channel_subsys.max_cssid) ||
((channel_subsys.max_cssid == 0) &&
(cssid != channel_subsys.default_cssid))) {
return;
}
chain_crw = (channel_subsys.max_ssid > 0) ||
(channel_subsys.max_cssid > 0);
css_queue_crw(CRW_RSC_SUBCH, CRW_ERC_IPI, chain_crw ? 1 : 0, schid);
if (chain_crw) {
css_queue_crw(CRW_RSC_SUBCH, CRW_ERC_IPI, 0,
(guest_cssid << 8) | (ssid << 4));
}
/* RW_ERC_IPI --> clear pending interrupts */
css_clear_io_interrupt(css_do_build_subchannel_id(cssid, ssid), schid);
}
| false | qemu | 5c8d6f008c0555b54cf10550fa86199a2cfabbca | void css_generate_sch_crws(uint8_t cssid, uint8_t ssid, uint16_t schid,
int hotplugged, int add)
{
uint8_t guest_cssid;
bool chain_crw;
if (add && !hotplugged) {
return;
}
if (channel_subsys.max_cssid == 0) {
guest_cssid = (cssid == channel_subsys.default_cssid) ? 0 : cssid;
} else {
guest_cssid = cssid;
}
if ((ssid > channel_subsys.max_ssid) ||
(guest_cssid > channel_subsys.max_cssid) ||
((channel_subsys.max_cssid == 0) &&
(cssid != channel_subsys.default_cssid))) {
return;
}
chain_crw = (channel_subsys.max_ssid > 0) ||
(channel_subsys.max_cssid > 0);
css_queue_crw(CRW_RSC_SUBCH, CRW_ERC_IPI, chain_crw ? 1 : 0, schid);
if (chain_crw) {
css_queue_crw(CRW_RSC_SUBCH, CRW_ERC_IPI, 0,
(guest_cssid << 8) | (ssid << 4));
}
css_clear_io_interrupt(css_do_build_subchannel_id(cssid, ssid), schid);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(uint8_t VAR_0, uint8_t VAR_1, uint16_t VAR_2,
int VAR_3, int VAR_4)
{
uint8_t guest_cssid;
bool chain_crw;
if (VAR_4 && !VAR_3) {
return;
}
if (channel_subsys.max_cssid == 0) {
guest_cssid = (VAR_0 == channel_subsys.default_cssid) ? 0 : VAR_0;
} else {
guest_cssid = VAR_0;
}
if ((VAR_1 > channel_subsys.max_ssid) ||
(guest_cssid > channel_subsys.max_cssid) ||
((channel_subsys.max_cssid == 0) &&
(VAR_0 != channel_subsys.default_cssid))) {
return;
}
chain_crw = (channel_subsys.max_ssid > 0) ||
(channel_subsys.max_cssid > 0);
css_queue_crw(CRW_RSC_SUBCH, CRW_ERC_IPI, chain_crw ? 1 : 0, VAR_2);
if (chain_crw) {
css_queue_crw(CRW_RSC_SUBCH, CRW_ERC_IPI, 0,
(guest_cssid << 8) | (VAR_1 << 4));
}
css_clear_io_interrupt(css_do_build_subchannel_id(VAR_0, VAR_1), VAR_2);
}
| [
"void FUNC_0(uint8_t VAR_0, uint8_t VAR_1, uint16_t VAR_2,\nint VAR_3, int VAR_4)\n{",
"uint8_t guest_cssid;",
"bool chain_crw;",
"if (VAR_4 && !VAR_3) {",
"return;",
"}",
"if (channel_subsys.max_cssid == 0) {",
"guest_cssid = (VAR_0 == channel_subsys.default_cssid) ? 0 : VAR_0;",
"} else {",
"guest_cssid = VAR_0;",
"}",
"if ((VAR_1 > channel_subsys.max_ssid) ||\n(guest_cssid > channel_subsys.max_cssid) ||\n((channel_subsys.max_cssid == 0) &&\n(VAR_0 != channel_subsys.default_cssid))) {",
"return;",
"}",
"chain_crw = (channel_subsys.max_ssid > 0) ||\n(channel_subsys.max_cssid > 0);",
"css_queue_crw(CRW_RSC_SUBCH, CRW_ERC_IPI, chain_crw ? 1 : 0, VAR_2);",
"if (chain_crw) {",
"css_queue_crw(CRW_RSC_SUBCH, CRW_ERC_IPI, 0,\n(guest_cssid << 8) | (VAR_1 << 4));",
"}",
"css_clear_io_interrupt(css_do_build_subchannel_id(VAR_0, VAR_1), VAR_2);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
29
],
[
31
],
[
41,
43,
45,
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
69
],
[
71
]
] |
18,354 | static void term_insert_char(int ch)
{
if (term_cmd_buf_index < TERM_CMD_BUF_SIZE) {
memmove(term_cmd_buf + term_cmd_buf_index + 1,
term_cmd_buf + term_cmd_buf_index,
term_cmd_buf_size - term_cmd_buf_index);
term_cmd_buf[term_cmd_buf_index] = ch;
term_cmd_buf_size++;
term_cmd_buf_index++;
}
}
| false | qemu | 7e2515e87c41e2e658aaed466e11cbdf1ea8bcb1 | static void term_insert_char(int ch)
{
if (term_cmd_buf_index < TERM_CMD_BUF_SIZE) {
memmove(term_cmd_buf + term_cmd_buf_index + 1,
term_cmd_buf + term_cmd_buf_index,
term_cmd_buf_size - term_cmd_buf_index);
term_cmd_buf[term_cmd_buf_index] = ch;
term_cmd_buf_size++;
term_cmd_buf_index++;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(int VAR_0)
{
if (term_cmd_buf_index < TERM_CMD_BUF_SIZE) {
memmove(term_cmd_buf + term_cmd_buf_index + 1,
term_cmd_buf + term_cmd_buf_index,
term_cmd_buf_size - term_cmd_buf_index);
term_cmd_buf[term_cmd_buf_index] = VAR_0;
term_cmd_buf_size++;
term_cmd_buf_index++;
}
}
| [
"static void FUNC_0(int VAR_0)\n{",
"if (term_cmd_buf_index < TERM_CMD_BUF_SIZE) {",
"memmove(term_cmd_buf + term_cmd_buf_index + 1,\nterm_cmd_buf + term_cmd_buf_index,\nterm_cmd_buf_size - term_cmd_buf_index);",
"term_cmd_buf[term_cmd_buf_index] = VAR_0;",
"term_cmd_buf_size++;",
"term_cmd_buf_index++;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
18,355 | static void spapr_phb_add_pci_device(sPAPRDRConnector *drc,
sPAPRPHBState *phb,
PCIDevice *pdev,
Error **errp)
{
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
DeviceState *dev = DEVICE(pdev);
int drc_index = drck->get_index(drc);
void *fdt = NULL;
int fdt_start_offset = 0, fdt_size;
if (dev->hotplugged) {
fdt = create_device_tree(&fdt_size);
fdt_start_offset = spapr_create_pci_child_dt(phb, pdev,
drc_index, NULL,
fdt, 0);
if (!fdt_start_offset) {
error_setg(errp, "Failed to create pci child device tree node");
goto out;
}
}
drck->attach(drc, DEVICE(pdev),
fdt, fdt_start_offset, !dev->hotplugged, errp);
out:
if (*errp) {
g_free(fdt);
}
}
| false | qemu | e634b89c6ed2309814de7a89bd7c5ced96f59291 | static void spapr_phb_add_pci_device(sPAPRDRConnector *drc,
sPAPRPHBState *phb,
PCIDevice *pdev,
Error **errp)
{
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
DeviceState *dev = DEVICE(pdev);
int drc_index = drck->get_index(drc);
void *fdt = NULL;
int fdt_start_offset = 0, fdt_size;
if (dev->hotplugged) {
fdt = create_device_tree(&fdt_size);
fdt_start_offset = spapr_create_pci_child_dt(phb, pdev,
drc_index, NULL,
fdt, 0);
if (!fdt_start_offset) {
error_setg(errp, "Failed to create pci child device tree node");
goto out;
}
}
drck->attach(drc, DEVICE(pdev),
fdt, fdt_start_offset, !dev->hotplugged, errp);
out:
if (*errp) {
g_free(fdt);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(sPAPRDRConnector *VAR_0,
sPAPRPHBState *VAR_1,
PCIDevice *VAR_2,
Error **VAR_3)
{
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(VAR_0);
DeviceState *dev = DEVICE(VAR_2);
int VAR_4 = drck->get_index(VAR_0);
void *VAR_5 = NULL;
int VAR_6 = 0, VAR_7;
if (dev->hotplugged) {
VAR_5 = create_device_tree(&VAR_7);
VAR_6 = spapr_create_pci_child_dt(VAR_1, VAR_2,
VAR_4, NULL,
VAR_5, 0);
if (!VAR_6) {
error_setg(VAR_3, "Failed to create pci child device tree node");
goto out;
}
}
drck->attach(VAR_0, DEVICE(VAR_2),
VAR_5, VAR_6, !dev->hotplugged, VAR_3);
out:
if (*VAR_3) {
g_free(VAR_5);
}
}
| [
"static void FUNC_0(sPAPRDRConnector *VAR_0,\nsPAPRPHBState *VAR_1,\nPCIDevice *VAR_2,\nError **VAR_3)\n{",
"sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(VAR_0);",
"DeviceState *dev = DEVICE(VAR_2);",
"int VAR_4 = drck->get_index(VAR_0);",
"void *VAR_5 = NULL;",
"int VAR_6 = 0, VAR_7;",
"if (dev->hotplugged) {",
"VAR_5 = create_device_tree(&VAR_7);",
"VAR_6 = spapr_create_pci_child_dt(VAR_1, VAR_2,\nVAR_4, NULL,\nVAR_5, 0);",
"if (!VAR_6) {",
"error_setg(VAR_3, \"Failed to create pci child device tree node\");",
"goto out;",
"}",
"}",
"drck->attach(VAR_0, DEVICE(VAR_2),\nVAR_5, VAR_6, !dev->hotplugged, VAR_3);",
"out:\nif (*VAR_3) {",
"g_free(VAR_5);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27,
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45,
47
],
[
49,
51
],
[
53
],
[
55
],
[
57
]
] |
18,357 | static void decode_scaling_matrices(H264Context *h, SPS *sps,
PPS *pps, int is_sps,
uint8_t(*scaling_matrix4)[16],
uint8_t(*scaling_matrix8)[64])
{
int fallback_sps = !is_sps && sps->scaling_matrix_present;
const uint8_t *fallback[4] = {
fallback_sps ? sps->scaling_matrix4[0] : default_scaling4[0],
fallback_sps ? sps->scaling_matrix4[3] : default_scaling4[1],
fallback_sps ? sps->scaling_matrix8[0] : default_scaling8[0],
fallback_sps ? sps->scaling_matrix8[3] : default_scaling8[1]
};
if (get_bits1(&h->gb)) {
sps->scaling_matrix_present |= is_sps;
decode_scaling_list(h, scaling_matrix4[0], 16, default_scaling4[0], fallback[0]); // Intra, Y
decode_scaling_list(h, scaling_matrix4[1], 16, default_scaling4[0], scaling_matrix4[0]); // Intra, Cr
decode_scaling_list(h, scaling_matrix4[2], 16, default_scaling4[0], scaling_matrix4[1]); // Intra, Cb
decode_scaling_list(h, scaling_matrix4[3], 16, default_scaling4[1], fallback[1]); // Inter, Y
decode_scaling_list(h, scaling_matrix4[4], 16, default_scaling4[1], scaling_matrix4[3]); // Inter, Cr
decode_scaling_list(h, scaling_matrix4[5], 16, default_scaling4[1], scaling_matrix4[4]); // Inter, Cb
if (is_sps || pps->transform_8x8_mode) {
decode_scaling_list(h, scaling_matrix8[0], 64, default_scaling8[0], fallback[2]); // Intra, Y
if (sps->chroma_format_idc == 3) {
decode_scaling_list(h, scaling_matrix8[1], 64, default_scaling8[0], scaling_matrix8[0]); // Intra, Cr
decode_scaling_list(h, scaling_matrix8[2], 64, default_scaling8[0], scaling_matrix8[1]); // Intra, Cb
}
decode_scaling_list(h, scaling_matrix8[3], 64, default_scaling8[1], fallback[3]); // Inter, Y
if (sps->chroma_format_idc == 3) {
decode_scaling_list(h, scaling_matrix8[4], 64, default_scaling8[1], scaling_matrix8[3]); // Inter, Cr
decode_scaling_list(h, scaling_matrix8[5], 64, default_scaling8[1], scaling_matrix8[4]); // Inter, Cb
}
}
}
}
| false | FFmpeg | 3176217c60ca7828712985092d9102d331ea4f3d | static void decode_scaling_matrices(H264Context *h, SPS *sps,
PPS *pps, int is_sps,
uint8_t(*scaling_matrix4)[16],
uint8_t(*scaling_matrix8)[64])
{
int fallback_sps = !is_sps && sps->scaling_matrix_present;
const uint8_t *fallback[4] = {
fallback_sps ? sps->scaling_matrix4[0] : default_scaling4[0],
fallback_sps ? sps->scaling_matrix4[3] : default_scaling4[1],
fallback_sps ? sps->scaling_matrix8[0] : default_scaling8[0],
fallback_sps ? sps->scaling_matrix8[3] : default_scaling8[1]
};
if (get_bits1(&h->gb)) {
sps->scaling_matrix_present |= is_sps;
decode_scaling_list(h, scaling_matrix4[0], 16, default_scaling4[0], fallback[0]);
decode_scaling_list(h, scaling_matrix4[1], 16, default_scaling4[0], scaling_matrix4[0]);
decode_scaling_list(h, scaling_matrix4[2], 16, default_scaling4[0], scaling_matrix4[1]);
decode_scaling_list(h, scaling_matrix4[3], 16, default_scaling4[1], fallback[1]);
decode_scaling_list(h, scaling_matrix4[4], 16, default_scaling4[1], scaling_matrix4[3]);
decode_scaling_list(h, scaling_matrix4[5], 16, default_scaling4[1], scaling_matrix4[4]);
if (is_sps || pps->transform_8x8_mode) {
decode_scaling_list(h, scaling_matrix8[0], 64, default_scaling8[0], fallback[2]);
if (sps->chroma_format_idc == 3) {
decode_scaling_list(h, scaling_matrix8[1], 64, default_scaling8[0], scaling_matrix8[0]);
decode_scaling_list(h, scaling_matrix8[2], 64, default_scaling8[0], scaling_matrix8[1]);
}
decode_scaling_list(h, scaling_matrix8[3], 64, default_scaling8[1], fallback[3]);
if (sps->chroma_format_idc == 3) {
decode_scaling_list(h, scaling_matrix8[4], 64, default_scaling8[1], scaling_matrix8[3]);
decode_scaling_list(h, scaling_matrix8[5], 64, default_scaling8[1], scaling_matrix8[4]);
}
}
}
}
| {
"code": [],
"line_no": []
} | VAR_5staticVAR_5 VAR_5voidVAR_5 VAR_5decode_scaling_matricesVAR_5(VAR_5H264ContextVAR_5 *VAR_5VAR_0VAR_5, VAR_5SPSVAR_5 *VAR_5VAR_1VAR_5,
VAR_5PPSVAR_5 *VAR_5VAR_2VAR_5, VAR_5intVAR_5 VAR_5VAR_3VAR_5,
VAR_5VAR_4VAR_5(*VAR_5scaling_matrix4VAR_5)[VAR_516VAR_5],
VAR_5VAR_4VAR_5(*VAR_5scaling_matrix8VAR_5)[VAR_564VAR_5])
{
VAR_5intVAR_5 VAR_5fallback_spsVAR_5 = !VAR_5VAR_3VAR_5 && VAR_5VAR_1VAR_5->VAR_5scaling_matrix_presentVAR_5;
VAR_5constVAR_5 VAR_5VAR_4VAR_5 *VAR_5fallbackVAR_5[VAR_54VAR_5] = {
VAR_5fallback_spsVAR_5 ? VAR_5VAR_1VAR_5->VAR_5scaling_matrix4VAR_5[VAR_50VAR_5] : VAR_5default_scaling4VAR_5[VAR_50VAR_5],
VAR_5fallback_spsVAR_5 ? VAR_5VAR_1VAR_5->VAR_5scaling_matrix4VAR_5[VAR_53VAR_5] : VAR_5default_scaling4VAR_5[VAR_51VAR_5],
VAR_5fallback_spsVAR_5 ? VAR_5VAR_1VAR_5->VAR_5scaling_matrix8VAR_5[VAR_50VAR_5] : VAR_5default_scaling8VAR_5[VAR_50VAR_5],
VAR_5fallback_spsVAR_5 ? VAR_5VAR_1VAR_5->VAR_5scaling_matrix8VAR_5[VAR_53VAR_5] : VAR_5default_scaling8VAR_5[VAR_51VAR_5]
};
VAR_5ifVAR_5 (VAR_5get_bits1VAR_5(&VAR_5VAR_0VAR_5->VAR_5gbVAR_5)) {
VAR_5VAR_1VAR_5->VAR_5scaling_matrix_presentVAR_5 |= VAR_5VAR_3VAR_5;
VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix4VAR_5[VAR_50VAR_5], VAR_516VAR_5, VAR_5default_scaling4VAR_5[VAR_50VAR_5], VAR_5fallbackVAR_5[VAR_50VAR_5]);
VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix4VAR_5[VAR_51VAR_5], VAR_516VAR_5, VAR_5default_scaling4VAR_5[VAR_50VAR_5], VAR_5scaling_matrix4VAR_5[VAR_50VAR_5]);
VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix4VAR_5[VAR_52VAR_5], VAR_516VAR_5, VAR_5default_scaling4VAR_5[VAR_50VAR_5], VAR_5scaling_matrix4VAR_5[VAR_51VAR_5]);
VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix4VAR_5[VAR_53VAR_5], VAR_516VAR_5, VAR_5default_scaling4VAR_5[VAR_51VAR_5], VAR_5fallbackVAR_5[VAR_51VAR_5]);
VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix4VAR_5[VAR_54VAR_5], VAR_516VAR_5, VAR_5default_scaling4VAR_5[VAR_51VAR_5], VAR_5scaling_matrix4VAR_5[VAR_53VAR_5]);
VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix4VAR_5[VAR_55VAR_5], VAR_516VAR_5, VAR_5default_scaling4VAR_5[VAR_51VAR_5], VAR_5scaling_matrix4VAR_5[VAR_54VAR_5]);
VAR_5ifVAR_5 (VAR_5VAR_3VAR_5 || VAR_5VAR_2VAR_5->VAR_5transform_8x8_modeVAR_5) {
VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix8VAR_5[VAR_50VAR_5], VAR_564VAR_5, VAR_5default_scaling8VAR_5[VAR_50VAR_5], VAR_5fallbackVAR_5[VAR_52VAR_5]);
VAR_5ifVAR_5 (VAR_5VAR_1VAR_5->VAR_5chroma_format_idcVAR_5 == VAR_53VAR_5) {
VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix8VAR_5[VAR_51VAR_5], VAR_564VAR_5, VAR_5default_scaling8VAR_5[VAR_50VAR_5], VAR_5scaling_matrix8VAR_5[VAR_50VAR_5]);
VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix8VAR_5[VAR_52VAR_5], VAR_564VAR_5, VAR_5default_scaling8VAR_5[VAR_50VAR_5], VAR_5scaling_matrix8VAR_5[VAR_51VAR_5]);
}
VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix8VAR_5[VAR_53VAR_5], VAR_564VAR_5, VAR_5default_scaling8VAR_5[VAR_51VAR_5], VAR_5fallbackVAR_5[VAR_53VAR_5]);
VAR_5ifVAR_5 (VAR_5VAR_1VAR_5->VAR_5chroma_format_idcVAR_5 == VAR_53VAR_5) {
VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix8VAR_5[VAR_54VAR_5], VAR_564VAR_5, VAR_5default_scaling8VAR_5[VAR_51VAR_5], VAR_5scaling_matrix8VAR_5[VAR_53VAR_5]);
VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix8VAR_5[VAR_55VAR_5], VAR_564VAR_5, VAR_5default_scaling8VAR_5[VAR_51VAR_5], VAR_5scaling_matrix8VAR_5[VAR_54VAR_5]);
}
}
}
}
| [
"VAR_5staticVAR_5 VAR_5voidVAR_5 VAR_5decode_scaling_matricesVAR_5(VAR_5H264ContextVAR_5 *VAR_5VAR_0VAR_5, VAR_5SPSVAR_5 *VAR_5VAR_1VAR_5,\nVAR_5PPSVAR_5 *VAR_5VAR_2VAR_5, VAR_5intVAR_5 VAR_5VAR_3VAR_5,\nVAR_5VAR_4VAR_5(*VAR_5scaling_matrix4VAR_5)[VAR_516VAR_5],\nVAR_5VAR_4VAR_5(*VAR_5scaling_matrix8VAR_5)[VAR_564VAR_5])\n{",
"VAR_5intVAR_5 VAR_5fallback_spsVAR_5 = !VAR_5VAR_3VAR_5 && VAR_5VAR_1VAR_5->VAR_5scaling_matrix_presentVAR_5;",
"VAR_5constVAR_5 VAR_5VAR_4VAR_5 *VAR_5fallbackVAR_5[VAR_54VAR_5] = {",
"VAR_5fallback_spsVAR_5 ? VAR_5VAR_1VAR_5->VAR_5scaling_matrix4VAR_5[VAR_50VAR_5] : VAR_5default_scaling4VAR_5[VAR_50VAR_5],\nVAR_5fallback_spsVAR_5 ? VAR_5VAR_1VAR_5->VAR_5scaling_matrix4VAR_5[VAR_53VAR_5] : VAR_5default_scaling4VAR_5[VAR_51VAR_5],\nVAR_5fallback_spsVAR_5 ? VAR_5VAR_1VAR_5->VAR_5scaling_matrix8VAR_5[VAR_50VAR_5] : VAR_5default_scaling8VAR_5[VAR_50VAR_5],\nVAR_5fallback_spsVAR_5 ? VAR_5VAR_1VAR_5->VAR_5scaling_matrix8VAR_5[VAR_53VAR_5] : VAR_5default_scaling8VAR_5[VAR_51VAR_5]\n};",
"VAR_5ifVAR_5 (VAR_5get_bits1VAR_5(&VAR_5VAR_0VAR_5->VAR_5gbVAR_5)) {",
"VAR_5VAR_1VAR_5->VAR_5scaling_matrix_presentVAR_5 |= VAR_5VAR_3VAR_5;",
"VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix4VAR_5[VAR_50VAR_5], VAR_516VAR_5, VAR_5default_scaling4VAR_5[VAR_50VAR_5], VAR_5fallbackVAR_5[VAR_50VAR_5]);",
"VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix4VAR_5[VAR_51VAR_5], VAR_516VAR_5, VAR_5default_scaling4VAR_5[VAR_50VAR_5], VAR_5scaling_matrix4VAR_5[VAR_50VAR_5]);",
"VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix4VAR_5[VAR_52VAR_5], VAR_516VAR_5, VAR_5default_scaling4VAR_5[VAR_50VAR_5], VAR_5scaling_matrix4VAR_5[VAR_51VAR_5]);",
"VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix4VAR_5[VAR_53VAR_5], VAR_516VAR_5, VAR_5default_scaling4VAR_5[VAR_51VAR_5], VAR_5fallbackVAR_5[VAR_51VAR_5]);",
"VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix4VAR_5[VAR_54VAR_5], VAR_516VAR_5, VAR_5default_scaling4VAR_5[VAR_51VAR_5], VAR_5scaling_matrix4VAR_5[VAR_53VAR_5]);",
"VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix4VAR_5[VAR_55VAR_5], VAR_516VAR_5, VAR_5default_scaling4VAR_5[VAR_51VAR_5], VAR_5scaling_matrix4VAR_5[VAR_54VAR_5]);",
"VAR_5ifVAR_5 (VAR_5VAR_3VAR_5 || VAR_5VAR_2VAR_5->VAR_5transform_8x8_modeVAR_5) {",
"VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix8VAR_5[VAR_50VAR_5], VAR_564VAR_5, VAR_5default_scaling8VAR_5[VAR_50VAR_5], VAR_5fallbackVAR_5[VAR_52VAR_5]);",
"VAR_5ifVAR_5 (VAR_5VAR_1VAR_5->VAR_5chroma_format_idcVAR_5 == VAR_53VAR_5) {",
"VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix8VAR_5[VAR_51VAR_5], VAR_564VAR_5, VAR_5default_scaling8VAR_5[VAR_50VAR_5], VAR_5scaling_matrix8VAR_5[VAR_50VAR_5]);",
"VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix8VAR_5[VAR_52VAR_5], VAR_564VAR_5, VAR_5default_scaling8VAR_5[VAR_50VAR_5], VAR_5scaling_matrix8VAR_5[VAR_51VAR_5]);",
"}",
"VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix8VAR_5[VAR_53VAR_5], VAR_564VAR_5, VAR_5default_scaling8VAR_5[VAR_51VAR_5], VAR_5fallbackVAR_5[VAR_53VAR_5]);",
"VAR_5ifVAR_5 (VAR_5VAR_1VAR_5->VAR_5chroma_format_idcVAR_5 == VAR_53VAR_5) {",
"VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix8VAR_5[VAR_54VAR_5], VAR_564VAR_5, VAR_5default_scaling8VAR_5[VAR_51VAR_5], VAR_5scaling_matrix8VAR_5[VAR_53VAR_5]);",
"VAR_5decode_scaling_listVAR_5(VAR_5VAR_0VAR_5, VAR_5scaling_matrix8VAR_5[VAR_55VAR_5], VAR_564VAR_5, VAR_5default_scaling8VAR_5[VAR_51VAR_5], VAR_5scaling_matrix8VAR_5[VAR_54VAR_5]);",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
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
]
] |
18,358 | static void macio_nvram_writeb(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
MacIONVRAMState *s = opaque;
addr = (addr >> s->it_shift) & (s->size - 1);
s->data[addr] = value;
NVR_DPRINTF("writeb addr %04x val %x\n", (int)addr, value);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void macio_nvram_writeb(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
MacIONVRAMState *s = opaque;
addr = (addr >> s->it_shift) & (s->size - 1);
s->data[addr] = value;
NVR_DPRINTF("writeb addr %04x val %x\n", (int)addr, value);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
MacIONVRAMState *s = VAR_0;
VAR_1 = (VAR_1 >> s->it_shift) & (s->VAR_3 - 1);
s->data[VAR_1] = VAR_2;
NVR_DPRINTF("writeb VAR_1 %04x val %x\n", (int)VAR_1, VAR_2);
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"MacIONVRAMState *s = VAR_0;",
"VAR_1 = (VAR_1 >> s->it_shift) & (s->VAR_3 - 1);",
"s->data[VAR_1] = VAR_2;",
"NVR_DPRINTF(\"writeb VAR_1 %04x val %x\\n\", (int)VAR_1, VAR_2);",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
18,359 | static void fill_prstatus(struct target_elf_prstatus *prstatus,
const TaskState *ts, int signr)
{
(void) memset(prstatus, 0, sizeof (*prstatus));
prstatus->pr_info.si_signo = prstatus->pr_cursig = signr;
prstatus->pr_pid = ts->ts_tid;
prstatus->pr_ppid = getppid();
prstatus->pr_pgrp = getpgrp();
prstatus->pr_sid = getsid(0);
#ifdef BSWAP_NEEDED
bswap_prstatus(prstatus);
#endif
}
| false | qemu | 991f8f0c91d65cebf51fa931450e02b0d5209012 | static void fill_prstatus(struct target_elf_prstatus *prstatus,
const TaskState *ts, int signr)
{
(void) memset(prstatus, 0, sizeof (*prstatus));
prstatus->pr_info.si_signo = prstatus->pr_cursig = signr;
prstatus->pr_pid = ts->ts_tid;
prstatus->pr_ppid = getppid();
prstatus->pr_pgrp = getpgrp();
prstatus->pr_sid = getsid(0);
#ifdef BSWAP_NEEDED
bswap_prstatus(prstatus);
#endif
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(struct target_elf_prstatus *VAR_0,
const TaskState *VAR_1, int VAR_2)
{
(void) memset(VAR_0, 0, sizeof (*VAR_0));
VAR_0->pr_info.si_signo = VAR_0->pr_cursig = VAR_2;
VAR_0->pr_pid = VAR_1->ts_tid;
VAR_0->pr_ppid = getppid();
VAR_0->pr_pgrp = getpgrp();
VAR_0->pr_sid = getsid(0);
#ifdef BSWAP_NEEDED
bswap_prstatus(VAR_0);
#endif
}
| [
"static void FUNC_0(struct target_elf_prstatus *VAR_0,\nconst TaskState *VAR_1, int VAR_2)\n{",
"(void) memset(VAR_0, 0, sizeof (*VAR_0));",
"VAR_0->pr_info.si_signo = VAR_0->pr_cursig = VAR_2;",
"VAR_0->pr_pid = VAR_1->ts_tid;",
"VAR_0->pr_ppid = getppid();",
"VAR_0->pr_pgrp = getpgrp();",
"VAR_0->pr_sid = getsid(0);",
"#ifdef BSWAP_NEEDED\nbswap_prstatus(VAR_0);",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21,
23
],
[
25,
27
]
] |
18,360 | static int usb_host_read_file(char *line, size_t line_size, const char *device_file, const char *device_name)
{
FILE *f;
int ret = 0;
char filename[PATH_MAX];
snprintf(filename, PATH_MAX, device_file, device_name);
f = fopen(filename, "r");
if (f) {
fgets(line, line_size, f);
fclose(f);
ret = 1;
} else {
term_printf("husb: could not open %s\n", filename);
}
return ret;
}
| false | qemu | b4e237aae774a6dd3de2c3db9f87012d48ab6716 | static int usb_host_read_file(char *line, size_t line_size, const char *device_file, const char *device_name)
{
FILE *f;
int ret = 0;
char filename[PATH_MAX];
snprintf(filename, PATH_MAX, device_file, device_name);
f = fopen(filename, "r");
if (f) {
fgets(line, line_size, f);
fclose(f);
ret = 1;
} else {
term_printf("husb: could not open %s\n", filename);
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(char *VAR_0, size_t VAR_1, const char *VAR_2, const char *VAR_3)
{
FILE *f;
int VAR_4 = 0;
char VAR_5[PATH_MAX];
snprintf(VAR_5, PATH_MAX, VAR_2, VAR_3);
f = fopen(VAR_5, "r");
if (f) {
fgets(VAR_0, VAR_1, f);
fclose(f);
VAR_4 = 1;
} else {
term_printf("husb: could not open %s\n", VAR_5);
}
return VAR_4;
}
| [
"static int FUNC_0(char *VAR_0, size_t VAR_1, const char *VAR_2, const char *VAR_3)\n{",
"FILE *f;",
"int VAR_4 = 0;",
"char VAR_5[PATH_MAX];",
"snprintf(VAR_5, PATH_MAX, VAR_2, VAR_3);",
"f = fopen(VAR_5, \"r\");",
"if (f) {",
"fgets(VAR_0, VAR_1, f);",
"fclose(f);",
"VAR_4 = 1;",
"} else {",
"term_printf(\"husb: could not open %s\\n\", VAR_5);",
"}",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
]
] |
18,362 | static uint32_t sdhci_read_dataport(SDHCIState *s, unsigned size)
{
uint32_t value = 0;
int i;
/* first check that a valid data exists in host controller input buffer */
if ((s->prnsts & SDHC_DATA_AVAILABLE) == 0) {
ERRPRINT("Trying to read from empty buffer\n");
return 0;
}
for (i = 0; i < size; i++) {
value |= s->fifo_buffer[s->data_count] << i * 8;
s->data_count++;
/* check if we've read all valid data (blksize bytes) from buffer */
if ((s->data_count) >= (s->blksize & 0x0fff)) {
DPRINT_L2("All %u bytes of data have been read from input buffer\n",
s->data_count);
s->prnsts &= ~SDHC_DATA_AVAILABLE; /* no more data in a buffer */
s->data_count = 0; /* next buff read must start at position [0] */
if (s->trnmod & SDHC_TRNS_BLK_CNT_EN) {
s->blkcnt--;
}
/* if that was the last block of data */
if ((s->trnmod & SDHC_TRNS_MULTI) == 0 ||
((s->trnmod & SDHC_TRNS_BLK_CNT_EN) && (s->blkcnt == 0)) ||
/* stop at gap request */
(s->stopped_state == sdhc_gap_read &&
!(s->prnsts & SDHC_DAT_LINE_ACTIVE))) {
SDHCI_GET_CLASS(s)->end_data_transfer(s);
} else { /* if there are more data, read next block from card */
SDHCI_GET_CLASS(s)->read_block_from_card(s);
}
break;
}
}
return value;
}
| false | qemu | d368ba4376b2c1c24175c74b3733b8fe64dbe8a6 | static uint32_t sdhci_read_dataport(SDHCIState *s, unsigned size)
{
uint32_t value = 0;
int i;
if ((s->prnsts & SDHC_DATA_AVAILABLE) == 0) {
ERRPRINT("Trying to read from empty buffer\n");
return 0;
}
for (i = 0; i < size; i++) {
value |= s->fifo_buffer[s->data_count] << i * 8;
s->data_count++;
if ((s->data_count) >= (s->blksize & 0x0fff)) {
DPRINT_L2("All %u bytes of data have been read from input buffer\n",
s->data_count);
s->prnsts &= ~SDHC_DATA_AVAILABLE;
s->data_count = 0;
if (s->trnmod & SDHC_TRNS_BLK_CNT_EN) {
s->blkcnt--;
}
if ((s->trnmod & SDHC_TRNS_MULTI) == 0 ||
((s->trnmod & SDHC_TRNS_BLK_CNT_EN) && (s->blkcnt == 0)) ||
(s->stopped_state == sdhc_gap_read &&
!(s->prnsts & SDHC_DAT_LINE_ACTIVE))) {
SDHCI_GET_CLASS(s)->end_data_transfer(s);
} else {
SDHCI_GET_CLASS(s)->read_block_from_card(s);
}
break;
}
}
return value;
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(SDHCIState *s, unsigned size)
{
uint32_t value = 0;
int VAR_0;
if ((s->prnsts & SDHC_DATA_AVAILABLE) == 0) {
ERRPRINT("Trying to read from empty buffer\n");
return 0;
}
for (VAR_0 = 0; VAR_0 < size; VAR_0++) {
value |= s->fifo_buffer[s->data_count] << VAR_0 * 8;
s->data_count++;
if ((s->data_count) >= (s->blksize & 0x0fff)) {
DPRINT_L2("All %u bytes of data have been read from input buffer\n",
s->data_count);
s->prnsts &= ~SDHC_DATA_AVAILABLE;
s->data_count = 0;
if (s->trnmod & SDHC_TRNS_BLK_CNT_EN) {
s->blkcnt--;
}
if ((s->trnmod & SDHC_TRNS_MULTI) == 0 ||
((s->trnmod & SDHC_TRNS_BLK_CNT_EN) && (s->blkcnt == 0)) ||
(s->stopped_state == sdhc_gap_read &&
!(s->prnsts & SDHC_DAT_LINE_ACTIVE))) {
SDHCI_GET_CLASS(s)->end_data_transfer(s);
} else {
SDHCI_GET_CLASS(s)->read_block_from_card(s);
}
break;
}
}
return value;
}
| [
"static uint32_t FUNC_0(SDHCIState *s, unsigned size)\n{",
"uint32_t value = 0;",
"int VAR_0;",
"if ((s->prnsts & SDHC_DATA_AVAILABLE) == 0) {",
"ERRPRINT(\"Trying to read from empty buffer\\n\");",
"return 0;",
"}",
"for (VAR_0 = 0; VAR_0 < size; VAR_0++) {",
"value |= s->fifo_buffer[s->data_count] << VAR_0 * 8;",
"s->data_count++;",
"if ((s->data_count) >= (s->blksize & 0x0fff)) {",
"DPRINT_L2(\"All %u bytes of data have been read from input buffer\\n\",\ns->data_count);",
"s->prnsts &= ~SDHC_DATA_AVAILABLE;",
"s->data_count = 0;",
"if (s->trnmod & SDHC_TRNS_BLK_CNT_EN) {",
"s->blkcnt--;",
"}",
"if ((s->trnmod & SDHC_TRNS_MULTI) == 0 ||\n((s->trnmod & SDHC_TRNS_BLK_CNT_EN) && (s->blkcnt == 0)) ||\n(s->stopped_state == sdhc_gap_read &&\n!(s->prnsts & SDHC_DAT_LINE_ACTIVE))) {",
"SDHCI_GET_CLASS(s)->end_data_transfer(s);",
"} else {",
"SDHCI_GET_CLASS(s)->read_block_from_card(s);",
"}",
"break;",
"}",
"}",
"return value;",
"}"
] | [
0,
0,
0,
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
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
53,
55,
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
]
] |
18,363 | static void pc_fw_add_pflash_drv(void)
{
QemuOpts *opts;
QEMUMachine *machine;
char *filename;
if (bios_name == NULL) {
bios_name = BIOS_FILENAME;
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
opts = drive_add(IF_PFLASH, -1, filename, "readonly=on");
g_free(filename);
if (opts == NULL) {
return;
}
machine = find_default_machine();
if (machine == NULL) {
return;
}
if (!drive_init(opts, machine->use_scsi)) {
qemu_opts_del(opts);
}
}
| false | qemu | 2d0d2837dcf786da415cf4165d37f4ddd684ff57 | static void pc_fw_add_pflash_drv(void)
{
QemuOpts *opts;
QEMUMachine *machine;
char *filename;
if (bios_name == NULL) {
bios_name = BIOS_FILENAME;
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
opts = drive_add(IF_PFLASH, -1, filename, "readonly=on");
g_free(filename);
if (opts == NULL) {
return;
}
machine = find_default_machine();
if (machine == NULL) {
return;
}
if (!drive_init(opts, machine->use_scsi)) {
qemu_opts_del(opts);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
QemuOpts *opts;
QEMUMachine *machine;
char *VAR_0;
if (bios_name == NULL) {
bios_name = BIOS_FILENAME;
}
VAR_0 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
opts = drive_add(IF_PFLASH, -1, VAR_0, "readonly=on");
g_free(VAR_0);
if (opts == NULL) {
return;
}
machine = find_default_machine();
if (machine == NULL) {
return;
}
if (!drive_init(opts, machine->use_scsi)) {
qemu_opts_del(opts);
}
}
| [
"static void FUNC_0(void)\n{",
"QemuOpts *opts;",
"QEMUMachine *machine;",
"char *VAR_0;",
"if (bios_name == NULL) {",
"bios_name = BIOS_FILENAME;",
"}",
"VAR_0 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);",
"opts = drive_add(IF_PFLASH, -1, VAR_0, \"readonly=on\");",
"g_free(VAR_0);",
"if (opts == NULL) {",
"return;",
"}",
"machine = find_default_machine();",
"if (machine == NULL) {",
"return;",
"}",
"if (!drive_init(opts, machine->use_scsi)) {",
"qemu_opts_del(opts);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
]
] |
18,364 | static void escc_mem_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
SerialState *serial = opaque;
ChannelState *s;
uint32_t saddr;
int newreg, channel;
val &= 0xff;
saddr = (addr >> serial->it_shift) & 1;
channel = (addr >> (serial->it_shift + 1)) & 1;
s = &serial->chn[channel];
switch (saddr) {
case SERIAL_CTRL:
trace_escc_mem_writeb_ctrl(CHN_C(s), s->reg, val & 0xff);
newreg = 0;
switch (s->reg) {
case W_CMD:
newreg = val & CMD_PTR_MASK;
val &= CMD_CMD_MASK;
switch (val) {
case CMD_HI:
newreg |= CMD_HI;
break;
case CMD_CLR_TXINT:
clr_txint(s);
break;
case CMD_CLR_IUS:
if (s->rxint_under_svc) {
s->rxint_under_svc = 0;
if (s->txint) {
set_txint(s);
}
} else if (s->txint_under_svc) {
s->txint_under_svc = 0;
}
escc_update_irq(s);
break;
default:
break;
}
break;
case W_INTR ... W_RXCTRL:
case W_SYNC1 ... W_TXBUF:
case W_MISC1 ... W_CLOCK:
case W_MISC2 ... W_EXTINT:
s->wregs[s->reg] = val;
break;
case W_TXCTRL1:
case W_TXCTRL2:
s->wregs[s->reg] = val;
escc_update_parameters(s);
break;
case W_BRGLO:
case W_BRGHI:
s->wregs[s->reg] = val;
s->rregs[s->reg] = val;
escc_update_parameters(s);
break;
case W_MINTR:
switch (val & MINTR_RST_MASK) {
case 0:
default:
break;
case MINTR_RST_B:
escc_reset_chn(&serial->chn[0]);
return;
case MINTR_RST_A:
escc_reset_chn(&serial->chn[1]);
return;
case MINTR_RST_ALL:
escc_reset(&serial->busdev.qdev);
return;
}
break;
default:
break;
}
if (s->reg == 0)
s->reg = newreg;
else
s->reg = 0;
break;
case SERIAL_DATA:
trace_escc_mem_writeb_data(CHN_C(s), val);
s->tx = val;
if (s->wregs[W_TXCTRL2] & TXCTRL2_TXEN) { // tx enabled
if (s->chr)
qemu_chr_fe_write(s->chr, &s->tx, 1);
else if (s->type == kbd && !s->disabled) {
handle_kbd_command(s, val);
}
}
s->rregs[R_STATUS] |= STATUS_TXEMPTY; // Tx buffer empty
s->rregs[R_SPEC] |= SPEC_ALLSENT; // All sent
set_txint(s);
break;
default:
break;
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void escc_mem_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
SerialState *serial = opaque;
ChannelState *s;
uint32_t saddr;
int newreg, channel;
val &= 0xff;
saddr = (addr >> serial->it_shift) & 1;
channel = (addr >> (serial->it_shift + 1)) & 1;
s = &serial->chn[channel];
switch (saddr) {
case SERIAL_CTRL:
trace_escc_mem_writeb_ctrl(CHN_C(s), s->reg, val & 0xff);
newreg = 0;
switch (s->reg) {
case W_CMD:
newreg = val & CMD_PTR_MASK;
val &= CMD_CMD_MASK;
switch (val) {
case CMD_HI:
newreg |= CMD_HI;
break;
case CMD_CLR_TXINT:
clr_txint(s);
break;
case CMD_CLR_IUS:
if (s->rxint_under_svc) {
s->rxint_under_svc = 0;
if (s->txint) {
set_txint(s);
}
} else if (s->txint_under_svc) {
s->txint_under_svc = 0;
}
escc_update_irq(s);
break;
default:
break;
}
break;
case W_INTR ... W_RXCTRL:
case W_SYNC1 ... W_TXBUF:
case W_MISC1 ... W_CLOCK:
case W_MISC2 ... W_EXTINT:
s->wregs[s->reg] = val;
break;
case W_TXCTRL1:
case W_TXCTRL2:
s->wregs[s->reg] = val;
escc_update_parameters(s);
break;
case W_BRGLO:
case W_BRGHI:
s->wregs[s->reg] = val;
s->rregs[s->reg] = val;
escc_update_parameters(s);
break;
case W_MINTR:
switch (val & MINTR_RST_MASK) {
case 0:
default:
break;
case MINTR_RST_B:
escc_reset_chn(&serial->chn[0]);
return;
case MINTR_RST_A:
escc_reset_chn(&serial->chn[1]);
return;
case MINTR_RST_ALL:
escc_reset(&serial->busdev.qdev);
return;
}
break;
default:
break;
}
if (s->reg == 0)
s->reg = newreg;
else
s->reg = 0;
break;
case SERIAL_DATA:
trace_escc_mem_writeb_data(CHN_C(s), val);
s->tx = val;
if (s->wregs[W_TXCTRL2] & TXCTRL2_TXEN) {
if (s->chr)
qemu_chr_fe_write(s->chr, &s->tx, 1);
else if (s->type == kbd && !s->disabled) {
handle_kbd_command(s, val);
}
}
s->rregs[R_STATUS] |= STATUS_TXEMPTY;
s->rregs[R_SPEC] |= SPEC_ALLSENT;
set_txint(s);
break;
default:
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
SerialState *serial = VAR_0;
ChannelState *s;
uint32_t saddr;
int VAR_4, VAR_5;
VAR_2 &= 0xff;
saddr = (VAR_1 >> serial->it_shift) & 1;
VAR_5 = (VAR_1 >> (serial->it_shift + 1)) & 1;
s = &serial->chn[VAR_5];
switch (saddr) {
case SERIAL_CTRL:
trace_escc_mem_writeb_ctrl(CHN_C(s), s->reg, VAR_2 & 0xff);
VAR_4 = 0;
switch (s->reg) {
case W_CMD:
VAR_4 = VAR_2 & CMD_PTR_MASK;
VAR_2 &= CMD_CMD_MASK;
switch (VAR_2) {
case CMD_HI:
VAR_4 |= CMD_HI;
break;
case CMD_CLR_TXINT:
clr_txint(s);
break;
case CMD_CLR_IUS:
if (s->rxint_under_svc) {
s->rxint_under_svc = 0;
if (s->txint) {
set_txint(s);
}
} else if (s->txint_under_svc) {
s->txint_under_svc = 0;
}
escc_update_irq(s);
break;
default:
break;
}
break;
case W_INTR ... W_RXCTRL:
case W_SYNC1 ... W_TXBUF:
case W_MISC1 ... W_CLOCK:
case W_MISC2 ... W_EXTINT:
s->wregs[s->reg] = VAR_2;
break;
case W_TXCTRL1:
case W_TXCTRL2:
s->wregs[s->reg] = VAR_2;
escc_update_parameters(s);
break;
case W_BRGLO:
case W_BRGHI:
s->wregs[s->reg] = VAR_2;
s->rregs[s->reg] = VAR_2;
escc_update_parameters(s);
break;
case W_MINTR:
switch (VAR_2 & MINTR_RST_MASK) {
case 0:
default:
break;
case MINTR_RST_B:
escc_reset_chn(&serial->chn[0]);
return;
case MINTR_RST_A:
escc_reset_chn(&serial->chn[1]);
return;
case MINTR_RST_ALL:
escc_reset(&serial->busdev.qdev);
return;
}
break;
default:
break;
}
if (s->reg == 0)
s->reg = VAR_4;
else
s->reg = 0;
break;
case SERIAL_DATA:
trace_escc_mem_writeb_data(CHN_C(s), VAR_2);
s->tx = VAR_2;
if (s->wregs[W_TXCTRL2] & TXCTRL2_TXEN) {
if (s->chr)
qemu_chr_fe_write(s->chr, &s->tx, 1);
else if (s->type == kbd && !s->disabled) {
handle_kbd_command(s, VAR_2);
}
}
s->rregs[R_STATUS] |= STATUS_TXEMPTY;
s->rregs[R_SPEC] |= SPEC_ALLSENT;
set_txint(s);
break;
default:
break;
}
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"SerialState *serial = VAR_0;",
"ChannelState *s;",
"uint32_t saddr;",
"int VAR_4, VAR_5;",
"VAR_2 &= 0xff;",
"saddr = (VAR_1 >> serial->it_shift) & 1;",
"VAR_5 = (VAR_1 >> (serial->it_shift + 1)) & 1;",
"s = &serial->chn[VAR_5];",
"switch (saddr) {",
"case SERIAL_CTRL:\ntrace_escc_mem_writeb_ctrl(CHN_C(s), s->reg, VAR_2 & 0xff);",
"VAR_4 = 0;",
"switch (s->reg) {",
"case W_CMD:\nVAR_4 = VAR_2 & CMD_PTR_MASK;",
"VAR_2 &= CMD_CMD_MASK;",
"switch (VAR_2) {",
"case CMD_HI:\nVAR_4 |= CMD_HI;",
"break;",
"case CMD_CLR_TXINT:\nclr_txint(s);",
"break;",
"case CMD_CLR_IUS:\nif (s->rxint_under_svc) {",
"s->rxint_under_svc = 0;",
"if (s->txint) {",
"set_txint(s);",
"}",
"} else if (s->txint_under_svc) {",
"s->txint_under_svc = 0;",
"}",
"escc_update_irq(s);",
"break;",
"default:\nbreak;",
"}",
"break;",
"case W_INTR ... W_RXCTRL:\ncase W_SYNC1 ... W_TXBUF:\ncase W_MISC1 ... W_CLOCK:\ncase W_MISC2 ... W_EXTINT:\ns->wregs[s->reg] = VAR_2;",
"break;",
"case W_TXCTRL1:\ncase W_TXCTRL2:\ns->wregs[s->reg] = VAR_2;",
"escc_update_parameters(s);",
"break;",
"case W_BRGLO:\ncase W_BRGHI:\ns->wregs[s->reg] = VAR_2;",
"s->rregs[s->reg] = VAR_2;",
"escc_update_parameters(s);",
"break;",
"case W_MINTR:\nswitch (VAR_2 & MINTR_RST_MASK) {",
"case 0:\ndefault:\nbreak;",
"case MINTR_RST_B:\nescc_reset_chn(&serial->chn[0]);",
"return;",
"case MINTR_RST_A:\nescc_reset_chn(&serial->chn[1]);",
"return;",
"case MINTR_RST_ALL:\nescc_reset(&serial->busdev.qdev);",
"return;",
"}",
"break;",
"default:\nbreak;",
"}",
"if (s->reg == 0)\ns->reg = VAR_4;",
"else\ns->reg = 0;",
"break;",
"case SERIAL_DATA:\ntrace_escc_mem_writeb_data(CHN_C(s), VAR_2);",
"s->tx = VAR_2;",
"if (s->wregs[W_TXCTRL2] & TXCTRL2_TXEN) {",
"if (s->chr)\nqemu_chr_fe_write(s->chr, &s->tx, 1);",
"else if (s->type == kbd && !s->disabled) {",
"handle_kbd_command(s, VAR_2);",
"}",
"}",
"s->rregs[R_STATUS] |= STATUS_TXEMPTY;",
"s->rregs[R_SPEC] |= SPEC_ALLSENT;",
"set_txint(s);",
"break;",
"default:\nbreak;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
47
],
[
49,
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
85,
87,
89,
91,
93
],
[
95
],
[
97,
99,
101
],
[
103
],
[
105
],
[
107,
109,
111
],
[
113
],
[
115
],
[
117
],
[
119,
121
],
[
123,
125,
127
],
[
129,
131
],
[
133
],
[
135,
137
],
[
139
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
151,
153
],
[
155
],
[
157,
159
],
[
161,
163
],
[
165
],
[
167,
169
],
[
171
],
[
173
],
[
175,
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195,
197
],
[
199
],
[
201
]
] |
18,365 | int ff_cbs_write_packet(CodedBitstreamContext *ctx,
AVPacket *pkt,
CodedBitstreamFragment *frag)
{
int err;
err = ff_cbs_write_fragment_data(ctx, frag);
if (err < 0)
return err;
av_new_packet(pkt, frag->data_size);
if (err < 0)
return err;
memcpy(pkt->data, frag->data, frag->data_size);
pkt->size = frag->data_size;
return 0;
}
| false | FFmpeg | 476d301316aa5436c1d26cfc4858f36875637853 | int ff_cbs_write_packet(CodedBitstreamContext *ctx,
AVPacket *pkt,
CodedBitstreamFragment *frag)
{
int err;
err = ff_cbs_write_fragment_data(ctx, frag);
if (err < 0)
return err;
av_new_packet(pkt, frag->data_size);
if (err < 0)
return err;
memcpy(pkt->data, frag->data, frag->data_size);
pkt->size = frag->data_size;
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(CodedBitstreamContext *VAR_0,
AVPacket *VAR_1,
CodedBitstreamFragment *VAR_2)
{
int VAR_3;
VAR_3 = ff_cbs_write_fragment_data(VAR_0, VAR_2);
if (VAR_3 < 0)
return VAR_3;
av_new_packet(VAR_1, VAR_2->data_size);
if (VAR_3 < 0)
return VAR_3;
memcpy(VAR_1->data, VAR_2->data, VAR_2->data_size);
VAR_1->size = VAR_2->data_size;
return 0;
}
| [
"int FUNC_0(CodedBitstreamContext *VAR_0,\nAVPacket *VAR_1,\nCodedBitstreamFragment *VAR_2)\n{",
"int VAR_3;",
"VAR_3 = ff_cbs_write_fragment_data(VAR_0, VAR_2);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"av_new_packet(VAR_1, VAR_2->data_size);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"memcpy(VAR_1->data, VAR_2->data, VAR_2->data_size);",
"VAR_1->size = VAR_2->data_size;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
15,
17
],
[
21
],
[
23,
25
],
[
29
],
[
31
],
[
35
],
[
37
]
] |
18,367 | static av_cold int sunrast_encode_close(AVCodecContext *avctx)
{
av_frame_free(&avctx->coded_frame);
return 0;
}
| false | FFmpeg | d6604b29ef544793479d7fb4e05ef6622bb3e534 | static av_cold int sunrast_encode_close(AVCodecContext *avctx)
{
av_frame_free(&avctx->coded_frame);
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
av_frame_free(&avctx->coded_frame);
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"av_frame_free(&avctx->coded_frame);",
"return 0;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
18,368 | static void RENAME(yadif_filter_line)(uint8_t *dst, uint8_t *prev, uint8_t *cur,
uint8_t *next, int w, int prefs,
int mrefs, int parity, int mode)
{
DECLARE_ALIGNED(16, uint8_t, tmp0)[16];
DECLARE_ALIGNED(16, uint8_t, tmp1)[16];
DECLARE_ALIGNED(16, uint8_t, tmp2)[16];
DECLARE_ALIGNED(16, uint8_t, tmp3)[16];
int x;
#define FILTER\
for(x=0; x<w; x+=STEP){\
__asm__ volatile(\
"pxor "MM"7, "MM"7 \n\t"\
LOAD("(%[cur],%[mrefs])", MM"0") /* c = cur[x-refs] */\
LOAD("(%[cur],%[prefs])", MM"1") /* e = cur[x+refs] */\
LOAD("(%["prev2"])", MM"2") /* prev2[x] */\
LOAD("(%["next2"])", MM"3") /* next2[x] */\
MOVQ" "MM"3, "MM"4 \n\t"\
"paddw "MM"2, "MM"3 \n\t"\
"psraw $1, "MM"3 \n\t" /* d = (prev2[x] + next2[x])>>1 */\
MOVQ" "MM"0, %[tmp0] \n\t" /* c */\
MOVQ" "MM"3, %[tmp1] \n\t" /* d */\
MOVQ" "MM"1, %[tmp2] \n\t" /* e */\
"psubw "MM"4, "MM"2 \n\t"\
PABS( MM"4", MM"2") /* temporal_diff0 */\
LOAD("(%[prev],%[mrefs])", MM"3") /* prev[x-refs] */\
LOAD("(%[prev],%[prefs])", MM"4") /* prev[x+refs] */\
"psubw "MM"0, "MM"3 \n\t"\
"psubw "MM"1, "MM"4 \n\t"\
PABS( MM"5", MM"3")\
PABS( MM"5", MM"4")\
"paddw "MM"4, "MM"3 \n\t" /* temporal_diff1 */\
"psrlw $1, "MM"2 \n\t"\
"psrlw $1, "MM"3 \n\t"\
"pmaxsw "MM"3, "MM"2 \n\t"\
LOAD("(%[next],%[mrefs])", MM"3") /* next[x-refs] */\
LOAD("(%[next],%[prefs])", MM"4") /* next[x+refs] */\
"psubw "MM"0, "MM"3 \n\t"\
"psubw "MM"1, "MM"4 \n\t"\
PABS( MM"5", MM"3")\
PABS( MM"5", MM"4")\
"paddw "MM"4, "MM"3 \n\t" /* temporal_diff2 */\
"psrlw $1, "MM"3 \n\t"\
"pmaxsw "MM"3, "MM"2 \n\t"\
MOVQ" "MM"2, %[tmp3] \n\t" /* diff */\
\
"paddw "MM"0, "MM"1 \n\t"\
"paddw "MM"0, "MM"0 \n\t"\
"psubw "MM"1, "MM"0 \n\t"\
"psrlw $1, "MM"1 \n\t" /* spatial_pred */\
PABS( MM"2", MM"0") /* ABS(c-e) */\
\
MOVQU" -1(%[cur],%[mrefs]), "MM"2 \n\t" /* cur[x-refs-1] */\
MOVQU" -1(%[cur],%[prefs]), "MM"3 \n\t" /* cur[x+refs-1] */\
MOVQ" "MM"2, "MM"4 \n\t"\
"psubusb "MM"3, "MM"2 \n\t"\
"psubusb "MM"4, "MM"3 \n\t"\
"pmaxub "MM"3, "MM"2 \n\t"\
PSHUF(MM"3", MM"2") \
"punpcklbw "MM"7, "MM"2 \n\t" /* ABS(cur[x-refs-1] - cur[x+refs-1]) */\
"punpcklbw "MM"7, "MM"3 \n\t" /* ABS(cur[x-refs+1] - cur[x+refs+1]) */\
"paddw "MM"2, "MM"0 \n\t"\
"paddw "MM"3, "MM"0 \n\t"\
"psubw "MANGLE(pw_1)", "MM"0 \n\t" /* spatial_score */\
\
CHECK(-2,0)\
CHECK1\
CHECK(-3,1)\
CHECK2\
CHECK(0,-2)\
CHECK1\
CHECK(1,-3)\
CHECK2\
\
/* if(p->mode<2) ... */\
MOVQ" %[tmp3], "MM"6 \n\t" /* diff */\
"cmpl $2, %[mode] \n\t"\
"jge 1f \n\t"\
LOAD("(%["prev2"],%[mrefs],2)", MM"2") /* prev2[x-2*refs] */\
LOAD("(%["next2"],%[mrefs],2)", MM"4") /* next2[x-2*refs] */\
LOAD("(%["prev2"],%[prefs],2)", MM"3") /* prev2[x+2*refs] */\
LOAD("(%["next2"],%[prefs],2)", MM"5") /* next2[x+2*refs] */\
"paddw "MM"4, "MM"2 \n\t"\
"paddw "MM"5, "MM"3 \n\t"\
"psrlw $1, "MM"2 \n\t" /* b */\
"psrlw $1, "MM"3 \n\t" /* f */\
MOVQ" %[tmp0], "MM"4 \n\t" /* c */\
MOVQ" %[tmp1], "MM"5 \n\t" /* d */\
MOVQ" %[tmp2], "MM"7 \n\t" /* e */\
"psubw "MM"4, "MM"2 \n\t" /* b-c */\
"psubw "MM"7, "MM"3 \n\t" /* f-e */\
MOVQ" "MM"5, "MM"0 \n\t"\
"psubw "MM"4, "MM"5 \n\t" /* d-c */\
"psubw "MM"7, "MM"0 \n\t" /* d-e */\
MOVQ" "MM"2, "MM"4 \n\t"\
"pminsw "MM"3, "MM"2 \n\t"\
"pmaxsw "MM"4, "MM"3 \n\t"\
"pmaxsw "MM"5, "MM"2 \n\t"\
"pminsw "MM"5, "MM"3 \n\t"\
"pmaxsw "MM"0, "MM"2 \n\t" /* max */\
"pminsw "MM"0, "MM"3 \n\t" /* min */\
"pxor "MM"4, "MM"4 \n\t"\
"pmaxsw "MM"3, "MM"6 \n\t"\
"psubw "MM"2, "MM"4 \n\t" /* -max */\
"pmaxsw "MM"4, "MM"6 \n\t" /* diff= MAX3(diff, min, -max); */\
"1: \n\t"\
\
MOVQ" %[tmp1], "MM"2 \n\t" /* d */\
MOVQ" "MM"2, "MM"3 \n\t"\
"psubw "MM"6, "MM"2 \n\t" /* d-diff */\
"paddw "MM"6, "MM"3 \n\t" /* d+diff */\
"pmaxsw "MM"2, "MM"1 \n\t"\
"pminsw "MM"3, "MM"1 \n\t" /* d = clip(spatial_pred, d-diff, d+diff); */\
"packuswb "MM"1, "MM"1 \n\t"\
\
:[tmp0]"=m"(tmp0),\
[tmp1]"=m"(tmp1),\
[tmp2]"=m"(tmp2),\
[tmp3]"=m"(tmp3)\
:[prev] "r"(prev),\
[cur] "r"(cur),\
[next] "r"(next),\
[prefs]"r"((x86_reg)prefs),\
[mrefs]"r"((x86_reg)mrefs),\
[mode] "g"(mode)\
);\
__asm__ volatile(MOV" "MM"1, %0" :"=m"(*dst));\
dst += STEP;\
prev+= STEP;\
cur += STEP;\
next+= STEP;\
}
if (parity) {
#define prev2 "prev"
#define next2 "cur"
FILTER
#undef prev2
#undef next2
} else {
#define prev2 "cur"
#define next2 "next"
FILTER
#undef prev2
#undef next2
}
}
| false | FFmpeg | 480178a29587df8ed6d5e93bfe79e4a08a61f9e1 | static void RENAME(yadif_filter_line)(uint8_t *dst, uint8_t *prev, uint8_t *cur,
uint8_t *next, int w, int prefs,
int mrefs, int parity, int mode)
{
DECLARE_ALIGNED(16, uint8_t, tmp0)[16];
DECLARE_ALIGNED(16, uint8_t, tmp1)[16];
DECLARE_ALIGNED(16, uint8_t, tmp2)[16];
DECLARE_ALIGNED(16, uint8_t, tmp3)[16];
int x;
#define FILTER\
for(x=0; x<w; x+=STEP){\
__asm__ volatile(\
"pxor "MM"7, "MM"7 \n\t"\
LOAD("(%[cur],%[mrefs])", MM"0") \
LOAD("(%[cur],%[prefs])", MM"1") \
LOAD("(%["prev2"])", MM"2") \
LOAD("(%["next2"])", MM"3") \
MOVQ" "MM"3, "MM"4 \n\t"\
"paddw "MM"2, "MM"3 \n\t"\
"psraw $1, "MM"3 \n\t" \
MOVQ" "MM"0, %[tmp0] \n\t" \
MOVQ" "MM"3, %[tmp1] \n\t" \
MOVQ" "MM"1, %[tmp2] \n\t" \
"psubw "MM"4, "MM"2 \n\t"\
PABS( MM"4", MM"2") \
LOAD("(%[prev],%[mrefs])", MM"3") \
LOAD("(%[prev],%[prefs])", MM"4") \
"psubw "MM"0, "MM"3 \n\t"\
"psubw "MM"1, "MM"4 \n\t"\
PABS( MM"5", MM"3")\
PABS( MM"5", MM"4")\
"paddw "MM"4, "MM"3 \n\t" \
"psrlw $1, "MM"2 \n\t"\
"psrlw $1, "MM"3 \n\t"\
"pmaxsw "MM"3, "MM"2 \n\t"\
LOAD("(%[next],%[mrefs])", MM"3") \
LOAD("(%[next],%[prefs])", MM"4") \
"psubw "MM"0, "MM"3 \n\t"\
"psubw "MM"1, "MM"4 \n\t"\
PABS( MM"5", MM"3")\
PABS( MM"5", MM"4")\
"paddw "MM"4, "MM"3 \n\t" \
"psrlw $1, "MM"3 \n\t"\
"pmaxsw "MM"3, "MM"2 \n\t"\
MOVQ" "MM"2, %[tmp3] \n\t" \
\
"paddw "MM"0, "MM"1 \n\t"\
"paddw "MM"0, "MM"0 \n\t"\
"psubw "MM"1, "MM"0 \n\t"\
"psrlw $1, "MM"1 \n\t" \
PABS( MM"2", MM"0") \
\
MOVQU" -1(%[cur],%[mrefs]), "MM"2 \n\t" \
MOVQU" -1(%[cur],%[prefs]), "MM"3 \n\t" \
MOVQ" "MM"2, "MM"4 \n\t"\
"psubusb "MM"3, "MM"2 \n\t"\
"psubusb "MM"4, "MM"3 \n\t"\
"pmaxub "MM"3, "MM"2 \n\t"\
PSHUF(MM"3", MM"2") \
"punpcklbw "MM"7, "MM"2 \n\t" \
"punpcklbw "MM"7, "MM"3 \n\t" \
"paddw "MM"2, "MM"0 \n\t"\
"paddw "MM"3, "MM"0 \n\t"\
"psubw "MANGLE(pw_1)", "MM"0 \n\t" \
\
CHECK(-2,0)\
CHECK1\
CHECK(-3,1)\
CHECK2\
CHECK(0,-2)\
CHECK1\
CHECK(1,-3)\
CHECK2\
\
\
MOVQ" %[tmp3], "MM"6 \n\t" \
"cmpl $2, %[mode] \n\t"\
"jge 1f \n\t"\
LOAD("(%["prev2"],%[mrefs],2)", MM"2") \
LOAD("(%["next2"],%[mrefs],2)", MM"4") \
LOAD("(%["prev2"],%[prefs],2)", MM"3") \
LOAD("(%["next2"],%[prefs],2)", MM"5") \
"paddw "MM"4, "MM"2 \n\t"\
"paddw "MM"5, "MM"3 \n\t"\
"psrlw $1, "MM"2 \n\t" \
"psrlw $1, "MM"3 \n\t" \
MOVQ" %[tmp0], "MM"4 \n\t" \
MOVQ" %[tmp1], "MM"5 \n\t" \
MOVQ" %[tmp2], "MM"7 \n\t" \
"psubw "MM"4, "MM"2 \n\t" \
"psubw "MM"7, "MM"3 \n\t" \
MOVQ" "MM"5, "MM"0 \n\t"\
"psubw "MM"4, "MM"5 \n\t" \
"psubw "MM"7, "MM"0 \n\t" \
MOVQ" "MM"2, "MM"4 \n\t"\
"pminsw "MM"3, "MM"2 \n\t"\
"pmaxsw "MM"4, "MM"3 \n\t"\
"pmaxsw "MM"5, "MM"2 \n\t"\
"pminsw "MM"5, "MM"3 \n\t"\
"pmaxsw "MM"0, "MM"2 \n\t" \
"pminsw "MM"0, "MM"3 \n\t" \
"pxor "MM"4, "MM"4 \n\t"\
"pmaxsw "MM"3, "MM"6 \n\t"\
"psubw "MM"2, "MM"4 \n\t" \
"pmaxsw "MM"4, "MM"6 \n\t" \
"1: \n\t"\
\
MOVQ" %[tmp1], "MM"2 \n\t" \
MOVQ" "MM"2, "MM"3 \n\t"\
"psubw "MM"6, "MM"2 \n\t" \
"paddw "MM"6, "MM"3 \n\t" \
"pmaxsw "MM"2, "MM"1 \n\t"\
"pminsw "MM"3, "MM"1 \n\t" \
"packuswb "MM"1, "MM"1 \n\t"\
\
:[tmp0]"=m"(tmp0),\
[tmp1]"=m"(tmp1),\
[tmp2]"=m"(tmp2),\
[tmp3]"=m"(tmp3)\
:[prev] "r"(prev),\
[cur] "r"(cur),\
[next] "r"(next),\
[prefs]"r"((x86_reg)prefs),\
[mrefs]"r"((x86_reg)mrefs),\
[mode] "g"(mode)\
);\
__asm__ volatile(MOV" "MM"1, %0" :"=m"(*dst));\
dst += STEP;\
prev+= STEP;\
cur += STEP;\
next+= STEP;\
}
if (parity) {
#define prev2 "prev"
#define next2 "cur"
FILTER
#undef prev2
#undef next2
} else {
#define prev2 "cur"
#define next2 "next"
FILTER
#undef prev2
#undef next2
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(yadif_filter_line)(uint8_t *dst, uint8_t *prev, uint8_t *cur,
uint8_t *next, int w, int prefs,
int mrefs, int parity, int mode)
{
DECLARE_ALIGNED(16, uint8_t, tmp0)[16];
DECLARE_ALIGNED(16, uint8_t, tmp1)[16];
DECLARE_ALIGNED(16, uint8_t, tmp2)[16];
DECLARE_ALIGNED(16, uint8_t, tmp3)[16];
int VAR_0;
#define FILTER\
for(VAR_0=0; VAR_0<w; VAR_0+=STEP){\
__asm__ volatile(\
"pxor "MM"7, "MM"7 \n\t"\
LOAD("(%[cur],%[mrefs])", MM"0") \
LOAD("(%[cur],%[prefs])", MM"1") \
LOAD("(%["prev2"])", MM"2") \
LOAD("(%["next2"])", MM"3") \
MOVQ" "MM"3, "MM"4 \n\t"\
"paddw "MM"2, "MM"3 \n\t"\
"psraw $1, "MM"3 \n\t" \
MOVQ" "MM"0, %[tmp0] \n\t" \
MOVQ" "MM"3, %[tmp1] \n\t" \
MOVQ" "MM"1, %[tmp2] \n\t" \
"psubw "MM"4, "MM"2 \n\t"\
PABS( MM"4", MM"2") \
LOAD("(%[prev],%[mrefs])", MM"3") \
LOAD("(%[prev],%[prefs])", MM"4") \
"psubw "MM"0, "MM"3 \n\t"\
"psubw "MM"1, "MM"4 \n\t"\
PABS( MM"5", MM"3")\
PABS( MM"5", MM"4")\
"paddw "MM"4, "MM"3 \n\t" \
"psrlw $1, "MM"2 \n\t"\
"psrlw $1, "MM"3 \n\t"\
"pmaxsw "MM"3, "MM"2 \n\t"\
LOAD("(%[next],%[mrefs])", MM"3") \
LOAD("(%[next],%[prefs])", MM"4") \
"psubw "MM"0, "MM"3 \n\t"\
"psubw "MM"1, "MM"4 \n\t"\
PABS( MM"5", MM"3")\
PABS( MM"5", MM"4")\
"paddw "MM"4, "MM"3 \n\t" \
"psrlw $1, "MM"3 \n\t"\
"pmaxsw "MM"3, "MM"2 \n\t"\
MOVQ" "MM"2, %[tmp3] \n\t" \
\
"paddw "MM"0, "MM"1 \n\t"\
"paddw "MM"0, "MM"0 \n\t"\
"psubw "MM"1, "MM"0 \n\t"\
"psrlw $1, "MM"1 \n\t" \
PABS( MM"2", MM"0") \
\
MOVQU" -1(%[cur],%[mrefs]), "MM"2 \n\t" \
MOVQU" -1(%[cur],%[prefs]), "MM"3 \n\t" \
MOVQ" "MM"2, "MM"4 \n\t"\
"psubusb "MM"3, "MM"2 \n\t"\
"psubusb "MM"4, "MM"3 \n\t"\
"pmaxub "MM"3, "MM"2 \n\t"\
PSHUF(MM"3", MM"2") \
"punpcklbw "MM"7, "MM"2 \n\t" \
"punpcklbw "MM"7, "MM"3 \n\t" \
"paddw "MM"2, "MM"0 \n\t"\
"paddw "MM"3, "MM"0 \n\t"\
"psubw "MANGLE(pw_1)", "MM"0 \n\t" \
\
CHECK(-2,0)\
CHECK1\
CHECK(-3,1)\
CHECK2\
CHECK(0,-2)\
CHECK1\
CHECK(1,-3)\
CHECK2\
\
\
MOVQ" %[tmp3], "MM"6 \n\t" \
"cmpl $2, %[mode] \n\t"\
"jge 1f \n\t"\
LOAD("(%["prev2"],%[mrefs],2)", MM"2") \
LOAD("(%["next2"],%[mrefs],2)", MM"4") \
LOAD("(%["prev2"],%[prefs],2)", MM"3") \
LOAD("(%["next2"],%[prefs],2)", MM"5") \
"paddw "MM"4, "MM"2 \n\t"\
"paddw "MM"5, "MM"3 \n\t"\
"psrlw $1, "MM"2 \n\t" \
"psrlw $1, "MM"3 \n\t" \
MOVQ" %[tmp0], "MM"4 \n\t" \
MOVQ" %[tmp1], "MM"5 \n\t" \
MOVQ" %[tmp2], "MM"7 \n\t" \
"psubw "MM"4, "MM"2 \n\t" \
"psubw "MM"7, "MM"3 \n\t" \
MOVQ" "MM"5, "MM"0 \n\t"\
"psubw "MM"4, "MM"5 \n\t" \
"psubw "MM"7, "MM"0 \n\t" \
MOVQ" "MM"2, "MM"4 \n\t"\
"pminsw "MM"3, "MM"2 \n\t"\
"pmaxsw "MM"4, "MM"3 \n\t"\
"pmaxsw "MM"5, "MM"2 \n\t"\
"pminsw "MM"5, "MM"3 \n\t"\
"pmaxsw "MM"0, "MM"2 \n\t" \
"pminsw "MM"0, "MM"3 \n\t" \
"pxor "MM"4, "MM"4 \n\t"\
"pmaxsw "MM"3, "MM"6 \n\t"\
"psubw "MM"2, "MM"4 \n\t" \
"pmaxsw "MM"4, "MM"6 \n\t" \
"1: \n\t"\
\
MOVQ" %[tmp1], "MM"2 \n\t" \
MOVQ" "MM"2, "MM"3 \n\t"\
"psubw "MM"6, "MM"2 \n\t" \
"paddw "MM"6, "MM"3 \n\t" \
"pmaxsw "MM"2, "MM"1 \n\t"\
"pminsw "MM"3, "MM"1 \n\t" \
"packuswb "MM"1, "MM"1 \n\t"\
\
:[tmp0]"=m"(tmp0),\
[tmp1]"=m"(tmp1),\
[tmp2]"=m"(tmp2),\
[tmp3]"=m"(tmp3)\
:[prev] "r"(prev),\
[cur] "r"(cur),\
[next] "r"(next),\
[prefs]"r"((x86_reg)prefs),\
[mrefs]"r"((x86_reg)mrefs),\
[mode] "g"(mode)\
);\
__asm__ volatile(MOV" "MM"1, %0" :"=m"(*dst));\
dst += STEP;\
prev+= STEP;\
cur += STEP;\
next+= STEP;\
}
if (parity) {
#define prev2 "prev"
#define next2 "cur"
FILTER
#undef prev2
#undef next2
} else {
#define prev2 "cur"
#define next2 "next"
FILTER
#undef prev2
#undef next2
}
}
| [
"static void FUNC_0(yadif_filter_line)(uint8_t *dst, uint8_t *prev, uint8_t *cur,\nuint8_t *next, int w, int prefs,\nint mrefs, int parity, int mode)\n{",
"DECLARE_ALIGNED(16, uint8_t, tmp0)[16];",
"DECLARE_ALIGNED(16, uint8_t, tmp1)[16];",
"DECLARE_ALIGNED(16, uint8_t, tmp2)[16];",
"DECLARE_ALIGNED(16, uint8_t, tmp3)[16];",
"int VAR_0;",
"#define FILTER\\\nfor(VAR_0=0; VAR_0<w; VAR_0+=STEP){\\",
"__asm__ volatile(\\\n\"pxor \"MM\"7, \"MM\"7 \\n\\t\"\\\nLOAD(\"(%[cur],%[mrefs])\", MM\"0\") \\\nLOAD(\"(%[cur],%[prefs])\", MM\"1\") \\\nLOAD(\"(%[\"prev2\"])\", MM\"2\") \\\nLOAD(\"(%[\"next2\"])\", MM\"3\") \\\nMOVQ\" \"MM\"3, \"MM\"4 \\n\\t\"\\\n\"paddw \"MM\"2, \"MM\"3 \\n\\t\"\\\n\"psraw $1, \"MM\"3 \\n\\t\" \\\nMOVQ\" \"MM\"0, %[tmp0] \\n\\t\" \\\nMOVQ\" \"MM\"3, %[tmp1] \\n\\t\" \\\nMOVQ\" \"MM\"1, %[tmp2] \\n\\t\" \\\n\"psubw \"MM\"4, \"MM\"2 \\n\\t\"\\\nPABS( MM\"4\", MM\"2\") \\\nLOAD(\"(%[prev],%[mrefs])\", MM\"3\") \\\nLOAD(\"(%[prev],%[prefs])\", MM\"4\") \\\n\"psubw \"MM\"0, \"MM\"3 \\n\\t\"\\\n\"psubw \"MM\"1, \"MM\"4 \\n\\t\"\\\nPABS( MM\"5\", MM\"3\")\\\nPABS( MM\"5\", MM\"4\")\\\n\"paddw \"MM\"4, \"MM\"3 \\n\\t\" \\\n\"psrlw $1, \"MM\"2 \\n\\t\"\\\n\"psrlw $1, \"MM\"3 \\n\\t\"\\\n\"pmaxsw \"MM\"3, \"MM\"2 \\n\\t\"\\\nLOAD(\"(%[next],%[mrefs])\", MM\"3\") \\\nLOAD(\"(%[next],%[prefs])\", MM\"4\") \\\n\"psubw \"MM\"0, \"MM\"3 \\n\\t\"\\\n\"psubw \"MM\"1, \"MM\"4 \\n\\t\"\\\nPABS( MM\"5\", MM\"3\")\\\nPABS( MM\"5\", MM\"4\")\\\n\"paddw \"MM\"4, \"MM\"3 \\n\\t\" \\\n\"psrlw $1, \"MM\"3 \\n\\t\"\\\n\"pmaxsw \"MM\"3, \"MM\"2 \\n\\t\"\\\nMOVQ\" \"MM\"2, %[tmp3] \\n\\t\" \\\n\\\n\"paddw \"MM\"0, \"MM\"1 \\n\\t\"\\\n\"paddw \"MM\"0, \"MM\"0 \\n\\t\"\\\n\"psubw \"MM\"1, \"MM\"0 \\n\\t\"\\\n\"psrlw $1, \"MM\"1 \\n\\t\" \\\nPABS( MM\"2\", MM\"0\") \\\n\\\nMOVQU\" -1(%[cur],%[mrefs]), \"MM\"2 \\n\\t\" \\\nMOVQU\" -1(%[cur],%[prefs]), \"MM\"3 \\n\\t\" \\\nMOVQ\" \"MM\"2, \"MM\"4 \\n\\t\"\\\n\"psubusb \"MM\"3, \"MM\"2 \\n\\t\"\\\n\"psubusb \"MM\"4, \"MM\"3 \\n\\t\"\\\n\"pmaxub \"MM\"3, \"MM\"2 \\n\\t\"\\\nPSHUF(MM\"3\", MM\"2\") \\\n\"punpcklbw \"MM\"7, \"MM\"2 \\n\\t\" \\\n\"punpcklbw \"MM\"7, \"MM\"3 \\n\\t\" \\\n\"paddw \"MM\"2, \"MM\"0 \\n\\t\"\\\n\"paddw \"MM\"3, \"MM\"0 \\n\\t\"\\\n\"psubw \"MANGLE(pw_1)\", \"MM\"0 \\n\\t\" \\\n\\\nCHECK(-2,0)\\\nCHECK1\\\nCHECK(-3,1)\\\nCHECK2\\\nCHECK(0,-2)\\\nCHECK1\\\nCHECK(1,-3)\\\nCHECK2\\\n\\\n\\\nMOVQ\" %[tmp3], \"MM\"6 \\n\\t\" \\\n\"cmpl $2, %[mode] \\n\\t\"\\\n\"jge 1f \\n\\t\"\\\nLOAD(\"(%[\"prev2\"],%[mrefs],2)\", MM\"2\") \\\nLOAD(\"(%[\"next2\"],%[mrefs],2)\", MM\"4\") \\\nLOAD(\"(%[\"prev2\"],%[prefs],2)\", MM\"3\") \\\nLOAD(\"(%[\"next2\"],%[prefs],2)\", MM\"5\") \\\n\"paddw \"MM\"4, \"MM\"2 \\n\\t\"\\\n\"paddw \"MM\"5, \"MM\"3 \\n\\t\"\\\n\"psrlw $1, \"MM\"2 \\n\\t\" \\\n\"psrlw $1, \"MM\"3 \\n\\t\" \\\nMOVQ\" %[tmp0], \"MM\"4 \\n\\t\" \\\nMOVQ\" %[tmp1], \"MM\"5 \\n\\t\" \\\nMOVQ\" %[tmp2], \"MM\"7 \\n\\t\" \\\n\"psubw \"MM\"4, \"MM\"2 \\n\\t\" \\\n\"psubw \"MM\"7, \"MM\"3 \\n\\t\" \\\nMOVQ\" \"MM\"5, \"MM\"0 \\n\\t\"\\\n\"psubw \"MM\"4, \"MM\"5 \\n\\t\" \\\n\"psubw \"MM\"7, \"MM\"0 \\n\\t\" \\\nMOVQ\" \"MM\"2, \"MM\"4 \\n\\t\"\\\n\"pminsw \"MM\"3, \"MM\"2 \\n\\t\"\\\n\"pmaxsw \"MM\"4, \"MM\"3 \\n\\t\"\\\n\"pmaxsw \"MM\"5, \"MM\"2 \\n\\t\"\\\n\"pminsw \"MM\"5, \"MM\"3 \\n\\t\"\\\n\"pmaxsw \"MM\"0, \"MM\"2 \\n\\t\" \\\n\"pminsw \"MM\"0, \"MM\"3 \\n\\t\" \\\n\"pxor \"MM\"4, \"MM\"4 \\n\\t\"\\\n\"pmaxsw \"MM\"3, \"MM\"6 \\n\\t\"\\\n\"psubw \"MM\"2, \"MM\"4 \\n\\t\" \\\n\"pmaxsw \"MM\"4, \"MM\"6 \\n\\t\" \\\n\"1: \\n\\t\"\\\n\\\nMOVQ\" %[tmp1], \"MM\"2 \\n\\t\" \\\nMOVQ\" \"MM\"2, \"MM\"3 \\n\\t\"\\\n\"psubw \"MM\"6, \"MM\"2 \\n\\t\" \\\n\"paddw \"MM\"6, \"MM\"3 \\n\\t\" \\\n\"pmaxsw \"MM\"2, \"MM\"1 \\n\\t\"\\\n\"pminsw \"MM\"3, \"MM\"1 \\n\\t\" \\\n\"packuswb \"MM\"1, \"MM\"1 \\n\\t\"\\\n\\\n:[tmp0]\"=m\"(tmp0),\\\n[tmp1]\"=m\"(tmp1),\\\n[tmp2]\"=m\"(tmp2),\\\n[tmp3]\"=m\"(tmp3)\\\n:[prev] \"r\"(prev),\\\n[cur] \"r\"(cur),\\\n[next] \"r\"(next),\\\n[prefs]\"r\"((x86_reg)prefs),\\\n[mrefs]\"r\"((x86_reg)mrefs),\\\n[mode] \"g\"(mode)\\\n);\\",
"__asm__ volatile(MOV\" \"MM\"1, %0\" :\"=m\"(*dst));\\",
"dst += STEP;\\",
"prev+= STEP;\\",
"cur += STEP;\\",
"next+= STEP;\\",
"}",
"if (parity) {",
"#define prev2 \"prev\"\n#define next2 \"cur\"\nFILTER\n#undef prev2\n#undef next2\n} else {",
"#define prev2 \"cur\"\n#define next2 \"next\"\nFILTER\n#undef prev2\n#undef next2\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
],
[
21,
23
],
[
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
93,
95,
97,
99,
101,
103,
105,
107,
109,
111,
113,
115,
117,
119,
121,
123,
125,
127,
129,
131,
133,
135,
137,
139,
141,
143,
145,
147,
149,
151,
153,
155,
157,
159,
161,
163,
165,
167,
169,
171,
173,
175,
177,
179,
181,
183,
185,
187,
189,
191,
193,
195,
197,
199,
201,
203,
205,
207,
209,
211,
213,
215,
217,
219,
221,
223,
225,
227,
229,
231,
233,
235,
237,
239,
241,
243,
245,
247,
249,
251,
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
269
],
[
271,
273,
275,
277,
279,
281
],
[
283,
285,
287,
289,
291,
293
],
[
295
]
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.