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
9,317
static void gen_compute_eflags_z(DisasContext *s, TCGv reg, bool inv) { switch (s->cc_op) { case CC_OP_DYNAMIC: gen_compute_eflags(s); /* FALLTHRU */ case CC_OP_EFLAGS: tcg_gen_shri_tl(reg, cpu_cc_src, 6); tcg_gen_andi_tl(reg, reg, 1); if (inv) { tcg_gen_xori_tl(reg, reg, 1); } break; default: { int size = (s->cc_op - CC_OP_ADDB) & 3; TCGv t0 = gen_ext_tl(reg, cpu_cc_dst, size, false); tcg_gen_setcondi_tl(inv ? TCG_COND_NE : TCG_COND_EQ, reg, t0, 0); } break; } }
false
qemu
bec93d7283b635aabaf0bbff67b6da7fc99e020a
static void gen_compute_eflags_z(DisasContext *s, TCGv reg, bool inv) { switch (s->cc_op) { case CC_OP_DYNAMIC: gen_compute_eflags(s); case CC_OP_EFLAGS: tcg_gen_shri_tl(reg, cpu_cc_src, 6); tcg_gen_andi_tl(reg, reg, 1); if (inv) { tcg_gen_xori_tl(reg, reg, 1); } break; default: { int size = (s->cc_op - CC_OP_ADDB) & 3; TCGv t0 = gen_ext_tl(reg, cpu_cc_dst, size, false); tcg_gen_setcondi_tl(inv ? TCG_COND_NE : TCG_COND_EQ, reg, t0, 0); } break; } }
{ "code": [], "line_no": [] }
static void FUNC_0(DisasContext *VAR_0, TCGv VAR_1, bool VAR_2) { switch (VAR_0->cc_op) { case CC_OP_DYNAMIC: gen_compute_eflags(VAR_0); case CC_OP_EFLAGS: tcg_gen_shri_tl(VAR_1, cpu_cc_src, 6); tcg_gen_andi_tl(VAR_1, VAR_1, 1); if (VAR_2) { tcg_gen_xori_tl(VAR_1, VAR_1, 1); } break; default: { int VAR_3 = (VAR_0->cc_op - CC_OP_ADDB) & 3; TCGv t0 = gen_ext_tl(VAR_1, cpu_cc_dst, VAR_3, false); tcg_gen_setcondi_tl(VAR_2 ? TCG_COND_NE : TCG_COND_EQ, VAR_1, t0, 0); } break; } }
[ "static void FUNC_0(DisasContext *VAR_0, TCGv VAR_1, bool VAR_2)\n{", "switch (VAR_0->cc_op) {", "case CC_OP_DYNAMIC:\ngen_compute_eflags(VAR_0);", "case CC_OP_EFLAGS:\ntcg_gen_shri_tl(VAR_1, cpu_cc_src, 6);", "tcg_gen_andi_tl(VAR_1, VAR_1, 1);", "if (VAR_2) {", "tcg_gen_xori_tl(VAR_1, VAR_1, 1);", "}", "break;", "default:\n{", "int VAR_3 = (VAR_0->cc_op - CC_OP_ADDB) & 3;", "TCGv t0 = gen_ext_tl(VAR_1, cpu_cc_dst, VAR_3, false);", "tcg_gen_setcondi_tl(VAR_2 ? TCG_COND_NE : TCG_COND_EQ, VAR_1, t0, 0);", "}", "break;", "}", "}" ]
[ 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 ] ]
9,318
uint32_t omap_badwidth_read16(void *opaque, target_phys_addr_t addr) { uint16_t ret; OMAP_16B_REG(addr); cpu_physical_memory_read(addr, (void *) &ret, 2); return ret; }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
uint32_t omap_badwidth_read16(void *opaque, target_phys_addr_t addr) { uint16_t ret; OMAP_16B_REG(addr); cpu_physical_memory_read(addr, (void *) &ret, 2); return ret; }
{ "code": [], "line_no": [] }
uint32_t FUNC_0(void *opaque, target_phys_addr_t addr) { uint16_t ret; OMAP_16B_REG(addr); cpu_physical_memory_read(addr, (void *) &ret, 2); return ret; }
[ "uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)\n{", "uint16_t ret;", "OMAP_16B_REG(addr);", "cpu_physical_memory_read(addr, (void *) &ret, 2);", "return ret;", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ] ]
9,319
void nelly_decode_block(NellyMoserDecodeContext *s, unsigned char block[NELLY_BLOCK_LEN], float audio[NELLY_SAMPLES]) { int i,j; float buf[NELLY_FILL_LEN], pows[NELLY_FILL_LEN]; float *aptr, *bptr, *pptr, val, pval; int bits[NELLY_BUF_LEN]; unsigned char v; init_get_bits(&s->gb, block, NELLY_BLOCK_LEN * 8); bptr = buf; pptr = pows; val = nelly_init_table[get_bits(&s->gb, 6)]; for (i=0 ; i<NELLY_BANDS ; i++) { if (i > 0) val += nelly_delta_table[get_bits(&s->gb, 5)]; pval = pow(2, val/2048); for (j = 0; j < nelly_band_sizes_table[i]; j++) { *bptr++ = val; *pptr++ = pval; } } get_sample_bits(buf, bits); for (i = 0; i < 2; i++) { aptr = audio + i * NELLY_BUF_LEN; init_get_bits(&s->gb, block, NELLY_BLOCK_LEN * 8); skip_bits(&s->gb, NELLY_HEADER_BITS + i*NELLY_DETAIL_BITS); for (j = 0; j < NELLY_FILL_LEN; j++) { if (bits[j] <= 0) { aptr[j] = M_SQRT1_2*pows[j]; if (av_random(&s->random_state) & 1) aptr[j] *= -1.0; } else { v = get_bits(&s->gb, bits[j]); aptr[j] = dequantization_table[(1<<bits[j])-1+v]*pows[j]; } } memset(&aptr[NELLY_FILL_LEN], 0, (NELLY_BUF_LEN - NELLY_FILL_LEN) * sizeof(float)); s->imdct_ctx.fft.imdct_calc(&s->imdct_ctx, s->imdct_out, aptr, s->imdct_tmp); /* XXX: overlapping and windowing should be part of a more generic imdct function */ for(j = 0; j < NELLY_BUF_LEN / 2; j++) { aptr[j] = s->imdct_out[j + NELLY_BUF_LEN + NELLY_BUF_LEN / 2]; aptr[j + NELLY_BUF_LEN / 2] = s->imdct_out[j]; } overlap_and_window(s, s->state, aptr); } }
false
FFmpeg
289987e454cf3705c9cc824fdda3e25949f78898
void nelly_decode_block(NellyMoserDecodeContext *s, unsigned char block[NELLY_BLOCK_LEN], float audio[NELLY_SAMPLES]) { int i,j; float buf[NELLY_FILL_LEN], pows[NELLY_FILL_LEN]; float *aptr, *bptr, *pptr, val, pval; int bits[NELLY_BUF_LEN]; unsigned char v; init_get_bits(&s->gb, block, NELLY_BLOCK_LEN * 8); bptr = buf; pptr = pows; val = nelly_init_table[get_bits(&s->gb, 6)]; for (i=0 ; i<NELLY_BANDS ; i++) { if (i > 0) val += nelly_delta_table[get_bits(&s->gb, 5)]; pval = pow(2, val/2048); for (j = 0; j < nelly_band_sizes_table[i]; j++) { *bptr++ = val; *pptr++ = pval; } } get_sample_bits(buf, bits); for (i = 0; i < 2; i++) { aptr = audio + i * NELLY_BUF_LEN; init_get_bits(&s->gb, block, NELLY_BLOCK_LEN * 8); skip_bits(&s->gb, NELLY_HEADER_BITS + i*NELLY_DETAIL_BITS); for (j = 0; j < NELLY_FILL_LEN; j++) { if (bits[j] <= 0) { aptr[j] = M_SQRT1_2*pows[j]; if (av_random(&s->random_state) & 1) aptr[j] *= -1.0; } else { v = get_bits(&s->gb, bits[j]); aptr[j] = dequantization_table[(1<<bits[j])-1+v]*pows[j]; } } memset(&aptr[NELLY_FILL_LEN], 0, (NELLY_BUF_LEN - NELLY_FILL_LEN) * sizeof(float)); s->imdct_ctx.fft.imdct_calc(&s->imdct_ctx, s->imdct_out, aptr, s->imdct_tmp); for(j = 0; j < NELLY_BUF_LEN / 2; j++) { aptr[j] = s->imdct_out[j + NELLY_BUF_LEN + NELLY_BUF_LEN / 2]; aptr[j + NELLY_BUF_LEN / 2] = s->imdct_out[j]; } overlap_and_window(s, s->state, aptr); } }
{ "code": [], "line_no": [] }
void FUNC_0(NellyMoserDecodeContext *VAR_0, unsigned char VAR_1[NELLY_BLOCK_LEN], float VAR_2[NELLY_SAMPLES]) { int VAR_3,VAR_4; float VAR_5[NELLY_FILL_LEN], pows[NELLY_FILL_LEN]; float *VAR_6, *VAR_7, *VAR_8, VAR_9, VAR_10; int VAR_11[NELLY_BUF_LEN]; unsigned char VAR_12; init_get_bits(&VAR_0->gb, VAR_1, NELLY_BLOCK_LEN * 8); VAR_7 = VAR_5; VAR_8 = pows; VAR_9 = nelly_init_table[get_bits(&VAR_0->gb, 6)]; for (VAR_3=0 ; VAR_3<NELLY_BANDS ; VAR_3++) { if (VAR_3 > 0) VAR_9 += nelly_delta_table[get_bits(&VAR_0->gb, 5)]; VAR_10 = pow(2, VAR_9/2048); for (VAR_4 = 0; VAR_4 < nelly_band_sizes_table[VAR_3]; VAR_4++) { *VAR_7++ = VAR_9; *VAR_8++ = VAR_10; } } get_sample_bits(VAR_5, VAR_11); for (VAR_3 = 0; VAR_3 < 2; VAR_3++) { VAR_6 = VAR_2 + VAR_3 * NELLY_BUF_LEN; init_get_bits(&VAR_0->gb, VAR_1, NELLY_BLOCK_LEN * 8); skip_bits(&VAR_0->gb, NELLY_HEADER_BITS + VAR_3*NELLY_DETAIL_BITS); for (VAR_4 = 0; VAR_4 < NELLY_FILL_LEN; VAR_4++) { if (VAR_11[VAR_4] <= 0) { VAR_6[VAR_4] = M_SQRT1_2*pows[VAR_4]; if (av_random(&VAR_0->random_state) & 1) VAR_6[VAR_4] *= -1.0; } else { VAR_12 = get_bits(&VAR_0->gb, VAR_11[VAR_4]); VAR_6[VAR_4] = dequantization_table[(1<<VAR_11[VAR_4])-1+VAR_12]*pows[VAR_4]; } } memset(&VAR_6[NELLY_FILL_LEN], 0, (NELLY_BUF_LEN - NELLY_FILL_LEN) * sizeof(float)); VAR_0->imdct_ctx.fft.imdct_calc(&VAR_0->imdct_ctx, VAR_0->imdct_out, VAR_6, VAR_0->imdct_tmp); for(VAR_4 = 0; VAR_4 < NELLY_BUF_LEN / 2; VAR_4++) { VAR_6[VAR_4] = VAR_0->imdct_out[VAR_4 + NELLY_BUF_LEN + NELLY_BUF_LEN / 2]; VAR_6[VAR_4 + NELLY_BUF_LEN / 2] = VAR_0->imdct_out[VAR_4]; } overlap_and_window(VAR_0, VAR_0->state, VAR_6); } }
[ "void FUNC_0(NellyMoserDecodeContext *VAR_0, unsigned char VAR_1[NELLY_BLOCK_LEN], float VAR_2[NELLY_SAMPLES])\n{", "int VAR_3,VAR_4;", "float VAR_5[NELLY_FILL_LEN], pows[NELLY_FILL_LEN];", "float *VAR_6, *VAR_7, *VAR_8, VAR_9, VAR_10;", "int VAR_11[NELLY_BUF_LEN];", "unsigned char VAR_12;", "init_get_bits(&VAR_0->gb, VAR_1, NELLY_BLOCK_LEN * 8);", "VAR_7 = VAR_5;", "VAR_8 = pows;", "VAR_9 = nelly_init_table[get_bits(&VAR_0->gb, 6)];", "for (VAR_3=0 ; VAR_3<NELLY_BANDS ; VAR_3++) {", "if (VAR_3 > 0)\nVAR_9 += nelly_delta_table[get_bits(&VAR_0->gb, 5)];", "VAR_10 = pow(2, VAR_9/2048);", "for (VAR_4 = 0; VAR_4 < nelly_band_sizes_table[VAR_3]; VAR_4++) {", "*VAR_7++ = VAR_9;", "*VAR_8++ = VAR_10;", "}", "}", "get_sample_bits(VAR_5, VAR_11);", "for (VAR_3 = 0; VAR_3 < 2; VAR_3++) {", "VAR_6 = VAR_2 + VAR_3 * NELLY_BUF_LEN;", "init_get_bits(&VAR_0->gb, VAR_1, NELLY_BLOCK_LEN * 8);", "skip_bits(&VAR_0->gb, NELLY_HEADER_BITS + VAR_3*NELLY_DETAIL_BITS);", "for (VAR_4 = 0; VAR_4 < NELLY_FILL_LEN; VAR_4++) {", "if (VAR_11[VAR_4] <= 0) {", "VAR_6[VAR_4] = M_SQRT1_2*pows[VAR_4];", "if (av_random(&VAR_0->random_state) & 1)\nVAR_6[VAR_4] *= -1.0;", "} else {", "VAR_12 = get_bits(&VAR_0->gb, VAR_11[VAR_4]);", "VAR_6[VAR_4] = dequantization_table[(1<<VAR_11[VAR_4])-1+VAR_12]*pows[VAR_4];", "}", "}", "memset(&VAR_6[NELLY_FILL_LEN], 0,\n(NELLY_BUF_LEN - NELLY_FILL_LEN) * sizeof(float));", "VAR_0->imdct_ctx.fft.imdct_calc(&VAR_0->imdct_ctx, VAR_0->imdct_out,\nVAR_6, VAR_0->imdct_tmp);", "for(VAR_4 = 0; VAR_4 < NELLY_BUF_LEN / 2; VAR_4++) {", "VAR_6[VAR_4] = VAR_0->imdct_out[VAR_4 + NELLY_BUF_LEN + NELLY_BUF_LEN / 2];", "VAR_6[VAR_4 + NELLY_BUF_LEN / 2] = VAR_0->imdct_out[VAR_4];", "}", "overlap_and_window(VAR_0, VAR_0->state, VAR_6);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29, 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 49 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71, 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85, 87 ], [ 91, 93 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ] ]
9,320
AioContext *qemu_get_aio_context(void) { return qemu_aio_context; }
false
qemu
c2b38b277a7882a592f4f2ec955084b2b756daaa
AioContext *qemu_get_aio_context(void) { return qemu_aio_context; }
{ "code": [], "line_no": [] }
AioContext *FUNC_0(void) { return qemu_aio_context; }
[ "AioContext *FUNC_0(void)\n{", "return qemu_aio_context;", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
9,321
void bios_linker_loader_add_checksum(GArray *linker, const char *file, void *table, void *start, unsigned size, uint8_t *checksum) { BiosLinkerLoaderEntry entry; memset(&entry, 0, sizeof entry); strncpy(entry.cksum.file, file, sizeof entry.cksum.file - 1); entry.command = cpu_to_le32(BIOS_LINKER_LOADER_COMMAND_ADD_CHECKSUM); entry.cksum.offset = cpu_to_le32(checksum - (uint8_t *)table); entry.cksum.start = cpu_to_le32((uint8_t *)start - (uint8_t *)table); entry.cksum.length = cpu_to_le32(size); g_array_append_val(linker, entry); }
false
qemu
fd8f5e37557596e14a859d8edf3dc24523bd4400
void bios_linker_loader_add_checksum(GArray *linker, const char *file, void *table, void *start, unsigned size, uint8_t *checksum) { BiosLinkerLoaderEntry entry; memset(&entry, 0, sizeof entry); strncpy(entry.cksum.file, file, sizeof entry.cksum.file - 1); entry.command = cpu_to_le32(BIOS_LINKER_LOADER_COMMAND_ADD_CHECKSUM); entry.cksum.offset = cpu_to_le32(checksum - (uint8_t *)table); entry.cksum.start = cpu_to_le32((uint8_t *)start - (uint8_t *)table); entry.cksum.length = cpu_to_le32(size); g_array_append_val(linker, entry); }
{ "code": [], "line_no": [] }
void FUNC_0(GArray *VAR_0, const char *VAR_1, void *VAR_2, void *VAR_3, unsigned VAR_4, uint8_t *VAR_5) { BiosLinkerLoaderEntry entry; memset(&entry, 0, sizeof entry); strncpy(entry.cksum.VAR_1, VAR_1, sizeof entry.cksum.VAR_1 - 1); entry.command = cpu_to_le32(BIOS_LINKER_LOADER_COMMAND_ADD_CHECKSUM); entry.cksum.offset = cpu_to_le32(VAR_5 - (uint8_t *)VAR_2); entry.cksum.VAR_3 = cpu_to_le32((uint8_t *)VAR_3 - (uint8_t *)VAR_2); entry.cksum.length = cpu_to_le32(VAR_4); g_array_append_val(VAR_0, entry); }
[ "void FUNC_0(GArray *VAR_0, const char *VAR_1,\nvoid *VAR_2,\nvoid *VAR_3, unsigned VAR_4,\nuint8_t *VAR_5)\n{", "BiosLinkerLoaderEntry entry;", "memset(&entry, 0, sizeof entry);", "strncpy(entry.cksum.VAR_1, VAR_1, sizeof entry.cksum.VAR_1 - 1);", "entry.command = cpu_to_le32(BIOS_LINKER_LOADER_COMMAND_ADD_CHECKSUM);", "entry.cksum.offset = cpu_to_le32(VAR_5 - (uint8_t *)VAR_2);", "entry.cksum.VAR_3 = cpu_to_le32((uint8_t *)VAR_3 - (uint8_t *)VAR_2);", "entry.cksum.length = cpu_to_le32(VAR_4);", "g_array_append_val(VAR_0, entry);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ] ]
9,322
void build_legacy_cpu_hotplug_aml(Aml *ctx, MachineState *machine, uint16_t io_base, uint16_t io_len) { Aml *dev; Aml *crs; Aml *pkg; Aml *field; Aml *method; Aml *if_ctx; Aml *else_ctx; int i, apic_idx; Aml *sb_scope = aml_scope("_SB"); uint8_t madt_tmpl[8] = {0x00, 0x08, 0x00, 0x00, 0x00, 0, 0, 0}; Aml *cpu_id = aml_arg(0); Aml *cpu_on = aml_local(0); Aml *madt = aml_local(1); Aml *cpus_map = aml_name(CPU_ON_BITMAP); Aml *zero = aml_int(0); Aml *one = aml_int(1); MachineClass *mc = MACHINE_GET_CLASS(machine); CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(machine); PCMachineState *pcms = PC_MACHINE(machine); /* * _MAT method - creates an madt apic buffer * cpu_id = Arg0 = Processor ID = Local APIC ID * cpu_on = Local0 = CPON flag for this cpu * madt = Local1 = Buffer (in madt apic form) to return */ method = aml_method(CPU_MAT_METHOD, 1, AML_NOTSERIALIZED); aml_append(method, aml_store(aml_derefof(aml_index(cpus_map, cpu_id)), cpu_on)); aml_append(method, aml_store(aml_buffer(sizeof(madt_tmpl), madt_tmpl), madt)); /* Update the processor id, lapic id, and enable/disable status */ aml_append(method, aml_store(cpu_id, aml_index(madt, aml_int(2)))); aml_append(method, aml_store(cpu_id, aml_index(madt, aml_int(3)))); aml_append(method, aml_store(cpu_on, aml_index(madt, aml_int(4)))); aml_append(method, aml_return(madt)); aml_append(sb_scope, method); /* * _STA method - return ON status of cpu * cpu_id = Arg0 = Processor ID = Local APIC ID * cpu_on = Local0 = CPON flag for this cpu */ method = aml_method(CPU_STATUS_METHOD, 1, AML_NOTSERIALIZED); aml_append(method, aml_store(aml_derefof(aml_index(cpus_map, cpu_id)), cpu_on)); if_ctx = aml_if(cpu_on); { aml_append(if_ctx, aml_return(aml_int(0xF))); } aml_append(method, if_ctx); else_ctx = aml_else(); { aml_append(else_ctx, aml_return(zero)); } aml_append(method, else_ctx); aml_append(sb_scope, method); method = aml_method(CPU_EJECT_METHOD, 2, AML_NOTSERIALIZED); aml_append(method, aml_sleep(200)); aml_append(sb_scope, method); method = aml_method(CPU_SCAN_METHOD, 0, AML_NOTSERIALIZED); { Aml *while_ctx, *if_ctx2, *else_ctx2; Aml *bus_check_evt = aml_int(1); Aml *remove_evt = aml_int(3); Aml *status_map = aml_local(5); /* Local5 = active cpu bitmap */ Aml *byte = aml_local(2); /* Local2 = last read byte from bitmap */ Aml *idx = aml_local(0); /* Processor ID / APIC ID iterator */ Aml *is_cpu_on = aml_local(1); /* Local1 = CPON flag for cpu */ Aml *status = aml_local(3); /* Local3 = active state for cpu */ aml_append(method, aml_store(aml_name(CPU_STATUS_MAP), status_map)); aml_append(method, aml_store(zero, byte)); aml_append(method, aml_store(zero, idx)); /* While (idx < SizeOf(CPON)) */ while_ctx = aml_while(aml_lless(idx, aml_sizeof(cpus_map))); aml_append(while_ctx, aml_store(aml_derefof(aml_index(cpus_map, idx)), is_cpu_on)); if_ctx = aml_if(aml_and(idx, aml_int(0x07), NULL)); { /* Shift down previously read bitmap byte */ aml_append(if_ctx, aml_shiftright(byte, one, byte)); } aml_append(while_ctx, if_ctx); else_ctx = aml_else(); { /* Read next byte from cpu bitmap */ aml_append(else_ctx, aml_store(aml_derefof(aml_index(status_map, aml_shiftright(idx, aml_int(3), NULL))), byte)); } aml_append(while_ctx, else_ctx); aml_append(while_ctx, aml_store(aml_and(byte, one, NULL), status)); if_ctx = aml_if(aml_lnot(aml_equal(is_cpu_on, status))); { /* State change - update CPON with new state */ aml_append(if_ctx, aml_store(status, aml_index(cpus_map, idx))); if_ctx2 = aml_if(aml_equal(status, one)); { aml_append(if_ctx2, aml_call2(AML_NOTIFY_METHOD, idx, bus_check_evt)); } aml_append(if_ctx, if_ctx2); else_ctx2 = aml_else(); { aml_append(else_ctx2, aml_call2(AML_NOTIFY_METHOD, idx, remove_evt)); } } aml_append(if_ctx, else_ctx2); aml_append(while_ctx, if_ctx); aml_append(while_ctx, aml_increment(idx)); /* go to next cpu */ aml_append(method, while_ctx); } aml_append(sb_scope, method); /* The current AML generator can cover the APIC ID range [0..255], * inclusive, for VCPU hotplug. */ QEMU_BUILD_BUG_ON(ACPI_CPU_HOTPLUG_ID_LIMIT > 256); g_assert(pcms->apic_id_limit <= ACPI_CPU_HOTPLUG_ID_LIMIT); /* create PCI0.PRES device and its _CRS to reserve CPU hotplug MMIO */ dev = aml_device("PCI0." stringify(CPU_HOTPLUG_RESOURCE_DEVICE)); aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A06"))); aml_append(dev, aml_name_decl("_UID", aml_string("CPU Hotplug resources")) ); /* device present, functioning, decoding, not shown in UI */ aml_append(dev, aml_name_decl("_STA", aml_int(0xB))); crs = aml_resource_template(); aml_append(crs, aml_io(AML_DECODE16, io_base, io_base, 1, io_len) ); aml_append(dev, aml_name_decl("_CRS", crs)); aml_append(sb_scope, dev); /* declare CPU hotplug MMIO region and PRS field to access it */ aml_append(sb_scope, aml_operation_region( "PRST", AML_SYSTEM_IO, aml_int(io_base), io_len)); field = aml_field("PRST", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE); aml_append(field, aml_named_field("PRS", 256)); aml_append(sb_scope, field); /* build Processor object for each processor */ for (i = 0; i < apic_ids->len; i++) { int apic_id = apic_ids->cpus[i].arch_id; assert(apic_id < ACPI_CPU_HOTPLUG_ID_LIMIT); dev = aml_processor(apic_id, 0, 0, "CP%.02X", apic_id); method = aml_method("_MAT", 0, AML_NOTSERIALIZED); aml_append(method, aml_return(aml_call1(CPU_MAT_METHOD, aml_int(apic_id)))); aml_append(dev, method); method = aml_method("_STA", 0, AML_NOTSERIALIZED); aml_append(method, aml_return(aml_call1(CPU_STATUS_METHOD, aml_int(apic_id)))); aml_append(dev, method); method = aml_method("_EJ0", 1, AML_NOTSERIALIZED); aml_append(method, aml_return(aml_call2(CPU_EJECT_METHOD, aml_int(apic_id), aml_arg(0))) ); aml_append(dev, method); aml_append(sb_scope, dev); } /* build this code: * Method(NTFY, 2) {If (LEqual(Arg0, 0x00)) {Notify(CP00, Arg1)} ...} */ /* Arg0 = Processor ID = APIC ID */ method = aml_method(AML_NOTIFY_METHOD, 2, AML_NOTSERIALIZED); for (i = 0; i < apic_ids->len; i++) { int apic_id = apic_ids->cpus[i].arch_id; if_ctx = aml_if(aml_equal(aml_arg(0), aml_int(apic_id))); aml_append(if_ctx, aml_notify(aml_name("CP%.02X", apic_id), aml_arg(1)) ); aml_append(method, if_ctx); } aml_append(sb_scope, method); /* build "Name(CPON, Package() { One, One, ..., Zero, Zero, ... })" * * Note: The ability to create variable-sized packages was first * introduced in ACPI 2.0. ACPI 1.0 only allowed fixed-size packages * ith up to 255 elements. Windows guests up to win2k8 fail when * VarPackageOp is used. */ pkg = pcms->apic_id_limit <= 255 ? aml_package(pcms->apic_id_limit) : aml_varpackage(pcms->apic_id_limit); for (i = 0, apic_idx = 0; i < apic_ids->len; i++) { int apic_id = apic_ids->cpus[i].arch_id; for (; apic_idx < apic_id; apic_idx++) { aml_append(pkg, aml_int(0)); } aml_append(pkg, aml_int(apic_ids->cpus[i].cpu ? 1 : 0)); apic_idx = apic_id + 1; } aml_append(sb_scope, aml_name_decl(CPU_ON_BITMAP, pkg)); g_free(apic_ids); aml_append(ctx, sb_scope); method = aml_method("\\_GPE._E02", 0, AML_NOTSERIALIZED); aml_append(method, aml_call0("\\_SB." CPU_SCAN_METHOD)); aml_append(ctx, method); }
false
qemu
ebd8ea82441020f2781928b17f37ed9a0d2e4250
void build_legacy_cpu_hotplug_aml(Aml *ctx, MachineState *machine, uint16_t io_base, uint16_t io_len) { Aml *dev; Aml *crs; Aml *pkg; Aml *field; Aml *method; Aml *if_ctx; Aml *else_ctx; int i, apic_idx; Aml *sb_scope = aml_scope("_SB"); uint8_t madt_tmpl[8] = {0x00, 0x08, 0x00, 0x00, 0x00, 0, 0, 0}; Aml *cpu_id = aml_arg(0); Aml *cpu_on = aml_local(0); Aml *madt = aml_local(1); Aml *cpus_map = aml_name(CPU_ON_BITMAP); Aml *zero = aml_int(0); Aml *one = aml_int(1); MachineClass *mc = MACHINE_GET_CLASS(machine); CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(machine); PCMachineState *pcms = PC_MACHINE(machine); method = aml_method(CPU_MAT_METHOD, 1, AML_NOTSERIALIZED); aml_append(method, aml_store(aml_derefof(aml_index(cpus_map, cpu_id)), cpu_on)); aml_append(method, aml_store(aml_buffer(sizeof(madt_tmpl), madt_tmpl), madt)); aml_append(method, aml_store(cpu_id, aml_index(madt, aml_int(2)))); aml_append(method, aml_store(cpu_id, aml_index(madt, aml_int(3)))); aml_append(method, aml_store(cpu_on, aml_index(madt, aml_int(4)))); aml_append(method, aml_return(madt)); aml_append(sb_scope, method); method = aml_method(CPU_STATUS_METHOD, 1, AML_NOTSERIALIZED); aml_append(method, aml_store(aml_derefof(aml_index(cpus_map, cpu_id)), cpu_on)); if_ctx = aml_if(cpu_on); { aml_append(if_ctx, aml_return(aml_int(0xF))); } aml_append(method, if_ctx); else_ctx = aml_else(); { aml_append(else_ctx, aml_return(zero)); } aml_append(method, else_ctx); aml_append(sb_scope, method); method = aml_method(CPU_EJECT_METHOD, 2, AML_NOTSERIALIZED); aml_append(method, aml_sleep(200)); aml_append(sb_scope, method); method = aml_method(CPU_SCAN_METHOD, 0, AML_NOTSERIALIZED); { Aml *while_ctx, *if_ctx2, *else_ctx2; Aml *bus_check_evt = aml_int(1); Aml *remove_evt = aml_int(3); Aml *status_map = aml_local(5); Aml *byte = aml_local(2); Aml *idx = aml_local(0); Aml *is_cpu_on = aml_local(1); Aml *status = aml_local(3); aml_append(method, aml_store(aml_name(CPU_STATUS_MAP), status_map)); aml_append(method, aml_store(zero, byte)); aml_append(method, aml_store(zero, idx)); while_ctx = aml_while(aml_lless(idx, aml_sizeof(cpus_map))); aml_append(while_ctx, aml_store(aml_derefof(aml_index(cpus_map, idx)), is_cpu_on)); if_ctx = aml_if(aml_and(idx, aml_int(0x07), NULL)); { aml_append(if_ctx, aml_shiftright(byte, one, byte)); } aml_append(while_ctx, if_ctx); else_ctx = aml_else(); { aml_append(else_ctx, aml_store(aml_derefof(aml_index(status_map, aml_shiftright(idx, aml_int(3), NULL))), byte)); } aml_append(while_ctx, else_ctx); aml_append(while_ctx, aml_store(aml_and(byte, one, NULL), status)); if_ctx = aml_if(aml_lnot(aml_equal(is_cpu_on, status))); { aml_append(if_ctx, aml_store(status, aml_index(cpus_map, idx))); if_ctx2 = aml_if(aml_equal(status, one)); { aml_append(if_ctx2, aml_call2(AML_NOTIFY_METHOD, idx, bus_check_evt)); } aml_append(if_ctx, if_ctx2); else_ctx2 = aml_else(); { aml_append(else_ctx2, aml_call2(AML_NOTIFY_METHOD, idx, remove_evt)); } } aml_append(if_ctx, else_ctx2); aml_append(while_ctx, if_ctx); aml_append(while_ctx, aml_increment(idx)); aml_append(method, while_ctx); } aml_append(sb_scope, method); QEMU_BUILD_BUG_ON(ACPI_CPU_HOTPLUG_ID_LIMIT > 256); g_assert(pcms->apic_id_limit <= ACPI_CPU_HOTPLUG_ID_LIMIT); dev = aml_device("PCI0." stringify(CPU_HOTPLUG_RESOURCE_DEVICE)); aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A06"))); aml_append(dev, aml_name_decl("_UID", aml_string("CPU Hotplug resources")) ); aml_append(dev, aml_name_decl("_STA", aml_int(0xB))); crs = aml_resource_template(); aml_append(crs, aml_io(AML_DECODE16, io_base, io_base, 1, io_len) ); aml_append(dev, aml_name_decl("_CRS", crs)); aml_append(sb_scope, dev); aml_append(sb_scope, aml_operation_region( "PRST", AML_SYSTEM_IO, aml_int(io_base), io_len)); field = aml_field("PRST", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE); aml_append(field, aml_named_field("PRS", 256)); aml_append(sb_scope, field); for (i = 0; i < apic_ids->len; i++) { int apic_id = apic_ids->cpus[i].arch_id; assert(apic_id < ACPI_CPU_HOTPLUG_ID_LIMIT); dev = aml_processor(apic_id, 0, 0, "CP%.02X", apic_id); method = aml_method("_MAT", 0, AML_NOTSERIALIZED); aml_append(method, aml_return(aml_call1(CPU_MAT_METHOD, aml_int(apic_id)))); aml_append(dev, method); method = aml_method("_STA", 0, AML_NOTSERIALIZED); aml_append(method, aml_return(aml_call1(CPU_STATUS_METHOD, aml_int(apic_id)))); aml_append(dev, method); method = aml_method("_EJ0", 1, AML_NOTSERIALIZED); aml_append(method, aml_return(aml_call2(CPU_EJECT_METHOD, aml_int(apic_id), aml_arg(0))) ); aml_append(dev, method); aml_append(sb_scope, dev); } method = aml_method(AML_NOTIFY_METHOD, 2, AML_NOTSERIALIZED); for (i = 0; i < apic_ids->len; i++) { int apic_id = apic_ids->cpus[i].arch_id; if_ctx = aml_if(aml_equal(aml_arg(0), aml_int(apic_id))); aml_append(if_ctx, aml_notify(aml_name("CP%.02X", apic_id), aml_arg(1)) ); aml_append(method, if_ctx); } aml_append(sb_scope, method); pkg = pcms->apic_id_limit <= 255 ? aml_package(pcms->apic_id_limit) : aml_varpackage(pcms->apic_id_limit); for (i = 0, apic_idx = 0; i < apic_ids->len; i++) { int apic_id = apic_ids->cpus[i].arch_id; for (; apic_idx < apic_id; apic_idx++) { aml_append(pkg, aml_int(0)); } aml_append(pkg, aml_int(apic_ids->cpus[i].cpu ? 1 : 0)); apic_idx = apic_id + 1; } aml_append(sb_scope, aml_name_decl(CPU_ON_BITMAP, pkg)); g_free(apic_ids); aml_append(ctx, sb_scope); method = aml_method("\\_GPE._E02", 0, AML_NOTSERIALIZED); aml_append(method, aml_call0("\\_SB." CPU_SCAN_METHOD)); aml_append(ctx, method); }
{ "code": [], "line_no": [] }
void FUNC_0(Aml *VAR_0, MachineState *VAR_1, uint16_t VAR_2, uint16_t VAR_3) { Aml *dev; Aml *crs; Aml *pkg; Aml *field; Aml *method; Aml *if_ctx; Aml *else_ctx; int VAR_4, VAR_5; Aml *sb_scope = aml_scope("_SB"); uint8_t madt_tmpl[8] = {0x00, 0x08, 0x00, 0x00, 0x00, 0, 0, 0}; Aml *cpu_id = aml_arg(0); Aml *cpu_on = aml_local(0); Aml *madt = aml_local(1); Aml *cpus_map = aml_name(CPU_ON_BITMAP); Aml *zero = aml_int(0); Aml *one = aml_int(1); MachineClass *mc = MACHINE_GET_CLASS(VAR_1); CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(VAR_1); PCMachineState *pcms = PC_MACHINE(VAR_1); method = aml_method(CPU_MAT_METHOD, 1, AML_NOTSERIALIZED); aml_append(method, aml_store(aml_derefof(aml_index(cpus_map, cpu_id)), cpu_on)); aml_append(method, aml_store(aml_buffer(sizeof(madt_tmpl), madt_tmpl), madt)); aml_append(method, aml_store(cpu_id, aml_index(madt, aml_int(2)))); aml_append(method, aml_store(cpu_id, aml_index(madt, aml_int(3)))); aml_append(method, aml_store(cpu_on, aml_index(madt, aml_int(4)))); aml_append(method, aml_return(madt)); aml_append(sb_scope, method); method = aml_method(CPU_STATUS_METHOD, 1, AML_NOTSERIALIZED); aml_append(method, aml_store(aml_derefof(aml_index(cpus_map, cpu_id)), cpu_on)); if_ctx = aml_if(cpu_on); { aml_append(if_ctx, aml_return(aml_int(0xF))); } aml_append(method, if_ctx); else_ctx = aml_else(); { aml_append(else_ctx, aml_return(zero)); } aml_append(method, else_ctx); aml_append(sb_scope, method); method = aml_method(CPU_EJECT_METHOD, 2, AML_NOTSERIALIZED); aml_append(method, aml_sleep(200)); aml_append(sb_scope, method); method = aml_method(CPU_SCAN_METHOD, 0, AML_NOTSERIALIZED); { Aml *while_ctx, *if_ctx2, *else_ctx2; Aml *bus_check_evt = aml_int(1); Aml *remove_evt = aml_int(3); Aml *status_map = aml_local(5); Aml *byte = aml_local(2); Aml *idx = aml_local(0); Aml *is_cpu_on = aml_local(1); Aml *status = aml_local(3); aml_append(method, aml_store(aml_name(CPU_STATUS_MAP), status_map)); aml_append(method, aml_store(zero, byte)); aml_append(method, aml_store(zero, idx)); while_ctx = aml_while(aml_lless(idx, aml_sizeof(cpus_map))); aml_append(while_ctx, aml_store(aml_derefof(aml_index(cpus_map, idx)), is_cpu_on)); if_ctx = aml_if(aml_and(idx, aml_int(0x07), NULL)); { aml_append(if_ctx, aml_shiftright(byte, one, byte)); } aml_append(while_ctx, if_ctx); else_ctx = aml_else(); { aml_append(else_ctx, aml_store(aml_derefof(aml_index(status_map, aml_shiftright(idx, aml_int(3), NULL))), byte)); } aml_append(while_ctx, else_ctx); aml_append(while_ctx, aml_store(aml_and(byte, one, NULL), status)); if_ctx = aml_if(aml_lnot(aml_equal(is_cpu_on, status))); { aml_append(if_ctx, aml_store(status, aml_index(cpus_map, idx))); if_ctx2 = aml_if(aml_equal(status, one)); { aml_append(if_ctx2, aml_call2(AML_NOTIFY_METHOD, idx, bus_check_evt)); } aml_append(if_ctx, if_ctx2); else_ctx2 = aml_else(); { aml_append(else_ctx2, aml_call2(AML_NOTIFY_METHOD, idx, remove_evt)); } } aml_append(if_ctx, else_ctx2); aml_append(while_ctx, if_ctx); aml_append(while_ctx, aml_increment(idx)); aml_append(method, while_ctx); } aml_append(sb_scope, method); QEMU_BUILD_BUG_ON(ACPI_CPU_HOTPLUG_ID_LIMIT > 256); g_assert(pcms->apic_id_limit <= ACPI_CPU_HOTPLUG_ID_LIMIT); dev = aml_device("PCI0." stringify(CPU_HOTPLUG_RESOURCE_DEVICE)); aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A06"))); aml_append(dev, aml_name_decl("_UID", aml_string("CPU Hotplug resources")) ); aml_append(dev, aml_name_decl("_STA", aml_int(0xB))); crs = aml_resource_template(); aml_append(crs, aml_io(AML_DECODE16, VAR_2, VAR_2, 1, VAR_3) ); aml_append(dev, aml_name_decl("_CRS", crs)); aml_append(sb_scope, dev); aml_append(sb_scope, aml_operation_region( "PRST", AML_SYSTEM_IO, aml_int(VAR_2), VAR_3)); field = aml_field("PRST", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE); aml_append(field, aml_named_field("PRS", 256)); aml_append(sb_scope, field); for (VAR_4 = 0; VAR_4 < apic_ids->len; VAR_4++) { int apic_id = apic_ids->cpus[VAR_4].arch_id; assert(apic_id < ACPI_CPU_HOTPLUG_ID_LIMIT); dev = aml_processor(apic_id, 0, 0, "CP%.02X", apic_id); method = aml_method("_MAT", 0, AML_NOTSERIALIZED); aml_append(method, aml_return(aml_call1(CPU_MAT_METHOD, aml_int(apic_id)))); aml_append(dev, method); method = aml_method("_STA", 0, AML_NOTSERIALIZED); aml_append(method, aml_return(aml_call1(CPU_STATUS_METHOD, aml_int(apic_id)))); aml_append(dev, method); method = aml_method("_EJ0", 1, AML_NOTSERIALIZED); aml_append(method, aml_return(aml_call2(CPU_EJECT_METHOD, aml_int(apic_id), aml_arg(0))) ); aml_append(dev, method); aml_append(sb_scope, dev); } method = aml_method(AML_NOTIFY_METHOD, 2, AML_NOTSERIALIZED); for (VAR_4 = 0; VAR_4 < apic_ids->len; VAR_4++) { int apic_id = apic_ids->cpus[VAR_4].arch_id; if_ctx = aml_if(aml_equal(aml_arg(0), aml_int(apic_id))); aml_append(if_ctx, aml_notify(aml_name("CP%.02X", apic_id), aml_arg(1)) ); aml_append(method, if_ctx); } aml_append(sb_scope, method); pkg = pcms->apic_id_limit <= 255 ? aml_package(pcms->apic_id_limit) : aml_varpackage(pcms->apic_id_limit); for (VAR_4 = 0, VAR_5 = 0; VAR_4 < apic_ids->len; VAR_4++) { int apic_id = apic_ids->cpus[VAR_4].arch_id; for (; VAR_5 < apic_id; VAR_5++) { aml_append(pkg, aml_int(0)); } aml_append(pkg, aml_int(apic_ids->cpus[VAR_4].cpu ? 1 : 0)); VAR_5 = apic_id + 1; } aml_append(sb_scope, aml_name_decl(CPU_ON_BITMAP, pkg)); g_free(apic_ids); aml_append(VAR_0, sb_scope); method = aml_method("\\_GPE._E02", 0, AML_NOTSERIALIZED); aml_append(method, aml_call0("\\_SB." CPU_SCAN_METHOD)); aml_append(VAR_0, method); }
[ "void FUNC_0(Aml *VAR_0, MachineState *VAR_1,\nuint16_t VAR_2, uint16_t VAR_3)\n{", "Aml *dev;", "Aml *crs;", "Aml *pkg;", "Aml *field;", "Aml *method;", "Aml *if_ctx;", "Aml *else_ctx;", "int VAR_4, VAR_5;", "Aml *sb_scope = aml_scope(\"_SB\");", "uint8_t madt_tmpl[8] = {0x00, 0x08, 0x00, 0x00, 0x00, 0, 0, 0};", "Aml *cpu_id = aml_arg(0);", "Aml *cpu_on = aml_local(0);", "Aml *madt = aml_local(1);", "Aml *cpus_map = aml_name(CPU_ON_BITMAP);", "Aml *zero = aml_int(0);", "Aml *one = aml_int(1);", "MachineClass *mc = MACHINE_GET_CLASS(VAR_1);", "CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(VAR_1);", "PCMachineState *pcms = PC_MACHINE(VAR_1);", "method = aml_method(CPU_MAT_METHOD, 1, AML_NOTSERIALIZED);", "aml_append(method,\naml_store(aml_derefof(aml_index(cpus_map, cpu_id)), cpu_on));", "aml_append(method,\naml_store(aml_buffer(sizeof(madt_tmpl), madt_tmpl), madt));", "aml_append(method, aml_store(cpu_id, aml_index(madt, aml_int(2))));", "aml_append(method, aml_store(cpu_id, aml_index(madt, aml_int(3))));", "aml_append(method, aml_store(cpu_on, aml_index(madt, aml_int(4))));", "aml_append(method, aml_return(madt));", "aml_append(sb_scope, method);", "method = aml_method(CPU_STATUS_METHOD, 1, AML_NOTSERIALIZED);", "aml_append(method,\naml_store(aml_derefof(aml_index(cpus_map, cpu_id)), cpu_on));", "if_ctx = aml_if(cpu_on);", "{", "aml_append(if_ctx, aml_return(aml_int(0xF)));", "}", "aml_append(method, if_ctx);", "else_ctx = aml_else();", "{", "aml_append(else_ctx, aml_return(zero));", "}", "aml_append(method, else_ctx);", "aml_append(sb_scope, method);", "method = aml_method(CPU_EJECT_METHOD, 2, AML_NOTSERIALIZED);", "aml_append(method, aml_sleep(200));", "aml_append(sb_scope, method);", "method = aml_method(CPU_SCAN_METHOD, 0, AML_NOTSERIALIZED);", "{", "Aml *while_ctx, *if_ctx2, *else_ctx2;", "Aml *bus_check_evt = aml_int(1);", "Aml *remove_evt = aml_int(3);", "Aml *status_map = aml_local(5);", "Aml *byte = aml_local(2);", "Aml *idx = aml_local(0);", "Aml *is_cpu_on = aml_local(1);", "Aml *status = aml_local(3);", "aml_append(method, aml_store(aml_name(CPU_STATUS_MAP), status_map));", "aml_append(method, aml_store(zero, byte));", "aml_append(method, aml_store(zero, idx));", "while_ctx = aml_while(aml_lless(idx, aml_sizeof(cpus_map)));", "aml_append(while_ctx,\naml_store(aml_derefof(aml_index(cpus_map, idx)), is_cpu_on));", "if_ctx = aml_if(aml_and(idx, aml_int(0x07), NULL));", "{", "aml_append(if_ctx, aml_shiftright(byte, one, byte));", "}", "aml_append(while_ctx, if_ctx);", "else_ctx = aml_else();", "{", "aml_append(else_ctx, aml_store(aml_derefof(aml_index(status_map,\naml_shiftright(idx, aml_int(3), NULL))), byte));", "}", "aml_append(while_ctx, else_ctx);", "aml_append(while_ctx, aml_store(aml_and(byte, one, NULL), status));", "if_ctx = aml_if(aml_lnot(aml_equal(is_cpu_on, status)));", "{", "aml_append(if_ctx, aml_store(status, aml_index(cpus_map, idx)));", "if_ctx2 = aml_if(aml_equal(status, one));", "{", "aml_append(if_ctx2,\naml_call2(AML_NOTIFY_METHOD, idx, bus_check_evt));", "}", "aml_append(if_ctx, if_ctx2);", "else_ctx2 = aml_else();", "{", "aml_append(else_ctx2,\naml_call2(AML_NOTIFY_METHOD, idx, remove_evt));", "}", "}", "aml_append(if_ctx, else_ctx2);", "aml_append(while_ctx, if_ctx);", "aml_append(while_ctx, aml_increment(idx));", "aml_append(method, while_ctx);", "}", "aml_append(sb_scope, method);", "QEMU_BUILD_BUG_ON(ACPI_CPU_HOTPLUG_ID_LIMIT > 256);", "g_assert(pcms->apic_id_limit <= ACPI_CPU_HOTPLUG_ID_LIMIT);", "dev = aml_device(\"PCI0.\" stringify(CPU_HOTPLUG_RESOURCE_DEVICE));", "aml_append(dev, aml_name_decl(\"_HID\", aml_eisaid(\"PNP0A06\")));", "aml_append(dev,\naml_name_decl(\"_UID\", aml_string(\"CPU Hotplug resources\"))\n);", "aml_append(dev, aml_name_decl(\"_STA\", aml_int(0xB)));", "crs = aml_resource_template();", "aml_append(crs,\naml_io(AML_DECODE16, VAR_2, VAR_2, 1, VAR_3)\n);", "aml_append(dev, aml_name_decl(\"_CRS\", crs));", "aml_append(sb_scope, dev);", "aml_append(sb_scope, aml_operation_region(\n\"PRST\", AML_SYSTEM_IO, aml_int(VAR_2), VAR_3));", "field = aml_field(\"PRST\", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);", "aml_append(field, aml_named_field(\"PRS\", 256));", "aml_append(sb_scope, field);", "for (VAR_4 = 0; VAR_4 < apic_ids->len; VAR_4++) {", "int apic_id = apic_ids->cpus[VAR_4].arch_id;", "assert(apic_id < ACPI_CPU_HOTPLUG_ID_LIMIT);", "dev = aml_processor(apic_id, 0, 0, \"CP%.02X\", apic_id);", "method = aml_method(\"_MAT\", 0, AML_NOTSERIALIZED);", "aml_append(method,\naml_return(aml_call1(CPU_MAT_METHOD, aml_int(apic_id))));", "aml_append(dev, method);", "method = aml_method(\"_STA\", 0, AML_NOTSERIALIZED);", "aml_append(method,\naml_return(aml_call1(CPU_STATUS_METHOD, aml_int(apic_id))));", "aml_append(dev, method);", "method = aml_method(\"_EJ0\", 1, AML_NOTSERIALIZED);", "aml_append(method,\naml_return(aml_call2(CPU_EJECT_METHOD, aml_int(apic_id),\naml_arg(0)))\n);", "aml_append(dev, method);", "aml_append(sb_scope, dev);", "}", "method = aml_method(AML_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);", "for (VAR_4 = 0; VAR_4 < apic_ids->len; VAR_4++) {", "int apic_id = apic_ids->cpus[VAR_4].arch_id;", "if_ctx = aml_if(aml_equal(aml_arg(0), aml_int(apic_id)));", "aml_append(if_ctx,\naml_notify(aml_name(\"CP%.02X\", apic_id), aml_arg(1))\n);", "aml_append(method, if_ctx);", "}", "aml_append(sb_scope, method);", "pkg = pcms->apic_id_limit <= 255 ? aml_package(pcms->apic_id_limit) :\naml_varpackage(pcms->apic_id_limit);", "for (VAR_4 = 0, VAR_5 = 0; VAR_4 < apic_ids->len; VAR_4++) {", "int apic_id = apic_ids->cpus[VAR_4].arch_id;", "for (; VAR_5 < apic_id; VAR_5++) {", "aml_append(pkg, aml_int(0));", "}", "aml_append(pkg, aml_int(apic_ids->cpus[VAR_4].cpu ? 1 : 0));", "VAR_5 = apic_id + 1;", "}", "aml_append(sb_scope, aml_name_decl(CPU_ON_BITMAP, pkg));", "g_free(apic_ids);", "aml_append(VAR_0, sb_scope);", "method = aml_method(\"\\\\_GPE._E02\", 0, AML_NOTSERIALIZED);", "aml_append(method, aml_call0(\"\\\\_SB.\" CPU_SCAN_METHOD));", "aml_append(VAR_0, method);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 59 ], [ 61, 63 ], [ 65, 67 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 93 ], [ 95, 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 123 ], [ 125 ], [ 127 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 153 ], [ 155 ], [ 157 ], [ 163 ], [ 165, 167 ], [ 171 ], [ 173 ], [ 177 ], [ 179 ], [ 181 ], [ 185 ], [ 187 ], [ 191, 193 ], [ 195 ], [ 197 ], [ 201 ], [ 203 ], [ 205 ], [ 209 ], [ 211 ], [ 213 ], [ 215, 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227, 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 255 ], [ 257 ], [ 263 ], [ 265 ], [ 267, 269, 271 ], [ 275 ], [ 277 ], [ 279, 281, 283 ], [ 285 ], [ 287 ], [ 291, 293 ], [ 295 ], [ 297 ], [ 299 ], [ 305 ], [ 307 ], [ 311 ], [ 315 ], [ 319 ], [ 321, 323 ], [ 325 ], [ 329 ], [ 331, 333 ], [ 335 ], [ 339 ], [ 341, 343, 345, 347 ], [ 349 ], [ 353 ], [ 355 ], [ 367 ], [ 369 ], [ 371 ], [ 375 ], [ 377, 379, 381 ], [ 383 ], [ 385 ], [ 387 ], [ 405, 407 ], [ 411 ], [ 413 ], [ 417 ], [ 419 ], [ 421 ], [ 423 ], [ 425 ], [ 427 ], [ 429 ], [ 431 ], [ 435 ], [ 439 ], [ 441 ], [ 443 ], [ 445 ] ]
9,323
static int cirrus_bitblt_solidfill(CirrusVGAState *s, int blt_rop) { cirrus_fill_t rop_func; if (blit_is_unsafe(s, true)) { return 0; } rop_func = cirrus_fill[rop_to_index[blt_rop]][s->cirrus_blt_pixelwidth - 1]; rop_func(s, s->vga.vram_ptr + s->cirrus_blt_dstaddr, s->cirrus_blt_dstpitch, s->cirrus_blt_width, s->cirrus_blt_height); cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, s->cirrus_blt_dstpitch, s->cirrus_blt_width, s->cirrus_blt_height); cirrus_bitblt_reset(s); return 1; }
false
qemu
026aeffcb4752054830ba203020ed6eb05bcaba8
static int cirrus_bitblt_solidfill(CirrusVGAState *s, int blt_rop) { cirrus_fill_t rop_func; if (blit_is_unsafe(s, true)) { return 0; } rop_func = cirrus_fill[rop_to_index[blt_rop]][s->cirrus_blt_pixelwidth - 1]; rop_func(s, s->vga.vram_ptr + s->cirrus_blt_dstaddr, s->cirrus_blt_dstpitch, s->cirrus_blt_width, s->cirrus_blt_height); cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, s->cirrus_blt_dstpitch, s->cirrus_blt_width, s->cirrus_blt_height); cirrus_bitblt_reset(s); return 1; }
{ "code": [], "line_no": [] }
static int FUNC_0(CirrusVGAState *VAR_0, int VAR_1) { cirrus_fill_t rop_func; if (blit_is_unsafe(VAR_0, true)) { return 0; } rop_func = cirrus_fill[rop_to_index[VAR_1]][VAR_0->cirrus_blt_pixelwidth - 1]; rop_func(VAR_0, VAR_0->vga.vram_ptr + VAR_0->cirrus_blt_dstaddr, VAR_0->cirrus_blt_dstpitch, VAR_0->cirrus_blt_width, VAR_0->cirrus_blt_height); cirrus_invalidate_region(VAR_0, VAR_0->cirrus_blt_dstaddr, VAR_0->cirrus_blt_dstpitch, VAR_0->cirrus_blt_width, VAR_0->cirrus_blt_height); cirrus_bitblt_reset(VAR_0); return 1; }
[ "static int FUNC_0(CirrusVGAState *VAR_0, int VAR_1)\n{", "cirrus_fill_t rop_func;", "if (blit_is_unsafe(VAR_0, true)) {", "return 0;", "}", "rop_func = cirrus_fill[rop_to_index[VAR_1]][VAR_0->cirrus_blt_pixelwidth - 1];", "rop_func(VAR_0, VAR_0->vga.vram_ptr + VAR_0->cirrus_blt_dstaddr,\nVAR_0->cirrus_blt_dstpitch,\nVAR_0->cirrus_blt_width, VAR_0->cirrus_blt_height);", "cirrus_invalidate_region(VAR_0, VAR_0->cirrus_blt_dstaddr,\nVAR_0->cirrus_blt_dstpitch, VAR_0->cirrus_blt_width,\nVAR_0->cirrus_blt_height);", "cirrus_bitblt_reset(VAR_0);", "return 1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17, 19, 21 ], [ 23, 25, 27 ], [ 29 ], [ 31 ], [ 33 ] ]
9,324
void OPPROTO op_addw_EDI_T0(void) { EDI = (EDI & ~0xffff) | ((EDI + T0) & 0xffff); }
false
qemu
6e0d8677cb443e7408c0b7a25a93c6596d7fa380
void OPPROTO op_addw_EDI_T0(void) { EDI = (EDI & ~0xffff) | ((EDI + T0) & 0xffff); }
{ "code": [], "line_no": [] }
void VAR_0 op_addw_EDI_T0(void) { EDI = (EDI & ~0xffff) | ((EDI + T0) & 0xffff); }
[ "void VAR_0 op_addw_EDI_T0(void)\n{", "EDI = (EDI & ~0xffff) | ((EDI + T0) & 0xffff);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
9,325
uint64_t helper_fdiv (uint64_t arg1, uint64_t arg2) { CPU_DoubleU farg1, farg2; farg1.ll = arg1; farg2.ll = arg2; #if USE_PRECISE_EMULATION if (unlikely(float64_is_signaling_nan(farg1.d) || float64_is_signaling_nan(farg2.d))) { /* sNaN division */ farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN); } else if (unlikely(float64_is_infinity(farg1.d) && float64_is_infinity(farg2.d))) { /* Division of infinity by infinity */ farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXIDI); } else if (unlikely(!float64_is_nan(farg1.d) && float64_is_zero(farg2.d))) { if (float64_is_zero(farg1.d)) { /* Division of zero by zero */ farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXZDZ); } else { /* Division by zero */ farg1.ll = float_zero_divide_excp(farg1.d, farg2.d); } } else { farg1.d = float64_div(farg1.d, farg2.d, &env->fp_status); } #else farg1.d = float64_div(farg1.d, farg2.d, &env->fp_status); #endif return farg1.ll; }
false
qemu
e33e94f92298c96e0928cefab00ea5bae0a1cd19
uint64_t helper_fdiv (uint64_t arg1, uint64_t arg2) { CPU_DoubleU farg1, farg2; farg1.ll = arg1; farg2.ll = arg2; #if USE_PRECISE_EMULATION if (unlikely(float64_is_signaling_nan(farg1.d) || float64_is_signaling_nan(farg2.d))) { farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN); } else if (unlikely(float64_is_infinity(farg1.d) && float64_is_infinity(farg2.d))) { farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXIDI); } else if (unlikely(!float64_is_nan(farg1.d) && float64_is_zero(farg2.d))) { if (float64_is_zero(farg1.d)) { farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXZDZ); } else { farg1.ll = float_zero_divide_excp(farg1.d, farg2.d); } } else { farg1.d = float64_div(farg1.d, farg2.d, &env->fp_status); } #else farg1.d = float64_div(farg1.d, farg2.d, &env->fp_status); #endif return farg1.ll; }
{ "code": [], "line_no": [] }
uint64_t FUNC_0 (uint64_t arg1, uint64_t arg2) { CPU_DoubleU farg1, farg2; farg1.ll = arg1; farg2.ll = arg2; #if USE_PRECISE_EMULATION if (unlikely(float64_is_signaling_nan(farg1.d) || float64_is_signaling_nan(farg2.d))) { farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN); } else if (unlikely(float64_is_infinity(farg1.d) && float64_is_infinity(farg2.d))) { farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXIDI); } else if (unlikely(!float64_is_nan(farg1.d) && float64_is_zero(farg2.d))) { if (float64_is_zero(farg1.d)) { farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXZDZ); } else { farg1.ll = float_zero_divide_excp(farg1.d, farg2.d); } } else { farg1.d = float64_div(farg1.d, farg2.d, &env->fp_status); } #else farg1.d = float64_div(farg1.d, farg2.d, &env->fp_status); #endif return farg1.ll; }
[ "uint64_t FUNC_0 (uint64_t arg1, uint64_t arg2)\n{", "CPU_DoubleU farg1, farg2;", "farg1.ll = arg1;", "farg2.ll = arg2;", "#if USE_PRECISE_EMULATION\nif (unlikely(float64_is_signaling_nan(farg1.d) ||\nfloat64_is_signaling_nan(farg2.d))) {", "farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN);", "} else if (unlikely(float64_is_infinity(farg1.d) && float64_is_infinity(farg2.d))) {", "farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXIDI);", "} else if (unlikely(!float64_is_nan(farg1.d) && float64_is_zero(farg2.d))) {", "if (float64_is_zero(farg1.d)) {", "farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXZDZ);", "} else {", "farg1.ll = float_zero_divide_excp(farg1.d, farg2.d);", "}", "} else {", "farg1.d = float64_div(farg1.d, farg2.d, &env->fp_status);", "}", "#else\nfarg1.d = float64_div(farg1.d, farg2.d, &env->fp_status);", "#endif\nreturn farg1.ll;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13, 15, 17 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51, 53 ], [ 55, 57 ], [ 59 ] ]
9,326
void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb) { ARMCPU *cpu = arm_env_get_cpu(env); CPUState *cs = CPU(cpu); DisasContext dc1, *dc = &dc1; target_ulong pc_start; target_ulong next_page_start; int num_insns; int max_insns; bool end_of_page; /* generate intermediate code */ /* The A64 decoder has its own top level loop, because it doesn't need * the A32/T32 complexity to do with conditional execution/IT blocks/etc. */ if (ARM_TBFLAG_AARCH64_STATE(tb->flags)) { gen_intermediate_code_a64(cpu, tb); return; } pc_start = tb->pc; dc->tb = tb; dc->is_jmp = DISAS_NEXT; dc->pc = pc_start; dc->singlestep_enabled = cs->singlestep_enabled; dc->condjmp = 0; dc->aarch64 = 0; /* If we are coming from secure EL0 in a system with a 32-bit EL3, then * there is no secure EL1, so we route exceptions to EL3. */ dc->secure_routed_to_el3 = arm_feature(env, ARM_FEATURE_EL3) && !arm_el_is_aa64(env, 3); dc->thumb = ARM_TBFLAG_THUMB(tb->flags); dc->sctlr_b = ARM_TBFLAG_SCTLR_B(tb->flags); dc->be_data = ARM_TBFLAG_BE_DATA(tb->flags) ? MO_BE : MO_LE; dc->condexec_mask = (ARM_TBFLAG_CONDEXEC(tb->flags) & 0xf) << 1; dc->condexec_cond = ARM_TBFLAG_CONDEXEC(tb->flags) >> 4; dc->mmu_idx = ARM_TBFLAG_MMUIDX(tb->flags); dc->current_el = arm_mmu_idx_to_el(dc->mmu_idx); #if !defined(CONFIG_USER_ONLY) dc->user = (dc->current_el == 0); #endif dc->ns = ARM_TBFLAG_NS(tb->flags); dc->fp_excp_el = ARM_TBFLAG_FPEXC_EL(tb->flags); dc->vfp_enabled = ARM_TBFLAG_VFPEN(tb->flags); dc->vec_len = ARM_TBFLAG_VECLEN(tb->flags); dc->vec_stride = ARM_TBFLAG_VECSTRIDE(tb->flags); dc->c15_cpar = ARM_TBFLAG_XSCALE_CPAR(tb->flags); dc->cp_regs = cpu->cp_regs; dc->features = env->features; /* Single step state. The code-generation logic here is: * SS_ACTIVE == 0: * generate code with no special handling for single-stepping (except * that anything that can make us go to SS_ACTIVE == 1 must end the TB; * this happens anyway because those changes are all system register or * PSTATE writes). * SS_ACTIVE == 1, PSTATE.SS == 1: (active-not-pending) * emit code for one insn * emit code to clear PSTATE.SS * emit code to generate software step exception for completed step * end TB (as usual for having generated an exception) * SS_ACTIVE == 1, PSTATE.SS == 0: (active-pending) * emit code to generate a software step exception * end the TB */ dc->ss_active = ARM_TBFLAG_SS_ACTIVE(tb->flags); dc->pstate_ss = ARM_TBFLAG_PSTATE_SS(tb->flags); dc->is_ldex = false; dc->ss_same_el = false; /* Can't be true since EL_d must be AArch64 */ cpu_F0s = tcg_temp_new_i32(); cpu_F1s = tcg_temp_new_i32(); cpu_F0d = tcg_temp_new_i64(); cpu_F1d = tcg_temp_new_i64(); cpu_V0 = cpu_F0d; cpu_V1 = cpu_F1d; /* FIXME: cpu_M0 can probably be the same as cpu_V0. */ cpu_M0 = tcg_temp_new_i64(); next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; num_insns = 0; max_insns = tb->cflags & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } if (max_insns > TCG_MAX_INSNS) { max_insns = TCG_MAX_INSNS; } gen_tb_start(tb); tcg_clear_temp_count(); /* A note on handling of the condexec (IT) bits: * * We want to avoid the overhead of having to write the updated condexec * bits back to the CPUARMState for every instruction in an IT block. So: * (1) if the condexec bits are not already zero then we write * zero back into the CPUARMState now. This avoids complications trying * to do it at the end of the block. (For example if we don't do this * it's hard to identify whether we can safely skip writing condexec * at the end of the TB, which we definitely want to do for the case * where a TB doesn't do anything with the IT state at all.) * (2) if we are going to leave the TB then we call gen_set_condexec() * which will write the correct value into CPUARMState if zero is wrong. * This is done both for leaving the TB at the end, and for leaving * it because of an exception we know will happen, which is done in * gen_exception_insn(). The latter is necessary because we need to * leave the TB with the PC/IT state just prior to execution of the * instruction which caused the exception. * (3) if we leave the TB unexpectedly (eg a data abort on a load) * then the CPUARMState will be wrong and we need to reset it. * This is handled in the same way as restoration of the * PC in these situations; we save the value of the condexec bits * for each PC via tcg_gen_insn_start(), and restore_state_to_opc() * then uses this to restore them after an exception. * * Note that there are no instructions which can read the condexec * bits, and none which can write non-static values to them, so * we don't need to care about whether CPUARMState is correct in the * middle of a TB. */ /* Reset the conditional execution bits immediately. This avoids complications trying to do it at the end of the block. */ if (dc->condexec_mask || dc->condexec_cond) { TCGv_i32 tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, 0); store_cpu_field(tmp, condexec_bits); } do { dc->insn_start_idx = tcg_op_buf_count(); tcg_gen_insn_start(dc->pc, (dc->condexec_cond << 4) | (dc->condexec_mask >> 1), 0); num_insns++; #ifdef CONFIG_USER_ONLY /* Intercept jump to the magic kernel page. */ if (dc->pc >= 0xffff0000) { /* We always get here via a jump, so know we are not in a conditional execution block. */ gen_exception_internal(EXCP_KERNEL_TRAP); dc->is_jmp = DISAS_EXC; break; } #else if (arm_dc_feature(dc, ARM_FEATURE_M)) { /* Branches to the magic exception-return addresses should * already have been caught via the arm_v7m_unassigned_access hook, * and never get here. */ assert(dc->pc < 0xfffffff0); } #endif if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) { CPUBreakpoint *bp; QTAILQ_FOREACH(bp, &cs->breakpoints, entry) { if (bp->pc == dc->pc) { if (bp->flags & BP_CPU) { gen_set_condexec(dc); gen_set_pc_im(dc, dc->pc); gen_helper_check_breakpoints(cpu_env); /* End the TB early; it's likely not going to be executed */ dc->is_jmp = DISAS_UPDATE; } else { gen_exception_internal_insn(dc, 0, EXCP_DEBUG); /* The address covered by the breakpoint must be included in [tb->pc, tb->pc + tb->size) in order to for it to be properly cleared -- thus we increment the PC here so that the logic setting tb->size below does the right thing. */ /* TODO: Advance PC by correct instruction length to * avoid disassembler error messages */ dc->pc += 2; goto done_generating; } break; } } } if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) { gen_io_start(); } if (dc->ss_active && !dc->pstate_ss) { /* Singlestep state is Active-pending. * If we're in this state at the start of a TB then either * a) we just took an exception to an EL which is being debugged * and this is the first insn in the exception handler * b) debug exceptions were masked and we just unmasked them * without changing EL (eg by clearing PSTATE.D) * In either case we're going to take a swstep exception in the * "did not step an insn" case, and so the syndrome ISV and EX * bits should be zero. */ assert(num_insns == 1); gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0), default_exception_el(dc)); goto done_generating; } if (dc->thumb) { disas_thumb_insn(env, dc); if (dc->condexec_mask) { dc->condexec_cond = (dc->condexec_cond & 0xe) | ((dc->condexec_mask >> 4) & 1); dc->condexec_mask = (dc->condexec_mask << 1) & 0x1f; if (dc->condexec_mask == 0) { dc->condexec_cond = 0; } } } else { unsigned int insn = arm_ldl_code(env, dc->pc, dc->sctlr_b); dc->pc += 4; disas_arm_insn(dc, insn); } if (dc->condjmp && !dc->is_jmp) { gen_set_label(dc->condlabel); dc->condjmp = 0; } if (tcg_check_temp_count()) { fprintf(stderr, "TCG temporary leak before "TARGET_FMT_lx"\n", dc->pc); } /* Translation stops when a conditional branch is encountered. * Otherwise the subsequent code could get translated several times. * Also stop translation when a page boundary is reached. This * ensures prefetch aborts occur at the right place. */ /* We want to stop the TB if the next insn starts in a new page, * or if it spans between this page and the next. This means that * if we're looking at the last halfword in the page we need to * see if it's a 16-bit Thumb insn (which will fit in this TB) * or a 32-bit Thumb insn (which won't). * This is to avoid generating a silly TB with a single 16-bit insn * in it at the end of this page (which would execute correctly * but isn't very efficient). */ end_of_page = (dc->pc >= next_page_start) || ((dc->pc >= next_page_start - 3) && insn_crosses_page(env, dc)); } while (!dc->is_jmp && !tcg_op_buf_full() && !is_singlestepping(dc) && !singlestep && !end_of_page && num_insns < max_insns); if (tb->cflags & CF_LAST_IO) { if (dc->condjmp) { /* FIXME: This can theoretically happen with self-modifying code. */ cpu_abort(cs, "IO on conditional branch instruction"); } gen_io_end(); } /* At this stage dc->condjmp will only be set when the skipped instruction was a conditional branch or trap, and the PC has already been written. */ gen_set_condexec(dc); if (unlikely(is_singlestepping(dc))) { /* Unconditional and "condition passed" instruction codepath. */ switch (dc->is_jmp) { case DISAS_SWI: gen_ss_advance(dc); gen_exception(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb), default_exception_el(dc)); break; case DISAS_HVC: gen_ss_advance(dc); gen_exception(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2); break; case DISAS_SMC: gen_ss_advance(dc); gen_exception(EXCP_SMC, syn_aa32_smc(), 3); break; case DISAS_NEXT: case DISAS_UPDATE: gen_set_pc_im(dc, dc->pc); /* fall through */ default: /* FIXME: Single stepping a WFI insn will not halt the CPU. */ gen_singlestep_exception(dc); } } else { /* While branches must always occur at the end of an IT block, there are a few other things that can cause us to terminate the TB in the middle of an IT block: - Exception generating instructions (bkpt, swi, undefined). - Page boundaries. - Hardware watchpoints. Hardware breakpoints have already been handled and skip this code. */ switch(dc->is_jmp) { case DISAS_NEXT: gen_goto_tb(dc, 1, dc->pc); break; case DISAS_UPDATE: gen_set_pc_im(dc, dc->pc); /* fall through */ case DISAS_JUMP: default: /* indicate that the hash table must be used to find the next TB */ tcg_gen_exit_tb(0); break; case DISAS_TB_JUMP: /* nothing more to generate */ break; case DISAS_WFI: gen_helper_wfi(cpu_env); /* The helper doesn't necessarily throw an exception, but we * must go back to the main loop to check for interrupts anyway. */ tcg_gen_exit_tb(0); break; case DISAS_WFE: gen_helper_wfe(cpu_env); break; case DISAS_YIELD: gen_helper_yield(cpu_env); break; case DISAS_SWI: gen_exception(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb), default_exception_el(dc)); break; case DISAS_HVC: gen_exception(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2); break; case DISAS_SMC: gen_exception(EXCP_SMC, syn_aa32_smc(), 3); break; } } if (dc->condjmp) { /* "Condition failed" instruction codepath for the branch/trap insn */ gen_set_label(dc->condlabel); gen_set_condexec(dc); if (unlikely(is_singlestepping(dc))) { gen_set_pc_im(dc, dc->pc); gen_singlestep_exception(dc); } else { gen_goto_tb(dc, 1, dc->pc); } } done_generating: gen_tb_end(tb, num_insns); #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) && qemu_log_in_addr_range(pc_start)) { qemu_log_lock(); qemu_log("----------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); log_target_disas(cs, pc_start, dc->pc - pc_start, dc->thumb | (dc->sctlr_b << 1)); qemu_log("\n"); qemu_log_unlock(); } #endif tb->size = dc->pc - pc_start; tb->icount = num_insns; }
true
qemu
064c379c99b835bdcc478d21a3849507ea07d53a
void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb) { ARMCPU *cpu = arm_env_get_cpu(env); CPUState *cs = CPU(cpu); DisasContext dc1, *dc = &dc1; target_ulong pc_start; target_ulong next_page_start; int num_insns; int max_insns; bool end_of_page; if (ARM_TBFLAG_AARCH64_STATE(tb->flags)) { gen_intermediate_code_a64(cpu, tb); return; } pc_start = tb->pc; dc->tb = tb; dc->is_jmp = DISAS_NEXT; dc->pc = pc_start; dc->singlestep_enabled = cs->singlestep_enabled; dc->condjmp = 0; dc->aarch64 = 0; dc->secure_routed_to_el3 = arm_feature(env, ARM_FEATURE_EL3) && !arm_el_is_aa64(env, 3); dc->thumb = ARM_TBFLAG_THUMB(tb->flags); dc->sctlr_b = ARM_TBFLAG_SCTLR_B(tb->flags); dc->be_data = ARM_TBFLAG_BE_DATA(tb->flags) ? MO_BE : MO_LE; dc->condexec_mask = (ARM_TBFLAG_CONDEXEC(tb->flags) & 0xf) << 1; dc->condexec_cond = ARM_TBFLAG_CONDEXEC(tb->flags) >> 4; dc->mmu_idx = ARM_TBFLAG_MMUIDX(tb->flags); dc->current_el = arm_mmu_idx_to_el(dc->mmu_idx); #if !defined(CONFIG_USER_ONLY) dc->user = (dc->current_el == 0); #endif dc->ns = ARM_TBFLAG_NS(tb->flags); dc->fp_excp_el = ARM_TBFLAG_FPEXC_EL(tb->flags); dc->vfp_enabled = ARM_TBFLAG_VFPEN(tb->flags); dc->vec_len = ARM_TBFLAG_VECLEN(tb->flags); dc->vec_stride = ARM_TBFLAG_VECSTRIDE(tb->flags); dc->c15_cpar = ARM_TBFLAG_XSCALE_CPAR(tb->flags); dc->cp_regs = cpu->cp_regs; dc->features = env->features; dc->ss_active = ARM_TBFLAG_SS_ACTIVE(tb->flags); dc->pstate_ss = ARM_TBFLAG_PSTATE_SS(tb->flags); dc->is_ldex = false; dc->ss_same_el = false; cpu_F0s = tcg_temp_new_i32(); cpu_F1s = tcg_temp_new_i32(); cpu_F0d = tcg_temp_new_i64(); cpu_F1d = tcg_temp_new_i64(); cpu_V0 = cpu_F0d; cpu_V1 = cpu_F1d; cpu_M0 = tcg_temp_new_i64(); next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; num_insns = 0; max_insns = tb->cflags & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } if (max_insns > TCG_MAX_INSNS) { max_insns = TCG_MAX_INSNS; } gen_tb_start(tb); tcg_clear_temp_count(); if (dc->condexec_mask || dc->condexec_cond) { TCGv_i32 tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, 0); store_cpu_field(tmp, condexec_bits); } do { dc->insn_start_idx = tcg_op_buf_count(); tcg_gen_insn_start(dc->pc, (dc->condexec_cond << 4) | (dc->condexec_mask >> 1), 0); num_insns++; #ifdef CONFIG_USER_ONLY if (dc->pc >= 0xffff0000) { gen_exception_internal(EXCP_KERNEL_TRAP); dc->is_jmp = DISAS_EXC; break; } #else if (arm_dc_feature(dc, ARM_FEATURE_M)) { assert(dc->pc < 0xfffffff0); } #endif if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) { CPUBreakpoint *bp; QTAILQ_FOREACH(bp, &cs->breakpoints, entry) { if (bp->pc == dc->pc) { if (bp->flags & BP_CPU) { gen_set_condexec(dc); gen_set_pc_im(dc, dc->pc); gen_helper_check_breakpoints(cpu_env); dc->is_jmp = DISAS_UPDATE; } else { gen_exception_internal_insn(dc, 0, EXCP_DEBUG); dc->pc += 2; goto done_generating; } break; } } } if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) { gen_io_start(); } if (dc->ss_active && !dc->pstate_ss) { assert(num_insns == 1); gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0), default_exception_el(dc)); goto done_generating; } if (dc->thumb) { disas_thumb_insn(env, dc); if (dc->condexec_mask) { dc->condexec_cond = (dc->condexec_cond & 0xe) | ((dc->condexec_mask >> 4) & 1); dc->condexec_mask = (dc->condexec_mask << 1) & 0x1f; if (dc->condexec_mask == 0) { dc->condexec_cond = 0; } } } else { unsigned int insn = arm_ldl_code(env, dc->pc, dc->sctlr_b); dc->pc += 4; disas_arm_insn(dc, insn); } if (dc->condjmp && !dc->is_jmp) { gen_set_label(dc->condlabel); dc->condjmp = 0; } if (tcg_check_temp_count()) { fprintf(stderr, "TCG temporary leak before "TARGET_FMT_lx"\n", dc->pc); } end_of_page = (dc->pc >= next_page_start) || ((dc->pc >= next_page_start - 3) && insn_crosses_page(env, dc)); } while (!dc->is_jmp && !tcg_op_buf_full() && !is_singlestepping(dc) && !singlestep && !end_of_page && num_insns < max_insns); if (tb->cflags & CF_LAST_IO) { if (dc->condjmp) { cpu_abort(cs, "IO on conditional branch instruction"); } gen_io_end(); } gen_set_condexec(dc); if (unlikely(is_singlestepping(dc))) { switch (dc->is_jmp) { case DISAS_SWI: gen_ss_advance(dc); gen_exception(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb), default_exception_el(dc)); break; case DISAS_HVC: gen_ss_advance(dc); gen_exception(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2); break; case DISAS_SMC: gen_ss_advance(dc); gen_exception(EXCP_SMC, syn_aa32_smc(), 3); break; case DISAS_NEXT: case DISAS_UPDATE: gen_set_pc_im(dc, dc->pc); default: gen_singlestep_exception(dc); } } else { switch(dc->is_jmp) { case DISAS_NEXT: gen_goto_tb(dc, 1, dc->pc); break; case DISAS_UPDATE: gen_set_pc_im(dc, dc->pc); case DISAS_JUMP: default: tcg_gen_exit_tb(0); break; case DISAS_TB_JUMP: break; case DISAS_WFI: gen_helper_wfi(cpu_env); tcg_gen_exit_tb(0); break; case DISAS_WFE: gen_helper_wfe(cpu_env); break; case DISAS_YIELD: gen_helper_yield(cpu_env); break; case DISAS_SWI: gen_exception(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb), default_exception_el(dc)); break; case DISAS_HVC: gen_exception(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2); break; case DISAS_SMC: gen_exception(EXCP_SMC, syn_aa32_smc(), 3); break; } } if (dc->condjmp) { gen_set_label(dc->condlabel); gen_set_condexec(dc); if (unlikely(is_singlestepping(dc))) { gen_set_pc_im(dc, dc->pc); gen_singlestep_exception(dc); } else { gen_goto_tb(dc, 1, dc->pc); } } done_generating: gen_tb_end(tb, num_insns); #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) && qemu_log_in_addr_range(pc_start)) { qemu_log_lock(); qemu_log("----------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); log_target_disas(cs, pc_start, dc->pc - pc_start, dc->thumb | (dc->sctlr_b << 1)); qemu_log("\n"); qemu_log_unlock(); } #endif tb->size = dc->pc - pc_start; tb->icount = num_insns; }
{ "code": [], "line_no": [] }
void FUNC_0(CPUARMState *VAR_0, TranslationBlock *VAR_1) { ARMCPU *cpu = arm_env_get_cpu(VAR_0); CPUState *cs = CPU(cpu); DisasContext dc1, *dc = &dc1; target_ulong pc_start; target_ulong next_page_start; int VAR_2; int VAR_3; bool end_of_page; if (ARM_TBFLAG_AARCH64_STATE(VAR_1->flags)) { gen_intermediate_code_a64(cpu, VAR_1); return; } pc_start = VAR_1->pc; dc->VAR_1 = VAR_1; dc->is_jmp = DISAS_NEXT; dc->pc = pc_start; dc->singlestep_enabled = cs->singlestep_enabled; dc->condjmp = 0; dc->aarch64 = 0; dc->secure_routed_to_el3 = arm_feature(VAR_0, ARM_FEATURE_EL3) && !arm_el_is_aa64(VAR_0, 3); dc->thumb = ARM_TBFLAG_THUMB(VAR_1->flags); dc->sctlr_b = ARM_TBFLAG_SCTLR_B(VAR_1->flags); dc->be_data = ARM_TBFLAG_BE_DATA(VAR_1->flags) ? MO_BE : MO_LE; dc->condexec_mask = (ARM_TBFLAG_CONDEXEC(VAR_1->flags) & 0xf) << 1; dc->condexec_cond = ARM_TBFLAG_CONDEXEC(VAR_1->flags) >> 4; dc->mmu_idx = ARM_TBFLAG_MMUIDX(VAR_1->flags); dc->current_el = arm_mmu_idx_to_el(dc->mmu_idx); #if !defined(CONFIG_USER_ONLY) dc->user = (dc->current_el == 0); #endif dc->ns = ARM_TBFLAG_NS(VAR_1->flags); dc->fp_excp_el = ARM_TBFLAG_FPEXC_EL(VAR_1->flags); dc->vfp_enabled = ARM_TBFLAG_VFPEN(VAR_1->flags); dc->vec_len = ARM_TBFLAG_VECLEN(VAR_1->flags); dc->vec_stride = ARM_TBFLAG_VECSTRIDE(VAR_1->flags); dc->c15_cpar = ARM_TBFLAG_XSCALE_CPAR(VAR_1->flags); dc->cp_regs = cpu->cp_regs; dc->features = VAR_0->features; dc->ss_active = ARM_TBFLAG_SS_ACTIVE(VAR_1->flags); dc->pstate_ss = ARM_TBFLAG_PSTATE_SS(VAR_1->flags); dc->is_ldex = false; dc->ss_same_el = false; cpu_F0s = tcg_temp_new_i32(); cpu_F1s = tcg_temp_new_i32(); cpu_F0d = tcg_temp_new_i64(); cpu_F1d = tcg_temp_new_i64(); cpu_V0 = cpu_F0d; cpu_V1 = cpu_F1d; cpu_M0 = tcg_temp_new_i64(); next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; VAR_2 = 0; VAR_3 = VAR_1->cflags & CF_COUNT_MASK; if (VAR_3 == 0) { VAR_3 = CF_COUNT_MASK; } if (VAR_3 > TCG_MAX_INSNS) { VAR_3 = TCG_MAX_INSNS; } gen_tb_start(VAR_1); tcg_clear_temp_count(); if (dc->condexec_mask || dc->condexec_cond) { TCGv_i32 tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, 0); store_cpu_field(tmp, condexec_bits); } do { dc->insn_start_idx = tcg_op_buf_count(); tcg_gen_insn_start(dc->pc, (dc->condexec_cond << 4) | (dc->condexec_mask >> 1), 0); VAR_2++; #ifdef CONFIG_USER_ONLY if (dc->pc >= 0xffff0000) { gen_exception_internal(EXCP_KERNEL_TRAP); dc->is_jmp = DISAS_EXC; break; } #else if (arm_dc_feature(dc, ARM_FEATURE_M)) { assert(dc->pc < 0xfffffff0); } #endif if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) { CPUBreakpoint *bp; QTAILQ_FOREACH(bp, &cs->breakpoints, entry) { if (bp->pc == dc->pc) { if (bp->flags & BP_CPU) { gen_set_condexec(dc); gen_set_pc_im(dc, dc->pc); gen_helper_check_breakpoints(cpu_env); dc->is_jmp = DISAS_UPDATE; } else { gen_exception_internal_insn(dc, 0, EXCP_DEBUG); dc->pc += 2; goto done_generating; } break; } } } if (VAR_2 == VAR_3 && (VAR_1->cflags & CF_LAST_IO)) { gen_io_start(); } if (dc->ss_active && !dc->pstate_ss) { assert(VAR_2 == 1); gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0), default_exception_el(dc)); goto done_generating; } if (dc->thumb) { disas_thumb_insn(VAR_0, dc); if (dc->condexec_mask) { dc->condexec_cond = (dc->condexec_cond & 0xe) | ((dc->condexec_mask >> 4) & 1); dc->condexec_mask = (dc->condexec_mask << 1) & 0x1f; if (dc->condexec_mask == 0) { dc->condexec_cond = 0; } } } else { unsigned int VAR_4 = arm_ldl_code(VAR_0, dc->pc, dc->sctlr_b); dc->pc += 4; disas_arm_insn(dc, VAR_4); } if (dc->condjmp && !dc->is_jmp) { gen_set_label(dc->condlabel); dc->condjmp = 0; } if (tcg_check_temp_count()) { fprintf(stderr, "TCG temporary leak before "TARGET_FMT_lx"\n", dc->pc); } end_of_page = (dc->pc >= next_page_start) || ((dc->pc >= next_page_start - 3) && insn_crosses_page(VAR_0, dc)); } while (!dc->is_jmp && !tcg_op_buf_full() && !is_singlestepping(dc) && !singlestep && !end_of_page && VAR_2 < VAR_3); if (VAR_1->cflags & CF_LAST_IO) { if (dc->condjmp) { cpu_abort(cs, "IO on conditional branch instruction"); } gen_io_end(); } gen_set_condexec(dc); if (unlikely(is_singlestepping(dc))) { switch (dc->is_jmp) { case DISAS_SWI: gen_ss_advance(dc); gen_exception(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb), default_exception_el(dc)); break; case DISAS_HVC: gen_ss_advance(dc); gen_exception(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2); break; case DISAS_SMC: gen_ss_advance(dc); gen_exception(EXCP_SMC, syn_aa32_smc(), 3); break; case DISAS_NEXT: case DISAS_UPDATE: gen_set_pc_im(dc, dc->pc); default: gen_singlestep_exception(dc); } } else { switch(dc->is_jmp) { case DISAS_NEXT: gen_goto_tb(dc, 1, dc->pc); break; case DISAS_UPDATE: gen_set_pc_im(dc, dc->pc); case DISAS_JUMP: default: tcg_gen_exit_tb(0); break; case DISAS_TB_JUMP: break; case DISAS_WFI: gen_helper_wfi(cpu_env); tcg_gen_exit_tb(0); break; case DISAS_WFE: gen_helper_wfe(cpu_env); break; case DISAS_YIELD: gen_helper_yield(cpu_env); break; case DISAS_SWI: gen_exception(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb), default_exception_el(dc)); break; case DISAS_HVC: gen_exception(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2); break; case DISAS_SMC: gen_exception(EXCP_SMC, syn_aa32_smc(), 3); break; } } if (dc->condjmp) { gen_set_label(dc->condlabel); gen_set_condexec(dc); if (unlikely(is_singlestepping(dc))) { gen_set_pc_im(dc, dc->pc); gen_singlestep_exception(dc); } else { gen_goto_tb(dc, 1, dc->pc); } } done_generating: gen_tb_end(VAR_1, VAR_2); #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) && qemu_log_in_addr_range(pc_start)) { qemu_log_lock(); qemu_log("----------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); log_target_disas(cs, pc_start, dc->pc - pc_start, dc->thumb | (dc->sctlr_b << 1)); qemu_log("\n"); qemu_log_unlock(); } #endif VAR_1->size = dc->pc - pc_start; VAR_1->icount = VAR_2; }
[ "void FUNC_0(CPUARMState *VAR_0, TranslationBlock *VAR_1)\n{", "ARMCPU *cpu = arm_env_get_cpu(VAR_0);", "CPUState *cs = CPU(cpu);", "DisasContext dc1, *dc = &dc1;", "target_ulong pc_start;", "target_ulong next_page_start;", "int VAR_2;", "int VAR_3;", "bool end_of_page;", "if (ARM_TBFLAG_AARCH64_STATE(VAR_1->flags)) {", "gen_intermediate_code_a64(cpu, VAR_1);", "return;", "}", "pc_start = VAR_1->pc;", "dc->VAR_1 = VAR_1;", "dc->is_jmp = DISAS_NEXT;", "dc->pc = pc_start;", "dc->singlestep_enabled = cs->singlestep_enabled;", "dc->condjmp = 0;", "dc->aarch64 = 0;", "dc->secure_routed_to_el3 = arm_feature(VAR_0, ARM_FEATURE_EL3) &&\n!arm_el_is_aa64(VAR_0, 3);", "dc->thumb = ARM_TBFLAG_THUMB(VAR_1->flags);", "dc->sctlr_b = ARM_TBFLAG_SCTLR_B(VAR_1->flags);", "dc->be_data = ARM_TBFLAG_BE_DATA(VAR_1->flags) ? MO_BE : MO_LE;", "dc->condexec_mask = (ARM_TBFLAG_CONDEXEC(VAR_1->flags) & 0xf) << 1;", "dc->condexec_cond = ARM_TBFLAG_CONDEXEC(VAR_1->flags) >> 4;", "dc->mmu_idx = ARM_TBFLAG_MMUIDX(VAR_1->flags);", "dc->current_el = arm_mmu_idx_to_el(dc->mmu_idx);", "#if !defined(CONFIG_USER_ONLY)\ndc->user = (dc->current_el == 0);", "#endif\ndc->ns = ARM_TBFLAG_NS(VAR_1->flags);", "dc->fp_excp_el = ARM_TBFLAG_FPEXC_EL(VAR_1->flags);", "dc->vfp_enabled = ARM_TBFLAG_VFPEN(VAR_1->flags);", "dc->vec_len = ARM_TBFLAG_VECLEN(VAR_1->flags);", "dc->vec_stride = ARM_TBFLAG_VECSTRIDE(VAR_1->flags);", "dc->c15_cpar = ARM_TBFLAG_XSCALE_CPAR(VAR_1->flags);", "dc->cp_regs = cpu->cp_regs;", "dc->features = VAR_0->features;", "dc->ss_active = ARM_TBFLAG_SS_ACTIVE(VAR_1->flags);", "dc->pstate_ss = ARM_TBFLAG_PSTATE_SS(VAR_1->flags);", "dc->is_ldex = false;", "dc->ss_same_el = false;", "cpu_F0s = tcg_temp_new_i32();", "cpu_F1s = tcg_temp_new_i32();", "cpu_F0d = tcg_temp_new_i64();", "cpu_F1d = tcg_temp_new_i64();", "cpu_V0 = cpu_F0d;", "cpu_V1 = cpu_F1d;", "cpu_M0 = tcg_temp_new_i64();", "next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;", "VAR_2 = 0;", "VAR_3 = VAR_1->cflags & CF_COUNT_MASK;", "if (VAR_3 == 0) {", "VAR_3 = CF_COUNT_MASK;", "}", "if (VAR_3 > TCG_MAX_INSNS) {", "VAR_3 = TCG_MAX_INSNS;", "}", "gen_tb_start(VAR_1);", "tcg_clear_temp_count();", "if (dc->condexec_mask || dc->condexec_cond)\n{", "TCGv_i32 tmp = tcg_temp_new_i32();", "tcg_gen_movi_i32(tmp, 0);", "store_cpu_field(tmp, condexec_bits);", "}", "do {", "dc->insn_start_idx = tcg_op_buf_count();", "tcg_gen_insn_start(dc->pc,\n(dc->condexec_cond << 4) | (dc->condexec_mask >> 1),\n0);", "VAR_2++;", "#ifdef CONFIG_USER_ONLY\nif (dc->pc >= 0xffff0000) {", "gen_exception_internal(EXCP_KERNEL_TRAP);", "dc->is_jmp = DISAS_EXC;", "break;", "}", "#else\nif (arm_dc_feature(dc, ARM_FEATURE_M)) {", "assert(dc->pc < 0xfffffff0);", "}", "#endif\nif (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {", "CPUBreakpoint *bp;", "QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {", "if (bp->pc == dc->pc) {", "if (bp->flags & BP_CPU) {", "gen_set_condexec(dc);", "gen_set_pc_im(dc, dc->pc);", "gen_helper_check_breakpoints(cpu_env);", "dc->is_jmp = DISAS_UPDATE;", "} else {", "gen_exception_internal_insn(dc, 0, EXCP_DEBUG);", "dc->pc += 2;", "goto done_generating;", "}", "break;", "}", "}", "}", "if (VAR_2 == VAR_3 && (VAR_1->cflags & CF_LAST_IO)) {", "gen_io_start();", "}", "if (dc->ss_active && !dc->pstate_ss) {", "assert(VAR_2 == 1);", "gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0),\ndefault_exception_el(dc));", "goto done_generating;", "}", "if (dc->thumb) {", "disas_thumb_insn(VAR_0, dc);", "if (dc->condexec_mask) {", "dc->condexec_cond = (dc->condexec_cond & 0xe)\n| ((dc->condexec_mask >> 4) & 1);", "dc->condexec_mask = (dc->condexec_mask << 1) & 0x1f;", "if (dc->condexec_mask == 0) {", "dc->condexec_cond = 0;", "}", "}", "} else {", "unsigned int VAR_4 = arm_ldl_code(VAR_0, dc->pc, dc->sctlr_b);", "dc->pc += 4;", "disas_arm_insn(dc, VAR_4);", "}", "if (dc->condjmp && !dc->is_jmp) {", "gen_set_label(dc->condlabel);", "dc->condjmp = 0;", "}", "if (tcg_check_temp_count()) {", "fprintf(stderr, \"TCG temporary leak before \"TARGET_FMT_lx\"\\n\",\ndc->pc);", "}", "end_of_page = (dc->pc >= next_page_start) ||\n((dc->pc >= next_page_start - 3) && insn_crosses_page(VAR_0, dc));", "} while (!dc->is_jmp && !tcg_op_buf_full() &&", "!is_singlestepping(dc) &&\n!singlestep &&\n!end_of_page &&\nVAR_2 < VAR_3);", "if (VAR_1->cflags & CF_LAST_IO) {", "if (dc->condjmp) {", "cpu_abort(cs, \"IO on conditional branch instruction\");", "}", "gen_io_end();", "}", "gen_set_condexec(dc);", "if (unlikely(is_singlestepping(dc))) {", "switch (dc->is_jmp) {", "case DISAS_SWI:\ngen_ss_advance(dc);", "gen_exception(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb),\ndefault_exception_el(dc));", "break;", "case DISAS_HVC:\ngen_ss_advance(dc);", "gen_exception(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2);", "break;", "case DISAS_SMC:\ngen_ss_advance(dc);", "gen_exception(EXCP_SMC, syn_aa32_smc(), 3);", "break;", "case DISAS_NEXT:\ncase DISAS_UPDATE:\ngen_set_pc_im(dc, dc->pc);", "default:\ngen_singlestep_exception(dc);", "}", "} else {", "switch(dc->is_jmp) {", "case DISAS_NEXT:\ngen_goto_tb(dc, 1, dc->pc);", "break;", "case DISAS_UPDATE:\ngen_set_pc_im(dc, dc->pc);", "case DISAS_JUMP:\ndefault:\ntcg_gen_exit_tb(0);", "break;", "case DISAS_TB_JUMP:\nbreak;", "case DISAS_WFI:\ngen_helper_wfi(cpu_env);", "tcg_gen_exit_tb(0);", "break;", "case DISAS_WFE:\ngen_helper_wfe(cpu_env);", "break;", "case DISAS_YIELD:\ngen_helper_yield(cpu_env);", "break;", "case DISAS_SWI:\ngen_exception(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb),\ndefault_exception_el(dc));", "break;", "case DISAS_HVC:\ngen_exception(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2);", "break;", "case DISAS_SMC:\ngen_exception(EXCP_SMC, syn_aa32_smc(), 3);", "break;", "}", "}", "if (dc->condjmp) {", "gen_set_label(dc->condlabel);", "gen_set_condexec(dc);", "if (unlikely(is_singlestepping(dc))) {", "gen_set_pc_im(dc, dc->pc);", "gen_singlestep_exception(dc);", "} else {", "gen_goto_tb(dc, 1, dc->pc);", "}", "}", "done_generating:\ngen_tb_end(VAR_1, VAR_2);", "#ifdef DEBUG_DISAS\nif (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) &&\nqemu_log_in_addr_range(pc_start)) {", "qemu_log_lock();", "qemu_log(\"----------------\\n\");", "qemu_log(\"IN: %s\\n\", lookup_symbol(pc_start));", "log_target_disas(cs, pc_start, dc->pc - pc_start,\ndc->thumb | (dc->sctlr_b << 1));", "qemu_log(\"\\n\");", "qemu_log_unlock();", "}", "#endif\nVAR_1->size = dc->pc - pc_start;", "VAR_1->icount = VAR_2;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 69, 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87, 89 ], [ 91, 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 106 ], [ 108 ], [ 142 ], [ 144 ], [ 146 ], [ 148 ], [ 152 ], [ 154 ], [ 156 ], [ 158 ], [ 160 ], [ 162 ], [ 166 ], [ 168 ], [ 170 ], [ 172 ], [ 174 ], [ 176 ], [ 178 ], [ 180 ], [ 182 ], [ 184 ], [ 188 ], [ 192 ], [ 260, 262 ], [ 264 ], [ 266 ], [ 268 ], [ 270 ], [ 272 ], [ 274 ], [ 276, 278, 280 ], [ 282 ], [ 286, 290 ], [ 296 ], [ 298 ], [ 300 ], [ 302 ], [ 304, 306 ], [ 316 ], [ 318 ], [ 320, 324 ], [ 326 ], [ 328 ], [ 330 ], [ 332 ], [ 334 ], [ 336 ], [ 338 ], [ 342 ], [ 344 ], [ 346 ], [ 362 ], [ 364 ], [ 366 ], [ 368 ], [ 370 ], [ 372 ], [ 374 ], [ 378 ], [ 380 ], [ 382 ], [ 386 ], [ 408 ], [ 410, 412 ], [ 414 ], [ 416 ], [ 420 ], [ 422 ], [ 424 ], [ 426, 428 ], [ 430 ], [ 432 ], [ 434 ], [ 436 ], [ 438 ], [ 440 ], [ 442 ], [ 444 ], [ 446 ], [ 448 ], [ 452 ], [ 454 ], [ 456 ], [ 458 ], [ 462 ], [ 464, 466 ], [ 468 ], [ 500, 502 ], [ 506 ], [ 508, 510, 512, 514 ], [ 518 ], [ 520 ], [ 526 ], [ 528 ], [ 530 ], [ 532 ], [ 542 ], [ 544 ], [ 548 ], [ 550, 552 ], [ 554, 556 ], [ 558 ], [ 560, 562 ], [ 564 ], [ 566 ], [ 568, 570 ], [ 572 ], [ 574 ], [ 576, 578, 580 ], [ 584, 588 ], [ 590 ], [ 592 ], [ 610 ], [ 612, 614 ], [ 616 ], [ 618, 620 ], [ 624, 626, 630 ], [ 632 ], [ 634, 638 ], [ 640, 642 ], [ 650 ], [ 652 ], [ 654, 656 ], [ 658 ], [ 660, 662 ], [ 664 ], [ 666, 668, 670 ], [ 672 ], [ 674, 676 ], [ 678 ], [ 680, 682 ], [ 684 ], [ 686 ], [ 688 ], [ 692 ], [ 696 ], [ 698 ], [ 700 ], [ 702 ], [ 704 ], [ 706 ], [ 708 ], [ 710 ], [ 712 ], [ 716, 718 ], [ 722, 724, 726 ], [ 728 ], [ 730 ], [ 732 ], [ 734, 736 ], [ 738 ], [ 740 ], [ 742 ], [ 744, 746 ], [ 748 ], [ 750 ] ]
9,328
NEON_TYPE4(s8, int8_t) NEON_TYPE4(u8, uint8_t) NEON_TYPE2(s16, int16_t) NEON_TYPE2(u16, uint16_t) NEON_TYPE1(s32, int32_t) NEON_TYPE1(u32, uint32_t) #undef NEON_TYPE4 #undef NEON_TYPE2 #undef NEON_TYPE1 /* Copy from a uint32_t to a vector structure type. */ #define NEON_UNPACK(vtype, dest, val) do { \ union { \ vtype v; \ uint32_t i; \ } conv_u; \ conv_u.i = (val); \ dest = conv_u.v; \ } while(0) /* Copy from a vector structure type to a uint32_t. */ #define NEON_PACK(vtype, dest, val) do { \ union { \ vtype v; \ uint32_t i; \ } conv_u; \ conv_u.v = (val); \ dest = conv_u.i; \ } while(0) #define NEON_DO1 \ NEON_FN(vdest.v1, vsrc1.v1, vsrc2.v1); #define NEON_DO2 \ NEON_FN(vdest.v1, vsrc1.v1, vsrc2.v1); \ NEON_FN(vdest.v2, vsrc1.v2, vsrc2.v2); #define NEON_DO4 \ NEON_FN(vdest.v1, vsrc1.v1, vsrc2.v1); \ NEON_FN(vdest.v2, vsrc1.v2, vsrc2.v2); \ NEON_FN(vdest.v3, vsrc1.v3, vsrc2.v3); \ NEON_FN(vdest.v4, vsrc1.v4, vsrc2.v4); #define NEON_VOP_BODY(vtype, n) \ { \ uint32_t res; \ vtype vsrc1; \ vtype vsrc2; \ vtype vdest; \ NEON_UNPACK(vtype, vsrc1, arg1); \ NEON_UNPACK(vtype, vsrc2, arg2); \ NEON_DO##n; \ NEON_PACK(vtype, res, vdest); \ return res; \ #define NEON_VOP(name, vtype, n) \ uint32_t HELPER(glue(neon_,name))(uint32_t arg1, uint32_t arg2) \ NEON_VOP_BODY(vtype, n) #define NEON_VOP_ENV(name, vtype, n) \ uint32_t HELPER(glue(neon_,name))(CPUState *env, uint32_t arg1, uint32_t arg2) \ NEON_VOP_BODY(vtype, n) /* Pairwise operations. */ /* For 32-bit elements each segment only contains a single element, so the elementwise and pairwise operations are the same. */ #define NEON_PDO2 \ NEON_FN(vdest.v1, vsrc1.v1, vsrc1.v2); \ NEON_FN(vdest.v2, vsrc2.v1, vsrc2.v2); #define NEON_PDO4 \ NEON_FN(vdest.v1, vsrc1.v1, vsrc1.v2); \ NEON_FN(vdest.v2, vsrc1.v3, vsrc1.v4); \ NEON_FN(vdest.v3, vsrc2.v1, vsrc2.v2); \ NEON_FN(vdest.v4, vsrc2.v3, vsrc2.v4); \ #define NEON_POP(name, vtype, n) \ uint32_t HELPER(glue(neon_,name))(uint32_t arg1, uint32_t arg2) \ { \ uint32_t res; \ vtype vsrc1; \ vtype vsrc2; \ vtype vdest; \ NEON_UNPACK(vtype, vsrc1, arg1); \ NEON_UNPACK(vtype, vsrc2, arg2); \ NEON_PDO##n; \ NEON_PACK(vtype, res, vdest); \ return res; \ /* Unary operators. */ #define NEON_VOP1(name, vtype, n) \ uint32_t HELPER(glue(neon_,name))(uint32_t arg) \ { \ vtype vsrc1; \ vtype vdest; \ NEON_UNPACK(vtype, vsrc1, arg); \ NEON_DO##n; \ NEON_PACK(vtype, arg, vdest); \ return arg; \ #define NEON_USAT(dest, src1, src2, type) do { \ uint32_t tmp = (uint32_t)src1 + (uint32_t)src2; \ if (tmp != (type)tmp) { \ SET_QC(); \ dest = ~0; \ } else { \ dest = tmp; \ }} while(0) #define NEON_FN(dest, src1, src2) NEON_USAT(dest, src1, src2, uint8_t) NEON_VOP_ENV(qadd_u8, neon_u8, 4) #undef NEON_FN #define NEON_FN(dest, src1, src2) NEON_USAT(dest, src1, src2, uint16_t) NEON_VOP_ENV(qadd_u16, neon_u16, 2) #undef NEON_FN #undef NEON_USAT
true
qemu
72902672dc2ed6281cdb205259c1d52ecf01f6b2
NEON_TYPE4(s8, int8_t) NEON_TYPE4(u8, uint8_t) NEON_TYPE2(s16, int16_t) NEON_TYPE2(u16, uint16_t) NEON_TYPE1(s32, int32_t) NEON_TYPE1(u32, uint32_t) #undef NEON_TYPE4 #undef NEON_TYPE2 #undef NEON_TYPE1 #define NEON_UNPACK(vtype, dest, val) do { \ union { \ vtype v; \ uint32_t i; \ } conv_u; \ conv_u.i = (val); \ dest = conv_u.v; \ } while(0) #define NEON_PACK(vtype, dest, val) do { \ union { \ vtype v; \ uint32_t i; \ } conv_u; \ conv_u.v = (val); \ dest = conv_u.i; \ } while(0) #define NEON_DO1 \ NEON_FN(vdest.v1, vsrc1.v1, vsrc2.v1); #define NEON_DO2 \ NEON_FN(vdest.v1, vsrc1.v1, vsrc2.v1); \ NEON_FN(vdest.v2, vsrc1.v2, vsrc2.v2); #define NEON_DO4 \ NEON_FN(vdest.v1, vsrc1.v1, vsrc2.v1); \ NEON_FN(vdest.v2, vsrc1.v2, vsrc2.v2); \ NEON_FN(vdest.v3, vsrc1.v3, vsrc2.v3); \ NEON_FN(vdest.v4, vsrc1.v4, vsrc2.v4); #define NEON_VOP_BODY(vtype, n) \ { \ uint32_t res; \ vtype vsrc1; \ vtype vsrc2; \ vtype vdest; \ NEON_UNPACK(vtype, vsrc1, arg1); \ NEON_UNPACK(vtype, vsrc2, arg2); \ NEON_DO##n; \ NEON_PACK(vtype, res, vdest); \ return res; \ #define NEON_VOP(name, vtype, n) \ uint32_t HELPER(glue(neon_,name))(uint32_t arg1, uint32_t arg2) \ NEON_VOP_BODY(vtype, n) #define NEON_VOP_ENV(name, vtype, n) \ uint32_t HELPER(glue(neon_,name))(CPUState *env, uint32_t arg1, uint32_t arg2) \ NEON_VOP_BODY(vtype, n) #define NEON_PDO2 \ NEON_FN(vdest.v1, vsrc1.v1, vsrc1.v2); \ NEON_FN(vdest.v2, vsrc2.v1, vsrc2.v2); #define NEON_PDO4 \ NEON_FN(vdest.v1, vsrc1.v1, vsrc1.v2); \ NEON_FN(vdest.v2, vsrc1.v3, vsrc1.v4); \ NEON_FN(vdest.v3, vsrc2.v1, vsrc2.v2); \ NEON_FN(vdest.v4, vsrc2.v3, vsrc2.v4); \ #define NEON_POP(name, vtype, n) \ uint32_t HELPER(glue(neon_,name))(uint32_t arg1, uint32_t arg2) \ { \ uint32_t res; \ vtype vsrc1; \ vtype vsrc2; \ vtype vdest; \ NEON_UNPACK(vtype, vsrc1, arg1); \ NEON_UNPACK(vtype, vsrc2, arg2); \ NEON_PDO##n; \ NEON_PACK(vtype, res, vdest); \ return res; \ #define NEON_VOP1(name, vtype, n) \ uint32_t HELPER(glue(neon_,name))(uint32_t arg) \ { \ vtype vsrc1; \ vtype vdest; \ NEON_UNPACK(vtype, vsrc1, arg); \ NEON_DO##n; \ NEON_PACK(vtype, arg, vdest); \ return arg; \ #define NEON_USAT(dest, src1, src2, type) do { \ uint32_t tmp = (uint32_t)src1 + (uint32_t)src2; \ if (tmp != (type)tmp) { \ SET_QC(); \ dest = ~0; \ } else { \ dest = tmp; \ }} while(0) #define NEON_FN(dest, src1, src2) NEON_USAT(dest, src1, src2, uint8_t) NEON_VOP_ENV(qadd_u8, neon_u8, 4) #undef NEON_FN #define NEON_FN(dest, src1, src2) NEON_USAT(dest, src1, src2, uint16_t) NEON_VOP_ENV(qadd_u16, neon_u16, 2) #undef NEON_FN #undef NEON_USAT
{ "code": [], "line_no": [] }
NEON_TYPE4(s8, int8_t) NEON_TYPE4(u8, uint8_t) NEON_TYPE2(s16, int16_t) NEON_TYPE2(u16, uint16_t) NEON_TYPE1(s32, int32_t) NEON_TYPE1(u32, uint32_t) #undef NEON_TYPE4 #undef NEON_TYPE2 #undef NEON_TYPE1 #define NEON_UNPACK(vtype, dest, val) do { \ union { \ vtype v; \ uint32_t i; \ } conv_u; \ conv_u.i = (val); \ dest = conv_u.v; \ } while(0) #define NEON_PACK(vtype, dest, val) do { \ union { \ vtype v; \ uint32_t i; \ } conv_u; \ conv_u.v = (val); \ dest = conv_u.i; \ } while(0) #define NEON_DO1 \ NEON_FN(vdest.v1, vsrc1.v1, vsrc2.v1); #define NEON_DO2 \ NEON_FN(vdest.v1, vsrc1.v1, vsrc2.v1); \ NEON_FN(vdest.v2, vsrc1.v2, vsrc2.v2); #define NEON_DO4 \ NEON_FN(vdest.v1, vsrc1.v1, vsrc2.v1); \ NEON_FN(vdest.v2, vsrc1.v2, vsrc2.v2); \ NEON_FN(vdest.v3, vsrc1.v3, vsrc2.v3); \ NEON_FN(vdest.v4, vsrc1.v4, vsrc2.v4); #define NEON_VOP_BODY(vtype, n) \ { \ uint32_t res; \ vtype vsrc1; \ vtype vsrc2; \ vtype vdest; \ NEON_UNPACK(vtype, vsrc1, arg1); \ NEON_UNPACK(vtype, vsrc2, arg2); \ NEON_DO##n; \ NEON_PACK(vtype, res, vdest); \ return res; \ #define NEON_VOP(name, vtype, n) \ uint32_t HELPER(glue(neon_,name))(uint32_t arg1, uint32_t arg2) \ NEON_VOP_BODY(vtype, n) #define NEON_VOP_ENV(name, vtype, n) \ uint32_t HELPER(glue(neon_,name))(CPUState *env, uint32_t arg1, uint32_t arg2) \ NEON_VOP_BODY(vtype, n) #define NEON_PDO2 \ NEON_FN(vdest.v1, vsrc1.v1, vsrc1.v2); \ NEON_FN(vdest.v2, vsrc2.v1, vsrc2.v2); #define NEON_PDO4 \ NEON_FN(vdest.v1, vsrc1.v1, vsrc1.v2); \ NEON_FN(vdest.v2, vsrc1.v3, vsrc1.v4); \ NEON_FN(vdest.v3, vsrc2.v1, vsrc2.v2); \ NEON_FN(vdest.v4, vsrc2.v3, vsrc2.v4); \ #define NEON_POP(name, vtype, n) \ uint32_t HELPER(glue(neon_,name))(uint32_t arg1, uint32_t arg2) \ { \ uint32_t res; \ vtype vsrc1; \ vtype vsrc2; \ vtype vdest; \ NEON_UNPACK(vtype, vsrc1, arg1); \ NEON_UNPACK(vtype, vsrc2, arg2); \ NEON_PDO##n; \ NEON_PACK(vtype, res, vdest); \ return res; \ #define NEON_VOP1(name, vtype, n) \ uint32_t HELPER(glue(neon_,name))(uint32_t arg) \ { \ vtype vsrc1; \ vtype vdest; \ NEON_UNPACK(vtype, vsrc1, arg); \ NEON_DO##n; \ NEON_PACK(vtype, arg, vdest); \ return arg; \ #define NEON_USAT(dest, src1, src2, type) do { \ uint32_t tmp = (uint32_t)src1 + (uint32_t)src2; \ if (tmp != (type)tmp) { \ SET_QC(); \ dest = ~0; \ } else { \ dest = tmp; \ }} while(0) #define NEON_FN(dest, src1, src2) NEON_USAT(dest, src1, src2, uint8_t) NEON_VOP_ENV(qadd_u8, neon_u8, 4) #undef NEON_FN #define NEON_FN(dest, src1, src2) NEON_USAT(dest, src1, src2, uint16_t) NEON_VOP_ENV(qadd_u16, neon_u16, 2) #undef NEON_FN #undef NEON_USAT
[ "NEON_TYPE4(s8, int8_t)\nNEON_TYPE4(u8, uint8_t)\nNEON_TYPE2(s16, int16_t)\nNEON_TYPE2(u16, uint16_t)\nNEON_TYPE1(s32, int32_t)\nNEON_TYPE1(u32, uint32_t)\n#undef NEON_TYPE4\n#undef NEON_TYPE2\n#undef NEON_TYPE1\n#define NEON_UNPACK(vtype, dest, val) do { \\", "union { \\", "vtype v; \\", "uint32_t i; \\", "} conv_u; \\", "conv_u.i = (val); \\", "dest = conv_u.v; \\", "} while(0)", "#define NEON_PACK(vtype, dest, val) do { \\", "union { \\", "vtype v; \\", "uint32_t i; \\", "} conv_u; \\", "conv_u.v = (val); \\", "dest = conv_u.i; \\", "} while(0)", "#define NEON_DO1 \\\nNEON_FN(vdest.v1, vsrc1.v1, vsrc2.v1);", "#define NEON_DO2 \\\nNEON_FN(vdest.v1, vsrc1.v1, vsrc2.v1); \\", "NEON_FN(vdest.v2, vsrc1.v2, vsrc2.v2);", "#define NEON_DO4 \\\nNEON_FN(vdest.v1, vsrc1.v1, vsrc2.v1); \\", "NEON_FN(vdest.v2, vsrc1.v2, vsrc2.v2); \\", "NEON_FN(vdest.v3, vsrc1.v3, vsrc2.v3); \\", "NEON_FN(vdest.v4, vsrc1.v4, vsrc2.v4);", "#define NEON_VOP_BODY(vtype, n) \\\n{ \\", "uint32_t res; \\", "vtype vsrc1; \\", "vtype vsrc2; \\", "vtype vdest; \\", "NEON_UNPACK(vtype, vsrc1, arg1); \\", "NEON_UNPACK(vtype, vsrc2, arg2); \\", "NEON_DO##n; \\", "NEON_PACK(vtype, res, vdest); \\", "return res; \\", "#define NEON_VOP(name, vtype, n) \\\nuint32_t HELPER(glue(neon_,name))(uint32_t arg1, uint32_t arg2) \\\nNEON_VOP_BODY(vtype, n)\n#define NEON_VOP_ENV(name, vtype, n) \\\nuint32_t HELPER(glue(neon_,name))(CPUState *env, uint32_t arg1, uint32_t arg2) \\\nNEON_VOP_BODY(vtype, n)\n#define NEON_PDO2 \\\nNEON_FN(vdest.v1, vsrc1.v1, vsrc1.v2); \\", "NEON_FN(vdest.v2, vsrc2.v1, vsrc2.v2);", "#define NEON_PDO4 \\\nNEON_FN(vdest.v1, vsrc1.v1, vsrc1.v2); \\", "NEON_FN(vdest.v2, vsrc1.v3, vsrc1.v4); \\", "NEON_FN(vdest.v3, vsrc2.v1, vsrc2.v2); \\", "NEON_FN(vdest.v4, vsrc2.v3, vsrc2.v4); \\", "#define NEON_POP(name, vtype, n) \\\nuint32_t HELPER(glue(neon_,name))(uint32_t arg1, uint32_t arg2) \\\n{ \\", "uint32_t res; \\", "vtype vsrc1; \\", "vtype vsrc2; \\", "vtype vdest; \\", "NEON_UNPACK(vtype, vsrc1, arg1); \\", "NEON_UNPACK(vtype, vsrc2, arg2); \\", "NEON_PDO##n; \\", "NEON_PACK(vtype, res, vdest); \\", "return res; \\", "#define NEON_VOP1(name, vtype, n) \\\nuint32_t HELPER(glue(neon_,name))(uint32_t arg) \\\n{ \\", "vtype vsrc1; \\", "vtype vdest; \\", "NEON_UNPACK(vtype, vsrc1, arg); \\", "NEON_DO##n; \\", "NEON_PACK(vtype, arg, vdest); \\", "return arg; \\", "#define NEON_USAT(dest, src1, src2, type) do { \\", "uint32_t tmp = (uint32_t)src1 + (uint32_t)src2; \\", "if (tmp != (type)tmp) { \\", "SET_QC(); \\", "dest = ~0; \\", "} else { \\", "dest = tmp; \\", "}} while(0)" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 11 ], [ 12 ], [ 13 ], [ 14 ], [ 15 ], [ 16 ], [ 17 ], [ 18 ], [ 20 ], [ 21 ], [ 22 ], [ 23 ], [ 24 ], [ 25 ], [ 26 ], [ 27 ], [ 28, 29 ], [ 30, 31 ], [ 32 ], [ 33, 34 ], [ 35 ], [ 36 ], [ 37 ], [ 38, 39 ], [ 40 ], [ 41 ], [ 42 ], [ 43 ], [ 44 ], [ 45 ], [ 46 ], [ 47 ], [ 48 ], [ 49, 50, 51, 52, 53, 54, 58, 59 ], [ 60 ], [ 61, 62 ], [ 63 ], [ 64 ], [ 65 ], [ 66, 67, 68 ], [ 69 ], [ 70 ], [ 71 ], [ 72 ], [ 73 ], [ 74 ], [ 75 ], [ 76 ], [ 77 ], [ 79, 80, 81 ], [ 82 ], [ 83 ], [ 84 ], [ 85 ], [ 86 ], [ 87 ], [ 88 ], [ 89 ], [ 90 ], [ 91 ], [ 92 ], [ 93 ], [ 94 ], [ 95 ] ]
9,329
static int vmdk_create_extent(const char *filename, int64_t filesize, bool flat, bool compress, bool zeroed_grain, Error **errp) { int ret, i; BlockDriverState *bs = NULL; VMDK4Header header; Error *local_err; uint32_t tmp, magic, grains, gd_sectors, gt_size, gt_count; uint32_t *gd_buf = NULL; int gd_buf_size; ret = bdrv_create_file(filename, NULL, &local_err); if (ret < 0) { error_propagate(errp, local_err); goto exit; } ret = bdrv_file_open(&bs, filename, NULL, NULL, BDRV_O_RDWR, &local_err); if (ret < 0) { error_propagate(errp, local_err); goto exit; } if (flat) { ret = bdrv_truncate(bs, filesize); if (ret < 0) { error_setg(errp, "Could not truncate file"); } goto exit; } magic = cpu_to_be32(VMDK4_MAGIC); memset(&header, 0, sizeof(header)); header.version = zeroed_grain ? 2 : 1; header.flags = VMDK4_FLAG_RGD | VMDK4_FLAG_NL_DETECT | (compress ? VMDK4_FLAG_COMPRESS | VMDK4_FLAG_MARKER : 0) | (zeroed_grain ? VMDK4_FLAG_ZERO_GRAIN : 0); header.compressAlgorithm = compress ? VMDK4_COMPRESSION_DEFLATE : 0; header.capacity = filesize / BDRV_SECTOR_SIZE; header.granularity = 128; header.num_gtes_per_gt = BDRV_SECTOR_SIZE; grains = DIV_ROUND_UP(filesize / BDRV_SECTOR_SIZE, header.granularity); gt_size = DIV_ROUND_UP(header.num_gtes_per_gt * sizeof(uint32_t), BDRV_SECTOR_SIZE); gt_count = DIV_ROUND_UP(grains, header.num_gtes_per_gt); gd_sectors = DIV_ROUND_UP(gt_count * sizeof(uint32_t), BDRV_SECTOR_SIZE); header.desc_offset = 1; header.desc_size = 20; header.rgd_offset = header.desc_offset + header.desc_size; header.gd_offset = header.rgd_offset + gd_sectors + (gt_size * gt_count); header.grain_offset = ROUND_UP(header.gd_offset + gd_sectors + (gt_size * gt_count), header.granularity); /* swap endianness for all header fields */ header.version = cpu_to_le32(header.version); header.flags = cpu_to_le32(header.flags); header.capacity = cpu_to_le64(header.capacity); header.granularity = cpu_to_le64(header.granularity); header.num_gtes_per_gt = cpu_to_le32(header.num_gtes_per_gt); header.desc_offset = cpu_to_le64(header.desc_offset); header.desc_size = cpu_to_le64(header.desc_size); header.rgd_offset = cpu_to_le64(header.rgd_offset); header.gd_offset = cpu_to_le64(header.gd_offset); header.grain_offset = cpu_to_le64(header.grain_offset); header.compressAlgorithm = cpu_to_le16(header.compressAlgorithm); header.check_bytes[0] = 0xa; header.check_bytes[1] = 0x20; header.check_bytes[2] = 0xd; header.check_bytes[3] = 0xa; /* write all the data */ ret = bdrv_pwrite(bs, 0, &magic, sizeof(magic)); if (ret < 0) { error_set(errp, QERR_IO_ERROR); goto exit; } ret = bdrv_pwrite(bs, sizeof(magic), &header, sizeof(header)); if (ret < 0) { error_set(errp, QERR_IO_ERROR); goto exit; } ret = bdrv_truncate(bs, le64_to_cpu(header.grain_offset) << 9); if (ret < 0) { error_setg(errp, "Could not truncate file"); goto exit; } /* write grain directory */ gd_buf_size = gd_sectors * BDRV_SECTOR_SIZE; gd_buf = g_malloc0(gd_buf_size); for (i = 0, tmp = le64_to_cpu(header.rgd_offset) + gd_sectors; i < gt_count; i++, tmp += gt_size) { gd_buf[i] = cpu_to_le32(tmp); } ret = bdrv_pwrite(bs, le64_to_cpu(header.rgd_offset) * BDRV_SECTOR_SIZE, gd_buf, gd_buf_size); if (ret < 0) { error_set(errp, QERR_IO_ERROR); goto exit; } /* write backup grain directory */ for (i = 0, tmp = le64_to_cpu(header.gd_offset) + gd_sectors; i < gt_count; i++, tmp += gt_size) { gd_buf[i] = cpu_to_le32(tmp); } ret = bdrv_pwrite(bs, le64_to_cpu(header.gd_offset) * BDRV_SECTOR_SIZE, gd_buf, gd_buf_size); if (ret < 0) { error_set(errp, QERR_IO_ERROR); goto exit; } ret = 0; exit: if (bs) { bdrv_unref(bs); } g_free(gd_buf); return ret; }
true
qemu
39a611a3e035e148257af314a522a6cd169c2d0e
static int vmdk_create_extent(const char *filename, int64_t filesize, bool flat, bool compress, bool zeroed_grain, Error **errp) { int ret, i; BlockDriverState *bs = NULL; VMDK4Header header; Error *local_err; uint32_t tmp, magic, grains, gd_sectors, gt_size, gt_count; uint32_t *gd_buf = NULL; int gd_buf_size; ret = bdrv_create_file(filename, NULL, &local_err); if (ret < 0) { error_propagate(errp, local_err); goto exit; } ret = bdrv_file_open(&bs, filename, NULL, NULL, BDRV_O_RDWR, &local_err); if (ret < 0) { error_propagate(errp, local_err); goto exit; } if (flat) { ret = bdrv_truncate(bs, filesize); if (ret < 0) { error_setg(errp, "Could not truncate file"); } goto exit; } magic = cpu_to_be32(VMDK4_MAGIC); memset(&header, 0, sizeof(header)); header.version = zeroed_grain ? 2 : 1; header.flags = VMDK4_FLAG_RGD | VMDK4_FLAG_NL_DETECT | (compress ? VMDK4_FLAG_COMPRESS | VMDK4_FLAG_MARKER : 0) | (zeroed_grain ? VMDK4_FLAG_ZERO_GRAIN : 0); header.compressAlgorithm = compress ? VMDK4_COMPRESSION_DEFLATE : 0; header.capacity = filesize / BDRV_SECTOR_SIZE; header.granularity = 128; header.num_gtes_per_gt = BDRV_SECTOR_SIZE; grains = DIV_ROUND_UP(filesize / BDRV_SECTOR_SIZE, header.granularity); gt_size = DIV_ROUND_UP(header.num_gtes_per_gt * sizeof(uint32_t), BDRV_SECTOR_SIZE); gt_count = DIV_ROUND_UP(grains, header.num_gtes_per_gt); gd_sectors = DIV_ROUND_UP(gt_count * sizeof(uint32_t), BDRV_SECTOR_SIZE); header.desc_offset = 1; header.desc_size = 20; header.rgd_offset = header.desc_offset + header.desc_size; header.gd_offset = header.rgd_offset + gd_sectors + (gt_size * gt_count); header.grain_offset = ROUND_UP(header.gd_offset + gd_sectors + (gt_size * gt_count), header.granularity); header.version = cpu_to_le32(header.version); header.flags = cpu_to_le32(header.flags); header.capacity = cpu_to_le64(header.capacity); header.granularity = cpu_to_le64(header.granularity); header.num_gtes_per_gt = cpu_to_le32(header.num_gtes_per_gt); header.desc_offset = cpu_to_le64(header.desc_offset); header.desc_size = cpu_to_le64(header.desc_size); header.rgd_offset = cpu_to_le64(header.rgd_offset); header.gd_offset = cpu_to_le64(header.gd_offset); header.grain_offset = cpu_to_le64(header.grain_offset); header.compressAlgorithm = cpu_to_le16(header.compressAlgorithm); header.check_bytes[0] = 0xa; header.check_bytes[1] = 0x20; header.check_bytes[2] = 0xd; header.check_bytes[3] = 0xa; ret = bdrv_pwrite(bs, 0, &magic, sizeof(magic)); if (ret < 0) { error_set(errp, QERR_IO_ERROR); goto exit; } ret = bdrv_pwrite(bs, sizeof(magic), &header, sizeof(header)); if (ret < 0) { error_set(errp, QERR_IO_ERROR); goto exit; } ret = bdrv_truncate(bs, le64_to_cpu(header.grain_offset) << 9); if (ret < 0) { error_setg(errp, "Could not truncate file"); goto exit; } gd_buf_size = gd_sectors * BDRV_SECTOR_SIZE; gd_buf = g_malloc0(gd_buf_size); for (i = 0, tmp = le64_to_cpu(header.rgd_offset) + gd_sectors; i < gt_count; i++, tmp += gt_size) { gd_buf[i] = cpu_to_le32(tmp); } ret = bdrv_pwrite(bs, le64_to_cpu(header.rgd_offset) * BDRV_SECTOR_SIZE, gd_buf, gd_buf_size); if (ret < 0) { error_set(errp, QERR_IO_ERROR); goto exit; } for (i = 0, tmp = le64_to_cpu(header.gd_offset) + gd_sectors; i < gt_count; i++, tmp += gt_size) { gd_buf[i] = cpu_to_le32(tmp); } ret = bdrv_pwrite(bs, le64_to_cpu(header.gd_offset) * BDRV_SECTOR_SIZE, gd_buf, gd_buf_size); if (ret < 0) { error_set(errp, QERR_IO_ERROR); goto exit; } ret = 0; exit: if (bs) { bdrv_unref(bs); } g_free(gd_buf); return ret; }
{ "code": [ " error_setg(errp, \"Could not truncate file\");", " error_setg(errp, \"Could not truncate file\");", " error_setg(errp, \"Could not truncate file\");" ], "line_no": [ 55, 175, 55 ] }
static int FUNC_0(const char *VAR_0, int64_t VAR_1, bool VAR_2, bool VAR_3, bool VAR_4, Error **VAR_5) { int VAR_6, VAR_7; BlockDriverState *bs = NULL; VMDK4Header header; Error *local_err; uint32_t tmp, magic, grains, gd_sectors, gt_size, gt_count; uint32_t *gd_buf = NULL; int VAR_8; VAR_6 = bdrv_create_file(VAR_0, NULL, &local_err); if (VAR_6 < 0) { error_propagate(VAR_5, local_err); goto exit; } VAR_6 = bdrv_file_open(&bs, VAR_0, NULL, NULL, BDRV_O_RDWR, &local_err); if (VAR_6 < 0) { error_propagate(VAR_5, local_err); goto exit; } if (VAR_2) { VAR_6 = bdrv_truncate(bs, VAR_1); if (VAR_6 < 0) { error_setg(VAR_5, "Could not truncate file"); } goto exit; } magic = cpu_to_be32(VMDK4_MAGIC); memset(&header, 0, sizeof(header)); header.version = VAR_4 ? 2 : 1; header.flags = VMDK4_FLAG_RGD | VMDK4_FLAG_NL_DETECT | (VAR_3 ? VMDK4_FLAG_COMPRESS | VMDK4_FLAG_MARKER : 0) | (VAR_4 ? VMDK4_FLAG_ZERO_GRAIN : 0); header.compressAlgorithm = VAR_3 ? VMDK4_COMPRESSION_DEFLATE : 0; header.capacity = VAR_1 / BDRV_SECTOR_SIZE; header.granularity = 128; header.num_gtes_per_gt = BDRV_SECTOR_SIZE; grains = DIV_ROUND_UP(VAR_1 / BDRV_SECTOR_SIZE, header.granularity); gt_size = DIV_ROUND_UP(header.num_gtes_per_gt * sizeof(uint32_t), BDRV_SECTOR_SIZE); gt_count = DIV_ROUND_UP(grains, header.num_gtes_per_gt); gd_sectors = DIV_ROUND_UP(gt_count * sizeof(uint32_t), BDRV_SECTOR_SIZE); header.desc_offset = 1; header.desc_size = 20; header.rgd_offset = header.desc_offset + header.desc_size; header.gd_offset = header.rgd_offset + gd_sectors + (gt_size * gt_count); header.grain_offset = ROUND_UP(header.gd_offset + gd_sectors + (gt_size * gt_count), header.granularity); header.version = cpu_to_le32(header.version); header.flags = cpu_to_le32(header.flags); header.capacity = cpu_to_le64(header.capacity); header.granularity = cpu_to_le64(header.granularity); header.num_gtes_per_gt = cpu_to_le32(header.num_gtes_per_gt); header.desc_offset = cpu_to_le64(header.desc_offset); header.desc_size = cpu_to_le64(header.desc_size); header.rgd_offset = cpu_to_le64(header.rgd_offset); header.gd_offset = cpu_to_le64(header.gd_offset); header.grain_offset = cpu_to_le64(header.grain_offset); header.compressAlgorithm = cpu_to_le16(header.compressAlgorithm); header.check_bytes[0] = 0xa; header.check_bytes[1] = 0x20; header.check_bytes[2] = 0xd; header.check_bytes[3] = 0xa; VAR_6 = bdrv_pwrite(bs, 0, &magic, sizeof(magic)); if (VAR_6 < 0) { error_set(VAR_5, QERR_IO_ERROR); goto exit; } VAR_6 = bdrv_pwrite(bs, sizeof(magic), &header, sizeof(header)); if (VAR_6 < 0) { error_set(VAR_5, QERR_IO_ERROR); goto exit; } VAR_6 = bdrv_truncate(bs, le64_to_cpu(header.grain_offset) << 9); if (VAR_6 < 0) { error_setg(VAR_5, "Could not truncate file"); goto exit; } VAR_8 = gd_sectors * BDRV_SECTOR_SIZE; gd_buf = g_malloc0(VAR_8); for (VAR_7 = 0, tmp = le64_to_cpu(header.rgd_offset) + gd_sectors; VAR_7 < gt_count; VAR_7++, tmp += gt_size) { gd_buf[VAR_7] = cpu_to_le32(tmp); } VAR_6 = bdrv_pwrite(bs, le64_to_cpu(header.rgd_offset) * BDRV_SECTOR_SIZE, gd_buf, VAR_8); if (VAR_6 < 0) { error_set(VAR_5, QERR_IO_ERROR); goto exit; } for (VAR_7 = 0, tmp = le64_to_cpu(header.gd_offset) + gd_sectors; VAR_7 < gt_count; VAR_7++, tmp += gt_size) { gd_buf[VAR_7] = cpu_to_le32(tmp); } VAR_6 = bdrv_pwrite(bs, le64_to_cpu(header.gd_offset) * BDRV_SECTOR_SIZE, gd_buf, VAR_8); if (VAR_6 < 0) { error_set(VAR_5, QERR_IO_ERROR); goto exit; } VAR_6 = 0; exit: if (bs) { bdrv_unref(bs); } g_free(gd_buf); return VAR_6; }
[ "static int FUNC_0(const char *VAR_0, int64_t VAR_1,\nbool VAR_2, bool VAR_3, bool VAR_4,\nError **VAR_5)\n{", "int VAR_6, VAR_7;", "BlockDriverState *bs = NULL;", "VMDK4Header header;", "Error *local_err;", "uint32_t tmp, magic, grains, gd_sectors, gt_size, gt_count;", "uint32_t *gd_buf = NULL;", "int VAR_8;", "VAR_6 = bdrv_create_file(VAR_0, NULL, &local_err);", "if (VAR_6 < 0) {", "error_propagate(VAR_5, local_err);", "goto exit;", "}", "VAR_6 = bdrv_file_open(&bs, VAR_0, NULL, NULL, BDRV_O_RDWR, &local_err);", "if (VAR_6 < 0) {", "error_propagate(VAR_5, local_err);", "goto exit;", "}", "if (VAR_2) {", "VAR_6 = bdrv_truncate(bs, VAR_1);", "if (VAR_6 < 0) {", "error_setg(VAR_5, \"Could not truncate file\");", "}", "goto exit;", "}", "magic = cpu_to_be32(VMDK4_MAGIC);", "memset(&header, 0, sizeof(header));", "header.version = VAR_4 ? 2 : 1;", "header.flags = VMDK4_FLAG_RGD | VMDK4_FLAG_NL_DETECT\n| (VAR_3 ? VMDK4_FLAG_COMPRESS | VMDK4_FLAG_MARKER : 0)\n| (VAR_4 ? VMDK4_FLAG_ZERO_GRAIN : 0);", "header.compressAlgorithm = VAR_3 ? VMDK4_COMPRESSION_DEFLATE : 0;", "header.capacity = VAR_1 / BDRV_SECTOR_SIZE;", "header.granularity = 128;", "header.num_gtes_per_gt = BDRV_SECTOR_SIZE;", "grains = DIV_ROUND_UP(VAR_1 / BDRV_SECTOR_SIZE, header.granularity);", "gt_size = DIV_ROUND_UP(header.num_gtes_per_gt * sizeof(uint32_t),\nBDRV_SECTOR_SIZE);", "gt_count = DIV_ROUND_UP(grains, header.num_gtes_per_gt);", "gd_sectors = DIV_ROUND_UP(gt_count * sizeof(uint32_t), BDRV_SECTOR_SIZE);", "header.desc_offset = 1;", "header.desc_size = 20;", "header.rgd_offset = header.desc_offset + header.desc_size;", "header.gd_offset = header.rgd_offset + gd_sectors + (gt_size * gt_count);", "header.grain_offset =\nROUND_UP(header.gd_offset + gd_sectors + (gt_size * gt_count),\nheader.granularity);", "header.version = cpu_to_le32(header.version);", "header.flags = cpu_to_le32(header.flags);", "header.capacity = cpu_to_le64(header.capacity);", "header.granularity = cpu_to_le64(header.granularity);", "header.num_gtes_per_gt = cpu_to_le32(header.num_gtes_per_gt);", "header.desc_offset = cpu_to_le64(header.desc_offset);", "header.desc_size = cpu_to_le64(header.desc_size);", "header.rgd_offset = cpu_to_le64(header.rgd_offset);", "header.gd_offset = cpu_to_le64(header.gd_offset);", "header.grain_offset = cpu_to_le64(header.grain_offset);", "header.compressAlgorithm = cpu_to_le16(header.compressAlgorithm);", "header.check_bytes[0] = 0xa;", "header.check_bytes[1] = 0x20;", "header.check_bytes[2] = 0xd;", "header.check_bytes[3] = 0xa;", "VAR_6 = bdrv_pwrite(bs, 0, &magic, sizeof(magic));", "if (VAR_6 < 0) {", "error_set(VAR_5, QERR_IO_ERROR);", "goto exit;", "}", "VAR_6 = bdrv_pwrite(bs, sizeof(magic), &header, sizeof(header));", "if (VAR_6 < 0) {", "error_set(VAR_5, QERR_IO_ERROR);", "goto exit;", "}", "VAR_6 = bdrv_truncate(bs, le64_to_cpu(header.grain_offset) << 9);", "if (VAR_6 < 0) {", "error_setg(VAR_5, \"Could not truncate file\");", "goto exit;", "}", "VAR_8 = gd_sectors * BDRV_SECTOR_SIZE;", "gd_buf = g_malloc0(VAR_8);", "for (VAR_7 = 0, tmp = le64_to_cpu(header.rgd_offset) + gd_sectors;", "VAR_7 < gt_count; VAR_7++, tmp += gt_size) {", "gd_buf[VAR_7] = cpu_to_le32(tmp);", "}", "VAR_6 = bdrv_pwrite(bs, le64_to_cpu(header.rgd_offset) * BDRV_SECTOR_SIZE,\ngd_buf, VAR_8);", "if (VAR_6 < 0) {", "error_set(VAR_5, QERR_IO_ERROR);", "goto exit;", "}", "for (VAR_7 = 0, tmp = le64_to_cpu(header.gd_offset) + gd_sectors;", "VAR_7 < gt_count; VAR_7++, tmp += gt_size) {", "gd_buf[VAR_7] = cpu_to_le32(tmp);", "}", "VAR_6 = bdrv_pwrite(bs, le64_to_cpu(header.gd_offset) * BDRV_SECTOR_SIZE,\ngd_buf, VAR_8);", "if (VAR_6 < 0) {", "error_set(VAR_5, QERR_IO_ERROR);", "goto exit;", "}", "VAR_6 = 0;", "exit:\nif (bs) {", "bdrv_unref(bs);", "}", "g_free(gd_buf);", "return VAR_6;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69, 71, 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 85 ], [ 87, 89 ], [ 91 ], [ 93 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105, 107, 109 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197, 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221, 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 235 ], [ 237, 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ] ]
9,331
static void ppc_prep_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_order; MemoryRegion *sysmem = get_system_memory(); PowerPCCPU *cpu = NULL; CPUPPCState *env = NULL; nvram_t nvram; M48t59State *m48t59; PortioList *port_list = g_new(PortioList, 1); #if 0 MemoryRegion *xcsr = g_new(MemoryRegion, 1); #endif int linux_boot, i, nb_nics1; MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *vga = g_new(MemoryRegion, 1); uint32_t kernel_base, initrd_base; long kernel_size, initrd_size; DeviceState *dev; PCIHostState *pcihost; PCIBus *pci_bus; PCIDevice *pci; ISABus *isa_bus; ISADevice *isa; qemu_irq *cpu_exit_irq; int ppc_boot_device; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; sysctrl = g_malloc0(sizeof(sysctrl_t)); linux_boot = (kernel_filename != NULL); /* init CPUs */ if (cpu_model == NULL) cpu_model = "602"; 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; if (env->flags & POWERPC_FLAG_RTC_CLK) { /* POWER / PowerPC 601 RTC clock frequency is 7.8125 MHz */ cpu_ppc_tb_init(env, 7812500UL); } else { /* Set time-base frequency to 100 Mhz */ cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL); } qemu_register_reset(ppc_prep_reset, cpu); } /* allocate RAM */ memory_region_init_ram(ram, NULL, "ppc_prep.ram", ram_size); vmstate_register_ram_global(ram); memory_region_add_subregion(sysmem, 0, ram); if (linux_boot) { kernel_base = KERNEL_LOAD_ADDR; /* now we can load the kernel */ kernel_size = load_image_targphys(kernel_filename, kernel_base, ram_size - kernel_base); if (kernel_size < 0) { hw_error("qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } /* load initrd */ if (initrd_filename) { initrd_base = INITRD_LOAD_ADDR; initrd_size = load_image_targphys(initrd_filename, initrd_base, ram_size - initrd_base); if (initrd_size < 0) { hw_error("qemu: could not load initial ram disk '%s'\n", initrd_filename); } } else { initrd_base = 0; initrd_size = 0; } ppc_boot_device = 'm'; } else { kernel_base = 0; kernel_size = 0; initrd_base = 0; initrd_size = 0; ppc_boot_device = '\0'; /* For now, OHW cannot boot from the network. */ for (i = 0; boot_device[i] != '\0'; i++) { if (boot_device[i] >= 'a' && boot_device[i] <= 'f') { ppc_boot_device = boot_device[i]; break; } } if (ppc_boot_device == '\0') { fprintf(stderr, "No valid boot device for Mac99 machine\n"); exit(1); } } if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) { hw_error("Only 6xx bus is supported on PREP machine\n"); } dev = qdev_create(NULL, "raven-pcihost"); if (bios_name == NULL) { bios_name = BIOS_FILENAME; } qdev_prop_set_string(dev, "bios-name", bios_name); qdev_prop_set_uint32(dev, "elf-machine", ELF_MACHINE); pcihost = PCI_HOST_BRIDGE(dev); object_property_add_child(qdev_get_machine(), "raven", OBJECT(dev), NULL); qdev_init_nofail(dev); pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0"); if (pci_bus == NULL) { fprintf(stderr, "Couldn't create PCI host controller.\n"); exit(1); } sysctrl->contiguous_map_irq = qdev_get_gpio_in(dev, 0); /* PCI -> ISA bridge */ pci = pci_create_simple(pci_bus, PCI_DEVFN(1, 0), "i82378"); cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); cpu = POWERPC_CPU(first_cpu); qdev_connect_gpio_out(&pci->qdev, 0, cpu->env.irq_inputs[PPC6xx_INPUT_INT]); qdev_connect_gpio_out(&pci->qdev, 1, *cpu_exit_irq); sysbus_connect_irq(&pcihost->busdev, 0, qdev_get_gpio_in(&pci->qdev, 9)); sysbus_connect_irq(&pcihost->busdev, 1, qdev_get_gpio_in(&pci->qdev, 11)); sysbus_connect_irq(&pcihost->busdev, 2, qdev_get_gpio_in(&pci->qdev, 9)); sysbus_connect_irq(&pcihost->busdev, 3, qdev_get_gpio_in(&pci->qdev, 11)); isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(pci), "isa.0")); /* Super I/O (parallel + serial ports) */ isa = isa_create(isa_bus, TYPE_PC87312); dev = DEVICE(isa); qdev_prop_set_uint8(dev, "config", 13); /* fdc, ser0, ser1, par0 */ qdev_init_nofail(dev); /* init basic PC hardware */ pci_vga_init(pci_bus); /* Open Hack'Ware hack: PCI BAR#0 is programmed to 0xf0000000. * While bios will access framebuffer at 0xf0000000, real physical * address is 0xf0000000 + 0xc0000000 (PCI memory base). * Alias the wrong memory accesses to the right place. */ memory_region_init_alias(vga, NULL, "vga-alias", pci_address_space(pci), 0xf0000000, 0x1000000); memory_region_add_subregion_overlap(sysmem, 0xf0000000, vga, 10); nb_nics1 = nb_nics; if (nb_nics1 > NE2000_NB_MAX) nb_nics1 = NE2000_NB_MAX; for(i = 0; i < nb_nics1; i++) { if (nd_table[i].model == NULL) { nd_table[i].model = g_strdup("ne2k_isa"); } if (strcmp(nd_table[i].model, "ne2k_isa") == 0) { isa_ne2000_init(isa_bus, ne2000_io[i], ne2000_irq[i], &nd_table[i]); } else { pci_nic_init_nofail(&nd_table[i], pci_bus, "ne2k_pci", NULL); } } ide_drive_get(hd, MAX_IDE_BUS); for(i = 0; i < MAX_IDE_BUS; i++) { isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], ide_irq[i], hd[2 * i], hd[2 * i + 1]); } isa_create_simple(isa_bus, "i8042"); cpu = POWERPC_CPU(first_cpu); sysctrl->reset_irq = cpu->env.irq_inputs[PPC6xx_INPUT_HRESET]; portio_list_init(port_list, NULL, prep_portio_list, sysctrl, "prep"); portio_list_add(port_list, isa_address_space_io(isa), 0x0); /* PowerPC control and status register group */ #if 0 memory_region_init_io(xcsr, NULL, &PPC_XCSR_ops, NULL, "ppc-xcsr", 0x1000); memory_region_add_subregion(sysmem, 0xFEFF0000, xcsr); #endif if (usb_enabled(false)) { pci_create_simple(pci_bus, -1, "pci-ohci"); } m48t59 = m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 59); if (m48t59 == NULL) return; sysctrl->nvram = m48t59; /* Initialise NVRAM */ nvram.opaque = m48t59; nvram.read_fn = &m48t59_read; nvram.write_fn = &m48t59_write; PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "PREP", ram_size, ppc_boot_device, kernel_base, kernel_size, kernel_cmdline, initrd_base, initrd_size, /* XXX: need an option to load a NVRAM image */ 0, graphic_width, graphic_height, graphic_depth); }
true
qemu
848696bf353750899832c51005f1bd3540da5c29
static void ppc_prep_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_order; MemoryRegion *sysmem = get_system_memory(); PowerPCCPU *cpu = NULL; CPUPPCState *env = NULL; nvram_t nvram; M48t59State *m48t59; PortioList *port_list = g_new(PortioList, 1); #if 0 MemoryRegion *xcsr = g_new(MemoryRegion, 1); #endif int linux_boot, i, nb_nics1; MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *vga = g_new(MemoryRegion, 1); uint32_t kernel_base, initrd_base; long kernel_size, initrd_size; DeviceState *dev; PCIHostState *pcihost; PCIBus *pci_bus; PCIDevice *pci; ISABus *isa_bus; ISADevice *isa; qemu_irq *cpu_exit_irq; int ppc_boot_device; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; sysctrl = g_malloc0(sizeof(sysctrl_t)); linux_boot = (kernel_filename != NULL); if (cpu_model == NULL) cpu_model = "602"; 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; if (env->flags & POWERPC_FLAG_RTC_CLK) { cpu_ppc_tb_init(env, 7812500UL); } else { cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL); } qemu_register_reset(ppc_prep_reset, cpu); } memory_region_init_ram(ram, NULL, "ppc_prep.ram", ram_size); vmstate_register_ram_global(ram); memory_region_add_subregion(sysmem, 0, ram); if (linux_boot) { kernel_base = KERNEL_LOAD_ADDR; kernel_size = load_image_targphys(kernel_filename, kernel_base, ram_size - kernel_base); if (kernel_size < 0) { hw_error("qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } if (initrd_filename) { initrd_base = INITRD_LOAD_ADDR; initrd_size = load_image_targphys(initrd_filename, initrd_base, ram_size - initrd_base); if (initrd_size < 0) { hw_error("qemu: could not load initial ram disk '%s'\n", initrd_filename); } } else { initrd_base = 0; initrd_size = 0; } ppc_boot_device = 'm'; } else { kernel_base = 0; kernel_size = 0; initrd_base = 0; initrd_size = 0; ppc_boot_device = '\0'; for (i = 0; boot_device[i] != '\0'; i++) { if (boot_device[i] >= 'a' && boot_device[i] <= 'f') { ppc_boot_device = boot_device[i]; break; } } if (ppc_boot_device == '\0') { fprintf(stderr, "No valid boot device for Mac99 machine\n"); exit(1); } } if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) { hw_error("Only 6xx bus is supported on PREP machine\n"); } dev = qdev_create(NULL, "raven-pcihost"); if (bios_name == NULL) { bios_name = BIOS_FILENAME; } qdev_prop_set_string(dev, "bios-name", bios_name); qdev_prop_set_uint32(dev, "elf-machine", ELF_MACHINE); pcihost = PCI_HOST_BRIDGE(dev); object_property_add_child(qdev_get_machine(), "raven", OBJECT(dev), NULL); qdev_init_nofail(dev); pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0"); if (pci_bus == NULL) { fprintf(stderr, "Couldn't create PCI host controller.\n"); exit(1); } sysctrl->contiguous_map_irq = qdev_get_gpio_in(dev, 0); pci = pci_create_simple(pci_bus, PCI_DEVFN(1, 0), "i82378"); cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); cpu = POWERPC_CPU(first_cpu); qdev_connect_gpio_out(&pci->qdev, 0, cpu->env.irq_inputs[PPC6xx_INPUT_INT]); qdev_connect_gpio_out(&pci->qdev, 1, *cpu_exit_irq); sysbus_connect_irq(&pcihost->busdev, 0, qdev_get_gpio_in(&pci->qdev, 9)); sysbus_connect_irq(&pcihost->busdev, 1, qdev_get_gpio_in(&pci->qdev, 11)); sysbus_connect_irq(&pcihost->busdev, 2, qdev_get_gpio_in(&pci->qdev, 9)); sysbus_connect_irq(&pcihost->busdev, 3, qdev_get_gpio_in(&pci->qdev, 11)); isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(pci), "isa.0")); isa = isa_create(isa_bus, TYPE_PC87312); dev = DEVICE(isa); qdev_prop_set_uint8(dev, "config", 13); qdev_init_nofail(dev); pci_vga_init(pci_bus); memory_region_init_alias(vga, NULL, "vga-alias", pci_address_space(pci), 0xf0000000, 0x1000000); memory_region_add_subregion_overlap(sysmem, 0xf0000000, vga, 10); nb_nics1 = nb_nics; if (nb_nics1 > NE2000_NB_MAX) nb_nics1 = NE2000_NB_MAX; for(i = 0; i < nb_nics1; i++) { if (nd_table[i].model == NULL) { nd_table[i].model = g_strdup("ne2k_isa"); } if (strcmp(nd_table[i].model, "ne2k_isa") == 0) { isa_ne2000_init(isa_bus, ne2000_io[i], ne2000_irq[i], &nd_table[i]); } else { pci_nic_init_nofail(&nd_table[i], pci_bus, "ne2k_pci", NULL); } } ide_drive_get(hd, MAX_IDE_BUS); for(i = 0; i < MAX_IDE_BUS; i++) { isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], ide_irq[i], hd[2 * i], hd[2 * i + 1]); } isa_create_simple(isa_bus, "i8042"); cpu = POWERPC_CPU(first_cpu); sysctrl->reset_irq = cpu->env.irq_inputs[PPC6xx_INPUT_HRESET]; portio_list_init(port_list, NULL, prep_portio_list, sysctrl, "prep"); portio_list_add(port_list, isa_address_space_io(isa), 0x0); #if 0 memory_region_init_io(xcsr, NULL, &PPC_XCSR_ops, NULL, "ppc-xcsr", 0x1000); memory_region_add_subregion(sysmem, 0xFEFF0000, xcsr); #endif if (usb_enabled(false)) { pci_create_simple(pci_bus, -1, "pci-ohci"); } m48t59 = m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 59); if (m48t59 == NULL) return; sysctrl->nvram = m48t59; nvram.opaque = m48t59; nvram.read_fn = &m48t59_read; nvram.write_fn = &m48t59_write; PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "PREP", ram_size, ppc_boot_device, kernel_base, kernel_size, kernel_cmdline, initrd_base, initrd_size, 0, graphic_width, graphic_height, graphic_depth); }
{ "code": [ " PortioList *port_list = g_new(PortioList, 1);", " PortioList *port_list = g_new(PortioList, 1);", " PortioList *port_list = g_new(PortioList, 1);", " portio_list_init(port_list, NULL, prep_portio_list, sysctrl, \"prep\");", " portio_list_add(port_list, isa_address_space_io(isa), 0x0);", " PortioList *port_list = g_new(PortioList, 1);" ], "line_no": [ 27, 27, 27, 361, 363, 27 ] }
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->boot_order; MemoryRegion *sysmem = get_system_memory(); PowerPCCPU *cpu = NULL; CPUPPCState *env = NULL; nvram_t nvram; M48t59State *m48t59; PortioList *port_list = g_new(PortioList, 1); #if 0 MemoryRegion *xcsr = g_new(MemoryRegion, 1); #endif int VAR_6, VAR_7, VAR_8; MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *vga = g_new(MemoryRegion, 1); uint32_t kernel_base, initrd_base; long VAR_9, VAR_10; DeviceState *dev; PCIHostState *pcihost; PCIBus *pci_bus; PCIDevice *pci; ISABus *isa_bus; ISADevice *isa; qemu_irq *cpu_exit_irq; int VAR_11; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; sysctrl = g_malloc0(sizeof(sysctrl_t)); VAR_6 = (VAR_2 != NULL); if (VAR_1 == NULL) VAR_1 = "602"; for (VAR_7 = 0; VAR_7 < smp_cpus; VAR_7++) { cpu = cpu_ppc_init(VAR_1); if (cpu == NULL) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); } env = &cpu->env; if (env->flags & POWERPC_FLAG_RTC_CLK) { cpu_ppc_tb_init(env, 7812500UL); } else { cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL); } qemu_register_reset(ppc_prep_reset, cpu); } memory_region_init_ram(ram, NULL, "ppc_prep.ram", ram_size); vmstate_register_ram_global(ram); memory_region_add_subregion(sysmem, 0, ram); if (VAR_6) { kernel_base = KERNEL_LOAD_ADDR; VAR_9 = load_image_targphys(VAR_2, kernel_base, ram_size - kernel_base); if (VAR_9 < 0) { hw_error("qemu: could not load kernel '%s'\n", VAR_2); exit(1); } if (VAR_4) { initrd_base = INITRD_LOAD_ADDR; VAR_10 = load_image_targphys(VAR_4, initrd_base, ram_size - initrd_base); if (VAR_10 < 0) { hw_error("qemu: could not load initial ram disk '%s'\n", VAR_4); } } else { initrd_base = 0; VAR_10 = 0; } VAR_11 = 'm'; } else { kernel_base = 0; VAR_9 = 0; initrd_base = 0; VAR_10 = 0; VAR_11 = '\0'; for (VAR_7 = 0; VAR_5[VAR_7] != '\0'; VAR_7++) { if (VAR_5[VAR_7] >= 'a' && VAR_5[VAR_7] <= 'f') { VAR_11 = VAR_5[VAR_7]; break; } } if (VAR_11 == '\0') { fprintf(stderr, "No valid boot device for Mac99 machine\n"); exit(1); } } if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) { hw_error("Only 6xx bus is supported on PREP machine\n"); } dev = qdev_create(NULL, "raven-pcihost"); if (bios_name == NULL) { bios_name = BIOS_FILENAME; } qdev_prop_set_string(dev, "bios-name", bios_name); qdev_prop_set_uint32(dev, "elf-machine", ELF_MACHINE); pcihost = PCI_HOST_BRIDGE(dev); object_property_add_child(qdev_get_machine(), "raven", OBJECT(dev), NULL); qdev_init_nofail(dev); pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0"); if (pci_bus == NULL) { fprintf(stderr, "Couldn't create PCI host controller.\n"); exit(1); } sysctrl->contiguous_map_irq = qdev_get_gpio_in(dev, 0); pci = pci_create_simple(pci_bus, PCI_DEVFN(1, 0), "i82378"); cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); cpu = POWERPC_CPU(first_cpu); qdev_connect_gpio_out(&pci->qdev, 0, cpu->env.irq_inputs[PPC6xx_INPUT_INT]); qdev_connect_gpio_out(&pci->qdev, 1, *cpu_exit_irq); sysbus_connect_irq(&pcihost->busdev, 0, qdev_get_gpio_in(&pci->qdev, 9)); sysbus_connect_irq(&pcihost->busdev, 1, qdev_get_gpio_in(&pci->qdev, 11)); sysbus_connect_irq(&pcihost->busdev, 2, qdev_get_gpio_in(&pci->qdev, 9)); sysbus_connect_irq(&pcihost->busdev, 3, qdev_get_gpio_in(&pci->qdev, 11)); isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(pci), "isa.0")); isa = isa_create(isa_bus, TYPE_PC87312); dev = DEVICE(isa); qdev_prop_set_uint8(dev, "config", 13); qdev_init_nofail(dev); pci_vga_init(pci_bus); memory_region_init_alias(vga, NULL, "vga-alias", pci_address_space(pci), 0xf0000000, 0x1000000); memory_region_add_subregion_overlap(sysmem, 0xf0000000, vga, 10); VAR_8 = nb_nics; if (VAR_8 > NE2000_NB_MAX) VAR_8 = NE2000_NB_MAX; for(VAR_7 = 0; VAR_7 < VAR_8; VAR_7++) { if (nd_table[VAR_7].model == NULL) { nd_table[VAR_7].model = g_strdup("ne2k_isa"); } if (strcmp(nd_table[VAR_7].model, "ne2k_isa") == 0) { isa_ne2000_init(isa_bus, ne2000_io[VAR_7], ne2000_irq[VAR_7], &nd_table[VAR_7]); } else { pci_nic_init_nofail(&nd_table[VAR_7], pci_bus, "ne2k_pci", NULL); } } ide_drive_get(hd, MAX_IDE_BUS); for(VAR_7 = 0; VAR_7 < MAX_IDE_BUS; VAR_7++) { isa_ide_init(isa_bus, ide_iobase[VAR_7], ide_iobase2[VAR_7], ide_irq[VAR_7], hd[2 * VAR_7], hd[2 * VAR_7 + 1]); } isa_create_simple(isa_bus, "i8042"); cpu = POWERPC_CPU(first_cpu); sysctrl->reset_irq = cpu->env.irq_inputs[PPC6xx_INPUT_HRESET]; portio_list_init(port_list, NULL, prep_portio_list, sysctrl, "prep"); portio_list_add(port_list, isa_address_space_io(isa), 0x0); #if 0 memory_region_init_io(xcsr, NULL, &PPC_XCSR_ops, NULL, "ppc-xcsr", 0x1000); memory_region_add_subregion(sysmem, 0xFEFF0000, xcsr); #endif if (usb_enabled(false)) { pci_create_simple(pci_bus, -1, "pci-ohci"); } m48t59 = m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 59); if (m48t59 == NULL) return; sysctrl->nvram = m48t59; nvram.opaque = m48t59; nvram.read_fn = &m48t59_read; nvram.write_fn = &m48t59_write; PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "PREP", ram_size, VAR_11, kernel_base, VAR_9, VAR_3, initrd_base, VAR_10, 0, graphic_width, graphic_height, graphic_depth); }
[ "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->boot_order;", "MemoryRegion *sysmem = get_system_memory();", "PowerPCCPU *cpu = NULL;", "CPUPPCState *env = NULL;", "nvram_t nvram;", "M48t59State *m48t59;", "PortioList *port_list = g_new(PortioList, 1);", "#if 0\nMemoryRegion *xcsr = g_new(MemoryRegion, 1);", "#endif\nint VAR_6, VAR_7, VAR_8;", "MemoryRegion *ram = g_new(MemoryRegion, 1);", "MemoryRegion *vga = g_new(MemoryRegion, 1);", "uint32_t kernel_base, initrd_base;", "long VAR_9, VAR_10;", "DeviceState *dev;", "PCIHostState *pcihost;", "PCIBus *pci_bus;", "PCIDevice *pci;", "ISABus *isa_bus;", "ISADevice *isa;", "qemu_irq *cpu_exit_irq;", "int VAR_11;", "DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];", "sysctrl = g_malloc0(sizeof(sysctrl_t));", "VAR_6 = (VAR_2 != NULL);", "if (VAR_1 == NULL)\nVAR_1 = \"602\";", "for (VAR_7 = 0; VAR_7 < smp_cpus; VAR_7++) {", "cpu = cpu_ppc_init(VAR_1);", "if (cpu == NULL) {", "fprintf(stderr, \"Unable to find PowerPC CPU definition\\n\");", "exit(1);", "}", "env = &cpu->env;", "if (env->flags & POWERPC_FLAG_RTC_CLK) {", "cpu_ppc_tb_init(env, 7812500UL);", "} else {", "cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);", "}", "qemu_register_reset(ppc_prep_reset, cpu);", "}", "memory_region_init_ram(ram, NULL, \"ppc_prep.ram\", ram_size);", "vmstate_register_ram_global(ram);", "memory_region_add_subregion(sysmem, 0, ram);", "if (VAR_6) {", "kernel_base = KERNEL_LOAD_ADDR;", "VAR_9 = load_image_targphys(VAR_2, kernel_base,\nram_size - kernel_base);", "if (VAR_9 < 0) {", "hw_error(\"qemu: could not load kernel '%s'\\n\", VAR_2);", "exit(1);", "}", "if (VAR_4) {", "initrd_base = INITRD_LOAD_ADDR;", "VAR_10 = load_image_targphys(VAR_4, initrd_base,\nram_size - initrd_base);", "if (VAR_10 < 0) {", "hw_error(\"qemu: could not load initial ram disk '%s'\\n\",\nVAR_4);", "}", "} else {", "initrd_base = 0;", "VAR_10 = 0;", "}", "VAR_11 = 'm';", "} else {", "kernel_base = 0;", "VAR_9 = 0;", "initrd_base = 0;", "VAR_10 = 0;", "VAR_11 = '\\0';", "for (VAR_7 = 0; VAR_5[VAR_7] != '\\0'; VAR_7++) {", "if (VAR_5[VAR_7] >= 'a' && VAR_5[VAR_7] <= 'f') {", "VAR_11 = VAR_5[VAR_7];", "break;", "}", "}", "if (VAR_11 == '\\0') {", "fprintf(stderr, \"No valid boot device for Mac99 machine\\n\");", "exit(1);", "}", "}", "if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {", "hw_error(\"Only 6xx bus is supported on PREP machine\\n\");", "}", "dev = qdev_create(NULL, \"raven-pcihost\");", "if (bios_name == NULL) {", "bios_name = BIOS_FILENAME;", "}", "qdev_prop_set_string(dev, \"bios-name\", bios_name);", "qdev_prop_set_uint32(dev, \"elf-machine\", ELF_MACHINE);", "pcihost = PCI_HOST_BRIDGE(dev);", "object_property_add_child(qdev_get_machine(), \"raven\", OBJECT(dev), NULL);", "qdev_init_nofail(dev);", "pci_bus = (PCIBus *)qdev_get_child_bus(dev, \"pci.0\");", "if (pci_bus == NULL) {", "fprintf(stderr, \"Couldn't create PCI host controller.\\n\");", "exit(1);", "}", "sysctrl->contiguous_map_irq = qdev_get_gpio_in(dev, 0);", "pci = pci_create_simple(pci_bus, PCI_DEVFN(1, 0), \"i82378\");", "cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);", "cpu = POWERPC_CPU(first_cpu);", "qdev_connect_gpio_out(&pci->qdev, 0,\ncpu->env.irq_inputs[PPC6xx_INPUT_INT]);", "qdev_connect_gpio_out(&pci->qdev, 1, *cpu_exit_irq);", "sysbus_connect_irq(&pcihost->busdev, 0, qdev_get_gpio_in(&pci->qdev, 9));", "sysbus_connect_irq(&pcihost->busdev, 1, qdev_get_gpio_in(&pci->qdev, 11));", "sysbus_connect_irq(&pcihost->busdev, 2, qdev_get_gpio_in(&pci->qdev, 9));", "sysbus_connect_irq(&pcihost->busdev, 3, qdev_get_gpio_in(&pci->qdev, 11));", "isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(pci), \"isa.0\"));", "isa = isa_create(isa_bus, TYPE_PC87312);", "dev = DEVICE(isa);", "qdev_prop_set_uint8(dev, \"config\", 13);", "qdev_init_nofail(dev);", "pci_vga_init(pci_bus);", "memory_region_init_alias(vga, NULL, \"vga-alias\", pci_address_space(pci),\n0xf0000000, 0x1000000);", "memory_region_add_subregion_overlap(sysmem, 0xf0000000, vga, 10);", "VAR_8 = nb_nics;", "if (VAR_8 > NE2000_NB_MAX)\nVAR_8 = NE2000_NB_MAX;", "for(VAR_7 = 0; VAR_7 < VAR_8; VAR_7++) {", "if (nd_table[VAR_7].model == NULL) {", "nd_table[VAR_7].model = g_strdup(\"ne2k_isa\");", "}", "if (strcmp(nd_table[VAR_7].model, \"ne2k_isa\") == 0) {", "isa_ne2000_init(isa_bus, ne2000_io[VAR_7], ne2000_irq[VAR_7],\n&nd_table[VAR_7]);", "} else {", "pci_nic_init_nofail(&nd_table[VAR_7], pci_bus, \"ne2k_pci\", NULL);", "}", "}", "ide_drive_get(hd, MAX_IDE_BUS);", "for(VAR_7 = 0; VAR_7 < MAX_IDE_BUS; VAR_7++) {", "isa_ide_init(isa_bus, ide_iobase[VAR_7], ide_iobase2[VAR_7], ide_irq[VAR_7],\nhd[2 * VAR_7],\nhd[2 * VAR_7 + 1]);", "}", "isa_create_simple(isa_bus, \"i8042\");", "cpu = POWERPC_CPU(first_cpu);", "sysctrl->reset_irq = cpu->env.irq_inputs[PPC6xx_INPUT_HRESET];", "portio_list_init(port_list, NULL, prep_portio_list, sysctrl, \"prep\");", "portio_list_add(port_list, isa_address_space_io(isa), 0x0);", "#if 0\nmemory_region_init_io(xcsr, NULL, &PPC_XCSR_ops, NULL, \"ppc-xcsr\", 0x1000);", "memory_region_add_subregion(sysmem, 0xFEFF0000, xcsr);", "#endif\nif (usb_enabled(false)) {", "pci_create_simple(pci_bus, -1, \"pci-ohci\");", "}", "m48t59 = m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 59);", "if (m48t59 == NULL)\nreturn;", "sysctrl->nvram = m48t59;", "nvram.opaque = m48t59;", "nvram.read_fn = &m48t59_read;", "nvram.write_fn = &m48t59_write;", "PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, \"PREP\", ram_size, VAR_11,\nkernel_base, VAR_9,\nVAR_3,\ninitrd_base, VAR_10,\n0,\ngraphic_width, graphic_height, graphic_depth);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 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 ], [ 65 ], [ 69 ], [ 75, 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 95 ], [ 99 ], [ 101 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 117 ], [ 119 ], [ 121 ], [ 125 ], [ 127 ], [ 131, 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 145 ], [ 147 ], [ 149, 151 ], [ 153 ], [ 155, 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 209 ], [ 211 ], [ 213 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 251 ], [ 253 ], [ 255 ], [ 257, 259 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 269 ], [ 271 ], [ 277 ], [ 279 ], [ 281 ], [ 283 ], [ 289 ], [ 301, 303 ], [ 305 ], [ 309 ], [ 311, 313 ], [ 315 ], [ 317 ], [ 319 ], [ 321 ], [ 323 ], [ 325, 327 ], [ 329 ], [ 331 ], [ 333 ], [ 335 ], [ 339 ], [ 341 ], [ 343, 345, 347 ], [ 349 ], [ 351 ], [ 355 ], [ 357 ], [ 361 ], [ 363 ], [ 369, 371 ], [ 373 ], [ 375, 379 ], [ 381 ], [ 383 ], [ 387 ], [ 389, 391 ], [ 393 ], [ 399 ], [ 401 ], [ 403 ], [ 405, 407, 409, 411, 415, 417 ], [ 419 ] ]
9,332
int boot_sector_init(char *fname) { int fd, ret; size_t len = sizeof boot_sector; fd = mkstemp(fname); if (fd < 0) { fprintf(stderr, "Couldn't open \"%s\": %s", fname, strerror(errno)); return 1; } /* For Open Firmware based system, we can use a Forth script instead */ if (strcmp(qtest_get_arch(), "ppc64") == 0) { len = sprintf((char *)boot_sector, "\\ Bootscript\n%x %x c! %x %x c!\n", LOW(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET, HIGH(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1); } ret = write(fd, boot_sector, len); close(fd); if (ret != len) { fprintf(stderr, "Could not write \"%s\"", fname); return 1; } return 0; }
true
qemu
83898cce62ba25a473af6a164388105994481e9c
int boot_sector_init(char *fname) { int fd, ret; size_t len = sizeof boot_sector; fd = mkstemp(fname); if (fd < 0) { fprintf(stderr, "Couldn't open \"%s\": %s", fname, strerror(errno)); return 1; } if (strcmp(qtest_get_arch(), "ppc64") == 0) { len = sprintf((char *)boot_sector, "\\ Bootscript\n%x %x c! %x %x c!\n", LOW(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET, HIGH(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1); } ret = write(fd, boot_sector, len); close(fd); if (ret != len) { fprintf(stderr, "Could not write \"%s\"", fname); return 1; } return 0; }
{ "code": [ " size_t len = sizeof boot_sector;", " if (strcmp(qtest_get_arch(), \"ppc64\") == 0) {", " len = sprintf((char *)boot_sector, \"\\\\ Bootscript\\n%x %x c! %x %x c!\\n\",", " LOW(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET,", " HIGH(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);", " ret = write(fd, boot_sector, len);" ], "line_no": [ 7, 25, 27, 29, 31, 37 ] }
int FUNC_0(char *VAR_0) { int VAR_1, VAR_2; size_t len = sizeof boot_sector; VAR_1 = mkstemp(VAR_0); if (VAR_1 < 0) { fprintf(stderr, "Couldn't open \"%s\": %s", VAR_0, strerror(errno)); return 1; } if (strcmp(qtest_get_arch(), "ppc64") == 0) { len = sprintf((char *)boot_sector, "\\ Bootscript\n%x %x c! %x %x c!\n", LOW(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET, HIGH(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1); } VAR_2 = write(VAR_1, boot_sector, len); close(VAR_1); if (VAR_2 != len) { fprintf(stderr, "Could not write \"%s\"", VAR_0); return 1; } return 0; }
[ "int FUNC_0(char *VAR_0)\n{", "int VAR_1, VAR_2;", "size_t len = sizeof boot_sector;", "VAR_1 = mkstemp(VAR_0);", "if (VAR_1 < 0) {", "fprintf(stderr, \"Couldn't open \\\"%s\\\": %s\", VAR_0, strerror(errno));", "return 1;", "}", "if (strcmp(qtest_get_arch(), \"ppc64\") == 0) {", "len = sprintf((char *)boot_sector, \"\\\\ Bootscript\\n%x %x c! %x %x c!\\n\",\nLOW(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET,\nHIGH(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);", "}", "VAR_2 = write(VAR_1, boot_sector, len);", "close(VAR_1);", "if (VAR_2 != len) {", "fprintf(stderr, \"Could not write \\\"%s\\\"\", VAR_0);", "return 1;", "}", "return 0;", "}" ]
[ 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 25 ], [ 27, 29, 31 ], [ 33 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ] ]
9,335
static int usbnet_can_receive(VLANClientState *nc) { USBNetState *s = DO_UPCAST(NICState, nc, nc)->opaque; if (is_rndis(s) && !s->rndis_state == RNDIS_DATA_INITIALIZED) { return 1; } return !s->in_len; }
true
qemu
98d23704138e0be17a3ed9eb2631077bf92cc028
static int usbnet_can_receive(VLANClientState *nc) { USBNetState *s = DO_UPCAST(NICState, nc, nc)->opaque; if (is_rndis(s) && !s->rndis_state == RNDIS_DATA_INITIALIZED) { return 1; } return !s->in_len; }
{ "code": [ " if (is_rndis(s) && !s->rndis_state == RNDIS_DATA_INITIALIZED) {" ], "line_no": [ 9 ] }
static int FUNC_0(VLANClientState *VAR_0) { USBNetState *s = DO_UPCAST(NICState, VAR_0, VAR_0)->opaque; if (is_rndis(s) && !s->rndis_state == RNDIS_DATA_INITIALIZED) { return 1; } return !s->in_len; }
[ "static int FUNC_0(VLANClientState *VAR_0)\n{", "USBNetState *s = DO_UPCAST(NICState, VAR_0, VAR_0)->opaque;", "if (is_rndis(s) && !s->rndis_state == RNDIS_DATA_INITIALIZED) {", "return 1;", "}", "return !s->in_len;", "}" ]
[ 0, 0, 1, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ] ]
9,336
static void virtio_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(dev); Error *err = NULL; /* Devices should either use vmsd or the load/save methods */ assert(!vdc->vmsd || !vdc->load); if (vdc->realize != NULL) { vdc->realize(dev, &err); if (err != NULL) { error_propagate(errp, err); return; } } virtio_bus_device_plugged(vdev, &err); if (err != NULL) { error_propagate(errp, err); return; } vdev->listener.commit = virtio_memory_listener_commit; memory_listener_register(&vdev->listener, vdev->dma_as); }
true
qemu
7abea552aba6e85b338015726648974d6d6f19c8
static void virtio_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(dev); Error *err = NULL; assert(!vdc->vmsd || !vdc->load); if (vdc->realize != NULL) { vdc->realize(dev, &err); if (err != NULL) { error_propagate(errp, err); return; } } virtio_bus_device_plugged(vdev, &err); if (err != NULL) { error_propagate(errp, err); return; } vdev->listener.commit = virtio_memory_listener_commit; memory_listener_register(&vdev->listener, vdev->dma_as); }
{ "code": [], "line_no": [] }
static void FUNC_0(DeviceState *VAR_0, Error **VAR_1) { VirtIODevice *vdev = VIRTIO_DEVICE(VAR_0); VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(VAR_0); Error *err = NULL; assert(!vdc->vmsd || !vdc->load); if (vdc->realize != NULL) { vdc->realize(VAR_0, &err); if (err != NULL) { error_propagate(VAR_1, err); return; } } virtio_bus_device_plugged(vdev, &err); if (err != NULL) { error_propagate(VAR_1, err); return; } vdev->listener.commit = virtio_memory_listener_commit; memory_listener_register(&vdev->listener, vdev->dma_as); }
[ "static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{", "VirtIODevice *vdev = VIRTIO_DEVICE(VAR_0);", "VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(VAR_0);", "Error *err = NULL;", "assert(!vdc->vmsd || !vdc->load);", "if (vdc->realize != NULL) {", "vdc->realize(VAR_0, &err);", "if (err != NULL) {", "error_propagate(VAR_1, err);", "return;", "}", "}", "virtio_bus_device_plugged(vdev, &err);", "if (err != NULL) {", "error_propagate(VAR_1, err);", "return;", "}", "vdev->listener.commit = virtio_memory_listener_commit;", "memory_listener_register(&vdev->listener, vdev->dma_as);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 42 ], [ 44 ], [ 48 ], [ 50 ], [ 52 ] ]
9,337
int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecContext *codec, int idx) { int i; AVOutputFormat *ofmt = fmt ? fmt->oformat : NULL; /* Was the payload type already specified for the RTP muxer? */ if (ofmt && ofmt->priv_class && fmt->priv_data) { int64_t payload_type; if (av_opt_get_int(fmt->priv_data, "payload_type", 0, &payload_type) >= 0 && payload_type >= 0) return (int)payload_type; } /* static payload type */ for (i = 0; rtp_payload_types[i].pt >= 0; ++i) if (rtp_payload_types[i].codec_id == codec->codec_id) { if (codec->codec_id == AV_CODEC_ID_H263 && (!fmt || !fmt->oformat->priv_class || !av_opt_flag_is_set(fmt->priv_data, "rtpflags", "rfc2190"))) continue; /* G722 has 8000 as nominal rate even if the sample rate is 16000, * see section 4.5.2 in RFC 3551. */ if (codec->codec_id == AV_CODEC_ID_ADPCM_G722 && codec->sample_rate == 16000 && codec->channels == 1) return rtp_payload_types[i].pt; if (codec->codec_type == AVMEDIA_TYPE_AUDIO && ((rtp_payload_types[i].clock_rate > 0 && codec->sample_rate != rtp_payload_types[i].clock_rate) || (rtp_payload_types[i].audio_channels > 0 && codec->channels != rtp_payload_types[i].audio_channels))) continue; return rtp_payload_types[i].pt; } if (idx < 0) idx = codec->codec_type == AVMEDIA_TYPE_AUDIO; /* dynamic payload type */ return RTP_PT_PRIVATE + idx; }
true
FFmpeg
e90820d4f815c15796e642467cdddbad755212a2
int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecContext *codec, int idx) { int i; AVOutputFormat *ofmt = fmt ? fmt->oformat : NULL; if (ofmt && ofmt->priv_class && fmt->priv_data) { int64_t payload_type; if (av_opt_get_int(fmt->priv_data, "payload_type", 0, &payload_type) >= 0 && payload_type >= 0) return (int)payload_type; } for (i = 0; rtp_payload_types[i].pt >= 0; ++i) if (rtp_payload_types[i].codec_id == codec->codec_id) { if (codec->codec_id == AV_CODEC_ID_H263 && (!fmt || !fmt->oformat->priv_class || !av_opt_flag_is_set(fmt->priv_data, "rtpflags", "rfc2190"))) continue; if (codec->codec_id == AV_CODEC_ID_ADPCM_G722 && codec->sample_rate == 16000 && codec->channels == 1) return rtp_payload_types[i].pt; if (codec->codec_type == AVMEDIA_TYPE_AUDIO && ((rtp_payload_types[i].clock_rate > 0 && codec->sample_rate != rtp_payload_types[i].clock_rate) || (rtp_payload_types[i].audio_channels > 0 && codec->channels != rtp_payload_types[i].audio_channels))) continue; return rtp_payload_types[i].pt; } if (idx < 0) idx = codec->codec_type == AVMEDIA_TYPE_AUDIO; return RTP_PT_PRIVATE + idx; }
{ "code": [ " !fmt->oformat->priv_class ||" ], "line_no": [ 37 ] }
int FUNC_0(AVFormatContext *VAR_0, AVCodecContext *VAR_1, int VAR_2) { int VAR_3; AVOutputFormat *ofmt = VAR_0 ? VAR_0->oformat : NULL; if (ofmt && ofmt->priv_class && VAR_0->priv_data) { int64_t payload_type; if (av_opt_get_int(VAR_0->priv_data, "payload_type", 0, &payload_type) >= 0 && payload_type >= 0) return (int)payload_type; } for (VAR_3 = 0; rtp_payload_types[VAR_3].pt >= 0; ++VAR_3) if (rtp_payload_types[VAR_3].codec_id == VAR_1->codec_id) { if (VAR_1->codec_id == AV_CODEC_ID_H263 && (!VAR_0 || !VAR_0->oformat->priv_class || !av_opt_flag_is_set(VAR_0->priv_data, "rtpflags", "rfc2190"))) continue; if (VAR_1->codec_id == AV_CODEC_ID_ADPCM_G722 && VAR_1->sample_rate == 16000 && VAR_1->channels == 1) return rtp_payload_types[VAR_3].pt; if (VAR_1->codec_type == AVMEDIA_TYPE_AUDIO && ((rtp_payload_types[VAR_3].clock_rate > 0 && VAR_1->sample_rate != rtp_payload_types[VAR_3].clock_rate) || (rtp_payload_types[VAR_3].audio_channels > 0 && VAR_1->channels != rtp_payload_types[VAR_3].audio_channels))) continue; return rtp_payload_types[VAR_3].pt; } if (VAR_2 < 0) VAR_2 = VAR_1->codec_type == AVMEDIA_TYPE_AUDIO; return RTP_PT_PRIVATE + VAR_2; }
[ "int FUNC_0(AVFormatContext *VAR_0,\nAVCodecContext *VAR_1, int VAR_2)\n{", "int VAR_3;", "AVOutputFormat *ofmt = VAR_0 ? VAR_0->oformat : NULL;", "if (ofmt && ofmt->priv_class && VAR_0->priv_data) {", "int64_t payload_type;", "if (av_opt_get_int(VAR_0->priv_data, \"payload_type\", 0, &payload_type) >= 0 &&\npayload_type >= 0)\nreturn (int)payload_type;", "}", "for (VAR_3 = 0; rtp_payload_types[VAR_3].pt >= 0; ++VAR_3)", "if (rtp_payload_types[VAR_3].codec_id == VAR_1->codec_id) {", "if (VAR_1->codec_id == AV_CODEC_ID_H263 && (!VAR_0 ||\n!VAR_0->oformat->priv_class ||\n!av_opt_flag_is_set(VAR_0->priv_data, \"rtpflags\", \"rfc2190\")))\ncontinue;", "if (VAR_1->codec_id == AV_CODEC_ID_ADPCM_G722 &&\nVAR_1->sample_rate == 16000 && VAR_1->channels == 1)\nreturn rtp_payload_types[VAR_3].pt;", "if (VAR_1->codec_type == AVMEDIA_TYPE_AUDIO &&\n((rtp_payload_types[VAR_3].clock_rate > 0 &&\nVAR_1->sample_rate != rtp_payload_types[VAR_3].clock_rate) ||\n(rtp_payload_types[VAR_3].audio_channels > 0 &&\nVAR_1->channels != rtp_payload_types[VAR_3].audio_channels)))\ncontinue;", "return rtp_payload_types[VAR_3].pt;", "}", "if (VAR_2 < 0)\nVAR_2 = VAR_1->codec_type == AVMEDIA_TYPE_AUDIO;", "return RTP_PT_PRIVATE + VAR_2;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 15 ], [ 17 ], [ 19, 21, 23 ], [ 25 ], [ 31 ], [ 33 ], [ 35, 37, 39, 41 ], [ 47, 49, 51 ], [ 53, 55, 57, 59, 61, 63 ], [ 65 ], [ 67 ], [ 71, 73 ], [ 79 ], [ 81 ] ]
9,338
static void pit_common_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = pit_common_realize; dc->vmsd = &vmstate_pit_common; dc->no_user = 1; }
true
qemu
efec3dd631d94160288392721a5f9c39e50fb2bc
static void pit_common_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = pit_common_realize; dc->vmsd = &vmstate_pit_common; dc->no_user = 1; }
{ "code": [ " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;" ], "line_no": [ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13 ] }
static void FUNC_0(ObjectClass *VAR_0, void *VAR_1) { DeviceClass *dc = DEVICE_CLASS(VAR_0); dc->realize = pit_common_realize; dc->vmsd = &vmstate_pit_common; dc->no_user = 1; }
[ "static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{", "DeviceClass *dc = DEVICE_CLASS(VAR_0);", "dc->realize = pit_common_realize;", "dc->vmsd = &vmstate_pit_common;", "dc->no_user = 1;", "}" ]
[ 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ] ]
9,339
static int filter_frame(AVFilterLink *inlink, AVFrame *in) { AVFilterContext *ctx = inlink->dst; AVFilterLink *outlink = ctx->outputs[0]; QPContext *s = ctx->priv; AVBufferRef *out_qp_table_buf; AVFrame *out; const int8_t *in_qp_table; int type, stride, ret; if (!s->qp_expr_str || ctx->is_disabled) return ff_filter_frame(outlink, in); out_qp_table_buf = av_buffer_alloc(s->h * s->qstride); if (!out_qp_table_buf) { ret = AVERROR(ENOMEM); goto fail; } out = av_frame_clone(in); if (!out) { ret = AVERROR(ENOMEM); goto fail; } in_qp_table = av_frame_get_qp_table(in, &stride, &type); av_frame_set_qp_table(out, out_qp_table_buf, s->qstride, type); if (in_qp_table) { int y, x; for (y = 0; y < s->h; y++) for (x = 0; x < s->qstride; x++) out_qp_table_buf->data[x + s->qstride * y] = s->lut[129 + ((int8_t)in_qp_table[x + stride * y])]; } else { int y, x, qp = s->lut[0]; for (y = 0; y < s->h; y++) for (x = 0; x < s->qstride; x++) out_qp_table_buf->data[x + s->qstride * y] = qp; } ret = ff_filter_frame(outlink, out); fail: av_frame_free(&in); return ret; }
true
FFmpeg
bdb31942174c4673c7f212378951366e0704668d
static int filter_frame(AVFilterLink *inlink, AVFrame *in) { AVFilterContext *ctx = inlink->dst; AVFilterLink *outlink = ctx->outputs[0]; QPContext *s = ctx->priv; AVBufferRef *out_qp_table_buf; AVFrame *out; const int8_t *in_qp_table; int type, stride, ret; if (!s->qp_expr_str || ctx->is_disabled) return ff_filter_frame(outlink, in); out_qp_table_buf = av_buffer_alloc(s->h * s->qstride); if (!out_qp_table_buf) { ret = AVERROR(ENOMEM); goto fail; } out = av_frame_clone(in); if (!out) { ret = AVERROR(ENOMEM); goto fail; } in_qp_table = av_frame_get_qp_table(in, &stride, &type); av_frame_set_qp_table(out, out_qp_table_buf, s->qstride, type); if (in_qp_table) { int y, x; for (y = 0; y < s->h; y++) for (x = 0; x < s->qstride; x++) out_qp_table_buf->data[x + s->qstride * y] = s->lut[129 + ((int8_t)in_qp_table[x + stride * y])]; } else { int y, x, qp = s->lut[0]; for (y = 0; y < s->h; y++) for (x = 0; x < s->qstride; x++) out_qp_table_buf->data[x + s->qstride * y] = qp; } ret = ff_filter_frame(outlink, out); fail: av_frame_free(&in); return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFilterLink *VAR_0, AVFrame *VAR_1) { AVFilterContext *ctx = VAR_0->dst; AVFilterLink *outlink = ctx->outputs[0]; QPContext *s = ctx->priv; AVBufferRef *out_qp_table_buf; AVFrame *out; const int8_t *VAR_2; int VAR_3, VAR_4, VAR_5; if (!s->qp_expr_str || ctx->is_disabled) return ff_filter_frame(outlink, VAR_1); out_qp_table_buf = av_buffer_alloc(s->h * s->qstride); if (!out_qp_table_buf) { VAR_5 = AVERROR(ENOMEM); goto fail; } out = av_frame_clone(VAR_1); if (!out) { VAR_5 = AVERROR(ENOMEM); goto fail; } VAR_2 = av_frame_get_qp_table(VAR_1, &VAR_4, &VAR_3); av_frame_set_qp_table(out, out_qp_table_buf, s->qstride, VAR_3); if (VAR_2) { int VAR_8, VAR_8; for (VAR_8 = 0; VAR_8 < s->h; VAR_8++) for (VAR_8 = 0; VAR_8 < s->qstride; VAR_8++) out_qp_table_buf->data[VAR_8 + s->qstride * VAR_8] = s->lut[129 + ((int8_t)VAR_2[VAR_8 + VAR_4 * VAR_8])]; } else { int VAR_8, VAR_8, VAR_8 = s->lut[0]; for (VAR_8 = 0; VAR_8 < s->h; VAR_8++) for (VAR_8 = 0; VAR_8 < s->qstride; VAR_8++) out_qp_table_buf->data[VAR_8 + s->qstride * VAR_8] = VAR_8; } VAR_5 = ff_filter_frame(outlink, out); fail: av_frame_free(&VAR_1); return VAR_5; }
[ "static int FUNC_0(AVFilterLink *VAR_0, AVFrame *VAR_1)\n{", "AVFilterContext *ctx = VAR_0->dst;", "AVFilterLink *outlink = ctx->outputs[0];", "QPContext *s = ctx->priv;", "AVBufferRef *out_qp_table_buf;", "AVFrame *out;", "const int8_t *VAR_2;", "int VAR_3, VAR_4, VAR_5;", "if (!s->qp_expr_str || ctx->is_disabled)\nreturn ff_filter_frame(outlink, VAR_1);", "out_qp_table_buf = av_buffer_alloc(s->h * s->qstride);", "if (!out_qp_table_buf) {", "VAR_5 = AVERROR(ENOMEM);", "goto fail;", "}", "out = av_frame_clone(VAR_1);", "if (!out) {", "VAR_5 = AVERROR(ENOMEM);", "goto fail;", "}", "VAR_2 = av_frame_get_qp_table(VAR_1, &VAR_4, &VAR_3);", "av_frame_set_qp_table(out, out_qp_table_buf, s->qstride, VAR_3);", "if (VAR_2) {", "int VAR_8, VAR_8;", "for (VAR_8 = 0; VAR_8 < s->h; VAR_8++)", "for (VAR_8 = 0; VAR_8 < s->qstride; VAR_8++)", "out_qp_table_buf->data[VAR_8 + s->qstride * VAR_8] = s->lut[129 +\n((int8_t)VAR_2[VAR_8 + VAR_4 * VAR_8])];", "} else {", "int VAR_8, VAR_8, VAR_8 = s->lut[0];", "for (VAR_8 = 0; VAR_8 < s->h; VAR_8++)", "for (VAR_8 = 0; VAR_8 < s->qstride; VAR_8++)", "out_qp_table_buf->data[VAR_8 + s->qstride * VAR_8] = VAR_8;", "}", "VAR_5 = ff_filter_frame(outlink, out);", "fail:\nav_frame_free(&VAR_1);", "return VAR_5;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21, 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 44 ], [ 46 ], [ 48 ], [ 52 ], [ 54 ], [ 58 ], [ 60 ], [ 64 ], [ 66 ], [ 68, 70 ], [ 72 ], [ 74 ], [ 78 ], [ 80 ], [ 82 ], [ 84 ], [ 88 ], [ 90, 92 ], [ 94 ], [ 96 ] ]
9,340
static int oss_init_out (HWVoiceOut *hw, struct audsettings *as) { OSSVoiceOut *oss = (OSSVoiceOut *) hw; struct oss_params req, obt; int endianness; int err; int fd; audfmt_e effective_fmt; struct audsettings obt_as; oss->fd = -1; req.fmt = aud_to_ossfmt (as->fmt, as->endianness); req.freq = as->freq; req.nchannels = as->nchannels; req.fragsize = conf.fragsize; req.nfrags = conf.nfrags; if (oss_open (0, &req, &obt, &fd)) { return -1; } err = oss_to_audfmt (obt.fmt, &effective_fmt, &endianness); if (err) { oss_anal_close (&fd); return -1; } obt_as.freq = obt.freq; obt_as.nchannels = obt.nchannels; obt_as.fmt = effective_fmt; obt_as.endianness = endianness; audio_pcm_init_info (&hw->info, &obt_as); oss->nfrags = obt.nfrags; oss->fragsize = obt.fragsize; if (obt.nfrags * obt.fragsize & hw->info.align) { dolog ("warning: Misaligned DAC buffer, size %d, alignment %d\n", obt.nfrags * obt.fragsize, hw->info.align + 1); } hw->samples = (obt.nfrags * obt.fragsize) >> hw->info.shift; oss->mmapped = 0; if (conf.try_mmap) { oss->pcm_buf = mmap ( NULL, hw->samples << hw->info.shift, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 ); if (oss->pcm_buf == MAP_FAILED) { oss_logerr (errno, "Failed to map %d bytes of DAC\n", hw->samples << hw->info.shift); } else { int err; int trig = 0; if (ioctl (fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) { oss_logerr (errno, "SNDCTL_DSP_SETTRIGGER 0 failed\n"); } else { trig = PCM_ENABLE_OUTPUT; if (ioctl (fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) { oss_logerr ( errno, "SNDCTL_DSP_SETTRIGGER PCM_ENABLE_OUTPUT failed\n" ); } else { oss->mmapped = 1; } } if (!oss->mmapped) { err = munmap (oss->pcm_buf, hw->samples << hw->info.shift); if (err) { oss_logerr (errno, "Failed to unmap buffer %p size %d\n", oss->pcm_buf, hw->samples << hw->info.shift); } } } } if (!oss->mmapped) { oss->pcm_buf = audio_calloc ( AUDIO_FUNC, hw->samples, 1 << hw->info.shift ); if (!oss->pcm_buf) { dolog ( "Could not allocate DAC buffer (%d samples, each %d bytes)\n", hw->samples, 1 << hw->info.shift ); oss_anal_close (&fd); return -1; } } oss->fd = fd; return 0; }
true
qemu
5706db1deb061ee9affdcea81e59c4c2cad7c41e
static int oss_init_out (HWVoiceOut *hw, struct audsettings *as) { OSSVoiceOut *oss = (OSSVoiceOut *) hw; struct oss_params req, obt; int endianness; int err; int fd; audfmt_e effective_fmt; struct audsettings obt_as; oss->fd = -1; req.fmt = aud_to_ossfmt (as->fmt, as->endianness); req.freq = as->freq; req.nchannels = as->nchannels; req.fragsize = conf.fragsize; req.nfrags = conf.nfrags; if (oss_open (0, &req, &obt, &fd)) { return -1; } err = oss_to_audfmt (obt.fmt, &effective_fmt, &endianness); if (err) { oss_anal_close (&fd); return -1; } obt_as.freq = obt.freq; obt_as.nchannels = obt.nchannels; obt_as.fmt = effective_fmt; obt_as.endianness = endianness; audio_pcm_init_info (&hw->info, &obt_as); oss->nfrags = obt.nfrags; oss->fragsize = obt.fragsize; if (obt.nfrags * obt.fragsize & hw->info.align) { dolog ("warning: Misaligned DAC buffer, size %d, alignment %d\n", obt.nfrags * obt.fragsize, hw->info.align + 1); } hw->samples = (obt.nfrags * obt.fragsize) >> hw->info.shift; oss->mmapped = 0; if (conf.try_mmap) { oss->pcm_buf = mmap ( NULL, hw->samples << hw->info.shift, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 ); if (oss->pcm_buf == MAP_FAILED) { oss_logerr (errno, "Failed to map %d bytes of DAC\n", hw->samples << hw->info.shift); } else { int err; int trig = 0; if (ioctl (fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) { oss_logerr (errno, "SNDCTL_DSP_SETTRIGGER 0 failed\n"); } else { trig = PCM_ENABLE_OUTPUT; if (ioctl (fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) { oss_logerr ( errno, "SNDCTL_DSP_SETTRIGGER PCM_ENABLE_OUTPUT failed\n" ); } else { oss->mmapped = 1; } } if (!oss->mmapped) { err = munmap (oss->pcm_buf, hw->samples << hw->info.shift); if (err) { oss_logerr (errno, "Failed to unmap buffer %p size %d\n", oss->pcm_buf, hw->samples << hw->info.shift); } } } } if (!oss->mmapped) { oss->pcm_buf = audio_calloc ( AUDIO_FUNC, hw->samples, 1 << hw->info.shift ); if (!oss->pcm_buf) { dolog ( "Could not allocate DAC buffer (%d samples, each %d bytes)\n", hw->samples, 1 << hw->info.shift ); oss_anal_close (&fd); return -1; } } oss->fd = fd; return 0; }
{ "code": [ "static int oss_init_out (HWVoiceOut *hw, struct audsettings *as)" ], "line_no": [ 1 ] }
static int FUNC_0 (HWVoiceOut *VAR_0, struct audsettings *VAR_1) { OSSVoiceOut *oss = (OSSVoiceOut *) VAR_0; struct oss_params VAR_2, VAR_3; int VAR_4; int VAR_8; int VAR_6; audfmt_e effective_fmt; struct audsettings VAR_7; oss->VAR_6 = -1; VAR_2.fmt = aud_to_ossfmt (VAR_1->fmt, VAR_1->VAR_4); VAR_2.freq = VAR_1->freq; VAR_2.nchannels = VAR_1->nchannels; VAR_2.fragsize = conf.fragsize; VAR_2.nfrags = conf.nfrags; if (oss_open (0, &VAR_2, &VAR_3, &VAR_6)) { return -1; } VAR_8 = oss_to_audfmt (VAR_3.fmt, &effective_fmt, &VAR_4); if (VAR_8) { oss_anal_close (&VAR_6); return -1; } VAR_7.freq = VAR_3.freq; VAR_7.nchannels = VAR_3.nchannels; VAR_7.fmt = effective_fmt; VAR_7.VAR_4 = VAR_4; audio_pcm_init_info (&VAR_0->info, &VAR_7); oss->nfrags = VAR_3.nfrags; oss->fragsize = VAR_3.fragsize; if (VAR_3.nfrags * VAR_3.fragsize & VAR_0->info.align) { dolog ("warning: Misaligned DAC buffer, size %d, alignment %d\n", VAR_3.nfrags * VAR_3.fragsize, VAR_0->info.align + 1); } VAR_0->samples = (VAR_3.nfrags * VAR_3.fragsize) >> VAR_0->info.shift; oss->mmapped = 0; if (conf.try_mmap) { oss->pcm_buf = mmap ( NULL, VAR_0->samples << VAR_0->info.shift, PROT_READ | PROT_WRITE, MAP_SHARED, VAR_6, 0 ); if (oss->pcm_buf == MAP_FAILED) { oss_logerr (errno, "Failed to map %d bytes of DAC\n", VAR_0->samples << VAR_0->info.shift); } else { int VAR_8; int VAR_8 = 0; if (ioctl (VAR_6, SNDCTL_DSP_SETTRIGGER, &VAR_8) < 0) { oss_logerr (errno, "SNDCTL_DSP_SETTRIGGER 0 failed\n"); } else { VAR_8 = PCM_ENABLE_OUTPUT; if (ioctl (VAR_6, SNDCTL_DSP_SETTRIGGER, &VAR_8) < 0) { oss_logerr ( errno, "SNDCTL_DSP_SETTRIGGER PCM_ENABLE_OUTPUT failed\n" ); } else { oss->mmapped = 1; } } if (!oss->mmapped) { VAR_8 = munmap (oss->pcm_buf, VAR_0->samples << VAR_0->info.shift); if (VAR_8) { oss_logerr (errno, "Failed to unmap buffer %p size %d\n", oss->pcm_buf, VAR_0->samples << VAR_0->info.shift); } } } } if (!oss->mmapped) { oss->pcm_buf = audio_calloc ( AUDIO_FUNC, VAR_0->samples, 1 << VAR_0->info.shift ); if (!oss->pcm_buf) { dolog ( "Could not allocate DAC buffer (%d samples, each %d bytes)\n", VAR_0->samples, 1 << VAR_0->info.shift ); oss_anal_close (&VAR_6); return -1; } } oss->VAR_6 = VAR_6; return 0; }
[ "static int FUNC_0 (HWVoiceOut *VAR_0, struct audsettings *VAR_1)\n{", "OSSVoiceOut *oss = (OSSVoiceOut *) VAR_0;", "struct oss_params VAR_2, VAR_3;", "int VAR_4;", "int VAR_8;", "int VAR_6;", "audfmt_e effective_fmt;", "struct audsettings VAR_7;", "oss->VAR_6 = -1;", "VAR_2.fmt = aud_to_ossfmt (VAR_1->fmt, VAR_1->VAR_4);", "VAR_2.freq = VAR_1->freq;", "VAR_2.nchannels = VAR_1->nchannels;", "VAR_2.fragsize = conf.fragsize;", "VAR_2.nfrags = conf.nfrags;", "if (oss_open (0, &VAR_2, &VAR_3, &VAR_6)) {", "return -1;", "}", "VAR_8 = oss_to_audfmt (VAR_3.fmt, &effective_fmt, &VAR_4);", "if (VAR_8) {", "oss_anal_close (&VAR_6);", "return -1;", "}", "VAR_7.freq = VAR_3.freq;", "VAR_7.nchannels = VAR_3.nchannels;", "VAR_7.fmt = effective_fmt;", "VAR_7.VAR_4 = VAR_4;", "audio_pcm_init_info (&VAR_0->info, &VAR_7);", "oss->nfrags = VAR_3.nfrags;", "oss->fragsize = VAR_3.fragsize;", "if (VAR_3.nfrags * VAR_3.fragsize & VAR_0->info.align) {", "dolog (\"warning: Misaligned DAC buffer, size %d, alignment %d\\n\",\nVAR_3.nfrags * VAR_3.fragsize, VAR_0->info.align + 1);", "}", "VAR_0->samples = (VAR_3.nfrags * VAR_3.fragsize) >> VAR_0->info.shift;", "oss->mmapped = 0;", "if (conf.try_mmap) {", "oss->pcm_buf = mmap (\nNULL,\nVAR_0->samples << VAR_0->info.shift,\nPROT_READ | PROT_WRITE,\nMAP_SHARED,\nVAR_6,\n0\n);", "if (oss->pcm_buf == MAP_FAILED) {", "oss_logerr (errno, \"Failed to map %d bytes of DAC\\n\",\nVAR_0->samples << VAR_0->info.shift);", "}", "else {", "int VAR_8;", "int VAR_8 = 0;", "if (ioctl (VAR_6, SNDCTL_DSP_SETTRIGGER, &VAR_8) < 0) {", "oss_logerr (errno, \"SNDCTL_DSP_SETTRIGGER 0 failed\\n\");", "}", "else {", "VAR_8 = PCM_ENABLE_OUTPUT;", "if (ioctl (VAR_6, SNDCTL_DSP_SETTRIGGER, &VAR_8) < 0) {", "oss_logerr (\nerrno,\n\"SNDCTL_DSP_SETTRIGGER PCM_ENABLE_OUTPUT failed\\n\"\n);", "}", "else {", "oss->mmapped = 1;", "}", "}", "if (!oss->mmapped) {", "VAR_8 = munmap (oss->pcm_buf, VAR_0->samples << VAR_0->info.shift);", "if (VAR_8) {", "oss_logerr (errno, \"Failed to unmap buffer %p size %d\\n\",\noss->pcm_buf, VAR_0->samples << VAR_0->info.shift);", "}", "}", "}", "}", "if (!oss->mmapped) {", "oss->pcm_buf = audio_calloc (\nAUDIO_FUNC,\nVAR_0->samples,\n1 << VAR_0->info.shift\n);", "if (!oss->pcm_buf) {", "dolog (\n\"Could not allocate DAC buffer (%d samples, each %d bytes)\\n\",\nVAR_0->samples,\n1 << VAR_0->info.shift\n);", "oss_anal_close (&VAR_6);", "return -1;", "}", "}", "oss->VAR_6 = VAR_6;", "return 0;", "}" ]
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77, 79 ], [ 81 ], [ 85 ], [ 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 ], [ 155 ], [ 157 ], [ 159 ], [ 161, 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 175 ], [ 177, 179, 181, 183, 185 ], [ 187 ], [ 189, 191, 193, 195, 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 209 ], [ 211 ], [ 213 ] ]
9,341
static int mov_write_source_reference_tag(AVIOContext *pb, MOVTrack *track, const char *reel_name){ int64_t pos = avio_tell(pb); avio_wb32(pb, 0); /* size */ ffio_wfourcc(pb, "name"); /* Data format */ avio_wb16(pb, strlen(reel_name)); /* string size */ avio_wb16(pb, track->language); /* langcode */ avio_write(pb, reel_name, strlen(reel_name)); /* reel name */ return update_size(pb,pos); }
false
FFmpeg
cab39afb1a9c8a86a00485fbba12a9ba26bea57d
static int mov_write_source_reference_tag(AVIOContext *pb, MOVTrack *track, const char *reel_name){ int64_t pos = avio_tell(pb); avio_wb32(pb, 0); ffio_wfourcc(pb, "name"); avio_wb16(pb, strlen(reel_name)); avio_wb16(pb, track->language); avio_write(pb, reel_name, strlen(reel_name)); return update_size(pb,pos); }
{ "code": [], "line_no": [] }
static int FUNC_0(AVIOContext *VAR_0, MOVTrack *VAR_1, const char *VAR_2){ int64_t pos = avio_tell(VAR_0); avio_wb32(VAR_0, 0); ffio_wfourcc(VAR_0, "name"); avio_wb16(VAR_0, strlen(VAR_2)); avio_wb16(VAR_0, VAR_1->language); avio_write(VAR_0, VAR_2, strlen(VAR_2)); return update_size(VAR_0,pos); }
[ "static int FUNC_0(AVIOContext *VAR_0, MOVTrack *VAR_1, const char *VAR_2){", "int64_t pos = avio_tell(VAR_0);", "avio_wb32(VAR_0, 0);", "ffio_wfourcc(VAR_0, \"name\");", "avio_wb16(VAR_0, strlen(VAR_2));", "avio_wb16(VAR_0, VAR_1->language);", "avio_write(VAR_0, VAR_2, strlen(VAR_2));", "return update_size(VAR_0,pos);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1 ], [ 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ] ]
9,342
static void encode_mb(MpegEncContext *s, int motion_x, int motion_y) { const int mb_x= s->mb_x; const int mb_y= s->mb_y; int i; #if 0 if (s->interlaced_dct) { dct_linesize = s->linesize * 2; dct_offset = s->linesize; } else { dct_linesize = s->linesize; dct_offset = s->linesize * 8; } #endif if (s->mb_intra) { UINT8 *ptr; int wrap; wrap = s->linesize; ptr = s->new_picture[0] + (mb_y * 16 * wrap) + mb_x * 16; get_pixels(s->block[0], ptr , wrap); get_pixels(s->block[1], ptr + 8, wrap); get_pixels(s->block[2], ptr + 8 * wrap , wrap); get_pixels(s->block[3], ptr + 8 * wrap + 8, wrap); wrap >>=1; ptr = s->new_picture[1] + (mb_y * 8 * wrap) + mb_x * 8; get_pixels(s->block[4], ptr, wrap); ptr = s->new_picture[2] + (mb_y * 8 * wrap) + mb_x * 8; get_pixels(s->block[5], ptr, wrap); }else{ op_pixels_func *op_pix; qpel_mc_func *op_qpix; UINT8 *dest_y, *dest_cb, *dest_cr; UINT8 *ptr; int wrap; dest_y = s->current_picture[0] + (mb_y * 16 * s->linesize ) + mb_x * 16; dest_cb = s->current_picture[1] + (mb_y * 8 * (s->linesize >> 1)) + mb_x * 8; dest_cr = s->current_picture[2] + (mb_y * 8 * (s->linesize >> 1)) + mb_x * 8; if ((!s->no_rounding) || s->pict_type==B_TYPE){ op_pix = put_pixels_tab; op_qpix= qpel_mc_rnd_tab; }else{ op_pix = put_no_rnd_pixels_tab; op_qpix= qpel_mc_no_rnd_tab; } if (s->mv_dir & MV_DIR_FORWARD) { MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture, op_pix, op_qpix); if ((!s->no_rounding) || s->pict_type==B_TYPE) op_pix = avg_pixels_tab; else op_pix = avg_no_rnd_pixels_tab; } if (s->mv_dir & MV_DIR_BACKWARD) { MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture, op_pix, op_qpix); } wrap = s->linesize; ptr = s->new_picture[0] + (mb_y * 16 * wrap) + mb_x * 16; diff_pixels(s->block[0], ptr , dest_y , wrap); diff_pixels(s->block[1], ptr + 8, dest_y + 8, wrap); diff_pixels(s->block[2], ptr + 8 * wrap , dest_y + 8 * wrap , wrap); diff_pixels(s->block[3], ptr + 8 * wrap + 8, dest_y + 8 * wrap + 8, wrap); wrap >>=1; ptr = s->new_picture[1] + (mb_y * 8 * wrap) + mb_x * 8; diff_pixels(s->block[4], ptr, dest_cb, wrap); ptr = s->new_picture[2] + (mb_y * 8 * wrap) + mb_x * 8; diff_pixels(s->block[5], ptr, dest_cr, wrap); } #if 0 { float adap_parm; adap_parm = ((s->avg_mb_var << 1) + s->mb_var[s->mb_width*mb_y+mb_x] + 1.0) / ((s->mb_var[s->mb_width*mb_y+mb_x] << 1) + s->avg_mb_var + 1.0); printf("\ntype=%c qscale=%2d adap=%0.2f dquant=%4.2f var=%4d avgvar=%4d", (s->mb_type[s->mb_width*mb_y+mb_x] > 0) ? 'I' : 'P', s->qscale, adap_parm, s->qscale*adap_parm, s->mb_var[s->mb_width*mb_y+mb_x], s->avg_mb_var); } #endif /* DCT & quantize */ if (s->h263_pred && s->msmpeg4_version!=2) { h263_dc_scale(s); } else if (s->h263_aic) { s->y_dc_scale = 2*s->qscale; s->c_dc_scale = 2*s->qscale; } else { /* default quantization values */ s->y_dc_scale = 8; s->c_dc_scale = 8; } if(s->out_format==FMT_MJPEG){ for(i=0;i<6;i++) { int overflow; s->block_last_index[i] = dct_quantize(s, s->block[i], i, 8, &overflow); if (overflow) clip_coeffs(s, s->block[i], s->block_last_index[i]); } }else{ for(i=0;i<6;i++) { int overflow; s->block_last_index[i] = dct_quantize(s, s->block[i], i, s->qscale, &overflow); // FIXME we could decide to change to quantizer instead of clipping // JS: I don't think that would be a good idea it could lower quality instead // of improve it. Just INTRADC clipping deserves changes in quantizer if (overflow) clip_coeffs(s, s->block[i], s->block_last_index[i]); } } /* huffman encode */ switch(s->out_format) { case FMT_MPEG1: mpeg1_encode_mb(s, s->block, motion_x, motion_y); break; case FMT_H263: if (s->h263_msmpeg4) msmpeg4_encode_mb(s, s->block, motion_x, motion_y); else if(s->h263_pred) mpeg4_encode_mb(s, s->block, motion_x, motion_y); else h263_encode_mb(s, s->block, motion_x, motion_y); break; case FMT_MJPEG: mjpeg_encode_mb(s, s->block); break; } }
false
FFmpeg
7f2fe444a39bca733d390b6608801c5f002bfd31
static void encode_mb(MpegEncContext *s, int motion_x, int motion_y) { const int mb_x= s->mb_x; const int mb_y= s->mb_y; int i; #if 0 if (s->interlaced_dct) { dct_linesize = s->linesize * 2; dct_offset = s->linesize; } else { dct_linesize = s->linesize; dct_offset = s->linesize * 8; } #endif if (s->mb_intra) { UINT8 *ptr; int wrap; wrap = s->linesize; ptr = s->new_picture[0] + (mb_y * 16 * wrap) + mb_x * 16; get_pixels(s->block[0], ptr , wrap); get_pixels(s->block[1], ptr + 8, wrap); get_pixels(s->block[2], ptr + 8 * wrap , wrap); get_pixels(s->block[3], ptr + 8 * wrap + 8, wrap); wrap >>=1; ptr = s->new_picture[1] + (mb_y * 8 * wrap) + mb_x * 8; get_pixels(s->block[4], ptr, wrap); ptr = s->new_picture[2] + (mb_y * 8 * wrap) + mb_x * 8; get_pixels(s->block[5], ptr, wrap); }else{ op_pixels_func *op_pix; qpel_mc_func *op_qpix; UINT8 *dest_y, *dest_cb, *dest_cr; UINT8 *ptr; int wrap; dest_y = s->current_picture[0] + (mb_y * 16 * s->linesize ) + mb_x * 16; dest_cb = s->current_picture[1] + (mb_y * 8 * (s->linesize >> 1)) + mb_x * 8; dest_cr = s->current_picture[2] + (mb_y * 8 * (s->linesize >> 1)) + mb_x * 8; if ((!s->no_rounding) || s->pict_type==B_TYPE){ op_pix = put_pixels_tab; op_qpix= qpel_mc_rnd_tab; }else{ op_pix = put_no_rnd_pixels_tab; op_qpix= qpel_mc_no_rnd_tab; } if (s->mv_dir & MV_DIR_FORWARD) { MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture, op_pix, op_qpix); if ((!s->no_rounding) || s->pict_type==B_TYPE) op_pix = avg_pixels_tab; else op_pix = avg_no_rnd_pixels_tab; } if (s->mv_dir & MV_DIR_BACKWARD) { MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture, op_pix, op_qpix); } wrap = s->linesize; ptr = s->new_picture[0] + (mb_y * 16 * wrap) + mb_x * 16; diff_pixels(s->block[0], ptr , dest_y , wrap); diff_pixels(s->block[1], ptr + 8, dest_y + 8, wrap); diff_pixels(s->block[2], ptr + 8 * wrap , dest_y + 8 * wrap , wrap); diff_pixels(s->block[3], ptr + 8 * wrap + 8, dest_y + 8 * wrap + 8, wrap); wrap >>=1; ptr = s->new_picture[1] + (mb_y * 8 * wrap) + mb_x * 8; diff_pixels(s->block[4], ptr, dest_cb, wrap); ptr = s->new_picture[2] + (mb_y * 8 * wrap) + mb_x * 8; diff_pixels(s->block[5], ptr, dest_cr, wrap); } #if 0 { float adap_parm; adap_parm = ((s->avg_mb_var << 1) + s->mb_var[s->mb_width*mb_y+mb_x] + 1.0) / ((s->mb_var[s->mb_width*mb_y+mb_x] << 1) + s->avg_mb_var + 1.0); printf("\ntype=%c qscale=%2d adap=%0.2f dquant=%4.2f var=%4d avgvar=%4d", (s->mb_type[s->mb_width*mb_y+mb_x] > 0) ? 'I' : 'P', s->qscale, adap_parm, s->qscale*adap_parm, s->mb_var[s->mb_width*mb_y+mb_x], s->avg_mb_var); } #endif if (s->h263_pred && s->msmpeg4_version!=2) { h263_dc_scale(s); } else if (s->h263_aic) { s->y_dc_scale = 2*s->qscale; s->c_dc_scale = 2*s->qscale; } else { s->y_dc_scale = 8; s->c_dc_scale = 8; } if(s->out_format==FMT_MJPEG){ for(i=0;i<6;i++) { int overflow; s->block_last_index[i] = dct_quantize(s, s->block[i], i, 8, &overflow); if (overflow) clip_coeffs(s, s->block[i], s->block_last_index[i]); } }else{ for(i=0;i<6;i++) { int overflow; s->block_last_index[i] = dct_quantize(s, s->block[i], i, s->qscale, &overflow); if (overflow) clip_coeffs(s, s->block[i], s->block_last_index[i]); } } switch(s->out_format) { case FMT_MPEG1: mpeg1_encode_mb(s, s->block, motion_x, motion_y); break; case FMT_H263: if (s->h263_msmpeg4) msmpeg4_encode_mb(s, s->block, motion_x, motion_y); else if(s->h263_pred) mpeg4_encode_mb(s, s->block, motion_x, motion_y); else h263_encode_mb(s, s->block, motion_x, motion_y); break; case FMT_MJPEG: mjpeg_encode_mb(s, s->block); break; } }
{ "code": [], "line_no": [] }
static void FUNC_0(MpegEncContext *VAR_0, int VAR_1, int VAR_2) { const int VAR_3= VAR_0->VAR_3; const int VAR_4= VAR_0->VAR_4; int VAR_5; #if 0 if (VAR_0->interlaced_dct) { dct_linesize = VAR_0->linesize * 2; dct_offset = VAR_0->linesize; } else { dct_linesize = VAR_0->linesize; dct_offset = VAR_0->linesize * 8; } #endif if (VAR_0->mb_intra) { UINT8 *ptr; int VAR_7; VAR_7 = VAR_0->linesize; ptr = VAR_0->new_picture[0] + (VAR_4 * 16 * VAR_7) + VAR_3 * 16; get_pixels(VAR_0->block[0], ptr , VAR_7); get_pixels(VAR_0->block[1], ptr + 8, VAR_7); get_pixels(VAR_0->block[2], ptr + 8 * VAR_7 , VAR_7); get_pixels(VAR_0->block[3], ptr + 8 * VAR_7 + 8, VAR_7); VAR_7 >>=1; ptr = VAR_0->new_picture[1] + (VAR_4 * 8 * VAR_7) + VAR_3 * 8; get_pixels(VAR_0->block[4], ptr, VAR_7); ptr = VAR_0->new_picture[2] + (VAR_4 * 8 * VAR_7) + VAR_3 * 8; get_pixels(VAR_0->block[5], ptr, VAR_7); }else{ op_pixels_func *op_pix; qpel_mc_func *op_qpix; UINT8 *dest_y, *dest_cb, *dest_cr; UINT8 *ptr; int VAR_7; dest_y = VAR_0->current_picture[0] + (VAR_4 * 16 * VAR_0->linesize ) + VAR_3 * 16; dest_cb = VAR_0->current_picture[1] + (VAR_4 * 8 * (VAR_0->linesize >> 1)) + VAR_3 * 8; dest_cr = VAR_0->current_picture[2] + (VAR_4 * 8 * (VAR_0->linesize >> 1)) + VAR_3 * 8; if ((!VAR_0->no_rounding) || VAR_0->pict_type==B_TYPE){ op_pix = put_pixels_tab; op_qpix= qpel_mc_rnd_tab; }else{ op_pix = put_no_rnd_pixels_tab; op_qpix= qpel_mc_no_rnd_tab; } if (VAR_0->mv_dir & MV_DIR_FORWARD) { MPV_motion(VAR_0, dest_y, dest_cb, dest_cr, 0, VAR_0->last_picture, op_pix, op_qpix); if ((!VAR_0->no_rounding) || VAR_0->pict_type==B_TYPE) op_pix = avg_pixels_tab; else op_pix = avg_no_rnd_pixels_tab; } if (VAR_0->mv_dir & MV_DIR_BACKWARD) { MPV_motion(VAR_0, dest_y, dest_cb, dest_cr, 1, VAR_0->next_picture, op_pix, op_qpix); } VAR_7 = VAR_0->linesize; ptr = VAR_0->new_picture[0] + (VAR_4 * 16 * VAR_7) + VAR_3 * 16; diff_pixels(VAR_0->block[0], ptr , dest_y , VAR_7); diff_pixels(VAR_0->block[1], ptr + 8, dest_y + 8, VAR_7); diff_pixels(VAR_0->block[2], ptr + 8 * VAR_7 , dest_y + 8 * VAR_7 , VAR_7); diff_pixels(VAR_0->block[3], ptr + 8 * VAR_7 + 8, dest_y + 8 * VAR_7 + 8, VAR_7); VAR_7 >>=1; ptr = VAR_0->new_picture[1] + (VAR_4 * 8 * VAR_7) + VAR_3 * 8; diff_pixels(VAR_0->block[4], ptr, dest_cb, VAR_7); ptr = VAR_0->new_picture[2] + (VAR_4 * 8 * VAR_7) + VAR_3 * 8; diff_pixels(VAR_0->block[5], ptr, dest_cr, VAR_7); } #if 0 { float adap_parm; adap_parm = ((VAR_0->avg_mb_var << 1) + VAR_0->mb_var[VAR_0->mb_width*VAR_4+VAR_3] + 1.0) / ((VAR_0->mb_var[VAR_0->mb_width*VAR_4+VAR_3] << 1) + VAR_0->avg_mb_var + 1.0); printf("\ntype=%c qscale=%2d adap=%0.2f dquant=%4.2f var=%4d avgvar=%4d", (VAR_0->mb_type[VAR_0->mb_width*VAR_4+VAR_3] > 0) ? 'I' : 'P', VAR_0->qscale, adap_parm, VAR_0->qscale*adap_parm, VAR_0->mb_var[VAR_0->mb_width*VAR_4+VAR_3], VAR_0->avg_mb_var); } #endif if (VAR_0->h263_pred && VAR_0->msmpeg4_version!=2) { h263_dc_scale(VAR_0); } else if (VAR_0->h263_aic) { VAR_0->y_dc_scale = 2*VAR_0->qscale; VAR_0->c_dc_scale = 2*VAR_0->qscale; } else { VAR_0->y_dc_scale = 8; VAR_0->c_dc_scale = 8; } if(VAR_0->out_format==FMT_MJPEG){ for(VAR_5=0;VAR_5<6;VAR_5++) { int VAR_8; VAR_0->block_last_index[VAR_5] = dct_quantize(VAR_0, VAR_0->block[VAR_5], VAR_5, 8, &VAR_8); if (VAR_8) clip_coeffs(VAR_0, VAR_0->block[VAR_5], VAR_0->block_last_index[VAR_5]); } }else{ for(VAR_5=0;VAR_5<6;VAR_5++) { int VAR_8; VAR_0->block_last_index[VAR_5] = dct_quantize(VAR_0, VAR_0->block[VAR_5], VAR_5, VAR_0->qscale, &VAR_8); if (VAR_8) clip_coeffs(VAR_0, VAR_0->block[VAR_5], VAR_0->block_last_index[VAR_5]); } } switch(VAR_0->out_format) { case FMT_MPEG1: mpeg1_encode_mb(VAR_0, VAR_0->block, VAR_1, VAR_2); break; case FMT_H263: if (VAR_0->h263_msmpeg4) msmpeg4_encode_mb(VAR_0, VAR_0->block, VAR_1, VAR_2); else if(VAR_0->h263_pred) mpeg4_encode_mb(VAR_0, VAR_0->block, VAR_1, VAR_2); else h263_encode_mb(VAR_0, VAR_0->block, VAR_1, VAR_2); break; case FMT_MJPEG: mjpeg_encode_mb(VAR_0, VAR_0->block); break; } }
[ "static void FUNC_0(MpegEncContext *VAR_0, int VAR_1, int VAR_2)\n{", "const int VAR_3= VAR_0->VAR_3;", "const int VAR_4= VAR_0->VAR_4;", "int VAR_5;", "#if 0\nif (VAR_0->interlaced_dct) {", "dct_linesize = VAR_0->linesize * 2;", "dct_offset = VAR_0->linesize;", "} else {", "dct_linesize = VAR_0->linesize;", "dct_offset = VAR_0->linesize * 8;", "}", "#endif\nif (VAR_0->mb_intra) {", "UINT8 *ptr;", "int VAR_7;", "VAR_7 = VAR_0->linesize;", "ptr = VAR_0->new_picture[0] + (VAR_4 * 16 * VAR_7) + VAR_3 * 16;", "get_pixels(VAR_0->block[0], ptr , VAR_7);", "get_pixels(VAR_0->block[1], ptr + 8, VAR_7);", "get_pixels(VAR_0->block[2], ptr + 8 * VAR_7 , VAR_7);", "get_pixels(VAR_0->block[3], ptr + 8 * VAR_7 + 8, VAR_7);", "VAR_7 >>=1;", "ptr = VAR_0->new_picture[1] + (VAR_4 * 8 * VAR_7) + VAR_3 * 8;", "get_pixels(VAR_0->block[4], ptr, VAR_7);", "ptr = VAR_0->new_picture[2] + (VAR_4 * 8 * VAR_7) + VAR_3 * 8;", "get_pixels(VAR_0->block[5], ptr, VAR_7);", "}else{", "op_pixels_func *op_pix;", "qpel_mc_func *op_qpix;", "UINT8 *dest_y, *dest_cb, *dest_cr;", "UINT8 *ptr;", "int VAR_7;", "dest_y = VAR_0->current_picture[0] + (VAR_4 * 16 * VAR_0->linesize ) + VAR_3 * 16;", "dest_cb = VAR_0->current_picture[1] + (VAR_4 * 8 * (VAR_0->linesize >> 1)) + VAR_3 * 8;", "dest_cr = VAR_0->current_picture[2] + (VAR_4 * 8 * (VAR_0->linesize >> 1)) + VAR_3 * 8;", "if ((!VAR_0->no_rounding) || VAR_0->pict_type==B_TYPE){", "op_pix = put_pixels_tab;", "op_qpix= qpel_mc_rnd_tab;", "}else{", "op_pix = put_no_rnd_pixels_tab;", "op_qpix= qpel_mc_no_rnd_tab;", "}", "if (VAR_0->mv_dir & MV_DIR_FORWARD) {", "MPV_motion(VAR_0, dest_y, dest_cb, dest_cr, 0, VAR_0->last_picture, op_pix, op_qpix);", "if ((!VAR_0->no_rounding) || VAR_0->pict_type==B_TYPE)\nop_pix = avg_pixels_tab;", "else\nop_pix = avg_no_rnd_pixels_tab;", "}", "if (VAR_0->mv_dir & MV_DIR_BACKWARD) {", "MPV_motion(VAR_0, dest_y, dest_cb, dest_cr, 1, VAR_0->next_picture, op_pix, op_qpix);", "}", "VAR_7 = VAR_0->linesize;", "ptr = VAR_0->new_picture[0] + (VAR_4 * 16 * VAR_7) + VAR_3 * 16;", "diff_pixels(VAR_0->block[0], ptr , dest_y , VAR_7);", "diff_pixels(VAR_0->block[1], ptr + 8, dest_y + 8, VAR_7);", "diff_pixels(VAR_0->block[2], ptr + 8 * VAR_7 , dest_y + 8 * VAR_7 , VAR_7);", "diff_pixels(VAR_0->block[3], ptr + 8 * VAR_7 + 8, dest_y + 8 * VAR_7 + 8, VAR_7);", "VAR_7 >>=1;", "ptr = VAR_0->new_picture[1] + (VAR_4 * 8 * VAR_7) + VAR_3 * 8;", "diff_pixels(VAR_0->block[4], ptr, dest_cb, VAR_7);", "ptr = VAR_0->new_picture[2] + (VAR_4 * 8 * VAR_7) + VAR_3 * 8;", "diff_pixels(VAR_0->block[5], ptr, dest_cr, VAR_7);", "}", "#if 0\n{", "float adap_parm;", "adap_parm = ((VAR_0->avg_mb_var << 1) + VAR_0->mb_var[VAR_0->mb_width*VAR_4+VAR_3] + 1.0) /\n((VAR_0->mb_var[VAR_0->mb_width*VAR_4+VAR_3] << 1) + VAR_0->avg_mb_var + 1.0);", "printf(\"\\ntype=%c qscale=%2d adap=%0.2f dquant=%4.2f var=%4d avgvar=%4d\",\n(VAR_0->mb_type[VAR_0->mb_width*VAR_4+VAR_3] > 0) ? 'I' : 'P',\nVAR_0->qscale, adap_parm, VAR_0->qscale*adap_parm,\nVAR_0->mb_var[VAR_0->mb_width*VAR_4+VAR_3], VAR_0->avg_mb_var);", "}", "#endif\nif (VAR_0->h263_pred && VAR_0->msmpeg4_version!=2) {", "h263_dc_scale(VAR_0);", "} else if (VAR_0->h263_aic) {", "VAR_0->y_dc_scale = 2*VAR_0->qscale;", "VAR_0->c_dc_scale = 2*VAR_0->qscale;", "} else {", "VAR_0->y_dc_scale = 8;", "VAR_0->c_dc_scale = 8;", "}", "if(VAR_0->out_format==FMT_MJPEG){", "for(VAR_5=0;VAR_5<6;VAR_5++) {", "int VAR_8;", "VAR_0->block_last_index[VAR_5] = dct_quantize(VAR_0, VAR_0->block[VAR_5], VAR_5, 8, &VAR_8);", "if (VAR_8) clip_coeffs(VAR_0, VAR_0->block[VAR_5], VAR_0->block_last_index[VAR_5]);", "}", "}else{", "for(VAR_5=0;VAR_5<6;VAR_5++) {", "int VAR_8;", "VAR_0->block_last_index[VAR_5] = dct_quantize(VAR_0, VAR_0->block[VAR_5], VAR_5, VAR_0->qscale, &VAR_8);", "if (VAR_8) clip_coeffs(VAR_0, VAR_0->block[VAR_5], VAR_0->block_last_index[VAR_5]);", "}", "}", "switch(VAR_0->out_format) {", "case FMT_MPEG1:\nmpeg1_encode_mb(VAR_0, VAR_0->block, VAR_1, VAR_2);", "break;", "case FMT_H263:\nif (VAR_0->h263_msmpeg4)\nmsmpeg4_encode_mb(VAR_0, VAR_0->block, VAR_1, VAR_2);", "else if(VAR_0->h263_pred)\nmpeg4_encode_mb(VAR_0, VAR_0->block, VAR_1, VAR_2);", "else\nh263_encode_mb(VAR_0, VAR_0->block, VAR_1, VAR_2);", "break;", "case FMT_MJPEG:\nmjpeg_encode_mb(VAR_0, VAR_0->block);", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11, 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27, 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 103 ], [ 105 ], [ 107, 109 ], [ 111, 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 137 ], [ 139 ], [ 141 ], [ 145 ], [ 147 ], [ 149 ], [ 153, 155 ], [ 157 ], [ 161, 163 ], [ 167, 169, 171, 173 ], [ 175 ], [ 177, 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 227 ], [ 229 ], [ 231 ], [ 237 ], [ 239, 241 ], [ 243 ], [ 245, 247, 249 ], [ 251, 253 ], [ 255, 257 ], [ 259 ], [ 261, 263 ], [ 265 ], [ 267 ], [ 269 ] ]
9,344
static int decode_subframe_fixed(FLACContext *s, int channel, int pred_order) { const int blocksize = s->blocksize; int32_t *decoded = s->decoded[channel]; int a, b, c, d, i; /* warm up samples */ for (i = 0; i < pred_order; i++) { decoded[i] = get_sbits(&s->gb, s->curr_bps); } if (decode_residuals(s, channel, pred_order) < 0) return -1; if (pred_order > 0) a = decoded[pred_order-1]; if (pred_order > 1) b = a - decoded[pred_order-2]; if (pred_order > 2) c = b - decoded[pred_order-2] + decoded[pred_order-3]; if (pred_order > 3) d = c - decoded[pred_order-2] + 2*decoded[pred_order-3] - decoded[pred_order-4]; switch (pred_order) { case 0: break; case 1: for (i = pred_order; i < blocksize; i++) decoded[i] = a += decoded[i]; break; case 2: for (i = pred_order; i < blocksize; i++) decoded[i] = a += b += decoded[i]; break; case 3: for (i = pred_order; i < blocksize; i++) decoded[i] = a += b += c += decoded[i]; break; case 4: for (i = pred_order; i < blocksize; i++) decoded[i] = a += b += c += d += decoded[i]; break; default: av_log(s->avctx, AV_LOG_ERROR, "illegal pred order %d\n", pred_order); return -1; } return 0; }
true
FFmpeg
7846418bdb346c344fe9ff9801a820f0cd470212
static int decode_subframe_fixed(FLACContext *s, int channel, int pred_order) { const int blocksize = s->blocksize; int32_t *decoded = s->decoded[channel]; int a, b, c, d, i; for (i = 0; i < pred_order; i++) { decoded[i] = get_sbits(&s->gb, s->curr_bps); } if (decode_residuals(s, channel, pred_order) < 0) return -1; if (pred_order > 0) a = decoded[pred_order-1]; if (pred_order > 1) b = a - decoded[pred_order-2]; if (pred_order > 2) c = b - decoded[pred_order-2] + decoded[pred_order-3]; if (pred_order > 3) d = c - decoded[pred_order-2] + 2*decoded[pred_order-3] - decoded[pred_order-4]; switch (pred_order) { case 0: break; case 1: for (i = pred_order; i < blocksize; i++) decoded[i] = a += decoded[i]; break; case 2: for (i = pred_order; i < blocksize; i++) decoded[i] = a += b += decoded[i]; break; case 3: for (i = pred_order; i < blocksize; i++) decoded[i] = a += b += c += decoded[i]; break; case 4: for (i = pred_order; i < blocksize; i++) decoded[i] = a += b += c += d += decoded[i]; break; default: av_log(s->avctx, AV_LOG_ERROR, "illegal pred order %d\n", pred_order); return -1; } return 0; }
{ "code": [ " int a, b, c, d, i;" ], "line_no": [ 9 ] }
static int FUNC_0(FLACContext *VAR_0, int VAR_1, int VAR_2) { const int VAR_3 = VAR_0->VAR_3; int32_t *decoded = VAR_0->decoded[VAR_1]; int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8; for (VAR_8 = 0; VAR_8 < VAR_2; VAR_8++) { decoded[VAR_8] = get_sbits(&VAR_0->gb, VAR_0->curr_bps); } if (decode_residuals(VAR_0, VAR_1, VAR_2) < 0) return -1; if (VAR_2 > 0) VAR_4 = decoded[VAR_2-1]; if (VAR_2 > 1) VAR_5 = VAR_4 - decoded[VAR_2-2]; if (VAR_2 > 2) VAR_6 = VAR_5 - decoded[VAR_2-2] + decoded[VAR_2-3]; if (VAR_2 > 3) VAR_7 = VAR_6 - decoded[VAR_2-2] + 2*decoded[VAR_2-3] - decoded[VAR_2-4]; switch (VAR_2) { case 0: break; case 1: for (VAR_8 = VAR_2; VAR_8 < VAR_3; VAR_8++) decoded[VAR_8] = VAR_4 += decoded[VAR_8]; break; case 2: for (VAR_8 = VAR_2; VAR_8 < VAR_3; VAR_8++) decoded[VAR_8] = VAR_4 += VAR_5 += decoded[VAR_8]; break; case 3: for (VAR_8 = VAR_2; VAR_8 < VAR_3; VAR_8++) decoded[VAR_8] = VAR_4 += VAR_5 += VAR_6 += decoded[VAR_8]; break; case 4: for (VAR_8 = VAR_2; VAR_8 < VAR_3; VAR_8++) decoded[VAR_8] = VAR_4 += VAR_5 += VAR_6 += VAR_7 += decoded[VAR_8]; break; default: av_log(VAR_0->avctx, AV_LOG_ERROR, "illegal pred order %VAR_7\n", VAR_2); return -1; } return 0; }
[ "static int FUNC_0(FLACContext *VAR_0, int VAR_1, int VAR_2)\n{", "const int VAR_3 = VAR_0->VAR_3;", "int32_t *decoded = VAR_0->decoded[VAR_1];", "int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;", "for (VAR_8 = 0; VAR_8 < VAR_2; VAR_8++) {", "decoded[VAR_8] = get_sbits(&VAR_0->gb, VAR_0->curr_bps);", "}", "if (decode_residuals(VAR_0, VAR_1, VAR_2) < 0)\nreturn -1;", "if (VAR_2 > 0)\nVAR_4 = decoded[VAR_2-1];", "if (VAR_2 > 1)\nVAR_5 = VAR_4 - decoded[VAR_2-2];", "if (VAR_2 > 2)\nVAR_6 = VAR_5 - decoded[VAR_2-2] + decoded[VAR_2-3];", "if (VAR_2 > 3)\nVAR_7 = VAR_6 - decoded[VAR_2-2] + 2*decoded[VAR_2-3] - decoded[VAR_2-4];", "switch (VAR_2) {", "case 0:\nbreak;", "case 1:\nfor (VAR_8 = VAR_2; VAR_8 < VAR_3; VAR_8++)", "decoded[VAR_8] = VAR_4 += decoded[VAR_8];", "break;", "case 2:\nfor (VAR_8 = VAR_2; VAR_8 < VAR_3; VAR_8++)", "decoded[VAR_8] = VAR_4 += VAR_5 += decoded[VAR_8];", "break;", "case 3:\nfor (VAR_8 = VAR_2; VAR_8 < VAR_3; VAR_8++)", "decoded[VAR_8] = VAR_4 += VAR_5 += VAR_6 += decoded[VAR_8];", "break;", "case 4:\nfor (VAR_8 = VAR_2; VAR_8 < VAR_3; VAR_8++)", "decoded[VAR_8] = VAR_4 += VAR_5 += VAR_6 += VAR_7 += decoded[VAR_8];", "break;", "default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"illegal pred order %VAR_7\\n\", VAR_2);", "return -1;", "}", "return 0;", "}" ]
[ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 15 ], [ 17 ], [ 19 ], [ 23, 25 ], [ 29, 31 ], [ 33, 35 ], [ 37, 39 ], [ 41, 43 ], [ 47 ], [ 49, 51 ], [ 53, 55 ], [ 57 ], [ 59 ], [ 61, 63 ], [ 65 ], [ 67 ], [ 69, 71 ], [ 73 ], [ 75 ], [ 77, 79 ], [ 81 ], [ 83 ], [ 85, 87 ], [ 89 ], [ 91 ], [ 95 ], [ 97 ] ]
9,345
static int bitplane_decoding(uint8_t* data, int *raw_flag, VC1Context *v) { GetBitContext *gb = &v->s.gb; int imode, x, y, code, offset; uint8_t invert, *planep = data; int width, height, stride; width = v->s.mb_width; height = v->s.mb_height >> v->field_mode; stride = v->s.mb_stride; invert = get_bits1(gb); imode = get_vlc2(gb, ff_vc1_imode_vlc.table, VC1_IMODE_VLC_BITS, 1); *raw_flag = 0; switch (imode) { case IMODE_RAW: //Data is actually read in the MB layer (same for all tests == "raw") *raw_flag = 1; //invert ignored return invert; case IMODE_DIFF2: case IMODE_NORM2: if ((height * width) & 1) { *planep++ = get_bits1(gb); offset = 1; } else offset = 0; // decode bitplane as one long line for (y = offset; y < height * width; y += 2) { code = get_vlc2(gb, ff_vc1_norm2_vlc.table, VC1_NORM2_VLC_BITS, 1); *planep++ = code & 1; offset++; if (offset == width) { offset = 0; planep += stride - width; } *planep++ = code >> 1; offset++; if (offset == width) { offset = 0; planep += stride - width; } } break; case IMODE_DIFF6: case IMODE_NORM6: if (!(height % 3) && (width % 3)) { // use 2x3 decoding for (y = 0; y < height; y += 3) { for (x = width & 1; x < width; x += 2) { code = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2); if (code < 0) { av_log(v->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n"); return -1; } planep[x + 0] = (code >> 0) & 1; planep[x + 1] = (code >> 1) & 1; planep[x + 0 + stride] = (code >> 2) & 1; planep[x + 1 + stride] = (code >> 3) & 1; planep[x + 0 + stride * 2] = (code >> 4) & 1; planep[x + 1 + stride * 2] = (code >> 5) & 1; } planep += stride * 3; } if (width & 1) decode_colskip(data, 1, height, stride, &v->s.gb); } else { // 3x2 planep += (height & 1) * stride; for (y = height & 1; y < height; y += 2) { for (x = width % 3; x < width; x += 3) { code = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2); if (code < 0) { av_log(v->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n"); return -1; } planep[x + 0] = (code >> 0) & 1; planep[x + 1] = (code >> 1) & 1; planep[x + 2] = (code >> 2) & 1; planep[x + 0 + stride] = (code >> 3) & 1; planep[x + 1 + stride] = (code >> 4) & 1; planep[x + 2 + stride] = (code >> 5) & 1; } planep += stride * 2; } x = width % 3; if (x) decode_colskip(data, x, height, stride, &v->s.gb); if (height & 1) decode_rowskip(data + x, width - x, 1, stride, &v->s.gb); } break; case IMODE_ROWSKIP: decode_rowskip(data, width, height, stride, &v->s.gb); break; case IMODE_COLSKIP: decode_colskip(data, width, height, stride, &v->s.gb); break; default: break; } /* Applying diff operator */ if (imode == IMODE_DIFF2 || imode == IMODE_DIFF6) { planep = data; planep[0] ^= invert; for (x = 1; x < width; x++) planep[x] ^= planep[x-1]; for (y = 1; y < height; y++) { planep += stride; planep[0] ^= planep[-stride]; for (x = 1; x < width; x++) { if (planep[x-1] != planep[x-stride]) planep[x] ^= invert; else planep[x] ^= planep[x-1]; } } } else if (invert) { planep = data; for (x = 0; x < stride * height; x++) planep[x] = !planep[x]; //FIXME stride } return (imode << 1) + invert; }
true
FFmpeg
2224159c787ed19a3cd2e061bc00af125c9c2cef
static int bitplane_decoding(uint8_t* data, int *raw_flag, VC1Context *v) { GetBitContext *gb = &v->s.gb; int imode, x, y, code, offset; uint8_t invert, *planep = data; int width, height, stride; width = v->s.mb_width; height = v->s.mb_height >> v->field_mode; stride = v->s.mb_stride; invert = get_bits1(gb); imode = get_vlc2(gb, ff_vc1_imode_vlc.table, VC1_IMODE_VLC_BITS, 1); *raw_flag = 0; switch (imode) { case IMODE_RAW: *raw_flag = 1; return invert; case IMODE_DIFF2: case IMODE_NORM2: if ((height * width) & 1) { *planep++ = get_bits1(gb); offset = 1; } else offset = 0; for (y = offset; y < height * width; y += 2) { code = get_vlc2(gb, ff_vc1_norm2_vlc.table, VC1_NORM2_VLC_BITS, 1); *planep++ = code & 1; offset++; if (offset == width) { offset = 0; planep += stride - width; } *planep++ = code >> 1; offset++; if (offset == width) { offset = 0; planep += stride - width; } } break; case IMODE_DIFF6: case IMODE_NORM6: if (!(height % 3) && (width % 3)) { for (y = 0; y < height; y += 3) { for (x = width & 1; x < width; x += 2) { code = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2); if (code < 0) { av_log(v->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n"); return -1; } planep[x + 0] = (code >> 0) & 1; planep[x + 1] = (code >> 1) & 1; planep[x + 0 + stride] = (code >> 2) & 1; planep[x + 1 + stride] = (code >> 3) & 1; planep[x + 0 + stride * 2] = (code >> 4) & 1; planep[x + 1 + stride * 2] = (code >> 5) & 1; } planep += stride * 3; } if (width & 1) decode_colskip(data, 1, height, stride, &v->s.gb); } else { planep += (height & 1) * stride; for (y = height & 1; y < height; y += 2) { for (x = width % 3; x < width; x += 3) { code = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2); if (code < 0) { av_log(v->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n"); return -1; } planep[x + 0] = (code >> 0) & 1; planep[x + 1] = (code >> 1) & 1; planep[x + 2] = (code >> 2) & 1; planep[x + 0 + stride] = (code >> 3) & 1; planep[x + 1 + stride] = (code >> 4) & 1; planep[x + 2 + stride] = (code >> 5) & 1; } planep += stride * 2; } x = width % 3; if (x) decode_colskip(data, x, height, stride, &v->s.gb); if (height & 1) decode_rowskip(data + x, width - x, 1, stride, &v->s.gb); } break; case IMODE_ROWSKIP: decode_rowskip(data, width, height, stride, &v->s.gb); break; case IMODE_COLSKIP: decode_colskip(data, width, height, stride, &v->s.gb); break; default: break; } if (imode == IMODE_DIFF2 || imode == IMODE_DIFF6) { planep = data; planep[0] ^= invert; for (x = 1; x < width; x++) planep[x] ^= planep[x-1]; for (y = 1; y < height; y++) { planep += stride; planep[0] ^= planep[-stride]; for (x = 1; x < width; x++) { if (planep[x-1] != planep[x-stride]) planep[x] ^= invert; else planep[x] ^= planep[x-1]; } } } else if (invert) { planep = data; for (x = 0; x < stride * height; x++) planep[x] = !planep[x]; } return (imode << 1) + invert; }
{ "code": [ " offset = 1;", " offset = 0;", " for (y = offset; y < height * width; y += 2) {" ], "line_no": [ 49, 55, 59 ] }
static int FUNC_0(uint8_t* VAR_0, int *VAR_1, VC1Context *VAR_2) { GetBitContext *gb = &VAR_2->s.gb; int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7; uint8_t invert, *planep = VAR_0; int VAR_8, VAR_9, VAR_10; VAR_8 = VAR_2->s.mb_width; VAR_9 = VAR_2->s.mb_height >> VAR_2->field_mode; VAR_10 = VAR_2->s.mb_stride; invert = get_bits1(gb); VAR_3 = get_vlc2(gb, ff_vc1_imode_vlc.table, VC1_IMODE_VLC_BITS, 1); *VAR_1 = 0; switch (VAR_3) { case IMODE_RAW: *VAR_1 = 1; return invert; case IMODE_DIFF2: case IMODE_NORM2: if ((VAR_9 * VAR_8) & 1) { *planep++ = get_bits1(gb); VAR_7 = 1; } else VAR_7 = 0; for (VAR_5 = VAR_7; VAR_5 < VAR_9 * VAR_8; VAR_5 += 2) { VAR_6 = get_vlc2(gb, ff_vc1_norm2_vlc.table, VC1_NORM2_VLC_BITS, 1); *planep++ = VAR_6 & 1; VAR_7++; if (VAR_7 == VAR_8) { VAR_7 = 0; planep += VAR_10 - VAR_8; } *planep++ = VAR_6 >> 1; VAR_7++; if (VAR_7 == VAR_8) { VAR_7 = 0; planep += VAR_10 - VAR_8; } } break; case IMODE_DIFF6: case IMODE_NORM6: if (!(VAR_9 % 3) && (VAR_8 % 3)) { for (VAR_5 = 0; VAR_5 < VAR_9; VAR_5 += 3) { for (VAR_4 = VAR_8 & 1; VAR_4 < VAR_8; VAR_4 += 2) { VAR_6 = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2); if (VAR_6 < 0) { av_log(VAR_2->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n"); return -1; } planep[VAR_4 + 0] = (VAR_6 >> 0) & 1; planep[VAR_4 + 1] = (VAR_6 >> 1) & 1; planep[VAR_4 + 0 + VAR_10] = (VAR_6 >> 2) & 1; planep[VAR_4 + 1 + VAR_10] = (VAR_6 >> 3) & 1; planep[VAR_4 + 0 + VAR_10 * 2] = (VAR_6 >> 4) & 1; planep[VAR_4 + 1 + VAR_10 * 2] = (VAR_6 >> 5) & 1; } planep += VAR_10 * 3; } if (VAR_8 & 1) decode_colskip(VAR_0, 1, VAR_9, VAR_10, &VAR_2->s.gb); } else { planep += (VAR_9 & 1) * VAR_10; for (VAR_5 = VAR_9 & 1; VAR_5 < VAR_9; VAR_5 += 2) { for (VAR_4 = VAR_8 % 3; VAR_4 < VAR_8; VAR_4 += 3) { VAR_6 = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2); if (VAR_6 < 0) { av_log(VAR_2->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n"); return -1; } planep[VAR_4 + 0] = (VAR_6 >> 0) & 1; planep[VAR_4 + 1] = (VAR_6 >> 1) & 1; planep[VAR_4 + 2] = (VAR_6 >> 2) & 1; planep[VAR_4 + 0 + VAR_10] = (VAR_6 >> 3) & 1; planep[VAR_4 + 1 + VAR_10] = (VAR_6 >> 4) & 1; planep[VAR_4 + 2 + VAR_10] = (VAR_6 >> 5) & 1; } planep += VAR_10 * 2; } VAR_4 = VAR_8 % 3; if (VAR_4) decode_colskip(VAR_0, VAR_4, VAR_9, VAR_10, &VAR_2->s.gb); if (VAR_9 & 1) decode_rowskip(VAR_0 + VAR_4, VAR_8 - VAR_4, 1, VAR_10, &VAR_2->s.gb); } break; case IMODE_ROWSKIP: decode_rowskip(VAR_0, VAR_8, VAR_9, VAR_10, &VAR_2->s.gb); break; case IMODE_COLSKIP: decode_colskip(VAR_0, VAR_8, VAR_9, VAR_10, &VAR_2->s.gb); break; default: break; } if (VAR_3 == IMODE_DIFF2 || VAR_3 == IMODE_DIFF6) { planep = VAR_0; planep[0] ^= invert; for (VAR_4 = 1; VAR_4 < VAR_8; VAR_4++) planep[VAR_4] ^= planep[VAR_4-1]; for (VAR_5 = 1; VAR_5 < VAR_9; VAR_5++) { planep += VAR_10; planep[0] ^= planep[-VAR_10]; for (VAR_4 = 1; VAR_4 < VAR_8; VAR_4++) { if (planep[VAR_4-1] != planep[VAR_4-VAR_10]) planep[VAR_4] ^= invert; else planep[VAR_4] ^= planep[VAR_4-1]; } } } else if (invert) { planep = VAR_0; for (VAR_4 = 0; VAR_4 < VAR_10 * VAR_9; VAR_4++) planep[VAR_4] = !planep[VAR_4]; } return (VAR_3 << 1) + invert; }
[ "static int FUNC_0(uint8_t* VAR_0, int *VAR_1, VC1Context *VAR_2)\n{", "GetBitContext *gb = &VAR_2->s.gb;", "int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;", "uint8_t invert, *planep = VAR_0;", "int VAR_8, VAR_9, VAR_10;", "VAR_8 = VAR_2->s.mb_width;", "VAR_9 = VAR_2->s.mb_height >> VAR_2->field_mode;", "VAR_10 = VAR_2->s.mb_stride;", "invert = get_bits1(gb);", "VAR_3 = get_vlc2(gb, ff_vc1_imode_vlc.table, VC1_IMODE_VLC_BITS, 1);", "*VAR_1 = 0;", "switch (VAR_3) {", "case IMODE_RAW:\n*VAR_1 = 1;", "return invert;", "case IMODE_DIFF2:\ncase IMODE_NORM2:\nif ((VAR_9 * VAR_8) & 1) {", "*planep++ = get_bits1(gb);", "VAR_7 = 1;", "}", "else\nVAR_7 = 0;", "for (VAR_5 = VAR_7; VAR_5 < VAR_9 * VAR_8; VAR_5 += 2) {", "VAR_6 = get_vlc2(gb, ff_vc1_norm2_vlc.table, VC1_NORM2_VLC_BITS, 1);", "*planep++ = VAR_6 & 1;", "VAR_7++;", "if (VAR_7 == VAR_8) {", "VAR_7 = 0;", "planep += VAR_10 - VAR_8;", "}", "*planep++ = VAR_6 >> 1;", "VAR_7++;", "if (VAR_7 == VAR_8) {", "VAR_7 = 0;", "planep += VAR_10 - VAR_8;", "}", "}", "break;", "case IMODE_DIFF6:\ncase IMODE_NORM6:\nif (!(VAR_9 % 3) && (VAR_8 % 3)) {", "for (VAR_5 = 0; VAR_5 < VAR_9; VAR_5 += 3) {", "for (VAR_4 = VAR_8 & 1; VAR_4 < VAR_8; VAR_4 += 2) {", "VAR_6 = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2);", "if (VAR_6 < 0) {", "av_log(VAR_2->s.avctx, AV_LOG_DEBUG, \"invalid NORM-6 VLC\\n\");", "return -1;", "}", "planep[VAR_4 + 0] = (VAR_6 >> 0) & 1;", "planep[VAR_4 + 1] = (VAR_6 >> 1) & 1;", "planep[VAR_4 + 0 + VAR_10] = (VAR_6 >> 2) & 1;", "planep[VAR_4 + 1 + VAR_10] = (VAR_6 >> 3) & 1;", "planep[VAR_4 + 0 + VAR_10 * 2] = (VAR_6 >> 4) & 1;", "planep[VAR_4 + 1 + VAR_10 * 2] = (VAR_6 >> 5) & 1;", "}", "planep += VAR_10 * 3;", "}", "if (VAR_8 & 1)\ndecode_colskip(VAR_0, 1, VAR_9, VAR_10, &VAR_2->s.gb);", "} else {", "planep += (VAR_9 & 1) * VAR_10;", "for (VAR_5 = VAR_9 & 1; VAR_5 < VAR_9; VAR_5 += 2) {", "for (VAR_4 = VAR_8 % 3; VAR_4 < VAR_8; VAR_4 += 3) {", "VAR_6 = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2);", "if (VAR_6 < 0) {", "av_log(VAR_2->s.avctx, AV_LOG_DEBUG, \"invalid NORM-6 VLC\\n\");", "return -1;", "}", "planep[VAR_4 + 0] = (VAR_6 >> 0) & 1;", "planep[VAR_4 + 1] = (VAR_6 >> 1) & 1;", "planep[VAR_4 + 2] = (VAR_6 >> 2) & 1;", "planep[VAR_4 + 0 + VAR_10] = (VAR_6 >> 3) & 1;", "planep[VAR_4 + 1 + VAR_10] = (VAR_6 >> 4) & 1;", "planep[VAR_4 + 2 + VAR_10] = (VAR_6 >> 5) & 1;", "}", "planep += VAR_10 * 2;", "}", "VAR_4 = VAR_8 % 3;", "if (VAR_4)\ndecode_colskip(VAR_0, VAR_4, VAR_9, VAR_10, &VAR_2->s.gb);", "if (VAR_9 & 1)\ndecode_rowskip(VAR_0 + VAR_4, VAR_8 - VAR_4, 1, VAR_10, &VAR_2->s.gb);", "}", "break;", "case IMODE_ROWSKIP:\ndecode_rowskip(VAR_0, VAR_8, VAR_9, VAR_10, &VAR_2->s.gb);", "break;", "case IMODE_COLSKIP:\ndecode_colskip(VAR_0, VAR_8, VAR_9, VAR_10, &VAR_2->s.gb);", "break;", "default:\nbreak;", "}", "if (VAR_3 == IMODE_DIFF2 || VAR_3 == IMODE_DIFF6) {", "planep = VAR_0;", "planep[0] ^= invert;", "for (VAR_4 = 1; VAR_4 < VAR_8; VAR_4++)", "planep[VAR_4] ^= planep[VAR_4-1];", "for (VAR_5 = 1; VAR_5 < VAR_9; VAR_5++) {", "planep += VAR_10;", "planep[0] ^= planep[-VAR_10];", "for (VAR_4 = 1; VAR_4 < VAR_8; VAR_4++) {", "if (planep[VAR_4-1] != planep[VAR_4-VAR_10]) planep[VAR_4] ^= invert;", "else planep[VAR_4] ^= planep[VAR_4-1];", "}", "}", "} else if (invert) {", "planep = VAR_0;", "for (VAR_4 = 0; VAR_4 < VAR_10 * VAR_9; VAR_4++)", "planep[VAR_4] = !planep[VAR_4];", "}", "return (VAR_3 << 1) + invert;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 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 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33, 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 ], [ 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 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ] ]
9,348
int monitor_fdset_dup_fd_remove(int dup_fd) { return monitor_fdset_dup_fd_find_remove(dup_fd, true); }
true
qemu
b3dd1b8c295636e64ceb14cdc4db6420d7319e38
int monitor_fdset_dup_fd_remove(int dup_fd) { return monitor_fdset_dup_fd_find_remove(dup_fd, true); }
{ "code": [ "int monitor_fdset_dup_fd_remove(int dup_fd)", " return monitor_fdset_dup_fd_find_remove(dup_fd, true);" ], "line_no": [ 1, 5 ] }
int FUNC_0(int VAR_0) { return monitor_fdset_dup_fd_find_remove(VAR_0, true); }
[ "int FUNC_0(int VAR_0)\n{", "return monitor_fdset_dup_fd_find_remove(VAR_0, true);", "}" ]
[ 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
9,350
static int virtio_pci_load_config(void * opaque, QEMUFile *f) { VirtIOPCIProxy *proxy = opaque; int ret; ret = pci_device_load(&proxy->pci_dev, f); if (ret) { return ret; } msix_load(&proxy->pci_dev, f); if (msix_present(&proxy->pci_dev)) { qemu_get_be16s(f, &proxy->vdev->config_vector); } else { proxy->vdev->config_vector = VIRTIO_NO_VECTOR; } if (proxy->vdev->config_vector != VIRTIO_NO_VECTOR) { return msix_vector_use(&proxy->pci_dev, proxy->vdev->config_vector); } /* Try to find out if the guest has bus master disabled, but is in ready state. Then we have a buggy guest OS. */ if (!(proxy->vdev->status & VIRTIO_CONFIG_S_DRIVER_OK) && !(proxy->pci_dev.config[PCI_COMMAND] & PCI_COMMAND_MASTER)) { proxy->bugs |= VIRTIO_PCI_BUG_BUS_MASTER; } return 0; }
true
qemu
8a911107386b5c7a78a629f0fe29381cf0ea5f6f
static int virtio_pci_load_config(void * opaque, QEMUFile *f) { VirtIOPCIProxy *proxy = opaque; int ret; ret = pci_device_load(&proxy->pci_dev, f); if (ret) { return ret; } msix_load(&proxy->pci_dev, f); if (msix_present(&proxy->pci_dev)) { qemu_get_be16s(f, &proxy->vdev->config_vector); } else { proxy->vdev->config_vector = VIRTIO_NO_VECTOR; } if (proxy->vdev->config_vector != VIRTIO_NO_VECTOR) { return msix_vector_use(&proxy->pci_dev, proxy->vdev->config_vector); } if (!(proxy->vdev->status & VIRTIO_CONFIG_S_DRIVER_OK) && !(proxy->pci_dev.config[PCI_COMMAND] & PCI_COMMAND_MASTER)) { proxy->bugs |= VIRTIO_PCI_BUG_BUS_MASTER; } return 0; }
{ "code": [ " if (!(proxy->vdev->status & VIRTIO_CONFIG_S_DRIVER_OK) &&" ], "line_no": [ 41 ] }
static int FUNC_0(void * VAR_0, QEMUFile *VAR_1) { VirtIOPCIProxy *proxy = VAR_0; int VAR_2; VAR_2 = pci_device_load(&proxy->pci_dev, VAR_1); if (VAR_2) { return VAR_2; } msix_load(&proxy->pci_dev, VAR_1); if (msix_present(&proxy->pci_dev)) { qemu_get_be16s(VAR_1, &proxy->vdev->config_vector); } else { proxy->vdev->config_vector = VIRTIO_NO_VECTOR; } if (proxy->vdev->config_vector != VIRTIO_NO_VECTOR) { return msix_vector_use(&proxy->pci_dev, proxy->vdev->config_vector); } if (!(proxy->vdev->status & VIRTIO_CONFIG_S_DRIVER_OK) && !(proxy->pci_dev.config[PCI_COMMAND] & PCI_COMMAND_MASTER)) { proxy->bugs |= VIRTIO_PCI_BUG_BUS_MASTER; } return 0; }
[ "static int FUNC_0(void * VAR_0, QEMUFile *VAR_1)\n{", "VirtIOPCIProxy *proxy = VAR_0;", "int VAR_2;", "VAR_2 = pci_device_load(&proxy->pci_dev, VAR_1);", "if (VAR_2) {", "return VAR_2;", "}", "msix_load(&proxy->pci_dev, VAR_1);", "if (msix_present(&proxy->pci_dev)) {", "qemu_get_be16s(VAR_1, &proxy->vdev->config_vector);", "} else {", "proxy->vdev->config_vector = VIRTIO_NO_VECTOR;", "}", "if (proxy->vdev->config_vector != VIRTIO_NO_VECTOR) {", "return msix_vector_use(&proxy->pci_dev, proxy->vdev->config_vector);", "}", "if (!(proxy->vdev->status & VIRTIO_CONFIG_S_DRIVER_OK) &&\n!(proxy->pci_dev.config[PCI_COMMAND] & PCI_COMMAND_MASTER)) {", "proxy->bugs |= VIRTIO_PCI_BUG_BUS_MASTER;", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 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 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 41, 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ] ]
9,353
static void opt_qmax(const char *arg) { video_qmax = atoi(arg); if (video_qmax < 0 || video_qmax > 31) { fprintf(stderr, "qmax must be >= 1 and <= 31\n"); exit(1); } }
false
FFmpeg
6e0d8c06c7af61859e8d7bc2351a607d8abeab75
static void opt_qmax(const char *arg) { video_qmax = atoi(arg); if (video_qmax < 0 || video_qmax > 31) { fprintf(stderr, "qmax must be >= 1 and <= 31\n"); exit(1); } }
{ "code": [], "line_no": [] }
static void FUNC_0(const char *VAR_0) { video_qmax = atoi(VAR_0); if (video_qmax < 0 || video_qmax > 31) { fprintf(stderr, "qmax must be >= 1 and <= 31\n"); exit(1); } }
[ "static void FUNC_0(const char *VAR_0)\n{", "video_qmax = atoi(VAR_0);", "if (video_qmax < 0 ||\nvideo_qmax > 31) {", "fprintf(stderr, \"qmax must be >= 1 and <= 31\\n\");", "exit(1);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ] ]
9,354
hadamard_func(mmx2) hadamard_func(sse2) hadamard_func(ssse3) void ff_dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx) { int mm_flags = av_get_cpu_flags(); #if HAVE_INLINE_ASM int bit_depth = avctx->bits_per_raw_sample; if (mm_flags & AV_CPU_FLAG_MMX) { const int dct_algo = avctx->dct_algo; if (avctx->bits_per_raw_sample <= 8 && (dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX)) { if(mm_flags & AV_CPU_FLAG_SSE2){ c->fdct = ff_fdct_sse2; } else if (mm_flags & AV_CPU_FLAG_MMXEXT) { c->fdct = ff_fdct_mmx2; }else{ c->fdct = ff_fdct_mmx; } } if (bit_depth <= 8) c->get_pixels = get_pixels_mmx; c->diff_pixels = diff_pixels_mmx; c->pix_sum = pix_sum16_mmx; c->diff_bytes= diff_bytes_mmx; c->sum_abs_dctelem= sum_abs_dctelem_mmx; c->pix_norm1 = pix_norm1_mmx; c->sse[0] = sse16_mmx; c->sse[1] = sse8_mmx; c->vsad[4]= vsad_intra16_mmx; c->nsse[0] = nsse16_mmx; c->nsse[1] = nsse8_mmx; if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->vsad[0] = vsad16_mmx; } if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->try_8x8basis= try_8x8basis_mmx; } c->add_8x8basis= add_8x8basis_mmx; c->ssd_int8_vs_int16 = ssd_int8_vs_int16_mmx; if (mm_flags & AV_CPU_FLAG_MMXEXT) { c->sum_abs_dctelem= sum_abs_dctelem_mmx2; c->vsad[4]= vsad_intra16_mmx2; if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->vsad[0] = vsad16_mmx2; } c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_mmx2; } if(mm_flags & AV_CPU_FLAG_SSE2){ if (bit_depth <= 8) c->get_pixels = get_pixels_sse2; c->sum_abs_dctelem= sum_abs_dctelem_sse2; } #if HAVE_SSSE3_INLINE if(mm_flags & AV_CPU_FLAG_SSSE3){ if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->try_8x8basis= try_8x8basis_ssse3; } c->add_8x8basis= add_8x8basis_ssse3; c->sum_abs_dctelem= sum_abs_dctelem_ssse3; } #endif if(mm_flags & AV_CPU_FLAG_3DNOW){ if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->try_8x8basis= try_8x8basis_3dnow; } c->add_8x8basis= add_8x8basis_3dnow; } } #endif /* HAVE_INLINE_ASM */ #if HAVE_YASM if (mm_flags & AV_CPU_FLAG_MMX) { c->hadamard8_diff[0] = ff_hadamard8_diff16_mmx; c->hadamard8_diff[1] = ff_hadamard8_diff_mmx; if (mm_flags & AV_CPU_FLAG_MMXEXT) { c->hadamard8_diff[0] = ff_hadamard8_diff16_mmx2; c->hadamard8_diff[1] = ff_hadamard8_diff_mmx2; } if (mm_flags & AV_CPU_FLAG_SSE2){ c->sse[0] = ff_sse16_sse2; #if HAVE_ALIGNED_STACK c->hadamard8_diff[0] = ff_hadamard8_diff16_sse2; c->hadamard8_diff[1] = ff_hadamard8_diff_sse2; #endif } #if HAVE_SSSE3 && HAVE_ALIGNED_STACK if (mm_flags & AV_CPU_FLAG_SSSE3) { c->hadamard8_diff[0] = ff_hadamard8_diff16_ssse3; c->hadamard8_diff[1] = ff_hadamard8_diff_ssse3; } #endif } #endif /* HAVE_YASM */ ff_dsputil_init_pix_mmx(c, avctx); }
false
FFmpeg
e0c6cce44729d94e2a5507a4b6d031f23e8bd7b6
hadamard_func(mmx2) hadamard_func(sse2) hadamard_func(ssse3) void ff_dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx) { int mm_flags = av_get_cpu_flags(); #if HAVE_INLINE_ASM int bit_depth = avctx->bits_per_raw_sample; if (mm_flags & AV_CPU_FLAG_MMX) { const int dct_algo = avctx->dct_algo; if (avctx->bits_per_raw_sample <= 8 && (dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX)) { if(mm_flags & AV_CPU_FLAG_SSE2){ c->fdct = ff_fdct_sse2; } else if (mm_flags & AV_CPU_FLAG_MMXEXT) { c->fdct = ff_fdct_mmx2; }else{ c->fdct = ff_fdct_mmx; } } if (bit_depth <= 8) c->get_pixels = get_pixels_mmx; c->diff_pixels = diff_pixels_mmx; c->pix_sum = pix_sum16_mmx; c->diff_bytes= diff_bytes_mmx; c->sum_abs_dctelem= sum_abs_dctelem_mmx; c->pix_norm1 = pix_norm1_mmx; c->sse[0] = sse16_mmx; c->sse[1] = sse8_mmx; c->vsad[4]= vsad_intra16_mmx; c->nsse[0] = nsse16_mmx; c->nsse[1] = nsse8_mmx; if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->vsad[0] = vsad16_mmx; } if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->try_8x8basis= try_8x8basis_mmx; } c->add_8x8basis= add_8x8basis_mmx; c->ssd_int8_vs_int16 = ssd_int8_vs_int16_mmx; if (mm_flags & AV_CPU_FLAG_MMXEXT) { c->sum_abs_dctelem= sum_abs_dctelem_mmx2; c->vsad[4]= vsad_intra16_mmx2; if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->vsad[0] = vsad16_mmx2; } c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_mmx2; } if(mm_flags & AV_CPU_FLAG_SSE2){ if (bit_depth <= 8) c->get_pixels = get_pixels_sse2; c->sum_abs_dctelem= sum_abs_dctelem_sse2; } #if HAVE_SSSE3_INLINE if(mm_flags & AV_CPU_FLAG_SSSE3){ if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->try_8x8basis= try_8x8basis_ssse3; } c->add_8x8basis= add_8x8basis_ssse3; c->sum_abs_dctelem= sum_abs_dctelem_ssse3; } #endif if(mm_flags & AV_CPU_FLAG_3DNOW){ if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->try_8x8basis= try_8x8basis_3dnow; } c->add_8x8basis= add_8x8basis_3dnow; } } #endif #if HAVE_YASM if (mm_flags & AV_CPU_FLAG_MMX) { c->hadamard8_diff[0] = ff_hadamard8_diff16_mmx; c->hadamard8_diff[1] = ff_hadamard8_diff_mmx; if (mm_flags & AV_CPU_FLAG_MMXEXT) { c->hadamard8_diff[0] = ff_hadamard8_diff16_mmx2; c->hadamard8_diff[1] = ff_hadamard8_diff_mmx2; } if (mm_flags & AV_CPU_FLAG_SSE2){ c->sse[0] = ff_sse16_sse2; #if HAVE_ALIGNED_STACK c->hadamard8_diff[0] = ff_hadamard8_diff16_sse2; c->hadamard8_diff[1] = ff_hadamard8_diff_sse2; #endif } #if HAVE_SSSE3 && HAVE_ALIGNED_STACK if (mm_flags & AV_CPU_FLAG_SSSE3) { c->hadamard8_diff[0] = ff_hadamard8_diff16_ssse3; c->hadamard8_diff[1] = ff_hadamard8_diff_ssse3; } #endif } #endif ff_dsputil_init_pix_mmx(c, avctx); }
{ "code": [], "line_no": [] }
hadamard_func(mmx2) hadamard_func(sse2) hadamard_func(ssse3) void ff_dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx) { int mm_flags = av_get_cpu_flags(); #if HAVE_INLINE_ASM int bit_depth = avctx->bits_per_raw_sample; if (mm_flags & AV_CPU_FLAG_MMX) { const int dct_algo = avctx->dct_algo; if (avctx->bits_per_raw_sample <= 8 && (dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX)) { if(mm_flags & AV_CPU_FLAG_SSE2){ c->fdct = ff_fdct_sse2; } else if (mm_flags & AV_CPU_FLAG_MMXEXT) { c->fdct = ff_fdct_mmx2; }else{ c->fdct = ff_fdct_mmx; } } if (bit_depth <= 8) c->get_pixels = get_pixels_mmx; c->diff_pixels = diff_pixels_mmx; c->pix_sum = pix_sum16_mmx; c->diff_bytes= diff_bytes_mmx; c->sum_abs_dctelem= sum_abs_dctelem_mmx; c->pix_norm1 = pix_norm1_mmx; c->sse[0] = sse16_mmx; c->sse[1] = sse8_mmx; c->vsad[4]= vsad_intra16_mmx; c->nsse[0] = nsse16_mmx; c->nsse[1] = nsse8_mmx; if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->vsad[0] = vsad16_mmx; } if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->try_8x8basis= try_8x8basis_mmx; } c->add_8x8basis= add_8x8basis_mmx; c->ssd_int8_vs_int16 = ssd_int8_vs_int16_mmx; if (mm_flags & AV_CPU_FLAG_MMXEXT) { c->sum_abs_dctelem= sum_abs_dctelem_mmx2; c->vsad[4]= vsad_intra16_mmx2; if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->vsad[0] = vsad16_mmx2; } c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_mmx2; } if(mm_flags & AV_CPU_FLAG_SSE2){ if (bit_depth <= 8) c->get_pixels = get_pixels_sse2; c->sum_abs_dctelem= sum_abs_dctelem_sse2; } #if HAVE_SSSE3_INLINE if(mm_flags & AV_CPU_FLAG_SSSE3){ if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->try_8x8basis= try_8x8basis_ssse3; } c->add_8x8basis= add_8x8basis_ssse3; c->sum_abs_dctelem= sum_abs_dctelem_ssse3; } #endif if(mm_flags & AV_CPU_FLAG_3DNOW){ if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->try_8x8basis= try_8x8basis_3dnow; } c->add_8x8basis= add_8x8basis_3dnow; } } #endif #if HAVE_YASM if (mm_flags & AV_CPU_FLAG_MMX) { c->hadamard8_diff[0] = ff_hadamard8_diff16_mmx; c->hadamard8_diff[1] = ff_hadamard8_diff_mmx; if (mm_flags & AV_CPU_FLAG_MMXEXT) { c->hadamard8_diff[0] = ff_hadamard8_diff16_mmx2; c->hadamard8_diff[1] = ff_hadamard8_diff_mmx2; } if (mm_flags & AV_CPU_FLAG_SSE2){ c->sse[0] = ff_sse16_sse2; #if HAVE_ALIGNED_STACK c->hadamard8_diff[0] = ff_hadamard8_diff16_sse2; c->hadamard8_diff[1] = ff_hadamard8_diff_sse2; #endif } #if HAVE_SSSE3 && HAVE_ALIGNED_STACK if (mm_flags & AV_CPU_FLAG_SSSE3) { c->hadamard8_diff[0] = ff_hadamard8_diff16_ssse3; c->hadamard8_diff[1] = ff_hadamard8_diff_ssse3; } #endif } #endif ff_dsputil_init_pix_mmx(c, avctx); }
[ "hadamard_func(mmx2)\nhadamard_func(sse2)\nhadamard_func(ssse3)\nvoid ff_dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx)\n{", "int mm_flags = av_get_cpu_flags();", "#if HAVE_INLINE_ASM\nint bit_depth = avctx->bits_per_raw_sample;", "if (mm_flags & AV_CPU_FLAG_MMX) {", "const int dct_algo = avctx->dct_algo;", "if (avctx->bits_per_raw_sample <= 8 &&\n(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX)) {", "if(mm_flags & AV_CPU_FLAG_SSE2){", "c->fdct = ff_fdct_sse2;", "} else if (mm_flags & AV_CPU_FLAG_MMXEXT) {", "c->fdct = ff_fdct_mmx2;", "}else{", "c->fdct = ff_fdct_mmx;", "}", "}", "if (bit_depth <= 8)\nc->get_pixels = get_pixels_mmx;", "c->diff_pixels = diff_pixels_mmx;", "c->pix_sum = pix_sum16_mmx;", "c->diff_bytes= diff_bytes_mmx;", "c->sum_abs_dctelem= sum_abs_dctelem_mmx;", "c->pix_norm1 = pix_norm1_mmx;", "c->sse[0] = sse16_mmx;", "c->sse[1] = sse8_mmx;", "c->vsad[4]= vsad_intra16_mmx;", "c->nsse[0] = nsse16_mmx;", "c->nsse[1] = nsse8_mmx;", "if(!(avctx->flags & CODEC_FLAG_BITEXACT)){", "c->vsad[0] = vsad16_mmx;", "}", "if(!(avctx->flags & CODEC_FLAG_BITEXACT)){", "c->try_8x8basis= try_8x8basis_mmx;", "}", "c->add_8x8basis= add_8x8basis_mmx;", "c->ssd_int8_vs_int16 = ssd_int8_vs_int16_mmx;", "if (mm_flags & AV_CPU_FLAG_MMXEXT) {", "c->sum_abs_dctelem= sum_abs_dctelem_mmx2;", "c->vsad[4]= vsad_intra16_mmx2;", "if(!(avctx->flags & CODEC_FLAG_BITEXACT)){", "c->vsad[0] = vsad16_mmx2;", "}", "c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_mmx2;", "}", "if(mm_flags & AV_CPU_FLAG_SSE2){", "if (bit_depth <= 8)\nc->get_pixels = get_pixels_sse2;", "c->sum_abs_dctelem= sum_abs_dctelem_sse2;", "}", "#if HAVE_SSSE3_INLINE\nif(mm_flags & AV_CPU_FLAG_SSSE3){", "if(!(avctx->flags & CODEC_FLAG_BITEXACT)){", "c->try_8x8basis= try_8x8basis_ssse3;", "}", "c->add_8x8basis= add_8x8basis_ssse3;", "c->sum_abs_dctelem= sum_abs_dctelem_ssse3;", "}", "#endif\nif(mm_flags & AV_CPU_FLAG_3DNOW){", "if(!(avctx->flags & CODEC_FLAG_BITEXACT)){", "c->try_8x8basis= try_8x8basis_3dnow;", "}", "c->add_8x8basis= add_8x8basis_3dnow;", "}", "}", "#endif\n#if HAVE_YASM\nif (mm_flags & AV_CPU_FLAG_MMX) {", "c->hadamard8_diff[0] = ff_hadamard8_diff16_mmx;", "c->hadamard8_diff[1] = ff_hadamard8_diff_mmx;", "if (mm_flags & AV_CPU_FLAG_MMXEXT) {", "c->hadamard8_diff[0] = ff_hadamard8_diff16_mmx2;", "c->hadamard8_diff[1] = ff_hadamard8_diff_mmx2;", "}", "if (mm_flags & AV_CPU_FLAG_SSE2){", "c->sse[0] = ff_sse16_sse2;", "#if HAVE_ALIGNED_STACK\nc->hadamard8_diff[0] = ff_hadamard8_diff16_sse2;", "c->hadamard8_diff[1] = ff_hadamard8_diff_sse2;", "#endif\n}", "#if HAVE_SSSE3 && HAVE_ALIGNED_STACK\nif (mm_flags & AV_CPU_FLAG_SSSE3) {", "c->hadamard8_diff[0] = ff_hadamard8_diff16_ssse3;", "c->hadamard8_diff[1] = ff_hadamard8_diff_ssse3;", "}", "#endif\n}", "#endif\nff_dsputil_init_pix_mmx(c, avctx);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 17, 19 ], [ 23 ], [ 25 ], [ 27, 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49, 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 97 ], [ 101 ], [ 103 ], [ 105 ], [ 109 ], [ 111 ], [ 113 ], [ 117 ], [ 119 ], [ 123 ], [ 125, 127 ], [ 129 ], [ 131 ], [ 135, 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151, 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169, 173, 175 ], [ 177 ], [ 179 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 193 ], [ 195 ], [ 199, 201 ], [ 203 ], [ 205, 207 ], [ 211, 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221, 223 ], [ 225, 229 ], [ 231 ] ]
9,355
static int init_opaque_surf(QSVContext *qsv) { AVQSVContext *hwctx_enc = qsv->ost->enc_ctx->hwaccel_context; mfxFrameSurface1 *surfaces; int i; qsv->nb_surfaces = hwctx_enc->nb_opaque_surfaces; qsv->opaque_surfaces_buf = av_buffer_ref(hwctx_enc->opaque_surfaces); qsv->surface_ptrs = av_mallocz_array(qsv->nb_surfaces, sizeof(*qsv->surface_ptrs)); qsv->surface_used = av_mallocz_array(qsv->nb_surfaces, sizeof(*qsv->surface_used)); if (!qsv->opaque_surfaces_buf || !qsv->surface_ptrs || !qsv->surface_used) return AVERROR(ENOMEM); surfaces = (mfxFrameSurface1*)qsv->opaque_surfaces_buf->data; for (i = 0; i < qsv->nb_surfaces; i++) qsv->surface_ptrs[i] = surfaces + i; qsv->opaque_alloc.Out.Surfaces = qsv->surface_ptrs; qsv->opaque_alloc.Out.NumSurface = qsv->nb_surfaces; qsv->opaque_alloc.Out.Type = hwctx_enc->opaque_alloc_type; qsv->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION; qsv->opaque_alloc.Header.BufferSz = sizeof(qsv->opaque_alloc); qsv->ext_buffers[0] = (mfxExtBuffer*)&qsv->opaque_alloc; return 0; }
false
FFmpeg
03cef34aa66662e2ab3681d290e7c5a6634f4058
static int init_opaque_surf(QSVContext *qsv) { AVQSVContext *hwctx_enc = qsv->ost->enc_ctx->hwaccel_context; mfxFrameSurface1 *surfaces; int i; qsv->nb_surfaces = hwctx_enc->nb_opaque_surfaces; qsv->opaque_surfaces_buf = av_buffer_ref(hwctx_enc->opaque_surfaces); qsv->surface_ptrs = av_mallocz_array(qsv->nb_surfaces, sizeof(*qsv->surface_ptrs)); qsv->surface_used = av_mallocz_array(qsv->nb_surfaces, sizeof(*qsv->surface_used)); if (!qsv->opaque_surfaces_buf || !qsv->surface_ptrs || !qsv->surface_used) return AVERROR(ENOMEM); surfaces = (mfxFrameSurface1*)qsv->opaque_surfaces_buf->data; for (i = 0; i < qsv->nb_surfaces; i++) qsv->surface_ptrs[i] = surfaces + i; qsv->opaque_alloc.Out.Surfaces = qsv->surface_ptrs; qsv->opaque_alloc.Out.NumSurface = qsv->nb_surfaces; qsv->opaque_alloc.Out.Type = hwctx_enc->opaque_alloc_type; qsv->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION; qsv->opaque_alloc.Header.BufferSz = sizeof(qsv->opaque_alloc); qsv->ext_buffers[0] = (mfxExtBuffer*)&qsv->opaque_alloc; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(QSVContext *VAR_0) { AVQSVContext *hwctx_enc = VAR_0->ost->enc_ctx->hwaccel_context; mfxFrameSurface1 *surfaces; int VAR_1; VAR_0->nb_surfaces = hwctx_enc->nb_opaque_surfaces; VAR_0->opaque_surfaces_buf = av_buffer_ref(hwctx_enc->opaque_surfaces); VAR_0->surface_ptrs = av_mallocz_array(VAR_0->nb_surfaces, sizeof(*VAR_0->surface_ptrs)); VAR_0->surface_used = av_mallocz_array(VAR_0->nb_surfaces, sizeof(*VAR_0->surface_used)); if (!VAR_0->opaque_surfaces_buf || !VAR_0->surface_ptrs || !VAR_0->surface_used) return AVERROR(ENOMEM); surfaces = (mfxFrameSurface1*)VAR_0->opaque_surfaces_buf->data; for (VAR_1 = 0; VAR_1 < VAR_0->nb_surfaces; VAR_1++) VAR_0->surface_ptrs[VAR_1] = surfaces + VAR_1; VAR_0->opaque_alloc.Out.Surfaces = VAR_0->surface_ptrs; VAR_0->opaque_alloc.Out.NumSurface = VAR_0->nb_surfaces; VAR_0->opaque_alloc.Out.Type = hwctx_enc->opaque_alloc_type; VAR_0->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION; VAR_0->opaque_alloc.Header.BufferSz = sizeof(VAR_0->opaque_alloc); VAR_0->ext_buffers[0] = (mfxExtBuffer*)&VAR_0->opaque_alloc; return 0; }
[ "static int FUNC_0(QSVContext *VAR_0)\n{", "AVQSVContext *hwctx_enc = VAR_0->ost->enc_ctx->hwaccel_context;", "mfxFrameSurface1 *surfaces;", "int VAR_1;", "VAR_0->nb_surfaces = hwctx_enc->nb_opaque_surfaces;", "VAR_0->opaque_surfaces_buf = av_buffer_ref(hwctx_enc->opaque_surfaces);", "VAR_0->surface_ptrs = av_mallocz_array(VAR_0->nb_surfaces, sizeof(*VAR_0->surface_ptrs));", "VAR_0->surface_used = av_mallocz_array(VAR_0->nb_surfaces, sizeof(*VAR_0->surface_used));", "if (!VAR_0->opaque_surfaces_buf || !VAR_0->surface_ptrs || !VAR_0->surface_used)\nreturn AVERROR(ENOMEM);", "surfaces = (mfxFrameSurface1*)VAR_0->opaque_surfaces_buf->data;", "for (VAR_1 = 0; VAR_1 < VAR_0->nb_surfaces; VAR_1++)", "VAR_0->surface_ptrs[VAR_1] = surfaces + VAR_1;", "VAR_0->opaque_alloc.Out.Surfaces = VAR_0->surface_ptrs;", "VAR_0->opaque_alloc.Out.NumSurface = VAR_0->nb_surfaces;", "VAR_0->opaque_alloc.Out.Type = hwctx_enc->opaque_alloc_type;", "VAR_0->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION;", "VAR_0->opaque_alloc.Header.BufferSz = sizeof(VAR_0->opaque_alloc);", "VAR_0->ext_buffers[0] = (mfxExtBuffer*)&VAR_0->opaque_alloc;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23, 25 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ] ]
9,357
static int rv20_decode_picture_header(RVDecContext *rv) { MpegEncContext *s = &rv->m; int seq, mb_pos, i; int rpr_bits; #if 0 GetBitContext gb= s->gb; for(i=0; i<64; i++){ av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&gb)); if(i%4==3) av_log(s->avctx, AV_LOG_DEBUG, " "); } av_log(s->avctx, AV_LOG_DEBUG, "\n"); #endif #if 0 av_log(s->avctx, AV_LOG_DEBUG, "%3dx%03d/%02Xx%02X ", s->width, s->height, s->width/4, s->height/4); for(i=0; i<s->avctx->extradata_size; i++){ av_log(s->avctx, AV_LOG_DEBUG, "%02X ", ((uint8_t*)s->avctx->extradata)[i]); if(i%4==3) av_log(s->avctx, AV_LOG_DEBUG, " "); } av_log(s->avctx, AV_LOG_DEBUG, "\n"); #endif i= get_bits(&s->gb, 2); switch(i){ case 0: s->pict_type= AV_PICTURE_TYPE_I; break; case 1: s->pict_type= AV_PICTURE_TYPE_I; break; //hmm ... case 2: s->pict_type= AV_PICTURE_TYPE_P; break; case 3: s->pict_type= AV_PICTURE_TYPE_B; break; default: av_log(s->avctx, AV_LOG_ERROR, "unknown frame type\n"); return -1; } if(s->last_picture_ptr==NULL && s->pict_type==AV_PICTURE_TYPE_B){ av_log(s->avctx, AV_LOG_ERROR, "early B pix\n"); return -1; } if (get_bits1(&s->gb)){ av_log(s->avctx, AV_LOG_ERROR, "reserved bit set\n"); return -1; } s->qscale = get_bits(&s->gb, 5); if(s->qscale==0){ av_log(s->avctx, AV_LOG_ERROR, "error, qscale:0\n"); return -1; } if(RV_GET_MINOR_VER(rv->sub_id) >= 2) s->loop_filter = get_bits1(&s->gb); if(RV_GET_MINOR_VER(rv->sub_id) <= 1) seq = get_bits(&s->gb, 8) << 7; else seq = get_bits(&s->gb, 13) << 2; rpr_bits = s->avctx->extradata[1] & 7; if(rpr_bits){ int f, new_w, new_h; rpr_bits = FFMIN((rpr_bits >> 1) + 1, 3); f = get_bits(&s->gb, rpr_bits); if(f){ new_w= 4*((uint8_t*)s->avctx->extradata)[6+2*f]; new_h= 4*((uint8_t*)s->avctx->extradata)[7+2*f]; }else{ new_w= s->orig_width ; new_h= s->orig_height; } if(new_w != s->width || new_h != s->height){ AVRational old_aspect = s->avctx->sample_aspect_ratio; av_log(s->avctx, AV_LOG_DEBUG, "attempting to change resolution to %dx%d\n", new_w, new_h); if (av_image_check_size(new_w, new_h, 0, s->avctx) < 0) return -1; ff_MPV_common_end(s); // attempt to keep aspect during typical resolution switches if (!old_aspect.num) old_aspect = (AVRational){1, 1}; if (2 * new_w * s->height == new_h * s->width) s->avctx->sample_aspect_ratio = av_mul_q(old_aspect, (AVRational){2, 1}); if (new_w * s->height == 2 * new_h * s->width) s->avctx->sample_aspect_ratio = av_mul_q(old_aspect, (AVRational){1, 2}); avcodec_set_dimensions(s->avctx, new_w, new_h); s->width = new_w; s->height = new_h; if (ff_MPV_common_init(s) < 0) return -1; } if(s->avctx->debug & FF_DEBUG_PICT_INFO){ av_log(s->avctx, AV_LOG_DEBUG, "F %d/%d\n", f, rpr_bits); } } else if (av_image_check_size(s->width, s->height, 0, s->avctx) < 0) return AVERROR_INVALIDDATA; mb_pos = ff_h263_decode_mba(s); //av_log(s->avctx, AV_LOG_DEBUG, "%d\n", seq); seq |= s->time &~0x7FFF; if(seq - s->time > 0x4000) seq -= 0x8000; if(seq - s->time < -0x4000) seq += 0x8000; if(seq != s->time){ if(s->pict_type!=AV_PICTURE_TYPE_B){ s->time= seq; s->pp_time= s->time - s->last_non_b_time; s->last_non_b_time= s->time; }else{ s->time= seq; s->pb_time= s->pp_time - (s->last_non_b_time - s->time); if(s->pp_time <=s->pb_time || s->pp_time <= s->pp_time - s->pb_time || s->pp_time<=0){ av_log(s->avctx, AV_LOG_DEBUG, "messed up order, possible from seeking? skipping current b frame\n"); return FRAME_SKIPPED; } ff_mpeg4_init_direct_mv(s); } } // printf("%d %d %d %d %d\n", seq, (int)s->time, (int)s->last_non_b_time, s->pp_time, s->pb_time); /*for(i=0; i<32; i++){ av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb)); } av_log(s->avctx, AV_LOG_DEBUG, "\n");*/ s->no_rounding= get_bits1(&s->gb); if(RV_GET_MINOR_VER(rv->sub_id) <= 1 && s->pict_type == AV_PICTURE_TYPE_B) skip_bits(&s->gb, 5); // binary decoder reads 3+2 bits here but they don't seem to be used s->f_code = 1; s->unrestricted_mv = 1; s->h263_aic= s->pict_type == AV_PICTURE_TYPE_I; // s->alt_inter_vlc=1; // s->obmc=1; // s->umvplus=1; s->modified_quant=1; if(!s->avctx->lowres) s->loop_filter=1; if(s->avctx->debug & FF_DEBUG_PICT_INFO){ av_log(s->avctx, AV_LOG_INFO, "num:%5d x:%2d y:%2d type:%d qscale:%2d rnd:%d\n", seq, s->mb_x, s->mb_y, s->pict_type, s->qscale, s->no_rounding); } assert(s->pict_type != AV_PICTURE_TYPE_B || !s->low_delay); return s->mb_width*s->mb_height - mb_pos; }
false
FFmpeg
0766b6e3ec6b7f51af5787421290284050e32a91
static int rv20_decode_picture_header(RVDecContext *rv) { MpegEncContext *s = &rv->m; int seq, mb_pos, i; int rpr_bits; #if 0 GetBitContext gb= s->gb; for(i=0; i<64; i++){ av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&gb)); if(i%4==3) av_log(s->avctx, AV_LOG_DEBUG, " "); } av_log(s->avctx, AV_LOG_DEBUG, "\n"); #endif #if 0 av_log(s->avctx, AV_LOG_DEBUG, "%3dx%03d/%02Xx%02X ", s->width, s->height, s->width/4, s->height/4); for(i=0; i<s->avctx->extradata_size; i++){ av_log(s->avctx, AV_LOG_DEBUG, "%02X ", ((uint8_t*)s->avctx->extradata)[i]); if(i%4==3) av_log(s->avctx, AV_LOG_DEBUG, " "); } av_log(s->avctx, AV_LOG_DEBUG, "\n"); #endif i= get_bits(&s->gb, 2); switch(i){ case 0: s->pict_type= AV_PICTURE_TYPE_I; break; case 1: s->pict_type= AV_PICTURE_TYPE_I; break; case 2: s->pict_type= AV_PICTURE_TYPE_P; break; case 3: s->pict_type= AV_PICTURE_TYPE_B; break; default: av_log(s->avctx, AV_LOG_ERROR, "unknown frame type\n"); return -1; } if(s->last_picture_ptr==NULL && s->pict_type==AV_PICTURE_TYPE_B){ av_log(s->avctx, AV_LOG_ERROR, "early B pix\n"); return -1; } if (get_bits1(&s->gb)){ av_log(s->avctx, AV_LOG_ERROR, "reserved bit set\n"); return -1; } s->qscale = get_bits(&s->gb, 5); if(s->qscale==0){ av_log(s->avctx, AV_LOG_ERROR, "error, qscale:0\n"); return -1; } if(RV_GET_MINOR_VER(rv->sub_id) >= 2) s->loop_filter = get_bits1(&s->gb); if(RV_GET_MINOR_VER(rv->sub_id) <= 1) seq = get_bits(&s->gb, 8) << 7; else seq = get_bits(&s->gb, 13) << 2; rpr_bits = s->avctx->extradata[1] & 7; if(rpr_bits){ int f, new_w, new_h; rpr_bits = FFMIN((rpr_bits >> 1) + 1, 3); f = get_bits(&s->gb, rpr_bits); if(f){ new_w= 4*((uint8_t*)s->avctx->extradata)[6+2*f]; new_h= 4*((uint8_t*)s->avctx->extradata)[7+2*f]; }else{ new_w= s->orig_width ; new_h= s->orig_height; } if(new_w != s->width || new_h != s->height){ AVRational old_aspect = s->avctx->sample_aspect_ratio; av_log(s->avctx, AV_LOG_DEBUG, "attempting to change resolution to %dx%d\n", new_w, new_h); if (av_image_check_size(new_w, new_h, 0, s->avctx) < 0) return -1; ff_MPV_common_end(s); if (!old_aspect.num) old_aspect = (AVRational){1, 1}; if (2 * new_w * s->height == new_h * s->width) s->avctx->sample_aspect_ratio = av_mul_q(old_aspect, (AVRational){2, 1}); if (new_w * s->height == 2 * new_h * s->width) s->avctx->sample_aspect_ratio = av_mul_q(old_aspect, (AVRational){1, 2}); avcodec_set_dimensions(s->avctx, new_w, new_h); s->width = new_w; s->height = new_h; if (ff_MPV_common_init(s) < 0) return -1; } if(s->avctx->debug & FF_DEBUG_PICT_INFO){ av_log(s->avctx, AV_LOG_DEBUG, "F %d/%d\n", f, rpr_bits); } } else if (av_image_check_size(s->width, s->height, 0, s->avctx) < 0) return AVERROR_INVALIDDATA; mb_pos = ff_h263_decode_mba(s); seq |= s->time &~0x7FFF; if(seq - s->time > 0x4000) seq -= 0x8000; if(seq - s->time < -0x4000) seq += 0x8000; if(seq != s->time){ if(s->pict_type!=AV_PICTURE_TYPE_B){ s->time= seq; s->pp_time= s->time - s->last_non_b_time; s->last_non_b_time= s->time; }else{ s->time= seq; s->pb_time= s->pp_time - (s->last_non_b_time - s->time); if(s->pp_time <=s->pb_time || s->pp_time <= s->pp_time - s->pb_time || s->pp_time<=0){ av_log(s->avctx, AV_LOG_DEBUG, "messed up order, possible from seeking? skipping current b frame\n"); return FRAME_SKIPPED; } ff_mpeg4_init_direct_mv(s); } } s->no_rounding= get_bits1(&s->gb); if(RV_GET_MINOR_VER(rv->sub_id) <= 1 && s->pict_type == AV_PICTURE_TYPE_B) skip_bits(&s->gb, 5); s->f_code = 1; s->unrestricted_mv = 1; s->h263_aic= s->pict_type == AV_PICTURE_TYPE_I; s->modified_quant=1; if(!s->avctx->lowres) s->loop_filter=1; if(s->avctx->debug & FF_DEBUG_PICT_INFO){ av_log(s->avctx, AV_LOG_INFO, "num:%5d x:%2d y:%2d type:%d qscale:%2d rnd:%d\n", seq, s->mb_x, s->mb_y, s->pict_type, s->qscale, s->no_rounding); } assert(s->pict_type != AV_PICTURE_TYPE_B || !s->low_delay); return s->mb_width*s->mb_height - mb_pos; }
{ "code": [], "line_no": [] }
static int FUNC_0(RVDecContext *VAR_0) { MpegEncContext *s = &VAR_0->m; int VAR_1, VAR_2, VAR_3; int VAR_4; #if 0 GetBitContext gb= s->gb; for(VAR_3=0; VAR_3<64; VAR_3++){ av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&gb)); if(VAR_3%4==3) av_log(s->avctx, AV_LOG_DEBUG, " "); } av_log(s->avctx, AV_LOG_DEBUG, "\n"); #endif #if 0 av_log(s->avctx, AV_LOG_DEBUG, "%3dx%03d/%02Xx%02X ", s->width, s->height, s->width/4, s->height/4); for(VAR_3=0; VAR_3<s->avctx->extradata_size; VAR_3++){ av_log(s->avctx, AV_LOG_DEBUG, "%02X ", ((uint8_t*)s->avctx->extradata)[VAR_3]); if(VAR_3%4==3) av_log(s->avctx, AV_LOG_DEBUG, " "); } av_log(s->avctx, AV_LOG_DEBUG, "\n"); #endif VAR_3= get_bits(&s->gb, 2); switch(VAR_3){ case 0: s->pict_type= AV_PICTURE_TYPE_I; break; case 1: s->pict_type= AV_PICTURE_TYPE_I; break; case 2: s->pict_type= AV_PICTURE_TYPE_P; break; case 3: s->pict_type= AV_PICTURE_TYPE_B; break; default: av_log(s->avctx, AV_LOG_ERROR, "unknown frame type\n"); return -1; } if(s->last_picture_ptr==NULL && s->pict_type==AV_PICTURE_TYPE_B){ av_log(s->avctx, AV_LOG_ERROR, "early B pix\n"); return -1; } if (get_bits1(&s->gb)){ av_log(s->avctx, AV_LOG_ERROR, "reserved bit set\n"); return -1; } s->qscale = get_bits(&s->gb, 5); if(s->qscale==0){ av_log(s->avctx, AV_LOG_ERROR, "error, qscale:0\n"); return -1; } if(RV_GET_MINOR_VER(VAR_0->sub_id) >= 2) s->loop_filter = get_bits1(&s->gb); if(RV_GET_MINOR_VER(VAR_0->sub_id) <= 1) VAR_1 = get_bits(&s->gb, 8) << 7; else VAR_1 = get_bits(&s->gb, 13) << 2; VAR_4 = s->avctx->extradata[1] & 7; if(VAR_4){ int VAR_5, VAR_6, VAR_7; VAR_4 = FFMIN((VAR_4 >> 1) + 1, 3); VAR_5 = get_bits(&s->gb, VAR_4); if(VAR_5){ VAR_6= 4*((uint8_t*)s->avctx->extradata)[6+2*VAR_5]; VAR_7= 4*((uint8_t*)s->avctx->extradata)[7+2*VAR_5]; }else{ VAR_6= s->orig_width ; VAR_7= s->orig_height; } if(VAR_6 != s->width || VAR_7 != s->height){ AVRational old_aspect = s->avctx->sample_aspect_ratio; av_log(s->avctx, AV_LOG_DEBUG, "attempting to change resolution to %dx%d\n", VAR_6, VAR_7); if (av_image_check_size(VAR_6, VAR_7, 0, s->avctx) < 0) return -1; ff_MPV_common_end(s); if (!old_aspect.num) old_aspect = (AVRational){1, 1}; if (2 * VAR_6 * s->height == VAR_7 * s->width) s->avctx->sample_aspect_ratio = av_mul_q(old_aspect, (AVRational){2, 1}); if (VAR_6 * s->height == 2 * VAR_7 * s->width) s->avctx->sample_aspect_ratio = av_mul_q(old_aspect, (AVRational){1, 2}); avcodec_set_dimensions(s->avctx, VAR_6, VAR_7); s->width = VAR_6; s->height = VAR_7; if (ff_MPV_common_init(s) < 0) return -1; } if(s->avctx->debug & FF_DEBUG_PICT_INFO){ av_log(s->avctx, AV_LOG_DEBUG, "F %d/%d\n", VAR_5, VAR_4); } } else if (av_image_check_size(s->width, s->height, 0, s->avctx) < 0) return AVERROR_INVALIDDATA; VAR_2 = ff_h263_decode_mba(s); VAR_1 |= s->time &~0x7FFF; if(VAR_1 - s->time > 0x4000) VAR_1 -= 0x8000; if(VAR_1 - s->time < -0x4000) VAR_1 += 0x8000; if(VAR_1 != s->time){ if(s->pict_type!=AV_PICTURE_TYPE_B){ s->time= VAR_1; s->pp_time= s->time - s->last_non_b_time; s->last_non_b_time= s->time; }else{ s->time= VAR_1; s->pb_time= s->pp_time - (s->last_non_b_time - s->time); if(s->pp_time <=s->pb_time || s->pp_time <= s->pp_time - s->pb_time || s->pp_time<=0){ av_log(s->avctx, AV_LOG_DEBUG, "messed up order, possible from seeking? skipping current b frame\n"); return FRAME_SKIPPED; } ff_mpeg4_init_direct_mv(s); } } s->no_rounding= get_bits1(&s->gb); if(RV_GET_MINOR_VER(VAR_0->sub_id) <= 1 && s->pict_type == AV_PICTURE_TYPE_B) skip_bits(&s->gb, 5); s->f_code = 1; s->unrestricted_mv = 1; s->h263_aic= s->pict_type == AV_PICTURE_TYPE_I; s->modified_quant=1; if(!s->avctx->lowres) s->loop_filter=1; if(s->avctx->debug & FF_DEBUG_PICT_INFO){ av_log(s->avctx, AV_LOG_INFO, "num:%5d x:%2d y:%2d type:%d qscale:%2d rnd:%d\n", VAR_1, s->mb_x, s->mb_y, s->pict_type, s->qscale, s->no_rounding); } assert(s->pict_type != AV_PICTURE_TYPE_B || !s->low_delay); return s->mb_width*s->mb_height - VAR_2; }
[ "static int FUNC_0(RVDecContext *VAR_0)\n{", "MpegEncContext *s = &VAR_0->m;", "int VAR_1, VAR_2, VAR_3;", "int VAR_4;", "#if 0\nGetBitContext gb= s->gb;", "for(VAR_3=0; VAR_3<64; VAR_3++){", "av_log(s->avctx, AV_LOG_DEBUG, \"%d\", get_bits1(&gb));", "if(VAR_3%4==3) av_log(s->avctx, AV_LOG_DEBUG, \" \");", "}", "av_log(s->avctx, AV_LOG_DEBUG, \"\\n\");", "#endif\n#if 0\nav_log(s->avctx, AV_LOG_DEBUG, \"%3dx%03d/%02Xx%02X \", s->width, s->height, s->width/4, s->height/4);", "for(VAR_3=0; VAR_3<s->avctx->extradata_size; VAR_3++){", "av_log(s->avctx, AV_LOG_DEBUG, \"%02X \", ((uint8_t*)s->avctx->extradata)[VAR_3]);", "if(VAR_3%4==3) av_log(s->avctx, AV_LOG_DEBUG, \" \");", "}", "av_log(s->avctx, AV_LOG_DEBUG, \"\\n\");", "#endif\nVAR_3= get_bits(&s->gb, 2);", "switch(VAR_3){", "case 0: s->pict_type= AV_PICTURE_TYPE_I; break;", "case 1: s->pict_type= AV_PICTURE_TYPE_I; break;", "case 2: s->pict_type= AV_PICTURE_TYPE_P; break;", "case 3: s->pict_type= AV_PICTURE_TYPE_B; break;", "default:\nav_log(s->avctx, AV_LOG_ERROR, \"unknown frame type\\n\");", "return -1;", "}", "if(s->last_picture_ptr==NULL && s->pict_type==AV_PICTURE_TYPE_B){", "av_log(s->avctx, AV_LOG_ERROR, \"early B pix\\n\");", "return -1;", "}", "if (get_bits1(&s->gb)){", "av_log(s->avctx, AV_LOG_ERROR, \"reserved bit set\\n\");", "return -1;", "}", "s->qscale = get_bits(&s->gb, 5);", "if(s->qscale==0){", "av_log(s->avctx, AV_LOG_ERROR, \"error, qscale:0\\n\");", "return -1;", "}", "if(RV_GET_MINOR_VER(VAR_0->sub_id) >= 2)\ns->loop_filter = get_bits1(&s->gb);", "if(RV_GET_MINOR_VER(VAR_0->sub_id) <= 1)\nVAR_1 = get_bits(&s->gb, 8) << 7;", "else\nVAR_1 = get_bits(&s->gb, 13) << 2;", "VAR_4 = s->avctx->extradata[1] & 7;", "if(VAR_4){", "int VAR_5, VAR_6, VAR_7;", "VAR_4 = FFMIN((VAR_4 >> 1) + 1, 3);", "VAR_5 = get_bits(&s->gb, VAR_4);", "if(VAR_5){", "VAR_6= 4*((uint8_t*)s->avctx->extradata)[6+2*VAR_5];", "VAR_7= 4*((uint8_t*)s->avctx->extradata)[7+2*VAR_5];", "}else{", "VAR_6= s->orig_width ;", "VAR_7= s->orig_height;", "}", "if(VAR_6 != s->width || VAR_7 != s->height){", "AVRational old_aspect = s->avctx->sample_aspect_ratio;", "av_log(s->avctx, AV_LOG_DEBUG, \"attempting to change resolution to %dx%d\\n\", VAR_6, VAR_7);", "if (av_image_check_size(VAR_6, VAR_7, 0, s->avctx) < 0)\nreturn -1;", "ff_MPV_common_end(s);", "if (!old_aspect.num)\nold_aspect = (AVRational){1, 1};", "if (2 * VAR_6 * s->height == VAR_7 * s->width)\ns->avctx->sample_aspect_ratio = av_mul_q(old_aspect, (AVRational){2, 1});", "if (VAR_6 * s->height == 2 * VAR_7 * s->width)\ns->avctx->sample_aspect_ratio = av_mul_q(old_aspect, (AVRational){1, 2});", "avcodec_set_dimensions(s->avctx, VAR_6, VAR_7);", "s->width = VAR_6;", "s->height = VAR_7;", "if (ff_MPV_common_init(s) < 0)\nreturn -1;", "}", "if(s->avctx->debug & FF_DEBUG_PICT_INFO){", "av_log(s->avctx, AV_LOG_DEBUG, \"F %d/%d\\n\", VAR_5, VAR_4);", "}", "} else if (av_image_check_size(s->width, s->height, 0, s->avctx) < 0)", "return AVERROR_INVALIDDATA;", "VAR_2 = ff_h263_decode_mba(s);", "VAR_1 |= s->time &~0x7FFF;", "if(VAR_1 - s->time > 0x4000) VAR_1 -= 0x8000;", "if(VAR_1 - s->time < -0x4000) VAR_1 += 0x8000;", "if(VAR_1 != s->time){", "if(s->pict_type!=AV_PICTURE_TYPE_B){", "s->time= VAR_1;", "s->pp_time= s->time - s->last_non_b_time;", "s->last_non_b_time= s->time;", "}else{", "s->time= VAR_1;", "s->pb_time= s->pp_time - (s->last_non_b_time - s->time);", "if(s->pp_time <=s->pb_time || s->pp_time <= s->pp_time - s->pb_time || s->pp_time<=0){", "av_log(s->avctx, AV_LOG_DEBUG, \"messed up order, possible from seeking? skipping current b frame\\n\");", "return FRAME_SKIPPED;", "}", "ff_mpeg4_init_direct_mv(s);", "}", "}", "s->no_rounding= get_bits1(&s->gb);", "if(RV_GET_MINOR_VER(VAR_0->sub_id) <= 1 && s->pict_type == AV_PICTURE_TYPE_B)\nskip_bits(&s->gb, 5);", "s->f_code = 1;", "s->unrestricted_mv = 1;", "s->h263_aic= s->pict_type == AV_PICTURE_TYPE_I;", "s->modified_quant=1;", "if(!s->avctx->lowres)\ns->loop_filter=1;", "if(s->avctx->debug & FF_DEBUG_PICT_INFO){", "av_log(s->avctx, AV_LOG_INFO, \"num:%5d x:%2d y:%2d type:%d qscale:%2d rnd:%d\\n\",\nVAR_1, s->mb_x, s->mb_y, s->pict_type, s->qscale, s->no_rounding);", "}", "assert(s->pict_type != AV_PICTURE_TYPE_B || !s->low_delay);", "return s->mb_width*s->mb_height - VAR_2;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13, 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27, 29, 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59, 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 101, 103 ], [ 107, 109 ], [ 111, 113 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 127 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151, 153 ], [ 155 ], [ 161, 163 ], [ 165, 167 ], [ 169, 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179, 181 ], [ 183 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 199 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 239 ], [ 251 ], [ 255, 257 ], [ 261 ], [ 263 ], [ 265 ], [ 273 ], [ 275, 277 ], [ 281 ], [ 283, 285 ], [ 287 ], [ 291 ], [ 295 ], [ 297 ] ]
9,360
int avpriv_vsnprintf(char *restrict s, size_t n, const char *restrict fmt, va_list ap) { int ret; if (n == 0) return 0; else if (n > INT_MAX) return AVERROR(EINVAL); /* we use n - 1 here because if the buffer is not big enough, the MS * runtime libraries don't add a terminating zero at the end. MSDN * recommends to provide _snprintf/_vsnprintf() a buffer size that * is one less than the actual buffer, and zero it before calling * _snprintf/_vsnprintf() to workaround this problem. * See http://msdn.microsoft.com/en-us/library/1kt27hek(v=vs.80).aspx */ memset(s, 0, n); ret = vsnprintf(s, n - 1, fmt, ap); if (ret == -1) ret = n; return ret; }
false
FFmpeg
2bb62455c899cdccbdc2a6ad33f9582008ed9f05
int avpriv_vsnprintf(char *restrict s, size_t n, const char *restrict fmt, va_list ap) { int ret; if (n == 0) return 0; else if (n > INT_MAX) return AVERROR(EINVAL); memset(s, 0, n); ret = vsnprintf(s, n - 1, fmt, ap); if (ret == -1) ret = n; return ret; }
{ "code": [], "line_no": [] }
int FUNC_0(char *restrict VAR_0, size_t VAR_1, const char *restrict VAR_2, va_list VAR_3) { int VAR_4; if (VAR_1 == 0) return 0; else if (VAR_1 > INT_MAX) return AVERROR(EINVAL); memset(VAR_0, 0, VAR_1); VAR_4 = vsnprintf(VAR_0, VAR_1 - 1, VAR_2, VAR_3); if (VAR_4 == -1) VAR_4 = VAR_1; return VAR_4; }
[ "int FUNC_0(char *restrict VAR_0, size_t VAR_1, const char *restrict VAR_2,\nva_list VAR_3)\n{", "int VAR_4;", "if (VAR_1 == 0)\nreturn 0;", "else if (VAR_1 > INT_MAX)\nreturn AVERROR(EINVAL);", "memset(VAR_0, 0, VAR_1);", "VAR_4 = vsnprintf(VAR_0, VAR_1 - 1, VAR_2, VAR_3);", "if (VAR_4 == -1)\nVAR_4 = VAR_1;", "return VAR_4;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11, 13 ], [ 15, 17 ], [ 33 ], [ 35 ], [ 37, 39 ], [ 43 ], [ 45 ] ]
9,361
static int qdm2_get_vlc (GetBitContext *gb, VLC *vlc, int flag, int depth) { int value; value = get_vlc2(gb, vlc->table, vlc->bits, depth); /* stage-2, 3 bits exponent escape sequence */ if (value-- == 0) value = get_bits (gb, get_bits (gb, 3) + 1); /* stage-3, optional */ if (flag) { int tmp = vlc_stage3_values[value]; if ((value & ~3) > 0) tmp += get_bits (gb, (value >> 2)); value = tmp; } return value; }
false
FFmpeg
1a974679d097e878401cc1a425c3ed612be1581e
static int qdm2_get_vlc (GetBitContext *gb, VLC *vlc, int flag, int depth) { int value; value = get_vlc2(gb, vlc->table, vlc->bits, depth); if (value-- == 0) value = get_bits (gb, get_bits (gb, 3) + 1); if (flag) { int tmp = vlc_stage3_values[value]; if ((value & ~3) > 0) tmp += get_bits (gb, (value >> 2)); value = tmp; } return value; }
{ "code": [], "line_no": [] }
static int FUNC_0 (GetBitContext *VAR_0, VLC *VAR_1, int VAR_2, int VAR_3) { int VAR_4; VAR_4 = get_vlc2(VAR_0, VAR_1->table, VAR_1->bits, VAR_3); if (VAR_4-- == 0) VAR_4 = get_bits (VAR_0, get_bits (VAR_0, 3) + 1); if (VAR_2) { int VAR_5 = vlc_stage3_values[VAR_4]; if ((VAR_4 & ~3) > 0) VAR_5 += get_bits (VAR_0, (VAR_4 >> 2)); VAR_4 = VAR_5; } return VAR_4; }
[ "static int FUNC_0 (GetBitContext *VAR_0, VLC *VAR_1, int VAR_2, int VAR_3)\n{", "int VAR_4;", "VAR_4 = get_vlc2(VAR_0, VAR_1->table, VAR_1->bits, VAR_3);", "if (VAR_4-- == 0)\nVAR_4 = get_bits (VAR_0, get_bits (VAR_0, 3) + 1);", "if (VAR_2) {", "int VAR_5 = vlc_stage3_values[VAR_4];", "if ((VAR_4 & ~3) > 0)\nVAR_5 += get_bits (VAR_0, (VAR_4 >> 2));", "VAR_4 = VAR_5;", "}", "return VAR_4;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 15, 17 ], [ 23 ], [ 25 ], [ 29, 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ] ]
9,362
static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap) { MOVContext *mov = (MOVContext *) s->priv_data; ByteIOContext *pb = &s->pb; int i, err; MOV_atom_t atom = { 0, 0, 0 }; mov->fc = s; mov->parse_table = mov_default_parse_table; if(!url_is_streamed(pb)) /* .mov and .mp4 aren't streamable anyway (only progressive download if moov is before mdat) */ atom.size = url_fsize(pb); else atom.size = 0x7FFFFFFFFFFFFFFFLL; /* check MOV header */ err = mov_read_default(mov, pb, atom); if (err<0 || (!mov->found_moov && !mov->found_mdat)) { av_log(s, AV_LOG_ERROR, "mov: header not found !!! (err:%d, moov:%d, mdat:%d) pos:%"PRId64"\n", err, mov->found_moov, mov->found_mdat, url_ftell(pb)); return -1; } dprintf("on_parse_exit_offset=%d\n", (int) url_ftell(pb)); /* some cleanup : make sure we are on the mdat atom */ if(!url_is_streamed(pb) && (url_ftell(pb) != mov->mdat_offset)) url_fseek(pb, mov->mdat_offset, SEEK_SET); mov->total_streams = s->nb_streams; for(i=0; i<mov->total_streams; i++) { MOVStreamContext *sc = mov->streams[i]; if(!sc->time_rate) sc->time_rate=1; if(!sc->time_scale) sc->time_scale= mov->time_scale; av_set_pts_info(s->streams[i], 64, sc->time_rate, sc->time_scale); if(s->streams[i]->duration != AV_NOPTS_VALUE){ assert(s->streams[i]->duration % sc->time_rate == 0); s->streams[i]->duration /= sc->time_rate; } sc->ffindex = i; mov_build_index(mov, s->streams[i]); } for(i=0; i<mov->total_streams; i++) { /* dont need those anymore */ av_freep(&mov->streams[i]->chunk_offsets); av_freep(&mov->streams[i]->sample_to_chunk); av_freep(&mov->streams[i]->sample_sizes); av_freep(&mov->streams[i]->keyframes); av_freep(&mov->streams[i]->stts_data); } av_freep(&mov->mdat_list); return 0; }
true
FFmpeg
dfcf8d57c59428ba1a9f5a65c4c75d2f84661cf5
static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap) { MOVContext *mov = (MOVContext *) s->priv_data; ByteIOContext *pb = &s->pb; int i, err; MOV_atom_t atom = { 0, 0, 0 }; mov->fc = s; mov->parse_table = mov_default_parse_table; if(!url_is_streamed(pb)) atom.size = url_fsize(pb); else atom.size = 0x7FFFFFFFFFFFFFFFLL; err = mov_read_default(mov, pb, atom); if (err<0 || (!mov->found_moov && !mov->found_mdat)) { av_log(s, AV_LOG_ERROR, "mov: header not found !!! (err:%d, moov:%d, mdat:%d) pos:%"PRId64"\n", err, mov->found_moov, mov->found_mdat, url_ftell(pb)); return -1; } dprintf("on_parse_exit_offset=%d\n", (int) url_ftell(pb)); if(!url_is_streamed(pb) && (url_ftell(pb) != mov->mdat_offset)) url_fseek(pb, mov->mdat_offset, SEEK_SET); mov->total_streams = s->nb_streams; for(i=0; i<mov->total_streams; i++) { MOVStreamContext *sc = mov->streams[i]; if(!sc->time_rate) sc->time_rate=1; if(!sc->time_scale) sc->time_scale= mov->time_scale; av_set_pts_info(s->streams[i], 64, sc->time_rate, sc->time_scale); if(s->streams[i]->duration != AV_NOPTS_VALUE){ assert(s->streams[i]->duration % sc->time_rate == 0); s->streams[i]->duration /= sc->time_rate; } sc->ffindex = i; mov_build_index(mov, s->streams[i]); } for(i=0; i<mov->total_streams; i++) { av_freep(&mov->streams[i]->chunk_offsets); av_freep(&mov->streams[i]->sample_to_chunk); av_freep(&mov->streams[i]->sample_sizes); av_freep(&mov->streams[i]->keyframes); av_freep(&mov->streams[i]->stts_data); } av_freep(&mov->mdat_list); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0, AVFormatParameters *VAR_1) { MOVContext *mov = (MOVContext *) VAR_0->priv_data; ByteIOContext *pb = &VAR_0->pb; int VAR_2, VAR_3; MOV_atom_t atom = { 0, 0, 0 }; mov->fc = VAR_0; mov->parse_table = mov_default_parse_table; if(!url_is_streamed(pb)) atom.size = url_fsize(pb); else atom.size = 0x7FFFFFFFFFFFFFFFLL; VAR_3 = mov_read_default(mov, pb, atom); if (VAR_3<0 || (!mov->found_moov && !mov->found_mdat)) { av_log(VAR_0, AV_LOG_ERROR, "mov: header not found !!! (VAR_3:%d, moov:%d, mdat:%d) pos:%"PRId64"\n", VAR_3, mov->found_moov, mov->found_mdat, url_ftell(pb)); return -1; } dprintf("on_parse_exit_offset=%d\n", (int) url_ftell(pb)); if(!url_is_streamed(pb) && (url_ftell(pb) != mov->mdat_offset)) url_fseek(pb, mov->mdat_offset, SEEK_SET); mov->total_streams = VAR_0->nb_streams; for(VAR_2=0; VAR_2<mov->total_streams; VAR_2++) { MOVStreamContext *sc = mov->streams[VAR_2]; if(!sc->time_rate) sc->time_rate=1; if(!sc->time_scale) sc->time_scale= mov->time_scale; av_set_pts_info(VAR_0->streams[VAR_2], 64, sc->time_rate, sc->time_scale); if(VAR_0->streams[VAR_2]->duration != AV_NOPTS_VALUE){ assert(VAR_0->streams[VAR_2]->duration % sc->time_rate == 0); VAR_0->streams[VAR_2]->duration /= sc->time_rate; } sc->ffindex = VAR_2; mov_build_index(mov, VAR_0->streams[VAR_2]); } for(VAR_2=0; VAR_2<mov->total_streams; VAR_2++) { av_freep(&mov->streams[VAR_2]->chunk_offsets); av_freep(&mov->streams[VAR_2]->sample_to_chunk); av_freep(&mov->streams[VAR_2]->sample_sizes); av_freep(&mov->streams[VAR_2]->keyframes); av_freep(&mov->streams[VAR_2]->stts_data); } av_freep(&mov->mdat_list); return 0; }
[ "static int FUNC_0(AVFormatContext *VAR_0, AVFormatParameters *VAR_1)\n{", "MOVContext *mov = (MOVContext *) VAR_0->priv_data;", "ByteIOContext *pb = &VAR_0->pb;", "int VAR_2, VAR_3;", "MOV_atom_t atom = { 0, 0, 0 };", "mov->fc = VAR_0;", "mov->parse_table = mov_default_parse_table;", "if(!url_is_streamed(pb))\natom.size = url_fsize(pb);", "else\natom.size = 0x7FFFFFFFFFFFFFFFLL;", "VAR_3 = mov_read_default(mov, pb, atom);", "if (VAR_3<0 || (!mov->found_moov && !mov->found_mdat)) {", "av_log(VAR_0, AV_LOG_ERROR, \"mov: header not found !!! (VAR_3:%d, moov:%d, mdat:%d) pos:%\"PRId64\"\\n\",\nVAR_3, mov->found_moov, mov->found_mdat, url_ftell(pb));", "return -1;", "}", "dprintf(\"on_parse_exit_offset=%d\\n\", (int) url_ftell(pb));", "if(!url_is_streamed(pb) && (url_ftell(pb) != mov->mdat_offset))\nurl_fseek(pb, mov->mdat_offset, SEEK_SET);", "mov->total_streams = VAR_0->nb_streams;", "for(VAR_2=0; VAR_2<mov->total_streams; VAR_2++) {", "MOVStreamContext *sc = mov->streams[VAR_2];", "if(!sc->time_rate)\nsc->time_rate=1;", "if(!sc->time_scale)\nsc->time_scale= mov->time_scale;", "av_set_pts_info(VAR_0->streams[VAR_2], 64, sc->time_rate, sc->time_scale);", "if(VAR_0->streams[VAR_2]->duration != AV_NOPTS_VALUE){", "assert(VAR_0->streams[VAR_2]->duration % sc->time_rate == 0);", "VAR_0->streams[VAR_2]->duration /= sc->time_rate;", "}", "sc->ffindex = VAR_2;", "mov_build_index(mov, VAR_0->streams[VAR_2]);", "}", "for(VAR_2=0; VAR_2<mov->total_streams; VAR_2++) {", "av_freep(&mov->streams[VAR_2]->chunk_offsets);", "av_freep(&mov->streams[VAR_2]->sample_to_chunk);", "av_freep(&mov->streams[VAR_2]->sample_sizes);", "av_freep(&mov->streams[VAR_2]->keyframes);", "av_freep(&mov->streams[VAR_2]->stts_data);", "}", "av_freep(&mov->mdat_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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 21, 23 ], [ 25, 27 ], [ 33 ], [ 35 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 51, 53 ], [ 57 ], [ 61 ], [ 63 ], [ 67, 69 ], [ 71, 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 95 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ] ]
9,363
static void s390_ipl_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); k->init = s390_ipl_init; dc->props = s390_ipl_properties; dc->reset = s390_ipl_reset; dc->no_user = 1; }
true
qemu
efec3dd631d94160288392721a5f9c39e50fb2bc
static void s390_ipl_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); k->init = s390_ipl_init; dc->props = s390_ipl_properties; dc->reset = s390_ipl_reset; dc->no_user = 1; }
{ "code": [ " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;", " dc->no_user = 1;" ], "line_no": [ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17 ] }
static void FUNC_0(ObjectClass *VAR_0, void *VAR_1) { DeviceClass *dc = DEVICE_CLASS(VAR_0); SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(VAR_0); k->init = s390_ipl_init; dc->props = s390_ipl_properties; dc->reset = s390_ipl_reset; dc->no_user = 1; }
[ "static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{", "DeviceClass *dc = DEVICE_CLASS(VAR_0);", "SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(VAR_0);", "k->init = s390_ipl_init;", "dc->props = s390_ipl_properties;", "dc->reset = s390_ipl_reset;", "dc->no_user = 1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
9,364
static char *doubles2str(double *dp, int count, const char *sep) { int i; char *ap, *ap0; int component_len; if (!sep) sep = ", "; component_len = 15 + strlen(sep); ap = av_malloc(component_len * count); if (!ap) return NULL; ap0 = ap; ap[0] = '\0'; for (i = 0; i < count; i++) { unsigned l = snprintf(ap, component_len, "%f%s", dp[i], sep); if(l >= component_len) { av_free(ap0); return NULL; } ap += l; } ap0[strlen(ap0) - strlen(sep)] = '\0'; return ap0; }
false
FFmpeg
e1219cdaf9fb4bc8cea410e1caf802373c1bfe51
static char *doubles2str(double *dp, int count, const char *sep) { int i; char *ap, *ap0; int component_len; if (!sep) sep = ", "; component_len = 15 + strlen(sep); ap = av_malloc(component_len * count); if (!ap) return NULL; ap0 = ap; ap[0] = '\0'; for (i = 0; i < count; i++) { unsigned l = snprintf(ap, component_len, "%f%s", dp[i], sep); if(l >= component_len) { av_free(ap0); return NULL; } ap += l; } ap0[strlen(ap0) - strlen(sep)] = '\0'; return ap0; }
{ "code": [], "line_no": [] }
static char *FUNC_0(double *VAR_0, int VAR_1, const char *VAR_2) { int VAR_3; char *VAR_4, *VAR_5; int VAR_6; if (!VAR_2) VAR_2 = ", "; VAR_6 = 15 + strlen(VAR_2); VAR_4 = av_malloc(VAR_6 * VAR_1); if (!VAR_4) return NULL; VAR_5 = VAR_4; VAR_4[0] = '\0'; for (VAR_3 = 0; VAR_3 < VAR_1; VAR_3++) { unsigned VAR_7 = snprintf(VAR_4, VAR_6, "%f%s", VAR_0[VAR_3], VAR_2); if(VAR_7 >= VAR_6) { av_free(VAR_5); return NULL; } VAR_4 += VAR_7; } VAR_5[strlen(VAR_5) - strlen(VAR_2)] = '\0'; return VAR_5; }
[ "static char *FUNC_0(double *VAR_0, int VAR_1, const char *VAR_2)\n{", "int VAR_3;", "char *VAR_4, *VAR_5;", "int VAR_6;", "if (!VAR_2) VAR_2 = \", \";", "VAR_6 = 15 + strlen(VAR_2);", "VAR_4 = av_malloc(VAR_6 * VAR_1);", "if (!VAR_4)\nreturn NULL;", "VAR_5 = VAR_4;", "VAR_4[0] = '\\0';", "for (VAR_3 = 0; VAR_3 < VAR_1; VAR_3++) {", "unsigned VAR_7 = snprintf(VAR_4, VAR_6, \"%f%s\", VAR_0[VAR_3], VAR_2);", "if(VAR_7 >= VAR_6) {", "av_free(VAR_5);", "return NULL;", "}", "VAR_4 += VAR_7;", "}", "VAR_5[strlen(VAR_5) - strlen(VAR_2)] = '\\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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17, 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ] ]
9,365
static int vhost_user_get_vring_base(struct vhost_dev *dev, struct vhost_vring_state *ring) { VhostUserMsg msg = { .request = VHOST_USER_GET_VRING_BASE, .flags = VHOST_USER_VERSION, .state = *ring, .size = sizeof(*ring), }; vhost_user_write(dev, &msg, NULL, 0); if (vhost_user_read(dev, &msg) < 0) { return 0; } if (msg.request != VHOST_USER_GET_VRING_BASE) { error_report("Received unexpected msg type. Expected %d received %d", VHOST_USER_GET_VRING_BASE, msg.request); return -1; } if (msg.size != sizeof(m.state)) { error_report("Received bad msg size."); return -1; } *ring = msg.state; return 0; }
true
qemu
7f4a930e64b9e69cd340395a7e4f0494aef4fcdd
static int vhost_user_get_vring_base(struct vhost_dev *dev, struct vhost_vring_state *ring) { VhostUserMsg msg = { .request = VHOST_USER_GET_VRING_BASE, .flags = VHOST_USER_VERSION, .state = *ring, .size = sizeof(*ring), }; vhost_user_write(dev, &msg, NULL, 0); if (vhost_user_read(dev, &msg) < 0) { return 0; } if (msg.request != VHOST_USER_GET_VRING_BASE) { error_report("Received unexpected msg type. Expected %d received %d", VHOST_USER_GET_VRING_BASE, msg.request); return -1; } if (msg.size != sizeof(m.state)) { error_report("Received bad msg size."); return -1; } *ring = msg.state; return 0; }
{ "code": [ " };", " .state = *ring,", " .state = *ring,", " if (msg.size != sizeof(m.state)) {", " *ring = msg.state;" ], "line_no": [ 17, 13, 13, 45, 55 ] }
static int FUNC_0(struct vhost_dev *VAR_0, struct vhost_vring_state *VAR_1) { VhostUserMsg msg = { .request = VHOST_USER_GET_VRING_BASE, .flags = VHOST_USER_VERSION, .state = *VAR_1, .size = sizeof(*VAR_1), }; vhost_user_write(VAR_0, &msg, NULL, 0); if (vhost_user_read(VAR_0, &msg) < 0) { return 0; } if (msg.request != VHOST_USER_GET_VRING_BASE) { error_report("Received unexpected msg type. Expected %d received %d", VHOST_USER_GET_VRING_BASE, msg.request); return -1; } if (msg.size != sizeof(m.state)) { error_report("Received bad msg size."); return -1; } *VAR_1 = msg.state; return 0; }
[ "static int FUNC_0(struct vhost_dev *VAR_0,\nstruct vhost_vring_state *VAR_1)\n{", "VhostUserMsg msg = {", ".request = VHOST_USER_GET_VRING_BASE,\n.flags = VHOST_USER_VERSION,\n.state = *VAR_1,\n.size = sizeof(*VAR_1),\n};", "vhost_user_write(VAR_0, &msg, NULL, 0);", "if (vhost_user_read(VAR_0, &msg) < 0) {", "return 0;", "}", "if (msg.request != VHOST_USER_GET_VRING_BASE) {", "error_report(\"Received unexpected msg type. Expected %d received %d\",\nVHOST_USER_GET_VRING_BASE, msg.request);", "return -1;", "}", "if (msg.size != sizeof(m.state)) {", "error_report(\"Received bad msg size.\");", "return -1;", "}", "*VAR_1 = msg.state;", "return 0;", "}" ]
[ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9, 11, 13, 15, 17 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35, 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 59 ], [ 61 ] ]
9,367
static void multipath_pr_init(void) { static struct udev *udev; udev = udev_new(); mpath_lib_init(udev); }
true
qemu
b3f1c8c413bc83e4a2cc7a63e4eddf9fe6449052
static void multipath_pr_init(void) { static struct udev *udev; udev = udev_new(); mpath_lib_init(udev); }
{ "code": [ " mpath_lib_init(udev);", "static void multipath_pr_init(void)", " static struct udev *udev;", " mpath_lib_init(udev);" ], "line_no": [ 11, 1, 5, 11 ] }
static void FUNC_0(void) { static struct VAR_0 *VAR_0; VAR_0 = udev_new(); mpath_lib_init(VAR_0); }
[ "static void FUNC_0(void)\n{", "static struct VAR_0 *VAR_0;", "VAR_0 = udev_new();", "mpath_lib_init(VAR_0);", "}" ]
[ 1, 1, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ] ]
9,368
static int dot_product(const int16_t *a, const int16_t *b, int length) { int i, sum = 0; for (i = 0; i < length; i++) { int64_t prod = av_clipl_int32(MUL64(a[i], b[i]) << 1); sum = av_clipl_int32(sum + prod); } return sum; }
true
FFmpeg
1eb1f6f281eb6036d363e0317c1500be4a2708f2
static int dot_product(const int16_t *a, const int16_t *b, int length) { int i, sum = 0; for (i = 0; i < length; i++) { int64_t prod = av_clipl_int32(MUL64(a[i], b[i]) << 1); sum = av_clipl_int32(sum + prod); } return sum; }
{ "code": [ " int64_t prod = av_clipl_int32(MUL64(a[i], b[i]) << 1);" ], "line_no": [ 11 ] }
static int FUNC_0(const int16_t *VAR_0, const int16_t *VAR_1, int VAR_2) { int VAR_3, VAR_4 = 0; for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) { int64_t prod = av_clipl_int32(MUL64(VAR_0[VAR_3], VAR_1[VAR_3]) << 1); VAR_4 = av_clipl_int32(VAR_4 + prod); } return VAR_4; }
[ "static int FUNC_0(const int16_t *VAR_0, const int16_t *VAR_1, int VAR_2)\n{", "int VAR_3, VAR_4 = 0;", "for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) {", "int64_t prod = av_clipl_int32(MUL64(VAR_0[VAR_3], VAR_1[VAR_3]) << 1);", "VAR_4 = av_clipl_int32(VAR_4 + prod);", "}", "return VAR_4;", "}" ]
[ 0, 0, 0, 1, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
9,369
static int console_init(SCLPEvent *event) { static bool console_available; SCLPConsole *scon = DO_UPCAST(SCLPConsole, event, event); if (console_available) { error_report("Multiple VT220 operator consoles are not supported"); return -1; } console_available = true; if (scon->chr) { qemu_chr_add_handlers(scon->chr, chr_can_read, chr_read, NULL, scon); } scon->irq_read_vt220 = *qemu_allocate_irqs(trigger_ascii_console_data, NULL, 1); return 0; }
true
qemu
b074e6220542107afb9fad480a184775be591d2a
static int console_init(SCLPEvent *event) { static bool console_available; SCLPConsole *scon = DO_UPCAST(SCLPConsole, event, event); if (console_available) { error_report("Multiple VT220 operator consoles are not supported"); return -1; } console_available = true; if (scon->chr) { qemu_chr_add_handlers(scon->chr, chr_can_read, chr_read, NULL, scon); } scon->irq_read_vt220 = *qemu_allocate_irqs(trigger_ascii_console_data, NULL, 1); return 0; }
{ "code": [ " scon->irq_read_vt220 = *qemu_allocate_irqs(trigger_ascii_console_data,", " NULL, 1);" ], "line_no": [ 31, 33 ] }
static int FUNC_0(SCLPEvent *VAR_0) { static bool VAR_1; SCLPConsole *scon = DO_UPCAST(SCLPConsole, VAR_0, VAR_0); if (VAR_1) { error_report("Multiple VT220 operator consoles are not supported"); return -1; } VAR_1 = true; if (scon->chr) { qemu_chr_add_handlers(scon->chr, chr_can_read, chr_read, NULL, scon); } scon->irq_read_vt220 = *qemu_allocate_irqs(trigger_ascii_console_data, NULL, 1); return 0; }
[ "static int FUNC_0(SCLPEvent *VAR_0)\n{", "static bool VAR_1;", "SCLPConsole *scon = DO_UPCAST(SCLPConsole, VAR_0, VAR_0);", "if (VAR_1) {", "error_report(\"Multiple VT220 operator consoles are not supported\");", "return -1;", "}", "VAR_1 = true;", "if (scon->chr) {", "qemu_chr_add_handlers(scon->chr, chr_can_read,\nchr_read, NULL, scon);", "}", "scon->irq_read_vt220 = *qemu_allocate_irqs(trigger_ascii_console_data,\nNULL, 1);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 29 ], [ 31, 33 ], [ 37 ], [ 39 ] ]
9,370
static int vnc_worker_thread_loop(VncJobQueue *queue) { VncJob *job; VncRectEntry *entry, *tmp; VncState vs; int n_rectangles; int saved_offset; vnc_lock_queue(queue); while (QTAILQ_EMPTY(&queue->jobs) && !queue->exit) { qemu_cond_wait(&queue->cond, &queue->mutex); } /* Here job can only be NULL if queue->exit is true */ job = QTAILQ_FIRST(&queue->jobs); vnc_unlock_queue(queue); if (queue->exit) { return -1; } vnc_lock_output(job->vs); if (job->vs->csock == -1 || job->vs->abort == true) { vnc_unlock_output(job->vs); goto disconnected; } vnc_unlock_output(job->vs); /* Make a local copy of vs and switch output buffers */ vnc_async_encoding_start(job->vs, &vs); /* Start sending rectangles */ n_rectangles = 0; vnc_write_u8(&vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE); vnc_write_u8(&vs, 0); saved_offset = vs.output.offset; vnc_write_u16(&vs, 0); vnc_lock_display(job->vs->vd); QLIST_FOREACH_SAFE(entry, &job->rectangles, next, tmp) { int n; if (job->vs->csock == -1) { vnc_unlock_display(job->vs->vd); goto disconnected; } n = vnc_send_framebuffer_update(&vs, entry->rect.x, entry->rect.y, entry->rect.w, entry->rect.h); if (n >= 0) { n_rectangles += n; } g_free(entry); } vnc_unlock_display(job->vs->vd); /* Put n_rectangles at the beginning of the message */ vs.output.buffer[saved_offset] = (n_rectangles >> 8) & 0xFF; vs.output.buffer[saved_offset + 1] = n_rectangles & 0xFF; vnc_lock_output(job->vs); if (job->vs->csock != -1) { buffer_reserve(&job->vs->jobs_buffer, vs.output.offset); buffer_append(&job->vs->jobs_buffer, vs.output.buffer, vs.output.offset); qemu_bh_schedule(job->vs->bh); } else { } vnc_unlock_output(job->vs); disconnected: vnc_lock_queue(queue); QTAILQ_REMOVE(&queue->jobs, job, next); vnc_unlock_queue(queue); qemu_cond_broadcast(&queue->cond); g_free(job); return 0; }
true
qemu
e3c1adf16e38714ebd761dd02517dd07760ba6d2
static int vnc_worker_thread_loop(VncJobQueue *queue) { VncJob *job; VncRectEntry *entry, *tmp; VncState vs; int n_rectangles; int saved_offset; vnc_lock_queue(queue); while (QTAILQ_EMPTY(&queue->jobs) && !queue->exit) { qemu_cond_wait(&queue->cond, &queue->mutex); } job = QTAILQ_FIRST(&queue->jobs); vnc_unlock_queue(queue); if (queue->exit) { return -1; } vnc_lock_output(job->vs); if (job->vs->csock == -1 || job->vs->abort == true) { vnc_unlock_output(job->vs); goto disconnected; } vnc_unlock_output(job->vs); vnc_async_encoding_start(job->vs, &vs); n_rectangles = 0; vnc_write_u8(&vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE); vnc_write_u8(&vs, 0); saved_offset = vs.output.offset; vnc_write_u16(&vs, 0); vnc_lock_display(job->vs->vd); QLIST_FOREACH_SAFE(entry, &job->rectangles, next, tmp) { int n; if (job->vs->csock == -1) { vnc_unlock_display(job->vs->vd); goto disconnected; } n = vnc_send_framebuffer_update(&vs, entry->rect.x, entry->rect.y, entry->rect.w, entry->rect.h); if (n >= 0) { n_rectangles += n; } g_free(entry); } vnc_unlock_display(job->vs->vd); vs.output.buffer[saved_offset] = (n_rectangles >> 8) & 0xFF; vs.output.buffer[saved_offset + 1] = n_rectangles & 0xFF; vnc_lock_output(job->vs); if (job->vs->csock != -1) { buffer_reserve(&job->vs->jobs_buffer, vs.output.offset); buffer_append(&job->vs->jobs_buffer, vs.output.buffer, vs.output.offset); qemu_bh_schedule(job->vs->bh); } else { } vnc_unlock_output(job->vs); disconnected: vnc_lock_queue(queue); QTAILQ_REMOVE(&queue->jobs, job, next); vnc_unlock_queue(queue); qemu_cond_broadcast(&queue->cond); g_free(job); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(VncJobQueue *VAR_0) { VncJob *job; VncRectEntry *entry, *tmp; VncState vs; int VAR_1; int VAR_2; vnc_lock_queue(VAR_0); while (QTAILQ_EMPTY(&VAR_0->jobs) && !VAR_0->exit) { qemu_cond_wait(&VAR_0->cond, &VAR_0->mutex); } job = QTAILQ_FIRST(&VAR_0->jobs); vnc_unlock_queue(VAR_0); if (VAR_0->exit) { return -1; } vnc_lock_output(job->vs); if (job->vs->csock == -1 || job->vs->abort == true) { vnc_unlock_output(job->vs); goto disconnected; } vnc_unlock_output(job->vs); vnc_async_encoding_start(job->vs, &vs); VAR_1 = 0; vnc_write_u8(&vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE); vnc_write_u8(&vs, 0); VAR_2 = vs.output.offset; vnc_write_u16(&vs, 0); vnc_lock_display(job->vs->vd); QLIST_FOREACH_SAFE(entry, &job->rectangles, next, tmp) { int n; if (job->vs->csock == -1) { vnc_unlock_display(job->vs->vd); goto disconnected; } n = vnc_send_framebuffer_update(&vs, entry->rect.x, entry->rect.y, entry->rect.w, entry->rect.h); if (n >= 0) { VAR_1 += n; } g_free(entry); } vnc_unlock_display(job->vs->vd); vs.output.buffer[VAR_2] = (VAR_1 >> 8) & 0xFF; vs.output.buffer[VAR_2 + 1] = VAR_1 & 0xFF; vnc_lock_output(job->vs); if (job->vs->csock != -1) { buffer_reserve(&job->vs->jobs_buffer, vs.output.offset); buffer_append(&job->vs->jobs_buffer, vs.output.buffer, vs.output.offset); qemu_bh_schedule(job->vs->bh); } else { } vnc_unlock_output(job->vs); disconnected: vnc_lock_queue(VAR_0); QTAILQ_REMOVE(&VAR_0->jobs, job, next); vnc_unlock_queue(VAR_0); qemu_cond_broadcast(&VAR_0->cond); g_free(job); return 0; }
[ "static int FUNC_0(VncJobQueue *VAR_0)\n{", "VncJob *job;", "VncRectEntry *entry, *tmp;", "VncState vs;", "int VAR_1;", "int VAR_2;", "vnc_lock_queue(VAR_0);", "while (QTAILQ_EMPTY(&VAR_0->jobs) && !VAR_0->exit) {", "qemu_cond_wait(&VAR_0->cond, &VAR_0->mutex);", "}", "job = QTAILQ_FIRST(&VAR_0->jobs);", "vnc_unlock_queue(VAR_0);", "if (VAR_0->exit) {", "return -1;", "}", "vnc_lock_output(job->vs);", "if (job->vs->csock == -1 || job->vs->abort == true) {", "vnc_unlock_output(job->vs);", "goto disconnected;", "}", "vnc_unlock_output(job->vs);", "vnc_async_encoding_start(job->vs, &vs);", "VAR_1 = 0;", "vnc_write_u8(&vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);", "vnc_write_u8(&vs, 0);", "VAR_2 = vs.output.offset;", "vnc_write_u16(&vs, 0);", "vnc_lock_display(job->vs->vd);", "QLIST_FOREACH_SAFE(entry, &job->rectangles, next, tmp) {", "int n;", "if (job->vs->csock == -1) {", "vnc_unlock_display(job->vs->vd);", "goto disconnected;", "}", "n = vnc_send_framebuffer_update(&vs, entry->rect.x, entry->rect.y,\nentry->rect.w, entry->rect.h);", "if (n >= 0) {", "VAR_1 += n;", "}", "g_free(entry);", "}", "vnc_unlock_display(job->vs->vd);", "vs.output.buffer[VAR_2] = (VAR_1 >> 8) & 0xFF;", "vs.output.buffer[VAR_2 + 1] = VAR_1 & 0xFF;", "vnc_lock_output(job->vs);", "if (job->vs->csock != -1) {", "buffer_reserve(&job->vs->jobs_buffer, vs.output.offset);", "buffer_append(&job->vs->jobs_buffer, vs.output.buffer,\nvs.output.offset);", "qemu_bh_schedule(job->vs->bh);", "} else {", "}", "vnc_unlock_output(job->vs);", "disconnected:\nvnc_lock_queue(VAR_0);", "QTAILQ_REMOVE(&VAR_0->jobs, job, next);", "vnc_unlock_queue(VAR_0);", "qemu_cond_broadcast(&VAR_0->cond);", "g_free(job);", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 57 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 79 ], [ 83 ], [ 85 ], [ 89 ], [ 91 ], [ 95, 97 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 117 ], [ 119 ], [ 123 ], [ 125 ], [ 127 ], [ 129, 131 ], [ 137 ], [ 139 ], [ 143 ], [ 145 ], [ 149, 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ] ]
9,371
AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_frame(const AVFrame *frame, int perms) { AVFilterBufferRef *samplesref = avfilter_get_audio_buffer_ref_from_arrays((uint8_t **)frame->data, frame->linesize[0], perms, frame->nb_samples, frame->format, av_frame_get_channel_layout(frame)); if (!samplesref) return NULL; avfilter_copy_frame_props(samplesref, frame); return samplesref; }
false
FFmpeg
a150bad4062a29fc11b32117bc1ade38115cd95b
AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_frame(const AVFrame *frame, int perms) { AVFilterBufferRef *samplesref = avfilter_get_audio_buffer_ref_from_arrays((uint8_t **)frame->data, frame->linesize[0], perms, frame->nb_samples, frame->format, av_frame_get_channel_layout(frame)); if (!samplesref) return NULL; avfilter_copy_frame_props(samplesref, frame); return samplesref; }
{ "code": [], "line_no": [] }
AVFilterBufferRef *FUNC_0(const AVFrame *frame, int perms) { AVFilterBufferRef *samplesref = avfilter_get_audio_buffer_ref_from_arrays((uint8_t **)frame->data, frame->linesize[0], perms, frame->nb_samples, frame->format, av_frame_get_channel_layout(frame)); if (!samplesref) return NULL; avfilter_copy_frame_props(samplesref, frame); return samplesref; }
[ "AVFilterBufferRef *FUNC_0(const AVFrame *frame,\nint perms)\n{", "AVFilterBufferRef *samplesref =\navfilter_get_audio_buffer_ref_from_arrays((uint8_t **)frame->data, frame->linesize[0], perms,\nframe->nb_samples, frame->format,\nav_frame_get_channel_layout(frame));", "if (!samplesref)\nreturn NULL;", "avfilter_copy_frame_props(samplesref, frame);", "return samplesref;", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7, 9, 11, 13 ], [ 15, 17 ], [ 19 ], [ 21 ], [ 23 ] ]
9,372
static void input_linux_complete(UserCreatable *uc, Error **errp) { InputLinux *il = INPUT_LINUX(uc); uint8_t evtmap, relmap, absmap, keymap[KEY_CNT / 8]; unsigned int i; int rc, ver; if (!il->evdev) { error_setg(errp, "no input device specified"); return; } il->fd = open(il->evdev, O_RDWR); if (il->fd < 0) { error_setg_file_open(errp, errno, il->evdev); return; } qemu_set_nonblock(il->fd); rc = ioctl(il->fd, EVIOCGVERSION, &ver); if (rc < 0) { error_setg(errp, "%s: is not an evdev device", il->evdev); goto err_close; } rc = ioctl(il->fd, EVIOCGBIT(0, sizeof(evtmap)), &evtmap); if (rc < 0) { error_setg(errp, "%s: failed to read event bits", il->evdev); goto err_close; } if (evtmap & (1 << EV_REL)) { relmap = 0; rc = ioctl(il->fd, EVIOCGBIT(EV_REL, sizeof(relmap)), &relmap); if (relmap & (1 << REL_X)) { il->has_rel_x = true; } } if (evtmap & (1 << EV_ABS)) { absmap = 0; rc = ioctl(il->fd, EVIOCGBIT(EV_ABS, sizeof(absmap)), &absmap); if (absmap & (1 << ABS_X)) { il->has_abs_x = true; } } if (evtmap & (1 << EV_KEY)) { memset(keymap, 0, sizeof(keymap)); rc = ioctl(il->fd, EVIOCGBIT(EV_KEY, sizeof(keymap)), keymap); for (i = 0; i < KEY_CNT; i++) { if (keymap[i / 8] & (1 << (i % 8))) { if (linux_is_button(i)) { il->num_btns++; } else { il->num_keys++; } } } } qemu_set_fd_handler(il->fd, input_linux_event, NULL, il); input_linux_toggle_grab(il); QTAILQ_INSERT_TAIL(&inputs, il, next); il->initialized = true; return; err_close: close(il->fd); return; }
false
qemu
2a57c55f26f7ba6dcea6d01ef74bae7069150f6f
static void input_linux_complete(UserCreatable *uc, Error **errp) { InputLinux *il = INPUT_LINUX(uc); uint8_t evtmap, relmap, absmap, keymap[KEY_CNT / 8]; unsigned int i; int rc, ver; if (!il->evdev) { error_setg(errp, "no input device specified"); return; } il->fd = open(il->evdev, O_RDWR); if (il->fd < 0) { error_setg_file_open(errp, errno, il->evdev); return; } qemu_set_nonblock(il->fd); rc = ioctl(il->fd, EVIOCGVERSION, &ver); if (rc < 0) { error_setg(errp, "%s: is not an evdev device", il->evdev); goto err_close; } rc = ioctl(il->fd, EVIOCGBIT(0, sizeof(evtmap)), &evtmap); if (rc < 0) { error_setg(errp, "%s: failed to read event bits", il->evdev); goto err_close; } if (evtmap & (1 << EV_REL)) { relmap = 0; rc = ioctl(il->fd, EVIOCGBIT(EV_REL, sizeof(relmap)), &relmap); if (relmap & (1 << REL_X)) { il->has_rel_x = true; } } if (evtmap & (1 << EV_ABS)) { absmap = 0; rc = ioctl(il->fd, EVIOCGBIT(EV_ABS, sizeof(absmap)), &absmap); if (absmap & (1 << ABS_X)) { il->has_abs_x = true; } } if (evtmap & (1 << EV_KEY)) { memset(keymap, 0, sizeof(keymap)); rc = ioctl(il->fd, EVIOCGBIT(EV_KEY, sizeof(keymap)), keymap); for (i = 0; i < KEY_CNT; i++) { if (keymap[i / 8] & (1 << (i % 8))) { if (linux_is_button(i)) { il->num_btns++; } else { il->num_keys++; } } } } qemu_set_fd_handler(il->fd, input_linux_event, NULL, il); input_linux_toggle_grab(il); QTAILQ_INSERT_TAIL(&inputs, il, next); il->initialized = true; return; err_close: close(il->fd); return; }
{ "code": [], "line_no": [] }
static void FUNC_0(UserCreatable *VAR_0, Error **VAR_1) { InputLinux *il = INPUT_LINUX(VAR_0); uint8_t evtmap, relmap, absmap, keymap[KEY_CNT / 8]; unsigned int VAR_2; int VAR_3, VAR_4; if (!il->evdev) { error_setg(VAR_1, "no input device specified"); return; } il->fd = open(il->evdev, O_RDWR); if (il->fd < 0) { error_setg_file_open(VAR_1, errno, il->evdev); return; } qemu_set_nonblock(il->fd); VAR_3 = ioctl(il->fd, EVIOCGVERSION, &VAR_4); if (VAR_3 < 0) { error_setg(VAR_1, "%s: is not an evdev device", il->evdev); goto err_close; } VAR_3 = ioctl(il->fd, EVIOCGBIT(0, sizeof(evtmap)), &evtmap); if (VAR_3 < 0) { error_setg(VAR_1, "%s: failed to read event bits", il->evdev); goto err_close; } if (evtmap & (1 << EV_REL)) { relmap = 0; VAR_3 = ioctl(il->fd, EVIOCGBIT(EV_REL, sizeof(relmap)), &relmap); if (relmap & (1 << REL_X)) { il->has_rel_x = true; } } if (evtmap & (1 << EV_ABS)) { absmap = 0; VAR_3 = ioctl(il->fd, EVIOCGBIT(EV_ABS, sizeof(absmap)), &absmap); if (absmap & (1 << ABS_X)) { il->has_abs_x = true; } } if (evtmap & (1 << EV_KEY)) { memset(keymap, 0, sizeof(keymap)); VAR_3 = ioctl(il->fd, EVIOCGBIT(EV_KEY, sizeof(keymap)), keymap); for (VAR_2 = 0; VAR_2 < KEY_CNT; VAR_2++) { if (keymap[VAR_2 / 8] & (1 << (VAR_2 % 8))) { if (linux_is_button(VAR_2)) { il->num_btns++; } else { il->num_keys++; } } } } qemu_set_fd_handler(il->fd, input_linux_event, NULL, il); input_linux_toggle_grab(il); QTAILQ_INSERT_TAIL(&inputs, il, next); il->initialized = true; return; err_close: close(il->fd); return; }
[ "static void FUNC_0(UserCreatable *VAR_0, Error **VAR_1)\n{", "InputLinux *il = INPUT_LINUX(VAR_0);", "uint8_t evtmap, relmap, absmap, keymap[KEY_CNT / 8];", "unsigned int VAR_2;", "int VAR_3, VAR_4;", "if (!il->evdev) {", "error_setg(VAR_1, \"no input device specified\");", "return;", "}", "il->fd = open(il->evdev, O_RDWR);", "if (il->fd < 0) {", "error_setg_file_open(VAR_1, errno, il->evdev);", "return;", "}", "qemu_set_nonblock(il->fd);", "VAR_3 = ioctl(il->fd, EVIOCGVERSION, &VAR_4);", "if (VAR_3 < 0) {", "error_setg(VAR_1, \"%s: is not an evdev device\", il->evdev);", "goto err_close;", "}", "VAR_3 = ioctl(il->fd, EVIOCGBIT(0, sizeof(evtmap)), &evtmap);", "if (VAR_3 < 0) {", "error_setg(VAR_1, \"%s: failed to read event bits\", il->evdev);", "goto err_close;", "}", "if (evtmap & (1 << EV_REL)) {", "relmap = 0;", "VAR_3 = ioctl(il->fd, EVIOCGBIT(EV_REL, sizeof(relmap)), &relmap);", "if (relmap & (1 << REL_X)) {", "il->has_rel_x = true;", "}", "}", "if (evtmap & (1 << EV_ABS)) {", "absmap = 0;", "VAR_3 = ioctl(il->fd, EVIOCGBIT(EV_ABS, sizeof(absmap)), &absmap);", "if (absmap & (1 << ABS_X)) {", "il->has_abs_x = true;", "}", "}", "if (evtmap & (1 << EV_KEY)) {", "memset(keymap, 0, sizeof(keymap));", "VAR_3 = ioctl(il->fd, EVIOCGBIT(EV_KEY, sizeof(keymap)), keymap);", "for (VAR_2 = 0; VAR_2 < KEY_CNT; VAR_2++) {", "if (keymap[VAR_2 / 8] & (1 << (VAR_2 % 8))) {", "if (linux_is_button(VAR_2)) {", "il->num_btns++;", "} else {", "il->num_keys++;", "}", "}", "}", "}", "qemu_set_fd_handler(il->fd, input_linux_event, NULL, il);", "input_linux_toggle_grab(il);", "QTAILQ_INSERT_TAIL(&inputs, il, next);", "il->initialized = true;", "return;", "err_close:\nclose(il->fd);", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 135, 137 ], [ 139 ], [ 141 ] ]
9,373
int bdrv_get_dirty(BlockDriverState *bs, BdrvDirtyBitmap *bitmap, int64_t sector) { if (bitmap) { return hbitmap_get(bitmap->bitmap, sector); } else { return 0; } }
false
qemu
b64bd51efa9bbf30df1b2f91477d2805678d0b93
int bdrv_get_dirty(BlockDriverState *bs, BdrvDirtyBitmap *bitmap, int64_t sector) { if (bitmap) { return hbitmap_get(bitmap->bitmap, sector); } else { return 0; } }
{ "code": [], "line_no": [] }
int FUNC_0(BlockDriverState *VAR_0, BdrvDirtyBitmap *VAR_1, int64_t VAR_2) { if (VAR_1) { return hbitmap_get(VAR_1->VAR_1, VAR_2); } else { return 0; } }
[ "int FUNC_0(BlockDriverState *VAR_0, BdrvDirtyBitmap *VAR_1,\nint64_t VAR_2)\n{", "if (VAR_1) {", "return hbitmap_get(VAR_1->VAR_1, VAR_2);", "} else {", "return 0;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ] ]
9,374
static void v9fs_attach(void *opaque) { V9fsPDU *pdu = opaque; V9fsState *s = pdu->s; int32_t fid, afid, n_uname; V9fsString uname, aname; V9fsFidState *fidp; size_t offset = 7; V9fsQID qid; ssize_t err; pdu_unmarshal(pdu, offset, "ddssd", &fid, &afid, &uname, &aname, &n_uname); trace_v9fs_attach(pdu->tag, pdu->id, fid, afid, uname.data, aname.data); fidp = alloc_fid(s, fid); if (fidp == NULL) { err = -EINVAL; goto out_nofid; } fidp->uid = n_uname; err = v9fs_co_name_to_path(pdu, NULL, "/", &fidp->path); if (err < 0) { err = -EINVAL; clunk_fid(s, fid); goto out; } err = fid_to_qid(pdu, fidp, &qid); if (err < 0) { err = -EINVAL; clunk_fid(s, fid); goto out; } offset += pdu_marshal(pdu, offset, "Q", &qid); err = offset; trace_v9fs_attach_return(pdu->tag, pdu->id, qid.type, qid.version, qid.path); s->root_fid = fid; /* disable migration */ error_set(&s->migration_blocker, QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION, s->ctx.fs_root, s->tag); migrate_add_blocker(s->migration_blocker); out: put_fid(pdu, fidp); out_nofid: complete_pdu(s, pdu, err); v9fs_string_free(&uname); v9fs_string_free(&aname); }
false
qemu
ddca7f86ac022289840e0200fd4050b2b58e9176
static void v9fs_attach(void *opaque) { V9fsPDU *pdu = opaque; V9fsState *s = pdu->s; int32_t fid, afid, n_uname; V9fsString uname, aname; V9fsFidState *fidp; size_t offset = 7; V9fsQID qid; ssize_t err; pdu_unmarshal(pdu, offset, "ddssd", &fid, &afid, &uname, &aname, &n_uname); trace_v9fs_attach(pdu->tag, pdu->id, fid, afid, uname.data, aname.data); fidp = alloc_fid(s, fid); if (fidp == NULL) { err = -EINVAL; goto out_nofid; } fidp->uid = n_uname; err = v9fs_co_name_to_path(pdu, NULL, "/", &fidp->path); if (err < 0) { err = -EINVAL; clunk_fid(s, fid); goto out; } err = fid_to_qid(pdu, fidp, &qid); if (err < 0) { err = -EINVAL; clunk_fid(s, fid); goto out; } offset += pdu_marshal(pdu, offset, "Q", &qid); err = offset; trace_v9fs_attach_return(pdu->tag, pdu->id, qid.type, qid.version, qid.path); s->root_fid = fid; error_set(&s->migration_blocker, QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION, s->ctx.fs_root, s->tag); migrate_add_blocker(s->migration_blocker); out: put_fid(pdu, fidp); out_nofid: complete_pdu(s, pdu, err); v9fs_string_free(&uname); v9fs_string_free(&aname); }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0) { V9fsPDU *pdu = VAR_0; V9fsState *s = pdu->s; int32_t fid, afid, n_uname; V9fsString uname, aname; V9fsFidState *fidp; size_t offset = 7; V9fsQID qid; ssize_t err; pdu_unmarshal(pdu, offset, "ddssd", &fid, &afid, &uname, &aname, &n_uname); trace_v9fs_attach(pdu->tag, pdu->id, fid, afid, uname.data, aname.data); fidp = alloc_fid(s, fid); if (fidp == NULL) { err = -EINVAL; goto out_nofid; } fidp->uid = n_uname; err = v9fs_co_name_to_path(pdu, NULL, "/", &fidp->path); if (err < 0) { err = -EINVAL; clunk_fid(s, fid); goto out; } err = fid_to_qid(pdu, fidp, &qid); if (err < 0) { err = -EINVAL; clunk_fid(s, fid); goto out; } offset += pdu_marshal(pdu, offset, "Q", &qid); err = offset; trace_v9fs_attach_return(pdu->tag, pdu->id, qid.type, qid.version, qid.path); s->root_fid = fid; error_set(&s->migration_blocker, QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION, s->ctx.fs_root, s->tag); migrate_add_blocker(s->migration_blocker); out: put_fid(pdu, fidp); out_nofid: complete_pdu(s, pdu, err); v9fs_string_free(&uname); v9fs_string_free(&aname); }
[ "static void FUNC_0(void *VAR_0)\n{", "V9fsPDU *pdu = VAR_0;", "V9fsState *s = pdu->s;", "int32_t fid, afid, n_uname;", "V9fsString uname, aname;", "V9fsFidState *fidp;", "size_t offset = 7;", "V9fsQID qid;", "ssize_t err;", "pdu_unmarshal(pdu, offset, \"ddssd\", &fid, &afid, &uname, &aname, &n_uname);", "trace_v9fs_attach(pdu->tag, pdu->id, fid, afid, uname.data, aname.data);", "fidp = alloc_fid(s, fid);", "if (fidp == NULL) {", "err = -EINVAL;", "goto out_nofid;", "}", "fidp->uid = n_uname;", "err = v9fs_co_name_to_path(pdu, NULL, \"/\", &fidp->path);", "if (err < 0) {", "err = -EINVAL;", "clunk_fid(s, fid);", "goto out;", "}", "err = fid_to_qid(pdu, fidp, &qid);", "if (err < 0) {", "err = -EINVAL;", "clunk_fid(s, fid);", "goto out;", "}", "offset += pdu_marshal(pdu, offset, \"Q\", &qid);", "err = offset;", "trace_v9fs_attach_return(pdu->tag, pdu->id,\nqid.type, qid.version, qid.path);", "s->root_fid = fid;", "error_set(&s->migration_blocker, QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION,\ns->ctx.fs_root, s->tag);", "migrate_add_blocker(s->migration_blocker);", "out:\nput_fid(pdu, fidp);", "out_nofid:\ncomplete_pdu(s, pdu, err);", "v9fs_string_free(&uname);", "v9fs_string_free(&aname);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69, 71 ], [ 73 ], [ 77, 79 ], [ 81 ], [ 83, 85 ], [ 87, 89 ], [ 91 ], [ 93 ], [ 95 ] ]
9,376
void arm_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) { int i; (*cpu_fprintf)(f, "Available CPUs:\n"); for (i = 0; arm_cpu_names[i].name; i++) { (*cpu_fprintf)(f, " %s\n", arm_cpu_names[i].name); } }
false
qemu
9a78eead0c74333a394c0f7bbfc4423ac746fcd5
void arm_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) { int i; (*cpu_fprintf)(f, "Available CPUs:\n"); for (i = 0; arm_cpu_names[i].name; i++) { (*cpu_fprintf)(f, " %s\n", arm_cpu_names[i].name); } }
{ "code": [], "line_no": [] }
void FUNC_0(FILE *VAR_2, int (*VAR_1)(FILE *VAR_2, const char *VAR_2, ...)) { int VAR_3; (*VAR_1)(VAR_2, "Available CPUs:\n"); for (VAR_3 = 0; arm_cpu_names[VAR_3].name; VAR_3++) { (*VAR_1)(VAR_2, " %s\n", arm_cpu_names[VAR_3].name); } }
[ "void FUNC_0(FILE *VAR_2, int (*VAR_1)(FILE *VAR_2, const char *VAR_2, ...))\n{", "int VAR_3;", "(*VAR_1)(VAR_2, \"Available CPUs:\\n\");", "for (VAR_3 = 0; arm_cpu_names[VAR_3].name; VAR_3++) {", "(*VAR_1)(VAR_2, \" %s\\n\", arm_cpu_names[VAR_3].name);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ] ]
9,377
static void ehci_execute_complete(EHCIQueue *q) { EHCIPacket *p = QTAILQ_FIRST(&q->packets); assert(p != NULL); assert(p->qtdaddr == q->qtdaddr); assert(p->async != EHCI_ASYNC_INFLIGHT); p->async = EHCI_ASYNC_NONE; DPRINTF("execute_complete: qhaddr 0x%x, next %x, qtdaddr 0x%x, status %d\n", q->qhaddr, q->qh.next, q->qtdaddr, q->usb_status); if (p->usb_status < 0) { switch (p->usb_status) { case USB_RET_IOERROR: case USB_RET_NODEV: q->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_XACTERR); set_field(&q->qh.token, 0, QTD_TOKEN_CERR); ehci_raise_irq(q->ehci, USBSTS_ERRINT); break; case USB_RET_STALL: q->qh.token |= QTD_TOKEN_HALT; ehci_raise_irq(q->ehci, USBSTS_ERRINT); break; case USB_RET_NAK: set_field(&q->qh.altnext_qtd, 0, QH_ALTNEXT_NAKCNT); return; /* We're not done yet with this transaction */ case USB_RET_BABBLE: q->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_BABBLE); ehci_raise_irq(q->ehci, USBSTS_ERRINT); break; default: /* should not be triggerable */ fprintf(stderr, "USB invalid response %d\n", p->usb_status); assert(0); break; } } else if ((p->usb_status > p->tbytes) && (p->pid == USB_TOKEN_IN)) { p->usb_status = USB_RET_BABBLE; q->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_BABBLE); ehci_raise_irq(q->ehci, USBSTS_ERRINT); } else { // TODO check 4.12 for splits if (p->tbytes && p->pid == USB_TOKEN_IN) { p->tbytes -= p->usb_status; } else { p->tbytes = 0; } DPRINTF("updating tbytes to %d\n", p->tbytes); set_field(&q->qh.token, p->tbytes, QTD_TOKEN_TBYTES); } ehci_finish_transfer(q, p->usb_status); usb_packet_unmap(&p->packet, &p->sgl); qemu_sglist_destroy(&p->sgl); q->qh.token ^= QTD_TOKEN_DTOGGLE; q->qh.token &= ~QTD_TOKEN_ACTIVE; if (q->qh.token & QTD_TOKEN_IOC) { ehci_raise_irq(q->ehci, USBSTS_INT); } }
false
qemu
45b339b18c660eb85af2ba25bfcaed5469660d77
static void ehci_execute_complete(EHCIQueue *q) { EHCIPacket *p = QTAILQ_FIRST(&q->packets); assert(p != NULL); assert(p->qtdaddr == q->qtdaddr); assert(p->async != EHCI_ASYNC_INFLIGHT); p->async = EHCI_ASYNC_NONE; DPRINTF("execute_complete: qhaddr 0x%x, next %x, qtdaddr 0x%x, status %d\n", q->qhaddr, q->qh.next, q->qtdaddr, q->usb_status); if (p->usb_status < 0) { switch (p->usb_status) { case USB_RET_IOERROR: case USB_RET_NODEV: q->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_XACTERR); set_field(&q->qh.token, 0, QTD_TOKEN_CERR); ehci_raise_irq(q->ehci, USBSTS_ERRINT); break; case USB_RET_STALL: q->qh.token |= QTD_TOKEN_HALT; ehci_raise_irq(q->ehci, USBSTS_ERRINT); break; case USB_RET_NAK: set_field(&q->qh.altnext_qtd, 0, QH_ALTNEXT_NAKCNT); return; case USB_RET_BABBLE: q->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_BABBLE); ehci_raise_irq(q->ehci, USBSTS_ERRINT); break; default: fprintf(stderr, "USB invalid response %d\n", p->usb_status); assert(0); break; } } else if ((p->usb_status > p->tbytes) && (p->pid == USB_TOKEN_IN)) { p->usb_status = USB_RET_BABBLE; q->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_BABBLE); ehci_raise_irq(q->ehci, USBSTS_ERRINT); } else { if (p->tbytes && p->pid == USB_TOKEN_IN) { p->tbytes -= p->usb_status; } else { p->tbytes = 0; } DPRINTF("updating tbytes to %d\n", p->tbytes); set_field(&q->qh.token, p->tbytes, QTD_TOKEN_TBYTES); } ehci_finish_transfer(q, p->usb_status); usb_packet_unmap(&p->packet, &p->sgl); qemu_sglist_destroy(&p->sgl); q->qh.token ^= QTD_TOKEN_DTOGGLE; q->qh.token &= ~QTD_TOKEN_ACTIVE; if (q->qh.token & QTD_TOKEN_IOC) { ehci_raise_irq(q->ehci, USBSTS_INT); } }
{ "code": [], "line_no": [] }
static void FUNC_0(EHCIQueue *VAR_0) { EHCIPacket *p = QTAILQ_FIRST(&VAR_0->packets); assert(p != NULL); assert(p->qtdaddr == VAR_0->qtdaddr); assert(p->async != EHCI_ASYNC_INFLIGHT); p->async = EHCI_ASYNC_NONE; DPRINTF("execute_complete: qhaddr 0x%x, next %x, qtdaddr 0x%x, status %d\n", VAR_0->qhaddr, VAR_0->qh.next, VAR_0->qtdaddr, VAR_0->usb_status); if (p->usb_status < 0) { switch (p->usb_status) { case USB_RET_IOERROR: case USB_RET_NODEV: VAR_0->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_XACTERR); set_field(&VAR_0->qh.token, 0, QTD_TOKEN_CERR); ehci_raise_irq(VAR_0->ehci, USBSTS_ERRINT); break; case USB_RET_STALL: VAR_0->qh.token |= QTD_TOKEN_HALT; ehci_raise_irq(VAR_0->ehci, USBSTS_ERRINT); break; case USB_RET_NAK: set_field(&VAR_0->qh.altnext_qtd, 0, QH_ALTNEXT_NAKCNT); return; case USB_RET_BABBLE: VAR_0->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_BABBLE); ehci_raise_irq(VAR_0->ehci, USBSTS_ERRINT); break; default: fprintf(stderr, "USB invalid response %d\n", p->usb_status); assert(0); break; } } else if ((p->usb_status > p->tbytes) && (p->pid == USB_TOKEN_IN)) { p->usb_status = USB_RET_BABBLE; VAR_0->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_BABBLE); ehci_raise_irq(VAR_0->ehci, USBSTS_ERRINT); } else { if (p->tbytes && p->pid == USB_TOKEN_IN) { p->tbytes -= p->usb_status; } else { p->tbytes = 0; } DPRINTF("updating tbytes to %d\n", p->tbytes); set_field(&VAR_0->qh.token, p->tbytes, QTD_TOKEN_TBYTES); } ehci_finish_transfer(VAR_0, p->usb_status); usb_packet_unmap(&p->packet, &p->sgl); qemu_sglist_destroy(&p->sgl); VAR_0->qh.token ^= QTD_TOKEN_DTOGGLE; VAR_0->qh.token &= ~QTD_TOKEN_ACTIVE; if (VAR_0->qh.token & QTD_TOKEN_IOC) { ehci_raise_irq(VAR_0->ehci, USBSTS_INT); } }
[ "static void FUNC_0(EHCIQueue *VAR_0)\n{", "EHCIPacket *p = QTAILQ_FIRST(&VAR_0->packets);", "assert(p != NULL);", "assert(p->qtdaddr == VAR_0->qtdaddr);", "assert(p->async != EHCI_ASYNC_INFLIGHT);", "p->async = EHCI_ASYNC_NONE;", "DPRINTF(\"execute_complete: qhaddr 0x%x, next %x, qtdaddr 0x%x, status %d\\n\",\nVAR_0->qhaddr, VAR_0->qh.next, VAR_0->qtdaddr, VAR_0->usb_status);", "if (p->usb_status < 0) {", "switch (p->usb_status) {", "case USB_RET_IOERROR:\ncase USB_RET_NODEV:\nVAR_0->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_XACTERR);", "set_field(&VAR_0->qh.token, 0, QTD_TOKEN_CERR);", "ehci_raise_irq(VAR_0->ehci, USBSTS_ERRINT);", "break;", "case USB_RET_STALL:\nVAR_0->qh.token |= QTD_TOKEN_HALT;", "ehci_raise_irq(VAR_0->ehci, USBSTS_ERRINT);", "break;", "case USB_RET_NAK:\nset_field(&VAR_0->qh.altnext_qtd, 0, QH_ALTNEXT_NAKCNT);", "return;", "case USB_RET_BABBLE:\nVAR_0->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_BABBLE);", "ehci_raise_irq(VAR_0->ehci, USBSTS_ERRINT);", "break;", "default:\nfprintf(stderr, \"USB invalid response %d\\n\", p->usb_status);", "assert(0);", "break;", "}", "} else if ((p->usb_status > p->tbytes) && (p->pid == USB_TOKEN_IN)) {", "p->usb_status = USB_RET_BABBLE;", "VAR_0->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_BABBLE);", "ehci_raise_irq(VAR_0->ehci, USBSTS_ERRINT);", "} else {", "if (p->tbytes && p->pid == USB_TOKEN_IN) {", "p->tbytes -= p->usb_status;", "} else {", "p->tbytes = 0;", "}", "DPRINTF(\"updating tbytes to %d\\n\", p->tbytes);", "set_field(&VAR_0->qh.token, p->tbytes, QTD_TOKEN_TBYTES);", "}", "ehci_finish_transfer(VAR_0, p->usb_status);", "usb_packet_unmap(&p->packet, &p->sgl);", "qemu_sglist_destroy(&p->sgl);", "VAR_0->qh.token ^= QTD_TOKEN_DTOGGLE;", "VAR_0->qh.token &= ~QTD_TOKEN_ACTIVE;", "if (VAR_0->qh.token & QTD_TOKEN_IOC) {", "ehci_raise_irq(VAR_0->ehci, USBSTS_INT);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19, 21 ], [ 25 ], [ 27 ], [ 29, 31, 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41, 43 ], [ 45 ], [ 47 ], [ 49, 51 ], [ 53 ], [ 55, 57 ], [ 59 ], [ 61 ], [ 63, 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 115 ], [ 117 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ] ]
9,378
static void do_info_history (void) { int i; for (i = 0; i < TERM_MAX_CMDS; i++) { if (term_history[i] == NULL) break; term_printf("%d: '%s'\n", i, term_history[i]); } }
false
qemu
7e2515e87c41e2e658aaed466e11cbdf1ea8bcb1
static void do_info_history (void) { int i; for (i = 0; i < TERM_MAX_CMDS; i++) { if (term_history[i] == NULL) break; term_printf("%d: '%s'\n", i, term_history[i]); } }
{ "code": [], "line_no": [] }
static void FUNC_0 (void) { int VAR_0; for (VAR_0 = 0; VAR_0 < TERM_MAX_CMDS; VAR_0++) { if (term_history[VAR_0] == NULL) break; term_printf("%d: '%s'\n", VAR_0, term_history[VAR_0]); } }
[ "static void FUNC_0 (void)\n{", "int VAR_0;", "for (VAR_0 = 0; VAR_0 < TERM_MAX_CMDS; VAR_0++) {", "if (term_history[VAR_0] == NULL)\nbreak;", "term_printf(\"%d: '%s'\\n\", VAR_0, term_history[VAR_0]);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11, 13 ], [ 15 ], [ 17 ], [ 19 ] ]
9,379
static void uhci_async_cancel_all(UHCIState *s) { UHCIQueue *queue; UHCIAsync *curr, *n; QTAILQ_FOREACH(queue, &s->queues, next) { QTAILQ_FOREACH_SAFE(curr, &queue->asyncs, next, n) { uhci_async_unlink(curr); uhci_async_cancel(curr); } uhci_queue_free(queue); } }
false
qemu
77fa9aee38758a078870e25f0dcf642066b4d5cc
static void uhci_async_cancel_all(UHCIState *s) { UHCIQueue *queue; UHCIAsync *curr, *n; QTAILQ_FOREACH(queue, &s->queues, next) { QTAILQ_FOREACH_SAFE(curr, &queue->asyncs, next, n) { uhci_async_unlink(curr); uhci_async_cancel(curr); } uhci_queue_free(queue); } }
{ "code": [], "line_no": [] }
static void FUNC_0(UHCIState *VAR_0) { UHCIQueue *queue; UHCIAsync *curr, *n; QTAILQ_FOREACH(queue, &VAR_0->queues, next) { QTAILQ_FOREACH_SAFE(curr, &queue->asyncs, next, n) { uhci_async_unlink(curr); uhci_async_cancel(curr); } uhci_queue_free(queue); } }
[ "static void FUNC_0(UHCIState *VAR_0)\n{", "UHCIQueue *queue;", "UHCIAsync *curr, *n;", "QTAILQ_FOREACH(queue, &VAR_0->queues, next) {", "QTAILQ_FOREACH_SAFE(curr, &queue->asyncs, next, n) {", "uhci_async_unlink(curr);", "uhci_async_cancel(curr);", "}", "uhci_queue_free(queue);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ] ]
9,380
int ppc_get_compat_smt_threads(PowerPCCPU *cpu) { int ret = smp_threads; PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); switch (cpu->cpu_version) { case CPU_POWERPC_LOGICAL_2_05: ret = 2; break; case CPU_POWERPC_LOGICAL_2_06: ret = 4; break; case CPU_POWERPC_LOGICAL_2_07: ret = 8; break; default: if (pcc->pcr_mask & PCR_COMPAT_2_06) { ret = 4; } else if (pcc->pcr_mask & PCR_COMPAT_2_05) { ret = 2; } break; } return MIN(ret, smp_threads); }
false
qemu
063cac5326518abfcd4f3f0eaace3fa9b1a97424
int ppc_get_compat_smt_threads(PowerPCCPU *cpu) { int ret = smp_threads; PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); switch (cpu->cpu_version) { case CPU_POWERPC_LOGICAL_2_05: ret = 2; break; case CPU_POWERPC_LOGICAL_2_06: ret = 4; break; case CPU_POWERPC_LOGICAL_2_07: ret = 8; break; default: if (pcc->pcr_mask & PCR_COMPAT_2_06) { ret = 4; } else if (pcc->pcr_mask & PCR_COMPAT_2_05) { ret = 2; } break; } return MIN(ret, smp_threads); }
{ "code": [], "line_no": [] }
int FUNC_0(PowerPCCPU *VAR_0) { int VAR_1 = smp_threads; PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(VAR_0); switch (VAR_0->cpu_version) { case CPU_POWERPC_LOGICAL_2_05: VAR_1 = 2; break; case CPU_POWERPC_LOGICAL_2_06: VAR_1 = 4; break; case CPU_POWERPC_LOGICAL_2_07: VAR_1 = 8; break; default: if (pcc->pcr_mask & PCR_COMPAT_2_06) { VAR_1 = 4; } else if (pcc->pcr_mask & PCR_COMPAT_2_05) { VAR_1 = 2; } break; } return MIN(VAR_1, smp_threads); }
[ "int FUNC_0(PowerPCCPU *VAR_0)\n{", "int VAR_1 = smp_threads;", "PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(VAR_0);", "switch (VAR_0->cpu_version) {", "case CPU_POWERPC_LOGICAL_2_05:\nVAR_1 = 2;", "break;", "case CPU_POWERPC_LOGICAL_2_06:\nVAR_1 = 4;", "break;", "case CPU_POWERPC_LOGICAL_2_07:\nVAR_1 = 8;", "break;", "default:\nif (pcc->pcr_mask & PCR_COMPAT_2_06) {", "VAR_1 = 4;", "} else if (pcc->pcr_mask & PCR_COMPAT_2_05) {", "VAR_1 = 2;", "}", "break;", "}", "return MIN(VAR_1, smp_threads);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13, 15 ], [ 17 ], [ 19, 21 ], [ 23 ], [ 25, 27 ], [ 29 ], [ 31, 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ] ]
9,381
static uint64_t fw_cfg_comb_read(void *opaque, target_phys_addr_t addr, unsigned size) { return fw_cfg_read(opaque); }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static uint64_t fw_cfg_comb_read(void *opaque, target_phys_addr_t addr, unsigned size) { return fw_cfg_read(opaque); }
{ "code": [], "line_no": [] }
static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr, unsigned size) { return fw_cfg_read(opaque); }
[ "static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{", "return fw_cfg_read(opaque);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ] ]
9,382
static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom) { MOVFragment *frag = &c->fragment; AVStream *st = NULL; MOVStreamContext *sc; MOVStts *ctts_data; uint64_t offset; int64_t dts; int data_offset = 0; unsigned entries, first_sample_flags = frag->flags; int flags, distance, i, found_keyframe = 0, err; for (i = 0; i < c->fc->nb_streams; i++) { if (c->fc->streams[i]->id == frag->track_id) { st = c->fc->streams[i]; break; } } if (!st) { av_log(c->fc, AV_LOG_ERROR, "could not find corresponding track id %d\n", frag->track_id); return AVERROR_INVALIDDATA; } sc = st->priv_data; if (sc->pseudo_stream_id+1 != frag->stsd_id && sc->pseudo_stream_id != -1) return 0; avio_r8(pb); /* version */ flags = avio_rb24(pb); entries = avio_rb32(pb); av_dlog(c->fc, "flags 0x%x entries %d\n", flags, entries); /* Always assume the presence of composition time offsets. * Without this assumption, for instance, we cannot deal with a track in fragmented movies that meet the following. * 1) in the initial movie, there are no samples. * 2) in the first movie fragment, there is only one sample without composition time offset. * 3) in the subsequent movie fragments, there are samples with composition time offset. */ if (!sc->ctts_count && sc->sample_count) { /* Complement ctts table if moov atom doesn't have ctts atom. */ ctts_data = av_realloc(NULL, sizeof(*sc->ctts_data)); if (!ctts_data) return AVERROR(ENOMEM); sc->ctts_data = ctts_data; sc->ctts_data[sc->ctts_count].count = sc->sample_count; sc->ctts_data[sc->ctts_count].duration = 0; sc->ctts_count++; } if ((uint64_t)entries+sc->ctts_count >= UINT_MAX/sizeof(*sc->ctts_data)) return AVERROR_INVALIDDATA; if ((err = av_reallocp_array(&sc->ctts_data, entries + sc->ctts_count, sizeof(*sc->ctts_data))) < 0) { sc->ctts_count = 0; return err; } if (flags & MOV_TRUN_DATA_OFFSET) data_offset = avio_rb32(pb); if (flags & MOV_TRUN_FIRST_SAMPLE_FLAGS) first_sample_flags = avio_rb32(pb); dts = sc->track_end - sc->time_offset; offset = frag->base_data_offset + data_offset; distance = 0; av_dlog(c->fc, "first sample flags 0x%x\n", first_sample_flags); for (i = 0; i < entries && !pb->eof_reached; i++) { unsigned sample_size = frag->size; int sample_flags = i ? frag->flags : first_sample_flags; unsigned sample_duration = frag->duration; int keyframe = 0; int sample_cts = 0; int64_t cts; if (flags & MOV_TRUN_SAMPLE_DURATION) sample_duration = avio_rb32(pb); if (flags & MOV_TRUN_SAMPLE_SIZE) sample_size = avio_rb32(pb); if (flags & MOV_TRUN_SAMPLE_FLAGS) sample_flags = avio_rb32(pb); if (flags & MOV_TRUN_SAMPLE_CTS) sample_cts = avio_rb32(pb); sc->ctts_data[sc->ctts_count].count = 1; sc->ctts_data[sc->ctts_count].duration = sample_cts; mov_update_dts_shift(sc, sc->ctts_data[sc->ctts_count].duration); if (frag->time != AV_NOPTS_VALUE) { if (c->use_mfra_for == FF_MOV_FLAG_MFRA_PTS) { int64_t pts = frag->time; av_log(c->fc, AV_LOG_DEBUG, "found frag time %"PRId64 " sc->dts_shift %d ctts.duration %d" " sc->time_offset %"PRId64" flags & MOV_TRUN_SAMPLE_CTS %d\n", pts, sc->dts_shift, sc->ctts_data[sc->ctts_count].duration, sc->time_offset, flags & MOV_TRUN_SAMPLE_CTS); dts = pts - sc->dts_shift; if (flags & MOV_TRUN_SAMPLE_CTS) { dts -= sc->ctts_data[sc->ctts_count].duration; } else { dts -= sc->time_offset; } av_log(c->fc, AV_LOG_DEBUG, "calculated into dts %"PRId64"\n", dts); } else { dts = frag->time; av_log(c->fc, AV_LOG_DEBUG, "found frag time %"PRId64 ", using it for dts\n", dts); } frag->time = AV_NOPTS_VALUE; } cts = dts + sample_cts; sc->ctts_count++; if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) keyframe = 1; else if (!found_keyframe) keyframe = found_keyframe = !(sample_flags & (MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC | MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES)); if (keyframe) distance = 0; err = av_add_index_entry(st, offset, INT64_MAX/2, sample_size, distance, keyframe ? AVINDEX_KEYFRAME : 0); if (err < 0) { av_log(c->fc, AV_LOG_ERROR, "Failed to add index entry\n"); } else st->index_entries[st->nb_index_entries - 1].timestamp = cts; av_dlog(c->fc, "AVIndex stream %d, sample %d, offset %"PRIx64", cts %"PRId64", " "size %d, distance %d, keyframe %d\n", st->index, sc->sample_count+i, offset, cts, sample_size, distance, keyframe); distance++; dts += sample_duration; offset += sample_size; sc->data_size += sample_size; sc->duration_for_fps += sample_duration; sc->nb_frames_for_fps ++; } if (pb->eof_reached) return AVERROR_EOF; frag->implicit_offset = offset; st->duration = sc->track_end = dts + sc->time_offset; return 0; }
false
FFmpeg
82fe4072ea4251d47167017b3223928279a5abab
static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom) { MOVFragment *frag = &c->fragment; AVStream *st = NULL; MOVStreamContext *sc; MOVStts *ctts_data; uint64_t offset; int64_t dts; int data_offset = 0; unsigned entries, first_sample_flags = frag->flags; int flags, distance, i, found_keyframe = 0, err; for (i = 0; i < c->fc->nb_streams; i++) { if (c->fc->streams[i]->id == frag->track_id) { st = c->fc->streams[i]; break; } } if (!st) { av_log(c->fc, AV_LOG_ERROR, "could not find corresponding track id %d\n", frag->track_id); return AVERROR_INVALIDDATA; } sc = st->priv_data; if (sc->pseudo_stream_id+1 != frag->stsd_id && sc->pseudo_stream_id != -1) return 0; avio_r8(pb); flags = avio_rb24(pb); entries = avio_rb32(pb); av_dlog(c->fc, "flags 0x%x entries %d\n", flags, entries); if (!sc->ctts_count && sc->sample_count) { ctts_data = av_realloc(NULL, sizeof(*sc->ctts_data)); if (!ctts_data) return AVERROR(ENOMEM); sc->ctts_data = ctts_data; sc->ctts_data[sc->ctts_count].count = sc->sample_count; sc->ctts_data[sc->ctts_count].duration = 0; sc->ctts_count++; } if ((uint64_t)entries+sc->ctts_count >= UINT_MAX/sizeof(*sc->ctts_data)) return AVERROR_INVALIDDATA; if ((err = av_reallocp_array(&sc->ctts_data, entries + sc->ctts_count, sizeof(*sc->ctts_data))) < 0) { sc->ctts_count = 0; return err; } if (flags & MOV_TRUN_DATA_OFFSET) data_offset = avio_rb32(pb); if (flags & MOV_TRUN_FIRST_SAMPLE_FLAGS) first_sample_flags = avio_rb32(pb); dts = sc->track_end - sc->time_offset; offset = frag->base_data_offset + data_offset; distance = 0; av_dlog(c->fc, "first sample flags 0x%x\n", first_sample_flags); for (i = 0; i < entries && !pb->eof_reached; i++) { unsigned sample_size = frag->size; int sample_flags = i ? frag->flags : first_sample_flags; unsigned sample_duration = frag->duration; int keyframe = 0; int sample_cts = 0; int64_t cts; if (flags & MOV_TRUN_SAMPLE_DURATION) sample_duration = avio_rb32(pb); if (flags & MOV_TRUN_SAMPLE_SIZE) sample_size = avio_rb32(pb); if (flags & MOV_TRUN_SAMPLE_FLAGS) sample_flags = avio_rb32(pb); if (flags & MOV_TRUN_SAMPLE_CTS) sample_cts = avio_rb32(pb); sc->ctts_data[sc->ctts_count].count = 1; sc->ctts_data[sc->ctts_count].duration = sample_cts; mov_update_dts_shift(sc, sc->ctts_data[sc->ctts_count].duration); if (frag->time != AV_NOPTS_VALUE) { if (c->use_mfra_for == FF_MOV_FLAG_MFRA_PTS) { int64_t pts = frag->time; av_log(c->fc, AV_LOG_DEBUG, "found frag time %"PRId64 " sc->dts_shift %d ctts.duration %d" " sc->time_offset %"PRId64" flags & MOV_TRUN_SAMPLE_CTS %d\n", pts, sc->dts_shift, sc->ctts_data[sc->ctts_count].duration, sc->time_offset, flags & MOV_TRUN_SAMPLE_CTS); dts = pts - sc->dts_shift; if (flags & MOV_TRUN_SAMPLE_CTS) { dts -= sc->ctts_data[sc->ctts_count].duration; } else { dts -= sc->time_offset; } av_log(c->fc, AV_LOG_DEBUG, "calculated into dts %"PRId64"\n", dts); } else { dts = frag->time; av_log(c->fc, AV_LOG_DEBUG, "found frag time %"PRId64 ", using it for dts\n", dts); } frag->time = AV_NOPTS_VALUE; } cts = dts + sample_cts; sc->ctts_count++; if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) keyframe = 1; else if (!found_keyframe) keyframe = found_keyframe = !(sample_flags & (MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC | MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES)); if (keyframe) distance = 0; err = av_add_index_entry(st, offset, INT64_MAX/2, sample_size, distance, keyframe ? AVINDEX_KEYFRAME : 0); if (err < 0) { av_log(c->fc, AV_LOG_ERROR, "Failed to add index entry\n"); } else st->index_entries[st->nb_index_entries - 1].timestamp = cts; av_dlog(c->fc, "AVIndex stream %d, sample %d, offset %"PRIx64", cts %"PRId64", " "size %d, distance %d, keyframe %d\n", st->index, sc->sample_count+i, offset, cts, sample_size, distance, keyframe); distance++; dts += sample_duration; offset += sample_size; sc->data_size += sample_size; sc->duration_for_fps += sample_duration; sc->nb_frames_for_fps ++; } if (pb->eof_reached) return AVERROR_EOF; frag->implicit_offset = offset; st->duration = sc->track_end = dts + sc->time_offset; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2) { MOVFragment *frag = &VAR_0->fragment; AVStream *st = NULL; MOVStreamContext *sc; MOVStts *ctts_data; uint64_t offset; int64_t dts; int VAR_3 = 0; unsigned VAR_4, VAR_5 = frag->VAR_6; int VAR_6, VAR_7, VAR_8, VAR_9 = 0, VAR_10; for (VAR_8 = 0; VAR_8 < VAR_0->fc->nb_streams; VAR_8++) { if (VAR_0->fc->streams[VAR_8]->id == frag->track_id) { st = VAR_0->fc->streams[VAR_8]; break; } } if (!st) { av_log(VAR_0->fc, AV_LOG_ERROR, "could not find corresponding track id %d\n", frag->track_id); return AVERROR_INVALIDDATA; } sc = st->priv_data; if (sc->pseudo_stream_id+1 != frag->stsd_id && sc->pseudo_stream_id != -1) return 0; avio_r8(VAR_1); VAR_6 = avio_rb24(VAR_1); VAR_4 = avio_rb32(VAR_1); av_dlog(VAR_0->fc, "VAR_6 0x%x VAR_4 %d\n", VAR_6, VAR_4); if (!sc->ctts_count && sc->sample_count) { ctts_data = av_realloc(NULL, sizeof(*sc->ctts_data)); if (!ctts_data) return AVERROR(ENOMEM); sc->ctts_data = ctts_data; sc->ctts_data[sc->ctts_count].count = sc->sample_count; sc->ctts_data[sc->ctts_count].duration = 0; sc->ctts_count++; } if ((uint64_t)VAR_4+sc->ctts_count >= UINT_MAX/sizeof(*sc->ctts_data)) return AVERROR_INVALIDDATA; if ((VAR_10 = av_reallocp_array(&sc->ctts_data, VAR_4 + sc->ctts_count, sizeof(*sc->ctts_data))) < 0) { sc->ctts_count = 0; return VAR_10; } if (VAR_6 & MOV_TRUN_DATA_OFFSET) VAR_3 = avio_rb32(VAR_1); if (VAR_6 & MOV_TRUN_FIRST_SAMPLE_FLAGS) VAR_5 = avio_rb32(VAR_1); dts = sc->track_end - sc->time_offset; offset = frag->base_data_offset + VAR_3; VAR_7 = 0; av_dlog(VAR_0->fc, "first sample VAR_6 0x%x\n", VAR_5); for (VAR_8 = 0; VAR_8 < VAR_4 && !VAR_1->eof_reached; VAR_8++) { unsigned sample_size = frag->size; int sample_flags = VAR_8 ? frag->VAR_6 : VAR_5; unsigned sample_duration = frag->duration; int keyframe = 0; int sample_cts = 0; int64_t cts; if (VAR_6 & MOV_TRUN_SAMPLE_DURATION) sample_duration = avio_rb32(VAR_1); if (VAR_6 & MOV_TRUN_SAMPLE_SIZE) sample_size = avio_rb32(VAR_1); if (VAR_6 & MOV_TRUN_SAMPLE_FLAGS) sample_flags = avio_rb32(VAR_1); if (VAR_6 & MOV_TRUN_SAMPLE_CTS) sample_cts = avio_rb32(VAR_1); sc->ctts_data[sc->ctts_count].count = 1; sc->ctts_data[sc->ctts_count].duration = sample_cts; mov_update_dts_shift(sc, sc->ctts_data[sc->ctts_count].duration); if (frag->time != AV_NOPTS_VALUE) { if (VAR_0->use_mfra_for == FF_MOV_FLAG_MFRA_PTS) { int64_t pts = frag->time; av_log(VAR_0->fc, AV_LOG_DEBUG, "found frag time %"PRId64 " sc->dts_shift %d ctts.duration %d" " sc->time_offset %"PRId64" VAR_6 & MOV_TRUN_SAMPLE_CTS %d\n", pts, sc->dts_shift, sc->ctts_data[sc->ctts_count].duration, sc->time_offset, VAR_6 & MOV_TRUN_SAMPLE_CTS); dts = pts - sc->dts_shift; if (VAR_6 & MOV_TRUN_SAMPLE_CTS) { dts -= sc->ctts_data[sc->ctts_count].duration; } else { dts -= sc->time_offset; } av_log(VAR_0->fc, AV_LOG_DEBUG, "calculated into dts %"PRId64"\n", dts); } else { dts = frag->time; av_log(VAR_0->fc, AV_LOG_DEBUG, "found frag time %"PRId64 ", using it for dts\n", dts); } frag->time = AV_NOPTS_VALUE; } cts = dts + sample_cts; sc->ctts_count++; if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) keyframe = 1; else if (!VAR_9) keyframe = VAR_9 = !(sample_flags & (MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC | MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES)); if (keyframe) VAR_7 = 0; VAR_10 = av_add_index_entry(st, offset, INT64_MAX/2, sample_size, VAR_7, keyframe ? AVINDEX_KEYFRAME : 0); if (VAR_10 < 0) { av_log(VAR_0->fc, AV_LOG_ERROR, "Failed to add index entry\n"); } else st->index_entries[st->nb_index_entries - 1].timestamp = cts; av_dlog(VAR_0->fc, "AVIndex stream %d, sample %d, offset %"PRIx64", cts %"PRId64", " "size %d, VAR_7 %d, keyframe %d\n", st->index, sc->sample_count+VAR_8, offset, cts, sample_size, VAR_7, keyframe); VAR_7++; dts += sample_duration; offset += sample_size; sc->data_size += sample_size; sc->duration_for_fps += sample_duration; sc->nb_frames_for_fps ++; } if (VAR_1->eof_reached) return AVERROR_EOF; frag->implicit_offset = offset; st->duration = sc->track_end = dts + sc->time_offset; return 0; }
[ "static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2)\n{", "MOVFragment *frag = &VAR_0->fragment;", "AVStream *st = NULL;", "MOVStreamContext *sc;", "MOVStts *ctts_data;", "uint64_t offset;", "int64_t dts;", "int VAR_3 = 0;", "unsigned VAR_4, VAR_5 = frag->VAR_6;", "int VAR_6, VAR_7, VAR_8, VAR_9 = 0, VAR_10;", "for (VAR_8 = 0; VAR_8 < VAR_0->fc->nb_streams; VAR_8++) {", "if (VAR_0->fc->streams[VAR_8]->id == frag->track_id) {", "st = VAR_0->fc->streams[VAR_8];", "break;", "}", "}", "if (!st) {", "av_log(VAR_0->fc, AV_LOG_ERROR, \"could not find corresponding track id %d\\n\", frag->track_id);", "return AVERROR_INVALIDDATA;", "}", "sc = st->priv_data;", "if (sc->pseudo_stream_id+1 != frag->stsd_id && sc->pseudo_stream_id != -1)\nreturn 0;", "avio_r8(VAR_1);", "VAR_6 = avio_rb24(VAR_1);", "VAR_4 = avio_rb32(VAR_1);", "av_dlog(VAR_0->fc, \"VAR_6 0x%x VAR_4 %d\\n\", VAR_6, VAR_4);", "if (!sc->ctts_count && sc->sample_count)\n{", "ctts_data = av_realloc(NULL, sizeof(*sc->ctts_data));", "if (!ctts_data)\nreturn AVERROR(ENOMEM);", "sc->ctts_data = ctts_data;", "sc->ctts_data[sc->ctts_count].count = sc->sample_count;", "sc->ctts_data[sc->ctts_count].duration = 0;", "sc->ctts_count++;", "}", "if ((uint64_t)VAR_4+sc->ctts_count >= UINT_MAX/sizeof(*sc->ctts_data))\nreturn AVERROR_INVALIDDATA;", "if ((VAR_10 = av_reallocp_array(&sc->ctts_data, VAR_4 + sc->ctts_count,\nsizeof(*sc->ctts_data))) < 0) {", "sc->ctts_count = 0;", "return VAR_10;", "}", "if (VAR_6 & MOV_TRUN_DATA_OFFSET) VAR_3 = avio_rb32(VAR_1);", "if (VAR_6 & MOV_TRUN_FIRST_SAMPLE_FLAGS) VAR_5 = avio_rb32(VAR_1);", "dts = sc->track_end - sc->time_offset;", "offset = frag->base_data_offset + VAR_3;", "VAR_7 = 0;", "av_dlog(VAR_0->fc, \"first sample VAR_6 0x%x\\n\", VAR_5);", "for (VAR_8 = 0; VAR_8 < VAR_4 && !VAR_1->eof_reached; VAR_8++) {", "unsigned sample_size = frag->size;", "int sample_flags = VAR_8 ? frag->VAR_6 : VAR_5;", "unsigned sample_duration = frag->duration;", "int keyframe = 0;", "int sample_cts = 0;", "int64_t cts;", "if (VAR_6 & MOV_TRUN_SAMPLE_DURATION) sample_duration = avio_rb32(VAR_1);", "if (VAR_6 & MOV_TRUN_SAMPLE_SIZE) sample_size = avio_rb32(VAR_1);", "if (VAR_6 & MOV_TRUN_SAMPLE_FLAGS) sample_flags = avio_rb32(VAR_1);", "if (VAR_6 & MOV_TRUN_SAMPLE_CTS) sample_cts = avio_rb32(VAR_1);", "sc->ctts_data[sc->ctts_count].count = 1;", "sc->ctts_data[sc->ctts_count].duration = sample_cts;", "mov_update_dts_shift(sc, sc->ctts_data[sc->ctts_count].duration);", "if (frag->time != AV_NOPTS_VALUE) {", "if (VAR_0->use_mfra_for == FF_MOV_FLAG_MFRA_PTS) {", "int64_t pts = frag->time;", "av_log(VAR_0->fc, AV_LOG_DEBUG, \"found frag time %\"PRId64\n\" sc->dts_shift %d ctts.duration %d\"\n\" sc->time_offset %\"PRId64\" VAR_6 & MOV_TRUN_SAMPLE_CTS %d\\n\", pts,\nsc->dts_shift, sc->ctts_data[sc->ctts_count].duration,\nsc->time_offset, VAR_6 & MOV_TRUN_SAMPLE_CTS);", "dts = pts - sc->dts_shift;", "if (VAR_6 & MOV_TRUN_SAMPLE_CTS) {", "dts -= sc->ctts_data[sc->ctts_count].duration;", "} else {", "dts -= sc->time_offset;", "}", "av_log(VAR_0->fc, AV_LOG_DEBUG, \"calculated into dts %\"PRId64\"\\n\", dts);", "} else {", "dts = frag->time;", "av_log(VAR_0->fc, AV_LOG_DEBUG, \"found frag time %\"PRId64\n\", using it for dts\\n\", dts);", "}", "frag->time = AV_NOPTS_VALUE;", "}", "cts = dts + sample_cts;", "sc->ctts_count++;", "if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)\nkeyframe = 1;", "else if (!VAR_9)\nkeyframe = VAR_9 =\n!(sample_flags & (MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC |\nMOV_FRAG_SAMPLE_FLAG_DEPENDS_YES));", "if (keyframe)\nVAR_7 = 0;", "VAR_10 = av_add_index_entry(st, offset, INT64_MAX/2, sample_size, VAR_7,\nkeyframe ? AVINDEX_KEYFRAME : 0);", "if (VAR_10 < 0) {", "av_log(VAR_0->fc, AV_LOG_ERROR, \"Failed to add index entry\\n\");", "} else", "st->index_entries[st->nb_index_entries - 1].timestamp = cts;", "av_dlog(VAR_0->fc, \"AVIndex stream %d, sample %d, offset %\"PRIx64\", cts %\"PRId64\", \"\n\"size %d, VAR_7 %d, keyframe %d\\n\", st->index, sc->sample_count+VAR_8,\noffset, cts, sample_size, VAR_7, keyframe);", "VAR_7++;", "dts += sample_duration;", "offset += sample_size;", "sc->data_size += sample_size;", "sc->duration_for_fps += sample_duration;", "sc->nb_frames_for_fps ++;", "}", "if (VAR_1->eof_reached)\nreturn AVERROR_EOF;", "frag->implicit_offset = offset;", "st->duration = sc->track_end = dts + sc->time_offset;", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47, 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 71, 73 ], [ 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 ], [ 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 ], [ 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 ], [ 249, 251 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ] ]
9,383
static void DEF(put, pixels8_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h) { MOVQ_BFE(mm6); __asm__ volatile( "lea (%3, %3), %%"REG_a" \n\t" "movq (%1), %%mm0 \n\t" ".p2align 3 \n\t" "1: \n\t" "movq (%1, %3), %%mm1 \n\t" "movq (%1, %%"REG_a"),%%mm2 \n\t" PAVGBP(%%mm1, %%mm0, %%mm4, %%mm2, %%mm1, %%mm5) "movq %%mm4, (%2) \n\t" "movq %%mm5, (%2, %3) \n\t" "add %%"REG_a", %1 \n\t" "add %%"REG_a", %2 \n\t" "movq (%1, %3), %%mm1 \n\t" "movq (%1, %%"REG_a"),%%mm0 \n\t" PAVGBP(%%mm1, %%mm2, %%mm4, %%mm0, %%mm1, %%mm5) "movq %%mm4, (%2) \n\t" "movq %%mm5, (%2, %3) \n\t" "add %%"REG_a", %1 \n\t" "add %%"REG_a", %2 \n\t" "subl $4, %0 \n\t" "jnz 1b \n\t" :"+g"(h), "+S"(pixels), "+D"(block) :"r"((x86_reg)line_size) :REG_a, "memory"); }
false
FFmpeg
0493e42eb2f9fbf42d0aee0b48a84f81f19fb7fa
static void DEF(put, pixels8_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h) { MOVQ_BFE(mm6); __asm__ volatile( "lea (%3, %3), %%"REG_a" \n\t" "movq (%1), %%mm0 \n\t" ".p2align 3 \n\t" "1: \n\t" "movq (%1, %3), %%mm1 \n\t" "movq (%1, %%"REG_a"),%%mm2 \n\t" PAVGBP(%%mm1, %%mm0, %%mm4, %%mm2, %%mm1, %%mm5) "movq %%mm4, (%2) \n\t" "movq %%mm5, (%2, %3) \n\t" "add %%"REG_a", %1 \n\t" "add %%"REG_a", %2 \n\t" "movq (%1, %3), %%mm1 \n\t" "movq (%1, %%"REG_a"),%%mm0 \n\t" PAVGBP(%%mm1, %%mm2, %%mm4, %%mm0, %%mm1, %%mm5) "movq %%mm4, (%2) \n\t" "movq %%mm5, (%2, %3) \n\t" "add %%"REG_a", %1 \n\t" "add %%"REG_a", %2 \n\t" "subl $4, %0 \n\t" "jnz 1b \n\t" :"+g"(h), "+S"(pixels), "+D"(block) :"r"((x86_reg)line_size) :REG_a, "memory"); }
{ "code": [], "line_no": [] }
static void FUNC_0(put, pixels8_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h) { MOVQ_BFE(mm6); __asm__ volatile( "lea (%3, %3), %%"REG_a" \n\t" "movq (%1), %%mm0 \n\t" ".p2align 3 \n\t" "1: \n\t" "movq (%1, %3), %%mm1 \n\t" "movq (%1, %%"REG_a"),%%mm2 \n\t" PAVGBP(%%mm1, %%mm0, %%mm4, %%mm2, %%mm1, %%mm5) "movq %%mm4, (%2) \n\t" "movq %%mm5, (%2, %3) \n\t" "add %%"REG_a", %1 \n\t" "add %%"REG_a", %2 \n\t" "movq (%1, %3), %%mm1 \n\t" "movq (%1, %%"REG_a"),%%mm0 \n\t" PAVGBP(%%mm1, %%mm2, %%mm4, %%mm0, %%mm1, %%mm5) "movq %%mm4, (%2) \n\t" "movq %%mm5, (%2, %3) \n\t" "add %%"REG_a", %1 \n\t" "add %%"REG_a", %2 \n\t" "subl $4, %0 \n\t" "jnz 1b \n\t" :"+g"(h), "+S"(pixels), "+D"(block) :"r"((x86_reg)line_size) :REG_a, "memory"); }
[ "static void FUNC_0(put, pixels8_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)\n{", "MOVQ_BFE(mm6);", "__asm__ volatile(\n\"lea (%3, %3), %%\"REG_a\" \\n\\t\"\n\"movq (%1), %%mm0 \\n\\t\"\n\".p2align 3 \\n\\t\"\n\"1: \\n\\t\"\n\"movq (%1, %3), %%mm1 \\n\\t\"\n\"movq (%1, %%\"REG_a\"),%%mm2 \\n\\t\"\nPAVGBP(%%mm1, %%mm0, %%mm4, %%mm2, %%mm1, %%mm5)\n\"movq %%mm4, (%2) \\n\\t\"\n\"movq %%mm5, (%2, %3) \\n\\t\"\n\"add %%\"REG_a\", %1 \\n\\t\"\n\"add %%\"REG_a\", %2 \\n\\t\"\n\"movq (%1, %3), %%mm1 \\n\\t\"\n\"movq (%1, %%\"REG_a\"),%%mm0 \\n\\t\"\nPAVGBP(%%mm1, %%mm2, %%mm4, %%mm0, %%mm1, %%mm5)\n\"movq %%mm4, (%2) \\n\\t\"\n\"movq %%mm5, (%2, %3) \\n\\t\"\n\"add %%\"REG_a\", %1 \\n\\t\"\n\"add %%\"REG_a\", %2 \\n\\t\"\n\"subl $4, %0 \\n\\t\"\n\"jnz 1b \\n\\t\"\n:\"+g\"(h), \"+S\"(pixels), \"+D\"(block)\n:\"r\"((x86_reg)line_size)\n:REG_a, \"memory\");", "}" ]
[ 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 ] ]
9,384
static QDict *build_qmp_error_dict(const QError *err) { QObject *obj; obj = qobject_from_jsonf("{ 'error': { 'class': %s, 'desc': %p } }", ErrorClass_lookup[err->err_class], qerror_human(err)); return qobject_to_qdict(obj); }
false
qemu
710aec915d208246891b68e2ba61b54951edc508
static QDict *build_qmp_error_dict(const QError *err) { QObject *obj; obj = qobject_from_jsonf("{ 'error': { 'class': %s, 'desc': %p } }", ErrorClass_lookup[err->err_class], qerror_human(err)); return qobject_to_qdict(obj); }
{ "code": [], "line_no": [] }
static QDict *FUNC_0(const QError *err) { QObject *obj; obj = qobject_from_jsonf("{ 'error': { 'class': %s, 'desc': %p } }", ErrorClass_lookup[err->err_class], qerror_human(err)); return qobject_to_qdict(obj); }
[ "static QDict *FUNC_0(const QError *err)\n{", "QObject *obj;", "obj = qobject_from_jsonf(\"{ 'error': { 'class': %s, 'desc': %p } }\",", "ErrorClass_lookup[err->err_class],\nqerror_human(err));", "return qobject_to_qdict(obj);", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11, 13 ], [ 17 ], [ 19 ] ]
9,385
static void gd_update_caption(GtkDisplayState *s) { const char *status = ""; gchar *title; if (!runstate_is_running()) { status = " [Stopped]"; } if (qemu_name) { title = g_strdup_printf("QEMU (%s)%s", qemu_name, status); } else { title = g_strdup_printf("QEMU%s", status); } gtk_window_set_title(GTK_WINDOW(s->window), title); g_free(title); }
false
qemu
5104a1f65088285ddf870aa641b9061064e8757d
static void gd_update_caption(GtkDisplayState *s) { const char *status = ""; gchar *title; if (!runstate_is_running()) { status = " [Stopped]"; } if (qemu_name) { title = g_strdup_printf("QEMU (%s)%s", qemu_name, status); } else { title = g_strdup_printf("QEMU%s", status); } gtk_window_set_title(GTK_WINDOW(s->window), title); g_free(title); }
{ "code": [], "line_no": [] }
static void FUNC_0(GtkDisplayState *VAR_0) { const char *VAR_1 = ""; gchar *title; if (!runstate_is_running()) { VAR_1 = " [Stopped]"; } if (qemu_name) { title = g_strdup_printf("QEMU (%VAR_0)%VAR_0", qemu_name, VAR_1); } else { title = g_strdup_printf("QEMU%VAR_0", VAR_1); } gtk_window_set_title(GTK_WINDOW(VAR_0->window), title); g_free(title); }
[ "static void FUNC_0(GtkDisplayState *VAR_0)\n{", "const char *VAR_1 = \"\";", "gchar *title;", "if (!runstate_is_running()) {", "VAR_1 = \" [Stopped]\";", "}", "if (qemu_name) {", "title = g_strdup_printf(\"QEMU (%VAR_0)%VAR_0\", qemu_name, VAR_1);", "} else {", "title = g_strdup_printf(\"QEMU%VAR_0\", VAR_1);", "}", "gtk_window_set_title(GTK_WINDOW(VAR_0->window), title);", "g_free(title);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 35 ], [ 37 ] ]
9,386
void css_adapter_interrupt(uint8_t isc) { S390CPU *cpu = s390_cpu_addr2state(0); uint32_t io_int_word = (isc << 27) | IO_INT_WORD_AI; trace_css_adapter_interrupt(isc); s390_io_interrupt(cpu, 0, 0, 0, io_int_word); }
false
qemu
de13d2161473d02ae97ec0f8e4503147554892dd
void css_adapter_interrupt(uint8_t isc) { S390CPU *cpu = s390_cpu_addr2state(0); uint32_t io_int_word = (isc << 27) | IO_INT_WORD_AI; trace_css_adapter_interrupt(isc); s390_io_interrupt(cpu, 0, 0, 0, io_int_word); }
{ "code": [], "line_no": [] }
void FUNC_0(uint8_t VAR_0) { S390CPU *cpu = s390_cpu_addr2state(0); uint32_t io_int_word = (VAR_0 << 27) | IO_INT_WORD_AI; trace_css_adapter_interrupt(VAR_0); s390_io_interrupt(cpu, 0, 0, 0, io_int_word); }
[ "void FUNC_0(uint8_t VAR_0)\n{", "S390CPU *cpu = s390_cpu_addr2state(0);", "uint32_t io_int_word = (VAR_0 << 27) | IO_INT_WORD_AI;", "trace_css_adapter_interrupt(VAR_0);", "s390_io_interrupt(cpu, 0, 0, 0, io_int_word);", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ] ]
9,387
void tb_check_watchpoint(CPUState *cpu) { TranslationBlock *tb; tb = tb_find_pc(cpu->mem_io_pc); if (!tb) { cpu_abort(cpu, "check_watchpoint: could not find TB for pc=%p", (void *)cpu->mem_io_pc); } cpu_restore_state_from_tb(cpu, tb, cpu->mem_io_pc); tb_phys_invalidate(tb, -1); }
false
qemu
8d302e76755b8157373073d7107e31b0b13f80c1
void tb_check_watchpoint(CPUState *cpu) { TranslationBlock *tb; tb = tb_find_pc(cpu->mem_io_pc); if (!tb) { cpu_abort(cpu, "check_watchpoint: could not find TB for pc=%p", (void *)cpu->mem_io_pc); } cpu_restore_state_from_tb(cpu, tb, cpu->mem_io_pc); tb_phys_invalidate(tb, -1); }
{ "code": [], "line_no": [] }
void FUNC_0(CPUState *VAR_0) { TranslationBlock *tb; tb = tb_find_pc(VAR_0->mem_io_pc); if (!tb) { cpu_abort(VAR_0, "check_watchpoint: could not find TB for pc=%p", (void *)VAR_0->mem_io_pc); } cpu_restore_state_from_tb(VAR_0, tb, VAR_0->mem_io_pc); tb_phys_invalidate(tb, -1); }
[ "void FUNC_0(CPUState *VAR_0)\n{", "TranslationBlock *tb;", "tb = tb_find_pc(VAR_0->mem_io_pc);", "if (!tb) {", "cpu_abort(VAR_0, \"check_watchpoint: could not find TB for pc=%p\",\n(void *)VAR_0->mem_io_pc);", "}", "cpu_restore_state_from_tb(VAR_0, tb, VAR_0->mem_io_pc);", "tb_phys_invalidate(tb, -1);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13, 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ] ]
9,388
static void info_mice_iter(QObject *data, void *opaque) { QDict *mouse; Monitor *mon = opaque; mouse = qobject_to_qdict(data); monitor_printf(mon, "%c Mouse #%" PRId64 ": %s\n", (qdict_get_bool(mouse, "current") ? '*' : ' '), qdict_get_int(mouse, "index"), qdict_get_str(mouse, "name")); }
false
qemu
1aaee43cf7a43ca8e7f12883ee7e3a35fe5eb84c
static void info_mice_iter(QObject *data, void *opaque) { QDict *mouse; Monitor *mon = opaque; mouse = qobject_to_qdict(data); monitor_printf(mon, "%c Mouse #%" PRId64 ": %s\n", (qdict_get_bool(mouse, "current") ? '*' : ' '), qdict_get_int(mouse, "index"), qdict_get_str(mouse, "name")); }
{ "code": [], "line_no": [] }
static void FUNC_0(QObject *VAR_0, void *VAR_1) { QDict *mouse; Monitor *mon = VAR_1; mouse = qobject_to_qdict(VAR_0); monitor_printf(mon, "%c Mouse #%" PRId64 ": %s\n", (qdict_get_bool(mouse, "current") ? '*' : ' '), qdict_get_int(mouse, "index"), qdict_get_str(mouse, "name")); }
[ "static void FUNC_0(QObject *VAR_0, void *VAR_1)\n{", "QDict *mouse;", "Monitor *mon = VAR_1;", "mouse = qobject_to_qdict(VAR_0);", "monitor_printf(mon, \"%c Mouse #%\" PRId64 \": %s\\n\",\n(qdict_get_bool(mouse, \"current\") ? '*' : ' '),\nqdict_get_int(mouse, \"index\"), qdict_get_str(mouse, \"name\"));", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13, 15, 17 ], [ 19 ] ]
9,389
ram_addr_t qemu_ram_addr_from_host(void *ptr) { RAMBlock *prev; RAMBlock **prevp; RAMBlock *block; uint8_t *host = ptr; #ifdef CONFIG_KQEMU if (kqemu_phys_ram_base) { return host - kqemu_phys_ram_base; } #endif prev = NULL; prevp = &ram_blocks; block = ram_blocks; while (block && (block->host > host || block->host + block->length <= host)) { if (prev) prevp = &prev->next; prev = block; block = block->next; } if (!block) { fprintf(stderr, "Bad ram pointer %p\n", ptr); abort(); } return block->offset + (host - block->host); }
false
qemu
4a1418e07bdcfaa3177739e04707ecaec75d89e1
ram_addr_t qemu_ram_addr_from_host(void *ptr) { RAMBlock *prev; RAMBlock **prevp; RAMBlock *block; uint8_t *host = ptr; #ifdef CONFIG_KQEMU if (kqemu_phys_ram_base) { return host - kqemu_phys_ram_base; } #endif prev = NULL; prevp = &ram_blocks; block = ram_blocks; while (block && (block->host > host || block->host + block->length <= host)) { if (prev) prevp = &prev->next; prev = block; block = block->next; } if (!block) { fprintf(stderr, "Bad ram pointer %p\n", ptr); abort(); } return block->offset + (host - block->host); }
{ "code": [], "line_no": [] }
ram_addr_t FUNC_0(void *ptr) { RAMBlock *prev; RAMBlock **prevp; RAMBlock *block; uint8_t *host = ptr; #ifdef CONFIG_KQEMU if (kqemu_phys_ram_base) { return host - kqemu_phys_ram_base; } #endif prev = NULL; prevp = &ram_blocks; block = ram_blocks; while (block && (block->host > host || block->host + block->length <= host)) { if (prev) prevp = &prev->next; prev = block; block = block->next; } if (!block) { fprintf(stderr, "Bad ram pointer %p\n", ptr); abort(); } return block->offset + (host - block->host); }
[ "ram_addr_t FUNC_0(void *ptr)\n{", "RAMBlock *prev;", "RAMBlock **prevp;", "RAMBlock *block;", "uint8_t *host = ptr;", "#ifdef CONFIG_KQEMU\nif (kqemu_phys_ram_base) {", "return host - kqemu_phys_ram_base;", "}", "#endif\nprev = NULL;", "prevp = &ram_blocks;", "block = ram_blocks;", "while (block && (block->host > host\n|| block->host + block->length <= host)) {", "if (prev)\nprevp = &prev->next;", "prev = block;", "block = block->next;", "}", "if (!block) {", "fprintf(stderr, \"Bad ram pointer %p\\n\", ptr);", "abort();", "}", "return block->offset + (host - block->host);", "}" ]
[ 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, 27 ], [ 29 ], [ 31 ], [ 33, 35 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ] ]
9,391
static void fdt_add_cpu_nodes(const VirtBoardInfo *vbi) { int cpu; int addr_cells = 1; /* * From Documentation/devicetree/bindings/arm/cpus.txt * On ARM v8 64-bit systems value should be set to 2, * that corresponds to the MPIDR_EL1 register size. * If MPIDR_EL1[63:32] value is equal to 0 on all CPUs * in the system, #address-cells can be set to 1, since * MPIDR_EL1[63:32] bits are not used for CPUs * identification. * * Here we actually don't know whether our system is 32- or 64-bit one. * The simplest way to go is to examine affinity IDs of all our CPUs. If * at least one of them has Aff3 populated, we set #address-cells to 2. */ for (cpu = 0; cpu < vbi->smp_cpus; cpu++) { ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu)); if (armcpu->mp_affinity & ARM_AFF3_MASK) { addr_cells = 2; break; } } qemu_fdt_add_subnode(vbi->fdt, "/cpus"); qemu_fdt_setprop_cell(vbi->fdt, "/cpus", "#address-cells", addr_cells); qemu_fdt_setprop_cell(vbi->fdt, "/cpus", "#size-cells", 0x0); for (cpu = vbi->smp_cpus - 1; cpu >= 0; cpu--) { char *nodename = g_strdup_printf("/cpus/cpu@%d", cpu); ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu)); qemu_fdt_add_subnode(vbi->fdt, nodename); qemu_fdt_setprop_string(vbi->fdt, nodename, "device_type", "cpu"); qemu_fdt_setprop_string(vbi->fdt, nodename, "compatible", armcpu->dtb_compatible); if (vbi->smp_cpus > 1) { qemu_fdt_setprop_string(vbi->fdt, nodename, "enable-method", "psci"); } if (addr_cells == 2) { qemu_fdt_setprop_u64(vbi->fdt, nodename, "reg", armcpu->mp_affinity); } else { qemu_fdt_setprop_cell(vbi->fdt, nodename, "reg", armcpu->mp_affinity); } g_free(nodename); } }
false
qemu
4824a61a6dc1ce768be5c0a81f16224618104a63
static void fdt_add_cpu_nodes(const VirtBoardInfo *vbi) { int cpu; int addr_cells = 1; for (cpu = 0; cpu < vbi->smp_cpus; cpu++) { ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu)); if (armcpu->mp_affinity & ARM_AFF3_MASK) { addr_cells = 2; break; } } qemu_fdt_add_subnode(vbi->fdt, "/cpus"); qemu_fdt_setprop_cell(vbi->fdt, "/cpus", "#address-cells", addr_cells); qemu_fdt_setprop_cell(vbi->fdt, "/cpus", "#size-cells", 0x0); for (cpu = vbi->smp_cpus - 1; cpu >= 0; cpu--) { char *nodename = g_strdup_printf("/cpus/cpu@%d", cpu); ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu)); qemu_fdt_add_subnode(vbi->fdt, nodename); qemu_fdt_setprop_string(vbi->fdt, nodename, "device_type", "cpu"); qemu_fdt_setprop_string(vbi->fdt, nodename, "compatible", armcpu->dtb_compatible); if (vbi->smp_cpus > 1) { qemu_fdt_setprop_string(vbi->fdt, nodename, "enable-method", "psci"); } if (addr_cells == 2) { qemu_fdt_setprop_u64(vbi->fdt, nodename, "reg", armcpu->mp_affinity); } else { qemu_fdt_setprop_cell(vbi->fdt, nodename, "reg", armcpu->mp_affinity); } g_free(nodename); } }
{ "code": [], "line_no": [] }
static void FUNC_0(const VirtBoardInfo *VAR_0) { int VAR_1; int VAR_2 = 1; for (VAR_1 = 0; VAR_1 < VAR_0->smp_cpus; VAR_1++) { ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(VAR_1)); if (armcpu->mp_affinity & ARM_AFF3_MASK) { VAR_2 = 2; break; } } qemu_fdt_add_subnode(VAR_0->fdt, "/cpus"); qemu_fdt_setprop_cell(VAR_0->fdt, "/cpus", "#address-cells", VAR_2); qemu_fdt_setprop_cell(VAR_0->fdt, "/cpus", "#size-cells", 0x0); for (VAR_1 = VAR_0->smp_cpus - 1; VAR_1 >= 0; VAR_1--) { char *VAR_3 = g_strdup_printf("/cpus/VAR_1@%d", VAR_1); ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(VAR_1)); qemu_fdt_add_subnode(VAR_0->fdt, VAR_3); qemu_fdt_setprop_string(VAR_0->fdt, VAR_3, "device_type", "VAR_1"); qemu_fdt_setprop_string(VAR_0->fdt, VAR_3, "compatible", armcpu->dtb_compatible); if (VAR_0->smp_cpus > 1) { qemu_fdt_setprop_string(VAR_0->fdt, VAR_3, "enable-method", "psci"); } if (VAR_2 == 2) { qemu_fdt_setprop_u64(VAR_0->fdt, VAR_3, "reg", armcpu->mp_affinity); } else { qemu_fdt_setprop_cell(VAR_0->fdt, VAR_3, "reg", armcpu->mp_affinity); } g_free(VAR_3); } }
[ "static void FUNC_0(const VirtBoardInfo *VAR_0)\n{", "int VAR_1;", "int VAR_2 = 1;", "for (VAR_1 = 0; VAR_1 < VAR_0->smp_cpus; VAR_1++) {", "ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(VAR_1));", "if (armcpu->mp_affinity & ARM_AFF3_MASK) {", "VAR_2 = 2;", "break;", "}", "}", "qemu_fdt_add_subnode(VAR_0->fdt, \"/cpus\");", "qemu_fdt_setprop_cell(VAR_0->fdt, \"/cpus\", \"#address-cells\", VAR_2);", "qemu_fdt_setprop_cell(VAR_0->fdt, \"/cpus\", \"#size-cells\", 0x0);", "for (VAR_1 = VAR_0->smp_cpus - 1; VAR_1 >= 0; VAR_1--) {", "char *VAR_3 = g_strdup_printf(\"/cpus/VAR_1@%d\", VAR_1);", "ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(VAR_1));", "qemu_fdt_add_subnode(VAR_0->fdt, VAR_3);", "qemu_fdt_setprop_string(VAR_0->fdt, VAR_3, \"device_type\", \"VAR_1\");", "qemu_fdt_setprop_string(VAR_0->fdt, VAR_3, \"compatible\",\narmcpu->dtb_compatible);", "if (VAR_0->smp_cpus > 1) {", "qemu_fdt_setprop_string(VAR_0->fdt, VAR_3,\n\"enable-method\", \"psci\");", "}", "if (VAR_2 == 2) {", "qemu_fdt_setprop_u64(VAR_0->fdt, VAR_3, \"reg\",\narmcpu->mp_affinity);", "} else {", "qemu_fdt_setprop_cell(VAR_0->fdt, VAR_3, \"reg\",\narmcpu->mp_affinity);", "}", "g_free(VAR_3);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ], [ 75, 77 ], [ 81 ], [ 83, 85 ], [ 87 ], [ 91 ], [ 93, 95 ], [ 97 ], [ 99, 101 ], [ 103 ], [ 107 ], [ 109 ], [ 111 ] ]
9,392
static void scsi_write_complete_noio(SCSIDiskReq *r, int ret) { uint32_t n; assert (r->req.aiocb == NULL); if (r->req.io_canceled) { scsi_req_cancel_complete(&r->req); goto done; } if (ret < 0) { if (scsi_handle_rw_error(r, -ret, false)) { goto done; } } n = r->qiov.size / 512; r->sector += n; r->sector_count -= n; if (r->sector_count == 0) { scsi_write_do_fua(r); return; } else { scsi_init_iovec(r, SCSI_DMA_BUF_SIZE); DPRINTF("Write complete tag=0x%x more=%zd\n", r->req.tag, r->qiov.size); scsi_req_data(&r->req, r->qiov.size); } done: scsi_req_unref(&r->req); }
false
qemu
5b956f415a356449a4171d5e0c7d9a25bbc84b5a
static void scsi_write_complete_noio(SCSIDiskReq *r, int ret) { uint32_t n; assert (r->req.aiocb == NULL); if (r->req.io_canceled) { scsi_req_cancel_complete(&r->req); goto done; } if (ret < 0) { if (scsi_handle_rw_error(r, -ret, false)) { goto done; } } n = r->qiov.size / 512; r->sector += n; r->sector_count -= n; if (r->sector_count == 0) { scsi_write_do_fua(r); return; } else { scsi_init_iovec(r, SCSI_DMA_BUF_SIZE); DPRINTF("Write complete tag=0x%x more=%zd\n", r->req.tag, r->qiov.size); scsi_req_data(&r->req, r->qiov.size); } done: scsi_req_unref(&r->req); }
{ "code": [], "line_no": [] }
static void FUNC_0(SCSIDiskReq *VAR_0, int VAR_1) { uint32_t n; assert (VAR_0->req.aiocb == NULL); if (VAR_0->req.io_canceled) { scsi_req_cancel_complete(&VAR_0->req); goto done; } if (VAR_1 < 0) { if (scsi_handle_rw_error(VAR_0, -VAR_1, false)) { goto done; } } n = VAR_0->qiov.size / 512; VAR_0->sector += n; VAR_0->sector_count -= n; if (VAR_0->sector_count == 0) { scsi_write_do_fua(VAR_0); return; } else { scsi_init_iovec(VAR_0, SCSI_DMA_BUF_SIZE); DPRINTF("Write complete tag=0x%x more=%zd\n", VAR_0->req.tag, VAR_0->qiov.size); scsi_req_data(&VAR_0->req, VAR_0->qiov.size); } done: scsi_req_unref(&VAR_0->req); }
[ "static void FUNC_0(SCSIDiskReq *VAR_0, int VAR_1)\n{", "uint32_t n;", "assert (VAR_0->req.aiocb == NULL);", "if (VAR_0->req.io_canceled) {", "scsi_req_cancel_complete(&VAR_0->req);", "goto done;", "}", "if (VAR_1 < 0) {", "if (scsi_handle_rw_error(VAR_0, -VAR_1, false)) {", "goto done;", "}", "}", "n = VAR_0->qiov.size / 512;", "VAR_0->sector += n;", "VAR_0->sector_count -= n;", "if (VAR_0->sector_count == 0) {", "scsi_write_do_fua(VAR_0);", "return;", "} else {", "scsi_init_iovec(VAR_0, SCSI_DMA_BUF_SIZE);", "DPRINTF(\"Write complete tag=0x%x more=%zd\\n\", VAR_0->req.tag, VAR_0->qiov.size);", "scsi_req_data(&VAR_0->req, VAR_0->qiov.size);", "}", "done:\nscsi_req_unref(&VAR_0->req);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59, 61 ], [ 63 ] ]
9,393
iscsi_co_writev_flags(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *iov, int flags) { IscsiLun *iscsilun = bs->opaque; struct IscsiTask iTask; uint64_t lba; uint32_t num_sectors; bool fua = flags & BDRV_REQ_FUA; if (fua) { assert(iscsilun->dpofua); } if (!is_sector_request_lun_aligned(sector_num, nb_sectors, iscsilun)) { return -EINVAL; } if (bs->bl.max_transfer_length && nb_sectors > bs->bl.max_transfer_length) { error_report("iSCSI Error: Write of %d sectors exceeds max_xfer_len " "of %d sectors", nb_sectors, bs->bl.max_transfer_length); return -EINVAL; } lba = sector_qemu2lun(sector_num, iscsilun); num_sectors = sector_qemu2lun(nb_sectors, iscsilun); iscsi_co_init_iscsitask(iscsilun, &iTask); retry: if (iscsilun->use_16_for_rw) { iTask.task = iscsi_write16_task(iscsilun->iscsi, iscsilun->lun, lba, NULL, num_sectors * iscsilun->block_size, iscsilun->block_size, 0, 0, fua, 0, 0, iscsi_co_generic_cb, &iTask); } else { iTask.task = iscsi_write10_task(iscsilun->iscsi, iscsilun->lun, lba, NULL, num_sectors * iscsilun->block_size, iscsilun->block_size, 0, 0, fua, 0, 0, iscsi_co_generic_cb, &iTask); } if (iTask.task == NULL) { return -ENOMEM; } scsi_task_set_iov_out(iTask.task, (struct scsi_iovec *) iov->iov, iov->niov); while (!iTask.complete) { iscsi_set_events(iscsilun); qemu_coroutine_yield(); } if (iTask.task != NULL) { scsi_free_scsi_task(iTask.task); iTask.task = NULL; } if (iTask.do_retry) { iTask.complete = 0; goto retry; } if (iTask.status != SCSI_STATUS_GOOD) { return iTask.err_code; } iscsi_allocationmap_set(iscsilun, sector_num, nb_sectors); return 0; }
false
qemu
5def6b80e1eca696c1fc6099e7f4d36729686402
iscsi_co_writev_flags(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *iov, int flags) { IscsiLun *iscsilun = bs->opaque; struct IscsiTask iTask; uint64_t lba; uint32_t num_sectors; bool fua = flags & BDRV_REQ_FUA; if (fua) { assert(iscsilun->dpofua); } if (!is_sector_request_lun_aligned(sector_num, nb_sectors, iscsilun)) { return -EINVAL; } if (bs->bl.max_transfer_length && nb_sectors > bs->bl.max_transfer_length) { error_report("iSCSI Error: Write of %d sectors exceeds max_xfer_len " "of %d sectors", nb_sectors, bs->bl.max_transfer_length); return -EINVAL; } lba = sector_qemu2lun(sector_num, iscsilun); num_sectors = sector_qemu2lun(nb_sectors, iscsilun); iscsi_co_init_iscsitask(iscsilun, &iTask); retry: if (iscsilun->use_16_for_rw) { iTask.task = iscsi_write16_task(iscsilun->iscsi, iscsilun->lun, lba, NULL, num_sectors * iscsilun->block_size, iscsilun->block_size, 0, 0, fua, 0, 0, iscsi_co_generic_cb, &iTask); } else { iTask.task = iscsi_write10_task(iscsilun->iscsi, iscsilun->lun, lba, NULL, num_sectors * iscsilun->block_size, iscsilun->block_size, 0, 0, fua, 0, 0, iscsi_co_generic_cb, &iTask); } if (iTask.task == NULL) { return -ENOMEM; } scsi_task_set_iov_out(iTask.task, (struct scsi_iovec *) iov->iov, iov->niov); while (!iTask.complete) { iscsi_set_events(iscsilun); qemu_coroutine_yield(); } if (iTask.task != NULL) { scsi_free_scsi_task(iTask.task); iTask.task = NULL; } if (iTask.do_retry) { iTask.complete = 0; goto retry; } if (iTask.status != SCSI_STATUS_GOOD) { return iTask.err_code; } iscsi_allocationmap_set(iscsilun, sector_num, nb_sectors); return 0; }
{ "code": [], "line_no": [] }
FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1, int VAR_2, QEMUIOVector *VAR_3, int VAR_4) { IscsiLun *iscsilun = VAR_0->opaque; struct IscsiTask VAR_5; uint64_t lba; uint32_t num_sectors; bool fua = VAR_4 & BDRV_REQ_FUA; if (fua) { assert(iscsilun->dpofua); } if (!is_sector_request_lun_aligned(VAR_1, VAR_2, iscsilun)) { return -EINVAL; } if (VAR_0->bl.max_transfer_length && VAR_2 > VAR_0->bl.max_transfer_length) { error_report("iSCSI Error: Write of %d sectors exceeds max_xfer_len " "of %d sectors", VAR_2, VAR_0->bl.max_transfer_length); return -EINVAL; } lba = sector_qemu2lun(VAR_1, iscsilun); num_sectors = sector_qemu2lun(VAR_2, iscsilun); iscsi_co_init_iscsitask(iscsilun, &VAR_5); retry: if (iscsilun->use_16_for_rw) { VAR_5.task = iscsi_write16_task(iscsilun->iscsi, iscsilun->lun, lba, NULL, num_sectors * iscsilun->block_size, iscsilun->block_size, 0, 0, fua, 0, 0, iscsi_co_generic_cb, &VAR_5); } else { VAR_5.task = iscsi_write10_task(iscsilun->iscsi, iscsilun->lun, lba, NULL, num_sectors * iscsilun->block_size, iscsilun->block_size, 0, 0, fua, 0, 0, iscsi_co_generic_cb, &VAR_5); } if (VAR_5.task == NULL) { return -ENOMEM; } scsi_task_set_iov_out(VAR_5.task, (struct scsi_iovec *) VAR_3->VAR_3, VAR_3->niov); while (!VAR_5.complete) { iscsi_set_events(iscsilun); qemu_coroutine_yield(); } if (VAR_5.task != NULL) { scsi_free_scsi_task(VAR_5.task); VAR_5.task = NULL; } if (VAR_5.do_retry) { VAR_5.complete = 0; goto retry; } if (VAR_5.status != SCSI_STATUS_GOOD) { return VAR_5.err_code; } iscsi_allocationmap_set(iscsilun, VAR_1, VAR_2); return 0; }
[ "FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1, int VAR_2,\nQEMUIOVector *VAR_3, int VAR_4)\n{", "IscsiLun *iscsilun = VAR_0->opaque;", "struct IscsiTask VAR_5;", "uint64_t lba;", "uint32_t num_sectors;", "bool fua = VAR_4 & BDRV_REQ_FUA;", "if (fua) {", "assert(iscsilun->dpofua);", "}", "if (!is_sector_request_lun_aligned(VAR_1, VAR_2, iscsilun)) {", "return -EINVAL;", "}", "if (VAR_0->bl.max_transfer_length && VAR_2 > VAR_0->bl.max_transfer_length) {", "error_report(\"iSCSI Error: Write of %d sectors exceeds max_xfer_len \"\n\"of %d sectors\", VAR_2, VAR_0->bl.max_transfer_length);", "return -EINVAL;", "}", "lba = sector_qemu2lun(VAR_1, iscsilun);", "num_sectors = sector_qemu2lun(VAR_2, iscsilun);", "iscsi_co_init_iscsitask(iscsilun, &VAR_5);", "retry:\nif (iscsilun->use_16_for_rw) {", "VAR_5.task = iscsi_write16_task(iscsilun->iscsi, iscsilun->lun, lba,\nNULL, num_sectors * iscsilun->block_size,\niscsilun->block_size, 0, 0, fua, 0, 0,\niscsi_co_generic_cb, &VAR_5);", "} else {", "VAR_5.task = iscsi_write10_task(iscsilun->iscsi, iscsilun->lun, lba,\nNULL, num_sectors * iscsilun->block_size,\niscsilun->block_size, 0, 0, fua, 0, 0,\niscsi_co_generic_cb, &VAR_5);", "}", "if (VAR_5.task == NULL) {", "return -ENOMEM;", "}", "scsi_task_set_iov_out(VAR_5.task, (struct scsi_iovec *) VAR_3->VAR_3,\nVAR_3->niov);", "while (!VAR_5.complete) {", "iscsi_set_events(iscsilun);", "qemu_coroutine_yield();", "}", "if (VAR_5.task != NULL) {", "scsi_free_scsi_task(VAR_5.task);", "VAR_5.task = NULL;", "}", "if (VAR_5.do_retry) {", "VAR_5.complete = 0;", "goto retry;", "}", "if (VAR_5.status != SCSI_STATUS_GOOD) {", "return VAR_5.err_code;", "}", "iscsi_allocationmap_set(iscsilun, VAR_1, VAR_2);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35, 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51, 53 ], [ 55, 57, 59, 61 ], [ 63 ], [ 65, 67, 69, 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81, 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 115 ], [ 117 ], [ 119 ], [ 123 ], [ 127 ], [ 129 ] ]
9,394
void av_set_cpu_flags_mask(int mask) { checked = 0; flags = av_get_cpu_flags() & mask; checked = 1; }
false
FFmpeg
29fb49194bedc74ac9be0b49b6b42dcfeb6222d9
void av_set_cpu_flags_mask(int mask) { checked = 0; flags = av_get_cpu_flags() & mask; checked = 1; }
{ "code": [], "line_no": [] }
void FUNC_0(int VAR_0) { checked = 0; flags = av_get_cpu_flags() & VAR_0; checked = 1; }
[ "void FUNC_0(int VAR_0)\n{", "checked = 0;", "flags = av_get_cpu_flags() & VAR_0;", "checked = 1;", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ] ]
9,395
static bool cmd_read_multiple(IDEState *s, uint8_t cmd) { bool lba48 = (cmd == WIN_MULTREAD_EXT); if (!s->bs || !s->mult_sectors) { ide_abort_command(s); return true; } ide_cmd_lba48_transform(s, lba48); s->req_nb_sectors = s->mult_sectors; ide_sector_read(s); return false; }
false
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
static bool cmd_read_multiple(IDEState *s, uint8_t cmd) { bool lba48 = (cmd == WIN_MULTREAD_EXT); if (!s->bs || !s->mult_sectors) { ide_abort_command(s); return true; } ide_cmd_lba48_transform(s, lba48); s->req_nb_sectors = s->mult_sectors; ide_sector_read(s); return false; }
{ "code": [], "line_no": [] }
static bool FUNC_0(IDEState *s, uint8_t cmd) { bool lba48 = (cmd == WIN_MULTREAD_EXT); if (!s->bs || !s->mult_sectors) { ide_abort_command(s); return true; } ide_cmd_lba48_transform(s, lba48); s->req_nb_sectors = s->mult_sectors; ide_sector_read(s); return false; }
[ "static bool FUNC_0(IDEState *s, uint8_t cmd)\n{", "bool lba48 = (cmd == WIN_MULTREAD_EXT);", "if (!s->bs || !s->mult_sectors) {", "ide_abort_command(s);", "return true;", "}", "ide_cmd_lba48_transform(s, lba48);", "s->req_nb_sectors = s->mult_sectors;", "ide_sector_read(s);", "return false;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ] ]
9,396
static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; MemTxAttrs attrs = {}; AddressSpace *as; attrs.secure = is_secure; as = arm_addressspace(cs, attrs); addr = S1_ptw_translate(env, mmu_idx, addr, attrs, fi); if (fi->s1ptw) { return 0; } if (regime_translation_big_endian(env, mmu_idx)) { return address_space_ldq_be(as, addr, attrs, NULL); } else { return address_space_ldq_le(as, addr, attrs, NULL); } }
true
qemu
3b39d734141a71296d08af3d4c32f872fafd782e
static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; MemTxAttrs attrs = {}; AddressSpace *as; attrs.secure = is_secure; as = arm_addressspace(cs, attrs); addr = S1_ptw_translate(env, mmu_idx, addr, attrs, fi); if (fi->s1ptw) { return 0; } if (regime_translation_big_endian(env, mmu_idx)) { return address_space_ldq_be(as, addr, attrs, NULL); } else { return address_space_ldq_le(as, addr, attrs, NULL); } }
{ "code": [ " return address_space_ldq_be(as, addr, attrs, NULL);", " return address_space_ldq_le(as, addr, attrs, NULL);" ], "line_no": [ 31, 35 ] }
static uint64_t FUNC_0(CPUState *cs, hwaddr addr, bool is_secure, ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; MemTxAttrs attrs = {}; AddressSpace *as; attrs.secure = is_secure; as = arm_addressspace(cs, attrs); addr = S1_ptw_translate(env, mmu_idx, addr, attrs, fi); if (fi->s1ptw) { return 0; } if (regime_translation_big_endian(env, mmu_idx)) { return address_space_ldq_be(as, addr, attrs, NULL); } else { return address_space_ldq_le(as, addr, attrs, NULL); } }
[ "static uint64_t FUNC_0(CPUState *cs, hwaddr addr, bool is_secure,\nARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi)\n{", "ARMCPU *cpu = ARM_CPU(cs);", "CPUARMState *env = &cpu->env;", "MemTxAttrs attrs = {};", "AddressSpace *as;", "attrs.secure = is_secure;", "as = arm_addressspace(cs, attrs);", "addr = S1_ptw_translate(env, mmu_idx, addr, attrs, fi);", "if (fi->s1ptw) {", "return 0;", "}", "if (regime_translation_big_endian(env, mmu_idx)) {", "return address_space_ldq_be(as, addr, attrs, NULL);", "} else {", "return address_space_ldq_le(as, addr, attrs, NULL);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ] ]
9,397
static void gen_adc(TCGv t0, TCGv t1) { TCGv tmp; tcg_gen_add_i32(t0, t0, t1); tmp = load_cpu_field(CF); tcg_gen_add_i32(t0, t0, tmp); dead_tmp(tmp); }
true
qemu
7d1b0095bff7157e856d1d0e6c4295641ced2752
static void gen_adc(TCGv t0, TCGv t1) { TCGv tmp; tcg_gen_add_i32(t0, t0, t1); tmp = load_cpu_field(CF); tcg_gen_add_i32(t0, t0, tmp); dead_tmp(tmp); }
{ "code": [ " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);" ], "line_no": [ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13 ] }
static void FUNC_0(TCGv VAR_0, TCGv VAR_1) { TCGv tmp; tcg_gen_add_i32(VAR_0, VAR_0, VAR_1); tmp = load_cpu_field(CF); tcg_gen_add_i32(VAR_0, VAR_0, tmp); dead_tmp(tmp); }
[ "static void FUNC_0(TCGv VAR_0, TCGv VAR_1)\n{", "TCGv tmp;", "tcg_gen_add_i32(VAR_0, VAR_0, VAR_1);", "tmp = load_cpu_field(CF);", "tcg_gen_add_i32(VAR_0, VAR_0, tmp);", "dead_tmp(tmp);", "}" ]
[ 0, 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ] ]
9,398
static int g723_1_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { G723_1_Context *p = avctx->priv_data; AVFrame *frame = data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; int dec_mode = buf[0] & 3; PPFParam ppf[SUBFRAMES]; int16_t cur_lsp[LPC_ORDER]; int16_t lpc[SUBFRAMES * LPC_ORDER]; int16_t acb_vector[SUBFRAME_LEN]; int16_t *out; int bad_frame = 0, i, j, ret; int16_t *audio = p->audio; if (buf_size < frame_size[dec_mode]) { if (buf_size) av_log(avctx, AV_LOG_WARNING, "Expected %d bytes, got %d - skipping packet\n", frame_size[dec_mode], buf_size); *got_frame_ptr = 0; return buf_size; } if (unpack_bitstream(p, buf, buf_size) < 0) { bad_frame = 1; if (p->past_frame_type == ACTIVE_FRAME) p->cur_frame_type = ACTIVE_FRAME; else p->cur_frame_type = UNTRANSMITTED_FRAME; } frame->nb_samples = FRAME_LEN; if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; out = (int16_t *)frame->data[0]; if (p->cur_frame_type == ACTIVE_FRAME) { if (!bad_frame) p->erased_frames = 0; else if (p->erased_frames != 3) p->erased_frames++; ff_g723_1_inverse_quant(cur_lsp, p->prev_lsp, p->lsp_index, bad_frame); ff_g723_1_lsp_interpolate(lpc, cur_lsp, p->prev_lsp); /* Save the lsp_vector for the next frame */ memcpy(p->prev_lsp, cur_lsp, LPC_ORDER * sizeof(*p->prev_lsp)); /* Generate the excitation for the frame */ memcpy(p->excitation, p->prev_excitation, PITCH_MAX * sizeof(*p->excitation)); if (!p->erased_frames) { int16_t *vector_ptr = p->excitation + PITCH_MAX; /* Update interpolation gain memory */ p->interp_gain = fixed_cb_gain[(p->subframe[2].amp_index + p->subframe[3].amp_index) >> 1]; for (i = 0; i < SUBFRAMES; i++) { gen_fcb_excitation(vector_ptr, &p->subframe[i], p->cur_rate, p->pitch_lag[i >> 1], i); ff_g723_1_gen_acb_excitation(acb_vector, &p->excitation[SUBFRAME_LEN * i], p->pitch_lag[i >> 1], &p->subframe[i], p->cur_rate); /* Get the total excitation */ for (j = 0; j < SUBFRAME_LEN; j++) { int v = av_clip_int16(vector_ptr[j] << 1); vector_ptr[j] = av_clip_int16(v + acb_vector[j]); } vector_ptr += SUBFRAME_LEN; } vector_ptr = p->excitation + PITCH_MAX; p->interp_index = comp_interp_index(p, p->pitch_lag[1], &p->sid_gain, &p->cur_gain); /* Perform pitch postfiltering */ if (p->postfilter) { i = PITCH_MAX; for (j = 0; j < SUBFRAMES; i += SUBFRAME_LEN, j++) comp_ppf_coeff(p, i, p->pitch_lag[j >> 1], ppf + j, p->cur_rate); for (i = 0, j = 0; j < SUBFRAMES; i += SUBFRAME_LEN, j++) ff_acelp_weighted_vector_sum(p->audio + LPC_ORDER + i, vector_ptr + i, vector_ptr + i + ppf[j].index, ppf[j].sc_gain, ppf[j].opt_gain, 1 << 14, 15, SUBFRAME_LEN); } else { audio = vector_ptr - LPC_ORDER; } /* Save the excitation for the next frame */ memcpy(p->prev_excitation, p->excitation + FRAME_LEN, PITCH_MAX * sizeof(*p->excitation)); } else { p->interp_gain = (p->interp_gain * 3 + 2) >> 2; if (p->erased_frames == 3) { /* Mute output */ memset(p->excitation, 0, (FRAME_LEN + PITCH_MAX) * sizeof(*p->excitation)); memset(p->prev_excitation, 0, PITCH_MAX * sizeof(*p->excitation)); memset(frame->data[0], 0, (FRAME_LEN + LPC_ORDER) * sizeof(int16_t)); } else { int16_t *buf = p->audio + LPC_ORDER; /* Regenerate frame */ residual_interp(p->excitation, buf, p->interp_index, p->interp_gain, &p->random_seed); /* Save the excitation for the next frame */ memcpy(p->prev_excitation, buf + (FRAME_LEN - PITCH_MAX), PITCH_MAX * sizeof(*p->excitation)); } } p->cng_random_seed = CNG_RANDOM_SEED; } else { if (p->cur_frame_type == SID_FRAME) { p->sid_gain = sid_gain_to_lsp_index(p->subframe[0].amp_index); ff_g723_1_inverse_quant(p->sid_lsp, p->prev_lsp, p->lsp_index, 0); } else if (p->past_frame_type == ACTIVE_FRAME) { p->sid_gain = estimate_sid_gain(p); } if (p->past_frame_type == ACTIVE_FRAME) p->cur_gain = p->sid_gain; else p->cur_gain = (p->cur_gain * 7 + p->sid_gain) >> 3; generate_noise(p); ff_g723_1_lsp_interpolate(lpc, p->sid_lsp, p->prev_lsp); /* Save the lsp_vector for the next frame */ memcpy(p->prev_lsp, p->sid_lsp, LPC_ORDER * sizeof(*p->prev_lsp)); } p->past_frame_type = p->cur_frame_type; memcpy(p->audio, p->synth_mem, LPC_ORDER * sizeof(*p->audio)); for (i = LPC_ORDER, j = 0; j < SUBFRAMES; i += SUBFRAME_LEN, j++) ff_celp_lp_synthesis_filter(p->audio + i, &lpc[j * LPC_ORDER], audio + i, SUBFRAME_LEN, LPC_ORDER, 0, 1, 1 << 12); memcpy(p->synth_mem, p->audio + FRAME_LEN, LPC_ORDER * sizeof(*p->audio)); if (p->postfilter) { formant_postfilter(p, lpc, p->audio, out); } else { // if output is not postfiltered it should be scaled by 2 for (i = 0; i < FRAME_LEN; i++) out[i] = av_clip_int16(p->audio[LPC_ORDER + i] << 1); } *got_frame_ptr = 1; return frame_size[dec_mode]; }
true
FFmpeg
4ace2d22192f3995911ec926940125dcb29d606a
static int g723_1_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { G723_1_Context *p = avctx->priv_data; AVFrame *frame = data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; int dec_mode = buf[0] & 3; PPFParam ppf[SUBFRAMES]; int16_t cur_lsp[LPC_ORDER]; int16_t lpc[SUBFRAMES * LPC_ORDER]; int16_t acb_vector[SUBFRAME_LEN]; int16_t *out; int bad_frame = 0, i, j, ret; int16_t *audio = p->audio; if (buf_size < frame_size[dec_mode]) { if (buf_size) av_log(avctx, AV_LOG_WARNING, "Expected %d bytes, got %d - skipping packet\n", frame_size[dec_mode], buf_size); *got_frame_ptr = 0; return buf_size; } if (unpack_bitstream(p, buf, buf_size) < 0) { bad_frame = 1; if (p->past_frame_type == ACTIVE_FRAME) p->cur_frame_type = ACTIVE_FRAME; else p->cur_frame_type = UNTRANSMITTED_FRAME; } frame->nb_samples = FRAME_LEN; if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; out = (int16_t *)frame->data[0]; if (p->cur_frame_type == ACTIVE_FRAME) { if (!bad_frame) p->erased_frames = 0; else if (p->erased_frames != 3) p->erased_frames++; ff_g723_1_inverse_quant(cur_lsp, p->prev_lsp, p->lsp_index, bad_frame); ff_g723_1_lsp_interpolate(lpc, cur_lsp, p->prev_lsp); memcpy(p->prev_lsp, cur_lsp, LPC_ORDER * sizeof(*p->prev_lsp)); memcpy(p->excitation, p->prev_excitation, PITCH_MAX * sizeof(*p->excitation)); if (!p->erased_frames) { int16_t *vector_ptr = p->excitation + PITCH_MAX; p->interp_gain = fixed_cb_gain[(p->subframe[2].amp_index + p->subframe[3].amp_index) >> 1]; for (i = 0; i < SUBFRAMES; i++) { gen_fcb_excitation(vector_ptr, &p->subframe[i], p->cur_rate, p->pitch_lag[i >> 1], i); ff_g723_1_gen_acb_excitation(acb_vector, &p->excitation[SUBFRAME_LEN * i], p->pitch_lag[i >> 1], &p->subframe[i], p->cur_rate); for (j = 0; j < SUBFRAME_LEN; j++) { int v = av_clip_int16(vector_ptr[j] << 1); vector_ptr[j] = av_clip_int16(v + acb_vector[j]); } vector_ptr += SUBFRAME_LEN; } vector_ptr = p->excitation + PITCH_MAX; p->interp_index = comp_interp_index(p, p->pitch_lag[1], &p->sid_gain, &p->cur_gain); if (p->postfilter) { i = PITCH_MAX; for (j = 0; j < SUBFRAMES; i += SUBFRAME_LEN, j++) comp_ppf_coeff(p, i, p->pitch_lag[j >> 1], ppf + j, p->cur_rate); for (i = 0, j = 0; j < SUBFRAMES; i += SUBFRAME_LEN, j++) ff_acelp_weighted_vector_sum(p->audio + LPC_ORDER + i, vector_ptr + i, vector_ptr + i + ppf[j].index, ppf[j].sc_gain, ppf[j].opt_gain, 1 << 14, 15, SUBFRAME_LEN); } else { audio = vector_ptr - LPC_ORDER; } memcpy(p->prev_excitation, p->excitation + FRAME_LEN, PITCH_MAX * sizeof(*p->excitation)); } else { p->interp_gain = (p->interp_gain * 3 + 2) >> 2; if (p->erased_frames == 3) { memset(p->excitation, 0, (FRAME_LEN + PITCH_MAX) * sizeof(*p->excitation)); memset(p->prev_excitation, 0, PITCH_MAX * sizeof(*p->excitation)); memset(frame->data[0], 0, (FRAME_LEN + LPC_ORDER) * sizeof(int16_t)); } else { int16_t *buf = p->audio + LPC_ORDER; residual_interp(p->excitation, buf, p->interp_index, p->interp_gain, &p->random_seed); memcpy(p->prev_excitation, buf + (FRAME_LEN - PITCH_MAX), PITCH_MAX * sizeof(*p->excitation)); } } p->cng_random_seed = CNG_RANDOM_SEED; } else { if (p->cur_frame_type == SID_FRAME) { p->sid_gain = sid_gain_to_lsp_index(p->subframe[0].amp_index); ff_g723_1_inverse_quant(p->sid_lsp, p->prev_lsp, p->lsp_index, 0); } else if (p->past_frame_type == ACTIVE_FRAME) { p->sid_gain = estimate_sid_gain(p); } if (p->past_frame_type == ACTIVE_FRAME) p->cur_gain = p->sid_gain; else p->cur_gain = (p->cur_gain * 7 + p->sid_gain) >> 3; generate_noise(p); ff_g723_1_lsp_interpolate(lpc, p->sid_lsp, p->prev_lsp); memcpy(p->prev_lsp, p->sid_lsp, LPC_ORDER * sizeof(*p->prev_lsp)); } p->past_frame_type = p->cur_frame_type; memcpy(p->audio, p->synth_mem, LPC_ORDER * sizeof(*p->audio)); for (i = LPC_ORDER, j = 0; j < SUBFRAMES; i += SUBFRAME_LEN, j++) ff_celp_lp_synthesis_filter(p->audio + i, &lpc[j * LPC_ORDER], audio + i, SUBFRAME_LEN, LPC_ORDER, 0, 1, 1 << 12); memcpy(p->synth_mem, p->audio + FRAME_LEN, LPC_ORDER * sizeof(*p->audio)); if (p->postfilter) { formant_postfilter(p, lpc, p->audio, out); } else { for (i = 0; i < FRAME_LEN; i++) out[i] = av_clip_int16(p->audio[LPC_ORDER + i] << 1); } *got_frame_ptr = 1; return frame_size[dec_mode]; }
{ "code": [ " int v = av_clip_int16(vector_ptr[j] << 1);" ], "line_no": [ 141 ] }
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, AVPacket *VAR_3) { G723_1_Context *p = VAR_0->priv_data; AVFrame *frame = VAR_1; const uint8_t *VAR_4 = VAR_3->VAR_1; int VAR_5 = VAR_3->size; int VAR_6 = VAR_4[0] & 3; PPFParam ppf[SUBFRAMES]; int16_t cur_lsp[LPC_ORDER]; int16_t lpc[SUBFRAMES * LPC_ORDER]; int16_t acb_vector[SUBFRAME_LEN]; int16_t *out; int VAR_7 = 0, VAR_8, VAR_9, VAR_10; int16_t *audio = p->audio; if (VAR_5 < frame_size[VAR_6]) { if (VAR_5) av_log(VAR_0, AV_LOG_WARNING, "Expected %d bytes, got %d - skipping packet\n", frame_size[VAR_6], VAR_5); *VAR_2 = 0; return VAR_5; } if (unpack_bitstream(p, VAR_4, VAR_5) < 0) { VAR_7 = 1; if (p->past_frame_type == ACTIVE_FRAME) p->cur_frame_type = ACTIVE_FRAME; else p->cur_frame_type = UNTRANSMITTED_FRAME; } frame->nb_samples = FRAME_LEN; if ((VAR_10 = ff_get_buffer(VAR_0, frame, 0)) < 0) return VAR_10; out = (int16_t *)frame->VAR_1[0]; if (p->cur_frame_type == ACTIVE_FRAME) { if (!VAR_7) p->erased_frames = 0; else if (p->erased_frames != 3) p->erased_frames++; ff_g723_1_inverse_quant(cur_lsp, p->prev_lsp, p->lsp_index, VAR_7); ff_g723_1_lsp_interpolate(lpc, cur_lsp, p->prev_lsp); memcpy(p->prev_lsp, cur_lsp, LPC_ORDER * sizeof(*p->prev_lsp)); memcpy(p->excitation, p->prev_excitation, PITCH_MAX * sizeof(*p->excitation)); if (!p->erased_frames) { int16_t *vector_ptr = p->excitation + PITCH_MAX; p->interp_gain = fixed_cb_gain[(p->subframe[2].amp_index + p->subframe[3].amp_index) >> 1]; for (VAR_8 = 0; VAR_8 < SUBFRAMES; VAR_8++) { gen_fcb_excitation(vector_ptr, &p->subframe[VAR_8], p->cur_rate, p->pitch_lag[VAR_8 >> 1], VAR_8); ff_g723_1_gen_acb_excitation(acb_vector, &p->excitation[SUBFRAME_LEN * VAR_8], p->pitch_lag[VAR_8 >> 1], &p->subframe[VAR_8], p->cur_rate); for (VAR_9 = 0; VAR_9 < SUBFRAME_LEN; VAR_9++) { int v = av_clip_int16(vector_ptr[VAR_9] << 1); vector_ptr[VAR_9] = av_clip_int16(v + acb_vector[VAR_9]); } vector_ptr += SUBFRAME_LEN; } vector_ptr = p->excitation + PITCH_MAX; p->interp_index = comp_interp_index(p, p->pitch_lag[1], &p->sid_gain, &p->cur_gain); if (p->postfilter) { VAR_8 = PITCH_MAX; for (VAR_9 = 0; VAR_9 < SUBFRAMES; VAR_8 += SUBFRAME_LEN, VAR_9++) comp_ppf_coeff(p, VAR_8, p->pitch_lag[VAR_9 >> 1], ppf + VAR_9, p->cur_rate); for (VAR_8 = 0, VAR_9 = 0; VAR_9 < SUBFRAMES; VAR_8 += SUBFRAME_LEN, VAR_9++) ff_acelp_weighted_vector_sum(p->audio + LPC_ORDER + VAR_8, vector_ptr + VAR_8, vector_ptr + VAR_8 + ppf[VAR_9].index, ppf[VAR_9].sc_gain, ppf[VAR_9].opt_gain, 1 << 14, 15, SUBFRAME_LEN); } else { audio = vector_ptr - LPC_ORDER; } memcpy(p->prev_excitation, p->excitation + FRAME_LEN, PITCH_MAX * sizeof(*p->excitation)); } else { p->interp_gain = (p->interp_gain * 3 + 2) >> 2; if (p->erased_frames == 3) { memset(p->excitation, 0, (FRAME_LEN + PITCH_MAX) * sizeof(*p->excitation)); memset(p->prev_excitation, 0, PITCH_MAX * sizeof(*p->excitation)); memset(frame->VAR_1[0], 0, (FRAME_LEN + LPC_ORDER) * sizeof(int16_t)); } else { int16_t *VAR_4 = p->audio + LPC_ORDER; residual_interp(p->excitation, VAR_4, p->interp_index, p->interp_gain, &p->random_seed); memcpy(p->prev_excitation, VAR_4 + (FRAME_LEN - PITCH_MAX), PITCH_MAX * sizeof(*p->excitation)); } } p->cng_random_seed = CNG_RANDOM_SEED; } else { if (p->cur_frame_type == SID_FRAME) { p->sid_gain = sid_gain_to_lsp_index(p->subframe[0].amp_index); ff_g723_1_inverse_quant(p->sid_lsp, p->prev_lsp, p->lsp_index, 0); } else if (p->past_frame_type == ACTIVE_FRAME) { p->sid_gain = estimate_sid_gain(p); } if (p->past_frame_type == ACTIVE_FRAME) p->cur_gain = p->sid_gain; else p->cur_gain = (p->cur_gain * 7 + p->sid_gain) >> 3; generate_noise(p); ff_g723_1_lsp_interpolate(lpc, p->sid_lsp, p->prev_lsp); memcpy(p->prev_lsp, p->sid_lsp, LPC_ORDER * sizeof(*p->prev_lsp)); } p->past_frame_type = p->cur_frame_type; memcpy(p->audio, p->synth_mem, LPC_ORDER * sizeof(*p->audio)); for (VAR_8 = LPC_ORDER, VAR_9 = 0; VAR_9 < SUBFRAMES; VAR_8 += SUBFRAME_LEN, VAR_9++) ff_celp_lp_synthesis_filter(p->audio + VAR_8, &lpc[VAR_9 * LPC_ORDER], audio + VAR_8, SUBFRAME_LEN, LPC_ORDER, 0, 1, 1 << 12); memcpy(p->synth_mem, p->audio + FRAME_LEN, LPC_ORDER * sizeof(*p->audio)); if (p->postfilter) { formant_postfilter(p, lpc, p->audio, out); } else { for (VAR_8 = 0; VAR_8 < FRAME_LEN; VAR_8++) out[VAR_8] = av_clip_int16(p->audio[LPC_ORDER + VAR_8] << 1); } *VAR_2 = 1; return frame_size[VAR_6]; }
[ "static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{", "G723_1_Context *p = VAR_0->priv_data;", "AVFrame *frame = VAR_1;", "const uint8_t *VAR_4 = VAR_3->VAR_1;", "int VAR_5 = VAR_3->size;", "int VAR_6 = VAR_4[0] & 3;", "PPFParam ppf[SUBFRAMES];", "int16_t cur_lsp[LPC_ORDER];", "int16_t lpc[SUBFRAMES * LPC_ORDER];", "int16_t acb_vector[SUBFRAME_LEN];", "int16_t *out;", "int VAR_7 = 0, VAR_8, VAR_9, VAR_10;", "int16_t *audio = p->audio;", "if (VAR_5 < frame_size[VAR_6]) {", "if (VAR_5)\nav_log(VAR_0, AV_LOG_WARNING,\n\"Expected %d bytes, got %d - skipping packet\\n\",\nframe_size[VAR_6], VAR_5);", "*VAR_2 = 0;", "return VAR_5;", "}", "if (unpack_bitstream(p, VAR_4, VAR_5) < 0) {", "VAR_7 = 1;", "if (p->past_frame_type == ACTIVE_FRAME)\np->cur_frame_type = ACTIVE_FRAME;", "else\np->cur_frame_type = UNTRANSMITTED_FRAME;", "}", "frame->nb_samples = FRAME_LEN;", "if ((VAR_10 = ff_get_buffer(VAR_0, frame, 0)) < 0)\nreturn VAR_10;", "out = (int16_t *)frame->VAR_1[0];", "if (p->cur_frame_type == ACTIVE_FRAME) {", "if (!VAR_7)\np->erased_frames = 0;", "else if (p->erased_frames != 3)\np->erased_frames++;", "ff_g723_1_inverse_quant(cur_lsp, p->prev_lsp, p->lsp_index, VAR_7);", "ff_g723_1_lsp_interpolate(lpc, cur_lsp, p->prev_lsp);", "memcpy(p->prev_lsp, cur_lsp, LPC_ORDER * sizeof(*p->prev_lsp));", "memcpy(p->excitation, p->prev_excitation,\nPITCH_MAX * sizeof(*p->excitation));", "if (!p->erased_frames) {", "int16_t *vector_ptr = p->excitation + PITCH_MAX;", "p->interp_gain = fixed_cb_gain[(p->subframe[2].amp_index +\np->subframe[3].amp_index) >> 1];", "for (VAR_8 = 0; VAR_8 < SUBFRAMES; VAR_8++) {", "gen_fcb_excitation(vector_ptr, &p->subframe[VAR_8], p->cur_rate,\np->pitch_lag[VAR_8 >> 1], VAR_8);", "ff_g723_1_gen_acb_excitation(acb_vector,\n&p->excitation[SUBFRAME_LEN * VAR_8],\np->pitch_lag[VAR_8 >> 1],\n&p->subframe[VAR_8], p->cur_rate);", "for (VAR_9 = 0; VAR_9 < SUBFRAME_LEN; VAR_9++) {", "int v = av_clip_int16(vector_ptr[VAR_9] << 1);", "vector_ptr[VAR_9] = av_clip_int16(v + acb_vector[VAR_9]);", "}", "vector_ptr += SUBFRAME_LEN;", "}", "vector_ptr = p->excitation + PITCH_MAX;", "p->interp_index = comp_interp_index(p, p->pitch_lag[1],\n&p->sid_gain, &p->cur_gain);", "if (p->postfilter) {", "VAR_8 = PITCH_MAX;", "for (VAR_9 = 0; VAR_9 < SUBFRAMES; VAR_8 += SUBFRAME_LEN, VAR_9++)", "comp_ppf_coeff(p, VAR_8, p->pitch_lag[VAR_9 >> 1],\nppf + VAR_9, p->cur_rate);", "for (VAR_8 = 0, VAR_9 = 0; VAR_9 < SUBFRAMES; VAR_8 += SUBFRAME_LEN, VAR_9++)", "ff_acelp_weighted_vector_sum(p->audio + LPC_ORDER + VAR_8,\nvector_ptr + VAR_8,\nvector_ptr + VAR_8 + ppf[VAR_9].index,\nppf[VAR_9].sc_gain,\nppf[VAR_9].opt_gain,\n1 << 14, 15, SUBFRAME_LEN);", "} else {", "audio = vector_ptr - LPC_ORDER;", "}", "memcpy(p->prev_excitation, p->excitation + FRAME_LEN,\nPITCH_MAX * sizeof(*p->excitation));", "} else {", "p->interp_gain = (p->interp_gain * 3 + 2) >> 2;", "if (p->erased_frames == 3) {", "memset(p->excitation, 0,\n(FRAME_LEN + PITCH_MAX) * sizeof(*p->excitation));", "memset(p->prev_excitation, 0,\nPITCH_MAX * sizeof(*p->excitation));", "memset(frame->VAR_1[0], 0,\n(FRAME_LEN + LPC_ORDER) * sizeof(int16_t));", "} else {", "int16_t *VAR_4 = p->audio + LPC_ORDER;", "residual_interp(p->excitation, VAR_4, p->interp_index,\np->interp_gain, &p->random_seed);", "memcpy(p->prev_excitation, VAR_4 + (FRAME_LEN - PITCH_MAX),\nPITCH_MAX * sizeof(*p->excitation));", "}", "}", "p->cng_random_seed = CNG_RANDOM_SEED;", "} else {", "if (p->cur_frame_type == SID_FRAME) {", "p->sid_gain = sid_gain_to_lsp_index(p->subframe[0].amp_index);", "ff_g723_1_inverse_quant(p->sid_lsp, p->prev_lsp, p->lsp_index, 0);", "} else if (p->past_frame_type == ACTIVE_FRAME) {", "p->sid_gain = estimate_sid_gain(p);", "}", "if (p->past_frame_type == ACTIVE_FRAME)\np->cur_gain = p->sid_gain;", "else\np->cur_gain = (p->cur_gain * 7 + p->sid_gain) >> 3;", "generate_noise(p);", "ff_g723_1_lsp_interpolate(lpc, p->sid_lsp, p->prev_lsp);", "memcpy(p->prev_lsp, p->sid_lsp, LPC_ORDER * sizeof(*p->prev_lsp));", "}", "p->past_frame_type = p->cur_frame_type;", "memcpy(p->audio, p->synth_mem, LPC_ORDER * sizeof(*p->audio));", "for (VAR_8 = LPC_ORDER, VAR_9 = 0; VAR_9 < SUBFRAMES; VAR_8 += SUBFRAME_LEN, VAR_9++)", "ff_celp_lp_synthesis_filter(p->audio + VAR_8, &lpc[VAR_9 * LPC_ORDER],\naudio + VAR_8, SUBFRAME_LEN, LPC_ORDER,\n0, 1, 1 << 12);", "memcpy(p->synth_mem, p->audio + FRAME_LEN, LPC_ORDER * sizeof(*p->audio));", "if (p->postfilter) {", "formant_postfilter(p, lpc, p->audio, out);", "} else {", "for (VAR_8 = 0; VAR_8 < FRAME_LEN; VAR_8++)", "out[VAR_8] = av_clip_int16(p->audio[LPC_ORDER + VAR_8] << 1);", "}", "*VAR_2 = 1;", "return frame_size[VAR_6];", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37, 39, 41, 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ], [ 57, 59 ], [ 61, 63 ], [ 65 ], [ 69 ], [ 71, 73 ], [ 77 ], [ 81 ], [ 83, 85 ], [ 87, 89 ], [ 93 ], [ 95 ], [ 101 ], [ 107, 109 ], [ 111 ], [ 113 ], [ 119, 121 ], [ 123 ], [ 125, 127 ], [ 129, 131, 133, 135 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 153 ], [ 157, 159 ], [ 165 ], [ 167 ], [ 169 ], [ 171, 173 ], [ 177 ], [ 179, 181, 183, 185, 187, 189 ], [ 191 ], [ 193 ], [ 195 ], [ 201, 203 ], [ 205 ], [ 207 ], [ 209 ], [ 213, 215 ], [ 217, 219 ], [ 221, 223 ], [ 225 ], [ 227 ], [ 233, 235 ], [ 241, 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 267, 269 ], [ 271, 273 ], [ 275 ], [ 277 ], [ 281 ], [ 283 ], [ 287 ], [ 291 ], [ 293 ], [ 295, 297, 299 ], [ 301 ], [ 305 ], [ 307 ], [ 309 ], [ 311 ], [ 313 ], [ 315 ], [ 319 ], [ 323 ], [ 325 ] ]
9,401
static int parse_chap(struct iscsi_context *iscsi, const char *target) { QemuOptsList *list; QemuOpts *opts; const char *user = NULL; const char *password = NULL; list = qemu_find_opts("iscsi"); if (!list) { return 0; } opts = qemu_opts_find(list, target); if (opts == NULL) { opts = QTAILQ_FIRST(&list->head); if (!opts) { return 0; } } user = qemu_opt_get(opts, "user"); if (!user) { return 0; } password = qemu_opt_get(opts, "password"); if (!password) { error_report("CHAP username specified but no password was given"); return -1; } if (iscsi_set_initiator_username_pwd(iscsi, user, password)) { error_report("Failed to set initiator username and password"); return -1; } return 0; }
true
qemu
f2917853f715b0ef55df29eb2ffea29dc69ce814
static int parse_chap(struct iscsi_context *iscsi, const char *target) { QemuOptsList *list; QemuOpts *opts; const char *user = NULL; const char *password = NULL; list = qemu_find_opts("iscsi"); if (!list) { return 0; } opts = qemu_opts_find(list, target); if (opts == NULL) { opts = QTAILQ_FIRST(&list->head); if (!opts) { return 0; } } user = qemu_opt_get(opts, "user"); if (!user) { return 0; } password = qemu_opt_get(opts, "password"); if (!password) { error_report("CHAP username specified but no password was given"); return -1; } if (iscsi_set_initiator_username_pwd(iscsi, user, password)) { error_report("Failed to set initiator username and password"); return -1; } return 0; }
{ "code": [ "static int parse_chap(struct iscsi_context *iscsi, const char *target)", " return 0;", " return 0;", " return 0;", " error_report(\"CHAP username specified but no password was given\");", " return -1;", " error_report(\"Failed to set initiator username and password\");", " return -1;", " return 0;", " return 0;" ], "line_no": [ 1, 19, 33, 19, 55, 57, 65, 57, 73, 33 ] }
static int FUNC_0(struct iscsi_context *VAR_0, const char *VAR_1) { QemuOptsList *list; QemuOpts *opts; const char *VAR_2 = NULL; const char *VAR_3 = NULL; list = qemu_find_opts("VAR_0"); if (!list) { return 0; } opts = qemu_opts_find(list, VAR_1); if (opts == NULL) { opts = QTAILQ_FIRST(&list->head); if (!opts) { return 0; } } VAR_2 = qemu_opt_get(opts, "VAR_2"); if (!VAR_2) { return 0; } VAR_3 = qemu_opt_get(opts, "VAR_3"); if (!VAR_3) { error_report("CHAP username specified but no VAR_3 was given"); return -1; } if (iscsi_set_initiator_username_pwd(VAR_0, VAR_2, VAR_3)) { error_report("Failed to set initiator username and VAR_3"); return -1; } return 0; }
[ "static int FUNC_0(struct iscsi_context *VAR_0, const char *VAR_1)\n{", "QemuOptsList *list;", "QemuOpts *opts;", "const char *VAR_2 = NULL;", "const char *VAR_3 = NULL;", "list = qemu_find_opts(\"VAR_0\");", "if (!list) {", "return 0;", "}", "opts = qemu_opts_find(list, VAR_1);", "if (opts == NULL) {", "opts = QTAILQ_FIRST(&list->head);", "if (!opts) {", "return 0;", "}", "}", "VAR_2 = qemu_opt_get(opts, \"VAR_2\");", "if (!VAR_2) {", "return 0;", "}", "VAR_3 = qemu_opt_get(opts, \"VAR_3\");", "if (!VAR_3) {", "error_report(\"CHAP username specified but no VAR_3 was given\");", "return -1;", "}", "if (iscsi_set_initiator_username_pwd(VAR_0, VAR_2, VAR_3)) {", "error_report(\"Failed to set initiator username and VAR_3\");", "return -1;", "}", "return 0;", "}" ]
[ 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 73 ], [ 75 ] ]
9,402
static int nbd_handle_reply_err(uint32_t opt, uint32_t type, Error **errp) { if (!(type & (1 << 31))) { return 0; } switch (type) { case NBD_REP_ERR_UNSUP: error_setg(errp, "Unsupported option type %x", opt); break; case NBD_REP_ERR_POLICY: error_setg(errp, "Denied by server for option %x", opt); break; case NBD_REP_ERR_INVALID: error_setg(errp, "Invalid data length for option %x", opt); break; case NBD_REP_ERR_TLS_REQD: error_setg(errp, "TLS negotiation required before option %x", opt); break; default: error_setg(errp, "Unknown error code when asking for option %x", opt); break; } return -1; }
true
qemu
6ff5816478940c76d3412593e503f644af531d49
static int nbd_handle_reply_err(uint32_t opt, uint32_t type, Error **errp) { if (!(type & (1 << 31))) { return 0; } switch (type) { case NBD_REP_ERR_UNSUP: error_setg(errp, "Unsupported option type %x", opt); break; case NBD_REP_ERR_POLICY: error_setg(errp, "Denied by server for option %x", opt); break; case NBD_REP_ERR_INVALID: error_setg(errp, "Invalid data length for option %x", opt); break; case NBD_REP_ERR_TLS_REQD: error_setg(errp, "TLS negotiation required before option %x", opt); break; default: error_setg(errp, "Unknown error code when asking for option %x", opt); break; } return -1; }
{ "code": [ "static int nbd_handle_reply_err(uint32_t opt, uint32_t type, Error **errp)", " return 0;", " error_setg(errp, \"Unsupported option type %x\", opt);", " break;", " return -1;", " return 0;" ], "line_no": [ 1, 7, 17, 19, 57, 7 ] }
static int FUNC_0(uint32_t VAR_0, uint32_t VAR_1, Error **VAR_2) { if (!(VAR_1 & (1 << 31))) { return 0; } switch (VAR_1) { case NBD_REP_ERR_UNSUP: error_setg(VAR_2, "Unsupported option VAR_1 %x", VAR_0); break; case NBD_REP_ERR_POLICY: error_setg(VAR_2, "Denied by server for option %x", VAR_0); break; case NBD_REP_ERR_INVALID: error_setg(VAR_2, "Invalid data length for option %x", VAR_0); break; case NBD_REP_ERR_TLS_REQD: error_setg(VAR_2, "TLS negotiation required before option %x", VAR_0); break; default: error_setg(VAR_2, "Unknown error code when asking for option %x", VAR_0); break; } return -1; }
[ "static int FUNC_0(uint32_t VAR_0, uint32_t VAR_1, Error **VAR_2)\n{", "if (!(VAR_1 & (1 << 31))) {", "return 0;", "}", "switch (VAR_1) {", "case NBD_REP_ERR_UNSUP:\nerror_setg(VAR_2, \"Unsupported option VAR_1 %x\", VAR_0);", "break;", "case NBD_REP_ERR_POLICY:\nerror_setg(VAR_2, \"Denied by server for option %x\", VAR_0);", "break;", "case NBD_REP_ERR_INVALID:\nerror_setg(VAR_2, \"Invalid data length for option %x\", VAR_0);", "break;", "case NBD_REP_ERR_TLS_REQD:\nerror_setg(VAR_2, \"TLS negotiation required before option %x\", VAR_0);", "break;", "default:\nerror_setg(VAR_2, \"Unknown error code when asking for option %x\", VAR_0);", "break;", "}", "return -1;", "}" ]
[ 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15, 17 ], [ 19 ], [ 23, 25 ], [ 27 ], [ 31, 33 ], [ 35 ], [ 39, 41 ], [ 43 ], [ 47, 49 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ] ]
9,403
static void pop_output_configuration(AACContext *ac) { if (ac->oc[1].status != OC_LOCKED) { if (ac->oc[0].status == OC_LOCKED) { ac->oc[1] = ac->oc[0]; ac->avctx->channels = ac->oc[1].channels; ac->avctx->channel_layout = ac->oc[1].channel_layout; }else{ ac->avctx->channels = 0; ac->avctx->channel_layout = 0; } } }
true
FFmpeg
124eb7e476f7e3f66dcdc30f780a45b378751219
static void pop_output_configuration(AACContext *ac) { if (ac->oc[1].status != OC_LOCKED) { if (ac->oc[0].status == OC_LOCKED) { ac->oc[1] = ac->oc[0]; ac->avctx->channels = ac->oc[1].channels; ac->avctx->channel_layout = ac->oc[1].channel_layout; }else{ ac->avctx->channels = 0; ac->avctx->channel_layout = 0; } } }
{ "code": [ " }else{", " ac->avctx->channels = 0;", " ac->avctx->channel_layout = 0;" ], "line_no": [ 13, 15, 17 ] }
static void FUNC_0(AACContext *VAR_0) { if (VAR_0->oc[1].status != OC_LOCKED) { if (VAR_0->oc[0].status == OC_LOCKED) { VAR_0->oc[1] = VAR_0->oc[0]; VAR_0->avctx->channels = VAR_0->oc[1].channels; VAR_0->avctx->channel_layout = VAR_0->oc[1].channel_layout; }else{ VAR_0->avctx->channels = 0; VAR_0->avctx->channel_layout = 0; } } }
[ "static void FUNC_0(AACContext *VAR_0) {", "if (VAR_0->oc[1].status != OC_LOCKED) {", "if (VAR_0->oc[0].status == OC_LOCKED) {", "VAR_0->oc[1] = VAR_0->oc[0];", "VAR_0->avctx->channels = VAR_0->oc[1].channels;", "VAR_0->avctx->channel_layout = VAR_0->oc[1].channel_layout;", "}else{", "VAR_0->avctx->channels = 0;", "VAR_0->avctx->channel_layout = 0;", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0 ]
[ [ 1 ], [ 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ] ]
9,404
static int mmubooke206_get_physical_address(CPUState *env, mmu_ctx_t *ctx, target_ulong address, int rw, int access_type) { ppcmas_tlb_t *tlb; target_phys_addr_t raddr; int i, j, ret; ret = -1; raddr = (target_phys_addr_t)-1ULL; for (i = 0; i < BOOKE206_MAX_TLBN; i++) { int ways = booke206_tlb_ways(env, i); for (j = 0; j < ways; j++) { tlb = booke206_get_tlbm(env, i, address, j); ret = mmubooke206_check_tlb(env, tlb, &raddr, &ctx->prot, address, rw, access_type); if (ret != -1) { goto found_tlb; found_tlb: if (ret >= 0) { ctx->raddr = raddr; LOG_SWTLB("%s: access granted " TARGET_FMT_lx " => " TARGET_FMT_plx " %d %d\n", __func__, address, ctx->raddr, ctx->prot, ret); } else { LOG_SWTLB("%s: access refused " TARGET_FMT_lx " => " TARGET_FMT_plx " %d %d\n", __func__, address, raddr, ctx->prot, ret); return ret;
true
qemu
3f162d119ef52fda714ebb498fcb4f4b7c354d38
static int mmubooke206_get_physical_address(CPUState *env, mmu_ctx_t *ctx, target_ulong address, int rw, int access_type) { ppcmas_tlb_t *tlb; target_phys_addr_t raddr; int i, j, ret; ret = -1; raddr = (target_phys_addr_t)-1ULL; for (i = 0; i < BOOKE206_MAX_TLBN; i++) { int ways = booke206_tlb_ways(env, i); for (j = 0; j < ways; j++) { tlb = booke206_get_tlbm(env, i, address, j); ret = mmubooke206_check_tlb(env, tlb, &raddr, &ctx->prot, address, rw, access_type); if (ret != -1) { goto found_tlb; found_tlb: if (ret >= 0) { ctx->raddr = raddr; LOG_SWTLB("%s: access granted " TARGET_FMT_lx " => " TARGET_FMT_plx " %d %d\n", __func__, address, ctx->raddr, ctx->prot, ret); } else { LOG_SWTLB("%s: access refused " TARGET_FMT_lx " => " TARGET_FMT_plx " %d %d\n", __func__, address, raddr, ctx->prot, ret); return ret;
{ "code": [], "line_no": [] }
static int FUNC_0(CPUState *VAR_0, mmu_ctx_t *VAR_1, target_ulong VAR_2, int VAR_3, int VAR_4) { ppcmas_tlb_t *tlb; target_phys_addr_t raddr; int VAR_5, VAR_6, VAR_7; VAR_7 = -1; raddr = (target_phys_addr_t)-1ULL; for (VAR_5 = 0; VAR_5 < BOOKE206_MAX_TLBN; VAR_5++) { int ways = booke206_tlb_ways(VAR_0, VAR_5); for (VAR_6 = 0; VAR_6 < ways; VAR_6++) { tlb = booke206_get_tlbm(VAR_0, VAR_5, VAR_2, VAR_6); VAR_7 = mmubooke206_check_tlb(VAR_0, tlb, &raddr, &VAR_1->prot, VAR_2, VAR_3, VAR_4); if (VAR_7 != -1) { goto found_tlb; found_tlb: if (VAR_7 >= 0) { VAR_1->raddr = raddr; LOG_SWTLB("%s: access granted " TARGET_FMT_lx " => " TARGET_FMT_plx " %d %d\n", __func__, VAR_2, VAR_1->raddr, VAR_1->prot, VAR_7); } else { LOG_SWTLB("%s: access refused " TARGET_FMT_lx " => " TARGET_FMT_plx " %d %d\n", __func__, VAR_2, raddr, VAR_1->prot, VAR_7); return VAR_7;
[ "static int FUNC_0(CPUState *VAR_0, mmu_ctx_t *VAR_1,\ntarget_ulong VAR_2, int VAR_3,\nint VAR_4)\n{", "ppcmas_tlb_t *tlb;", "target_phys_addr_t raddr;", "int VAR_5, VAR_6, VAR_7;", "VAR_7 = -1;", "raddr = (target_phys_addr_t)-1ULL;", "for (VAR_5 = 0; VAR_5 < BOOKE206_MAX_TLBN; VAR_5++) {", "int ways = booke206_tlb_ways(VAR_0, VAR_5);", "for (VAR_6 = 0; VAR_6 < ways; VAR_6++) {", "tlb = booke206_get_tlbm(VAR_0, VAR_5, VAR_2, VAR_6);", "VAR_7 = mmubooke206_check_tlb(VAR_0, tlb, &raddr, &VAR_1->prot, VAR_2,\nVAR_3, VAR_4);", "if (VAR_7 != -1) {", "goto found_tlb;", "found_tlb:\nif (VAR_7 >= 0) {", "VAR_1->raddr = raddr;", "LOG_SWTLB(\"%s: access granted \" TARGET_FMT_lx \" => \" TARGET_FMT_plx\n\" %d %d\\n\", __func__, VAR_2, VAR_1->raddr, VAR_1->prot,\nVAR_7);", "} else {", "LOG_SWTLB(\"%s: access refused \" TARGET_FMT_lx \" => \" TARGET_FMT_plx\n\" %d %d\\n\", __func__, VAR_2, raddr, VAR_1->prot, VAR_7);", "return VAR_7;" ]
[ 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 ], [ 29 ], [ 31 ], [ 36, 38 ], [ 40 ], [ 42 ], [ 49, 53 ], [ 55 ], [ 57, 59, 61 ], [ 63 ], [ 65, 67 ], [ 72 ] ]
9,405
static int raw_write_scrubbed_bootsect(BlockDriverState *bs, const uint8_t *buf) { uint8_t bootsect[512]; /* scrub the dangerous signature */ memcpy(bootsect, buf, 512); memset(bootsect, 0, 4); return bdrv_write(bs->file, 0, bootsect, 1); }
true
qemu
8b33d9eeba91422ee2d73b6936ad57262d18cf5a
static int raw_write_scrubbed_bootsect(BlockDriverState *bs, const uint8_t *buf) { uint8_t bootsect[512]; memcpy(bootsect, buf, 512); memset(bootsect, 0, 4); return bdrv_write(bs->file, 0, bootsect, 1); }
{ "code": [ "static int raw_write_scrubbed_bootsect(BlockDriverState *bs,", " const uint8_t *buf)", " uint8_t bootsect[512];", " memcpy(bootsect, buf, 512);", " memset(bootsect, 0, 4);", " return bdrv_write(bs->file, 0, bootsect, 1);" ], "line_no": [ 1, 3, 7, 13, 15, 19 ] }
static int FUNC_0(BlockDriverState *VAR_0, const uint8_t *VAR_1) { uint8_t bootsect[512]; memcpy(bootsect, VAR_1, 512); memset(bootsect, 0, 4); return bdrv_write(VAR_0->file, 0, bootsect, 1); }
[ "static int FUNC_0(BlockDriverState *VAR_0,\nconst uint8_t *VAR_1)\n{", "uint8_t bootsect[512];", "memcpy(bootsect, VAR_1, 512);", "memset(bootsect, 0, 4);", "return bdrv_write(VAR_0->file, 0, bootsect, 1);", "}" ]
[ 1, 1, 1, 1, 1, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ] ]
9,406
void OPPROTO op_POWER_sllq (void) { uint32_t msk = -1; msk = msk << (T1 & 0x1FUL); if (T1 & 0x20UL) msk = ~msk; T1 &= 0x1FUL; T0 = (T0 << T1) & msk; T0 |= env->spr[SPR_MQ] & ~msk; RETURN(); }
true
qemu
6f2d8978728c48ca46f5c01835438508aace5c64
void OPPROTO op_POWER_sllq (void) { uint32_t msk = -1; msk = msk << (T1 & 0x1FUL); if (T1 & 0x20UL) msk = ~msk; T1 &= 0x1FUL; T0 = (T0 << T1) & msk; T0 |= env->spr[SPR_MQ] & ~msk; RETURN(); }
{ "code": [ " uint32_t msk = -1;" ], "line_no": [ 5 ] }
void VAR_0 op_POWER_sllq (void) { uint32_t msk = -1; msk = msk << (T1 & 0x1FUL); if (T1 & 0x20UL) msk = ~msk; T1 &= 0x1FUL; T0 = (T0 << T1) & msk; T0 |= env->spr[SPR_MQ] & ~msk; RETURN(); }
[ "void VAR_0 op_POWER_sllq (void)\n{", "uint32_t msk = -1;", "msk = msk << (T1 & 0x1FUL);", "if (T1 & 0x20UL)\nmsk = ~msk;", "T1 &= 0x1FUL;", "T0 = (T0 << T1) & msk;", "T0 |= env->spr[SPR_MQ] & ~msk;", "RETURN();", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11, 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ] ]
9,407
static void cirrus_bitblt_cputovideo_next(CirrusVGAState * s) { int copy_count; uint8_t *end_ptr; if (s->cirrus_srccounter > 0) { if (s->cirrus_blt_mode & CIRRUS_BLTMODE_PATTERNCOPY) { cirrus_bitblt_common_patterncopy(s, s->cirrus_bltbuf); the_end: s->cirrus_srccounter = 0; cirrus_bitblt_reset(s); } else { /* at least one scan line */ do { (*s->cirrus_rop)(s, s->vga.vram_ptr + s->cirrus_blt_dstaddr, s->cirrus_bltbuf, 0, 0, s->cirrus_blt_width, 1); cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, 0, s->cirrus_blt_width, 1); s->cirrus_blt_dstaddr += s->cirrus_blt_dstpitch; s->cirrus_srccounter -= s->cirrus_blt_srcpitch; if (s->cirrus_srccounter <= 0) goto the_end; /* more bytes than needed can be transferred because of word alignment, so we keep them for the next line */ /* XXX: keep alignment to speed up transfer */ end_ptr = s->cirrus_bltbuf + s->cirrus_blt_srcpitch; copy_count = s->cirrus_srcptr_end - end_ptr; memmove(s->cirrus_bltbuf, end_ptr, copy_count); s->cirrus_srcptr = s->cirrus_bltbuf + copy_count; s->cirrus_srcptr_end = s->cirrus_bltbuf + s->cirrus_blt_srcpitch; } while (s->cirrus_srcptr >= s->cirrus_srcptr_end); } } }
true
qemu
95280c31cda79bb1d0968afc7b19a220b3a9d986
static void cirrus_bitblt_cputovideo_next(CirrusVGAState * s) { int copy_count; uint8_t *end_ptr; if (s->cirrus_srccounter > 0) { if (s->cirrus_blt_mode & CIRRUS_BLTMODE_PATTERNCOPY) { cirrus_bitblt_common_patterncopy(s, s->cirrus_bltbuf); the_end: s->cirrus_srccounter = 0; cirrus_bitblt_reset(s); } else { do { (*s->cirrus_rop)(s, s->vga.vram_ptr + s->cirrus_blt_dstaddr, s->cirrus_bltbuf, 0, 0, s->cirrus_blt_width, 1); cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, 0, s->cirrus_blt_width, 1); s->cirrus_blt_dstaddr += s->cirrus_blt_dstpitch; s->cirrus_srccounter -= s->cirrus_blt_srcpitch; if (s->cirrus_srccounter <= 0) goto the_end; end_ptr = s->cirrus_bltbuf + s->cirrus_blt_srcpitch; copy_count = s->cirrus_srcptr_end - end_ptr; memmove(s->cirrus_bltbuf, end_ptr, copy_count); s->cirrus_srcptr = s->cirrus_bltbuf + copy_count; s->cirrus_srcptr_end = s->cirrus_bltbuf + s->cirrus_blt_srcpitch; } while (s->cirrus_srcptr >= s->cirrus_srcptr_end); } } }
{ "code": [ " cirrus_bitblt_common_patterncopy(s, s->cirrus_bltbuf);" ], "line_no": [ 15 ] }
static void FUNC_0(CirrusVGAState * VAR_0) { int VAR_1; uint8_t *end_ptr; if (VAR_0->cirrus_srccounter > 0) { if (VAR_0->cirrus_blt_mode & CIRRUS_BLTMODE_PATTERNCOPY) { cirrus_bitblt_common_patterncopy(VAR_0, VAR_0->cirrus_bltbuf); the_end: VAR_0->cirrus_srccounter = 0; cirrus_bitblt_reset(VAR_0); } else { do { (*VAR_0->cirrus_rop)(VAR_0, VAR_0->vga.vram_ptr + VAR_0->cirrus_blt_dstaddr, VAR_0->cirrus_bltbuf, 0, 0, VAR_0->cirrus_blt_width, 1); cirrus_invalidate_region(VAR_0, VAR_0->cirrus_blt_dstaddr, 0, VAR_0->cirrus_blt_width, 1); VAR_0->cirrus_blt_dstaddr += VAR_0->cirrus_blt_dstpitch; VAR_0->cirrus_srccounter -= VAR_0->cirrus_blt_srcpitch; if (VAR_0->cirrus_srccounter <= 0) goto the_end; end_ptr = VAR_0->cirrus_bltbuf + VAR_0->cirrus_blt_srcpitch; VAR_1 = VAR_0->cirrus_srcptr_end - end_ptr; memmove(VAR_0->cirrus_bltbuf, end_ptr, VAR_1); VAR_0->cirrus_srcptr = VAR_0->cirrus_bltbuf + VAR_1; VAR_0->cirrus_srcptr_end = VAR_0->cirrus_bltbuf + VAR_0->cirrus_blt_srcpitch; } while (VAR_0->cirrus_srcptr >= VAR_0->cirrus_srcptr_end); } } }
[ "static void FUNC_0(CirrusVGAState * VAR_0)\n{", "int VAR_1;", "uint8_t *end_ptr;", "if (VAR_0->cirrus_srccounter > 0) {", "if (VAR_0->cirrus_blt_mode & CIRRUS_BLTMODE_PATTERNCOPY) {", "cirrus_bitblt_common_patterncopy(VAR_0, VAR_0->cirrus_bltbuf);", "the_end:\nVAR_0->cirrus_srccounter = 0;", "cirrus_bitblt_reset(VAR_0);", "} else {", "do {", "(*VAR_0->cirrus_rop)(VAR_0, VAR_0->vga.vram_ptr + VAR_0->cirrus_blt_dstaddr,\nVAR_0->cirrus_bltbuf, 0, 0, VAR_0->cirrus_blt_width, 1);", "cirrus_invalidate_region(VAR_0, VAR_0->cirrus_blt_dstaddr, 0,\nVAR_0->cirrus_blt_width, 1);", "VAR_0->cirrus_blt_dstaddr += VAR_0->cirrus_blt_dstpitch;", "VAR_0->cirrus_srccounter -= VAR_0->cirrus_blt_srcpitch;", "if (VAR_0->cirrus_srccounter <= 0)\ngoto the_end;", "end_ptr = VAR_0->cirrus_bltbuf + VAR_0->cirrus_blt_srcpitch;", "VAR_1 = VAR_0->cirrus_srcptr_end - end_ptr;", "memmove(VAR_0->cirrus_bltbuf, end_ptr, VAR_1);", "VAR_0->cirrus_srcptr = VAR_0->cirrus_bltbuf + VAR_1;", "VAR_0->cirrus_srcptr_end = VAR_0->cirrus_bltbuf + VAR_0->cirrus_blt_srcpitch;", "} while (VAR_0->cirrus_srcptr >= VAR_0->cirrus_srcptr_end);", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17, 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29, 31 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 41, 43 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ] ]
9,409
static void fsl_imx31_realize(DeviceState *dev, Error **errp) { FslIMX31State *s = FSL_IMX31(dev); uint16_t i; Error *err = NULL; object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err); if (err) { error_propagate(errp, err); return; } object_property_set_bool(OBJECT(&s->avic), true, "realized", &err); if (err) { error_propagate(errp, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->avic), 0, FSL_IMX31_AVIC_ADDR); sysbus_connect_irq(SYS_BUS_DEVICE(&s->avic), 0, qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_IRQ)); sysbus_connect_irq(SYS_BUS_DEVICE(&s->avic), 1, qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ)); object_property_set_bool(OBJECT(&s->ccm), true, "realized", &err); if (err) { error_propagate(errp, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, FSL_IMX31_CCM_ADDR); /* Initialize all UARTS */ for (i = 0; i < FSL_IMX31_NUM_UARTS; i++) { static const struct { hwaddr addr; unsigned int irq; } serial_table[FSL_IMX31_NUM_UARTS] = { { FSL_IMX31_UART1_ADDR, FSL_IMX31_UART1_IRQ }, { FSL_IMX31_UART2_ADDR, FSL_IMX31_UART2_IRQ }, }; if (i < MAX_SERIAL_PORTS) { Chardev *chr; chr = serial_hds[i]; if (!chr) { char label[20]; snprintf(label, sizeof(label), "imx31.uart%d", i); chr = qemu_chr_new(label, "null"); } qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr); } object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err); if (err) { error_propagate(errp, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, serial_table[i].addr); sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0, qdev_get_gpio_in(DEVICE(&s->avic), serial_table[i].irq)); } s->gpt.ccm = IMX_CCM(&s->ccm); object_property_set_bool(OBJECT(&s->gpt), true, "realized", &err); if (err) { error_propagate(errp, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpt), 0, FSL_IMX31_GPT_ADDR); sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpt), 0, qdev_get_gpio_in(DEVICE(&s->avic), FSL_IMX31_GPT_IRQ)); /* Initialize all EPIT timers */ for (i = 0; i < FSL_IMX31_NUM_EPITS; i++) { static const struct { hwaddr addr; unsigned int irq; } epit_table[FSL_IMX31_NUM_EPITS] = { { FSL_IMX31_EPIT1_ADDR, FSL_IMX31_EPIT1_IRQ }, { FSL_IMX31_EPIT2_ADDR, FSL_IMX31_EPIT2_IRQ }, }; s->epit[i].ccm = IMX_CCM(&s->ccm); object_property_set_bool(OBJECT(&s->epit[i]), true, "realized", &err); if (err) { error_propagate(errp, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->epit[i]), 0, epit_table[i].addr); sysbus_connect_irq(SYS_BUS_DEVICE(&s->epit[i]), 0, qdev_get_gpio_in(DEVICE(&s->avic), epit_table[i].irq)); } /* Initialize all I2C */ for (i = 0; i < FSL_IMX31_NUM_I2CS; i++) { static const struct { hwaddr addr; unsigned int irq; } i2c_table[FSL_IMX31_NUM_I2CS] = { { FSL_IMX31_I2C1_ADDR, FSL_IMX31_I2C1_IRQ }, { FSL_IMX31_I2C2_ADDR, FSL_IMX31_I2C2_IRQ }, { FSL_IMX31_I2C3_ADDR, FSL_IMX31_I2C3_IRQ } }; /* Initialize the I2C */ object_property_set_bool(OBJECT(&s->i2c[i]), true, "realized", &err); if (err) { error_propagate(errp, err); return; } /* Map I2C memory */ sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c[i]), 0, i2c_table[i].addr); /* Connect I2C IRQ to PIC */ sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c[i]), 0, qdev_get_gpio_in(DEVICE(&s->avic), i2c_table[i].irq)); } /* Initialize all GPIOs */ for (i = 0; i < FSL_IMX31_NUM_GPIOS; i++) { static const struct { hwaddr addr; unsigned int irq; } gpio_table[FSL_IMX31_NUM_GPIOS] = { { FSL_IMX31_GPIO1_ADDR, FSL_IMX31_GPIO1_IRQ }, { FSL_IMX31_GPIO2_ADDR, FSL_IMX31_GPIO2_IRQ }, { FSL_IMX31_GPIO3_ADDR, FSL_IMX31_GPIO3_IRQ } }; object_property_set_bool(OBJECT(&s->gpio[i]), false, "has-edge-sel", &error_abort); object_property_set_bool(OBJECT(&s->gpio[i]), true, "realized", &err); if (err) { error_propagate(errp, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, gpio_table[i].addr); /* Connect GPIO IRQ to PIC */ sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0, qdev_get_gpio_in(DEVICE(&s->avic), gpio_table[i].irq)); } /* On a real system, the first 16k is a `secure boot rom' */ memory_region_init_rom_nomigrate(&s->secure_rom, NULL, "imx31.secure_rom", FSL_IMX31_SECURE_ROM_SIZE, &err); if (err) { error_propagate(errp, err); return; } memory_region_add_subregion(get_system_memory(), FSL_IMX31_SECURE_ROM_ADDR, &s->secure_rom); /* There is also a 16k ROM */ memory_region_init_rom_nomigrate(&s->rom, NULL, "imx31.rom", FSL_IMX31_ROM_SIZE, &err); if (err) { error_propagate(errp, err); return; } memory_region_add_subregion(get_system_memory(), FSL_IMX31_ROM_ADDR, &s->rom); /* initialize internal RAM (16 KB) */ memory_region_init_ram(&s->iram, NULL, "imx31.iram", FSL_IMX31_IRAM_SIZE, &err); if (err) { error_propagate(errp, err); return; } memory_region_add_subregion(get_system_memory(), FSL_IMX31_IRAM_ADDR, &s->iram); /* internal RAM (16 KB) is aliased over 256 MB - 16 KB */ memory_region_init_alias(&s->iram_alias, NULL, "imx31.iram_alias", &s->iram, 0, FSL_IMX31_IRAM_ALIAS_SIZE); memory_region_add_subregion(get_system_memory(), FSL_IMX31_IRAM_ALIAS_ADDR, &s->iram_alias); }
true
qemu
eda40cc1686162dcd92a97debcbb0df74269651f
static void fsl_imx31_realize(DeviceState *dev, Error **errp) { FslIMX31State *s = FSL_IMX31(dev); uint16_t i; Error *err = NULL; object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err); if (err) { error_propagate(errp, err); return; } object_property_set_bool(OBJECT(&s->avic), true, "realized", &err); if (err) { error_propagate(errp, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->avic), 0, FSL_IMX31_AVIC_ADDR); sysbus_connect_irq(SYS_BUS_DEVICE(&s->avic), 0, qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_IRQ)); sysbus_connect_irq(SYS_BUS_DEVICE(&s->avic), 1, qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ)); object_property_set_bool(OBJECT(&s->ccm), true, "realized", &err); if (err) { error_propagate(errp, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, FSL_IMX31_CCM_ADDR); for (i = 0; i < FSL_IMX31_NUM_UARTS; i++) { static const struct { hwaddr addr; unsigned int irq; } serial_table[FSL_IMX31_NUM_UARTS] = { { FSL_IMX31_UART1_ADDR, FSL_IMX31_UART1_IRQ }, { FSL_IMX31_UART2_ADDR, FSL_IMX31_UART2_IRQ }, }; if (i < MAX_SERIAL_PORTS) { Chardev *chr; chr = serial_hds[i]; if (!chr) { char label[20]; snprintf(label, sizeof(label), "imx31.uart%d", i); chr = qemu_chr_new(label, "null"); } qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr); } object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err); if (err) { error_propagate(errp, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, serial_table[i].addr); sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0, qdev_get_gpio_in(DEVICE(&s->avic), serial_table[i].irq)); } s->gpt.ccm = IMX_CCM(&s->ccm); object_property_set_bool(OBJECT(&s->gpt), true, "realized", &err); if (err) { error_propagate(errp, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpt), 0, FSL_IMX31_GPT_ADDR); sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpt), 0, qdev_get_gpio_in(DEVICE(&s->avic), FSL_IMX31_GPT_IRQ)); for (i = 0; i < FSL_IMX31_NUM_EPITS; i++) { static const struct { hwaddr addr; unsigned int irq; } epit_table[FSL_IMX31_NUM_EPITS] = { { FSL_IMX31_EPIT1_ADDR, FSL_IMX31_EPIT1_IRQ }, { FSL_IMX31_EPIT2_ADDR, FSL_IMX31_EPIT2_IRQ }, }; s->epit[i].ccm = IMX_CCM(&s->ccm); object_property_set_bool(OBJECT(&s->epit[i]), true, "realized", &err); if (err) { error_propagate(errp, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->epit[i]), 0, epit_table[i].addr); sysbus_connect_irq(SYS_BUS_DEVICE(&s->epit[i]), 0, qdev_get_gpio_in(DEVICE(&s->avic), epit_table[i].irq)); } for (i = 0; i < FSL_IMX31_NUM_I2CS; i++) { static const struct { hwaddr addr; unsigned int irq; } i2c_table[FSL_IMX31_NUM_I2CS] = { { FSL_IMX31_I2C1_ADDR, FSL_IMX31_I2C1_IRQ }, { FSL_IMX31_I2C2_ADDR, FSL_IMX31_I2C2_IRQ }, { FSL_IMX31_I2C3_ADDR, FSL_IMX31_I2C3_IRQ } }; object_property_set_bool(OBJECT(&s->i2c[i]), true, "realized", &err); if (err) { error_propagate(errp, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c[i]), 0, i2c_table[i].addr); sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c[i]), 0, qdev_get_gpio_in(DEVICE(&s->avic), i2c_table[i].irq)); } for (i = 0; i < FSL_IMX31_NUM_GPIOS; i++) { static const struct { hwaddr addr; unsigned int irq; } gpio_table[FSL_IMX31_NUM_GPIOS] = { { FSL_IMX31_GPIO1_ADDR, FSL_IMX31_GPIO1_IRQ }, { FSL_IMX31_GPIO2_ADDR, FSL_IMX31_GPIO2_IRQ }, { FSL_IMX31_GPIO3_ADDR, FSL_IMX31_GPIO3_IRQ } }; object_property_set_bool(OBJECT(&s->gpio[i]), false, "has-edge-sel", &error_abort); object_property_set_bool(OBJECT(&s->gpio[i]), true, "realized", &err); if (err) { error_propagate(errp, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, gpio_table[i].addr); sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0, qdev_get_gpio_in(DEVICE(&s->avic), gpio_table[i].irq)); } memory_region_init_rom_nomigrate(&s->secure_rom, NULL, "imx31.secure_rom", FSL_IMX31_SECURE_ROM_SIZE, &err); if (err) { error_propagate(errp, err); return; } memory_region_add_subregion(get_system_memory(), FSL_IMX31_SECURE_ROM_ADDR, &s->secure_rom); memory_region_init_rom_nomigrate(&s->rom, NULL, "imx31.rom", FSL_IMX31_ROM_SIZE, &err); if (err) { error_propagate(errp, err); return; } memory_region_add_subregion(get_system_memory(), FSL_IMX31_ROM_ADDR, &s->rom); memory_region_init_ram(&s->iram, NULL, "imx31.iram", FSL_IMX31_IRAM_SIZE, &err); if (err) { error_propagate(errp, err); return; } memory_region_add_subregion(get_system_memory(), FSL_IMX31_IRAM_ADDR, &s->iram); memory_region_init_alias(&s->iram_alias, NULL, "imx31.iram_alias", &s->iram, 0, FSL_IMX31_IRAM_ALIAS_SIZE); memory_region_add_subregion(get_system_memory(), FSL_IMX31_IRAM_ALIAS_ADDR, &s->iram_alias); }
{ "code": [ " memory_region_init_rom_nomigrate(&s->secure_rom, NULL, \"imx31.secure_rom\",", " memory_region_init_rom_nomigrate(&s->rom, NULL, \"imx31.rom\"," ], "line_no": [ 307, 327 ] }
static void FUNC_0(DeviceState *VAR_0, Error **VAR_1) { FslIMX31State *s = FSL_IMX31(VAR_0); uint16_t i; Error *err = NULL; object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err); if (err) { error_propagate(VAR_1, err); return; } object_property_set_bool(OBJECT(&s->avic), true, "realized", &err); if (err) { error_propagate(VAR_1, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->avic), 0, FSL_IMX31_AVIC_ADDR); sysbus_connect_irq(SYS_BUS_DEVICE(&s->avic), 0, qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_IRQ)); sysbus_connect_irq(SYS_BUS_DEVICE(&s->avic), 1, qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ)); object_property_set_bool(OBJECT(&s->ccm), true, "realized", &err); if (err) { error_propagate(VAR_1, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, FSL_IMX31_CCM_ADDR); for (i = 0; i < FSL_IMX31_NUM_UARTS; i++) { static const struct { hwaddr addr; unsigned int irq; } serial_table[FSL_IMX31_NUM_UARTS] = { { FSL_IMX31_UART1_ADDR, FSL_IMX31_UART1_IRQ }, { FSL_IMX31_UART2_ADDR, FSL_IMX31_UART2_IRQ }, }; if (i < MAX_SERIAL_PORTS) { Chardev *chr; chr = serial_hds[i]; if (!chr) { char label[20]; snprintf(label, sizeof(label), "imx31.uart%d", i); chr = qemu_chr_new(label, "null"); } qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr); } object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err); if (err) { error_propagate(VAR_1, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, serial_table[i].addr); sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0, qdev_get_gpio_in(DEVICE(&s->avic), serial_table[i].irq)); } s->gpt.ccm = IMX_CCM(&s->ccm); object_property_set_bool(OBJECT(&s->gpt), true, "realized", &err); if (err) { error_propagate(VAR_1, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpt), 0, FSL_IMX31_GPT_ADDR); sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpt), 0, qdev_get_gpio_in(DEVICE(&s->avic), FSL_IMX31_GPT_IRQ)); for (i = 0; i < FSL_IMX31_NUM_EPITS; i++) { static const struct { hwaddr addr; unsigned int irq; } epit_table[FSL_IMX31_NUM_EPITS] = { { FSL_IMX31_EPIT1_ADDR, FSL_IMX31_EPIT1_IRQ }, { FSL_IMX31_EPIT2_ADDR, FSL_IMX31_EPIT2_IRQ }, }; s->epit[i].ccm = IMX_CCM(&s->ccm); object_property_set_bool(OBJECT(&s->epit[i]), true, "realized", &err); if (err) { error_propagate(VAR_1, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->epit[i]), 0, epit_table[i].addr); sysbus_connect_irq(SYS_BUS_DEVICE(&s->epit[i]), 0, qdev_get_gpio_in(DEVICE(&s->avic), epit_table[i].irq)); } for (i = 0; i < FSL_IMX31_NUM_I2CS; i++) { static const struct { hwaddr addr; unsigned int irq; } i2c_table[FSL_IMX31_NUM_I2CS] = { { FSL_IMX31_I2C1_ADDR, FSL_IMX31_I2C1_IRQ }, { FSL_IMX31_I2C2_ADDR, FSL_IMX31_I2C2_IRQ }, { FSL_IMX31_I2C3_ADDR, FSL_IMX31_I2C3_IRQ } }; object_property_set_bool(OBJECT(&s->i2c[i]), true, "realized", &err); if (err) { error_propagate(VAR_1, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c[i]), 0, i2c_table[i].addr); sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c[i]), 0, qdev_get_gpio_in(DEVICE(&s->avic), i2c_table[i].irq)); } for (i = 0; i < FSL_IMX31_NUM_GPIOS; i++) { static const struct { hwaddr addr; unsigned int irq; } gpio_table[FSL_IMX31_NUM_GPIOS] = { { FSL_IMX31_GPIO1_ADDR, FSL_IMX31_GPIO1_IRQ }, { FSL_IMX31_GPIO2_ADDR, FSL_IMX31_GPIO2_IRQ }, { FSL_IMX31_GPIO3_ADDR, FSL_IMX31_GPIO3_IRQ } }; object_property_set_bool(OBJECT(&s->gpio[i]), false, "has-edge-sel", &error_abort); object_property_set_bool(OBJECT(&s->gpio[i]), true, "realized", &err); if (err) { error_propagate(VAR_1, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, gpio_table[i].addr); sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0, qdev_get_gpio_in(DEVICE(&s->avic), gpio_table[i].irq)); } memory_region_init_rom_nomigrate(&s->secure_rom, NULL, "imx31.secure_rom", FSL_IMX31_SECURE_ROM_SIZE, &err); if (err) { error_propagate(VAR_1, err); return; } memory_region_add_subregion(get_system_memory(), FSL_IMX31_SECURE_ROM_ADDR, &s->secure_rom); memory_region_init_rom_nomigrate(&s->rom, NULL, "imx31.rom", FSL_IMX31_ROM_SIZE, &err); if (err) { error_propagate(VAR_1, err); return; } memory_region_add_subregion(get_system_memory(), FSL_IMX31_ROM_ADDR, &s->rom); memory_region_init_ram(&s->iram, NULL, "imx31.iram", FSL_IMX31_IRAM_SIZE, &err); if (err) { error_propagate(VAR_1, err); return; } memory_region_add_subregion(get_system_memory(), FSL_IMX31_IRAM_ADDR, &s->iram); memory_region_init_alias(&s->iram_alias, NULL, "imx31.iram_alias", &s->iram, 0, FSL_IMX31_IRAM_ALIAS_SIZE); memory_region_add_subregion(get_system_memory(), FSL_IMX31_IRAM_ALIAS_ADDR, &s->iram_alias); }
[ "static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{", "FslIMX31State *s = FSL_IMX31(VAR_0);", "uint16_t i;", "Error *err = NULL;", "object_property_set_bool(OBJECT(&s->cpu), true, \"realized\", &err);", "if (err) {", "error_propagate(VAR_1, err);", "return;", "}", "object_property_set_bool(OBJECT(&s->avic), true, \"realized\", &err);", "if (err) {", "error_propagate(VAR_1, err);", "return;", "}", "sysbus_mmio_map(SYS_BUS_DEVICE(&s->avic), 0, FSL_IMX31_AVIC_ADDR);", "sysbus_connect_irq(SYS_BUS_DEVICE(&s->avic), 0,\nqdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_IRQ));", "sysbus_connect_irq(SYS_BUS_DEVICE(&s->avic), 1,\nqdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ));", "object_property_set_bool(OBJECT(&s->ccm), true, \"realized\", &err);", "if (err) {", "error_propagate(VAR_1, err);", "return;", "}", "sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, FSL_IMX31_CCM_ADDR);", "for (i = 0; i < FSL_IMX31_NUM_UARTS; i++) {", "static const struct {", "hwaddr addr;", "unsigned int irq;", "} serial_table[FSL_IMX31_NUM_UARTS] = {", "{ FSL_IMX31_UART1_ADDR, FSL_IMX31_UART1_IRQ },", "{ FSL_IMX31_UART2_ADDR, FSL_IMX31_UART2_IRQ },", "};", "if (i < MAX_SERIAL_PORTS) {", "Chardev *chr;", "chr = serial_hds[i];", "if (!chr) {", "char label[20];", "snprintf(label, sizeof(label), \"imx31.uart%d\", i);", "chr = qemu_chr_new(label, \"null\");", "}", "qdev_prop_set_chr(DEVICE(&s->uart[i]), \"chardev\", chr);", "}", "object_property_set_bool(OBJECT(&s->uart[i]), true, \"realized\", &err);", "if (err) {", "error_propagate(VAR_1, err);", "return;", "}", "sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, serial_table[i].addr);", "sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0,\nqdev_get_gpio_in(DEVICE(&s->avic),\nserial_table[i].irq));", "}", "s->gpt.ccm = IMX_CCM(&s->ccm);", "object_property_set_bool(OBJECT(&s->gpt), true, \"realized\", &err);", "if (err) {", "error_propagate(VAR_1, err);", "return;", "}", "sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpt), 0, FSL_IMX31_GPT_ADDR);", "sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpt), 0,\nqdev_get_gpio_in(DEVICE(&s->avic), FSL_IMX31_GPT_IRQ));", "for (i = 0; i < FSL_IMX31_NUM_EPITS; i++) {", "static const struct {", "hwaddr addr;", "unsigned int irq;", "} epit_table[FSL_IMX31_NUM_EPITS] = {", "{ FSL_IMX31_EPIT1_ADDR, FSL_IMX31_EPIT1_IRQ },", "{ FSL_IMX31_EPIT2_ADDR, FSL_IMX31_EPIT2_IRQ },", "};", "s->epit[i].ccm = IMX_CCM(&s->ccm);", "object_property_set_bool(OBJECT(&s->epit[i]), true, \"realized\", &err);", "if (err) {", "error_propagate(VAR_1, err);", "return;", "}", "sysbus_mmio_map(SYS_BUS_DEVICE(&s->epit[i]), 0, epit_table[i].addr);", "sysbus_connect_irq(SYS_BUS_DEVICE(&s->epit[i]), 0,\nqdev_get_gpio_in(DEVICE(&s->avic),\nepit_table[i].irq));", "}", "for (i = 0; i < FSL_IMX31_NUM_I2CS; i++) {", "static const struct {", "hwaddr addr;", "unsigned int irq;", "} i2c_table[FSL_IMX31_NUM_I2CS] = {", "{ FSL_IMX31_I2C1_ADDR, FSL_IMX31_I2C1_IRQ },", "{ FSL_IMX31_I2C2_ADDR, FSL_IMX31_I2C2_IRQ },", "{ FSL_IMX31_I2C3_ADDR, FSL_IMX31_I2C3_IRQ }", "};", "object_property_set_bool(OBJECT(&s->i2c[i]), true, \"realized\", &err);", "if (err) {", "error_propagate(VAR_1, err);", "return;", "}", "sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c[i]), 0, i2c_table[i].addr);", "sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c[i]), 0,\nqdev_get_gpio_in(DEVICE(&s->avic),\ni2c_table[i].irq));", "}", "for (i = 0; i < FSL_IMX31_NUM_GPIOS; i++) {", "static const struct {", "hwaddr addr;", "unsigned int irq;", "} gpio_table[FSL_IMX31_NUM_GPIOS] = {", "{ FSL_IMX31_GPIO1_ADDR, FSL_IMX31_GPIO1_IRQ },", "{ FSL_IMX31_GPIO2_ADDR, FSL_IMX31_GPIO2_IRQ },", "{ FSL_IMX31_GPIO3_ADDR, FSL_IMX31_GPIO3_IRQ }", "};", "object_property_set_bool(OBJECT(&s->gpio[i]), false, \"has-edge-sel\",\n&error_abort);", "object_property_set_bool(OBJECT(&s->gpio[i]), true, \"realized\", &err);", "if (err) {", "error_propagate(VAR_1, err);", "return;", "}", "sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, gpio_table[i].addr);", "sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0,\nqdev_get_gpio_in(DEVICE(&s->avic),\ngpio_table[i].irq));", "}", "memory_region_init_rom_nomigrate(&s->secure_rom, NULL, \"imx31.secure_rom\",\nFSL_IMX31_SECURE_ROM_SIZE, &err);", "if (err) {", "error_propagate(VAR_1, err);", "return;", "}", "memory_region_add_subregion(get_system_memory(), FSL_IMX31_SECURE_ROM_ADDR,\n&s->secure_rom);", "memory_region_init_rom_nomigrate(&s->rom, NULL, \"imx31.rom\",\nFSL_IMX31_ROM_SIZE, &err);", "if (err) {", "error_propagate(VAR_1, err);", "return;", "}", "memory_region_add_subregion(get_system_memory(), FSL_IMX31_ROM_ADDR,\n&s->rom);", "memory_region_init_ram(&s->iram, NULL, \"imx31.iram\", FSL_IMX31_IRAM_SIZE,\n&err);", "if (err) {", "error_propagate(VAR_1, err);", "return;", "}", "memory_region_add_subregion(get_system_memory(), FSL_IMX31_IRAM_ADDR,\n&s->iram);", "memory_region_init_alias(&s->iram_alias, NULL, \"imx31.iram_alias\",\n&s->iram, 0, FSL_IMX31_IRAM_ALIAS_SIZE);", "memory_region_add_subregion(get_system_memory(), FSL_IMX31_IRAM_ALIAS_ADDR,\n&s->iram_alias);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37, 39 ], [ 41, 43 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 81 ], [ 83 ], [ 87 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 103 ], [ 105 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 121 ], [ 123, 125, 127 ], [ 129 ], [ 133 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 149 ], [ 151, 153 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 177 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 193 ], [ 195, 197, 199 ], [ 201 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 241 ], [ 245, 247, 249 ], [ 251 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 277, 279 ], [ 281 ], [ 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 295, 297, 299 ], [ 301 ], [ 307, 309 ], [ 311 ], [ 313 ], [ 315 ], [ 317 ], [ 319, 321 ], [ 327, 329 ], [ 331 ], [ 333 ], [ 335 ], [ 337 ], [ 339, 341 ], [ 347, 349 ], [ 351 ], [ 353 ], [ 355 ], [ 357 ], [ 359, 361 ], [ 367, 369 ], [ 371, 373 ], [ 375 ] ]
9,410
static void inc_refcounts(BlockDriverState *bs, BdrvCheckResult *res, uint16_t *refcount_table, int refcount_table_size, int64_t offset, int64_t size) { BDRVQcowState *s = bs->opaque; int64_t start, last, cluster_offset; int k; if (size <= 0) return; start = start_of_cluster(s, offset); last = start_of_cluster(s, offset + size - 1); for(cluster_offset = start; cluster_offset <= last; cluster_offset += s->cluster_size) { k = cluster_offset >> s->cluster_bits; if (k < 0) { fprintf(stderr, "ERROR: invalid cluster offset=0x%" PRIx64 "\n", cluster_offset); res->corruptions++; } else if (k >= refcount_table_size) { fprintf(stderr, "Warning: cluster offset=0x%" PRIx64 " is after " "the end of the image file, can't properly check refcounts.\n", cluster_offset); res->check_errors++; } else { if (++refcount_table[k] == 0) { fprintf(stderr, "ERROR: overflow cluster offset=0x%" PRIx64 "\n", cluster_offset); res->corruptions++; } } } }
true
qemu
0abe740f1de899737242bcba1fb4a9857f7a3087
static void inc_refcounts(BlockDriverState *bs, BdrvCheckResult *res, uint16_t *refcount_table, int refcount_table_size, int64_t offset, int64_t size) { BDRVQcowState *s = bs->opaque; int64_t start, last, cluster_offset; int k; if (size <= 0) return; start = start_of_cluster(s, offset); last = start_of_cluster(s, offset + size - 1); for(cluster_offset = start; cluster_offset <= last; cluster_offset += s->cluster_size) { k = cluster_offset >> s->cluster_bits; if (k < 0) { fprintf(stderr, "ERROR: invalid cluster offset=0x%" PRIx64 "\n", cluster_offset); res->corruptions++; } else if (k >= refcount_table_size) { fprintf(stderr, "Warning: cluster offset=0x%" PRIx64 " is after " "the end of the image file, can't properly check refcounts.\n", cluster_offset); res->check_errors++; } else { if (++refcount_table[k] == 0) { fprintf(stderr, "ERROR: overflow cluster offset=0x%" PRIx64 "\n", cluster_offset); res->corruptions++; } } } }
{ "code": [ " int64_t start, last, cluster_offset;", " int k;", " if (k < 0) {", " fprintf(stderr, \"ERROR: invalid cluster offset=0x%\" PRIx64 \"\\n\",", " cluster_offset);", " res->corruptions++;", " } else if (k >= refcount_table_size) {" ], "line_no": [ 15, 17, 37, 39, 41, 43, 45 ] }
static void FUNC_0(BlockDriverState *VAR_0, BdrvCheckResult *VAR_1, uint16_t *VAR_2, int VAR_3, int64_t VAR_4, int64_t VAR_5) { BDRVQcowState *s = VAR_0->opaque; int64_t start, last, cluster_offset; int VAR_6; if (VAR_5 <= 0) return; start = start_of_cluster(s, VAR_4); last = start_of_cluster(s, VAR_4 + VAR_5 - 1); for(cluster_offset = start; cluster_offset <= last; cluster_offset += s->cluster_size) { VAR_6 = cluster_offset >> s->cluster_bits; if (VAR_6 < 0) { fprintf(stderr, "ERROR: invalid cluster VAR_4=0x%" PRIx64 "\n", cluster_offset); VAR_1->corruptions++; } else if (VAR_6 >= VAR_3) { fprintf(stderr, "Warning: cluster VAR_4=0x%" PRIx64 " is after " "the end of the image file, can't properly check refcounts.\n", cluster_offset); VAR_1->check_errors++; } else { if (++VAR_2[VAR_6] == 0) { fprintf(stderr, "ERROR: overflow cluster VAR_4=0x%" PRIx64 "\n", cluster_offset); VAR_1->corruptions++; } } } }
[ "static void FUNC_0(BlockDriverState *VAR_0,\nBdrvCheckResult *VAR_1,\nuint16_t *VAR_2,\nint VAR_3,\nint64_t VAR_4, int64_t VAR_5)\n{", "BDRVQcowState *s = VAR_0->opaque;", "int64_t start, last, cluster_offset;", "int VAR_6;", "if (VAR_5 <= 0)\nreturn;", "start = start_of_cluster(s, VAR_4);", "last = start_of_cluster(s, VAR_4 + VAR_5 - 1);", "for(cluster_offset = start; cluster_offset <= last;", "cluster_offset += s->cluster_size) {", "VAR_6 = cluster_offset >> s->cluster_bits;", "if (VAR_6 < 0) {", "fprintf(stderr, \"ERROR: invalid cluster VAR_4=0x%\" PRIx64 \"\\n\",\ncluster_offset);", "VAR_1->corruptions++;", "} else if (VAR_6 >= VAR_3) {", "fprintf(stderr, \"Warning: cluster VAR_4=0x%\" PRIx64 \" is after \"\n\"the end of the image file, can't properly check refcounts.\\n\",\ncluster_offset);", "VAR_1->check_errors++;", "} else {", "if (++VAR_2[VAR_6] == 0) {", "fprintf(stderr, \"ERROR: overflow cluster VAR_4=0x%\" PRIx64\n\"\\n\", cluster_offset);", "VAR_1->corruptions++;", "}", "}", "}", "}" ]
[ 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21, 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39, 41 ], [ 43 ], [ 45 ], [ 47, 49, 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59, 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ] ]
9,411
static int read_decoding_params(MLPDecodeContext *m, GetBitContext *gbp, unsigned int substr) { SubStream *s = &m->substream[substr]; unsigned int ch; int ret; if (s->param_presence_flags & PARAM_PRESENCE) if (get_bits1(gbp)) s->param_presence_flags = get_bits(gbp, 8); if (s->param_presence_flags & PARAM_BLOCKSIZE) if (get_bits1(gbp)) { s->blocksize = get_bits(gbp, 9); if (s->blocksize < 8 || s->blocksize > m->access_unit_size) { av_log(m->avctx, AV_LOG_ERROR, "Invalid blocksize.\n"); s->blocksize = 0; return AVERROR_INVALIDDATA; } } if (s->param_presence_flags & PARAM_MATRIX) if (get_bits1(gbp)) if ((ret = read_matrix_params(m, substr, gbp)) < 0) return ret; if (s->param_presence_flags & PARAM_OUTSHIFT) if (get_bits1(gbp)) { for (ch = 0; ch <= s->max_matrix_channel; ch++) { s->output_shift[ch] = get_sbits(gbp, 4); if (s->output_shift[ch] < 0) { avpriv_request_sample(m->avctx, "Negative output_shift"); s->output_shift[ch] = 0; } } if (substr == m->max_decoded_substream) m->dsp.mlp_pack_output = m->dsp.mlp_select_pack_output(s->ch_assign, s->output_shift, s->max_matrix_channel, m->avctx->sample_fmt == AV_SAMPLE_FMT_S32); } if (s->param_presence_flags & PARAM_QUANTSTEP) if (get_bits1(gbp)) for (ch = 0; ch <= s->max_channel; ch++) { ChannelParams *cp = &s->channel_params[ch]; s->quant_step_size[ch] = get_bits(gbp, 4); cp->sign_huff_offset = calculate_sign_huff(m, substr, ch); } for (ch = s->min_channel; ch <= s->max_channel; ch++) if (get_bits1(gbp)) if ((ret = read_channel_params(m, substr, gbp, ch)) < 0) return ret; return 0; }
true
FFmpeg
361e0310d95bf2a0377f168518d1135ae15ca3f8
static int read_decoding_params(MLPDecodeContext *m, GetBitContext *gbp, unsigned int substr) { SubStream *s = &m->substream[substr]; unsigned int ch; int ret; if (s->param_presence_flags & PARAM_PRESENCE) if (get_bits1(gbp)) s->param_presence_flags = get_bits(gbp, 8); if (s->param_presence_flags & PARAM_BLOCKSIZE) if (get_bits1(gbp)) { s->blocksize = get_bits(gbp, 9); if (s->blocksize < 8 || s->blocksize > m->access_unit_size) { av_log(m->avctx, AV_LOG_ERROR, "Invalid blocksize.\n"); s->blocksize = 0; return AVERROR_INVALIDDATA; } } if (s->param_presence_flags & PARAM_MATRIX) if (get_bits1(gbp)) if ((ret = read_matrix_params(m, substr, gbp)) < 0) return ret; if (s->param_presence_flags & PARAM_OUTSHIFT) if (get_bits1(gbp)) { for (ch = 0; ch <= s->max_matrix_channel; ch++) { s->output_shift[ch] = get_sbits(gbp, 4); if (s->output_shift[ch] < 0) { avpriv_request_sample(m->avctx, "Negative output_shift"); s->output_shift[ch] = 0; } } if (substr == m->max_decoded_substream) m->dsp.mlp_pack_output = m->dsp.mlp_select_pack_output(s->ch_assign, s->output_shift, s->max_matrix_channel, m->avctx->sample_fmt == AV_SAMPLE_FMT_S32); } if (s->param_presence_flags & PARAM_QUANTSTEP) if (get_bits1(gbp)) for (ch = 0; ch <= s->max_channel; ch++) { ChannelParams *cp = &s->channel_params[ch]; s->quant_step_size[ch] = get_bits(gbp, 4); cp->sign_huff_offset = calculate_sign_huff(m, substr, ch); } for (ch = s->min_channel; ch <= s->max_channel; ch++) if (get_bits1(gbp)) if ((ret = read_channel_params(m, substr, gbp, ch)) < 0) return ret; return 0; }
{ "code": [ " int ret;", " ChannelParams *cp = &s->channel_params[ch];", " cp->sign_huff_offset = calculate_sign_huff(m, substr, ch);", " if (get_bits1(gbp))", " return ret;", " return 0;" ], "line_no": [ 11, 91, 99, 17, 49, 115 ] }
static int FUNC_0(MLPDecodeContext *VAR_0, GetBitContext *VAR_1, unsigned int VAR_2) { SubStream *s = &VAR_0->substream[VAR_2]; unsigned int VAR_3; int VAR_4; if (s->param_presence_flags & PARAM_PRESENCE) if (get_bits1(VAR_1)) s->param_presence_flags = get_bits(VAR_1, 8); if (s->param_presence_flags & PARAM_BLOCKSIZE) if (get_bits1(VAR_1)) { s->blocksize = get_bits(VAR_1, 9); if (s->blocksize < 8 || s->blocksize > VAR_0->access_unit_size) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid blocksize.\n"); s->blocksize = 0; return AVERROR_INVALIDDATA; } } if (s->param_presence_flags & PARAM_MATRIX) if (get_bits1(VAR_1)) if ((VAR_4 = read_matrix_params(VAR_0, VAR_2, VAR_1)) < 0) return VAR_4; if (s->param_presence_flags & PARAM_OUTSHIFT) if (get_bits1(VAR_1)) { for (VAR_3 = 0; VAR_3 <= s->max_matrix_channel; VAR_3++) { s->output_shift[VAR_3] = get_sbits(VAR_1, 4); if (s->output_shift[VAR_3] < 0) { avpriv_request_sample(VAR_0->avctx, "Negative output_shift"); s->output_shift[VAR_3] = 0; } } if (VAR_2 == VAR_0->max_decoded_substream) VAR_0->dsp.mlp_pack_output = VAR_0->dsp.mlp_select_pack_output(s->ch_assign, s->output_shift, s->max_matrix_channel, VAR_0->avctx->sample_fmt == AV_SAMPLE_FMT_S32); } if (s->param_presence_flags & PARAM_QUANTSTEP) if (get_bits1(VAR_1)) for (VAR_3 = 0; VAR_3 <= s->max_channel; VAR_3++) { ChannelParams *cp = &s->channel_params[VAR_3]; s->quant_step_size[VAR_3] = get_bits(VAR_1, 4); cp->sign_huff_offset = calculate_sign_huff(VAR_0, VAR_2, VAR_3); } for (VAR_3 = s->min_channel; VAR_3 <= s->max_channel; VAR_3++) if (get_bits1(VAR_1)) if ((VAR_4 = read_channel_params(VAR_0, VAR_2, VAR_1, VAR_3)) < 0) return VAR_4; return 0; }
[ "static int FUNC_0(MLPDecodeContext *VAR_0, GetBitContext *VAR_1,\nunsigned int VAR_2)\n{", "SubStream *s = &VAR_0->substream[VAR_2];", "unsigned int VAR_3;", "int VAR_4;", "if (s->param_presence_flags & PARAM_PRESENCE)\nif (get_bits1(VAR_1))\ns->param_presence_flags = get_bits(VAR_1, 8);", "if (s->param_presence_flags & PARAM_BLOCKSIZE)\nif (get_bits1(VAR_1)) {", "s->blocksize = get_bits(VAR_1, 9);", "if (s->blocksize < 8 || s->blocksize > VAR_0->access_unit_size) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid blocksize.\\n\");", "s->blocksize = 0;", "return AVERROR_INVALIDDATA;", "}", "}", "if (s->param_presence_flags & PARAM_MATRIX)\nif (get_bits1(VAR_1))\nif ((VAR_4 = read_matrix_params(VAR_0, VAR_2, VAR_1)) < 0)\nreturn VAR_4;", "if (s->param_presence_flags & PARAM_OUTSHIFT)\nif (get_bits1(VAR_1)) {", "for (VAR_3 = 0; VAR_3 <= s->max_matrix_channel; VAR_3++) {", "s->output_shift[VAR_3] = get_sbits(VAR_1, 4);", "if (s->output_shift[VAR_3] < 0) {", "avpriv_request_sample(VAR_0->avctx, \"Negative output_shift\");", "s->output_shift[VAR_3] = 0;", "}", "}", "if (VAR_2 == VAR_0->max_decoded_substream)\nVAR_0->dsp.mlp_pack_output = VAR_0->dsp.mlp_select_pack_output(s->ch_assign,\ns->output_shift,\ns->max_matrix_channel,\nVAR_0->avctx->sample_fmt == AV_SAMPLE_FMT_S32);", "}", "if (s->param_presence_flags & PARAM_QUANTSTEP)\nif (get_bits1(VAR_1))\nfor (VAR_3 = 0; VAR_3 <= s->max_channel; VAR_3++) {", "ChannelParams *cp = &s->channel_params[VAR_3];", "s->quant_step_size[VAR_3] = get_bits(VAR_1, 4);", "cp->sign_huff_offset = calculate_sign_huff(VAR_0, VAR_2, VAR_3);", "}", "for (VAR_3 = s->min_channel; VAR_3 <= s->max_channel; VAR_3++)", "if (get_bits1(VAR_1))\nif ((VAR_4 = read_channel_params(VAR_0, VAR_2, VAR_1, VAR_3)) < 0)\nreturn VAR_4;", "return 0;", "}" ]
[ 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15, 17, 19 ], [ 23, 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43, 45, 47, 49 ], [ 53, 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71, 73, 75, 77, 79 ], [ 81 ], [ 85, 87, 89 ], [ 91 ], [ 95 ], [ 99 ], [ 101 ], [ 105 ], [ 107, 109, 111 ], [ 115 ], [ 117 ] ]
9,412
static bool bdrv_requests_pending_all(void) { BlockDriverState *bs; QTAILQ_FOREACH(bs, &bdrv_states, device_list) { if (bdrv_requests_pending(bs)) { return true; } } return false; }
true
qemu
9b536adcbefb72090f43c9715ce042e37e47af73
static bool bdrv_requests_pending_all(void) { BlockDriverState *bs; QTAILQ_FOREACH(bs, &bdrv_states, device_list) { if (bdrv_requests_pending(bs)) { return true; } } return false; }
{ "code": [ "static bool bdrv_requests_pending_all(void)", " BlockDriverState *bs;", " QTAILQ_FOREACH(bs, &bdrv_states, device_list) {", " if (bdrv_requests_pending(bs)) {", " return true;", " return false;" ], "line_no": [ 1, 5, 7, 9, 11, 17 ] }
static bool FUNC_0(void) { BlockDriverState *bs; QTAILQ_FOREACH(bs, &bdrv_states, device_list) { if (bdrv_requests_pending(bs)) { return true; } } return false; }
[ "static bool FUNC_0(void)\n{", "BlockDriverState *bs;", "QTAILQ_FOREACH(bs, &bdrv_states, device_list) {", "if (bdrv_requests_pending(bs)) {", "return true;", "}", "}", "return false;", "}" ]
[ 1, 1, 1, 1, 1, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
9,413
static void mxf_write_package(AVFormatContext *s, enum MXFMetadataSetType type, const char *package_name) { MXFContext *mxf = s->priv_data; AVIOContext *pb = s->pb; int i, track_count = s->nb_streams+1; int name_size = mxf_utf16_local_tag_length(package_name); int user_comment_count = 0; if (type == MaterialPackage) { if (mxf->store_user_comments) user_comment_count = mxf_write_user_comments(s, s->metadata); mxf_write_metadata_key(pb, 0x013600); PRINT_KEY(s, "Material Package key", pb->buf_ptr - 16); klv_encode_ber_length(pb, 92 + name_size + (16*track_count) + (16*user_comment_count) + 12*mxf->store_user_comments); } else { mxf_write_metadata_key(pb, 0x013700); PRINT_KEY(s, "Source Package key", pb->buf_ptr - 16); klv_encode_ber_length(pb, 112 + name_size + (16*track_count) + 12*mxf->store_user_comments); // 20 bytes length for descriptor reference } // write uid mxf_write_local_tag(pb, 16, 0x3C0A); mxf_write_uuid(pb, type, 0); av_log(s,AV_LOG_DEBUG, "package type:%d\n", type); PRINT_KEY(s, "package uid", pb->buf_ptr - 16); // write package umid mxf_write_local_tag(pb, 32, 0x4401); mxf_write_umid(s, type == SourcePackage); PRINT_KEY(s, "package umid second part", pb->buf_ptr - 16); // package name if (name_size) mxf_write_local_tag_utf16(pb, 0x4402, package_name); // package creation date mxf_write_local_tag(pb, 8, 0x4405); avio_wb64(pb, mxf->timestamp); // package modified date mxf_write_local_tag(pb, 8, 0x4404); avio_wb64(pb, mxf->timestamp); // write track refs mxf_write_local_tag(pb, track_count*16 + 8, 0x4403); mxf_write_refs_count(pb, track_count); mxf_write_uuid(pb, type == MaterialPackage ? Track : Track + TypeBottom, -1); // timecode track for (i = 0; i < s->nb_streams; i++) mxf_write_uuid(pb, type == MaterialPackage ? Track : Track + TypeBottom, i); // write user comment refs if (mxf->store_user_comments) { mxf_write_local_tag(pb, user_comment_count*16 + 8, 0x4406); mxf_write_refs_count(pb, user_comment_count); for (i = 0; i < user_comment_count; i++) mxf_write_uuid(pb, TaggedValue, mxf->tagged_value_count - user_comment_count + i); } // write multiple descriptor reference if (type == SourcePackage) { mxf_write_local_tag(pb, 16, 0x4701); if (s->nb_streams > 1) { mxf_write_uuid(pb, MultipleDescriptor, 0); mxf_write_multi_descriptor(s); } else mxf_write_uuid(pb, SubDescriptor, 0); } // write timecode track mxf_write_track(s, mxf->timecode_track, type); mxf_write_sequence(s, mxf->timecode_track, type); mxf_write_timecode_component(s, mxf->timecode_track, type); for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; mxf_write_track(s, st, type); mxf_write_sequence(s, st, type); mxf_write_structural_component(s, st, type); if (type == SourcePackage) { MXFStreamContext *sc = st->priv_data; mxf_essence_container_uls[sc->index].write_desc(s, st); } } }
true
FFmpeg
537e901fe66c326f78e916ee9393830ee366131d
static void mxf_write_package(AVFormatContext *s, enum MXFMetadataSetType type, const char *package_name) { MXFContext *mxf = s->priv_data; AVIOContext *pb = s->pb; int i, track_count = s->nb_streams+1; int name_size = mxf_utf16_local_tag_length(package_name); int user_comment_count = 0; if (type == MaterialPackage) { if (mxf->store_user_comments) user_comment_count = mxf_write_user_comments(s, s->metadata); mxf_write_metadata_key(pb, 0x013600); PRINT_KEY(s, "Material Package key", pb->buf_ptr - 16); klv_encode_ber_length(pb, 92 + name_size + (16*track_count) + (16*user_comment_count) + 12*mxf->store_user_comments); } else { mxf_write_metadata_key(pb, 0x013700); PRINT_KEY(s, "Source Package key", pb->buf_ptr - 16); klv_encode_ber_length(pb, 112 + name_size + (16*track_count) + 12*mxf->store_user_comments); } mxf_write_local_tag(pb, 16, 0x3C0A); mxf_write_uuid(pb, type, 0); av_log(s,AV_LOG_DEBUG, "package type:%d\n", type); PRINT_KEY(s, "package uid", pb->buf_ptr - 16); mxf_write_local_tag(pb, 32, 0x4401); mxf_write_umid(s, type == SourcePackage); PRINT_KEY(s, "package umid second part", pb->buf_ptr - 16); if (name_size) mxf_write_local_tag_utf16(pb, 0x4402, package_name); mxf_write_local_tag(pb, 8, 0x4405); avio_wb64(pb, mxf->timestamp); mxf_write_local_tag(pb, 8, 0x4404); avio_wb64(pb, mxf->timestamp); mxf_write_local_tag(pb, track_count*16 + 8, 0x4403); mxf_write_refs_count(pb, track_count); mxf_write_uuid(pb, type == MaterialPackage ? Track : Track + TypeBottom, -1); for (i = 0; i < s->nb_streams; i++) mxf_write_uuid(pb, type == MaterialPackage ? Track : Track + TypeBottom, i); if (mxf->store_user_comments) { mxf_write_local_tag(pb, user_comment_count*16 + 8, 0x4406); mxf_write_refs_count(pb, user_comment_count); for (i = 0; i < user_comment_count; i++) mxf_write_uuid(pb, TaggedValue, mxf->tagged_value_count - user_comment_count + i); } if (type == SourcePackage) { mxf_write_local_tag(pb, 16, 0x4701); if (s->nb_streams > 1) { mxf_write_uuid(pb, MultipleDescriptor, 0); mxf_write_multi_descriptor(s); } else mxf_write_uuid(pb, SubDescriptor, 0); } mxf_write_track(s, mxf->timecode_track, type); mxf_write_sequence(s, mxf->timecode_track, type); mxf_write_timecode_component(s, mxf->timecode_track, type); for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; mxf_write_track(s, st, type); mxf_write_sequence(s, st, type); mxf_write_structural_component(s, st, type); if (type == SourcePackage) { MXFStreamContext *sc = st->priv_data; mxf_essence_container_uls[sc->index].write_desc(s, st); } } }
{ "code": [ " klv_encode_ber_length(pb, 92 + name_size + (16*track_count) + (16*user_comment_count) + 12*mxf->store_user_comments);" ], "line_no": [ 27 ] }
static void FUNC_0(AVFormatContext *VAR_0, enum MXFMetadataSetType VAR_1, const char *VAR_2) { MXFContext *mxf = VAR_0->priv_data; AVIOContext *pb = VAR_0->pb; int VAR_3, VAR_4 = VAR_0->nb_streams+1; int VAR_5 = mxf_utf16_local_tag_length(VAR_2); int VAR_6 = 0; if (VAR_1 == MaterialPackage) { if (mxf->store_user_comments) VAR_6 = mxf_write_user_comments(VAR_0, VAR_0->metadata); mxf_write_metadata_key(pb, 0x013600); PRINT_KEY(VAR_0, "Material Package key", pb->buf_ptr - 16); klv_encode_ber_length(pb, 92 + VAR_5 + (16*VAR_4) + (16*VAR_6) + 12*mxf->store_user_comments); } else { mxf_write_metadata_key(pb, 0x013700); PRINT_KEY(VAR_0, "Source Package key", pb->buf_ptr - 16); klv_encode_ber_length(pb, 112 + VAR_5 + (16*VAR_4) + 12*mxf->store_user_comments); } mxf_write_local_tag(pb, 16, 0x3C0A); mxf_write_uuid(pb, VAR_1, 0); av_log(VAR_0,AV_LOG_DEBUG, "package VAR_1:%d\n", VAR_1); PRINT_KEY(VAR_0, "package uid", pb->buf_ptr - 16); mxf_write_local_tag(pb, 32, 0x4401); mxf_write_umid(VAR_0, VAR_1 == SourcePackage); PRINT_KEY(VAR_0, "package umid second part", pb->buf_ptr - 16); if (VAR_5) mxf_write_local_tag_utf16(pb, 0x4402, VAR_2); mxf_write_local_tag(pb, 8, 0x4405); avio_wb64(pb, mxf->timestamp); mxf_write_local_tag(pb, 8, 0x4404); avio_wb64(pb, mxf->timestamp); mxf_write_local_tag(pb, VAR_4*16 + 8, 0x4403); mxf_write_refs_count(pb, VAR_4); mxf_write_uuid(pb, VAR_1 == MaterialPackage ? Track : Track + TypeBottom, -1); for (VAR_3 = 0; VAR_3 < VAR_0->nb_streams; VAR_3++) mxf_write_uuid(pb, VAR_1 == MaterialPackage ? Track : Track + TypeBottom, VAR_3); if (mxf->store_user_comments) { mxf_write_local_tag(pb, VAR_6*16 + 8, 0x4406); mxf_write_refs_count(pb, VAR_6); for (VAR_3 = 0; VAR_3 < VAR_6; VAR_3++) mxf_write_uuid(pb, TaggedValue, mxf->tagged_value_count - VAR_6 + VAR_3); } if (VAR_1 == SourcePackage) { mxf_write_local_tag(pb, 16, 0x4701); if (VAR_0->nb_streams > 1) { mxf_write_uuid(pb, MultipleDescriptor, 0); mxf_write_multi_descriptor(VAR_0); } else mxf_write_uuid(pb, SubDescriptor, 0); } mxf_write_track(VAR_0, mxf->timecode_track, VAR_1); mxf_write_sequence(VAR_0, mxf->timecode_track, VAR_1); mxf_write_timecode_component(VAR_0, mxf->timecode_track, VAR_1); for (VAR_3 = 0; VAR_3 < VAR_0->nb_streams; VAR_3++) { AVStream *st = VAR_0->streams[VAR_3]; mxf_write_track(VAR_0, st, VAR_1); mxf_write_sequence(VAR_0, st, VAR_1); mxf_write_structural_component(VAR_0, st, VAR_1); if (VAR_1 == SourcePackage) { MXFStreamContext *sc = st->priv_data; mxf_essence_container_uls[sc->index].write_desc(VAR_0, st); } } }
[ "static void FUNC_0(AVFormatContext *VAR_0, enum MXFMetadataSetType VAR_1, const char *VAR_2)\n{", "MXFContext *mxf = VAR_0->priv_data;", "AVIOContext *pb = VAR_0->pb;", "int VAR_3, VAR_4 = VAR_0->nb_streams+1;", "int VAR_5 = mxf_utf16_local_tag_length(VAR_2);", "int VAR_6 = 0;", "if (VAR_1 == MaterialPackage) {", "if (mxf->store_user_comments)\nVAR_6 = mxf_write_user_comments(VAR_0, VAR_0->metadata);", "mxf_write_metadata_key(pb, 0x013600);", "PRINT_KEY(VAR_0, \"Material Package key\", pb->buf_ptr - 16);", "klv_encode_ber_length(pb, 92 + VAR_5 + (16*VAR_4) + (16*VAR_6) + 12*mxf->store_user_comments);", "} else {", "mxf_write_metadata_key(pb, 0x013700);", "PRINT_KEY(VAR_0, \"Source Package key\", pb->buf_ptr - 16);", "klv_encode_ber_length(pb, 112 + VAR_5 + (16*VAR_4) + 12*mxf->store_user_comments);", "}", "mxf_write_local_tag(pb, 16, 0x3C0A);", "mxf_write_uuid(pb, VAR_1, 0);", "av_log(VAR_0,AV_LOG_DEBUG, \"package VAR_1:%d\\n\", VAR_1);", "PRINT_KEY(VAR_0, \"package uid\", pb->buf_ptr - 16);", "mxf_write_local_tag(pb, 32, 0x4401);", "mxf_write_umid(VAR_0, VAR_1 == SourcePackage);", "PRINT_KEY(VAR_0, \"package umid second part\", pb->buf_ptr - 16);", "if (VAR_5)\nmxf_write_local_tag_utf16(pb, 0x4402, VAR_2);", "mxf_write_local_tag(pb, 8, 0x4405);", "avio_wb64(pb, mxf->timestamp);", "mxf_write_local_tag(pb, 8, 0x4404);", "avio_wb64(pb, mxf->timestamp);", "mxf_write_local_tag(pb, VAR_4*16 + 8, 0x4403);", "mxf_write_refs_count(pb, VAR_4);", "mxf_write_uuid(pb, VAR_1 == MaterialPackage ? Track :\nTrack + TypeBottom, -1);", "for (VAR_3 = 0; VAR_3 < VAR_0->nb_streams; VAR_3++)", "mxf_write_uuid(pb, VAR_1 == MaterialPackage ? Track : Track + TypeBottom, VAR_3);", "if (mxf->store_user_comments) {", "mxf_write_local_tag(pb, VAR_6*16 + 8, 0x4406);", "mxf_write_refs_count(pb, VAR_6);", "for (VAR_3 = 0; VAR_3 < VAR_6; VAR_3++)", "mxf_write_uuid(pb, TaggedValue, mxf->tagged_value_count - VAR_6 + VAR_3);", "}", "if (VAR_1 == SourcePackage) {", "mxf_write_local_tag(pb, 16, 0x4701);", "if (VAR_0->nb_streams > 1) {", "mxf_write_uuid(pb, MultipleDescriptor, 0);", "mxf_write_multi_descriptor(VAR_0);", "} else", "mxf_write_uuid(pb, SubDescriptor, 0);", "}", "mxf_write_track(VAR_0, mxf->timecode_track, VAR_1);", "mxf_write_sequence(VAR_0, mxf->timecode_track, VAR_1);", "mxf_write_timecode_component(VAR_0, mxf->timecode_track, VAR_1);", "for (VAR_3 = 0; VAR_3 < VAR_0->nb_streams; VAR_3++) {", "AVStream *st = VAR_0->streams[VAR_3];", "mxf_write_track(VAR_0, st, VAR_1);", "mxf_write_sequence(VAR_0, st, VAR_1);", "mxf_write_structural_component(VAR_0, st, VAR_1);", "if (VAR_1 == SourcePackage) {", "MXFStreamContext *sc = st->priv_data;", "mxf_essence_container_uls[sc->index].write_desc(VAR_0, st);", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19, 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 55 ], [ 57 ], [ 59 ], [ 65, 67 ], [ 73 ], [ 75 ], [ 81 ], [ 83 ], [ 89 ], [ 91 ], [ 93, 95 ], [ 97 ], [ 99 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 141 ], [ 143 ], [ 145 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ] ]
9,414
static void rxfilter_notify(NetClientState *nc) { QObject *event_data; VirtIONet *n = qemu_get_nic_opaque(nc); if (nc->rxfilter_notify_enabled) { if (n->netclient_name) { event_data = qobject_from_jsonf("{ 'name': %s, 'path': %s }", n->netclient_name, object_get_canonical_path(OBJECT(n->qdev))); } else { event_data = qobject_from_jsonf("{ 'path': %s }", object_get_canonical_path(OBJECT(n->qdev))); } monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_data); qobject_decref(event_data); /* disable event notification to avoid events flooding */ nc->rxfilter_notify_enabled = 0; } }
true
qemu
96e35046e4a97df5b4e1e24e217eb1e1701c7c71
static void rxfilter_notify(NetClientState *nc) { QObject *event_data; VirtIONet *n = qemu_get_nic_opaque(nc); if (nc->rxfilter_notify_enabled) { if (n->netclient_name) { event_data = qobject_from_jsonf("{ 'name': %s, 'path': %s }", n->netclient_name, object_get_canonical_path(OBJECT(n->qdev))); } else { event_data = qobject_from_jsonf("{ 'path': %s }", object_get_canonical_path(OBJECT(n->qdev))); } monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_data); qobject_decref(event_data); nc->rxfilter_notify_enabled = 0; } }
{ "code": [ " n->netclient_name,", " object_get_canonical_path(OBJECT(n->qdev)));", " event_data = qobject_from_jsonf(\"{ 'path': %s }\",", " object_get_canonical_path(OBJECT(n->qdev)));" ], "line_no": [ 17, 19, 23, 19 ] }
static void FUNC_0(NetClientState *VAR_0) { QObject *event_data; VirtIONet *n = qemu_get_nic_opaque(VAR_0); if (VAR_0->rxfilter_notify_enabled) { if (n->netclient_name) { event_data = qobject_from_jsonf("{ 'name': %s, 'path': %s }", n->netclient_name, object_get_canonical_path(OBJECT(n->qdev))); } else { event_data = qobject_from_jsonf("{ 'path': %s }", object_get_canonical_path(OBJECT(n->qdev))); } monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_data); qobject_decref(event_data); VAR_0->rxfilter_notify_enabled = 0; } }
[ "static void FUNC_0(NetClientState *VAR_0)\n{", "QObject *event_data;", "VirtIONet *n = qemu_get_nic_opaque(VAR_0);", "if (VAR_0->rxfilter_notify_enabled) {", "if (n->netclient_name) {", "event_data = qobject_from_jsonf(\"{ 'name': %s, 'path': %s }\",", "n->netclient_name,\nobject_get_canonical_path(OBJECT(n->qdev)));", "} else {", "event_data = qobject_from_jsonf(\"{ 'path': %s }\",", "object_get_canonical_path(OBJECT(n->qdev)));", "}", "monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_data);", "qobject_decref(event_data);", "VAR_0->rxfilter_notify_enabled = 0;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17, 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 37 ], [ 39 ], [ 41 ] ]
9,415
static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { uint32_t config_addr = rtas_ld(args, 0); uint64_t buid = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 2); unsigned int func = rtas_ld(args, 3); unsigned int req_num = rtas_ld(args, 4); /* 0 == remove all */ unsigned int seq_num = rtas_ld(args, 5); unsigned int ret_intr_type; int ndev, irq, max_irqs = 0; sPAPRPHBState *phb = NULL; PCIDevice *pdev = NULL; switch (func) { case RTAS_CHANGE_MSI_FN: case RTAS_CHANGE_FN: ret_intr_type = RTAS_TYPE_MSI; break; case RTAS_CHANGE_MSIX_FN: ret_intr_type = RTAS_TYPE_MSIX; break; default: error_report("rtas_ibm_change_msi(%u) is not implemented", func); rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); return; } /* Fins sPAPRPHBState */ phb = find_phb(spapr, buid); if (phb) { pdev = find_dev(spapr, buid, config_addr); } if (!phb || !pdev) { rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); return; } /* Releasing MSIs */ if (!req_num) { ndev = spapr_msicfg_find(phb, config_addr, false); if (ndev < 0) { trace_spapr_pci_msi("MSI has not been enabled", -1, config_addr); rtas_st(rets, 0, RTAS_OUT_HW_ERROR); return; } trace_spapr_pci_msi("Released MSIs", ndev, config_addr); rtas_st(rets, 0, RTAS_OUT_SUCCESS); rtas_st(rets, 1, 0); return; } /* Enabling MSI */ /* Find a device number in the map to add or reuse the existing one */ ndev = spapr_msicfg_find(phb, config_addr, true); if (ndev >= SPAPR_MSIX_MAX_DEVS || ndev < 0) { error_report("No free entry for a new MSI device"); rtas_st(rets, 0, RTAS_OUT_HW_ERROR); return; } trace_spapr_pci_msi("Configuring MSI", ndev, config_addr); /* Check if the device supports as many IRQs as requested */ if (ret_intr_type == RTAS_TYPE_MSI) { max_irqs = msi_nr_vectors_allocated(pdev); } else if (ret_intr_type == RTAS_TYPE_MSIX) { max_irqs = pdev->msix_entries_nr; } if (!max_irqs) { error_report("Requested interrupt type %d is not enabled for device#%d", ret_intr_type, ndev); rtas_st(rets, 0, -1); /* Hardware error */ return; } /* Correct the number if the guest asked for too many */ if (req_num > max_irqs) { req_num = max_irqs; } /* Check if there is an old config and MSI number has not changed */ if (phb->msi_table[ndev].nvec && (req_num != phb->msi_table[ndev].nvec)) { /* Unexpected behaviour */ error_report("Cannot reuse MSI config for device#%d", ndev); rtas_st(rets, 0, RTAS_OUT_HW_ERROR); return; } /* There is no cached config, allocate MSIs */ if (!phb->msi_table[ndev].nvec) { irq = xics_alloc_block(spapr->icp, 0, req_num, false, ret_intr_type == RTAS_TYPE_MSI); if (irq < 0) { error_report("Cannot allocate MSIs for device#%d", ndev); rtas_st(rets, 0, RTAS_OUT_HW_ERROR); return; } phb->msi_table[ndev].irq = irq; phb->msi_table[ndev].nvec = req_num; phb->msi_table[ndev].config_addr = config_addr; } /* Setup MSI/MSIX vectors in the device (via cfgspace or MSIX BAR) */ spapr_msi_setmsg(pdev, spapr->msi_win_addr, ret_intr_type == RTAS_TYPE_MSIX, phb->msi_table[ndev].irq, req_num); rtas_st(rets, 0, RTAS_OUT_SUCCESS); rtas_st(rets, 1, req_num); rtas_st(rets, 2, ++seq_num); rtas_st(rets, 3, ret_intr_type); trace_spapr_pci_rtas_ibm_change_msi(func, req_num); }
true
qemu
9a321e92343891e30f6fe8bfaad40454ae358bfb
static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { uint32_t config_addr = rtas_ld(args, 0); uint64_t buid = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 2); unsigned int func = rtas_ld(args, 3); unsigned int req_num = rtas_ld(args, 4); unsigned int seq_num = rtas_ld(args, 5); unsigned int ret_intr_type; int ndev, irq, max_irqs = 0; sPAPRPHBState *phb = NULL; PCIDevice *pdev = NULL; switch (func) { case RTAS_CHANGE_MSI_FN: case RTAS_CHANGE_FN: ret_intr_type = RTAS_TYPE_MSI; break; case RTAS_CHANGE_MSIX_FN: ret_intr_type = RTAS_TYPE_MSIX; break; default: error_report("rtas_ibm_change_msi(%u) is not implemented", func); rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); return; } phb = find_phb(spapr, buid); if (phb) { pdev = find_dev(spapr, buid, config_addr); } if (!phb || !pdev) { rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); return; } if (!req_num) { ndev = spapr_msicfg_find(phb, config_addr, false); if (ndev < 0) { trace_spapr_pci_msi("MSI has not been enabled", -1, config_addr); rtas_st(rets, 0, RTAS_OUT_HW_ERROR); return; } trace_spapr_pci_msi("Released MSIs", ndev, config_addr); rtas_st(rets, 0, RTAS_OUT_SUCCESS); rtas_st(rets, 1, 0); return; } ndev = spapr_msicfg_find(phb, config_addr, true); if (ndev >= SPAPR_MSIX_MAX_DEVS || ndev < 0) { error_report("No free entry for a new MSI device"); rtas_st(rets, 0, RTAS_OUT_HW_ERROR); return; } trace_spapr_pci_msi("Configuring MSI", ndev, config_addr); if (ret_intr_type == RTAS_TYPE_MSI) { max_irqs = msi_nr_vectors_allocated(pdev); } else if (ret_intr_type == RTAS_TYPE_MSIX) { max_irqs = pdev->msix_entries_nr; } if (!max_irqs) { error_report("Requested interrupt type %d is not enabled for device#%d", ret_intr_type, ndev); rtas_st(rets, 0, -1); return; } if (req_num > max_irqs) { req_num = max_irqs; } if (phb->msi_table[ndev].nvec && (req_num != phb->msi_table[ndev].nvec)) { error_report("Cannot reuse MSI config for device#%d", ndev); rtas_st(rets, 0, RTAS_OUT_HW_ERROR); return; } if (!phb->msi_table[ndev].nvec) { irq = xics_alloc_block(spapr->icp, 0, req_num, false, ret_intr_type == RTAS_TYPE_MSI); if (irq < 0) { error_report("Cannot allocate MSIs for device#%d", ndev); rtas_st(rets, 0, RTAS_OUT_HW_ERROR); return; } phb->msi_table[ndev].irq = irq; phb->msi_table[ndev].nvec = req_num; phb->msi_table[ndev].config_addr = config_addr; } spapr_msi_setmsg(pdev, spapr->msi_win_addr, ret_intr_type == RTAS_TYPE_MSIX, phb->msi_table[ndev].irq, req_num); rtas_st(rets, 0, RTAS_OUT_SUCCESS); rtas_st(rets, 1, req_num); rtas_st(rets, 2, ++seq_num); rtas_st(rets, 3, ret_intr_type); trace_spapr_pci_rtas_ibm_change_msi(func, req_num); }
{ "code": [ " int ndev, irq, max_irqs = 0;", " ndev = spapr_msicfg_find(phb, config_addr, false);", " if (ndev < 0) {", " trace_spapr_pci_msi(\"MSI has not been enabled\", -1, config_addr);", " trace_spapr_pci_msi(\"Released MSIs\", ndev, config_addr);", " ndev = spapr_msicfg_find(phb, config_addr, true);", " if (ndev >= SPAPR_MSIX_MAX_DEVS || ndev < 0) {", " error_report(\"No free entry for a new MSI device\");", " rtas_st(rets, 0, RTAS_OUT_HW_ERROR);", " trace_spapr_pci_msi(\"Configuring MSI\", ndev, config_addr);", " error_report(\"Requested interrupt type %d is not enabled for device#%d\",", " ret_intr_type, ndev);", " if (phb->msi_table[ndev].nvec && (req_num != phb->msi_table[ndev].nvec)) {", " error_report(\"Cannot reuse MSI config for device#%d\", ndev);", " if (!phb->msi_table[ndev].nvec) {", " irq = xics_alloc_block(spapr->icp, 0, req_num, false,", " ret_intr_type == RTAS_TYPE_MSI);", " if (irq < 0) {", " error_report(\"Cannot allocate MSIs for device#%d\", ndev);", " rtas_st(rets, 0, RTAS_OUT_HW_ERROR);", " phb->msi_table[ndev].irq = irq;", " phb->msi_table[ndev].nvec = req_num;", " phb->msi_table[ndev].config_addr = config_addr;", " phb->msi_table[ndev].irq, req_num);", " trace_spapr_pci_rtas_ibm_change_msi(func, req_num);" ], "line_no": [ 23, 83, 85, 87, 95, 113, 115, 117, 119, 125, 143, 145, 165, 169, 181, 183, 185, 187, 189, 89, 197, 199, 201, 211, 225 ] }
static void FUNC_0(PowerPCCPU *VAR_0, sPAPREnvironment *VAR_1, uint32_t VAR_2, uint32_t VAR_3, target_ulong VAR_4, uint32_t VAR_5, target_ulong VAR_6) { uint32_t config_addr = rtas_ld(VAR_4, 0); uint64_t buid = ((uint64_t)rtas_ld(VAR_4, 1) << 32) | rtas_ld(VAR_4, 2); unsigned int VAR_7 = rtas_ld(VAR_4, 3); unsigned int VAR_8 = rtas_ld(VAR_4, 4); unsigned int VAR_9 = rtas_ld(VAR_4, 5); unsigned int VAR_10; int VAR_11, VAR_12, VAR_13 = 0; sPAPRPHBState *phb = NULL; PCIDevice *pdev = NULL; switch (VAR_7) { case RTAS_CHANGE_MSI_FN: case RTAS_CHANGE_FN: VAR_10 = RTAS_TYPE_MSI; break; case RTAS_CHANGE_MSIX_FN: VAR_10 = RTAS_TYPE_MSIX; break; default: error_report("FUNC_0(%u) is not implemented", VAR_7); rtas_st(VAR_6, 0, RTAS_OUT_PARAM_ERROR); return; } phb = find_phb(VAR_1, buid); if (phb) { pdev = find_dev(VAR_1, buid, config_addr); } if (!phb || !pdev) { rtas_st(VAR_6, 0, RTAS_OUT_PARAM_ERROR); return; } if (!VAR_8) { VAR_11 = spapr_msicfg_find(phb, config_addr, false); if (VAR_11 < 0) { trace_spapr_pci_msi("MSI has not been enabled", -1, config_addr); rtas_st(VAR_6, 0, RTAS_OUT_HW_ERROR); return; } trace_spapr_pci_msi("Released MSIs", VAR_11, config_addr); rtas_st(VAR_6, 0, RTAS_OUT_SUCCESS); rtas_st(VAR_6, 1, 0); return; } VAR_11 = spapr_msicfg_find(phb, config_addr, true); if (VAR_11 >= SPAPR_MSIX_MAX_DEVS || VAR_11 < 0) { error_report("No free entry for a new MSI device"); rtas_st(VAR_6, 0, RTAS_OUT_HW_ERROR); return; } trace_spapr_pci_msi("Configuring MSI", VAR_11, config_addr); if (VAR_10 == RTAS_TYPE_MSI) { VAR_13 = msi_nr_vectors_allocated(pdev); } else if (VAR_10 == RTAS_TYPE_MSIX) { VAR_13 = pdev->msix_entries_nr; } if (!VAR_13) { error_report("Requested interrupt type %d is not enabled for device#%d", VAR_10, VAR_11); rtas_st(VAR_6, 0, -1); return; } if (VAR_8 > VAR_13) { VAR_8 = VAR_13; } if (phb->msi_table[VAR_11].nvec && (VAR_8 != phb->msi_table[VAR_11].nvec)) { error_report("Cannot reuse MSI config for device#%d", VAR_11); rtas_st(VAR_6, 0, RTAS_OUT_HW_ERROR); return; } if (!phb->msi_table[VAR_11].nvec) { VAR_12 = xics_alloc_block(VAR_1->icp, 0, VAR_8, false, VAR_10 == RTAS_TYPE_MSI); if (VAR_12 < 0) { error_report("Cannot allocate MSIs for device#%d", VAR_11); rtas_st(VAR_6, 0, RTAS_OUT_HW_ERROR); return; } phb->msi_table[VAR_11].VAR_12 = VAR_12; phb->msi_table[VAR_11].nvec = VAR_8; phb->msi_table[VAR_11].config_addr = config_addr; } spapr_msi_setmsg(pdev, VAR_1->msi_win_addr, VAR_10 == RTAS_TYPE_MSIX, phb->msi_table[VAR_11].VAR_12, VAR_8); rtas_st(VAR_6, 0, RTAS_OUT_SUCCESS); rtas_st(VAR_6, 1, VAR_8); rtas_st(VAR_6, 2, ++VAR_9); rtas_st(VAR_6, 3, VAR_10); trace_spapr_pci_rtas_ibm_change_msi(VAR_7, VAR_8); }
[ "static void FUNC_0(PowerPCCPU *VAR_0, sPAPREnvironment *VAR_1,\nuint32_t VAR_2, uint32_t VAR_3,\ntarget_ulong VAR_4, uint32_t VAR_5,\ntarget_ulong VAR_6)\n{", "uint32_t config_addr = rtas_ld(VAR_4, 0);", "uint64_t buid = ((uint64_t)rtas_ld(VAR_4, 1) << 32) | rtas_ld(VAR_4, 2);", "unsigned int VAR_7 = rtas_ld(VAR_4, 3);", "unsigned int VAR_8 = rtas_ld(VAR_4, 4);", "unsigned int VAR_9 = rtas_ld(VAR_4, 5);", "unsigned int VAR_10;", "int VAR_11, VAR_12, VAR_13 = 0;", "sPAPRPHBState *phb = NULL;", "PCIDevice *pdev = NULL;", "switch (VAR_7) {", "case RTAS_CHANGE_MSI_FN:\ncase RTAS_CHANGE_FN:\nVAR_10 = RTAS_TYPE_MSI;", "break;", "case RTAS_CHANGE_MSIX_FN:\nVAR_10 = RTAS_TYPE_MSIX;", "break;", "default:\nerror_report(\"FUNC_0(%u) is not implemented\", VAR_7);", "rtas_st(VAR_6, 0, RTAS_OUT_PARAM_ERROR);", "return;", "}", "phb = find_phb(VAR_1, buid);", "if (phb) {", "pdev = find_dev(VAR_1, buid, config_addr);", "}", "if (!phb || !pdev) {", "rtas_st(VAR_6, 0, RTAS_OUT_PARAM_ERROR);", "return;", "}", "if (!VAR_8) {", "VAR_11 = spapr_msicfg_find(phb, config_addr, false);", "if (VAR_11 < 0) {", "trace_spapr_pci_msi(\"MSI has not been enabled\", -1, config_addr);", "rtas_st(VAR_6, 0, RTAS_OUT_HW_ERROR);", "return;", "}", "trace_spapr_pci_msi(\"Released MSIs\", VAR_11, config_addr);", "rtas_st(VAR_6, 0, RTAS_OUT_SUCCESS);", "rtas_st(VAR_6, 1, 0);", "return;", "}", "VAR_11 = spapr_msicfg_find(phb, config_addr, true);", "if (VAR_11 >= SPAPR_MSIX_MAX_DEVS || VAR_11 < 0) {", "error_report(\"No free entry for a new MSI device\");", "rtas_st(VAR_6, 0, RTAS_OUT_HW_ERROR);", "return;", "}", "trace_spapr_pci_msi(\"Configuring MSI\", VAR_11, config_addr);", "if (VAR_10 == RTAS_TYPE_MSI) {", "VAR_13 = msi_nr_vectors_allocated(pdev);", "} else if (VAR_10 == RTAS_TYPE_MSIX) {", "VAR_13 = pdev->msix_entries_nr;", "}", "if (!VAR_13) {", "error_report(\"Requested interrupt type %d is not enabled for device#%d\",\nVAR_10, VAR_11);", "rtas_st(VAR_6, 0, -1);", "return;", "}", "if (VAR_8 > VAR_13) {", "VAR_8 = VAR_13;", "}", "if (phb->msi_table[VAR_11].nvec && (VAR_8 != phb->msi_table[VAR_11].nvec)) {", "error_report(\"Cannot reuse MSI config for device#%d\", VAR_11);", "rtas_st(VAR_6, 0, RTAS_OUT_HW_ERROR);", "return;", "}", "if (!phb->msi_table[VAR_11].nvec) {", "VAR_12 = xics_alloc_block(VAR_1->icp, 0, VAR_8, false,\nVAR_10 == RTAS_TYPE_MSI);", "if (VAR_12 < 0) {", "error_report(\"Cannot allocate MSIs for device#%d\", VAR_11);", "rtas_st(VAR_6, 0, RTAS_OUT_HW_ERROR);", "return;", "}", "phb->msi_table[VAR_11].VAR_12 = VAR_12;", "phb->msi_table[VAR_11].nvec = VAR_8;", "phb->msi_table[VAR_11].config_addr = config_addr;", "}", "spapr_msi_setmsg(pdev, VAR_1->msi_win_addr, VAR_10 == RTAS_TYPE_MSIX,\nphb->msi_table[VAR_11].VAR_12, VAR_8);", "rtas_st(VAR_6, 0, RTAS_OUT_SUCCESS);", "rtas_st(VAR_6, 1, VAR_8);", "rtas_st(VAR_6, 2, ++VAR_9);", "rtas_st(VAR_6, 3, VAR_10);", "trace_spapr_pci_rtas_ibm_change_msi(VAR_7, VAR_8);", "}" ]
[ 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, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33, 35, 37 ], [ 39 ], [ 41, 43 ], [ 45 ], [ 47, 49 ], [ 51 ], [ 53 ], [ 55 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143, 145 ], [ 147 ], [ 149 ], [ 151 ], [ 155 ], [ 157 ], [ 159 ], [ 165 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 181 ], [ 183, 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 209, 211 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 225 ], [ 227 ] ]
9,416
static void dec_sru(DisasContext *dc) { if (dc->format == OP_FMT_RI) { LOG_DIS("srui r%d, r%d, %d\n", dc->r1, dc->r0, dc->imm5); } else { LOG_DIS("sru r%d, r%d, r%d\n", dc->r2, dc->r0, dc->r1); } if (!(dc->env->features & LM32_FEATURE_SHIFT)) { if (dc->format == OP_FMT_RI) { /* TODO: check r1 == 1 during runtime */ } else { if (dc->imm5 != 1) { cpu_abort(dc->env, "hardware shifter is not available\n"); } } } if (dc->format == OP_FMT_RI) { tcg_gen_shri_tl(cpu_R[dc->r1], cpu_R[dc->r0], dc->imm5); } else { TCGv t0 = tcg_temp_new(); tcg_gen_andi_tl(t0, cpu_R[dc->r1], 0x1f); tcg_gen_shr_tl(cpu_R[dc->r2], cpu_R[dc->r0], t0); tcg_temp_free(t0); } }
true
qemu
3604a76fea6ff37738d4a8f596be38407be74a83
static void dec_sru(DisasContext *dc) { if (dc->format == OP_FMT_RI) { LOG_DIS("srui r%d, r%d, %d\n", dc->r1, dc->r0, dc->imm5); } else { LOG_DIS("sru r%d, r%d, r%d\n", dc->r2, dc->r0, dc->r1); } if (!(dc->env->features & LM32_FEATURE_SHIFT)) { if (dc->format == OP_FMT_RI) { } else { if (dc->imm5 != 1) { cpu_abort(dc->env, "hardware shifter is not available\n"); } } } if (dc->format == OP_FMT_RI) { tcg_gen_shri_tl(cpu_R[dc->r1], cpu_R[dc->r0], dc->imm5); } else { TCGv t0 = tcg_temp_new(); tcg_gen_andi_tl(t0, cpu_R[dc->r1], 0x1f); tcg_gen_shr_tl(cpu_R[dc->r2], cpu_R[dc->r0], t0); tcg_temp_free(t0); } }
{ "code": [ " cpu_abort(dc->env, \"hardware shifter is not available\\n\");", " cpu_abort(dc->env, \"hardware shifter is not available\\n\");", " } else {" ], "line_no": [ 27, 27, 9 ] }
static void FUNC_0(DisasContext *VAR_0) { if (VAR_0->format == OP_FMT_RI) { LOG_DIS("srui r%d, r%d, %d\n", VAR_0->r1, VAR_0->r0, VAR_0->imm5); } else { LOG_DIS("sru r%d, r%d, r%d\n", VAR_0->r2, VAR_0->r0, VAR_0->r1); } if (!(VAR_0->env->features & LM32_FEATURE_SHIFT)) { if (VAR_0->format == OP_FMT_RI) { } else { if (VAR_0->imm5 != 1) { cpu_abort(VAR_0->env, "hardware shifter is not available\n"); } } } if (VAR_0->format == OP_FMT_RI) { tcg_gen_shri_tl(cpu_R[VAR_0->r1], cpu_R[VAR_0->r0], VAR_0->imm5); } else { TCGv t0 = tcg_temp_new(); tcg_gen_andi_tl(t0, cpu_R[VAR_0->r1], 0x1f); tcg_gen_shr_tl(cpu_R[VAR_0->r2], cpu_R[VAR_0->r0], t0); tcg_temp_free(t0); } }
[ "static void FUNC_0(DisasContext *VAR_0)\n{", "if (VAR_0->format == OP_FMT_RI) {", "LOG_DIS(\"srui r%d, r%d, %d\\n\", VAR_0->r1, VAR_0->r0, VAR_0->imm5);", "} else {", "LOG_DIS(\"sru r%d, r%d, r%d\\n\", VAR_0->r2, VAR_0->r0, VAR_0->r1);", "}", "if (!(VAR_0->env->features & LM32_FEATURE_SHIFT)) {", "if (VAR_0->format == OP_FMT_RI) {", "} else {", "if (VAR_0->imm5 != 1) {", "cpu_abort(VAR_0->env, \"hardware shifter is not available\\n\");", "}", "}", "}", "if (VAR_0->format == OP_FMT_RI) {", "tcg_gen_shri_tl(cpu_R[VAR_0->r1], cpu_R[VAR_0->r0], VAR_0->imm5);", "} else {", "TCGv t0 = tcg_temp_new();", "tcg_gen_andi_tl(t0, cpu_R[VAR_0->r1], 0x1f);", "tcg_gen_shr_tl(cpu_R[VAR_0->r2], cpu_R[VAR_0->r0], t0);", "tcg_temp_free(t0);", "}", "}" ]
[ 0, 0, 0, 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 ], [ 13 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ] ]
9,417
int ff_vbv_update(MpegEncContext *s, int frame_size) { RateControlContext *rcc = &s->rc_context; const double fps = get_fps(s->avctx); const int buffer_size = s->avctx->rc_buffer_size; const double min_rate = s->avctx->rc_min_rate / fps; const double max_rate = s->avctx->rc_max_rate / fps; av_dlog(s, "%d %f %d %f %f\n", buffer_size, rcc->buffer_index, frame_size, min_rate, max_rate); if (buffer_size) { int left; rcc->buffer_index -= frame_size; if (rcc->buffer_index < 0) { av_log(s->avctx, AV_LOG_ERROR, "rc buffer underflow\n"); rcc->buffer_index = 0; left = buffer_size - rcc->buffer_index - 1; rcc->buffer_index += av_clip(left, min_rate, max_rate); if (rcc->buffer_index > buffer_size) { int stuffing = ceil((rcc->buffer_index - buffer_size) / 8); if (stuffing < 4 && s->codec_id == AV_CODEC_ID_MPEG4) stuffing = 4; rcc->buffer_index -= 8 * stuffing; if (s->avctx->debug & FF_DEBUG_RC) av_log(s->avctx, AV_LOG_DEBUG, "stuffing %d bytes\n", stuffing); return stuffing; return 0;
true
FFmpeg
d8fb170da2e7edbfd250c1d8e1de6b1a0e965170
int ff_vbv_update(MpegEncContext *s, int frame_size) { RateControlContext *rcc = &s->rc_context; const double fps = get_fps(s->avctx); const int buffer_size = s->avctx->rc_buffer_size; const double min_rate = s->avctx->rc_min_rate / fps; const double max_rate = s->avctx->rc_max_rate / fps; av_dlog(s, "%d %f %d %f %f\n", buffer_size, rcc->buffer_index, frame_size, min_rate, max_rate); if (buffer_size) { int left; rcc->buffer_index -= frame_size; if (rcc->buffer_index < 0) { av_log(s->avctx, AV_LOG_ERROR, "rc buffer underflow\n"); rcc->buffer_index = 0; left = buffer_size - rcc->buffer_index - 1; rcc->buffer_index += av_clip(left, min_rate, max_rate); if (rcc->buffer_index > buffer_size) { int stuffing = ceil((rcc->buffer_index - buffer_size) / 8); if (stuffing < 4 && s->codec_id == AV_CODEC_ID_MPEG4) stuffing = 4; rcc->buffer_index -= 8 * stuffing; if (s->avctx->debug & FF_DEBUG_RC) av_log(s->avctx, AV_LOG_DEBUG, "stuffing %d bytes\n", stuffing); return stuffing; return 0;
{ "code": [], "line_no": [] }
int FUNC_0(MpegEncContext *VAR_0, int VAR_1) { RateControlContext *rcc = &VAR_0->rc_context; const double VAR_2 = get_fps(VAR_0->avctx); const int VAR_3 = VAR_0->avctx->rc_buffer_size; const double VAR_4 = VAR_0->avctx->rc_min_rate / VAR_2; const double VAR_5 = VAR_0->avctx->rc_max_rate / VAR_2; av_dlog(VAR_0, "%d %f %d %f %f\n", VAR_3, rcc->buffer_index, VAR_1, VAR_4, VAR_5); if (VAR_3) { int VAR_6; rcc->buffer_index -= VAR_1; if (rcc->buffer_index < 0) { av_log(VAR_0->avctx, AV_LOG_ERROR, "rc buffer underflow\n"); rcc->buffer_index = 0; VAR_6 = VAR_3 - rcc->buffer_index - 1; rcc->buffer_index += av_clip(VAR_6, VAR_4, VAR_5); if (rcc->buffer_index > VAR_3) { int VAR_7 = ceil((rcc->buffer_index - VAR_3) / 8); if (VAR_7 < 4 && VAR_0->codec_id == AV_CODEC_ID_MPEG4) VAR_7 = 4; rcc->buffer_index -= 8 * VAR_7; if (VAR_0->avctx->debug & FF_DEBUG_RC) av_log(VAR_0->avctx, AV_LOG_DEBUG, "VAR_7 %d bytes\n", VAR_7); return VAR_7; return 0;
[ "int FUNC_0(MpegEncContext *VAR_0, int VAR_1)\n{", "RateControlContext *rcc = &VAR_0->rc_context;", "const double VAR_2 = get_fps(VAR_0->avctx);", "const int VAR_3 = VAR_0->avctx->rc_buffer_size;", "const double VAR_4 = VAR_0->avctx->rc_min_rate / VAR_2;", "const double VAR_5 = VAR_0->avctx->rc_max_rate / VAR_2;", "av_dlog(VAR_0, \"%d %f %d %f %f\\n\",\nVAR_3, rcc->buffer_index, VAR_1, VAR_4, VAR_5);", "if (VAR_3) {", "int VAR_6;", "rcc->buffer_index -= VAR_1;", "if (rcc->buffer_index < 0) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"rc buffer underflow\\n\");", "rcc->buffer_index = 0;", "VAR_6 = VAR_3 - rcc->buffer_index - 1;", "rcc->buffer_index += av_clip(VAR_6, VAR_4, VAR_5);", "if (rcc->buffer_index > VAR_3) {", "int VAR_7 = ceil((rcc->buffer_index - VAR_3) / 8);", "if (VAR_7 < 4 && VAR_0->codec_id == AV_CODEC_ID_MPEG4)\nVAR_7 = 4;", "rcc->buffer_index -= 8 * VAR_7;", "if (VAR_0->avctx->debug & FF_DEBUG_RC)\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"VAR_7 %d bytes\\n\", VAR_7);", "return VAR_7;", "return 0;" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17, 19 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 38 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 55, 57 ], [ 59 ], [ 63, 65 ], [ 69 ], [ 73 ] ]
9,419
void dpy_gl_scanout(QemuConsole *con, uint32_t backing_id, bool backing_y_0_top, uint32_t x, uint32_t y, uint32_t width, uint32_t height) { assert(con->gl); con->gl->ops->dpy_gl_scanout(con->gl, backing_id, backing_y_0_top, x, y, width, height); }
true
qemu
9d8256ebc0ef88fb1f35d0405893962d20cc10ad
void dpy_gl_scanout(QemuConsole *con, uint32_t backing_id, bool backing_y_0_top, uint32_t x, uint32_t y, uint32_t width, uint32_t height) { assert(con->gl); con->gl->ops->dpy_gl_scanout(con->gl, backing_id, backing_y_0_top, x, y, width, height); }
{ "code": [], "line_no": [] }
void FUNC_0(QemuConsole *VAR_0, uint32_t VAR_1, bool VAR_2, uint32_t VAR_3, uint32_t VAR_4, uint32_t VAR_5, uint32_t VAR_6) { assert(VAR_0->gl); VAR_0->gl->ops->FUNC_0(VAR_0->gl, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6); }
[ "void FUNC_0(QemuConsole *VAR_0,\nuint32_t VAR_1, bool VAR_2,\nuint32_t VAR_3, uint32_t VAR_4, uint32_t VAR_5, uint32_t VAR_6)\n{", "assert(VAR_0->gl);", "VAR_0->gl->ops->FUNC_0(VAR_0->gl, VAR_1,\nVAR_2,\nVAR_3, VAR_4, VAR_5, VAR_6);", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3, 6, 8 ], [ 10 ], [ 12, 14, 17 ], [ 19 ] ]
9,420
void parse_options(int argc, char **argv, const OptionDef *options, void (* parse_arg_function)(const char*)) { const char *opt, *arg; int optindex, handleoptions=1; const OptionDef *po; /* parse options */ optindex = 1; while (optindex < argc) { opt = argv[optindex++]; if (handleoptions && opt[0] == '-' && opt[1] != '\0') { int bool_val = 1; if (opt[1] == '-' && opt[2] == '\0') { handleoptions = 0; continue; } opt++; po= find_option(options, opt); if (!po->name && opt[0] == 'n' && opt[1] == 'o') { /* handle 'no' bool option */ po = find_option(options, opt + 2); if (!(po->name && (po->flags & OPT_BOOL))) goto unknown_opt; bool_val = 0; } if (!po->name) po= find_option(options, "default"); if (!po->name) { unknown_opt: fprintf(stderr, "%s: unrecognized option '%s'\n", argv[0], opt); exit(1); } arg = NULL; if (po->flags & HAS_ARG) { arg = argv[optindex++]; if (!arg) { fprintf(stderr, "%s: missing argument for option '%s'\n", argv[0], opt); exit(1); } } if (po->flags & OPT_STRING) { char *str; str = av_strdup(arg); *po->u.str_arg = str; } else if (po->flags & OPT_BOOL) { *po->u.int_arg = bool_val; } else if (po->flags & OPT_INT) { *po->u.int_arg = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX); } else if (po->flags & OPT_INT64) { *po->u.int64_arg = parse_number_or_die(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX); } else if (po->flags & OPT_FLOAT) { *po->u.float_arg = parse_number_or_die(opt, arg, OPT_FLOAT, -1.0/0.0, 1.0/0.0); } else if (po->flags & OPT_FUNC2) { if (po->u.func2_arg(opt, arg) < 0) { fprintf(stderr, "%s: invalid value '%s' for option '%s'\n", argv[0], arg, opt); exit(1); } } else { po->u.func_arg(arg); } if(po->flags & OPT_EXIT) exit(0); } else { if (parse_arg_function) parse_arg_function(opt); } } }
true
FFmpeg
330d86f59377aca20372ba2e758f75e6ce45c4c2
void parse_options(int argc, char **argv, const OptionDef *options, void (* parse_arg_function)(const char*)) { const char *opt, *arg; int optindex, handleoptions=1; const OptionDef *po; optindex = 1; while (optindex < argc) { opt = argv[optindex++]; if (handleoptions && opt[0] == '-' && opt[1] != '\0') { int bool_val = 1; if (opt[1] == '-' && opt[2] == '\0') { handleoptions = 0; continue; } opt++; po= find_option(options, opt); if (!po->name && opt[0] == 'n' && opt[1] == 'o') { po = find_option(options, opt + 2); if (!(po->name && (po->flags & OPT_BOOL))) goto unknown_opt; bool_val = 0; } if (!po->name) po= find_option(options, "default"); if (!po->name) { unknown_opt: fprintf(stderr, "%s: unrecognized option '%s'\n", argv[0], opt); exit(1); } arg = NULL; if (po->flags & HAS_ARG) { arg = argv[optindex++]; if (!arg) { fprintf(stderr, "%s: missing argument for option '%s'\n", argv[0], opt); exit(1); } } if (po->flags & OPT_STRING) { char *str; str = av_strdup(arg); *po->u.str_arg = str; } else if (po->flags & OPT_BOOL) { *po->u.int_arg = bool_val; } else if (po->flags & OPT_INT) { *po->u.int_arg = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX); } else if (po->flags & OPT_INT64) { *po->u.int64_arg = parse_number_or_die(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX); } else if (po->flags & OPT_FLOAT) { *po->u.float_arg = parse_number_or_die(opt, arg, OPT_FLOAT, -1.0/0.0, 1.0/0.0); } else if (po->flags & OPT_FUNC2) { if (po->u.func2_arg(opt, arg) < 0) { fprintf(stderr, "%s: invalid value '%s' for option '%s'\n", argv[0], arg, opt); exit(1); } } else { po->u.func_arg(arg); } if(po->flags & OPT_EXIT) exit(0); } else { if (parse_arg_function) parse_arg_function(opt); } } }
{ "code": [ " fprintf(stderr, \"%s: invalid value '%s' for option '%s'\\n\", argv[0], arg, opt);" ], "line_no": [ 113 ] }
VAR_4voidVAR_4 VAR_4parse_optionsVAR_4(VAR_4intVAR_4 VAR_4VAR_0VAR_4, VAR_4charVAR_4 **VAR_4VAR_1VAR_4, VAR_4constVAR_4 VAR_4OptionDefVAR_4 *VAR_4VAR_2VAR_4, VAR_4voidVAR_4 (* VAR_4VAR_3VAR_4)(VAR_4constVAR_4 VAR_4charVAR_4*)) { VAR_4constVAR_4 VAR_4charVAR_4 *VAR_4optVAR_4, *VAR_4argVAR_4; VAR_4intVAR_4 VAR_4optindexVAR_4, VAR_4handleoptionsVAR_4=VAR_41VAR_4; VAR_4constVAR_4 VAR_4OptionDefVAR_4 *VAR_4poVAR_4; VAR_4optindexVAR_4 = VAR_41VAR_4; VAR_4whileVAR_4 (VAR_4optindexVAR_4 < VAR_4VAR_0VAR_4) { VAR_4optVAR_4 = VAR_4VAR_1VAR_4[VAR_4optindexVAR_4++]; VAR_4ifVAR_4 (VAR_4handleoptionsVAR_4 && VAR_4optVAR_4[VAR_40VAR_4] == '-' && VAR_4optVAR_4[VAR_41VAR_4] != '\VAR_40VAR_4') { VAR_4intVAR_4 VAR_4bool_valVAR_4 = VAR_41VAR_4; VAR_4ifVAR_4 (VAR_4optVAR_4[VAR_41VAR_4] == '-' && VAR_4optVAR_4[VAR_42VAR_4] == '\VAR_40VAR_4') { VAR_4handleoptionsVAR_4 = VAR_40VAR_4; VAR_4continueVAR_4; } VAR_4optVAR_4++; VAR_4poVAR_4= VAR_4find_optionVAR_4(VAR_4VAR_2VAR_4, VAR_4optVAR_4); VAR_4ifVAR_4 (!VAR_4poVAR_4->VAR_4nameVAR_4 && VAR_4optVAR_4[VAR_40VAR_4] == 'VAR_4nVAR_4' && VAR_4optVAR_4[VAR_41VAR_4] == 'VAR_4oVAR_4') { VAR_4poVAR_4 = VAR_4find_optionVAR_4(VAR_4VAR_2VAR_4, VAR_4optVAR_4 + VAR_42VAR_4); VAR_4ifVAR_4 (!(VAR_4poVAR_4->VAR_4nameVAR_4 && (VAR_4poVAR_4->VAR_4flagsVAR_4 & VAR_4OPT_BOOLVAR_4))) VAR_4gotoVAR_4 VAR_4unknown_optVAR_4; VAR_4bool_valVAR_4 = VAR_40VAR_4; } VAR_4ifVAR_4 (!VAR_4poVAR_4->VAR_4nameVAR_4) VAR_4poVAR_4= VAR_4find_optionVAR_4(VAR_4VAR_2VAR_4, "VAR_4defaultVAR_4"); VAR_4ifVAR_4 (!VAR_4poVAR_4->VAR_4nameVAR_4) { VAR_4unknown_optVAR_4: VAR_4fprintfVAR_4(VAR_4stderrVAR_4, "%VAR_4sVAR_4: VAR_4unrecognizedVAR_4 VAR_4optionVAR_4 '%VAR_4sVAR_4'\VAR_4nVAR_4", VAR_4VAR_1VAR_4[VAR_40VAR_4], VAR_4optVAR_4); VAR_4exitVAR_4(VAR_41VAR_4); } VAR_4argVAR_4 = VAR_4NULLVAR_4; VAR_4ifVAR_4 (VAR_4poVAR_4->VAR_4flagsVAR_4 & VAR_4HAS_ARGVAR_4) { VAR_4argVAR_4 = VAR_4VAR_1VAR_4[VAR_4optindexVAR_4++]; VAR_4ifVAR_4 (!VAR_4argVAR_4) { VAR_4fprintfVAR_4(VAR_4stderrVAR_4, "%VAR_4sVAR_4: VAR_4missingVAR_4 VAR_4argumentVAR_4 VAR_4forVAR_4 VAR_4optionVAR_4 '%VAR_4sVAR_4'\VAR_4nVAR_4", VAR_4VAR_1VAR_4[VAR_40VAR_4], VAR_4optVAR_4); VAR_4exitVAR_4(VAR_41VAR_4); } } VAR_4ifVAR_4 (VAR_4poVAR_4->VAR_4flagsVAR_4 & VAR_4OPT_STRINGVAR_4) { VAR_4charVAR_4 *VAR_4strVAR_4; VAR_4strVAR_4 = VAR_4av_strdupVAR_4(VAR_4argVAR_4); *VAR_4poVAR_4->VAR_4uVAR_4.VAR_4str_argVAR_4 = VAR_4strVAR_4; } VAR_4elseVAR_4 VAR_4ifVAR_4 (VAR_4poVAR_4->VAR_4flagsVAR_4 & VAR_4OPT_BOOLVAR_4) { *VAR_4poVAR_4->VAR_4uVAR_4.VAR_4int_argVAR_4 = VAR_4bool_valVAR_4; } VAR_4elseVAR_4 VAR_4ifVAR_4 (VAR_4poVAR_4->VAR_4flagsVAR_4 & VAR_4OPT_INTVAR_4) { *VAR_4poVAR_4->VAR_4uVAR_4.VAR_4int_argVAR_4 = VAR_4parse_number_or_dieVAR_4(VAR_4optVAR_4, VAR_4argVAR_4, VAR_4OPT_INT64VAR_4, VAR_4INT_MINVAR_4, VAR_4INT_MAXVAR_4); } VAR_4elseVAR_4 VAR_4ifVAR_4 (VAR_4poVAR_4->VAR_4flagsVAR_4 & VAR_4OPT_INT64VAR_4) { *VAR_4poVAR_4->VAR_4uVAR_4.VAR_4int64_argVAR_4 = VAR_4parse_number_or_dieVAR_4(VAR_4optVAR_4, VAR_4argVAR_4, VAR_4OPT_INT64VAR_4, VAR_4INT64_MINVAR_4, VAR_4INT64_MAXVAR_4); } VAR_4elseVAR_4 VAR_4ifVAR_4 (VAR_4poVAR_4->VAR_4flagsVAR_4 & VAR_4OPT_FLOATVAR_4) { *VAR_4poVAR_4->VAR_4uVAR_4.VAR_4float_argVAR_4 = VAR_4parse_number_or_dieVAR_4(VAR_4optVAR_4, VAR_4argVAR_4, VAR_4OPT_FLOATVAR_4, -VAR_41VAR_4.VAR_40VAR_4/VAR_40VAR_4.VAR_40VAR_4, VAR_41VAR_4.VAR_40VAR_4/VAR_40VAR_4.VAR_40VAR_4); } VAR_4elseVAR_4 VAR_4ifVAR_4 (VAR_4poVAR_4->VAR_4flagsVAR_4 & VAR_4OPT_FUNC2VAR_4) { VAR_4ifVAR_4 (VAR_4poVAR_4->VAR_4uVAR_4.VAR_4func2_argVAR_4(VAR_4optVAR_4, VAR_4argVAR_4) < VAR_40VAR_4) { VAR_4fprintfVAR_4(VAR_4stderrVAR_4, "%VAR_4sVAR_4: VAR_4invalidVAR_4 VAR_4valueVAR_4 '%VAR_4sVAR_4' VAR_4forVAR_4 VAR_4optionVAR_4 '%VAR_4sVAR_4'\VAR_4nVAR_4", VAR_4VAR_1VAR_4[VAR_40VAR_4], VAR_4argVAR_4, VAR_4optVAR_4); VAR_4exitVAR_4(VAR_41VAR_4); } } VAR_4elseVAR_4 { VAR_4poVAR_4->VAR_4uVAR_4.VAR_4func_argVAR_4(VAR_4argVAR_4); } VAR_4ifVAR_4(VAR_4poVAR_4->VAR_4flagsVAR_4 & VAR_4OPT_EXITVAR_4) VAR_4exitVAR_4(VAR_40VAR_4); } VAR_4elseVAR_4 { VAR_4ifVAR_4 (VAR_4VAR_3VAR_4) VAR_4VAR_3VAR_4(VAR_4optVAR_4); } } }
[ "VAR_4voidVAR_4 VAR_4parse_optionsVAR_4(VAR_4intVAR_4 VAR_4VAR_0VAR_4, VAR_4charVAR_4 **VAR_4VAR_1VAR_4, VAR_4constVAR_4 VAR_4OptionDefVAR_4 *VAR_4VAR_2VAR_4,\nVAR_4voidVAR_4 (* VAR_4VAR_3VAR_4)(VAR_4constVAR_4 VAR_4charVAR_4*))\n{", "VAR_4constVAR_4 VAR_4charVAR_4 *VAR_4optVAR_4, *VAR_4argVAR_4;", "VAR_4intVAR_4 VAR_4optindexVAR_4, VAR_4handleoptionsVAR_4=VAR_41VAR_4;", "VAR_4constVAR_4 VAR_4OptionDefVAR_4 *VAR_4poVAR_4;", "VAR_4optindexVAR_4 = VAR_41VAR_4;", "VAR_4whileVAR_4 (VAR_4optindexVAR_4 < VAR_4VAR_0VAR_4) {", "VAR_4optVAR_4 = VAR_4VAR_1VAR_4[VAR_4optindexVAR_4++];", "VAR_4ifVAR_4 (VAR_4handleoptionsVAR_4 && VAR_4optVAR_4[VAR_40VAR_4] == '-' && VAR_4optVAR_4[VAR_41VAR_4] != '\\VAR_40VAR_4') {", "VAR_4intVAR_4 VAR_4bool_valVAR_4 = VAR_41VAR_4;", "VAR_4ifVAR_4 (VAR_4optVAR_4[VAR_41VAR_4] == '-' && VAR_4optVAR_4[VAR_42VAR_4] == '\\VAR_40VAR_4') {", "VAR_4handleoptionsVAR_4 = VAR_40VAR_4;", "VAR_4continueVAR_4;", "}", "VAR_4optVAR_4++;", "VAR_4poVAR_4= VAR_4find_optionVAR_4(VAR_4VAR_2VAR_4, VAR_4optVAR_4);", "VAR_4ifVAR_4 (!VAR_4poVAR_4->VAR_4nameVAR_4 && VAR_4optVAR_4[VAR_40VAR_4] == 'VAR_4nVAR_4' && VAR_4optVAR_4[VAR_41VAR_4] == 'VAR_4oVAR_4') {", "VAR_4poVAR_4 = VAR_4find_optionVAR_4(VAR_4VAR_2VAR_4, VAR_4optVAR_4 + VAR_42VAR_4);", "VAR_4ifVAR_4 (!(VAR_4poVAR_4->VAR_4nameVAR_4 && (VAR_4poVAR_4->VAR_4flagsVAR_4 & VAR_4OPT_BOOLVAR_4)))\nVAR_4gotoVAR_4 VAR_4unknown_optVAR_4;", "VAR_4bool_valVAR_4 = VAR_40VAR_4;", "}", "VAR_4ifVAR_4 (!VAR_4poVAR_4->VAR_4nameVAR_4)\nVAR_4poVAR_4= VAR_4find_optionVAR_4(VAR_4VAR_2VAR_4, \"VAR_4defaultVAR_4\");", "VAR_4ifVAR_4 (!VAR_4poVAR_4->VAR_4nameVAR_4) {", "VAR_4unknown_optVAR_4:\nVAR_4fprintfVAR_4(VAR_4stderrVAR_4, \"%VAR_4sVAR_4: VAR_4unrecognizedVAR_4 VAR_4optionVAR_4 '%VAR_4sVAR_4'\\VAR_4nVAR_4\", VAR_4VAR_1VAR_4[VAR_40VAR_4], VAR_4optVAR_4);", "VAR_4exitVAR_4(VAR_41VAR_4);", "}", "VAR_4argVAR_4 = VAR_4NULLVAR_4;", "VAR_4ifVAR_4 (VAR_4poVAR_4->VAR_4flagsVAR_4 & VAR_4HAS_ARGVAR_4) {", "VAR_4argVAR_4 = VAR_4VAR_1VAR_4[VAR_4optindexVAR_4++];", "VAR_4ifVAR_4 (!VAR_4argVAR_4) {", "VAR_4fprintfVAR_4(VAR_4stderrVAR_4, \"%VAR_4sVAR_4: VAR_4missingVAR_4 VAR_4argumentVAR_4 VAR_4forVAR_4 VAR_4optionVAR_4 '%VAR_4sVAR_4'\\VAR_4nVAR_4\", VAR_4VAR_1VAR_4[VAR_40VAR_4], VAR_4optVAR_4);", "VAR_4exitVAR_4(VAR_41VAR_4);", "}", "}", "VAR_4ifVAR_4 (VAR_4poVAR_4->VAR_4flagsVAR_4 & VAR_4OPT_STRINGVAR_4) {", "VAR_4charVAR_4 *VAR_4strVAR_4;", "VAR_4strVAR_4 = VAR_4av_strdupVAR_4(VAR_4argVAR_4);", "*VAR_4poVAR_4->VAR_4uVAR_4.VAR_4str_argVAR_4 = VAR_4strVAR_4;", "} VAR_4elseVAR_4 VAR_4ifVAR_4 (VAR_4poVAR_4->VAR_4flagsVAR_4 & VAR_4OPT_BOOLVAR_4) {", "*VAR_4poVAR_4->VAR_4uVAR_4.VAR_4int_argVAR_4 = VAR_4bool_valVAR_4;", "} VAR_4elseVAR_4 VAR_4ifVAR_4 (VAR_4poVAR_4->VAR_4flagsVAR_4 & VAR_4OPT_INTVAR_4) {", "*VAR_4poVAR_4->VAR_4uVAR_4.VAR_4int_argVAR_4 = VAR_4parse_number_or_dieVAR_4(VAR_4optVAR_4, VAR_4argVAR_4, VAR_4OPT_INT64VAR_4, VAR_4INT_MINVAR_4, VAR_4INT_MAXVAR_4);", "} VAR_4elseVAR_4 VAR_4ifVAR_4 (VAR_4poVAR_4->VAR_4flagsVAR_4 & VAR_4OPT_INT64VAR_4) {", "*VAR_4poVAR_4->VAR_4uVAR_4.VAR_4int64_argVAR_4 = VAR_4parse_number_or_dieVAR_4(VAR_4optVAR_4, VAR_4argVAR_4, VAR_4OPT_INT64VAR_4, VAR_4INT64_MINVAR_4, VAR_4INT64_MAXVAR_4);", "} VAR_4elseVAR_4 VAR_4ifVAR_4 (VAR_4poVAR_4->VAR_4flagsVAR_4 & VAR_4OPT_FLOATVAR_4) {", "*VAR_4poVAR_4->VAR_4uVAR_4.VAR_4float_argVAR_4 = VAR_4parse_number_or_dieVAR_4(VAR_4optVAR_4, VAR_4argVAR_4, VAR_4OPT_FLOATVAR_4, -VAR_41VAR_4.VAR_40VAR_4/VAR_40VAR_4.VAR_40VAR_4, VAR_41VAR_4.VAR_40VAR_4/VAR_40VAR_4.VAR_40VAR_4);", "} VAR_4elseVAR_4 VAR_4ifVAR_4 (VAR_4poVAR_4->VAR_4flagsVAR_4 & VAR_4OPT_FUNC2VAR_4) {", "VAR_4ifVAR_4 (VAR_4poVAR_4->VAR_4uVAR_4.VAR_4func2_argVAR_4(VAR_4optVAR_4, VAR_4argVAR_4) < VAR_40VAR_4) {", "VAR_4fprintfVAR_4(VAR_4stderrVAR_4, \"%VAR_4sVAR_4: VAR_4invalidVAR_4 VAR_4valueVAR_4 '%VAR_4sVAR_4' VAR_4forVAR_4 VAR_4optionVAR_4 '%VAR_4sVAR_4'\\VAR_4nVAR_4\", VAR_4VAR_1VAR_4[VAR_40VAR_4], VAR_4argVAR_4, VAR_4optVAR_4);", "VAR_4exitVAR_4(VAR_41VAR_4);", "}", "} VAR_4elseVAR_4 {", "VAR_4poVAR_4->VAR_4uVAR_4.VAR_4func_argVAR_4(VAR_4argVAR_4);", "}", "VAR_4ifVAR_4(VAR_4poVAR_4->VAR_4flagsVAR_4 & VAR_4OPT_EXITVAR_4)\nVAR_4exitVAR_4(VAR_40VAR_4);", "} VAR_4elseVAR_4 {", "VAR_4ifVAR_4 (VAR_4VAR_3VAR_4)\nVAR_4VAR_3VAR_4(VAR_4optVAR_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, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 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 ] ]
9,421
static int scan_mmco_reset(AVCodecParserContext *s, GetBitContext *gb, void *logctx) { H264PredWeightTable pwt; int slice_type_nos = s->pict_type & 3; H264ParseContext *p = s->priv_data; int list_count, ref_count[2]; if (p->ps.pps->redundant_pic_cnt_present) get_ue_golomb(gb); // redundant_pic_count if (slice_type_nos == AV_PICTURE_TYPE_B) get_bits1(gb); // direct_spatial_mv_pred if (ff_h264_parse_ref_count(&list_count, ref_count, gb, p->ps.pps, slice_type_nos, p->picture_structure, logctx) < 0) return AVERROR_INVALIDDATA; if (slice_type_nos != AV_PICTURE_TYPE_I) { int list; for (list = 0; list < list_count; list++) { if (get_bits1(gb)) { int index; for (index = 0; ; index++) { unsigned int reordering_of_pic_nums_idc = get_ue_golomb_31(gb); if (reordering_of_pic_nums_idc < 3) get_ue_golomb_long(gb); else if (reordering_of_pic_nums_idc > 3) { av_log(logctx, AV_LOG_ERROR, "illegal reordering_of_pic_nums_idc %d\n", reordering_of_pic_nums_idc); return AVERROR_INVALIDDATA; } else break; if (index >= ref_count[list]) { av_log(logctx, AV_LOG_ERROR, "reference count %d overflow\n", index); return AVERROR_INVALIDDATA; } } } } } if ((p->ps.pps->weighted_pred && slice_type_nos == AV_PICTURE_TYPE_P) || (p->ps.pps->weighted_bipred_idc == 1 && slice_type_nos == AV_PICTURE_TYPE_B)) ff_h264_pred_weight_table(gb, p->ps.sps, ref_count, slice_type_nos, &pwt, logctx); if (get_bits1(gb)) { // adaptive_ref_pic_marking_mode_flag int i; for (i = 0; i < MAX_MMCO_COUNT; i++) { MMCOOpcode opcode = get_ue_golomb_31(gb); if (opcode > (unsigned) MMCO_LONG) { av_log(logctx, AV_LOG_ERROR, "illegal memory management control operation %d\n", opcode); return AVERROR_INVALIDDATA; } if (opcode == MMCO_END) return 0; else if (opcode == MMCO_RESET) return 1; if (opcode == MMCO_SHORT2UNUSED || opcode == MMCO_SHORT2LONG) get_ue_golomb_long(gb); // difference_of_pic_nums_minus1 if (opcode == MMCO_SHORT2LONG || opcode == MMCO_LONG2UNUSED || opcode == MMCO_LONG || opcode == MMCO_SET_MAX_LONG) get_ue_golomb_31(gb); } } return 0; }
true
FFmpeg
09096fb68713089a8f97c8fa24e9d7f3bb9231d5
static int scan_mmco_reset(AVCodecParserContext *s, GetBitContext *gb, void *logctx) { H264PredWeightTable pwt; int slice_type_nos = s->pict_type & 3; H264ParseContext *p = s->priv_data; int list_count, ref_count[2]; if (p->ps.pps->redundant_pic_cnt_present) get_ue_golomb(gb); if (slice_type_nos == AV_PICTURE_TYPE_B) get_bits1(gb); if (ff_h264_parse_ref_count(&list_count, ref_count, gb, p->ps.pps, slice_type_nos, p->picture_structure, logctx) < 0) return AVERROR_INVALIDDATA; if (slice_type_nos != AV_PICTURE_TYPE_I) { int list; for (list = 0; list < list_count; list++) { if (get_bits1(gb)) { int index; for (index = 0; ; index++) { unsigned int reordering_of_pic_nums_idc = get_ue_golomb_31(gb); if (reordering_of_pic_nums_idc < 3) get_ue_golomb_long(gb); else if (reordering_of_pic_nums_idc > 3) { av_log(logctx, AV_LOG_ERROR, "illegal reordering_of_pic_nums_idc %d\n", reordering_of_pic_nums_idc); return AVERROR_INVALIDDATA; } else break; if (index >= ref_count[list]) { av_log(logctx, AV_LOG_ERROR, "reference count %d overflow\n", index); return AVERROR_INVALIDDATA; } } } } } if ((p->ps.pps->weighted_pred && slice_type_nos == AV_PICTURE_TYPE_P) || (p->ps.pps->weighted_bipred_idc == 1 && slice_type_nos == AV_PICTURE_TYPE_B)) ff_h264_pred_weight_table(gb, p->ps.sps, ref_count, slice_type_nos, &pwt, logctx); if (get_bits1(gb)) { int i; for (i = 0; i < MAX_MMCO_COUNT; i++) { MMCOOpcode opcode = get_ue_golomb_31(gb); if (opcode > (unsigned) MMCO_LONG) { av_log(logctx, AV_LOG_ERROR, "illegal memory management control operation %d\n", opcode); return AVERROR_INVALIDDATA; } if (opcode == MMCO_END) return 0; else if (opcode == MMCO_RESET) return 1; if (opcode == MMCO_SHORT2UNUSED || opcode == MMCO_SHORT2LONG) get_ue_golomb_long(gb); if (opcode == MMCO_SHORT2LONG || opcode == MMCO_LONG2UNUSED || opcode == MMCO_LONG || opcode == MMCO_SET_MAX_LONG) get_ue_golomb_31(gb); } } return 0; }
{ "code": [ " &pwt, logctx);" ], "line_no": [ 101 ] }
static int FUNC_0(AVCodecParserContext *VAR_0, GetBitContext *VAR_1, void *VAR_2) { H264PredWeightTable pwt; int VAR_3 = VAR_0->pict_type & 3; H264ParseContext *p = VAR_0->priv_data; int VAR_4, VAR_5[2]; if (p->ps.pps->redundant_pic_cnt_present) get_ue_golomb(VAR_1); if (VAR_3 == AV_PICTURE_TYPE_B) get_bits1(VAR_1); if (ff_h264_parse_ref_count(&VAR_4, VAR_5, VAR_1, p->ps.pps, VAR_3, p->picture_structure, VAR_2) < 0) return AVERROR_INVALIDDATA; if (VAR_3 != AV_PICTURE_TYPE_I) { int VAR_6; for (VAR_6 = 0; VAR_6 < VAR_4; VAR_6++) { if (get_bits1(VAR_1)) { int VAR_7; for (VAR_7 = 0; ; VAR_7++) { unsigned int VAR_8 = get_ue_golomb_31(VAR_1); if (VAR_8 < 3) get_ue_golomb_long(VAR_1); else if (VAR_8 > 3) { av_log(VAR_2, AV_LOG_ERROR, "illegal VAR_8 %d\n", VAR_8); return AVERROR_INVALIDDATA; } else break; if (VAR_7 >= VAR_5[VAR_6]) { av_log(VAR_2, AV_LOG_ERROR, "reference count %d overflow\n", VAR_7); return AVERROR_INVALIDDATA; } } } } } if ((p->ps.pps->weighted_pred && VAR_3 == AV_PICTURE_TYPE_P) || (p->ps.pps->weighted_bipred_idc == 1 && VAR_3 == AV_PICTURE_TYPE_B)) ff_h264_pred_weight_table(VAR_1, p->ps.sps, VAR_5, VAR_3, &pwt, VAR_2); if (get_bits1(VAR_1)) { int VAR_9; for (VAR_9 = 0; VAR_9 < MAX_MMCO_COUNT; VAR_9++) { MMCOOpcode opcode = get_ue_golomb_31(VAR_1); if (opcode > (unsigned) MMCO_LONG) { av_log(VAR_2, AV_LOG_ERROR, "illegal memory management control operation %d\n", opcode); return AVERROR_INVALIDDATA; } if (opcode == MMCO_END) return 0; else if (opcode == MMCO_RESET) return 1; if (opcode == MMCO_SHORT2UNUSED || opcode == MMCO_SHORT2LONG) get_ue_golomb_long(VAR_1); if (opcode == MMCO_SHORT2LONG || opcode == MMCO_LONG2UNUSED || opcode == MMCO_LONG || opcode == MMCO_SET_MAX_LONG) get_ue_golomb_31(VAR_1); } } return 0; }
[ "static int FUNC_0(AVCodecParserContext *VAR_0, GetBitContext *VAR_1,\nvoid *VAR_2)\n{", "H264PredWeightTable pwt;", "int VAR_3 = VAR_0->pict_type & 3;", "H264ParseContext *p = VAR_0->priv_data;", "int VAR_4, VAR_5[2];", "if (p->ps.pps->redundant_pic_cnt_present)\nget_ue_golomb(VAR_1);", "if (VAR_3 == AV_PICTURE_TYPE_B)\nget_bits1(VAR_1);", "if (ff_h264_parse_ref_count(&VAR_4, VAR_5, VAR_1, p->ps.pps,\nVAR_3, p->picture_structure, VAR_2) < 0)\nreturn AVERROR_INVALIDDATA;", "if (VAR_3 != AV_PICTURE_TYPE_I) {", "int VAR_6;", "for (VAR_6 = 0; VAR_6 < VAR_4; VAR_6++) {", "if (get_bits1(VAR_1)) {", "int VAR_7;", "for (VAR_7 = 0; ; VAR_7++) {", "unsigned int VAR_8 = get_ue_golomb_31(VAR_1);", "if (VAR_8 < 3)\nget_ue_golomb_long(VAR_1);", "else if (VAR_8 > 3) {", "av_log(VAR_2, AV_LOG_ERROR,\n\"illegal VAR_8 %d\\n\",\nVAR_8);", "return AVERROR_INVALIDDATA;", "} else", "break;", "if (VAR_7 >= VAR_5[VAR_6]) {", "av_log(VAR_2, AV_LOG_ERROR,\n\"reference count %d overflow\\n\", VAR_7);", "return AVERROR_INVALIDDATA;", "}", "}", "}", "}", "}", "if ((p->ps.pps->weighted_pred && VAR_3 == AV_PICTURE_TYPE_P) ||\n(p->ps.pps->weighted_bipred_idc == 1 && VAR_3 == AV_PICTURE_TYPE_B))\nff_h264_pred_weight_table(VAR_1, p->ps.sps, VAR_5, VAR_3,\n&pwt, VAR_2);", "if (get_bits1(VAR_1)) {", "int VAR_9;", "for (VAR_9 = 0; VAR_9 < MAX_MMCO_COUNT; VAR_9++) {", "MMCOOpcode opcode = get_ue_golomb_31(VAR_1);", "if (opcode > (unsigned) MMCO_LONG) {", "av_log(VAR_2, AV_LOG_ERROR,\n\"illegal memory management control operation %d\\n\",\nopcode);", "return AVERROR_INVALIDDATA;", "}", "if (opcode == MMCO_END)\nreturn 0;", "else if (opcode == MMCO_RESET)\nreturn 1;", "if (opcode == MMCO_SHORT2UNUSED || opcode == MMCO_SHORT2LONG)\nget_ue_golomb_long(VAR_1);", "if (opcode == MMCO_SHORT2LONG || opcode == MMCO_LONG2UNUSED ||\nopcode == MMCO_LONG || opcode == MMCO_SET_MAX_LONG)\nget_ue_golomb_31(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, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 19, 21 ], [ 25, 27 ], [ 31, 33, 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55, 57 ], [ 59 ], [ 61, 63, 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77, 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 95, 97, 99, 101 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115, 117, 119 ], [ 121 ], [ 123 ], [ 125, 127 ], [ 129, 131 ], [ 135, 137 ], [ 139, 141, 143 ], [ 145 ], [ 147 ], [ 151 ], [ 153 ] ]
9,422
static int transcode(AVFormatContext **output_files, int nb_output_files, AVFormatContext **input_files, int nb_input_files, AVStreamMap *stream_maps, int nb_stream_maps) { int ret = 0, i, j, k, n, nb_istreams = 0, nb_ostreams = 0, step; AVFormatContext *is, *os; AVCodecContext *codec, *icodec; AVOutputStream *ost, **ost_table = NULL; AVInputStream *ist, **ist_table = NULL; AVInputFile *file_table; char error[1024]; int key; int want_sdp = 1; uint8_t no_packet[MAX_FILES]={0}; int no_packet_count=0; int nb_frame_threshold[AVMEDIA_TYPE_NB]={0}; int nb_streams[AVMEDIA_TYPE_NB]={0}; file_table= av_mallocz(nb_input_files * sizeof(AVInputFile)); if (!file_table) goto fail; /* input stream init */ j = 0; for(i=0;i<nb_input_files;i++) { is = input_files[i]; file_table[i].ist_index = j; file_table[i].nb_streams = is->nb_streams; j += is->nb_streams; } nb_istreams = j; ist_table = av_mallocz(nb_istreams * sizeof(AVInputStream *)); if (!ist_table) goto fail; for(i=0;i<nb_istreams;i++) { ist = av_mallocz(sizeof(AVInputStream)); if (!ist) goto fail; ist_table[i] = ist; } j = 0; for(i=0;i<nb_input_files;i++) { is = input_files[i]; for(k=0;k<is->nb_streams;k++) { ist = ist_table[j++]; ist->st = is->streams[k]; ist->file_index = i; ist->index = k; ist->discard = 1; /* the stream is discarded by default (changed later) */ if (rate_emu) { ist->start = av_gettime(); } } } /* output stream init */ nb_ostreams = 0; for(i=0;i<nb_output_files;i++) { os = output_files[i]; if (!os->nb_streams && !(os->oformat->flags & AVFMT_NOSTREAMS)) { av_dump_format(output_files[i], i, output_files[i]->filename, 1); fprintf(stderr, "Output file #%d does not contain any stream\n", i); ret = AVERROR(EINVAL); goto fail; } nb_ostreams += os->nb_streams; } if (nb_stream_maps > 0 && nb_stream_maps != nb_ostreams) { fprintf(stderr, "Number of stream maps must match number of output streams\n"); ret = AVERROR(EINVAL); goto fail; } /* Sanity check the mapping args -- do the input files & streams exist? */ for(i=0;i<nb_stream_maps;i++) { int fi = stream_maps[i].file_index; int si = stream_maps[i].stream_index; if (fi < 0 || fi > nb_input_files - 1 || si < 0 || si > file_table[fi].nb_streams - 1) { fprintf(stderr,"Could not find input stream #%d.%d\n", fi, si); ret = AVERROR(EINVAL); goto fail; } fi = stream_maps[i].sync_file_index; si = stream_maps[i].sync_stream_index; if (fi < 0 || fi > nb_input_files - 1 || si < 0 || si > file_table[fi].nb_streams - 1) { fprintf(stderr,"Could not find sync stream #%d.%d\n", fi, si); ret = AVERROR(EINVAL); goto fail; } } ost_table = av_mallocz(sizeof(AVOutputStream *) * nb_ostreams); if (!ost_table) goto fail; for(k=0;k<nb_output_files;k++) { os = output_files[k]; for(i=0;i<os->nb_streams;i++,n++) { nb_streams[os->streams[i]->codec->codec_type]++; } } for(step=1<<30; step; step>>=1){ int found_streams[AVMEDIA_TYPE_NB]={0}; for(j=0; j<AVMEDIA_TYPE_NB; j++) nb_frame_threshold[j] += step; for(j=0; j<nb_istreams; j++) { int skip=0; ist = ist_table[j]; if(opt_programid){ int pi,si; AVFormatContext *f= input_files[ ist->file_index ]; skip=1; for(pi=0; pi<f->nb_programs; pi++){ AVProgram *p= f->programs[pi]; if(p->id == opt_programid) for(si=0; si<p->nb_stream_indexes; si++){ if(f->streams[ p->stream_index[si] ] == ist->st) skip=0; } } } if (ist->discard && ist->st->discard != AVDISCARD_ALL && !skip && nb_frame_threshold[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames){ found_streams[ist->st->codec->codec_type]++; } } for(j=0; j<AVMEDIA_TYPE_NB; j++) if(found_streams[j] < nb_streams[j]) nb_frame_threshold[j] -= step; } n = 0; for(k=0;k<nb_output_files;k++) { os = output_files[k]; for(i=0;i<os->nb_streams;i++,n++) { int found; ost = ost_table[n] = output_streams_for_file[k][i]; ost->st = os->streams[i]; if (nb_stream_maps > 0) { ost->source_index = file_table[stream_maps[n].file_index].ist_index + stream_maps[n].stream_index; /* Sanity check that the stream types match */ if (ist_table[ost->source_index]->st->codec->codec_type != ost->st->codec->codec_type) { int i= ost->file_index; av_dump_format(output_files[i], i, output_files[i]->filename, 1); fprintf(stderr, "Codec type mismatch for mapping #%d.%d -> #%d.%d\n", stream_maps[n].file_index, stream_maps[n].stream_index, ost->file_index, ost->index); ffmpeg_exit(1); } } else { /* get corresponding input stream index : we select the first one with the right type */ found = 0; for(j=0;j<nb_istreams;j++) { int skip=0; ist = ist_table[j]; if(opt_programid){ int pi,si; AVFormatContext *f= input_files[ ist->file_index ]; skip=1; for(pi=0; pi<f->nb_programs; pi++){ AVProgram *p= f->programs[pi]; if(p->id == opt_programid) for(si=0; si<p->nb_stream_indexes; si++){ if(f->streams[ p->stream_index[si] ] == ist->st) skip=0; } } } if (ist->discard && ist->st->discard != AVDISCARD_ALL && !skip && ist->st->codec->codec_type == ost->st->codec->codec_type && nb_frame_threshold[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames) { ost->source_index = j; found = 1; break; } } if (!found) { if(! opt_programid) { /* try again and reuse existing stream */ for(j=0;j<nb_istreams;j++) { ist = ist_table[j]; if ( ist->st->codec->codec_type == ost->st->codec->codec_type && ist->st->discard != AVDISCARD_ALL) { ost->source_index = j; found = 1; } } } if (!found) { int i= ost->file_index; av_dump_format(output_files[i], i, output_files[i]->filename, 1); fprintf(stderr, "Could not find input stream matching output stream #%d.%d\n", ost->file_index, ost->index); ffmpeg_exit(1); } } } ist = ist_table[ost->source_index]; ist->discard = 0; ost->sync_ist = (nb_stream_maps > 0) ? ist_table[file_table[stream_maps[n].sync_file_index].ist_index + stream_maps[n].sync_stream_index] : ist; } } /* for each output stream, we compute the right encoding parameters */ for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; os = output_files[ost->file_index]; ist = ist_table[ost->source_index]; codec = ost->st->codec; icodec = ist->st->codec; if (metadata_streams_autocopy) av_metadata_copy(&ost->st->metadata, ist->st->metadata, AV_METADATA_DONT_OVERWRITE); ost->st->disposition = ist->st->disposition; codec->bits_per_raw_sample= icodec->bits_per_raw_sample; codec->chroma_sample_location = icodec->chroma_sample_location; if (ost->st->stream_copy) { uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE; if (extra_size > INT_MAX) goto fail; /* if stream_copy is selected, no need to decode or encode */ codec->codec_id = icodec->codec_id; codec->codec_type = icodec->codec_type; if(!codec->codec_tag){ if( !os->oformat->codec_tag || av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id || av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0) codec->codec_tag = icodec->codec_tag; } codec->bit_rate = icodec->bit_rate; codec->rc_max_rate = icodec->rc_max_rate; codec->rc_buffer_size = icodec->rc_buffer_size; codec->extradata= av_mallocz(extra_size); if (!codec->extradata) goto fail; memcpy(codec->extradata, icodec->extradata, icodec->extradata_size); codec->extradata_size= icodec->extradata_size; if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){ codec->time_base = icodec->time_base; codec->time_base.num *= icodec->ticks_per_frame; av_reduce(&codec->time_base.num, &codec->time_base.den, codec->time_base.num, codec->time_base.den, INT_MAX); }else codec->time_base = ist->st->time_base; switch(codec->codec_type) { case AVMEDIA_TYPE_AUDIO: if(audio_volume != 256) { fprintf(stderr,"-acodec copy and -vol are incompatible (frames are not decoded)\n"); ffmpeg_exit(1); } codec->channel_layout = icodec->channel_layout; codec->sample_rate = icodec->sample_rate; codec->channels = icodec->channels; codec->frame_size = icodec->frame_size; codec->audio_service_type = icodec->audio_service_type; codec->block_align= icodec->block_align; if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3) codec->block_align= 0; if(codec->codec_id == CODEC_ID_AC3) codec->block_align= 0; break; case AVMEDIA_TYPE_VIDEO: codec->pix_fmt = icodec->pix_fmt; codec->width = icodec->width; codec->height = icodec->height; codec->has_b_frames = icodec->has_b_frames; break; case AVMEDIA_TYPE_SUBTITLE: codec->width = icodec->width; codec->height = icodec->height; break; default: abort(); } } else { switch(codec->codec_type) { case AVMEDIA_TYPE_AUDIO: ost->fifo= av_fifo_alloc(1024); if(!ost->fifo) goto fail; ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE); ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1; icodec->request_channels = codec->channels; ist->decoding_needed = 1; ost->encoding_needed = 1; ost->resample_sample_fmt = icodec->sample_fmt; ost->resample_sample_rate = icodec->sample_rate; ost->resample_channels = icodec->channels; break; case AVMEDIA_TYPE_VIDEO: if (ost->st->codec->pix_fmt == PIX_FMT_NONE) { fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\n"); ffmpeg_exit(1); } ost->video_resample = (codec->width != icodec->width || codec->height != icodec->height || (codec->pix_fmt != icodec->pix_fmt)); if (ost->video_resample) { #if !CONFIG_AVFILTER avcodec_get_frame_defaults(&ost->pict_tmp); if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt, codec->width, codec->height)) { fprintf(stderr, "Cannot allocate temp picture, check pix fmt\n"); ffmpeg_exit(1); } sws_flags = av_get_int(sws_opts, "sws_flags", NULL); ost->img_resample_ctx = sws_getContext( icodec->width, icodec->height, icodec->pix_fmt, codec->width, codec->height, codec->pix_fmt, sws_flags, NULL, NULL, NULL); if (ost->img_resample_ctx == NULL) { fprintf(stderr, "Cannot get resampling context\n"); ffmpeg_exit(1); } ost->original_height = icodec->height; ost->original_width = icodec->width; #endif codec->bits_per_raw_sample= 0; } ost->resample_height = icodec->height; ost->resample_width = icodec->width; ost->resample_pix_fmt= icodec->pix_fmt; ost->encoding_needed = 1; ist->decoding_needed = 1; #if CONFIG_AVFILTER if (configure_filters(ist, ost)) { fprintf(stderr, "Error opening filters!\n"); exit(1); } #endif break; case AVMEDIA_TYPE_SUBTITLE: ost->encoding_needed = 1; ist->decoding_needed = 1; break; default: abort(); break; } /* two pass mode */ if (ost->encoding_needed && (codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) { char logfilename[1024]; FILE *f; snprintf(logfilename, sizeof(logfilename), "%s-%d.log", pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX, i); if (codec->flags & CODEC_FLAG_PASS1) { f = fopen(logfilename, "wb"); if (!f) { fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\n", logfilename, strerror(errno)); ffmpeg_exit(1); } ost->logfile = f; } else { char *logbuffer; size_t logbuffer_size; if (read_file(logfilename, &logbuffer, &logbuffer_size) < 0) { fprintf(stderr, "Error reading log file '%s' for pass-2 encoding\n", logfilename); ffmpeg_exit(1); } codec->stats_in = logbuffer; } } } if(codec->codec_type == AVMEDIA_TYPE_VIDEO){ /* maximum video buffer size is 6-bytes per pixel, plus DPX header size */ int size= codec->width * codec->height; bit_buffer_size= FFMAX(bit_buffer_size, 6*size + 1664); } } if (!bit_buffer) bit_buffer = av_malloc(bit_buffer_size); if (!bit_buffer) { fprintf(stderr, "Cannot allocate %d bytes output buffer\n", bit_buffer_size); ret = AVERROR(ENOMEM); goto fail; } /* open each encoder */ for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; if (ost->encoding_needed) { AVCodec *codec = i < nb_output_codecs ? output_codecs[i] : NULL; AVCodecContext *dec = ist_table[ost->source_index]->st->codec; if (!codec) codec = avcodec_find_encoder(ost->st->codec->codec_id); if (!codec) { snprintf(error, sizeof(error), "Encoder (codec id %d) not found for output stream #%d.%d", ost->st->codec->codec_id, ost->file_index, ost->index); ret = AVERROR(EINVAL); goto dump_format; } if (dec->subtitle_header) { ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size); if (!ost->st->codec->subtitle_header) { ret = AVERROR(ENOMEM); goto dump_format; } memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); ost->st->codec->subtitle_header_size = dec->subtitle_header_size; } if (avcodec_open(ost->st->codec, codec) < 0) { snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height", ost->file_index, ost->index); ret = AVERROR(EINVAL); goto dump_format; } extra_size += ost->st->codec->extradata_size; } } /* open each decoder */ for(i=0;i<nb_istreams;i++) { ist = ist_table[i]; if (ist->decoding_needed) { AVCodec *codec = i < nb_input_codecs ? input_codecs[i] : NULL; if (!codec) codec = avcodec_find_decoder(ist->st->codec->codec_id); if (!codec) { snprintf(error, sizeof(error), "Decoder (codec id %d) not found for input stream #%d.%d", ist->st->codec->codec_id, ist->file_index, ist->index); ret = AVERROR(EINVAL); goto dump_format; } if (avcodec_open(ist->st->codec, codec) < 0) { snprintf(error, sizeof(error), "Error while opening decoder for input stream #%d.%d", ist->file_index, ist->index); ret = AVERROR(EINVAL); goto dump_format; } //if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) // ist->st->codec->flags |= CODEC_FLAG_REPEAT_FIELD; } } /* init pts */ for(i=0;i<nb_istreams;i++) { AVStream *st; ist = ist_table[i]; st= ist->st; ist->pts = st->avg_frame_rate.num ? - st->codec->has_b_frames*AV_TIME_BASE / av_q2d(st->avg_frame_rate) : 0; ist->next_pts = AV_NOPTS_VALUE; ist->is_start = 1; } /* set meta data information from input file if required */ for (i=0;i<nb_meta_data_maps;i++) { AVFormatContext *files[2]; AVMetadata **meta[2]; int j; #define METADATA_CHECK_INDEX(index, nb_elems, desc)\ if ((index) < 0 || (index) >= (nb_elems)) {\ snprintf(error, sizeof(error), "Invalid %s index %d while processing metadata maps\n",\ (desc), (index));\ ret = AVERROR(EINVAL);\ goto dump_format;\ } int out_file_index = meta_data_maps[i][0].file; int in_file_index = meta_data_maps[i][1].file; if (in_file_index < 0 || out_file_index < 0) continue; METADATA_CHECK_INDEX(out_file_index, nb_output_files, "output file") METADATA_CHECK_INDEX(in_file_index, nb_input_files, "input file") files[0] = output_files[out_file_index]; files[1] = input_files[in_file_index]; for (j = 0; j < 2; j++) { AVMetaDataMap *map = &meta_data_maps[i][j]; switch (map->type) { case 'g': meta[j] = &files[j]->metadata; break; case 's': METADATA_CHECK_INDEX(map->index, files[j]->nb_streams, "stream") meta[j] = &files[j]->streams[map->index]->metadata; break; case 'c': METADATA_CHECK_INDEX(map->index, files[j]->nb_chapters, "chapter") meta[j] = &files[j]->chapters[map->index]->metadata; break; case 'p': METADATA_CHECK_INDEX(map->index, files[j]->nb_programs, "program") meta[j] = &files[j]->programs[map->index]->metadata; break; } } av_metadata_copy(meta[0], *meta[1], AV_METADATA_DONT_OVERWRITE); } /* copy global metadata by default */ if (metadata_global_autocopy) { for (i = 0; i < nb_output_files; i++) av_metadata_copy(&output_files[i]->metadata, input_files[0]->metadata, AV_METADATA_DONT_OVERWRITE); } /* copy chapters according to chapter maps */ for (i = 0; i < nb_chapter_maps; i++) { int infile = chapter_maps[i].in_file; int outfile = chapter_maps[i].out_file; if (infile < 0 || outfile < 0) continue; if (infile >= nb_input_files) { snprintf(error, sizeof(error), "Invalid input file index %d in chapter mapping.\n", infile); ret = AVERROR(EINVAL); goto dump_format; } if (outfile >= nb_output_files) { snprintf(error, sizeof(error), "Invalid output file index %d in chapter mapping.\n",outfile); ret = AVERROR(EINVAL); goto dump_format; } copy_chapters(infile, outfile); } /* copy chapters from the first input file that has them*/ if (!nb_chapter_maps) for (i = 0; i < nb_input_files; i++) { if (!input_files[i]->nb_chapters) continue; for (j = 0; j < nb_output_files; j++) if ((ret = copy_chapters(i, j)) < 0) goto dump_format; break; } /* open files and write file headers */ for(i=0;i<nb_output_files;i++) { os = output_files[i]; if (av_write_header(os) < 0) { snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i); ret = AVERROR(EINVAL); goto dump_format; } if (strcmp(output_files[i]->oformat->name, "rtp")) { want_sdp = 0; } } dump_format: /* dump the file output parameters - cannot be done before in case of stream copy */ for(i=0;i<nb_output_files;i++) { av_dump_format(output_files[i], i, output_files[i]->filename, 1); } /* dump the stream mapping */ if (verbose >= 0) { fprintf(stderr, "Stream mapping:\n"); for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; fprintf(stderr, " Stream #%d.%d -> #%d.%d", ist_table[ost->source_index]->file_index, ist_table[ost->source_index]->index, ost->file_index, ost->index); if (ost->sync_ist != ist_table[ost->source_index]) fprintf(stderr, " [sync #%d.%d]", ost->sync_ist->file_index, ost->sync_ist->index); fprintf(stderr, "\n"); } } if (ret) { fprintf(stderr, "%s\n", error); goto fail; } if (want_sdp) { print_sdp(output_files, nb_output_files); } if (!using_stdin) { if(verbose >= 0) fprintf(stderr, "Press [q] to stop encoding\n"); url_set_interrupt_cb(decode_interrupt_cb); } term_init(); timer_start = av_gettime(); for(; received_sigterm == 0;) { int file_index, ist_index; AVPacket pkt; double ipts_min; double opts_min; redo: ipts_min= 1e100; opts_min= 1e100; /* if 'q' pressed, exits */ if (!using_stdin) { if (q_pressed) break; /* read_key() returns 0 on EOF */ key = read_key(); if (key == 'q') break; } /* select the stream that we must read now by looking at the smallest output pts */ file_index = -1; for(i=0;i<nb_ostreams;i++) { double ipts, opts; ost = ost_table[i]; os = output_files[ost->file_index]; ist = ist_table[ost->source_index]; if(ist->is_past_recording_time || no_packet[ist->file_index]) continue; opts = ost->st->pts.val * av_q2d(ost->st->time_base); ipts = (double)ist->pts; if (!file_table[ist->file_index].eof_reached){ if(ipts < ipts_min) { ipts_min = ipts; if(input_sync ) file_index = ist->file_index; } if(opts < opts_min) { opts_min = opts; if(!input_sync) file_index = ist->file_index; } } if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){ file_index= -1; break; } } /* if none, if is finished */ if (file_index < 0) { if(no_packet_count){ no_packet_count=0; memset(no_packet, 0, sizeof(no_packet)); usleep(10000); continue; } break; } /* finish if limit size exhausted */ if (limit_filesize != 0 && limit_filesize <= avio_tell(output_files[0]->pb)) break; /* read a frame from it and output it in the fifo */ is = input_files[file_index]; ret= av_read_frame(is, &pkt); if(ret == AVERROR(EAGAIN)){ no_packet[file_index]=1; no_packet_count++; continue; } if (ret < 0) { file_table[file_index].eof_reached = 1; if (opt_shortest) break; else continue; } no_packet_count=0; memset(no_packet, 0, sizeof(no_packet)); 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 >= file_table[file_index].nb_streams) goto discard_packet; ist_index = file_table[file_index].ist_index + pkt.stream_index; ist = ist_table[ist_index]; if (ist->discard) goto discard_packet; if (pkt.dts != AV_NOPTS_VALUE) pkt.dts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) pkt.pts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base); if (pkt.stream_index < nb_input_files_ts_scale[file_index] && input_files_ts_scale[file_index][pkt.stream_index]){ if(pkt.pts != AV_NOPTS_VALUE) pkt.pts *= input_files_ts_scale[file_index][pkt.stream_index]; if(pkt.dts != AV_NOPTS_VALUE) pkt.dts *= input_files_ts_scale[file_index][pkt.stream_index]; } // fprintf(stderr, "next:%"PRId64" dts:%"PRId64" off:%"PRId64" %d\n", ist->next_pts, pkt.dts, input_files_ts_offset[ist->file_index], ist->st->codec->codec_type); if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE && (is->iformat->flags & AVFMT_TS_DISCONT)) { int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q); int64_t delta= pkt_dts - ist->next_pts; if((FFABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE || pkt_dts+1<ist->pts)&& !copy_ts){ input_files_ts_offset[ist->file_index]-= delta; if (verbose > 2) fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", delta, input_files_ts_offset[ist->file_index]); 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); } } /* finish if recording time exhausted */ if (recording_time != INT64_MAX && av_compare_ts(pkt.pts, ist->st->time_base, recording_time + start_time, (AVRational){1, 1000000}) >= 0) { ist->is_past_recording_time = 1; goto discard_packet; } //fprintf(stderr,"read #%d.%d size=%d\n", ist->file_index, ist->index, pkt.size); if (output_packet(ist, ist_index, ost_table, nb_ostreams, &pkt) < 0) { if (verbose >= 0) fprintf(stderr, "Error while decoding stream #%d.%d\n", ist->file_index, ist->index); if (exit_on_error) ffmpeg_exit(1); av_free_packet(&pkt); goto redo; } discard_packet: av_free_packet(&pkt); /* dump report by using the output first video and audio streams */ print_report(output_files, ost_table, nb_ostreams, 0); } /* at the end of stream, we must flush the decoder buffers */ for(i=0;i<nb_istreams;i++) { ist = ist_table[i]; if (ist->decoding_needed) { output_packet(ist, i, ost_table, nb_ostreams, NULL); } } term_exit(); /* write the trailer if needed and close file */ for(i=0;i<nb_output_files;i++) { os = output_files[i]; av_write_trailer(os); } /* dump report by using the first video and audio streams */ print_report(output_files, ost_table, nb_ostreams, 1); /* close each encoder */ for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; if (ost->encoding_needed) { av_freep(&ost->st->codec->stats_in); avcodec_close(ost->st->codec); } #if CONFIG_AVFILTER avfilter_graph_free(&ost->graph); #endif } /* close each decoder */ for(i=0;i<nb_istreams;i++) { ist = ist_table[i]; if (ist->decoding_needed) { avcodec_close(ist->st->codec); } } /* finished ! */ ret = 0; fail: av_freep(&bit_buffer); av_free(file_table); if (ist_table) { for(i=0;i<nb_istreams;i++) { ist = ist_table[i]; av_free(ist); } av_free(ist_table); } if (ost_table) { for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; if (ost) { if (ost->st->stream_copy) av_freep(&ost->st->codec->extradata); if (ost->logfile) { fclose(ost->logfile); ost->logfile = NULL; } av_fifo_free(ost->fifo); /* works even if fifo is not initialized but set to zero */ av_freep(&ost->st->codec->subtitle_header); av_free(ost->pict_tmp.data[0]); av_free(ost->forced_kf_pts); if (ost->video_resample) sws_freeContext(ost->img_resample_ctx); if (ost->resample) audio_resample_close(ost->resample); if (ost->reformat_ctx) av_audio_convert_free(ost->reformat_ctx); av_free(ost); } } av_free(ost_table); } return ret; }
true
FFmpeg
100a6b7c77fb4fa5b3a91e9206b9b3e7a7d01238
static int transcode(AVFormatContext **output_files, int nb_output_files, AVFormatContext **input_files, int nb_input_files, AVStreamMap *stream_maps, int nb_stream_maps) { int ret = 0, i, j, k, n, nb_istreams = 0, nb_ostreams = 0, step; AVFormatContext *is, *os; AVCodecContext *codec, *icodec; AVOutputStream *ost, **ost_table = NULL; AVInputStream *ist, **ist_table = NULL; AVInputFile *file_table; char error[1024]; int key; int want_sdp = 1; uint8_t no_packet[MAX_FILES]={0}; int no_packet_count=0; int nb_frame_threshold[AVMEDIA_TYPE_NB]={0}; int nb_streams[AVMEDIA_TYPE_NB]={0}; file_table= av_mallocz(nb_input_files * sizeof(AVInputFile)); if (!file_table) goto fail; j = 0; for(i=0;i<nb_input_files;i++) { is = input_files[i]; file_table[i].ist_index = j; file_table[i].nb_streams = is->nb_streams; j += is->nb_streams; } nb_istreams = j; ist_table = av_mallocz(nb_istreams * sizeof(AVInputStream *)); if (!ist_table) goto fail; for(i=0;i<nb_istreams;i++) { ist = av_mallocz(sizeof(AVInputStream)); if (!ist) goto fail; ist_table[i] = ist; } j = 0; for(i=0;i<nb_input_files;i++) { is = input_files[i]; for(k=0;k<is->nb_streams;k++) { ist = ist_table[j++]; ist->st = is->streams[k]; ist->file_index = i; ist->index = k; ist->discard = 1; if (rate_emu) { ist->start = av_gettime(); } } } nb_ostreams = 0; for(i=0;i<nb_output_files;i++) { os = output_files[i]; if (!os->nb_streams && !(os->oformat->flags & AVFMT_NOSTREAMS)) { av_dump_format(output_files[i], i, output_files[i]->filename, 1); fprintf(stderr, "Output file #%d does not contain any stream\n", i); ret = AVERROR(EINVAL); goto fail; } nb_ostreams += os->nb_streams; } if (nb_stream_maps > 0 && nb_stream_maps != nb_ostreams) { fprintf(stderr, "Number of stream maps must match number of output streams\n"); ret = AVERROR(EINVAL); goto fail; } for(i=0;i<nb_stream_maps;i++) { int fi = stream_maps[i].file_index; int si = stream_maps[i].stream_index; if (fi < 0 || fi > nb_input_files - 1 || si < 0 || si > file_table[fi].nb_streams - 1) { fprintf(stderr,"Could not find input stream #%d.%d\n", fi, si); ret = AVERROR(EINVAL); goto fail; } fi = stream_maps[i].sync_file_index; si = stream_maps[i].sync_stream_index; if (fi < 0 || fi > nb_input_files - 1 || si < 0 || si > file_table[fi].nb_streams - 1) { fprintf(stderr,"Could not find sync stream #%d.%d\n", fi, si); ret = AVERROR(EINVAL); goto fail; } } ost_table = av_mallocz(sizeof(AVOutputStream *) * nb_ostreams); if (!ost_table) goto fail; for(k=0;k<nb_output_files;k++) { os = output_files[k]; for(i=0;i<os->nb_streams;i++,n++) { nb_streams[os->streams[i]->codec->codec_type]++; } } for(step=1<<30; step; step>>=1){ int found_streams[AVMEDIA_TYPE_NB]={0}; for(j=0; j<AVMEDIA_TYPE_NB; j++) nb_frame_threshold[j] += step; for(j=0; j<nb_istreams; j++) { int skip=0; ist = ist_table[j]; if(opt_programid){ int pi,si; AVFormatContext *f= input_files[ ist->file_index ]; skip=1; for(pi=0; pi<f->nb_programs; pi++){ AVProgram *p= f->programs[pi]; if(p->id == opt_programid) for(si=0; si<p->nb_stream_indexes; si++){ if(f->streams[ p->stream_index[si] ] == ist->st) skip=0; } } } if (ist->discard && ist->st->discard != AVDISCARD_ALL && !skip && nb_frame_threshold[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames){ found_streams[ist->st->codec->codec_type]++; } } for(j=0; j<AVMEDIA_TYPE_NB; j++) if(found_streams[j] < nb_streams[j]) nb_frame_threshold[j] -= step; } n = 0; for(k=0;k<nb_output_files;k++) { os = output_files[k]; for(i=0;i<os->nb_streams;i++,n++) { int found; ost = ost_table[n] = output_streams_for_file[k][i]; ost->st = os->streams[i]; if (nb_stream_maps > 0) { ost->source_index = file_table[stream_maps[n].file_index].ist_index + stream_maps[n].stream_index; if (ist_table[ost->source_index]->st->codec->codec_type != ost->st->codec->codec_type) { int i= ost->file_index; av_dump_format(output_files[i], i, output_files[i]->filename, 1); fprintf(stderr, "Codec type mismatch for mapping #%d.%d -> #%d.%d\n", stream_maps[n].file_index, stream_maps[n].stream_index, ost->file_index, ost->index); ffmpeg_exit(1); } } else { found = 0; for(j=0;j<nb_istreams;j++) { int skip=0; ist = ist_table[j]; if(opt_programid){ int pi,si; AVFormatContext *f= input_files[ ist->file_index ]; skip=1; for(pi=0; pi<f->nb_programs; pi++){ AVProgram *p= f->programs[pi]; if(p->id == opt_programid) for(si=0; si<p->nb_stream_indexes; si++){ if(f->streams[ p->stream_index[si] ] == ist->st) skip=0; } } } if (ist->discard && ist->st->discard != AVDISCARD_ALL && !skip && ist->st->codec->codec_type == ost->st->codec->codec_type && nb_frame_threshold[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames) { ost->source_index = j; found = 1; break; } } if (!found) { if(! opt_programid) { for(j=0;j<nb_istreams;j++) { ist = ist_table[j]; if ( ist->st->codec->codec_type == ost->st->codec->codec_type && ist->st->discard != AVDISCARD_ALL) { ost->source_index = j; found = 1; } } } if (!found) { int i= ost->file_index; av_dump_format(output_files[i], i, output_files[i]->filename, 1); fprintf(stderr, "Could not find input stream matching output stream #%d.%d\n", ost->file_index, ost->index); ffmpeg_exit(1); } } } ist = ist_table[ost->source_index]; ist->discard = 0; ost->sync_ist = (nb_stream_maps > 0) ? ist_table[file_table[stream_maps[n].sync_file_index].ist_index + stream_maps[n].sync_stream_index] : ist; } } for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; os = output_files[ost->file_index]; ist = ist_table[ost->source_index]; codec = ost->st->codec; icodec = ist->st->codec; if (metadata_streams_autocopy) av_metadata_copy(&ost->st->metadata, ist->st->metadata, AV_METADATA_DONT_OVERWRITE); ost->st->disposition = ist->st->disposition; codec->bits_per_raw_sample= icodec->bits_per_raw_sample; codec->chroma_sample_location = icodec->chroma_sample_location; if (ost->st->stream_copy) { uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE; if (extra_size > INT_MAX) goto fail; codec->codec_id = icodec->codec_id; codec->codec_type = icodec->codec_type; if(!codec->codec_tag){ if( !os->oformat->codec_tag || av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id || av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0) codec->codec_tag = icodec->codec_tag; } codec->bit_rate = icodec->bit_rate; codec->rc_max_rate = icodec->rc_max_rate; codec->rc_buffer_size = icodec->rc_buffer_size; codec->extradata= av_mallocz(extra_size); if (!codec->extradata) goto fail; memcpy(codec->extradata, icodec->extradata, icodec->extradata_size); codec->extradata_size= icodec->extradata_size; if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){ codec->time_base = icodec->time_base; codec->time_base.num *= icodec->ticks_per_frame; av_reduce(&codec->time_base.num, &codec->time_base.den, codec->time_base.num, codec->time_base.den, INT_MAX); }else codec->time_base = ist->st->time_base; switch(codec->codec_type) { case AVMEDIA_TYPE_AUDIO: if(audio_volume != 256) { fprintf(stderr,"-acodec copy and -vol are incompatible (frames are not decoded)\n"); ffmpeg_exit(1); } codec->channel_layout = icodec->channel_layout; codec->sample_rate = icodec->sample_rate; codec->channels = icodec->channels; codec->frame_size = icodec->frame_size; codec->audio_service_type = icodec->audio_service_type; codec->block_align= icodec->block_align; if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3) codec->block_align= 0; if(codec->codec_id == CODEC_ID_AC3) codec->block_align= 0; break; case AVMEDIA_TYPE_VIDEO: codec->pix_fmt = icodec->pix_fmt; codec->width = icodec->width; codec->height = icodec->height; codec->has_b_frames = icodec->has_b_frames; break; case AVMEDIA_TYPE_SUBTITLE: codec->width = icodec->width; codec->height = icodec->height; break; default: abort(); } } else { switch(codec->codec_type) { case AVMEDIA_TYPE_AUDIO: ost->fifo= av_fifo_alloc(1024); if(!ost->fifo) goto fail; ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE); ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1; icodec->request_channels = codec->channels; ist->decoding_needed = 1; ost->encoding_needed = 1; ost->resample_sample_fmt = icodec->sample_fmt; ost->resample_sample_rate = icodec->sample_rate; ost->resample_channels = icodec->channels; break; case AVMEDIA_TYPE_VIDEO: if (ost->st->codec->pix_fmt == PIX_FMT_NONE) { fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\n"); ffmpeg_exit(1); } ost->video_resample = (codec->width != icodec->width || codec->height != icodec->height || (codec->pix_fmt != icodec->pix_fmt)); if (ost->video_resample) { #if !CONFIG_AVFILTER avcodec_get_frame_defaults(&ost->pict_tmp); if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt, codec->width, codec->height)) { fprintf(stderr, "Cannot allocate temp picture, check pix fmt\n"); ffmpeg_exit(1); } sws_flags = av_get_int(sws_opts, "sws_flags", NULL); ost->img_resample_ctx = sws_getContext( icodec->width, icodec->height, icodec->pix_fmt, codec->width, codec->height, codec->pix_fmt, sws_flags, NULL, NULL, NULL); if (ost->img_resample_ctx == NULL) { fprintf(stderr, "Cannot get resampling context\n"); ffmpeg_exit(1); } ost->original_height = icodec->height; ost->original_width = icodec->width; #endif codec->bits_per_raw_sample= 0; } ost->resample_height = icodec->height; ost->resample_width = icodec->width; ost->resample_pix_fmt= icodec->pix_fmt; ost->encoding_needed = 1; ist->decoding_needed = 1; #if CONFIG_AVFILTER if (configure_filters(ist, ost)) { fprintf(stderr, "Error opening filters!\n"); exit(1); } #endif break; case AVMEDIA_TYPE_SUBTITLE: ost->encoding_needed = 1; ist->decoding_needed = 1; break; default: abort(); break; } if (ost->encoding_needed && (codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) { char logfilename[1024]; FILE *f; snprintf(logfilename, sizeof(logfilename), "%s-%d.log", pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX, i); if (codec->flags & CODEC_FLAG_PASS1) { f = fopen(logfilename, "wb"); if (!f) { fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\n", logfilename, strerror(errno)); ffmpeg_exit(1); } ost->logfile = f; } else { char *logbuffer; size_t logbuffer_size; if (read_file(logfilename, &logbuffer, &logbuffer_size) < 0) { fprintf(stderr, "Error reading log file '%s' for pass-2 encoding\n", logfilename); ffmpeg_exit(1); } codec->stats_in = logbuffer; } } } if(codec->codec_type == AVMEDIA_TYPE_VIDEO){ int size= codec->width * codec->height; bit_buffer_size= FFMAX(bit_buffer_size, 6*size + 1664); } } if (!bit_buffer) bit_buffer = av_malloc(bit_buffer_size); if (!bit_buffer) { fprintf(stderr, "Cannot allocate %d bytes output buffer\n", bit_buffer_size); ret = AVERROR(ENOMEM); goto fail; } for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; if (ost->encoding_needed) { AVCodec *codec = i < nb_output_codecs ? output_codecs[i] : NULL; AVCodecContext *dec = ist_table[ost->source_index]->st->codec; if (!codec) codec = avcodec_find_encoder(ost->st->codec->codec_id); if (!codec) { snprintf(error, sizeof(error), "Encoder (codec id %d) not found for output stream #%d.%d", ost->st->codec->codec_id, ost->file_index, ost->index); ret = AVERROR(EINVAL); goto dump_format; } if (dec->subtitle_header) { ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size); if (!ost->st->codec->subtitle_header) { ret = AVERROR(ENOMEM); goto dump_format; } memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); ost->st->codec->subtitle_header_size = dec->subtitle_header_size; } if (avcodec_open(ost->st->codec, codec) < 0) { snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height", ost->file_index, ost->index); ret = AVERROR(EINVAL); goto dump_format; } extra_size += ost->st->codec->extradata_size; } } for(i=0;i<nb_istreams;i++) { ist = ist_table[i]; if (ist->decoding_needed) { AVCodec *codec = i < nb_input_codecs ? input_codecs[i] : NULL; if (!codec) codec = avcodec_find_decoder(ist->st->codec->codec_id); if (!codec) { snprintf(error, sizeof(error), "Decoder (codec id %d) not found for input stream #%d.%d", ist->st->codec->codec_id, ist->file_index, ist->index); ret = AVERROR(EINVAL); goto dump_format; } if (avcodec_open(ist->st->codec, codec) < 0) { snprintf(error, sizeof(error), "Error while opening decoder for input stream #%d.%d", ist->file_index, ist->index); ret = AVERROR(EINVAL); goto dump_format; } } } for(i=0;i<nb_istreams;i++) { AVStream *st; ist = ist_table[i]; st= ist->st; ist->pts = st->avg_frame_rate.num ? - st->codec->has_b_frames*AV_TIME_BASE / av_q2d(st->avg_frame_rate) : 0; ist->next_pts = AV_NOPTS_VALUE; ist->is_start = 1; } for (i=0;i<nb_meta_data_maps;i++) { AVFormatContext *files[2]; AVMetadata **meta[2]; int j; #define METADATA_CHECK_INDEX(index, nb_elems, desc)\ if ((index) < 0 || (index) >= (nb_elems)) {\ snprintf(error, sizeof(error), "Invalid %s index %d while processing metadata maps\n",\ (desc), (index));\ ret = AVERROR(EINVAL);\ goto dump_format;\ } int out_file_index = meta_data_maps[i][0].file; int in_file_index = meta_data_maps[i][1].file; if (in_file_index < 0 || out_file_index < 0) continue; METADATA_CHECK_INDEX(out_file_index, nb_output_files, "output file") METADATA_CHECK_INDEX(in_file_index, nb_input_files, "input file") files[0] = output_files[out_file_index]; files[1] = input_files[in_file_index]; for (j = 0; j < 2; j++) { AVMetaDataMap *map = &meta_data_maps[i][j]; switch (map->type) { case 'g': meta[j] = &files[j]->metadata; break; case 's': METADATA_CHECK_INDEX(map->index, files[j]->nb_streams, "stream") meta[j] = &files[j]->streams[map->index]->metadata; break; case 'c': METADATA_CHECK_INDEX(map->index, files[j]->nb_chapters, "chapter") meta[j] = &files[j]->chapters[map->index]->metadata; break; case 'p': METADATA_CHECK_INDEX(map->index, files[j]->nb_programs, "program") meta[j] = &files[j]->programs[map->index]->metadata; break; } } av_metadata_copy(meta[0], *meta[1], AV_METADATA_DONT_OVERWRITE); } if (metadata_global_autocopy) { for (i = 0; i < nb_output_files; i++) av_metadata_copy(&output_files[i]->metadata, input_files[0]->metadata, AV_METADATA_DONT_OVERWRITE); } for (i = 0; i < nb_chapter_maps; i++) { int infile = chapter_maps[i].in_file; int outfile = chapter_maps[i].out_file; if (infile < 0 || outfile < 0) continue; if (infile >= nb_input_files) { snprintf(error, sizeof(error), "Invalid input file index %d in chapter mapping.\n", infile); ret = AVERROR(EINVAL); goto dump_format; } if (outfile >= nb_output_files) { snprintf(error, sizeof(error), "Invalid output file index %d in chapter mapping.\n",outfile); ret = AVERROR(EINVAL); goto dump_format; } copy_chapters(infile, outfile); } if (!nb_chapter_maps) for (i = 0; i < nb_input_files; i++) { if (!input_files[i]->nb_chapters) continue; for (j = 0; j < nb_output_files; j++) if ((ret = copy_chapters(i, j)) < 0) goto dump_format; break; } for(i=0;i<nb_output_files;i++) { os = output_files[i]; if (av_write_header(os) < 0) { snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i); ret = AVERROR(EINVAL); goto dump_format; } if (strcmp(output_files[i]->oformat->name, "rtp")) { want_sdp = 0; } } dump_format: for(i=0;i<nb_output_files;i++) { av_dump_format(output_files[i], i, output_files[i]->filename, 1); } if (verbose >= 0) { fprintf(stderr, "Stream mapping:\n"); for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; fprintf(stderr, " Stream #%d.%d -> #%d.%d", ist_table[ost->source_index]->file_index, ist_table[ost->source_index]->index, ost->file_index, ost->index); if (ost->sync_ist != ist_table[ost->source_index]) fprintf(stderr, " [sync #%d.%d]", ost->sync_ist->file_index, ost->sync_ist->index); fprintf(stderr, "\n"); } } if (ret) { fprintf(stderr, "%s\n", error); goto fail; } if (want_sdp) { print_sdp(output_files, nb_output_files); } if (!using_stdin) { if(verbose >= 0) fprintf(stderr, "Press [q] to stop encoding\n"); url_set_interrupt_cb(decode_interrupt_cb); } term_init(); timer_start = av_gettime(); for(; received_sigterm == 0;) { int file_index, ist_index; AVPacket pkt; double ipts_min; double opts_min; redo: ipts_min= 1e100; opts_min= 1e100; if (!using_stdin) { if (q_pressed) break; key = read_key(); if (key == 'q') break; } file_index = -1; for(i=0;i<nb_ostreams;i++) { double ipts, opts; ost = ost_table[i]; os = output_files[ost->file_index]; ist = ist_table[ost->source_index]; if(ist->is_past_recording_time || no_packet[ist->file_index]) continue; opts = ost->st->pts.val * av_q2d(ost->st->time_base); ipts = (double)ist->pts; if (!file_table[ist->file_index].eof_reached){ if(ipts < ipts_min) { ipts_min = ipts; if(input_sync ) file_index = ist->file_index; } if(opts < opts_min) { opts_min = opts; if(!input_sync) file_index = ist->file_index; } } if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){ file_index= -1; break; } } if (file_index < 0) { if(no_packet_count){ no_packet_count=0; memset(no_packet, 0, sizeof(no_packet)); usleep(10000); continue; } break; } if (limit_filesize != 0 && limit_filesize <= avio_tell(output_files[0]->pb)) break; is = input_files[file_index]; ret= av_read_frame(is, &pkt); if(ret == AVERROR(EAGAIN)){ no_packet[file_index]=1; no_packet_count++; continue; } if (ret < 0) { file_table[file_index].eof_reached = 1; if (opt_shortest) break; else continue; } no_packet_count=0; memset(no_packet, 0, sizeof(no_packet)); 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 >= file_table[file_index].nb_streams) goto discard_packet; ist_index = file_table[file_index].ist_index + pkt.stream_index; ist = ist_table[ist_index]; if (ist->discard) goto discard_packet; if (pkt.dts != AV_NOPTS_VALUE) pkt.dts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) pkt.pts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base); if (pkt.stream_index < nb_input_files_ts_scale[file_index] && input_files_ts_scale[file_index][pkt.stream_index]){ if(pkt.pts != AV_NOPTS_VALUE) pkt.pts *= input_files_ts_scale[file_index][pkt.stream_index]; if(pkt.dts != AV_NOPTS_VALUE) pkt.dts *= input_files_ts_scale[file_index][pkt.stream_index]; } if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE && (is->iformat->flags & AVFMT_TS_DISCONT)) { int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q); int64_t delta= pkt_dts - ist->next_pts; if((FFABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE || pkt_dts+1<ist->pts)&& !copy_ts){ input_files_ts_offset[ist->file_index]-= delta; if (verbose > 2) fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", delta, input_files_ts_offset[ist->file_index]); 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); } } if (recording_time != INT64_MAX && av_compare_ts(pkt.pts, ist->st->time_base, recording_time + start_time, (AVRational){1, 1000000}) >= 0) { ist->is_past_recording_time = 1; goto discard_packet; } if (output_packet(ist, ist_index, ost_table, nb_ostreams, &pkt) < 0) { if (verbose >= 0) fprintf(stderr, "Error while decoding stream #%d.%d\n", ist->file_index, ist->index); if (exit_on_error) ffmpeg_exit(1); av_free_packet(&pkt); goto redo; } discard_packet: av_free_packet(&pkt); print_report(output_files, ost_table, nb_ostreams, 0); } for(i=0;i<nb_istreams;i++) { ist = ist_table[i]; if (ist->decoding_needed) { output_packet(ist, i, ost_table, nb_ostreams, NULL); } } term_exit(); for(i=0;i<nb_output_files;i++) { os = output_files[i]; av_write_trailer(os); } print_report(output_files, ost_table, nb_ostreams, 1); for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; if (ost->encoding_needed) { av_freep(&ost->st->codec->stats_in); avcodec_close(ost->st->codec); } #if CONFIG_AVFILTER avfilter_graph_free(&ost->graph); #endif } for(i=0;i<nb_istreams;i++) { ist = ist_table[i]; if (ist->decoding_needed) { avcodec_close(ist->st->codec); } } ret = 0; fail: av_freep(&bit_buffer); av_free(file_table); if (ist_table) { for(i=0;i<nb_istreams;i++) { ist = ist_table[i]; av_free(ist); } av_free(ist_table); } if (ost_table) { for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; if (ost) { if (ost->st->stream_copy) av_freep(&ost->st->codec->extradata); if (ost->logfile) { fclose(ost->logfile); ost->logfile = NULL; } av_fifo_free(ost->fifo); av_freep(&ost->st->codec->subtitle_header); av_free(ost->pict_tmp.data[0]); av_free(ost->forced_kf_pts); if (ost->video_resample) sws_freeContext(ost->img_resample_ctx); if (ost->resample) audio_resample_close(ost->resample); if (ost->reformat_ctx) av_audio_convert_free(ost->reformat_ctx); av_free(ost); } } av_free(ost_table); } return ret; }
{ "code": [ " codec->bits_per_raw_sample= 0;" ], "line_no": [ 691 ] }
static int FUNC_0(AVFormatContext **VAR_0, int VAR_1, AVFormatContext **VAR_2, int VAR_3, AVStreamMap *VAR_4, int VAR_5) { int VAR_6 = 0, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11 = 0, VAR_12 = 0, VAR_13; AVFormatContext *is, *os; AVCodecContext *codec, *icodec; AVOutputStream *ost, **ost_table = NULL; AVInputStream *ist, **ist_table = NULL; AVInputFile *file_table; char VAR_14[1024]; int VAR_15; int VAR_16 = 1; uint8_t no_packet[MAX_FILES]={0}; int VAR_17=0; int VAR_18[AVMEDIA_TYPE_NB]={0}; int VAR_19[AVMEDIA_TYPE_NB]={0}; file_table= av_mallocz(VAR_3 * sizeof(AVInputFile)); if (!file_table) goto fail; VAR_8 = 0; for(VAR_7=0;VAR_7<VAR_3;VAR_7++) { is = VAR_2[VAR_7]; file_table[VAR_7].ist_index = VAR_8; file_table[VAR_7].VAR_19 = is->VAR_19; VAR_8 += is->VAR_19; } VAR_11 = VAR_8; ist_table = av_mallocz(VAR_11 * sizeof(AVInputStream *)); if (!ist_table) goto fail; for(VAR_7=0;VAR_7<VAR_11;VAR_7++) { ist = av_mallocz(sizeof(AVInputStream)); if (!ist) goto fail; ist_table[VAR_7] = ist; } VAR_8 = 0; for(VAR_7=0;VAR_7<VAR_3;VAR_7++) { is = VAR_2[VAR_7]; for(VAR_9=0;VAR_9<is->VAR_19;VAR_9++) { ist = ist_table[VAR_8++]; ist->st = is->streams[VAR_9]; ist->file_index = VAR_7; ist->index = VAR_9; ist->discard = 1; if (rate_emu) { ist->start = av_gettime(); } } } VAR_12 = 0; for(VAR_7=0;VAR_7<VAR_1;VAR_7++) { os = VAR_0[VAR_7]; if (!os->VAR_19 && !(os->oformat->flags & AVFMT_NOSTREAMS)) { av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1); fprintf(stderr, "Output file #%d does not contain any stream\VAR_10", VAR_7); VAR_6 = AVERROR(EINVAL); goto fail; } VAR_12 += os->VAR_19; } if (VAR_5 > 0 && VAR_5 != VAR_12) { fprintf(stderr, "Number of stream maps must match number of output streams\VAR_10"); VAR_6 = AVERROR(EINVAL); goto fail; } for(VAR_7=0;VAR_7<VAR_5;VAR_7++) { int VAR_20 = VAR_4[VAR_7].file_index; int VAR_25 = VAR_4[VAR_7].stream_index; if (VAR_20 < 0 || VAR_20 > VAR_3 - 1 || VAR_25 < 0 || VAR_25 > file_table[VAR_20].VAR_19 - 1) { fprintf(stderr,"Could not find input stream #%d.%d\VAR_10", VAR_20, VAR_25); VAR_6 = AVERROR(EINVAL); goto fail; } VAR_20 = VAR_4[VAR_7].sync_file_index; VAR_25 = VAR_4[VAR_7].sync_stream_index; if (VAR_20 < 0 || VAR_20 > VAR_3 - 1 || VAR_25 < 0 || VAR_25 > file_table[VAR_20].VAR_19 - 1) { fprintf(stderr,"Could not find sync stream #%d.%d\VAR_10", VAR_20, VAR_25); VAR_6 = AVERROR(EINVAL); goto fail; } } ost_table = av_mallocz(sizeof(AVOutputStream *) * VAR_12); if (!ost_table) goto fail; for(VAR_9=0;VAR_9<VAR_1;VAR_9++) { os = VAR_0[VAR_9]; for(VAR_7=0;VAR_7<os->VAR_19;VAR_7++,VAR_10++) { VAR_19[os->streams[VAR_7]->codec->codec_type]++; } } for(VAR_13=1<<30; VAR_13; VAR_13>>=1){ int VAR_22[AVMEDIA_TYPE_NB]={0}; for(VAR_8=0; VAR_8<AVMEDIA_TYPE_NB; VAR_8++) VAR_18[VAR_8] += VAR_13; for(VAR_8=0; VAR_8<VAR_11; VAR_8++) { int VAR_23=0; ist = ist_table[VAR_8]; if(opt_programid){ int VAR_24,VAR_25; AVFormatContext *f= VAR_2[ ist->file_index ]; VAR_23=1; for(VAR_24=0; VAR_24<f->nb_programs; VAR_24++){ AVProgram *p= f->programs[VAR_24]; if(p->id == opt_programid) for(VAR_25=0; VAR_25<p->nb_stream_indexes; VAR_25++){ if(f->streams[ p->stream_index[VAR_25] ] == ist->st) VAR_23=0; } } } if (ist->discard && ist->st->discard != AVDISCARD_ALL && !VAR_23 && VAR_18[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames){ VAR_22[ist->st->codec->codec_type]++; } } for(VAR_8=0; VAR_8<AVMEDIA_TYPE_NB; VAR_8++) if(VAR_22[VAR_8] < VAR_19[VAR_8]) VAR_18[VAR_8] -= VAR_13; } VAR_10 = 0; for(VAR_9=0;VAR_9<VAR_1;VAR_9++) { os = VAR_0[VAR_9]; for(VAR_7=0;VAR_7<os->VAR_19;VAR_7++,VAR_10++) { int found; ost = ost_table[VAR_10] = output_streams_for_file[VAR_9][VAR_7]; ost->st = os->streams[VAR_7]; if (VAR_5 > 0) { ost->source_index = file_table[VAR_4[VAR_10].file_index].ist_index + VAR_4[VAR_10].stream_index; if (ist_table[ost->source_index]->st->codec->codec_type != ost->st->codec->codec_type) { int VAR_7= ost->file_index; av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1); fprintf(stderr, "Codec type mismatch for mapping #%d.%d -> #%d.%d\VAR_10", VAR_4[VAR_10].file_index, VAR_4[VAR_10].stream_index, ost->file_index, ost->index); ffmpeg_exit(1); } } else { found = 0; for(VAR_8=0;VAR_8<VAR_11;VAR_8++) { int VAR_23=0; ist = ist_table[VAR_8]; if(opt_programid){ int VAR_24,VAR_25; AVFormatContext *f= VAR_2[ ist->file_index ]; VAR_23=1; for(VAR_24=0; VAR_24<f->nb_programs; VAR_24++){ AVProgram *p= f->programs[VAR_24]; if(p->id == opt_programid) for(VAR_25=0; VAR_25<p->nb_stream_indexes; VAR_25++){ if(f->streams[ p->stream_index[VAR_25] ] == ist->st) VAR_23=0; } } } if (ist->discard && ist->st->discard != AVDISCARD_ALL && !VAR_23 && ist->st->codec->codec_type == ost->st->codec->codec_type && VAR_18[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames) { ost->source_index = VAR_8; found = 1; break; } } if (!found) { if(! opt_programid) { for(VAR_8=0;VAR_8<VAR_11;VAR_8++) { ist = ist_table[VAR_8]; if ( ist->st->codec->codec_type == ost->st->codec->codec_type && ist->st->discard != AVDISCARD_ALL) { ost->source_index = VAR_8; found = 1; } } } if (!found) { int VAR_7= ost->file_index; av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1); fprintf(stderr, "Could not find input stream matching output stream #%d.%d\VAR_10", ost->file_index, ost->index); ffmpeg_exit(1); } } } ist = ist_table[ost->source_index]; ist->discard = 0; ost->sync_ist = (VAR_5 > 0) ? ist_table[file_table[VAR_4[VAR_10].sync_file_index].ist_index + VAR_4[VAR_10].sync_stream_index] : ist; } } for(VAR_7=0;VAR_7<VAR_12;VAR_7++) { ost = ost_table[VAR_7]; os = VAR_0[ost->file_index]; ist = ist_table[ost->source_index]; codec = ost->st->codec; icodec = ist->st->codec; if (metadata_streams_autocopy) av_metadata_copy(&ost->st->metadata, ist->st->metadata, AV_METADATA_DONT_OVERWRITE); ost->st->disposition = ist->st->disposition; codec->bits_per_raw_sample= icodec->bits_per_raw_sample; codec->chroma_sample_location = icodec->chroma_sample_location; if (ost->st->stream_copy) { uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE; if (extra_size > INT_MAX) goto fail; codec->codec_id = icodec->codec_id; codec->codec_type = icodec->codec_type; if(!codec->codec_tag){ if( !os->oformat->codec_tag || av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id || av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0) codec->codec_tag = icodec->codec_tag; } codec->bit_rate = icodec->bit_rate; codec->rc_max_rate = icodec->rc_max_rate; codec->rc_buffer_size = icodec->rc_buffer_size; codec->extradata= av_mallocz(extra_size); if (!codec->extradata) goto fail; memcpy(codec->extradata, icodec->extradata, icodec->extradata_size); codec->extradata_size= icodec->extradata_size; if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){ codec->time_base = icodec->time_base; codec->time_base.num *= icodec->ticks_per_frame; av_reduce(&codec->time_base.num, &codec->time_base.den, codec->time_base.num, codec->time_base.den, INT_MAX); }else codec->time_base = ist->st->time_base; switch(codec->codec_type) { case AVMEDIA_TYPE_AUDIO: if(audio_volume != 256) { fprintf(stderr,"-acodec copy and -vol are incompatible (frames are not decoded)\VAR_10"); ffmpeg_exit(1); } codec->channel_layout = icodec->channel_layout; codec->sample_rate = icodec->sample_rate; codec->channels = icodec->channels; codec->frame_size = icodec->frame_size; codec->audio_service_type = icodec->audio_service_type; codec->block_align= icodec->block_align; if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3) codec->block_align= 0; if(codec->codec_id == CODEC_ID_AC3) codec->block_align= 0; break; case AVMEDIA_TYPE_VIDEO: codec->pix_fmt = icodec->pix_fmt; codec->width = icodec->width; codec->height = icodec->height; codec->has_b_frames = icodec->has_b_frames; break; case AVMEDIA_TYPE_SUBTITLE: codec->width = icodec->width; codec->height = icodec->height; break; default: abort(); } } else { switch(codec->codec_type) { case AVMEDIA_TYPE_AUDIO: ost->fifo= av_fifo_alloc(1024); if(!ost->fifo) goto fail; ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE); ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1; icodec->request_channels = codec->channels; ist->decoding_needed = 1; ost->encoding_needed = 1; ost->resample_sample_fmt = icodec->sample_fmt; ost->resample_sample_rate = icodec->sample_rate; ost->resample_channels = icodec->channels; break; case AVMEDIA_TYPE_VIDEO: if (ost->st->codec->pix_fmt == PIX_FMT_NONE) { fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\VAR_10"); ffmpeg_exit(1); } ost->video_resample = (codec->width != icodec->width || codec->height != icodec->height || (codec->pix_fmt != icodec->pix_fmt)); if (ost->video_resample) { #if !CONFIG_AVFILTER avcodec_get_frame_defaults(&ost->pict_tmp); if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt, codec->width, codec->height)) { fprintf(stderr, "Cannot allocate temp picture, check pix fmt\VAR_10"); ffmpeg_exit(1); } sws_flags = av_get_int(sws_opts, "sws_flags", NULL); ost->img_resample_ctx = sws_getContext( icodec->width, icodec->height, icodec->pix_fmt, codec->width, codec->height, codec->pix_fmt, sws_flags, NULL, NULL, NULL); if (ost->img_resample_ctx == NULL) { fprintf(stderr, "Cannot get resampling context\VAR_10"); ffmpeg_exit(1); } ost->original_height = icodec->height; ost->original_width = icodec->width; #endif codec->bits_per_raw_sample= 0; } ost->resample_height = icodec->height; ost->resample_width = icodec->width; ost->resample_pix_fmt= icodec->pix_fmt; ost->encoding_needed = 1; ist->decoding_needed = 1; #if CONFIG_AVFILTER if (configure_filters(ist, ost)) { fprintf(stderr, "Error opening filters!\VAR_10"); exit(1); } #endif break; case AVMEDIA_TYPE_SUBTITLE: ost->encoding_needed = 1; ist->decoding_needed = 1; break; default: abort(); break; } if (ost->encoding_needed && (codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) { char VAR_25[1024]; FILE *f; snprintf(VAR_25, sizeof(VAR_25), "%s-%d.log", pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX, VAR_7); if (codec->flags & CODEC_FLAG_PASS1) { f = fopen(VAR_25, "wb"); if (!f) { fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\VAR_10", VAR_25, strerror(errno)); ffmpeg_exit(1); } ost->logfile = f; } else { char *VAR_26; size_t logbuffer_size; if (read_file(VAR_25, &VAR_26, &logbuffer_size) < 0) { fprintf(stderr, "Error reading log file '%s' for pass-2 encoding\VAR_10", VAR_25); ffmpeg_exit(1); } codec->stats_in = VAR_26; } } } if(codec->codec_type == AVMEDIA_TYPE_VIDEO){ int VAR_27= codec->width * codec->height; bit_buffer_size= FFMAX(bit_buffer_size, 6*VAR_27 + 1664); } } if (!bit_buffer) bit_buffer = av_malloc(bit_buffer_size); if (!bit_buffer) { fprintf(stderr, "Cannot allocate %d bytes output buffer\VAR_10", bit_buffer_size); VAR_6 = AVERROR(ENOMEM); goto fail; } for(VAR_7=0;VAR_7<VAR_12;VAR_7++) { ost = ost_table[VAR_7]; if (ost->encoding_needed) { AVCodec *codec = VAR_7 < nb_output_codecs ? output_codecs[VAR_7] : NULL; AVCodecContext *dec = ist_table[ost->source_index]->st->codec; if (!codec) codec = avcodec_find_encoder(ost->st->codec->codec_id); if (!codec) { snprintf(VAR_14, sizeof(VAR_14), "Encoder (codec id %d) not found for output stream #%d.%d", ost->st->codec->codec_id, ost->file_index, ost->index); VAR_6 = AVERROR(EINVAL); goto dump_format; } if (dec->subtitle_header) { ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size); if (!ost->st->codec->subtitle_header) { VAR_6 = AVERROR(ENOMEM); goto dump_format; } memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); ost->st->codec->subtitle_header_size = dec->subtitle_header_size; } if (avcodec_open(ost->st->codec, codec) < 0) { snprintf(VAR_14, sizeof(VAR_14), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height", ost->file_index, ost->index); VAR_6 = AVERROR(EINVAL); goto dump_format; } extra_size += ost->st->codec->extradata_size; } } for(VAR_7=0;VAR_7<VAR_11;VAR_7++) { ist = ist_table[VAR_7]; if (ist->decoding_needed) { AVCodec *codec = VAR_7 < nb_input_codecs ? input_codecs[VAR_7] : NULL; if (!codec) codec = avcodec_find_decoder(ist->st->codec->codec_id); if (!codec) { snprintf(VAR_14, sizeof(VAR_14), "Decoder (codec id %d) not found for input stream #%d.%d", ist->st->codec->codec_id, ist->file_index, ist->index); VAR_6 = AVERROR(EINVAL); goto dump_format; } if (avcodec_open(ist->st->codec, codec) < 0) { snprintf(VAR_14, sizeof(VAR_14), "Error while opening decoder for input stream #%d.%d", ist->file_index, ist->index); VAR_6 = AVERROR(EINVAL); goto dump_format; } } } for(VAR_7=0;VAR_7<VAR_11;VAR_7++) { AVStream *st; ist = ist_table[VAR_7]; st= ist->st; ist->pts = st->avg_frame_rate.num ? - st->codec->has_b_frames*AV_TIME_BASE / av_q2d(st->avg_frame_rate) : 0; ist->next_pts = AV_NOPTS_VALUE; ist->is_start = 1; } for (VAR_7=0;VAR_7<nb_meta_data_maps;VAR_7++) { AVFormatContext *files[2]; AVMetadata **meta[2]; int VAR_8; #define METADATA_CHECK_INDEX(index, nb_elems, desc)\ if ((index) < 0 || (index) >= (nb_elems)) {\ snprintf(VAR_14, sizeof(VAR_14), "Invalid %s index %d while processing metadata maps\VAR_10",\ (desc), (index));\ VAR_6 = AVERROR(EINVAL);\ goto dump_format;\ } int out_file_index = meta_data_maps[VAR_7][0].file; int in_file_index = meta_data_maps[VAR_7][1].file; if (in_file_index < 0 || out_file_index < 0) continue; METADATA_CHECK_INDEX(out_file_index, VAR_1, "output file") METADATA_CHECK_INDEX(in_file_index, VAR_3, "input file") files[0] = VAR_0[out_file_index]; files[1] = VAR_2[in_file_index]; for (VAR_8 = 0; VAR_8 < 2; VAR_8++) { AVMetaDataMap *map = &meta_data_maps[VAR_7][VAR_8]; switch (map->type) { case 'g': meta[VAR_8] = &files[VAR_8]->metadata; break; case 's': METADATA_CHECK_INDEX(map->index, files[VAR_8]->VAR_19, "stream") meta[VAR_8] = &files[VAR_8]->streams[map->index]->metadata; break; case 'c': METADATA_CHECK_INDEX(map->index, files[VAR_8]->nb_chapters, "chapter") meta[VAR_8] = &files[VAR_8]->chapters[map->index]->metadata; break; case 'p': METADATA_CHECK_INDEX(map->index, files[VAR_8]->nb_programs, "program") meta[VAR_8] = &files[VAR_8]->programs[map->index]->metadata; break; } } av_metadata_copy(meta[0], *meta[1], AV_METADATA_DONT_OVERWRITE); } if (metadata_global_autocopy) { for (VAR_7 = 0; VAR_7 < VAR_1; VAR_7++) av_metadata_copy(&VAR_0[VAR_7]->metadata, VAR_2[0]->metadata, AV_METADATA_DONT_OVERWRITE); } for (VAR_7 = 0; VAR_7 < nb_chapter_maps; VAR_7++) { int infile = chapter_maps[VAR_7].in_file; int outfile = chapter_maps[VAR_7].out_file; if (infile < 0 || outfile < 0) continue; if (infile >= VAR_3) { snprintf(VAR_14, sizeof(VAR_14), "Invalid input file index %d in chapter mapping.\VAR_10", infile); VAR_6 = AVERROR(EINVAL); goto dump_format; } if (outfile >= VAR_1) { snprintf(VAR_14, sizeof(VAR_14), "Invalid output file index %d in chapter mapping.\VAR_10",outfile); VAR_6 = AVERROR(EINVAL); goto dump_format; } copy_chapters(infile, outfile); } if (!nb_chapter_maps) for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) { if (!VAR_2[VAR_7]->nb_chapters) continue; for (VAR_8 = 0; VAR_8 < VAR_1; VAR_8++) if ((VAR_6 = copy_chapters(VAR_7, VAR_8)) < 0) goto dump_format; break; } for(VAR_7=0;VAR_7<VAR_1;VAR_7++) { os = VAR_0[VAR_7]; if (av_write_header(os) < 0) { snprintf(VAR_14, sizeof(VAR_14), "Could not write header for output file #%d (incorrect codec parameters ?)", VAR_7); VAR_6 = AVERROR(EINVAL); goto dump_format; } if (strcmp(VAR_0[VAR_7]->oformat->name, "rtp")) { VAR_16 = 0; } } dump_format: for(VAR_7=0;VAR_7<VAR_1;VAR_7++) { av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1); } if (verbose >= 0) { fprintf(stderr, "Stream mapping:\VAR_10"); for(VAR_7=0;VAR_7<VAR_12;VAR_7++) { ost = ost_table[VAR_7]; fprintf(stderr, " Stream #%d.%d -> #%d.%d", ist_table[ost->source_index]->file_index, ist_table[ost->source_index]->index, ost->file_index, ost->index); if (ost->sync_ist != ist_table[ost->source_index]) fprintf(stderr, " [sync #%d.%d]", ost->sync_ist->file_index, ost->sync_ist->index); fprintf(stderr, "\VAR_10"); } } if (VAR_6) { fprintf(stderr, "%s\VAR_10", VAR_14); goto fail; } if (VAR_16) { print_sdp(VAR_0, VAR_1); } if (!using_stdin) { if(verbose >= 0) fprintf(stderr, "Press [q] to stop encoding\VAR_10"); url_set_interrupt_cb(decode_interrupt_cb); } term_init(); timer_start = av_gettime(); for(; received_sigterm == 0;) { int file_index, ist_index; AVPacket pkt; double ipts_min; double opts_min; redo: ipts_min= 1e100; opts_min= 1e100; if (!using_stdin) { if (q_pressed) break; VAR_15 = read_key(); if (VAR_15 == 'q') break; } file_index = -1; for(VAR_7=0;VAR_7<VAR_12;VAR_7++) { double ipts, opts; ost = ost_table[VAR_7]; os = VAR_0[ost->file_index]; ist = ist_table[ost->source_index]; if(ist->is_past_recording_time || no_packet[ist->file_index]) continue; opts = ost->st->pts.val * av_q2d(ost->st->time_base); ipts = (double)ist->pts; if (!file_table[ist->file_index].eof_reached){ if(ipts < ipts_min) { ipts_min = ipts; if(input_sync ) file_index = ist->file_index; } if(opts < opts_min) { opts_min = opts; if(!input_sync) file_index = ist->file_index; } } if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){ file_index= -1; break; } } if (file_index < 0) { if(VAR_17){ VAR_17=0; memset(no_packet, 0, sizeof(no_packet)); usleep(10000); continue; } break; } if (limit_filesize != 0 && limit_filesize <= avio_tell(VAR_0[0]->pb)) break; is = VAR_2[file_index]; VAR_6= av_read_frame(is, &pkt); if(VAR_6 == AVERROR(EAGAIN)){ no_packet[file_index]=1; VAR_17++; continue; } if (VAR_6 < 0) { file_table[file_index].eof_reached = 1; if (opt_shortest) break; else continue; } VAR_17=0; memset(no_packet, 0, sizeof(no_packet)); 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 >= file_table[file_index].VAR_19) goto discard_packet; ist_index = file_table[file_index].ist_index + pkt.stream_index; ist = ist_table[ist_index]; if (ist->discard) goto discard_packet; if (pkt.dts != AV_NOPTS_VALUE) pkt.dts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) pkt.pts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base); if (pkt.stream_index < nb_input_files_ts_scale[file_index] && input_files_ts_scale[file_index][pkt.stream_index]){ if(pkt.pts != AV_NOPTS_VALUE) pkt.pts *= input_files_ts_scale[file_index][pkt.stream_index]; if(pkt.dts != AV_NOPTS_VALUE) pkt.dts *= input_files_ts_scale[file_index][pkt.stream_index]; } if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE && (is->iformat->flags & AVFMT_TS_DISCONT)) { int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q); int64_t delta= pkt_dts - ist->next_pts; if((FFABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE || pkt_dts+1<ist->pts)&& !copy_ts){ input_files_ts_offset[ist->file_index]-= delta; if (verbose > 2) fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\VAR_10", delta, input_files_ts_offset[ist->file_index]); 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); } } if (recording_time != INT64_MAX && av_compare_ts(pkt.pts, ist->st->time_base, recording_time + start_time, (AVRational){1, 1000000}) >= 0) { ist->is_past_recording_time = 1; goto discard_packet; } if (output_packet(ist, ist_index, ost_table, VAR_12, &pkt) < 0) { if (verbose >= 0) fprintf(stderr, "Error while decoding stream #%d.%d\VAR_10", ist->file_index, ist->index); if (exit_on_error) ffmpeg_exit(1); av_free_packet(&pkt); goto redo; } discard_packet: av_free_packet(&pkt); print_report(VAR_0, ost_table, VAR_12, 0); } for(VAR_7=0;VAR_7<VAR_11;VAR_7++) { ist = ist_table[VAR_7]; if (ist->decoding_needed) { output_packet(ist, VAR_7, ost_table, VAR_12, NULL); } } term_exit(); for(VAR_7=0;VAR_7<VAR_1;VAR_7++) { os = VAR_0[VAR_7]; av_write_trailer(os); } print_report(VAR_0, ost_table, VAR_12, 1); for(VAR_7=0;VAR_7<VAR_12;VAR_7++) { ost = ost_table[VAR_7]; if (ost->encoding_needed) { av_freep(&ost->st->codec->stats_in); avcodec_close(ost->st->codec); } #if CONFIG_AVFILTER avfilter_graph_free(&ost->graph); #endif } for(VAR_7=0;VAR_7<VAR_11;VAR_7++) { ist = ist_table[VAR_7]; if (ist->decoding_needed) { avcodec_close(ist->st->codec); } } VAR_6 = 0; fail: av_freep(&bit_buffer); av_free(file_table); if (ist_table) { for(VAR_7=0;VAR_7<VAR_11;VAR_7++) { ist = ist_table[VAR_7]; av_free(ist); } av_free(ist_table); } if (ost_table) { for(VAR_7=0;VAR_7<VAR_12;VAR_7++) { ost = ost_table[VAR_7]; if (ost) { if (ost->st->stream_copy) av_freep(&ost->st->codec->extradata); if (ost->logfile) { fclose(ost->logfile); ost->logfile = NULL; } av_fifo_free(ost->fifo); av_freep(&ost->st->codec->subtitle_header); av_free(ost->pict_tmp.data[0]); av_free(ost->forced_kf_pts); if (ost->video_resample) sws_freeContext(ost->img_resample_ctx); if (ost->resample) audio_resample_close(ost->resample); if (ost->reformat_ctx) av_audio_convert_free(ost->reformat_ctx); av_free(ost); } } av_free(ost_table); } return VAR_6; }
[ "static int FUNC_0(AVFormatContext **VAR_0,\nint VAR_1,\nAVFormatContext **VAR_2,\nint VAR_3,\nAVStreamMap *VAR_4, int VAR_5)\n{", "int VAR_6 = 0, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11 = 0, VAR_12 = 0, VAR_13;", "AVFormatContext *is, *os;", "AVCodecContext *codec, *icodec;", "AVOutputStream *ost, **ost_table = NULL;", "AVInputStream *ist, **ist_table = NULL;", "AVInputFile *file_table;", "char VAR_14[1024];", "int VAR_15;", "int VAR_16 = 1;", "uint8_t no_packet[MAX_FILES]={0};", "int VAR_17=0;", "int VAR_18[AVMEDIA_TYPE_NB]={0};", "int VAR_19[AVMEDIA_TYPE_NB]={0};", "file_table= av_mallocz(VAR_3 * sizeof(AVInputFile));", "if (!file_table)\ngoto fail;", "VAR_8 = 0;", "for(VAR_7=0;VAR_7<VAR_3;VAR_7++) {", "is = VAR_2[VAR_7];", "file_table[VAR_7].ist_index = VAR_8;", "file_table[VAR_7].VAR_19 = is->VAR_19;", "VAR_8 += is->VAR_19;", "}", "VAR_11 = VAR_8;", "ist_table = av_mallocz(VAR_11 * sizeof(AVInputStream *));", "if (!ist_table)\ngoto fail;", "for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {", "ist = av_mallocz(sizeof(AVInputStream));", "if (!ist)\ngoto fail;", "ist_table[VAR_7] = ist;", "}", "VAR_8 = 0;", "for(VAR_7=0;VAR_7<VAR_3;VAR_7++) {", "is = VAR_2[VAR_7];", "for(VAR_9=0;VAR_9<is->VAR_19;VAR_9++) {", "ist = ist_table[VAR_8++];", "ist->st = is->streams[VAR_9];", "ist->file_index = VAR_7;", "ist->index = VAR_9;", "ist->discard = 1;", "if (rate_emu) {", "ist->start = av_gettime();", "}", "}", "}", "VAR_12 = 0;", "for(VAR_7=0;VAR_7<VAR_1;VAR_7++) {", "os = VAR_0[VAR_7];", "if (!os->VAR_19 && !(os->oformat->flags & AVFMT_NOSTREAMS)) {", "av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1);", "fprintf(stderr, \"Output file #%d does not contain any stream\\VAR_10\", VAR_7);", "VAR_6 = AVERROR(EINVAL);", "goto fail;", "}", "VAR_12 += os->VAR_19;", "}", "if (VAR_5 > 0 && VAR_5 != VAR_12) {", "fprintf(stderr, \"Number of stream maps must match number of output streams\\VAR_10\");", "VAR_6 = AVERROR(EINVAL);", "goto fail;", "}", "for(VAR_7=0;VAR_7<VAR_5;VAR_7++) {", "int VAR_20 = VAR_4[VAR_7].file_index;", "int VAR_25 = VAR_4[VAR_7].stream_index;", "if (VAR_20 < 0 || VAR_20 > VAR_3 - 1 ||\nVAR_25 < 0 || VAR_25 > file_table[VAR_20].VAR_19 - 1) {", "fprintf(stderr,\"Could not find input stream #%d.%d\\VAR_10\", VAR_20, VAR_25);", "VAR_6 = AVERROR(EINVAL);", "goto fail;", "}", "VAR_20 = VAR_4[VAR_7].sync_file_index;", "VAR_25 = VAR_4[VAR_7].sync_stream_index;", "if (VAR_20 < 0 || VAR_20 > VAR_3 - 1 ||\nVAR_25 < 0 || VAR_25 > file_table[VAR_20].VAR_19 - 1) {", "fprintf(stderr,\"Could not find sync stream #%d.%d\\VAR_10\", VAR_20, VAR_25);", "VAR_6 = AVERROR(EINVAL);", "goto fail;", "}", "}", "ost_table = av_mallocz(sizeof(AVOutputStream *) * VAR_12);", "if (!ost_table)\ngoto fail;", "for(VAR_9=0;VAR_9<VAR_1;VAR_9++) {", "os = VAR_0[VAR_9];", "for(VAR_7=0;VAR_7<os->VAR_19;VAR_7++,VAR_10++) {", "VAR_19[os->streams[VAR_7]->codec->codec_type]++;", "}", "}", "for(VAR_13=1<<30; VAR_13; VAR_13>>=1){", "int VAR_22[AVMEDIA_TYPE_NB]={0};", "for(VAR_8=0; VAR_8<AVMEDIA_TYPE_NB; VAR_8++)", "VAR_18[VAR_8] += VAR_13;", "for(VAR_8=0; VAR_8<VAR_11; VAR_8++) {", "int VAR_23=0;", "ist = ist_table[VAR_8];", "if(opt_programid){", "int VAR_24,VAR_25;", "AVFormatContext *f= VAR_2[ ist->file_index ];", "VAR_23=1;", "for(VAR_24=0; VAR_24<f->nb_programs; VAR_24++){", "AVProgram *p= f->programs[VAR_24];", "if(p->id == opt_programid)\nfor(VAR_25=0; VAR_25<p->nb_stream_indexes; VAR_25++){", "if(f->streams[ p->stream_index[VAR_25] ] == ist->st)\nVAR_23=0;", "}", "}", "}", "if (ist->discard && ist->st->discard != AVDISCARD_ALL && !VAR_23\n&& VAR_18[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames){", "VAR_22[ist->st->codec->codec_type]++;", "}", "}", "for(VAR_8=0; VAR_8<AVMEDIA_TYPE_NB; VAR_8++)", "if(VAR_22[VAR_8] < VAR_19[VAR_8])\nVAR_18[VAR_8] -= VAR_13;", "}", "VAR_10 = 0;", "for(VAR_9=0;VAR_9<VAR_1;VAR_9++) {", "os = VAR_0[VAR_9];", "for(VAR_7=0;VAR_7<os->VAR_19;VAR_7++,VAR_10++) {", "int found;", "ost = ost_table[VAR_10] = output_streams_for_file[VAR_9][VAR_7];", "ost->st = os->streams[VAR_7];", "if (VAR_5 > 0) {", "ost->source_index = file_table[VAR_4[VAR_10].file_index].ist_index +\nVAR_4[VAR_10].stream_index;", "if (ist_table[ost->source_index]->st->codec->codec_type != ost->st->codec->codec_type) {", "int VAR_7= ost->file_index;", "av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1);", "fprintf(stderr, \"Codec type mismatch for mapping #%d.%d -> #%d.%d\\VAR_10\",\nVAR_4[VAR_10].file_index, VAR_4[VAR_10].stream_index,\nost->file_index, ost->index);", "ffmpeg_exit(1);", "}", "} else {", "found = 0;", "for(VAR_8=0;VAR_8<VAR_11;VAR_8++) {", "int VAR_23=0;", "ist = ist_table[VAR_8];", "if(opt_programid){", "int VAR_24,VAR_25;", "AVFormatContext *f= VAR_2[ ist->file_index ];", "VAR_23=1;", "for(VAR_24=0; VAR_24<f->nb_programs; VAR_24++){", "AVProgram *p= f->programs[VAR_24];", "if(p->id == opt_programid)\nfor(VAR_25=0; VAR_25<p->nb_stream_indexes; VAR_25++){", "if(f->streams[ p->stream_index[VAR_25] ] == ist->st)\nVAR_23=0;", "}", "}", "}", "if (ist->discard && ist->st->discard != AVDISCARD_ALL && !VAR_23 &&\nist->st->codec->codec_type == ost->st->codec->codec_type &&\nVAR_18[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames) {", "ost->source_index = VAR_8;", "found = 1;", "break;", "}", "}", "if (!found) {", "if(! opt_programid) {", "for(VAR_8=0;VAR_8<VAR_11;VAR_8++) {", "ist = ist_table[VAR_8];", "if ( ist->st->codec->codec_type == ost->st->codec->codec_type\n&& ist->st->discard != AVDISCARD_ALL) {", "ost->source_index = VAR_8;", "found = 1;", "}", "}", "}", "if (!found) {", "int VAR_7= ost->file_index;", "av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1);", "fprintf(stderr, \"Could not find input stream matching output stream #%d.%d\\VAR_10\",\nost->file_index, ost->index);", "ffmpeg_exit(1);", "}", "}", "}", "ist = ist_table[ost->source_index];", "ist->discard = 0;", "ost->sync_ist = (VAR_5 > 0) ?\nist_table[file_table[VAR_4[VAR_10].sync_file_index].ist_index +\nVAR_4[VAR_10].sync_stream_index] : ist;", "}", "}", "for(VAR_7=0;VAR_7<VAR_12;VAR_7++) {", "ost = ost_table[VAR_7];", "os = VAR_0[ost->file_index];", "ist = ist_table[ost->source_index];", "codec = ost->st->codec;", "icodec = ist->st->codec;", "if (metadata_streams_autocopy)\nav_metadata_copy(&ost->st->metadata, ist->st->metadata,\nAV_METADATA_DONT_OVERWRITE);", "ost->st->disposition = ist->st->disposition;", "codec->bits_per_raw_sample= icodec->bits_per_raw_sample;", "codec->chroma_sample_location = icodec->chroma_sample_location;", "if (ost->st->stream_copy) {", "uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE;", "if (extra_size > INT_MAX)\ngoto fail;", "codec->codec_id = icodec->codec_id;", "codec->codec_type = icodec->codec_type;", "if(!codec->codec_tag){", "if( !os->oformat->codec_tag\n|| av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id\n|| av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0)\ncodec->codec_tag = icodec->codec_tag;", "}", "codec->bit_rate = icodec->bit_rate;", "codec->rc_max_rate = icodec->rc_max_rate;", "codec->rc_buffer_size = icodec->rc_buffer_size;", "codec->extradata= av_mallocz(extra_size);", "if (!codec->extradata)\ngoto fail;", "memcpy(codec->extradata, icodec->extradata, icodec->extradata_size);", "codec->extradata_size= icodec->extradata_size;", "if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){", "codec->time_base = icodec->time_base;", "codec->time_base.num *= icodec->ticks_per_frame;", "av_reduce(&codec->time_base.num, &codec->time_base.den,\ncodec->time_base.num, codec->time_base.den, INT_MAX);", "}else", "codec->time_base = ist->st->time_base;", "switch(codec->codec_type) {", "case AVMEDIA_TYPE_AUDIO:\nif(audio_volume != 256) {", "fprintf(stderr,\"-acodec copy and -vol are incompatible (frames are not decoded)\\VAR_10\");", "ffmpeg_exit(1);", "}", "codec->channel_layout = icodec->channel_layout;", "codec->sample_rate = icodec->sample_rate;", "codec->channels = icodec->channels;", "codec->frame_size = icodec->frame_size;", "codec->audio_service_type = icodec->audio_service_type;", "codec->block_align= icodec->block_align;", "if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3)\ncodec->block_align= 0;", "if(codec->codec_id == CODEC_ID_AC3)\ncodec->block_align= 0;", "break;", "case AVMEDIA_TYPE_VIDEO:\ncodec->pix_fmt = icodec->pix_fmt;", "codec->width = icodec->width;", "codec->height = icodec->height;", "codec->has_b_frames = icodec->has_b_frames;", "break;", "case AVMEDIA_TYPE_SUBTITLE:\ncodec->width = icodec->width;", "codec->height = icodec->height;", "break;", "default:\nabort();", "}", "} else {", "switch(codec->codec_type) {", "case AVMEDIA_TYPE_AUDIO:\nost->fifo= av_fifo_alloc(1024);", "if(!ost->fifo)\ngoto fail;", "ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE);", "ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1;", "icodec->request_channels = codec->channels;", "ist->decoding_needed = 1;", "ost->encoding_needed = 1;", "ost->resample_sample_fmt = icodec->sample_fmt;", "ost->resample_sample_rate = icodec->sample_rate;", "ost->resample_channels = icodec->channels;", "break;", "case AVMEDIA_TYPE_VIDEO:\nif (ost->st->codec->pix_fmt == PIX_FMT_NONE) {", "fprintf(stderr, \"Video pixel format is unknown, stream cannot be encoded\\VAR_10\");", "ffmpeg_exit(1);", "}", "ost->video_resample = (codec->width != icodec->width ||\ncodec->height != icodec->height ||\n(codec->pix_fmt != icodec->pix_fmt));", "if (ost->video_resample) {", "#if !CONFIG_AVFILTER\navcodec_get_frame_defaults(&ost->pict_tmp);", "if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt,\ncodec->width, codec->height)) {", "fprintf(stderr, \"Cannot allocate temp picture, check pix fmt\\VAR_10\");", "ffmpeg_exit(1);", "}", "sws_flags = av_get_int(sws_opts, \"sws_flags\", NULL);", "ost->img_resample_ctx = sws_getContext(\nicodec->width,\nicodec->height,\nicodec->pix_fmt,\ncodec->width,\ncodec->height,\ncodec->pix_fmt,\nsws_flags, NULL, NULL, NULL);", "if (ost->img_resample_ctx == NULL) {", "fprintf(stderr, \"Cannot get resampling context\\VAR_10\");", "ffmpeg_exit(1);", "}", "ost->original_height = icodec->height;", "ost->original_width = icodec->width;", "#endif\ncodec->bits_per_raw_sample= 0;", "}", "ost->resample_height = icodec->height;", "ost->resample_width = icodec->width;", "ost->resample_pix_fmt= icodec->pix_fmt;", "ost->encoding_needed = 1;", "ist->decoding_needed = 1;", "#if CONFIG_AVFILTER\nif (configure_filters(ist, ost)) {", "fprintf(stderr, \"Error opening filters!\\VAR_10\");", "exit(1);", "}", "#endif\nbreak;", "case AVMEDIA_TYPE_SUBTITLE:\nost->encoding_needed = 1;", "ist->decoding_needed = 1;", "break;", "default:\nabort();", "break;", "}", "if (ost->encoding_needed &&\n(codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {", "char VAR_25[1024];", "FILE *f;", "snprintf(VAR_25, sizeof(VAR_25), \"%s-%d.log\",\npass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX,\nVAR_7);", "if (codec->flags & CODEC_FLAG_PASS1) {", "f = fopen(VAR_25, \"wb\");", "if (!f) {", "fprintf(stderr, \"Cannot write log file '%s' for pass-1 encoding: %s\\VAR_10\", VAR_25, strerror(errno));", "ffmpeg_exit(1);", "}", "ost->logfile = f;", "} else {", "char *VAR_26;", "size_t logbuffer_size;", "if (read_file(VAR_25, &VAR_26, &logbuffer_size) < 0) {", "fprintf(stderr, \"Error reading log file '%s' for pass-2 encoding\\VAR_10\", VAR_25);", "ffmpeg_exit(1);", "}", "codec->stats_in = VAR_26;", "}", "}", "}", "if(codec->codec_type == AVMEDIA_TYPE_VIDEO){", "int VAR_27= codec->width * codec->height;", "bit_buffer_size= FFMAX(bit_buffer_size, 6*VAR_27 + 1664);", "}", "}", "if (!bit_buffer)\nbit_buffer = av_malloc(bit_buffer_size);", "if (!bit_buffer) {", "fprintf(stderr, \"Cannot allocate %d bytes output buffer\\VAR_10\",\nbit_buffer_size);", "VAR_6 = AVERROR(ENOMEM);", "goto fail;", "}", "for(VAR_7=0;VAR_7<VAR_12;VAR_7++) {", "ost = ost_table[VAR_7];", "if (ost->encoding_needed) {", "AVCodec *codec = VAR_7 < nb_output_codecs ? output_codecs[VAR_7] : NULL;", "AVCodecContext *dec = ist_table[ost->source_index]->st->codec;", "if (!codec)\ncodec = avcodec_find_encoder(ost->st->codec->codec_id);", "if (!codec) {", "snprintf(VAR_14, sizeof(VAR_14), \"Encoder (codec id %d) not found for output stream #%d.%d\",\nost->st->codec->codec_id, ost->file_index, ost->index);", "VAR_6 = AVERROR(EINVAL);", "goto dump_format;", "}", "if (dec->subtitle_header) {", "ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size);", "if (!ost->st->codec->subtitle_header) {", "VAR_6 = AVERROR(ENOMEM);", "goto dump_format;", "}", "memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);", "ost->st->codec->subtitle_header_size = dec->subtitle_header_size;", "}", "if (avcodec_open(ost->st->codec, codec) < 0) {", "snprintf(VAR_14, sizeof(VAR_14), \"Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height\",\nost->file_index, ost->index);", "VAR_6 = AVERROR(EINVAL);", "goto dump_format;", "}", "extra_size += ost->st->codec->extradata_size;", "}", "}", "for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {", "ist = ist_table[VAR_7];", "if (ist->decoding_needed) {", "AVCodec *codec = VAR_7 < nb_input_codecs ? input_codecs[VAR_7] : NULL;", "if (!codec)\ncodec = avcodec_find_decoder(ist->st->codec->codec_id);", "if (!codec) {", "snprintf(VAR_14, sizeof(VAR_14), \"Decoder (codec id %d) not found for input stream #%d.%d\",\nist->st->codec->codec_id, ist->file_index, ist->index);", "VAR_6 = AVERROR(EINVAL);", "goto dump_format;", "}", "if (avcodec_open(ist->st->codec, codec) < 0) {", "snprintf(VAR_14, sizeof(VAR_14), \"Error while opening decoder for input stream #%d.%d\",\nist->file_index, ist->index);", "VAR_6 = AVERROR(EINVAL);", "goto dump_format;", "}", "}", "}", "for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {", "AVStream *st;", "ist = ist_table[VAR_7];", "st= ist->st;", "ist->pts = st->avg_frame_rate.num ? - st->codec->has_b_frames*AV_TIME_BASE / av_q2d(st->avg_frame_rate) : 0;", "ist->next_pts = AV_NOPTS_VALUE;", "ist->is_start = 1;", "}", "for (VAR_7=0;VAR_7<nb_meta_data_maps;VAR_7++) {", "AVFormatContext *files[2];", "AVMetadata **meta[2];", "int VAR_8;", "#define METADATA_CHECK_INDEX(index, nb_elems, desc)\\\nif ((index) < 0 || (index) >= (nb_elems)) {\\", "snprintf(VAR_14, sizeof(VAR_14), \"Invalid %s index %d while processing metadata maps\\VAR_10\",\\\n(desc), (index));\\", "VAR_6 = AVERROR(EINVAL);\\", "goto dump_format;\\", "}", "int out_file_index = meta_data_maps[VAR_7][0].file;", "int in_file_index = meta_data_maps[VAR_7][1].file;", "if (in_file_index < 0 || out_file_index < 0)\ncontinue;", "METADATA_CHECK_INDEX(out_file_index, VAR_1, \"output file\")\nMETADATA_CHECK_INDEX(in_file_index, VAR_3, \"input file\")\nfiles[0] = VAR_0[out_file_index];", "files[1] = VAR_2[in_file_index];", "for (VAR_8 = 0; VAR_8 < 2; VAR_8++) {", "AVMetaDataMap *map = &meta_data_maps[VAR_7][VAR_8];", "switch (map->type) {", "case 'g':\nmeta[VAR_8] = &files[VAR_8]->metadata;", "break;", "case 's':\nMETADATA_CHECK_INDEX(map->index, files[VAR_8]->VAR_19, \"stream\")\nmeta[VAR_8] = &files[VAR_8]->streams[map->index]->metadata;", "break;", "case 'c':\nMETADATA_CHECK_INDEX(map->index, files[VAR_8]->nb_chapters, \"chapter\")\nmeta[VAR_8] = &files[VAR_8]->chapters[map->index]->metadata;", "break;", "case 'p':\nMETADATA_CHECK_INDEX(map->index, files[VAR_8]->nb_programs, \"program\")\nmeta[VAR_8] = &files[VAR_8]->programs[map->index]->metadata;", "break;", "}", "}", "av_metadata_copy(meta[0], *meta[1], AV_METADATA_DONT_OVERWRITE);", "}", "if (metadata_global_autocopy) {", "for (VAR_7 = 0; VAR_7 < VAR_1; VAR_7++)", "av_metadata_copy(&VAR_0[VAR_7]->metadata, VAR_2[0]->metadata,\nAV_METADATA_DONT_OVERWRITE);", "}", "for (VAR_7 = 0; VAR_7 < nb_chapter_maps; VAR_7++) {", "int infile = chapter_maps[VAR_7].in_file;", "int outfile = chapter_maps[VAR_7].out_file;", "if (infile < 0 || outfile < 0)\ncontinue;", "if (infile >= VAR_3) {", "snprintf(VAR_14, sizeof(VAR_14), \"Invalid input file index %d in chapter mapping.\\VAR_10\", infile);", "VAR_6 = AVERROR(EINVAL);", "goto dump_format;", "}", "if (outfile >= VAR_1) {", "snprintf(VAR_14, sizeof(VAR_14), \"Invalid output file index %d in chapter mapping.\\VAR_10\",outfile);", "VAR_6 = AVERROR(EINVAL);", "goto dump_format;", "}", "copy_chapters(infile, outfile);", "}", "if (!nb_chapter_maps)\nfor (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {", "if (!VAR_2[VAR_7]->nb_chapters)\ncontinue;", "for (VAR_8 = 0; VAR_8 < VAR_1; VAR_8++)", "if ((VAR_6 = copy_chapters(VAR_7, VAR_8)) < 0)\ngoto dump_format;", "break;", "}", "for(VAR_7=0;VAR_7<VAR_1;VAR_7++) {", "os = VAR_0[VAR_7];", "if (av_write_header(os) < 0) {", "snprintf(VAR_14, sizeof(VAR_14), \"Could not write header for output file #%d (incorrect codec parameters ?)\", VAR_7);", "VAR_6 = AVERROR(EINVAL);", "goto dump_format;", "}", "if (strcmp(VAR_0[VAR_7]->oformat->name, \"rtp\")) {", "VAR_16 = 0;", "}", "}", "dump_format:\nfor(VAR_7=0;VAR_7<VAR_1;VAR_7++) {", "av_dump_format(VAR_0[VAR_7], VAR_7, VAR_0[VAR_7]->filename, 1);", "}", "if (verbose >= 0) {", "fprintf(stderr, \"Stream mapping:\\VAR_10\");", "for(VAR_7=0;VAR_7<VAR_12;VAR_7++) {", "ost = ost_table[VAR_7];", "fprintf(stderr, \" Stream #%d.%d -> #%d.%d\",\nist_table[ost->source_index]->file_index,\nist_table[ost->source_index]->index,\nost->file_index,\nost->index);", "if (ost->sync_ist != ist_table[ost->source_index])\nfprintf(stderr, \" [sync #%d.%d]\",\nost->sync_ist->file_index,\nost->sync_ist->index);", "fprintf(stderr, \"\\VAR_10\");", "}", "}", "if (VAR_6) {", "fprintf(stderr, \"%s\\VAR_10\", VAR_14);", "goto fail;", "}", "if (VAR_16) {", "print_sdp(VAR_0, VAR_1);", "}", "if (!using_stdin) {", "if(verbose >= 0)\nfprintf(stderr, \"Press [q] to stop encoding\\VAR_10\");", "url_set_interrupt_cb(decode_interrupt_cb);", "}", "term_init();", "timer_start = av_gettime();", "for(; received_sigterm == 0;) {", "int file_index, ist_index;", "AVPacket pkt;", "double ipts_min;", "double opts_min;", "redo:\nipts_min= 1e100;", "opts_min= 1e100;", "if (!using_stdin) {", "if (q_pressed)\nbreak;", "VAR_15 = read_key();", "if (VAR_15 == 'q')\nbreak;", "}", "file_index = -1;", "for(VAR_7=0;VAR_7<VAR_12;VAR_7++) {", "double ipts, opts;", "ost = ost_table[VAR_7];", "os = VAR_0[ost->file_index];", "ist = ist_table[ost->source_index];", "if(ist->is_past_recording_time || no_packet[ist->file_index])\ncontinue;", "opts = ost->st->pts.val * av_q2d(ost->st->time_base);", "ipts = (double)ist->pts;", "if (!file_table[ist->file_index].eof_reached){", "if(ipts < ipts_min) {", "ipts_min = ipts;", "if(input_sync ) file_index = ist->file_index;", "}", "if(opts < opts_min) {", "opts_min = opts;", "if(!input_sync) file_index = ist->file_index;", "}", "}", "if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){", "file_index= -1;", "break;", "}", "}", "if (file_index < 0) {", "if(VAR_17){", "VAR_17=0;", "memset(no_packet, 0, sizeof(no_packet));", "usleep(10000);", "continue;", "}", "break;", "}", "if (limit_filesize != 0 && limit_filesize <= avio_tell(VAR_0[0]->pb))\nbreak;", "is = VAR_2[file_index];", "VAR_6= av_read_frame(is, &pkt);", "if(VAR_6 == AVERROR(EAGAIN)){", "no_packet[file_index]=1;", "VAR_17++;", "continue;", "}", "if (VAR_6 < 0) {", "file_table[file_index].eof_reached = 1;", "if (opt_shortest)\nbreak;", "else\ncontinue;", "}", "VAR_17=0;", "memset(no_packet, 0, sizeof(no_packet));", "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 >= file_table[file_index].VAR_19)\ngoto discard_packet;", "ist_index = file_table[file_index].ist_index + pkt.stream_index;", "ist = ist_table[ist_index];", "if (ist->discard)\ngoto discard_packet;", "if (pkt.dts != AV_NOPTS_VALUE)\npkt.dts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base);", "if (pkt.pts != AV_NOPTS_VALUE)\npkt.pts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base);", "if (pkt.stream_index < nb_input_files_ts_scale[file_index]\n&& input_files_ts_scale[file_index][pkt.stream_index]){", "if(pkt.pts != AV_NOPTS_VALUE)\npkt.pts *= input_files_ts_scale[file_index][pkt.stream_index];", "if(pkt.dts != AV_NOPTS_VALUE)\npkt.dts *= input_files_ts_scale[file_index][pkt.stream_index];", "}", "if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE\n&& (is->iformat->flags & AVFMT_TS_DISCONT)) {", "int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);", "int64_t delta= pkt_dts - ist->next_pts;", "if((FFABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE || pkt_dts+1<ist->pts)&& !copy_ts){", "input_files_ts_offset[ist->file_index]-= delta;", "if (verbose > 2)\nfprintf(stderr, \"timestamp discontinuity %\"PRId64\", new offset= %\"PRId64\"\\VAR_10\", delta, input_files_ts_offset[ist->file_index]);", "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);", "}", "}", "if (recording_time != INT64_MAX &&\nav_compare_ts(pkt.pts, ist->st->time_base, recording_time + start_time, (AVRational){1, 1000000}) >= 0) {", "ist->is_past_recording_time = 1;", "goto discard_packet;", "}", "if (output_packet(ist, ist_index, ost_table, VAR_12, &pkt) < 0) {", "if (verbose >= 0)\nfprintf(stderr, \"Error while decoding stream #%d.%d\\VAR_10\",\nist->file_index, ist->index);", "if (exit_on_error)\nffmpeg_exit(1);", "av_free_packet(&pkt);", "goto redo;", "}", "discard_packet:\nav_free_packet(&pkt);", "print_report(VAR_0, ost_table, VAR_12, 0);", "}", "for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {", "ist = ist_table[VAR_7];", "if (ist->decoding_needed) {", "output_packet(ist, VAR_7, ost_table, VAR_12, NULL);", "}", "}", "term_exit();", "for(VAR_7=0;VAR_7<VAR_1;VAR_7++) {", "os = VAR_0[VAR_7];", "av_write_trailer(os);", "}", "print_report(VAR_0, ost_table, VAR_12, 1);", "for(VAR_7=0;VAR_7<VAR_12;VAR_7++) {", "ost = ost_table[VAR_7];", "if (ost->encoding_needed) {", "av_freep(&ost->st->codec->stats_in);", "avcodec_close(ost->st->codec);", "}", "#if CONFIG_AVFILTER\navfilter_graph_free(&ost->graph);", "#endif\n}", "for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {", "ist = ist_table[VAR_7];", "if (ist->decoding_needed) {", "avcodec_close(ist->st->codec);", "}", "}", "VAR_6 = 0;", "fail:\nav_freep(&bit_buffer);", "av_free(file_table);", "if (ist_table) {", "for(VAR_7=0;VAR_7<VAR_11;VAR_7++) {", "ist = ist_table[VAR_7];", "av_free(ist);", "}", "av_free(ist_table);", "}", "if (ost_table) {", "for(VAR_7=0;VAR_7<VAR_12;VAR_7++) {", "ost = ost_table[VAR_7];", "if (ost) {", "if (ost->st->stream_copy)\nav_freep(&ost->st->codec->extradata);", "if (ost->logfile) {", "fclose(ost->logfile);", "ost->logfile = NULL;", "}", "av_fifo_free(ost->fifo);", "av_freep(&ost->st->codec->subtitle_header);", "av_free(ost->pict_tmp.data[0]);", "av_free(ost->forced_kf_pts);", "if (ost->video_resample)\nsws_freeContext(ost->img_resample_ctx);", "if (ost->resample)\naudio_resample_close(ost->resample);", "if (ost->reformat_ctx)\nav_audio_convert_free(ost->reformat_ctx);", "av_free(ost);", "}", "}", "av_free(ost_table);", "}", "return VAR_6;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43, 45 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71, 73 ], [ 77 ], [ 79 ], [ 81, 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 161 ], [ 163 ], [ 165 ], [ 169, 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185, 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 201 ], [ 203, 205 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249, 251 ], [ 253, 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263, 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275, 277 ], [ 279 ], [ 281 ], [ 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297, 299 ], [ 305 ], [ 307 ], [ 309 ], [ 311, 313, 315 ], [ 317 ], [ 319 ], [ 323 ], [ 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 ], [ 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 ], [ 439 ], [ 441 ], [ 443 ], [ 445 ], [ 449 ], [ 451 ], [ 455, 457, 459 ], [ 463 ], [ 465 ], [ 467 ], [ 471 ], [ 473 ], [ 477, 479 ], [ 485 ], [ 487 ], [ 491 ], [ 493, 495, 497, 499 ], [ 501 ], [ 505 ], [ 507 ], [ 509 ], [ 511 ], [ 513, 515 ], [ 517 ], [ 519 ], [ 521 ], [ 523 ], [ 525 ], [ 527, 529 ], [ 531 ], [ 533 ], [ 535 ], [ 537, 539 ], [ 541 ], [ 543 ], [ 545 ], [ 547 ], [ 549 ], [ 551 ], [ 553 ], [ 555 ], [ 557 ], [ 559, 561 ], [ 563, 565 ], [ 567 ], [ 569, 571 ], [ 573 ], [ 575 ], [ 577 ], [ 579 ], [ 581, 583 ], [ 585 ], [ 587 ], [ 589, 591 ], [ 593 ], [ 595 ], [ 597 ], [ 599, 601 ], [ 603, 605 ], [ 607 ], [ 609 ], [ 611 ], [ 613 ], [ 615 ], [ 617 ], [ 619 ], [ 621 ], [ 623 ], [ 625, 627 ], [ 629 ], [ 631 ], [ 633 ], [ 635, 637, 639 ], [ 641 ], [ 643, 645 ], [ 647, 649 ], [ 651 ], [ 653 ], [ 655 ], [ 657 ], [ 659, 661, 663, 665, 667, 669, 671, 673 ], [ 675 ], [ 677 ], [ 679 ], [ 681 ], [ 685 ], [ 687 ], [ 689, 691 ], [ 693 ], [ 695 ], [ 697 ], [ 699 ], [ 701 ], [ 703 ], [ 707, 709 ], [ 711 ], [ 713 ], [ 715 ], [ 717, 719 ], [ 721, 723 ], [ 725 ], [ 727 ], [ 729, 731 ], [ 733 ], [ 735 ], [ 739, 741 ], [ 743 ], [ 745 ], [ 749, 751, 753 ], [ 755 ], [ 757 ], [ 759 ], [ 761 ], [ 763 ], [ 765 ], [ 767 ], [ 769 ], [ 771 ], [ 773 ], [ 775 ], [ 777 ], [ 779 ], [ 781 ], [ 783 ], [ 785 ], [ 787 ], [ 789 ], [ 791 ], [ 795 ], [ 797 ], [ 799 ], [ 801 ], [ 805, 807 ], [ 809 ], [ 811, 813 ], [ 815 ], [ 817 ], [ 819 ], [ 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 ], [ 891 ], [ 893 ], [ 895 ], [ 897 ], [ 899, 901 ], [ 903 ], [ 905, 907 ], [ 909 ], [ 911 ], [ 913 ], [ 915 ], [ 917, 919 ], [ 921 ], [ 923 ], [ 925 ], [ 931 ], [ 933 ], [ 939 ], [ 941 ], [ 943 ], [ 945 ], [ 947 ], [ 949 ], [ 951 ], [ 953 ], [ 959 ], [ 961 ], [ 963 ], [ 965 ], [ 969, 971 ], [ 973, 975 ], [ 977 ], [ 979 ], [ 981 ], [ 985 ], [ 987 ], [ 989, 991 ], [ 993, 995, 999 ], [ 1001 ], [ 1005 ], [ 1007 ], [ 1011 ], [ 1013, 1015 ], [ 1017 ], [ 1019, 1021, 1023 ], [ 1025 ], [ 1027, 1029, 1031 ], [ 1033 ], [ 1035, 1037, 1039 ], [ 1041 ], [ 1043 ], [ 1045 ], [ 1049 ], [ 1051 ], [ 1057 ], [ 1061 ], [ 1063, 1065 ], [ 1067 ], [ 1073 ], [ 1075 ], [ 1077 ], [ 1081, 1083 ], [ 1085 ], [ 1087 ], [ 1089 ], [ 1091 ], [ 1093 ], [ 1095 ], [ 1097 ], [ 1099 ], [ 1101 ], [ 1103 ], [ 1105 ], [ 1107 ], [ 1113, 1115 ], [ 1117, 1119 ], [ 1123 ], [ 1125, 1127 ], [ 1129 ], [ 1131 ], [ 1137 ], [ 1139 ], [ 1141 ], [ 1143 ], [ 1145 ], [ 1147 ], [ 1149 ], [ 1151 ], [ 1153 ], [ 1155 ], [ 1157 ], [ 1161, 1167 ], [ 1169 ], [ 1171 ], [ 1177 ], [ 1179 ], [ 1181 ], [ 1183 ], [ 1185, 1187, 1189, 1191, 1193 ], [ 1195, 1197, 1199, 1201 ], [ 1203 ], [ 1205 ], [ 1207 ], [ 1211 ], [ 1213 ], [ 1215 ], [ 1217 ], [ 1221 ], [ 1223 ], [ 1225 ], [ 1229 ], [ 1231, 1233 ], [ 1235 ], [ 1237 ], [ 1239 ], [ 1243 ], [ 1247 ], [ 1249 ], [ 1251 ], [ 1253 ], [ 1255 ], [ 1259, 1261 ], [ 1263 ], [ 1267 ], [ 1269, 1271 ], [ 1275 ], [ 1277, 1279 ], [ 1281 ], [ 1289 ], [ 1291 ], [ 1293 ], [ 1295 ], [ 1297 ], [ 1299 ], [ 1301, 1303 ], [ 1305 ], [ 1307 ], [ 1309 ], [ 1311 ], [ 1313 ], [ 1315 ], [ 1317 ], [ 1319 ], [ 1321 ], [ 1323 ], [ 1325 ], [ 1327 ], [ 1329 ], [ 1331 ], [ 1333 ], [ 1335 ], [ 1337 ], [ 1341 ], [ 1343 ], [ 1345 ], [ 1347 ], [ 1349 ], [ 1351 ], [ 1353 ], [ 1355 ], [ 1357 ], [ 1363, 1365 ], [ 1371 ], [ 1373 ], [ 1375 ], [ 1377 ], [ 1379 ], [ 1381 ], [ 1383 ], [ 1385 ], [ 1387 ], [ 1389, 1391 ], [ 1393, 1395 ], [ 1397 ], [ 1401 ], [ 1403 ], [ 1407 ], [ 1409, 1411 ], [ 1413 ], [ 1419, 1421 ], [ 1423 ], [ 1425 ], [ 1427, 1429 ], [ 1433, 1435 ], [ 1437, 1439 ], [ 1443, 1445 ], [ 1447, 1449 ], [ 1451, 1453 ], [ 1455 ], [ 1461, 1463 ], [ 1465 ], [ 1467 ], [ 1469 ], [ 1471 ], [ 1473, 1475 ], [ 1477 ], [ 1479, 1481 ], [ 1483 ], [ 1485 ], [ 1491, 1493 ], [ 1495 ], [ 1497 ], [ 1499 ], [ 1505 ], [ 1509, 1511, 1513 ], [ 1515, 1517 ], [ 1519 ], [ 1521 ], [ 1523 ], [ 1527, 1529 ], [ 1535 ], [ 1537 ], [ 1543 ], [ 1545 ], [ 1547 ], [ 1549 ], [ 1551 ], [ 1553 ], [ 1557 ], [ 1563 ], [ 1565 ], [ 1567 ], [ 1569 ], [ 1575 ], [ 1581 ], [ 1583 ], [ 1585 ], [ 1587 ], [ 1589 ], [ 1591 ], [ 1593, 1595 ], [ 1597, 1599 ], [ 1605 ], [ 1607 ], [ 1609 ], [ 1611 ], [ 1613 ], [ 1615 ], [ 1621 ], [ 1625, 1627 ], [ 1629 ], [ 1633 ], [ 1635 ], [ 1637 ], [ 1639 ], [ 1641 ], [ 1643 ], [ 1645 ], [ 1647 ], [ 1649 ], [ 1651 ], [ 1653 ], [ 1655, 1657 ], [ 1659 ], [ 1661 ], [ 1663 ], [ 1665 ], [ 1667 ], [ 1671 ], [ 1673 ], [ 1675 ], [ 1677, 1679 ], [ 1681, 1683 ], [ 1685, 1687 ], [ 1689 ], [ 1691 ], [ 1693 ], [ 1695 ], [ 1697 ], [ 1699 ], [ 1701 ] ]
9,423
static int xan_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { XanContext *s = avctx->priv_data; int ftype; int ret; s->pic.reference = 1; s->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; if ((ret = avctx->reget_buffer(avctx, &s->pic))) { av_log(s->avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return ret; } ftype = AV_RL32(avpkt->data); switch (ftype) { case 0: ret = xan_decode_frame_type0(avctx, avpkt); break; case 1: ret = xan_decode_frame_type1(avctx, avpkt); break; default: av_log(avctx, AV_LOG_ERROR, "Unknown frame type %d\n", ftype); return -1; } if (ret) return ret; *data_size = sizeof(AVFrame); *(AVFrame*)data = s->pic; return avpkt->size; }
true
FFmpeg
55188278169c3a1838334d7aa47a1f7a40741690
static int xan_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { XanContext *s = avctx->priv_data; int ftype; int ret; s->pic.reference = 1; s->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; if ((ret = avctx->reget_buffer(avctx, &s->pic))) { av_log(s->avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return ret; } ftype = AV_RL32(avpkt->data); switch (ftype) { case 0: ret = xan_decode_frame_type0(avctx, avpkt); break; case 1: ret = xan_decode_frame_type1(avctx, avpkt); break; default: av_log(avctx, AV_LOG_ERROR, "Unknown frame type %d\n", ftype); return -1; } if (ret) return ret; *data_size = sizeof(AVFrame); *(AVFrame*)data = s->pic; return avpkt->size; }
{ "code": [ " ftype = AV_RL32(avpkt->data);", " ret = xan_decode_frame_type0(avctx, avpkt);", " ret = xan_decode_frame_type1(avctx, avpkt);" ], "line_no": [ 35, 41, 47 ] }
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, AVPacket *VAR_3) { XanContext *s = VAR_0->priv_data; int VAR_4; int VAR_5; s->pic.reference = 1; s->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; if ((VAR_5 = VAR_0->reget_buffer(VAR_0, &s->pic))) { av_log(s->VAR_0, AV_LOG_ERROR, "reget_buffer() failed\n"); return VAR_5; } VAR_4 = AV_RL32(VAR_3->VAR_1); switch (VAR_4) { case 0: VAR_5 = xan_decode_frame_type0(VAR_0, VAR_3); break; case 1: VAR_5 = xan_decode_frame_type1(VAR_0, VAR_3); break; default: av_log(VAR_0, AV_LOG_ERROR, "Unknown frame type %d\n", VAR_4); return -1; } if (VAR_5) return VAR_5; *VAR_2 = sizeof(AVFrame); *(AVFrame*)VAR_1 = s->pic; return VAR_3->size; }
[ "static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{", "XanContext *s = VAR_0->priv_data;", "int VAR_4;", "int VAR_5;", "s->pic.reference = 1;", "s->pic.buffer_hints = FF_BUFFER_HINTS_VALID |\nFF_BUFFER_HINTS_PRESERVE |\nFF_BUFFER_HINTS_REUSABLE;", "if ((VAR_5 = VAR_0->reget_buffer(VAR_0, &s->pic))) {", "av_log(s->VAR_0, AV_LOG_ERROR, \"reget_buffer() failed\\n\");", "return VAR_5;", "}", "VAR_4 = AV_RL32(VAR_3->VAR_1);", "switch (VAR_4) {", "case 0:\nVAR_5 = xan_decode_frame_type0(VAR_0, VAR_3);", "break;", "case 1:\nVAR_5 = xan_decode_frame_type1(VAR_0, VAR_3);", "break;", "default:\nav_log(VAR_0, AV_LOG_ERROR, \"Unknown frame type %d\\n\", VAR_4);", "return -1;", "}", "if (VAR_5)\nreturn VAR_5;", "*VAR_2 = sizeof(AVFrame);", "*(AVFrame*)VAR_1 = s->pic;", "return VAR_3->size;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19, 21, 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39, 41 ], [ 43 ], [ 45, 47 ], [ 49 ], [ 51, 53 ], [ 55 ], [ 57 ], [ 59, 61 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ] ]
9,424
static void decode_rowskip(uint8_t* plane, int width, int height, int stride, VC9Context *v){ int x, y; GetBitContext *gb = &v->s.gb; for (y=0; y<height; y++){ if (!get_bits(gb, 1)) //rowskip memset(plane, 0, width); else for (x=0; x<width; x++) plane[x] = get_bits(gb, 1); plane += stride; } }
true
FFmpeg
7cc84d241ba6ef8e27e4d057176a4ad385ad3d59
static void decode_rowskip(uint8_t* plane, int width, int height, int stride, VC9Context *v){ int x, y; GetBitContext *gb = &v->s.gb; for (y=0; y<height; y++){ if (!get_bits(gb, 1)) memset(plane, 0, width); else for (x=0; x<width; x++) plane[x] = get_bits(gb, 1); plane += stride; } }
{ "code": [ "static void decode_rowskip(uint8_t* plane, int width, int height, int stride, VC9Context *v){", " GetBitContext *gb = &v->s.gb;", " GetBitContext *gb = &v->s.gb;" ], "line_no": [ 1, 5, 5 ] }
static void FUNC_0(uint8_t* VAR_0, int VAR_1, int VAR_2, int VAR_3, VC9Context *VAR_4){ int VAR_5, VAR_6; GetBitContext *gb = &VAR_4->s.gb; for (VAR_6=0; VAR_6<VAR_2; VAR_6++){ if (!get_bits(gb, 1)) memset(VAR_0, 0, VAR_1); else for (VAR_5=0; VAR_5<VAR_1; VAR_5++) VAR_0[VAR_5] = get_bits(gb, 1); VAR_0 += VAR_3; } }
[ "static void FUNC_0(uint8_t* VAR_0, int VAR_1, int VAR_2, int VAR_3, VC9Context *VAR_4){", "int VAR_5, VAR_6;", "GetBitContext *gb = &VAR_4->s.gb;", "for (VAR_6=0; VAR_6<VAR_2; VAR_6++){", "if (!get_bits(gb, 1))\nmemset(VAR_0, 0, VAR_1);", "else\nfor (VAR_5=0; VAR_5<VAR_1; VAR_5++)", "VAR_0[VAR_5] = get_bits(gb, 1);", "VAR_0 += VAR_3;", "}", "}" ]
[ 1, 0, 1, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1 ], [ 3 ], [ 5 ], [ 9 ], [ 11, 13 ], [ 15, 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ] ]
9,425
vu_queue_notify(VuDev *dev, VuVirtq *vq) { if (unlikely(dev->broken)) { return; } if (!vring_notify(dev, vq)) { DPRINT("skipped notify...\n"); return; } if (eventfd_write(vq->call_fd, 1) < 0) { vu_panic(dev, "Error writing eventfd: %s", strerror(errno)); } }
true
qemu
640601c7cb1b6b41d3e1a435b986266c2b71e9bc
vu_queue_notify(VuDev *dev, VuVirtq *vq) { if (unlikely(dev->broken)) { return; } if (!vring_notify(dev, vq)) { DPRINT("skipped notify...\n"); return; } if (eventfd_write(vq->call_fd, 1) < 0) { vu_panic(dev, "Error writing eventfd: %s", strerror(errno)); } }
{ "code": [ " if (unlikely(dev->broken)) {", " if (unlikely(dev->broken)) {", " if (unlikely(dev->broken)) {", " if (unlikely(dev->broken)) {" ], "line_no": [ 5, 5, 5, 5 ] }
FUNC_0(VuDev *VAR_0, VuVirtq *VAR_1) { if (unlikely(VAR_0->broken)) { return; } if (!vring_notify(VAR_0, VAR_1)) { DPRINT("skipped notify...\n"); return; } if (eventfd_write(VAR_1->call_fd, 1) < 0) { vu_panic(VAR_0, "Error writing eventfd: %s", strerror(errno)); } }
[ "FUNC_0(VuDev *VAR_0, VuVirtq *VAR_1)\n{", "if (unlikely(VAR_0->broken)) {", "return;", "}", "if (!vring_notify(VAR_0, VAR_1)) {", "DPRINT(\"skipped notify...\\n\");", "return;", "}", "if (eventfd_write(VAR_1->call_fd, 1) < 0) {", "vu_panic(VAR_0, \"Error writing eventfd: %s\", strerror(errno));", "}", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ] ]
9,426
int ff_rv34_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; RV34DecContext *r = avctx->priv_data; MpegEncContext *s = &r->s; AVFrame *pict = data; SliceInfo si; int i; int slice_count; const uint8_t *slices_hdr = NULL; int last = 0; /* no supplementary picture */ if (buf_size == 0) { /* special case for last picture */ if (s->low_delay==0 && s->next_picture_ptr) { *pict = *(AVFrame*)s->next_picture_ptr; s->next_picture_ptr = NULL; *data_size = sizeof(AVFrame); } return 0; } if(!avctx->slice_count){ slice_count = (*buf++) + 1; slices_hdr = buf + 4; buf += 8 * slice_count; }else slice_count = avctx->slice_count; //parse first slice header to check whether this frame can be decoded if(get_slice_offset(avctx, slices_hdr, 0) > buf_size){ av_log(avctx, AV_LOG_ERROR, "Slice offset is greater than frame size\n"); return -1; } init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, 0), (buf_size-get_slice_offset(avctx, slices_hdr, 0))*8); if(r->parse_slice_header(r, &r->s.gb, &si) < 0 || si.start){ av_log(avctx, AV_LOG_ERROR, "First slice header is incorrect\n"); return -1; } if ((!s->last_picture_ptr || !s->last_picture_ptr->f.data[0]) && si.type == AV_PICTURE_TYPE_B) return -1; if( (avctx->skip_frame >= AVDISCARD_NONREF && si.type==AV_PICTURE_TYPE_B) || (avctx->skip_frame >= AVDISCARD_NONKEY && si.type!=AV_PICTURE_TYPE_I) || avctx->skip_frame >= AVDISCARD_ALL) return buf_size; for(i = 0; i < slice_count; i++){ int offset = get_slice_offset(avctx, slices_hdr, i); int size; if(i+1 == slice_count) size = buf_size - offset; else size = get_slice_offset(avctx, slices_hdr, i+1) - offset; if(offset > buf_size){ av_log(avctx, AV_LOG_ERROR, "Slice offset is greater than frame size\n"); break; } r->si.end = s->mb_width * s->mb_height; if(i+1 < slice_count){ init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, i+1), (buf_size-get_slice_offset(avctx, slices_hdr, i+1))*8); if(r->parse_slice_header(r, &r->s.gb, &si) < 0){ if(i+2 < slice_count) size = get_slice_offset(avctx, slices_hdr, i+2) - offset; else size = buf_size - offset; }else r->si.end = si.start; } last = rv34_decode_slice(r, r->si.end, buf + offset, size); s->mb_num_left = r->s.mb_x + r->s.mb_y*r->s.mb_width - r->si.start; if(last) break; } if(last && s->current_picture_ptr){ if(r->loop_filter) r->loop_filter(r, s->mb_height - 1); ff_er_frame_end(s); MPV_frame_end(s); if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { *pict = *(AVFrame*)s->current_picture_ptr; } else if (s->last_picture_ptr != NULL) { *pict = *(AVFrame*)s->last_picture_ptr; } if(s->last_picture_ptr || s->low_delay){ *data_size = sizeof(AVFrame); ff_print_debug_info(s, pict); } s->current_picture_ptr = NULL; //so we can detect if frame_end wasnt called (find some nicer solution...) } return buf_size; }
true
FFmpeg
b4ed3d78cb6c41c9d3ee5918c326ab925edd6a89
int ff_rv34_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; RV34DecContext *r = avctx->priv_data; MpegEncContext *s = &r->s; AVFrame *pict = data; SliceInfo si; int i; int slice_count; const uint8_t *slices_hdr = NULL; int last = 0; if (buf_size == 0) { if (s->low_delay==0 && s->next_picture_ptr) { *pict = *(AVFrame*)s->next_picture_ptr; s->next_picture_ptr = NULL; *data_size = sizeof(AVFrame); } return 0; } if(!avctx->slice_count){ slice_count = (*buf++) + 1; slices_hdr = buf + 4; buf += 8 * slice_count; }else slice_count = avctx->slice_count; if(get_slice_offset(avctx, slices_hdr, 0) > buf_size){ av_log(avctx, AV_LOG_ERROR, "Slice offset is greater than frame size\n"); return -1; } init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, 0), (buf_size-get_slice_offset(avctx, slices_hdr, 0))*8); if(r->parse_slice_header(r, &r->s.gb, &si) < 0 || si.start){ av_log(avctx, AV_LOG_ERROR, "First slice header is incorrect\n"); return -1; } if ((!s->last_picture_ptr || !s->last_picture_ptr->f.data[0]) && si.type == AV_PICTURE_TYPE_B) return -1; if( (avctx->skip_frame >= AVDISCARD_NONREF && si.type==AV_PICTURE_TYPE_B) || (avctx->skip_frame >= AVDISCARD_NONKEY && si.type!=AV_PICTURE_TYPE_I) || avctx->skip_frame >= AVDISCARD_ALL) return buf_size; for(i = 0; i < slice_count; i++){ int offset = get_slice_offset(avctx, slices_hdr, i); int size; if(i+1 == slice_count) size = buf_size - offset; else size = get_slice_offset(avctx, slices_hdr, i+1) - offset; if(offset > buf_size){ av_log(avctx, AV_LOG_ERROR, "Slice offset is greater than frame size\n"); break; } r->si.end = s->mb_width * s->mb_height; if(i+1 < slice_count){ init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, i+1), (buf_size-get_slice_offset(avctx, slices_hdr, i+1))*8); if(r->parse_slice_header(r, &r->s.gb, &si) < 0){ if(i+2 < slice_count) size = get_slice_offset(avctx, slices_hdr, i+2) - offset; else size = buf_size - offset; }else r->si.end = si.start; } last = rv34_decode_slice(r, r->si.end, buf + offset, size); s->mb_num_left = r->s.mb_x + r->s.mb_y*r->s.mb_width - r->si.start; if(last) break; } if(last && s->current_picture_ptr){ if(r->loop_filter) r->loop_filter(r, s->mb_height - 1); ff_er_frame_end(s); MPV_frame_end(s); if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { *pict = *(AVFrame*)s->current_picture_ptr; } else if (s->last_picture_ptr != NULL) { *pict = *(AVFrame*)s->last_picture_ptr; } if(s->last_picture_ptr || s->low_delay){ *data_size = sizeof(AVFrame); ff_print_debug_info(s, pict); } s->current_picture_ptr = NULL; } return buf_size; }
{ "code": [ " return buf_size;", " return buf_size;" ], "line_no": [ 99, 197 ] }
int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, AVPacket *VAR_3) { const uint8_t *VAR_4 = VAR_3->VAR_1; int VAR_5 = VAR_3->VAR_11; RV34DecContext *r = VAR_0->priv_data; MpegEncContext *s = &r->s; AVFrame *pict = VAR_1; SliceInfo si; int VAR_6; int VAR_7; const uint8_t *VAR_8 = NULL; int VAR_9 = 0; if (VAR_5 == 0) { if (s->low_delay==0 && s->next_picture_ptr) { *pict = *(AVFrame*)s->next_picture_ptr; s->next_picture_ptr = NULL; *VAR_2 = sizeof(AVFrame); } return 0; } if(!VAR_0->VAR_7){ VAR_7 = (*VAR_4++) + 1; VAR_8 = VAR_4 + 4; VAR_4 += 8 * VAR_7; }else VAR_7 = VAR_0->VAR_7; if(get_slice_offset(VAR_0, VAR_8, 0) > VAR_5){ av_log(VAR_0, AV_LOG_ERROR, "Slice VAR_10 is greater than frame VAR_11\n"); return -1; } init_get_bits(&s->gb, VAR_4+get_slice_offset(VAR_0, VAR_8, 0), (VAR_5-get_slice_offset(VAR_0, VAR_8, 0))*8); if(r->parse_slice_header(r, &r->s.gb, &si) < 0 || si.start){ av_log(VAR_0, AV_LOG_ERROR, "First slice header is incorrect\n"); return -1; } if ((!s->last_picture_ptr || !s->last_picture_ptr->f.VAR_1[0]) && si.type == AV_PICTURE_TYPE_B) return -1; if( (VAR_0->skip_frame >= AVDISCARD_NONREF && si.type==AV_PICTURE_TYPE_B) || (VAR_0->skip_frame >= AVDISCARD_NONKEY && si.type!=AV_PICTURE_TYPE_I) || VAR_0->skip_frame >= AVDISCARD_ALL) return VAR_5; for(VAR_6 = 0; VAR_6 < VAR_7; VAR_6++){ int VAR_10 = get_slice_offset(VAR_0, VAR_8, VAR_6); int VAR_11; if(VAR_6+1 == VAR_7) VAR_11 = VAR_5 - VAR_10; else VAR_11 = get_slice_offset(VAR_0, VAR_8, VAR_6+1) - VAR_10; if(VAR_10 > VAR_5){ av_log(VAR_0, AV_LOG_ERROR, "Slice VAR_10 is greater than frame VAR_11\n"); break; } r->si.end = s->mb_width * s->mb_height; if(VAR_6+1 < VAR_7){ init_get_bits(&s->gb, VAR_4+get_slice_offset(VAR_0, VAR_8, VAR_6+1), (VAR_5-get_slice_offset(VAR_0, VAR_8, VAR_6+1))*8); if(r->parse_slice_header(r, &r->s.gb, &si) < 0){ if(VAR_6+2 < VAR_7) VAR_11 = get_slice_offset(VAR_0, VAR_8, VAR_6+2) - VAR_10; else VAR_11 = VAR_5 - VAR_10; }else r->si.end = si.start; } VAR_9 = rv34_decode_slice(r, r->si.end, VAR_4 + VAR_10, VAR_11); s->mb_num_left = r->s.mb_x + r->s.mb_y*r->s.mb_width - r->si.start; if(VAR_9) break; } if(VAR_9 && s->current_picture_ptr){ if(r->loop_filter) r->loop_filter(r, s->mb_height - 1); ff_er_frame_end(s); MPV_frame_end(s); if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { *pict = *(AVFrame*)s->current_picture_ptr; } else if (s->last_picture_ptr != NULL) { *pict = *(AVFrame*)s->last_picture_ptr; } if(s->last_picture_ptr || s->low_delay){ *VAR_2 = sizeof(AVFrame); ff_print_debug_info(s, pict); } s->current_picture_ptr = NULL; } return VAR_5; }
[ "int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{", "const uint8_t *VAR_4 = VAR_3->VAR_1;", "int VAR_5 = VAR_3->VAR_11;", "RV34DecContext *r = VAR_0->priv_data;", "MpegEncContext *s = &r->s;", "AVFrame *pict = VAR_1;", "SliceInfo si;", "int VAR_6;", "int VAR_7;", "const uint8_t *VAR_8 = NULL;", "int VAR_9 = 0;", "if (VAR_5 == 0) {", "if (s->low_delay==0 && s->next_picture_ptr) {", "*pict = *(AVFrame*)s->next_picture_ptr;", "s->next_picture_ptr = NULL;", "*VAR_2 = sizeof(AVFrame);", "}", "return 0;", "}", "if(!VAR_0->VAR_7){", "VAR_7 = (*VAR_4++) + 1;", "VAR_8 = VAR_4 + 4;", "VAR_4 += 8 * VAR_7;", "}else", "VAR_7 = VAR_0->VAR_7;", "if(get_slice_offset(VAR_0, VAR_8, 0) > VAR_5){", "av_log(VAR_0, AV_LOG_ERROR, \"Slice VAR_10 is greater than frame VAR_11\\n\");", "return -1;", "}", "init_get_bits(&s->gb, VAR_4+get_slice_offset(VAR_0, VAR_8, 0), (VAR_5-get_slice_offset(VAR_0, VAR_8, 0))*8);", "if(r->parse_slice_header(r, &r->s.gb, &si) < 0 || si.start){", "av_log(VAR_0, AV_LOG_ERROR, \"First slice header is incorrect\\n\");", "return -1;", "}", "if ((!s->last_picture_ptr || !s->last_picture_ptr->f.VAR_1[0]) && si.type == AV_PICTURE_TYPE_B)\nreturn -1;", "if( (VAR_0->skip_frame >= AVDISCARD_NONREF && si.type==AV_PICTURE_TYPE_B)\n|| (VAR_0->skip_frame >= AVDISCARD_NONKEY && si.type!=AV_PICTURE_TYPE_I)\n|| VAR_0->skip_frame >= AVDISCARD_ALL)\nreturn VAR_5;", "for(VAR_6 = 0; VAR_6 < VAR_7; VAR_6++){", "int VAR_10 = get_slice_offset(VAR_0, VAR_8, VAR_6);", "int VAR_11;", "if(VAR_6+1 == VAR_7)\nVAR_11 = VAR_5 - VAR_10;", "else\nVAR_11 = get_slice_offset(VAR_0, VAR_8, VAR_6+1) - VAR_10;", "if(VAR_10 > VAR_5){", "av_log(VAR_0, AV_LOG_ERROR, \"Slice VAR_10 is greater than frame VAR_11\\n\");", "break;", "}", "r->si.end = s->mb_width * s->mb_height;", "if(VAR_6+1 < VAR_7){", "init_get_bits(&s->gb, VAR_4+get_slice_offset(VAR_0, VAR_8, VAR_6+1), (VAR_5-get_slice_offset(VAR_0, VAR_8, VAR_6+1))*8);", "if(r->parse_slice_header(r, &r->s.gb, &si) < 0){", "if(VAR_6+2 < VAR_7)\nVAR_11 = get_slice_offset(VAR_0, VAR_8, VAR_6+2) - VAR_10;", "else\nVAR_11 = VAR_5 - VAR_10;", "}else", "r->si.end = si.start;", "}", "VAR_9 = rv34_decode_slice(r, r->si.end, VAR_4 + VAR_10, VAR_11);", "s->mb_num_left = r->s.mb_x + r->s.mb_y*r->s.mb_width - r->si.start;", "if(VAR_9)\nbreak;", "}", "if(VAR_9 && s->current_picture_ptr){", "if(r->loop_filter)\nr->loop_filter(r, s->mb_height - 1);", "ff_er_frame_end(s);", "MPV_frame_end(s);", "if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {", "*pict = *(AVFrame*)s->current_picture_ptr;", "} else if (s->last_picture_ptr != NULL) {", "*pict = *(AVFrame*)s->last_picture_ptr;", "}", "if(s->last_picture_ptr || s->low_delay){", "*VAR_2 = sizeof(AVFrame);", "ff_print_debug_info(s, pict);", "}", "s->current_picture_ptr = NULL;", "}", "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, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89, 91 ], [ 93, 95, 97, 99 ], [ 103 ], [ 105 ], [ 107 ], [ 109, 111 ], [ 113, 115 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137, 139 ], [ 141, 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155, 157 ], [ 159 ], [ 163 ], [ 165, 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ] ]
9,428
static int qemu_chr_open_win_stdio(QemuOpts *opts, CharDriverState **_chr) { CharDriverState *chr; WinStdioCharState *stdio; DWORD dwMode; int is_console = 0; if (stdio_nb_clients >= STDIO_MAX_CLIENTS || ((display_type != DT_NOGRAPHIC) && (stdio_nb_clients != 0))) { return -EIO; } chr = g_malloc0(sizeof(CharDriverState)); stdio = g_malloc0(sizeof(WinStdioCharState)); stdio->hStdIn = GetStdHandle(STD_INPUT_HANDLE); if (stdio->hStdIn == INVALID_HANDLE_VALUE) { fprintf(stderr, "cannot open stdio: invalid handle\n"); exit(1); } is_console = GetConsoleMode(stdio->hStdIn, &dwMode) != 0; chr->opaque = stdio; chr->chr_write = win_stdio_write; chr->chr_close = win_stdio_close; if (stdio_nb_clients == 0) { if (is_console) { if (qemu_add_wait_object(stdio->hStdIn, win_stdio_wait_func, chr)) { fprintf(stderr, "qemu_add_wait_object: failed\n"); } } else { DWORD dwId; stdio->hInputReadyEvent = CreateEvent(NULL, FALSE, FALSE, NULL); stdio->hInputDoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL); stdio->hInputThread = CreateThread(NULL, 0, win_stdio_thread, chr, 0, &dwId); if (stdio->hInputThread == INVALID_HANDLE_VALUE || stdio->hInputReadyEvent == INVALID_HANDLE_VALUE || stdio->hInputDoneEvent == INVALID_HANDLE_VALUE) { fprintf(stderr, "cannot create stdio thread or event\n"); exit(1); } if (qemu_add_wait_object(stdio->hInputReadyEvent, win_stdio_thread_wait_func, chr)) { fprintf(stderr, "qemu_add_wait_object: failed\n"); } } } dwMode |= ENABLE_LINE_INPUT; stdio_clients[stdio_nb_clients++] = chr; if (stdio_nb_clients == 1 && is_console) { /* set the terminal in raw mode */ /* ENABLE_QUICK_EDIT_MODE | ENABLE_EXTENDED_FLAGS */ dwMode |= ENABLE_PROCESSED_INPUT; } SetConsoleMode(stdio->hStdIn, dwMode); chr->chr_set_echo = qemu_chr_set_echo_win_stdio; qemu_chr_fe_set_echo(chr, false); *_chr = chr; return 0; }
true
qemu
1f51470d044852592922f91000e741c381582cdc
static int qemu_chr_open_win_stdio(QemuOpts *opts, CharDriverState **_chr) { CharDriverState *chr; WinStdioCharState *stdio; DWORD dwMode; int is_console = 0; if (stdio_nb_clients >= STDIO_MAX_CLIENTS || ((display_type != DT_NOGRAPHIC) && (stdio_nb_clients != 0))) { return -EIO; } chr = g_malloc0(sizeof(CharDriverState)); stdio = g_malloc0(sizeof(WinStdioCharState)); stdio->hStdIn = GetStdHandle(STD_INPUT_HANDLE); if (stdio->hStdIn == INVALID_HANDLE_VALUE) { fprintf(stderr, "cannot open stdio: invalid handle\n"); exit(1); } is_console = GetConsoleMode(stdio->hStdIn, &dwMode) != 0; chr->opaque = stdio; chr->chr_write = win_stdio_write; chr->chr_close = win_stdio_close; if (stdio_nb_clients == 0) { if (is_console) { if (qemu_add_wait_object(stdio->hStdIn, win_stdio_wait_func, chr)) { fprintf(stderr, "qemu_add_wait_object: failed\n"); } } else { DWORD dwId; stdio->hInputReadyEvent = CreateEvent(NULL, FALSE, FALSE, NULL); stdio->hInputDoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL); stdio->hInputThread = CreateThread(NULL, 0, win_stdio_thread, chr, 0, &dwId); if (stdio->hInputThread == INVALID_HANDLE_VALUE || stdio->hInputReadyEvent == INVALID_HANDLE_VALUE || stdio->hInputDoneEvent == INVALID_HANDLE_VALUE) { fprintf(stderr, "cannot create stdio thread or event\n"); exit(1); } if (qemu_add_wait_object(stdio->hInputReadyEvent, win_stdio_thread_wait_func, chr)) { fprintf(stderr, "qemu_add_wait_object: failed\n"); } } } dwMode |= ENABLE_LINE_INPUT; stdio_clients[stdio_nb_clients++] = chr; if (stdio_nb_clients == 1 && is_console) { dwMode |= ENABLE_PROCESSED_INPUT; } SetConsoleMode(stdio->hStdIn, dwMode); chr->chr_set_echo = qemu_chr_set_echo_win_stdio; qemu_chr_fe_set_echo(chr, false); *_chr = chr; return 0; }
{ "code": [ " *_chr = chr;", " return 0;", " *_chr = chr;", " return 0;", " *_chr = chr;", " return 0;", " return 0;", " return 0;", " return 0;", " *_chr = chr;", " return 0;", " *_chr = chr;", " return 0;", " *_chr = chr;", " return 0;", " *_chr = chr;", " return 0;", " *_chr = chr;", " return 0;", " return -EIO;", " *_chr = chr;", " return 0;", " return -EIO;", " *_chr = chr;", " return 0;", " return 0;", " return -EIO;", "static int qemu_chr_open_win_stdio(QemuOpts *opts, CharDriverState **_chr)", " return -EIO;", " *_chr = chr;", " return 0;", " *_chr = chr;", " return 0;", " *_chr = chr;", " return 0;", " *_chr = chr;", " return 0;" ], "line_no": [ 137, 141, 137, 141, 137, 141, 141, 141, 141, 137, 141, 137, 141, 137, 141, 137, 141, 137, 141, 19, 137, 141, 19, 137, 141, 141, 19, 1, 19, 137, 141, 137, 141, 137, 141, 137, 141 ] }
static int FUNC_0(QemuOpts *VAR_0, CharDriverState **VAR_1) { CharDriverState *chr; WinStdioCharState *stdio; DWORD dwMode; int VAR_2 = 0; if (stdio_nb_clients >= STDIO_MAX_CLIENTS || ((display_type != DT_NOGRAPHIC) && (stdio_nb_clients != 0))) { return -EIO; } chr = g_malloc0(sizeof(CharDriverState)); stdio = g_malloc0(sizeof(WinStdioCharState)); stdio->hStdIn = GetStdHandle(STD_INPUT_HANDLE); if (stdio->hStdIn == INVALID_HANDLE_VALUE) { fprintf(stderr, "cannot open stdio: invalid handle\n"); exit(1); } VAR_2 = GetConsoleMode(stdio->hStdIn, &dwMode) != 0; chr->opaque = stdio; chr->chr_write = win_stdio_write; chr->chr_close = win_stdio_close; if (stdio_nb_clients == 0) { if (VAR_2) { if (qemu_add_wait_object(stdio->hStdIn, win_stdio_wait_func, chr)) { fprintf(stderr, "qemu_add_wait_object: failed\n"); } } else { DWORD dwId; stdio->hInputReadyEvent = CreateEvent(NULL, FALSE, FALSE, NULL); stdio->hInputDoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL); stdio->hInputThread = CreateThread(NULL, 0, win_stdio_thread, chr, 0, &dwId); if (stdio->hInputThread == INVALID_HANDLE_VALUE || stdio->hInputReadyEvent == INVALID_HANDLE_VALUE || stdio->hInputDoneEvent == INVALID_HANDLE_VALUE) { fprintf(stderr, "cannot create stdio thread or event\n"); exit(1); } if (qemu_add_wait_object(stdio->hInputReadyEvent, win_stdio_thread_wait_func, chr)) { fprintf(stderr, "qemu_add_wait_object: failed\n"); } } } dwMode |= ENABLE_LINE_INPUT; stdio_clients[stdio_nb_clients++] = chr; if (stdio_nb_clients == 1 && VAR_2) { dwMode |= ENABLE_PROCESSED_INPUT; } SetConsoleMode(stdio->hStdIn, dwMode); chr->chr_set_echo = qemu_chr_set_echo_win_stdio; qemu_chr_fe_set_echo(chr, false); *VAR_1 = chr; return 0; }
[ "static int FUNC_0(QemuOpts *VAR_0, CharDriverState **VAR_1)\n{", "CharDriverState *chr;", "WinStdioCharState *stdio;", "DWORD dwMode;", "int VAR_2 = 0;", "if (stdio_nb_clients >= STDIO_MAX_CLIENTS\n|| ((display_type != DT_NOGRAPHIC) && (stdio_nb_clients != 0))) {", "return -EIO;", "}", "chr = g_malloc0(sizeof(CharDriverState));", "stdio = g_malloc0(sizeof(WinStdioCharState));", "stdio->hStdIn = GetStdHandle(STD_INPUT_HANDLE);", "if (stdio->hStdIn == INVALID_HANDLE_VALUE) {", "fprintf(stderr, \"cannot open stdio: invalid handle\\n\");", "exit(1);", "}", "VAR_2 = GetConsoleMode(stdio->hStdIn, &dwMode) != 0;", "chr->opaque = stdio;", "chr->chr_write = win_stdio_write;", "chr->chr_close = win_stdio_close;", "if (stdio_nb_clients == 0) {", "if (VAR_2) {", "if (qemu_add_wait_object(stdio->hStdIn,\nwin_stdio_wait_func, chr)) {", "fprintf(stderr, \"qemu_add_wait_object: failed\\n\");", "}", "} else {", "DWORD dwId;", "stdio->hInputReadyEvent = CreateEvent(NULL, FALSE, FALSE, NULL);", "stdio->hInputDoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL);", "stdio->hInputThread = CreateThread(NULL, 0, win_stdio_thread,\nchr, 0, &dwId);", "if (stdio->hInputThread == INVALID_HANDLE_VALUE\n|| stdio->hInputReadyEvent == INVALID_HANDLE_VALUE\n|| stdio->hInputDoneEvent == INVALID_HANDLE_VALUE) {", "fprintf(stderr, \"cannot create stdio thread or event\\n\");", "exit(1);", "}", "if (qemu_add_wait_object(stdio->hInputReadyEvent,\nwin_stdio_thread_wait_func, chr)) {", "fprintf(stderr, \"qemu_add_wait_object: failed\\n\");", "}", "}", "}", "dwMode |= ENABLE_LINE_INPUT;", "stdio_clients[stdio_nb_clients++] = chr;", "if (stdio_nb_clients == 1 && VAR_2) {", "dwMode |= ENABLE_PROCESSED_INPUT;", "}", "SetConsoleMode(stdio->hStdIn, dwMode);", "chr->chr_set_echo = qemu_chr_set_echo_win_stdio;", "qemu_chr_fe_set_echo(chr, false);", "*VAR_1 = chr;", "return 0;", "}" ]
[ 1, 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, 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15, 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59, 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 73 ], [ 75 ], [ 77, 79 ], [ 83, 85, 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95, 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 109 ], [ 113 ], [ 115 ], [ 121 ], [ 123 ], [ 127 ], [ 131 ], [ 133 ], [ 137 ], [ 141 ], [ 143 ] ]
9,429
int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[]) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat); int nb_components = desc->nb_components; int plane, x, y; int plane_count = isGray(c->srcFormat) ? 1 : 3; int sixteen_bits = desc->comp[0].depth_minus1 >= 8; unsigned off = 1<<desc->comp[0].depth_minus1; unsigned shift = desc->comp[0].depth_minus1 + 1; unsigned max = (1<<shift) - 1; av_assert0(plane_count == nb_components - 1); if (desc->flags & AV_PIX_FMT_FLAG_PLANAR) { for (plane = 0; plane < plane_count; plane++) { int w = plane ? c->chrSrcW : c->srcW; int y_subsample = plane ? desc->log2_chroma_h: 0; for (y = srcSliceY >> y_subsample; y < FF_CEIL_RSHIFT(srcSliceH, y_subsample); y++) { if (sixteen_bits) { const uint16_t *s = src[plane ] + srcStride[plane] * y; const uint16_t *a = src[plane_count] + srcStride[plane_count] * y; uint16_t *d = dst[plane ] + dstStride[plane] * y; unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<desc->comp[0].depth_minus1 : 0; if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) { for (x = 0; x < w; x++) { unsigned u = s[x]*a[x] + target*(max-a[x]) + off; d[x] = av_clip((u + (u >> shift)) >> shift, 0, max); } } else { for (x = 0; x < w; x++) { unsigned aswap =av_bswap16(a[x]); unsigned u = av_bswap16(s[x])*aswap + target*(max-aswap) + off; d[x] = av_clip((u + (u >> shift)) >> shift, 0, max); } } } else { const uint8_t *s = src[plane ] + srcStride[plane] * y; const uint8_t *a = src[plane_count] + srcStride[plane_count] * y; uint8_t *d = dst[plane ] + dstStride[plane] * y; unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 128 : 0; for (x = 0; x < w; x++) { unsigned u = s[x]*a[x] + target*(255-a[x]) + 128; d[x] = (257*u) >> 16; } } } } } else { int alpha_pos = desc->comp[plane_count].offset_plus1 - 1; int w = c->srcW; for (y = srcSliceY; y < srcSliceH; y++) { if (sixteen_bits) { const uint16_t *s = src[0] + srcStride[0] * y + 2*!alpha_pos; const uint16_t *a = src[0] + srcStride[0] * y + alpha_pos; uint16_t *d = dst[0] + dstStride[0] * y; if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) { for (x = 0; x < w; x++) { for (plane = 0; plane < plane_count; plane++) { unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<desc->comp[0].depth_minus1 : 0; int x_index = (plane_count + 1) * x; unsigned u = s[x_index + plane]*a[x_index] + target*(max-a[x_index]) + off; d[plane_count*x + plane] = av_clip((u + (u >> shift)) >> shift, 0, max); } } } else { for (x = 0; x < w; x++) { for (plane = 0; plane < plane_count; plane++) { unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<desc->comp[0].depth_minus1 : 0; int x_index = (plane_count + 1) * x; unsigned aswap =av_bswap16(a[x_index]); unsigned u = av_bswap16(s[x_index + plane])*aswap + target*(max-aswap) + off; d[plane_count*x + plane] = av_clip((u + (u >> shift)) >> shift, 0, max); } } } } else { const uint8_t *s = src[0] + srcStride[0] * y + !alpha_pos; const uint8_t *a = src[0] + srcStride[0] * y + alpha_pos; uint8_t *d = dst[0] + dstStride[0] * y; for (x = 0; x < w; x++) { for (plane = 0; plane < plane_count; plane++) { unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 128 : 0; int x_index = (plane_count + 1) * x; unsigned u = s[x_index + plane]*a[x_index] + target*(255-a[x_index]) + 128; d[plane_count*x + plane] = (257*u) >> 16; } } } } } return 0; }
false
FFmpeg
87100e828a59fa04dc892b45d8db2d690ce6a2a1
int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[]) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat); int nb_components = desc->nb_components; int plane, x, y; int plane_count = isGray(c->srcFormat) ? 1 : 3; int sixteen_bits = desc->comp[0].depth_minus1 >= 8; unsigned off = 1<<desc->comp[0].depth_minus1; unsigned shift = desc->comp[0].depth_minus1 + 1; unsigned max = (1<<shift) - 1; av_assert0(plane_count == nb_components - 1); if (desc->flags & AV_PIX_FMT_FLAG_PLANAR) { for (plane = 0; plane < plane_count; plane++) { int w = plane ? c->chrSrcW : c->srcW; int y_subsample = plane ? desc->log2_chroma_h: 0; for (y = srcSliceY >> y_subsample; y < FF_CEIL_RSHIFT(srcSliceH, y_subsample); y++) { if (sixteen_bits) { const uint16_t *s = src[plane ] + srcStride[plane] * y; const uint16_t *a = src[plane_count] + srcStride[plane_count] * y; uint16_t *d = dst[plane ] + dstStride[plane] * y; unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<desc->comp[0].depth_minus1 : 0; if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) { for (x = 0; x < w; x++) { unsigned u = s[x]*a[x] + target*(max-a[x]) + off; d[x] = av_clip((u + (u >> shift)) >> shift, 0, max); } } else { for (x = 0; x < w; x++) { unsigned aswap =av_bswap16(a[x]); unsigned u = av_bswap16(s[x])*aswap + target*(max-aswap) + off; d[x] = av_clip((u + (u >> shift)) >> shift, 0, max); } } } else { const uint8_t *s = src[plane ] + srcStride[plane] * y; const uint8_t *a = src[plane_count] + srcStride[plane_count] * y; uint8_t *d = dst[plane ] + dstStride[plane] * y; unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 128 : 0; for (x = 0; x < w; x++) { unsigned u = s[x]*a[x] + target*(255-a[x]) + 128; d[x] = (257*u) >> 16; } } } } } else { int alpha_pos = desc->comp[plane_count].offset_plus1 - 1; int w = c->srcW; for (y = srcSliceY; y < srcSliceH; y++) { if (sixteen_bits) { const uint16_t *s = src[0] + srcStride[0] * y + 2*!alpha_pos; const uint16_t *a = src[0] + srcStride[0] * y + alpha_pos; uint16_t *d = dst[0] + dstStride[0] * y; if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) { for (x = 0; x < w; x++) { for (plane = 0; plane < plane_count; plane++) { unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<desc->comp[0].depth_minus1 : 0; int x_index = (plane_count + 1) * x; unsigned u = s[x_index + plane]*a[x_index] + target*(max-a[x_index]) + off; d[plane_count*x + plane] = av_clip((u + (u >> shift)) >> shift, 0, max); } } } else { for (x = 0; x < w; x++) { for (plane = 0; plane < plane_count; plane++) { unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<desc->comp[0].depth_minus1 : 0; int x_index = (plane_count + 1) * x; unsigned aswap =av_bswap16(a[x_index]); unsigned u = av_bswap16(s[x_index + plane])*aswap + target*(max-aswap) + off; d[plane_count*x + plane] = av_clip((u + (u >> shift)) >> shift, 0, max); } } } } else { const uint8_t *s = src[0] + srcStride[0] * y + !alpha_pos; const uint8_t *a = src[0] + srcStride[0] * y + alpha_pos; uint8_t *d = dst[0] + dstStride[0] * y; for (x = 0; x < w; x++) { for (plane = 0; plane < plane_count; plane++) { unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 128 : 0; int x_index = (plane_count + 1) * x; unsigned u = s[x_index + plane]*a[x_index] + target*(255-a[x_index]) + 128; d[plane_count*x + plane] = (257*u) >> 16; } } } } } return 0; }
{ "code": [], "line_no": [] }
int FUNC_0(SwsContext *VAR_0, const uint8_t *VAR_1[], int VAR_2[], int VAR_3, int VAR_4, uint8_t *VAR_5[], int VAR_6[]) { const AVPixFmtDescriptor *VAR_7 = av_pix_fmt_desc_get(VAR_0->srcFormat); int VAR_8 = VAR_7->VAR_8; int VAR_9, VAR_10, VAR_11; int VAR_12 = isGray(VAR_0->srcFormat) ? 1 : 3; int VAR_13 = VAR_7->comp[0].depth_minus1 >= 8; unsigned VAR_14 = 1<<VAR_7->comp[0].depth_minus1; unsigned VAR_15 = VAR_7->comp[0].depth_minus1 + 1; unsigned VAR_16 = (1<<VAR_15) - 1; av_assert0(VAR_12 == VAR_8 - 1); if (VAR_7->flags & AV_PIX_FMT_FLAG_PLANAR) { for (VAR_9 = 0; VAR_9 < VAR_12; VAR_9++) { int VAR_25 = VAR_9 ? VAR_0->chrSrcW : VAR_0->srcW; int VAR_18 = VAR_9 ? VAR_7->log2_chroma_h: 0; for (VAR_11 = VAR_3 >> VAR_18; VAR_11 < FF_CEIL_RSHIFT(VAR_4, VAR_18); VAR_11++) { if (VAR_13) { const uint16_t *VAR_26 = VAR_1[VAR_9 ] + VAR_2[VAR_9] * VAR_11; const uint16_t *VAR_26 = VAR_1[VAR_12] + VAR_2[VAR_12] * VAR_11; uint16_t *d = VAR_5[VAR_9 ] + VAR_6[VAR_9] * VAR_11; unsigned VAR_26 = VAR_9 && !(VAR_7->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<VAR_7->comp[0].depth_minus1 : 0; if ((!isBE(VAR_0->srcFormat)) == !HAVE_BIGENDIAN) { for (VAR_10 = 0; VAR_10 < VAR_25; VAR_10++) { unsigned VAR_26 = VAR_26[VAR_10]*VAR_26[VAR_10] + VAR_26*(VAR_16-VAR_26[VAR_10]) + VAR_14; d[VAR_10] = av_clip((VAR_26 + (VAR_26 >> VAR_15)) >> VAR_15, 0, VAR_16); } } else { for (VAR_10 = 0; VAR_10 < VAR_25; VAR_10++) { unsigned VAR_26 =av_bswap16(VAR_26[VAR_10]); unsigned VAR_26 = av_bswap16(VAR_26[VAR_10])*VAR_26 + VAR_26*(VAR_16-VAR_26) + VAR_14; d[VAR_10] = av_clip((VAR_26 + (VAR_26 >> VAR_15)) >> VAR_15, 0, VAR_16); } } } else { const uint8_t *VAR_26 = VAR_1[VAR_9 ] + VAR_2[VAR_9] * VAR_11; const uint8_t *VAR_26 = VAR_1[VAR_12] + VAR_2[VAR_12] * VAR_11; uint8_t *d = VAR_5[VAR_9 ] + VAR_6[VAR_9] * VAR_11; unsigned VAR_26 = VAR_9 && !(VAR_7->flags & AV_PIX_FMT_FLAG_RGB) ? 128 : 0; for (VAR_10 = 0; VAR_10 < VAR_25; VAR_10++) { unsigned VAR_26 = VAR_26[VAR_10]*VAR_26[VAR_10] + VAR_26*(255-VAR_26[VAR_10]) + 128; d[VAR_10] = (257*VAR_26) >> 16; } } } } } else { int VAR_24 = VAR_7->comp[VAR_12].offset_plus1 - 1; int VAR_25 = VAR_0->srcW; for (VAR_11 = VAR_3; VAR_11 < VAR_4; VAR_11++) { if (VAR_13) { const uint16_t *VAR_26 = VAR_1[0] + VAR_2[0] * VAR_11 + 2*!VAR_24; const uint16_t *VAR_26 = VAR_1[0] + VAR_2[0] * VAR_11 + VAR_24; uint16_t *d = VAR_5[0] + VAR_6[0] * VAR_11; if ((!isBE(VAR_0->srcFormat)) == !HAVE_BIGENDIAN) { for (VAR_10 = 0; VAR_10 < VAR_25; VAR_10++) { for (VAR_9 = 0; VAR_9 < VAR_12; VAR_9++) { unsigned VAR_26 = VAR_9 && !(VAR_7->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<VAR_7->comp[0].depth_minus1 : 0; int VAR_26 = (VAR_12 + 1) * VAR_10; unsigned VAR_26 = VAR_26[VAR_26 + VAR_9]*VAR_26[VAR_26] + VAR_26*(VAR_16-VAR_26[VAR_26]) + VAR_14; d[VAR_12*VAR_10 + VAR_9] = av_clip((VAR_26 + (VAR_26 >> VAR_15)) >> VAR_15, 0, VAR_16); } } } else { for (VAR_10 = 0; VAR_10 < VAR_25; VAR_10++) { for (VAR_9 = 0; VAR_9 < VAR_12; VAR_9++) { unsigned VAR_26 = VAR_9 && !(VAR_7->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<VAR_7->comp[0].depth_minus1 : 0; int VAR_26 = (VAR_12 + 1) * VAR_10; unsigned VAR_26 =av_bswap16(VAR_26[VAR_26]); unsigned VAR_26 = av_bswap16(VAR_26[VAR_26 + VAR_9])*VAR_26 + VAR_26*(VAR_16-VAR_26) + VAR_14; d[VAR_12*VAR_10 + VAR_9] = av_clip((VAR_26 + (VAR_26 >> VAR_15)) >> VAR_15, 0, VAR_16); } } } } else { const uint8_t *VAR_26 = VAR_1[0] + VAR_2[0] * VAR_11 + !VAR_24; const uint8_t *VAR_26 = VAR_1[0] + VAR_2[0] * VAR_11 + VAR_24; uint8_t *d = VAR_5[0] + VAR_6[0] * VAR_11; for (VAR_10 = 0; VAR_10 < VAR_25; VAR_10++) { for (VAR_9 = 0; VAR_9 < VAR_12; VAR_9++) { unsigned VAR_26 = VAR_9 && !(VAR_7->flags & AV_PIX_FMT_FLAG_RGB) ? 128 : 0; int VAR_26 = (VAR_12 + 1) * VAR_10; unsigned VAR_26 = VAR_26[VAR_26 + VAR_9]*VAR_26[VAR_26] + VAR_26*(255-VAR_26[VAR_26]) + 128; d[VAR_12*VAR_10 + VAR_9] = (257*VAR_26) >> 16; } } } } } return 0; }
[ "int FUNC_0(SwsContext *VAR_0, const uint8_t *VAR_1[],\nint VAR_2[], int VAR_3, int VAR_4,\nuint8_t *VAR_5[], int VAR_6[])\n{", "const AVPixFmtDescriptor *VAR_7 = av_pix_fmt_desc_get(VAR_0->srcFormat);", "int VAR_8 = VAR_7->VAR_8;", "int VAR_9, VAR_10, VAR_11;", "int VAR_12 = isGray(VAR_0->srcFormat) ? 1 : 3;", "int VAR_13 = VAR_7->comp[0].depth_minus1 >= 8;", "unsigned VAR_14 = 1<<VAR_7->comp[0].depth_minus1;", "unsigned VAR_15 = VAR_7->comp[0].depth_minus1 + 1;", "unsigned VAR_16 = (1<<VAR_15) - 1;", "av_assert0(VAR_12 == VAR_8 - 1);", "if (VAR_7->flags & AV_PIX_FMT_FLAG_PLANAR) {", "for (VAR_9 = 0; VAR_9 < VAR_12; VAR_9++) {", "int VAR_25 = VAR_9 ? VAR_0->chrSrcW : VAR_0->srcW;", "int VAR_18 = VAR_9 ? VAR_7->log2_chroma_h: 0;", "for (VAR_11 = VAR_3 >> VAR_18; VAR_11 < FF_CEIL_RSHIFT(VAR_4, VAR_18); VAR_11++) {", "if (VAR_13) {", "const uint16_t *VAR_26 = VAR_1[VAR_9 ] + VAR_2[VAR_9] * VAR_11;", "const uint16_t *VAR_26 = VAR_1[VAR_12] + VAR_2[VAR_12] * VAR_11;", "uint16_t *d = VAR_5[VAR_9 ] + VAR_6[VAR_9] * VAR_11;", "unsigned VAR_26 = VAR_9 && !(VAR_7->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<VAR_7->comp[0].depth_minus1 : 0;", "if ((!isBE(VAR_0->srcFormat)) == !HAVE_BIGENDIAN) {", "for (VAR_10 = 0; VAR_10 < VAR_25; VAR_10++) {", "unsigned VAR_26 = VAR_26[VAR_10]*VAR_26[VAR_10] + VAR_26*(VAR_16-VAR_26[VAR_10]) + VAR_14;", "d[VAR_10] = av_clip((VAR_26 + (VAR_26 >> VAR_15)) >> VAR_15, 0, VAR_16);", "}", "} else {", "for (VAR_10 = 0; VAR_10 < VAR_25; VAR_10++) {", "unsigned VAR_26 =av_bswap16(VAR_26[VAR_10]);", "unsigned VAR_26 = av_bswap16(VAR_26[VAR_10])*VAR_26 + VAR_26*(VAR_16-VAR_26) + VAR_14;", "d[VAR_10] = av_clip((VAR_26 + (VAR_26 >> VAR_15)) >> VAR_15, 0, VAR_16);", "}", "}", "} else {", "const uint8_t *VAR_26 = VAR_1[VAR_9 ] + VAR_2[VAR_9] * VAR_11;", "const uint8_t *VAR_26 = VAR_1[VAR_12] + VAR_2[VAR_12] * VAR_11;", "uint8_t *d = VAR_5[VAR_9 ] + VAR_6[VAR_9] * VAR_11;", "unsigned VAR_26 = VAR_9 && !(VAR_7->flags & AV_PIX_FMT_FLAG_RGB) ? 128 : 0;", "for (VAR_10 = 0; VAR_10 < VAR_25; VAR_10++) {", "unsigned VAR_26 = VAR_26[VAR_10]*VAR_26[VAR_10] + VAR_26*(255-VAR_26[VAR_10]) + 128;", "d[VAR_10] = (257*VAR_26) >> 16;", "}", "}", "}", "}", "} else {", "int VAR_24 = VAR_7->comp[VAR_12].offset_plus1 - 1;", "int VAR_25 = VAR_0->srcW;", "for (VAR_11 = VAR_3; VAR_11 < VAR_4; VAR_11++) {", "if (VAR_13) {", "const uint16_t *VAR_26 = VAR_1[0] + VAR_2[0] * VAR_11 + 2*!VAR_24;", "const uint16_t *VAR_26 = VAR_1[0] + VAR_2[0] * VAR_11 + VAR_24;", "uint16_t *d = VAR_5[0] + VAR_6[0] * VAR_11;", "if ((!isBE(VAR_0->srcFormat)) == !HAVE_BIGENDIAN) {", "for (VAR_10 = 0; VAR_10 < VAR_25; VAR_10++) {", "for (VAR_9 = 0; VAR_9 < VAR_12; VAR_9++) {", "unsigned VAR_26 = VAR_9 && !(VAR_7->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<VAR_7->comp[0].depth_minus1 : 0;", "int VAR_26 = (VAR_12 + 1) * VAR_10;", "unsigned VAR_26 = VAR_26[VAR_26 + VAR_9]*VAR_26[VAR_26] + VAR_26*(VAR_16-VAR_26[VAR_26]) + VAR_14;", "d[VAR_12*VAR_10 + VAR_9] = av_clip((VAR_26 + (VAR_26 >> VAR_15)) >> VAR_15, 0, VAR_16);", "}", "}", "} else {", "for (VAR_10 = 0; VAR_10 < VAR_25; VAR_10++) {", "for (VAR_9 = 0; VAR_9 < VAR_12; VAR_9++) {", "unsigned VAR_26 = VAR_9 && !(VAR_7->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<VAR_7->comp[0].depth_minus1 : 0;", "int VAR_26 = (VAR_12 + 1) * VAR_10;", "unsigned VAR_26 =av_bswap16(VAR_26[VAR_26]);", "unsigned VAR_26 = av_bswap16(VAR_26[VAR_26 + VAR_9])*VAR_26 + VAR_26*(VAR_16-VAR_26) + VAR_14;", "d[VAR_12*VAR_10 + VAR_9] = av_clip((VAR_26 + (VAR_26 >> VAR_15)) >> VAR_15, 0, VAR_16);", "}", "}", "}", "} else {", "const uint8_t *VAR_26 = VAR_1[0] + VAR_2[0] * VAR_11 + !VAR_24;", "const uint8_t *VAR_26 = VAR_1[0] + VAR_2[0] * VAR_11 + VAR_24;", "uint8_t *d = VAR_5[0] + VAR_6[0] * VAR_11;", "for (VAR_10 = 0; VAR_10 < VAR_25; VAR_10++) {", "for (VAR_9 = 0; VAR_9 < VAR_12; VAR_9++) {", "unsigned VAR_26 = VAR_9 && !(VAR_7->flags & AV_PIX_FMT_FLAG_RGB) ? 128 : 0;", "int VAR_26 = (VAR_12 + 1) * VAR_10;", "unsigned VAR_26 = VAR_26[VAR_26 + VAR_9]*VAR_26[VAR_26] + VAR_26*(255-VAR_26[VAR_26]) + 128;", "d[VAR_12*VAR_10 + VAR_9] = (257*VAR_26) >> 16;", "}", "}", "}", "}", "}", "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 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 185 ], [ 187 ] ]
9,430
int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb) { AVStream *st; int tag; if (fc->nb_streams < 1) return 0; st = fc->streams[fc->nb_streams-1]; avio_rb32(pb); /* version + flags */ ff_mp4_read_descr(fc, pb, &tag); if (tag == MP4ESDescrTag) { ff_mp4_parse_es_descr(pb, NULL); } else avio_rb16(pb); /* ID */ ff_mp4_read_descr(fc, pb, &tag); if (tag == MP4DecConfigDescrTag) ff_mp4_read_dec_config_descr(fc, st, pb); return 0; }
false
FFmpeg
abf669479c0098ab5eb184a167e57a70aabb942b
int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb) { AVStream *st; int tag; if (fc->nb_streams < 1) return 0; st = fc->streams[fc->nb_streams-1]; avio_rb32(pb); ff_mp4_read_descr(fc, pb, &tag); if (tag == MP4ESDescrTag) { ff_mp4_parse_es_descr(pb, NULL); } else avio_rb16(pb); ff_mp4_read_descr(fc, pb, &tag); if (tag == MP4DecConfigDescrTag) ff_mp4_read_dec_config_descr(fc, st, pb); return 0; }
{ "code": [], "line_no": [] }
int FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1) { AVStream *st; int VAR_2; if (VAR_0->nb_streams < 1) return 0; st = VAR_0->streams[VAR_0->nb_streams-1]; avio_rb32(VAR_1); ff_mp4_read_descr(VAR_0, VAR_1, &VAR_2); if (VAR_2 == MP4ESDescrTag) { ff_mp4_parse_es_descr(VAR_1, NULL); } else avio_rb16(VAR_1); ff_mp4_read_descr(VAR_0, VAR_1, &VAR_2); if (VAR_2 == MP4DecConfigDescrTag) ff_mp4_read_dec_config_descr(VAR_0, st, VAR_1); return 0; }
[ "int FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1)\n{", "AVStream *st;", "int VAR_2;", "if (VAR_0->nb_streams < 1)\nreturn 0;", "st = VAR_0->streams[VAR_0->nb_streams-1];", "avio_rb32(VAR_1);", "ff_mp4_read_descr(VAR_0, VAR_1, &VAR_2);", "if (VAR_2 == MP4ESDescrTag) {", "ff_mp4_parse_es_descr(VAR_1, NULL);", "} else", "avio_rb16(VAR_1);", "ff_mp4_read_descr(VAR_0, VAR_1, &VAR_2);", "if (VAR_2 == MP4DecConfigDescrTag)\nff_mp4_read_dec_config_descr(VAR_0, st, VAR_1);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11, 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35, 37 ], [ 39 ], [ 41 ] ]
9,431
void ff_atrac_iqmf(float *inlo, float *inhi, unsigned int nIn, float *pOut, float *delayBuf, float *temp) { int i, j; float *p1, *p3; memcpy(temp, delayBuf, 46*sizeof(float)); p3 = temp + 46; /* loop1 */ for(i=0; i<nIn; i+=2){ p3[2*i+0] = inlo[i ] + inhi[i ]; p3[2*i+1] = inlo[i ] - inhi[i ]; p3[2*i+2] = inlo[i+1] + inhi[i+1]; p3[2*i+3] = inlo[i+1] - inhi[i+1]; } /* loop2 */ p1 = temp; for (j = nIn; j != 0; j--) { float s1 = 0.0; float s2 = 0.0; for (i = 0; i < 48; i += 2) { s1 += p1[i] * qmf_window[i]; s2 += p1[i+1] * qmf_window[i+1]; } pOut[0] = s2; pOut[1] = s1; p1 += 2; pOut += 2; } /* Update the delay buffer. */ memcpy(delayBuf, temp + nIn*2, 46*sizeof(float)); }
false
FFmpeg
746cb9bc53f71ed8d67827c4518deecc4ba2a75d
void ff_atrac_iqmf(float *inlo, float *inhi, unsigned int nIn, float *pOut, float *delayBuf, float *temp) { int i, j; float *p1, *p3; memcpy(temp, delayBuf, 46*sizeof(float)); p3 = temp + 46; for(i=0; i<nIn; i+=2){ p3[2*i+0] = inlo[i ] + inhi[i ]; p3[2*i+1] = inlo[i ] - inhi[i ]; p3[2*i+2] = inlo[i+1] + inhi[i+1]; p3[2*i+3] = inlo[i+1] - inhi[i+1]; } p1 = temp; for (j = nIn; j != 0; j--) { float s1 = 0.0; float s2 = 0.0; for (i = 0; i < 48; i += 2) { s1 += p1[i] * qmf_window[i]; s2 += p1[i+1] * qmf_window[i+1]; } pOut[0] = s2; pOut[1] = s1; p1 += 2; pOut += 2; } memcpy(delayBuf, temp + nIn*2, 46*sizeof(float)); }
{ "code": [], "line_no": [] }
void FUNC_0(float *VAR_0, float *VAR_1, unsigned int VAR_2, float *VAR_3, float *VAR_4, float *VAR_5) { int VAR_6, VAR_7; float *VAR_8, *VAR_9; memcpy(VAR_5, VAR_4, 46*sizeof(float)); VAR_9 = VAR_5 + 46; for(VAR_6=0; VAR_6<VAR_2; VAR_6+=2){ VAR_9[2*VAR_6+0] = VAR_0[VAR_6 ] + VAR_1[VAR_6 ]; VAR_9[2*VAR_6+1] = VAR_0[VAR_6 ] - VAR_1[VAR_6 ]; VAR_9[2*VAR_6+2] = VAR_0[VAR_6+1] + VAR_1[VAR_6+1]; VAR_9[2*VAR_6+3] = VAR_0[VAR_6+1] - VAR_1[VAR_6+1]; } VAR_8 = VAR_5; for (VAR_7 = VAR_2; VAR_7 != 0; VAR_7--) { float VAR_10 = 0.0; float VAR_11 = 0.0; for (VAR_6 = 0; VAR_6 < 48; VAR_6 += 2) { VAR_10 += VAR_8[VAR_6] * qmf_window[VAR_6]; VAR_11 += VAR_8[VAR_6+1] * qmf_window[VAR_6+1]; } VAR_3[0] = VAR_11; VAR_3[1] = VAR_10; VAR_8 += 2; VAR_3 += 2; } memcpy(VAR_4, VAR_5 + VAR_2*2, 46*sizeof(float)); }
[ "void FUNC_0(float *VAR_0, float *VAR_1, unsigned int VAR_2, float *VAR_3, float *VAR_4, float *VAR_5)\n{", "int VAR_6, VAR_7;", "float *VAR_8, *VAR_9;", "memcpy(VAR_5, VAR_4, 46*sizeof(float));", "VAR_9 = VAR_5 + 46;", "for(VAR_6=0; VAR_6<VAR_2; VAR_6+=2){", "VAR_9[2*VAR_6+0] = VAR_0[VAR_6 ] + VAR_1[VAR_6 ];", "VAR_9[2*VAR_6+1] = VAR_0[VAR_6 ] - VAR_1[VAR_6 ];", "VAR_9[2*VAR_6+2] = VAR_0[VAR_6+1] + VAR_1[VAR_6+1];", "VAR_9[2*VAR_6+3] = VAR_0[VAR_6+1] - VAR_1[VAR_6+1];", "}", "VAR_8 = VAR_5;", "for (VAR_7 = VAR_2; VAR_7 != 0; VAR_7--) {", "float VAR_10 = 0.0;", "float VAR_11 = 0.0;", "for (VAR_6 = 0; VAR_6 < 48; VAR_6 += 2) {", "VAR_10 += VAR_8[VAR_6] * qmf_window[VAR_6];", "VAR_11 += VAR_8[VAR_6+1] * qmf_window[VAR_6+1];", "}", "VAR_3[0] = VAR_11;", "VAR_3[1] = VAR_10;", "VAR_8 += 2;", "VAR_3 += 2;", "}", "memcpy(VAR_4, VAR_5 + VAR_2*2, 46*sizeof(float));", "}" ]
[ 0, 0, 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 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 63 ], [ 65 ], [ 67 ], [ 73 ], [ 75 ] ]
9,432
static void uc32_cpu_initfn(Object *obj) { CPUState *cs = CPU(obj); UniCore32CPU *cpu = UNICORE32_CPU(obj); CPUUniCore32State *env = &cpu->env; static bool inited; cs->env_ptr = env; cpu_exec_init(cs, &error_abort); #ifdef CONFIG_USER_ONLY env->uncached_asr = ASR_MODE_USER; env->regs[31] = 0; #else env->uncached_asr = ASR_MODE_PRIV; env->regs[31] = 0x03000000; #endif tlb_flush(cs, 1); if (tcg_enabled() && !inited) { inited = true; uc32_translate_init(); } }
true
qemu
ce5b1bbf624b977a55ff7f85bb3871682d03baff
static void uc32_cpu_initfn(Object *obj) { CPUState *cs = CPU(obj); UniCore32CPU *cpu = UNICORE32_CPU(obj); CPUUniCore32State *env = &cpu->env; static bool inited; cs->env_ptr = env; cpu_exec_init(cs, &error_abort); #ifdef CONFIG_USER_ONLY env->uncached_asr = ASR_MODE_USER; env->regs[31] = 0; #else env->uncached_asr = ASR_MODE_PRIV; env->regs[31] = 0x03000000; #endif tlb_flush(cs, 1); if (tcg_enabled() && !inited) { inited = true; uc32_translate_init(); } }
{ "code": [ " cpu_exec_init(cs, &error_abort);", " cpu_exec_init(cs, &error_abort);", " cpu_exec_init(cs, &error_abort);", " cpu_exec_init(cs, &error_abort);", " cpu_exec_init(cs, &error_abort);", " cpu_exec_init(cs, &error_abort);", " cpu_exec_init(cs, &error_abort);", " cpu_exec_init(cs, &error_abort);", " cpu_exec_init(cs, &error_abort);", " cpu_exec_init(cs, &error_abort);", " cpu_exec_init(cs, &error_abort);", " cpu_exec_init(cs, &error_abort);", " cpu_exec_init(cs, &error_abort);", " cpu_exec_init(cs, &error_abort);", " cpu_exec_init(cs, &error_abort);", " cpu_exec_init(cs, &error_abort);" ], "line_no": [ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17 ] }
static void FUNC_0(Object *VAR_0) { CPUState *cs = CPU(VAR_0); UniCore32CPU *cpu = UNICORE32_CPU(VAR_0); CPUUniCore32State *env = &cpu->env; static bool VAR_1; cs->env_ptr = env; cpu_exec_init(cs, &error_abort); #ifdef CONFIG_USER_ONLY env->uncached_asr = ASR_MODE_USER; env->regs[31] = 0; #else env->uncached_asr = ASR_MODE_PRIV; env->regs[31] = 0x03000000; #endif tlb_flush(cs, 1); if (tcg_enabled() && !VAR_1) { VAR_1 = true; uc32_translate_init(); } }
[ "static void FUNC_0(Object *VAR_0)\n{", "CPUState *cs = CPU(VAR_0);", "UniCore32CPU *cpu = UNICORE32_CPU(VAR_0);", "CPUUniCore32State *env = &cpu->env;", "static bool VAR_1;", "cs->env_ptr = env;", "cpu_exec_init(cs, &error_abort);", "#ifdef CONFIG_USER_ONLY\nenv->uncached_asr = ASR_MODE_USER;", "env->regs[31] = 0;", "#else\nenv->uncached_asr = ASR_MODE_PRIV;", "env->regs[31] = 0x03000000;", "#endif\ntlb_flush(cs, 1);", "if (tcg_enabled() && !VAR_1) {", "VAR_1 = true;", "uc32_translate_init();", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 21, 23 ], [ 25 ], [ 27, 29 ], [ 31 ], [ 33, 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ] ]
9,433
static int read_rle_sgi(unsigned char* out_buf, const uint8_t *in_buf, const uint8_t *in_end, SgiState* s) { uint8_t *dest_row; unsigned int len = s->height * s->depth * 4; const uint8_t *start_table = in_buf; unsigned int y, z; unsigned int start_offset; /* size of RLE offset and length tables */ if(len * 2 > in_end - in_buf) { return AVERROR_INVALIDDATA; } in_buf -= SGI_HEADER_SIZE; for (z = 0; z < s->depth; z++) { dest_row = out_buf; for (y = 0; y < s->height; y++) { dest_row -= s->linesize; start_offset = bytestream_get_be32(&start_table); if(start_offset > in_end - in_buf) { return AVERROR_INVALIDDATA; } if (expand_rle_row(in_buf + start_offset, in_end, dest_row + z, dest_row + FFABS(s->linesize), s->depth) != s->width) return AVERROR_INVALIDDATA; } } return 0; }
true
FFmpeg
4cd0bdae9a62d1f0366e60603222762af31e5289
static int read_rle_sgi(unsigned char* out_buf, const uint8_t *in_buf, const uint8_t *in_end, SgiState* s) { uint8_t *dest_row; unsigned int len = s->height * s->depth * 4; const uint8_t *start_table = in_buf; unsigned int y, z; unsigned int start_offset; if(len * 2 > in_end - in_buf) { return AVERROR_INVALIDDATA; } in_buf -= SGI_HEADER_SIZE; for (z = 0; z < s->depth; z++) { dest_row = out_buf; for (y = 0; y < s->height; y++) { dest_row -= s->linesize; start_offset = bytestream_get_be32(&start_table); if(start_offset > in_end - in_buf) { return AVERROR_INVALIDDATA; } if (expand_rle_row(in_buf + start_offset, in_end, dest_row + z, dest_row + FFABS(s->linesize), s->depth) != s->width) return AVERROR_INVALIDDATA; } } return 0; }
{ "code": [ "static int read_rle_sgi(unsigned char* out_buf, const uint8_t *in_buf,", " const uint8_t *in_end, SgiState* s)", " const uint8_t *start_table = in_buf;", " if(len * 2 > in_end - in_buf) {", " in_buf -= SGI_HEADER_SIZE;", " start_offset = bytestream_get_be32(&start_table);", " if(start_offset > in_end - in_buf) {", " if (expand_rle_row(in_buf + start_offset, in_end, dest_row + z,", " dest_row + FFABS(s->linesize), s->depth) != s->width)", " return AVERROR_INVALIDDATA;" ], "line_no": [ 1, 3, 11, 21, 29, 39, 41, 47, 49, 43 ] }
static int FUNC_0(unsigned char* VAR_0, const uint8_t *VAR_1, const uint8_t *VAR_2, SgiState* VAR_3) { uint8_t *dest_row; unsigned int VAR_4 = VAR_3->height * VAR_3->depth * 4; const uint8_t *VAR_5 = VAR_1; unsigned int VAR_6, VAR_7; unsigned int VAR_8; if(VAR_4 * 2 > VAR_2 - VAR_1) { return AVERROR_INVALIDDATA; } VAR_1 -= SGI_HEADER_SIZE; for (VAR_7 = 0; VAR_7 < VAR_3->depth; VAR_7++) { dest_row = VAR_0; for (VAR_6 = 0; VAR_6 < VAR_3->height; VAR_6++) { dest_row -= VAR_3->linesize; VAR_8 = bytestream_get_be32(&VAR_5); if(VAR_8 > VAR_2 - VAR_1) { return AVERROR_INVALIDDATA; } if (expand_rle_row(VAR_1 + VAR_8, VAR_2, dest_row + VAR_7, dest_row + FFABS(VAR_3->linesize), VAR_3->depth) != VAR_3->width) return AVERROR_INVALIDDATA; } } return 0; }
[ "static int FUNC_0(unsigned char* VAR_0, const uint8_t *VAR_1,\nconst uint8_t *VAR_2, SgiState* VAR_3)\n{", "uint8_t *dest_row;", "unsigned int VAR_4 = VAR_3->height * VAR_3->depth * 4;", "const uint8_t *VAR_5 = VAR_1;", "unsigned int VAR_6, VAR_7;", "unsigned int VAR_8;", "if(VAR_4 * 2 > VAR_2 - VAR_1) {", "return AVERROR_INVALIDDATA;", "}", "VAR_1 -= SGI_HEADER_SIZE;", "for (VAR_7 = 0; VAR_7 < VAR_3->depth; VAR_7++) {", "dest_row = VAR_0;", "for (VAR_6 = 0; VAR_6 < VAR_3->height; VAR_6++) {", "dest_row -= VAR_3->linesize;", "VAR_8 = bytestream_get_be32(&VAR_5);", "if(VAR_8 > VAR_2 - VAR_1) {", "return AVERROR_INVALIDDATA;", "}", "if (expand_rle_row(VAR_1 + VAR_8, VAR_2, dest_row + VAR_7,\ndest_row + FFABS(VAR_3->linesize), VAR_3->depth) != VAR_3->width)\nreturn AVERROR_INVALIDDATA;", "}", "}", "return 0;", "}" ]
[ 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47, 49, 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ] ]
9,436
static inline void RENAME(rgb15to16)(const uint8_t *src,uint8_t *dst,long src_size) { register const uint8_t* s=src; register uint8_t* d=dst; register const uint8_t *end; const uint8_t *mm_end; end = s + src_size; #ifdef HAVE_MMX __asm __volatile(PREFETCH" %0"::"m"(*s)); __asm __volatile("movq %0, %%mm4"::"m"(mask15s)); mm_end = end - 15; while(s<mm_end) { __asm __volatile( PREFETCH" 32%1\n\t" "movq %1, %%mm0\n\t" "movq 8%1, %%mm2\n\t" "movq %%mm0, %%mm1\n\t" "movq %%mm2, %%mm3\n\t" "pand %%mm4, %%mm0\n\t" "pand %%mm4, %%mm2\n\t" "paddw %%mm1, %%mm0\n\t" "paddw %%mm3, %%mm2\n\t" MOVNTQ" %%mm0, %0\n\t" MOVNTQ" %%mm2, 8%0" :"=m"(*d) :"m"(*s) ); d+=16; s+=16; } __asm __volatile(SFENCE:::"memory"); __asm __volatile(EMMS:::"memory"); #endif mm_end = end - 3; while(s < mm_end) { register unsigned x= *((uint32_t *)s); *((uint32_t *)d) = (x&0x7FFF7FFF) + (x&0x7FE07FE0); d+=4; s+=4; } if(s < end) { register unsigned short x= *((uint16_t *)s); *((uint16_t *)d) = (x&0x7FFF) + (x&0x7FE0); } }
true
FFmpeg
6e42e6c4b410dbef8b593c2d796a5dad95f89ee4
static inline void RENAME(rgb15to16)(const uint8_t *src,uint8_t *dst,long src_size) { register const uint8_t* s=src; register uint8_t* d=dst; register const uint8_t *end; const uint8_t *mm_end; end = s + src_size; #ifdef HAVE_MMX __asm __volatile(PREFETCH" %0"::"m"(*s)); __asm __volatile("movq %0, %%mm4"::"m"(mask15s)); mm_end = end - 15; while(s<mm_end) { __asm __volatile( PREFETCH" 32%1\n\t" "movq %1, %%mm0\n\t" "movq 8%1, %%mm2\n\t" "movq %%mm0, %%mm1\n\t" "movq %%mm2, %%mm3\n\t" "pand %%mm4, %%mm0\n\t" "pand %%mm4, %%mm2\n\t" "paddw %%mm1, %%mm0\n\t" "paddw %%mm3, %%mm2\n\t" MOVNTQ" %%mm0, %0\n\t" MOVNTQ" %%mm2, 8%0" :"=m"(*d) :"m"(*s) ); d+=16; s+=16; } __asm __volatile(SFENCE:::"memory"); __asm __volatile(EMMS:::"memory"); #endif mm_end = end - 3; while(s < mm_end) { register unsigned x= *((uint32_t *)s); *((uint32_t *)d) = (x&0x7FFF7FFF) + (x&0x7FE07FE0); d+=4; s+=4; } if(s < end) { register unsigned short x= *((uint16_t *)s); *((uint16_t *)d) = (x&0x7FFF) + (x&0x7FE0); } }
{ "code": [ "#ifdef HAVE_MMX", " const uint8_t *mm_end;", "#endif", " end = s + src_size;", "#ifdef HAVE_MMX", " __asm __volatile(SFENCE:::\"memory\");", " __asm __volatile(EMMS:::\"memory\");", "#endif", "#endif", " const uint8_t *mm_end;", " end = s + src_size;", " __asm __volatile(SFENCE:::\"memory\");", " __asm __volatile(EMMS:::\"memory\");", "#endif", " register const uint8_t* s=src;", " register uint8_t* d=dst;", " register const uint8_t *end;", " const uint8_t *mm_end;", " end = s + src_size;", " __asm __volatile(PREFETCH\"\t%0\"::\"m\"(*s));", " __asm __volatile(\"movq\t%0, %%mm4\"::\"m\"(mask15s));", " mm_end = end - 15;", " while(s<mm_end)", "\t__asm __volatile(", "\t\tPREFETCH\"\t32%1\\n\\t\"", "\t\t\"movq\t%1, %%mm0\\n\\t\"", "\t\t\"movq\t8%1, %%mm2\\n\\t\"", "\t\t\"movq\t%%mm0, %%mm1\\n\\t\"", "\t\t\"movq\t%%mm2, %%mm3\\n\\t\"", "\t\t\"pand\t%%mm4, %%mm0\\n\\t\"", "\t\t\"pand\t%%mm4, %%mm2\\n\\t\"", "\t\t\"paddw\t%%mm1, %%mm0\\n\\t\"", "\t\t\"paddw\t%%mm3, %%mm2\\n\\t\"", "\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"", "\t\tMOVNTQ\"\t%%mm2, 8%0\"", "\t\t:\"=m\"(*d)", "\t\t:\"m\"(*s)", "\t\t);", "\td+=16;", "\ts+=16;", " __asm __volatile(SFENCE:::\"memory\");", " __asm __volatile(EMMS:::\"memory\");", " while(s < mm_end)", "\tregister unsigned x= *((uint32_t *)s);", "\t*((uint32_t *)d) = (x&0x7FFF7FFF) + (x&0x7FE07FE0);", "\td+=4;", "\ts+=4;", " if(s < end)", "\tregister unsigned short x= *((uint16_t *)s);", "\t*((uint16_t *)d) = (x&0x7FFF) + (x&0x7FE0);", " register const uint8_t* s=src;", " register uint8_t* d=dst;", " register const uint8_t *end;", " const uint8_t *mm_end;", " end = s + src_size;", " __asm __volatile(PREFETCH\"\t%0\"::\"m\"(*s));", " mm_end = end - 15;", " while(s<mm_end)", "\t__asm __volatile(", "\t\tPREFETCH\"\t32%1\\n\\t\"", "\t\t\"movq\t%1, %%mm0\\n\\t\"", "\t\t\"movq\t8%1, %%mm2\\n\\t\"", "\t\t\"movq\t%%mm0, %%mm1\\n\\t\"", "\t\t\"movq\t%%mm2, %%mm3\\n\\t\"", "\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"", "\t\tMOVNTQ\"\t%%mm2, 8%0\"", "\t\t:\"=m\"(*d)", "\t\t:\"m\"(*s)", "\t\t);", "\td+=16;", "\ts+=16;", " __asm __volatile(SFENCE:::\"memory\");", " __asm __volatile(EMMS:::\"memory\");", " while(s < mm_end)", "\ts+=4;", "\td+=4;", " if(s < end)", "\t__asm __volatile(", "\t\t\"movq\t%%mm0, %%mm1\\n\\t\"", "\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"", "#endif", "#endif", "\t__asm __volatile(", "\t\t\"movq\t%%mm0, %%mm1\\n\\t\"", "\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"", "#endif", "\t__asm __volatile(", "\t\t\"movq\t%%mm0, %%mm1\\n\\t\"", "\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"", "#endif", "#endif", "\t__asm __volatile(", "\t\t\"movq\t%%mm0, %%mm1\\n\\t\"", "\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"", "#endif", "\t__asm __volatile(", "\t\t\"movq\t%%mm0, %%mm1\\n\\t\"", "\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"", "#endif", "\t__asm __volatile(", "\t\t\"movq\t%%mm0, %%mm1\\n\\t\"", "\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"", "#endif", "\t__asm __volatile(", "\t\t\"movq\t%%mm0, %%mm1\\n\\t\"", "\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"", "#endif", "\t__asm __volatile(", "\t\t\"movq\t%%mm0, %%mm1\\n\\t\"", "\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"", "#endif", "\t\t\"movq\t%1, %%mm0\\n\\t\"", "\t\t\"movq\t8%1, %%mm2\\n\\t\"", "\t\t:\"=m\"(*d)", "\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"", "\t\t:\"=m\"(*d)", "#endif", "\t\t\"movq\t%1, %%mm0\\n\\t\"", "\t\t\"movq\t8%1, %%mm2\\n\\t\"", "\t\t:\"=m\"(*d)", "\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"", "\t\t:\"=m\"(*d)", "#endif", "\t\t\"movq\t%1, %%mm0\\n\\t\"", "\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"", "\t\t:\"=m\"(*d)", "#endif", "\t\t\"movq\t%1, %%mm0\\n\\t\"", "\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"", "\t\t:\"=m\"(*d)", "#endif", "\t__asm __volatile(", "#endif", "#endif", "\t\t);", "#endif", "#endif", "#endif", "\t\t);", "#endif", "#endif", "#endif", "\t\t);", "\t\t);", "#endif", "#endif", "\t\t);", "#endif", "\t\t);", "\t\t);", "#endif", "#endif", "#endif", "#endif", "#endif", "#endif", "#endif", "\t\t);", "#endif", "\t\t);", "\t\t);", "#endif", "\t\t);", "#endif", "\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"", "#endif", "\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"", "#endif", "\t\t);", "#endif", "\t\t);" ], "line_no": [ 15, 11, 67, 13, 15, 63, 65, 67, 67, 11, 13, 63, 65, 67, 5, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 63, 65, 71, 75, 77, 79, 81, 85, 89, 91, 5, 7, 9, 11, 13, 17, 21, 23, 27, 29, 31, 33, 35, 37, 47, 49, 51, 53, 55, 57, 59, 63, 65, 71, 81, 79, 85, 27, 35, 47, 67, 67, 27, 35, 47, 67, 27, 35, 47, 67, 67, 27, 35, 47, 67, 27, 35, 47, 67, 27, 35, 47, 67, 27, 35, 47, 67, 27, 35, 47, 67, 31, 33, 51, 47, 51, 67, 31, 33, 51, 47, 51, 67, 31, 47, 51, 67, 31, 47, 51, 67, 27, 67, 67, 55, 67, 67, 67, 55, 67, 67, 67, 55, 55, 67, 67, 55, 67, 55, 55, 67, 67, 67, 67, 67, 67, 67, 55, 67, 55, 55, 67, 55, 67, 47, 67, 47, 67, 55, 67, 55 ] }
static inline void FUNC_0(rgb15to16)(const uint8_t *src,uint8_t *dst,long src_size) { register const uint8_t* VAR_0=src; register uint8_t* VAR_1=dst; register const uint8_t *VAR_2; const uint8_t *VAR_3; VAR_2 = VAR_0 + src_size; #ifdef HAVE_MMX __asm __volatile(PREFETCH" %0"::"m"(*VAR_0)); __asm __volatile("movq %0, %%mm4"::"m"(mask15s)); VAR_3 = VAR_2 - 15; while(VAR_0<VAR_3) { __asm __volatile( PREFETCH" 32%1\n\t" "movq %1, %%mm0\n\t" "movq 8%1, %%mm2\n\t" "movq %%mm0, %%mm1\n\t" "movq %%mm2, %%mm3\n\t" "pand %%mm4, %%mm0\n\t" "pand %%mm4, %%mm2\n\t" "paddw %%mm1, %%mm0\n\t" "paddw %%mm3, %%mm2\n\t" MOVNTQ" %%mm0, %0\n\t" MOVNTQ" %%mm2, 8%0" :"=m"(*VAR_1) :"m"(*VAR_0) ); VAR_1+=16; VAR_0+=16; } __asm __volatile(SFENCE:::"memory"); __asm __volatile(EMMS:::"memory"); #endif VAR_3 = VAR_2 - 3; while(VAR_0 < VAR_3) { register unsigned VAR_5= *((uint32_t *)VAR_0); *((uint32_t *)VAR_1) = (VAR_5&0x7FFF7FFF) + (VAR_5&0x7FE07FE0); VAR_1+=4; VAR_0+=4; } if(VAR_0 < VAR_2) { register unsigned short VAR_5= *((uint16_t *)VAR_0); *((uint16_t *)VAR_1) = (VAR_5&0x7FFF) + (VAR_5&0x7FE0); } }
[ "static inline void FUNC_0(rgb15to16)(const uint8_t *src,uint8_t *dst,long src_size)\n{", "register const uint8_t* VAR_0=src;", "register uint8_t* VAR_1=dst;", "register const uint8_t *VAR_2;", "const uint8_t *VAR_3;", "VAR_2 = VAR_0 + src_size;", "#ifdef HAVE_MMX\n__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*VAR_0));", "__asm __volatile(\"movq\t%0, %%mm4\"::\"m\"(mask15s));", "VAR_3 = VAR_2 - 15;", "while(VAR_0<VAR_3)\n{", "__asm __volatile(\nPREFETCH\"\t32%1\\n\\t\"\n\"movq\t%1, %%mm0\\n\\t\"\n\"movq\t8%1, %%mm2\\n\\t\"\n\"movq\t%%mm0, %%mm1\\n\\t\"\n\"movq\t%%mm2, %%mm3\\n\\t\"\n\"pand\t%%mm4, %%mm0\\n\\t\"\n\"pand\t%%mm4, %%mm2\\n\\t\"\n\"paddw\t%%mm1, %%mm0\\n\\t\"\n\"paddw\t%%mm3, %%mm2\\n\\t\"\nMOVNTQ\"\t%%mm0, %0\\n\\t\"\nMOVNTQ\"\t%%mm2, 8%0\"\n:\"=m\"(*VAR_1)\n:\"m\"(*VAR_0)\n);", "VAR_1+=16;", "VAR_0+=16;", "}", "__asm __volatile(SFENCE:::\"memory\");", "__asm __volatile(EMMS:::\"memory\");", "#endif\nVAR_3 = VAR_2 - 3;", "while(VAR_0 < VAR_3)\n{", "register unsigned VAR_5= *((uint32_t *)VAR_0);", "*((uint32_t *)VAR_1) = (VAR_5&0x7FFF7FFF) + (VAR_5&0x7FE07FE0);", "VAR_1+=4;", "VAR_0+=4;", "}", "if(VAR_0 < VAR_2)\n{", "register unsigned short VAR_5= *((uint16_t *)VAR_0);", "*((uint16_t *)VAR_1) = (VAR_5&0x7FFF) + (VAR_5&0x7FE0);", "}", "}" ]
[ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 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 ] ]
9,438
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options) { AVFormatContext *s = *ps; int ret = 0; AVFormatParameters ap = { 0 }; AVDictionary *tmp = NULL; if (!s && !(s = avformat_alloc_context())) return AVERROR(ENOMEM); if (fmt) s->iformat = fmt; if (options) av_dict_copy(&tmp, *options, 0); if ((ret = av_opt_set_dict(s, &tmp)) < 0) goto fail; if ((ret = init_input(s, filename)) < 0) goto fail; /* check filename in case an image number is expected */ if (s->iformat->flags & AVFMT_NEEDNUMBER) { if (!av_filename_number_test(filename)) { ret = AVERROR(EINVAL); goto fail; } } s->duration = s->start_time = AV_NOPTS_VALUE; av_strlcpy(s->filename, filename, sizeof(s->filename)); /* allocate private data */ if (s->iformat->priv_data_size > 0) { if (!(s->priv_data = av_mallocz(s->iformat->priv_data_size))) { ret = AVERROR(ENOMEM); goto fail; } if (s->iformat->priv_class) { *(const AVClass**)s->priv_data = s->iformat->priv_class; av_opt_set_defaults(s->priv_data); if ((ret = av_opt_set_dict(s->priv_data, &tmp)) < 0) goto fail; } } /* e.g. AVFMT_NOFILE formats will not have a AVIOContext */ if (s->pb) ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC); if (s->iformat->read_header) if ((ret = s->iformat->read_header(s, &ap)) < 0) goto fail; if (s->pb && !s->data_offset) s->data_offset = avio_tell(s->pb); s->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE; if (options) { av_dict_free(options); *options = tmp; } *ps = s; return 0; fail: av_dict_free(&tmp); if (s->pb && !(s->flags & AVFMT_FLAG_CUSTOM_IO)) avio_close(s->pb); avformat_free_context(s); *ps = NULL; return ret; }
true
FFmpeg
5a819c5e23b46bb03a9862790452ff829ea1e898
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options) { AVFormatContext *s = *ps; int ret = 0; AVFormatParameters ap = { 0 }; AVDictionary *tmp = NULL; if (!s && !(s = avformat_alloc_context())) return AVERROR(ENOMEM); if (fmt) s->iformat = fmt; if (options) av_dict_copy(&tmp, *options, 0); if ((ret = av_opt_set_dict(s, &tmp)) < 0) goto fail; if ((ret = init_input(s, filename)) < 0) goto fail; if (s->iformat->flags & AVFMT_NEEDNUMBER) { if (!av_filename_number_test(filename)) { ret = AVERROR(EINVAL); goto fail; } } s->duration = s->start_time = AV_NOPTS_VALUE; av_strlcpy(s->filename, filename, sizeof(s->filename)); if (s->iformat->priv_data_size > 0) { if (!(s->priv_data = av_mallocz(s->iformat->priv_data_size))) { ret = AVERROR(ENOMEM); goto fail; } if (s->iformat->priv_class) { *(const AVClass**)s->priv_data = s->iformat->priv_class; av_opt_set_defaults(s->priv_data); if ((ret = av_opt_set_dict(s->priv_data, &tmp)) < 0) goto fail; } } if (s->pb) ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC); if (s->iformat->read_header) if ((ret = s->iformat->read_header(s, &ap)) < 0) goto fail; if (s->pb && !s->data_offset) s->data_offset = avio_tell(s->pb); s->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE; if (options) { av_dict_free(options); *options = tmp; } *ps = s; return 0; fail: av_dict_free(&tmp); if (s->pb && !(s->flags & AVFMT_FLAG_CUSTOM_IO)) avio_close(s->pb); avformat_free_context(s); *ps = NULL; return ret; }
{ "code": [ " AVFormatParameters ap = { 0 };" ], "line_no": [ 9 ] }
int FUNC_0(AVFormatContext **VAR_0, const char *VAR_1, AVInputFormat *VAR_2, AVDictionary **VAR_3) { AVFormatContext *s = *VAR_0; int VAR_4 = 0; AVFormatParameters ap = { 0 }; AVDictionary *tmp = NULL; if (!s && !(s = avformat_alloc_context())) return AVERROR(ENOMEM); if (VAR_2) s->iformat = VAR_2; if (VAR_3) av_dict_copy(&tmp, *VAR_3, 0); if ((VAR_4 = av_opt_set_dict(s, &tmp)) < 0) goto fail; if ((VAR_4 = init_input(s, VAR_1)) < 0) goto fail; if (s->iformat->flags & AVFMT_NEEDNUMBER) { if (!av_filename_number_test(VAR_1)) { VAR_4 = AVERROR(EINVAL); goto fail; } } s->duration = s->start_time = AV_NOPTS_VALUE; av_strlcpy(s->VAR_1, VAR_1, sizeof(s->VAR_1)); if (s->iformat->priv_data_size > 0) { if (!(s->priv_data = av_mallocz(s->iformat->priv_data_size))) { VAR_4 = AVERROR(ENOMEM); goto fail; } if (s->iformat->priv_class) { *(const AVClass**)s->priv_data = s->iformat->priv_class; av_opt_set_defaults(s->priv_data); if ((VAR_4 = av_opt_set_dict(s->priv_data, &tmp)) < 0) goto fail; } } if (s->pb) ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC); if (s->iformat->read_header) if ((VAR_4 = s->iformat->read_header(s, &ap)) < 0) goto fail; if (s->pb && !s->data_offset) s->data_offset = avio_tell(s->pb); s->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE; if (VAR_3) { av_dict_free(VAR_3); *VAR_3 = tmp; } *VAR_0 = s; return 0; fail: av_dict_free(&tmp); if (s->pb && !(s->flags & AVFMT_FLAG_CUSTOM_IO)) avio_close(s->pb); avformat_free_context(s); *VAR_0 = NULL; return VAR_4; }
[ "int FUNC_0(AVFormatContext **VAR_0, const char *VAR_1, AVInputFormat *VAR_2, AVDictionary **VAR_3)\n{", "AVFormatContext *s = *VAR_0;", "int VAR_4 = 0;", "AVFormatParameters ap = { 0 };", "AVDictionary *tmp = NULL;", "if (!s && !(s = avformat_alloc_context()))\nreturn AVERROR(ENOMEM);", "if (VAR_2)\ns->iformat = VAR_2;", "if (VAR_3)\nav_dict_copy(&tmp, *VAR_3, 0);", "if ((VAR_4 = av_opt_set_dict(s, &tmp)) < 0)\ngoto fail;", "if ((VAR_4 = init_input(s, VAR_1)) < 0)\ngoto fail;", "if (s->iformat->flags & AVFMT_NEEDNUMBER) {", "if (!av_filename_number_test(VAR_1)) {", "VAR_4 = AVERROR(EINVAL);", "goto fail;", "}", "}", "s->duration = s->start_time = AV_NOPTS_VALUE;", "av_strlcpy(s->VAR_1, VAR_1, sizeof(s->VAR_1));", "if (s->iformat->priv_data_size > 0) {", "if (!(s->priv_data = av_mallocz(s->iformat->priv_data_size))) {", "VAR_4 = AVERROR(ENOMEM);", "goto fail;", "}", "if (s->iformat->priv_class) {", "*(const AVClass**)s->priv_data = s->iformat->priv_class;", "av_opt_set_defaults(s->priv_data);", "if ((VAR_4 = av_opt_set_dict(s->priv_data, &tmp)) < 0)\ngoto fail;", "}", "}", "if (s->pb)\nff_id3v2_read(s, ID3v2_DEFAULT_MAGIC);", "if (s->iformat->read_header)\nif ((VAR_4 = s->iformat->read_header(s, &ap)) < 0)\ngoto fail;", "if (s->pb && !s->data_offset)\ns->data_offset = avio_tell(s->pb);", "s->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;", "if (VAR_3) {", "av_dict_free(VAR_3);", "*VAR_3 = tmp;", "}", "*VAR_0 = s;", "return 0;", "fail:\nav_dict_free(&tmp);", "if (s->pb && !(s->flags & AVFMT_FLAG_CUSTOM_IO))\navio_close(s->pb);", "avformat_free_context(s);", "*VAR_0 = NULL;", "return VAR_4;", "}" ]
[ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15, 17 ], [ 19, 21 ], [ 25, 27 ], [ 31, 33 ], [ 37, 39 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83, 85 ], [ 87 ], [ 89 ], [ 95, 97 ], [ 101, 103, 105 ], [ 109, 111 ], [ 115 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 133, 135 ], [ 137, 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ] ]
9,440
void vp8_mc_luma(VP8Context *s, VP8ThreadData *td, uint8_t *dst, ThreadFrame *ref, const VP56mv *mv, int x_off, int y_off, int block_w, int block_h, int width, int height, int linesize, vp8_mc_func mc_func[3][3]) { uint8_t *src = ref->f->data[0]; if (AV_RN32A(mv)) { int mx = (mv->x << 1)&7, mx_idx = subpel_idx[0][mx]; int my = (mv->y << 1)&7, my_idx = subpel_idx[0][my]; x_off += mv->x >> 2; y_off += mv->y >> 2; // edge emulation ff_thread_await_progress(ref, (3 + y_off + block_h + subpel_idx[2][my]) >> 4, 0); src += y_off * linesize + x_off; if (x_off < mx_idx || x_off >= width - block_w - subpel_idx[2][mx] || y_off < my_idx || y_off >= height - block_h - subpel_idx[2][my]) { s->vdsp.emulated_edge_mc(td->edge_emu_buffer, src - my_idx * linesize - mx_idx, linesize, block_w + subpel_idx[1][mx], block_h + subpel_idx[1][my], x_off - mx_idx, y_off - my_idx, width, height); src = td->edge_emu_buffer + mx_idx + linesize * my_idx; } mc_func[my_idx][mx_idx](dst, linesize, src, linesize, block_h, mx, my); } else { ff_thread_await_progress(ref, (3 + y_off + block_h) >> 4, 0); mc_func[0][0](dst, linesize, src + y_off * linesize + x_off, linesize, block_h, 0, 0); } }
true
FFmpeg
c341f734e5f9d6af4a8fdcceb6f5d12de6395c76
void vp8_mc_luma(VP8Context *s, VP8ThreadData *td, uint8_t *dst, ThreadFrame *ref, const VP56mv *mv, int x_off, int y_off, int block_w, int block_h, int width, int height, int linesize, vp8_mc_func mc_func[3][3]) { uint8_t *src = ref->f->data[0]; if (AV_RN32A(mv)) { int mx = (mv->x << 1)&7, mx_idx = subpel_idx[0][mx]; int my = (mv->y << 1)&7, my_idx = subpel_idx[0][my]; x_off += mv->x >> 2; y_off += mv->y >> 2; ff_thread_await_progress(ref, (3 + y_off + block_h + subpel_idx[2][my]) >> 4, 0); src += y_off * linesize + x_off; if (x_off < mx_idx || x_off >= width - block_w - subpel_idx[2][mx] || y_off < my_idx || y_off >= height - block_h - subpel_idx[2][my]) { s->vdsp.emulated_edge_mc(td->edge_emu_buffer, src - my_idx * linesize - mx_idx, linesize, block_w + subpel_idx[1][mx], block_h + subpel_idx[1][my], x_off - mx_idx, y_off - my_idx, width, height); src = td->edge_emu_buffer + mx_idx + linesize * my_idx; } mc_func[my_idx][mx_idx](dst, linesize, src, linesize, block_h, mx, my); } else { ff_thread_await_progress(ref, (3 + y_off + block_h) >> 4, 0); mc_func[0][0](dst, linesize, src + y_off * linesize + x_off, linesize, block_h, 0, 0); } }
{ "code": [ " int width, int height, int linesize," ], "line_no": [ 7 ] }
void FUNC_0(VP8Context *VAR_0, VP8ThreadData *VAR_1, uint8_t *VAR_2, ThreadFrame *VAR_3, const VP56mv *VAR_4, int VAR_5, int VAR_6, int VAR_7, int VAR_8, int VAR_9, int VAR_10, int VAR_11, vp8_mc_func VAR_12[3][3]) { uint8_t *src = VAR_3->f->data[0]; if (AV_RN32A(VAR_4)) { int VAR_13 = (VAR_4->x << 1)&7, VAR_14 = subpel_idx[0][VAR_13]; int VAR_15 = (VAR_4->y << 1)&7, VAR_16 = subpel_idx[0][VAR_15]; VAR_5 += VAR_4->x >> 2; VAR_6 += VAR_4->y >> 2; ff_thread_await_progress(VAR_3, (3 + VAR_6 + VAR_8 + subpel_idx[2][VAR_15]) >> 4, 0); src += VAR_6 * VAR_11 + VAR_5; if (VAR_5 < VAR_14 || VAR_5 >= VAR_9 - VAR_7 - subpel_idx[2][VAR_13] || VAR_6 < VAR_16 || VAR_6 >= VAR_10 - VAR_8 - subpel_idx[2][VAR_15]) { VAR_0->vdsp.emulated_edge_mc(VAR_1->edge_emu_buffer, src - VAR_16 * VAR_11 - VAR_14, VAR_11, VAR_7 + subpel_idx[1][VAR_13], VAR_8 + subpel_idx[1][VAR_15], VAR_5 - VAR_14, VAR_6 - VAR_16, VAR_9, VAR_10); src = VAR_1->edge_emu_buffer + VAR_14 + VAR_11 * VAR_16; } VAR_12[VAR_16][VAR_14](VAR_2, VAR_11, src, VAR_11, VAR_8, VAR_13, VAR_15); } else { ff_thread_await_progress(VAR_3, (3 + VAR_6 + VAR_8) >> 4, 0); VAR_12[0][0](VAR_2, VAR_11, src + VAR_6 * VAR_11 + VAR_5, VAR_11, VAR_8, 0, 0); } }
[ "void FUNC_0(VP8Context *VAR_0, VP8ThreadData *VAR_1, uint8_t *VAR_2,\nThreadFrame *VAR_3, const VP56mv *VAR_4,\nint VAR_5, int VAR_6, int VAR_7, int VAR_8,\nint VAR_9, int VAR_10, int VAR_11,\nvp8_mc_func VAR_12[3][3])\n{", "uint8_t *src = VAR_3->f->data[0];", "if (AV_RN32A(VAR_4)) {", "int VAR_13 = (VAR_4->x << 1)&7, VAR_14 = subpel_idx[0][VAR_13];", "int VAR_15 = (VAR_4->y << 1)&7, VAR_16 = subpel_idx[0][VAR_15];", "VAR_5 += VAR_4->x >> 2;", "VAR_6 += VAR_4->y >> 2;", "ff_thread_await_progress(VAR_3, (3 + VAR_6 + VAR_8 + subpel_idx[2][VAR_15]) >> 4, 0);", "src += VAR_6 * VAR_11 + VAR_5;", "if (VAR_5 < VAR_14 || VAR_5 >= VAR_9 - VAR_7 - subpel_idx[2][VAR_13] ||\nVAR_6 < VAR_16 || VAR_6 >= VAR_10 - VAR_8 - subpel_idx[2][VAR_15]) {", "VAR_0->vdsp.emulated_edge_mc(VAR_1->edge_emu_buffer, src - VAR_16 * VAR_11 - VAR_14, VAR_11,\nVAR_7 + subpel_idx[1][VAR_13], VAR_8 + subpel_idx[1][VAR_15],\nVAR_5 - VAR_14, VAR_6 - VAR_16, VAR_9, VAR_10);", "src = VAR_1->edge_emu_buffer + VAR_14 + VAR_11 * VAR_16;", "}", "VAR_12[VAR_16][VAR_14](VAR_2, VAR_11, src, VAR_11, VAR_8, VAR_13, VAR_15);", "} else {", "ff_thread_await_progress(VAR_3, (3 + VAR_6 + VAR_8) >> 4, 0);", "VAR_12[0][0](VAR_2, VAR_11, src + VAR_6 * VAR_11 + VAR_5, VAR_11, VAR_8, 0, 0);", "}", "}" ]
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11 ], [ 13 ], [ 17 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 35 ], [ 37 ], [ 39, 41 ], [ 43, 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ] ]
9,442
static void syborg_virtio_writel(void *opaque, target_phys_addr_t offset, uint32_t value) { SyborgVirtIOProxy *s = opaque; VirtIODevice *vdev = s->vdev; DPRINTF("writel 0x%x = 0x%x\n", (int)offset, value); if (offset >= SYBORG_VIRTIO_CONFIG) { return virtio_config_writel(vdev, offset - SYBORG_VIRTIO_CONFIG, value); } switch (offset >> 2) { case SYBORG_VIRTIO_GUEST_FEATURES: if (vdev->set_features) vdev->set_features(vdev, value); vdev->guest_features = value; break; case SYBORG_VIRTIO_QUEUE_BASE: if (value == 0) virtio_reset(vdev); else virtio_queue_set_addr(vdev, vdev->queue_sel, value); break; case SYBORG_VIRTIO_QUEUE_SEL: if (value < VIRTIO_PCI_QUEUE_MAX) vdev->queue_sel = value; break; case SYBORG_VIRTIO_QUEUE_NOTIFY: virtio_queue_notify(vdev, value); break; case SYBORG_VIRTIO_STATUS: virtio_set_status(vdev, value & 0xFF); if (vdev->status == 0) virtio_reset(vdev); break; case SYBORG_VIRTIO_INT_ENABLE: s->int_enable = value; virtio_update_irq(vdev); break; case SYBORG_VIRTIO_INT_STATUS: vdev->isr &= ~value; virtio_update_irq(vdev); break; default: BADF("Bad write offset 0x%x\n", (int)offset); break; } }
true
qemu
7157e2e23e89adcd436caeab31fdd6b47eded377
static void syborg_virtio_writel(void *opaque, target_phys_addr_t offset, uint32_t value) { SyborgVirtIOProxy *s = opaque; VirtIODevice *vdev = s->vdev; DPRINTF("writel 0x%x = 0x%x\n", (int)offset, value); if (offset >= SYBORG_VIRTIO_CONFIG) { return virtio_config_writel(vdev, offset - SYBORG_VIRTIO_CONFIG, value); } switch (offset >> 2) { case SYBORG_VIRTIO_GUEST_FEATURES: if (vdev->set_features) vdev->set_features(vdev, value); vdev->guest_features = value; break; case SYBORG_VIRTIO_QUEUE_BASE: if (value == 0) virtio_reset(vdev); else virtio_queue_set_addr(vdev, vdev->queue_sel, value); break; case SYBORG_VIRTIO_QUEUE_SEL: if (value < VIRTIO_PCI_QUEUE_MAX) vdev->queue_sel = value; break; case SYBORG_VIRTIO_QUEUE_NOTIFY: virtio_queue_notify(vdev, value); break; case SYBORG_VIRTIO_STATUS: virtio_set_status(vdev, value & 0xFF); if (vdev->status == 0) virtio_reset(vdev); break; case SYBORG_VIRTIO_INT_ENABLE: s->int_enable = value; virtio_update_irq(vdev); break; case SYBORG_VIRTIO_INT_STATUS: vdev->isr &= ~value; virtio_update_irq(vdev); break; default: BADF("Bad write offset 0x%x\n", (int)offset); break; } }
{ "code": [ " virtio_queue_notify(vdev, value);" ], "line_no": [ 57 ] }
static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint32_t VAR_2) { SyborgVirtIOProxy *s = VAR_0; VirtIODevice *vdev = s->vdev; DPRINTF("writel 0x%x = 0x%x\n", (int)VAR_1, VAR_2); if (VAR_1 >= SYBORG_VIRTIO_CONFIG) { return virtio_config_writel(vdev, VAR_1 - SYBORG_VIRTIO_CONFIG, VAR_2); } switch (VAR_1 >> 2) { case SYBORG_VIRTIO_GUEST_FEATURES: if (vdev->set_features) vdev->set_features(vdev, VAR_2); vdev->guest_features = VAR_2; break; case SYBORG_VIRTIO_QUEUE_BASE: if (VAR_2 == 0) virtio_reset(vdev); else virtio_queue_set_addr(vdev, vdev->queue_sel, VAR_2); break; case SYBORG_VIRTIO_QUEUE_SEL: if (VAR_2 < VIRTIO_PCI_QUEUE_MAX) vdev->queue_sel = VAR_2; break; case SYBORG_VIRTIO_QUEUE_NOTIFY: virtio_queue_notify(vdev, VAR_2); break; case SYBORG_VIRTIO_STATUS: virtio_set_status(vdev, VAR_2 & 0xFF); if (vdev->status == 0) virtio_reset(vdev); break; case SYBORG_VIRTIO_INT_ENABLE: s->int_enable = VAR_2; virtio_update_irq(vdev); break; case SYBORG_VIRTIO_INT_STATUS: vdev->isr &= ~VAR_2; virtio_update_irq(vdev); break; default: BADF("Bad write VAR_1 0x%x\n", (int)VAR_1); break; } }
[ "static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint32_t VAR_2)\n{", "SyborgVirtIOProxy *s = VAR_0;", "VirtIODevice *vdev = s->vdev;", "DPRINTF(\"writel 0x%x = 0x%x\\n\", (int)VAR_1, VAR_2);", "if (VAR_1 >= SYBORG_VIRTIO_CONFIG) {", "return virtio_config_writel(vdev, VAR_1 - SYBORG_VIRTIO_CONFIG,\nVAR_2);", "}", "switch (VAR_1 >> 2) {", "case SYBORG_VIRTIO_GUEST_FEATURES:\nif (vdev->set_features)\nvdev->set_features(vdev, VAR_2);", "vdev->guest_features = VAR_2;", "break;", "case SYBORG_VIRTIO_QUEUE_BASE:\nif (VAR_2 == 0)\nvirtio_reset(vdev);", "else\nvirtio_queue_set_addr(vdev, vdev->queue_sel, VAR_2);", "break;", "case SYBORG_VIRTIO_QUEUE_SEL:\nif (VAR_2 < VIRTIO_PCI_QUEUE_MAX)\nvdev->queue_sel = VAR_2;", "break;", "case SYBORG_VIRTIO_QUEUE_NOTIFY:\nvirtio_queue_notify(vdev, VAR_2);", "break;", "case SYBORG_VIRTIO_STATUS:\nvirtio_set_status(vdev, VAR_2 & 0xFF);", "if (vdev->status == 0)\nvirtio_reset(vdev);", "break;", "case SYBORG_VIRTIO_INT_ENABLE:\ns->int_enable = VAR_2;", "virtio_update_irq(vdev);", "break;", "case SYBORG_VIRTIO_INT_STATUS:\nvdev->isr &= ~VAR_2;", "virtio_update_irq(vdev);", "break;", "default:\nBADF(\"Bad write VAR_1 0x%x\\n\", (int)VAR_1);", "break;", "}", "}" ]
[ 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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17, 19 ], [ 21 ], [ 23 ], [ 25, 27, 29 ], [ 31 ], [ 33 ], [ 35, 37, 39 ], [ 41, 43 ], [ 45 ], [ 47, 49, 51 ], [ 53 ], [ 55, 57 ], [ 59 ], [ 61, 63 ], [ 65, 67 ], [ 69 ], [ 71, 73 ], [ 75 ], [ 77 ], [ 79, 81 ], [ 83 ], [ 85 ], [ 87, 89 ], [ 91 ], [ 93 ], [ 95 ] ]