id
int32
0
27.3k
func
stringlengths
26
142k
target
bool
2 classes
project
stringclasses
2 values
commit_id
stringlengths
40
40
func_clean
stringlengths
26
131k
vul_lines
dict
normalized_func
stringlengths
24
132k
lines
listlengths
1
2.8k
label
listlengths
1
2.8k
line_no
listlengths
1
2.8k
12,475
yuv2mono_2_c_template(SwsContext *c, const uint16_t *buf0, const uint16_t *buf1, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, const uint16_t *abuf1, uint8_t *dest, int dstW, int yalpha, int uvalpha, int y, enum PixelFormat target) { const uint8_t * const d128 = dither_8x8_220[y & 7]; uint8_t *g = c->table_gU[128] + c->table_gV[128]; int yalpha1 = 4095 - yalpha; int i; for (i = 0; i < dstW - 7; i += 8) { int acc = g[((buf0[i ] * yalpha1 + buf1[i ] * yalpha) >> 19) + d128[0]]; acc += acc + g[((buf0[i + 1] * yalpha1 + buf1[i + 1] * yalpha) >> 19) + d128[1]]; acc += acc + g[((buf0[i + 2] * yalpha1 + buf1[i + 2] * yalpha) >> 19) + d128[2]]; acc += acc + g[((buf0[i + 3] * yalpha1 + buf1[i + 3] * yalpha) >> 19) + d128[3]]; acc += acc + g[((buf0[i + 4] * yalpha1 + buf1[i + 4] * yalpha) >> 19) + d128[4]]; acc += acc + g[((buf0[i + 5] * yalpha1 + buf1[i + 5] * yalpha) >> 19) + d128[5]]; acc += acc + g[((buf0[i + 6] * yalpha1 + buf1[i + 6] * yalpha) >> 19) + d128[6]]; acc += acc + g[((buf0[i + 7] * yalpha1 + buf1[i + 7] * yalpha) >> 19) + d128[7]]; output_pixel(*dest++, acc); } }
false
FFmpeg
13a099799e89a76eb921ca452e1b04a7a28a9855
yuv2mono_2_c_template(SwsContext *c, const uint16_t *buf0, const uint16_t *buf1, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, const uint16_t *abuf1, uint8_t *dest, int dstW, int yalpha, int uvalpha, int y, enum PixelFormat target) { const uint8_t * const d128 = dither_8x8_220[y & 7]; uint8_t *g = c->table_gU[128] + c->table_gV[128]; int yalpha1 = 4095 - yalpha; int i; for (i = 0; i < dstW - 7; i += 8) { int acc = g[((buf0[i ] * yalpha1 + buf1[i ] * yalpha) >> 19) + d128[0]]; acc += acc + g[((buf0[i + 1] * yalpha1 + buf1[i + 1] * yalpha) >> 19) + d128[1]]; acc += acc + g[((buf0[i + 2] * yalpha1 + buf1[i + 2] * yalpha) >> 19) + d128[2]]; acc += acc + g[((buf0[i + 3] * yalpha1 + buf1[i + 3] * yalpha) >> 19) + d128[3]]; acc += acc + g[((buf0[i + 4] * yalpha1 + buf1[i + 4] * yalpha) >> 19) + d128[4]]; acc += acc + g[((buf0[i + 5] * yalpha1 + buf1[i + 5] * yalpha) >> 19) + d128[5]]; acc += acc + g[((buf0[i + 6] * yalpha1 + buf1[i + 6] * yalpha) >> 19) + d128[6]]; acc += acc + g[((buf0[i + 7] * yalpha1 + buf1[i + 7] * yalpha) >> 19) + d128[7]]; output_pixel(*dest++, acc); } }
{ "code": [], "line_no": [] }
FUNC_0(SwsContext *VAR_0, const uint16_t *VAR_1, const uint16_t *VAR_2, const uint16_t *VAR_3, const uint16_t *VAR_4, const uint16_t *VAR_5, const uint16_t *VAR_6, const uint16_t *VAR_7, const uint16_t *VAR_8, uint8_t *VAR_9, int VAR_10, int VAR_11, int VAR_12, int VAR_13, enum PixelFormat VAR_14) { const uint8_t * const VAR_15 = dither_8x8_220[VAR_13 & 7]; uint8_t *g = VAR_0->table_gU[128] + VAR_0->table_gV[128]; int VAR_16 = 4095 - VAR_11; int VAR_17; for (VAR_17 = 0; VAR_17 < VAR_10 - 7; VAR_17 += 8) { int VAR_18 = g[((VAR_1[VAR_17 ] * VAR_16 + VAR_2[VAR_17 ] * VAR_11) >> 19) + VAR_15[0]]; VAR_18 += VAR_18 + g[((VAR_1[VAR_17 + 1] * VAR_16 + VAR_2[VAR_17 + 1] * VAR_11) >> 19) + VAR_15[1]]; VAR_18 += VAR_18 + g[((VAR_1[VAR_17 + 2] * VAR_16 + VAR_2[VAR_17 + 2] * VAR_11) >> 19) + VAR_15[2]]; VAR_18 += VAR_18 + g[((VAR_1[VAR_17 + 3] * VAR_16 + VAR_2[VAR_17 + 3] * VAR_11) >> 19) + VAR_15[3]]; VAR_18 += VAR_18 + g[((VAR_1[VAR_17 + 4] * VAR_16 + VAR_2[VAR_17 + 4] * VAR_11) >> 19) + VAR_15[4]]; VAR_18 += VAR_18 + g[((VAR_1[VAR_17 + 5] * VAR_16 + VAR_2[VAR_17 + 5] * VAR_11) >> 19) + VAR_15[5]]; VAR_18 += VAR_18 + g[((VAR_1[VAR_17 + 6] * VAR_16 + VAR_2[VAR_17 + 6] * VAR_11) >> 19) + VAR_15[6]]; VAR_18 += VAR_18 + g[((VAR_1[VAR_17 + 7] * VAR_16 + VAR_2[VAR_17 + 7] * VAR_11) >> 19) + VAR_15[7]]; output_pixel(*VAR_9++, VAR_18); } }
[ "FUNC_0(SwsContext *VAR_0, const uint16_t *VAR_1,\nconst uint16_t *VAR_2, const uint16_t *VAR_3,\nconst uint16_t *VAR_4, const uint16_t *VAR_5,\nconst uint16_t *VAR_6, const uint16_t *VAR_7,\nconst uint16_t *VAR_8, uint8_t *VAR_9, int VAR_10,\nint VAR_11, int VAR_12, int VAR_13,\nenum PixelFormat VAR_14)\n{", "const uint8_t * const VAR_15 = dither_8x8_220[VAR_13 & 7];", "uint8_t *g = VAR_0->table_gU[128] + VAR_0->table_gV[128];", "int VAR_16 = 4095 - VAR_11;", "int VAR_17;", "for (VAR_17 = 0; VAR_17 < VAR_10 - 7; VAR_17 += 8) {", "int VAR_18 = g[((VAR_1[VAR_17 ] * VAR_16 + VAR_2[VAR_17 ] * VAR_11) >> 19) + VAR_15[0]];", "VAR_18 += VAR_18 + g[((VAR_1[VAR_17 + 1] * VAR_16 + VAR_2[VAR_17 + 1] * VAR_11) >> 19) + VAR_15[1]];", "VAR_18 += VAR_18 + g[((VAR_1[VAR_17 + 2] * VAR_16 + VAR_2[VAR_17 + 2] * VAR_11) >> 19) + VAR_15[2]];", "VAR_18 += VAR_18 + g[((VAR_1[VAR_17 + 3] * VAR_16 + VAR_2[VAR_17 + 3] * VAR_11) >> 19) + VAR_15[3]];", "VAR_18 += VAR_18 + g[((VAR_1[VAR_17 + 4] * VAR_16 + VAR_2[VAR_17 + 4] * VAR_11) >> 19) + VAR_15[4]];", "VAR_18 += VAR_18 + g[((VAR_1[VAR_17 + 5] * VAR_16 + VAR_2[VAR_17 + 5] * VAR_11) >> 19) + VAR_15[5]];", "VAR_18 += VAR_18 + g[((VAR_1[VAR_17 + 6] * VAR_16 + VAR_2[VAR_17 + 6] * VAR_11) >> 19) + VAR_15[6]];", "VAR_18 += VAR_18 + g[((VAR_1[VAR_17 + 7] * VAR_16 + VAR_2[VAR_17 + 7] * VAR_11) >> 19) + VAR_15[7]];", "output_pixel(*VAR_9++, VAR_18);", "}", "}" ]
[ 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 ] ]
12,476
static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu, Error **errp) { CPUClass *k = CPU_GET_CLASS(cpu); int64_t cpu_id; cpu_id = k->get_arch_id(cpu); if ((cpu_id / 8) >= ACPI_GPE_PROC_LEN) { error_setg(errp, "acpi: invalid cpu id: %" PRIi64, cpu_id); return; } g->sts[cpu_id / 8] |= (1 << (cpu_id % 8)); }
false
qemu
f9dc175d84802e9a00161bc8d4356b90d6c52125
static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu, Error **errp) { CPUClass *k = CPU_GET_CLASS(cpu); int64_t cpu_id; cpu_id = k->get_arch_id(cpu); if ((cpu_id / 8) >= ACPI_GPE_PROC_LEN) { error_setg(errp, "acpi: invalid cpu id: %" PRIi64, cpu_id); return; } g->sts[cpu_id / 8] |= (1 << (cpu_id % 8)); }
{ "code": [], "line_no": [] }
static void FUNC_0(AcpiCpuHotplug *VAR_0, CPUState *VAR_1, Error **VAR_2) { CPUClass *k = CPU_GET_CLASS(VAR_1); int64_t cpu_id; cpu_id = k->get_arch_id(VAR_1); if ((cpu_id / 8) >= ACPI_GPE_PROC_LEN) { error_setg(VAR_2, "acpi: invalid VAR_1 id: %" PRIi64, cpu_id); return; } VAR_0->sts[cpu_id / 8] |= (1 << (cpu_id % 8)); }
[ "static void FUNC_0(AcpiCpuHotplug *VAR_0, CPUState *VAR_1,\nError **VAR_2)\n{", "CPUClass *k = CPU_GET_CLASS(VAR_1);", "int64_t cpu_id;", "cpu_id = k->get_arch_id(VAR_1);", "if ((cpu_id / 8) >= ACPI_GPE_PROC_LEN) {", "error_setg(VAR_2, \"acpi: invalid VAR_1 id: %\" PRIi64, cpu_id);", "return;", "}", "VAR_0->sts[cpu_id / 8] |= (1 << (cpu_id % 8));", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ] ]
12,478
uint32_t HELPER(get_cp15)(CPUARMState *env, uint32_t insn) { int op1; int op2; int crm; op1 = (insn >> 21) & 7; op2 = (insn >> 5) & 7; crm = insn & 0xf; switch ((insn >> 16) & 0xf) { case 0: /* ID codes. */ switch (op1) { case 0: switch (crm) { case 0: switch (op2) { case 0: /* Device ID. */ return env->cp15.c0_cpuid; case 1: /* Cache Type. */ return env->cp15.c0_cachetype; case 2: /* TCM status. */ return 0; case 3: /* TLB type register. */ return 0; /* No lockable TLB entries. */ case 5: /* MPIDR */ /* The MPIDR was standardised in v7; prior to * this it was implemented only in the 11MPCore. * For all other pre-v7 cores it does not exist. */ if (arm_feature(env, ARM_FEATURE_V7) || ARM_CPUID(env) == ARM_CPUID_ARM11MPCORE) { int mpidr = env->cpu_index; /* We don't support setting cluster ID ([8..11]) * so these bits always RAZ. */ if (arm_feature(env, ARM_FEATURE_V7MP)) { mpidr |= (1 << 31); /* Cores which are uniprocessor (non-coherent) * but still implement the MP extensions set * bit 30. (For instance, A9UP.) However we do * not currently model any of those cores. */ } return mpidr; } /* otherwise fall through to the unimplemented-reg case */ default: goto bad_reg; } case 3: case 4: case 5: case 6: case 7: return 0; default: goto bad_reg; } default: goto bad_reg; } case 4: /* Reserved. */ goto bad_reg; case 11: /* TCM DMA control. */ case 12: /* Reserved. */ goto bad_reg; } bad_reg: /* ??? For debugging only. Should raise illegal instruction exception. */ cpu_abort(env, "Unimplemented cp15 register read (c%d, c%d, {%d, %d})\n", (insn >> 16) & 0xf, crm, op1, op2); return 0; }
false
qemu
81bdde9dcdba5bbc358b2c6b8f776a05a751cc72
uint32_t HELPER(get_cp15)(CPUARMState *env, uint32_t insn) { int op1; int op2; int crm; op1 = (insn >> 21) & 7; op2 = (insn >> 5) & 7; crm = insn & 0xf; switch ((insn >> 16) & 0xf) { case 0: switch (op1) { case 0: switch (crm) { case 0: switch (op2) { case 0: return env->cp15.c0_cpuid; case 1: return env->cp15.c0_cachetype; case 2: return 0; case 3: return 0; case 5: if (arm_feature(env, ARM_FEATURE_V7) || ARM_CPUID(env) == ARM_CPUID_ARM11MPCORE) { int mpidr = env->cpu_index; if (arm_feature(env, ARM_FEATURE_V7MP)) { mpidr |= (1 << 31); } return mpidr; } default: goto bad_reg; } case 3: case 4: case 5: case 6: case 7: return 0; default: goto bad_reg; } default: goto bad_reg; } case 4: goto bad_reg; case 11: case 12: goto bad_reg; } bad_reg: cpu_abort(env, "Unimplemented cp15 register read (c%d, c%d, {%d, %d})\n", (insn >> 16) & 0xf, crm, op1, op2); return 0; }
{ "code": [], "line_no": [] }
uint32_t FUNC_0(get_cp15)(CPUARMState *env, uint32_t insn) { int VAR_0; int VAR_1; int VAR_2; VAR_0 = (insn >> 21) & 7; VAR_1 = (insn >> 5) & 7; VAR_2 = insn & 0xf; switch ((insn >> 16) & 0xf) { case 0: switch (VAR_0) { case 0: switch (VAR_2) { case 0: switch (VAR_1) { case 0: return env->cp15.c0_cpuid; case 1: return env->cp15.c0_cachetype; case 2: return 0; case 3: return 0; case 5: if (arm_feature(env, ARM_FEATURE_V7) || ARM_CPUID(env) == ARM_CPUID_ARM11MPCORE) { int VAR_3 = env->cpu_index; if (arm_feature(env, ARM_FEATURE_V7MP)) { VAR_3 |= (1 << 31); } return VAR_3; } default: goto bad_reg; } case 3: case 4: case 5: case 6: case 7: return 0; default: goto bad_reg; } default: goto bad_reg; } case 4: goto bad_reg; case 11: case 12: goto bad_reg; } bad_reg: cpu_abort(env, "Unimplemented cp15 register read (c%d, c%d, {%d, %d})\n", (insn >> 16) & 0xf, VAR_2, VAR_0, VAR_1); return 0; }
[ "uint32_t FUNC_0(get_cp15)(CPUARMState *env, uint32_t insn)\n{", "int VAR_0;", "int VAR_1;", "int VAR_2;", "VAR_0 = (insn >> 21) & 7;", "VAR_1 = (insn >> 5) & 7;", "VAR_2 = insn & 0xf;", "switch ((insn >> 16) & 0xf) {", "case 0:\nswitch (VAR_0) {", "case 0:\nswitch (VAR_2) {", "case 0:\nswitch (VAR_1) {", "case 0:\nreturn env->cp15.c0_cpuid;", "case 1:\nreturn env->cp15.c0_cachetype;", "case 2:\nreturn 0;", "case 3:\nreturn 0;", "case 5:\nif (arm_feature(env, ARM_FEATURE_V7) ||\nARM_CPUID(env) == ARM_CPUID_ARM11MPCORE) {", "int VAR_3 = env->cpu_index;", "if (arm_feature(env, ARM_FEATURE_V7MP)) {", "VAR_3 |= (1 << 31);", "}", "return VAR_3;", "}", "default:\ngoto bad_reg;", "}", "case 3: case 4: case 5: case 6: case 7:\nreturn 0;", "default:\ngoto bad_reg;", "}", "default:\ngoto bad_reg;", "}", "case 4:\ngoto bad_reg;", "case 11:\ncase 12:\ngoto bad_reg;", "}", "bad_reg:\ncpu_abort(env, \"Unimplemented cp15 register read (c%d, c%d, {%d, %d})\\n\",", "(insn >> 16) & 0xf, VAR_2, VAR_0, VAR_1);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21, 23 ], [ 25, 27 ], [ 29, 31 ], [ 33, 35 ], [ 37, 39 ], [ 41, 43 ], [ 45, 47 ], [ 49, 59, 61 ], [ 63 ], [ 71 ], [ 73 ], [ 85 ], [ 87 ], [ 89 ], [ 93, 95 ], [ 97 ], [ 99, 101 ], [ 103, 105 ], [ 107 ], [ 109, 111 ], [ 113 ], [ 115, 117 ], [ 119, 121, 123 ], [ 125 ], [ 127, 131 ], [ 133 ], [ 135 ], [ 137 ] ]
12,479
static void hpet_ram_writel(void *opaque, target_phys_addr_t addr, uint32_t value) { int i; HPETState *s = opaque; uint64_t old_val, new_val, val, index; DPRINTF("qemu: Enter hpet_ram_writel at %" PRIx64 " = %#x\n", addr, value); index = addr; old_val = hpet_ram_readl(opaque, addr); new_val = value; /*address range of all TN regs*/ if (index >= 0x100 && index <= 0x3ff) { uint8_t timer_id = (addr - 0x100) / 0x20; HPETTimer *timer = &s->timer[timer_id]; DPRINTF("qemu: hpet_ram_writel timer_id = %#x \n", timer_id); if (timer_id > s->num_timers) { DPRINTF("qemu: timer id out of range\n"); return; } switch ((addr - 0x100) % 0x20) { case HPET_TN_CFG: DPRINTF("qemu: hpet_ram_writel HPET_TN_CFG\n"); if (activating_bit(old_val, new_val, HPET_TN_FSB_ENABLE)) { update_irq(timer, 0); } val = hpet_fixup_reg(new_val, old_val, HPET_TN_CFG_WRITE_MASK); timer->config = (timer->config & 0xffffffff00000000ULL) | val; if (new_val & HPET_TN_32BIT) { timer->cmp = (uint32_t)timer->cmp; timer->period = (uint32_t)timer->period; } if (activating_bit(old_val, new_val, HPET_TN_ENABLE)) { hpet_set_timer(timer); } else if (deactivating_bit(old_val, new_val, HPET_TN_ENABLE)) { hpet_del_timer(timer); } break; case HPET_TN_CFG + 4: // Interrupt capabilities DPRINTF("qemu: invalid HPET_TN_CFG+4 write\n"); break; case HPET_TN_CMP: // comparator register DPRINTF("qemu: hpet_ram_writel HPET_TN_CMP \n"); if (timer->config & HPET_TN_32BIT) { new_val = (uint32_t)new_val; } if (!timer_is_periodic(timer) || (timer->config & HPET_TN_SETVAL)) { timer->cmp = (timer->cmp & 0xffffffff00000000ULL) | new_val; } if (timer_is_periodic(timer)) { /* * FIXME: Clamp period to reasonable min value? * Clamp period to reasonable max value */ new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1; timer->period = (timer->period & 0xffffffff00000000ULL) | new_val; } timer->config &= ~HPET_TN_SETVAL; if (hpet_enabled(s)) { hpet_set_timer(timer); } break; case HPET_TN_CMP + 4: // comparator register high order DPRINTF("qemu: hpet_ram_writel HPET_TN_CMP + 4\n"); if (!timer_is_periodic(timer) || (timer->config & HPET_TN_SETVAL)) { timer->cmp = (timer->cmp & 0xffffffffULL) | new_val << 32; } else { /* * FIXME: Clamp period to reasonable min value? * Clamp period to reasonable max value */ new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1; timer->period = (timer->period & 0xffffffffULL) | new_val << 32; } timer->config &= ~HPET_TN_SETVAL; if (hpet_enabled(s)) { hpet_set_timer(timer); } break; case HPET_TN_ROUTE: timer->fsb = (timer->fsb & 0xffffffff00000000ULL) | new_val; break; case HPET_TN_ROUTE + 4: timer->fsb = (new_val << 32) | (timer->fsb & 0xffffffff); break; default: DPRINTF("qemu: invalid hpet_ram_writel\n"); break; } return; } else { switch (index) { case HPET_ID: return; case HPET_CFG: val = hpet_fixup_reg(new_val, old_val, HPET_CFG_WRITE_MASK); s->config = (s->config & 0xffffffff00000000ULL) | val; if (activating_bit(old_val, new_val, HPET_CFG_ENABLE)) { /* Enable main counter and interrupt generation. */ s->hpet_offset = ticks_to_ns(s->hpet_counter) - qemu_get_clock_ns(vm_clock); for (i = 0; i < s->num_timers; i++) { if ((&s->timer[i])->cmp != ~0ULL) { hpet_set_timer(&s->timer[i]); } } } else if (deactivating_bit(old_val, new_val, HPET_CFG_ENABLE)) { /* Halt main counter and disable interrupt generation. */ s->hpet_counter = hpet_get_ticks(s); for (i = 0; i < s->num_timers; i++) { hpet_del_timer(&s->timer[i]); } } /* i8254 and RTC are disabled when HPET is in legacy mode */ if (activating_bit(old_val, new_val, HPET_CFG_LEGACY)) { hpet_pit_disable(); qemu_irq_lower(s->irqs[RTC_ISA_IRQ]); } else if (deactivating_bit(old_val, new_val, HPET_CFG_LEGACY)) { hpet_pit_enable(); qemu_set_irq(s->irqs[RTC_ISA_IRQ], s->rtc_irq_level); } break; case HPET_CFG + 4: DPRINTF("qemu: invalid HPET_CFG+4 write \n"); break; case HPET_STATUS: val = new_val & s->isr; for (i = 0; i < s->num_timers; i++) { if (val & (1 << i)) { update_irq(&s->timer[i], 0); } } break; case HPET_COUNTER: if (hpet_enabled(s)) { DPRINTF("qemu: Writing counter while HPET enabled!\n"); } s->hpet_counter = (s->hpet_counter & 0xffffffff00000000ULL) | value; DPRINTF("qemu: HPET counter written. ctr = %#x -> %" PRIx64 "\n", value, s->hpet_counter); break; case HPET_COUNTER + 4: if (hpet_enabled(s)) { DPRINTF("qemu: Writing counter while HPET enabled!\n"); } s->hpet_counter = (s->hpet_counter & 0xffffffffULL) | (((uint64_t)value) << 32); DPRINTF("qemu: HPET counter + 4 written. ctr = %#x -> %" PRIx64 "\n", value, s->hpet_counter); break; default: DPRINTF("qemu: invalid hpet_ram_writel\n"); break; } } }
false
qemu
b2bedb214469af55179d907a60cd67fed6b0779e
static void hpet_ram_writel(void *opaque, target_phys_addr_t addr, uint32_t value) { int i; HPETState *s = opaque; uint64_t old_val, new_val, val, index; DPRINTF("qemu: Enter hpet_ram_writel at %" PRIx64 " = %#x\n", addr, value); index = addr; old_val = hpet_ram_readl(opaque, addr); new_val = value; if (index >= 0x100 && index <= 0x3ff) { uint8_t timer_id = (addr - 0x100) / 0x20; HPETTimer *timer = &s->timer[timer_id]; DPRINTF("qemu: hpet_ram_writel timer_id = %#x \n", timer_id); if (timer_id > s->num_timers) { DPRINTF("qemu: timer id out of range\n"); return; } switch ((addr - 0x100) % 0x20) { case HPET_TN_CFG: DPRINTF("qemu: hpet_ram_writel HPET_TN_CFG\n"); if (activating_bit(old_val, new_val, HPET_TN_FSB_ENABLE)) { update_irq(timer, 0); } val = hpet_fixup_reg(new_val, old_val, HPET_TN_CFG_WRITE_MASK); timer->config = (timer->config & 0xffffffff00000000ULL) | val; if (new_val & HPET_TN_32BIT) { timer->cmp = (uint32_t)timer->cmp; timer->period = (uint32_t)timer->period; } if (activating_bit(old_val, new_val, HPET_TN_ENABLE)) { hpet_set_timer(timer); } else if (deactivating_bit(old_val, new_val, HPET_TN_ENABLE)) { hpet_del_timer(timer); } break; case HPET_TN_CFG + 4: DPRINTF("qemu: invalid HPET_TN_CFG+4 write\n"); break; case HPET_TN_CMP: DPRINTF("qemu: hpet_ram_writel HPET_TN_CMP \n"); if (timer->config & HPET_TN_32BIT) { new_val = (uint32_t)new_val; } if (!timer_is_periodic(timer) || (timer->config & HPET_TN_SETVAL)) { timer->cmp = (timer->cmp & 0xffffffff00000000ULL) | new_val; } if (timer_is_periodic(timer)) { new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1; timer->period = (timer->period & 0xffffffff00000000ULL) | new_val; } timer->config &= ~HPET_TN_SETVAL; if (hpet_enabled(s)) { hpet_set_timer(timer); } break; case HPET_TN_CMP + 4: high order DPRINTF("qemu: hpet_ram_writel HPET_TN_CMP + 4\n"); if (!timer_is_periodic(timer) || (timer->config & HPET_TN_SETVAL)) { timer->cmp = (timer->cmp & 0xffffffffULL) | new_val << 32; } else { new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1; timer->period = (timer->period & 0xffffffffULL) | new_val << 32; } timer->config &= ~HPET_TN_SETVAL; if (hpet_enabled(s)) { hpet_set_timer(timer); } break; case HPET_TN_ROUTE: timer->fsb = (timer->fsb & 0xffffffff00000000ULL) | new_val; break; case HPET_TN_ROUTE + 4: timer->fsb = (new_val << 32) | (timer->fsb & 0xffffffff); break; default: DPRINTF("qemu: invalid hpet_ram_writel\n"); break; } return; } else { switch (index) { case HPET_ID: return; case HPET_CFG: val = hpet_fixup_reg(new_val, old_val, HPET_CFG_WRITE_MASK); s->config = (s->config & 0xffffffff00000000ULL) | val; if (activating_bit(old_val, new_val, HPET_CFG_ENABLE)) { s->hpet_offset = ticks_to_ns(s->hpet_counter) - qemu_get_clock_ns(vm_clock); for (i = 0; i < s->num_timers; i++) { if ((&s->timer[i])->cmp != ~0ULL) { hpet_set_timer(&s->timer[i]); } } } else if (deactivating_bit(old_val, new_val, HPET_CFG_ENABLE)) { s->hpet_counter = hpet_get_ticks(s); for (i = 0; i < s->num_timers; i++) { hpet_del_timer(&s->timer[i]); } } if (activating_bit(old_val, new_val, HPET_CFG_LEGACY)) { hpet_pit_disable(); qemu_irq_lower(s->irqs[RTC_ISA_IRQ]); } else if (deactivating_bit(old_val, new_val, HPET_CFG_LEGACY)) { hpet_pit_enable(); qemu_set_irq(s->irqs[RTC_ISA_IRQ], s->rtc_irq_level); } break; case HPET_CFG + 4: DPRINTF("qemu: invalid HPET_CFG+4 write \n"); break; case HPET_STATUS: val = new_val & s->isr; for (i = 0; i < s->num_timers; i++) { if (val & (1 << i)) { update_irq(&s->timer[i], 0); } } break; case HPET_COUNTER: if (hpet_enabled(s)) { DPRINTF("qemu: Writing counter while HPET enabled!\n"); } s->hpet_counter = (s->hpet_counter & 0xffffffff00000000ULL) | value; DPRINTF("qemu: HPET counter written. ctr = %#x -> %" PRIx64 "\n", value, s->hpet_counter); break; case HPET_COUNTER + 4: if (hpet_enabled(s)) { DPRINTF("qemu: Writing counter while HPET enabled!\n"); } s->hpet_counter = (s->hpet_counter & 0xffffffffULL) | (((uint64_t)value) << 32); DPRINTF("qemu: HPET counter + 4 written. ctr = %#x -> %" PRIx64 "\n", value, s->hpet_counter); break; default: DPRINTF("qemu: invalid hpet_ram_writel\n"); break; } } }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint32_t VAR_2) { int VAR_3; HPETState *s = VAR_0; uint64_t old_val, new_val, val, index; DPRINTF("qemu: Enter FUNC_0 at %" PRIx64 " = %#x\n", VAR_1, VAR_2); index = VAR_1; old_val = hpet_ram_readl(VAR_0, VAR_1); new_val = VAR_2; if (index >= 0x100 && index <= 0x3ff) { uint8_t timer_id = (VAR_1 - 0x100) / 0x20; HPETTimer *timer = &s->timer[timer_id]; DPRINTF("qemu: FUNC_0 timer_id = %#x \n", timer_id); if (timer_id > s->num_timers) { DPRINTF("qemu: timer id out of range\n"); return; } switch ((VAR_1 - 0x100) % 0x20) { case HPET_TN_CFG: DPRINTF("qemu: FUNC_0 HPET_TN_CFG\n"); if (activating_bit(old_val, new_val, HPET_TN_FSB_ENABLE)) { update_irq(timer, 0); } val = hpet_fixup_reg(new_val, old_val, HPET_TN_CFG_WRITE_MASK); timer->config = (timer->config & 0xffffffff00000000ULL) | val; if (new_val & HPET_TN_32BIT) { timer->cmp = (uint32_t)timer->cmp; timer->period = (uint32_t)timer->period; } if (activating_bit(old_val, new_val, HPET_TN_ENABLE)) { hpet_set_timer(timer); } else if (deactivating_bit(old_val, new_val, HPET_TN_ENABLE)) { hpet_del_timer(timer); } break; case HPET_TN_CFG + 4: DPRINTF("qemu: invalid HPET_TN_CFG+4 write\n"); break; case HPET_TN_CMP: DPRINTF("qemu: FUNC_0 HPET_TN_CMP \n"); if (timer->config & HPET_TN_32BIT) { new_val = (uint32_t)new_val; } if (!timer_is_periodic(timer) || (timer->config & HPET_TN_SETVAL)) { timer->cmp = (timer->cmp & 0xffffffff00000000ULL) | new_val; } if (timer_is_periodic(timer)) { new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1; timer->period = (timer->period & 0xffffffff00000000ULL) | new_val; } timer->config &= ~HPET_TN_SETVAL; if (hpet_enabled(s)) { hpet_set_timer(timer); } break; case HPET_TN_CMP + 4: high order DPRINTF("qemu: FUNC_0 HPET_TN_CMP + 4\n"); if (!timer_is_periodic(timer) || (timer->config & HPET_TN_SETVAL)) { timer->cmp = (timer->cmp & 0xffffffffULL) | new_val << 32; } else { new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1; timer->period = (timer->period & 0xffffffffULL) | new_val << 32; } timer->config &= ~HPET_TN_SETVAL; if (hpet_enabled(s)) { hpet_set_timer(timer); } break; case HPET_TN_ROUTE: timer->fsb = (timer->fsb & 0xffffffff00000000ULL) | new_val; break; case HPET_TN_ROUTE + 4: timer->fsb = (new_val << 32) | (timer->fsb & 0xffffffff); break; default: DPRINTF("qemu: invalid FUNC_0\n"); break; } return; } else { switch (index) { case HPET_ID: return; case HPET_CFG: val = hpet_fixup_reg(new_val, old_val, HPET_CFG_WRITE_MASK); s->config = (s->config & 0xffffffff00000000ULL) | val; if (activating_bit(old_val, new_val, HPET_CFG_ENABLE)) { s->hpet_offset = ticks_to_ns(s->hpet_counter) - qemu_get_clock_ns(vm_clock); for (VAR_3 = 0; VAR_3 < s->num_timers; VAR_3++) { if ((&s->timer[VAR_3])->cmp != ~0ULL) { hpet_set_timer(&s->timer[VAR_3]); } } } else if (deactivating_bit(old_val, new_val, HPET_CFG_ENABLE)) { s->hpet_counter = hpet_get_ticks(s); for (VAR_3 = 0; VAR_3 < s->num_timers; VAR_3++) { hpet_del_timer(&s->timer[VAR_3]); } } if (activating_bit(old_val, new_val, HPET_CFG_LEGACY)) { hpet_pit_disable(); qemu_irq_lower(s->irqs[RTC_ISA_IRQ]); } else if (deactivating_bit(old_val, new_val, HPET_CFG_LEGACY)) { hpet_pit_enable(); qemu_set_irq(s->irqs[RTC_ISA_IRQ], s->rtc_irq_level); } break; case HPET_CFG + 4: DPRINTF("qemu: invalid HPET_CFG+4 write \n"); break; case HPET_STATUS: val = new_val & s->isr; for (VAR_3 = 0; VAR_3 < s->num_timers; VAR_3++) { if (val & (1 << VAR_3)) { update_irq(&s->timer[VAR_3], 0); } } break; case HPET_COUNTER: if (hpet_enabled(s)) { DPRINTF("qemu: Writing counter while HPET enabled!\n"); } s->hpet_counter = (s->hpet_counter & 0xffffffff00000000ULL) | VAR_2; DPRINTF("qemu: HPET counter written. ctr = %#x -> %" PRIx64 "\n", VAR_2, s->hpet_counter); break; case HPET_COUNTER + 4: if (hpet_enabled(s)) { DPRINTF("qemu: Writing counter while HPET enabled!\n"); } s->hpet_counter = (s->hpet_counter & 0xffffffffULL) | (((uint64_t)VAR_2) << 32); DPRINTF("qemu: HPET counter + 4 written. ctr = %#x -> %" PRIx64 "\n", VAR_2, s->hpet_counter); break; default: DPRINTF("qemu: invalid FUNC_0\n"); break; } } }
[ "static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint32_t VAR_2)\n{", "int VAR_3;", "HPETState *s = VAR_0;", "uint64_t old_val, new_val, val, index;", "DPRINTF(\"qemu: Enter FUNC_0 at %\" PRIx64 \" = %#x\\n\", VAR_1, VAR_2);", "index = VAR_1;", "old_val = hpet_ram_readl(VAR_0, VAR_1);", "new_val = VAR_2;", "if (index >= 0x100 && index <= 0x3ff) {", "uint8_t timer_id = (VAR_1 - 0x100) / 0x20;", "HPETTimer *timer = &s->timer[timer_id];", "DPRINTF(\"qemu: FUNC_0 timer_id = %#x \\n\", timer_id);", "if (timer_id > s->num_timers) {", "DPRINTF(\"qemu: timer id out of range\\n\");", "return;", "}", "switch ((VAR_1 - 0x100) % 0x20) {", "case HPET_TN_CFG:\nDPRINTF(\"qemu: FUNC_0 HPET_TN_CFG\\n\");", "if (activating_bit(old_val, new_val, HPET_TN_FSB_ENABLE)) {", "update_irq(timer, 0);", "}", "val = hpet_fixup_reg(new_val, old_val, HPET_TN_CFG_WRITE_MASK);", "timer->config = (timer->config & 0xffffffff00000000ULL) | val;", "if (new_val & HPET_TN_32BIT) {", "timer->cmp = (uint32_t)timer->cmp;", "timer->period = (uint32_t)timer->period;", "}", "if (activating_bit(old_val, new_val, HPET_TN_ENABLE)) {", "hpet_set_timer(timer);", "} else if (deactivating_bit(old_val, new_val, HPET_TN_ENABLE)) {", "hpet_del_timer(timer);", "}", "break;", "case HPET_TN_CFG + 4:\nDPRINTF(\"qemu: invalid HPET_TN_CFG+4 write\\n\");", "break;", "case HPET_TN_CMP:\nDPRINTF(\"qemu: FUNC_0 HPET_TN_CMP \\n\");", "if (timer->config & HPET_TN_32BIT) {", "new_val = (uint32_t)new_val;", "}", "if (!timer_is_periodic(timer)\n|| (timer->config & HPET_TN_SETVAL)) {", "timer->cmp = (timer->cmp & 0xffffffff00000000ULL) | new_val;", "}", "if (timer_is_periodic(timer)) {", "new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1;", "timer->period =\n(timer->period & 0xffffffff00000000ULL) | new_val;", "}", "timer->config &= ~HPET_TN_SETVAL;", "if (hpet_enabled(s)) {", "hpet_set_timer(timer);", "}", "break;", "case HPET_TN_CMP + 4: high order\nDPRINTF(\"qemu: FUNC_0 HPET_TN_CMP + 4\\n\");", "if (!timer_is_periodic(timer)\n|| (timer->config & HPET_TN_SETVAL)) {", "timer->cmp = (timer->cmp & 0xffffffffULL) | new_val << 32;", "} else {", "new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1;", "timer->period =\n(timer->period & 0xffffffffULL) | new_val << 32;", "}", "timer->config &= ~HPET_TN_SETVAL;", "if (hpet_enabled(s)) {", "hpet_set_timer(timer);", "}", "break;", "case HPET_TN_ROUTE:\ntimer->fsb = (timer->fsb & 0xffffffff00000000ULL) | new_val;", "break;", "case HPET_TN_ROUTE + 4:\ntimer->fsb = (new_val << 32) | (timer->fsb & 0xffffffff);", "break;", "default:\nDPRINTF(\"qemu: invalid FUNC_0\\n\");", "break;", "}", "return;", "} else {", "switch (index) {", "case HPET_ID:\nreturn;", "case HPET_CFG:\nval = hpet_fixup_reg(new_val, old_val, HPET_CFG_WRITE_MASK);", "s->config = (s->config & 0xffffffff00000000ULL) | val;", "if (activating_bit(old_val, new_val, HPET_CFG_ENABLE)) {", "s->hpet_offset =\nticks_to_ns(s->hpet_counter) - qemu_get_clock_ns(vm_clock);", "for (VAR_3 = 0; VAR_3 < s->num_timers; VAR_3++) {", "if ((&s->timer[VAR_3])->cmp != ~0ULL) {", "hpet_set_timer(&s->timer[VAR_3]);", "}", "}", "} else if (deactivating_bit(old_val, new_val, HPET_CFG_ENABLE)) {", "s->hpet_counter = hpet_get_ticks(s);", "for (VAR_3 = 0; VAR_3 < s->num_timers; VAR_3++) {", "hpet_del_timer(&s->timer[VAR_3]);", "}", "}", "if (activating_bit(old_val, new_val, HPET_CFG_LEGACY)) {", "hpet_pit_disable();", "qemu_irq_lower(s->irqs[RTC_ISA_IRQ]);", "} else if (deactivating_bit(old_val, new_val, HPET_CFG_LEGACY)) {", "hpet_pit_enable();", "qemu_set_irq(s->irqs[RTC_ISA_IRQ], s->rtc_irq_level);", "}", "break;", "case HPET_CFG + 4:\nDPRINTF(\"qemu: invalid HPET_CFG+4 write \\n\");", "break;", "case HPET_STATUS:\nval = new_val & s->isr;", "for (VAR_3 = 0; VAR_3 < s->num_timers; VAR_3++) {", "if (val & (1 << VAR_3)) {", "update_irq(&s->timer[VAR_3], 0);", "}", "}", "break;", "case HPET_COUNTER:\nif (hpet_enabled(s)) {", "DPRINTF(\"qemu: Writing counter while HPET enabled!\\n\");", "}", "s->hpet_counter =\n(s->hpet_counter & 0xffffffff00000000ULL) | VAR_2;", "DPRINTF(\"qemu: HPET counter written. ctr = %#x -> %\" PRIx64 \"\\n\",\nVAR_2, s->hpet_counter);", "break;", "case HPET_COUNTER + 4:\nif (hpet_enabled(s)) {", "DPRINTF(\"qemu: Writing counter while HPET enabled!\\n\");", "}", "s->hpet_counter =\n(s->hpet_counter & 0xffffffffULL) | (((uint64_t)VAR_2) << 32);", "DPRINTF(\"qemu: HPET counter + 4 written. ctr = %#x -> %\" PRIx64 \"\\n\",\nVAR_2, s->hpet_counter);", "break;", "default:\nDPRINTF(\"qemu: invalid FUNC_0\\n\");", "break;", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 27 ], [ 29 ], [ 31 ], [ 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 ], [ 115 ], [ 117, 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133, 135 ], [ 137, 139 ], [ 141 ], [ 143 ], [ 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 ], [ 211, 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 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 ] ]
12,480
static void create_pcie(const VirtBoardInfo *vbi, qemu_irq *pic, bool use_highmem) { hwaddr base_mmio = vbi->memmap[VIRT_PCIE_MMIO].base; hwaddr size_mmio = vbi->memmap[VIRT_PCIE_MMIO].size; hwaddr base_mmio_high = vbi->memmap[VIRT_PCIE_MMIO_HIGH].base; hwaddr size_mmio_high = vbi->memmap[VIRT_PCIE_MMIO_HIGH].size; hwaddr base_pio = vbi->memmap[VIRT_PCIE_PIO].base; hwaddr size_pio = vbi->memmap[VIRT_PCIE_PIO].size; hwaddr base_ecam = vbi->memmap[VIRT_PCIE_ECAM].base; hwaddr size_ecam = vbi->memmap[VIRT_PCIE_ECAM].size; hwaddr base = base_mmio; int nr_pcie_buses = size_ecam / PCIE_MMCFG_SIZE_MIN; int irq = vbi->irqmap[VIRT_PCIE]; MemoryRegion *mmio_alias; MemoryRegion *mmio_reg; MemoryRegion *ecam_alias; MemoryRegion *ecam_reg; DeviceState *dev; char *nodename; int i; dev = qdev_create(NULL, TYPE_GPEX_HOST); qdev_init_nofail(dev); /* Map only the first size_ecam bytes of ECAM space */ ecam_alias = g_new0(MemoryRegion, 1); ecam_reg = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0); memory_region_init_alias(ecam_alias, OBJECT(dev), "pcie-ecam", ecam_reg, 0, size_ecam); memory_region_add_subregion(get_system_memory(), base_ecam, ecam_alias); /* Map the MMIO window into system address space so as to expose * the section of PCI MMIO space which starts at the same base address * (ie 1:1 mapping for that part of PCI MMIO space visible through * the window). */ mmio_alias = g_new0(MemoryRegion, 1); mmio_reg = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 1); memory_region_init_alias(mmio_alias, OBJECT(dev), "pcie-mmio", mmio_reg, base_mmio, size_mmio); memory_region_add_subregion(get_system_memory(), base_mmio, mmio_alias); if (use_highmem) { /* Map high MMIO space */ MemoryRegion *high_mmio_alias = g_new0(MemoryRegion, 1); memory_region_init_alias(high_mmio_alias, OBJECT(dev), "pcie-mmio-high", mmio_reg, base_mmio_high, size_mmio_high); memory_region_add_subregion(get_system_memory(), base_mmio_high, high_mmio_alias); } /* Map IO port space */ sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, base_pio); for (i = 0; i < GPEX_NUM_IRQS; i++) { sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, pic[irq + i]); } nodename = g_strdup_printf("/pcie@%" PRIx64, base); qemu_fdt_add_subnode(vbi->fdt, nodename); qemu_fdt_setprop_string(vbi->fdt, nodename, "compatible", "pci-host-ecam-generic"); qemu_fdt_setprop_string(vbi->fdt, nodename, "device_type", "pci"); qemu_fdt_setprop_cell(vbi->fdt, nodename, "#address-cells", 3); qemu_fdt_setprop_cell(vbi->fdt, nodename, "#size-cells", 2); qemu_fdt_setprop_cells(vbi->fdt, nodename, "bus-range", 0, nr_pcie_buses - 1); qemu_fdt_setprop_cells(vbi->fdt, nodename, "msi-parent", vbi->v2m_phandle); qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg", 2, base_ecam, 2, size_ecam); if (use_highmem) { qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "ranges", 1, FDT_PCI_RANGE_IOPORT, 2, 0, 2, base_pio, 2, size_pio, 1, FDT_PCI_RANGE_MMIO, 2, base_mmio, 2, base_mmio, 2, size_mmio, 1, FDT_PCI_RANGE_MMIO_64BIT, 2, base_mmio_high, 2, base_mmio_high, 2, size_mmio_high); } else { qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "ranges", 1, FDT_PCI_RANGE_IOPORT, 2, 0, 2, base_pio, 2, size_pio, 1, FDT_PCI_RANGE_MMIO, 2, base_mmio, 2, base_mmio, 2, size_mmio); } qemu_fdt_setprop_cell(vbi->fdt, nodename, "#interrupt-cells", 1); create_pcie_irq_map(vbi, vbi->gic_phandle, irq, nodename); g_free(nodename); }
false
qemu
b92ad3949bc9cacd1652b4e07e7f6003b9e512af
static void create_pcie(const VirtBoardInfo *vbi, qemu_irq *pic, bool use_highmem) { hwaddr base_mmio = vbi->memmap[VIRT_PCIE_MMIO].base; hwaddr size_mmio = vbi->memmap[VIRT_PCIE_MMIO].size; hwaddr base_mmio_high = vbi->memmap[VIRT_PCIE_MMIO_HIGH].base; hwaddr size_mmio_high = vbi->memmap[VIRT_PCIE_MMIO_HIGH].size; hwaddr base_pio = vbi->memmap[VIRT_PCIE_PIO].base; hwaddr size_pio = vbi->memmap[VIRT_PCIE_PIO].size; hwaddr base_ecam = vbi->memmap[VIRT_PCIE_ECAM].base; hwaddr size_ecam = vbi->memmap[VIRT_PCIE_ECAM].size; hwaddr base = base_mmio; int nr_pcie_buses = size_ecam / PCIE_MMCFG_SIZE_MIN; int irq = vbi->irqmap[VIRT_PCIE]; MemoryRegion *mmio_alias; MemoryRegion *mmio_reg; MemoryRegion *ecam_alias; MemoryRegion *ecam_reg; DeviceState *dev; char *nodename; int i; dev = qdev_create(NULL, TYPE_GPEX_HOST); qdev_init_nofail(dev); ecam_alias = g_new0(MemoryRegion, 1); ecam_reg = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0); memory_region_init_alias(ecam_alias, OBJECT(dev), "pcie-ecam", ecam_reg, 0, size_ecam); memory_region_add_subregion(get_system_memory(), base_ecam, ecam_alias); mmio_alias = g_new0(MemoryRegion, 1); mmio_reg = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 1); memory_region_init_alias(mmio_alias, OBJECT(dev), "pcie-mmio", mmio_reg, base_mmio, size_mmio); memory_region_add_subregion(get_system_memory(), base_mmio, mmio_alias); if (use_highmem) { MemoryRegion *high_mmio_alias = g_new0(MemoryRegion, 1); memory_region_init_alias(high_mmio_alias, OBJECT(dev), "pcie-mmio-high", mmio_reg, base_mmio_high, size_mmio_high); memory_region_add_subregion(get_system_memory(), base_mmio_high, high_mmio_alias); } sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, base_pio); for (i = 0; i < GPEX_NUM_IRQS; i++) { sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, pic[irq + i]); } nodename = g_strdup_printf("/pcie@%" PRIx64, base); qemu_fdt_add_subnode(vbi->fdt, nodename); qemu_fdt_setprop_string(vbi->fdt, nodename, "compatible", "pci-host-ecam-generic"); qemu_fdt_setprop_string(vbi->fdt, nodename, "device_type", "pci"); qemu_fdt_setprop_cell(vbi->fdt, nodename, "#address-cells", 3); qemu_fdt_setprop_cell(vbi->fdt, nodename, "#size-cells", 2); qemu_fdt_setprop_cells(vbi->fdt, nodename, "bus-range", 0, nr_pcie_buses - 1); qemu_fdt_setprop_cells(vbi->fdt, nodename, "msi-parent", vbi->v2m_phandle); qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg", 2, base_ecam, 2, size_ecam); if (use_highmem) { qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "ranges", 1, FDT_PCI_RANGE_IOPORT, 2, 0, 2, base_pio, 2, size_pio, 1, FDT_PCI_RANGE_MMIO, 2, base_mmio, 2, base_mmio, 2, size_mmio, 1, FDT_PCI_RANGE_MMIO_64BIT, 2, base_mmio_high, 2, base_mmio_high, 2, size_mmio_high); } else { qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "ranges", 1, FDT_PCI_RANGE_IOPORT, 2, 0, 2, base_pio, 2, size_pio, 1, FDT_PCI_RANGE_MMIO, 2, base_mmio, 2, base_mmio, 2, size_mmio); } qemu_fdt_setprop_cell(vbi->fdt, nodename, "#interrupt-cells", 1); create_pcie_irq_map(vbi, vbi->gic_phandle, irq, nodename); g_free(nodename); }
{ "code": [], "line_no": [] }
static void FUNC_0(const VirtBoardInfo *VAR_0, qemu_irq *VAR_1, bool VAR_2) { hwaddr base_mmio = VAR_0->memmap[VIRT_PCIE_MMIO].base; hwaddr size_mmio = VAR_0->memmap[VIRT_PCIE_MMIO].size; hwaddr base_mmio_high = VAR_0->memmap[VIRT_PCIE_MMIO_HIGH].base; hwaddr size_mmio_high = VAR_0->memmap[VIRT_PCIE_MMIO_HIGH].size; hwaddr base_pio = VAR_0->memmap[VIRT_PCIE_PIO].base; hwaddr size_pio = VAR_0->memmap[VIRT_PCIE_PIO].size; hwaddr base_ecam = VAR_0->memmap[VIRT_PCIE_ECAM].base; hwaddr size_ecam = VAR_0->memmap[VIRT_PCIE_ECAM].size; hwaddr base = base_mmio; int VAR_3 = size_ecam / PCIE_MMCFG_SIZE_MIN; int VAR_4 = VAR_0->irqmap[VIRT_PCIE]; MemoryRegion *mmio_alias; MemoryRegion *mmio_reg; MemoryRegion *ecam_alias; MemoryRegion *ecam_reg; DeviceState *dev; char *VAR_5; int VAR_6; dev = qdev_create(NULL, TYPE_GPEX_HOST); qdev_init_nofail(dev); ecam_alias = g_new0(MemoryRegion, 1); ecam_reg = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0); memory_region_init_alias(ecam_alias, OBJECT(dev), "pcie-ecam", ecam_reg, 0, size_ecam); memory_region_add_subregion(get_system_memory(), base_ecam, ecam_alias); mmio_alias = g_new0(MemoryRegion, 1); mmio_reg = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 1); memory_region_init_alias(mmio_alias, OBJECT(dev), "pcie-mmio", mmio_reg, base_mmio, size_mmio); memory_region_add_subregion(get_system_memory(), base_mmio, mmio_alias); if (VAR_2) { MemoryRegion *high_mmio_alias = g_new0(MemoryRegion, 1); memory_region_init_alias(high_mmio_alias, OBJECT(dev), "pcie-mmio-high", mmio_reg, base_mmio_high, size_mmio_high); memory_region_add_subregion(get_system_memory(), base_mmio_high, high_mmio_alias); } sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, base_pio); for (VAR_6 = 0; VAR_6 < GPEX_NUM_IRQS; VAR_6++) { sysbus_connect_irq(SYS_BUS_DEVICE(dev), VAR_6, VAR_1[VAR_4 + VAR_6]); } VAR_5 = g_strdup_printf("/pcie@%" PRIx64, base); qemu_fdt_add_subnode(VAR_0->fdt, VAR_5); qemu_fdt_setprop_string(VAR_0->fdt, VAR_5, "compatible", "pci-host-ecam-generic"); qemu_fdt_setprop_string(VAR_0->fdt, VAR_5, "device_type", "pci"); qemu_fdt_setprop_cell(VAR_0->fdt, VAR_5, "#address-cells", 3); qemu_fdt_setprop_cell(VAR_0->fdt, VAR_5, "#size-cells", 2); qemu_fdt_setprop_cells(VAR_0->fdt, VAR_5, "bus-range", 0, VAR_3 - 1); qemu_fdt_setprop_cells(VAR_0->fdt, VAR_5, "msi-parent", VAR_0->v2m_phandle); qemu_fdt_setprop_sized_cells(VAR_0->fdt, VAR_5, "reg", 2, base_ecam, 2, size_ecam); if (VAR_2) { qemu_fdt_setprop_sized_cells(VAR_0->fdt, VAR_5, "ranges", 1, FDT_PCI_RANGE_IOPORT, 2, 0, 2, base_pio, 2, size_pio, 1, FDT_PCI_RANGE_MMIO, 2, base_mmio, 2, base_mmio, 2, size_mmio, 1, FDT_PCI_RANGE_MMIO_64BIT, 2, base_mmio_high, 2, base_mmio_high, 2, size_mmio_high); } else { qemu_fdt_setprop_sized_cells(VAR_0->fdt, VAR_5, "ranges", 1, FDT_PCI_RANGE_IOPORT, 2, 0, 2, base_pio, 2, size_pio, 1, FDT_PCI_RANGE_MMIO, 2, base_mmio, 2, base_mmio, 2, size_mmio); } qemu_fdt_setprop_cell(VAR_0->fdt, VAR_5, "#interrupt-cells", 1); create_pcie_irq_map(VAR_0, VAR_0->gic_phandle, VAR_4, VAR_5); g_free(VAR_5); }
[ "static void FUNC_0(const VirtBoardInfo *VAR_0, qemu_irq *VAR_1,\nbool VAR_2)\n{", "hwaddr base_mmio = VAR_0->memmap[VIRT_PCIE_MMIO].base;", "hwaddr size_mmio = VAR_0->memmap[VIRT_PCIE_MMIO].size;", "hwaddr base_mmio_high = VAR_0->memmap[VIRT_PCIE_MMIO_HIGH].base;", "hwaddr size_mmio_high = VAR_0->memmap[VIRT_PCIE_MMIO_HIGH].size;", "hwaddr base_pio = VAR_0->memmap[VIRT_PCIE_PIO].base;", "hwaddr size_pio = VAR_0->memmap[VIRT_PCIE_PIO].size;", "hwaddr base_ecam = VAR_0->memmap[VIRT_PCIE_ECAM].base;", "hwaddr size_ecam = VAR_0->memmap[VIRT_PCIE_ECAM].size;", "hwaddr base = base_mmio;", "int VAR_3 = size_ecam / PCIE_MMCFG_SIZE_MIN;", "int VAR_4 = VAR_0->irqmap[VIRT_PCIE];", "MemoryRegion *mmio_alias;", "MemoryRegion *mmio_reg;", "MemoryRegion *ecam_alias;", "MemoryRegion *ecam_reg;", "DeviceState *dev;", "char *VAR_5;", "int VAR_6;", "dev = qdev_create(NULL, TYPE_GPEX_HOST);", "qdev_init_nofail(dev);", "ecam_alias = g_new0(MemoryRegion, 1);", "ecam_reg = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0);", "memory_region_init_alias(ecam_alias, OBJECT(dev), \"pcie-ecam\",\necam_reg, 0, size_ecam);", "memory_region_add_subregion(get_system_memory(), base_ecam, ecam_alias);", "mmio_alias = g_new0(MemoryRegion, 1);", "mmio_reg = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 1);", "memory_region_init_alias(mmio_alias, OBJECT(dev), \"pcie-mmio\",\nmmio_reg, base_mmio, size_mmio);", "memory_region_add_subregion(get_system_memory(), base_mmio, mmio_alias);", "if (VAR_2) {", "MemoryRegion *high_mmio_alias = g_new0(MemoryRegion, 1);", "memory_region_init_alias(high_mmio_alias, OBJECT(dev), \"pcie-mmio-high\",\nmmio_reg, base_mmio_high, size_mmio_high);", "memory_region_add_subregion(get_system_memory(), base_mmio_high,\nhigh_mmio_alias);", "}", "sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, base_pio);", "for (VAR_6 = 0; VAR_6 < GPEX_NUM_IRQS; VAR_6++) {", "sysbus_connect_irq(SYS_BUS_DEVICE(dev), VAR_6, VAR_1[VAR_4 + VAR_6]);", "}", "VAR_5 = g_strdup_printf(\"/pcie@%\" PRIx64, base);", "qemu_fdt_add_subnode(VAR_0->fdt, VAR_5);", "qemu_fdt_setprop_string(VAR_0->fdt, VAR_5,\n\"compatible\", \"pci-host-ecam-generic\");", "qemu_fdt_setprop_string(VAR_0->fdt, VAR_5, \"device_type\", \"pci\");", "qemu_fdt_setprop_cell(VAR_0->fdt, VAR_5, \"#address-cells\", 3);", "qemu_fdt_setprop_cell(VAR_0->fdt, VAR_5, \"#size-cells\", 2);", "qemu_fdt_setprop_cells(VAR_0->fdt, VAR_5, \"bus-range\", 0,\nVAR_3 - 1);", "qemu_fdt_setprop_cells(VAR_0->fdt, VAR_5, \"msi-parent\", VAR_0->v2m_phandle);", "qemu_fdt_setprop_sized_cells(VAR_0->fdt, VAR_5, \"reg\",\n2, base_ecam, 2, size_ecam);", "if (VAR_2) {", "qemu_fdt_setprop_sized_cells(VAR_0->fdt, VAR_5, \"ranges\",\n1, FDT_PCI_RANGE_IOPORT, 2, 0,\n2, base_pio, 2, size_pio,\n1, FDT_PCI_RANGE_MMIO, 2, base_mmio,\n2, base_mmio, 2, size_mmio,\n1, FDT_PCI_RANGE_MMIO_64BIT,\n2, base_mmio_high,\n2, base_mmio_high, 2, size_mmio_high);", "} else {", "qemu_fdt_setprop_sized_cells(VAR_0->fdt, VAR_5, \"ranges\",\n1, FDT_PCI_RANGE_IOPORT, 2, 0,\n2, base_pio, 2, size_pio,\n1, FDT_PCI_RANGE_MMIO, 2, base_mmio,\n2, base_mmio, 2, size_mmio);", "}", "qemu_fdt_setprop_cell(VAR_0->fdt, VAR_5, \"#interrupt-cells\", 1);", "create_pcie_irq_map(VAR_0, VAR_0->gic_phandle, VAR_4, VAR_5);", "g_free(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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 53 ], [ 55 ], [ 57, 59 ], [ 61 ], [ 75 ], [ 77 ], [ 79, 81 ], [ 83 ], [ 87 ], [ 91 ], [ 95, 97 ], [ 99, 101 ], [ 103 ], [ 109 ], [ 113 ], [ 115 ], [ 117 ], [ 121 ], [ 123 ], [ 125, 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135, 137 ], [ 141 ], [ 145, 147 ], [ 151 ], [ 153, 155, 157, 159, 161, 163, 165, 167 ], [ 169 ], [ 171, 173, 175, 177, 179 ], [ 181 ], [ 185 ], [ 187 ], [ 191 ], [ 193 ] ]
12,481
int omap_validate_emifs_addr(struct omap_mpu_state_s *s, target_phys_addr_t addr) { return addr >= OMAP_EMIFS_BASE && addr < OMAP_EMIFF_BASE; }
false
qemu
b854bc196f5c4b4e3299c0b0ee63cf828ece9e77
int omap_validate_emifs_addr(struct omap_mpu_state_s *s, target_phys_addr_t addr) { return addr >= OMAP_EMIFS_BASE && addr < OMAP_EMIFF_BASE; }
{ "code": [], "line_no": [] }
int FUNC_0(struct omap_mpu_state_s *VAR_0, target_phys_addr_t VAR_1) { return VAR_1 >= OMAP_EMIFS_BASE && VAR_1 < OMAP_EMIFF_BASE; }
[ "int FUNC_0(struct omap_mpu_state_s *VAR_0,\ntarget_phys_addr_t VAR_1)\n{", "return VAR_1 >= OMAP_EMIFS_BASE && VAR_1 < OMAP_EMIFF_BASE;", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ] ]
12,482
static int ppc_hash64_get_physical_address(CPUPPCState *env, struct mmu_ctx_hash64 *ctx, target_ulong eaddr, int rw, int access_type) { bool real_mode = (access_type == ACCESS_CODE && msr_ir == 0) || (access_type != ACCESS_CODE && msr_dr == 0); if (real_mode) { ctx->raddr = eaddr & 0x0FFFFFFFFFFFFFFFULL; ctx->prot = PAGE_READ | PAGE_EXEC | PAGE_WRITE; return 0; } else { return get_segment64(env, ctx, eaddr, rw, access_type); } }
false
qemu
91cda45b69e45a089f9989979a65db3f710c9925
static int ppc_hash64_get_physical_address(CPUPPCState *env, struct mmu_ctx_hash64 *ctx, target_ulong eaddr, int rw, int access_type) { bool real_mode = (access_type == ACCESS_CODE && msr_ir == 0) || (access_type != ACCESS_CODE && msr_dr == 0); if (real_mode) { ctx->raddr = eaddr & 0x0FFFFFFFFFFFFFFFULL; ctx->prot = PAGE_READ | PAGE_EXEC | PAGE_WRITE; return 0; } else { return get_segment64(env, ctx, eaddr, rw, access_type); } }
{ "code": [], "line_no": [] }
static int FUNC_0(CPUPPCState *VAR_0, struct mmu_ctx_hash64 *VAR_1, target_ulong VAR_2, int VAR_3, int VAR_4) { bool real_mode = (VAR_4 == ACCESS_CODE && msr_ir == 0) || (VAR_4 != ACCESS_CODE && msr_dr == 0); if (real_mode) { VAR_1->raddr = VAR_2 & 0x0FFFFFFFFFFFFFFFULL; VAR_1->prot = PAGE_READ | PAGE_EXEC | PAGE_WRITE; return 0; } else { return get_segment64(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4); } }
[ "static int FUNC_0(CPUPPCState *VAR_0,\nstruct mmu_ctx_hash64 *VAR_1,\ntarget_ulong VAR_2, int VAR_3,\nint VAR_4)\n{", "bool real_mode = (VAR_4 == ACCESS_CODE && msr_ir == 0)\n|| (VAR_4 != ACCESS_CODE && msr_dr == 0);", "if (real_mode) {", "VAR_1->raddr = VAR_2 & 0x0FFFFFFFFFFFFFFFULL;", "VAR_1->prot = PAGE_READ | PAGE_EXEC | PAGE_WRITE;", "return 0;", "} else {", "return get_segment64(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4);", "}", "}" ]
[ 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 ] ]
12,483
void cpu_resume_from_signal(CPUState *env1, void *puc) { env = env1; /* XXX: restore cpu registers saved in host registers */ env->exception_index = -1; longjmp(env->jmp_env, 1); }
false
qemu
cea5f9a28faa528b6b1b117c9ab2d8828f473fef
void cpu_resume_from_signal(CPUState *env1, void *puc) { env = env1; env->exception_index = -1; longjmp(env->jmp_env, 1); }
{ "code": [], "line_no": [] }
void FUNC_0(CPUState *VAR_0, void *VAR_1) { env = VAR_0; env->exception_index = -1; longjmp(env->jmp_env, 1); }
[ "void FUNC_0(CPUState *VAR_0, void *VAR_1)\n{", "env = VAR_0;", "env->exception_index = -1;", "longjmp(env->jmp_env, 1);", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 13 ], [ 15 ], [ 17 ] ]
12,484
static void minimac2_cleanup(NetClientState *nc) { MilkymistMinimac2State *s = qemu_get_nic_opaque(nc); s->nic = NULL; }
false
qemu
57407ea44cc0a3d630b9b89a2be011f1955ce5c1
static void minimac2_cleanup(NetClientState *nc) { MilkymistMinimac2State *s = qemu_get_nic_opaque(nc); s->nic = NULL; }
{ "code": [], "line_no": [] }
static void FUNC_0(NetClientState *VAR_0) { MilkymistMinimac2State *s = qemu_get_nic_opaque(VAR_0); s->nic = NULL; }
[ "static void FUNC_0(NetClientState *VAR_0)\n{", "MilkymistMinimac2State *s = qemu_get_nic_opaque(VAR_0);", "s->nic = NULL;", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ] ]
12,486
static int webp_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { AVFrame * const p = data; WebPContext *s = avctx->priv_data; GetByteContext gb; int ret; uint32_t chunk_type, chunk_size; int vp8x_flags = 0; s->avctx = avctx; s->width = 0; s->height = 0; *got_frame = 0; s->has_alpha = 0; bytestream2_init(&gb, avpkt->data, avpkt->size); if (bytestream2_get_bytes_left(&gb) < 12) return AVERROR_INVALIDDATA; if (bytestream2_get_le32(&gb) != MKTAG('R', 'I', 'F', 'F')) { av_log(avctx, AV_LOG_ERROR, "missing RIFF tag\n"); return AVERROR_INVALIDDATA; } chunk_size = bytestream2_get_le32(&gb); if (bytestream2_get_bytes_left(&gb) < chunk_size) return AVERROR_INVALIDDATA; if (bytestream2_get_le32(&gb) != MKTAG('W', 'E', 'B', 'P')) { av_log(avctx, AV_LOG_ERROR, "missing WEBP tag\n"); return AVERROR_INVALIDDATA; } while (bytestream2_get_bytes_left(&gb) > 0) { char chunk_str[5] = { 0 }; chunk_type = bytestream2_get_le32(&gb); chunk_size = bytestream2_get_le32(&gb); if (chunk_size == UINT32_MAX) return AVERROR_INVALIDDATA; chunk_size += chunk_size & 1; if (bytestream2_get_bytes_left(&gb) < chunk_size) return AVERROR_INVALIDDATA; switch (chunk_type) { case MKTAG('V', 'P', '8', ' '): if (!*got_frame) { ret = vp8_lossy_decode_frame(avctx, p, got_frame, avpkt->data + bytestream2_tell(&gb), chunk_size); if (ret < 0) return ret; } bytestream2_skip(&gb, chunk_size); break; case MKTAG('V', 'P', '8', 'L'): if (!*got_frame) { ret = vp8_lossless_decode_frame(avctx, p, got_frame, avpkt->data + bytestream2_tell(&gb), chunk_size, 0); if (ret < 0) return ret; } bytestream2_skip(&gb, chunk_size); break; case MKTAG('V', 'P', '8', 'X'): vp8x_flags = bytestream2_get_byte(&gb); bytestream2_skip(&gb, 3); s->width = bytestream2_get_le24(&gb) + 1; s->height = bytestream2_get_le24(&gb) + 1; ret = av_image_check_size(s->width, s->height, 0, avctx); if (ret < 0) return ret; break; case MKTAG('A', 'L', 'P', 'H'): { int alpha_header, filter_m, compression; if (!(vp8x_flags & VP8X_FLAG_ALPHA)) { av_log(avctx, AV_LOG_WARNING, "ALPHA chunk present, but alpha bit not set in the " "VP8X header\n"); } if (chunk_size == 0) { av_log(avctx, AV_LOG_ERROR, "invalid ALPHA chunk size\n"); return AVERROR_INVALIDDATA; } alpha_header = bytestream2_get_byte(&gb); s->alpha_data = avpkt->data + bytestream2_tell(&gb); s->alpha_data_size = chunk_size - 1; bytestream2_skip(&gb, s->alpha_data_size); filter_m = (alpha_header >> 2) & 0x03; compression = alpha_header & 0x03; if (compression > ALPHA_COMPRESSION_VP8L) { av_log(avctx, AV_LOG_VERBOSE, "skipping unsupported ALPHA chunk\n"); } else { s->has_alpha = 1; s->alpha_compression = compression; s->alpha_filter = filter_m; } break; } case MKTAG('I', 'C', 'C', 'P'): case MKTAG('A', 'N', 'I', 'M'): case MKTAG('A', 'N', 'M', 'F'): case MKTAG('E', 'X', 'I', 'F'): case MKTAG('X', 'M', 'P', ' '): AV_WL32(chunk_str, chunk_type); av_log(avctx, AV_LOG_VERBOSE, "skipping unsupported chunk: %s\n", chunk_str); bytestream2_skip(&gb, chunk_size); break; default: AV_WL32(chunk_str, chunk_type); av_log(avctx, AV_LOG_VERBOSE, "skipping unknown chunk: %s\n", chunk_str); bytestream2_skip(&gb, chunk_size); break; } } if (!*got_frame) { av_log(avctx, AV_LOG_ERROR, "image data not found\n"); return AVERROR_INVALIDDATA; } return avpkt->size; }
false
FFmpeg
76d4c62734fbb8a9f497712812f30ff5c27e787f
static int webp_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { AVFrame * const p = data; WebPContext *s = avctx->priv_data; GetByteContext gb; int ret; uint32_t chunk_type, chunk_size; int vp8x_flags = 0; s->avctx = avctx; s->width = 0; s->height = 0; *got_frame = 0; s->has_alpha = 0; bytestream2_init(&gb, avpkt->data, avpkt->size); if (bytestream2_get_bytes_left(&gb) < 12) return AVERROR_INVALIDDATA; if (bytestream2_get_le32(&gb) != MKTAG('R', 'I', 'F', 'F')) { av_log(avctx, AV_LOG_ERROR, "missing RIFF tag\n"); return AVERROR_INVALIDDATA; } chunk_size = bytestream2_get_le32(&gb); if (bytestream2_get_bytes_left(&gb) < chunk_size) return AVERROR_INVALIDDATA; if (bytestream2_get_le32(&gb) != MKTAG('W', 'E', 'B', 'P')) { av_log(avctx, AV_LOG_ERROR, "missing WEBP tag\n"); return AVERROR_INVALIDDATA; } while (bytestream2_get_bytes_left(&gb) > 0) { char chunk_str[5] = { 0 }; chunk_type = bytestream2_get_le32(&gb); chunk_size = bytestream2_get_le32(&gb); if (chunk_size == UINT32_MAX) return AVERROR_INVALIDDATA; chunk_size += chunk_size & 1; if (bytestream2_get_bytes_left(&gb) < chunk_size) return AVERROR_INVALIDDATA; switch (chunk_type) { case MKTAG('V', 'P', '8', ' '): if (!*got_frame) { ret = vp8_lossy_decode_frame(avctx, p, got_frame, avpkt->data + bytestream2_tell(&gb), chunk_size); if (ret < 0) return ret; } bytestream2_skip(&gb, chunk_size); break; case MKTAG('V', 'P', '8', 'L'): if (!*got_frame) { ret = vp8_lossless_decode_frame(avctx, p, got_frame, avpkt->data + bytestream2_tell(&gb), chunk_size, 0); if (ret < 0) return ret; } bytestream2_skip(&gb, chunk_size); break; case MKTAG('V', 'P', '8', 'X'): vp8x_flags = bytestream2_get_byte(&gb); bytestream2_skip(&gb, 3); s->width = bytestream2_get_le24(&gb) + 1; s->height = bytestream2_get_le24(&gb) + 1; ret = av_image_check_size(s->width, s->height, 0, avctx); if (ret < 0) return ret; break; case MKTAG('A', 'L', 'P', 'H'): { int alpha_header, filter_m, compression; if (!(vp8x_flags & VP8X_FLAG_ALPHA)) { av_log(avctx, AV_LOG_WARNING, "ALPHA chunk present, but alpha bit not set in the " "VP8X header\n"); } if (chunk_size == 0) { av_log(avctx, AV_LOG_ERROR, "invalid ALPHA chunk size\n"); return AVERROR_INVALIDDATA; } alpha_header = bytestream2_get_byte(&gb); s->alpha_data = avpkt->data + bytestream2_tell(&gb); s->alpha_data_size = chunk_size - 1; bytestream2_skip(&gb, s->alpha_data_size); filter_m = (alpha_header >> 2) & 0x03; compression = alpha_header & 0x03; if (compression > ALPHA_COMPRESSION_VP8L) { av_log(avctx, AV_LOG_VERBOSE, "skipping unsupported ALPHA chunk\n"); } else { s->has_alpha = 1; s->alpha_compression = compression; s->alpha_filter = filter_m; } break; } case MKTAG('I', 'C', 'C', 'P'): case MKTAG('A', 'N', 'I', 'M'): case MKTAG('A', 'N', 'M', 'F'): case MKTAG('E', 'X', 'I', 'F'): case MKTAG('X', 'M', 'P', ' '): AV_WL32(chunk_str, chunk_type); av_log(avctx, AV_LOG_VERBOSE, "skipping unsupported chunk: %s\n", chunk_str); bytestream2_skip(&gb, chunk_size); break; default: AV_WL32(chunk_str, chunk_type); av_log(avctx, AV_LOG_VERBOSE, "skipping unknown chunk: %s\n", chunk_str); bytestream2_skip(&gb, chunk_size); break; } } if (!*got_frame) { av_log(avctx, AV_LOG_ERROR, "image data not found\n"); return AVERROR_INVALIDDATA; } return avpkt->size; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, AVPacket *VAR_3) { AVFrame * const p = VAR_1; WebPContext *s = VAR_0->priv_data; GetByteContext gb; int VAR_4; uint32_t chunk_type, chunk_size; int VAR_5 = 0; s->VAR_0 = VAR_0; s->width = 0; s->height = 0; *VAR_2 = 0; s->has_alpha = 0; bytestream2_init(&gb, VAR_3->VAR_1, VAR_3->size); if (bytestream2_get_bytes_left(&gb) < 12) return AVERROR_INVALIDDATA; if (bytestream2_get_le32(&gb) != MKTAG('R', 'I', 'F', 'F')) { av_log(VAR_0, AV_LOG_ERROR, "missing RIFF tag\n"); return AVERROR_INVALIDDATA; } chunk_size = bytestream2_get_le32(&gb); if (bytestream2_get_bytes_left(&gb) < chunk_size) return AVERROR_INVALIDDATA; if (bytestream2_get_le32(&gb) != MKTAG('W', 'E', 'B', 'P')) { av_log(VAR_0, AV_LOG_ERROR, "missing WEBP tag\n"); return AVERROR_INVALIDDATA; } while (bytestream2_get_bytes_left(&gb) > 0) { char VAR_6[5] = { 0 }; chunk_type = bytestream2_get_le32(&gb); chunk_size = bytestream2_get_le32(&gb); if (chunk_size == UINT32_MAX) return AVERROR_INVALIDDATA; chunk_size += chunk_size & 1; if (bytestream2_get_bytes_left(&gb) < chunk_size) return AVERROR_INVALIDDATA; switch (chunk_type) { case MKTAG('V', 'P', '8', ' '): if (!*VAR_2) { VAR_4 = vp8_lossy_decode_frame(VAR_0, p, VAR_2, VAR_3->VAR_1 + bytestream2_tell(&gb), chunk_size); if (VAR_4 < 0) return VAR_4; } bytestream2_skip(&gb, chunk_size); break; case MKTAG('V', 'P', '8', 'L'): if (!*VAR_2) { VAR_4 = vp8_lossless_decode_frame(VAR_0, p, VAR_2, VAR_3->VAR_1 + bytestream2_tell(&gb), chunk_size, 0); if (VAR_4 < 0) return VAR_4; } bytestream2_skip(&gb, chunk_size); break; case MKTAG('V', 'P', '8', 'X'): VAR_5 = bytestream2_get_byte(&gb); bytestream2_skip(&gb, 3); s->width = bytestream2_get_le24(&gb) + 1; s->height = bytestream2_get_le24(&gb) + 1; VAR_4 = av_image_check_size(s->width, s->height, 0, VAR_0); if (VAR_4 < 0) return VAR_4; break; case MKTAG('A', 'L', 'P', 'H'): { int VAR_7, VAR_8, VAR_9; if (!(VAR_5 & VP8X_FLAG_ALPHA)) { av_log(VAR_0, AV_LOG_WARNING, "ALPHA chunk present, but alpha bit not set in the " "VP8X header\n"); } if (chunk_size == 0) { av_log(VAR_0, AV_LOG_ERROR, "invalid ALPHA chunk size\n"); return AVERROR_INVALIDDATA; } VAR_7 = bytestream2_get_byte(&gb); s->alpha_data = VAR_3->VAR_1 + bytestream2_tell(&gb); s->alpha_data_size = chunk_size - 1; bytestream2_skip(&gb, s->alpha_data_size); VAR_8 = (VAR_7 >> 2) & 0x03; VAR_9 = VAR_7 & 0x03; if (VAR_9 > ALPHA_COMPRESSION_VP8L) { av_log(VAR_0, AV_LOG_VERBOSE, "skipping unsupported ALPHA chunk\n"); } else { s->has_alpha = 1; s->alpha_compression = VAR_9; s->alpha_filter = VAR_8; } break; } case MKTAG('I', 'C', 'C', 'P'): case MKTAG('A', 'N', 'I', 'M'): case MKTAG('A', 'N', 'M', 'F'): case MKTAG('E', 'X', 'I', 'F'): case MKTAG('X', 'M', 'P', ' '): AV_WL32(VAR_6, chunk_type); av_log(VAR_0, AV_LOG_VERBOSE, "skipping unsupported chunk: %s\n", VAR_6); bytestream2_skip(&gb, chunk_size); break; default: AV_WL32(VAR_6, chunk_type); av_log(VAR_0, AV_LOG_VERBOSE, "skipping unknown chunk: %s\n", VAR_6); bytestream2_skip(&gb, chunk_size); break; } } if (!*VAR_2) { av_log(VAR_0, AV_LOG_ERROR, "image VAR_1 not found\n"); return AVERROR_INVALIDDATA; } return VAR_3->size; }
[ "static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{", "AVFrame * const p = VAR_1;", "WebPContext *s = VAR_0->priv_data;", "GetByteContext gb;", "int VAR_4;", "uint32_t chunk_type, chunk_size;", "int VAR_5 = 0;", "s->VAR_0 = VAR_0;", "s->width = 0;", "s->height = 0;", "*VAR_2 = 0;", "s->has_alpha = 0;", "bytestream2_init(&gb, VAR_3->VAR_1, VAR_3->size);", "if (bytestream2_get_bytes_left(&gb) < 12)\nreturn AVERROR_INVALIDDATA;", "if (bytestream2_get_le32(&gb) != MKTAG('R', 'I', 'F', 'F')) {", "av_log(VAR_0, AV_LOG_ERROR, \"missing RIFF tag\\n\");", "return AVERROR_INVALIDDATA;", "}", "chunk_size = bytestream2_get_le32(&gb);", "if (bytestream2_get_bytes_left(&gb) < chunk_size)\nreturn AVERROR_INVALIDDATA;", "if (bytestream2_get_le32(&gb) != MKTAG('W', 'E', 'B', 'P')) {", "av_log(VAR_0, AV_LOG_ERROR, \"missing WEBP tag\\n\");", "return AVERROR_INVALIDDATA;", "}", "while (bytestream2_get_bytes_left(&gb) > 0) {", "char VAR_6[5] = { 0 };", "chunk_type = bytestream2_get_le32(&gb);", "chunk_size = bytestream2_get_le32(&gb);", "if (chunk_size == UINT32_MAX)\nreturn AVERROR_INVALIDDATA;", "chunk_size += chunk_size & 1;", "if (bytestream2_get_bytes_left(&gb) < chunk_size)\nreturn AVERROR_INVALIDDATA;", "switch (chunk_type) {", "case MKTAG('V', 'P', '8', ' '):\nif (!*VAR_2) {", "VAR_4 = vp8_lossy_decode_frame(VAR_0, p, VAR_2,\nVAR_3->VAR_1 + bytestream2_tell(&gb),\nchunk_size);", "if (VAR_4 < 0)\nreturn VAR_4;", "}", "bytestream2_skip(&gb, chunk_size);", "break;", "case MKTAG('V', 'P', '8', 'L'):\nif (!*VAR_2) {", "VAR_4 = vp8_lossless_decode_frame(VAR_0, p, VAR_2,\nVAR_3->VAR_1 + bytestream2_tell(&gb),\nchunk_size, 0);", "if (VAR_4 < 0)\nreturn VAR_4;", "}", "bytestream2_skip(&gb, chunk_size);", "break;", "case MKTAG('V', 'P', '8', 'X'):\nVAR_5 = bytestream2_get_byte(&gb);", "bytestream2_skip(&gb, 3);", "s->width = bytestream2_get_le24(&gb) + 1;", "s->height = bytestream2_get_le24(&gb) + 1;", "VAR_4 = av_image_check_size(s->width, s->height, 0, VAR_0);", "if (VAR_4 < 0)\nreturn VAR_4;", "break;", "case MKTAG('A', 'L', 'P', 'H'): {", "int VAR_7, VAR_8, VAR_9;", "if (!(VAR_5 & VP8X_FLAG_ALPHA)) {", "av_log(VAR_0, AV_LOG_WARNING,\n\"ALPHA chunk present, but alpha bit not set in the \"\n\"VP8X header\\n\");", "}", "if (chunk_size == 0) {", "av_log(VAR_0, AV_LOG_ERROR, \"invalid ALPHA chunk size\\n\");", "return AVERROR_INVALIDDATA;", "}", "VAR_7 = bytestream2_get_byte(&gb);", "s->alpha_data = VAR_3->VAR_1 + bytestream2_tell(&gb);", "s->alpha_data_size = chunk_size - 1;", "bytestream2_skip(&gb, s->alpha_data_size);", "VAR_8 = (VAR_7 >> 2) & 0x03;", "VAR_9 = VAR_7 & 0x03;", "if (VAR_9 > ALPHA_COMPRESSION_VP8L) {", "av_log(VAR_0, AV_LOG_VERBOSE,\n\"skipping unsupported ALPHA chunk\\n\");", "} else {", "s->has_alpha = 1;", "s->alpha_compression = VAR_9;", "s->alpha_filter = VAR_8;", "}", "break;", "}", "case MKTAG('I', 'C', 'C', 'P'):\ncase MKTAG('A', 'N', 'I', 'M'):\ncase MKTAG('A', 'N', 'M', 'F'):\ncase MKTAG('E', 'X', 'I', 'F'):\ncase MKTAG('X', 'M', 'P', ' '):\nAV_WL32(VAR_6, chunk_type);", "av_log(VAR_0, AV_LOG_VERBOSE, \"skipping unsupported chunk: %s\\n\",\nVAR_6);", "bytestream2_skip(&gb, chunk_size);", "break;", "default:\nAV_WL32(VAR_6, chunk_type);", "av_log(VAR_0, AV_LOG_VERBOSE, \"skipping unknown chunk: %s\\n\",\nVAR_6);", "bytestream2_skip(&gb, chunk_size);", "break;", "}", "}", "if (!*VAR_2) {", "av_log(VAR_0, AV_LOG_ERROR, \"image VAR_1 not found\\n\");", "return AVERROR_INVALIDDATA;", "}", "return VAR_3->size;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35, 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53, 55 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 79, 81 ], [ 83 ], [ 87, 89 ], [ 93 ], [ 95, 97 ], [ 99, 101, 103 ], [ 105, 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115, 117 ], [ 119, 121, 123 ], [ 125, 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135, 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147, 149 ], [ 151 ], [ 153 ], [ 155 ], [ 159 ], [ 161, 163, 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 187 ], [ 189 ], [ 193 ], [ 195, 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 211 ], [ 213 ], [ 215, 217, 219, 221, 223, 225 ], [ 227, 229 ], [ 231 ], [ 233 ], [ 235, 237 ], [ 239, 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 263 ], [ 265 ] ]
12,487
static int find_hw_breakpoint(target_ulong addr, int len, int type) { int n; for (n = 0; n < nb_hw_breakpoint; n++) if (hw_breakpoint[n].addr == addr && hw_breakpoint[n].type == type && (hw_breakpoint[n].len == len || len == -1)) return n; return -1; }
false
qemu
b9bec74bcb16519a876ec21cd5277c526a9b512d
static int find_hw_breakpoint(target_ulong addr, int len, int type) { int n; for (n = 0; n < nb_hw_breakpoint; n++) if (hw_breakpoint[n].addr == addr && hw_breakpoint[n].type == type && (hw_breakpoint[n].len == len || len == -1)) return n; return -1; }
{ "code": [], "line_no": [] }
static int FUNC_0(target_ulong VAR_0, int VAR_1, int VAR_2) { int VAR_3; for (VAR_3 = 0; VAR_3 < nb_hw_breakpoint; VAR_3++) if (hw_breakpoint[VAR_3].VAR_0 == VAR_0 && hw_breakpoint[VAR_3].VAR_2 == VAR_2 && (hw_breakpoint[VAR_3].VAR_1 == VAR_1 || VAR_1 == -1)) return VAR_3; return -1; }
[ "static int FUNC_0(target_ulong VAR_0, int VAR_1, int VAR_2)\n{", "int VAR_3;", "for (VAR_3 = 0; VAR_3 < nb_hw_breakpoint; VAR_3++)", "if (hw_breakpoint[VAR_3].VAR_0 == VAR_0 && hw_breakpoint[VAR_3].VAR_2 == VAR_2 &&\n(hw_breakpoint[VAR_3].VAR_1 == VAR_1 || VAR_1 == -1))\nreturn VAR_3;", "return -1;", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11, 13, 15 ], [ 17 ], [ 19 ] ]
12,488
static void qobject_input_start_struct(Visitor *v, const char *name, void **obj, size_t size, Error **errp) { QObjectInputVisitor *qiv = to_qiv(v); QObject *qobj = qobject_input_get_object(qiv, name, true, errp); if (obj) { *obj = NULL; } if (!qobj) { return; } if (qobject_type(qobj) != QTYPE_QDICT) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null", "QDict"); return; } qobject_input_push(qiv, qobj, obj); if (obj) { *obj = g_malloc0(size); } }
true
qemu
a9fc37f6bc3f2ab90585cb16493da9f6dcfbfbcf
static void qobject_input_start_struct(Visitor *v, const char *name, void **obj, size_t size, Error **errp) { QObjectInputVisitor *qiv = to_qiv(v); QObject *qobj = qobject_input_get_object(qiv, name, true, errp); if (obj) { *obj = NULL; } if (!qobj) { return; } if (qobject_type(qobj) != QTYPE_QDICT) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null", "QDict"); return; } qobject_input_push(qiv, qobj, obj); if (obj) { *obj = g_malloc0(size); } }
{ "code": [ " error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",", " \"QDict\");", " qobject_input_push(qiv, qobj, obj);", " error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",", " error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",", " error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",", " error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",", " error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",", " error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\"," ], "line_no": [ 27, 29, 37, 27, 27, 27, 27, 27, 27 ] }
static void FUNC_0(Visitor *VAR_0, const char *VAR_1, void **VAR_2, size_t VAR_3, Error **VAR_4) { QObjectInputVisitor *qiv = to_qiv(VAR_0); QObject *qobj = qobject_input_get_object(qiv, VAR_1, true, VAR_4); if (VAR_2) { *VAR_2 = NULL; } if (!qobj) { return; } if (qobject_type(qobj) != QTYPE_QDICT) { error_setg(VAR_4, QERR_INVALID_PARAMETER_TYPE, VAR_1 ? VAR_1 : "null", "QDict"); return; } qobject_input_push(qiv, qobj, VAR_2); if (VAR_2) { *VAR_2 = g_malloc0(VAR_3); } }
[ "static void FUNC_0(Visitor *VAR_0, const char *VAR_1, void **VAR_2,\nsize_t VAR_3, Error **VAR_4)\n{", "QObjectInputVisitor *qiv = to_qiv(VAR_0);", "QObject *qobj = qobject_input_get_object(qiv, VAR_1, true, VAR_4);", "if (VAR_2) {", "*VAR_2 = NULL;", "}", "if (!qobj) {", "return;", "}", "if (qobject_type(qobj) != QTYPE_QDICT) {", "error_setg(VAR_4, QERR_INVALID_PARAMETER_TYPE, VAR_1 ? VAR_1 : \"null\",\n\"QDict\");", "return;", "}", "qobject_input_push(qiv, qobj, VAR_2);", "if (VAR_2) {", "*VAR_2 = g_malloc0(VAR_3);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27, 29 ], [ 31 ], [ 33 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ] ]
12,489
static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length) { int i, consumed, ret = 0; s->ref = NULL; s->last_eos = s->eos; s->eos = 0; /* split the input packet into NAL units, so we know the upper bound on the * number of slices in the frame */ s->nb_nals = 0; while (length >= 4) { HEVCNAL *nal; int extract_length = 0; if (s->is_nalff) { int i; for (i = 0; i < s->nal_length_size; i++) extract_length = (extract_length << 8) | buf[i]; buf += s->nal_length_size; length -= s->nal_length_size; if (extract_length > length) { av_log(s->avctx, AV_LOG_ERROR, "Invalid NAL unit size.\n"); ret = AVERROR_INVALIDDATA; } } else { /* search start code */ while (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) { ++buf; --length; if (length < 4) { av_log(s->avctx, AV_LOG_ERROR, "No start code is found.\n"); ret = AVERROR_INVALIDDATA; } } buf += 3; length -= 3; } if (!s->is_nalff) extract_length = length; if (s->nals_allocated < s->nb_nals + 1) { int new_size = s->nals_allocated + 1; void *tmp = av_realloc_array(s->nals, new_size, sizeof(*s->nals)); ret = AVERROR(ENOMEM); if (!tmp) { } s->nals = tmp; memset(s->nals + s->nals_allocated, 0, (new_size - s->nals_allocated) * sizeof(*s->nals)); tmp = av_realloc_array(s->skipped_bytes_nal, new_size, sizeof(*s->skipped_bytes_nal)); if (!tmp) s->skipped_bytes_nal = tmp; tmp = av_realloc_array(s->skipped_bytes_pos_size_nal, new_size, sizeof(*s->skipped_bytes_pos_size_nal)); if (!tmp) s->skipped_bytes_pos_size_nal = tmp; tmp = av_realloc_array(s->skipped_bytes_pos_nal, new_size, sizeof(*s->skipped_bytes_pos_nal)); if (!tmp) s->skipped_bytes_pos_nal = tmp; s->skipped_bytes_pos_size_nal[s->nals_allocated] = 1024; // initial buffer size s->skipped_bytes_pos_nal[s->nals_allocated] = av_malloc_array(s->skipped_bytes_pos_size_nal[s->nals_allocated], sizeof(*s->skipped_bytes_pos)); s->nals_allocated = new_size; } s->skipped_bytes_pos_size = s->skipped_bytes_pos_size_nal[s->nb_nals]; s->skipped_bytes_pos = s->skipped_bytes_pos_nal[s->nb_nals]; nal = &s->nals[s->nb_nals]; consumed = ff_hevc_extract_rbsp(s, buf, extract_length, nal); s->skipped_bytes_nal[s->nb_nals] = s->skipped_bytes; s->skipped_bytes_pos_size_nal[s->nb_nals] = s->skipped_bytes_pos_size; s->skipped_bytes_pos_nal[s->nb_nals++] = s->skipped_bytes_pos; if (consumed < 0) { ret = consumed; } ret = init_get_bits8(&s->HEVClc->gb, nal->data, nal->size); if (ret < 0) hls_nal_unit(s); if (s->nal_unit_type == NAL_EOB_NUT || s->nal_unit_type == NAL_EOS_NUT) s->eos = 1; buf += consumed; length -= consumed; } /* parse the NAL units */ for (i = 0; i < s->nb_nals; i++) { int ret; s->skipped_bytes = s->skipped_bytes_nal[i]; s->skipped_bytes_pos = s->skipped_bytes_pos_nal[i]; ret = decode_nal_unit(s, &s->nals[i]); if (ret < 0) { av_log(s->avctx, AV_LOG_WARNING, "Error parsing NAL unit #%d.\n", i); } } fail: if (s->ref && s->threads_type == FF_THREAD_FRAME) ff_thread_report_progress(&s->ref->tf, INT_MAX, 0); return ret; }
true
FFmpeg
2b215b7f5af0ef9be79c697d8990e6958a134f98
static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length) { int i, consumed, ret = 0; s->ref = NULL; s->last_eos = s->eos; s->eos = 0; s->nb_nals = 0; while (length >= 4) { HEVCNAL *nal; int extract_length = 0; if (s->is_nalff) { int i; for (i = 0; i < s->nal_length_size; i++) extract_length = (extract_length << 8) | buf[i]; buf += s->nal_length_size; length -= s->nal_length_size; if (extract_length > length) { av_log(s->avctx, AV_LOG_ERROR, "Invalid NAL unit size.\n"); ret = AVERROR_INVALIDDATA; } } else { while (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) { ++buf; --length; if (length < 4) { av_log(s->avctx, AV_LOG_ERROR, "No start code is found.\n"); ret = AVERROR_INVALIDDATA; } } buf += 3; length -= 3; } if (!s->is_nalff) extract_length = length; if (s->nals_allocated < s->nb_nals + 1) { int new_size = s->nals_allocated + 1; void *tmp = av_realloc_array(s->nals, new_size, sizeof(*s->nals)); ret = AVERROR(ENOMEM); if (!tmp) { } s->nals = tmp; memset(s->nals + s->nals_allocated, 0, (new_size - s->nals_allocated) * sizeof(*s->nals)); tmp = av_realloc_array(s->skipped_bytes_nal, new_size, sizeof(*s->skipped_bytes_nal)); if (!tmp) s->skipped_bytes_nal = tmp; tmp = av_realloc_array(s->skipped_bytes_pos_size_nal, new_size, sizeof(*s->skipped_bytes_pos_size_nal)); if (!tmp) s->skipped_bytes_pos_size_nal = tmp; tmp = av_realloc_array(s->skipped_bytes_pos_nal, new_size, sizeof(*s->skipped_bytes_pos_nal)); if (!tmp) s->skipped_bytes_pos_nal = tmp; s->skipped_bytes_pos_size_nal[s->nals_allocated] = 1024; s->skipped_bytes_pos_nal[s->nals_allocated] = av_malloc_array(s->skipped_bytes_pos_size_nal[s->nals_allocated], sizeof(*s->skipped_bytes_pos)); s->nals_allocated = new_size; } s->skipped_bytes_pos_size = s->skipped_bytes_pos_size_nal[s->nb_nals]; s->skipped_bytes_pos = s->skipped_bytes_pos_nal[s->nb_nals]; nal = &s->nals[s->nb_nals]; consumed = ff_hevc_extract_rbsp(s, buf, extract_length, nal); s->skipped_bytes_nal[s->nb_nals] = s->skipped_bytes; s->skipped_bytes_pos_size_nal[s->nb_nals] = s->skipped_bytes_pos_size; s->skipped_bytes_pos_nal[s->nb_nals++] = s->skipped_bytes_pos; if (consumed < 0) { ret = consumed; } ret = init_get_bits8(&s->HEVClc->gb, nal->data, nal->size); if (ret < 0) hls_nal_unit(s); if (s->nal_unit_type == NAL_EOB_NUT || s->nal_unit_type == NAL_EOS_NUT) s->eos = 1; buf += consumed; length -= consumed; } for (i = 0; i < s->nb_nals; i++) { int ret; s->skipped_bytes = s->skipped_bytes_nal[i]; s->skipped_bytes_pos = s->skipped_bytes_pos_nal[i]; ret = decode_nal_unit(s, &s->nals[i]); if (ret < 0) { av_log(s->avctx, AV_LOG_WARNING, "Error parsing NAL unit #%d.\n", i); } } fail: if (s->ref && s->threads_type == FF_THREAD_FRAME) ff_thread_report_progress(&s->ref->tf, INT_MAX, 0); return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(HEVCContext *VAR_0, const uint8_t *VAR_1, int VAR_2) { int VAR_7, VAR_4, VAR_5 = 0; VAR_0->ref = NULL; VAR_0->last_eos = VAR_0->eos; VAR_0->eos = 0; VAR_0->nb_nals = 0; while (VAR_2 >= 4) { HEVCNAL *nal; int VAR_6 = 0; if (VAR_0->is_nalff) { int VAR_7; for (VAR_7 = 0; VAR_7 < VAR_0->nal_length_size; VAR_7++) VAR_6 = (VAR_6 << 8) | VAR_1[VAR_7]; VAR_1 += VAR_0->nal_length_size; VAR_2 -= VAR_0->nal_length_size; if (VAR_6 > VAR_2) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid NAL unit size.\n"); VAR_5 = AVERROR_INVALIDDATA; } } else { while (VAR_1[0] != 0 || VAR_1[1] != 0 || VAR_1[2] != 1) { ++VAR_1; --VAR_2; if (VAR_2 < 4) { av_log(VAR_0->avctx, AV_LOG_ERROR, "No start code is found.\n"); VAR_5 = AVERROR_INVALIDDATA; } } VAR_1 += 3; VAR_2 -= 3; } if (!VAR_0->is_nalff) VAR_6 = VAR_2; if (VAR_0->nals_allocated < VAR_0->nb_nals + 1) { int VAR_7 = VAR_0->nals_allocated + 1; void *VAR_8 = av_realloc_array(VAR_0->nals, VAR_7, sizeof(*VAR_0->nals)); VAR_5 = AVERROR(ENOMEM); if (!VAR_8) { } VAR_0->nals = VAR_8; memset(VAR_0->nals + VAR_0->nals_allocated, 0, (VAR_7 - VAR_0->nals_allocated) * sizeof(*VAR_0->nals)); VAR_8 = av_realloc_array(VAR_0->skipped_bytes_nal, VAR_7, sizeof(*VAR_0->skipped_bytes_nal)); if (!VAR_8) VAR_0->skipped_bytes_nal = VAR_8; VAR_8 = av_realloc_array(VAR_0->skipped_bytes_pos_size_nal, VAR_7, sizeof(*VAR_0->skipped_bytes_pos_size_nal)); if (!VAR_8) VAR_0->skipped_bytes_pos_size_nal = VAR_8; VAR_8 = av_realloc_array(VAR_0->skipped_bytes_pos_nal, VAR_7, sizeof(*VAR_0->skipped_bytes_pos_nal)); if (!VAR_8) VAR_0->skipped_bytes_pos_nal = VAR_8; VAR_0->skipped_bytes_pos_size_nal[VAR_0->nals_allocated] = 1024; VAR_0->skipped_bytes_pos_nal[VAR_0->nals_allocated] = av_malloc_array(VAR_0->skipped_bytes_pos_size_nal[VAR_0->nals_allocated], sizeof(*VAR_0->skipped_bytes_pos)); VAR_0->nals_allocated = VAR_7; } VAR_0->skipped_bytes_pos_size = VAR_0->skipped_bytes_pos_size_nal[VAR_0->nb_nals]; VAR_0->skipped_bytes_pos = VAR_0->skipped_bytes_pos_nal[VAR_0->nb_nals]; nal = &VAR_0->nals[VAR_0->nb_nals]; VAR_4 = ff_hevc_extract_rbsp(VAR_0, VAR_1, VAR_6, nal); VAR_0->skipped_bytes_nal[VAR_0->nb_nals] = VAR_0->skipped_bytes; VAR_0->skipped_bytes_pos_size_nal[VAR_0->nb_nals] = VAR_0->skipped_bytes_pos_size; VAR_0->skipped_bytes_pos_nal[VAR_0->nb_nals++] = VAR_0->skipped_bytes_pos; if (VAR_4 < 0) { VAR_5 = VAR_4; } VAR_5 = init_get_bits8(&VAR_0->HEVClc->gb, nal->data, nal->size); if (VAR_5 < 0) hls_nal_unit(VAR_0); if (VAR_0->nal_unit_type == NAL_EOB_NUT || VAR_0->nal_unit_type == NAL_EOS_NUT) VAR_0->eos = 1; VAR_1 += VAR_4; VAR_2 -= VAR_4; } for (VAR_7 = 0; VAR_7 < VAR_0->nb_nals; VAR_7++) { int VAR_5; VAR_0->skipped_bytes = VAR_0->skipped_bytes_nal[VAR_7]; VAR_0->skipped_bytes_pos = VAR_0->skipped_bytes_pos_nal[VAR_7]; VAR_5 = decode_nal_unit(VAR_0, &VAR_0->nals[VAR_7]); if (VAR_5 < 0) { av_log(VAR_0->avctx, AV_LOG_WARNING, "Error parsing NAL unit #%d.\n", VAR_7); } } fail: if (VAR_0->ref && VAR_0->threads_type == FF_THREAD_FRAME) ff_thread_report_progress(&VAR_0->ref->tf, INT_MAX, 0); return VAR_5; }
[ "static int FUNC_0(HEVCContext *VAR_0, const uint8_t *VAR_1, int VAR_2)\n{", "int VAR_7, VAR_4, VAR_5 = 0;", "VAR_0->ref = NULL;", "VAR_0->last_eos = VAR_0->eos;", "VAR_0->eos = 0;", "VAR_0->nb_nals = 0;", "while (VAR_2 >= 4) {", "HEVCNAL *nal;", "int VAR_6 = 0;", "if (VAR_0->is_nalff) {", "int VAR_7;", "for (VAR_7 = 0; VAR_7 < VAR_0->nal_length_size; VAR_7++)", "VAR_6 = (VAR_6 << 8) | VAR_1[VAR_7];", "VAR_1 += VAR_0->nal_length_size;", "VAR_2 -= VAR_0->nal_length_size;", "if (VAR_6 > VAR_2) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid NAL unit size.\\n\");", "VAR_5 = AVERROR_INVALIDDATA;", "}", "} else {", "while (VAR_1[0] != 0 || VAR_1[1] != 0 || VAR_1[2] != 1) {", "++VAR_1;", "--VAR_2;", "if (VAR_2 < 4) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"No start code is found.\\n\");", "VAR_5 = AVERROR_INVALIDDATA;", "}", "}", "VAR_1 += 3;", "VAR_2 -= 3;", "}", "if (!VAR_0->is_nalff)\nVAR_6 = VAR_2;", "if (VAR_0->nals_allocated < VAR_0->nb_nals + 1) {", "int VAR_7 = VAR_0->nals_allocated + 1;", "void *VAR_8 = av_realloc_array(VAR_0->nals, VAR_7, sizeof(*VAR_0->nals));", "VAR_5 = AVERROR(ENOMEM);", "if (!VAR_8) {", "}", "VAR_0->nals = VAR_8;", "memset(VAR_0->nals + VAR_0->nals_allocated, 0,\n(VAR_7 - VAR_0->nals_allocated) * sizeof(*VAR_0->nals));", "VAR_8 = av_realloc_array(VAR_0->skipped_bytes_nal, VAR_7, sizeof(*VAR_0->skipped_bytes_nal));", "if (!VAR_8)\nVAR_0->skipped_bytes_nal = VAR_8;", "VAR_8 = av_realloc_array(VAR_0->skipped_bytes_pos_size_nal, VAR_7, sizeof(*VAR_0->skipped_bytes_pos_size_nal));", "if (!VAR_8)\nVAR_0->skipped_bytes_pos_size_nal = VAR_8;", "VAR_8 = av_realloc_array(VAR_0->skipped_bytes_pos_nal, VAR_7, sizeof(*VAR_0->skipped_bytes_pos_nal));", "if (!VAR_8)\nVAR_0->skipped_bytes_pos_nal = VAR_8;", "VAR_0->skipped_bytes_pos_size_nal[VAR_0->nals_allocated] = 1024;", "VAR_0->skipped_bytes_pos_nal[VAR_0->nals_allocated] = av_malloc_array(VAR_0->skipped_bytes_pos_size_nal[VAR_0->nals_allocated], sizeof(*VAR_0->skipped_bytes_pos));", "VAR_0->nals_allocated = VAR_7;", "}", "VAR_0->skipped_bytes_pos_size = VAR_0->skipped_bytes_pos_size_nal[VAR_0->nb_nals];", "VAR_0->skipped_bytes_pos = VAR_0->skipped_bytes_pos_nal[VAR_0->nb_nals];", "nal = &VAR_0->nals[VAR_0->nb_nals];", "VAR_4 = ff_hevc_extract_rbsp(VAR_0, VAR_1, VAR_6, nal);", "VAR_0->skipped_bytes_nal[VAR_0->nb_nals] = VAR_0->skipped_bytes;", "VAR_0->skipped_bytes_pos_size_nal[VAR_0->nb_nals] = VAR_0->skipped_bytes_pos_size;", "VAR_0->skipped_bytes_pos_nal[VAR_0->nb_nals++] = VAR_0->skipped_bytes_pos;", "if (VAR_4 < 0) {", "VAR_5 = VAR_4;", "}", "VAR_5 = init_get_bits8(&VAR_0->HEVClc->gb, nal->data, nal->size);", "if (VAR_5 < 0)\nhls_nal_unit(VAR_0);", "if (VAR_0->nal_unit_type == NAL_EOB_NUT ||\nVAR_0->nal_unit_type == NAL_EOS_NUT)\nVAR_0->eos = 1;", "VAR_1 += VAR_4;", "VAR_2 -= VAR_4;", "}", "for (VAR_7 = 0; VAR_7 < VAR_0->nb_nals; VAR_7++) {", "int VAR_5;", "VAR_0->skipped_bytes = VAR_0->skipped_bytes_nal[VAR_7];", "VAR_0->skipped_bytes_pos = VAR_0->skipped_bytes_pos_nal[VAR_7];", "VAR_5 = decode_nal_unit(VAR_0, &VAR_0->nals[VAR_7]);", "if (VAR_5 < 0) {", "av_log(VAR_0->avctx, AV_LOG_WARNING,\n\"Error parsing NAL unit #%d.\\n\", VAR_7);", "}", "}", "fail:\nif (VAR_0->ref && VAR_0->threads_type == FF_THREAD_FRAME)\nff_thread_report_progress(&VAR_0->ref->tf, INT_MAX, 0);", "return VAR_5;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 52 ], [ 54 ], [ 58 ], [ 60 ], [ 62 ], [ 64 ], [ 66 ], [ 68 ], [ 71 ], [ 73 ], [ 77 ], [ 79 ], [ 81 ], [ 85, 87 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 102 ], [ 104 ], [ 106, 108 ], [ 112 ], [ 114, 117 ], [ 121 ], [ 123, 126 ], [ 130 ], [ 132, 135 ], [ 139 ], [ 141 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 157 ], [ 161 ], [ 163 ], [ 165 ], [ 171 ], [ 173 ], [ 176 ], [ 180 ], [ 182, 185 ], [ 189, 191, 193 ], [ 197 ], [ 199 ], [ 201 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 217 ], [ 219 ], [ 221, 223 ], [ 226 ], [ 228 ], [ 232, 234, 236 ], [ 240 ], [ 242 ] ]
12,490
static uint64_t vfio_rom_read(void *opaque, hwaddr addr, unsigned size) { VFIODevice *vdev = opaque; uint64_t val = ((uint64_t)1 << (size * 8)) - 1; /* Load the ROM lazily when the guest tries to read it */ if (unlikely(!vdev->rom)) { memcpy(&val, vdev->rom + addr, (addr < vdev->rom_size) ? MIN(size, vdev->rom_size - addr) : 0); DPRINTF("%s(%04x:%02x:%02x.%x, 0x%"HWADDR_PRIx", 0x%x) = 0x%"PRIx64"\n", __func__, vdev->host.domain, vdev->host.bus, vdev->host.slot, vdev->host.function, addr, size, val); return val;
true
qemu
e638073c569e801ce9def2016a84f955cbbca779
static uint64_t vfio_rom_read(void *opaque, hwaddr addr, unsigned size) { VFIODevice *vdev = opaque; uint64_t val = ((uint64_t)1 << (size * 8)) - 1; if (unlikely(!vdev->rom)) { memcpy(&val, vdev->rom + addr, (addr < vdev->rom_size) ? MIN(size, vdev->rom_size - addr) : 0); DPRINTF("%s(%04x:%02x:%02x.%x, 0x%"HWADDR_PRIx", 0x%x) = 0x%"PRIx64"\n", __func__, vdev->host.domain, vdev->host.bus, vdev->host.slot, vdev->host.function, addr, size, val); return val;
{ "code": [], "line_no": [] }
static uint64_t FUNC_0(void *opaque, hwaddr addr, unsigned size) { VFIODevice *vdev = opaque; uint64_t val = ((uint64_t)1 << (size * 8)) - 1; if (unlikely(!vdev->rom)) { memcpy(&val, vdev->rom + addr, (addr < vdev->rom_size) ? MIN(size, vdev->rom_size - addr) : 0); DPRINTF("%s(%04x:%02x:%02x.%x, 0x%"HWADDR_PRIx", 0x%x) = 0x%"PRIx64"\n", __func__, vdev->host.domain, vdev->host.bus, vdev->host.slot, vdev->host.function, addr, size, val); return val;
[ "static uint64_t FUNC_0(void *opaque, hwaddr addr, unsigned size)\n{", "VFIODevice *vdev = opaque;", "uint64_t val = ((uint64_t)1 << (size * 8)) - 1;", "if (unlikely(!vdev->rom)) {", "memcpy(&val, vdev->rom + addr,\n(addr < vdev->rom_size) ? MIN(size, vdev->rom_size - addr) : 0);", "DPRINTF(\"%s(%04x:%02x:%02x.%x, 0x%\"HWADDR_PRIx\", 0x%x) = 0x%\"PRIx64\"\\n\",\n__func__, vdev->host.domain, vdev->host.bus, vdev->host.slot,\nvdev->host.function, addr, size, val);", "return val;" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 13 ], [ 22, 24 ], [ 28, 30, 32 ], [ 36 ] ]
12,491
static void vtd_handle_gcmd_qie(IntelIOMMUState *s, bool en) { uint64_t iqa_val = vtd_get_quad_raw(s, DMAR_IQA_REG); trace_vtd_inv_qi_enable(en); if (en) { if (vtd_queued_inv_enable_check(s)) { s->iq = iqa_val & VTD_IQA_IQA_MASK; /* 2^(x+8) entries */ s->iq_size = 1UL << ((iqa_val & VTD_IQA_QS) + 8); s->qi_enabled = true; trace_vtd_inv_qi_setup(s->iq, s->iq_size); /* Ok - report back to driver */ vtd_set_clear_mask_long(s, DMAR_GSTS_REG, 0, VTD_GSTS_QIES); } else { trace_vtd_err_qi_enable(s->iq_tail); } } else { if (vtd_queued_inv_disable_check(s)) { /* disable Queued Invalidation */ vtd_set_quad_raw(s, DMAR_IQH_REG, 0); s->iq_head = 0; s->qi_enabled = false; /* Ok - report back to driver */ vtd_set_clear_mask_long(s, DMAR_GSTS_REG, VTD_GSTS_QIES, 0); } else { trace_vtd_err_qi_disable(s->iq_head, s->iq_tail, s->iq_last_desc_type); } } }
true
qemu
8991c460be5a0811194fd4d2b49ba7146a23526b
static void vtd_handle_gcmd_qie(IntelIOMMUState *s, bool en) { uint64_t iqa_val = vtd_get_quad_raw(s, DMAR_IQA_REG); trace_vtd_inv_qi_enable(en); if (en) { if (vtd_queued_inv_enable_check(s)) { s->iq = iqa_val & VTD_IQA_IQA_MASK; s->iq_size = 1UL << ((iqa_val & VTD_IQA_QS) + 8); s->qi_enabled = true; trace_vtd_inv_qi_setup(s->iq, s->iq_size); vtd_set_clear_mask_long(s, DMAR_GSTS_REG, 0, VTD_GSTS_QIES); } else { trace_vtd_err_qi_enable(s->iq_tail); } } else { if (vtd_queued_inv_disable_check(s)) { vtd_set_quad_raw(s, DMAR_IQH_REG, 0); s->iq_head = 0; s->qi_enabled = false; vtd_set_clear_mask_long(s, DMAR_GSTS_REG, VTD_GSTS_QIES, 0); } else { trace_vtd_err_qi_disable(s->iq_head, s->iq_tail, s->iq_last_desc_type); } } }
{ "code": [ " if (vtd_queued_inv_enable_check(s)) {", " s->iq = iqa_val & VTD_IQA_IQA_MASK;", " s->iq_size = 1UL << ((iqa_val & VTD_IQA_QS) + 8);", " s->qi_enabled = true;", " trace_vtd_inv_qi_setup(s->iq, s->iq_size);", " vtd_set_clear_mask_long(s, DMAR_GSTS_REG, 0, VTD_GSTS_QIES);", " } else {", " trace_vtd_err_qi_enable(s->iq_tail);" ], "line_no": [ 15, 17, 21, 23, 25, 29, 31, 33 ] }
static void FUNC_0(IntelIOMMUState *VAR_0, bool VAR_1) { uint64_t iqa_val = vtd_get_quad_raw(VAR_0, DMAR_IQA_REG); trace_vtd_inv_qi_enable(VAR_1); if (VAR_1) { if (vtd_queued_inv_enable_check(VAR_0)) { VAR_0->iq = iqa_val & VTD_IQA_IQA_MASK; VAR_0->iq_size = 1UL << ((iqa_val & VTD_IQA_QS) + 8); VAR_0->qi_enabled = true; trace_vtd_inv_qi_setup(VAR_0->iq, VAR_0->iq_size); vtd_set_clear_mask_long(VAR_0, DMAR_GSTS_REG, 0, VTD_GSTS_QIES); } else { trace_vtd_err_qi_enable(VAR_0->iq_tail); } } else { if (vtd_queued_inv_disable_check(VAR_0)) { vtd_set_quad_raw(VAR_0, DMAR_IQH_REG, 0); VAR_0->iq_head = 0; VAR_0->qi_enabled = false; vtd_set_clear_mask_long(VAR_0, DMAR_GSTS_REG, VTD_GSTS_QIES, 0); } else { trace_vtd_err_qi_disable(VAR_0->iq_head, VAR_0->iq_tail, VAR_0->iq_last_desc_type); } } }
[ "static void FUNC_0(IntelIOMMUState *VAR_0, bool VAR_1)\n{", "uint64_t iqa_val = vtd_get_quad_raw(VAR_0, DMAR_IQA_REG);", "trace_vtd_inv_qi_enable(VAR_1);", "if (VAR_1) {", "if (vtd_queued_inv_enable_check(VAR_0)) {", "VAR_0->iq = iqa_val & VTD_IQA_IQA_MASK;", "VAR_0->iq_size = 1UL << ((iqa_val & VTD_IQA_QS) + 8);", "VAR_0->qi_enabled = true;", "trace_vtd_inv_qi_setup(VAR_0->iq, VAR_0->iq_size);", "vtd_set_clear_mask_long(VAR_0, DMAR_GSTS_REG, 0, VTD_GSTS_QIES);", "} else {", "trace_vtd_err_qi_enable(VAR_0->iq_tail);", "}", "} else {", "if (vtd_queued_inv_disable_check(VAR_0)) {", "vtd_set_quad_raw(VAR_0, DMAR_IQH_REG, 0);", "VAR_0->iq_head = 0;", "VAR_0->qi_enabled = false;", "vtd_set_clear_mask_long(VAR_0, DMAR_GSTS_REG, VTD_GSTS_QIES, 0);", "} else {", "trace_vtd_err_qi_disable(VAR_0->iq_head, VAR_0->iq_tail, VAR_0->iq_last_desc_type);", "}", "}", "}" ]
[ 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ] ]
12,492
static int get_qPy_pred(HEVCContext *s, int xC, int yC, int xBase, int yBase, int log2_cb_size) { HEVCLocalContext *lc = s->HEVClc; int ctb_size_mask = (1 << s->sps->log2_ctb_size) - 1; int MinCuQpDeltaSizeMask = (1 << (s->sps->log2_ctb_size - s->pps->diff_cu_qp_delta_depth)) - 1; int xQgBase = xBase - (xBase & MinCuQpDeltaSizeMask); int yQgBase = yBase - (yBase & MinCuQpDeltaSizeMask); int min_cb_width = s->sps->min_cb_width; int min_cb_height = s->sps->min_cb_height; int x_cb = xQgBase >> s->sps->log2_min_cb_size; int y_cb = yQgBase >> s->sps->log2_min_cb_size; int availableA = (xBase & ctb_size_mask) && (xQgBase & ctb_size_mask); int availableB = (yBase & ctb_size_mask) && (yQgBase & ctb_size_mask); int qPy_pred, qPy_a, qPy_b; // qPy_pred if (lc->first_qp_group || (!xQgBase && !yQgBase)) { lc->first_qp_group = !lc->tu.is_cu_qp_delta_coded; qPy_pred = s->sh.slice_qp; } else { qPy_pred = lc->qp_y; if (log2_cb_size < s->sps->log2_ctb_size - s->pps->diff_cu_qp_delta_depth) { static const int offsetX[8][8] = { { -1, 1, 3, 1, 7, 1, 3, 1 }, { 0, 0, 0, 0, 0, 0, 0, 0 }, { 1, 3, 1, 3, 1, 3, 1, 3 }, { 2, 2, 2, 2, 2, 2, 2, 2 }, { 3, 5, 7, 5, 3, 5, 7, 5 }, { 4, 4, 4, 4, 4, 4, 4, 4 }, { 5, 7, 5, 7, 5, 7, 5, 7 }, { 6, 6, 6, 6, 6, 6, 6, 6 } }; static const int offsetY[8][8] = { { 7, 0, 1, 2, 3, 4, 5, 6 }, { 0, 1, 2, 3, 4, 5, 6, 7 }, { 1, 0, 3, 2, 5, 4, 7, 6 }, { 0, 1, 2, 3, 4, 5, 6, 7 }, { 3, 0, 1, 2, 7, 4, 5, 6 }, { 0, 1, 2, 3, 4, 5, 6, 7 }, { 1, 0, 3, 2, 5, 4, 7, 6 }, { 0, 1, 2, 3, 4, 5, 6, 7 } }; int xC0b = (xC - (xC & ctb_size_mask)) >> s->sps->log2_min_cb_size; int yC0b = (yC - (yC & ctb_size_mask)) >> s->sps->log2_min_cb_size; int idxX = (xQgBase & ctb_size_mask) >> s->sps->log2_min_cb_size; int idxY = (yQgBase & ctb_size_mask) >> s->sps->log2_min_cb_size; int idx_mask = ctb_size_mask >> s->sps->log2_min_cb_size; int x, y; x = FFMIN(xC0b + offsetX[idxX][idxY], min_cb_width - 1); y = FFMIN(yC0b + (offsetY[idxX][idxY] & idx_mask), min_cb_height - 1); if (xC0b == (lc->start_of_tiles_x >> s->sps->log2_min_cb_size) && offsetX[idxX][idxY] == -1) { x = (lc->end_of_tiles_x >> s->sps->log2_min_cb_size) - 1; y = yC0b - 1; } qPy_pred = s->qp_y_tab[y * min_cb_width + x]; } } // qPy_a if (availableA == 0) qPy_a = qPy_pred; else qPy_a = s->qp_y_tab[(x_cb - 1) + y_cb * min_cb_width]; // qPy_b if (availableB == 0) qPy_b = qPy_pred; else qPy_b = s->qp_y_tab[x_cb + (y_cb - 1) * min_cb_width]; av_assert2(qPy_a >= -s->sps->qp_bd_offset && qPy_a < 52); av_assert2(qPy_b >= -s->sps->qp_bd_offset && qPy_b < 52); return (qPy_a + qPy_b + 1) >> 1; }
true
FFmpeg
64278039e55ffc88d231a8d760ecc257a120760a
static int get_qPy_pred(HEVCContext *s, int xC, int yC, int xBase, int yBase, int log2_cb_size) { HEVCLocalContext *lc = s->HEVClc; int ctb_size_mask = (1 << s->sps->log2_ctb_size) - 1; int MinCuQpDeltaSizeMask = (1 << (s->sps->log2_ctb_size - s->pps->diff_cu_qp_delta_depth)) - 1; int xQgBase = xBase - (xBase & MinCuQpDeltaSizeMask); int yQgBase = yBase - (yBase & MinCuQpDeltaSizeMask); int min_cb_width = s->sps->min_cb_width; int min_cb_height = s->sps->min_cb_height; int x_cb = xQgBase >> s->sps->log2_min_cb_size; int y_cb = yQgBase >> s->sps->log2_min_cb_size; int availableA = (xBase & ctb_size_mask) && (xQgBase & ctb_size_mask); int availableB = (yBase & ctb_size_mask) && (yQgBase & ctb_size_mask); int qPy_pred, qPy_a, qPy_b; if (lc->first_qp_group || (!xQgBase && !yQgBase)) { lc->first_qp_group = !lc->tu.is_cu_qp_delta_coded; qPy_pred = s->sh.slice_qp; } else { qPy_pred = lc->qp_y; if (log2_cb_size < s->sps->log2_ctb_size - s->pps->diff_cu_qp_delta_depth) { static const int offsetX[8][8] = { { -1, 1, 3, 1, 7, 1, 3, 1 }, { 0, 0, 0, 0, 0, 0, 0, 0 }, { 1, 3, 1, 3, 1, 3, 1, 3 }, { 2, 2, 2, 2, 2, 2, 2, 2 }, { 3, 5, 7, 5, 3, 5, 7, 5 }, { 4, 4, 4, 4, 4, 4, 4, 4 }, { 5, 7, 5, 7, 5, 7, 5, 7 }, { 6, 6, 6, 6, 6, 6, 6, 6 } }; static const int offsetY[8][8] = { { 7, 0, 1, 2, 3, 4, 5, 6 }, { 0, 1, 2, 3, 4, 5, 6, 7 }, { 1, 0, 3, 2, 5, 4, 7, 6 }, { 0, 1, 2, 3, 4, 5, 6, 7 }, { 3, 0, 1, 2, 7, 4, 5, 6 }, { 0, 1, 2, 3, 4, 5, 6, 7 }, { 1, 0, 3, 2, 5, 4, 7, 6 }, { 0, 1, 2, 3, 4, 5, 6, 7 } }; int xC0b = (xC - (xC & ctb_size_mask)) >> s->sps->log2_min_cb_size; int yC0b = (yC - (yC & ctb_size_mask)) >> s->sps->log2_min_cb_size; int idxX = (xQgBase & ctb_size_mask) >> s->sps->log2_min_cb_size; int idxY = (yQgBase & ctb_size_mask) >> s->sps->log2_min_cb_size; int idx_mask = ctb_size_mask >> s->sps->log2_min_cb_size; int x, y; x = FFMIN(xC0b + offsetX[idxX][idxY], min_cb_width - 1); y = FFMIN(yC0b + (offsetY[idxX][idxY] & idx_mask), min_cb_height - 1); if (xC0b == (lc->start_of_tiles_x >> s->sps->log2_min_cb_size) && offsetX[idxX][idxY] == -1) { x = (lc->end_of_tiles_x >> s->sps->log2_min_cb_size) - 1; y = yC0b - 1; } qPy_pred = s->qp_y_tab[y * min_cb_width + x]; } } if (availableA == 0) qPy_a = qPy_pred; else qPy_a = s->qp_y_tab[(x_cb - 1) + y_cb * min_cb_width]; if (availableB == 0) qPy_b = qPy_pred; else qPy_b = s->qp_y_tab[x_cb + (y_cb - 1) * min_cb_width]; av_assert2(qPy_a >= -s->sps->qp_bd_offset && qPy_a < 52); av_assert2(qPy_b >= -s->sps->qp_bd_offset && qPy_b < 52); return (qPy_a + qPy_b + 1) >> 1; }
{ "code": [ " qPy_pred = lc->qp_y;", " if (log2_cb_size < s->sps->log2_ctb_size -", " s->pps->diff_cu_qp_delta_depth) {", " static const int offsetX[8][8] = {", " { -1, 1, 3, 1, 7, 1, 3, 1 },", " { 0, 0, 0, 0, 0, 0, 0, 0 },", " { 1, 3, 1, 3, 1, 3, 1, 3 },", " { 2, 2, 2, 2, 2, 2, 2, 2 },", " { 3, 5, 7, 5, 3, 5, 7, 5 },", " { 4, 4, 4, 4, 4, 4, 4, 4 },", " { 5, 7, 5, 7, 5, 7, 5, 7 },", " { 6, 6, 6, 6, 6, 6, 6, 6 }", " };", " static const int offsetY[8][8] = {", " { 7, 0, 1, 2, 3, 4, 5, 6 },", " { 0, 1, 2, 3, 4, 5, 6, 7 },", " { 1, 0, 3, 2, 5, 4, 7, 6 },", " { 0, 1, 2, 3, 4, 5, 6, 7 },", " { 3, 0, 1, 2, 7, 4, 5, 6 },", " { 0, 1, 2, 3, 4, 5, 6, 7 },", " { 1, 0, 3, 2, 5, 4, 7, 6 },", " { 0, 1, 2, 3, 4, 5, 6, 7 }", " };", " int xC0b = (xC - (xC & ctb_size_mask)) >> s->sps->log2_min_cb_size;", " int yC0b = (yC - (yC & ctb_size_mask)) >> s->sps->log2_min_cb_size;", " int idxX = (xQgBase & ctb_size_mask) >> s->sps->log2_min_cb_size;", " int idxY = (yQgBase & ctb_size_mask) >> s->sps->log2_min_cb_size;", " int idx_mask = ctb_size_mask >> s->sps->log2_min_cb_size;", " int x, y;", " x = FFMIN(xC0b + offsetX[idxX][idxY], min_cb_width - 1);", " y = FFMIN(yC0b + (offsetY[idxX][idxY] & idx_mask), min_cb_height - 1);", " if (xC0b == (lc->start_of_tiles_x >> s->sps->log2_min_cb_size) &&", " offsetX[idxX][idxY] == -1) {", " x = (lc->end_of_tiles_x >> s->sps->log2_min_cb_size) - 1;", " y = yC0b - 1;", " qPy_pred = s->qp_y_tab[y * min_cb_width + x];" ], "line_no": [ 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 79, 85, 79, 81, 91, 73, 95, 97, 99, 101, 103, 105, 109, 111, 115, 117, 119, 121, 125 ] }
static int FUNC_0(HEVCContext *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4, int VAR_5) { HEVCLocalContext *lc = VAR_0->HEVClc; int VAR_6 = (1 << VAR_0->sps->log2_ctb_size) - 1; int VAR_7 = (1 << (VAR_0->sps->log2_ctb_size - VAR_0->pps->diff_cu_qp_delta_depth)) - 1; int VAR_8 = VAR_3 - (VAR_3 & VAR_7); int VAR_9 = VAR_4 - (VAR_4 & VAR_7); int VAR_10 = VAR_0->sps->VAR_10; int VAR_11 = VAR_0->sps->VAR_11; int VAR_12 = VAR_8 >> VAR_0->sps->log2_min_cb_size; int VAR_13 = VAR_9 >> VAR_0->sps->log2_min_cb_size; int VAR_14 = (VAR_3 & VAR_6) && (VAR_8 & VAR_6); int VAR_15 = (VAR_4 & VAR_6) && (VAR_9 & VAR_6); int VAR_16, VAR_17, VAR_18; if (lc->first_qp_group || (!VAR_8 && !VAR_9)) { lc->first_qp_group = !lc->tu.is_cu_qp_delta_coded; VAR_16 = VAR_0->sh.slice_qp; } else { VAR_16 = lc->qp_y; if (VAR_5 < VAR_0->sps->log2_ctb_size - VAR_0->pps->diff_cu_qp_delta_depth) { static const int VAR_19[8][8] = { { -1, 1, 3, 1, 7, 1, 3, 1 }, { 0, 0, 0, 0, 0, 0, 0, 0 }, { 1, 3, 1, 3, 1, 3, 1, 3 }, { 2, 2, 2, 2, 2, 2, 2, 2 }, { 3, 5, 7, 5, 3, 5, 7, 5 }, { 4, 4, 4, 4, 4, 4, 4, 4 }, { 5, 7, 5, 7, 5, 7, 5, 7 }, { 6, 6, 6, 6, 6, 6, 6, 6 } }; static const int VAR_20[8][8] = { { 7, 0, 1, 2, 3, 4, 5, 6 }, { 0, 1, 2, 3, 4, 5, 6, 7 }, { 1, 0, 3, 2, 5, 4, 7, 6 }, { 0, 1, 2, 3, 4, 5, 6, 7 }, { 3, 0, 1, 2, 7, 4, 5, 6 }, { 0, 1, 2, 3, 4, 5, 6, 7 }, { 1, 0, 3, 2, 5, 4, 7, 6 }, { 0, 1, 2, 3, 4, 5, 6, 7 } }; int VAR_21 = (VAR_1 - (VAR_1 & VAR_6)) >> VAR_0->sps->log2_min_cb_size; int VAR_22 = (VAR_2 - (VAR_2 & VAR_6)) >> VAR_0->sps->log2_min_cb_size; int VAR_23 = (VAR_8 & VAR_6) >> VAR_0->sps->log2_min_cb_size; int VAR_24 = (VAR_9 & VAR_6) >> VAR_0->sps->log2_min_cb_size; int VAR_25 = VAR_6 >> VAR_0->sps->log2_min_cb_size; int VAR_26, VAR_27; VAR_26 = FFMIN(VAR_21 + VAR_19[VAR_23][VAR_24], VAR_10 - 1); VAR_27 = FFMIN(VAR_22 + (VAR_20[VAR_23][VAR_24] & VAR_25), VAR_11 - 1); if (VAR_21 == (lc->start_of_tiles_x >> VAR_0->sps->log2_min_cb_size) && VAR_19[VAR_23][VAR_24] == -1) { VAR_26 = (lc->end_of_tiles_x >> VAR_0->sps->log2_min_cb_size) - 1; VAR_27 = VAR_22 - 1; } VAR_16 = VAR_0->qp_y_tab[VAR_27 * VAR_10 + VAR_26]; } } if (VAR_14 == 0) VAR_17 = VAR_16; else VAR_17 = VAR_0->qp_y_tab[(VAR_12 - 1) + VAR_13 * VAR_10]; if (VAR_15 == 0) VAR_18 = VAR_16; else VAR_18 = VAR_0->qp_y_tab[VAR_12 + (VAR_13 - 1) * VAR_10]; av_assert2(VAR_17 >= -VAR_0->sps->qp_bd_offset && VAR_17 < 52); av_assert2(VAR_18 >= -VAR_0->sps->qp_bd_offset && VAR_18 < 52); return (VAR_17 + VAR_18 + 1) >> 1; }
[ "static int FUNC_0(HEVCContext *VAR_0, int VAR_1, int VAR_2,\nint VAR_3, int VAR_4, int VAR_5)\n{", "HEVCLocalContext *lc = VAR_0->HEVClc;", "int VAR_6 = (1 << VAR_0->sps->log2_ctb_size) - 1;", "int VAR_7 = (1 << (VAR_0->sps->log2_ctb_size -\nVAR_0->pps->diff_cu_qp_delta_depth)) - 1;", "int VAR_8 = VAR_3 - (VAR_3 & VAR_7);", "int VAR_9 = VAR_4 - (VAR_4 & VAR_7);", "int VAR_10 = VAR_0->sps->VAR_10;", "int VAR_11 = VAR_0->sps->VAR_11;", "int VAR_12 = VAR_8 >> VAR_0->sps->log2_min_cb_size;", "int VAR_13 = VAR_9 >> VAR_0->sps->log2_min_cb_size;", "int VAR_14 = (VAR_3 & VAR_6) &&\n(VAR_8 & VAR_6);", "int VAR_15 = (VAR_4 & VAR_6) &&\n(VAR_9 & VAR_6);", "int VAR_16, VAR_17, VAR_18;", "if (lc->first_qp_group || (!VAR_8 && !VAR_9)) {", "lc->first_qp_group = !lc->tu.is_cu_qp_delta_coded;", "VAR_16 = VAR_0->sh.slice_qp;", "} else {", "VAR_16 = lc->qp_y;", "if (VAR_5 < VAR_0->sps->log2_ctb_size -\nVAR_0->pps->diff_cu_qp_delta_depth) {", "static const int VAR_19[8][8] = {", "{ -1, 1, 3, 1, 7, 1, 3, 1 },", "{ 0, 0, 0, 0, 0, 0, 0, 0 },", "{ 1, 3, 1, 3, 1, 3, 1, 3 },", "{ 2, 2, 2, 2, 2, 2, 2, 2 },", "{ 3, 5, 7, 5, 3, 5, 7, 5 },", "{ 4, 4, 4, 4, 4, 4, 4, 4 },", "{ 5, 7, 5, 7, 5, 7, 5, 7 },", "{ 6, 6, 6, 6, 6, 6, 6, 6 }", "};", "static const int VAR_20[8][8] = {", "{ 7, 0, 1, 2, 3, 4, 5, 6 },", "{ 0, 1, 2, 3, 4, 5, 6, 7 },", "{ 1, 0, 3, 2, 5, 4, 7, 6 },", "{ 0, 1, 2, 3, 4, 5, 6, 7 },", "{ 3, 0, 1, 2, 7, 4, 5, 6 },", "{ 0, 1, 2, 3, 4, 5, 6, 7 },", "{ 1, 0, 3, 2, 5, 4, 7, 6 },", "{ 0, 1, 2, 3, 4, 5, 6, 7 }", "};", "int VAR_21 = (VAR_1 - (VAR_1 & VAR_6)) >> VAR_0->sps->log2_min_cb_size;", "int VAR_22 = (VAR_2 - (VAR_2 & VAR_6)) >> VAR_0->sps->log2_min_cb_size;", "int VAR_23 = (VAR_8 & VAR_6) >> VAR_0->sps->log2_min_cb_size;", "int VAR_24 = (VAR_9 & VAR_6) >> VAR_0->sps->log2_min_cb_size;", "int VAR_25 = VAR_6 >> VAR_0->sps->log2_min_cb_size;", "int VAR_26, VAR_27;", "VAR_26 = FFMIN(VAR_21 + VAR_19[VAR_23][VAR_24], VAR_10 - 1);", "VAR_27 = FFMIN(VAR_22 + (VAR_20[VAR_23][VAR_24] & VAR_25), VAR_11 - 1);", "if (VAR_21 == (lc->start_of_tiles_x >> VAR_0->sps->log2_min_cb_size) &&\nVAR_19[VAR_23][VAR_24] == -1) {", "VAR_26 = (lc->end_of_tiles_x >> VAR_0->sps->log2_min_cb_size) - 1;", "VAR_27 = VAR_22 - 1;", "}", "VAR_16 = VAR_0->qp_y_tab[VAR_27 * VAR_10 + VAR_26];", "}", "}", "if (VAR_14 == 0)\nVAR_17 = VAR_16;", "else\nVAR_17 = VAR_0->qp_y_tab[(VAR_12 - 1) + VAR_13 * VAR_10];", "if (VAR_15 == 0)\nVAR_18 = VAR_16;", "else\nVAR_18 = VAR_0->qp_y_tab[VAR_12 + (VAR_13 - 1) * VAR_10];", "av_assert2(VAR_17 >= -VAR_0->sps->qp_bd_offset && VAR_17 < 52);", "av_assert2(VAR_18 >= -VAR_0->sps->qp_bd_offset && VAR_18 < 52);", "return (VAR_17 + VAR_18 + 1) >> 1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 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 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 109 ], [ 111 ], [ 115, 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 135, 137 ], [ 139, 141 ], [ 147, 149 ], [ 151, 153 ], [ 157 ], [ 159 ], [ 163 ], [ 165 ] ]
12,494
static void framebuffer_update_request(VncState *vs, int incremental, int x_position, int y_position, int w, int h) { if (x_position > ds_get_width(vs->ds)) x_position = ds_get_width(vs->ds); if (y_position > ds_get_height(vs->ds)) y_position = ds_get_height(vs->ds); if (x_position + w >= ds_get_width(vs->ds)) w = ds_get_width(vs->ds) - x_position; if (y_position + h >= ds_get_height(vs->ds)) h = ds_get_height(vs->ds) - y_position; int i; vs->need_update = 1; if (!incremental) { char *old_row = vs->old_data + y_position * ds_get_linesize(vs->ds); for (i = 0; i < h; i++) { vnc_set_bits(vs->dirty_row[y_position + i], (ds_get_width(vs->ds) / 16), VNC_DIRTY_WORDS); memset(old_row, 42, ds_get_width(vs->ds) * vs->depth); old_row += ds_get_linesize(vs->ds); } } }
true
qemu
6cec5487990bf3f1f22b3fcb871978255e92ae0d
static void framebuffer_update_request(VncState *vs, int incremental, int x_position, int y_position, int w, int h) { if (x_position > ds_get_width(vs->ds)) x_position = ds_get_width(vs->ds); if (y_position > ds_get_height(vs->ds)) y_position = ds_get_height(vs->ds); if (x_position + w >= ds_get_width(vs->ds)) w = ds_get_width(vs->ds) - x_position; if (y_position + h >= ds_get_height(vs->ds)) h = ds_get_height(vs->ds) - y_position; int i; vs->need_update = 1; if (!incremental) { char *old_row = vs->old_data + y_position * ds_get_linesize(vs->ds); for (i = 0; i < h; i++) { vnc_set_bits(vs->dirty_row[y_position + i], (ds_get_width(vs->ds) / 16), VNC_DIRTY_WORDS); memset(old_row, 42, ds_get_width(vs->ds) * vs->depth); old_row += ds_get_linesize(vs->ds); } } }
{ "code": [ "\t memset(old_row, 42, ds_get_width(vs->ds) * vs->depth);" ], "line_no": [ 43 ] }
static void FUNC_0(VncState *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4, int VAR_5) { if (VAR_2 > ds_get_width(VAR_0->ds)) VAR_2 = ds_get_width(VAR_0->ds); if (VAR_3 > ds_get_height(VAR_0->ds)) VAR_3 = ds_get_height(VAR_0->ds); if (VAR_2 + VAR_4 >= ds_get_width(VAR_0->ds)) VAR_4 = ds_get_width(VAR_0->ds) - VAR_2; if (VAR_3 + VAR_5 >= ds_get_height(VAR_0->ds)) VAR_5 = ds_get_height(VAR_0->ds) - VAR_3; int VAR_6; VAR_0->need_update = 1; if (!VAR_1) { char *VAR_7 = VAR_0->old_data + VAR_3 * ds_get_linesize(VAR_0->ds); for (VAR_6 = 0; VAR_6 < VAR_5; VAR_6++) { vnc_set_bits(VAR_0->dirty_row[VAR_3 + VAR_6], (ds_get_width(VAR_0->ds) / 16), VNC_DIRTY_WORDS); memset(VAR_7, 42, ds_get_width(VAR_0->ds) * VAR_0->depth); VAR_7 += ds_get_linesize(VAR_0->ds); } } }
[ "static void FUNC_0(VncState *VAR_0, int VAR_1,\nint VAR_2, int VAR_3,\nint VAR_4, int VAR_5)\n{", "if (VAR_2 > ds_get_width(VAR_0->ds))\nVAR_2 = ds_get_width(VAR_0->ds);", "if (VAR_3 > ds_get_height(VAR_0->ds))\nVAR_3 = ds_get_height(VAR_0->ds);", "if (VAR_2 + VAR_4 >= ds_get_width(VAR_0->ds))\nVAR_4 = ds_get_width(VAR_0->ds) - VAR_2;", "if (VAR_3 + VAR_5 >= ds_get_height(VAR_0->ds))\nVAR_5 = ds_get_height(VAR_0->ds) - VAR_3;", "int VAR_6;", "VAR_0->need_update = 1;", "if (!VAR_1) {", "char *VAR_7 = VAR_0->old_data + VAR_3 * ds_get_linesize(VAR_0->ds);", "for (VAR_6 = 0; VAR_6 < VAR_5; VAR_6++) {", "vnc_set_bits(VAR_0->dirty_row[VAR_3 + VAR_6],\n(ds_get_width(VAR_0->ds) / 16), VNC_DIRTY_WORDS);", "memset(VAR_7, 42, ds_get_width(VAR_0->ds) * VAR_0->depth);", "VAR_7 += ds_get_linesize(VAR_0->ds);", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9, 11 ], [ 13, 15 ], [ 17, 19 ], [ 21, 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39, 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ] ]
12,495
static void vnc_connect(VncDisplay *vd, int csock) { VncState *vs = qemu_mallocz(sizeof(VncState)); vs->csock = csock; VNC_DEBUG("New client on socket %d\n", csock); dcl->idle = 0; socket_set_nonblock(vs->csock); qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, NULL, vs); vs->vd = vd; vs->ds = vd->ds; vs->timer = qemu_new_timer(rt_clock, vnc_update_client, vs); vs->last_x = -1; vs->last_y = -1; vs->as.freq = 44100; vs->as.nchannels = 2; vs->as.fmt = AUD_FMT_S16; vs->as.endianness = 0; vnc_resize(vs); vnc_write(vs, "RFB 003.008\n", 12); vnc_flush(vs); vnc_read_when(vs, protocol_version, 12); memset(vs->old_data, 0, ds_get_linesize(vs->ds) * ds_get_height(vs->ds)); memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row)); vnc_update_client(vs); reset_keys(vs); vs->next = vd->clients; vd->clients = vs; }
true
qemu
6baebed7698a37a0ac5168faf26023426b0ac940
static void vnc_connect(VncDisplay *vd, int csock) { VncState *vs = qemu_mallocz(sizeof(VncState)); vs->csock = csock; VNC_DEBUG("New client on socket %d\n", csock); dcl->idle = 0; socket_set_nonblock(vs->csock); qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, NULL, vs); vs->vd = vd; vs->ds = vd->ds; vs->timer = qemu_new_timer(rt_clock, vnc_update_client, vs); vs->last_x = -1; vs->last_y = -1; vs->as.freq = 44100; vs->as.nchannels = 2; vs->as.fmt = AUD_FMT_S16; vs->as.endianness = 0; vnc_resize(vs); vnc_write(vs, "RFB 003.008\n", 12); vnc_flush(vs); vnc_read_when(vs, protocol_version, 12); memset(vs->old_data, 0, ds_get_linesize(vs->ds) * ds_get_height(vs->ds)); memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row)); vnc_update_client(vs); reset_keys(vs); vs->next = vd->clients; vd->clients = vs; }
{ "code": [ " memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row));", " memset(vs->old_data, 0, ds_get_linesize(vs->ds) * ds_get_height(vs->ds));", " memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row));" ], "line_no": [ 53, 51, 53 ] }
static void FUNC_0(VncDisplay *VAR_0, int VAR_1) { VncState *vs = qemu_mallocz(sizeof(VncState)); vs->VAR_1 = VAR_1; VNC_DEBUG("New client on socket %d\n", VAR_1); dcl->idle = 0; socket_set_nonblock(vs->VAR_1); qemu_set_fd_handler2(vs->VAR_1, NULL, vnc_client_read, NULL, vs); vs->VAR_0 = VAR_0; vs->ds = VAR_0->ds; vs->timer = qemu_new_timer(rt_clock, vnc_update_client, vs); vs->last_x = -1; vs->last_y = -1; vs->as.freq = 44100; vs->as.nchannels = 2; vs->as.fmt = AUD_FMT_S16; vs->as.endianness = 0; vnc_resize(vs); vnc_write(vs, "RFB 003.008\n", 12); vnc_flush(vs); vnc_read_when(vs, protocol_version, 12); memset(vs->old_data, 0, ds_get_linesize(vs->ds) * ds_get_height(vs->ds)); memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row)); vnc_update_client(vs); reset_keys(vs); vs->next = VAR_0->clients; VAR_0->clients = vs; }
[ "static void FUNC_0(VncDisplay *VAR_0, int VAR_1)\n{", "VncState *vs = qemu_mallocz(sizeof(VncState));", "vs->VAR_1 = VAR_1;", "VNC_DEBUG(\"New client on socket %d\\n\", VAR_1);", "dcl->idle = 0;", "socket_set_nonblock(vs->VAR_1);", "qemu_set_fd_handler2(vs->VAR_1, NULL, vnc_client_read, NULL, vs);", "vs->VAR_0 = VAR_0;", "vs->ds = VAR_0->ds;", "vs->timer = qemu_new_timer(rt_clock, vnc_update_client, vs);", "vs->last_x = -1;", "vs->last_y = -1;", "vs->as.freq = 44100;", "vs->as.nchannels = 2;", "vs->as.fmt = AUD_FMT_S16;", "vs->as.endianness = 0;", "vnc_resize(vs);", "vnc_write(vs, \"RFB 003.008\\n\", 12);", "vnc_flush(vs);", "vnc_read_when(vs, protocol_version, 12);", "memset(vs->old_data, 0, ds_get_linesize(vs->ds) * ds_get_height(vs->ds));", "memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row));", "vnc_update_client(vs);", "reset_keys(vs);", "vs->next = VAR_0->clients;", "VAR_0->clients = vs;", "}" ]
[ 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ] ]
12,496
static uint32_t get_elf_hwcap(void) { CPUState *e = thread_env; uint32_t features = 0; /* We don't have to be terribly complete here; the high points are Altivec/FP/SPE support. Anything else is just a bonus. */ #define GET_FEATURE(flag, feature) \ do {if (e->insns_flags & flag) features |= feature; } while(0) GET_FEATURE(PPC_64B, PPC_FEATURE_64); GET_FEATURE(PPC_FLOAT, PPC_FEATURE_HAS_FPU); GET_FEATURE(PPC_ALTIVEC, PPC_FEATURE_HAS_ALTIVEC); GET_FEATURE(PPC_SPE, PPC_FEATURE_HAS_SPE); GET_FEATURE(PPC_SPE_SINGLE, PPC_FEATURE_HAS_EFP_SINGLE); GET_FEATURE(PPC_SPE_DOUBLE, PPC_FEATURE_HAS_EFP_DOUBLE); GET_FEATURE(PPC_BOOKE, PPC_FEATURE_BOOKE); GET_FEATURE(PPC_405_MAC, PPC_FEATURE_HAS_4xxMAC); #undef GET_FEATURE return features; }
true
qemu
3efa9a672e4a5f7b2d35cf457ea277e997a0f8c6
static uint32_t get_elf_hwcap(void) { CPUState *e = thread_env; uint32_t features = 0; #define GET_FEATURE(flag, feature) \ do {if (e->insns_flags & flag) features |= feature; } while(0) GET_FEATURE(PPC_64B, PPC_FEATURE_64); GET_FEATURE(PPC_FLOAT, PPC_FEATURE_HAS_FPU); GET_FEATURE(PPC_ALTIVEC, PPC_FEATURE_HAS_ALTIVEC); GET_FEATURE(PPC_SPE, PPC_FEATURE_HAS_SPE); GET_FEATURE(PPC_SPE_SINGLE, PPC_FEATURE_HAS_EFP_SINGLE); GET_FEATURE(PPC_SPE_DOUBLE, PPC_FEATURE_HAS_EFP_DOUBLE); GET_FEATURE(PPC_BOOKE, PPC_FEATURE_BOOKE); GET_FEATURE(PPC_405_MAC, PPC_FEATURE_HAS_4xxMAC); #undef GET_FEATURE return features; }
{ "code": [ " GET_FEATURE(PPC_64B, PPC_FEATURE_64);", " GET_FEATURE(PPC_FLOAT, PPC_FEATURE_HAS_FPU);", " GET_FEATURE(PPC_ALTIVEC, PPC_FEATURE_HAS_ALTIVEC);", " GET_FEATURE(PPC_SPE, PPC_FEATURE_HAS_SPE);", " GET_FEATURE(PPC_SPE_SINGLE, PPC_FEATURE_HAS_EFP_SINGLE);", " GET_FEATURE(PPC_SPE_DOUBLE, PPC_FEATURE_HAS_EFP_DOUBLE);", " GET_FEATURE(PPC_BOOKE, PPC_FEATURE_BOOKE);", " GET_FEATURE(PPC_405_MAC, PPC_FEATURE_HAS_4xxMAC);" ], "line_no": [ 19, 21, 23, 25, 27, 29, 31, 33 ] }
static uint32_t FUNC_0(void) { CPUState *e = thread_env; uint32_t features = 0; #define GET_FEATURE(flag, feature) \ do {if (e->insns_flags & flag) features |= feature; } while(0) GET_FEATURE(PPC_64B, PPC_FEATURE_64); GET_FEATURE(PPC_FLOAT, PPC_FEATURE_HAS_FPU); GET_FEATURE(PPC_ALTIVEC, PPC_FEATURE_HAS_ALTIVEC); GET_FEATURE(PPC_SPE, PPC_FEATURE_HAS_SPE); GET_FEATURE(PPC_SPE_SINGLE, PPC_FEATURE_HAS_EFP_SINGLE); GET_FEATURE(PPC_SPE_DOUBLE, PPC_FEATURE_HAS_EFP_DOUBLE); GET_FEATURE(PPC_BOOKE, PPC_FEATURE_BOOKE); GET_FEATURE(PPC_405_MAC, PPC_FEATURE_HAS_4xxMAC); #undef GET_FEATURE return features; }
[ "static uint32_t FUNC_0(void)\n{", "CPUState *e = thread_env;", "uint32_t features = 0;", "#define GET_FEATURE(flag, feature) \\\ndo {if (e->insns_flags & flag) features |= feature; } while(0)", "GET_FEATURE(PPC_64B, PPC_FEATURE_64);", "GET_FEATURE(PPC_FLOAT, PPC_FEATURE_HAS_FPU);", "GET_FEATURE(PPC_ALTIVEC, PPC_FEATURE_HAS_ALTIVEC);", "GET_FEATURE(PPC_SPE, PPC_FEATURE_HAS_SPE);", "GET_FEATURE(PPC_SPE_SINGLE, PPC_FEATURE_HAS_EFP_SINGLE);", "GET_FEATURE(PPC_SPE_DOUBLE, PPC_FEATURE_HAS_EFP_DOUBLE);", "GET_FEATURE(PPC_BOOKE, PPC_FEATURE_BOOKE);", "GET_FEATURE(PPC_405_MAC, PPC_FEATURE_HAS_4xxMAC);", "#undef GET_FEATURE\nreturn features;", "}" ]
[ 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 15, 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35, 39 ], [ 41 ] ]
12,497
static inline void RENAME(rgb24tobgr24)(const uint8_t *src, uint8_t *dst, unsigned int src_size) { unsigned i; #ifdef HAVE_MMX long mmx_size= 23 - src_size; asm volatile ( "movq "MANGLE(mask24r)", %%mm5 \n\t" "movq "MANGLE(mask24g)", %%mm6 \n\t" "movq "MANGLE(mask24b)", %%mm7 \n\t" ".balign 16 \n\t" "1: \n\t" PREFETCH" 32(%1, %%"REG_a") \n\t" "movq (%1, %%"REG_a"), %%mm0 \n\t" // BGR BGR BG "movq (%1, %%"REG_a"), %%mm1 \n\t" // BGR BGR BG "movq 2(%1, %%"REG_a"), %%mm2 \n\t" // R BGR BGR B "psllq $16, %%mm0 \n\t" // 00 BGR BGR "pand %%mm5, %%mm0 \n\t" "pand %%mm6, %%mm1 \n\t" "pand %%mm7, %%mm2 \n\t" "por %%mm0, %%mm1 \n\t" "por %%mm2, %%mm1 \n\t" "movq 6(%1, %%"REG_a"), %%mm0 \n\t" // BGR BGR BG MOVNTQ" %%mm1, (%2, %%"REG_a")\n\t" // RGB RGB RG "movq 8(%1, %%"REG_a"), %%mm1 \n\t" // R BGR BGR B "movq 10(%1, %%"REG_a"), %%mm2 \n\t" // GR BGR BGR "pand %%mm7, %%mm0 \n\t" "pand %%mm5, %%mm1 \n\t" "pand %%mm6, %%mm2 \n\t" "por %%mm0, %%mm1 \n\t" "por %%mm2, %%mm1 \n\t" "movq 14(%1, %%"REG_a"), %%mm0 \n\t" // R BGR BGR B MOVNTQ" %%mm1, 8(%2, %%"REG_a")\n\t" // B RGB RGB R "movq 16(%1, %%"REG_a"), %%mm1 \n\t" // GR BGR BGR "movq 18(%1, %%"REG_a"), %%mm2 \n\t" // BGR BGR BG "pand %%mm6, %%mm0 \n\t" "pand %%mm7, %%mm1 \n\t" "pand %%mm5, %%mm2 \n\t" "por %%mm0, %%mm1 \n\t" "por %%mm2, %%mm1 \n\t" MOVNTQ" %%mm1, 16(%2, %%"REG_a")\n\t" "add $24, %%"REG_a" \n\t" " js 1b \n\t" : "+a" (mmx_size) : "r" (src-mmx_size), "r"(dst-mmx_size) ); __asm __volatile(SFENCE:::"memory"); __asm __volatile(EMMS:::"memory"); if(mmx_size==23) return; //finihsed, was multiple of 8 src+= src_size; dst+= src_size; src_size= 23-mmx_size; src-= src_size; dst-= src_size; #endif for(i=0; i<src_size; i+=3) { register uint8_t x; x = src[i + 2]; dst[i + 1] = src[i + 1]; dst[i + 2] = src[i + 0]; dst[i + 0] = x; } }
true
FFmpeg
7f526efd17973ec6d2204f7a47b6923e2be31363
static inline void RENAME(rgb24tobgr24)(const uint8_t *src, uint8_t *dst, unsigned int src_size) { unsigned i; #ifdef HAVE_MMX long mmx_size= 23 - src_size; asm volatile ( "movq "MANGLE(mask24r)", %%mm5 \n\t" "movq "MANGLE(mask24g)", %%mm6 \n\t" "movq "MANGLE(mask24b)", %%mm7 \n\t" ".balign 16 \n\t" "1: \n\t" PREFETCH" 32(%1, %%"REG_a") \n\t" "movq (%1, %%"REG_a"), %%mm0 \n\t" "movq (%1, %%"REG_a"), %%mm1 \n\t" "movq 2(%1, %%"REG_a"), %%mm2 \n\t" "psllq $16, %%mm0 \n\t" "pand %%mm5, %%mm0 \n\t" "pand %%mm6, %%mm1 \n\t" "pand %%mm7, %%mm2 \n\t" "por %%mm0, %%mm1 \n\t" "por %%mm2, %%mm1 \n\t" "movq 6(%1, %%"REG_a"), %%mm0 \n\t" MOVNTQ" %%mm1, (%2, %%"REG_a")\n\t" "movq 8(%1, %%"REG_a"), %%mm1 \n\t" "movq 10(%1, %%"REG_a"), %%mm2 \n\t" "pand %%mm7, %%mm0 \n\t" "pand %%mm5, %%mm1 \n\t" "pand %%mm6, %%mm2 \n\t" "por %%mm0, %%mm1 \n\t" "por %%mm2, %%mm1 \n\t" "movq 14(%1, %%"REG_a"), %%mm0 \n\t" MOVNTQ" %%mm1, 8(%2, %%"REG_a")\n\t" "movq 16(%1, %%"REG_a"), %%mm1 \n\t" "movq 18(%1, %%"REG_a"), %%mm2 \n\t" "pand %%mm6, %%mm0 \n\t" "pand %%mm7, %%mm1 \n\t" "pand %%mm5, %%mm2 \n\t" "por %%mm0, %%mm1 \n\t" "por %%mm2, %%mm1 \n\t" MOVNTQ" %%mm1, 16(%2, %%"REG_a")\n\t" "add $24, %%"REG_a" \n\t" " js 1b \n\t" : "+a" (mmx_size) : "r" (src-mmx_size), "r"(dst-mmx_size) ); __asm __volatile(SFENCE:::"memory"); __asm __volatile(EMMS:::"memory"); if(mmx_size==23) return; src+= src_size; dst+= src_size; src_size= 23-mmx_size; src-= src_size; dst-= src_size; #endif for(i=0; i<src_size; i+=3) { register uint8_t x; x = src[i + 2]; dst[i + 1] = src[i + 1]; dst[i + 2] = src[i + 0]; dst[i + 0] = x; } }
{ "code": [ "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "static inline void RENAME(rgb24tobgr24)(const uint8_t *src, uint8_t *dst, unsigned int src_size)" ], "line_no": [ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1 ] }
static inline void FUNC_0(rgb24tobgr24)(const uint8_t *src, uint8_t *dst, unsigned int src_size) { unsigned VAR_0; #ifdef HAVE_MMX long mmx_size= 23 - src_size; asm volatile ( "movq "MANGLE(mask24r)", %%mm5 \n\t" "movq "MANGLE(mask24g)", %%mm6 \n\t" "movq "MANGLE(mask24b)", %%mm7 \n\t" ".balign 16 \n\t" "1: \n\t" PREFETCH" 32(%1, %%"REG_a") \n\t" "movq (%1, %%"REG_a"), %%mm0 \n\t" "movq (%1, %%"REG_a"), %%mm1 \n\t" "movq 2(%1, %%"REG_a"), %%mm2 \n\t" "psllq $16, %%mm0 \n\t" "pand %%mm5, %%mm0 \n\t" "pand %%mm6, %%mm1 \n\t" "pand %%mm7, %%mm2 \n\t" "por %%mm0, %%mm1 \n\t" "por %%mm2, %%mm1 \n\t" "movq 6(%1, %%"REG_a"), %%mm0 \n\t" MOVNTQ" %%mm1, (%2, %%"REG_a")\n\t" "movq 8(%1, %%"REG_a"), %%mm1 \n\t" "movq 10(%1, %%"REG_a"), %%mm2 \n\t" "pand %%mm7, %%mm0 \n\t" "pand %%mm5, %%mm1 \n\t" "pand %%mm6, %%mm2 \n\t" "por %%mm0, %%mm1 \n\t" "por %%mm2, %%mm1 \n\t" "movq 14(%1, %%"REG_a"), %%mm0 \n\t" MOVNTQ" %%mm1, 8(%2, %%"REG_a")\n\t" "movq 16(%1, %%"REG_a"), %%mm1 \n\t" "movq 18(%1, %%"REG_a"), %%mm2 \n\t" "pand %%mm6, %%mm0 \n\t" "pand %%mm7, %%mm1 \n\t" "pand %%mm5, %%mm2 \n\t" "por %%mm0, %%mm1 \n\t" "por %%mm2, %%mm1 \n\t" MOVNTQ" %%mm1, 16(%2, %%"REG_a")\n\t" "add $24, %%"REG_a" \n\t" " js 1b \n\t" : "+a" (mmx_size) : "r" (src-mmx_size), "r"(dst-mmx_size) ); __asm __volatile(SFENCE:::"memory"); __asm __volatile(EMMS:::"memory"); if(mmx_size==23) return; src+= src_size; dst+= src_size; src_size= 23-mmx_size; src-= src_size; dst-= src_size; #endif for(VAR_0=0; VAR_0<src_size; VAR_0+=3) { register uint8_t x; x = src[VAR_0 + 2]; dst[VAR_0 + 1] = src[VAR_0 + 1]; dst[VAR_0 + 2] = src[VAR_0 + 0]; dst[VAR_0 + 0] = x; } }
[ "static inline void FUNC_0(rgb24tobgr24)(const uint8_t *src, uint8_t *dst, unsigned int src_size)\n{", "unsigned VAR_0;", "#ifdef HAVE_MMX\nlong mmx_size= 23 - src_size;", "asm volatile (\n\"movq \"MANGLE(mask24r)\", %%mm5\t\\n\\t\"\n\"movq \"MANGLE(mask24g)\", %%mm6\t\\n\\t\"\n\"movq \"MANGLE(mask24b)\", %%mm7\t\\n\\t\"\n\".balign 16\t\t\t\\n\\t\"\n\"1:\t\t\t\t\\n\\t\"\nPREFETCH\" 32(%1, %%\"REG_a\")\t\\n\\t\"\n\"movq (%1, %%\"REG_a\"), %%mm0\t\\n\\t\"\n\"movq (%1, %%\"REG_a\"), %%mm1\t\\n\\t\"\n\"movq 2(%1, %%\"REG_a\"), %%mm2\t\\n\\t\"\n\"psllq $16, %%mm0\t\t\\n\\t\"\n\"pand %%mm5, %%mm0\t\t\\n\\t\"\n\"pand %%mm6, %%mm1\t\t\\n\\t\"\n\"pand %%mm7, %%mm2\t\t\\n\\t\"\n\"por %%mm0, %%mm1\t\t\\n\\t\"\n\"por %%mm2, %%mm1\t\t\\n\\t\"\n\"movq 6(%1, %%\"REG_a\"), %%mm0\t\\n\\t\"\nMOVNTQ\" %%mm1, (%2, %%\"REG_a\")\\n\\t\"\n\"movq 8(%1, %%\"REG_a\"), %%mm1\t\\n\\t\"\n\"movq 10(%1, %%\"REG_a\"), %%mm2\t\\n\\t\"\n\"pand %%mm7, %%mm0\t\t\\n\\t\"\n\"pand %%mm5, %%mm1\t\t\\n\\t\"\n\"pand %%mm6, %%mm2\t\t\\n\\t\"\n\"por %%mm0, %%mm1\t\t\\n\\t\"\n\"por %%mm2, %%mm1\t\t\\n\\t\"\n\"movq 14(%1, %%\"REG_a\"), %%mm0\t\\n\\t\"\nMOVNTQ\" %%mm1, 8(%2, %%\"REG_a\")\\n\\t\"\n\"movq 16(%1, %%\"REG_a\"), %%mm1\t\\n\\t\"\n\"movq 18(%1, %%\"REG_a\"), %%mm2\t\\n\\t\"\n\"pand %%mm6, %%mm0\t\t\\n\\t\"\n\"pand %%mm7, %%mm1\t\t\\n\\t\"\n\"pand %%mm5, %%mm2\t\t\\n\\t\"\n\"por %%mm0, %%mm1\t\t\\n\\t\"\n\"por %%mm2, %%mm1\t\t\\n\\t\"\nMOVNTQ\" %%mm1, 16(%2, %%\"REG_a\")\\n\\t\"\n\"add $24, %%\"REG_a\"\t\t\\n\\t\"\n\" js 1b\t\t\t\t\\n\\t\"\n: \"+a\" (mmx_size)\n: \"r\" (src-mmx_size), \"r\"(dst-mmx_size)\n);", "__asm __volatile(SFENCE:::\"memory\");", "__asm __volatile(EMMS:::\"memory\");", "if(mmx_size==23) return;", "src+= src_size;", "dst+= src_size;", "src_size= 23-mmx_size;", "src-= src_size;", "dst-= src_size;", "#endif\nfor(VAR_0=0; VAR_0<src_size; VAR_0+=3)", "{", "register uint8_t x;", "x = src[VAR_0 + 2];", "dst[VAR_0 + 1] = src[VAR_0 + 1];", "dst[VAR_0 + 2] = src[VAR_0 + 0];", "dst[VAR_0 + 0] = x;", "}", "}" ]
[ 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7, 9 ], [ 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89 ], [ 93 ], [ 95 ], [ 99 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113, 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ] ]
12,498
static void ff_amf_tag_contents(void *ctx, const uint8_t *data, const uint8_t *data_end) { int size; char buf[1024]; if (data >= data_end) return; switch (*data++) { case AMF_DATA_TYPE_NUMBER: av_log(ctx, AV_LOG_DEBUG, " number %g\n", av_int2double(AV_RB64(data))); return; case AMF_DATA_TYPE_BOOL: av_log(ctx, AV_LOG_DEBUG, " bool %d\n", *data); return; case AMF_DATA_TYPE_STRING: case AMF_DATA_TYPE_LONG_STRING: if (data[-1] == AMF_DATA_TYPE_STRING) { size = bytestream_get_be16(&data); } else { size = bytestream_get_be32(&data); } size = FFMIN(size, 1023); memcpy(buf, data, size); buf[size] = 0; av_log(ctx, AV_LOG_DEBUG, " string '%s'\n", buf); return; case AMF_DATA_TYPE_NULL: av_log(ctx, AV_LOG_DEBUG, " NULL\n"); return; case AMF_DATA_TYPE_ARRAY: data += 4; case AMF_DATA_TYPE_OBJECT: av_log(ctx, AV_LOG_DEBUG, " {\n"); for (;;) { int size = bytestream_get_be16(&data); int t; memcpy(buf, data, size); buf[size] = 0; if (!size) { av_log(ctx, AV_LOG_DEBUG, " }\n"); data++; break; } if (size < 0 || size >= data_end - data) return; data += size; av_log(ctx, AV_LOG_DEBUG, " %s: ", buf); ff_amf_tag_contents(ctx, data, data_end); t = ff_amf_tag_size(data, data_end); if (t < 0 || t >= data_end - data) return; data += t; } return; case AMF_DATA_TYPE_OBJECT_END: av_log(ctx, AV_LOG_DEBUG, " }\n"); return; default: return; } }
true
FFmpeg
ecb918e5f0a4395468862b5fbd11a51de9be3d4f
static void ff_amf_tag_contents(void *ctx, const uint8_t *data, const uint8_t *data_end) { int size; char buf[1024]; if (data >= data_end) return; switch (*data++) { case AMF_DATA_TYPE_NUMBER: av_log(ctx, AV_LOG_DEBUG, " number %g\n", av_int2double(AV_RB64(data))); return; case AMF_DATA_TYPE_BOOL: av_log(ctx, AV_LOG_DEBUG, " bool %d\n", *data); return; case AMF_DATA_TYPE_STRING: case AMF_DATA_TYPE_LONG_STRING: if (data[-1] == AMF_DATA_TYPE_STRING) { size = bytestream_get_be16(&data); } else { size = bytestream_get_be32(&data); } size = FFMIN(size, 1023); memcpy(buf, data, size); buf[size] = 0; av_log(ctx, AV_LOG_DEBUG, " string '%s'\n", buf); return; case AMF_DATA_TYPE_NULL: av_log(ctx, AV_LOG_DEBUG, " NULL\n"); return; case AMF_DATA_TYPE_ARRAY: data += 4; case AMF_DATA_TYPE_OBJECT: av_log(ctx, AV_LOG_DEBUG, " {\n"); for (;;) { int size = bytestream_get_be16(&data); int t; memcpy(buf, data, size); buf[size] = 0; if (!size) { av_log(ctx, AV_LOG_DEBUG, " }\n"); data++; break; } if (size < 0 || size >= data_end - data) return; data += size; av_log(ctx, AV_LOG_DEBUG, " %s: ", buf); ff_amf_tag_contents(ctx, data, data_end); t = ff_amf_tag_size(data, data_end); if (t < 0 || t >= data_end - data) return; data += t; } return; case AMF_DATA_TYPE_OBJECT_END: av_log(ctx, AV_LOG_DEBUG, " }\n"); return; default: return; } }
{ "code": [ " int size;", " size = FFMIN(size, 1023);", " int size = bytestream_get_be16(&data);", " memcpy(buf, data, size);", " buf[size] = 0;", " if (size < 0 || size >= data_end - data)" ], "line_no": [ 5, 43, 69, 73, 75, 87 ] }
static void FUNC_0(void *VAR_0, const uint8_t *VAR_1, const uint8_t *VAR_2) { int VAR_5; char VAR_4[1024]; if (VAR_1 >= VAR_2) return; switch (*VAR_1++) { case AMF_DATA_TYPE_NUMBER: av_log(VAR_0, AV_LOG_DEBUG, " number %g\n", av_int2double(AV_RB64(VAR_1))); return; case AMF_DATA_TYPE_BOOL: av_log(VAR_0, AV_LOG_DEBUG, " bool %d\n", *VAR_1); return; case AMF_DATA_TYPE_STRING: case AMF_DATA_TYPE_LONG_STRING: if (VAR_1[-1] == AMF_DATA_TYPE_STRING) { VAR_5 = bytestream_get_be16(&VAR_1); } else { VAR_5 = bytestream_get_be32(&VAR_1); } VAR_5 = FFMIN(VAR_5, 1023); memcpy(VAR_4, VAR_1, VAR_5); VAR_4[VAR_5] = 0; av_log(VAR_0, AV_LOG_DEBUG, " string '%s'\n", VAR_4); return; case AMF_DATA_TYPE_NULL: av_log(VAR_0, AV_LOG_DEBUG, " NULL\n"); return; case AMF_DATA_TYPE_ARRAY: VAR_1 += 4; case AMF_DATA_TYPE_OBJECT: av_log(VAR_0, AV_LOG_DEBUG, " {\n"); for (;;) { int VAR_5 = bytestream_get_be16(&VAR_1); int VAR_5; memcpy(VAR_4, VAR_1, VAR_5); VAR_4[VAR_5] = 0; if (!VAR_5) { av_log(VAR_0, AV_LOG_DEBUG, " }\n"); VAR_1++; break; } if (VAR_5 < 0 || VAR_5 >= VAR_2 - VAR_1) return; VAR_1 += VAR_5; av_log(VAR_0, AV_LOG_DEBUG, " %s: ", VAR_4); FUNC_0(VAR_0, VAR_1, VAR_2); VAR_5 = ff_amf_tag_size(VAR_1, VAR_2); if (VAR_5 < 0 || VAR_5 >= VAR_2 - VAR_1) return; VAR_1 += VAR_5; } return; case AMF_DATA_TYPE_OBJECT_END: av_log(VAR_0, AV_LOG_DEBUG, " }\n"); return; default: return; } }
[ "static void FUNC_0(void *VAR_0, const uint8_t *VAR_1, const uint8_t *VAR_2)\n{", "int VAR_5;", "char VAR_4[1024];", "if (VAR_1 >= VAR_2)\nreturn;", "switch (*VAR_1++) {", "case AMF_DATA_TYPE_NUMBER:\nav_log(VAR_0, AV_LOG_DEBUG, \" number %g\\n\", av_int2double(AV_RB64(VAR_1)));", "return;", "case AMF_DATA_TYPE_BOOL:\nav_log(VAR_0, AV_LOG_DEBUG, \" bool %d\\n\", *VAR_1);", "return;", "case AMF_DATA_TYPE_STRING:\ncase AMF_DATA_TYPE_LONG_STRING:\nif (VAR_1[-1] == AMF_DATA_TYPE_STRING) {", "VAR_5 = bytestream_get_be16(&VAR_1);", "} else {", "VAR_5 = bytestream_get_be32(&VAR_1);", "}", "VAR_5 = FFMIN(VAR_5, 1023);", "memcpy(VAR_4, VAR_1, VAR_5);", "VAR_4[VAR_5] = 0;", "av_log(VAR_0, AV_LOG_DEBUG, \" string '%s'\\n\", VAR_4);", "return;", "case AMF_DATA_TYPE_NULL:\nav_log(VAR_0, AV_LOG_DEBUG, \" NULL\\n\");", "return;", "case AMF_DATA_TYPE_ARRAY:\nVAR_1 += 4;", "case AMF_DATA_TYPE_OBJECT:\nav_log(VAR_0, AV_LOG_DEBUG, \" {\\n\");", "for (;;) {", "int VAR_5 = bytestream_get_be16(&VAR_1);", "int VAR_5;", "memcpy(VAR_4, VAR_1, VAR_5);", "VAR_4[VAR_5] = 0;", "if (!VAR_5) {", "av_log(VAR_0, AV_LOG_DEBUG, \" }\\n\");", "VAR_1++;", "break;", "}", "if (VAR_5 < 0 || VAR_5 >= VAR_2 - VAR_1)\nreturn;", "VAR_1 += VAR_5;", "av_log(VAR_0, AV_LOG_DEBUG, \" %s: \", VAR_4);", "FUNC_0(VAR_0, VAR_1, VAR_2);", "VAR_5 = ff_amf_tag_size(VAR_1, VAR_2);", "if (VAR_5 < 0 || VAR_5 >= VAR_2 - VAR_1)\nreturn;", "VAR_1 += VAR_5;", "}", "return;", "case AMF_DATA_TYPE_OBJECT_END:\nav_log(VAR_0, AV_LOG_DEBUG, \" }\\n\");", "return;", "default:\nreturn;", "}", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11, 13 ], [ 15 ], [ 17, 19 ], [ 21 ], [ 23, 25 ], [ 27 ], [ 29, 31, 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53, 55 ], [ 57 ], [ 59, 61 ], [ 63, 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87, 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99, 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109, 111 ], [ 113 ], [ 115, 117 ], [ 119 ], [ 121 ] ]
12,500
static int mov_read_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom, enum AVCodecID codec_id) { AVStream *st; uint64_t size; uint8_t *buf; int err; if (c->fc->nb_streams < 1) // will happen with jp2 files return 0; st= c->fc->streams[c->fc->nb_streams-1]; if (st->codec->codec_id != codec_id) return 0; /* unexpected codec_id - don't mess with extradata */ size= (uint64_t)st->codec->extradata_size + atom.size + 8 + FF_INPUT_BUFFER_PADDING_SIZE; if (size > INT_MAX || (uint64_t)atom.size > INT_MAX) return AVERROR_INVALIDDATA; if ((err = av_reallocp(&st->codec->extradata, size)) < 0) return err; buf = st->codec->extradata + st->codec->extradata_size; st->codec->extradata_size= size - FF_INPUT_BUFFER_PADDING_SIZE; AV_WB32( buf , atom.size + 8); AV_WL32( buf + 4, atom.type); avio_read(pb, buf + 8, atom.size); return 0; }
true
FFmpeg
a5cbf1991c3d04b0be3c23ee0a7096b5a365cc85
static int mov_read_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom, enum AVCodecID codec_id) { AVStream *st; uint64_t size; uint8_t *buf; int err; if (c->fc->nb_streams < 1) return 0; st= c->fc->streams[c->fc->nb_streams-1]; if (st->codec->codec_id != codec_id) return 0; size= (uint64_t)st->codec->extradata_size + atom.size + 8 + FF_INPUT_BUFFER_PADDING_SIZE; if (size > INT_MAX || (uint64_t)atom.size > INT_MAX) return AVERROR_INVALIDDATA; if ((err = av_reallocp(&st->codec->extradata, size)) < 0) return err; buf = st->codec->extradata + st->codec->extradata_size; st->codec->extradata_size= size - FF_INPUT_BUFFER_PADDING_SIZE; AV_WB32( buf , atom.size + 8); AV_WL32( buf + 4, atom.type); avio_read(pb, buf + 8, atom.size); return 0; }
{ "code": [ " if ((err = av_reallocp(&st->codec->extradata, size)) < 0)" ], "line_no": [ 37 ] }
static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2, enum AVCodecID VAR_3) { AVStream *st; uint64_t size; uint8_t *buf; int VAR_4; if (VAR_0->fc->nb_streams < 1) return 0; st= VAR_0->fc->streams[VAR_0->fc->nb_streams-1]; if (st->codec->VAR_3 != VAR_3) return 0; size= (uint64_t)st->codec->extradata_size + VAR_2.size + 8 + FF_INPUT_BUFFER_PADDING_SIZE; if (size > INT_MAX || (uint64_t)VAR_2.size > INT_MAX) return AVERROR_INVALIDDATA; if ((VAR_4 = av_reallocp(&st->codec->extradata, size)) < 0) return VAR_4; buf = st->codec->extradata + st->codec->extradata_size; st->codec->extradata_size= size - FF_INPUT_BUFFER_PADDING_SIZE; AV_WB32( buf , VAR_2.size + 8); AV_WL32( buf + 4, VAR_2.type); avio_read(VAR_1, buf + 8, VAR_2.size); return 0; }
[ "static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2,\nenum AVCodecID VAR_3)\n{", "AVStream *st;", "uint64_t size;", "uint8_t *buf;", "int VAR_4;", "if (VAR_0->fc->nb_streams < 1)\nreturn 0;", "st= VAR_0->fc->streams[VAR_0->fc->nb_streams-1];", "if (st->codec->VAR_3 != VAR_3)\nreturn 0;", "size= (uint64_t)st->codec->extradata_size + VAR_2.size + 8 + FF_INPUT_BUFFER_PADDING_SIZE;", "if (size > INT_MAX || (uint64_t)VAR_2.size > INT_MAX)\nreturn AVERROR_INVALIDDATA;", "if ((VAR_4 = av_reallocp(&st->codec->extradata, size)) < 0)\nreturn VAR_4;", "buf = st->codec->extradata + st->codec->extradata_size;", "st->codec->extradata_size= size - FF_INPUT_BUFFER_PADDING_SIZE;", "AV_WB32( buf , VAR_2.size + 8);", "AV_WL32( buf + 4, VAR_2.type);", "avio_read(VAR_1, buf + 8, VAR_2.size);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17, 19 ], [ 21 ], [ 25, 27 ], [ 31 ], [ 33, 35 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ] ]
12,501
int ff_h263_decode_picture_header(MpegEncContext *s) { int format, width, height, i; uint32_t startcode; align_get_bits(&s->gb); startcode= get_bits(&s->gb, 22-8); for(i= get_bits_left(&s->gb); i>24; i-=8) { startcode = ((startcode << 8) | get_bits(&s->gb, 8)) & 0x003FFFFF; if(startcode == 0x20) break; } if (startcode != 0x20) { av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n"); return -1; } /* temporal reference */ i = get_bits(&s->gb, 8); /* picture timestamp */ if( (s->picture_number&~0xFF)+i < s->picture_number) i+= 256; s->current_picture_ptr->f.pts = s->picture_number= (s->picture_number&~0xFF) + i; /* PTYPE starts here */ if (get_bits1(&s->gb) != 1) { /* marker */ av_log(s->avctx, AV_LOG_ERROR, "Bad marker\n"); return -1; } if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "Bad H263 id\n"); return -1; /* h263 id */ } skip_bits1(&s->gb); /* split screen off */ skip_bits1(&s->gb); /* camera off */ skip_bits1(&s->gb); /* freeze picture release off */ format = get_bits(&s->gb, 3); /* 0 forbidden 1 sub-QCIF 10 QCIF 7 extended PTYPE (PLUSPTYPE) */ if (format != 7 && format != 6) { s->h263_plus = 0; /* H.263v1 */ width = ff_h263_format[format][0]; height = ff_h263_format[format][1]; if (!width) return -1; s->pict_type = AV_PICTURE_TYPE_I + get_bits1(&s->gb); s->h263_long_vectors = get_bits1(&s->gb); if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "H263 SAC not supported\n"); return -1; /* SAC: off */ } s->obmc= get_bits1(&s->gb); /* Advanced prediction mode */ s->unrestricted_mv = s->h263_long_vectors || s->obmc; s->pb_frame = get_bits1(&s->gb); s->chroma_qscale= s->qscale = get_bits(&s->gb, 5); skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */ s->width = width; s->height = height; s->avctx->sample_aspect_ratio= (AVRational){12,11}; s->avctx->time_base= (AVRational){1001, 30000}; } else { int ufep; /* H.263v2 */ s->h263_plus = 1; ufep = get_bits(&s->gb, 3); /* Update Full Extended PTYPE */ /* ufep other than 0 and 1 are reserved */ if (ufep == 1) { /* OPPTYPE */ format = get_bits(&s->gb, 3); av_dlog(s->avctx, "ufep=1, format: %d\n", format); s->custom_pcf= get_bits1(&s->gb); s->umvplus = get_bits1(&s->gb); /* Unrestricted Motion Vector */ if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "Syntax-based Arithmetic Coding (SAC) not supported\n"); } s->obmc= get_bits1(&s->gb); /* Advanced prediction mode */ s->h263_aic = get_bits1(&s->gb); /* Advanced Intra Coding (AIC) */ s->loop_filter= get_bits1(&s->gb); s->unrestricted_mv = s->umvplus || s->obmc || s->loop_filter; s->h263_slice_structured= get_bits1(&s->gb); if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "Reference Picture Selection not supported\n"); } if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "Independent Segment Decoding not supported\n"); } s->alt_inter_vlc= get_bits1(&s->gb); s->modified_quant= get_bits1(&s->gb); if(s->modified_quant) s->chroma_qscale_table= ff_h263_chroma_qscale_table; skip_bits(&s->gb, 1); /* Prevent start code emulation */ skip_bits(&s->gb, 3); /* Reserved */ } else if (ufep != 0) { av_log(s->avctx, AV_LOG_ERROR, "Bad UFEP type (%d)\n", ufep); return -1; } /* MPPTYPE */ s->pict_type = get_bits(&s->gb, 3); switch(s->pict_type){ case 0: s->pict_type= AV_PICTURE_TYPE_I;break; case 1: s->pict_type= AV_PICTURE_TYPE_P;break; case 2: s->pict_type= AV_PICTURE_TYPE_P;s->pb_frame = 3;break; case 3: s->pict_type= AV_PICTURE_TYPE_B;break; case 7: s->pict_type= AV_PICTURE_TYPE_I;break; //ZYGO default: return -1; } skip_bits(&s->gb, 2); s->no_rounding = get_bits1(&s->gb); skip_bits(&s->gb, 4); /* Get the picture dimensions */ if (ufep) { if (format == 6) { /* Custom Picture Format (CPFMT) */ s->aspect_ratio_info = get_bits(&s->gb, 4); av_dlog(s->avctx, "aspect: %d\n", s->aspect_ratio_info); /* aspect ratios: 0 - forbidden 1 - 1:1 2 - 12:11 (CIF 4:3) 3 - 10:11 (525-type 4:3) 4 - 16:11 (CIF 16:9) 5 - 40:33 (525-type 16:9) 6-14 - reserved */ width = (get_bits(&s->gb, 9) + 1) * 4; skip_bits1(&s->gb); height = get_bits(&s->gb, 9) * 4; av_dlog(s->avctx, "\nH.263+ Custom picture: %dx%d\n",width,height); if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) { /* aspected dimensions */ s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 8); s->avctx->sample_aspect_ratio.den= get_bits(&s->gb, 8); }else{ s->avctx->sample_aspect_ratio= ff_h263_pixel_aspect[s->aspect_ratio_info]; } } else { width = ff_h263_format[format][0]; height = ff_h263_format[format][1]; s->avctx->sample_aspect_ratio= (AVRational){12,11}; } if ((width == 0) || (height == 0)) return -1; s->width = width; s->height = height; if(s->custom_pcf){ int gcd; s->avctx->time_base.den= 1800000; s->avctx->time_base.num= 1000 + get_bits1(&s->gb); s->avctx->time_base.num*= get_bits(&s->gb, 7); if(s->avctx->time_base.num == 0){ av_log(s, AV_LOG_ERROR, "zero framerate\n"); return -1; } gcd= av_gcd(s->avctx->time_base.den, s->avctx->time_base.num); s->avctx->time_base.den /= gcd; s->avctx->time_base.num /= gcd; }else{ s->avctx->time_base= (AVRational){1001, 30000}; } } if(s->custom_pcf){ skip_bits(&s->gb, 2); //extended Temporal reference } if (ufep) { if (s->umvplus) { if(get_bits1(&s->gb)==0) /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */ skip_bits1(&s->gb); } if(s->h263_slice_structured){ if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "rectangular slices not supported\n"); } if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "unordered slices not supported\n"); } } } s->qscale = get_bits(&s->gb, 5); } s->mb_width = (s->width + 15) / 16; s->mb_height = (s->height + 15) / 16; s->mb_num = s->mb_width * s->mb_height; if (s->pb_frame) { skip_bits(&s->gb, 3); /* Temporal reference for B-pictures */ if (s->custom_pcf) skip_bits(&s->gb, 2); //extended Temporal reference skip_bits(&s->gb, 2); /* Quantization information for B-pictures */ } /* PEI */ while (get_bits1(&s->gb) != 0) { skip_bits(&s->gb, 8); } if(s->h263_slice_structured){ if (get_bits1(&s->gb) != 1) { av_log(s->avctx, AV_LOG_ERROR, "SEPB1 marker missing\n"); return -1; } ff_h263_decode_mba(s); if (get_bits1(&s->gb) != 1) { av_log(s->avctx, AV_LOG_ERROR, "SEPB2 marker missing\n"); return -1; } } s->f_code = 1; if(s->h263_aic){ s->y_dc_scale_table= s->c_dc_scale_table= ff_aic_dc_scale_table; }else{ s->y_dc_scale_table= s->c_dc_scale_table= ff_mpeg1_dc_scale_table; } ff_h263_show_pict_info(s); if (s->pict_type == AV_PICTURE_TYPE_I && s->codec_tag == AV_RL32("ZYGO")){ int i,j; for(i=0; i<85; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb)); av_log(s->avctx, AV_LOG_DEBUG, "\n"); for(i=0; i<13; i++){ for(j=0; j<3; j++){ int v= get_bits(&s->gb, 8); v |= get_sbits(&s->gb, 8)<<8; av_log(s->avctx, AV_LOG_DEBUG, " %5d", v); } av_log(s->avctx, AV_LOG_DEBUG, "\n"); } for(i=0; i<50; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb)); } return 0; }
true
FFmpeg
e93d911e483ffcf3da3dd2cbac2895fa061d2f58
int ff_h263_decode_picture_header(MpegEncContext *s) { int format, width, height, i; uint32_t startcode; align_get_bits(&s->gb); startcode= get_bits(&s->gb, 22-8); for(i= get_bits_left(&s->gb); i>24; i-=8) { startcode = ((startcode << 8) | get_bits(&s->gb, 8)) & 0x003FFFFF; if(startcode == 0x20) break; } if (startcode != 0x20) { av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n"); return -1; } i = get_bits(&s->gb, 8); if( (s->picture_number&~0xFF)+i < s->picture_number) i+= 256; s->current_picture_ptr->f.pts = s->picture_number= (s->picture_number&~0xFF) + i; if (get_bits1(&s->gb) != 1) { av_log(s->avctx, AV_LOG_ERROR, "Bad marker\n"); return -1; } if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "Bad H263 id\n"); return -1; } skip_bits1(&s->gb); skip_bits1(&s->gb); skip_bits1(&s->gb); format = get_bits(&s->gb, 3); if (format != 7 && format != 6) { s->h263_plus = 0; width = ff_h263_format[format][0]; height = ff_h263_format[format][1]; if (!width) return -1; s->pict_type = AV_PICTURE_TYPE_I + get_bits1(&s->gb); s->h263_long_vectors = get_bits1(&s->gb); if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "H263 SAC not supported\n"); return -1; } s->obmc= get_bits1(&s->gb); s->unrestricted_mv = s->h263_long_vectors || s->obmc; s->pb_frame = get_bits1(&s->gb); s->chroma_qscale= s->qscale = get_bits(&s->gb, 5); skip_bits1(&s->gb); s->width = width; s->height = height; s->avctx->sample_aspect_ratio= (AVRational){12,11}; s->avctx->time_base= (AVRational){1001, 30000}; } else { int ufep; s->h263_plus = 1; ufep = get_bits(&s->gb, 3); if (ufep == 1) { format = get_bits(&s->gb, 3); av_dlog(s->avctx, "ufep=1, format: %d\n", format); s->custom_pcf= get_bits1(&s->gb); s->umvplus = get_bits1(&s->gb); if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "Syntax-based Arithmetic Coding (SAC) not supported\n"); } s->obmc= get_bits1(&s->gb); s->h263_aic = get_bits1(&s->gb); s->loop_filter= get_bits1(&s->gb); s->unrestricted_mv = s->umvplus || s->obmc || s->loop_filter; s->h263_slice_structured= get_bits1(&s->gb); if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "Reference Picture Selection not supported\n"); } if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "Independent Segment Decoding not supported\n"); } s->alt_inter_vlc= get_bits1(&s->gb); s->modified_quant= get_bits1(&s->gb); if(s->modified_quant) s->chroma_qscale_table= ff_h263_chroma_qscale_table; skip_bits(&s->gb, 1); skip_bits(&s->gb, 3); } else if (ufep != 0) { av_log(s->avctx, AV_LOG_ERROR, "Bad UFEP type (%d)\n", ufep); return -1; } s->pict_type = get_bits(&s->gb, 3); switch(s->pict_type){ case 0: s->pict_type= AV_PICTURE_TYPE_I;break; case 1: s->pict_type= AV_PICTURE_TYPE_P;break; case 2: s->pict_type= AV_PICTURE_TYPE_P;s->pb_frame = 3;break; case 3: s->pict_type= AV_PICTURE_TYPE_B;break; case 7: s->pict_type= AV_PICTURE_TYPE_I;break; default: return -1; } skip_bits(&s->gb, 2); s->no_rounding = get_bits1(&s->gb); skip_bits(&s->gb, 4); if (ufep) { if (format == 6) { s->aspect_ratio_info = get_bits(&s->gb, 4); av_dlog(s->avctx, "aspect: %d\n", s->aspect_ratio_info); width = (get_bits(&s->gb, 9) + 1) * 4; skip_bits1(&s->gb); height = get_bits(&s->gb, 9) * 4; av_dlog(s->avctx, "\nH.263+ Custom picture: %dx%d\n",width,height); if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) { s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 8); s->avctx->sample_aspect_ratio.den= get_bits(&s->gb, 8); }else{ s->avctx->sample_aspect_ratio= ff_h263_pixel_aspect[s->aspect_ratio_info]; } } else { width = ff_h263_format[format][0]; height = ff_h263_format[format][1]; s->avctx->sample_aspect_ratio= (AVRational){12,11}; } if ((width == 0) || (height == 0)) return -1; s->width = width; s->height = height; if(s->custom_pcf){ int gcd; s->avctx->time_base.den= 1800000; s->avctx->time_base.num= 1000 + get_bits1(&s->gb); s->avctx->time_base.num*= get_bits(&s->gb, 7); if(s->avctx->time_base.num == 0){ av_log(s, AV_LOG_ERROR, "zero framerate\n"); return -1; } gcd= av_gcd(s->avctx->time_base.den, s->avctx->time_base.num); s->avctx->time_base.den /= gcd; s->avctx->time_base.num /= gcd; }else{ s->avctx->time_base= (AVRational){1001, 30000}; } } if(s->custom_pcf){ skip_bits(&s->gb, 2); } if (ufep) { if (s->umvplus) { if(get_bits1(&s->gb)==0) skip_bits1(&s->gb); } if(s->h263_slice_structured){ if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "rectangular slices not supported\n"); } if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "unordered slices not supported\n"); } } } s->qscale = get_bits(&s->gb, 5); } s->mb_width = (s->width + 15) / 16; s->mb_height = (s->height + 15) / 16; s->mb_num = s->mb_width * s->mb_height; if (s->pb_frame) { skip_bits(&s->gb, 3); if (s->custom_pcf) skip_bits(&s->gb, 2); skip_bits(&s->gb, 2); } while (get_bits1(&s->gb) != 0) { skip_bits(&s->gb, 8); } if(s->h263_slice_structured){ if (get_bits1(&s->gb) != 1) { av_log(s->avctx, AV_LOG_ERROR, "SEPB1 marker missing\n"); return -1; } ff_h263_decode_mba(s); if (get_bits1(&s->gb) != 1) { av_log(s->avctx, AV_LOG_ERROR, "SEPB2 marker missing\n"); return -1; } } s->f_code = 1; if(s->h263_aic){ s->y_dc_scale_table= s->c_dc_scale_table= ff_aic_dc_scale_table; }else{ s->y_dc_scale_table= s->c_dc_scale_table= ff_mpeg1_dc_scale_table; } ff_h263_show_pict_info(s); if (s->pict_type == AV_PICTURE_TYPE_I && s->codec_tag == AV_RL32("ZYGO")){ int i,j; for(i=0; i<85; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb)); av_log(s->avctx, AV_LOG_DEBUG, "\n"); for(i=0; i<13; i++){ for(j=0; j<3; j++){ int v= get_bits(&s->gb, 8); v |= get_sbits(&s->gb, 8)<<8; av_log(s->avctx, AV_LOG_DEBUG, " %5d", v); } av_log(s->avctx, AV_LOG_DEBUG, "\n"); } for(i=0; i<50; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb)); } return 0; }
{ "code": [ " if (s->pict_type == AV_PICTURE_TYPE_I && s->codec_tag == AV_RL32(\"ZYGO\")){" ], "line_no": [ 497 ] }
int FUNC_0(MpegEncContext *VAR_0) { int VAR_1, VAR_2, VAR_3, VAR_7; uint32_t startcode; align_get_bits(&VAR_0->gb); startcode= get_bits(&VAR_0->gb, 22-8); for(VAR_7= get_bits_left(&VAR_0->gb); VAR_7>24; VAR_7-=8) { startcode = ((startcode << 8) | get_bits(&VAR_0->gb, 8)) & 0x003FFFFF; if(startcode == 0x20) break; } if (startcode != 0x20) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Bad picture start code\n"); return -1; } VAR_7 = get_bits(&VAR_0->gb, 8); if( (VAR_0->picture_number&~0xFF)+VAR_7 < VAR_0->picture_number) VAR_7+= 256; VAR_0->current_picture_ptr->f.pts = VAR_0->picture_number= (VAR_0->picture_number&~0xFF) + VAR_7; if (get_bits1(&VAR_0->gb) != 1) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Bad marker\n"); return -1; } if (get_bits1(&VAR_0->gb) != 0) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Bad H263 id\n"); return -1; } skip_bits1(&VAR_0->gb); skip_bits1(&VAR_0->gb); skip_bits1(&VAR_0->gb); VAR_1 = get_bits(&VAR_0->gb, 3); if (VAR_1 != 7 && VAR_1 != 6) { VAR_0->h263_plus = 0; VAR_2 = ff_h263_format[VAR_1][0]; VAR_3 = ff_h263_format[VAR_1][1]; if (!VAR_2) return -1; VAR_0->pict_type = AV_PICTURE_TYPE_I + get_bits1(&VAR_0->gb); VAR_0->h263_long_vectors = get_bits1(&VAR_0->gb); if (get_bits1(&VAR_0->gb) != 0) { av_log(VAR_0->avctx, AV_LOG_ERROR, "H263 SAC not supported\n"); return -1; } VAR_0->obmc= get_bits1(&VAR_0->gb); VAR_0->unrestricted_mv = VAR_0->h263_long_vectors || VAR_0->obmc; VAR_0->pb_frame = get_bits1(&VAR_0->gb); VAR_0->chroma_qscale= VAR_0->qscale = get_bits(&VAR_0->gb, 5); skip_bits1(&VAR_0->gb); VAR_0->VAR_2 = VAR_2; VAR_0->VAR_3 = VAR_3; VAR_0->avctx->sample_aspect_ratio= (AVRational){12,11}; VAR_0->avctx->time_base= (AVRational){1001, 30000}; } else { int VAR_5; VAR_0->h263_plus = 1; VAR_5 = get_bits(&VAR_0->gb, 3); if (VAR_5 == 1) { VAR_1 = get_bits(&VAR_0->gb, 3); av_dlog(VAR_0->avctx, "VAR_5=1, VAR_1: %d\n", VAR_1); VAR_0->custom_pcf= get_bits1(&VAR_0->gb); VAR_0->umvplus = get_bits1(&VAR_0->gb); if (get_bits1(&VAR_0->gb) != 0) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Syntax-based Arithmetic Coding (SAC) not supported\n"); } VAR_0->obmc= get_bits1(&VAR_0->gb); VAR_0->h263_aic = get_bits1(&VAR_0->gb); VAR_0->loop_filter= get_bits1(&VAR_0->gb); VAR_0->unrestricted_mv = VAR_0->umvplus || VAR_0->obmc || VAR_0->loop_filter; VAR_0->h263_slice_structured= get_bits1(&VAR_0->gb); if (get_bits1(&VAR_0->gb) != 0) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Reference Picture Selection not supported\n"); } if (get_bits1(&VAR_0->gb) != 0) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Independent Segment Decoding not supported\n"); } VAR_0->alt_inter_vlc= get_bits1(&VAR_0->gb); VAR_0->modified_quant= get_bits1(&VAR_0->gb); if(VAR_0->modified_quant) VAR_0->chroma_qscale_table= ff_h263_chroma_qscale_table; skip_bits(&VAR_0->gb, 1); skip_bits(&VAR_0->gb, 3); } else if (VAR_5 != 0) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Bad UFEP type (%d)\n", VAR_5); return -1; } VAR_0->pict_type = get_bits(&VAR_0->gb, 3); switch(VAR_0->pict_type){ case 0: VAR_0->pict_type= AV_PICTURE_TYPE_I;break; case 1: VAR_0->pict_type= AV_PICTURE_TYPE_P;break; case 2: VAR_0->pict_type= AV_PICTURE_TYPE_P;VAR_0->pb_frame = 3;break; case 3: VAR_0->pict_type= AV_PICTURE_TYPE_B;break; case 7: VAR_0->pict_type= AV_PICTURE_TYPE_I;break; default: return -1; } skip_bits(&VAR_0->gb, 2); VAR_0->no_rounding = get_bits1(&VAR_0->gb); skip_bits(&VAR_0->gb, 4); if (VAR_5) { if (VAR_1 == 6) { VAR_0->aspect_ratio_info = get_bits(&VAR_0->gb, 4); av_dlog(VAR_0->avctx, "aspect: %d\n", VAR_0->aspect_ratio_info); VAR_2 = (get_bits(&VAR_0->gb, 9) + 1) * 4; skip_bits1(&VAR_0->gb); VAR_3 = get_bits(&VAR_0->gb, 9) * 4; av_dlog(VAR_0->avctx, "\nH.263+ Custom picture: %dx%d\n",VAR_2,VAR_3); if (VAR_0->aspect_ratio_info == FF_ASPECT_EXTENDED) { VAR_0->avctx->sample_aspect_ratio.num= get_bits(&VAR_0->gb, 8); VAR_0->avctx->sample_aspect_ratio.den= get_bits(&VAR_0->gb, 8); }else{ VAR_0->avctx->sample_aspect_ratio= ff_h263_pixel_aspect[VAR_0->aspect_ratio_info]; } } else { VAR_2 = ff_h263_format[VAR_1][0]; VAR_3 = ff_h263_format[VAR_1][1]; VAR_0->avctx->sample_aspect_ratio= (AVRational){12,11}; } if ((VAR_2 == 0) || (VAR_3 == 0)) return -1; VAR_0->VAR_2 = VAR_2; VAR_0->VAR_3 = VAR_3; if(VAR_0->custom_pcf){ int VAR_6; VAR_0->avctx->time_base.den= 1800000; VAR_0->avctx->time_base.num= 1000 + get_bits1(&VAR_0->gb); VAR_0->avctx->time_base.num*= get_bits(&VAR_0->gb, 7); if(VAR_0->avctx->time_base.num == 0){ av_log(VAR_0, AV_LOG_ERROR, "zero framerate\n"); return -1; } VAR_6= av_gcd(VAR_0->avctx->time_base.den, VAR_0->avctx->time_base.num); VAR_0->avctx->time_base.den /= VAR_6; VAR_0->avctx->time_base.num /= VAR_6; }else{ VAR_0->avctx->time_base= (AVRational){1001, 30000}; } } if(VAR_0->custom_pcf){ skip_bits(&VAR_0->gb, 2); } if (VAR_5) { if (VAR_0->umvplus) { if(get_bits1(&VAR_0->gb)==0) skip_bits1(&VAR_0->gb); } if(VAR_0->h263_slice_structured){ if (get_bits1(&VAR_0->gb) != 0) { av_log(VAR_0->avctx, AV_LOG_ERROR, "rectangular slices not supported\n"); } if (get_bits1(&VAR_0->gb) != 0) { av_log(VAR_0->avctx, AV_LOG_ERROR, "unordered slices not supported\n"); } } } VAR_0->qscale = get_bits(&VAR_0->gb, 5); } VAR_0->mb_width = (VAR_0->VAR_2 + 15) / 16; VAR_0->mb_height = (VAR_0->VAR_3 + 15) / 16; VAR_0->mb_num = VAR_0->mb_width * VAR_0->mb_height; if (VAR_0->pb_frame) { skip_bits(&VAR_0->gb, 3); if (VAR_0->custom_pcf) skip_bits(&VAR_0->gb, 2); skip_bits(&VAR_0->gb, 2); } while (get_bits1(&VAR_0->gb) != 0) { skip_bits(&VAR_0->gb, 8); } if(VAR_0->h263_slice_structured){ if (get_bits1(&VAR_0->gb) != 1) { av_log(VAR_0->avctx, AV_LOG_ERROR, "SEPB1 marker missing\n"); return -1; } ff_h263_decode_mba(VAR_0); if (get_bits1(&VAR_0->gb) != 1) { av_log(VAR_0->avctx, AV_LOG_ERROR, "SEPB2 marker missing\n"); return -1; } } VAR_0->f_code = 1; if(VAR_0->h263_aic){ VAR_0->y_dc_scale_table= VAR_0->c_dc_scale_table= ff_aic_dc_scale_table; }else{ VAR_0->y_dc_scale_table= VAR_0->c_dc_scale_table= ff_mpeg1_dc_scale_table; } ff_h263_show_pict_info(VAR_0); if (VAR_0->pict_type == AV_PICTURE_TYPE_I && VAR_0->codec_tag == AV_RL32("ZYGO")){ int VAR_7,VAR_7; for(VAR_7=0; VAR_7<85; VAR_7++) av_log(VAR_0->avctx, AV_LOG_DEBUG, "%d", get_bits1(&VAR_0->gb)); av_log(VAR_0->avctx, AV_LOG_DEBUG, "\n"); for(VAR_7=0; VAR_7<13; VAR_7++){ for(VAR_7=0; VAR_7<3; VAR_7++){ int VAR_8= get_bits(&VAR_0->gb, 8); VAR_8 |= get_sbits(&VAR_0->gb, 8)<<8; av_log(VAR_0->avctx, AV_LOG_DEBUG, " %5d", VAR_8); } av_log(VAR_0->avctx, AV_LOG_DEBUG, "\n"); } for(VAR_7=0; VAR_7<50; VAR_7++) av_log(VAR_0->avctx, AV_LOG_DEBUG, "%d", get_bits1(&VAR_0->gb)); } return 0; }
[ "int FUNC_0(MpegEncContext *VAR_0)\n{", "int VAR_1, VAR_2, VAR_3, VAR_7;", "uint32_t startcode;", "align_get_bits(&VAR_0->gb);", "startcode= get_bits(&VAR_0->gb, 22-8);", "for(VAR_7= get_bits_left(&VAR_0->gb); VAR_7>24; VAR_7-=8) {", "startcode = ((startcode << 8) | get_bits(&VAR_0->gb, 8)) & 0x003FFFFF;", "if(startcode == 0x20)\nbreak;", "}", "if (startcode != 0x20) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"Bad picture start code\\n\");", "return -1;", "}", "VAR_7 = get_bits(&VAR_0->gb, 8);", "if( (VAR_0->picture_number&~0xFF)+VAR_7 < VAR_0->picture_number)\nVAR_7+= 256;", "VAR_0->current_picture_ptr->f.pts =\nVAR_0->picture_number= (VAR_0->picture_number&~0xFF) + VAR_7;", "if (get_bits1(&VAR_0->gb) != 1) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"Bad marker\\n\");", "return -1;", "}", "if (get_bits1(&VAR_0->gb) != 0) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"Bad H263 id\\n\");", "return -1;", "}", "skip_bits1(&VAR_0->gb);", "skip_bits1(&VAR_0->gb);", "skip_bits1(&VAR_0->gb);", "VAR_1 = get_bits(&VAR_0->gb, 3);", "if (VAR_1 != 7 && VAR_1 != 6) {", "VAR_0->h263_plus = 0;", "VAR_2 = ff_h263_format[VAR_1][0];", "VAR_3 = ff_h263_format[VAR_1][1];", "if (!VAR_2)\nreturn -1;", "VAR_0->pict_type = AV_PICTURE_TYPE_I + get_bits1(&VAR_0->gb);", "VAR_0->h263_long_vectors = get_bits1(&VAR_0->gb);", "if (get_bits1(&VAR_0->gb) != 0) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"H263 SAC not supported\\n\");", "return -1;", "}", "VAR_0->obmc= get_bits1(&VAR_0->gb);", "VAR_0->unrestricted_mv = VAR_0->h263_long_vectors || VAR_0->obmc;", "VAR_0->pb_frame = get_bits1(&VAR_0->gb);", "VAR_0->chroma_qscale= VAR_0->qscale = get_bits(&VAR_0->gb, 5);", "skip_bits1(&VAR_0->gb);", "VAR_0->VAR_2 = VAR_2;", "VAR_0->VAR_3 = VAR_3;", "VAR_0->avctx->sample_aspect_ratio= (AVRational){12,11};", "VAR_0->avctx->time_base= (AVRational){1001, 30000};", "} else {", "int VAR_5;", "VAR_0->h263_plus = 1;", "VAR_5 = get_bits(&VAR_0->gb, 3);", "if (VAR_5 == 1) {", "VAR_1 = get_bits(&VAR_0->gb, 3);", "av_dlog(VAR_0->avctx, \"VAR_5=1, VAR_1: %d\\n\", VAR_1);", "VAR_0->custom_pcf= get_bits1(&VAR_0->gb);", "VAR_0->umvplus = get_bits1(&VAR_0->gb);", "if (get_bits1(&VAR_0->gb) != 0) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"Syntax-based Arithmetic Coding (SAC) not supported\\n\");", "}", "VAR_0->obmc= get_bits1(&VAR_0->gb);", "VAR_0->h263_aic = get_bits1(&VAR_0->gb);", "VAR_0->loop_filter= get_bits1(&VAR_0->gb);", "VAR_0->unrestricted_mv = VAR_0->umvplus || VAR_0->obmc || VAR_0->loop_filter;", "VAR_0->h263_slice_structured= get_bits1(&VAR_0->gb);", "if (get_bits1(&VAR_0->gb) != 0) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"Reference Picture Selection not supported\\n\");", "}", "if (get_bits1(&VAR_0->gb) != 0) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"Independent Segment Decoding not supported\\n\");", "}", "VAR_0->alt_inter_vlc= get_bits1(&VAR_0->gb);", "VAR_0->modified_quant= get_bits1(&VAR_0->gb);", "if(VAR_0->modified_quant)\nVAR_0->chroma_qscale_table= ff_h263_chroma_qscale_table;", "skip_bits(&VAR_0->gb, 1);", "skip_bits(&VAR_0->gb, 3);", "} else if (VAR_5 != 0) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"Bad UFEP type (%d)\\n\", VAR_5);", "return -1;", "}", "VAR_0->pict_type = get_bits(&VAR_0->gb, 3);", "switch(VAR_0->pict_type){", "case 0: VAR_0->pict_type= AV_PICTURE_TYPE_I;break;", "case 1: VAR_0->pict_type= AV_PICTURE_TYPE_P;break;", "case 2: VAR_0->pict_type= AV_PICTURE_TYPE_P;VAR_0->pb_frame = 3;break;", "case 3: VAR_0->pict_type= AV_PICTURE_TYPE_B;break;", "case 7: VAR_0->pict_type= AV_PICTURE_TYPE_I;break;", "default:\nreturn -1;", "}", "skip_bits(&VAR_0->gb, 2);", "VAR_0->no_rounding = get_bits1(&VAR_0->gb);", "skip_bits(&VAR_0->gb, 4);", "if (VAR_5) {", "if (VAR_1 == 6) {", "VAR_0->aspect_ratio_info = get_bits(&VAR_0->gb, 4);", "av_dlog(VAR_0->avctx, \"aspect: %d\\n\", VAR_0->aspect_ratio_info);", "VAR_2 = (get_bits(&VAR_0->gb, 9) + 1) * 4;", "skip_bits1(&VAR_0->gb);", "VAR_3 = get_bits(&VAR_0->gb, 9) * 4;", "av_dlog(VAR_0->avctx, \"\\nH.263+ Custom picture: %dx%d\\n\",VAR_2,VAR_3);", "if (VAR_0->aspect_ratio_info == FF_ASPECT_EXTENDED) {", "VAR_0->avctx->sample_aspect_ratio.num= get_bits(&VAR_0->gb, 8);", "VAR_0->avctx->sample_aspect_ratio.den= get_bits(&VAR_0->gb, 8);", "}else{", "VAR_0->avctx->sample_aspect_ratio= ff_h263_pixel_aspect[VAR_0->aspect_ratio_info];", "}", "} else {", "VAR_2 = ff_h263_format[VAR_1][0];", "VAR_3 = ff_h263_format[VAR_1][1];", "VAR_0->avctx->sample_aspect_ratio= (AVRational){12,11};", "}", "if ((VAR_2 == 0) || (VAR_3 == 0))\nreturn -1;", "VAR_0->VAR_2 = VAR_2;", "VAR_0->VAR_3 = VAR_3;", "if(VAR_0->custom_pcf){", "int VAR_6;", "VAR_0->avctx->time_base.den= 1800000;", "VAR_0->avctx->time_base.num= 1000 + get_bits1(&VAR_0->gb);", "VAR_0->avctx->time_base.num*= get_bits(&VAR_0->gb, 7);", "if(VAR_0->avctx->time_base.num == 0){", "av_log(VAR_0, AV_LOG_ERROR, \"zero framerate\\n\");", "return -1;", "}", "VAR_6= av_gcd(VAR_0->avctx->time_base.den, VAR_0->avctx->time_base.num);", "VAR_0->avctx->time_base.den /= VAR_6;", "VAR_0->avctx->time_base.num /= VAR_6;", "}else{", "VAR_0->avctx->time_base= (AVRational){1001, 30000};", "}", "}", "if(VAR_0->custom_pcf){", "skip_bits(&VAR_0->gb, 2);", "}", "if (VAR_5) {", "if (VAR_0->umvplus) {", "if(get_bits1(&VAR_0->gb)==0)\nskip_bits1(&VAR_0->gb);", "}", "if(VAR_0->h263_slice_structured){", "if (get_bits1(&VAR_0->gb) != 0) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"rectangular slices not supported\\n\");", "}", "if (get_bits1(&VAR_0->gb) != 0) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"unordered slices not supported\\n\");", "}", "}", "}", "VAR_0->qscale = get_bits(&VAR_0->gb, 5);", "}", "VAR_0->mb_width = (VAR_0->VAR_2 + 15) / 16;", "VAR_0->mb_height = (VAR_0->VAR_3 + 15) / 16;", "VAR_0->mb_num = VAR_0->mb_width * VAR_0->mb_height;", "if (VAR_0->pb_frame) {", "skip_bits(&VAR_0->gb, 3);", "if (VAR_0->custom_pcf)\nskip_bits(&VAR_0->gb, 2);", "skip_bits(&VAR_0->gb, 2);", "}", "while (get_bits1(&VAR_0->gb) != 0) {", "skip_bits(&VAR_0->gb, 8);", "}", "if(VAR_0->h263_slice_structured){", "if (get_bits1(&VAR_0->gb) != 1) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"SEPB1 marker missing\\n\");", "return -1;", "}", "ff_h263_decode_mba(VAR_0);", "if (get_bits1(&VAR_0->gb) != 1) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"SEPB2 marker missing\\n\");", "return -1;", "}", "}", "VAR_0->f_code = 1;", "if(VAR_0->h263_aic){", "VAR_0->y_dc_scale_table=\nVAR_0->c_dc_scale_table= ff_aic_dc_scale_table;", "}else{", "VAR_0->y_dc_scale_table=\nVAR_0->c_dc_scale_table= ff_mpeg1_dc_scale_table;", "}", "ff_h263_show_pict_info(VAR_0);", "if (VAR_0->pict_type == AV_PICTURE_TYPE_I && VAR_0->codec_tag == AV_RL32(\"ZYGO\")){", "int VAR_7,VAR_7;", "for(VAR_7=0; VAR_7<85; VAR_7++) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"%d\", get_bits1(&VAR_0->gb));", "av_log(VAR_0->avctx, AV_LOG_DEBUG, \"\\n\");", "for(VAR_7=0; VAR_7<13; VAR_7++){", "for(VAR_7=0; VAR_7<3; VAR_7++){", "int VAR_8= get_bits(&VAR_0->gb, 8);", "VAR_8 |= get_sbits(&VAR_0->gb, 8)<<8;", "av_log(VAR_0->avctx, AV_LOG_DEBUG, \" %5d\", VAR_8);", "}", "av_log(VAR_0->avctx, AV_LOG_DEBUG, \"\\n\");", "}", "for(VAR_7=0; VAR_7<50; VAR_7++) av_log(VAR_0->avctx, AV_LOG_DEBUG, \"%d\", get_bits1(&VAR_0->gb));", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 15 ], [ 19 ], [ 21 ], [ 25, 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45, 47 ], [ 49, 51 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 83 ], [ 99 ], [ 101 ], [ 105 ], [ 107 ], [ 109, 111 ], [ 115 ], [ 119 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 137 ], [ 139 ], [ 141 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 161 ], [ 163 ], [ 169 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215, 217 ], [ 221 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253, 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 269 ], [ 271 ], [ 275 ], [ 277 ], [ 297 ], [ 299 ], [ 301 ], [ 303 ], [ 305 ], [ 309 ], [ 311 ], [ 313 ], [ 315 ], [ 317 ], [ 319 ], [ 321 ], [ 323 ], [ 325 ], [ 327 ], [ 329, 331 ], [ 333 ], [ 335 ], [ 339 ], [ 341 ], [ 343 ], [ 345 ], [ 347 ], [ 349 ], [ 351 ], [ 353 ], [ 355 ], [ 357 ], [ 359 ], [ 361 ], [ 363 ], [ 365 ], [ 367 ], [ 369 ], [ 373 ], [ 375 ], [ 377 ], [ 381 ], [ 383 ], [ 385, 387 ], [ 389 ], [ 391 ], [ 393 ], [ 395 ], [ 397 ], [ 399 ], [ 401 ], [ 403 ], [ 405 ], [ 407 ], [ 411 ], [ 413 ], [ 417 ], [ 419 ], [ 421 ], [ 425 ], [ 427 ], [ 429, 431 ], [ 433 ], [ 435 ], [ 441 ], [ 443 ], [ 445 ], [ 449 ], [ 451 ], [ 453 ], [ 455 ], [ 457 ], [ 461 ], [ 465 ], [ 467 ], [ 469 ], [ 471 ], [ 473 ], [ 475 ], [ 479 ], [ 481, 483 ], [ 485 ], [ 487, 489 ], [ 491 ], [ 495 ], [ 497 ], [ 499 ], [ 501 ], [ 503 ], [ 505 ], [ 507 ], [ 509 ], [ 511 ], [ 513 ], [ 515 ], [ 517 ], [ 519 ], [ 521 ], [ 523 ], [ 527 ], [ 529 ] ]
12,502
static uint64_t get_cluster_offset(BlockDriverState *bs, uint64_t offset, int allocate, int compressed_size, int n_start, int n_end) { BDRVQcowState *s = bs->opaque; int min_index, i, j, l1_index, l2_index; uint64_t l2_offset, *l2_table, cluster_offset, tmp; uint32_t min_count; int new_l2_table; l1_index = offset >> (s->l2_bits + s->cluster_bits); l2_offset = s->l1_table[l1_index]; new_l2_table = 0; if (!l2_offset) { if (!allocate) return 0; /* allocate a new l2 entry */ l2_offset = bdrv_getlength(bs->file); /* round to cluster size */ l2_offset = (l2_offset + s->cluster_size - 1) & ~(s->cluster_size - 1); /* update the L1 entry */ s->l1_table[l1_index] = l2_offset; tmp = cpu_to_be64(l2_offset); if (bdrv_pwrite(bs->file, s->l1_table_offset + l1_index * sizeof(tmp), &tmp, sizeof(tmp)) != sizeof(tmp)) return 0; new_l2_table = 1; } for(i = 0; i < L2_CACHE_SIZE; i++) { if (l2_offset == s->l2_cache_offsets[i]) { /* increment the hit count */ if (++s->l2_cache_counts[i] == 0xffffffff) { for(j = 0; j < L2_CACHE_SIZE; j++) { s->l2_cache_counts[j] >>= 1; } } l2_table = s->l2_cache + (i << s->l2_bits); goto found; } } /* not found: load a new entry in the least used one */ min_index = 0; min_count = 0xffffffff; for(i = 0; i < L2_CACHE_SIZE; i++) { if (s->l2_cache_counts[i] < min_count) { min_count = s->l2_cache_counts[i]; min_index = i; } } l2_table = s->l2_cache + (min_index << s->l2_bits); if (new_l2_table) { memset(l2_table, 0, s->l2_size * sizeof(uint64_t)); if (bdrv_pwrite(bs->file, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) != s->l2_size * sizeof(uint64_t)) return 0; } else { if (bdrv_pread(bs->file, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) != s->l2_size * sizeof(uint64_t)) return 0; } s->l2_cache_offsets[min_index] = l2_offset; s->l2_cache_counts[min_index] = 1; found: l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1); cluster_offset = be64_to_cpu(l2_table[l2_index]); if (!cluster_offset || ((cluster_offset & QCOW_OFLAG_COMPRESSED) && allocate == 1)) { if (!allocate) return 0; /* allocate a new cluster */ if ((cluster_offset & QCOW_OFLAG_COMPRESSED) && (n_end - n_start) < s->cluster_sectors) { /* if the cluster is already compressed, we must decompress it in the case it is not completely overwritten */ if (decompress_cluster(bs, cluster_offset) < 0) return 0; cluster_offset = bdrv_getlength(bs->file); cluster_offset = (cluster_offset + s->cluster_size - 1) & ~(s->cluster_size - 1); /* write the cluster content */ if (bdrv_pwrite(bs->file, cluster_offset, s->cluster_cache, s->cluster_size) != s->cluster_size) return -1; } else { cluster_offset = bdrv_getlength(bs->file); if (allocate == 1) { /* round to cluster size */ cluster_offset = (cluster_offset + s->cluster_size - 1) & ~(s->cluster_size - 1); bdrv_truncate(bs->file, cluster_offset + s->cluster_size); /* if encrypted, we must initialize the cluster content which won't be written */ if (s->crypt_method && (n_end - n_start) < s->cluster_sectors) { uint64_t start_sect; start_sect = (offset & ~(s->cluster_size - 1)) >> 9; memset(s->cluster_data + 512, 0x00, 512); for(i = 0; i < s->cluster_sectors; i++) { if (i < n_start || i >= n_end) { encrypt_sectors(s, start_sect + i, s->cluster_data, s->cluster_data + 512, 1, 1, &s->aes_encrypt_key); if (bdrv_pwrite(bs->file, cluster_offset + i * 512, s->cluster_data, 512) != 512) return -1; } } } } else if (allocate == 2) { cluster_offset |= QCOW_OFLAG_COMPRESSED | (uint64_t)compressed_size << (63 - s->cluster_bits); } } /* update L2 table */ tmp = cpu_to_be64(cluster_offset); l2_table[l2_index] = tmp; if (bdrv_pwrite(bs->file, l2_offset + l2_index * sizeof(tmp), &tmp, sizeof(tmp)) != sizeof(tmp)) return 0; } return cluster_offset; }
true
qemu
5e5557d97026d1d3325e0e7b0ba593366da2f3dc
static uint64_t get_cluster_offset(BlockDriverState *bs, uint64_t offset, int allocate, int compressed_size, int n_start, int n_end) { BDRVQcowState *s = bs->opaque; int min_index, i, j, l1_index, l2_index; uint64_t l2_offset, *l2_table, cluster_offset, tmp; uint32_t min_count; int new_l2_table; l1_index = offset >> (s->l2_bits + s->cluster_bits); l2_offset = s->l1_table[l1_index]; new_l2_table = 0; if (!l2_offset) { if (!allocate) return 0; l2_offset = bdrv_getlength(bs->file); l2_offset = (l2_offset + s->cluster_size - 1) & ~(s->cluster_size - 1); s->l1_table[l1_index] = l2_offset; tmp = cpu_to_be64(l2_offset); if (bdrv_pwrite(bs->file, s->l1_table_offset + l1_index * sizeof(tmp), &tmp, sizeof(tmp)) != sizeof(tmp)) return 0; new_l2_table = 1; } for(i = 0; i < L2_CACHE_SIZE; i++) { if (l2_offset == s->l2_cache_offsets[i]) { if (++s->l2_cache_counts[i] == 0xffffffff) { for(j = 0; j < L2_CACHE_SIZE; j++) { s->l2_cache_counts[j] >>= 1; } } l2_table = s->l2_cache + (i << s->l2_bits); goto found; } } min_index = 0; min_count = 0xffffffff; for(i = 0; i < L2_CACHE_SIZE; i++) { if (s->l2_cache_counts[i] < min_count) { min_count = s->l2_cache_counts[i]; min_index = i; } } l2_table = s->l2_cache + (min_index << s->l2_bits); if (new_l2_table) { memset(l2_table, 0, s->l2_size * sizeof(uint64_t)); if (bdrv_pwrite(bs->file, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) != s->l2_size * sizeof(uint64_t)) return 0; } else { if (bdrv_pread(bs->file, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) != s->l2_size * sizeof(uint64_t)) return 0; } s->l2_cache_offsets[min_index] = l2_offset; s->l2_cache_counts[min_index] = 1; found: l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1); cluster_offset = be64_to_cpu(l2_table[l2_index]); if (!cluster_offset || ((cluster_offset & QCOW_OFLAG_COMPRESSED) && allocate == 1)) { if (!allocate) return 0; if ((cluster_offset & QCOW_OFLAG_COMPRESSED) && (n_end - n_start) < s->cluster_sectors) { if (decompress_cluster(bs, cluster_offset) < 0) return 0; cluster_offset = bdrv_getlength(bs->file); cluster_offset = (cluster_offset + s->cluster_size - 1) & ~(s->cluster_size - 1); if (bdrv_pwrite(bs->file, cluster_offset, s->cluster_cache, s->cluster_size) != s->cluster_size) return -1; } else { cluster_offset = bdrv_getlength(bs->file); if (allocate == 1) { cluster_offset = (cluster_offset + s->cluster_size - 1) & ~(s->cluster_size - 1); bdrv_truncate(bs->file, cluster_offset + s->cluster_size); if (s->crypt_method && (n_end - n_start) < s->cluster_sectors) { uint64_t start_sect; start_sect = (offset & ~(s->cluster_size - 1)) >> 9; memset(s->cluster_data + 512, 0x00, 512); for(i = 0; i < s->cluster_sectors; i++) { if (i < n_start || i >= n_end) { encrypt_sectors(s, start_sect + i, s->cluster_data, s->cluster_data + 512, 1, 1, &s->aes_encrypt_key); if (bdrv_pwrite(bs->file, cluster_offset + i * 512, s->cluster_data, 512) != 512) return -1; } } } } else if (allocate == 2) { cluster_offset |= QCOW_OFLAG_COMPRESSED | (uint64_t)compressed_size << (63 - s->cluster_bits); } } tmp = cpu_to_be64(cluster_offset); l2_table[l2_index] = tmp; if (bdrv_pwrite(bs->file, l2_offset + l2_index * sizeof(tmp), &tmp, sizeof(tmp)) != sizeof(tmp)) return 0; } return cluster_offset; }
{ "code": [ " if (bdrv_pwrite(bs->file, s->l1_table_offset + l1_index * sizeof(tmp),", " &tmp, sizeof(tmp)) != sizeof(tmp))", " if (bdrv_pwrite(bs->file, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) !=", " s->l2_size * sizeof(uint64_t))", " if (bdrv_pwrite(bs->file,", " l2_offset + l2_index * sizeof(tmp), &tmp, sizeof(tmp)) != sizeof(tmp))" ], "line_no": [ 49, 51, 107, 109, 239, 241 ] }
static uint64_t FUNC_0(BlockDriverState *bs, uint64_t offset, int allocate, int compressed_size, int n_start, int n_end) { BDRVQcowState *s = bs->opaque; int VAR_0, VAR_1, VAR_2, VAR_3, VAR_4; uint64_t l2_offset, *l2_table, cluster_offset, tmp; uint32_t min_count; int VAR_5; VAR_3 = offset >> (s->l2_bits + s->cluster_bits); l2_offset = s->l1_table[VAR_3]; VAR_5 = 0; if (!l2_offset) { if (!allocate) return 0; l2_offset = bdrv_getlength(bs->file); l2_offset = (l2_offset + s->cluster_size - 1) & ~(s->cluster_size - 1); s->l1_table[VAR_3] = l2_offset; tmp = cpu_to_be64(l2_offset); if (bdrv_pwrite(bs->file, s->l1_table_offset + VAR_3 * sizeof(tmp), &tmp, sizeof(tmp)) != sizeof(tmp)) return 0; VAR_5 = 1; } for(VAR_1 = 0; VAR_1 < L2_CACHE_SIZE; VAR_1++) { if (l2_offset == s->l2_cache_offsets[VAR_1]) { if (++s->l2_cache_counts[VAR_1] == 0xffffffff) { for(VAR_2 = 0; VAR_2 < L2_CACHE_SIZE; VAR_2++) { s->l2_cache_counts[VAR_2] >>= 1; } } l2_table = s->l2_cache + (VAR_1 << s->l2_bits); goto found; } } VAR_0 = 0; min_count = 0xffffffff; for(VAR_1 = 0; VAR_1 < L2_CACHE_SIZE; VAR_1++) { if (s->l2_cache_counts[VAR_1] < min_count) { min_count = s->l2_cache_counts[VAR_1]; VAR_0 = VAR_1; } } l2_table = s->l2_cache + (VAR_0 << s->l2_bits); if (VAR_5) { memset(l2_table, 0, s->l2_size * sizeof(uint64_t)); if (bdrv_pwrite(bs->file, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) != s->l2_size * sizeof(uint64_t)) return 0; } else { if (bdrv_pread(bs->file, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) != s->l2_size * sizeof(uint64_t)) return 0; } s->l2_cache_offsets[VAR_0] = l2_offset; s->l2_cache_counts[VAR_0] = 1; found: VAR_4 = (offset >> s->cluster_bits) & (s->l2_size - 1); cluster_offset = be64_to_cpu(l2_table[VAR_4]); if (!cluster_offset || ((cluster_offset & QCOW_OFLAG_COMPRESSED) && allocate == 1)) { if (!allocate) return 0; if ((cluster_offset & QCOW_OFLAG_COMPRESSED) && (n_end - n_start) < s->cluster_sectors) { if (decompress_cluster(bs, cluster_offset) < 0) return 0; cluster_offset = bdrv_getlength(bs->file); cluster_offset = (cluster_offset + s->cluster_size - 1) & ~(s->cluster_size - 1); if (bdrv_pwrite(bs->file, cluster_offset, s->cluster_cache, s->cluster_size) != s->cluster_size) return -1; } else { cluster_offset = bdrv_getlength(bs->file); if (allocate == 1) { cluster_offset = (cluster_offset + s->cluster_size - 1) & ~(s->cluster_size - 1); bdrv_truncate(bs->file, cluster_offset + s->cluster_size); if (s->crypt_method && (n_end - n_start) < s->cluster_sectors) { uint64_t start_sect; start_sect = (offset & ~(s->cluster_size - 1)) >> 9; memset(s->cluster_data + 512, 0x00, 512); for(VAR_1 = 0; VAR_1 < s->cluster_sectors; VAR_1++) { if (VAR_1 < n_start || VAR_1 >= n_end) { encrypt_sectors(s, start_sect + VAR_1, s->cluster_data, s->cluster_data + 512, 1, 1, &s->aes_encrypt_key); if (bdrv_pwrite(bs->file, cluster_offset + VAR_1 * 512, s->cluster_data, 512) != 512) return -1; } } } } else if (allocate == 2) { cluster_offset |= QCOW_OFLAG_COMPRESSED | (uint64_t)compressed_size << (63 - s->cluster_bits); } } tmp = cpu_to_be64(cluster_offset); l2_table[VAR_4] = tmp; if (bdrv_pwrite(bs->file, l2_offset + VAR_4 * sizeof(tmp), &tmp, sizeof(tmp)) != sizeof(tmp)) return 0; } return cluster_offset; }
[ "static uint64_t FUNC_0(BlockDriverState *bs,\nuint64_t offset, int allocate,\nint compressed_size,\nint n_start, int n_end)\n{", "BDRVQcowState *s = bs->opaque;", "int VAR_0, VAR_1, VAR_2, VAR_3, VAR_4;", "uint64_t l2_offset, *l2_table, cluster_offset, tmp;", "uint32_t min_count;", "int VAR_5;", "VAR_3 = offset >> (s->l2_bits + s->cluster_bits);", "l2_offset = s->l1_table[VAR_3];", "VAR_5 = 0;", "if (!l2_offset) {", "if (!allocate)\nreturn 0;", "l2_offset = bdrv_getlength(bs->file);", "l2_offset = (l2_offset + s->cluster_size - 1) & ~(s->cluster_size - 1);", "s->l1_table[VAR_3] = l2_offset;", "tmp = cpu_to_be64(l2_offset);", "if (bdrv_pwrite(bs->file, s->l1_table_offset + VAR_3 * sizeof(tmp),\n&tmp, sizeof(tmp)) != sizeof(tmp))\nreturn 0;", "VAR_5 = 1;", "}", "for(VAR_1 = 0; VAR_1 < L2_CACHE_SIZE; VAR_1++) {", "if (l2_offset == s->l2_cache_offsets[VAR_1]) {", "if (++s->l2_cache_counts[VAR_1] == 0xffffffff) {", "for(VAR_2 = 0; VAR_2 < L2_CACHE_SIZE; VAR_2++) {", "s->l2_cache_counts[VAR_2] >>= 1;", "}", "}", "l2_table = s->l2_cache + (VAR_1 << s->l2_bits);", "goto found;", "}", "}", "VAR_0 = 0;", "min_count = 0xffffffff;", "for(VAR_1 = 0; VAR_1 < L2_CACHE_SIZE; VAR_1++) {", "if (s->l2_cache_counts[VAR_1] < min_count) {", "min_count = s->l2_cache_counts[VAR_1];", "VAR_0 = VAR_1;", "}", "}", "l2_table = s->l2_cache + (VAR_0 << s->l2_bits);", "if (VAR_5) {", "memset(l2_table, 0, s->l2_size * sizeof(uint64_t));", "if (bdrv_pwrite(bs->file, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) !=\ns->l2_size * sizeof(uint64_t))\nreturn 0;", "} else {", "if (bdrv_pread(bs->file, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) !=\ns->l2_size * sizeof(uint64_t))\nreturn 0;", "}", "s->l2_cache_offsets[VAR_0] = l2_offset;", "s->l2_cache_counts[VAR_0] = 1;", "found:\nVAR_4 = (offset >> s->cluster_bits) & (s->l2_size - 1);", "cluster_offset = be64_to_cpu(l2_table[VAR_4]);", "if (!cluster_offset ||\n((cluster_offset & QCOW_OFLAG_COMPRESSED) && allocate == 1)) {", "if (!allocate)\nreturn 0;", "if ((cluster_offset & QCOW_OFLAG_COMPRESSED) &&\n(n_end - n_start) < s->cluster_sectors) {", "if (decompress_cluster(bs, cluster_offset) < 0)\nreturn 0;", "cluster_offset = bdrv_getlength(bs->file);", "cluster_offset = (cluster_offset + s->cluster_size - 1) &\n~(s->cluster_size - 1);", "if (bdrv_pwrite(bs->file, cluster_offset, s->cluster_cache, s->cluster_size) !=\ns->cluster_size)\nreturn -1;", "} else {", "cluster_offset = bdrv_getlength(bs->file);", "if (allocate == 1) {", "cluster_offset = (cluster_offset + s->cluster_size - 1) &\n~(s->cluster_size - 1);", "bdrv_truncate(bs->file, cluster_offset + s->cluster_size);", "if (s->crypt_method &&\n(n_end - n_start) < s->cluster_sectors) {", "uint64_t start_sect;", "start_sect = (offset & ~(s->cluster_size - 1)) >> 9;", "memset(s->cluster_data + 512, 0x00, 512);", "for(VAR_1 = 0; VAR_1 < s->cluster_sectors; VAR_1++) {", "if (VAR_1 < n_start || VAR_1 >= n_end) {", "encrypt_sectors(s, start_sect + VAR_1,\ns->cluster_data,\ns->cluster_data + 512, 1, 1,\n&s->aes_encrypt_key);", "if (bdrv_pwrite(bs->file, cluster_offset + VAR_1 * 512,\ns->cluster_data, 512) != 512)\nreturn -1;", "}", "}", "}", "} else if (allocate == 2) {", "cluster_offset |= QCOW_OFLAG_COMPRESSED |\n(uint64_t)compressed_size << (63 - s->cluster_bits);", "}", "}", "tmp = cpu_to_be64(cluster_offset);", "l2_table[VAR_4] = tmp;", "if (bdrv_pwrite(bs->file,\nl2_offset + VAR_4 * sizeof(tmp), &tmp, sizeof(tmp)) != sizeof(tmp))\nreturn 0;", "}", "return cluster_offset;", "}" ]
[ 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, 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, 1, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31, 33 ], [ 37 ], [ 41 ], [ 45 ], [ 47 ], [ 49, 51, 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 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 ], [ 143, 145 ], [ 153, 155 ], [ 157 ], [ 159, 161 ], [ 165, 167, 169 ], [ 171 ], [ 173 ], [ 175 ], [ 179, 181 ], [ 183 ], [ 189, 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203, 205, 207, 209 ], [ 211, 213, 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225, 227 ], [ 229 ], [ 231 ], [ 235 ], [ 237 ], [ 239, 241, 243 ], [ 245 ], [ 247 ], [ 249 ] ]
12,503
static BlockAIOCB *blkverify_aio_flush(BlockDriverState *bs, BlockCompletionFunc *cb, void *opaque) { BDRVBlkverifyState *s = bs->opaque; /* Only flush test file, the raw file is not important */ return bdrv_aio_flush(s->test_file->bs, cb, opaque); }
true
qemu
44b6789299a8acca3f25331bc411055cafc7bb06
static BlockAIOCB *blkverify_aio_flush(BlockDriverState *bs, BlockCompletionFunc *cb, void *opaque) { BDRVBlkverifyState *s = bs->opaque; return bdrv_aio_flush(s->test_file->bs, cb, opaque); }
{ "code": [ " BDRVBlkverifyState *s = bs->opaque;", " BDRVBlkverifyState *s = bs->opaque;", "static BlockAIOCB *blkverify_aio_flush(BlockDriverState *bs,", " BlockCompletionFunc *cb,", " void *opaque)", " return bdrv_aio_flush(s->test_file->bs, cb, opaque);" ], "line_no": [ 9, 9, 1, 3, 5, 15 ] }
static BlockAIOCB *FUNC_0(BlockDriverState *bs, BlockCompletionFunc *cb, void *opaque) { BDRVBlkverifyState *s = bs->opaque; return bdrv_aio_flush(s->test_file->bs, cb, opaque); }
[ "static BlockAIOCB *FUNC_0(BlockDriverState *bs,\nBlockCompletionFunc *cb,\nvoid *opaque)\n{", "BDRVBlkverifyState *s = bs->opaque;", "return bdrv_aio_flush(s->test_file->bs, cb, opaque);", "}" ]
[ 1, 1, 1, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 15 ], [ 17 ] ]
12,504
static int del_existing_snapshots(Monitor *mon, const char *name) { BlockDriverState *bs; QEMUSnapshotInfo sn1, *snapshot = &sn1; int ret; bs = NULL; while ((bs = bdrv_next(bs))) { if (bdrv_can_snapshot(bs) && bdrv_snapshot_find(bs, snapshot, name) >= 0) { ret = bdrv_snapshot_delete(bs, name); if (ret < 0) { monitor_printf(mon, "Error while deleting snapshot on '%s'\n", bdrv_get_device_name(bs)); return -1; } } } return 0; }
true
qemu
a89d89d3e65800fa4a8e00de7af0ea8272bef779
static int del_existing_snapshots(Monitor *mon, const char *name) { BlockDriverState *bs; QEMUSnapshotInfo sn1, *snapshot = &sn1; int ret; bs = NULL; while ((bs = bdrv_next(bs))) { if (bdrv_can_snapshot(bs) && bdrv_snapshot_find(bs, snapshot, name) >= 0) { ret = bdrv_snapshot_delete(bs, name); if (ret < 0) { monitor_printf(mon, "Error while deleting snapshot on '%s'\n", bdrv_get_device_name(bs)); return -1; } } } return 0; }
{ "code": [ " int ret;", " ret = bdrv_snapshot_delete(bs, name);", " if (ret < 0) {", " \"Error while deleting snapshot on '%s'\\n\",", " bdrv_get_device_name(bs));", " int ret;", " if (ret < 0) {" ], "line_no": [ 9, 23, 25, 29, 31, 9, 25 ] }
static int FUNC_0(Monitor *VAR_0, const char *VAR_1) { BlockDriverState *bs; QEMUSnapshotInfo sn1, *snapshot = &sn1; int VAR_2; bs = NULL; while ((bs = bdrv_next(bs))) { if (bdrv_can_snapshot(bs) && bdrv_snapshot_find(bs, snapshot, VAR_1) >= 0) { VAR_2 = bdrv_snapshot_delete(bs, VAR_1); if (VAR_2 < 0) { monitor_printf(VAR_0, "Error while deleting snapshot on '%s'\n", bdrv_get_device_name(bs)); return -1; } } } return 0; }
[ "static int FUNC_0(Monitor *VAR_0, const char *VAR_1)\n{", "BlockDriverState *bs;", "QEMUSnapshotInfo sn1, *snapshot = &sn1;", "int VAR_2;", "bs = NULL;", "while ((bs = bdrv_next(bs))) {", "if (bdrv_can_snapshot(bs) &&\nbdrv_snapshot_find(bs, snapshot, VAR_1) >= 0)\n{", "VAR_2 = bdrv_snapshot_delete(bs, VAR_1);", "if (VAR_2 < 0) {", "monitor_printf(VAR_0,\n\"Error while deleting snapshot on '%s'\\n\",\nbdrv_get_device_name(bs));", "return -1;", "}", "}", "}", "return 0;", "}" ]
[ 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 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 ], [ 43 ], [ 45 ] ]
12,505
static void wavpack_decode_flush(AVCodecContext *avctx) { WavpackContext *s = avctx->priv_data; int i; for (i = 0; i < s->fdec_num; i++) wv_reset_saved_context(s->fdec[i]); }
true
FFmpeg
2c6cf1394096d08396faadc6e7c0b404fd6df006
static void wavpack_decode_flush(AVCodecContext *avctx) { WavpackContext *s = avctx->priv_data; int i; for (i = 0; i < s->fdec_num; i++) wv_reset_saved_context(s->fdec[i]); }
{ "code": [ "static void wavpack_decode_flush(AVCodecContext *avctx)", " WavpackContext *s = avctx->priv_data;", " int i;", " for (i = 0; i < s->fdec_num; i++)", " wv_reset_saved_context(s->fdec[i]);" ], "line_no": [ 1, 5, 7, 11, 13 ] }
static void FUNC_0(AVCodecContext *VAR_0) { WavpackContext *s = VAR_0->priv_data; int VAR_1; for (VAR_1 = 0; VAR_1 < s->fdec_num; VAR_1++) wv_reset_saved_context(s->fdec[VAR_1]); }
[ "static void FUNC_0(AVCodecContext *VAR_0)\n{", "WavpackContext *s = VAR_0->priv_data;", "int VAR_1;", "for (VAR_1 = 0; VAR_1 < s->fdec_num; VAR_1++)", "wv_reset_saved_context(s->fdec[VAR_1]);", "}" ]
[ 1, 1, 1, 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ] ]
12,506
inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth, uint8_t *src1, uint8_t *src2, int srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter, int16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode, int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter, int32_t *mmx2FilterPos, uint8_t *pal) { if (srcFormat==PIX_FMT_YUYV422) { RENAME(yuy2ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_UYVY422) { RENAME(uyvyToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_RGB32) { RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_RGB32_1) { RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1+ALT32_CORR, src2+ALT32_CORR, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_BGR24) { RENAME(bgr24ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_BGR565) { RENAME(bgr16ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_BGR555) { RENAME(bgr15ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_BGR32) { RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_BGR32_1) { RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1+ALT32_CORR, src2+ALT32_CORR, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_RGB24) { RENAME(rgb24ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_RGB565) { RENAME(rgb16ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_RGB555) { RENAME(rgb15ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (isGray(srcFormat)) { return; } else if (srcFormat==PIX_FMT_RGB8 || srcFormat==PIX_FMT_BGR8 || srcFormat==PIX_FMT_PAL8 || srcFormat==PIX_FMT_BGR4_BYTE || srcFormat==PIX_FMT_RGB4_BYTE) { RENAME(palToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, (uint32_t*)pal); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } #ifdef HAVE_MMX // Use the new MMX scaler if the MMX2 one can't be used (it is faster than the x86 ASM one). if (!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed)) #else if (!(flags&SWS_FAST_BILINEAR)) #endif { RENAME(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); RENAME(hScale)(dst+VOFW, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); } else // fast bilinear upscale / crap downscale { #if defined(ARCH_X86) #ifdef HAVE_MMX2 int i; #if defined(PIC) uint64_t ebxsave __attribute__((aligned(8))); #endif if (canMMX2BeUsed) { asm volatile( #if defined(PIC) "mov %%"REG_b", %6 \n\t" #endif "pxor %%mm7, %%mm7 \n\t" "mov %0, %%"REG_c" \n\t" "mov %1, %%"REG_D" \n\t" "mov %2, %%"REG_d" \n\t" "mov %3, %%"REG_b" \n\t" "xor %%"REG_a", %%"REG_a" \n\t" // i PREFETCH" (%%"REG_c") \n\t" PREFETCH" 32(%%"REG_c") \n\t" PREFETCH" 64(%%"REG_c") \n\t" #ifdef ARCH_X86_64 #define FUNNY_UV_CODE \ "movl (%%"REG_b"), %%esi \n\t"\ "call *%4 \n\t"\ "movl (%%"REG_b", %%"REG_a"), %%esi \n\t"\ "add %%"REG_S", %%"REG_c" \n\t"\ "add %%"REG_a", %%"REG_D" \n\t"\ "xor %%"REG_a", %%"REG_a" \n\t"\ #else #define FUNNY_UV_CODE \ "movl (%%"REG_b"), %%esi \n\t"\ "call *%4 \n\t"\ "addl (%%"REG_b", %%"REG_a"), %%"REG_c" \n\t"\ "add %%"REG_a", %%"REG_D" \n\t"\ "xor %%"REG_a", %%"REG_a" \n\t"\ #endif /* ARCH_X86_64 */ FUNNY_UV_CODE FUNNY_UV_CODE FUNNY_UV_CODE FUNNY_UV_CODE "xor %%"REG_a", %%"REG_a" \n\t" // i "mov %5, %%"REG_c" \n\t" // src "mov %1, %%"REG_D" \n\t" // buf1 "add $"AV_STRINGIFY(VOF)", %%"REG_D" \n\t" PREFETCH" (%%"REG_c") \n\t" PREFETCH" 32(%%"REG_c") \n\t" PREFETCH" 64(%%"REG_c") \n\t" FUNNY_UV_CODE FUNNY_UV_CODE FUNNY_UV_CODE FUNNY_UV_CODE #if defined(PIC) "mov %6, %%"REG_b" \n\t" #endif :: "m" (src1), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos), "m" (funnyUVCode), "m" (src2) #if defined(PIC) ,"m" (ebxsave) #endif : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D #if !defined(PIC) ,"%"REG_b #endif ); for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) { //printf("%d %d %d\n", dstWidth, i, srcW); dst[i] = src1[srcW-1]*128; dst[i+VOFW] = src2[srcW-1]*128; } } else { #endif /* HAVE_MMX2 */ long xInc_shr16 = (long) (xInc >> 16); uint16_t xInc_mask = xInc & 0xffff; asm volatile( "xor %%"REG_a", %%"REG_a" \n\t" // i "xor %%"REG_d", %%"REG_d" \n\t" // xx "xorl %%ecx, %%ecx \n\t" // 2*xalpha ASMALIGN(4) "1: \n\t" "mov %0, %%"REG_S" \n\t" "movzbl (%%"REG_S", %%"REG_d"), %%edi \n\t" //src[xx] "movzbl 1(%%"REG_S", %%"REG_d"), %%esi \n\t" //src[xx+1] "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx] "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha "shll $16, %%edi \n\t" "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha) "mov %1, %%"REG_D" \n\t" "shrl $9, %%esi \n\t" "movw %%si, (%%"REG_D", %%"REG_a", 2) \n\t" "movzbl (%5, %%"REG_d"), %%edi \n\t" //src[xx] "movzbl 1(%5, %%"REG_d"), %%esi \n\t" //src[xx+1] "subl %%edi, %%esi \n\t" //src[xx+1] - src[xx] "imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha "shll $16, %%edi \n\t" "addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha) "mov %1, %%"REG_D" \n\t" "shrl $9, %%esi \n\t" "movw %%si, "AV_STRINGIFY(VOF)"(%%"REG_D", %%"REG_a", 2) \n\t" "addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF "adc %3, %%"REG_d" \n\t" //xx+= xInc>>8 + carry "add $1, %%"REG_a" \n\t" "cmp %2, %%"REG_a" \n\t" " jb 1b \n\t" /* GCC 3.3 makes MPlayer crash on IA-32 machines when using "g" operand here, which is needed to support GCC 4.0. */ #if defined(ARCH_X86_64) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) :: "m" (src1), "m" (dst), "g" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask), #else :: "m" (src1), "m" (dst), "m" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask), #endif "r" (src2) : "%"REG_a, "%"REG_d, "%ecx", "%"REG_D, "%esi" ); #ifdef HAVE_MMX2 } //if MMX2 can't be used #endif #else int i; unsigned int xpos=0; for (i=0;i<dstWidth;i++) { register unsigned int xx=xpos>>16; register unsigned int xalpha=(xpos&0xFFFF)>>9; dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha); dst[i+VOFW]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha); /* slower dst[i]= (src1[xx]<<7) + (src1[xx+1] - src1[xx])*xalpha; dst[i+VOFW]=(src2[xx]<<7) + (src2[xx+1] - src2[xx])*xalpha; */ xpos+=xInc; } #endif /* defined(ARCH_X86) */ } if(c->srcRange != c->dstRange && !(isRGB(c->dstFormat) || isBGR(c->dstFormat))){ int i; //FIXME all pal and rgb srcFormats could do this convertion as well //FIXME all scalers more complex than bilinear could do half of this transform if(c->srcRange){ for (i=0; i<dstWidth; i++){ dst[i ]= (dst[i ]*1799 + 4081085)>>11; //1469 dst[i+VOFW]= (dst[i+VOFW]*1799 + 4081085)>>11; //1469 } }else{ for (i=0; i<dstWidth; i++){ dst[i ]= (dst[i ]*4663 - 9289992)>>12; //-264 dst[i+VOFW]= (dst[i+VOFW]*4663 - 9289992)>>12; //-264 } } } }
true
FFmpeg
aa13b0fc55f5aec58fce24d1a047271b3e5727f1
inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth, uint8_t *src1, uint8_t *src2, int srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter, int16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode, int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter, int32_t *mmx2FilterPos, uint8_t *pal) { if (srcFormat==PIX_FMT_YUYV422) { RENAME(yuy2ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_UYVY422) { RENAME(uyvyToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_RGB32) { RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_RGB32_1) { RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1+ALT32_CORR, src2+ALT32_CORR, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_BGR24) { RENAME(bgr24ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_BGR565) { RENAME(bgr16ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_BGR555) { RENAME(bgr15ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_BGR32) { RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_BGR32_1) { RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1+ALT32_CORR, src2+ALT32_CORR, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_RGB24) { RENAME(rgb24ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_RGB565) { RENAME(rgb16ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_RGB555) { RENAME(rgb15ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (isGray(srcFormat)) { return; } else if (srcFormat==PIX_FMT_RGB8 || srcFormat==PIX_FMT_BGR8 || srcFormat==PIX_FMT_PAL8 || srcFormat==PIX_FMT_BGR4_BYTE || srcFormat==PIX_FMT_RGB4_BYTE) { RENAME(palToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, (uint32_t*)pal); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } #ifdef HAVE_MMX if (!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed)) #else if (!(flags&SWS_FAST_BILINEAR)) #endif { RENAME(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); RENAME(hScale)(dst+VOFW, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); } else { #if defined(ARCH_X86) #ifdef HAVE_MMX2 int i; #if defined(PIC) uint64_t ebxsave __attribute__((aligned(8))); #endif if (canMMX2BeUsed) { asm volatile( #if defined(PIC) "mov %%"REG_b", %6 \n\t" #endif "pxor %%mm7, %%mm7 \n\t" "mov %0, %%"REG_c" \n\t" "mov %1, %%"REG_D" \n\t" "mov %2, %%"REG_d" \n\t" "mov %3, %%"REG_b" \n\t" "xor %%"REG_a", %%"REG_a" \n\t" PREFETCH" (%%"REG_c") \n\t" PREFETCH" 32(%%"REG_c") \n\t" PREFETCH" 64(%%"REG_c") \n\t" #ifdef ARCH_X86_64 #define FUNNY_UV_CODE \ "movl (%%"REG_b"), %%esi \n\t"\ "call *%4 \n\t"\ "movl (%%"REG_b", %%"REG_a"), %%esi \n\t"\ "add %%"REG_S", %%"REG_c" \n\t"\ "add %%"REG_a", %%"REG_D" \n\t"\ "xor %%"REG_a", %%"REG_a" \n\t"\ #else #define FUNNY_UV_CODE \ "movl (%%"REG_b"), %%esi \n\t"\ "call *%4 \n\t"\ "addl (%%"REG_b", %%"REG_a"), %%"REG_c" \n\t"\ "add %%"REG_a", %%"REG_D" \n\t"\ "xor %%"REG_a", %%"REG_a" \n\t"\ #endif FUNNY_UV_CODE FUNNY_UV_CODE FUNNY_UV_CODE FUNNY_UV_CODE "xor %%"REG_a", %%"REG_a" \n\t" "mov %5, %%"REG_c" \n\t" "mov %1, %%"REG_D" \n\t" "add $"AV_STRINGIFY(VOF)", %%"REG_D" \n\t" PREFETCH" (%%"REG_c") \n\t" PREFETCH" 32(%%"REG_c") \n\t" PREFETCH" 64(%%"REG_c") \n\t" FUNNY_UV_CODE FUNNY_UV_CODE FUNNY_UV_CODE FUNNY_UV_CODE #if defined(PIC) "mov %6, %%"REG_b" \n\t" #endif :: "m" (src1), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos), "m" (funnyUVCode), "m" (src2) #if defined(PIC) ,"m" (ebxsave) #endif : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D #if !defined(PIC) ,"%"REG_b #endif ); for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) { dst[i] = src1[srcW-1]*128; dst[i+VOFW] = src2[srcW-1]*128; } } else { #endif long xInc_shr16 = (long) (xInc >> 16); uint16_t xInc_mask = xInc & 0xffff; asm volatile( "xor %%"REG_a", %%"REG_a" \n\t" "xor %%"REG_d", %%"REG_d" \n\t" "xorl %%ecx, %%ecx \n\t" ASMALIGN(4) "1: \n\t" "mov %0, %%"REG_S" \n\t" "movzbl (%%"REG_S", %%"REG_d"), %%edi \n\t" "movzbl 1(%%"REG_S", %%"REG_d"), %%esi \n\t" "subl %%edi, %%esi \n\t" - src[xx] "imull %%ecx, %%esi \n\t" "shll $16, %%edi \n\t" "addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha) "mov %1, %%"REG_D" \n\t" "shrl $9, %%esi \n\t" "movw %%si, (%%"REG_D", %%"REG_a", 2) \n\t" "movzbl (%5, %%"REG_d"), %%edi \n\t" "movzbl 1(%5, %%"REG_d"), %%esi \n\t" "subl %%edi, %%esi \n\t" - src[xx] "imull %%ecx, %%esi \n\t" "shll $16, %%edi \n\t" "addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha) "mov %1, %%"REG_D" \n\t" "shrl $9, %%esi \n\t" "movw %%si, "AV_STRINGIFY(VOF)"(%%"REG_D", %%"REG_a", 2) \n\t" "addw %4, %%cx \n\t" "adc %3, %%"REG_d" \n\t" "add $1, %%"REG_a" \n\t" "cmp %2, %%"REG_a" \n\t" " jb 1b \n\t" #if defined(ARCH_X86_64) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) :: "m" (src1), "m" (dst), "g" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask), #else :: "m" (src1), "m" (dst), "m" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask), #endif "r" (src2) : "%"REG_a, "%"REG_d, "%ecx", "%"REG_D, "%esi" ); #ifdef HAVE_MMX2 } #endif #else int i; unsigned int xpos=0; for (i=0;i<dstWidth;i++) { register unsigned int xx=xpos>>16; register unsigned int xalpha=(xpos&0xFFFF)>>9; dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha); dst[i+VOFW]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha); xpos+=xInc; } #endif } if(c->srcRange != c->dstRange && !(isRGB(c->dstFormat) || isBGR(c->dstFormat))){ int i; if(c->srcRange){ for (i=0; i<dstWidth; i++){ dst[i ]= (dst[i ]*1799 + 4081085)>>11; dst[i+VOFW]= (dst[i+VOFW]*1799 + 4081085)>>11; } }else{ for (i=0; i<dstWidth; i++){ dst[i ]= (dst[i ]*4663 - 9289992)>>12; dst[i+VOFW]= (dst[i+VOFW]*4663 - 9289992)>>12; } } } }
{ "code": [], "line_no": [] }
inline static void FUNC_0(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth, uint8_t *src1, uint8_t *src2, int srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter, int16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode, int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter, int32_t *mmx2FilterPos, uint8_t *pal) { if (srcFormat==PIX_FMT_YUYV422) { FUNC_0(yuy2ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_UYVY422) { FUNC_0(uyvyToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_RGB32) { FUNC_0(bgr32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_RGB32_1) { FUNC_0(bgr32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1+ALT32_CORR, src2+ALT32_CORR, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_BGR24) { FUNC_0(bgr24ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_BGR565) { FUNC_0(bgr16ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_BGR555) { FUNC_0(bgr15ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_BGR32) { FUNC_0(rgb32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_BGR32_1) { FUNC_0(rgb32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1+ALT32_CORR, src2+ALT32_CORR, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_RGB24) { FUNC_0(rgb24ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_RGB565) { FUNC_0(rgb16ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (srcFormat==PIX_FMT_RGB555) { FUNC_0(rgb15ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } else if (isGray(srcFormat)) { return; } else if (srcFormat==PIX_FMT_RGB8 || srcFormat==PIX_FMT_BGR8 || srcFormat==PIX_FMT_PAL8 || srcFormat==PIX_FMT_BGR4_BYTE || srcFormat==PIX_FMT_RGB4_BYTE) { FUNC_0(palToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, (uint32_t*)pal); src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } #ifdef HAVE_MMX if (!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed)) #else if (!(flags&SWS_FAST_BILINEAR)) #endif { FUNC_0(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); FUNC_0(hScale)(dst+VOFW, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); } else { #if defined(ARCH_X86) #ifdef HAVE_MMX2 int VAR_2; #if defined(PIC) uint64_t ebxsave __attribute__((aligned(8))); #endif if (canMMX2BeUsed) { asm volatile( #if defined(PIC) "mov %%"REG_b", %6 \n\t" #endif "pxor %%mm7, %%mm7 \n\t" "mov %0, %%"REG_c" \n\t" "mov %1, %%"REG_D" \n\t" "mov %2, %%"REG_d" \n\t" "mov %3, %%"REG_b" \n\t" "xor %%"REG_a", %%"REG_a" \n\t" PREFETCH" (%%"REG_c") \n\t" PREFETCH" 32(%%"REG_c") \n\t" PREFETCH" 64(%%"REG_c") \n\t" #ifdef ARCH_X86_64 #define FUNNY_UV_CODE \ "movl (%%"REG_b"), %%esi \n\t"\ "call *%4 \n\t"\ "movl (%%"REG_b", %%"REG_a"), %%esi \n\t"\ "add %%"REG_S", %%"REG_c" \n\t"\ "add %%"REG_a", %%"REG_D" \n\t"\ "xor %%"REG_a", %%"REG_a" \n\t"\ #else #define FUNNY_UV_CODE \ "movl (%%"REG_b"), %%esi \n\t"\ "call *%4 \n\t"\ "addl (%%"REG_b", %%"REG_a"), %%"REG_c" \n\t"\ "add %%"REG_a", %%"REG_D" \n\t"\ "xor %%"REG_a", %%"REG_a" \n\t"\ #endif FUNNY_UV_CODE FUNNY_UV_CODE FUNNY_UV_CODE FUNNY_UV_CODE "xor %%"REG_a", %%"REG_a" \n\t" "mov %5, %%"REG_c" \n\t" "mov %1, %%"REG_D" \n\t" "add $"AV_STRINGIFY(VOF)", %%"REG_D" \n\t" PREFETCH" (%%"REG_c") \n\t" PREFETCH" 32(%%"REG_c") \n\t" PREFETCH" 64(%%"REG_c") \n\t" FUNNY_UV_CODE FUNNY_UV_CODE FUNNY_UV_CODE FUNNY_UV_CODE #if defined(PIC) "mov %6, %%"REG_b" \n\t" #endif :: "m" (src1), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos), "m" (funnyUVCode), "m" (src2) #if defined(PIC) ,"m" (ebxsave) #endif : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D #if !defined(PIC) ,"%"REG_b #endif ); for (VAR_2=dstWidth-1; (VAR_2*xInc)>>16 >=srcW-1; VAR_2--) { dst[VAR_2] = src1[srcW-1]*128; dst[VAR_2+VOFW] = src2[srcW-1]*128; } } else { #endif long xInc_shr16 = (long) (xInc >> 16); uint16_t xInc_mask = xInc & 0xffff; asm volatile( "xor %%"REG_a", %%"REG_a" \n\t" "xor %%"REG_d", %%"REG_d" \n\t" "xorl %%ecx, %%ecx \n\t" ASMALIGN(4) "1: \n\t" "mov %0, %%"REG_S" \n\t" "movzbl (%%"REG_S", %%"REG_d"), %%edi \n\t" "movzbl 1(%%"REG_S", %%"REG_d"), %%esi \n\t" "subl %%edi, %%esi \n\t" - src[xx] "imull %%ecx, %%esi \n\t" "shll $16, %%edi \n\t" "addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha) "mov %1, %%"REG_D" \n\t" "shrl $9, %%esi \n\t" "movw %%si, (%%"REG_D", %%"REG_a", 2) \n\t" "movzbl (%5, %%"REG_d"), %%edi \n\t" "movzbl 1(%5, %%"REG_d"), %%esi \n\t" "subl %%edi, %%esi \n\t" - src[xx] "imull %%ecx, %%esi \n\t" "shll $16, %%edi \n\t" "addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha) "mov %1, %%"REG_D" \n\t" "shrl $9, %%esi \n\t" "movw %%si, "AV_STRINGIFY(VOF)"(%%"REG_D", %%"REG_a", 2) \n\t" "addw %4, %%cx \n\t" "adc %3, %%"REG_d" \n\t" "add $1, %%"REG_a" \n\t" "cmp %2, %%"REG_a" \n\t" " jb 1b \n\t" #if defined(ARCH_X86_64) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) :: "m" (src1), "m" (dst), "g" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask), #else :: "m" (src1), "m" (dst), "m" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask), #endif "r" (src2) : "%"REG_a, "%"REG_d, "%ecx", "%"REG_D, "%esi" ); #ifdef HAVE_MMX2 } #endif #else int VAR_2; unsigned int VAR_1=0; for (VAR_2=0;VAR_2<dstWidth;VAR_2++) { register unsigned int xx=VAR_1>>16; register unsigned int xalpha=(VAR_1&0xFFFF)>>9; dst[VAR_2]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha); dst[VAR_2+VOFW]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha); VAR_1+=xInc; } #endif } if(c->srcRange != c->dstRange && !(isRGB(c->dstFormat) || isBGR(c->dstFormat))){ int VAR_2; if(c->srcRange){ for (VAR_2=0; VAR_2<dstWidth; VAR_2++){ dst[VAR_2 ]= (dst[VAR_2 ]*1799 + 4081085)>>11; dst[VAR_2+VOFW]= (dst[VAR_2+VOFW]*1799 + 4081085)>>11; } }else{ for (VAR_2=0; VAR_2<dstWidth; VAR_2++){ dst[VAR_2 ]= (dst[VAR_2 ]*4663 - 9289992)>>12; dst[VAR_2+VOFW]= (dst[VAR_2+VOFW]*4663 - 9289992)>>12; } } } }
[ "inline static void FUNC_0(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth, uint8_t *src1, uint8_t *src2,\nint srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter,\nint16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode,\nint srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,\nint32_t *mmx2FilterPos, uint8_t *pal)\n{", "if (srcFormat==PIX_FMT_YUYV422)\n{", "FUNC_0(yuy2ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);", "src1= formatConvBuffer;", "src2= formatConvBuffer+VOFW;", "}", "else if (srcFormat==PIX_FMT_UYVY422)\n{", "FUNC_0(uyvyToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);", "src1= formatConvBuffer;", "src2= formatConvBuffer+VOFW;", "}", "else if (srcFormat==PIX_FMT_RGB32)\n{", "FUNC_0(bgr32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);", "src1= formatConvBuffer;", "src2= formatConvBuffer+VOFW;", "}", "else if (srcFormat==PIX_FMT_RGB32_1)\n{", "FUNC_0(bgr32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1+ALT32_CORR, src2+ALT32_CORR, srcW);", "src1= formatConvBuffer;", "src2= formatConvBuffer+VOFW;", "}", "else if (srcFormat==PIX_FMT_BGR24)\n{", "FUNC_0(bgr24ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);", "src1= formatConvBuffer;", "src2= formatConvBuffer+VOFW;", "}", "else if (srcFormat==PIX_FMT_BGR565)\n{", "FUNC_0(bgr16ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);", "src1= formatConvBuffer;", "src2= formatConvBuffer+VOFW;", "}", "else if (srcFormat==PIX_FMT_BGR555)\n{", "FUNC_0(bgr15ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);", "src1= formatConvBuffer;", "src2= formatConvBuffer+VOFW;", "}", "else if (srcFormat==PIX_FMT_BGR32)\n{", "FUNC_0(rgb32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);", "src1= formatConvBuffer;", "src2= formatConvBuffer+VOFW;", "}", "else if (srcFormat==PIX_FMT_BGR32_1)\n{", "FUNC_0(rgb32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1+ALT32_CORR, src2+ALT32_CORR, srcW);", "src1= formatConvBuffer;", "src2= formatConvBuffer+VOFW;", "}", "else if (srcFormat==PIX_FMT_RGB24)\n{", "FUNC_0(rgb24ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);", "src1= formatConvBuffer;", "src2= formatConvBuffer+VOFW;", "}", "else if (srcFormat==PIX_FMT_RGB565)\n{", "FUNC_0(rgb16ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);", "src1= formatConvBuffer;", "src2= formatConvBuffer+VOFW;", "}", "else if (srcFormat==PIX_FMT_RGB555)\n{", "FUNC_0(rgb15ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);", "src1= formatConvBuffer;", "src2= formatConvBuffer+VOFW;", "}", "else if (isGray(srcFormat))\n{", "return;", "}", "else if (srcFormat==PIX_FMT_RGB8 || srcFormat==PIX_FMT_BGR8 || srcFormat==PIX_FMT_PAL8 || srcFormat==PIX_FMT_BGR4_BYTE || srcFormat==PIX_FMT_RGB4_BYTE)\n{", "FUNC_0(palToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, (uint32_t*)pal);", "src1= formatConvBuffer;", "src2= formatConvBuffer+VOFW;", "}", "#ifdef HAVE_MMX\nif (!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed))\n#else\nif (!(flags&SWS_FAST_BILINEAR))\n#endif\n{", "FUNC_0(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);", "FUNC_0(hScale)(dst+VOFW, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);", "}", "else\n{", "#if defined(ARCH_X86)\n#ifdef HAVE_MMX2\nint VAR_2;", "#if defined(PIC)\nuint64_t ebxsave __attribute__((aligned(8)));", "#endif\nif (canMMX2BeUsed)\n{", "asm volatile(\n#if defined(PIC)\n\"mov %%\"REG_b\", %6 \\n\\t\"\n#endif\n\"pxor %%mm7, %%mm7 \\n\\t\"\n\"mov %0, %%\"REG_c\" \\n\\t\"\n\"mov %1, %%\"REG_D\" \\n\\t\"\n\"mov %2, %%\"REG_d\" \\n\\t\"\n\"mov %3, %%\"REG_b\" \\n\\t\"\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\nPREFETCH\" (%%\"REG_c\") \\n\\t\"\nPREFETCH\" 32(%%\"REG_c\") \\n\\t\"\nPREFETCH\" 64(%%\"REG_c\") \\n\\t\"\n#ifdef ARCH_X86_64\n#define FUNNY_UV_CODE \\\n\"movl (%%\"REG_b\"), %%esi \\n\\t\"\\\n\"call *%4 \\n\\t\"\\\n\"movl (%%\"REG_b\", %%\"REG_a\"), %%esi \\n\\t\"\\\n\"add %%\"REG_S\", %%\"REG_c\" \\n\\t\"\\\n\"add %%\"REG_a\", %%\"REG_D\" \\n\\t\"\\\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\\\n#else\n#define FUNNY_UV_CODE \\\n\"movl (%%\"REG_b\"), %%esi \\n\\t\"\\\n\"call *%4 \\n\\t\"\\\n\"addl (%%\"REG_b\", %%\"REG_a\"), %%\"REG_c\" \\n\\t\"\\\n\"add %%\"REG_a\", %%\"REG_D\" \\n\\t\"\\\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\\\n#endif\nFUNNY_UV_CODE\nFUNNY_UV_CODE\nFUNNY_UV_CODE\nFUNNY_UV_CODE\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\n\"mov %5, %%\"REG_c\" \\n\\t\"\n\"mov %1, %%\"REG_D\" \\n\\t\"\n\"add $\"AV_STRINGIFY(VOF)\", %%\"REG_D\" \\n\\t\"\nPREFETCH\" (%%\"REG_c\") \\n\\t\"\nPREFETCH\" 32(%%\"REG_c\") \\n\\t\"\nPREFETCH\" 64(%%\"REG_c\") \\n\\t\"\nFUNNY_UV_CODE\nFUNNY_UV_CODE\nFUNNY_UV_CODE\nFUNNY_UV_CODE\n#if defined(PIC)\n\"mov %6, %%\"REG_b\" \\n\\t\"\n#endif\n:: \"m\" (src1), \"m\" (dst), \"m\" (mmx2Filter), \"m\" (mmx2FilterPos),\n\"m\" (funnyUVCode), \"m\" (src2)\n#if defined(PIC)\n,\"m\" (ebxsave)\n#endif\n: \"%\"REG_a, \"%\"REG_c, \"%\"REG_d, \"%\"REG_S, \"%\"REG_D\n#if !defined(PIC)\n,\"%\"REG_b\n#endif\n);", "for (VAR_2=dstWidth-1; (VAR_2*xInc)>>16 >=srcW-1; VAR_2--)", "{", "dst[VAR_2] = src1[srcW-1]*128;", "dst[VAR_2+VOFW] = src2[srcW-1]*128;", "}", "}", "else\n{", "#endif\nlong xInc_shr16 = (long) (xInc >> 16);", "uint16_t xInc_mask = xInc & 0xffff;", "asm volatile(\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\n\"xor %%\"REG_d\", %%\"REG_d\" \\n\\t\"\n\"xorl %%ecx, %%ecx \\n\\t\"\nASMALIGN(4)\n\"1: \\n\\t\"\n\"mov %0, %%\"REG_S\" \\n\\t\"\n\"movzbl (%%\"REG_S\", %%\"REG_d\"), %%edi \\n\\t\"\n\"movzbl 1(%%\"REG_S\", %%\"REG_d\"), %%esi \\n\\t\"\n\"subl %%edi, %%esi \\n\\t\" - src[xx]\n\"imull %%ecx, %%esi \\n\\t\"\n\"shll $16, %%edi \\n\\t\"\n\"addl %%edi, %%esi \\n\\t\" *2*xalpha + src[xx]*(1-2*xalpha)\n\"mov %1, %%\"REG_D\" \\n\\t\"\n\"shrl $9, %%esi \\n\\t\"\n\"movw %%si, (%%\"REG_D\", %%\"REG_a\", 2) \\n\\t\"\n\"movzbl (%5, %%\"REG_d\"), %%edi \\n\\t\"\n\"movzbl 1(%5, %%\"REG_d\"), %%esi \\n\\t\"\n\"subl %%edi, %%esi \\n\\t\" - src[xx]\n\"imull %%ecx, %%esi \\n\\t\"\n\"shll $16, %%edi \\n\\t\"\n\"addl %%edi, %%esi \\n\\t\" *2*xalpha + src[xx]*(1-2*xalpha)\n\"mov %1, %%\"REG_D\" \\n\\t\"\n\"shrl $9, %%esi \\n\\t\"\n\"movw %%si, \"AV_STRINGIFY(VOF)\"(%%\"REG_D\", %%\"REG_a\", 2) \\n\\t\"\n\"addw %4, %%cx \\n\\t\"\n\"adc %3, %%\"REG_d\" \\n\\t\"\n\"add $1, %%\"REG_a\" \\n\\t\"\n\"cmp %2, %%\"REG_a\" \\n\\t\"\n\" jb 1b \\n\\t\"\n#if defined(ARCH_X86_64) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))\n:: \"m\" (src1), \"m\" (dst), \"g\" ((long)dstWidth), \"m\" (xInc_shr16), \"m\" (xInc_mask),\n#else\n:: \"m\" (src1), \"m\" (dst), \"m\" ((long)dstWidth), \"m\" (xInc_shr16), \"m\" (xInc_mask),\n#endif\n\"r\" (src2)\n: \"%\"REG_a, \"%\"REG_d, \"%ecx\", \"%\"REG_D, \"%esi\"\n);", "#ifdef HAVE_MMX2\n}", "#endif\n#else\nint VAR_2;", "unsigned int VAR_1=0;", "for (VAR_2=0;VAR_2<dstWidth;VAR_2++)", "{", "register unsigned int xx=VAR_1>>16;", "register unsigned int xalpha=(VAR_1&0xFFFF)>>9;", "dst[VAR_2]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);", "dst[VAR_2+VOFW]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);", "VAR_1+=xInc;", "}", "#endif\n}", "if(c->srcRange != c->dstRange && !(isRGB(c->dstFormat) || isBGR(c->dstFormat))){", "int VAR_2;", "if(c->srcRange){", "for (VAR_2=0; VAR_2<dstWidth; VAR_2++){", "dst[VAR_2 ]= (dst[VAR_2 ]*1799 + 4081085)>>11;", "dst[VAR_2+VOFW]= (dst[VAR_2+VOFW]*1799 + 4081085)>>11;", "}", "}else{", "for (VAR_2=0; VAR_2<dstWidth; VAR_2++){", "dst[VAR_2 ]= (dst[VAR_2 ]*4663 - 9289992)>>12;", "dst[VAR_2+VOFW]= (dst[VAR_2+VOFW]*4663 - 9289992)>>12;", "}", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11 ], [ 13, 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49, 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61, 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73, 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85, 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97, 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109, 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121, 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133, 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145, 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157, 159 ], [ 161 ], [ 163 ], [ 165, 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 179, 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, 247, 251, 253, 255, 257, 259, 261, 263, 267, 271, 273, 275, 277, 279, 281, 285, 289, 291, 293, 295, 297, 299, 301, 303, 305, 307, 309, 313, 315, 317, 319, 323, 325, 327, 329, 331, 333, 335, 337, 339, 341, 343, 345, 347 ], [ 349 ], [ 351 ], [ 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, 407, 409, 411, 413, 415, 417, 419, 421, 423, 427, 429, 431, 433, 435, 443, 445, 447, 449, 451, 453, 455, 457 ], [ 459, 461 ], [ 463, 465, 467 ], [ 469 ], [ 471 ], [ 473 ], [ 475 ], [ 477 ], [ 479 ], [ 481 ], [ 491 ], [ 493 ], [ 495, 497 ], [ 499 ], [ 501 ], [ 507 ], [ 509 ], [ 511 ], [ 513 ], [ 515 ], [ 517 ], [ 519 ], [ 521 ], [ 523 ], [ 525 ], [ 527 ], [ 529 ], [ 531 ] ]
12,507
static int qcow2_check(BlockDriverState *bs, BdrvCheckResult *result, BdrvCheckMode fix) { int ret = qcow2_check_refcounts(bs, result, fix); if (ret < 0) { return ret; } if (fix && result->check_errors == 0 && result->corruptions == 0) { return qcow2_mark_clean(bs); } return ret; }
true
qemu
24530f3e060c71b6c57c7a70336f08a13a8b0a3d
static int qcow2_check(BlockDriverState *bs, BdrvCheckResult *result, BdrvCheckMode fix) { int ret = qcow2_check_refcounts(bs, result, fix); if (ret < 0) { return ret; } if (fix && result->check_errors == 0 && result->corruptions == 0) { return qcow2_mark_clean(bs); } return ret; }
{ "code": [ " return qcow2_mark_clean(bs);" ], "line_no": [ 19 ] }
static int FUNC_0(BlockDriverState *VAR_0, BdrvCheckResult *VAR_1, BdrvCheckMode VAR_2) { int VAR_3 = qcow2_check_refcounts(VAR_0, VAR_1, VAR_2); if (VAR_3 < 0) { return VAR_3; } if (VAR_2 && VAR_1->check_errors == 0 && VAR_1->corruptions == 0) { return qcow2_mark_clean(VAR_0); } return VAR_3; }
[ "static int FUNC_0(BlockDriverState *VAR_0, BdrvCheckResult *VAR_1,\nBdrvCheckMode VAR_2)\n{", "int VAR_3 = qcow2_check_refcounts(VAR_0, VAR_1, VAR_2);", "if (VAR_3 < 0) {", "return VAR_3;", "}", "if (VAR_2 && VAR_1->check_errors == 0 && VAR_1->corruptions == 0) {", "return qcow2_mark_clean(VAR_0);", "}", "return VAR_3;", "}" ]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ] ]
12,508
static inline void gen_sync_flags(DisasContext *dc) { /* Sync the tb dependent flag between translate and runtime. */ if (dc->tb_flags != dc->synced_flags) { tcg_gen_movi_tl(env_flags, dc->tb_flags); dc->synced_flags = dc->tb_flags; } }
true
qemu
0c53d7342b4e8412f3b81eed67f053304813dc5d
static inline void gen_sync_flags(DisasContext *dc) { if (dc->tb_flags != dc->synced_flags) { tcg_gen_movi_tl(env_flags, dc->tb_flags); dc->synced_flags = dc->tb_flags; } }
{ "code": [ " if (dc->tb_flags != dc->synced_flags) {", " tcg_gen_movi_tl(env_flags, dc->tb_flags);" ], "line_no": [ 7, 9 ] }
static inline void FUNC_0(DisasContext *VAR_0) { if (VAR_0->tb_flags != VAR_0->synced_flags) { tcg_gen_movi_tl(env_flags, VAR_0->tb_flags); VAR_0->synced_flags = VAR_0->tb_flags; } }
[ "static inline void FUNC_0(DisasContext *VAR_0)\n{", "if (VAR_0->tb_flags != VAR_0->synced_flags) {", "tcg_gen_movi_tl(env_flags, VAR_0->tb_flags);", "VAR_0->synced_flags = VAR_0->tb_flags;", "}", "}" ]
[ 0, 1, 1, 0, 0, 0 ]
[ [ 1, 3 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ] ]
12,509
void avcodec_flush_buffers(AVCodecContext *avctx) { if(HAVE_PTHREADS && avctx->active_thread_type&FF_THREAD_FRAME) ff_thread_flush(avctx); if(avctx->codec->flush) avctx->codec->flush(avctx); }
true
FFmpeg
d1cf45911935cc4fed9afd3a37d99616d31eb9da
void avcodec_flush_buffers(AVCodecContext *avctx) { if(HAVE_PTHREADS && avctx->active_thread_type&FF_THREAD_FRAME) ff_thread_flush(avctx); if(avctx->codec->flush) avctx->codec->flush(avctx); }
{ "code": [ " if(avctx->codec->flush)" ], "line_no": [ 9 ] }
void FUNC_0(AVCodecContext *VAR_0) { if(HAVE_PTHREADS && VAR_0->active_thread_type&FF_THREAD_FRAME) ff_thread_flush(VAR_0); if(VAR_0->codec->flush) VAR_0->codec->flush(VAR_0); }
[ "void FUNC_0(AVCodecContext *VAR_0)\n{", "if(HAVE_PTHREADS && VAR_0->active_thread_type&FF_THREAD_FRAME)\nff_thread_flush(VAR_0);", "if(VAR_0->codec->flush)\nVAR_0->codec->flush(VAR_0);", "}" ]
[ 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5, 7 ], [ 9, 11 ], [ 13 ] ]
12,510
static int ipvideo_decode_block_opcode_0x5(IpvideoContext *s) { signed char x, y; /* copy a block from the previous frame using an expanded range; * need 2 more bytes */ CHECK_STREAM_PTR(2); x = *s->stream_ptr++; y = *s->stream_ptr++; debug_interplay (" motion bytes = %d, %d\n", x, y); return copy_from(s, &s->last_frame, x, y); }
false
FFmpeg
80ca19f766aea8f4724aac1b3faa772d25163c8a
static int ipvideo_decode_block_opcode_0x5(IpvideoContext *s) { signed char x, y; CHECK_STREAM_PTR(2); x = *s->stream_ptr++; y = *s->stream_ptr++; debug_interplay (" motion bytes = %d, %d\n", x, y); return copy_from(s, &s->last_frame, x, y); }
{ "code": [], "line_no": [] }
static int FUNC_0(IpvideoContext *VAR_0) { signed char VAR_1, VAR_2; CHECK_STREAM_PTR(2); VAR_1 = *VAR_0->stream_ptr++; VAR_2 = *VAR_0->stream_ptr++; debug_interplay (" motion bytes = %d, %d\n", VAR_1, VAR_2); return copy_from(VAR_0, &VAR_0->last_frame, VAR_1, VAR_2); }
[ "static int FUNC_0(IpvideoContext *VAR_0)\n{", "signed char VAR_1, VAR_2;", "CHECK_STREAM_PTR(2);", "VAR_1 = *VAR_0->stream_ptr++;", "VAR_2 = *VAR_0->stream_ptr++;", "debug_interplay (\" motion bytes = %d, %d\\n\", VAR_1, VAR_2);", "return copy_from(VAR_0, &VAR_0->last_frame, VAR_1, VAR_2);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 13 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ] ]
12,511
void smc91c111_init(NICInfo *nd, uint32_t base, qemu_irq irq) { smc91c111_state *s; int iomemtype; qemu_check_nic_model(nd, "smc91c111"); s = (smc91c111_state *)qemu_mallocz(sizeof(smc91c111_state)); iomemtype = cpu_register_io_memory(0, smc91c111_readfn, smc91c111_writefn, s); cpu_register_physical_memory(base, 16, iomemtype); s->irq = irq; memcpy(s->macaddr, nd->macaddr, 6); smc91c111_reset(s); s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, smc91c111_receive, smc91c111_can_receive, s); qemu_format_nic_info_str(s->vc, s->macaddr); /* ??? Save/restore. */ }
true
qemu
b946a1533209f61a93e34898aebb5b43154b99c3
void smc91c111_init(NICInfo *nd, uint32_t base, qemu_irq irq) { smc91c111_state *s; int iomemtype; qemu_check_nic_model(nd, "smc91c111"); s = (smc91c111_state *)qemu_mallocz(sizeof(smc91c111_state)); iomemtype = cpu_register_io_memory(0, smc91c111_readfn, smc91c111_writefn, s); cpu_register_physical_memory(base, 16, iomemtype); s->irq = irq; memcpy(s->macaddr, nd->macaddr, 6); smc91c111_reset(s); s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, smc91c111_receive, smc91c111_can_receive, s); qemu_format_nic_info_str(s->vc, s->macaddr); }
{ "code": [ " int iomemtype;", " int iomemtype;", " int iomemtype;", " iomemtype = cpu_register_io_memory(0, smc91c111_readfn,", " smc91c111_writefn, s);", " cpu_register_physical_memory(base, 16, iomemtype);", " smc91c111_receive, smc91c111_can_receive, s);", " int iomemtype;" ], "line_no": [ 7, 7, 7, 17, 19, 21, 35, 7 ] }
void FUNC_0(NICInfo *VAR_0, uint32_t VAR_1, qemu_irq VAR_2) { smc91c111_state *s; int VAR_3; qemu_check_nic_model(VAR_0, "smc91c111"); s = (smc91c111_state *)qemu_mallocz(sizeof(smc91c111_state)); VAR_3 = cpu_register_io_memory(0, smc91c111_readfn, smc91c111_writefn, s); cpu_register_physical_memory(VAR_1, 16, VAR_3); s->VAR_2 = VAR_2; memcpy(s->macaddr, VAR_0->macaddr, 6); smc91c111_reset(s); s->vc = qemu_new_vlan_client(VAR_0->vlan, VAR_0->model, VAR_0->name, smc91c111_receive, smc91c111_can_receive, s); qemu_format_nic_info_str(s->vc, s->macaddr); }
[ "void FUNC_0(NICInfo *VAR_0, uint32_t VAR_1, qemu_irq VAR_2)\n{", "smc91c111_state *s;", "int VAR_3;", "qemu_check_nic_model(VAR_0, \"smc91c111\");", "s = (smc91c111_state *)qemu_mallocz(sizeof(smc91c111_state));", "VAR_3 = cpu_register_io_memory(0, smc91c111_readfn,\nsmc91c111_writefn, s);", "cpu_register_physical_memory(VAR_1, 16, VAR_3);", "s->VAR_2 = VAR_2;", "memcpy(s->macaddr, VAR_0->macaddr, 6);", "smc91c111_reset(s);", "s->vc = qemu_new_vlan_client(VAR_0->vlan, VAR_0->model, VAR_0->name,\nsmc91c111_receive, smc91c111_can_receive, s);", "qemu_format_nic_info_str(s->vc, s->macaddr);", "}" ]
[ 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 15 ], [ 17, 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 33, 35 ], [ 37 ], [ 41 ] ]
12,512
static av_cold int vc2_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { int ret; int max_frame_bytes, sig_size = 256; VC2EncContext *s = avctx->priv_data; const char aux_data[] = "FFmpeg version "FFMPEG_VERSION; const int aux_data_size = sizeof(aux_data); const int header_size = 100 + aux_data_size; int64_t r_bitrate = avctx->bit_rate >> (s->interlaced); s->avctx = avctx; s->size_scaler = 1; s->prefix_bytes = 0; s->last_parse_code = 0; s->next_parse_offset = 0; /* Rate control */ max_frame_bytes = (av_rescale(r_bitrate, s->avctx->time_base.num, s->avctx->time_base.den) >> 3) - header_size; /* Find an appropriate size scaler */ while (sig_size > 255) { s->slice_max_bytes = FFALIGN(av_rescale(max_frame_bytes, 1, s->num_x*s->num_y), s->size_scaler); s->slice_max_bytes += 4 + s->prefix_bytes; sig_size = s->slice_max_bytes/s->size_scaler; /* Signalled slize size */ s->size_scaler <<= 1; } ret = ff_alloc_packet2(avctx, avpkt, max_frame_bytes*2, 0); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); return ret; } else { init_put_bits(&s->pb, avpkt->data, avpkt->size); } encode_frame(s, frame, aux_data, s->interlaced); if (s->interlaced) encode_frame(s, frame, NULL, 2); flush_put_bits(&s->pb); avpkt->size = put_bits_count(&s->pb) >> 3; *got_packet_ptr = 1; return 0; }
false
FFmpeg
dc0481f2fbae4d5942ccabf2061900da3ee85f30
static av_cold int vc2_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { int ret; int max_frame_bytes, sig_size = 256; VC2EncContext *s = avctx->priv_data; const char aux_data[] = "FFmpeg version "FFMPEG_VERSION; const int aux_data_size = sizeof(aux_data); const int header_size = 100 + aux_data_size; int64_t r_bitrate = avctx->bit_rate >> (s->interlaced); s->avctx = avctx; s->size_scaler = 1; s->prefix_bytes = 0; s->last_parse_code = 0; s->next_parse_offset = 0; max_frame_bytes = (av_rescale(r_bitrate, s->avctx->time_base.num, s->avctx->time_base.den) >> 3) - header_size; while (sig_size > 255) { s->slice_max_bytes = FFALIGN(av_rescale(max_frame_bytes, 1, s->num_x*s->num_y), s->size_scaler); s->slice_max_bytes += 4 + s->prefix_bytes; sig_size = s->slice_max_bytes/s->size_scaler; s->size_scaler <<= 1; } ret = ff_alloc_packet2(avctx, avpkt, max_frame_bytes*2, 0); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); return ret; } else { init_put_bits(&s->pb, avpkt->data, avpkt->size); } encode_frame(s, frame, aux_data, s->interlaced); if (s->interlaced) encode_frame(s, frame, NULL, 2); flush_put_bits(&s->pb); avpkt->size = put_bits_count(&s->pb) >> 3; *got_packet_ptr = 1; return 0; }
{ "code": [], "line_no": [] }
static av_cold int FUNC_0(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { int VAR_0; int VAR_1, VAR_2 = 256; VC2EncContext *s = avctx->priv_data; const char VAR_3[] = "FFmpeg version "FFMPEG_VERSION; const int VAR_4 = sizeof(VAR_3); const int VAR_5 = 100 + VAR_4; int64_t r_bitrate = avctx->bit_rate >> (s->interlaced); s->avctx = avctx; s->size_scaler = 1; s->prefix_bytes = 0; s->last_parse_code = 0; s->next_parse_offset = 0; VAR_1 = (av_rescale(r_bitrate, s->avctx->time_base.num, s->avctx->time_base.den) >> 3) - VAR_5; while (VAR_2 > 255) { s->slice_max_bytes = FFALIGN(av_rescale(VAR_1, 1, s->num_x*s->num_y), s->size_scaler); s->slice_max_bytes += 4 + s->prefix_bytes; VAR_2 = s->slice_max_bytes/s->size_scaler; s->size_scaler <<= 1; } VAR_0 = ff_alloc_packet2(avctx, avpkt, VAR_1*2, 0); if (VAR_0 < 0) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); return VAR_0; } else { init_put_bits(&s->pb, avpkt->data, avpkt->size); } encode_frame(s, frame, VAR_3, s->interlaced); if (s->interlaced) encode_frame(s, frame, NULL, 2); flush_put_bits(&s->pb); avpkt->size = put_bits_count(&s->pb) >> 3; *got_packet_ptr = 1; return 0; }
[ "static av_cold int FUNC_0(AVCodecContext *avctx, AVPacket *avpkt,\nconst AVFrame *frame, int *got_packet_ptr)\n{", "int VAR_0;", "int VAR_1, VAR_2 = 256;", "VC2EncContext *s = avctx->priv_data;", "const char VAR_3[] = \"FFmpeg version \"FFMPEG_VERSION;", "const int VAR_4 = sizeof(VAR_3);", "const int VAR_5 = 100 + VAR_4;", "int64_t r_bitrate = avctx->bit_rate >> (s->interlaced);", "s->avctx = avctx;", "s->size_scaler = 1;", "s->prefix_bytes = 0;", "s->last_parse_code = 0;", "s->next_parse_offset = 0;", "VAR_1 = (av_rescale(r_bitrate, s->avctx->time_base.num,\ns->avctx->time_base.den) >> 3) - VAR_5;", "while (VAR_2 > 255) {", "s->slice_max_bytes = FFALIGN(av_rescale(VAR_1, 1,\ns->num_x*s->num_y), s->size_scaler);", "s->slice_max_bytes += 4 + s->prefix_bytes;", "VAR_2 = s->slice_max_bytes/s->size_scaler;", "s->size_scaler <<= 1;", "}", "VAR_0 = ff_alloc_packet2(avctx, avpkt, VAR_1*2, 0);", "if (VAR_0 < 0) {", "av_log(avctx, AV_LOG_ERROR, \"Error getting output packet.\\n\");", "return VAR_0;", "} else {", "init_put_bits(&s->pb, avpkt->data, avpkt->size);", "}", "encode_frame(s, frame, VAR_3, s->interlaced);", "if (s->interlaced)\nencode_frame(s, frame, NULL, 2);", "flush_put_bits(&s->pb);", "avpkt->size = put_bits_count(&s->pb) >> 3;", "*got_packet_ptr = 1;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 37, 39 ], [ 45 ], [ 47, 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 77 ], [ 79, 81 ], [ 85 ], [ 87 ], [ 91 ], [ 95 ], [ 97 ] ]
12,513
static int estimate_best_b_count(MpegEncContext *s) { AVCodec *codec = avcodec_find_encoder(s->avctx->codec_id); AVCodecContext *c = avcodec_alloc_context3(NULL); AVFrame input[FF_MAX_B_FRAMES + 2]; const int scale = s->avctx->brd_scale; int i, j, out_size, p_lambda, b_lambda, lambda2; int64_t best_rd = INT64_MAX; int best_b_count = -1; assert(scale >= 0 && scale <= 3); //emms_c(); //s->next_picture_ptr->quality; p_lambda = s->last_lambda_for[AV_PICTURE_TYPE_P]; //p_lambda * FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset; b_lambda = s->last_lambda_for[AV_PICTURE_TYPE_B]; if (!b_lambda) // FIXME we should do this somewhere else b_lambda = p_lambda; lambda2 = (b_lambda * b_lambda + (1 << FF_LAMBDA_SHIFT) / 2) >> FF_LAMBDA_SHIFT; c->width = s->width >> scale; c->height = s->height >> scale; c->flags = CODEC_FLAG_QSCALE | CODEC_FLAG_PSNR | CODEC_FLAG_INPUT_PRESERVED /*| CODEC_FLAG_EMU_EDGE*/; c->flags |= s->avctx->flags & CODEC_FLAG_QPEL; c->mb_decision = s->avctx->mb_decision; c->me_cmp = s->avctx->me_cmp; c->mb_cmp = s->avctx->mb_cmp; c->me_sub_cmp = s->avctx->me_sub_cmp; c->pix_fmt = AV_PIX_FMT_YUV420P; c->time_base = s->avctx->time_base; c->max_b_frames = s->max_b_frames; if (avcodec_open2(c, codec, NULL) < 0) return -1; for (i = 0; i < s->max_b_frames + 2; i++) { int ysize = c->width * c->height; int csize = (c->width / 2) * (c->height / 2); Picture pre_input, *pre_input_ptr = i ? s->input_picture[i - 1] : s->next_picture_ptr; avcodec_get_frame_defaults(&input[i]); input[i].data[0] = av_malloc(ysize + 2 * csize); input[i].data[1] = input[i].data[0] + ysize; input[i].data[2] = input[i].data[1] + csize; input[i].linesize[0] = c->width; input[i].linesize[1] = input[i].linesize[2] = c->width / 2; if (pre_input_ptr && (!i || s->input_picture[i - 1])) { pre_input = *pre_input_ptr; if (!pre_input.shared && i) { pre_input.f.data[0] += INPLACE_OFFSET; pre_input.f.data[1] += INPLACE_OFFSET; pre_input.f.data[2] += INPLACE_OFFSET; } s->dsp.shrink[scale](input[i].data[0], input[i].linesize[0], pre_input.f.data[0], pre_input.f.linesize[0], c->width, c->height); s->dsp.shrink[scale](input[i].data[1], input[i].linesize[1], pre_input.f.data[1], pre_input.f.linesize[1], c->width >> 1, c->height >> 1); s->dsp.shrink[scale](input[i].data[2], input[i].linesize[2], pre_input.f.data[2], pre_input.f.linesize[2], c->width >> 1, c->height >> 1); } } for (j = 0; j < s->max_b_frames + 1; j++) { int64_t rd = 0; if (!s->input_picture[j]) break; c->error[0] = c->error[1] = c->error[2] = 0; input[0].pict_type = AV_PICTURE_TYPE_I; input[0].quality = 1 * FF_QP2LAMBDA; out_size = encode_frame(c, &input[0]); //rd += (out_size * lambda2) >> FF_LAMBDA_SHIFT; for (i = 0; i < s->max_b_frames + 1; i++) { int is_p = i % (j + 1) == j || i == s->max_b_frames; input[i + 1].pict_type = is_p ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_B; input[i + 1].quality = is_p ? p_lambda : b_lambda; out_size = encode_frame(c, &input[i + 1]); rd += (out_size * lambda2) >> (FF_LAMBDA_SHIFT - 3); } /* get the delayed frames */ while (out_size) { out_size = encode_frame(c, NULL); rd += (out_size * lambda2) >> (FF_LAMBDA_SHIFT - 3); } rd += c->error[0] + c->error[1] + c->error[2]; if (rd < best_rd) { best_rd = rd; best_b_count = j; } } avcodec_close(c); av_freep(&c); for (i = 0; i < s->max_b_frames + 2; i++) { av_freep(&input[i].data[0]); } return best_b_count; }
false
FFmpeg
aa241229891173b0357eee04e6ca78f806cc9c0c
static int estimate_best_b_count(MpegEncContext *s) { AVCodec *codec = avcodec_find_encoder(s->avctx->codec_id); AVCodecContext *c = avcodec_alloc_context3(NULL); AVFrame input[FF_MAX_B_FRAMES + 2]; const int scale = s->avctx->brd_scale; int i, j, out_size, p_lambda, b_lambda, lambda2; int64_t best_rd = INT64_MAX; int best_b_count = -1; assert(scale >= 0 && scale <= 3); p_lambda = s->last_lambda_for[AV_PICTURE_TYPE_P]; b_lambda = s->last_lambda_for[AV_PICTURE_TYPE_B]; if (!b_lambda) b_lambda = p_lambda; lambda2 = (b_lambda * b_lambda + (1 << FF_LAMBDA_SHIFT) / 2) >> FF_LAMBDA_SHIFT; c->width = s->width >> scale; c->height = s->height >> scale; c->flags = CODEC_FLAG_QSCALE | CODEC_FLAG_PSNR | CODEC_FLAG_INPUT_PRESERVED ; c->flags |= s->avctx->flags & CODEC_FLAG_QPEL; c->mb_decision = s->avctx->mb_decision; c->me_cmp = s->avctx->me_cmp; c->mb_cmp = s->avctx->mb_cmp; c->me_sub_cmp = s->avctx->me_sub_cmp; c->pix_fmt = AV_PIX_FMT_YUV420P; c->time_base = s->avctx->time_base; c->max_b_frames = s->max_b_frames; if (avcodec_open2(c, codec, NULL) < 0) return -1; for (i = 0; i < s->max_b_frames + 2; i++) { int ysize = c->width * c->height; int csize = (c->width / 2) * (c->height / 2); Picture pre_input, *pre_input_ptr = i ? s->input_picture[i - 1] : s->next_picture_ptr; avcodec_get_frame_defaults(&input[i]); input[i].data[0] = av_malloc(ysize + 2 * csize); input[i].data[1] = input[i].data[0] + ysize; input[i].data[2] = input[i].data[1] + csize; input[i].linesize[0] = c->width; input[i].linesize[1] = input[i].linesize[2] = c->width / 2; if (pre_input_ptr && (!i || s->input_picture[i - 1])) { pre_input = *pre_input_ptr; if (!pre_input.shared && i) { pre_input.f.data[0] += INPLACE_OFFSET; pre_input.f.data[1] += INPLACE_OFFSET; pre_input.f.data[2] += INPLACE_OFFSET; } s->dsp.shrink[scale](input[i].data[0], input[i].linesize[0], pre_input.f.data[0], pre_input.f.linesize[0], c->width, c->height); s->dsp.shrink[scale](input[i].data[1], input[i].linesize[1], pre_input.f.data[1], pre_input.f.linesize[1], c->width >> 1, c->height >> 1); s->dsp.shrink[scale](input[i].data[2], input[i].linesize[2], pre_input.f.data[2], pre_input.f.linesize[2], c->width >> 1, c->height >> 1); } } for (j = 0; j < s->max_b_frames + 1; j++) { int64_t rd = 0; if (!s->input_picture[j]) break; c->error[0] = c->error[1] = c->error[2] = 0; input[0].pict_type = AV_PICTURE_TYPE_I; input[0].quality = 1 * FF_QP2LAMBDA; out_size = encode_frame(c, &input[0]); for (i = 0; i < s->max_b_frames + 1; i++) { int is_p = i % (j + 1) == j || i == s->max_b_frames; input[i + 1].pict_type = is_p ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_B; input[i + 1].quality = is_p ? p_lambda : b_lambda; out_size = encode_frame(c, &input[i + 1]); rd += (out_size * lambda2) >> (FF_LAMBDA_SHIFT - 3); } while (out_size) { out_size = encode_frame(c, NULL); rd += (out_size * lambda2) >> (FF_LAMBDA_SHIFT - 3); } rd += c->error[0] + c->error[1] + c->error[2]; if (rd < best_rd) { best_rd = rd; best_b_count = j; } } avcodec_close(c); av_freep(&c); for (i = 0; i < s->max_b_frames + 2; i++) { av_freep(&input[i].data[0]); } return best_b_count; }
{ "code": [], "line_no": [] }
static int FUNC_0(MpegEncContext *VAR_0) { AVCodec *codec = avcodec_find_encoder(VAR_0->avctx->codec_id); AVCodecContext *c = avcodec_alloc_context3(NULL); AVFrame input[FF_MAX_B_FRAMES + 2]; const int VAR_1 = VAR_0->avctx->brd_scale; int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7; int64_t best_rd = INT64_MAX; int VAR_8 = -1; assert(VAR_1 >= 0 && VAR_1 <= 3); VAR_5 = VAR_0->last_lambda_for[AV_PICTURE_TYPE_P]; VAR_6 = VAR_0->last_lambda_for[AV_PICTURE_TYPE_B]; if (!VAR_6) VAR_6 = VAR_5; VAR_7 = (VAR_6 * VAR_6 + (1 << FF_LAMBDA_SHIFT) / 2) >> FF_LAMBDA_SHIFT; c->width = VAR_0->width >> VAR_1; c->height = VAR_0->height >> VAR_1; c->flags = CODEC_FLAG_QSCALE | CODEC_FLAG_PSNR | CODEC_FLAG_INPUT_PRESERVED ; c->flags |= VAR_0->avctx->flags & CODEC_FLAG_QPEL; c->mb_decision = VAR_0->avctx->mb_decision; c->me_cmp = VAR_0->avctx->me_cmp; c->mb_cmp = VAR_0->avctx->mb_cmp; c->me_sub_cmp = VAR_0->avctx->me_sub_cmp; c->pix_fmt = AV_PIX_FMT_YUV420P; c->time_base = VAR_0->avctx->time_base; c->max_b_frames = VAR_0->max_b_frames; if (avcodec_open2(c, codec, NULL) < 0) return -1; for (VAR_2 = 0; VAR_2 < VAR_0->max_b_frames + 2; VAR_2++) { int ysize = c->width * c->height; int csize = (c->width / 2) * (c->height / 2); Picture pre_input, *pre_input_ptr = VAR_2 ? VAR_0->input_picture[VAR_2 - 1] : VAR_0->next_picture_ptr; avcodec_get_frame_defaults(&input[VAR_2]); input[VAR_2].data[0] = av_malloc(ysize + 2 * csize); input[VAR_2].data[1] = input[VAR_2].data[0] + ysize; input[VAR_2].data[2] = input[VAR_2].data[1] + csize; input[VAR_2].linesize[0] = c->width; input[VAR_2].linesize[1] = input[VAR_2].linesize[2] = c->width / 2; if (pre_input_ptr && (!VAR_2 || VAR_0->input_picture[VAR_2 - 1])) { pre_input = *pre_input_ptr; if (!pre_input.shared && VAR_2) { pre_input.f.data[0] += INPLACE_OFFSET; pre_input.f.data[1] += INPLACE_OFFSET; pre_input.f.data[2] += INPLACE_OFFSET; } VAR_0->dsp.shrink[VAR_1](input[VAR_2].data[0], input[VAR_2].linesize[0], pre_input.f.data[0], pre_input.f.linesize[0], c->width, c->height); VAR_0->dsp.shrink[VAR_1](input[VAR_2].data[1], input[VAR_2].linesize[1], pre_input.f.data[1], pre_input.f.linesize[1], c->width >> 1, c->height >> 1); VAR_0->dsp.shrink[VAR_1](input[VAR_2].data[2], input[VAR_2].linesize[2], pre_input.f.data[2], pre_input.f.linesize[2], c->width >> 1, c->height >> 1); } } for (VAR_3 = 0; VAR_3 < VAR_0->max_b_frames + 1; VAR_3++) { int64_t rd = 0; if (!VAR_0->input_picture[VAR_3]) break; c->error[0] = c->error[1] = c->error[2] = 0; input[0].pict_type = AV_PICTURE_TYPE_I; input[0].quality = 1 * FF_QP2LAMBDA; VAR_4 = encode_frame(c, &input[0]); for (VAR_2 = 0; VAR_2 < VAR_0->max_b_frames + 1; VAR_2++) { int is_p = VAR_2 % (VAR_3 + 1) == VAR_3 || VAR_2 == VAR_0->max_b_frames; input[VAR_2 + 1].pict_type = is_p ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_B; input[VAR_2 + 1].quality = is_p ? VAR_5 : VAR_6; VAR_4 = encode_frame(c, &input[VAR_2 + 1]); rd += (VAR_4 * VAR_7) >> (FF_LAMBDA_SHIFT - 3); } while (VAR_4) { VAR_4 = encode_frame(c, NULL); rd += (VAR_4 * VAR_7) >> (FF_LAMBDA_SHIFT - 3); } rd += c->error[0] + c->error[1] + c->error[2]; if (rd < best_rd) { best_rd = rd; VAR_8 = VAR_3; } } avcodec_close(c); av_freep(&c); for (VAR_2 = 0; VAR_2 < VAR_0->max_b_frames + 2; VAR_2++) { av_freep(&input[VAR_2].data[0]); } return VAR_8; }
[ "static int FUNC_0(MpegEncContext *VAR_0)\n{", "AVCodec *codec = avcodec_find_encoder(VAR_0->avctx->codec_id);", "AVCodecContext *c = avcodec_alloc_context3(NULL);", "AVFrame input[FF_MAX_B_FRAMES + 2];", "const int VAR_1 = VAR_0->avctx->brd_scale;", "int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;", "int64_t best_rd = INT64_MAX;", "int VAR_8 = -1;", "assert(VAR_1 >= 0 && VAR_1 <= 3);", "VAR_5 = VAR_0->last_lambda_for[AV_PICTURE_TYPE_P];", "VAR_6 = VAR_0->last_lambda_for[AV_PICTURE_TYPE_B];", "if (!VAR_6)\nVAR_6 = VAR_5;", "VAR_7 = (VAR_6 * VAR_6 + (1 << FF_LAMBDA_SHIFT) / 2) >>\nFF_LAMBDA_SHIFT;", "c->width = VAR_0->width >> VAR_1;", "c->height = VAR_0->height >> VAR_1;", "c->flags = CODEC_FLAG_QSCALE | CODEC_FLAG_PSNR |\nCODEC_FLAG_INPUT_PRESERVED ;", "c->flags |= VAR_0->avctx->flags & CODEC_FLAG_QPEL;", "c->mb_decision = VAR_0->avctx->mb_decision;", "c->me_cmp = VAR_0->avctx->me_cmp;", "c->mb_cmp = VAR_0->avctx->mb_cmp;", "c->me_sub_cmp = VAR_0->avctx->me_sub_cmp;", "c->pix_fmt = AV_PIX_FMT_YUV420P;", "c->time_base = VAR_0->avctx->time_base;", "c->max_b_frames = VAR_0->max_b_frames;", "if (avcodec_open2(c, codec, NULL) < 0)\nreturn -1;", "for (VAR_2 = 0; VAR_2 < VAR_0->max_b_frames + 2; VAR_2++) {", "int ysize = c->width * c->height;", "int csize = (c->width / 2) * (c->height / 2);", "Picture pre_input, *pre_input_ptr = VAR_2 ? VAR_0->input_picture[VAR_2 - 1] :\nVAR_0->next_picture_ptr;", "avcodec_get_frame_defaults(&input[VAR_2]);", "input[VAR_2].data[0] = av_malloc(ysize + 2 * csize);", "input[VAR_2].data[1] = input[VAR_2].data[0] + ysize;", "input[VAR_2].data[2] = input[VAR_2].data[1] + csize;", "input[VAR_2].linesize[0] = c->width;", "input[VAR_2].linesize[1] =\ninput[VAR_2].linesize[2] = c->width / 2;", "if (pre_input_ptr && (!VAR_2 || VAR_0->input_picture[VAR_2 - 1])) {", "pre_input = *pre_input_ptr;", "if (!pre_input.shared && VAR_2) {", "pre_input.f.data[0] += INPLACE_OFFSET;", "pre_input.f.data[1] += INPLACE_OFFSET;", "pre_input.f.data[2] += INPLACE_OFFSET;", "}", "VAR_0->dsp.shrink[VAR_1](input[VAR_2].data[0], input[VAR_2].linesize[0],\npre_input.f.data[0], pre_input.f.linesize[0],\nc->width, c->height);", "VAR_0->dsp.shrink[VAR_1](input[VAR_2].data[1], input[VAR_2].linesize[1],\npre_input.f.data[1], pre_input.f.linesize[1],\nc->width >> 1, c->height >> 1);", "VAR_0->dsp.shrink[VAR_1](input[VAR_2].data[2], input[VAR_2].linesize[2],\npre_input.f.data[2], pre_input.f.linesize[2],\nc->width >> 1, c->height >> 1);", "}", "}", "for (VAR_3 = 0; VAR_3 < VAR_0->max_b_frames + 1; VAR_3++) {", "int64_t rd = 0;", "if (!VAR_0->input_picture[VAR_3])\nbreak;", "c->error[0] = c->error[1] = c->error[2] = 0;", "input[0].pict_type = AV_PICTURE_TYPE_I;", "input[0].quality = 1 * FF_QP2LAMBDA;", "VAR_4 = encode_frame(c, &input[0]);", "for (VAR_2 = 0; VAR_2 < VAR_0->max_b_frames + 1; VAR_2++) {", "int is_p = VAR_2 % (VAR_3 + 1) == VAR_3 || VAR_2 == VAR_0->max_b_frames;", "input[VAR_2 + 1].pict_type = is_p ?\nAV_PICTURE_TYPE_P : AV_PICTURE_TYPE_B;", "input[VAR_2 + 1].quality = is_p ? VAR_5 : VAR_6;", "VAR_4 = encode_frame(c, &input[VAR_2 + 1]);", "rd += (VAR_4 * VAR_7) >> (FF_LAMBDA_SHIFT - 3);", "}", "while (VAR_4) {", "VAR_4 = encode_frame(c, NULL);", "rd += (VAR_4 * VAR_7) >> (FF_LAMBDA_SHIFT - 3);", "}", "rd += c->error[0] + c->error[1] + c->error[2];", "if (rd < best_rd) {", "best_rd = rd;", "VAR_8 = VAR_3;", "}", "}", "avcodec_close(c);", "av_freep(&c);", "for (VAR_2 = 0; VAR_2 < VAR_0->max_b_frames + 2; VAR_2++) {", "av_freep(&input[VAR_2].data[0]);", "}", "return VAR_8;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 29 ], [ 33 ], [ 35, 37 ], [ 39, 41 ], [ 45 ], [ 47 ], [ 49, 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71, 73 ], [ 77 ], [ 79 ], [ 81 ], [ 83, 85 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99, 101 ], [ 105 ], [ 107 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 123, 125, 127 ], [ 129, 131, 133 ], [ 135, 137, 139 ], [ 141 ], [ 143 ], [ 147 ], [ 149 ], [ 153, 155 ], [ 159 ], [ 163 ], [ 165 ], [ 169 ], [ 177 ], [ 179 ], [ 183, 185 ], [ 187 ], [ 191 ], [ 195 ], [ 197 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 213 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 229 ], [ 231 ], [ 235 ], [ 237 ], [ 239 ], [ 243 ], [ 245 ] ]
12,514
static void show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_idx) { AVStream *stream = fmt_ctx->streams[stream_idx]; AVCodecContext *dec_ctx; AVCodec *dec; char val_str[128]; AVRational display_aspect_ratio; struct print_buf pbuf = {.s = NULL}; print_section_header("stream"); print_int("index", stream->index); if ((dec_ctx = stream->codec)) { if ((dec = dec_ctx->codec)) { print_str("codec_name", dec->name); print_str("codec_long_name", dec->long_name); } else { print_str("codec_name", "unknown"); } print_str("codec_type", av_x_if_null(av_get_media_type_string(dec_ctx->codec_type), "unknown")); print_fmt("codec_time_base", "%d/%d", dec_ctx->time_base.num, dec_ctx->time_base.den); /* print AVI/FourCC tag */ av_get_codec_tag_string(val_str, sizeof(val_str), dec_ctx->codec_tag); print_str("codec_tag_string", val_str); print_fmt("codec_tag", "0x%04x", dec_ctx->codec_tag); switch (dec_ctx->codec_type) { case AVMEDIA_TYPE_VIDEO: print_int("width", dec_ctx->width); print_int("height", dec_ctx->height); print_int("has_b_frames", dec_ctx->has_b_frames); if (dec_ctx->sample_aspect_ratio.num) { print_fmt("sample_aspect_ratio", "%d:%d", dec_ctx->sample_aspect_ratio.num, dec_ctx->sample_aspect_ratio.den); av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, dec_ctx->width * dec_ctx->sample_aspect_ratio.num, dec_ctx->height * dec_ctx->sample_aspect_ratio.den, 1024*1024); print_fmt("display_aspect_ratio", "%d:%d", display_aspect_ratio.num, display_aspect_ratio.den); } print_str("pix_fmt", av_x_if_null(av_get_pix_fmt_name(dec_ctx->pix_fmt), "unknown")); print_int("level", dec_ctx->level); break; case AVMEDIA_TYPE_AUDIO: print_str("sample_fmt", av_x_if_null(av_get_sample_fmt_name(dec_ctx->sample_fmt), "unknown")); print_val("sample_rate", dec_ctx->sample_rate, unit_hertz_str); print_int("channels", dec_ctx->channels); print_int("bits_per_sample", av_get_bits_per_sample(dec_ctx->codec_id)); break; } } else { print_str("codec_type", "unknown"); } if (dec_ctx->codec && dec_ctx->codec->priv_class) { const AVOption *opt = NULL; while (opt = av_opt_next(dec_ctx->priv_data,opt)) { uint8_t *str; if (opt->flags) continue; if (av_opt_get(dec_ctx->priv_data, opt->name, 0, &str) >= 0) { print_str(opt->name, str); av_free(str); } } } if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS) print_fmt("id", "0x%x", stream->id); print_fmt("r_frame_rate", "%d/%d", stream->r_frame_rate.num, stream->r_frame_rate.den); print_fmt("avg_frame_rate", "%d/%d", stream->avg_frame_rate.num, stream->avg_frame_rate.den); print_fmt("time_base", "%d/%d", stream->time_base.num, stream->time_base.den); print_time("start_time", stream->start_time, &stream->time_base); print_time("duration", stream->duration, &stream->time_base); if (stream->nb_frames) print_fmt("nb_frames", "%"PRId64, stream->nb_frames); show_tags(stream->metadata); print_section_footer("stream"); av_free(pbuf.s); fflush(stdout); }
false
FFmpeg
0491a2a07a44f6e5e6f34081835e402c07025fd2
static void show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_idx) { AVStream *stream = fmt_ctx->streams[stream_idx]; AVCodecContext *dec_ctx; AVCodec *dec; char val_str[128]; AVRational display_aspect_ratio; struct print_buf pbuf = {.s = NULL}; print_section_header("stream"); print_int("index", stream->index); if ((dec_ctx = stream->codec)) { if ((dec = dec_ctx->codec)) { print_str("codec_name", dec->name); print_str("codec_long_name", dec->long_name); } else { print_str("codec_name", "unknown"); } print_str("codec_type", av_x_if_null(av_get_media_type_string(dec_ctx->codec_type), "unknown")); print_fmt("codec_time_base", "%d/%d", dec_ctx->time_base.num, dec_ctx->time_base.den); av_get_codec_tag_string(val_str, sizeof(val_str), dec_ctx->codec_tag); print_str("codec_tag_string", val_str); print_fmt("codec_tag", "0x%04x", dec_ctx->codec_tag); switch (dec_ctx->codec_type) { case AVMEDIA_TYPE_VIDEO: print_int("width", dec_ctx->width); print_int("height", dec_ctx->height); print_int("has_b_frames", dec_ctx->has_b_frames); if (dec_ctx->sample_aspect_ratio.num) { print_fmt("sample_aspect_ratio", "%d:%d", dec_ctx->sample_aspect_ratio.num, dec_ctx->sample_aspect_ratio.den); av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, dec_ctx->width * dec_ctx->sample_aspect_ratio.num, dec_ctx->height * dec_ctx->sample_aspect_ratio.den, 1024*1024); print_fmt("display_aspect_ratio", "%d:%d", display_aspect_ratio.num, display_aspect_ratio.den); } print_str("pix_fmt", av_x_if_null(av_get_pix_fmt_name(dec_ctx->pix_fmt), "unknown")); print_int("level", dec_ctx->level); break; case AVMEDIA_TYPE_AUDIO: print_str("sample_fmt", av_x_if_null(av_get_sample_fmt_name(dec_ctx->sample_fmt), "unknown")); print_val("sample_rate", dec_ctx->sample_rate, unit_hertz_str); print_int("channels", dec_ctx->channels); print_int("bits_per_sample", av_get_bits_per_sample(dec_ctx->codec_id)); break; } } else { print_str("codec_type", "unknown"); } if (dec_ctx->codec && dec_ctx->codec->priv_class) { const AVOption *opt = NULL; while (opt = av_opt_next(dec_ctx->priv_data,opt)) { uint8_t *str; if (opt->flags) continue; if (av_opt_get(dec_ctx->priv_data, opt->name, 0, &str) >= 0) { print_str(opt->name, str); av_free(str); } } } if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS) print_fmt("id", "0x%x", stream->id); print_fmt("r_frame_rate", "%d/%d", stream->r_frame_rate.num, stream->r_frame_rate.den); print_fmt("avg_frame_rate", "%d/%d", stream->avg_frame_rate.num, stream->avg_frame_rate.den); print_fmt("time_base", "%d/%d", stream->time_base.num, stream->time_base.den); print_time("start_time", stream->start_time, &stream->time_base); print_time("duration", stream->duration, &stream->time_base); if (stream->nb_frames) print_fmt("nb_frames", "%"PRId64, stream->nb_frames); show_tags(stream->metadata); print_section_footer("stream"); av_free(pbuf.s); fflush(stdout); }
{ "code": [], "line_no": [] }
static void FUNC_0(WriterContext *VAR_0, AVFormatContext *VAR_1, int VAR_2) { AVStream *stream = VAR_1->streams[VAR_2]; AVCodecContext *dec_ctx; AVCodec *dec; char VAR_3[128]; AVRational display_aspect_ratio; struct print_buf VAR_4 = {.s = NULL}; print_section_header("stream"); print_int("index", stream->index); if ((dec_ctx = stream->codec)) { if ((dec = dec_ctx->codec)) { print_str("codec_name", dec->name); print_str("codec_long_name", dec->long_name); } else { print_str("codec_name", "unknown"); } print_str("codec_type", av_x_if_null(av_get_media_type_string(dec_ctx->codec_type), "unknown")); print_fmt("codec_time_base", "%d/%d", dec_ctx->time_base.num, dec_ctx->time_base.den); av_get_codec_tag_string(VAR_3, sizeof(VAR_3), dec_ctx->codec_tag); print_str("codec_tag_string", VAR_3); print_fmt("codec_tag", "0x%04x", dec_ctx->codec_tag); switch (dec_ctx->codec_type) { case AVMEDIA_TYPE_VIDEO: print_int("width", dec_ctx->width); print_int("height", dec_ctx->height); print_int("has_b_frames", dec_ctx->has_b_frames); if (dec_ctx->sample_aspect_ratio.num) { print_fmt("sample_aspect_ratio", "%d:%d", dec_ctx->sample_aspect_ratio.num, dec_ctx->sample_aspect_ratio.den); av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, dec_ctx->width * dec_ctx->sample_aspect_ratio.num, dec_ctx->height * dec_ctx->sample_aspect_ratio.den, 1024*1024); print_fmt("display_aspect_ratio", "%d:%d", display_aspect_ratio.num, display_aspect_ratio.den); } print_str("pix_fmt", av_x_if_null(av_get_pix_fmt_name(dec_ctx->pix_fmt), "unknown")); print_int("level", dec_ctx->level); break; case AVMEDIA_TYPE_AUDIO: print_str("sample_fmt", av_x_if_null(av_get_sample_fmt_name(dec_ctx->sample_fmt), "unknown")); print_val("sample_rate", dec_ctx->sample_rate, unit_hertz_str); print_int("channels", dec_ctx->channels); print_int("bits_per_sample", av_get_bits_per_sample(dec_ctx->codec_id)); break; } } else { print_str("codec_type", "unknown"); } if (dec_ctx->codec && dec_ctx->codec->priv_class) { const AVOption *VAR_5 = NULL; while (VAR_5 = av_opt_next(dec_ctx->priv_data,VAR_5)) { uint8_t *str; if (VAR_5->flags) continue; if (av_opt_get(dec_ctx->priv_data, VAR_5->name, 0, &str) >= 0) { print_str(VAR_5->name, str); av_free(str); } } } if (VAR_1->iformat->flags & AVFMT_SHOW_IDS) print_fmt("id", "0x%x", stream->id); print_fmt("r_frame_rate", "%d/%d", stream->r_frame_rate.num, stream->r_frame_rate.den); print_fmt("avg_frame_rate", "%d/%d", stream->avg_frame_rate.num, stream->avg_frame_rate.den); print_fmt("time_base", "%d/%d", stream->time_base.num, stream->time_base.den); print_time("start_time", stream->start_time, &stream->time_base); print_time("duration", stream->duration, &stream->time_base); if (stream->nb_frames) print_fmt("nb_frames", "%"PRId64, stream->nb_frames); show_tags(stream->metadata); print_section_footer("stream"); av_free(VAR_4.s); fflush(stdout); }
[ "static void FUNC_0(WriterContext *VAR_0, AVFormatContext *VAR_1, int VAR_2)\n{", "AVStream *stream = VAR_1->streams[VAR_2];", "AVCodecContext *dec_ctx;", "AVCodec *dec;", "char VAR_3[128];", "AVRational display_aspect_ratio;", "struct print_buf VAR_4 = {.s = NULL};", "print_section_header(\"stream\");", "print_int(\"index\", stream->index);", "if ((dec_ctx = stream->codec)) {", "if ((dec = dec_ctx->codec)) {", "print_str(\"codec_name\", dec->name);", "print_str(\"codec_long_name\", dec->long_name);", "} else {", "print_str(\"codec_name\", \"unknown\");", "}", "print_str(\"codec_type\", av_x_if_null(av_get_media_type_string(dec_ctx->codec_type), \"unknown\"));", "print_fmt(\"codec_time_base\", \"%d/%d\", dec_ctx->time_base.num, dec_ctx->time_base.den);", "av_get_codec_tag_string(VAR_3, sizeof(VAR_3), dec_ctx->codec_tag);", "print_str(\"codec_tag_string\", VAR_3);", "print_fmt(\"codec_tag\", \"0x%04x\", dec_ctx->codec_tag);", "switch (dec_ctx->codec_type) {", "case AVMEDIA_TYPE_VIDEO:\nprint_int(\"width\", dec_ctx->width);", "print_int(\"height\", dec_ctx->height);", "print_int(\"has_b_frames\", dec_ctx->has_b_frames);", "if (dec_ctx->sample_aspect_ratio.num) {", "print_fmt(\"sample_aspect_ratio\", \"%d:%d\",\ndec_ctx->sample_aspect_ratio.num,\ndec_ctx->sample_aspect_ratio.den);", "av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,\ndec_ctx->width * dec_ctx->sample_aspect_ratio.num,\ndec_ctx->height * dec_ctx->sample_aspect_ratio.den,\n1024*1024);", "print_fmt(\"display_aspect_ratio\", \"%d:%d\",\ndisplay_aspect_ratio.num,\ndisplay_aspect_ratio.den);", "}", "print_str(\"pix_fmt\", av_x_if_null(av_get_pix_fmt_name(dec_ctx->pix_fmt), \"unknown\"));", "print_int(\"level\", dec_ctx->level);", "break;", "case AVMEDIA_TYPE_AUDIO:\nprint_str(\"sample_fmt\",\nav_x_if_null(av_get_sample_fmt_name(dec_ctx->sample_fmt), \"unknown\"));", "print_val(\"sample_rate\", dec_ctx->sample_rate, unit_hertz_str);", "print_int(\"channels\", dec_ctx->channels);", "print_int(\"bits_per_sample\", av_get_bits_per_sample(dec_ctx->codec_id));", "break;", "}", "} else {", "print_str(\"codec_type\", \"unknown\");", "}", "if (dec_ctx->codec && dec_ctx->codec->priv_class) {", "const AVOption *VAR_5 = NULL;", "while (VAR_5 = av_opt_next(dec_ctx->priv_data,VAR_5)) {", "uint8_t *str;", "if (VAR_5->flags) continue;", "if (av_opt_get(dec_ctx->priv_data, VAR_5->name, 0, &str) >= 0) {", "print_str(VAR_5->name, str);", "av_free(str);", "}", "}", "}", "if (VAR_1->iformat->flags & AVFMT_SHOW_IDS)\nprint_fmt(\"id\", \"0x%x\", stream->id);", "print_fmt(\"r_frame_rate\", \"%d/%d\", stream->r_frame_rate.num, stream->r_frame_rate.den);", "print_fmt(\"avg_frame_rate\", \"%d/%d\", stream->avg_frame_rate.num, stream->avg_frame_rate.den);", "print_fmt(\"time_base\", \"%d/%d\", stream->time_base.num, stream->time_base.den);", "print_time(\"start_time\", stream->start_time, &stream->time_base);", "print_time(\"duration\", stream->duration, &stream->time_base);", "if (stream->nb_frames)\nprint_fmt(\"nb_frames\", \"%\"PRId64, stream->nb_frames);", "show_tags(stream->metadata);", "print_section_footer(\"stream\");", "av_free(VAR_4.s);", "fflush(stdout);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61, 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71, 73, 75 ], [ 77, 79, 81, 83 ], [ 85, 87, 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 101, 103, 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 147, 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161, 163 ], [ 167 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ] ]
12,515
static void spapr_cpu_reset(void *opaque) { PowerPCCPU *cpu = opaque; CPUState *cs = CPU(cpu); CPUPPCState *env = &cpu->env; cpu_reset(cs); /* All CPUs start halted. CPU0 is unhalted from the machine level * reset code and the rest are explicitly started up by the guest * using an RTAS call */ cs->halted = 1; env->spr[SPR_HIOR] = 0; env->external_htab = (uint8_t *)spapr->htab; if (kvm_enabled() && !env->external_htab) { /* * HV KVM, set external_htab to 1 so our ppc_hash64_load_hpte* * functions do the right thing. */ env->external_htab = (void *)1; } env->htab_base = -1; env->htab_mask = HTAB_SIZE(spapr) - 1; env->spr[SPR_SDR1] = (target_ulong)(uintptr_t)spapr->htab | (spapr->htab_shift - 18); }
true
qemu
f3c75d42adbba553eaf218a832d4fbea32c8f7b8
static void spapr_cpu_reset(void *opaque) { PowerPCCPU *cpu = opaque; CPUState *cs = CPU(cpu); CPUPPCState *env = &cpu->env; cpu_reset(cs); cs->halted = 1; env->spr[SPR_HIOR] = 0; env->external_htab = (uint8_t *)spapr->htab; if (kvm_enabled() && !env->external_htab) { env->external_htab = (void *)1; } env->htab_base = -1; env->htab_mask = HTAB_SIZE(spapr) - 1; env->spr[SPR_SDR1] = (target_ulong)(uintptr_t)spapr->htab | (spapr->htab_shift - 18); }
{ "code": [ " env->htab_mask = HTAB_SIZE(spapr) - 1;" ], "line_no": [ 49 ] }
static void FUNC_0(void *VAR_0) { PowerPCCPU *cpu = VAR_0; CPUState *cs = CPU(cpu); CPUPPCState *env = &cpu->env; cpu_reset(cs); cs->halted = 1; env->spr[SPR_HIOR] = 0; env->external_htab = (uint8_t *)spapr->htab; if (kvm_enabled() && !env->external_htab) { env->external_htab = (void *)1; } env->htab_base = -1; env->htab_mask = HTAB_SIZE(spapr) - 1; env->spr[SPR_SDR1] = (target_ulong)(uintptr_t)spapr->htab | (spapr->htab_shift - 18); }
[ "static void FUNC_0(void *VAR_0)\n{", "PowerPCCPU *cpu = VAR_0;", "CPUState *cs = CPU(cpu);", "CPUPPCState *env = &cpu->env;", "cpu_reset(cs);", "cs->halted = 1;", "env->spr[SPR_HIOR] = 0;", "env->external_htab = (uint8_t *)spapr->htab;", "if (kvm_enabled() && !env->external_htab) {", "env->external_htab = (void *)1;", "}", "env->htab_base = -1;", "env->htab_mask = HTAB_SIZE(spapr) - 1;", "env->spr[SPR_SDR1] = (target_ulong)(uintptr_t)spapr->htab |\n(spapr->htab_shift - 18);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 23 ], [ 27 ], [ 31 ], [ 33 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51, 53 ], [ 55 ] ]
12,516
static void exynos4210_fimd_update(void *opaque) { Exynos4210fimdState *s = (Exynos4210fimdState *)opaque; DisplaySurface *surface = qemu_console_surface(s->console); Exynos4210fimdWindow *w; int i, line; hwaddr fb_line_addr, inc_size; int scrn_height; int first_line = -1, last_line = -1, scrn_width; bool blend = false; uint8_t *host_fb_addr; bool is_dirty = false; const int global_width = (s->vidtcon[2] & FIMD_VIDTCON2_SIZE_MASK) + 1; const int global_height = ((s->vidtcon[2] >> FIMD_VIDTCON2_VER_SHIFT) & FIMD_VIDTCON2_SIZE_MASK) + 1; if (!s || !s->console || !surface_bits_per_pixel(surface) || !s->enabled) { return; } exynos4210_update_resolution(s); for (i = 0; i < NUM_OF_WINDOWS; i++) { w = &s->window[i]; if ((w->wincon & FIMD_WINCON_ENWIN) && w->host_fb_addr) { scrn_height = w->rightbot_y - w->lefttop_y + 1; scrn_width = w->virtpage_width; /* Total width of virtual screen page in bytes */ inc_size = scrn_width + w->virtpage_offsize; memory_region_sync_dirty_bitmap(w->mem_section.mr); host_fb_addr = w->host_fb_addr; fb_line_addr = w->mem_section.offset_within_region; for (line = 0; line < scrn_height; line++) { is_dirty = memory_region_get_dirty(w->mem_section.mr, fb_line_addr, scrn_width, DIRTY_MEMORY_VGA); if (s->invalidate || is_dirty) { if (first_line == -1) { first_line = line; } last_line = line; w->draw_line(w, host_fb_addr, s->ifb + w->lefttop_x * RGBA_SIZE + (w->lefttop_y + line) * global_width * RGBA_SIZE, blend); } host_fb_addr += inc_size; fb_line_addr += inc_size; is_dirty = false; } memory_region_reset_dirty(w->mem_section.mr, w->mem_section.offset_within_region, w->fb_len, DIRTY_MEMORY_VGA); blend = true; } } /* Copy resulting image to QEMU_CONSOLE. */ if (first_line >= 0) { uint8_t *d; int bpp; bpp = surface_bits_per_pixel(surface); fimd_update_putpix_qemu(bpp); bpp = (bpp + 1) >> 3; d = surface_data(surface); for (line = first_line; line <= last_line; line++) { fimd_copy_line_toqemu(global_width, s->ifb + global_width * line * RGBA_SIZE, d + global_width * line * bpp); } dpy_gfx_update(s->console, 0, 0, global_width, global_height); } s->invalidate = false; s->vidintcon[1] |= FIMD_VIDINT_INTFRMPEND; if ((s->vidcon[0] & FIMD_VIDCON0_ENVID_F) == 0) { exynos4210_fimd_enable(s, false); } exynos4210_fimd_update_irq(s); }
true
qemu
522fccbe71e35efc96f66cb475f778c2ce02e9fc
static void exynos4210_fimd_update(void *opaque) { Exynos4210fimdState *s = (Exynos4210fimdState *)opaque; DisplaySurface *surface = qemu_console_surface(s->console); Exynos4210fimdWindow *w; int i, line; hwaddr fb_line_addr, inc_size; int scrn_height; int first_line = -1, last_line = -1, scrn_width; bool blend = false; uint8_t *host_fb_addr; bool is_dirty = false; const int global_width = (s->vidtcon[2] & FIMD_VIDTCON2_SIZE_MASK) + 1; const int global_height = ((s->vidtcon[2] >> FIMD_VIDTCON2_VER_SHIFT) & FIMD_VIDTCON2_SIZE_MASK) + 1; if (!s || !s->console || !surface_bits_per_pixel(surface) || !s->enabled) { return; } exynos4210_update_resolution(s); for (i = 0; i < NUM_OF_WINDOWS; i++) { w = &s->window[i]; if ((w->wincon & FIMD_WINCON_ENWIN) && w->host_fb_addr) { scrn_height = w->rightbot_y - w->lefttop_y + 1; scrn_width = w->virtpage_width; inc_size = scrn_width + w->virtpage_offsize; memory_region_sync_dirty_bitmap(w->mem_section.mr); host_fb_addr = w->host_fb_addr; fb_line_addr = w->mem_section.offset_within_region; for (line = 0; line < scrn_height; line++) { is_dirty = memory_region_get_dirty(w->mem_section.mr, fb_line_addr, scrn_width, DIRTY_MEMORY_VGA); if (s->invalidate || is_dirty) { if (first_line == -1) { first_line = line; } last_line = line; w->draw_line(w, host_fb_addr, s->ifb + w->lefttop_x * RGBA_SIZE + (w->lefttop_y + line) * global_width * RGBA_SIZE, blend); } host_fb_addr += inc_size; fb_line_addr += inc_size; is_dirty = false; } memory_region_reset_dirty(w->mem_section.mr, w->mem_section.offset_within_region, w->fb_len, DIRTY_MEMORY_VGA); blend = true; } } if (first_line >= 0) { uint8_t *d; int bpp; bpp = surface_bits_per_pixel(surface); fimd_update_putpix_qemu(bpp); bpp = (bpp + 1) >> 3; d = surface_data(surface); for (line = first_line; line <= last_line; line++) { fimd_copy_line_toqemu(global_width, s->ifb + global_width * line * RGBA_SIZE, d + global_width * line * bpp); } dpy_gfx_update(s->console, 0, 0, global_width, global_height); } s->invalidate = false; s->vidintcon[1] |= FIMD_VIDINT_INTFRMPEND; if ((s->vidcon[0] & FIMD_VIDCON0_ENVID_F) == 0) { exynos4210_fimd_enable(s, false); } exynos4210_fimd_update_irq(s); }
{ "code": [ " DisplaySurface *surface = qemu_console_surface(s->console);", " if (!s || !s->console || !surface_bits_per_pixel(surface) ||", " !s->enabled) {" ], "line_no": [ 7, 33, 35 ] }
static void FUNC_0(void *VAR_0) { Exynos4210fimdState *s = (Exynos4210fimdState *)VAR_0; DisplaySurface *surface = qemu_console_surface(s->console); Exynos4210fimdWindow *w; int VAR_1, VAR_2; hwaddr fb_line_addr, inc_size; int VAR_3; int VAR_4 = -1, VAR_5 = -1, VAR_6; bool blend = false; uint8_t *host_fb_addr; bool is_dirty = false; const int VAR_7 = (s->vidtcon[2] & FIMD_VIDTCON2_SIZE_MASK) + 1; const int VAR_8 = ((s->vidtcon[2] >> FIMD_VIDTCON2_VER_SHIFT) & FIMD_VIDTCON2_SIZE_MASK) + 1; if (!s || !s->console || !surface_bits_per_pixel(surface) || !s->enabled) { return; } exynos4210_update_resolution(s); for (VAR_1 = 0; VAR_1 < NUM_OF_WINDOWS; VAR_1++) { w = &s->window[VAR_1]; if ((w->wincon & FIMD_WINCON_ENWIN) && w->host_fb_addr) { VAR_3 = w->rightbot_y - w->lefttop_y + 1; VAR_6 = w->virtpage_width; inc_size = VAR_6 + w->virtpage_offsize; memory_region_sync_dirty_bitmap(w->mem_section.mr); host_fb_addr = w->host_fb_addr; fb_line_addr = w->mem_section.offset_within_region; for (VAR_2 = 0; VAR_2 < VAR_3; VAR_2++) { is_dirty = memory_region_get_dirty(w->mem_section.mr, fb_line_addr, VAR_6, DIRTY_MEMORY_VGA); if (s->invalidate || is_dirty) { if (VAR_4 == -1) { VAR_4 = VAR_2; } VAR_5 = VAR_2; w->draw_line(w, host_fb_addr, s->ifb + w->lefttop_x * RGBA_SIZE + (w->lefttop_y + VAR_2) * VAR_7 * RGBA_SIZE, blend); } host_fb_addr += inc_size; fb_line_addr += inc_size; is_dirty = false; } memory_region_reset_dirty(w->mem_section.mr, w->mem_section.offset_within_region, w->fb_len, DIRTY_MEMORY_VGA); blend = true; } } if (VAR_4 >= 0) { uint8_t *d; int VAR_9; VAR_9 = surface_bits_per_pixel(surface); fimd_update_putpix_qemu(VAR_9); VAR_9 = (VAR_9 + 1) >> 3; d = surface_data(surface); for (VAR_2 = VAR_4; VAR_2 <= VAR_5; VAR_2++) { fimd_copy_line_toqemu(VAR_7, s->ifb + VAR_7 * VAR_2 * RGBA_SIZE, d + VAR_7 * VAR_2 * VAR_9); } dpy_gfx_update(s->console, 0, 0, VAR_7, VAR_8); } s->invalidate = false; s->vidintcon[1] |= FIMD_VIDINT_INTFRMPEND; if ((s->vidcon[0] & FIMD_VIDCON0_ENVID_F) == 0) { exynos4210_fimd_enable(s, false); } exynos4210_fimd_update_irq(s); }
[ "static void FUNC_0(void *VAR_0)\n{", "Exynos4210fimdState *s = (Exynos4210fimdState *)VAR_0;", "DisplaySurface *surface = qemu_console_surface(s->console);", "Exynos4210fimdWindow *w;", "int VAR_1, VAR_2;", "hwaddr fb_line_addr, inc_size;", "int VAR_3;", "int VAR_4 = -1, VAR_5 = -1, VAR_6;", "bool blend = false;", "uint8_t *host_fb_addr;", "bool is_dirty = false;", "const int VAR_7 = (s->vidtcon[2] & FIMD_VIDTCON2_SIZE_MASK) + 1;", "const int VAR_8 = ((s->vidtcon[2] >> FIMD_VIDTCON2_VER_SHIFT) &\nFIMD_VIDTCON2_SIZE_MASK) + 1;", "if (!s || !s->console || !surface_bits_per_pixel(surface) ||\n!s->enabled) {", "return;", "}", "exynos4210_update_resolution(s);", "for (VAR_1 = 0; VAR_1 < NUM_OF_WINDOWS; VAR_1++) {", "w = &s->window[VAR_1];", "if ((w->wincon & FIMD_WINCON_ENWIN) && w->host_fb_addr) {", "VAR_3 = w->rightbot_y - w->lefttop_y + 1;", "VAR_6 = w->virtpage_width;", "inc_size = VAR_6 + w->virtpage_offsize;", "memory_region_sync_dirty_bitmap(w->mem_section.mr);", "host_fb_addr = w->host_fb_addr;", "fb_line_addr = w->mem_section.offset_within_region;", "for (VAR_2 = 0; VAR_2 < VAR_3; VAR_2++) {", "is_dirty = memory_region_get_dirty(w->mem_section.mr,\nfb_line_addr, VAR_6, DIRTY_MEMORY_VGA);", "if (s->invalidate || is_dirty) {", "if (VAR_4 == -1) {", "VAR_4 = VAR_2;", "}", "VAR_5 = VAR_2;", "w->draw_line(w, host_fb_addr, s->ifb +\nw->lefttop_x * RGBA_SIZE + (w->lefttop_y + VAR_2) *\nVAR_7 * RGBA_SIZE, blend);", "}", "host_fb_addr += inc_size;", "fb_line_addr += inc_size;", "is_dirty = false;", "}", "memory_region_reset_dirty(w->mem_section.mr,\nw->mem_section.offset_within_region,\nw->fb_len, DIRTY_MEMORY_VGA);", "blend = true;", "}", "}", "if (VAR_4 >= 0) {", "uint8_t *d;", "int VAR_9;", "VAR_9 = surface_bits_per_pixel(surface);", "fimd_update_putpix_qemu(VAR_9);", "VAR_9 = (VAR_9 + 1) >> 3;", "d = surface_data(surface);", "for (VAR_2 = VAR_4; VAR_2 <= VAR_5; VAR_2++) {", "fimd_copy_line_toqemu(VAR_7, s->ifb + VAR_7 * VAR_2 *\nRGBA_SIZE, d + VAR_7 * VAR_2 * VAR_9);", "}", "dpy_gfx_update(s->console, 0, 0, VAR_7, VAR_8);", "}", "s->invalidate = false;", "s->vidintcon[1] |= FIMD_VIDINT_INTFRMPEND;", "if ((s->vidcon[0] & FIMD_VIDCON0_ENVID_F) == 0) {", "exynos4210_fimd_enable(s, false);", "}", "exynos4210_fimd_update_irq(s);", "}" ]
[ 0, 0, 1, 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27, 29 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69, 71 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85, 87, 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101, 103, 105 ], [ 107 ], [ 109 ], [ 111 ], [ 117 ], [ 119 ], [ 121 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135, 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ] ]
12,517
static void gen_waiti(DisasContext *dc, uint32_t imm4) { TCGv_i32 pc = tcg_const_i32(dc->next_pc); TCGv_i32 intlevel = tcg_const_i32(imm4); if (dc->tb->cflags & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_waiti(cpu_env, pc, intlevel); if (dc->tb->cflags & CF_USE_ICOUNT) { gen_io_end(); } tcg_temp_free(pc); tcg_temp_free(intlevel); gen_jumpi_check_loop_end(dc, 0); }
true
qemu
c5a49c63fa26e8825ad101dfe86339ae4c216539
static void gen_waiti(DisasContext *dc, uint32_t imm4) { TCGv_i32 pc = tcg_const_i32(dc->next_pc); TCGv_i32 intlevel = tcg_const_i32(imm4); if (dc->tb->cflags & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_waiti(cpu_env, pc, intlevel); if (dc->tb->cflags & CF_USE_ICOUNT) { gen_io_end(); } tcg_temp_free(pc); tcg_temp_free(intlevel); gen_jumpi_check_loop_end(dc, 0); }
{ "code": [ " if (dc->tb->cflags & CF_USE_ICOUNT) {", " if (dc->tb->cflags & CF_USE_ICOUNT) {", " if (dc->tb->cflags & CF_USE_ICOUNT) {", " if (dc->tb->cflags & CF_USE_ICOUNT) {", " if (dc->tb->cflags & CF_USE_ICOUNT) {", " if (dc->tb->cflags & CF_USE_ICOUNT) {", " if (dc->tb->cflags & CF_USE_ICOUNT) {", " if (dc->tb->cflags & CF_USE_ICOUNT) {" ], "line_no": [ 11, 11, 11, 11, 11, 11, 11, 11 ] }
static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1) { TCGv_i32 pc = tcg_const_i32(VAR_0->next_pc); TCGv_i32 intlevel = tcg_const_i32(VAR_1); if (VAR_0->tb->cflags & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_waiti(cpu_env, pc, intlevel); if (VAR_0->tb->cflags & CF_USE_ICOUNT) { gen_io_end(); } tcg_temp_free(pc); tcg_temp_free(intlevel); gen_jumpi_check_loop_end(VAR_0, 0); }
[ "static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1)\n{", "TCGv_i32 pc = tcg_const_i32(VAR_0->next_pc);", "TCGv_i32 intlevel = tcg_const_i32(VAR_1);", "if (VAR_0->tb->cflags & CF_USE_ICOUNT) {", "gen_io_start();", "}", "gen_helper_waiti(cpu_env, pc, intlevel);", "if (VAR_0->tb->cflags & CF_USE_ICOUNT) {", "gen_io_end();", "}", "tcg_temp_free(pc);", "tcg_temp_free(intlevel);", "gen_jumpi_check_loop_end(VAR_0, 0);", "}" ]
[ 0, 0, 0, 1, 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 ] ]
12,519
static void spr_read_hdecr(DisasContext *ctx, int gprn, int sprn) { if (ctx->tb->cflags & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_load_hdecr(cpu_gpr[gprn], cpu_env); if (ctx->tb->cflags & CF_USE_ICOUNT) { gen_io_end(); gen_stop_exception(ctx); } }
true
qemu
c5a49c63fa26e8825ad101dfe86339ae4c216539
static void spr_read_hdecr(DisasContext *ctx, int gprn, int sprn) { if (ctx->tb->cflags & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_load_hdecr(cpu_gpr[gprn], cpu_env); if (ctx->tb->cflags & CF_USE_ICOUNT) { gen_io_end(); gen_stop_exception(ctx); } }
{ "code": [ " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {", " if (ctx->tb->cflags & CF_USE_ICOUNT) {" ], "line_no": [ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 ] }
static void FUNC_0(DisasContext *VAR_0, int VAR_1, int VAR_2) { if (VAR_0->tb->cflags & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_load_hdecr(cpu_gpr[VAR_1], cpu_env); if (VAR_0->tb->cflags & CF_USE_ICOUNT) { gen_io_end(); gen_stop_exception(VAR_0); } }
[ "static void FUNC_0(DisasContext *VAR_0, int VAR_1, int VAR_2)\n{", "if (VAR_0->tb->cflags & CF_USE_ICOUNT) {", "gen_io_start();", "}", "gen_helper_load_hdecr(cpu_gpr[VAR_1], cpu_env);", "if (VAR_0->tb->cflags & CF_USE_ICOUNT) {", "gen_io_end();", "gen_stop_exception(VAR_0);", "}", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ] ]
12,521
static int get_physical_address (CPUState *env, target_ulong *physical, int *prot, target_ulong address, int rw, int access_type) { /* User mode can only access useg/xuseg */ int user_mode = (env->hflags & MIPS_HFLAG_MODE) == MIPS_HFLAG_UM; int supervisor_mode = (env->hflags & MIPS_HFLAG_MODE) == MIPS_HFLAG_SM; int kernel_mode = !user_mode && !supervisor_mode; #if defined(TARGET_MIPS64) 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; #endif int ret = TLBRET_MATCH; #if 0 if (logfile) { fprintf(logfile, "user mode %d h %08x\n", user_mode, env->hflags); } #endif if (address <= (int32_t)0x7FFFFFFFUL) { /* useg */ if (env->CP0_Status & (1 << CP0St_ERL)) { *physical = address & 0xFFFFFFFF; *prot = PAGE_READ | PAGE_WRITE; } else { ret = env->tlb->map_address(env, physical, prot, address, rw, access_type); } #if defined(TARGET_MIPS64) } else if (address < 0x4000000000000000ULL) { /* xuseg */ if (UX && address < (0x3FFFFFFFFFFFFFFFULL & env->SEGMask)) { ret = env->tlb->map_address(env, physical, prot, address, rw, access_type); } else { ret = TLBRET_BADADDR; } } else if (address < 0x8000000000000000ULL) { /* xsseg */ if ((supervisor_mode || kernel_mode) && SX && address < (0x7FFFFFFFFFFFFFFFULL & env->SEGMask)) { ret = env->tlb->map_address(env, physical, prot, address, rw, access_type); } else { ret = TLBRET_BADADDR; } } else if (address < 0xC000000000000000ULL) { /* xkphys */ /* XXX: Assumes PABITS = 36 (correct for MIPS64R1) */ if (kernel_mode && KX && (address & 0x07FFFFFFFFFFFFFFULL) < 0x0000000FFFFFFFFFULL) { *physical = address & 0x0000000FFFFFFFFFULL; *prot = PAGE_READ | PAGE_WRITE; } else { ret = TLBRET_BADADDR; } } else if (address < 0xFFFFFFFF80000000ULL) { /* xkseg */ if (kernel_mode && KX && address < (0xFFFFFFFF7FFFFFFFULL & env->SEGMask)) { ret = env->tlb->map_address(env, physical, prot, address, rw, access_type); } else { ret = TLBRET_BADADDR; } #endif } else if (address < (int32_t)0xA0000000UL) { /* kseg0 */ if (kernel_mode) { *physical = address - (int32_t)0x80000000UL; *prot = PAGE_READ | PAGE_WRITE; } else { ret = TLBRET_BADADDR; } } else if (address < (int32_t)0xC0000000UL) { /* kseg1 */ if (kernel_mode) { *physical = address - (int32_t)0xA0000000UL; *prot = PAGE_READ | PAGE_WRITE; } else { ret = TLBRET_BADADDR; } } else if (address < (int32_t)0xE0000000UL) { /* sseg (kseg2) */ if (supervisor_mode || kernel_mode) { ret = env->tlb->map_address(env, physical, prot, address, rw, access_type); } else { ret = TLBRET_BADADDR; } } else { /* kseg3 */ /* XXX: debug segment is not emulated */ if (kernel_mode) { ret = env->tlb->map_address(env, physical, prot, address, rw, access_type); } else { ret = TLBRET_BADADDR; } } #if 0 if (logfile) { fprintf(logfile, TARGET_FMT_lx " %d %d => " TARGET_FMT_lx " %d (%d)\n", address, rw, access_type, *physical, *prot, ret); } #endif return ret; }
true
qemu
67d6abff605064317d1922745b2e99ffc57b4a77
static int get_physical_address (CPUState *env, target_ulong *physical, int *prot, target_ulong address, int rw, int access_type) { int user_mode = (env->hflags & MIPS_HFLAG_MODE) == MIPS_HFLAG_UM; int supervisor_mode = (env->hflags & MIPS_HFLAG_MODE) == MIPS_HFLAG_SM; int kernel_mode = !user_mode && !supervisor_mode; #if defined(TARGET_MIPS64) 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; #endif int ret = TLBRET_MATCH; #if 0 if (logfile) { fprintf(logfile, "user mode %d h %08x\n", user_mode, env->hflags); } #endif if (address <= (int32_t)0x7FFFFFFFUL) { if (env->CP0_Status & (1 << CP0St_ERL)) { *physical = address & 0xFFFFFFFF; *prot = PAGE_READ | PAGE_WRITE; } else { ret = env->tlb->map_address(env, physical, prot, address, rw, access_type); } #if defined(TARGET_MIPS64) } else if (address < 0x4000000000000000ULL) { if (UX && address < (0x3FFFFFFFFFFFFFFFULL & env->SEGMask)) { ret = env->tlb->map_address(env, physical, prot, address, rw, access_type); } else { ret = TLBRET_BADADDR; } } else if (address < 0x8000000000000000ULL) { if ((supervisor_mode || kernel_mode) && SX && address < (0x7FFFFFFFFFFFFFFFULL & env->SEGMask)) { ret = env->tlb->map_address(env, physical, prot, address, rw, access_type); } else { ret = TLBRET_BADADDR; } } else if (address < 0xC000000000000000ULL) { if (kernel_mode && KX && (address & 0x07FFFFFFFFFFFFFFULL) < 0x0000000FFFFFFFFFULL) { *physical = address & 0x0000000FFFFFFFFFULL; *prot = PAGE_READ | PAGE_WRITE; } else { ret = TLBRET_BADADDR; } } else if (address < 0xFFFFFFFF80000000ULL) { if (kernel_mode && KX && address < (0xFFFFFFFF7FFFFFFFULL & env->SEGMask)) { ret = env->tlb->map_address(env, physical, prot, address, rw, access_type); } else { ret = TLBRET_BADADDR; } #endif } else if (address < (int32_t)0xA0000000UL) { if (kernel_mode) { *physical = address - (int32_t)0x80000000UL; *prot = PAGE_READ | PAGE_WRITE; } else { ret = TLBRET_BADADDR; } } else if (address < (int32_t)0xC0000000UL) { if (kernel_mode) { *physical = address - (int32_t)0xA0000000UL; *prot = PAGE_READ | PAGE_WRITE; } else { ret = TLBRET_BADADDR; } } else if (address < (int32_t)0xE0000000UL) { if (supervisor_mode || kernel_mode) { ret = env->tlb->map_address(env, physical, prot, address, rw, access_type); } else { ret = TLBRET_BADADDR; } } else { if (kernel_mode) { ret = env->tlb->map_address(env, physical, prot, address, rw, access_type); } else { ret = TLBRET_BADADDR; } } #if 0 if (logfile) { fprintf(logfile, TARGET_FMT_lx " %d %d => " TARGET_FMT_lx " %d (%d)\n", address, rw, access_type, *physical, *prot, ret); } #endif return ret; }
{ "code": [ "\tif (UX && address < (0x3FFFFFFFFFFFFFFFULL & env->SEGMask)) {", "\t SX && address < (0x7FFFFFFFFFFFFFFFULL & env->SEGMask)) {", " (address & 0x07FFFFFFFFFFFFFFULL) < 0x0000000FFFFFFFFFULL) {", "\t address < (0xFFFFFFFF7FFFFFFFULL & env->SEGMask)) {" ], "line_no": [ 67, 83, 101, 119 ] }
static int FUNC_0 (CPUState *VAR_0, target_ulong *VAR_1, int *VAR_2, target_ulong VAR_3, int VAR_4, int VAR_5) { int VAR_6 = (VAR_0->hflags & MIPS_HFLAG_MODE) == MIPS_HFLAG_UM; int VAR_7 = (VAR_0->hflags & MIPS_HFLAG_MODE) == MIPS_HFLAG_SM; int VAR_8 = !VAR_6 && !VAR_7; #if defined(TARGET_MIPS64) int UX = (VAR_0->CP0_Status & (1 << CP0St_UX)) != 0; int SX = (VAR_0->CP0_Status & (1 << CP0St_SX)) != 0; int KX = (VAR_0->CP0_Status & (1 << CP0St_KX)) != 0; #endif int VAR_9 = TLBRET_MATCH; #if 0 if (logfile) { fprintf(logfile, "user mode %d h %08x\n", VAR_6, VAR_0->hflags); } #endif if (VAR_3 <= (int32_t)0x7FFFFFFFUL) { if (VAR_0->CP0_Status & (1 << CP0St_ERL)) { *VAR_1 = VAR_3 & 0xFFFFFFFF; *VAR_2 = PAGE_READ | PAGE_WRITE; } else { VAR_9 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5); } #if defined(TARGET_MIPS64) } else if (VAR_3 < 0x4000000000000000ULL) { if (UX && VAR_3 < (0x3FFFFFFFFFFFFFFFULL & VAR_0->SEGMask)) { VAR_9 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5); } else { VAR_9 = TLBRET_BADADDR; } } else if (VAR_3 < 0x8000000000000000ULL) { if ((VAR_7 || VAR_8) && SX && VAR_3 < (0x7FFFFFFFFFFFFFFFULL & VAR_0->SEGMask)) { VAR_9 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5); } else { VAR_9 = TLBRET_BADADDR; } } else if (VAR_3 < 0xC000000000000000ULL) { if (VAR_8 && KX && (VAR_3 & 0x07FFFFFFFFFFFFFFULL) < 0x0000000FFFFFFFFFULL) { *VAR_1 = VAR_3 & 0x0000000FFFFFFFFFULL; *VAR_2 = PAGE_READ | PAGE_WRITE; } else { VAR_9 = TLBRET_BADADDR; } } else if (VAR_3 < 0xFFFFFFFF80000000ULL) { if (VAR_8 && KX && VAR_3 < (0xFFFFFFFF7FFFFFFFULL & VAR_0->SEGMask)) { VAR_9 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5); } else { VAR_9 = TLBRET_BADADDR; } #endif } else if (VAR_3 < (int32_t)0xA0000000UL) { if (VAR_8) { *VAR_1 = VAR_3 - (int32_t)0x80000000UL; *VAR_2 = PAGE_READ | PAGE_WRITE; } else { VAR_9 = TLBRET_BADADDR; } } else if (VAR_3 < (int32_t)0xC0000000UL) { if (VAR_8) { *VAR_1 = VAR_3 - (int32_t)0xA0000000UL; *VAR_2 = PAGE_READ | PAGE_WRITE; } else { VAR_9 = TLBRET_BADADDR; } } else if (VAR_3 < (int32_t)0xE0000000UL) { if (VAR_7 || VAR_8) { VAR_9 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5); } else { VAR_9 = TLBRET_BADADDR; } } else { if (VAR_8) { VAR_9 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5); } else { VAR_9 = TLBRET_BADADDR; } } #if 0 if (logfile) { fprintf(logfile, TARGET_FMT_lx " %d %d => " TARGET_FMT_lx " %d (%d)\n", VAR_3, VAR_4, VAR_5, *VAR_1, *VAR_2, VAR_9); } #endif return VAR_9; }
[ "static int FUNC_0 (CPUState *VAR_0, target_ulong *VAR_1,\nint *VAR_2, target_ulong VAR_3,\nint VAR_4, int VAR_5)\n{", "int VAR_6 = (VAR_0->hflags & MIPS_HFLAG_MODE) == MIPS_HFLAG_UM;", "int VAR_7 = (VAR_0->hflags & MIPS_HFLAG_MODE) == MIPS_HFLAG_SM;", "int VAR_8 = !VAR_6 && !VAR_7;", "#if defined(TARGET_MIPS64)\nint UX = (VAR_0->CP0_Status & (1 << CP0St_UX)) != 0;", "int SX = (VAR_0->CP0_Status & (1 << CP0St_SX)) != 0;", "int KX = (VAR_0->CP0_Status & (1 << CP0St_KX)) != 0;", "#endif\nint VAR_9 = TLBRET_MATCH;", "#if 0\nif (logfile) {", "fprintf(logfile, \"user mode %d h %08x\\n\",\nVAR_6, VAR_0->hflags);", "}", "#endif\nif (VAR_3 <= (int32_t)0x7FFFFFFFUL) {", "if (VAR_0->CP0_Status & (1 << CP0St_ERL)) {", "*VAR_1 = VAR_3 & 0xFFFFFFFF;", "*VAR_2 = PAGE_READ | PAGE_WRITE;", "} else {", "VAR_9 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);", "}", "#if defined(TARGET_MIPS64)\n} else if (VAR_3 < 0x4000000000000000ULL) {", "if (UX && VAR_3 < (0x3FFFFFFFFFFFFFFFULL & VAR_0->SEGMask)) {", "VAR_9 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);", "} else {", "VAR_9 = TLBRET_BADADDR;", "}", "} else if (VAR_3 < 0x8000000000000000ULL) {", "if ((VAR_7 || VAR_8) &&\nSX && VAR_3 < (0x7FFFFFFFFFFFFFFFULL & VAR_0->SEGMask)) {", "VAR_9 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);", "} else {", "VAR_9 = TLBRET_BADADDR;", "}", "} else if (VAR_3 < 0xC000000000000000ULL) {", "if (VAR_8 && KX &&\n(VAR_3 & 0x07FFFFFFFFFFFFFFULL) < 0x0000000FFFFFFFFFULL) {", "*VAR_1 = VAR_3 & 0x0000000FFFFFFFFFULL;", "*VAR_2 = PAGE_READ | PAGE_WRITE;", "} else {", "VAR_9 = TLBRET_BADADDR;", "}", "} else if (VAR_3 < 0xFFFFFFFF80000000ULL) {", "if (VAR_8 && KX &&\nVAR_3 < (0xFFFFFFFF7FFFFFFFULL & VAR_0->SEGMask)) {", "VAR_9 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);", "} else {", "VAR_9 = TLBRET_BADADDR;", "}", "#endif\n} else if (VAR_3 < (int32_t)0xA0000000UL) {", "if (VAR_8) {", "*VAR_1 = VAR_3 - (int32_t)0x80000000UL;", "*VAR_2 = PAGE_READ | PAGE_WRITE;", "} else {", "VAR_9 = TLBRET_BADADDR;", "}", "} else if (VAR_3 < (int32_t)0xC0000000UL) {", "if (VAR_8) {", "*VAR_1 = VAR_3 - (int32_t)0xA0000000UL;", "*VAR_2 = PAGE_READ | PAGE_WRITE;", "} else {", "VAR_9 = TLBRET_BADADDR;", "}", "} else if (VAR_3 < (int32_t)0xE0000000UL) {", "if (VAR_7 || VAR_8) {", "VAR_9 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);", "} else {", "VAR_9 = TLBRET_BADADDR;", "}", "} else {", "if (VAR_8) {", "VAR_9 = VAR_0->tlb->map_address(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);", "} else {", "VAR_9 = TLBRET_BADADDR;", "}", "}", "#if 0\nif (logfile) {", "fprintf(logfile, TARGET_FMT_lx \" %d %d => \" TARGET_FMT_lx \" %d (%d)\\n\",\nVAR_3, VAR_4, VAR_5, *VAR_1, *VAR_2, VAR_9);", "}", "#endif\nreturn VAR_9;", "}" ]
[ 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, 1, 0, 0, 0, 0, 0, 1, 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 ]
[ [ 1, 3, 5, 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17, 19 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 31, 33 ], [ 35, 37 ], [ 39 ], [ 41, 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61, 63 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 81, 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 99, 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 117, 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129, 131 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195, 197 ], [ 199, 201 ], [ 203 ], [ 205, 209 ], [ 211 ] ]
12,523
void palette8tobgr32(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette) { unsigned i; for(i=0; i<num_pixels; i++) { #ifdef WORDS_BIGENDIAN dst[3]= palette[ src[i]*4+0 ]; dst[2]= palette[ src[i]*4+1 ]; dst[1]= palette[ src[i]*4+2 ]; #else //FIXME slow? dst[0]= palette[ src[i]*4+0 ]; dst[1]= palette[ src[i]*4+1 ]; dst[2]= palette[ src[i]*4+2 ]; // dst[3]= 0; /* do we need this cleansing? */ #endif dst+= 4; } }
true
FFmpeg
7f526efd17973ec6d2204f7a47b6923e2be31363
void palette8tobgr32(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette) { unsigned i; for(i=0; i<num_pixels; i++) { #ifdef WORDS_BIGENDIAN dst[3]= palette[ src[i]*4+0 ]; dst[2]= palette[ src[i]*4+1 ]; dst[1]= palette[ src[i]*4+2 ]; #else dst[0]= palette[ src[i]*4+0 ]; dst[1]= palette[ src[i]*4+1 ]; dst[2]= palette[ src[i]*4+2 ]; #endif dst+= 4; } }
{ "code": [ "\tunsigned i;", "void palette8tobgr32(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette)", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;" ], "line_no": [ 5, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 ] }
void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, unsigned VAR_2, const uint8_t *VAR_3) { unsigned VAR_4; for(VAR_4=0; VAR_4<VAR_2; VAR_4++) { #ifdef WORDS_BIGENDIAN VAR_1[3]= VAR_3[ VAR_0[VAR_4]*4+0 ]; VAR_1[2]= VAR_3[ VAR_0[VAR_4]*4+1 ]; VAR_1[1]= VAR_3[ VAR_0[VAR_4]*4+2 ]; #else VAR_1[0]= VAR_3[ VAR_0[VAR_4]*4+0 ]; VAR_1[1]= VAR_3[ VAR_0[VAR_4]*4+1 ]; VAR_1[2]= VAR_3[ VAR_0[VAR_4]*4+2 ]; #endif VAR_1+= 4; } }
[ "void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, unsigned VAR_2, const uint8_t *VAR_3)\n{", "unsigned VAR_4;", "for(VAR_4=0; VAR_4<VAR_2; VAR_4++)", "{", "#ifdef WORDS_BIGENDIAN\nVAR_1[3]= VAR_3[ VAR_0[VAR_4]*4+0 ];", "VAR_1[2]= VAR_3[ VAR_0[VAR_4]*4+1 ];", "VAR_1[1]= VAR_3[ VAR_0[VAR_4]*4+2 ];", "#else\nVAR_1[0]= VAR_3[ VAR_0[VAR_4]*4+0 ];", "VAR_1[1]= VAR_3[ VAR_0[VAR_4]*4+1 ];", "VAR_1[2]= VAR_3[ VAR_0[VAR_4]*4+2 ];", "#endif\nVAR_1+= 4;", "}", "}" ]
[ 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11, 13 ], [ 15 ], [ 17 ], [ 19, 23 ], [ 25 ], [ 27 ], [ 31, 35 ], [ 37 ], [ 39 ] ]
12,524
int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags){ AVInputFormat *avif= s->iformat; int64_t av_uninit(pos_min), av_uninit(pos_max), pos, pos_limit; int64_t ts_min, ts_max, ts; int index; AVStream *st; if (stream_index < 0) return -1; #ifdef DEBUG_SEEK av_log(s, AV_LOG_DEBUG, "read_seek: %d %"PRId64"\n", stream_index, target_ts); #endif ts_max= ts_min= AV_NOPTS_VALUE; pos_limit= -1; //gcc falsely says it may be uninitialized st= s->streams[stream_index]; if(st->index_entries){ AVIndexEntry *e; index= av_index_search_timestamp(st, target_ts, flags | AVSEEK_FLAG_BACKWARD); //FIXME whole func must be checked for non-keyframe entries in index case, especially read_timestamp() index= FFMAX(index, 0); e= &st->index_entries[index]; if(e->timestamp <= target_ts || e->pos == e->min_distance){ pos_min= e->pos; ts_min= e->timestamp; #ifdef DEBUG_SEEK av_log(s, AV_LOG_DEBUG, "using cached pos_min=0x%"PRIx64" dts_min=%"PRId64"\n", pos_min,ts_min); #endif }else{ assert(index==0); } index= av_index_search_timestamp(st, target_ts, flags & ~AVSEEK_FLAG_BACKWARD); assert(index < st->nb_index_entries); if(index >= 0){ e= &st->index_entries[index]; assert(e->timestamp >= target_ts); pos_max= e->pos; ts_max= e->timestamp; pos_limit= pos_max - e->min_distance; #ifdef DEBUG_SEEK av_log(s, AV_LOG_DEBUG, "using cached pos_max=0x%"PRIx64" pos_limit=0x%"PRIx64" dts_max=%"PRId64"\n", pos_max,pos_limit, ts_max); #endif } } pos= av_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit, ts_min, ts_max, flags, &ts, avif->read_timestamp); if(pos<0) return -1; /* do the seek */ url_fseek(s->pb, pos, SEEK_SET); av_update_cur_dts(s, st, ts); return 0; }
true
FFmpeg
b593f7fdef3448ea0fadfccc0bd7e4fde3df84aa
int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags){ AVInputFormat *avif= s->iformat; int64_t av_uninit(pos_min), av_uninit(pos_max), pos, pos_limit; int64_t ts_min, ts_max, ts; int index; AVStream *st; if (stream_index < 0) return -1; #ifdef DEBUG_SEEK av_log(s, AV_LOG_DEBUG, "read_seek: %d %"PRId64"\n", stream_index, target_ts); #endif ts_max= ts_min= AV_NOPTS_VALUE; pos_limit= -1; st= s->streams[stream_index]; if(st->index_entries){ AVIndexEntry *e; index= av_index_search_timestamp(st, target_ts, flags | AVSEEK_FLAG_BACKWARD); index= FFMAX(index, 0); e= &st->index_entries[index]; if(e->timestamp <= target_ts || e->pos == e->min_distance){ pos_min= e->pos; ts_min= e->timestamp; #ifdef DEBUG_SEEK av_log(s, AV_LOG_DEBUG, "using cached pos_min=0x%"PRIx64" dts_min=%"PRId64"\n", pos_min,ts_min); #endif }else{ assert(index==0); } index= av_index_search_timestamp(st, target_ts, flags & ~AVSEEK_FLAG_BACKWARD); assert(index < st->nb_index_entries); if(index >= 0){ e= &st->index_entries[index]; assert(e->timestamp >= target_ts); pos_max= e->pos; ts_max= e->timestamp; pos_limit= pos_max - e->min_distance; #ifdef DEBUG_SEEK av_log(s, AV_LOG_DEBUG, "using cached pos_max=0x%"PRIx64" pos_limit=0x%"PRIx64" dts_max=%"PRId64"\n", pos_max,pos_limit, ts_max); #endif } } pos= av_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit, ts_min, ts_max, flags, &ts, avif->read_timestamp); if(pos<0) return -1; url_fseek(s->pb, pos, SEEK_SET); av_update_cur_dts(s, st, ts); return 0; }
{ "code": [ " url_fseek(s->pb, pos, SEEK_SET);" ], "line_no": [ 115 ] }
int FUNC_0(AVFormatContext *VAR_0, int VAR_1, int64_t VAR_2, int VAR_3){ AVInputFormat *avif= VAR_0->iformat; int64_t av_uninit(pos_min), av_uninit(pos_max), pos, pos_limit; int64_t ts_min, ts_max, ts; int VAR_4; AVStream *st; if (VAR_1 < 0) return -1; #ifdef DEBUG_SEEK av_log(VAR_0, AV_LOG_DEBUG, "read_seek: %d %"PRId64"\n", VAR_1, VAR_2); #endif ts_max= ts_min= AV_NOPTS_VALUE; pos_limit= -1; st= VAR_0->streams[VAR_1]; if(st->index_entries){ AVIndexEntry *e; VAR_4= av_index_search_timestamp(st, VAR_2, VAR_3 | AVSEEK_FLAG_BACKWARD); VAR_4= FFMAX(VAR_4, 0); e= &st->index_entries[VAR_4]; if(e->timestamp <= VAR_2 || e->pos == e->min_distance){ pos_min= e->pos; ts_min= e->timestamp; #ifdef DEBUG_SEEK av_log(VAR_0, AV_LOG_DEBUG, "using cached pos_min=0x%"PRIx64" dts_min=%"PRId64"\n", pos_min,ts_min); #endif }else{ assert(VAR_4==0); } VAR_4= av_index_search_timestamp(st, VAR_2, VAR_3 & ~AVSEEK_FLAG_BACKWARD); assert(VAR_4 < st->nb_index_entries); if(VAR_4 >= 0){ e= &st->index_entries[VAR_4]; assert(e->timestamp >= VAR_2); pos_max= e->pos; ts_max= e->timestamp; pos_limit= pos_max - e->min_distance; #ifdef DEBUG_SEEK av_log(VAR_0, AV_LOG_DEBUG, "using cached pos_max=0x%"PRIx64" pos_limit=0x%"PRIx64" dts_max=%"PRId64"\n", pos_max,pos_limit, ts_max); #endif } } pos= av_gen_search(VAR_0, VAR_1, VAR_2, pos_min, pos_max, pos_limit, ts_min, ts_max, VAR_3, &ts, avif->read_timestamp); if(pos<0) return -1; url_fseek(VAR_0->pb, pos, SEEK_SET); av_update_cur_dts(VAR_0, st, ts); return 0; }
[ "int FUNC_0(AVFormatContext *VAR_0, int VAR_1, int64_t VAR_2, int VAR_3){", "AVInputFormat *avif= VAR_0->iformat;", "int64_t av_uninit(pos_min), av_uninit(pos_max), pos, pos_limit;", "int64_t ts_min, ts_max, ts;", "int VAR_4;", "AVStream *st;", "if (VAR_1 < 0)\nreturn -1;", "#ifdef DEBUG_SEEK\nav_log(VAR_0, AV_LOG_DEBUG, \"read_seek: %d %\"PRId64\"\\n\", VAR_1, VAR_2);", "#endif\nts_max=\nts_min= AV_NOPTS_VALUE;", "pos_limit= -1;", "st= VAR_0->streams[VAR_1];", "if(st->index_entries){", "AVIndexEntry *e;", "VAR_4= av_index_search_timestamp(st, VAR_2, VAR_3 | AVSEEK_FLAG_BACKWARD);", "VAR_4= FFMAX(VAR_4, 0);", "e= &st->index_entries[VAR_4];", "if(e->timestamp <= VAR_2 || e->pos == e->min_distance){", "pos_min= e->pos;", "ts_min= e->timestamp;", "#ifdef DEBUG_SEEK\nav_log(VAR_0, AV_LOG_DEBUG, \"using cached pos_min=0x%\"PRIx64\" dts_min=%\"PRId64\"\\n\",\npos_min,ts_min);", "#endif\n}else{", "assert(VAR_4==0);", "}", "VAR_4= av_index_search_timestamp(st, VAR_2, VAR_3 & ~AVSEEK_FLAG_BACKWARD);", "assert(VAR_4 < st->nb_index_entries);", "if(VAR_4 >= 0){", "e= &st->index_entries[VAR_4];", "assert(e->timestamp >= VAR_2);", "pos_max= e->pos;", "ts_max= e->timestamp;", "pos_limit= pos_max - e->min_distance;", "#ifdef DEBUG_SEEK\nav_log(VAR_0, AV_LOG_DEBUG, \"using cached pos_max=0x%\"PRIx64\" pos_limit=0x%\"PRIx64\" dts_max=%\"PRId64\"\\n\",\npos_max,pos_limit, ts_max);", "#endif\n}", "}", "pos= av_gen_search(VAR_0, VAR_1, VAR_2, pos_min, pos_max, pos_limit, ts_min, ts_max, VAR_3, &ts, avif->read_timestamp);", "if(pos<0)\nreturn -1;", "url_fseek(VAR_0->pb, pos, SEEK_SET);", "av_update_cur_dts(VAR_0, st, ts);", "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, 1, 0, 0, 0 ]
[ [ 1 ], [ 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15, 17 ], [ 21, 23 ], [ 25, 29, 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ], [ 57 ], [ 59, 61, 63 ], [ 65, 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91, 93, 95 ], [ 97, 99 ], [ 101 ], [ 105 ], [ 107, 109 ], [ 115 ], [ 119 ], [ 123 ], [ 125 ] ]
12,525
static abi_long do_ipc(unsigned int call, abi_long first, abi_long second, abi_long third, abi_long ptr, abi_long fifth) { int version; abi_long ret = 0; version = call >> 16; call &= 0xffff; switch (call) { case IPCOP_semop: ret = do_semop(first, ptr, second); break; case IPCOP_semget: ret = get_errno(semget(first, second, third)); break; case IPCOP_semctl: { /* The semun argument to semctl is passed by value, so dereference the * ptr argument. */ abi_ulong atptr; get_user_ual(atptr, ptr); ret = do_semctl(first, second, third, atptr); break; } case IPCOP_msgget: ret = get_errno(msgget(first, second)); break; case IPCOP_msgsnd: ret = do_msgsnd(first, ptr, second, third); break; case IPCOP_msgctl: ret = do_msgctl(first, second, ptr); break; case IPCOP_msgrcv: switch (version) { case 0: { struct target_ipc_kludge { abi_long msgp; abi_long msgtyp; } *tmp; if (!lock_user_struct(VERIFY_READ, tmp, ptr, 1)) { ret = -TARGET_EFAULT; break; } ret = do_msgrcv(first, tswapal(tmp->msgp), second, tswapal(tmp->msgtyp), third); unlock_user_struct(tmp, ptr, 0); break; } default: ret = do_msgrcv(first, ptr, second, fifth, third); } break; case IPCOP_shmat: switch (version) { default: { abi_ulong raddr; raddr = do_shmat(first, ptr, second); if (is_error(raddr)) return get_errno(raddr); if (put_user_ual(raddr, third)) return -TARGET_EFAULT; break; } case 1: ret = -TARGET_EINVAL; break; } break; case IPCOP_shmdt: ret = do_shmdt(ptr); break; case IPCOP_shmget: /* IPC_* flag values are the same on all linux platforms */ ret = get_errno(shmget(first, second, third)); break; /* IPC_* and SHM_* command values are the same on all linux platforms */ case IPCOP_shmctl: ret = do_shmctl(first, second, ptr); break; default: gemu_log("Unsupported ipc call: %d (version %d)\n", call, version); ret = -TARGET_ENOSYS; break; } return ret; }
true
qemu
ee8e76141b4dd00f8e97fda274876a17f9a46bbe
static abi_long do_ipc(unsigned int call, abi_long first, abi_long second, abi_long third, abi_long ptr, abi_long fifth) { int version; abi_long ret = 0; version = call >> 16; call &= 0xffff; switch (call) { case IPCOP_semop: ret = do_semop(first, ptr, second); break; case IPCOP_semget: ret = get_errno(semget(first, second, third)); break; case IPCOP_semctl: { abi_ulong atptr; get_user_ual(atptr, ptr); ret = do_semctl(first, second, third, atptr); break; } case IPCOP_msgget: ret = get_errno(msgget(first, second)); break; case IPCOP_msgsnd: ret = do_msgsnd(first, ptr, second, third); break; case IPCOP_msgctl: ret = do_msgctl(first, second, ptr); break; case IPCOP_msgrcv: switch (version) { case 0: { struct target_ipc_kludge { abi_long msgp; abi_long msgtyp; } *tmp; if (!lock_user_struct(VERIFY_READ, tmp, ptr, 1)) { ret = -TARGET_EFAULT; break; } ret = do_msgrcv(first, tswapal(tmp->msgp), second, tswapal(tmp->msgtyp), third); unlock_user_struct(tmp, ptr, 0); break; } default: ret = do_msgrcv(first, ptr, second, fifth, third); } break; case IPCOP_shmat: switch (version) { default: { abi_ulong raddr; raddr = do_shmat(first, ptr, second); if (is_error(raddr)) return get_errno(raddr); if (put_user_ual(raddr, third)) return -TARGET_EFAULT; break; } case 1: ret = -TARGET_EINVAL; break; } break; case IPCOP_shmdt: ret = do_shmdt(ptr); break; case IPCOP_shmget: ret = get_errno(shmget(first, second, third)); break; case IPCOP_shmctl: ret = do_shmctl(first, second, ptr); break; default: gemu_log("Unsupported ipc call: %d (version %d)\n", call, version); ret = -TARGET_ENOSYS; break; } return ret; }
{ "code": [ "static abi_long do_ipc(unsigned int call, abi_long first,", " raddr = do_shmat(first, ptr, second);", "\tbreak;" ], "line_no": [ 1, 139, 161 ] }
static abi_long FUNC_0(unsigned int call, abi_long first, abi_long second, abi_long third, abi_long ptr, abi_long fifth) { int VAR_0; abi_long ret = 0; VAR_0 = call >> 16; call &= 0xffff; switch (call) { case IPCOP_semop: ret = do_semop(first, ptr, second); break; case IPCOP_semget: ret = get_errno(semget(first, second, third)); break; case IPCOP_semctl: { abi_ulong atptr; get_user_ual(atptr, ptr); ret = do_semctl(first, second, third, atptr); break; } case IPCOP_msgget: ret = get_errno(msgget(first, second)); break; case IPCOP_msgsnd: ret = do_msgsnd(first, ptr, second, third); break; case IPCOP_msgctl: ret = do_msgctl(first, second, ptr); break; case IPCOP_msgrcv: switch (VAR_0) { case 0: { struct target_ipc_kludge { abi_long msgp; abi_long msgtyp; } *VAR_1; if (!lock_user_struct(VERIFY_READ, VAR_1, ptr, 1)) { ret = -TARGET_EFAULT; break; } ret = do_msgrcv(first, tswapal(VAR_1->msgp), second, tswapal(VAR_1->msgtyp), third); unlock_user_struct(VAR_1, ptr, 0); break; } default: ret = do_msgrcv(first, ptr, second, fifth, third); } break; case IPCOP_shmat: switch (VAR_0) { default: { abi_ulong raddr; raddr = do_shmat(first, ptr, second); if (is_error(raddr)) return get_errno(raddr); if (put_user_ual(raddr, third)) return -TARGET_EFAULT; break; } case 1: ret = -TARGET_EINVAL; break; } break; case IPCOP_shmdt: ret = do_shmdt(ptr); break; case IPCOP_shmget: ret = get_errno(shmget(first, second, third)); break; case IPCOP_shmctl: ret = do_shmctl(first, second, ptr); break; default: gemu_log("Unsupported ipc call: %d (VAR_0 %d)\n", call, VAR_0); ret = -TARGET_ENOSYS; break; } return ret; }
[ "static abi_long FUNC_0(unsigned int call, abi_long first,\nabi_long second, abi_long third,\nabi_long ptr, abi_long fifth)\n{", "int VAR_0;", "abi_long ret = 0;", "VAR_0 = call >> 16;", "call &= 0xffff;", "switch (call) {", "case IPCOP_semop:\nret = do_semop(first, ptr, second);", "break;", "case IPCOP_semget:\nret = get_errno(semget(first, second, third));", "break;", "case IPCOP_semctl: {", "abi_ulong atptr;", "get_user_ual(atptr, ptr);", "ret = do_semctl(first, second, third, atptr);", "break;", "}", "case IPCOP_msgget:\nret = get_errno(msgget(first, second));", "break;", "case IPCOP_msgsnd:\nret = do_msgsnd(first, ptr, second, third);", "break;", "case IPCOP_msgctl:\nret = do_msgctl(first, second, ptr);", "break;", "case IPCOP_msgrcv:\nswitch (VAR_0) {", "case 0:\n{", "struct target_ipc_kludge {", "abi_long msgp;", "abi_long msgtyp;", "} *VAR_1;", "if (!lock_user_struct(VERIFY_READ, VAR_1, ptr, 1)) {", "ret = -TARGET_EFAULT;", "break;", "}", "ret = do_msgrcv(first, tswapal(VAR_1->msgp), second, tswapal(VAR_1->msgtyp), third);", "unlock_user_struct(VAR_1, ptr, 0);", "break;", "}", "default:\nret = do_msgrcv(first, ptr, second, fifth, third);", "}", "break;", "case IPCOP_shmat:\nswitch (VAR_0) {", "default:\n{", "abi_ulong raddr;", "raddr = do_shmat(first, ptr, second);", "if (is_error(raddr))\nreturn get_errno(raddr);", "if (put_user_ual(raddr, third))\nreturn -TARGET_EFAULT;", "break;", "}", "case 1:\nret = -TARGET_EINVAL;", "break;", "}", "break;", "case IPCOP_shmdt:\nret = do_shmdt(ptr);", "break;", "case IPCOP_shmget:\nret = get_errno(shmget(first, second, third));", "break;", "case IPCOP_shmctl:\nret = do_shmctl(first, second, ptr);", "break;", "default:\ngemu_log(\"Unsupported ipc call: %d (VAR_0 %d)\\n\", call, VAR_0);", "ret = -TARGET_ENOSYS;", "break;", "}", "return ret;", "}" ]
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 21 ], [ 23, 25 ], [ 27 ], [ 31, 33 ], [ 35 ], [ 39 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57, 59 ], [ 61 ], [ 65, 67 ], [ 69 ], [ 73, 75 ], [ 77 ], [ 81, 83 ], [ 85, 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 109 ], [ 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 ], [ 171, 175 ], [ 177 ], [ 183, 185 ], [ 187 ], [ 189, 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ] ]
12,526
static int virtcon_parse(const char *devname) { QemuOptsList *device = qemu_find_opts("device"); static int index = 0; char label[32]; QemuOpts *bus_opts, *dev_opts; if (strcmp(devname, "none") == 0) return 0; if (index == MAX_VIRTIO_CONSOLES) { fprintf(stderr, "qemu: too many virtio consoles\n"); exit(1); } bus_opts = qemu_opts_create(device, NULL, 0, &error_abort); if (arch_type == QEMU_ARCH_S390X) { qemu_opt_set(bus_opts, "driver", "virtio-serial-s390", &error_abort); } else { qemu_opt_set(bus_opts, "driver", "virtio-serial-pci", &error_abort); } dev_opts = qemu_opts_create(device, NULL, 0, &error_abort); qemu_opt_set(dev_opts, "driver", "virtconsole", &error_abort); snprintf(label, sizeof(label), "virtcon%d", index); virtcon_hds[index] = qemu_chr_new(label, devname, NULL); if (!virtcon_hds[index]) { fprintf(stderr, "qemu: could not connect virtio console" " to character backend '%s'\n", devname); return -1; } qemu_opt_set(dev_opts, "chardev", label, &error_abort); index++; return 0; }
false
qemu
f61eddcb2bb5cbbdd1d911b7e937db9affc29028
static int virtcon_parse(const char *devname) { QemuOptsList *device = qemu_find_opts("device"); static int index = 0; char label[32]; QemuOpts *bus_opts, *dev_opts; if (strcmp(devname, "none") == 0) return 0; if (index == MAX_VIRTIO_CONSOLES) { fprintf(stderr, "qemu: too many virtio consoles\n"); exit(1); } bus_opts = qemu_opts_create(device, NULL, 0, &error_abort); if (arch_type == QEMU_ARCH_S390X) { qemu_opt_set(bus_opts, "driver", "virtio-serial-s390", &error_abort); } else { qemu_opt_set(bus_opts, "driver", "virtio-serial-pci", &error_abort); } dev_opts = qemu_opts_create(device, NULL, 0, &error_abort); qemu_opt_set(dev_opts, "driver", "virtconsole", &error_abort); snprintf(label, sizeof(label), "virtcon%d", index); virtcon_hds[index] = qemu_chr_new(label, devname, NULL); if (!virtcon_hds[index]) { fprintf(stderr, "qemu: could not connect virtio console" " to character backend '%s'\n", devname); return -1; } qemu_opt_set(dev_opts, "chardev", label, &error_abort); index++; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(const char *VAR_0) { QemuOptsList *device = qemu_find_opts("device"); static int VAR_1 = 0; char VAR_2[32]; QemuOpts *bus_opts, *dev_opts; if (strcmp(VAR_0, "none") == 0) return 0; if (VAR_1 == MAX_VIRTIO_CONSOLES) { fprintf(stderr, "qemu: too many virtio consoles\n"); exit(1); } bus_opts = qemu_opts_create(device, NULL, 0, &error_abort); if (arch_type == QEMU_ARCH_S390X) { qemu_opt_set(bus_opts, "driver", "virtio-serial-s390", &error_abort); } else { qemu_opt_set(bus_opts, "driver", "virtio-serial-pci", &error_abort); } dev_opts = qemu_opts_create(device, NULL, 0, &error_abort); qemu_opt_set(dev_opts, "driver", "virtconsole", &error_abort); snprintf(VAR_2, sizeof(VAR_2), "virtcon%d", VAR_1); virtcon_hds[VAR_1] = qemu_chr_new(VAR_2, VAR_0, NULL); if (!virtcon_hds[VAR_1]) { fprintf(stderr, "qemu: could not connect virtio console" " to character backend '%s'\n", VAR_0); return -1; } qemu_opt_set(dev_opts, "chardev", VAR_2, &error_abort); VAR_1++; return 0; }
[ "static int FUNC_0(const char *VAR_0)\n{", "QemuOptsList *device = qemu_find_opts(\"device\");", "static int VAR_1 = 0;", "char VAR_2[32];", "QemuOpts *bus_opts, *dev_opts;", "if (strcmp(VAR_0, \"none\") == 0)\nreturn 0;", "if (VAR_1 == MAX_VIRTIO_CONSOLES) {", "fprintf(stderr, \"qemu: too many virtio consoles\\n\");", "exit(1);", "}", "bus_opts = qemu_opts_create(device, NULL, 0, &error_abort);", "if (arch_type == QEMU_ARCH_S390X) {", "qemu_opt_set(bus_opts, \"driver\", \"virtio-serial-s390\", &error_abort);", "} else {", "qemu_opt_set(bus_opts, \"driver\", \"virtio-serial-pci\", &error_abort);", "}", "dev_opts = qemu_opts_create(device, NULL, 0, &error_abort);", "qemu_opt_set(dev_opts, \"driver\", \"virtconsole\", &error_abort);", "snprintf(VAR_2, sizeof(VAR_2), \"virtcon%d\", VAR_1);", "virtcon_hds[VAR_1] = qemu_chr_new(VAR_2, VAR_0, NULL);", "if (!virtcon_hds[VAR_1]) {", "fprintf(stderr, \"qemu: could not connect virtio console\"\n\" to character backend '%s'\\n\", VAR_0);", "return -1;", "}", "qemu_opt_set(dev_opts, \"chardev\", VAR_2, &error_abort);", "VAR_1++;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15, 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55, 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ] ]
12,527
void helper_lcall_protected(int new_cs, target_ulong new_eip, int shift, int next_eip_addend) { int new_stack, i; uint32_t e1, e2, cpl, dpl, rpl, selector, offset, param_count; uint32_t ss = 0, ss_e1 = 0, ss_e2 = 0, sp, type, ss_dpl, sp_mask; uint32_t val, limit, old_sp_mask; target_ulong ssp, old_ssp, next_eip; next_eip = env->eip + next_eip_addend; LOG_PCALL("lcall %04x:%08x s=%d\n", new_cs, (uint32_t)new_eip, shift); LOG_PCALL_STATE(env); if ((new_cs & 0xfffc) == 0) raise_exception_err(EXCP0D_GPF, 0); if (load_segment(&e1, &e2, new_cs) != 0) raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); cpl = env->hflags & HF_CPL_MASK; LOG_PCALL("desc=%08x:%08x\n", e1, e2); if (e2 & DESC_S_MASK) { if (!(e2 & DESC_CS_MASK)) raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); dpl = (e2 >> DESC_DPL_SHIFT) & 3; if (e2 & DESC_C_MASK) { /* conforming code segment */ if (dpl > cpl) raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); } else { /* non conforming code segment */ rpl = new_cs & 3; if (rpl > cpl) raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); if (dpl != cpl) raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); } if (!(e2 & DESC_P_MASK)) raise_exception_err(EXCP0B_NOSEG, new_cs & 0xfffc); #ifdef TARGET_X86_64 /* XXX: check 16/32 bit cases in long mode */ if (shift == 2) { target_ulong rsp; /* 64 bit case */ rsp = ESP; PUSHQ(rsp, env->segs[R_CS].selector); PUSHQ(rsp, next_eip); /* from this point, not restartable */ ESP = rsp; cpu_x86_load_seg_cache(env, R_CS, (new_cs & 0xfffc) | cpl, get_seg_base(e1, e2), get_seg_limit(e1, e2), e2); EIP = new_eip; } else #endif { sp = ESP; sp_mask = get_sp_mask(env->segs[R_SS].flags); ssp = env->segs[R_SS].base; if (shift) { PUSHL(ssp, sp, sp_mask, env->segs[R_CS].selector); PUSHL(ssp, sp, sp_mask, next_eip); } else { PUSHW(ssp, sp, sp_mask, env->segs[R_CS].selector); PUSHW(ssp, sp, sp_mask, next_eip); } limit = get_seg_limit(e1, e2); if (new_eip > limit) raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); /* from this point, not restartable */ SET_ESP(sp, sp_mask); cpu_x86_load_seg_cache(env, R_CS, (new_cs & 0xfffc) | cpl, get_seg_base(e1, e2), limit, e2); EIP = new_eip; } } else { /* check gate type */ type = (e2 >> DESC_TYPE_SHIFT) & 0x1f; dpl = (e2 >> DESC_DPL_SHIFT) & 3; rpl = new_cs & 3; switch(type) { case 1: /* available 286 TSS */ case 9: /* available 386 TSS */ case 5: /* task gate */ if (dpl < cpl || dpl < rpl) raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); switch_tss(new_cs, e1, e2, SWITCH_TSS_CALL, next_eip); CC_OP = CC_OP_EFLAGS; return; case 4: /* 286 call gate */ case 12: /* 386 call gate */ break; default: raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); break; } shift = type >> 3; if (dpl < cpl || dpl < rpl) raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); /* check valid bit */ if (!(e2 & DESC_P_MASK)) raise_exception_err(EXCP0B_NOSEG, new_cs & 0xfffc); selector = e1 >> 16; offset = (e2 & 0xffff0000) | (e1 & 0x0000ffff); param_count = e2 & 0x1f; if ((selector & 0xfffc) == 0) raise_exception_err(EXCP0D_GPF, 0); if (load_segment(&e1, &e2, selector) != 0) raise_exception_err(EXCP0D_GPF, selector & 0xfffc); if (!(e2 & DESC_S_MASK) || !(e2 & (DESC_CS_MASK))) raise_exception_err(EXCP0D_GPF, selector & 0xfffc); dpl = (e2 >> DESC_DPL_SHIFT) & 3; if (dpl > cpl) raise_exception_err(EXCP0D_GPF, selector & 0xfffc); if (!(e2 & DESC_P_MASK)) raise_exception_err(EXCP0B_NOSEG, selector & 0xfffc); if (!(e2 & DESC_C_MASK) && dpl < cpl) { /* to inner privilege */ get_ss_esp_from_tss(&ss, &sp, dpl); LOG_PCALL("new ss:esp=%04x:%08x param_count=%d ESP=" TARGET_FMT_lx "\n", ss, sp, param_count, ESP); if ((ss & 0xfffc) == 0) raise_exception_err(EXCP0A_TSS, ss & 0xfffc); if ((ss & 3) != dpl) raise_exception_err(EXCP0A_TSS, ss & 0xfffc); if (load_segment(&ss_e1, &ss_e2, ss) != 0) raise_exception_err(EXCP0A_TSS, ss & 0xfffc); ss_dpl = (ss_e2 >> DESC_DPL_SHIFT) & 3; if (ss_dpl != dpl) raise_exception_err(EXCP0A_TSS, ss & 0xfffc); if (!(ss_e2 & DESC_S_MASK) || (ss_e2 & DESC_CS_MASK) || !(ss_e2 & DESC_W_MASK)) raise_exception_err(EXCP0A_TSS, ss & 0xfffc); if (!(ss_e2 & DESC_P_MASK)) raise_exception_err(EXCP0A_TSS, ss & 0xfffc); // push_size = ((param_count * 2) + 8) << shift; old_sp_mask = get_sp_mask(env->segs[R_SS].flags); old_ssp = env->segs[R_SS].base; sp_mask = get_sp_mask(ss_e2); ssp = get_seg_base(ss_e1, ss_e2); if (shift) { PUSHL(ssp, sp, sp_mask, env->segs[R_SS].selector); PUSHL(ssp, sp, sp_mask, ESP); for(i = param_count - 1; i >= 0; i--) { val = ldl_kernel(old_ssp + ((ESP + i * 4) & old_sp_mask)); PUSHL(ssp, sp, sp_mask, val); } } else { PUSHW(ssp, sp, sp_mask, env->segs[R_SS].selector); PUSHW(ssp, sp, sp_mask, ESP); for(i = param_count - 1; i >= 0; i--) { val = lduw_kernel(old_ssp + ((ESP + i * 2) & old_sp_mask)); PUSHW(ssp, sp, sp_mask, val); } } new_stack = 1; } else { /* to same privilege */ sp = ESP; sp_mask = get_sp_mask(env->segs[R_SS].flags); ssp = env->segs[R_SS].base; // push_size = (4 << shift); new_stack = 0; } if (shift) { PUSHL(ssp, sp, sp_mask, env->segs[R_CS].selector); PUSHL(ssp, sp, sp_mask, next_eip); } else { PUSHW(ssp, sp, sp_mask, env->segs[R_CS].selector); PUSHW(ssp, sp, sp_mask, next_eip); } /* from this point, not restartable */ if (new_stack) { ss = (ss & ~3) | dpl; cpu_x86_load_seg_cache(env, R_SS, ss, ssp, get_seg_limit(ss_e1, ss_e2), ss_e2); } selector = (selector & ~3) | dpl; cpu_x86_load_seg_cache(env, R_CS, selector, get_seg_base(e1, e2), get_seg_limit(e1, e2), e2); cpu_x86_set_cpl(env, dpl); SET_ESP(sp, sp_mask); EIP = offset; } #ifdef CONFIG_KQEMU if (kqemu_is_ok(env)) { env->exception_index = -1; cpu_loop_exit(); } #endif }
false
qemu
4a1418e07bdcfaa3177739e04707ecaec75d89e1
void helper_lcall_protected(int new_cs, target_ulong new_eip, int shift, int next_eip_addend) { int new_stack, i; uint32_t e1, e2, cpl, dpl, rpl, selector, offset, param_count; uint32_t ss = 0, ss_e1 = 0, ss_e2 = 0, sp, type, ss_dpl, sp_mask; uint32_t val, limit, old_sp_mask; target_ulong ssp, old_ssp, next_eip; next_eip = env->eip + next_eip_addend; LOG_PCALL("lcall %04x:%08x s=%d\n", new_cs, (uint32_t)new_eip, shift); LOG_PCALL_STATE(env); if ((new_cs & 0xfffc) == 0) raise_exception_err(EXCP0D_GPF, 0); if (load_segment(&e1, &e2, new_cs) != 0) raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); cpl = env->hflags & HF_CPL_MASK; LOG_PCALL("desc=%08x:%08x\n", e1, e2); if (e2 & DESC_S_MASK) { if (!(e2 & DESC_CS_MASK)) raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); dpl = (e2 >> DESC_DPL_SHIFT) & 3; if (e2 & DESC_C_MASK) { if (dpl > cpl) raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); } else { rpl = new_cs & 3; if (rpl > cpl) raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); if (dpl != cpl) raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); } if (!(e2 & DESC_P_MASK)) raise_exception_err(EXCP0B_NOSEG, new_cs & 0xfffc); #ifdef TARGET_X86_64 if (shift == 2) { target_ulong rsp; rsp = ESP; PUSHQ(rsp, env->segs[R_CS].selector); PUSHQ(rsp, next_eip); ESP = rsp; cpu_x86_load_seg_cache(env, R_CS, (new_cs & 0xfffc) | cpl, get_seg_base(e1, e2), get_seg_limit(e1, e2), e2); EIP = new_eip; } else #endif { sp = ESP; sp_mask = get_sp_mask(env->segs[R_SS].flags); ssp = env->segs[R_SS].base; if (shift) { PUSHL(ssp, sp, sp_mask, env->segs[R_CS].selector); PUSHL(ssp, sp, sp_mask, next_eip); } else { PUSHW(ssp, sp, sp_mask, env->segs[R_CS].selector); PUSHW(ssp, sp, sp_mask, next_eip); } limit = get_seg_limit(e1, e2); if (new_eip > limit) raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); SET_ESP(sp, sp_mask); cpu_x86_load_seg_cache(env, R_CS, (new_cs & 0xfffc) | cpl, get_seg_base(e1, e2), limit, e2); EIP = new_eip; } } else { type = (e2 >> DESC_TYPE_SHIFT) & 0x1f; dpl = (e2 >> DESC_DPL_SHIFT) & 3; rpl = new_cs & 3; switch(type) { case 1: case 9: case 5: if (dpl < cpl || dpl < rpl) raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); switch_tss(new_cs, e1, e2, SWITCH_TSS_CALL, next_eip); CC_OP = CC_OP_EFLAGS; return; case 4: case 12: break; default: raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); break; } shift = type >> 3; if (dpl < cpl || dpl < rpl) raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); if (!(e2 & DESC_P_MASK)) raise_exception_err(EXCP0B_NOSEG, new_cs & 0xfffc); selector = e1 >> 16; offset = (e2 & 0xffff0000) | (e1 & 0x0000ffff); param_count = e2 & 0x1f; if ((selector & 0xfffc) == 0) raise_exception_err(EXCP0D_GPF, 0); if (load_segment(&e1, &e2, selector) != 0) raise_exception_err(EXCP0D_GPF, selector & 0xfffc); if (!(e2 & DESC_S_MASK) || !(e2 & (DESC_CS_MASK))) raise_exception_err(EXCP0D_GPF, selector & 0xfffc); dpl = (e2 >> DESC_DPL_SHIFT) & 3; if (dpl > cpl) raise_exception_err(EXCP0D_GPF, selector & 0xfffc); if (!(e2 & DESC_P_MASK)) raise_exception_err(EXCP0B_NOSEG, selector & 0xfffc); if (!(e2 & DESC_C_MASK) && dpl < cpl) { get_ss_esp_from_tss(&ss, &sp, dpl); LOG_PCALL("new ss:esp=%04x:%08x param_count=%d ESP=" TARGET_FMT_lx "\n", ss, sp, param_count, ESP); if ((ss & 0xfffc) == 0) raise_exception_err(EXCP0A_TSS, ss & 0xfffc); if ((ss & 3) != dpl) raise_exception_err(EXCP0A_TSS, ss & 0xfffc); if (load_segment(&ss_e1, &ss_e2, ss) != 0) raise_exception_err(EXCP0A_TSS, ss & 0xfffc); ss_dpl = (ss_e2 >> DESC_DPL_SHIFT) & 3; if (ss_dpl != dpl) raise_exception_err(EXCP0A_TSS, ss & 0xfffc); if (!(ss_e2 & DESC_S_MASK) || (ss_e2 & DESC_CS_MASK) || !(ss_e2 & DESC_W_MASK)) raise_exception_err(EXCP0A_TSS, ss & 0xfffc); if (!(ss_e2 & DESC_P_MASK)) raise_exception_err(EXCP0A_TSS, ss & 0xfffc); old_sp_mask = get_sp_mask(env->segs[R_SS].flags); old_ssp = env->segs[R_SS].base; sp_mask = get_sp_mask(ss_e2); ssp = get_seg_base(ss_e1, ss_e2); if (shift) { PUSHL(ssp, sp, sp_mask, env->segs[R_SS].selector); PUSHL(ssp, sp, sp_mask, ESP); for(i = param_count - 1; i >= 0; i--) { val = ldl_kernel(old_ssp + ((ESP + i * 4) & old_sp_mask)); PUSHL(ssp, sp, sp_mask, val); } } else { PUSHW(ssp, sp, sp_mask, env->segs[R_SS].selector); PUSHW(ssp, sp, sp_mask, ESP); for(i = param_count - 1; i >= 0; i--) { val = lduw_kernel(old_ssp + ((ESP + i * 2) & old_sp_mask)); PUSHW(ssp, sp, sp_mask, val); } } new_stack = 1; } else { sp = ESP; sp_mask = get_sp_mask(env->segs[R_SS].flags); ssp = env->segs[R_SS].base; new_stack = 0; } if (shift) { PUSHL(ssp, sp, sp_mask, env->segs[R_CS].selector); PUSHL(ssp, sp, sp_mask, next_eip); } else { PUSHW(ssp, sp, sp_mask, env->segs[R_CS].selector); PUSHW(ssp, sp, sp_mask, next_eip); } if (new_stack) { ss = (ss & ~3) | dpl; cpu_x86_load_seg_cache(env, R_SS, ss, ssp, get_seg_limit(ss_e1, ss_e2), ss_e2); } selector = (selector & ~3) | dpl; cpu_x86_load_seg_cache(env, R_CS, selector, get_seg_base(e1, e2), get_seg_limit(e1, e2), e2); cpu_x86_set_cpl(env, dpl); SET_ESP(sp, sp_mask); EIP = offset; } #ifdef CONFIG_KQEMU if (kqemu_is_ok(env)) { env->exception_index = -1; cpu_loop_exit(); } #endif }
{ "code": [], "line_no": [] }
void FUNC_0(int VAR_0, target_ulong VAR_1, int VAR_2, int VAR_3) { int VAR_4, VAR_5; uint32_t e1, e2, cpl, dpl, rpl, selector, offset, param_count; uint32_t ss = 0, ss_e1 = 0, ss_e2 = 0, sp, type, ss_dpl, sp_mask; uint32_t val, limit, old_sp_mask; target_ulong ssp, old_ssp, next_eip; next_eip = env->eip + VAR_3; LOG_PCALL("lcall %04x:%08x s=%d\n", VAR_0, (uint32_t)VAR_1, VAR_2); LOG_PCALL_STATE(env); if ((VAR_0 & 0xfffc) == 0) raise_exception_err(EXCP0D_GPF, 0); if (load_segment(&e1, &e2, VAR_0) != 0) raise_exception_err(EXCP0D_GPF, VAR_0 & 0xfffc); cpl = env->hflags & HF_CPL_MASK; LOG_PCALL("desc=%08x:%08x\n", e1, e2); if (e2 & DESC_S_MASK) { if (!(e2 & DESC_CS_MASK)) raise_exception_err(EXCP0D_GPF, VAR_0 & 0xfffc); dpl = (e2 >> DESC_DPL_SHIFT) & 3; if (e2 & DESC_C_MASK) { if (dpl > cpl) raise_exception_err(EXCP0D_GPF, VAR_0 & 0xfffc); } else { rpl = VAR_0 & 3; if (rpl > cpl) raise_exception_err(EXCP0D_GPF, VAR_0 & 0xfffc); if (dpl != cpl) raise_exception_err(EXCP0D_GPF, VAR_0 & 0xfffc); } if (!(e2 & DESC_P_MASK)) raise_exception_err(EXCP0B_NOSEG, VAR_0 & 0xfffc); #ifdef TARGET_X86_64 if (VAR_2 == 2) { target_ulong rsp; rsp = ESP; PUSHQ(rsp, env->segs[R_CS].selector); PUSHQ(rsp, next_eip); ESP = rsp; cpu_x86_load_seg_cache(env, R_CS, (VAR_0 & 0xfffc) | cpl, get_seg_base(e1, e2), get_seg_limit(e1, e2), e2); EIP = VAR_1; } else #endif { sp = ESP; sp_mask = get_sp_mask(env->segs[R_SS].flags); ssp = env->segs[R_SS].base; if (VAR_2) { PUSHL(ssp, sp, sp_mask, env->segs[R_CS].selector); PUSHL(ssp, sp, sp_mask, next_eip); } else { PUSHW(ssp, sp, sp_mask, env->segs[R_CS].selector); PUSHW(ssp, sp, sp_mask, next_eip); } limit = get_seg_limit(e1, e2); if (VAR_1 > limit) raise_exception_err(EXCP0D_GPF, VAR_0 & 0xfffc); SET_ESP(sp, sp_mask); cpu_x86_load_seg_cache(env, R_CS, (VAR_0 & 0xfffc) | cpl, get_seg_base(e1, e2), limit, e2); EIP = VAR_1; } } else { type = (e2 >> DESC_TYPE_SHIFT) & 0x1f; dpl = (e2 >> DESC_DPL_SHIFT) & 3; rpl = VAR_0 & 3; switch(type) { case 1: case 9: case 5: if (dpl < cpl || dpl < rpl) raise_exception_err(EXCP0D_GPF, VAR_0 & 0xfffc); switch_tss(VAR_0, e1, e2, SWITCH_TSS_CALL, next_eip); CC_OP = CC_OP_EFLAGS; return; case 4: case 12: break; default: raise_exception_err(EXCP0D_GPF, VAR_0 & 0xfffc); break; } VAR_2 = type >> 3; if (dpl < cpl || dpl < rpl) raise_exception_err(EXCP0D_GPF, VAR_0 & 0xfffc); if (!(e2 & DESC_P_MASK)) raise_exception_err(EXCP0B_NOSEG, VAR_0 & 0xfffc); selector = e1 >> 16; offset = (e2 & 0xffff0000) | (e1 & 0x0000ffff); param_count = e2 & 0x1f; if ((selector & 0xfffc) == 0) raise_exception_err(EXCP0D_GPF, 0); if (load_segment(&e1, &e2, selector) != 0) raise_exception_err(EXCP0D_GPF, selector & 0xfffc); if (!(e2 & DESC_S_MASK) || !(e2 & (DESC_CS_MASK))) raise_exception_err(EXCP0D_GPF, selector & 0xfffc); dpl = (e2 >> DESC_DPL_SHIFT) & 3; if (dpl > cpl) raise_exception_err(EXCP0D_GPF, selector & 0xfffc); if (!(e2 & DESC_P_MASK)) raise_exception_err(EXCP0B_NOSEG, selector & 0xfffc); if (!(e2 & DESC_C_MASK) && dpl < cpl) { get_ss_esp_from_tss(&ss, &sp, dpl); LOG_PCALL("new ss:esp=%04x:%08x param_count=%d ESP=" TARGET_FMT_lx "\n", ss, sp, param_count, ESP); if ((ss & 0xfffc) == 0) raise_exception_err(EXCP0A_TSS, ss & 0xfffc); if ((ss & 3) != dpl) raise_exception_err(EXCP0A_TSS, ss & 0xfffc); if (load_segment(&ss_e1, &ss_e2, ss) != 0) raise_exception_err(EXCP0A_TSS, ss & 0xfffc); ss_dpl = (ss_e2 >> DESC_DPL_SHIFT) & 3; if (ss_dpl != dpl) raise_exception_err(EXCP0A_TSS, ss & 0xfffc); if (!(ss_e2 & DESC_S_MASK) || (ss_e2 & DESC_CS_MASK) || !(ss_e2 & DESC_W_MASK)) raise_exception_err(EXCP0A_TSS, ss & 0xfffc); if (!(ss_e2 & DESC_P_MASK)) raise_exception_err(EXCP0A_TSS, ss & 0xfffc); old_sp_mask = get_sp_mask(env->segs[R_SS].flags); old_ssp = env->segs[R_SS].base; sp_mask = get_sp_mask(ss_e2); ssp = get_seg_base(ss_e1, ss_e2); if (VAR_2) { PUSHL(ssp, sp, sp_mask, env->segs[R_SS].selector); PUSHL(ssp, sp, sp_mask, ESP); for(VAR_5 = param_count - 1; VAR_5 >= 0; VAR_5--) { val = ldl_kernel(old_ssp + ((ESP + VAR_5 * 4) & old_sp_mask)); PUSHL(ssp, sp, sp_mask, val); } } else { PUSHW(ssp, sp, sp_mask, env->segs[R_SS].selector); PUSHW(ssp, sp, sp_mask, ESP); for(VAR_5 = param_count - 1; VAR_5 >= 0; VAR_5--) { val = lduw_kernel(old_ssp + ((ESP + VAR_5 * 2) & old_sp_mask)); PUSHW(ssp, sp, sp_mask, val); } } VAR_4 = 1; } else { sp = ESP; sp_mask = get_sp_mask(env->segs[R_SS].flags); ssp = env->segs[R_SS].base; VAR_4 = 0; } if (VAR_2) { PUSHL(ssp, sp, sp_mask, env->segs[R_CS].selector); PUSHL(ssp, sp, sp_mask, next_eip); } else { PUSHW(ssp, sp, sp_mask, env->segs[R_CS].selector); PUSHW(ssp, sp, sp_mask, next_eip); } if (VAR_4) { ss = (ss & ~3) | dpl; cpu_x86_load_seg_cache(env, R_SS, ss, ssp, get_seg_limit(ss_e1, ss_e2), ss_e2); } selector = (selector & ~3) | dpl; cpu_x86_load_seg_cache(env, R_CS, selector, get_seg_base(e1, e2), get_seg_limit(e1, e2), e2); cpu_x86_set_cpl(env, dpl); SET_ESP(sp, sp_mask); EIP = offset; } #ifdef CONFIG_KQEMU if (kqemu_is_ok(env)) { env->exception_index = -1; cpu_loop_exit(); } #endif }
[ "void FUNC_0(int VAR_0, target_ulong VAR_1,\nint VAR_2, int VAR_3)\n{", "int VAR_4, VAR_5;", "uint32_t e1, e2, cpl, dpl, rpl, selector, offset, param_count;", "uint32_t ss = 0, ss_e1 = 0, ss_e2 = 0, sp, type, ss_dpl, sp_mask;", "uint32_t val, limit, old_sp_mask;", "target_ulong ssp, old_ssp, next_eip;", "next_eip = env->eip + VAR_3;", "LOG_PCALL(\"lcall %04x:%08x s=%d\\n\", VAR_0, (uint32_t)VAR_1, VAR_2);", "LOG_PCALL_STATE(env);", "if ((VAR_0 & 0xfffc) == 0)\nraise_exception_err(EXCP0D_GPF, 0);", "if (load_segment(&e1, &e2, VAR_0) != 0)\nraise_exception_err(EXCP0D_GPF, VAR_0 & 0xfffc);", "cpl = env->hflags & HF_CPL_MASK;", "LOG_PCALL(\"desc=%08x:%08x\\n\", e1, e2);", "if (e2 & DESC_S_MASK) {", "if (!(e2 & DESC_CS_MASK))\nraise_exception_err(EXCP0D_GPF, VAR_0 & 0xfffc);", "dpl = (e2 >> DESC_DPL_SHIFT) & 3;", "if (e2 & DESC_C_MASK) {", "if (dpl > cpl)\nraise_exception_err(EXCP0D_GPF, VAR_0 & 0xfffc);", "} else {", "rpl = VAR_0 & 3;", "if (rpl > cpl)\nraise_exception_err(EXCP0D_GPF, VAR_0 & 0xfffc);", "if (dpl != cpl)\nraise_exception_err(EXCP0D_GPF, VAR_0 & 0xfffc);", "}", "if (!(e2 & DESC_P_MASK))\nraise_exception_err(EXCP0B_NOSEG, VAR_0 & 0xfffc);", "#ifdef TARGET_X86_64\nif (VAR_2 == 2) {", "target_ulong rsp;", "rsp = ESP;", "PUSHQ(rsp, env->segs[R_CS].selector);", "PUSHQ(rsp, next_eip);", "ESP = rsp;", "cpu_x86_load_seg_cache(env, R_CS, (VAR_0 & 0xfffc) | cpl,\nget_seg_base(e1, e2),\nget_seg_limit(e1, e2), e2);", "EIP = VAR_1;", "} else", "#endif\n{", "sp = ESP;", "sp_mask = get_sp_mask(env->segs[R_SS].flags);", "ssp = env->segs[R_SS].base;", "if (VAR_2) {", "PUSHL(ssp, sp, sp_mask, env->segs[R_CS].selector);", "PUSHL(ssp, sp, sp_mask, next_eip);", "} else {", "PUSHW(ssp, sp, sp_mask, env->segs[R_CS].selector);", "PUSHW(ssp, sp, sp_mask, next_eip);", "}", "limit = get_seg_limit(e1, e2);", "if (VAR_1 > limit)\nraise_exception_err(EXCP0D_GPF, VAR_0 & 0xfffc);", "SET_ESP(sp, sp_mask);", "cpu_x86_load_seg_cache(env, R_CS, (VAR_0 & 0xfffc) | cpl,\nget_seg_base(e1, e2), limit, e2);", "EIP = VAR_1;", "}", "} else {", "type = (e2 >> DESC_TYPE_SHIFT) & 0x1f;", "dpl = (e2 >> DESC_DPL_SHIFT) & 3;", "rpl = VAR_0 & 3;", "switch(type) {", "case 1:\ncase 9:\ncase 5:\nif (dpl < cpl || dpl < rpl)\nraise_exception_err(EXCP0D_GPF, VAR_0 & 0xfffc);", "switch_tss(VAR_0, e1, e2, SWITCH_TSS_CALL, next_eip);", "CC_OP = CC_OP_EFLAGS;", "return;", "case 4:\ncase 12:\nbreak;", "default:\nraise_exception_err(EXCP0D_GPF, VAR_0 & 0xfffc);", "break;", "}", "VAR_2 = type >> 3;", "if (dpl < cpl || dpl < rpl)\nraise_exception_err(EXCP0D_GPF, VAR_0 & 0xfffc);", "if (!(e2 & DESC_P_MASK))\nraise_exception_err(EXCP0B_NOSEG, VAR_0 & 0xfffc);", "selector = e1 >> 16;", "offset = (e2 & 0xffff0000) | (e1 & 0x0000ffff);", "param_count = e2 & 0x1f;", "if ((selector & 0xfffc) == 0)\nraise_exception_err(EXCP0D_GPF, 0);", "if (load_segment(&e1, &e2, selector) != 0)\nraise_exception_err(EXCP0D_GPF, selector & 0xfffc);", "if (!(e2 & DESC_S_MASK) || !(e2 & (DESC_CS_MASK)))\nraise_exception_err(EXCP0D_GPF, selector & 0xfffc);", "dpl = (e2 >> DESC_DPL_SHIFT) & 3;", "if (dpl > cpl)\nraise_exception_err(EXCP0D_GPF, selector & 0xfffc);", "if (!(e2 & DESC_P_MASK))\nraise_exception_err(EXCP0B_NOSEG, selector & 0xfffc);", "if (!(e2 & DESC_C_MASK) && dpl < cpl) {", "get_ss_esp_from_tss(&ss, &sp, dpl);", "LOG_PCALL(\"new ss:esp=%04x:%08x param_count=%d ESP=\" TARGET_FMT_lx \"\\n\",\nss, sp, param_count, ESP);", "if ((ss & 0xfffc) == 0)\nraise_exception_err(EXCP0A_TSS, ss & 0xfffc);", "if ((ss & 3) != dpl)\nraise_exception_err(EXCP0A_TSS, ss & 0xfffc);", "if (load_segment(&ss_e1, &ss_e2, ss) != 0)\nraise_exception_err(EXCP0A_TSS, ss & 0xfffc);", "ss_dpl = (ss_e2 >> DESC_DPL_SHIFT) & 3;", "if (ss_dpl != dpl)\nraise_exception_err(EXCP0A_TSS, ss & 0xfffc);", "if (!(ss_e2 & DESC_S_MASK) ||\n(ss_e2 & DESC_CS_MASK) ||\n!(ss_e2 & DESC_W_MASK))\nraise_exception_err(EXCP0A_TSS, ss & 0xfffc);", "if (!(ss_e2 & DESC_P_MASK))\nraise_exception_err(EXCP0A_TSS, ss & 0xfffc);", "old_sp_mask = get_sp_mask(env->segs[R_SS].flags);", "old_ssp = env->segs[R_SS].base;", "sp_mask = get_sp_mask(ss_e2);", "ssp = get_seg_base(ss_e1, ss_e2);", "if (VAR_2) {", "PUSHL(ssp, sp, sp_mask, env->segs[R_SS].selector);", "PUSHL(ssp, sp, sp_mask, ESP);", "for(VAR_5 = param_count - 1; VAR_5 >= 0; VAR_5--) {", "val = ldl_kernel(old_ssp + ((ESP + VAR_5 * 4) & old_sp_mask));", "PUSHL(ssp, sp, sp_mask, val);", "}", "} else {", "PUSHW(ssp, sp, sp_mask, env->segs[R_SS].selector);", "PUSHW(ssp, sp, sp_mask, ESP);", "for(VAR_5 = param_count - 1; VAR_5 >= 0; VAR_5--) {", "val = lduw_kernel(old_ssp + ((ESP + VAR_5 * 2) & old_sp_mask));", "PUSHW(ssp, sp, sp_mask, val);", "}", "}", "VAR_4 = 1;", "} else {", "sp = ESP;", "sp_mask = get_sp_mask(env->segs[R_SS].flags);", "ssp = env->segs[R_SS].base;", "VAR_4 = 0;", "}", "if (VAR_2) {", "PUSHL(ssp, sp, sp_mask, env->segs[R_CS].selector);", "PUSHL(ssp, sp, sp_mask, next_eip);", "} else {", "PUSHW(ssp, sp, sp_mask, env->segs[R_CS].selector);", "PUSHW(ssp, sp, sp_mask, next_eip);", "}", "if (VAR_4) {", "ss = (ss & ~3) | dpl;", "cpu_x86_load_seg_cache(env, R_SS, ss,\nssp,\nget_seg_limit(ss_e1, ss_e2),\nss_e2);", "}", "selector = (selector & ~3) | dpl;", "cpu_x86_load_seg_cache(env, R_CS, selector,\nget_seg_base(e1, e2),\nget_seg_limit(e1, e2),\ne2);", "cpu_x86_set_cpl(env, dpl);", "SET_ESP(sp, sp_mask);", "EIP = offset;", "}", "#ifdef CONFIG_KQEMU\nif (kqemu_is_ok(env)) {", "env->exception_index = -1;", "cpu_loop_exit();", "}", "#endif\n}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 29, 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39, 41 ], [ 43 ], [ 45 ], [ 49, 51 ], [ 53 ], [ 57 ], [ 59, 61 ], [ 63, 65 ], [ 67 ], [ 69, 71 ], [ 75, 79 ], [ 81 ], [ 85 ], [ 87 ], [ 89 ], [ 93 ], [ 95, 97, 99 ], [ 101 ], [ 103 ], [ 105, 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 131 ], [ 133, 135 ], [ 139 ], [ 141, 143 ], [ 145 ], [ 147 ], [ 149 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161, 163, 165, 167, 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177, 179, 181 ], [ 183, 185 ], [ 187 ], [ 189 ], [ 191 ], [ 195, 197 ], [ 201, 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211, 213 ], [ 217, 219 ], [ 221, 223 ], [ 225 ], [ 227, 229 ], [ 231, 233 ], [ 237 ], [ 241 ], [ 243, 245 ], [ 247, 249 ], [ 251, 253 ], [ 255, 257 ], [ 259 ], [ 261, 263 ], [ 265, 267, 269, 271 ], [ 273, 275 ], [ 283 ], [ 285 ], [ 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ], [ 299 ], [ 301 ], [ 303 ], [ 305 ], [ 307 ], [ 309 ], [ 311 ], [ 313 ], [ 315 ], [ 317 ], [ 319 ], [ 321 ], [ 323 ], [ 325 ], [ 329 ], [ 331 ], [ 333 ], [ 337 ], [ 339 ], [ 343 ], [ 345 ], [ 347 ], [ 349 ], [ 351 ], [ 353 ], [ 355 ], [ 363 ], [ 365 ], [ 367, 369, 371, 373 ], [ 375 ], [ 379 ], [ 381, 383, 385, 387 ], [ 389 ], [ 391 ], [ 393 ], [ 395 ], [ 397, 399 ], [ 401 ], [ 403 ], [ 405 ], [ 407, 409 ] ]
12,528
static void raw_reopen_abort(BDRVReopenState *state) { g_free(state->opaque); state->opaque = NULL; }
false
qemu
2e6fc7eb1a4af1b127df5f07b8bb28af891946fa
static void raw_reopen_abort(BDRVReopenState *state) { g_free(state->opaque); state->opaque = NULL; }
{ "code": [], "line_no": [] }
static void FUNC_0(BDRVReopenState *VAR_0) { g_free(VAR_0->opaque); VAR_0->opaque = NULL; }
[ "static void FUNC_0(BDRVReopenState *VAR_0)\n{", "g_free(VAR_0->opaque);", "VAR_0->opaque = NULL;", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ] ]
12,529
void err (const char *s) { perror (s); abort (); }
false
qemu
85b3ed1db5e50b66016ef59ca2afce10e753cbc6
void err (const char *s) { perror (s); abort (); }
{ "code": [], "line_no": [] }
void FUNC_0 (const char *VAR_0) { perror (VAR_0); abort (); }
[ "void FUNC_0 (const char *VAR_0)\n{", "perror (VAR_0);", "abort ();", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ] ]
12,530
static void hda_audio_command(HDACodecDevice *hda, uint32_t nid, uint32_t data) { HDAAudioState *a = HDA_AUDIO(hda); HDAAudioStream *st; const desc_node *node = NULL; const desc_param *param; uint32_t verb, payload, response, count, shift; if ((data & 0x70000) == 0x70000) { /* 12/8 id/payload */ verb = (data >> 8) & 0xfff; payload = data & 0x00ff; } else { /* 4/16 id/payload */ verb = (data >> 8) & 0xf00; payload = data & 0xffff; } node = hda_codec_find_node(a->desc, nid); if (node == NULL) { goto fail; } dprint(a, 2, "%s: nid %d (%s), verb 0x%x, payload 0x%x\n", __FUNCTION__, nid, node->name, verb, payload); switch (verb) { /* all nodes */ case AC_VERB_PARAMETERS: param = hda_codec_find_param(node, payload); if (param == NULL) { goto fail; } hda_codec_response(hda, true, param->val); break; case AC_VERB_GET_SUBSYSTEM_ID: hda_codec_response(hda, true, a->desc->iid); break; /* all functions */ case AC_VERB_GET_CONNECT_LIST: param = hda_codec_find_param(node, AC_PAR_CONNLIST_LEN); count = param ? param->val : 0; response = 0; shift = 0; while (payload < count && shift < 32) { response |= node->conn[payload] << shift; payload++; shift += 8; } hda_codec_response(hda, true, response); break; /* pin widget */ case AC_VERB_GET_CONFIG_DEFAULT: hda_codec_response(hda, true, node->config); break; case AC_VERB_GET_PIN_WIDGET_CONTROL: hda_codec_response(hda, true, node->pinctl); break; case AC_VERB_SET_PIN_WIDGET_CONTROL: if (node->pinctl != payload) { dprint(a, 1, "unhandled pin control bit\n"); } hda_codec_response(hda, true, 0); break; /* audio in/out widget */ case AC_VERB_SET_CHANNEL_STREAMID: st = a->st + node->stindex; if (st->node == NULL) { goto fail; } hda_audio_set_running(st, false); st->stream = (payload >> 4) & 0x0f; st->channel = payload & 0x0f; dprint(a, 2, "%s: stream %d, channel %d\n", st->node->name, st->stream, st->channel); hda_audio_set_running(st, a->running_real[st->output * 16 + st->stream]); hda_codec_response(hda, true, 0); break; case AC_VERB_GET_CONV: st = a->st + node->stindex; if (st->node == NULL) { goto fail; } response = st->stream << 4 | st->channel; hda_codec_response(hda, true, response); break; case AC_VERB_SET_STREAM_FORMAT: st = a->st + node->stindex; if (st->node == NULL) { goto fail; } st->format = payload; hda_codec_parse_fmt(st->format, &st->as); hda_audio_setup(st); hda_codec_response(hda, true, 0); break; case AC_VERB_GET_STREAM_FORMAT: st = a->st + node->stindex; if (st->node == NULL) { goto fail; } hda_codec_response(hda, true, st->format); break; case AC_VERB_GET_AMP_GAIN_MUTE: st = a->st + node->stindex; if (st->node == NULL) { goto fail; } if (payload & AC_AMP_GET_LEFT) { response = st->gain_left | (st->mute_left ? AC_AMP_MUTE : 0); } else { response = st->gain_right | (st->mute_right ? AC_AMP_MUTE : 0); } hda_codec_response(hda, true, response); break; case AC_VERB_SET_AMP_GAIN_MUTE: st = a->st + node->stindex; if (st->node == NULL) { goto fail; } dprint(a, 1, "amp (%s): %s%s%s%s index %d gain %3d %s\n", st->node->name, (payload & AC_AMP_SET_OUTPUT) ? "o" : "-", (payload & AC_AMP_SET_INPUT) ? "i" : "-", (payload & AC_AMP_SET_LEFT) ? "l" : "-", (payload & AC_AMP_SET_RIGHT) ? "r" : "-", (payload & AC_AMP_SET_INDEX) >> AC_AMP_SET_INDEX_SHIFT, (payload & AC_AMP_GAIN), (payload & AC_AMP_MUTE) ? "muted" : ""); if (payload & AC_AMP_SET_LEFT) { st->gain_left = payload & AC_AMP_GAIN; st->mute_left = payload & AC_AMP_MUTE; } if (payload & AC_AMP_SET_RIGHT) { st->gain_right = payload & AC_AMP_GAIN; st->mute_right = payload & AC_AMP_MUTE; } hda_audio_set_amp(st); hda_codec_response(hda, true, 0); break; /* not supported */ case AC_VERB_SET_POWER_STATE: case AC_VERB_GET_POWER_STATE: case AC_VERB_GET_SDI_SELECT: hda_codec_response(hda, true, 0); break; default: goto fail; } return; fail: dprint(a, 1, "%s: not handled: nid %d (%s), verb 0x%x, payload 0x%x\n", __FUNCTION__, nid, node ? node->name : "?", verb, payload); hda_codec_response(hda, true, 0); }
false
qemu
a89f364ae8740dfc31b321eed9ee454e996dc3c1
static void hda_audio_command(HDACodecDevice *hda, uint32_t nid, uint32_t data) { HDAAudioState *a = HDA_AUDIO(hda); HDAAudioStream *st; const desc_node *node = NULL; const desc_param *param; uint32_t verb, payload, response, count, shift; if ((data & 0x70000) == 0x70000) { verb = (data >> 8) & 0xfff; payload = data & 0x00ff; } else { verb = (data >> 8) & 0xf00; payload = data & 0xffff; } node = hda_codec_find_node(a->desc, nid); if (node == NULL) { goto fail; } dprint(a, 2, "%s: nid %d (%s), verb 0x%x, payload 0x%x\n", __FUNCTION__, nid, node->name, verb, payload); switch (verb) { case AC_VERB_PARAMETERS: param = hda_codec_find_param(node, payload); if (param == NULL) { goto fail; } hda_codec_response(hda, true, param->val); break; case AC_VERB_GET_SUBSYSTEM_ID: hda_codec_response(hda, true, a->desc->iid); break; case AC_VERB_GET_CONNECT_LIST: param = hda_codec_find_param(node, AC_PAR_CONNLIST_LEN); count = param ? param->val : 0; response = 0; shift = 0; while (payload < count && shift < 32) { response |= node->conn[payload] << shift; payload++; shift += 8; } hda_codec_response(hda, true, response); break; case AC_VERB_GET_CONFIG_DEFAULT: hda_codec_response(hda, true, node->config); break; case AC_VERB_GET_PIN_WIDGET_CONTROL: hda_codec_response(hda, true, node->pinctl); break; case AC_VERB_SET_PIN_WIDGET_CONTROL: if (node->pinctl != payload) { dprint(a, 1, "unhandled pin control bit\n"); } hda_codec_response(hda, true, 0); break; case AC_VERB_SET_CHANNEL_STREAMID: st = a->st + node->stindex; if (st->node == NULL) { goto fail; } hda_audio_set_running(st, false); st->stream = (payload >> 4) & 0x0f; st->channel = payload & 0x0f; dprint(a, 2, "%s: stream %d, channel %d\n", st->node->name, st->stream, st->channel); hda_audio_set_running(st, a->running_real[st->output * 16 + st->stream]); hda_codec_response(hda, true, 0); break; case AC_VERB_GET_CONV: st = a->st + node->stindex; if (st->node == NULL) { goto fail; } response = st->stream << 4 | st->channel; hda_codec_response(hda, true, response); break; case AC_VERB_SET_STREAM_FORMAT: st = a->st + node->stindex; if (st->node == NULL) { goto fail; } st->format = payload; hda_codec_parse_fmt(st->format, &st->as); hda_audio_setup(st); hda_codec_response(hda, true, 0); break; case AC_VERB_GET_STREAM_FORMAT: st = a->st + node->stindex; if (st->node == NULL) { goto fail; } hda_codec_response(hda, true, st->format); break; case AC_VERB_GET_AMP_GAIN_MUTE: st = a->st + node->stindex; if (st->node == NULL) { goto fail; } if (payload & AC_AMP_GET_LEFT) { response = st->gain_left | (st->mute_left ? AC_AMP_MUTE : 0); } else { response = st->gain_right | (st->mute_right ? AC_AMP_MUTE : 0); } hda_codec_response(hda, true, response); break; case AC_VERB_SET_AMP_GAIN_MUTE: st = a->st + node->stindex; if (st->node == NULL) { goto fail; } dprint(a, 1, "amp (%s): %s%s%s%s index %d gain %3d %s\n", st->node->name, (payload & AC_AMP_SET_OUTPUT) ? "o" : "-", (payload & AC_AMP_SET_INPUT) ? "i" : "-", (payload & AC_AMP_SET_LEFT) ? "l" : "-", (payload & AC_AMP_SET_RIGHT) ? "r" : "-", (payload & AC_AMP_SET_INDEX) >> AC_AMP_SET_INDEX_SHIFT, (payload & AC_AMP_GAIN), (payload & AC_AMP_MUTE) ? "muted" : ""); if (payload & AC_AMP_SET_LEFT) { st->gain_left = payload & AC_AMP_GAIN; st->mute_left = payload & AC_AMP_MUTE; } if (payload & AC_AMP_SET_RIGHT) { st->gain_right = payload & AC_AMP_GAIN; st->mute_right = payload & AC_AMP_MUTE; } hda_audio_set_amp(st); hda_codec_response(hda, true, 0); break; case AC_VERB_SET_POWER_STATE: case AC_VERB_GET_POWER_STATE: case AC_VERB_GET_SDI_SELECT: hda_codec_response(hda, true, 0); break; default: goto fail; } return; fail: dprint(a, 1, "%s: not handled: nid %d (%s), verb 0x%x, payload 0x%x\n", __FUNCTION__, nid, node ? node->name : "?", verb, payload); hda_codec_response(hda, true, 0); }
{ "code": [], "line_no": [] }
static void FUNC_0(HDACodecDevice *VAR_0, uint32_t VAR_1, uint32_t VAR_2) { HDAAudioState *a = HDA_AUDIO(VAR_0); HDAAudioStream *st; const desc_node *VAR_3 = NULL; const desc_param *VAR_4; uint32_t verb, payload, response, count, shift; if ((VAR_2 & 0x70000) == 0x70000) { verb = (VAR_2 >> 8) & 0xfff; payload = VAR_2 & 0x00ff; } else { verb = (VAR_2 >> 8) & 0xf00; payload = VAR_2 & 0xffff; } VAR_3 = hda_codec_find_node(a->desc, VAR_1); if (VAR_3 == NULL) { goto fail; } dprint(a, 2, "%s: VAR_1 %d (%s), verb 0x%x, payload 0x%x\n", __FUNCTION__, VAR_1, VAR_3->name, verb, payload); switch (verb) { case AC_VERB_PARAMETERS: VAR_4 = hda_codec_find_param(VAR_3, payload); if (VAR_4 == NULL) { goto fail; } hda_codec_response(VAR_0, true, VAR_4->val); break; case AC_VERB_GET_SUBSYSTEM_ID: hda_codec_response(VAR_0, true, a->desc->iid); break; case AC_VERB_GET_CONNECT_LIST: VAR_4 = hda_codec_find_param(VAR_3, AC_PAR_CONNLIST_LEN); count = VAR_4 ? VAR_4->val : 0; response = 0; shift = 0; while (payload < count && shift < 32) { response |= VAR_3->conn[payload] << shift; payload++; shift += 8; } hda_codec_response(VAR_0, true, response); break; case AC_VERB_GET_CONFIG_DEFAULT: hda_codec_response(VAR_0, true, VAR_3->config); break; case AC_VERB_GET_PIN_WIDGET_CONTROL: hda_codec_response(VAR_0, true, VAR_3->pinctl); break; case AC_VERB_SET_PIN_WIDGET_CONTROL: if (VAR_3->pinctl != payload) { dprint(a, 1, "unhandled pin control bit\n"); } hda_codec_response(VAR_0, true, 0); break; case AC_VERB_SET_CHANNEL_STREAMID: st = a->st + VAR_3->stindex; if (st->VAR_3 == NULL) { goto fail; } hda_audio_set_running(st, false); st->stream = (payload >> 4) & 0x0f; st->channel = payload & 0x0f; dprint(a, 2, "%s: stream %d, channel %d\n", st->VAR_3->name, st->stream, st->channel); hda_audio_set_running(st, a->running_real[st->output * 16 + st->stream]); hda_codec_response(VAR_0, true, 0); break; case AC_VERB_GET_CONV: st = a->st + VAR_3->stindex; if (st->VAR_3 == NULL) { goto fail; } response = st->stream << 4 | st->channel; hda_codec_response(VAR_0, true, response); break; case AC_VERB_SET_STREAM_FORMAT: st = a->st + VAR_3->stindex; if (st->VAR_3 == NULL) { goto fail; } st->format = payload; hda_codec_parse_fmt(st->format, &st->as); hda_audio_setup(st); hda_codec_response(VAR_0, true, 0); break; case AC_VERB_GET_STREAM_FORMAT: st = a->st + VAR_3->stindex; if (st->VAR_3 == NULL) { goto fail; } hda_codec_response(VAR_0, true, st->format); break; case AC_VERB_GET_AMP_GAIN_MUTE: st = a->st + VAR_3->stindex; if (st->VAR_3 == NULL) { goto fail; } if (payload & AC_AMP_GET_LEFT) { response = st->gain_left | (st->mute_left ? AC_AMP_MUTE : 0); } else { response = st->gain_right | (st->mute_right ? AC_AMP_MUTE : 0); } hda_codec_response(VAR_0, true, response); break; case AC_VERB_SET_AMP_GAIN_MUTE: st = a->st + VAR_3->stindex; if (st->VAR_3 == NULL) { goto fail; } dprint(a, 1, "amp (%s): %s%s%s%s index %d gain %3d %s\n", st->VAR_3->name, (payload & AC_AMP_SET_OUTPUT) ? "o" : "-", (payload & AC_AMP_SET_INPUT) ? "i" : "-", (payload & AC_AMP_SET_LEFT) ? "l" : "-", (payload & AC_AMP_SET_RIGHT) ? "r" : "-", (payload & AC_AMP_SET_INDEX) >> AC_AMP_SET_INDEX_SHIFT, (payload & AC_AMP_GAIN), (payload & AC_AMP_MUTE) ? "muted" : ""); if (payload & AC_AMP_SET_LEFT) { st->gain_left = payload & AC_AMP_GAIN; st->mute_left = payload & AC_AMP_MUTE; } if (payload & AC_AMP_SET_RIGHT) { st->gain_right = payload & AC_AMP_GAIN; st->mute_right = payload & AC_AMP_MUTE; } hda_audio_set_amp(st); hda_codec_response(VAR_0, true, 0); break; case AC_VERB_SET_POWER_STATE: case AC_VERB_GET_POWER_STATE: case AC_VERB_GET_SDI_SELECT: hda_codec_response(VAR_0, true, 0); break; default: goto fail; } return; fail: dprint(a, 1, "%s: not handled: VAR_1 %d (%s), verb 0x%x, payload 0x%x\n", __FUNCTION__, VAR_1, VAR_3 ? VAR_3->name : "?", verb, payload); hda_codec_response(VAR_0, true, 0); }
[ "static void FUNC_0(HDACodecDevice *VAR_0, uint32_t VAR_1, uint32_t VAR_2)\n{", "HDAAudioState *a = HDA_AUDIO(VAR_0);", "HDAAudioStream *st;", "const desc_node *VAR_3 = NULL;", "const desc_param *VAR_4;", "uint32_t verb, payload, response, count, shift;", "if ((VAR_2 & 0x70000) == 0x70000) {", "verb = (VAR_2 >> 8) & 0xfff;", "payload = VAR_2 & 0x00ff;", "} else {", "verb = (VAR_2 >> 8) & 0xf00;", "payload = VAR_2 & 0xffff;", "}", "VAR_3 = hda_codec_find_node(a->desc, VAR_1);", "if (VAR_3 == NULL) {", "goto fail;", "}", "dprint(a, 2, \"%s: VAR_1 %d (%s), verb 0x%x, payload 0x%x\\n\",\n__FUNCTION__, VAR_1, VAR_3->name, verb, payload);", "switch (verb) {", "case AC_VERB_PARAMETERS:\nVAR_4 = hda_codec_find_param(VAR_3, payload);", "if (VAR_4 == NULL) {", "goto fail;", "}", "hda_codec_response(VAR_0, true, VAR_4->val);", "break;", "case AC_VERB_GET_SUBSYSTEM_ID:\nhda_codec_response(VAR_0, true, a->desc->iid);", "break;", "case AC_VERB_GET_CONNECT_LIST:\nVAR_4 = hda_codec_find_param(VAR_3, AC_PAR_CONNLIST_LEN);", "count = VAR_4 ? VAR_4->val : 0;", "response = 0;", "shift = 0;", "while (payload < count && shift < 32) {", "response |= VAR_3->conn[payload] << shift;", "payload++;", "shift += 8;", "}", "hda_codec_response(VAR_0, true, response);", "break;", "case AC_VERB_GET_CONFIG_DEFAULT:\nhda_codec_response(VAR_0, true, VAR_3->config);", "break;", "case AC_VERB_GET_PIN_WIDGET_CONTROL:\nhda_codec_response(VAR_0, true, VAR_3->pinctl);", "break;", "case AC_VERB_SET_PIN_WIDGET_CONTROL:\nif (VAR_3->pinctl != payload) {", "dprint(a, 1, \"unhandled pin control bit\\n\");", "}", "hda_codec_response(VAR_0, true, 0);", "break;", "case AC_VERB_SET_CHANNEL_STREAMID:\nst = a->st + VAR_3->stindex;", "if (st->VAR_3 == NULL) {", "goto fail;", "}", "hda_audio_set_running(st, false);", "st->stream = (payload >> 4) & 0x0f;", "st->channel = payload & 0x0f;", "dprint(a, 2, \"%s: stream %d, channel %d\\n\",\nst->VAR_3->name, st->stream, st->channel);", "hda_audio_set_running(st, a->running_real[st->output * 16 + st->stream]);", "hda_codec_response(VAR_0, true, 0);", "break;", "case AC_VERB_GET_CONV:\nst = a->st + VAR_3->stindex;", "if (st->VAR_3 == NULL) {", "goto fail;", "}", "response = st->stream << 4 | st->channel;", "hda_codec_response(VAR_0, true, response);", "break;", "case AC_VERB_SET_STREAM_FORMAT:\nst = a->st + VAR_3->stindex;", "if (st->VAR_3 == NULL) {", "goto fail;", "}", "st->format = payload;", "hda_codec_parse_fmt(st->format, &st->as);", "hda_audio_setup(st);", "hda_codec_response(VAR_0, true, 0);", "break;", "case AC_VERB_GET_STREAM_FORMAT:\nst = a->st + VAR_3->stindex;", "if (st->VAR_3 == NULL) {", "goto fail;", "}", "hda_codec_response(VAR_0, true, st->format);", "break;", "case AC_VERB_GET_AMP_GAIN_MUTE:\nst = a->st + VAR_3->stindex;", "if (st->VAR_3 == NULL) {", "goto fail;", "}", "if (payload & AC_AMP_GET_LEFT) {", "response = st->gain_left | (st->mute_left ? AC_AMP_MUTE : 0);", "} else {", "response = st->gain_right | (st->mute_right ? AC_AMP_MUTE : 0);", "}", "hda_codec_response(VAR_0, true, response);", "break;", "case AC_VERB_SET_AMP_GAIN_MUTE:\nst = a->st + VAR_3->stindex;", "if (st->VAR_3 == NULL) {", "goto fail;", "}", "dprint(a, 1, \"amp (%s): %s%s%s%s index %d gain %3d %s\\n\",\nst->VAR_3->name,\n(payload & AC_AMP_SET_OUTPUT) ? \"o\" : \"-\",\n(payload & AC_AMP_SET_INPUT) ? \"i\" : \"-\",\n(payload & AC_AMP_SET_LEFT) ? \"l\" : \"-\",\n(payload & AC_AMP_SET_RIGHT) ? \"r\" : \"-\",\n(payload & AC_AMP_SET_INDEX) >> AC_AMP_SET_INDEX_SHIFT,\n(payload & AC_AMP_GAIN),\n(payload & AC_AMP_MUTE) ? \"muted\" : \"\");", "if (payload & AC_AMP_SET_LEFT) {", "st->gain_left = payload & AC_AMP_GAIN;", "st->mute_left = payload & AC_AMP_MUTE;", "}", "if (payload & AC_AMP_SET_RIGHT) {", "st->gain_right = payload & AC_AMP_GAIN;", "st->mute_right = payload & AC_AMP_MUTE;", "}", "hda_audio_set_amp(st);", "hda_codec_response(VAR_0, true, 0);", "break;", "case AC_VERB_SET_POWER_STATE:\ncase AC_VERB_GET_POWER_STATE:\ncase AC_VERB_GET_SDI_SELECT:\nhda_codec_response(VAR_0, true, 0);", "break;", "default:\ngoto fail;", "}", "return;", "fail:\ndprint(a, 1, \"%s: not handled: VAR_1 %d (%s), verb 0x%x, payload 0x%x\\n\",\n__FUNCTION__, VAR_1, VAR_3 ? VAR_3->name : \"?\", verb, payload);", "hda_codec_response(VAR_0, true, 0);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45, 47 ], [ 51 ], [ 55, 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69, 71 ], [ 73 ], [ 79, 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 107, 109 ], [ 111 ], [ 113, 115 ], [ 117 ], [ 119, 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 135, 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151, 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161, 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177, 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197, 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211, 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235, 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245, 247, 249, 251, 253, 255, 257, 259, 261 ], [ 263 ], [ 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 277 ], [ 279 ], [ 281 ], [ 283 ], [ 289, 291, 293, 295 ], [ 297 ], [ 299, 301 ], [ 303 ], [ 305 ], [ 309, 311, 313 ], [ 315 ], [ 317 ] ]
12,531
static void sdp_parse_fmtp_config(AVCodecContext * codec, void *ctx, char *attr, char *value) { switch (codec->codec_id) { case CODEC_ID_MPEG4: case CODEC_ID_AAC: if (!strcmp(attr, "config")) { /* decode the hexa encoded parameter */ int len = hex_to_data(NULL, value); if (codec->extradata) av_free(codec->extradata); codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE); if (!codec->extradata) return; codec->extradata_size = len; hex_to_data(codec->extradata, value); } break; case CODEC_ID_VORBIS: ff_vorbis_parse_fmtp_config(codec, ctx, attr, value); break; default: break; } return; }
false
FFmpeg
c89658008705d949c319df3fa6f400c481ad73e1
static void sdp_parse_fmtp_config(AVCodecContext * codec, void *ctx, char *attr, char *value) { switch (codec->codec_id) { case CODEC_ID_MPEG4: case CODEC_ID_AAC: if (!strcmp(attr, "config")) { int len = hex_to_data(NULL, value); if (codec->extradata) av_free(codec->extradata); codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE); if (!codec->extradata) return; codec->extradata_size = len; hex_to_data(codec->extradata, value); } break; case CODEC_ID_VORBIS: ff_vorbis_parse_fmtp_config(codec, ctx, attr, value); break; default: break; } return; }
{ "code": [], "line_no": [] }
static void FUNC_0(AVCodecContext * VAR_0, void *VAR_1, char *VAR_2, char *VAR_3) { switch (VAR_0->codec_id) { case CODEC_ID_MPEG4: case CODEC_ID_AAC: if (!strcmp(VAR_2, "config")) { int VAR_4 = hex_to_data(NULL, VAR_3); if (VAR_0->extradata) av_free(VAR_0->extradata); VAR_0->extradata = av_mallocz(VAR_4 + FF_INPUT_BUFFER_PADDING_SIZE); if (!VAR_0->extradata) return; VAR_0->extradata_size = VAR_4; hex_to_data(VAR_0->extradata, VAR_3); } break; case CODEC_ID_VORBIS: ff_vorbis_parse_fmtp_config(VAR_0, VAR_1, VAR_2, VAR_3); break; default: break; } return; }
[ "static void FUNC_0(AVCodecContext * VAR_0, void *VAR_1,\nchar *VAR_2, char *VAR_3)\n{", "switch (VAR_0->codec_id) {", "case CODEC_ID_MPEG4:\ncase CODEC_ID_AAC:\nif (!strcmp(VAR_2, \"config\")) {", "int VAR_4 = hex_to_data(NULL, VAR_3);", "if (VAR_0->extradata)\nav_free(VAR_0->extradata);", "VAR_0->extradata = av_mallocz(VAR_4 + FF_INPUT_BUFFER_PADDING_SIZE);", "if (!VAR_0->extradata)\nreturn;", "VAR_0->extradata_size = VAR_4;", "hex_to_data(VAR_0->extradata, VAR_3);", "}", "break;", "case CODEC_ID_VORBIS:\nff_vorbis_parse_fmtp_config(VAR_0, VAR_1, VAR_2, VAR_3);", "break;", "default:\nbreak;", "}", "return;", "}" ]
[ 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 ] ]
12,532
static void mux_print_help(CharDriverState *chr) { int i, j; char ebuf[15] = "Escape-Char"; char cbuf[50] = "\n\r"; if (term_escape_char > 0 && term_escape_char < 26) { snprintf(cbuf, sizeof(cbuf), "\n\r"); snprintf(ebuf, sizeof(ebuf), "C-%c", term_escape_char - 1 + 'a'); } else { snprintf(cbuf, sizeof(cbuf), "\n\rEscape-Char set to Ascii: 0x%02x\n\r\n\r", term_escape_char); } qemu_chr_fe_write(chr, (uint8_t *)cbuf, strlen(cbuf)); for (i = 0; mux_help[i] != NULL; i++) { for (j=0; mux_help[i][j] != '\0'; j++) { if (mux_help[i][j] == '%') qemu_chr_fe_write(chr, (uint8_t *)ebuf, strlen(ebuf)); else qemu_chr_fe_write(chr, (uint8_t *)&mux_help[i][j], 1); } } }
false
qemu
90f998f5f4267a0c22e983f533d19b9de1849283
static void mux_print_help(CharDriverState *chr) { int i, j; char ebuf[15] = "Escape-Char"; char cbuf[50] = "\n\r"; if (term_escape_char > 0 && term_escape_char < 26) { snprintf(cbuf, sizeof(cbuf), "\n\r"); snprintf(ebuf, sizeof(ebuf), "C-%c", term_escape_char - 1 + 'a'); } else { snprintf(cbuf, sizeof(cbuf), "\n\rEscape-Char set to Ascii: 0x%02x\n\r\n\r", term_escape_char); } qemu_chr_fe_write(chr, (uint8_t *)cbuf, strlen(cbuf)); for (i = 0; mux_help[i] != NULL; i++) { for (j=0; mux_help[i][j] != '\0'; j++) { if (mux_help[i][j] == '%') qemu_chr_fe_write(chr, (uint8_t *)ebuf, strlen(ebuf)); else qemu_chr_fe_write(chr, (uint8_t *)&mux_help[i][j], 1); } } }
{ "code": [], "line_no": [] }
static void FUNC_0(CharDriverState *VAR_0) { int VAR_1, VAR_2; char VAR_3[15] = "Escape-Char"; char VAR_4[50] = "\n\r"; if (term_escape_char > 0 && term_escape_char < 26) { snprintf(VAR_4, sizeof(VAR_4), "\n\r"); snprintf(VAR_3, sizeof(VAR_3), "C-%c", term_escape_char - 1 + 'a'); } else { snprintf(VAR_4, sizeof(VAR_4), "\n\rEscape-Char set to Ascii: 0x%02x\n\r\n\r", term_escape_char); } qemu_chr_fe_write(VAR_0, (uint8_t *)VAR_4, strlen(VAR_4)); for (VAR_1 = 0; mux_help[VAR_1] != NULL; VAR_1++) { for (VAR_2=0; mux_help[VAR_1][VAR_2] != '\0'; VAR_2++) { if (mux_help[VAR_1][VAR_2] == '%') qemu_chr_fe_write(VAR_0, (uint8_t *)VAR_3, strlen(VAR_3)); else qemu_chr_fe_write(VAR_0, (uint8_t *)&mux_help[VAR_1][VAR_2], 1); } } }
[ "static void FUNC_0(CharDriverState *VAR_0)\n{", "int VAR_1, VAR_2;", "char VAR_3[15] = \"Escape-Char\";", "char VAR_4[50] = \"\\n\\r\";", "if (term_escape_char > 0 && term_escape_char < 26) {", "snprintf(VAR_4, sizeof(VAR_4), \"\\n\\r\");", "snprintf(VAR_3, sizeof(VAR_3), \"C-%c\", term_escape_char - 1 + 'a');", "} else {", "snprintf(VAR_4, sizeof(VAR_4),\n\"\\n\\rEscape-Char set to Ascii: 0x%02x\\n\\r\\n\\r\",\nterm_escape_char);", "}", "qemu_chr_fe_write(VAR_0, (uint8_t *)VAR_4, strlen(VAR_4));", "for (VAR_1 = 0; mux_help[VAR_1] != NULL; VAR_1++) {", "for (VAR_2=0; mux_help[VAR_1][VAR_2] != '\\0'; VAR_2++) {", "if (mux_help[VAR_1][VAR_2] == '%')\nqemu_chr_fe_write(VAR_0, (uint8_t *)VAR_3, strlen(VAR_3));", "else\nqemu_chr_fe_write(VAR_0, (uint8_t *)&mux_help[VAR_1][VAR_2], 1);", "}", "}", "}" ]
[ 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 ] ]
12,533
void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict) { struct in_addr host_addr = { .s_addr = INADDR_ANY }; int host_port; char buf[256] = ""; const char *src_str, *p; SlirpState *s; int is_udp = 0; int err; const char *arg1 = qdict_get_str(qdict, "arg1"); const char *arg2 = qdict_get_try_str(qdict, "arg2"); const char *arg3 = qdict_get_try_str(qdict, "arg3"); if (arg2) { s = slirp_lookup(mon, arg1, arg2); src_str = arg3; } else { s = slirp_lookup(mon, NULL, NULL); src_str = arg1; } if (!s) { return; } if (!src_str || !src_str[0]) goto fail_syntax; p = src_str; get_str_sep(buf, sizeof(buf), &p, ':'); if (!strcmp(buf, "tcp") || buf[0] == '\0') { is_udp = 0; } else if (!strcmp(buf, "udp")) { is_udp = 1; } else { goto fail_syntax; } if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) { goto fail_syntax; } if (buf[0] != '\0' && !inet_aton(buf, &host_addr)) { goto fail_syntax; } host_port = atoi(p); err = slirp_remove_hostfwd(TAILQ_FIRST(&slirp_stacks)->slirp, is_udp, host_addr, host_port); monitor_printf(mon, "host forwarding rule for %s %s\n", src_str, err ? "removed" : "not found"); return; fail_syntax: monitor_printf(mon, "invalid format\n"); }
false
qemu
72cf2d4f0e181d0d3a3122e04129c58a95da713e
void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict) { struct in_addr host_addr = { .s_addr = INADDR_ANY }; int host_port; char buf[256] = ""; const char *src_str, *p; SlirpState *s; int is_udp = 0; int err; const char *arg1 = qdict_get_str(qdict, "arg1"); const char *arg2 = qdict_get_try_str(qdict, "arg2"); const char *arg3 = qdict_get_try_str(qdict, "arg3"); if (arg2) { s = slirp_lookup(mon, arg1, arg2); src_str = arg3; } else { s = slirp_lookup(mon, NULL, NULL); src_str = arg1; } if (!s) { return; } if (!src_str || !src_str[0]) goto fail_syntax; p = src_str; get_str_sep(buf, sizeof(buf), &p, ':'); if (!strcmp(buf, "tcp") || buf[0] == '\0') { is_udp = 0; } else if (!strcmp(buf, "udp")) { is_udp = 1; } else { goto fail_syntax; } if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) { goto fail_syntax; } if (buf[0] != '\0' && !inet_aton(buf, &host_addr)) { goto fail_syntax; } host_port = atoi(p); err = slirp_remove_hostfwd(TAILQ_FIRST(&slirp_stacks)->slirp, is_udp, host_addr, host_port); monitor_printf(mon, "host forwarding rule for %s %s\n", src_str, err ? "removed" : "not found"); return; fail_syntax: monitor_printf(mon, "invalid format\n"); }
{ "code": [], "line_no": [] }
void FUNC_0(Monitor *VAR_0, const QDict *VAR_1) { struct in_addr VAR_2 = { .s_addr = INADDR_ANY }; int VAR_3; char VAR_4[256] = ""; const char *VAR_5, *VAR_6; SlirpState *s; int VAR_7 = 0; int VAR_8; const char *VAR_9 = qdict_get_str(VAR_1, "VAR_9"); const char *VAR_10 = qdict_get_try_str(VAR_1, "VAR_10"); const char *VAR_11 = qdict_get_try_str(VAR_1, "VAR_11"); if (VAR_10) { s = slirp_lookup(VAR_0, VAR_9, VAR_10); VAR_5 = VAR_11; } else { s = slirp_lookup(VAR_0, NULL, NULL); VAR_5 = VAR_9; } if (!s) { return; } if (!VAR_5 || !VAR_5[0]) goto fail_syntax; VAR_6 = VAR_5; get_str_sep(VAR_4, sizeof(VAR_4), &VAR_6, ':'); if (!strcmp(VAR_4, "tcp") || VAR_4[0] == '\0') { VAR_7 = 0; } else if (!strcmp(VAR_4, "udp")) { VAR_7 = 1; } else { goto fail_syntax; } if (get_str_sep(VAR_4, sizeof(VAR_4), &VAR_6, ':') < 0) { goto fail_syntax; } if (VAR_4[0] != '\0' && !inet_aton(VAR_4, &VAR_2)) { goto fail_syntax; } VAR_3 = atoi(VAR_6); VAR_8 = slirp_remove_hostfwd(TAILQ_FIRST(&slirp_stacks)->slirp, VAR_7, VAR_2, VAR_3); monitor_printf(VAR_0, "host forwarding rule for %s %s\n", VAR_5, VAR_8 ? "removed" : "not found"); return; fail_syntax: monitor_printf(VAR_0, "invalid format\n"); }
[ "void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)\n{", "struct in_addr VAR_2 = { .s_addr = INADDR_ANY };", "int VAR_3;", "char VAR_4[256] = \"\";", "const char *VAR_5, *VAR_6;", "SlirpState *s;", "int VAR_7 = 0;", "int VAR_8;", "const char *VAR_9 = qdict_get_str(VAR_1, \"VAR_9\");", "const char *VAR_10 = qdict_get_try_str(VAR_1, \"VAR_10\");", "const char *VAR_11 = qdict_get_try_str(VAR_1, \"VAR_11\");", "if (VAR_10) {", "s = slirp_lookup(VAR_0, VAR_9, VAR_10);", "VAR_5 = VAR_11;", "} else {", "s = slirp_lookup(VAR_0, NULL, NULL);", "VAR_5 = VAR_9;", "}", "if (!s) {", "return;", "}", "if (!VAR_5 || !VAR_5[0])\ngoto fail_syntax;", "VAR_6 = VAR_5;", "get_str_sep(VAR_4, sizeof(VAR_4), &VAR_6, ':');", "if (!strcmp(VAR_4, \"tcp\") || VAR_4[0] == '\\0') {", "VAR_7 = 0;", "} else if (!strcmp(VAR_4, \"udp\")) {", "VAR_7 = 1;", "} else {", "goto fail_syntax;", "}", "if (get_str_sep(VAR_4, sizeof(VAR_4), &VAR_6, ':') < 0) {", "goto fail_syntax;", "}", "if (VAR_4[0] != '\\0' && !inet_aton(VAR_4, &VAR_2)) {", "goto fail_syntax;", "}", "VAR_3 = atoi(VAR_6);", "VAR_8 = slirp_remove_hostfwd(TAILQ_FIRST(&slirp_stacks)->slirp, VAR_7,\nVAR_2, VAR_3);", "monitor_printf(VAR_0, \"host forwarding rule for %s %s\\n\", VAR_5,\nVAR_8 ? \"removed\" : \"not found\");", "return;", "fail_syntax:\nmonitor_printf(VAR_0, \"invalid format\\n\");", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49, 51 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 91 ], [ 95, 97 ], [ 101, 103 ], [ 105 ], [ 109, 111 ], [ 113 ] ]
12,534
static QObject *parse_object(JSONParserContext *ctxt, va_list *ap) { QDict *dict = NULL; QObject *token, *peek; JSONParserContext saved_ctxt = parser_context_save(ctxt); token = parser_context_pop_token(ctxt); if (token == NULL) { goto out; } if (!token_is_operator(token, '{')) { goto out; } dict = qdict_new(); peek = parser_context_peek_token(ctxt); if (peek == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } if (!token_is_operator(peek, '}')) { if (parse_pair(ctxt, dict, ap) == -1) { goto out; } token = parser_context_pop_token(ctxt); if (token == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } while (!token_is_operator(token, '}')) { if (!token_is_operator(token, ',')) { parse_error(ctxt, token, "expected separator in dict"); goto out; } if (parse_pair(ctxt, dict, ap) == -1) { goto out; } token = parser_context_pop_token(ctxt); if (token == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } } } else { (void)parser_context_pop_token(ctxt); } return QOBJECT(dict); out: parser_context_restore(ctxt, saved_ctxt); QDECREF(dict); return NULL; }
false
qemu
c54616608af442edf4cfb7397a1909c2653efba0
static QObject *parse_object(JSONParserContext *ctxt, va_list *ap) { QDict *dict = NULL; QObject *token, *peek; JSONParserContext saved_ctxt = parser_context_save(ctxt); token = parser_context_pop_token(ctxt); if (token == NULL) { goto out; } if (!token_is_operator(token, '{')) { goto out; } dict = qdict_new(); peek = parser_context_peek_token(ctxt); if (peek == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } if (!token_is_operator(peek, '}')) { if (parse_pair(ctxt, dict, ap) == -1) { goto out; } token = parser_context_pop_token(ctxt); if (token == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } while (!token_is_operator(token, '}')) { if (!token_is_operator(token, ',')) { parse_error(ctxt, token, "expected separator in dict"); goto out; } if (parse_pair(ctxt, dict, ap) == -1) { goto out; } token = parser_context_pop_token(ctxt); if (token == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } } } else { (void)parser_context_pop_token(ctxt); } return QOBJECT(dict); out: parser_context_restore(ctxt, saved_ctxt); QDECREF(dict); return NULL; }
{ "code": [], "line_no": [] }
static QObject *FUNC_0(JSONParserContext *ctxt, va_list *ap) { QDict *dict = NULL; QObject *token, *peek; JSONParserContext saved_ctxt = parser_context_save(ctxt); token = parser_context_pop_token(ctxt); if (token == NULL) { goto out; } if (!token_is_operator(token, '{')) { goto out; } dict = qdict_new(); peek = parser_context_peek_token(ctxt); if (peek == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } if (!token_is_operator(peek, '}')) { if (parse_pair(ctxt, dict, ap) == -1) { goto out; } token = parser_context_pop_token(ctxt); if (token == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } while (!token_is_operator(token, '}')) { if (!token_is_operator(token, ',')) { parse_error(ctxt, token, "expected separator in dict"); goto out; } if (parse_pair(ctxt, dict, ap) == -1) { goto out; } token = parser_context_pop_token(ctxt); if (token == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } } } else { (void)parser_context_pop_token(ctxt); } return QOBJECT(dict); out: parser_context_restore(ctxt, saved_ctxt); QDECREF(dict); return NULL; }
[ "static QObject *FUNC_0(JSONParserContext *ctxt, va_list *ap)\n{", "QDict *dict = NULL;", "QObject *token, *peek;", "JSONParserContext saved_ctxt = parser_context_save(ctxt);", "token = parser_context_pop_token(ctxt);", "if (token == NULL) {", "goto out;", "}", "if (!token_is_operator(token, '{')) {", "goto out;", "}", "dict = qdict_new();", "peek = parser_context_peek_token(ctxt);", "if (peek == NULL) {", "parse_error(ctxt, NULL, \"premature EOI\");", "goto out;", "}", "if (!token_is_operator(peek, '}')) {", "if (parse_pair(ctxt, dict, ap) == -1) {", "goto out;", "}", "token = parser_context_pop_token(ctxt);", "if (token == NULL) {", "parse_error(ctxt, NULL, \"premature EOI\");", "goto out;", "}", "while (!token_is_operator(token, '}')) {", "if (!token_is_operator(token, ',')) {", "parse_error(ctxt, token, \"expected separator in dict\");", "goto out;", "}", "if (parse_pair(ctxt, dict, ap) == -1) {", "goto out;", "}", "token = parser_context_pop_token(ctxt);", "if (token == NULL) {", "parse_error(ctxt, NULL, \"premature EOI\");", "goto out;", "}", "}", "} else {", "(void)parser_context_pop_token(ctxt);", "}", "return QOBJECT(dict);", "out:\nparser_context_restore(ctxt, saved_ctxt);", "QDECREF(dict);", "return NULL;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 81 ], [ 83 ], [ 85 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 109 ], [ 113, 115 ], [ 117 ], [ 119 ], [ 121 ] ]
12,535
static void qemu_chr_parse_mux(QemuOpts *opts, ChardevBackend *backend, Error **errp) { const char *chardev = qemu_opt_get(opts, "chardev"); ChardevMux *mux; if (chardev == NULL) { error_setg(errp, "chardev: mux: no chardev given"); return; } mux = backend->u.mux = g_new0(ChardevMux, 1); qemu_chr_parse_common(opts, qapi_ChardevMux_base(mux)); mux->chardev = g_strdup(chardev); }
false
qemu
32bafa8fdd098d52fbf1102d5a5e48d29398c0aa
static void qemu_chr_parse_mux(QemuOpts *opts, ChardevBackend *backend, Error **errp) { const char *chardev = qemu_opt_get(opts, "chardev"); ChardevMux *mux; if (chardev == NULL) { error_setg(errp, "chardev: mux: no chardev given"); return; } mux = backend->u.mux = g_new0(ChardevMux, 1); qemu_chr_parse_common(opts, qapi_ChardevMux_base(mux)); mux->chardev = g_strdup(chardev); }
{ "code": [], "line_no": [] }
static void FUNC_0(QemuOpts *VAR_0, ChardevBackend *VAR_1, Error **VAR_2) { const char *VAR_3 = qemu_opt_get(VAR_0, "VAR_3"); ChardevMux *mux; if (VAR_3 == NULL) { error_setg(VAR_2, "VAR_3: mux: no VAR_3 given"); return; } mux = VAR_1->u.mux = g_new0(ChardevMux, 1); qemu_chr_parse_common(VAR_0, qapi_ChardevMux_base(mux)); mux->VAR_3 = g_strdup(VAR_3); }
[ "static void FUNC_0(QemuOpts *VAR_0, ChardevBackend *VAR_1,\nError **VAR_2)\n{", "const char *VAR_3 = qemu_opt_get(VAR_0, \"VAR_3\");", "ChardevMux *mux;", "if (VAR_3 == NULL) {", "error_setg(VAR_2, \"VAR_3: mux: no VAR_3 given\");", "return;", "}", "mux = VAR_1->u.mux = g_new0(ChardevMux, 1);", "qemu_chr_parse_common(VAR_0, qapi_ChardevMux_base(mux));", "mux->VAR_3 = g_strdup(VAR_3);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ] ]
12,536
static void do_flush_queued_data(VirtIOSerialPort *port, VirtQueue *vq, VirtIODevice *vdev) { VirtIOSerialPortClass *vsc; assert(port); assert(virtio_queue_ready(vq)); vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port); while (!port->throttled) { unsigned int i; /* Pop an elem only if we haven't left off a previous one mid-way */ if (!port->elem.out_num) { if (!virtqueue_pop(vq, &port->elem)) { break; } port->iov_idx = 0; port->iov_offset = 0; } for (i = port->iov_idx; i < port->elem.out_num; i++) { size_t buf_size; ssize_t ret; buf_size = port->elem.out_sg[i].iov_len - port->iov_offset; ret = vsc->have_data(port, port->elem.out_sg[i].iov_base + port->iov_offset, buf_size); if (port->throttled) { port->iov_idx = i; if (ret > 0) { port->iov_offset += ret; } break; } port->iov_offset = 0; } if (port->throttled) { break; } virtqueue_push(vq, &port->elem, 0); port->elem.out_num = 0; } virtio_notify(vdev, vq); }
false
qemu
51b19ebe4320f3dcd93cea71235c1219318ddfd2
static void do_flush_queued_data(VirtIOSerialPort *port, VirtQueue *vq, VirtIODevice *vdev) { VirtIOSerialPortClass *vsc; assert(port); assert(virtio_queue_ready(vq)); vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port); while (!port->throttled) { unsigned int i; if (!port->elem.out_num) { if (!virtqueue_pop(vq, &port->elem)) { break; } port->iov_idx = 0; port->iov_offset = 0; } for (i = port->iov_idx; i < port->elem.out_num; i++) { size_t buf_size; ssize_t ret; buf_size = port->elem.out_sg[i].iov_len - port->iov_offset; ret = vsc->have_data(port, port->elem.out_sg[i].iov_base + port->iov_offset, buf_size); if (port->throttled) { port->iov_idx = i; if (ret > 0) { port->iov_offset += ret; } break; } port->iov_offset = 0; } if (port->throttled) { break; } virtqueue_push(vq, &port->elem, 0); port->elem.out_num = 0; } virtio_notify(vdev, vq); }
{ "code": [], "line_no": [] }
static void FUNC_0(VirtIOSerialPort *VAR_0, VirtQueue *VAR_1, VirtIODevice *VAR_2) { VirtIOSerialPortClass *vsc; assert(VAR_0); assert(virtio_queue_ready(VAR_1)); vsc = VIRTIO_SERIAL_PORT_GET_CLASS(VAR_0); while (!VAR_0->throttled) { unsigned int VAR_3; if (!VAR_0->elem.out_num) { if (!virtqueue_pop(VAR_1, &VAR_0->elem)) { break; } VAR_0->iov_idx = 0; VAR_0->iov_offset = 0; } for (VAR_3 = VAR_0->iov_idx; VAR_3 < VAR_0->elem.out_num; VAR_3++) { size_t buf_size; ssize_t ret; buf_size = VAR_0->elem.out_sg[VAR_3].iov_len - VAR_0->iov_offset; ret = vsc->have_data(VAR_0, VAR_0->elem.out_sg[VAR_3].iov_base + VAR_0->iov_offset, buf_size); if (VAR_0->throttled) { VAR_0->iov_idx = VAR_3; if (ret > 0) { VAR_0->iov_offset += ret; } break; } VAR_0->iov_offset = 0; } if (VAR_0->throttled) { break; } virtqueue_push(VAR_1, &VAR_0->elem, 0); VAR_0->elem.out_num = 0; } virtio_notify(VAR_2, VAR_1); }
[ "static void FUNC_0(VirtIOSerialPort *VAR_0, VirtQueue *VAR_1,\nVirtIODevice *VAR_2)\n{", "VirtIOSerialPortClass *vsc;", "assert(VAR_0);", "assert(virtio_queue_ready(VAR_1));", "vsc = VIRTIO_SERIAL_PORT_GET_CLASS(VAR_0);", "while (!VAR_0->throttled) {", "unsigned int VAR_3;", "if (!VAR_0->elem.out_num) {", "if (!virtqueue_pop(VAR_1, &VAR_0->elem)) {", "break;", "}", "VAR_0->iov_idx = 0;", "VAR_0->iov_offset = 0;", "}", "for (VAR_3 = VAR_0->iov_idx; VAR_3 < VAR_0->elem.out_num; VAR_3++) {", "size_t buf_size;", "ssize_t ret;", "buf_size = VAR_0->elem.out_sg[VAR_3].iov_len - VAR_0->iov_offset;", "ret = vsc->have_data(VAR_0,\nVAR_0->elem.out_sg[VAR_3].iov_base\n+ VAR_0->iov_offset,\nbuf_size);", "if (VAR_0->throttled) {", "VAR_0->iov_idx = VAR_3;", "if (ret > 0) {", "VAR_0->iov_offset += ret;", "}", "break;", "}", "VAR_0->iov_offset = 0;", "}", "if (VAR_0->throttled) {", "break;", "}", "virtqueue_push(VAR_1, &VAR_0->elem, 0);", "VAR_0->elem.out_num = 0;", "}", "virtio_notify(VAR_2, VAR_1);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ], [ 17 ], [ 21 ], [ 23 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55, 57, 59, 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ] ]
12,537
static void l2cap_command(struct l2cap_instance_s *l2cap, int code, int id, const uint8_t *params, int len) { int err; #if 0 /* TODO: do the IDs really have to be in sequence? */ if (!id || (id != l2cap->last_id && id != l2cap->next_id)) { fprintf(stderr, "%s: out of sequence command packet ignored.\n", __func__); return; } #else l2cap->next_id = id; #endif if (id == l2cap->next_id) { l2cap->last_id = l2cap->next_id; l2cap->next_id = l2cap->next_id == 255 ? 1 : l2cap->next_id + 1; } else { /* TODO: Need to re-send the same response, without re-executing * the corresponding command! */ } switch (code) { case L2CAP_COMMAND_REJ: if (unlikely(len != 2 && len != 4 && len != 6)) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } /* We never issue commands other than Command Reject currently. */ fprintf(stderr, "%s: stray Command Reject (%02x, %04x) " "packet, ignoring.\n", __func__, id, le16_to_cpu(((l2cap_cmd_rej *) params)->reason)); break; case L2CAP_CONN_REQ: if (unlikely(len != L2CAP_CONN_REQ_SIZE)) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } l2cap_channel_open_req_msg(l2cap, le16_to_cpu(((l2cap_conn_req *) params)->psm), le16_to_cpu(((l2cap_conn_req *) params)->scid)); break; case L2CAP_CONN_RSP: if (unlikely(len != L2CAP_CONN_RSP_SIZE)) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } /* We never issue Connection Requests currently. TODO */ fprintf(stderr, "%s: unexpected Connection Response (%02x) " "packet, ignoring.\n", __func__, id); break; case L2CAP_CONF_REQ: if (unlikely(len < L2CAP_CONF_REQ_SIZE(0))) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } l2cap_channel_config_req_msg(l2cap, le16_to_cpu(((l2cap_conf_req *) params)->flags) & 1, le16_to_cpu(((l2cap_conf_req *) params)->dcid), ((l2cap_conf_req *) params)->data, len - L2CAP_CONF_REQ_SIZE(0)); break; case L2CAP_CONF_RSP: if (unlikely(len < L2CAP_CONF_RSP_SIZE(0))) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } if (l2cap_channel_config_rsp_msg(l2cap, le16_to_cpu(((l2cap_conf_rsp *) params)->result), le16_to_cpu(((l2cap_conf_rsp *) params)->flags) & 1, le16_to_cpu(((l2cap_conf_rsp *) params)->scid), ((l2cap_conf_rsp *) params)->data, len - L2CAP_CONF_RSP_SIZE(0))) fprintf(stderr, "%s: unexpected Configure Response (%02x) " "packet, ignoring.\n", __func__, id); break; case L2CAP_DISCONN_REQ: if (unlikely(len != L2CAP_DISCONN_REQ_SIZE)) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } l2cap_channel_close(l2cap, le16_to_cpu(((l2cap_disconn_req *) params)->dcid), le16_to_cpu(((l2cap_disconn_req *) params)->scid)); break; case L2CAP_DISCONN_RSP: if (unlikely(len != L2CAP_DISCONN_RSP_SIZE)) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } /* We never issue Disconnection Requests currently. TODO */ fprintf(stderr, "%s: unexpected Disconnection Response (%02x) " "packet, ignoring.\n", __func__, id); break; case L2CAP_ECHO_REQ: l2cap_echo_response(l2cap, params, len); break; case L2CAP_ECHO_RSP: /* We never issue Echo Requests currently. TODO */ fprintf(stderr, "%s: unexpected Echo Response (%02x) " "packet, ignoring.\n", __func__, id); break; case L2CAP_INFO_REQ: if (unlikely(len != L2CAP_INFO_REQ_SIZE)) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } l2cap_info(l2cap, le16_to_cpu(((l2cap_info_req *) params)->type)); break; case L2CAP_INFO_RSP: if (unlikely(len != L2CAP_INFO_RSP_SIZE)) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } /* We never issue Information Requests currently. TODO */ fprintf(stderr, "%s: unexpected Information Response (%02x) " "packet, ignoring.\n", __func__, id); break; default: err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; reject: l2cap_command_reject(l2cap, id, err, 0, 0); break; } }
false
qemu
bf937a7965c1d1a6dce4f615d0ead2e2ab505004
static void l2cap_command(struct l2cap_instance_s *l2cap, int code, int id, const uint8_t *params, int len) { int err; #if 0 if (!id || (id != l2cap->last_id && id != l2cap->next_id)) { fprintf(stderr, "%s: out of sequence command packet ignored.\n", __func__); return; } #else l2cap->next_id = id; #endif if (id == l2cap->next_id) { l2cap->last_id = l2cap->next_id; l2cap->next_id = l2cap->next_id == 255 ? 1 : l2cap->next_id + 1; } else { } switch (code) { case L2CAP_COMMAND_REJ: if (unlikely(len != 2 && len != 4 && len != 6)) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } fprintf(stderr, "%s: stray Command Reject (%02x, %04x) " "packet, ignoring.\n", __func__, id, le16_to_cpu(((l2cap_cmd_rej *) params)->reason)); break; case L2CAP_CONN_REQ: if (unlikely(len != L2CAP_CONN_REQ_SIZE)) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } l2cap_channel_open_req_msg(l2cap, le16_to_cpu(((l2cap_conn_req *) params)->psm), le16_to_cpu(((l2cap_conn_req *) params)->scid)); break; case L2CAP_CONN_RSP: if (unlikely(len != L2CAP_CONN_RSP_SIZE)) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } fprintf(stderr, "%s: unexpected Connection Response (%02x) " "packet, ignoring.\n", __func__, id); break; case L2CAP_CONF_REQ: if (unlikely(len < L2CAP_CONF_REQ_SIZE(0))) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } l2cap_channel_config_req_msg(l2cap, le16_to_cpu(((l2cap_conf_req *) params)->flags) & 1, le16_to_cpu(((l2cap_conf_req *) params)->dcid), ((l2cap_conf_req *) params)->data, len - L2CAP_CONF_REQ_SIZE(0)); break; case L2CAP_CONF_RSP: if (unlikely(len < L2CAP_CONF_RSP_SIZE(0))) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } if (l2cap_channel_config_rsp_msg(l2cap, le16_to_cpu(((l2cap_conf_rsp *) params)->result), le16_to_cpu(((l2cap_conf_rsp *) params)->flags) & 1, le16_to_cpu(((l2cap_conf_rsp *) params)->scid), ((l2cap_conf_rsp *) params)->data, len - L2CAP_CONF_RSP_SIZE(0))) fprintf(stderr, "%s: unexpected Configure Response (%02x) " "packet, ignoring.\n", __func__, id); break; case L2CAP_DISCONN_REQ: if (unlikely(len != L2CAP_DISCONN_REQ_SIZE)) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } l2cap_channel_close(l2cap, le16_to_cpu(((l2cap_disconn_req *) params)->dcid), le16_to_cpu(((l2cap_disconn_req *) params)->scid)); break; case L2CAP_DISCONN_RSP: if (unlikely(len != L2CAP_DISCONN_RSP_SIZE)) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } fprintf(stderr, "%s: unexpected Disconnection Response (%02x) " "packet, ignoring.\n", __func__, id); break; case L2CAP_ECHO_REQ: l2cap_echo_response(l2cap, params, len); break; case L2CAP_ECHO_RSP: fprintf(stderr, "%s: unexpected Echo Response (%02x) " "packet, ignoring.\n", __func__, id); break; case L2CAP_INFO_REQ: if (unlikely(len != L2CAP_INFO_REQ_SIZE)) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } l2cap_info(l2cap, le16_to_cpu(((l2cap_info_req *) params)->type)); break; case L2CAP_INFO_RSP: if (unlikely(len != L2CAP_INFO_RSP_SIZE)) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } fprintf(stderr, "%s: unexpected Information Response (%02x) " "packet, ignoring.\n", __func__, id); break; default: err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; reject: l2cap_command_reject(l2cap, id, err, 0, 0); break; } }
{ "code": [], "line_no": [] }
static void FUNC_0(struct l2cap_instance_s *VAR_0, int VAR_1, int VAR_2, const uint8_t *VAR_3, int VAR_4) { int VAR_5; #if 0 if (!VAR_2 || (VAR_2 != VAR_0->last_id && VAR_2 != VAR_0->next_id)) { fprintf(stderr, "%s: out of sequence command packet ignored.\n", __func__); return; } #else VAR_0->next_id = VAR_2; #endif if (VAR_2 == VAR_0->next_id) { VAR_0->last_id = VAR_0->next_id; VAR_0->next_id = VAR_0->next_id == 255 ? 1 : VAR_0->next_id + 1; } else { } switch (VAR_1) { case L2CAP_COMMAND_REJ: if (unlikely(VAR_4 != 2 && VAR_4 != 4 && VAR_4 != 6)) { VAR_5 = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } fprintf(stderr, "%s: stray Command Reject (%02x, %04x) " "packet, ignoring.\n", __func__, VAR_2, le16_to_cpu(((l2cap_cmd_rej *) VAR_3)->reason)); break; case L2CAP_CONN_REQ: if (unlikely(VAR_4 != L2CAP_CONN_REQ_SIZE)) { VAR_5 = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } l2cap_channel_open_req_msg(VAR_0, le16_to_cpu(((l2cap_conn_req *) VAR_3)->psm), le16_to_cpu(((l2cap_conn_req *) VAR_3)->scid)); break; case L2CAP_CONN_RSP: if (unlikely(VAR_4 != L2CAP_CONN_RSP_SIZE)) { VAR_5 = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } fprintf(stderr, "%s: unexpected Connection Response (%02x) " "packet, ignoring.\n", __func__, VAR_2); break; case L2CAP_CONF_REQ: if (unlikely(VAR_4 < L2CAP_CONF_REQ_SIZE(0))) { VAR_5 = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } l2cap_channel_config_req_msg(VAR_0, le16_to_cpu(((l2cap_conf_req *) VAR_3)->flags) & 1, le16_to_cpu(((l2cap_conf_req *) VAR_3)->dcid), ((l2cap_conf_req *) VAR_3)->data, VAR_4 - L2CAP_CONF_REQ_SIZE(0)); break; case L2CAP_CONF_RSP: if (unlikely(VAR_4 < L2CAP_CONF_RSP_SIZE(0))) { VAR_5 = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } if (l2cap_channel_config_rsp_msg(VAR_0, le16_to_cpu(((l2cap_conf_rsp *) VAR_3)->result), le16_to_cpu(((l2cap_conf_rsp *) VAR_3)->flags) & 1, le16_to_cpu(((l2cap_conf_rsp *) VAR_3)->scid), ((l2cap_conf_rsp *) VAR_3)->data, VAR_4 - L2CAP_CONF_RSP_SIZE(0))) fprintf(stderr, "%s: unexpected Configure Response (%02x) " "packet, ignoring.\n", __func__, VAR_2); break; case L2CAP_DISCONN_REQ: if (unlikely(VAR_4 != L2CAP_DISCONN_REQ_SIZE)) { VAR_5 = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } l2cap_channel_close(VAR_0, le16_to_cpu(((l2cap_disconn_req *) VAR_3)->dcid), le16_to_cpu(((l2cap_disconn_req *) VAR_3)->scid)); break; case L2CAP_DISCONN_RSP: if (unlikely(VAR_4 != L2CAP_DISCONN_RSP_SIZE)) { VAR_5 = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } fprintf(stderr, "%s: unexpected Disconnection Response (%02x) " "packet, ignoring.\n", __func__, VAR_2); break; case L2CAP_ECHO_REQ: l2cap_echo_response(VAR_0, VAR_3, VAR_4); break; case L2CAP_ECHO_RSP: fprintf(stderr, "%s: unexpected Echo Response (%02x) " "packet, ignoring.\n", __func__, VAR_2); break; case L2CAP_INFO_REQ: if (unlikely(VAR_4 != L2CAP_INFO_REQ_SIZE)) { VAR_5 = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } l2cap_info(VAR_0, le16_to_cpu(((l2cap_info_req *) VAR_3)->type)); break; case L2CAP_INFO_RSP: if (unlikely(VAR_4 != L2CAP_INFO_RSP_SIZE)) { VAR_5 = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } fprintf(stderr, "%s: unexpected Information Response (%02x) " "packet, ignoring.\n", __func__, VAR_2); break; default: VAR_5 = L2CAP_REJ_CMD_NOT_UNDERSTOOD; reject: l2cap_command_reject(VAR_0, VAR_2, VAR_5, 0, 0); break; } }
[ "static void FUNC_0(struct l2cap_instance_s *VAR_0, int VAR_1, int VAR_2,\nconst uint8_t *VAR_3, int VAR_4)\n{", "int VAR_5;", "#if 0\nif (!VAR_2 || (VAR_2 != VAR_0->last_id && VAR_2 != VAR_0->next_id)) {", "fprintf(stderr, \"%s: out of sequence command packet ignored.\\n\",\n__func__);", "return;", "}", "#else\nVAR_0->next_id = VAR_2;", "#endif\nif (VAR_2 == VAR_0->next_id) {", "VAR_0->last_id = VAR_0->next_id;", "VAR_0->next_id = VAR_0->next_id == 255 ? 1 : VAR_0->next_id + 1;", "} else {", "}", "switch (VAR_1) {", "case L2CAP_COMMAND_REJ:\nif (unlikely(VAR_4 != 2 && VAR_4 != 4 && VAR_4 != 6)) {", "VAR_5 = L2CAP_REJ_CMD_NOT_UNDERSTOOD;", "goto reject;", "}", "fprintf(stderr, \"%s: stray Command Reject (%02x, %04x) \"\n\"packet, ignoring.\\n\", __func__, VAR_2,\nle16_to_cpu(((l2cap_cmd_rej *) VAR_3)->reason));", "break;", "case L2CAP_CONN_REQ:\nif (unlikely(VAR_4 != L2CAP_CONN_REQ_SIZE)) {", "VAR_5 = L2CAP_REJ_CMD_NOT_UNDERSTOOD;", "goto reject;", "}", "l2cap_channel_open_req_msg(VAR_0,\nle16_to_cpu(((l2cap_conn_req *) VAR_3)->psm),\nle16_to_cpu(((l2cap_conn_req *) VAR_3)->scid));", "break;", "case L2CAP_CONN_RSP:\nif (unlikely(VAR_4 != L2CAP_CONN_RSP_SIZE)) {", "VAR_5 = L2CAP_REJ_CMD_NOT_UNDERSTOOD;", "goto reject;", "}", "fprintf(stderr, \"%s: unexpected Connection Response (%02x) \"\n\"packet, ignoring.\\n\", __func__, VAR_2);", "break;", "case L2CAP_CONF_REQ:\nif (unlikely(VAR_4 < L2CAP_CONF_REQ_SIZE(0))) {", "VAR_5 = L2CAP_REJ_CMD_NOT_UNDERSTOOD;", "goto reject;", "}", "l2cap_channel_config_req_msg(VAR_0,\nle16_to_cpu(((l2cap_conf_req *) VAR_3)->flags) & 1,\nle16_to_cpu(((l2cap_conf_req *) VAR_3)->dcid),\n((l2cap_conf_req *) VAR_3)->data,\nVAR_4 - L2CAP_CONF_REQ_SIZE(0));", "break;", "case L2CAP_CONF_RSP:\nif (unlikely(VAR_4 < L2CAP_CONF_RSP_SIZE(0))) {", "VAR_5 = L2CAP_REJ_CMD_NOT_UNDERSTOOD;", "goto reject;", "}", "if (l2cap_channel_config_rsp_msg(VAR_0,\nle16_to_cpu(((l2cap_conf_rsp *) VAR_3)->result),\nle16_to_cpu(((l2cap_conf_rsp *) VAR_3)->flags) & 1,\nle16_to_cpu(((l2cap_conf_rsp *) VAR_3)->scid),\n((l2cap_conf_rsp *) VAR_3)->data,\nVAR_4 - L2CAP_CONF_RSP_SIZE(0)))\nfprintf(stderr, \"%s: unexpected Configure Response (%02x) \"\n\"packet, ignoring.\\n\", __func__, VAR_2);", "break;", "case L2CAP_DISCONN_REQ:\nif (unlikely(VAR_4 != L2CAP_DISCONN_REQ_SIZE)) {", "VAR_5 = L2CAP_REJ_CMD_NOT_UNDERSTOOD;", "goto reject;", "}", "l2cap_channel_close(VAR_0,\nle16_to_cpu(((l2cap_disconn_req *) VAR_3)->dcid),\nle16_to_cpu(((l2cap_disconn_req *) VAR_3)->scid));", "break;", "case L2CAP_DISCONN_RSP:\nif (unlikely(VAR_4 != L2CAP_DISCONN_RSP_SIZE)) {", "VAR_5 = L2CAP_REJ_CMD_NOT_UNDERSTOOD;", "goto reject;", "}", "fprintf(stderr, \"%s: unexpected Disconnection Response (%02x) \"\n\"packet, ignoring.\\n\", __func__, VAR_2);", "break;", "case L2CAP_ECHO_REQ:\nl2cap_echo_response(VAR_0, VAR_3, VAR_4);", "break;", "case L2CAP_ECHO_RSP:\nfprintf(stderr, \"%s: unexpected Echo Response (%02x) \"\n\"packet, ignoring.\\n\", __func__, VAR_2);", "break;", "case L2CAP_INFO_REQ:\nif (unlikely(VAR_4 != L2CAP_INFO_REQ_SIZE)) {", "VAR_5 = L2CAP_REJ_CMD_NOT_UNDERSTOOD;", "goto reject;", "}", "l2cap_info(VAR_0, le16_to_cpu(((l2cap_info_req *) VAR_3)->type));", "break;", "case L2CAP_INFO_RSP:\nif (unlikely(VAR_4 != L2CAP_INFO_RSP_SIZE)) {", "VAR_5 = L2CAP_REJ_CMD_NOT_UNDERSTOOD;", "goto reject;", "}", "fprintf(stderr, \"%s: unexpected Information Response (%02x) \"\n\"packet, ignoring.\\n\", __func__, VAR_2);", "break;", "default:\nVAR_5 = L2CAP_REJ_CMD_NOT_UNDERSTOOD;", "reject:\nl2cap_command_reject(VAR_0, VAR_2, VAR_5, 0, 0);", "break;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11, 15 ], [ 17, 19 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 29, 31 ], [ 33 ], [ 35 ], [ 37 ], [ 43 ], [ 47 ], [ 49, 51 ], [ 53 ], [ 55 ], [ 57 ], [ 63, 65, 67 ], [ 69 ], [ 73, 75 ], [ 77 ], [ 79 ], [ 81 ], [ 85, 87, 89 ], [ 91 ], [ 95, 97 ], [ 99 ], [ 101 ], [ 103 ], [ 109, 111 ], [ 113 ], [ 117, 119 ], [ 121 ], [ 123 ], [ 125 ], [ 129, 131, 133, 135, 137 ], [ 139 ], [ 143, 145 ], [ 147 ], [ 149 ], [ 151 ], [ 155, 157, 159, 161, 163, 165, 167, 169 ], [ 171 ], [ 175, 177 ], [ 179 ], [ 181 ], [ 183 ], [ 187, 189, 191 ], [ 193 ], [ 197, 199 ], [ 201 ], [ 203 ], [ 205 ], [ 211, 213 ], [ 215 ], [ 219, 221 ], [ 223 ], [ 227, 231, 233 ], [ 235 ], [ 239, 241 ], [ 243 ], [ 245 ], [ 247 ], [ 251 ], [ 253 ], [ 257, 259 ], [ 261 ], [ 263 ], [ 265 ], [ 271, 273 ], [ 275 ], [ 279, 281 ], [ 283, 285 ], [ 287 ], [ 289 ], [ 291 ] ]
12,538
static int curl_aio_flush(void *opaque) { BDRVCURLState *s = opaque; int i, j; for (i=0; i < CURL_NUM_STATES; i++) { for(j=0; j < CURL_NUM_ACB; j++) { if (s->states[i].acb[j]) { return 1; } } } return 0; }
false
qemu
0d1460226fb05c92fa3ad869ca39090ff13cf6bc
static int curl_aio_flush(void *opaque) { BDRVCURLState *s = opaque; int i, j; for (i=0; i < CURL_NUM_STATES; i++) { for(j=0; j < CURL_NUM_ACB; j++) { if (s->states[i].acb[j]) { return 1; } } } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(void *VAR_0) { BDRVCURLState *s = VAR_0; int VAR_1, VAR_2; for (VAR_1=0; VAR_1 < CURL_NUM_STATES; VAR_1++) { for(VAR_2=0; VAR_2 < CURL_NUM_ACB; VAR_2++) { if (s->states[VAR_1].acb[VAR_2]) { return 1; } } } return 0; }
[ "static int FUNC_0(void *VAR_0)\n{", "BDRVCURLState *s = VAR_0;", "int VAR_1, VAR_2;", "for (VAR_1=0; VAR_1 < CURL_NUM_STATES; VAR_1++) {", "for(VAR_2=0; VAR_2 < CURL_NUM_ACB; VAR_2++) {", "if (s->states[VAR_1].acb[VAR_2]) {", "return 1;", "}", "}", "}", "return 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 ] ]
12,539
static void test_dynamic_globalprop_subprocess(void) { MyType *mt; static GlobalProperty props[] = { { TYPE_DYNAMIC_PROPS, "prop1", "101", true }, { TYPE_DYNAMIC_PROPS, "prop2", "102", true }, { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103", true }, /* .not_used=false to emulate what qdev_add_one_global() does: */ { TYPE_UNUSED_HOTPLUG, "prop4", "104", false }, { TYPE_UNUSED_NOHOTPLUG, "prop5", "105", true }, { TYPE_NONDEVICE, "prop6", "106", true }, {} }; int all_used; qdev_prop_register_global_list(props); mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS)); qdev_init_nofail(DEVICE(mt)); g_assert_cmpuint(mt->prop1, ==, 101); g_assert_cmpuint(mt->prop2, ==, 102); all_used = qdev_prop_check_globals(); g_assert_cmpuint(all_used, ==, 1); g_assert(!props[0].not_used); g_assert(!props[1].not_used); g_assert(props[2].not_used); g_assert(!props[3].not_used); g_assert(props[4].not_used); g_assert(props[5].not_used); }
false
qemu
b3ce84fea466f3bca2ff85d158744f00c0f429bd
static void test_dynamic_globalprop_subprocess(void) { MyType *mt; static GlobalProperty props[] = { { TYPE_DYNAMIC_PROPS, "prop1", "101", true }, { TYPE_DYNAMIC_PROPS, "prop2", "102", true }, { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103", true }, { TYPE_UNUSED_HOTPLUG, "prop4", "104", false }, { TYPE_UNUSED_NOHOTPLUG, "prop5", "105", true }, { TYPE_NONDEVICE, "prop6", "106", true }, {} }; int all_used; qdev_prop_register_global_list(props); mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS)); qdev_init_nofail(DEVICE(mt)); g_assert_cmpuint(mt->prop1, ==, 101); g_assert_cmpuint(mt->prop2, ==, 102); all_used = qdev_prop_check_globals(); g_assert_cmpuint(all_used, ==, 1); g_assert(!props[0].not_used); g_assert(!props[1].not_used); g_assert(props[2].not_used); g_assert(!props[3].not_used); g_assert(props[4].not_used); g_assert(props[5].not_used); }
{ "code": [], "line_no": [] }
static void FUNC_0(void) { MyType *mt; static GlobalProperty VAR_0[] = { { TYPE_DYNAMIC_PROPS, "prop1", "101", true }, { TYPE_DYNAMIC_PROPS, "prop2", "102", true }, { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103", true }, { TYPE_UNUSED_HOTPLUG, "prop4", "104", false }, { TYPE_UNUSED_NOHOTPLUG, "prop5", "105", true }, { TYPE_NONDEVICE, "prop6", "106", true }, {} }; int VAR_1; qdev_prop_register_global_list(VAR_0); mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS)); qdev_init_nofail(DEVICE(mt)); g_assert_cmpuint(mt->prop1, ==, 101); g_assert_cmpuint(mt->prop2, ==, 102); VAR_1 = qdev_prop_check_globals(); g_assert_cmpuint(VAR_1, ==, 1); g_assert(!VAR_0[0].not_used); g_assert(!VAR_0[1].not_used); g_assert(VAR_0[2].not_used); g_assert(!VAR_0[3].not_used); g_assert(VAR_0[4].not_used); g_assert(VAR_0[5].not_used); }
[ "static void FUNC_0(void)\n{", "MyType *mt;", "static GlobalProperty VAR_0[] = {", "{ TYPE_DYNAMIC_PROPS, \"prop1\", \"101\", true },", "{ TYPE_DYNAMIC_PROPS, \"prop2\", \"102\", true },", "{ TYPE_DYNAMIC_PROPS\"-bad\", \"prop3\", \"103\", true },", "{ TYPE_UNUSED_HOTPLUG, \"prop4\", \"104\", false },", "{ TYPE_UNUSED_NOHOTPLUG, \"prop5\", \"105\", true },", "{ TYPE_NONDEVICE, \"prop6\", \"106\", true },", "{}", "};", "int VAR_1;", "qdev_prop_register_global_list(VAR_0);", "mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));", "qdev_init_nofail(DEVICE(mt));", "g_assert_cmpuint(mt->prop1, ==, 101);", "g_assert_cmpuint(mt->prop2, ==, 102);", "VAR_1 = qdev_prop_check_globals();", "g_assert_cmpuint(VAR_1, ==, 1);", "g_assert(!VAR_0[0].not_used);", "g_assert(!VAR_0[1].not_used);", "g_assert(VAR_0[2].not_used);", "g_assert(!VAR_0[3].not_used);", "g_assert(VAR_0[4].not_used);", "g_assert(VAR_0[5].not_used);", "}" ]
[ 0, 0, 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 ], [ 31 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ] ]
12,540
void bdrv_aio_cancel(BlockDriverAIOCB *acb) { if (acb->cb == bdrv_aio_rw_vector_cb) { VectorTranslationState *s = acb->opaque; acb = s->aiocb; } acb->pool->cancel(acb); }
false
qemu
c07a9008ac6985cd5a15909c2b9977d982defc12
void bdrv_aio_cancel(BlockDriverAIOCB *acb) { if (acb->cb == bdrv_aio_rw_vector_cb) { VectorTranslationState *s = acb->opaque; acb = s->aiocb; } acb->pool->cancel(acb); }
{ "code": [], "line_no": [] }
void FUNC_0(BlockDriverAIOCB *VAR_0) { if (VAR_0->cb == bdrv_aio_rw_vector_cb) { VectorTranslationState *s = VAR_0->opaque; VAR_0 = s->aiocb; } VAR_0->pool->cancel(VAR_0); }
[ "void FUNC_0(BlockDriverAIOCB *VAR_0)\n{", "if (VAR_0->cb == bdrv_aio_rw_vector_cb) {", "VectorTranslationState *s = VAR_0->opaque;", "VAR_0 = s->aiocb;", "}", "VAR_0->pool->cancel(VAR_0);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ] ]
12,541
static void omap_mcbsp_writeh(void *opaque, hwaddr addr, uint32_t value) { struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque; int offset = addr & OMAP_MPUI_REG_MASK; switch (offset) { case 0x00: /* DRR2 */ case 0x02: /* DRR1 */ OMAP_RO_REG(addr); return; case 0x04: /* DXR2 */ if (((s->xcr[0] >> 5) & 7) < 3) /* XWDLEN1 */ return; /* Fall through. */ case 0x06: /* DXR1 */ if (s->tx_req > 1) { s->tx_req -= 2; if (s->codec && s->codec->cts) { s->codec->out.fifo[s->codec->out.len ++] = (value >> 8) & 0xff; s->codec->out.fifo[s->codec->out.len ++] = (value >> 0) & 0xff; } if (s->tx_req < 2) omap_mcbsp_tx_done(s); } else printf("%s: Tx FIFO overrun\n", __FUNCTION__); return; case 0x08: /* SPCR2 */ s->spcr[1] &= 0x0002; s->spcr[1] |= 0x03f9 & value; s->spcr[1] |= 0x0004 & (value << 2); /* XEMPTY := XRST */ if (~value & 1) /* XRST */ s->spcr[1] &= ~6; omap_mcbsp_req_update(s); return; case 0x0a: /* SPCR1 */ s->spcr[0] &= 0x0006; s->spcr[0] |= 0xf8f9 & value; if (value & (1 << 15)) /* DLB */ printf("%s: Digital Loopback mode enable attempt\n", __FUNCTION__); if (~value & 1) { /* RRST */ s->spcr[0] &= ~6; s->rx_req = 0; omap_mcbsp_rx_done(s); } omap_mcbsp_req_update(s); return; case 0x0c: /* RCR2 */ s->rcr[1] = value & 0xffff; return; case 0x0e: /* RCR1 */ s->rcr[0] = value & 0x7fe0; return; case 0x10: /* XCR2 */ s->xcr[1] = value & 0xffff; return; case 0x12: /* XCR1 */ s->xcr[0] = value & 0x7fe0; return; case 0x14: /* SRGR2 */ s->srgr[1] = value & 0xffff; omap_mcbsp_req_update(s); return; case 0x16: /* SRGR1 */ s->srgr[0] = value & 0xffff; omap_mcbsp_req_update(s); return; case 0x18: /* MCR2 */ s->mcr[1] = value & 0x03e3; if (value & 3) /* XMCM */ printf("%s: Tx channel selection mode enable attempt\n", __FUNCTION__); return; case 0x1a: /* MCR1 */ s->mcr[0] = value & 0x03e1; if (value & 1) /* RMCM */ printf("%s: Rx channel selection mode enable attempt\n", __FUNCTION__); return; case 0x1c: /* RCERA */ s->rcer[0] = value & 0xffff; return; case 0x1e: /* RCERB */ s->rcer[1] = value & 0xffff; return; case 0x20: /* XCERA */ s->xcer[0] = value & 0xffff; return; case 0x22: /* XCERB */ s->xcer[1] = value & 0xffff; return; case 0x24: /* PCR0 */ s->pcr = value & 0x7faf; return; case 0x26: /* RCERC */ s->rcer[2] = value & 0xffff; return; case 0x28: /* RCERD */ s->rcer[3] = value & 0xffff; return; case 0x2a: /* XCERC */ s->xcer[2] = value & 0xffff; return; case 0x2c: /* XCERD */ s->xcer[3] = value & 0xffff; return; case 0x2e: /* RCERE */ s->rcer[4] = value & 0xffff; return; case 0x30: /* RCERF */ s->rcer[5] = value & 0xffff; return; case 0x32: /* XCERE */ s->xcer[4] = value & 0xffff; return; case 0x34: /* XCERF */ s->xcer[5] = value & 0xffff; return; case 0x36: /* RCERG */ s->rcer[6] = value & 0xffff; return; case 0x38: /* RCERH */ s->rcer[7] = value & 0xffff; return; case 0x3a: /* XCERG */ s->xcer[6] = value & 0xffff; return; case 0x3c: /* XCERH */ s->xcer[7] = value & 0xffff; return; } OMAP_BAD_REG(addr); }
false
qemu
a89f364ae8740dfc31b321eed9ee454e996dc3c1
static void omap_mcbsp_writeh(void *opaque, hwaddr addr, uint32_t value) { struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque; int offset = addr & OMAP_MPUI_REG_MASK; switch (offset) { case 0x00: case 0x02: OMAP_RO_REG(addr); return; case 0x04: if (((s->xcr[0] >> 5) & 7) < 3) return; case 0x06: if (s->tx_req > 1) { s->tx_req -= 2; if (s->codec && s->codec->cts) { s->codec->out.fifo[s->codec->out.len ++] = (value >> 8) & 0xff; s->codec->out.fifo[s->codec->out.len ++] = (value >> 0) & 0xff; } if (s->tx_req < 2) omap_mcbsp_tx_done(s); } else printf("%s: Tx FIFO overrun\n", __FUNCTION__); return; case 0x08: s->spcr[1] &= 0x0002; s->spcr[1] |= 0x03f9 & value; s->spcr[1] |= 0x0004 & (value << 2); if (~value & 1) s->spcr[1] &= ~6; omap_mcbsp_req_update(s); return; case 0x0a: s->spcr[0] &= 0x0006; s->spcr[0] |= 0xf8f9 & value; if (value & (1 << 15)) printf("%s: Digital Loopback mode enable attempt\n", __FUNCTION__); if (~value & 1) { s->spcr[0] &= ~6; s->rx_req = 0; omap_mcbsp_rx_done(s); } omap_mcbsp_req_update(s); return; case 0x0c: s->rcr[1] = value & 0xffff; return; case 0x0e: s->rcr[0] = value & 0x7fe0; return; case 0x10: s->xcr[1] = value & 0xffff; return; case 0x12: s->xcr[0] = value & 0x7fe0; return; case 0x14: s->srgr[1] = value & 0xffff; omap_mcbsp_req_update(s); return; case 0x16: s->srgr[0] = value & 0xffff; omap_mcbsp_req_update(s); return; case 0x18: s->mcr[1] = value & 0x03e3; if (value & 3) printf("%s: Tx channel selection mode enable attempt\n", __FUNCTION__); return; case 0x1a: s->mcr[0] = value & 0x03e1; if (value & 1) printf("%s: Rx channel selection mode enable attempt\n", __FUNCTION__); return; case 0x1c: s->rcer[0] = value & 0xffff; return; case 0x1e: s->rcer[1] = value & 0xffff; return; case 0x20: s->xcer[0] = value & 0xffff; return; case 0x22: s->xcer[1] = value & 0xffff; return; case 0x24: s->pcr = value & 0x7faf; return; case 0x26: s->rcer[2] = value & 0xffff; return; case 0x28: s->rcer[3] = value & 0xffff; return; case 0x2a: s->xcer[2] = value & 0xffff; return; case 0x2c: s->xcer[3] = value & 0xffff; return; case 0x2e: s->rcer[4] = value & 0xffff; return; case 0x30: s->rcer[5] = value & 0xffff; return; case 0x32: s->xcer[4] = value & 0xffff; return; case 0x34: s->xcer[5] = value & 0xffff; return; case 0x36: s->rcer[6] = value & 0xffff; return; case 0x38: s->rcer[7] = value & 0xffff; return; case 0x3a: s->xcer[6] = value & 0xffff; return; case 0x3c: s->xcer[7] = value & 0xffff; return; } OMAP_BAD_REG(addr); }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0, hwaddr VAR_1, uint32_t VAR_2) { struct omap_mcbsp_s *VAR_3 = (struct omap_mcbsp_s *) VAR_0; int VAR_4 = VAR_1 & OMAP_MPUI_REG_MASK; switch (VAR_4) { case 0x00: case 0x02: OMAP_RO_REG(VAR_1); return; case 0x04: if (((VAR_3->xcr[0] >> 5) & 7) < 3) return; case 0x06: if (VAR_3->tx_req > 1) { VAR_3->tx_req -= 2; if (VAR_3->codec && VAR_3->codec->cts) { VAR_3->codec->out.fifo[VAR_3->codec->out.len ++] = (VAR_2 >> 8) & 0xff; VAR_3->codec->out.fifo[VAR_3->codec->out.len ++] = (VAR_2 >> 0) & 0xff; } if (VAR_3->tx_req < 2) omap_mcbsp_tx_done(VAR_3); } else printf("%VAR_3: Tx FIFO overrun\n", __FUNCTION__); return; case 0x08: VAR_3->spcr[1] &= 0x0002; VAR_3->spcr[1] |= 0x03f9 & VAR_2; VAR_3->spcr[1] |= 0x0004 & (VAR_2 << 2); if (~VAR_2 & 1) VAR_3->spcr[1] &= ~6; omap_mcbsp_req_update(VAR_3); return; case 0x0a: VAR_3->spcr[0] &= 0x0006; VAR_3->spcr[0] |= 0xf8f9 & VAR_2; if (VAR_2 & (1 << 15)) printf("%VAR_3: Digital Loopback mode enable attempt\n", __FUNCTION__); if (~VAR_2 & 1) { VAR_3->spcr[0] &= ~6; VAR_3->rx_req = 0; omap_mcbsp_rx_done(VAR_3); } omap_mcbsp_req_update(VAR_3); return; case 0x0c: VAR_3->rcr[1] = VAR_2 & 0xffff; return; case 0x0e: VAR_3->rcr[0] = VAR_2 & 0x7fe0; return; case 0x10: VAR_3->xcr[1] = VAR_2 & 0xffff; return; case 0x12: VAR_3->xcr[0] = VAR_2 & 0x7fe0; return; case 0x14: VAR_3->srgr[1] = VAR_2 & 0xffff; omap_mcbsp_req_update(VAR_3); return; case 0x16: VAR_3->srgr[0] = VAR_2 & 0xffff; omap_mcbsp_req_update(VAR_3); return; case 0x18: VAR_3->mcr[1] = VAR_2 & 0x03e3; if (VAR_2 & 3) printf("%VAR_3: Tx channel selection mode enable attempt\n", __FUNCTION__); return; case 0x1a: VAR_3->mcr[0] = VAR_2 & 0x03e1; if (VAR_2 & 1) printf("%VAR_3: Rx channel selection mode enable attempt\n", __FUNCTION__); return; case 0x1c: VAR_3->rcer[0] = VAR_2 & 0xffff; return; case 0x1e: VAR_3->rcer[1] = VAR_2 & 0xffff; return; case 0x20: VAR_3->xcer[0] = VAR_2 & 0xffff; return; case 0x22: VAR_3->xcer[1] = VAR_2 & 0xffff; return; case 0x24: VAR_3->pcr = VAR_2 & 0x7faf; return; case 0x26: VAR_3->rcer[2] = VAR_2 & 0xffff; return; case 0x28: VAR_3->rcer[3] = VAR_2 & 0xffff; return; case 0x2a: VAR_3->xcer[2] = VAR_2 & 0xffff; return; case 0x2c: VAR_3->xcer[3] = VAR_2 & 0xffff; return; case 0x2e: VAR_3->rcer[4] = VAR_2 & 0xffff; return; case 0x30: VAR_3->rcer[5] = VAR_2 & 0xffff; return; case 0x32: VAR_3->xcer[4] = VAR_2 & 0xffff; return; case 0x34: VAR_3->xcer[5] = VAR_2 & 0xffff; return; case 0x36: VAR_3->rcer[6] = VAR_2 & 0xffff; return; case 0x38: VAR_3->rcer[7] = VAR_2 & 0xffff; return; case 0x3a: VAR_3->xcer[6] = VAR_2 & 0xffff; return; case 0x3c: VAR_3->xcer[7] = VAR_2 & 0xffff; return; } OMAP_BAD_REG(VAR_1); }
[ "static void FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint32_t VAR_2)\n{", "struct omap_mcbsp_s *VAR_3 = (struct omap_mcbsp_s *) VAR_0;", "int VAR_4 = VAR_1 & OMAP_MPUI_REG_MASK;", "switch (VAR_4) {", "case 0x00:\ncase 0x02:\nOMAP_RO_REG(VAR_1);", "return;", "case 0x04:\nif (((VAR_3->xcr[0] >> 5) & 7) < 3)\nreturn;", "case 0x06:\nif (VAR_3->tx_req > 1) {", "VAR_3->tx_req -= 2;", "if (VAR_3->codec && VAR_3->codec->cts) {", "VAR_3->codec->out.fifo[VAR_3->codec->out.len ++] = (VAR_2 >> 8) & 0xff;", "VAR_3->codec->out.fifo[VAR_3->codec->out.len ++] = (VAR_2 >> 0) & 0xff;", "}", "if (VAR_3->tx_req < 2)\nomap_mcbsp_tx_done(VAR_3);", "} else", "printf(\"%VAR_3: Tx FIFO overrun\\n\", __FUNCTION__);", "return;", "case 0x08:\nVAR_3->spcr[1] &= 0x0002;", "VAR_3->spcr[1] |= 0x03f9 & VAR_2;", "VAR_3->spcr[1] |= 0x0004 & (VAR_2 << 2);", "if (~VAR_2 & 1)\nVAR_3->spcr[1] &= ~6;", "omap_mcbsp_req_update(VAR_3);", "return;", "case 0x0a:\nVAR_3->spcr[0] &= 0x0006;", "VAR_3->spcr[0] |= 0xf8f9 & VAR_2;", "if (VAR_2 & (1 << 15))\nprintf(\"%VAR_3: Digital Loopback mode enable attempt\\n\", __FUNCTION__);", "if (~VAR_2 & 1) {", "VAR_3->spcr[0] &= ~6;", "VAR_3->rx_req = 0;", "omap_mcbsp_rx_done(VAR_3);", "}", "omap_mcbsp_req_update(VAR_3);", "return;", "case 0x0c:\nVAR_3->rcr[1] = VAR_2 & 0xffff;", "return;", "case 0x0e:\nVAR_3->rcr[0] = VAR_2 & 0x7fe0;", "return;", "case 0x10:\nVAR_3->xcr[1] = VAR_2 & 0xffff;", "return;", "case 0x12:\nVAR_3->xcr[0] = VAR_2 & 0x7fe0;", "return;", "case 0x14:\nVAR_3->srgr[1] = VAR_2 & 0xffff;", "omap_mcbsp_req_update(VAR_3);", "return;", "case 0x16:\nVAR_3->srgr[0] = VAR_2 & 0xffff;", "omap_mcbsp_req_update(VAR_3);", "return;", "case 0x18:\nVAR_3->mcr[1] = VAR_2 & 0x03e3;", "if (VAR_2 & 3)\nprintf(\"%VAR_3: Tx channel selection mode enable attempt\\n\",\n__FUNCTION__);", "return;", "case 0x1a:\nVAR_3->mcr[0] = VAR_2 & 0x03e1;", "if (VAR_2 & 1)\nprintf(\"%VAR_3: Rx channel selection mode enable attempt\\n\",\n__FUNCTION__);", "return;", "case 0x1c:\nVAR_3->rcer[0] = VAR_2 & 0xffff;", "return;", "case 0x1e:\nVAR_3->rcer[1] = VAR_2 & 0xffff;", "return;", "case 0x20:\nVAR_3->xcer[0] = VAR_2 & 0xffff;", "return;", "case 0x22:\nVAR_3->xcer[1] = VAR_2 & 0xffff;", "return;", "case 0x24:\nVAR_3->pcr = VAR_2 & 0x7faf;", "return;", "case 0x26:\nVAR_3->rcer[2] = VAR_2 & 0xffff;", "return;", "case 0x28:\nVAR_3->rcer[3] = VAR_2 & 0xffff;", "return;", "case 0x2a:\nVAR_3->xcer[2] = VAR_2 & 0xffff;", "return;", "case 0x2c:\nVAR_3->xcer[3] = VAR_2 & 0xffff;", "return;", "case 0x2e:\nVAR_3->rcer[4] = VAR_2 & 0xffff;", "return;", "case 0x30:\nVAR_3->rcer[5] = VAR_2 & 0xffff;", "return;", "case 0x32:\nVAR_3->xcer[4] = VAR_2 & 0xffff;", "return;", "case 0x34:\nVAR_3->xcer[5] = VAR_2 & 0xffff;", "return;", "case 0x36:\nVAR_3->rcer[6] = VAR_2 & 0xffff;", "return;", "case 0x38:\nVAR_3->rcer[7] = VAR_2 & 0xffff;", "return;", "case 0x3a:\nVAR_3->xcer[6] = VAR_2 & 0xffff;", "return;", "case 0x3c:\nVAR_3->xcer[7] = VAR_2 & 0xffff;", "return;", "}", "OMAP_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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15, 17, 19 ], [ 21 ], [ 25, 27, 29 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47, 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59, 61 ], [ 63 ], [ 65 ], [ 67, 69 ], [ 71 ], [ 73 ], [ 75, 77 ], [ 79 ], [ 81, 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 101, 103 ], [ 105 ], [ 107, 109 ], [ 111 ], [ 113, 115 ], [ 117 ], [ 119, 121 ], [ 123 ], [ 125, 127 ], [ 129 ], [ 131 ], [ 133, 135 ], [ 137 ], [ 139 ], [ 141, 143 ], [ 145, 147, 149 ], [ 151 ], [ 153, 155 ], [ 157, 159, 161 ], [ 163 ], [ 165, 167 ], [ 169 ], [ 171, 173 ], [ 175 ], [ 177, 179 ], [ 181 ], [ 183, 185 ], [ 187 ], [ 189, 191 ], [ 193 ], [ 195, 197 ], [ 199 ], [ 201, 203 ], [ 205 ], [ 207, 209 ], [ 211 ], [ 213, 215 ], [ 217 ], [ 219, 221 ], [ 223 ], [ 225, 227 ], [ 229 ], [ 231, 233 ], [ 235 ], [ 237, 239 ], [ 241 ], [ 243, 245 ], [ 247 ], [ 249, 251 ], [ 253 ], [ 255, 257 ], [ 259 ], [ 261, 263 ], [ 265 ], [ 267 ], [ 271 ], [ 273 ] ]
12,543
BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd, unsigned long int req, void *buf, BlockDriverCompletionFunc *cb, void *opaque) { struct qemu_paiocb *acb; acb = qemu_aio_get(&raw_aio_pool, bs, cb, opaque); if (!acb) return NULL; acb->aio_type = QEMU_AIO_IOCTL; acb->aio_fildes = fd; acb->ev_signo = SIGUSR2; acb->async_context_id = get_async_context_id(); acb->aio_offset = 0; acb->aio_ioctl_buf = buf; acb->aio_ioctl_cmd = req; acb->next = posix_aio_state->first_aio; posix_aio_state->first_aio = acb; qemu_paio_submit(acb); return &acb->common; }
false
qemu
384acbf46b70edf0d2c1648aa1a92a90bcf7057d
BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd, unsigned long int req, void *buf, BlockDriverCompletionFunc *cb, void *opaque) { struct qemu_paiocb *acb; acb = qemu_aio_get(&raw_aio_pool, bs, cb, opaque); if (!acb) return NULL; acb->aio_type = QEMU_AIO_IOCTL; acb->aio_fildes = fd; acb->ev_signo = SIGUSR2; acb->async_context_id = get_async_context_id(); acb->aio_offset = 0; acb->aio_ioctl_buf = buf; acb->aio_ioctl_cmd = req; acb->next = posix_aio_state->first_aio; posix_aio_state->first_aio = acb; qemu_paio_submit(acb); return &acb->common; }
{ "code": [], "line_no": [] }
BlockDriverAIOCB *FUNC_0(BlockDriverState *bs, int fd, unsigned long int req, void *buf, BlockDriverCompletionFunc *cb, void *opaque) { struct qemu_paiocb *VAR_0; VAR_0 = qemu_aio_get(&raw_aio_pool, bs, cb, opaque); if (!VAR_0) return NULL; VAR_0->aio_type = QEMU_AIO_IOCTL; VAR_0->aio_fildes = fd; VAR_0->ev_signo = SIGUSR2; VAR_0->async_context_id = get_async_context_id(); VAR_0->aio_offset = 0; VAR_0->aio_ioctl_buf = buf; VAR_0->aio_ioctl_cmd = req; VAR_0->next = posix_aio_state->first_aio; posix_aio_state->first_aio = VAR_0; qemu_paio_submit(VAR_0); return &VAR_0->common; }
[ "BlockDriverAIOCB *FUNC_0(BlockDriverState *bs, int fd,\nunsigned long int req, void *buf,\nBlockDriverCompletionFunc *cb, void *opaque)\n{", "struct qemu_paiocb *VAR_0;", "VAR_0 = qemu_aio_get(&raw_aio_pool, bs, cb, opaque);", "if (!VAR_0)\nreturn NULL;", "VAR_0->aio_type = QEMU_AIO_IOCTL;", "VAR_0->aio_fildes = fd;", "VAR_0->ev_signo = SIGUSR2;", "VAR_0->async_context_id = get_async_context_id();", "VAR_0->aio_offset = 0;", "VAR_0->aio_ioctl_buf = buf;", "VAR_0->aio_ioctl_cmd = req;", "VAR_0->next = posix_aio_state->first_aio;", "posix_aio_state->first_aio = VAR_0;", "qemu_paio_submit(VAR_0);", "return &VAR_0->common;", "}" ]
[ 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 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ] ]
12,546
static void object_get_link_property(Object *obj, Visitor *v, void *opaque, const char *name, Error **errp) { Object **child = opaque; gchar *path; if (*child) { path = object_get_canonical_path(*child); visit_type_str(v, &path, name, errp); g_free(path); } else { path = (gchar *)""; visit_type_str(v, &path, name, errp); } }
true
qemu
9561fda8d90e176bef598ba87c42a1bd6ad03ef7
static void object_get_link_property(Object *obj, Visitor *v, void *opaque, const char *name, Error **errp) { Object **child = opaque; gchar *path; if (*child) { path = object_get_canonical_path(*child); visit_type_str(v, &path, name, errp); g_free(path); } else { path = (gchar *)""; visit_type_str(v, &path, name, errp); } }
{ "code": [ " Object **child = opaque;", " Object **child = opaque;" ], "line_no": [ 7, 7 ] }
static void FUNC_0(Object *VAR_0, Visitor *VAR_1, void *VAR_2, const char *VAR_3, Error **VAR_4) { Object **child = VAR_2; gchar *path; if (*child) { path = object_get_canonical_path(*child); visit_type_str(VAR_1, &path, VAR_3, VAR_4); g_free(path); } else { path = (gchar *)""; visit_type_str(VAR_1, &path, VAR_3, VAR_4); } }
[ "static void FUNC_0(Object *VAR_0, Visitor *VAR_1, void *VAR_2,\nconst char *VAR_3, Error **VAR_4)\n{", "Object **child = VAR_2;", "gchar *path;", "if (*child) {", "path = object_get_canonical_path(*child);", "visit_type_str(VAR_1, &path, VAR_3, VAR_4);", "g_free(path);", "} else {", "path = (gchar *)\"\";", "visit_type_str(VAR_1, &path, VAR_3, VAR_4);", "}", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ] ]
12,547
void FUNCC(ff_h264_idct_dc_add)(uint8_t *_dst, DCTELEM *block, int stride){ int i, j; int dc = (((dctcoef*)block)[0] + 32) >> 6; INIT_CLIP pixel *dst = (pixel*)_dst; stride /= sizeof(pixel); for( j = 0; j < 4; j++ ) { for( i = 0; i < 4; i++ ) dst[i] = CLIP( dst[i] + dc ); dst += stride; } }
true
FFmpeg
c23acbaed40101c677dfcfbbfe0d2c230a8e8f44
void FUNCC(ff_h264_idct_dc_add)(uint8_t *_dst, DCTELEM *block, int stride){ int i, j; int dc = (((dctcoef*)block)[0] + 32) >> 6; INIT_CLIP pixel *dst = (pixel*)_dst; stride /= sizeof(pixel); for( j = 0; j < 4; j++ ) { for( i = 0; i < 4; i++ ) dst[i] = CLIP( dst[i] + dc ); dst += stride; } }
{ "code": [ " INIT_CLIP", " INIT_CLIP", " INIT_CLIP", " dst[i] = CLIP( dst[i] + dc );", " INIT_CLIP", " dst[i] = CLIP( dst[i] + dc );" ], "line_no": [ 7, 7, 7, 19, 7, 19 ] }
void FUNC_0(ff_h264_idct_dc_add)(uint8_t *_dst, DCTELEM *block, int stride){ int VAR_0, VAR_1; int VAR_2 = (((dctcoef*)block)[0] + 32) >> 6; INIT_CLIP pixel *dst = (pixel*)_dst; stride /= sizeof(pixel); for( VAR_1 = 0; VAR_1 < 4; VAR_1++ ) { for( VAR_0 = 0; VAR_0 < 4; VAR_0++ ) dst[VAR_0] = CLIP( dst[VAR_0] + VAR_2 ); dst += stride; } }
[ "void FUNC_0(ff_h264_idct_dc_add)(uint8_t *_dst, DCTELEM *block, int stride){", "int VAR_0, VAR_1;", "int VAR_2 = (((dctcoef*)block)[0] + 32) >> 6;", "INIT_CLIP\npixel *dst = (pixel*)_dst;", "stride /= sizeof(pixel);", "for( VAR_1 = 0; VAR_1 < 4; VAR_1++ )", "{", "for( VAR_0 = 0; VAR_0 < 4; VAR_0++ )", "dst[VAR_0] = CLIP( dst[VAR_0] + VAR_2 );", "dst += stride;", "}", "}" ]
[ 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0 ]
[ [ 1 ], [ 3 ], [ 5 ], [ 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ] ]
12,549
int av_read_frame(AVFormatContext *s, AVPacket *pkt) { const int genpts = s->flags & AVFMT_FLAG_GENPTS; int eof = 0; int ret; AVStream *st; if (!genpts) { ret = s->packet_buffer ? read_from_packet_buffer(&s->packet_buffer, &s->packet_buffer_end, pkt) : read_frame_internal(s, pkt); if (ret < 0) return ret; goto return_packet; } for (;;) { AVPacketList *pktl = s->packet_buffer; if (pktl) { AVPacket *next_pkt = &pktl->pkt; if (next_pkt->dts != AV_NOPTS_VALUE) { int wrap_bits = s->streams[next_pkt->stream_index]->pts_wrap_bits; // last dts seen for this stream. if any of packets following // current one had no dts, we will set this to AV_NOPTS_VALUE. int64_t last_dts = next_pkt->dts; while (pktl && next_pkt->pts == AV_NOPTS_VALUE) { if (pktl->pkt.stream_index == next_pkt->stream_index && (av_compare_mod(next_pkt->dts, pktl->pkt.dts, 2LL << (wrap_bits - 1)) < 0)) { if (av_compare_mod(pktl->pkt.pts, pktl->pkt.dts, 2LL << (wrap_bits - 1))) { //not b frame next_pkt->pts = pktl->pkt.dts; } if (last_dts != AV_NOPTS_VALUE) { // Once last dts was set to AV_NOPTS_VALUE, we don't change it. last_dts = pktl->pkt.dts; } } pktl = pktl->next; } if (eof && next_pkt->pts == AV_NOPTS_VALUE && last_dts != AV_NOPTS_VALUE) { // Fixing the last reference frame had none pts issue (For MXF etc). // We only do this when // 1. eof. // 2. we are not able to resolve a pts value for current packet. // 3. the packets for this stream at the end of the files had valid dts. next_pkt->pts = last_dts + next_pkt->duration; } pktl = s->packet_buffer; } /* read packet from packet buffer, if there is data */ if (!(next_pkt->pts == AV_NOPTS_VALUE && next_pkt->dts != AV_NOPTS_VALUE && !eof)) { ret = read_from_packet_buffer(&s->packet_buffer, &s->packet_buffer_end, pkt); goto return_packet; } } ret = read_frame_internal(s, pkt); if (ret < 0) { if (pktl && ret != AVERROR(EAGAIN)) { eof = 1; continue; } else return ret; } if (av_dup_packet(add_to_pktbuf(&s->packet_buffer, pkt, &s->packet_buffer_end)) < 0) return AVERROR(ENOMEM); } return_packet: st = s->streams[pkt->stream_index]; if (st->skip_samples) { uint8_t *p = av_packet_new_side_data(pkt, AV_PKT_DATA_SKIP_SAMPLES, 10); AV_WL32(p, st->skip_samples); av_log(s, AV_LOG_DEBUG, "demuxer injecting skip %d\n", st->skip_samples); st->skip_samples = 0; } if ((s->iformat->flags & AVFMT_GENERIC_INDEX) && pkt->flags & AV_PKT_FLAG_KEY) { ff_reduce_index(s, st->index); av_add_index_entry(st, pkt->pos, pkt->dts, 0, 0, AVINDEX_KEYFRAME); } if (is_relative(pkt->dts)) pkt->dts -= RELATIVE_TS_BASE; if (is_relative(pkt->pts)) pkt->pts -= RELATIVE_TS_BASE; return ret; }
true
FFmpeg
88d4ff4b5f4c28fe38fa257b1d19b8fede4c35cc
int av_read_frame(AVFormatContext *s, AVPacket *pkt) { const int genpts = s->flags & AVFMT_FLAG_GENPTS; int eof = 0; int ret; AVStream *st; if (!genpts) { ret = s->packet_buffer ? read_from_packet_buffer(&s->packet_buffer, &s->packet_buffer_end, pkt) : read_frame_internal(s, pkt); if (ret < 0) return ret; goto return_packet; } for (;;) { AVPacketList *pktl = s->packet_buffer; if (pktl) { AVPacket *next_pkt = &pktl->pkt; if (next_pkt->dts != AV_NOPTS_VALUE) { int wrap_bits = s->streams[next_pkt->stream_index]->pts_wrap_bits; int64_t last_dts = next_pkt->dts; while (pktl && next_pkt->pts == AV_NOPTS_VALUE) { if (pktl->pkt.stream_index == next_pkt->stream_index && (av_compare_mod(next_pkt->dts, pktl->pkt.dts, 2LL << (wrap_bits - 1)) < 0)) { if (av_compare_mod(pktl->pkt.pts, pktl->pkt.dts, 2LL << (wrap_bits - 1))) { next_pkt->pts = pktl->pkt.dts; } if (last_dts != AV_NOPTS_VALUE) { last_dts = pktl->pkt.dts; } } pktl = pktl->next; } if (eof && next_pkt->pts == AV_NOPTS_VALUE && last_dts != AV_NOPTS_VALUE) { next_pkt->pts = last_dts + next_pkt->duration; } pktl = s->packet_buffer; } if (!(next_pkt->pts == AV_NOPTS_VALUE && next_pkt->dts != AV_NOPTS_VALUE && !eof)) { ret = read_from_packet_buffer(&s->packet_buffer, &s->packet_buffer_end, pkt); goto return_packet; } } ret = read_frame_internal(s, pkt); if (ret < 0) { if (pktl && ret != AVERROR(EAGAIN)) { eof = 1; continue; } else return ret; } if (av_dup_packet(add_to_pktbuf(&s->packet_buffer, pkt, &s->packet_buffer_end)) < 0) return AVERROR(ENOMEM); } return_packet: st = s->streams[pkt->stream_index]; if (st->skip_samples) { uint8_t *p = av_packet_new_side_data(pkt, AV_PKT_DATA_SKIP_SAMPLES, 10); AV_WL32(p, st->skip_samples); av_log(s, AV_LOG_DEBUG, "demuxer injecting skip %d\n", st->skip_samples); st->skip_samples = 0; } if ((s->iformat->flags & AVFMT_GENERIC_INDEX) && pkt->flags & AV_PKT_FLAG_KEY) { ff_reduce_index(s, st->index); av_add_index_entry(st, pkt->pos, pkt->dts, 0, 0, AVINDEX_KEYFRAME); } if (is_relative(pkt->dts)) pkt->dts -= RELATIVE_TS_BASE; if (is_relative(pkt->pts)) pkt->pts -= RELATIVE_TS_BASE; return ret; }
{ "code": [ " AV_WL32(p, st->skip_samples);", " av_log(s, AV_LOG_DEBUG, \"demuxer injecting skip %d\\n\", st->skip_samples);" ], "line_no": [ 159, 161 ] }
int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1) { const int VAR_2 = VAR_0->flags & AVFMT_FLAG_GENPTS; int VAR_3 = 0; int VAR_4; AVStream *st; if (!VAR_2) { VAR_4 = VAR_0->packet_buffer ? read_from_packet_buffer(&VAR_0->packet_buffer, &VAR_0->packet_buffer_end, VAR_1) : read_frame_internal(VAR_0, VAR_1); if (VAR_4 < 0) return VAR_4; goto return_packet; } for (;;) { AVPacketList *pktl = VAR_0->packet_buffer; if (pktl) { AVPacket *next_pkt = &pktl->VAR_1; if (next_pkt->dts != AV_NOPTS_VALUE) { int VAR_5 = VAR_0->streams[next_pkt->stream_index]->pts_wrap_bits; int64_t last_dts = next_pkt->dts; while (pktl && next_pkt->pts == AV_NOPTS_VALUE) { if (pktl->VAR_1.stream_index == next_pkt->stream_index && (av_compare_mod(next_pkt->dts, pktl->VAR_1.dts, 2LL << (VAR_5 - 1)) < 0)) { if (av_compare_mod(pktl->VAR_1.pts, pktl->VAR_1.dts, 2LL << (VAR_5 - 1))) { next_pkt->pts = pktl->VAR_1.dts; } if (last_dts != AV_NOPTS_VALUE) { last_dts = pktl->VAR_1.dts; } } pktl = pktl->next; } if (VAR_3 && next_pkt->pts == AV_NOPTS_VALUE && last_dts != AV_NOPTS_VALUE) { next_pkt->pts = last_dts + next_pkt->duration; } pktl = VAR_0->packet_buffer; } if (!(next_pkt->pts == AV_NOPTS_VALUE && next_pkt->dts != AV_NOPTS_VALUE && !VAR_3)) { VAR_4 = read_from_packet_buffer(&VAR_0->packet_buffer, &VAR_0->packet_buffer_end, VAR_1); goto return_packet; } } VAR_4 = read_frame_internal(VAR_0, VAR_1); if (VAR_4 < 0) { if (pktl && VAR_4 != AVERROR(EAGAIN)) { VAR_3 = 1; continue; } else return VAR_4; } if (av_dup_packet(add_to_pktbuf(&VAR_0->packet_buffer, VAR_1, &VAR_0->packet_buffer_end)) < 0) return AVERROR(ENOMEM); } return_packet: st = VAR_0->streams[VAR_1->stream_index]; if (st->skip_samples) { uint8_t *p = av_packet_new_side_data(VAR_1, AV_PKT_DATA_SKIP_SAMPLES, 10); AV_WL32(p, st->skip_samples); av_log(VAR_0, AV_LOG_DEBUG, "demuxer injecting skip %d\n", st->skip_samples); st->skip_samples = 0; } if ((VAR_0->iformat->flags & AVFMT_GENERIC_INDEX) && VAR_1->flags & AV_PKT_FLAG_KEY) { ff_reduce_index(VAR_0, st->index); av_add_index_entry(st, VAR_1->pos, VAR_1->dts, 0, 0, AVINDEX_KEYFRAME); } if (is_relative(VAR_1->dts)) VAR_1->dts -= RELATIVE_TS_BASE; if (is_relative(VAR_1->pts)) VAR_1->pts -= RELATIVE_TS_BASE; return VAR_4; }
[ "int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{", "const int VAR_2 = VAR_0->flags & AVFMT_FLAG_GENPTS;", "int VAR_3 = 0;", "int VAR_4;", "AVStream *st;", "if (!VAR_2) {", "VAR_4 = VAR_0->packet_buffer ?\nread_from_packet_buffer(&VAR_0->packet_buffer, &VAR_0->packet_buffer_end, VAR_1) :\nread_frame_internal(VAR_0, VAR_1);", "if (VAR_4 < 0)\nreturn VAR_4;", "goto return_packet;", "}", "for (;;) {", "AVPacketList *pktl = VAR_0->packet_buffer;", "if (pktl) {", "AVPacket *next_pkt = &pktl->VAR_1;", "if (next_pkt->dts != AV_NOPTS_VALUE) {", "int VAR_5 = VAR_0->streams[next_pkt->stream_index]->pts_wrap_bits;", "int64_t last_dts = next_pkt->dts;", "while (pktl && next_pkt->pts == AV_NOPTS_VALUE) {", "if (pktl->VAR_1.stream_index == next_pkt->stream_index &&\n(av_compare_mod(next_pkt->dts, pktl->VAR_1.dts, 2LL << (VAR_5 - 1)) < 0)) {", "if (av_compare_mod(pktl->VAR_1.pts, pktl->VAR_1.dts, 2LL << (VAR_5 - 1))) {", "next_pkt->pts = pktl->VAR_1.dts;", "}", "if (last_dts != AV_NOPTS_VALUE) {", "last_dts = pktl->VAR_1.dts;", "}", "}", "pktl = pktl->next;", "}", "if (VAR_3 && next_pkt->pts == AV_NOPTS_VALUE && last_dts != AV_NOPTS_VALUE) {", "next_pkt->pts = last_dts + next_pkt->duration;", "}", "pktl = VAR_0->packet_buffer;", "}", "if (!(next_pkt->pts == AV_NOPTS_VALUE &&\nnext_pkt->dts != AV_NOPTS_VALUE && !VAR_3)) {", "VAR_4 = read_from_packet_buffer(&VAR_0->packet_buffer,\n&VAR_0->packet_buffer_end, VAR_1);", "goto return_packet;", "}", "}", "VAR_4 = read_frame_internal(VAR_0, VAR_1);", "if (VAR_4 < 0) {", "if (pktl && VAR_4 != AVERROR(EAGAIN)) {", "VAR_3 = 1;", "continue;", "} else", "return VAR_4;", "}", "if (av_dup_packet(add_to_pktbuf(&VAR_0->packet_buffer, VAR_1,\n&VAR_0->packet_buffer_end)) < 0)\nreturn AVERROR(ENOMEM);", "}", "return_packet:\nst = VAR_0->streams[VAR_1->stream_index];", "if (st->skip_samples) {", "uint8_t *p = av_packet_new_side_data(VAR_1, AV_PKT_DATA_SKIP_SAMPLES, 10);", "AV_WL32(p, st->skip_samples);", "av_log(VAR_0, AV_LOG_DEBUG, \"demuxer injecting skip %d\\n\", st->skip_samples);", "st->skip_samples = 0;", "}", "if ((VAR_0->iformat->flags & AVFMT_GENERIC_INDEX) && VAR_1->flags & AV_PKT_FLAG_KEY) {", "ff_reduce_index(VAR_0, st->index);", "av_add_index_entry(st, VAR_1->pos, VAR_1->dts, 0, 0, AVINDEX_KEYFRAME);", "}", "if (is_relative(VAR_1->dts))\nVAR_1->dts -= RELATIVE_TS_BASE;", "if (is_relative(VAR_1->pts))\nVAR_1->pts -= RELATIVE_TS_BASE;", "return VAR_4;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17, 19, 21 ], [ 23, 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 53 ], [ 55 ], [ 57, 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 105, 107 ], [ 109, 111 ], [ 113 ], [ 115 ], [ 117 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 139, 141, 143 ], [ 145 ], [ 149, 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 179, 181 ], [ 183, 185 ], [ 189 ], [ 191 ] ]
12,550
static int buf_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size) { QEMUBuffer *s = opaque; ssize_t len = qsb_get_length(s->qsb) - pos; if (len <= 0) { return 0; } if (len > size) { len = size; } return qsb_get_buffer(s->qsb, pos, len, buf); }
true
qemu
60fe637bf0e4d7989e21e50f52526444765c63b4
static int buf_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size) { QEMUBuffer *s = opaque; ssize_t len = qsb_get_length(s->qsb) - pos; if (len <= 0) { return 0; } if (len > size) { len = size; } return qsb_get_buffer(s->qsb, pos, len, buf); }
{ "code": [], "line_no": [] }
static int FUNC_0(void *VAR_0, uint8_t *VAR_1, int64_t VAR_2, int VAR_3) { QEMUBuffer *s = VAR_0; ssize_t len = qsb_get_length(s->qsb) - VAR_2; if (len <= 0) { return 0; } if (len > VAR_3) { len = VAR_3; } return qsb_get_buffer(s->qsb, VAR_2, len, VAR_1); }
[ "static int FUNC_0(void *VAR_0, uint8_t *VAR_1, int64_t VAR_2, int VAR_3)\n{", "QEMUBuffer *s = VAR_0;", "ssize_t len = qsb_get_length(s->qsb) - VAR_2;", "if (len <= 0) {", "return 0;", "}", "if (len > VAR_3) {", "len = VAR_3;", "}", "return qsb_get_buffer(s->qsb, VAR_2, len, VAR_1);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ] ]
12,551
int unix_listen(const char *str, char *ostr, int olen) { QemuOpts *opts; char *path, *optstr; int sock, len; opts = qemu_opts_create(&dummy_opts, NULL, 0); optstr = strchr(str, ','); if (optstr) { len = optstr - str; if (len) { path = g_malloc(len+1); snprintf(path, len+1, "%.*s", len, str); qemu_opt_set(opts, "path", path); g_free(path); } } else { qemu_opt_set(opts, "path", str); } sock = unix_listen_opts(opts); if (sock != -1 && ostr) snprintf(ostr, olen, "%s%s", qemu_opt_get(opts, "path"), optstr ? optstr : ""); qemu_opts_del(opts); return sock; }
true
qemu
8be7e7e4c72c048b90e3482557954a24bba43ba7
int unix_listen(const char *str, char *ostr, int olen) { QemuOpts *opts; char *path, *optstr; int sock, len; opts = qemu_opts_create(&dummy_opts, NULL, 0); optstr = strchr(str, ','); if (optstr) { len = optstr - str; if (len) { path = g_malloc(len+1); snprintf(path, len+1, "%.*s", len, str); qemu_opt_set(opts, "path", path); g_free(path); } } else { qemu_opt_set(opts, "path", str); } sock = unix_listen_opts(opts); if (sock != -1 && ostr) snprintf(ostr, olen, "%s%s", qemu_opt_get(opts, "path"), optstr ? optstr : ""); qemu_opts_del(opts); return sock; }
{ "code": [ " opts = qemu_opts_create(&dummy_opts, NULL, 0);", " opts = qemu_opts_create(&dummy_opts, NULL, 0);", " opts = qemu_opts_create(&dummy_opts, NULL, 0);", " opts = qemu_opts_create(&dummy_opts, NULL, 0);" ], "line_no": [ 13, 13, 13, 13 ] }
int FUNC_0(const char *VAR_0, char *VAR_1, int VAR_2) { QemuOpts *opts; char *VAR_3, *VAR_4; int VAR_5, VAR_6; opts = qemu_opts_create(&dummy_opts, NULL, 0); VAR_4 = strchr(VAR_0, ','); if (VAR_4) { VAR_6 = VAR_4 - VAR_0; if (VAR_6) { VAR_3 = g_malloc(VAR_6+1); snprintf(VAR_3, VAR_6+1, "%.*s", VAR_6, VAR_0); qemu_opt_set(opts, "VAR_3", VAR_3); g_free(VAR_3); } } else { qemu_opt_set(opts, "VAR_3", VAR_0); } VAR_5 = unix_listen_opts(opts); if (VAR_5 != -1 && VAR_1) snprintf(VAR_1, VAR_2, "%s%s", qemu_opt_get(opts, "VAR_3"), VAR_4 ? VAR_4 : ""); qemu_opts_del(opts); return VAR_5; }
[ "int FUNC_0(const char *VAR_0, char *VAR_1, int VAR_2)\n{", "QemuOpts *opts;", "char *VAR_3, *VAR_4;", "int VAR_5, VAR_6;", "opts = qemu_opts_create(&dummy_opts, NULL, 0);", "VAR_4 = strchr(VAR_0, ',');", "if (VAR_4) {", "VAR_6 = VAR_4 - VAR_0;", "if (VAR_6) {", "VAR_3 = g_malloc(VAR_6+1);", "snprintf(VAR_3, VAR_6+1, \"%.*s\", VAR_6, VAR_0);", "qemu_opt_set(opts, \"VAR_3\", VAR_3);", "g_free(VAR_3);", "}", "} else {", "qemu_opt_set(opts, \"VAR_3\", VAR_0);", "}", "VAR_5 = unix_listen_opts(opts);", "if (VAR_5 != -1 && VAR_1)\nsnprintf(VAR_1, VAR_2, \"%s%s\", qemu_opt_get(opts, \"VAR_3\"), VAR_4 ? VAR_4 : \"\");", "qemu_opts_del(opts);", "return VAR_5;", "}" ]
[ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 47, 49 ], [ 51 ], [ 53 ], [ 55 ] ]
12,552
static void render_fragments(Vp3DecodeContext *s, int first_fragment, int width, int height, int plane /* 0 = Y, 1 = U, 2 = V */) { int x, y; int m, n; int i = first_fragment; int j; int16_t *dequantizer; DCTELEM dequant_block[64]; unsigned char *output_plane; unsigned char *last_plane; unsigned char *golden_plane; int stride; int motion_x, motion_y; int motion_x_limit, motion_y_limit; int motion_halfpel_index; unsigned int motion_source; debug_vp3(" vp3: rendering final fragments for %s\n", (plane == 0) ? "Y plane" : (plane == 1) ? "U plane" : "V plane"); /* set up plane-specific parameters */ if (plane == 0) { dequantizer = s->intra_y_dequant; output_plane = s->current_frame.data[0]; last_plane = s->last_frame.data[0]; golden_plane = s->golden_frame.data[0]; stride = -s->current_frame.linesize[0]; } else if (plane == 1) { dequantizer = s->intra_c_dequant; output_plane = s->current_frame.data[1]; last_plane = s->last_frame.data[1]; golden_plane = s->golden_frame.data[1]; stride = -s->current_frame.linesize[1]; } else { dequantizer = s->intra_c_dequant; output_plane = s->current_frame.data[2]; last_plane = s->last_frame.data[2]; golden_plane = s->golden_frame.data[2]; stride = -s->current_frame.linesize[2]; } motion_x_limit = width - 8; motion_y_limit = height - 8; /* for each fragment row... */ for (y = 0; y < height; y += 8) { /* for each fragment in a row... */ for (x = 0; x < width; x += 8, i++) { /* transform if this block was coded */ if (s->all_fragments[i].coding_method != MODE_COPY) { /* sort out the motion vector */ motion_x = s->all_fragments[i].motion_x; motion_y = s->all_fragments[i].motion_y; motion_halfpel_index = s->all_fragments[i].motion_halfpel_index; /* if (motion_x < 0) motion_x = 0; if (motion_y < 0) motion_y = 0; if (motion_x > motion_x_limit) motion_x = motion_x_limit; if (motion_y > motion_y_limit) motion_y = motion_y_limit; */ motion_source = s->all_fragments[i].first_pixel; motion_source += motion_x; motion_source += (motion_y * stride); /* first, take care of copying a block from either the * previous or the golden frame */ if ((s->all_fragments[i].coding_method == MODE_USING_GOLDEN) || (s->all_fragments[i].coding_method == MODE_GOLDEN_MV)) { s->dsp.put_pixels_tab[1][motion_halfpel_index]( output_plane + s->all_fragments[i].first_pixel, golden_plane + motion_source, stride, 8); } else if (s->all_fragments[i].coding_method != MODE_INTRA) { s->dsp.put_pixels_tab[1][motion_halfpel_index]( output_plane + s->all_fragments[i].first_pixel, last_plane + motion_source, stride, 8); } /* dequantize the DCT coefficients */ debug_idct("fragment %d, coding mode %d, DC = %d, dequant = %d:\n", i, s->all_fragments[i].coding_method, s->all_fragments[i].coeffs[0], dequantizer[0]); for (j = 0; j < 64; j++) dequant_block[dequant_index[j]] = s->all_fragments[i].coeffs[j] * dequantizer[j]; debug_idct("dequantized block:\n"); for (m = 0; m < 8; m++) { for (n = 0; n < 8; n++) { debug_idct(" %5d", dequant_block[m * 8 + n]); } debug_idct("\n"); } debug_idct("\n"); /* invert DCT and place (or add) in final output */ if (s->all_fragments[i].coding_method == MODE_INTRA) { dequant_block[0] += 1024; s->dsp.idct_put( output_plane + s->all_fragments[i].first_pixel, stride, dequant_block); } else { s->dsp.idct_add( output_plane + s->all_fragments[i].first_pixel, stride, dequant_block); } debug_idct("block after idct_%s():\n", (s->all_fragments[i].coding_method == MODE_INTRA)? "put" : "add"); for (m = 0; m < 8; m++) { for (n = 0; n < 8; n++) { debug_idct(" %3d", *(output_plane + s->all_fragments[i].first_pixel + (m * stride + n))); } debug_idct("\n"); } debug_idct("\n"); } else { /* copy directly from the previous frame */ s->dsp.put_pixels_tab[1][0]( output_plane + s->all_fragments[i].first_pixel, last_plane + s->all_fragments[i].first_pixel, stride, 8); } } } emms_c(); }
false
FFmpeg
a466e345e41253aa2c8cf9d62ff32be8d2cde0fa
static void render_fragments(Vp3DecodeContext *s, int first_fragment, int width, int height, int plane ) { int x, y; int m, n; int i = first_fragment; int j; int16_t *dequantizer; DCTELEM dequant_block[64]; unsigned char *output_plane; unsigned char *last_plane; unsigned char *golden_plane; int stride; int motion_x, motion_y; int motion_x_limit, motion_y_limit; int motion_halfpel_index; unsigned int motion_source; debug_vp3(" vp3: rendering final fragments for %s\n", (plane == 0) ? "Y plane" : (plane == 1) ? "U plane" : "V plane"); if (plane == 0) { dequantizer = s->intra_y_dequant; output_plane = s->current_frame.data[0]; last_plane = s->last_frame.data[0]; golden_plane = s->golden_frame.data[0]; stride = -s->current_frame.linesize[0]; } else if (plane == 1) { dequantizer = s->intra_c_dequant; output_plane = s->current_frame.data[1]; last_plane = s->last_frame.data[1]; golden_plane = s->golden_frame.data[1]; stride = -s->current_frame.linesize[1]; } else { dequantizer = s->intra_c_dequant; output_plane = s->current_frame.data[2]; last_plane = s->last_frame.data[2]; golden_plane = s->golden_frame.data[2]; stride = -s->current_frame.linesize[2]; } motion_x_limit = width - 8; motion_y_limit = height - 8; for (y = 0; y < height; y += 8) { for (x = 0; x < width; x += 8, i++) { if (s->all_fragments[i].coding_method != MODE_COPY) { motion_x = s->all_fragments[i].motion_x; motion_y = s->all_fragments[i].motion_y; motion_halfpel_index = s->all_fragments[i].motion_halfpel_index; motion_source = s->all_fragments[i].first_pixel; motion_source += motion_x; motion_source += (motion_y * stride); if ((s->all_fragments[i].coding_method == MODE_USING_GOLDEN) || (s->all_fragments[i].coding_method == MODE_GOLDEN_MV)) { s->dsp.put_pixels_tab[1][motion_halfpel_index]( output_plane + s->all_fragments[i].first_pixel, golden_plane + motion_source, stride, 8); } else if (s->all_fragments[i].coding_method != MODE_INTRA) { s->dsp.put_pixels_tab[1][motion_halfpel_index]( output_plane + s->all_fragments[i].first_pixel, last_plane + motion_source, stride, 8); } debug_idct("fragment %d, coding mode %d, DC = %d, dequant = %d:\n", i, s->all_fragments[i].coding_method, s->all_fragments[i].coeffs[0], dequantizer[0]); for (j = 0; j < 64; j++) dequant_block[dequant_index[j]] = s->all_fragments[i].coeffs[j] * dequantizer[j]; debug_idct("dequantized block:\n"); for (m = 0; m < 8; m++) { for (n = 0; n < 8; n++) { debug_idct(" %5d", dequant_block[m * 8 + n]); } debug_idct("\n"); } debug_idct("\n"); if (s->all_fragments[i].coding_method == MODE_INTRA) { dequant_block[0] += 1024; s->dsp.idct_put( output_plane + s->all_fragments[i].first_pixel, stride, dequant_block); } else { s->dsp.idct_add( output_plane + s->all_fragments[i].first_pixel, stride, dequant_block); } debug_idct("block after idct_%s():\n", (s->all_fragments[i].coding_method == MODE_INTRA)? "put" : "add"); for (m = 0; m < 8; m++) { for (n = 0; n < 8; n++) { debug_idct(" %3d", *(output_plane + s->all_fragments[i].first_pixel + (m * stride + n))); } debug_idct("\n"); } debug_idct("\n"); } else { s->dsp.put_pixels_tab[1][0]( output_plane + s->all_fragments[i].first_pixel, last_plane + s->all_fragments[i].first_pixel, stride, 8); } } } emms_c(); }
{ "code": [], "line_no": [] }
static void FUNC_0(Vp3DecodeContext *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4 ) { int VAR_5, VAR_6; int VAR_7, VAR_8; int VAR_9 = VAR_1; int VAR_10; int16_t *dequantizer; DCTELEM dequant_block[64]; unsigned char *VAR_11; unsigned char *VAR_12; unsigned char *VAR_13; int VAR_14; int VAR_15, VAR_16; int VAR_17, VAR_18; int VAR_19; unsigned int VAR_20; debug_vp3(" vp3: rendering final fragments for %VAR_0\VAR_8", (VAR_4 == 0) ? "Y VAR_4" : (VAR_4 == 1) ? "U VAR_4" : "V VAR_4"); if (VAR_4 == 0) { dequantizer = VAR_0->intra_y_dequant; VAR_11 = VAR_0->current_frame.data[0]; VAR_12 = VAR_0->last_frame.data[0]; VAR_13 = VAR_0->golden_frame.data[0]; VAR_14 = -VAR_0->current_frame.linesize[0]; } else if (VAR_4 == 1) { dequantizer = VAR_0->intra_c_dequant; VAR_11 = VAR_0->current_frame.data[1]; VAR_12 = VAR_0->last_frame.data[1]; VAR_13 = VAR_0->golden_frame.data[1]; VAR_14 = -VAR_0->current_frame.linesize[1]; } else { dequantizer = VAR_0->intra_c_dequant; VAR_11 = VAR_0->current_frame.data[2]; VAR_12 = VAR_0->last_frame.data[2]; VAR_13 = VAR_0->golden_frame.data[2]; VAR_14 = -VAR_0->current_frame.linesize[2]; } VAR_17 = VAR_2 - 8; VAR_18 = VAR_3 - 8; for (VAR_6 = 0; VAR_6 < VAR_3; VAR_6 += 8) { for (VAR_5 = 0; VAR_5 < VAR_2; VAR_5 += 8, VAR_9++) { if (VAR_0->all_fragments[VAR_9].coding_method != MODE_COPY) { VAR_15 = VAR_0->all_fragments[VAR_9].VAR_15; VAR_16 = VAR_0->all_fragments[VAR_9].VAR_16; VAR_19 = VAR_0->all_fragments[VAR_9].VAR_19; VAR_20 = VAR_0->all_fragments[VAR_9].first_pixel; VAR_20 += VAR_15; VAR_20 += (VAR_16 * VAR_14); if ((VAR_0->all_fragments[VAR_9].coding_method == MODE_USING_GOLDEN) || (VAR_0->all_fragments[VAR_9].coding_method == MODE_GOLDEN_MV)) { VAR_0->dsp.put_pixels_tab[1][VAR_19]( VAR_11 + VAR_0->all_fragments[VAR_9].first_pixel, VAR_13 + VAR_20, VAR_14, 8); } else if (VAR_0->all_fragments[VAR_9].coding_method != MODE_INTRA) { VAR_0->dsp.put_pixels_tab[1][VAR_19]( VAR_11 + VAR_0->all_fragments[VAR_9].first_pixel, VAR_12 + VAR_20, VAR_14, 8); } debug_idct("fragment %d, coding mode %d, DC = %d, dequant = %d:\VAR_8", VAR_9, VAR_0->all_fragments[VAR_9].coding_method, VAR_0->all_fragments[VAR_9].coeffs[0], dequantizer[0]); for (VAR_10 = 0; VAR_10 < 64; VAR_10++) dequant_block[dequant_index[VAR_10]] = VAR_0->all_fragments[VAR_9].coeffs[VAR_10] * dequantizer[VAR_10]; debug_idct("dequantized block:\VAR_8"); for (VAR_7 = 0; VAR_7 < 8; VAR_7++) { for (VAR_8 = 0; VAR_8 < 8; VAR_8++) { debug_idct(" %5d", dequant_block[VAR_7 * 8 + VAR_8]); } debug_idct("\VAR_8"); } debug_idct("\VAR_8"); if (VAR_0->all_fragments[VAR_9].coding_method == MODE_INTRA) { dequant_block[0] += 1024; VAR_0->dsp.idct_put( VAR_11 + VAR_0->all_fragments[VAR_9].first_pixel, VAR_14, dequant_block); } else { VAR_0->dsp.idct_add( VAR_11 + VAR_0->all_fragments[VAR_9].first_pixel, VAR_14, dequant_block); } debug_idct("block after idct_%VAR_0():\VAR_8", (VAR_0->all_fragments[VAR_9].coding_method == MODE_INTRA)? "put" : "add"); for (VAR_7 = 0; VAR_7 < 8; VAR_7++) { for (VAR_8 = 0; VAR_8 < 8; VAR_8++) { debug_idct(" %3d", *(VAR_11 + VAR_0->all_fragments[VAR_9].first_pixel + (VAR_7 * VAR_14 + VAR_8))); } debug_idct("\VAR_8"); } debug_idct("\VAR_8"); } else { VAR_0->dsp.put_pixels_tab[1][0]( VAR_11 + VAR_0->all_fragments[VAR_9].first_pixel, VAR_12 + VAR_0->all_fragments[VAR_9].first_pixel, VAR_14, 8); } } } emms_c(); }
[ "static void FUNC_0(Vp3DecodeContext *VAR_0,\nint VAR_1,\nint VAR_2,\nint VAR_3,\nint VAR_4 )\n{", "int VAR_5, VAR_6;", "int VAR_7, VAR_8;", "int VAR_9 = VAR_1;", "int VAR_10;", "int16_t *dequantizer;", "DCTELEM dequant_block[64];", "unsigned char *VAR_11;", "unsigned char *VAR_12;", "unsigned char *VAR_13;", "int VAR_14;", "int VAR_15, VAR_16;", "int VAR_17, VAR_18;", "int VAR_19;", "unsigned int VAR_20;", "debug_vp3(\" vp3: rendering final fragments for %VAR_0\\VAR_8\",\n(VAR_4 == 0) ? \"Y VAR_4\" : (VAR_4 == 1) ? \"U VAR_4\" : \"V VAR_4\");", "if (VAR_4 == 0) {", "dequantizer = VAR_0->intra_y_dequant;", "VAR_11 = VAR_0->current_frame.data[0];", "VAR_12 = VAR_0->last_frame.data[0];", "VAR_13 = VAR_0->golden_frame.data[0];", "VAR_14 = -VAR_0->current_frame.linesize[0];", "} else if (VAR_4 == 1) {", "dequantizer = VAR_0->intra_c_dequant;", "VAR_11 = VAR_0->current_frame.data[1];", "VAR_12 = VAR_0->last_frame.data[1];", "VAR_13 = VAR_0->golden_frame.data[1];", "VAR_14 = -VAR_0->current_frame.linesize[1];", "} else {", "dequantizer = VAR_0->intra_c_dequant;", "VAR_11 = VAR_0->current_frame.data[2];", "VAR_12 = VAR_0->last_frame.data[2];", "VAR_13 = VAR_0->golden_frame.data[2];", "VAR_14 = -VAR_0->current_frame.linesize[2];", "}", "VAR_17 = VAR_2 - 8;", "VAR_18 = VAR_3 - 8;", "for (VAR_6 = 0; VAR_6 < VAR_3; VAR_6 += 8) {", "for (VAR_5 = 0; VAR_5 < VAR_2; VAR_5 += 8, VAR_9++) {", "if (VAR_0->all_fragments[VAR_9].coding_method != MODE_COPY) {", "VAR_15 = VAR_0->all_fragments[VAR_9].VAR_15;", "VAR_16 = VAR_0->all_fragments[VAR_9].VAR_16;", "VAR_19 = VAR_0->all_fragments[VAR_9].VAR_19;", "VAR_20 = VAR_0->all_fragments[VAR_9].first_pixel;", "VAR_20 += VAR_15;", "VAR_20 += (VAR_16 * VAR_14);", "if ((VAR_0->all_fragments[VAR_9].coding_method == MODE_USING_GOLDEN) ||\n(VAR_0->all_fragments[VAR_9].coding_method == MODE_GOLDEN_MV)) {", "VAR_0->dsp.put_pixels_tab[1][VAR_19](\nVAR_11 + VAR_0->all_fragments[VAR_9].first_pixel,\nVAR_13 + VAR_20,\nVAR_14, 8);", "} else", "if (VAR_0->all_fragments[VAR_9].coding_method != MODE_INTRA) {", "VAR_0->dsp.put_pixels_tab[1][VAR_19](\nVAR_11 + VAR_0->all_fragments[VAR_9].first_pixel,\nVAR_12 + VAR_20,\nVAR_14, 8);", "}", "debug_idct(\"fragment %d, coding mode %d, DC = %d, dequant = %d:\\VAR_8\",\nVAR_9, VAR_0->all_fragments[VAR_9].coding_method,\nVAR_0->all_fragments[VAR_9].coeffs[0], dequantizer[0]);", "for (VAR_10 = 0; VAR_10 < 64; VAR_10++)", "dequant_block[dequant_index[VAR_10]] =\nVAR_0->all_fragments[VAR_9].coeffs[VAR_10] *\ndequantizer[VAR_10];", "debug_idct(\"dequantized block:\\VAR_8\");", "for (VAR_7 = 0; VAR_7 < 8; VAR_7++) {", "for (VAR_8 = 0; VAR_8 < 8; VAR_8++) {", "debug_idct(\" %5d\", dequant_block[VAR_7 * 8 + VAR_8]);", "}", "debug_idct(\"\\VAR_8\");", "}", "debug_idct(\"\\VAR_8\");", "if (VAR_0->all_fragments[VAR_9].coding_method == MODE_INTRA) {", "dequant_block[0] += 1024;", "VAR_0->dsp.idct_put(\nVAR_11 + VAR_0->all_fragments[VAR_9].first_pixel,\nVAR_14, dequant_block);", "} else {", "VAR_0->dsp.idct_add(\nVAR_11 + VAR_0->all_fragments[VAR_9].first_pixel,\nVAR_14, dequant_block);", "}", "debug_idct(\"block after idct_%VAR_0():\\VAR_8\",\n(VAR_0->all_fragments[VAR_9].coding_method == MODE_INTRA)?\n\"put\" : \"add\");", "for (VAR_7 = 0; VAR_7 < 8; VAR_7++) {", "for (VAR_8 = 0; VAR_8 < 8; VAR_8++) {", "debug_idct(\" %3d\", *(VAR_11 +\nVAR_0->all_fragments[VAR_9].first_pixel + (VAR_7 * VAR_14 + VAR_8)));", "}", "debug_idct(\"\\VAR_8\");", "}", "debug_idct(\"\\VAR_8\");", "} else {", "VAR_0->dsp.put_pixels_tab[1][0](\nVAR_11 + VAR_0->all_fragments[VAR_9].first_pixel,\nVAR_12 + VAR_0->all_fragments[VAR_9].first_pixel,\nVAR_14, 8);", "}", "}", "}", "emms_c();", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 43, 45 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 91 ], [ 93 ], [ 99 ], [ 105 ], [ 111 ], [ 117 ], [ 119 ], [ 121 ], [ 145 ], [ 147 ], [ 149 ], [ 157, 159 ], [ 163, 165, 167, 169 ], [ 173 ], [ 175 ], [ 179, 181, 183, 185 ], [ 187 ], [ 193, 195, 197 ], [ 199 ], [ 201, 203, 205 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 231 ], [ 233 ], [ 235, 237, 239 ], [ 241 ], [ 243, 245, 247 ], [ 249 ], [ 253, 255, 257 ], [ 259 ], [ 261 ], [ 263, 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 277 ], [ 283, 285, 287, 289 ], [ 293 ], [ 295 ], [ 297 ], [ 301 ], [ 305 ] ]
12,553
static av_cold int color_init(AVFilterContext *ctx, const char *args, void *opaque) { ColorContext *color = ctx->priv; char color_string[128] = "black"; char frame_size [128] = "320x240"; char frame_rate [128] = "25"; AVRational frame_rate_q; char *colon = 0, *equal = 0; int ret = 0; color->class = &color_class; if (args) { colon = strchr(args, ':'); equal = strchr(args, '='); } if (!args || (equal && (!colon || equal < colon))) { av_opt_set_defaults(color); if ((ret = av_set_options_string(color, args, "=", ":")) < 0) { av_log(ctx, AV_LOG_ERROR, "Error parsing options string: '%s'\n", args); goto end; } if (av_parse_video_rate(&frame_rate_q, color->rate_str) < 0 || frame_rate_q.den <= 0 || frame_rate_q.num <= 0) { av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: %s\n", color->rate_str); ret = AVERROR(EINVAL); goto end; } if (av_parse_color(color->color_rgba, color->color_str, -1, ctx) < 0) { ret = AVERROR(EINVAL); goto end; } } else { av_log(ctx, AV_LOG_WARNING, "Flat options syntax is deprecated, use key=value pairs.\n"); sscanf(args, "%127[^:]:%127[^:]:%127s", color_string, frame_size, frame_rate); if (av_parse_video_size(&color->w, &color->h, frame_size) < 0) { av_log(ctx, AV_LOG_ERROR, "Invalid frame size: %s\n", frame_size); return AVERROR(EINVAL); } if (av_parse_video_rate(&frame_rate_q, frame_rate) < 0 || frame_rate_q.den <= 0 || frame_rate_q.num <= 0) { av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: %s\n", frame_rate); return AVERROR(EINVAL); } if (av_parse_color(color->color_rgba, color_string, -1, ctx) < 0) return AVERROR(EINVAL); } color->time_base.num = frame_rate_q.den; color->time_base.den = frame_rate_q.num; end: av_opt_free(color); return ret; }
false
FFmpeg
de0587739011b7636743251a86d48bcd10ab7c22
static av_cold int color_init(AVFilterContext *ctx, const char *args, void *opaque) { ColorContext *color = ctx->priv; char color_string[128] = "black"; char frame_size [128] = "320x240"; char frame_rate [128] = "25"; AVRational frame_rate_q; char *colon = 0, *equal = 0; int ret = 0; color->class = &color_class; if (args) { colon = strchr(args, ':'); equal = strchr(args, '='); } if (!args || (equal && (!colon || equal < colon))) { av_opt_set_defaults(color); if ((ret = av_set_options_string(color, args, "=", ":")) < 0) { av_log(ctx, AV_LOG_ERROR, "Error parsing options string: '%s'\n", args); goto end; } if (av_parse_video_rate(&frame_rate_q, color->rate_str) < 0 || frame_rate_q.den <= 0 || frame_rate_q.num <= 0) { av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: %s\n", color->rate_str); ret = AVERROR(EINVAL); goto end; } if (av_parse_color(color->color_rgba, color->color_str, -1, ctx) < 0) { ret = AVERROR(EINVAL); goto end; } } else { av_log(ctx, AV_LOG_WARNING, "Flat options syntax is deprecated, use key=value pairs.\n"); sscanf(args, "%127[^:]:%127[^:]:%127s", color_string, frame_size, frame_rate); if (av_parse_video_size(&color->w, &color->h, frame_size) < 0) { av_log(ctx, AV_LOG_ERROR, "Invalid frame size: %s\n", frame_size); return AVERROR(EINVAL); } if (av_parse_video_rate(&frame_rate_q, frame_rate) < 0 || frame_rate_q.den <= 0 || frame_rate_q.num <= 0) { av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: %s\n", frame_rate); return AVERROR(EINVAL); } if (av_parse_color(color->color_rgba, color_string, -1, ctx) < 0) return AVERROR(EINVAL); } color->time_base.num = frame_rate_q.den; color->time_base.den = frame_rate_q.num; end: av_opt_free(color); return ret; }
{ "code": [], "line_no": [] }
static av_cold int FUNC_0(AVFilterContext *ctx, const char *args, void *opaque) { ColorContext *color = ctx->priv; char VAR_0[128] = "black"; char VAR_1 [128] = "320x240"; char VAR_2 [128] = "25"; AVRational frame_rate_q; char *VAR_3 = 0, *VAR_4 = 0; int VAR_5 = 0; color->class = &color_class; if (args) { VAR_3 = strchr(args, ':'); VAR_4 = strchr(args, '='); } if (!args || (VAR_4 && (!VAR_3 || VAR_4 < VAR_3))) { av_opt_set_defaults(color); if ((VAR_5 = av_set_options_string(color, args, "=", ":")) < 0) { av_log(ctx, AV_LOG_ERROR, "Error parsing options string: '%s'\n", args); goto end; } if (av_parse_video_rate(&frame_rate_q, color->rate_str) < 0 || frame_rate_q.den <= 0 || frame_rate_q.num <= 0) { av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: %s\n", color->rate_str); VAR_5 = AVERROR(EINVAL); goto end; } if (av_parse_color(color->color_rgba, color->color_str, -1, ctx) < 0) { VAR_5 = AVERROR(EINVAL); goto end; } } else { av_log(ctx, AV_LOG_WARNING, "Flat options syntax is deprecated, use key=value pairs.\n"); sscanf(args, "%127[^:]:%127[^:]:%127s", VAR_0, VAR_1, VAR_2); if (av_parse_video_size(&color->w, &color->h, VAR_1) < 0) { av_log(ctx, AV_LOG_ERROR, "Invalid frame size: %s\n", VAR_1); return AVERROR(EINVAL); } if (av_parse_video_rate(&frame_rate_q, VAR_2) < 0 || frame_rate_q.den <= 0 || frame_rate_q.num <= 0) { av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: %s\n", VAR_2); return AVERROR(EINVAL); } if (av_parse_color(color->color_rgba, VAR_0, -1, ctx) < 0) return AVERROR(EINVAL); } color->time_base.num = frame_rate_q.den; color->time_base.den = frame_rate_q.num; end: av_opt_free(color); return VAR_5; }
[ "static av_cold int FUNC_0(AVFilterContext *ctx, const char *args, void *opaque)\n{", "ColorContext *color = ctx->priv;", "char VAR_0[128] = \"black\";", "char VAR_1 [128] = \"320x240\";", "char VAR_2 [128] = \"25\";", "AVRational frame_rate_q;", "char *VAR_3 = 0, *VAR_4 = 0;", "int VAR_5 = 0;", "color->class = &color_class;", "if (args) {", "VAR_3 = strchr(args, ':');", "VAR_4 = strchr(args, '=');", "}", "if (!args || (VAR_4 && (!VAR_3 || VAR_4 < VAR_3))) {", "av_opt_set_defaults(color);", "if ((VAR_5 = av_set_options_string(color, args, \"=\", \":\")) < 0) {", "av_log(ctx, AV_LOG_ERROR, \"Error parsing options string: '%s'\\n\", args);", "goto end;", "}", "if (av_parse_video_rate(&frame_rate_q, color->rate_str) < 0 ||\nframe_rate_q.den <= 0 || frame_rate_q.num <= 0) {", "av_log(ctx, AV_LOG_ERROR, \"Invalid frame rate: %s\\n\", color->rate_str);", "VAR_5 = AVERROR(EINVAL);", "goto end;", "}", "if (av_parse_color(color->color_rgba, color->color_str, -1, ctx) < 0) {", "VAR_5 = AVERROR(EINVAL);", "goto end;", "}", "} else {", "av_log(ctx, AV_LOG_WARNING, \"Flat options syntax is deprecated, use key=value pairs.\\n\");", "sscanf(args, \"%127[^:]:%127[^:]:%127s\", VAR_0, VAR_1, VAR_2);", "if (av_parse_video_size(&color->w, &color->h, VAR_1) < 0) {", "av_log(ctx, AV_LOG_ERROR, \"Invalid frame size: %s\\n\", VAR_1);", "return AVERROR(EINVAL);", "}", "if (av_parse_video_rate(&frame_rate_q, VAR_2) < 0 ||\nframe_rate_q.den <= 0 || frame_rate_q.num <= 0) {", "av_log(ctx, AV_LOG_ERROR, \"Invalid frame rate: %s\\n\", VAR_2);", "return AVERROR(EINVAL);", "}", "if (av_parse_color(color->color_rgba, VAR_0, -1, ctx) < 0)\nreturn AVERROR(EINVAL);", "}", "color->time_base.num = frame_rate_q.den;", "color->time_base.den = frame_rate_q.num;", "end:\nav_opt_free(color);", "return VAR_5;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 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 ], [ 99 ], [ 101 ], [ 105, 107 ], [ 109 ], [ 111 ] ]
12,554
static int parse_ffconfig(const char *filename) { FILE *f; char line[1024]; char cmd[64]; char arg[1024]; const char *p; int val, errors, line_num; FFStream **last_stream, *stream, *redirect; FFStream **last_feed, *feed, *s; AVCodecContext audio_enc, video_enc; enum CodecID audio_id, video_id; f = fopen(filename, "r"); if (!f) { perror(filename); return -1; } errors = 0; line_num = 0; first_stream = NULL; last_stream = &first_stream; first_feed = NULL; last_feed = &first_feed; stream = NULL; feed = NULL; redirect = NULL; audio_id = CODEC_ID_NONE; video_id = CODEC_ID_NONE; for(;;) { if (fgets(line, sizeof(line), f) == NULL) break; line_num++; p = line; while (isspace(*p)) p++; if (*p == '\0' || *p == '#') continue; get_arg(cmd, sizeof(cmd), &p); if (!strcasecmp(cmd, "Port")) { get_arg(arg, sizeof(arg), &p); val = atoi(arg); if (val < 1 || val > 65536) { fprintf(stderr, "%s:%d: Invalid port: %s\n", filename, line_num, arg); errors++; } my_http_addr.sin_port = htons(val); } else if (!strcasecmp(cmd, "BindAddress")) { get_arg(arg, sizeof(arg), &p); if (resolve_host(&my_http_addr.sin_addr, arg) != 0) { fprintf(stderr, "%s:%d: Invalid host/IP address: %s\n", filename, line_num, arg); errors++; } } else if (!strcasecmp(cmd, "NoDaemon")) { ffserver_daemon = 0; } else if (!strcasecmp(cmd, "RTSPPort")) { get_arg(arg, sizeof(arg), &p); val = atoi(arg); if (val < 1 || val > 65536) { fprintf(stderr, "%s:%d: Invalid port: %s\n", filename, line_num, arg); errors++; } my_rtsp_addr.sin_port = htons(atoi(arg)); } else if (!strcasecmp(cmd, "RTSPBindAddress")) { get_arg(arg, sizeof(arg), &p); if (resolve_host(&my_rtsp_addr.sin_addr, arg) != 0) { fprintf(stderr, "%s:%d: Invalid host/IP address: %s\n", filename, line_num, arg); errors++; } } else if (!strcasecmp(cmd, "MaxHTTPConnections")) { get_arg(arg, sizeof(arg), &p); val = atoi(arg); if (val < 1 || val > 65536) { fprintf(stderr, "%s:%d: Invalid MaxHTTPConnections: %s\n", filename, line_num, arg); errors++; } nb_max_http_connections = val; } else if (!strcasecmp(cmd, "MaxClients")) { get_arg(arg, sizeof(arg), &p); val = atoi(arg); if (val < 1 || val > nb_max_http_connections) { fprintf(stderr, "%s:%d: Invalid MaxClients: %s\n", filename, line_num, arg); errors++; } else { nb_max_connections = val; } } else if (!strcasecmp(cmd, "MaxBandwidth")) { int64_t llval; get_arg(arg, sizeof(arg), &p); llval = atoll(arg); if (llval < 10 || llval > 10000000) { fprintf(stderr, "%s:%d: Invalid MaxBandwidth: %s\n", filename, line_num, arg); errors++; } else max_bandwidth = llval; } else if (!strcasecmp(cmd, "CustomLog")) { if (!ffserver_debug) get_arg(logfilename, sizeof(logfilename), &p); } else if (!strcasecmp(cmd, "<Feed")) { /*********************************************/ /* Feed related options */ char *q; if (stream || feed) { fprintf(stderr, "%s:%d: Already in a tag\n", filename, line_num); } else { feed = av_mallocz(sizeof(FFStream)); get_arg(feed->filename, sizeof(feed->filename), &p); q = strrchr(feed->filename, '>'); if (*q) *q = '\0'; for (s = first_feed; s; s = s->next) { if (!strcmp(feed->filename, s->filename)) { fprintf(stderr, "%s:%d: Feed '%s' already registered\n", filename, line_num, s->filename); errors++; } } feed->fmt = guess_format("ffm", NULL, NULL); /* defaut feed file */ snprintf(feed->feed_filename, sizeof(feed->feed_filename), "/tmp/%s.ffm", feed->filename); feed->feed_max_size = 5 * 1024 * 1024; feed->is_feed = 1; feed->feed = feed; /* self feeding :-) */ /* add in stream list */ *last_stream = feed; last_stream = &feed->next; /* add in feed list */ *last_feed = feed; last_feed = &feed->next_feed; } } else if (!strcasecmp(cmd, "Launch")) { if (feed) { int i; feed->child_argv = av_mallocz(64 * sizeof(char *)); for (i = 0; i < 62; i++) { get_arg(arg, sizeof(arg), &p); if (!arg[0]) break; feed->child_argv[i] = av_strdup(arg); } feed->child_argv[i] = av_malloc(30 + strlen(feed->filename)); snprintf(feed->child_argv[i], 30+strlen(feed->filename), "http://%s:%d/%s", (my_http_addr.sin_addr.s_addr == INADDR_ANY) ? "127.0.0.1" : inet_ntoa(my_http_addr.sin_addr), ntohs(my_http_addr.sin_port), feed->filename); } } else if (!strcasecmp(cmd, "ReadOnlyFile")) { if (feed) { get_arg(feed->feed_filename, sizeof(feed->feed_filename), &p); feed->readonly = 1; } else if (stream) { get_arg(stream->feed_filename, sizeof(stream->feed_filename), &p); } } else if (!strcasecmp(cmd, "File")) { if (feed) { get_arg(feed->feed_filename, sizeof(feed->feed_filename), &p); } else if (stream) get_arg(stream->feed_filename, sizeof(stream->feed_filename), &p); } else if (!strcasecmp(cmd, "Truncate")) { if (feed) { get_arg(arg, sizeof(arg), &p); feed->truncate = strtod(arg, NULL); } } else if (!strcasecmp(cmd, "FileMaxSize")) { if (feed) { char *p1; double fsize; get_arg(arg, sizeof(arg), &p); p1 = arg; fsize = strtod(p1, &p1); switch(toupper(*p1)) { case 'K': fsize *= 1024; break; case 'M': fsize *= 1024 * 1024; break; case 'G': fsize *= 1024 * 1024 * 1024; break; } feed->feed_max_size = (int64_t)fsize; if (feed->feed_max_size < FFM_PACKET_SIZE*4) { fprintf(stderr, "%s:%d: Feed max file size is too small, " "must be at least %d\n", filename, line_num, FFM_PACKET_SIZE*4); errors++; } } } else if (!strcasecmp(cmd, "</Feed>")) { if (!feed) { fprintf(stderr, "%s:%d: No corresponding <Feed> for </Feed>\n", filename, line_num); errors++; } feed = NULL; } else if (!strcasecmp(cmd, "<Stream")) { /*********************************************/ /* Stream related options */ char *q; if (stream || feed) { fprintf(stderr, "%s:%d: Already in a tag\n", filename, line_num); } else { FFStream *s; const AVClass *class; stream = av_mallocz(sizeof(FFStream)); get_arg(stream->filename, sizeof(stream->filename), &p); q = strrchr(stream->filename, '>'); if (*q) *q = '\0'; for (s = first_stream; s; s = s->next) { if (!strcmp(stream->filename, s->filename)) { fprintf(stderr, "%s:%d: Stream '%s' already registered\n", filename, line_num, s->filename); errors++; } } stream->fmt = guess_stream_format(NULL, stream->filename, NULL); /* fetch avclass so AVOption works * FIXME try to use avcodec_get_context_defaults2 * without changing defaults too much */ avcodec_get_context_defaults(&video_enc); class = video_enc.av_class; memset(&audio_enc, 0, sizeof(AVCodecContext)); memset(&video_enc, 0, sizeof(AVCodecContext)); audio_enc.av_class = class; video_enc.av_class = class; audio_id = CODEC_ID_NONE; video_id = CODEC_ID_NONE; if (stream->fmt) { audio_id = stream->fmt->audio_codec; video_id = stream->fmt->video_codec; } *last_stream = stream; last_stream = &stream->next; } } else if (!strcasecmp(cmd, "Feed")) { get_arg(arg, sizeof(arg), &p); if (stream) { FFStream *sfeed; sfeed = first_feed; while (sfeed != NULL) { if (!strcmp(sfeed->filename, arg)) break; sfeed = sfeed->next_feed; } if (!sfeed) fprintf(stderr, "%s:%d: feed '%s' not defined\n", filename, line_num, arg); else stream->feed = sfeed; } } else if (!strcasecmp(cmd, "Format")) { get_arg(arg, sizeof(arg), &p); if (stream) { if (!strcmp(arg, "status")) { stream->stream_type = STREAM_TYPE_STATUS; stream->fmt = NULL; } else { stream->stream_type = STREAM_TYPE_LIVE; /* jpeg cannot be used here, so use single frame jpeg */ if (!strcmp(arg, "jpeg")) strcpy(arg, "mjpeg"); stream->fmt = guess_stream_format(arg, NULL, NULL); if (!stream->fmt) { fprintf(stderr, "%s:%d: Unknown Format: %s\n", filename, line_num, arg); errors++; } } if (stream->fmt) { audio_id = stream->fmt->audio_codec; video_id = stream->fmt->video_codec; } } } else if (!strcasecmp(cmd, "InputFormat")) { get_arg(arg, sizeof(arg), &p); if (stream) { stream->ifmt = av_find_input_format(arg); if (!stream->ifmt) { fprintf(stderr, "%s:%d: Unknown input format: %s\n", filename, line_num, arg); } } } else if (!strcasecmp(cmd, "FaviconURL")) { if (stream && stream->stream_type == STREAM_TYPE_STATUS) { get_arg(stream->feed_filename, sizeof(stream->feed_filename), &p); } else { fprintf(stderr, "%s:%d: FaviconURL only permitted for status streams\n", filename, line_num); errors++; } } else if (!strcasecmp(cmd, "Author")) { if (stream) get_arg(stream->author, sizeof(stream->author), &p); } else if (!strcasecmp(cmd, "Comment")) { if (stream) get_arg(stream->comment, sizeof(stream->comment), &p); } else if (!strcasecmp(cmd, "Copyright")) { if (stream) get_arg(stream->copyright, sizeof(stream->copyright), &p); } else if (!strcasecmp(cmd, "Title")) { if (stream) get_arg(stream->title, sizeof(stream->title), &p); } else if (!strcasecmp(cmd, "Preroll")) { get_arg(arg, sizeof(arg), &p); if (stream) stream->prebuffer = atof(arg) * 1000; } else if (!strcasecmp(cmd, "StartSendOnKey")) { if (stream) stream->send_on_key = 1; } else if (!strcasecmp(cmd, "AudioCodec")) { get_arg(arg, sizeof(arg), &p); audio_id = opt_audio_codec(arg); if (audio_id == CODEC_ID_NONE) { fprintf(stderr, "%s:%d: Unknown AudioCodec: %s\n", filename, line_num, arg); errors++; } } else if (!strcasecmp(cmd, "VideoCodec")) { get_arg(arg, sizeof(arg), &p); video_id = opt_video_codec(arg); if (video_id == CODEC_ID_NONE) { fprintf(stderr, "%s:%d: Unknown VideoCodec: %s\n", filename, line_num, arg); errors++; } } else if (!strcasecmp(cmd, "MaxTime")) { get_arg(arg, sizeof(arg), &p); if (stream) stream->max_time = atof(arg) * 1000; } else if (!strcasecmp(cmd, "AudioBitRate")) { get_arg(arg, sizeof(arg), &p); if (stream) audio_enc.bit_rate = atoi(arg) * 1000; } else if (!strcasecmp(cmd, "AudioChannels")) { get_arg(arg, sizeof(arg), &p); if (stream) audio_enc.channels = atoi(arg); } else if (!strcasecmp(cmd, "AudioSampleRate")) { get_arg(arg, sizeof(arg), &p); if (stream) audio_enc.sample_rate = atoi(arg); } else if (!strcasecmp(cmd, "AudioQuality")) { get_arg(arg, sizeof(arg), &p); if (stream) { // audio_enc.quality = atof(arg) * 1000; } } else if (!strcasecmp(cmd, "VideoBitRateRange")) { if (stream) { int minrate, maxrate; get_arg(arg, sizeof(arg), &p); if (sscanf(arg, "%d-%d", &minrate, &maxrate) == 2) { video_enc.rc_min_rate = minrate * 1000; video_enc.rc_max_rate = maxrate * 1000; } else { fprintf(stderr, "%s:%d: Incorrect format for VideoBitRateRange -- should be <min>-<max>: %s\n", filename, line_num, arg); errors++; } } } else if (!strcasecmp(cmd, "Debug")) { if (stream) { get_arg(arg, sizeof(arg), &p); video_enc.debug = strtol(arg,0,0); } } else if (!strcasecmp(cmd, "Strict")) { if (stream) { get_arg(arg, sizeof(arg), &p); video_enc.strict_std_compliance = atoi(arg); } } else if (!strcasecmp(cmd, "VideoBufferSize")) { if (stream) { get_arg(arg, sizeof(arg), &p); video_enc.rc_buffer_size = atoi(arg) * 8*1024; } } else if (!strcasecmp(cmd, "VideoBitRateTolerance")) { if (stream) { get_arg(arg, sizeof(arg), &p); video_enc.bit_rate_tolerance = atoi(arg) * 1000; } } else if (!strcasecmp(cmd, "VideoBitRate")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.bit_rate = atoi(arg) * 1000; } } else if (!strcasecmp(cmd, "VideoSize")) { get_arg(arg, sizeof(arg), &p); if (stream) { av_parse_video_frame_size(&video_enc.width, &video_enc.height, arg); if ((video_enc.width % 16) != 0 || (video_enc.height % 16) != 0) { fprintf(stderr, "%s:%d: Image size must be a multiple of 16\n", filename, line_num); errors++; } } } else if (!strcasecmp(cmd, "VideoFrameRate")) { get_arg(arg, sizeof(arg), &p); if (stream) { AVRational frame_rate; if (av_parse_video_frame_rate(&frame_rate, arg) < 0) { fprintf(stderr, "Incorrect frame rate\n"); errors++; } else { video_enc.time_base.num = frame_rate.den; video_enc.time_base.den = frame_rate.num; } } } else if (!strcasecmp(cmd, "VideoGopSize")) { get_arg(arg, sizeof(arg), &p); if (stream) video_enc.gop_size = atoi(arg); } else if (!strcasecmp(cmd, "VideoIntraOnly")) { if (stream) video_enc.gop_size = 1; } else if (!strcasecmp(cmd, "VideoHighQuality")) { if (stream) video_enc.mb_decision = FF_MB_DECISION_BITS; } else if (!strcasecmp(cmd, "Video4MotionVector")) { if (stream) { video_enc.mb_decision = FF_MB_DECISION_BITS; //FIXME remove video_enc.flags |= CODEC_FLAG_4MV; } } else if (!strcasecmp(cmd, "AVOptionVideo") || !strcasecmp(cmd, "AVOptionAudio")) { char arg2[1024]; AVCodecContext *avctx; int type; get_arg(arg, sizeof(arg), &p); get_arg(arg2, sizeof(arg2), &p); if (!strcasecmp(cmd, "AVOptionVideo")) { avctx = &video_enc; type = AV_OPT_FLAG_VIDEO_PARAM; } else { avctx = &audio_enc; type = AV_OPT_FLAG_AUDIO_PARAM; } if (ffserver_opt_default(arg, arg2, avctx, type|AV_OPT_FLAG_ENCODING_PARAM)) { fprintf(stderr, "AVOption error: %s %s\n", arg, arg2); errors++; } } else if (!strcasecmp(cmd, "VideoTag")) { get_arg(arg, sizeof(arg), &p); if ((strlen(arg) == 4) && stream) video_enc.codec_tag = AV_RL32(arg); } else if (!strcasecmp(cmd, "BitExact")) { if (stream) video_enc.flags |= CODEC_FLAG_BITEXACT; } else if (!strcasecmp(cmd, "DctFastint")) { if (stream) video_enc.dct_algo = FF_DCT_FASTINT; } else if (!strcasecmp(cmd, "IdctSimple")) { if (stream) video_enc.idct_algo = FF_IDCT_SIMPLE; } else if (!strcasecmp(cmd, "Qscale")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.flags |= CODEC_FLAG_QSCALE; video_enc.global_quality = FF_QP2LAMBDA * atoi(arg); } } else if (!strcasecmp(cmd, "VideoQDiff")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.max_qdiff = atoi(arg); if (video_enc.max_qdiff < 1 || video_enc.max_qdiff > 31) { fprintf(stderr, "%s:%d: VideoQDiff out of range\n", filename, line_num); errors++; } } } else if (!strcasecmp(cmd, "VideoQMax")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.qmax = atoi(arg); if (video_enc.qmax < 1 || video_enc.qmax > 31) { fprintf(stderr, "%s:%d: VideoQMax out of range\n", filename, line_num); errors++; } } } else if (!strcasecmp(cmd, "VideoQMin")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.qmin = atoi(arg); if (video_enc.qmin < 1 || video_enc.qmin > 31) { fprintf(stderr, "%s:%d: VideoQMin out of range\n", filename, line_num); errors++; } } } else if (!strcasecmp(cmd, "LumaElim")) { get_arg(arg, sizeof(arg), &p); if (stream) video_enc.luma_elim_threshold = atoi(arg); } else if (!strcasecmp(cmd, "ChromaElim")) { get_arg(arg, sizeof(arg), &p); if (stream) video_enc.chroma_elim_threshold = atoi(arg); } else if (!strcasecmp(cmd, "LumiMask")) { get_arg(arg, sizeof(arg), &p); if (stream) video_enc.lumi_masking = atof(arg); } else if (!strcasecmp(cmd, "DarkMask")) { get_arg(arg, sizeof(arg), &p); if (stream) video_enc.dark_masking = atof(arg); } else if (!strcasecmp(cmd, "NoVideo")) { video_id = CODEC_ID_NONE; } else if (!strcasecmp(cmd, "NoAudio")) { audio_id = CODEC_ID_NONE; } else if (!strcasecmp(cmd, "ACL")) { IPAddressACL acl; get_arg(arg, sizeof(arg), &p); if (strcasecmp(arg, "allow") == 0) acl.action = IP_ALLOW; else if (strcasecmp(arg, "deny") == 0) acl.action = IP_DENY; else { fprintf(stderr, "%s:%d: ACL action '%s' is not ALLOW or DENY\n", filename, line_num, arg); errors++; } get_arg(arg, sizeof(arg), &p); if (resolve_host(&acl.first, arg) != 0) { fprintf(stderr, "%s:%d: ACL refers to invalid host or ip address '%s'\n", filename, line_num, arg); errors++; } else acl.last = acl.first; get_arg(arg, sizeof(arg), &p); if (arg[0]) { if (resolve_host(&acl.last, arg) != 0) { fprintf(stderr, "%s:%d: ACL refers to invalid host or ip address '%s'\n", filename, line_num, arg); errors++; } } if (!errors) { IPAddressACL *nacl = av_mallocz(sizeof(*nacl)); IPAddressACL **naclp = 0; acl.next = 0; *nacl = acl; if (stream) naclp = &stream->acl; else if (feed) naclp = &feed->acl; else { fprintf(stderr, "%s:%d: ACL found not in <stream> or <feed>\n", filename, line_num); errors++; } if (naclp) { while (*naclp) naclp = &(*naclp)->next; *naclp = nacl; } } } else if (!strcasecmp(cmd, "RTSPOption")) { get_arg(arg, sizeof(arg), &p); if (stream) { av_freep(&stream->rtsp_option); stream->rtsp_option = av_strdup(arg); } } else if (!strcasecmp(cmd, "MulticastAddress")) { get_arg(arg, sizeof(arg), &p); if (stream) { if (resolve_host(&stream->multicast_ip, arg) != 0) { fprintf(stderr, "%s:%d: Invalid host/IP address: %s\n", filename, line_num, arg); errors++; } stream->is_multicast = 1; stream->loop = 1; /* default is looping */ } } else if (!strcasecmp(cmd, "MulticastPort")) { get_arg(arg, sizeof(arg), &p); if (stream) stream->multicast_port = atoi(arg); } else if (!strcasecmp(cmd, "MulticastTTL")) { get_arg(arg, sizeof(arg), &p); if (stream) stream->multicast_ttl = atoi(arg); } else if (!strcasecmp(cmd, "NoLoop")) { if (stream) stream->loop = 0; } else if (!strcasecmp(cmd, "</Stream>")) { if (!stream) { fprintf(stderr, "%s:%d: No corresponding <Stream> for </Stream>\n", filename, line_num); errors++; } else { if (stream->feed && stream->fmt && strcmp(stream->fmt->name, "ffm") != 0) { if (audio_id != CODEC_ID_NONE) { audio_enc.codec_type = CODEC_TYPE_AUDIO; audio_enc.codec_id = audio_id; add_codec(stream, &audio_enc); } if (video_id != CODEC_ID_NONE) { video_enc.codec_type = CODEC_TYPE_VIDEO; video_enc.codec_id = video_id; add_codec(stream, &video_enc); } } stream = NULL; } } else if (!strcasecmp(cmd, "<Redirect")) { /*********************************************/ char *q; if (stream || feed || redirect) { fprintf(stderr, "%s:%d: Already in a tag\n", filename, line_num); errors++; } else { redirect = av_mallocz(sizeof(FFStream)); *last_stream = redirect; last_stream = &redirect->next; get_arg(redirect->filename, sizeof(redirect->filename), &p); q = strrchr(redirect->filename, '>'); if (*q) *q = '\0'; redirect->stream_type = STREAM_TYPE_REDIRECT; } } else if (!strcasecmp(cmd, "URL")) { if (redirect) get_arg(redirect->feed_filename, sizeof(redirect->feed_filename), &p); } else if (!strcasecmp(cmd, "</Redirect>")) { if (!redirect) { fprintf(stderr, "%s:%d: No corresponding <Redirect> for </Redirect>\n", filename, line_num); errors++; } else { if (!redirect->feed_filename[0]) { fprintf(stderr, "%s:%d: No URL found for <Redirect>\n", filename, line_num); errors++; } redirect = NULL; } } else if (!strcasecmp(cmd, "LoadModule")) { get_arg(arg, sizeof(arg), &p); #if HAVE_DLOPEN load_module(arg); #else fprintf(stderr, "%s:%d: Module support not compiled into this version: '%s'\n", filename, line_num, arg); errors++; #endif } else { fprintf(stderr, "%s:%d: Incorrect keyword: '%s'\n", filename, line_num, cmd); } } fclose(f); if (errors) return -1; else return 0; }
false
FFmpeg
1642ee4337988523207ee8f30be9281e6919d95a
static int parse_ffconfig(const char *filename) { FILE *f; char line[1024]; char cmd[64]; char arg[1024]; const char *p; int val, errors, line_num; FFStream **last_stream, *stream, *redirect; FFStream **last_feed, *feed, *s; AVCodecContext audio_enc, video_enc; enum CodecID audio_id, video_id; f = fopen(filename, "r"); if (!f) { perror(filename); return -1; } errors = 0; line_num = 0; first_stream = NULL; last_stream = &first_stream; first_feed = NULL; last_feed = &first_feed; stream = NULL; feed = NULL; redirect = NULL; audio_id = CODEC_ID_NONE; video_id = CODEC_ID_NONE; for(;;) { if (fgets(line, sizeof(line), f) == NULL) break; line_num++; p = line; while (isspace(*p)) p++; if (*p == '\0' || *p == '#') continue; get_arg(cmd, sizeof(cmd), &p); if (!strcasecmp(cmd, "Port")) { get_arg(arg, sizeof(arg), &p); val = atoi(arg); if (val < 1 || val > 65536) { fprintf(stderr, "%s:%d: Invalid port: %s\n", filename, line_num, arg); errors++; } my_http_addr.sin_port = htons(val); } else if (!strcasecmp(cmd, "BindAddress")) { get_arg(arg, sizeof(arg), &p); if (resolve_host(&my_http_addr.sin_addr, arg) != 0) { fprintf(stderr, "%s:%d: Invalid host/IP address: %s\n", filename, line_num, arg); errors++; } } else if (!strcasecmp(cmd, "NoDaemon")) { ffserver_daemon = 0; } else if (!strcasecmp(cmd, "RTSPPort")) { get_arg(arg, sizeof(arg), &p); val = atoi(arg); if (val < 1 || val > 65536) { fprintf(stderr, "%s:%d: Invalid port: %s\n", filename, line_num, arg); errors++; } my_rtsp_addr.sin_port = htons(atoi(arg)); } else if (!strcasecmp(cmd, "RTSPBindAddress")) { get_arg(arg, sizeof(arg), &p); if (resolve_host(&my_rtsp_addr.sin_addr, arg) != 0) { fprintf(stderr, "%s:%d: Invalid host/IP address: %s\n", filename, line_num, arg); errors++; } } else if (!strcasecmp(cmd, "MaxHTTPConnections")) { get_arg(arg, sizeof(arg), &p); val = atoi(arg); if (val < 1 || val > 65536) { fprintf(stderr, "%s:%d: Invalid MaxHTTPConnections: %s\n", filename, line_num, arg); errors++; } nb_max_http_connections = val; } else if (!strcasecmp(cmd, "MaxClients")) { get_arg(arg, sizeof(arg), &p); val = atoi(arg); if (val < 1 || val > nb_max_http_connections) { fprintf(stderr, "%s:%d: Invalid MaxClients: %s\n", filename, line_num, arg); errors++; } else { nb_max_connections = val; } } else if (!strcasecmp(cmd, "MaxBandwidth")) { int64_t llval; get_arg(arg, sizeof(arg), &p); llval = atoll(arg); if (llval < 10 || llval > 10000000) { fprintf(stderr, "%s:%d: Invalid MaxBandwidth: %s\n", filename, line_num, arg); errors++; } else max_bandwidth = llval; } else if (!strcasecmp(cmd, "CustomLog")) { if (!ffserver_debug) get_arg(logfilename, sizeof(logfilename), &p); } else if (!strcasecmp(cmd, "<Feed")) { char *q; if (stream || feed) { fprintf(stderr, "%s:%d: Already in a tag\n", filename, line_num); } else { feed = av_mallocz(sizeof(FFStream)); get_arg(feed->filename, sizeof(feed->filename), &p); q = strrchr(feed->filename, '>'); if (*q) *q = '\0'; for (s = first_feed; s; s = s->next) { if (!strcmp(feed->filename, s->filename)) { fprintf(stderr, "%s:%d: Feed '%s' already registered\n", filename, line_num, s->filename); errors++; } } feed->fmt = guess_format("ffm", NULL, NULL); snprintf(feed->feed_filename, sizeof(feed->feed_filename), "/tmp/%s.ffm", feed->filename); feed->feed_max_size = 5 * 1024 * 1024; feed->is_feed = 1; feed->feed = feed; *last_stream = feed; last_stream = &feed->next; *last_feed = feed; last_feed = &feed->next_feed; } } else if (!strcasecmp(cmd, "Launch")) { if (feed) { int i; feed->child_argv = av_mallocz(64 * sizeof(char *)); for (i = 0; i < 62; i++) { get_arg(arg, sizeof(arg), &p); if (!arg[0]) break; feed->child_argv[i] = av_strdup(arg); } feed->child_argv[i] = av_malloc(30 + strlen(feed->filename)); snprintf(feed->child_argv[i], 30+strlen(feed->filename), "http: (my_http_addr.sin_addr.s_addr == INADDR_ANY) ? "127.0.0.1" : inet_ntoa(my_http_addr.sin_addr), ntohs(my_http_addr.sin_port), feed->filename); } } else if (!strcasecmp(cmd, "ReadOnlyFile")) { if (feed) { get_arg(feed->feed_filename, sizeof(feed->feed_filename), &p); feed->readonly = 1; } else if (stream) { get_arg(stream->feed_filename, sizeof(stream->feed_filename), &p); } } else if (!strcasecmp(cmd, "File")) { if (feed) { get_arg(feed->feed_filename, sizeof(feed->feed_filename), &p); } else if (stream) get_arg(stream->feed_filename, sizeof(stream->feed_filename), &p); } else if (!strcasecmp(cmd, "Truncate")) { if (feed) { get_arg(arg, sizeof(arg), &p); feed->truncate = strtod(arg, NULL); } } else if (!strcasecmp(cmd, "FileMaxSize")) { if (feed) { char *p1; double fsize; get_arg(arg, sizeof(arg), &p); p1 = arg; fsize = strtod(p1, &p1); switch(toupper(*p1)) { case 'K': fsize *= 1024; break; case 'M': fsize *= 1024 * 1024; break; case 'G': fsize *= 1024 * 1024 * 1024; break; } feed->feed_max_size = (int64_t)fsize; if (feed->feed_max_size < FFM_PACKET_SIZE*4) { fprintf(stderr, "%s:%d: Feed max file size is too small, " "must be at least %d\n", filename, line_num, FFM_PACKET_SIZE*4); errors++; } } } else if (!strcasecmp(cmd, "</Feed>")) { if (!feed) { fprintf(stderr, "%s:%d: No corresponding <Feed> for </Feed>\n", filename, line_num); errors++; } feed = NULL; } else if (!strcasecmp(cmd, "<Stream")) { char *q; if (stream || feed) { fprintf(stderr, "%s:%d: Already in a tag\n", filename, line_num); } else { FFStream *s; const AVClass *class; stream = av_mallocz(sizeof(FFStream)); get_arg(stream->filename, sizeof(stream->filename), &p); q = strrchr(stream->filename, '>'); if (*q) *q = '\0'; for (s = first_stream; s; s = s->next) { if (!strcmp(stream->filename, s->filename)) { fprintf(stderr, "%s:%d: Stream '%s' already registered\n", filename, line_num, s->filename); errors++; } } stream->fmt = guess_stream_format(NULL, stream->filename, NULL); avcodec_get_context_defaults(&video_enc); class = video_enc.av_class; memset(&audio_enc, 0, sizeof(AVCodecContext)); memset(&video_enc, 0, sizeof(AVCodecContext)); audio_enc.av_class = class; video_enc.av_class = class; audio_id = CODEC_ID_NONE; video_id = CODEC_ID_NONE; if (stream->fmt) { audio_id = stream->fmt->audio_codec; video_id = stream->fmt->video_codec; } *last_stream = stream; last_stream = &stream->next; } } else if (!strcasecmp(cmd, "Feed")) { get_arg(arg, sizeof(arg), &p); if (stream) { FFStream *sfeed; sfeed = first_feed; while (sfeed != NULL) { if (!strcmp(sfeed->filename, arg)) break; sfeed = sfeed->next_feed; } if (!sfeed) fprintf(stderr, "%s:%d: feed '%s' not defined\n", filename, line_num, arg); else stream->feed = sfeed; } } else if (!strcasecmp(cmd, "Format")) { get_arg(arg, sizeof(arg), &p); if (stream) { if (!strcmp(arg, "status")) { stream->stream_type = STREAM_TYPE_STATUS; stream->fmt = NULL; } else { stream->stream_type = STREAM_TYPE_LIVE; if (!strcmp(arg, "jpeg")) strcpy(arg, "mjpeg"); stream->fmt = guess_stream_format(arg, NULL, NULL); if (!stream->fmt) { fprintf(stderr, "%s:%d: Unknown Format: %s\n", filename, line_num, arg); errors++; } } if (stream->fmt) { audio_id = stream->fmt->audio_codec; video_id = stream->fmt->video_codec; } } } else if (!strcasecmp(cmd, "InputFormat")) { get_arg(arg, sizeof(arg), &p); if (stream) { stream->ifmt = av_find_input_format(arg); if (!stream->ifmt) { fprintf(stderr, "%s:%d: Unknown input format: %s\n", filename, line_num, arg); } } } else if (!strcasecmp(cmd, "FaviconURL")) { if (stream && stream->stream_type == STREAM_TYPE_STATUS) { get_arg(stream->feed_filename, sizeof(stream->feed_filename), &p); } else { fprintf(stderr, "%s:%d: FaviconURL only permitted for status streams\n", filename, line_num); errors++; } } else if (!strcasecmp(cmd, "Author")) { if (stream) get_arg(stream->author, sizeof(stream->author), &p); } else if (!strcasecmp(cmd, "Comment")) { if (stream) get_arg(stream->comment, sizeof(stream->comment), &p); } else if (!strcasecmp(cmd, "Copyright")) { if (stream) get_arg(stream->copyright, sizeof(stream->copyright), &p); } else if (!strcasecmp(cmd, "Title")) { if (stream) get_arg(stream->title, sizeof(stream->title), &p); } else if (!strcasecmp(cmd, "Preroll")) { get_arg(arg, sizeof(arg), &p); if (stream) stream->prebuffer = atof(arg) * 1000; } else if (!strcasecmp(cmd, "StartSendOnKey")) { if (stream) stream->send_on_key = 1; } else if (!strcasecmp(cmd, "AudioCodec")) { get_arg(arg, sizeof(arg), &p); audio_id = opt_audio_codec(arg); if (audio_id == CODEC_ID_NONE) { fprintf(stderr, "%s:%d: Unknown AudioCodec: %s\n", filename, line_num, arg); errors++; } } else if (!strcasecmp(cmd, "VideoCodec")) { get_arg(arg, sizeof(arg), &p); video_id = opt_video_codec(arg); if (video_id == CODEC_ID_NONE) { fprintf(stderr, "%s:%d: Unknown VideoCodec: %s\n", filename, line_num, arg); errors++; } } else if (!strcasecmp(cmd, "MaxTime")) { get_arg(arg, sizeof(arg), &p); if (stream) stream->max_time = atof(arg) * 1000; } else if (!strcasecmp(cmd, "AudioBitRate")) { get_arg(arg, sizeof(arg), &p); if (stream) audio_enc.bit_rate = atoi(arg) * 1000; } else if (!strcasecmp(cmd, "AudioChannels")) { get_arg(arg, sizeof(arg), &p); if (stream) audio_enc.channels = atoi(arg); } else if (!strcasecmp(cmd, "AudioSampleRate")) { get_arg(arg, sizeof(arg), &p); if (stream) audio_enc.sample_rate = atoi(arg); } else if (!strcasecmp(cmd, "AudioQuality")) { get_arg(arg, sizeof(arg), &p); if (stream) { } } else if (!strcasecmp(cmd, "VideoBitRateRange")) { if (stream) { int minrate, maxrate; get_arg(arg, sizeof(arg), &p); if (sscanf(arg, "%d-%d", &minrate, &maxrate) == 2) { video_enc.rc_min_rate = minrate * 1000; video_enc.rc_max_rate = maxrate * 1000; } else { fprintf(stderr, "%s:%d: Incorrect format for VideoBitRateRange -- should be <min>-<max>: %s\n", filename, line_num, arg); errors++; } } } else if (!strcasecmp(cmd, "Debug")) { if (stream) { get_arg(arg, sizeof(arg), &p); video_enc.debug = strtol(arg,0,0); } } else if (!strcasecmp(cmd, "Strict")) { if (stream) { get_arg(arg, sizeof(arg), &p); video_enc.strict_std_compliance = atoi(arg); } } else if (!strcasecmp(cmd, "VideoBufferSize")) { if (stream) { get_arg(arg, sizeof(arg), &p); video_enc.rc_buffer_size = atoi(arg) * 8*1024; } } else if (!strcasecmp(cmd, "VideoBitRateTolerance")) { if (stream) { get_arg(arg, sizeof(arg), &p); video_enc.bit_rate_tolerance = atoi(arg) * 1000; } } else if (!strcasecmp(cmd, "VideoBitRate")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.bit_rate = atoi(arg) * 1000; } } else if (!strcasecmp(cmd, "VideoSize")) { get_arg(arg, sizeof(arg), &p); if (stream) { av_parse_video_frame_size(&video_enc.width, &video_enc.height, arg); if ((video_enc.width % 16) != 0 || (video_enc.height % 16) != 0) { fprintf(stderr, "%s:%d: Image size must be a multiple of 16\n", filename, line_num); errors++; } } } else if (!strcasecmp(cmd, "VideoFrameRate")) { get_arg(arg, sizeof(arg), &p); if (stream) { AVRational frame_rate; if (av_parse_video_frame_rate(&frame_rate, arg) < 0) { fprintf(stderr, "Incorrect frame rate\n"); errors++; } else { video_enc.time_base.num = frame_rate.den; video_enc.time_base.den = frame_rate.num; } } } else if (!strcasecmp(cmd, "VideoGopSize")) { get_arg(arg, sizeof(arg), &p); if (stream) video_enc.gop_size = atoi(arg); } else if (!strcasecmp(cmd, "VideoIntraOnly")) { if (stream) video_enc.gop_size = 1; } else if (!strcasecmp(cmd, "VideoHighQuality")) { if (stream) video_enc.mb_decision = FF_MB_DECISION_BITS; } else if (!strcasecmp(cmd, "Video4MotionVector")) { if (stream) { video_enc.mb_decision = FF_MB_DECISION_BITS; video_enc.flags |= CODEC_FLAG_4MV; } } else if (!strcasecmp(cmd, "AVOptionVideo") || !strcasecmp(cmd, "AVOptionAudio")) { char arg2[1024]; AVCodecContext *avctx; int type; get_arg(arg, sizeof(arg), &p); get_arg(arg2, sizeof(arg2), &p); if (!strcasecmp(cmd, "AVOptionVideo")) { avctx = &video_enc; type = AV_OPT_FLAG_VIDEO_PARAM; } else { avctx = &audio_enc; type = AV_OPT_FLAG_AUDIO_PARAM; } if (ffserver_opt_default(arg, arg2, avctx, type|AV_OPT_FLAG_ENCODING_PARAM)) { fprintf(stderr, "AVOption error: %s %s\n", arg, arg2); errors++; } } else if (!strcasecmp(cmd, "VideoTag")) { get_arg(arg, sizeof(arg), &p); if ((strlen(arg) == 4) && stream) video_enc.codec_tag = AV_RL32(arg); } else if (!strcasecmp(cmd, "BitExact")) { if (stream) video_enc.flags |= CODEC_FLAG_BITEXACT; } else if (!strcasecmp(cmd, "DctFastint")) { if (stream) video_enc.dct_algo = FF_DCT_FASTINT; } else if (!strcasecmp(cmd, "IdctSimple")) { if (stream) video_enc.idct_algo = FF_IDCT_SIMPLE; } else if (!strcasecmp(cmd, "Qscale")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.flags |= CODEC_FLAG_QSCALE; video_enc.global_quality = FF_QP2LAMBDA * atoi(arg); } } else if (!strcasecmp(cmd, "VideoQDiff")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.max_qdiff = atoi(arg); if (video_enc.max_qdiff < 1 || video_enc.max_qdiff > 31) { fprintf(stderr, "%s:%d: VideoQDiff out of range\n", filename, line_num); errors++; } } } else if (!strcasecmp(cmd, "VideoQMax")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.qmax = atoi(arg); if (video_enc.qmax < 1 || video_enc.qmax > 31) { fprintf(stderr, "%s:%d: VideoQMax out of range\n", filename, line_num); errors++; } } } else if (!strcasecmp(cmd, "VideoQMin")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.qmin = atoi(arg); if (video_enc.qmin < 1 || video_enc.qmin > 31) { fprintf(stderr, "%s:%d: VideoQMin out of range\n", filename, line_num); errors++; } } } else if (!strcasecmp(cmd, "LumaElim")) { get_arg(arg, sizeof(arg), &p); if (stream) video_enc.luma_elim_threshold = atoi(arg); } else if (!strcasecmp(cmd, "ChromaElim")) { get_arg(arg, sizeof(arg), &p); if (stream) video_enc.chroma_elim_threshold = atoi(arg); } else if (!strcasecmp(cmd, "LumiMask")) { get_arg(arg, sizeof(arg), &p); if (stream) video_enc.lumi_masking = atof(arg); } else if (!strcasecmp(cmd, "DarkMask")) { get_arg(arg, sizeof(arg), &p); if (stream) video_enc.dark_masking = atof(arg); } else if (!strcasecmp(cmd, "NoVideo")) { video_id = CODEC_ID_NONE; } else if (!strcasecmp(cmd, "NoAudio")) { audio_id = CODEC_ID_NONE; } else if (!strcasecmp(cmd, "ACL")) { IPAddressACL acl; get_arg(arg, sizeof(arg), &p); if (strcasecmp(arg, "allow") == 0) acl.action = IP_ALLOW; else if (strcasecmp(arg, "deny") == 0) acl.action = IP_DENY; else { fprintf(stderr, "%s:%d: ACL action '%s' is not ALLOW or DENY\n", filename, line_num, arg); errors++; } get_arg(arg, sizeof(arg), &p); if (resolve_host(&acl.first, arg) != 0) { fprintf(stderr, "%s:%d: ACL refers to invalid host or ip address '%s'\n", filename, line_num, arg); errors++; } else acl.last = acl.first; get_arg(arg, sizeof(arg), &p); if (arg[0]) { if (resolve_host(&acl.last, arg) != 0) { fprintf(stderr, "%s:%d: ACL refers to invalid host or ip address '%s'\n", filename, line_num, arg); errors++; } } if (!errors) { IPAddressACL *nacl = av_mallocz(sizeof(*nacl)); IPAddressACL **naclp = 0; acl.next = 0; *nacl = acl; if (stream) naclp = &stream->acl; else if (feed) naclp = &feed->acl; else { fprintf(stderr, "%s:%d: ACL found not in <stream> or <feed>\n", filename, line_num); errors++; } if (naclp) { while (*naclp) naclp = &(*naclp)->next; *naclp = nacl; } } } else if (!strcasecmp(cmd, "RTSPOption")) { get_arg(arg, sizeof(arg), &p); if (stream) { av_freep(&stream->rtsp_option); stream->rtsp_option = av_strdup(arg); } } else if (!strcasecmp(cmd, "MulticastAddress")) { get_arg(arg, sizeof(arg), &p); if (stream) { if (resolve_host(&stream->multicast_ip, arg) != 0) { fprintf(stderr, "%s:%d: Invalid host/IP address: %s\n", filename, line_num, arg); errors++; } stream->is_multicast = 1; stream->loop = 1; } } else if (!strcasecmp(cmd, "MulticastPort")) { get_arg(arg, sizeof(arg), &p); if (stream) stream->multicast_port = atoi(arg); } else if (!strcasecmp(cmd, "MulticastTTL")) { get_arg(arg, sizeof(arg), &p); if (stream) stream->multicast_ttl = atoi(arg); } else if (!strcasecmp(cmd, "NoLoop")) { if (stream) stream->loop = 0; } else if (!strcasecmp(cmd, "</Stream>")) { if (!stream) { fprintf(stderr, "%s:%d: No corresponding <Stream> for </Stream>\n", filename, line_num); errors++; } else { if (stream->feed && stream->fmt && strcmp(stream->fmt->name, "ffm") != 0) { if (audio_id != CODEC_ID_NONE) { audio_enc.codec_type = CODEC_TYPE_AUDIO; audio_enc.codec_id = audio_id; add_codec(stream, &audio_enc); } if (video_id != CODEC_ID_NONE) { video_enc.codec_type = CODEC_TYPE_VIDEO; video_enc.codec_id = video_id; add_codec(stream, &video_enc); } } stream = NULL; } } else if (!strcasecmp(cmd, "<Redirect")) { char *q; if (stream || feed || redirect) { fprintf(stderr, "%s:%d: Already in a tag\n", filename, line_num); errors++; } else { redirect = av_mallocz(sizeof(FFStream)); *last_stream = redirect; last_stream = &redirect->next; get_arg(redirect->filename, sizeof(redirect->filename), &p); q = strrchr(redirect->filename, '>'); if (*q) *q = '\0'; redirect->stream_type = STREAM_TYPE_REDIRECT; } } else if (!strcasecmp(cmd, "URL")) { if (redirect) get_arg(redirect->feed_filename, sizeof(redirect->feed_filename), &p); } else if (!strcasecmp(cmd, "</Redirect>")) { if (!redirect) { fprintf(stderr, "%s:%d: No corresponding <Redirect> for </Redirect>\n", filename, line_num); errors++; } else { if (!redirect->feed_filename[0]) { fprintf(stderr, "%s:%d: No URL found for <Redirect>\n", filename, line_num); errors++; } redirect = NULL; } } else if (!strcasecmp(cmd, "LoadModule")) { get_arg(arg, sizeof(arg), &p); #if HAVE_DLOPEN load_module(arg); #else fprintf(stderr, "%s:%d: Module support not compiled into this version: '%s'\n", filename, line_num, arg); errors++; #endif } else { fprintf(stderr, "%s:%d: Incorrect keyword: '%s'\n", filename, line_num, cmd); } } fclose(f); if (errors) return -1; else return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(const char *VAR_0) { FILE *f; char VAR_1[1024]; char VAR_2[64]; char VAR_3[1024]; const char *VAR_4; int VAR_5, VAR_6, VAR_7; FFStream **last_stream, *stream, *redirect; FFStream **last_feed, *feed, *s; AVCodecContext audio_enc, video_enc; enum CodecID VAR_8, VAR_9; f = fopen(VAR_0, "r"); if (!f) { perror(VAR_0); return -1; } VAR_6 = 0; VAR_7 = 0; first_stream = NULL; last_stream = &first_stream; first_feed = NULL; last_feed = &first_feed; stream = NULL; feed = NULL; redirect = NULL; VAR_8 = CODEC_ID_NONE; VAR_9 = CODEC_ID_NONE; for(;;) { if (fgets(VAR_1, sizeof(VAR_1), f) == NULL) break; VAR_7++; VAR_4 = VAR_1; while (isspace(*VAR_4)) VAR_4++; if (*VAR_4 == '\0' || *VAR_4 == '#') continue; get_arg(VAR_2, sizeof(VAR_2), &VAR_4); if (!strcasecmp(VAR_2, "Port")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); VAR_5 = atoi(VAR_3); if (VAR_5 < 1 || VAR_5 > 65536) { fprintf(stderr, "%s:%d: Invalid port: %s\n", VAR_0, VAR_7, VAR_3); VAR_6++; } my_http_addr.sin_port = htons(VAR_5); } else if (!strcasecmp(VAR_2, "BindAddress")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (resolve_host(&my_http_addr.sin_addr, VAR_3) != 0) { fprintf(stderr, "%s:%d: Invalid host/IP address: %s\n", VAR_0, VAR_7, VAR_3); VAR_6++; } } else if (!strcasecmp(VAR_2, "NoDaemon")) { ffserver_daemon = 0; } else if (!strcasecmp(VAR_2, "RTSPPort")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); VAR_5 = atoi(VAR_3); if (VAR_5 < 1 || VAR_5 > 65536) { fprintf(stderr, "%s:%d: Invalid port: %s\n", VAR_0, VAR_7, VAR_3); VAR_6++; } my_rtsp_addr.sin_port = htons(atoi(VAR_3)); } else if (!strcasecmp(VAR_2, "RTSPBindAddress")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (resolve_host(&my_rtsp_addr.sin_addr, VAR_3) != 0) { fprintf(stderr, "%s:%d: Invalid host/IP address: %s\n", VAR_0, VAR_7, VAR_3); VAR_6++; } } else if (!strcasecmp(VAR_2, "MaxHTTPConnections")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); VAR_5 = atoi(VAR_3); if (VAR_5 < 1 || VAR_5 > 65536) { fprintf(stderr, "%s:%d: Invalid MaxHTTPConnections: %s\n", VAR_0, VAR_7, VAR_3); VAR_6++; } nb_max_http_connections = VAR_5; } else if (!strcasecmp(VAR_2, "MaxClients")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); VAR_5 = atoi(VAR_3); if (VAR_5 < 1 || VAR_5 > nb_max_http_connections) { fprintf(stderr, "%s:%d: Invalid MaxClients: %s\n", VAR_0, VAR_7, VAR_3); VAR_6++; } else { nb_max_connections = VAR_5; } } else if (!strcasecmp(VAR_2, "MaxBandwidth")) { int64_t llval; get_arg(VAR_3, sizeof(VAR_3), &VAR_4); llval = atoll(VAR_3); if (llval < 10 || llval > 10000000) { fprintf(stderr, "%s:%d: Invalid MaxBandwidth: %s\n", VAR_0, VAR_7, VAR_3); VAR_6++; } else max_bandwidth = llval; } else if (!strcasecmp(VAR_2, "CustomLog")) { if (!ffserver_debug) get_arg(logfilename, sizeof(logfilename), &VAR_4); } else if (!strcasecmp(VAR_2, "<Feed")) { char *VAR_19; if (stream || feed) { fprintf(stderr, "%s:%d: Already in a tag\n", VAR_0, VAR_7); } else { feed = av_mallocz(sizeof(FFStream)); get_arg(feed->VAR_0, sizeof(feed->VAR_0), &VAR_4); VAR_19 = strrchr(feed->VAR_0, '>'); if (*VAR_19) *VAR_19 = '\0'; for (s = first_feed; s; s = s->next) { if (!strcmp(feed->VAR_0, s->VAR_0)) { fprintf(stderr, "%s:%d: Feed '%s' already registered\n", VAR_0, VAR_7, s->VAR_0); VAR_6++; } } feed->fmt = guess_format("ffm", NULL, NULL); snprintf(feed->feed_filename, sizeof(feed->feed_filename), "/tmp/%s.ffm", feed->VAR_0); feed->feed_max_size = 5 * 1024 * 1024; feed->is_feed = 1; feed->feed = feed; *last_stream = feed; last_stream = &feed->next; *last_feed = feed; last_feed = &feed->next_feed; } } else if (!strcasecmp(VAR_2, "Launch")) { if (feed) { int VAR_11; feed->child_argv = av_mallocz(64 * sizeof(char *)); for (VAR_11 = 0; VAR_11 < 62; VAR_11++) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (!VAR_3[0]) break; feed->child_argv[VAR_11] = av_strdup(VAR_3); } feed->child_argv[VAR_11] = av_malloc(30 + strlen(feed->VAR_0)); snprintf(feed->child_argv[VAR_11], 30+strlen(feed->VAR_0), "http: (my_http_addr.sin_addr.s_addr == INADDR_ANY) ? "127.0.0.1" : inet_ntoa(my_http_addr.sin_addr), ntohs(my_http_addr.sin_port), feed->VAR_0); } } else if (!strcasecmp(VAR_2, "ReadOnlyFile")) { if (feed) { get_arg(feed->feed_filename, sizeof(feed->feed_filename), &VAR_4); feed->readonly = 1; } else if (stream) { get_arg(stream->feed_filename, sizeof(stream->feed_filename), &VAR_4); } } else if (!strcasecmp(VAR_2, "File")) { if (feed) { get_arg(feed->feed_filename, sizeof(feed->feed_filename), &VAR_4); } else if (stream) get_arg(stream->feed_filename, sizeof(stream->feed_filename), &VAR_4); } else if (!strcasecmp(VAR_2, "Truncate")) { if (feed) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); feed->truncate = strtod(VAR_3, NULL); } } else if (!strcasecmp(VAR_2, "FileMaxSize")) { if (feed) { char *VAR_12; double VAR_13; get_arg(VAR_3, sizeof(VAR_3), &VAR_4); VAR_12 = VAR_3; VAR_13 = strtod(VAR_12, &VAR_12); switch(toupper(*VAR_12)) { case 'K': VAR_13 *= 1024; break; case 'M': VAR_13 *= 1024 * 1024; break; case 'G': VAR_13 *= 1024 * 1024 * 1024; break; } feed->feed_max_size = (int64_t)VAR_13; if (feed->feed_max_size < FFM_PACKET_SIZE*4) { fprintf(stderr, "%s:%d: Feed max file size is too small, " "must be at least %d\n", VAR_0, VAR_7, FFM_PACKET_SIZE*4); VAR_6++; } } } else if (!strcasecmp(VAR_2, "</Feed>")) { if (!feed) { fprintf(stderr, "%s:%d: No corresponding <Feed> for </Feed>\n", VAR_0, VAR_7); VAR_6++; } feed = NULL; } else if (!strcasecmp(VAR_2, "<Stream")) { char *VAR_19; if (stream || feed) { fprintf(stderr, "%s:%d: Already in a tag\n", VAR_0, VAR_7); } else { FFStream *s; const AVClass *VAR_14; stream = av_mallocz(sizeof(FFStream)); get_arg(stream->VAR_0, sizeof(stream->VAR_0), &VAR_4); VAR_19 = strrchr(stream->VAR_0, '>'); if (*VAR_19) *VAR_19 = '\0'; for (s = first_stream; s; s = s->next) { if (!strcmp(stream->VAR_0, s->VAR_0)) { fprintf(stderr, "%s:%d: Stream '%s' already registered\n", VAR_0, VAR_7, s->VAR_0); VAR_6++; } } stream->fmt = guess_stream_format(NULL, stream->VAR_0, NULL); avcodec_get_context_defaults(&video_enc); VAR_14 = video_enc.av_class; memset(&audio_enc, 0, sizeof(AVCodecContext)); memset(&video_enc, 0, sizeof(AVCodecContext)); audio_enc.av_class = VAR_14; video_enc.av_class = VAR_14; VAR_8 = CODEC_ID_NONE; VAR_9 = CODEC_ID_NONE; if (stream->fmt) { VAR_8 = stream->fmt->audio_codec; VAR_9 = stream->fmt->video_codec; } *last_stream = stream; last_stream = &stream->next; } } else if (!strcasecmp(VAR_2, "Feed")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { FFStream *sfeed; sfeed = first_feed; while (sfeed != NULL) { if (!strcmp(sfeed->VAR_0, VAR_3)) break; sfeed = sfeed->next_feed; } if (!sfeed) fprintf(stderr, "%s:%d: feed '%s' not defined\n", VAR_0, VAR_7, VAR_3); else stream->feed = sfeed; } } else if (!strcasecmp(VAR_2, "Format")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { if (!strcmp(VAR_3, "status")) { stream->stream_type = STREAM_TYPE_STATUS; stream->fmt = NULL; } else { stream->stream_type = STREAM_TYPE_LIVE; if (!strcmp(VAR_3, "jpeg")) strcpy(VAR_3, "mjpeg"); stream->fmt = guess_stream_format(VAR_3, NULL, NULL); if (!stream->fmt) { fprintf(stderr, "%s:%d: Unknown Format: %s\n", VAR_0, VAR_7, VAR_3); VAR_6++; } } if (stream->fmt) { VAR_8 = stream->fmt->audio_codec; VAR_9 = stream->fmt->video_codec; } } } else if (!strcasecmp(VAR_2, "InputFormat")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { stream->ifmt = av_find_input_format(VAR_3); if (!stream->ifmt) { fprintf(stderr, "%s:%d: Unknown input format: %s\n", VAR_0, VAR_7, VAR_3); } } } else if (!strcasecmp(VAR_2, "FaviconURL")) { if (stream && stream->stream_type == STREAM_TYPE_STATUS) { get_arg(stream->feed_filename, sizeof(stream->feed_filename), &VAR_4); } else { fprintf(stderr, "%s:%d: FaviconURL only permitted for status streams\n", VAR_0, VAR_7); VAR_6++; } } else if (!strcasecmp(VAR_2, "Author")) { if (stream) get_arg(stream->author, sizeof(stream->author), &VAR_4); } else if (!strcasecmp(VAR_2, "Comment")) { if (stream) get_arg(stream->comment, sizeof(stream->comment), &VAR_4); } else if (!strcasecmp(VAR_2, "Copyright")) { if (stream) get_arg(stream->copyright, sizeof(stream->copyright), &VAR_4); } else if (!strcasecmp(VAR_2, "Title")) { if (stream) get_arg(stream->title, sizeof(stream->title), &VAR_4); } else if (!strcasecmp(VAR_2, "Preroll")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) stream->prebuffer = atof(VAR_3) * 1000; } else if (!strcasecmp(VAR_2, "StartSendOnKey")) { if (stream) stream->send_on_key = 1; } else if (!strcasecmp(VAR_2, "AudioCodec")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); VAR_8 = opt_audio_codec(VAR_3); if (VAR_8 == CODEC_ID_NONE) { fprintf(stderr, "%s:%d: Unknown AudioCodec: %s\n", VAR_0, VAR_7, VAR_3); VAR_6++; } } else if (!strcasecmp(VAR_2, "VideoCodec")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); VAR_9 = opt_video_codec(VAR_3); if (VAR_9 == CODEC_ID_NONE) { fprintf(stderr, "%s:%d: Unknown VideoCodec: %s\n", VAR_0, VAR_7, VAR_3); VAR_6++; } } else if (!strcasecmp(VAR_2, "MaxTime")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) stream->max_time = atof(VAR_3) * 1000; } else if (!strcasecmp(VAR_2, "AudioBitRate")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) audio_enc.bit_rate = atoi(VAR_3) * 1000; } else if (!strcasecmp(VAR_2, "AudioChannels")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) audio_enc.channels = atoi(VAR_3); } else if (!strcasecmp(VAR_2, "AudioSampleRate")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) audio_enc.sample_rate = atoi(VAR_3); } else if (!strcasecmp(VAR_2, "AudioQuality")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { } } else if (!strcasecmp(VAR_2, "VideoBitRateRange")) { if (stream) { int VAR_15, VAR_16; get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (sscanf(VAR_3, "%d-%d", &VAR_15, &VAR_16) == 2) { video_enc.rc_min_rate = VAR_15 * 1000; video_enc.rc_max_rate = VAR_16 * 1000; } else { fprintf(stderr, "%s:%d: Incorrect format for VideoBitRateRange -- should be <min>-<max>: %s\n", VAR_0, VAR_7, VAR_3); VAR_6++; } } } else if (!strcasecmp(VAR_2, "Debug")) { if (stream) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); video_enc.debug = strtol(VAR_3,0,0); } } else if (!strcasecmp(VAR_2, "Strict")) { if (stream) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); video_enc.strict_std_compliance = atoi(VAR_3); } } else if (!strcasecmp(VAR_2, "VideoBufferSize")) { if (stream) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); video_enc.rc_buffer_size = atoi(VAR_3) * 8*1024; } } else if (!strcasecmp(VAR_2, "VideoBitRateTolerance")) { if (stream) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); video_enc.bit_rate_tolerance = atoi(VAR_3) * 1000; } } else if (!strcasecmp(VAR_2, "VideoBitRate")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { video_enc.bit_rate = atoi(VAR_3) * 1000; } } else if (!strcasecmp(VAR_2, "VideoSize")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { av_parse_video_frame_size(&video_enc.width, &video_enc.height, VAR_3); if ((video_enc.width % 16) != 0 || (video_enc.height % 16) != 0) { fprintf(stderr, "%s:%d: Image size must be a multiple of 16\n", VAR_0, VAR_7); VAR_6++; } } } else if (!strcasecmp(VAR_2, "VideoFrameRate")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { AVRational frame_rate; if (av_parse_video_frame_rate(&frame_rate, VAR_3) < 0) { fprintf(stderr, "Incorrect frame rate\n"); VAR_6++; } else { video_enc.time_base.num = frame_rate.den; video_enc.time_base.den = frame_rate.num; } } } else if (!strcasecmp(VAR_2, "VideoGopSize")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) video_enc.gop_size = atoi(VAR_3); } else if (!strcasecmp(VAR_2, "VideoIntraOnly")) { if (stream) video_enc.gop_size = 1; } else if (!strcasecmp(VAR_2, "VideoHighQuality")) { if (stream) video_enc.mb_decision = FF_MB_DECISION_BITS; } else if (!strcasecmp(VAR_2, "Video4MotionVector")) { if (stream) { video_enc.mb_decision = FF_MB_DECISION_BITS; video_enc.flags |= CODEC_FLAG_4MV; } } else if (!strcasecmp(VAR_2, "AVOptionVideo") || !strcasecmp(VAR_2, "AVOptionAudio")) { char VAR_17[1024]; AVCodecContext *avctx; int VAR_18; get_arg(VAR_3, sizeof(VAR_3), &VAR_4); get_arg(VAR_17, sizeof(VAR_17), &VAR_4); if (!strcasecmp(VAR_2, "AVOptionVideo")) { avctx = &video_enc; VAR_18 = AV_OPT_FLAG_VIDEO_PARAM; } else { avctx = &audio_enc; VAR_18 = AV_OPT_FLAG_AUDIO_PARAM; } if (ffserver_opt_default(VAR_3, VAR_17, avctx, VAR_18|AV_OPT_FLAG_ENCODING_PARAM)) { fprintf(stderr, "AVOption error: %s %s\n", VAR_3, VAR_17); VAR_6++; } } else if (!strcasecmp(VAR_2, "VideoTag")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if ((strlen(VAR_3) == 4) && stream) video_enc.codec_tag = AV_RL32(VAR_3); } else if (!strcasecmp(VAR_2, "BitExact")) { if (stream) video_enc.flags |= CODEC_FLAG_BITEXACT; } else if (!strcasecmp(VAR_2, "DctFastint")) { if (stream) video_enc.dct_algo = FF_DCT_FASTINT; } else if (!strcasecmp(VAR_2, "IdctSimple")) { if (stream) video_enc.idct_algo = FF_IDCT_SIMPLE; } else if (!strcasecmp(VAR_2, "Qscale")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { video_enc.flags |= CODEC_FLAG_QSCALE; video_enc.global_quality = FF_QP2LAMBDA * atoi(VAR_3); } } else if (!strcasecmp(VAR_2, "VideoQDiff")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { video_enc.max_qdiff = atoi(VAR_3); if (video_enc.max_qdiff < 1 || video_enc.max_qdiff > 31) { fprintf(stderr, "%s:%d: VideoQDiff out of range\n", VAR_0, VAR_7); VAR_6++; } } } else if (!strcasecmp(VAR_2, "VideoQMax")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { video_enc.qmax = atoi(VAR_3); if (video_enc.qmax < 1 || video_enc.qmax > 31) { fprintf(stderr, "%s:%d: VideoQMax out of range\n", VAR_0, VAR_7); VAR_6++; } } } else if (!strcasecmp(VAR_2, "VideoQMin")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { video_enc.qmin = atoi(VAR_3); if (video_enc.qmin < 1 || video_enc.qmin > 31) { fprintf(stderr, "%s:%d: VideoQMin out of range\n", VAR_0, VAR_7); VAR_6++; } } } else if (!strcasecmp(VAR_2, "LumaElim")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) video_enc.luma_elim_threshold = atoi(VAR_3); } else if (!strcasecmp(VAR_2, "ChromaElim")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) video_enc.chroma_elim_threshold = atoi(VAR_3); } else if (!strcasecmp(VAR_2, "LumiMask")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) video_enc.lumi_masking = atof(VAR_3); } else if (!strcasecmp(VAR_2, "DarkMask")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) video_enc.dark_masking = atof(VAR_3); } else if (!strcasecmp(VAR_2, "NoVideo")) { VAR_9 = CODEC_ID_NONE; } else if (!strcasecmp(VAR_2, "NoAudio")) { VAR_8 = CODEC_ID_NONE; } else if (!strcasecmp(VAR_2, "ACL")) { IPAddressACL acl; get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (strcasecmp(VAR_3, "allow") == 0) acl.action = IP_ALLOW; else if (strcasecmp(VAR_3, "deny") == 0) acl.action = IP_DENY; else { fprintf(stderr, "%s:%d: ACL action '%s' is not ALLOW or DENY\n", VAR_0, VAR_7, VAR_3); VAR_6++; } get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (resolve_host(&acl.first, VAR_3) != 0) { fprintf(stderr, "%s:%d: ACL refers to invalid host or ip address '%s'\n", VAR_0, VAR_7, VAR_3); VAR_6++; } else acl.last = acl.first; get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (VAR_3[0]) { if (resolve_host(&acl.last, VAR_3) != 0) { fprintf(stderr, "%s:%d: ACL refers to invalid host or ip address '%s'\n", VAR_0, VAR_7, VAR_3); VAR_6++; } } if (!VAR_6) { IPAddressACL *nacl = av_mallocz(sizeof(*nacl)); IPAddressACL **naclp = 0; acl.next = 0; *nacl = acl; if (stream) naclp = &stream->acl; else if (feed) naclp = &feed->acl; else { fprintf(stderr, "%s:%d: ACL found not in <stream> or <feed>\n", VAR_0, VAR_7); VAR_6++; } if (naclp) { while (*naclp) naclp = &(*naclp)->next; *naclp = nacl; } } } else if (!strcasecmp(VAR_2, "RTSPOption")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { av_freep(&stream->rtsp_option); stream->rtsp_option = av_strdup(VAR_3); } } else if (!strcasecmp(VAR_2, "MulticastAddress")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) { if (resolve_host(&stream->multicast_ip, VAR_3) != 0) { fprintf(stderr, "%s:%d: Invalid host/IP address: %s\n", VAR_0, VAR_7, VAR_3); VAR_6++; } stream->is_multicast = 1; stream->loop = 1; } } else if (!strcasecmp(VAR_2, "MulticastPort")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) stream->multicast_port = atoi(VAR_3); } else if (!strcasecmp(VAR_2, "MulticastTTL")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); if (stream) stream->multicast_ttl = atoi(VAR_3); } else if (!strcasecmp(VAR_2, "NoLoop")) { if (stream) stream->loop = 0; } else if (!strcasecmp(VAR_2, "</Stream>")) { if (!stream) { fprintf(stderr, "%s:%d: No corresponding <Stream> for </Stream>\n", VAR_0, VAR_7); VAR_6++; } else { if (stream->feed && stream->fmt && strcmp(stream->fmt->name, "ffm") != 0) { if (VAR_8 != CODEC_ID_NONE) { audio_enc.codec_type = CODEC_TYPE_AUDIO; audio_enc.codec_id = VAR_8; add_codec(stream, &audio_enc); } if (VAR_9 != CODEC_ID_NONE) { video_enc.codec_type = CODEC_TYPE_VIDEO; video_enc.codec_id = VAR_9; add_codec(stream, &video_enc); } } stream = NULL; } } else if (!strcasecmp(VAR_2, "<Redirect")) { char *VAR_19; if (stream || feed || redirect) { fprintf(stderr, "%s:%d: Already in a tag\n", VAR_0, VAR_7); VAR_6++; } else { redirect = av_mallocz(sizeof(FFStream)); *last_stream = redirect; last_stream = &redirect->next; get_arg(redirect->VAR_0, sizeof(redirect->VAR_0), &VAR_4); VAR_19 = strrchr(redirect->VAR_0, '>'); if (*VAR_19) *VAR_19 = '\0'; redirect->stream_type = STREAM_TYPE_REDIRECT; } } else if (!strcasecmp(VAR_2, "URL")) { if (redirect) get_arg(redirect->feed_filename, sizeof(redirect->feed_filename), &VAR_4); } else if (!strcasecmp(VAR_2, "</Redirect>")) { if (!redirect) { fprintf(stderr, "%s:%d: No corresponding <Redirect> for </Redirect>\n", VAR_0, VAR_7); VAR_6++; } else { if (!redirect->feed_filename[0]) { fprintf(stderr, "%s:%d: No URL found for <Redirect>\n", VAR_0, VAR_7); VAR_6++; } redirect = NULL; } } else if (!strcasecmp(VAR_2, "LoadModule")) { get_arg(VAR_3, sizeof(VAR_3), &VAR_4); #if HAVE_DLOPEN load_module(VAR_3); #else fprintf(stderr, "%s:%d: Module support not compiled into this version: '%s'\n", VAR_0, VAR_7, VAR_3); VAR_6++; #endif } else { fprintf(stderr, "%s:%d: Incorrect keyword: '%s'\n", VAR_0, VAR_7, VAR_2); } } fclose(f); if (VAR_6) return -1; else return 0; }
[ "static int FUNC_0(const char *VAR_0)\n{", "FILE *f;", "char VAR_1[1024];", "char VAR_2[64];", "char VAR_3[1024];", "const char *VAR_4;", "int VAR_5, VAR_6, VAR_7;", "FFStream **last_stream, *stream, *redirect;", "FFStream **last_feed, *feed, *s;", "AVCodecContext audio_enc, video_enc;", "enum CodecID VAR_8, VAR_9;", "f = fopen(VAR_0, \"r\");", "if (!f) {", "perror(VAR_0);", "return -1;", "}", "VAR_6 = 0;", "VAR_7 = 0;", "first_stream = NULL;", "last_stream = &first_stream;", "first_feed = NULL;", "last_feed = &first_feed;", "stream = NULL;", "feed = NULL;", "redirect = NULL;", "VAR_8 = CODEC_ID_NONE;", "VAR_9 = CODEC_ID_NONE;", "for(;;) {", "if (fgets(VAR_1, sizeof(VAR_1), f) == NULL)\nbreak;", "VAR_7++;", "VAR_4 = VAR_1;", "while (isspace(*VAR_4))\nVAR_4++;", "if (*VAR_4 == '\\0' || *VAR_4 == '#')\ncontinue;", "get_arg(VAR_2, sizeof(VAR_2), &VAR_4);", "if (!strcasecmp(VAR_2, \"Port\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "VAR_5 = atoi(VAR_3);", "if (VAR_5 < 1 || VAR_5 > 65536) {", "fprintf(stderr, \"%s:%d: Invalid port: %s\\n\",\nVAR_0, VAR_7, VAR_3);", "VAR_6++;", "}", "my_http_addr.sin_port = htons(VAR_5);", "} else if (!strcasecmp(VAR_2, \"BindAddress\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (resolve_host(&my_http_addr.sin_addr, VAR_3) != 0) {", "fprintf(stderr, \"%s:%d: Invalid host/IP address: %s\\n\",\nVAR_0, VAR_7, VAR_3);", "VAR_6++;", "}", "} else if (!strcasecmp(VAR_2, \"NoDaemon\")) {", "ffserver_daemon = 0;", "} else if (!strcasecmp(VAR_2, \"RTSPPort\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "VAR_5 = atoi(VAR_3);", "if (VAR_5 < 1 || VAR_5 > 65536) {", "fprintf(stderr, \"%s:%d: Invalid port: %s\\n\",\nVAR_0, VAR_7, VAR_3);", "VAR_6++;", "}", "my_rtsp_addr.sin_port = htons(atoi(VAR_3));", "} else if (!strcasecmp(VAR_2, \"RTSPBindAddress\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (resolve_host(&my_rtsp_addr.sin_addr, VAR_3) != 0) {", "fprintf(stderr, \"%s:%d: Invalid host/IP address: %s\\n\",\nVAR_0, VAR_7, VAR_3);", "VAR_6++;", "}", "} else if (!strcasecmp(VAR_2, \"MaxHTTPConnections\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "VAR_5 = atoi(VAR_3);", "if (VAR_5 < 1 || VAR_5 > 65536) {", "fprintf(stderr, \"%s:%d: Invalid MaxHTTPConnections: %s\\n\",\nVAR_0, VAR_7, VAR_3);", "VAR_6++;", "}", "nb_max_http_connections = VAR_5;", "} else if (!strcasecmp(VAR_2, \"MaxClients\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "VAR_5 = atoi(VAR_3);", "if (VAR_5 < 1 || VAR_5 > nb_max_http_connections) {", "fprintf(stderr, \"%s:%d: Invalid MaxClients: %s\\n\",\nVAR_0, VAR_7, VAR_3);", "VAR_6++;", "} else {", "nb_max_connections = VAR_5;", "}", "} else if (!strcasecmp(VAR_2, \"MaxBandwidth\")) {", "int64_t llval;", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "llval = atoll(VAR_3);", "if (llval < 10 || llval > 10000000) {", "fprintf(stderr, \"%s:%d: Invalid MaxBandwidth: %s\\n\",\nVAR_0, VAR_7, VAR_3);", "VAR_6++;", "} else", "max_bandwidth = llval;", "} else if (!strcasecmp(VAR_2, \"CustomLog\")) {", "if (!ffserver_debug)\nget_arg(logfilename, sizeof(logfilename), &VAR_4);", "} else if (!strcasecmp(VAR_2, \"<Feed\")) {", "char *VAR_19;", "if (stream || feed) {", "fprintf(stderr, \"%s:%d: Already in a tag\\n\",\nVAR_0, VAR_7);", "} else {", "feed = av_mallocz(sizeof(FFStream));", "get_arg(feed->VAR_0, sizeof(feed->VAR_0), &VAR_4);", "VAR_19 = strrchr(feed->VAR_0, '>');", "if (*VAR_19)\n*VAR_19 = '\\0';", "for (s = first_feed; s; s = s->next) {", "if (!strcmp(feed->VAR_0, s->VAR_0)) {", "fprintf(stderr, \"%s:%d: Feed '%s' already registered\\n\",\nVAR_0, VAR_7, s->VAR_0);", "VAR_6++;", "}", "}", "feed->fmt = guess_format(\"ffm\", NULL, NULL);", "snprintf(feed->feed_filename, sizeof(feed->feed_filename),\n\"/tmp/%s.ffm\", feed->VAR_0);", "feed->feed_max_size = 5 * 1024 * 1024;", "feed->is_feed = 1;", "feed->feed = feed;", "*last_stream = feed;", "last_stream = &feed->next;", "*last_feed = feed;", "last_feed = &feed->next_feed;", "}", "} else if (!strcasecmp(VAR_2, \"Launch\")) {", "if (feed) {", "int VAR_11;", "feed->child_argv = av_mallocz(64 * sizeof(char *));", "for (VAR_11 = 0; VAR_11 < 62; VAR_11++) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (!VAR_3[0])\nbreak;", "feed->child_argv[VAR_11] = av_strdup(VAR_3);", "}", "feed->child_argv[VAR_11] = av_malloc(30 + strlen(feed->VAR_0));", "snprintf(feed->child_argv[VAR_11], 30+strlen(feed->VAR_0),\n\"http:\n(my_http_addr.sin_addr.s_addr == INADDR_ANY) ? \"127.0.0.1\" :\ninet_ntoa(my_http_addr.sin_addr),\nntohs(my_http_addr.sin_port), feed->VAR_0);", "}", "} else if (!strcasecmp(VAR_2, \"ReadOnlyFile\")) {", "if (feed) {", "get_arg(feed->feed_filename, sizeof(feed->feed_filename), &VAR_4);", "feed->readonly = 1;", "} else if (stream) {", "get_arg(stream->feed_filename, sizeof(stream->feed_filename), &VAR_4);", "}", "} else if (!strcasecmp(VAR_2, \"File\")) {", "if (feed) {", "get_arg(feed->feed_filename, sizeof(feed->feed_filename), &VAR_4);", "} else if (stream)", "get_arg(stream->feed_filename, sizeof(stream->feed_filename), &VAR_4);", "} else if (!strcasecmp(VAR_2, \"Truncate\")) {", "if (feed) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "feed->truncate = strtod(VAR_3, NULL);", "}", "} else if (!strcasecmp(VAR_2, \"FileMaxSize\")) {", "if (feed) {", "char *VAR_12;", "double VAR_13;", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "VAR_12 = VAR_3;", "VAR_13 = strtod(VAR_12, &VAR_12);", "switch(toupper(*VAR_12)) {", "case 'K':\nVAR_13 *= 1024;", "break;", "case 'M':\nVAR_13 *= 1024 * 1024;", "break;", "case 'G':\nVAR_13 *= 1024 * 1024 * 1024;", "break;", "}", "feed->feed_max_size = (int64_t)VAR_13;", "if (feed->feed_max_size < FFM_PACKET_SIZE*4) {", "fprintf(stderr, \"%s:%d: Feed max file size is too small, \"\n\"must be at least %d\\n\", VAR_0, VAR_7, FFM_PACKET_SIZE*4);", "VAR_6++;", "}", "}", "} else if (!strcasecmp(VAR_2, \"</Feed>\")) {", "if (!feed) {", "fprintf(stderr, \"%s:%d: No corresponding <Feed> for </Feed>\\n\",\nVAR_0, VAR_7);", "VAR_6++;", "}", "feed = NULL;", "} else if (!strcasecmp(VAR_2, \"<Stream\")) {", "char *VAR_19;", "if (stream || feed) {", "fprintf(stderr, \"%s:%d: Already in a tag\\n\",\nVAR_0, VAR_7);", "} else {", "FFStream *s;", "const AVClass *VAR_14;", "stream = av_mallocz(sizeof(FFStream));", "get_arg(stream->VAR_0, sizeof(stream->VAR_0), &VAR_4);", "VAR_19 = strrchr(stream->VAR_0, '>');", "if (*VAR_19)\n*VAR_19 = '\\0';", "for (s = first_stream; s; s = s->next) {", "if (!strcmp(stream->VAR_0, s->VAR_0)) {", "fprintf(stderr, \"%s:%d: Stream '%s' already registered\\n\",\nVAR_0, VAR_7, s->VAR_0);", "VAR_6++;", "}", "}", "stream->fmt = guess_stream_format(NULL, stream->VAR_0, NULL);", "avcodec_get_context_defaults(&video_enc);", "VAR_14 = video_enc.av_class;", "memset(&audio_enc, 0, sizeof(AVCodecContext));", "memset(&video_enc, 0, sizeof(AVCodecContext));", "audio_enc.av_class = VAR_14;", "video_enc.av_class = VAR_14;", "VAR_8 = CODEC_ID_NONE;", "VAR_9 = CODEC_ID_NONE;", "if (stream->fmt) {", "VAR_8 = stream->fmt->audio_codec;", "VAR_9 = stream->fmt->video_codec;", "}", "*last_stream = stream;", "last_stream = &stream->next;", "}", "} else if (!strcasecmp(VAR_2, \"Feed\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "FFStream *sfeed;", "sfeed = first_feed;", "while (sfeed != NULL) {", "if (!strcmp(sfeed->VAR_0, VAR_3))\nbreak;", "sfeed = sfeed->next_feed;", "}", "if (!sfeed)\nfprintf(stderr, \"%s:%d: feed '%s' not defined\\n\",\nVAR_0, VAR_7, VAR_3);", "else\nstream->feed = sfeed;", "}", "} else if (!strcasecmp(VAR_2, \"Format\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "if (!strcmp(VAR_3, \"status\")) {", "stream->stream_type = STREAM_TYPE_STATUS;", "stream->fmt = NULL;", "} else {", "stream->stream_type = STREAM_TYPE_LIVE;", "if (!strcmp(VAR_3, \"jpeg\"))\nstrcpy(VAR_3, \"mjpeg\");", "stream->fmt = guess_stream_format(VAR_3, NULL, NULL);", "if (!stream->fmt) {", "fprintf(stderr, \"%s:%d: Unknown Format: %s\\n\",\nVAR_0, VAR_7, VAR_3);", "VAR_6++;", "}", "}", "if (stream->fmt) {", "VAR_8 = stream->fmt->audio_codec;", "VAR_9 = stream->fmt->video_codec;", "}", "}", "} else if (!strcasecmp(VAR_2, \"InputFormat\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "stream->ifmt = av_find_input_format(VAR_3);", "if (!stream->ifmt) {", "fprintf(stderr, \"%s:%d: Unknown input format: %s\\n\",\nVAR_0, VAR_7, VAR_3);", "}", "}", "} else if (!strcasecmp(VAR_2, \"FaviconURL\")) {", "if (stream && stream->stream_type == STREAM_TYPE_STATUS) {", "get_arg(stream->feed_filename, sizeof(stream->feed_filename), &VAR_4);", "} else {", "fprintf(stderr, \"%s:%d: FaviconURL only permitted for status streams\\n\",\nVAR_0, VAR_7);", "VAR_6++;", "}", "} else if (!strcasecmp(VAR_2, \"Author\")) {", "if (stream)\nget_arg(stream->author, sizeof(stream->author), &VAR_4);", "} else if (!strcasecmp(VAR_2, \"Comment\")) {", "if (stream)\nget_arg(stream->comment, sizeof(stream->comment), &VAR_4);", "} else if (!strcasecmp(VAR_2, \"Copyright\")) {", "if (stream)\nget_arg(stream->copyright, sizeof(stream->copyright), &VAR_4);", "} else if (!strcasecmp(VAR_2, \"Title\")) {", "if (stream)\nget_arg(stream->title, sizeof(stream->title), &VAR_4);", "} else if (!strcasecmp(VAR_2, \"Preroll\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream)\nstream->prebuffer = atof(VAR_3) * 1000;", "} else if (!strcasecmp(VAR_2, \"StartSendOnKey\")) {", "if (stream)\nstream->send_on_key = 1;", "} else if (!strcasecmp(VAR_2, \"AudioCodec\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "VAR_8 = opt_audio_codec(VAR_3);", "if (VAR_8 == CODEC_ID_NONE) {", "fprintf(stderr, \"%s:%d: Unknown AudioCodec: %s\\n\",\nVAR_0, VAR_7, VAR_3);", "VAR_6++;", "}", "} else if (!strcasecmp(VAR_2, \"VideoCodec\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "VAR_9 = opt_video_codec(VAR_3);", "if (VAR_9 == CODEC_ID_NONE) {", "fprintf(stderr, \"%s:%d: Unknown VideoCodec: %s\\n\",\nVAR_0, VAR_7, VAR_3);", "VAR_6++;", "}", "} else if (!strcasecmp(VAR_2, \"MaxTime\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream)\nstream->max_time = atof(VAR_3) * 1000;", "} else if (!strcasecmp(VAR_2, \"AudioBitRate\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream)\naudio_enc.bit_rate = atoi(VAR_3) * 1000;", "} else if (!strcasecmp(VAR_2, \"AudioChannels\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream)\naudio_enc.channels = atoi(VAR_3);", "} else if (!strcasecmp(VAR_2, \"AudioSampleRate\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream)\naudio_enc.sample_rate = atoi(VAR_3);", "} else if (!strcasecmp(VAR_2, \"AudioQuality\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "}", "} else if (!strcasecmp(VAR_2, \"VideoBitRateRange\")) {", "if (stream) {", "int VAR_15, VAR_16;", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (sscanf(VAR_3, \"%d-%d\", &VAR_15, &VAR_16) == 2) {", "video_enc.rc_min_rate = VAR_15 * 1000;", "video_enc.rc_max_rate = VAR_16 * 1000;", "} else {", "fprintf(stderr, \"%s:%d: Incorrect format for VideoBitRateRange -- should be <min>-<max>: %s\\n\",\nVAR_0, VAR_7, VAR_3);", "VAR_6++;", "}", "}", "} else if (!strcasecmp(VAR_2, \"Debug\")) {", "if (stream) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "video_enc.debug = strtol(VAR_3,0,0);", "}", "} else if (!strcasecmp(VAR_2, \"Strict\")) {", "if (stream) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "video_enc.strict_std_compliance = atoi(VAR_3);", "}", "} else if (!strcasecmp(VAR_2, \"VideoBufferSize\")) {", "if (stream) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "video_enc.rc_buffer_size = atoi(VAR_3) * 8*1024;", "}", "} else if (!strcasecmp(VAR_2, \"VideoBitRateTolerance\")) {", "if (stream) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "video_enc.bit_rate_tolerance = atoi(VAR_3) * 1000;", "}", "} else if (!strcasecmp(VAR_2, \"VideoBitRate\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "video_enc.bit_rate = atoi(VAR_3) * 1000;", "}", "} else if (!strcasecmp(VAR_2, \"VideoSize\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "av_parse_video_frame_size(&video_enc.width, &video_enc.height, VAR_3);", "if ((video_enc.width % 16) != 0 ||\n(video_enc.height % 16) != 0) {", "fprintf(stderr, \"%s:%d: Image size must be a multiple of 16\\n\",\nVAR_0, VAR_7);", "VAR_6++;", "}", "}", "} else if (!strcasecmp(VAR_2, \"VideoFrameRate\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "AVRational frame_rate;", "if (av_parse_video_frame_rate(&frame_rate, VAR_3) < 0) {", "fprintf(stderr, \"Incorrect frame rate\\n\");", "VAR_6++;", "} else {", "video_enc.time_base.num = frame_rate.den;", "video_enc.time_base.den = frame_rate.num;", "}", "}", "} else if (!strcasecmp(VAR_2, \"VideoGopSize\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream)\nvideo_enc.gop_size = atoi(VAR_3);", "} else if (!strcasecmp(VAR_2, \"VideoIntraOnly\")) {", "if (stream)\nvideo_enc.gop_size = 1;", "} else if (!strcasecmp(VAR_2, \"VideoHighQuality\")) {", "if (stream)\nvideo_enc.mb_decision = FF_MB_DECISION_BITS;", "} else if (!strcasecmp(VAR_2, \"Video4MotionVector\")) {", "if (stream) {", "video_enc.mb_decision = FF_MB_DECISION_BITS;", "video_enc.flags |= CODEC_FLAG_4MV;", "}", "} else if (!strcasecmp(VAR_2, \"AVOptionVideo\") ||", "!strcasecmp(VAR_2, \"AVOptionAudio\")) {", "char VAR_17[1024];", "AVCodecContext *avctx;", "int VAR_18;", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "get_arg(VAR_17, sizeof(VAR_17), &VAR_4);", "if (!strcasecmp(VAR_2, \"AVOptionVideo\")) {", "avctx = &video_enc;", "VAR_18 = AV_OPT_FLAG_VIDEO_PARAM;", "} else {", "avctx = &audio_enc;", "VAR_18 = AV_OPT_FLAG_AUDIO_PARAM;", "}", "if (ffserver_opt_default(VAR_3, VAR_17, avctx, VAR_18|AV_OPT_FLAG_ENCODING_PARAM)) {", "fprintf(stderr, \"AVOption error: %s %s\\n\", VAR_3, VAR_17);", "VAR_6++;", "}", "} else if (!strcasecmp(VAR_2, \"VideoTag\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if ((strlen(VAR_3) == 4) && stream)\nvideo_enc.codec_tag = AV_RL32(VAR_3);", "} else if (!strcasecmp(VAR_2, \"BitExact\")) {", "if (stream)\nvideo_enc.flags |= CODEC_FLAG_BITEXACT;", "} else if (!strcasecmp(VAR_2, \"DctFastint\")) {", "if (stream)\nvideo_enc.dct_algo = FF_DCT_FASTINT;", "} else if (!strcasecmp(VAR_2, \"IdctSimple\")) {", "if (stream)\nvideo_enc.idct_algo = FF_IDCT_SIMPLE;", "} else if (!strcasecmp(VAR_2, \"Qscale\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "video_enc.flags |= CODEC_FLAG_QSCALE;", "video_enc.global_quality = FF_QP2LAMBDA * atoi(VAR_3);", "}", "} else if (!strcasecmp(VAR_2, \"VideoQDiff\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "video_enc.max_qdiff = atoi(VAR_3);", "if (video_enc.max_qdiff < 1 || video_enc.max_qdiff > 31) {", "fprintf(stderr, \"%s:%d: VideoQDiff out of range\\n\",\nVAR_0, VAR_7);", "VAR_6++;", "}", "}", "} else if (!strcasecmp(VAR_2, \"VideoQMax\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "video_enc.qmax = atoi(VAR_3);", "if (video_enc.qmax < 1 || video_enc.qmax > 31) {", "fprintf(stderr, \"%s:%d: VideoQMax out of range\\n\",\nVAR_0, VAR_7);", "VAR_6++;", "}", "}", "} else if (!strcasecmp(VAR_2, \"VideoQMin\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "video_enc.qmin = atoi(VAR_3);", "if (video_enc.qmin < 1 || video_enc.qmin > 31) {", "fprintf(stderr, \"%s:%d: VideoQMin out of range\\n\",\nVAR_0, VAR_7);", "VAR_6++;", "}", "}", "} else if (!strcasecmp(VAR_2, \"LumaElim\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream)\nvideo_enc.luma_elim_threshold = atoi(VAR_3);", "} else if (!strcasecmp(VAR_2, \"ChromaElim\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream)\nvideo_enc.chroma_elim_threshold = atoi(VAR_3);", "} else if (!strcasecmp(VAR_2, \"LumiMask\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream)\nvideo_enc.lumi_masking = atof(VAR_3);", "} else if (!strcasecmp(VAR_2, \"DarkMask\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream)\nvideo_enc.dark_masking = atof(VAR_3);", "} else if (!strcasecmp(VAR_2, \"NoVideo\")) {", "VAR_9 = CODEC_ID_NONE;", "} else if (!strcasecmp(VAR_2, \"NoAudio\")) {", "VAR_8 = CODEC_ID_NONE;", "} else if (!strcasecmp(VAR_2, \"ACL\")) {", "IPAddressACL acl;", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (strcasecmp(VAR_3, \"allow\") == 0)\nacl.action = IP_ALLOW;", "else if (strcasecmp(VAR_3, \"deny\") == 0)\nacl.action = IP_DENY;", "else {", "fprintf(stderr, \"%s:%d: ACL action '%s' is not ALLOW or DENY\\n\",\nVAR_0, VAR_7, VAR_3);", "VAR_6++;", "}", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (resolve_host(&acl.first, VAR_3) != 0) {", "fprintf(stderr, \"%s:%d: ACL refers to invalid host or ip address '%s'\\n\",\nVAR_0, VAR_7, VAR_3);", "VAR_6++;", "} else", "acl.last = acl.first;", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (VAR_3[0]) {", "if (resolve_host(&acl.last, VAR_3) != 0) {", "fprintf(stderr, \"%s:%d: ACL refers to invalid host or ip address '%s'\\n\",\nVAR_0, VAR_7, VAR_3);", "VAR_6++;", "}", "}", "if (!VAR_6) {", "IPAddressACL *nacl = av_mallocz(sizeof(*nacl));", "IPAddressACL **naclp = 0;", "acl.next = 0;", "*nacl = acl;", "if (stream)\nnaclp = &stream->acl;", "else if (feed)\nnaclp = &feed->acl;", "else {", "fprintf(stderr, \"%s:%d: ACL found not in <stream> or <feed>\\n\",\nVAR_0, VAR_7);", "VAR_6++;", "}", "if (naclp) {", "while (*naclp)\nnaclp = &(*naclp)->next;", "*naclp = nacl;", "}", "}", "} else if (!strcasecmp(VAR_2, \"RTSPOption\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "av_freep(&stream->rtsp_option);", "stream->rtsp_option = av_strdup(VAR_3);", "}", "} else if (!strcasecmp(VAR_2, \"MulticastAddress\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream) {", "if (resolve_host(&stream->multicast_ip, VAR_3) != 0) {", "fprintf(stderr, \"%s:%d: Invalid host/IP address: %s\\n\",\nVAR_0, VAR_7, VAR_3);", "VAR_6++;", "}", "stream->is_multicast = 1;", "stream->loop = 1;", "}", "} else if (!strcasecmp(VAR_2, \"MulticastPort\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream)\nstream->multicast_port = atoi(VAR_3);", "} else if (!strcasecmp(VAR_2, \"MulticastTTL\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "if (stream)\nstream->multicast_ttl = atoi(VAR_3);", "} else if (!strcasecmp(VAR_2, \"NoLoop\")) {", "if (stream)\nstream->loop = 0;", "} else if (!strcasecmp(VAR_2, \"</Stream>\")) {", "if (!stream) {", "fprintf(stderr, \"%s:%d: No corresponding <Stream> for </Stream>\\n\",\nVAR_0, VAR_7);", "VAR_6++;", "} else {", "if (stream->feed && stream->fmt && strcmp(stream->fmt->name, \"ffm\") != 0) {", "if (VAR_8 != CODEC_ID_NONE) {", "audio_enc.codec_type = CODEC_TYPE_AUDIO;", "audio_enc.codec_id = VAR_8;", "add_codec(stream, &audio_enc);", "}", "if (VAR_9 != CODEC_ID_NONE) {", "video_enc.codec_type = CODEC_TYPE_VIDEO;", "video_enc.codec_id = VAR_9;", "add_codec(stream, &video_enc);", "}", "}", "stream = NULL;", "}", "} else if (!strcasecmp(VAR_2, \"<Redirect\")) {", "char *VAR_19;", "if (stream || feed || redirect) {", "fprintf(stderr, \"%s:%d: Already in a tag\\n\",\nVAR_0, VAR_7);", "VAR_6++;", "} else {", "redirect = av_mallocz(sizeof(FFStream));", "*last_stream = redirect;", "last_stream = &redirect->next;", "get_arg(redirect->VAR_0, sizeof(redirect->VAR_0), &VAR_4);", "VAR_19 = strrchr(redirect->VAR_0, '>');", "if (*VAR_19)\n*VAR_19 = '\\0';", "redirect->stream_type = STREAM_TYPE_REDIRECT;", "}", "} else if (!strcasecmp(VAR_2, \"URL\")) {", "if (redirect)\nget_arg(redirect->feed_filename, sizeof(redirect->feed_filename), &VAR_4);", "} else if (!strcasecmp(VAR_2, \"</Redirect>\")) {", "if (!redirect) {", "fprintf(stderr, \"%s:%d: No corresponding <Redirect> for </Redirect>\\n\",\nVAR_0, VAR_7);", "VAR_6++;", "} else {", "if (!redirect->feed_filename[0]) {", "fprintf(stderr, \"%s:%d: No URL found for <Redirect>\\n\",\nVAR_0, VAR_7);", "VAR_6++;", "}", "redirect = NULL;", "}", "} else if (!strcasecmp(VAR_2, \"LoadModule\")) {", "get_arg(VAR_3, sizeof(VAR_3), &VAR_4);", "#if HAVE_DLOPEN\nload_module(VAR_3);", "#else\nfprintf(stderr, \"%s:%d: Module support not compiled into this version: '%s'\\n\",\nVAR_0, VAR_7, VAR_3);", "VAR_6++;", "#endif\n} else {", "fprintf(stderr, \"%s:%d: Incorrect keyword: '%s'\\n\",\nVAR_0, VAR_7, VAR_2);", "}", "}", "fclose(f);", "if (VAR_6)\nreturn -1;", "else\nreturn 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63, 65 ], [ 67 ], [ 69 ], [ 71, 73 ], [ 75, 77 ], [ 81 ], [ 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 ], [ 223 ], [ 225 ], [ 227, 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 239, 241 ], [ 245 ], [ 247 ], [ 249, 251 ], [ 253 ], [ 255 ], [ 257 ], [ 261 ], [ 265, 267 ], [ 269 ], [ 271 ], [ 273 ], [ 279 ], [ 281 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293 ], [ 295 ], [ 299 ], [ 303 ], [ 305 ], [ 307, 309 ], [ 313 ], [ 315 ], [ 319 ], [ 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 ], [ 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 ], [ 441 ], [ 443 ], [ 445, 447 ], [ 449 ], [ 451 ], [ 453 ], [ 455 ], [ 457 ], [ 459 ], [ 461, 463 ], [ 467 ], [ 469 ], [ 471, 473 ], [ 475 ], [ 477 ], [ 479 ], [ 483 ], [ 491 ], [ 493 ], [ 495 ], [ 497 ], [ 499 ], [ 501 ], [ 503 ], [ 505 ], [ 507 ], [ 509 ], [ 511 ], [ 513 ], [ 517 ], [ 519 ], [ 521 ], [ 523 ], [ 525 ], [ 527 ], [ 529 ], [ 533 ], [ 535 ], [ 537, 539 ], [ 541 ], [ 543 ], [ 545, 547, 549 ], [ 551, 553 ], [ 555 ], [ 557 ], [ 559 ], [ 561 ], [ 563 ], [ 565 ], [ 567 ], [ 569 ], [ 571 ], [ 575, 577 ], [ 579 ], [ 581 ], [ 583, 585 ], [ 587 ], [ 589 ], [ 591 ], [ 593 ], [ 595 ], [ 597 ], [ 599 ], [ 601 ], [ 603 ], [ 605 ], [ 607 ], [ 609 ], [ 611 ], [ 613, 615 ], [ 617 ], [ 619 ], [ 621 ], [ 623 ], [ 625 ], [ 627 ], [ 629, 631 ], [ 633 ], [ 635 ], [ 637 ], [ 639, 641 ], [ 643 ], [ 645, 647 ], [ 649 ], [ 651, 653 ], [ 655 ], [ 657, 659 ], [ 661 ], [ 663 ], [ 665, 667 ], [ 669 ], [ 671, 673 ], [ 675 ], [ 677 ], [ 679 ], [ 681 ], [ 683, 685 ], [ 687 ], [ 689 ], [ 691 ], [ 693 ], [ 695 ], [ 697 ], [ 699, 701 ], [ 703 ], [ 705 ], [ 707 ], [ 709 ], [ 711, 713 ], [ 715 ], [ 717 ], [ 719, 721 ], [ 723 ], [ 725 ], [ 727, 729 ], [ 731 ], [ 733 ], [ 735, 737 ], [ 739 ], [ 741 ], [ 743 ], [ 747 ], [ 749 ], [ 751 ], [ 753 ], [ 757 ], [ 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 ], [ 813 ], [ 815 ], [ 817 ], [ 819 ], [ 821 ], [ 823 ], [ 825 ], [ 827 ], [ 829 ], [ 831 ], [ 833 ], [ 835 ], [ 837, 839 ], [ 841, 843 ], [ 845 ], [ 847 ], [ 849 ], [ 851 ], [ 853 ], [ 855 ], [ 857 ], [ 859 ], [ 861 ], [ 863 ], [ 865 ], [ 867 ], [ 869 ], [ 871 ], [ 873 ], [ 875 ], [ 877 ], [ 879, 881 ], [ 883 ], [ 885, 887 ], [ 889 ], [ 891, 893 ], [ 895 ], [ 897 ], [ 899 ], [ 901 ], [ 903 ], [ 905 ], [ 907 ], [ 909 ], [ 911 ], [ 913 ], [ 915 ], [ 917 ], [ 919 ], [ 921 ], [ 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 ], [ 1085 ], [ 1087, 1089 ], [ 1091, 1093 ], [ 1095 ], [ 1097, 1099 ], [ 1101 ], [ 1103 ], [ 1107 ], [ 1111 ], [ 1113, 1115 ], [ 1117 ], [ 1119 ], [ 1121 ], [ 1125 ], [ 1129 ], [ 1131 ], [ 1133, 1135 ], [ 1137 ], [ 1139 ], [ 1141 ], [ 1145 ], [ 1147 ], [ 1149 ], [ 1153 ], [ 1155 ], [ 1159, 1161 ], [ 1163, 1165 ], [ 1167 ], [ 1169, 1171 ], [ 1173 ], [ 1175 ], [ 1179 ], [ 1181, 1183 ], [ 1187 ], [ 1189 ], [ 1191 ], [ 1193 ], [ 1195 ], [ 1197 ], [ 1199 ], [ 1201 ], [ 1203 ], [ 1205 ], [ 1207 ], [ 1209 ], [ 1211 ], [ 1213, 1215 ], [ 1217 ], [ 1219 ], [ 1221 ], [ 1223 ], [ 1225 ], [ 1227 ], [ 1229 ], [ 1231, 1233 ], [ 1235 ], [ 1237 ], [ 1239, 1241 ], [ 1243 ], [ 1245, 1247 ], [ 1249 ], [ 1251 ], [ 1253, 1255 ], [ 1257 ], [ 1259 ], [ 1261 ], [ 1263 ], [ 1265 ], [ 1267 ], [ 1269 ], [ 1271 ], [ 1273 ], [ 1275 ], [ 1277 ], [ 1279 ], [ 1281 ], [ 1283 ], [ 1285 ], [ 1287 ], [ 1289 ], [ 1293 ], [ 1295 ], [ 1297, 1299 ], [ 1301 ], [ 1303 ], [ 1305 ], [ 1307 ], [ 1309 ], [ 1313 ], [ 1315 ], [ 1317, 1319 ], [ 1321 ], [ 1323 ], [ 1325 ], [ 1327, 1329 ], [ 1331 ], [ 1333 ], [ 1335, 1337 ], [ 1339 ], [ 1341 ], [ 1343 ], [ 1345, 1347 ], [ 1349 ], [ 1351 ], [ 1353 ], [ 1355 ], [ 1357 ], [ 1359 ], [ 1361, 1363 ], [ 1365, 1367, 1369 ], [ 1371 ], [ 1373, 1375 ], [ 1377, 1379 ], [ 1381 ], [ 1383 ], [ 1387 ], [ 1389, 1391 ], [ 1393, 1395 ], [ 1397 ] ]
12,555
void ff_put_h264_qpel16_mc03_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_vt_qrt_16w_msa(src - (stride * 2), stride, dst, stride, 16, 1); }
false
FFmpeg
6796a1dd8c14843b77925cb83a3ef88706ae1dd0
void ff_put_h264_qpel16_mc03_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_vt_qrt_16w_msa(src - (stride * 2), stride, dst, stride, 16, 1); }
{ "code": [], "line_no": [] }
void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1, ptrdiff_t VAR_2) { avc_luma_vt_qrt_16w_msa(VAR_1 - (VAR_2 * 2), VAR_2, VAR_0, VAR_2, 16, 1); }
[ "void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,\nptrdiff_t VAR_2)\n{", "avc_luma_vt_qrt_16w_msa(VAR_1 - (VAR_2 * 2), VAR_2, VAR_0, VAR_2, 16, 1);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ] ]
12,557
static int ccw_dstream_rw_noflags(CcwDataStream *cds, void *buff, int len, CcwDataStreamOp op) { int ret; ret = cds_check_len(cds, len); if (ret <= 0) { return ret; if (op == CDS_OP_A) { goto incr; ret = address_space_rw(&address_space_memory, cds->cda, MEMTXATTRS_UNSPECIFIED, buff, len, op); if (ret != MEMTX_OK) { cds->flags |= CDS_F_STREAM_BROKEN; return -EINVAL; incr: cds->at_byte += len; cds->cda += len; return 0;
true
qemu
62a2554ec2630896d1299e1a282a64c7f3b00da0
static int ccw_dstream_rw_noflags(CcwDataStream *cds, void *buff, int len, CcwDataStreamOp op) { int ret; ret = cds_check_len(cds, len); if (ret <= 0) { return ret; if (op == CDS_OP_A) { goto incr; ret = address_space_rw(&address_space_memory, cds->cda, MEMTXATTRS_UNSPECIFIED, buff, len, op); if (ret != MEMTX_OK) { cds->flags |= CDS_F_STREAM_BROKEN; return -EINVAL; incr: cds->at_byte += len; cds->cda += len; return 0;
{ "code": [], "line_no": [] }
static int FUNC_0(CcwDataStream *VAR_0, void *VAR_1, int VAR_2, CcwDataStreamOp VAR_3) { int VAR_4; VAR_4 = cds_check_len(VAR_0, VAR_2); if (VAR_4 <= 0) { return VAR_4; if (VAR_3 == CDS_OP_A) { goto incr; VAR_4 = address_space_rw(&address_space_memory, VAR_0->cda, MEMTXATTRS_UNSPECIFIED, VAR_1, VAR_2, VAR_3); if (VAR_4 != MEMTX_OK) { VAR_0->flags |= CDS_F_STREAM_BROKEN; return -EINVAL; incr: VAR_0->at_byte += VAR_2; VAR_0->cda += VAR_2; return 0;
[ "static int FUNC_0(CcwDataStream *VAR_0, void *VAR_1, int VAR_2,\nCcwDataStreamOp VAR_3)\n{", "int VAR_4;", "VAR_4 = cds_check_len(VAR_0, VAR_2);", "if (VAR_4 <= 0) {", "return VAR_4;", "if (VAR_3 == CDS_OP_A) {", "goto incr;", "VAR_4 = address_space_rw(&address_space_memory, VAR_0->cda,\nMEMTXATTRS_UNSPECIFIED, VAR_1, VAR_2, VAR_3);", "if (VAR_4 != MEMTX_OK) {", "VAR_0->flags |= CDS_F_STREAM_BROKEN;", "return -EINVAL;", "incr:\nVAR_0->at_byte += VAR_2;", "VAR_0->cda += VAR_2;", "return 0;" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 21 ], [ 23 ], [ 26, 28 ], [ 30 ], [ 32 ], [ 34 ], [ 37, 39 ], [ 41 ], [ 43 ] ]
12,559
static void grlib_apbuart_write(void *opaque, hwaddr addr, uint64_t value, unsigned size) { UART *uart = opaque; unsigned char c = 0; addr &= 0xff; /* Unit registers */ switch (addr) { case DATA_OFFSET: case DATA_OFFSET + 3: /* When only one byte write */ /* Transmit when character device available and transmitter enabled */ if ((uart->chr) && (uart->control & UART_TRANSMIT_ENABLE)) { c = value & 0xFF; qemu_chr_fe_write(uart->chr, &c, 1); /* Generate interrupt */ if (uart->control & UART_TRANSMIT_INTERRUPT) { qemu_irq_pulse(uart->irq); } } return; case STATUS_OFFSET: /* Read Only */ return; case CONTROL_OFFSET: uart->control = value; return; case SCALER_OFFSET: /* Not supported */ return; default: break; } trace_grlib_apbuart_writel_unknown(addr, value); }
true
qemu
6ab3fc32ea640026726bc5f9f4db622d0954fb8a
static void grlib_apbuart_write(void *opaque, hwaddr addr, uint64_t value, unsigned size) { UART *uart = opaque; unsigned char c = 0; addr &= 0xff; switch (addr) { case DATA_OFFSET: case DATA_OFFSET + 3: if ((uart->chr) && (uart->control & UART_TRANSMIT_ENABLE)) { c = value & 0xFF; qemu_chr_fe_write(uart->chr, &c, 1); if (uart->control & UART_TRANSMIT_INTERRUPT) { qemu_irq_pulse(uart->irq); } } return; case STATUS_OFFSET: return; case CONTROL_OFFSET: uart->control = value; return; case SCALER_OFFSET: return; default: break; } trace_grlib_apbuart_writel_unknown(addr, value); }
{ "code": [ " qemu_chr_fe_write(uart->chr, &c, 1);" ], "line_no": [ 31 ] }
static void FUNC_0(void *VAR_0, hwaddr VAR_1, uint64_t VAR_2, unsigned VAR_3) { UART *uart = VAR_0; unsigned char VAR_4 = 0; VAR_1 &= 0xff; switch (VAR_1) { case DATA_OFFSET: case DATA_OFFSET + 3: if ((uart->chr) && (uart->control & UART_TRANSMIT_ENABLE)) { VAR_4 = VAR_2 & 0xFF; qemu_chr_fe_write(uart->chr, &VAR_4, 1); if (uart->control & UART_TRANSMIT_INTERRUPT) { qemu_irq_pulse(uart->irq); } } return; case STATUS_OFFSET: return; case CONTROL_OFFSET: uart->control = VAR_2; return; case SCALER_OFFSET: return; default: break; } trace_grlib_apbuart_writel_unknown(VAR_1, VAR_2); }
[ "static void FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{", "UART *uart = VAR_0;", "unsigned char VAR_4 = 0;", "VAR_1 &= 0xff;", "switch (VAR_1) {", "case DATA_OFFSET:\ncase DATA_OFFSET + 3:\nif ((uart->chr) && (uart->control & UART_TRANSMIT_ENABLE)) {", "VAR_4 = VAR_2 & 0xFF;", "qemu_chr_fe_write(uart->chr, &VAR_4, 1);", "if (uart->control & UART_TRANSMIT_INTERRUPT) {", "qemu_irq_pulse(uart->irq);", "}", "}", "return;", "case STATUS_OFFSET:\nreturn;", "case CONTROL_OFFSET:\nuart->control = VAR_2;", "return;", "case SCALER_OFFSET:\nreturn;", "default:\nbreak;", "}", "trace_grlib_apbuart_writel_unknown(VAR_1, VAR_2);", "}" ]
[ 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 ], [ 13 ], [ 19 ], [ 21, 23, 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47, 51 ], [ 55, 57 ], [ 59 ], [ 63, 67 ], [ 71, 73 ], [ 75 ], [ 79 ], [ 81 ] ]
12,560
static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y, const uint8_t **buf, int buf_size) { MpegEncContext *s = &s1->mpeg_enc_ctx; AVCodecContext *avctx= s->avctx; int ret; const int field_pic= s->picture_structure != PICT_FRAME; s->resync_mb_x= s->resync_mb_y= -1; if (mb_y >= s->mb_height){ av_log(s->avctx, AV_LOG_ERROR, "slice below image (%d >= %d)\n", s->mb_y, s->mb_height); return -1; } init_get_bits(&s->gb, *buf, buf_size*8); ff_mpeg1_clean_buffers(s); s->interlaced_dct = 0; s->qscale = get_qscale(s); if(s->qscale == 0){ av_log(s->avctx, AV_LOG_ERROR, "qscale == 0\n"); return -1; } /* extra slice info */ while (get_bits1(&s->gb) != 0) { skip_bits(&s->gb, 8); } s->mb_x=0; for(;;) { int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2); if (code < 0){ av_log(s->avctx, AV_LOG_ERROR, "first mb_incr damaged\n"); return -1; } if (code >= 33) { if (code == 33) { s->mb_x += 33; } /* otherwise, stuffing, nothing to do */ } else { s->mb_x += code; break; } } s->resync_mb_x= s->mb_x; s->resync_mb_y= s->mb_y= mb_y; s->mb_skip_run= 0; ff_init_block_index(s); if (s->mb_y==0 && s->mb_x==0 && (s->first_field || s->picture_structure==PICT_FRAME)) { if(s->avctx->debug&FF_DEBUG_PICT_INFO){ av_log(s->avctx, AV_LOG_DEBUG, "qp:%d fc:%2d%2d%2d%2d %s %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n", s->qscale, s->mpeg_f_code[0][0],s->mpeg_f_code[0][1],s->mpeg_f_code[1][0],s->mpeg_f_code[1][1], s->pict_type == I_TYPE ? "I" : (s->pict_type == P_TYPE ? "P" : (s->pict_type == B_TYPE ? "B" : "S")), s->progressive_sequence ? "ps" :"", s->progressive_frame ? "pf" : "", s->alternate_scan ? "alt" :"", s->top_field_first ? "top" :"", s->intra_dc_precision, s->picture_structure, s->frame_pred_frame_dct, s->concealment_motion_vectors, s->q_scale_type, s->intra_vlc_format, s->repeat_first_field, s->chroma_420_type ? "420" :""); } } for(;;) { #ifdef HAVE_XVMC //one 1 we memcpy blocks in xvmcvideo if(s->avctx->xvmc_acceleration > 1) XVMC_init_block(s);//set s->block #endif s->dsp.clear_blocks(s->block[0]); ret = mpeg_decode_mb(s, s->block); s->chroma_qscale= s->qscale; dprintf("ret=%d\n", ret); if (ret < 0) return -1; if(s->current_picture.motion_val[0] && !s->encoding){ //note motion_val is normally NULL unless we want to extract the MVs const int wrap = field_pic ? 2*s->b8_stride : s->b8_stride; int xy = s->mb_x*2 + s->mb_y*2*wrap; int motion_x, motion_y, dir, i; if(field_pic && !s->first_field) xy += wrap/2; for(i=0; i<2; i++){ for(dir=0; dir<2; dir++){ if (s->mb_intra || (dir==1 && s->pict_type != B_TYPE)) { motion_x = motion_y = 0; }else if (s->mv_type == MV_TYPE_16X16 || (s->mv_type == MV_TYPE_FIELD && field_pic)){ motion_x = s->mv[dir][0][0]; motion_y = s->mv[dir][0][1]; } else /*if ((s->mv_type == MV_TYPE_FIELD) || (s->mv_type == MV_TYPE_16X8))*/ { motion_x = s->mv[dir][i][0]; motion_y = s->mv[dir][i][1]; } s->current_picture.motion_val[dir][xy ][0] = motion_x; s->current_picture.motion_val[dir][xy ][1] = motion_y; s->current_picture.motion_val[dir][xy + 1][0] = motion_x; s->current_picture.motion_val[dir][xy + 1][1] = motion_y; s->current_picture.ref_index [dir][xy ]= s->current_picture.ref_index [dir][xy + 1]= s->field_select[dir][i]; } xy += wrap; } } s->dest[0] += 16; s->dest[1] += 8; s->dest[2] += 8; MPV_decode_mb(s, s->block); if (++s->mb_x >= s->mb_width) { ff_draw_horiz_band(s, 16*s->mb_y, 16); s->mb_x = 0; s->mb_y++; if(s->mb_y<<field_pic >= s->mb_height){ int left= s->gb.size_in_bits - get_bits_count(&s->gb); if(left < 0 || (left && show_bits(&s->gb, FFMIN(left, 23))) || (avctx->error_resilience >= FF_ER_AGGRESSIVE && left>8)){ av_log(avctx, AV_LOG_ERROR, "end mismatch left=%d\n", left); return -1; }else goto eos; } ff_init_block_index(s); } /* skip mb handling */ if (s->mb_skip_run == -1) { /* read again increment */ s->mb_skip_run = 0; for(;;) { int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2); if (code < 0){ av_log(s->avctx, AV_LOG_ERROR, "mb incr damaged\n"); return -1; } if (code >= 33) { if (code == 33) { s->mb_skip_run += 33; }else if(code == 35){ if(s->mb_skip_run != 0 || show_bits(&s->gb, 15) != 0){ av_log(s->avctx, AV_LOG_ERROR, "slice mismatch\n"); return -1; } goto eos; /* end of slice */ } /* otherwise, stuffing, nothing to do */ } else { s->mb_skip_run += code; break; } } } } eos: // end of slice *buf += get_bits_count(&s->gb)/8 - 1; //printf("y %d %d %d %d\n", s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y); return 0; }
true
FFmpeg
25ef43bb289a3a3a717a684902c0a310e292beba
static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y, const uint8_t **buf, int buf_size) { MpegEncContext *s = &s1->mpeg_enc_ctx; AVCodecContext *avctx= s->avctx; int ret; const int field_pic= s->picture_structure != PICT_FRAME; s->resync_mb_x= s->resync_mb_y= -1; if (mb_y >= s->mb_height){ av_log(s->avctx, AV_LOG_ERROR, "slice below image (%d >= %d)\n", s->mb_y, s->mb_height); return -1; } init_get_bits(&s->gb, *buf, buf_size*8); ff_mpeg1_clean_buffers(s); s->interlaced_dct = 0; s->qscale = get_qscale(s); if(s->qscale == 0){ av_log(s->avctx, AV_LOG_ERROR, "qscale == 0\n"); return -1; } while (get_bits1(&s->gb) != 0) { skip_bits(&s->gb, 8); } s->mb_x=0; for(;;) { int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2); if (code < 0){ av_log(s->avctx, AV_LOG_ERROR, "first mb_incr damaged\n"); return -1; } if (code >= 33) { if (code == 33) { s->mb_x += 33; } } else { s->mb_x += code; break; } } s->resync_mb_x= s->mb_x; s->resync_mb_y= s->mb_y= mb_y; s->mb_skip_run= 0; ff_init_block_index(s); if (s->mb_y==0 && s->mb_x==0 && (s->first_field || s->picture_structure==PICT_FRAME)) { if(s->avctx->debug&FF_DEBUG_PICT_INFO){ av_log(s->avctx, AV_LOG_DEBUG, "qp:%d fc:%2d%2d%2d%2d %s %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n", s->qscale, s->mpeg_f_code[0][0],s->mpeg_f_code[0][1],s->mpeg_f_code[1][0],s->mpeg_f_code[1][1], s->pict_type == I_TYPE ? "I" : (s->pict_type == P_TYPE ? "P" : (s->pict_type == B_TYPE ? "B" : "S")), s->progressive_sequence ? "ps" :"", s->progressive_frame ? "pf" : "", s->alternate_scan ? "alt" :"", s->top_field_first ? "top" :"", s->intra_dc_precision, s->picture_structure, s->frame_pred_frame_dct, s->concealment_motion_vectors, s->q_scale_type, s->intra_vlc_format, s->repeat_first_field, s->chroma_420_type ? "420" :""); } } for(;;) { #ifdef HAVE_XVMC if(s->avctx->xvmc_acceleration > 1) XVMC_init_block(s); #endif s->dsp.clear_blocks(s->block[0]); ret = mpeg_decode_mb(s, s->block); s->chroma_qscale= s->qscale; dprintf("ret=%d\n", ret); if (ret < 0) return -1; if(s->current_picture.motion_val[0] && !s->encoding){ const int wrap = field_pic ? 2*s->b8_stride : s->b8_stride; int xy = s->mb_x*2 + s->mb_y*2*wrap; int motion_x, motion_y, dir, i; if(field_pic && !s->first_field) xy += wrap/2; for(i=0; i<2; i++){ for(dir=0; dir<2; dir++){ if (s->mb_intra || (dir==1 && s->pict_type != B_TYPE)) { motion_x = motion_y = 0; }else if (s->mv_type == MV_TYPE_16X16 || (s->mv_type == MV_TYPE_FIELD && field_pic)){ motion_x = s->mv[dir][0][0]; motion_y = s->mv[dir][0][1]; } else { motion_x = s->mv[dir][i][0]; motion_y = s->mv[dir][i][1]; } s->current_picture.motion_val[dir][xy ][0] = motion_x; s->current_picture.motion_val[dir][xy ][1] = motion_y; s->current_picture.motion_val[dir][xy + 1][0] = motion_x; s->current_picture.motion_val[dir][xy + 1][1] = motion_y; s->current_picture.ref_index [dir][xy ]= s->current_picture.ref_index [dir][xy + 1]= s->field_select[dir][i]; } xy += wrap; } } s->dest[0] += 16; s->dest[1] += 8; s->dest[2] += 8; MPV_decode_mb(s, s->block); if (++s->mb_x >= s->mb_width) { ff_draw_horiz_band(s, 16*s->mb_y, 16); s->mb_x = 0; s->mb_y++; if(s->mb_y<<field_pic >= s->mb_height){ int left= s->gb.size_in_bits - get_bits_count(&s->gb); if(left < 0 || (left && show_bits(&s->gb, FFMIN(left, 23))) || (avctx->error_resilience >= FF_ER_AGGRESSIVE && left>8)){ av_log(avctx, AV_LOG_ERROR, "end mismatch left=%d\n", left); return -1; }else goto eos; } ff_init_block_index(s); } if (s->mb_skip_run == -1) { s->mb_skip_run = 0; for(;;) { int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2); if (code < 0){ av_log(s->avctx, AV_LOG_ERROR, "mb incr damaged\n"); return -1; } if (code >= 33) { if (code == 33) { s->mb_skip_run += 33; }else if(code == 35){ if(s->mb_skip_run != 0 || show_bits(&s->gb, 15) != 0){ av_log(s->avctx, AV_LOG_ERROR, "slice mismatch\n"); return -1; } goto eos; } } else { s->mb_skip_run += code; break; } } } } eos: *buf += get_bits_count(&s->gb)/8 - 1; return 0; }
{ "code": [ " if (mb_y >= s->mb_height){", " av_log(s->avctx, AV_LOG_ERROR, \"slice below image (%d >= %d)\\n\", s->mb_y, s->mb_height);" ], "line_no": [ 23, 25 ] }
static int FUNC_0(Mpeg1Context *VAR_0, int VAR_1, const uint8_t **VAR_2, int VAR_3) { MpegEncContext *s = &VAR_0->mpeg_enc_ctx; AVCodecContext *avctx= s->avctx; int VAR_4; const int VAR_5= s->picture_structure != PICT_FRAME; s->resync_mb_x= s->resync_mb_y= -1; if (VAR_1 >= s->mb_height){ av_log(s->avctx, AV_LOG_ERROR, "slice below image (%d >= %d)\n", s->VAR_1, s->mb_height); return -1; } init_get_bits(&s->gb, *VAR_2, VAR_3*8); ff_mpeg1_clean_buffers(s); s->interlaced_dct = 0; s->qscale = get_qscale(s); if(s->qscale == 0){ av_log(s->avctx, AV_LOG_ERROR, "qscale == 0\n"); return -1; } while (get_bits1(&s->gb) != 0) { skip_bits(&s->gb, 8); } s->mb_x=0; for(;;) { int VAR_14 = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2); if (VAR_14 < 0){ av_log(s->avctx, AV_LOG_ERROR, "first mb_incr damaged\n"); return -1; } if (VAR_14 >= 33) { if (VAR_14 == 33) { s->mb_x += 33; } } else { s->mb_x += VAR_14; break; } } s->resync_mb_x= s->mb_x; s->resync_mb_y= s->VAR_1= VAR_1; s->mb_skip_run= 0; ff_init_block_index(s); if (s->VAR_1==0 && s->mb_x==0 && (s->first_field || s->picture_structure==PICT_FRAME)) { if(s->avctx->debug&FF_DEBUG_PICT_INFO){ av_log(s->avctx, AV_LOG_DEBUG, "qp:%d fc:%2d%2d%2d%2d %s %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n", s->qscale, s->mpeg_f_code[0][0],s->mpeg_f_code[0][1],s->mpeg_f_code[1][0],s->mpeg_f_code[1][1], s->pict_type == I_TYPE ? "I" : (s->pict_type == P_TYPE ? "P" : (s->pict_type == B_TYPE ? "B" : "S")), s->progressive_sequence ? "ps" :"", s->progressive_frame ? "pf" : "", s->alternate_scan ? "alt" :"", s->top_field_first ? "top" :"", s->intra_dc_precision, s->picture_structure, s->frame_pred_frame_dct, s->concealment_motion_vectors, s->q_scale_type, s->intra_vlc_format, s->repeat_first_field, s->chroma_420_type ? "420" :""); } } for(;;) { #ifdef HAVE_XVMC if(s->avctx->xvmc_acceleration > 1) XVMC_init_block(s); #endif s->dsp.clear_blocks(s->block[0]); VAR_4 = mpeg_decode_mb(s, s->block); s->chroma_qscale= s->qscale; dprintf("VAR_4=%d\n", VAR_4); if (VAR_4 < 0) return -1; if(s->current_picture.motion_val[0] && !s->encoding){ const int VAR_7 = VAR_5 ? 2*s->b8_stride : s->b8_stride; int VAR_8 = s->mb_x*2 + s->VAR_1*2*VAR_7; int VAR_9, VAR_10, VAR_11, VAR_12; if(VAR_5 && !s->first_field) VAR_8 += VAR_7/2; for(VAR_12=0; VAR_12<2; VAR_12++){ for(VAR_11=0; VAR_11<2; VAR_11++){ if (s->mb_intra || (VAR_11==1 && s->pict_type != B_TYPE)) { VAR_9 = VAR_10 = 0; }else if (s->mv_type == MV_TYPE_16X16 || (s->mv_type == MV_TYPE_FIELD && VAR_5)){ VAR_9 = s->mv[VAR_11][0][0]; VAR_10 = s->mv[VAR_11][0][1]; } else { VAR_9 = s->mv[VAR_11][VAR_12][0]; VAR_10 = s->mv[VAR_11][VAR_12][1]; } s->current_picture.motion_val[VAR_11][VAR_8 ][0] = VAR_9; s->current_picture.motion_val[VAR_11][VAR_8 ][1] = VAR_10; s->current_picture.motion_val[VAR_11][VAR_8 + 1][0] = VAR_9; s->current_picture.motion_val[VAR_11][VAR_8 + 1][1] = VAR_10; s->current_picture.ref_index [VAR_11][VAR_8 ]= s->current_picture.ref_index [VAR_11][VAR_8 + 1]= s->field_select[VAR_11][VAR_12]; } VAR_8 += VAR_7; } } s->dest[0] += 16; s->dest[1] += 8; s->dest[2] += 8; MPV_decode_mb(s, s->block); if (++s->mb_x >= s->mb_width) { ff_draw_horiz_band(s, 16*s->VAR_1, 16); s->mb_x = 0; s->VAR_1++; if(s->VAR_1<<VAR_5 >= s->mb_height){ int VAR_13= s->gb.size_in_bits - get_bits_count(&s->gb); if(VAR_13 < 0 || (VAR_13 && show_bits(&s->gb, FFMIN(VAR_13, 23))) || (avctx->error_resilience >= FF_ER_AGGRESSIVE && VAR_13>8)){ av_log(avctx, AV_LOG_ERROR, "end mismatch VAR_13=%d\n", VAR_13); return -1; }else goto eos; } ff_init_block_index(s); } if (s->mb_skip_run == -1) { s->mb_skip_run = 0; for(;;) { int VAR_14 = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2); if (VAR_14 < 0){ av_log(s->avctx, AV_LOG_ERROR, "mb incr damaged\n"); return -1; } if (VAR_14 >= 33) { if (VAR_14 == 33) { s->mb_skip_run += 33; }else if(VAR_14 == 35){ if(s->mb_skip_run != 0 || show_bits(&s->gb, 15) != 0){ av_log(s->avctx, AV_LOG_ERROR, "slice mismatch\n"); return -1; } goto eos; } } else { s->mb_skip_run += VAR_14; break; } } } } eos: *VAR_2 += get_bits_count(&s->gb)/8 - 1; return 0; }
[ "static int FUNC_0(Mpeg1Context *VAR_0, int VAR_1,\nconst uint8_t **VAR_2, int VAR_3)\n{", "MpegEncContext *s = &VAR_0->mpeg_enc_ctx;", "AVCodecContext *avctx= s->avctx;", "int VAR_4;", "const int VAR_5= s->picture_structure != PICT_FRAME;", "s->resync_mb_x=\ns->resync_mb_y= -1;", "if (VAR_1 >= s->mb_height){", "av_log(s->avctx, AV_LOG_ERROR, \"slice below image (%d >= %d)\\n\", s->VAR_1, s->mb_height);", "return -1;", "}", "init_get_bits(&s->gb, *VAR_2, VAR_3*8);", "ff_mpeg1_clean_buffers(s);", "s->interlaced_dct = 0;", "s->qscale = get_qscale(s);", "if(s->qscale == 0){", "av_log(s->avctx, AV_LOG_ERROR, \"qscale == 0\\n\");", "return -1;", "}", "while (get_bits1(&s->gb) != 0) {", "skip_bits(&s->gb, 8);", "}", "s->mb_x=0;", "for(;;) {", "int VAR_14 = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2);", "if (VAR_14 < 0){", "av_log(s->avctx, AV_LOG_ERROR, \"first mb_incr damaged\\n\");", "return -1;", "}", "if (VAR_14 >= 33) {", "if (VAR_14 == 33) {", "s->mb_x += 33;", "}", "} else {", "s->mb_x += VAR_14;", "break;", "}", "}", "s->resync_mb_x= s->mb_x;", "s->resync_mb_y= s->VAR_1= VAR_1;", "s->mb_skip_run= 0;", "ff_init_block_index(s);", "if (s->VAR_1==0 && s->mb_x==0 && (s->first_field || s->picture_structure==PICT_FRAME)) {", "if(s->avctx->debug&FF_DEBUG_PICT_INFO){", "av_log(s->avctx, AV_LOG_DEBUG, \"qp:%d fc:%2d%2d%2d%2d %s %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\\n\",\ns->qscale, s->mpeg_f_code[0][0],s->mpeg_f_code[0][1],s->mpeg_f_code[1][0],s->mpeg_f_code[1][1],\ns->pict_type == I_TYPE ? \"I\" : (s->pict_type == P_TYPE ? \"P\" : (s->pict_type == B_TYPE ? \"B\" : \"S\")),\ns->progressive_sequence ? \"ps\" :\"\", s->progressive_frame ? \"pf\" : \"\", s->alternate_scan ? \"alt\" :\"\", s->top_field_first ? \"top\" :\"\",\ns->intra_dc_precision, s->picture_structure, s->frame_pred_frame_dct, s->concealment_motion_vectors,\ns->q_scale_type, s->intra_vlc_format, s->repeat_first_field, s->chroma_420_type ? \"420\" :\"\");", "}", "}", "for(;;) {", "#ifdef HAVE_XVMC\nif(s->avctx->xvmc_acceleration > 1)\nXVMC_init_block(s);", "#endif\ns->dsp.clear_blocks(s->block[0]);", "VAR_4 = mpeg_decode_mb(s, s->block);", "s->chroma_qscale= s->qscale;", "dprintf(\"VAR_4=%d\\n\", VAR_4);", "if (VAR_4 < 0)\nreturn -1;", "if(s->current_picture.motion_val[0] && !s->encoding){", "const int VAR_7 = VAR_5 ? 2*s->b8_stride : s->b8_stride;", "int VAR_8 = s->mb_x*2 + s->VAR_1*2*VAR_7;", "int VAR_9, VAR_10, VAR_11, VAR_12;", "if(VAR_5 && !s->first_field)\nVAR_8 += VAR_7/2;", "for(VAR_12=0; VAR_12<2; VAR_12++){", "for(VAR_11=0; VAR_11<2; VAR_11++){", "if (s->mb_intra || (VAR_11==1 && s->pict_type != B_TYPE)) {", "VAR_9 = VAR_10 = 0;", "}else if (s->mv_type == MV_TYPE_16X16 || (s->mv_type == MV_TYPE_FIELD && VAR_5)){", "VAR_9 = s->mv[VAR_11][0][0];", "VAR_10 = s->mv[VAR_11][0][1];", "} else {", "VAR_9 = s->mv[VAR_11][VAR_12][0];", "VAR_10 = s->mv[VAR_11][VAR_12][1];", "}", "s->current_picture.motion_val[VAR_11][VAR_8 ][0] = VAR_9;", "s->current_picture.motion_val[VAR_11][VAR_8 ][1] = VAR_10;", "s->current_picture.motion_val[VAR_11][VAR_8 + 1][0] = VAR_9;", "s->current_picture.motion_val[VAR_11][VAR_8 + 1][1] = VAR_10;", "s->current_picture.ref_index [VAR_11][VAR_8 ]=\ns->current_picture.ref_index [VAR_11][VAR_8 + 1]= s->field_select[VAR_11][VAR_12];", "}", "VAR_8 += VAR_7;", "}", "}", "s->dest[0] += 16;", "s->dest[1] += 8;", "s->dest[2] += 8;", "MPV_decode_mb(s, s->block);", "if (++s->mb_x >= s->mb_width) {", "ff_draw_horiz_band(s, 16*s->VAR_1, 16);", "s->mb_x = 0;", "s->VAR_1++;", "if(s->VAR_1<<VAR_5 >= s->mb_height){", "int VAR_13= s->gb.size_in_bits - get_bits_count(&s->gb);", "if(VAR_13 < 0 || (VAR_13 && show_bits(&s->gb, FFMIN(VAR_13, 23)))\n|| (avctx->error_resilience >= FF_ER_AGGRESSIVE && VAR_13>8)){", "av_log(avctx, AV_LOG_ERROR, \"end mismatch VAR_13=%d\\n\", VAR_13);", "return -1;", "}else", "goto eos;", "}", "ff_init_block_index(s);", "}", "if (s->mb_skip_run == -1) {", "s->mb_skip_run = 0;", "for(;;) {", "int VAR_14 = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2);", "if (VAR_14 < 0){", "av_log(s->avctx, AV_LOG_ERROR, \"mb incr damaged\\n\");", "return -1;", "}", "if (VAR_14 >= 33) {", "if (VAR_14 == 33) {", "s->mb_skip_run += 33;", "}else if(VAR_14 == 35){", "if(s->mb_skip_run != 0 || show_bits(&s->gb, 15) != 0){", "av_log(s->avctx, AV_LOG_ERROR, \"slice mismatch\\n\");", "return -1;", "}", "goto eos;", "}", "} else {", "s->mb_skip_run += VAR_14;", "break;", "}", "}", "}", "}", "eos:\n*VAR_2 += get_bits_count(&s->gb)/8 - 1;", "return 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17, 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 37 ], [ 39 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 115 ], [ 117 ], [ 119, 121, 123, 125, 127, 129 ], [ 131 ], [ 133 ], [ 137 ], [ 139, 143, 145 ], [ 147, 151 ], [ 155 ], [ 157 ], [ 161 ], [ 163, 165 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177, 179 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215, 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 229 ], [ 231 ], [ 233 ], [ 237 ], [ 241 ], [ 245 ], [ 249 ], [ 251 ], [ 255 ], [ 257 ], [ 261, 263 ], [ 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 277 ], [ 279 ], [ 285 ], [ 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ], [ 299 ], [ 301 ], [ 303 ], [ 305 ], [ 307 ], [ 309 ], [ 311 ], [ 313 ], [ 315 ], [ 317 ], [ 319 ], [ 321 ], [ 325 ], [ 327 ], [ 329 ], [ 331 ], [ 333 ], [ 335 ], [ 337 ], [ 339, 341 ], [ 345 ], [ 347 ] ]
12,561
av_cold void ff_schro_queue_init(FFSchroQueue *queue) { queue->p_head = queue->p_tail = NULL; queue->size = 0; }
true
FFmpeg
220b24c7c97dc033ceab1510549f66d0e7b52ef1
av_cold void ff_schro_queue_init(FFSchroQueue *queue) { queue->p_head = queue->p_tail = NULL; queue->size = 0; }
{ "code": [ "av_cold void ff_schro_queue_init(FFSchroQueue *queue)", " queue->p_head = queue->p_tail = NULL;", " queue->size = 0;" ], "line_no": [ 1, 5, 7 ] }
av_cold void FUNC_0(FFSchroQueue *queue) { queue->p_head = queue->p_tail = NULL; queue->size = 0; }
[ "av_cold void FUNC_0(FFSchroQueue *queue)\n{", "queue->p_head = queue->p_tail = NULL;", "queue->size = 0;", "}" ]
[ 1, 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ] ]
12,562
static int ffm_write_header(AVFormatContext *s) { FFMContext *ffm = s->priv_data; AVStream *st; ByteIOContext *pb = s->pb; AVCodecContext *codec; int bit_rate, i; ffm->packet_size = FFM_PACKET_SIZE; /* header */ put_le32(pb, MKTAG('F', 'F', 'M', '1')); put_be32(pb, ffm->packet_size); /* XXX: store write position in other file ? */ put_be64(pb, ffm->packet_size); /* current write position */ put_be32(pb, s->nb_streams); bit_rate = 0; for(i=0;i<s->nb_streams;i++) { st = s->streams[i]; bit_rate += st->codec->bit_rate; } put_be32(pb, bit_rate); /* list of streams */ for(i=0;i<s->nb_streams;i++) { st = s->streams[i]; av_set_pts_info(st, 64, 1, 1000000); codec = st->codec; /* generic info */ put_be32(pb, codec->codec_id); put_byte(pb, codec->codec_type); put_be32(pb, codec->bit_rate); put_be32(pb, st->quality); put_be32(pb, codec->flags); put_be32(pb, codec->flags2); put_be32(pb, codec->debug); /* specific info */ switch(codec->codec_type) { case CODEC_TYPE_VIDEO: put_be32(pb, codec->time_base.num); put_be32(pb, codec->time_base.den); put_be16(pb, codec->width); put_be16(pb, codec->height); put_be16(pb, codec->gop_size); put_be32(pb, codec->pix_fmt); put_byte(pb, codec->qmin); put_byte(pb, codec->qmax); put_byte(pb, codec->max_qdiff); put_be16(pb, (int) (codec->qcompress * 10000.0)); put_be16(pb, (int) (codec->qblur * 10000.0)); put_be32(pb, codec->bit_rate_tolerance); put_strz(pb, codec->rc_eq); put_be32(pb, codec->rc_max_rate); put_be32(pb, codec->rc_min_rate); put_be32(pb, codec->rc_buffer_size); put_be64(pb, av_dbl2int(codec->i_quant_factor)); put_be64(pb, av_dbl2int(codec->b_quant_factor)); put_be64(pb, av_dbl2int(codec->i_quant_offset)); put_be64(pb, av_dbl2int(codec->b_quant_offset)); put_be32(pb, codec->dct_algo); put_be32(pb, codec->strict_std_compliance); put_be32(pb, codec->max_b_frames); put_be32(pb, codec->luma_elim_threshold); put_be32(pb, codec->chroma_elim_threshold); put_be32(pb, codec->mpeg_quant); put_be32(pb, codec->intra_dc_precision); put_be32(pb, codec->me_method); put_be32(pb, codec->mb_decision); put_be32(pb, codec->nsse_weight); put_be32(pb, codec->frame_skip_cmp); put_be64(pb, av_dbl2int(codec->rc_buffer_aggressivity)); put_be32(pb, codec->codec_tag); put_byte(pb, codec->thread_count); break; case CODEC_TYPE_AUDIO: put_be32(pb, codec->sample_rate); put_le16(pb, codec->channels); put_le16(pb, codec->frame_size); break; default: return -1; } if (codec->flags & CODEC_FLAG_GLOBAL_HEADER) { put_be32(pb, codec->extradata_size); put_buffer(pb, codec->extradata, codec->extradata_size); } } /* flush until end of block reached */ while ((url_ftell(pb) % ffm->packet_size) != 0) put_byte(pb, 0); put_flush_packet(pb); /* init packet mux */ ffm->packet_ptr = ffm->packet; ffm->packet_end = ffm->packet + ffm->packet_size - FFM_HEADER_SIZE; assert(ffm->packet_end >= ffm->packet); ffm->frame_offset = 0; ffm->dts = 0; ffm->first_packet = 1; return 0; }
true
FFmpeg
3cffbe090a5168dcfe580de8d662a32e7ad1d911
static int ffm_write_header(AVFormatContext *s) { FFMContext *ffm = s->priv_data; AVStream *st; ByteIOContext *pb = s->pb; AVCodecContext *codec; int bit_rate, i; ffm->packet_size = FFM_PACKET_SIZE; put_le32(pb, MKTAG('F', 'F', 'M', '1')); put_be32(pb, ffm->packet_size); put_be64(pb, ffm->packet_size); put_be32(pb, s->nb_streams); bit_rate = 0; for(i=0;i<s->nb_streams;i++) { st = s->streams[i]; bit_rate += st->codec->bit_rate; } put_be32(pb, bit_rate); for(i=0;i<s->nb_streams;i++) { st = s->streams[i]; av_set_pts_info(st, 64, 1, 1000000); codec = st->codec; put_be32(pb, codec->codec_id); put_byte(pb, codec->codec_type); put_be32(pb, codec->bit_rate); put_be32(pb, st->quality); put_be32(pb, codec->flags); put_be32(pb, codec->flags2); put_be32(pb, codec->debug); switch(codec->codec_type) { case CODEC_TYPE_VIDEO: put_be32(pb, codec->time_base.num); put_be32(pb, codec->time_base.den); put_be16(pb, codec->width); put_be16(pb, codec->height); put_be16(pb, codec->gop_size); put_be32(pb, codec->pix_fmt); put_byte(pb, codec->qmin); put_byte(pb, codec->qmax); put_byte(pb, codec->max_qdiff); put_be16(pb, (int) (codec->qcompress * 10000.0)); put_be16(pb, (int) (codec->qblur * 10000.0)); put_be32(pb, codec->bit_rate_tolerance); put_strz(pb, codec->rc_eq); put_be32(pb, codec->rc_max_rate); put_be32(pb, codec->rc_min_rate); put_be32(pb, codec->rc_buffer_size); put_be64(pb, av_dbl2int(codec->i_quant_factor)); put_be64(pb, av_dbl2int(codec->b_quant_factor)); put_be64(pb, av_dbl2int(codec->i_quant_offset)); put_be64(pb, av_dbl2int(codec->b_quant_offset)); put_be32(pb, codec->dct_algo); put_be32(pb, codec->strict_std_compliance); put_be32(pb, codec->max_b_frames); put_be32(pb, codec->luma_elim_threshold); put_be32(pb, codec->chroma_elim_threshold); put_be32(pb, codec->mpeg_quant); put_be32(pb, codec->intra_dc_precision); put_be32(pb, codec->me_method); put_be32(pb, codec->mb_decision); put_be32(pb, codec->nsse_weight); put_be32(pb, codec->frame_skip_cmp); put_be64(pb, av_dbl2int(codec->rc_buffer_aggressivity)); put_be32(pb, codec->codec_tag); put_byte(pb, codec->thread_count); break; case CODEC_TYPE_AUDIO: put_be32(pb, codec->sample_rate); put_le16(pb, codec->channels); put_le16(pb, codec->frame_size); break; default: return -1; } if (codec->flags & CODEC_FLAG_GLOBAL_HEADER) { put_be32(pb, codec->extradata_size); put_buffer(pb, codec->extradata, codec->extradata_size); } } while ((url_ftell(pb) % ffm->packet_size) != 0) put_byte(pb, 0); put_flush_packet(pb); ffm->packet_ptr = ffm->packet; ffm->packet_end = ffm->packet + ffm->packet_size - FFM_HEADER_SIZE; assert(ffm->packet_end >= ffm->packet); ffm->frame_offset = 0; ffm->dts = 0; ffm->first_packet = 1; return 0; }
{ "code": [ " put_strz(pb, codec->rc_eq);" ], "line_no": [ 107 ] }
static int FUNC_0(AVFormatContext *VAR_0) { FFMContext *ffm = VAR_0->priv_data; AVStream *st; ByteIOContext *pb = VAR_0->pb; AVCodecContext *codec; int VAR_1, VAR_2; ffm->packet_size = FFM_PACKET_SIZE; put_le32(pb, MKTAG('F', 'F', 'M', '1')); put_be32(pb, ffm->packet_size); put_be64(pb, ffm->packet_size); put_be32(pb, VAR_0->nb_streams); VAR_1 = 0; for(VAR_2=0;VAR_2<VAR_0->nb_streams;VAR_2++) { st = VAR_0->streams[VAR_2]; VAR_1 += st->codec->VAR_1; } put_be32(pb, VAR_1); for(VAR_2=0;VAR_2<VAR_0->nb_streams;VAR_2++) { st = VAR_0->streams[VAR_2]; av_set_pts_info(st, 64, 1, 1000000); codec = st->codec; put_be32(pb, codec->codec_id); put_byte(pb, codec->codec_type); put_be32(pb, codec->VAR_1); put_be32(pb, st->quality); put_be32(pb, codec->flags); put_be32(pb, codec->flags2); put_be32(pb, codec->debug); switch(codec->codec_type) { case CODEC_TYPE_VIDEO: put_be32(pb, codec->time_base.num); put_be32(pb, codec->time_base.den); put_be16(pb, codec->width); put_be16(pb, codec->height); put_be16(pb, codec->gop_size); put_be32(pb, codec->pix_fmt); put_byte(pb, codec->qmin); put_byte(pb, codec->qmax); put_byte(pb, codec->max_qdiff); put_be16(pb, (int) (codec->qcompress * 10000.0)); put_be16(pb, (int) (codec->qblur * 10000.0)); put_be32(pb, codec->bit_rate_tolerance); put_strz(pb, codec->rc_eq); put_be32(pb, codec->rc_max_rate); put_be32(pb, codec->rc_min_rate); put_be32(pb, codec->rc_buffer_size); put_be64(pb, av_dbl2int(codec->i_quant_factor)); put_be64(pb, av_dbl2int(codec->b_quant_factor)); put_be64(pb, av_dbl2int(codec->i_quant_offset)); put_be64(pb, av_dbl2int(codec->b_quant_offset)); put_be32(pb, codec->dct_algo); put_be32(pb, codec->strict_std_compliance); put_be32(pb, codec->max_b_frames); put_be32(pb, codec->luma_elim_threshold); put_be32(pb, codec->chroma_elim_threshold); put_be32(pb, codec->mpeg_quant); put_be32(pb, codec->intra_dc_precision); put_be32(pb, codec->me_method); put_be32(pb, codec->mb_decision); put_be32(pb, codec->nsse_weight); put_be32(pb, codec->frame_skip_cmp); put_be64(pb, av_dbl2int(codec->rc_buffer_aggressivity)); put_be32(pb, codec->codec_tag); put_byte(pb, codec->thread_count); break; case CODEC_TYPE_AUDIO: put_be32(pb, codec->sample_rate); put_le16(pb, codec->channels); put_le16(pb, codec->frame_size); break; default: return -1; } if (codec->flags & CODEC_FLAG_GLOBAL_HEADER) { put_be32(pb, codec->extradata_size); put_buffer(pb, codec->extradata, codec->extradata_size); } } while ((url_ftell(pb) % ffm->packet_size) != 0) put_byte(pb, 0); put_flush_packet(pb); ffm->packet_ptr = ffm->packet; ffm->packet_end = ffm->packet + ffm->packet_size - FFM_HEADER_SIZE; assert(ffm->packet_end >= ffm->packet); ffm->frame_offset = 0; ffm->dts = 0; ffm->first_packet = 1; return 0; }
[ "static int FUNC_0(AVFormatContext *VAR_0)\n{", "FFMContext *ffm = VAR_0->priv_data;", "AVStream *st;", "ByteIOContext *pb = VAR_0->pb;", "AVCodecContext *codec;", "int VAR_1, VAR_2;", "ffm->packet_size = FFM_PACKET_SIZE;", "put_le32(pb, MKTAG('F', 'F', 'M', '1'));", "put_be32(pb, ffm->packet_size);", "put_be64(pb, ffm->packet_size);", "put_be32(pb, VAR_0->nb_streams);", "VAR_1 = 0;", "for(VAR_2=0;VAR_2<VAR_0->nb_streams;VAR_2++) {", "st = VAR_0->streams[VAR_2];", "VAR_1 += st->codec->VAR_1;", "}", "put_be32(pb, VAR_1);", "for(VAR_2=0;VAR_2<VAR_0->nb_streams;VAR_2++) {", "st = VAR_0->streams[VAR_2];", "av_set_pts_info(st, 64, 1, 1000000);", "codec = st->codec;", "put_be32(pb, codec->codec_id);", "put_byte(pb, codec->codec_type);", "put_be32(pb, codec->VAR_1);", "put_be32(pb, st->quality);", "put_be32(pb, codec->flags);", "put_be32(pb, codec->flags2);", "put_be32(pb, codec->debug);", "switch(codec->codec_type) {", "case CODEC_TYPE_VIDEO:\nput_be32(pb, codec->time_base.num);", "put_be32(pb, codec->time_base.den);", "put_be16(pb, codec->width);", "put_be16(pb, codec->height);", "put_be16(pb, codec->gop_size);", "put_be32(pb, codec->pix_fmt);", "put_byte(pb, codec->qmin);", "put_byte(pb, codec->qmax);", "put_byte(pb, codec->max_qdiff);", "put_be16(pb, (int) (codec->qcompress * 10000.0));", "put_be16(pb, (int) (codec->qblur * 10000.0));", "put_be32(pb, codec->bit_rate_tolerance);", "put_strz(pb, codec->rc_eq);", "put_be32(pb, codec->rc_max_rate);", "put_be32(pb, codec->rc_min_rate);", "put_be32(pb, codec->rc_buffer_size);", "put_be64(pb, av_dbl2int(codec->i_quant_factor));", "put_be64(pb, av_dbl2int(codec->b_quant_factor));", "put_be64(pb, av_dbl2int(codec->i_quant_offset));", "put_be64(pb, av_dbl2int(codec->b_quant_offset));", "put_be32(pb, codec->dct_algo);", "put_be32(pb, codec->strict_std_compliance);", "put_be32(pb, codec->max_b_frames);", "put_be32(pb, codec->luma_elim_threshold);", "put_be32(pb, codec->chroma_elim_threshold);", "put_be32(pb, codec->mpeg_quant);", "put_be32(pb, codec->intra_dc_precision);", "put_be32(pb, codec->me_method);", "put_be32(pb, codec->mb_decision);", "put_be32(pb, codec->nsse_weight);", "put_be32(pb, codec->frame_skip_cmp);", "put_be64(pb, av_dbl2int(codec->rc_buffer_aggressivity));", "put_be32(pb, codec->codec_tag);", "put_byte(pb, codec->thread_count);", "break;", "case CODEC_TYPE_AUDIO:\nput_be32(pb, codec->sample_rate);", "put_le16(pb, codec->channels);", "put_le16(pb, codec->frame_size);", "break;", "default:\nreturn -1;", "}", "if (codec->flags & CODEC_FLAG_GLOBAL_HEADER) {", "put_be32(pb, codec->extradata_size);", "put_buffer(pb, codec->extradata, codec->extradata_size);", "}", "}", "while ((url_ftell(pb) % ffm->packet_size) != 0)\nput_byte(pb, 0);", "put_flush_packet(pb);", "ffm->packet_ptr = ffm->packet;", "ffm->packet_end = ffm->packet + ffm->packet_size - FFM_HEADER_SIZE;", "assert(ffm->packet_end >= ffm->packet);", "ffm->frame_offset = 0;", "ffm->dts = 0;", "ffm->first_packet = 1;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 23 ], [ 25 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 63 ], [ 65 ], [ 67 ], [ 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 ], [ 183, 185 ], [ 189 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 209 ], [ 211 ] ]
12,563
static int assigned_device_pci_cap_init(PCIDevice *pci_dev, Error **errp) { AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev); PCIRegion *pci_region = dev->real_device.regions; int ret, pos; Error *local_err = NULL; /* Clear initial capabilities pointer and status copied from hw */ pci_set_byte(pci_dev->config + PCI_CAPABILITY_LIST, 0); pci_set_word(pci_dev->config + PCI_STATUS, pci_get_word(pci_dev->config + PCI_STATUS) & ~PCI_STATUS_CAP_LIST); /* Expose MSI capability * MSI capability is the 1st capability in capability config */ pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSI, 0); if (pos != 0 && kvm_check_extension(kvm_state, KVM_CAP_ASSIGN_DEV_IRQ)) { verify_irqchip_in_kernel(&local_err); if (local_err) { error_propagate(errp, local_err); return -ENOTSUP; } dev->cap.available |= ASSIGNED_DEVICE_CAP_MSI; /* Only 32-bit/no-mask currently supported */ ret = pci_add_capability2(pci_dev, PCI_CAP_ID_MSI, pos, 10, &local_err); if (ret < 0) { error_propagate(errp, local_err); return ret; } pci_dev->msi_cap = pos; pci_set_word(pci_dev->config + pos + PCI_MSI_FLAGS, pci_get_word(pci_dev->config + pos + PCI_MSI_FLAGS) & PCI_MSI_FLAGS_QMASK); pci_set_long(pci_dev->config + pos + PCI_MSI_ADDRESS_LO, 0); pci_set_word(pci_dev->config + pos + PCI_MSI_DATA_32, 0); /* Set writable fields */ pci_set_word(pci_dev->wmask + pos + PCI_MSI_FLAGS, PCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE); pci_set_long(pci_dev->wmask + pos + PCI_MSI_ADDRESS_LO, 0xfffffffc); pci_set_word(pci_dev->wmask + pos + PCI_MSI_DATA_32, 0xffff); } /* Expose MSI-X capability */ pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSIX, 0); if (pos != 0 && kvm_device_msix_supported(kvm_state)) { int bar_nr; uint32_t msix_table_entry; verify_irqchip_in_kernel(&local_err); if (local_err) { error_propagate(errp, local_err); return -ENOTSUP; } dev->cap.available |= ASSIGNED_DEVICE_CAP_MSIX; ret = pci_add_capability2(pci_dev, PCI_CAP_ID_MSIX, pos, 12, &local_err); if (ret < 0) { error_propagate(errp, local_err); return ret; } pci_dev->msix_cap = pos; pci_set_word(pci_dev->config + pos + PCI_MSIX_FLAGS, pci_get_word(pci_dev->config + pos + PCI_MSIX_FLAGS) & PCI_MSIX_FLAGS_QSIZE); /* Only enable and function mask bits are writable */ pci_set_word(pci_dev->wmask + pos + PCI_MSIX_FLAGS, PCI_MSIX_FLAGS_ENABLE | PCI_MSIX_FLAGS_MASKALL); msix_table_entry = pci_get_long(pci_dev->config + pos + PCI_MSIX_TABLE); bar_nr = msix_table_entry & PCI_MSIX_FLAGS_BIRMASK; msix_table_entry &= ~PCI_MSIX_FLAGS_BIRMASK; dev->msix_table_addr = pci_region[bar_nr].base_addr + msix_table_entry; dev->msix_max = pci_get_word(pci_dev->config + pos + PCI_MSIX_FLAGS); dev->msix_max &= PCI_MSIX_FLAGS_QSIZE; dev->msix_max += 1; } /* Minimal PM support, nothing writable, device appears to NAK changes */ pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_PM, 0); if (pos) { uint16_t pmc; ret = pci_add_capability2(pci_dev, PCI_CAP_ID_PM, pos, PCI_PM_SIZEOF, &local_err); if (ret < 0) { error_propagate(errp, local_err); return ret; } assigned_dev_setup_cap_read(dev, pos, PCI_PM_SIZEOF); pmc = pci_get_word(pci_dev->config + pos + PCI_CAP_FLAGS); pmc &= (PCI_PM_CAP_VER_MASK | PCI_PM_CAP_DSI); pci_set_word(pci_dev->config + pos + PCI_CAP_FLAGS, pmc); /* assign_device will bring the device up to D0, so we don't need * to worry about doing that ourselves here. */ pci_set_word(pci_dev->config + pos + PCI_PM_CTRL, PCI_PM_CTRL_NO_SOFT_RESET); pci_set_byte(pci_dev->config + pos + PCI_PM_PPB_EXTENSIONS, 0); pci_set_byte(pci_dev->config + pos + PCI_PM_DATA_REGISTER, 0); } pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_EXP, 0); if (pos) { uint8_t version, size = 0; uint16_t type, devctl, lnksta; uint32_t devcap, lnkcap; version = pci_get_byte(pci_dev->config + pos + PCI_EXP_FLAGS); version &= PCI_EXP_FLAGS_VERS; if (version == 1) { size = 0x14; } else if (version == 2) { /* * Check for non-std size, accept reduced size to 0x34, * which is what bcm5761 implemented, violating the * PCIe v3.0 spec that regs should exist and be read as 0, * not optionally provided and shorten the struct size. */ size = MIN(0x3c, PCI_CONFIG_SPACE_SIZE - pos); if (size < 0x34) { error_setg(errp, "Invalid size PCIe cap-id 0x%x", PCI_CAP_ID_EXP); return -EINVAL; } else if (size != 0x3c) { error_report("WARNING, %s: PCIe cap-id 0x%x has " "non-standard size 0x%x; std size should be 0x3c", __func__, PCI_CAP_ID_EXP, size); } } else if (version == 0) { uint16_t vid, did; vid = pci_get_word(pci_dev->config + PCI_VENDOR_ID); did = pci_get_word(pci_dev->config + PCI_DEVICE_ID); if (vid == PCI_VENDOR_ID_INTEL && did == 0x10ed) { /* * quirk for Intel 82599 VF with invalid PCIe capability * version, should really be version 2 (same as PF) */ size = 0x3c; } } if (size == 0) { error_setg(errp, "Unsupported PCI express capability version %d", version); return -EINVAL; } ret = pci_add_capability2(pci_dev, PCI_CAP_ID_EXP, pos, size, &local_err); if (ret < 0) { error_propagate(errp, local_err); return ret; } assigned_dev_setup_cap_read(dev, pos, size); type = pci_get_word(pci_dev->config + pos + PCI_EXP_FLAGS); type = (type & PCI_EXP_FLAGS_TYPE) >> 4; if (type != PCI_EXP_TYPE_ENDPOINT && type != PCI_EXP_TYPE_LEG_END && type != PCI_EXP_TYPE_RC_END) { error_setg(errp, "Device assignment only supports endpoint " "assignment, device type %d", type); return -EINVAL; } /* capabilities, pass existing read-only copy * PCI_EXP_FLAGS_IRQ: updated by hardware, should be direct read */ /* device capabilities: hide FLR */ devcap = pci_get_long(pci_dev->config + pos + PCI_EXP_DEVCAP); devcap &= ~PCI_EXP_DEVCAP_FLR; pci_set_long(pci_dev->config + pos + PCI_EXP_DEVCAP, devcap); /* device control: clear all error reporting enable bits, leaving * only a few host values. Note, these are * all writable, but not passed to hw. */ devctl = pci_get_word(pci_dev->config + pos + PCI_EXP_DEVCTL); devctl = (devctl & (PCI_EXP_DEVCTL_READRQ | PCI_EXP_DEVCTL_PAYLOAD)) | PCI_EXP_DEVCTL_RELAX_EN | PCI_EXP_DEVCTL_NOSNOOP_EN; pci_set_word(pci_dev->config + pos + PCI_EXP_DEVCTL, devctl); devctl = PCI_EXP_DEVCTL_BCR_FLR | PCI_EXP_DEVCTL_AUX_PME; pci_set_word(pci_dev->wmask + pos + PCI_EXP_DEVCTL, ~devctl); /* Clear device status */ pci_set_word(pci_dev->config + pos + PCI_EXP_DEVSTA, 0); /* Link capabilities, expose links and latencues, clear reporting */ lnkcap = pci_get_long(pci_dev->config + pos + PCI_EXP_LNKCAP); lnkcap &= (PCI_EXP_LNKCAP_SLS | PCI_EXP_LNKCAP_MLW | PCI_EXP_LNKCAP_ASPMS | PCI_EXP_LNKCAP_L0SEL | PCI_EXP_LNKCAP_L1EL); pci_set_long(pci_dev->config + pos + PCI_EXP_LNKCAP, lnkcap); /* Link control, pass existing read-only copy. Should be writable? */ /* Link status, only expose current speed and width */ lnksta = pci_get_word(pci_dev->config + pos + PCI_EXP_LNKSTA); lnksta &= (PCI_EXP_LNKSTA_CLS | PCI_EXP_LNKSTA_NLW); pci_set_word(pci_dev->config + pos + PCI_EXP_LNKSTA, lnksta); if (version >= 2) { /* Slot capabilities, control, status - not needed for endpoints */ pci_set_long(pci_dev->config + pos + PCI_EXP_SLTCAP, 0); pci_set_word(pci_dev->config + pos + PCI_EXP_SLTCTL, 0); pci_set_word(pci_dev->config + pos + PCI_EXP_SLTSTA, 0); /* Root control, capabilities, status - not needed for endpoints */ pci_set_word(pci_dev->config + pos + PCI_EXP_RTCTL, 0); pci_set_word(pci_dev->config + pos + PCI_EXP_RTCAP, 0); pci_set_long(pci_dev->config + pos + PCI_EXP_RTSTA, 0); /* Device capabilities/control 2, pass existing read-only copy */ /* Link control 2, pass existing read-only copy */ } } pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_PCIX, 0); if (pos) { uint16_t cmd; uint32_t status; /* Only expose the minimum, 8 byte capability */ ret = pci_add_capability2(pci_dev, PCI_CAP_ID_PCIX, pos, 8, &local_err); if (ret < 0) { error_propagate(errp, local_err); return ret; } assigned_dev_setup_cap_read(dev, pos, 8); /* Command register, clear upper bits, including extended modes */ cmd = pci_get_word(pci_dev->config + pos + PCI_X_CMD); cmd &= (PCI_X_CMD_DPERR_E | PCI_X_CMD_ERO | PCI_X_CMD_MAX_READ | PCI_X_CMD_MAX_SPLIT); pci_set_word(pci_dev->config + pos + PCI_X_CMD, cmd); /* Status register, update with emulated PCI bus location, clear * error bits, leave the rest. */ status = pci_get_long(pci_dev->config + pos + PCI_X_STATUS); status &= ~(PCI_X_STATUS_BUS | PCI_X_STATUS_DEVFN); status |= (pci_bus_num(pci_dev->bus) << 8) | pci_dev->devfn; status &= ~(PCI_X_STATUS_SPL_DISC | PCI_X_STATUS_UNX_SPL | PCI_X_STATUS_SPL_ERR); pci_set_long(pci_dev->config + pos + PCI_X_STATUS, status); } pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_VPD, 0); if (pos) { /* Direct R/W passthrough */ ret = pci_add_capability2(pci_dev, PCI_CAP_ID_VPD, pos, 8, &local_err); if (ret < 0) { error_propagate(errp, local_err); return ret; } assigned_dev_setup_cap_read(dev, pos, 8); /* direct write for cap content */ assigned_dev_direct_config_write(dev, pos + 2, 6); } /* Devices can have multiple vendor capabilities, get them all */ for (pos = 0; (pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_VNDR, pos)); pos += PCI_CAP_LIST_NEXT) { uint8_t len = pci_get_byte(pci_dev->config + pos + PCI_CAP_FLAGS); /* Direct R/W passthrough */ ret = pci_add_capability2(pci_dev, PCI_CAP_ID_VNDR, pos, len, &local_err); if (ret < 0) { error_propagate(errp, local_err); return ret; } assigned_dev_setup_cap_read(dev, pos, len); /* direct write for cap content */ assigned_dev_direct_config_write(dev, pos + 2, len - 2); } /* If real and virtual capability list status bits differ, virtualize the * access. */ if ((pci_get_word(pci_dev->config + PCI_STATUS) & PCI_STATUS_CAP_LIST) != (assigned_dev_pci_read_byte(pci_dev, PCI_STATUS) & PCI_STATUS_CAP_LIST)) { dev->emulate_config_read[PCI_STATUS] |= PCI_STATUS_CAP_LIST; } return 0; }
true
qemu
639973a4740f38789057744b550df3a175bc49ad
static int assigned_device_pci_cap_init(PCIDevice *pci_dev, Error **errp) { AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev); PCIRegion *pci_region = dev->real_device.regions; int ret, pos; Error *local_err = NULL; pci_set_byte(pci_dev->config + PCI_CAPABILITY_LIST, 0); pci_set_word(pci_dev->config + PCI_STATUS, pci_get_word(pci_dev->config + PCI_STATUS) & ~PCI_STATUS_CAP_LIST); pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSI, 0); if (pos != 0 && kvm_check_extension(kvm_state, KVM_CAP_ASSIGN_DEV_IRQ)) { verify_irqchip_in_kernel(&local_err); if (local_err) { error_propagate(errp, local_err); return -ENOTSUP; } dev->cap.available |= ASSIGNED_DEVICE_CAP_MSI; ret = pci_add_capability2(pci_dev, PCI_CAP_ID_MSI, pos, 10, &local_err); if (ret < 0) { error_propagate(errp, local_err); return ret; } pci_dev->msi_cap = pos; pci_set_word(pci_dev->config + pos + PCI_MSI_FLAGS, pci_get_word(pci_dev->config + pos + PCI_MSI_FLAGS) & PCI_MSI_FLAGS_QMASK); pci_set_long(pci_dev->config + pos + PCI_MSI_ADDRESS_LO, 0); pci_set_word(pci_dev->config + pos + PCI_MSI_DATA_32, 0); pci_set_word(pci_dev->wmask + pos + PCI_MSI_FLAGS, PCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE); pci_set_long(pci_dev->wmask + pos + PCI_MSI_ADDRESS_LO, 0xfffffffc); pci_set_word(pci_dev->wmask + pos + PCI_MSI_DATA_32, 0xffff); } pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSIX, 0); if (pos != 0 && kvm_device_msix_supported(kvm_state)) { int bar_nr; uint32_t msix_table_entry; verify_irqchip_in_kernel(&local_err); if (local_err) { error_propagate(errp, local_err); return -ENOTSUP; } dev->cap.available |= ASSIGNED_DEVICE_CAP_MSIX; ret = pci_add_capability2(pci_dev, PCI_CAP_ID_MSIX, pos, 12, &local_err); if (ret < 0) { error_propagate(errp, local_err); return ret; } pci_dev->msix_cap = pos; pci_set_word(pci_dev->config + pos + PCI_MSIX_FLAGS, pci_get_word(pci_dev->config + pos + PCI_MSIX_FLAGS) & PCI_MSIX_FLAGS_QSIZE); pci_set_word(pci_dev->wmask + pos + PCI_MSIX_FLAGS, PCI_MSIX_FLAGS_ENABLE | PCI_MSIX_FLAGS_MASKALL); msix_table_entry = pci_get_long(pci_dev->config + pos + PCI_MSIX_TABLE); bar_nr = msix_table_entry & PCI_MSIX_FLAGS_BIRMASK; msix_table_entry &= ~PCI_MSIX_FLAGS_BIRMASK; dev->msix_table_addr = pci_region[bar_nr].base_addr + msix_table_entry; dev->msix_max = pci_get_word(pci_dev->config + pos + PCI_MSIX_FLAGS); dev->msix_max &= PCI_MSIX_FLAGS_QSIZE; dev->msix_max += 1; } pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_PM, 0); if (pos) { uint16_t pmc; ret = pci_add_capability2(pci_dev, PCI_CAP_ID_PM, pos, PCI_PM_SIZEOF, &local_err); if (ret < 0) { error_propagate(errp, local_err); return ret; } assigned_dev_setup_cap_read(dev, pos, PCI_PM_SIZEOF); pmc = pci_get_word(pci_dev->config + pos + PCI_CAP_FLAGS); pmc &= (PCI_PM_CAP_VER_MASK | PCI_PM_CAP_DSI); pci_set_word(pci_dev->config + pos + PCI_CAP_FLAGS, pmc); pci_set_word(pci_dev->config + pos + PCI_PM_CTRL, PCI_PM_CTRL_NO_SOFT_RESET); pci_set_byte(pci_dev->config + pos + PCI_PM_PPB_EXTENSIONS, 0); pci_set_byte(pci_dev->config + pos + PCI_PM_DATA_REGISTER, 0); } pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_EXP, 0); if (pos) { uint8_t version, size = 0; uint16_t type, devctl, lnksta; uint32_t devcap, lnkcap; version = pci_get_byte(pci_dev->config + pos + PCI_EXP_FLAGS); version &= PCI_EXP_FLAGS_VERS; if (version == 1) { size = 0x14; } else if (version == 2) { size = MIN(0x3c, PCI_CONFIG_SPACE_SIZE - pos); if (size < 0x34) { error_setg(errp, "Invalid size PCIe cap-id 0x%x", PCI_CAP_ID_EXP); return -EINVAL; } else if (size != 0x3c) { error_report("WARNING, %s: PCIe cap-id 0x%x has " "non-standard size 0x%x; std size should be 0x3c", __func__, PCI_CAP_ID_EXP, size); } } else if (version == 0) { uint16_t vid, did; vid = pci_get_word(pci_dev->config + PCI_VENDOR_ID); did = pci_get_word(pci_dev->config + PCI_DEVICE_ID); if (vid == PCI_VENDOR_ID_INTEL && did == 0x10ed) { size = 0x3c; } } if (size == 0) { error_setg(errp, "Unsupported PCI express capability version %d", version); return -EINVAL; } ret = pci_add_capability2(pci_dev, PCI_CAP_ID_EXP, pos, size, &local_err); if (ret < 0) { error_propagate(errp, local_err); return ret; } assigned_dev_setup_cap_read(dev, pos, size); type = pci_get_word(pci_dev->config + pos + PCI_EXP_FLAGS); type = (type & PCI_EXP_FLAGS_TYPE) >> 4; if (type != PCI_EXP_TYPE_ENDPOINT && type != PCI_EXP_TYPE_LEG_END && type != PCI_EXP_TYPE_RC_END) { error_setg(errp, "Device assignment only supports endpoint " "assignment, device type %d", type); return -EINVAL; } devcap = pci_get_long(pci_dev->config + pos + PCI_EXP_DEVCAP); devcap &= ~PCI_EXP_DEVCAP_FLR; pci_set_long(pci_dev->config + pos + PCI_EXP_DEVCAP, devcap); devctl = pci_get_word(pci_dev->config + pos + PCI_EXP_DEVCTL); devctl = (devctl & (PCI_EXP_DEVCTL_READRQ | PCI_EXP_DEVCTL_PAYLOAD)) | PCI_EXP_DEVCTL_RELAX_EN | PCI_EXP_DEVCTL_NOSNOOP_EN; pci_set_word(pci_dev->config + pos + PCI_EXP_DEVCTL, devctl); devctl = PCI_EXP_DEVCTL_BCR_FLR | PCI_EXP_DEVCTL_AUX_PME; pci_set_word(pci_dev->wmask + pos + PCI_EXP_DEVCTL, ~devctl); pci_set_word(pci_dev->config + pos + PCI_EXP_DEVSTA, 0); lnkcap = pci_get_long(pci_dev->config + pos + PCI_EXP_LNKCAP); lnkcap &= (PCI_EXP_LNKCAP_SLS | PCI_EXP_LNKCAP_MLW | PCI_EXP_LNKCAP_ASPMS | PCI_EXP_LNKCAP_L0SEL | PCI_EXP_LNKCAP_L1EL); pci_set_long(pci_dev->config + pos + PCI_EXP_LNKCAP, lnkcap); lnksta = pci_get_word(pci_dev->config + pos + PCI_EXP_LNKSTA); lnksta &= (PCI_EXP_LNKSTA_CLS | PCI_EXP_LNKSTA_NLW); pci_set_word(pci_dev->config + pos + PCI_EXP_LNKSTA, lnksta); if (version >= 2) { pci_set_long(pci_dev->config + pos + PCI_EXP_SLTCAP, 0); pci_set_word(pci_dev->config + pos + PCI_EXP_SLTCTL, 0); pci_set_word(pci_dev->config + pos + PCI_EXP_SLTSTA, 0); pci_set_word(pci_dev->config + pos + PCI_EXP_RTCTL, 0); pci_set_word(pci_dev->config + pos + PCI_EXP_RTCAP, 0); pci_set_long(pci_dev->config + pos + PCI_EXP_RTSTA, 0); } } pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_PCIX, 0); if (pos) { uint16_t cmd; uint32_t status; ret = pci_add_capability2(pci_dev, PCI_CAP_ID_PCIX, pos, 8, &local_err); if (ret < 0) { error_propagate(errp, local_err); return ret; } assigned_dev_setup_cap_read(dev, pos, 8); cmd = pci_get_word(pci_dev->config + pos + PCI_X_CMD); cmd &= (PCI_X_CMD_DPERR_E | PCI_X_CMD_ERO | PCI_X_CMD_MAX_READ | PCI_X_CMD_MAX_SPLIT); pci_set_word(pci_dev->config + pos + PCI_X_CMD, cmd); status = pci_get_long(pci_dev->config + pos + PCI_X_STATUS); status &= ~(PCI_X_STATUS_BUS | PCI_X_STATUS_DEVFN); status |= (pci_bus_num(pci_dev->bus) << 8) | pci_dev->devfn; status &= ~(PCI_X_STATUS_SPL_DISC | PCI_X_STATUS_UNX_SPL | PCI_X_STATUS_SPL_ERR); pci_set_long(pci_dev->config + pos + PCI_X_STATUS, status); } pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_VPD, 0); if (pos) { ret = pci_add_capability2(pci_dev, PCI_CAP_ID_VPD, pos, 8, &local_err); if (ret < 0) { error_propagate(errp, local_err); return ret; } assigned_dev_setup_cap_read(dev, pos, 8); assigned_dev_direct_config_write(dev, pos + 2, 6); } for (pos = 0; (pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_VNDR, pos)); pos += PCI_CAP_LIST_NEXT) { uint8_t len = pci_get_byte(pci_dev->config + pos + PCI_CAP_FLAGS); ret = pci_add_capability2(pci_dev, PCI_CAP_ID_VNDR, pos, len, &local_err); if (ret < 0) { error_propagate(errp, local_err); return ret; } assigned_dev_setup_cap_read(dev, pos, len); assigned_dev_direct_config_write(dev, pos + 2, len - 2); } if ((pci_get_word(pci_dev->config + PCI_STATUS) & PCI_STATUS_CAP_LIST) != (assigned_dev_pci_read_byte(pci_dev, PCI_STATUS) & PCI_STATUS_CAP_LIST)) { dev->emulate_config_read[PCI_STATUS] |= PCI_STATUS_CAP_LIST; } return 0; }
{ "code": [ " pci_set_word(pci_dev->config + pos + PCI_MSIX_FLAGS,", " pci_get_word(pci_dev->config + pos + PCI_MSIX_FLAGS) &", " PCI_MSIX_FLAGS_QSIZE);", " dev->msix_max = pci_get_word(pci_dev->config + pos + PCI_MSIX_FLAGS);", " dev->msix_max &= PCI_MSIX_FLAGS_QSIZE;", " dev->msix_max += 1;" ], "line_no": [ 129, 131, 133, 153, 155, 157 ] }
static int FUNC_0(PCIDevice *VAR_0, Error **VAR_1) { AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, VAR_0); PCIRegion *pci_region = dev->real_device.regions; int VAR_2, VAR_3; Error *local_err = NULL; pci_set_byte(VAR_0->config + PCI_CAPABILITY_LIST, 0); pci_set_word(VAR_0->config + PCI_STATUS, pci_get_word(VAR_0->config + PCI_STATUS) & ~PCI_STATUS_CAP_LIST); VAR_3 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_MSI, 0); if (VAR_3 != 0 && kvm_check_extension(kvm_state, KVM_CAP_ASSIGN_DEV_IRQ)) { verify_irqchip_in_kernel(&local_err); if (local_err) { error_propagate(VAR_1, local_err); return -ENOTSUP; } dev->cap.available |= ASSIGNED_DEVICE_CAP_MSI; VAR_2 = pci_add_capability2(VAR_0, PCI_CAP_ID_MSI, VAR_3, 10, &local_err); if (VAR_2 < 0) { error_propagate(VAR_1, local_err); return VAR_2; } VAR_0->msi_cap = VAR_3; pci_set_word(VAR_0->config + VAR_3 + PCI_MSI_FLAGS, pci_get_word(VAR_0->config + VAR_3 + PCI_MSI_FLAGS) & PCI_MSI_FLAGS_QMASK); pci_set_long(VAR_0->config + VAR_3 + PCI_MSI_ADDRESS_LO, 0); pci_set_word(VAR_0->config + VAR_3 + PCI_MSI_DATA_32, 0); pci_set_word(VAR_0->wmask + VAR_3 + PCI_MSI_FLAGS, PCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE); pci_set_long(VAR_0->wmask + VAR_3 + PCI_MSI_ADDRESS_LO, 0xfffffffc); pci_set_word(VAR_0->wmask + VAR_3 + PCI_MSI_DATA_32, 0xffff); } VAR_3 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_MSIX, 0); if (VAR_3 != 0 && kvm_device_msix_supported(kvm_state)) { int VAR_4; uint32_t msix_table_entry; verify_irqchip_in_kernel(&local_err); if (local_err) { error_propagate(VAR_1, local_err); return -ENOTSUP; } dev->cap.available |= ASSIGNED_DEVICE_CAP_MSIX; VAR_2 = pci_add_capability2(VAR_0, PCI_CAP_ID_MSIX, VAR_3, 12, &local_err); if (VAR_2 < 0) { error_propagate(VAR_1, local_err); return VAR_2; } VAR_0->msix_cap = VAR_3; pci_set_word(VAR_0->config + VAR_3 + PCI_MSIX_FLAGS, pci_get_word(VAR_0->config + VAR_3 + PCI_MSIX_FLAGS) & PCI_MSIX_FLAGS_QSIZE); pci_set_word(VAR_0->wmask + VAR_3 + PCI_MSIX_FLAGS, PCI_MSIX_FLAGS_ENABLE | PCI_MSIX_FLAGS_MASKALL); msix_table_entry = pci_get_long(VAR_0->config + VAR_3 + PCI_MSIX_TABLE); VAR_4 = msix_table_entry & PCI_MSIX_FLAGS_BIRMASK; msix_table_entry &= ~PCI_MSIX_FLAGS_BIRMASK; dev->msix_table_addr = pci_region[VAR_4].base_addr + msix_table_entry; dev->msix_max = pci_get_word(VAR_0->config + VAR_3 + PCI_MSIX_FLAGS); dev->msix_max &= PCI_MSIX_FLAGS_QSIZE; dev->msix_max += 1; } VAR_3 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_PM, 0); if (VAR_3) { uint16_t pmc; VAR_2 = pci_add_capability2(VAR_0, PCI_CAP_ID_PM, VAR_3, PCI_PM_SIZEOF, &local_err); if (VAR_2 < 0) { error_propagate(VAR_1, local_err); return VAR_2; } assigned_dev_setup_cap_read(dev, VAR_3, PCI_PM_SIZEOF); pmc = pci_get_word(VAR_0->config + VAR_3 + PCI_CAP_FLAGS); pmc &= (PCI_PM_CAP_VER_MASK | PCI_PM_CAP_DSI); pci_set_word(VAR_0->config + VAR_3 + PCI_CAP_FLAGS, pmc); pci_set_word(VAR_0->config + VAR_3 + PCI_PM_CTRL, PCI_PM_CTRL_NO_SOFT_RESET); pci_set_byte(VAR_0->config + VAR_3 + PCI_PM_PPB_EXTENSIONS, 0); pci_set_byte(VAR_0->config + VAR_3 + PCI_PM_DATA_REGISTER, 0); } VAR_3 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_EXP, 0); if (VAR_3) { uint8_t version, size = 0; uint16_t type, devctl, lnksta; uint32_t devcap, lnkcap; version = pci_get_byte(VAR_0->config + VAR_3 + PCI_EXP_FLAGS); version &= PCI_EXP_FLAGS_VERS; if (version == 1) { size = 0x14; } else if (version == 2) { size = MIN(0x3c, PCI_CONFIG_SPACE_SIZE - VAR_3); if (size < 0x34) { error_setg(VAR_1, "Invalid size PCIe cap-id 0x%x", PCI_CAP_ID_EXP); return -EINVAL; } else if (size != 0x3c) { error_report("WARNING, %s: PCIe cap-id 0x%x has " "non-standard size 0x%x; std size should be 0x3c", __func__, PCI_CAP_ID_EXP, size); } } else if (version == 0) { uint16_t vid, did; vid = pci_get_word(VAR_0->config + PCI_VENDOR_ID); did = pci_get_word(VAR_0->config + PCI_DEVICE_ID); if (vid == PCI_VENDOR_ID_INTEL && did == 0x10ed) { size = 0x3c; } } if (size == 0) { error_setg(VAR_1, "Unsupported PCI express capability version %d", version); return -EINVAL; } VAR_2 = pci_add_capability2(VAR_0, PCI_CAP_ID_EXP, VAR_3, size, &local_err); if (VAR_2 < 0) { error_propagate(VAR_1, local_err); return VAR_2; } assigned_dev_setup_cap_read(dev, VAR_3, size); type = pci_get_word(VAR_0->config + VAR_3 + PCI_EXP_FLAGS); type = (type & PCI_EXP_FLAGS_TYPE) >> 4; if (type != PCI_EXP_TYPE_ENDPOINT && type != PCI_EXP_TYPE_LEG_END && type != PCI_EXP_TYPE_RC_END) { error_setg(VAR_1, "Device assignment only supports endpoint " "assignment, device type %d", type); return -EINVAL; } devcap = pci_get_long(VAR_0->config + VAR_3 + PCI_EXP_DEVCAP); devcap &= ~PCI_EXP_DEVCAP_FLR; pci_set_long(VAR_0->config + VAR_3 + PCI_EXP_DEVCAP, devcap); devctl = pci_get_word(VAR_0->config + VAR_3 + PCI_EXP_DEVCTL); devctl = (devctl & (PCI_EXP_DEVCTL_READRQ | PCI_EXP_DEVCTL_PAYLOAD)) | PCI_EXP_DEVCTL_RELAX_EN | PCI_EXP_DEVCTL_NOSNOOP_EN; pci_set_word(VAR_0->config + VAR_3 + PCI_EXP_DEVCTL, devctl); devctl = PCI_EXP_DEVCTL_BCR_FLR | PCI_EXP_DEVCTL_AUX_PME; pci_set_word(VAR_0->wmask + VAR_3 + PCI_EXP_DEVCTL, ~devctl); pci_set_word(VAR_0->config + VAR_3 + PCI_EXP_DEVSTA, 0); lnkcap = pci_get_long(VAR_0->config + VAR_3 + PCI_EXP_LNKCAP); lnkcap &= (PCI_EXP_LNKCAP_SLS | PCI_EXP_LNKCAP_MLW | PCI_EXP_LNKCAP_ASPMS | PCI_EXP_LNKCAP_L0SEL | PCI_EXP_LNKCAP_L1EL); pci_set_long(VAR_0->config + VAR_3 + PCI_EXP_LNKCAP, lnkcap); lnksta = pci_get_word(VAR_0->config + VAR_3 + PCI_EXP_LNKSTA); lnksta &= (PCI_EXP_LNKSTA_CLS | PCI_EXP_LNKSTA_NLW); pci_set_word(VAR_0->config + VAR_3 + PCI_EXP_LNKSTA, lnksta); if (version >= 2) { pci_set_long(VAR_0->config + VAR_3 + PCI_EXP_SLTCAP, 0); pci_set_word(VAR_0->config + VAR_3 + PCI_EXP_SLTCTL, 0); pci_set_word(VAR_0->config + VAR_3 + PCI_EXP_SLTSTA, 0); pci_set_word(VAR_0->config + VAR_3 + PCI_EXP_RTCTL, 0); pci_set_word(VAR_0->config + VAR_3 + PCI_EXP_RTCAP, 0); pci_set_long(VAR_0->config + VAR_3 + PCI_EXP_RTSTA, 0); } } VAR_3 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_PCIX, 0); if (VAR_3) { uint16_t cmd; uint32_t status; VAR_2 = pci_add_capability2(VAR_0, PCI_CAP_ID_PCIX, VAR_3, 8, &local_err); if (VAR_2 < 0) { error_propagate(VAR_1, local_err); return VAR_2; } assigned_dev_setup_cap_read(dev, VAR_3, 8); cmd = pci_get_word(VAR_0->config + VAR_3 + PCI_X_CMD); cmd &= (PCI_X_CMD_DPERR_E | PCI_X_CMD_ERO | PCI_X_CMD_MAX_READ | PCI_X_CMD_MAX_SPLIT); pci_set_word(VAR_0->config + VAR_3 + PCI_X_CMD, cmd); status = pci_get_long(VAR_0->config + VAR_3 + PCI_X_STATUS); status &= ~(PCI_X_STATUS_BUS | PCI_X_STATUS_DEVFN); status |= (pci_bus_num(VAR_0->bus) << 8) | VAR_0->devfn; status &= ~(PCI_X_STATUS_SPL_DISC | PCI_X_STATUS_UNX_SPL | PCI_X_STATUS_SPL_ERR); pci_set_long(VAR_0->config + VAR_3 + PCI_X_STATUS, status); } VAR_3 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_VPD, 0); if (VAR_3) { VAR_2 = pci_add_capability2(VAR_0, PCI_CAP_ID_VPD, VAR_3, 8, &local_err); if (VAR_2 < 0) { error_propagate(VAR_1, local_err); return VAR_2; } assigned_dev_setup_cap_read(dev, VAR_3, 8); assigned_dev_direct_config_write(dev, VAR_3 + 2, 6); } for (VAR_3 = 0; (VAR_3 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_VNDR, VAR_3)); VAR_3 += PCI_CAP_LIST_NEXT) { uint8_t len = pci_get_byte(VAR_0->config + VAR_3 + PCI_CAP_FLAGS); VAR_2 = pci_add_capability2(VAR_0, PCI_CAP_ID_VNDR, VAR_3, len, &local_err); if (VAR_2 < 0) { error_propagate(VAR_1, local_err); return VAR_2; } assigned_dev_setup_cap_read(dev, VAR_3, len); assigned_dev_direct_config_write(dev, VAR_3 + 2, len - 2); } if ((pci_get_word(VAR_0->config + PCI_STATUS) & PCI_STATUS_CAP_LIST) != (assigned_dev_pci_read_byte(VAR_0, PCI_STATUS) & PCI_STATUS_CAP_LIST)) { dev->emulate_config_read[PCI_STATUS] |= PCI_STATUS_CAP_LIST; } return 0; }
[ "static int FUNC_0(PCIDevice *VAR_0, Error **VAR_1)\n{", "AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, VAR_0);", "PCIRegion *pci_region = dev->real_device.regions;", "int VAR_2, VAR_3;", "Error *local_err = NULL;", "pci_set_byte(VAR_0->config + PCI_CAPABILITY_LIST, 0);", "pci_set_word(VAR_0->config + PCI_STATUS,\npci_get_word(VAR_0->config + PCI_STATUS) &\n~PCI_STATUS_CAP_LIST);", "VAR_3 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_MSI, 0);", "if (VAR_3 != 0 && kvm_check_extension(kvm_state, KVM_CAP_ASSIGN_DEV_IRQ)) {", "verify_irqchip_in_kernel(&local_err);", "if (local_err) {", "error_propagate(VAR_1, local_err);", "return -ENOTSUP;", "}", "dev->cap.available |= ASSIGNED_DEVICE_CAP_MSI;", "VAR_2 = pci_add_capability2(VAR_0, PCI_CAP_ID_MSI, VAR_3, 10,\n&local_err);", "if (VAR_2 < 0) {", "error_propagate(VAR_1, local_err);", "return VAR_2;", "}", "VAR_0->msi_cap = VAR_3;", "pci_set_word(VAR_0->config + VAR_3 + PCI_MSI_FLAGS,\npci_get_word(VAR_0->config + VAR_3 + PCI_MSI_FLAGS) &\nPCI_MSI_FLAGS_QMASK);", "pci_set_long(VAR_0->config + VAR_3 + PCI_MSI_ADDRESS_LO, 0);", "pci_set_word(VAR_0->config + VAR_3 + PCI_MSI_DATA_32, 0);", "pci_set_word(VAR_0->wmask + VAR_3 + PCI_MSI_FLAGS,\nPCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE);", "pci_set_long(VAR_0->wmask + VAR_3 + PCI_MSI_ADDRESS_LO, 0xfffffffc);", "pci_set_word(VAR_0->wmask + VAR_3 + PCI_MSI_DATA_32, 0xffff);", "}", "VAR_3 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_MSIX, 0);", "if (VAR_3 != 0 && kvm_device_msix_supported(kvm_state)) {", "int VAR_4;", "uint32_t msix_table_entry;", "verify_irqchip_in_kernel(&local_err);", "if (local_err) {", "error_propagate(VAR_1, local_err);", "return -ENOTSUP;", "}", "dev->cap.available |= ASSIGNED_DEVICE_CAP_MSIX;", "VAR_2 = pci_add_capability2(VAR_0, PCI_CAP_ID_MSIX, VAR_3, 12,\n&local_err);", "if (VAR_2 < 0) {", "error_propagate(VAR_1, local_err);", "return VAR_2;", "}", "VAR_0->msix_cap = VAR_3;", "pci_set_word(VAR_0->config + VAR_3 + PCI_MSIX_FLAGS,\npci_get_word(VAR_0->config + VAR_3 + PCI_MSIX_FLAGS) &\nPCI_MSIX_FLAGS_QSIZE);", "pci_set_word(VAR_0->wmask + VAR_3 + PCI_MSIX_FLAGS,\nPCI_MSIX_FLAGS_ENABLE | PCI_MSIX_FLAGS_MASKALL);", "msix_table_entry = pci_get_long(VAR_0->config + VAR_3 + PCI_MSIX_TABLE);", "VAR_4 = msix_table_entry & PCI_MSIX_FLAGS_BIRMASK;", "msix_table_entry &= ~PCI_MSIX_FLAGS_BIRMASK;", "dev->msix_table_addr = pci_region[VAR_4].base_addr + msix_table_entry;", "dev->msix_max = pci_get_word(VAR_0->config + VAR_3 + PCI_MSIX_FLAGS);", "dev->msix_max &= PCI_MSIX_FLAGS_QSIZE;", "dev->msix_max += 1;", "}", "VAR_3 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_PM, 0);", "if (VAR_3) {", "uint16_t pmc;", "VAR_2 = pci_add_capability2(VAR_0, PCI_CAP_ID_PM, VAR_3, PCI_PM_SIZEOF,\n&local_err);", "if (VAR_2 < 0) {", "error_propagate(VAR_1, local_err);", "return VAR_2;", "}", "assigned_dev_setup_cap_read(dev, VAR_3, PCI_PM_SIZEOF);", "pmc = pci_get_word(VAR_0->config + VAR_3 + PCI_CAP_FLAGS);", "pmc &= (PCI_PM_CAP_VER_MASK | PCI_PM_CAP_DSI);", "pci_set_word(VAR_0->config + VAR_3 + PCI_CAP_FLAGS, pmc);", "pci_set_word(VAR_0->config + VAR_3 + PCI_PM_CTRL,\nPCI_PM_CTRL_NO_SOFT_RESET);", "pci_set_byte(VAR_0->config + VAR_3 + PCI_PM_PPB_EXTENSIONS, 0);", "pci_set_byte(VAR_0->config + VAR_3 + PCI_PM_DATA_REGISTER, 0);", "}", "VAR_3 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_EXP, 0);", "if (VAR_3) {", "uint8_t version, size = 0;", "uint16_t type, devctl, lnksta;", "uint32_t devcap, lnkcap;", "version = pci_get_byte(VAR_0->config + VAR_3 + PCI_EXP_FLAGS);", "version &= PCI_EXP_FLAGS_VERS;", "if (version == 1) {", "size = 0x14;", "} else if (version == 2) {", "size = MIN(0x3c, PCI_CONFIG_SPACE_SIZE - VAR_3);", "if (size < 0x34) {", "error_setg(VAR_1, \"Invalid size PCIe cap-id 0x%x\",\nPCI_CAP_ID_EXP);", "return -EINVAL;", "} else if (size != 0x3c) {", "error_report(\"WARNING, %s: PCIe cap-id 0x%x has \"\n\"non-standard size 0x%x; std size should be 0x3c\",", "__func__, PCI_CAP_ID_EXP, size);", "}", "} else if (version == 0) {", "uint16_t vid, did;", "vid = pci_get_word(VAR_0->config + PCI_VENDOR_ID);", "did = pci_get_word(VAR_0->config + PCI_DEVICE_ID);", "if (vid == PCI_VENDOR_ID_INTEL && did == 0x10ed) {", "size = 0x3c;", "}", "}", "if (size == 0) {", "error_setg(VAR_1, \"Unsupported PCI express capability version %d\",\nversion);", "return -EINVAL;", "}", "VAR_2 = pci_add_capability2(VAR_0, PCI_CAP_ID_EXP, VAR_3, size,\n&local_err);", "if (VAR_2 < 0) {", "error_propagate(VAR_1, local_err);", "return VAR_2;", "}", "assigned_dev_setup_cap_read(dev, VAR_3, size);", "type = pci_get_word(VAR_0->config + VAR_3 + PCI_EXP_FLAGS);", "type = (type & PCI_EXP_FLAGS_TYPE) >> 4;", "if (type != PCI_EXP_TYPE_ENDPOINT &&\ntype != PCI_EXP_TYPE_LEG_END && type != PCI_EXP_TYPE_RC_END) {", "error_setg(VAR_1, \"Device assignment only supports endpoint \"\n\"assignment, device type %d\", type);", "return -EINVAL;", "}", "devcap = pci_get_long(VAR_0->config + VAR_3 + PCI_EXP_DEVCAP);", "devcap &= ~PCI_EXP_DEVCAP_FLR;", "pci_set_long(VAR_0->config + VAR_3 + PCI_EXP_DEVCAP, devcap);", "devctl = pci_get_word(VAR_0->config + VAR_3 + PCI_EXP_DEVCTL);", "devctl = (devctl & (PCI_EXP_DEVCTL_READRQ | PCI_EXP_DEVCTL_PAYLOAD)) |\nPCI_EXP_DEVCTL_RELAX_EN | PCI_EXP_DEVCTL_NOSNOOP_EN;", "pci_set_word(VAR_0->config + VAR_3 + PCI_EXP_DEVCTL, devctl);", "devctl = PCI_EXP_DEVCTL_BCR_FLR | PCI_EXP_DEVCTL_AUX_PME;", "pci_set_word(VAR_0->wmask + VAR_3 + PCI_EXP_DEVCTL, ~devctl);", "pci_set_word(VAR_0->config + VAR_3 + PCI_EXP_DEVSTA, 0);", "lnkcap = pci_get_long(VAR_0->config + VAR_3 + PCI_EXP_LNKCAP);", "lnkcap &= (PCI_EXP_LNKCAP_SLS | PCI_EXP_LNKCAP_MLW |\nPCI_EXP_LNKCAP_ASPMS | PCI_EXP_LNKCAP_L0SEL |\nPCI_EXP_LNKCAP_L1EL);", "pci_set_long(VAR_0->config + VAR_3 + PCI_EXP_LNKCAP, lnkcap);", "lnksta = pci_get_word(VAR_0->config + VAR_3 + PCI_EXP_LNKSTA);", "lnksta &= (PCI_EXP_LNKSTA_CLS | PCI_EXP_LNKSTA_NLW);", "pci_set_word(VAR_0->config + VAR_3 + PCI_EXP_LNKSTA, lnksta);", "if (version >= 2) {", "pci_set_long(VAR_0->config + VAR_3 + PCI_EXP_SLTCAP, 0);", "pci_set_word(VAR_0->config + VAR_3 + PCI_EXP_SLTCTL, 0);", "pci_set_word(VAR_0->config + VAR_3 + PCI_EXP_SLTSTA, 0);", "pci_set_word(VAR_0->config + VAR_3 + PCI_EXP_RTCTL, 0);", "pci_set_word(VAR_0->config + VAR_3 + PCI_EXP_RTCAP, 0);", "pci_set_long(VAR_0->config + VAR_3 + PCI_EXP_RTSTA, 0);", "}", "}", "VAR_3 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_PCIX, 0);", "if (VAR_3) {", "uint16_t cmd;", "uint32_t status;", "VAR_2 = pci_add_capability2(VAR_0, PCI_CAP_ID_PCIX, VAR_3, 8,\n&local_err);", "if (VAR_2 < 0) {", "error_propagate(VAR_1, local_err);", "return VAR_2;", "}", "assigned_dev_setup_cap_read(dev, VAR_3, 8);", "cmd = pci_get_word(VAR_0->config + VAR_3 + PCI_X_CMD);", "cmd &= (PCI_X_CMD_DPERR_E | PCI_X_CMD_ERO | PCI_X_CMD_MAX_READ |\nPCI_X_CMD_MAX_SPLIT);", "pci_set_word(VAR_0->config + VAR_3 + PCI_X_CMD, cmd);", "status = pci_get_long(VAR_0->config + VAR_3 + PCI_X_STATUS);", "status &= ~(PCI_X_STATUS_BUS | PCI_X_STATUS_DEVFN);", "status |= (pci_bus_num(VAR_0->bus) << 8) | VAR_0->devfn;", "status &= ~(PCI_X_STATUS_SPL_DISC | PCI_X_STATUS_UNX_SPL |\nPCI_X_STATUS_SPL_ERR);", "pci_set_long(VAR_0->config + VAR_3 + PCI_X_STATUS, status);", "}", "VAR_3 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_VPD, 0);", "if (VAR_3) {", "VAR_2 = pci_add_capability2(VAR_0, PCI_CAP_ID_VPD, VAR_3, 8,\n&local_err);", "if (VAR_2 < 0) {", "error_propagate(VAR_1, local_err);", "return VAR_2;", "}", "assigned_dev_setup_cap_read(dev, VAR_3, 8);", "assigned_dev_direct_config_write(dev, VAR_3 + 2, 6);", "}", "for (VAR_3 = 0; (VAR_3 = pci_find_cap_offset(VAR_0, PCI_CAP_ID_VNDR, VAR_3));", "VAR_3 += PCI_CAP_LIST_NEXT) {", "uint8_t len = pci_get_byte(VAR_0->config + VAR_3 + PCI_CAP_FLAGS);", "VAR_2 = pci_add_capability2(VAR_0, PCI_CAP_ID_VNDR, VAR_3, len,\n&local_err);", "if (VAR_2 < 0) {", "error_propagate(VAR_1, local_err);", "return VAR_2;", "}", "assigned_dev_setup_cap_read(dev, VAR_3, len);", "assigned_dev_direct_config_write(dev, VAR_3 + 2, len - 2);", "}", "if ((pci_get_word(VAR_0->config + PCI_STATUS) & PCI_STATUS_CAP_LIST) !=\n(assigned_dev_pci_read_byte(VAR_0, PCI_STATUS) &\nPCI_STATUS_CAP_LIST)) {", "dev->emulate_config_read[PCI_STATUS] |= PCI_STATUS_CAP_LIST;", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 21, 23 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49, 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 65, 67, 69 ], [ 71 ], [ 73 ], [ 79, 81 ], [ 83 ], [ 85 ], [ 87 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113, 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 129, 131, 133 ], [ 139, 141 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 165 ], [ 167 ], [ 169 ], [ 173, 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 187 ], [ 191 ], [ 193 ], [ 195 ], [ 203, 205 ], [ 209 ], [ 211 ], [ 213 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 251 ], [ 253 ], [ 255, 257 ], [ 259 ], [ 261 ], [ 263, 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 277 ], [ 279 ], [ 289 ], [ 291 ], [ 293 ], [ 297 ], [ 299, 301 ], [ 303 ], [ 305 ], [ 309, 311 ], [ 313 ], [ 315 ], [ 317 ], [ 319 ], [ 323 ], [ 327 ], [ 329 ], [ 331, 333 ], [ 335, 337 ], [ 339 ], [ 341 ], [ 353 ], [ 355 ], [ 357 ], [ 369 ], [ 371, 373 ], [ 375 ], [ 377 ], [ 379 ], [ 385 ], [ 391 ], [ 393, 395, 397 ], [ 399 ], [ 409 ], [ 411 ], [ 413 ], [ 417 ], [ 421 ], [ 423 ], [ 425 ], [ 431 ], [ 433 ], [ 435 ], [ 443 ], [ 445 ], [ 449 ], [ 451 ], [ 453 ], [ 455 ], [ 461, 463 ], [ 465 ], [ 467 ], [ 469 ], [ 471 ], [ 475 ], [ 481 ], [ 483, 485 ], [ 487 ], [ 495 ], [ 497 ], [ 499 ], [ 501, 503 ], [ 505 ], [ 507 ], [ 511 ], [ 513 ], [ 517, 519 ], [ 521 ], [ 523 ], [ 525 ], [ 527 ], [ 531 ], [ 537 ], [ 539 ], [ 545 ], [ 547 ], [ 549 ], [ 553, 555 ], [ 557 ], [ 559 ], [ 561 ], [ 563 ], [ 567 ], [ 573 ], [ 575 ], [ 583, 585, 587 ], [ 589 ], [ 591 ], [ 595 ], [ 597 ] ]
12,564
int avfilter_graph_send_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, char *res, int res_len, int flags) { int i, r = AVERROR(ENOSYS); if(!graph) return r; if((flags & AVFILTER_CMD_FLAG_ONE) && !(flags & AVFILTER_CMD_FLAG_FAST)) { r=avfilter_graph_send_command(graph, target, cmd, arg, res, res_len, flags | AVFILTER_CMD_FLAG_FAST); if(r != AVERROR(ENOSYS)) return r; } if(res_len && res) res[0]= 0; for (i = 0; i < graph->filter_count; i++) { AVFilterContext *filter = graph->filters[i]; if(!strcmp(target, "all") || !strcmp(target, filter->name) || !strcmp(target, filter->filter->name)){ r = avfilter_process_command(filter, cmd, arg, res, res_len, flags); if(r != AVERROR(ENOSYS)) { if((flags & AVFILTER_CMD_FLAG_ONE) || r<0) return r; } } } return r; }
true
FFmpeg
c0323b9c9bcebe029df0b19a19a6f81deef94b3a
int avfilter_graph_send_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, char *res, int res_len, int flags) { int i, r = AVERROR(ENOSYS); if(!graph) return r; if((flags & AVFILTER_CMD_FLAG_ONE) && !(flags & AVFILTER_CMD_FLAG_FAST)) { r=avfilter_graph_send_command(graph, target, cmd, arg, res, res_len, flags | AVFILTER_CMD_FLAG_FAST); if(r != AVERROR(ENOSYS)) return r; } if(res_len && res) res[0]= 0; for (i = 0; i < graph->filter_count; i++) { AVFilterContext *filter = graph->filters[i]; if(!strcmp(target, "all") || !strcmp(target, filter->name) || !strcmp(target, filter->filter->name)){ r = avfilter_process_command(filter, cmd, arg, res, res_len, flags); if(r != AVERROR(ENOSYS)) { if((flags & AVFILTER_CMD_FLAG_ONE) || r<0) return r; } } } return r; }
{ "code": [ " if(!strcmp(target, \"all\") || !strcmp(target, filter->name) || !strcmp(target, filter->filter->name)){" ], "line_no": [ 37 ] }
int FUNC_0(AVFilterGraph *VAR_0, const char *VAR_1, const char *VAR_2, const char *VAR_3, char *VAR_4, int VAR_5, int VAR_6) { int VAR_7, VAR_8 = AVERROR(ENOSYS); if(!VAR_0) return VAR_8; if((VAR_6 & AVFILTER_CMD_FLAG_ONE) && !(VAR_6 & AVFILTER_CMD_FLAG_FAST)) { VAR_8=FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6 | AVFILTER_CMD_FLAG_FAST); if(VAR_8 != AVERROR(ENOSYS)) return VAR_8; } if(VAR_5 && VAR_4) VAR_4[0]= 0; for (VAR_7 = 0; VAR_7 < VAR_0->filter_count; VAR_7++) { AVFilterContext *filter = VAR_0->filters[VAR_7]; if(!strcmp(VAR_1, "all") || !strcmp(VAR_1, filter->name) || !strcmp(VAR_1, filter->filter->name)){ VAR_8 = avfilter_process_command(filter, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6); if(VAR_8 != AVERROR(ENOSYS)) { if((VAR_6 & AVFILTER_CMD_FLAG_ONE) || VAR_8<0) return VAR_8; } } } return VAR_8; }
[ "int FUNC_0(AVFilterGraph *VAR_0, const char *VAR_1, const char *VAR_2, const char *VAR_3, char *VAR_4, int VAR_5, int VAR_6)\n{", "int VAR_7, VAR_8 = AVERROR(ENOSYS);", "if(!VAR_0)\nreturn VAR_8;", "if((VAR_6 & AVFILTER_CMD_FLAG_ONE) && !(VAR_6 & AVFILTER_CMD_FLAG_FAST)) {", "VAR_8=FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6 | AVFILTER_CMD_FLAG_FAST);", "if(VAR_8 != AVERROR(ENOSYS))\nreturn VAR_8;", "}", "if(VAR_5 && VAR_4)\nVAR_4[0]= 0;", "for (VAR_7 = 0; VAR_7 < VAR_0->filter_count; VAR_7++) {", "AVFilterContext *filter = VAR_0->filters[VAR_7];", "if(!strcmp(VAR_1, \"all\") || !strcmp(VAR_1, filter->name) || !strcmp(VAR_1, filter->filter->name)){", "VAR_8 = avfilter_process_command(filter, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6);", "if(VAR_8 != AVERROR(ENOSYS)) {", "if((VAR_6 & AVFILTER_CMD_FLAG_ONE) || VAR_8<0)\nreturn VAR_8;", "}", "}", "}", "return VAR_8;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9, 11 ], [ 15 ], [ 17 ], [ 19, 21 ], [ 23 ], [ 27, 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43, 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ] ]
12,565
static void dct_unquantize_mpeg2_c(MpegEncContext *s, DCTELEM *block, int n, int qscale) { int i, level, nCoeffs; const UINT16 *quant_matrix; if(s->alternate_scan) nCoeffs= 64; else nCoeffs= s->block_last_index[n]+1; if (s->mb_intra) { if (n < 4) block[0] = block[0] * s->y_dc_scale; else block[0] = block[0] * s->c_dc_scale; quant_matrix = s->intra_matrix; for(i=1;i<nCoeffs;i++) { int j= zigzag_direct[i]; level = block[j]; if (level) { if (level < 0) { level = -level; level = (int)(level * qscale * quant_matrix[j]) >> 3; level = -level; } else { level = (int)(level * qscale * quant_matrix[j]) >> 3; } #ifdef PARANOID if (level < -2048 || level > 2047) fprintf(stderr, "unquant error %d %d\n", i, level); #endif block[j] = level; } } } else { int sum=-1; i = 0; quant_matrix = s->non_intra_matrix; for(;i<nCoeffs;i++) { int j= zigzag_direct[i]; level = block[j]; if (level) { if (level < 0) { level = -level; level = (((level << 1) + 1) * qscale * ((int) (quant_matrix[j]))) >> 4; level = -level; } else { level = (((level << 1) + 1) * qscale * ((int) (quant_matrix[j]))) >> 4; } #ifdef PARANOID if (level < -2048 || level > 2047) fprintf(stderr, "unquant error %d %d\n", i, level); #endif block[j] = level; sum+=level; } } block[63]^=sum&1; } }
true
FFmpeg
d7e9533aa06f4073a27812349b35ba5fede11ca1
static void dct_unquantize_mpeg2_c(MpegEncContext *s, DCTELEM *block, int n, int qscale) { int i, level, nCoeffs; const UINT16 *quant_matrix; if(s->alternate_scan) nCoeffs= 64; else nCoeffs= s->block_last_index[n]+1; if (s->mb_intra) { if (n < 4) block[0] = block[0] * s->y_dc_scale; else block[0] = block[0] * s->c_dc_scale; quant_matrix = s->intra_matrix; for(i=1;i<nCoeffs;i++) { int j= zigzag_direct[i]; level = block[j]; if (level) { if (level < 0) { level = -level; level = (int)(level * qscale * quant_matrix[j]) >> 3; level = -level; } else { level = (int)(level * qscale * quant_matrix[j]) >> 3; } #ifdef PARANOID if (level < -2048 || level > 2047) fprintf(stderr, "unquant error %d %d\n", i, level); #endif block[j] = level; } } } else { int sum=-1; i = 0; quant_matrix = s->non_intra_matrix; for(;i<nCoeffs;i++) { int j= zigzag_direct[i]; level = block[j]; if (level) { if (level < 0) { level = -level; level = (((level << 1) + 1) * qscale * ((int) (quant_matrix[j]))) >> 4; level = -level; } else { level = (((level << 1) + 1) * qscale * ((int) (quant_matrix[j]))) >> 4; } #ifdef PARANOID if (level < -2048 || level > 2047) fprintf(stderr, "unquant error %d %d\n", i, level); #endif block[j] = level; sum+=level; } } block[63]^=sum&1; } }
{ "code": [ " quant_matrix = s->non_intra_matrix;", " quant_matrix = s->non_intra_matrix;", " i = 0;", "#endif", "#endif", "#endif", " } else {", " } else {", "#ifdef PARANOID", "#endif", " quant_matrix = s->non_intra_matrix;", " quant_matrix = s->non_intra_matrix;" ], "line_no": [ 73, 73, 71, 59, 59, 59, 67, 67, 53, 59, 73, 73 ] }
static void FUNC_0(MpegEncContext *VAR_0, DCTELEM *VAR_1, int VAR_2, int VAR_3) { int VAR_4, VAR_5, VAR_6; const UINT16 *VAR_7; if(VAR_0->alternate_scan) VAR_6= 64; else VAR_6= VAR_0->block_last_index[VAR_2]+1; if (VAR_0->mb_intra) { if (VAR_2 < 4) VAR_1[0] = VAR_1[0] * VAR_0->y_dc_scale; else VAR_1[0] = VAR_1[0] * VAR_0->c_dc_scale; VAR_7 = VAR_0->intra_matrix; for(VAR_4=1;VAR_4<VAR_6;VAR_4++) { int VAR_10= zigzag_direct[VAR_4]; VAR_5 = VAR_1[VAR_10]; if (VAR_5) { if (VAR_5 < 0) { VAR_5 = -VAR_5; VAR_5 = (int)(VAR_5 * VAR_3 * VAR_7[VAR_10]) >> 3; VAR_5 = -VAR_5; } else { VAR_5 = (int)(VAR_5 * VAR_3 * VAR_7[VAR_10]) >> 3; } #ifdef PARANOID if (VAR_5 < -2048 || VAR_5 > 2047) fprintf(stderr, "unquant error %d %d\VAR_2", VAR_4, VAR_5); #endif VAR_1[VAR_10] = VAR_5; } } } else { int VAR_9=-1; VAR_4 = 0; VAR_7 = VAR_0->non_intra_matrix; for(;VAR_4<VAR_6;VAR_4++) { int VAR_10= zigzag_direct[VAR_4]; VAR_5 = VAR_1[VAR_10]; if (VAR_5) { if (VAR_5 < 0) { VAR_5 = -VAR_5; VAR_5 = (((VAR_5 << 1) + 1) * VAR_3 * ((int) (VAR_7[VAR_10]))) >> 4; VAR_5 = -VAR_5; } else { VAR_5 = (((VAR_5 << 1) + 1) * VAR_3 * ((int) (VAR_7[VAR_10]))) >> 4; } #ifdef PARANOID if (VAR_5 < -2048 || VAR_5 > 2047) fprintf(stderr, "unquant error %d %d\VAR_2", VAR_4, VAR_5); #endif VAR_1[VAR_10] = VAR_5; VAR_9+=VAR_5; } } VAR_1[63]^=VAR_9&1; } }
[ "static void FUNC_0(MpegEncContext *VAR_0,\nDCTELEM *VAR_1, int VAR_2, int VAR_3)\n{", "int VAR_4, VAR_5, VAR_6;", "const UINT16 *VAR_7;", "if(VAR_0->alternate_scan) VAR_6= 64;", "else VAR_6= VAR_0->block_last_index[VAR_2]+1;", "if (VAR_0->mb_intra) {", "if (VAR_2 < 4)\nVAR_1[0] = VAR_1[0] * VAR_0->y_dc_scale;", "else\nVAR_1[0] = VAR_1[0] * VAR_0->c_dc_scale;", "VAR_7 = VAR_0->intra_matrix;", "for(VAR_4=1;VAR_4<VAR_6;VAR_4++) {", "int VAR_10= zigzag_direct[VAR_4];", "VAR_5 = VAR_1[VAR_10];", "if (VAR_5) {", "if (VAR_5 < 0) {", "VAR_5 = -VAR_5;", "VAR_5 = (int)(VAR_5 * VAR_3 * VAR_7[VAR_10]) >> 3;", "VAR_5 = -VAR_5;", "} else {", "VAR_5 = (int)(VAR_5 * VAR_3 * VAR_7[VAR_10]) >> 3;", "}", "#ifdef PARANOID\nif (VAR_5 < -2048 || VAR_5 > 2047)\nfprintf(stderr, \"unquant error %d %d\\VAR_2\", VAR_4, VAR_5);", "#endif\nVAR_1[VAR_10] = VAR_5;", "}", "}", "} else {", "int VAR_9=-1;", "VAR_4 = 0;", "VAR_7 = VAR_0->non_intra_matrix;", "for(;VAR_4<VAR_6;VAR_4++) {", "int VAR_10= zigzag_direct[VAR_4];", "VAR_5 = VAR_1[VAR_10];", "if (VAR_5) {", "if (VAR_5 < 0) {", "VAR_5 = -VAR_5;", "VAR_5 = (((VAR_5 << 1) + 1) * VAR_3 *\n((int) (VAR_7[VAR_10]))) >> 4;", "VAR_5 = -VAR_5;", "} else {", "VAR_5 = (((VAR_5 << 1) + 1) * VAR_3 *\n((int) (VAR_7[VAR_10]))) >> 4;", "}", "#ifdef PARANOID\nif (VAR_5 < -2048 || VAR_5 > 2047)\nfprintf(stderr, \"unquant error %d %d\\VAR_2\", VAR_4, VAR_5);", "#endif\nVAR_1[VAR_10] = VAR_5;", "VAR_9+=VAR_5;", "}", "}", "VAR_1[63]^=VAR_9&1;", "}", "}" ]
[ 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, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 19 ], [ 21, 23 ], [ 25, 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53, 55, 57 ], [ 59, 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87, 89 ], [ 91 ], [ 93 ], [ 95, 97 ], [ 99 ], [ 101, 103, 105 ], [ 107, 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ] ]
12,566
static void destroy_l2_mapping(PhysPageEntry *lp, unsigned level) { unsigned i; PhysPageEntry *p; if (lp->ptr == PHYS_MAP_NODE_NIL) { return; } p = phys_map_nodes[lp->ptr]; for (i = 0; i < L2_SIZE; ++i) { if (!p[i].is_leaf) { destroy_l2_mapping(&p[i], level - 1); } else { destroy_page_desc(p[i].ptr); } } lp->is_leaf = 0; lp->ptr = PHYS_MAP_NODE_NIL; }
true
qemu
058bc4b57f9d6b39d9a6748b4049e1be3fde3dac
static void destroy_l2_mapping(PhysPageEntry *lp, unsigned level) { unsigned i; PhysPageEntry *p; if (lp->ptr == PHYS_MAP_NODE_NIL) { return; } p = phys_map_nodes[lp->ptr]; for (i = 0; i < L2_SIZE; ++i) { if (!p[i].is_leaf) { destroy_l2_mapping(&p[i], level - 1); } else { destroy_page_desc(p[i].ptr); } } lp->is_leaf = 0; lp->ptr = PHYS_MAP_NODE_NIL; }
{ "code": [ " } else {", " destroy_page_desc(p[i].ptr);" ], "line_no": [ 27, 29 ] }
static void FUNC_0(PhysPageEntry *VAR_0, unsigned VAR_1) { unsigned VAR_2; PhysPageEntry *p; if (VAR_0->ptr == PHYS_MAP_NODE_NIL) { return; } p = phys_map_nodes[VAR_0->ptr]; for (VAR_2 = 0; VAR_2 < L2_SIZE; ++VAR_2) { if (!p[VAR_2].is_leaf) { FUNC_0(&p[VAR_2], VAR_1 - 1); } else { destroy_page_desc(p[VAR_2].ptr); } } VAR_0->is_leaf = 0; VAR_0->ptr = PHYS_MAP_NODE_NIL; }
[ "static void FUNC_0(PhysPageEntry *VAR_0, unsigned VAR_1)\n{", "unsigned VAR_2;", "PhysPageEntry *p;", "if (VAR_0->ptr == PHYS_MAP_NODE_NIL) {", "return;", "}", "p = phys_map_nodes[VAR_0->ptr];", "for (VAR_2 = 0; VAR_2 < L2_SIZE; ++VAR_2) {", "if (!p[VAR_2].is_leaf) {", "FUNC_0(&p[VAR_2], VAR_1 - 1);", "} else {", "destroy_page_desc(p[VAR_2].ptr);", "}", "}", "VAR_0->is_leaf = 0;", "VAR_0->ptr = PHYS_MAP_NODE_NIL;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ] ]
12,568
static int apply_window_and_mdct(vorbis_enc_context *venc, float **audio, int samples) { int channel; const float * win = venc->win[0]; int window_len = 1 << (venc->log2_blocksize[0] - 1); float n = (float)(1 << venc->log2_blocksize[0]) / 4.0; AVFloatDSPContext *fdsp = venc->fdsp; if (!venc->have_saved && !samples) return 0; if (venc->have_saved) { for (channel = 0; channel < venc->channels; channel++) memcpy(venc->samples + channel * window_len * 2, venc->saved + channel * window_len, sizeof(float) * window_len); } else { for (channel = 0; channel < venc->channels; channel++) memset(venc->samples + channel * window_len * 2, 0, sizeof(float) * window_len); } if (samples) { for (channel = 0; channel < venc->channels; channel++) { float *offset = venc->samples + channel * window_len * 2 + window_len; fdsp->vector_fmul_reverse(offset, audio[channel], win, samples); fdsp->vector_fmul_scalar(offset, offset, 1/n, samples); } } else { for (channel = 0; channel < venc->channels; channel++) memset(venc->samples + channel * window_len * 2 + window_len, 0, sizeof(float) * window_len); } for (channel = 0; channel < venc->channels; channel++) venc->mdct[0].mdct_calc(&venc->mdct[0], venc->coeffs + channel * window_len, venc->samples + channel * window_len * 2); if (samples) { for (channel = 0; channel < venc->channels; channel++) { float *offset = venc->saved + channel * window_len; fdsp->vector_fmul(offset, audio[channel], win, samples); fdsp->vector_fmul_scalar(offset, offset, 1/n, samples); } venc->have_saved = 1; } else { venc->have_saved = 0; } return 1; }
true
FFmpeg
34c52005605d68f7cd1957b169b6732c7d2447d9
static int apply_window_and_mdct(vorbis_enc_context *venc, float **audio, int samples) { int channel; const float * win = venc->win[0]; int window_len = 1 << (venc->log2_blocksize[0] - 1); float n = (float)(1 << venc->log2_blocksize[0]) / 4.0; AVFloatDSPContext *fdsp = venc->fdsp; if (!venc->have_saved && !samples) return 0; if (venc->have_saved) { for (channel = 0; channel < venc->channels; channel++) memcpy(venc->samples + channel * window_len * 2, venc->saved + channel * window_len, sizeof(float) * window_len); } else { for (channel = 0; channel < venc->channels; channel++) memset(venc->samples + channel * window_len * 2, 0, sizeof(float) * window_len); } if (samples) { for (channel = 0; channel < venc->channels; channel++) { float *offset = venc->samples + channel * window_len * 2 + window_len; fdsp->vector_fmul_reverse(offset, audio[channel], win, samples); fdsp->vector_fmul_scalar(offset, offset, 1/n, samples); } } else { for (channel = 0; channel < venc->channels; channel++) memset(venc->samples + channel * window_len * 2 + window_len, 0, sizeof(float) * window_len); } for (channel = 0; channel < venc->channels; channel++) venc->mdct[0].mdct_calc(&venc->mdct[0], venc->coeffs + channel * window_len, venc->samples + channel * window_len * 2); if (samples) { for (channel = 0; channel < venc->channels; channel++) { float *offset = venc->saved + channel * window_len; fdsp->vector_fmul(offset, audio[channel], win, samples); fdsp->vector_fmul_scalar(offset, offset, 1/n, samples); } venc->have_saved = 1; } else { venc->have_saved = 0; } return 1; }
{ "code": [ " float **audio, int samples)", " fdsp->vector_fmul_reverse(offset, audio[channel], win, samples);", " fdsp->vector_fmul(offset, audio[channel], win, samples);" ], "line_no": [ 3, 53, 87 ] }
static int FUNC_0(vorbis_enc_context *VAR_0, float **VAR_1, int VAR_2) { int VAR_3; const float * VAR_4 = VAR_0->VAR_4[0]; int VAR_5 = 1 << (VAR_0->log2_blocksize[0] - 1); float VAR_6 = (float)(1 << VAR_0->log2_blocksize[0]) / 4.0; AVFloatDSPContext *fdsp = VAR_0->fdsp; if (!VAR_0->have_saved && !VAR_2) return 0; if (VAR_0->have_saved) { for (VAR_3 = 0; VAR_3 < VAR_0->channels; VAR_3++) memcpy(VAR_0->VAR_2 + VAR_3 * VAR_5 * 2, VAR_0->saved + VAR_3 * VAR_5, sizeof(float) * VAR_5); } else { for (VAR_3 = 0; VAR_3 < VAR_0->channels; VAR_3++) memset(VAR_0->VAR_2 + VAR_3 * VAR_5 * 2, 0, sizeof(float) * VAR_5); } if (VAR_2) { for (VAR_3 = 0; VAR_3 < VAR_0->channels; VAR_3++) { float *offset = VAR_0->VAR_2 + VAR_3 * VAR_5 * 2 + VAR_5; fdsp->vector_fmul_reverse(offset, VAR_1[VAR_3], VAR_4, VAR_2); fdsp->vector_fmul_scalar(offset, offset, 1/VAR_6, VAR_2); } } else { for (VAR_3 = 0; VAR_3 < VAR_0->channels; VAR_3++) memset(VAR_0->VAR_2 + VAR_3 * VAR_5 * 2 + VAR_5, 0, sizeof(float) * VAR_5); } for (VAR_3 = 0; VAR_3 < VAR_0->channels; VAR_3++) VAR_0->mdct[0].mdct_calc(&VAR_0->mdct[0], VAR_0->coeffs + VAR_3 * VAR_5, VAR_0->VAR_2 + VAR_3 * VAR_5 * 2); if (VAR_2) { for (VAR_3 = 0; VAR_3 < VAR_0->channels; VAR_3++) { float *offset = VAR_0->saved + VAR_3 * VAR_5; fdsp->vector_fmul(offset, VAR_1[VAR_3], VAR_4, VAR_2); fdsp->vector_fmul_scalar(offset, offset, 1/VAR_6, VAR_2); } VAR_0->have_saved = 1; } else { VAR_0->have_saved = 0; } return 1; }
[ "static int FUNC_0(vorbis_enc_context *VAR_0,\nfloat **VAR_1, int VAR_2)\n{", "int VAR_3;", "const float * VAR_4 = VAR_0->VAR_4[0];", "int VAR_5 = 1 << (VAR_0->log2_blocksize[0] - 1);", "float VAR_6 = (float)(1 << VAR_0->log2_blocksize[0]) / 4.0;", "AVFloatDSPContext *fdsp = VAR_0->fdsp;", "if (!VAR_0->have_saved && !VAR_2)\nreturn 0;", "if (VAR_0->have_saved) {", "for (VAR_3 = 0; VAR_3 < VAR_0->channels; VAR_3++)", "memcpy(VAR_0->VAR_2 + VAR_3 * VAR_5 * 2,\nVAR_0->saved + VAR_3 * VAR_5, sizeof(float) * VAR_5);", "} else {", "for (VAR_3 = 0; VAR_3 < VAR_0->channels; VAR_3++)", "memset(VAR_0->VAR_2 + VAR_3 * VAR_5 * 2, 0,\nsizeof(float) * VAR_5);", "}", "if (VAR_2) {", "for (VAR_3 = 0; VAR_3 < VAR_0->channels; VAR_3++) {", "float *offset = VAR_0->VAR_2 + VAR_3 * VAR_5 * 2 + VAR_5;", "fdsp->vector_fmul_reverse(offset, VAR_1[VAR_3], VAR_4, VAR_2);", "fdsp->vector_fmul_scalar(offset, offset, 1/VAR_6, VAR_2);", "}", "} else {", "for (VAR_3 = 0; VAR_3 < VAR_0->channels; VAR_3++)", "memset(VAR_0->VAR_2 + VAR_3 * VAR_5 * 2 + VAR_5,\n0, sizeof(float) * VAR_5);", "}", "for (VAR_3 = 0; VAR_3 < VAR_0->channels; VAR_3++)", "VAR_0->mdct[0].mdct_calc(&VAR_0->mdct[0], VAR_0->coeffs + VAR_3 * VAR_5,\nVAR_0->VAR_2 + VAR_3 * VAR_5 * 2);", "if (VAR_2) {", "for (VAR_3 = 0; VAR_3 < VAR_0->channels; VAR_3++) {", "float *offset = VAR_0->saved + VAR_3 * VAR_5;", "fdsp->vector_fmul(offset, VAR_1[VAR_3], VAR_4, VAR_2);", "fdsp->vector_fmul_scalar(offset, offset, 1/VAR_6, VAR_2);", "}", "VAR_0->have_saved = 1;", "} else {", "VAR_0->have_saved = 0;", "}", "return 1;", "}" ]
[ 1, 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, 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19, 21 ], [ 25 ], [ 27 ], [ 29, 31 ], [ 33 ], [ 35 ], [ 37, 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63, 65 ], [ 67 ], [ 71 ], [ 73, 75 ], [ 79 ], [ 81 ], [ 83 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ] ]
12,569
static int transcode(void) { int ret, i; AVFormatContext *is, *os; OutputStream *ost; InputStream *ist; uint8_t *no_packet; int no_packet_count = 0; int64_t timer_start; int key; if (!(no_packet = av_mallocz(nb_input_files))) exit_program(1); ret = transcode_init(); if (ret < 0) goto fail; if (!using_stdin) { av_log(NULL, AV_LOG_INFO, "Press [q] to stop, [?] for help\n"); } timer_start = av_gettime(); for (; received_sigterm == 0;) { int file_index, ist_index; AVPacket pkt; int64_t cur_time= av_gettime(); /* if 'q' pressed, exits */ if (!using_stdin) { static int64_t last_time; if (received_nb_signals) break; /* read_key() returns 0 on EOF */ if(cur_time - last_time >= 100000 && !run_as_daemon){ key = read_key(); last_time = cur_time; }else key = -1; if (key == 'q') break; if (key == '+') av_log_set_level(av_log_get_level()+10); if (key == '-') av_log_set_level(av_log_get_level()-10); if (key == 's') qp_hist ^= 1; if (key == 'h'){ if (do_hex_dump){ do_hex_dump = do_pkt_dump = 0; } else if(do_pkt_dump){ do_hex_dump = 1; } else do_pkt_dump = 1; av_log_set_level(AV_LOG_DEBUG); } if (key == 'c' || key == 'C'){ char buf[4096], target[64], command[256], arg[256] = {0}; double time; int k, n = 0; fprintf(stderr, "\nEnter command: <target> <time> <command>[ <argument>]\n"); i = 0; while ((k = read_key()) != '\n' && k != '\r' && i < sizeof(buf)-1) if (k > 0) buf[i++] = k; buf[i] = 0; if (k > 0 && (n = sscanf(buf, "%63[^ ] %lf %255[^ ] %255[^\n]", target, &time, command, arg)) >= 3) { av_log(NULL, AV_LOG_DEBUG, "Processing command target:%s time:%f command:%s arg:%s", target, time, command, arg); for (i = 0; i < nb_filtergraphs; i++) { FilterGraph *fg = filtergraphs[i]; if (fg->graph) { if (time < 0) { ret = avfilter_graph_send_command(fg->graph, target, command, arg, buf, sizeof(buf), key == 'c' ? AVFILTER_CMD_FLAG_ONE : 0); fprintf(stderr, "Command reply for stream %d: ret:%d res:%s\n", i, ret, buf); } else { ret = avfilter_graph_queue_command(fg->graph, target, command, arg, 0, time); } } } } else { av_log(NULL, AV_LOG_ERROR, "Parse error, at least 3 arguments were expected, " "only %d given in string '%s'\n", n, buf); } } if (key == 'd' || key == 'D'){ int debug=0; if(key == 'D') { debug = input_streams[0]->st->codec->debug<<1; if(!debug) debug = 1; while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) //unsupported, would just crash debug += debug; }else if(scanf("%d", &debug)!=1) fprintf(stderr,"error parsing debug value\n"); for(i=0;i<nb_input_streams;i++) { input_streams[i]->st->codec->debug = debug; } for(i=0;i<nb_output_streams;i++) { ost = output_streams[i]; ost->st->codec->debug = debug; } if(debug) av_log_set_level(AV_LOG_DEBUG); fprintf(stderr,"debug=%d\n", debug); } if (key == '?'){ fprintf(stderr, "key function\n" "? show this help\n" "+ increase verbosity\n" "- decrease verbosity\n" "c Send command to filtergraph\n" "D cycle through available debug modes\n" "h dump packets/hex press to cycle through the 3 states\n" "q quit\n" "s Show QP histogram\n" ); } } /* check if there's any stream where output is still needed */ if (!need_output()) { av_log(NULL, AV_LOG_VERBOSE, "No more output streams to write to, finishing.\n"); break; } /* select the stream that we must read now */ file_index = select_input_file(no_packet); /* if none, if is finished */ if (file_index < 0) { if (no_packet_count) { no_packet_count = 0; memset(no_packet, 0, nb_input_files); usleep(10000); continue; } break; } /* read a frame from it and output it in the fifo */ is = input_files[file_index]->ctx; ret = av_read_frame(is, &pkt); if (ret == AVERROR(EAGAIN)) { no_packet[file_index] = 1; no_packet_count++; continue; } if (ret < 0) { input_files[file_index]->eof_reached = 1; for (i = 0; i < input_files[file_index]->nb_streams; i++) { ist = input_streams[input_files[file_index]->ist_index + i]; if (ist->decoding_needed) output_packet(ist, NULL); } if (opt_shortest) break; else continue; } no_packet_count = 0; memset(no_packet, 0, nb_input_files); if (do_pkt_dump) { av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump, is->streams[pkt.stream_index]); } /* the following test is needed in case new streams appear dynamically in stream : we ignore them */ if (pkt.stream_index >= input_files[file_index]->nb_streams) goto discard_packet; ist_index = input_files[file_index]->ist_index + pkt.stream_index; ist = input_streams[ist_index]; if (ist->discard) goto discard_packet; if (pkt.dts != AV_NOPTS_VALUE) pkt.dts += av_rescale_q(input_files[ist->file_index]->ts_offset, AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) pkt.pts += av_rescale_q(input_files[ist->file_index]->ts_offset, AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) pkt.pts *= ist->ts_scale; if (pkt.dts != AV_NOPTS_VALUE) pkt.dts *= ist->ts_scale; if (debug_ts) { av_log(NULL, AV_LOG_INFO, "demuxer -> ist_index:%d type:%s " "next_dts:%s next_dts_time:%s next_pts:%s next_pts_time:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s off:%"PRId64"\n", ist_index, av_get_media_type_string(ist->st->codec->codec_type), av_ts2str(ist->next_dts), av_ts2timestr(ist->next_dts, &ist->st->time_base), av_ts2str(ist->next_pts), av_ts2timestr(ist->next_pts, &ist->st->time_base), av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ist->st->time_base), av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ist->st->time_base), input_files[ist->file_index]->ts_offset); } if (pkt.dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE && !copy_ts) { int64_t pkt_dts = av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q); int64_t delta = pkt_dts - ist->next_dts; if (is->iformat->flags & AVFMT_TS_DISCONT) { if(delta < -1LL*dts_delta_threshold*AV_TIME_BASE || (delta > 1LL*dts_delta_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) || pkt_dts+1<ist->pts){ input_files[ist->file_index]->ts_offset -= delta; av_log(NULL, AV_LOG_DEBUG, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", delta, input_files[ist->file_index]->ts_offset); pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) pkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); } } else { if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE || (delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) || pkt_dts+1<ist->pts){ av_log(NULL, AV_LOG_WARNING, "DTS %"PRId64", next:%"PRId64" st:%d invalid dropping\n", pkt.dts, ist->next_dts, pkt.stream_index); pkt.dts = AV_NOPTS_VALUE; } if (pkt.pts != AV_NOPTS_VALUE){ int64_t pkt_pts = av_rescale_q(pkt.pts, ist->st->time_base, AV_TIME_BASE_Q); delta = pkt_pts - ist->next_dts; if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE || (delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) || pkt_pts+1<ist->pts) { av_log(NULL, AV_LOG_WARNING, "PTS %"PRId64", next:%"PRId64" invalid dropping st:%d\n", pkt.pts, ist->next_dts, pkt.stream_index); pkt.pts = AV_NOPTS_VALUE; } } } } // fprintf(stderr,"read #%d.%d size=%d\n", ist->file_index, ist->st->index, pkt.size); if ((ret = output_packet(ist, &pkt)) < 0 || ((ret = poll_filters()) < 0 && ret != AVERROR_EOF)) { char buf[128]; av_strerror(ret, buf, sizeof(buf)); av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d: %s\n", ist->file_index, ist->st->index, buf); if (exit_on_error) exit_program(1); av_free_packet(&pkt); continue; } discard_packet: av_free_packet(&pkt); /* dump report by using the output first video and audio streams */ print_report(0, timer_start, cur_time); } /* at the end of stream, we must flush the decoder buffers */ for (i = 0; i < nb_input_streams; i++) { ist = input_streams[i]; if (!input_files[ist->file_index]->eof_reached && ist->decoding_needed) { output_packet(ist, NULL); } } poll_filters(); flush_encoders(); term_exit(); /* write the trailer if needed and close file */ for (i = 0; i < nb_output_files; i++) { os = output_files[i]->ctx; av_write_trailer(os); } /* dump report by using the first video and audio streams */ print_report(1, timer_start, av_gettime()); /* close each encoder */ for (i = 0; i < nb_output_streams; i++) { ost = output_streams[i]; if (ost->encoding_needed) { av_freep(&ost->st->codec->stats_in); avcodec_close(ost->st->codec); } } /* close each decoder */ for (i = 0; i < nb_input_streams; i++) { ist = input_streams[i]; if (ist->decoding_needed) { avcodec_close(ist->st->codec); } } /* finished ! */ ret = 0; fail: av_freep(&no_packet); if (output_streams) { for (i = 0; i < nb_output_streams; i++) { ost = output_streams[i]; if (ost) { if (ost->stream_copy) av_freep(&ost->st->codec->extradata); if (ost->logfile) { fclose(ost->logfile); ost->logfile = NULL; } av_freep(&ost->st->codec->subtitle_header); av_free(ost->forced_kf_pts); av_dict_free(&ost->opts); } } } return ret; }
false
FFmpeg
25e87fc5f61bd9b85ecf52c6082a18d7e7c8506b
static int transcode(void) { int ret, i; AVFormatContext *is, *os; OutputStream *ost; InputStream *ist; uint8_t *no_packet; int no_packet_count = 0; int64_t timer_start; int key; if (!(no_packet = av_mallocz(nb_input_files))) exit_program(1); ret = transcode_init(); if (ret < 0) goto fail; if (!using_stdin) { av_log(NULL, AV_LOG_INFO, "Press [q] to stop, [?] for help\n"); } timer_start = av_gettime(); for (; received_sigterm == 0;) { int file_index, ist_index; AVPacket pkt; int64_t cur_time= av_gettime(); if (!using_stdin) { static int64_t last_time; if (received_nb_signals) break; if(cur_time - last_time >= 100000 && !run_as_daemon){ key = read_key(); last_time = cur_time; }else key = -1; if (key == 'q') break; if (key == '+') av_log_set_level(av_log_get_level()+10); if (key == '-') av_log_set_level(av_log_get_level()-10); if (key == 's') qp_hist ^= 1; if (key == 'h'){ if (do_hex_dump){ do_hex_dump = do_pkt_dump = 0; } else if(do_pkt_dump){ do_hex_dump = 1; } else do_pkt_dump = 1; av_log_set_level(AV_LOG_DEBUG); } if (key == 'c' || key == 'C'){ char buf[4096], target[64], command[256], arg[256] = {0}; double time; int k, n = 0; fprintf(stderr, "\nEnter command: <target> <time> <command>[ <argument>]\n"); i = 0; while ((k = read_key()) != '\n' && k != '\r' && i < sizeof(buf)-1) if (k > 0) buf[i++] = k; buf[i] = 0; if (k > 0 && (n = sscanf(buf, "%63[^ ] %lf %255[^ ] %255[^\n]", target, &time, command, arg)) >= 3) { av_log(NULL, AV_LOG_DEBUG, "Processing command target:%s time:%f command:%s arg:%s", target, time, command, arg); for (i = 0; i < nb_filtergraphs; i++) { FilterGraph *fg = filtergraphs[i]; if (fg->graph) { if (time < 0) { ret = avfilter_graph_send_command(fg->graph, target, command, arg, buf, sizeof(buf), key == 'c' ? AVFILTER_CMD_FLAG_ONE : 0); fprintf(stderr, "Command reply for stream %d: ret:%d res:%s\n", i, ret, buf); } else { ret = avfilter_graph_queue_command(fg->graph, target, command, arg, 0, time); } } } } else { av_log(NULL, AV_LOG_ERROR, "Parse error, at least 3 arguments were expected, " "only %d given in string '%s'\n", n, buf); } } if (key == 'd' || key == 'D'){ int debug=0; if(key == 'D') { debug = input_streams[0]->st->codec->debug<<1; if(!debug) debug = 1; while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) debug += debug; }else if(scanf("%d", &debug)!=1) fprintf(stderr,"error parsing debug value\n"); for(i=0;i<nb_input_streams;i++) { input_streams[i]->st->codec->debug = debug; } for(i=0;i<nb_output_streams;i++) { ost = output_streams[i]; ost->st->codec->debug = debug; } if(debug) av_log_set_level(AV_LOG_DEBUG); fprintf(stderr,"debug=%d\n", debug); } if (key == '?'){ fprintf(stderr, "key function\n" "? show this help\n" "+ increase verbosity\n" "- decrease verbosity\n" "c Send command to filtergraph\n" "D cycle through available debug modes\n" "h dump packets/hex press to cycle through the 3 states\n" "q quit\n" "s Show QP histogram\n" ); } } if (!need_output()) { av_log(NULL, AV_LOG_VERBOSE, "No more output streams to write to, finishing.\n"); break; } file_index = select_input_file(no_packet); if (file_index < 0) { if (no_packet_count) { no_packet_count = 0; memset(no_packet, 0, nb_input_files); usleep(10000); continue; } break; } is = input_files[file_index]->ctx; ret = av_read_frame(is, &pkt); if (ret == AVERROR(EAGAIN)) { no_packet[file_index] = 1; no_packet_count++; continue; } if (ret < 0) { input_files[file_index]->eof_reached = 1; for (i = 0; i < input_files[file_index]->nb_streams; i++) { ist = input_streams[input_files[file_index]->ist_index + i]; if (ist->decoding_needed) output_packet(ist, NULL); } if (opt_shortest) break; else continue; } no_packet_count = 0; memset(no_packet, 0, nb_input_files); if (do_pkt_dump) { av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump, is->streams[pkt.stream_index]); } if (pkt.stream_index >= input_files[file_index]->nb_streams) goto discard_packet; ist_index = input_files[file_index]->ist_index + pkt.stream_index; ist = input_streams[ist_index]; if (ist->discard) goto discard_packet; if (pkt.dts != AV_NOPTS_VALUE) pkt.dts += av_rescale_q(input_files[ist->file_index]->ts_offset, AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) pkt.pts += av_rescale_q(input_files[ist->file_index]->ts_offset, AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) pkt.pts *= ist->ts_scale; if (pkt.dts != AV_NOPTS_VALUE) pkt.dts *= ist->ts_scale; if (debug_ts) { av_log(NULL, AV_LOG_INFO, "demuxer -> ist_index:%d type:%s " "next_dts:%s next_dts_time:%s next_pts:%s next_pts_time:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s off:%"PRId64"\n", ist_index, av_get_media_type_string(ist->st->codec->codec_type), av_ts2str(ist->next_dts), av_ts2timestr(ist->next_dts, &ist->st->time_base), av_ts2str(ist->next_pts), av_ts2timestr(ist->next_pts, &ist->st->time_base), av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ist->st->time_base), av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ist->st->time_base), input_files[ist->file_index]->ts_offset); } if (pkt.dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE && !copy_ts) { int64_t pkt_dts = av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q); int64_t delta = pkt_dts - ist->next_dts; if (is->iformat->flags & AVFMT_TS_DISCONT) { if(delta < -1LL*dts_delta_threshold*AV_TIME_BASE || (delta > 1LL*dts_delta_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) || pkt_dts+1<ist->pts){ input_files[ist->file_index]->ts_offset -= delta; av_log(NULL, AV_LOG_DEBUG, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", delta, input_files[ist->file_index]->ts_offset); pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) pkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); } } else { if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE || (delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) || pkt_dts+1<ist->pts){ av_log(NULL, AV_LOG_WARNING, "DTS %"PRId64", next:%"PRId64" st:%d invalid dropping\n", pkt.dts, ist->next_dts, pkt.stream_index); pkt.dts = AV_NOPTS_VALUE; } if (pkt.pts != AV_NOPTS_VALUE){ int64_t pkt_pts = av_rescale_q(pkt.pts, ist->st->time_base, AV_TIME_BASE_Q); delta = pkt_pts - ist->next_dts; if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE || (delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) || pkt_pts+1<ist->pts) { av_log(NULL, AV_LOG_WARNING, "PTS %"PRId64", next:%"PRId64" invalid dropping st:%d\n", pkt.pts, ist->next_dts, pkt.stream_index); pkt.pts = AV_NOPTS_VALUE; } } } } if ((ret = output_packet(ist, &pkt)) < 0 || ((ret = poll_filters()) < 0 && ret != AVERROR_EOF)) { char buf[128]; av_strerror(ret, buf, sizeof(buf)); av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d: %s\n", ist->file_index, ist->st->index, buf); if (exit_on_error) exit_program(1); av_free_packet(&pkt); continue; } discard_packet: av_free_packet(&pkt); print_report(0, timer_start, cur_time); } for (i = 0; i < nb_input_streams; i++) { ist = input_streams[i]; if (!input_files[ist->file_index]->eof_reached && ist->decoding_needed) { output_packet(ist, NULL); } } poll_filters(); flush_encoders(); term_exit(); for (i = 0; i < nb_output_files; i++) { os = output_files[i]->ctx; av_write_trailer(os); } print_report(1, timer_start, av_gettime()); for (i = 0; i < nb_output_streams; i++) { ost = output_streams[i]; if (ost->encoding_needed) { av_freep(&ost->st->codec->stats_in); avcodec_close(ost->st->codec); } } for (i = 0; i < nb_input_streams; i++) { ist = input_streams[i]; if (ist->decoding_needed) { avcodec_close(ist->st->codec); } } ret = 0; fail: av_freep(&no_packet); if (output_streams) { for (i = 0; i < nb_output_streams; i++) { ost = output_streams[i]; if (ost) { if (ost->stream_copy) av_freep(&ost->st->codec->extradata); if (ost->logfile) { fclose(ost->logfile); ost->logfile = NULL; } av_freep(&ost->st->codec->subtitle_header); av_free(ost->forced_kf_pts); av_dict_free(&ost->opts); } } } return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(void) { int VAR_0, VAR_1; AVFormatContext *is, *os; OutputStream *ost; InputStream *ist; uint8_t *no_packet; int VAR_2 = 0; int64_t timer_start; int VAR_3; if (!(no_packet = av_mallocz(nb_input_files))) exit_program(1); VAR_0 = transcode_init(); if (VAR_0 < 0) goto fail; if (!using_stdin) { av_log(NULL, AV_LOG_INFO, "Press [q] to stop, [?] for help\n"); } timer_start = av_gettime(); for (; received_sigterm == 0;) { int file_index, ist_index; AVPacket pkt; int64_t cur_time= av_gettime(); if (!using_stdin) { static int64_t last_time; if (received_nb_signals) break; if(cur_time - last_time >= 100000 && !run_as_daemon){ VAR_3 = read_key(); last_time = cur_time; }else VAR_3 = -1; if (VAR_3 == 'q') break; if (VAR_3 == '+') av_log_set_level(av_log_get_level()+10); if (VAR_3 == '-') av_log_set_level(av_log_get_level()-10); if (VAR_3 == 's') qp_hist ^= 1; if (VAR_3 == 'h'){ if (do_hex_dump){ do_hex_dump = do_pkt_dump = 0; } else if(do_pkt_dump){ do_hex_dump = 1; } else do_pkt_dump = 1; av_log_set_level(AV_LOG_DEBUG); } if (VAR_3 == 'c' || VAR_3 == 'C'){ char buf[4096], target[64], command[256], arg[256] = {0}; double time; int k, n = 0; fprintf(stderr, "\nEnter command: <target> <time> <command>[ <argument>]\n"); VAR_1 = 0; while ((k = read_key()) != '\n' && k != '\r' && VAR_1 < sizeof(buf)-1) if (k > 0) buf[VAR_1++] = k; buf[VAR_1] = 0; if (k > 0 && (n = sscanf(buf, "%63[^ ] %lf %255[^ ] %255[^\n]", target, &time, command, arg)) >= 3) { av_log(NULL, AV_LOG_DEBUG, "Processing command target:%s time:%f command:%s arg:%s", target, time, command, arg); for (VAR_1 = 0; VAR_1 < nb_filtergraphs; VAR_1++) { FilterGraph *fg = filtergraphs[VAR_1]; if (fg->graph) { if (time < 0) { VAR_0 = avfilter_graph_send_command(fg->graph, target, command, arg, buf, sizeof(buf), VAR_3 == 'c' ? AVFILTER_CMD_FLAG_ONE : 0); fprintf(stderr, "Command reply for stream %d: VAR_0:%d res:%s\n", VAR_1, VAR_0, buf); } else { VAR_0 = avfilter_graph_queue_command(fg->graph, target, command, arg, 0, time); } } } } else { av_log(NULL, AV_LOG_ERROR, "Parse error, at least 3 arguments were expected, " "only %d given in string '%s'\n", n, buf); } } if (VAR_3 == 'd' || VAR_3 == 'D'){ int debug=0; if(VAR_3 == 'D') { debug = input_streams[0]->st->codec->debug<<1; if(!debug) debug = 1; while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) debug += debug; }else if(scanf("%d", &debug)!=1) fprintf(stderr,"error parsing debug value\n"); for(VAR_1=0;VAR_1<nb_input_streams;VAR_1++) { input_streams[VAR_1]->st->codec->debug = debug; } for(VAR_1=0;VAR_1<nb_output_streams;VAR_1++) { ost = output_streams[VAR_1]; ost->st->codec->debug = debug; } if(debug) av_log_set_level(AV_LOG_DEBUG); fprintf(stderr,"debug=%d\n", debug); } if (VAR_3 == '?'){ fprintf(stderr, "VAR_3 function\n" "? show this help\n" "+ increase verbosity\n" "- decrease verbosity\n" "c Send command to filtergraph\n" "D cycle through available debug modes\n" "h dump packets/hex press to cycle through the 3 states\n" "q quit\n" "s Show QP histogram\n" ); } } if (!need_output()) { av_log(NULL, AV_LOG_VERBOSE, "No more output streams to write to, finishing.\n"); break; } file_index = select_input_file(no_packet); if (file_index < 0) { if (VAR_2) { VAR_2 = 0; memset(no_packet, 0, nb_input_files); usleep(10000); continue; } break; } is = input_files[file_index]->ctx; VAR_0 = av_read_frame(is, &pkt); if (VAR_0 == AVERROR(EAGAIN)) { no_packet[file_index] = 1; VAR_2++; continue; } if (VAR_0 < 0) { input_files[file_index]->eof_reached = 1; for (VAR_1 = 0; VAR_1 < input_files[file_index]->nb_streams; VAR_1++) { ist = input_streams[input_files[file_index]->ist_index + VAR_1]; if (ist->decoding_needed) output_packet(ist, NULL); } if (opt_shortest) break; else continue; } VAR_2 = 0; memset(no_packet, 0, nb_input_files); if (do_pkt_dump) { av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump, is->streams[pkt.stream_index]); } if (pkt.stream_index >= input_files[file_index]->nb_streams) goto discard_packet; ist_index = input_files[file_index]->ist_index + pkt.stream_index; ist = input_streams[ist_index]; if (ist->discard) goto discard_packet; if (pkt.dts != AV_NOPTS_VALUE) pkt.dts += av_rescale_q(input_files[ist->file_index]->ts_offset, AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) pkt.pts += av_rescale_q(input_files[ist->file_index]->ts_offset, AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) pkt.pts *= ist->ts_scale; if (pkt.dts != AV_NOPTS_VALUE) pkt.dts *= ist->ts_scale; if (debug_ts) { av_log(NULL, AV_LOG_INFO, "demuxer -> ist_index:%d type:%s " "next_dts:%s next_dts_time:%s next_pts:%s next_pts_time:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s off:%"PRId64"\n", ist_index, av_get_media_type_string(ist->st->codec->codec_type), av_ts2str(ist->next_dts), av_ts2timestr(ist->next_dts, &ist->st->time_base), av_ts2str(ist->next_pts), av_ts2timestr(ist->next_pts, &ist->st->time_base), av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ist->st->time_base), av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ist->st->time_base), input_files[ist->file_index]->ts_offset); } if (pkt.dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE && !copy_ts) { int64_t pkt_dts = av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q); int64_t delta = pkt_dts - ist->next_dts; if (is->iformat->flags & AVFMT_TS_DISCONT) { if(delta < -1LL*dts_delta_threshold*AV_TIME_BASE || (delta > 1LL*dts_delta_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) || pkt_dts+1<ist->pts){ input_files[ist->file_index]->ts_offset -= delta; av_log(NULL, AV_LOG_DEBUG, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", delta, input_files[ist->file_index]->ts_offset); pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) pkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); } } else { if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE || (delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) || pkt_dts+1<ist->pts){ av_log(NULL, AV_LOG_WARNING, "DTS %"PRId64", next:%"PRId64" st:%d invalid dropping\n", pkt.dts, ist->next_dts, pkt.stream_index); pkt.dts = AV_NOPTS_VALUE; } if (pkt.pts != AV_NOPTS_VALUE){ int64_t pkt_pts = av_rescale_q(pkt.pts, ist->st->time_base, AV_TIME_BASE_Q); delta = pkt_pts - ist->next_dts; if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE || (delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) || pkt_pts+1<ist->pts) { av_log(NULL, AV_LOG_WARNING, "PTS %"PRId64", next:%"PRId64" invalid dropping st:%d\n", pkt.pts, ist->next_dts, pkt.stream_index); pkt.pts = AV_NOPTS_VALUE; } } } } if ((VAR_0 = output_packet(ist, &pkt)) < 0 || ((VAR_0 = poll_filters()) < 0 && VAR_0 != AVERROR_EOF)) { char buf[128]; av_strerror(VAR_0, buf, sizeof(buf)); av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d: %s\n", ist->file_index, ist->st->index, buf); if (exit_on_error) exit_program(1); av_free_packet(&pkt); continue; } discard_packet: av_free_packet(&pkt); print_report(0, timer_start, cur_time); } for (VAR_1 = 0; VAR_1 < nb_input_streams; VAR_1++) { ist = input_streams[VAR_1]; if (!input_files[ist->file_index]->eof_reached && ist->decoding_needed) { output_packet(ist, NULL); } } poll_filters(); flush_encoders(); term_exit(); for (VAR_1 = 0; VAR_1 < nb_output_files; VAR_1++) { os = output_files[VAR_1]->ctx; av_write_trailer(os); } print_report(1, timer_start, av_gettime()); for (VAR_1 = 0; VAR_1 < nb_output_streams; VAR_1++) { ost = output_streams[VAR_1]; if (ost->encoding_needed) { av_freep(&ost->st->codec->stats_in); avcodec_close(ost->st->codec); } } for (VAR_1 = 0; VAR_1 < nb_input_streams; VAR_1++) { ist = input_streams[VAR_1]; if (ist->decoding_needed) { avcodec_close(ist->st->codec); } } VAR_0 = 0; fail: av_freep(&no_packet); if (output_streams) { for (VAR_1 = 0; VAR_1 < nb_output_streams; VAR_1++) { ost = output_streams[VAR_1]; if (ost) { if (ost->stream_copy) av_freep(&ost->st->codec->extradata); if (ost->logfile) { fclose(ost->logfile); ost->logfile = NULL; } av_freep(&ost->st->codec->subtitle_header); av_free(ost->forced_kf_pts); av_dict_free(&ost->opts); } } } return VAR_0; }
[ "static int FUNC_0(void)\n{", "int VAR_0, VAR_1;", "AVFormatContext *is, *os;", "OutputStream *ost;", "InputStream *ist;", "uint8_t *no_packet;", "int VAR_2 = 0;", "int64_t timer_start;", "int VAR_3;", "if (!(no_packet = av_mallocz(nb_input_files)))\nexit_program(1);", "VAR_0 = transcode_init();", "if (VAR_0 < 0)\ngoto fail;", "if (!using_stdin) {", "av_log(NULL, AV_LOG_INFO, \"Press [q] to stop, [?] for help\\n\");", "}", "timer_start = av_gettime();", "for (; received_sigterm == 0;) {", "int file_index, ist_index;", "AVPacket pkt;", "int64_t cur_time= av_gettime();", "if (!using_stdin) {", "static int64_t last_time;", "if (received_nb_signals)\nbreak;", "if(cur_time - last_time >= 100000 && !run_as_daemon){", "VAR_3 = read_key();", "last_time = cur_time;", "}else", "VAR_3 = -1;", "if (VAR_3 == 'q')\nbreak;", "if (VAR_3 == '+') av_log_set_level(av_log_get_level()+10);", "if (VAR_3 == '-') av_log_set_level(av_log_get_level()-10);", "if (VAR_3 == 's') qp_hist ^= 1;", "if (VAR_3 == 'h'){", "if (do_hex_dump){", "do_hex_dump = do_pkt_dump = 0;", "} else if(do_pkt_dump){", "do_hex_dump = 1;", "} else", "do_pkt_dump = 1;", "av_log_set_level(AV_LOG_DEBUG);", "}", "if (VAR_3 == 'c' || VAR_3 == 'C'){", "char buf[4096], target[64], command[256], arg[256] = {0};", "double time;", "int k, n = 0;", "fprintf(stderr, \"\\nEnter command: <target> <time> <command>[ <argument>]\\n\");", "VAR_1 = 0;", "while ((k = read_key()) != '\\n' && k != '\\r' && VAR_1 < sizeof(buf)-1)\nif (k > 0)\nbuf[VAR_1++] = k;", "buf[VAR_1] = 0;", "if (k > 0 &&\n(n = sscanf(buf, \"%63[^ ] %lf %255[^ ] %255[^\\n]\", target, &time, command, arg)) >= 3) {", "av_log(NULL, AV_LOG_DEBUG, \"Processing command target:%s time:%f command:%s arg:%s\",\ntarget, time, command, arg);", "for (VAR_1 = 0; VAR_1 < nb_filtergraphs; VAR_1++) {", "FilterGraph *fg = filtergraphs[VAR_1];", "if (fg->graph) {", "if (time < 0) {", "VAR_0 = avfilter_graph_send_command(fg->graph, target, command, arg, buf, sizeof(buf),\nVAR_3 == 'c' ? AVFILTER_CMD_FLAG_ONE : 0);", "fprintf(stderr, \"Command reply for stream %d: VAR_0:%d res:%s\\n\", VAR_1, VAR_0, buf);", "} else {", "VAR_0 = avfilter_graph_queue_command(fg->graph, target, command, arg, 0, time);", "}", "}", "}", "} else {", "av_log(NULL, AV_LOG_ERROR,\n\"Parse error, at least 3 arguments were expected, \"\n\"only %d given in string '%s'\\n\", n, buf);", "}", "}", "if (VAR_3 == 'd' || VAR_3 == 'D'){", "int debug=0;", "if(VAR_3 == 'D') {", "debug = input_streams[0]->st->codec->debug<<1;", "if(!debug) debug = 1;", "while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE))\ndebug += debug;", "}else", "if(scanf(\"%d\", &debug)!=1)\nfprintf(stderr,\"error parsing debug value\\n\");", "for(VAR_1=0;VAR_1<nb_input_streams;VAR_1++) {", "input_streams[VAR_1]->st->codec->debug = debug;", "}", "for(VAR_1=0;VAR_1<nb_output_streams;VAR_1++) {", "ost = output_streams[VAR_1];", "ost->st->codec->debug = debug;", "}", "if(debug) av_log_set_level(AV_LOG_DEBUG);", "fprintf(stderr,\"debug=%d\\n\", debug);", "}", "if (VAR_3 == '?'){", "fprintf(stderr, \"VAR_3 function\\n\"\n\"? show this help\\n\"\n\"+ increase verbosity\\n\"\n\"- decrease verbosity\\n\"\n\"c Send command to filtergraph\\n\"\n\"D cycle through available debug modes\\n\"\n\"h dump packets/hex press to cycle through the 3 states\\n\"\n\"q quit\\n\"\n\"s Show QP histogram\\n\"\n);", "}", "}", "if (!need_output()) {", "av_log(NULL, AV_LOG_VERBOSE, \"No more output streams to write to, finishing.\\n\");", "break;", "}", "file_index = select_input_file(no_packet);", "if (file_index < 0) {", "if (VAR_2) {", "VAR_2 = 0;", "memset(no_packet, 0, nb_input_files);", "usleep(10000);", "continue;", "}", "break;", "}", "is = input_files[file_index]->ctx;", "VAR_0 = av_read_frame(is, &pkt);", "if (VAR_0 == AVERROR(EAGAIN)) {", "no_packet[file_index] = 1;", "VAR_2++;", "continue;", "}", "if (VAR_0 < 0) {", "input_files[file_index]->eof_reached = 1;", "for (VAR_1 = 0; VAR_1 < input_files[file_index]->nb_streams; VAR_1++) {", "ist = input_streams[input_files[file_index]->ist_index + VAR_1];", "if (ist->decoding_needed)\noutput_packet(ist, NULL);", "}", "if (opt_shortest)\nbreak;", "else\ncontinue;", "}", "VAR_2 = 0;", "memset(no_packet, 0, nb_input_files);", "if (do_pkt_dump) {", "av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,\nis->streams[pkt.stream_index]);", "}", "if (pkt.stream_index >= input_files[file_index]->nb_streams)\ngoto discard_packet;", "ist_index = input_files[file_index]->ist_index + pkt.stream_index;", "ist = input_streams[ist_index];", "if (ist->discard)\ngoto discard_packet;", "if (pkt.dts != AV_NOPTS_VALUE)\npkt.dts += av_rescale_q(input_files[ist->file_index]->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);", "if (pkt.pts != AV_NOPTS_VALUE)\npkt.pts += av_rescale_q(input_files[ist->file_index]->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);", "if (pkt.pts != AV_NOPTS_VALUE)\npkt.pts *= ist->ts_scale;", "if (pkt.dts != AV_NOPTS_VALUE)\npkt.dts *= ist->ts_scale;", "if (debug_ts) {", "av_log(NULL, AV_LOG_INFO, \"demuxer -> ist_index:%d type:%s \"\n\"next_dts:%s next_dts_time:%s next_pts:%s next_pts_time:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s off:%\"PRId64\"\\n\",\nist_index, av_get_media_type_string(ist->st->codec->codec_type),\nav_ts2str(ist->next_dts), av_ts2timestr(ist->next_dts, &ist->st->time_base),\nav_ts2str(ist->next_pts), av_ts2timestr(ist->next_pts, &ist->st->time_base),\nav_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ist->st->time_base),\nav_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ist->st->time_base),\ninput_files[ist->file_index]->ts_offset);", "}", "if (pkt.dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE && !copy_ts) {", "int64_t pkt_dts = av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);", "int64_t delta = pkt_dts - ist->next_dts;", "if (is->iformat->flags & AVFMT_TS_DISCONT) {", "if(delta < -1LL*dts_delta_threshold*AV_TIME_BASE ||\n(delta > 1LL*dts_delta_threshold*AV_TIME_BASE &&\nist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) ||\npkt_dts+1<ist->pts){", "input_files[ist->file_index]->ts_offset -= delta;", "av_log(NULL, AV_LOG_DEBUG,\n\"timestamp discontinuity %\"PRId64\", new offset= %\"PRId64\"\\n\",\ndelta, input_files[ist->file_index]->ts_offset);", "pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);", "if (pkt.pts != AV_NOPTS_VALUE)\npkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);", "}", "} else {", "if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE ||\n(delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) ||\npkt_dts+1<ist->pts){", "av_log(NULL, AV_LOG_WARNING, \"DTS %\"PRId64\", next:%\"PRId64\" st:%d invalid dropping\\n\", pkt.dts, ist->next_dts, pkt.stream_index);", "pkt.dts = AV_NOPTS_VALUE;", "}", "if (pkt.pts != AV_NOPTS_VALUE){", "int64_t pkt_pts = av_rescale_q(pkt.pts, ist->st->time_base, AV_TIME_BASE_Q);", "delta = pkt_pts - ist->next_dts;", "if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE ||\n(delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) ||\npkt_pts+1<ist->pts) {", "av_log(NULL, AV_LOG_WARNING, \"PTS %\"PRId64\", next:%\"PRId64\" invalid dropping st:%d\\n\", pkt.pts, ist->next_dts, pkt.stream_index);", "pkt.pts = AV_NOPTS_VALUE;", "}", "}", "}", "}", "if ((VAR_0 = output_packet(ist, &pkt)) < 0 ||\n((VAR_0 = poll_filters()) < 0 && VAR_0 != AVERROR_EOF)) {", "char buf[128];", "av_strerror(VAR_0, buf, sizeof(buf));", "av_log(NULL, AV_LOG_ERROR, \"Error while decoding stream #%d:%d: %s\\n\",\nist->file_index, ist->st->index, buf);", "if (exit_on_error)\nexit_program(1);", "av_free_packet(&pkt);", "continue;", "}", "discard_packet:\nav_free_packet(&pkt);", "print_report(0, timer_start, cur_time);", "}", "for (VAR_1 = 0; VAR_1 < nb_input_streams; VAR_1++) {", "ist = input_streams[VAR_1];", "if (!input_files[ist->file_index]->eof_reached && ist->decoding_needed) {", "output_packet(ist, NULL);", "}", "}", "poll_filters();", "flush_encoders();", "term_exit();", "for (VAR_1 = 0; VAR_1 < nb_output_files; VAR_1++) {", "os = output_files[VAR_1]->ctx;", "av_write_trailer(os);", "}", "print_report(1, timer_start, av_gettime());", "for (VAR_1 = 0; VAR_1 < nb_output_streams; VAR_1++) {", "ost = output_streams[VAR_1];", "if (ost->encoding_needed) {", "av_freep(&ost->st->codec->stats_in);", "avcodec_close(ost->st->codec);", "}", "}", "for (VAR_1 = 0; VAR_1 < nb_input_streams; VAR_1++) {", "ist = input_streams[VAR_1];", "if (ist->decoding_needed) {", "avcodec_close(ist->st->codec);", "}", "}", "VAR_0 = 0;", "fail:\nav_freep(&no_packet);", "if (output_streams) {", "for (VAR_1 = 0; VAR_1 < nb_output_streams; VAR_1++) {", "ost = output_streams[VAR_1];", "if (ost) {", "if (ost->stream_copy)\nav_freep(&ost->st->codec->extradata);", "if (ost->logfile) {", "fclose(ost->logfile);", "ost->logfile = NULL;", "}", "av_freep(&ost->st->codec->subtitle_header);", "av_free(ost->forced_kf_pts);", "av_dict_free(&ost->opts);", "}", "}", "}", "return VAR_0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23, 25 ], [ 29 ], [ 31, 33 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 61 ], [ 63 ], [ 65, 67 ], [ 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 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 255 ], [ 259 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 281 ], [ 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ], [ 301 ], [ 303 ], [ 305, 307 ], [ 309 ], [ 313, 315 ], [ 317, 319 ], [ 321 ], [ 325 ], [ 327 ], [ 331 ], [ 333, 335 ], [ 337 ], [ 343, 345 ], [ 347 ], [ 349 ], [ 351, 353 ], [ 357, 359 ], [ 361, 363 ], [ 367, 369 ], [ 371, 373 ], [ 377 ], [ 379, 381, 383, 385, 387, 389, 391, 393 ], [ 395 ], [ 399 ], [ 401 ], [ 403 ], [ 405 ], [ 407, 409, 411, 413 ], [ 415 ], [ 417, 419, 421 ], [ 423 ], [ 425, 427 ], [ 429 ], [ 431 ], [ 433, 435, 437 ], [ 439 ], [ 441 ], [ 443 ], [ 445 ], [ 447 ], [ 449 ], [ 451, 453, 455 ], [ 457 ], [ 459 ], [ 461 ], [ 463 ], [ 465 ], [ 467 ], [ 473, 475 ], [ 477 ], [ 479 ], [ 481, 483 ], [ 485, 487 ], [ 489 ], [ 491 ], [ 493 ], [ 497, 499 ], [ 505 ], [ 507 ], [ 513 ], [ 515 ], [ 517 ], [ 519 ], [ 521 ], [ 523 ], [ 525 ], [ 527 ], [ 531 ], [ 537 ], [ 539 ], [ 541 ], [ 543 ], [ 549 ], [ 555 ], [ 557 ], [ 559 ], [ 561 ], [ 563 ], [ 565 ], [ 567 ], [ 573 ], [ 575 ], [ 577 ], [ 579 ], [ 581 ], [ 583 ], [ 589 ], [ 593, 595 ], [ 599 ], [ 601 ], [ 603 ], [ 605 ], [ 607, 609 ], [ 611 ], [ 613 ], [ 615 ], [ 617 ], [ 619 ], [ 621 ], [ 623 ], [ 625 ], [ 627 ], [ 629 ], [ 631 ], [ 633 ] ]
12,570
static int rtsp_write_packet(AVFormatContext *s, AVPacket *pkt) { RTSPState *rt = s->priv_data; RTSPStream *rtsp_st; fd_set rfds; int n, tcp_fd; struct timeval tv; AVFormatContext *rtpctx; int ret; tcp_fd = url_get_file_handle(rt->rtsp_hd); while (1) { FD_ZERO(&rfds); FD_SET(tcp_fd, &rfds); tv.tv_sec = 0; tv.tv_usec = 0; n = select(tcp_fd + 1, &rfds, NULL, NULL, &tv); if (n <= 0) break; if (FD_ISSET(tcp_fd, &rfds)) { RTSPMessageHeader reply; /* Don't let ff_rtsp_read_reply handle interleaved packets, * since it would block and wait for an RTSP reply on the socket * (which may not be coming any time soon) if it handles * interleaved packets internally. */ ret = ff_rtsp_read_reply(s, &reply, NULL, 1, NULL); if (ret < 0) return AVERROR(EPIPE); if (ret == 1) ff_rtsp_skip_packet(s); /* XXX: parse message */ if (rt->state != RTSP_STATE_STREAMING) return AVERROR(EPIPE); } } if (pkt->stream_index < 0 || pkt->stream_index >= rt->nb_rtsp_streams) return AVERROR_INVALIDDATA; rtsp_st = rt->rtsp_streams[pkt->stream_index]; rtpctx = rtsp_st->transport_priv; ret = ff_write_chained(rtpctx, 0, pkt, s); /* ff_write_chained does all the RTP packetization. If using TCP as * transport, rtpctx->pb is only a dyn_packet_buf that queues up the * packets, so we need to send them out on the TCP connection separately. */ if (!ret && rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP) ret = tcp_write_packet(s, rtsp_st); return ret; }
false
FFmpeg
a8475bbdb64e638bd8161df9647876fd23f8a29a
static int rtsp_write_packet(AVFormatContext *s, AVPacket *pkt) { RTSPState *rt = s->priv_data; RTSPStream *rtsp_st; fd_set rfds; int n, tcp_fd; struct timeval tv; AVFormatContext *rtpctx; int ret; tcp_fd = url_get_file_handle(rt->rtsp_hd); while (1) { FD_ZERO(&rfds); FD_SET(tcp_fd, &rfds); tv.tv_sec = 0; tv.tv_usec = 0; n = select(tcp_fd + 1, &rfds, NULL, NULL, &tv); if (n <= 0) break; if (FD_ISSET(tcp_fd, &rfds)) { RTSPMessageHeader reply; ret = ff_rtsp_read_reply(s, &reply, NULL, 1, NULL); if (ret < 0) return AVERROR(EPIPE); if (ret == 1) ff_rtsp_skip_packet(s); if (rt->state != RTSP_STATE_STREAMING) return AVERROR(EPIPE); } } if (pkt->stream_index < 0 || pkt->stream_index >= rt->nb_rtsp_streams) return AVERROR_INVALIDDATA; rtsp_st = rt->rtsp_streams[pkt->stream_index]; rtpctx = rtsp_st->transport_priv; ret = ff_write_chained(rtpctx, 0, pkt, s); if (!ret && rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP) ret = tcp_write_packet(s, rtsp_st); return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1) { RTSPState *rt = VAR_0->priv_data; RTSPStream *rtsp_st; fd_set rfds; int VAR_2, VAR_3; struct timeval VAR_4; AVFormatContext *rtpctx; int VAR_5; VAR_3 = url_get_file_handle(rt->rtsp_hd); while (1) { FD_ZERO(&rfds); FD_SET(VAR_3, &rfds); VAR_4.tv_sec = 0; VAR_4.tv_usec = 0; VAR_2 = select(VAR_3 + 1, &rfds, NULL, NULL, &VAR_4); if (VAR_2 <= 0) break; if (FD_ISSET(VAR_3, &rfds)) { RTSPMessageHeader reply; VAR_5 = ff_rtsp_read_reply(VAR_0, &reply, NULL, 1, NULL); if (VAR_5 < 0) return AVERROR(EPIPE); if (VAR_5 == 1) ff_rtsp_skip_packet(VAR_0); if (rt->state != RTSP_STATE_STREAMING) return AVERROR(EPIPE); } } if (VAR_1->stream_index < 0 || VAR_1->stream_index >= rt->nb_rtsp_streams) return AVERROR_INVALIDDATA; rtsp_st = rt->rtsp_streams[VAR_1->stream_index]; rtpctx = rtsp_st->transport_priv; VAR_5 = ff_write_chained(rtpctx, 0, VAR_1, VAR_0); if (!VAR_5 && rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP) VAR_5 = tcp_write_packet(VAR_0, rtsp_st); return VAR_5; }
[ "static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{", "RTSPState *rt = VAR_0->priv_data;", "RTSPStream *rtsp_st;", "fd_set rfds;", "int VAR_2, VAR_3;", "struct timeval VAR_4;", "AVFormatContext *rtpctx;", "int VAR_5;", "VAR_3 = url_get_file_handle(rt->rtsp_hd);", "while (1) {", "FD_ZERO(&rfds);", "FD_SET(VAR_3, &rfds);", "VAR_4.tv_sec = 0;", "VAR_4.tv_usec = 0;", "VAR_2 = select(VAR_3 + 1, &rfds, NULL, NULL, &VAR_4);", "if (VAR_2 <= 0)\nbreak;", "if (FD_ISSET(VAR_3, &rfds)) {", "RTSPMessageHeader reply;", "VAR_5 = ff_rtsp_read_reply(VAR_0, &reply, NULL, 1, NULL);", "if (VAR_5 < 0)\nreturn AVERROR(EPIPE);", "if (VAR_5 == 1)\nff_rtsp_skip_packet(VAR_0);", "if (rt->state != RTSP_STATE_STREAMING)\nreturn AVERROR(EPIPE);", "}", "}", "if (VAR_1->stream_index < 0 || VAR_1->stream_index >= rt->nb_rtsp_streams)\nreturn AVERROR_INVALIDDATA;", "rtsp_st = rt->rtsp_streams[VAR_1->stream_index];", "rtpctx = rtsp_st->transport_priv;", "VAR_5 = ff_write_chained(rtpctx, 0, VAR_1, VAR_0);", "if (!VAR_5 && rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP)\nVAR_5 = tcp_write_packet(VAR_0, rtsp_st);", "return VAR_5;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 55 ], [ 57, 59 ], [ 61, 63 ], [ 67, 69 ], [ 71 ], [ 73 ], [ 77, 79 ], [ 81 ], [ 83 ], [ 87 ], [ 97, 99 ], [ 101 ], [ 103 ] ]
12,571
static inline TCGv load_reg(DisasContext *s, int reg) { TCGv tmp = new_tmp(); load_reg_var(s, tmp, reg); return tmp; }
true
qemu
7d1b0095bff7157e856d1d0e6c4295641ced2752
static inline TCGv load_reg(DisasContext *s, int reg) { TCGv tmp = new_tmp(); load_reg_var(s, tmp, reg); return tmp; }
{ "code": [ " TCGv tmp = new_tmp();", " TCGv tmp = new_tmp();", " TCGv tmp = new_tmp();", " TCGv tmp = new_tmp();", " TCGv tmp = new_tmp();", " TCGv tmp = new_tmp();", " TCGv tmp = new_tmp();", " TCGv tmp = new_tmp();", " TCGv tmp = new_tmp();", " TCGv tmp = new_tmp();", " TCGv tmp = new_tmp();", " TCGv tmp = new_tmp();", " TCGv tmp = new_tmp();", " TCGv tmp = new_tmp();", " TCGv tmp = new_tmp();", " TCGv tmp = new_tmp();", " TCGv tmp = new_tmp();", " TCGv tmp = new_tmp();", " TCGv tmp = new_tmp();", " TCGv tmp = new_tmp();", " TCGv tmp = new_tmp();" ], "line_no": [ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 ] }
static inline TCGv FUNC_0(DisasContext *s, int reg) { TCGv tmp = new_tmp(); load_reg_var(s, tmp, reg); return tmp; }
[ "static inline TCGv FUNC_0(DisasContext *s, int reg)\n{", "TCGv tmp = new_tmp();", "load_reg_var(s, tmp, reg);", "return tmp;", "}" ]
[ 0, 1, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ] ]
12,572
static void ppc_spapr_init(QEMUMachineInitArgs *args) { ram_addr_t ram_size = args->ram_size; const char *cpu_model = args->cpu_model; const char *kernel_filename = args->kernel_filename; const char *kernel_cmdline = args->kernel_cmdline; const char *initrd_filename = args->initrd_filename; const char *boot_device = args->boot_device; PowerPCCPU *cpu; CPUPPCState *env; PCIHostState *phb; int i; MemoryRegion *sysmem = get_system_memory(); MemoryRegion *ram = g_new(MemoryRegion, 1); hwaddr rma_alloc_size; uint32_t initrd_base = 0; long kernel_size = 0, initrd_size = 0; long load_limit, rtas_limit, fw_size; char *filename; msi_supported = true; spapr = g_malloc0(sizeof(*spapr)); QLIST_INIT(&spapr->phbs); cpu_ppc_hypercall = emulate_spapr_hypercall; /* Allocate RMA if necessary */ rma_alloc_size = kvmppc_alloc_rma("ppc_spapr.rma", sysmem); if (rma_alloc_size == -1) { hw_error("qemu: Unable to create RMA\n"); exit(1); } if (rma_alloc_size && (rma_alloc_size < ram_size)) { spapr->rma_size = rma_alloc_size; } else { spapr->rma_size = ram_size; /* With KVM, we don't actually know whether KVM supports an * unbounded RMA (PR KVM) or is limited by the hash table size * (HV KVM using VRMA), so we always assume the latter * * In that case, we also limit the initial allocations for RTAS * etc... to 256M since we have no way to know what the VRMA size * is going to be as it depends on the size of the hash table * isn't determined yet. */ if (kvm_enabled()) { spapr->vrma_adjust = 1; spapr->rma_size = MIN(spapr->rma_size, 0x10000000); } } /* We place the device tree and RTAS just below either the top of the RMA, * or just below 2GB, whichever is lowere, so that it can be * processed with 32-bit real mode code if necessary */ rtas_limit = MIN(spapr->rma_size, 0x80000000); spapr->rtas_addr = rtas_limit - RTAS_MAX_SIZE; spapr->fdt_addr = spapr->rtas_addr - FDT_MAX_SIZE; load_limit = spapr->fdt_addr - FW_OVERHEAD; /* We aim for a hash table of size 1/128 the size of RAM. The * normal rule of thumb is 1/64 the size of RAM, but that's much * more than needed for the Linux guests we support. */ spapr->htab_shift = 18; /* Minimum architected size */ while (spapr->htab_shift <= 46) { if ((1ULL << (spapr->htab_shift + 7)) >= ram_size) { break; } spapr->htab_shift++; } /* init CPUs */ if (cpu_model == NULL) { cpu_model = kvm_enabled() ? "host" : "POWER7"; } for (i = 0; i < smp_cpus; i++) { cpu = cpu_ppc_init(cpu_model); if (cpu == NULL) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); } env = &cpu->env; /* Set time-base frequency to 512 MHz */ cpu_ppc_tb_init(env, TIMEBASE_FREQ); /* PAPR always has exception vectors in RAM not ROM */ env->hreset_excp_prefix = 0; /* Tell KVM that we're in PAPR mode */ if (kvm_enabled()) { kvmppc_set_papr(cpu); } qemu_register_reset(spapr_cpu_reset, cpu); } /* allocate RAM */ spapr->ram_limit = ram_size; if (spapr->ram_limit > rma_alloc_size) { ram_addr_t nonrma_base = rma_alloc_size; ram_addr_t nonrma_size = spapr->ram_limit - rma_alloc_size; memory_region_init_ram(ram, "ppc_spapr.ram", nonrma_size); vmstate_register_ram_global(ram); memory_region_add_subregion(sysmem, nonrma_base, ram); } filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "spapr-rtas.bin"); spapr->rtas_size = load_image_targphys(filename, spapr->rtas_addr, rtas_limit - spapr->rtas_addr); if (spapr->rtas_size < 0) { hw_error("qemu: could not load LPAR rtas '%s'\n", filename); exit(1); } if (spapr->rtas_size > RTAS_MAX_SIZE) { hw_error("RTAS too big ! 0x%lx bytes (max is 0x%x)\n", spapr->rtas_size, RTAS_MAX_SIZE); exit(1); } g_free(filename); /* Set up Interrupt Controller */ spapr->icp = xics_system_init(XICS_IRQS); spapr->next_irq = XICS_IRQ_BASE; /* Set up EPOW events infrastructure */ spapr_events_init(spapr); /* Set up IOMMU */ spapr_iommu_init(); /* Set up VIO bus */ spapr->vio_bus = spapr_vio_bus_init(); for (i = 0; i < MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { spapr_vty_create(spapr->vio_bus, serial_hds[i]); } } /* We always have at least the nvram device on VIO */ spapr_create_nvram(spapr); /* Set up PCI */ spapr_pci_rtas_init(); spapr_create_phb(spapr, "pci", SPAPR_PCI_BUID, SPAPR_PCI_MEM_WIN_ADDR, SPAPR_PCI_MEM_WIN_SIZE, SPAPR_PCI_IO_WIN_ADDR, SPAPR_PCI_MSI_WIN_ADDR); phb = PCI_HOST_BRIDGE(QLIST_FIRST(&spapr->phbs)); for (i = 0; i < nb_nics; i++) { NICInfo *nd = &nd_table[i]; if (!nd->model) { nd->model = g_strdup("ibmveth"); } if (strcmp(nd->model, "ibmveth") == 0) { spapr_vlan_create(spapr->vio_bus, nd); } else { pci_nic_init_nofail(&nd_table[i], nd->model, NULL); } } for (i = 0; i <= drive_get_max_bus(IF_SCSI); i++) { spapr_vscsi_create(spapr->vio_bus); } /* Graphics */ if (spapr_vga_init(phb->bus)) { spapr->has_graphics = true; } if (usb_enabled(spapr->has_graphics)) { pci_create_simple(phb->bus, -1, "pci-ohci"); if (spapr->has_graphics) { usbdevice_create("keyboard"); usbdevice_create("mouse"); } } if (spapr->rma_size < (MIN_RMA_SLOF << 20)) { fprintf(stderr, "qemu: pSeries SLOF firmware requires >= " "%ldM guest RMA (Real Mode Area memory)\n", MIN_RMA_SLOF); exit(1); } if (kernel_filename) { uint64_t lowaddr = 0; kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL, NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0); if (kernel_size < 0) { kernel_size = load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR, load_limit - KERNEL_LOAD_ADDR); } if (kernel_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } /* load initrd */ if (initrd_filename) { /* Try to locate the initrd in the gap between the kernel * and the firmware. Add a bit of space just in case */ initrd_base = (KERNEL_LOAD_ADDR + kernel_size + 0x1ffff) & ~0xffff; initrd_size = load_image_targphys(initrd_filename, initrd_base, load_limit - initrd_base); if (initrd_size < 0) { fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", initrd_filename); exit(1); } } else { initrd_base = 0; initrd_size = 0; } } filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, FW_FILE_NAME); fw_size = load_image_targphys(filename, 0, FW_MAX_SIZE); if (fw_size < 0) { hw_error("qemu: could not load LPAR rtas '%s'\n", filename); exit(1); } g_free(filename); spapr->entry_point = 0x100; /* Prepare the device tree */ spapr->fdt_skel = spapr_create_fdt_skel(cpu_model, initrd_base, initrd_size, kernel_size, boot_device, kernel_cmdline, spapr->epow_irq); assert(spapr->fdt_skel != NULL); }
true
qemu
caae58cba07efec5f0616f568531c9dfaf1e9179
static void ppc_spapr_init(QEMUMachineInitArgs *args) { ram_addr_t ram_size = args->ram_size; const char *cpu_model = args->cpu_model; const char *kernel_filename = args->kernel_filename; const char *kernel_cmdline = args->kernel_cmdline; const char *initrd_filename = args->initrd_filename; const char *boot_device = args->boot_device; PowerPCCPU *cpu; CPUPPCState *env; PCIHostState *phb; int i; MemoryRegion *sysmem = get_system_memory(); MemoryRegion *ram = g_new(MemoryRegion, 1); hwaddr rma_alloc_size; uint32_t initrd_base = 0; long kernel_size = 0, initrd_size = 0; long load_limit, rtas_limit, fw_size; char *filename; msi_supported = true; spapr = g_malloc0(sizeof(*spapr)); QLIST_INIT(&spapr->phbs); cpu_ppc_hypercall = emulate_spapr_hypercall; rma_alloc_size = kvmppc_alloc_rma("ppc_spapr.rma", sysmem); if (rma_alloc_size == -1) { hw_error("qemu: Unable to create RMA\n"); exit(1); } if (rma_alloc_size && (rma_alloc_size < ram_size)) { spapr->rma_size = rma_alloc_size; } else { spapr->rma_size = ram_size; if (kvm_enabled()) { spapr->vrma_adjust = 1; spapr->rma_size = MIN(spapr->rma_size, 0x10000000); } } rtas_limit = MIN(spapr->rma_size, 0x80000000); spapr->rtas_addr = rtas_limit - RTAS_MAX_SIZE; spapr->fdt_addr = spapr->rtas_addr - FDT_MAX_SIZE; load_limit = spapr->fdt_addr - FW_OVERHEAD; spapr->htab_shift = 18; while (spapr->htab_shift <= 46) { if ((1ULL << (spapr->htab_shift + 7)) >= ram_size) { break; } spapr->htab_shift++; } if (cpu_model == NULL) { cpu_model = kvm_enabled() ? "host" : "POWER7"; } for (i = 0; i < smp_cpus; i++) { cpu = cpu_ppc_init(cpu_model); if (cpu == NULL) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); } env = &cpu->env; cpu_ppc_tb_init(env, TIMEBASE_FREQ); env->hreset_excp_prefix = 0; if (kvm_enabled()) { kvmppc_set_papr(cpu); } qemu_register_reset(spapr_cpu_reset, cpu); } spapr->ram_limit = ram_size; if (spapr->ram_limit > rma_alloc_size) { ram_addr_t nonrma_base = rma_alloc_size; ram_addr_t nonrma_size = spapr->ram_limit - rma_alloc_size; memory_region_init_ram(ram, "ppc_spapr.ram", nonrma_size); vmstate_register_ram_global(ram); memory_region_add_subregion(sysmem, nonrma_base, ram); } filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "spapr-rtas.bin"); spapr->rtas_size = load_image_targphys(filename, spapr->rtas_addr, rtas_limit - spapr->rtas_addr); if (spapr->rtas_size < 0) { hw_error("qemu: could not load LPAR rtas '%s'\n", filename); exit(1); } if (spapr->rtas_size > RTAS_MAX_SIZE) { hw_error("RTAS too big ! 0x%lx bytes (max is 0x%x)\n", spapr->rtas_size, RTAS_MAX_SIZE); exit(1); } g_free(filename); spapr->icp = xics_system_init(XICS_IRQS); spapr->next_irq = XICS_IRQ_BASE; spapr_events_init(spapr); spapr_iommu_init(); spapr->vio_bus = spapr_vio_bus_init(); for (i = 0; i < MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { spapr_vty_create(spapr->vio_bus, serial_hds[i]); } } spapr_create_nvram(spapr); spapr_pci_rtas_init(); spapr_create_phb(spapr, "pci", SPAPR_PCI_BUID, SPAPR_PCI_MEM_WIN_ADDR, SPAPR_PCI_MEM_WIN_SIZE, SPAPR_PCI_IO_WIN_ADDR, SPAPR_PCI_MSI_WIN_ADDR); phb = PCI_HOST_BRIDGE(QLIST_FIRST(&spapr->phbs)); for (i = 0; i < nb_nics; i++) { NICInfo *nd = &nd_table[i]; if (!nd->model) { nd->model = g_strdup("ibmveth"); } if (strcmp(nd->model, "ibmveth") == 0) { spapr_vlan_create(spapr->vio_bus, nd); } else { pci_nic_init_nofail(&nd_table[i], nd->model, NULL); } } for (i = 0; i <= drive_get_max_bus(IF_SCSI); i++) { spapr_vscsi_create(spapr->vio_bus); } if (spapr_vga_init(phb->bus)) { spapr->has_graphics = true; } if (usb_enabled(spapr->has_graphics)) { pci_create_simple(phb->bus, -1, "pci-ohci"); if (spapr->has_graphics) { usbdevice_create("keyboard"); usbdevice_create("mouse"); } } if (spapr->rma_size < (MIN_RMA_SLOF << 20)) { fprintf(stderr, "qemu: pSeries SLOF firmware requires >= " "%ldM guest RMA (Real Mode Area memory)\n", MIN_RMA_SLOF); exit(1); } if (kernel_filename) { uint64_t lowaddr = 0; kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL, NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0); if (kernel_size < 0) { kernel_size = load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR, load_limit - KERNEL_LOAD_ADDR); } if (kernel_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } if (initrd_filename) { initrd_base = (KERNEL_LOAD_ADDR + kernel_size + 0x1ffff) & ~0xffff; initrd_size = load_image_targphys(initrd_filename, initrd_base, load_limit - initrd_base); if (initrd_size < 0) { fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", initrd_filename); exit(1); } } else { initrd_base = 0; initrd_size = 0; } } filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, FW_FILE_NAME); fw_size = load_image_targphys(filename, 0, FW_MAX_SIZE); if (fw_size < 0) { hw_error("qemu: could not load LPAR rtas '%s'\n", filename); exit(1); } g_free(filename); spapr->entry_point = 0x100; spapr->fdt_skel = spapr_create_fdt_skel(cpu_model, initrd_base, initrd_size, kernel_size, boot_device, kernel_cmdline, spapr->epow_irq); assert(spapr->fdt_skel != NULL); }
{ "code": [ " spapr_create_phb(spapr, \"pci\", SPAPR_PCI_BUID,", " SPAPR_PCI_MEM_WIN_ADDR,", " SPAPR_PCI_MEM_WIN_SIZE,", " SPAPR_PCI_IO_WIN_ADDR,", " SPAPR_PCI_MSI_WIN_ADDR);", " phb = PCI_HOST_BRIDGE(QLIST_FIRST(&spapr->phbs));" ], "line_no": [ 303, 305, 307, 309, 311, 313 ] }
static void FUNC_0(QEMUMachineInitArgs *VAR_0) { ram_addr_t ram_size = VAR_0->ram_size; const char *VAR_1 = VAR_0->VAR_1; const char *VAR_2 = VAR_0->VAR_2; const char *VAR_3 = VAR_0->VAR_3; const char *VAR_4 = VAR_0->VAR_4; const char *VAR_5 = VAR_0->VAR_5; PowerPCCPU *cpu; CPUPPCState *env; PCIHostState *phb; int VAR_6; MemoryRegion *sysmem = get_system_memory(); MemoryRegion *ram = g_new(MemoryRegion, 1); hwaddr rma_alloc_size; uint32_t initrd_base = 0; long VAR_7 = 0, VAR_8 = 0; long VAR_9, VAR_10, VAR_11; char *VAR_12; msi_supported = true; spapr = g_malloc0(sizeof(*spapr)); QLIST_INIT(&spapr->phbs); cpu_ppc_hypercall = emulate_spapr_hypercall; rma_alloc_size = kvmppc_alloc_rma("ppc_spapr.rma", sysmem); if (rma_alloc_size == -1) { hw_error("qemu: Unable to create RMA\n"); exit(1); } if (rma_alloc_size && (rma_alloc_size < ram_size)) { spapr->rma_size = rma_alloc_size; } else { spapr->rma_size = ram_size; if (kvm_enabled()) { spapr->vrma_adjust = 1; spapr->rma_size = MIN(spapr->rma_size, 0x10000000); } } VAR_10 = MIN(spapr->rma_size, 0x80000000); spapr->rtas_addr = VAR_10 - RTAS_MAX_SIZE; spapr->fdt_addr = spapr->rtas_addr - FDT_MAX_SIZE; VAR_9 = spapr->fdt_addr - FW_OVERHEAD; spapr->htab_shift = 18; while (spapr->htab_shift <= 46) { if ((1ULL << (spapr->htab_shift + 7)) >= ram_size) { break; } spapr->htab_shift++; } if (VAR_1 == NULL) { VAR_1 = kvm_enabled() ? "host" : "POWER7"; } for (VAR_6 = 0; VAR_6 < smp_cpus; VAR_6++) { cpu = cpu_ppc_init(VAR_1); if (cpu == NULL) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); } env = &cpu->env; cpu_ppc_tb_init(env, TIMEBASE_FREQ); env->hreset_excp_prefix = 0; if (kvm_enabled()) { kvmppc_set_papr(cpu); } qemu_register_reset(spapr_cpu_reset, cpu); } spapr->ram_limit = ram_size; if (spapr->ram_limit > rma_alloc_size) { ram_addr_t nonrma_base = rma_alloc_size; ram_addr_t nonrma_size = spapr->ram_limit - rma_alloc_size; memory_region_init_ram(ram, "ppc_spapr.ram", nonrma_size); vmstate_register_ram_global(ram); memory_region_add_subregion(sysmem, nonrma_base, ram); } VAR_12 = qemu_find_file(QEMU_FILE_TYPE_BIOS, "spapr-rtas.bin"); spapr->rtas_size = load_image_targphys(VAR_12, spapr->rtas_addr, VAR_10 - spapr->rtas_addr); if (spapr->rtas_size < 0) { hw_error("qemu: could not load LPAR rtas '%s'\n", VAR_12); exit(1); } if (spapr->rtas_size > RTAS_MAX_SIZE) { hw_error("RTAS too big ! 0x%lx bytes (max is 0x%x)\n", spapr->rtas_size, RTAS_MAX_SIZE); exit(1); } g_free(VAR_12); spapr->icp = xics_system_init(XICS_IRQS); spapr->next_irq = XICS_IRQ_BASE; spapr_events_init(spapr); spapr_iommu_init(); spapr->vio_bus = spapr_vio_bus_init(); for (VAR_6 = 0; VAR_6 < MAX_SERIAL_PORTS; VAR_6++) { if (serial_hds[VAR_6]) { spapr_vty_create(spapr->vio_bus, serial_hds[VAR_6]); } } spapr_create_nvram(spapr); spapr_pci_rtas_init(); spapr_create_phb(spapr, "pci", SPAPR_PCI_BUID, SPAPR_PCI_MEM_WIN_ADDR, SPAPR_PCI_MEM_WIN_SIZE, SPAPR_PCI_IO_WIN_ADDR, SPAPR_PCI_MSI_WIN_ADDR); phb = PCI_HOST_BRIDGE(QLIST_FIRST(&spapr->phbs)); for (VAR_6 = 0; VAR_6 < nb_nics; VAR_6++) { NICInfo *nd = &nd_table[VAR_6]; if (!nd->model) { nd->model = g_strdup("ibmveth"); } if (strcmp(nd->model, "ibmveth") == 0) { spapr_vlan_create(spapr->vio_bus, nd); } else { pci_nic_init_nofail(&nd_table[VAR_6], nd->model, NULL); } } for (VAR_6 = 0; VAR_6 <= drive_get_max_bus(IF_SCSI); VAR_6++) { spapr_vscsi_create(spapr->vio_bus); } if (spapr_vga_init(phb->bus)) { spapr->has_graphics = true; } if (usb_enabled(spapr->has_graphics)) { pci_create_simple(phb->bus, -1, "pci-ohci"); if (spapr->has_graphics) { usbdevice_create("keyboard"); usbdevice_create("mouse"); } } if (spapr->rma_size < (MIN_RMA_SLOF << 20)) { fprintf(stderr, "qemu: pSeries SLOF firmware requires >= " "%ldM guest RMA (Real Mode Area memory)\n", MIN_RMA_SLOF); exit(1); } if (VAR_2) { uint64_t lowaddr = 0; VAR_7 = load_elf(VAR_2, translate_kernel_address, NULL, NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0); if (VAR_7 < 0) { VAR_7 = load_image_targphys(VAR_2, KERNEL_LOAD_ADDR, VAR_9 - KERNEL_LOAD_ADDR); } if (VAR_7 < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", VAR_2); exit(1); } if (VAR_4) { initrd_base = (KERNEL_LOAD_ADDR + VAR_7 + 0x1ffff) & ~0xffff; VAR_8 = load_image_targphys(VAR_4, initrd_base, VAR_9 - initrd_base); if (VAR_8 < 0) { fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", VAR_4); exit(1); } } else { initrd_base = 0; VAR_8 = 0; } } VAR_12 = qemu_find_file(QEMU_FILE_TYPE_BIOS, FW_FILE_NAME); VAR_11 = load_image_targphys(VAR_12, 0, FW_MAX_SIZE); if (VAR_11 < 0) { hw_error("qemu: could not load LPAR rtas '%s'\n", VAR_12); exit(1); } g_free(VAR_12); spapr->entry_point = 0x100; spapr->fdt_skel = spapr_create_fdt_skel(VAR_1, initrd_base, VAR_8, VAR_7, VAR_5, VAR_3, spapr->epow_irq); assert(spapr->fdt_skel != NULL); }
[ "static void FUNC_0(QEMUMachineInitArgs *VAR_0)\n{", "ram_addr_t ram_size = VAR_0->ram_size;", "const char *VAR_1 = VAR_0->VAR_1;", "const char *VAR_2 = VAR_0->VAR_2;", "const char *VAR_3 = VAR_0->VAR_3;", "const char *VAR_4 = VAR_0->VAR_4;", "const char *VAR_5 = VAR_0->VAR_5;", "PowerPCCPU *cpu;", "CPUPPCState *env;", "PCIHostState *phb;", "int VAR_6;", "MemoryRegion *sysmem = get_system_memory();", "MemoryRegion *ram = g_new(MemoryRegion, 1);", "hwaddr rma_alloc_size;", "uint32_t initrd_base = 0;", "long VAR_7 = 0, VAR_8 = 0;", "long VAR_9, VAR_10, VAR_11;", "char *VAR_12;", "msi_supported = true;", "spapr = g_malloc0(sizeof(*spapr));", "QLIST_INIT(&spapr->phbs);", "cpu_ppc_hypercall = emulate_spapr_hypercall;", "rma_alloc_size = kvmppc_alloc_rma(\"ppc_spapr.rma\", sysmem);", "if (rma_alloc_size == -1) {", "hw_error(\"qemu: Unable to create RMA\\n\");", "exit(1);", "}", "if (rma_alloc_size && (rma_alloc_size < ram_size)) {", "spapr->rma_size = rma_alloc_size;", "} else {", "spapr->rma_size = ram_size;", "if (kvm_enabled()) {", "spapr->vrma_adjust = 1;", "spapr->rma_size = MIN(spapr->rma_size, 0x10000000);", "}", "}", "VAR_10 = MIN(spapr->rma_size, 0x80000000);", "spapr->rtas_addr = VAR_10 - RTAS_MAX_SIZE;", "spapr->fdt_addr = spapr->rtas_addr - FDT_MAX_SIZE;", "VAR_9 = spapr->fdt_addr - FW_OVERHEAD;", "spapr->htab_shift = 18;", "while (spapr->htab_shift <= 46) {", "if ((1ULL << (spapr->htab_shift + 7)) >= ram_size) {", "break;", "}", "spapr->htab_shift++;", "}", "if (VAR_1 == NULL) {", "VAR_1 = kvm_enabled() ? \"host\" : \"POWER7\";", "}", "for (VAR_6 = 0; VAR_6 < smp_cpus; VAR_6++) {", "cpu = cpu_ppc_init(VAR_1);", "if (cpu == NULL) {", "fprintf(stderr, \"Unable to find PowerPC CPU definition\\n\");", "exit(1);", "}", "env = &cpu->env;", "cpu_ppc_tb_init(env, TIMEBASE_FREQ);", "env->hreset_excp_prefix = 0;", "if (kvm_enabled()) {", "kvmppc_set_papr(cpu);", "}", "qemu_register_reset(spapr_cpu_reset, cpu);", "}", "spapr->ram_limit = ram_size;", "if (spapr->ram_limit > rma_alloc_size) {", "ram_addr_t nonrma_base = rma_alloc_size;", "ram_addr_t nonrma_size = spapr->ram_limit - rma_alloc_size;", "memory_region_init_ram(ram, \"ppc_spapr.ram\", nonrma_size);", "vmstate_register_ram_global(ram);", "memory_region_add_subregion(sysmem, nonrma_base, ram);", "}", "VAR_12 = qemu_find_file(QEMU_FILE_TYPE_BIOS, \"spapr-rtas.bin\");", "spapr->rtas_size = load_image_targphys(VAR_12, spapr->rtas_addr,\nVAR_10 - spapr->rtas_addr);", "if (spapr->rtas_size < 0) {", "hw_error(\"qemu: could not load LPAR rtas '%s'\\n\", VAR_12);", "exit(1);", "}", "if (spapr->rtas_size > RTAS_MAX_SIZE) {", "hw_error(\"RTAS too big ! 0x%lx bytes (max is 0x%x)\\n\",\nspapr->rtas_size, RTAS_MAX_SIZE);", "exit(1);", "}", "g_free(VAR_12);", "spapr->icp = xics_system_init(XICS_IRQS);", "spapr->next_irq = XICS_IRQ_BASE;", "spapr_events_init(spapr);", "spapr_iommu_init();", "spapr->vio_bus = spapr_vio_bus_init();", "for (VAR_6 = 0; VAR_6 < MAX_SERIAL_PORTS; VAR_6++) {", "if (serial_hds[VAR_6]) {", "spapr_vty_create(spapr->vio_bus, serial_hds[VAR_6]);", "}", "}", "spapr_create_nvram(spapr);", "spapr_pci_rtas_init();", "spapr_create_phb(spapr, \"pci\", SPAPR_PCI_BUID,\nSPAPR_PCI_MEM_WIN_ADDR,\nSPAPR_PCI_MEM_WIN_SIZE,\nSPAPR_PCI_IO_WIN_ADDR,\nSPAPR_PCI_MSI_WIN_ADDR);", "phb = PCI_HOST_BRIDGE(QLIST_FIRST(&spapr->phbs));", "for (VAR_6 = 0; VAR_6 < nb_nics; VAR_6++) {", "NICInfo *nd = &nd_table[VAR_6];", "if (!nd->model) {", "nd->model = g_strdup(\"ibmveth\");", "}", "if (strcmp(nd->model, \"ibmveth\") == 0) {", "spapr_vlan_create(spapr->vio_bus, nd);", "} else {", "pci_nic_init_nofail(&nd_table[VAR_6], nd->model, NULL);", "}", "}", "for (VAR_6 = 0; VAR_6 <= drive_get_max_bus(IF_SCSI); VAR_6++) {", "spapr_vscsi_create(spapr->vio_bus);", "}", "if (spapr_vga_init(phb->bus)) {", "spapr->has_graphics = true;", "}", "if (usb_enabled(spapr->has_graphics)) {", "pci_create_simple(phb->bus, -1, \"pci-ohci\");", "if (spapr->has_graphics) {", "usbdevice_create(\"keyboard\");", "usbdevice_create(\"mouse\");", "}", "}", "if (spapr->rma_size < (MIN_RMA_SLOF << 20)) {", "fprintf(stderr, \"qemu: pSeries SLOF firmware requires >= \"\n\"%ldM guest RMA (Real Mode Area memory)\\n\", MIN_RMA_SLOF);", "exit(1);", "}", "if (VAR_2) {", "uint64_t lowaddr = 0;", "VAR_7 = load_elf(VAR_2, translate_kernel_address, NULL,\nNULL, &lowaddr, NULL, 1, ELF_MACHINE, 0);", "if (VAR_7 < 0) {", "VAR_7 = load_image_targphys(VAR_2,\nKERNEL_LOAD_ADDR,\nVAR_9 - KERNEL_LOAD_ADDR);", "}", "if (VAR_7 < 0) {", "fprintf(stderr, \"qemu: could not load kernel '%s'\\n\",\nVAR_2);", "exit(1);", "}", "if (VAR_4) {", "initrd_base = (KERNEL_LOAD_ADDR + VAR_7 + 0x1ffff) & ~0xffff;", "VAR_8 = load_image_targphys(VAR_4, initrd_base,\nVAR_9 - initrd_base);", "if (VAR_8 < 0) {", "fprintf(stderr, \"qemu: could not load initial ram disk '%s'\\n\",\nVAR_4);", "exit(1);", "}", "} else {", "initrd_base = 0;", "VAR_8 = 0;", "}", "}", "VAR_12 = qemu_find_file(QEMU_FILE_TYPE_BIOS, FW_FILE_NAME);", "VAR_11 = load_image_targphys(VAR_12, 0, FW_MAX_SIZE);", "if (VAR_11 < 0) {", "hw_error(\"qemu: could not load LPAR rtas '%s'\\n\", VAR_12);", "exit(1);", "}", "g_free(VAR_12);", "spapr->entry_point = 0x100;", "spapr->fdt_skel = spapr_create_fdt_skel(VAR_1,\ninitrd_base, VAR_8,\nVAR_7,\nVAR_5, VAR_3,\nspapr->epow_irq);", "assert(spapr->fdt_skel != NULL);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 45 ], [ 47 ], [ 51 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 175 ], [ 181 ], [ 187 ], [ 189 ], [ 191 ], [ 195 ], [ 197 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 223 ], [ 225, 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 239, 241 ], [ 243 ], [ 245 ], [ 247 ], [ 255 ], [ 257 ], [ 263 ], [ 269 ], [ 275 ], [ 279 ], [ 281 ], [ 283 ], [ 285 ], [ 287 ], [ 293 ], [ 299 ], [ 303, 305, 307, 309, 311 ], [ 313 ], [ 317 ], [ 319 ], [ 323 ], [ 325 ], [ 327 ], [ 331 ], [ 333 ], [ 335 ], [ 337 ], [ 339 ], [ 341 ], [ 345 ], [ 347 ], [ 349 ], [ 355 ], [ 357 ], [ 359 ], [ 363 ], [ 365 ], [ 367 ], [ 369 ], [ 371 ], [ 373 ], [ 375 ], [ 379 ], [ 381, 383 ], [ 385 ], [ 387 ], [ 391 ], [ 393 ], [ 397, 399 ], [ 401 ], [ 403, 405, 407 ], [ 409 ], [ 411 ], [ 413, 415 ], [ 417 ], [ 419 ], [ 425 ], [ 433 ], [ 435, 437 ], [ 439 ], [ 441, 443 ], [ 445 ], [ 447 ], [ 449 ], [ 451 ], [ 453 ], [ 455 ], [ 457 ], [ 461 ], [ 463 ], [ 465 ], [ 467 ], [ 469 ], [ 471 ], [ 473 ], [ 477 ], [ 483, 485, 487, 489, 491 ], [ 493 ], [ 495 ] ]
12,573
static void hmp_info_cpustats(Monitor *mon, const QDict *qdict) { cpu_dump_statistics(mon_get_cpu(), (FILE *)mon, &monitor_fprintf, 0); }
true
qemu
854e67fea6a6f181163a5467fc9ba04de8d181bb
static void hmp_info_cpustats(Monitor *mon, const QDict *qdict) { cpu_dump_statistics(mon_get_cpu(), (FILE *)mon, &monitor_fprintf, 0); }
{ "code": [ " cpu_dump_statistics(mon_get_cpu(), (FILE *)mon, &monitor_fprintf, 0);" ], "line_no": [ 5 ] }
static void FUNC_0(Monitor *VAR_0, const QDict *VAR_1) { cpu_dump_statistics(mon_get_cpu(), (FILE *)VAR_0, &monitor_fprintf, 0); }
[ "static void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)\n{", "cpu_dump_statistics(mon_get_cpu(), (FILE *)VAR_0, &monitor_fprintf, 0);", "}" ]
[ 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
12,574
static int read_decode_block(ALSDecContext *ctx, ALSBlockData *bd) { int ret; ret = read_block(ctx, bd); if (ret) return ret; ret = decode_block(ctx, bd); return ret; }
true
FFmpeg
ca488ad480360dfafcb5766f7bfbb567a0638979
static int read_decode_block(ALSDecContext *ctx, ALSBlockData *bd) { int ret; ret = read_block(ctx, bd); if (ret) return ret; ret = decode_block(ctx, bd); return ret; }
{ "code": [ " ret = read_block(ctx, bd);", " if (ret)", " ret = decode_block(ctx, bd);", " return ret;" ], "line_no": [ 9, 13, 19, 23 ] }
static int FUNC_0(ALSDecContext *VAR_0, ALSBlockData *VAR_1) { int VAR_2; VAR_2 = read_block(VAR_0, VAR_1); if (VAR_2) return VAR_2; VAR_2 = decode_block(VAR_0, VAR_1); return VAR_2; }
[ "static int FUNC_0(ALSDecContext *VAR_0, ALSBlockData *VAR_1)\n{", "int VAR_2;", "VAR_2 = read_block(VAR_0, VAR_1);", "if (VAR_2)\nreturn VAR_2;", "VAR_2 = decode_block(VAR_0, VAR_1);", "return VAR_2;", "}" ]
[ 0, 0, 1, 1, 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 13, 15 ], [ 19 ], [ 23 ], [ 25 ] ]
12,575
DeviceState *aux_create_slave(AUXBus *bus, const char *type, uint32_t addr) { DeviceState *dev; dev = DEVICE(object_new(type)); assert(dev); qdev_set_parent_bus(dev, &bus->qbus); qdev_init_nofail(dev); aux_bus_map_device(AUX_BUS(qdev_get_parent_bus(dev)), AUX_SLAVE(dev), addr); return dev; }
true
qemu
e0dadc1e9ef1f35208e5d2af9c7740c18a0b769f
DeviceState *aux_create_slave(AUXBus *bus, const char *type, uint32_t addr) { DeviceState *dev; dev = DEVICE(object_new(type)); assert(dev); qdev_set_parent_bus(dev, &bus->qbus); qdev_init_nofail(dev); aux_bus_map_device(AUX_BUS(qdev_get_parent_bus(dev)), AUX_SLAVE(dev), addr); return dev; }
{ "code": [], "line_no": [] }
DeviceState *FUNC_0(AUXBus *bus, const char *type, uint32_t addr) { DeviceState *dev; dev = DEVICE(object_new(type)); assert(dev); qdev_set_parent_bus(dev, &bus->qbus); qdev_init_nofail(dev); aux_bus_map_device(AUX_BUS(qdev_get_parent_bus(dev)), AUX_SLAVE(dev), addr); return dev; }
[ "DeviceState *FUNC_0(AUXBus *bus, const char *type, uint32_t addr)\n{", "DeviceState *dev;", "dev = DEVICE(object_new(type));", "assert(dev);", "qdev_set_parent_bus(dev, &bus->qbus);", "qdev_init_nofail(dev);", "aux_bus_map_device(AUX_BUS(qdev_get_parent_bus(dev)), AUX_SLAVE(dev), addr);", "return dev;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ] ]
12,576
static int get_uint64_equal(QEMUFile *f, void *pv, size_t size, VMStateField *field) { uint64_t *v = pv; uint64_t v2; qemu_get_be64s(f, &v2); if (*v == v2) { return 0; error_report("%" PRIx64 " != %" PRIx64, *v, v2); return -EINVAL;
true
qemu
d2164ad35c411d97abd2aa5c6f160283d215e214
static int get_uint64_equal(QEMUFile *f, void *pv, size_t size, VMStateField *field) { uint64_t *v = pv; uint64_t v2; qemu_get_be64s(f, &v2); if (*v == v2) { return 0; error_report("%" PRIx64 " != %" PRIx64, *v, v2); return -EINVAL;
{ "code": [], "line_no": [] }
static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2, VMStateField *VAR_3) { uint64_t *v = VAR_1; uint64_t v2; qemu_get_be64s(VAR_0, &v2); if (*v == v2) { return 0; error_report("%" PRIx64 " != %" PRIx64, *v, v2); return -EINVAL;
[ "static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2,\nVMStateField *VAR_3)\n{", "uint64_t *v = VAR_1;", "uint64_t v2;", "qemu_get_be64s(VAR_0, &v2);", "if (*v == v2) {", "return 0;", "error_report(\"%\" PRIx64 \" != %\" PRIx64, *v, v2);", "return -EINVAL;" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 20 ], [ 25 ] ]
12,577
static void vhost_net_stop_one(struct vhost_net *net, VirtIODevice *dev) { struct vhost_vring_file file = { .fd = -1 }; if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) { for (file.index = 0; file.index < net->dev.nvqs; ++file.index) { const VhostOps *vhost_ops = net->dev.vhost_ops; int r = vhost_ops->vhost_net_set_backend(&net->dev, &file); assert(r >= 0); } } if (net->nc->info->poll) { net->nc->info->poll(net->nc, true); } vhost_dev_stop(&net->dev, dev); vhost_dev_disable_notifiers(&net->dev, dev); }
true
qemu
950d94ba0671e7f154a9e87a277f8efbddcee28f
static void vhost_net_stop_one(struct vhost_net *net, VirtIODevice *dev) { struct vhost_vring_file file = { .fd = -1 }; if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) { for (file.index = 0; file.index < net->dev.nvqs; ++file.index) { const VhostOps *vhost_ops = net->dev.vhost_ops; int r = vhost_ops->vhost_net_set_backend(&net->dev, &file); assert(r >= 0); } } if (net->nc->info->poll) { net->nc->info->poll(net->nc, true); } vhost_dev_stop(&net->dev, dev); vhost_dev_disable_notifiers(&net->dev, dev); }
{ "code": [ " const VhostOps *vhost_ops = net->dev.vhost_ops;", " const VhostOps *vhost_ops = net->dev.vhost_ops;", " int r = vhost_ops->vhost_net_set_backend(&net->dev, &file);", " const VhostOps *vhost_ops = net->dev.vhost_ops;", " int r = vhost_ops->vhost_net_set_backend(&net->dev, &file);" ], "line_no": [ 15, 15, 17, 15, 17 ] }
static void FUNC_0(struct vhost_net *VAR_0, VirtIODevice *VAR_1) { struct vhost_vring_file VAR_2 = { .fd = -1 }; if (VAR_0->nc->info->type == NET_CLIENT_DRIVER_TAP) { for (VAR_2.index = 0; VAR_2.index < VAR_0->VAR_1.nvqs; ++VAR_2.index) { const VhostOps *vhost_ops = VAR_0->VAR_1.vhost_ops; int r = vhost_ops->vhost_net_set_backend(&VAR_0->VAR_1, &VAR_2); assert(r >= 0); } } if (VAR_0->nc->info->poll) { VAR_0->nc->info->poll(VAR_0->nc, true); } vhost_dev_stop(&VAR_0->VAR_1, VAR_1); vhost_dev_disable_notifiers(&VAR_0->VAR_1, VAR_1); }
[ "static void FUNC_0(struct vhost_net *VAR_0,\nVirtIODevice *VAR_1)\n{", "struct vhost_vring_file VAR_2 = { .fd = -1 };", "if (VAR_0->nc->info->type == NET_CLIENT_DRIVER_TAP) {", "for (VAR_2.index = 0; VAR_2.index < VAR_0->VAR_1.nvqs; ++VAR_2.index) {", "const VhostOps *vhost_ops = VAR_0->VAR_1.vhost_ops;", "int r = vhost_ops->vhost_net_set_backend(&VAR_0->VAR_1, &VAR_2);", "assert(r >= 0);", "}", "}", "if (VAR_0->nc->info->poll) {", "VAR_0->nc->info->poll(VAR_0->nc, true);", "}", "vhost_dev_stop(&VAR_0->VAR_1, VAR_1);", "vhost_dev_disable_notifiers(&VAR_0->VAR_1, VAR_1);", "}" ]
[ 0, 0, 0, 0, 1, 1, 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 ] ]
12,578
static int pci_init_multifunction(PCIBus *bus, PCIDevice *dev) { uint8_t slot = PCI_SLOT(dev->devfn); uint8_t func; if (dev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) { dev->config[PCI_HEADER_TYPE] |= PCI_HEADER_TYPE_MULTI_FUNCTION; } /* * multifunction bit is interpreted in two ways as follows. * - all functions must set the bit to 1. * Example: Intel X53 * - function 0 must set the bit, but the rest function (> 0) * is allowed to leave the bit to 0. * Example: PIIX3(also in qemu), PIIX4(also in qemu), ICH10, * * So OS (at least Linux) checks the bit of only function 0, * and doesn't see the bit of function > 0. * * The below check allows both interpretation. */ if (PCI_FUNC(dev->devfn)) { PCIDevice *f0 = bus->devices[PCI_DEVFN(slot, 0)]; if (f0 && !(f0->cap_present & QEMU_PCI_CAP_MULTIFUNCTION)) { /* function 0 should set multifunction bit */ error_report("PCI: single function device can't be populated " "in function %x.%x", slot, PCI_FUNC(dev->devfn)); return -1; } return 0; } if (dev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) { return 0; } /* function 0 indicates single function, so function > 0 must be NULL */ for (func = 1; func < PCI_FUNC_MAX; ++func) { if (bus->devices[PCI_DEVFN(slot, func)]) { error_report("PCI: %x.0 indicates single function, " "but %x.%x is already populated.", slot, slot, func); return -1; } } return 0; }
true
qemu
133e9b228df16d11de01529c217417e78d1d9370
static int pci_init_multifunction(PCIBus *bus, PCIDevice *dev) { uint8_t slot = PCI_SLOT(dev->devfn); uint8_t func; if (dev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) { dev->config[PCI_HEADER_TYPE] |= PCI_HEADER_TYPE_MULTI_FUNCTION; } if (PCI_FUNC(dev->devfn)) { PCIDevice *f0 = bus->devices[PCI_DEVFN(slot, 0)]; if (f0 && !(f0->cap_present & QEMU_PCI_CAP_MULTIFUNCTION)) { error_report("PCI: single function device can't be populated " "in function %x.%x", slot, PCI_FUNC(dev->devfn)); return -1; } return 0; } if (dev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) { return 0; } for (func = 1; func < PCI_FUNC_MAX; ++func) { if (bus->devices[PCI_DEVFN(slot, func)]) { error_report("PCI: %x.0 indicates single function, " "but %x.%x is already populated.", slot, slot, func); return -1; } } return 0; }
{ "code": [ "static int pci_init_multifunction(PCIBus *bus, PCIDevice *dev)", " error_report(\"PCI: single function device can't be populated \"", " \"in function %x.%x\", slot, PCI_FUNC(dev->devfn));", " return -1;", " return 0;", " return 0;", " error_report(\"PCI: %x.0 indicates single function, \"", " \"but %x.%x is already populated.\",", " slot, slot, func);", " return -1;", " return 0;", " return 0;", " return 0;", " return 0;", " return 0;", " return -1;", " return 0;", " return 0;" ], "line_no": [ 1, 53, 55, 57, 61, 61, 79, 81, 83, 57, 91, 91, 91, 61, 61, 57, 61, 91 ] }
static int FUNC_0(PCIBus *VAR_0, PCIDevice *VAR_1) { uint8_t slot = PCI_SLOT(VAR_1->devfn); uint8_t func; if (VAR_1->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) { VAR_1->config[PCI_HEADER_TYPE] |= PCI_HEADER_TYPE_MULTI_FUNCTION; } if (PCI_FUNC(VAR_1->devfn)) { PCIDevice *f0 = VAR_0->devices[PCI_DEVFN(slot, 0)]; if (f0 && !(f0->cap_present & QEMU_PCI_CAP_MULTIFUNCTION)) { error_report("PCI: single function device can't be populated " "in function %x.%x", slot, PCI_FUNC(VAR_1->devfn)); return -1; } return 0; } if (VAR_1->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) { return 0; } for (func = 1; func < PCI_FUNC_MAX; ++func) { if (VAR_0->devices[PCI_DEVFN(slot, func)]) { error_report("PCI: %x.0 indicates single function, " "but %x.%x is already populated.", slot, slot, func); return -1; } } return 0; }
[ "static int FUNC_0(PCIBus *VAR_0, PCIDevice *VAR_1)\n{", "uint8_t slot = PCI_SLOT(VAR_1->devfn);", "uint8_t func;", "if (VAR_1->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) {", "VAR_1->config[PCI_HEADER_TYPE] |= PCI_HEADER_TYPE_MULTI_FUNCTION;", "}", "if (PCI_FUNC(VAR_1->devfn)) {", "PCIDevice *f0 = VAR_0->devices[PCI_DEVFN(slot, 0)];", "if (f0 && !(f0->cap_present & QEMU_PCI_CAP_MULTIFUNCTION)) {", "error_report(\"PCI: single function device can't be populated \"\n\"in function %x.%x\", slot, PCI_FUNC(VAR_1->devfn));", "return -1;", "}", "return 0;", "}", "if (VAR_1->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) {", "return 0;", "}", "for (func = 1; func < PCI_FUNC_MAX; ++func) {", "if (VAR_0->devices[PCI_DEVFN(slot, func)]) {", "error_report(\"PCI: %x.0 indicates single function, \"\n\"but %x.%x is already populated.\",\nslot, slot, func);", "return -1;", "}", "}", "return 0;", "}" ]
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 45 ], [ 47 ], [ 49 ], [ 53, 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 79, 81, 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ] ]
12,580
static int mpeg_mux_init(AVFormatContext *ctx) { MpegMuxContext *s = ctx->priv_data; int bitrate, i, mpa_id, mpv_id, mps_id, ac3_id, dts_id, lpcm_id, j; AVStream *st; StreamInfo *stream; int audio_bitrate; int video_bitrate; s->packet_number = 0; s->is_vcd = (CONFIG_MPEG1VCD_MUXER && ctx->oformat == &mpeg1vcd_muxer); s->is_svcd = (CONFIG_MPEG2SVCD_MUXER && ctx->oformat == &mpeg2svcd_muxer); s->is_mpeg2 = ((CONFIG_MPEG2VOB_MUXER && ctx->oformat == &mpeg2vob_muxer) || (CONFIG_MPEG2DVD_MUXER && ctx->oformat == &mpeg2dvd_muxer) || (CONFIG_MPEG2SVCD_MUXER && ctx->oformat == &mpeg2svcd_muxer)); s->is_dvd = (CONFIG_MPEG2DVD_MUXER && ctx->oformat == &mpeg2dvd_muxer); if(ctx->packet_size) s->packet_size = ctx->packet_size; else s->packet_size = 2048; s->vcd_padding_bytes_written = 0; s->vcd_padding_bitrate=0; s->audio_bound = 0; s->video_bound = 0; mpa_id = AUDIO_ID; ac3_id = AC3_ID; dts_id = DTS_ID; mpv_id = VIDEO_ID; mps_id = SUB_ID; lpcm_id = LPCM_ID; for(i=0;i<ctx->nb_streams;i++) { st = ctx->streams[i]; stream = av_mallocz(sizeof(StreamInfo)); if (!stream) goto fail; st->priv_data = stream; av_set_pts_info(st, 64, 1, 90000); switch(st->codec->codec_type) { case CODEC_TYPE_AUDIO: if (st->codec->codec_id == CODEC_ID_AC3) { stream->id = ac3_id++; } else if (st->codec->codec_id == CODEC_ID_DTS) { stream->id = dts_id++; } else if (st->codec->codec_id == CODEC_ID_PCM_S16BE) { stream->id = lpcm_id++; for(j = 0; j < 4; j++) { if (lpcm_freq_tab[j] == st->codec->sample_rate) break; } if (j == 4) goto fail; if (st->codec->channels > 8) return -1; stream->lpcm_header[0] = 0x0c; stream->lpcm_header[1] = (st->codec->channels - 1) | (j << 4); stream->lpcm_header[2] = 0x80; stream->lpcm_align = st->codec->channels * 2; } else { stream->id = mpa_id++; } /* This value HAS to be used for VCD (see VCD standard, p. IV-7). Right now it is also used for everything else.*/ stream->max_buffer_size = 4 * 1024; s->audio_bound++; break; case CODEC_TYPE_VIDEO: stream->id = mpv_id++; if (st->codec->rc_buffer_size) stream->max_buffer_size = 6*1024 + st->codec->rc_buffer_size/8; else stream->max_buffer_size = 230*1024; //FIXME this is probably too small as default #if 0 /* see VCD standard, p. IV-7*/ stream->max_buffer_size = 46 * 1024; else /* This value HAS to be used for SVCD (see SVCD standard, p. 26 V.2.3.2). Right now it is also used for everything else.*/ stream->max_buffer_size = 230 * 1024; #endif s->video_bound++; break; case CODEC_TYPE_SUBTITLE: stream->id = mps_id++; stream->max_buffer_size = 16 * 1024; break; default: return -1; } stream->fifo= av_fifo_alloc(16); } bitrate = 0; audio_bitrate = 0; video_bitrate = 0; for(i=0;i<ctx->nb_streams;i++) { int codec_rate; st = ctx->streams[i]; stream = (StreamInfo*) st->priv_data; if(st->codec->rc_max_rate || stream->id==VIDEO_ID) codec_rate= st->codec->rc_max_rate; else codec_rate= st->codec->bit_rate; if(!codec_rate) codec_rate= (1<<21)*8*50/ctx->nb_streams; bitrate += codec_rate; if (stream->id==AUDIO_ID) audio_bitrate += codec_rate; else if (stream->id==VIDEO_ID) video_bitrate += codec_rate; } if(ctx->mux_rate){ s->mux_rate= (ctx->mux_rate + (8 * 50) - 1) / (8 * 50); } else { /* we increase slightly the bitrate to take into account the headers. XXX: compute it exactly */ bitrate += bitrate*5/100; bitrate += 10000; s->mux_rate = (bitrate + (8 * 50) - 1) / (8 * 50); } if (s->is_vcd) { double overhead_rate; /* The VCD standard mandates that the mux_rate field is 3528 (see standard p. IV-6). The value is actually "wrong", i.e. if you calculate it using the normal formula and the 75 sectors per second transfer rate you get a different value because the real pack size is 2324, not 2352. But the standard explicitly specifies that the mux_rate field in the header must have this value.*/ // s->mux_rate=2352 * 75 / 50; /* = 3528*/ /* The VCD standard states that the muxed stream must be exactly 75 packs / second (the data rate of a single speed cdrom). Since the video bitrate (probably 1150000 bits/sec) will be below the theoretical maximum we have to add some padding packets to make up for the lower data rate. (cf. VCD standard p. IV-6 )*/ /* Add the header overhead to the data rate. 2279 data bytes per audio pack, 2294 data bytes per video pack*/ overhead_rate = ((audio_bitrate / 8.0) / 2279) * (2324 - 2279); overhead_rate += ((video_bitrate / 8.0) / 2294) * (2324 - 2294); overhead_rate *= 8; /* Add padding so that the full bitrate is 2324*75 bytes/sec */ s->vcd_padding_bitrate = 2324 * 75 * 8 - (bitrate + overhead_rate); } if (s->is_vcd || s->is_mpeg2) /* every packet */ s->pack_header_freq = 1; else /* every 2 seconds */ s->pack_header_freq = 2 * bitrate / s->packet_size / 8; /* the above seems to make pack_header_freq zero sometimes */ if (s->pack_header_freq == 0) s->pack_header_freq = 1; if (s->is_mpeg2) /* every 200 packets. Need to look at the spec. */ s->system_header_freq = s->pack_header_freq * 40; else if (s->is_vcd) /* the standard mandates that there are only two system headers in the whole file: one in the first packet of each stream. (see standard p. IV-7 and IV-8) */ s->system_header_freq = 0x7fffffff; else s->system_header_freq = s->pack_header_freq * 5; for(i=0;i<ctx->nb_streams;i++) { stream = ctx->streams[i]->priv_data; stream->packet_number = 0; } s->system_header_size = get_system_header_size(ctx); s->last_scr = 0; return 0; fail: for(i=0;i<ctx->nb_streams;i++) { av_free(ctx->streams[i]->priv_data); } return AVERROR(ENOMEM); }
false
FFmpeg
24dc7776ff4452764d0365b12d0728153f879cf8
static int mpeg_mux_init(AVFormatContext *ctx) { MpegMuxContext *s = ctx->priv_data; int bitrate, i, mpa_id, mpv_id, mps_id, ac3_id, dts_id, lpcm_id, j; AVStream *st; StreamInfo *stream; int audio_bitrate; int video_bitrate; s->packet_number = 0; s->is_vcd = (CONFIG_MPEG1VCD_MUXER && ctx->oformat == &mpeg1vcd_muxer); s->is_svcd = (CONFIG_MPEG2SVCD_MUXER && ctx->oformat == &mpeg2svcd_muxer); s->is_mpeg2 = ((CONFIG_MPEG2VOB_MUXER && ctx->oformat == &mpeg2vob_muxer) || (CONFIG_MPEG2DVD_MUXER && ctx->oformat == &mpeg2dvd_muxer) || (CONFIG_MPEG2SVCD_MUXER && ctx->oformat == &mpeg2svcd_muxer)); s->is_dvd = (CONFIG_MPEG2DVD_MUXER && ctx->oformat == &mpeg2dvd_muxer); if(ctx->packet_size) s->packet_size = ctx->packet_size; else s->packet_size = 2048; s->vcd_padding_bytes_written = 0; s->vcd_padding_bitrate=0; s->audio_bound = 0; s->video_bound = 0; mpa_id = AUDIO_ID; ac3_id = AC3_ID; dts_id = DTS_ID; mpv_id = VIDEO_ID; mps_id = SUB_ID; lpcm_id = LPCM_ID; for(i=0;i<ctx->nb_streams;i++) { st = ctx->streams[i]; stream = av_mallocz(sizeof(StreamInfo)); if (!stream) goto fail; st->priv_data = stream; av_set_pts_info(st, 64, 1, 90000); switch(st->codec->codec_type) { case CODEC_TYPE_AUDIO: if (st->codec->codec_id == CODEC_ID_AC3) { stream->id = ac3_id++; } else if (st->codec->codec_id == CODEC_ID_DTS) { stream->id = dts_id++; } else if (st->codec->codec_id == CODEC_ID_PCM_S16BE) { stream->id = lpcm_id++; for(j = 0; j < 4; j++) { if (lpcm_freq_tab[j] == st->codec->sample_rate) break; } if (j == 4) goto fail; if (st->codec->channels > 8) return -1; stream->lpcm_header[0] = 0x0c; stream->lpcm_header[1] = (st->codec->channels - 1) | (j << 4); stream->lpcm_header[2] = 0x80; stream->lpcm_align = st->codec->channels * 2; } else { stream->id = mpa_id++; } stream->max_buffer_size = 4 * 1024; s->audio_bound++; break; case CODEC_TYPE_VIDEO: stream->id = mpv_id++; if (st->codec->rc_buffer_size) stream->max_buffer_size = 6*1024 + st->codec->rc_buffer_size/8; else stream->max_buffer_size = 230*1024; #if 0 stream->max_buffer_size = 46 * 1024; else stream->max_buffer_size = 230 * 1024; #endif s->video_bound++; break; case CODEC_TYPE_SUBTITLE: stream->id = mps_id++; stream->max_buffer_size = 16 * 1024; break; default: return -1; } stream->fifo= av_fifo_alloc(16); } bitrate = 0; audio_bitrate = 0; video_bitrate = 0; for(i=0;i<ctx->nb_streams;i++) { int codec_rate; st = ctx->streams[i]; stream = (StreamInfo*) st->priv_data; if(st->codec->rc_max_rate || stream->id==VIDEO_ID) codec_rate= st->codec->rc_max_rate; else codec_rate= st->codec->bit_rate; if(!codec_rate) codec_rate= (1<<21)*8*50/ctx->nb_streams; bitrate += codec_rate; if (stream->id==AUDIO_ID) audio_bitrate += codec_rate; else if (stream->id==VIDEO_ID) video_bitrate += codec_rate; } if(ctx->mux_rate){ s->mux_rate= (ctx->mux_rate + (8 * 50) - 1) / (8 * 50); } else { bitrate += bitrate*5/100; bitrate += 10000; s->mux_rate = (bitrate + (8 * 50) - 1) / (8 * 50); } if (s->is_vcd) { double overhead_rate; overhead_rate = ((audio_bitrate / 8.0) / 2279) * (2324 - 2279); overhead_rate += ((video_bitrate / 8.0) / 2294) * (2324 - 2294); overhead_rate *= 8; s->vcd_padding_bitrate = 2324 * 75 * 8 - (bitrate + overhead_rate); } if (s->is_vcd || s->is_mpeg2) s->pack_header_freq = 1; else s->pack_header_freq = 2 * bitrate / s->packet_size / 8; if (s->pack_header_freq == 0) s->pack_header_freq = 1; if (s->is_mpeg2) s->system_header_freq = s->pack_header_freq * 40; else if (s->is_vcd) s->system_header_freq = 0x7fffffff; else s->system_header_freq = s->pack_header_freq * 5; for(i=0;i<ctx->nb_streams;i++) { stream = ctx->streams[i]->priv_data; stream->packet_number = 0; } s->system_header_size = get_system_header_size(ctx); s->last_scr = 0; return 0; fail: for(i=0;i<ctx->nb_streams;i++) { av_free(ctx->streams[i]->priv_data); } return AVERROR(ENOMEM); }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0) { MpegMuxContext *s = VAR_0->priv_data; int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9; AVStream *st; StreamInfo *stream; int VAR_10; int VAR_11; s->packet_number = 0; s->is_vcd = (CONFIG_MPEG1VCD_MUXER && VAR_0->oformat == &mpeg1vcd_muxer); s->is_svcd = (CONFIG_MPEG2SVCD_MUXER && VAR_0->oformat == &mpeg2svcd_muxer); s->is_mpeg2 = ((CONFIG_MPEG2VOB_MUXER && VAR_0->oformat == &mpeg2vob_muxer) || (CONFIG_MPEG2DVD_MUXER && VAR_0->oformat == &mpeg2dvd_muxer) || (CONFIG_MPEG2SVCD_MUXER && VAR_0->oformat == &mpeg2svcd_muxer)); s->is_dvd = (CONFIG_MPEG2DVD_MUXER && VAR_0->oformat == &mpeg2dvd_muxer); if(VAR_0->packet_size) s->packet_size = VAR_0->packet_size; else s->packet_size = 2048; s->vcd_padding_bytes_written = 0; s->vcd_padding_bitrate=0; s->audio_bound = 0; s->video_bound = 0; VAR_3 = AUDIO_ID; VAR_6 = AC3_ID; VAR_7 = DTS_ID; VAR_4 = VIDEO_ID; VAR_5 = SUB_ID; VAR_8 = LPCM_ID; for(VAR_2=0;VAR_2<VAR_0->nb_streams;VAR_2++) { st = VAR_0->streams[VAR_2]; stream = av_mallocz(sizeof(StreamInfo)); if (!stream) goto fail; st->priv_data = stream; av_set_pts_info(st, 64, 1, 90000); switch(st->codec->codec_type) { case CODEC_TYPE_AUDIO: if (st->codec->codec_id == CODEC_ID_AC3) { stream->id = VAR_6++; } else if (st->codec->codec_id == CODEC_ID_DTS) { stream->id = VAR_7++; } else if (st->codec->codec_id == CODEC_ID_PCM_S16BE) { stream->id = VAR_8++; for(VAR_9 = 0; VAR_9 < 4; VAR_9++) { if (lpcm_freq_tab[VAR_9] == st->codec->sample_rate) break; } if (VAR_9 == 4) goto fail; if (st->codec->channels > 8) return -1; stream->lpcm_header[0] = 0x0c; stream->lpcm_header[1] = (st->codec->channels - 1) | (VAR_9 << 4); stream->lpcm_header[2] = 0x80; stream->lpcm_align = st->codec->channels * 2; } else { stream->id = VAR_3++; } stream->max_buffer_size = 4 * 1024; s->audio_bound++; break; case CODEC_TYPE_VIDEO: stream->id = VAR_4++; if (st->codec->rc_buffer_size) stream->max_buffer_size = 6*1024 + st->codec->rc_buffer_size/8; else stream->max_buffer_size = 230*1024; #if 0 stream->max_buffer_size = 46 * 1024; else stream->max_buffer_size = 230 * 1024; #endif s->video_bound++; break; case CODEC_TYPE_SUBTITLE: stream->id = VAR_5++; stream->max_buffer_size = 16 * 1024; break; default: return -1; } stream->fifo= av_fifo_alloc(16); } VAR_1 = 0; VAR_10 = 0; VAR_11 = 0; for(VAR_2=0;VAR_2<VAR_0->nb_streams;VAR_2++) { int codec_rate; st = VAR_0->streams[VAR_2]; stream = (StreamInfo*) st->priv_data; if(st->codec->rc_max_rate || stream->id==VIDEO_ID) codec_rate= st->codec->rc_max_rate; else codec_rate= st->codec->bit_rate; if(!codec_rate) codec_rate= (1<<21)*8*50/VAR_0->nb_streams; VAR_1 += codec_rate; if (stream->id==AUDIO_ID) VAR_10 += codec_rate; else if (stream->id==VIDEO_ID) VAR_11 += codec_rate; } if(VAR_0->mux_rate){ s->mux_rate= (VAR_0->mux_rate + (8 * 50) - 1) / (8 * 50); } else { VAR_1 += VAR_1*5/100; VAR_1 += 10000; s->mux_rate = (VAR_1 + (8 * 50) - 1) / (8 * 50); } if (s->is_vcd) { double VAR_12; VAR_12 = ((VAR_10 / 8.0) / 2279) * (2324 - 2279); VAR_12 += ((VAR_11 / 8.0) / 2294) * (2324 - 2294); VAR_12 *= 8; s->vcd_padding_bitrate = 2324 * 75 * 8 - (VAR_1 + VAR_12); } if (s->is_vcd || s->is_mpeg2) s->pack_header_freq = 1; else s->pack_header_freq = 2 * VAR_1 / s->packet_size / 8; if (s->pack_header_freq == 0) s->pack_header_freq = 1; if (s->is_mpeg2) s->system_header_freq = s->pack_header_freq * 40; else if (s->is_vcd) s->system_header_freq = 0x7fffffff; else s->system_header_freq = s->pack_header_freq * 5; for(VAR_2=0;VAR_2<VAR_0->nb_streams;VAR_2++) { stream = VAR_0->streams[VAR_2]->priv_data; stream->packet_number = 0; } s->system_header_size = get_system_header_size(VAR_0); s->last_scr = 0; return 0; fail: for(VAR_2=0;VAR_2<VAR_0->nb_streams;VAR_2++) { av_free(VAR_0->streams[VAR_2]->priv_data); } return AVERROR(ENOMEM); }
[ "static int FUNC_0(AVFormatContext *VAR_0)\n{", "MpegMuxContext *s = VAR_0->priv_data;", "int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;", "AVStream *st;", "StreamInfo *stream;", "int VAR_10;", "int VAR_11;", "s->packet_number = 0;", "s->is_vcd = (CONFIG_MPEG1VCD_MUXER && VAR_0->oformat == &mpeg1vcd_muxer);", "s->is_svcd = (CONFIG_MPEG2SVCD_MUXER && VAR_0->oformat == &mpeg2svcd_muxer);", "s->is_mpeg2 = ((CONFIG_MPEG2VOB_MUXER && VAR_0->oformat == &mpeg2vob_muxer) ||\n(CONFIG_MPEG2DVD_MUXER && VAR_0->oformat == &mpeg2dvd_muxer) ||\n(CONFIG_MPEG2SVCD_MUXER && VAR_0->oformat == &mpeg2svcd_muxer));", "s->is_dvd = (CONFIG_MPEG2DVD_MUXER && VAR_0->oformat == &mpeg2dvd_muxer);", "if(VAR_0->packet_size)\ns->packet_size = VAR_0->packet_size;", "else\ns->packet_size = 2048;", "s->vcd_padding_bytes_written = 0;", "s->vcd_padding_bitrate=0;", "s->audio_bound = 0;", "s->video_bound = 0;", "VAR_3 = AUDIO_ID;", "VAR_6 = AC3_ID;", "VAR_7 = DTS_ID;", "VAR_4 = VIDEO_ID;", "VAR_5 = SUB_ID;", "VAR_8 = LPCM_ID;", "for(VAR_2=0;VAR_2<VAR_0->nb_streams;VAR_2++) {", "st = VAR_0->streams[VAR_2];", "stream = av_mallocz(sizeof(StreamInfo));", "if (!stream)\ngoto fail;", "st->priv_data = stream;", "av_set_pts_info(st, 64, 1, 90000);", "switch(st->codec->codec_type) {", "case CODEC_TYPE_AUDIO:\nif (st->codec->codec_id == CODEC_ID_AC3) {", "stream->id = VAR_6++;", "} else if (st->codec->codec_id == CODEC_ID_DTS) {", "stream->id = VAR_7++;", "} else if (st->codec->codec_id == CODEC_ID_PCM_S16BE) {", "stream->id = VAR_8++;", "for(VAR_9 = 0; VAR_9 < 4; VAR_9++) {", "if (lpcm_freq_tab[VAR_9] == st->codec->sample_rate)\nbreak;", "}", "if (VAR_9 == 4)\ngoto fail;", "if (st->codec->channels > 8)\nreturn -1;", "stream->lpcm_header[0] = 0x0c;", "stream->lpcm_header[1] = (st->codec->channels - 1) | (VAR_9 << 4);", "stream->lpcm_header[2] = 0x80;", "stream->lpcm_align = st->codec->channels * 2;", "} else {", "stream->id = VAR_3++;", "}", "stream->max_buffer_size = 4 * 1024;", "s->audio_bound++;", "break;", "case CODEC_TYPE_VIDEO:\nstream->id = VAR_4++;", "if (st->codec->rc_buffer_size)\nstream->max_buffer_size = 6*1024 + st->codec->rc_buffer_size/8;", "else\nstream->max_buffer_size = 230*1024;", "#if 0\nstream->max_buffer_size = 46 * 1024;", "else\nstream->max_buffer_size = 230 * 1024;", "#endif\ns->video_bound++;", "break;", "case CODEC_TYPE_SUBTITLE:\nstream->id = VAR_5++;", "stream->max_buffer_size = 16 * 1024;", "break;", "default:\nreturn -1;", "}", "stream->fifo= av_fifo_alloc(16);", "}", "VAR_1 = 0;", "VAR_10 = 0;", "VAR_11 = 0;", "for(VAR_2=0;VAR_2<VAR_0->nb_streams;VAR_2++) {", "int codec_rate;", "st = VAR_0->streams[VAR_2];", "stream = (StreamInfo*) st->priv_data;", "if(st->codec->rc_max_rate || stream->id==VIDEO_ID)\ncodec_rate= st->codec->rc_max_rate;", "else\ncodec_rate= st->codec->bit_rate;", "if(!codec_rate)\ncodec_rate= (1<<21)*8*50/VAR_0->nb_streams;", "VAR_1 += codec_rate;", "if (stream->id==AUDIO_ID)\nVAR_10 += codec_rate;", "else if (stream->id==VIDEO_ID)\nVAR_11 += codec_rate;", "}", "if(VAR_0->mux_rate){", "s->mux_rate= (VAR_0->mux_rate + (8 * 50) - 1) / (8 * 50);", "} else {", "VAR_1 += VAR_1*5/100;", "VAR_1 += 10000;", "s->mux_rate = (VAR_1 + (8 * 50) - 1) / (8 * 50);", "}", "if (s->is_vcd) {", "double VAR_12;", "VAR_12 = ((VAR_10 / 8.0) / 2279) * (2324 - 2279);", "VAR_12 += ((VAR_11 / 8.0) / 2294) * (2324 - 2294);", "VAR_12 *= 8;", "s->vcd_padding_bitrate = 2324 * 75 * 8 - (VAR_1 + VAR_12);", "}", "if (s->is_vcd || s->is_mpeg2)\ns->pack_header_freq = 1;", "else\ns->pack_header_freq = 2 * VAR_1 / s->packet_size / 8;", "if (s->pack_header_freq == 0)\ns->pack_header_freq = 1;", "if (s->is_mpeg2)\ns->system_header_freq = s->pack_header_freq * 40;", "else if (s->is_vcd)\ns->system_header_freq = 0x7fffffff;", "else\ns->system_header_freq = s->pack_header_freq * 5;", "for(VAR_2=0;VAR_2<VAR_0->nb_streams;VAR_2++) {", "stream = VAR_0->streams[VAR_2]->priv_data;", "stream->packet_number = 0;", "}", "s->system_header_size = get_system_header_size(VAR_0);", "s->last_scr = 0;", "return 0;", "fail:\nfor(VAR_2=0;VAR_2<VAR_0->nb_streams;VAR_2++) {", "av_free(VAR_0->streams[VAR_2]->priv_data);", "}", "return AVERROR(ENOMEM);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25, 27, 29 ], [ 31 ], [ 35, 37 ], [ 39, 41 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73, 75 ], [ 77 ], [ 81 ], [ 85 ], [ 87, 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103, 105 ], [ 107 ], [ 109, 111 ], [ 113, 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 137 ], [ 139 ], [ 141 ], [ 143, 145 ], [ 147, 149 ], [ 151, 153 ], [ 155, 159 ], [ 161, 167 ], [ 169, 171 ], [ 173 ], [ 175, 177 ], [ 179 ], [ 181 ], [ 183, 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 209, 211 ], [ 213, 215 ], [ 219, 221 ], [ 225 ], [ 229, 231 ], [ 233, 235 ], [ 237 ], [ 241 ], [ 243 ], [ 245 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 261 ], [ 263 ], [ 303 ], [ 305 ], [ 307 ], [ 313 ], [ 315 ], [ 319, 323 ], [ 325, 329 ], [ 335, 337 ], [ 341, 345 ], [ 347, 355 ], [ 357, 359 ], [ 363 ], [ 365 ], [ 367 ], [ 369 ], [ 371 ], [ 373 ], [ 375 ], [ 377, 379 ], [ 381 ], [ 383 ], [ 385 ], [ 387 ] ]
12,581
static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos, int *outFilterSize, int xInc, int srcW, int dstW, int filterAlign, int one, int flags, int cpu_flags, SwsVector *srcFilter, SwsVector *dstFilter, double param[2], int srcPos, int dstPos) { int i; int filterSize; int filter2Size; int minFilterSize; int64_t *filter = NULL; int64_t *filter2 = NULL; const int64_t fone = 1LL << (54 - FFMIN(av_log2(srcW/dstW), 8)); int ret = -1; emms_c(); // FIXME should not be required but IS (even for non-MMX versions) // NOTE: the +3 is for the MMX(+1) / SSE(+3) scaler which reads over the end FF_ALLOC_ARRAY_OR_GOTO(NULL, *filterPos, (dstW + 3), sizeof(**filterPos), fail); if (FFABS(xInc - 0x10000) < 10 && srcPos == dstPos) { // unscaled int i; filterSize = 1; FF_ALLOCZ_ARRAY_OR_GOTO(NULL, filter, dstW, sizeof(*filter) * filterSize, fail); for (i = 0; i < dstW; i++) { filter[i * filterSize] = fone; (*filterPos)[i] = i; } } else if (flags & SWS_POINT) { // lame looking point sampling mode int i; int64_t xDstInSrc; filterSize = 1; FF_ALLOC_ARRAY_OR_GOTO(NULL, filter, dstW, sizeof(*filter) * filterSize, fail); xDstInSrc = ((dstPos*(int64_t)xInc)>>8) - ((srcPos*0x8000LL)>>7); for (i = 0; i < dstW; i++) { int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16; (*filterPos)[i] = xx; filter[i] = fone; xDstInSrc += xInc; } } else if ((xInc <= (1 << 16) && (flags & SWS_AREA)) || (flags & SWS_FAST_BILINEAR)) { // bilinear upscale int i; int64_t xDstInSrc; filterSize = 2; FF_ALLOC_ARRAY_OR_GOTO(NULL, filter, dstW, sizeof(*filter) * filterSize, fail); xDstInSrc = ((dstPos*(int64_t)xInc)>>8) - ((srcPos*0x8000LL)>>7); for (i = 0; i < dstW; i++) { int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16; int j; (*filterPos)[i] = xx; // bilinear upscale / linear interpolate / area averaging for (j = 0; j < filterSize; j++) { int64_t coeff= fone - FFABS(((int64_t)xx<<16) - xDstInSrc)*(fone>>16); if (coeff < 0) coeff = 0; filter[i * filterSize + j] = coeff; xx++; } xDstInSrc += xInc; } } else { int64_t xDstInSrc; int sizeFactor = -1; for (i = 0; i < FF_ARRAY_ELEMS(scale_algorithms); i++) { if (flags & scale_algorithms[i].flag && scale_algorithms[i].size_factor > 0) { sizeFactor = scale_algorithms[i].size_factor; break; } } if (flags & SWS_LANCZOS) sizeFactor = param[0] != SWS_PARAM_DEFAULT ? ceil(2 * param[0]) : 6; av_assert0(sizeFactor > 0); if (xInc <= 1 << 16) filterSize = 1 + sizeFactor; // upscale else filterSize = 1 + (sizeFactor * srcW + dstW - 1) / dstW; filterSize = FFMIN(filterSize, srcW - 2); filterSize = FFMAX(filterSize, 1); FF_ALLOC_ARRAY_OR_GOTO(NULL, filter, dstW, sizeof(*filter) * filterSize, fail); xDstInSrc = ((dstPos*(int64_t)xInc)>>7) - ((srcPos*0x10000LL)>>7); for (i = 0; i < dstW; i++) { int xx = (xDstInSrc - ((int64_t)(filterSize - 2) << 16)) / (1 << 17); int j; (*filterPos)[i] = xx; for (j = 0; j < filterSize; j++) { int64_t d = (FFABS(((int64_t)xx << 17) - xDstInSrc)) << 13; double floatd; int64_t coeff; if (xInc > 1 << 16) d = d * dstW / srcW; floatd = d * (1.0 / (1 << 30)); if (flags & SWS_BICUBIC) { int64_t B = (param[0] != SWS_PARAM_DEFAULT ? param[0] : 0) * (1 << 24); int64_t C = (param[1] != SWS_PARAM_DEFAULT ? param[1] : 0.6) * (1 << 24); if (d >= 1LL << 31) { coeff = 0.0; } else { int64_t dd = (d * d) >> 30; int64_t ddd = (dd * d) >> 30; if (d < 1LL << 30) coeff = (12 * (1 << 24) - 9 * B - 6 * C) * ddd + (-18 * (1 << 24) + 12 * B + 6 * C) * dd + (6 * (1 << 24) - 2 * B) * (1 << 30); else coeff = (-B - 6 * C) * ddd + (6 * B + 30 * C) * dd + (-12 * B - 48 * C) * d + (8 * B + 24 * C) * (1 << 30); } coeff /= (1LL<<54)/fone; } #if 0 else if (flags & SWS_X) { double p = param ? param * 0.01 : 0.3; coeff = d ? sin(d * M_PI) / (d * M_PI) : 1.0; coeff *= pow(2.0, -p * d * d); } #endif else if (flags & SWS_X) { double A = param[0] != SWS_PARAM_DEFAULT ? param[0] : 1.0; double c; if (floatd < 1.0) c = cos(floatd * M_PI); else c = -1.0; if (c < 0.0) c = -pow(-c, A); else c = pow(c, A); coeff = (c * 0.5 + 0.5) * fone; } else if (flags & SWS_AREA) { int64_t d2 = d - (1 << 29); if (d2 * xInc < -(1LL << (29 + 16))) coeff = 1.0 * (1LL << (30 + 16)); else if (d2 * xInc < (1LL << (29 + 16))) coeff = -d2 * xInc + (1LL << (29 + 16)); else coeff = 0.0; coeff *= fone >> (30 + 16); } else if (flags & SWS_GAUSS) { double p = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0; coeff = (pow(2.0, -p * floatd * floatd)) * fone; } else if (flags & SWS_SINC) { coeff = (d ? sin(floatd * M_PI) / (floatd * M_PI) : 1.0) * fone; } else if (flags & SWS_LANCZOS) { double p = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0; coeff = (d ? sin(floatd * M_PI) * sin(floatd * M_PI / p) / (floatd * floatd * M_PI * M_PI / p) : 1.0) * fone; if (floatd > p) coeff = 0; } else if (flags & SWS_BILINEAR) { coeff = (1 << 30) - d; if (coeff < 0) coeff = 0; coeff *= fone >> 30; } else if (flags & SWS_SPLINE) { double p = -2.196152422706632; coeff = getSplineCoeff(1.0, 0.0, p, -p - 1.0, floatd) * fone; } else { av_assert0(0); } filter[i * filterSize + j] = coeff; xx++; } xDstInSrc += 2 * xInc; } } /* apply src & dst Filter to filter -> filter2 * av_free(filter); */ av_assert0(filterSize > 0); filter2Size = filterSize; if (srcFilter) filter2Size += srcFilter->length - 1; if (dstFilter) filter2Size += dstFilter->length - 1; av_assert0(filter2Size > 0); FF_ALLOCZ_ARRAY_OR_GOTO(NULL, filter2, dstW, filter2Size * sizeof(*filter2), fail); for (i = 0; i < dstW; i++) { int j, k; if (srcFilter) { for (k = 0; k < srcFilter->length; k++) { for (j = 0; j < filterSize; j++) filter2[i * filter2Size + k + j] += srcFilter->coeff[k] * filter[i * filterSize + j]; } } else { for (j = 0; j < filterSize; j++) filter2[i * filter2Size + j] = filter[i * filterSize + j]; } // FIXME dstFilter (*filterPos)[i] += (filterSize - 1) / 2 - (filter2Size - 1) / 2; } av_freep(&filter); /* try to reduce the filter-size (step1 find size and shift left) */ // Assume it is near normalized (*0.5 or *2.0 is OK but * 0.001 is not). minFilterSize = 0; for (i = dstW - 1; i >= 0; i--) { int min = filter2Size; int j; int64_t cutOff = 0.0; /* get rid of near zero elements on the left by shifting left */ for (j = 0; j < filter2Size; j++) { int k; cutOff += FFABS(filter2[i * filter2Size]); if (cutOff > SWS_MAX_REDUCE_CUTOFF * fone) break; /* preserve monotonicity because the core can't handle the * filter otherwise */ if (i < dstW - 1 && (*filterPos)[i] >= (*filterPos)[i + 1]) break; // move filter coefficients left for (k = 1; k < filter2Size; k++) filter2[i * filter2Size + k - 1] = filter2[i * filter2Size + k]; filter2[i * filter2Size + k - 1] = 0; (*filterPos)[i]++; } cutOff = 0; /* count near zeros on the right */ for (j = filter2Size - 1; j > 0; j--) { cutOff += FFABS(filter2[i * filter2Size + j]); if (cutOff > SWS_MAX_REDUCE_CUTOFF * fone) break; min--; } if (min > minFilterSize) minFilterSize = min; } if (PPC_ALTIVEC(cpu_flags)) { // we can handle the special case 4, so we don't want to go the full 8 if (minFilterSize < 5) filterAlign = 4; /* We really don't want to waste our time doing useless computation, so * fall back on the scalar C code for very small filters. * Vectorizing is worth it only if you have a decent-sized vector. */ if (minFilterSize < 3) filterAlign = 1; } if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) { // special case for unscaled vertical filtering if (minFilterSize == 1 && filterAlign == 2) filterAlign = 1; } av_assert0(minFilterSize > 0); filterSize = (minFilterSize + (filterAlign - 1)) & (~(filterAlign - 1)); av_assert0(filterSize > 0); filter = av_malloc_array(dstW, filterSize * sizeof(*filter)); if (!filter) goto fail; if (filterSize >= MAX_FILTER_SIZE * 16 / ((flags & SWS_ACCURATE_RND) ? APCK_SIZE : 16)) { ret = RETCODE_USE_CASCADE; goto fail; } *outFilterSize = filterSize; if (flags & SWS_PRINT_INFO) av_log(NULL, AV_LOG_VERBOSE, "SwScaler: reducing / aligning filtersize %d -> %d\n", filter2Size, filterSize); /* try to reduce the filter-size (step2 reduce it) */ for (i = 0; i < dstW; i++) { int j; for (j = 0; j < filterSize; j++) { if (j >= filter2Size) filter[i * filterSize + j] = 0; else filter[i * filterSize + j] = filter2[i * filter2Size + j]; if ((flags & SWS_BITEXACT) && j >= minFilterSize) filter[i * filterSize + j] = 0; } } // FIXME try to align filterPos if possible // fix borders for (i = 0; i < dstW; i++) { int j; if ((*filterPos)[i] < 0) { // move filter coefficients left to compensate for filterPos for (j = 1; j < filterSize; j++) { int left = FFMAX(j + (*filterPos)[i], 0); filter[i * filterSize + left] += filter[i * filterSize + j]; filter[i * filterSize + j] = 0; } (*filterPos)[i]= 0; } if ((*filterPos)[i] + filterSize > srcW) { int shift = (*filterPos)[i] + FFMIN(filterSize - srcW, 0); // move filter coefficients right to compensate for filterPos for (j = filterSize - 2; j >= 0; j--) { int right = FFMIN(j + shift, filterSize - 1); filter[i * filterSize + right] += filter[i * filterSize + j]; filter[i * filterSize + j] = 0; } (*filterPos)[i]-= shift; } } // Note the +1 is for the MMX scaler which reads over the end /* align at 16 for AltiVec (needed by hScale_altivec_real) */ FF_ALLOCZ_ARRAY_OR_GOTO(NULL, *outFilter, (dstW + 3), *outFilterSize * sizeof(int16_t), fail); /* normalize & store in outFilter */ for (i = 0; i < dstW; i++) { int j; int64_t error = 0; int64_t sum = 0; for (j = 0; j < filterSize; j++) { sum += filter[i * filterSize + j]; } sum = (sum + one / 2) / one; if (!sum) { av_log(NULL, AV_LOG_WARNING, "SwScaler: zero vector in scaling\n"); sum = 1; } for (j = 0; j < *outFilterSize; j++) { int64_t v = filter[i * filterSize + j] + error; int intV = ROUNDED_DIV(v, sum); (*outFilter)[i * (*outFilterSize) + j] = intV; error = v - intV * sum; } } (*filterPos)[dstW + 0] = (*filterPos)[dstW + 1] = (*filterPos)[dstW + 2] = (*filterPos)[dstW - 1]; /* the MMX/SSE scaler will * read over the end */ for (i = 0; i < *outFilterSize; i++) { int k = (dstW - 1) * (*outFilterSize) + i; (*outFilter)[k + 1 * (*outFilterSize)] = (*outFilter)[k + 2 * (*outFilterSize)] = (*outFilter)[k + 3 * (*outFilterSize)] = (*outFilter)[k]; } ret = 0; fail: if(ret < 0) av_log(NULL, ret == RETCODE_USE_CASCADE ? AV_LOG_DEBUG : AV_LOG_ERROR, "sws: initFilter failed\n"); av_free(filter); av_free(filter2); return ret; }
false
FFmpeg
1895d414aaacece3b57d7bf19502305e9a064fae
static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos, int *outFilterSize, int xInc, int srcW, int dstW, int filterAlign, int one, int flags, int cpu_flags, SwsVector *srcFilter, SwsVector *dstFilter, double param[2], int srcPos, int dstPos) { int i; int filterSize; int filter2Size; int minFilterSize; int64_t *filter = NULL; int64_t *filter2 = NULL; const int64_t fone = 1LL << (54 - FFMIN(av_log2(srcW/dstW), 8)); int ret = -1; emms_c(); FF_ALLOC_ARRAY_OR_GOTO(NULL, *filterPos, (dstW + 3), sizeof(**filterPos), fail); if (FFABS(xInc - 0x10000) < 10 && srcPos == dstPos) { int i; filterSize = 1; FF_ALLOCZ_ARRAY_OR_GOTO(NULL, filter, dstW, sizeof(*filter) * filterSize, fail); for (i = 0; i < dstW; i++) { filter[i * filterSize] = fone; (*filterPos)[i] = i; } } else if (flags & SWS_POINT) { int i; int64_t xDstInSrc; filterSize = 1; FF_ALLOC_ARRAY_OR_GOTO(NULL, filter, dstW, sizeof(*filter) * filterSize, fail); xDstInSrc = ((dstPos*(int64_t)xInc)>>8) - ((srcPos*0x8000LL)>>7); for (i = 0; i < dstW; i++) { int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16; (*filterPos)[i] = xx; filter[i] = fone; xDstInSrc += xInc; } } else if ((xInc <= (1 << 16) && (flags & SWS_AREA)) || (flags & SWS_FAST_BILINEAR)) { int i; int64_t xDstInSrc; filterSize = 2; FF_ALLOC_ARRAY_OR_GOTO(NULL, filter, dstW, sizeof(*filter) * filterSize, fail); xDstInSrc = ((dstPos*(int64_t)xInc)>>8) - ((srcPos*0x8000LL)>>7); for (i = 0; i < dstW; i++) { int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16; int j; (*filterPos)[i] = xx; / linear interpolate / area averaging for (j = 0; j < filterSize; j++) { int64_t coeff= fone - FFABS(((int64_t)xx<<16) - xDstInSrc)*(fone>>16); if (coeff < 0) coeff = 0; filter[i * filterSize + j] = coeff; xx++; } xDstInSrc += xInc; } } else { int64_t xDstInSrc; int sizeFactor = -1; for (i = 0; i < FF_ARRAY_ELEMS(scale_algorithms); i++) { if (flags & scale_algorithms[i].flag && scale_algorithms[i].size_factor > 0) { sizeFactor = scale_algorithms[i].size_factor; break; } } if (flags & SWS_LANCZOS) sizeFactor = param[0] != SWS_PARAM_DEFAULT ? ceil(2 * param[0]) : 6; av_assert0(sizeFactor > 0); if (xInc <= 1 << 16) filterSize = 1 + sizeFactor; else filterSize = 1 + (sizeFactor * srcW + dstW - 1) / dstW; filterSize = FFMIN(filterSize, srcW - 2); filterSize = FFMAX(filterSize, 1); FF_ALLOC_ARRAY_OR_GOTO(NULL, filter, dstW, sizeof(*filter) * filterSize, fail); xDstInSrc = ((dstPos*(int64_t)xInc)>>7) - ((srcPos*0x10000LL)>>7); for (i = 0; i < dstW; i++) { int xx = (xDstInSrc - ((int64_t)(filterSize - 2) << 16)) / (1 << 17); int j; (*filterPos)[i] = xx; for (j = 0; j < filterSize; j++) { int64_t d = (FFABS(((int64_t)xx << 17) - xDstInSrc)) << 13; double floatd; int64_t coeff; if (xInc > 1 << 16) d = d * dstW / srcW; floatd = d * (1.0 / (1 << 30)); if (flags & SWS_BICUBIC) { int64_t B = (param[0] != SWS_PARAM_DEFAULT ? param[0] : 0) * (1 << 24); int64_t C = (param[1] != SWS_PARAM_DEFAULT ? param[1] : 0.6) * (1 << 24); if (d >= 1LL << 31) { coeff = 0.0; } else { int64_t dd = (d * d) >> 30; int64_t ddd = (dd * d) >> 30; if (d < 1LL << 30) coeff = (12 * (1 << 24) - 9 * B - 6 * C) * ddd + (-18 * (1 << 24) + 12 * B + 6 * C) * dd + (6 * (1 << 24) - 2 * B) * (1 << 30); else coeff = (-B - 6 * C) * ddd + (6 * B + 30 * C) * dd + (-12 * B - 48 * C) * d + (8 * B + 24 * C) * (1 << 30); } coeff /= (1LL<<54)/fone; } #if 0 else if (flags & SWS_X) { double p = param ? param * 0.01 : 0.3; coeff = d ? sin(d * M_PI) / (d * M_PI) : 1.0; coeff *= pow(2.0, -p * d * d); } #endif else if (flags & SWS_X) { double A = param[0] != SWS_PARAM_DEFAULT ? param[0] : 1.0; double c; if (floatd < 1.0) c = cos(floatd * M_PI); else c = -1.0; if (c < 0.0) c = -pow(-c, A); else c = pow(c, A); coeff = (c * 0.5 + 0.5) * fone; } else if (flags & SWS_AREA) { int64_t d2 = d - (1 << 29); if (d2 * xInc < -(1LL << (29 + 16))) coeff = 1.0 * (1LL << (30 + 16)); else if (d2 * xInc < (1LL << (29 + 16))) coeff = -d2 * xInc + (1LL << (29 + 16)); else coeff = 0.0; coeff *= fone >> (30 + 16); } else if (flags & SWS_GAUSS) { double p = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0; coeff = (pow(2.0, -p * floatd * floatd)) * fone; } else if (flags & SWS_SINC) { coeff = (d ? sin(floatd * M_PI) / (floatd * M_PI) : 1.0) * fone; } else if (flags & SWS_LANCZOS) { double p = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0; coeff = (d ? sin(floatd * M_PI) * sin(floatd * M_PI / p) / (floatd * floatd * M_PI * M_PI / p) : 1.0) * fone; if (floatd > p) coeff = 0; } else if (flags & SWS_BILINEAR) { coeff = (1 << 30) - d; if (coeff < 0) coeff = 0; coeff *= fone >> 30; } else if (flags & SWS_SPLINE) { double p = -2.196152422706632; coeff = getSplineCoeff(1.0, 0.0, p, -p - 1.0, floatd) * fone; } else { av_assert0(0); } filter[i * filterSize + j] = coeff; xx++; } xDstInSrc += 2 * xInc; } } av_assert0(filterSize > 0); filter2Size = filterSize; if (srcFilter) filter2Size += srcFilter->length - 1; if (dstFilter) filter2Size += dstFilter->length - 1; av_assert0(filter2Size > 0); FF_ALLOCZ_ARRAY_OR_GOTO(NULL, filter2, dstW, filter2Size * sizeof(*filter2), fail); for (i = 0; i < dstW; i++) { int j, k; if (srcFilter) { for (k = 0; k < srcFilter->length; k++) { for (j = 0; j < filterSize; j++) filter2[i * filter2Size + k + j] += srcFilter->coeff[k] * filter[i * filterSize + j]; } } else { for (j = 0; j < filterSize; j++) filter2[i * filter2Size + j] = filter[i * filterSize + j]; } (*filterPos)[i] += (filterSize - 1) / 2 - (filter2Size - 1) / 2; } av_freep(&filter); minFilterSize = 0; for (i = dstW - 1; i >= 0; i--) { int min = filter2Size; int j; int64_t cutOff = 0.0; for (j = 0; j < filter2Size; j++) { int k; cutOff += FFABS(filter2[i * filter2Size]); if (cutOff > SWS_MAX_REDUCE_CUTOFF * fone) break; if (i < dstW - 1 && (*filterPos)[i] >= (*filterPos)[i + 1]) break; for (k = 1; k < filter2Size; k++) filter2[i * filter2Size + k - 1] = filter2[i * filter2Size + k]; filter2[i * filter2Size + k - 1] = 0; (*filterPos)[i]++; } cutOff = 0; for (j = filter2Size - 1; j > 0; j--) { cutOff += FFABS(filter2[i * filter2Size + j]); if (cutOff > SWS_MAX_REDUCE_CUTOFF * fone) break; min--; } if (min > minFilterSize) minFilterSize = min; } if (PPC_ALTIVEC(cpu_flags)) { if (minFilterSize < 5) filterAlign = 4; if (minFilterSize < 3) filterAlign = 1; } if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) { if (minFilterSize == 1 && filterAlign == 2) filterAlign = 1; } av_assert0(minFilterSize > 0); filterSize = (minFilterSize + (filterAlign - 1)) & (~(filterAlign - 1)); av_assert0(filterSize > 0); filter = av_malloc_array(dstW, filterSize * sizeof(*filter)); if (!filter) goto fail; if (filterSize >= MAX_FILTER_SIZE * 16 / ((flags & SWS_ACCURATE_RND) ? APCK_SIZE : 16)) { ret = RETCODE_USE_CASCADE; goto fail; } *outFilterSize = filterSize; if (flags & SWS_PRINT_INFO) av_log(NULL, AV_LOG_VERBOSE, "SwScaler: reducing / aligning filtersize %d -> %d\n", filter2Size, filterSize); for (i = 0; i < dstW; i++) { int j; for (j = 0; j < filterSize; j++) { if (j >= filter2Size) filter[i * filterSize + j] = 0; else filter[i * filterSize + j] = filter2[i * filter2Size + j]; if ((flags & SWS_BITEXACT) && j >= minFilterSize) filter[i * filterSize + j] = 0; } } for (i = 0; i < dstW; i++) { int j; if ((*filterPos)[i] < 0) { to compensate for filterPos for (j = 1; j < filterSize; j++) { int left = FFMAX(j + (*filterPos)[i], 0); filter[i * filterSize + left] += filter[i * filterSize + j]; filter[i * filterSize + j] = 0; } (*filterPos)[i]= 0; } if ((*filterPos)[i] + filterSize > srcW) { int shift = (*filterPos)[i] + FFMIN(filterSize - srcW, 0); for (j = filterSize - 2; j >= 0; j--) { int right = FFMIN(j + shift, filterSize - 1); filter[i * filterSize + right] += filter[i * filterSize + j]; filter[i * filterSize + j] = 0; } (*filterPos)[i]-= shift; } } FF_ALLOCZ_ARRAY_OR_GOTO(NULL, *outFilter, (dstW + 3), *outFilterSize * sizeof(int16_t), fail); for (i = 0; i < dstW; i++) { int j; int64_t error = 0; int64_t sum = 0; for (j = 0; j < filterSize; j++) { sum += filter[i * filterSize + j]; } sum = (sum + one / 2) / one; if (!sum) { av_log(NULL, AV_LOG_WARNING, "SwScaler: zero vector in scaling\n"); sum = 1; } for (j = 0; j < *outFilterSize; j++) { int64_t v = filter[i * filterSize + j] + error; int intV = ROUNDED_DIV(v, sum); (*outFilter)[i * (*outFilterSize) + j] = intV; error = v - intV * sum; } } (*filterPos)[dstW + 0] = (*filterPos)[dstW + 1] = (*filterPos)[dstW + 2] = (*filterPos)[dstW - 1]; for (i = 0; i < *outFilterSize; i++) { int k = (dstW - 1) * (*outFilterSize) + i; (*outFilter)[k + 1 * (*outFilterSize)] = (*outFilter)[k + 2 * (*outFilterSize)] = (*outFilter)[k + 3 * (*outFilterSize)] = (*outFilter)[k]; } ret = 0; fail: if(ret < 0) av_log(NULL, ret == RETCODE_USE_CASCADE ? AV_LOG_DEBUG : AV_LOG_ERROR, "sws: initFilter failed\n"); av_free(filter); av_free(filter2); return ret; }
{ "code": [], "line_no": [] }
static av_cold int FUNC_0(int16_t **outFilter, int32_t **filterPos, int *outFilterSize, int xInc, int srcW, int dstW, int filterAlign, int one, int flags, int cpu_flags, SwsVector *srcFilter, SwsVector *dstFilter, double param[2], int srcPos, int dstPos) { int VAR_7; int VAR_1; int VAR_2; int VAR_3; int64_t *filter = NULL; int64_t *filter2 = NULL; const int64_t VAR_4 = 1LL << (54 - FFMIN(av_log2(srcW/dstW), 8)); int VAR_5 = -1; emms_c(); FF_ALLOC_ARRAY_OR_GOTO(NULL, *filterPos, (dstW + 3), sizeof(**filterPos), fail); if (FFABS(xInc - 0x10000) < 10 && srcPos == dstPos) { int VAR_7; VAR_1 = 1; FF_ALLOCZ_ARRAY_OR_GOTO(NULL, filter, dstW, sizeof(*filter) * VAR_1, fail); for (VAR_7 = 0; VAR_7 < dstW; VAR_7++) { filter[VAR_7 * VAR_1] = VAR_4; (*filterPos)[VAR_7] = VAR_7; } } else if (flags & SWS_POINT) { int VAR_7; int64_t xDstInSrc; VAR_1 = 1; FF_ALLOC_ARRAY_OR_GOTO(NULL, filter, dstW, sizeof(*filter) * VAR_1, fail); xDstInSrc = ((dstPos*(int64_t)xInc)>>8) - ((srcPos*0x8000LL)>>7); for (VAR_7 = 0; VAR_7 < dstW; VAR_7++) { int VAR_9 = (xDstInSrc - ((VAR_1 - 1) << 15) + (1 << 15)) >> 16; (*filterPos)[VAR_7] = VAR_9; filter[VAR_7] = VAR_4; xDstInSrc += xInc; } } else if ((xInc <= (1 << 16) && (flags & SWS_AREA)) || (flags & SWS_FAST_BILINEAR)) { int VAR_7; int64_t xDstInSrc; VAR_1 = 2; FF_ALLOC_ARRAY_OR_GOTO(NULL, filter, dstW, sizeof(*filter) * VAR_1, fail); xDstInSrc = ((dstPos*(int64_t)xInc)>>8) - ((srcPos*0x8000LL)>>7); for (VAR_7 = 0; VAR_7 < dstW; VAR_7++) { int VAR_9 = (xDstInSrc - ((VAR_1 - 1) << 15) + (1 << 15)) >> 16; int VAR_17; (*filterPos)[VAR_7] = VAR_9; / linear interpolate / area averaging for (VAR_17 = 0; VAR_17 < VAR_1; VAR_17++) { int64_t coeff= VAR_4 - FFABS(((int64_t)VAR_9<<16) - xDstInSrc)*(VAR_4>>16); if (coeff < 0) coeff = 0; filter[VAR_7 * VAR_1 + VAR_17] = coeff; VAR_9++; } xDstInSrc += xInc; } } else { int64_t xDstInSrc; int VAR_8 = -1; for (VAR_7 = 0; VAR_7 < FF_ARRAY_ELEMS(scale_algorithms); VAR_7++) { if (flags & scale_algorithms[VAR_7].flag && scale_algorithms[VAR_7].size_factor > 0) { VAR_8 = scale_algorithms[VAR_7].size_factor; break; } } if (flags & SWS_LANCZOS) VAR_8 = param[0] != SWS_PARAM_DEFAULT ? ceil(2 * param[0]) : 6; av_assert0(VAR_8 > 0); if (xInc <= 1 << 16) VAR_1 = 1 + VAR_8; else VAR_1 = 1 + (VAR_8 * srcW + dstW - 1) / dstW; VAR_1 = FFMIN(VAR_1, srcW - 2); VAR_1 = FFMAX(VAR_1, 1); FF_ALLOC_ARRAY_OR_GOTO(NULL, filter, dstW, sizeof(*filter) * VAR_1, fail); xDstInSrc = ((dstPos*(int64_t)xInc)>>7) - ((srcPos*0x10000LL)>>7); for (VAR_7 = 0; VAR_7 < dstW; VAR_7++) { int VAR_9 = (xDstInSrc - ((int64_t)(VAR_1 - 2) << 16)) / (1 << 17); int VAR_17; (*filterPos)[VAR_7] = VAR_9; for (VAR_17 = 0; VAR_17 < VAR_1; VAR_17++) { int64_t d = (FFABS(((int64_t)VAR_9 << 17) - xDstInSrc)) << 13; double VAR_9; int64_t coeff; if (xInc > 1 << 16) d = d * dstW / srcW; VAR_9 = d * (1.0 / (1 << 30)); if (flags & SWS_BICUBIC) { int64_t B = (param[0] != SWS_PARAM_DEFAULT ? param[0] : 0) * (1 << 24); int64_t C = (param[1] != SWS_PARAM_DEFAULT ? param[1] : 0.6) * (1 << 24); if (d >= 1LL << 31) { coeff = 0.0; } else { int64_t dd = (d * d) >> 30; int64_t ddd = (dd * d) >> 30; if (d < 1LL << 30) coeff = (12 * (1 << 24) - 9 * B - 6 * C) * ddd + (-18 * (1 << 24) + 12 * B + 6 * C) * dd + (6 * (1 << 24) - 2 * B) * (1 << 30); else coeff = (-B - 6 * C) * ddd + (6 * B + 30 * C) * dd + (-12 * B - 48 * C) * d + (8 * B + 24 * C) * (1 << 30); } coeff /= (1LL<<54)/VAR_4; } #if 0 else if (flags & SWS_X) { double VAR_13 = param ? param * 0.01 : 0.3; coeff = d ? sin(d * M_PI) / (d * M_PI) : 1.0; coeff *= pow(2.0, -VAR_13 * d * d); } #endif else if (flags & SWS_X) { double VAR_10 = param[0] != SWS_PARAM_DEFAULT ? param[0] : 1.0; double VAR_11; if (VAR_9 < 1.0) VAR_11 = cos(VAR_9 * M_PI); else VAR_11 = -1.0; if (VAR_11 < 0.0) VAR_11 = -pow(-VAR_11, VAR_10); else VAR_11 = pow(VAR_11, VAR_10); coeff = (VAR_11 * 0.5 + 0.5) * VAR_4; } else if (flags & SWS_AREA) { int64_t d2 = d - (1 << 29); if (d2 * xInc < -(1LL << (29 + 16))) coeff = 1.0 * (1LL << (30 + 16)); else if (d2 * xInc < (1LL << (29 + 16))) coeff = -d2 * xInc + (1LL << (29 + 16)); else coeff = 0.0; coeff *= VAR_4 >> (30 + 16); } else if (flags & SWS_GAUSS) { double VAR_13 = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0; coeff = (pow(2.0, -VAR_13 * VAR_9 * VAR_9)) * VAR_4; } else if (flags & SWS_SINC) { coeff = (d ? sin(VAR_9 * M_PI) / (VAR_9 * M_PI) : 1.0) * VAR_4; } else if (flags & SWS_LANCZOS) { double VAR_13 = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0; coeff = (d ? sin(VAR_9 * M_PI) * sin(VAR_9 * M_PI / VAR_13) / (VAR_9 * VAR_9 * M_PI * M_PI / VAR_13) : 1.0) * VAR_4; if (VAR_9 > VAR_13) coeff = 0; } else if (flags & SWS_BILINEAR) { coeff = (1 << 30) - d; if (coeff < 0) coeff = 0; coeff *= VAR_4 >> 30; } else if (flags & SWS_SPLINE) { double VAR_13 = -2.196152422706632; coeff = getSplineCoeff(1.0, 0.0, VAR_13, -VAR_13 - 1.0, VAR_9) * VAR_4; } else { av_assert0(0); } filter[VAR_7 * VAR_1 + VAR_17] = coeff; VAR_9++; } xDstInSrc += 2 * xInc; } } av_assert0(VAR_1 > 0); VAR_2 = VAR_1; if (srcFilter) VAR_2 += srcFilter->length - 1; if (dstFilter) VAR_2 += dstFilter->length - 1; av_assert0(VAR_2 > 0); FF_ALLOCZ_ARRAY_OR_GOTO(NULL, filter2, dstW, VAR_2 * sizeof(*filter2), fail); for (VAR_7 = 0; VAR_7 < dstW; VAR_7++) { int VAR_17, VAR_18; if (srcFilter) { for (VAR_18 = 0; VAR_18 < srcFilter->length; VAR_18++) { for (VAR_17 = 0; VAR_17 < VAR_1; VAR_17++) filter2[VAR_7 * VAR_2 + VAR_18 + VAR_17] += srcFilter->coeff[VAR_18] * filter[VAR_7 * VAR_1 + VAR_17]; } } else { for (VAR_17 = 0; VAR_17 < VAR_1; VAR_17++) filter2[VAR_7 * VAR_2 + VAR_17] = filter[VAR_7 * VAR_1 + VAR_17]; } (*filterPos)[VAR_7] += (VAR_1 - 1) / 2 - (VAR_2 - 1) / 2; } av_freep(&filter); VAR_3 = 0; for (VAR_7 = dstW - 1; VAR_7 >= 0; VAR_7--) { int VAR_14 = VAR_2; int VAR_17; int64_t cutOff = 0.0; for (VAR_17 = 0; VAR_17 < VAR_2; VAR_17++) { int VAR_18; cutOff += FFABS(filter2[VAR_7 * VAR_2]); if (cutOff > SWS_MAX_REDUCE_CUTOFF * VAR_4) break; if (VAR_7 < dstW - 1 && (*filterPos)[VAR_7] >= (*filterPos)[VAR_7 + 1]) break; for (VAR_18 = 1; VAR_18 < VAR_2; VAR_18++) filter2[VAR_7 * VAR_2 + VAR_18 - 1] = filter2[VAR_7 * VAR_2 + VAR_18]; filter2[VAR_7 * VAR_2 + VAR_18 - 1] = 0; (*filterPos)[VAR_7]++; } cutOff = 0; for (VAR_17 = VAR_2 - 1; VAR_17 > 0; VAR_17--) { cutOff += FFABS(filter2[VAR_7 * VAR_2 + VAR_17]); if (cutOff > SWS_MAX_REDUCE_CUTOFF * VAR_4) break; VAR_14--; } if (VAR_14 > VAR_3) VAR_3 = VAR_14; } if (PPC_ALTIVEC(cpu_flags)) { if (VAR_3 < 5) filterAlign = 4; if (VAR_3 < 3) filterAlign = 1; } if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) { if (VAR_3 == 1 && filterAlign == 2) filterAlign = 1; } av_assert0(VAR_3 > 0); VAR_1 = (VAR_3 + (filterAlign - 1)) & (~(filterAlign - 1)); av_assert0(VAR_1 > 0); filter = av_malloc_array(dstW, VAR_1 * sizeof(*filter)); if (!filter) goto fail; if (VAR_1 >= MAX_FILTER_SIZE * 16 / ((flags & SWS_ACCURATE_RND) ? APCK_SIZE : 16)) { VAR_5 = RETCODE_USE_CASCADE; goto fail; } *outFilterSize = VAR_1; if (flags & SWS_PRINT_INFO) av_log(NULL, AV_LOG_VERBOSE, "SwScaler: reducing / aligning filtersize %d -> %d\n", VAR_2, VAR_1); for (VAR_7 = 0; VAR_7 < dstW; VAR_7++) { int VAR_17; for (VAR_17 = 0; VAR_17 < VAR_1; VAR_17++) { if (VAR_17 >= VAR_2) filter[VAR_7 * VAR_1 + VAR_17] = 0; else filter[VAR_7 * VAR_1 + VAR_17] = filter2[VAR_7 * VAR_2 + VAR_17]; if ((flags & SWS_BITEXACT) && VAR_17 >= VAR_3) filter[VAR_7 * VAR_1 + VAR_17] = 0; } } for (VAR_7 = 0; VAR_7 < dstW; VAR_7++) { int VAR_17; if ((*filterPos)[VAR_7] < 0) { to compensate for filterPos for (VAR_17 = 1; VAR_17 < VAR_1; VAR_17++) { int left = FFMAX(VAR_17 + (*filterPos)[VAR_7], 0); filter[VAR_7 * VAR_1 + left] += filter[VAR_7 * VAR_1 + VAR_17]; filter[VAR_7 * VAR_1 + VAR_17] = 0; } (*filterPos)[VAR_7]= 0; } if ((*filterPos)[VAR_7] + VAR_1 > srcW) { int VAR_15 = (*filterPos)[VAR_7] + FFMIN(VAR_1 - srcW, 0); for (VAR_17 = VAR_1 - 2; VAR_17 >= 0; VAR_17--) { int VAR_16 = FFMIN(VAR_17 + VAR_15, VAR_1 - 1); filter[VAR_7 * VAR_1 + VAR_16] += filter[VAR_7 * VAR_1 + VAR_17]; filter[VAR_7 * VAR_1 + VAR_17] = 0; } (*filterPos)[VAR_7]-= VAR_15; } } FF_ALLOCZ_ARRAY_OR_GOTO(NULL, *outFilter, (dstW + 3), *outFilterSize * sizeof(int16_t), fail); for (VAR_7 = 0; VAR_7 < dstW; VAR_7++) { int VAR_17; int64_t error = 0; int64_t sum = 0; for (VAR_17 = 0; VAR_17 < VAR_1; VAR_17++) { sum += filter[VAR_7 * VAR_1 + VAR_17]; } sum = (sum + one / 2) / one; if (!sum) { av_log(NULL, AV_LOG_WARNING, "SwScaler: zero vector in scaling\n"); sum = 1; } for (VAR_17 = 0; VAR_17 < *outFilterSize; VAR_17++) { int64_t v = filter[VAR_7 * VAR_1 + VAR_17] + error; int VAR_17 = ROUNDED_DIV(v, sum); (*outFilter)[VAR_7 * (*outFilterSize) + VAR_17] = VAR_17; error = v - VAR_17 * sum; } } (*filterPos)[dstW + 0] = (*filterPos)[dstW + 1] = (*filterPos)[dstW + 2] = (*filterPos)[dstW - 1]; for (VAR_7 = 0; VAR_7 < *outFilterSize; VAR_7++) { int VAR_18 = (dstW - 1) * (*outFilterSize) + VAR_7; (*outFilter)[VAR_18 + 1 * (*outFilterSize)] = (*outFilter)[VAR_18 + 2 * (*outFilterSize)] = (*outFilter)[VAR_18 + 3 * (*outFilterSize)] = (*outFilter)[VAR_18]; } VAR_5 = 0; fail: if(VAR_5 < 0) av_log(NULL, VAR_5 == RETCODE_USE_CASCADE ? AV_LOG_DEBUG : AV_LOG_ERROR, "sws: FUNC_0 failed\n"); av_free(filter); av_free(filter2); return VAR_5; }
[ "static av_cold int FUNC_0(int16_t **outFilter, int32_t **filterPos,\nint *outFilterSize, int xInc, int srcW,\nint dstW, int filterAlign, int one,\nint flags, int cpu_flags,\nSwsVector *srcFilter, SwsVector *dstFilter,\ndouble param[2], int srcPos, int dstPos)\n{", "int VAR_7;", "int VAR_1;", "int VAR_2;", "int VAR_3;", "int64_t *filter = NULL;", "int64_t *filter2 = NULL;", "const int64_t VAR_4 = 1LL << (54 - FFMIN(av_log2(srcW/dstW), 8));", "int VAR_5 = -1;", "emms_c();", "FF_ALLOC_ARRAY_OR_GOTO(NULL, *filterPos, (dstW + 3), sizeof(**filterPos), fail);", "if (FFABS(xInc - 0x10000) < 10 && srcPos == dstPos) {", "int VAR_7;", "VAR_1 = 1;", "FF_ALLOCZ_ARRAY_OR_GOTO(NULL, filter,\ndstW, sizeof(*filter) * VAR_1, fail);", "for (VAR_7 = 0; VAR_7 < dstW; VAR_7++) {", "filter[VAR_7 * VAR_1] = VAR_4;", "(*filterPos)[VAR_7] = VAR_7;", "}", "} else if (flags & SWS_POINT) {", "int VAR_7;", "int64_t xDstInSrc;", "VAR_1 = 1;", "FF_ALLOC_ARRAY_OR_GOTO(NULL, filter,\ndstW, sizeof(*filter) * VAR_1, fail);", "xDstInSrc = ((dstPos*(int64_t)xInc)>>8) - ((srcPos*0x8000LL)>>7);", "for (VAR_7 = 0; VAR_7 < dstW; VAR_7++) {", "int VAR_9 = (xDstInSrc - ((VAR_1 - 1) << 15) + (1 << 15)) >> 16;", "(*filterPos)[VAR_7] = VAR_9;", "filter[VAR_7] = VAR_4;", "xDstInSrc += xInc;", "}", "} else if ((xInc <= (1 << 16) && (flags & SWS_AREA)) ||", "(flags & SWS_FAST_BILINEAR)) {", "int VAR_7;", "int64_t xDstInSrc;", "VAR_1 = 2;", "FF_ALLOC_ARRAY_OR_GOTO(NULL, filter,\ndstW, sizeof(*filter) * VAR_1, fail);", "xDstInSrc = ((dstPos*(int64_t)xInc)>>8) - ((srcPos*0x8000LL)>>7);", "for (VAR_7 = 0; VAR_7 < dstW; VAR_7++) {", "int VAR_9 = (xDstInSrc - ((VAR_1 - 1) << 15) + (1 << 15)) >> 16;", "int VAR_17;", "(*filterPos)[VAR_7] = VAR_9;", "/ linear interpolate / area averaging\nfor (VAR_17 = 0; VAR_17 < VAR_1; VAR_17++) {", "int64_t coeff= VAR_4 - FFABS(((int64_t)VAR_9<<16) - xDstInSrc)*(VAR_4>>16);", "if (coeff < 0)\ncoeff = 0;", "filter[VAR_7 * VAR_1 + VAR_17] = coeff;", "VAR_9++;", "}", "xDstInSrc += xInc;", "}", "} else {", "int64_t xDstInSrc;", "int VAR_8 = -1;", "for (VAR_7 = 0; VAR_7 < FF_ARRAY_ELEMS(scale_algorithms); VAR_7++) {", "if (flags & scale_algorithms[VAR_7].flag && scale_algorithms[VAR_7].size_factor > 0) {", "VAR_8 = scale_algorithms[VAR_7].size_factor;", "break;", "}", "}", "if (flags & SWS_LANCZOS)\nVAR_8 = param[0] != SWS_PARAM_DEFAULT ? ceil(2 * param[0]) : 6;", "av_assert0(VAR_8 > 0);", "if (xInc <= 1 << 16)\nVAR_1 = 1 + VAR_8;", "else\nVAR_1 = 1 + (VAR_8 * srcW + dstW - 1) / dstW;", "VAR_1 = FFMIN(VAR_1, srcW - 2);", "VAR_1 = FFMAX(VAR_1, 1);", "FF_ALLOC_ARRAY_OR_GOTO(NULL, filter,\ndstW, sizeof(*filter) * VAR_1, fail);", "xDstInSrc = ((dstPos*(int64_t)xInc)>>7) - ((srcPos*0x10000LL)>>7);", "for (VAR_7 = 0; VAR_7 < dstW; VAR_7++) {", "int VAR_9 = (xDstInSrc - ((int64_t)(VAR_1 - 2) << 16)) / (1 << 17);", "int VAR_17;", "(*filterPos)[VAR_7] = VAR_9;", "for (VAR_17 = 0; VAR_17 < VAR_1; VAR_17++) {", "int64_t d = (FFABS(((int64_t)VAR_9 << 17) - xDstInSrc)) << 13;", "double VAR_9;", "int64_t coeff;", "if (xInc > 1 << 16)\nd = d * dstW / srcW;", "VAR_9 = d * (1.0 / (1 << 30));", "if (flags & SWS_BICUBIC) {", "int64_t B = (param[0] != SWS_PARAM_DEFAULT ? param[0] : 0) * (1 << 24);", "int64_t C = (param[1] != SWS_PARAM_DEFAULT ? param[1] : 0.6) * (1 << 24);", "if (d >= 1LL << 31) {", "coeff = 0.0;", "} else {", "int64_t dd = (d * d) >> 30;", "int64_t ddd = (dd * d) >> 30;", "if (d < 1LL << 30)\ncoeff = (12 * (1 << 24) - 9 * B - 6 * C) * ddd +\n(-18 * (1 << 24) + 12 * B + 6 * C) * dd +\n(6 * (1 << 24) - 2 * B) * (1 << 30);", "else\ncoeff = (-B - 6 * C) * ddd +\n(6 * B + 30 * C) * dd +\n(-12 * B - 48 * C) * d +\n(8 * B + 24 * C) * (1 << 30);", "}", "coeff /= (1LL<<54)/VAR_4;", "}", "#if 0\nelse if (flags & SWS_X) {", "double VAR_13 = param ? param * 0.01 : 0.3;", "coeff = d ? sin(d * M_PI) / (d * M_PI) : 1.0;", "coeff *= pow(2.0, -VAR_13 * d * d);", "}", "#endif\nelse if (flags & SWS_X) {", "double VAR_10 = param[0] != SWS_PARAM_DEFAULT ? param[0] : 1.0;", "double VAR_11;", "if (VAR_9 < 1.0)\nVAR_11 = cos(VAR_9 * M_PI);", "else\nVAR_11 = -1.0;", "if (VAR_11 < 0.0)\nVAR_11 = -pow(-VAR_11, VAR_10);", "else\nVAR_11 = pow(VAR_11, VAR_10);", "coeff = (VAR_11 * 0.5 + 0.5) * VAR_4;", "} else if (flags & SWS_AREA) {", "int64_t d2 = d - (1 << 29);", "if (d2 * xInc < -(1LL << (29 + 16)))\ncoeff = 1.0 * (1LL << (30 + 16));", "else if (d2 * xInc < (1LL << (29 + 16)))\ncoeff = -d2 * xInc + (1LL << (29 + 16));", "else\ncoeff = 0.0;", "coeff *= VAR_4 >> (30 + 16);", "} else if (flags & SWS_GAUSS) {", "double VAR_13 = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0;", "coeff = (pow(2.0, -VAR_13 * VAR_9 * VAR_9)) * VAR_4;", "} else if (flags & SWS_SINC) {", "coeff = (d ? sin(VAR_9 * M_PI) / (VAR_9 * M_PI) : 1.0) * VAR_4;", "} else if (flags & SWS_LANCZOS) {", "double VAR_13 = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0;", "coeff = (d ? sin(VAR_9 * M_PI) * sin(VAR_9 * M_PI / VAR_13) /\n(VAR_9 * VAR_9 * M_PI * M_PI / VAR_13) : 1.0) * VAR_4;", "if (VAR_9 > VAR_13)\ncoeff = 0;", "} else if (flags & SWS_BILINEAR) {", "coeff = (1 << 30) - d;", "if (coeff < 0)\ncoeff = 0;", "coeff *= VAR_4 >> 30;", "} else if (flags & SWS_SPLINE) {", "double VAR_13 = -2.196152422706632;", "coeff = getSplineCoeff(1.0, 0.0, VAR_13, -VAR_13 - 1.0, VAR_9) * VAR_4;", "} else {", "av_assert0(0);", "}", "filter[VAR_7 * VAR_1 + VAR_17] = coeff;", "VAR_9++;", "}", "xDstInSrc += 2 * xInc;", "}", "}", "av_assert0(VAR_1 > 0);", "VAR_2 = VAR_1;", "if (srcFilter)\nVAR_2 += srcFilter->length - 1;", "if (dstFilter)\nVAR_2 += dstFilter->length - 1;", "av_assert0(VAR_2 > 0);", "FF_ALLOCZ_ARRAY_OR_GOTO(NULL, filter2, dstW, VAR_2 * sizeof(*filter2), fail);", "for (VAR_7 = 0; VAR_7 < dstW; VAR_7++) {", "int VAR_17, VAR_18;", "if (srcFilter) {", "for (VAR_18 = 0; VAR_18 < srcFilter->length; VAR_18++) {", "for (VAR_17 = 0; VAR_17 < VAR_1; VAR_17++)", "filter2[VAR_7 * VAR_2 + VAR_18 + VAR_17] +=\nsrcFilter->coeff[VAR_18] * filter[VAR_7 * VAR_1 + VAR_17];", "}", "} else {", "for (VAR_17 = 0; VAR_17 < VAR_1; VAR_17++)", "filter2[VAR_7 * VAR_2 + VAR_17] = filter[VAR_7 * VAR_1 + VAR_17];", "}", "(*filterPos)[VAR_7] += (VAR_1 - 1) / 2 - (VAR_2 - 1) / 2;", "}", "av_freep(&filter);", "VAR_3 = 0;", "for (VAR_7 = dstW - 1; VAR_7 >= 0; VAR_7--) {", "int VAR_14 = VAR_2;", "int VAR_17;", "int64_t cutOff = 0.0;", "for (VAR_17 = 0; VAR_17 < VAR_2; VAR_17++) {", "int VAR_18;", "cutOff += FFABS(filter2[VAR_7 * VAR_2]);", "if (cutOff > SWS_MAX_REDUCE_CUTOFF * VAR_4)\nbreak;", "if (VAR_7 < dstW - 1 && (*filterPos)[VAR_7] >= (*filterPos)[VAR_7 + 1])\nbreak;", "for (VAR_18 = 1; VAR_18 < VAR_2; VAR_18++)", "filter2[VAR_7 * VAR_2 + VAR_18 - 1] = filter2[VAR_7 * VAR_2 + VAR_18];", "filter2[VAR_7 * VAR_2 + VAR_18 - 1] = 0;", "(*filterPos)[VAR_7]++;", "}", "cutOff = 0;", "for (VAR_17 = VAR_2 - 1; VAR_17 > 0; VAR_17--) {", "cutOff += FFABS(filter2[VAR_7 * VAR_2 + VAR_17]);", "if (cutOff > SWS_MAX_REDUCE_CUTOFF * VAR_4)\nbreak;", "VAR_14--;", "}", "if (VAR_14 > VAR_3)\nVAR_3 = VAR_14;", "}", "if (PPC_ALTIVEC(cpu_flags)) {", "if (VAR_3 < 5)\nfilterAlign = 4;", "if (VAR_3 < 3)\nfilterAlign = 1;", "}", "if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) {", "if (VAR_3 == 1 && filterAlign == 2)\nfilterAlign = 1;", "}", "av_assert0(VAR_3 > 0);", "VAR_1 = (VAR_3 + (filterAlign - 1)) & (~(filterAlign - 1));", "av_assert0(VAR_1 > 0);", "filter = av_malloc_array(dstW, VAR_1 * sizeof(*filter));", "if (!filter)\ngoto fail;", "if (VAR_1 >= MAX_FILTER_SIZE * 16 /\n((flags & SWS_ACCURATE_RND) ? APCK_SIZE : 16)) {", "VAR_5 = RETCODE_USE_CASCADE;", "goto fail;", "}", "*outFilterSize = VAR_1;", "if (flags & SWS_PRINT_INFO)\nav_log(NULL, AV_LOG_VERBOSE,\n\"SwScaler: reducing / aligning filtersize %d -> %d\\n\",\nVAR_2, VAR_1);", "for (VAR_7 = 0; VAR_7 < dstW; VAR_7++) {", "int VAR_17;", "for (VAR_17 = 0; VAR_17 < VAR_1; VAR_17++) {", "if (VAR_17 >= VAR_2)\nfilter[VAR_7 * VAR_1 + VAR_17] = 0;", "else\nfilter[VAR_7 * VAR_1 + VAR_17] = filter2[VAR_7 * VAR_2 + VAR_17];", "if ((flags & SWS_BITEXACT) && VAR_17 >= VAR_3)\nfilter[VAR_7 * VAR_1 + VAR_17] = 0;", "}", "}", "for (VAR_7 = 0; VAR_7 < dstW; VAR_7++) {", "int VAR_17;", "if ((*filterPos)[VAR_7] < 0) {", "to compensate for filterPos\nfor (VAR_17 = 1; VAR_17 < VAR_1; VAR_17++) {", "int left = FFMAX(VAR_17 + (*filterPos)[VAR_7], 0);", "filter[VAR_7 * VAR_1 + left] += filter[VAR_7 * VAR_1 + VAR_17];", "filter[VAR_7 * VAR_1 + VAR_17] = 0;", "}", "(*filterPos)[VAR_7]= 0;", "}", "if ((*filterPos)[VAR_7] + VAR_1 > srcW) {", "int VAR_15 = (*filterPos)[VAR_7] + FFMIN(VAR_1 - srcW, 0);", "for (VAR_17 = VAR_1 - 2; VAR_17 >= 0; VAR_17--) {", "int VAR_16 = FFMIN(VAR_17 + VAR_15, VAR_1 - 1);", "filter[VAR_7 * VAR_1 + VAR_16] += filter[VAR_7 * VAR_1 + VAR_17];", "filter[VAR_7 * VAR_1 + VAR_17] = 0;", "}", "(*filterPos)[VAR_7]-= VAR_15;", "}", "}", "FF_ALLOCZ_ARRAY_OR_GOTO(NULL, *outFilter,\n(dstW + 3), *outFilterSize * sizeof(int16_t), fail);", "for (VAR_7 = 0; VAR_7 < dstW; VAR_7++) {", "int VAR_17;", "int64_t error = 0;", "int64_t sum = 0;", "for (VAR_17 = 0; VAR_17 < VAR_1; VAR_17++) {", "sum += filter[VAR_7 * VAR_1 + VAR_17];", "}", "sum = (sum + one / 2) / one;", "if (!sum) {", "av_log(NULL, AV_LOG_WARNING, \"SwScaler: zero vector in scaling\\n\");", "sum = 1;", "}", "for (VAR_17 = 0; VAR_17 < *outFilterSize; VAR_17++) {", "int64_t v = filter[VAR_7 * VAR_1 + VAR_17] + error;", "int VAR_17 = ROUNDED_DIV(v, sum);", "(*outFilter)[VAR_7 * (*outFilterSize) + VAR_17] = VAR_17;", "error = v - VAR_17 * sum;", "}", "}", "(*filterPos)[dstW + 0] =\n(*filterPos)[dstW + 1] =\n(*filterPos)[dstW + 2] = (*filterPos)[dstW - 1];", "for (VAR_7 = 0; VAR_7 < *outFilterSize; VAR_7++) {", "int VAR_18 = (dstW - 1) * (*outFilterSize) + VAR_7;", "(*outFilter)[VAR_18 + 1 * (*outFilterSize)] =\n(*outFilter)[VAR_18 + 2 * (*outFilterSize)] =\n(*outFilter)[VAR_18 + 3 * (*outFilterSize)] = (*outFilter)[VAR_18];", "}", "VAR_5 = 0;", "fail:\nif(VAR_5 < 0)\nav_log(NULL, VAR_5 == RETCODE_USE_CASCADE ? AV_LOG_DEBUG : AV_LOG_ERROR, \"sws: FUNC_0 failed\\n\");", "av_free(filter);", "av_free(filter2);", "return VAR_5;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 33 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49, 51 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71, 73 ], [ 77 ], [ 79 ], [ 81 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103, 105 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 119 ], [ 121, 123 ], [ 125 ], [ 127, 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161, 163 ], [ 165 ], [ 169, 171 ], [ 173, 175 ], [ 179 ], [ 181 ], [ 185, 187 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 211, 213 ], [ 215 ], [ 219 ], [ 221 ], [ 223 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 239, 241, 243, 245 ], [ 247, 249, 251, 253, 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263, 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275, 277 ], [ 279 ], [ 281 ], [ 285, 287 ], [ 289, 291 ], [ 293, 295 ], [ 297, 299 ], [ 301 ], [ 303 ], [ 305 ], [ 307, 309 ], [ 311, 313 ], [ 315, 317 ], [ 319 ], [ 321 ], [ 323 ], [ 325 ], [ 327 ], [ 329 ], [ 331 ], [ 333 ], [ 335, 337 ], [ 339, 341 ], [ 343 ], [ 345 ], [ 347, 349 ], [ 351 ], [ 353 ], [ 355 ], [ 357 ], [ 359 ], [ 361 ], [ 363 ], [ 367 ], [ 369 ], [ 371 ], [ 373 ], [ 375 ], [ 377 ], [ 387 ], [ 389 ], [ 391, 393 ], [ 395, 397 ], [ 399 ], [ 401 ], [ 405 ], [ 407 ], [ 411 ], [ 413 ], [ 415 ], [ 417, 419 ], [ 421 ], [ 423 ], [ 425 ], [ 427 ], [ 429 ], [ 435 ], [ 437 ], [ 439 ], [ 447 ], [ 449 ], [ 451 ], [ 453 ], [ 455 ], [ 461 ], [ 463 ], [ 465 ], [ 469, 471 ], [ 479, 481 ], [ 487 ], [ 489 ], [ 491 ], [ 493 ], [ 495 ], [ 499 ], [ 503 ], [ 505 ], [ 509, 511 ], [ 513 ], [ 515 ], [ 519, 521 ], [ 523 ], [ 527 ], [ 531, 533 ], [ 543, 545 ], [ 547 ], [ 551 ], [ 555, 557 ], [ 559 ], [ 563 ], [ 565 ], [ 567 ], [ 569 ], [ 571, 573 ], [ 575, 577 ], [ 579 ], [ 581 ], [ 583 ], [ 585 ], [ 589, 591, 593, 595 ], [ 599 ], [ 601 ], [ 605 ], [ 607, 609 ], [ 611, 613 ], [ 615, 617 ], [ 619 ], [ 621 ], [ 631 ], [ 633 ], [ 635 ], [ 637, 639 ], [ 641 ], [ 643 ], [ 645 ], [ 647 ], [ 649 ], [ 651 ], [ 655 ], [ 657 ], [ 663 ], [ 665 ], [ 667 ], [ 669 ], [ 671 ], [ 673 ], [ 675 ], [ 677 ], [ 685, 687 ], [ 693 ], [ 695 ], [ 697 ], [ 699 ], [ 703 ], [ 705 ], [ 707 ], [ 709 ], [ 711 ], [ 713 ], [ 715 ], [ 717 ], [ 719 ], [ 721 ], [ 723 ], [ 725 ], [ 727 ], [ 729 ], [ 731 ], [ 735, 737, 739 ], [ 743 ], [ 745 ], [ 747, 749, 751 ], [ 753 ], [ 757 ], [ 761, 763, 765 ], [ 767 ], [ 769 ], [ 771 ], [ 773 ] ]
12,582
static av_cold int vorbis_encode_init(AVCodecContext *avccontext) { vorbis_enc_context *venc = avccontext->priv_data; if (avccontext->channels != 2) { av_log(avccontext, AV_LOG_ERROR, "Current Libav Vorbis encoder only supports 2 channels.\n"); return -1; } create_vorbis_context(venc, avccontext); if (avccontext->flags & CODEC_FLAG_QSCALE) venc->quality = avccontext->global_quality / (float)FF_QP2LAMBDA / 10.; else venc->quality = 0.03; venc->quality *= venc->quality; avccontext->extradata_size = put_main_header(venc, (uint8_t**)&avccontext->extradata); avccontext->frame_size = 1 << (venc->log2_blocksize[0] - 1); avccontext->coded_frame = avcodec_alloc_frame(); avccontext->coded_frame->key_frame = 1; return 0; }
true
FFmpeg
be8d812c9635f31f69c30dff9ebf565a07a7dab7
static av_cold int vorbis_encode_init(AVCodecContext *avccontext) { vorbis_enc_context *venc = avccontext->priv_data; if (avccontext->channels != 2) { av_log(avccontext, AV_LOG_ERROR, "Current Libav Vorbis encoder only supports 2 channels.\n"); return -1; } create_vorbis_context(venc, avccontext); if (avccontext->flags & CODEC_FLAG_QSCALE) venc->quality = avccontext->global_quality / (float)FF_QP2LAMBDA / 10.; else venc->quality = 0.03; venc->quality *= venc->quality; avccontext->extradata_size = put_main_header(venc, (uint8_t**)&avccontext->extradata); avccontext->frame_size = 1 << (venc->log2_blocksize[0] - 1); avccontext->coded_frame = avcodec_alloc_frame(); avccontext->coded_frame->key_frame = 1; return 0; }
{ "code": [ "static av_cold int vorbis_encode_init(AVCodecContext *avccontext)", " vorbis_enc_context *venc = avccontext->priv_data;", " if (avccontext->channels != 2) {", " av_log(avccontext, AV_LOG_ERROR, \"Current Libav Vorbis encoder only supports 2 channels.\\n\");", " return -1;", " create_vorbis_context(venc, avccontext);", " if (avccontext->flags & CODEC_FLAG_QSCALE)", " venc->quality = avccontext->global_quality / (float)FF_QP2LAMBDA / 10.;", " venc->quality = 0.03;", " venc->quality *= venc->quality;", " avccontext->extradata_size = put_main_header(venc, (uint8_t**)&avccontext->extradata);", " avccontext->frame_size = 1 << (venc->log2_blocksize[0] - 1);", " avccontext->coded_frame = avcodec_alloc_frame();", " avccontext->coded_frame->key_frame = 1;", " return 0;" ], "line_no": [ 1, 5, 9, 11, 13, 19, 23, 25, 29, 31, 35, 39, 43, 45, 49 ] }
static av_cold int FUNC_0(AVCodecContext *avccontext) { vorbis_enc_context *venc = avccontext->priv_data; if (avccontext->channels != 2) { av_log(avccontext, AV_LOG_ERROR, "Current Libav Vorbis encoder only supports 2 channels.\n"); return -1; } create_vorbis_context(venc, avccontext); if (avccontext->flags & CODEC_FLAG_QSCALE) venc->quality = avccontext->global_quality / (float)FF_QP2LAMBDA / 10.; else venc->quality = 0.03; venc->quality *= venc->quality; avccontext->extradata_size = put_main_header(venc, (uint8_t**)&avccontext->extradata); avccontext->frame_size = 1 << (venc->log2_blocksize[0] - 1); avccontext->coded_frame = avcodec_alloc_frame(); avccontext->coded_frame->key_frame = 1; return 0; }
[ "static av_cold int FUNC_0(AVCodecContext *avccontext)\n{", "vorbis_enc_context *venc = avccontext->priv_data;", "if (avccontext->channels != 2) {", "av_log(avccontext, AV_LOG_ERROR, \"Current Libav Vorbis encoder only supports 2 channels.\\n\");", "return -1;", "}", "create_vorbis_context(venc, avccontext);", "if (avccontext->flags & CODEC_FLAG_QSCALE)\nvenc->quality = avccontext->global_quality / (float)FF_QP2LAMBDA / 10.;", "else\nvenc->quality = 0.03;", "venc->quality *= venc->quality;", "avccontext->extradata_size = put_main_header(venc, (uint8_t**)&avccontext->extradata);", "avccontext->frame_size = 1 << (venc->log2_blocksize[0] - 1);", "avccontext->coded_frame = avcodec_alloc_frame();", "avccontext->coded_frame->key_frame = 1;", "return 0;", "}" ]
[ 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 23, 25 ], [ 27, 29 ], [ 31 ], [ 35 ], [ 39 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ] ]
12,583
struct omap_gp_timer_s *omap_gp_timer_init(struct omap_target_agent_s *ta, qemu_irq irq, omap_clk fclk, omap_clk iclk) { struct omap_gp_timer_s *s = (struct omap_gp_timer_s *) g_malloc0(sizeof(struct omap_gp_timer_s)); s->ta = ta; s->irq = irq; s->clk = fclk; s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, omap_gp_timer_tick, s); s->match = timer_new_ns(QEMU_CLOCK_VIRTUAL, omap_gp_timer_match, s); s->in = qemu_allocate_irq(omap_gp_timer_input, s, 0); omap_gp_timer_reset(s); omap_gp_timer_clk_setup(s); memory_region_init_io(&s->iomem, NULL, &omap_gp_timer_ops, s, "omap.gptimer", omap_l4_region_size(ta, 0)); omap_l4_attach(ta, 0, &s->iomem); return s; }
true
qemu
b45c03f585ea9bb1af76c73e82195418c294919d
struct omap_gp_timer_s *omap_gp_timer_init(struct omap_target_agent_s *ta, qemu_irq irq, omap_clk fclk, omap_clk iclk) { struct omap_gp_timer_s *s = (struct omap_gp_timer_s *) g_malloc0(sizeof(struct omap_gp_timer_s)); s->ta = ta; s->irq = irq; s->clk = fclk; s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, omap_gp_timer_tick, s); s->match = timer_new_ns(QEMU_CLOCK_VIRTUAL, omap_gp_timer_match, s); s->in = qemu_allocate_irq(omap_gp_timer_input, s, 0); omap_gp_timer_reset(s); omap_gp_timer_clk_setup(s); memory_region_init_io(&s->iomem, NULL, &omap_gp_timer_ops, s, "omap.gptimer", omap_l4_region_size(ta, 0)); omap_l4_attach(ta, 0, &s->iomem); return s; }
{ "code": [ " struct omap_gp_timer_s *s = (struct omap_gp_timer_s *)", " g_malloc0(sizeof(struct omap_gp_timer_s));" ], "line_no": [ 7, 9 ] }
struct omap_gp_timer_s *FUNC_0(struct omap_target_agent_s *VAR_0, qemu_irq VAR_1, omap_clk VAR_2, omap_clk VAR_3) { struct omap_gp_timer_s *VAR_4 = (struct omap_gp_timer_s *) g_malloc0(sizeof(struct omap_gp_timer_s)); VAR_4->VAR_0 = VAR_0; VAR_4->VAR_1 = VAR_1; VAR_4->clk = VAR_2; VAR_4->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, omap_gp_timer_tick, VAR_4); VAR_4->match = timer_new_ns(QEMU_CLOCK_VIRTUAL, omap_gp_timer_match, VAR_4); VAR_4->in = qemu_allocate_irq(omap_gp_timer_input, VAR_4, 0); omap_gp_timer_reset(VAR_4); omap_gp_timer_clk_setup(VAR_4); memory_region_init_io(&VAR_4->iomem, NULL, &omap_gp_timer_ops, VAR_4, "omap.gptimer", omap_l4_region_size(VAR_0, 0)); omap_l4_attach(VAR_0, 0, &VAR_4->iomem); return VAR_4; }
[ "struct omap_gp_timer_s *FUNC_0(struct omap_target_agent_s *VAR_0,\nqemu_irq VAR_1, omap_clk VAR_2, omap_clk VAR_3)\n{", "struct omap_gp_timer_s *VAR_4 = (struct omap_gp_timer_s *)\ng_malloc0(sizeof(struct omap_gp_timer_s));", "VAR_4->VAR_0 = VAR_0;", "VAR_4->VAR_1 = VAR_1;", "VAR_4->clk = VAR_2;", "VAR_4->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, omap_gp_timer_tick, VAR_4);", "VAR_4->match = timer_new_ns(QEMU_CLOCK_VIRTUAL, omap_gp_timer_match, VAR_4);", "VAR_4->in = qemu_allocate_irq(omap_gp_timer_input, VAR_4, 0);", "omap_gp_timer_reset(VAR_4);", "omap_gp_timer_clk_setup(VAR_4);", "memory_region_init_io(&VAR_4->iomem, NULL, &omap_gp_timer_ops, VAR_4, \"omap.gptimer\",\nomap_l4_region_size(VAR_0, 0));", "omap_l4_attach(VAR_0, 0, &VAR_4->iomem);", "return VAR_4;", "}" ]
[ 0, 1, 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 ], [ 39 ], [ 41 ] ]
12,584
ISADevice *isa_try_create(ISABus *bus, const char *name) { DeviceState *dev; if (!bus) { hw_error("Tried to create isa device %s with no isa bus present.", name); } dev = qdev_try_create(BUS(bus), name); return ISA_DEVICE(dev); }
true
qemu
675463d9b6b2c2b65a713a6d906aeebe9e6750ae
ISADevice *isa_try_create(ISABus *bus, const char *name) { DeviceState *dev; if (!bus) { hw_error("Tried to create isa device %s with no isa bus present.", name); } dev = qdev_try_create(BUS(bus), name); return ISA_DEVICE(dev); }
{ "code": [ " if (!bus) {", " if (!bus) {", " hw_error(\"Tried to create isa device %s with no isa bus present.\",", " name);", " if (!bus) {", " hw_error(\"Tried to create isa device %s with no isa bus present.\",", " name);" ], "line_no": [ 9, 9, 11, 13, 9, 11, 13 ] }
ISADevice *FUNC_0(ISABus *bus, const char *name) { DeviceState *dev; if (!bus) { hw_error("Tried to create isa device %s with no isa bus present.", name); } dev = qdev_try_create(BUS(bus), name); return ISA_DEVICE(dev); }
[ "ISADevice *FUNC_0(ISABus *bus, const char *name)\n{", "DeviceState *dev;", "if (!bus) {", "hw_error(\"Tried to create isa device %s with no isa bus present.\",\nname);", "}", "dev = qdev_try_create(BUS(bus), name);", "return ISA_DEVICE(dev);", "}" ]
[ 0, 0, 1, 1, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11, 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ] ]
12,586
static int spapr_tce_table_realize(DeviceState *dev) { sPAPRTCETable *tcet = SPAPR_TCE_TABLE(dev); if (kvm_enabled()) { tcet->table = kvmppc_create_spapr_tce(tcet->liobn, tcet->nb_table << tcet->page_shift, &tcet->fd, tcet->vfio_accel); } if (!tcet->table) { size_t table_size = tcet->nb_table * sizeof(uint64_t); tcet->table = g_malloc0(table_size); } trace_spapr_iommu_new_table(tcet->liobn, tcet, tcet->table, tcet->fd); memory_region_init_iommu(&tcet->iommu, OBJECT(dev), &spapr_iommu_ops, "iommu-spapr", (uint64_t)tcet->nb_table << tcet->page_shift); QLIST_INSERT_HEAD(&spapr_tce_tables, tcet, list); vmstate_register(DEVICE(tcet), tcet->liobn, &vmstate_spapr_tce_table, tcet); return 0; }
true
qemu
12fd28535891572be7aaf862a03019257dafa425
static int spapr_tce_table_realize(DeviceState *dev) { sPAPRTCETable *tcet = SPAPR_TCE_TABLE(dev); if (kvm_enabled()) { tcet->table = kvmppc_create_spapr_tce(tcet->liobn, tcet->nb_table << tcet->page_shift, &tcet->fd, tcet->vfio_accel); } if (!tcet->table) { size_t table_size = tcet->nb_table * sizeof(uint64_t); tcet->table = g_malloc0(table_size); } trace_spapr_iommu_new_table(tcet->liobn, tcet, tcet->table, tcet->fd); memory_region_init_iommu(&tcet->iommu, OBJECT(dev), &spapr_iommu_ops, "iommu-spapr", (uint64_t)tcet->nb_table << tcet->page_shift); QLIST_INSERT_HEAD(&spapr_tce_tables, tcet, list); vmstate_register(DEVICE(tcet), tcet->liobn, &vmstate_spapr_tce_table, tcet); return 0; }
{ "code": [ " if (kvm_enabled()) {", " tcet->nb_table <<", " tcet->page_shift," ], "line_no": [ 9, 13, 15 ] }
static int FUNC_0(DeviceState *VAR_0) { sPAPRTCETable *tcet = SPAPR_TCE_TABLE(VAR_0); if (kvm_enabled()) { tcet->table = kvmppc_create_spapr_tce(tcet->liobn, tcet->nb_table << tcet->page_shift, &tcet->fd, tcet->vfio_accel); } if (!tcet->table) { size_t table_size = tcet->nb_table * sizeof(uint64_t); tcet->table = g_malloc0(table_size); } trace_spapr_iommu_new_table(tcet->liobn, tcet, tcet->table, tcet->fd); memory_region_init_iommu(&tcet->iommu, OBJECT(VAR_0), &spapr_iommu_ops, "iommu-spapr", (uint64_t)tcet->nb_table << tcet->page_shift); QLIST_INSERT_HEAD(&spapr_tce_tables, tcet, list); vmstate_register(DEVICE(tcet), tcet->liobn, &vmstate_spapr_tce_table, tcet); return 0; }
[ "static int FUNC_0(DeviceState *VAR_0)\n{", "sPAPRTCETable *tcet = SPAPR_TCE_TABLE(VAR_0);", "if (kvm_enabled()) {", "tcet->table = kvmppc_create_spapr_tce(tcet->liobn,\ntcet->nb_table <<\ntcet->page_shift,\n&tcet->fd,\ntcet->vfio_accel);", "}", "if (!tcet->table) {", "size_t table_size = tcet->nb_table * sizeof(uint64_t);", "tcet->table = g_malloc0(table_size);", "}", "trace_spapr_iommu_new_table(tcet->liobn, tcet, tcet->table, tcet->fd);", "memory_region_init_iommu(&tcet->iommu, OBJECT(VAR_0), &spapr_iommu_ops,\n\"iommu-spapr\",\n(uint64_t)tcet->nb_table << tcet->page_shift);", "QLIST_INSERT_HEAD(&spapr_tce_tables, tcet, list);", "vmstate_register(DEVICE(tcet), tcet->liobn, &vmstate_spapr_tce_table,\ntcet);", "return 0;", "}" ]
[ 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11, 13, 15, 17, 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 39, 41, 43 ], [ 47 ], [ 51, 53 ], [ 57 ], [ 59 ] ]
12,587
static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, int *prot, ARMMMUFaultInfo *fi) { ARMCPU *cpu = arm_env_get_cpu(env); int n; bool is_user = regime_is_user(env, mmu_idx); *phys_ptr = address; *prot = 0; if (regime_translation_disabled(env, mmu_idx) || m_is_ppb_region(env, address)) { /* MPU disabled or M profile PPB access: use default memory map. * The other case which uses the default memory map in the * v7M ARM ARM pseudocode is exception vector reads from the vector * table. In QEMU those accesses are done in arm_v7m_load_vector(), * which always does a direct read using address_space_ldl(), rather * than going via this function, so we don't need to check that here. */ get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); } else { /* MPU enabled */ for (n = (int)cpu->pmsav7_dregion - 1; n >= 0; n--) { /* region search */ uint32_t base = env->pmsav7.drbar[n]; uint32_t rsize = extract32(env->pmsav7.drsr[n], 1, 5); uint32_t rmask; bool srdis = false; if (!(env->pmsav7.drsr[n] & 0x1)) { continue; if (!rsize) { qemu_log_mask(LOG_GUEST_ERROR, "DRSR[%d]: Rsize field cannot be 0\n", n); continue; rsize++; rmask = (1ull << rsize) - 1; if (base & rmask) { qemu_log_mask(LOG_GUEST_ERROR, "DRBAR[%d]: 0x%" PRIx32 " misaligned " "to DRSR region size, mask = 0x%" PRIx32 "\n", n, base, rmask); continue; if (address < base || address > base + rmask) { continue; /* Region matched */ if (rsize >= 8) { /* no subregions for regions < 256 bytes */ int i, snd; uint32_t srdis_mask; rsize -= 3; /* sub region size (power of 2) */ snd = ((address - base) >> rsize) & 0x7; srdis = extract32(env->pmsav7.drsr[n], snd + 8, 1); srdis_mask = srdis ? 0x3 : 0x0; for (i = 2; i <= 8 && rsize < TARGET_PAGE_BITS; i *= 2) { /* This will check in groups of 2, 4 and then 8, whether * the subregion bits are consistent. rsize is incremented * back up to give the region size, considering consistent * adjacent subregions as one region. Stop testing if rsize * is already big enough for an entire QEMU page. */ int snd_rounded = snd & ~(i - 1); uint32_t srdis_multi = extract32(env->pmsav7.drsr[n], snd_rounded + 8, i); if (srdis_mask ^ srdis_multi) { srdis_mask = (srdis_mask << i) | srdis_mask; rsize++; if (rsize < TARGET_PAGE_BITS) { qemu_log_mask(LOG_UNIMP, "DRSR[%d]: No support for MPU (sub)region " "alignment of %" PRIu32 " bits. Minimum is %d\n", n, rsize, TARGET_PAGE_BITS); continue; if (srdis) { continue; if (n == -1) { /* no hits */ if (!pmsav7_use_background_region(cpu, mmu_idx, is_user)) { /* background fault */ fi->type = ARMFault_Background; return true; get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); } else { /* a MPU hit! */ uint32_t ap = extract32(env->pmsav7.dracr[n], 8, 3); uint32_t xn = extract32(env->pmsav7.dracr[n], 12, 1); if (m_is_system_region(env, address)) { /* System space is always execute never */ xn = 1; if (is_user) { /* User mode AP bit decoding */ switch (ap) { case 0: case 1: case 5: break; /* no access */ case 3: *prot |= PAGE_WRITE; case 2: case 6: default: qemu_log_mask(LOG_GUEST_ERROR, "DRACR[%d]: Bad value for AP bits: 0x%" PRIx32 "\n", n, ap); } else { /* Priv. mode AP bits decoding */ switch (ap) { case 0: break; /* no access */ case 1: case 2: case 3: *prot |= PAGE_WRITE; case 5: case 6: default: qemu_log_mask(LOG_GUEST_ERROR, "DRACR[%d]: Bad value for AP bits: 0x%" PRIx32 "\n", n, ap); /* execute never */ if (xn) { *prot &= ~PAGE_EXEC; fi->type = ARMFault_Permission; fi->level = 1; return !(*prot & (1 << access_type));
true
qemu
8638f1ad7403b63db880dadce38e6690b5d82b64
static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, int *prot, ARMMMUFaultInfo *fi) { ARMCPU *cpu = arm_env_get_cpu(env); int n; bool is_user = regime_is_user(env, mmu_idx); *phys_ptr = address; *prot = 0; if (regime_translation_disabled(env, mmu_idx) || m_is_ppb_region(env, address)) { get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); } else { for (n = (int)cpu->pmsav7_dregion - 1; n >= 0; n--) { uint32_t base = env->pmsav7.drbar[n]; uint32_t rsize = extract32(env->pmsav7.drsr[n], 1, 5); uint32_t rmask; bool srdis = false; if (!(env->pmsav7.drsr[n] & 0x1)) { continue; if (!rsize) { qemu_log_mask(LOG_GUEST_ERROR, "DRSR[%d]: Rsize field cannot be 0\n", n); continue; rsize++; rmask = (1ull << rsize) - 1; if (base & rmask) { qemu_log_mask(LOG_GUEST_ERROR, "DRBAR[%d]: 0x%" PRIx32 " misaligned " "to DRSR region size, mask = 0x%" PRIx32 "\n", n, base, rmask); continue; if (address < base || address > base + rmask) { continue; if (rsize >= 8) { int i, snd; uint32_t srdis_mask; rsize -= 3; snd = ((address - base) >> rsize) & 0x7; srdis = extract32(env->pmsav7.drsr[n], snd + 8, 1); srdis_mask = srdis ? 0x3 : 0x0; for (i = 2; i <= 8 && rsize < TARGET_PAGE_BITS; i *= 2) { int snd_rounded = snd & ~(i - 1); uint32_t srdis_multi = extract32(env->pmsav7.drsr[n], snd_rounded + 8, i); if (srdis_mask ^ srdis_multi) { srdis_mask = (srdis_mask << i) | srdis_mask; rsize++; if (rsize < TARGET_PAGE_BITS) { qemu_log_mask(LOG_UNIMP, "DRSR[%d]: No support for MPU (sub)region " "alignment of %" PRIu32 " bits. Minimum is %d\n", n, rsize, TARGET_PAGE_BITS); continue; if (srdis) { continue; if (n == -1) { if (!pmsav7_use_background_region(cpu, mmu_idx, is_user)) { fi->type = ARMFault_Background; return true; get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); } else { uint32_t ap = extract32(env->pmsav7.dracr[n], 8, 3); uint32_t xn = extract32(env->pmsav7.dracr[n], 12, 1); if (m_is_system_region(env, address)) { xn = 1; if (is_user) { switch (ap) { case 0: case 1: case 5: break; case 3: *prot |= PAGE_WRITE; case 2: case 6: default: qemu_log_mask(LOG_GUEST_ERROR, "DRACR[%d]: Bad value for AP bits: 0x%" PRIx32 "\n", n, ap); } else { switch (ap) { case 0: break; case 1: case 2: case 3: *prot |= PAGE_WRITE; case 5: case 6: default: qemu_log_mask(LOG_GUEST_ERROR, "DRACR[%d]: Bad value for AP bits: 0x%" PRIx32 "\n", n, ap); if (xn) { *prot &= ~PAGE_EXEC; fi->type = ARMFault_Permission; fi->level = 1; return !(*prot & (1 << access_type));
{ "code": [], "line_no": [] }
static bool FUNC_0(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, int *prot, ARMMMUFaultInfo *fi) { ARMCPU *cpu = arm_env_get_cpu(env); int VAR_0; bool is_user = regime_is_user(env, mmu_idx); *phys_ptr = address; *prot = 0; if (regime_translation_disabled(env, mmu_idx) || m_is_ppb_region(env, address)) { get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); } else { for (VAR_0 = (int)cpu->pmsav7_dregion - 1; VAR_0 >= 0; VAR_0--) { uint32_t base = env->pmsav7.drbar[VAR_0]; uint32_t rsize = extract32(env->pmsav7.drsr[VAR_0], 1, 5); uint32_t rmask; bool srdis = false; if (!(env->pmsav7.drsr[VAR_0] & 0x1)) { continue; if (!rsize) { qemu_log_mask(LOG_GUEST_ERROR, "DRSR[%d]: Rsize field cannot be 0\VAR_0", VAR_0); continue; rsize++; rmask = (1ull << rsize) - 1; if (base & rmask) { qemu_log_mask(LOG_GUEST_ERROR, "DRBAR[%d]: 0x%" PRIx32 " misaligned " "to DRSR region size, mask = 0x%" PRIx32 "\VAR_0", VAR_0, base, rmask); continue; if (address < base || address > base + rmask) { continue; if (rsize >= 8) { int VAR_1, VAR_2; uint32_t srdis_mask; rsize -= 3; VAR_2 = ((address - base) >> rsize) & 0x7; srdis = extract32(env->pmsav7.drsr[VAR_0], VAR_2 + 8, 1); srdis_mask = srdis ? 0x3 : 0x0; for (VAR_1 = 2; VAR_1 <= 8 && rsize < TARGET_PAGE_BITS; VAR_1 *= 2) { int snd_rounded = VAR_2 & ~(VAR_1 - 1); uint32_t srdis_multi = extract32(env->pmsav7.drsr[VAR_0], snd_rounded + 8, VAR_1); if (srdis_mask ^ srdis_multi) { srdis_mask = (srdis_mask << VAR_1) | srdis_mask; rsize++; if (rsize < TARGET_PAGE_BITS) { qemu_log_mask(LOG_UNIMP, "DRSR[%d]: No support for MPU (sub)region " "alignment of %" PRIu32 " bits. Minimum is %d\VAR_0", VAR_0, rsize, TARGET_PAGE_BITS); continue; if (srdis) { continue; if (VAR_0 == -1) { if (!pmsav7_use_background_region(cpu, mmu_idx, is_user)) { fi->type = ARMFault_Background; return true; get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); } else { uint32_t ap = extract32(env->pmsav7.dracr[VAR_0], 8, 3); uint32_t xn = extract32(env->pmsav7.dracr[VAR_0], 12, 1); if (m_is_system_region(env, address)) { xn = 1; if (is_user) { switch (ap) { case 0: case 1: case 5: break; case 3: *prot |= PAGE_WRITE; case 2: case 6: default: qemu_log_mask(LOG_GUEST_ERROR, "DRACR[%d]: Bad value for AP bits: 0x%" PRIx32 "\VAR_0", VAR_0, ap); } else { switch (ap) { case 0: break; case 1: case 2: case 3: *prot |= PAGE_WRITE; case 5: case 6: default: qemu_log_mask(LOG_GUEST_ERROR, "DRACR[%d]: Bad value for AP bits: 0x%" PRIx32 "\VAR_0", VAR_0, ap); if (xn) { *prot &= ~PAGE_EXEC; fi->type = ARMFault_Permission; fi->level = 1; return !(*prot & (1 << access_type));
[ "static bool FUNC_0(CPUARMState *env, uint32_t address,\nMMUAccessType access_type, ARMMMUIdx mmu_idx,\nhwaddr *phys_ptr, int *prot,\nARMMMUFaultInfo *fi)\n{", "ARMCPU *cpu = arm_env_get_cpu(env);", "int VAR_0;", "bool is_user = regime_is_user(env, mmu_idx);", "*phys_ptr = address;", "*prot = 0;", "if (regime_translation_disabled(env, mmu_idx) ||\nm_is_ppb_region(env, address)) {", "get_phys_addr_pmsav7_default(env, mmu_idx, address, prot);", "} else {", "for (VAR_0 = (int)cpu->pmsav7_dregion - 1; VAR_0 >= 0; VAR_0--) {", "uint32_t base = env->pmsav7.drbar[VAR_0];", "uint32_t rsize = extract32(env->pmsav7.drsr[VAR_0], 1, 5);", "uint32_t rmask;", "bool srdis = false;", "if (!(env->pmsav7.drsr[VAR_0] & 0x1)) {", "continue;", "if (!rsize) {", "qemu_log_mask(LOG_GUEST_ERROR,\n\"DRSR[%d]: Rsize field cannot be 0\\VAR_0\", VAR_0);", "continue;", "rsize++;", "rmask = (1ull << rsize) - 1;", "if (base & rmask) {", "qemu_log_mask(LOG_GUEST_ERROR,\n\"DRBAR[%d]: 0x%\" PRIx32 \" misaligned \"\n\"to DRSR region size, mask = 0x%\" PRIx32 \"\\VAR_0\",\nVAR_0, base, rmask);", "continue;", "if (address < base || address > base + rmask) {", "continue;", "if (rsize >= 8) {", "int VAR_1, VAR_2;", "uint32_t srdis_mask;", "rsize -= 3;", "VAR_2 = ((address - base) >> rsize) & 0x7;", "srdis = extract32(env->pmsav7.drsr[VAR_0], VAR_2 + 8, 1);", "srdis_mask = srdis ? 0x3 : 0x0;", "for (VAR_1 = 2; VAR_1 <= 8 && rsize < TARGET_PAGE_BITS; VAR_1 *= 2) {", "int snd_rounded = VAR_2 & ~(VAR_1 - 1);", "uint32_t srdis_multi = extract32(env->pmsav7.drsr[VAR_0],\nsnd_rounded + 8, VAR_1);", "if (srdis_mask ^ srdis_multi) {", "srdis_mask = (srdis_mask << VAR_1) | srdis_mask;", "rsize++;", "if (rsize < TARGET_PAGE_BITS) {", "qemu_log_mask(LOG_UNIMP,\n\"DRSR[%d]: No support for MPU (sub)region \"\n\"alignment of %\" PRIu32 \" bits. Minimum is %d\\VAR_0\",\nVAR_0, rsize, TARGET_PAGE_BITS);", "continue;", "if (srdis) {", "continue;", "if (VAR_0 == -1) {", "if (!pmsav7_use_background_region(cpu, mmu_idx, is_user)) {", "fi->type = ARMFault_Background;", "return true;", "get_phys_addr_pmsav7_default(env, mmu_idx, address, prot);", "} else {", "uint32_t ap = extract32(env->pmsav7.dracr[VAR_0], 8, 3);", "uint32_t xn = extract32(env->pmsav7.dracr[VAR_0], 12, 1);", "if (m_is_system_region(env, address)) {", "xn = 1;", "if (is_user) {", "switch (ap) {", "case 0:\ncase 1:\ncase 5:\nbreak;", "case 3:\n*prot |= PAGE_WRITE;", "case 2:\ncase 6:\ndefault:\nqemu_log_mask(LOG_GUEST_ERROR,\n\"DRACR[%d]: Bad value for AP bits: 0x%\"\nPRIx32 \"\\VAR_0\", VAR_0, ap);", "} else {", "switch (ap) {", "case 0:\nbreak;", "case 1:\ncase 2:\ncase 3:\n*prot |= PAGE_WRITE;", "case 5:\ncase 6:\ndefault:\nqemu_log_mask(LOG_GUEST_ERROR,\n\"DRACR[%d]: Bad value for AP bits: 0x%\"\nPRIx32 \"\\VAR_0\", VAR_0, ap);", "if (xn) {", "*prot &= ~PAGE_EXEC;", "fi->type = ARMFault_Permission;", "fi->level = 1;", "return !(*prot & (1 << access_type));" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 68 ], [ 70, 72 ], [ 74 ], [ 77 ], [ 79 ], [ 83 ], [ 85, 87, 89, 91 ], [ 93 ], [ 98 ], [ 100 ], [ 109 ], [ 111 ], [ 113 ], [ 117 ], [ 119 ], [ 121 ], [ 125 ], [ 127 ], [ 141 ], [ 143, 145 ], [ 147 ], [ 151 ], [ 153 ], [ 157 ], [ 159, 161, 163, 165 ], [ 167 ], [ 170 ], [ 172 ], [ 179 ], [ 181 ], [ 185 ], [ 187 ], [ 190 ], [ 192 ], [ 194 ], [ 196 ], [ 200 ], [ 204 ], [ 209 ], [ 211 ], [ 213, 215, 217, 219 ], [ 221, 223 ], [ 226, 228, 239, 241, 243, 245 ], [ 248 ], [ 250 ], [ 252, 254 ], [ 256, 258, 260, 262 ], [ 265, 267, 278, 280, 282, 284 ], [ 292 ], [ 294 ], [ 301 ], [ 303 ], [ 305 ] ]
12,588
bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_write) { MemoryRegion *mr; hwaddr l, xlat; rcu_read_lock(); while (len > 0) { l = len; mr = address_space_translate(as, addr, &xlat, &l, is_write); if (!memory_access_is_direct(mr, is_write)) { l = memory_access_size(mr, l, addr); if (!memory_region_access_valid(mr, xlat, l, is_write)) { return false; } } len -= l; addr += l; } return true; }
true
qemu
5ad4a2b75f85dd854a781a6e03b90320cb3441d3
bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_write) { MemoryRegion *mr; hwaddr l, xlat; rcu_read_lock(); while (len > 0) { l = len; mr = address_space_translate(as, addr, &xlat, &l, is_write); if (!memory_access_is_direct(mr, is_write)) { l = memory_access_size(mr, l, addr); if (!memory_region_access_valid(mr, xlat, l, is_write)) { return false; } } len -= l; addr += l; } return true; }
{ "code": [], "line_no": [] }
bool FUNC_0(AddressSpace *as, hwaddr addr, int len, bool is_write) { MemoryRegion *mr; hwaddr l, xlat; rcu_read_lock(); while (len > 0) { l = len; mr = address_space_translate(as, addr, &xlat, &l, is_write); if (!memory_access_is_direct(mr, is_write)) { l = memory_access_size(mr, l, addr); if (!memory_region_access_valid(mr, xlat, l, is_write)) { return false; } } len -= l; addr += l; } return true; }
[ "bool FUNC_0(AddressSpace *as, hwaddr addr, int len, bool is_write)\n{", "MemoryRegion *mr;", "hwaddr l, xlat;", "rcu_read_lock();", "while (len > 0) {", "l = len;", "mr = address_space_translate(as, addr, &xlat, &l, is_write);", "if (!memory_access_is_direct(mr, is_write)) {", "l = memory_access_size(mr, l, addr);", "if (!memory_region_access_valid(mr, xlat, l, is_write)) {", "return false;", "}", "}", "len -= l;", "addr += l;", "}", "return true;", "}" ]
[ 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 ], [ 26 ], [ 28 ], [ 30 ], [ 34 ], [ 36 ], [ 38 ], [ 41 ], [ 43 ] ]
12,589
static int restore_sigcontext(CPUAlphaState *env, struct target_sigcontext *sc) { uint64_t fpcr; int i, err = 0; __get_user(env->pc, &sc->sc_pc); for (i = 0; i < 31; ++i) { __get_user(env->ir[i], &sc->sc_regs[i]); } for (i = 0; i < 31; ++i) { __get_user(env->fir[i], &sc->sc_fpregs[i]); } __get_user(fpcr, &sc->sc_fpcr); cpu_alpha_store_fpcr(env, fpcr); return err; }
true
qemu
016d2e1dfa21b64a524d3629fdd317d4c25bc3b8
static int restore_sigcontext(CPUAlphaState *env, struct target_sigcontext *sc) { uint64_t fpcr; int i, err = 0; __get_user(env->pc, &sc->sc_pc); for (i = 0; i < 31; ++i) { __get_user(env->ir[i], &sc->sc_regs[i]); } for (i = 0; i < 31; ++i) { __get_user(env->fir[i], &sc->sc_fpregs[i]); } __get_user(fpcr, &sc->sc_fpcr); cpu_alpha_store_fpcr(env, fpcr); return err; }
{ "code": [ " return err;", " return err;", " return err;", "static int restore_sigcontext(CPUAlphaState *env,", " int i, err = 0;", " return err;" ], "line_no": [ 37, 37, 37, 1, 9, 37 ] }
static int FUNC_0(CPUAlphaState *VAR_0, struct target_sigcontext *VAR_1) { uint64_t fpcr; int VAR_2, VAR_3 = 0; __get_user(VAR_0->pc, &VAR_1->sc_pc); for (VAR_2 = 0; VAR_2 < 31; ++VAR_2) { __get_user(VAR_0->ir[VAR_2], &VAR_1->sc_regs[VAR_2]); } for (VAR_2 = 0; VAR_2 < 31; ++VAR_2) { __get_user(VAR_0->fir[VAR_2], &VAR_1->sc_fpregs[VAR_2]); } __get_user(fpcr, &VAR_1->sc_fpcr); cpu_alpha_store_fpcr(VAR_0, fpcr); return VAR_3; }
[ "static int FUNC_0(CPUAlphaState *VAR_0,\nstruct target_sigcontext *VAR_1)\n{", "uint64_t fpcr;", "int VAR_2, VAR_3 = 0;", "__get_user(VAR_0->pc, &VAR_1->sc_pc);", "for (VAR_2 = 0; VAR_2 < 31; ++VAR_2) {", "__get_user(VAR_0->ir[VAR_2], &VAR_1->sc_regs[VAR_2]);", "}", "for (VAR_2 = 0; VAR_2 < 31; ++VAR_2) {", "__get_user(VAR_0->fir[VAR_2], &VAR_1->sc_fpregs[VAR_2]);", "}", "__get_user(fpcr, &VAR_1->sc_fpcr);", "cpu_alpha_store_fpcr(VAR_0, fpcr);", "return VAR_3;", "}" ]
[ 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ] ]
12,590
static void qxl_realize_secondary(PCIDevice *dev, Error **errp) { static int device_id = 1; PCIQXLDevice *qxl = PCI_QXL(dev); qxl->id = device_id++; qxl_init_ramsize(qxl); memory_region_init_ram(&qxl->vga.vram, OBJECT(dev), "qxl.vgavram", qxl->vga.vram_size, &error_abort); vmstate_register_ram(&qxl->vga.vram, &qxl->pci.qdev); qxl->vga.vram_ptr = memory_region_get_ram_ptr(&qxl->vga.vram); qxl->vga.con = graphic_console_init(DEVICE(dev), 0, &qxl_ops, qxl); qxl_realize_common(qxl, errp); }
true
qemu
f8ed85ac992c48814d916d5df4d44f9a971c5de4
static void qxl_realize_secondary(PCIDevice *dev, Error **errp) { static int device_id = 1; PCIQXLDevice *qxl = PCI_QXL(dev); qxl->id = device_id++; qxl_init_ramsize(qxl); memory_region_init_ram(&qxl->vga.vram, OBJECT(dev), "qxl.vgavram", qxl->vga.vram_size, &error_abort); vmstate_register_ram(&qxl->vga.vram, &qxl->pci.qdev); qxl->vga.vram_ptr = memory_region_get_ram_ptr(&qxl->vga.vram); qxl->vga.con = graphic_console_init(DEVICE(dev), 0, &qxl_ops, qxl); qxl_realize_common(qxl, errp); }
{ "code": [ " qxl->vga.vram_size, &error_abort);" ], "line_no": [ 17 ] }
static void FUNC_0(PCIDevice *VAR_0, Error **VAR_1) { static int VAR_2 = 1; PCIQXLDevice *qxl = PCI_QXL(VAR_0); qxl->id = VAR_2++; qxl_init_ramsize(qxl); memory_region_init_ram(&qxl->vga.vram, OBJECT(VAR_0), "qxl.vgavram", qxl->vga.vram_size, &error_abort); vmstate_register_ram(&qxl->vga.vram, &qxl->pci.qdev); qxl->vga.vram_ptr = memory_region_get_ram_ptr(&qxl->vga.vram); qxl->vga.con = graphic_console_init(DEVICE(VAR_0), 0, &qxl_ops, qxl); qxl_realize_common(qxl, VAR_1); }
[ "static void FUNC_0(PCIDevice *VAR_0, Error **VAR_1)\n{", "static int VAR_2 = 1;", "PCIQXLDevice *qxl = PCI_QXL(VAR_0);", "qxl->id = VAR_2++;", "qxl_init_ramsize(qxl);", "memory_region_init_ram(&qxl->vga.vram, OBJECT(VAR_0), \"qxl.vgavram\",\nqxl->vga.vram_size, &error_abort);", "vmstate_register_ram(&qxl->vga.vram, &qxl->pci.qdev);", "qxl->vga.vram_ptr = memory_region_get_ram_ptr(&qxl->vga.vram);", "qxl->vga.con = graphic_console_init(DEVICE(VAR_0), 0, &qxl_ops, qxl);", "qxl_realize_common(qxl, VAR_1);", "}" ]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15, 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ] ]