id
int32
0
27.3k
func
stringlengths
26
142k
target
bool
2 classes
project
stringclasses
2 values
commit_id
stringlengths
40
40
func_clean
stringlengths
26
131k
vul_lines
dict
normalized_func
stringlengths
24
132k
lines
sequencelengths
1
2.8k
label
sequencelengths
1
2.8k
line_no
sequencelengths
1
2.8k
619
static void do_dcbz(CPUPPCState *env, target_ulong addr, int dcache_line_size, uintptr_t raddr) { int i; addr &= ~(dcache_line_size - 1); for (i = 0; i < dcache_line_size; i += 4) { cpu_stl_data_ra(env, addr + i, 0, raddr); } if (env->reserve_addr == addr) { env->reserve_addr = (target_ulong)-1ULL; } }
true
qemu
c9f82d013be0d8d9c5d9f51bb76e337a0a5a5cac
static void do_dcbz(CPUPPCState *env, target_ulong addr, int dcache_line_size, uintptr_t raddr) { int i; addr &= ~(dcache_line_size - 1); for (i = 0; i < dcache_line_size; i += 4) { cpu_stl_data_ra(env, addr + i, 0, raddr); } if (env->reserve_addr == addr) { env->reserve_addr = (target_ulong)-1ULL; } }
{ "code": [ "static void do_dcbz(CPUPPCState *env, target_ulong addr, int dcache_line_size,", " uintptr_t raddr)", " int i;", " addr &= ~(dcache_line_size - 1);", " for (i = 0; i < dcache_line_size; i += 4) {", " cpu_stl_data_ra(env, addr + i, 0, raddr);", " if (env->reserve_addr == addr) {", " env->reserve_addr = (target_ulong)-1ULL;" ], "line_no": [ 1, 3, 7, 11, 13, 15, 19, 21 ] }
static void FUNC_0(CPUPPCState *VAR_0, target_ulong VAR_1, int VAR_2, uintptr_t VAR_3) { int VAR_4; VAR_1 &= ~(VAR_2 - 1); for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4 += 4) { cpu_stl_data_ra(VAR_0, VAR_1 + VAR_4, 0, VAR_3); } if (VAR_0->reserve_addr == VAR_1) { VAR_0->reserve_addr = (target_ulong)-1ULL; } }
[ "static void FUNC_0(CPUPPCState *VAR_0, target_ulong VAR_1, int VAR_2,\nuintptr_t VAR_3)\n{", "int VAR_4;", "VAR_1 &= ~(VAR_2 - 1);", "for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4 += 4) {", "cpu_stl_data_ra(VAR_0, VAR_1 + VAR_4, 0, VAR_3);", "}", "if (VAR_0->reserve_addr == VAR_1) {", "VAR_0->reserve_addr = (target_ulong)-1ULL;", "}", "}" ]
[ 1, 1, 1, 1, 1, 0, 1, 1, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ] ]
620
static int32_t ide_nop_int32(IDEDMA *dma, int x) { return 0; }
true
qemu
a718978ed58abc1ad92567a9c17525136be02a71
static int32_t ide_nop_int32(IDEDMA *dma, int x) { return 0; }
{ "code": [ "static int32_t ide_nop_int32(IDEDMA *dma, int x)", "static int32_t ide_nop_int32(IDEDMA *dma, int x)" ], "line_no": [ 1, 1 ] }
static int32_t FUNC_0(IDEDMA *dma, int x) { return 0; }
[ "static int32_t FUNC_0(IDEDMA *dma, int x)\n{", "return 0;", "}" ]
[ 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
621
static int read_password(char *buf, int buf_size) { int c, i; printf("Password: "); fflush(stdout); i = 0; for(;;) { c = getchar(); if (c == '\n') break; if (i < (buf_size - 1)) buf[i++] = c; } buf[i] = '\0'; return 0; }
true
qemu
fdcf6e65bce1f8972030fed7af5e8aa5f6ae92c6
static int read_password(char *buf, int buf_size) { int c, i; printf("Password: "); fflush(stdout); i = 0; for(;;) { c = getchar(); if (c == '\n') break; if (i < (buf_size - 1)) buf[i++] = c; } buf[i] = '\0'; return 0; }
{ "code": [ " if (c == '\\n')", " if (i < (buf_size - 1))" ], "line_no": [ 17, 21 ] }
static int FUNC_0(char *VAR_0, int VAR_1) { int VAR_2, VAR_3; printf("Password: "); fflush(stdout); VAR_3 = 0; for(;;) { VAR_2 = getchar(); if (VAR_2 == '\n') break; if (VAR_3 < (VAR_1 - 1)) VAR_0[VAR_3++] = VAR_2; } VAR_0[VAR_3] = '\0'; return 0; }
[ "static int FUNC_0(char *VAR_0, int VAR_1)\n{", "int VAR_2, VAR_3;", "printf(\"Password: \");", "fflush(stdout);", "VAR_3 = 0;", "for(;;) {", "VAR_2 = getchar();", "if (VAR_2 == '\\n')\nbreak;", "if (VAR_3 < (VAR_1 - 1))\nVAR_0[VAR_3++] = VAR_2;", "}", "VAR_0[VAR_3] = '\\0';", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17, 19 ], [ 21, 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ] ]
622
long do_rt_sigreturn(CPUARMState *env) { struct target_rt_sigframe *frame; abi_ulong frame_addr = env->xregs[31]; if (frame_addr & 15) { goto badframe; } if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) { goto badframe; } if (target_restore_sigframe(env, frame)) { goto badframe; } if (do_sigaltstack(frame_addr + offsetof(struct target_rt_sigframe, uc.tuc_stack), 0, get_sp_from_cpustate(env)) == -EFAULT) { goto badframe; } unlock_user_struct(frame, frame_addr, 0); return env->xregs[0]; badframe: unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV); return 0; }
true
qemu
7f72cd235fa33f2fc7a8d1cc4d621bf7db61e9eb
long do_rt_sigreturn(CPUARMState *env) { struct target_rt_sigframe *frame; abi_ulong frame_addr = env->xregs[31]; if (frame_addr & 15) { goto badframe; } if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) { goto badframe; } if (target_restore_sigframe(env, frame)) { goto badframe; } if (do_sigaltstack(frame_addr + offsetof(struct target_rt_sigframe, uc.tuc_stack), 0, get_sp_from_cpustate(env)) == -EFAULT) { goto badframe; } unlock_user_struct(frame, frame_addr, 0); return env->xregs[0]; badframe: unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV); return 0; }
{ "code": [ " struct target_rt_sigframe *frame;" ], "line_no": [ 5 ] }
long FUNC_0(CPUARMState *VAR_0) { struct target_rt_sigframe *VAR_1; abi_ulong frame_addr = VAR_0->xregs[31]; if (frame_addr & 15) { goto badframe; } if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1)) { goto badframe; } if (target_restore_sigframe(VAR_0, VAR_1)) { goto badframe; } if (do_sigaltstack(frame_addr + offsetof(struct target_rt_sigframe, uc.tuc_stack), 0, get_sp_from_cpustate(VAR_0)) == -EFAULT) { goto badframe; } unlock_user_struct(VAR_1, frame_addr, 0); return VAR_0->xregs[0]; badframe: unlock_user_struct(VAR_1, frame_addr, 0); force_sig(TARGET_SIGSEGV); return 0; }
[ "long FUNC_0(CPUARMState *VAR_0)\n{", "struct target_rt_sigframe *VAR_1;", "abi_ulong frame_addr = VAR_0->xregs[31];", "if (frame_addr & 15) {", "goto badframe;", "}", "if (!lock_user_struct(VERIFY_READ, VAR_1, frame_addr, 1)) {", "goto badframe;", "}", "if (target_restore_sigframe(VAR_0, VAR_1)) {", "goto badframe;", "}", "if (do_sigaltstack(frame_addr +\noffsetof(struct target_rt_sigframe, uc.tuc_stack),\n0, get_sp_from_cpustate(VAR_0)) == -EFAULT) {", "goto badframe;", "}", "unlock_user_struct(VAR_1, frame_addr, 0);", "return VAR_0->xregs[0];", "badframe:\nunlock_user_struct(VAR_1, frame_addr, 0);", "force_sig(TARGET_SIGSEGV);", "return 0;", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 35, 37, 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 53, 55 ], [ 57 ], [ 59 ], [ 61 ] ]
623
tcp_sockclosed(struct tcpcb *tp) { DEBUG_CALL("tcp_sockclosed"); DEBUG_ARG("tp = %p", tp); switch (tp->t_state) { case TCPS_CLOSED: case TCPS_LISTEN: case TCPS_SYN_SENT: tp->t_state = TCPS_CLOSED; tp = tcp_close(tp); break; case TCPS_SYN_RECEIVED: case TCPS_ESTABLISHED: tp->t_state = TCPS_FIN_WAIT_1; break; case TCPS_CLOSE_WAIT: tp->t_state = TCPS_LAST_ACK; break; } if (tp) tcp_output(tp); }
true
qemu
b5ab677189b93efa4eaa921f42b21dc008247184
tcp_sockclosed(struct tcpcb *tp) { DEBUG_CALL("tcp_sockclosed"); DEBUG_ARG("tp = %p", tp); switch (tp->t_state) { case TCPS_CLOSED: case TCPS_LISTEN: case TCPS_SYN_SENT: tp->t_state = TCPS_CLOSED; tp = tcp_close(tp); break; case TCPS_SYN_RECEIVED: case TCPS_ESTABLISHED: tp->t_state = TCPS_FIN_WAIT_1; break; case TCPS_CLOSE_WAIT: tp->t_state = TCPS_LAST_ACK; break; } if (tp) tcp_output(tp); }
{ "code": [ "\tif (tp)", "\t\ttcp_output(tp);" ], "line_no": [ 49, 51 ] }
FUNC_0(struct tcpcb *VAR_0) { DEBUG_CALL("FUNC_0"); DEBUG_ARG("VAR_0 = %p", VAR_0); switch (VAR_0->t_state) { case TCPS_CLOSED: case TCPS_LISTEN: case TCPS_SYN_SENT: VAR_0->t_state = TCPS_CLOSED; VAR_0 = tcp_close(VAR_0); break; case TCPS_SYN_RECEIVED: case TCPS_ESTABLISHED: VAR_0->t_state = TCPS_FIN_WAIT_1; break; case TCPS_CLOSE_WAIT: VAR_0->t_state = TCPS_LAST_ACK; break; } if (VAR_0) tcp_output(VAR_0); }
[ "FUNC_0(struct tcpcb *VAR_0)\n{", "DEBUG_CALL(\"FUNC_0\");", "DEBUG_ARG(\"VAR_0 = %p\", VAR_0);", "switch (VAR_0->t_state) {", "case TCPS_CLOSED:\ncase TCPS_LISTEN:\ncase TCPS_SYN_SENT:\nVAR_0->t_state = TCPS_CLOSED;", "VAR_0 = tcp_close(VAR_0);", "break;", "case TCPS_SYN_RECEIVED:\ncase TCPS_ESTABLISHED:\nVAR_0->t_state = TCPS_FIN_WAIT_1;", "break;", "case TCPS_CLOSE_WAIT:\nVAR_0->t_state = TCPS_LAST_ACK;", "break;", "}", "if (VAR_0)\ntcp_output(VAR_0);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 7 ], [ 9 ], [ 13 ], [ 17, 19, 21, 23 ], [ 25 ], [ 27 ], [ 31, 33, 35 ], [ 37 ], [ 41, 43 ], [ 45 ], [ 47 ], [ 49, 51 ], [ 53 ] ]
624
static void icp_pit_write(void *opaque, target_phys_addr_t offset, uint64_t value, unsigned size) { icp_pit_state *s = (icp_pit_state *)opaque; int n; n = offset >> 8; if (n > 3) { hw_error("sp804_write: Bad timer %d\n", n); } arm_timer_write(s->timer[n], offset & 0xff, value); }
true
qemu
ee71c984342408a357a74f65915bf66484ba445a
static void icp_pit_write(void *opaque, target_phys_addr_t offset, uint64_t value, unsigned size) { icp_pit_state *s = (icp_pit_state *)opaque; int n; n = offset >> 8; if (n > 3) { hw_error("sp804_write: Bad timer %d\n", n); } arm_timer_write(s->timer[n], offset & 0xff, value); }
{ "code": [ " if (n > 3) {", " if (n > 3) {" ], "line_no": [ 15, 15 ] }
static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint64_t VAR_2, unsigned VAR_3) { icp_pit_state *s = (icp_pit_state *)VAR_0; int VAR_4; VAR_4 = VAR_1 >> 8; if (VAR_4 > 3) { hw_error("sp804_write: Bad timer %d\VAR_4", VAR_4); } arm_timer_write(s->timer[VAR_4], VAR_1 & 0xff, VAR_2); }
[ "static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{", "icp_pit_state *s = (icp_pit_state *)VAR_0;", "int VAR_4;", "VAR_4 = VAR_1 >> 8;", "if (VAR_4 > 3) {", "hw_error(\"sp804_write: Bad timer %d\\VAR_4\", VAR_4);", "}", "arm_timer_write(s->timer[VAR_4], VAR_1 & 0xff, VAR_2);", "}" ]
[ 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ] ]
625
static int exynos4210_combiner_init(SysBusDevice *sbd) { DeviceState *dev = DEVICE(sbd); Exynos4210CombinerState *s = EXYNOS4210_COMBINER(dev); unsigned int i; /* Allocate general purpose input signals and connect a handler to each of * them */ qdev_init_gpio_in(dev, exynos4210_combiner_handler, IIC_NIRQ); /* Connect SysBusDev irqs to device specific irqs */ for (i = 0; i < IIC_NIRQ; i++) { sysbus_init_irq(sbd, &s->output_irq[i]); } memory_region_init_io(&s->iomem, OBJECT(s), &exynos4210_combiner_ops, s, "exynos4210-combiner", IIC_REGION_SIZE); sysbus_init_mmio(sbd, &s->iomem); return 0; }
true
qemu
fce0a826083e0416981e2ea9518ce5faa75b81a3
static int exynos4210_combiner_init(SysBusDevice *sbd) { DeviceState *dev = DEVICE(sbd); Exynos4210CombinerState *s = EXYNOS4210_COMBINER(dev); unsigned int i; qdev_init_gpio_in(dev, exynos4210_combiner_handler, IIC_NIRQ); for (i = 0; i < IIC_NIRQ; i++) { sysbus_init_irq(sbd, &s->output_irq[i]); } memory_region_init_io(&s->iomem, OBJECT(s), &exynos4210_combiner_ops, s, "exynos4210-combiner", IIC_REGION_SIZE); sysbus_init_mmio(sbd, &s->iomem); return 0; }
{ "code": [ " for (i = 0; i < IIC_NIRQ; i++) {" ], "line_no": [ 23 ] }
static int FUNC_0(SysBusDevice *VAR_0) { DeviceState *dev = DEVICE(VAR_0); Exynos4210CombinerState *s = EXYNOS4210_COMBINER(dev); unsigned int VAR_1; qdev_init_gpio_in(dev, exynos4210_combiner_handler, IIC_NIRQ); for (VAR_1 = 0; VAR_1 < IIC_NIRQ; VAR_1++) { sysbus_init_irq(VAR_0, &s->output_irq[VAR_1]); } memory_region_init_io(&s->iomem, OBJECT(s), &exynos4210_combiner_ops, s, "exynos4210-combiner", IIC_REGION_SIZE); sysbus_init_mmio(VAR_0, &s->iomem); return 0; }
[ "static int FUNC_0(SysBusDevice *VAR_0)\n{", "DeviceState *dev = DEVICE(VAR_0);", "Exynos4210CombinerState *s = EXYNOS4210_COMBINER(dev);", "unsigned int VAR_1;", "qdev_init_gpio_in(dev, exynos4210_combiner_handler, IIC_NIRQ);", "for (VAR_1 = 0; VAR_1 < IIC_NIRQ; VAR_1++) {", "sysbus_init_irq(VAR_0, &s->output_irq[VAR_1]);", "}", "memory_region_init_io(&s->iomem, OBJECT(s), &exynos4210_combiner_ops, s,\n\"exynos4210-combiner\", IIC_REGION_SIZE);", "sysbus_init_mmio(VAR_0, &s->iomem);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 17 ], [ 23 ], [ 25 ], [ 27 ], [ 31, 33 ], [ 35 ], [ 39 ], [ 41 ] ]
626
static uint32_t calc_optimal_rice_params(RiceContext *rc, int porder, uint32_t *sums, int n, int pred_order) { int i; int k, cnt, part; uint32_t all_bits; part = (1 << porder); all_bits = 0; cnt = (n >> porder) - pred_order; for(i=0; i<part; i++) { if(i == 1) cnt = (n >> porder); k = find_optimal_param(sums[i], cnt); rc->params[i] = k; all_bits += rice_encode_count(sums[i], cnt, k); } all_bits += (4 * part); rc->porder = porder; return all_bits; }
false
FFmpeg
90f03441654f85a1402a65c3dcaa3f634a24c27e
static uint32_t calc_optimal_rice_params(RiceContext *rc, int porder, uint32_t *sums, int n, int pred_order) { int i; int k, cnt, part; uint32_t all_bits; part = (1 << porder); all_bits = 0; cnt = (n >> porder) - pred_order; for(i=0; i<part; i++) { if(i == 1) cnt = (n >> porder); k = find_optimal_param(sums[i], cnt); rc->params[i] = k; all_bits += rice_encode_count(sums[i], cnt, k); } all_bits += (4 * part); rc->porder = porder; return all_bits; }
{ "code": [], "line_no": [] }
static uint32_t FUNC_0(RiceContext *rc, int porder, uint32_t *sums, int n, int pred_order) { int VAR_0; int VAR_1, VAR_2, VAR_3; uint32_t all_bits; VAR_3 = (1 << porder); all_bits = 0; VAR_2 = (n >> porder) - pred_order; for(VAR_0=0; VAR_0<VAR_3; VAR_0++) { if(VAR_0 == 1) VAR_2 = (n >> porder); VAR_1 = find_optimal_param(sums[VAR_0], VAR_2); rc->params[VAR_0] = VAR_1; all_bits += rice_encode_count(sums[VAR_0], VAR_2, VAR_1); } all_bits += (4 * VAR_3); rc->porder = porder; return all_bits; }
[ "static uint32_t FUNC_0(RiceContext *rc, int porder,\nuint32_t *sums, int n, int pred_order)\n{", "int VAR_0;", "int VAR_1, VAR_2, VAR_3;", "uint32_t all_bits;", "VAR_3 = (1 << porder);", "all_bits = 0;", "VAR_2 = (n >> porder) - pred_order;", "for(VAR_0=0; VAR_0<VAR_3; VAR_0++) {", "if(VAR_0 == 1) VAR_2 = (n >> porder);", "VAR_1 = find_optimal_param(sums[VAR_0], VAR_2);", "rc->params[VAR_0] = VAR_1;", "all_bits += rice_encode_count(sums[VAR_0], VAR_2, VAR_1);", "}", "all_bits += (4 * VAR_3);", "rc->porder = porder;", "return all_bits;", "}" ]
[ 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 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 43 ], [ 45 ] ]
627
static void raw_decode(uint8_t *dst, const int8_t *src, int src_size) { while (src_size--) *dst++ = *src++ + 128; }
false
FFmpeg
da8242e2d6f85d95239082efd0e5e2345e685a2c
static void raw_decode(uint8_t *dst, const int8_t *src, int src_size) { while (src_size--) *dst++ = *src++ + 128; }
{ "code": [], "line_no": [] }
static void FUNC_0(uint8_t *VAR_0, const int8_t *VAR_1, int VAR_2) { while (VAR_2--) *VAR_0++ = *VAR_1++ + 128; }
[ "static void FUNC_0(uint8_t *VAR_0, const int8_t *VAR_1, int VAR_2)\n{", "while (VAR_2--)\n*VAR_0++ = *VAR_1++ + 128;", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5, 7 ], [ 9 ] ]
628
static int dxtory_decode_v1_410(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size) { int h, w; uint8_t *Y1, *Y2, *Y3, *Y4, *U, *V; int ret; if (src_size < avctx->width * avctx->height * 9LL / 8) { av_log(avctx, AV_LOG_ERROR, "packet too small\n"); return AVERROR_INVALIDDATA; } avctx->pix_fmt = AV_PIX_FMT_YUV410P; if ((ret = ff_get_buffer(avctx, pic, 0)) < 0) return ret; Y1 = pic->data[0]; Y2 = pic->data[0] + pic->linesize[0]; Y3 = pic->data[0] + pic->linesize[0] * 2; Y4 = pic->data[0] + pic->linesize[0] * 3; U = pic->data[1]; V = pic->data[2]; for (h = 0; h < avctx->height; h += 4) { for (w = 0; w < avctx->width; w += 4) { AV_COPY32U(Y1 + w, src); AV_COPY32U(Y2 + w, src + 4); AV_COPY32U(Y3 + w, src + 8); AV_COPY32U(Y4 + w, src + 12); U[w >> 2] = src[16] + 0x80; V[w >> 2] = src[17] + 0x80; src += 18; } Y1 += pic->linesize[0] << 2; Y2 += pic->linesize[0] << 2; Y3 += pic->linesize[0] << 2; Y4 += pic->linesize[0] << 2; U += pic->linesize[1]; V += pic->linesize[2]; } return 0; }
false
FFmpeg
76b6f4b7d91901929177cc61d9810dcca0bb40c1
static int dxtory_decode_v1_410(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size) { int h, w; uint8_t *Y1, *Y2, *Y3, *Y4, *U, *V; int ret; if (src_size < avctx->width * avctx->height * 9LL / 8) { av_log(avctx, AV_LOG_ERROR, "packet too small\n"); return AVERROR_INVALIDDATA; } avctx->pix_fmt = AV_PIX_FMT_YUV410P; if ((ret = ff_get_buffer(avctx, pic, 0)) < 0) return ret; Y1 = pic->data[0]; Y2 = pic->data[0] + pic->linesize[0]; Y3 = pic->data[0] + pic->linesize[0] * 2; Y4 = pic->data[0] + pic->linesize[0] * 3; U = pic->data[1]; V = pic->data[2]; for (h = 0; h < avctx->height; h += 4) { for (w = 0; w < avctx->width; w += 4) { AV_COPY32U(Y1 + w, src); AV_COPY32U(Y2 + w, src + 4); AV_COPY32U(Y3 + w, src + 8); AV_COPY32U(Y4 + w, src + 12); U[w >> 2] = src[16] + 0x80; V[w >> 2] = src[17] + 0x80; src += 18; } Y1 += pic->linesize[0] << 2; Y2 += pic->linesize[0] << 2; Y3 += pic->linesize[0] << 2; Y4 += pic->linesize[0] << 2; U += pic->linesize[1]; V += pic->linesize[2]; } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1, const uint8_t *VAR_2, int VAR_3) { int VAR_4, VAR_5; uint8_t *Y1, *Y2, *Y3, *Y4, *U, *V; int VAR_6; if (VAR_3 < VAR_0->width * VAR_0->height * 9LL / 8) { av_log(VAR_0, AV_LOG_ERROR, "packet too small\n"); return AVERROR_INVALIDDATA; } VAR_0->pix_fmt = AV_PIX_FMT_YUV410P; if ((VAR_6 = ff_get_buffer(VAR_0, VAR_1, 0)) < 0) return VAR_6; Y1 = VAR_1->data[0]; Y2 = VAR_1->data[0] + VAR_1->linesize[0]; Y3 = VAR_1->data[0] + VAR_1->linesize[0] * 2; Y4 = VAR_1->data[0] + VAR_1->linesize[0] * 3; U = VAR_1->data[1]; V = VAR_1->data[2]; for (VAR_4 = 0; VAR_4 < VAR_0->height; VAR_4 += 4) { for (VAR_5 = 0; VAR_5 < VAR_0->width; VAR_5 += 4) { AV_COPY32U(Y1 + VAR_5, VAR_2); AV_COPY32U(Y2 + VAR_5, VAR_2 + 4); AV_COPY32U(Y3 + VAR_5, VAR_2 + 8); AV_COPY32U(Y4 + VAR_5, VAR_2 + 12); U[VAR_5 >> 2] = VAR_2[16] + 0x80; V[VAR_5 >> 2] = VAR_2[17] + 0x80; VAR_2 += 18; } Y1 += VAR_1->linesize[0] << 2; Y2 += VAR_1->linesize[0] << 2; Y3 += VAR_1->linesize[0] << 2; Y4 += VAR_1->linesize[0] << 2; U += VAR_1->linesize[1]; V += VAR_1->linesize[2]; } return 0; }
[ "static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1,\nconst uint8_t *VAR_2, int VAR_3)\n{", "int VAR_4, VAR_5;", "uint8_t *Y1, *Y2, *Y3, *Y4, *U, *V;", "int VAR_6;", "if (VAR_3 < VAR_0->width * VAR_0->height * 9LL / 8) {", "av_log(VAR_0, AV_LOG_ERROR, \"packet too small\\n\");", "return AVERROR_INVALIDDATA;", "}", "VAR_0->pix_fmt = AV_PIX_FMT_YUV410P;", "if ((VAR_6 = ff_get_buffer(VAR_0, VAR_1, 0)) < 0)\nreturn VAR_6;", "Y1 = VAR_1->data[0];", "Y2 = VAR_1->data[0] + VAR_1->linesize[0];", "Y3 = VAR_1->data[0] + VAR_1->linesize[0] * 2;", "Y4 = VAR_1->data[0] + VAR_1->linesize[0] * 3;", "U = VAR_1->data[1];", "V = VAR_1->data[2];", "for (VAR_4 = 0; VAR_4 < VAR_0->height; VAR_4 += 4) {", "for (VAR_5 = 0; VAR_5 < VAR_0->width; VAR_5 += 4) {", "AV_COPY32U(Y1 + VAR_5, VAR_2);", "AV_COPY32U(Y2 + VAR_5, VAR_2 + 4);", "AV_COPY32U(Y3 + VAR_5, VAR_2 + 8);", "AV_COPY32U(Y4 + VAR_5, VAR_2 + 12);", "U[VAR_5 >> 2] = VAR_2[16] + 0x80;", "V[VAR_5 >> 2] = VAR_2[17] + 0x80;", "VAR_2 += 18;", "}", "Y1 += VAR_1->linesize[0] << 2;", "Y2 += VAR_1->linesize[0] << 2;", "Y3 += VAR_1->linesize[0] << 2;", "Y4 += VAR_1->linesize[0] << 2;", "U += VAR_1->linesize[1];", "V += VAR_1->linesize[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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27, 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 81 ], [ 83 ] ]
629
static int ff_filter_frame_framed(AVFilterLink *link, AVFilterBufferRef *frame) { int (*filter_frame)(AVFilterLink *, AVFilterBufferRef *); AVFilterPad *src = link->srcpad; AVFilterPad *dst = link->dstpad; AVFilterBufferRef *out; int perms, ret; AVFilterCommand *cmd= link->dst->command_queue; int64_t pts; if (link->closed) { avfilter_unref_buffer(frame); return AVERROR_EOF; } if (!(filter_frame = dst->filter_frame)) filter_frame = default_filter_frame; av_assert1((frame->perms & src->min_perms) == src->min_perms); frame->perms &= ~ src->rej_perms; perms = frame->perms; if (frame->linesize[0] < 0) perms |= AV_PERM_NEG_LINESIZES; /* prepare to copy the frame if the buffer has insufficient permissions */ if ((dst->min_perms & perms) != dst->min_perms || dst->rej_perms & perms) { av_log(link->dst, AV_LOG_DEBUG, "Copying data in avfilter (have perms %x, need %x, reject %x)\n", perms, link->dstpad->min_perms, link->dstpad->rej_perms); /* Maybe use ff_copy_buffer_ref instead? */ switch (link->type) { case AVMEDIA_TYPE_VIDEO: out = ff_get_video_buffer(link, dst->min_perms, link->w, link->h); break; case AVMEDIA_TYPE_AUDIO: out = ff_get_audio_buffer(link, dst->min_perms, frame->audio->nb_samples); break; default: return AVERROR(EINVAL); } if (!out) { avfilter_unref_buffer(frame); return AVERROR(ENOMEM); } avfilter_copy_buffer_ref_props(out, frame); switch (link->type) { case AVMEDIA_TYPE_VIDEO: av_image_copy(out->data, out->linesize, frame->data, frame->linesize, frame->format, frame->video->w, frame->video->h); break; case AVMEDIA_TYPE_AUDIO: av_samples_copy(out->extended_data, frame->extended_data, 0, 0, frame->audio->nb_samples, av_get_channel_layout_nb_channels(frame->audio->channel_layout), frame->format); break; default: return AVERROR(EINVAL); } avfilter_unref_buffer(frame); } else out = frame; while(cmd && cmd->time <= frame->pts * av_q2d(link->time_base)){ av_log(link->dst, AV_LOG_DEBUG, "Processing command time:%f command:%s arg:%s\n", cmd->time, cmd->command, cmd->arg); avfilter_process_command(link->dst, cmd->command, cmd->arg, 0, 0, cmd->flags); ff_command_queue_pop(link->dst); cmd= link->dst->command_queue; } pts = out->pts; ret = filter_frame(link, out); ff_update_link_current_pts(link, pts); return ret; }
true
FFmpeg
ff6b34009d4571ae0a4d130c0f8d27706a4c4026
static int ff_filter_frame_framed(AVFilterLink *link, AVFilterBufferRef *frame) { int (*filter_frame)(AVFilterLink *, AVFilterBufferRef *); AVFilterPad *src = link->srcpad; AVFilterPad *dst = link->dstpad; AVFilterBufferRef *out; int perms, ret; AVFilterCommand *cmd= link->dst->command_queue; int64_t pts; if (link->closed) { avfilter_unref_buffer(frame); return AVERROR_EOF; } if (!(filter_frame = dst->filter_frame)) filter_frame = default_filter_frame; av_assert1((frame->perms & src->min_perms) == src->min_perms); frame->perms &= ~ src->rej_perms; perms = frame->perms; if (frame->linesize[0] < 0) perms |= AV_PERM_NEG_LINESIZES; if ((dst->min_perms & perms) != dst->min_perms || dst->rej_perms & perms) { av_log(link->dst, AV_LOG_DEBUG, "Copying data in avfilter (have perms %x, need %x, reject %x)\n", perms, link->dstpad->min_perms, link->dstpad->rej_perms); switch (link->type) { case AVMEDIA_TYPE_VIDEO: out = ff_get_video_buffer(link, dst->min_perms, link->w, link->h); break; case AVMEDIA_TYPE_AUDIO: out = ff_get_audio_buffer(link, dst->min_perms, frame->audio->nb_samples); break; default: return AVERROR(EINVAL); } if (!out) { avfilter_unref_buffer(frame); return AVERROR(ENOMEM); } avfilter_copy_buffer_ref_props(out, frame); switch (link->type) { case AVMEDIA_TYPE_VIDEO: av_image_copy(out->data, out->linesize, frame->data, frame->linesize, frame->format, frame->video->w, frame->video->h); break; case AVMEDIA_TYPE_AUDIO: av_samples_copy(out->extended_data, frame->extended_data, 0, 0, frame->audio->nb_samples, av_get_channel_layout_nb_channels(frame->audio->channel_layout), frame->format); break; default: return AVERROR(EINVAL); } avfilter_unref_buffer(frame); } else out = frame; while(cmd && cmd->time <= frame->pts * av_q2d(link->time_base)){ av_log(link->dst, AV_LOG_DEBUG, "Processing command time:%f command:%s arg:%s\n", cmd->time, cmd->command, cmd->arg); avfilter_process_command(link->dst, cmd->command, cmd->arg, 0, 0, cmd->flags); ff_command_queue_pop(link->dst); cmd= link->dst->command_queue; } pts = out->pts; ret = filter_frame(link, out); ff_update_link_current_pts(link, pts); return ret; }
{ "code": [ " while(cmd && cmd->time <= frame->pts * av_q2d(link->time_base)){" ], "line_no": [ 137 ] }
VAR_4staticVAR_4 VAR_4intVAR_4 VAR_4ff_filter_frame_framedVAR_4(VAR_4AVFilterLinkVAR_4 *VAR_4VAR_0VAR_4, VAR_4AVFilterBufferRefVAR_4 *VAR_4VAR_1VAR_4) { VAR_4intVAR_4 (*VAR_4VAR_2VAR_4)(VAR_4AVFilterLinkVAR_4 *, VAR_4AVFilterBufferRefVAR_4 *); VAR_4AVFilterPadVAR_4 *VAR_4srcVAR_4 = VAR_4VAR_0VAR_4->VAR_4srcpadVAR_4; VAR_4AVFilterPadVAR_4 *VAR_4dstVAR_4 = VAR_4VAR_0VAR_4->VAR_4dstpadVAR_4; VAR_4AVFilterBufferRefVAR_4 *VAR_4outVAR_4; VAR_4intVAR_4 VAR_4permsVAR_4, VAR_4retVAR_4; VAR_4AVFilterCommandVAR_4 *VAR_4cmdVAR_4= VAR_4VAR_0VAR_4->VAR_4dstVAR_4->VAR_4command_queueVAR_4; VAR_4int64_tVAR_4 VAR_4ptsVAR_4; VAR_4ifVAR_4 (VAR_4VAR_0VAR_4->VAR_4closedVAR_4) { VAR_4avfilter_unref_bufferVAR_4(VAR_4VAR_1VAR_4); VAR_4returnVAR_4 VAR_4AVERROR_EOFVAR_4; } VAR_4ifVAR_4 (!(VAR_4VAR_2VAR_4 = VAR_4dstVAR_4->VAR_4VAR_2VAR_4)) VAR_4VAR_2VAR_4 = VAR_4default_filter_frameVAR_4; VAR_4av_assert1VAR_4((VAR_4VAR_1VAR_4->VAR_4permsVAR_4 & VAR_4srcVAR_4->VAR_4min_permsVAR_4) == VAR_4srcVAR_4->VAR_4min_permsVAR_4); VAR_4VAR_1VAR_4->VAR_4permsVAR_4 &= ~ VAR_4srcVAR_4->VAR_4rej_permsVAR_4; VAR_4permsVAR_4 = VAR_4VAR_1VAR_4->VAR_4permsVAR_4; VAR_4ifVAR_4 (VAR_4VAR_1VAR_4->VAR_4linesizeVAR_4[VAR_40VAR_4] < VAR_40VAR_4) VAR_4permsVAR_4 |= VAR_4AV_PERM_NEG_LINESIZESVAR_4; VAR_4ifVAR_4 ((VAR_4dstVAR_4->VAR_4min_permsVAR_4 & VAR_4permsVAR_4) != VAR_4dstVAR_4->VAR_4min_permsVAR_4 || VAR_4dstVAR_4->VAR_4rej_permsVAR_4 & VAR_4permsVAR_4) { VAR_4av_logVAR_4(VAR_4VAR_0VAR_4->VAR_4dstVAR_4, VAR_4AV_LOG_DEBUGVAR_4, "VAR_4CopyingVAR_4 VAR_4dataVAR_4 VAR_4inVAR_4 VAR_4avfilterVAR_4 (VAR_4haveVAR_4 VAR_4permsVAR_4 %VAR_4xVAR_4, VAR_4needVAR_4 %VAR_4xVAR_4, VAR_4rejectVAR_4 %VAR_4xVAR_4)\VAR_4nVAR_4", VAR_4permsVAR_4, VAR_4VAR_0VAR_4->VAR_4dstpadVAR_4->VAR_4min_permsVAR_4, VAR_4VAR_0VAR_4->VAR_4dstpadVAR_4->VAR_4rej_permsVAR_4); VAR_4switchVAR_4 (VAR_4VAR_0VAR_4->VAR_4typeVAR_4) { VAR_4caseVAR_4 VAR_4AVMEDIA_TYPE_VIDEOVAR_4: VAR_4outVAR_4 = VAR_4ff_get_video_bufferVAR_4(VAR_4VAR_0VAR_4, VAR_4dstVAR_4->VAR_4min_permsVAR_4, VAR_4VAR_0VAR_4->VAR_4wVAR_4, VAR_4VAR_0VAR_4->VAR_4hVAR_4); VAR_4breakVAR_4; VAR_4caseVAR_4 VAR_4AVMEDIA_TYPE_AUDIOVAR_4: VAR_4outVAR_4 = VAR_4ff_get_audio_bufferVAR_4(VAR_4VAR_0VAR_4, VAR_4dstVAR_4->VAR_4min_permsVAR_4, VAR_4VAR_1VAR_4->VAR_4audioVAR_4->VAR_4nb_samplesVAR_4); VAR_4breakVAR_4; VAR_4defaultVAR_4: VAR_4returnVAR_4 VAR_4AVERRORVAR_4(VAR_4EINVALVAR_4); } VAR_4ifVAR_4 (!VAR_4outVAR_4) { VAR_4avfilter_unref_bufferVAR_4(VAR_4VAR_1VAR_4); VAR_4returnVAR_4 VAR_4AVERRORVAR_4(VAR_4ENOMEMVAR_4); } VAR_4avfilter_copy_buffer_ref_propsVAR_4(VAR_4outVAR_4, VAR_4VAR_1VAR_4); VAR_4switchVAR_4 (VAR_4VAR_0VAR_4->VAR_4typeVAR_4) { VAR_4caseVAR_4 VAR_4AVMEDIA_TYPE_VIDEOVAR_4: VAR_4av_image_copyVAR_4(VAR_4outVAR_4->VAR_4dataVAR_4, VAR_4outVAR_4->VAR_4linesizeVAR_4, VAR_4VAR_1VAR_4->VAR_4dataVAR_4, VAR_4VAR_1VAR_4->VAR_4linesizeVAR_4, VAR_4VAR_1VAR_4->VAR_4formatVAR_4, VAR_4VAR_1VAR_4->VAR_4videoVAR_4->VAR_4wVAR_4, VAR_4VAR_1VAR_4->VAR_4videoVAR_4->VAR_4hVAR_4); VAR_4breakVAR_4; VAR_4caseVAR_4 VAR_4AVMEDIA_TYPE_AUDIOVAR_4: VAR_4av_samples_copyVAR_4(VAR_4outVAR_4->VAR_4extended_dataVAR_4, VAR_4VAR_1VAR_4->VAR_4extended_dataVAR_4, VAR_40VAR_4, VAR_40VAR_4, VAR_4VAR_1VAR_4->VAR_4audioVAR_4->VAR_4nb_samplesVAR_4, VAR_4av_get_channel_layout_nb_channelsVAR_4(VAR_4VAR_1VAR_4->VAR_4audioVAR_4->VAR_4channel_layoutVAR_4), VAR_4VAR_1VAR_4->VAR_4formatVAR_4); VAR_4breakVAR_4; VAR_4defaultVAR_4: VAR_4returnVAR_4 VAR_4AVERRORVAR_4(VAR_4EINVALVAR_4); } VAR_4avfilter_unref_bufferVAR_4(VAR_4VAR_1VAR_4); } VAR_4elseVAR_4 VAR_4outVAR_4 = VAR_4VAR_1VAR_4; VAR_4whileVAR_4(VAR_4cmdVAR_4 && VAR_4cmdVAR_4->VAR_4timeVAR_4 <= VAR_4VAR_1VAR_4->VAR_4ptsVAR_4 * VAR_4av_q2dVAR_4(VAR_4VAR_0VAR_4->VAR_4time_baseVAR_4)){ VAR_4av_logVAR_4(VAR_4VAR_0VAR_4->VAR_4dstVAR_4, VAR_4AV_LOG_DEBUGVAR_4, "VAR_4ProcessingVAR_4 VAR_4commandVAR_4 VAR_4timeVAR_4:%VAR_4fVAR_4 VAR_4commandVAR_4:%VAR_4sVAR_4 VAR_4argVAR_4:%VAR_4sVAR_4\VAR_4nVAR_4", VAR_4cmdVAR_4->VAR_4timeVAR_4, VAR_4cmdVAR_4->VAR_4commandVAR_4, VAR_4cmdVAR_4->VAR_4argVAR_4); VAR_4avfilter_process_commandVAR_4(VAR_4VAR_0VAR_4->VAR_4dstVAR_4, VAR_4cmdVAR_4->VAR_4commandVAR_4, VAR_4cmdVAR_4->VAR_4argVAR_4, VAR_40VAR_4, VAR_40VAR_4, VAR_4cmdVAR_4->VAR_4flagsVAR_4); VAR_4ff_command_queue_popVAR_4(VAR_4VAR_0VAR_4->VAR_4dstVAR_4); VAR_4cmdVAR_4= VAR_4VAR_0VAR_4->VAR_4dstVAR_4->VAR_4command_queueVAR_4; } VAR_4ptsVAR_4 = VAR_4outVAR_4->VAR_4ptsVAR_4; VAR_4retVAR_4 = VAR_4VAR_2VAR_4(VAR_4VAR_0VAR_4, VAR_4outVAR_4); VAR_4ff_update_link_current_ptsVAR_4(VAR_4VAR_0VAR_4, VAR_4ptsVAR_4); VAR_4returnVAR_4 VAR_4retVAR_4; }
[ "VAR_4staticVAR_4 VAR_4intVAR_4 VAR_4ff_filter_frame_framedVAR_4(VAR_4AVFilterLinkVAR_4 *VAR_4VAR_0VAR_4, VAR_4AVFilterBufferRefVAR_4 *VAR_4VAR_1VAR_4)\n{", "VAR_4intVAR_4 (*VAR_4VAR_2VAR_4)(VAR_4AVFilterLinkVAR_4 *, VAR_4AVFilterBufferRefVAR_4 *);", "VAR_4AVFilterPadVAR_4 *VAR_4srcVAR_4 = VAR_4VAR_0VAR_4->VAR_4srcpadVAR_4;", "VAR_4AVFilterPadVAR_4 *VAR_4dstVAR_4 = VAR_4VAR_0VAR_4->VAR_4dstpadVAR_4;", "VAR_4AVFilterBufferRefVAR_4 *VAR_4outVAR_4;", "VAR_4intVAR_4 VAR_4permsVAR_4, VAR_4retVAR_4;", "VAR_4AVFilterCommandVAR_4 *VAR_4cmdVAR_4= VAR_4VAR_0VAR_4->VAR_4dstVAR_4->VAR_4command_queueVAR_4;", "VAR_4int64_tVAR_4 VAR_4ptsVAR_4;", "VAR_4ifVAR_4 (VAR_4VAR_0VAR_4->VAR_4closedVAR_4) {", "VAR_4avfilter_unref_bufferVAR_4(VAR_4VAR_1VAR_4);", "VAR_4returnVAR_4 VAR_4AVERROR_EOFVAR_4;", "}", "VAR_4ifVAR_4 (!(VAR_4VAR_2VAR_4 = VAR_4dstVAR_4->VAR_4VAR_2VAR_4))\nVAR_4VAR_2VAR_4 = VAR_4default_filter_frameVAR_4;", "VAR_4av_assert1VAR_4((VAR_4VAR_1VAR_4->VAR_4permsVAR_4 & VAR_4srcVAR_4->VAR_4min_permsVAR_4) == VAR_4srcVAR_4->VAR_4min_permsVAR_4);", "VAR_4VAR_1VAR_4->VAR_4permsVAR_4 &= ~ VAR_4srcVAR_4->VAR_4rej_permsVAR_4;", "VAR_4permsVAR_4 = VAR_4VAR_1VAR_4->VAR_4permsVAR_4;", "VAR_4ifVAR_4 (VAR_4VAR_1VAR_4->VAR_4linesizeVAR_4[VAR_40VAR_4] < VAR_40VAR_4)\nVAR_4permsVAR_4 |= VAR_4AV_PERM_NEG_LINESIZESVAR_4;", "VAR_4ifVAR_4 ((VAR_4dstVAR_4->VAR_4min_permsVAR_4 & VAR_4permsVAR_4) != VAR_4dstVAR_4->VAR_4min_permsVAR_4 ||\nVAR_4dstVAR_4->VAR_4rej_permsVAR_4 & VAR_4permsVAR_4) {", "VAR_4av_logVAR_4(VAR_4VAR_0VAR_4->VAR_4dstVAR_4, VAR_4AV_LOG_DEBUGVAR_4,\n\"VAR_4CopyingVAR_4 VAR_4dataVAR_4 VAR_4inVAR_4 VAR_4avfilterVAR_4 (VAR_4haveVAR_4 VAR_4permsVAR_4 %VAR_4xVAR_4, VAR_4needVAR_4 %VAR_4xVAR_4, VAR_4rejectVAR_4 %VAR_4xVAR_4)\\VAR_4nVAR_4\",\nVAR_4permsVAR_4, VAR_4VAR_0VAR_4->VAR_4dstpadVAR_4->VAR_4min_permsVAR_4, VAR_4VAR_0VAR_4->VAR_4dstpadVAR_4->VAR_4rej_permsVAR_4);", "VAR_4switchVAR_4 (VAR_4VAR_0VAR_4->VAR_4typeVAR_4) {", "VAR_4caseVAR_4 VAR_4AVMEDIA_TYPE_VIDEOVAR_4:\nVAR_4outVAR_4 = VAR_4ff_get_video_bufferVAR_4(VAR_4VAR_0VAR_4, VAR_4dstVAR_4->VAR_4min_permsVAR_4,\nVAR_4VAR_0VAR_4->VAR_4wVAR_4, VAR_4VAR_0VAR_4->VAR_4hVAR_4);", "VAR_4breakVAR_4;", "VAR_4caseVAR_4 VAR_4AVMEDIA_TYPE_AUDIOVAR_4:\nVAR_4outVAR_4 = VAR_4ff_get_audio_bufferVAR_4(VAR_4VAR_0VAR_4, VAR_4dstVAR_4->VAR_4min_permsVAR_4,\nVAR_4VAR_1VAR_4->VAR_4audioVAR_4->VAR_4nb_samplesVAR_4);", "VAR_4breakVAR_4;", "VAR_4defaultVAR_4: VAR_4returnVAR_4 VAR_4AVERRORVAR_4(VAR_4EINVALVAR_4);", "}", "VAR_4ifVAR_4 (!VAR_4outVAR_4) {", "VAR_4avfilter_unref_bufferVAR_4(VAR_4VAR_1VAR_4);", "VAR_4returnVAR_4 VAR_4AVERRORVAR_4(VAR_4ENOMEMVAR_4);", "}", "VAR_4avfilter_copy_buffer_ref_propsVAR_4(VAR_4outVAR_4, VAR_4VAR_1VAR_4);", "VAR_4switchVAR_4 (VAR_4VAR_0VAR_4->VAR_4typeVAR_4) {", "VAR_4caseVAR_4 VAR_4AVMEDIA_TYPE_VIDEOVAR_4:\nVAR_4av_image_copyVAR_4(VAR_4outVAR_4->VAR_4dataVAR_4, VAR_4outVAR_4->VAR_4linesizeVAR_4, VAR_4VAR_1VAR_4->VAR_4dataVAR_4, VAR_4VAR_1VAR_4->VAR_4linesizeVAR_4,\nVAR_4VAR_1VAR_4->VAR_4formatVAR_4, VAR_4VAR_1VAR_4->VAR_4videoVAR_4->VAR_4wVAR_4, VAR_4VAR_1VAR_4->VAR_4videoVAR_4->VAR_4hVAR_4);", "VAR_4breakVAR_4;", "VAR_4caseVAR_4 VAR_4AVMEDIA_TYPE_AUDIOVAR_4:\nVAR_4av_samples_copyVAR_4(VAR_4outVAR_4->VAR_4extended_dataVAR_4, VAR_4VAR_1VAR_4->VAR_4extended_dataVAR_4,\nVAR_40VAR_4, VAR_40VAR_4, VAR_4VAR_1VAR_4->VAR_4audioVAR_4->VAR_4nb_samplesVAR_4,\nVAR_4av_get_channel_layout_nb_channelsVAR_4(VAR_4VAR_1VAR_4->VAR_4audioVAR_4->VAR_4channel_layoutVAR_4),\nVAR_4VAR_1VAR_4->VAR_4formatVAR_4);", "VAR_4breakVAR_4;", "VAR_4defaultVAR_4: VAR_4returnVAR_4 VAR_4AVERRORVAR_4(VAR_4EINVALVAR_4);", "}", "VAR_4avfilter_unref_bufferVAR_4(VAR_4VAR_1VAR_4);", "} VAR_4elseVAR_4", "VAR_4outVAR_4 = VAR_4VAR_1VAR_4;", "VAR_4whileVAR_4(VAR_4cmdVAR_4 && VAR_4cmdVAR_4->VAR_4timeVAR_4 <= VAR_4VAR_1VAR_4->VAR_4ptsVAR_4 * VAR_4av_q2dVAR_4(VAR_4VAR_0VAR_4->VAR_4time_baseVAR_4)){", "VAR_4av_logVAR_4(VAR_4VAR_0VAR_4->VAR_4dstVAR_4, VAR_4AV_LOG_DEBUGVAR_4,\n\"VAR_4ProcessingVAR_4 VAR_4commandVAR_4 VAR_4timeVAR_4:%VAR_4fVAR_4 VAR_4commandVAR_4:%VAR_4sVAR_4 VAR_4argVAR_4:%VAR_4sVAR_4\\VAR_4nVAR_4\",\nVAR_4cmdVAR_4->VAR_4timeVAR_4, VAR_4cmdVAR_4->VAR_4commandVAR_4, VAR_4cmdVAR_4->VAR_4argVAR_4);", "VAR_4avfilter_process_commandVAR_4(VAR_4VAR_0VAR_4->VAR_4dstVAR_4, VAR_4cmdVAR_4->VAR_4commandVAR_4, VAR_4cmdVAR_4->VAR_4argVAR_4, VAR_40VAR_4, VAR_40VAR_4, VAR_4cmdVAR_4->VAR_4flagsVAR_4);", "VAR_4ff_command_queue_popVAR_4(VAR_4VAR_0VAR_4->VAR_4dstVAR_4);", "VAR_4cmdVAR_4= VAR_4VAR_0VAR_4->VAR_4dstVAR_4->VAR_4command_queueVAR_4;", "}", "VAR_4ptsVAR_4 = VAR_4outVAR_4->VAR_4ptsVAR_4;", "VAR_4retVAR_4 = VAR_4VAR_2VAR_4(VAR_4VAR_0VAR_4, VAR_4outVAR_4);", "VAR_4ff_update_link_current_ptsVAR_4(VAR_4VAR_0VAR_4, VAR_4ptsVAR_4);", "VAR_4returnVAR_4 VAR_4retVAR_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, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 31, 33 ], [ 37 ], [ 39 ], [ 41 ], [ 45, 47 ], [ 53, 55 ], [ 57, 59, 61 ], [ 67 ], [ 69, 71, 73 ], [ 75 ], [ 77, 79, 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 101 ], [ 103, 105, 107 ], [ 109 ], [ 111, 113, 115, 117, 119 ], [ 121 ], [ 123 ], [ 125 ], [ 129 ], [ 131 ], [ 133 ], [ 137 ], [ 139, 141, 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ] ]
630
void bdrv_get_backing_filename(BlockDriverState *bs, char *filename, int filename_size) { if (!bs->backing_hd) { pstrcpy(filename, filename_size, ""); } else { pstrcpy(filename, filename_size, bs->backing_file); } }
true
qemu
b783e409bf17b92f4af8dc5d6bd040d0092f33e0
void bdrv_get_backing_filename(BlockDriverState *bs, char *filename, int filename_size) { if (!bs->backing_hd) { pstrcpy(filename, filename_size, ""); } else { pstrcpy(filename, filename_size, bs->backing_file); } }
{ "code": [ " if (!bs->backing_hd) {" ], "line_no": [ 7 ] }
void FUNC_0(BlockDriverState *VAR_0, char *VAR_1, int VAR_2) { if (!VAR_0->backing_hd) { pstrcpy(VAR_1, VAR_2, ""); } else { pstrcpy(VAR_1, VAR_2, VAR_0->backing_file); } }
[ "void FUNC_0(BlockDriverState *VAR_0,\nchar *VAR_1, int VAR_2)\n{", "if (!VAR_0->backing_hd) {", "pstrcpy(VAR_1, VAR_2, \"\");", "} else {", "pstrcpy(VAR_1, VAR_2, VAR_0->backing_file);", "}", "}" ]
[ 0, 1, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ] ]
631
static uint32_t e1000e_macreg_read(e1000e_device *d, uint32_t reg) { return qpci_io_readl(d->pci_dev, d->mac_regs + reg); }
true
qemu
b4ba67d9a702507793c2724e56f98e9b0f7be02b
static uint32_t e1000e_macreg_read(e1000e_device *d, uint32_t reg) { return qpci_io_readl(d->pci_dev, d->mac_regs + reg); }
{ "code": [ " return qpci_io_readl(d->pci_dev, d->mac_regs + reg);" ], "line_no": [ 5 ] }
static uint32_t FUNC_0(e1000e_device *d, uint32_t reg) { return qpci_io_readl(d->pci_dev, d->mac_regs + reg); }
[ "static uint32_t FUNC_0(e1000e_device *d, uint32_t reg)\n{", "return qpci_io_readl(d->pci_dev, d->mac_regs + reg);", "}" ]
[ 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
632
static inline void direct_ref_list_init(H264Context * const h){ MpegEncContext * const s = &h->s; Picture * const ref1 = &h->ref_list[1][0]; Picture * const cur = s->current_picture_ptr; int list, i, j; if(cur->pict_type == I_TYPE) cur->ref_count[0] = 0; if(cur->pict_type != B_TYPE) cur->ref_count[1] = 0; for(list=0; list<2; list++){ cur->ref_count[list] = h->ref_count[list]; for(j=0; j<h->ref_count[list]; j++) cur->ref_poc[list][j] = h->ref_list[list][j].poc; } if(cur->pict_type != B_TYPE || h->direct_spatial_mv_pred) return; for(list=0; list<2; list++){ for(i=0; i<ref1->ref_count[list]; i++){ const int poc = ref1->ref_poc[list][i]; h->map_col_to_list0[list][i] = PART_NOT_AVAILABLE; for(j=0; j<h->ref_count[list]; j++) if(h->ref_list[list][j].poc == poc){ h->map_col_to_list0[list][i] = j; break; } } } }
true
FFmpeg
171c407621b7ff52a0cf128b31651ca927c2dd49
static inline void direct_ref_list_init(H264Context * const h){ MpegEncContext * const s = &h->s; Picture * const ref1 = &h->ref_list[1][0]; Picture * const cur = s->current_picture_ptr; int list, i, j; if(cur->pict_type == I_TYPE) cur->ref_count[0] = 0; if(cur->pict_type != B_TYPE) cur->ref_count[1] = 0; for(list=0; list<2; list++){ cur->ref_count[list] = h->ref_count[list]; for(j=0; j<h->ref_count[list]; j++) cur->ref_poc[list][j] = h->ref_list[list][j].poc; } if(cur->pict_type != B_TYPE || h->direct_spatial_mv_pred) return; for(list=0; list<2; list++){ for(i=0; i<ref1->ref_count[list]; i++){ const int poc = ref1->ref_poc[list][i]; h->map_col_to_list0[list][i] = PART_NOT_AVAILABLE; for(j=0; j<h->ref_count[list]; j++) if(h->ref_list[list][j].poc == poc){ h->map_col_to_list0[list][i] = j; break; } } } }
{ "code": [ " h->map_col_to_list0[list][i] = PART_NOT_AVAILABLE;" ], "line_no": [ 39 ] }
static inline void FUNC_0(H264Context * const VAR_0){ MpegEncContext * const s = &VAR_0->s; Picture * const ref1 = &VAR_0->ref_list[1][0]; Picture * const cur = s->current_picture_ptr; int VAR_1, VAR_2, VAR_3; if(cur->pict_type == I_TYPE) cur->ref_count[0] = 0; if(cur->pict_type != B_TYPE) cur->ref_count[1] = 0; for(VAR_1=0; VAR_1<2; VAR_1++){ cur->ref_count[VAR_1] = VAR_0->ref_count[VAR_1]; for(VAR_3=0; VAR_3<VAR_0->ref_count[VAR_1]; VAR_3++) cur->ref_poc[VAR_1][VAR_3] = VAR_0->ref_list[VAR_1][VAR_3].poc; } if(cur->pict_type != B_TYPE || VAR_0->direct_spatial_mv_pred) return; for(VAR_1=0; VAR_1<2; VAR_1++){ for(VAR_2=0; VAR_2<ref1->ref_count[VAR_1]; VAR_2++){ const int poc = ref1->ref_poc[VAR_1][VAR_2]; VAR_0->map_col_to_list0[VAR_1][VAR_2] = PART_NOT_AVAILABLE; for(VAR_3=0; VAR_3<VAR_0->ref_count[VAR_1]; VAR_3++) if(VAR_0->ref_list[VAR_1][VAR_3].poc == poc){ VAR_0->map_col_to_list0[VAR_1][VAR_2] = VAR_3; break; } } } }
[ "static inline void FUNC_0(H264Context * const VAR_0){", "MpegEncContext * const s = &VAR_0->s;", "Picture * const ref1 = &VAR_0->ref_list[1][0];", "Picture * const cur = s->current_picture_ptr;", "int VAR_1, VAR_2, VAR_3;", "if(cur->pict_type == I_TYPE)\ncur->ref_count[0] = 0;", "if(cur->pict_type != B_TYPE)\ncur->ref_count[1] = 0;", "for(VAR_1=0; VAR_1<2; VAR_1++){", "cur->ref_count[VAR_1] = VAR_0->ref_count[VAR_1];", "for(VAR_3=0; VAR_3<VAR_0->ref_count[VAR_1]; VAR_3++)", "cur->ref_poc[VAR_1][VAR_3] = VAR_0->ref_list[VAR_1][VAR_3].poc;", "}", "if(cur->pict_type != B_TYPE || VAR_0->direct_spatial_mv_pred)\nreturn;", "for(VAR_1=0; VAR_1<2; VAR_1++){", "for(VAR_2=0; VAR_2<ref1->ref_count[VAR_1]; VAR_2++){", "const int poc = ref1->ref_poc[VAR_1][VAR_2];", "VAR_0->map_col_to_list0[VAR_1][VAR_2] = PART_NOT_AVAILABLE;", "for(VAR_3=0; VAR_3<VAR_0->ref_count[VAR_1]; VAR_3++)", "if(VAR_0->ref_list[VAR_1][VAR_3].poc == poc){", "VAR_0->map_col_to_list0[VAR_1][VAR_2] = VAR_3;", "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 ]
[ [ 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 ] ]
633
static void encode_rgb48_10bit(AVCodecContext *avctx, const AVPicture *pic, uint8_t *dst) { DPXContext *s = avctx->priv_data; const uint8_t *src = pic->data[0]; int x, y; for (y = 0; y < avctx->height; y++) { for (x = 0; x < avctx->width; x++) { int value; if (s->big_endian) { value = ((AV_RB16(src + 6*x + 4) & 0xFFC0) >> 4) | ((AV_RB16(src + 6*x + 2) & 0xFFC0) << 6) | ((AV_RB16(src + 6*x + 0) & 0xFFC0) << 16); } else { value = ((AV_RL16(src + 6*x + 4) & 0xFFC0) >> 4) | ((AV_RL16(src + 6*x + 2) & 0xFFC0) << 6) | ((AV_RL16(src + 6*x + 0) & 0xFFC0) << 16); } write32(dst, value); dst += 4; } src += pic->linesize[0]; } }
true
FFmpeg
2217a2249dd78c3719f865569b661b8adcda4962
static void encode_rgb48_10bit(AVCodecContext *avctx, const AVPicture *pic, uint8_t *dst) { DPXContext *s = avctx->priv_data; const uint8_t *src = pic->data[0]; int x, y; for (y = 0; y < avctx->height; y++) { for (x = 0; x < avctx->width; x++) { int value; if (s->big_endian) { value = ((AV_RB16(src + 6*x + 4) & 0xFFC0) >> 4) | ((AV_RB16(src + 6*x + 2) & 0xFFC0) << 6) | ((AV_RB16(src + 6*x + 0) & 0xFFC0) << 16); } else { value = ((AV_RL16(src + 6*x + 4) & 0xFFC0) >> 4) | ((AV_RL16(src + 6*x + 2) & 0xFFC0) << 6) | ((AV_RL16(src + 6*x + 0) & 0xFFC0) << 16); } write32(dst, value); dst += 4; } src += pic->linesize[0]; } }
{ "code": [ " value = ((AV_RB16(src + 6*x + 4) & 0xFFC0) >> 4)", " | ((AV_RB16(src + 6*x + 2) & 0xFFC0) << 6)", " | ((AV_RB16(src + 6*x + 0) & 0xFFC0) << 16);", " value = ((AV_RL16(src + 6*x + 4) & 0xFFC0) >> 4)", " | ((AV_RL16(src + 6*x + 2) & 0xFFC0) << 6)", " | ((AV_RL16(src + 6*x + 0) & 0xFFC0) << 16);" ], "line_no": [ 21, 23, 25, 29, 31, 33 ] }
static void FUNC_0(AVCodecContext *VAR_0, const AVPicture *VAR_1, uint8_t *VAR_2) { DPXContext *s = VAR_0->priv_data; const uint8_t *VAR_3 = VAR_1->data[0]; int VAR_4, VAR_5; for (VAR_5 = 0; VAR_5 < VAR_0->height; VAR_5++) { for (VAR_4 = 0; VAR_4 < VAR_0->width; VAR_4++) { int value; if (s->big_endian) { value = ((AV_RB16(VAR_3 + 6*VAR_4 + 4) & 0xFFC0) >> 4) | ((AV_RB16(VAR_3 + 6*VAR_4 + 2) & 0xFFC0) << 6) | ((AV_RB16(VAR_3 + 6*VAR_4 + 0) & 0xFFC0) << 16); } else { value = ((AV_RL16(VAR_3 + 6*VAR_4 + 4) & 0xFFC0) >> 4) | ((AV_RL16(VAR_3 + 6*VAR_4 + 2) & 0xFFC0) << 6) | ((AV_RL16(VAR_3 + 6*VAR_4 + 0) & 0xFFC0) << 16); } write32(VAR_2, value); VAR_2 += 4; } VAR_3 += VAR_1->linesize[0]; } }
[ "static void FUNC_0(AVCodecContext *VAR_0, const AVPicture *VAR_1, uint8_t *VAR_2)\n{", "DPXContext *s = VAR_0->priv_data;", "const uint8_t *VAR_3 = VAR_1->data[0];", "int VAR_4, VAR_5;", "for (VAR_5 = 0; VAR_5 < VAR_0->height; VAR_5++) {", "for (VAR_4 = 0; VAR_4 < VAR_0->width; VAR_4++) {", "int value;", "if (s->big_endian) {", "value = ((AV_RB16(VAR_3 + 6*VAR_4 + 4) & 0xFFC0) >> 4)\n| ((AV_RB16(VAR_3 + 6*VAR_4 + 2) & 0xFFC0) << 6)\n| ((AV_RB16(VAR_3 + 6*VAR_4 + 0) & 0xFFC0) << 16);", "} else {", "value = ((AV_RL16(VAR_3 + 6*VAR_4 + 4) & 0xFFC0) >> 4)\n| ((AV_RL16(VAR_3 + 6*VAR_4 + 2) & 0xFFC0) << 6)\n| ((AV_RL16(VAR_3 + 6*VAR_4 + 0) & 0xFFC0) << 16);", "}", "write32(VAR_2, value);", "VAR_2 += 4;", "}", "VAR_3 += VAR_1->linesize[0];", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 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 ] ]
634
static int tgv_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; TgvContext *s = avctx->priv_data; const uint8_t *buf_end = buf + buf_size; int chunk_type; if (buf_end - buf < EA_PREAMBLE_SIZE) return AVERROR_INVALIDDATA; chunk_type = AV_RL32(&buf[0]); buf += EA_PREAMBLE_SIZE; if (chunk_type==kVGT_TAG) { int pal_count, i; if(buf_end - buf < 12) { av_log(avctx, AV_LOG_WARNING, "truncated header\n"); return -1; } s->width = AV_RL16(&buf[0]); s->height = AV_RL16(&buf[2]); if (s->avctx->width!=s->width || s->avctx->height!=s->height) { avcodec_set_dimensions(s->avctx, s->width, s->height); cond_release_buffer(&s->frame); cond_release_buffer(&s->last_frame); } pal_count = AV_RL16(&buf[6]); buf += 12; for(i=0; i<pal_count && i<AVPALETTE_COUNT && buf_end - buf >= 3; i++) { s->palette[i] = 0xFF << 24 | AV_RB24(buf); buf += 3; } } if (av_image_check_size(s->width, s->height, 0, avctx)) return -1; /* shuffle */ FFSWAP(AVFrame, s->frame, s->last_frame); if (!s->frame.data[0]) { s->frame.reference = 3; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID; s->frame.linesize[0] = s->width; /* allocate additional 12 bytes to accommodate av_memcpy_backptr() OUTBUF_PADDED optimisation */ s->frame.data[0] = av_malloc(s->width*s->height + 12); if (!s->frame.data[0]) return AVERROR(ENOMEM); s->frame.data[1] = av_malloc(AVPALETTE_SIZE); if (!s->frame.data[1]) { av_freep(&s->frame.data[0]); return AVERROR(ENOMEM); } } memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE); if(chunk_type==kVGT_TAG) { s->frame.key_frame = 1; s->frame.pict_type = AV_PICTURE_TYPE_I; if (unpack(buf, buf_end, s->frame.data[0], s->avctx->width, s->avctx->height)<0) { av_log(avctx, AV_LOG_WARNING, "truncated intra frame\n"); return -1; } }else{ if (!s->last_frame.data[0]) { av_log(avctx, AV_LOG_WARNING, "inter frame without corresponding intra frame\n"); return buf_size; } s->frame.key_frame = 0; s->frame.pict_type = AV_PICTURE_TYPE_P; if (tgv_decode_inter(s, buf, buf_end)<0) { av_log(avctx, AV_LOG_WARNING, "truncated inter frame\n"); return -1; } } *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; return buf_size; }
true
FFmpeg
b12d92efd6c0d48665383a9baecc13e7ebbd8a22
static int tgv_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; TgvContext *s = avctx->priv_data; const uint8_t *buf_end = buf + buf_size; int chunk_type; if (buf_end - buf < EA_PREAMBLE_SIZE) return AVERROR_INVALIDDATA; chunk_type = AV_RL32(&buf[0]); buf += EA_PREAMBLE_SIZE; if (chunk_type==kVGT_TAG) { int pal_count, i; if(buf_end - buf < 12) { av_log(avctx, AV_LOG_WARNING, "truncated header\n"); return -1; } s->width = AV_RL16(&buf[0]); s->height = AV_RL16(&buf[2]); if (s->avctx->width!=s->width || s->avctx->height!=s->height) { avcodec_set_dimensions(s->avctx, s->width, s->height); cond_release_buffer(&s->frame); cond_release_buffer(&s->last_frame); } pal_count = AV_RL16(&buf[6]); buf += 12; for(i=0; i<pal_count && i<AVPALETTE_COUNT && buf_end - buf >= 3; i++) { s->palette[i] = 0xFF << 24 | AV_RB24(buf); buf += 3; } } if (av_image_check_size(s->width, s->height, 0, avctx)) return -1; FFSWAP(AVFrame, s->frame, s->last_frame); if (!s->frame.data[0]) { s->frame.reference = 3; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID; s->frame.linesize[0] = s->width; s->frame.data[0] = av_malloc(s->width*s->height + 12); if (!s->frame.data[0]) return AVERROR(ENOMEM); s->frame.data[1] = av_malloc(AVPALETTE_SIZE); if (!s->frame.data[1]) { av_freep(&s->frame.data[0]); return AVERROR(ENOMEM); } } memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE); if(chunk_type==kVGT_TAG) { s->frame.key_frame = 1; s->frame.pict_type = AV_PICTURE_TYPE_I; if (unpack(buf, buf_end, s->frame.data[0], s->avctx->width, s->avctx->height)<0) { av_log(avctx, AV_LOG_WARNING, "truncated intra frame\n"); return -1; } }else{ if (!s->last_frame.data[0]) { av_log(avctx, AV_LOG_WARNING, "inter frame without corresponding intra frame\n"); return buf_size; } s->frame.key_frame = 0; s->frame.pict_type = AV_PICTURE_TYPE_P; if (tgv_decode_inter(s, buf, buf_end)<0) { av_log(avctx, AV_LOG_WARNING, "truncated inter frame\n"); return -1; } } *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; return buf_size; }
{ "code": [ " s->palette[i] = 0xFF << 24 | AV_RB24(buf);" ], "line_no": [ 69 ] }
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, AVPacket *VAR_3) { const uint8_t *VAR_4 = VAR_3->VAR_1; int VAR_5 = VAR_3->size; TgvContext *s = VAR_0->priv_data; const uint8_t *VAR_6 = VAR_4 + VAR_5; int VAR_7; if (VAR_6 - VAR_4 < EA_PREAMBLE_SIZE) return AVERROR_INVALIDDATA; VAR_7 = AV_RL32(&VAR_4[0]); VAR_4 += EA_PREAMBLE_SIZE; if (VAR_7==kVGT_TAG) { int VAR_8, VAR_9; if(VAR_6 - VAR_4 < 12) { av_log(VAR_0, AV_LOG_WARNING, "truncated header\n"); return -1; } s->width = AV_RL16(&VAR_4[0]); s->height = AV_RL16(&VAR_4[2]); if (s->VAR_0->width!=s->width || s->VAR_0->height!=s->height) { avcodec_set_dimensions(s->VAR_0, s->width, s->height); cond_release_buffer(&s->frame); cond_release_buffer(&s->last_frame); } VAR_8 = AV_RL16(&VAR_4[6]); VAR_4 += 12; for(VAR_9=0; VAR_9<VAR_8 && VAR_9<AVPALETTE_COUNT && VAR_6 - VAR_4 >= 3; VAR_9++) { s->palette[VAR_9] = 0xFF << 24 | AV_RB24(VAR_4); VAR_4 += 3; } } if (av_image_check_size(s->width, s->height, 0, VAR_0)) return -1; FFSWAP(AVFrame, s->frame, s->last_frame); if (!s->frame.VAR_1[0]) { s->frame.reference = 3; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID; s->frame.linesize[0] = s->width; s->frame.VAR_1[0] = av_malloc(s->width*s->height + 12); if (!s->frame.VAR_1[0]) return AVERROR(ENOMEM); s->frame.VAR_1[1] = av_malloc(AVPALETTE_SIZE); if (!s->frame.VAR_1[1]) { av_freep(&s->frame.VAR_1[0]); return AVERROR(ENOMEM); } } memcpy(s->frame.VAR_1[1], s->palette, AVPALETTE_SIZE); if(VAR_7==kVGT_TAG) { s->frame.key_frame = 1; s->frame.pict_type = AV_PICTURE_TYPE_I; if (unpack(VAR_4, VAR_6, s->frame.VAR_1[0], s->VAR_0->width, s->VAR_0->height)<0) { av_log(VAR_0, AV_LOG_WARNING, "truncated intra frame\n"); return -1; } }else{ if (!s->last_frame.VAR_1[0]) { av_log(VAR_0, AV_LOG_WARNING, "inter frame without corresponding intra frame\n"); return VAR_5; } s->frame.key_frame = 0; s->frame.pict_type = AV_PICTURE_TYPE_P; if (tgv_decode_inter(s, VAR_4, VAR_6)<0) { av_log(VAR_0, AV_LOG_WARNING, "truncated inter frame\n"); return -1; } } *VAR_2 = sizeof(AVFrame); *(AVFrame*)VAR_1 = s->frame; return VAR_5; }
[ "static 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->size;", "TgvContext *s = VAR_0->priv_data;", "const uint8_t *VAR_6 = VAR_4 + VAR_5;", "int VAR_7;", "if (VAR_6 - VAR_4 < EA_PREAMBLE_SIZE)\nreturn AVERROR_INVALIDDATA;", "VAR_7 = AV_RL32(&VAR_4[0]);", "VAR_4 += EA_PREAMBLE_SIZE;", "if (VAR_7==kVGT_TAG) {", "int VAR_8, VAR_9;", "if(VAR_6 - VAR_4 < 12) {", "av_log(VAR_0, AV_LOG_WARNING, \"truncated header\\n\");", "return -1;", "}", "s->width = AV_RL16(&VAR_4[0]);", "s->height = AV_RL16(&VAR_4[2]);", "if (s->VAR_0->width!=s->width || s->VAR_0->height!=s->height) {", "avcodec_set_dimensions(s->VAR_0, s->width, s->height);", "cond_release_buffer(&s->frame);", "cond_release_buffer(&s->last_frame);", "}", "VAR_8 = AV_RL16(&VAR_4[6]);", "VAR_4 += 12;", "for(VAR_9=0; VAR_9<VAR_8 && VAR_9<AVPALETTE_COUNT && VAR_6 - VAR_4 >= 3; VAR_9++) {", "s->palette[VAR_9] = 0xFF << 24 | AV_RB24(VAR_4);", "VAR_4 += 3;", "}", "}", "if (av_image_check_size(s->width, s->height, 0, VAR_0))\nreturn -1;", "FFSWAP(AVFrame, s->frame, s->last_frame);", "if (!s->frame.VAR_1[0]) {", "s->frame.reference = 3;", "s->frame.buffer_hints = FF_BUFFER_HINTS_VALID;", "s->frame.linesize[0] = s->width;", "s->frame.VAR_1[0] = av_malloc(s->width*s->height + 12);", "if (!s->frame.VAR_1[0])\nreturn AVERROR(ENOMEM);", "s->frame.VAR_1[1] = av_malloc(AVPALETTE_SIZE);", "if (!s->frame.VAR_1[1]) {", "av_freep(&s->frame.VAR_1[0]);", "return AVERROR(ENOMEM);", "}", "}", "memcpy(s->frame.VAR_1[1], s->palette, AVPALETTE_SIZE);", "if(VAR_7==kVGT_TAG) {", "s->frame.key_frame = 1;", "s->frame.pict_type = AV_PICTURE_TYPE_I;", "if (unpack(VAR_4, VAR_6, s->frame.VAR_1[0], s->VAR_0->width, s->VAR_0->height)<0) {", "av_log(VAR_0, AV_LOG_WARNING, \"truncated intra frame\\n\");", "return -1;", "}", "}else{", "if (!s->last_frame.VAR_1[0]) {", "av_log(VAR_0, AV_LOG_WARNING, \"inter frame without corresponding intra frame\\n\");", "return VAR_5;", "}", "s->frame.key_frame = 0;", "s->frame.pict_type = AV_PICTURE_TYPE_P;", "if (tgv_decode_inter(s, VAR_4, VAR_6)<0) {", "av_log(VAR_0, AV_LOG_WARNING, \"truncated inter frame\\n\");", "return -1;", "}", "}", "*VAR_2 = sizeof(AVFrame);", "*(AVFrame*)VAR_1 = s->frame;", "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, 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 ], [ 13 ], [ 15 ], [ 17 ], [ 21, 23 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79, 81 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 101 ], [ 103, 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 163 ], [ 165 ], [ 169 ], [ 171 ] ]
635
static void adjust_frame_information(ChannelElement *cpe, int chans) { int i, w, w2, g, ch; int start, maxsfb, cmaxsfb; for (ch = 0; ch < chans; ch++) { IndividualChannelStream *ics = &cpe->ch[ch].ics; start = 0; maxsfb = 0; cpe->ch[ch].pulse.num_pulse = 0; for (w = 0; w < ics->num_windows*16; w += 16) { for (g = 0; g < ics->num_swb; g++) { //apply M/S if (cpe->common_window && !ch && cpe->ms_mask[w + g]) { for (i = 0; i < ics->swb_sizes[g]; i++) { cpe->ch[0].coeffs[start+i] = (cpe->ch[0].coeffs[start+i] + cpe->ch[1].coeffs[start+i]) / 2.0; cpe->ch[1].coeffs[start+i] = cpe->ch[0].coeffs[start+i] - cpe->ch[1].coeffs[start+i]; } } start += ics->swb_sizes[g]; } for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w+cmaxsfb-1]; cmaxsfb--) ; maxsfb = FFMAX(maxsfb, cmaxsfb); } ics->max_sfb = maxsfb; //adjust zero bands for window groups for (w = 0; w < ics->num_windows; w += ics->group_len[w]) { for (g = 0; g < ics->max_sfb; g++) { i = 1; for (w2 = w; w2 < w + ics->group_len[w]; w2++) { if (!cpe->ch[ch].zeroes[w2*16 + g]) { i = 0; break; } } cpe->ch[ch].zeroes[w*16 + g] = i; } } } if (chans > 1 && cpe->common_window) { IndividualChannelStream *ics0 = &cpe->ch[0].ics; IndividualChannelStream *ics1 = &cpe->ch[1].ics; int msc = 0; ics0->max_sfb = FFMAX(ics0->max_sfb, ics1->max_sfb); ics1->max_sfb = ics0->max_sfb; for (w = 0; w < ics0->num_windows*16; w += 16) for (i = 0; i < ics0->max_sfb; i++) if (cpe->ms_mask[w+i]) msc++; if (msc == 0 || ics0->max_sfb == 0) cpe->ms_mode = 0; else cpe->ms_mode = msc < ics0->max_sfb * ics0->num_windows ? 1 : 2; } }
true
FFmpeg
6394acaf36da3106f4793bda32730f8ff6b0ddb1
static void adjust_frame_information(ChannelElement *cpe, int chans) { int i, w, w2, g, ch; int start, maxsfb, cmaxsfb; for (ch = 0; ch < chans; ch++) { IndividualChannelStream *ics = &cpe->ch[ch].ics; start = 0; maxsfb = 0; cpe->ch[ch].pulse.num_pulse = 0; for (w = 0; w < ics->num_windows*16; w += 16) { for (g = 0; g < ics->num_swb; g++) { if (cpe->common_window && !ch && cpe->ms_mask[w + g]) { for (i = 0; i < ics->swb_sizes[g]; i++) { cpe->ch[0].coeffs[start+i] = (cpe->ch[0].coeffs[start+i] + cpe->ch[1].coeffs[start+i]) / 2.0; cpe->ch[1].coeffs[start+i] = cpe->ch[0].coeffs[start+i] - cpe->ch[1].coeffs[start+i]; } } start += ics->swb_sizes[g]; } for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w+cmaxsfb-1]; cmaxsfb--) ; maxsfb = FFMAX(maxsfb, cmaxsfb); } ics->max_sfb = maxsfb; for (w = 0; w < ics->num_windows; w += ics->group_len[w]) { for (g = 0; g < ics->max_sfb; g++) { i = 1; for (w2 = w; w2 < w + ics->group_len[w]; w2++) { if (!cpe->ch[ch].zeroes[w2*16 + g]) { i = 0; break; } } cpe->ch[ch].zeroes[w*16 + g] = i; } } } if (chans > 1 && cpe->common_window) { IndividualChannelStream *ics0 = &cpe->ch[0].ics; IndividualChannelStream *ics1 = &cpe->ch[1].ics; int msc = 0; ics0->max_sfb = FFMAX(ics0->max_sfb, ics1->max_sfb); ics1->max_sfb = ics0->max_sfb; for (w = 0; w < ics0->num_windows*16; w += 16) for (i = 0; i < ics0->max_sfb; i++) if (cpe->ms_mask[w+i]) msc++; if (msc == 0 || ics0->max_sfb == 0) cpe->ms_mode = 0; else cpe->ms_mode = msc < ics0->max_sfb * ics0->num_windows ? 1 : 2; } }
{ "code": [ " for (w = 0; w < ics->num_windows*16; w += 16) {", " for (g = 0; g < ics->num_swb; g++) {", " if (cpe->common_window && !ch && cpe->ms_mask[w + g]) {", " for (i = 0; i < ics->swb_sizes[g]; i++) {", " cpe->ch[0].coeffs[start+i] = (cpe->ch[0].coeffs[start+i] + cpe->ch[1].coeffs[start+i]) / 2.0;", " cpe->ch[1].coeffs[start+i] = cpe->ch[0].coeffs[start+i] - cpe->ch[1].coeffs[start+i];", " start += ics->swb_sizes[g];", " for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w+cmaxsfb-1]; cmaxsfb--)", " maxsfb = FFMAX(maxsfb, cmaxsfb);" ], "line_no": [ 21, 23, 27, 29, 31, 33, 39, 43, 47 ] }
static void FUNC_0(ChannelElement *VAR_0, int VAR_1) { int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6; int VAR_7, VAR_8, VAR_9; for (VAR_6 = 0; VAR_6 < VAR_1; VAR_6++) { IndividualChannelStream *ics = &VAR_0->VAR_6[VAR_6].ics; VAR_7 = 0; VAR_8 = 0; VAR_0->VAR_6[VAR_6].pulse.num_pulse = 0; for (VAR_3 = 0; VAR_3 < ics->num_windows*16; VAR_3 += 16) { for (VAR_5 = 0; VAR_5 < ics->num_swb; VAR_5++) { if (VAR_0->common_window && !VAR_6 && VAR_0->ms_mask[VAR_3 + VAR_5]) { for (VAR_2 = 0; VAR_2 < ics->swb_sizes[VAR_5]; VAR_2++) { VAR_0->VAR_6[0].coeffs[VAR_7+VAR_2] = (VAR_0->VAR_6[0].coeffs[VAR_7+VAR_2] + VAR_0->VAR_6[1].coeffs[VAR_7+VAR_2]) / 2.0; VAR_0->VAR_6[1].coeffs[VAR_7+VAR_2] = VAR_0->VAR_6[0].coeffs[VAR_7+VAR_2] - VAR_0->VAR_6[1].coeffs[VAR_7+VAR_2]; } } VAR_7 += ics->swb_sizes[VAR_5]; } for (VAR_9 = ics->num_swb; VAR_9 > 0 && VAR_0->VAR_6[VAR_6].zeroes[VAR_3+VAR_9-1]; VAR_9--) ; VAR_8 = FFMAX(VAR_8, VAR_9); } ics->max_sfb = VAR_8; for (VAR_3 = 0; VAR_3 < ics->num_windows; VAR_3 += ics->group_len[VAR_3]) { for (VAR_5 = 0; VAR_5 < ics->max_sfb; VAR_5++) { VAR_2 = 1; for (VAR_4 = VAR_3; VAR_4 < VAR_3 + ics->group_len[VAR_3]; VAR_4++) { if (!VAR_0->VAR_6[VAR_6].zeroes[VAR_4*16 + VAR_5]) { VAR_2 = 0; break; } } VAR_0->VAR_6[VAR_6].zeroes[VAR_3*16 + VAR_5] = VAR_2; } } } if (VAR_1 > 1 && VAR_0->common_window) { IndividualChannelStream *ics0 = &VAR_0->VAR_6[0].ics; IndividualChannelStream *ics1 = &VAR_0->VAR_6[1].ics; int VAR_10 = 0; ics0->max_sfb = FFMAX(ics0->max_sfb, ics1->max_sfb); ics1->max_sfb = ics0->max_sfb; for (VAR_3 = 0; VAR_3 < ics0->num_windows*16; VAR_3 += 16) for (VAR_2 = 0; VAR_2 < ics0->max_sfb; VAR_2++) if (VAR_0->ms_mask[VAR_3+VAR_2]) VAR_10++; if (VAR_10 == 0 || ics0->max_sfb == 0) VAR_0->ms_mode = 0; else VAR_0->ms_mode = VAR_10 < ics0->max_sfb * ics0->num_windows ? 1 : 2; } }
[ "static void FUNC_0(ChannelElement *VAR_0, int VAR_1)\n{", "int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6;", "int VAR_7, VAR_8, VAR_9;", "for (VAR_6 = 0; VAR_6 < VAR_1; VAR_6++) {", "IndividualChannelStream *ics = &VAR_0->VAR_6[VAR_6].ics;", "VAR_7 = 0;", "VAR_8 = 0;", "VAR_0->VAR_6[VAR_6].pulse.num_pulse = 0;", "for (VAR_3 = 0; VAR_3 < ics->num_windows*16; VAR_3 += 16) {", "for (VAR_5 = 0; VAR_5 < ics->num_swb; VAR_5++) {", "if (VAR_0->common_window && !VAR_6 && VAR_0->ms_mask[VAR_3 + VAR_5]) {", "for (VAR_2 = 0; VAR_2 < ics->swb_sizes[VAR_5]; VAR_2++) {", "VAR_0->VAR_6[0].coeffs[VAR_7+VAR_2] = (VAR_0->VAR_6[0].coeffs[VAR_7+VAR_2] + VAR_0->VAR_6[1].coeffs[VAR_7+VAR_2]) / 2.0;", "VAR_0->VAR_6[1].coeffs[VAR_7+VAR_2] = VAR_0->VAR_6[0].coeffs[VAR_7+VAR_2] - VAR_0->VAR_6[1].coeffs[VAR_7+VAR_2];", "}", "}", "VAR_7 += ics->swb_sizes[VAR_5];", "}", "for (VAR_9 = ics->num_swb; VAR_9 > 0 && VAR_0->VAR_6[VAR_6].zeroes[VAR_3+VAR_9-1]; VAR_9--)", ";", "VAR_8 = FFMAX(VAR_8, VAR_9);", "}", "ics->max_sfb = VAR_8;", "for (VAR_3 = 0; VAR_3 < ics->num_windows; VAR_3 += ics->group_len[VAR_3]) {", "for (VAR_5 = 0; VAR_5 < ics->max_sfb; VAR_5++) {", "VAR_2 = 1;", "for (VAR_4 = VAR_3; VAR_4 < VAR_3 + ics->group_len[VAR_3]; VAR_4++) {", "if (!VAR_0->VAR_6[VAR_6].zeroes[VAR_4*16 + VAR_5]) {", "VAR_2 = 0;", "break;", "}", "}", "VAR_0->VAR_6[VAR_6].zeroes[VAR_3*16 + VAR_5] = VAR_2;", "}", "}", "}", "if (VAR_1 > 1 && VAR_0->common_window) {", "IndividualChannelStream *ics0 = &VAR_0->VAR_6[0].ics;", "IndividualChannelStream *ics1 = &VAR_0->VAR_6[1].ics;", "int VAR_10 = 0;", "ics0->max_sfb = FFMAX(ics0->max_sfb, ics1->max_sfb);", "ics1->max_sfb = ics0->max_sfb;", "for (VAR_3 = 0; VAR_3 < ics0->num_windows*16; VAR_3 += 16)", "for (VAR_2 = 0; VAR_2 < ics0->max_sfb; VAR_2++)", "if (VAR_0->ms_mask[VAR_3+VAR_2])\nVAR_10++;", "if (VAR_10 == 0 || ics0->max_sfb == 0)\nVAR_0->ms_mode = 0;", "else\nVAR_0->ms_mode = VAR_10 < ics0->max_sfb * ics0->num_windows ? 1 : 2;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101, 103 ], [ 105, 107 ], [ 109, 111 ], [ 113 ], [ 115 ] ]
636
int ff_img_read_header(AVFormatContext *s1) { VideoDemuxData *s = s1->priv_data; int first_index, last_index; AVStream *st; enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE; s1->ctx_flags |= AVFMTCTX_NOHEADER; st = avformat_new_stream(s1, NULL); if (!st) { return AVERROR(ENOMEM); } if (s->pixel_format && (pix_fmt = av_get_pix_fmt(s->pixel_format)) == AV_PIX_FMT_NONE) { av_log(s1, AV_LOG_ERROR, "No such pixel format: %s.\n", s->pixel_format); return AVERROR(EINVAL); } av_strlcpy(s->path, s1->filename, sizeof(s->path)); s->img_number = 0; s->img_count = 0; /* find format */ if (s1->iformat->flags & AVFMT_NOFILE) s->is_pipe = 0; else { s->is_pipe = 1; st->need_parsing = AVSTREAM_PARSE_FULL; } if (s->ts_from_file == 2) { #if !HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC av_log(s1, AV_LOG_ERROR, "POSIX.1-2008 not supported, nanosecond file timestamps unavailable\n"); return AVERROR(ENOSYS); #endif avpriv_set_pts_info(st, 64, 1, 1000000000); } else if (s->ts_from_file) avpriv_set_pts_info(st, 64, 1, 1); else avpriv_set_pts_info(st, 64, s->framerate.den, s->framerate.num); if (s->width && s->height) { st->codec->width = s->width; st->codec->height = s->height; } if (!s->is_pipe) { if (s->pattern_type == PT_GLOB_SEQUENCE) { s->use_glob = is_glob(s->path); if (s->use_glob) { #if HAVE_GLOB char *p = s->path, *q, *dup; int gerr; #endif av_log(s1, AV_LOG_WARNING, "Pattern type 'glob_sequence' is deprecated: " "use pattern_type 'glob' instead\n"); #if HAVE_GLOB dup = q = av_strdup(p); while (*q) { /* Do we have room for the next char and a \ insertion? */ if ((p - s->path) >= (sizeof(s->path) - 2)) break; if (*q == '%' && strspn(q + 1, "%*?[]{}")) ++q; else if (strspn(q, "\\*?[]{}")) *p++ = '\\'; *p++ = *q++; } *p = 0; av_free(dup); gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate); if (gerr != 0) { return AVERROR(ENOENT); } first_index = 0; last_index = s->globstate.gl_pathc - 1; #endif } } if ((s->pattern_type == PT_GLOB_SEQUENCE && !s->use_glob) || s->pattern_type == PT_SEQUENCE) { if (find_image_range(&first_index, &last_index, s->path, s->start_number, s->start_number_range) < 0) { av_log(s1, AV_LOG_ERROR, "Could find no file with path '%s' and index in the range %d-%d\n", s->path, s->start_number, s->start_number + s->start_number_range - 1); return AVERROR(ENOENT); } } else if (s->pattern_type == PT_GLOB) { #if HAVE_GLOB int gerr; gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate); if (gerr != 0) { return AVERROR(ENOENT); } first_index = 0; last_index = s->globstate.gl_pathc - 1; s->use_glob = 1; #else av_log(s1, AV_LOG_ERROR, "Pattern type 'glob' was selected but globbing " "is not supported by this libavformat build\n"); return AVERROR(ENOSYS); #endif } else if (s->pattern_type != PT_GLOB_SEQUENCE) { av_log(s1, AV_LOG_ERROR, "Unknown value '%d' for pattern_type option\n", s->pattern_type); return AVERROR(EINVAL); } s->img_first = first_index; s->img_last = last_index; s->img_number = first_index; /* compute duration */ if (!s->ts_from_file) { st->start_time = 0; st->duration = last_index - first_index + 1; } } if (s1->video_codec_id) { st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = s1->video_codec_id; } else if (s1->audio_codec_id) { st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = s1->audio_codec_id; } else if (s1->iformat->raw_codec_id) { st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = s1->iformat->raw_codec_id; } else { const char *str = strrchr(s->path, '.'); s->split_planes = str && !av_strcasecmp(str + 1, "y"); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; if (s1->pb) { int probe_buffer_size = 2048; uint8_t *probe_buffer = av_realloc(NULL, probe_buffer_size + AVPROBE_PADDING_SIZE); AVInputFormat *fmt = NULL; AVProbeData pd = { 0 }; if (!probe_buffer) return AVERROR(ENOMEM); probe_buffer_size = avio_read(s1->pb, probe_buffer, probe_buffer_size); if (probe_buffer_size < 0) { av_free(probe_buffer); return probe_buffer_size; } memset(probe_buffer + probe_buffer_size, 0, AVPROBE_PADDING_SIZE); pd.buf = probe_buffer; pd.buf_size = probe_buffer_size; pd.filename = s1->filename; while ((fmt = av_iformat_next(fmt))) { if (fmt->read_header != ff_img_read_header || !fmt->read_probe || (fmt->flags & AVFMT_NOFILE) || !fmt->raw_codec_id) continue; if (fmt->read_probe(&pd) > 0) { st->codec->codec_id = fmt->raw_codec_id; break; } } ffio_rewind_with_probe_data(s1->pb, &probe_buffer, probe_buffer_size); } if (st->codec->codec_id == AV_CODEC_ID_NONE) st->codec->codec_id = ff_guess_image2_codec(s->path); if (st->codec->codec_id == AV_CODEC_ID_LJPEG) st->codec->codec_id = AV_CODEC_ID_MJPEG; if (st->codec->codec_id == AV_CODEC_ID_ALIAS_PIX) // we cannot distingiush this from BRENDER_PIX st->codec->codec_id = AV_CODEC_ID_NONE; } if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && pix_fmt != AV_PIX_FMT_NONE) st->codec->pix_fmt = pix_fmt; return 0; }
true
FFmpeg
e6e8cc8ce9c2a398fbb51254a5067f4bd3c4fa8a
int ff_img_read_header(AVFormatContext *s1) { VideoDemuxData *s = s1->priv_data; int first_index, last_index; AVStream *st; enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE; s1->ctx_flags |= AVFMTCTX_NOHEADER; st = avformat_new_stream(s1, NULL); if (!st) { return AVERROR(ENOMEM); } if (s->pixel_format && (pix_fmt = av_get_pix_fmt(s->pixel_format)) == AV_PIX_FMT_NONE) { av_log(s1, AV_LOG_ERROR, "No such pixel format: %s.\n", s->pixel_format); return AVERROR(EINVAL); } av_strlcpy(s->path, s1->filename, sizeof(s->path)); s->img_number = 0; s->img_count = 0; if (s1->iformat->flags & AVFMT_NOFILE) s->is_pipe = 0; else { s->is_pipe = 1; st->need_parsing = AVSTREAM_PARSE_FULL; } if (s->ts_from_file == 2) { #if !HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC av_log(s1, AV_LOG_ERROR, "POSIX.1-2008 not supported, nanosecond file timestamps unavailable\n"); return AVERROR(ENOSYS); #endif avpriv_set_pts_info(st, 64, 1, 1000000000); } else if (s->ts_from_file) avpriv_set_pts_info(st, 64, 1, 1); else avpriv_set_pts_info(st, 64, s->framerate.den, s->framerate.num); if (s->width && s->height) { st->codec->width = s->width; st->codec->height = s->height; } if (!s->is_pipe) { if (s->pattern_type == PT_GLOB_SEQUENCE) { s->use_glob = is_glob(s->path); if (s->use_glob) { #if HAVE_GLOB char *p = s->path, *q, *dup; int gerr; #endif av_log(s1, AV_LOG_WARNING, "Pattern type 'glob_sequence' is deprecated: " "use pattern_type 'glob' instead\n"); #if HAVE_GLOB dup = q = av_strdup(p); while (*q) { if ((p - s->path) >= (sizeof(s->path) - 2)) break; if (*q == '%' && strspn(q + 1, "%*?[]{}")) ++q; else if (strspn(q, "\\*?[]{}")) *p++ = '\\'; *p++ = *q++; } *p = 0; av_free(dup); gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate); if (gerr != 0) { return AVERROR(ENOENT); } first_index = 0; last_index = s->globstate.gl_pathc - 1; #endif } } if ((s->pattern_type == PT_GLOB_SEQUENCE && !s->use_glob) || s->pattern_type == PT_SEQUENCE) { if (find_image_range(&first_index, &last_index, s->path, s->start_number, s->start_number_range) < 0) { av_log(s1, AV_LOG_ERROR, "Could find no file with path '%s' and index in the range %d-%d\n", s->path, s->start_number, s->start_number + s->start_number_range - 1); return AVERROR(ENOENT); } } else if (s->pattern_type == PT_GLOB) { #if HAVE_GLOB int gerr; gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate); if (gerr != 0) { return AVERROR(ENOENT); } first_index = 0; last_index = s->globstate.gl_pathc - 1; s->use_glob = 1; #else av_log(s1, AV_LOG_ERROR, "Pattern type 'glob' was selected but globbing " "is not supported by this libavformat build\n"); return AVERROR(ENOSYS); #endif } else if (s->pattern_type != PT_GLOB_SEQUENCE) { av_log(s1, AV_LOG_ERROR, "Unknown value '%d' for pattern_type option\n", s->pattern_type); return AVERROR(EINVAL); } s->img_first = first_index; s->img_last = last_index; s->img_number = first_index; if (!s->ts_from_file) { st->start_time = 0; st->duration = last_index - first_index + 1; } } if (s1->video_codec_id) { st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = s1->video_codec_id; } else if (s1->audio_codec_id) { st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = s1->audio_codec_id; } else if (s1->iformat->raw_codec_id) { st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = s1->iformat->raw_codec_id; } else { const char *str = strrchr(s->path, '.'); s->split_planes = str && !av_strcasecmp(str + 1, "y"); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; if (s1->pb) { int probe_buffer_size = 2048; uint8_t *probe_buffer = av_realloc(NULL, probe_buffer_size + AVPROBE_PADDING_SIZE); AVInputFormat *fmt = NULL; AVProbeData pd = { 0 }; if (!probe_buffer) return AVERROR(ENOMEM); probe_buffer_size = avio_read(s1->pb, probe_buffer, probe_buffer_size); if (probe_buffer_size < 0) { av_free(probe_buffer); return probe_buffer_size; } memset(probe_buffer + probe_buffer_size, 0, AVPROBE_PADDING_SIZE); pd.buf = probe_buffer; pd.buf_size = probe_buffer_size; pd.filename = s1->filename; while ((fmt = av_iformat_next(fmt))) { if (fmt->read_header != ff_img_read_header || !fmt->read_probe || (fmt->flags & AVFMT_NOFILE) || !fmt->raw_codec_id) continue; if (fmt->read_probe(&pd) > 0) { st->codec->codec_id = fmt->raw_codec_id; break; } } ffio_rewind_with_probe_data(s1->pb, &probe_buffer, probe_buffer_size); } if (st->codec->codec_id == AV_CODEC_ID_NONE) st->codec->codec_id = ff_guess_image2_codec(s->path); if (st->codec->codec_id == AV_CODEC_ID_LJPEG) st->codec->codec_id = AV_CODEC_ID_MJPEG; if (st->codec->codec_id == AV_CODEC_ID_ALIAS_PIX) st->codec->codec_id = AV_CODEC_ID_NONE; } if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && pix_fmt != AV_PIX_FMT_NONE) st->codec->pix_fmt = pix_fmt; return 0; }
{ "code": [ " ffio_rewind_with_probe_data(s1->pb, &probe_buffer, probe_buffer_size);" ], "line_no": [ 335 ] }
int FUNC_0(AVFormatContext *VAR_0) { VideoDemuxData *s = VAR_0->priv_data; int VAR_1, VAR_2; AVStream *st; enum AVPixelFormat VAR_3 = AV_PIX_FMT_NONE; VAR_0->ctx_flags |= AVFMTCTX_NOHEADER; st = avformat_new_stream(VAR_0, NULL); if (!st) { return AVERROR(ENOMEM); } if (s->pixel_format && (VAR_3 = av_get_pix_fmt(s->pixel_format)) == AV_PIX_FMT_NONE) { av_log(VAR_0, AV_LOG_ERROR, "No such pixel format: %s.\n", s->pixel_format); return AVERROR(EINVAL); } av_strlcpy(s->path, VAR_0->filename, sizeof(s->path)); s->img_number = 0; s->img_count = 0; if (VAR_0->iformat->flags & AVFMT_NOFILE) s->is_pipe = 0; else { s->is_pipe = 1; st->need_parsing = AVSTREAM_PARSE_FULL; } if (s->ts_from_file == 2) { #if !HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC av_log(VAR_0, AV_LOG_ERROR, "POSIX.1-2008 not supported, nanosecond file timestamps unavailable\n"); return AVERROR(ENOSYS); #endif avpriv_set_pts_info(st, 64, 1, 1000000000); } else if (s->ts_from_file) avpriv_set_pts_info(st, 64, 1, 1); else avpriv_set_pts_info(st, 64, s->framerate.den, s->framerate.num); if (s->width && s->height) { st->codec->width = s->width; st->codec->height = s->height; } if (!s->is_pipe) { if (s->pattern_type == PT_GLOB_SEQUENCE) { s->use_glob = is_glob(s->path); if (s->use_glob) { #if HAVE_GLOB char *p = s->path, *q, *dup; int gerr; #endif av_log(VAR_0, AV_LOG_WARNING, "Pattern type 'glob_sequence' is deprecated: " "use pattern_type 'glob' instead\n"); #if HAVE_GLOB dup = q = av_strdup(p); while (*q) { if ((p - s->path) >= (sizeof(s->path) - 2)) break; if (*q == '%' && strspn(q + 1, "%*?[]{}")) ++q; else if (strspn(q, "\\*?[]{}")) *p++ = '\\'; *p++ = *q++; } *p = 0; av_free(dup); gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate); if (gerr != 0) { return AVERROR(ENOENT); } VAR_1 = 0; VAR_2 = s->globstate.gl_pathc - 1; #endif } } if ((s->pattern_type == PT_GLOB_SEQUENCE && !s->use_glob) || s->pattern_type == PT_SEQUENCE) { if (find_image_range(&VAR_1, &VAR_2, s->path, s->start_number, s->start_number_range) < 0) { av_log(VAR_0, AV_LOG_ERROR, "Could find no file with path '%s' and index in the range %d-%d\n", s->path, s->start_number, s->start_number + s->start_number_range - 1); return AVERROR(ENOENT); } } else if (s->pattern_type == PT_GLOB) { #if HAVE_GLOB int gerr; gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate); if (gerr != 0) { return AVERROR(ENOENT); } VAR_1 = 0; VAR_2 = s->globstate.gl_pathc - 1; s->use_glob = 1; #else av_log(VAR_0, AV_LOG_ERROR, "Pattern type 'glob' was selected but globbing " "is not supported by this libavformat build\n"); return AVERROR(ENOSYS); #endif } else if (s->pattern_type != PT_GLOB_SEQUENCE) { av_log(VAR_0, AV_LOG_ERROR, "Unknown value '%d' for pattern_type option\n", s->pattern_type); return AVERROR(EINVAL); } s->img_first = VAR_1; s->img_last = VAR_2; s->img_number = VAR_1; if (!s->ts_from_file) { st->start_time = 0; st->duration = VAR_2 - VAR_1 + 1; } } if (VAR_0->video_codec_id) { st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = VAR_0->video_codec_id; } else if (VAR_0->audio_codec_id) { st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = VAR_0->audio_codec_id; } else if (VAR_0->iformat->raw_codec_id) { st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = VAR_0->iformat->raw_codec_id; } else { const char *VAR_4 = strrchr(s->path, '.'); s->split_planes = VAR_4 && !av_strcasecmp(VAR_4 + 1, "y"); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; if (VAR_0->pb) { int VAR_5 = 2048; uint8_t *probe_buffer = av_realloc(NULL, VAR_5 + AVPROBE_PADDING_SIZE); AVInputFormat *fmt = NULL; AVProbeData pd = { 0 }; if (!probe_buffer) return AVERROR(ENOMEM); VAR_5 = avio_read(VAR_0->pb, probe_buffer, VAR_5); if (VAR_5 < 0) { av_free(probe_buffer); return VAR_5; } memset(probe_buffer + VAR_5, 0, AVPROBE_PADDING_SIZE); pd.buf = probe_buffer; pd.buf_size = VAR_5; pd.filename = VAR_0->filename; while ((fmt = av_iformat_next(fmt))) { if (fmt->read_header != FUNC_0 || !fmt->read_probe || (fmt->flags & AVFMT_NOFILE) || !fmt->raw_codec_id) continue; if (fmt->read_probe(&pd) > 0) { st->codec->codec_id = fmt->raw_codec_id; break; } } ffio_rewind_with_probe_data(VAR_0->pb, &probe_buffer, VAR_5); } if (st->codec->codec_id == AV_CODEC_ID_NONE) st->codec->codec_id = ff_guess_image2_codec(s->path); if (st->codec->codec_id == AV_CODEC_ID_LJPEG) st->codec->codec_id = AV_CODEC_ID_MJPEG; if (st->codec->codec_id == AV_CODEC_ID_ALIAS_PIX) st->codec->codec_id = AV_CODEC_ID_NONE; } if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && VAR_3 != AV_PIX_FMT_NONE) st->codec->VAR_3 = VAR_3; return 0; }
[ "int FUNC_0(AVFormatContext *VAR_0)\n{", "VideoDemuxData *s = VAR_0->priv_data;", "int VAR_1, VAR_2;", "AVStream *st;", "enum AVPixelFormat VAR_3 = AV_PIX_FMT_NONE;", "VAR_0->ctx_flags |= AVFMTCTX_NOHEADER;", "st = avformat_new_stream(VAR_0, NULL);", "if (!st) {", "return AVERROR(ENOMEM);", "}", "if (s->pixel_format &&\n(VAR_3 = av_get_pix_fmt(s->pixel_format)) == AV_PIX_FMT_NONE) {", "av_log(VAR_0, AV_LOG_ERROR, \"No such pixel format: %s.\\n\",\ns->pixel_format);", "return AVERROR(EINVAL);", "}", "av_strlcpy(s->path, VAR_0->filename, sizeof(s->path));", "s->img_number = 0;", "s->img_count = 0;", "if (VAR_0->iformat->flags & AVFMT_NOFILE)\ns->is_pipe = 0;", "else {", "s->is_pipe = 1;", "st->need_parsing = AVSTREAM_PARSE_FULL;", "}", "if (s->ts_from_file == 2) {", "#if !HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC\nav_log(VAR_0, AV_LOG_ERROR, \"POSIX.1-2008 not supported, nanosecond file timestamps unavailable\\n\");", "return AVERROR(ENOSYS);", "#endif\navpriv_set_pts_info(st, 64, 1, 1000000000);", "} else if (s->ts_from_file)", "avpriv_set_pts_info(st, 64, 1, 1);", "else\navpriv_set_pts_info(st, 64, s->framerate.den, s->framerate.num);", "if (s->width && s->height) {", "st->codec->width = s->width;", "st->codec->height = s->height;", "}", "if (!s->is_pipe) {", "if (s->pattern_type == PT_GLOB_SEQUENCE) {", "s->use_glob = is_glob(s->path);", "if (s->use_glob) {", "#if HAVE_GLOB\nchar *p = s->path, *q, *dup;", "int gerr;", "#endif\nav_log(VAR_0, AV_LOG_WARNING, \"Pattern type 'glob_sequence' is deprecated: \"\n\"use pattern_type 'glob' instead\\n\");", "#if HAVE_GLOB\ndup = q = av_strdup(p);", "while (*q) {", "if ((p - s->path) >= (sizeof(s->path) - 2))\nbreak;", "if (*q == '%' && strspn(q + 1, \"%*?[]{}\"))", "++q;", "else if (strspn(q, \"\\\\*?[]{}\"))", "*p++ = '\\\\';", "*p++ = *q++;", "}", "*p = 0;", "av_free(dup);", "gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate);", "if (gerr != 0) {", "return AVERROR(ENOENT);", "}", "VAR_1 = 0;", "VAR_2 = s->globstate.gl_pathc - 1;", "#endif\n}", "}", "if ((s->pattern_type == PT_GLOB_SEQUENCE && !s->use_glob) || s->pattern_type == PT_SEQUENCE) {", "if (find_image_range(&VAR_1, &VAR_2, s->path,\ns->start_number, s->start_number_range) < 0) {", "av_log(VAR_0, AV_LOG_ERROR,\n\"Could find no file with path '%s' and index in the range %d-%d\\n\",\ns->path, s->start_number, s->start_number + s->start_number_range - 1);", "return AVERROR(ENOENT);", "}", "} else if (s->pattern_type == PT_GLOB) {", "#if HAVE_GLOB\nint gerr;", "gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate);", "if (gerr != 0) {", "return AVERROR(ENOENT);", "}", "VAR_1 = 0;", "VAR_2 = s->globstate.gl_pathc - 1;", "s->use_glob = 1;", "#else\nav_log(VAR_0, AV_LOG_ERROR,\n\"Pattern type 'glob' was selected but globbing \"\n\"is not supported by this libavformat build\\n\");", "return AVERROR(ENOSYS);", "#endif\n} else if (s->pattern_type != PT_GLOB_SEQUENCE) {", "av_log(VAR_0, AV_LOG_ERROR,\n\"Unknown value '%d' for pattern_type option\\n\", s->pattern_type);", "return AVERROR(EINVAL);", "}", "s->img_first = VAR_1;", "s->img_last = VAR_2;", "s->img_number = VAR_1;", "if (!s->ts_from_file) {", "st->start_time = 0;", "st->duration = VAR_2 - VAR_1 + 1;", "}", "}", "if (VAR_0->video_codec_id) {", "st->codec->codec_type = AVMEDIA_TYPE_VIDEO;", "st->codec->codec_id = VAR_0->video_codec_id;", "} else if (VAR_0->audio_codec_id) {", "st->codec->codec_type = AVMEDIA_TYPE_AUDIO;", "st->codec->codec_id = VAR_0->audio_codec_id;", "} else if (VAR_0->iformat->raw_codec_id) {", "st->codec->codec_type = AVMEDIA_TYPE_VIDEO;", "st->codec->codec_id = VAR_0->iformat->raw_codec_id;", "} else {", "const char *VAR_4 = strrchr(s->path, '.');", "s->split_planes = VAR_4 && !av_strcasecmp(VAR_4 + 1, \"y\");", "st->codec->codec_type = AVMEDIA_TYPE_VIDEO;", "if (VAR_0->pb) {", "int VAR_5 = 2048;", "uint8_t *probe_buffer = av_realloc(NULL, VAR_5 + AVPROBE_PADDING_SIZE);", "AVInputFormat *fmt = NULL;", "AVProbeData pd = { 0 };", "if (!probe_buffer)\nreturn AVERROR(ENOMEM);", "VAR_5 = avio_read(VAR_0->pb, probe_buffer, VAR_5);", "if (VAR_5 < 0) {", "av_free(probe_buffer);", "return VAR_5;", "}", "memset(probe_buffer + VAR_5, 0, AVPROBE_PADDING_SIZE);", "pd.buf = probe_buffer;", "pd.buf_size = VAR_5;", "pd.filename = VAR_0->filename;", "while ((fmt = av_iformat_next(fmt))) {", "if (fmt->read_header != FUNC_0 ||\n!fmt->read_probe ||\n(fmt->flags & AVFMT_NOFILE) ||\n!fmt->raw_codec_id)\ncontinue;", "if (fmt->read_probe(&pd) > 0) {", "st->codec->codec_id = fmt->raw_codec_id;", "break;", "}", "}", "ffio_rewind_with_probe_data(VAR_0->pb, &probe_buffer, VAR_5);", "}", "if (st->codec->codec_id == AV_CODEC_ID_NONE)\nst->codec->codec_id = ff_guess_image2_codec(s->path);", "if (st->codec->codec_id == AV_CODEC_ID_LJPEG)\nst->codec->codec_id = AV_CODEC_ID_MJPEG;", "if (st->codec->codec_id == AV_CODEC_ID_ALIAS_PIX)\nst->codec->codec_id = AV_CODEC_ID_NONE;", "}", "if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&\nVAR_3 != AV_PIX_FMT_NONE)\nst->codec->VAR_3 = VAR_3;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29, 31 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 53, 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69, 71 ], [ 73 ], [ 75, 77 ], [ 79 ], [ 81 ], [ 83, 85 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107, 109 ], [ 111 ], [ 113, 117, 119 ], [ 121, 123 ], [ 125 ], [ 129, 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163, 165 ], [ 167 ], [ 169 ], [ 171, 173 ], [ 175, 177, 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187, 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205, 207, 209, 211 ], [ 213 ], [ 215, 217 ], [ 219, 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 277 ], [ 279 ], [ 281 ], [ 285, 287 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ], [ 299 ], [ 301 ], [ 305 ], [ 307 ], [ 309 ], [ 313 ], [ 315, 317, 319, 321, 323 ], [ 325 ], [ 327 ], [ 329 ], [ 331 ], [ 333 ], [ 335 ], [ 337 ], [ 339, 341 ], [ 343, 345 ], [ 347, 349 ], [ 351 ], [ 353, 355, 357 ], [ 361 ], [ 363 ] ]
637
static void hpet_ram_write(void *opaque, hwaddr addr, uint64_t value, unsigned size) { int i; HPETState *s = opaque; uint64_t old_val, new_val, val, index; DPRINTF("qemu: Enter hpet_ram_writel at %" PRIx64 " = %#x\n", addr, value); index = addr; old_val = hpet_ram_read(opaque, addr, 4); new_val = value; /*address range of all TN regs*/ if (index >= 0x100 && index <= 0x3ff) { uint8_t timer_id = (addr - 0x100) / 0x20; HPETTimer *timer = &s->timer[timer_id]; DPRINTF("qemu: hpet_ram_writel timer_id = %#x\n", timer_id); if (timer_id > s->num_timers) { DPRINTF("qemu: timer id out of range\n"); return; } switch ((addr - 0x100) % 0x20) { case HPET_TN_CFG: DPRINTF("qemu: hpet_ram_writel HPET_TN_CFG\n"); if (activating_bit(old_val, new_val, HPET_TN_FSB_ENABLE)) { update_irq(timer, 0); } val = hpet_fixup_reg(new_val, old_val, HPET_TN_CFG_WRITE_MASK); timer->config = (timer->config & 0xffffffff00000000ULL) | val; if (new_val & HPET_TN_32BIT) { timer->cmp = (uint32_t)timer->cmp; timer->period = (uint32_t)timer->period; } if (activating_bit(old_val, new_val, HPET_TN_ENABLE)) { hpet_set_timer(timer); } else if (deactivating_bit(old_val, new_val, HPET_TN_ENABLE)) { hpet_del_timer(timer); } break; case HPET_TN_CFG + 4: // Interrupt capabilities DPRINTF("qemu: invalid HPET_TN_CFG+4 write\n"); break; case HPET_TN_CMP: // comparator register DPRINTF("qemu: hpet_ram_writel HPET_TN_CMP\n"); if (timer->config & HPET_TN_32BIT) { new_val = (uint32_t)new_val; } if (!timer_is_periodic(timer) || (timer->config & HPET_TN_SETVAL)) { timer->cmp = (timer->cmp & 0xffffffff00000000ULL) | new_val; } if (timer_is_periodic(timer)) { /* * FIXME: Clamp period to reasonable min value? * Clamp period to reasonable max value */ new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1; timer->period = (timer->period & 0xffffffff00000000ULL) | new_val; } timer->config &= ~HPET_TN_SETVAL; if (hpet_enabled(s)) { hpet_set_timer(timer); } break; case HPET_TN_CMP + 4: // comparator register high order DPRINTF("qemu: hpet_ram_writel HPET_TN_CMP + 4\n"); if (!timer_is_periodic(timer) || (timer->config & HPET_TN_SETVAL)) { timer->cmp = (timer->cmp & 0xffffffffULL) | new_val << 32; } else { /* * FIXME: Clamp period to reasonable min value? * Clamp period to reasonable max value */ new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1; timer->period = (timer->period & 0xffffffffULL) | new_val << 32; } timer->config &= ~HPET_TN_SETVAL; if (hpet_enabled(s)) { hpet_set_timer(timer); } break; case HPET_TN_ROUTE: timer->fsb = (timer->fsb & 0xffffffff00000000ULL) | new_val; break; case HPET_TN_ROUTE + 4: timer->fsb = (new_val << 32) | (timer->fsb & 0xffffffff); break; default: DPRINTF("qemu: invalid hpet_ram_writel\n"); break; } return; } else { switch (index) { case HPET_ID: return; case HPET_CFG: val = hpet_fixup_reg(new_val, old_val, HPET_CFG_WRITE_MASK); s->config = (s->config & 0xffffffff00000000ULL) | val; if (activating_bit(old_val, new_val, HPET_CFG_ENABLE)) { /* Enable main counter and interrupt generation. */ s->hpet_offset = ticks_to_ns(s->hpet_counter) - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); for (i = 0; i < s->num_timers; i++) { if ((&s->timer[i])->cmp != ~0ULL) { hpet_set_timer(&s->timer[i]); } } } else if (deactivating_bit(old_val, new_val, HPET_CFG_ENABLE)) { /* Halt main counter and disable interrupt generation. */ s->hpet_counter = hpet_get_ticks(s); for (i = 0; i < s->num_timers; i++) { hpet_del_timer(&s->timer[i]); } } /* i8254 and RTC output pins are disabled * when HPET is in legacy mode */ if (activating_bit(old_val, new_val, HPET_CFG_LEGACY)) { qemu_set_irq(s->pit_enabled, 0); qemu_irq_lower(s->irqs[0]); qemu_irq_lower(s->irqs[RTC_ISA_IRQ]); } else if (deactivating_bit(old_val, new_val, HPET_CFG_LEGACY)) { qemu_irq_lower(s->irqs[0]); qemu_set_irq(s->pit_enabled, 1); qemu_set_irq(s->irqs[RTC_ISA_IRQ], s->rtc_irq_level); } break; case HPET_CFG + 4: DPRINTF("qemu: invalid HPET_CFG+4 write\n"); break; case HPET_STATUS: val = new_val & s->isr; for (i = 0; i < s->num_timers; i++) { if (val & (1 << i)) { update_irq(&s->timer[i], 0); } } break; case HPET_COUNTER: if (hpet_enabled(s)) { DPRINTF("qemu: Writing counter while HPET enabled!\n"); } s->hpet_counter = (s->hpet_counter & 0xffffffff00000000ULL) | value; DPRINTF("qemu: HPET counter written. ctr = %#x -> %" PRIx64 "\n", value, s->hpet_counter); break; case HPET_COUNTER + 4: if (hpet_enabled(s)) { DPRINTF("qemu: Writing counter while HPET enabled!\n"); } s->hpet_counter = (s->hpet_counter & 0xffffffffULL) | (((uint64_t)value) << 32); DPRINTF("qemu: HPET counter + 4 written. ctr = %#x -> %" PRIx64 "\n", value, s->hpet_counter); break; default: DPRINTF("qemu: invalid hpet_ram_writel\n"); break; } } }
true
qemu
c36ad13fe9ece9a21a8c1dd082473a2b182298ee
static void hpet_ram_write(void *opaque, hwaddr addr, uint64_t value, unsigned size) { int i; HPETState *s = opaque; uint64_t old_val, new_val, val, index; DPRINTF("qemu: Enter hpet_ram_writel at %" PRIx64 " = %#x\n", addr, value); index = addr; old_val = hpet_ram_read(opaque, addr, 4); new_val = value; if (index >= 0x100 && index <= 0x3ff) { uint8_t timer_id = (addr - 0x100) / 0x20; HPETTimer *timer = &s->timer[timer_id]; DPRINTF("qemu: hpet_ram_writel timer_id = %#x\n", timer_id); if (timer_id > s->num_timers) { DPRINTF("qemu: timer id out of range\n"); return; } switch ((addr - 0x100) % 0x20) { case HPET_TN_CFG: DPRINTF("qemu: hpet_ram_writel HPET_TN_CFG\n"); if (activating_bit(old_val, new_val, HPET_TN_FSB_ENABLE)) { update_irq(timer, 0); } val = hpet_fixup_reg(new_val, old_val, HPET_TN_CFG_WRITE_MASK); timer->config = (timer->config & 0xffffffff00000000ULL) | val; if (new_val & HPET_TN_32BIT) { timer->cmp = (uint32_t)timer->cmp; timer->period = (uint32_t)timer->period; } if (activating_bit(old_val, new_val, HPET_TN_ENABLE)) { hpet_set_timer(timer); } else if (deactivating_bit(old_val, new_val, HPET_TN_ENABLE)) { hpet_del_timer(timer); } break; case HPET_TN_CFG + 4: DPRINTF("qemu: invalid HPET_TN_CFG+4 write\n"); break; case HPET_TN_CMP: DPRINTF("qemu: hpet_ram_writel HPET_TN_CMP\n"); if (timer->config & HPET_TN_32BIT) { new_val = (uint32_t)new_val; } if (!timer_is_periodic(timer) || (timer->config & HPET_TN_SETVAL)) { timer->cmp = (timer->cmp & 0xffffffff00000000ULL) | new_val; } if (timer_is_periodic(timer)) { new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1; timer->period = (timer->period & 0xffffffff00000000ULL) | new_val; } timer->config &= ~HPET_TN_SETVAL; if (hpet_enabled(s)) { hpet_set_timer(timer); } break; case HPET_TN_CMP + 4: high order DPRINTF("qemu: hpet_ram_writel HPET_TN_CMP + 4\n"); if (!timer_is_periodic(timer) || (timer->config & HPET_TN_SETVAL)) { timer->cmp = (timer->cmp & 0xffffffffULL) | new_val << 32; } else { new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1; timer->period = (timer->period & 0xffffffffULL) | new_val << 32; } timer->config &= ~HPET_TN_SETVAL; if (hpet_enabled(s)) { hpet_set_timer(timer); } break; case HPET_TN_ROUTE: timer->fsb = (timer->fsb & 0xffffffff00000000ULL) | new_val; break; case HPET_TN_ROUTE + 4: timer->fsb = (new_val << 32) | (timer->fsb & 0xffffffff); break; default: DPRINTF("qemu: invalid hpet_ram_writel\n"); break; } return; } else { switch (index) { case HPET_ID: return; case HPET_CFG: val = hpet_fixup_reg(new_val, old_val, HPET_CFG_WRITE_MASK); s->config = (s->config & 0xffffffff00000000ULL) | val; if (activating_bit(old_val, new_val, HPET_CFG_ENABLE)) { s->hpet_offset = ticks_to_ns(s->hpet_counter) - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); for (i = 0; i < s->num_timers; i++) { if ((&s->timer[i])->cmp != ~0ULL) { hpet_set_timer(&s->timer[i]); } } } else if (deactivating_bit(old_val, new_val, HPET_CFG_ENABLE)) { s->hpet_counter = hpet_get_ticks(s); for (i = 0; i < s->num_timers; i++) { hpet_del_timer(&s->timer[i]); } } if (activating_bit(old_val, new_val, HPET_CFG_LEGACY)) { qemu_set_irq(s->pit_enabled, 0); qemu_irq_lower(s->irqs[0]); qemu_irq_lower(s->irqs[RTC_ISA_IRQ]); } else if (deactivating_bit(old_val, new_val, HPET_CFG_LEGACY)) { qemu_irq_lower(s->irqs[0]); qemu_set_irq(s->pit_enabled, 1); qemu_set_irq(s->irqs[RTC_ISA_IRQ], s->rtc_irq_level); } break; case HPET_CFG + 4: DPRINTF("qemu: invalid HPET_CFG+4 write\n"); break; case HPET_STATUS: val = new_val & s->isr; for (i = 0; i < s->num_timers; i++) { if (val & (1 << i)) { update_irq(&s->timer[i], 0); } } break; case HPET_COUNTER: if (hpet_enabled(s)) { DPRINTF("qemu: Writing counter while HPET enabled!\n"); } s->hpet_counter = (s->hpet_counter & 0xffffffff00000000ULL) | value; DPRINTF("qemu: HPET counter written. ctr = %#x -> %" PRIx64 "\n", value, s->hpet_counter); break; case HPET_COUNTER + 4: if (hpet_enabled(s)) { DPRINTF("qemu: Writing counter while HPET enabled!\n"); } s->hpet_counter = (s->hpet_counter & 0xffffffffULL) | (((uint64_t)value) << 32); DPRINTF("qemu: HPET counter + 4 written. ctr = %#x -> %" PRIx64 "\n", value, s->hpet_counter); break; default: DPRINTF("qemu: invalid hpet_ram_writel\n"); break; } } }
{ "code": [ " if (activating_bit(old_val, new_val, HPET_TN_ENABLE)) {" ], "line_no": [ 69 ] }
static void FUNC_0(void *VAR_0, hwaddr VAR_1, uint64_t VAR_2, unsigned VAR_3) { int VAR_4; HPETState *s = VAR_0; uint64_t old_val, new_val, val, index; DPRINTF("qemu: Enter hpet_ram_writel at %" PRIx64 " = %#x\n", VAR_1, VAR_2); index = VAR_1; old_val = hpet_ram_read(VAR_0, VAR_1, 4); new_val = VAR_2; if (index >= 0x100 && index <= 0x3ff) { uint8_t timer_id = (VAR_1 - 0x100) / 0x20; HPETTimer *timer = &s->timer[timer_id]; DPRINTF("qemu: hpet_ram_writel timer_id = %#x\n", timer_id); if (timer_id > s->num_timers) { DPRINTF("qemu: timer id out of range\n"); return; } switch ((VAR_1 - 0x100) % 0x20) { case HPET_TN_CFG: DPRINTF("qemu: hpet_ram_writel HPET_TN_CFG\n"); if (activating_bit(old_val, new_val, HPET_TN_FSB_ENABLE)) { update_irq(timer, 0); } val = hpet_fixup_reg(new_val, old_val, HPET_TN_CFG_WRITE_MASK); timer->config = (timer->config & 0xffffffff00000000ULL) | val; if (new_val & HPET_TN_32BIT) { timer->cmp = (uint32_t)timer->cmp; timer->period = (uint32_t)timer->period; } if (activating_bit(old_val, new_val, HPET_TN_ENABLE)) { hpet_set_timer(timer); } else if (deactivating_bit(old_val, new_val, HPET_TN_ENABLE)) { hpet_del_timer(timer); } break; case HPET_TN_CFG + 4: DPRINTF("qemu: invalid HPET_TN_CFG+4 write\n"); break; case HPET_TN_CMP: DPRINTF("qemu: hpet_ram_writel HPET_TN_CMP\n"); if (timer->config & HPET_TN_32BIT) { new_val = (uint32_t)new_val; } if (!timer_is_periodic(timer) || (timer->config & HPET_TN_SETVAL)) { timer->cmp = (timer->cmp & 0xffffffff00000000ULL) | new_val; } if (timer_is_periodic(timer)) { new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1; timer->period = (timer->period & 0xffffffff00000000ULL) | new_val; } timer->config &= ~HPET_TN_SETVAL; if (hpet_enabled(s)) { hpet_set_timer(timer); } break; case HPET_TN_CMP + 4: high order DPRINTF("qemu: hpet_ram_writel HPET_TN_CMP + 4\n"); if (!timer_is_periodic(timer) || (timer->config & HPET_TN_SETVAL)) { timer->cmp = (timer->cmp & 0xffffffffULL) | new_val << 32; } else { new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1; timer->period = (timer->period & 0xffffffffULL) | new_val << 32; } timer->config &= ~HPET_TN_SETVAL; if (hpet_enabled(s)) { hpet_set_timer(timer); } break; case HPET_TN_ROUTE: timer->fsb = (timer->fsb & 0xffffffff00000000ULL) | new_val; break; case HPET_TN_ROUTE + 4: timer->fsb = (new_val << 32) | (timer->fsb & 0xffffffff); break; default: DPRINTF("qemu: invalid hpet_ram_writel\n"); break; } return; } else { switch (index) { case HPET_ID: return; case HPET_CFG: val = hpet_fixup_reg(new_val, old_val, HPET_CFG_WRITE_MASK); s->config = (s->config & 0xffffffff00000000ULL) | val; if (activating_bit(old_val, new_val, HPET_CFG_ENABLE)) { s->hpet_offset = ticks_to_ns(s->hpet_counter) - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); for (VAR_4 = 0; VAR_4 < s->num_timers; VAR_4++) { if ((&s->timer[VAR_4])->cmp != ~0ULL) { hpet_set_timer(&s->timer[VAR_4]); } } } else if (deactivating_bit(old_val, new_val, HPET_CFG_ENABLE)) { s->hpet_counter = hpet_get_ticks(s); for (VAR_4 = 0; VAR_4 < s->num_timers; VAR_4++) { hpet_del_timer(&s->timer[VAR_4]); } } if (activating_bit(old_val, new_val, HPET_CFG_LEGACY)) { qemu_set_irq(s->pit_enabled, 0); qemu_irq_lower(s->irqs[0]); qemu_irq_lower(s->irqs[RTC_ISA_IRQ]); } else if (deactivating_bit(old_val, new_val, HPET_CFG_LEGACY)) { qemu_irq_lower(s->irqs[0]); qemu_set_irq(s->pit_enabled, 1); qemu_set_irq(s->irqs[RTC_ISA_IRQ], s->rtc_irq_level); } break; case HPET_CFG + 4: DPRINTF("qemu: invalid HPET_CFG+4 write\n"); break; case HPET_STATUS: val = new_val & s->isr; for (VAR_4 = 0; VAR_4 < s->num_timers; VAR_4++) { if (val & (1 << VAR_4)) { update_irq(&s->timer[VAR_4], 0); } } break; case HPET_COUNTER: if (hpet_enabled(s)) { DPRINTF("qemu: Writing counter while HPET enabled!\n"); } s->hpet_counter = (s->hpet_counter & 0xffffffff00000000ULL) | VAR_2; DPRINTF("qemu: HPET counter written. ctr = %#x -> %" PRIx64 "\n", VAR_2, s->hpet_counter); break; case HPET_COUNTER + 4: if (hpet_enabled(s)) { DPRINTF("qemu: Writing counter while HPET enabled!\n"); } s->hpet_counter = (s->hpet_counter & 0xffffffffULL) | (((uint64_t)VAR_2) << 32); DPRINTF("qemu: HPET counter + 4 written. ctr = %#x -> %" PRIx64 "\n", VAR_2, s->hpet_counter); break; default: DPRINTF("qemu: invalid hpet_ram_writel\n"); break; } } }
[ "static void FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{", "int VAR_4;", "HPETState *s = VAR_0;", "uint64_t old_val, new_val, val, index;", "DPRINTF(\"qemu: Enter hpet_ram_writel at %\" PRIx64 \" = %#x\\n\", VAR_1, VAR_2);", "index = VAR_1;", "old_val = hpet_ram_read(VAR_0, VAR_1, 4);", "new_val = VAR_2;", "if (index >= 0x100 && index <= 0x3ff) {", "uint8_t timer_id = (VAR_1 - 0x100) / 0x20;", "HPETTimer *timer = &s->timer[timer_id];", "DPRINTF(\"qemu: hpet_ram_writel timer_id = %#x\\n\", timer_id);", "if (timer_id > s->num_timers) {", "DPRINTF(\"qemu: timer id out of range\\n\");", "return;", "}", "switch ((VAR_1 - 0x100) % 0x20) {", "case HPET_TN_CFG:\nDPRINTF(\"qemu: hpet_ram_writel HPET_TN_CFG\\n\");", "if (activating_bit(old_val, new_val, HPET_TN_FSB_ENABLE)) {", "update_irq(timer, 0);", "}", "val = hpet_fixup_reg(new_val, old_val, HPET_TN_CFG_WRITE_MASK);", "timer->config = (timer->config & 0xffffffff00000000ULL) | val;", "if (new_val & HPET_TN_32BIT) {", "timer->cmp = (uint32_t)timer->cmp;", "timer->period = (uint32_t)timer->period;", "}", "if (activating_bit(old_val, new_val, HPET_TN_ENABLE)) {", "hpet_set_timer(timer);", "} else if (deactivating_bit(old_val, new_val, HPET_TN_ENABLE)) {", "hpet_del_timer(timer);", "}", "break;", "case HPET_TN_CFG + 4:\nDPRINTF(\"qemu: invalid HPET_TN_CFG+4 write\\n\");", "break;", "case HPET_TN_CMP:\nDPRINTF(\"qemu: hpet_ram_writel HPET_TN_CMP\\n\");", "if (timer->config & HPET_TN_32BIT) {", "new_val = (uint32_t)new_val;", "}", "if (!timer_is_periodic(timer)\n|| (timer->config & HPET_TN_SETVAL)) {", "timer->cmp = (timer->cmp & 0xffffffff00000000ULL) | new_val;", "}", "if (timer_is_periodic(timer)) {", "new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1;", "timer->period =\n(timer->period & 0xffffffff00000000ULL) | new_val;", "}", "timer->config &= ~HPET_TN_SETVAL;", "if (hpet_enabled(s)) {", "hpet_set_timer(timer);", "}", "break;", "case HPET_TN_CMP + 4: high order\nDPRINTF(\"qemu: hpet_ram_writel HPET_TN_CMP + 4\\n\");", "if (!timer_is_periodic(timer)\n|| (timer->config & HPET_TN_SETVAL)) {", "timer->cmp = (timer->cmp & 0xffffffffULL) | new_val << 32;", "} else {", "new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1;", "timer->period =\n(timer->period & 0xffffffffULL) | new_val << 32;", "}", "timer->config &= ~HPET_TN_SETVAL;", "if (hpet_enabled(s)) {", "hpet_set_timer(timer);", "}", "break;", "case HPET_TN_ROUTE:\ntimer->fsb = (timer->fsb & 0xffffffff00000000ULL) | new_val;", "break;", "case HPET_TN_ROUTE + 4:\ntimer->fsb = (new_val << 32) | (timer->fsb & 0xffffffff);", "break;", "default:\nDPRINTF(\"qemu: invalid hpet_ram_writel\\n\");", "break;", "}", "return;", "} else {", "switch (index) {", "case HPET_ID:\nreturn;", "case HPET_CFG:\nval = hpet_fixup_reg(new_val, old_val, HPET_CFG_WRITE_MASK);", "s->config = (s->config & 0xffffffff00000000ULL) | val;", "if (activating_bit(old_val, new_val, HPET_CFG_ENABLE)) {", "s->hpet_offset =\nticks_to_ns(s->hpet_counter) - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);", "for (VAR_4 = 0; VAR_4 < s->num_timers; VAR_4++) {", "if ((&s->timer[VAR_4])->cmp != ~0ULL) {", "hpet_set_timer(&s->timer[VAR_4]);", "}", "}", "} else if (deactivating_bit(old_val, new_val, HPET_CFG_ENABLE)) {", "s->hpet_counter = hpet_get_ticks(s);", "for (VAR_4 = 0; VAR_4 < s->num_timers; VAR_4++) {", "hpet_del_timer(&s->timer[VAR_4]);", "}", "}", "if (activating_bit(old_val, new_val, HPET_CFG_LEGACY)) {", "qemu_set_irq(s->pit_enabled, 0);", "qemu_irq_lower(s->irqs[0]);", "qemu_irq_lower(s->irqs[RTC_ISA_IRQ]);", "} else if (deactivating_bit(old_val, new_val, HPET_CFG_LEGACY)) {", "qemu_irq_lower(s->irqs[0]);", "qemu_set_irq(s->pit_enabled, 1);", "qemu_set_irq(s->irqs[RTC_ISA_IRQ], s->rtc_irq_level);", "}", "break;", "case HPET_CFG + 4:\nDPRINTF(\"qemu: invalid HPET_CFG+4 write\\n\");", "break;", "case HPET_STATUS:\nval = new_val & s->isr;", "for (VAR_4 = 0; VAR_4 < s->num_timers; VAR_4++) {", "if (val & (1 << VAR_4)) {", "update_irq(&s->timer[VAR_4], 0);", "}", "}", "break;", "case HPET_COUNTER:\nif (hpet_enabled(s)) {", "DPRINTF(\"qemu: Writing counter while HPET enabled!\\n\");", "}", "s->hpet_counter =\n(s->hpet_counter & 0xffffffff00000000ULL) | VAR_2;", "DPRINTF(\"qemu: HPET counter written. ctr = %#x -> %\" PRIx64 \"\\n\",\nVAR_2, s->hpet_counter);", "break;", "case HPET_COUNTER + 4:\nif (hpet_enabled(s)) {", "DPRINTF(\"qemu: Writing counter while HPET enabled!\\n\");", "}", "s->hpet_counter =\n(s->hpet_counter & 0xffffffffULL) | (((uint64_t)VAR_2) << 32);", "DPRINTF(\"qemu: HPET counter + 4 written. ctr = %#x -> %\" PRIx64 \"\\n\",\nVAR_2, s->hpet_counter);", "break;", "default:\nDPRINTF(\"qemu: invalid hpet_ram_writel\\n\");", "break;", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47, 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81, 83 ], [ 85 ], [ 87, 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97, 99 ], [ 101 ], [ 103 ], [ 105 ], [ 115 ], [ 117, 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133, 135 ], [ 137, 139 ], [ 141 ], [ 143 ], [ 153 ], [ 155, 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171, 173 ], [ 175 ], [ 177, 179 ], [ 181 ], [ 183, 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197, 199 ], [ 201, 203 ], [ 205 ], [ 207 ], [ 211, 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263, 265 ], [ 267 ], [ 269, 271 ], [ 273 ], [ 275 ], [ 277 ], [ 279 ], [ 281 ], [ 283 ], [ 285, 287 ], [ 289 ], [ 291 ], [ 293, 295 ], [ 297, 299 ], [ 301 ], [ 303, 305 ], [ 307 ], [ 309 ], [ 311, 313 ], [ 315, 317 ], [ 319 ], [ 321, 323 ], [ 325 ], [ 327 ], [ 329 ], [ 331 ] ]
638
static abi_ulong copy_elf_strings(int argc,char ** argv, void **page, abi_ulong p) { char *tmp, *tmp1, *pag = NULL; int len, offset = 0; if (!p) { return 0; /* bullet-proofing */ } while (argc-- > 0) { tmp = argv[argc]; if (!tmp) { fprintf(stderr, "VFS: argc is wrong"); exit(-1); } tmp1 = tmp; while (*tmp++); len = tmp - tmp1; if (p < len) { /* this shouldn't happen - 128kB */ return 0; } while (len) { --p; --tmp; --len; if (--offset < 0) { offset = p % TARGET_PAGE_SIZE; pag = (char *)page[p/TARGET_PAGE_SIZE]; if (!pag) { pag = (char *)malloc(TARGET_PAGE_SIZE); memset(pag, 0, TARGET_PAGE_SIZE); page[p/TARGET_PAGE_SIZE] = pag; if (!pag) return 0; } } if (len == 0 || offset == 0) { *(pag + offset) = *tmp; } else { int bytes_to_copy = (len > offset) ? offset : len; tmp -= bytes_to_copy; p -= bytes_to_copy; offset -= bytes_to_copy; len -= bytes_to_copy; memcpy_fromfs(pag + offset, tmp, bytes_to_copy + 1); } } } return p; }
true
qemu
7dd47667b9b0b23807fc1a550644fc2427462f41
static abi_ulong copy_elf_strings(int argc,char ** argv, void **page, abi_ulong p) { char *tmp, *tmp1, *pag = NULL; int len, offset = 0; if (!p) { return 0; } while (argc-- > 0) { tmp = argv[argc]; if (!tmp) { fprintf(stderr, "VFS: argc is wrong"); exit(-1); } tmp1 = tmp; while (*tmp++); len = tmp - tmp1; if (p < len) { return 0; } while (len) { --p; --tmp; --len; if (--offset < 0) { offset = p % TARGET_PAGE_SIZE; pag = (char *)page[p/TARGET_PAGE_SIZE]; if (!pag) { pag = (char *)malloc(TARGET_PAGE_SIZE); memset(pag, 0, TARGET_PAGE_SIZE); page[p/TARGET_PAGE_SIZE] = pag; if (!pag) return 0; } } if (len == 0 || offset == 0) { *(pag + offset) = *tmp; } else { int bytes_to_copy = (len > offset) ? offset : len; tmp -= bytes_to_copy; p -= bytes_to_copy; offset -= bytes_to_copy; len -= bytes_to_copy; memcpy_fromfs(pag + offset, tmp, bytes_to_copy + 1); } } } return p; }
{ "code": [ " pag = (char *)malloc(TARGET_PAGE_SIZE);", " memset(pag, 0, TARGET_PAGE_SIZE);" ], "line_no": [ 55, 57 ] }
static abi_ulong FUNC_0(int argc,char ** argv, void **page, abi_ulong p) { char *VAR_0, *VAR_1, *VAR_2 = NULL; int VAR_3, VAR_4 = 0; if (!p) { return 0; } while (argc-- > 0) { VAR_0 = argv[argc]; if (!VAR_0) { fprintf(stderr, "VFS: argc is wrong"); exit(-1); } VAR_1 = VAR_0; while (*VAR_0++); VAR_3 = VAR_0 - VAR_1; if (p < VAR_3) { return 0; } while (VAR_3) { --p; --VAR_0; --VAR_3; if (--VAR_4 < 0) { VAR_4 = p % TARGET_PAGE_SIZE; VAR_2 = (char *)page[p/TARGET_PAGE_SIZE]; if (!VAR_2) { VAR_2 = (char *)malloc(TARGET_PAGE_SIZE); memset(VAR_2, 0, TARGET_PAGE_SIZE); page[p/TARGET_PAGE_SIZE] = VAR_2; if (!VAR_2) return 0; } } if (VAR_3 == 0 || VAR_4 == 0) { *(VAR_2 + VAR_4) = *VAR_0; } else { int VAR_5 = (VAR_3 > VAR_4) ? VAR_4 : VAR_3; VAR_0 -= VAR_5; p -= VAR_5; VAR_4 -= VAR_5; VAR_3 -= VAR_5; memcpy_fromfs(VAR_2 + VAR_4, VAR_0, VAR_5 + 1); } } } return p; }
[ "static abi_ulong FUNC_0(int argc,char ** argv, void **page,\nabi_ulong p)\n{", "char *VAR_0, *VAR_1, *VAR_2 = NULL;", "int VAR_3, VAR_4 = 0;", "if (!p) {", "return 0;", "}", "while (argc-- > 0) {", "VAR_0 = argv[argc];", "if (!VAR_0) {", "fprintf(stderr, \"VFS: argc is wrong\");", "exit(-1);", "}", "VAR_1 = VAR_0;", "while (*VAR_0++);", "VAR_3 = VAR_0 - VAR_1;", "if (p < VAR_3) {", "return 0;", "}", "while (VAR_3) {", "--p; --VAR_0; --VAR_3;", "if (--VAR_4 < 0) {", "VAR_4 = p % TARGET_PAGE_SIZE;", "VAR_2 = (char *)page[p/TARGET_PAGE_SIZE];", "if (!VAR_2) {", "VAR_2 = (char *)malloc(TARGET_PAGE_SIZE);", "memset(VAR_2, 0, TARGET_PAGE_SIZE);", "page[p/TARGET_PAGE_SIZE] = VAR_2;", "if (!VAR_2)\nreturn 0;", "}", "}", "if (VAR_3 == 0 || VAR_4 == 0) {", "*(VAR_2 + VAR_4) = *VAR_0;", "}", "else {", "int VAR_5 = (VAR_3 > VAR_4) ? VAR_4 : VAR_3;", "VAR_0 -= VAR_5;", "p -= VAR_5;", "VAR_4 -= VAR_5;", "VAR_3 -= VAR_5;", "memcpy_fromfs(VAR_2 + VAR_4, VAR_0, VAR_5 + 1);", "}", "}", "}", "return p;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 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 ], [ 97 ] ]
639
static int mov_text_decode_close(AVCodecContext *avctx) { MovTextContext *m = avctx->priv_data; mov_text_cleanup_ftab(m); return 0; }
true
FFmpeg
a9f9b7f5c70e80245983e67b8ed23212d9637645
static int mov_text_decode_close(AVCodecContext *avctx) { MovTextContext *m = avctx->priv_data; mov_text_cleanup_ftab(m); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVCodecContext *VAR_0) { MovTextContext *m = VAR_0->priv_data; mov_text_cleanup_ftab(m); return 0; }
[ "static int FUNC_0(AVCodecContext *VAR_0)\n{", "MovTextContext *m = VAR_0->priv_data;", "mov_text_cleanup_ftab(m);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 10 ], [ 12 ] ]
640
static void xhci_intr_raise(XHCIState *xhci, int v) { PCIDevice *pci_dev = PCI_DEVICE(xhci); xhci->intr[v].erdp_low |= ERDP_EHB; xhci->intr[v].iman |= IMAN_IP; xhci->usbsts |= USBSTS_EINT; if (!(xhci->intr[v].iman & IMAN_IE)) { if (!(xhci->usbcmd & USBCMD_INTE)) { if (msix_enabled(pci_dev)) { trace_usb_xhci_irq_msix(v); msix_notify(pci_dev, v); if (msi_enabled(pci_dev)) { trace_usb_xhci_irq_msi(v); msi_notify(pci_dev, v); if (v == 0) { trace_usb_xhci_irq_intx(1); pci_irq_assert(pci_dev);
true
qemu
7da76e12cc5cc902dda4c168d8d608fd4e61cbc5
static void xhci_intr_raise(XHCIState *xhci, int v) { PCIDevice *pci_dev = PCI_DEVICE(xhci); xhci->intr[v].erdp_low |= ERDP_EHB; xhci->intr[v].iman |= IMAN_IP; xhci->usbsts |= USBSTS_EINT; if (!(xhci->intr[v].iman & IMAN_IE)) { if (!(xhci->usbcmd & USBCMD_INTE)) { if (msix_enabled(pci_dev)) { trace_usb_xhci_irq_msix(v); msix_notify(pci_dev, v); if (msi_enabled(pci_dev)) { trace_usb_xhci_irq_msi(v); msi_notify(pci_dev, v); if (v == 0) { trace_usb_xhci_irq_intx(1); pci_irq_assert(pci_dev);
{ "code": [], "line_no": [] }
static void FUNC_0(XHCIState *VAR_0, int VAR_1) { PCIDevice *pci_dev = PCI_DEVICE(VAR_0); VAR_0->intr[VAR_1].erdp_low |= ERDP_EHB; VAR_0->intr[VAR_1].iman |= IMAN_IP; VAR_0->usbsts |= USBSTS_EINT; if (!(VAR_0->intr[VAR_1].iman & IMAN_IE)) { if (!(VAR_0->usbcmd & USBCMD_INTE)) { if (msix_enabled(pci_dev)) { trace_usb_xhci_irq_msix(VAR_1); msix_notify(pci_dev, VAR_1); if (msi_enabled(pci_dev)) { trace_usb_xhci_irq_msi(VAR_1); msi_notify(pci_dev, VAR_1); if (VAR_1 == 0) { trace_usb_xhci_irq_intx(1); pci_irq_assert(pci_dev);
[ "static void FUNC_0(XHCIState *VAR_0, int VAR_1)\n{", "PCIDevice *pci_dev = PCI_DEVICE(VAR_0);", "VAR_0->intr[VAR_1].erdp_low |= ERDP_EHB;", "VAR_0->intr[VAR_1].iman |= IMAN_IP;", "VAR_0->usbsts |= USBSTS_EINT;", "if (!(VAR_0->intr[VAR_1].iman & IMAN_IE)) {", "if (!(VAR_0->usbcmd & USBCMD_INTE)) {", "if (msix_enabled(pci_dev)) {", "trace_usb_xhci_irq_msix(VAR_1);", "msix_notify(pci_dev, VAR_1);", "if (msi_enabled(pci_dev)) {", "trace_usb_xhci_irq_msi(VAR_1);", "msi_notify(pci_dev, VAR_1);", "if (VAR_1 == 0) {", "trace_usb_xhci_irq_intx(1);", "pci_irq_assert(pci_dev);" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 10 ], [ 12 ], [ 14 ], [ 21 ], [ 27 ], [ 33 ], [ 35 ], [ 37 ], [ 43 ], [ 45 ], [ 47 ], [ 53 ], [ 55 ], [ 57 ] ]
641
int qemu_chr_fe_get_msgfd(CharDriverState *s) { int fd; return (qemu_chr_fe_get_msgfds(s, &fd, 1) >= 0) ? fd : -1; }
true
qemu
4f8586144161d5e680fdef3e09b7e8e9111c2929
int qemu_chr_fe_get_msgfd(CharDriverState *s) { int fd; return (qemu_chr_fe_get_msgfds(s, &fd, 1) >= 0) ? fd : -1; }
{ "code": [ " return (qemu_chr_fe_get_msgfds(s, &fd, 1) >= 0) ? fd : -1;" ], "line_no": [ 7 ] }
int FUNC_0(CharDriverState *VAR_0) { int VAR_1; return (qemu_chr_fe_get_msgfds(VAR_0, &VAR_1, 1) >= 0) ? VAR_1 : -1; }
[ "int FUNC_0(CharDriverState *VAR_0)\n{", "int VAR_1;", "return (qemu_chr_fe_get_msgfds(VAR_0, &VAR_1, 1) >= 0) ? VAR_1 : -1;", "}" ]
[ 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ] ]
642
void qemu_set_dfilter_ranges(const char *filter_spec) { gchar **ranges = g_strsplit(filter_spec, ",", 0); if (ranges) { gchar **next = ranges; gchar *r = *next++; debug_regions = g_array_sized_new(FALSE, FALSE, sizeof(Range), g_strv_length(ranges)); while (r) { char *range_op = strstr(r, "-"); char *r2 = range_op ? range_op + 1 : NULL; if (!range_op) { range_op = strstr(r, "+"); r2 = range_op ? range_op + 1 : NULL; if (!range_op) { range_op = strstr(r, ".."); r2 = range_op ? range_op + 2 : NULL; if (range_op) { const char *e = NULL; uint64_t r1val, r2val; if ((qemu_strtoull(r, &e, 0, &r1val) == 0) && (qemu_strtoull(r2, NULL, 0, &r2val) == 0) && r2val > 0) { struct Range range; g_assert(e == range_op); switch (*range_op) { case '+': { range.begin = r1val; range.end = r1val + (r2val - 1); break; case '-': { range.end = r1val; range.begin = r1val - (r2val - 1); break; case '.': range.begin = r1val; range.end = r2val; break; default: g_assert_not_reached(); g_array_append_val(debug_regions, range); } else { g_error("Failed to parse range in: %s", r); } else { g_error("Bad range specifier in: %s", r); r = *next++; g_strfreev(ranges);
true
qemu
2ec62faea274aabb2feaad2b8f85961161b5e1e4
void qemu_set_dfilter_ranges(const char *filter_spec) { gchar **ranges = g_strsplit(filter_spec, ",", 0); if (ranges) { gchar **next = ranges; gchar *r = *next++; debug_regions = g_array_sized_new(FALSE, FALSE, sizeof(Range), g_strv_length(ranges)); while (r) { char *range_op = strstr(r, "-"); char *r2 = range_op ? range_op + 1 : NULL; if (!range_op) { range_op = strstr(r, "+"); r2 = range_op ? range_op + 1 : NULL; if (!range_op) { range_op = strstr(r, ".."); r2 = range_op ? range_op + 2 : NULL; if (range_op) { const char *e = NULL; uint64_t r1val, r2val; if ((qemu_strtoull(r, &e, 0, &r1val) == 0) && (qemu_strtoull(r2, NULL, 0, &r2val) == 0) && r2val > 0) { struct Range range; g_assert(e == range_op); switch (*range_op) { case '+': { range.begin = r1val; range.end = r1val + (r2val - 1); break; case '-': { range.end = r1val; range.begin = r1val - (r2val - 1); break; case '.': range.begin = r1val; range.end = r2val; break; default: g_assert_not_reached(); g_array_append_val(debug_regions, range); } else { g_error("Failed to parse range in: %s", r); } else { g_error("Bad range specifier in: %s", r); r = *next++; g_strfreev(ranges);
{ "code": [], "line_no": [] }
void FUNC_0(const char *VAR_0) { gchar **ranges = g_strsplit(VAR_0, ",", 0); if (ranges) { gchar **next = ranges; gchar *r = *next++; debug_regions = g_array_sized_new(FALSE, FALSE, sizeof(Range), g_strv_length(ranges)); while (r) { char *VAR_1 = strstr(r, "-"); char *VAR_2 = VAR_1 ? VAR_1 + 1 : NULL; if (!VAR_1) { VAR_1 = strstr(r, "+"); VAR_2 = VAR_1 ? VAR_1 + 1 : NULL; if (!VAR_1) { VAR_1 = strstr(r, ".."); VAR_2 = VAR_1 ? VAR_1 + 2 : NULL; if (VAR_1) { const char *VAR_3 = NULL; uint64_t r1val, r2val; if ((qemu_strtoull(r, &VAR_3, 0, &r1val) == 0) && (qemu_strtoull(VAR_2, NULL, 0, &r2val) == 0) && r2val > 0) { struct Range VAR_4; g_assert(VAR_3 == VAR_1); switch (*VAR_1) { case '+': { VAR_4.begin = r1val; VAR_4.end = r1val + (r2val - 1); break; case '-': { VAR_4.end = r1val; VAR_4.begin = r1val - (r2val - 1); break; case '.': VAR_4.begin = r1val; VAR_4.end = r2val; break; default: g_assert_not_reached(); g_array_append_val(debug_regions, VAR_4); } else { g_error("Failed to parse VAR_4 in: %s", r); } else { g_error("Bad VAR_4 specifier in: %s", r); r = *next++; g_strfreev(ranges);
[ "void FUNC_0(const char *VAR_0)\n{", "gchar **ranges = g_strsplit(VAR_0, \",\", 0);", "if (ranges) {", "gchar **next = ranges;", "gchar *r = *next++;", "debug_regions = g_array_sized_new(FALSE, FALSE,\nsizeof(Range), g_strv_length(ranges));", "while (r) {", "char *VAR_1 = strstr(r, \"-\");", "char *VAR_2 = VAR_1 ? VAR_1 + 1 : NULL;", "if (!VAR_1) {", "VAR_1 = strstr(r, \"+\");", "VAR_2 = VAR_1 ? VAR_1 + 1 : NULL;", "if (!VAR_1) {", "VAR_1 = strstr(r, \"..\");", "VAR_2 = VAR_1 ? VAR_1 + 2 : NULL;", "if (VAR_1) {", "const char *VAR_3 = NULL;", "uint64_t r1val, r2val;", "if ((qemu_strtoull(r, &VAR_3, 0, &r1val) == 0) &&\n(qemu_strtoull(VAR_2, NULL, 0, &r2val) == 0) &&\nr2val > 0) {", "struct Range VAR_4;", "g_assert(VAR_3 == VAR_1);", "switch (*VAR_1) {", "case '+':\n{", "VAR_4.begin = r1val;", "VAR_4.end = r1val + (r2val - 1);", "break;", "case '-':\n{", "VAR_4.end = r1val;", "VAR_4.begin = r1val - (r2val - 1);", "break;", "case '.':\nVAR_4.begin = r1val;", "VAR_4.end = r2val;", "break;", "default:\ng_assert_not_reached();", "g_array_append_val(debug_regions, VAR_4);", "} else {", "g_error(\"Failed to parse VAR_4 in: %s\", r);", "} else {", "g_error(\"Bad VAR_4 specifier in: %s\", r);", "r = *next++;", "g_strfreev(ranges);" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 10 ], [ 11 ], [ 12 ], [ 13 ], [ 14 ], [ 15 ], [ 16 ], [ 17 ], [ 18 ], [ 19 ], [ 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 ] ]
643
static void flush(AVCodecContext *avctx) { WmallDecodeCtx *s = avctx->priv_data; s->packet_loss = 1; s->packet_done = 0; s->num_saved_bits = 0; s->frame_offset = 0; s->next_packet_start = 0; s->cdlms[0][0].order = 0; s->frame.nb_samples = 0; init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE); }
true
FFmpeg
3ca5df36a50e3ffd3b24734725bf545617a627a8
static void flush(AVCodecContext *avctx) { WmallDecodeCtx *s = avctx->priv_data; s->packet_loss = 1; s->packet_done = 0; s->num_saved_bits = 0; s->frame_offset = 0; s->next_packet_start = 0; s->cdlms[0][0].order = 0; s->frame.nb_samples = 0; init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE); }
{ "code": [ " s->frame.nb_samples = 0;" ], "line_no": [ 19 ] }
static void FUNC_0(AVCodecContext *VAR_0) { WmallDecodeCtx *s = VAR_0->priv_data; s->packet_loss = 1; s->packet_done = 0; s->num_saved_bits = 0; s->frame_offset = 0; s->next_packet_start = 0; s->cdlms[0][0].order = 0; s->frame.nb_samples = 0; init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE); }
[ "static void FUNC_0(AVCodecContext *VAR_0)\n{", "WmallDecodeCtx *s = VAR_0->priv_data;", "s->packet_loss = 1;", "s->packet_done = 0;", "s->num_saved_bits = 0;", "s->frame_offset = 0;", "s->next_packet_start = 0;", "s->cdlms[0][0].order = 0;", "s->frame.nb_samples = 0;", "init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ] ]
644
avs_decode_frame(AVCodecContext * avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; const uint8_t *buf_end = avpkt->data + avpkt->size; int buf_size = avpkt->size; AvsContext *const avs = avctx->priv_data; AVFrame *picture = data; AVFrame *const p = &avs->picture; const uint8_t *table, *vect; uint8_t *out; int i, j, x, y, stride, vect_w = 3, vect_h = 3; AvsVideoSubType sub_type; AvsBlockType type; GetBitContext change_map; if (avctx->reget_buffer(avctx, p)) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return -1; } p->reference = 3; p->pict_type = AV_PICTURE_TYPE_P; p->key_frame = 0; out = avs->picture.data[0]; stride = avs->picture.linesize[0]; if (buf_end - buf < 4) return AVERROR_INVALIDDATA; sub_type = buf[0]; type = buf[1]; buf += 4; if (type == AVS_PALETTE) { int first, last; uint32_t *pal = (uint32_t *) avs->picture.data[1]; first = AV_RL16(buf); last = first + AV_RL16(buf + 2); if (first >= 256 || last > 256 || buf_end - buf < 4 + 4 + 3 * (last - first)) return AVERROR_INVALIDDATA; buf += 4; for (i=first; i<last; i++, buf+=3) { pal[i] = (buf[0] << 18) | (buf[1] << 10) | (buf[2] << 2); pal[i] |= 0xFF << 24 | (pal[i] >> 6) & 0x30303; } sub_type = buf[0]; type = buf[1]; buf += 4; } if (type != AVS_VIDEO) return -1; switch (sub_type) { case AVS_I_FRAME: p->pict_type = AV_PICTURE_TYPE_I; p->key_frame = 1; case AVS_P_FRAME_3X3: vect_w = 3; vect_h = 3; break; case AVS_P_FRAME_2X2: vect_w = 2; vect_h = 2; break; case AVS_P_FRAME_2X3: vect_w = 2; vect_h = 3; break; default: return -1; } if (buf_end - buf < 256 * vect_w * vect_h) return AVERROR_INVALIDDATA; table = buf + (256 * vect_w * vect_h); if (sub_type != AVS_I_FRAME) { int map_size = ((318 / vect_w + 7) / 8) * (198 / vect_h); if (buf_end - table < map_size) return AVERROR_INVALIDDATA; init_get_bits(&change_map, table, map_size * 8); table += map_size; } for (y=0; y<198; y+=vect_h) { for (x=0; x<318; x+=vect_w) { if (sub_type == AVS_I_FRAME || get_bits1(&change_map)) { if (buf_end - table < 1) return AVERROR_INVALIDDATA; vect = &buf[*table++ * (vect_w * vect_h)]; for (j=0; j<vect_w; j++) { out[(y + 0) * stride + x + j] = vect[(0 * vect_w) + j]; out[(y + 1) * stride + x + j] = vect[(1 * vect_w) + j]; if (vect_h == 3) out[(y + 2) * stride + x + j] = vect[(2 * vect_w) + j]; } } } if (sub_type != AVS_I_FRAME) align_get_bits(&change_map); } *picture = avs->picture; *data_size = sizeof(AVPicture); return buf_size; }
true
FFmpeg
b12d92efd6c0d48665383a9baecc13e7ebbd8a22
avs_decode_frame(AVCodecContext * avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; const uint8_t *buf_end = avpkt->data + avpkt->size; int buf_size = avpkt->size; AvsContext *const avs = avctx->priv_data; AVFrame *picture = data; AVFrame *const p = &avs->picture; const uint8_t *table, *vect; uint8_t *out; int i, j, x, y, stride, vect_w = 3, vect_h = 3; AvsVideoSubType sub_type; AvsBlockType type; GetBitContext change_map; if (avctx->reget_buffer(avctx, p)) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return -1; } p->reference = 3; p->pict_type = AV_PICTURE_TYPE_P; p->key_frame = 0; out = avs->picture.data[0]; stride = avs->picture.linesize[0]; if (buf_end - buf < 4) return AVERROR_INVALIDDATA; sub_type = buf[0]; type = buf[1]; buf += 4; if (type == AVS_PALETTE) { int first, last; uint32_t *pal = (uint32_t *) avs->picture.data[1]; first = AV_RL16(buf); last = first + AV_RL16(buf + 2); if (first >= 256 || last > 256 || buf_end - buf < 4 + 4 + 3 * (last - first)) return AVERROR_INVALIDDATA; buf += 4; for (i=first; i<last; i++, buf+=3) { pal[i] = (buf[0] << 18) | (buf[1] << 10) | (buf[2] << 2); pal[i] |= 0xFF << 24 | (pal[i] >> 6) & 0x30303; } sub_type = buf[0]; type = buf[1]; buf += 4; } if (type != AVS_VIDEO) return -1; switch (sub_type) { case AVS_I_FRAME: p->pict_type = AV_PICTURE_TYPE_I; p->key_frame = 1; case AVS_P_FRAME_3X3: vect_w = 3; vect_h = 3; break; case AVS_P_FRAME_2X2: vect_w = 2; vect_h = 2; break; case AVS_P_FRAME_2X3: vect_w = 2; vect_h = 3; break; default: return -1; } if (buf_end - buf < 256 * vect_w * vect_h) return AVERROR_INVALIDDATA; table = buf + (256 * vect_w * vect_h); if (sub_type != AVS_I_FRAME) { int map_size = ((318 / vect_w + 7) / 8) * (198 / vect_h); if (buf_end - table < map_size) return AVERROR_INVALIDDATA; init_get_bits(&change_map, table, map_size * 8); table += map_size; } for (y=0; y<198; y+=vect_h) { for (x=0; x<318; x+=vect_w) { if (sub_type == AVS_I_FRAME || get_bits1(&change_map)) { if (buf_end - table < 1) return AVERROR_INVALIDDATA; vect = &buf[*table++ * (vect_w * vect_h)]; for (j=0; j<vect_w; j++) { out[(y + 0) * stride + x + j] = vect[(0 * vect_w) + j]; out[(y + 1) * stride + x + j] = vect[(1 * vect_w) + j]; if (vect_h == 3) out[(y + 2) * stride + x + j] = vect[(2 * vect_w) + j]; } } } if (sub_type != AVS_I_FRAME) align_get_bits(&change_map); } *picture = avs->picture; *data_size = sizeof(AVPicture); return buf_size; }
{ "code": [ " pal[i] |= 0xFF << 24 | (pal[i] >> 6) & 0x30303;" ], "line_no": [ 89 ] }
FUNC_0(AVCodecContext * VAR_0, void *VAR_1, int *VAR_2, AVPacket *VAR_3) { const uint8_t *VAR_4 = VAR_3->VAR_1; const uint8_t *VAR_5 = VAR_3->VAR_1 + VAR_3->size; int VAR_6 = VAR_3->size; AvsContext *const avs = VAR_0->priv_data; AVFrame *picture = VAR_1; AVFrame *const p = &avs->picture; const uint8_t *VAR_7, *vect; uint8_t *out; int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13 = 3, VAR_14 = 3; AvsVideoSubType sub_type; AvsBlockType type; GetBitContext change_map; if (VAR_0->reget_buffer(VAR_0, p)) { av_log(VAR_0, AV_LOG_ERROR, "reget_buffer() failed\n"); return -1; } p->reference = 3; p->pict_type = AV_PICTURE_TYPE_P; p->key_frame = 0; out = avs->picture.VAR_1[0]; VAR_12 = avs->picture.linesize[0]; if (VAR_5 - VAR_4 < 4) return AVERROR_INVALIDDATA; sub_type = VAR_4[0]; type = VAR_4[1]; VAR_4 += 4; if (type == AVS_PALETTE) { int VAR_15, VAR_16; uint32_t *pal = (uint32_t *) avs->picture.VAR_1[1]; VAR_15 = AV_RL16(VAR_4); VAR_16 = VAR_15 + AV_RL16(VAR_4 + 2); if (VAR_15 >= 256 || VAR_16 > 256 || VAR_5 - VAR_4 < 4 + 4 + 3 * (VAR_16 - VAR_15)) return AVERROR_INVALIDDATA; VAR_4 += 4; for (VAR_8=VAR_15; VAR_8<VAR_16; VAR_8++, VAR_4+=3) { pal[VAR_8] = (VAR_4[0] << 18) | (VAR_4[1] << 10) | (VAR_4[2] << 2); pal[VAR_8] |= 0xFF << 24 | (pal[VAR_8] >> 6) & 0x30303; } sub_type = VAR_4[0]; type = VAR_4[1]; VAR_4 += 4; } if (type != AVS_VIDEO) return -1; switch (sub_type) { case AVS_I_FRAME: p->pict_type = AV_PICTURE_TYPE_I; p->key_frame = 1; case AVS_P_FRAME_3X3: VAR_13 = 3; VAR_14 = 3; break; case AVS_P_FRAME_2X2: VAR_13 = 2; VAR_14 = 2; break; case AVS_P_FRAME_2X3: VAR_13 = 2; VAR_14 = 3; break; default: return -1; } if (VAR_5 - VAR_4 < 256 * VAR_13 * VAR_14) return AVERROR_INVALIDDATA; VAR_7 = VAR_4 + (256 * VAR_13 * VAR_14); if (sub_type != AVS_I_FRAME) { int VAR_17 = ((318 / VAR_13 + 7) / 8) * (198 / VAR_14); if (VAR_5 - VAR_7 < VAR_17) return AVERROR_INVALIDDATA; init_get_bits(&change_map, VAR_7, VAR_17 * 8); VAR_7 += VAR_17; } for (VAR_11=0; VAR_11<198; VAR_11+=VAR_14) { for (VAR_10=0; VAR_10<318; VAR_10+=VAR_13) { if (sub_type == AVS_I_FRAME || get_bits1(&change_map)) { if (VAR_5 - VAR_7 < 1) return AVERROR_INVALIDDATA; vect = &VAR_4[*VAR_7++ * (VAR_13 * VAR_14)]; for (VAR_9=0; VAR_9<VAR_13; VAR_9++) { out[(VAR_11 + 0) * VAR_12 + VAR_10 + VAR_9] = vect[(0 * VAR_13) + VAR_9]; out[(VAR_11 + 1) * VAR_12 + VAR_10 + VAR_9] = vect[(1 * VAR_13) + VAR_9]; if (VAR_14 == 3) out[(VAR_11 + 2) * VAR_12 + VAR_10 + VAR_9] = vect[(2 * VAR_13) + VAR_9]; } } } if (sub_type != AVS_I_FRAME) align_get_bits(&change_map); } *picture = avs->picture; *VAR_2 = sizeof(AVPicture); return VAR_6; }
[ "FUNC_0(AVCodecContext * VAR_0,\nvoid *VAR_1, int *VAR_2, AVPacket *VAR_3)\n{", "const uint8_t *VAR_4 = VAR_3->VAR_1;", "const uint8_t *VAR_5 = VAR_3->VAR_1 + VAR_3->size;", "int VAR_6 = VAR_3->size;", "AvsContext *const avs = VAR_0->priv_data;", "AVFrame *picture = VAR_1;", "AVFrame *const p = &avs->picture;", "const uint8_t *VAR_7, *vect;", "uint8_t *out;", "int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13 = 3, VAR_14 = 3;", "AvsVideoSubType sub_type;", "AvsBlockType type;", "GetBitContext change_map;", "if (VAR_0->reget_buffer(VAR_0, p)) {", "av_log(VAR_0, AV_LOG_ERROR, \"reget_buffer() failed\\n\");", "return -1;", "}", "p->reference = 3;", "p->pict_type = AV_PICTURE_TYPE_P;", "p->key_frame = 0;", "out = avs->picture.VAR_1[0];", "VAR_12 = avs->picture.linesize[0];", "if (VAR_5 - VAR_4 < 4)\nreturn AVERROR_INVALIDDATA;", "sub_type = VAR_4[0];", "type = VAR_4[1];", "VAR_4 += 4;", "if (type == AVS_PALETTE) {", "int VAR_15, VAR_16;", "uint32_t *pal = (uint32_t *) avs->picture.VAR_1[1];", "VAR_15 = AV_RL16(VAR_4);", "VAR_16 = VAR_15 + AV_RL16(VAR_4 + 2);", "if (VAR_15 >= 256 || VAR_16 > 256 || VAR_5 - VAR_4 < 4 + 4 + 3 * (VAR_16 - VAR_15))\nreturn AVERROR_INVALIDDATA;", "VAR_4 += 4;", "for (VAR_8=VAR_15; VAR_8<VAR_16; VAR_8++, VAR_4+=3) {", "pal[VAR_8] = (VAR_4[0] << 18) | (VAR_4[1] << 10) | (VAR_4[2] << 2);", "pal[VAR_8] |= 0xFF << 24 | (pal[VAR_8] >> 6) & 0x30303;", "}", "sub_type = VAR_4[0];", "type = VAR_4[1];", "VAR_4 += 4;", "}", "if (type != AVS_VIDEO)\nreturn -1;", "switch (sub_type) {", "case AVS_I_FRAME:\np->pict_type = AV_PICTURE_TYPE_I;", "p->key_frame = 1;", "case AVS_P_FRAME_3X3:\nVAR_13 = 3;", "VAR_14 = 3;", "break;", "case AVS_P_FRAME_2X2:\nVAR_13 = 2;", "VAR_14 = 2;", "break;", "case AVS_P_FRAME_2X3:\nVAR_13 = 2;", "VAR_14 = 3;", "break;", "default:\nreturn -1;", "}", "if (VAR_5 - VAR_4 < 256 * VAR_13 * VAR_14)\nreturn AVERROR_INVALIDDATA;", "VAR_7 = VAR_4 + (256 * VAR_13 * VAR_14);", "if (sub_type != AVS_I_FRAME) {", "int VAR_17 = ((318 / VAR_13 + 7) / 8) * (198 / VAR_14);", "if (VAR_5 - VAR_7 < VAR_17)\nreturn AVERROR_INVALIDDATA;", "init_get_bits(&change_map, VAR_7, VAR_17 * 8);", "VAR_7 += VAR_17;", "}", "for (VAR_11=0; VAR_11<198; VAR_11+=VAR_14) {", "for (VAR_10=0; VAR_10<318; VAR_10+=VAR_13) {", "if (sub_type == AVS_I_FRAME || get_bits1(&change_map)) {", "if (VAR_5 - VAR_7 < 1)\nreturn AVERROR_INVALIDDATA;", "vect = &VAR_4[*VAR_7++ * (VAR_13 * VAR_14)];", "for (VAR_9=0; VAR_9<VAR_13; VAR_9++) {", "out[(VAR_11 + 0) * VAR_12 + VAR_10 + VAR_9] = vect[(0 * VAR_13) + VAR_9];", "out[(VAR_11 + 1) * VAR_12 + VAR_10 + VAR_9] = vect[(1 * VAR_13) + VAR_9];", "if (VAR_14 == 3)\nout[(VAR_11 + 2) * VAR_12 + VAR_10 + VAR_9] =\nvect[(2 * VAR_13) + VAR_9];", "}", "}", "}", "if (sub_type != AVS_I_FRAME)\nalign_get_bits(&change_map);", "}", "*picture = avs->picture;", "*VAR_2 = sizeof(AVPicture);", "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, 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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 55, 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 79, 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 105, 107 ], [ 111 ], [ 113, 115 ], [ 117 ], [ 119, 121 ], [ 123 ], [ 125 ], [ 129, 131 ], [ 133 ], [ 135 ], [ 139, 141 ], [ 143 ], [ 145 ], [ 149, 151 ], [ 153 ], [ 157, 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167, 169 ], [ 171 ], [ 173 ], [ 175 ], [ 179 ], [ 181 ], [ 183 ], [ 185, 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197, 199, 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209, 211 ], [ 213 ], [ 217 ], [ 219 ], [ 223 ], [ 225 ] ]
645
static void uc32_cpu_realizefn(DeviceState *dev, Error **errp) { UniCore32CPUClass *ucc = UNICORE32_CPU_GET_CLASS(dev); ucc->parent_realize(dev, errp); }
true
qemu
14a10fc39923b3af07c8c46d22cb20843bee3a72
static void uc32_cpu_realizefn(DeviceState *dev, Error **errp) { UniCore32CPUClass *ucc = UNICORE32_CPU_GET_CLASS(dev); ucc->parent_realize(dev, errp); }
{ "code": [], "line_no": [] }
static void FUNC_0(DeviceState *VAR_0, Error **VAR_1) { UniCore32CPUClass *ucc = UNICORE32_CPU_GET_CLASS(VAR_0); ucc->parent_realize(VAR_0, VAR_1); }
[ "static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{", "UniCore32CPUClass *ucc = UNICORE32_CPU_GET_CLASS(VAR_0);", "ucc->parent_realize(VAR_0, VAR_1);", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 2 ], [ 3 ], [ 4 ], [ 5 ] ]
647
void parse_option_size(const char *name, const char *value, uint64_t *ret, Error **errp) { char *postfix; double sizef; sizef = strtod(value, &postfix); if (sizef < 0 || sizef > UINT64_MAX) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a non-negative number below 2^64"); return; } switch (*postfix) { case 'T': sizef *= 1024; /* fall through */ case 'G': sizef *= 1024; /* fall through */ case 'M': sizef *= 1024; /* fall through */ case 'K': case 'k': sizef *= 1024; /* fall through */ case 'b': case '\0': *ret = (uint64_t) sizef; break; default: error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size"); error_append_hint(errp, "You may use k, M, G or T suffixes for " "kilobytes, megabytes, gigabytes and terabytes.\n"); return; } }
true
qemu
75cdcd1553e74b5edc58aed23e3b2da8dabb1876
void parse_option_size(const char *name, const char *value, uint64_t *ret, Error **errp) { char *postfix; double sizef; sizef = strtod(value, &postfix); if (sizef < 0 || sizef > UINT64_MAX) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a non-negative number below 2^64"); return; } switch (*postfix) { case 'T': sizef *= 1024; case 'G': sizef *= 1024; case 'M': sizef *= 1024; case 'K': case 'k': sizef *= 1024; case 'b': case '\0': *ret = (uint64_t) sizef; break; default: error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size"); error_append_hint(errp, "You may use k, M, G or T suffixes for " "kilobytes, megabytes, gigabytes and terabytes.\n"); return; } }
{ "code": [ " char *postfix;", " double sizef;", " sizef = strtod(value, &postfix);", " if (sizef < 0 || sizef > UINT64_MAX) {", " error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name,", " \"a non-negative number below 2^64\");", " switch (*postfix) {", " case 'T':", " sizef *= 1024;", " case 'G':", " sizef *= 1024;", " case 'M':", " sizef *= 1024;", " case 'K':", " case 'k':", " sizef *= 1024;", " case 'b':", " case '\\0':", " *ret = (uint64_t) sizef;", " break;", " default:", " error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, \"a size\");", " error_append_hint(errp, \"You may use k, M, G or T suffixes for \"", " \"kilobytes, megabytes, gigabytes and terabytes.\\n\");" ], "line_no": [ 7, 9, 13, 15, 17, 19, 25, 27, 29, 33, 29, 39, 29, 45, 47, 29, 53, 55, 57, 59, 61, 63, 65, 67 ] }
void FUNC_0(const char *VAR_0, const char *VAR_1, uint64_t *VAR_2, Error **VAR_3) { char *VAR_4; double VAR_5; VAR_5 = strtod(VAR_1, &VAR_4); if (VAR_5 < 0 || VAR_5 > UINT64_MAX) { error_setg(VAR_3, QERR_INVALID_PARAMETER_VALUE, VAR_0, "a non-negative number below 2^64"); return; } switch (*VAR_4) { case 'T': VAR_5 *= 1024; case 'G': VAR_5 *= 1024; case 'M': VAR_5 *= 1024; case 'K': case 'k': VAR_5 *= 1024; case 'b': case '\0': *VAR_2 = (uint64_t) VAR_5; break; default: error_setg(VAR_3, QERR_INVALID_PARAMETER_VALUE, VAR_0, "a size"); error_append_hint(VAR_3, "You may use k, M, G or T suffixes for " "kilobytes, megabytes, gigabytes and terabytes.\n"); return; } }
[ "void FUNC_0(const char *VAR_0, const char *VAR_1,\nuint64_t *VAR_2, Error **VAR_3)\n{", "char *VAR_4;", "double VAR_5;", "VAR_5 = strtod(VAR_1, &VAR_4);", "if (VAR_5 < 0 || VAR_5 > UINT64_MAX) {", "error_setg(VAR_3, QERR_INVALID_PARAMETER_VALUE, VAR_0,\n\"a non-negative number below 2^64\");", "return;", "}", "switch (*VAR_4) {", "case 'T':\nVAR_5 *= 1024;", "case 'G':\nVAR_5 *= 1024;", "case 'M':\nVAR_5 *= 1024;", "case 'K':\ncase 'k':\nVAR_5 *= 1024;", "case 'b':\ncase '\\0':\n*VAR_2 = (uint64_t) VAR_5;", "break;", "default:\nerror_setg(VAR_3, QERR_INVALID_PARAMETER_VALUE, VAR_0, \"a size\");", "error_append_hint(VAR_3, \"You may use k, M, G or T suffixes for \"\n\"kilobytes, megabytes, gigabytes and terabytes.\\n\");", "return;", "}", "}" ]
[ 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17, 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27, 29 ], [ 33, 35 ], [ 39, 41 ], [ 45, 47, 49 ], [ 53, 55, 57 ], [ 59 ], [ 61, 63 ], [ 65, 67 ], [ 69 ], [ 71 ], [ 73 ] ]
648
static void gen_ove_cy(DisasContext *dc, TCGv cy) { if (dc->tb_flags & SR_OVE) { gen_helper_ove(cpu_env, cy); } }
true
qemu
9745807191a81c45970f780166f44a7f93b18653
static void gen_ove_cy(DisasContext *dc, TCGv cy) { if (dc->tb_flags & SR_OVE) { gen_helper_ove(cpu_env, cy); } }
{ "code": [ "static void gen_ove_cy(DisasContext *dc, TCGv cy)", " gen_helper_ove(cpu_env, cy);" ], "line_no": [ 1, 7 ] }
static void FUNC_0(DisasContext *VAR_0, TCGv VAR_1) { if (VAR_0->tb_flags & SR_OVE) { gen_helper_ove(cpu_env, VAR_1); } }
[ "static void FUNC_0(DisasContext *VAR_0, TCGv VAR_1)\n{", "if (VAR_0->tb_flags & SR_OVE) {", "gen_helper_ove(cpu_env, VAR_1);", "}", "}" ]
[ 1, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ] ]
649
static void limits_nesting(void) { enum { max_nesting = 1024 }; /* see qobject/json-streamer.c */ char buf[2 * (max_nesting + 1) + 1]; QObject *obj; obj = qobject_from_json(make_nest(buf, max_nesting), NULL); g_assert(obj != NULL); qobject_decref(obj); obj = qobject_from_json(make_nest(buf, max_nesting + 1), NULL); g_assert(obj == NULL); }
true
qemu
aec4b054ea36c53c8b887da99f20010133b84378
static void limits_nesting(void) { enum { max_nesting = 1024 }; char buf[2 * (max_nesting + 1) + 1]; QObject *obj; obj = qobject_from_json(make_nest(buf, max_nesting), NULL); g_assert(obj != NULL); qobject_decref(obj); obj = qobject_from_json(make_nest(buf, max_nesting + 1), NULL); g_assert(obj == NULL); }
{ "code": [ " obj = qobject_from_json(make_nest(buf, max_nesting), NULL);", " obj = qobject_from_json(make_nest(buf, max_nesting + 1), NULL);" ], "line_no": [ 13, 21 ] }
static void FUNC_0(void) { enum { max_nesting = 1024 }; char VAR_0[2 * (max_nesting + 1) + 1]; QObject *obj; obj = qobject_from_json(make_nest(VAR_0, max_nesting), NULL); g_assert(obj != NULL); qobject_decref(obj); obj = qobject_from_json(make_nest(VAR_0, max_nesting + 1), NULL); g_assert(obj == NULL); }
[ "static void FUNC_0(void)\n{", "enum { max_nesting = 1024 };", "char VAR_0[2 * (max_nesting + 1) + 1];", "QObject *obj;", "obj = qobject_from_json(make_nest(VAR_0, max_nesting), NULL);", "g_assert(obj != NULL);", "qobject_decref(obj);", "obj = qobject_from_json(make_nest(VAR_0, max_nesting + 1), NULL);", "g_assert(obj == NULL);", "}" ]
[ 0, 0, 0, 0, 1, 0, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ] ]
650
static int decode_end(AVCodecContext *avctx) { H264Context *h = avctx->priv_data; MpegEncContext *s = &h->s; free_tables(h); //FIXME cleanup init stuff perhaps MPV_common_end(s); // memset(h, 0, sizeof(H264Context)); return 0; }
true
FFmpeg
dc9f52602f6493b33d1ac0d729ffb188e6a676fa
static int decode_end(AVCodecContext *avctx) { H264Context *h = avctx->priv_data; MpegEncContext *s = &h->s; free_tables(h); MPV_common_end(s); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVCodecContext *VAR_0) { H264Context *h = VAR_0->priv_data; MpegEncContext *s = &h->s; free_tables(h); MPV_common_end(s); return 0; }
[ "static int FUNC_0(AVCodecContext *VAR_0)\n{", "H264Context *h = VAR_0->priv_data;", "MpegEncContext *s = &h->s;", "free_tables(h);", "MPV_common_end(s);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 12 ], [ 14 ], [ 22 ], [ 24 ] ]
651
static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s) { int i, j; if (!avctx->channel_layout) { av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The " "encoder will guess the layout, but it " "might be incorrect.\n"); } if (set_channel_info(s, avctx->channels, &avctx->channel_layout)) { av_log(avctx, AV_LOG_ERROR, "invalid channel layout\n"); return -1; } /* frequency */ for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) if ((ff_ac3_sample_rate_tab[j] >> i) == avctx->sample_rate) goto found; } return -1; found: s->sample_rate = avctx->sample_rate; s->bit_alloc.sr_shift = i; s->bit_alloc.sr_code = j; s->bitstream_id = 8 + s->bit_alloc.sr_shift; s->bitstream_mode = 0; /* complete main audio service */ /* bitrate & frame size */ for (i = 0; i < 19; i++) { if ((ff_ac3_bitrate_tab[i] >> s->bit_alloc.sr_shift)*1000 == avctx->bit_rate) break; } if (i == 19) return -1; s->bit_rate = avctx->bit_rate; s->frame_size_code = i << 1; return 0; }
false
FFmpeg
99ca4f73f0a2085d8b3c7636f4734825894c42dc
static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s) { int i, j; if (!avctx->channel_layout) { av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The " "encoder will guess the layout, but it " "might be incorrect.\n"); } if (set_channel_info(s, avctx->channels, &avctx->channel_layout)) { av_log(avctx, AV_LOG_ERROR, "invalid channel layout\n"); return -1; } for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) if ((ff_ac3_sample_rate_tab[j] >> i) == avctx->sample_rate) goto found; } return -1; found: s->sample_rate = avctx->sample_rate; s->bit_alloc.sr_shift = i; s->bit_alloc.sr_code = j; s->bitstream_id = 8 + s->bit_alloc.sr_shift; s->bitstream_mode = 0; for (i = 0; i < 19; i++) { if ((ff_ac3_bitrate_tab[i] >> s->bit_alloc.sr_shift)*1000 == avctx->bit_rate) break; } if (i == 19) return -1; s->bit_rate = avctx->bit_rate; s->frame_size_code = i << 1; return 0; }
{ "code": [], "line_no": [] }
static av_cold int FUNC_0(AVCodecContext *avctx, AC3EncodeContext *s) { int VAR_0, VAR_1; if (!avctx->channel_layout) { av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The " "encoder will guess the layout, but it " "might be incorrect.\n"); } if (set_channel_info(s, avctx->channels, &avctx->channel_layout)) { av_log(avctx, AV_LOG_ERROR, "invalid channel layout\n"); return -1; } for (VAR_0 = 0; VAR_0 < 3; VAR_0++) { for (VAR_1 = 0; VAR_1 < 3; VAR_1++) if ((ff_ac3_sample_rate_tab[VAR_1] >> VAR_0) == avctx->sample_rate) goto found; } return -1; found: s->sample_rate = avctx->sample_rate; s->bit_alloc.sr_shift = VAR_0; s->bit_alloc.sr_code = VAR_1; s->bitstream_id = 8 + s->bit_alloc.sr_shift; s->bitstream_mode = 0; for (VAR_0 = 0; VAR_0 < 19; VAR_0++) { if ((ff_ac3_bitrate_tab[VAR_0] >> s->bit_alloc.sr_shift)*1000 == avctx->bit_rate) break; } if (VAR_0 == 19) return -1; s->bit_rate = avctx->bit_rate; s->frame_size_code = VAR_0 << 1; return 0; }
[ "static av_cold int FUNC_0(AVCodecContext *avctx, AC3EncodeContext *s)\n{", "int VAR_0, VAR_1;", "if (!avctx->channel_layout) {", "av_log(avctx, AV_LOG_WARNING, \"No channel layout specified. The \"\n\"encoder will guess the layout, but it \"\n\"might be incorrect.\\n\");", "}", "if (set_channel_info(s, avctx->channels, &avctx->channel_layout)) {", "av_log(avctx, AV_LOG_ERROR, \"invalid channel layout\\n\");", "return -1;", "}", "for (VAR_0 = 0; VAR_0 < 3; VAR_0++) {", "for (VAR_1 = 0; VAR_1 < 3; VAR_1++)", "if ((ff_ac3_sample_rate_tab[VAR_1] >> VAR_0) == avctx->sample_rate)\ngoto found;", "}", "return -1;", "found:\ns->sample_rate = avctx->sample_rate;", "s->bit_alloc.sr_shift = VAR_0;", "s->bit_alloc.sr_code = VAR_1;", "s->bitstream_id = 8 + s->bit_alloc.sr_shift;", "s->bitstream_mode = 0;", "for (VAR_0 = 0; VAR_0 < 19; VAR_0++) {", "if ((ff_ac3_bitrate_tab[VAR_0] >> s->bit_alloc.sr_shift)*1000 == avctx->bit_rate)\nbreak;", "}", "if (VAR_0 == 19)\nreturn -1;", "s->bit_rate = avctx->bit_rate;", "s->frame_size_code = VAR_0 << 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 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11, 13, 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 31 ], [ 33 ], [ 35, 37 ], [ 39 ], [ 41 ], [ 43, 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 59 ], [ 61, 63 ], [ 65 ], [ 67, 69 ], [ 71 ], [ 73 ], [ 77 ], [ 79 ] ]
652
static NvencSurface *get_free_frame(NvencContext *ctx) { int i; for (i = 0; i < ctx->nb_surfaces; i++) { if (!ctx->surfaces[i].lockCount) { ctx->surfaces[i].lockCount = 1; return &ctx->surfaces[i]; } } return NULL; }
false
FFmpeg
8de3458a07376b0a96772e586b6dba5e93432f52
static NvencSurface *get_free_frame(NvencContext *ctx) { int i; for (i = 0; i < ctx->nb_surfaces; i++) { if (!ctx->surfaces[i].lockCount) { ctx->surfaces[i].lockCount = 1; return &ctx->surfaces[i]; } } return NULL; }
{ "code": [], "line_no": [] }
static NvencSurface *FUNC_0(NvencContext *ctx) { int VAR_0; for (VAR_0 = 0; VAR_0 < ctx->nb_surfaces; VAR_0++) { if (!ctx->surfaces[VAR_0].lockCount) { ctx->surfaces[VAR_0].lockCount = 1; return &ctx->surfaces[VAR_0]; } } return NULL; }
[ "static NvencSurface *FUNC_0(NvencContext *ctx)\n{", "int VAR_0;", "for (VAR_0 = 0; VAR_0 < ctx->nb_surfaces; VAR_0++) {", "if (!ctx->surfaces[VAR_0].lockCount) {", "ctx->surfaces[VAR_0].lockCount = 1;", "return &ctx->surfaces[VAR_0];", "}", "}", "return NULL;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ] ]
654
int ff_ccitt_unpack(AVCodecContext *avctx, const uint8_t *src, int srcsize, uint8_t *dst, int height, int stride, enum TiffCompr compr, int opts) { int j; GetBitContext gb; int *runs, *ref, *runend; int ret; int runsize= avctx->width + 2; runs = av_malloc(runsize * sizeof(runs[0])); ref = av_malloc(runsize * sizeof(ref[0])); ref[0] = avctx->width; ref[1] = 0; ref[2] = 0; init_get_bits(&gb, src, srcsize*8); for(j = 0; j < height; j++){ runend = runs + runsize; if(compr == TIFF_G4){ ret = decode_group3_2d_line(avctx, &gb, avctx->width, runs, runend, ref); if(ret < 0){ av_free(runs); av_free(ref); return -1; } }else{ int g3d1 = (compr == TIFF_G3) && !(opts & 1); if(compr!=TIFF_CCITT_RLE && find_group3_syncmarker(&gb, srcsize*8) < 0) break; if(compr==TIFF_CCITT_RLE || g3d1 || get_bits1(&gb)) ret = decode_group3_1d_line(avctx, &gb, avctx->width, runs, runend); else ret = decode_group3_2d_line(avctx, &gb, avctx->width, runs, runend, ref); if(compr==TIFF_CCITT_RLE) align_get_bits(&gb); } if(ret < 0){ put_line(dst, stride, avctx->width, ref); }else{ put_line(dst, stride, avctx->width, runs); FFSWAP(int*, runs, ref); } dst += stride; } av_free(runs); av_free(ref); return 0; }
false
FFmpeg
99a335299ff3541f89e6e3be4b9ae84257288fcc
int ff_ccitt_unpack(AVCodecContext *avctx, const uint8_t *src, int srcsize, uint8_t *dst, int height, int stride, enum TiffCompr compr, int opts) { int j; GetBitContext gb; int *runs, *ref, *runend; int ret; int runsize= avctx->width + 2; runs = av_malloc(runsize * sizeof(runs[0])); ref = av_malloc(runsize * sizeof(ref[0])); ref[0] = avctx->width; ref[1] = 0; ref[2] = 0; init_get_bits(&gb, src, srcsize*8); for(j = 0; j < height; j++){ runend = runs + runsize; if(compr == TIFF_G4){ ret = decode_group3_2d_line(avctx, &gb, avctx->width, runs, runend, ref); if(ret < 0){ av_free(runs); av_free(ref); return -1; } }else{ int g3d1 = (compr == TIFF_G3) && !(opts & 1); if(compr!=TIFF_CCITT_RLE && find_group3_syncmarker(&gb, srcsize*8) < 0) break; if(compr==TIFF_CCITT_RLE || g3d1 || get_bits1(&gb)) ret = decode_group3_1d_line(avctx, &gb, avctx->width, runs, runend); else ret = decode_group3_2d_line(avctx, &gb, avctx->width, runs, runend, ref); if(compr==TIFF_CCITT_RLE) align_get_bits(&gb); } if(ret < 0){ put_line(dst, stride, avctx->width, ref); }else{ put_line(dst, stride, avctx->width, runs); FFSWAP(int*, runs, ref); } dst += stride; } av_free(runs); av_free(ref); return 0; }
{ "code": [], "line_no": [] }
int FUNC_0(AVCodecContext *VAR_0, const uint8_t *VAR_1, int VAR_2, uint8_t *VAR_3, int VAR_4, int VAR_5, enum TiffCompr VAR_6, int VAR_7) { int VAR_8; GetBitContext gb; int *VAR_9, *VAR_10, *VAR_11; int VAR_12; int VAR_13= VAR_0->width + 2; VAR_9 = av_malloc(VAR_13 * sizeof(VAR_9[0])); VAR_10 = av_malloc(VAR_13 * sizeof(VAR_10[0])); VAR_10[0] = VAR_0->width; VAR_10[1] = 0; VAR_10[2] = 0; init_get_bits(&gb, VAR_1, VAR_2*8); for(VAR_8 = 0; VAR_8 < VAR_4; VAR_8++){ VAR_11 = VAR_9 + VAR_13; if(VAR_6 == TIFF_G4){ VAR_12 = decode_group3_2d_line(VAR_0, &gb, VAR_0->width, VAR_9, VAR_11, VAR_10); if(VAR_12 < 0){ av_free(VAR_9); av_free(VAR_10); return -1; } }else{ int VAR_14 = (VAR_6 == TIFF_G3) && !(VAR_7 & 1); if(VAR_6!=TIFF_CCITT_RLE && find_group3_syncmarker(&gb, VAR_2*8) < 0) break; if(VAR_6==TIFF_CCITT_RLE || VAR_14 || get_bits1(&gb)) VAR_12 = decode_group3_1d_line(VAR_0, &gb, VAR_0->width, VAR_9, VAR_11); else VAR_12 = decode_group3_2d_line(VAR_0, &gb, VAR_0->width, VAR_9, VAR_11, VAR_10); if(VAR_6==TIFF_CCITT_RLE) align_get_bits(&gb); } if(VAR_12 < 0){ put_line(VAR_3, VAR_5, VAR_0->width, VAR_10); }else{ put_line(VAR_3, VAR_5, VAR_0->width, VAR_9); FFSWAP(int*, VAR_9, VAR_10); } VAR_3 += VAR_5; } av_free(VAR_9); av_free(VAR_10); return 0; }
[ "int FUNC_0(AVCodecContext *VAR_0,\nconst uint8_t *VAR_1, int VAR_2,\nuint8_t *VAR_3, int VAR_4, int VAR_5,\nenum TiffCompr VAR_6, int VAR_7)\n{", "int VAR_8;", "GetBitContext gb;", "int *VAR_9, *VAR_10, *VAR_11;", "int VAR_12;", "int VAR_13= VAR_0->width + 2;", "VAR_9 = av_malloc(VAR_13 * sizeof(VAR_9[0]));", "VAR_10 = av_malloc(VAR_13 * sizeof(VAR_10[0]));", "VAR_10[0] = VAR_0->width;", "VAR_10[1] = 0;", "VAR_10[2] = 0;", "init_get_bits(&gb, VAR_1, VAR_2*8);", "for(VAR_8 = 0; VAR_8 < VAR_4; VAR_8++){", "VAR_11 = VAR_9 + VAR_13;", "if(VAR_6 == TIFF_G4){", "VAR_12 = decode_group3_2d_line(VAR_0, &gb, VAR_0->width, VAR_9, VAR_11, VAR_10);", "if(VAR_12 < 0){", "av_free(VAR_9);", "av_free(VAR_10);", "return -1;", "}", "}else{", "int VAR_14 = (VAR_6 == TIFF_G3) && !(VAR_7 & 1);", "if(VAR_6!=TIFF_CCITT_RLE && find_group3_syncmarker(&gb, VAR_2*8) < 0)\nbreak;", "if(VAR_6==TIFF_CCITT_RLE || VAR_14 || get_bits1(&gb))\nVAR_12 = decode_group3_1d_line(VAR_0, &gb, VAR_0->width, VAR_9, VAR_11);", "else\nVAR_12 = decode_group3_2d_line(VAR_0, &gb, VAR_0->width, VAR_9, VAR_11, VAR_10);", "if(VAR_6==TIFF_CCITT_RLE)\nalign_get_bits(&gb);", "}", "if(VAR_12 < 0){", "put_line(VAR_3, VAR_5, VAR_0->width, VAR_10);", "}else{", "put_line(VAR_3, VAR_5, VAR_0->width, VAR_9);", "FFSWAP(int*, VAR_9, VAR_10);", "}", "VAR_3 += VAR_5;", "}", "av_free(VAR_9);", "av_free(VAR_10);", "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 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57, 59 ], [ 61, 63 ], [ 65, 67 ], [ 69, 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ] ]
655
static int exif_decode_tag(void *logctx, GetByteContext *gbytes, int le, int depth, AVDictionary **metadata) { int ret, cur_pos; unsigned id, count; enum TiffTypes type; if (depth > 2) { return 0; } ff_tread_tag(gbytes, le, &id, &type, &count, &cur_pos); if (!bytestream2_tell(gbytes)) { bytestream2_seek(gbytes, cur_pos, SEEK_SET); return 0; } // read count values and add it metadata // store metadata or proceed with next IFD ret = ff_tis_ifd(id); if (ret) { ret = avpriv_exif_decode_ifd(logctx, gbytes, le, depth + 1, metadata); } else { const char *name = exif_get_tag_name(id); char *use_name = (char*) name; if (!use_name) { use_name = av_malloc(7); if (!use_name) { return AVERROR(ENOMEM); } snprintf(use_name, 7, "0x%04X", id); } ret = exif_add_metadata(logctx, count, type, use_name, NULL, gbytes, le, metadata); if (!name) { av_freep(&use_name); } } bytestream2_seek(gbytes, cur_pos, SEEK_SET); return ret; }
false
FFmpeg
ae100046ca32b0b83031a60d0c3cdfc5ceb9f874
static int exif_decode_tag(void *logctx, GetByteContext *gbytes, int le, int depth, AVDictionary **metadata) { int ret, cur_pos; unsigned id, count; enum TiffTypes type; if (depth > 2) { return 0; } ff_tread_tag(gbytes, le, &id, &type, &count, &cur_pos); if (!bytestream2_tell(gbytes)) { bytestream2_seek(gbytes, cur_pos, SEEK_SET); return 0; } ret = ff_tis_ifd(id); if (ret) { ret = avpriv_exif_decode_ifd(logctx, gbytes, le, depth + 1, metadata); } else { const char *name = exif_get_tag_name(id); char *use_name = (char*) name; if (!use_name) { use_name = av_malloc(7); if (!use_name) { return AVERROR(ENOMEM); } snprintf(use_name, 7, "0x%04X", id); } ret = exif_add_metadata(logctx, count, type, use_name, NULL, gbytes, le, metadata); if (!name) { av_freep(&use_name); } } bytestream2_seek(gbytes, cur_pos, SEEK_SET); return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(void *VAR_0, GetByteContext *VAR_1, int VAR_2, int VAR_3, AVDictionary **VAR_4) { int VAR_5, VAR_6; unsigned VAR_7, VAR_8; enum TiffTypes VAR_9; if (VAR_3 > 2) { return 0; } ff_tread_tag(VAR_1, VAR_2, &VAR_7, &VAR_9, &VAR_8, &VAR_6); if (!bytestream2_tell(VAR_1)) { bytestream2_seek(VAR_1, VAR_6, SEEK_SET); return 0; } VAR_5 = ff_tis_ifd(VAR_7); if (VAR_5) { VAR_5 = avpriv_exif_decode_ifd(VAR_0, VAR_1, VAR_2, VAR_3 + 1, VAR_4); } else { const char *VAR_10 = exif_get_tag_name(VAR_7); char *VAR_11 = (char*) VAR_10; if (!VAR_11) { VAR_11 = av_malloc(7); if (!VAR_11) { return AVERROR(ENOMEM); } snprintf(VAR_11, 7, "0x%04X", VAR_7); } VAR_5 = exif_add_metadata(VAR_0, VAR_8, VAR_9, VAR_11, NULL, VAR_1, VAR_2, VAR_4); if (!VAR_10) { av_freep(&VAR_11); } } bytestream2_seek(VAR_1, VAR_6, SEEK_SET); return VAR_5; }
[ "static int FUNC_0(void *VAR_0, GetByteContext *VAR_1, int VAR_2,\nint VAR_3, AVDictionary **VAR_4)\n{", "int VAR_5, VAR_6;", "unsigned VAR_7, VAR_8;", "enum TiffTypes VAR_9;", "if (VAR_3 > 2) {", "return 0;", "}", "ff_tread_tag(VAR_1, VAR_2, &VAR_7, &VAR_9, &VAR_8, &VAR_6);", "if (!bytestream2_tell(VAR_1)) {", "bytestream2_seek(VAR_1, VAR_6, SEEK_SET);", "return 0;", "}", "VAR_5 = ff_tis_ifd(VAR_7);", "if (VAR_5) {", "VAR_5 = avpriv_exif_decode_ifd(VAR_0, VAR_1, VAR_2, VAR_3 + 1, VAR_4);", "} else {", "const char *VAR_10 = exif_get_tag_name(VAR_7);", "char *VAR_11 = (char*) VAR_10;", "if (!VAR_11) {", "VAR_11 = av_malloc(7);", "if (!VAR_11) {", "return AVERROR(ENOMEM);", "}", "snprintf(VAR_11, 7, \"0x%04X\", VAR_7);", "}", "VAR_5 = exif_add_metadata(VAR_0, VAR_8, VAR_9, VAR_11, NULL,\nVAR_1, VAR_2, VAR_4);", "if (!VAR_10) {", "av_freep(&VAR_11);", "}", "}", "bytestream2_seek(VAR_1, VAR_6, SEEK_SET);", "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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71, 73 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 87 ], [ 91 ], [ 93 ] ]
656
static int pci_bridge_dev_initfn(PCIDevice *dev) { PCIBridge *br = DO_UPCAST(PCIBridge, dev, dev); PCIBridgeDev *bridge_dev = DO_UPCAST(PCIBridgeDev, bridge, br); int err; pci_bridge_map_irq(br, NULL, pci_bridge_dev_map_irq_fn); err = pci_bridge_initfn(dev); if (err) { goto bridge_error; } memory_region_init(&bridge_dev->bar, "shpc-bar", shpc_bar_size(dev)); err = shpc_init(dev, &br->sec_bus, &bridge_dev->bar, 0); if (err) { goto shpc_error; } err = slotid_cap_init(dev, 0, bridge_dev->chassis_nr, 0); if (err) { goto slotid_error; } if ((bridge_dev->flags & (1 << PCI_BRIDGE_DEV_F_MSI_REQ)) && msi_supported) { err = msi_init(dev, 0, 1, true, true); if (err < 0) { goto msi_error; } } /* TODO: spec recommends using 64 bit prefetcheable BAR. * Check whether that works well. */ pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64, &bridge_dev->bar); dev->config[PCI_INTERRUPT_PIN] = 0x1; return 0; msi_error: slotid_cap_cleanup(dev); slotid_error: shpc_cleanup(dev, &bridge_dev->bar); shpc_error: memory_region_destroy(&bridge_dev->bar); bridge_error: return err; }
true
qemu
80aa796bf38b7ef21daa42673b4711510c450d8a
static int pci_bridge_dev_initfn(PCIDevice *dev) { PCIBridge *br = DO_UPCAST(PCIBridge, dev, dev); PCIBridgeDev *bridge_dev = DO_UPCAST(PCIBridgeDev, bridge, br); int err; pci_bridge_map_irq(br, NULL, pci_bridge_dev_map_irq_fn); err = pci_bridge_initfn(dev); if (err) { goto bridge_error; } memory_region_init(&bridge_dev->bar, "shpc-bar", shpc_bar_size(dev)); err = shpc_init(dev, &br->sec_bus, &bridge_dev->bar, 0); if (err) { goto shpc_error; } err = slotid_cap_init(dev, 0, bridge_dev->chassis_nr, 0); if (err) { goto slotid_error; } if ((bridge_dev->flags & (1 << PCI_BRIDGE_DEV_F_MSI_REQ)) && msi_supported) { err = msi_init(dev, 0, 1, true, true); if (err < 0) { goto msi_error; } } pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64, &bridge_dev->bar); dev->config[PCI_INTERRUPT_PIN] = 0x1; return 0; msi_error: slotid_cap_cleanup(dev); slotid_error: shpc_cleanup(dev, &bridge_dev->bar); shpc_error: memory_region_destroy(&bridge_dev->bar); bridge_error: return err; }
{ "code": [ " int err;" ], "line_no": [ 9 ] }
static int FUNC_0(PCIDevice *VAR_0) { PCIBridge *br = DO_UPCAST(PCIBridge, VAR_0, VAR_0); PCIBridgeDev *bridge_dev = DO_UPCAST(PCIBridgeDev, bridge, br); int VAR_1; pci_bridge_map_irq(br, NULL, pci_bridge_dev_map_irq_fn); VAR_1 = pci_bridge_initfn(VAR_0); if (VAR_1) { goto bridge_error; } memory_region_init(&bridge_dev->bar, "shpc-bar", shpc_bar_size(VAR_0)); VAR_1 = shpc_init(VAR_0, &br->sec_bus, &bridge_dev->bar, 0); if (VAR_1) { goto shpc_error; } VAR_1 = slotid_cap_init(VAR_0, 0, bridge_dev->chassis_nr, 0); if (VAR_1) { goto slotid_error; } if ((bridge_dev->flags & (1 << PCI_BRIDGE_DEV_F_MSI_REQ)) && msi_supported) { VAR_1 = msi_init(VAR_0, 0, 1, true, true); if (VAR_1 < 0) { goto msi_error; } } pci_register_bar(VAR_0, 0, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64, &bridge_dev->bar); VAR_0->config[PCI_INTERRUPT_PIN] = 0x1; return 0; msi_error: slotid_cap_cleanup(VAR_0); slotid_error: shpc_cleanup(VAR_0, &bridge_dev->bar); shpc_error: memory_region_destroy(&bridge_dev->bar); bridge_error: return VAR_1; }
[ "static int FUNC_0(PCIDevice *VAR_0)\n{", "PCIBridge *br = DO_UPCAST(PCIBridge, VAR_0, VAR_0);", "PCIBridgeDev *bridge_dev = DO_UPCAST(PCIBridgeDev, bridge, br);", "int VAR_1;", "pci_bridge_map_irq(br, NULL, pci_bridge_dev_map_irq_fn);", "VAR_1 = pci_bridge_initfn(VAR_0);", "if (VAR_1) {", "goto bridge_error;", "}", "memory_region_init(&bridge_dev->bar, \"shpc-bar\", shpc_bar_size(VAR_0));", "VAR_1 = shpc_init(VAR_0, &br->sec_bus, &bridge_dev->bar, 0);", "if (VAR_1) {", "goto shpc_error;", "}", "VAR_1 = slotid_cap_init(VAR_0, 0, bridge_dev->chassis_nr, 0);", "if (VAR_1) {", "goto slotid_error;", "}", "if ((bridge_dev->flags & (1 << PCI_BRIDGE_DEV_F_MSI_REQ)) &&\nmsi_supported) {", "VAR_1 = msi_init(VAR_0, 0, 1, true, true);", "if (VAR_1 < 0) {", "goto msi_error;", "}", "}", "pci_register_bar(VAR_0, 0, PCI_BASE_ADDRESS_SPACE_MEMORY |\nPCI_BASE_ADDRESS_MEM_TYPE_64, &bridge_dev->bar);", "VAR_0->config[PCI_INTERRUPT_PIN] = 0x1;", "return 0;", "msi_error:\nslotid_cap_cleanup(VAR_0);", "slotid_error:\nshpc_cleanup(VAR_0, &bridge_dev->bar);", "shpc_error:\nmemory_region_destroy(&bridge_dev->bar);", "bridge_error:\nreturn VAR_1;", "}" ]
[ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39, 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 57, 59 ], [ 61 ], [ 63 ], [ 65, 67 ], [ 69, 71 ], [ 73, 75 ], [ 77, 79 ], [ 81 ] ]
658
static const AVClass *urlcontext_child_class_next(const AVClass *prev) { URLProtocol *p = NULL; /* find the protocol that corresponds to prev */ while (prev && (p = ffurl_protocol_next(p))) if (p->priv_data_class == prev) break; /* find next protocol with priv options */ while (p = ffurl_protocol_next(p)) if (p->priv_data_class) return p->priv_data_class; return NULL; }
false
FFmpeg
2758cdedfb7ac61f8b5e4861f99218b6fd43491d
static const AVClass *urlcontext_child_class_next(const AVClass *prev) { URLProtocol *p = NULL; while (prev && (p = ffurl_protocol_next(p))) if (p->priv_data_class == prev) break; while (p = ffurl_protocol_next(p)) if (p->priv_data_class) return p->priv_data_class; return NULL; }
{ "code": [], "line_no": [] }
static const AVClass *FUNC_0(const AVClass *prev) { URLProtocol *p = NULL; while (prev && (p = ffurl_protocol_next(p))) if (p->priv_data_class == prev) break; while (p = ffurl_protocol_next(p)) if (p->priv_data_class) return p->priv_data_class; return NULL; }
[ "static const AVClass *FUNC_0(const AVClass *prev)\n{", "URLProtocol *p = NULL;", "while (prev && (p = ffurl_protocol_next(p)))\nif (p->priv_data_class == prev)\nbreak;", "while (p = ffurl_protocol_next(p))\nif (p->priv_data_class)\nreturn p->priv_data_class;", "return NULL;", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 11, 13, 15 ], [ 21, 23, 25 ], [ 27 ], [ 29 ] ]
659
static void do_change_vnc(const char *target) { if (strcmp(target, "passwd") == 0 || strcmp(target, "password") == 0) { char password[9]; monitor_readline("Password: ", 1, password, sizeof(password)-1); password[sizeof(password)-1] = '\0'; if (vnc_display_password(NULL, password) < 0) term_printf("could not set VNC server password\n"); } else { if (vnc_display_open(NULL, target) < 0) term_printf("could not start VNC server on %s\n", target); } }
true
qemu
2a7e8dda090af586f3d0b3d157054a9e18776a52
static void do_change_vnc(const char *target) { if (strcmp(target, "passwd") == 0 || strcmp(target, "password") == 0) { char password[9]; monitor_readline("Password: ", 1, password, sizeof(password)-1); password[sizeof(password)-1] = '\0'; if (vnc_display_password(NULL, password) < 0) term_printf("could not set VNC server password\n"); } else { if (vnc_display_open(NULL, target) < 0) term_printf("could not start VNC server on %s\n", target); } }
{ "code": [ "\tmonitor_readline(\"Password: \", 1, password, sizeof(password)-1);", "\tpassword[sizeof(password)-1] = '\\0';" ], "line_no": [ 11, 13 ] }
static void FUNC_0(const char *VAR_0) { if (strcmp(VAR_0, "passwd") == 0 || strcmp(VAR_0, "VAR_1") == 0) { char VAR_1[9]; monitor_readline("Password: ", 1, VAR_1, sizeof(VAR_1)-1); VAR_1[sizeof(VAR_1)-1] = '\0'; if (vnc_display_password(NULL, VAR_1) < 0) term_printf("could not set VNC server VAR_1\n"); } else { if (vnc_display_open(NULL, VAR_0) < 0) term_printf("could not start VNC server on %s\n", VAR_0); } }
[ "static void FUNC_0(const char *VAR_0)\n{", "if (strcmp(VAR_0, \"passwd\") == 0 ||\nstrcmp(VAR_0, \"VAR_1\") == 0) {", "char VAR_1[9];", "monitor_readline(\"Password: \", 1, VAR_1, sizeof(VAR_1)-1);", "VAR_1[sizeof(VAR_1)-1] = '\\0';", "if (vnc_display_password(NULL, VAR_1) < 0)\nterm_printf(\"could not set VNC server VAR_1\\n\");", "} else {", "if (vnc_display_open(NULL, VAR_0) < 0)\nterm_printf(\"could not start VNC server on %s\\n\", VAR_0);", "}", "}" ]
[ 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15, 17 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 27 ] ]
660
int ff_get_cpu_flags_x86(void) { int rval = 0; int eax, ebx, ecx, edx; int max_std_level, max_ext_level, std_caps=0, ext_caps=0; int family=0, model=0; union { int i[3]; char c[12]; } vendor; #if ARCH_X86_32 x86_reg a, c; __asm__ volatile ( /* See if CPUID instruction is supported ... */ /* ... Get copies of EFLAGS into eax and ecx */ "pushfl\n\t" "pop %0\n\t" "mov %0, %1\n\t" /* ... Toggle the ID bit in one copy and store */ /* to the EFLAGS reg */ "xor $0x200000, %0\n\t" "push %0\n\t" "popfl\n\t" /* ... Get the (hopefully modified) EFLAGS */ "pushfl\n\t" "pop %0\n\t" : "=a" (a), "=c" (c) : : "cc" ); if (a == c) return 0; /* CPUID not supported */ #endif cpuid(0, max_std_level, vendor.i[0], vendor.i[2], vendor.i[1]); if(max_std_level >= 1){ cpuid(1, eax, ebx, ecx, std_caps); family = ((eax>>8)&0xf) + ((eax>>20)&0xff); model = ((eax>>4)&0xf) + ((eax>>12)&0xf0); if (std_caps & (1<<23)) rval |= AV_CPU_FLAG_MMX; if (std_caps & (1<<25)) rval |= AV_CPU_FLAG_MMX2 #if HAVE_SSE | AV_CPU_FLAG_SSE; if (std_caps & (1<<26)) rval |= AV_CPU_FLAG_SSE2; if (ecx & 1) rval |= AV_CPU_FLAG_SSE3; if (ecx & 0x00000200 ) rval |= AV_CPU_FLAG_SSSE3; if (ecx & 0x00080000 ) rval |= AV_CPU_FLAG_SSE4; if (ecx & 0x00100000 ) rval |= AV_CPU_FLAG_SSE42; #if HAVE_AVX /* Check OXSAVE and AVX bits */ if ((ecx & 0x18000000) == 0x18000000) { /* Check for OS support */ xgetbv(0, eax, edx); if ((eax & 0x6) == 0x6) rval |= AV_CPU_FLAG_AVX; } #endif #endif ; } cpuid(0x80000000, max_ext_level, ebx, ecx, edx); if(max_ext_level >= 0x80000001){ cpuid(0x80000001, eax, ebx, ecx, ext_caps); if (ext_caps & (1<<31)) rval |= AV_CPU_FLAG_3DNOW; if (ext_caps & (1<<30)) rval |= AV_CPU_FLAG_3DNOWEXT; if (ext_caps & (1<<23)) rval |= AV_CPU_FLAG_MMX; if (ext_caps & (1<<22)) rval |= AV_CPU_FLAG_MMX2; /* Allow for selectively disabling SSE2 functions on AMD processors with SSE2 support but not SSE4a. This includes Athlon64, some Opteron, and some Sempron processors. MMX, SSE, or 3DNow! are faster than SSE2 often enough to utilize this special-case flag. AV_CPU_FLAG_SSE2 and AV_CPU_FLAG_SSE2SLOW are both set in this case so that SSE2 is used unless explicitly disabled by checking AV_CPU_FLAG_SSE2SLOW. */ if (!strncmp(vendor.c, "AuthenticAMD", 12) && rval & AV_CPU_FLAG_SSE2 && !(ecx & 0x00000040)) { rval |= AV_CPU_FLAG_SSE2SLOW; } } if (!strncmp(vendor.c, "GenuineIntel", 12)) { if (family == 6 && (model == 9 || model == 13 || model == 14)) { /* 6/9 (pentium-m "banias"), 6/13 (pentium-m "dothan"), and 6/14 (core1 "yonah") * theoretically support sse2, but it's usually slower than mmx, * so let's just pretend they don't. AV_CPU_FLAG_SSE2 is disabled and * AV_CPU_FLAG_SSE2SLOW is enabled so that SSE2 is not used unless * explicitly enabled by checking AV_CPU_FLAG_SSE2SLOW. The same * situation applies for AV_CPU_FLAG_SSE3 and AV_CPU_FLAG_SSE3SLOW. */ if (rval & AV_CPU_FLAG_SSE2) rval ^= AV_CPU_FLAG_SSE2SLOW|AV_CPU_FLAG_SSE2; if (rval & AV_CPU_FLAG_SSE3) rval ^= AV_CPU_FLAG_SSE3SLOW|AV_CPU_FLAG_SSE3; } /* The Atom processor has SSSE3 support, which is useful in many cases, * but sometimes the SSSE3 version is slower than the SSE2 equivalent * on the Atom, but is generally faster on other processors supporting * SSSE3. This flag allows for selectively disabling certain SSSE3 * functions on the Atom. */ if (family == 6 && model == 28) rval |= AV_CPU_FLAG_ATOM; } return rval; }
true
FFmpeg
5938e02185430ca711106aaec9b5622dbf588af3
int ff_get_cpu_flags_x86(void) { int rval = 0; int eax, ebx, ecx, edx; int max_std_level, max_ext_level, std_caps=0, ext_caps=0; int family=0, model=0; union { int i[3]; char c[12]; } vendor; #if ARCH_X86_32 x86_reg a, c; __asm__ volatile ( "pushfl\n\t" "pop %0\n\t" "mov %0, %1\n\t" "xor $0x200000, %0\n\t" "push %0\n\t" "popfl\n\t" "pushfl\n\t" "pop %0\n\t" : "=a" (a), "=c" (c) : : "cc" ); if (a == c) return 0; #endif cpuid(0, max_std_level, vendor.i[0], vendor.i[2], vendor.i[1]); if(max_std_level >= 1){ cpuid(1, eax, ebx, ecx, std_caps); family = ((eax>>8)&0xf) + ((eax>>20)&0xff); model = ((eax>>4)&0xf) + ((eax>>12)&0xf0); if (std_caps & (1<<23)) rval |= AV_CPU_FLAG_MMX; if (std_caps & (1<<25)) rval |= AV_CPU_FLAG_MMX2 #if HAVE_SSE | AV_CPU_FLAG_SSE; if (std_caps & (1<<26)) rval |= AV_CPU_FLAG_SSE2; if (ecx & 1) rval |= AV_CPU_FLAG_SSE3; if (ecx & 0x00000200 ) rval |= AV_CPU_FLAG_SSSE3; if (ecx & 0x00080000 ) rval |= AV_CPU_FLAG_SSE4; if (ecx & 0x00100000 ) rval |= AV_CPU_FLAG_SSE42; #if HAVE_AVX if ((ecx & 0x18000000) == 0x18000000) { xgetbv(0, eax, edx); if ((eax & 0x6) == 0x6) rval |= AV_CPU_FLAG_AVX; } #endif #endif ; } cpuid(0x80000000, max_ext_level, ebx, ecx, edx); if(max_ext_level >= 0x80000001){ cpuid(0x80000001, eax, ebx, ecx, ext_caps); if (ext_caps & (1<<31)) rval |= AV_CPU_FLAG_3DNOW; if (ext_caps & (1<<30)) rval |= AV_CPU_FLAG_3DNOWEXT; if (ext_caps & (1<<23)) rval |= AV_CPU_FLAG_MMX; if (ext_caps & (1<<22)) rval |= AV_CPU_FLAG_MMX2; if (!strncmp(vendor.c, "AuthenticAMD", 12) && rval & AV_CPU_FLAG_SSE2 && !(ecx & 0x00000040)) { rval |= AV_CPU_FLAG_SSE2SLOW; } } if (!strncmp(vendor.c, "GenuineIntel", 12)) { if (family == 6 && (model == 9 || model == 13 || model == 14)) { if (rval & AV_CPU_FLAG_SSE2) rval ^= AV_CPU_FLAG_SSE2SLOW|AV_CPU_FLAG_SSE2; if (rval & AV_CPU_FLAG_SSE3) rval ^= AV_CPU_FLAG_SSE3SLOW|AV_CPU_FLAG_SSE3; } if (family == 6 && model == 28) rval |= AV_CPU_FLAG_ATOM; } return rval; }
{ "code": [ " if (ext_caps & (1<<31))" ], "line_no": [ 149 ] }
int FUNC_0(void) { int VAR_0 = 0; int VAR_1, VAR_2, VAR_3, VAR_4; int VAR_5, VAR_6, VAR_7=0, VAR_8=0; int VAR_9=0, VAR_10=0; union { int i[3]; char c[12]; } VAR_11; #if ARCH_X86_32 x86_reg a, c; __asm__ volatile ( "pushfl\n\t" "pop %0\n\t" "mov %0, %1\n\t" "xor $0x200000, %0\n\t" "push %0\n\t" "popfl\n\t" "pushfl\n\t" "pop %0\n\t" : "=a" (a), "=c" (c) : : "cc" ); if (a == c) return 0; #endif cpuid(0, VAR_5, VAR_11.i[0], VAR_11.i[2], VAR_11.i[1]); if(VAR_5 >= 1){ cpuid(1, VAR_1, VAR_2, VAR_3, VAR_7); VAR_9 = ((VAR_1>>8)&0xf) + ((VAR_1>>20)&0xff); VAR_10 = ((VAR_1>>4)&0xf) + ((VAR_1>>12)&0xf0); if (VAR_7 & (1<<23)) VAR_0 |= AV_CPU_FLAG_MMX; if (VAR_7 & (1<<25)) VAR_0 |= AV_CPU_FLAG_MMX2 #if HAVE_SSE | AV_CPU_FLAG_SSE; if (VAR_7 & (1<<26)) VAR_0 |= AV_CPU_FLAG_SSE2; if (VAR_3 & 1) VAR_0 |= AV_CPU_FLAG_SSE3; if (VAR_3 & 0x00000200 ) VAR_0 |= AV_CPU_FLAG_SSSE3; if (VAR_3 & 0x00080000 ) VAR_0 |= AV_CPU_FLAG_SSE4; if (VAR_3 & 0x00100000 ) VAR_0 |= AV_CPU_FLAG_SSE42; #if HAVE_AVX if ((VAR_3 & 0x18000000) == 0x18000000) { xgetbv(0, VAR_1, VAR_4); if ((VAR_1 & 0x6) == 0x6) VAR_0 |= AV_CPU_FLAG_AVX; } #endif #endif ; } cpuid(0x80000000, VAR_6, VAR_2, VAR_3, VAR_4); if(VAR_6 >= 0x80000001){ cpuid(0x80000001, VAR_1, VAR_2, VAR_3, VAR_8); if (VAR_8 & (1<<31)) VAR_0 |= AV_CPU_FLAG_3DNOW; if (VAR_8 & (1<<30)) VAR_0 |= AV_CPU_FLAG_3DNOWEXT; if (VAR_8 & (1<<23)) VAR_0 |= AV_CPU_FLAG_MMX; if (VAR_8 & (1<<22)) VAR_0 |= AV_CPU_FLAG_MMX2; if (!strncmp(VAR_11.c, "AuthenticAMD", 12) && VAR_0 & AV_CPU_FLAG_SSE2 && !(VAR_3 & 0x00000040)) { VAR_0 |= AV_CPU_FLAG_SSE2SLOW; } } if (!strncmp(VAR_11.c, "GenuineIntel", 12)) { if (VAR_9 == 6 && (VAR_10 == 9 || VAR_10 == 13 || VAR_10 == 14)) { if (VAR_0 & AV_CPU_FLAG_SSE2) VAR_0 ^= AV_CPU_FLAG_SSE2SLOW|AV_CPU_FLAG_SSE2; if (VAR_0 & AV_CPU_FLAG_SSE3) VAR_0 ^= AV_CPU_FLAG_SSE3SLOW|AV_CPU_FLAG_SSE3; } if (VAR_9 == 6 && VAR_10 == 28) VAR_0 |= AV_CPU_FLAG_ATOM; } return VAR_0; }
[ "int FUNC_0(void)\n{", "int VAR_0 = 0;", "int VAR_1, VAR_2, VAR_3, VAR_4;", "int VAR_5, VAR_6, VAR_7=0, VAR_8=0;", "int VAR_9=0, VAR_10=0;", "union { int i[3]; char c[12]; } VAR_11;", "#if ARCH_X86_32\nx86_reg a, c;", "__asm__ volatile (\n\"pushfl\\n\\t\"\n\"pop %0\\n\\t\"\n\"mov %0, %1\\n\\t\"\n\"xor $0x200000, %0\\n\\t\"\n\"push %0\\n\\t\"\n\"popfl\\n\\t\"\n\"pushfl\\n\\t\"\n\"pop %0\\n\\t\"\n: \"=a\" (a), \"=c\" (c)\n:\n: \"cc\"\n);", "if (a == c)\nreturn 0;", "#endif\ncpuid(0, VAR_5, VAR_11.i[0], VAR_11.i[2], VAR_11.i[1]);", "if(VAR_5 >= 1){", "cpuid(1, VAR_1, VAR_2, VAR_3, VAR_7);", "VAR_9 = ((VAR_1>>8)&0xf) + ((VAR_1>>20)&0xff);", "VAR_10 = ((VAR_1>>4)&0xf) + ((VAR_1>>12)&0xf0);", "if (VAR_7 & (1<<23))\nVAR_0 |= AV_CPU_FLAG_MMX;", "if (VAR_7 & (1<<25))\nVAR_0 |= AV_CPU_FLAG_MMX2\n#if HAVE_SSE\n| AV_CPU_FLAG_SSE;", "if (VAR_7 & (1<<26))\nVAR_0 |= AV_CPU_FLAG_SSE2;", "if (VAR_3 & 1)\nVAR_0 |= AV_CPU_FLAG_SSE3;", "if (VAR_3 & 0x00000200 )\nVAR_0 |= AV_CPU_FLAG_SSSE3;", "if (VAR_3 & 0x00080000 )\nVAR_0 |= AV_CPU_FLAG_SSE4;", "if (VAR_3 & 0x00100000 )\nVAR_0 |= AV_CPU_FLAG_SSE42;", "#if HAVE_AVX\nif ((VAR_3 & 0x18000000) == 0x18000000) {", "xgetbv(0, VAR_1, VAR_4);", "if ((VAR_1 & 0x6) == 0x6)\nVAR_0 |= AV_CPU_FLAG_AVX;", "}", "#endif\n#endif\n;", "}", "cpuid(0x80000000, VAR_6, VAR_2, VAR_3, VAR_4);", "if(VAR_6 >= 0x80000001){", "cpuid(0x80000001, VAR_1, VAR_2, VAR_3, VAR_8);", "if (VAR_8 & (1<<31))\nVAR_0 |= AV_CPU_FLAG_3DNOW;", "if (VAR_8 & (1<<30))\nVAR_0 |= AV_CPU_FLAG_3DNOWEXT;", "if (VAR_8 & (1<<23))\nVAR_0 |= AV_CPU_FLAG_MMX;", "if (VAR_8 & (1<<22))\nVAR_0 |= AV_CPU_FLAG_MMX2;", "if (!strncmp(VAR_11.c, \"AuthenticAMD\", 12) &&\nVAR_0 & AV_CPU_FLAG_SSE2 && !(VAR_3 & 0x00000040)) {", "VAR_0 |= AV_CPU_FLAG_SSE2SLOW;", "}", "}", "if (!strncmp(VAR_11.c, \"GenuineIntel\", 12)) {", "if (VAR_9 == 6 && (VAR_10 == 9 || VAR_10 == 13 || VAR_10 == 14)) {", "if (VAR_0 & AV_CPU_FLAG_SSE2) VAR_0 ^= AV_CPU_FLAG_SSE2SLOW|AV_CPU_FLAG_SSE2;", "if (VAR_0 & AV_CPU_FLAG_SSE3) VAR_0 ^= AV_CPU_FLAG_SSE3SLOW|AV_CPU_FLAG_SSE3;", "}", "if (VAR_9 == 6 && VAR_10 == 28)\nVAR_0 |= AV_CPU_FLAG_ATOM;", "}", "return VAR_0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 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, 27, 29, 31, 39, 41, 43, 49, 51, 53, 55, 57, 59 ], [ 63, 65 ], [ 67, 71 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83, 85 ], [ 87, 89, 91, 93 ], [ 95, 97 ], [ 99, 101 ], [ 103, 105 ], [ 107, 109 ], [ 111, 113 ], [ 115, 119 ], [ 123 ], [ 125, 127 ], [ 129 ], [ 131, 133, 135 ], [ 137 ], [ 141 ], [ 145 ], [ 147 ], [ 149, 151 ], [ 153, 155 ], [ 157, 159 ], [ 161, 163 ], [ 181, 183 ], [ 185 ], [ 187 ], [ 189 ], [ 193 ], [ 195 ], [ 209 ], [ 211 ], [ 213 ], [ 225, 227 ], [ 229 ], [ 233 ], [ 235 ] ]
661
static inline void cvtyuvtoRGB (SwsContext *c, vector signed short Y, vector signed short U, vector signed short V, vector signed short *R, vector signed short *G, vector signed short *B) { vector signed short vx,ux,uvx; Y = vec_mradds (Y, c->CY, c->OY); U = vec_sub (U,(vector signed short) vec_splat((vector signed short)AVV(128),0)); V = vec_sub (V,(vector signed short) vec_splat((vector signed short)AVV(128),0)); // ux = (CBU*(u<<c->CSHIFT)+0x4000)>>15; ux = vec_sl (U, c->CSHIFT); *B = vec_mradds (ux, c->CBU, Y); // vx = (CRV*(v<<c->CSHIFT)+0x4000)>>15; vx = vec_sl (V, c->CSHIFT); *R = vec_mradds (vx, c->CRV, Y); // uvx = ((CGU*u) + (CGV*v))>>15; uvx = vec_mradds (U, c->CGU, Y); *G = vec_mradds (V, c->CGV, uvx); }
true
FFmpeg
428098165de4c3edfe42c1b7f00627d287015863
static inline void cvtyuvtoRGB (SwsContext *c, vector signed short Y, vector signed short U, vector signed short V, vector signed short *R, vector signed short *G, vector signed short *B) { vector signed short vx,ux,uvx; Y = vec_mradds (Y, c->CY, c->OY); U = vec_sub (U,(vector signed short) vec_splat((vector signed short)AVV(128),0)); V = vec_sub (V,(vector signed short) vec_splat((vector signed short)AVV(128),0)); ux = vec_sl (U, c->CSHIFT); *B = vec_mradds (ux, c->CBU, Y); vx = vec_sl (V, c->CSHIFT); *R = vec_mradds (vx, c->CRV, Y); uvx = vec_mradds (U, c->CGU, Y); *G = vec_mradds (V, c->CGV, uvx); }
{ "code": [ "\t\t\t vector signed short Y, vector signed short U, vector signed short V,", "\t\t\t vector signed short *R, vector signed short *G, vector signed short *B)", " vector signed short vx,ux,uvx;", " Y = vec_mradds (Y, c->CY, c->OY);", " U = vec_sub (U,(vector signed short)", " \t\t\tvec_splat((vector signed short)AVV(128),0));", " V = vec_sub (V,(vector signed short)", " \t\t\tvec_splat((vector signed short)AVV(128),0));", " ux = vec_sl (U, c->CSHIFT);", " *B = vec_mradds (ux, c->CBU, Y);", " vx = vec_sl (V, c->CSHIFT);", " *R = vec_mradds (vx, c->CRV, Y);", " uvx = vec_mradds (U, c->CGU, Y);", " *G = vec_mradds (V, c->CGV, uvx);" ], "line_no": [ 3, 5, 9, 13, 15, 17, 19, 17, 27, 29, 35, 37, 43, 45 ] }
static inline void FUNC_0 (SwsContext *VAR_0, vector signed short VAR_1, vector signed short VAR_2, vector signed short VAR_3, vector signed short *VAR_4, vector signed short *VAR_5, vector signed short *VAR_6) { vector signed short vx,ux,uvx; VAR_1 = vec_mradds (VAR_1, VAR_0->CY, VAR_0->OY); VAR_2 = vec_sub (VAR_2,(vector signed short) vec_splat((vector signed short)AVV(128),0)); VAR_3 = vec_sub (VAR_3,(vector signed short) vec_splat((vector signed short)AVV(128),0)); ux = vec_sl (VAR_2, VAR_0->CSHIFT); *VAR_6 = vec_mradds (ux, VAR_0->CBU, VAR_1); vx = vec_sl (VAR_3, VAR_0->CSHIFT); *VAR_4 = vec_mradds (vx, VAR_0->CRV, VAR_1); uvx = vec_mradds (VAR_2, VAR_0->CGU, VAR_1); *VAR_5 = vec_mradds (VAR_3, VAR_0->CGV, uvx); }
[ "static inline void FUNC_0 (SwsContext *VAR_0,\nvector signed short VAR_1, vector signed short VAR_2, vector signed short VAR_3,\nvector signed short *VAR_4, vector signed short *VAR_5, vector signed short *VAR_6)\n{", "vector signed short vx,ux,uvx;", "VAR_1 = vec_mradds (VAR_1, VAR_0->CY, VAR_0->OY);", "VAR_2 = vec_sub (VAR_2,(vector signed short)\nvec_splat((vector signed short)AVV(128),0));", "VAR_3 = vec_sub (VAR_3,(vector signed short)\nvec_splat((vector signed short)AVV(128),0));", "ux = vec_sl (VAR_2, VAR_0->CSHIFT);", "*VAR_6 = vec_mradds (ux, VAR_0->CBU, VAR_1);", "vx = vec_sl (VAR_3, VAR_0->CSHIFT);", "*VAR_4 = vec_mradds (vx, VAR_0->CRV, VAR_1);", "uvx = vec_mradds (VAR_2, VAR_0->CGU, VAR_1);", "*VAR_5 = vec_mradds (VAR_3, VAR_0->CGV, uvx);", "}" ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 13 ], [ 15, 17 ], [ 19, 21 ], [ 27 ], [ 29 ], [ 35 ], [ 37 ], [ 43 ], [ 45 ], [ 47 ] ]
662
void usb_generic_async_ctrl_complete(USBDevice *s, USBPacket *p) { if (p->len < 0) { s->setup_state = SETUP_STATE_IDLE; } switch (s->setup_state) { case SETUP_STATE_SETUP: if (p->len < s->setup_len) { s->setup_len = p->len; } s->setup_state = SETUP_STATE_DATA; p->len = 8; break; case SETUP_STATE_ACK: s->setup_state = SETUP_STATE_IDLE; p->len = 0; break; default: break; } usb_packet_complete(s, p); }
true
qemu
4f4321c11ff6e98583846bfd6f0e81954924b003
void usb_generic_async_ctrl_complete(USBDevice *s, USBPacket *p) { if (p->len < 0) { s->setup_state = SETUP_STATE_IDLE; } switch (s->setup_state) { case SETUP_STATE_SETUP: if (p->len < s->setup_len) { s->setup_len = p->len; } s->setup_state = SETUP_STATE_DATA; p->len = 8; break; case SETUP_STATE_ACK: s->setup_state = SETUP_STATE_IDLE; p->len = 0; break; default: break; } usb_packet_complete(s, p); }
{ "code": [ " if (p->len < 0) {", " if (p->len < s->setup_len) {", " s->setup_len = p->len;", " p->len = 8;", " p->len = 0;" ], "line_no": [ 5, 17, 19, 25, 35 ] }
void FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1) { if (VAR_1->len < 0) { VAR_0->setup_state = SETUP_STATE_IDLE; } switch (VAR_0->setup_state) { case SETUP_STATE_SETUP: if (VAR_1->len < VAR_0->setup_len) { VAR_0->setup_len = VAR_1->len; } VAR_0->setup_state = SETUP_STATE_DATA; VAR_1->len = 8; break; case SETUP_STATE_ACK: VAR_0->setup_state = SETUP_STATE_IDLE; VAR_1->len = 0; break; default: break; } usb_packet_complete(VAR_0, VAR_1); }
[ "void FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)\n{", "if (VAR_1->len < 0) {", "VAR_0->setup_state = SETUP_STATE_IDLE;", "}", "switch (VAR_0->setup_state) {", "case SETUP_STATE_SETUP:\nif (VAR_1->len < VAR_0->setup_len) {", "VAR_0->setup_len = VAR_1->len;", "}", "VAR_0->setup_state = SETUP_STATE_DATA;", "VAR_1->len = 8;", "break;", "case SETUP_STATE_ACK:\nVAR_0->setup_state = SETUP_STATE_IDLE;", "VAR_1->len = 0;", "break;", "default:\nbreak;", "}", "usb_packet_complete(VAR_0, VAR_1);", "}" ]
[ 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15, 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 31, 33 ], [ 35 ], [ 37 ], [ 41, 43 ], [ 45 ], [ 47 ], [ 49 ] ]
663
static int encode_audio_frame(AVFormatContext *s, OutputStream *ost, const uint8_t *buf, int buf_size) { AVCodecContext *enc = ost->st->codec; AVFrame *frame = NULL; AVPacket pkt; int ret, got_packet; av_init_packet(&pkt); pkt.data = NULL; pkt.size = 0; if (buf && buf_size) { if (!ost->output_frame) { ost->output_frame = avcodec_alloc_frame(); if (!ost->output_frame) { av_log(NULL, AV_LOG_FATAL, "out-of-memory in encode_audio_frame()\n"); exit_program(1); } } frame = ost->output_frame; if (frame->extended_data != frame->data) av_freep(&frame->extended_data); avcodec_get_frame_defaults(frame); frame->nb_samples = buf_size / (enc->channels * av_get_bytes_per_sample(enc->sample_fmt)); if ((ret = avcodec_fill_audio_frame(frame, enc->channels, enc->sample_fmt, buf, buf_size, 1)) < 0) { av_log(NULL, AV_LOG_FATAL, "Audio encoding failed (avcodec_fill_audio_frame)\n"); exit_program(1); } frame->pts = ost->sync_opts; ost->sync_opts += frame->nb_samples; } got_packet = 0; update_benchmark(NULL); if (avcodec_encode_audio2(enc, &pkt, frame, &got_packet) < 0) { av_log(NULL, AV_LOG_FATAL, "Audio encoding failed (avcodec_encode_audio2)\n"); exit_program(1); } update_benchmark("encode_audio %d.%d", ost->file_index, ost->index); ret = pkt.size; if (got_packet) { if (pkt.pts != AV_NOPTS_VALUE) pkt.pts = av_rescale_q(pkt.pts, enc->time_base, ost->st->time_base); if (pkt.dts != AV_NOPTS_VALUE) { int64_t max = ost->st->cur_dts + !(s->oformat->flags & AVFMT_TS_NONSTRICT); pkt.dts = av_rescale_q(pkt.dts, enc->time_base, ost->st->time_base); if (ost->st->cur_dts && ost->st->cur_dts != AV_NOPTS_VALUE && max > pkt.dts) { av_log(s, max - pkt.dts > 2 ? AV_LOG_WARNING : AV_LOG_DEBUG, "Audio timestamp %"PRId64" < %"PRId64" invalid, cliping\n", pkt.dts, max); pkt.pts = pkt.dts = max; } } if (pkt.duration > 0) pkt.duration = av_rescale_q(pkt.duration, enc->time_base, ost->st->time_base); write_frame(s, &pkt, ost); audio_size += pkt.size; av_free_packet(&pkt); } if (debug_ts) { av_log(NULL, AV_LOG_INFO, "encoder -> type:audio " "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n", av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ost->st->time_base), av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ost->st->time_base)); } return ret; }
true
FFmpeg
fc49f22c3b735db5aaac5f98e40b7124a2be13b8
static int encode_audio_frame(AVFormatContext *s, OutputStream *ost, const uint8_t *buf, int buf_size) { AVCodecContext *enc = ost->st->codec; AVFrame *frame = NULL; AVPacket pkt; int ret, got_packet; av_init_packet(&pkt); pkt.data = NULL; pkt.size = 0; if (buf && buf_size) { if (!ost->output_frame) { ost->output_frame = avcodec_alloc_frame(); if (!ost->output_frame) { av_log(NULL, AV_LOG_FATAL, "out-of-memory in encode_audio_frame()\n"); exit_program(1); } } frame = ost->output_frame; if (frame->extended_data != frame->data) av_freep(&frame->extended_data); avcodec_get_frame_defaults(frame); frame->nb_samples = buf_size / (enc->channels * av_get_bytes_per_sample(enc->sample_fmt)); if ((ret = avcodec_fill_audio_frame(frame, enc->channels, enc->sample_fmt, buf, buf_size, 1)) < 0) { av_log(NULL, AV_LOG_FATAL, "Audio encoding failed (avcodec_fill_audio_frame)\n"); exit_program(1); } frame->pts = ost->sync_opts; ost->sync_opts += frame->nb_samples; } got_packet = 0; update_benchmark(NULL); if (avcodec_encode_audio2(enc, &pkt, frame, &got_packet) < 0) { av_log(NULL, AV_LOG_FATAL, "Audio encoding failed (avcodec_encode_audio2)\n"); exit_program(1); } update_benchmark("encode_audio %d.%d", ost->file_index, ost->index); ret = pkt.size; if (got_packet) { if (pkt.pts != AV_NOPTS_VALUE) pkt.pts = av_rescale_q(pkt.pts, enc->time_base, ost->st->time_base); if (pkt.dts != AV_NOPTS_VALUE) { int64_t max = ost->st->cur_dts + !(s->oformat->flags & AVFMT_TS_NONSTRICT); pkt.dts = av_rescale_q(pkt.dts, enc->time_base, ost->st->time_base); if (ost->st->cur_dts && ost->st->cur_dts != AV_NOPTS_VALUE && max > pkt.dts) { av_log(s, max - pkt.dts > 2 ? AV_LOG_WARNING : AV_LOG_DEBUG, "Audio timestamp %"PRId64" < %"PRId64" invalid, cliping\n", pkt.dts, max); pkt.pts = pkt.dts = max; } } if (pkt.duration > 0) pkt.duration = av_rescale_q(pkt.duration, enc->time_base, ost->st->time_base); write_frame(s, &pkt, ost); audio_size += pkt.size; av_free_packet(&pkt); } if (debug_ts) { av_log(NULL, AV_LOG_INFO, "encoder -> type:audio " "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n", av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ost->st->time_base), av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ost->st->time_base)); } return ret; }
{ "code": [ " AVCodecContext *enc = ost->st->codec;", " exit_program(1);", " exit_program(1);", "static int encode_audio_frame(AVFormatContext *s, OutputStream *ost,", " const uint8_t *buf, int buf_size)", " AVFrame *frame = NULL;", " int ret, got_packet;", " if (buf && buf_size) {", " if (!ost->output_frame) {", " ost->output_frame = avcodec_alloc_frame();", " if (!ost->output_frame) {", " av_log(NULL, AV_LOG_FATAL, \"out-of-memory in encode_audio_frame()\\n\");", " exit_program(1);", " frame = ost->output_frame;", " if (frame->extended_data != frame->data)", " av_freep(&frame->extended_data);", " avcodec_get_frame_defaults(frame);", " frame->nb_samples = buf_size /", " (enc->channels * av_get_bytes_per_sample(enc->sample_fmt));", " if ((ret = avcodec_fill_audio_frame(frame, enc->channels, enc->sample_fmt,", " buf, buf_size, 1)) < 0) {", " av_log(NULL, AV_LOG_FATAL, \"Audio encoding failed (avcodec_fill_audio_frame)\\n\");", " exit_program(1);", " ost->sync_opts += frame->nb_samples;", " got_packet = 0;", " ret = pkt.size;", " if (debug_ts) {", " av_log(NULL, AV_LOG_INFO, \"encoder -> type:audio \"", " \"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\\n\",", " av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ost->st->time_base),", " av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ost->st->time_base));", " return ret;", " AVCodecContext *enc = ost->st->codec;", " exit_program(1);", " exit_program(1);", " exit_program(1);", " exit_program(1);", " exit_program(1);", " exit_program(1);" ], "line_no": [ 7, 35, 61, 1, 3, 9, 13, 25, 27, 29, 31, 33, 35, 41, 43, 45, 47, 51, 53, 55, 57, 59, 61, 69, 75, 91, 137, 139, 141, 143, 145, 151, 7, 83, 35, 35, 35, 61, 61 ] }
static int FUNC_0(AVFormatContext *VAR_0, OutputStream *VAR_1, const uint8_t *VAR_2, int VAR_3) { AVCodecContext *enc = VAR_1->st->codec; AVFrame *frame = NULL; AVPacket pkt; int VAR_4, VAR_5; av_init_packet(&pkt); pkt.data = NULL; pkt.size = 0; if (VAR_2 && VAR_3) { if (!VAR_1->output_frame) { VAR_1->output_frame = avcodec_alloc_frame(); if (!VAR_1->output_frame) { av_log(NULL, AV_LOG_FATAL, "out-of-memory in FUNC_0()\n"); exit_program(1); } } frame = VAR_1->output_frame; if (frame->extended_data != frame->data) av_freep(&frame->extended_data); avcodec_get_frame_defaults(frame); frame->nb_samples = VAR_3 / (enc->channels * av_get_bytes_per_sample(enc->sample_fmt)); if ((VAR_4 = avcodec_fill_audio_frame(frame, enc->channels, enc->sample_fmt, VAR_2, VAR_3, 1)) < 0) { av_log(NULL, AV_LOG_FATAL, "Audio encoding failed (avcodec_fill_audio_frame)\n"); exit_program(1); } frame->pts = VAR_1->sync_opts; VAR_1->sync_opts += frame->nb_samples; } VAR_5 = 0; update_benchmark(NULL); if (avcodec_encode_audio2(enc, &pkt, frame, &VAR_5) < 0) { av_log(NULL, AV_LOG_FATAL, "Audio encoding failed (avcodec_encode_audio2)\n"); exit_program(1); } update_benchmark("encode_audio %d.%d", VAR_1->file_index, VAR_1->index); VAR_4 = pkt.size; if (VAR_5) { if (pkt.pts != AV_NOPTS_VALUE) pkt.pts = av_rescale_q(pkt.pts, enc->time_base, VAR_1->st->time_base); if (pkt.dts != AV_NOPTS_VALUE) { int64_t max = VAR_1->st->cur_dts + !(VAR_0->oformat->flags & AVFMT_TS_NONSTRICT); pkt.dts = av_rescale_q(pkt.dts, enc->time_base, VAR_1->st->time_base); if (VAR_1->st->cur_dts && VAR_1->st->cur_dts != AV_NOPTS_VALUE && max > pkt.dts) { av_log(VAR_0, max - pkt.dts > 2 ? AV_LOG_WARNING : AV_LOG_DEBUG, "Audio timestamp %"PRId64" < %"PRId64" invalid, cliping\n", pkt.dts, max); pkt.pts = pkt.dts = max; } } if (pkt.duration > 0) pkt.duration = av_rescale_q(pkt.duration, enc->time_base, VAR_1->st->time_base); write_frame(VAR_0, &pkt, VAR_1); audio_size += pkt.size; av_free_packet(&pkt); } if (debug_ts) { av_log(NULL, AV_LOG_INFO, "encoder -> type:audio " "pkt_pts:%VAR_0 pkt_pts_time:%VAR_0 pkt_dts:%VAR_0 pkt_dts_time:%VAR_0\n", av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &VAR_1->st->time_base), av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &VAR_1->st->time_base)); } return VAR_4; }
[ "static int FUNC_0(AVFormatContext *VAR_0, OutputStream *VAR_1,\nconst uint8_t *VAR_2, int VAR_3)\n{", "AVCodecContext *enc = VAR_1->st->codec;", "AVFrame *frame = NULL;", "AVPacket pkt;", "int VAR_4, VAR_5;", "av_init_packet(&pkt);", "pkt.data = NULL;", "pkt.size = 0;", "if (VAR_2 && VAR_3) {", "if (!VAR_1->output_frame) {", "VAR_1->output_frame = avcodec_alloc_frame();", "if (!VAR_1->output_frame) {", "av_log(NULL, AV_LOG_FATAL, \"out-of-memory in FUNC_0()\\n\");", "exit_program(1);", "}", "}", "frame = VAR_1->output_frame;", "if (frame->extended_data != frame->data)\nav_freep(&frame->extended_data);", "avcodec_get_frame_defaults(frame);", "frame->nb_samples = VAR_3 /\n(enc->channels * av_get_bytes_per_sample(enc->sample_fmt));", "if ((VAR_4 = avcodec_fill_audio_frame(frame, enc->channels, enc->sample_fmt,\nVAR_2, VAR_3, 1)) < 0) {", "av_log(NULL, AV_LOG_FATAL, \"Audio encoding failed (avcodec_fill_audio_frame)\\n\");", "exit_program(1);", "}", "frame->pts = VAR_1->sync_opts;", "VAR_1->sync_opts += frame->nb_samples;", "}", "VAR_5 = 0;", "update_benchmark(NULL);", "if (avcodec_encode_audio2(enc, &pkt, frame, &VAR_5) < 0) {", "av_log(NULL, AV_LOG_FATAL, \"Audio encoding failed (avcodec_encode_audio2)\\n\");", "exit_program(1);", "}", "update_benchmark(\"encode_audio %d.%d\", VAR_1->file_index, VAR_1->index);", "VAR_4 = pkt.size;", "if (VAR_5) {", "if (pkt.pts != AV_NOPTS_VALUE)\npkt.pts = av_rescale_q(pkt.pts, enc->time_base, VAR_1->st->time_base);", "if (pkt.dts != AV_NOPTS_VALUE) {", "int64_t max = VAR_1->st->cur_dts + !(VAR_0->oformat->flags & AVFMT_TS_NONSTRICT);", "pkt.dts = av_rescale_q(pkt.dts, enc->time_base, VAR_1->st->time_base);", "if (VAR_1->st->cur_dts && VAR_1->st->cur_dts != AV_NOPTS_VALUE && max > pkt.dts) {", "av_log(VAR_0, max - pkt.dts > 2 ? AV_LOG_WARNING : AV_LOG_DEBUG, \"Audio timestamp %\"PRId64\" < %\"PRId64\" invalid, cliping\\n\", pkt.dts, max);", "pkt.pts = pkt.dts = max;", "}", "}", "if (pkt.duration > 0)\npkt.duration = av_rescale_q(pkt.duration, enc->time_base, VAR_1->st->time_base);", "write_frame(VAR_0, &pkt, VAR_1);", "audio_size += pkt.size;", "av_free_packet(&pkt);", "}", "if (debug_ts) {", "av_log(NULL, AV_LOG_INFO, \"encoder -> type:audio \"\n\"pkt_pts:%VAR_0 pkt_pts_time:%VAR_0 pkt_dts:%VAR_0 pkt_dts_time:%VAR_0\\n\",\nav_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &VAR_1->st->time_base),\nav_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &VAR_1->st->time_base));", "}", "return VAR_4;", "}" ]
[ 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43, 45 ], [ 47 ], [ 51, 53 ], [ 55, 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 91 ], [ 95 ], [ 97, 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117, 119 ], [ 123 ], [ 127 ], [ 131 ], [ 133 ], [ 137 ], [ 139, 141, 143, 145 ], [ 147 ], [ 151 ], [ 153 ] ]
664
static void rng_egd_opened(RngBackend *b, Error **errp) { RngEgd *s = RNG_EGD(b); if (s->chr_name == NULL) { error_set(errp, QERR_INVALID_PARAMETER_VALUE, "chardev", "a valid character device"); s->chr = qemu_chr_find(s->chr_name); if (s->chr == NULL) { error_set(errp, QERR_DEVICE_NOT_FOUND, s->chr_name); /* FIXME we should resubmit pending requests when the CDS reconnects. */ qemu_chr_add_handlers(s->chr, rng_egd_chr_can_read, rng_egd_chr_read, NULL, s);
true
qemu
456d60692310e7ac25cf822cc1e98192ad636ece
static void rng_egd_opened(RngBackend *b, Error **errp) { RngEgd *s = RNG_EGD(b); if (s->chr_name == NULL) { error_set(errp, QERR_INVALID_PARAMETER_VALUE, "chardev", "a valid character device"); s->chr = qemu_chr_find(s->chr_name); if (s->chr == NULL) { error_set(errp, QERR_DEVICE_NOT_FOUND, s->chr_name); qemu_chr_add_handlers(s->chr, rng_egd_chr_can_read, rng_egd_chr_read, NULL, s);
{ "code": [], "line_no": [] }
static void FUNC_0(RngBackend *VAR_0, Error **VAR_1) { RngEgd *s = RNG_EGD(VAR_0); if (s->chr_name == NULL) { error_set(VAR_1, QERR_INVALID_PARAMETER_VALUE, "chardev", "a valid character device"); s->chr = qemu_chr_find(s->chr_name); if (s->chr == NULL) { error_set(VAR_1, QERR_DEVICE_NOT_FOUND, s->chr_name); qemu_chr_add_handlers(s->chr, rng_egd_chr_can_read, rng_egd_chr_read, NULL, s);
[ "static void FUNC_0(RngBackend *VAR_0, Error **VAR_1)\n{", "RngEgd *s = RNG_EGD(VAR_0);", "if (s->chr_name == NULL) {", "error_set(VAR_1, QERR_INVALID_PARAMETER_VALUE,\n\"chardev\", \"a valid character device\");", "s->chr = qemu_chr_find(s->chr_name);", "if (s->chr == NULL) {", "error_set(VAR_1, QERR_DEVICE_NOT_FOUND, s->chr_name);", "qemu_chr_add_handlers(s->chr, rng_egd_chr_can_read, rng_egd_chr_read,\nNULL, s);" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 2 ], [ 3 ], [ 4 ], [ 5, 6 ], [ 7 ], [ 8 ], [ 9 ], [ 11, 12 ] ]
665
static int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit) { MpegTSContext *ts = s->priv_data; int64_t pos, timestamp; uint8_t buf[TS_PACKET_SIZE]; int pcr_l, pcr_pid = ((PESContext*)s->streams[stream_index]->priv_data)->pcr_pid; pos = ((*ppos + ts->raw_packet_size - 1 - ts->pos47) / ts->raw_packet_size) * ts->raw_packet_size + ts->pos47; while(pos < pos_limit) { avio_seek(s->pb, pos, SEEK_SET); if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE) return AV_NOPTS_VALUE; if ((pcr_pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pcr_pid) && parse_pcr(&timestamp, &pcr_l, buf) == 0) { *ppos = pos; return timestamp; } pos += ts->raw_packet_size; } return AV_NOPTS_VALUE; }
false
FFmpeg
0a90b6a43e76aec8031b6c8a46bba2bf6cd25fa7
static int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit) { MpegTSContext *ts = s->priv_data; int64_t pos, timestamp; uint8_t buf[TS_PACKET_SIZE]; int pcr_l, pcr_pid = ((PESContext*)s->streams[stream_index]->priv_data)->pcr_pid; pos = ((*ppos + ts->raw_packet_size - 1 - ts->pos47) / ts->raw_packet_size) * ts->raw_packet_size + ts->pos47; while(pos < pos_limit) { avio_seek(s->pb, pos, SEEK_SET); if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE) return AV_NOPTS_VALUE; if ((pcr_pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pcr_pid) && parse_pcr(&timestamp, &pcr_l, buf) == 0) { *ppos = pos; return timestamp; } pos += ts->raw_packet_size; } return AV_NOPTS_VALUE; }
{ "code": [], "line_no": [] }
static int64_t FUNC_0(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit) { MpegTSContext *ts = s->priv_data; int64_t pos, timestamp; uint8_t buf[TS_PACKET_SIZE]; int VAR_0, VAR_1 = ((PESContext*)s->streams[stream_index]->priv_data)->VAR_1; pos = ((*ppos + ts->raw_packet_size - 1 - ts->pos47) / ts->raw_packet_size) * ts->raw_packet_size + ts->pos47; while(pos < pos_limit) { avio_seek(s->pb, pos, SEEK_SET); if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE) return AV_NOPTS_VALUE; if ((VAR_1 < 0 || (AV_RB16(buf + 1) & 0x1fff) == VAR_1) && parse_pcr(&timestamp, &VAR_0, buf) == 0) { *ppos = pos; return timestamp; } pos += ts->raw_packet_size; } return AV_NOPTS_VALUE; }
[ "static int64_t FUNC_0(AVFormatContext *s, int stream_index,\nint64_t *ppos, int64_t pos_limit)\n{", "MpegTSContext *ts = s->priv_data;", "int64_t pos, timestamp;", "uint8_t buf[TS_PACKET_SIZE];", "int VAR_0, VAR_1 = ((PESContext*)s->streams[stream_index]->priv_data)->VAR_1;", "pos = ((*ppos + ts->raw_packet_size - 1 - ts->pos47) / ts->raw_packet_size) * ts->raw_packet_size + ts->pos47;", "while(pos < pos_limit) {", "avio_seek(s->pb, pos, SEEK_SET);", "if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)\nreturn AV_NOPTS_VALUE;", "if ((VAR_1 < 0 || (AV_RB16(buf + 1) & 0x1fff) == VAR_1) &&\nparse_pcr(&timestamp, &VAR_0, buf) == 0) {", "*ppos = pos;", "return timestamp;", "}", "pos += ts->raw_packet_size;", "}", "return AV_NOPTS_VALUE;", "}" ]
[ 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 ] ]
667
static enum AVPixelFormat get_pixel_format(H264Context *h) { #define HWACCEL_MAX (CONFIG_H264_DXVA2_HWACCEL + \ CONFIG_H264_D3D11VA_HWACCEL + \ CONFIG_H264_VAAPI_HWACCEL + \ (CONFIG_H264_VDA_HWACCEL * 2) + \ CONFIG_H264_VDPAU_HWACCEL) enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts; const enum AVPixelFormat *choices = pix_fmts; switch (h->sps.bit_depth_luma) { case 9: if (CHROMA444(h)) { if (h->avctx->colorspace == AVCOL_SPC_RGB) { *fmt++ = AV_PIX_FMT_GBRP9; } else *fmt++ = AV_PIX_FMT_YUV444P9; } else if (CHROMA422(h)) *fmt++ = AV_PIX_FMT_YUV422P9; else *fmt++ = AV_PIX_FMT_YUV420P9; break; case 10: if (CHROMA444(h)) { if (h->avctx->colorspace == AVCOL_SPC_RGB) { *fmt++ = AV_PIX_FMT_GBRP10; } else *fmt++ = AV_PIX_FMT_YUV444P10; } else if (CHROMA422(h)) *fmt++ = AV_PIX_FMT_YUV422P10; else *fmt++ = AV_PIX_FMT_YUV420P10; break; case 8: #if CONFIG_H264_VDPAU_HWACCEL *fmt++ = AV_PIX_FMT_VDPAU; #endif if (CHROMA444(h)) { if (h->avctx->colorspace == AVCOL_SPC_RGB) *fmt++ = AV_PIX_FMT_GBRP; else if (h->avctx->color_range == AVCOL_RANGE_JPEG) *fmt++ = AV_PIX_FMT_YUVJ444P; else *fmt++ = AV_PIX_FMT_YUV444P; } else if (CHROMA422(h)) { if (h->avctx->color_range == AVCOL_RANGE_JPEG) *fmt++ = AV_PIX_FMT_YUVJ422P; else *fmt++ = AV_PIX_FMT_YUV422P; } else { #if CONFIG_H264_DXVA2_HWACCEL *fmt++ = AV_PIX_FMT_DXVA2_VLD; #endif #if CONFIG_H264_D3D11VA_HWACCEL *fmt++ = AV_PIX_FMT_D3D11VA_VLD; #endif #if CONFIG_H264_VAAPI_HWACCEL *fmt++ = AV_PIX_FMT_VAAPI; #endif #if CONFIG_H264_VDA_HWACCEL *fmt++ = AV_PIX_FMT_VDA_VLD; *fmt++ = AV_PIX_FMT_VDA; #endif if (h->avctx->codec->pix_fmts) choices = h->avctx->codec->pix_fmts; else if (h->avctx->color_range == AVCOL_RANGE_JPEG) *fmt++ = AV_PIX_FMT_YUVJ420P; else *fmt++ = AV_PIX_FMT_YUV420P; } break; default: av_log(h->avctx, AV_LOG_ERROR, "Unsupported bit depth %d\n", h->sps.bit_depth_luma); return AVERROR_INVALIDDATA; } *fmt = AV_PIX_FMT_NONE; return ff_get_format(h->avctx, choices); }
false
FFmpeg
3176217c60ca7828712985092d9102d331ea4f3d
static enum AVPixelFormat get_pixel_format(H264Context *h) { #define HWACCEL_MAX (CONFIG_H264_DXVA2_HWACCEL + \ CONFIG_H264_D3D11VA_HWACCEL + \ CONFIG_H264_VAAPI_HWACCEL + \ (CONFIG_H264_VDA_HWACCEL * 2) + \ CONFIG_H264_VDPAU_HWACCEL) enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts; const enum AVPixelFormat *choices = pix_fmts; switch (h->sps.bit_depth_luma) { case 9: if (CHROMA444(h)) { if (h->avctx->colorspace == AVCOL_SPC_RGB) { *fmt++ = AV_PIX_FMT_GBRP9; } else *fmt++ = AV_PIX_FMT_YUV444P9; } else if (CHROMA422(h)) *fmt++ = AV_PIX_FMT_YUV422P9; else *fmt++ = AV_PIX_FMT_YUV420P9; break; case 10: if (CHROMA444(h)) { if (h->avctx->colorspace == AVCOL_SPC_RGB) { *fmt++ = AV_PIX_FMT_GBRP10; } else *fmt++ = AV_PIX_FMT_YUV444P10; } else if (CHROMA422(h)) *fmt++ = AV_PIX_FMT_YUV422P10; else *fmt++ = AV_PIX_FMT_YUV420P10; break; case 8: #if CONFIG_H264_VDPAU_HWACCEL *fmt++ = AV_PIX_FMT_VDPAU; #endif if (CHROMA444(h)) { if (h->avctx->colorspace == AVCOL_SPC_RGB) *fmt++ = AV_PIX_FMT_GBRP; else if (h->avctx->color_range == AVCOL_RANGE_JPEG) *fmt++ = AV_PIX_FMT_YUVJ444P; else *fmt++ = AV_PIX_FMT_YUV444P; } else if (CHROMA422(h)) { if (h->avctx->color_range == AVCOL_RANGE_JPEG) *fmt++ = AV_PIX_FMT_YUVJ422P; else *fmt++ = AV_PIX_FMT_YUV422P; } else { #if CONFIG_H264_DXVA2_HWACCEL *fmt++ = AV_PIX_FMT_DXVA2_VLD; #endif #if CONFIG_H264_D3D11VA_HWACCEL *fmt++ = AV_PIX_FMT_D3D11VA_VLD; #endif #if CONFIG_H264_VAAPI_HWACCEL *fmt++ = AV_PIX_FMT_VAAPI; #endif #if CONFIG_H264_VDA_HWACCEL *fmt++ = AV_PIX_FMT_VDA_VLD; *fmt++ = AV_PIX_FMT_VDA; #endif if (h->avctx->codec->pix_fmts) choices = h->avctx->codec->pix_fmts; else if (h->avctx->color_range == AVCOL_RANGE_JPEG) *fmt++ = AV_PIX_FMT_YUVJ420P; else *fmt++ = AV_PIX_FMT_YUV420P; } break; default: av_log(h->avctx, AV_LOG_ERROR, "Unsupported bit depth %d\n", h->sps.bit_depth_luma); return AVERROR_INVALIDDATA; } *fmt = AV_PIX_FMT_NONE; return ff_get_format(h->avctx, choices); }
{ "code": [], "line_no": [] }
static enum AVPixelFormat FUNC_0(H264Context *VAR_0) { #define HWACCEL_MAX (CONFIG_H264_DXVA2_HWACCEL + \ CONFIG_H264_D3D11VA_HWACCEL + \ CONFIG_H264_VAAPI_HWACCEL + \ (CONFIG_H264_VDA_HWACCEL * 2) + \ CONFIG_H264_VDPAU_HWACCEL) enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts; const enum AVPixelFormat *VAR_1 = pix_fmts; switch (VAR_0->sps.bit_depth_luma) { case 9: if (CHROMA444(VAR_0)) { if (VAR_0->avctx->colorspace == AVCOL_SPC_RGB) { *fmt++ = AV_PIX_FMT_GBRP9; } else *fmt++ = AV_PIX_FMT_YUV444P9; } else if (CHROMA422(VAR_0)) *fmt++ = AV_PIX_FMT_YUV422P9; else *fmt++ = AV_PIX_FMT_YUV420P9; break; case 10: if (CHROMA444(VAR_0)) { if (VAR_0->avctx->colorspace == AVCOL_SPC_RGB) { *fmt++ = AV_PIX_FMT_GBRP10; } else *fmt++ = AV_PIX_FMT_YUV444P10; } else if (CHROMA422(VAR_0)) *fmt++ = AV_PIX_FMT_YUV422P10; else *fmt++ = AV_PIX_FMT_YUV420P10; break; case 8: #if CONFIG_H264_VDPAU_HWACCEL *fmt++ = AV_PIX_FMT_VDPAU; #endif if (CHROMA444(VAR_0)) { if (VAR_0->avctx->colorspace == AVCOL_SPC_RGB) *fmt++ = AV_PIX_FMT_GBRP; else if (VAR_0->avctx->color_range == AVCOL_RANGE_JPEG) *fmt++ = AV_PIX_FMT_YUVJ444P; else *fmt++ = AV_PIX_FMT_YUV444P; } else if (CHROMA422(VAR_0)) { if (VAR_0->avctx->color_range == AVCOL_RANGE_JPEG) *fmt++ = AV_PIX_FMT_YUVJ422P; else *fmt++ = AV_PIX_FMT_YUV422P; } else { #if CONFIG_H264_DXVA2_HWACCEL *fmt++ = AV_PIX_FMT_DXVA2_VLD; #endif #if CONFIG_H264_D3D11VA_HWACCEL *fmt++ = AV_PIX_FMT_D3D11VA_VLD; #endif #if CONFIG_H264_VAAPI_HWACCEL *fmt++ = AV_PIX_FMT_VAAPI; #endif #if CONFIG_H264_VDA_HWACCEL *fmt++ = AV_PIX_FMT_VDA_VLD; *fmt++ = AV_PIX_FMT_VDA; #endif if (VAR_0->avctx->codec->pix_fmts) VAR_1 = VAR_0->avctx->codec->pix_fmts; else if (VAR_0->avctx->color_range == AVCOL_RANGE_JPEG) *fmt++ = AV_PIX_FMT_YUVJ420P; else *fmt++ = AV_PIX_FMT_YUV420P; } break; default: av_log(VAR_0->avctx, AV_LOG_ERROR, "Unsupported bit depth %d\n", VAR_0->sps.bit_depth_luma); return AVERROR_INVALIDDATA; } *fmt = AV_PIX_FMT_NONE; return ff_get_format(VAR_0->avctx, VAR_1); }
[ "static enum AVPixelFormat FUNC_0(H264Context *VAR_0)\n{", "#define HWACCEL_MAX (CONFIG_H264_DXVA2_HWACCEL + \\\nCONFIG_H264_D3D11VA_HWACCEL + \\\nCONFIG_H264_VAAPI_HWACCEL + \\\n(CONFIG_H264_VDA_HWACCEL * 2) + \\\nCONFIG_H264_VDPAU_HWACCEL)\nenum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts;", "const enum AVPixelFormat *VAR_1 = pix_fmts;", "switch (VAR_0->sps.bit_depth_luma) {", "case 9:\nif (CHROMA444(VAR_0)) {", "if (VAR_0->avctx->colorspace == AVCOL_SPC_RGB) {", "*fmt++ = AV_PIX_FMT_GBRP9;", "} else", "*fmt++ = AV_PIX_FMT_YUV444P9;", "} else if (CHROMA422(VAR_0))", "*fmt++ = AV_PIX_FMT_YUV422P9;", "else\n*fmt++ = AV_PIX_FMT_YUV420P9;", "break;", "case 10:\nif (CHROMA444(VAR_0)) {", "if (VAR_0->avctx->colorspace == AVCOL_SPC_RGB) {", "*fmt++ = AV_PIX_FMT_GBRP10;", "} else", "*fmt++ = AV_PIX_FMT_YUV444P10;", "} else if (CHROMA422(VAR_0))", "*fmt++ = AV_PIX_FMT_YUV422P10;", "else\n*fmt++ = AV_PIX_FMT_YUV420P10;", "break;", "case 8:\n#if CONFIG_H264_VDPAU_HWACCEL\n*fmt++ = AV_PIX_FMT_VDPAU;", "#endif\nif (CHROMA444(VAR_0)) {", "if (VAR_0->avctx->colorspace == AVCOL_SPC_RGB)\n*fmt++ = AV_PIX_FMT_GBRP;", "else if (VAR_0->avctx->color_range == AVCOL_RANGE_JPEG)\n*fmt++ = AV_PIX_FMT_YUVJ444P;", "else\n*fmt++ = AV_PIX_FMT_YUV444P;", "} else if (CHROMA422(VAR_0)) {", "if (VAR_0->avctx->color_range == AVCOL_RANGE_JPEG)\n*fmt++ = AV_PIX_FMT_YUVJ422P;", "else\n*fmt++ = AV_PIX_FMT_YUV422P;", "} else {", "#if CONFIG_H264_DXVA2_HWACCEL\n*fmt++ = AV_PIX_FMT_DXVA2_VLD;", "#endif\n#if CONFIG_H264_D3D11VA_HWACCEL\n*fmt++ = AV_PIX_FMT_D3D11VA_VLD;", "#endif\n#if CONFIG_H264_VAAPI_HWACCEL\n*fmt++ = AV_PIX_FMT_VAAPI;", "#endif\n#if CONFIG_H264_VDA_HWACCEL\n*fmt++ = AV_PIX_FMT_VDA_VLD;", "*fmt++ = AV_PIX_FMT_VDA;", "#endif\nif (VAR_0->avctx->codec->pix_fmts)\nVAR_1 = VAR_0->avctx->codec->pix_fmts;", "else if (VAR_0->avctx->color_range == AVCOL_RANGE_JPEG)\n*fmt++ = AV_PIX_FMT_YUVJ420P;", "else\n*fmt++ = AV_PIX_FMT_YUV420P;", "}", "break;", "default:\nav_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Unsupported bit depth %d\\n\", VAR_0->sps.bit_depth_luma);", "return AVERROR_INVALIDDATA;", "}", "*fmt = AV_PIX_FMT_NONE;", "return ff_get_format(VAR_0->avctx, VAR_1);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5, 7, 9, 11, 13, 15 ], [ 17 ], [ 21 ], [ 23, 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39, 41 ], [ 43 ], [ 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61, 63 ], [ 65 ], [ 67, 69, 71 ], [ 73, 75 ], [ 77, 79 ], [ 81, 83 ], [ 85, 87 ], [ 89 ], [ 91, 93 ], [ 95, 97 ], [ 99 ], [ 101, 103 ], [ 105, 107, 109 ], [ 111, 113, 115 ], [ 117, 119, 121 ], [ 123 ], [ 125, 127, 129 ], [ 131, 133 ], [ 135, 137 ], [ 139 ], [ 141 ], [ 143, 145, 147 ], [ 149 ], [ 151 ], [ 155 ], [ 159 ], [ 161 ] ]
671
static void mv88w8618_eth_init(NICInfo *nd, uint32_t base, qemu_irq irq) { mv88w8618_eth_state *s; int iomemtype; qemu_check_nic_model(nd, "mv88w8618"); s = qemu_mallocz(sizeof(mv88w8618_eth_state)); s->irq = irq; s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, eth_receive, eth_can_receive, s); iomemtype = cpu_register_io_memory(0, mv88w8618_eth_readfn, mv88w8618_eth_writefn, s); cpu_register_physical_memory(base, MP_ETH_SIZE, iomemtype); }
true
qemu
b946a1533209f61a93e34898aebb5b43154b99c3
static void mv88w8618_eth_init(NICInfo *nd, uint32_t base, qemu_irq irq) { mv88w8618_eth_state *s; int iomemtype; qemu_check_nic_model(nd, "mv88w8618"); s = qemu_mallocz(sizeof(mv88w8618_eth_state)); s->irq = irq; s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, eth_receive, eth_can_receive, s); iomemtype = cpu_register_io_memory(0, mv88w8618_eth_readfn, mv88w8618_eth_writefn, s); cpu_register_physical_memory(base, MP_ETH_SIZE, iomemtype); }
{ "code": [ " int iomemtype;", " int iomemtype;", " eth_receive, eth_can_receive, s);", " iomemtype = cpu_register_io_memory(0, mv88w8618_eth_readfn,", " mv88w8618_eth_writefn, s);", " cpu_register_physical_memory(base, MP_ETH_SIZE, iomemtype);", " int iomemtype;", " int iomemtype;" ], "line_no": [ 7, 7, 21, 23, 25, 27, 7, 7 ] }
static void FUNC_0(NICInfo *VAR_0, uint32_t VAR_1, qemu_irq VAR_2) { mv88w8618_eth_state *s; int VAR_3; qemu_check_nic_model(VAR_0, "mv88w8618"); s = qemu_mallocz(sizeof(mv88w8618_eth_state)); s->VAR_2 = VAR_2; s->vc = qemu_new_vlan_client(VAR_0->vlan, VAR_0->model, VAR_0->name, eth_receive, eth_can_receive, s); VAR_3 = cpu_register_io_memory(0, mv88w8618_eth_readfn, mv88w8618_eth_writefn, s); cpu_register_physical_memory(VAR_1, MP_ETH_SIZE, VAR_3); }
[ "static void FUNC_0(NICInfo *VAR_0, uint32_t VAR_1, qemu_irq VAR_2)\n{", "mv88w8618_eth_state *s;", "int VAR_3;", "qemu_check_nic_model(VAR_0, \"mv88w8618\");", "s = qemu_mallocz(sizeof(mv88w8618_eth_state));", "s->VAR_2 = VAR_2;", "s->vc = qemu_new_vlan_client(VAR_0->vlan, VAR_0->model, VAR_0->name,\neth_receive, eth_can_receive, s);", "VAR_3 = cpu_register_io_memory(0, mv88w8618_eth_readfn,\nmv88w8618_eth_writefn, s);", "cpu_register_physical_memory(VAR_1, MP_ETH_SIZE, VAR_3);", "}" ]
[ 0, 0, 1, 0, 0, 0, 1, 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 15 ], [ 17 ], [ 19, 21 ], [ 23, 25 ], [ 27 ], [ 29 ] ]
672
static int vnc_update_client_sync(VncState *vs, int has_dirty) { int ret = vnc_update_client(vs, has_dirty); vnc_jobs_join(vs); return ret; }
true
qemu
38ee14f4f33f8836fc0e209ca59c6ae8c6edf380
static int vnc_update_client_sync(VncState *vs, int has_dirty) { int ret = vnc_update_client(vs, has_dirty); vnc_jobs_join(vs); return ret; }
{ "code": [ "static int vnc_update_client_sync(VncState *vs, int has_dirty)", " int ret = vnc_update_client(vs, has_dirty);", " vnc_jobs_join(vs);", " return ret;" ], "line_no": [ 1, 5, 7, 9 ] }
static int FUNC_0(VncState *VAR_0, int VAR_1) { int VAR_2 = vnc_update_client(VAR_0, VAR_1); vnc_jobs_join(VAR_0); return VAR_2; }
[ "static int FUNC_0(VncState *VAR_0, int VAR_1)\n{", "int VAR_2 = vnc_update_client(VAR_0, VAR_1);", "vnc_jobs_join(VAR_0);", "return VAR_2;", "}" ]
[ 1, 1, 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ] ]
673
static struct omap_tipb_bridge_s *omap_tipb_bridge_init( MemoryRegion *memory, hwaddr base, qemu_irq abort_irq, omap_clk clk) { struct omap_tipb_bridge_s *s = (struct omap_tipb_bridge_s *) g_malloc0(sizeof(struct omap_tipb_bridge_s)); s->abort = abort_irq; omap_tipb_bridge_reset(s); memory_region_init_io(&s->iomem, NULL, &omap_tipb_bridge_ops, s, "omap-tipb-bridge", 0x100); memory_region_add_subregion(memory, base, &s->iomem); return s; }
true
qemu
b45c03f585ea9bb1af76c73e82195418c294919d
static struct omap_tipb_bridge_s *omap_tipb_bridge_init( MemoryRegion *memory, hwaddr base, qemu_irq abort_irq, omap_clk clk) { struct omap_tipb_bridge_s *s = (struct omap_tipb_bridge_s *) g_malloc0(sizeof(struct omap_tipb_bridge_s)); s->abort = abort_irq; omap_tipb_bridge_reset(s); memory_region_init_io(&s->iomem, NULL, &omap_tipb_bridge_ops, s, "omap-tipb-bridge", 0x100); memory_region_add_subregion(memory, base, &s->iomem); return s; }
{ "code": [ " struct omap_tipb_bridge_s *s = (struct omap_tipb_bridge_s *)", " g_malloc0(sizeof(struct omap_tipb_bridge_s));" ], "line_no": [ 9, 11 ] }
static struct omap_tipb_bridge_s *FUNC_0( MemoryRegion *VAR_0, hwaddr VAR_1, qemu_irq VAR_2, omap_clk VAR_3) { struct omap_tipb_bridge_s *VAR_4 = (struct omap_tipb_bridge_s *) g_malloc0(sizeof(struct omap_tipb_bridge_s)); VAR_4->abort = VAR_2; omap_tipb_bridge_reset(VAR_4); memory_region_init_io(&VAR_4->iomem, NULL, &omap_tipb_bridge_ops, VAR_4, "omap-tipb-bridge", 0x100); memory_region_add_subregion(VAR_0, VAR_1, &VAR_4->iomem); return VAR_4; }
[ "static struct omap_tipb_bridge_s *FUNC_0(\nMemoryRegion *VAR_0, hwaddr VAR_1,\nqemu_irq VAR_2, omap_clk VAR_3)\n{", "struct omap_tipb_bridge_s *VAR_4 = (struct omap_tipb_bridge_s *)\ng_malloc0(sizeof(struct omap_tipb_bridge_s));", "VAR_4->abort = VAR_2;", "omap_tipb_bridge_reset(VAR_4);", "memory_region_init_io(&VAR_4->iomem, NULL, &omap_tipb_bridge_ops, VAR_4,\n\"omap-tipb-bridge\", 0x100);", "memory_region_add_subregion(VAR_0, VAR_1, &VAR_4->iomem);", "return VAR_4;", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9, 11 ], [ 15 ], [ 17 ], [ 21, 23 ], [ 25 ], [ 29 ], [ 31 ] ]
675
static void seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int data_size) { GetBitContext gb; int flags, i, j, x, y, op; unsigned char c[3]; unsigned char *dst; uint32_t *palette; flags = *data++; if (flags & 1) { palette = (uint32_t *)seq->frame.data[1]; for (i = 0; i < 256; i++) { for (j = 0; j < 3; j++, data++) c[j] = (*data << 2) | (*data >> 4); palette[i] = AV_RB24(c); } seq->frame.palette_has_changed = 1; } if (flags & 2) { init_get_bits(&gb, data, 128 * 8); data += 128; for (y = 0; y < 128; y += 8) for (x = 0; x < 256; x += 8) { dst = &seq->frame.data[0][y * seq->frame.linesize[0] + x]; op = get_bits(&gb, 2); switch (op) { case 1: data = seq_decode_op1(seq, data, dst); break; case 2: data = seq_decode_op2(seq, data, dst); break; case 3: data = seq_decode_op3(seq, data, dst); break; } } } }
true
FFmpeg
5d7e3d71673d64a16b58430a0027afadb6b3a54e
static void seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int data_size) { GetBitContext gb; int flags, i, j, x, y, op; unsigned char c[3]; unsigned char *dst; uint32_t *palette; flags = *data++; if (flags & 1) { palette = (uint32_t *)seq->frame.data[1]; for (i = 0; i < 256; i++) { for (j = 0; j < 3; j++, data++) c[j] = (*data << 2) | (*data >> 4); palette[i] = AV_RB24(c); } seq->frame.palette_has_changed = 1; } if (flags & 2) { init_get_bits(&gb, data, 128 * 8); data += 128; for (y = 0; y < 128; y += 8) for (x = 0; x < 256; x += 8) { dst = &seq->frame.data[0][y * seq->frame.linesize[0] + x]; op = get_bits(&gb, 2); switch (op) { case 1: data = seq_decode_op1(seq, data, dst); break; case 2: data = seq_decode_op2(seq, data, dst); break; case 3: data = seq_decode_op3(seq, data, dst); break; } } } }
{ "code": [ "static void seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int data_size)", " data = seq_decode_op1(seq, data, dst);", " data = seq_decode_op2(seq, data, dst);", " data = seq_decode_op3(seq, data, dst);" ], "line_no": [ 1, 57, 63, 69 ] }
static void FUNC_0(SeqVideoContext *VAR_0, const unsigned char *VAR_1, int VAR_2) { GetBitContext gb; int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8; unsigned char VAR_9[3]; unsigned char *VAR_10; uint32_t *palette; VAR_3 = *VAR_1++; if (VAR_3 & 1) { palette = (uint32_t *)VAR_0->frame.VAR_1[1]; for (VAR_4 = 0; VAR_4 < 256; VAR_4++) { for (VAR_5 = 0; VAR_5 < 3; VAR_5++, VAR_1++) VAR_9[VAR_5] = (*VAR_1 << 2) | (*VAR_1 >> 4); palette[VAR_4] = AV_RB24(VAR_9); } VAR_0->frame.palette_has_changed = 1; } if (VAR_3 & 2) { init_get_bits(&gb, VAR_1, 128 * 8); VAR_1 += 128; for (VAR_7 = 0; VAR_7 < 128; VAR_7 += 8) for (VAR_6 = 0; VAR_6 < 256; VAR_6 += 8) { VAR_10 = &VAR_0->frame.VAR_1[0][VAR_7 * VAR_0->frame.linesize[0] + VAR_6]; VAR_8 = get_bits(&gb, 2); switch (VAR_8) { case 1: VAR_1 = seq_decode_op1(VAR_0, VAR_1, VAR_10); break; case 2: VAR_1 = seq_decode_op2(VAR_0, VAR_1, VAR_10); break; case 3: VAR_1 = seq_decode_op3(VAR_0, VAR_1, VAR_10); break; } } } }
[ "static void FUNC_0(SeqVideoContext *VAR_0, const unsigned char *VAR_1, int VAR_2)\n{", "GetBitContext gb;", "int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;", "unsigned char VAR_9[3];", "unsigned char *VAR_10;", "uint32_t *palette;", "VAR_3 = *VAR_1++;", "if (VAR_3 & 1) {", "palette = (uint32_t *)VAR_0->frame.VAR_1[1];", "for (VAR_4 = 0; VAR_4 < 256; VAR_4++) {", "for (VAR_5 = 0; VAR_5 < 3; VAR_5++, VAR_1++)", "VAR_9[VAR_5] = (*VAR_1 << 2) | (*VAR_1 >> 4);", "palette[VAR_4] = AV_RB24(VAR_9);", "}", "VAR_0->frame.palette_has_changed = 1;", "}", "if (VAR_3 & 2) {", "init_get_bits(&gb, VAR_1, 128 * 8); VAR_1 += 128;", "for (VAR_7 = 0; VAR_7 < 128; VAR_7 += 8)", "for (VAR_6 = 0; VAR_6 < 256; VAR_6 += 8) {", "VAR_10 = &VAR_0->frame.VAR_1[0][VAR_7 * VAR_0->frame.linesize[0] + VAR_6];", "VAR_8 = get_bits(&gb, 2);", "switch (VAR_8) {", "case 1:\nVAR_1 = seq_decode_op1(VAR_0, VAR_1, VAR_10);", "break;", "case 2:\nVAR_1 = seq_decode_op2(VAR_0, VAR_1, VAR_10);", "break;", "case 3:\nVAR_1 = seq_decode_op3(VAR_0, VAR_1, VAR_10);", "break;", "}", "}", "}", "}" ]
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55, 57 ], [ 59 ], [ 61, 63 ], [ 65 ], [ 67, 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ] ]
676
static int get_video_buffer(AVFrame *frame, int align) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); int ret, i; if (!desc) return AVERROR(EINVAL); if ((ret = av_image_check_size(frame->width, frame->height, 0, NULL)) < 0) return ret; if (!frame->linesize[0]) { ret = av_image_fill_linesizes(frame->linesize, frame->format, frame->width); if (ret < 0) return ret; for (i = 0; i < 4 && frame->linesize[i]; i++) frame->linesize[i] = FFALIGN(frame->linesize[i], align); } for (i = 0; i < 4 && frame->linesize[i]; i++) { int h = frame->height; if (i == 1 || i == 2) h = -((-h) >> desc->log2_chroma_h); frame->buf[i] = av_buffer_alloc(frame->linesize[i] * h); if (!frame->buf[i]) goto fail; frame->data[i] = frame->buf[i]->data; } if (desc->flags & PIX_FMT_PAL || desc->flags & PIX_FMT_PSEUDOPAL) { av_buffer_unref(&frame->buf[1]); frame->buf[1] = av_buffer_alloc(1024); if (!frame->buf[1]) goto fail; frame->data[1] = frame->buf[1]->data; } frame->extended_data = frame->data; return 0; fail: av_frame_unref(frame); return AVERROR(ENOMEM); }
true
FFmpeg
1ad542f11f4717a9dee19d46f4da5ce3f6beb449
static int get_video_buffer(AVFrame *frame, int align) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); int ret, i; if (!desc) return AVERROR(EINVAL); if ((ret = av_image_check_size(frame->width, frame->height, 0, NULL)) < 0) return ret; if (!frame->linesize[0]) { ret = av_image_fill_linesizes(frame->linesize, frame->format, frame->width); if (ret < 0) return ret; for (i = 0; i < 4 && frame->linesize[i]; i++) frame->linesize[i] = FFALIGN(frame->linesize[i], align); } for (i = 0; i < 4 && frame->linesize[i]; i++) { int h = frame->height; if (i == 1 || i == 2) h = -((-h) >> desc->log2_chroma_h); frame->buf[i] = av_buffer_alloc(frame->linesize[i] * h); if (!frame->buf[i]) goto fail; frame->data[i] = frame->buf[i]->data; } if (desc->flags & PIX_FMT_PAL || desc->flags & PIX_FMT_PSEUDOPAL) { av_buffer_unref(&frame->buf[1]); frame->buf[1] = av_buffer_alloc(1024); if (!frame->buf[1]) goto fail; frame->data[1] = frame->buf[1]->data; } frame->extended_data = frame->data; return 0; fail: av_frame_unref(frame); return AVERROR(ENOMEM); }
{ "code": [ " int h = frame->height;" ], "line_no": [ 45 ] }
static int FUNC_0(AVFrame *VAR_0, int VAR_1) { const AVPixFmtDescriptor *VAR_2 = av_pix_fmt_desc_get(VAR_0->format); int VAR_3, VAR_4; if (!VAR_2) return AVERROR(EINVAL); if ((VAR_3 = av_image_check_size(VAR_0->width, VAR_0->height, 0, NULL)) < 0) return VAR_3; if (!VAR_0->linesize[0]) { VAR_3 = av_image_fill_linesizes(VAR_0->linesize, VAR_0->format, VAR_0->width); if (VAR_3 < 0) return VAR_3; for (VAR_4 = 0; VAR_4 < 4 && VAR_0->linesize[VAR_4]; VAR_4++) VAR_0->linesize[VAR_4] = FFALIGN(VAR_0->linesize[VAR_4], VAR_1); } for (VAR_4 = 0; VAR_4 < 4 && VAR_0->linesize[VAR_4]; VAR_4++) { int h = VAR_0->height; if (VAR_4 == 1 || VAR_4 == 2) h = -((-h) >> VAR_2->log2_chroma_h); VAR_0->buf[VAR_4] = av_buffer_alloc(VAR_0->linesize[VAR_4] * h); if (!VAR_0->buf[VAR_4]) goto fail; VAR_0->data[VAR_4] = VAR_0->buf[VAR_4]->data; } if (VAR_2->flags & PIX_FMT_PAL || VAR_2->flags & PIX_FMT_PSEUDOPAL) { av_buffer_unref(&VAR_0->buf[1]); VAR_0->buf[1] = av_buffer_alloc(1024); if (!VAR_0->buf[1]) goto fail; VAR_0->data[1] = VAR_0->buf[1]->data; } VAR_0->extended_data = VAR_0->data; return 0; fail: av_frame_unref(VAR_0); return AVERROR(ENOMEM); }
[ "static int FUNC_0(AVFrame *VAR_0, int VAR_1)\n{", "const AVPixFmtDescriptor *VAR_2 = av_pix_fmt_desc_get(VAR_0->format);", "int VAR_3, VAR_4;", "if (!VAR_2)\nreturn AVERROR(EINVAL);", "if ((VAR_3 = av_image_check_size(VAR_0->width, VAR_0->height, 0, NULL)) < 0)\nreturn VAR_3;", "if (!VAR_0->linesize[0]) {", "VAR_3 = av_image_fill_linesizes(VAR_0->linesize, VAR_0->format,\nVAR_0->width);", "if (VAR_3 < 0)\nreturn VAR_3;", "for (VAR_4 = 0; VAR_4 < 4 && VAR_0->linesize[VAR_4]; VAR_4++)", "VAR_0->linesize[VAR_4] = FFALIGN(VAR_0->linesize[VAR_4], VAR_1);", "}", "for (VAR_4 = 0; VAR_4 < 4 && VAR_0->linesize[VAR_4]; VAR_4++) {", "int h = VAR_0->height;", "if (VAR_4 == 1 || VAR_4 == 2)\nh = -((-h) >> VAR_2->log2_chroma_h);", "VAR_0->buf[VAR_4] = av_buffer_alloc(VAR_0->linesize[VAR_4] * h);", "if (!VAR_0->buf[VAR_4])\ngoto fail;", "VAR_0->data[VAR_4] = VAR_0->buf[VAR_4]->data;", "}", "if (VAR_2->flags & PIX_FMT_PAL || VAR_2->flags & PIX_FMT_PSEUDOPAL) {", "av_buffer_unref(&VAR_0->buf[1]);", "VAR_0->buf[1] = av_buffer_alloc(1024);", "if (!VAR_0->buf[1])\ngoto fail;", "VAR_0->data[1] = VAR_0->buf[1]->data;", "}", "VAR_0->extended_data = VAR_0->data;", "return 0;", "fail:\nav_frame_unref(VAR_0);", "return AVERROR(ENOMEM);", "}" ]
[ 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 ], [ 11, 13 ], [ 17, 19 ], [ 23 ], [ 25, 27 ], [ 29, 31 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47, 49 ], [ 53 ], [ 55, 57 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71, 73 ], [ 75 ], [ 77 ], [ 81 ], [ 85 ], [ 87, 89 ], [ 91 ], [ 93 ] ]
678
static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, VLCcode *codes, int flags) { int table_size, table_index, index, code_prefix, symbol, subtable_bits; int i, j, k, n, nb, inc; uint32_t code; VLC_TYPE (*table)[2]; table_size = 1 << table_nb_bits; if (table_nb_bits > 30) return -1; table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC); av_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size); if (table_index < 0) return table_index; table = &vlc->table[table_index]; for (i = 0; i < table_size; i++) { table[i][1] = 0; //bits table[i][0] = -1; //codes } /* first pass: map codes and compute auxiliary table sizes */ for (i = 0; i < nb_codes; i++) { n = codes[i].bits; code = codes[i].code; symbol = codes[i].symbol; av_dlog(NULL, "i=%d n=%d code=0x%x\n", i, n, code); if (n <= table_nb_bits) { /* no need to add another table */ j = code >> (32 - table_nb_bits); nb = 1 << (table_nb_bits - n); inc = 1; if (flags & INIT_VLC_LE) { j = bitswap_32(code); inc = 1 << n; } for (k = 0; k < nb; k++) { av_dlog(NULL, "%4x: code=%d n=%d\n", j, i, n); if (table[j][1] /*bits*/ != 0) { av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); return AVERROR_INVALIDDATA; } table[j][1] = n; //bits table[j][0] = symbol; j += inc; } } else { /* fill auxiliary table recursively */ n -= table_nb_bits; code_prefix = code >> (32 - table_nb_bits); subtable_bits = n; codes[i].bits = n; codes[i].code = code << table_nb_bits; for (k = i+1; k < nb_codes; k++) { n = codes[k].bits - table_nb_bits; if (n <= 0) break; code = codes[k].code; if (code >> (32 - table_nb_bits) != code_prefix) break; codes[k].bits = n; codes[k].code = code << table_nb_bits; subtable_bits = FFMAX(subtable_bits, n); } subtable_bits = FFMIN(subtable_bits, table_nb_bits); j = (flags & INIT_VLC_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix; table[j][1] = -subtable_bits; av_dlog(NULL, "%4x: n=%d (subtable)\n", j, codes[i].bits + table_nb_bits); index = build_table(vlc, subtable_bits, k-i, codes+i, flags); if (index < 0) return index; /* note: realloc has been done, so reload tables */ table = &vlc->table[table_index]; table[j][0] = index; //code av_assert0(table[j][0] == index); i = k-1; } } return table_index; }
false
FFmpeg
f7f96cf4bcc369730bb945e993bec53881e212f5
static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, VLCcode *codes, int flags) { int table_size, table_index, index, code_prefix, symbol, subtable_bits; int i, j, k, n, nb, inc; uint32_t code; VLC_TYPE (*table)[2]; table_size = 1 << table_nb_bits; if (table_nb_bits > 30) return -1; table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC); av_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size); if (table_index < 0) return table_index; table = &vlc->table[table_index]; for (i = 0; i < table_size; i++) { table[i][1] = 0; table[i][0] = -1; } for (i = 0; i < nb_codes; i++) { n = codes[i].bits; code = codes[i].code; symbol = codes[i].symbol; av_dlog(NULL, "i=%d n=%d code=0x%x\n", i, n, code); if (n <= table_nb_bits) { j = code >> (32 - table_nb_bits); nb = 1 << (table_nb_bits - n); inc = 1; if (flags & INIT_VLC_LE) { j = bitswap_32(code); inc = 1 << n; } for (k = 0; k < nb; k++) { av_dlog(NULL, "%4x: code=%d n=%d\n", j, i, n); if (table[j][1] != 0) { av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); return AVERROR_INVALIDDATA; } table[j][1] = n; table[j][0] = symbol; j += inc; } } else { n -= table_nb_bits; code_prefix = code >> (32 - table_nb_bits); subtable_bits = n; codes[i].bits = n; codes[i].code = code << table_nb_bits; for (k = i+1; k < nb_codes; k++) { n = codes[k].bits - table_nb_bits; if (n <= 0) break; code = codes[k].code; if (code >> (32 - table_nb_bits) != code_prefix) break; codes[k].bits = n; codes[k].code = code << table_nb_bits; subtable_bits = FFMAX(subtable_bits, n); } subtable_bits = FFMIN(subtable_bits, table_nb_bits); j = (flags & INIT_VLC_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix; table[j][1] = -subtable_bits; av_dlog(NULL, "%4x: n=%d (subtable)\n", j, codes[i].bits + table_nb_bits); index = build_table(vlc, subtable_bits, k-i, codes+i, flags); if (index < 0) return index; table = &vlc->table[table_index]; table[j][0] = index; av_assert0(table[j][0] == index); i = k-1; } } return table_index; }
{ "code": [], "line_no": [] }
static int FUNC_0(VLC *VAR_0, int VAR_1, int VAR_2, VLCcode *VAR_3, int VAR_4) { int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10; int VAR_11, VAR_12, VAR_13, VAR_14, VAR_15, VAR_16; uint32_t code; VLC_TYPE (*table)[2]; VAR_5 = 1 << VAR_1; if (VAR_1 > 30) return -1; VAR_6 = alloc_table(VAR_0, VAR_5, VAR_4 & INIT_VLC_USE_NEW_STATIC); av_dlog(NULL, "new table VAR_7=%d size=%d\VAR_14", VAR_6, VAR_5); if (VAR_6 < 0) return VAR_6; table = &VAR_0->table[VAR_6]; for (VAR_11 = 0; VAR_11 < VAR_5; VAR_11++) { table[VAR_11][1] = 0; table[VAR_11][0] = -1; } for (VAR_11 = 0; VAR_11 < VAR_2; VAR_11++) { VAR_14 = VAR_3[VAR_11].bits; code = VAR_3[VAR_11].code; VAR_9 = VAR_3[VAR_11].VAR_9; av_dlog(NULL, "VAR_11=%d VAR_14=%d code=0x%x\VAR_14", VAR_11, VAR_14, code); if (VAR_14 <= VAR_1) { VAR_12 = code >> (32 - VAR_1); VAR_15 = 1 << (VAR_1 - VAR_14); VAR_16 = 1; if (VAR_4 & INIT_VLC_LE) { VAR_12 = bitswap_32(code); VAR_16 = 1 << VAR_14; } for (VAR_13 = 0; VAR_13 < VAR_15; VAR_13++) { av_dlog(NULL, "%4x: code=%d VAR_14=%d\VAR_14", VAR_12, VAR_11, VAR_14); if (table[VAR_12][1] != 0) { av_log(NULL, AV_LOG_ERROR, "incorrect VAR_3\VAR_14"); return AVERROR_INVALIDDATA; } table[VAR_12][1] = VAR_14; table[VAR_12][0] = VAR_9; VAR_12 += VAR_16; } } else { VAR_14 -= VAR_1; VAR_8 = code >> (32 - VAR_1); VAR_10 = VAR_14; VAR_3[VAR_11].bits = VAR_14; VAR_3[VAR_11].code = code << VAR_1; for (VAR_13 = VAR_11+1; VAR_13 < VAR_2; VAR_13++) { VAR_14 = VAR_3[VAR_13].bits - VAR_1; if (VAR_14 <= 0) break; code = VAR_3[VAR_13].code; if (code >> (32 - VAR_1) != VAR_8) break; VAR_3[VAR_13].bits = VAR_14; VAR_3[VAR_13].code = code << VAR_1; VAR_10 = FFMAX(VAR_10, VAR_14); } VAR_10 = FFMIN(VAR_10, VAR_1); VAR_12 = (VAR_4 & INIT_VLC_LE) ? bitswap_32(VAR_8) >> (32 - VAR_1) : VAR_8; table[VAR_12][1] = -VAR_10; av_dlog(NULL, "%4x: VAR_14=%d (subtable)\VAR_14", VAR_12, VAR_3[VAR_11].bits + VAR_1); VAR_7 = FUNC_0(VAR_0, VAR_10, VAR_13-VAR_11, VAR_3+VAR_11, VAR_4); if (VAR_7 < 0) return VAR_7; table = &VAR_0->table[VAR_6]; table[VAR_12][0] = VAR_7; av_assert0(table[VAR_12][0] == VAR_7); VAR_11 = VAR_13-1; } } return VAR_6; }
[ "static int FUNC_0(VLC *VAR_0, int VAR_1, int VAR_2,\nVLCcode *VAR_3, int VAR_4)\n{", "int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;", "int VAR_11, VAR_12, VAR_13, VAR_14, VAR_15, VAR_16;", "uint32_t code;", "VLC_TYPE (*table)[2];", "VAR_5 = 1 << VAR_1;", "if (VAR_1 > 30)\nreturn -1;", "VAR_6 = alloc_table(VAR_0, VAR_5, VAR_4 & INIT_VLC_USE_NEW_STATIC);", "av_dlog(NULL, \"new table VAR_7=%d size=%d\\VAR_14\", VAR_6, VAR_5);", "if (VAR_6 < 0)\nreturn VAR_6;", "table = &VAR_0->table[VAR_6];", "for (VAR_11 = 0; VAR_11 < VAR_5; VAR_11++) {", "table[VAR_11][1] = 0;", "table[VAR_11][0] = -1;", "}", "for (VAR_11 = 0; VAR_11 < VAR_2; VAR_11++) {", "VAR_14 = VAR_3[VAR_11].bits;", "code = VAR_3[VAR_11].code;", "VAR_9 = VAR_3[VAR_11].VAR_9;", "av_dlog(NULL, \"VAR_11=%d VAR_14=%d code=0x%x\\VAR_14\", VAR_11, VAR_14, code);", "if (VAR_14 <= VAR_1) {", "VAR_12 = code >> (32 - VAR_1);", "VAR_15 = 1 << (VAR_1 - VAR_14);", "VAR_16 = 1;", "if (VAR_4 & INIT_VLC_LE) {", "VAR_12 = bitswap_32(code);", "VAR_16 = 1 << VAR_14;", "}", "for (VAR_13 = 0; VAR_13 < VAR_15; VAR_13++) {", "av_dlog(NULL, \"%4x: code=%d VAR_14=%d\\VAR_14\", VAR_12, VAR_11, VAR_14);", "if (table[VAR_12][1] != 0) {", "av_log(NULL, AV_LOG_ERROR, \"incorrect VAR_3\\VAR_14\");", "return AVERROR_INVALIDDATA;", "}", "table[VAR_12][1] = VAR_14;", "table[VAR_12][0] = VAR_9;", "VAR_12 += VAR_16;", "}", "} else {", "VAR_14 -= VAR_1;", "VAR_8 = code >> (32 - VAR_1);", "VAR_10 = VAR_14;", "VAR_3[VAR_11].bits = VAR_14;", "VAR_3[VAR_11].code = code << VAR_1;", "for (VAR_13 = VAR_11+1; VAR_13 < VAR_2; VAR_13++) {", "VAR_14 = VAR_3[VAR_13].bits - VAR_1;", "if (VAR_14 <= 0)\nbreak;", "code = VAR_3[VAR_13].code;", "if (code >> (32 - VAR_1) != VAR_8)\nbreak;", "VAR_3[VAR_13].bits = VAR_14;", "VAR_3[VAR_13].code = code << VAR_1;", "VAR_10 = FFMAX(VAR_10, VAR_14);", "}", "VAR_10 = FFMIN(VAR_10, VAR_1);", "VAR_12 = (VAR_4 & INIT_VLC_LE) ? bitswap_32(VAR_8) >> (32 - VAR_1) : VAR_8;", "table[VAR_12][1] = -VAR_10;", "av_dlog(NULL, \"%4x: VAR_14=%d (subtable)\\VAR_14\",\nVAR_12, VAR_3[VAR_11].bits + VAR_1);", "VAR_7 = FUNC_0(VAR_0, VAR_10, VAR_13-VAR_11, VAR_3+VAR_11, VAR_4);", "if (VAR_7 < 0)\nreturn VAR_7;", "table = &VAR_0->table[VAR_6];", "table[VAR_12][0] = VAR_7;", "av_assert0(table[VAR_12][0] == VAR_7);", "VAR_11 = VAR_13-1;", "}", "}", "return VAR_6;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19, 21 ], [ 23 ], [ 25 ], [ 27, 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113, 115 ], [ 117 ], [ 119, 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137, 139 ], [ 141 ], [ 143, 145 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ] ]
679
static void h264_h_loop_filter_luma_intra_c(uint8_t *pix, int stride, int alpha, int beta) { h264_loop_filter_luma_intra_c(pix, 1, stride, alpha, beta); }
false
FFmpeg
dd561441b1e849df7d8681c6f32af82d4088dafd
static void h264_h_loop_filter_luma_intra_c(uint8_t *pix, int stride, int alpha, int beta) { h264_loop_filter_luma_intra_c(pix, 1, stride, alpha, beta); }
{ "code": [], "line_no": [] }
static void FUNC_0(uint8_t *VAR_0, int VAR_1, int VAR_2, int VAR_3) { h264_loop_filter_luma_intra_c(VAR_0, 1, VAR_1, VAR_2, VAR_3); }
[ "static void FUNC_0(uint8_t *VAR_0, int VAR_1, int VAR_2, int VAR_3)\n{", "h264_loop_filter_luma_intra_c(VAR_0, 1, VAR_1, VAR_2, VAR_3);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
680
static inline void do_imdct(AC3DecodeContext *s, int channels) { int ch; for (ch=1; ch<=channels; ch++) { if (s->block_switch[ch]) { int i; float *x = s->tmp_output+128; for(i=0; i<128; i++) x[i] = s->transform_coeffs[ch][2*i]; ff_imdct_half(&s->imdct_256, s->tmp_output, x); s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, s->add_bias, 128); for(i=0; i<128; i++) x[i] = s->transform_coeffs[ch][2*i+1]; ff_imdct_half(&s->imdct_256, s->delay[ch-1], x); } else { ff_imdct_half(&s->imdct_512, s->tmp_output, s->transform_coeffs[ch]); s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, s->add_bias, 128); memcpy(s->delay[ch-1], s->tmp_output+128, 128*sizeof(float)); } } }
false
FFmpeg
3b6516f7e7bb33b7aef9fa25adbf45f3de6c0560
static inline void do_imdct(AC3DecodeContext *s, int channels) { int ch; for (ch=1; ch<=channels; ch++) { if (s->block_switch[ch]) { int i; float *x = s->tmp_output+128; for(i=0; i<128; i++) x[i] = s->transform_coeffs[ch][2*i]; ff_imdct_half(&s->imdct_256, s->tmp_output, x); s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, s->add_bias, 128); for(i=0; i<128; i++) x[i] = s->transform_coeffs[ch][2*i+1]; ff_imdct_half(&s->imdct_256, s->delay[ch-1], x); } else { ff_imdct_half(&s->imdct_512, s->tmp_output, s->transform_coeffs[ch]); s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, s->add_bias, 128); memcpy(s->delay[ch-1], s->tmp_output+128, 128*sizeof(float)); } } }
{ "code": [], "line_no": [] }
static inline void FUNC_0(AC3DecodeContext *VAR_0, int VAR_1) { int VAR_2; for (VAR_2=1; VAR_2<=VAR_1; VAR_2++) { if (VAR_0->block_switch[VAR_2]) { int VAR_3; float *VAR_4 = VAR_0->tmp_output+128; for(VAR_3=0; VAR_3<128; VAR_3++) VAR_4[VAR_3] = VAR_0->transform_coeffs[VAR_2][2*VAR_3]; ff_imdct_half(&VAR_0->imdct_256, VAR_0->tmp_output, VAR_4); VAR_0->dsp.vector_fmul_window(VAR_0->output[VAR_2-1], VAR_0->delay[VAR_2-1], VAR_0->tmp_output, VAR_0->window, VAR_0->add_bias, 128); for(VAR_3=0; VAR_3<128; VAR_3++) VAR_4[VAR_3] = VAR_0->transform_coeffs[VAR_2][2*VAR_3+1]; ff_imdct_half(&VAR_0->imdct_256, VAR_0->delay[VAR_2-1], VAR_4); } else { ff_imdct_half(&VAR_0->imdct_512, VAR_0->tmp_output, VAR_0->transform_coeffs[VAR_2]); VAR_0->dsp.vector_fmul_window(VAR_0->output[VAR_2-1], VAR_0->delay[VAR_2-1], VAR_0->tmp_output, VAR_0->window, VAR_0->add_bias, 128); memcpy(VAR_0->delay[VAR_2-1], VAR_0->tmp_output+128, 128*sizeof(float)); } } }
[ "static inline void FUNC_0(AC3DecodeContext *VAR_0, int VAR_1)\n{", "int VAR_2;", "for (VAR_2=1; VAR_2<=VAR_1; VAR_2++) {", "if (VAR_0->block_switch[VAR_2]) {", "int VAR_3;", "float *VAR_4 = VAR_0->tmp_output+128;", "for(VAR_3=0; VAR_3<128; VAR_3++)", "VAR_4[VAR_3] = VAR_0->transform_coeffs[VAR_2][2*VAR_3];", "ff_imdct_half(&VAR_0->imdct_256, VAR_0->tmp_output, VAR_4);", "VAR_0->dsp.vector_fmul_window(VAR_0->output[VAR_2-1], VAR_0->delay[VAR_2-1], VAR_0->tmp_output, VAR_0->window, VAR_0->add_bias, 128);", "for(VAR_3=0; VAR_3<128; VAR_3++)", "VAR_4[VAR_3] = VAR_0->transform_coeffs[VAR_2][2*VAR_3+1];", "ff_imdct_half(&VAR_0->imdct_256, VAR_0->delay[VAR_2-1], VAR_4);", "} else {", "ff_imdct_half(&VAR_0->imdct_512, VAR_0->tmp_output, VAR_0->transform_coeffs[VAR_2]);", "VAR_0->dsp.vector_fmul_window(VAR_0->output[VAR_2-1], VAR_0->delay[VAR_2-1], VAR_0->tmp_output, VAR_0->window, VAR_0->add_bias, 128);", "memcpy(VAR_0->delay[VAR_2-1], VAR_0->tmp_output+128, 128*sizeof(float));", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ] ]
681
static void parse_header_digest(struct iscsi_context *iscsi, const char *target) { QemuOptsList *list; QemuOpts *opts; const char *digest = NULL; list = qemu_find_opts("iscsi"); if (!list) { return; } opts = qemu_opts_find(list, target); if (opts == NULL) { opts = QTAILQ_FIRST(&list->head); if (!opts) { return; } } digest = qemu_opt_get(opts, "header-digest"); if (!digest) { return; } if (!strcmp(digest, "CRC32C")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_CRC32C); } else if (!strcmp(digest, "NONE")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE); } else if (!strcmp(digest, "CRC32C-NONE")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_CRC32C_NONE); } else if (!strcmp(digest, "NONE-CRC32C")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C); } else { error_report("Invalid header-digest setting : %s", digest); } }
true
qemu
f2917853f715b0ef55df29eb2ffea29dc69ce814
static void parse_header_digest(struct iscsi_context *iscsi, const char *target) { QemuOptsList *list; QemuOpts *opts; const char *digest = NULL; list = qemu_find_opts("iscsi"); if (!list) { return; } opts = qemu_opts_find(list, target); if (opts == NULL) { opts = QTAILQ_FIRST(&list->head); if (!opts) { return; } } digest = qemu_opt_get(opts, "header-digest"); if (!digest) { return; } if (!strcmp(digest, "CRC32C")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_CRC32C); } else if (!strcmp(digest, "NONE")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE); } else if (!strcmp(digest, "CRC32C-NONE")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_CRC32C_NONE); } else if (!strcmp(digest, "NONE-CRC32C")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C); } else { error_report("Invalid header-digest setting : %s", digest); } }
{ "code": [ "static void parse_header_digest(struct iscsi_context *iscsi, const char *target)", " error_report(\"Invalid header-digest setting : %s\", digest);" ], "line_no": [ 1, 67 ] }
static void FUNC_0(struct iscsi_context *VAR_0, const char *VAR_1) { QemuOptsList *list; QemuOpts *opts; const char *VAR_2 = NULL; list = qemu_find_opts("VAR_0"); if (!list) { return; } opts = qemu_opts_find(list, VAR_1); if (opts == NULL) { opts = QTAILQ_FIRST(&list->head); if (!opts) { return; } } VAR_2 = qemu_opt_get(opts, "header-VAR_2"); if (!VAR_2) { return; } if (!strcmp(VAR_2, "CRC32C")) { iscsi_set_header_digest(VAR_0, ISCSI_HEADER_DIGEST_CRC32C); } else if (!strcmp(VAR_2, "NONE")) { iscsi_set_header_digest(VAR_0, ISCSI_HEADER_DIGEST_NONE); } else if (!strcmp(VAR_2, "CRC32C-NONE")) { iscsi_set_header_digest(VAR_0, ISCSI_HEADER_DIGEST_CRC32C_NONE); } else if (!strcmp(VAR_2, "NONE-CRC32C")) { iscsi_set_header_digest(VAR_0, ISCSI_HEADER_DIGEST_NONE_CRC32C); } else { error_report("Invalid header-VAR_2 setting : %s", VAR_2); } }
[ "static void FUNC_0(struct iscsi_context *VAR_0, const char *VAR_1)\n{", "QemuOptsList *list;", "QemuOpts *opts;", "const char *VAR_2 = NULL;", "list = qemu_find_opts(\"VAR_0\");", "if (!list) {", "return;", "}", "opts = qemu_opts_find(list, VAR_1);", "if (opts == NULL) {", "opts = QTAILQ_FIRST(&list->head);", "if (!opts) {", "return;", "}", "}", "VAR_2 = qemu_opt_get(opts, \"header-VAR_2\");", "if (!VAR_2) {", "return;", "}", "if (!strcmp(VAR_2, \"CRC32C\")) {", "iscsi_set_header_digest(VAR_0, ISCSI_HEADER_DIGEST_CRC32C);", "} else if (!strcmp(VAR_2, \"NONE\")) {", "iscsi_set_header_digest(VAR_0, ISCSI_HEADER_DIGEST_NONE);", "} else if (!strcmp(VAR_2, \"CRC32C-NONE\")) {", "iscsi_set_header_digest(VAR_0, ISCSI_HEADER_DIGEST_CRC32C_NONE);", "} else if (!strcmp(VAR_2, \"NONE-CRC32C\")) {", "iscsi_set_header_digest(VAR_0, ISCSI_HEADER_DIGEST_NONE_CRC32C);", "} else {", "error_report(\"Invalid header-VAR_2 setting : %s\", VAR_2);", "}", "}" ]
[ 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, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ] ]
684
void visit_type_str(Visitor *v, char **obj, const char *name, Error **errp) { if (!error_is_set(errp)) { v->type_str(v, obj, name, errp); } }
true
qemu
297a3646c2947ee64a6d42ca264039732c6218e0
void visit_type_str(Visitor *v, char **obj, const char *name, Error **errp) { if (!error_is_set(errp)) { v->type_str(v, obj, name, errp); } }
{ "code": [ " if (!error_is_set(errp)) {", " if (!error_is_set(errp)) {", " if (!error_is_set(errp)) {", " if (!error_is_set(errp)) {", " if (!error_is_set(errp)) {", " if (!error_is_set(errp)) {", " if (!error_is_set(errp)) {", " if (!error_is_set(errp)) {", " if (!error_is_set(errp)) {", " if (!error_is_set(errp)) {", " if (!error_is_set(errp)) {", " if (!error_is_set(errp)) {", " if (!error_is_set(errp)) {", " if (!error_is_set(errp)) {", " if (!error_is_set(errp)) {", " if (!error_is_set(errp)) {", " v->type_str(v, obj, name, errp);", " if (!error_is_set(errp)) {", " if (!error_is_set(errp)) {", " if (!error_is_set(errp)) {", " if (!error_is_set(errp)) {", " if (!error_is_set(errp)) {" ], "line_no": [ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 5, 5, 5, 5, 5 ] }
void FUNC_0(Visitor *VAR_0, char **VAR_1, const char *VAR_2, Error **VAR_3) { if (!error_is_set(VAR_3)) { VAR_0->type_str(VAR_0, VAR_1, VAR_2, VAR_3); } }
[ "void FUNC_0(Visitor *VAR_0, char **VAR_1, const char *VAR_2, Error **VAR_3)\n{", "if (!error_is_set(VAR_3)) {", "VAR_0->type_str(VAR_0, VAR_1, VAR_2, VAR_3);", "}", "}" ]
[ 0, 1, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ] ]
685
static int http_send_data(HTTPContext *c) { int len, ret; while (c->buffer_ptr >= c->buffer_end) { ret = http_prepare_data(c); if (ret < 0) return -1; else if (ret == 0) { break; } else { /* state change requested */ return 0; } } if (c->buffer_end > c->buffer_ptr) { len = write(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr); if (len < 0) { if (errno != EAGAIN && errno != EINTR) { /* error : close connection */ return -1; } } else { c->buffer_ptr += len; c->data_count += len; } } return 0; }
true
FFmpeg
a6e14edde01bafbbe54f6f451efa718a48975b47
static int http_send_data(HTTPContext *c) { int len, ret; while (c->buffer_ptr >= c->buffer_end) { ret = http_prepare_data(c); if (ret < 0) return -1; else if (ret == 0) { break; } else { return 0; } } if (c->buffer_end > c->buffer_ptr) { len = write(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr); if (len < 0) { if (errno != EAGAIN && errno != EINTR) { return -1; } } else { c->buffer_ptr += len; c->data_count += len; } } return 0; }
{ "code": [ " break;", " break;", " break;" ], "line_no": [ 19, 19, 19 ] }
static int FUNC_0(HTTPContext *VAR_0) { int VAR_1, VAR_2; while (VAR_0->buffer_ptr >= VAR_0->buffer_end) { VAR_2 = http_prepare_data(VAR_0); if (VAR_2 < 0) return -1; else if (VAR_2 == 0) { break; } else { return 0; } } if (VAR_0->buffer_end > VAR_0->buffer_ptr) { VAR_1 = write(VAR_0->fd, VAR_0->buffer_ptr, VAR_0->buffer_end - VAR_0->buffer_ptr); if (VAR_1 < 0) { if (errno != EAGAIN && errno != EINTR) { return -1; } } else { VAR_0->buffer_ptr += VAR_1; VAR_0->data_count += VAR_1; } } return 0; }
[ "static int FUNC_0(HTTPContext *VAR_0)\n{", "int VAR_1, VAR_2;", "while (VAR_0->buffer_ptr >= VAR_0->buffer_end) {", "VAR_2 = http_prepare_data(VAR_0);", "if (VAR_2 < 0)\nreturn -1;", "else if (VAR_2 == 0) {", "break;", "} else {", "return 0;", "}", "}", "if (VAR_0->buffer_end > VAR_0->buffer_ptr) {", "VAR_1 = write(VAR_0->fd, VAR_0->buffer_ptr, VAR_0->buffer_end - VAR_0->buffer_ptr);", "if (VAR_1 < 0) {", "if (errno != EAGAIN && errno != EINTR) {", "return -1;", "}", "} else {", "VAR_0->buffer_ptr += VAR_1;", "VAR_0->data_count += VAR_1;", "}", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13, 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ] ]
687
static void m68060_cpu_initfn(Object *obj) { M68kCPU *cpu = M68K_CPU(obj); CPUM68KState *env = &cpu->env; m68k_set_feature(env, M68K_FEATURE_M68000); m68k_set_feature(env, M68K_FEATURE_USP); m68k_set_feature(env, M68K_FEATURE_WORD_INDEX); m68k_set_feature(env, M68K_FEATURE_BRAL); m68k_set_feature(env, M68K_FEATURE_BCCL); m68k_set_feature(env, M68K_FEATURE_BITFIELD); m68k_set_feature(env, M68K_FEATURE_EXT_FULL); m68k_set_feature(env, M68K_FEATURE_SCALED_INDEX); m68k_set_feature(env, M68K_FEATURE_LONG_MULDIV); m68k_set_feature(env, M68K_FEATURE_FPU); m68k_set_feature(env, M68K_FEATURE_CAS); m68k_set_feature(env, M68K_FEATURE_BKPT); m68k_set_feature(env, M68K_FEATURE_RTD); }
true
qemu
8bf6cbaf396a8b54b138bb8a7c3377f2868ed16e
static void m68060_cpu_initfn(Object *obj) { M68kCPU *cpu = M68K_CPU(obj); CPUM68KState *env = &cpu->env; m68k_set_feature(env, M68K_FEATURE_M68000); m68k_set_feature(env, M68K_FEATURE_USP); m68k_set_feature(env, M68K_FEATURE_WORD_INDEX); m68k_set_feature(env, M68K_FEATURE_BRAL); m68k_set_feature(env, M68K_FEATURE_BCCL); m68k_set_feature(env, M68K_FEATURE_BITFIELD); m68k_set_feature(env, M68K_FEATURE_EXT_FULL); m68k_set_feature(env, M68K_FEATURE_SCALED_INDEX); m68k_set_feature(env, M68K_FEATURE_LONG_MULDIV); m68k_set_feature(env, M68K_FEATURE_FPU); m68k_set_feature(env, M68K_FEATURE_CAS); m68k_set_feature(env, M68K_FEATURE_BKPT); m68k_set_feature(env, M68K_FEATURE_RTD); }
{ "code": [], "line_no": [] }
static void FUNC_0(Object *VAR_0) { M68kCPU *cpu = M68K_CPU(VAR_0); CPUM68KState *env = &cpu->env; m68k_set_feature(env, M68K_FEATURE_M68000); m68k_set_feature(env, M68K_FEATURE_USP); m68k_set_feature(env, M68K_FEATURE_WORD_INDEX); m68k_set_feature(env, M68K_FEATURE_BRAL); m68k_set_feature(env, M68K_FEATURE_BCCL); m68k_set_feature(env, M68K_FEATURE_BITFIELD); m68k_set_feature(env, M68K_FEATURE_EXT_FULL); m68k_set_feature(env, M68K_FEATURE_SCALED_INDEX); m68k_set_feature(env, M68K_FEATURE_LONG_MULDIV); m68k_set_feature(env, M68K_FEATURE_FPU); m68k_set_feature(env, M68K_FEATURE_CAS); m68k_set_feature(env, M68K_FEATURE_BKPT); m68k_set_feature(env, M68K_FEATURE_RTD); }
[ "static void FUNC_0(Object *VAR_0)\n{", "M68kCPU *cpu = M68K_CPU(VAR_0);", "CPUM68KState *env = &cpu->env;", "m68k_set_feature(env, M68K_FEATURE_M68000);", "m68k_set_feature(env, M68K_FEATURE_USP);", "m68k_set_feature(env, M68K_FEATURE_WORD_INDEX);", "m68k_set_feature(env, M68K_FEATURE_BRAL);", "m68k_set_feature(env, M68K_FEATURE_BCCL);", "m68k_set_feature(env, M68K_FEATURE_BITFIELD);", "m68k_set_feature(env, M68K_FEATURE_EXT_FULL);", "m68k_set_feature(env, M68K_FEATURE_SCALED_INDEX);", "m68k_set_feature(env, M68K_FEATURE_LONG_MULDIV);", "m68k_set_feature(env, M68K_FEATURE_FPU);", "m68k_set_feature(env, M68K_FEATURE_CAS);", "m68k_set_feature(env, M68K_FEATURE_BKPT);", "m68k_set_feature(env, M68K_FEATURE_RTD);", "}" ]
[ 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 ], [ 38 ] ]
688
void mips_r4k_init (ram_addr_t ram_size, int vga_ram_size, const char *boot_device, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { char buf[1024]; unsigned long bios_offset; int bios_size; CPUState *env; RTCState *rtc_state; int i; qemu_irq *i8259; int index; BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; /* init CPUs */ if (cpu_model == NULL) { #ifdef TARGET_MIPS64 cpu_model = "R4000"; #else cpu_model = "24Kf"; #endif env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find CPU definition\n"); qemu_register_reset(main_cpu_reset, env); /* allocate RAM */ cpu_register_physical_memory(0, ram_size, IO_MEM_RAM); if (!mips_qemu_iomemtype) { mips_qemu_iomemtype = cpu_register_io_memory(0, mips_qemu_read, mips_qemu_write, NULL); cpu_register_physical_memory(0x1fbf0000, 0x10000, mips_qemu_iomemtype); /* Try to load a BIOS image. If this fails, we continue regardless, but initialize the hardware ourselves. When a kernel gets preloaded we also initialize the hardware, since the BIOS wasn't run. */ bios_offset = ram_size + vga_ram_size; if (bios_name == NULL) bios_name = BIOS_FILENAME; snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); bios_size = load_image(buf, phys_ram_base + bios_offset); if ((bios_size > 0) && (bios_size <= BIOS_SIZE)) { cpu_register_physical_memory(0x1fc00000, BIOS_SIZE, bios_offset | IO_MEM_ROM); } else if ((index = drive_get_index(IF_PFLASH, 0, 0)) > -1) { uint32_t mips_rom = 0x00400000; cpu_register_physical_memory(0x1fc00000, mips_rom, qemu_ram_alloc(mips_rom) | IO_MEM_ROM); if (!pflash_cfi01_register(0x1fc00000, qemu_ram_alloc(mips_rom), drives_table[index].bdrv, sector_len, mips_rom / sector_len, 4, 0, 0, 0, 0)) { fprintf(stderr, "qemu: Error registering flash memory.\n"); else { /* not fatal */ fprintf(stderr, "qemu: Warning, could not load MIPS bios '%s'\n", buf); if (kernel_filename) { loaderparams.ram_size = ram_size; loaderparams.kernel_filename = kernel_filename; loaderparams.kernel_cmdline = kernel_cmdline; loaderparams.initrd_filename = initrd_filename; load_kernel (env); /* Init CPU internal devices */ cpu_mips_irq_init_cpu(env); cpu_mips_clock_init(env); /* The PIC is attached to the MIPS CPU INT0 pin */ i8259 = i8259_init(env->irq[2]); rtc_state = rtc_init(0x70, i8259[8]); /* Register 64 KB of ISA IO space at 0x14000000 */ isa_mmio_init(0x14000000, 0x00010000); isa_mem_base = 0x10000000; pit = pit_init(0x40, i8259[0]); for(i = 0; i < MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { serial_init(serial_io[i], i8259[serial_irq[i]], 115200, serial_hds[i]); isa_vga_init(phys_ram_base + ram_size, ram_size, vga_ram_size); if (nd_table[0].vlan) isa_ne2000_init(0x300, i8259[9], &nd_table[0]); if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) { fprintf(stderr, "qemu: too many IDE bus\n"); for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { index = drive_get_index(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); if (index != -1) hd[i] = drives_table[index].bdrv; else hd[i] = NULL; for(i = 0; i < MAX_IDE_BUS; i++) isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]], hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]); i8042_init(i8259[1], i8259[12], 0x60);
true
qemu
0ccff151b42a5b684ce22473b68972a94bc708fb
void mips_r4k_init (ram_addr_t ram_size, int vga_ram_size, const char *boot_device, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { char buf[1024]; unsigned long bios_offset; int bios_size; CPUState *env; RTCState *rtc_state; int i; qemu_irq *i8259; int index; BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; if (cpu_model == NULL) { #ifdef TARGET_MIPS64 cpu_model = "R4000"; #else cpu_model = "24Kf"; #endif env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find CPU definition\n"); qemu_register_reset(main_cpu_reset, env); cpu_register_physical_memory(0, ram_size, IO_MEM_RAM); if (!mips_qemu_iomemtype) { mips_qemu_iomemtype = cpu_register_io_memory(0, mips_qemu_read, mips_qemu_write, NULL); cpu_register_physical_memory(0x1fbf0000, 0x10000, mips_qemu_iomemtype); bios_offset = ram_size + vga_ram_size; if (bios_name == NULL) bios_name = BIOS_FILENAME; snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); bios_size = load_image(buf, phys_ram_base + bios_offset); if ((bios_size > 0) && (bios_size <= BIOS_SIZE)) { cpu_register_physical_memory(0x1fc00000, BIOS_SIZE, bios_offset | IO_MEM_ROM); } else if ((index = drive_get_index(IF_PFLASH, 0, 0)) > -1) { uint32_t mips_rom = 0x00400000; cpu_register_physical_memory(0x1fc00000, mips_rom, qemu_ram_alloc(mips_rom) | IO_MEM_ROM); if (!pflash_cfi01_register(0x1fc00000, qemu_ram_alloc(mips_rom), drives_table[index].bdrv, sector_len, mips_rom / sector_len, 4, 0, 0, 0, 0)) { fprintf(stderr, "qemu: Error registering flash memory.\n"); else { fprintf(stderr, "qemu: Warning, could not load MIPS bios '%s'\n", buf); if (kernel_filename) { loaderparams.ram_size = ram_size; loaderparams.kernel_filename = kernel_filename; loaderparams.kernel_cmdline = kernel_cmdline; loaderparams.initrd_filename = initrd_filename; load_kernel (env); cpu_mips_irq_init_cpu(env); cpu_mips_clock_init(env); i8259 = i8259_init(env->irq[2]); rtc_state = rtc_init(0x70, i8259[8]); isa_mmio_init(0x14000000, 0x00010000); isa_mem_base = 0x10000000; pit = pit_init(0x40, i8259[0]); for(i = 0; i < MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { serial_init(serial_io[i], i8259[serial_irq[i]], 115200, serial_hds[i]); isa_vga_init(phys_ram_base + ram_size, ram_size, vga_ram_size); if (nd_table[0].vlan) isa_ne2000_init(0x300, i8259[9], &nd_table[0]); if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) { fprintf(stderr, "qemu: too many IDE bus\n"); for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { index = drive_get_index(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); if (index != -1) hd[i] = drives_table[index].bdrv; else hd[i] = NULL; for(i = 0; i < MAX_IDE_BUS; i++) isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]], hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]); i8042_init(i8259[1], i8259[12], 0x60);
{ "code": [], "line_no": [] }
void FUNC_0 (ram_addr_t VAR_0, int VAR_1, const char *VAR_2, const char *VAR_3, const char *VAR_4, const char *VAR_5, const char *VAR_6) { char VAR_7[1024]; unsigned long VAR_8; int VAR_9; CPUState *env; RTCState *rtc_state; int VAR_10; qemu_irq *i8259; int VAR_11; BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; if (VAR_6 == NULL) { #ifdef TARGET_MIPS64 VAR_6 = "R4000"; #else VAR_6 = "24Kf"; #endif env = cpu_init(VAR_6); if (!env) { fprintf(stderr, "Unable to find CPU definition\n"); qemu_register_reset(main_cpu_reset, env); cpu_register_physical_memory(0, VAR_0, IO_MEM_RAM); if (!mips_qemu_iomemtype) { mips_qemu_iomemtype = cpu_register_io_memory(0, mips_qemu_read, mips_qemu_write, NULL); cpu_register_physical_memory(0x1fbf0000, 0x10000, mips_qemu_iomemtype); VAR_8 = VAR_0 + VAR_1; if (bios_name == NULL) bios_name = BIOS_FILENAME; snprintf(VAR_7, sizeof(VAR_7), "%s/%s", bios_dir, bios_name); VAR_9 = load_image(VAR_7, phys_ram_base + VAR_8); if ((VAR_9 > 0) && (VAR_9 <= BIOS_SIZE)) { cpu_register_physical_memory(0x1fc00000, BIOS_SIZE, VAR_8 | IO_MEM_ROM); } else if ((VAR_11 = drive_get_index(IF_PFLASH, 0, 0)) > -1) { uint32_t mips_rom = 0x00400000; cpu_register_physical_memory(0x1fc00000, mips_rom, qemu_ram_alloc(mips_rom) | IO_MEM_ROM); if (!pflash_cfi01_register(0x1fc00000, qemu_ram_alloc(mips_rom), drives_table[VAR_11].bdrv, sector_len, mips_rom / sector_len, 4, 0, 0, 0, 0)) { fprintf(stderr, "qemu: Error registering flash memory.\n"); else { fprintf(stderr, "qemu: Warning, could not load MIPS bios '%s'\n", VAR_7); if (VAR_3) { loaderparams.VAR_0 = VAR_0; loaderparams.VAR_3 = VAR_3; loaderparams.VAR_4 = VAR_4; loaderparams.VAR_5 = VAR_5; load_kernel (env); cpu_mips_irq_init_cpu(env); cpu_mips_clock_init(env); i8259 = i8259_init(env->irq[2]); rtc_state = rtc_init(0x70, i8259[8]); isa_mmio_init(0x14000000, 0x00010000); isa_mem_base = 0x10000000; pit = pit_init(0x40, i8259[0]); for(VAR_10 = 0; VAR_10 < MAX_SERIAL_PORTS; VAR_10++) { if (serial_hds[VAR_10]) { serial_init(serial_io[VAR_10], i8259[serial_irq[VAR_10]], 115200, serial_hds[VAR_10]); isa_vga_init(phys_ram_base + VAR_0, VAR_0, VAR_1); if (nd_table[0].vlan) isa_ne2000_init(0x300, i8259[9], &nd_table[0]); if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) { fprintf(stderr, "qemu: too many IDE bus\n"); for(VAR_10 = 0; VAR_10 < MAX_IDE_BUS * MAX_IDE_DEVS; VAR_10++) { VAR_11 = drive_get_index(IF_IDE, VAR_10 / MAX_IDE_DEVS, VAR_10 % MAX_IDE_DEVS); if (VAR_11 != -1) hd[VAR_10] = drives_table[VAR_11].bdrv; else hd[VAR_10] = NULL; for(VAR_10 = 0; VAR_10 < MAX_IDE_BUS; VAR_10++) isa_ide_init(ide_iobase[VAR_10], ide_iobase2[VAR_10], i8259[ide_irq[VAR_10]], hd[MAX_IDE_DEVS * VAR_10], hd[MAX_IDE_DEVS * VAR_10 + 1]); i8042_init(i8259[1], i8259[12], 0x60);
[ "void FUNC_0 (ram_addr_t VAR_0, int VAR_1,\nconst char *VAR_2,\nconst char *VAR_3, const char *VAR_4,\nconst char *VAR_5, const char *VAR_6)\n{", "char VAR_7[1024];", "unsigned long VAR_8;", "int VAR_9;", "CPUState *env;", "RTCState *rtc_state;", "int VAR_10;", "qemu_irq *i8259;", "int VAR_11;", "BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];", "if (VAR_6 == NULL) {", "#ifdef TARGET_MIPS64\nVAR_6 = \"R4000\";", "#else\nVAR_6 = \"24Kf\";", "#endif\nenv = cpu_init(VAR_6);", "if (!env) {", "fprintf(stderr, \"Unable to find CPU definition\\n\");", "qemu_register_reset(main_cpu_reset, env);", "cpu_register_physical_memory(0, VAR_0, IO_MEM_RAM);", "if (!mips_qemu_iomemtype) {", "mips_qemu_iomemtype = cpu_register_io_memory(0, mips_qemu_read,\nmips_qemu_write, NULL);", "cpu_register_physical_memory(0x1fbf0000, 0x10000, mips_qemu_iomemtype);", "VAR_8 = VAR_0 + VAR_1;", "if (bios_name == NULL)\nbios_name = BIOS_FILENAME;", "snprintf(VAR_7, sizeof(VAR_7), \"%s/%s\", bios_dir, bios_name);", "VAR_9 = load_image(VAR_7, phys_ram_base + VAR_8);", "if ((VAR_9 > 0) && (VAR_9 <= BIOS_SIZE)) {", "cpu_register_physical_memory(0x1fc00000,\nBIOS_SIZE, VAR_8 | IO_MEM_ROM);", "} else if ((VAR_11 = drive_get_index(IF_PFLASH, 0, 0)) > -1) {", "uint32_t mips_rom = 0x00400000;", "cpu_register_physical_memory(0x1fc00000, mips_rom,\nqemu_ram_alloc(mips_rom) | IO_MEM_ROM);", "if (!pflash_cfi01_register(0x1fc00000, qemu_ram_alloc(mips_rom),\ndrives_table[VAR_11].bdrv, sector_len, mips_rom / sector_len,\n4, 0, 0, 0, 0)) {", "fprintf(stderr, \"qemu: Error registering flash memory.\\n\");", "else {", "fprintf(stderr, \"qemu: Warning, could not load MIPS bios '%s'\\n\",\nVAR_7);", "if (VAR_3) {", "loaderparams.VAR_0 = VAR_0;", "loaderparams.VAR_3 = VAR_3;", "loaderparams.VAR_4 = VAR_4;", "loaderparams.VAR_5 = VAR_5;", "load_kernel (env);", "cpu_mips_irq_init_cpu(env);", "cpu_mips_clock_init(env);", "i8259 = i8259_init(env->irq[2]);", "rtc_state = rtc_init(0x70, i8259[8]);", "isa_mmio_init(0x14000000, 0x00010000);", "isa_mem_base = 0x10000000;", "pit = pit_init(0x40, i8259[0]);", "for(VAR_10 = 0; VAR_10 < MAX_SERIAL_PORTS; VAR_10++) {", "if (serial_hds[VAR_10]) {", "serial_init(serial_io[VAR_10], i8259[serial_irq[VAR_10]], 115200,\nserial_hds[VAR_10]);", "isa_vga_init(phys_ram_base + VAR_0, VAR_0,\nVAR_1);", "if (nd_table[0].vlan)\nisa_ne2000_init(0x300, i8259[9], &nd_table[0]);", "if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {", "fprintf(stderr, \"qemu: too many IDE bus\\n\");", "for(VAR_10 = 0; VAR_10 < MAX_IDE_BUS * MAX_IDE_DEVS; VAR_10++) {", "VAR_11 = drive_get_index(IF_IDE, VAR_10 / MAX_IDE_DEVS, VAR_10 % MAX_IDE_DEVS);", "if (VAR_11 != -1)\nhd[VAR_10] = drives_table[VAR_11].bdrv;", "else\nhd[VAR_10] = NULL;", "for(VAR_10 = 0; VAR_10 < MAX_IDE_BUS; VAR_10++)", "isa_ide_init(ide_iobase[VAR_10], ide_iobase2[VAR_10], i8259[ide_irq[VAR_10]],\nhd[MAX_IDE_DEVS * VAR_10],\nhd[MAX_IDE_DEVS * VAR_10 + 1]);", "i8042_init(i8259[1], i8259[12], 0x60);" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 33 ], [ 35, 37 ], [ 39, 41 ], [ 43, 46 ], [ 48 ], [ 50 ], [ 54 ], [ 66 ], [ 70 ], [ 72, 74 ], [ 77 ], [ 89 ], [ 91, 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101, 103 ], [ 105 ], [ 107 ], [ 109, 111 ], [ 113, 115, 117 ], [ 119 ], [ 123 ], [ 127, 129 ], [ 134 ], [ 136 ], [ 138 ], [ 140 ], [ 142 ], [ 144 ], [ 151 ], [ 153 ], [ 159 ], [ 163 ], [ 169 ], [ 171 ], [ 175 ], [ 179 ], [ 181 ], [ 183, 185 ], [ 191, 193 ], [ 197, 199 ], [ 203 ], [ 205 ], [ 211 ], [ 213 ], [ 215, 217 ], [ 219, 221 ], [ 226 ], [ 228, 230, 232 ], [ 236 ] ]
689
static void windowing_and_mdct_ltp(AACContext *ac, float *out, float *in, IndividualChannelStream *ics) { const float *lwindow = ics->use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024; const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024; const float *swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128; if (ics->window_sequence[0] != LONG_STOP_SEQUENCE) { ac->dsp.vector_fmul(in, in, lwindow_prev, 1024); } else { memset(in, 0, 448 * sizeof(float)); ac->dsp.vector_fmul(in + 448, in + 448, swindow_prev, 128); memcpy(in + 576, in + 576, 448 * sizeof(float)); } if (ics->window_sequence[0] != LONG_START_SEQUENCE) { ac->dsp.vector_fmul_reverse(in + 1024, in + 1024, lwindow, 1024); } else { memcpy(in + 1024, in + 1024, 448 * sizeof(float)); ac->dsp.vector_fmul_reverse(in + 1024 + 448, in + 1024 + 448, swindow, 128); memset(in + 1024 + 576, 0, 448 * sizeof(float)); } ac->mdct_ltp.mdct_calc(&ac->mdct_ltp, out, in); }
true
FFmpeg
a6c49f18abacb9bf52d4d808a2a56561a5b5445c
static void windowing_and_mdct_ltp(AACContext *ac, float *out, float *in, IndividualChannelStream *ics) { const float *lwindow = ics->use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024; const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024; const float *swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128; if (ics->window_sequence[0] != LONG_STOP_SEQUENCE) { ac->dsp.vector_fmul(in, in, lwindow_prev, 1024); } else { memset(in, 0, 448 * sizeof(float)); ac->dsp.vector_fmul(in + 448, in + 448, swindow_prev, 128); memcpy(in + 576, in + 576, 448 * sizeof(float)); } if (ics->window_sequence[0] != LONG_START_SEQUENCE) { ac->dsp.vector_fmul_reverse(in + 1024, in + 1024, lwindow, 1024); } else { memcpy(in + 1024, in + 1024, 448 * sizeof(float)); ac->dsp.vector_fmul_reverse(in + 1024 + 448, in + 1024 + 448, swindow, 128); memset(in + 1024 + 576, 0, 448 * sizeof(float)); } ac->mdct_ltp.mdct_calc(&ac->mdct_ltp, out, in); }
{ "code": [ " memcpy(in + 576, in + 576, 448 * sizeof(float));", " memcpy(in + 1024, in + 1024, 448 * sizeof(float));" ], "line_no": [ 27, 37 ] }
static void FUNC_0(AACContext *VAR_0, float *VAR_1, float *VAR_2, IndividualChannelStream *VAR_3) { const float *VAR_4 = VAR_3->use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024; const float *VAR_5 = VAR_3->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; const float *VAR_6 = VAR_3->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024; const float *VAR_7 = VAR_3->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128; if (VAR_3->window_sequence[0] != LONG_STOP_SEQUENCE) { VAR_0->dsp.vector_fmul(VAR_2, VAR_2, VAR_6, 1024); } else { memset(VAR_2, 0, 448 * sizeof(float)); VAR_0->dsp.vector_fmul(VAR_2 + 448, VAR_2 + 448, VAR_7, 128); memcpy(VAR_2 + 576, VAR_2 + 576, 448 * sizeof(float)); } if (VAR_3->window_sequence[0] != LONG_START_SEQUENCE) { VAR_0->dsp.vector_fmul_reverse(VAR_2 + 1024, VAR_2 + 1024, VAR_4, 1024); } else { memcpy(VAR_2 + 1024, VAR_2 + 1024, 448 * sizeof(float)); VAR_0->dsp.vector_fmul_reverse(VAR_2 + 1024 + 448, VAR_2 + 1024 + 448, VAR_5, 128); memset(VAR_2 + 1024 + 576, 0, 448 * sizeof(float)); } VAR_0->mdct_ltp.mdct_calc(&VAR_0->mdct_ltp, VAR_1, VAR_2); }
[ "static void FUNC_0(AACContext *VAR_0, float *VAR_1,\nfloat *VAR_2, IndividualChannelStream *VAR_3)\n{", "const float *VAR_4 = VAR_3->use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024;", "const float *VAR_5 = VAR_3->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128;", "const float *VAR_6 = VAR_3->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024;", "const float *VAR_7 = VAR_3->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128;", "if (VAR_3->window_sequence[0] != LONG_STOP_SEQUENCE) {", "VAR_0->dsp.vector_fmul(VAR_2, VAR_2, VAR_6, 1024);", "} else {", "memset(VAR_2, 0, 448 * sizeof(float));", "VAR_0->dsp.vector_fmul(VAR_2 + 448, VAR_2 + 448, VAR_7, 128);", "memcpy(VAR_2 + 576, VAR_2 + 576, 448 * sizeof(float));", "}", "if (VAR_3->window_sequence[0] != LONG_START_SEQUENCE) {", "VAR_0->dsp.vector_fmul_reverse(VAR_2 + 1024, VAR_2 + 1024, VAR_4, 1024);", "} else {", "memcpy(VAR_2 + 1024, VAR_2 + 1024, 448 * sizeof(float));", "VAR_0->dsp.vector_fmul_reverse(VAR_2 + 1024 + 448, VAR_2 + 1024 + 448, VAR_5, 128);", "memset(VAR_2 + 1024 + 576, 0, 448 * sizeof(float));", "}", "VAR_0->mdct_ltp.mdct_calc(&VAR_0->mdct_ltp, VAR_1, VAR_2);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ] ]
690
static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; MOVStreamContext *sc; int ret; st = avformat_new_stream(c->fc, NULL); if (!st) return AVERROR(ENOMEM); st->id = c->fc->nb_streams; sc = av_mallocz(sizeof(MOVStreamContext)); if (!sc) return AVERROR(ENOMEM); st->priv_data = sc; st->codec->codec_type = AVMEDIA_TYPE_DATA; sc->ffindex = st->index; c->trak_index = st->index; if ((ret = mov_read_default(c, pb, atom)) < 0) return ret; c->trak_index = -1; /* sanity checks */ if (sc->chunk_count && (!sc->stts_count || !sc->stsc_count || (!sc->sample_size && !sc->sample_count))) { av_log(c->fc, AV_LOG_ERROR, "stream %d, missing mandatory atoms, broken header\n", st->index); return 0; } fix_timescale(c, sc); avpriv_set_pts_info(st, 64, 1, sc->time_scale); mov_build_index(c, st); if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) { MOVDref *dref = &sc->drefs[sc->dref_id - 1]; if (mov_open_dref(c, &sc->pb, c->fc->filename, dref, &c->fc->interrupt_callback) < 0) av_log(c->fc, AV_LOG_ERROR, "stream %d, error opening alias: path='%s', dir='%s', " "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\n", st->index, dref->path, dref->dir, dref->filename, dref->volume, dref->nlvl_from, dref->nlvl_to); } else { sc->pb = c->fc->pb; sc->pb_is_copied = 1; } if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (!st->sample_aspect_ratio.num && st->codec->width && st->codec->height && sc->height && sc->width && (st->codec->width != sc->width || st->codec->height != sc->height)) { st->sample_aspect_ratio = av_d2q(((double)st->codec->height * sc->width) / ((double)st->codec->width * sc->height), INT_MAX); } #if FF_API_R_FRAME_RATE if (sc->stts_count == 1 || (sc->stts_count == 2 && sc->stts_data[1].count == 1)) av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, sc->time_scale, sc->stts_data[0].duration, INT_MAX); #endif } // done for ai5q, ai52, ai55, ai1q, ai12 and ai15. if (!st->codec->extradata_size && st->codec->codec_id == AV_CODEC_ID_H264 && TAG_IS_AVCI(st->codec->codec_tag)) { ret = ff_generate_avci_extradata(st); if (ret < 0) return ret; } switch (st->codec->codec_id) { #if CONFIG_H261_DECODER case AV_CODEC_ID_H261: #endif #if CONFIG_H263_DECODER case AV_CODEC_ID_H263: #endif #if CONFIG_MPEG4_DECODER case AV_CODEC_ID_MPEG4: #endif st->codec->width = 0; /* let decoder init width/height */ st->codec->height= 0; break; } // If the duration of the mp3 packets is not constant, then they could need a parser if (st->codec->codec_id == AV_CODEC_ID_MP3 && sc->stts_count > 3 && sc->stts_count*10 > st->nb_frames && sc->time_scale == st->codec->sample_rate) { st->need_parsing = AVSTREAM_PARSE_FULL; } /* Do not need those anymore. */ av_freep(&sc->chunk_offsets); av_freep(&sc->stsc_data); av_freep(&sc->sample_sizes); av_freep(&sc->keyframes); av_freep(&sc->stts_data); av_freep(&sc->stps_data); av_freep(&sc->elst_data); av_freep(&sc->rap_group); return 0; }
false
FFmpeg
712d962a6a29b1099cd872cfb07867175a93ac4c
static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; MOVStreamContext *sc; int ret; st = avformat_new_stream(c->fc, NULL); if (!st) return AVERROR(ENOMEM); st->id = c->fc->nb_streams; sc = av_mallocz(sizeof(MOVStreamContext)); if (!sc) return AVERROR(ENOMEM); st->priv_data = sc; st->codec->codec_type = AVMEDIA_TYPE_DATA; sc->ffindex = st->index; c->trak_index = st->index; if ((ret = mov_read_default(c, pb, atom)) < 0) return ret; c->trak_index = -1; if (sc->chunk_count && (!sc->stts_count || !sc->stsc_count || (!sc->sample_size && !sc->sample_count))) { av_log(c->fc, AV_LOG_ERROR, "stream %d, missing mandatory atoms, broken header\n", st->index); return 0; } fix_timescale(c, sc); avpriv_set_pts_info(st, 64, 1, sc->time_scale); mov_build_index(c, st); if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) { MOVDref *dref = &sc->drefs[sc->dref_id - 1]; if (mov_open_dref(c, &sc->pb, c->fc->filename, dref, &c->fc->interrupt_callback) < 0) av_log(c->fc, AV_LOG_ERROR, "stream %d, error opening alias: path='%s', dir='%s', " "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\n", st->index, dref->path, dref->dir, dref->filename, dref->volume, dref->nlvl_from, dref->nlvl_to); } else { sc->pb = c->fc->pb; sc->pb_is_copied = 1; } if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (!st->sample_aspect_ratio.num && st->codec->width && st->codec->height && sc->height && sc->width && (st->codec->width != sc->width || st->codec->height != sc->height)) { st->sample_aspect_ratio = av_d2q(((double)st->codec->height * sc->width) / ((double)st->codec->width * sc->height), INT_MAX); } #if FF_API_R_FRAME_RATE if (sc->stts_count == 1 || (sc->stts_count == 2 && sc->stts_data[1].count == 1)) av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, sc->time_scale, sc->stts_data[0].duration, INT_MAX); #endif } if (!st->codec->extradata_size && st->codec->codec_id == AV_CODEC_ID_H264 && TAG_IS_AVCI(st->codec->codec_tag)) { ret = ff_generate_avci_extradata(st); if (ret < 0) return ret; } switch (st->codec->codec_id) { #if CONFIG_H261_DECODER case AV_CODEC_ID_H261: #endif #if CONFIG_H263_DECODER case AV_CODEC_ID_H263: #endif #if CONFIG_MPEG4_DECODER case AV_CODEC_ID_MPEG4: #endif st->codec->width = 0; st->codec->height= 0; break; } if (st->codec->codec_id == AV_CODEC_ID_MP3 && sc->stts_count > 3 && sc->stts_count*10 > st->nb_frames && sc->time_scale == st->codec->sample_rate) { st->need_parsing = AVSTREAM_PARSE_FULL; } av_freep(&sc->chunk_offsets); av_freep(&sc->stsc_data); av_freep(&sc->sample_sizes); av_freep(&sc->keyframes); av_freep(&sc->stts_data); av_freep(&sc->stps_data); av_freep(&sc->elst_data); av_freep(&sc->rap_group); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2) { AVStream *st; MOVStreamContext *sc; int VAR_3; st = avformat_new_stream(VAR_0->fc, NULL); if (!st) return AVERROR(ENOMEM); st->id = VAR_0->fc->nb_streams; sc = av_mallocz(sizeof(MOVStreamContext)); if (!sc) return AVERROR(ENOMEM); st->priv_data = sc; st->codec->codec_type = AVMEDIA_TYPE_DATA; sc->ffindex = st->index; VAR_0->trak_index = st->index; if ((VAR_3 = mov_read_default(VAR_0, VAR_1, VAR_2)) < 0) return VAR_3; VAR_0->trak_index = -1; if (sc->chunk_count && (!sc->stts_count || !sc->stsc_count || (!sc->sample_size && !sc->sample_count))) { av_log(VAR_0->fc, AV_LOG_ERROR, "stream %d, missing mandatory atoms, broken header\n", st->index); return 0; } fix_timescale(VAR_0, sc); avpriv_set_pts_info(st, 64, 1, sc->time_scale); mov_build_index(VAR_0, st); if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) { MOVDref *dref = &sc->drefs[sc->dref_id - 1]; if (mov_open_dref(VAR_0, &sc->VAR_1, VAR_0->fc->filename, dref, &VAR_0->fc->interrupt_callback) < 0) av_log(VAR_0->fc, AV_LOG_ERROR, "stream %d, error opening alias: path='%s', dir='%s', " "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\n", st->index, dref->path, dref->dir, dref->filename, dref->volume, dref->nlvl_from, dref->nlvl_to); } else { sc->VAR_1 = VAR_0->fc->VAR_1; sc->pb_is_copied = 1; } if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (!st->sample_aspect_ratio.num && st->codec->width && st->codec->height && sc->height && sc->width && (st->codec->width != sc->width || st->codec->height != sc->height)) { st->sample_aspect_ratio = av_d2q(((double)st->codec->height * sc->width) / ((double)st->codec->width * sc->height), INT_MAX); } #if FF_API_R_FRAME_RATE if (sc->stts_count == 1 || (sc->stts_count == 2 && sc->stts_data[1].count == 1)) av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, sc->time_scale, sc->stts_data[0].duration, INT_MAX); #endif } if (!st->codec->extradata_size && st->codec->codec_id == AV_CODEC_ID_H264 && TAG_IS_AVCI(st->codec->codec_tag)) { VAR_3 = ff_generate_avci_extradata(st); if (VAR_3 < 0) return VAR_3; } switch (st->codec->codec_id) { #if CONFIG_H261_DECODER case AV_CODEC_ID_H261: #endif #if CONFIG_H263_DECODER case AV_CODEC_ID_H263: #endif #if CONFIG_MPEG4_DECODER case AV_CODEC_ID_MPEG4: #endif st->codec->width = 0; st->codec->height= 0; break; } if (st->codec->codec_id == AV_CODEC_ID_MP3 && sc->stts_count > 3 && sc->stts_count*10 > st->nb_frames && sc->time_scale == st->codec->sample_rate) { st->need_parsing = AVSTREAM_PARSE_FULL; } av_freep(&sc->chunk_offsets); av_freep(&sc->stsc_data); av_freep(&sc->sample_sizes); av_freep(&sc->keyframes); av_freep(&sc->stts_data); av_freep(&sc->stps_data); av_freep(&sc->elst_data); av_freep(&sc->rap_group); return 0; }
[ "static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2)\n{", "AVStream *st;", "MOVStreamContext *sc;", "int VAR_3;", "st = avformat_new_stream(VAR_0->fc, NULL);", "if (!st) return AVERROR(ENOMEM);", "st->id = VAR_0->fc->nb_streams;", "sc = av_mallocz(sizeof(MOVStreamContext));", "if (!sc) return AVERROR(ENOMEM);", "st->priv_data = sc;", "st->codec->codec_type = AVMEDIA_TYPE_DATA;", "sc->ffindex = st->index;", "VAR_0->trak_index = st->index;", "if ((VAR_3 = mov_read_default(VAR_0, VAR_1, VAR_2)) < 0)\nreturn VAR_3;", "VAR_0->trak_index = -1;", "if (sc->chunk_count && (!sc->stts_count || !sc->stsc_count ||\n(!sc->sample_size && !sc->sample_count))) {", "av_log(VAR_0->fc, AV_LOG_ERROR, \"stream %d, missing mandatory atoms, broken header\\n\",\nst->index);", "return 0;", "}", "fix_timescale(VAR_0, sc);", "avpriv_set_pts_info(st, 64, 1, sc->time_scale);", "mov_build_index(VAR_0, st);", "if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) {", "MOVDref *dref = &sc->drefs[sc->dref_id - 1];", "if (mov_open_dref(VAR_0, &sc->VAR_1, VAR_0->fc->filename, dref,\n&VAR_0->fc->interrupt_callback) < 0)\nav_log(VAR_0->fc, AV_LOG_ERROR,\n\"stream %d, error opening alias: path='%s', dir='%s', \"\n\"filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\\n\",\nst->index, dref->path, dref->dir, dref->filename,\ndref->volume, dref->nlvl_from, dref->nlvl_to);", "} else {", "sc->VAR_1 = VAR_0->fc->VAR_1;", "sc->pb_is_copied = 1;", "}", "if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {", "if (!st->sample_aspect_ratio.num && st->codec->width && st->codec->height &&\nsc->height && sc->width &&\n(st->codec->width != sc->width || st->codec->height != sc->height)) {", "st->sample_aspect_ratio = av_d2q(((double)st->codec->height * sc->width) /\n((double)st->codec->width * sc->height), INT_MAX);", "}", "#if FF_API_R_FRAME_RATE\nif (sc->stts_count == 1 || (sc->stts_count == 2 && sc->stts_data[1].count == 1))\nav_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den,\nsc->time_scale, sc->stts_data[0].duration, INT_MAX);", "#endif\n}", "if (!st->codec->extradata_size && st->codec->codec_id == AV_CODEC_ID_H264 &&\nTAG_IS_AVCI(st->codec->codec_tag)) {", "VAR_3 = ff_generate_avci_extradata(st);", "if (VAR_3 < 0)\nreturn VAR_3;", "}", "switch (st->codec->codec_id) {", "#if CONFIG_H261_DECODER\ncase AV_CODEC_ID_H261:\n#endif\n#if CONFIG_H263_DECODER\ncase AV_CODEC_ID_H263:\n#endif\n#if CONFIG_MPEG4_DECODER\ncase AV_CODEC_ID_MPEG4:\n#endif\nst->codec->width = 0;", "st->codec->height= 0;", "break;", "}", "if (st->codec->codec_id == AV_CODEC_ID_MP3\n&& sc->stts_count > 3\n&& sc->stts_count*10 > st->nb_frames\n&& sc->time_scale == st->codec->sample_rate) {", "st->need_parsing = AVSTREAM_PARSE_FULL;", "}", "av_freep(&sc->chunk_offsets);", "av_freep(&sc->stsc_data);", "av_freep(&sc->sample_sizes);", "av_freep(&sc->keyframes);", "av_freep(&sc->stts_data);", "av_freep(&sc->stps_data);", "av_freep(&sc->elst_data);", "av_freep(&sc->rap_group);", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35, 37 ], [ 41 ], [ 47, 49 ], [ 51, 53 ], [ 55 ], [ 57 ], [ 61 ], [ 65 ], [ 69 ], [ 73 ], [ 75 ], [ 77, 79, 81, 83, 85, 87, 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 101 ], [ 103, 105, 107 ], [ 109, 111 ], [ 113 ], [ 117, 119, 121, 123 ], [ 125, 127 ], [ 133, 135 ], [ 137 ], [ 139, 141 ], [ 143 ], [ 147 ], [ 149, 151, 153, 155, 157, 159, 161, 163, 165, 167 ], [ 169 ], [ 171 ], [ 173 ], [ 179, 181, 183, 185 ], [ 187 ], [ 189 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 211 ], [ 213 ] ]
692
static int mxg_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret; unsigned int size; uint8_t *startmarker_ptr, *end, *search_end, marker; MXGContext *mxg = s->priv_data; while (!avio_feof(s->pb) && !s->pb->error){ if (mxg->cache_size <= OVERREAD_SIZE) { /* update internal buffer */ ret = mxg_update_cache(s, DEFAULT_PACKET_SIZE + OVERREAD_SIZE); if (ret < 0) return ret; } end = mxg->buffer_ptr + mxg->cache_size; /* find start marker - 0xff */ if (mxg->cache_size > OVERREAD_SIZE) { search_end = end - OVERREAD_SIZE; startmarker_ptr = mxg_find_startmarker(mxg->buffer_ptr, search_end); } else { search_end = end; startmarker_ptr = mxg_find_startmarker(mxg->buffer_ptr, search_end); if (startmarker_ptr >= search_end - 1 || *(startmarker_ptr + 1) != EOI) break; } if (startmarker_ptr != search_end) { /* start marker found */ marker = *(startmarker_ptr + 1); mxg->buffer_ptr = startmarker_ptr + 2; mxg->cache_size = end - mxg->buffer_ptr; if (marker == SOI) { mxg->soi_ptr = startmarker_ptr; } else if (marker == EOI) { if (!mxg->soi_ptr) { av_log(s, AV_LOG_WARNING, "Found EOI before SOI, skipping\n"); continue; } pkt->pts = pkt->dts = mxg->dts; pkt->stream_index = 0; #if FF_API_DESTRUCT_PACKET FF_DISABLE_DEPRECATION_WARNINGS pkt->destruct = NULL; FF_ENABLE_DEPRECATION_WARNINGS #endif pkt->buf = NULL; pkt->size = mxg->buffer_ptr - mxg->soi_ptr; pkt->data = mxg->soi_ptr; if (mxg->soi_ptr - mxg->buffer > mxg->cache_size) { if (mxg->cache_size > 0) { memcpy(mxg->buffer, mxg->buffer_ptr, mxg->cache_size); } mxg->buffer_ptr = mxg->buffer; } mxg->soi_ptr = 0; return pkt->size; } else if ( (SOF0 <= marker && marker <= SOF15) || (SOS <= marker && marker <= COM) ) { /* all other markers that start marker segment also contain length value (see specification for JPEG Annex B.1) */ size = AV_RB16(mxg->buffer_ptr); if (size < 2) return AVERROR(EINVAL); if (mxg->cache_size < size) { ret = mxg_update_cache(s, size); if (ret < 0) return ret; startmarker_ptr = mxg->buffer_ptr - 2; mxg->cache_size = 0; } else { mxg->cache_size -= size; } mxg->buffer_ptr += size; if (marker == APP13 && size >= 16) { /* audio data */ /* time (GMT) of first sample in usec since 1970, little-endian */ pkt->pts = pkt->dts = AV_RL64(startmarker_ptr + 8); pkt->stream_index = 1; #if FF_API_DESTRUCT_PACKET FF_DISABLE_DEPRECATION_WARNINGS pkt->destruct = NULL; FF_ENABLE_DEPRECATION_WARNINGS #endif pkt->buf = NULL; pkt->size = size - 14; pkt->data = startmarker_ptr + 16; if (startmarker_ptr - mxg->buffer > mxg->cache_size) { if (mxg->cache_size > 0) { memcpy(mxg->buffer, mxg->buffer_ptr, mxg->cache_size); } mxg->buffer_ptr = mxg->buffer; } return pkt->size; } else if (marker == COM && size >= 18 && !strncmp(startmarker_ptr + 4, "MXF", 3)) { /* time (GMT) of video frame in usec since 1970, little-endian */ mxg->dts = AV_RL64(startmarker_ptr + 12); } } } else { /* start marker not found */ mxg->buffer_ptr = search_end; mxg->cache_size = OVERREAD_SIZE; } } return AVERROR_EOF; }
true
FFmpeg
c7c207aecde0773afc974ce4b7e25dca659bc5b5
static int mxg_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret; unsigned int size; uint8_t *startmarker_ptr, *end, *search_end, marker; MXGContext *mxg = s->priv_data; while (!avio_feof(s->pb) && !s->pb->error){ if (mxg->cache_size <= OVERREAD_SIZE) { ret = mxg_update_cache(s, DEFAULT_PACKET_SIZE + OVERREAD_SIZE); if (ret < 0) return ret; } end = mxg->buffer_ptr + mxg->cache_size; if (mxg->cache_size > OVERREAD_SIZE) { search_end = end - OVERREAD_SIZE; startmarker_ptr = mxg_find_startmarker(mxg->buffer_ptr, search_end); } else { search_end = end; startmarker_ptr = mxg_find_startmarker(mxg->buffer_ptr, search_end); if (startmarker_ptr >= search_end - 1 || *(startmarker_ptr + 1) != EOI) break; } if (startmarker_ptr != search_end) { marker = *(startmarker_ptr + 1); mxg->buffer_ptr = startmarker_ptr + 2; mxg->cache_size = end - mxg->buffer_ptr; if (marker == SOI) { mxg->soi_ptr = startmarker_ptr; } else if (marker == EOI) { if (!mxg->soi_ptr) { av_log(s, AV_LOG_WARNING, "Found EOI before SOI, skipping\n"); continue; } pkt->pts = pkt->dts = mxg->dts; pkt->stream_index = 0; #if FF_API_DESTRUCT_PACKET FF_DISABLE_DEPRECATION_WARNINGS pkt->destruct = NULL; FF_ENABLE_DEPRECATION_WARNINGS #endif pkt->buf = NULL; pkt->size = mxg->buffer_ptr - mxg->soi_ptr; pkt->data = mxg->soi_ptr; if (mxg->soi_ptr - mxg->buffer > mxg->cache_size) { if (mxg->cache_size > 0) { memcpy(mxg->buffer, mxg->buffer_ptr, mxg->cache_size); } mxg->buffer_ptr = mxg->buffer; } mxg->soi_ptr = 0; return pkt->size; } else if ( (SOF0 <= marker && marker <= SOF15) || (SOS <= marker && marker <= COM) ) { size = AV_RB16(mxg->buffer_ptr); if (size < 2) return AVERROR(EINVAL); if (mxg->cache_size < size) { ret = mxg_update_cache(s, size); if (ret < 0) return ret; startmarker_ptr = mxg->buffer_ptr - 2; mxg->cache_size = 0; } else { mxg->cache_size -= size; } mxg->buffer_ptr += size; if (marker == APP13 && size >= 16) { pkt->pts = pkt->dts = AV_RL64(startmarker_ptr + 8); pkt->stream_index = 1; #if FF_API_DESTRUCT_PACKET FF_DISABLE_DEPRECATION_WARNINGS pkt->destruct = NULL; FF_ENABLE_DEPRECATION_WARNINGS #endif pkt->buf = NULL; pkt->size = size - 14; pkt->data = startmarker_ptr + 16; if (startmarker_ptr - mxg->buffer > mxg->cache_size) { if (mxg->cache_size > 0) { memcpy(mxg->buffer, mxg->buffer_ptr, mxg->cache_size); } mxg->buffer_ptr = mxg->buffer; } return pkt->size; } else if (marker == COM && size >= 18 && !strncmp(startmarker_ptr + 4, "MXF", 3)) { mxg->dts = AV_RL64(startmarker_ptr + 12); } } } else { mxg->buffer_ptr = search_end; mxg->cache_size = OVERREAD_SIZE; } } return AVERROR_EOF; }
{ "code": [ " memcpy(mxg->buffer, mxg->buffer_ptr, mxg->cache_size);" ], "line_no": [ 107 ] }
static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1) { int VAR_2; unsigned int VAR_3; uint8_t *startmarker_ptr, *end, *search_end, marker; MXGContext *mxg = VAR_0->priv_data; while (!avio_feof(VAR_0->pb) && !VAR_0->pb->error){ if (mxg->cache_size <= OVERREAD_SIZE) { VAR_2 = mxg_update_cache(VAR_0, DEFAULT_PACKET_SIZE + OVERREAD_SIZE); if (VAR_2 < 0) return VAR_2; } end = mxg->buffer_ptr + mxg->cache_size; if (mxg->cache_size > OVERREAD_SIZE) { search_end = end - OVERREAD_SIZE; startmarker_ptr = mxg_find_startmarker(mxg->buffer_ptr, search_end); } else { search_end = end; startmarker_ptr = mxg_find_startmarker(mxg->buffer_ptr, search_end); if (startmarker_ptr >= search_end - 1 || *(startmarker_ptr + 1) != EOI) break; } if (startmarker_ptr != search_end) { marker = *(startmarker_ptr + 1); mxg->buffer_ptr = startmarker_ptr + 2; mxg->cache_size = end - mxg->buffer_ptr; if (marker == SOI) { mxg->soi_ptr = startmarker_ptr; } else if (marker == EOI) { if (!mxg->soi_ptr) { av_log(VAR_0, AV_LOG_WARNING, "Found EOI before SOI, skipping\n"); continue; } VAR_1->pts = VAR_1->dts = mxg->dts; VAR_1->stream_index = 0; #if FF_API_DESTRUCT_PACKET FF_DISABLE_DEPRECATION_WARNINGS VAR_1->destruct = NULL; FF_ENABLE_DEPRECATION_WARNINGS #endif VAR_1->buf = NULL; VAR_1->VAR_3 = mxg->buffer_ptr - mxg->soi_ptr; VAR_1->data = mxg->soi_ptr; if (mxg->soi_ptr - mxg->buffer > mxg->cache_size) { if (mxg->cache_size > 0) { memcpy(mxg->buffer, mxg->buffer_ptr, mxg->cache_size); } mxg->buffer_ptr = mxg->buffer; } mxg->soi_ptr = 0; return VAR_1->VAR_3; } else if ( (SOF0 <= marker && marker <= SOF15) || (SOS <= marker && marker <= COM) ) { VAR_3 = AV_RB16(mxg->buffer_ptr); if (VAR_3 < 2) return AVERROR(EINVAL); if (mxg->cache_size < VAR_3) { VAR_2 = mxg_update_cache(VAR_0, VAR_3); if (VAR_2 < 0) return VAR_2; startmarker_ptr = mxg->buffer_ptr - 2; mxg->cache_size = 0; } else { mxg->cache_size -= VAR_3; } mxg->buffer_ptr += VAR_3; if (marker == APP13 && VAR_3 >= 16) { VAR_1->pts = VAR_1->dts = AV_RL64(startmarker_ptr + 8); VAR_1->stream_index = 1; #if FF_API_DESTRUCT_PACKET FF_DISABLE_DEPRECATION_WARNINGS VAR_1->destruct = NULL; FF_ENABLE_DEPRECATION_WARNINGS #endif VAR_1->buf = NULL; VAR_1->VAR_3 = VAR_3 - 14; VAR_1->data = startmarker_ptr + 16; if (startmarker_ptr - mxg->buffer > mxg->cache_size) { if (mxg->cache_size > 0) { memcpy(mxg->buffer, mxg->buffer_ptr, mxg->cache_size); } mxg->buffer_ptr = mxg->buffer; } return VAR_1->VAR_3; } else if (marker == COM && VAR_3 >= 18 && !strncmp(startmarker_ptr + 4, "MXF", 3)) { mxg->dts = AV_RL64(startmarker_ptr + 12); } } } else { mxg->buffer_ptr = search_end; mxg->cache_size = OVERREAD_SIZE; } } return AVERROR_EOF; }
[ "static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{", "int VAR_2;", "unsigned int VAR_3;", "uint8_t *startmarker_ptr, *end, *search_end, marker;", "MXGContext *mxg = VAR_0->priv_data;", "while (!avio_feof(VAR_0->pb) && !VAR_0->pb->error){", "if (mxg->cache_size <= OVERREAD_SIZE) {", "VAR_2 = mxg_update_cache(VAR_0, DEFAULT_PACKET_SIZE + OVERREAD_SIZE);", "if (VAR_2 < 0)\nreturn VAR_2;", "}", "end = mxg->buffer_ptr + mxg->cache_size;", "if (mxg->cache_size > OVERREAD_SIZE) {", "search_end = end - OVERREAD_SIZE;", "startmarker_ptr = mxg_find_startmarker(mxg->buffer_ptr, search_end);", "} else {", "search_end = end;", "startmarker_ptr = mxg_find_startmarker(mxg->buffer_ptr, search_end);", "if (startmarker_ptr >= search_end - 1 ||\n*(startmarker_ptr + 1) != EOI) break;", "}", "if (startmarker_ptr != search_end) {", "marker = *(startmarker_ptr + 1);", "mxg->buffer_ptr = startmarker_ptr + 2;", "mxg->cache_size = end - mxg->buffer_ptr;", "if (marker == SOI) {", "mxg->soi_ptr = startmarker_ptr;", "} else if (marker == EOI) {", "if (!mxg->soi_ptr) {", "av_log(VAR_0, AV_LOG_WARNING, \"Found EOI before SOI, skipping\\n\");", "continue;", "}", "VAR_1->pts = VAR_1->dts = mxg->dts;", "VAR_1->stream_index = 0;", "#if FF_API_DESTRUCT_PACKET\nFF_DISABLE_DEPRECATION_WARNINGS\nVAR_1->destruct = NULL;", "FF_ENABLE_DEPRECATION_WARNINGS\n#endif\nVAR_1->buf = NULL;", "VAR_1->VAR_3 = mxg->buffer_ptr - mxg->soi_ptr;", "VAR_1->data = mxg->soi_ptr;", "if (mxg->soi_ptr - mxg->buffer > mxg->cache_size) {", "if (mxg->cache_size > 0) {", "memcpy(mxg->buffer, mxg->buffer_ptr, mxg->cache_size);", "}", "mxg->buffer_ptr = mxg->buffer;", "}", "mxg->soi_ptr = 0;", "return VAR_1->VAR_3;", "} else if ( (SOF0 <= marker && marker <= SOF15) ||", "(SOS <= marker && marker <= COM) ) {", "VAR_3 = AV_RB16(mxg->buffer_ptr);", "if (VAR_3 < 2)\nreturn AVERROR(EINVAL);", "if (mxg->cache_size < VAR_3) {", "VAR_2 = mxg_update_cache(VAR_0, VAR_3);", "if (VAR_2 < 0)\nreturn VAR_2;", "startmarker_ptr = mxg->buffer_ptr - 2;", "mxg->cache_size = 0;", "} else {", "mxg->cache_size -= VAR_3;", "}", "mxg->buffer_ptr += VAR_3;", "if (marker == APP13 && VAR_3 >= 16) {", "VAR_1->pts = VAR_1->dts = AV_RL64(startmarker_ptr + 8);", "VAR_1->stream_index = 1;", "#if FF_API_DESTRUCT_PACKET\nFF_DISABLE_DEPRECATION_WARNINGS\nVAR_1->destruct = NULL;", "FF_ENABLE_DEPRECATION_WARNINGS\n#endif\nVAR_1->buf = NULL;", "VAR_1->VAR_3 = VAR_3 - 14;", "VAR_1->data = startmarker_ptr + 16;", "if (startmarker_ptr - mxg->buffer > mxg->cache_size) {", "if (mxg->cache_size > 0) {", "memcpy(mxg->buffer, mxg->buffer_ptr, mxg->cache_size);", "}", "mxg->buffer_ptr = mxg->buffer;", "}", "return VAR_1->VAR_3;", "} else if (marker == COM && VAR_3 >= 18 &&", "!strncmp(startmarker_ptr + 4, \"MXF\", 3)) {", "mxg->dts = AV_RL64(startmarker_ptr + 12);", "}", "}", "} else {", "mxg->buffer_ptr = search_end;", "mxg->cache_size = OVERREAD_SIZE;", "}", "}", "return AVERROR_EOF;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 21 ], [ 23, 25 ], [ 27 ], [ 29 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47, 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 81 ], [ 83 ], [ 85, 87, 89 ], [ 91, 93, 95 ], [ 97 ], [ 99 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 113 ], [ 115 ], [ 117 ], [ 121 ], [ 123 ], [ 125 ], [ 131 ], [ 133, 135 ], [ 139 ], [ 141 ], [ 143, 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 159 ], [ 163 ], [ 167 ], [ 169 ], [ 171, 173, 175 ], [ 177, 179, 181 ], [ 183 ], [ 185 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 203 ], [ 205 ], [ 207 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 231 ], [ 233 ] ]
693
static uint32_t pci_unin_config_readl (void *opaque, target_phys_addr_t addr) { UNINState *s = opaque; return s->config_reg; }
true
qemu
2e29bd04786003561303dcad940b38afe790fb9b
static uint32_t pci_unin_config_readl (void *opaque, target_phys_addr_t addr) { UNINState *s = opaque; return s->config_reg; }
{ "code": [ " return s->config_reg;" ], "line_no": [ 11 ] }
static uint32_t FUNC_0 (void *opaque, target_phys_addr_t addr) { UNINState *s = opaque; return s->config_reg; }
[ "static uint32_t FUNC_0 (void *opaque,\ntarget_phys_addr_t addr)\n{", "UNINState *s = opaque;", "return s->config_reg;", "}" ]
[ 0, 0, 1, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ] ]
694
static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vstream, const char *key, int64_t max_pos, int depth) { AVCodecContext *acodec, *vcodec; FLVContext *flv = s->priv_data; AVIOContext *ioc; AMFDataType amf_type; char str_val[256]; double num_val; num_val = 0; ioc = s->pb; amf_type = avio_r8(ioc); switch (amf_type) { case AMF_DATA_TYPE_NUMBER: num_val = av_int2double(avio_rb64(ioc)); break; case AMF_DATA_TYPE_BOOL: num_val = avio_r8(ioc); break; case AMF_DATA_TYPE_STRING: if (amf_get_string(ioc, str_val, sizeof(str_val)) < 0) return -1; break; case AMF_DATA_TYPE_OBJECT: if ((vstream || astream) && key && ioc->seekable && !strcmp(KEYFRAMES_TAG, key) && depth == 1) if (parse_keyframes_index(s, ioc, vstream ? vstream : astream, max_pos) < 0) av_log(s, AV_LOG_ERROR, "Keyframe index parsing failed\n"); while (avio_tell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) if (amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0) return -1; // if we couldn't skip, bomb out. if (avio_r8(ioc) != AMF_END_OF_OBJECT) return -1; break; case AMF_DATA_TYPE_NULL: case AMF_DATA_TYPE_UNDEFINED: case AMF_DATA_TYPE_UNSUPPORTED: break; // these take up no additional space case AMF_DATA_TYPE_MIXEDARRAY: avio_skip(ioc, 4); // skip 32-bit max array index while (avio_tell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) // this is the only case in which we would want a nested // parse to not skip over the object if (amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0) return -1; if (avio_r8(ioc) != AMF_END_OF_OBJECT) return -1; break; case AMF_DATA_TYPE_ARRAY: { unsigned int arraylen, i; arraylen = avio_rb32(ioc); for (i = 0; i < arraylen && avio_tell(ioc) < max_pos - 1; i++) if (amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0) return -1; // if we couldn't skip, bomb out. } break; case AMF_DATA_TYPE_DATE: avio_skip(ioc, 8 + 2); // timestamp (double) and UTC offset (int16) break; default: // unsupported type, we couldn't skip return -1; } if (key) { // stream info doesn't live any deeper than the first object if (depth == 1) { acodec = astream ? astream->codec : NULL; vcodec = vstream ? vstream->codec : NULL; if (amf_type == AMF_DATA_TYPE_NUMBER || amf_type == AMF_DATA_TYPE_BOOL) { if (!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE; else if (!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0)) vcodec->bit_rate = num_val * 1024.0; else if (!strcmp(key, "audiodatarate") && acodec && 0 <= (int)(num_val * 1024.0)) acodec->bit_rate = num_val * 1024.0; else if (!strcmp(key, "datastream")) { AVStream *st = create_stream(s, AVMEDIA_TYPE_DATA); if (!st) return AVERROR(ENOMEM); st->codec->codec_id = AV_CODEC_ID_TEXT; } else if (flv->trust_metadata) { if (!strcmp(key, "videocodecid") && vcodec) { flv_set_video_codec(s, vstream, num_val, 0); } else if (!strcmp(key, "audiocodecid") && acodec) { int id = ((int)num_val) << FLV_AUDIO_CODECID_OFFSET; flv_set_audio_codec(s, astream, acodec, id); } else if (!strcmp(key, "audiosamplerate") && acodec) { acodec->sample_rate = num_val; } else if (!strcmp(key, "audiosamplesize") && acodec) { acodec->bits_per_coded_sample = num_val; } else if (!strcmp(key, "stereo") && acodec) { acodec->channels = num_val + 1; acodec->channel_layout = acodec->channels == 2 ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; } else if (!strcmp(key, "width") && vcodec) { vcodec->width = num_val; } else if (!strcmp(key, "height") && vcodec) { vcodec->height = num_val; } } } } if (amf_type == AMF_DATA_TYPE_OBJECT && s->nb_streams == 1 && ((!acodec && !strcmp(key, "audiocodecid")) || (!vcodec && !strcmp(key, "videocodecid")))) s->ctx_flags &= ~AVFMTCTX_NOHEADER; //If there is either audio/video missing, codecid will be an empty object if (!strcmp(key, "duration") || !strcmp(key, "filesize") || !strcmp(key, "width") || !strcmp(key, "height") || !strcmp(key, "videodatarate") || !strcmp(key, "framerate") || !strcmp(key, "videocodecid") || !strcmp(key, "audiodatarate") || !strcmp(key, "audiosamplerate") || !strcmp(key, "audiosamplesize") || !strcmp(key, "stereo") || !strcmp(key, "audiocodecid") || !strcmp(key, "datastream")) return 0; s->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED; if (amf_type == AMF_DATA_TYPE_BOOL) { av_strlcpy(str_val, num_val > 0 ? "true" : "false", sizeof(str_val)); av_dict_set(&s->metadata, key, str_val, 0); } else if (amf_type == AMF_DATA_TYPE_NUMBER) { snprintf(str_val, sizeof(str_val), "%.f", num_val); av_dict_set(&s->metadata, key, str_val, 0); } else if (amf_type == AMF_DATA_TYPE_STRING) av_dict_set(&s->metadata, key, str_val, 0); } return 0; }
true
FFmpeg
0fadbd3623cf9132832f48810c0edb93aa63f51b
static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vstream, const char *key, int64_t max_pos, int depth) { AVCodecContext *acodec, *vcodec; FLVContext *flv = s->priv_data; AVIOContext *ioc; AMFDataType amf_type; char str_val[256]; double num_val; num_val = 0; ioc = s->pb; amf_type = avio_r8(ioc); switch (amf_type) { case AMF_DATA_TYPE_NUMBER: num_val = av_int2double(avio_rb64(ioc)); break; case AMF_DATA_TYPE_BOOL: num_val = avio_r8(ioc); break; case AMF_DATA_TYPE_STRING: if (amf_get_string(ioc, str_val, sizeof(str_val)) < 0) return -1; break; case AMF_DATA_TYPE_OBJECT: if ((vstream || astream) && key && ioc->seekable && !strcmp(KEYFRAMES_TAG, key) && depth == 1) if (parse_keyframes_index(s, ioc, vstream ? vstream : astream, max_pos) < 0) av_log(s, AV_LOG_ERROR, "Keyframe index parsing failed\n"); while (avio_tell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) if (amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0) return -1; if (avio_r8(ioc) != AMF_END_OF_OBJECT) return -1; break; case AMF_DATA_TYPE_NULL: case AMF_DATA_TYPE_UNDEFINED: case AMF_DATA_TYPE_UNSUPPORTED: break; case AMF_DATA_TYPE_MIXEDARRAY: avio_skip(ioc, 4); while (avio_tell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) if (amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0) return -1; if (avio_r8(ioc) != AMF_END_OF_OBJECT) return -1; break; case AMF_DATA_TYPE_ARRAY: { unsigned int arraylen, i; arraylen = avio_rb32(ioc); for (i = 0; i < arraylen && avio_tell(ioc) < max_pos - 1; i++) if (amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0) return -1; } break; case AMF_DATA_TYPE_DATE: avio_skip(ioc, 8 + 2); break; default: return -1; } if (key) { if (depth == 1) { acodec = astream ? astream->codec : NULL; vcodec = vstream ? vstream->codec : NULL; if (amf_type == AMF_DATA_TYPE_NUMBER || amf_type == AMF_DATA_TYPE_BOOL) { if (!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE; else if (!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0)) vcodec->bit_rate = num_val * 1024.0; else if (!strcmp(key, "audiodatarate") && acodec && 0 <= (int)(num_val * 1024.0)) acodec->bit_rate = num_val * 1024.0; else if (!strcmp(key, "datastream")) { AVStream *st = create_stream(s, AVMEDIA_TYPE_DATA); if (!st) return AVERROR(ENOMEM); st->codec->codec_id = AV_CODEC_ID_TEXT; } else if (flv->trust_metadata) { if (!strcmp(key, "videocodecid") && vcodec) { flv_set_video_codec(s, vstream, num_val, 0); } else if (!strcmp(key, "audiocodecid") && acodec) { int id = ((int)num_val) << FLV_AUDIO_CODECID_OFFSET; flv_set_audio_codec(s, astream, acodec, id); } else if (!strcmp(key, "audiosamplerate") && acodec) { acodec->sample_rate = num_val; } else if (!strcmp(key, "audiosamplesize") && acodec) { acodec->bits_per_coded_sample = num_val; } else if (!strcmp(key, "stereo") && acodec) { acodec->channels = num_val + 1; acodec->channel_layout = acodec->channels == 2 ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; } else if (!strcmp(key, "width") && vcodec) { vcodec->width = num_val; } else if (!strcmp(key, "height") && vcodec) { vcodec->height = num_val; } } } } if (amf_type == AMF_DATA_TYPE_OBJECT && s->nb_streams == 1 && ((!acodec && !strcmp(key, "audiocodecid")) || (!vcodec && !strcmp(key, "videocodecid")))) s->ctx_flags &= ~AVFMTCTX_NOHEADER; if (!strcmp(key, "duration") || !strcmp(key, "filesize") || !strcmp(key, "width") || !strcmp(key, "height") || !strcmp(key, "videodatarate") || !strcmp(key, "framerate") || !strcmp(key, "videocodecid") || !strcmp(key, "audiodatarate") || !strcmp(key, "audiosamplerate") || !strcmp(key, "audiosamplesize") || !strcmp(key, "stereo") || !strcmp(key, "audiocodecid") || !strcmp(key, "datastream")) return 0; s->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED; if (amf_type == AMF_DATA_TYPE_BOOL) { av_strlcpy(str_val, num_val > 0 ? "true" : "false", sizeof(str_val)); av_dict_set(&s->metadata, key, str_val, 0); } else if (amf_type == AMF_DATA_TYPE_NUMBER) { snprintf(str_val, sizeof(str_val), "%.f", num_val); av_dict_set(&s->metadata, key, str_val, 0); } else if (amf_type == AMF_DATA_TYPE_STRING) av_dict_set(&s->metadata, key, str_val, 0); } return 0; }
{ "code": [ " acodec = astream ? astream->codec : NULL;", " vcodec = vstream ? vstream->codec : NULL;" ], "line_no": [ 159, 161 ] }
static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, AVStream *VAR_2, const char *VAR_3, int64_t VAR_4, int VAR_5) { AVCodecContext *acodec, *vcodec; FLVContext *flv = VAR_0->priv_data; AVIOContext *ioc; AMFDataType amf_type; char VAR_6[256]; double VAR_7; VAR_7 = 0; ioc = VAR_0->pb; amf_type = avio_r8(ioc); switch (amf_type) { case AMF_DATA_TYPE_NUMBER: VAR_7 = av_int2double(avio_rb64(ioc)); break; case AMF_DATA_TYPE_BOOL: VAR_7 = avio_r8(ioc); break; case AMF_DATA_TYPE_STRING: if (amf_get_string(ioc, VAR_6, sizeof(VAR_6)) < 0) return -1; break; case AMF_DATA_TYPE_OBJECT: if ((VAR_2 || VAR_1) && VAR_3 && ioc->seekable && !strcmp(KEYFRAMES_TAG, VAR_3) && VAR_5 == 1) if (parse_keyframes_index(VAR_0, ioc, VAR_2 ? VAR_2 : VAR_1, VAR_4) < 0) av_log(VAR_0, AV_LOG_ERROR, "Keyframe index parsing failed\n"); while (avio_tell(ioc) < VAR_4 - 2 && amf_get_string(ioc, VAR_6, sizeof(VAR_6)) > 0) if (FUNC_0(VAR_0, VAR_1, VAR_2, VAR_6, VAR_4, VAR_5 + 1) < 0) return -1; if (avio_r8(ioc) != AMF_END_OF_OBJECT) return -1; break; case AMF_DATA_TYPE_NULL: case AMF_DATA_TYPE_UNDEFINED: case AMF_DATA_TYPE_UNSUPPORTED: break; case AMF_DATA_TYPE_MIXEDARRAY: avio_skip(ioc, 4); while (avio_tell(ioc) < VAR_4 - 2 && amf_get_string(ioc, VAR_6, sizeof(VAR_6)) > 0) if (FUNC_0(VAR_0, VAR_1, VAR_2, VAR_6, VAR_4, VAR_5 + 1) < 0) return -1; if (avio_r8(ioc) != AMF_END_OF_OBJECT) return -1; break; case AMF_DATA_TYPE_ARRAY: { unsigned int VAR_8, VAR_9; VAR_8 = avio_rb32(ioc); for (VAR_9 = 0; VAR_9 < VAR_8 && avio_tell(ioc) < VAR_4 - 1; VAR_9++) if (FUNC_0(VAR_0, NULL, NULL, NULL, VAR_4, VAR_5 + 1) < 0) return -1; } break; case AMF_DATA_TYPE_DATE: avio_skip(ioc, 8 + 2); break; default: return -1; } if (VAR_3) { if (VAR_5 == 1) { acodec = VAR_1 ? VAR_1->codec : NULL; vcodec = VAR_2 ? VAR_2->codec : NULL; if (amf_type == AMF_DATA_TYPE_NUMBER || amf_type == AMF_DATA_TYPE_BOOL) { if (!strcmp(VAR_3, "duration")) VAR_0->duration = VAR_7 * AV_TIME_BASE; else if (!strcmp(VAR_3, "videodatarate") && vcodec && 0 <= (int)(VAR_7 * 1024.0)) vcodec->bit_rate = VAR_7 * 1024.0; else if (!strcmp(VAR_3, "audiodatarate") && acodec && 0 <= (int)(VAR_7 * 1024.0)) acodec->bit_rate = VAR_7 * 1024.0; else if (!strcmp(VAR_3, "datastream")) { AVStream *st = create_stream(VAR_0, AVMEDIA_TYPE_DATA); if (!st) return AVERROR(ENOMEM); st->codec->codec_id = AV_CODEC_ID_TEXT; } else if (flv->trust_metadata) { if (!strcmp(VAR_3, "videocodecid") && vcodec) { flv_set_video_codec(VAR_0, VAR_2, VAR_7, 0); } else if (!strcmp(VAR_3, "audiocodecid") && acodec) { int VAR_10 = ((int)VAR_7) << FLV_AUDIO_CODECID_OFFSET; flv_set_audio_codec(VAR_0, VAR_1, acodec, VAR_10); } else if (!strcmp(VAR_3, "audiosamplerate") && acodec) { acodec->sample_rate = VAR_7; } else if (!strcmp(VAR_3, "audiosamplesize") && acodec) { acodec->bits_per_coded_sample = VAR_7; } else if (!strcmp(VAR_3, "stereo") && acodec) { acodec->channels = VAR_7 + 1; acodec->channel_layout = acodec->channels == 2 ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; } else if (!strcmp(VAR_3, "width") && vcodec) { vcodec->width = VAR_7; } else if (!strcmp(VAR_3, "height") && vcodec) { vcodec->height = VAR_7; } } } } if (amf_type == AMF_DATA_TYPE_OBJECT && VAR_0->nb_streams == 1 && ((!acodec && !strcmp(VAR_3, "audiocodecid")) || (!vcodec && !strcmp(VAR_3, "videocodecid")))) VAR_0->ctx_flags &= ~AVFMTCTX_NOHEADER; if (!strcmp(VAR_3, "duration") || !strcmp(VAR_3, "filesize") || !strcmp(VAR_3, "width") || !strcmp(VAR_3, "height") || !strcmp(VAR_3, "videodatarate") || !strcmp(VAR_3, "framerate") || !strcmp(VAR_3, "videocodecid") || !strcmp(VAR_3, "audiodatarate") || !strcmp(VAR_3, "audiosamplerate") || !strcmp(VAR_3, "audiosamplesize") || !strcmp(VAR_3, "stereo") || !strcmp(VAR_3, "audiocodecid") || !strcmp(VAR_3, "datastream")) return 0; VAR_0->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED; if (amf_type == AMF_DATA_TYPE_BOOL) { av_strlcpy(VAR_6, VAR_7 > 0 ? "true" : "false", sizeof(VAR_6)); av_dict_set(&VAR_0->metadata, VAR_3, VAR_6, 0); } else if (amf_type == AMF_DATA_TYPE_NUMBER) { snprintf(VAR_6, sizeof(VAR_6), "%.f", VAR_7); av_dict_set(&VAR_0->metadata, VAR_3, VAR_6, 0); } else if (amf_type == AMF_DATA_TYPE_STRING) av_dict_set(&VAR_0->metadata, VAR_3, VAR_6, 0); } return 0; }
[ "static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1,\nAVStream *VAR_2, const char *VAR_3,\nint64_t VAR_4, int VAR_5)\n{", "AVCodecContext *acodec, *vcodec;", "FLVContext *flv = VAR_0->priv_data;", "AVIOContext *ioc;", "AMFDataType amf_type;", "char VAR_6[256];", "double VAR_7;", "VAR_7 = 0;", "ioc = VAR_0->pb;", "amf_type = avio_r8(ioc);", "switch (amf_type) {", "case AMF_DATA_TYPE_NUMBER:\nVAR_7 = av_int2double(avio_rb64(ioc));", "break;", "case AMF_DATA_TYPE_BOOL:\nVAR_7 = avio_r8(ioc);", "break;", "case AMF_DATA_TYPE_STRING:\nif (amf_get_string(ioc, VAR_6, sizeof(VAR_6)) < 0)\nreturn -1;", "break;", "case AMF_DATA_TYPE_OBJECT:\nif ((VAR_2 || VAR_1) && VAR_3 &&\nioc->seekable &&\n!strcmp(KEYFRAMES_TAG, VAR_3) && VAR_5 == 1)\nif (parse_keyframes_index(VAR_0, ioc, VAR_2 ? VAR_2 : VAR_1,\nVAR_4) < 0)\nav_log(VAR_0, AV_LOG_ERROR, \"Keyframe index parsing failed\\n\");", "while (avio_tell(ioc) < VAR_4 - 2 &&\namf_get_string(ioc, VAR_6, sizeof(VAR_6)) > 0)\nif (FUNC_0(VAR_0, VAR_1, VAR_2, VAR_6, VAR_4,\nVAR_5 + 1) < 0)\nreturn -1;", "if (avio_r8(ioc) != AMF_END_OF_OBJECT)\nreturn -1;", "break;", "case AMF_DATA_TYPE_NULL:\ncase AMF_DATA_TYPE_UNDEFINED:\ncase AMF_DATA_TYPE_UNSUPPORTED:\nbreak;", "case AMF_DATA_TYPE_MIXEDARRAY:\navio_skip(ioc, 4);", "while (avio_tell(ioc) < VAR_4 - 2 &&\namf_get_string(ioc, VAR_6, sizeof(VAR_6)) > 0)\nif (FUNC_0(VAR_0, VAR_1, VAR_2, VAR_6, VAR_4,\nVAR_5 + 1) < 0)\nreturn -1;", "if (avio_r8(ioc) != AMF_END_OF_OBJECT)\nreturn -1;", "break;", "case AMF_DATA_TYPE_ARRAY:\n{", "unsigned int VAR_8, VAR_9;", "VAR_8 = avio_rb32(ioc);", "for (VAR_9 = 0; VAR_9 < VAR_8 && avio_tell(ioc) < VAR_4 - 1; VAR_9++)", "if (FUNC_0(VAR_0, NULL, NULL, NULL, VAR_4,\nVAR_5 + 1) < 0)\nreturn -1;", "}", "break;", "case AMF_DATA_TYPE_DATE:\navio_skip(ioc, 8 + 2);", "break;", "default:\nreturn -1;", "}", "if (VAR_3) {", "if (VAR_5 == 1) {", "acodec = VAR_1 ? VAR_1->codec : NULL;", "vcodec = VAR_2 ? VAR_2->codec : NULL;", "if (amf_type == AMF_DATA_TYPE_NUMBER ||\namf_type == AMF_DATA_TYPE_BOOL) {", "if (!strcmp(VAR_3, \"duration\"))\nVAR_0->duration = VAR_7 * AV_TIME_BASE;", "else if (!strcmp(VAR_3, \"videodatarate\") && vcodec &&\n0 <= (int)(VAR_7 * 1024.0))\nvcodec->bit_rate = VAR_7 * 1024.0;", "else if (!strcmp(VAR_3, \"audiodatarate\") && acodec &&\n0 <= (int)(VAR_7 * 1024.0))\nacodec->bit_rate = VAR_7 * 1024.0;", "else if (!strcmp(VAR_3, \"datastream\")) {", "AVStream *st = create_stream(VAR_0, AVMEDIA_TYPE_DATA);", "if (!st)\nreturn AVERROR(ENOMEM);", "st->codec->codec_id = AV_CODEC_ID_TEXT;", "} else if (flv->trust_metadata) {", "if (!strcmp(VAR_3, \"videocodecid\") && vcodec) {", "flv_set_video_codec(VAR_0, VAR_2, VAR_7, 0);", "} else if (!strcmp(VAR_3, \"audiocodecid\") && acodec) {", "int VAR_10 = ((int)VAR_7) << FLV_AUDIO_CODECID_OFFSET;", "flv_set_audio_codec(VAR_0, VAR_1, acodec, VAR_10);", "} else if (!strcmp(VAR_3, \"audiosamplerate\") && acodec) {", "acodec->sample_rate = VAR_7;", "} else if (!strcmp(VAR_3, \"audiosamplesize\") && acodec) {", "acodec->bits_per_coded_sample = VAR_7;", "} else if (!strcmp(VAR_3, \"stereo\") && acodec) {", "acodec->channels = VAR_7 + 1;", "acodec->channel_layout = acodec->channels == 2 ?\nAV_CH_LAYOUT_STEREO :\nAV_CH_LAYOUT_MONO;", "} else if (!strcmp(VAR_3, \"width\") && vcodec) {", "vcodec->width = VAR_7;", "} else if (!strcmp(VAR_3, \"height\") && vcodec) {", "vcodec->height = VAR_7;", "}", "}", "}", "}", "if (amf_type == AMF_DATA_TYPE_OBJECT && VAR_0->nb_streams == 1 &&\n((!acodec && !strcmp(VAR_3, \"audiocodecid\")) ||\n(!vcodec && !strcmp(VAR_3, \"videocodecid\"))))\nVAR_0->ctx_flags &= ~AVFMTCTX_NOHEADER;", "if (!strcmp(VAR_3, \"duration\") ||\n!strcmp(VAR_3, \"filesize\") ||\n!strcmp(VAR_3, \"width\") ||\n!strcmp(VAR_3, \"height\") ||\n!strcmp(VAR_3, \"videodatarate\") ||\n!strcmp(VAR_3, \"framerate\") ||\n!strcmp(VAR_3, \"videocodecid\") ||\n!strcmp(VAR_3, \"audiodatarate\") ||\n!strcmp(VAR_3, \"audiosamplerate\") ||\n!strcmp(VAR_3, \"audiosamplesize\") ||\n!strcmp(VAR_3, \"stereo\") ||\n!strcmp(VAR_3, \"audiocodecid\") ||\n!strcmp(VAR_3, \"datastream\"))\nreturn 0;", "VAR_0->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;", "if (amf_type == AMF_DATA_TYPE_BOOL) {", "av_strlcpy(VAR_6, VAR_7 > 0 ? \"true\" : \"false\",\nsizeof(VAR_6));", "av_dict_set(&VAR_0->metadata, VAR_3, VAR_6, 0);", "} else if (amf_type == AMF_DATA_TYPE_NUMBER) {", "snprintf(VAR_6, sizeof(VAR_6), \"%.f\", VAR_7);", "av_dict_set(&VAR_0->metadata, VAR_3, VAR_6, 0);", "} else if (amf_type == AMF_DATA_TYPE_STRING)", "av_dict_set(&VAR_0->metadata, VAR_3, VAR_6, 0);", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33, 35 ], [ 37 ], [ 39, 41 ], [ 43 ], [ 45, 47, 49 ], [ 51 ], [ 53, 55, 57, 59, 61, 63, 65 ], [ 69, 71, 73, 75, 77 ], [ 79, 81 ], [ 83 ], [ 85, 87, 89, 91 ], [ 93, 95 ], [ 97, 99, 105, 107, 109 ], [ 111, 113 ], [ 115 ], [ 117, 119 ], [ 121 ], [ 125 ], [ 127 ], [ 129, 131, 133 ], [ 135 ], [ 137 ], [ 139, 141 ], [ 143 ], [ 145, 147 ], [ 149 ], [ 153 ], [ 157 ], [ 159 ], [ 161 ], [ 165, 167 ], [ 169, 171 ], [ 173, 175, 177 ], [ 179, 181, 183 ], [ 185 ], [ 187 ], [ 189, 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219, 221, 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 239 ], [ 243, 245, 247, 249 ], [ 253, 255, 257, 259, 261, 263, 265, 267, 269, 271, 273, 275, 277, 279 ], [ 283 ], [ 285 ], [ 287, 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ], [ 299 ], [ 301 ], [ 303 ], [ 307 ], [ 309 ] ]
695
static TCGv_i64 gen_subq_msw(TCGv_i64 a, TCGv b) { TCGv_i64 tmp64 = tcg_temp_new_i64(); tcg_gen_extu_i32_i64(tmp64, b); dead_tmp(b); tcg_gen_shli_i64(tmp64, tmp64, 32); tcg_gen_sub_i64(a, tmp64, a); tcg_temp_free_i64(tmp64); return a; }
true
qemu
7d1b0095bff7157e856d1d0e6c4295641ced2752
static TCGv_i64 gen_subq_msw(TCGv_i64 a, TCGv b) { TCGv_i64 tmp64 = tcg_temp_new_i64(); tcg_gen_extu_i32_i64(tmp64, b); dead_tmp(b); tcg_gen_shli_i64(tmp64, tmp64, 32); tcg_gen_sub_i64(a, tmp64, a); tcg_temp_free_i64(tmp64); return a; }
{ "code": [ " dead_tmp(b);", " dead_tmp(b);", " dead_tmp(b);", " dead_tmp(b);" ], "line_no": [ 11, 11, 11, 11 ] }
static TCGv_i64 FUNC_0(TCGv_i64 a, TCGv b) { TCGv_i64 tmp64 = tcg_temp_new_i64(); tcg_gen_extu_i32_i64(tmp64, b); dead_tmp(b); tcg_gen_shli_i64(tmp64, tmp64, 32); tcg_gen_sub_i64(a, tmp64, a); tcg_temp_free_i64(tmp64); return a; }
[ "static TCGv_i64 FUNC_0(TCGv_i64 a, TCGv b)\n{", "TCGv_i64 tmp64 = tcg_temp_new_i64();", "tcg_gen_extu_i32_i64(tmp64, b);", "dead_tmp(b);", "tcg_gen_shli_i64(tmp64, tmp64, 32);", "tcg_gen_sub_i64(a, tmp64, a);", "tcg_temp_free_i64(tmp64);", "return a;", "}" ]
[ 0, 0, 0, 1, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ] ]
697
static void decode_component(DiracContext *s, int comp) { AVCodecContext *avctx = s->avctx; SubBand *bands[3*MAX_DWT_LEVELS+1]; enum dirac_subband orientation; int level, num_bands = 0; /* Unpack all subbands at all levels. */ for (level = 0; level < s->wavelet_depth; level++) { for (orientation = !!level; orientation < 4; orientation++) { SubBand *b = &s->plane[comp].band[level][orientation]; bands[num_bands++] = b; align_get_bits(&s->gb); /* [DIRAC_STD] 13.4.2 subband() */ b->length = svq3_get_ue_golomb(&s->gb); if (b->length) { b->quant = svq3_get_ue_golomb(&s->gb); align_get_bits(&s->gb); b->coeff_data = s->gb.buffer + get_bits_count(&s->gb)/8; b->length = FFMIN(b->length, get_bits_left(&s->gb)/8); skip_bits_long(&s->gb, b->length*8); } } /* arithmetic coding has inter-level dependencies, so we can only execute one level at a time */ if (s->is_arith) avctx->execute(avctx, decode_subband_arith, &s->plane[comp].band[level][!!level], NULL, 4-!!level, sizeof(SubBand)); } /* golomb coding has no inter-level dependencies, so we can execute all subbands in parallel */ if (!s->is_arith) avctx->execute(avctx, decode_subband_golomb, bands, NULL, num_bands, sizeof(SubBand*)); }
true
FFmpeg
0f13cc732b3752828890b8dff507615cfd454336
static void decode_component(DiracContext *s, int comp) { AVCodecContext *avctx = s->avctx; SubBand *bands[3*MAX_DWT_LEVELS+1]; enum dirac_subband orientation; int level, num_bands = 0; for (level = 0; level < s->wavelet_depth; level++) { for (orientation = !!level; orientation < 4; orientation++) { SubBand *b = &s->plane[comp].band[level][orientation]; bands[num_bands++] = b; align_get_bits(&s->gb); b->length = svq3_get_ue_golomb(&s->gb); if (b->length) { b->quant = svq3_get_ue_golomb(&s->gb); align_get_bits(&s->gb); b->coeff_data = s->gb.buffer + get_bits_count(&s->gb)/8; b->length = FFMIN(b->length, get_bits_left(&s->gb)/8); skip_bits_long(&s->gb, b->length*8); } } if (s->is_arith) avctx->execute(avctx, decode_subband_arith, &s->plane[comp].band[level][!!level], NULL, 4-!!level, sizeof(SubBand)); } if (!s->is_arith) avctx->execute(avctx, decode_subband_golomb, bands, NULL, num_bands, sizeof(SubBand*)); }
{ "code": [ " b->length = FFMIN(b->length, get_bits_left(&s->gb)/8);" ], "line_no": [ 41 ] }
static void FUNC_0(DiracContext *VAR_0, int VAR_1) { AVCodecContext *avctx = VAR_0->avctx; SubBand *bands[3*MAX_DWT_LEVELS+1]; enum dirac_subband VAR_2; int VAR_3, VAR_4 = 0; for (VAR_3 = 0; VAR_3 < VAR_0->wavelet_depth; VAR_3++) { for (VAR_2 = !!VAR_3; VAR_2 < 4; VAR_2++) { SubBand *b = &VAR_0->plane[VAR_1].band[VAR_3][VAR_2]; bands[VAR_4++] = b; align_get_bits(&VAR_0->gb); b->length = svq3_get_ue_golomb(&VAR_0->gb); if (b->length) { b->quant = svq3_get_ue_golomb(&VAR_0->gb); align_get_bits(&VAR_0->gb); b->coeff_data = VAR_0->gb.buffer + get_bits_count(&VAR_0->gb)/8; b->length = FFMIN(b->length, get_bits_left(&VAR_0->gb)/8); skip_bits_long(&VAR_0->gb, b->length*8); } } if (VAR_0->is_arith) avctx->execute(avctx, decode_subband_arith, &VAR_0->plane[VAR_1].band[VAR_3][!!VAR_3], NULL, 4-!!VAR_3, sizeof(SubBand)); } if (!VAR_0->is_arith) avctx->execute(avctx, decode_subband_golomb, bands, NULL, VAR_4, sizeof(SubBand*)); }
[ "static void FUNC_0(DiracContext *VAR_0, int VAR_1)\n{", "AVCodecContext *avctx = VAR_0->avctx;", "SubBand *bands[3*MAX_DWT_LEVELS+1];", "enum dirac_subband VAR_2;", "int VAR_3, VAR_4 = 0;", "for (VAR_3 = 0; VAR_3 < VAR_0->wavelet_depth; VAR_3++) {", "for (VAR_2 = !!VAR_3; VAR_2 < 4; VAR_2++) {", "SubBand *b = &VAR_0->plane[VAR_1].band[VAR_3][VAR_2];", "bands[VAR_4++] = b;", "align_get_bits(&VAR_0->gb);", "b->length = svq3_get_ue_golomb(&VAR_0->gb);", "if (b->length) {", "b->quant = svq3_get_ue_golomb(&VAR_0->gb);", "align_get_bits(&VAR_0->gb);", "b->coeff_data = VAR_0->gb.buffer + get_bits_count(&VAR_0->gb)/8;", "b->length = FFMIN(b->length, get_bits_left(&VAR_0->gb)/8);", "skip_bits_long(&VAR_0->gb, b->length*8);", "}", "}", "if (VAR_0->is_arith)\navctx->execute(avctx, decode_subband_arith, &VAR_0->plane[VAR_1].band[VAR_3][!!VAR_3],\nNULL, 4-!!VAR_3, sizeof(SubBand));", "}", "if (!VAR_0->is_arith)\navctx->execute(avctx, decode_subband_golomb, bands, NULL, VAR_4, sizeof(SubBand*));", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51, 53, 55 ], [ 57 ], [ 61, 63 ], [ 65 ] ]
698
static void ppc_heathrow_init(MachineState *machine) { ram_addr_t ram_size = machine->ram_size; const char *cpu_model = machine->cpu_model; const char *kernel_filename = machine->kernel_filename; const char *kernel_cmdline = machine->kernel_cmdline; const char *initrd_filename = machine->initrd_filename; const char *boot_device = machine->boot_order; MemoryRegion *sysmem = get_system_memory(); PowerPCCPU *cpu = NULL; CPUPPCState *env = NULL; char *filename; qemu_irq *pic, **heathrow_irqs; int linux_boot, i; MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *bios = g_new(MemoryRegion, 1); MemoryRegion *isa = g_new(MemoryRegion, 1); uint32_t kernel_base, initrd_base, cmdline_base = 0; int32_t kernel_size, initrd_size; PCIBus *pci_bus; PCIDevice *macio; MACIOIDEState *macio_ide; DeviceState *dev; BusState *adb_bus; int bios_size; MemoryRegion *pic_mem; MemoryRegion *escc_mem, *escc_bar = g_new(MemoryRegion, 1); uint16_t ppc_boot_device; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; void *fw_cfg; uint64_t tbfreq; linux_boot = (kernel_filename != NULL); /* init CPUs */ if (cpu_model == NULL) cpu_model = "G3"; for (i = 0; i < smp_cpus; i++) { cpu = cpu_ppc_init(cpu_model); if (cpu == NULL) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); } env = &cpu->env; /* Set time-base frequency to 16.6 Mhz */ cpu_ppc_tb_init(env, TBFREQ); qemu_register_reset(ppc_heathrow_reset, cpu); } /* allocate RAM */ if (ram_size > (2047 << 20)) { fprintf(stderr, "qemu: Too much memory for this machine: %d MB, maximum 2047 MB\n", ((unsigned int)ram_size / (1 << 20))); exit(1); } memory_region_allocate_system_memory(ram, NULL, "ppc_heathrow.ram", ram_size); memory_region_add_subregion(sysmem, 0, ram); /* allocate and load BIOS */ memory_region_init_ram(bios, NULL, "ppc_heathrow.bios", BIOS_SIZE); vmstate_register_ram_global(bios); if (bios_name == NULL) bios_name = PROM_FILENAME; filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); memory_region_set_readonly(bios, true); memory_region_add_subregion(sysmem, PROM_ADDR, bios); /* Load OpenBIOS (ELF) */ if (filename) { bios_size = load_elf(filename, 0, NULL, NULL, NULL, NULL, 1, ELF_MACHINE, 0); g_free(filename); } else { bios_size = -1; } if (bios_size < 0 || bios_size > BIOS_SIZE) { hw_error("qemu: could not load PowerPC bios '%s'\n", bios_name); exit(1); } if (linux_boot) { uint64_t lowaddr = 0; int bswap_needed; #ifdef BSWAP_NEEDED bswap_needed = 1; #else bswap_needed = 0; #endif kernel_base = KERNEL_LOAD_ADDR; kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL, NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0); if (kernel_size < 0) kernel_size = load_aout(kernel_filename, kernel_base, ram_size - kernel_base, bswap_needed, TARGET_PAGE_SIZE); if (kernel_size < 0) 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 = round_page(kernel_base + kernel_size + KERNEL_GAP); 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); exit(1); } cmdline_base = round_page(initrd_base + initrd_size); } else { initrd_base = 0; initrd_size = 0; cmdline_base = round_page(kernel_base + kernel_size + KERNEL_GAP); } 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++) { /* TOFIX: for now, the second IDE channel is not properly * used by OHW. The Mac floppy disk are not emulated. * For now, OHW cannot boot from the network. */ #if 0 if (boot_device[i] >= 'a' && boot_device[i] <= 'f') { ppc_boot_device = boot_device[i]; break; } #else if (boot_device[i] >= 'c' && boot_device[i] <= 'd') { ppc_boot_device = boot_device[i]; break; } #endif } if (ppc_boot_device == '\0') { fprintf(stderr, "No valid boot device for G3 Beige machine\n"); exit(1); } } /* Register 2 MB of ISA IO space */ memory_region_init_alias(isa, NULL, "isa_mmio", get_system_io(), 0, 0x00200000); memory_region_add_subregion(sysmem, 0xfe000000, isa); /* XXX: we register only 1 output pin for heathrow PIC */ heathrow_irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *)); heathrow_irqs[0] = g_malloc0(smp_cpus * sizeof(qemu_irq) * 1); /* Connect the heathrow PIC outputs to the 6xx bus */ for (i = 0; i < smp_cpus; i++) { switch (PPC_INPUT(env)) { case PPC_FLAGS_INPUT_6xx: heathrow_irqs[i] = heathrow_irqs[0] + (i * 1); heathrow_irqs[i][0] = ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT]; break; default: hw_error("Bus model not supported on OldWorld Mac machine\n"); } } /* Timebase Frequency */ if (kvm_enabled()) { tbfreq = kvmppc_get_tbfreq(); } else { tbfreq = TBFREQ; } /* init basic PC hardware */ if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) { hw_error("Only 6xx bus is supported on heathrow machine\n"); } pic = heathrow_pic_init(&pic_mem, 1, heathrow_irqs); pci_bus = pci_grackle_init(0xfec00000, pic, get_system_memory(), get_system_io()); pci_vga_init(pci_bus); escc_mem = escc_init(0, pic[0x0f], pic[0x10], serial_hds[0], serial_hds[1], ESCC_CLOCK, 4); memory_region_init_alias(escc_bar, NULL, "escc-bar", escc_mem, 0, memory_region_size(escc_mem)); for(i = 0; i < nb_nics; i++) pci_nic_init_nofail(&nd_table[i], pci_bus, "ne2k_pci", NULL); ide_drive_get(hd, MAX_IDE_BUS); macio = pci_create(pci_bus, -1, TYPE_OLDWORLD_MACIO); dev = DEVICE(macio); qdev_connect_gpio_out(dev, 0, pic[0x12]); /* CUDA */ qdev_connect_gpio_out(dev, 1, pic[0x0D]); /* IDE-0 */ qdev_connect_gpio_out(dev, 2, pic[0x02]); /* IDE-0 DMA */ qdev_connect_gpio_out(dev, 3, pic[0x0E]); /* IDE-1 */ qdev_connect_gpio_out(dev, 4, pic[0x03]); /* IDE-1 DMA */ macio_init(macio, pic_mem, escc_bar); macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio), "ide[0]")); macio_ide_init_drives(macio_ide, hd); macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio), "ide[1]")); macio_ide_init_drives(macio_ide, &hd[MAX_IDE_DEVS]); dev = DEVICE(object_resolve_path_component(OBJECT(macio), "cuda")); adb_bus = qdev_get_child_bus(dev, "adb.0"); dev = qdev_create(adb_bus, TYPE_ADB_KEYBOARD); qdev_init_nofail(dev); dev = qdev_create(adb_bus, TYPE_ADB_MOUSE); qdev_init_nofail(dev); if (usb_enabled(false)) { pci_create_simple(pci_bus, -1, "pci-ohci"); } if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8) graphic_depth = 15; /* No PCI init: the BIOS will do it */ fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2); fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus); fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1); fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_HEATHROW); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); if (kernel_cmdline) { fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, cmdline_base); pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE, kernel_cmdline); } else { fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0); } fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_base); fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ppc_boot_device); fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width); fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height); fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth); fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled()); if (kvm_enabled()) { #ifdef CONFIG_KVM uint8_t *hypercall; hypercall = g_malloc(16); kvmppc_get_hypercall(env, hypercall, 16); fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16); fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid()); #endif } fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, tbfreq); /* Mac OS X requires a "known good" clock-frequency value; pass it one. */ fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_CLOCKFREQ, CLOCKFREQ); fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_BUSFREQ, BUSFREQ); qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); }
true
qemu
b981289c493c7ddabc1cdf7de99daa24642c7739
static void ppc_heathrow_init(MachineState *machine) { ram_addr_t ram_size = machine->ram_size; const char *cpu_model = machine->cpu_model; const char *kernel_filename = machine->kernel_filename; const char *kernel_cmdline = machine->kernel_cmdline; const char *initrd_filename = machine->initrd_filename; const char *boot_device = machine->boot_order; MemoryRegion *sysmem = get_system_memory(); PowerPCCPU *cpu = NULL; CPUPPCState *env = NULL; char *filename; qemu_irq *pic, **heathrow_irqs; int linux_boot, i; MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *bios = g_new(MemoryRegion, 1); MemoryRegion *isa = g_new(MemoryRegion, 1); uint32_t kernel_base, initrd_base, cmdline_base = 0; int32_t kernel_size, initrd_size; PCIBus *pci_bus; PCIDevice *macio; MACIOIDEState *macio_ide; DeviceState *dev; BusState *adb_bus; int bios_size; MemoryRegion *pic_mem; MemoryRegion *escc_mem, *escc_bar = g_new(MemoryRegion, 1); uint16_t ppc_boot_device; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; void *fw_cfg; uint64_t tbfreq; linux_boot = (kernel_filename != NULL); if (cpu_model == NULL) cpu_model = "G3"; for (i = 0; i < smp_cpus; i++) { cpu = cpu_ppc_init(cpu_model); if (cpu == NULL) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); } env = &cpu->env; cpu_ppc_tb_init(env, TBFREQ); qemu_register_reset(ppc_heathrow_reset, cpu); } if (ram_size > (2047 << 20)) { fprintf(stderr, "qemu: Too much memory for this machine: %d MB, maximum 2047 MB\n", ((unsigned int)ram_size / (1 << 20))); exit(1); } memory_region_allocate_system_memory(ram, NULL, "ppc_heathrow.ram", ram_size); memory_region_add_subregion(sysmem, 0, ram); memory_region_init_ram(bios, NULL, "ppc_heathrow.bios", BIOS_SIZE); vmstate_register_ram_global(bios); if (bios_name == NULL) bios_name = PROM_FILENAME; filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); memory_region_set_readonly(bios, true); memory_region_add_subregion(sysmem, PROM_ADDR, bios); if (filename) { bios_size = load_elf(filename, 0, NULL, NULL, NULL, NULL, 1, ELF_MACHINE, 0); g_free(filename); } else { bios_size = -1; } if (bios_size < 0 || bios_size > BIOS_SIZE) { hw_error("qemu: could not load PowerPC bios '%s'\n", bios_name); exit(1); } if (linux_boot) { uint64_t lowaddr = 0; int bswap_needed; #ifdef BSWAP_NEEDED bswap_needed = 1; #else bswap_needed = 0; #endif kernel_base = KERNEL_LOAD_ADDR; kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL, NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0); if (kernel_size < 0) kernel_size = load_aout(kernel_filename, kernel_base, ram_size - kernel_base, bswap_needed, TARGET_PAGE_SIZE); if (kernel_size < 0) 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 = round_page(kernel_base + kernel_size + KERNEL_GAP); 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); exit(1); } cmdline_base = round_page(initrd_base + initrd_size); } else { initrd_base = 0; initrd_size = 0; cmdline_base = round_page(kernel_base + kernel_size + KERNEL_GAP); } 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 0 if (boot_device[i] >= 'a' && boot_device[i] <= 'f') { ppc_boot_device = boot_device[i]; break; } #else if (boot_device[i] >= 'c' && boot_device[i] <= 'd') { ppc_boot_device = boot_device[i]; break; } #endif } if (ppc_boot_device == '\0') { fprintf(stderr, "No valid boot device for G3 Beige machine\n"); exit(1); } } memory_region_init_alias(isa, NULL, "isa_mmio", get_system_io(), 0, 0x00200000); memory_region_add_subregion(sysmem, 0xfe000000, isa); heathrow_irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *)); heathrow_irqs[0] = g_malloc0(smp_cpus * sizeof(qemu_irq) * 1); for (i = 0; i < smp_cpus; i++) { switch (PPC_INPUT(env)) { case PPC_FLAGS_INPUT_6xx: heathrow_irqs[i] = heathrow_irqs[0] + (i * 1); heathrow_irqs[i][0] = ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT]; break; default: hw_error("Bus model not supported on OldWorld Mac machine\n"); } } if (kvm_enabled()) { tbfreq = kvmppc_get_tbfreq(); } else { tbfreq = TBFREQ; } if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) { hw_error("Only 6xx bus is supported on heathrow machine\n"); } pic = heathrow_pic_init(&pic_mem, 1, heathrow_irqs); pci_bus = pci_grackle_init(0xfec00000, pic, get_system_memory(), get_system_io()); pci_vga_init(pci_bus); escc_mem = escc_init(0, pic[0x0f], pic[0x10], serial_hds[0], serial_hds[1], ESCC_CLOCK, 4); memory_region_init_alias(escc_bar, NULL, "escc-bar", escc_mem, 0, memory_region_size(escc_mem)); for(i = 0; i < nb_nics; i++) pci_nic_init_nofail(&nd_table[i], pci_bus, "ne2k_pci", NULL); ide_drive_get(hd, MAX_IDE_BUS); macio = pci_create(pci_bus, -1, TYPE_OLDWORLD_MACIO); dev = DEVICE(macio); qdev_connect_gpio_out(dev, 0, pic[0x12]); qdev_connect_gpio_out(dev, 1, pic[0x0D]); qdev_connect_gpio_out(dev, 2, pic[0x02]); qdev_connect_gpio_out(dev, 3, pic[0x0E]); qdev_connect_gpio_out(dev, 4, pic[0x03]); macio_init(macio, pic_mem, escc_bar); macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio), "ide[0]")); macio_ide_init_drives(macio_ide, hd); macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio), "ide[1]")); macio_ide_init_drives(macio_ide, &hd[MAX_IDE_DEVS]); dev = DEVICE(object_resolve_path_component(OBJECT(macio), "cuda")); adb_bus = qdev_get_child_bus(dev, "adb.0"); dev = qdev_create(adb_bus, TYPE_ADB_KEYBOARD); qdev_init_nofail(dev); dev = qdev_create(adb_bus, TYPE_ADB_MOUSE); qdev_init_nofail(dev); if (usb_enabled(false)) { pci_create_simple(pci_bus, -1, "pci-ohci"); } if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8) graphic_depth = 15; fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2); fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus); fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1); fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_HEATHROW); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); if (kernel_cmdline) { fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, cmdline_base); pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE, kernel_cmdline); } else { fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0); } fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_base); fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ppc_boot_device); fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width); fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height); fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth); fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled()); if (kvm_enabled()) { #ifdef CONFIG_KVM uint8_t *hypercall; hypercall = g_malloc(16); kvmppc_get_hypercall(env, hypercall, 16); fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16); fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid()); #endif } fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, tbfreq); fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_CLOCKFREQ, CLOCKFREQ); fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_BUSFREQ, BUSFREQ); qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); }
{ "code": [], "line_no": [] }
static void FUNC_0(MachineState *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; char *VAR_6; qemu_irq *pic, **heathrow_irqs; int VAR_7, VAR_8; MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *bios = g_new(MemoryRegion, 1); MemoryRegion *isa = g_new(MemoryRegion, 1); uint32_t kernel_base, initrd_base, cmdline_base = 0; int32_t kernel_size, initrd_size; PCIBus *pci_bus; PCIDevice *macio; MACIOIDEState *macio_ide; DeviceState *dev; BusState *adb_bus; int VAR_9; MemoryRegion *pic_mem; MemoryRegion *escc_mem, *escc_bar = g_new(MemoryRegion, 1); uint16_t ppc_boot_device; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; void *VAR_10; uint64_t tbfreq; VAR_7 = (VAR_2 != NULL); if (VAR_1 == NULL) VAR_1 = "G3"; for (VAR_8 = 0; VAR_8 < smp_cpus; VAR_8++) { cpu = cpu_ppc_init(VAR_1); if (cpu == NULL) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); } env = &cpu->env; cpu_ppc_tb_init(env, TBFREQ); qemu_register_reset(ppc_heathrow_reset, cpu); } if (ram_size > (2047 << 20)) { fprintf(stderr, "qemu: Too much memory for this VAR_0: %d MB, maximum 2047 MB\n", ((unsigned int)ram_size / (1 << 20))); exit(1); } memory_region_allocate_system_memory(ram, NULL, "ppc_heathrow.ram", ram_size); memory_region_add_subregion(sysmem, 0, ram); memory_region_init_ram(bios, NULL, "ppc_heathrow.bios", BIOS_SIZE); vmstate_register_ram_global(bios); if (bios_name == NULL) bios_name = PROM_FILENAME; VAR_6 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); memory_region_set_readonly(bios, true); memory_region_add_subregion(sysmem, PROM_ADDR, bios); if (VAR_6) { VAR_9 = load_elf(VAR_6, 0, NULL, NULL, NULL, NULL, 1, ELF_MACHINE, 0); g_free(VAR_6); } else { VAR_9 = -1; } if (VAR_9 < 0 || VAR_9 > BIOS_SIZE) { hw_error("qemu: could not load PowerPC bios '%s'\n", bios_name); exit(1); } if (VAR_7) { uint64_t lowaddr = 0; int VAR_11; #ifdef BSWAP_NEEDED VAR_11 = 1; #else VAR_11 = 0; #endif kernel_base = KERNEL_LOAD_ADDR; kernel_size = load_elf(VAR_2, translate_kernel_address, NULL, NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0); if (kernel_size < 0) kernel_size = load_aout(VAR_2, kernel_base, ram_size - kernel_base, VAR_11, TARGET_PAGE_SIZE); if (kernel_size < 0) kernel_size = load_image_targphys(VAR_2, kernel_base, ram_size - kernel_base); if (kernel_size < 0) { hw_error("qemu: could not load kernel '%s'\n", VAR_2); exit(1); } if (VAR_4) { initrd_base = round_page(kernel_base + kernel_size + KERNEL_GAP); initrd_size = load_image_targphys(VAR_4, initrd_base, ram_size - initrd_base); if (initrd_size < 0) { hw_error("qemu: could not load initial ram disk '%s'\n", VAR_4); exit(1); } cmdline_base = round_page(initrd_base + initrd_size); } else { initrd_base = 0; initrd_size = 0; cmdline_base = round_page(kernel_base + kernel_size + KERNEL_GAP); } ppc_boot_device = 'm'; } else { kernel_base = 0; kernel_size = 0; initrd_base = 0; initrd_size = 0; ppc_boot_device = '\0'; for (VAR_8 = 0; VAR_5[VAR_8] != '\0'; VAR_8++) { #if 0 if (VAR_5[VAR_8] >= 'a' && VAR_5[VAR_8] <= 'f') { ppc_boot_device = VAR_5[VAR_8]; break; } #else if (VAR_5[VAR_8] >= 'c' && VAR_5[VAR_8] <= 'd') { ppc_boot_device = VAR_5[VAR_8]; break; } #endif } if (ppc_boot_device == '\0') { fprintf(stderr, "No valid boot device for G3 Beige VAR_0\n"); exit(1); } } memory_region_init_alias(isa, NULL, "isa_mmio", get_system_io(), 0, 0x00200000); memory_region_add_subregion(sysmem, 0xfe000000, isa); heathrow_irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *)); heathrow_irqs[0] = g_malloc0(smp_cpus * sizeof(qemu_irq) * 1); for (VAR_8 = 0; VAR_8 < smp_cpus; VAR_8++) { switch (PPC_INPUT(env)) { case PPC_FLAGS_INPUT_6xx: heathrow_irqs[VAR_8] = heathrow_irqs[0] + (VAR_8 * 1); heathrow_irqs[VAR_8][0] = ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT]; break; default: hw_error("Bus model not supported on OldWorld Mac VAR_0\n"); } } if (kvm_enabled()) { tbfreq = kvmppc_get_tbfreq(); } else { tbfreq = TBFREQ; } if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) { hw_error("Only 6xx bus is supported on heathrow VAR_0\n"); } pic = heathrow_pic_init(&pic_mem, 1, heathrow_irqs); pci_bus = pci_grackle_init(0xfec00000, pic, get_system_memory(), get_system_io()); pci_vga_init(pci_bus); escc_mem = escc_init(0, pic[0x0f], pic[0x10], serial_hds[0], serial_hds[1], ESCC_CLOCK, 4); memory_region_init_alias(escc_bar, NULL, "escc-bar", escc_mem, 0, memory_region_size(escc_mem)); for(VAR_8 = 0; VAR_8 < nb_nics; VAR_8++) pci_nic_init_nofail(&nd_table[VAR_8], pci_bus, "ne2k_pci", NULL); ide_drive_get(hd, MAX_IDE_BUS); macio = pci_create(pci_bus, -1, TYPE_OLDWORLD_MACIO); dev = DEVICE(macio); qdev_connect_gpio_out(dev, 0, pic[0x12]); qdev_connect_gpio_out(dev, 1, pic[0x0D]); qdev_connect_gpio_out(dev, 2, pic[0x02]); qdev_connect_gpio_out(dev, 3, pic[0x0E]); qdev_connect_gpio_out(dev, 4, pic[0x03]); macio_init(macio, pic_mem, escc_bar); macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio), "ide[0]")); macio_ide_init_drives(macio_ide, hd); macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio), "ide[1]")); macio_ide_init_drives(macio_ide, &hd[MAX_IDE_DEVS]); dev = DEVICE(object_resolve_path_component(OBJECT(macio), "cuda")); adb_bus = qdev_get_child_bus(dev, "adb.0"); dev = qdev_create(adb_bus, TYPE_ADB_KEYBOARD); qdev_init_nofail(dev); dev = qdev_create(adb_bus, TYPE_ADB_MOUSE); qdev_init_nofail(dev); if (usb_enabled(false)) { pci_create_simple(pci_bus, -1, "pci-ohci"); } if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8) graphic_depth = 15; VAR_10 = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2); fw_cfg_add_i16(VAR_10, FW_CFG_MAX_CPUS, (uint16_t)max_cpus); fw_cfg_add_i32(VAR_10, FW_CFG_ID, 1); fw_cfg_add_i64(VAR_10, FW_CFG_RAM_SIZE, (uint64_t)ram_size); fw_cfg_add_i16(VAR_10, FW_CFG_MACHINE_ID, ARCH_HEATHROW); fw_cfg_add_i32(VAR_10, FW_CFG_KERNEL_ADDR, kernel_base); fw_cfg_add_i32(VAR_10, FW_CFG_KERNEL_SIZE, kernel_size); if (VAR_3) { fw_cfg_add_i32(VAR_10, FW_CFG_KERNEL_CMDLINE, cmdline_base); pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE, VAR_3); } else { fw_cfg_add_i32(VAR_10, FW_CFG_KERNEL_CMDLINE, 0); } fw_cfg_add_i32(VAR_10, FW_CFG_INITRD_ADDR, initrd_base); fw_cfg_add_i32(VAR_10, FW_CFG_INITRD_SIZE, initrd_size); fw_cfg_add_i16(VAR_10, FW_CFG_BOOT_DEVICE, ppc_boot_device); fw_cfg_add_i16(VAR_10, FW_CFG_PPC_WIDTH, graphic_width); fw_cfg_add_i16(VAR_10, FW_CFG_PPC_HEIGHT, graphic_height); fw_cfg_add_i16(VAR_10, FW_CFG_PPC_DEPTH, graphic_depth); fw_cfg_add_i32(VAR_10, FW_CFG_PPC_IS_KVM, kvm_enabled()); if (kvm_enabled()) { #ifdef CONFIG_KVM uint8_t *hypercall; hypercall = g_malloc(16); kvmppc_get_hypercall(env, hypercall, 16); fw_cfg_add_bytes(VAR_10, FW_CFG_PPC_KVM_HC, hypercall, 16); fw_cfg_add_i32(VAR_10, FW_CFG_PPC_KVM_PID, getpid()); #endif } fw_cfg_add_i32(VAR_10, FW_CFG_PPC_TBFREQ, tbfreq); fw_cfg_add_i32(VAR_10, FW_CFG_PPC_CLOCKFREQ, CLOCKFREQ); fw_cfg_add_i32(VAR_10, FW_CFG_PPC_BUSFREQ, BUSFREQ); qemu_register_boot_set(fw_cfg_boot_set, VAR_10); }
[ "static void FUNC_0(MachineState *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;", "char *VAR_6;", "qemu_irq *pic, **heathrow_irqs;", "int VAR_7, VAR_8;", "MemoryRegion *ram = g_new(MemoryRegion, 1);", "MemoryRegion *bios = g_new(MemoryRegion, 1);", "MemoryRegion *isa = g_new(MemoryRegion, 1);", "uint32_t kernel_base, initrd_base, cmdline_base = 0;", "int32_t kernel_size, initrd_size;", "PCIBus *pci_bus;", "PCIDevice *macio;", "MACIOIDEState *macio_ide;", "DeviceState *dev;", "BusState *adb_bus;", "int VAR_9;", "MemoryRegion *pic_mem;", "MemoryRegion *escc_mem, *escc_bar = g_new(MemoryRegion, 1);", "uint16_t ppc_boot_device;", "DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];", "void *VAR_10;", "uint64_t tbfreq;", "VAR_7 = (VAR_2 != NULL);", "if (VAR_1 == NULL)\nVAR_1 = \"G3\";", "for (VAR_8 = 0; VAR_8 < smp_cpus; VAR_8++) {", "cpu = cpu_ppc_init(VAR_1);", "if (cpu == NULL) {", "fprintf(stderr, \"Unable to find PowerPC CPU definition\\n\");", "exit(1);", "}", "env = &cpu->env;", "cpu_ppc_tb_init(env, TBFREQ);", "qemu_register_reset(ppc_heathrow_reset, cpu);", "}", "if (ram_size > (2047 << 20)) {", "fprintf(stderr,\n\"qemu: Too much memory for this VAR_0: %d MB, maximum 2047 MB\\n\",\n((unsigned int)ram_size / (1 << 20)));", "exit(1);", "}", "memory_region_allocate_system_memory(ram, NULL, \"ppc_heathrow.ram\",\nram_size);", "memory_region_add_subregion(sysmem, 0, ram);", "memory_region_init_ram(bios, NULL, \"ppc_heathrow.bios\", BIOS_SIZE);", "vmstate_register_ram_global(bios);", "if (bios_name == NULL)\nbios_name = PROM_FILENAME;", "VAR_6 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);", "memory_region_set_readonly(bios, true);", "memory_region_add_subregion(sysmem, PROM_ADDR, bios);", "if (VAR_6) {", "VAR_9 = load_elf(VAR_6, 0, NULL, NULL, NULL, NULL,\n1, ELF_MACHINE, 0);", "g_free(VAR_6);", "} else {", "VAR_9 = -1;", "}", "if (VAR_9 < 0 || VAR_9 > BIOS_SIZE) {", "hw_error(\"qemu: could not load PowerPC bios '%s'\\n\", bios_name);", "exit(1);", "}", "if (VAR_7) {", "uint64_t lowaddr = 0;", "int VAR_11;", "#ifdef BSWAP_NEEDED\nVAR_11 = 1;", "#else\nVAR_11 = 0;", "#endif\nkernel_base = KERNEL_LOAD_ADDR;", "kernel_size = load_elf(VAR_2, translate_kernel_address, NULL,\nNULL, &lowaddr, NULL, 1, ELF_MACHINE, 0);", "if (kernel_size < 0)\nkernel_size = load_aout(VAR_2, kernel_base,\nram_size - kernel_base, VAR_11,\nTARGET_PAGE_SIZE);", "if (kernel_size < 0)\nkernel_size = load_image_targphys(VAR_2,\nkernel_base,\nram_size - kernel_base);", "if (kernel_size < 0) {", "hw_error(\"qemu: could not load kernel '%s'\\n\",\nVAR_2);", "exit(1);", "}", "if (VAR_4) {", "initrd_base = round_page(kernel_base + kernel_size + KERNEL_GAP);", "initrd_size = load_image_targphys(VAR_4, initrd_base,\nram_size - initrd_base);", "if (initrd_size < 0) {", "hw_error(\"qemu: could not load initial ram disk '%s'\\n\",\nVAR_4);", "exit(1);", "}", "cmdline_base = round_page(initrd_base + initrd_size);", "} else {", "initrd_base = 0;", "initrd_size = 0;", "cmdline_base = round_page(kernel_base + kernel_size + KERNEL_GAP);", "}", "ppc_boot_device = 'm';", "} else {", "kernel_base = 0;", "kernel_size = 0;", "initrd_base = 0;", "initrd_size = 0;", "ppc_boot_device = '\\0';", "for (VAR_8 = 0; VAR_5[VAR_8] != '\\0'; VAR_8++) {", "#if 0\nif (VAR_5[VAR_8] >= 'a' && VAR_5[VAR_8] <= 'f') {", "ppc_boot_device = VAR_5[VAR_8];", "break;", "}", "#else\nif (VAR_5[VAR_8] >= 'c' && VAR_5[VAR_8] <= 'd') {", "ppc_boot_device = VAR_5[VAR_8];", "break;", "}", "#endif\n}", "if (ppc_boot_device == '\\0') {", "fprintf(stderr, \"No valid boot device for G3 Beige VAR_0\\n\");", "exit(1);", "}", "}", "memory_region_init_alias(isa, NULL, \"isa_mmio\",\nget_system_io(), 0, 0x00200000);", "memory_region_add_subregion(sysmem, 0xfe000000, isa);", "heathrow_irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *));", "heathrow_irqs[0] =\ng_malloc0(smp_cpus * sizeof(qemu_irq) * 1);", "for (VAR_8 = 0; VAR_8 < smp_cpus; VAR_8++) {", "switch (PPC_INPUT(env)) {", "case PPC_FLAGS_INPUT_6xx:\nheathrow_irqs[VAR_8] = heathrow_irqs[0] + (VAR_8 * 1);", "heathrow_irqs[VAR_8][0] =\n((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT];", "break;", "default:\nhw_error(\"Bus model not supported on OldWorld Mac VAR_0\\n\");", "}", "}", "if (kvm_enabled()) {", "tbfreq = kvmppc_get_tbfreq();", "} else {", "tbfreq = TBFREQ;", "}", "if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {", "hw_error(\"Only 6xx bus is supported on heathrow VAR_0\\n\");", "}", "pic = heathrow_pic_init(&pic_mem, 1, heathrow_irqs);", "pci_bus = pci_grackle_init(0xfec00000, pic,\nget_system_memory(),\nget_system_io());", "pci_vga_init(pci_bus);", "escc_mem = escc_init(0, pic[0x0f], pic[0x10], serial_hds[0],\nserial_hds[1], ESCC_CLOCK, 4);", "memory_region_init_alias(escc_bar, NULL, \"escc-bar\",\nescc_mem, 0, memory_region_size(escc_mem));", "for(VAR_8 = 0; VAR_8 < nb_nics; VAR_8++)", "pci_nic_init_nofail(&nd_table[VAR_8], pci_bus, \"ne2k_pci\", NULL);", "ide_drive_get(hd, MAX_IDE_BUS);", "macio = pci_create(pci_bus, -1, TYPE_OLDWORLD_MACIO);", "dev = DEVICE(macio);", "qdev_connect_gpio_out(dev, 0, pic[0x12]);", "qdev_connect_gpio_out(dev, 1, pic[0x0D]);", "qdev_connect_gpio_out(dev, 2, pic[0x02]);", "qdev_connect_gpio_out(dev, 3, pic[0x0E]);", "qdev_connect_gpio_out(dev, 4, pic[0x03]);", "macio_init(macio, pic_mem, escc_bar);", "macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio),\n\"ide[0]\"));", "macio_ide_init_drives(macio_ide, hd);", "macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio),\n\"ide[1]\"));", "macio_ide_init_drives(macio_ide, &hd[MAX_IDE_DEVS]);", "dev = DEVICE(object_resolve_path_component(OBJECT(macio), \"cuda\"));", "adb_bus = qdev_get_child_bus(dev, \"adb.0\");", "dev = qdev_create(adb_bus, TYPE_ADB_KEYBOARD);", "qdev_init_nofail(dev);", "dev = qdev_create(adb_bus, TYPE_ADB_MOUSE);", "qdev_init_nofail(dev);", "if (usb_enabled(false)) {", "pci_create_simple(pci_bus, -1, \"pci-ohci\");", "}", "if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)\ngraphic_depth = 15;", "VAR_10 = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);", "fw_cfg_add_i16(VAR_10, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);", "fw_cfg_add_i32(VAR_10, FW_CFG_ID, 1);", "fw_cfg_add_i64(VAR_10, FW_CFG_RAM_SIZE, (uint64_t)ram_size);", "fw_cfg_add_i16(VAR_10, FW_CFG_MACHINE_ID, ARCH_HEATHROW);", "fw_cfg_add_i32(VAR_10, FW_CFG_KERNEL_ADDR, kernel_base);", "fw_cfg_add_i32(VAR_10, FW_CFG_KERNEL_SIZE, kernel_size);", "if (VAR_3) {", "fw_cfg_add_i32(VAR_10, FW_CFG_KERNEL_CMDLINE, cmdline_base);", "pstrcpy_targphys(\"cmdline\", cmdline_base, TARGET_PAGE_SIZE, VAR_3);", "} else {", "fw_cfg_add_i32(VAR_10, FW_CFG_KERNEL_CMDLINE, 0);", "}", "fw_cfg_add_i32(VAR_10, FW_CFG_INITRD_ADDR, initrd_base);", "fw_cfg_add_i32(VAR_10, FW_CFG_INITRD_SIZE, initrd_size);", "fw_cfg_add_i16(VAR_10, FW_CFG_BOOT_DEVICE, ppc_boot_device);", "fw_cfg_add_i16(VAR_10, FW_CFG_PPC_WIDTH, graphic_width);", "fw_cfg_add_i16(VAR_10, FW_CFG_PPC_HEIGHT, graphic_height);", "fw_cfg_add_i16(VAR_10, FW_CFG_PPC_DEPTH, graphic_depth);", "fw_cfg_add_i32(VAR_10, FW_CFG_PPC_IS_KVM, kvm_enabled());", "if (kvm_enabled()) {", "#ifdef CONFIG_KVM\nuint8_t *hypercall;", "hypercall = g_malloc(16);", "kvmppc_get_hypercall(env, hypercall, 16);", "fw_cfg_add_bytes(VAR_10, FW_CFG_PPC_KVM_HC, hypercall, 16);", "fw_cfg_add_i32(VAR_10, FW_CFG_PPC_KVM_PID, getpid());", "#endif\n}", "fw_cfg_add_i32(VAR_10, FW_CFG_PPC_TBFREQ, tbfreq);", "fw_cfg_add_i32(VAR_10, FW_CFG_PPC_CLOCKFREQ, CLOCKFREQ);", "fw_cfg_add_i32(VAR_10, FW_CFG_PPC_BUSFREQ, BUSFREQ);", "qemu_register_boot_set(fw_cfg_boot_set, VAR_10);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 65 ], [ 71, 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 93 ], [ 95 ], [ 97 ], [ 103 ], [ 105, 107, 109 ], [ 111 ], [ 113 ], [ 117, 119 ], [ 121 ], [ 127 ], [ 129 ], [ 133, 135 ], [ 137 ], [ 139 ], [ 141 ], [ 147 ], [ 149, 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 171 ], [ 173 ], [ 175 ], [ 179, 181 ], [ 183, 185 ], [ 187, 189 ], [ 191, 193 ], [ 195, 197, 199, 201 ], [ 203, 205, 207, 209 ], [ 211 ], [ 213, 215 ], [ 217 ], [ 219 ], [ 223 ], [ 225 ], [ 227, 229 ], [ 231 ], [ 233, 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 277, 279 ], [ 281 ], [ 283 ], [ 285 ], [ 287, 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297, 299 ], [ 301 ], [ 303 ], [ 305 ], [ 307 ], [ 309 ], [ 315, 317 ], [ 319 ], [ 325 ], [ 327, 329 ], [ 333 ], [ 335 ], [ 337, 339 ], [ 341, 343 ], [ 345 ], [ 347, 349 ], [ 351 ], [ 353 ], [ 359 ], [ 361 ], [ 363 ], [ 365 ], [ 367 ], [ 373 ], [ 375 ], [ 377 ], [ 379 ], [ 381, 383, 385 ], [ 387 ], [ 391, 393 ], [ 395, 397 ], [ 401 ], [ 403 ], [ 409 ], [ 413 ], [ 415 ], [ 417 ], [ 419 ], [ 421 ], [ 423 ], [ 425 ], [ 428 ], [ 432, 434 ], [ 436 ], [ 440, 442 ], [ 444 ], [ 448 ], [ 450 ], [ 452 ], [ 454 ], [ 456 ], [ 458 ], [ 462 ], [ 464 ], [ 466 ], [ 470, 472 ], [ 480 ], [ 482 ], [ 484 ], [ 486 ], [ 488 ], [ 490 ], [ 492 ], [ 494 ], [ 496 ], [ 498 ], [ 500 ], [ 502 ], [ 504 ], [ 506 ], [ 508 ], [ 510 ], [ 514 ], [ 516 ], [ 518 ], [ 522 ], [ 524 ], [ 526, 528 ], [ 532 ], [ 534 ], [ 536 ], [ 538 ], [ 540, 542 ], [ 544 ], [ 548 ], [ 550 ], [ 554 ], [ 556 ] ]
699
static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb) { int i; int dc_y_table; int dc_c_table; int ac_y_table; int ac_c_table; int residual_eob_run = 0; VLC *y_tables[64]; VLC *c_tables[64]; s->dct_tokens[0][0] = s->dct_tokens_base; if (get_bits_left(gb) < 16) /* fetch the DC table indexes */ dc_y_table = get_bits(gb, 4); dc_c_table = get_bits(gb, 4); /* unpack the Y plane DC coefficients */ residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_y_table], 0, 0, residual_eob_run); if (residual_eob_run < 0) return residual_eob_run; /* reverse prediction of the Y-plane DC coefficients */ reverse_dc_prediction(s, 0, s->fragment_width[0], s->fragment_height[0]); /* unpack the C plane DC coefficients */ residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0, 1, residual_eob_run); if (residual_eob_run < 0) return residual_eob_run; residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0, 2, residual_eob_run); if (residual_eob_run < 0) return residual_eob_run; /* reverse prediction of the C-plane DC coefficients */ if (!(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { reverse_dc_prediction(s, s->fragment_start[1], s->fragment_width[1], s->fragment_height[1]); reverse_dc_prediction(s, s->fragment_start[2], s->fragment_width[1], s->fragment_height[1]); } /* fetch the AC table indexes */ ac_y_table = get_bits(gb, 4); ac_c_table = get_bits(gb, 4); /* build tables of AC VLC tables */ for (i = 1; i <= 5; i++) { y_tables[i] = &s->ac_vlc_1[ac_y_table]; c_tables[i] = &s->ac_vlc_1[ac_c_table]; } for (i = 6; i <= 14; i++) { y_tables[i] = &s->ac_vlc_2[ac_y_table]; c_tables[i] = &s->ac_vlc_2[ac_c_table]; } for (i = 15; i <= 27; i++) { y_tables[i] = &s->ac_vlc_3[ac_y_table]; c_tables[i] = &s->ac_vlc_3[ac_c_table]; } for (i = 28; i <= 63; i++) { y_tables[i] = &s->ac_vlc_4[ac_y_table]; c_tables[i] = &s->ac_vlc_4[ac_c_table]; } /* decode all AC coefficients */ for (i = 1; i <= 63; i++) { residual_eob_run = unpack_vlcs(s, gb, y_tables[i], i, 0, residual_eob_run); if (residual_eob_run < 0) return residual_eob_run; residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i, 1, residual_eob_run); if (residual_eob_run < 0) return residual_eob_run; residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i, 2, residual_eob_run); if (residual_eob_run < 0) return residual_eob_run; } return 0; }
true
FFmpeg
2f00300b779e7b247c85db0d7daef448225105ff
static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb) { int i; int dc_y_table; int dc_c_table; int ac_y_table; int ac_c_table; int residual_eob_run = 0; VLC *y_tables[64]; VLC *c_tables[64]; s->dct_tokens[0][0] = s->dct_tokens_base; if (get_bits_left(gb) < 16) dc_y_table = get_bits(gb, 4); dc_c_table = get_bits(gb, 4); residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_y_table], 0, 0, residual_eob_run); if (residual_eob_run < 0) return residual_eob_run; reverse_dc_prediction(s, 0, s->fragment_width[0], s->fragment_height[0]); residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0, 1, residual_eob_run); if (residual_eob_run < 0) return residual_eob_run; residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0, 2, residual_eob_run); if (residual_eob_run < 0) return residual_eob_run; if (!(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { reverse_dc_prediction(s, s->fragment_start[1], s->fragment_width[1], s->fragment_height[1]); reverse_dc_prediction(s, s->fragment_start[2], s->fragment_width[1], s->fragment_height[1]); } ac_y_table = get_bits(gb, 4); ac_c_table = get_bits(gb, 4); for (i = 1; i <= 5; i++) { y_tables[i] = &s->ac_vlc_1[ac_y_table]; c_tables[i] = &s->ac_vlc_1[ac_c_table]; } for (i = 6; i <= 14; i++) { y_tables[i] = &s->ac_vlc_2[ac_y_table]; c_tables[i] = &s->ac_vlc_2[ac_c_table]; } for (i = 15; i <= 27; i++) { y_tables[i] = &s->ac_vlc_3[ac_y_table]; c_tables[i] = &s->ac_vlc_3[ac_c_table]; } for (i = 28; i <= 63; i++) { y_tables[i] = &s->ac_vlc_4[ac_y_table]; c_tables[i] = &s->ac_vlc_4[ac_c_table]; } for (i = 1; i <= 63; i++) { residual_eob_run = unpack_vlcs(s, gb, y_tables[i], i, 0, residual_eob_run); if (residual_eob_run < 0) return residual_eob_run; residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i, 1, residual_eob_run); if (residual_eob_run < 0) return residual_eob_run; residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i, 2, residual_eob_run); if (residual_eob_run < 0) return residual_eob_run; } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(Vp3DecodeContext *VAR_0, GetBitContext *VAR_1) { int VAR_2; int VAR_3; int VAR_4; int VAR_5; int VAR_6; int VAR_7 = 0; VLC *y_tables[64]; VLC *c_tables[64]; VAR_0->dct_tokens[0][0] = VAR_0->dct_tokens_base; if (get_bits_left(VAR_1) < 16) VAR_3 = get_bits(VAR_1, 4); VAR_4 = get_bits(VAR_1, 4); VAR_7 = unpack_vlcs(VAR_0, VAR_1, &VAR_0->dc_vlc[VAR_3], 0, 0, VAR_7); if (VAR_7 < 0) return VAR_7; reverse_dc_prediction(VAR_0, 0, VAR_0->fragment_width[0], VAR_0->fragment_height[0]); VAR_7 = unpack_vlcs(VAR_0, VAR_1, &VAR_0->dc_vlc[VAR_4], 0, 1, VAR_7); if (VAR_7 < 0) return VAR_7; VAR_7 = unpack_vlcs(VAR_0, VAR_1, &VAR_0->dc_vlc[VAR_4], 0, 2, VAR_7); if (VAR_7 < 0) return VAR_7; if (!(VAR_0->avctx->flags & AV_CODEC_FLAG_GRAY)) { reverse_dc_prediction(VAR_0, VAR_0->fragment_start[1], VAR_0->fragment_width[1], VAR_0->fragment_height[1]); reverse_dc_prediction(VAR_0, VAR_0->fragment_start[2], VAR_0->fragment_width[1], VAR_0->fragment_height[1]); } VAR_5 = get_bits(VAR_1, 4); VAR_6 = get_bits(VAR_1, 4); for (VAR_2 = 1; VAR_2 <= 5; VAR_2++) { y_tables[VAR_2] = &VAR_0->ac_vlc_1[VAR_5]; c_tables[VAR_2] = &VAR_0->ac_vlc_1[VAR_6]; } for (VAR_2 = 6; VAR_2 <= 14; VAR_2++) { y_tables[VAR_2] = &VAR_0->ac_vlc_2[VAR_5]; c_tables[VAR_2] = &VAR_0->ac_vlc_2[VAR_6]; } for (VAR_2 = 15; VAR_2 <= 27; VAR_2++) { y_tables[VAR_2] = &VAR_0->ac_vlc_3[VAR_5]; c_tables[VAR_2] = &VAR_0->ac_vlc_3[VAR_6]; } for (VAR_2 = 28; VAR_2 <= 63; VAR_2++) { y_tables[VAR_2] = &VAR_0->ac_vlc_4[VAR_5]; c_tables[VAR_2] = &VAR_0->ac_vlc_4[VAR_6]; } for (VAR_2 = 1; VAR_2 <= 63; VAR_2++) { VAR_7 = unpack_vlcs(VAR_0, VAR_1, y_tables[VAR_2], VAR_2, 0, VAR_7); if (VAR_7 < 0) return VAR_7; VAR_7 = unpack_vlcs(VAR_0, VAR_1, c_tables[VAR_2], VAR_2, 1, VAR_7); if (VAR_7 < 0) return VAR_7; VAR_7 = unpack_vlcs(VAR_0, VAR_1, c_tables[VAR_2], VAR_2, 2, VAR_7); if (VAR_7 < 0) return VAR_7; } return 0; }
[ "static int FUNC_0(Vp3DecodeContext *VAR_0, GetBitContext *VAR_1)\n{", "int VAR_2;", "int VAR_3;", "int VAR_4;", "int VAR_5;", "int VAR_6;", "int VAR_7 = 0;", "VLC *y_tables[64];", "VLC *c_tables[64];", "VAR_0->dct_tokens[0][0] = VAR_0->dct_tokens_base;", "if (get_bits_left(VAR_1) < 16)\nVAR_3 = get_bits(VAR_1, 4);", "VAR_4 = get_bits(VAR_1, 4);", "VAR_7 = unpack_vlcs(VAR_0, VAR_1, &VAR_0->dc_vlc[VAR_3], 0,\n0, VAR_7);", "if (VAR_7 < 0)\nreturn VAR_7;", "reverse_dc_prediction(VAR_0, 0, VAR_0->fragment_width[0], VAR_0->fragment_height[0]);", "VAR_7 = unpack_vlcs(VAR_0, VAR_1, &VAR_0->dc_vlc[VAR_4], 0,\n1, VAR_7);", "if (VAR_7 < 0)\nreturn VAR_7;", "VAR_7 = unpack_vlcs(VAR_0, VAR_1, &VAR_0->dc_vlc[VAR_4], 0,\n2, VAR_7);", "if (VAR_7 < 0)\nreturn VAR_7;", "if (!(VAR_0->avctx->flags & AV_CODEC_FLAG_GRAY)) {", "reverse_dc_prediction(VAR_0, VAR_0->fragment_start[1],\nVAR_0->fragment_width[1], VAR_0->fragment_height[1]);", "reverse_dc_prediction(VAR_0, VAR_0->fragment_start[2],\nVAR_0->fragment_width[1], VAR_0->fragment_height[1]);", "}", "VAR_5 = get_bits(VAR_1, 4);", "VAR_6 = get_bits(VAR_1, 4);", "for (VAR_2 = 1; VAR_2 <= 5; VAR_2++) {", "y_tables[VAR_2] = &VAR_0->ac_vlc_1[VAR_5];", "c_tables[VAR_2] = &VAR_0->ac_vlc_1[VAR_6];", "}", "for (VAR_2 = 6; VAR_2 <= 14; VAR_2++) {", "y_tables[VAR_2] = &VAR_0->ac_vlc_2[VAR_5];", "c_tables[VAR_2] = &VAR_0->ac_vlc_2[VAR_6];", "}", "for (VAR_2 = 15; VAR_2 <= 27; VAR_2++) {", "y_tables[VAR_2] = &VAR_0->ac_vlc_3[VAR_5];", "c_tables[VAR_2] = &VAR_0->ac_vlc_3[VAR_6];", "}", "for (VAR_2 = 28; VAR_2 <= 63; VAR_2++) {", "y_tables[VAR_2] = &VAR_0->ac_vlc_4[VAR_5];", "c_tables[VAR_2] = &VAR_0->ac_vlc_4[VAR_6];", "}", "for (VAR_2 = 1; VAR_2 <= 63; VAR_2++) {", "VAR_7 = unpack_vlcs(VAR_0, VAR_1, y_tables[VAR_2], VAR_2,\n0, VAR_7);", "if (VAR_7 < 0)\nreturn VAR_7;", "VAR_7 = unpack_vlcs(VAR_0, VAR_1, c_tables[VAR_2], VAR_2,\n1, VAR_7);", "if (VAR_7 < 0)\nreturn VAR_7;", "VAR_7 = unpack_vlcs(VAR_0, VAR_1, c_tables[VAR_2], VAR_2,\n2, VAR_7);", "if (VAR_7 < 0)\nreturn 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, 0, 0, 0, 0, 0, 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 ], [ 27, 34 ], [ 36 ], [ 42, 44 ], [ 46, 48 ], [ 56 ], [ 62, 64 ], [ 66, 68 ], [ 70, 72 ], [ 74, 76 ], [ 82 ], [ 84, 86 ], [ 88, 90 ], [ 92 ], [ 100 ], [ 102 ], [ 108 ], [ 110 ], [ 112 ], [ 114 ], [ 116 ], [ 118 ], [ 120 ], [ 122 ], [ 124 ], [ 126 ], [ 128 ], [ 130 ], [ 132 ], [ 134 ], [ 136 ], [ 138 ], [ 144 ], [ 146, 148 ], [ 150, 152 ], [ 156, 158 ], [ 160, 162 ], [ 164, 166 ], [ 168, 170 ], [ 172 ], [ 176 ], [ 178 ] ]
700
static void free_device_list(AVOpenCLDeviceList *device_list) { int i, j; if (!device_list) return; for (i = 0; i < device_list->platform_num; i++) { if (!device_list->platform_node[i]) continue; for (j = 0; j < device_list->platform_node[i]->device_num; j++) { av_freep(&(device_list->platform_node[i]->device_node[j]->device_name)); av_freep(&(device_list->platform_node[i]->device_node[j])); } av_freep(&device_list->platform_node[i]->device_node); av_freep(&(device_list->platform_node[i]->platform_name)); av_freep(&device_list->platform_node[i]); } av_freep(&device_list->platform_node); device_list->platform_num = 0; }
true
FFmpeg
ef0c6d9b01de773e5a1177de5fcbb981aac44d65
static void free_device_list(AVOpenCLDeviceList *device_list) { int i, j; if (!device_list) return; for (i = 0; i < device_list->platform_num; i++) { if (!device_list->platform_node[i]) continue; for (j = 0; j < device_list->platform_node[i]->device_num; j++) { av_freep(&(device_list->platform_node[i]->device_node[j]->device_name)); av_freep(&(device_list->platform_node[i]->device_node[j])); } av_freep(&device_list->platform_node[i]->device_node); av_freep(&(device_list->platform_node[i]->platform_name)); av_freep(&device_list->platform_node[i]); } av_freep(&device_list->platform_node); device_list->platform_num = 0; }
{ "code": [ " if (!device_list)" ], "line_no": [ 7 ] }
static void FUNC_0(AVOpenCLDeviceList *VAR_0) { int VAR_1, VAR_2; if (!VAR_0) return; for (VAR_1 = 0; VAR_1 < VAR_0->platform_num; VAR_1++) { if (!VAR_0->platform_node[VAR_1]) continue; for (VAR_2 = 0; VAR_2 < VAR_0->platform_node[VAR_1]->device_num; VAR_2++) { av_freep(&(VAR_0->platform_node[VAR_1]->device_node[VAR_2]->device_name)); av_freep(&(VAR_0->platform_node[VAR_1]->device_node[VAR_2])); } av_freep(&VAR_0->platform_node[VAR_1]->device_node); av_freep(&(VAR_0->platform_node[VAR_1]->platform_name)); av_freep(&VAR_0->platform_node[VAR_1]); } av_freep(&VAR_0->platform_node); VAR_0->platform_num = 0; }
[ "static void FUNC_0(AVOpenCLDeviceList *VAR_0)\n{", "int VAR_1, VAR_2;", "if (!VAR_0)\nreturn;", "for (VAR_1 = 0; VAR_1 < VAR_0->platform_num; VAR_1++) {", "if (!VAR_0->platform_node[VAR_1])\ncontinue;", "for (VAR_2 = 0; VAR_2 < VAR_0->platform_node[VAR_1]->device_num; VAR_2++) {", "av_freep(&(VAR_0->platform_node[VAR_1]->device_node[VAR_2]->device_name));", "av_freep(&(VAR_0->platform_node[VAR_1]->device_node[VAR_2]));", "}", "av_freep(&VAR_0->platform_node[VAR_1]->device_node);", "av_freep(&(VAR_0->platform_node[VAR_1]->platform_name));", "av_freep(&VAR_0->platform_node[VAR_1]);", "}", "av_freep(&VAR_0->platform_node);", "VAR_0->platform_num = 0;", "}" ]
[ 0, 0, 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 ] ]
701
void qemu_cond_init(QemuCond *cond) { memset(cond, 0, sizeof(*cond)); cond->sema = CreateSemaphore(NULL, 0, LONG_MAX, NULL); if (!cond->sema) { error_exit(GetLastError(), __func__); } cond->continue_event = CreateEvent(NULL, /* security */ FALSE, /* auto-reset */ FALSE, /* not signaled */ NULL); /* name */ if (!cond->continue_event) { error_exit(GetLastError(), __func__); } }
true
qemu
12f8def0e02232d7c6416ad9b66640f973c531d1
void qemu_cond_init(QemuCond *cond) { memset(cond, 0, sizeof(*cond)); cond->sema = CreateSemaphore(NULL, 0, LONG_MAX, NULL); if (!cond->sema) { error_exit(GetLastError(), __func__); } cond->continue_event = CreateEvent(NULL, FALSE, FALSE, NULL); if (!cond->continue_event) { error_exit(GetLastError(), __func__); } }
{ "code": [ " cond->sema = CreateSemaphore(NULL, 0, LONG_MAX, NULL);", " if (!cond->sema) {", " error_exit(GetLastError(), __func__);", " if (!cond->continue_event) {", " error_exit(GetLastError(), __func__);", " error_exit(GetLastError(), __func__);", " error_exit(GetLastError(), __func__);", " error_exit(GetLastError(), __func__);", " error_exit(GetLastError(), __func__);" ], "line_no": [ 9, 11, 13, 25, 13, 13, 13, 13, 13 ] }
void FUNC_0(QemuCond *VAR_0) { memset(VAR_0, 0, sizeof(*VAR_0)); VAR_0->sema = CreateSemaphore(NULL, 0, LONG_MAX, NULL); if (!VAR_0->sema) { error_exit(GetLastError(), __func__); } VAR_0->continue_event = CreateEvent(NULL, FALSE, FALSE, NULL); if (!VAR_0->continue_event) { error_exit(GetLastError(), __func__); } }
[ "void FUNC_0(QemuCond *VAR_0)\n{", "memset(VAR_0, 0, sizeof(*VAR_0));", "VAR_0->sema = CreateSemaphore(NULL, 0, LONG_MAX, NULL);", "if (!VAR_0->sema) {", "error_exit(GetLastError(), __func__);", "}", "VAR_0->continue_event = CreateEvent(NULL,\nFALSE,\nFALSE,\nNULL);", "if (!VAR_0->continue_event) {", "error_exit(GetLastError(), __func__);", "}", "}" ]
[ 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17, 19, 21, 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ] ]
702
void helper_rfdi(CPUPPCState *env) { do_rfi(env, env->spr[SPR_BOOKE_DSRR0], SPR_BOOKE_DSRR1, ~((target_ulong)0x3FFF0000), 0); }
true
qemu
a1bb73849fbd7d992b6ac2cf30c034244fb2299d
void helper_rfdi(CPUPPCState *env) { do_rfi(env, env->spr[SPR_BOOKE_DSRR0], SPR_BOOKE_DSRR1, ~((target_ulong)0x3FFF0000), 0); }
{ "code": [ " ~((target_ulong)0x3FFF0000), 0);", " do_rfi(env, env->spr[SPR_BOOKE_DSRR0], SPR_BOOKE_DSRR1,", " ~((target_ulong)0x3FFF0000), 0);", " ~((target_ulong)0x3FFF0000), 0);" ], "line_no": [ 7, 5, 7, 7 ] }
void FUNC_0(CPUPPCState *VAR_0) { do_rfi(VAR_0, VAR_0->spr[SPR_BOOKE_DSRR0], SPR_BOOKE_DSRR1, ~((target_ulong)0x3FFF0000), 0); }
[ "void FUNC_0(CPUPPCState *VAR_0)\n{", "do_rfi(VAR_0, VAR_0->spr[SPR_BOOKE_DSRR0], SPR_BOOKE_DSRR1,\n~((target_ulong)0x3FFF0000), 0);", "}" ]
[ 0, 1, 0 ]
[ [ 1, 3 ], [ 5, 7 ], [ 9 ] ]
703
static void choose_sample_rate(AVStream *st, AVCodec *codec) { if(codec && codec->supported_samplerates){ const int *p= codec->supported_samplerates; int best; int best_dist=INT_MAX; for(; *p; p++){ int dist= abs(st->codec->sample_rate - *p); if(dist < best_dist){ best_dist= dist; best= *p; } } if(best_dist){ av_log(st->codec, AV_LOG_WARNING, "Requested sampling rate unsupported using closest supported (%d)\n", best); } st->codec->sample_rate= best; } }
true
FFmpeg
947cbeca16c7a30322e02feea440e1e67801ab9a
static void choose_sample_rate(AVStream *st, AVCodec *codec) { if(codec && codec->supported_samplerates){ const int *p= codec->supported_samplerates; int best; int best_dist=INT_MAX; for(; *p; p++){ int dist= abs(st->codec->sample_rate - *p); if(dist < best_dist){ best_dist= dist; best= *p; } } if(best_dist){ av_log(st->codec, AV_LOG_WARNING, "Requested sampling rate unsupported using closest supported (%d)\n", best); } st->codec->sample_rate= best; } }
{ "code": [ " int best;" ], "line_no": [ 9 ] }
static void FUNC_0(AVStream *VAR_0, AVCodec *VAR_1) { if(VAR_1 && VAR_1->supported_samplerates){ const int *VAR_2= VAR_1->supported_samplerates; int VAR_3; int VAR_4=INT_MAX; for(; *VAR_2; VAR_2++){ int VAR_5= abs(VAR_0->VAR_1->sample_rate - *VAR_2); if(VAR_5 < VAR_4){ VAR_4= VAR_5; VAR_3= *VAR_2; } } if(VAR_4){ av_log(VAR_0->VAR_1, AV_LOG_WARNING, "Requested sampling rate unsupported using closest supported (%d)\n", VAR_3); } VAR_0->VAR_1->sample_rate= VAR_3; } }
[ "static void FUNC_0(AVStream *VAR_0, AVCodec *VAR_1)\n{", "if(VAR_1 && VAR_1->supported_samplerates){", "const int *VAR_2= VAR_1->supported_samplerates;", "int VAR_3;", "int VAR_4=INT_MAX;", "for(; *VAR_2; VAR_2++){", "int VAR_5= abs(VAR_0->VAR_1->sample_rate - *VAR_2);", "if(VAR_5 < VAR_4){", "VAR_4= VAR_5;", "VAR_3= *VAR_2;", "}", "}", "if(VAR_4){", "av_log(VAR_0->VAR_1, AV_LOG_WARNING, \"Requested sampling rate unsupported using closest supported (%d)\\n\", VAR_3);", "}", "VAR_0->VAR_1->sample_rate= VAR_3;", "}", "}" ]
[ 0, 0, 0, 1, 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 ] ]
704
unsigned iov_copy(struct iovec *dst_iov, unsigned int dst_iov_cnt, const struct iovec *iov, unsigned int iov_cnt, size_t offset, size_t bytes) { size_t len; unsigned int i, j; for (i = 0, j = 0; i < iov_cnt && j < dst_iov_cnt && bytes; i++) { if (offset >= iov[i].iov_len) { offset -= iov[i].iov_len; continue; } len = MIN(bytes, iov[i].iov_len - offset); dst_iov[j].iov_base = iov[i].iov_base + offset; dst_iov[j].iov_len = len; j++; bytes -= len; offset = 0; } assert(offset == 0); return j; }
true
qemu
e911765cbb9e9ddf5d952c88bb52180a62c6cea0
unsigned iov_copy(struct iovec *dst_iov, unsigned int dst_iov_cnt, const struct iovec *iov, unsigned int iov_cnt, size_t offset, size_t bytes) { size_t len; unsigned int i, j; for (i = 0, j = 0; i < iov_cnt && j < dst_iov_cnt && bytes; i++) { if (offset >= iov[i].iov_len) { offset -= iov[i].iov_len; continue; } len = MIN(bytes, iov[i].iov_len - offset); dst_iov[j].iov_base = iov[i].iov_base + offset; dst_iov[j].iov_len = len; j++; bytes -= len; offset = 0; } assert(offset == 0); return j; }
{ "code": [ " for (i = 0, j = 0; i < iov_cnt && j < dst_iov_cnt && bytes; i++) {" ], "line_no": [ 13 ] }
unsigned FUNC_0(struct iovec *VAR_0, unsigned int VAR_1, const struct iovec *VAR_2, unsigned int VAR_3, size_t VAR_4, size_t VAR_5) { size_t len; unsigned int VAR_6, VAR_7; for (VAR_6 = 0, VAR_7 = 0; VAR_6 < VAR_3 && VAR_7 < VAR_1 && VAR_5; VAR_6++) { if (VAR_4 >= VAR_2[VAR_6].iov_len) { VAR_4 -= VAR_2[VAR_6].iov_len; continue; } len = MIN(VAR_5, VAR_2[VAR_6].iov_len - VAR_4); VAR_0[VAR_7].iov_base = VAR_2[VAR_6].iov_base + VAR_4; VAR_0[VAR_7].iov_len = len; VAR_7++; VAR_5 -= len; VAR_4 = 0; } assert(VAR_4 == 0); return VAR_7; }
[ "unsigned FUNC_0(struct iovec *VAR_0, unsigned int VAR_1,\nconst struct iovec *VAR_2, unsigned int VAR_3,\nsize_t VAR_4, size_t VAR_5)\n{", "size_t len;", "unsigned int VAR_6, VAR_7;", "for (VAR_6 = 0, VAR_7 = 0; VAR_6 < VAR_3 && VAR_7 < VAR_1 && VAR_5; VAR_6++) {", "if (VAR_4 >= VAR_2[VAR_6].iov_len) {", "VAR_4 -= VAR_2[VAR_6].iov_len;", "continue;", "}", "len = MIN(VAR_5, VAR_2[VAR_6].iov_len - VAR_4);", "VAR_0[VAR_7].iov_base = VAR_2[VAR_6].iov_base + VAR_4;", "VAR_0[VAR_7].iov_len = len;", "VAR_7++;", "VAR_5 -= len;", "VAR_4 = 0;", "}", "assert(VAR_4 == 0);", "return VAR_7;", "}" ]
[ 0, 0, 0, 1, 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 ] ]
706
static int tty_serial_ioctl(CharDriverState *chr, int cmd, void *arg) FDCharDriver *s = chr->opaque; switch(cmd) { case CHR_IOCTL_SERIAL_SET_PARAMS: QEMUSerialSetParams *ssp = arg; tty_serial_init(s->fd_in, ssp->speed, ssp->parity, ssp->data_bits, ssp->stop_bits); case CHR_IOCTL_SERIAL_SET_BREAK: int enable = *(int *)arg; if (enable) tcsendbreak(s->fd_in, 1); default: return -ENOTSUP; return 0;
true
qemu
81174dae3f9189519cd60c7b79e91c291b021bbe
static int tty_serial_ioctl(CharDriverState *chr, int cmd, void *arg) FDCharDriver *s = chr->opaque; switch(cmd) { case CHR_IOCTL_SERIAL_SET_PARAMS: QEMUSerialSetParams *ssp = arg; tty_serial_init(s->fd_in, ssp->speed, ssp->parity, ssp->data_bits, ssp->stop_bits); case CHR_IOCTL_SERIAL_SET_BREAK: int enable = *(int *)arg; if (enable) tcsendbreak(s->fd_in, 1); default: return -ENOTSUP; return 0;
{ "code": [], "line_no": [] }
static int tty_serial_ioctl(CharDriverState *chr, int cmd, void *arg) FDCharDriver *s = chr->opaque; switch(cmd) { case CHR_IOCTL_SERIAL_SET_PARAMS: QEMUSerialSetParams *ssp = arg; tty_serial_init(s->fd_in, ssp->speed, ssp->parity, ssp->data_bits, ssp->stop_bits); case CHR_IOCTL_SERIAL_SET_BREAK: int enable = *(int *)arg; if (enable) tcsendbreak(s->fd_in, 1); default: return -ENOTSUP; return 0;
[ "static int tty_serial_ioctl(CharDriverState *chr, int cmd, void *arg)\nFDCharDriver *s = chr->opaque;", "switch(cmd) {", "case CHR_IOCTL_SERIAL_SET_PARAMS:\nQEMUSerialSetParams *ssp = arg;", "tty_serial_init(s->fd_in, ssp->speed, ssp->parity,\nssp->data_bits, ssp->stop_bits);", "case CHR_IOCTL_SERIAL_SET_BREAK:\nint enable = *(int *)arg;", "if (enable)\ntcsendbreak(s->fd_in, 1);", "default:\nreturn -ENOTSUP;", "return 0;" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 4 ], [ 8 ], [ 10, 13 ], [ 15, 17 ], [ 21, 24 ], [ 26, 28 ], [ 63, 65 ], [ 68 ] ]
708
static int spapr_populate_drconf_memory(sPAPRMachineState *spapr, void *fdt) { MachineState *machine = MACHINE(spapr); int ret, i, offset; uint64_t lmb_size = SPAPR_MEMORY_BLOCK_SIZE; uint32_t prop_lmb_size[] = {0, cpu_to_be32(lmb_size)}; uint32_t nr_lmbs = (machine->maxram_size - machine->ram_size)/lmb_size; uint32_t *int_buf, *cur_index, buf_len; int nr_nodes = nb_numa_nodes ? nb_numa_nodes : 1; /* Allocate enough buffer size to fit in ibm,dynamic-memory */ buf_len = nr_lmbs * SPAPR_DR_LMB_LIST_ENTRY_SIZE * sizeof(uint32_t) + sizeof(uint32_t); cur_index = int_buf = g_malloc0(buf_len); offset = fdt_add_subnode(fdt, 0, "ibm,dynamic-reconfiguration-memory"); ret = fdt_setprop(fdt, offset, "ibm,lmb-size", prop_lmb_size, sizeof(prop_lmb_size)); if (ret < 0) { goto out; } ret = fdt_setprop_cell(fdt, offset, "ibm,memory-flags-mask", 0xff); if (ret < 0) { goto out; } ret = fdt_setprop_cell(fdt, offset, "ibm,memory-preservation-time", 0x0); if (ret < 0) { goto out; } /* ibm,dynamic-memory */ int_buf[0] = cpu_to_be32(nr_lmbs); cur_index++; for (i = 0; i < nr_lmbs; i++) { sPAPRDRConnector *drc; sPAPRDRConnectorClass *drck; uint64_t addr = i * lmb_size + spapr->hotplug_memory.base;; uint32_t *dynamic_memory = cur_index; drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB, addr/lmb_size); g_assert(drc); drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); dynamic_memory[0] = cpu_to_be32(addr >> 32); dynamic_memory[1] = cpu_to_be32(addr & 0xffffffff); dynamic_memory[2] = cpu_to_be32(drck->get_index(drc)); dynamic_memory[3] = cpu_to_be32(0); /* reserved */ dynamic_memory[4] = cpu_to_be32(numa_get_node(addr, NULL)); if (addr < machine->ram_size || memory_region_present(get_system_memory(), addr)) { dynamic_memory[5] = cpu_to_be32(SPAPR_LMB_FLAGS_ASSIGNED); } else { dynamic_memory[5] = cpu_to_be32(0); } cur_index += SPAPR_DR_LMB_LIST_ENTRY_SIZE; } ret = fdt_setprop(fdt, offset, "ibm,dynamic-memory", int_buf, buf_len); if (ret < 0) { goto out; } /* ibm,associativity-lookup-arrays */ cur_index = int_buf; int_buf[0] = cpu_to_be32(nr_nodes); int_buf[1] = cpu_to_be32(4); /* Number of entries per associativity list */ cur_index += 2; for (i = 0; i < nr_nodes; i++) { uint32_t associativity[] = { cpu_to_be32(0x0), cpu_to_be32(0x0), cpu_to_be32(0x0), cpu_to_be32(i) }; memcpy(cur_index, associativity, sizeof(associativity)); cur_index += 4; } ret = fdt_setprop(fdt, offset, "ibm,associativity-lookup-arrays", int_buf, (cur_index - int_buf) * sizeof(uint32_t)); out: g_free(int_buf); return ret; }
true
qemu
ef001f069e0f175a036929782c5c63053df9569a
static int spapr_populate_drconf_memory(sPAPRMachineState *spapr, void *fdt) { MachineState *machine = MACHINE(spapr); int ret, i, offset; uint64_t lmb_size = SPAPR_MEMORY_BLOCK_SIZE; uint32_t prop_lmb_size[] = {0, cpu_to_be32(lmb_size)}; uint32_t nr_lmbs = (machine->maxram_size - machine->ram_size)/lmb_size; uint32_t *int_buf, *cur_index, buf_len; int nr_nodes = nb_numa_nodes ? nb_numa_nodes : 1; buf_len = nr_lmbs * SPAPR_DR_LMB_LIST_ENTRY_SIZE * sizeof(uint32_t) + sizeof(uint32_t); cur_index = int_buf = g_malloc0(buf_len); offset = fdt_add_subnode(fdt, 0, "ibm,dynamic-reconfiguration-memory"); ret = fdt_setprop(fdt, offset, "ibm,lmb-size", prop_lmb_size, sizeof(prop_lmb_size)); if (ret < 0) { goto out; } ret = fdt_setprop_cell(fdt, offset, "ibm,memory-flags-mask", 0xff); if (ret < 0) { goto out; } ret = fdt_setprop_cell(fdt, offset, "ibm,memory-preservation-time", 0x0); if (ret < 0) { goto out; } int_buf[0] = cpu_to_be32(nr_lmbs); cur_index++; for (i = 0; i < nr_lmbs; i++) { sPAPRDRConnector *drc; sPAPRDRConnectorClass *drck; uint64_t addr = i * lmb_size + spapr->hotplug_memory.base;; uint32_t *dynamic_memory = cur_index; drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB, addr/lmb_size); g_assert(drc); drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); dynamic_memory[0] = cpu_to_be32(addr >> 32); dynamic_memory[1] = cpu_to_be32(addr & 0xffffffff); dynamic_memory[2] = cpu_to_be32(drck->get_index(drc)); dynamic_memory[3] = cpu_to_be32(0); dynamic_memory[4] = cpu_to_be32(numa_get_node(addr, NULL)); if (addr < machine->ram_size || memory_region_present(get_system_memory(), addr)) { dynamic_memory[5] = cpu_to_be32(SPAPR_LMB_FLAGS_ASSIGNED); } else { dynamic_memory[5] = cpu_to_be32(0); } cur_index += SPAPR_DR_LMB_LIST_ENTRY_SIZE; } ret = fdt_setprop(fdt, offset, "ibm,dynamic-memory", int_buf, buf_len); if (ret < 0) { goto out; } cur_index = int_buf; int_buf[0] = cpu_to_be32(nr_nodes); int_buf[1] = cpu_to_be32(4); cur_index += 2; for (i = 0; i < nr_nodes; i++) { uint32_t associativity[] = { cpu_to_be32(0x0), cpu_to_be32(0x0), cpu_to_be32(0x0), cpu_to_be32(i) }; memcpy(cur_index, associativity, sizeof(associativity)); cur_index += 4; } ret = fdt_setprop(fdt, offset, "ibm,associativity-lookup-arrays", int_buf, (cur_index - int_buf) * sizeof(uint32_t)); out: g_free(int_buf); return ret; }
{ "code": [ " buf_len = nr_lmbs * SPAPR_DR_LMB_LIST_ENTRY_SIZE * sizeof(uint32_t) +", " sizeof(uint32_t);" ], "line_no": [ 23, 25 ] }
static int FUNC_0(sPAPRMachineState *VAR_0, void *VAR_1) { MachineState *machine = MACHINE(VAR_0); int VAR_2, VAR_3, VAR_4; uint64_t lmb_size = SPAPR_MEMORY_BLOCK_SIZE; uint32_t prop_lmb_size[] = {0, cpu_to_be32(lmb_size)}; uint32_t nr_lmbs = (machine->maxram_size - machine->ram_size)/lmb_size; uint32_t *int_buf, *cur_index, buf_len; int VAR_5 = nb_numa_nodes ? nb_numa_nodes : 1; buf_len = nr_lmbs * SPAPR_DR_LMB_LIST_ENTRY_SIZE * sizeof(uint32_t) + sizeof(uint32_t); cur_index = int_buf = g_malloc0(buf_len); VAR_4 = fdt_add_subnode(VAR_1, 0, "ibm,dynamic-reconfiguration-memory"); VAR_2 = fdt_setprop(VAR_1, VAR_4, "ibm,lmb-size", prop_lmb_size, sizeof(prop_lmb_size)); if (VAR_2 < 0) { goto out; } VAR_2 = fdt_setprop_cell(VAR_1, VAR_4, "ibm,memory-flags-mask", 0xff); if (VAR_2 < 0) { goto out; } VAR_2 = fdt_setprop_cell(VAR_1, VAR_4, "ibm,memory-preservation-time", 0x0); if (VAR_2 < 0) { goto out; } int_buf[0] = cpu_to_be32(nr_lmbs); cur_index++; for (VAR_3 = 0; VAR_3 < nr_lmbs; VAR_3++) { sPAPRDRConnector *drc; sPAPRDRConnectorClass *drck; uint64_t addr = VAR_3 * lmb_size + VAR_0->hotplug_memory.base;; uint32_t *dynamic_memory = cur_index; drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB, addr/lmb_size); g_assert(drc); drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); dynamic_memory[0] = cpu_to_be32(addr >> 32); dynamic_memory[1] = cpu_to_be32(addr & 0xffffffff); dynamic_memory[2] = cpu_to_be32(drck->get_index(drc)); dynamic_memory[3] = cpu_to_be32(0); dynamic_memory[4] = cpu_to_be32(numa_get_node(addr, NULL)); if (addr < machine->ram_size || memory_region_present(get_system_memory(), addr)) { dynamic_memory[5] = cpu_to_be32(SPAPR_LMB_FLAGS_ASSIGNED); } else { dynamic_memory[5] = cpu_to_be32(0); } cur_index += SPAPR_DR_LMB_LIST_ENTRY_SIZE; } VAR_2 = fdt_setprop(VAR_1, VAR_4, "ibm,dynamic-memory", int_buf, buf_len); if (VAR_2 < 0) { goto out; } cur_index = int_buf; int_buf[0] = cpu_to_be32(VAR_5); int_buf[1] = cpu_to_be32(4); cur_index += 2; for (VAR_3 = 0; VAR_3 < VAR_5; VAR_3++) { uint32_t associativity[] = { cpu_to_be32(0x0), cpu_to_be32(0x0), cpu_to_be32(0x0), cpu_to_be32(VAR_3) }; memcpy(cur_index, associativity, sizeof(associativity)); cur_index += 4; } VAR_2 = fdt_setprop(VAR_1, VAR_4, "ibm,associativity-lookup-arrays", int_buf, (cur_index - int_buf) * sizeof(uint32_t)); out: g_free(int_buf); return VAR_2; }
[ "static int FUNC_0(sPAPRMachineState *VAR_0, void *VAR_1)\n{", "MachineState *machine = MACHINE(VAR_0);", "int VAR_2, VAR_3, VAR_4;", "uint64_t lmb_size = SPAPR_MEMORY_BLOCK_SIZE;", "uint32_t prop_lmb_size[] = {0, cpu_to_be32(lmb_size)};", "uint32_t nr_lmbs = (machine->maxram_size - machine->ram_size)/lmb_size;", "uint32_t *int_buf, *cur_index, buf_len;", "int VAR_5 = nb_numa_nodes ? nb_numa_nodes : 1;", "buf_len = nr_lmbs * SPAPR_DR_LMB_LIST_ENTRY_SIZE * sizeof(uint32_t) +\nsizeof(uint32_t);", "cur_index = int_buf = g_malloc0(buf_len);", "VAR_4 = fdt_add_subnode(VAR_1, 0, \"ibm,dynamic-reconfiguration-memory\");", "VAR_2 = fdt_setprop(VAR_1, VAR_4, \"ibm,lmb-size\", prop_lmb_size,\nsizeof(prop_lmb_size));", "if (VAR_2 < 0) {", "goto out;", "}", "VAR_2 = fdt_setprop_cell(VAR_1, VAR_4, \"ibm,memory-flags-mask\", 0xff);", "if (VAR_2 < 0) {", "goto out;", "}", "VAR_2 = fdt_setprop_cell(VAR_1, VAR_4, \"ibm,memory-preservation-time\", 0x0);", "if (VAR_2 < 0) {", "goto out;", "}", "int_buf[0] = cpu_to_be32(nr_lmbs);", "cur_index++;", "for (VAR_3 = 0; VAR_3 < nr_lmbs; VAR_3++) {", "sPAPRDRConnector *drc;", "sPAPRDRConnectorClass *drck;", "uint64_t addr = VAR_3 * lmb_size + VAR_0->hotplug_memory.base;;", "uint32_t *dynamic_memory = cur_index;", "drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB,\naddr/lmb_size);", "g_assert(drc);", "drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);", "dynamic_memory[0] = cpu_to_be32(addr >> 32);", "dynamic_memory[1] = cpu_to_be32(addr & 0xffffffff);", "dynamic_memory[2] = cpu_to_be32(drck->get_index(drc));", "dynamic_memory[3] = cpu_to_be32(0);", "dynamic_memory[4] = cpu_to_be32(numa_get_node(addr, NULL));", "if (addr < machine->ram_size ||\nmemory_region_present(get_system_memory(), addr)) {", "dynamic_memory[5] = cpu_to_be32(SPAPR_LMB_FLAGS_ASSIGNED);", "} else {", "dynamic_memory[5] = cpu_to_be32(0);", "}", "cur_index += SPAPR_DR_LMB_LIST_ENTRY_SIZE;", "}", "VAR_2 = fdt_setprop(VAR_1, VAR_4, \"ibm,dynamic-memory\", int_buf, buf_len);", "if (VAR_2 < 0) {", "goto out;", "}", "cur_index = int_buf;", "int_buf[0] = cpu_to_be32(VAR_5);", "int_buf[1] = cpu_to_be32(4);", "cur_index += 2;", "for (VAR_3 = 0; VAR_3 < VAR_5; VAR_3++) {", "uint32_t associativity[] = {", "cpu_to_be32(0x0),\ncpu_to_be32(0x0),\ncpu_to_be32(0x0),\ncpu_to_be32(VAR_3)\n};", "memcpy(cur_index, associativity, sizeof(associativity));", "cur_index += 4;", "}", "VAR_2 = fdt_setprop(VAR_1, VAR_4, \"ibm,associativity-lookup-arrays\", int_buf,\n(cur_index - int_buf) * sizeof(uint32_t));", "out:\ng_free(int_buf);", "return VAR_2;", "}" ]
[ 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 23, 25 ], [ 27 ], [ 31 ], [ 35, 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 85, 87 ], [ 89 ], [ 91 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105, 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147, 149, 151, 153, 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163, 165 ], [ 167, 169 ], [ 171 ], [ 173 ] ]
709
static int http_server(struct sockaddr_in my_addr) { int server_fd, tmp, ret; struct sockaddr_in from_addr; struct pollfd poll_table[HTTP_MAX_CONNECTIONS + 1], *poll_entry; HTTPContext *c, **cp; long cur_time; server_fd = socket(AF_INET,SOCK_STREAM,0); if (server_fd < 0) { perror ("socket"); return -1; } tmp = 1; setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof(tmp)); if (bind (server_fd, (struct sockaddr *) &my_addr, sizeof (my_addr)) < 0) { perror ("bind"); close(server_fd); return -1; } if (listen (server_fd, 5) < 0) { perror ("listen"); close(server_fd); return -1; } http_log("ffserver started.\n"); start_children(first_feed); fcntl(server_fd, F_SETFL, O_NONBLOCK); first_http_ctx = NULL; nb_connections = 0; first_http_ctx = NULL; for(;;) { poll_entry = poll_table; poll_entry->fd = server_fd; poll_entry->events = POLLIN; poll_entry++; /* wait for events on each HTTP handle */ c = first_http_ctx; while (c != NULL) { int fd; fd = c->fd; switch(c->state) { case HTTPSTATE_WAIT_REQUEST: c->poll_entry = poll_entry; poll_entry->fd = fd; poll_entry->events = POLLIN; poll_entry++; break; case HTTPSTATE_SEND_HEADER: case HTTPSTATE_SEND_DATA_HEADER: case HTTPSTATE_SEND_DATA: case HTTPSTATE_SEND_DATA_TRAILER: c->poll_entry = poll_entry; poll_entry->fd = fd; poll_entry->events = POLLOUT; poll_entry++; break; case HTTPSTATE_RECEIVE_DATA: c->poll_entry = poll_entry; poll_entry->fd = fd; poll_entry->events = POLLIN; poll_entry++; break; case HTTPSTATE_WAIT_FEED: /* need to catch errors */ c->poll_entry = poll_entry; poll_entry->fd = fd; poll_entry->events = POLLIN;/* Maybe this will work */ poll_entry++; break; default: c->poll_entry = NULL; break; } c = c->next; } /* wait for an event on one connection. We poll at least every second to handle timeouts */ do { ret = poll(poll_table, poll_entry - poll_table, 1000); } while (ret == -1); cur_time = gettime_ms(); /* now handle the events */ cp = &first_http_ctx; while ((*cp) != NULL) { c = *cp; if (handle_http (c, cur_time) < 0) { /* close and free the connection */ log_connection(c); close(c->fd); if (c->fmt_in) av_close_input_file(c->fmt_in); *cp = c->next; nb_bandwidth -= c->bandwidth; av_free(c->buffer); av_free(c->pbuffer); av_free(c); nb_connections--; } else { cp = &c->next; } } /* new connection request ? */ poll_entry = poll_table; if (poll_entry->revents & POLLIN) { int fd, len; len = sizeof(from_addr); fd = accept(server_fd, (struct sockaddr *)&from_addr, &len); if (fd >= 0) { fcntl(fd, F_SETFL, O_NONBLOCK); /* XXX: should output a warning page when coming close to the connection limit */ if (nb_connections >= nb_max_connections) { c = NULL; } else { /* add a new connection */ c = av_mallocz(sizeof(HTTPContext)); if (c) { c->next = first_http_ctx; first_http_ctx = c; c->fd = fd; c->poll_entry = NULL; c->from_addr = from_addr; c->state = HTTPSTATE_WAIT_REQUEST; c->buffer = av_malloc(c->buffer_size = IOBUFFER_INIT_SIZE); c->pbuffer = av_malloc(c->pbuffer_size = PBUFFER_INIT_SIZE); if (!c->buffer || !c->pbuffer) { av_free(c->buffer); av_free(c->pbuffer); av_freep(&c); } else { c->buffer_ptr = c->buffer; c->buffer_end = c->buffer + c->buffer_size; c->timeout = cur_time + REQUEST_TIMEOUT; c->start_time = cur_time; nb_connections++; } } } if (!c) { close(fd); } } } poll_entry++; } }
true
FFmpeg
5eb765ef341c3ec1bea31914c897750f88476ede
static int http_server(struct sockaddr_in my_addr) { int server_fd, tmp, ret; struct sockaddr_in from_addr; struct pollfd poll_table[HTTP_MAX_CONNECTIONS + 1], *poll_entry; HTTPContext *c, **cp; long cur_time; server_fd = socket(AF_INET,SOCK_STREAM,0); if (server_fd < 0) { perror ("socket"); return -1; } tmp = 1; setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof(tmp)); if (bind (server_fd, (struct sockaddr *) &my_addr, sizeof (my_addr)) < 0) { perror ("bind"); close(server_fd); return -1; } if (listen (server_fd, 5) < 0) { perror ("listen"); close(server_fd); return -1; } http_log("ffserver started.\n"); start_children(first_feed); fcntl(server_fd, F_SETFL, O_NONBLOCK); first_http_ctx = NULL; nb_connections = 0; first_http_ctx = NULL; for(;;) { poll_entry = poll_table; poll_entry->fd = server_fd; poll_entry->events = POLLIN; poll_entry++; c = first_http_ctx; while (c != NULL) { int fd; fd = c->fd; switch(c->state) { case HTTPSTATE_WAIT_REQUEST: c->poll_entry = poll_entry; poll_entry->fd = fd; poll_entry->events = POLLIN; poll_entry++; break; case HTTPSTATE_SEND_HEADER: case HTTPSTATE_SEND_DATA_HEADER: case HTTPSTATE_SEND_DATA: case HTTPSTATE_SEND_DATA_TRAILER: c->poll_entry = poll_entry; poll_entry->fd = fd; poll_entry->events = POLLOUT; poll_entry++; break; case HTTPSTATE_RECEIVE_DATA: c->poll_entry = poll_entry; poll_entry->fd = fd; poll_entry->events = POLLIN; poll_entry++; break; case HTTPSTATE_WAIT_FEED: c->poll_entry = poll_entry; poll_entry->fd = fd; poll_entry->events = POLLIN; poll_entry++; break; default: c->poll_entry = NULL; break; } c = c->next; } do { ret = poll(poll_table, poll_entry - poll_table, 1000); } while (ret == -1); cur_time = gettime_ms(); cp = &first_http_ctx; while ((*cp) != NULL) { c = *cp; if (handle_http (c, cur_time) < 0) { log_connection(c); close(c->fd); if (c->fmt_in) av_close_input_file(c->fmt_in); *cp = c->next; nb_bandwidth -= c->bandwidth; av_free(c->buffer); av_free(c->pbuffer); av_free(c); nb_connections--; } else { cp = &c->next; } } poll_entry = poll_table; if (poll_entry->revents & POLLIN) { int fd, len; len = sizeof(from_addr); fd = accept(server_fd, (struct sockaddr *)&from_addr, &len); if (fd >= 0) { fcntl(fd, F_SETFL, O_NONBLOCK); if (nb_connections >= nb_max_connections) { c = NULL; } else { c = av_mallocz(sizeof(HTTPContext)); if (c) { c->next = first_http_ctx; first_http_ctx = c; c->fd = fd; c->poll_entry = NULL; c->from_addr = from_addr; c->state = HTTPSTATE_WAIT_REQUEST; c->buffer = av_malloc(c->buffer_size = IOBUFFER_INIT_SIZE); c->pbuffer = av_malloc(c->pbuffer_size = PBUFFER_INIT_SIZE); if (!c->buffer || !c->pbuffer) { av_free(c->buffer); av_free(c->pbuffer); av_freep(&c); } else { c->buffer_ptr = c->buffer; c->buffer_end = c->buffer + c->buffer_size; c->timeout = cur_time + REQUEST_TIMEOUT; c->start_time = cur_time; nb_connections++; } } } if (!c) { close(fd); } } } poll_entry++; } }
{ "code": [ " long cur_time;", " if (handle_http (c, cur_time) < 0) {" ], "line_no": [ 13, 195 ] }
static int FUNC_0(struct sockaddr_in VAR_0) { int VAR_1, VAR_2, VAR_3; struct sockaddr_in VAR_4; struct pollfd VAR_5[HTTP_MAX_CONNECTIONS + 1], *poll_entry; HTTPContext *c, **cp; long VAR_6; VAR_1 = socket(AF_INET,SOCK_STREAM,0); if (VAR_1 < 0) { perror ("socket"); return -1; } VAR_2 = 1; setsockopt(VAR_1, SOL_SOCKET, SO_REUSEADDR, &VAR_2, sizeof(VAR_2)); if (bind (VAR_1, (struct sockaddr *) &VAR_0, sizeof (VAR_0)) < 0) { perror ("bind"); close(VAR_1); return -1; } if (listen (VAR_1, 5) < 0) { perror ("listen"); close(VAR_1); return -1; } http_log("ffserver started.\n"); start_children(first_feed); fcntl(VAR_1, F_SETFL, O_NONBLOCK); first_http_ctx = NULL; nb_connections = 0; first_http_ctx = NULL; for(;;) { poll_entry = VAR_5; poll_entry->VAR_8 = VAR_1; poll_entry->events = POLLIN; poll_entry++; c = first_http_ctx; while (c != NULL) { int VAR_8; VAR_8 = c->VAR_8; switch(c->state) { case HTTPSTATE_WAIT_REQUEST: c->poll_entry = poll_entry; poll_entry->VAR_8 = VAR_8; poll_entry->events = POLLIN; poll_entry++; break; case HTTPSTATE_SEND_HEADER: case HTTPSTATE_SEND_DATA_HEADER: case HTTPSTATE_SEND_DATA: case HTTPSTATE_SEND_DATA_TRAILER: c->poll_entry = poll_entry; poll_entry->VAR_8 = VAR_8; poll_entry->events = POLLOUT; poll_entry++; break; case HTTPSTATE_RECEIVE_DATA: c->poll_entry = poll_entry; poll_entry->VAR_8 = VAR_8; poll_entry->events = POLLIN; poll_entry++; break; case HTTPSTATE_WAIT_FEED: c->poll_entry = poll_entry; poll_entry->VAR_8 = VAR_8; poll_entry->events = POLLIN; poll_entry++; break; default: c->poll_entry = NULL; break; } c = c->next; } do { VAR_3 = poll(VAR_5, poll_entry - VAR_5, 1000); } while (VAR_3 == -1); VAR_6 = gettime_ms(); cp = &first_http_ctx; while ((*cp) != NULL) { c = *cp; if (handle_http (c, VAR_6) < 0) { log_connection(c); close(c->VAR_8); if (c->fmt_in) av_close_input_file(c->fmt_in); *cp = c->next; nb_bandwidth -= c->bandwidth; av_free(c->buffer); av_free(c->pbuffer); av_free(c); nb_connections--; } else { cp = &c->next; } } poll_entry = VAR_5; if (poll_entry->revents & POLLIN) { int VAR_8, VAR_8; VAR_8 = sizeof(VAR_4); VAR_8 = accept(VAR_1, (struct sockaddr *)&VAR_4, &VAR_8); if (VAR_8 >= 0) { fcntl(VAR_8, F_SETFL, O_NONBLOCK); if (nb_connections >= nb_max_connections) { c = NULL; } else { c = av_mallocz(sizeof(HTTPContext)); if (c) { c->next = first_http_ctx; first_http_ctx = c; c->VAR_8 = VAR_8; c->poll_entry = NULL; c->VAR_4 = VAR_4; c->state = HTTPSTATE_WAIT_REQUEST; c->buffer = av_malloc(c->buffer_size = IOBUFFER_INIT_SIZE); c->pbuffer = av_malloc(c->pbuffer_size = PBUFFER_INIT_SIZE); if (!c->buffer || !c->pbuffer) { av_free(c->buffer); av_free(c->pbuffer); av_freep(&c); } else { c->buffer_ptr = c->buffer; c->buffer_end = c->buffer + c->buffer_size; c->timeout = VAR_6 + REQUEST_TIMEOUT; c->start_time = VAR_6; nb_connections++; } } } if (!c) { close(VAR_8); } } } poll_entry++; } }
[ "static int FUNC_0(struct sockaddr_in VAR_0)\n{", "int VAR_1, VAR_2, VAR_3;", "struct sockaddr_in VAR_4;", "struct pollfd VAR_5[HTTP_MAX_CONNECTIONS + 1], *poll_entry;", "HTTPContext *c, **cp;", "long VAR_6;", "VAR_1 = socket(AF_INET,SOCK_STREAM,0);", "if (VAR_1 < 0) {", "perror (\"socket\");", "return -1;", "}", "VAR_2 = 1;", "setsockopt(VAR_1, SOL_SOCKET, SO_REUSEADDR, &VAR_2, sizeof(VAR_2));", "if (bind (VAR_1, (struct sockaddr *) &VAR_0, sizeof (VAR_0)) < 0) {", "perror (\"bind\");", "close(VAR_1);", "return -1;", "}", "if (listen (VAR_1, 5) < 0) {", "perror (\"listen\");", "close(VAR_1);", "return -1;", "}", "http_log(\"ffserver started.\\n\");", "start_children(first_feed);", "fcntl(VAR_1, F_SETFL, O_NONBLOCK);", "first_http_ctx = NULL;", "nb_connections = 0;", "first_http_ctx = NULL;", "for(;;) {", "poll_entry = VAR_5;", "poll_entry->VAR_8 = VAR_1;", "poll_entry->events = POLLIN;", "poll_entry++;", "c = first_http_ctx;", "while (c != NULL) {", "int VAR_8;", "VAR_8 = c->VAR_8;", "switch(c->state) {", "case HTTPSTATE_WAIT_REQUEST:\nc->poll_entry = poll_entry;", "poll_entry->VAR_8 = VAR_8;", "poll_entry->events = POLLIN;", "poll_entry++;", "break;", "case HTTPSTATE_SEND_HEADER:\ncase HTTPSTATE_SEND_DATA_HEADER:\ncase HTTPSTATE_SEND_DATA:\ncase HTTPSTATE_SEND_DATA_TRAILER:\nc->poll_entry = poll_entry;", "poll_entry->VAR_8 = VAR_8;", "poll_entry->events = POLLOUT;", "poll_entry++;", "break;", "case HTTPSTATE_RECEIVE_DATA:\nc->poll_entry = poll_entry;", "poll_entry->VAR_8 = VAR_8;", "poll_entry->events = POLLIN;", "poll_entry++;", "break;", "case HTTPSTATE_WAIT_FEED:\nc->poll_entry = poll_entry;", "poll_entry->VAR_8 = VAR_8;", "poll_entry->events = POLLIN;", "poll_entry++;", "break;", "default:\nc->poll_entry = NULL;", "break;", "}", "c = c->next;", "}", "do {", "VAR_3 = poll(VAR_5, poll_entry - VAR_5, 1000);", "} while (VAR_3 == -1);", "VAR_6 = gettime_ms();", "cp = &first_http_ctx;", "while ((*cp) != NULL) {", "c = *cp;", "if (handle_http (c, VAR_6) < 0) {", "log_connection(c);", "close(c->VAR_8);", "if (c->fmt_in)\nav_close_input_file(c->fmt_in);", "*cp = c->next;", "nb_bandwidth -= c->bandwidth;", "av_free(c->buffer);", "av_free(c->pbuffer);", "av_free(c);", "nb_connections--;", "} else {", "cp = &c->next;", "}", "}", "poll_entry = VAR_5;", "if (poll_entry->revents & POLLIN) {", "int VAR_8, VAR_8;", "VAR_8 = sizeof(VAR_4);", "VAR_8 = accept(VAR_1, (struct sockaddr *)&VAR_4,\n&VAR_8);", "if (VAR_8 >= 0) {", "fcntl(VAR_8, F_SETFL, O_NONBLOCK);", "if (nb_connections >= nb_max_connections) {", "c = NULL;", "} else {", "c = av_mallocz(sizeof(HTTPContext));", "if (c) {", "c->next = first_http_ctx;", "first_http_ctx = c;", "c->VAR_8 = VAR_8;", "c->poll_entry = NULL;", "c->VAR_4 = VAR_4;", "c->state = HTTPSTATE_WAIT_REQUEST;", "c->buffer = av_malloc(c->buffer_size = IOBUFFER_INIT_SIZE);", "c->pbuffer = av_malloc(c->pbuffer_size = PBUFFER_INIT_SIZE);", "if (!c->buffer || !c->pbuffer) {", "av_free(c->buffer);", "av_free(c->pbuffer);", "av_freep(&c);", "} else {", "c->buffer_ptr = c->buffer;", "c->buffer_end = c->buffer + c->buffer_size;", "c->timeout = VAR_6 + REQUEST_TIMEOUT;", "c->start_time = VAR_6;", "nb_connections++;", "}", "}", "}", "if (!c) {", "close(VAR_8);", "}", "}", "}", "poll_entry++;", "}", "}" ]
[ 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, 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 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, 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155, 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 173 ], [ 175 ], [ 177 ], [ 181 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 199 ], [ 201 ], [ 203, 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 231 ], [ 233 ], [ 235 ], [ 239 ], [ 241, 243 ], [ 245 ], [ 247 ], [ 253 ], [ 255 ], [ 257 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 277 ], [ 279 ], [ 281 ], [ 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ], [ 299 ], [ 301 ], [ 303 ], [ 305 ], [ 307 ], [ 309 ], [ 311 ], [ 313 ], [ 315 ], [ 317 ], [ 319 ], [ 321 ] ]
711
int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp) { uint8_t t[sizeof(diag_501)]; if (cpu_memory_rw_debug(cs, bp->pc, t, sizeof(diag_501), 0)) { return -EINVAL; } else if (memcmp(t, diag_501, sizeof(diag_501))) { return -EINVAL; } else if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, sizeof(diag_501), 1)) { return -EINVAL; } return 0; }
true
qemu
b60fae32ff33cbaab76d14cc5f55b979cf58516d
int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp) { uint8_t t[sizeof(diag_501)]; if (cpu_memory_rw_debug(cs, bp->pc, t, sizeof(diag_501), 0)) { return -EINVAL; } else if (memcmp(t, diag_501, sizeof(diag_501))) { return -EINVAL; } else if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, sizeof(diag_501), 1)) { return -EINVAL; } return 0; }
{ "code": [ " uint8_t t[sizeof(diag_501)];", " if (cpu_memory_rw_debug(cs, bp->pc, t, sizeof(diag_501), 0)) {", " } else if (memcmp(t, diag_501, sizeof(diag_501))) {", " sizeof(diag_501), 1)) {" ], "line_no": [ 5, 9, 13, 19 ] }
int FUNC_0(CPUState *VAR_0, struct kvm_sw_breakpoint *VAR_1) { uint8_t t[sizeof(diag_501)]; if (cpu_memory_rw_debug(VAR_0, VAR_1->pc, t, sizeof(diag_501), 0)) { return -EINVAL; } else if (memcmp(t, diag_501, sizeof(diag_501))) { return -EINVAL; } else if (cpu_memory_rw_debug(VAR_0, VAR_1->pc, (uint8_t *)&VAR_1->saved_insn, sizeof(diag_501), 1)) { return -EINVAL; } return 0; }
[ "int FUNC_0(CPUState *VAR_0, struct kvm_sw_breakpoint *VAR_1)\n{", "uint8_t t[sizeof(diag_501)];", "if (cpu_memory_rw_debug(VAR_0, VAR_1->pc, t, sizeof(diag_501), 0)) {", "return -EINVAL;", "} else if (memcmp(t, diag_501, sizeof(diag_501))) {", "return -EINVAL;", "} else if (cpu_memory_rw_debug(VAR_0, VAR_1->pc, (uint8_t *)&VAR_1->saved_insn,", "sizeof(diag_501), 1)) {", "return -EINVAL;", "}", "return 0;", "}" ]
[ 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ] ]
714
static int kvm_get_dirty_pages_log_range(MemoryRegionSection *section, unsigned long *bitmap) { unsigned int i, j; unsigned long page_number, addr, addr1, c; unsigned int len = ((section->size / TARGET_PAGE_SIZE) + HOST_LONG_BITS - 1) / HOST_LONG_BITS; /* * bitmap-traveling is faster than memory-traveling (for addr...) * especially when most of the memory is not dirty. */ for (i = 0; i < len; i++) { if (bitmap[i] != 0) { c = leul_to_cpu(bitmap[i]); do { j = ffsl(c) - 1; c &= ~(1ul << j); page_number = i * HOST_LONG_BITS + j; addr1 = page_number * TARGET_PAGE_SIZE; addr = section->offset_within_region + addr1; memory_region_set_dirty(section->mr, addr); } while (c != 0); } } return 0; }
true
qemu
aa90fec7ad128039617d31a5fd5ced8b0488f71b
static int kvm_get_dirty_pages_log_range(MemoryRegionSection *section, unsigned long *bitmap) { unsigned int i, j; unsigned long page_number, addr, addr1, c; unsigned int len = ((section->size / TARGET_PAGE_SIZE) + HOST_LONG_BITS - 1) / HOST_LONG_BITS; for (i = 0; i < len; i++) { if (bitmap[i] != 0) { c = leul_to_cpu(bitmap[i]); do { j = ffsl(c) - 1; c &= ~(1ul << j); page_number = i * HOST_LONG_BITS + j; addr1 = page_number * TARGET_PAGE_SIZE; addr = section->offset_within_region + addr1; memory_region_set_dirty(section->mr, addr); } while (c != 0); } } return 0; }
{ "code": [ " unsigned long page_number, addr, addr1, c;" ], "line_no": [ 9 ] }
static int FUNC_0(MemoryRegionSection *VAR_0, unsigned long *VAR_1) { unsigned int VAR_2, VAR_3; unsigned long VAR_4, VAR_5, VAR_6, VAR_7; unsigned int VAR_8 = ((VAR_0->size / TARGET_PAGE_SIZE) + HOST_LONG_BITS - 1) / HOST_LONG_BITS; for (VAR_2 = 0; VAR_2 < VAR_8; VAR_2++) { if (VAR_1[VAR_2] != 0) { VAR_7 = leul_to_cpu(VAR_1[VAR_2]); do { VAR_3 = ffsl(VAR_7) - 1; VAR_7 &= ~(1ul << VAR_3); VAR_4 = VAR_2 * HOST_LONG_BITS + VAR_3; VAR_6 = VAR_4 * TARGET_PAGE_SIZE; VAR_5 = VAR_0->offset_within_region + VAR_6; memory_region_set_dirty(VAR_0->mr, VAR_5); } while (VAR_7 != 0); } } return 0; }
[ "static int FUNC_0(MemoryRegionSection *VAR_0,\nunsigned long *VAR_1)\n{", "unsigned int VAR_2, VAR_3;", "unsigned long VAR_4, VAR_5, VAR_6, VAR_7;", "unsigned int VAR_8 = ((VAR_0->size / TARGET_PAGE_SIZE) + HOST_LONG_BITS - 1) / HOST_LONG_BITS;", "for (VAR_2 = 0; VAR_2 < VAR_8; VAR_2++) {", "if (VAR_1[VAR_2] != 0) {", "VAR_7 = leul_to_cpu(VAR_1[VAR_2]);", "do {", "VAR_3 = ffsl(VAR_7) - 1;", "VAR_7 &= ~(1ul << VAR_3);", "VAR_4 = VAR_2 * HOST_LONG_BITS + VAR_3;", "VAR_6 = VAR_4 * TARGET_PAGE_SIZE;", "VAR_5 = VAR_0->offset_within_region + VAR_6;", "memory_region_set_dirty(VAR_0->mr, VAR_5);", "} while (VAR_7 != 0);", "}", "}", "return 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 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ] ]
715
static int ppc_hash64_pte_prot(PowerPCCPU *cpu, ppc_slb_t *slb, ppc_hash_pte64_t pte) { CPUPPCState *env = &cpu->env; unsigned pp, key; /* Some pp bit combinations have undefined behaviour, so default * to no access in those cases */ int prot = 0; key = !!(msr_pr ? (slb->vsid & SLB_VSID_KP) : (slb->vsid & SLB_VSID_KS)); pp = (pte.pte1 & HPTE64_R_PP) | ((pte.pte1 & HPTE64_R_PP0) >> 61); if (key == 0) { switch (pp) { case 0x0: case 0x1: case 0x2: prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; break; case 0x3: case 0x6: prot = PAGE_READ | PAGE_EXEC; break; } } else { switch (pp) { case 0x0: case 0x6: break; case 0x1: case 0x3: prot = PAGE_READ | PAGE_EXEC; break; case 0x2: prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; break; } } /* No execute if either noexec or guarded bits set */ if (!(pte.pte1 & HPTE64_R_N) || (pte.pte1 & HPTE64_R_G) || (slb->vsid & SLB_VSID_N)) { prot |= PAGE_EXEC; } return prot; }
true
qemu
07a68f990785a8574c78a36b21cf5165e46f1113
static int ppc_hash64_pte_prot(PowerPCCPU *cpu, ppc_slb_t *slb, ppc_hash_pte64_t pte) { CPUPPCState *env = &cpu->env; unsigned pp, key; int prot = 0; key = !!(msr_pr ? (slb->vsid & SLB_VSID_KP) : (slb->vsid & SLB_VSID_KS)); pp = (pte.pte1 & HPTE64_R_PP) | ((pte.pte1 & HPTE64_R_PP0) >> 61); if (key == 0) { switch (pp) { case 0x0: case 0x1: case 0x2: prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; break; case 0x3: case 0x6: prot = PAGE_READ | PAGE_EXEC; break; } } else { switch (pp) { case 0x0: case 0x6: break; case 0x1: case 0x3: prot = PAGE_READ | PAGE_EXEC; break; case 0x2: prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; break; } } if (!(pte.pte1 & HPTE64_R_N) || (pte.pte1 & HPTE64_R_G) || (slb->vsid & SLB_VSID_N)) { prot |= PAGE_EXEC; } return prot; }
{ "code": [ " if (!(pte.pte1 & HPTE64_R_N) || (pte.pte1 & HPTE64_R_G)", " || (slb->vsid & SLB_VSID_N)) {", " prot |= PAGE_EXEC;" ], "line_no": [ 89, 91, 93 ] }
static int FUNC_0(PowerPCCPU *VAR_0, ppc_slb_t *VAR_1, ppc_hash_pte64_t VAR_2) { CPUPPCState *env = &VAR_0->env; unsigned VAR_3, VAR_4; int VAR_5 = 0; VAR_4 = !!(msr_pr ? (VAR_1->vsid & SLB_VSID_KP) : (VAR_1->vsid & SLB_VSID_KS)); VAR_3 = (VAR_2.pte1 & HPTE64_R_PP) | ((VAR_2.pte1 & HPTE64_R_PP0) >> 61); if (VAR_4 == 0) { switch (VAR_3) { case 0x0: case 0x1: case 0x2: VAR_5 = PAGE_READ | PAGE_WRITE | PAGE_EXEC; break; case 0x3: case 0x6: VAR_5 = PAGE_READ | PAGE_EXEC; break; } } else { switch (VAR_3) { case 0x0: case 0x6: break; case 0x1: case 0x3: VAR_5 = PAGE_READ | PAGE_EXEC; break; case 0x2: VAR_5 = PAGE_READ | PAGE_WRITE | PAGE_EXEC; break; } } if (!(VAR_2.pte1 & HPTE64_R_N) || (VAR_2.pte1 & HPTE64_R_G) || (VAR_1->vsid & SLB_VSID_N)) { VAR_5 |= PAGE_EXEC; } return VAR_5; }
[ "static int FUNC_0(PowerPCCPU *VAR_0,\nppc_slb_t *VAR_1, ppc_hash_pte64_t VAR_2)\n{", "CPUPPCState *env = &VAR_0->env;", "unsigned VAR_3, VAR_4;", "int VAR_5 = 0;", "VAR_4 = !!(msr_pr ? (VAR_1->vsid & SLB_VSID_KP)\n: (VAR_1->vsid & SLB_VSID_KS));", "VAR_3 = (VAR_2.pte1 & HPTE64_R_PP) | ((VAR_2.pte1 & HPTE64_R_PP0) >> 61);", "if (VAR_4 == 0) {", "switch (VAR_3) {", "case 0x0:\ncase 0x1:\ncase 0x2:\nVAR_5 = PAGE_READ | PAGE_WRITE | PAGE_EXEC;", "break;", "case 0x3:\ncase 0x6:\nVAR_5 = PAGE_READ | PAGE_EXEC;", "break;", "}", "} else {", "switch (VAR_3) {", "case 0x0:\ncase 0x6:\nbreak;", "case 0x1:\ncase 0x3:\nVAR_5 = PAGE_READ | PAGE_EXEC;", "break;", "case 0x2:\nVAR_5 = PAGE_READ | PAGE_WRITE | PAGE_EXEC;", "break;", "}", "}", "if (!(VAR_2.pte1 & HPTE64_R_N) || (VAR_2.pte1 & HPTE64_R_G)\n|| (VAR_1->vsid & SLB_VSID_N)) {", "VAR_5 |= PAGE_EXEC;", "}", "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, 1, 1, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 15 ], [ 19, 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31, 33, 35, 37 ], [ 39 ], [ 43, 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57, 59, 61 ], [ 65, 67, 69 ], [ 71 ], [ 75, 77 ], [ 79 ], [ 81 ], [ 83 ], [ 89, 91 ], [ 93 ], [ 95 ], [ 99 ], [ 101 ] ]
716
static int rd_frame(CinepakEncContext *s, AVFrame *frame, unsigned char *buf, int buf_size) { int num_strips, strip, h, i, y, size, temp_size, best_size; AVPicture last_pict, pict, scratch_pict; int64_t best_score = 0, score, score_temp; //TODO: support encoding zero strips (meaning skip the whole frame) for(num_strips = MIN_STRIPS; num_strips <= MAX_STRIPS && num_strips <= s->h / MB_SIZE; num_strips++) { score = 0; size = 0; h = s->h / num_strips; //make h into next multiple of 4 h += 4 - (h & 3); for(strip = 0; strip < num_strips; strip++) { y = strip*h; get_sub_picture(s, 0, y, (AVPicture*)frame, &pict); get_sub_picture(s, 0, y, (AVPicture*)&s->last_frame, &last_pict); get_sub_picture(s, 0, y, (AVPicture*)&s->scratch_frame, &scratch_pict); if((temp_size = rd_strip(s, y, FFMIN(h, s->h - y), frame->key_frame, &last_pict, &pict, &scratch_pict, s->frame_buf + CVID_HEADER_SIZE, &score_temp)) < 0) return temp_size; score += score_temp; size += temp_size; } if(best_score == 0 || score < best_score) { best_score = score; best_size = size + write_cvid_header(s, s->frame_buf, num_strips, size); av_log(s->avctx, AV_LOG_INFO, "best number of strips so far: %2i, %12li, %i B\n", num_strips, score, best_size); FFSWAP(AVFrame, s->best_frame, s->scratch_frame); } } memcpy(buf, s->frame_buf, best_size); return best_size; }
true
FFmpeg
7da9f4523159670d577a2808d4481e64008a8894
static int rd_frame(CinepakEncContext *s, AVFrame *frame, unsigned char *buf, int buf_size) { int num_strips, strip, h, i, y, size, temp_size, best_size; AVPicture last_pict, pict, scratch_pict; int64_t best_score = 0, score, score_temp; for(num_strips = MIN_STRIPS; num_strips <= MAX_STRIPS && num_strips <= s->h / MB_SIZE; num_strips++) { score = 0; size = 0; h = s->h / num_strips; h += 4 - (h & 3); for(strip = 0; strip < num_strips; strip++) { y = strip*h; get_sub_picture(s, 0, y, (AVPicture*)frame, &pict); get_sub_picture(s, 0, y, (AVPicture*)&s->last_frame, &last_pict); get_sub_picture(s, 0, y, (AVPicture*)&s->scratch_frame, &scratch_pict); if((temp_size = rd_strip(s, y, FFMIN(h, s->h - y), frame->key_frame, &last_pict, &pict, &scratch_pict, s->frame_buf + CVID_HEADER_SIZE, &score_temp)) < 0) return temp_size; score += score_temp; size += temp_size; } if(best_score == 0 || score < best_score) { best_score = score; best_size = size + write_cvid_header(s, s->frame_buf, num_strips, size); av_log(s->avctx, AV_LOG_INFO, "best number of strips so far: %2i, %12li, %i B\n", num_strips, score, best_size); FFSWAP(AVFrame, s->best_frame, s->scratch_frame); } } memcpy(buf, s->frame_buf, best_size); return best_size; }
{ "code": [ "static int rd_frame(CinepakEncContext *s, AVFrame *frame, unsigned char *buf, int buf_size)", " int num_strips, strip, h, i, y, size, temp_size, best_size;", " for(num_strips = MIN_STRIPS; num_strips <= MAX_STRIPS && num_strips <= s->h / MB_SIZE; num_strips++) {", " h = s->h / num_strips;", " h += 4 - (h & 3);", " for(strip = 0; strip < num_strips; strip++) {", " y = strip*h;", " get_sub_picture(s, 0, y, (AVPicture*)frame, &pict);", " get_sub_picture(s, 0, y, (AVPicture*)&s->last_frame, &last_pict);", " get_sub_picture(s, 0, y, (AVPicture*)&s->scratch_frame, &scratch_pict);", " if((temp_size = rd_strip(s, y, FFMIN(h, s->h - y), frame->key_frame, &last_pict, &pict, &scratch_pict, s->frame_buf + CVID_HEADER_SIZE, &score_temp)) < 0)", " best_size = size + write_cvid_header(s, s->frame_buf, num_strips, size);", " av_log(s->avctx, AV_LOG_INFO, \"best number of strips so far: %2i, %12li, %i B\\n\", num_strips, score, best_size);", " FFSWAP(AVFrame, s->best_frame, s->scratch_frame);", " memcpy(buf, s->frame_buf, best_size);" ], "line_no": [ 1, 5, 15, 21, 25, 29, 31, 35, 37, 39, 43, 61, 63, 67, 75 ] }
static int FUNC_0(CinepakEncContext *VAR_0, AVFrame *VAR_1, unsigned char *VAR_2, int VAR_3) { int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11; AVPicture last_pict, pict, scratch_pict; int64_t best_score = 0, score, score_temp; for(VAR_4 = MIN_STRIPS; VAR_4 <= MAX_STRIPS && VAR_4 <= VAR_0->VAR_6 / MB_SIZE; VAR_4++) { score = 0; VAR_9 = 0; VAR_6 = VAR_0->VAR_6 / VAR_4; VAR_6 += 4 - (VAR_6 & 3); for(VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) { VAR_8 = VAR_5*VAR_6; get_sub_picture(VAR_0, 0, VAR_8, (AVPicture*)VAR_1, &pict); get_sub_picture(VAR_0, 0, VAR_8, (AVPicture*)&VAR_0->last_frame, &last_pict); get_sub_picture(VAR_0, 0, VAR_8, (AVPicture*)&VAR_0->scratch_frame, &scratch_pict); if((VAR_10 = rd_strip(VAR_0, VAR_8, FFMIN(VAR_6, VAR_0->VAR_6 - VAR_8), VAR_1->key_frame, &last_pict, &pict, &scratch_pict, VAR_0->frame_buf + CVID_HEADER_SIZE, &score_temp)) < 0) return VAR_10; score += score_temp; VAR_9 += VAR_10; } if(best_score == 0 || score < best_score) { best_score = score; VAR_11 = VAR_9 + write_cvid_header(VAR_0, VAR_0->frame_buf, VAR_4, VAR_9); av_log(VAR_0->avctx, AV_LOG_INFO, "best number of strips so far: %2i, %12li, %VAR_7 B\n", VAR_4, score, VAR_11); FFSWAP(AVFrame, VAR_0->best_frame, VAR_0->scratch_frame); } } memcpy(VAR_2, VAR_0->frame_buf, VAR_11); return VAR_11; }
[ "static int FUNC_0(CinepakEncContext *VAR_0, AVFrame *VAR_1, unsigned char *VAR_2, int VAR_3)\n{", "int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;", "AVPicture last_pict, pict, scratch_pict;", "int64_t best_score = 0, score, score_temp;", "for(VAR_4 = MIN_STRIPS; VAR_4 <= MAX_STRIPS && VAR_4 <= VAR_0->VAR_6 / MB_SIZE; VAR_4++) {", "score = 0;", "VAR_9 = 0;", "VAR_6 = VAR_0->VAR_6 / VAR_4;", "VAR_6 += 4 - (VAR_6 & 3);", "for(VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {", "VAR_8 = VAR_5*VAR_6;", "get_sub_picture(VAR_0, 0, VAR_8, (AVPicture*)VAR_1, &pict);", "get_sub_picture(VAR_0, 0, VAR_8, (AVPicture*)&VAR_0->last_frame, &last_pict);", "get_sub_picture(VAR_0, 0, VAR_8, (AVPicture*)&VAR_0->scratch_frame, &scratch_pict);", "if((VAR_10 = rd_strip(VAR_0, VAR_8, FFMIN(VAR_6, VAR_0->VAR_6 - VAR_8), VAR_1->key_frame, &last_pict, &pict, &scratch_pict, VAR_0->frame_buf + CVID_HEADER_SIZE, &score_temp)) < 0)\nreturn VAR_10;", "score += score_temp;", "VAR_9 += VAR_10;", "}", "if(best_score == 0 || score < best_score) {", "best_score = score;", "VAR_11 = VAR_9 + write_cvid_header(VAR_0, VAR_0->frame_buf, VAR_4, VAR_9);", "av_log(VAR_0->avctx, AV_LOG_INFO, \"best number of strips so far: %2i, %12li, %VAR_7 B\\n\", VAR_4, score, VAR_11);", "FFSWAP(AVFrame, VAR_0->best_frame, VAR_0->scratch_frame);", "}", "}", "memcpy(VAR_2, VAR_0->frame_buf, VAR_11);", "return VAR_11;", "}" ]
[ 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 43, 45 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 79 ], [ 81 ] ]
717
void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC, int xBase, int yBase, int log2_cb_size) { int qp_y = get_qPy_pred(s, xC, yC, xBase, yBase, log2_cb_size); if (s->HEVClc->tu.cu_qp_delta != 0) { int off = s->sps->qp_bd_offset; s->HEVClc->qp_y = ((qp_y + s->HEVClc->tu.cu_qp_delta + 52 + 2 * off) % (52 + off)) - off; } else s->HEVClc->qp_y = qp_y; }
true
FFmpeg
4ced5d7780fea2ea49444d6686d26f26b3a2160f
void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC, int xBase, int yBase, int log2_cb_size) { int qp_y = get_qPy_pred(s, xC, yC, xBase, yBase, log2_cb_size); if (s->HEVClc->tu.cu_qp_delta != 0) { int off = s->sps->qp_bd_offset; s->HEVClc->qp_y = ((qp_y + s->HEVClc->tu.cu_qp_delta + 52 + 2 * off) % (52 + off)) - off; } else s->HEVClc->qp_y = qp_y; }
{ "code": [ " s->HEVClc->qp_y = ((qp_y + s->HEVClc->tu.cu_qp_delta + 52 + 2 * off) %", " (52 + off)) - off;" ], "line_no": [ 15, 17 ] }
void FUNC_0(HEVCContext *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4, int VAR_5) { int VAR_6 = get_qPy_pred(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5); if (VAR_0->HEVClc->tu.cu_qp_delta != 0) { int VAR_7 = VAR_0->sps->qp_bd_offset; VAR_0->HEVClc->VAR_6 = ((VAR_6 + VAR_0->HEVClc->tu.cu_qp_delta + 52 + 2 * VAR_7) % (52 + VAR_7)) - VAR_7; } else VAR_0->HEVClc->VAR_6 = VAR_6; }
[ "void FUNC_0(HEVCContext *VAR_0, int VAR_1, int VAR_2,\nint VAR_3, int VAR_4, int VAR_5)\n{", "int VAR_6 = get_qPy_pred(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);", "if (VAR_0->HEVClc->tu.cu_qp_delta != 0) {", "int VAR_7 = VAR_0->sps->qp_bd_offset;", "VAR_0->HEVClc->VAR_6 = ((VAR_6 + VAR_0->HEVClc->tu.cu_qp_delta + 52 + 2 * VAR_7) %\n(52 + VAR_7)) - VAR_7;", "} else", "VAR_0->HEVClc->VAR_6 = VAR_6;", "}" ]
[ 0, 0, 0, 0, 1, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15, 17 ], [ 19 ], [ 21 ], [ 23 ] ]
718
static void sdhci_sysbus_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->vmsd = &sdhci_vmstate; dc->props = sdhci_sysbus_properties; dc->realize = sdhci_sysbus_realize; dc->reset = sdhci_poweron_reset; }
true
qemu
e4f4fb1eca795e36f363b4647724221e774523c1
static void sdhci_sysbus_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->vmsd = &sdhci_vmstate; dc->props = sdhci_sysbus_properties; dc->realize = sdhci_sysbus_realize; dc->reset = sdhci_poweron_reset; }
{ "code": [], "line_no": [] }
static void FUNC_0(ObjectClass *VAR_0, void *VAR_1) { DeviceClass *dc = DEVICE_CLASS(VAR_0); dc->vmsd = &sdhci_vmstate; dc->props = sdhci_sysbus_properties; dc->realize = sdhci_sysbus_realize; dc->reset = sdhci_poweron_reset; }
[ "static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{", "DeviceClass *dc = DEVICE_CLASS(VAR_0);", "dc->vmsd = &sdhci_vmstate;", "dc->props = sdhci_sysbus_properties;", "dc->realize = sdhci_sysbus_realize;", "dc->reset = sdhci_poweron_reset;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 22 ] ]
719
grlib_gptimer_writel(void *opaque, target_phys_addr_t addr, uint32_t value) { GPTimerUnit *unit = opaque; target_phys_addr_t timer_addr; int id; addr &= 0xff; /* Unit registers */ switch (addr) { case SCALER_OFFSET: value &= 0xFFFF; /* clean up the value */ unit->scaler = value; trace_grlib_gptimer_writel(-1, "scaler:", unit->scaler); return; case SCALER_RELOAD_OFFSET: value &= 0xFFFF; /* clean up the value */ unit->reload = value; trace_grlib_gptimer_writel(-1, "reload:", unit->reload); grlib_gptimer_set_scaler(unit, value); return; case CONFIG_OFFSET: /* Read Only (disable timer freeze not supported) */ trace_grlib_gptimer_writel(-1, "config (Read Only):", 0); return; default: break; } timer_addr = (addr % TIMER_BASE); id = (addr - TIMER_BASE) / TIMER_BASE; if (id >= 0 && id < unit->nr_timers) { /* GPTimer registers */ switch (timer_addr) { case COUNTER_OFFSET: trace_grlib_gptimer_writel(id, "counter:", value); unit->timers[id].counter = value; grlib_gptimer_enable(&unit->timers[id]); return; case COUNTER_RELOAD_OFFSET: trace_grlib_gptimer_writel(id, "reload:", value); unit->timers[id].reload = value; return; case CONFIG_OFFSET: trace_grlib_gptimer_writel(id, "config:", value); if (value & GPTIMER_INT_PENDING) { /* clear pending bit */ value &= ~GPTIMER_INT_PENDING; } else { /* keep pending bit */ value |= unit->timers[id].config & GPTIMER_INT_PENDING; } unit->timers[id].config = value; /* gptimer_restart calls gptimer_enable, so if "enable" and "load" bits are present, we just have to call restart. */ if (value & GPTIMER_LOAD) { grlib_gptimer_restart(&unit->timers[id]); } else if (value & GPTIMER_ENABLE) { grlib_gptimer_enable(&unit->timers[id]); } /* These fields must always be read as 0 */ value &= ~(GPTIMER_LOAD & GPTIMER_DEBUG_HALT); unit->timers[id].config = value; return; default: break; } } trace_grlib_gptimer_unknown_register("write", addr); }
true
qemu
b4548fcc0314f5e118ed45b5774e9cd99f9a97d3
grlib_gptimer_writel(void *opaque, target_phys_addr_t addr, uint32_t value) { GPTimerUnit *unit = opaque; target_phys_addr_t timer_addr; int id; addr &= 0xff; switch (addr) { case SCALER_OFFSET: value &= 0xFFFF; unit->scaler = value; trace_grlib_gptimer_writel(-1, "scaler:", unit->scaler); return; case SCALER_RELOAD_OFFSET: value &= 0xFFFF; unit->reload = value; trace_grlib_gptimer_writel(-1, "reload:", unit->reload); grlib_gptimer_set_scaler(unit, value); return; case CONFIG_OFFSET: trace_grlib_gptimer_writel(-1, "config (Read Only):", 0); return; default: break; } timer_addr = (addr % TIMER_BASE); id = (addr - TIMER_BASE) / TIMER_BASE; if (id >= 0 && id < unit->nr_timers) { switch (timer_addr) { case COUNTER_OFFSET: trace_grlib_gptimer_writel(id, "counter:", value); unit->timers[id].counter = value; grlib_gptimer_enable(&unit->timers[id]); return; case COUNTER_RELOAD_OFFSET: trace_grlib_gptimer_writel(id, "reload:", value); unit->timers[id].reload = value; return; case CONFIG_OFFSET: trace_grlib_gptimer_writel(id, "config:", value); if (value & GPTIMER_INT_PENDING) { value &= ~GPTIMER_INT_PENDING; } else { value |= unit->timers[id].config & GPTIMER_INT_PENDING; } unit->timers[id].config = value; if (value & GPTIMER_LOAD) { grlib_gptimer_restart(&unit->timers[id]); } else if (value & GPTIMER_ENABLE) { grlib_gptimer_enable(&unit->timers[id]); } value &= ~(GPTIMER_LOAD & GPTIMER_DEBUG_HALT); unit->timers[id].config = value; return; default: break; } } trace_grlib_gptimer_unknown_register("write", addr); }
{ "code": [ " trace_grlib_gptimer_writel(-1, \"scaler:\", unit->scaler);", " trace_grlib_gptimer_writel(-1, \"reload:\", unit->reload);", " trace_grlib_gptimer_writel(-1, \"config (Read Only):\", 0);", " trace_grlib_gptimer_writel(id, \"counter:\", value);", " trace_grlib_gptimer_writel(id, \"reload:\", value);", " trace_grlib_gptimer_writel(id, \"config:\", value);", " trace_grlib_gptimer_unknown_register(\"write\", addr);" ], "line_no": [ 27, 39, 51, 81, 93, 103, 169 ] }
FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint32_t VAR_2) { GPTimerUnit *unit = VAR_0; target_phys_addr_t timer_addr; int VAR_3; VAR_1 &= 0xff; switch (VAR_1) { case SCALER_OFFSET: VAR_2 &= 0xFFFF; unit->scaler = VAR_2; trace_grlib_gptimer_writel(-1, "scaler:", unit->scaler); return; case SCALER_RELOAD_OFFSET: VAR_2 &= 0xFFFF; unit->reload = VAR_2; trace_grlib_gptimer_writel(-1, "reload:", unit->reload); grlib_gptimer_set_scaler(unit, VAR_2); return; case CONFIG_OFFSET: trace_grlib_gptimer_writel(-1, "config (Read Only):", 0); return; default: break; } timer_addr = (VAR_1 % TIMER_BASE); VAR_3 = (VAR_1 - TIMER_BASE) / TIMER_BASE; if (VAR_3 >= 0 && VAR_3 < unit->nr_timers) { switch (timer_addr) { case COUNTER_OFFSET: trace_grlib_gptimer_writel(VAR_3, "counter:", VAR_2); unit->timers[VAR_3].counter = VAR_2; grlib_gptimer_enable(&unit->timers[VAR_3]); return; case COUNTER_RELOAD_OFFSET: trace_grlib_gptimer_writel(VAR_3, "reload:", VAR_2); unit->timers[VAR_3].reload = VAR_2; return; case CONFIG_OFFSET: trace_grlib_gptimer_writel(VAR_3, "config:", VAR_2); if (VAR_2 & GPTIMER_INT_PENDING) { VAR_2 &= ~GPTIMER_INT_PENDING; } else { VAR_2 |= unit->timers[VAR_3].config & GPTIMER_INT_PENDING; } unit->timers[VAR_3].config = VAR_2; if (VAR_2 & GPTIMER_LOAD) { grlib_gptimer_restart(&unit->timers[VAR_3]); } else if (VAR_2 & GPTIMER_ENABLE) { grlib_gptimer_enable(&unit->timers[VAR_3]); } VAR_2 &= ~(GPTIMER_LOAD & GPTIMER_DEBUG_HALT); unit->timers[VAR_3].config = VAR_2; return; default: break; } } trace_grlib_gptimer_unknown_register("write", VAR_1); }
[ "FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint32_t VAR_2)\n{", "GPTimerUnit *unit = VAR_0;", "target_phys_addr_t timer_addr;", "int VAR_3;", "VAR_1 &= 0xff;", "switch (VAR_1) {", "case SCALER_OFFSET:\nVAR_2 &= 0xFFFF;", "unit->scaler = VAR_2;", "trace_grlib_gptimer_writel(-1, \"scaler:\", unit->scaler);", "return;", "case SCALER_RELOAD_OFFSET:\nVAR_2 &= 0xFFFF;", "unit->reload = VAR_2;", "trace_grlib_gptimer_writel(-1, \"reload:\", unit->reload);", "grlib_gptimer_set_scaler(unit, VAR_2);", "return;", "case CONFIG_OFFSET:\ntrace_grlib_gptimer_writel(-1, \"config (Read Only):\", 0);", "return;", "default:\nbreak;", "}", "timer_addr = (VAR_1 % TIMER_BASE);", "VAR_3 = (VAR_1 - TIMER_BASE) / TIMER_BASE;", "if (VAR_3 >= 0 && VAR_3 < unit->nr_timers) {", "switch (timer_addr) {", "case COUNTER_OFFSET:\ntrace_grlib_gptimer_writel(VAR_3, \"counter:\", VAR_2);", "unit->timers[VAR_3].counter = VAR_2;", "grlib_gptimer_enable(&unit->timers[VAR_3]);", "return;", "case COUNTER_RELOAD_OFFSET:\ntrace_grlib_gptimer_writel(VAR_3, \"reload:\", VAR_2);", "unit->timers[VAR_3].reload = VAR_2;", "return;", "case CONFIG_OFFSET:\ntrace_grlib_gptimer_writel(VAR_3, \"config:\", VAR_2);", "if (VAR_2 & GPTIMER_INT_PENDING) {", "VAR_2 &= ~GPTIMER_INT_PENDING;", "} else {", "VAR_2 |= unit->timers[VAR_3].config & GPTIMER_INT_PENDING;", "}", "unit->timers[VAR_3].config = VAR_2;", "if (VAR_2 & GPTIMER_LOAD) {", "grlib_gptimer_restart(&unit->timers[VAR_3]);", "} else if (VAR_2 & GPTIMER_ENABLE) {", "grlib_gptimer_enable(&unit->timers[VAR_3]);", "}", "VAR_2 &= ~(GPTIMER_LOAD & GPTIMER_DEBUG_HALT);", "unit->timers[VAR_3].config = VAR_2;", "return;", "default:\nbreak;", "}", "}", "trace_grlib_gptimer_unknown_register(\"write\", VAR_1);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47, 51 ], [ 53 ], [ 57, 59 ], [ 61 ], [ 65 ], [ 67 ], [ 71 ], [ 77 ], [ 79, 81 ], [ 83 ], [ 85 ], [ 87 ], [ 91, 93 ], [ 95 ], [ 97 ], [ 101, 103 ], [ 107 ], [ 111 ], [ 113 ], [ 117 ], [ 119 ], [ 123 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 147 ], [ 151 ], [ 153 ], [ 157, 159 ], [ 161 ], [ 165 ], [ 169 ], [ 171 ] ]
720
static void check_watchpoint(int offset, int len, MemTxAttrs attrs, int flags) { CPUState *cpu = current_cpu; CPUClass *cc = CPU_GET_CLASS(cpu); CPUArchState *env = cpu->env_ptr; target_ulong pc, cs_base; target_ulong vaddr; CPUWatchpoint *wp; uint32_t cpu_flags; if (cpu->watchpoint_hit) { /* We re-entered the check after replacing the TB. Now raise * the debug interrupt so that is will trigger after the * current instruction. */ cpu_interrupt(cpu, CPU_INTERRUPT_DEBUG); return; } vaddr = (cpu->mem_io_vaddr & TARGET_PAGE_MASK) + offset; vaddr = cc->adjust_watchpoint_address(cpu, vaddr, len); QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { if (cpu_watchpoint_address_matches(wp, vaddr, len) && (wp->flags & flags)) { if (flags == BP_MEM_READ) { wp->flags |= BP_WATCHPOINT_HIT_READ; } else { wp->flags |= BP_WATCHPOINT_HIT_WRITE; } wp->hitaddr = vaddr; wp->hitattrs = attrs; if (!cpu->watchpoint_hit) { if (wp->flags & BP_CPU && !cc->debug_check_watchpoint(cpu, wp)) { wp->flags &= ~BP_WATCHPOINT_HIT; continue; } cpu->watchpoint_hit = wp; /* The tb_lock will be reset when cpu_loop_exit or * cpu_loop_exit_noexc longjmp back into the cpu_exec * main loop. */ tb_lock(); tb_check_watchpoint(cpu); if (wp->flags & BP_STOP_BEFORE_ACCESS) { cpu->exception_index = EXCP_DEBUG; cpu_loop_exit(cpu); } else { cpu_get_tb_cpu_state(env, &pc, &cs_base, &cpu_flags); tb_gen_code(cpu, pc, cs_base, cpu_flags, 1); cpu_loop_exit_noexc(cpu); } } } else { wp->flags &= ~BP_WATCHPOINT_HIT; } } }
true
qemu
8d04fb55dec381bc5105cb47f29d918e579e8cbd
static void check_watchpoint(int offset, int len, MemTxAttrs attrs, int flags) { CPUState *cpu = current_cpu; CPUClass *cc = CPU_GET_CLASS(cpu); CPUArchState *env = cpu->env_ptr; target_ulong pc, cs_base; target_ulong vaddr; CPUWatchpoint *wp; uint32_t cpu_flags; if (cpu->watchpoint_hit) { cpu_interrupt(cpu, CPU_INTERRUPT_DEBUG); return; } vaddr = (cpu->mem_io_vaddr & TARGET_PAGE_MASK) + offset; vaddr = cc->adjust_watchpoint_address(cpu, vaddr, len); QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { if (cpu_watchpoint_address_matches(wp, vaddr, len) && (wp->flags & flags)) { if (flags == BP_MEM_READ) { wp->flags |= BP_WATCHPOINT_HIT_READ; } else { wp->flags |= BP_WATCHPOINT_HIT_WRITE; } wp->hitaddr = vaddr; wp->hitattrs = attrs; if (!cpu->watchpoint_hit) { if (wp->flags & BP_CPU && !cc->debug_check_watchpoint(cpu, wp)) { wp->flags &= ~BP_WATCHPOINT_HIT; continue; } cpu->watchpoint_hit = wp; tb_lock(); tb_check_watchpoint(cpu); if (wp->flags & BP_STOP_BEFORE_ACCESS) { cpu->exception_index = EXCP_DEBUG; cpu_loop_exit(cpu); } else { cpu_get_tb_cpu_state(env, &pc, &cs_base, &cpu_flags); tb_gen_code(cpu, pc, cs_base, cpu_flags, 1); cpu_loop_exit_noexc(cpu); } } } else { wp->flags &= ~BP_WATCHPOINT_HIT; } } }
{ "code": [], "line_no": [] }
static void FUNC_0(int VAR_0, int VAR_1, MemTxAttrs VAR_2, int VAR_3) { CPUState *cpu = current_cpu; CPUClass *cc = CPU_GET_CLASS(cpu); CPUArchState *env = cpu->env_ptr; target_ulong pc, cs_base; target_ulong vaddr; CPUWatchpoint *wp; uint32_t cpu_flags; if (cpu->watchpoint_hit) { cpu_interrupt(cpu, CPU_INTERRUPT_DEBUG); return; } vaddr = (cpu->mem_io_vaddr & TARGET_PAGE_MASK) + VAR_0; vaddr = cc->adjust_watchpoint_address(cpu, vaddr, VAR_1); QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { if (cpu_watchpoint_address_matches(wp, vaddr, VAR_1) && (wp->VAR_3 & VAR_3)) { if (VAR_3 == BP_MEM_READ) { wp->VAR_3 |= BP_WATCHPOINT_HIT_READ; } else { wp->VAR_3 |= BP_WATCHPOINT_HIT_WRITE; } wp->hitaddr = vaddr; wp->hitattrs = VAR_2; if (!cpu->watchpoint_hit) { if (wp->VAR_3 & BP_CPU && !cc->debug_check_watchpoint(cpu, wp)) { wp->VAR_3 &= ~BP_WATCHPOINT_HIT; continue; } cpu->watchpoint_hit = wp; tb_lock(); tb_check_watchpoint(cpu); if (wp->VAR_3 & BP_STOP_BEFORE_ACCESS) { cpu->exception_index = EXCP_DEBUG; cpu_loop_exit(cpu); } else { cpu_get_tb_cpu_state(env, &pc, &cs_base, &cpu_flags); tb_gen_code(cpu, pc, cs_base, cpu_flags, 1); cpu_loop_exit_noexc(cpu); } } } else { wp->VAR_3 &= ~BP_WATCHPOINT_HIT; } } }
[ "static void FUNC_0(int VAR_0, int VAR_1, MemTxAttrs VAR_2, int VAR_3)\n{", "CPUState *cpu = current_cpu;", "CPUClass *cc = CPU_GET_CLASS(cpu);", "CPUArchState *env = cpu->env_ptr;", "target_ulong pc, cs_base;", "target_ulong vaddr;", "CPUWatchpoint *wp;", "uint32_t cpu_flags;", "if (cpu->watchpoint_hit) {", "cpu_interrupt(cpu, CPU_INTERRUPT_DEBUG);", "return;", "}", "vaddr = (cpu->mem_io_vaddr & TARGET_PAGE_MASK) + VAR_0;", "vaddr = cc->adjust_watchpoint_address(cpu, vaddr, VAR_1);", "QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) {", "if (cpu_watchpoint_address_matches(wp, vaddr, VAR_1)\n&& (wp->VAR_3 & VAR_3)) {", "if (VAR_3 == BP_MEM_READ) {", "wp->VAR_3 |= BP_WATCHPOINT_HIT_READ;", "} else {", "wp->VAR_3 |= BP_WATCHPOINT_HIT_WRITE;", "}", "wp->hitaddr = vaddr;", "wp->hitattrs = VAR_2;", "if (!cpu->watchpoint_hit) {", "if (wp->VAR_3 & BP_CPU &&\n!cc->debug_check_watchpoint(cpu, wp)) {", "wp->VAR_3 &= ~BP_WATCHPOINT_HIT;", "continue;", "}", "cpu->watchpoint_hit = wp;", "tb_lock();", "tb_check_watchpoint(cpu);", "if (wp->VAR_3 & BP_STOP_BEFORE_ACCESS) {", "cpu->exception_index = EXCP_DEBUG;", "cpu_loop_exit(cpu);", "} else {", "cpu_get_tb_cpu_state(env, &pc, &cs_base, &cpu_flags);", "tb_gen_code(cpu, pc, cs_base, cpu_flags, 1);", "cpu_loop_exit_noexc(cpu);", "}", "}", "} else {", "wp->VAR_3 &= ~BP_WATCHPOINT_HIT;", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41, 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61, 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ] ]
721
DISAS_INSN(shift_im) { TCGv reg; int tmp; TCGv shift; set_cc_op(s, CC_OP_FLAGS); reg = DREG(insn, 0); tmp = (insn >> 9) & 7; if (tmp == 0) tmp = 8; shift = tcg_const_i32(tmp); /* No need to flush flags becuse we know we will set C flag. */ if (insn & 0x100) { gen_helper_shl_cc(reg, cpu_env, reg, shift); } else { if (insn & 8) { gen_helper_shr_cc(reg, cpu_env, reg, shift); } else { gen_helper_sar_cc(reg, cpu_env, reg, shift); } } }
true
qemu
367790cce8e14131426f5190dfd7d1bdbf656e4d
DISAS_INSN(shift_im) { TCGv reg; int tmp; TCGv shift; set_cc_op(s, CC_OP_FLAGS); reg = DREG(insn, 0); tmp = (insn >> 9) & 7; if (tmp == 0) tmp = 8; shift = tcg_const_i32(tmp); if (insn & 0x100) { gen_helper_shl_cc(reg, cpu_env, reg, shift); } else { if (insn & 8) { gen_helper_shr_cc(reg, cpu_env, reg, shift); } else { gen_helper_sar_cc(reg, cpu_env, reg, shift); } } }
{ "code": [ "DISAS_INSN(shift_im)", " TCGv reg;", " int tmp;", " TCGv shift;", " reg = DREG(insn, 0);", " tmp = (insn >> 9) & 7;", " if (tmp == 0)", " tmp = 8;", " shift = tcg_const_i32(tmp);", " if (insn & 0x100) {", " gen_helper_shl_cc(reg, cpu_env, reg, shift);", " if (insn & 8) {", " gen_helper_shr_cc(reg, cpu_env, reg, shift);", " gen_helper_sar_cc(reg, cpu_env, reg, shift);", " TCGv reg;", " TCGv shift;", " reg = DREG(insn, 0);", " if (insn & 0x100) {", " gen_helper_shl_cc(reg, cpu_env, reg, shift);", " if (insn & 8) {", " gen_helper_shr_cc(reg, cpu_env, reg, shift);", " gen_helper_sar_cc(reg, cpu_env, reg, shift);" ], "line_no": [ 1, 5, 7, 9, 17, 19, 21, 23, 25, 29, 31, 35, 37, 41, 5, 9, 17, 29, 31, 35, 37, 41 ] }
FUNC_0(VAR_0) { TCGv reg; int VAR_1; TCGv shift; set_cc_op(s, CC_OP_FLAGS); reg = DREG(insn, 0); VAR_1 = (insn >> 9) & 7; if (VAR_1 == 0) VAR_1 = 8; shift = tcg_const_i32(VAR_1); if (insn & 0x100) { gen_helper_shl_cc(reg, cpu_env, reg, shift); } else { if (insn & 8) { gen_helper_shr_cc(reg, cpu_env, reg, shift); } else { gen_helper_sar_cc(reg, cpu_env, reg, shift); } } }
[ "FUNC_0(VAR_0)\n{", "TCGv reg;", "int VAR_1;", "TCGv shift;", "set_cc_op(s, CC_OP_FLAGS);", "reg = DREG(insn, 0);", "VAR_1 = (insn >> 9) & 7;", "if (VAR_1 == 0)\nVAR_1 = 8;", "shift = tcg_const_i32(VAR_1);", "if (insn & 0x100) {", "gen_helper_shl_cc(reg, cpu_env, reg, shift);", "} else {", "if (insn & 8) {", "gen_helper_shr_cc(reg, cpu_env, reg, shift);", "} else {", "gen_helper_sar_cc(reg, cpu_env, reg, shift);", "}", "}", "}" ]
[ 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 17 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ] ]
722
static target_ulong h_protect(PowerPCCPU *cpu, sPAPRMachineState *spapr, target_ulong opcode, target_ulong *args) { CPUPPCState *env = &cpu->env; target_ulong flags = args[0]; target_ulong pte_index = args[1]; target_ulong avpn = args[2]; uint64_t token; target_ulong v, r, rb; if (!valid_pte_index(env, pte_index)) { return H_PARAMETER; } token = ppc_hash64_start_access(cpu, pte_index); v = ppc_hash64_load_hpte0(cpu, token, 0); r = ppc_hash64_load_hpte1(cpu, token, 0); ppc_hash64_stop_access(token); if ((v & HPTE64_V_VALID) == 0 || ((flags & H_AVPN) && (v & ~0x7fULL) != avpn)) { return H_NOT_FOUND; } r &= ~(HPTE64_R_PP0 | HPTE64_R_PP | HPTE64_R_N | HPTE64_R_KEY_HI | HPTE64_R_KEY_LO); r |= (flags << 55) & HPTE64_R_PP0; r |= (flags << 48) & HPTE64_R_KEY_HI; r |= flags & (HPTE64_R_PP | HPTE64_R_N | HPTE64_R_KEY_LO); rb = compute_tlbie_rb(v, r, pte_index); ppc_hash64_store_hpte(cpu, pte_index, (v & ~HPTE64_V_VALID) | HPTE64_V_HPTE_DIRTY, 0); ppc_tlb_invalidate_one(env, rb); /* Don't need a memory barrier, due to qemu's global lock */ ppc_hash64_store_hpte(cpu, pte_index, v | HPTE64_V_HPTE_DIRTY, r); return H_SUCCESS; }
true
qemu
61a36c9b5a12889994e6c45f4a175efcd63936db
static target_ulong h_protect(PowerPCCPU *cpu, sPAPRMachineState *spapr, target_ulong opcode, target_ulong *args) { CPUPPCState *env = &cpu->env; target_ulong flags = args[0]; target_ulong pte_index = args[1]; target_ulong avpn = args[2]; uint64_t token; target_ulong v, r, rb; if (!valid_pte_index(env, pte_index)) { return H_PARAMETER; } token = ppc_hash64_start_access(cpu, pte_index); v = ppc_hash64_load_hpte0(cpu, token, 0); r = ppc_hash64_load_hpte1(cpu, token, 0); ppc_hash64_stop_access(token); if ((v & HPTE64_V_VALID) == 0 || ((flags & H_AVPN) && (v & ~0x7fULL) != avpn)) { return H_NOT_FOUND; } r &= ~(HPTE64_R_PP0 | HPTE64_R_PP | HPTE64_R_N | HPTE64_R_KEY_HI | HPTE64_R_KEY_LO); r |= (flags << 55) & HPTE64_R_PP0; r |= (flags << 48) & HPTE64_R_KEY_HI; r |= flags & (HPTE64_R_PP | HPTE64_R_N | HPTE64_R_KEY_LO); rb = compute_tlbie_rb(v, r, pte_index); ppc_hash64_store_hpte(cpu, pte_index, (v & ~HPTE64_V_VALID) | HPTE64_V_HPTE_DIRTY, 0); ppc_tlb_invalidate_one(env, rb); ppc_hash64_store_hpte(cpu, pte_index, v | HPTE64_V_HPTE_DIRTY, r); return H_SUCCESS; }
{ "code": [ " target_ulong v, r, rb;", " ppc_tlb_invalidate_one(env, rb);", " target_ulong v, r, rb;", " rb = compute_tlbie_rb(v, r, pte_index);", " ppc_tlb_invalidate_one(env, rb);" ], "line_no": [ 17, 65, 17, 59, 65 ] }
static target_ulong FUNC_0(PowerPCCPU *cpu, sPAPRMachineState *spapr, target_ulong opcode, target_ulong *args) { CPUPPCState *env = &cpu->env; target_ulong flags = args[0]; target_ulong pte_index = args[1]; target_ulong avpn = args[2]; uint64_t token; target_ulong v, r, rb; if (!valid_pte_index(env, pte_index)) { return H_PARAMETER; } token = ppc_hash64_start_access(cpu, pte_index); v = ppc_hash64_load_hpte0(cpu, token, 0); r = ppc_hash64_load_hpte1(cpu, token, 0); ppc_hash64_stop_access(token); if ((v & HPTE64_V_VALID) == 0 || ((flags & H_AVPN) && (v & ~0x7fULL) != avpn)) { return H_NOT_FOUND; } r &= ~(HPTE64_R_PP0 | HPTE64_R_PP | HPTE64_R_N | HPTE64_R_KEY_HI | HPTE64_R_KEY_LO); r |= (flags << 55) & HPTE64_R_PP0; r |= (flags << 48) & HPTE64_R_KEY_HI; r |= flags & (HPTE64_R_PP | HPTE64_R_N | HPTE64_R_KEY_LO); rb = compute_tlbie_rb(v, r, pte_index); ppc_hash64_store_hpte(cpu, pte_index, (v & ~HPTE64_V_VALID) | HPTE64_V_HPTE_DIRTY, 0); ppc_tlb_invalidate_one(env, rb); ppc_hash64_store_hpte(cpu, pte_index, v | HPTE64_V_HPTE_DIRTY, r); return H_SUCCESS; }
[ "static target_ulong FUNC_0(PowerPCCPU *cpu, sPAPRMachineState *spapr,\ntarget_ulong opcode, target_ulong *args)\n{", "CPUPPCState *env = &cpu->env;", "target_ulong flags = args[0];", "target_ulong pte_index = args[1];", "target_ulong avpn = args[2];", "uint64_t token;", "target_ulong v, r, rb;", "if (!valid_pte_index(env, pte_index)) {", "return H_PARAMETER;", "}", "token = ppc_hash64_start_access(cpu, pte_index);", "v = ppc_hash64_load_hpte0(cpu, token, 0);", "r = ppc_hash64_load_hpte1(cpu, token, 0);", "ppc_hash64_stop_access(token);", "if ((v & HPTE64_V_VALID) == 0 ||\n((flags & H_AVPN) && (v & ~0x7fULL) != avpn)) {", "return H_NOT_FOUND;", "}", "r &= ~(HPTE64_R_PP0 | HPTE64_R_PP | HPTE64_R_N |\nHPTE64_R_KEY_HI | HPTE64_R_KEY_LO);", "r |= (flags << 55) & HPTE64_R_PP0;", "r |= (flags << 48) & HPTE64_R_KEY_HI;", "r |= flags & (HPTE64_R_PP | HPTE64_R_N | HPTE64_R_KEY_LO);", "rb = compute_tlbie_rb(v, r, pte_index);", "ppc_hash64_store_hpte(cpu, pte_index,\n(v & ~HPTE64_V_VALID) | HPTE64_V_HPTE_DIRTY, 0);", "ppc_tlb_invalidate_one(env, rb);", "ppc_hash64_store_hpte(cpu, pte_index, v | HPTE64_V_HPTE_DIRTY, r);", "return H_SUCCESS;", "}" ]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39, 41 ], [ 43 ], [ 45 ], [ 49, 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61, 63 ], [ 65 ], [ 69 ], [ 71 ], [ 73 ] ]
723
static int kvm_get_msrs(X86CPU *cpu) { CPUX86State *env = &cpu->env; struct kvm_msr_entry *msrs = cpu->kvm_msr_buf->entries; int ret, i; uint64_t mtrr_top_bits; kvm_msr_buf_reset(cpu); kvm_msr_entry_add(cpu, MSR_IA32_SYSENTER_CS, 0); kvm_msr_entry_add(cpu, MSR_IA32_SYSENTER_ESP, 0); kvm_msr_entry_add(cpu, MSR_IA32_SYSENTER_EIP, 0); kvm_msr_entry_add(cpu, MSR_PAT, 0); if (has_msr_star) { kvm_msr_entry_add(cpu, MSR_STAR, 0); } if (has_msr_hsave_pa) { kvm_msr_entry_add(cpu, MSR_VM_HSAVE_PA, 0); } if (has_msr_tsc_aux) { kvm_msr_entry_add(cpu, MSR_TSC_AUX, 0); } if (has_msr_tsc_adjust) { kvm_msr_entry_add(cpu, MSR_TSC_ADJUST, 0); } if (has_msr_tsc_deadline) { kvm_msr_entry_add(cpu, MSR_IA32_TSCDEADLINE, 0); } if (has_msr_misc_enable) { kvm_msr_entry_add(cpu, MSR_IA32_MISC_ENABLE, 0); } if (has_msr_smbase) { kvm_msr_entry_add(cpu, MSR_IA32_SMBASE, 0); } if (has_msr_feature_control) { kvm_msr_entry_add(cpu, MSR_IA32_FEATURE_CONTROL, 0); } if (has_msr_bndcfgs) { kvm_msr_entry_add(cpu, MSR_IA32_BNDCFGS, 0); } if (has_msr_xss) { kvm_msr_entry_add(cpu, MSR_IA32_XSS, 0); } if (!env->tsc_valid) { kvm_msr_entry_add(cpu, MSR_IA32_TSC, 0); env->tsc_valid = !runstate_is_running(); } #ifdef TARGET_X86_64 if (lm_capable_kernel) { kvm_msr_entry_add(cpu, MSR_CSTAR, 0); kvm_msr_entry_add(cpu, MSR_KERNELGSBASE, 0); kvm_msr_entry_add(cpu, MSR_FMASK, 0); kvm_msr_entry_add(cpu, MSR_LSTAR, 0); } #endif kvm_msr_entry_add(cpu, MSR_KVM_SYSTEM_TIME, 0); kvm_msr_entry_add(cpu, MSR_KVM_WALL_CLOCK, 0); if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_ASYNC_PF)) { kvm_msr_entry_add(cpu, MSR_KVM_ASYNC_PF_EN, 0); } if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_PV_EOI)) { kvm_msr_entry_add(cpu, MSR_KVM_PV_EOI_EN, 0); } if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_STEAL_TIME)) { kvm_msr_entry_add(cpu, MSR_KVM_STEAL_TIME, 0); } if (has_msr_architectural_pmu) { kvm_msr_entry_add(cpu, MSR_CORE_PERF_FIXED_CTR_CTRL, 0); kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_CTRL, 0); kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_STATUS, 0); kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_OVF_CTRL, 0); for (i = 0; i < MAX_FIXED_COUNTERS; i++) { kvm_msr_entry_add(cpu, MSR_CORE_PERF_FIXED_CTR0 + i, 0); } for (i = 0; i < num_architectural_pmu_counters; i++) { kvm_msr_entry_add(cpu, MSR_P6_PERFCTR0 + i, 0); kvm_msr_entry_add(cpu, MSR_P6_EVNTSEL0 + i, 0); } } if (env->mcg_cap) { kvm_msr_entry_add(cpu, MSR_MCG_STATUS, 0); kvm_msr_entry_add(cpu, MSR_MCG_CTL, 0); if (has_msr_mcg_ext_ctl) { kvm_msr_entry_add(cpu, MSR_MCG_EXT_CTL, 0); } for (i = 0; i < (env->mcg_cap & 0xff) * 4; i++) { kvm_msr_entry_add(cpu, MSR_MC0_CTL + i, 0); } } if (has_msr_hv_hypercall) { kvm_msr_entry_add(cpu, HV_X64_MSR_HYPERCALL, 0); kvm_msr_entry_add(cpu, HV_X64_MSR_GUEST_OS_ID, 0); } if (cpu->hyperv_vapic) { kvm_msr_entry_add(cpu, HV_X64_MSR_APIC_ASSIST_PAGE, 0); } if (cpu->hyperv_time) { kvm_msr_entry_add(cpu, HV_X64_MSR_REFERENCE_TSC, 0); } if (has_msr_hv_crash) { int j; for (j = 0; j < HV_CRASH_PARAMS; j++) { kvm_msr_entry_add(cpu, HV_X64_MSR_CRASH_P0 + j, 0); } } if (has_msr_hv_runtime) { kvm_msr_entry_add(cpu, HV_X64_MSR_VP_RUNTIME, 0); } if (cpu->hyperv_synic) { uint32_t msr; kvm_msr_entry_add(cpu, HV_X64_MSR_SCONTROL, 0); kvm_msr_entry_add(cpu, HV_X64_MSR_SIEFP, 0); kvm_msr_entry_add(cpu, HV_X64_MSR_SIMP, 0); for (msr = HV_X64_MSR_SINT0; msr <= HV_X64_MSR_SINT15; msr++) { kvm_msr_entry_add(cpu, msr, 0); } } if (has_msr_hv_stimer) { uint32_t msr; for (msr = HV_X64_MSR_STIMER0_CONFIG; msr <= HV_X64_MSR_STIMER3_COUNT; msr++) { kvm_msr_entry_add(cpu, msr, 0); } } if (env->features[FEAT_1_EDX] & CPUID_MTRR) { kvm_msr_entry_add(cpu, MSR_MTRRdefType, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix64K_00000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix16K_80000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix16K_A0000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_C0000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_C8000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_D0000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_D8000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_E0000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_E8000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_F0000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_F8000, 0); for (i = 0; i < MSR_MTRRcap_VCNT; i++) { kvm_msr_entry_add(cpu, MSR_MTRRphysBase(i), 0); kvm_msr_entry_add(cpu, MSR_MTRRphysMask(i), 0); } } ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_MSRS, cpu->kvm_msr_buf); if (ret < 0) { return ret; } if (ret < cpu->kvm_msr_buf->nmsrs) { struct kvm_msr_entry *e = &cpu->kvm_msr_buf->entries[ret]; error_report("error: failed to get MSR 0x%" PRIx32, (uint32_t)e->index); } assert(ret == cpu->kvm_msr_buf->nmsrs); /* * MTRR masks: Each mask consists of 5 parts * a 10..0: must be zero * b 11 : valid bit * c n-1.12: actual mask bits * d 51..n: reserved must be zero * e 63.52: reserved must be zero * * 'n' is the number of physical bits supported by the CPU and is * apparently always <= 52. We know our 'n' but don't know what * the destinations 'n' is; it might be smaller, in which case * it masks (c) on loading. It might be larger, in which case * we fill 'd' so that d..c is consistent irrespetive of the 'n' * we're migrating to. */ if (cpu->fill_mtrr_mask) { QEMU_BUILD_BUG_ON(TARGET_PHYS_ADDR_SPACE_BITS > 52); assert(cpu->phys_bits <= TARGET_PHYS_ADDR_SPACE_BITS); mtrr_top_bits = MAKE_64BIT_MASK(cpu->phys_bits, 52 - cpu->phys_bits); } else { mtrr_top_bits = 0; } for (i = 0; i < ret; i++) { uint32_t index = msrs[i].index; switch (index) { case MSR_IA32_SYSENTER_CS: env->sysenter_cs = msrs[i].data; break; case MSR_IA32_SYSENTER_ESP: env->sysenter_esp = msrs[i].data; break; case MSR_IA32_SYSENTER_EIP: env->sysenter_eip = msrs[i].data; break; case MSR_PAT: env->pat = msrs[i].data; break; case MSR_STAR: env->star = msrs[i].data; break; #ifdef TARGET_X86_64 case MSR_CSTAR: env->cstar = msrs[i].data; break; case MSR_KERNELGSBASE: env->kernelgsbase = msrs[i].data; break; case MSR_FMASK: env->fmask = msrs[i].data; break; case MSR_LSTAR: env->lstar = msrs[i].data; break; #endif case MSR_IA32_TSC: env->tsc = msrs[i].data; break; case MSR_TSC_AUX: env->tsc_aux = msrs[i].data; break; case MSR_TSC_ADJUST: env->tsc_adjust = msrs[i].data; break; case MSR_IA32_TSCDEADLINE: env->tsc_deadline = msrs[i].data; break; case MSR_VM_HSAVE_PA: env->vm_hsave = msrs[i].data; break; case MSR_KVM_SYSTEM_TIME: env->system_time_msr = msrs[i].data; break; case MSR_KVM_WALL_CLOCK: env->wall_clock_msr = msrs[i].data; break; case MSR_MCG_STATUS: env->mcg_status = msrs[i].data; break; case MSR_MCG_CTL: env->mcg_ctl = msrs[i].data; break; case MSR_MCG_EXT_CTL: env->mcg_ext_ctl = msrs[i].data; break; case MSR_IA32_MISC_ENABLE: env->msr_ia32_misc_enable = msrs[i].data; break; case MSR_IA32_SMBASE: env->smbase = msrs[i].data; break; case MSR_IA32_FEATURE_CONTROL: env->msr_ia32_feature_control = msrs[i].data; break; case MSR_IA32_BNDCFGS: env->msr_bndcfgs = msrs[i].data; break; case MSR_IA32_XSS: env->xss = msrs[i].data; break; default: if (msrs[i].index >= MSR_MC0_CTL && msrs[i].index < MSR_MC0_CTL + (env->mcg_cap & 0xff) * 4) { env->mce_banks[msrs[i].index - MSR_MC0_CTL] = msrs[i].data; } break; case MSR_KVM_ASYNC_PF_EN: env->async_pf_en_msr = msrs[i].data; break; case MSR_KVM_PV_EOI_EN: env->pv_eoi_en_msr = msrs[i].data; break; case MSR_KVM_STEAL_TIME: env->steal_time_msr = msrs[i].data; break; case MSR_CORE_PERF_FIXED_CTR_CTRL: env->msr_fixed_ctr_ctrl = msrs[i].data; break; case MSR_CORE_PERF_GLOBAL_CTRL: env->msr_global_ctrl = msrs[i].data; break; case MSR_CORE_PERF_GLOBAL_STATUS: env->msr_global_status = msrs[i].data; break; case MSR_CORE_PERF_GLOBAL_OVF_CTRL: env->msr_global_ovf_ctrl = msrs[i].data; break; case MSR_CORE_PERF_FIXED_CTR0 ... MSR_CORE_PERF_FIXED_CTR0 + MAX_FIXED_COUNTERS - 1: env->msr_fixed_counters[index - MSR_CORE_PERF_FIXED_CTR0] = msrs[i].data; break; case MSR_P6_PERFCTR0 ... MSR_P6_PERFCTR0 + MAX_GP_COUNTERS - 1: env->msr_gp_counters[index - MSR_P6_PERFCTR0] = msrs[i].data; break; case MSR_P6_EVNTSEL0 ... MSR_P6_EVNTSEL0 + MAX_GP_COUNTERS - 1: env->msr_gp_evtsel[index - MSR_P6_EVNTSEL0] = msrs[i].data; break; case HV_X64_MSR_HYPERCALL: env->msr_hv_hypercall = msrs[i].data; break; case HV_X64_MSR_GUEST_OS_ID: env->msr_hv_guest_os_id = msrs[i].data; break; case HV_X64_MSR_APIC_ASSIST_PAGE: env->msr_hv_vapic = msrs[i].data; break; case HV_X64_MSR_REFERENCE_TSC: env->msr_hv_tsc = msrs[i].data; break; case HV_X64_MSR_CRASH_P0 ... HV_X64_MSR_CRASH_P4: env->msr_hv_crash_params[index - HV_X64_MSR_CRASH_P0] = msrs[i].data; break; case HV_X64_MSR_VP_RUNTIME: env->msr_hv_runtime = msrs[i].data; break; case HV_X64_MSR_SCONTROL: env->msr_hv_synic_control = msrs[i].data; break; case HV_X64_MSR_SIEFP: env->msr_hv_synic_evt_page = msrs[i].data; break; case HV_X64_MSR_SIMP: env->msr_hv_synic_msg_page = msrs[i].data; break; case HV_X64_MSR_SINT0 ... HV_X64_MSR_SINT15: env->msr_hv_synic_sint[index - HV_X64_MSR_SINT0] = msrs[i].data; break; case HV_X64_MSR_STIMER0_CONFIG: case HV_X64_MSR_STIMER1_CONFIG: case HV_X64_MSR_STIMER2_CONFIG: case HV_X64_MSR_STIMER3_CONFIG: env->msr_hv_stimer_config[(index - HV_X64_MSR_STIMER0_CONFIG)/2] = msrs[i].data; break; case HV_X64_MSR_STIMER0_COUNT: case HV_X64_MSR_STIMER1_COUNT: case HV_X64_MSR_STIMER2_COUNT: case HV_X64_MSR_STIMER3_COUNT: env->msr_hv_stimer_count[(index - HV_X64_MSR_STIMER0_COUNT)/2] = msrs[i].data; break; case MSR_MTRRdefType: env->mtrr_deftype = msrs[i].data; break; case MSR_MTRRfix64K_00000: env->mtrr_fixed[0] = msrs[i].data; break; case MSR_MTRRfix16K_80000: env->mtrr_fixed[1] = msrs[i].data; break; case MSR_MTRRfix16K_A0000: env->mtrr_fixed[2] = msrs[i].data; break; case MSR_MTRRfix4K_C0000: env->mtrr_fixed[3] = msrs[i].data; break; case MSR_MTRRfix4K_C8000: env->mtrr_fixed[4] = msrs[i].data; break; case MSR_MTRRfix4K_D0000: env->mtrr_fixed[5] = msrs[i].data; break; case MSR_MTRRfix4K_D8000: env->mtrr_fixed[6] = msrs[i].data; break; case MSR_MTRRfix4K_E0000: env->mtrr_fixed[7] = msrs[i].data; break; case MSR_MTRRfix4K_E8000: env->mtrr_fixed[8] = msrs[i].data; break; case MSR_MTRRfix4K_F0000: env->mtrr_fixed[9] = msrs[i].data; break; case MSR_MTRRfix4K_F8000: env->mtrr_fixed[10] = msrs[i].data; break; case MSR_MTRRphysBase(0) ... MSR_MTRRphysMask(MSR_MTRRcap_VCNT - 1): if (index & 1) { env->mtrr_var[MSR_MTRRphysIndex(index)].mask = msrs[i].data | mtrr_top_bits; } else { env->mtrr_var[MSR_MTRRphysIndex(index)].base = msrs[i].data; } break; } } return 0; }
true
qemu
0b368a10c71af96f6cf93b0ba5c2ee3bdbd50e96
static int kvm_get_msrs(X86CPU *cpu) { CPUX86State *env = &cpu->env; struct kvm_msr_entry *msrs = cpu->kvm_msr_buf->entries; int ret, i; uint64_t mtrr_top_bits; kvm_msr_buf_reset(cpu); kvm_msr_entry_add(cpu, MSR_IA32_SYSENTER_CS, 0); kvm_msr_entry_add(cpu, MSR_IA32_SYSENTER_ESP, 0); kvm_msr_entry_add(cpu, MSR_IA32_SYSENTER_EIP, 0); kvm_msr_entry_add(cpu, MSR_PAT, 0); if (has_msr_star) { kvm_msr_entry_add(cpu, MSR_STAR, 0); } if (has_msr_hsave_pa) { kvm_msr_entry_add(cpu, MSR_VM_HSAVE_PA, 0); } if (has_msr_tsc_aux) { kvm_msr_entry_add(cpu, MSR_TSC_AUX, 0); } if (has_msr_tsc_adjust) { kvm_msr_entry_add(cpu, MSR_TSC_ADJUST, 0); } if (has_msr_tsc_deadline) { kvm_msr_entry_add(cpu, MSR_IA32_TSCDEADLINE, 0); } if (has_msr_misc_enable) { kvm_msr_entry_add(cpu, MSR_IA32_MISC_ENABLE, 0); } if (has_msr_smbase) { kvm_msr_entry_add(cpu, MSR_IA32_SMBASE, 0); } if (has_msr_feature_control) { kvm_msr_entry_add(cpu, MSR_IA32_FEATURE_CONTROL, 0); } if (has_msr_bndcfgs) { kvm_msr_entry_add(cpu, MSR_IA32_BNDCFGS, 0); } if (has_msr_xss) { kvm_msr_entry_add(cpu, MSR_IA32_XSS, 0); } if (!env->tsc_valid) { kvm_msr_entry_add(cpu, MSR_IA32_TSC, 0); env->tsc_valid = !runstate_is_running(); } #ifdef TARGET_X86_64 if (lm_capable_kernel) { kvm_msr_entry_add(cpu, MSR_CSTAR, 0); kvm_msr_entry_add(cpu, MSR_KERNELGSBASE, 0); kvm_msr_entry_add(cpu, MSR_FMASK, 0); kvm_msr_entry_add(cpu, MSR_LSTAR, 0); } #endif kvm_msr_entry_add(cpu, MSR_KVM_SYSTEM_TIME, 0); kvm_msr_entry_add(cpu, MSR_KVM_WALL_CLOCK, 0); if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_ASYNC_PF)) { kvm_msr_entry_add(cpu, MSR_KVM_ASYNC_PF_EN, 0); } if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_PV_EOI)) { kvm_msr_entry_add(cpu, MSR_KVM_PV_EOI_EN, 0); } if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_STEAL_TIME)) { kvm_msr_entry_add(cpu, MSR_KVM_STEAL_TIME, 0); } if (has_msr_architectural_pmu) { kvm_msr_entry_add(cpu, MSR_CORE_PERF_FIXED_CTR_CTRL, 0); kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_CTRL, 0); kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_STATUS, 0); kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_OVF_CTRL, 0); for (i = 0; i < MAX_FIXED_COUNTERS; i++) { kvm_msr_entry_add(cpu, MSR_CORE_PERF_FIXED_CTR0 + i, 0); } for (i = 0; i < num_architectural_pmu_counters; i++) { kvm_msr_entry_add(cpu, MSR_P6_PERFCTR0 + i, 0); kvm_msr_entry_add(cpu, MSR_P6_EVNTSEL0 + i, 0); } } if (env->mcg_cap) { kvm_msr_entry_add(cpu, MSR_MCG_STATUS, 0); kvm_msr_entry_add(cpu, MSR_MCG_CTL, 0); if (has_msr_mcg_ext_ctl) { kvm_msr_entry_add(cpu, MSR_MCG_EXT_CTL, 0); } for (i = 0; i < (env->mcg_cap & 0xff) * 4; i++) { kvm_msr_entry_add(cpu, MSR_MC0_CTL + i, 0); } } if (has_msr_hv_hypercall) { kvm_msr_entry_add(cpu, HV_X64_MSR_HYPERCALL, 0); kvm_msr_entry_add(cpu, HV_X64_MSR_GUEST_OS_ID, 0); } if (cpu->hyperv_vapic) { kvm_msr_entry_add(cpu, HV_X64_MSR_APIC_ASSIST_PAGE, 0); } if (cpu->hyperv_time) { kvm_msr_entry_add(cpu, HV_X64_MSR_REFERENCE_TSC, 0); } if (has_msr_hv_crash) { int j; for (j = 0; j < HV_CRASH_PARAMS; j++) { kvm_msr_entry_add(cpu, HV_X64_MSR_CRASH_P0 + j, 0); } } if (has_msr_hv_runtime) { kvm_msr_entry_add(cpu, HV_X64_MSR_VP_RUNTIME, 0); } if (cpu->hyperv_synic) { uint32_t msr; kvm_msr_entry_add(cpu, HV_X64_MSR_SCONTROL, 0); kvm_msr_entry_add(cpu, HV_X64_MSR_SIEFP, 0); kvm_msr_entry_add(cpu, HV_X64_MSR_SIMP, 0); for (msr = HV_X64_MSR_SINT0; msr <= HV_X64_MSR_SINT15; msr++) { kvm_msr_entry_add(cpu, msr, 0); } } if (has_msr_hv_stimer) { uint32_t msr; for (msr = HV_X64_MSR_STIMER0_CONFIG; msr <= HV_X64_MSR_STIMER3_COUNT; msr++) { kvm_msr_entry_add(cpu, msr, 0); } } if (env->features[FEAT_1_EDX] & CPUID_MTRR) { kvm_msr_entry_add(cpu, MSR_MTRRdefType, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix64K_00000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix16K_80000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix16K_A0000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_C0000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_C8000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_D0000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_D8000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_E0000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_E8000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_F0000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_F8000, 0); for (i = 0; i < MSR_MTRRcap_VCNT; i++) { kvm_msr_entry_add(cpu, MSR_MTRRphysBase(i), 0); kvm_msr_entry_add(cpu, MSR_MTRRphysMask(i), 0); } } ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_MSRS, cpu->kvm_msr_buf); if (ret < 0) { return ret; } if (ret < cpu->kvm_msr_buf->nmsrs) { struct kvm_msr_entry *e = &cpu->kvm_msr_buf->entries[ret]; error_report("error: failed to get MSR 0x%" PRIx32, (uint32_t)e->index); } assert(ret == cpu->kvm_msr_buf->nmsrs); if (cpu->fill_mtrr_mask) { QEMU_BUILD_BUG_ON(TARGET_PHYS_ADDR_SPACE_BITS > 52); assert(cpu->phys_bits <= TARGET_PHYS_ADDR_SPACE_BITS); mtrr_top_bits = MAKE_64BIT_MASK(cpu->phys_bits, 52 - cpu->phys_bits); } else { mtrr_top_bits = 0; } for (i = 0; i < ret; i++) { uint32_t index = msrs[i].index; switch (index) { case MSR_IA32_SYSENTER_CS: env->sysenter_cs = msrs[i].data; break; case MSR_IA32_SYSENTER_ESP: env->sysenter_esp = msrs[i].data; break; case MSR_IA32_SYSENTER_EIP: env->sysenter_eip = msrs[i].data; break; case MSR_PAT: env->pat = msrs[i].data; break; case MSR_STAR: env->star = msrs[i].data; break; #ifdef TARGET_X86_64 case MSR_CSTAR: env->cstar = msrs[i].data; break; case MSR_KERNELGSBASE: env->kernelgsbase = msrs[i].data; break; case MSR_FMASK: env->fmask = msrs[i].data; break; case MSR_LSTAR: env->lstar = msrs[i].data; break; #endif case MSR_IA32_TSC: env->tsc = msrs[i].data; break; case MSR_TSC_AUX: env->tsc_aux = msrs[i].data; break; case MSR_TSC_ADJUST: env->tsc_adjust = msrs[i].data; break; case MSR_IA32_TSCDEADLINE: env->tsc_deadline = msrs[i].data; break; case MSR_VM_HSAVE_PA: env->vm_hsave = msrs[i].data; break; case MSR_KVM_SYSTEM_TIME: env->system_time_msr = msrs[i].data; break; case MSR_KVM_WALL_CLOCK: env->wall_clock_msr = msrs[i].data; break; case MSR_MCG_STATUS: env->mcg_status = msrs[i].data; break; case MSR_MCG_CTL: env->mcg_ctl = msrs[i].data; break; case MSR_MCG_EXT_CTL: env->mcg_ext_ctl = msrs[i].data; break; case MSR_IA32_MISC_ENABLE: env->msr_ia32_misc_enable = msrs[i].data; break; case MSR_IA32_SMBASE: env->smbase = msrs[i].data; break; case MSR_IA32_FEATURE_CONTROL: env->msr_ia32_feature_control = msrs[i].data; break; case MSR_IA32_BNDCFGS: env->msr_bndcfgs = msrs[i].data; break; case MSR_IA32_XSS: env->xss = msrs[i].data; break; default: if (msrs[i].index >= MSR_MC0_CTL && msrs[i].index < MSR_MC0_CTL + (env->mcg_cap & 0xff) * 4) { env->mce_banks[msrs[i].index - MSR_MC0_CTL] = msrs[i].data; } break; case MSR_KVM_ASYNC_PF_EN: env->async_pf_en_msr = msrs[i].data; break; case MSR_KVM_PV_EOI_EN: env->pv_eoi_en_msr = msrs[i].data; break; case MSR_KVM_STEAL_TIME: env->steal_time_msr = msrs[i].data; break; case MSR_CORE_PERF_FIXED_CTR_CTRL: env->msr_fixed_ctr_ctrl = msrs[i].data; break; case MSR_CORE_PERF_GLOBAL_CTRL: env->msr_global_ctrl = msrs[i].data; break; case MSR_CORE_PERF_GLOBAL_STATUS: env->msr_global_status = msrs[i].data; break; case MSR_CORE_PERF_GLOBAL_OVF_CTRL: env->msr_global_ovf_ctrl = msrs[i].data; break; case MSR_CORE_PERF_FIXED_CTR0 ... MSR_CORE_PERF_FIXED_CTR0 + MAX_FIXED_COUNTERS - 1: env->msr_fixed_counters[index - MSR_CORE_PERF_FIXED_CTR0] = msrs[i].data; break; case MSR_P6_PERFCTR0 ... MSR_P6_PERFCTR0 + MAX_GP_COUNTERS - 1: env->msr_gp_counters[index - MSR_P6_PERFCTR0] = msrs[i].data; break; case MSR_P6_EVNTSEL0 ... MSR_P6_EVNTSEL0 + MAX_GP_COUNTERS - 1: env->msr_gp_evtsel[index - MSR_P6_EVNTSEL0] = msrs[i].data; break; case HV_X64_MSR_HYPERCALL: env->msr_hv_hypercall = msrs[i].data; break; case HV_X64_MSR_GUEST_OS_ID: env->msr_hv_guest_os_id = msrs[i].data; break; case HV_X64_MSR_APIC_ASSIST_PAGE: env->msr_hv_vapic = msrs[i].data; break; case HV_X64_MSR_REFERENCE_TSC: env->msr_hv_tsc = msrs[i].data; break; case HV_X64_MSR_CRASH_P0 ... HV_X64_MSR_CRASH_P4: env->msr_hv_crash_params[index - HV_X64_MSR_CRASH_P0] = msrs[i].data; break; case HV_X64_MSR_VP_RUNTIME: env->msr_hv_runtime = msrs[i].data; break; case HV_X64_MSR_SCONTROL: env->msr_hv_synic_control = msrs[i].data; break; case HV_X64_MSR_SIEFP: env->msr_hv_synic_evt_page = msrs[i].data; break; case HV_X64_MSR_SIMP: env->msr_hv_synic_msg_page = msrs[i].data; break; case HV_X64_MSR_SINT0 ... HV_X64_MSR_SINT15: env->msr_hv_synic_sint[index - HV_X64_MSR_SINT0] = msrs[i].data; break; case HV_X64_MSR_STIMER0_CONFIG: case HV_X64_MSR_STIMER1_CONFIG: case HV_X64_MSR_STIMER2_CONFIG: case HV_X64_MSR_STIMER3_CONFIG: env->msr_hv_stimer_config[(index - HV_X64_MSR_STIMER0_CONFIG)/2] = msrs[i].data; break; case HV_X64_MSR_STIMER0_COUNT: case HV_X64_MSR_STIMER1_COUNT: case HV_X64_MSR_STIMER2_COUNT: case HV_X64_MSR_STIMER3_COUNT: env->msr_hv_stimer_count[(index - HV_X64_MSR_STIMER0_COUNT)/2] = msrs[i].data; break; case MSR_MTRRdefType: env->mtrr_deftype = msrs[i].data; break; case MSR_MTRRfix64K_00000: env->mtrr_fixed[0] = msrs[i].data; break; case MSR_MTRRfix16K_80000: env->mtrr_fixed[1] = msrs[i].data; break; case MSR_MTRRfix16K_A0000: env->mtrr_fixed[2] = msrs[i].data; break; case MSR_MTRRfix4K_C0000: env->mtrr_fixed[3] = msrs[i].data; break; case MSR_MTRRfix4K_C8000: env->mtrr_fixed[4] = msrs[i].data; break; case MSR_MTRRfix4K_D0000: env->mtrr_fixed[5] = msrs[i].data; break; case MSR_MTRRfix4K_D8000: env->mtrr_fixed[6] = msrs[i].data; break; case MSR_MTRRfix4K_E0000: env->mtrr_fixed[7] = msrs[i].data; break; case MSR_MTRRfix4K_E8000: env->mtrr_fixed[8] = msrs[i].data; break; case MSR_MTRRfix4K_F0000: env->mtrr_fixed[9] = msrs[i].data; break; case MSR_MTRRfix4K_F8000: env->mtrr_fixed[10] = msrs[i].data; break; case MSR_MTRRphysBase(0) ... MSR_MTRRphysMask(MSR_MTRRcap_VCNT - 1): if (index & 1) { env->mtrr_var[MSR_MTRRphysIndex(index)].mask = msrs[i].data | mtrr_top_bits; } else { env->mtrr_var[MSR_MTRRphysIndex(index)].base = msrs[i].data; } break; } } return 0; }
{ "code": [ " if (has_msr_architectural_pmu) {", " kvm_msr_entry_add(cpu, MSR_CORE_PERF_FIXED_CTR_CTRL, 0);", " kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_CTRL, 0);", " kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_STATUS, 0);", " kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_OVF_CTRL, 0);", " for (i = 0; i < MAX_FIXED_COUNTERS; i++) {", " for (i = 0; i < num_architectural_pmu_counters; i++) {" ], "line_no": [ 139, 141, 143, 145, 147, 149, 155 ] }
static int FUNC_0(X86CPU *VAR_0) { CPUX86State *env = &VAR_0->env; struct kvm_msr_entry *VAR_1 = VAR_0->kvm_msr_buf->entries; int VAR_2, VAR_3; uint64_t mtrr_top_bits; kvm_msr_buf_reset(VAR_0); kvm_msr_entry_add(VAR_0, MSR_IA32_SYSENTER_CS, 0); kvm_msr_entry_add(VAR_0, MSR_IA32_SYSENTER_ESP, 0); kvm_msr_entry_add(VAR_0, MSR_IA32_SYSENTER_EIP, 0); kvm_msr_entry_add(VAR_0, MSR_PAT, 0); if (has_msr_star) { kvm_msr_entry_add(VAR_0, MSR_STAR, 0); } if (has_msr_hsave_pa) { kvm_msr_entry_add(VAR_0, MSR_VM_HSAVE_PA, 0); } if (has_msr_tsc_aux) { kvm_msr_entry_add(VAR_0, MSR_TSC_AUX, 0); } if (has_msr_tsc_adjust) { kvm_msr_entry_add(VAR_0, MSR_TSC_ADJUST, 0); } if (has_msr_tsc_deadline) { kvm_msr_entry_add(VAR_0, MSR_IA32_TSCDEADLINE, 0); } if (has_msr_misc_enable) { kvm_msr_entry_add(VAR_0, MSR_IA32_MISC_ENABLE, 0); } if (has_msr_smbase) { kvm_msr_entry_add(VAR_0, MSR_IA32_SMBASE, 0); } if (has_msr_feature_control) { kvm_msr_entry_add(VAR_0, MSR_IA32_FEATURE_CONTROL, 0); } if (has_msr_bndcfgs) { kvm_msr_entry_add(VAR_0, MSR_IA32_BNDCFGS, 0); } if (has_msr_xss) { kvm_msr_entry_add(VAR_0, MSR_IA32_XSS, 0); } if (!env->tsc_valid) { kvm_msr_entry_add(VAR_0, MSR_IA32_TSC, 0); env->tsc_valid = !runstate_is_running(); } #ifdef TARGET_X86_64 if (lm_capable_kernel) { kvm_msr_entry_add(VAR_0, MSR_CSTAR, 0); kvm_msr_entry_add(VAR_0, MSR_KERNELGSBASE, 0); kvm_msr_entry_add(VAR_0, MSR_FMASK, 0); kvm_msr_entry_add(VAR_0, MSR_LSTAR, 0); } #endif kvm_msr_entry_add(VAR_0, MSR_KVM_SYSTEM_TIME, 0); kvm_msr_entry_add(VAR_0, MSR_KVM_WALL_CLOCK, 0); if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_ASYNC_PF)) { kvm_msr_entry_add(VAR_0, MSR_KVM_ASYNC_PF_EN, 0); } if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_PV_EOI)) { kvm_msr_entry_add(VAR_0, MSR_KVM_PV_EOI_EN, 0); } if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_STEAL_TIME)) { kvm_msr_entry_add(VAR_0, MSR_KVM_STEAL_TIME, 0); } if (has_msr_architectural_pmu) { kvm_msr_entry_add(VAR_0, MSR_CORE_PERF_FIXED_CTR_CTRL, 0); kvm_msr_entry_add(VAR_0, MSR_CORE_PERF_GLOBAL_CTRL, 0); kvm_msr_entry_add(VAR_0, MSR_CORE_PERF_GLOBAL_STATUS, 0); kvm_msr_entry_add(VAR_0, MSR_CORE_PERF_GLOBAL_OVF_CTRL, 0); for (VAR_3 = 0; VAR_3 < MAX_FIXED_COUNTERS; VAR_3++) { kvm_msr_entry_add(VAR_0, MSR_CORE_PERF_FIXED_CTR0 + VAR_3, 0); } for (VAR_3 = 0; VAR_3 < num_architectural_pmu_counters; VAR_3++) { kvm_msr_entry_add(VAR_0, MSR_P6_PERFCTR0 + VAR_3, 0); kvm_msr_entry_add(VAR_0, MSR_P6_EVNTSEL0 + VAR_3, 0); } } if (env->mcg_cap) { kvm_msr_entry_add(VAR_0, MSR_MCG_STATUS, 0); kvm_msr_entry_add(VAR_0, MSR_MCG_CTL, 0); if (has_msr_mcg_ext_ctl) { kvm_msr_entry_add(VAR_0, MSR_MCG_EXT_CTL, 0); } for (VAR_3 = 0; VAR_3 < (env->mcg_cap & 0xff) * 4; VAR_3++) { kvm_msr_entry_add(VAR_0, MSR_MC0_CTL + VAR_3, 0); } } if (has_msr_hv_hypercall) { kvm_msr_entry_add(VAR_0, HV_X64_MSR_HYPERCALL, 0); kvm_msr_entry_add(VAR_0, HV_X64_MSR_GUEST_OS_ID, 0); } if (VAR_0->hyperv_vapic) { kvm_msr_entry_add(VAR_0, HV_X64_MSR_APIC_ASSIST_PAGE, 0); } if (VAR_0->hyperv_time) { kvm_msr_entry_add(VAR_0, HV_X64_MSR_REFERENCE_TSC, 0); } if (has_msr_hv_crash) { int VAR_4; for (VAR_4 = 0; VAR_4 < HV_CRASH_PARAMS; VAR_4++) { kvm_msr_entry_add(VAR_0, HV_X64_MSR_CRASH_P0 + VAR_4, 0); } } if (has_msr_hv_runtime) { kvm_msr_entry_add(VAR_0, HV_X64_MSR_VP_RUNTIME, 0); } if (VAR_0->hyperv_synic) { uint32_t msr; kvm_msr_entry_add(VAR_0, HV_X64_MSR_SCONTROL, 0); kvm_msr_entry_add(VAR_0, HV_X64_MSR_SIEFP, 0); kvm_msr_entry_add(VAR_0, HV_X64_MSR_SIMP, 0); for (msr = HV_X64_MSR_SINT0; msr <= HV_X64_MSR_SINT15; msr++) { kvm_msr_entry_add(VAR_0, msr, 0); } } if (has_msr_hv_stimer) { uint32_t msr; for (msr = HV_X64_MSR_STIMER0_CONFIG; msr <= HV_X64_MSR_STIMER3_COUNT; msr++) { kvm_msr_entry_add(VAR_0, msr, 0); } } if (env->features[FEAT_1_EDX] & CPUID_MTRR) { kvm_msr_entry_add(VAR_0, MSR_MTRRdefType, 0); kvm_msr_entry_add(VAR_0, MSR_MTRRfix64K_00000, 0); kvm_msr_entry_add(VAR_0, MSR_MTRRfix16K_80000, 0); kvm_msr_entry_add(VAR_0, MSR_MTRRfix16K_A0000, 0); kvm_msr_entry_add(VAR_0, MSR_MTRRfix4K_C0000, 0); kvm_msr_entry_add(VAR_0, MSR_MTRRfix4K_C8000, 0); kvm_msr_entry_add(VAR_0, MSR_MTRRfix4K_D0000, 0); kvm_msr_entry_add(VAR_0, MSR_MTRRfix4K_D8000, 0); kvm_msr_entry_add(VAR_0, MSR_MTRRfix4K_E0000, 0); kvm_msr_entry_add(VAR_0, MSR_MTRRfix4K_E8000, 0); kvm_msr_entry_add(VAR_0, MSR_MTRRfix4K_F0000, 0); kvm_msr_entry_add(VAR_0, MSR_MTRRfix4K_F8000, 0); for (VAR_3 = 0; VAR_3 < MSR_MTRRcap_VCNT; VAR_3++) { kvm_msr_entry_add(VAR_0, MSR_MTRRphysBase(VAR_3), 0); kvm_msr_entry_add(VAR_0, MSR_MTRRphysMask(VAR_3), 0); } } VAR_2 = kvm_vcpu_ioctl(CPU(VAR_0), KVM_GET_MSRS, VAR_0->kvm_msr_buf); if (VAR_2 < 0) { return VAR_2; } if (VAR_2 < VAR_0->kvm_msr_buf->nmsrs) { struct kvm_msr_entry *VAR_5 = &VAR_0->kvm_msr_buf->entries[VAR_2]; error_report("error: failed to get MSR 0x%" PRIx32, (uint32_t)VAR_5->index); } assert(VAR_2 == VAR_0->kvm_msr_buf->nmsrs); if (VAR_0->fill_mtrr_mask) { QEMU_BUILD_BUG_ON(TARGET_PHYS_ADDR_SPACE_BITS > 52); assert(VAR_0->phys_bits <= TARGET_PHYS_ADDR_SPACE_BITS); mtrr_top_bits = MAKE_64BIT_MASK(VAR_0->phys_bits, 52 - VAR_0->phys_bits); } else { mtrr_top_bits = 0; } for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) { uint32_t index = VAR_1[VAR_3].index; switch (index) { case MSR_IA32_SYSENTER_CS: env->sysenter_cs = VAR_1[VAR_3].data; break; case MSR_IA32_SYSENTER_ESP: env->sysenter_esp = VAR_1[VAR_3].data; break; case MSR_IA32_SYSENTER_EIP: env->sysenter_eip = VAR_1[VAR_3].data; break; case MSR_PAT: env->pat = VAR_1[VAR_3].data; break; case MSR_STAR: env->star = VAR_1[VAR_3].data; break; #ifdef TARGET_X86_64 case MSR_CSTAR: env->cstar = VAR_1[VAR_3].data; break; case MSR_KERNELGSBASE: env->kernelgsbase = VAR_1[VAR_3].data; break; case MSR_FMASK: env->fmask = VAR_1[VAR_3].data; break; case MSR_LSTAR: env->lstar = VAR_1[VAR_3].data; break; #endif case MSR_IA32_TSC: env->tsc = VAR_1[VAR_3].data; break; case MSR_TSC_AUX: env->tsc_aux = VAR_1[VAR_3].data; break; case MSR_TSC_ADJUST: env->tsc_adjust = VAR_1[VAR_3].data; break; case MSR_IA32_TSCDEADLINE: env->tsc_deadline = VAR_1[VAR_3].data; break; case MSR_VM_HSAVE_PA: env->vm_hsave = VAR_1[VAR_3].data; break; case MSR_KVM_SYSTEM_TIME: env->system_time_msr = VAR_1[VAR_3].data; break; case MSR_KVM_WALL_CLOCK: env->wall_clock_msr = VAR_1[VAR_3].data; break; case MSR_MCG_STATUS: env->mcg_status = VAR_1[VAR_3].data; break; case MSR_MCG_CTL: env->mcg_ctl = VAR_1[VAR_3].data; break; case MSR_MCG_EXT_CTL: env->mcg_ext_ctl = VAR_1[VAR_3].data; break; case MSR_IA32_MISC_ENABLE: env->msr_ia32_misc_enable = VAR_1[VAR_3].data; break; case MSR_IA32_SMBASE: env->smbase = VAR_1[VAR_3].data; break; case MSR_IA32_FEATURE_CONTROL: env->msr_ia32_feature_control = VAR_1[VAR_3].data; break; case MSR_IA32_BNDCFGS: env->msr_bndcfgs = VAR_1[VAR_3].data; break; case MSR_IA32_XSS: env->xss = VAR_1[VAR_3].data; break; default: if (VAR_1[VAR_3].index >= MSR_MC0_CTL && VAR_1[VAR_3].index < MSR_MC0_CTL + (env->mcg_cap & 0xff) * 4) { env->mce_banks[VAR_1[VAR_3].index - MSR_MC0_CTL] = VAR_1[VAR_3].data; } break; case MSR_KVM_ASYNC_PF_EN: env->async_pf_en_msr = VAR_1[VAR_3].data; break; case MSR_KVM_PV_EOI_EN: env->pv_eoi_en_msr = VAR_1[VAR_3].data; break; case MSR_KVM_STEAL_TIME: env->steal_time_msr = VAR_1[VAR_3].data; break; case MSR_CORE_PERF_FIXED_CTR_CTRL: env->msr_fixed_ctr_ctrl = VAR_1[VAR_3].data; break; case MSR_CORE_PERF_GLOBAL_CTRL: env->msr_global_ctrl = VAR_1[VAR_3].data; break; case MSR_CORE_PERF_GLOBAL_STATUS: env->msr_global_status = VAR_1[VAR_3].data; break; case MSR_CORE_PERF_GLOBAL_OVF_CTRL: env->msr_global_ovf_ctrl = VAR_1[VAR_3].data; break; case MSR_CORE_PERF_FIXED_CTR0 ... MSR_CORE_PERF_FIXED_CTR0 + MAX_FIXED_COUNTERS - 1: env->msr_fixed_counters[index - MSR_CORE_PERF_FIXED_CTR0] = VAR_1[VAR_3].data; break; case MSR_P6_PERFCTR0 ... MSR_P6_PERFCTR0 + MAX_GP_COUNTERS - 1: env->msr_gp_counters[index - MSR_P6_PERFCTR0] = VAR_1[VAR_3].data; break; case MSR_P6_EVNTSEL0 ... MSR_P6_EVNTSEL0 + MAX_GP_COUNTERS - 1: env->msr_gp_evtsel[index - MSR_P6_EVNTSEL0] = VAR_1[VAR_3].data; break; case HV_X64_MSR_HYPERCALL: env->msr_hv_hypercall = VAR_1[VAR_3].data; break; case HV_X64_MSR_GUEST_OS_ID: env->msr_hv_guest_os_id = VAR_1[VAR_3].data; break; case HV_X64_MSR_APIC_ASSIST_PAGE: env->msr_hv_vapic = VAR_1[VAR_3].data; break; case HV_X64_MSR_REFERENCE_TSC: env->msr_hv_tsc = VAR_1[VAR_3].data; break; case HV_X64_MSR_CRASH_P0 ... HV_X64_MSR_CRASH_P4: env->msr_hv_crash_params[index - HV_X64_MSR_CRASH_P0] = VAR_1[VAR_3].data; break; case HV_X64_MSR_VP_RUNTIME: env->msr_hv_runtime = VAR_1[VAR_3].data; break; case HV_X64_MSR_SCONTROL: env->msr_hv_synic_control = VAR_1[VAR_3].data; break; case HV_X64_MSR_SIEFP: env->msr_hv_synic_evt_page = VAR_1[VAR_3].data; break; case HV_X64_MSR_SIMP: env->msr_hv_synic_msg_page = VAR_1[VAR_3].data; break; case HV_X64_MSR_SINT0 ... HV_X64_MSR_SINT15: env->msr_hv_synic_sint[index - HV_X64_MSR_SINT0] = VAR_1[VAR_3].data; break; case HV_X64_MSR_STIMER0_CONFIG: case HV_X64_MSR_STIMER1_CONFIG: case HV_X64_MSR_STIMER2_CONFIG: case HV_X64_MSR_STIMER3_CONFIG: env->msr_hv_stimer_config[(index - HV_X64_MSR_STIMER0_CONFIG)/2] = VAR_1[VAR_3].data; break; case HV_X64_MSR_STIMER0_COUNT: case HV_X64_MSR_STIMER1_COUNT: case HV_X64_MSR_STIMER2_COUNT: case HV_X64_MSR_STIMER3_COUNT: env->msr_hv_stimer_count[(index - HV_X64_MSR_STIMER0_COUNT)/2] = VAR_1[VAR_3].data; break; case MSR_MTRRdefType: env->mtrr_deftype = VAR_1[VAR_3].data; break; case MSR_MTRRfix64K_00000: env->mtrr_fixed[0] = VAR_1[VAR_3].data; break; case MSR_MTRRfix16K_80000: env->mtrr_fixed[1] = VAR_1[VAR_3].data; break; case MSR_MTRRfix16K_A0000: env->mtrr_fixed[2] = VAR_1[VAR_3].data; break; case MSR_MTRRfix4K_C0000: env->mtrr_fixed[3] = VAR_1[VAR_3].data; break; case MSR_MTRRfix4K_C8000: env->mtrr_fixed[4] = VAR_1[VAR_3].data; break; case MSR_MTRRfix4K_D0000: env->mtrr_fixed[5] = VAR_1[VAR_3].data; break; case MSR_MTRRfix4K_D8000: env->mtrr_fixed[6] = VAR_1[VAR_3].data; break; case MSR_MTRRfix4K_E0000: env->mtrr_fixed[7] = VAR_1[VAR_3].data; break; case MSR_MTRRfix4K_E8000: env->mtrr_fixed[8] = VAR_1[VAR_3].data; break; case MSR_MTRRfix4K_F0000: env->mtrr_fixed[9] = VAR_1[VAR_3].data; break; case MSR_MTRRfix4K_F8000: env->mtrr_fixed[10] = VAR_1[VAR_3].data; break; case MSR_MTRRphysBase(0) ... MSR_MTRRphysMask(MSR_MTRRcap_VCNT - 1): if (index & 1) { env->mtrr_var[MSR_MTRRphysIndex(index)].mask = VAR_1[VAR_3].data | mtrr_top_bits; } else { env->mtrr_var[MSR_MTRRphysIndex(index)].base = VAR_1[VAR_3].data; } break; } } return 0; }
[ "static int FUNC_0(X86CPU *VAR_0)\n{", "CPUX86State *env = &VAR_0->env;", "struct kvm_msr_entry *VAR_1 = VAR_0->kvm_msr_buf->entries;", "int VAR_2, VAR_3;", "uint64_t mtrr_top_bits;", "kvm_msr_buf_reset(VAR_0);", "kvm_msr_entry_add(VAR_0, MSR_IA32_SYSENTER_CS, 0);", "kvm_msr_entry_add(VAR_0, MSR_IA32_SYSENTER_ESP, 0);", "kvm_msr_entry_add(VAR_0, MSR_IA32_SYSENTER_EIP, 0);", "kvm_msr_entry_add(VAR_0, MSR_PAT, 0);", "if (has_msr_star) {", "kvm_msr_entry_add(VAR_0, MSR_STAR, 0);", "}", "if (has_msr_hsave_pa) {", "kvm_msr_entry_add(VAR_0, MSR_VM_HSAVE_PA, 0);", "}", "if (has_msr_tsc_aux) {", "kvm_msr_entry_add(VAR_0, MSR_TSC_AUX, 0);", "}", "if (has_msr_tsc_adjust) {", "kvm_msr_entry_add(VAR_0, MSR_TSC_ADJUST, 0);", "}", "if (has_msr_tsc_deadline) {", "kvm_msr_entry_add(VAR_0, MSR_IA32_TSCDEADLINE, 0);", "}", "if (has_msr_misc_enable) {", "kvm_msr_entry_add(VAR_0, MSR_IA32_MISC_ENABLE, 0);", "}", "if (has_msr_smbase) {", "kvm_msr_entry_add(VAR_0, MSR_IA32_SMBASE, 0);", "}", "if (has_msr_feature_control) {", "kvm_msr_entry_add(VAR_0, MSR_IA32_FEATURE_CONTROL, 0);", "}", "if (has_msr_bndcfgs) {", "kvm_msr_entry_add(VAR_0, MSR_IA32_BNDCFGS, 0);", "}", "if (has_msr_xss) {", "kvm_msr_entry_add(VAR_0, MSR_IA32_XSS, 0);", "}", "if (!env->tsc_valid) {", "kvm_msr_entry_add(VAR_0, MSR_IA32_TSC, 0);", "env->tsc_valid = !runstate_is_running();", "}", "#ifdef TARGET_X86_64\nif (lm_capable_kernel) {", "kvm_msr_entry_add(VAR_0, MSR_CSTAR, 0);", "kvm_msr_entry_add(VAR_0, MSR_KERNELGSBASE, 0);", "kvm_msr_entry_add(VAR_0, MSR_FMASK, 0);", "kvm_msr_entry_add(VAR_0, MSR_LSTAR, 0);", "}", "#endif\nkvm_msr_entry_add(VAR_0, MSR_KVM_SYSTEM_TIME, 0);", "kvm_msr_entry_add(VAR_0, MSR_KVM_WALL_CLOCK, 0);", "if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_ASYNC_PF)) {", "kvm_msr_entry_add(VAR_0, MSR_KVM_ASYNC_PF_EN, 0);", "}", "if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_PV_EOI)) {", "kvm_msr_entry_add(VAR_0, MSR_KVM_PV_EOI_EN, 0);", "}", "if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_STEAL_TIME)) {", "kvm_msr_entry_add(VAR_0, MSR_KVM_STEAL_TIME, 0);", "}", "if (has_msr_architectural_pmu) {", "kvm_msr_entry_add(VAR_0, MSR_CORE_PERF_FIXED_CTR_CTRL, 0);", "kvm_msr_entry_add(VAR_0, MSR_CORE_PERF_GLOBAL_CTRL, 0);", "kvm_msr_entry_add(VAR_0, MSR_CORE_PERF_GLOBAL_STATUS, 0);", "kvm_msr_entry_add(VAR_0, MSR_CORE_PERF_GLOBAL_OVF_CTRL, 0);", "for (VAR_3 = 0; VAR_3 < MAX_FIXED_COUNTERS; VAR_3++) {", "kvm_msr_entry_add(VAR_0, MSR_CORE_PERF_FIXED_CTR0 + VAR_3, 0);", "}", "for (VAR_3 = 0; VAR_3 < num_architectural_pmu_counters; VAR_3++) {", "kvm_msr_entry_add(VAR_0, MSR_P6_PERFCTR0 + VAR_3, 0);", "kvm_msr_entry_add(VAR_0, MSR_P6_EVNTSEL0 + VAR_3, 0);", "}", "}", "if (env->mcg_cap) {", "kvm_msr_entry_add(VAR_0, MSR_MCG_STATUS, 0);", "kvm_msr_entry_add(VAR_0, MSR_MCG_CTL, 0);", "if (has_msr_mcg_ext_ctl) {", "kvm_msr_entry_add(VAR_0, MSR_MCG_EXT_CTL, 0);", "}", "for (VAR_3 = 0; VAR_3 < (env->mcg_cap & 0xff) * 4; VAR_3++) {", "kvm_msr_entry_add(VAR_0, MSR_MC0_CTL + VAR_3, 0);", "}", "}", "if (has_msr_hv_hypercall) {", "kvm_msr_entry_add(VAR_0, HV_X64_MSR_HYPERCALL, 0);", "kvm_msr_entry_add(VAR_0, HV_X64_MSR_GUEST_OS_ID, 0);", "}", "if (VAR_0->hyperv_vapic) {", "kvm_msr_entry_add(VAR_0, HV_X64_MSR_APIC_ASSIST_PAGE, 0);", "}", "if (VAR_0->hyperv_time) {", "kvm_msr_entry_add(VAR_0, HV_X64_MSR_REFERENCE_TSC, 0);", "}", "if (has_msr_hv_crash) {", "int VAR_4;", "for (VAR_4 = 0; VAR_4 < HV_CRASH_PARAMS; VAR_4++) {", "kvm_msr_entry_add(VAR_0, HV_X64_MSR_CRASH_P0 + VAR_4, 0);", "}", "}", "if (has_msr_hv_runtime) {", "kvm_msr_entry_add(VAR_0, HV_X64_MSR_VP_RUNTIME, 0);", "}", "if (VAR_0->hyperv_synic) {", "uint32_t msr;", "kvm_msr_entry_add(VAR_0, HV_X64_MSR_SCONTROL, 0);", "kvm_msr_entry_add(VAR_0, HV_X64_MSR_SIEFP, 0);", "kvm_msr_entry_add(VAR_0, HV_X64_MSR_SIMP, 0);", "for (msr = HV_X64_MSR_SINT0; msr <= HV_X64_MSR_SINT15; msr++) {", "kvm_msr_entry_add(VAR_0, msr, 0);", "}", "}", "if (has_msr_hv_stimer) {", "uint32_t msr;", "for (msr = HV_X64_MSR_STIMER0_CONFIG; msr <= HV_X64_MSR_STIMER3_COUNT;", "msr++) {", "kvm_msr_entry_add(VAR_0, msr, 0);", "}", "}", "if (env->features[FEAT_1_EDX] & CPUID_MTRR) {", "kvm_msr_entry_add(VAR_0, MSR_MTRRdefType, 0);", "kvm_msr_entry_add(VAR_0, MSR_MTRRfix64K_00000, 0);", "kvm_msr_entry_add(VAR_0, MSR_MTRRfix16K_80000, 0);", "kvm_msr_entry_add(VAR_0, MSR_MTRRfix16K_A0000, 0);", "kvm_msr_entry_add(VAR_0, MSR_MTRRfix4K_C0000, 0);", "kvm_msr_entry_add(VAR_0, MSR_MTRRfix4K_C8000, 0);", "kvm_msr_entry_add(VAR_0, MSR_MTRRfix4K_D0000, 0);", "kvm_msr_entry_add(VAR_0, MSR_MTRRfix4K_D8000, 0);", "kvm_msr_entry_add(VAR_0, MSR_MTRRfix4K_E0000, 0);", "kvm_msr_entry_add(VAR_0, MSR_MTRRfix4K_E8000, 0);", "kvm_msr_entry_add(VAR_0, MSR_MTRRfix4K_F0000, 0);", "kvm_msr_entry_add(VAR_0, MSR_MTRRfix4K_F8000, 0);", "for (VAR_3 = 0; VAR_3 < MSR_MTRRcap_VCNT; VAR_3++) {", "kvm_msr_entry_add(VAR_0, MSR_MTRRphysBase(VAR_3), 0);", "kvm_msr_entry_add(VAR_0, MSR_MTRRphysMask(VAR_3), 0);", "}", "}", "VAR_2 = kvm_vcpu_ioctl(CPU(VAR_0), KVM_GET_MSRS, VAR_0->kvm_msr_buf);", "if (VAR_2 < 0) {", "return VAR_2;", "}", "if (VAR_2 < VAR_0->kvm_msr_buf->nmsrs) {", "struct kvm_msr_entry *VAR_5 = &VAR_0->kvm_msr_buf->entries[VAR_2];", "error_report(\"error: failed to get MSR 0x%\" PRIx32,\n(uint32_t)VAR_5->index);", "}", "assert(VAR_2 == VAR_0->kvm_msr_buf->nmsrs);", "if (VAR_0->fill_mtrr_mask) {", "QEMU_BUILD_BUG_ON(TARGET_PHYS_ADDR_SPACE_BITS > 52);", "assert(VAR_0->phys_bits <= TARGET_PHYS_ADDR_SPACE_BITS);", "mtrr_top_bits = MAKE_64BIT_MASK(VAR_0->phys_bits, 52 - VAR_0->phys_bits);", "} else {", "mtrr_top_bits = 0;", "}", "for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) {", "uint32_t index = VAR_1[VAR_3].index;", "switch (index) {", "case MSR_IA32_SYSENTER_CS:\nenv->sysenter_cs = VAR_1[VAR_3].data;", "break;", "case MSR_IA32_SYSENTER_ESP:\nenv->sysenter_esp = VAR_1[VAR_3].data;", "break;", "case MSR_IA32_SYSENTER_EIP:\nenv->sysenter_eip = VAR_1[VAR_3].data;", "break;", "case MSR_PAT:\nenv->pat = VAR_1[VAR_3].data;", "break;", "case MSR_STAR:\nenv->star = VAR_1[VAR_3].data;", "break;", "#ifdef TARGET_X86_64\ncase MSR_CSTAR:\nenv->cstar = VAR_1[VAR_3].data;", "break;", "case MSR_KERNELGSBASE:\nenv->kernelgsbase = VAR_1[VAR_3].data;", "break;", "case MSR_FMASK:\nenv->fmask = VAR_1[VAR_3].data;", "break;", "case MSR_LSTAR:\nenv->lstar = VAR_1[VAR_3].data;", "break;", "#endif\ncase MSR_IA32_TSC:\nenv->tsc = VAR_1[VAR_3].data;", "break;", "case MSR_TSC_AUX:\nenv->tsc_aux = VAR_1[VAR_3].data;", "break;", "case MSR_TSC_ADJUST:\nenv->tsc_adjust = VAR_1[VAR_3].data;", "break;", "case MSR_IA32_TSCDEADLINE:\nenv->tsc_deadline = VAR_1[VAR_3].data;", "break;", "case MSR_VM_HSAVE_PA:\nenv->vm_hsave = VAR_1[VAR_3].data;", "break;", "case MSR_KVM_SYSTEM_TIME:\nenv->system_time_msr = VAR_1[VAR_3].data;", "break;", "case MSR_KVM_WALL_CLOCK:\nenv->wall_clock_msr = VAR_1[VAR_3].data;", "break;", "case MSR_MCG_STATUS:\nenv->mcg_status = VAR_1[VAR_3].data;", "break;", "case MSR_MCG_CTL:\nenv->mcg_ctl = VAR_1[VAR_3].data;", "break;", "case MSR_MCG_EXT_CTL:\nenv->mcg_ext_ctl = VAR_1[VAR_3].data;", "break;", "case MSR_IA32_MISC_ENABLE:\nenv->msr_ia32_misc_enable = VAR_1[VAR_3].data;", "break;", "case MSR_IA32_SMBASE:\nenv->smbase = VAR_1[VAR_3].data;", "break;", "case MSR_IA32_FEATURE_CONTROL:\nenv->msr_ia32_feature_control = VAR_1[VAR_3].data;", "break;", "case MSR_IA32_BNDCFGS:\nenv->msr_bndcfgs = VAR_1[VAR_3].data;", "break;", "case MSR_IA32_XSS:\nenv->xss = VAR_1[VAR_3].data;", "break;", "default:\nif (VAR_1[VAR_3].index >= MSR_MC0_CTL &&\nVAR_1[VAR_3].index < MSR_MC0_CTL + (env->mcg_cap & 0xff) * 4) {", "env->mce_banks[VAR_1[VAR_3].index - MSR_MC0_CTL] = VAR_1[VAR_3].data;", "}", "break;", "case MSR_KVM_ASYNC_PF_EN:\nenv->async_pf_en_msr = VAR_1[VAR_3].data;", "break;", "case MSR_KVM_PV_EOI_EN:\nenv->pv_eoi_en_msr = VAR_1[VAR_3].data;", "break;", "case MSR_KVM_STEAL_TIME:\nenv->steal_time_msr = VAR_1[VAR_3].data;", "break;", "case MSR_CORE_PERF_FIXED_CTR_CTRL:\nenv->msr_fixed_ctr_ctrl = VAR_1[VAR_3].data;", "break;", "case MSR_CORE_PERF_GLOBAL_CTRL:\nenv->msr_global_ctrl = VAR_1[VAR_3].data;", "break;", "case MSR_CORE_PERF_GLOBAL_STATUS:\nenv->msr_global_status = VAR_1[VAR_3].data;", "break;", "case MSR_CORE_PERF_GLOBAL_OVF_CTRL:\nenv->msr_global_ovf_ctrl = VAR_1[VAR_3].data;", "break;", "case MSR_CORE_PERF_FIXED_CTR0 ... MSR_CORE_PERF_FIXED_CTR0 + MAX_FIXED_COUNTERS - 1:\nenv->msr_fixed_counters[index - MSR_CORE_PERF_FIXED_CTR0] = VAR_1[VAR_3].data;", "break;", "case MSR_P6_PERFCTR0 ... MSR_P6_PERFCTR0 + MAX_GP_COUNTERS - 1:\nenv->msr_gp_counters[index - MSR_P6_PERFCTR0] = VAR_1[VAR_3].data;", "break;", "case MSR_P6_EVNTSEL0 ... MSR_P6_EVNTSEL0 + MAX_GP_COUNTERS - 1:\nenv->msr_gp_evtsel[index - MSR_P6_EVNTSEL0] = VAR_1[VAR_3].data;", "break;", "case HV_X64_MSR_HYPERCALL:\nenv->msr_hv_hypercall = VAR_1[VAR_3].data;", "break;", "case HV_X64_MSR_GUEST_OS_ID:\nenv->msr_hv_guest_os_id = VAR_1[VAR_3].data;", "break;", "case HV_X64_MSR_APIC_ASSIST_PAGE:\nenv->msr_hv_vapic = VAR_1[VAR_3].data;", "break;", "case HV_X64_MSR_REFERENCE_TSC:\nenv->msr_hv_tsc = VAR_1[VAR_3].data;", "break;", "case HV_X64_MSR_CRASH_P0 ... HV_X64_MSR_CRASH_P4:\nenv->msr_hv_crash_params[index - HV_X64_MSR_CRASH_P0] = VAR_1[VAR_3].data;", "break;", "case HV_X64_MSR_VP_RUNTIME:\nenv->msr_hv_runtime = VAR_1[VAR_3].data;", "break;", "case HV_X64_MSR_SCONTROL:\nenv->msr_hv_synic_control = VAR_1[VAR_3].data;", "break;", "case HV_X64_MSR_SIEFP:\nenv->msr_hv_synic_evt_page = VAR_1[VAR_3].data;", "break;", "case HV_X64_MSR_SIMP:\nenv->msr_hv_synic_msg_page = VAR_1[VAR_3].data;", "break;", "case HV_X64_MSR_SINT0 ... HV_X64_MSR_SINT15:\nenv->msr_hv_synic_sint[index - HV_X64_MSR_SINT0] = VAR_1[VAR_3].data;", "break;", "case HV_X64_MSR_STIMER0_CONFIG:\ncase HV_X64_MSR_STIMER1_CONFIG:\ncase HV_X64_MSR_STIMER2_CONFIG:\ncase HV_X64_MSR_STIMER3_CONFIG:\nenv->msr_hv_stimer_config[(index - HV_X64_MSR_STIMER0_CONFIG)/2] =\nVAR_1[VAR_3].data;", "break;", "case HV_X64_MSR_STIMER0_COUNT:\ncase HV_X64_MSR_STIMER1_COUNT:\ncase HV_X64_MSR_STIMER2_COUNT:\ncase HV_X64_MSR_STIMER3_COUNT:\nenv->msr_hv_stimer_count[(index - HV_X64_MSR_STIMER0_COUNT)/2] =\nVAR_1[VAR_3].data;", "break;", "case MSR_MTRRdefType:\nenv->mtrr_deftype = VAR_1[VAR_3].data;", "break;", "case MSR_MTRRfix64K_00000:\nenv->mtrr_fixed[0] = VAR_1[VAR_3].data;", "break;", "case MSR_MTRRfix16K_80000:\nenv->mtrr_fixed[1] = VAR_1[VAR_3].data;", "break;", "case MSR_MTRRfix16K_A0000:\nenv->mtrr_fixed[2] = VAR_1[VAR_3].data;", "break;", "case MSR_MTRRfix4K_C0000:\nenv->mtrr_fixed[3] = VAR_1[VAR_3].data;", "break;", "case MSR_MTRRfix4K_C8000:\nenv->mtrr_fixed[4] = VAR_1[VAR_3].data;", "break;", "case MSR_MTRRfix4K_D0000:\nenv->mtrr_fixed[5] = VAR_1[VAR_3].data;", "break;", "case MSR_MTRRfix4K_D8000:\nenv->mtrr_fixed[6] = VAR_1[VAR_3].data;", "break;", "case MSR_MTRRfix4K_E0000:\nenv->mtrr_fixed[7] = VAR_1[VAR_3].data;", "break;", "case MSR_MTRRfix4K_E8000:\nenv->mtrr_fixed[8] = VAR_1[VAR_3].data;", "break;", "case MSR_MTRRfix4K_F0000:\nenv->mtrr_fixed[9] = VAR_1[VAR_3].data;", "break;", "case MSR_MTRRfix4K_F8000:\nenv->mtrr_fixed[10] = VAR_1[VAR_3].data;", "break;", "case MSR_MTRRphysBase(0) ... MSR_MTRRphysMask(MSR_MTRRcap_VCNT - 1):\nif (index & 1) {", "env->mtrr_var[MSR_MTRRphysIndex(index)].mask = VAR_1[VAR_3].data |\nmtrr_top_bits;", "} else {", "env->mtrr_var[MSR_MTRRphysIndex(index)].base = VAR_1[VAR_3].data;", "}", "break;", "}", "}", "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, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 19 ], [ 21 ], [ 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 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 101, 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115, 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 277 ], [ 279 ], [ 281 ], [ 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ], [ 299 ], [ 303 ], [ 305 ], [ 307 ], [ 309 ], [ 313 ], [ 315 ], [ 317, 319 ], [ 321 ], [ 325 ], [ 359 ], [ 361 ], [ 363 ], [ 365 ], [ 367 ], [ 369 ], [ 371 ], [ 375 ], [ 377 ], [ 379 ], [ 381, 383 ], [ 385 ], [ 387, 389 ], [ 391 ], [ 393, 395 ], [ 397 ], [ 399, 401 ], [ 403 ], [ 405, 407 ], [ 409 ], [ 411, 413, 415 ], [ 417 ], [ 419, 421 ], [ 423 ], [ 425, 427 ], [ 429 ], [ 431, 433 ], [ 435 ], [ 437, 439, 441 ], [ 443 ], [ 445, 447 ], [ 449 ], [ 451, 453 ], [ 455 ], [ 457, 459 ], [ 461 ], [ 463, 465 ], [ 467 ], [ 469, 471 ], [ 473 ], [ 475, 477 ], [ 479 ], [ 481, 483 ], [ 485 ], [ 487, 489 ], [ 491 ], [ 493, 495 ], [ 497 ], [ 499, 501 ], [ 503 ], [ 505, 507 ], [ 509 ], [ 511, 513 ], [ 515 ], [ 517, 519 ], [ 521 ], [ 523, 525 ], [ 527 ], [ 529, 531, 533 ], [ 535 ], [ 537 ], [ 539 ], [ 541, 543 ], [ 545 ], [ 547, 549 ], [ 551 ], [ 553, 555 ], [ 557 ], [ 559, 561 ], [ 563 ], [ 565, 567 ], [ 569 ], [ 571, 573 ], [ 575 ], [ 577, 579 ], [ 581 ], [ 583, 585 ], [ 587 ], [ 589, 591 ], [ 593 ], [ 595, 597 ], [ 599 ], [ 601, 603 ], [ 605 ], [ 607, 609 ], [ 611 ], [ 613, 615 ], [ 617 ], [ 619, 621 ], [ 623 ], [ 625, 627 ], [ 629 ], [ 631, 633 ], [ 635 ], [ 637, 639 ], [ 641 ], [ 643, 645 ], [ 647 ], [ 649, 651 ], [ 653 ], [ 655, 657 ], [ 659 ], [ 661, 663, 665, 667, 669, 671 ], [ 673 ], [ 675, 677, 679, 681, 683, 685 ], [ 687 ], [ 689, 691 ], [ 693 ], [ 695, 697 ], [ 699 ], [ 701, 703 ], [ 705 ], [ 707, 709 ], [ 711 ], [ 713, 715 ], [ 717 ], [ 719, 721 ], [ 723 ], [ 725, 727 ], [ 729 ], [ 731, 733 ], [ 735 ], [ 737, 739 ], [ 741 ], [ 743, 745 ], [ 747 ], [ 749, 751 ], [ 753 ], [ 755, 757 ], [ 759 ], [ 761, 763 ], [ 765, 767 ], [ 769 ], [ 771 ], [ 773 ], [ 775 ], [ 777 ], [ 779 ], [ 783 ], [ 785 ] ]
724
static void blk_mig_unlock(void) { qemu_mutex_unlock(&block_mig_state.lock); }
true
qemu
60fe637bf0e4d7989e21e50f52526444765c63b4
static void blk_mig_unlock(void) { qemu_mutex_unlock(&block_mig_state.lock); }
{ "code": [], "line_no": [] }
static void FUNC_0(void) { qemu_mutex_unlock(&block_mig_state.lock); }
[ "static void FUNC_0(void)\n{", "qemu_mutex_unlock(&block_mig_state.lock);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
725
static void do_tb_flush(CPUState *cpu, void *data) { unsigned tb_flush_req = (unsigned) (uintptr_t) data; tb_lock(); /* If it's already been done on request of another CPU, * just retry. */ if (tcg_ctx.tb_ctx.tb_flush_count != tb_flush_req) { goto done; } #if defined(DEBUG_FLUSH) printf("qemu: flush code_size=%ld nb_tbs=%d avg_tb_size=%ld\n", (unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer), tcg_ctx.tb_ctx.nb_tbs, tcg_ctx.tb_ctx.nb_tbs > 0 ? ((unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer)) / tcg_ctx.tb_ctx.nb_tbs : 0); #endif if ((unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer) > tcg_ctx.code_gen_buffer_size) { cpu_abort(cpu, "Internal error: code buffer overflow\n"); } CPU_FOREACH(cpu) { int i; for (i = 0; i < TB_JMP_CACHE_SIZE; ++i) { atomic_set(&cpu->tb_jmp_cache[i], NULL); } } tcg_ctx.tb_ctx.nb_tbs = 0; qht_reset_size(&tcg_ctx.tb_ctx.htable, CODE_GEN_HTABLE_SIZE); page_flush_tb(); tcg_ctx.code_gen_ptr = tcg_ctx.code_gen_buffer; /* XXX: flush processor icache at this point if cache flush is expensive */ atomic_mb_set(&tcg_ctx.tb_ctx.tb_flush_count, tcg_ctx.tb_ctx.tb_flush_count + 1); done: tb_unlock(); }
true
qemu
955939a2b51f72bea1c200b559ea39985df5a633
static void do_tb_flush(CPUState *cpu, void *data) { unsigned tb_flush_req = (unsigned) (uintptr_t) data; tb_lock(); if (tcg_ctx.tb_ctx.tb_flush_count != tb_flush_req) { goto done; } #if defined(DEBUG_FLUSH) printf("qemu: flush code_size=%ld nb_tbs=%d avg_tb_size=%ld\n", (unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer), tcg_ctx.tb_ctx.nb_tbs, tcg_ctx.tb_ctx.nb_tbs > 0 ? ((unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer)) / tcg_ctx.tb_ctx.nb_tbs : 0); #endif if ((unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer) > tcg_ctx.code_gen_buffer_size) { cpu_abort(cpu, "Internal error: code buffer overflow\n"); } CPU_FOREACH(cpu) { int i; for (i = 0; i < TB_JMP_CACHE_SIZE; ++i) { atomic_set(&cpu->tb_jmp_cache[i], NULL); } } tcg_ctx.tb_ctx.nb_tbs = 0; qht_reset_size(&tcg_ctx.tb_ctx.htable, CODE_GEN_HTABLE_SIZE); page_flush_tb(); tcg_ctx.code_gen_ptr = tcg_ctx.code_gen_buffer; atomic_mb_set(&tcg_ctx.tb_ctx.tb_flush_count, tcg_ctx.tb_ctx.tb_flush_count + 1); done: tb_unlock(); }
{ "code": [ "#if defined(DEBUG_FLUSH)" ], "line_no": [ 27 ] }
static void FUNC_0(CPUState *VAR_0, void *VAR_1) { unsigned VAR_2 = (unsigned) (uintptr_t) VAR_1; tb_lock(); if (tcg_ctx.tb_ctx.tb_flush_count != VAR_2) { goto done; } #if defined(DEBUG_FLUSH) printf("qemu: flush code_size=%ld nb_tbs=%d avg_tb_size=%ld\n", (unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer), tcg_ctx.tb_ctx.nb_tbs, tcg_ctx.tb_ctx.nb_tbs > 0 ? ((unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer)) / tcg_ctx.tb_ctx.nb_tbs : 0); #endif if ((unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer) > tcg_ctx.code_gen_buffer_size) { cpu_abort(VAR_0, "Internal error: code buffer overflow\n"); } CPU_FOREACH(VAR_0) { int i; for (i = 0; i < TB_JMP_CACHE_SIZE; ++i) { atomic_set(&VAR_0->tb_jmp_cache[i], NULL); } } tcg_ctx.tb_ctx.nb_tbs = 0; qht_reset_size(&tcg_ctx.tb_ctx.htable, CODE_GEN_HTABLE_SIZE); page_flush_tb(); tcg_ctx.code_gen_ptr = tcg_ctx.code_gen_buffer; atomic_mb_set(&tcg_ctx.tb_ctx.tb_flush_count, tcg_ctx.tb_ctx.tb_flush_count + 1); done: tb_unlock(); }
[ "static void FUNC_0(CPUState *VAR_0, void *VAR_1)\n{", "unsigned VAR_2 = (unsigned) (uintptr_t) VAR_1;", "tb_lock();", "if (tcg_ctx.tb_ctx.tb_flush_count != VAR_2) {", "goto done;", "}", "#if defined(DEBUG_FLUSH)\nprintf(\"qemu: flush code_size=%ld nb_tbs=%d avg_tb_size=%ld\\n\",\n(unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer),\ntcg_ctx.tb_ctx.nb_tbs, tcg_ctx.tb_ctx.nb_tbs > 0 ?\n((unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer)) /\ntcg_ctx.tb_ctx.nb_tbs : 0);", "#endif\nif ((unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer)\n> tcg_ctx.code_gen_buffer_size) {", "cpu_abort(VAR_0, \"Internal error: code buffer overflow\\n\");", "}", "CPU_FOREACH(VAR_0) {", "int i;", "for (i = 0; i < TB_JMP_CACHE_SIZE; ++i) {", "atomic_set(&VAR_0->tb_jmp_cache[i], NULL);", "}", "}", "tcg_ctx.tb_ctx.nb_tbs = 0;", "qht_reset_size(&tcg_ctx.tb_ctx.htable, CODE_GEN_HTABLE_SIZE);", "page_flush_tb();", "tcg_ctx.code_gen_ptr = tcg_ctx.code_gen_buffer;", "atomic_mb_set(&tcg_ctx.tb_ctx.tb_flush_count,\ntcg_ctx.tb_ctx.tb_flush_count + 1);", "done:\ntb_unlock();", "}" ]
[ 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 ], [ 9 ], [ 19 ], [ 21 ], [ 23 ], [ 27, 29, 31, 33, 35, 37 ], [ 39, 41, 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 81, 83 ], [ 87, 89 ], [ 91 ] ]
726
static int decode_gusa(DisasContext *ctx, CPUSH4State *env, int *pmax_insns) { uint16_t insns[5]; int ld_adr, ld_dst, ld_mop; int op_dst, op_src, op_opc; int mv_src, mt_dst, st_src, st_mop; TCGv op_arg; uint32_t pc = ctx->pc; uint32_t pc_end = ctx->tb->cs_base; int backup = sextract32(ctx->tbflags, GUSA_SHIFT, 8); int max_insns = (pc_end - pc) / 2; int i; if (pc != pc_end + backup || max_insns < 2) { /* This is a malformed gUSA region. Don't do anything special, since the interpreter is likely to get confused. */ ctx->envflags &= ~GUSA_MASK; return 0; } if (ctx->tbflags & GUSA_EXCLUSIVE) { /* Regardless of single-stepping or the end of the page, we must complete execution of the gUSA region while holding the exclusive lock. */ *pmax_insns = max_insns; return 0; } /* The state machine below will consume only a few insns. If there are more than that in a region, fail now. */ if (max_insns > ARRAY_SIZE(insns)) { goto fail; } /* Read all of the insns for the region. */ for (i = 0; i < max_insns; ++i) { insns[i] = cpu_lduw_code(env, pc + i * 2); } ld_adr = ld_dst = ld_mop = -1; mv_src = -1; op_dst = op_src = op_opc = -1; mt_dst = -1; st_src = st_mop = -1; TCGV_UNUSED(op_arg); i = 0; #define NEXT_INSN \ do { if (i >= max_insns) goto fail; ctx->opcode = insns[i++]; } while (0) /* * Expect a load to begin the region. */ NEXT_INSN; switch (ctx->opcode & 0xf00f) { case 0x6000: /* mov.b @Rm,Rn */ ld_mop = MO_SB; break; case 0x6001: /* mov.w @Rm,Rn */ ld_mop = MO_TESW; break; case 0x6002: /* mov.l @Rm,Rn */ ld_mop = MO_TESL; break; default: goto fail; } ld_adr = B7_4; ld_dst = B11_8; if (ld_adr == ld_dst) { goto fail; } /* Unless we see a mov, any two-operand operation must use ld_dst. */ op_dst = ld_dst; /* * Expect an optional register move. */ NEXT_INSN; switch (ctx->opcode & 0xf00f) { case 0x6003: /* mov Rm,Rn */ /* Here we want to recognize ld_dst being saved for later consumtion, or for another input register being copied so that ld_dst need not be clobbered during the operation. */ op_dst = B11_8; mv_src = B7_4; if (op_dst == ld_dst) { /* Overwriting the load output. */ goto fail; } if (mv_src != ld_dst) { /* Copying a new input; constrain op_src to match the load. */ op_src = ld_dst; } break; default: /* Put back and re-examine as operation. */ --i; } /* * Expect the operation. */ NEXT_INSN; switch (ctx->opcode & 0xf00f) { case 0x300c: /* add Rm,Rn */ op_opc = INDEX_op_add_i32; goto do_reg_op; case 0x2009: /* and Rm,Rn */ op_opc = INDEX_op_and_i32; goto do_reg_op; case 0x200a: /* xor Rm,Rn */ op_opc = INDEX_op_xor_i32; goto do_reg_op; case 0x200b: /* or Rm,Rn */ op_opc = INDEX_op_or_i32; do_reg_op: /* The operation register should be as expected, and the other input cannot depend on the load. */ if (op_dst != B11_8) { goto fail; } if (op_src < 0) { /* Unconstrainted input. */ op_src = B7_4; } else if (op_src == B7_4) { /* Constrained input matched load. All operations are commutative; "swap" them by "moving" the load output to the (implicit) first argument and the move source to the (explicit) second argument. */ op_src = mv_src; } else { goto fail; } op_arg = REG(op_src); break; case 0x6007: /* not Rm,Rn */ if (ld_dst != B7_4 || mv_src >= 0) { goto fail; } op_dst = B11_8; op_opc = INDEX_op_xor_i32; op_arg = tcg_const_i32(-1); break; case 0x7000 ... 0x700f: /* add #imm,Rn */ if (op_dst != B11_8 || mv_src >= 0) { goto fail; } op_opc = INDEX_op_add_i32; op_arg = tcg_const_i32(B7_0s); break; case 0x3000: /* cmp/eq Rm,Rn */ /* Looking for the middle of a compare-and-swap sequence, beginning with the compare. Operands can be either order, but with only one overlapping the load. */ if ((ld_dst == B11_8) + (ld_dst == B7_4) != 1 || mv_src >= 0) { goto fail; } op_opc = INDEX_op_setcond_i32; /* placeholder */ op_src = (ld_dst == B11_8 ? B7_4 : B11_8); op_arg = REG(op_src); NEXT_INSN; switch (ctx->opcode & 0xff00) { case 0x8b00: /* bf label */ case 0x8f00: /* bf/s label */ if (pc + (i + 1 + B7_0s) * 2 != pc_end) { goto fail; } if ((ctx->opcode & 0xff00) == 0x8b00) { /* bf label */ break; } /* We're looking to unconditionally modify Rn with the result of the comparison, within the delay slot of the branch. This is used by older gcc. */ NEXT_INSN; if ((ctx->opcode & 0xf0ff) == 0x0029) { /* movt Rn */ mt_dst = B11_8; } else { goto fail; } break; default: goto fail; } break; case 0x2008: /* tst Rm,Rn */ /* Looking for a compare-and-swap against zero. */ if (ld_dst != B11_8 || ld_dst != B7_4 || mv_src >= 0) { goto fail; } op_opc = INDEX_op_setcond_i32; op_arg = tcg_const_i32(0); NEXT_INSN; if ((ctx->opcode & 0xff00) != 0x8900 /* bt label */ || pc + (i + 1 + B7_0s) * 2 != pc_end) { goto fail; } break; default: /* Put back and re-examine as store. */ --i; } /* * Expect the store. */ /* The store must be the last insn. */ if (i != max_insns - 1) { goto fail; } NEXT_INSN; switch (ctx->opcode & 0xf00f) { case 0x2000: /* mov.b Rm,@Rn */ st_mop = MO_UB; break; case 0x2001: /* mov.w Rm,@Rn */ st_mop = MO_UW; break; case 0x2002: /* mov.l Rm,@Rn */ st_mop = MO_UL; break; default: goto fail; } /* The store must match the load. */ if (ld_adr != B11_8 || st_mop != (ld_mop & MO_SIZE)) { goto fail; } st_src = B7_4; #undef NEXT_INSN /* * Emit the operation. */ tcg_gen_insn_start(pc, ctx->envflags); switch (op_opc) { case -1: /* No operation found. Look for exchange pattern. */ if (st_src == ld_dst || mv_src >= 0) { goto fail; } tcg_gen_atomic_xchg_i32(REG(ld_dst), REG(ld_adr), REG(st_src), ctx->memidx, ld_mop); break; case INDEX_op_add_i32: if (op_dst != st_src) { goto fail; } if (op_dst == ld_dst && st_mop == MO_UL) { tcg_gen_atomic_add_fetch_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); } else { tcg_gen_atomic_fetch_add_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); if (op_dst != ld_dst) { /* Note that mop sizes < 4 cannot use add_fetch because it won't carry into the higher bits. */ tcg_gen_add_i32(REG(op_dst), REG(ld_dst), op_arg); } } break; case INDEX_op_and_i32: if (op_dst != st_src) { goto fail; } if (op_dst == ld_dst) { tcg_gen_atomic_and_fetch_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); } else { tcg_gen_atomic_fetch_and_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); tcg_gen_and_i32(REG(op_dst), REG(ld_dst), op_arg); } break; case INDEX_op_or_i32: if (op_dst != st_src) { goto fail; } if (op_dst == ld_dst) { tcg_gen_atomic_or_fetch_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); } else { tcg_gen_atomic_fetch_or_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); tcg_gen_or_i32(REG(op_dst), REG(ld_dst), op_arg); } break; case INDEX_op_xor_i32: if (op_dst != st_src) { goto fail; } if (op_dst == ld_dst) { tcg_gen_atomic_xor_fetch_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); } else { tcg_gen_atomic_fetch_xor_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); tcg_gen_xor_i32(REG(op_dst), REG(ld_dst), op_arg); } break; case INDEX_op_setcond_i32: if (st_src == ld_dst) { goto fail; } tcg_gen_atomic_cmpxchg_i32(REG(ld_dst), REG(ld_adr), op_arg, REG(st_src), ctx->memidx, ld_mop); tcg_gen_setcond_i32(TCG_COND_EQ, cpu_sr_t, REG(ld_dst), op_arg); if (mt_dst >= 0) { tcg_gen_mov_i32(REG(mt_dst), cpu_sr_t); } break; default: g_assert_not_reached(); } /* If op_src is not a valid register, then op_arg was a constant. */ if (op_src < 0) { tcg_temp_free_i32(op_arg); } /* The entire region has been translated. */ ctx->envflags &= ~GUSA_MASK; ctx->pc = pc_end; return max_insns; fail: qemu_log_mask(LOG_UNIMP, "Unrecognized gUSA sequence %08x-%08x\n", pc, pc_end); /* Restart with the EXCLUSIVE bit set, within a TB run via cpu_exec_step_atomic holding the exclusive lock. */ tcg_gen_insn_start(pc, ctx->envflags); ctx->envflags |= GUSA_EXCLUSIVE; gen_save_cpu_state(ctx, false); gen_helper_exclusive(cpu_env); ctx->bstate = BS_EXCP; /* We're not executing an instruction, but we must report one for the purposes of accounting within the TB. We might as well report the entire region consumed via ctx->pc so that it's immediately available in the disassembly dump. */ ctx->pc = pc_end; return 1; }
true
qemu
6d56fc6cc372284a4571f09b361a9ccd99318103
static int decode_gusa(DisasContext *ctx, CPUSH4State *env, int *pmax_insns) { uint16_t insns[5]; int ld_adr, ld_dst, ld_mop; int op_dst, op_src, op_opc; int mv_src, mt_dst, st_src, st_mop; TCGv op_arg; uint32_t pc = ctx->pc; uint32_t pc_end = ctx->tb->cs_base; int backup = sextract32(ctx->tbflags, GUSA_SHIFT, 8); int max_insns = (pc_end - pc) / 2; int i; if (pc != pc_end + backup || max_insns < 2) { ctx->envflags &= ~GUSA_MASK; return 0; } if (ctx->tbflags & GUSA_EXCLUSIVE) { *pmax_insns = max_insns; return 0; } if (max_insns > ARRAY_SIZE(insns)) { goto fail; } for (i = 0; i < max_insns; ++i) { insns[i] = cpu_lduw_code(env, pc + i * 2); } ld_adr = ld_dst = ld_mop = -1; mv_src = -1; op_dst = op_src = op_opc = -1; mt_dst = -1; st_src = st_mop = -1; TCGV_UNUSED(op_arg); i = 0; #define NEXT_INSN \ do { if (i >= max_insns) goto fail; ctx->opcode = insns[i++]; } while (0) NEXT_INSN; switch (ctx->opcode & 0xf00f) { case 0x6000: ld_mop = MO_SB; break; case 0x6001: ld_mop = MO_TESW; break; case 0x6002: ld_mop = MO_TESL; break; default: goto fail; } ld_adr = B7_4; ld_dst = B11_8; if (ld_adr == ld_dst) { goto fail; } op_dst = ld_dst; NEXT_INSN; switch (ctx->opcode & 0xf00f) { case 0x6003: op_dst = B11_8; mv_src = B7_4; if (op_dst == ld_dst) { goto fail; } if (mv_src != ld_dst) { op_src = ld_dst; } break; default: --i; } NEXT_INSN; switch (ctx->opcode & 0xf00f) { case 0x300c: op_opc = INDEX_op_add_i32; goto do_reg_op; case 0x2009: op_opc = INDEX_op_and_i32; goto do_reg_op; case 0x200a: op_opc = INDEX_op_xor_i32; goto do_reg_op; case 0x200b: op_opc = INDEX_op_or_i32; do_reg_op: if (op_dst != B11_8) { goto fail; } if (op_src < 0) { op_src = B7_4; } else if (op_src == B7_4) { op_src = mv_src; } else { goto fail; } op_arg = REG(op_src); break; case 0x6007: if (ld_dst != B7_4 || mv_src >= 0) { goto fail; } op_dst = B11_8; op_opc = INDEX_op_xor_i32; op_arg = tcg_const_i32(-1); break; case 0x7000 ... 0x700f: if (op_dst != B11_8 || mv_src >= 0) { goto fail; } op_opc = INDEX_op_add_i32; op_arg = tcg_const_i32(B7_0s); break; case 0x3000: if ((ld_dst == B11_8) + (ld_dst == B7_4) != 1 || mv_src >= 0) { goto fail; } op_opc = INDEX_op_setcond_i32; op_src = (ld_dst == B11_8 ? B7_4 : B11_8); op_arg = REG(op_src); NEXT_INSN; switch (ctx->opcode & 0xff00) { case 0x8b00: case 0x8f00: if (pc + (i + 1 + B7_0s) * 2 != pc_end) { goto fail; } if ((ctx->opcode & 0xff00) == 0x8b00) { break; } NEXT_INSN; if ((ctx->opcode & 0xf0ff) == 0x0029) { mt_dst = B11_8; } else { goto fail; } break; default: goto fail; } break; case 0x2008: if (ld_dst != B11_8 || ld_dst != B7_4 || mv_src >= 0) { goto fail; } op_opc = INDEX_op_setcond_i32; op_arg = tcg_const_i32(0); NEXT_INSN; if ((ctx->opcode & 0xff00) != 0x8900 || pc + (i + 1 + B7_0s) * 2 != pc_end) { goto fail; } break; default: --i; } if (i != max_insns - 1) { goto fail; } NEXT_INSN; switch (ctx->opcode & 0xf00f) { case 0x2000: st_mop = MO_UB; break; case 0x2001: st_mop = MO_UW; break; case 0x2002: st_mop = MO_UL; break; default: goto fail; } if (ld_adr != B11_8 || st_mop != (ld_mop & MO_SIZE)) { goto fail; } st_src = B7_4; #undef NEXT_INSN tcg_gen_insn_start(pc, ctx->envflags); switch (op_opc) { case -1: if (st_src == ld_dst || mv_src >= 0) { goto fail; } tcg_gen_atomic_xchg_i32(REG(ld_dst), REG(ld_adr), REG(st_src), ctx->memidx, ld_mop); break; case INDEX_op_add_i32: if (op_dst != st_src) { goto fail; } if (op_dst == ld_dst && st_mop == MO_UL) { tcg_gen_atomic_add_fetch_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); } else { tcg_gen_atomic_fetch_add_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); if (op_dst != ld_dst) { tcg_gen_add_i32(REG(op_dst), REG(ld_dst), op_arg); } } break; case INDEX_op_and_i32: if (op_dst != st_src) { goto fail; } if (op_dst == ld_dst) { tcg_gen_atomic_and_fetch_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); } else { tcg_gen_atomic_fetch_and_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); tcg_gen_and_i32(REG(op_dst), REG(ld_dst), op_arg); } break; case INDEX_op_or_i32: if (op_dst != st_src) { goto fail; } if (op_dst == ld_dst) { tcg_gen_atomic_or_fetch_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); } else { tcg_gen_atomic_fetch_or_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); tcg_gen_or_i32(REG(op_dst), REG(ld_dst), op_arg); } break; case INDEX_op_xor_i32: if (op_dst != st_src) { goto fail; } if (op_dst == ld_dst) { tcg_gen_atomic_xor_fetch_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); } else { tcg_gen_atomic_fetch_xor_i32(REG(ld_dst), REG(ld_adr), op_arg, ctx->memidx, ld_mop); tcg_gen_xor_i32(REG(op_dst), REG(ld_dst), op_arg); } break; case INDEX_op_setcond_i32: if (st_src == ld_dst) { goto fail; } tcg_gen_atomic_cmpxchg_i32(REG(ld_dst), REG(ld_adr), op_arg, REG(st_src), ctx->memidx, ld_mop); tcg_gen_setcond_i32(TCG_COND_EQ, cpu_sr_t, REG(ld_dst), op_arg); if (mt_dst >= 0) { tcg_gen_mov_i32(REG(mt_dst), cpu_sr_t); } break; default: g_assert_not_reached(); } if (op_src < 0) { tcg_temp_free_i32(op_arg); } ctx->envflags &= ~GUSA_MASK; ctx->pc = pc_end; return max_insns; fail: qemu_log_mask(LOG_UNIMP, "Unrecognized gUSA sequence %08x-%08x\n", pc, pc_end); tcg_gen_insn_start(pc, ctx->envflags); ctx->envflags |= GUSA_EXCLUSIVE; gen_save_cpu_state(ctx, false); gen_helper_exclusive(cpu_env); ctx->bstate = BS_EXCP; ctx->pc = pc_end; return 1; }
{ "code": [ " if (op_src < 0) {" ], "line_no": [ 667 ] }
static int FUNC_0(DisasContext *VAR_0, CPUSH4State *VAR_1, int *VAR_2) { uint16_t insns[5]; int VAR_3, VAR_4, VAR_5; int VAR_6, VAR_7, VAR_8; int VAR_9, VAR_10, VAR_11, VAR_12; TCGv op_arg; uint32_t pc = VAR_0->pc; uint32_t pc_end = VAR_0->tb->cs_base; int VAR_13 = sextract32(VAR_0->tbflags, GUSA_SHIFT, 8); int VAR_14 = (pc_end - pc) / 2; int VAR_15; if (pc != pc_end + VAR_13 || VAR_14 < 2) { VAR_0->envflags &= ~GUSA_MASK; return 0; } if (VAR_0->tbflags & GUSA_EXCLUSIVE) { *VAR_2 = VAR_14; return 0; } if (VAR_14 > ARRAY_SIZE(insns)) { goto fail; } for (VAR_15 = 0; VAR_15 < VAR_14; ++VAR_15) { insns[VAR_15] = cpu_lduw_code(VAR_1, pc + VAR_15 * 2); } VAR_3 = VAR_4 = VAR_5 = -1; VAR_9 = -1; VAR_6 = VAR_7 = VAR_8 = -1; VAR_10 = -1; VAR_11 = VAR_12 = -1; TCGV_UNUSED(op_arg); VAR_15 = 0; #define NEXT_INSN \ do { if (VAR_15 >= VAR_14) goto fail; VAR_0->opcode = insns[VAR_15++]; } while (0) NEXT_INSN; switch (VAR_0->opcode & 0xf00f) { case 0x6000: VAR_5 = MO_SB; break; case 0x6001: VAR_5 = MO_TESW; break; case 0x6002: VAR_5 = MO_TESL; break; default: goto fail; } VAR_3 = B7_4; VAR_4 = B11_8; if (VAR_3 == VAR_4) { goto fail; } VAR_6 = VAR_4; NEXT_INSN; switch (VAR_0->opcode & 0xf00f) { case 0x6003: VAR_6 = B11_8; VAR_9 = B7_4; if (VAR_6 == VAR_4) { goto fail; } if (VAR_9 != VAR_4) { VAR_7 = VAR_4; } break; default: --VAR_15; } NEXT_INSN; switch (VAR_0->opcode & 0xf00f) { case 0x300c: VAR_8 = INDEX_op_add_i32; goto do_reg_op; case 0x2009: VAR_8 = INDEX_op_and_i32; goto do_reg_op; case 0x200a: VAR_8 = INDEX_op_xor_i32; goto do_reg_op; case 0x200b: VAR_8 = INDEX_op_or_i32; do_reg_op: if (VAR_6 != B11_8) { goto fail; } if (VAR_7 < 0) { VAR_7 = B7_4; } else if (VAR_7 == B7_4) { VAR_7 = VAR_9; } else { goto fail; } op_arg = REG(VAR_7); break; case 0x6007: if (VAR_4 != B7_4 || VAR_9 >= 0) { goto fail; } VAR_6 = B11_8; VAR_8 = INDEX_op_xor_i32; op_arg = tcg_const_i32(-1); break; case 0x7000 ... 0x700f: if (VAR_6 != B11_8 || VAR_9 >= 0) { goto fail; } VAR_8 = INDEX_op_add_i32; op_arg = tcg_const_i32(B7_0s); break; case 0x3000: if ((VAR_4 == B11_8) + (VAR_4 == B7_4) != 1 || VAR_9 >= 0) { goto fail; } VAR_8 = INDEX_op_setcond_i32; VAR_7 = (VAR_4 == B11_8 ? B7_4 : B11_8); op_arg = REG(VAR_7); NEXT_INSN; switch (VAR_0->opcode & 0xff00) { case 0x8b00: case 0x8f00: if (pc + (VAR_15 + 1 + B7_0s) * 2 != pc_end) { goto fail; } if ((VAR_0->opcode & 0xff00) == 0x8b00) { break; } NEXT_INSN; if ((VAR_0->opcode & 0xf0ff) == 0x0029) { VAR_10 = B11_8; } else { goto fail; } break; default: goto fail; } break; case 0x2008: if (VAR_4 != B11_8 || VAR_4 != B7_4 || VAR_9 >= 0) { goto fail; } VAR_8 = INDEX_op_setcond_i32; op_arg = tcg_const_i32(0); NEXT_INSN; if ((VAR_0->opcode & 0xff00) != 0x8900 || pc + (VAR_15 + 1 + B7_0s) * 2 != pc_end) { goto fail; } break; default: --VAR_15; } if (VAR_15 != VAR_14 - 1) { goto fail; } NEXT_INSN; switch (VAR_0->opcode & 0xf00f) { case 0x2000: VAR_12 = MO_UB; break; case 0x2001: VAR_12 = MO_UW; break; case 0x2002: VAR_12 = MO_UL; break; default: goto fail; } if (VAR_3 != B11_8 || VAR_12 != (VAR_5 & MO_SIZE)) { goto fail; } VAR_11 = B7_4; #undef NEXT_INSN tcg_gen_insn_start(pc, VAR_0->envflags); switch (VAR_8) { case -1: if (VAR_11 == VAR_4 || VAR_9 >= 0) { goto fail; } tcg_gen_atomic_xchg_i32(REG(VAR_4), REG(VAR_3), REG(VAR_11), VAR_0->memidx, VAR_5); break; case INDEX_op_add_i32: if (VAR_6 != VAR_11) { goto fail; } if (VAR_6 == VAR_4 && VAR_12 == MO_UL) { tcg_gen_atomic_add_fetch_i32(REG(VAR_4), REG(VAR_3), op_arg, VAR_0->memidx, VAR_5); } else { tcg_gen_atomic_fetch_add_i32(REG(VAR_4), REG(VAR_3), op_arg, VAR_0->memidx, VAR_5); if (VAR_6 != VAR_4) { tcg_gen_add_i32(REG(VAR_6), REG(VAR_4), op_arg); } } break; case INDEX_op_and_i32: if (VAR_6 != VAR_11) { goto fail; } if (VAR_6 == VAR_4) { tcg_gen_atomic_and_fetch_i32(REG(VAR_4), REG(VAR_3), op_arg, VAR_0->memidx, VAR_5); } else { tcg_gen_atomic_fetch_and_i32(REG(VAR_4), REG(VAR_3), op_arg, VAR_0->memidx, VAR_5); tcg_gen_and_i32(REG(VAR_6), REG(VAR_4), op_arg); } break; case INDEX_op_or_i32: if (VAR_6 != VAR_11) { goto fail; } if (VAR_6 == VAR_4) { tcg_gen_atomic_or_fetch_i32(REG(VAR_4), REG(VAR_3), op_arg, VAR_0->memidx, VAR_5); } else { tcg_gen_atomic_fetch_or_i32(REG(VAR_4), REG(VAR_3), op_arg, VAR_0->memidx, VAR_5); tcg_gen_or_i32(REG(VAR_6), REG(VAR_4), op_arg); } break; case INDEX_op_xor_i32: if (VAR_6 != VAR_11) { goto fail; } if (VAR_6 == VAR_4) { tcg_gen_atomic_xor_fetch_i32(REG(VAR_4), REG(VAR_3), op_arg, VAR_0->memidx, VAR_5); } else { tcg_gen_atomic_fetch_xor_i32(REG(VAR_4), REG(VAR_3), op_arg, VAR_0->memidx, VAR_5); tcg_gen_xor_i32(REG(VAR_6), REG(VAR_4), op_arg); } break; case INDEX_op_setcond_i32: if (VAR_11 == VAR_4) { goto fail; } tcg_gen_atomic_cmpxchg_i32(REG(VAR_4), REG(VAR_3), op_arg, REG(VAR_11), VAR_0->memidx, VAR_5); tcg_gen_setcond_i32(TCG_COND_EQ, cpu_sr_t, REG(VAR_4), op_arg); if (VAR_10 >= 0) { tcg_gen_mov_i32(REG(VAR_10), cpu_sr_t); } break; default: g_assert_not_reached(); } if (VAR_7 < 0) { tcg_temp_free_i32(op_arg); } VAR_0->envflags &= ~GUSA_MASK; VAR_0->pc = pc_end; return VAR_14; fail: qemu_log_mask(LOG_UNIMP, "Unrecognized gUSA sequence %08x-%08x\n", pc, pc_end); tcg_gen_insn_start(pc, VAR_0->envflags); VAR_0->envflags |= GUSA_EXCLUSIVE; gen_save_cpu_state(VAR_0, false); gen_helper_exclusive(cpu_env); VAR_0->bstate = BS_EXCP; VAR_0->pc = pc_end; return 1; }
[ "static int FUNC_0(DisasContext *VAR_0, CPUSH4State *VAR_1, int *VAR_2)\n{", "uint16_t insns[5];", "int VAR_3, VAR_4, VAR_5;", "int VAR_6, VAR_7, VAR_8;", "int VAR_9, VAR_10, VAR_11, VAR_12;", "TCGv op_arg;", "uint32_t pc = VAR_0->pc;", "uint32_t pc_end = VAR_0->tb->cs_base;", "int VAR_13 = sextract32(VAR_0->tbflags, GUSA_SHIFT, 8);", "int VAR_14 = (pc_end - pc) / 2;", "int VAR_15;", "if (pc != pc_end + VAR_13 || VAR_14 < 2) {", "VAR_0->envflags &= ~GUSA_MASK;", "return 0;", "}", "if (VAR_0->tbflags & GUSA_EXCLUSIVE) {", "*VAR_2 = VAR_14;", "return 0;", "}", "if (VAR_14 > ARRAY_SIZE(insns)) {", "goto fail;", "}", "for (VAR_15 = 0; VAR_15 < VAR_14; ++VAR_15) {", "insns[VAR_15] = cpu_lduw_code(VAR_1, pc + VAR_15 * 2);", "}", "VAR_3 = VAR_4 = VAR_5 = -1;", "VAR_9 = -1;", "VAR_6 = VAR_7 = VAR_8 = -1;", "VAR_10 = -1;", "VAR_11 = VAR_12 = -1;", "TCGV_UNUSED(op_arg);", "VAR_15 = 0;", "#define NEXT_INSN \\\ndo { if (VAR_15 >= VAR_14) goto fail; VAR_0->opcode = insns[VAR_15++]; } while (0)", "NEXT_INSN;", "switch (VAR_0->opcode & 0xf00f) {", "case 0x6000:\nVAR_5 = MO_SB;", "break;", "case 0x6001:\nVAR_5 = MO_TESW;", "break;", "case 0x6002:\nVAR_5 = MO_TESL;", "break;", "default:\ngoto fail;", "}", "VAR_3 = B7_4;", "VAR_4 = B11_8;", "if (VAR_3 == VAR_4) {", "goto fail;", "}", "VAR_6 = VAR_4;", "NEXT_INSN;", "switch (VAR_0->opcode & 0xf00f) {", "case 0x6003:\nVAR_6 = B11_8;", "VAR_9 = B7_4;", "if (VAR_6 == VAR_4) {", "goto fail;", "}", "if (VAR_9 != VAR_4) {", "VAR_7 = VAR_4;", "}", "break;", "default:\n--VAR_15;", "}", "NEXT_INSN;", "switch (VAR_0->opcode & 0xf00f) {", "case 0x300c:\nVAR_8 = INDEX_op_add_i32;", "goto do_reg_op;", "case 0x2009:\nVAR_8 = INDEX_op_and_i32;", "goto do_reg_op;", "case 0x200a:\nVAR_8 = INDEX_op_xor_i32;", "goto do_reg_op;", "case 0x200b:\nVAR_8 = INDEX_op_or_i32;", "do_reg_op:\nif (VAR_6 != B11_8) {", "goto fail;", "}", "if (VAR_7 < 0) {", "VAR_7 = B7_4;", "} else if (VAR_7 == B7_4) {", "VAR_7 = VAR_9;", "} else {", "goto fail;", "}", "op_arg = REG(VAR_7);", "break;", "case 0x6007:\nif (VAR_4 != B7_4 || VAR_9 >= 0) {", "goto fail;", "}", "VAR_6 = B11_8;", "VAR_8 = INDEX_op_xor_i32;", "op_arg = tcg_const_i32(-1);", "break;", "case 0x7000 ... 0x700f:\nif (VAR_6 != B11_8 || VAR_9 >= 0) {", "goto fail;", "}", "VAR_8 = INDEX_op_add_i32;", "op_arg = tcg_const_i32(B7_0s);", "break;", "case 0x3000:\nif ((VAR_4 == B11_8) + (VAR_4 == B7_4) != 1 || VAR_9 >= 0) {", "goto fail;", "}", "VAR_8 = INDEX_op_setcond_i32;", "VAR_7 = (VAR_4 == B11_8 ? B7_4 : B11_8);", "op_arg = REG(VAR_7);", "NEXT_INSN;", "switch (VAR_0->opcode & 0xff00) {", "case 0x8b00:\ncase 0x8f00:\nif (pc + (VAR_15 + 1 + B7_0s) * 2 != pc_end) {", "goto fail;", "}", "if ((VAR_0->opcode & 0xff00) == 0x8b00) {", "break;", "}", "NEXT_INSN;", "if ((VAR_0->opcode & 0xf0ff) == 0x0029) {", "VAR_10 = B11_8;", "} else {", "goto fail;", "}", "break;", "default:\ngoto fail;", "}", "break;", "case 0x2008:\nif (VAR_4 != B11_8 || VAR_4 != B7_4 || VAR_9 >= 0) {", "goto fail;", "}", "VAR_8 = INDEX_op_setcond_i32;", "op_arg = tcg_const_i32(0);", "NEXT_INSN;", "if ((VAR_0->opcode & 0xff00) != 0x8900\n|| pc + (VAR_15 + 1 + B7_0s) * 2 != pc_end) {", "goto fail;", "}", "break;", "default:\n--VAR_15;", "}", "if (VAR_15 != VAR_14 - 1) {", "goto fail;", "}", "NEXT_INSN;", "switch (VAR_0->opcode & 0xf00f) {", "case 0x2000:\nVAR_12 = MO_UB;", "break;", "case 0x2001:\nVAR_12 = MO_UW;", "break;", "case 0x2002:\nVAR_12 = MO_UL;", "break;", "default:\ngoto fail;", "}", "if (VAR_3 != B11_8 || VAR_12 != (VAR_5 & MO_SIZE)) {", "goto fail;", "}", "VAR_11 = B7_4;", "#undef NEXT_INSN\ntcg_gen_insn_start(pc, VAR_0->envflags);", "switch (VAR_8) {", "case -1:\nif (VAR_11 == VAR_4 || VAR_9 >= 0) {", "goto fail;", "}", "tcg_gen_atomic_xchg_i32(REG(VAR_4), REG(VAR_3), REG(VAR_11),\nVAR_0->memidx, VAR_5);", "break;", "case INDEX_op_add_i32:\nif (VAR_6 != VAR_11) {", "goto fail;", "}", "if (VAR_6 == VAR_4 && VAR_12 == MO_UL) {", "tcg_gen_atomic_add_fetch_i32(REG(VAR_4), REG(VAR_3),\nop_arg, VAR_0->memidx, VAR_5);", "} else {", "tcg_gen_atomic_fetch_add_i32(REG(VAR_4), REG(VAR_3),\nop_arg, VAR_0->memidx, VAR_5);", "if (VAR_6 != VAR_4) {", "tcg_gen_add_i32(REG(VAR_6), REG(VAR_4), op_arg);", "}", "}", "break;", "case INDEX_op_and_i32:\nif (VAR_6 != VAR_11) {", "goto fail;", "}", "if (VAR_6 == VAR_4) {", "tcg_gen_atomic_and_fetch_i32(REG(VAR_4), REG(VAR_3),\nop_arg, VAR_0->memidx, VAR_5);", "} else {", "tcg_gen_atomic_fetch_and_i32(REG(VAR_4), REG(VAR_3),\nop_arg, VAR_0->memidx, VAR_5);", "tcg_gen_and_i32(REG(VAR_6), REG(VAR_4), op_arg);", "}", "break;", "case INDEX_op_or_i32:\nif (VAR_6 != VAR_11) {", "goto fail;", "}", "if (VAR_6 == VAR_4) {", "tcg_gen_atomic_or_fetch_i32(REG(VAR_4), REG(VAR_3),\nop_arg, VAR_0->memidx, VAR_5);", "} else {", "tcg_gen_atomic_fetch_or_i32(REG(VAR_4), REG(VAR_3),\nop_arg, VAR_0->memidx, VAR_5);", "tcg_gen_or_i32(REG(VAR_6), REG(VAR_4), op_arg);", "}", "break;", "case INDEX_op_xor_i32:\nif (VAR_6 != VAR_11) {", "goto fail;", "}", "if (VAR_6 == VAR_4) {", "tcg_gen_atomic_xor_fetch_i32(REG(VAR_4), REG(VAR_3),\nop_arg, VAR_0->memidx, VAR_5);", "} else {", "tcg_gen_atomic_fetch_xor_i32(REG(VAR_4), REG(VAR_3),\nop_arg, VAR_0->memidx, VAR_5);", "tcg_gen_xor_i32(REG(VAR_6), REG(VAR_4), op_arg);", "}", "break;", "case INDEX_op_setcond_i32:\nif (VAR_11 == VAR_4) {", "goto fail;", "}", "tcg_gen_atomic_cmpxchg_i32(REG(VAR_4), REG(VAR_3), op_arg,\nREG(VAR_11), VAR_0->memidx, VAR_5);", "tcg_gen_setcond_i32(TCG_COND_EQ, cpu_sr_t, REG(VAR_4), op_arg);", "if (VAR_10 >= 0) {", "tcg_gen_mov_i32(REG(VAR_10), cpu_sr_t);", "}", "break;", "default:\ng_assert_not_reached();", "}", "if (VAR_7 < 0) {", "tcg_temp_free_i32(op_arg);", "}", "VAR_0->envflags &= ~GUSA_MASK;", "VAR_0->pc = pc_end;", "return VAR_14;", "fail:\nqemu_log_mask(LOG_UNIMP, \"Unrecognized gUSA sequence %08x-%08x\\n\",\npc, pc_end);", "tcg_gen_insn_start(pc, VAR_0->envflags);", "VAR_0->envflags |= GUSA_EXCLUSIVE;", "gen_save_cpu_state(VAR_0, false);", "gen_helper_exclusive(cpu_env);", "VAR_0->bstate = BS_EXCP;", "VAR_0->pc = pc_end;", "return 1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 51 ], [ 53 ], [ 55 ], [ 63 ], [ 65 ], [ 67 ], [ 73 ], [ 75 ], [ 77 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 97, 99 ], [ 109 ], [ 111 ], [ 113, 115 ], [ 117 ], [ 119, 121 ], [ 123 ], [ 125, 127 ], [ 129 ], [ 131, 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 149 ], [ 159 ], [ 161 ], [ 163, 171 ], [ 173 ], [ 175 ], [ 179 ], [ 181 ], [ 183 ], [ 187 ], [ 189 ], [ 191 ], [ 195, 199 ], [ 201 ], [ 211 ], [ 213 ], [ 215, 217 ], [ 219 ], [ 221, 223 ], [ 225 ], [ 227, 229 ], [ 231 ], [ 233, 235 ], [ 237, 243 ], [ 245 ], [ 247 ], [ 249 ], [ 253 ], [ 255 ], [ 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 279, 281 ], [ 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293 ], [ 297, 299 ], [ 301 ], [ 303 ], [ 305 ], [ 307 ], [ 309 ], [ 313, 321 ], [ 323 ], [ 325 ], [ 327 ], [ 329 ], [ 331 ], [ 335 ], [ 337 ], [ 339, 341, 343 ], [ 345 ], [ 347 ], [ 349 ], [ 351 ], [ 353 ], [ 361 ], [ 363 ], [ 365 ], [ 367 ], [ 369 ], [ 371 ], [ 373 ], [ 377, 379 ], [ 381 ], [ 383 ], [ 387, 391 ], [ 393 ], [ 395 ], [ 397 ], [ 399 ], [ 403 ], [ 405, 407 ], [ 409 ], [ 411 ], [ 413 ], [ 417, 421 ], [ 423 ], [ 435 ], [ 437 ], [ 439 ], [ 441 ], [ 443 ], [ 445, 447 ], [ 449 ], [ 451, 453 ], [ 455 ], [ 457, 459 ], [ 461 ], [ 463, 465 ], [ 467 ], [ 471 ], [ 473 ], [ 475 ], [ 477 ], [ 481, 491 ], [ 493 ], [ 495, 499 ], [ 501 ], [ 503 ], [ 505, 507 ], [ 509 ], [ 513, 515 ], [ 517 ], [ 519 ], [ 521 ], [ 523, 525 ], [ 527 ], [ 529, 531 ], [ 533 ], [ 539 ], [ 541 ], [ 543 ], [ 545 ], [ 549, 551 ], [ 553 ], [ 555 ], [ 557 ], [ 559, 561 ], [ 563 ], [ 565, 567 ], [ 569 ], [ 571 ], [ 573 ], [ 577, 579 ], [ 581 ], [ 583 ], [ 585 ], [ 587, 589 ], [ 591 ], [ 593, 595 ], [ 597 ], [ 599 ], [ 601 ], [ 605, 607 ], [ 609 ], [ 611 ], [ 613 ], [ 615, 617 ], [ 619 ], [ 621, 623 ], [ 625 ], [ 627 ], [ 629 ], [ 633, 635 ], [ 637 ], [ 639 ], [ 641, 643 ], [ 645 ], [ 647 ], [ 649 ], [ 651 ], [ 653 ], [ 657, 659 ], [ 661 ], [ 667 ], [ 669 ], [ 671 ], [ 677 ], [ 679 ], [ 681 ], [ 685, 687, 689 ], [ 697 ], [ 699 ], [ 701 ], [ 703 ], [ 705 ], [ 717 ], [ 719 ], [ 721 ] ]
727
static int yop_read_header(AVFormatContext *s) { YopDecContext *yop = s->priv_data; AVIOContext *pb = s->pb; AVCodecContext *audio_dec, *video_dec; AVStream *audio_stream, *video_stream; int frame_rate, ret; audio_stream = avformat_new_stream(s, NULL); video_stream = avformat_new_stream(s, NULL); // Extra data that will be passed to the decoder video_stream->codec->extradata_size = 8; video_stream->codec->extradata = av_mallocz(video_stream->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); if (!video_stream->codec->extradata) // Audio audio_dec = audio_stream->codec; audio_dec->codec_type = AVMEDIA_TYPE_AUDIO; audio_dec->codec_id = AV_CODEC_ID_ADPCM_IMA_APC; audio_dec->channels = 1; audio_dec->sample_rate = 22050; // Video video_dec = video_stream->codec; video_dec->codec_type = AVMEDIA_TYPE_VIDEO; video_dec->codec_id = AV_CODEC_ID_YOP; avio_skip(pb, 6); frame_rate = avio_r8(pb); yop->frame_size = avio_r8(pb) * 2048; video_dec->width = avio_rl16(pb); video_dec->height = avio_rl16(pb); video_stream->sample_aspect_ratio = (AVRational){1, 2}; ret = avio_read(pb, video_dec->extradata, 8); if (ret < 8) return ret < 0 ? ret : AVERROR_EOF; yop->palette_size = video_dec->extradata[0] * 3 + 4; yop->audio_block_length = AV_RL16(video_dec->extradata + 6); // 1840 samples per frame, 1 nibble per sample; hence 1840/2 = 920 if (yop->audio_block_length < 920 || yop->audio_block_length + yop->palette_size >= yop->frame_size) { av_log(s, AV_LOG_ERROR, "YOP has invalid header\n"); return AVERROR_INVALIDDATA; } avio_seek(pb, 2048, SEEK_SET); avpriv_set_pts_info(video_stream, 32, 1, frame_rate); return 0; }
true
FFmpeg
3d179edf6d2a987e7eb134eea541954338a19add
static int yop_read_header(AVFormatContext *s) { YopDecContext *yop = s->priv_data; AVIOContext *pb = s->pb; AVCodecContext *audio_dec, *video_dec; AVStream *audio_stream, *video_stream; int frame_rate, ret; audio_stream = avformat_new_stream(s, NULL); video_stream = avformat_new_stream(s, NULL); video_stream->codec->extradata_size = 8; video_stream->codec->extradata = av_mallocz(video_stream->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); if (!video_stream->codec->extradata) audio_dec = audio_stream->codec; audio_dec->codec_type = AVMEDIA_TYPE_AUDIO; audio_dec->codec_id = AV_CODEC_ID_ADPCM_IMA_APC; audio_dec->channels = 1; audio_dec->sample_rate = 22050; video_dec = video_stream->codec; video_dec->codec_type = AVMEDIA_TYPE_VIDEO; video_dec->codec_id = AV_CODEC_ID_YOP; avio_skip(pb, 6); frame_rate = avio_r8(pb); yop->frame_size = avio_r8(pb) * 2048; video_dec->width = avio_rl16(pb); video_dec->height = avio_rl16(pb); video_stream->sample_aspect_ratio = (AVRational){1, 2}; ret = avio_read(pb, video_dec->extradata, 8); if (ret < 8) return ret < 0 ? ret : AVERROR_EOF; yop->palette_size = video_dec->extradata[0] * 3 + 4; yop->audio_block_length = AV_RL16(video_dec->extradata + 6); if (yop->audio_block_length < 920 || yop->audio_block_length + yop->palette_size >= yop->frame_size) { av_log(s, AV_LOG_ERROR, "YOP has invalid header\n"); return AVERROR_INVALIDDATA; } avio_seek(pb, 2048, SEEK_SET); avpriv_set_pts_info(video_stream, 32, 1, frame_rate); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0) { YopDecContext *yop = VAR_0->priv_data; AVIOContext *pb = VAR_0->pb; AVCodecContext *audio_dec, *video_dec; AVStream *audio_stream, *video_stream; int VAR_1, VAR_2; audio_stream = avformat_new_stream(VAR_0, NULL); video_stream = avformat_new_stream(VAR_0, NULL); video_stream->codec->extradata_size = 8; video_stream->codec->extradata = av_mallocz(video_stream->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); if (!video_stream->codec->extradata) audio_dec = audio_stream->codec; audio_dec->codec_type = AVMEDIA_TYPE_AUDIO; audio_dec->codec_id = AV_CODEC_ID_ADPCM_IMA_APC; audio_dec->channels = 1; audio_dec->sample_rate = 22050; video_dec = video_stream->codec; video_dec->codec_type = AVMEDIA_TYPE_VIDEO; video_dec->codec_id = AV_CODEC_ID_YOP; avio_skip(pb, 6); VAR_1 = avio_r8(pb); yop->frame_size = avio_r8(pb) * 2048; video_dec->width = avio_rl16(pb); video_dec->height = avio_rl16(pb); video_stream->sample_aspect_ratio = (AVRational){1, 2}; VAR_2 = avio_read(pb, video_dec->extradata, 8); if (VAR_2 < 8) return VAR_2 < 0 ? VAR_2 : AVERROR_EOF; yop->palette_size = video_dec->extradata[0] * 3 + 4; yop->audio_block_length = AV_RL16(video_dec->extradata + 6); if (yop->audio_block_length < 920 || yop->audio_block_length + yop->palette_size >= yop->frame_size) { av_log(VAR_0, AV_LOG_ERROR, "YOP has invalid header\n"); return AVERROR_INVALIDDATA; } avio_seek(pb, 2048, SEEK_SET); avpriv_set_pts_info(video_stream, 32, 1, VAR_1); return 0; }
[ "static int FUNC_0(AVFormatContext *VAR_0)\n{", "YopDecContext *yop = VAR_0->priv_data;", "AVIOContext *pb = VAR_0->pb;", "AVCodecContext *audio_dec, *video_dec;", "AVStream *audio_stream, *video_stream;", "int VAR_1, VAR_2;", "audio_stream = avformat_new_stream(VAR_0, NULL);", "video_stream = avformat_new_stream(VAR_0, NULL);", "video_stream->codec->extradata_size = 8;", "video_stream->codec->extradata = av_mallocz(video_stream->codec->extradata_size +\nFF_INPUT_BUFFER_PADDING_SIZE);", "if (!video_stream->codec->extradata)\naudio_dec = audio_stream->codec;", "audio_dec->codec_type = AVMEDIA_TYPE_AUDIO;", "audio_dec->codec_id = AV_CODEC_ID_ADPCM_IMA_APC;", "audio_dec->channels = 1;", "audio_dec->sample_rate = 22050;", "video_dec = video_stream->codec;", "video_dec->codec_type = AVMEDIA_TYPE_VIDEO;", "video_dec->codec_id = AV_CODEC_ID_YOP;", "avio_skip(pb, 6);", "VAR_1 = avio_r8(pb);", "yop->frame_size = avio_r8(pb) * 2048;", "video_dec->width = avio_rl16(pb);", "video_dec->height = avio_rl16(pb);", "video_stream->sample_aspect_ratio = (AVRational){1, 2};", "VAR_2 = avio_read(pb, video_dec->extradata, 8);", "if (VAR_2 < 8)\nreturn VAR_2 < 0 ? VAR_2 : AVERROR_EOF;", "yop->palette_size = video_dec->extradata[0] * 3 + 4;", "yop->audio_block_length = AV_RL16(video_dec->extradata + 6);", "if (yop->audio_block_length < 920 ||\nyop->audio_block_length + yop->palette_size >= yop->frame_size) {", "av_log(VAR_0, AV_LOG_ERROR, \"YOP has invalid header\\n\");", "return AVERROR_INVALIDDATA;", "}", "avio_seek(pb, 2048, SEEK_SET);", "avpriv_set_pts_info(video_stream, 32, 1, VAR_1);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 17 ], [ 21 ], [ 23 ], [ 31 ], [ 35, 37 ], [ 41, 48 ], [ 50 ], [ 52 ], [ 54 ], [ 56 ], [ 62 ], [ 64 ], [ 66 ], [ 70 ], [ 74 ], [ 76 ], [ 78 ], [ 80 ], [ 84 ], [ 88 ], [ 90, 92 ], [ 96 ], [ 98 ], [ 104, 106 ], [ 108 ], [ 110 ], [ 112 ], [ 116 ], [ 120 ], [ 124 ], [ 126 ] ]
728
int64_t bdrv_get_block_status_above(BlockDriverState *bs, BlockDriverState *base, int64_t sector_num, int nb_sectors, int *pnum, BlockDriverState **file) { Coroutine *co; BdrvCoGetBlockStatusData data = { .bs = bs, .base = base, .file = file, .sector_num = sector_num, .nb_sectors = nb_sectors, .pnum = pnum, .done = false, }; if (qemu_in_coroutine()) { /* Fast-path if already in coroutine context */ bdrv_get_block_status_above_co_entry(&data); } else { AioContext *aio_context = bdrv_get_aio_context(bs); co = qemu_coroutine_create(bdrv_get_block_status_above_co_entry); qemu_coroutine_enter(co, &data); while (!data.done) { aio_poll(aio_context, true); } } return data.ret; }
true
qemu
0b8b8753e4d94901627b3e86431230f2319215c4
int64_t bdrv_get_block_status_above(BlockDriverState *bs, BlockDriverState *base, int64_t sector_num, int nb_sectors, int *pnum, BlockDriverState **file) { Coroutine *co; BdrvCoGetBlockStatusData data = { .bs = bs, .base = base, .file = file, .sector_num = sector_num, .nb_sectors = nb_sectors, .pnum = pnum, .done = false, }; if (qemu_in_coroutine()) { bdrv_get_block_status_above_co_entry(&data); } else { AioContext *aio_context = bdrv_get_aio_context(bs); co = qemu_coroutine_create(bdrv_get_block_status_above_co_entry); qemu_coroutine_enter(co, &data); while (!data.done) { aio_poll(aio_context, true); } } return data.ret; }
{ "code": [ " co = qemu_coroutine_create(bdrv_get_block_status_above_co_entry);", " qemu_coroutine_enter(co, &data);", " qemu_coroutine_enter(co, &data);", " qemu_coroutine_enter(co, &data);", " qemu_coroutine_enter(co, &data);" ], "line_no": [ 47, 49, 49, 49, 49 ] }
int64_t FUNC_0(BlockDriverState *bs, BlockDriverState *base, int64_t sector_num, int nb_sectors, int *pnum, BlockDriverState **file) { Coroutine *co; BdrvCoGetBlockStatusData data = { .bs = bs, .base = base, .file = file, .sector_num = sector_num, .nb_sectors = nb_sectors, .pnum = pnum, .done = false, }; if (qemu_in_coroutine()) { bdrv_get_block_status_above_co_entry(&data); } else { AioContext *aio_context = bdrv_get_aio_context(bs); co = qemu_coroutine_create(bdrv_get_block_status_above_co_entry); qemu_coroutine_enter(co, &data); while (!data.done) { aio_poll(aio_context, true); } } return data.ret; }
[ "int64_t FUNC_0(BlockDriverState *bs,\nBlockDriverState *base,\nint64_t sector_num,\nint nb_sectors, int *pnum,\nBlockDriverState **file)\n{", "Coroutine *co;", "BdrvCoGetBlockStatusData data = {", ".bs = bs,\n.base = base,\n.file = file,\n.sector_num = sector_num,\n.nb_sectors = nb_sectors,\n.pnum = pnum,\n.done = false,\n};", "if (qemu_in_coroutine()) {", "bdrv_get_block_status_above_co_entry(&data);", "} else {", "AioContext *aio_context = bdrv_get_aio_context(bs);", "co = qemu_coroutine_create(bdrv_get_block_status_above_co_entry);", "qemu_coroutine_enter(co, &data);", "while (!data.done) {", "aio_poll(aio_context, true);", "}", "}", "return data.ret;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11 ], [ 13 ], [ 15 ], [ 17, 19, 21, 23, 25, 27, 29, 31 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ] ]
730
static int add_string_metadata(int count, const char *name, TiffContext *s) { char *value; if (bytestream2_get_bytes_left(&s->gb) < count || count < 0) return AVERROR_INVALIDDATA; value = av_malloc(count + 1); if (!value) return AVERROR(ENOMEM); bytestream2_get_bufferu(&s->gb, value, count); value[count] = 0; av_dict_set(avpriv_frame_get_metadatap(&s->picture), name, value, AV_DICT_DONT_STRDUP_VAL); return 0; }
true
FFmpeg
edcc51fb8e15b704955d742559215697598927bb
static int add_string_metadata(int count, const char *name, TiffContext *s) { char *value; if (bytestream2_get_bytes_left(&s->gb) < count || count < 0) return AVERROR_INVALIDDATA; value = av_malloc(count + 1); if (!value) return AVERROR(ENOMEM); bytestream2_get_bufferu(&s->gb, value, count); value[count] = 0; av_dict_set(avpriv_frame_get_metadatap(&s->picture), name, value, AV_DICT_DONT_STRDUP_VAL); return 0; }
{ "code": [ " TiffContext *s)", " av_dict_set(avpriv_frame_get_metadatap(&s->picture), name, value, AV_DICT_DONT_STRDUP_VAL);" ], "line_no": [ 3, 31 ] }
static int FUNC_0(int VAR_0, const char *VAR_1, TiffContext *VAR_2) { char *VAR_3; if (bytestream2_get_bytes_left(&VAR_2->gb) < VAR_0 || VAR_0 < 0) return AVERROR_INVALIDDATA; VAR_3 = av_malloc(VAR_0 + 1); if (!VAR_3) return AVERROR(ENOMEM); bytestream2_get_bufferu(&VAR_2->gb, VAR_3, VAR_0); VAR_3[VAR_0] = 0; av_dict_set(avpriv_frame_get_metadatap(&VAR_2->picture), VAR_1, VAR_3, AV_DICT_DONT_STRDUP_VAL); return 0; }
[ "static int FUNC_0(int VAR_0, const char *VAR_1,\nTiffContext *VAR_2)\n{", "char *VAR_3;", "if (bytestream2_get_bytes_left(&VAR_2->gb) < VAR_0 || VAR_0 < 0)\nreturn AVERROR_INVALIDDATA;", "VAR_3 = av_malloc(VAR_0 + 1);", "if (!VAR_3)\nreturn AVERROR(ENOMEM);", "bytestream2_get_bufferu(&VAR_2->gb, VAR_3, VAR_0);", "VAR_3[VAR_0] = 0;", "av_dict_set(avpriv_frame_get_metadatap(&VAR_2->picture), VAR_1, VAR_3, AV_DICT_DONT_STRDUP_VAL);", "return 0;", "}" ]
[ 1, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11, 13 ], [ 17 ], [ 19, 21 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ] ]
731
static void pc_q35_init_1_6(QEMUMachineInitArgs *args) { has_pci_info = false; pc_q35_init(args); }
true
qemu
04920fc0faa4760f9c4fc0e73b992b768099be70
static void pc_q35_init_1_6(QEMUMachineInitArgs *args) { has_pci_info = false; pc_q35_init(args); }
{ "code": [], "line_no": [] }
static void FUNC_0(QEMUMachineInitArgs *VAR_0) { has_pci_info = false; pc_q35_init(VAR_0); }
[ "static void FUNC_0(QEMUMachineInitArgs *VAR_0)\n{", "has_pci_info = false;", "pc_q35_init(VAR_0);", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 8 ], [ 10 ] ]
732
static void dvbsub_parse_clut_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { DVBSubContext *ctx = avctx->priv_data; const uint8_t *buf_end = buf + buf_size; int i, clut_id; DVBSubCLUT *clut; int entry_id, depth , full_range; int y, cr, cb, alpha; int r, g, b, r_add, g_add, b_add; av_dlog(avctx, "DVB clut packet:\n"); for (i=0; i < buf_size; i++) { av_dlog(avctx, "%02x ", buf[i]); if (i % 16 == 15) av_dlog(avctx, "\n"); } if (i % 16) av_dlog(avctx, "\n"); clut_id = *buf++; buf += 1; clut = get_clut(ctx, clut_id); if (!clut) { clut = av_malloc(sizeof(DVBSubCLUT)); memcpy(clut, &default_clut, sizeof(DVBSubCLUT)); clut->id = clut_id; clut->next = ctx->clut_list; ctx->clut_list = clut; } while (buf + 4 < buf_end) { entry_id = *buf++; depth = (*buf) & 0xe0; if (depth == 0) { av_log(avctx, AV_LOG_ERROR, "Invalid clut depth 0x%x!\n", *buf); return; } full_range = (*buf++) & 1; if (full_range) { y = *buf++; cr = *buf++; cb = *buf++; alpha = *buf++; } else { y = buf[0] & 0xfc; cr = (((buf[0] & 3) << 2) | ((buf[1] >> 6) & 3)) << 4; cb = (buf[1] << 2) & 0xf0; alpha = (buf[1] << 6) & 0xc0; buf += 2; } if (y == 0) alpha = 0xff; YUV_TO_RGB1_CCIR(cb, cr); YUV_TO_RGB2_CCIR(r, g, b, y); av_dlog(avctx, "clut %d := (%d,%d,%d,%d)\n", entry_id, r, g, b, alpha); if (depth & 0x80) clut->clut4[entry_id] = RGBA(r,g,b,255 - alpha); if (depth & 0x40) clut->clut16[entry_id] = RGBA(r,g,b,255 - alpha); if (depth & 0x20) clut->clut256[entry_id] = RGBA(r,g,b,255 - alpha); } }
false
FFmpeg
607ad990d31e6be52980970e5ce8cd25ab3de812
static void dvbsub_parse_clut_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { DVBSubContext *ctx = avctx->priv_data; const uint8_t *buf_end = buf + buf_size; int i, clut_id; DVBSubCLUT *clut; int entry_id, depth , full_range; int y, cr, cb, alpha; int r, g, b, r_add, g_add, b_add; av_dlog(avctx, "DVB clut packet:\n"); for (i=0; i < buf_size; i++) { av_dlog(avctx, "%02x ", buf[i]); if (i % 16 == 15) av_dlog(avctx, "\n"); } if (i % 16) av_dlog(avctx, "\n"); clut_id = *buf++; buf += 1; clut = get_clut(ctx, clut_id); if (!clut) { clut = av_malloc(sizeof(DVBSubCLUT)); memcpy(clut, &default_clut, sizeof(DVBSubCLUT)); clut->id = clut_id; clut->next = ctx->clut_list; ctx->clut_list = clut; } while (buf + 4 < buf_end) { entry_id = *buf++; depth = (*buf) & 0xe0; if (depth == 0) { av_log(avctx, AV_LOG_ERROR, "Invalid clut depth 0x%x!\n", *buf); return; } full_range = (*buf++) & 1; if (full_range) { y = *buf++; cr = *buf++; cb = *buf++; alpha = *buf++; } else { y = buf[0] & 0xfc; cr = (((buf[0] & 3) << 2) | ((buf[1] >> 6) & 3)) << 4; cb = (buf[1] << 2) & 0xf0; alpha = (buf[1] << 6) & 0xc0; buf += 2; } if (y == 0) alpha = 0xff; YUV_TO_RGB1_CCIR(cb, cr); YUV_TO_RGB2_CCIR(r, g, b, y); av_dlog(avctx, "clut %d := (%d,%d,%d,%d)\n", entry_id, r, g, b, alpha); if (depth & 0x80) clut->clut4[entry_id] = RGBA(r,g,b,255 - alpha); if (depth & 0x40) clut->clut16[entry_id] = RGBA(r,g,b,255 - alpha); if (depth & 0x20) clut->clut256[entry_id] = RGBA(r,g,b,255 - alpha); } }
{ "code": [], "line_no": [] }
static void FUNC_0(AVCodecContext *VAR_0, const uint8_t *VAR_1, int VAR_2) { DVBSubContext *ctx = VAR_0->priv_data; const uint8_t *VAR_3 = VAR_1 + VAR_2; int VAR_4, VAR_5; DVBSubCLUT *clut; int VAR_6, VAR_7 , VAR_8; int VAR_9, VAR_10, VAR_11, VAR_12; int VAR_13, VAR_14, VAR_15, VAR_16, VAR_17, VAR_18; av_dlog(VAR_0, "DVB clut packet:\n"); for (VAR_4=0; VAR_4 < VAR_2; VAR_4++) { av_dlog(VAR_0, "%02x ", VAR_1[VAR_4]); if (VAR_4 % 16 == 15) av_dlog(VAR_0, "\n"); } if (VAR_4 % 16) av_dlog(VAR_0, "\n"); VAR_5 = *VAR_1++; VAR_1 += 1; clut = get_clut(ctx, VAR_5); if (!clut) { clut = av_malloc(sizeof(DVBSubCLUT)); memcpy(clut, &default_clut, sizeof(DVBSubCLUT)); clut->id = VAR_5; clut->next = ctx->clut_list; ctx->clut_list = clut; } while (VAR_1 + 4 < VAR_3) { VAR_6 = *VAR_1++; VAR_7 = (*VAR_1) & 0xe0; if (VAR_7 == 0) { av_log(VAR_0, AV_LOG_ERROR, "Invalid clut VAR_7 0x%x!\n", *VAR_1); return; } VAR_8 = (*VAR_1++) & 1; if (VAR_8) { VAR_9 = *VAR_1++; VAR_10 = *VAR_1++; VAR_11 = *VAR_1++; VAR_12 = *VAR_1++; } else { VAR_9 = VAR_1[0] & 0xfc; VAR_10 = (((VAR_1[0] & 3) << 2) | ((VAR_1[1] >> 6) & 3)) << 4; VAR_11 = (VAR_1[1] << 2) & 0xf0; VAR_12 = (VAR_1[1] << 6) & 0xc0; VAR_1 += 2; } if (VAR_9 == 0) VAR_12 = 0xff; YUV_TO_RGB1_CCIR(VAR_11, VAR_10); YUV_TO_RGB2_CCIR(VAR_13, VAR_14, VAR_15, VAR_9); av_dlog(VAR_0, "clut %d := (%d,%d,%d,%d)\n", VAR_6, VAR_13, VAR_14, VAR_15, VAR_12); if (VAR_7 & 0x80) clut->clut4[VAR_6] = RGBA(VAR_13,VAR_14,VAR_15,255 - VAR_12); if (VAR_7 & 0x40) clut->clut16[VAR_6] = RGBA(VAR_13,VAR_14,VAR_15,255 - VAR_12); if (VAR_7 & 0x20) clut->clut256[VAR_6] = RGBA(VAR_13,VAR_14,VAR_15,255 - VAR_12); } }
[ "static void FUNC_0(AVCodecContext *VAR_0,\nconst uint8_t *VAR_1, int VAR_2)\n{", "DVBSubContext *ctx = VAR_0->priv_data;", "const uint8_t *VAR_3 = VAR_1 + VAR_2;", "int VAR_4, VAR_5;", "DVBSubCLUT *clut;", "int VAR_6, VAR_7 , VAR_8;", "int VAR_9, VAR_10, VAR_11, VAR_12;", "int VAR_13, VAR_14, VAR_15, VAR_16, VAR_17, VAR_18;", "av_dlog(VAR_0, \"DVB clut packet:\\n\");", "for (VAR_4=0; VAR_4 < VAR_2; VAR_4++) {", "av_dlog(VAR_0, \"%02x \", VAR_1[VAR_4]);", "if (VAR_4 % 16 == 15)\nav_dlog(VAR_0, \"\\n\");", "}", "if (VAR_4 % 16)\nav_dlog(VAR_0, \"\\n\");", "VAR_5 = *VAR_1++;", "VAR_1 += 1;", "clut = get_clut(ctx, VAR_5);", "if (!clut) {", "clut = av_malloc(sizeof(DVBSubCLUT));", "memcpy(clut, &default_clut, sizeof(DVBSubCLUT));", "clut->id = VAR_5;", "clut->next = ctx->clut_list;", "ctx->clut_list = clut;", "}", "while (VAR_1 + 4 < VAR_3) {", "VAR_6 = *VAR_1++;", "VAR_7 = (*VAR_1) & 0xe0;", "if (VAR_7 == 0) {", "av_log(VAR_0, AV_LOG_ERROR, \"Invalid clut VAR_7 0x%x!\\n\", *VAR_1);", "return;", "}", "VAR_8 = (*VAR_1++) & 1;", "if (VAR_8) {", "VAR_9 = *VAR_1++;", "VAR_10 = *VAR_1++;", "VAR_11 = *VAR_1++;", "VAR_12 = *VAR_1++;", "} else {", "VAR_9 = VAR_1[0] & 0xfc;", "VAR_10 = (((VAR_1[0] & 3) << 2) | ((VAR_1[1] >> 6) & 3)) << 4;", "VAR_11 = (VAR_1[1] << 2) & 0xf0;", "VAR_12 = (VAR_1[1] << 6) & 0xc0;", "VAR_1 += 2;", "}", "if (VAR_9 == 0)\nVAR_12 = 0xff;", "YUV_TO_RGB1_CCIR(VAR_11, VAR_10);", "YUV_TO_RGB2_CCIR(VAR_13, VAR_14, VAR_15, VAR_9);", "av_dlog(VAR_0, \"clut %d := (%d,%d,%d,%d)\\n\", VAR_6, VAR_13, VAR_14, VAR_15, VAR_12);", "if (VAR_7 & 0x80)\nclut->clut4[VAR_6] = RGBA(VAR_13,VAR_14,VAR_15,255 - VAR_12);", "if (VAR_7 & 0x40)\nclut->clut16[VAR_6] = RGBA(VAR_13,VAR_14,VAR_15,255 - VAR_12);", "if (VAR_7 & 0x20)\nclut->clut256[VAR_6] = RGBA(VAR_13,VAR_14,VAR_15,255 - VAR_12);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 29 ], [ 31 ], [ 33, 35 ], [ 37 ], [ 41, 43 ], [ 47 ], [ 49 ], [ 53 ], [ 57 ], [ 59 ], [ 63 ], [ 67 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 85 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 99 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 125 ], [ 127 ], [ 131, 133 ], [ 137 ], [ 139 ], [ 143 ], [ 147, 149 ], [ 151, 153 ], [ 155, 157 ], [ 159 ], [ 161 ] ]
733
static void intra_predict_mad_cow_dc_l0t_8x8_msa(uint8_t *src, int32_t stride) { uint8_t lp_cnt; uint32_t src0, src1, src2 = 0; uint32_t out0, out1, out2; v16u8 src_top; v8u16 add; v4u32 sum; src_top = LD_UB(src - stride); add = __msa_hadd_u_h(src_top, src_top); sum = __msa_hadd_u_w(add, add); src0 = __msa_copy_u_w((v4i32) sum, 0); src1 = __msa_copy_u_w((v4i32) sum, 1); for (lp_cnt = 0; lp_cnt < 4; lp_cnt++) { src2 += src[lp_cnt * stride - 1]; } src2 = (src0 + src2 + 4) >> 3; src0 = (src0 + 2) >> 2; src1 = (src1 + 2) >> 2; out0 = src0 * 0x01010101; out1 = src1 * 0x01010101; out2 = src2 * 0x01010101; for (lp_cnt = 4; lp_cnt--;) { SW(out2, src); SW(out1, src + 4); SW(out0, src + stride * 4); SW(out1, src + stride * 4 + 4); src += stride; } }
false
FFmpeg
d6737539e77e78fca9a04914d51996cfd1ccc55c
static void intra_predict_mad_cow_dc_l0t_8x8_msa(uint8_t *src, int32_t stride) { uint8_t lp_cnt; uint32_t src0, src1, src2 = 0; uint32_t out0, out1, out2; v16u8 src_top; v8u16 add; v4u32 sum; src_top = LD_UB(src - stride); add = __msa_hadd_u_h(src_top, src_top); sum = __msa_hadd_u_w(add, add); src0 = __msa_copy_u_w((v4i32) sum, 0); src1 = __msa_copy_u_w((v4i32) sum, 1); for (lp_cnt = 0; lp_cnt < 4; lp_cnt++) { src2 += src[lp_cnt * stride - 1]; } src2 = (src0 + src2 + 4) >> 3; src0 = (src0 + 2) >> 2; src1 = (src1 + 2) >> 2; out0 = src0 * 0x01010101; out1 = src1 * 0x01010101; out2 = src2 * 0x01010101; for (lp_cnt = 4; lp_cnt--;) { SW(out2, src); SW(out1, src + 4); SW(out0, src + stride * 4); SW(out1, src + stride * 4 + 4); src += stride; } }
{ "code": [], "line_no": [] }
static void FUNC_0(uint8_t *VAR_0, int32_t VAR_1) { uint8_t lp_cnt; uint32_t src0, src1, src2 = 0; uint32_t out0, out1, out2; v16u8 src_top; v8u16 add; v4u32 sum; src_top = LD_UB(VAR_0 - VAR_1); add = __msa_hadd_u_h(src_top, src_top); sum = __msa_hadd_u_w(add, add); src0 = __msa_copy_u_w((v4i32) sum, 0); src1 = __msa_copy_u_w((v4i32) sum, 1); for (lp_cnt = 0; lp_cnt < 4; lp_cnt++) { src2 += VAR_0[lp_cnt * VAR_1 - 1]; } src2 = (src0 + src2 + 4) >> 3; src0 = (src0 + 2) >> 2; src1 = (src1 + 2) >> 2; out0 = src0 * 0x01010101; out1 = src1 * 0x01010101; out2 = src2 * 0x01010101; for (lp_cnt = 4; lp_cnt--;) { SW(out2, VAR_0); SW(out1, VAR_0 + 4); SW(out0, VAR_0 + VAR_1 * 4); SW(out1, VAR_0 + VAR_1 * 4 + 4); VAR_0 += VAR_1; } }
[ "static void FUNC_0(uint8_t *VAR_0, int32_t VAR_1)\n{", "uint8_t lp_cnt;", "uint32_t src0, src1, src2 = 0;", "uint32_t out0, out1, out2;", "v16u8 src_top;", "v8u16 add;", "v4u32 sum;", "src_top = LD_UB(VAR_0 - VAR_1);", "add = __msa_hadd_u_h(src_top, src_top);", "sum = __msa_hadd_u_w(add, add);", "src0 = __msa_copy_u_w((v4i32) sum, 0);", "src1 = __msa_copy_u_w((v4i32) sum, 1);", "for (lp_cnt = 0; lp_cnt < 4; lp_cnt++) {", "src2 += VAR_0[lp_cnt * VAR_1 - 1];", "}", "src2 = (src0 + src2 + 4) >> 3;", "src0 = (src0 + 2) >> 2;", "src1 = (src1 + 2) >> 2;", "out0 = src0 * 0x01010101;", "out1 = src1 * 0x01010101;", "out2 = src2 * 0x01010101;", "for (lp_cnt = 4; lp_cnt--;) {", "SW(out2, VAR_0);", "SW(out1, VAR_0 + 4);", "SW(out0, VAR_0 + VAR_1 * 4);", "SW(out1, VAR_0 + VAR_1 * 4 + 4);", "VAR_0 += VAR_1;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ] ]
735
static int write_streamheader(AVFormatContext *avctx, AVIOContext *bc, AVStream *st, int i){ NUTContext *nut = avctx->priv_data; AVCodecContext *codec = st->codec; unsigned codec_tag = av_codec_get_tag(ff_nut_codec_tags, codec->codec_id); ff_put_v(bc, i); switch(codec->codec_type){ case AVMEDIA_TYPE_VIDEO: ff_put_v(bc, 0); break; case AVMEDIA_TYPE_AUDIO: ff_put_v(bc, 1); break; case AVMEDIA_TYPE_SUBTITLE: ff_put_v(bc, 2); break; default : ff_put_v(bc, 3); break; } ff_put_v(bc, 4); if (!codec_tag) codec_tag = codec->codec_tag; if (codec_tag) { avio_wl32(bc, codec_tag); } else { av_log(avctx, AV_LOG_ERROR, "No codec tag defined for stream %d\n", i); return AVERROR(EINVAL); } ff_put_v(bc, nut->stream[i].time_base - nut->time_base); ff_put_v(bc, nut->stream[i].msb_pts_shift); ff_put_v(bc, nut->stream[i].max_pts_distance); ff_put_v(bc, codec->has_b_frames); avio_w8(bc, 0); /* flags: 0x1 - fixed_fps, 0x2 - index_present */ ff_put_v(bc, codec->extradata_size); avio_write(bc, codec->extradata, codec->extradata_size); switch(codec->codec_type){ case AVMEDIA_TYPE_AUDIO: ff_put_v(bc, codec->sample_rate); ff_put_v(bc, 1); ff_put_v(bc, codec->channels); break; case AVMEDIA_TYPE_VIDEO: ff_put_v(bc, codec->width); ff_put_v(bc, codec->height); if(st->sample_aspect_ratio.num<=0 || st->sample_aspect_ratio.den<=0){ ff_put_v(bc, 0); ff_put_v(bc, 0); }else{ ff_put_v(bc, st->sample_aspect_ratio.num); ff_put_v(bc, st->sample_aspect_ratio.den); } ff_put_v(bc, 0); /* csp type -- unknown */ break; default: break; } return 0; }
false
FFmpeg
21de6ba5c12fbdd2ad86e5faf8aa12be8f5f6408
static int write_streamheader(AVFormatContext *avctx, AVIOContext *bc, AVStream *st, int i){ NUTContext *nut = avctx->priv_data; AVCodecContext *codec = st->codec; unsigned codec_tag = av_codec_get_tag(ff_nut_codec_tags, codec->codec_id); ff_put_v(bc, i); switch(codec->codec_type){ case AVMEDIA_TYPE_VIDEO: ff_put_v(bc, 0); break; case AVMEDIA_TYPE_AUDIO: ff_put_v(bc, 1); break; case AVMEDIA_TYPE_SUBTITLE: ff_put_v(bc, 2); break; default : ff_put_v(bc, 3); break; } ff_put_v(bc, 4); if (!codec_tag) codec_tag = codec->codec_tag; if (codec_tag) { avio_wl32(bc, codec_tag); } else { av_log(avctx, AV_LOG_ERROR, "No codec tag defined for stream %d\n", i); return AVERROR(EINVAL); } ff_put_v(bc, nut->stream[i].time_base - nut->time_base); ff_put_v(bc, nut->stream[i].msb_pts_shift); ff_put_v(bc, nut->stream[i].max_pts_distance); ff_put_v(bc, codec->has_b_frames); avio_w8(bc, 0); ff_put_v(bc, codec->extradata_size); avio_write(bc, codec->extradata, codec->extradata_size); switch(codec->codec_type){ case AVMEDIA_TYPE_AUDIO: ff_put_v(bc, codec->sample_rate); ff_put_v(bc, 1); ff_put_v(bc, codec->channels); break; case AVMEDIA_TYPE_VIDEO: ff_put_v(bc, codec->width); ff_put_v(bc, codec->height); if(st->sample_aspect_ratio.num<=0 || st->sample_aspect_ratio.den<=0){ ff_put_v(bc, 0); ff_put_v(bc, 0); }else{ ff_put_v(bc, st->sample_aspect_ratio.num); ff_put_v(bc, st->sample_aspect_ratio.den); } ff_put_v(bc, 0); break; default: break; } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1, AVStream *VAR_2, int VAR_3){ NUTContext *nut = VAR_0->priv_data; AVCodecContext *codec = VAR_2->codec; unsigned VAR_4 = av_codec_get_tag(ff_nut_codec_tags, codec->codec_id); ff_put_v(VAR_1, VAR_3); switch(codec->codec_type){ case AVMEDIA_TYPE_VIDEO: ff_put_v(VAR_1, 0); break; case AVMEDIA_TYPE_AUDIO: ff_put_v(VAR_1, 1); break; case AVMEDIA_TYPE_SUBTITLE: ff_put_v(VAR_1, 2); break; default : ff_put_v(VAR_1, 3); break; } ff_put_v(VAR_1, 4); if (!VAR_4) VAR_4 = codec->VAR_4; if (VAR_4) { avio_wl32(VAR_1, VAR_4); } else { av_log(VAR_0, AV_LOG_ERROR, "No codec tag defined for stream %d\n", VAR_3); return AVERROR(EINVAL); } ff_put_v(VAR_1, nut->stream[VAR_3].time_base - nut->time_base); ff_put_v(VAR_1, nut->stream[VAR_3].msb_pts_shift); ff_put_v(VAR_1, nut->stream[VAR_3].max_pts_distance); ff_put_v(VAR_1, codec->has_b_frames); avio_w8(VAR_1, 0); ff_put_v(VAR_1, codec->extradata_size); avio_write(VAR_1, codec->extradata, codec->extradata_size); switch(codec->codec_type){ case AVMEDIA_TYPE_AUDIO: ff_put_v(VAR_1, codec->sample_rate); ff_put_v(VAR_1, 1); ff_put_v(VAR_1, codec->channels); break; case AVMEDIA_TYPE_VIDEO: ff_put_v(VAR_1, codec->width); ff_put_v(VAR_1, codec->height); if(VAR_2->sample_aspect_ratio.num<=0 || VAR_2->sample_aspect_ratio.den<=0){ ff_put_v(VAR_1, 0); ff_put_v(VAR_1, 0); }else{ ff_put_v(VAR_1, VAR_2->sample_aspect_ratio.num); ff_put_v(VAR_1, VAR_2->sample_aspect_ratio.den); } ff_put_v(VAR_1, 0); break; default: break; } return 0; }
[ "static int FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1, AVStream *VAR_2, int VAR_3){", "NUTContext *nut = VAR_0->priv_data;", "AVCodecContext *codec = VAR_2->codec;", "unsigned VAR_4 = av_codec_get_tag(ff_nut_codec_tags, codec->codec_id);", "ff_put_v(VAR_1, VAR_3);", "switch(codec->codec_type){", "case AVMEDIA_TYPE_VIDEO: ff_put_v(VAR_1, 0); break;", "case AVMEDIA_TYPE_AUDIO: ff_put_v(VAR_1, 1); break;", "case AVMEDIA_TYPE_SUBTITLE: ff_put_v(VAR_1, 2); break;", "default : ff_put_v(VAR_1, 3); break;", "}", "ff_put_v(VAR_1, 4);", "if (!VAR_4)\nVAR_4 = codec->VAR_4;", "if (VAR_4) {", "avio_wl32(VAR_1, VAR_4);", "} else {", "av_log(VAR_0, AV_LOG_ERROR, \"No codec tag defined for stream %d\\n\", VAR_3);", "return AVERROR(EINVAL);", "}", "ff_put_v(VAR_1, nut->stream[VAR_3].time_base - nut->time_base);", "ff_put_v(VAR_1, nut->stream[VAR_3].msb_pts_shift);", "ff_put_v(VAR_1, nut->stream[VAR_3].max_pts_distance);", "ff_put_v(VAR_1, codec->has_b_frames);", "avio_w8(VAR_1, 0);", "ff_put_v(VAR_1, codec->extradata_size);", "avio_write(VAR_1, codec->extradata, codec->extradata_size);", "switch(codec->codec_type){", "case AVMEDIA_TYPE_AUDIO:\nff_put_v(VAR_1, codec->sample_rate);", "ff_put_v(VAR_1, 1);", "ff_put_v(VAR_1, codec->channels);", "break;", "case AVMEDIA_TYPE_VIDEO:\nff_put_v(VAR_1, codec->width);", "ff_put_v(VAR_1, codec->height);", "if(VAR_2->sample_aspect_ratio.num<=0 || VAR_2->sample_aspect_ratio.den<=0){", "ff_put_v(VAR_1, 0);", "ff_put_v(VAR_1, 0);", "}else{", "ff_put_v(VAR_1, VAR_2->sample_aspect_ratio.num);", "ff_put_v(VAR_1, VAR_2->sample_aspect_ratio.den);", "}", "ff_put_v(VAR_1, 0);", "break;", "default:\nbreak;", "}", "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 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29, 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 67 ], [ 69, 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79, 81 ], [ 83 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105, 107 ], [ 109 ], [ 111 ], [ 113 ] ]
736
SYNTH_FILTER_FUNC(sse2) SYNTH_FILTER_FUNC(avx) SYNTH_FILTER_FUNC(fma3) #endif /* HAVE_YASM */ av_cold void ff_synth_filter_init_x86(SynthFilterContext *s) { #if HAVE_YASM int cpu_flags = av_get_cpu_flags(); #if ARCH_X86_32 if (EXTERNAL_SSE(cpu_flags)) { s->synth_filter_float = synth_filter_sse; } #endif if (EXTERNAL_SSE2(cpu_flags)) { s->synth_filter_float = synth_filter_sse2; } if (EXTERNAL_AVX(cpu_flags)) { s->synth_filter_float = synth_filter_avx; } if (EXTERNAL_FMA3(cpu_flags)) { s->synth_filter_float = synth_filter_fma3; } #endif /* HAVE_YASM */ }
false
FFmpeg
d68c05380cebf563915412182643a8be04ef890b
SYNTH_FILTER_FUNC(sse2) SYNTH_FILTER_FUNC(avx) SYNTH_FILTER_FUNC(fma3) #endif av_cold void ff_synth_filter_init_x86(SynthFilterContext *s) { #if HAVE_YASM int cpu_flags = av_get_cpu_flags(); #if ARCH_X86_32 if (EXTERNAL_SSE(cpu_flags)) { s->synth_filter_float = synth_filter_sse; } #endif if (EXTERNAL_SSE2(cpu_flags)) { s->synth_filter_float = synth_filter_sse2; } if (EXTERNAL_AVX(cpu_flags)) { s->synth_filter_float = synth_filter_avx; } if (EXTERNAL_FMA3(cpu_flags)) { s->synth_filter_float = synth_filter_fma3; } #endif }
{ "code": [], "line_no": [] }
SYNTH_FILTER_FUNC(sse2) SYNTH_FILTER_FUNC(avx) SYNTH_FILTER_FUNC(fma3) #endif av_cold void ff_synth_filter_init_x86(SynthFilterContext *s) { #if HAVE_YASM int cpu_flags = av_get_cpu_flags(); #if ARCH_X86_32 if (EXTERNAL_SSE(cpu_flags)) { s->synth_filter_float = synth_filter_sse; } #endif if (EXTERNAL_SSE2(cpu_flags)) { s->synth_filter_float = synth_filter_sse2; } if (EXTERNAL_AVX(cpu_flags)) { s->synth_filter_float = synth_filter_avx; } if (EXTERNAL_FMA3(cpu_flags)) { s->synth_filter_float = synth_filter_fma3; } #endif }
[ "SYNTH_FILTER_FUNC(sse2)\nSYNTH_FILTER_FUNC(avx)\nSYNTH_FILTER_FUNC(fma3)\n#endif\nav_cold void ff_synth_filter_init_x86(SynthFilterContext *s)\n{", "#if HAVE_YASM\nint cpu_flags = av_get_cpu_flags();", "#if ARCH_X86_32\nif (EXTERNAL_SSE(cpu_flags)) {", "s->synth_filter_float = synth_filter_sse;", "}", "#endif\nif (EXTERNAL_SSE2(cpu_flags)) {", "s->synth_filter_float = synth_filter_sse2;", "}", "if (EXTERNAL_AVX(cpu_flags)) {", "s->synth_filter_float = synth_filter_avx;", "}", "if (EXTERNAL_FMA3(cpu_flags)) {", "s->synth_filter_float = synth_filter_fma3;", "}", "#endif\n}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 11, 13 ], [ 15, 17 ], [ 21, 23 ], [ 25 ], [ 27 ], [ 29, 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49, 51 ] ]
737
static BlockDriverAIOCB *iscsi_aio_ioctl(BlockDriverState *bs, unsigned long int req, void *buf, BlockDriverCompletionFunc *cb, void *opaque) { IscsiLun *iscsilun = bs->opaque; struct iscsi_context *iscsi = iscsilun->iscsi; struct iscsi_data data; IscsiAIOCB *acb; assert(req == SG_IO); acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque); acb->iscsilun = iscsilun; acb->canceled = 0; acb->bh = NULL; acb->status = -EINPROGRESS; acb->buf = NULL; acb->ioh = buf; acb->task = malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { error_report("iSCSI: Failed to allocate task for scsi command. %s", iscsi_get_error(iscsi)); qemu_aio_release(acb); return NULL; } memset(acb->task, 0, sizeof(struct scsi_task)); switch (acb->ioh->dxfer_direction) { case SG_DXFER_TO_DEV: acb->task->xfer_dir = SCSI_XFER_WRITE; break; case SG_DXFER_FROM_DEV: acb->task->xfer_dir = SCSI_XFER_READ; break; default: acb->task->xfer_dir = SCSI_XFER_NONE; break; } acb->task->cdb_size = acb->ioh->cmd_len; memcpy(&acb->task->cdb[0], acb->ioh->cmdp, acb->ioh->cmd_len); acb->task->expxferlen = acb->ioh->dxfer_len; data.size = 0; if (acb->task->xfer_dir == SCSI_XFER_WRITE) { if (acb->ioh->iovec_count == 0) { data.data = acb->ioh->dxferp; data.size = acb->ioh->dxfer_len; } else { #if defined(LIBISCSI_FEATURE_IOVECTOR) scsi_task_set_iov_out(acb->task, (struct scsi_iovec *) acb->ioh->dxferp, acb->ioh->iovec_count); #else struct iovec *iov = (struct iovec *)acb->ioh->dxferp; acb->buf = g_malloc(acb->ioh->dxfer_len); data.data = acb->buf; data.size = iov_to_buf(iov, acb->ioh->iovec_count, 0, acb->buf, acb->ioh->dxfer_len); #endif } } if (iscsi_scsi_command_async(iscsi, iscsilun->lun, acb->task, iscsi_aio_ioctl_cb, (data.size > 0) ? &data : NULL, acb) != 0) { scsi_free_scsi_task(acb->task); qemu_aio_release(acb); return NULL; } /* tell libiscsi to read straight into the buffer we got from ioctl */ if (acb->task->xfer_dir == SCSI_XFER_READ) { if (acb->ioh->iovec_count == 0) { scsi_task_add_data_in_buffer(acb->task, acb->ioh->dxfer_len, acb->ioh->dxferp); } else { #if defined(LIBISCSI_FEATURE_IOVECTOR) scsi_task_set_iov_in(acb->task, (struct scsi_iovec *) acb->ioh->dxferp, acb->ioh->iovec_count); #else int i; for (i = 0; i < acb->ioh->iovec_count; i++) { struct iovec *iov = (struct iovec *)acb->ioh->dxferp; scsi_task_add_data_in_buffer(acb->task, iov[i].iov_len, iov[i].iov_base); } #endif } } iscsi_set_events(iscsilun); return &acb->common; }
true
qemu
e49ab19fcaa617ad6cdfe1ac401327326b6a2552
static BlockDriverAIOCB *iscsi_aio_ioctl(BlockDriverState *bs, unsigned long int req, void *buf, BlockDriverCompletionFunc *cb, void *opaque) { IscsiLun *iscsilun = bs->opaque; struct iscsi_context *iscsi = iscsilun->iscsi; struct iscsi_data data; IscsiAIOCB *acb; assert(req == SG_IO); acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque); acb->iscsilun = iscsilun; acb->canceled = 0; acb->bh = NULL; acb->status = -EINPROGRESS; acb->buf = NULL; acb->ioh = buf; acb->task = malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { error_report("iSCSI: Failed to allocate task for scsi command. %s", iscsi_get_error(iscsi)); qemu_aio_release(acb); return NULL; } memset(acb->task, 0, sizeof(struct scsi_task)); switch (acb->ioh->dxfer_direction) { case SG_DXFER_TO_DEV: acb->task->xfer_dir = SCSI_XFER_WRITE; break; case SG_DXFER_FROM_DEV: acb->task->xfer_dir = SCSI_XFER_READ; break; default: acb->task->xfer_dir = SCSI_XFER_NONE; break; } acb->task->cdb_size = acb->ioh->cmd_len; memcpy(&acb->task->cdb[0], acb->ioh->cmdp, acb->ioh->cmd_len); acb->task->expxferlen = acb->ioh->dxfer_len; data.size = 0; if (acb->task->xfer_dir == SCSI_XFER_WRITE) { if (acb->ioh->iovec_count == 0) { data.data = acb->ioh->dxferp; data.size = acb->ioh->dxfer_len; } else { #if defined(LIBISCSI_FEATURE_IOVECTOR) scsi_task_set_iov_out(acb->task, (struct scsi_iovec *) acb->ioh->dxferp, acb->ioh->iovec_count); #else struct iovec *iov = (struct iovec *)acb->ioh->dxferp; acb->buf = g_malloc(acb->ioh->dxfer_len); data.data = acb->buf; data.size = iov_to_buf(iov, acb->ioh->iovec_count, 0, acb->buf, acb->ioh->dxfer_len); #endif } } if (iscsi_scsi_command_async(iscsi, iscsilun->lun, acb->task, iscsi_aio_ioctl_cb, (data.size > 0) ? &data : NULL, acb) != 0) { scsi_free_scsi_task(acb->task); qemu_aio_release(acb); return NULL; } if (acb->task->xfer_dir == SCSI_XFER_READ) { if (acb->ioh->iovec_count == 0) { scsi_task_add_data_in_buffer(acb->task, acb->ioh->dxfer_len, acb->ioh->dxferp); } else { #if defined(LIBISCSI_FEATURE_IOVECTOR) scsi_task_set_iov_in(acb->task, (struct scsi_iovec *) acb->ioh->dxferp, acb->ioh->iovec_count); #else int i; for (i = 0; i < acb->ioh->iovec_count; i++) { struct iovec *iov = (struct iovec *)acb->ioh->dxferp; scsi_task_add_data_in_buffer(acb->task, iov[i].iov_len, iov[i].iov_base); } #endif } } iscsi_set_events(iscsilun); return &acb->common; }
{ "code": [ "#endif", "#if defined(LIBISCSI_FEATURE_IOVECTOR)", "#endif", "#if defined(LIBISCSI_FEATURE_IOVECTOR)", "#endif", "#if defined(LIBISCSI_FEATURE_IOVECTOR)", "#endif", "#endif", "#if defined(LIBISCSI_FEATURE_IOVECTOR)", "#else", "#endif", "#if defined(LIBISCSI_FEATURE_IOVECTOR)", "#else", " struct iovec *iov = (struct iovec *)acb->ioh->dxferp;", " acb->buf = g_malloc(acb->ioh->dxfer_len);", " data.data = acb->buf;", " data.size = iov_to_buf(iov, acb->ioh->iovec_count, 0,", " acb->buf, acb->ioh->dxfer_len);", "#endif", "#if defined(LIBISCSI_FEATURE_IOVECTOR)", "#else", " int i;", " for (i = 0; i < acb->ioh->iovec_count; i++) {", " struct iovec *iov = (struct iovec *)acb->ioh->dxferp;", " scsi_task_add_data_in_buffer(acb->task,", " iov[i].iov_len,", " iov[i].iov_base);", "#endif", "#endif", "#endif", "#if defined(LIBISCSI_FEATURE_IOVECTOR)", "#endif", "#if defined(LIBISCSI_FEATURE_IOVECTOR)", "#endif", "#endif" ], "line_no": [ 125, 103, 125, 103, 125, 103, 125, 125, 103, 111, 125, 103, 111, 113, 117, 119, 121, 123, 125, 103, 111, 175, 177, 179, 183, 185, 187, 125, 125, 125, 103, 125, 103, 125, 125 ] }
static BlockDriverAIOCB *FUNC_0(BlockDriverState *bs, unsigned long int req, void *buf, BlockDriverCompletionFunc *cb, void *opaque) { IscsiLun *iscsilun = bs->opaque; struct iscsi_context *VAR_0 = iscsilun->VAR_0; struct iscsi_data VAR_1; IscsiAIOCB *acb; assert(req == SG_IO); acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque); acb->iscsilun = iscsilun; acb->canceled = 0; acb->bh = NULL; acb->status = -EINPROGRESS; acb->buf = NULL; acb->ioh = buf; acb->task = malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { error_report("iSCSI: Failed to allocate task for scsi command. %s", iscsi_get_error(VAR_0)); qemu_aio_release(acb); return NULL; } memset(acb->task, 0, sizeof(struct scsi_task)); switch (acb->ioh->dxfer_direction) { case SG_DXFER_TO_DEV: acb->task->xfer_dir = SCSI_XFER_WRITE; break; case SG_DXFER_FROM_DEV: acb->task->xfer_dir = SCSI_XFER_READ; break; default: acb->task->xfer_dir = SCSI_XFER_NONE; break; } acb->task->cdb_size = acb->ioh->cmd_len; memcpy(&acb->task->cdb[0], acb->ioh->cmdp, acb->ioh->cmd_len); acb->task->expxferlen = acb->ioh->dxfer_len; VAR_1.size = 0; if (acb->task->xfer_dir == SCSI_XFER_WRITE) { if (acb->ioh->iovec_count == 0) { VAR_1.VAR_1 = acb->ioh->dxferp; VAR_1.size = acb->ioh->dxfer_len; } else { #if defined(LIBISCSI_FEATURE_IOVECTOR) scsi_task_set_iov_out(acb->task, (struct scsi_iovec *) acb->ioh->dxferp, acb->ioh->iovec_count); #else struct iovec *VAR_2 = (struct iovec *)acb->ioh->dxferp; acb->buf = g_malloc(acb->ioh->dxfer_len); VAR_1.VAR_1 = acb->buf; VAR_1.size = iov_to_buf(VAR_2, acb->ioh->iovec_count, 0, acb->buf, acb->ioh->dxfer_len); #endif } } if (iscsi_scsi_command_async(VAR_0, iscsilun->lun, acb->task, iscsi_aio_ioctl_cb, (VAR_1.size > 0) ? &VAR_1 : NULL, acb) != 0) { scsi_free_scsi_task(acb->task); qemu_aio_release(acb); return NULL; } if (acb->task->xfer_dir == SCSI_XFER_READ) { if (acb->ioh->iovec_count == 0) { scsi_task_add_data_in_buffer(acb->task, acb->ioh->dxfer_len, acb->ioh->dxferp); } else { #if defined(LIBISCSI_FEATURE_IOVECTOR) scsi_task_set_iov_in(acb->task, (struct scsi_iovec *) acb->ioh->dxferp, acb->ioh->iovec_count); #else int VAR_3; for (VAR_3 = 0; VAR_3 < acb->ioh->iovec_count; VAR_3++) { struct iovec *VAR_2 = (struct iovec *)acb->ioh->dxferp; scsi_task_add_data_in_buffer(acb->task, VAR_2[VAR_3].iov_len, VAR_2[VAR_3].iov_base); } #endif } } iscsi_set_events(iscsilun); return &acb->common; }
[ "static BlockDriverAIOCB *FUNC_0(BlockDriverState *bs,\nunsigned long int req, void *buf,\nBlockDriverCompletionFunc *cb, void *opaque)\n{", "IscsiLun *iscsilun = bs->opaque;", "struct iscsi_context *VAR_0 = iscsilun->VAR_0;", "struct iscsi_data VAR_1;", "IscsiAIOCB *acb;", "assert(req == SG_IO);", "acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque);", "acb->iscsilun = iscsilun;", "acb->canceled = 0;", "acb->bh = NULL;", "acb->status = -EINPROGRESS;", "acb->buf = NULL;", "acb->ioh = buf;", "acb->task = malloc(sizeof(struct scsi_task));", "if (acb->task == NULL) {", "error_report(\"iSCSI: Failed to allocate task for scsi command. %s\",\niscsi_get_error(VAR_0));", "qemu_aio_release(acb);", "return NULL;", "}", "memset(acb->task, 0, sizeof(struct scsi_task));", "switch (acb->ioh->dxfer_direction) {", "case SG_DXFER_TO_DEV:\nacb->task->xfer_dir = SCSI_XFER_WRITE;", "break;", "case SG_DXFER_FROM_DEV:\nacb->task->xfer_dir = SCSI_XFER_READ;", "break;", "default:\nacb->task->xfer_dir = SCSI_XFER_NONE;", "break;", "}", "acb->task->cdb_size = acb->ioh->cmd_len;", "memcpy(&acb->task->cdb[0], acb->ioh->cmdp, acb->ioh->cmd_len);", "acb->task->expxferlen = acb->ioh->dxfer_len;", "VAR_1.size = 0;", "if (acb->task->xfer_dir == SCSI_XFER_WRITE) {", "if (acb->ioh->iovec_count == 0) {", "VAR_1.VAR_1 = acb->ioh->dxferp;", "VAR_1.size = acb->ioh->dxfer_len;", "} else {", "#if defined(LIBISCSI_FEATURE_IOVECTOR)\nscsi_task_set_iov_out(acb->task,\n(struct scsi_iovec *) acb->ioh->dxferp,\nacb->ioh->iovec_count);", "#else\nstruct iovec *VAR_2 = (struct iovec *)acb->ioh->dxferp;", "acb->buf = g_malloc(acb->ioh->dxfer_len);", "VAR_1.VAR_1 = acb->buf;", "VAR_1.size = iov_to_buf(VAR_2, acb->ioh->iovec_count, 0,\nacb->buf, acb->ioh->dxfer_len);", "#endif\n}", "}", "if (iscsi_scsi_command_async(VAR_0, iscsilun->lun, acb->task,\niscsi_aio_ioctl_cb,\n(VAR_1.size > 0) ? &VAR_1 : NULL,\nacb) != 0) {", "scsi_free_scsi_task(acb->task);", "qemu_aio_release(acb);", "return NULL;", "}", "if (acb->task->xfer_dir == SCSI_XFER_READ) {", "if (acb->ioh->iovec_count == 0) {", "scsi_task_add_data_in_buffer(acb->task,\nacb->ioh->dxfer_len,\nacb->ioh->dxferp);", "} else {", "#if defined(LIBISCSI_FEATURE_IOVECTOR)\nscsi_task_set_iov_in(acb->task,\n(struct scsi_iovec *) acb->ioh->dxferp,\nacb->ioh->iovec_count);", "#else\nint VAR_3;", "for (VAR_3 = 0; VAR_3 < acb->ioh->iovec_count; VAR_3++) {", "struct iovec *VAR_2 = (struct iovec *)acb->ioh->dxferp;", "scsi_task_add_data_in_buffer(acb->task,\nVAR_2[VAR_3].iov_len,\nVAR_2[VAR_3].iov_base);", "}", "#endif\n}", "}", "iscsi_set_events(iscsilun);", "return &acb->common;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61, 63 ], [ 65 ], [ 67, 69 ], [ 71 ], [ 73, 75 ], [ 77 ], [ 79 ], [ 83 ], [ 85 ], [ 87 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103, 105, 107, 109 ], [ 111, 113 ], [ 117 ], [ 119 ], [ 121, 123 ], [ 125, 127 ], [ 129 ], [ 133, 135, 137, 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 153 ], [ 155 ], [ 157, 159, 161 ], [ 163 ], [ 165, 167, 169, 171 ], [ 173, 175 ], [ 177 ], [ 179 ], [ 183, 185, 187 ], [ 189 ], [ 191, 193 ], [ 195 ], [ 199 ], [ 203 ], [ 205 ] ]
738
static void esp_pci_dma_memory_rw(PCIESPState *pci, uint8_t *buf, int len, DMADirection dir) { dma_addr_t addr; DMADirection expected_dir; if (pci->dma_regs[DMA_CMD] & DMA_CMD_DIR) { expected_dir = DMA_DIRECTION_FROM_DEVICE; } else { expected_dir = DMA_DIRECTION_TO_DEVICE; } if (dir != expected_dir) { trace_esp_pci_error_invalid_dma_direction(); return; } if (pci->dma_regs[DMA_STAT] & DMA_CMD_MDL) { qemu_log_mask(LOG_UNIMP, "am53c974: MDL transfer not implemented\n"); } addr = pci->dma_regs[DMA_SPA]; if (pci->dma_regs[DMA_WBC] < len) { len = pci->dma_regs[DMA_WBC]; } pci_dma_rw(PCI_DEVICE(pci), addr, buf, len, dir); /* update status registers */ pci->dma_regs[DMA_WBC] -= len; pci->dma_regs[DMA_WAC] += len; }
true
qemu
c3543fb5fe4520f03dd4fef04fab7745eeca1c96
static void esp_pci_dma_memory_rw(PCIESPState *pci, uint8_t *buf, int len, DMADirection dir) { dma_addr_t addr; DMADirection expected_dir; if (pci->dma_regs[DMA_CMD] & DMA_CMD_DIR) { expected_dir = DMA_DIRECTION_FROM_DEVICE; } else { expected_dir = DMA_DIRECTION_TO_DEVICE; } if (dir != expected_dir) { trace_esp_pci_error_invalid_dma_direction(); return; } if (pci->dma_regs[DMA_STAT] & DMA_CMD_MDL) { qemu_log_mask(LOG_UNIMP, "am53c974: MDL transfer not implemented\n"); } addr = pci->dma_regs[DMA_SPA]; if (pci->dma_regs[DMA_WBC] < len) { len = pci->dma_regs[DMA_WBC]; } pci_dma_rw(PCI_DEVICE(pci), addr, buf, len, dir); pci->dma_regs[DMA_WBC] -= len; pci->dma_regs[DMA_WAC] += len; }
{ "code": [], "line_no": [] }
static void FUNC_0(PCIESPState *VAR_0, uint8_t *VAR_1, int VAR_2, DMADirection VAR_3) { dma_addr_t addr; DMADirection expected_dir; if (VAR_0->dma_regs[DMA_CMD] & DMA_CMD_DIR) { expected_dir = DMA_DIRECTION_FROM_DEVICE; } else { expected_dir = DMA_DIRECTION_TO_DEVICE; } if (VAR_3 != expected_dir) { trace_esp_pci_error_invalid_dma_direction(); return; } if (VAR_0->dma_regs[DMA_STAT] & DMA_CMD_MDL) { qemu_log_mask(LOG_UNIMP, "am53c974: MDL transfer not implemented\n"); } addr = VAR_0->dma_regs[DMA_SPA]; if (VAR_0->dma_regs[DMA_WBC] < VAR_2) { VAR_2 = VAR_0->dma_regs[DMA_WBC]; } pci_dma_rw(PCI_DEVICE(VAR_0), addr, VAR_1, VAR_2, VAR_3); VAR_0->dma_regs[DMA_WBC] -= VAR_2; VAR_0->dma_regs[DMA_WAC] += VAR_2; }
[ "static void FUNC_0(PCIESPState *VAR_0, uint8_t *VAR_1, int VAR_2,\nDMADirection VAR_3)\n{", "dma_addr_t addr;", "DMADirection expected_dir;", "if (VAR_0->dma_regs[DMA_CMD] & DMA_CMD_DIR) {", "expected_dir = DMA_DIRECTION_FROM_DEVICE;", "} else {", "expected_dir = DMA_DIRECTION_TO_DEVICE;", "}", "if (VAR_3 != expected_dir) {", "trace_esp_pci_error_invalid_dma_direction();", "return;", "}", "if (VAR_0->dma_regs[DMA_STAT] & DMA_CMD_MDL) {", "qemu_log_mask(LOG_UNIMP, \"am53c974: MDL transfer not implemented\\n\");", "}", "addr = VAR_0->dma_regs[DMA_SPA];", "if (VAR_0->dma_regs[DMA_WBC] < VAR_2) {", "VAR_2 = VAR_0->dma_regs[DMA_WBC];", "}", "pci_dma_rw(PCI_DEVICE(VAR_0), addr, VAR_1, VAR_2, VAR_3);", "VAR_0->dma_regs[DMA_WBC] -= VAR_2;", "VAR_0->dma_regs[DMA_WAC] += 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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 59 ], [ 61 ], [ 65 ] ]
739
void qemu_fflush(QEMUFile *f) { ssize_t ret = 0; if (!qemu_file_is_writable(f)) { return; } if (f->ops->writev_buffer) { if (f->iovcnt > 0) { ret = f->ops->writev_buffer(f->opaque, f->iov, f->iovcnt, f->pos); } } else { if (f->buf_index > 0) { ret = f->ops->put_buffer(f->opaque, f->buf, f->pos, f->buf_index); } } if (ret >= 0) { f->pos += ret; } f->buf_index = 0; f->iovcnt = 0; if (ret < 0) { qemu_file_set_error(f, ret); } }
true
qemu
60fe637bf0e4d7989e21e50f52526444765c63b4
void qemu_fflush(QEMUFile *f) { ssize_t ret = 0; if (!qemu_file_is_writable(f)) { return; } if (f->ops->writev_buffer) { if (f->iovcnt > 0) { ret = f->ops->writev_buffer(f->opaque, f->iov, f->iovcnt, f->pos); } } else { if (f->buf_index > 0) { ret = f->ops->put_buffer(f->opaque, f->buf, f->pos, f->buf_index); } } if (ret >= 0) { f->pos += ret; } f->buf_index = 0; f->iovcnt = 0; if (ret < 0) { qemu_file_set_error(f, ret); } }
{ "code": [], "line_no": [] }
void FUNC_0(QEMUFile *VAR_0) { ssize_t ret = 0; if (!qemu_file_is_writable(VAR_0)) { return; } if (VAR_0->ops->writev_buffer) { if (VAR_0->iovcnt > 0) { ret = VAR_0->ops->writev_buffer(VAR_0->opaque, VAR_0->iov, VAR_0->iovcnt, VAR_0->pos); } } else { if (VAR_0->buf_index > 0) { ret = VAR_0->ops->put_buffer(VAR_0->opaque, VAR_0->buf, VAR_0->pos, VAR_0->buf_index); } } if (ret >= 0) { VAR_0->pos += ret; } VAR_0->buf_index = 0; VAR_0->iovcnt = 0; if (ret < 0) { qemu_file_set_error(VAR_0, ret); } }
[ "void FUNC_0(QEMUFile *VAR_0)\n{", "ssize_t ret = 0;", "if (!qemu_file_is_writable(VAR_0)) {", "return;", "}", "if (VAR_0->ops->writev_buffer) {", "if (VAR_0->iovcnt > 0) {", "ret = VAR_0->ops->writev_buffer(VAR_0->opaque, VAR_0->iov, VAR_0->iovcnt, VAR_0->pos);", "}", "} else {", "if (VAR_0->buf_index > 0) {", "ret = VAR_0->ops->put_buffer(VAR_0->opaque, VAR_0->buf, VAR_0->pos, VAR_0->buf_index);", "}", "}", "if (ret >= 0) {", "VAR_0->pos += ret;", "}", "VAR_0->buf_index = 0;", "VAR_0->iovcnt = 0;", "if (ret < 0) {", "qemu_file_set_error(VAR_0, ret);", "}", "}" ]
[ 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 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ] ]