id
int32
0
27.3k
func
stringlengths
26
142k
target
bool
2 classes
project
stringclasses
2 values
commit_id
stringlengths
40
40
func_clean
stringlengths
26
131k
vul_lines
dict
normalized_func
stringlengths
24
132k
lines
listlengths
1
2.8k
label
listlengths
1
2.8k
line_no
listlengths
1
2.8k
6,084
static void memory_region_iorange_write(IORange *iorange, uint64_t offset, unsigned width, uint64_t data) { MemoryRegionIORange *mrio = container_of(iorange, MemoryRegionIORange, iorange); MemoryRegion *mr = mrio->mr; offset += mrio->offset; if (mr->ops->old_portio) { const MemoryRegionPortio *mrp = find_portio(mr, offset - mrio->offset, width, true); if (mrp) { mrp->write(mr->opaque, offset, data); } else if (width == 2) { mrp = find_portio(mr, offset - mrio->offset, 1, true); assert(mrp); mrp->write(mr->opaque, offset, data & 0xff); mrp->write(mr->opaque, offset + 1, data >> 8); } return; } access_with_adjusted_size(offset, &data, width, mr->ops->impl.min_access_size, mr->ops->impl.max_access_size, memory_region_write_accessor, mr); }
false
qemu
b40acf99bef69fa8ab0f9092ff162fde945eec12
static void memory_region_iorange_write(IORange *iorange, uint64_t offset, unsigned width, uint64_t data) { MemoryRegionIORange *mrio = container_of(iorange, MemoryRegionIORange, iorange); MemoryRegion *mr = mrio->mr; offset += mrio->offset; if (mr->ops->old_portio) { const MemoryRegionPortio *mrp = find_portio(mr, offset - mrio->offset, width, true); if (mrp) { mrp->write(mr->opaque, offset, data); } else if (width == 2) { mrp = find_portio(mr, offset - mrio->offset, 1, true); assert(mrp); mrp->write(mr->opaque, offset, data & 0xff); mrp->write(mr->opaque, offset + 1, data >> 8); } return; } access_with_adjusted_size(offset, &data, width, mr->ops->impl.min_access_size, mr->ops->impl.max_access_size, memory_region_write_accessor, mr); }
{ "code": [], "line_no": [] }
static void FUNC_0(IORange *VAR_0, uint64_t VAR_1, unsigned VAR_2, uint64_t VAR_3) { MemoryRegionIORange *mrio = container_of(VAR_0, MemoryRegionIORange, VAR_0); MemoryRegion *mr = mrio->mr; VAR_1 += mrio->VAR_1; if (mr->ops->old_portio) { const MemoryRegionPortio *VAR_4 = find_portio(mr, VAR_1 - mrio->VAR_1, VAR_2, true); if (VAR_4) { VAR_4->write(mr->opaque, VAR_1, VAR_3); } else if (VAR_2 == 2) { VAR_4 = find_portio(mr, VAR_1 - mrio->VAR_1, 1, true); assert(VAR_4); VAR_4->write(mr->opaque, VAR_1, VAR_3 & 0xff); VAR_4->write(mr->opaque, VAR_1 + 1, VAR_3 >> 8); } return; } access_with_adjusted_size(VAR_1, &VAR_3, VAR_2, mr->ops->impl.min_access_size, mr->ops->impl.max_access_size, memory_region_write_accessor, mr); }
[ "static void FUNC_0(IORange *VAR_0,\nuint64_t VAR_1,\nunsigned VAR_2,\nuint64_t VAR_3)\n{", "MemoryRegionIORange *mrio\n= container_of(VAR_0, MemoryRegionIORange, VAR_0);", "MemoryRegion *mr = mrio->mr;", "VAR_1 += mrio->VAR_1;", "if (mr->ops->old_portio) {", "const MemoryRegionPortio *VAR_4 = find_portio(mr, VAR_1 - mrio->VAR_1,\nVAR_2, true);", "if (VAR_4) {", "VAR_4->write(mr->opaque, VAR_1, VAR_3);", "} else if (VAR_2 == 2) {", "VAR_4 = find_portio(mr, VAR_1 - mrio->VAR_1, 1, true);", "assert(VAR_4);", "VAR_4->write(mr->opaque, VAR_1, VAR_3 & 0xff);", "VAR_4->write(mr->opaque, VAR_1 + 1, VAR_3 >> 8);", "}", "return;", "}", "access_with_adjusted_size(VAR_1, &VAR_3, VAR_2,\nmr->ops->impl.min_access_size,\nmr->ops->impl.max_access_size,\nmemory_region_write_accessor, mr);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11, 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23, 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49, 51, 53, 55 ], [ 57 ] ]
6,085
int msi_init(struct PCIDevice *dev, uint8_t offset, unsigned int nr_vectors, bool msi64bit, bool msi_per_vector_mask) { unsigned int vectors_order; uint16_t flags; uint8_t cap_size; int config_offset; if (!msi_supported) { return -ENOTSUP; } MSI_DEV_PRINTF(dev, "init offset: 0x%"PRIx8" vector: %"PRId8 " 64bit %d mask %d\n", offset, nr_vectors, msi64bit, msi_per_vector_mask); assert(!(nr_vectors & (nr_vectors - 1))); /* power of 2 */ assert(nr_vectors > 0); assert(nr_vectors <= PCI_MSI_VECTORS_MAX); /* the nr of MSI vectors is up to 32 */ vectors_order = ffs(nr_vectors) - 1; flags = vectors_order << (ffs(PCI_MSI_FLAGS_QMASK) - 1); if (msi64bit) { flags |= PCI_MSI_FLAGS_64BIT; } if (msi_per_vector_mask) { flags |= PCI_MSI_FLAGS_MASKBIT; } cap_size = msi_cap_sizeof(flags); config_offset = pci_add_capability(dev, PCI_CAP_ID_MSI, offset, cap_size); if (config_offset < 0) { return config_offset; } dev->msi_cap = config_offset; dev->cap_present |= QEMU_PCI_CAP_MSI; pci_set_word(dev->config + msi_flags_off(dev), flags); pci_set_word(dev->wmask + msi_flags_off(dev), PCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE); pci_set_long(dev->wmask + msi_address_lo_off(dev), PCI_MSI_ADDRESS_LO_MASK); if (msi64bit) { pci_set_long(dev->wmask + msi_address_hi_off(dev), 0xffffffff); } pci_set_word(dev->wmask + msi_data_off(dev, msi64bit), 0xffff); if (msi_per_vector_mask) { /* Make mask bits 0 to nr_vectors - 1 writable. */ pci_set_long(dev->wmask + msi_mask_off(dev, msi64bit), 0xffffffff >> (PCI_MSI_VECTORS_MAX - nr_vectors)); } return config_offset; }
false
qemu
786a4ea82ec9c87e3a895cf41081029b285a5fe5
int msi_init(struct PCIDevice *dev, uint8_t offset, unsigned int nr_vectors, bool msi64bit, bool msi_per_vector_mask) { unsigned int vectors_order; uint16_t flags; uint8_t cap_size; int config_offset; if (!msi_supported) { return -ENOTSUP; } MSI_DEV_PRINTF(dev, "init offset: 0x%"PRIx8" vector: %"PRId8 " 64bit %d mask %d\n", offset, nr_vectors, msi64bit, msi_per_vector_mask); assert(!(nr_vectors & (nr_vectors - 1))); assert(nr_vectors > 0); assert(nr_vectors <= PCI_MSI_VECTORS_MAX); vectors_order = ffs(nr_vectors) - 1; flags = vectors_order << (ffs(PCI_MSI_FLAGS_QMASK) - 1); if (msi64bit) { flags |= PCI_MSI_FLAGS_64BIT; } if (msi_per_vector_mask) { flags |= PCI_MSI_FLAGS_MASKBIT; } cap_size = msi_cap_sizeof(flags); config_offset = pci_add_capability(dev, PCI_CAP_ID_MSI, offset, cap_size); if (config_offset < 0) { return config_offset; } dev->msi_cap = config_offset; dev->cap_present |= QEMU_PCI_CAP_MSI; pci_set_word(dev->config + msi_flags_off(dev), flags); pci_set_word(dev->wmask + msi_flags_off(dev), PCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE); pci_set_long(dev->wmask + msi_address_lo_off(dev), PCI_MSI_ADDRESS_LO_MASK); if (msi64bit) { pci_set_long(dev->wmask + msi_address_hi_off(dev), 0xffffffff); } pci_set_word(dev->wmask + msi_data_off(dev, msi64bit), 0xffff); if (msi_per_vector_mask) { pci_set_long(dev->wmask + msi_mask_off(dev, msi64bit), 0xffffffff >> (PCI_MSI_VECTORS_MAX - nr_vectors)); } return config_offset; }
{ "code": [], "line_no": [] }
int FUNC_0(struct PCIDevice *VAR_0, uint8_t VAR_1, unsigned int VAR_2, bool VAR_3, bool VAR_4) { unsigned int VAR_5; uint16_t flags; uint8_t cap_size; int VAR_6; if (!msi_supported) { return -ENOTSUP; } MSI_DEV_PRINTF(VAR_0, "init VAR_1: 0x%"PRIx8" vector: %"PRId8 " 64bit %d mask %d\n", VAR_1, VAR_2, VAR_3, VAR_4); assert(!(VAR_2 & (VAR_2 - 1))); assert(VAR_2 > 0); assert(VAR_2 <= PCI_MSI_VECTORS_MAX); VAR_5 = ffs(VAR_2) - 1; flags = VAR_5 << (ffs(PCI_MSI_FLAGS_QMASK) - 1); if (VAR_3) { flags |= PCI_MSI_FLAGS_64BIT; } if (VAR_4) { flags |= PCI_MSI_FLAGS_MASKBIT; } cap_size = msi_cap_sizeof(flags); VAR_6 = pci_add_capability(VAR_0, PCI_CAP_ID_MSI, VAR_1, cap_size); if (VAR_6 < 0) { return VAR_6; } VAR_0->msi_cap = VAR_6; VAR_0->cap_present |= QEMU_PCI_CAP_MSI; pci_set_word(VAR_0->config + msi_flags_off(VAR_0), flags); pci_set_word(VAR_0->wmask + msi_flags_off(VAR_0), PCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE); pci_set_long(VAR_0->wmask + msi_address_lo_off(VAR_0), PCI_MSI_ADDRESS_LO_MASK); if (VAR_3) { pci_set_long(VAR_0->wmask + msi_address_hi_off(VAR_0), 0xffffffff); } pci_set_word(VAR_0->wmask + msi_data_off(VAR_0, VAR_3), 0xffff); if (VAR_4) { pci_set_long(VAR_0->wmask + msi_mask_off(VAR_0, VAR_3), 0xffffffff >> (PCI_MSI_VECTORS_MAX - VAR_2)); } return VAR_6; }
[ "int FUNC_0(struct PCIDevice *VAR_0, uint8_t VAR_1,\nunsigned int VAR_2, bool VAR_3, bool VAR_4)\n{", "unsigned int VAR_5;", "uint16_t flags;", "uint8_t cap_size;", "int VAR_6;", "if (!msi_supported) {", "return -ENOTSUP;", "}", "MSI_DEV_PRINTF(VAR_0,\n\"init VAR_1: 0x%\"PRIx8\" vector: %\"PRId8\n\" 64bit %d mask %d\\n\",\nVAR_1, VAR_2, VAR_3, VAR_4);", "assert(!(VAR_2 & (VAR_2 - 1)));", "assert(VAR_2 > 0);", "assert(VAR_2 <= PCI_MSI_VECTORS_MAX);", "VAR_5 = ffs(VAR_2) - 1;", "flags = VAR_5 << (ffs(PCI_MSI_FLAGS_QMASK) - 1);", "if (VAR_3) {", "flags |= PCI_MSI_FLAGS_64BIT;", "}", "if (VAR_4) {", "flags |= PCI_MSI_FLAGS_MASKBIT;", "}", "cap_size = msi_cap_sizeof(flags);", "VAR_6 = pci_add_capability(VAR_0, PCI_CAP_ID_MSI, VAR_1, cap_size);", "if (VAR_6 < 0) {", "return VAR_6;", "}", "VAR_0->msi_cap = VAR_6;", "VAR_0->cap_present |= QEMU_PCI_CAP_MSI;", "pci_set_word(VAR_0->config + msi_flags_off(VAR_0), flags);", "pci_set_word(VAR_0->wmask + msi_flags_off(VAR_0),\nPCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE);", "pci_set_long(VAR_0->wmask + msi_address_lo_off(VAR_0),\nPCI_MSI_ADDRESS_LO_MASK);", "if (VAR_3) {", "pci_set_long(VAR_0->wmask + msi_address_hi_off(VAR_0), 0xffffffff);", "}", "pci_set_word(VAR_0->wmask + msi_data_off(VAR_0, VAR_3), 0xffff);", "if (VAR_4) {", "pci_set_long(VAR_0->wmask + msi_mask_off(VAR_0, VAR_3),\n0xffffffff >> (PCI_MSI_VECTORS_MAX - VAR_2));", "}", "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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 25, 27, 29, 31 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 81 ], [ 83, 85 ], [ 87, 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 101 ], [ 105, 107 ], [ 109 ], [ 111 ], [ 113 ] ]
6,086
static int mux_chr_write(CharDriverState *chr, const uint8_t *buf, int len) { MuxDriver *d = chr->opaque; int ret; if (!d->timestamps) { ret = d->drv->chr_write(d->drv, buf, len); } else { int i; ret = 0; for (i = 0; i < len; i++) { if (d->linestart) { char buf1[64]; int64_t ti; int secs; ti = qemu_get_clock(rt_clock); if (d->timestamps_start == -1) d->timestamps_start = ti; ti -= d->timestamps_start; secs = ti / 1000; snprintf(buf1, sizeof(buf1), "[%02d:%02d:%02d.%03d] ", secs / 3600, (secs / 60) % 60, secs % 60, (int)(ti % 1000)); d->drv->chr_write(d->drv, (uint8_t *)buf1, strlen(buf1)); d->linestart = 0; } ret += d->drv->chr_write(d->drv, buf+i, 1); if (buf[i] == '\n') { d->linestart = 1; } } } return ret; }
false
qemu
7bd427d801e1e3293a634d3c83beadaa90ffb911
static int mux_chr_write(CharDriverState *chr, const uint8_t *buf, int len) { MuxDriver *d = chr->opaque; int ret; if (!d->timestamps) { ret = d->drv->chr_write(d->drv, buf, len); } else { int i; ret = 0; for (i = 0; i < len; i++) { if (d->linestart) { char buf1[64]; int64_t ti; int secs; ti = qemu_get_clock(rt_clock); if (d->timestamps_start == -1) d->timestamps_start = ti; ti -= d->timestamps_start; secs = ti / 1000; snprintf(buf1, sizeof(buf1), "[%02d:%02d:%02d.%03d] ", secs / 3600, (secs / 60) % 60, secs % 60, (int)(ti % 1000)); d->drv->chr_write(d->drv, (uint8_t *)buf1, strlen(buf1)); d->linestart = 0; } ret += d->drv->chr_write(d->drv, buf+i, 1); if (buf[i] == '\n') { d->linestart = 1; } } } return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(CharDriverState *VAR_0, const uint8_t *VAR_1, int VAR_2) { MuxDriver *d = VAR_0->opaque; int VAR_3; if (!d->timestamps) { VAR_3 = d->drv->chr_write(d->drv, VAR_1, VAR_2); } else { int VAR_4; VAR_3 = 0; for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++) { if (d->linestart) { char VAR_5[64]; int64_t ti; int VAR_6; ti = qemu_get_clock(rt_clock); if (d->timestamps_start == -1) d->timestamps_start = ti; ti -= d->timestamps_start; VAR_6 = ti / 1000; snprintf(VAR_5, sizeof(VAR_5), "[%02d:%02d:%02d.%03d] ", VAR_6 / 3600, (VAR_6 / 60) % 60, VAR_6 % 60, (int)(ti % 1000)); d->drv->chr_write(d->drv, (uint8_t *)VAR_5, strlen(VAR_5)); d->linestart = 0; } VAR_3 += d->drv->chr_write(d->drv, VAR_1+VAR_4, 1); if (VAR_1[VAR_4] == '\n') { d->linestart = 1; } } } return VAR_3; }
[ "static int FUNC_0(CharDriverState *VAR_0, const uint8_t *VAR_1, int VAR_2)\n{", "MuxDriver *d = VAR_0->opaque;", "int VAR_3;", "if (!d->timestamps) {", "VAR_3 = d->drv->chr_write(d->drv, VAR_1, VAR_2);", "} else {", "int VAR_4;", "VAR_3 = 0;", "for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++) {", "if (d->linestart) {", "char VAR_5[64];", "int64_t ti;", "int VAR_6;", "ti = qemu_get_clock(rt_clock);", "if (d->timestamps_start == -1)\nd->timestamps_start = ti;", "ti -= d->timestamps_start;", "VAR_6 = ti / 1000;", "snprintf(VAR_5, sizeof(VAR_5),\n\"[%02d:%02d:%02d.%03d] \",\nVAR_6 / 3600,\n(VAR_6 / 60) % 60,\nVAR_6 % 60,\n(int)(ti % 1000));", "d->drv->chr_write(d->drv, (uint8_t *)VAR_5, strlen(VAR_5));", "d->linestart = 0;", "}", "VAR_3 += d->drv->chr_write(d->drv, VAR_1+VAR_4, 1);", "if (VAR_1[VAR_4] == '\\n') {", "d->linestart = 1;", "}", "}", "}", "return VAR_3;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35, 37 ], [ 39 ], [ 41 ], [ 43, 45, 47, 49, 51, 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ] ]
6,088
int qio_channel_socket_listen_sync(QIOChannelSocket *ioc, SocketAddress *addr, Error **errp) { int fd; trace_qio_channel_socket_listen_sync(ioc, addr); fd = socket_listen(addr, errp); if (fd < 0) { trace_qio_channel_socket_listen_fail(ioc); return -1; } trace_qio_channel_socket_listen_complete(ioc, fd); if (qio_channel_socket_set_fd(ioc, fd, errp) < 0) { close(fd); return -1; } qio_channel_set_feature(QIO_CHANNEL(ioc), QIO_CHANNEL_FEATURE_LISTEN); return 0; }
false
qemu
dfd100f242370886bb6732f70f1f7cbd8eb9fedc
int qio_channel_socket_listen_sync(QIOChannelSocket *ioc, SocketAddress *addr, Error **errp) { int fd; trace_qio_channel_socket_listen_sync(ioc, addr); fd = socket_listen(addr, errp); if (fd < 0) { trace_qio_channel_socket_listen_fail(ioc); return -1; } trace_qio_channel_socket_listen_complete(ioc, fd); if (qio_channel_socket_set_fd(ioc, fd, errp) < 0) { close(fd); return -1; } qio_channel_set_feature(QIO_CHANNEL(ioc), QIO_CHANNEL_FEATURE_LISTEN); return 0; }
{ "code": [], "line_no": [] }
int FUNC_0(QIOChannelSocket *VAR_0, SocketAddress *VAR_1, Error **VAR_2) { int VAR_3; trace_qio_channel_socket_listen_sync(VAR_0, VAR_1); VAR_3 = socket_listen(VAR_1, VAR_2); if (VAR_3 < 0) { trace_qio_channel_socket_listen_fail(VAR_0); return -1; } trace_qio_channel_socket_listen_complete(VAR_0, VAR_3); if (qio_channel_socket_set_fd(VAR_0, VAR_3, VAR_2) < 0) { close(VAR_3); return -1; } qio_channel_set_feature(QIO_CHANNEL(VAR_0), QIO_CHANNEL_FEATURE_LISTEN); return 0; }
[ "int FUNC_0(QIOChannelSocket *VAR_0,\nSocketAddress *VAR_1,\nError **VAR_2)\n{", "int VAR_3;", "trace_qio_channel_socket_listen_sync(VAR_0, VAR_1);", "VAR_3 = socket_listen(VAR_1, VAR_2);", "if (VAR_3 < 0) {", "trace_qio_channel_socket_listen_fail(VAR_0);", "return -1;", "}", "trace_qio_channel_socket_listen_complete(VAR_0, VAR_3);", "if (qio_channel_socket_set_fd(VAR_0, VAR_3, VAR_2) < 0) {", "close(VAR_3);", "return -1;", "}", "qio_channel_set_feature(QIO_CHANNEL(VAR_0), QIO_CHANNEL_FEATURE_LISTEN);", "return 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 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ] ]
6,089
static int rtc_post_load(void *opaque, int version_id) { RTCState *s = opaque; if (version_id <= 2 || rtc_clock == QEMU_CLOCK_REALTIME) { rtc_set_time(s); s->offset = 0; check_update_timer(s); } uint64_t now = qemu_clock_get_ns(rtc_clock); if (now < s->next_periodic_time || now > (s->next_periodic_time + get_max_clock_jump())) { periodic_timer_update(s, qemu_clock_get_ns(rtc_clock)); } #ifdef TARGET_I386 if (version_id >= 2) { if (s->lost_tick_policy == LOST_TICK_POLICY_SLEW) { rtc_coalesced_timer_update(s); } } #endif return 0; }
false
qemu
1dfb1b2d34840dce27e672f147bc4ef122abab74
static int rtc_post_load(void *opaque, int version_id) { RTCState *s = opaque; if (version_id <= 2 || rtc_clock == QEMU_CLOCK_REALTIME) { rtc_set_time(s); s->offset = 0; check_update_timer(s); } uint64_t now = qemu_clock_get_ns(rtc_clock); if (now < s->next_periodic_time || now > (s->next_periodic_time + get_max_clock_jump())) { periodic_timer_update(s, qemu_clock_get_ns(rtc_clock)); } #ifdef TARGET_I386 if (version_id >= 2) { if (s->lost_tick_policy == LOST_TICK_POLICY_SLEW) { rtc_coalesced_timer_update(s); } } #endif return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(void *VAR_0, int VAR_1) { RTCState *s = VAR_0; if (VAR_1 <= 2 || rtc_clock == QEMU_CLOCK_REALTIME) { rtc_set_time(s); s->offset = 0; check_update_timer(s); } uint64_t now = qemu_clock_get_ns(rtc_clock); if (now < s->next_periodic_time || now > (s->next_periodic_time + get_max_clock_jump())) { periodic_timer_update(s, qemu_clock_get_ns(rtc_clock)); } #ifdef TARGET_I386 if (VAR_1 >= 2) { if (s->lost_tick_policy == LOST_TICK_POLICY_SLEW) { rtc_coalesced_timer_update(s); } } #endif return 0; }
[ "static int FUNC_0(void *VAR_0, int VAR_1)\n{", "RTCState *s = VAR_0;", "if (VAR_1 <= 2 || rtc_clock == QEMU_CLOCK_REALTIME) {", "rtc_set_time(s);", "s->offset = 0;", "check_update_timer(s);", "}", "uint64_t now = qemu_clock_get_ns(rtc_clock);", "if (now < s->next_periodic_time ||\nnow > (s->next_periodic_time + get_max_clock_jump())) {", "periodic_timer_update(s, qemu_clock_get_ns(rtc_clock));", "}", "#ifdef TARGET_I386\nif (VAR_1 >= 2) {", "if (s->lost_tick_policy == LOST_TICK_POLICY_SLEW) {", "rtc_coalesced_timer_update(s);", "}", "}", "#endif\nreturn 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23, 25 ], [ 27 ], [ 29 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45, 47 ], [ 49 ] ]
6,090
static void virtio_serial_save_device(VirtIODevice *vdev, QEMUFile *f) { VirtIOSerial *s = VIRTIO_SERIAL(vdev); VirtIOSerialPort *port; uint32_t nr_active_ports; unsigned int i, max_nr_ports; struct virtio_console_config config; /* The config space (ignored on the far end in current versions) */ get_config(vdev, (uint8_t *)&config); qemu_put_be16s(f, &config.cols); qemu_put_be16s(f, &config.rows); qemu_put_be32s(f, &config.max_nr_ports); /* The ports map */ max_nr_ports = s->serial.max_virtserial_ports; for (i = 0; i < (max_nr_ports + 31) / 32; i++) { qemu_put_be32s(f, &s->ports_map[i]); } /* Ports */ nr_active_ports = 0; QTAILQ_FOREACH(port, &s->ports, next) { nr_active_ports++; } qemu_put_be32s(f, &nr_active_ports); /* * Items in struct VirtIOSerialPort. */ QTAILQ_FOREACH(port, &s->ports, next) { uint32_t elem_popped; qemu_put_be32s(f, &port->id); qemu_put_byte(f, port->guest_connected); qemu_put_byte(f, port->host_connected); elem_popped = 0; if (port->elem.out_num) { elem_popped = 1; } qemu_put_be32s(f, &elem_popped); if (elem_popped) { qemu_put_be32s(f, &port->iov_idx); qemu_put_be64s(f, &port->iov_offset); qemu_put_buffer(f, (unsigned char *)&port->elem, sizeof(port->elem)); } } }
false
qemu
51b19ebe4320f3dcd93cea71235c1219318ddfd2
static void virtio_serial_save_device(VirtIODevice *vdev, QEMUFile *f) { VirtIOSerial *s = VIRTIO_SERIAL(vdev); VirtIOSerialPort *port; uint32_t nr_active_ports; unsigned int i, max_nr_ports; struct virtio_console_config config; get_config(vdev, (uint8_t *)&config); qemu_put_be16s(f, &config.cols); qemu_put_be16s(f, &config.rows); qemu_put_be32s(f, &config.max_nr_ports); max_nr_ports = s->serial.max_virtserial_ports; for (i = 0; i < (max_nr_ports + 31) / 32; i++) { qemu_put_be32s(f, &s->ports_map[i]); } nr_active_ports = 0; QTAILQ_FOREACH(port, &s->ports, next) { nr_active_ports++; } qemu_put_be32s(f, &nr_active_ports); QTAILQ_FOREACH(port, &s->ports, next) { uint32_t elem_popped; qemu_put_be32s(f, &port->id); qemu_put_byte(f, port->guest_connected); qemu_put_byte(f, port->host_connected); elem_popped = 0; if (port->elem.out_num) { elem_popped = 1; } qemu_put_be32s(f, &elem_popped); if (elem_popped) { qemu_put_be32s(f, &port->iov_idx); qemu_put_be64s(f, &port->iov_offset); qemu_put_buffer(f, (unsigned char *)&port->elem, sizeof(port->elem)); } } }
{ "code": [], "line_no": [] }
static void FUNC_0(VirtIODevice *VAR_0, QEMUFile *VAR_1) { VirtIOSerial *s = VIRTIO_SERIAL(VAR_0); VirtIOSerialPort *port; uint32_t nr_active_ports; unsigned int VAR_2, VAR_3; struct virtio_console_config VAR_4; get_config(VAR_0, (uint8_t *)&VAR_4); qemu_put_be16s(VAR_1, &VAR_4.cols); qemu_put_be16s(VAR_1, &VAR_4.rows); qemu_put_be32s(VAR_1, &VAR_4.VAR_3); VAR_3 = s->serial.max_virtserial_ports; for (VAR_2 = 0; VAR_2 < (VAR_3 + 31) / 32; VAR_2++) { qemu_put_be32s(VAR_1, &s->ports_map[VAR_2]); } nr_active_ports = 0; QTAILQ_FOREACH(port, &s->ports, next) { nr_active_ports++; } qemu_put_be32s(VAR_1, &nr_active_ports); QTAILQ_FOREACH(port, &s->ports, next) { uint32_t elem_popped; qemu_put_be32s(VAR_1, &port->id); qemu_put_byte(VAR_1, port->guest_connected); qemu_put_byte(VAR_1, port->host_connected); elem_popped = 0; if (port->elem.out_num) { elem_popped = 1; } qemu_put_be32s(VAR_1, &elem_popped); if (elem_popped) { qemu_put_be32s(VAR_1, &port->iov_idx); qemu_put_be64s(VAR_1, &port->iov_offset); qemu_put_buffer(VAR_1, (unsigned char *)&port->elem, sizeof(port->elem)); } } }
[ "static void FUNC_0(VirtIODevice *VAR_0, QEMUFile *VAR_1)\n{", "VirtIOSerial *s = VIRTIO_SERIAL(VAR_0);", "VirtIOSerialPort *port;", "uint32_t nr_active_ports;", "unsigned int VAR_2, VAR_3;", "struct virtio_console_config VAR_4;", "get_config(VAR_0, (uint8_t *)&VAR_4);", "qemu_put_be16s(VAR_1, &VAR_4.cols);", "qemu_put_be16s(VAR_1, &VAR_4.rows);", "qemu_put_be32s(VAR_1, &VAR_4.VAR_3);", "VAR_3 = s->serial.max_virtserial_ports;", "for (VAR_2 = 0; VAR_2 < (VAR_3 + 31) / 32; VAR_2++) {", "qemu_put_be32s(VAR_1, &s->ports_map[VAR_2]);", "}", "nr_active_ports = 0;", "QTAILQ_FOREACH(port, &s->ports, next) {", "nr_active_ports++;", "}", "qemu_put_be32s(VAR_1, &nr_active_ports);", "QTAILQ_FOREACH(port, &s->ports, next) {", "uint32_t elem_popped;", "qemu_put_be32s(VAR_1, &port->id);", "qemu_put_byte(VAR_1, port->guest_connected);", "qemu_put_byte(VAR_1, port->host_connected);", "elem_popped = 0;", "if (port->elem.out_num) {", "elem_popped = 1;", "}", "qemu_put_be32s(VAR_1, &elem_popped);", "if (elem_popped) {", "qemu_put_be32s(VAR_1, &port->iov_idx);", "qemu_put_be64s(VAR_1, &port->iov_offset);", "qemu_put_buffer(VAR_1, (unsigned char *)&port->elem,\nsizeof(port->elem));", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 97, 99 ], [ 101 ], [ 103 ], [ 105 ] ]
6,091
static int init_directories(BDRVVVFATState* s, const char *dirname, int heads, int secs, Error **errp) { bootsector_t* bootsector; mapping_t* mapping; unsigned int i; unsigned int cluster; memset(&(s->first_sectors[0]),0,0x40*0x200); s->cluster_size=s->sectors_per_cluster*0x200; s->cluster_buffer=g_malloc(s->cluster_size); /* * The formula: sc = spf+1+spf*spc*(512*8/fat_type), * where sc is sector_count, * spf is sectors_per_fat, * spc is sectors_per_clusters, and * fat_type = 12, 16 or 32. */ i = 1+s->sectors_per_cluster*0x200*8/s->fat_type; s->sectors_per_fat=(s->sector_count+i)/i; /* round up */ array_init(&(s->mapping),sizeof(mapping_t)); array_init(&(s->directory),sizeof(direntry_t)); /* add volume label */ { direntry_t* entry=array_get_next(&(s->directory)); entry->attributes=0x28; /* archive | volume label */ memcpy(entry->name, "QEMU VVFAT ", sizeof(entry->name)); } /* Now build FAT, and write back information into directory */ init_fat(s); s->faked_sectors=s->first_sectors_number+s->sectors_per_fat*2; s->cluster_count=sector2cluster(s, s->sector_count); mapping = array_get_next(&(s->mapping)); mapping->begin = 0; mapping->dir_index = 0; mapping->info.dir.parent_mapping_index = -1; mapping->first_mapping_index = -1; mapping->path = g_strdup(dirname); i = strlen(mapping->path); if (i > 0 && mapping->path[i - 1] == '/') mapping->path[i - 1] = '\0'; mapping->mode = MODE_DIRECTORY; mapping->read_only = 0; s->path = mapping->path; for (i = 0, cluster = 0; i < s->mapping.next; i++) { /* MS-DOS expects the FAT to be 0 for the root directory * (except for the media byte). */ /* LATER TODO: still true for FAT32? */ int fix_fat = (i != 0); mapping = array_get(&(s->mapping), i); if (mapping->mode & MODE_DIRECTORY) { mapping->begin = cluster; if(read_directory(s, i)) { error_setg(errp, "Could not read directory %s", mapping->path); return -1; } mapping = array_get(&(s->mapping), i); } else { assert(mapping->mode == MODE_UNDEFINED); mapping->mode=MODE_NORMAL; mapping->begin = cluster; if (mapping->end > 0) { direntry_t* direntry = array_get(&(s->directory), mapping->dir_index); mapping->end = cluster + 1 + (mapping->end-1)/s->cluster_size; set_begin_of_direntry(direntry, mapping->begin); } else { mapping->end = cluster + 1; fix_fat = 0; } } assert(mapping->begin < mapping->end); /* next free cluster */ cluster = mapping->end; if(cluster > s->cluster_count) { error_setg(errp, "Directory does not fit in FAT%d (capacity %.2f MB)", s->fat_type, s->sector_count / 2000.0); return -1; } /* fix fat for entry */ if (fix_fat) { int j; for(j = mapping->begin; j < mapping->end - 1; j++) fat_set(s, j, j+1); fat_set(s, mapping->end - 1, s->max_fat_value); } } mapping = array_get(&(s->mapping), 0); s->sectors_of_root_directory = mapping->end * s->sectors_per_cluster; s->last_cluster_of_root_directory = mapping->end; /* the FAT signature */ fat_set(s,0,s->max_fat_value); fat_set(s,1,s->max_fat_value); s->current_mapping = NULL; bootsector=(bootsector_t*)(s->first_sectors+(s->first_sectors_number-1)*0x200); bootsector->jump[0]=0xeb; bootsector->jump[1]=0x3e; bootsector->jump[2]=0x90; memcpy(bootsector->name,"QEMU ",8); bootsector->sector_size=cpu_to_le16(0x200); bootsector->sectors_per_cluster=s->sectors_per_cluster; bootsector->reserved_sectors=cpu_to_le16(1); bootsector->number_of_fats=0x2; /* number of FATs */ bootsector->root_entries=cpu_to_le16(s->sectors_of_root_directory*0x10); bootsector->total_sectors16=s->sector_count>0xffff?0:cpu_to_le16(s->sector_count); bootsector->media_type=(s->first_sectors_number>1?0xf8:0xf0); /* media descriptor (f8=hd, f0=3.5 fd)*/ s->fat.pointer[0] = bootsector->media_type; bootsector->sectors_per_fat=cpu_to_le16(s->sectors_per_fat); bootsector->sectors_per_track = cpu_to_le16(secs); bootsector->number_of_heads = cpu_to_le16(heads); bootsector->hidden_sectors=cpu_to_le32(s->first_sectors_number==1?0:0x3f); bootsector->total_sectors=cpu_to_le32(s->sector_count>0xffff?s->sector_count:0); /* LATER TODO: if FAT32, this is wrong */ bootsector->u.fat16.drive_number=s->first_sectors_number==1?0:0x80; /* fda=0, hda=0x80 */ bootsector->u.fat16.current_head=0; bootsector->u.fat16.signature=0x29; bootsector->u.fat16.id=cpu_to_le32(0xfabe1afd); memcpy(bootsector->u.fat16.volume_label,"QEMU VVFAT ",11); memcpy(bootsector->fat_type,(s->fat_type==12?"FAT12 ":s->fat_type==16?"FAT16 ":"FAT32 "),8); bootsector->magic[0]=0x55; bootsector->magic[1]=0xaa; return 0; }
false
qemu
d5941ddae82a35771656d7e35f64f7f8f19c5627
static int init_directories(BDRVVVFATState* s, const char *dirname, int heads, int secs, Error **errp) { bootsector_t* bootsector; mapping_t* mapping; unsigned int i; unsigned int cluster; memset(&(s->first_sectors[0]),0,0x40*0x200); s->cluster_size=s->sectors_per_cluster*0x200; s->cluster_buffer=g_malloc(s->cluster_size); i = 1+s->sectors_per_cluster*0x200*8/s->fat_type; s->sectors_per_fat=(s->sector_count+i)/i; array_init(&(s->mapping),sizeof(mapping_t)); array_init(&(s->directory),sizeof(direntry_t)); { direntry_t* entry=array_get_next(&(s->directory)); entry->attributes=0x28; memcpy(entry->name, "QEMU VVFAT ", sizeof(entry->name)); } init_fat(s); s->faked_sectors=s->first_sectors_number+s->sectors_per_fat*2; s->cluster_count=sector2cluster(s, s->sector_count); mapping = array_get_next(&(s->mapping)); mapping->begin = 0; mapping->dir_index = 0; mapping->info.dir.parent_mapping_index = -1; mapping->first_mapping_index = -1; mapping->path = g_strdup(dirname); i = strlen(mapping->path); if (i > 0 && mapping->path[i - 1] == '/') mapping->path[i - 1] = '\0'; mapping->mode = MODE_DIRECTORY; mapping->read_only = 0; s->path = mapping->path; for (i = 0, cluster = 0; i < s->mapping.next; i++) { int fix_fat = (i != 0); mapping = array_get(&(s->mapping), i); if (mapping->mode & MODE_DIRECTORY) { mapping->begin = cluster; if(read_directory(s, i)) { error_setg(errp, "Could not read directory %s", mapping->path); return -1; } mapping = array_get(&(s->mapping), i); } else { assert(mapping->mode == MODE_UNDEFINED); mapping->mode=MODE_NORMAL; mapping->begin = cluster; if (mapping->end > 0) { direntry_t* direntry = array_get(&(s->directory), mapping->dir_index); mapping->end = cluster + 1 + (mapping->end-1)/s->cluster_size; set_begin_of_direntry(direntry, mapping->begin); } else { mapping->end = cluster + 1; fix_fat = 0; } } assert(mapping->begin < mapping->end); cluster = mapping->end; if(cluster > s->cluster_count) { error_setg(errp, "Directory does not fit in FAT%d (capacity %.2f MB)", s->fat_type, s->sector_count / 2000.0); return -1; } if (fix_fat) { int j; for(j = mapping->begin; j < mapping->end - 1; j++) fat_set(s, j, j+1); fat_set(s, mapping->end - 1, s->max_fat_value); } } mapping = array_get(&(s->mapping), 0); s->sectors_of_root_directory = mapping->end * s->sectors_per_cluster; s->last_cluster_of_root_directory = mapping->end; fat_set(s,0,s->max_fat_value); fat_set(s,1,s->max_fat_value); s->current_mapping = NULL; bootsector=(bootsector_t*)(s->first_sectors+(s->first_sectors_number-1)*0x200); bootsector->jump[0]=0xeb; bootsector->jump[1]=0x3e; bootsector->jump[2]=0x90; memcpy(bootsector->name,"QEMU ",8); bootsector->sector_size=cpu_to_le16(0x200); bootsector->sectors_per_cluster=s->sectors_per_cluster; bootsector->reserved_sectors=cpu_to_le16(1); bootsector->number_of_fats=0x2; bootsector->root_entries=cpu_to_le16(s->sectors_of_root_directory*0x10); bootsector->total_sectors16=s->sector_count>0xffff?0:cpu_to_le16(s->sector_count); bootsector->media_type=(s->first_sectors_number>1?0xf8:0xf0); s->fat.pointer[0] = bootsector->media_type; bootsector->sectors_per_fat=cpu_to_le16(s->sectors_per_fat); bootsector->sectors_per_track = cpu_to_le16(secs); bootsector->number_of_heads = cpu_to_le16(heads); bootsector->hidden_sectors=cpu_to_le32(s->first_sectors_number==1?0:0x3f); bootsector->total_sectors=cpu_to_le32(s->sector_count>0xffff?s->sector_count:0); bootsector->u.fat16.drive_number=s->first_sectors_number==1?0:0x80; bootsector->u.fat16.current_head=0; bootsector->u.fat16.signature=0x29; bootsector->u.fat16.id=cpu_to_le32(0xfabe1afd); memcpy(bootsector->u.fat16.volume_label,"QEMU VVFAT ",11); memcpy(bootsector->fat_type,(s->fat_type==12?"FAT12 ":s->fat_type==16?"FAT16 ":"FAT32 "),8); bootsector->magic[0]=0x55; bootsector->magic[1]=0xaa; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(BDRVVVFATState* VAR_0, const char *VAR_1, int VAR_2, int VAR_3, Error **VAR_4) { bootsector_t* bootsector; mapping_t* mapping; unsigned int VAR_5; unsigned int VAR_6; memset(&(VAR_0->first_sectors[0]),0,0x40*0x200); VAR_0->cluster_size=VAR_0->sectors_per_cluster*0x200; VAR_0->cluster_buffer=g_malloc(VAR_0->cluster_size); VAR_5 = 1+VAR_0->sectors_per_cluster*0x200*8/VAR_0->fat_type; VAR_0->sectors_per_fat=(VAR_0->sector_count+VAR_5)/VAR_5; array_init(&(VAR_0->mapping),sizeof(mapping_t)); array_init(&(VAR_0->directory),sizeof(direntry_t)); { direntry_t* entry=array_get_next(&(VAR_0->directory)); entry->attributes=0x28; memcpy(entry->name, "QEMU VVFAT ", sizeof(entry->name)); } init_fat(VAR_0); VAR_0->faked_sectors=VAR_0->first_sectors_number+VAR_0->sectors_per_fat*2; VAR_0->cluster_count=sector2cluster(VAR_0, VAR_0->sector_count); mapping = array_get_next(&(VAR_0->mapping)); mapping->begin = 0; mapping->dir_index = 0; mapping->info.dir.parent_mapping_index = -1; mapping->first_mapping_index = -1; mapping->path = g_strdup(VAR_1); VAR_5 = strlen(mapping->path); if (VAR_5 > 0 && mapping->path[VAR_5 - 1] == '/') mapping->path[VAR_5 - 1] = '\0'; mapping->mode = MODE_DIRECTORY; mapping->read_only = 0; VAR_0->path = mapping->path; for (VAR_5 = 0, VAR_6 = 0; VAR_5 < VAR_0->mapping.next; VAR_5++) { int fix_fat = (VAR_5 != 0); mapping = array_get(&(VAR_0->mapping), VAR_5); if (mapping->mode & MODE_DIRECTORY) { mapping->begin = VAR_6; if(read_directory(VAR_0, VAR_5)) { error_setg(VAR_4, "Could not read directory %VAR_0", mapping->path); return -1; } mapping = array_get(&(VAR_0->mapping), VAR_5); } else { assert(mapping->mode == MODE_UNDEFINED); mapping->mode=MODE_NORMAL; mapping->begin = VAR_6; if (mapping->end > 0) { direntry_t* direntry = array_get(&(VAR_0->directory), mapping->dir_index); mapping->end = VAR_6 + 1 + (mapping->end-1)/VAR_0->cluster_size; set_begin_of_direntry(direntry, mapping->begin); } else { mapping->end = VAR_6 + 1; fix_fat = 0; } } assert(mapping->begin < mapping->end); VAR_6 = mapping->end; if(VAR_6 > VAR_0->cluster_count) { error_setg(VAR_4, "Directory does not fit in FAT%d (capacity %.2f MB)", VAR_0->fat_type, VAR_0->sector_count / 2000.0); return -1; } if (fix_fat) { int j; for(j = mapping->begin; j < mapping->end - 1; j++) fat_set(VAR_0, j, j+1); fat_set(VAR_0, mapping->end - 1, VAR_0->max_fat_value); } } mapping = array_get(&(VAR_0->mapping), 0); VAR_0->sectors_of_root_directory = mapping->end * VAR_0->sectors_per_cluster; VAR_0->last_cluster_of_root_directory = mapping->end; fat_set(VAR_0,0,VAR_0->max_fat_value); fat_set(VAR_0,1,VAR_0->max_fat_value); VAR_0->current_mapping = NULL; bootsector=(bootsector_t*)(VAR_0->first_sectors+(VAR_0->first_sectors_number-1)*0x200); bootsector->jump[0]=0xeb; bootsector->jump[1]=0x3e; bootsector->jump[2]=0x90; memcpy(bootsector->name,"QEMU ",8); bootsector->sector_size=cpu_to_le16(0x200); bootsector->sectors_per_cluster=VAR_0->sectors_per_cluster; bootsector->reserved_sectors=cpu_to_le16(1); bootsector->number_of_fats=0x2; bootsector->root_entries=cpu_to_le16(VAR_0->sectors_of_root_directory*0x10); bootsector->total_sectors16=VAR_0->sector_count>0xffff?0:cpu_to_le16(VAR_0->sector_count); bootsector->media_type=(VAR_0->first_sectors_number>1?0xf8:0xf0); VAR_0->fat.pointer[0] = bootsector->media_type; bootsector->sectors_per_fat=cpu_to_le16(VAR_0->sectors_per_fat); bootsector->sectors_per_track = cpu_to_le16(VAR_3); bootsector->number_of_heads = cpu_to_le16(VAR_2); bootsector->hidden_sectors=cpu_to_le32(VAR_0->first_sectors_number==1?0:0x3f); bootsector->total_sectors=cpu_to_le32(VAR_0->sector_count>0xffff?VAR_0->sector_count:0); bootsector->u.fat16.drive_number=VAR_0->first_sectors_number==1?0:0x80; bootsector->u.fat16.current_head=0; bootsector->u.fat16.signature=0x29; bootsector->u.fat16.id=cpu_to_le32(0xfabe1afd); memcpy(bootsector->u.fat16.volume_label,"QEMU VVFAT ",11); memcpy(bootsector->fat_type,(VAR_0->fat_type==12?"FAT12 ":VAR_0->fat_type==16?"FAT16 ":"FAT32 "),8); bootsector->magic[0]=0x55; bootsector->magic[1]=0xaa; return 0; }
[ "static int FUNC_0(BDRVVVFATState* VAR_0,\nconst char *VAR_1, int VAR_2, int VAR_3,\nError **VAR_4)\n{", "bootsector_t* bootsector;", "mapping_t* mapping;", "unsigned int VAR_5;", "unsigned int VAR_6;", "memset(&(VAR_0->first_sectors[0]),0,0x40*0x200);", "VAR_0->cluster_size=VAR_0->sectors_per_cluster*0x200;", "VAR_0->cluster_buffer=g_malloc(VAR_0->cluster_size);", "VAR_5 = 1+VAR_0->sectors_per_cluster*0x200*8/VAR_0->fat_type;", "VAR_0->sectors_per_fat=(VAR_0->sector_count+VAR_5)/VAR_5;", "array_init(&(VAR_0->mapping),sizeof(mapping_t));", "array_init(&(VAR_0->directory),sizeof(direntry_t));", "{", "direntry_t* entry=array_get_next(&(VAR_0->directory));", "entry->attributes=0x28;", "memcpy(entry->name, \"QEMU VVFAT \", sizeof(entry->name));", "}", "init_fat(VAR_0);", "VAR_0->faked_sectors=VAR_0->first_sectors_number+VAR_0->sectors_per_fat*2;", "VAR_0->cluster_count=sector2cluster(VAR_0, VAR_0->sector_count);", "mapping = array_get_next(&(VAR_0->mapping));", "mapping->begin = 0;", "mapping->dir_index = 0;", "mapping->info.dir.parent_mapping_index = -1;", "mapping->first_mapping_index = -1;", "mapping->path = g_strdup(VAR_1);", "VAR_5 = strlen(mapping->path);", "if (VAR_5 > 0 && mapping->path[VAR_5 - 1] == '/')\nmapping->path[VAR_5 - 1] = '\\0';", "mapping->mode = MODE_DIRECTORY;", "mapping->read_only = 0;", "VAR_0->path = mapping->path;", "for (VAR_5 = 0, VAR_6 = 0; VAR_5 < VAR_0->mapping.next; VAR_5++) {", "int fix_fat = (VAR_5 != 0);", "mapping = array_get(&(VAR_0->mapping), VAR_5);", "if (mapping->mode & MODE_DIRECTORY) {", "mapping->begin = VAR_6;", "if(read_directory(VAR_0, VAR_5)) {", "error_setg(VAR_4, \"Could not read directory %VAR_0\",\nmapping->path);", "return -1;", "}", "mapping = array_get(&(VAR_0->mapping), VAR_5);", "} else {", "assert(mapping->mode == MODE_UNDEFINED);", "mapping->mode=MODE_NORMAL;", "mapping->begin = VAR_6;", "if (mapping->end > 0) {", "direntry_t* direntry = array_get(&(VAR_0->directory),\nmapping->dir_index);", "mapping->end = VAR_6 + 1 + (mapping->end-1)/VAR_0->cluster_size;", "set_begin_of_direntry(direntry, mapping->begin);", "} else {", "mapping->end = VAR_6 + 1;", "fix_fat = 0;", "}", "}", "assert(mapping->begin < mapping->end);", "VAR_6 = mapping->end;", "if(VAR_6 > VAR_0->cluster_count) {", "error_setg(VAR_4,\n\"Directory does not fit in FAT%d (capacity %.2f MB)\",\nVAR_0->fat_type, VAR_0->sector_count / 2000.0);", "return -1;", "}", "if (fix_fat) {", "int j;", "for(j = mapping->begin; j < mapping->end - 1; j++)", "fat_set(VAR_0, j, j+1);", "fat_set(VAR_0, mapping->end - 1, VAR_0->max_fat_value);", "}", "}", "mapping = array_get(&(VAR_0->mapping), 0);", "VAR_0->sectors_of_root_directory = mapping->end * VAR_0->sectors_per_cluster;", "VAR_0->last_cluster_of_root_directory = mapping->end;", "fat_set(VAR_0,0,VAR_0->max_fat_value);", "fat_set(VAR_0,1,VAR_0->max_fat_value);", "VAR_0->current_mapping = NULL;", "bootsector=(bootsector_t*)(VAR_0->first_sectors+(VAR_0->first_sectors_number-1)*0x200);", "bootsector->jump[0]=0xeb;", "bootsector->jump[1]=0x3e;", "bootsector->jump[2]=0x90;", "memcpy(bootsector->name,\"QEMU \",8);", "bootsector->sector_size=cpu_to_le16(0x200);", "bootsector->sectors_per_cluster=VAR_0->sectors_per_cluster;", "bootsector->reserved_sectors=cpu_to_le16(1);", "bootsector->number_of_fats=0x2;", "bootsector->root_entries=cpu_to_le16(VAR_0->sectors_of_root_directory*0x10);", "bootsector->total_sectors16=VAR_0->sector_count>0xffff?0:cpu_to_le16(VAR_0->sector_count);", "bootsector->media_type=(VAR_0->first_sectors_number>1?0xf8:0xf0);", "VAR_0->fat.pointer[0] = bootsector->media_type;", "bootsector->sectors_per_fat=cpu_to_le16(VAR_0->sectors_per_fat);", "bootsector->sectors_per_track = cpu_to_le16(VAR_3);", "bootsector->number_of_heads = cpu_to_le16(VAR_2);", "bootsector->hidden_sectors=cpu_to_le32(VAR_0->first_sectors_number==1?0:0x3f);", "bootsector->total_sectors=cpu_to_le32(VAR_0->sector_count>0xffff?VAR_0->sector_count:0);", "bootsector->u.fat16.drive_number=VAR_0->first_sectors_number==1?0:0x80;", "bootsector->u.fat16.current_head=0;", "bootsector->u.fat16.signature=0x29;", "bootsector->u.fat16.id=cpu_to_le32(0xfabe1afd);", "memcpy(bootsector->u.fat16.volume_label,\"QEMU VVFAT \",11);", "memcpy(bootsector->fat_type,(VAR_0->fat_type==12?\"FAT12 \":VAR_0->fat_type==16?\"FAT16 \":\"FAT32 \"),8);", "bootsector->magic[0]=0x55; bootsector->magic[1]=0xaa;", "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 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 23 ], [ 25 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 71 ], [ 75 ], [ 77 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95, 97 ], [ 99 ], [ 101 ], [ 103 ], [ 107 ], [ 115 ], [ 117 ], [ 121 ], [ 123 ], [ 125 ], [ 127, 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147, 149 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 169 ], [ 175 ], [ 179 ], [ 181, 183, 185 ], [ 187 ], [ 189 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 211 ], [ 213 ], [ 215 ], [ 221 ], [ 223 ], [ 227 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 265 ], [ 271 ], [ 273 ], [ 275 ], [ 277 ], [ 281 ], [ 283 ], [ 285 ], [ 289 ], [ 291 ] ]
6,093
static void lsp2polyf(const double *lsp, double *f, int lp_half_order) { int i, j; f[0] = 1.0; f[1] = -2 * lsp[0]; lsp -= 2; for(i=2; i<=lp_half_order; i++) { double val = -2 * lsp[2*i]; f[i] = val * f[i-1] + 2*f[i-2]; for(j=i-1; j>1; j--) f[j] += f[j-1] * val + f[j-2]; f[1] += val; } }
false
FFmpeg
33ae681f5ca9fa9aae82081dd6a6edbe2509f983
static void lsp2polyf(const double *lsp, double *f, int lp_half_order) { int i, j; f[0] = 1.0; f[1] = -2 * lsp[0]; lsp -= 2; for(i=2; i<=lp_half_order; i++) { double val = -2 * lsp[2*i]; f[i] = val * f[i-1] + 2*f[i-2]; for(j=i-1; j>1; j--) f[j] += f[j-1] * val + f[j-2]; f[1] += val; } }
{ "code": [], "line_no": [] }
static void FUNC_0(const double *VAR_0, double *VAR_1, int VAR_2) { int VAR_3, VAR_4; VAR_1[0] = 1.0; VAR_1[1] = -2 * VAR_0[0]; VAR_0 -= 2; for(VAR_3=2; VAR_3<=VAR_2; VAR_3++) { double VAR_5 = -2 * VAR_0[2*VAR_3]; VAR_1[VAR_3] = VAR_5 * VAR_1[VAR_3-1] + 2*VAR_1[VAR_3-2]; for(VAR_4=VAR_3-1; VAR_4>1; VAR_4--) VAR_1[VAR_4] += VAR_1[VAR_4-1] * VAR_5 + VAR_1[VAR_4-2]; VAR_1[1] += VAR_5; } }
[ "static void FUNC_0(const double *VAR_0, double *VAR_1, int VAR_2)\n{", "int VAR_3, VAR_4;", "VAR_1[0] = 1.0;", "VAR_1[1] = -2 * VAR_0[0];", "VAR_0 -= 2;", "for(VAR_3=2; VAR_3<=VAR_2; VAR_3++)", "{", "double VAR_5 = -2 * VAR_0[2*VAR_3];", "VAR_1[VAR_3] = VAR_5 * VAR_1[VAR_3-1] + 2*VAR_1[VAR_3-2];", "for(VAR_4=VAR_3-1; VAR_4>1; VAR_4--)", "VAR_1[VAR_4] += VAR_1[VAR_4-1] * VAR_5 + VAR_1[VAR_4-2];", "VAR_1[1] += VAR_5;", "}", "}" ]
[ 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 ] ]
6,094
static uint32_t slow_bar_readl(void *opaque, target_phys_addr_t addr) { AssignedDevRegion *d = opaque; uint32_t *in = (uint32_t *)(d->u.r_virtbase + addr); uint32_t r; r = *in; DEBUG("slow_bar_readl addr=0x" TARGET_FMT_plx " val=0x%08x\n", addr, r); return r; }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static uint32_t slow_bar_readl(void *opaque, target_phys_addr_t addr) { AssignedDevRegion *d = opaque; uint32_t *in = (uint32_t *)(d->u.r_virtbase + addr); uint32_t r; r = *in; DEBUG("slow_bar_readl addr=0x" TARGET_FMT_plx " val=0x%08x\n", addr, r); return r; }
{ "code": [], "line_no": [] }
static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr) { AssignedDevRegion *d = opaque; uint32_t *in = (uint32_t *)(d->u.r_virtbase + addr); uint32_t r; r = *in; DEBUG("FUNC_0 addr=0x" TARGET_FMT_plx " val=0x%08x\n", addr, r); return r; }
[ "static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)\n{", "AssignedDevRegion *d = opaque;", "uint32_t *in = (uint32_t *)(d->u.r_virtbase + addr);", "uint32_t r;", "r = *in;", "DEBUG(\"FUNC_0 addr=0x\" TARGET_FMT_plx \" val=0x%08x\\n\", addr, r);", "return r;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ] ]
6,095
void ich9_pm_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { ICH9LPCState *lpc = ICH9_LPC_DEVICE(hotplug_dev); if (lpc->pm.acpi_memory_hotplug.is_enabled && object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { acpi_memory_plug_cb(hotplug_dev, &lpc->pm.acpi_memory_hotplug, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { if (lpc->pm.cpu_hotplug_legacy) { legacy_acpi_cpu_plug_cb(hotplug_dev, &lpc->pm.gpe_cpu, dev, errp); } else { acpi_cpu_plug_cb(hotplug_dev, &lpc->pm.cpuhp_state, dev, errp); } } else { error_setg(errp, "acpi: device plug request for not supported device" " type: %s", object_get_typename(OBJECT(dev))); } }
false
qemu
75f27498220e6ff6f78bf08fbe2cc662ec76ba89
void ich9_pm_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { ICH9LPCState *lpc = ICH9_LPC_DEVICE(hotplug_dev); if (lpc->pm.acpi_memory_hotplug.is_enabled && object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { acpi_memory_plug_cb(hotplug_dev, &lpc->pm.acpi_memory_hotplug, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { if (lpc->pm.cpu_hotplug_legacy) { legacy_acpi_cpu_plug_cb(hotplug_dev, &lpc->pm.gpe_cpu, dev, errp); } else { acpi_cpu_plug_cb(hotplug_dev, &lpc->pm.cpuhp_state, dev, errp); } } else { error_setg(errp, "acpi: device plug request for not supported device" " type: %s", object_get_typename(OBJECT(dev))); } }
{ "code": [], "line_no": [] }
void FUNC_0(HotplugHandler *VAR_0, DeviceState *VAR_1, Error **VAR_2) { ICH9LPCState *lpc = ICH9_LPC_DEVICE(VAR_0); if (lpc->pm.acpi_memory_hotplug.is_enabled && object_dynamic_cast(OBJECT(VAR_1), TYPE_PC_DIMM)) { acpi_memory_plug_cb(VAR_0, &lpc->pm.acpi_memory_hotplug, VAR_1, VAR_2); } else if (object_dynamic_cast(OBJECT(VAR_1), TYPE_CPU)) { if (lpc->pm.cpu_hotplug_legacy) { legacy_acpi_cpu_plug_cb(VAR_0, &lpc->pm.gpe_cpu, VAR_1, VAR_2); } else { acpi_cpu_plug_cb(VAR_0, &lpc->pm.cpuhp_state, VAR_1, VAR_2); } } else { error_setg(VAR_2, "acpi: device plug request for not supported device" " type: %s", object_get_typename(OBJECT(VAR_1))); } }
[ "void FUNC_0(HotplugHandler *VAR_0, DeviceState *VAR_1,\nError **VAR_2)\n{", "ICH9LPCState *lpc = ICH9_LPC_DEVICE(VAR_0);", "if (lpc->pm.acpi_memory_hotplug.is_enabled &&\nobject_dynamic_cast(OBJECT(VAR_1), TYPE_PC_DIMM)) {", "acpi_memory_plug_cb(VAR_0, &lpc->pm.acpi_memory_hotplug,\nVAR_1, VAR_2);", "} else if (object_dynamic_cast(OBJECT(VAR_1), TYPE_CPU)) {", "if (lpc->pm.cpu_hotplug_legacy) {", "legacy_acpi_cpu_plug_cb(VAR_0, &lpc->pm.gpe_cpu, VAR_1, VAR_2);", "} else {", "acpi_cpu_plug_cb(VAR_0, &lpc->pm.cpuhp_state, VAR_1, VAR_2);", "}", "} else {", "error_setg(VAR_2, \"acpi: device plug request for not supported device\"\n\" type: %s\", object_get_typename(OBJECT(VAR_1)));", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11, 13 ], [ 15, 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33, 35 ], [ 37 ], [ 39 ] ]
6,096
static int megasas_dcmd_ld_get_list(MegasasState *s, MegasasCmd *cmd) { struct mfi_ld_list info; size_t dcmd_size = sizeof(info), resid; uint32_t num_ld_disks = 0, max_ld_disks = s->fw_luns; uint64_t ld_size; BusChild *kid; memset(&info, 0, dcmd_size); if (cmd->iov_size < dcmd_size) { trace_megasas_dcmd_invalid_xfer_len(cmd->index, cmd->iov_size, dcmd_size); return MFI_STAT_INVALID_PARAMETER; } if (megasas_is_jbod(s)) { max_ld_disks = 0; } QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) { SCSIDevice *sdev = DO_UPCAST(SCSIDevice, qdev, kid->child); BlockConf *conf = &sdev->conf; if (num_ld_disks >= max_ld_disks) { break; } /* Logical device size is in blocks */ bdrv_get_geometry(conf->bs, &ld_size); info.ld_list[num_ld_disks].ld.v.target_id = sdev->id; info.ld_list[num_ld_disks].ld.v.lun_id = sdev->lun; info.ld_list[num_ld_disks].state = MFI_LD_STATE_OPTIMAL; info.ld_list[num_ld_disks].size = cpu_to_le64(ld_size); num_ld_disks++; } info.ld_count = cpu_to_le32(num_ld_disks); trace_megasas_dcmd_ld_get_list(cmd->index, num_ld_disks, max_ld_disks); resid = dma_buf_read((uint8_t *)&info, dcmd_size, &cmd->qsg); cmd->iov_size = dcmd_size - resid; return MFI_STAT_OK; }
false
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
static int megasas_dcmd_ld_get_list(MegasasState *s, MegasasCmd *cmd) { struct mfi_ld_list info; size_t dcmd_size = sizeof(info), resid; uint32_t num_ld_disks = 0, max_ld_disks = s->fw_luns; uint64_t ld_size; BusChild *kid; memset(&info, 0, dcmd_size); if (cmd->iov_size < dcmd_size) { trace_megasas_dcmd_invalid_xfer_len(cmd->index, cmd->iov_size, dcmd_size); return MFI_STAT_INVALID_PARAMETER; } if (megasas_is_jbod(s)) { max_ld_disks = 0; } QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) { SCSIDevice *sdev = DO_UPCAST(SCSIDevice, qdev, kid->child); BlockConf *conf = &sdev->conf; if (num_ld_disks >= max_ld_disks) { break; } bdrv_get_geometry(conf->bs, &ld_size); info.ld_list[num_ld_disks].ld.v.target_id = sdev->id; info.ld_list[num_ld_disks].ld.v.lun_id = sdev->lun; info.ld_list[num_ld_disks].state = MFI_LD_STATE_OPTIMAL; info.ld_list[num_ld_disks].size = cpu_to_le64(ld_size); num_ld_disks++; } info.ld_count = cpu_to_le32(num_ld_disks); trace_megasas_dcmd_ld_get_list(cmd->index, num_ld_disks, max_ld_disks); resid = dma_buf_read((uint8_t *)&info, dcmd_size, &cmd->qsg); cmd->iov_size = dcmd_size - resid; return MFI_STAT_OK; }
{ "code": [], "line_no": [] }
static int FUNC_0(MegasasState *VAR_0, MegasasCmd *VAR_1) { struct mfi_ld_list VAR_2; size_t dcmd_size = sizeof(VAR_2), resid; uint32_t num_ld_disks = 0, max_ld_disks = VAR_0->fw_luns; uint64_t ld_size; BusChild *kid; memset(&VAR_2, 0, dcmd_size); if (VAR_1->iov_size < dcmd_size) { trace_megasas_dcmd_invalid_xfer_len(VAR_1->index, VAR_1->iov_size, dcmd_size); return MFI_STAT_INVALID_PARAMETER; } if (megasas_is_jbod(VAR_0)) { max_ld_disks = 0; } QTAILQ_FOREACH(kid, &VAR_0->bus.qbus.children, sibling) { SCSIDevice *sdev = DO_UPCAST(SCSIDevice, qdev, kid->child); BlockConf *conf = &sdev->conf; if (num_ld_disks >= max_ld_disks) { break; } bdrv_get_geometry(conf->bs, &ld_size); VAR_2.ld_list[num_ld_disks].ld.v.target_id = sdev->id; VAR_2.ld_list[num_ld_disks].ld.v.lun_id = sdev->lun; VAR_2.ld_list[num_ld_disks].state = MFI_LD_STATE_OPTIMAL; VAR_2.ld_list[num_ld_disks].size = cpu_to_le64(ld_size); num_ld_disks++; } VAR_2.ld_count = cpu_to_le32(num_ld_disks); trace_megasas_dcmd_ld_get_list(VAR_1->index, num_ld_disks, max_ld_disks); resid = dma_buf_read((uint8_t *)&VAR_2, dcmd_size, &VAR_1->qsg); VAR_1->iov_size = dcmd_size - resid; return MFI_STAT_OK; }
[ "static int FUNC_0(MegasasState *VAR_0, MegasasCmd *VAR_1)\n{", "struct mfi_ld_list VAR_2;", "size_t dcmd_size = sizeof(VAR_2), resid;", "uint32_t num_ld_disks = 0, max_ld_disks = VAR_0->fw_luns;", "uint64_t ld_size;", "BusChild *kid;", "memset(&VAR_2, 0, dcmd_size);", "if (VAR_1->iov_size < dcmd_size) {", "trace_megasas_dcmd_invalid_xfer_len(VAR_1->index, VAR_1->iov_size,\ndcmd_size);", "return MFI_STAT_INVALID_PARAMETER;", "}", "if (megasas_is_jbod(VAR_0)) {", "max_ld_disks = 0;", "}", "QTAILQ_FOREACH(kid, &VAR_0->bus.qbus.children, sibling) {", "SCSIDevice *sdev = DO_UPCAST(SCSIDevice, qdev, kid->child);", "BlockConf *conf = &sdev->conf;", "if (num_ld_disks >= max_ld_disks) {", "break;", "}", "bdrv_get_geometry(conf->bs, &ld_size);", "VAR_2.ld_list[num_ld_disks].ld.v.target_id = sdev->id;", "VAR_2.ld_list[num_ld_disks].ld.v.lun_id = sdev->lun;", "VAR_2.ld_list[num_ld_disks].state = MFI_LD_STATE_OPTIMAL;", "VAR_2.ld_list[num_ld_disks].size = cpu_to_le64(ld_size);", "num_ld_disks++;", "}", "VAR_2.ld_count = cpu_to_le32(num_ld_disks);", "trace_megasas_dcmd_ld_get_list(VAR_1->index, num_ld_disks, max_ld_disks);", "resid = dma_buf_read((uint8_t *)&VAR_2, dcmd_size, &VAR_1->qsg);", "VAR_1->iov_size = dcmd_size - resid;", "return MFI_STAT_OK;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ] ]
6,099
static void resume_all_vcpus(void) { CPUState *penv = first_cpu; while (penv) { penv->stop = 0; penv->stopped = 0; qemu_thread_signal(penv->thread, SIGUSR1); qemu_cpu_kick(penv); penv = (CPUState *)penv->next_cpu; } }
false
qemu
cc84de9570ffe01a9c3c169bd62ab9586a9a080c
static void resume_all_vcpus(void) { CPUState *penv = first_cpu; while (penv) { penv->stop = 0; penv->stopped = 0; qemu_thread_signal(penv->thread, SIGUSR1); qemu_cpu_kick(penv); penv = (CPUState *)penv->next_cpu; } }
{ "code": [], "line_no": [] }
static void FUNC_0(void) { CPUState *penv = first_cpu; while (penv) { penv->stop = 0; penv->stopped = 0; qemu_thread_signal(penv->thread, SIGUSR1); qemu_cpu_kick(penv); penv = (CPUState *)penv->next_cpu; } }
[ "static void FUNC_0(void)\n{", "CPUState *penv = first_cpu;", "while (penv) {", "penv->stop = 0;", "penv->stopped = 0;", "qemu_thread_signal(penv->thread, SIGUSR1);", "qemu_cpu_kick(penv);", "penv = (CPUState *)penv->next_cpu;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ] ]
6,100
static int coroutine_fn bdrv_co_writev_em(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *iov) { return bdrv_co_io_em(bs, sector_num, nb_sectors, iov, true); }
false
qemu
08844473820c93541fc47bdfeae0f2cc88cfab59
static int coroutine_fn bdrv_co_writev_em(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *iov) { return bdrv_co_io_em(bs, sector_num, nb_sectors, iov, true); }
{ "code": [], "line_no": [] }
static int VAR_0 bdrv_co_writev_em(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *iov) { return bdrv_co_io_em(bs, sector_num, nb_sectors, iov, true); }
[ "static int VAR_0 bdrv_co_writev_em(BlockDriverState *bs,\nint64_t sector_num, int nb_sectors,\nQEMUIOVector *iov)\n{", "return bdrv_co_io_em(bs, sector_num, nb_sectors, iov, true);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ] ]
6,101
static void do_audio_out(AVFormatContext *s, AVOutputStream *ost, AVInputStream *ist, unsigned char *buf, int size) { uint8_t *buftmp; int64_t audio_out_size, audio_buf_size; int64_t allocated_for_size= size; int size_out, frame_bytes, ret; AVCodecContext *enc= ost->st->codec; AVCodecContext *dec= ist->st->codec; int osize= av_get_bits_per_sample_format(enc->sample_fmt)/8; int isize= av_get_bits_per_sample_format(dec->sample_fmt)/8; const int coded_bps = av_get_bits_per_sample(enc->codec->id); need_realloc: audio_buf_size= (allocated_for_size + isize*dec->channels - 1) / (isize*dec->channels); audio_buf_size= (audio_buf_size*enc->sample_rate + dec->sample_rate) / dec->sample_rate; audio_buf_size= audio_buf_size*2 + 10000; //safety factors for the deprecated resampling API audio_buf_size= FFMAX(audio_buf_size, enc->frame_size); audio_buf_size*= osize*enc->channels; audio_out_size= FFMAX(audio_buf_size, enc->frame_size * osize * enc->channels); if(coded_bps > 8*osize) audio_out_size= audio_out_size * coded_bps / (8*osize); audio_out_size += FF_MIN_BUFFER_SIZE; if(audio_out_size > INT_MAX || audio_buf_size > INT_MAX){ fprintf(stderr, "Buffer sizes too large\n"); ffmpeg_exit(1); } av_fast_malloc(&audio_buf, &allocated_audio_buf_size, audio_buf_size); av_fast_malloc(&audio_out, &allocated_audio_out_size, audio_out_size); if (!audio_buf || !audio_out){ fprintf(stderr, "Out of memory in do_audio_out\n"); ffmpeg_exit(1); } if (enc->channels != dec->channels) ost->audio_resample = 1; if (ost->audio_resample && !ost->resample) { if (dec->sample_fmt != SAMPLE_FMT_S16) fprintf(stderr, "Warning, using s16 intermediate sample format for resampling\n"); ost->resample = av_audio_resample_init(enc->channels, dec->channels, enc->sample_rate, dec->sample_rate, enc->sample_fmt, dec->sample_fmt, 16, 10, 0, 0.8); if (!ost->resample) { fprintf(stderr, "Can not resample %d channels @ %d Hz to %d channels @ %d Hz\n", dec->channels, dec->sample_rate, enc->channels, enc->sample_rate); ffmpeg_exit(1); } } #define MAKE_SFMT_PAIR(a,b) ((a)+SAMPLE_FMT_NB*(b)) if (!ost->audio_resample && dec->sample_fmt!=enc->sample_fmt && MAKE_SFMT_PAIR(enc->sample_fmt,dec->sample_fmt)!=ost->reformat_pair) { if (ost->reformat_ctx) av_audio_convert_free(ost->reformat_ctx); ost->reformat_ctx = av_audio_convert_alloc(enc->sample_fmt, 1, dec->sample_fmt, 1, NULL, 0); if (!ost->reformat_ctx) { fprintf(stderr, "Cannot convert %s sample format to %s sample format\n", avcodec_get_sample_fmt_name(dec->sample_fmt), avcodec_get_sample_fmt_name(enc->sample_fmt)); ffmpeg_exit(1); } ost->reformat_pair=MAKE_SFMT_PAIR(enc->sample_fmt,dec->sample_fmt); } if(audio_sync_method){ double delta = get_sync_ipts(ost) * enc->sample_rate - ost->sync_opts - av_fifo_size(ost->fifo)/(enc->channels * 2); double idelta= delta*dec->sample_rate / enc->sample_rate; int byte_delta= ((int)idelta)*2*dec->channels; //FIXME resample delay if(fabs(delta) > 50){ if(ist->is_start || fabs(delta) > audio_drift_threshold*enc->sample_rate){ if(byte_delta < 0){ byte_delta= FFMAX(byte_delta, -size); size += byte_delta; buf -= byte_delta; if(verbose > 2) fprintf(stderr, "discarding %d audio samples\n", (int)-delta); if(!size) return; ist->is_start=0; }else{ static uint8_t *input_tmp= NULL; input_tmp= av_realloc(input_tmp, byte_delta + size); if(byte_delta > allocated_for_size - size){ allocated_for_size= byte_delta + (int64_t)size; goto need_realloc; } ist->is_start=0; memset(input_tmp, 0, byte_delta); memcpy(input_tmp + byte_delta, buf, size); buf= input_tmp; size += byte_delta; if(verbose > 2) fprintf(stderr, "adding %d audio samples of silence\n", (int)delta); } }else if(audio_sync_method>1){ int comp= av_clip(delta, -audio_sync_method, audio_sync_method); assert(ost->audio_resample); if(verbose > 2) fprintf(stderr, "compensating audio timestamp drift:%f compensation:%d in:%d\n", delta, comp, enc->sample_rate); // fprintf(stderr, "drift:%f len:%d opts:%"PRId64" ipts:%"PRId64" fifo:%d\n", delta, -1, ost->sync_opts, (int64_t)(get_sync_ipts(ost) * enc->sample_rate), av_fifo_size(ost->fifo)/(ost->st->codec->channels * 2)); av_resample_compensate(*(struct AVResampleContext**)ost->resample, comp, enc->sample_rate); } } }else ost->sync_opts= lrintf(get_sync_ipts(ost) * enc->sample_rate) - av_fifo_size(ost->fifo)/(enc->channels * 2); //FIXME wrong if (ost->audio_resample) { buftmp = audio_buf; size_out = audio_resample(ost->resample, (short *)buftmp, (short *)buf, size / (dec->channels * isize)); size_out = size_out * enc->channels * osize; } else { buftmp = buf; size_out = size; } if (!ost->audio_resample && dec->sample_fmt!=enc->sample_fmt) { const void *ibuf[6]= {buftmp}; void *obuf[6]= {audio_buf}; int istride[6]= {isize}; int ostride[6]= {osize}; int len= size_out/istride[0]; if (av_audio_convert(ost->reformat_ctx, obuf, ostride, ibuf, istride, len)<0) { printf("av_audio_convert() failed\n"); if (exit_on_error) ffmpeg_exit(1); return; } buftmp = audio_buf; size_out = len*osize; } /* now encode as many frames as possible */ if (enc->frame_size > 1) { /* output resampled raw samples */ if (av_fifo_realloc2(ost->fifo, av_fifo_size(ost->fifo) + size_out) < 0) { fprintf(stderr, "av_fifo_realloc2() failed\n"); ffmpeg_exit(1); } av_fifo_generic_write(ost->fifo, buftmp, size_out, NULL); frame_bytes = enc->frame_size * osize * enc->channels; while (av_fifo_size(ost->fifo) >= frame_bytes) { AVPacket pkt; av_init_packet(&pkt); av_fifo_generic_read(ost->fifo, audio_buf, frame_bytes, NULL); //FIXME pass ost->sync_opts as AVFrame.pts in avcodec_encode_audio() ret = avcodec_encode_audio(enc, audio_out, audio_out_size, (short *)audio_buf); if (ret < 0) { fprintf(stderr, "Audio encoding failed\n"); ffmpeg_exit(1); } audio_size += ret; pkt.stream_index= ost->index; pkt.data= audio_out; pkt.size= ret; if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE) pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base); pkt.flags |= AV_PKT_FLAG_KEY; write_frame(s, &pkt, enc, bitstream_filters[ost->file_index][pkt.stream_index]); ost->sync_opts += enc->frame_size; } } else { AVPacket pkt; av_init_packet(&pkt); ost->sync_opts += size_out / (osize * enc->channels); /* output a pcm frame */ /* determine the size of the coded buffer */ size_out /= osize; if (coded_bps) size_out = size_out*coded_bps/8; if(size_out > audio_out_size){ fprintf(stderr, "Internal error, buffer size too small\n"); ffmpeg_exit(1); } //FIXME pass ost->sync_opts as AVFrame.pts in avcodec_encode_audio() ret = avcodec_encode_audio(enc, audio_out, size_out, (short *)buftmp); if (ret < 0) { fprintf(stderr, "Audio encoding failed\n"); ffmpeg_exit(1); } audio_size += ret; pkt.stream_index= ost->index; pkt.data= audio_out; pkt.size= ret; if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE) pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base); pkt.flags |= AV_PKT_FLAG_KEY; write_frame(s, &pkt, enc, bitstream_filters[ost->file_index][pkt.stream_index]); } }
false
FFmpeg
b926b6282d3b9fc8115660ae013f74f4f8c06d30
static void do_audio_out(AVFormatContext *s, AVOutputStream *ost, AVInputStream *ist, unsigned char *buf, int size) { uint8_t *buftmp; int64_t audio_out_size, audio_buf_size; int64_t allocated_for_size= size; int size_out, frame_bytes, ret; AVCodecContext *enc= ost->st->codec; AVCodecContext *dec= ist->st->codec; int osize= av_get_bits_per_sample_format(enc->sample_fmt)/8; int isize= av_get_bits_per_sample_format(dec->sample_fmt)/8; const int coded_bps = av_get_bits_per_sample(enc->codec->id); need_realloc: audio_buf_size= (allocated_for_size + isize*dec->channels - 1) / (isize*dec->channels); audio_buf_size= (audio_buf_size*enc->sample_rate + dec->sample_rate) / dec->sample_rate; audio_buf_size= audio_buf_size*2 + 10000; audio_buf_size= FFMAX(audio_buf_size, enc->frame_size); audio_buf_size*= osize*enc->channels; audio_out_size= FFMAX(audio_buf_size, enc->frame_size * osize * enc->channels); if(coded_bps > 8*osize) audio_out_size= audio_out_size * coded_bps / (8*osize); audio_out_size += FF_MIN_BUFFER_SIZE; if(audio_out_size > INT_MAX || audio_buf_size > INT_MAX){ fprintf(stderr, "Buffer sizes too large\n"); ffmpeg_exit(1); } av_fast_malloc(&audio_buf, &allocated_audio_buf_size, audio_buf_size); av_fast_malloc(&audio_out, &allocated_audio_out_size, audio_out_size); if (!audio_buf || !audio_out){ fprintf(stderr, "Out of memory in do_audio_out\n"); ffmpeg_exit(1); } if (enc->channels != dec->channels) ost->audio_resample = 1; if (ost->audio_resample && !ost->resample) { if (dec->sample_fmt != SAMPLE_FMT_S16) fprintf(stderr, "Warning, using s16 intermediate sample format for resampling\n"); ost->resample = av_audio_resample_init(enc->channels, dec->channels, enc->sample_rate, dec->sample_rate, enc->sample_fmt, dec->sample_fmt, 16, 10, 0, 0.8); if (!ost->resample) { fprintf(stderr, "Can not resample %d channels @ %d Hz to %d channels @ %d Hz\n", dec->channels, dec->sample_rate, enc->channels, enc->sample_rate); ffmpeg_exit(1); } } #define MAKE_SFMT_PAIR(a,b) ((a)+SAMPLE_FMT_NB*(b)) if (!ost->audio_resample && dec->sample_fmt!=enc->sample_fmt && MAKE_SFMT_PAIR(enc->sample_fmt,dec->sample_fmt)!=ost->reformat_pair) { if (ost->reformat_ctx) av_audio_convert_free(ost->reformat_ctx); ost->reformat_ctx = av_audio_convert_alloc(enc->sample_fmt, 1, dec->sample_fmt, 1, NULL, 0); if (!ost->reformat_ctx) { fprintf(stderr, "Cannot convert %s sample format to %s sample format\n", avcodec_get_sample_fmt_name(dec->sample_fmt), avcodec_get_sample_fmt_name(enc->sample_fmt)); ffmpeg_exit(1); } ost->reformat_pair=MAKE_SFMT_PAIR(enc->sample_fmt,dec->sample_fmt); } if(audio_sync_method){ double delta = get_sync_ipts(ost) * enc->sample_rate - ost->sync_opts - av_fifo_size(ost->fifo)/(enc->channels * 2); double idelta= delta*dec->sample_rate / enc->sample_rate; int byte_delta= ((int)idelta)*2*dec->channels; if(fabs(delta) > 50){ if(ist->is_start || fabs(delta) > audio_drift_threshold*enc->sample_rate){ if(byte_delta < 0){ byte_delta= FFMAX(byte_delta, -size); size += byte_delta; buf -= byte_delta; if(verbose > 2) fprintf(stderr, "discarding %d audio samples\n", (int)-delta); if(!size) return; ist->is_start=0; }else{ static uint8_t *input_tmp= NULL; input_tmp= av_realloc(input_tmp, byte_delta + size); if(byte_delta > allocated_for_size - size){ allocated_for_size= byte_delta + (int64_t)size; goto need_realloc; } ist->is_start=0; memset(input_tmp, 0, byte_delta); memcpy(input_tmp + byte_delta, buf, size); buf= input_tmp; size += byte_delta; if(verbose > 2) fprintf(stderr, "adding %d audio samples of silence\n", (int)delta); } }else if(audio_sync_method>1){ int comp= av_clip(delta, -audio_sync_method, audio_sync_method); assert(ost->audio_resample); if(verbose > 2) fprintf(stderr, "compensating audio timestamp drift:%f compensation:%d in:%d\n", delta, comp, enc->sample_rate); av_resample_compensate(*(struct AVResampleContext**)ost->resample, comp, enc->sample_rate); } } }else ost->sync_opts= lrintf(get_sync_ipts(ost) * enc->sample_rate) - av_fifo_size(ost->fifo)/(enc->channels * 2); if (ost->audio_resample) { buftmp = audio_buf; size_out = audio_resample(ost->resample, (short *)buftmp, (short *)buf, size / (dec->channels * isize)); size_out = size_out * enc->channels * osize; } else { buftmp = buf; size_out = size; } if (!ost->audio_resample && dec->sample_fmt!=enc->sample_fmt) { const void *ibuf[6]= {buftmp}; void *obuf[6]= {audio_buf}; int istride[6]= {isize}; int ostride[6]= {osize}; int len= size_out/istride[0]; if (av_audio_convert(ost->reformat_ctx, obuf, ostride, ibuf, istride, len)<0) { printf("av_audio_convert() failed\n"); if (exit_on_error) ffmpeg_exit(1); return; } buftmp = audio_buf; size_out = len*osize; } if (enc->frame_size > 1) { if (av_fifo_realloc2(ost->fifo, av_fifo_size(ost->fifo) + size_out) < 0) { fprintf(stderr, "av_fifo_realloc2() failed\n"); ffmpeg_exit(1); } av_fifo_generic_write(ost->fifo, buftmp, size_out, NULL); frame_bytes = enc->frame_size * osize * enc->channels; while (av_fifo_size(ost->fifo) >= frame_bytes) { AVPacket pkt; av_init_packet(&pkt); av_fifo_generic_read(ost->fifo, audio_buf, frame_bytes, NULL); ret = avcodec_encode_audio(enc, audio_out, audio_out_size, (short *)audio_buf); if (ret < 0) { fprintf(stderr, "Audio encoding failed\n"); ffmpeg_exit(1); } audio_size += ret; pkt.stream_index= ost->index; pkt.data= audio_out; pkt.size= ret; if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE) pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base); pkt.flags |= AV_PKT_FLAG_KEY; write_frame(s, &pkt, enc, bitstream_filters[ost->file_index][pkt.stream_index]); ost->sync_opts += enc->frame_size; } } else { AVPacket pkt; av_init_packet(&pkt); ost->sync_opts += size_out / (osize * enc->channels); size_out /= osize; if (coded_bps) size_out = size_out*coded_bps/8; if(size_out > audio_out_size){ fprintf(stderr, "Internal error, buffer size too small\n"); ffmpeg_exit(1); } ret = avcodec_encode_audio(enc, audio_out, size_out, (short *)buftmp); if (ret < 0) { fprintf(stderr, "Audio encoding failed\n"); ffmpeg_exit(1); } audio_size += ret; pkt.stream_index= ost->index; pkt.data= audio_out; pkt.size= ret; if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE) pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base); pkt.flags |= AV_PKT_FLAG_KEY; write_frame(s, &pkt, enc, bitstream_filters[ost->file_index][pkt.stream_index]); } }
{ "code": [], "line_no": [] }
static void FUNC_0(AVFormatContext *VAR_0, AVOutputStream *VAR_1, AVInputStream *VAR_2, unsigned char *VAR_3, int VAR_4) { uint8_t *buftmp; int64_t audio_out_size, audio_buf_size; int64_t allocated_for_size= VAR_4; int VAR_5, VAR_6, VAR_7; AVCodecContext *enc= VAR_1->st->codec; AVCodecContext *dec= VAR_2->st->codec; int VAR_8= av_get_bits_per_sample_format(enc->sample_fmt)/8; int VAR_9= av_get_bits_per_sample_format(dec->sample_fmt)/8; const int VAR_10 = av_get_bits_per_sample(enc->codec->id); need_realloc: audio_buf_size= (allocated_for_size + VAR_9*dec->channels - 1) / (VAR_9*dec->channels); audio_buf_size= (audio_buf_size*enc->sample_rate + dec->sample_rate) / dec->sample_rate; audio_buf_size= audio_buf_size*2 + 10000; audio_buf_size= FFMAX(audio_buf_size, enc->frame_size); audio_buf_size*= VAR_8*enc->channels; audio_out_size= FFMAX(audio_buf_size, enc->frame_size * VAR_8 * enc->channels); if(VAR_10 > 8*VAR_8) audio_out_size= audio_out_size * VAR_10 / (8*VAR_8); audio_out_size += FF_MIN_BUFFER_SIZE; if(audio_out_size > INT_MAX || audio_buf_size > INT_MAX){ fprintf(stderr, "Buffer sizes too large\n"); ffmpeg_exit(1); } av_fast_malloc(&audio_buf, &allocated_audio_buf_size, audio_buf_size); av_fast_malloc(&audio_out, &allocated_audio_out_size, audio_out_size); if (!audio_buf || !audio_out){ fprintf(stderr, "Out of memory in FUNC_0\n"); ffmpeg_exit(1); } if (enc->channels != dec->channels) VAR_1->audio_resample = 1; if (VAR_1->audio_resample && !VAR_1->resample) { if (dec->sample_fmt != SAMPLE_FMT_S16) fprintf(stderr, "Warning, using s16 intermediate sample format for resampling\n"); VAR_1->resample = av_audio_resample_init(enc->channels, dec->channels, enc->sample_rate, dec->sample_rate, enc->sample_fmt, dec->sample_fmt, 16, 10, 0, 0.8); if (!VAR_1->resample) { fprintf(stderr, "Can not resample %d channels @ %d Hz to %d channels @ %d Hz\n", dec->channels, dec->sample_rate, enc->channels, enc->sample_rate); ffmpeg_exit(1); } } #define MAKE_SFMT_PAIR(a,b) ((a)+SAMPLE_FMT_NB*(b)) if (!VAR_1->audio_resample && dec->sample_fmt!=enc->sample_fmt && MAKE_SFMT_PAIR(enc->sample_fmt,dec->sample_fmt)!=VAR_1->reformat_pair) { if (VAR_1->reformat_ctx) av_audio_convert_free(VAR_1->reformat_ctx); VAR_1->reformat_ctx = av_audio_convert_alloc(enc->sample_fmt, 1, dec->sample_fmt, 1, NULL, 0); if (!VAR_1->reformat_ctx) { fprintf(stderr, "Cannot convert %VAR_0 sample format to %VAR_0 sample format\n", avcodec_get_sample_fmt_name(dec->sample_fmt), avcodec_get_sample_fmt_name(enc->sample_fmt)); ffmpeg_exit(1); } VAR_1->reformat_pair=MAKE_SFMT_PAIR(enc->sample_fmt,dec->sample_fmt); } if(audio_sync_method){ double VAR_11 = get_sync_ipts(VAR_1) * enc->sample_rate - VAR_1->sync_opts - av_fifo_size(VAR_1->fifo)/(enc->channels * 2); double VAR_12= VAR_11*dec->sample_rate / enc->sample_rate; int VAR_13= ((int)VAR_12)*2*dec->channels; if(fabs(VAR_11) > 50){ if(VAR_2->is_start || fabs(VAR_11) > audio_drift_threshold*enc->sample_rate){ if(VAR_13 < 0){ VAR_13= FFMAX(VAR_13, -VAR_4); VAR_4 += VAR_13; VAR_3 -= VAR_13; if(verbose > 2) fprintf(stderr, "discarding %d audio samples\n", (int)-VAR_11); if(!VAR_4) return; VAR_2->is_start=0; }else{ static uint8_t *VAR_14= NULL; VAR_14= av_realloc(VAR_14, VAR_13 + VAR_4); if(VAR_13 > allocated_for_size - VAR_4){ allocated_for_size= VAR_13 + (int64_t)VAR_4; goto need_realloc; } VAR_2->is_start=0; memset(VAR_14, 0, VAR_13); memcpy(VAR_14 + VAR_13, VAR_3, VAR_4); VAR_3= VAR_14; VAR_4 += VAR_13; if(verbose > 2) fprintf(stderr, "adding %d audio samples of silence\n", (int)VAR_11); } }else if(audio_sync_method>1){ int VAR_15= av_clip(VAR_11, -audio_sync_method, audio_sync_method); assert(VAR_1->audio_resample); if(verbose > 2) fprintf(stderr, "compensating audio timestamp drift:%f compensation:%d in:%d\n", VAR_11, VAR_15, enc->sample_rate); av_resample_compensate(*(struct AVResampleContext**)VAR_1->resample, VAR_15, enc->sample_rate); } } }else VAR_1->sync_opts= lrintf(get_sync_ipts(VAR_1) * enc->sample_rate) - av_fifo_size(VAR_1->fifo)/(enc->channels * 2); if (VAR_1->audio_resample) { buftmp = audio_buf; VAR_5 = audio_resample(VAR_1->resample, (short *)buftmp, (short *)VAR_3, VAR_4 / (dec->channels * VAR_9)); VAR_5 = VAR_5 * enc->channels * VAR_8; } else { buftmp = VAR_3; VAR_5 = VAR_4; } if (!VAR_1->audio_resample && dec->sample_fmt!=enc->sample_fmt) { const void *VAR_16[6]= {buftmp}; void *VAR_17[6]= {audio_buf}; int VAR_18[6]= {VAR_9}; int VAR_19[6]= {VAR_8}; int VAR_20= VAR_5/VAR_18[0]; if (av_audio_convert(VAR_1->reformat_ctx, VAR_17, VAR_19, VAR_16, VAR_18, VAR_20)<0) { printf("av_audio_convert() failed\n"); if (exit_on_error) ffmpeg_exit(1); return; } buftmp = audio_buf; VAR_5 = VAR_20*VAR_8; } if (enc->frame_size > 1) { if (av_fifo_realloc2(VAR_1->fifo, av_fifo_size(VAR_1->fifo) + VAR_5) < 0) { fprintf(stderr, "av_fifo_realloc2() failed\n"); ffmpeg_exit(1); } av_fifo_generic_write(VAR_1->fifo, buftmp, VAR_5, NULL); VAR_6 = enc->frame_size * VAR_8 * enc->channels; while (av_fifo_size(VAR_1->fifo) >= VAR_6) { AVPacket pkt; av_init_packet(&pkt); av_fifo_generic_read(VAR_1->fifo, audio_buf, VAR_6, NULL); VAR_7 = avcodec_encode_audio(enc, audio_out, audio_out_size, (short *)audio_buf); if (VAR_7 < 0) { fprintf(stderr, "Audio encoding failed\n"); ffmpeg_exit(1); } audio_size += VAR_7; pkt.stream_index= VAR_1->index; pkt.data= audio_out; pkt.VAR_4= VAR_7; if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE) pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, VAR_1->st->time_base); pkt.flags |= AV_PKT_FLAG_KEY; write_frame(VAR_0, &pkt, enc, bitstream_filters[VAR_1->file_index][pkt.stream_index]); VAR_1->sync_opts += enc->frame_size; } } else { AVPacket pkt; av_init_packet(&pkt); VAR_1->sync_opts += VAR_5 / (VAR_8 * enc->channels); VAR_5 /= VAR_8; if (VAR_10) VAR_5 = VAR_5*VAR_10/8; if(VAR_5 > audio_out_size){ fprintf(stderr, "Internal error, buffer VAR_4 too small\n"); ffmpeg_exit(1); } VAR_7 = avcodec_encode_audio(enc, audio_out, VAR_5, (short *)buftmp); if (VAR_7 < 0) { fprintf(stderr, "Audio encoding failed\n"); ffmpeg_exit(1); } audio_size += VAR_7; pkt.stream_index= VAR_1->index; pkt.data= audio_out; pkt.VAR_4= VAR_7; if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE) pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, VAR_1->st->time_base); pkt.flags |= AV_PKT_FLAG_KEY; write_frame(VAR_0, &pkt, enc, bitstream_filters[VAR_1->file_index][pkt.stream_index]); } }
[ "static void FUNC_0(AVFormatContext *VAR_0,\nAVOutputStream *VAR_1,\nAVInputStream *VAR_2,\nunsigned char *VAR_3, int VAR_4)\n{", "uint8_t *buftmp;", "int64_t audio_out_size, audio_buf_size;", "int64_t allocated_for_size= VAR_4;", "int VAR_5, VAR_6, VAR_7;", "AVCodecContext *enc= VAR_1->st->codec;", "AVCodecContext *dec= VAR_2->st->codec;", "int VAR_8= av_get_bits_per_sample_format(enc->sample_fmt)/8;", "int VAR_9= av_get_bits_per_sample_format(dec->sample_fmt)/8;", "const int VAR_10 = av_get_bits_per_sample(enc->codec->id);", "need_realloc:\naudio_buf_size= (allocated_for_size + VAR_9*dec->channels - 1) / (VAR_9*dec->channels);", "audio_buf_size= (audio_buf_size*enc->sample_rate + dec->sample_rate) / dec->sample_rate;", "audio_buf_size= audio_buf_size*2 + 10000;", "audio_buf_size= FFMAX(audio_buf_size, enc->frame_size);", "audio_buf_size*= VAR_8*enc->channels;", "audio_out_size= FFMAX(audio_buf_size, enc->frame_size * VAR_8 * enc->channels);", "if(VAR_10 > 8*VAR_8)\naudio_out_size= audio_out_size * VAR_10 / (8*VAR_8);", "audio_out_size += FF_MIN_BUFFER_SIZE;", "if(audio_out_size > INT_MAX || audio_buf_size > INT_MAX){", "fprintf(stderr, \"Buffer sizes too large\\n\");", "ffmpeg_exit(1);", "}", "av_fast_malloc(&audio_buf, &allocated_audio_buf_size, audio_buf_size);", "av_fast_malloc(&audio_out, &allocated_audio_out_size, audio_out_size);", "if (!audio_buf || !audio_out){", "fprintf(stderr, \"Out of memory in FUNC_0\\n\");", "ffmpeg_exit(1);", "}", "if (enc->channels != dec->channels)\nVAR_1->audio_resample = 1;", "if (VAR_1->audio_resample && !VAR_1->resample) {", "if (dec->sample_fmt != SAMPLE_FMT_S16)\nfprintf(stderr, \"Warning, using s16 intermediate sample format for resampling\\n\");", "VAR_1->resample = av_audio_resample_init(enc->channels, dec->channels,\nenc->sample_rate, dec->sample_rate,\nenc->sample_fmt, dec->sample_fmt,\n16, 10, 0, 0.8);", "if (!VAR_1->resample) {", "fprintf(stderr, \"Can not resample %d channels @ %d Hz to %d channels @ %d Hz\\n\",\ndec->channels, dec->sample_rate,\nenc->channels, enc->sample_rate);", "ffmpeg_exit(1);", "}", "}", "#define MAKE_SFMT_PAIR(a,b) ((a)+SAMPLE_FMT_NB*(b))\nif (!VAR_1->audio_resample && dec->sample_fmt!=enc->sample_fmt &&\nMAKE_SFMT_PAIR(enc->sample_fmt,dec->sample_fmt)!=VAR_1->reformat_pair) {", "if (VAR_1->reformat_ctx)\nav_audio_convert_free(VAR_1->reformat_ctx);", "VAR_1->reformat_ctx = av_audio_convert_alloc(enc->sample_fmt, 1,\ndec->sample_fmt, 1, NULL, 0);", "if (!VAR_1->reformat_ctx) {", "fprintf(stderr, \"Cannot convert %VAR_0 sample format to %VAR_0 sample format\\n\",\navcodec_get_sample_fmt_name(dec->sample_fmt),\navcodec_get_sample_fmt_name(enc->sample_fmt));", "ffmpeg_exit(1);", "}", "VAR_1->reformat_pair=MAKE_SFMT_PAIR(enc->sample_fmt,dec->sample_fmt);", "}", "if(audio_sync_method){", "double VAR_11 = get_sync_ipts(VAR_1) * enc->sample_rate - VAR_1->sync_opts\n- av_fifo_size(VAR_1->fifo)/(enc->channels * 2);", "double VAR_12= VAR_11*dec->sample_rate / enc->sample_rate;", "int VAR_13= ((int)VAR_12)*2*dec->channels;", "if(fabs(VAR_11) > 50){", "if(VAR_2->is_start || fabs(VAR_11) > audio_drift_threshold*enc->sample_rate){", "if(VAR_13 < 0){", "VAR_13= FFMAX(VAR_13, -VAR_4);", "VAR_4 += VAR_13;", "VAR_3 -= VAR_13;", "if(verbose > 2)\nfprintf(stderr, \"discarding %d audio samples\\n\", (int)-VAR_11);", "if(!VAR_4)\nreturn;", "VAR_2->is_start=0;", "}else{", "static uint8_t *VAR_14= NULL;", "VAR_14= av_realloc(VAR_14, VAR_13 + VAR_4);", "if(VAR_13 > allocated_for_size - VAR_4){", "allocated_for_size= VAR_13 + (int64_t)VAR_4;", "goto need_realloc;", "}", "VAR_2->is_start=0;", "memset(VAR_14, 0, VAR_13);", "memcpy(VAR_14 + VAR_13, VAR_3, VAR_4);", "VAR_3= VAR_14;", "VAR_4 += VAR_13;", "if(verbose > 2)\nfprintf(stderr, \"adding %d audio samples of silence\\n\", (int)VAR_11);", "}", "}else if(audio_sync_method>1){", "int VAR_15= av_clip(VAR_11, -audio_sync_method, audio_sync_method);", "assert(VAR_1->audio_resample);", "if(verbose > 2)\nfprintf(stderr, \"compensating audio timestamp drift:%f compensation:%d in:%d\\n\", VAR_11, VAR_15, enc->sample_rate);", "av_resample_compensate(*(struct AVResampleContext**)VAR_1->resample, VAR_15, enc->sample_rate);", "}", "}", "}else", "VAR_1->sync_opts= lrintf(get_sync_ipts(VAR_1) * enc->sample_rate)\n- av_fifo_size(VAR_1->fifo)/(enc->channels * 2);", "if (VAR_1->audio_resample) {", "buftmp = audio_buf;", "VAR_5 = audio_resample(VAR_1->resample,\n(short *)buftmp, (short *)VAR_3,\nVAR_4 / (dec->channels * VAR_9));", "VAR_5 = VAR_5 * enc->channels * VAR_8;", "} else {", "buftmp = VAR_3;", "VAR_5 = VAR_4;", "}", "if (!VAR_1->audio_resample && dec->sample_fmt!=enc->sample_fmt) {", "const void *VAR_16[6]= {buftmp};", "void *VAR_17[6]= {audio_buf};", "int VAR_18[6]= {VAR_9};", "int VAR_19[6]= {VAR_8};", "int VAR_20= VAR_5/VAR_18[0];", "if (av_audio_convert(VAR_1->reformat_ctx, VAR_17, VAR_19, VAR_16, VAR_18, VAR_20)<0) {", "printf(\"av_audio_convert() failed\\n\");", "if (exit_on_error)\nffmpeg_exit(1);", "return;", "}", "buftmp = audio_buf;", "VAR_5 = VAR_20*VAR_8;", "}", "if (enc->frame_size > 1) {", "if (av_fifo_realloc2(VAR_1->fifo, av_fifo_size(VAR_1->fifo) + VAR_5) < 0) {", "fprintf(stderr, \"av_fifo_realloc2() failed\\n\");", "ffmpeg_exit(1);", "}", "av_fifo_generic_write(VAR_1->fifo, buftmp, VAR_5, NULL);", "VAR_6 = enc->frame_size * VAR_8 * enc->channels;", "while (av_fifo_size(VAR_1->fifo) >= VAR_6) {", "AVPacket pkt;", "av_init_packet(&pkt);", "av_fifo_generic_read(VAR_1->fifo, audio_buf, VAR_6, NULL);", "VAR_7 = avcodec_encode_audio(enc, audio_out, audio_out_size,\n(short *)audio_buf);", "if (VAR_7 < 0) {", "fprintf(stderr, \"Audio encoding failed\\n\");", "ffmpeg_exit(1);", "}", "audio_size += VAR_7;", "pkt.stream_index= VAR_1->index;", "pkt.data= audio_out;", "pkt.VAR_4= VAR_7;", "if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE)\npkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, VAR_1->st->time_base);", "pkt.flags |= AV_PKT_FLAG_KEY;", "write_frame(VAR_0, &pkt, enc, bitstream_filters[VAR_1->file_index][pkt.stream_index]);", "VAR_1->sync_opts += enc->frame_size;", "}", "} else {", "AVPacket pkt;", "av_init_packet(&pkt);", "VAR_1->sync_opts += VAR_5 / (VAR_8 * enc->channels);", "VAR_5 /= VAR_8;", "if (VAR_10)\nVAR_5 = VAR_5*VAR_10/8;", "if(VAR_5 > audio_out_size){", "fprintf(stderr, \"Internal error, buffer VAR_4 too small\\n\");", "ffmpeg_exit(1);", "}", "VAR_7 = avcodec_encode_audio(enc, audio_out, VAR_5,\n(short *)buftmp);", "if (VAR_7 < 0) {", "fprintf(stderr, \"Audio encoding failed\\n\");", "ffmpeg_exit(1);", "}", "audio_size += VAR_7;", "pkt.stream_index= VAR_1->index;", "pkt.data= audio_out;", "pkt.VAR_4= VAR_7;", "if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE)\npkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, VAR_1->st->time_base);", "pkt.flags |= AV_PKT_FLAG_KEY;", "write_frame(VAR_0, &pkt, enc, bitstream_filters[VAR_1->file_index][pkt.stream_index]);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49, 51 ], [ 53 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 81, 83 ], [ 87 ], [ 89, 91 ], [ 93, 95, 97, 99 ], [ 101 ], [ 103, 105, 107 ], [ 109 ], [ 111 ], [ 113 ], [ 117, 119, 121 ], [ 123, 125 ], [ 127, 129 ], [ 131 ], [ 133, 135, 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 149 ], [ 151, 153 ], [ 155 ], [ 157 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175, 177 ], [ 179, 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213, 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225, 227 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 239, 241 ], [ 245 ], [ 247 ], [ 249, 251, 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 277 ], [ 279 ], [ 281 ], [ 283, 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293 ], [ 295 ], [ 301 ], [ 305 ], [ 307 ], [ 309 ], [ 311 ], [ 313 ], [ 317 ], [ 321 ], [ 323 ], [ 325 ], [ 329 ], [ 337, 339 ], [ 341 ], [ 343 ], [ 345 ], [ 347 ], [ 349 ], [ 351 ], [ 353 ], [ 355 ], [ 357, 359 ], [ 361 ], [ 363 ], [ 367 ], [ 369 ], [ 371 ], [ 373 ], [ 375 ], [ 379 ], [ 387 ], [ 389, 391 ], [ 395 ], [ 397 ], [ 399 ], [ 401 ], [ 407, 409 ], [ 411 ], [ 413 ], [ 415 ], [ 417 ], [ 419 ], [ 421 ], [ 423 ], [ 425 ], [ 427, 429 ], [ 431 ], [ 433 ], [ 435 ], [ 437 ] ]
6,104
static int emulated_initfn(CCIDCardState *base) { EmulatedState *card = DO_UPCAST(EmulatedState, base, base); VCardEmulError ret; const EnumTable *ptable; QSIMPLEQ_INIT(&card->event_list); QSIMPLEQ_INIT(&card->guest_apdu_list); qemu_mutex_init(&card->event_list_mutex); qemu_mutex_init(&card->vreader_mutex); qemu_mutex_init(&card->handle_apdu_mutex); qemu_cond_init(&card->handle_apdu_cond); card->reader = NULL; card->quit_apdu_thread = 0; if (init_pipe_signaling(card) < 0) { return -1; } card->backend = parse_enumeration(card->backend_str, backend_enum_table, 0); if (card->backend == 0) { printf("unknown backend, must be one of:\n"); for (ptable = backend_enum_table; ptable->name != NULL; ++ptable) { printf("%s\n", ptable->name); } return -1; } /* TODO: a passthru backened that works on local machine. third card type?*/ if (card->backend == BACKEND_CERTIFICATES) { if (card->cert1 != NULL && card->cert2 != NULL && card->cert3 != NULL) { ret = emulated_initialize_vcard_from_certificates(card); } else { printf("%s: you must provide all three certs for" " certificates backend\n", EMULATED_DEV_NAME); return -1; } } else { if (card->backend != BACKEND_NSS_EMULATED) { printf("%s: bad backend specified. The options are:\n%s (default)," " %s.\n", EMULATED_DEV_NAME, BACKEND_NSS_EMULATED_NAME, BACKEND_CERTIFICATES_NAME); return -1; } if (card->cert1 != NULL || card->cert2 != NULL || card->cert3 != NULL) { printf("%s: unexpected cert parameters to nss emulated backend\n", EMULATED_DEV_NAME); return -1; } /* default to mirroring the local hardware readers */ ret = wrap_vcard_emul_init(NULL); } if (ret != VCARD_EMUL_OK) { printf("%s: failed to initialize vcard\n", EMULATED_DEV_NAME); return -1; } qemu_thread_create(&card->event_thread_id, event_thread, card, QEMU_THREAD_JOINABLE); qemu_thread_create(&card->apdu_thread_id, handle_apdu_thread, card, QEMU_THREAD_JOINABLE); return 0; }
true
qemu
ae12e3a643c66575c77211e1226ada041e56b889
static int emulated_initfn(CCIDCardState *base) { EmulatedState *card = DO_UPCAST(EmulatedState, base, base); VCardEmulError ret; const EnumTable *ptable; QSIMPLEQ_INIT(&card->event_list); QSIMPLEQ_INIT(&card->guest_apdu_list); qemu_mutex_init(&card->event_list_mutex); qemu_mutex_init(&card->vreader_mutex); qemu_mutex_init(&card->handle_apdu_mutex); qemu_cond_init(&card->handle_apdu_cond); card->reader = NULL; card->quit_apdu_thread = 0; if (init_pipe_signaling(card) < 0) { return -1; } card->backend = parse_enumeration(card->backend_str, backend_enum_table, 0); if (card->backend == 0) { printf("unknown backend, must be one of:\n"); for (ptable = backend_enum_table; ptable->name != NULL; ++ptable) { printf("%s\n", ptable->name); } return -1; } if (card->backend == BACKEND_CERTIFICATES) { if (card->cert1 != NULL && card->cert2 != NULL && card->cert3 != NULL) { ret = emulated_initialize_vcard_from_certificates(card); } else { printf("%s: you must provide all three certs for" " certificates backend\n", EMULATED_DEV_NAME); return -1; } } else { if (card->backend != BACKEND_NSS_EMULATED) { printf("%s: bad backend specified. The options are:\n%s (default)," " %s.\n", EMULATED_DEV_NAME, BACKEND_NSS_EMULATED_NAME, BACKEND_CERTIFICATES_NAME); return -1; } if (card->cert1 != NULL || card->cert2 != NULL || card->cert3 != NULL) { printf("%s: unexpected cert parameters to nss emulated backend\n", EMULATED_DEV_NAME); return -1; } ret = wrap_vcard_emul_init(NULL); } if (ret != VCARD_EMUL_OK) { printf("%s: failed to initialize vcard\n", EMULATED_DEV_NAME); return -1; } qemu_thread_create(&card->event_thread_id, event_thread, card, QEMU_THREAD_JOINABLE); qemu_thread_create(&card->apdu_thread_id, handle_apdu_thread, card, QEMU_THREAD_JOINABLE); return 0; }
{ "code": [ " card->backend = parse_enumeration(card->backend_str, backend_enum_table, 0);", " printf(\"unknown backend, must be one of:\\n\");" ], "line_no": [ 35, 39 ] }
static int FUNC_0(CCIDCardState *VAR_0) { EmulatedState *card = DO_UPCAST(EmulatedState, VAR_0, VAR_0); VCardEmulError ret; const EnumTable *VAR_1; QSIMPLEQ_INIT(&card->event_list); QSIMPLEQ_INIT(&card->guest_apdu_list); qemu_mutex_init(&card->event_list_mutex); qemu_mutex_init(&card->vreader_mutex); qemu_mutex_init(&card->handle_apdu_mutex); qemu_cond_init(&card->handle_apdu_cond); card->reader = NULL; card->quit_apdu_thread = 0; if (init_pipe_signaling(card) < 0) { return -1; } card->backend = parse_enumeration(card->backend_str, backend_enum_table, 0); if (card->backend == 0) { printf("unknown backend, must be one of:\n"); for (VAR_1 = backend_enum_table; VAR_1->name != NULL; ++VAR_1) { printf("%s\n", VAR_1->name); } return -1; } if (card->backend == BACKEND_CERTIFICATES) { if (card->cert1 != NULL && card->cert2 != NULL && card->cert3 != NULL) { ret = emulated_initialize_vcard_from_certificates(card); } else { printf("%s: you must provide all three certs for" " certificates backend\n", EMULATED_DEV_NAME); return -1; } } else { if (card->backend != BACKEND_NSS_EMULATED) { printf("%s: bad backend specified. The options are:\n%s (default)," " %s.\n", EMULATED_DEV_NAME, BACKEND_NSS_EMULATED_NAME, BACKEND_CERTIFICATES_NAME); return -1; } if (card->cert1 != NULL || card->cert2 != NULL || card->cert3 != NULL) { printf("%s: unexpected cert parameters to nss emulated backend\n", EMULATED_DEV_NAME); return -1; } ret = wrap_vcard_emul_init(NULL); } if (ret != VCARD_EMUL_OK) { printf("%s: failed to initialize vcard\n", EMULATED_DEV_NAME); return -1; } qemu_thread_create(&card->event_thread_id, event_thread, card, QEMU_THREAD_JOINABLE); qemu_thread_create(&card->apdu_thread_id, handle_apdu_thread, card, QEMU_THREAD_JOINABLE); return 0; }
[ "static int FUNC_0(CCIDCardState *VAR_0)\n{", "EmulatedState *card = DO_UPCAST(EmulatedState, VAR_0, VAR_0);", "VCardEmulError ret;", "const EnumTable *VAR_1;", "QSIMPLEQ_INIT(&card->event_list);", "QSIMPLEQ_INIT(&card->guest_apdu_list);", "qemu_mutex_init(&card->event_list_mutex);", "qemu_mutex_init(&card->vreader_mutex);", "qemu_mutex_init(&card->handle_apdu_mutex);", "qemu_cond_init(&card->handle_apdu_cond);", "card->reader = NULL;", "card->quit_apdu_thread = 0;", "if (init_pipe_signaling(card) < 0) {", "return -1;", "}", "card->backend = parse_enumeration(card->backend_str, backend_enum_table, 0);", "if (card->backend == 0) {", "printf(\"unknown backend, must be one of:\\n\");", "for (VAR_1 = backend_enum_table; VAR_1->name != NULL; ++VAR_1) {", "printf(\"%s\\n\", VAR_1->name);", "}", "return -1;", "}", "if (card->backend == BACKEND_CERTIFICATES) {", "if (card->cert1 != NULL && card->cert2 != NULL && card->cert3 != NULL) {", "ret = emulated_initialize_vcard_from_certificates(card);", "} else {", "printf(\"%s: you must provide all three certs for\"\n\" certificates backend\\n\", EMULATED_DEV_NAME);", "return -1;", "}", "} else {", "if (card->backend != BACKEND_NSS_EMULATED) {", "printf(\"%s: bad backend specified. The options are:\\n%s (default),\"\n\" %s.\\n\", EMULATED_DEV_NAME, BACKEND_NSS_EMULATED_NAME,\nBACKEND_CERTIFICATES_NAME);", "return -1;", "}", "if (card->cert1 != NULL || card->cert2 != NULL || card->cert3 != NULL) {", "printf(\"%s: unexpected cert parameters to nss emulated backend\\n\",\nEMULATED_DEV_NAME);", "return -1;", "}", "ret = wrap_vcard_emul_init(NULL);", "}", "if (ret != VCARD_EMUL_OK) {", "printf(\"%s: failed to initialize vcard\\n\", EMULATED_DEV_NAME);", "return -1;", "}", "qemu_thread_create(&card->event_thread_id, event_thread, card,\nQEMU_THREAD_JOINABLE);", "qemu_thread_create(&card->apdu_thread_id, handle_apdu_thread, card,\nQEMU_THREAD_JOINABLE);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63, 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75, 77, 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87, 89 ], [ 91 ], [ 93 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109, 111 ], [ 113, 115 ], [ 117 ], [ 119 ] ]
6,105
static void mirror_exit(BlockJob *job, void *opaque) { MirrorBlockJob *s = container_of(job, MirrorBlockJob, common); MirrorExitData *data = opaque; AioContext *replace_aio_context = NULL; BlockDriverState *src = blk_bs(s->common.blk); BlockDriverState *target_bs = blk_bs(s->target); /* Make sure that the source BDS doesn't go away before we called * block_job_completed(). */ bdrv_ref(src); if (s->to_replace) { replace_aio_context = bdrv_get_aio_context(s->to_replace); aio_context_acquire(replace_aio_context); } if (s->should_complete && data->ret == 0) { BlockDriverState *to_replace = src; if (s->to_replace) { to_replace = s->to_replace; } if (bdrv_get_flags(target_bs) != bdrv_get_flags(to_replace)) { bdrv_reopen(target_bs, bdrv_get_flags(to_replace), NULL); } /* The mirror job has no requests in flight any more, but we need to * drain potential other users of the BDS before changing the graph. */ bdrv_drained_begin(target_bs); bdrv_replace_in_backing_chain(to_replace, target_bs); bdrv_drained_end(target_bs); /* We just changed the BDS the job BB refers to */ blk_remove_bs(job->blk); blk_insert_bs(job->blk, src); } if (s->to_replace) { bdrv_op_unblock_all(s->to_replace, s->replace_blocker); error_free(s->replace_blocker); bdrv_unref(s->to_replace); } if (replace_aio_context) { aio_context_release(replace_aio_context); } g_free(s->replaces); bdrv_op_unblock_all(target_bs, s->common.blocker); blk_unref(s->target); block_job_completed(&s->common, data->ret); g_free(data); bdrv_drained_end(src); if (qemu_get_aio_context() == bdrv_get_aio_context(src)) { aio_enable_external(iohandler_get_aio_context()); } bdrv_unref(src); }
true
qemu
d4a92a8420ac764f21652322aa7d4e49cfcbc607
static void mirror_exit(BlockJob *job, void *opaque) { MirrorBlockJob *s = container_of(job, MirrorBlockJob, common); MirrorExitData *data = opaque; AioContext *replace_aio_context = NULL; BlockDriverState *src = blk_bs(s->common.blk); BlockDriverState *target_bs = blk_bs(s->target); bdrv_ref(src); if (s->to_replace) { replace_aio_context = bdrv_get_aio_context(s->to_replace); aio_context_acquire(replace_aio_context); } if (s->should_complete && data->ret == 0) { BlockDriverState *to_replace = src; if (s->to_replace) { to_replace = s->to_replace; } if (bdrv_get_flags(target_bs) != bdrv_get_flags(to_replace)) { bdrv_reopen(target_bs, bdrv_get_flags(to_replace), NULL); } bdrv_drained_begin(target_bs); bdrv_replace_in_backing_chain(to_replace, target_bs); bdrv_drained_end(target_bs); blk_remove_bs(job->blk); blk_insert_bs(job->blk, src); } if (s->to_replace) { bdrv_op_unblock_all(s->to_replace, s->replace_blocker); error_free(s->replace_blocker); bdrv_unref(s->to_replace); } if (replace_aio_context) { aio_context_release(replace_aio_context); } g_free(s->replaces); bdrv_op_unblock_all(target_bs, s->common.blocker); blk_unref(s->target); block_job_completed(&s->common, data->ret); g_free(data); bdrv_drained_end(src); if (qemu_get_aio_context() == bdrv_get_aio_context(src)) { aio_enable_external(iohandler_get_aio_context()); } bdrv_unref(src); }
{ "code": [ " if (qemu_get_aio_context() == bdrv_get_aio_context(src)) {", " aio_enable_external(iohandler_get_aio_context());" ], "line_no": [ 103, 105 ] }
static void FUNC_0(BlockJob *VAR_0, void *VAR_1) { MirrorBlockJob *s = container_of(VAR_0, MirrorBlockJob, common); MirrorExitData *data = VAR_1; AioContext *replace_aio_context = NULL; BlockDriverState *src = blk_bs(s->common.blk); BlockDriverState *target_bs = blk_bs(s->target); bdrv_ref(src); if (s->to_replace) { replace_aio_context = bdrv_get_aio_context(s->to_replace); aio_context_acquire(replace_aio_context); } if (s->should_complete && data->ret == 0) { BlockDriverState *to_replace = src; if (s->to_replace) { to_replace = s->to_replace; } if (bdrv_get_flags(target_bs) != bdrv_get_flags(to_replace)) { bdrv_reopen(target_bs, bdrv_get_flags(to_replace), NULL); } bdrv_drained_begin(target_bs); bdrv_replace_in_backing_chain(to_replace, target_bs); bdrv_drained_end(target_bs); blk_remove_bs(VAR_0->blk); blk_insert_bs(VAR_0->blk, src); } if (s->to_replace) { bdrv_op_unblock_all(s->to_replace, s->replace_blocker); error_free(s->replace_blocker); bdrv_unref(s->to_replace); } if (replace_aio_context) { aio_context_release(replace_aio_context); } g_free(s->replaces); bdrv_op_unblock_all(target_bs, s->common.blocker); blk_unref(s->target); block_job_completed(&s->common, data->ret); g_free(data); bdrv_drained_end(src); if (qemu_get_aio_context() == bdrv_get_aio_context(src)) { aio_enable_external(iohandler_get_aio_context()); } bdrv_unref(src); }
[ "static void FUNC_0(BlockJob *VAR_0, void *VAR_1)\n{", "MirrorBlockJob *s = container_of(VAR_0, MirrorBlockJob, common);", "MirrorExitData *data = VAR_1;", "AioContext *replace_aio_context = NULL;", "BlockDriverState *src = blk_bs(s->common.blk);", "BlockDriverState *target_bs = blk_bs(s->target);", "bdrv_ref(src);", "if (s->to_replace) {", "replace_aio_context = bdrv_get_aio_context(s->to_replace);", "aio_context_acquire(replace_aio_context);", "}", "if (s->should_complete && data->ret == 0) {", "BlockDriverState *to_replace = src;", "if (s->to_replace) {", "to_replace = s->to_replace;", "}", "if (bdrv_get_flags(target_bs) != bdrv_get_flags(to_replace)) {", "bdrv_reopen(target_bs, bdrv_get_flags(to_replace), NULL);", "}", "bdrv_drained_begin(target_bs);", "bdrv_replace_in_backing_chain(to_replace, target_bs);", "bdrv_drained_end(target_bs);", "blk_remove_bs(VAR_0->blk);", "blk_insert_bs(VAR_0->blk, src);", "}", "if (s->to_replace) {", "bdrv_op_unblock_all(s->to_replace, s->replace_blocker);", "error_free(s->replace_blocker);", "bdrv_unref(s->to_replace);", "}", "if (replace_aio_context) {", "aio_context_release(replace_aio_context);", "}", "g_free(s->replaces);", "bdrv_op_unblock_all(target_bs, s->common.blocker);", "blk_unref(s->target);", "block_job_completed(&s->common, data->ret);", "g_free(data);", "bdrv_drained_end(src);", "if (qemu_get_aio_context() == bdrv_get_aio_context(src)) {", "aio_enable_external(iohandler_get_aio_context());", "}", "bdrv_unref(src);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 59 ], [ 61 ], [ 63 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ] ]
6,106
static void init_proc_620 (CPUPPCState *env) { gen_spr_ne_601(env); gen_spr_620(env); /* Time base */ gen_tbl(env); /* Hardware implementation registers */ /* XXX : not implemented */ spr_register(env, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* Memory management */ gen_low_BATs(env); gen_high_BATs(env); init_excp_620(env); env->dcache_line_size = 64; env->icache_line_size = 64; /* XXX: TODO: initialize internal interrupt controller */ }
true
qemu
faadf50e2962dd54175647a80bd6fc4319c91973
static void init_proc_620 (CPUPPCState *env) { gen_spr_ne_601(env); gen_spr_620(env); gen_tbl(env); spr_register(env, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); gen_low_BATs(env); gen_high_BATs(env); init_excp_620(env); env->dcache_line_size = 64; env->icache_line_size = 64; }
{ "code": [ " 0x00000000);" ], "line_no": [ 23 ] }
static void FUNC_0 (CPUPPCState *VAR_0) { gen_spr_ne_601(VAR_0); gen_spr_620(VAR_0); gen_tbl(VAR_0); spr_register(VAR_0, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); gen_low_BATs(VAR_0); gen_high_BATs(VAR_0); init_excp_620(VAR_0); VAR_0->dcache_line_size = 64; VAR_0->icache_line_size = 64; }
[ "static void FUNC_0 (CPUPPCState *VAR_0)\n{", "gen_spr_ne_601(VAR_0);", "gen_spr_620(VAR_0);", "gen_tbl(VAR_0);", "spr_register(VAR_0, SPR_HID0, \"HID0\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\n0x00000000);", "gen_low_BATs(VAR_0);", "gen_high_BATs(VAR_0);", "init_excp_620(VAR_0);", "VAR_0->dcache_line_size = 64;", "VAR_0->icache_line_size = 64;", "}" ]
[ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 17, 19, 21, 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ] ]
6,109
static inline void gen_intermediate_code_internal(PowerPCCPU *cpu, TranslationBlock *tb, bool search_pc) { CPUState *cs = CPU(cpu); CPUPPCState *env = &cpu->env; DisasContext ctx, *ctxp = &ctx; opc_handler_t **table, *handler; target_ulong pc_start; uint16_t *gen_opc_end; CPUBreakpoint *bp; int j, lj = -1; int num_insns; int max_insns; pc_start = tb->pc; gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE; ctx.nip = pc_start; ctx.tb = tb; ctx.exception = POWERPC_EXCP_NONE; ctx.spr_cb = env->spr_cb; ctx.mem_idx = env->mmu_idx; ctx.insns_flags = env->insns_flags; ctx.insns_flags2 = env->insns_flags2; ctx.access_type = -1; ctx.le_mode = env->hflags & (1 << MSR_LE) ? 1 : 0; #if defined(TARGET_PPC64) ctx.sf_mode = msr_is_64bit(env, env->msr); ctx.has_cfar = !!(env->flags & POWERPC_FLAG_CFAR); #endif ctx.fpu_enabled = msr_fp; if ((env->flags & POWERPC_FLAG_SPE) && msr_spe) ctx.spe_enabled = msr_spe; else ctx.spe_enabled = 0; if ((env->flags & POWERPC_FLAG_VRE) && msr_vr) ctx.altivec_enabled = msr_vr; else ctx.altivec_enabled = 0; if ((env->flags & POWERPC_FLAG_VSX) && msr_vsx) { ctx.vsx_enabled = msr_vsx; } else { ctx.vsx_enabled = 0; if ((env->flags & POWERPC_FLAG_SE) && msr_se) ctx.singlestep_enabled = CPU_SINGLE_STEP; else ctx.singlestep_enabled = 0; if ((env->flags & POWERPC_FLAG_BE) && msr_be) ctx.singlestep_enabled |= CPU_BRANCH_STEP; if (unlikely(cs->singlestep_enabled)) { ctx.singlestep_enabled |= GDBSTUB_SINGLE_STEP; #if defined (DO_SINGLE_STEP) && 0 /* Single step trace mode */ msr_se = 1; #endif num_insns = 0; max_insns = tb->cflags & CF_COUNT_MASK; if (max_insns == 0) max_insns = CF_COUNT_MASK; gen_tb_start(); tcg_clear_temp_count(); /* Set env in case of segfault during code fetch */ while (ctx.exception == POWERPC_EXCP_NONE && tcg_ctx.gen_opc_ptr < gen_opc_end) { if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) { QTAILQ_FOREACH(bp, &cs->breakpoints, entry) { if (bp->pc == ctx.nip) { gen_debug_exception(ctxp); break; if (unlikely(search_pc)) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; if (lj < j) { lj++; while (lj < j) tcg_ctx.gen_opc_instr_start[lj++] = 0; tcg_ctx.gen_opc_pc[lj] = ctx.nip; tcg_ctx.gen_opc_instr_start[lj] = 1; tcg_ctx.gen_opc_icount[lj] = num_insns; LOG_DISAS("----------------\n"); LOG_DISAS("nip=" TARGET_FMT_lx " super=%d ir=%d\n", ctx.nip, ctx.mem_idx, (int)msr_ir); if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) gen_io_start(); if (unlikely(ctx.le_mode)) { ctx.opcode = bswap32(cpu_ldl_code(env, ctx.nip)); } else { ctx.opcode = cpu_ldl_code(env, ctx.nip); LOG_DISAS("translate opcode %08x (%02x %02x %02x) (%s)\n", ctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode), opc3(ctx.opcode), ctx.le_mode ? "little" : "big"); if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) { tcg_gen_debug_insn_start(ctx.nip); ctx.nip += 4; table = env->opcodes; num_insns++; handler = table[opc1(ctx.opcode)]; if (is_indirect_opcode(handler)) { table = ind_table(handler); handler = table[opc2(ctx.opcode)]; if (is_indirect_opcode(handler)) { table = ind_table(handler); handler = table[opc3(ctx.opcode)]; /* Is opcode *REALLY* valid ? */ if (unlikely(handler->handler == &gen_invalid)) { if (qemu_log_enabled()) { qemu_log("invalid/unsupported opcode: " "%02x - %02x - %02x (%08x) " TARGET_FMT_lx " %d\n", opc1(ctx.opcode), opc2(ctx.opcode), opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir); } else { uint32_t inval; if (unlikely(handler->type & (PPC_SPE | PPC_SPE_SINGLE | PPC_SPE_DOUBLE) && Rc(ctx.opcode))) { inval = handler->inval2; } else { inval = handler->inval1; if (unlikely((ctx.opcode & inval) != 0)) { if (qemu_log_enabled()) { qemu_log("invalid bits: %08x for opcode: " "%02x - %02x - %02x (%08x) " TARGET_FMT_lx "\n", ctx.opcode & inval, opc1(ctx.opcode), opc2(ctx.opcode), opc3(ctx.opcode), ctx.opcode, ctx.nip - 4); gen_inval_exception(ctxp, POWERPC_EXCP_INVAL_INVAL); break; (*(handler->handler))(&ctx); #if defined(DO_PPC_STATISTICS) handler->count++; #endif /* Check trace mode exceptions */ if (unlikely(ctx.singlestep_enabled & CPU_SINGLE_STEP && (ctx.nip <= 0x100 || ctx.nip > 0xF00) && ctx.exception != POWERPC_SYSCALL && ctx.exception != POWERPC_EXCP_TRAP && ctx.exception != POWERPC_EXCP_BRANCH)) { gen_exception(ctxp, POWERPC_EXCP_TRACE); } else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) || (cs->singlestep_enabled) || singlestep || num_insns >= max_insns)) { /* if we reach a page boundary or are single stepping, stop * generation */ break; if (tb->cflags & CF_LAST_IO) gen_io_end(); if (ctx.exception == POWERPC_EXCP_NONE) { gen_goto_tb(&ctx, 0, ctx.nip); } else if (ctx.exception != POWERPC_EXCP_BRANCH) { if (unlikely(cs->singlestep_enabled)) { gen_debug_exception(ctxp); /* Generate the return instruction */ tcg_gen_exit_tb(0); gen_tb_end(tb, num_insns); *tcg_ctx.gen_opc_ptr = INDEX_op_end; if (unlikely(search_pc)) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; lj++; while (lj <= j) tcg_ctx.gen_opc_instr_start[lj++] = 0; } else { tb->size = ctx.nip - pc_start; tb->icount = num_insns; #if defined(DEBUG_DISAS) if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { int flags; flags = env->bfd_mach; flags |= ctx.le_mode << 16; qemu_log("IN: %s\n", lookup_symbol(pc_start)); log_target_disas(env, pc_start, ctx.nip - pc_start, flags); qemu_log("\n"); #endif
true
qemu
3de31797825e94fd67ee7c2e877127acc3d2edbd
static inline void gen_intermediate_code_internal(PowerPCCPU *cpu, TranslationBlock *tb, bool search_pc) { CPUState *cs = CPU(cpu); CPUPPCState *env = &cpu->env; DisasContext ctx, *ctxp = &ctx; opc_handler_t **table, *handler; target_ulong pc_start; uint16_t *gen_opc_end; CPUBreakpoint *bp; int j, lj = -1; int num_insns; int max_insns; pc_start = tb->pc; gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE; ctx.nip = pc_start; ctx.tb = tb; ctx.exception = POWERPC_EXCP_NONE; ctx.spr_cb = env->spr_cb; ctx.mem_idx = env->mmu_idx; ctx.insns_flags = env->insns_flags; ctx.insns_flags2 = env->insns_flags2; ctx.access_type = -1; ctx.le_mode = env->hflags & (1 << MSR_LE) ? 1 : 0; #if defined(TARGET_PPC64) ctx.sf_mode = msr_is_64bit(env, env->msr); ctx.has_cfar = !!(env->flags & POWERPC_FLAG_CFAR); #endif ctx.fpu_enabled = msr_fp; if ((env->flags & POWERPC_FLAG_SPE) && msr_spe) ctx.spe_enabled = msr_spe; else ctx.spe_enabled = 0; if ((env->flags & POWERPC_FLAG_VRE) && msr_vr) ctx.altivec_enabled = msr_vr; else ctx.altivec_enabled = 0; if ((env->flags & POWERPC_FLAG_VSX) && msr_vsx) { ctx.vsx_enabled = msr_vsx; } else { ctx.vsx_enabled = 0; if ((env->flags & POWERPC_FLAG_SE) && msr_se) ctx.singlestep_enabled = CPU_SINGLE_STEP; else ctx.singlestep_enabled = 0; if ((env->flags & POWERPC_FLAG_BE) && msr_be) ctx.singlestep_enabled |= CPU_BRANCH_STEP; if (unlikely(cs->singlestep_enabled)) { ctx.singlestep_enabled |= GDBSTUB_SINGLE_STEP; #if defined (DO_SINGLE_STEP) && 0 msr_se = 1; #endif num_insns = 0; max_insns = tb->cflags & CF_COUNT_MASK; if (max_insns == 0) max_insns = CF_COUNT_MASK; gen_tb_start(); tcg_clear_temp_count(); while (ctx.exception == POWERPC_EXCP_NONE && tcg_ctx.gen_opc_ptr < gen_opc_end) { if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) { QTAILQ_FOREACH(bp, &cs->breakpoints, entry) { if (bp->pc == ctx.nip) { gen_debug_exception(ctxp); break; if (unlikely(search_pc)) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; if (lj < j) { lj++; while (lj < j) tcg_ctx.gen_opc_instr_start[lj++] = 0; tcg_ctx.gen_opc_pc[lj] = ctx.nip; tcg_ctx.gen_opc_instr_start[lj] = 1; tcg_ctx.gen_opc_icount[lj] = num_insns; LOG_DISAS("----------------\n"); LOG_DISAS("nip=" TARGET_FMT_lx " super=%d ir=%d\n", ctx.nip, ctx.mem_idx, (int)msr_ir); if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) gen_io_start(); if (unlikely(ctx.le_mode)) { ctx.opcode = bswap32(cpu_ldl_code(env, ctx.nip)); } else { ctx.opcode = cpu_ldl_code(env, ctx.nip); LOG_DISAS("translate opcode %08x (%02x %02x %02x) (%s)\n", ctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode), opc3(ctx.opcode), ctx.le_mode ? "little" : "big"); if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) { tcg_gen_debug_insn_start(ctx.nip); ctx.nip += 4; table = env->opcodes; num_insns++; handler = table[opc1(ctx.opcode)]; if (is_indirect_opcode(handler)) { table = ind_table(handler); handler = table[opc2(ctx.opcode)]; if (is_indirect_opcode(handler)) { table = ind_table(handler); handler = table[opc3(ctx.opcode)]; if (unlikely(handler->handler == &gen_invalid)) { if (qemu_log_enabled()) { qemu_log("invalid/unsupported opcode: " "%02x - %02x - %02x (%08x) " TARGET_FMT_lx " %d\n", opc1(ctx.opcode), opc2(ctx.opcode), opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir); } else { uint32_t inval; if (unlikely(handler->type & (PPC_SPE | PPC_SPE_SINGLE | PPC_SPE_DOUBLE) && Rc(ctx.opcode))) { inval = handler->inval2; } else { inval = handler->inval1; if (unlikely((ctx.opcode & inval) != 0)) { if (qemu_log_enabled()) { qemu_log("invalid bits: %08x for opcode: " "%02x - %02x - %02x (%08x) " TARGET_FMT_lx "\n", ctx.opcode & inval, opc1(ctx.opcode), opc2(ctx.opcode), opc3(ctx.opcode), ctx.opcode, ctx.nip - 4); gen_inval_exception(ctxp, POWERPC_EXCP_INVAL_INVAL); break; (*(handler->handler))(&ctx); #if defined(DO_PPC_STATISTICS) handler->count++; #endif if (unlikely(ctx.singlestep_enabled & CPU_SINGLE_STEP && (ctx.nip <= 0x100 || ctx.nip > 0xF00) && ctx.exception != POWERPC_SYSCALL && ctx.exception != POWERPC_EXCP_TRAP && ctx.exception != POWERPC_EXCP_BRANCH)) { gen_exception(ctxp, POWERPC_EXCP_TRACE); } else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) || (cs->singlestep_enabled) || singlestep || num_insns >= max_insns)) { break; if (tb->cflags & CF_LAST_IO) gen_io_end(); if (ctx.exception == POWERPC_EXCP_NONE) { gen_goto_tb(&ctx, 0, ctx.nip); } else if (ctx.exception != POWERPC_EXCP_BRANCH) { if (unlikely(cs->singlestep_enabled)) { gen_debug_exception(ctxp); tcg_gen_exit_tb(0); gen_tb_end(tb, num_insns); *tcg_ctx.gen_opc_ptr = INDEX_op_end; if (unlikely(search_pc)) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; lj++; while (lj <= j) tcg_ctx.gen_opc_instr_start[lj++] = 0; } else { tb->size = ctx.nip - pc_start; tb->icount = num_insns; #if defined(DEBUG_DISAS) if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { int flags; flags = env->bfd_mach; flags |= ctx.le_mode << 16; qemu_log("IN: %s\n", lookup_symbol(pc_start)); log_target_disas(env, pc_start, ctx.nip - pc_start, flags); qemu_log("\n"); #endif
{ "code": [], "line_no": [] }
static inline void FUNC_0(PowerPCCPU *VAR_0, TranslationBlock *VAR_1, bool VAR_2) { CPUState *cs = CPU(VAR_0); CPUPPCState *env = &VAR_0->env; DisasContext ctx, *ctxp = &ctx; opc_handler_t **table, *handler; target_ulong pc_start; uint16_t *gen_opc_end; CPUBreakpoint *bp; int VAR_3, VAR_4 = -1; int VAR_5; int VAR_6; pc_start = VAR_1->pc; gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE; ctx.nip = pc_start; ctx.VAR_1 = VAR_1; ctx.exception = POWERPC_EXCP_NONE; ctx.spr_cb = env->spr_cb; ctx.mem_idx = env->mmu_idx; ctx.insns_flags = env->insns_flags; ctx.insns_flags2 = env->insns_flags2; ctx.access_type = -1; ctx.le_mode = env->hflags & (1 << MSR_LE) ? 1 : 0; #if defined(TARGET_PPC64) ctx.sf_mode = msr_is_64bit(env, env->msr); ctx.has_cfar = !!(env->flags & POWERPC_FLAG_CFAR); #endif ctx.fpu_enabled = msr_fp; if ((env->flags & POWERPC_FLAG_SPE) && msr_spe) ctx.spe_enabled = msr_spe; else ctx.spe_enabled = 0; if ((env->flags & POWERPC_FLAG_VRE) && msr_vr) ctx.altivec_enabled = msr_vr; else ctx.altivec_enabled = 0; if ((env->flags & POWERPC_FLAG_VSX) && msr_vsx) { ctx.vsx_enabled = msr_vsx; } else { ctx.vsx_enabled = 0; if ((env->flags & POWERPC_FLAG_SE) && msr_se) ctx.singlestep_enabled = CPU_SINGLE_STEP; else ctx.singlestep_enabled = 0; if ((env->flags & POWERPC_FLAG_BE) && msr_be) ctx.singlestep_enabled |= CPU_BRANCH_STEP; if (unlikely(cs->singlestep_enabled)) { ctx.singlestep_enabled |= GDBSTUB_SINGLE_STEP; #if defined (DO_SINGLE_STEP) && 0 msr_se = 1; #endif VAR_5 = 0; VAR_6 = VAR_1->cflags & CF_COUNT_MASK; if (VAR_6 == 0) VAR_6 = CF_COUNT_MASK; gen_tb_start(); tcg_clear_temp_count(); while (ctx.exception == POWERPC_EXCP_NONE && tcg_ctx.gen_opc_ptr < gen_opc_end) { if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) { QTAILQ_FOREACH(bp, &cs->breakpoints, entry) { if (bp->pc == ctx.nip) { gen_debug_exception(ctxp); break; if (unlikely(VAR_2)) { VAR_3 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; if (VAR_4 < VAR_3) { VAR_4++; while (VAR_4 < VAR_3) tcg_ctx.gen_opc_instr_start[VAR_4++] = 0; tcg_ctx.gen_opc_pc[VAR_4] = ctx.nip; tcg_ctx.gen_opc_instr_start[VAR_4] = 1; tcg_ctx.gen_opc_icount[VAR_4] = VAR_5; LOG_DISAS("----------------\n"); LOG_DISAS("nip=" TARGET_FMT_lx " super=%d ir=%d\n", ctx.nip, ctx.mem_idx, (int)msr_ir); if (VAR_5 + 1 == VAR_6 && (VAR_1->cflags & CF_LAST_IO)) gen_io_start(); if (unlikely(ctx.le_mode)) { ctx.opcode = bswap32(cpu_ldl_code(env, ctx.nip)); } else { ctx.opcode = cpu_ldl_code(env, ctx.nip); LOG_DISAS("translate opcode %08x (%02x %02x %02x) (%s)\n", ctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode), opc3(ctx.opcode), ctx.le_mode ? "little" : "big"); if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) { tcg_gen_debug_insn_start(ctx.nip); ctx.nip += 4; table = env->opcodes; VAR_5++; handler = table[opc1(ctx.opcode)]; if (is_indirect_opcode(handler)) { table = ind_table(handler); handler = table[opc2(ctx.opcode)]; if (is_indirect_opcode(handler)) { table = ind_table(handler); handler = table[opc3(ctx.opcode)]; if (unlikely(handler->handler == &gen_invalid)) { if (qemu_log_enabled()) { qemu_log("invalid/unsupported opcode: " "%02x - %02x - %02x (%08x) " TARGET_FMT_lx " %d\n", opc1(ctx.opcode), opc2(ctx.opcode), opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir); } else { uint32_t inval; if (unlikely(handler->type & (PPC_SPE | PPC_SPE_SINGLE | PPC_SPE_DOUBLE) && Rc(ctx.opcode))) { inval = handler->inval2; } else { inval = handler->inval1; if (unlikely((ctx.opcode & inval) != 0)) { if (qemu_log_enabled()) { qemu_log("invalid bits: %08x for opcode: " "%02x - %02x - %02x (%08x) " TARGET_FMT_lx "\n", ctx.opcode & inval, opc1(ctx.opcode), opc2(ctx.opcode), opc3(ctx.opcode), ctx.opcode, ctx.nip - 4); gen_inval_exception(ctxp, POWERPC_EXCP_INVAL_INVAL); break; (*(handler->handler))(&ctx); #if defined(DO_PPC_STATISTICS) handler->count++; #endif if (unlikely(ctx.singlestep_enabled & CPU_SINGLE_STEP && (ctx.nip <= 0x100 || ctx.nip > 0xF00) && ctx.exception != POWERPC_SYSCALL && ctx.exception != POWERPC_EXCP_TRAP && ctx.exception != POWERPC_EXCP_BRANCH)) { gen_exception(ctxp, POWERPC_EXCP_TRACE); } else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) || (cs->singlestep_enabled) || singlestep || VAR_5 >= VAR_6)) { break; if (VAR_1->cflags & CF_LAST_IO) gen_io_end(); if (ctx.exception == POWERPC_EXCP_NONE) { gen_goto_tb(&ctx, 0, ctx.nip); } else if (ctx.exception != POWERPC_EXCP_BRANCH) { if (unlikely(cs->singlestep_enabled)) { gen_debug_exception(ctxp); tcg_gen_exit_tb(0); gen_tb_end(VAR_1, VAR_5); *tcg_ctx.gen_opc_ptr = INDEX_op_end; if (unlikely(VAR_2)) { VAR_3 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; VAR_4++; while (VAR_4 <= VAR_3) tcg_ctx.gen_opc_instr_start[VAR_4++] = 0; } else { VAR_1->size = ctx.nip - pc_start; VAR_1->icount = VAR_5; #if defined(DEBUG_DISAS) if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { int flags; flags = env->bfd_mach; flags |= ctx.le_mode << 16; qemu_log("IN: %s\n", lookup_symbol(pc_start)); log_target_disas(env, pc_start, ctx.nip - pc_start, flags); qemu_log("\n"); #endif
[ "static inline void FUNC_0(PowerPCCPU *VAR_0,\nTranslationBlock *VAR_1,\nbool VAR_2)\n{", "CPUState *cs = CPU(VAR_0);", "CPUPPCState *env = &VAR_0->env;", "DisasContext ctx, *ctxp = &ctx;", "opc_handler_t **table, *handler;", "target_ulong pc_start;", "uint16_t *gen_opc_end;", "CPUBreakpoint *bp;", "int VAR_3, VAR_4 = -1;", "int VAR_5;", "int VAR_6;", "pc_start = VAR_1->pc;", "gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;", "ctx.nip = pc_start;", "ctx.VAR_1 = VAR_1;", "ctx.exception = POWERPC_EXCP_NONE;", "ctx.spr_cb = env->spr_cb;", "ctx.mem_idx = env->mmu_idx;", "ctx.insns_flags = env->insns_flags;", "ctx.insns_flags2 = env->insns_flags2;", "ctx.access_type = -1;", "ctx.le_mode = env->hflags & (1 << MSR_LE) ? 1 : 0;", "#if defined(TARGET_PPC64)\nctx.sf_mode = msr_is_64bit(env, env->msr);", "ctx.has_cfar = !!(env->flags & POWERPC_FLAG_CFAR);", "#endif\nctx.fpu_enabled = msr_fp;", "if ((env->flags & POWERPC_FLAG_SPE) && msr_spe)\nctx.spe_enabled = msr_spe;", "else\nctx.spe_enabled = 0;", "if ((env->flags & POWERPC_FLAG_VRE) && msr_vr)\nctx.altivec_enabled = msr_vr;", "else\nctx.altivec_enabled = 0;", "if ((env->flags & POWERPC_FLAG_VSX) && msr_vsx) {", "ctx.vsx_enabled = msr_vsx;", "} else {", "ctx.vsx_enabled = 0;", "if ((env->flags & POWERPC_FLAG_SE) && msr_se)\nctx.singlestep_enabled = CPU_SINGLE_STEP;", "else\nctx.singlestep_enabled = 0;", "if ((env->flags & POWERPC_FLAG_BE) && msr_be)\nctx.singlestep_enabled |= CPU_BRANCH_STEP;", "if (unlikely(cs->singlestep_enabled)) {", "ctx.singlestep_enabled |= GDBSTUB_SINGLE_STEP;", "#if defined (DO_SINGLE_STEP) && 0\nmsr_se = 1;", "#endif\nVAR_5 = 0;", "VAR_6 = VAR_1->cflags & CF_COUNT_MASK;", "if (VAR_6 == 0)\nVAR_6 = CF_COUNT_MASK;", "gen_tb_start();", "tcg_clear_temp_count();", "while (ctx.exception == POWERPC_EXCP_NONE\n&& tcg_ctx.gen_opc_ptr < gen_opc_end) {", "if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {", "QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {", "if (bp->pc == ctx.nip) {", "gen_debug_exception(ctxp);", "break;", "if (unlikely(VAR_2)) {", "VAR_3 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;", "if (VAR_4 < VAR_3) {", "VAR_4++;", "while (VAR_4 < VAR_3)\ntcg_ctx.gen_opc_instr_start[VAR_4++] = 0;", "tcg_ctx.gen_opc_pc[VAR_4] = ctx.nip;", "tcg_ctx.gen_opc_instr_start[VAR_4] = 1;", "tcg_ctx.gen_opc_icount[VAR_4] = VAR_5;", "LOG_DISAS(\"----------------\\n\");", "LOG_DISAS(\"nip=\" TARGET_FMT_lx \" super=%d ir=%d\\n\",\nctx.nip, ctx.mem_idx, (int)msr_ir);", "if (VAR_5 + 1 == VAR_6 && (VAR_1->cflags & CF_LAST_IO))\ngen_io_start();", "if (unlikely(ctx.le_mode)) {", "ctx.opcode = bswap32(cpu_ldl_code(env, ctx.nip));", "} else {", "ctx.opcode = cpu_ldl_code(env, ctx.nip);", "LOG_DISAS(\"translate opcode %08x (%02x %02x %02x) (%s)\\n\",\nctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode),\nopc3(ctx.opcode), ctx.le_mode ? \"little\" : \"big\");", "if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {", "tcg_gen_debug_insn_start(ctx.nip);", "ctx.nip += 4;", "table = env->opcodes;", "VAR_5++;", "handler = table[opc1(ctx.opcode)];", "if (is_indirect_opcode(handler)) {", "table = ind_table(handler);", "handler = table[opc2(ctx.opcode)];", "if (is_indirect_opcode(handler)) {", "table = ind_table(handler);", "handler = table[opc3(ctx.opcode)];", "if (unlikely(handler->handler == &gen_invalid)) {", "if (qemu_log_enabled()) {", "qemu_log(\"invalid/unsupported opcode: \"\n\"%02x - %02x - %02x (%08x) \" TARGET_FMT_lx \" %d\\n\",\nopc1(ctx.opcode), opc2(ctx.opcode),\nopc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir);", "} else {", "uint32_t inval;", "if (unlikely(handler->type & (PPC_SPE | PPC_SPE_SINGLE | PPC_SPE_DOUBLE) && Rc(ctx.opcode))) {", "inval = handler->inval2;", "} else {", "inval = handler->inval1;", "if (unlikely((ctx.opcode & inval) != 0)) {", "if (qemu_log_enabled()) {", "qemu_log(\"invalid bits: %08x for opcode: \"\n\"%02x - %02x - %02x (%08x) \" TARGET_FMT_lx \"\\n\",\nctx.opcode & inval, opc1(ctx.opcode),\nopc2(ctx.opcode), opc3(ctx.opcode),\nctx.opcode, ctx.nip - 4);", "gen_inval_exception(ctxp, POWERPC_EXCP_INVAL_INVAL);", "break;", "(*(handler->handler))(&ctx);", "#if defined(DO_PPC_STATISTICS)\nhandler->count++;", "#endif\nif (unlikely(ctx.singlestep_enabled & CPU_SINGLE_STEP &&\n(ctx.nip <= 0x100 || ctx.nip > 0xF00) &&\nctx.exception != POWERPC_SYSCALL &&\nctx.exception != POWERPC_EXCP_TRAP &&\nctx.exception != POWERPC_EXCP_BRANCH)) {", "gen_exception(ctxp, POWERPC_EXCP_TRACE);", "} else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) ||", "(cs->singlestep_enabled) ||\nsinglestep ||\nVAR_5 >= VAR_6)) {", "break;", "if (VAR_1->cflags & CF_LAST_IO)\ngen_io_end();", "if (ctx.exception == POWERPC_EXCP_NONE) {", "gen_goto_tb(&ctx, 0, ctx.nip);", "} else if (ctx.exception != POWERPC_EXCP_BRANCH) {", "if (unlikely(cs->singlestep_enabled)) {", "gen_debug_exception(ctxp);", "tcg_gen_exit_tb(0);", "gen_tb_end(VAR_1, VAR_5);", "*tcg_ctx.gen_opc_ptr = INDEX_op_end;", "if (unlikely(VAR_2)) {", "VAR_3 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;", "VAR_4++;", "while (VAR_4 <= VAR_3)\ntcg_ctx.gen_opc_instr_start[VAR_4++] = 0;", "} else {", "VAR_1->size = ctx.nip - pc_start;", "VAR_1->icount = VAR_5;", "#if defined(DEBUG_DISAS)\nif (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {", "int flags;", "flags = env->bfd_mach;", "flags |= ctx.le_mode << 16;", "qemu_log(\"IN: %s\\n\", lookup_symbol(pc_start));", "log_target_disas(env, pc_start, ctx.nip - pc_start, flags);", "qemu_log(\"\\n\");" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53, 55 ], [ 57 ], [ 59, 61 ], [ 63, 65 ], [ 67, 69 ], [ 71, 73 ], [ 75, 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 88, 90 ], [ 92, 94 ], [ 96, 98 ], [ 100 ], [ 102 ], [ 105, 109 ], [ 111, 113 ], [ 115 ], [ 117, 119 ], [ 123 ], [ 125 ], [ 129, 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 146 ], [ 148 ], [ 150 ], [ 152 ], [ 154, 156 ], [ 159 ], [ 161 ], [ 163 ], [ 166 ], [ 168, 170 ], [ 172, 174 ], [ 176 ], [ 178 ], [ 180 ], [ 182 ], [ 185, 187, 189 ], [ 191 ], [ 193 ], [ 196 ], [ 198 ], [ 200 ], [ 202 ], [ 204 ], [ 206 ], [ 208 ], [ 210 ], [ 212 ], [ 214 ], [ 220 ], [ 222 ], [ 224, 226, 228, 230 ], [ 233 ], [ 235 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 250 ], [ 252 ], [ 254, 256, 258, 260, 262 ], [ 265 ], [ 267 ], [ 271 ], [ 273, 275 ], [ 277, 281, 283, 285, 287, 289 ], [ 291 ], [ 293 ], [ 295, 297, 299 ], [ 307 ], [ 317, 319 ], [ 321 ], [ 323 ], [ 325 ], [ 327 ], [ 329 ], [ 334 ], [ 337 ], [ 339 ], [ 341 ], [ 343 ], [ 345 ], [ 347, 349 ], [ 351 ], [ 353 ], [ 355 ], [ 358, 360 ], [ 362 ], [ 364 ], [ 366 ], [ 368 ], [ 370 ], [ 372 ] ]
6,110
static void gen_mfsri(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); #else int ra = rA(ctx->opcode); int rd = rD(ctx->opcode); TCGv t0; if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); return; } t0 = tcg_temp_new(); gen_addr_reg_index(ctx, t0); tcg_gen_shri_tl(t0, t0, 28); tcg_gen_andi_tl(t0, t0, 0xF); gen_helper_load_sr(cpu_gpr[rd], cpu_env, t0); tcg_temp_free(t0); if (ra != 0 && ra != rd) tcg_gen_mov_tl(cpu_gpr[ra], cpu_gpr[rd]); #endif }
true
qemu
9b2fadda3e0196ffd485adde4fe9cdd6fae35300
static void gen_mfsri(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); #else int ra = rA(ctx->opcode); int rd = rD(ctx->opcode); TCGv t0; if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); return; } t0 = tcg_temp_new(); gen_addr_reg_index(ctx, t0); tcg_gen_shri_tl(t0, t0, 28); tcg_gen_andi_tl(t0, t0, 0xF); gen_helper_load_sr(cpu_gpr[rd], cpu_env, t0); tcg_temp_free(t0); if (ra != 0 && ra != rd) tcg_gen_mov_tl(cpu_gpr[ra], cpu_gpr[rd]); #endif }
{ "code": [ " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#if defined(CONFIG_USER_ONLY)", "#else", " if (unlikely(ctx->pr)) {", "#endif", "#if defined(CONFIG_USER_ONLY)", "#else", " if (unlikely(ctx->pr)) {", "#endif", "#endif", "#if defined(CONFIG_USER_ONLY)", "#else", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", "#if defined(CONFIG_USER_ONLY)", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#else", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", "#if defined(CONFIG_USER_ONLY)", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#else", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", "#if defined(CONFIG_USER_ONLY)", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#else", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", "#if defined(CONFIG_USER_ONLY)", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif" ], "line_no": [ 19, 7, 17, 19, 7, 17, 19, 7, 19, 5, 9, 17, 41, 5, 9, 17, 41, 41, 5, 9, 17, 7, 17, 19, 41, 17, 41, 17, 41, 17, 41, 17, 41, 17, 41, 17, 41, 17, 41, 17, 41, 17, 41, 17, 41, 17, 41, 7, 19, 41, 7, 17, 19, 41, 7, 19, 41, 7, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 41, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 17, 41, 17, 41, 17, 41, 17, 41, 5, 7, 9, 17, 19, 41, 7, 17, 19, 41, 5, 7, 9, 17, 19, 41, 5, 7, 9, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 5, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41, 7, 17, 19, 41 ] }
static void FUNC_0(DisasContext *VAR_0) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC); #else int VAR_1 = rA(VAR_0->opcode); int VAR_2 = rD(VAR_0->opcode); TCGv t0; if (unlikely(VAR_0->pr)) { gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC); return; } t0 = tcg_temp_new(); gen_addr_reg_index(VAR_0, t0); tcg_gen_shri_tl(t0, t0, 28); tcg_gen_andi_tl(t0, t0, 0xF); gen_helper_load_sr(cpu_gpr[VAR_2], cpu_env, t0); tcg_temp_free(t0); if (VAR_1 != 0 && VAR_1 != VAR_2) tcg_gen_mov_tl(cpu_gpr[VAR_1], cpu_gpr[VAR_2]); #endif }
[ "static void FUNC_0(DisasContext *VAR_0)\n{", "#if defined(CONFIG_USER_ONLY)\ngen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);", "#else\nint VAR_1 = rA(VAR_0->opcode);", "int VAR_2 = rD(VAR_0->opcode);", "TCGv t0;", "if (unlikely(VAR_0->pr)) {", "gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);", "return;", "}", "t0 = tcg_temp_new();", "gen_addr_reg_index(VAR_0, t0);", "tcg_gen_shri_tl(t0, t0, 28);", "tcg_gen_andi_tl(t0, t0, 0xF);", "gen_helper_load_sr(cpu_gpr[VAR_2], cpu_env, t0);", "tcg_temp_free(t0);", "if (VAR_1 != 0 && VAR_1 != VAR_2)\ntcg_gen_mov_tl(cpu_gpr[VAR_1], cpu_gpr[VAR_2]);", "#endif\n}" ]
[ 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
[ [ 1, 3 ], [ 5, 7 ], [ 9, 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37, 39 ], [ 41, 43 ] ]
6,111
static int rv20_decode_picture_header(MpegEncContext *s) { int seq, mb_pos, i; if(s->avctx->sub_id == 0x30202002 || s->avctx->sub_id == 0x30203002){ if (get_bits(&s->gb, 3)){ av_log(s->avctx, AV_LOG_ERROR, "unknown triplet set\n"); return -1; } } i= get_bits(&s->gb, 2); switch(i){ case 0: s->pict_type= I_TYPE; break; case 1: s->pict_type= I_TYPE; break; //hmm ... case 2: s->pict_type= P_TYPE; break; case 3: s->pict_type= B_TYPE; break; default: av_log(s->avctx, AV_LOG_ERROR, "unknown frame type\n"); return -1; } if (get_bits(&s->gb, 1)){ av_log(s->avctx, AV_LOG_ERROR, "unknown bit set\n"); return -1; } s->qscale = get_bits(&s->gb, 5); if(s->qscale==0){ av_log(s->avctx, AV_LOG_ERROR, "error, qscale:0\n"); return -1; } if(s->avctx->sub_id == 0x30203002){ if (get_bits(&s->gb, 1)){ av_log(s->avctx, AV_LOG_ERROR, "unknown bit2 set\n"); return -1; } } if(s->avctx->has_b_frames){ if (get_bits(&s->gb, 1)){ av_log(s->avctx, AV_LOG_ERROR, "unknown bit3 set\n"); return -1; } seq= get_bits(&s->gb, 15); }else seq= get_bits(&s->gb, 8)*128; //printf("%d\n", seq); seq |= s->time &~0x7FFF; if(seq - s->time > 0x4000) seq -= 0x8000; if(seq - s->time < -0x4000) seq += 0x8000; if(seq != s->time){ if(s->pict_type!=B_TYPE){ s->time= seq; s->pp_time= s->time - s->last_non_b_time; s->last_non_b_time= s->time; }else{ s->time= seq; s->pb_time= s->pp_time - (s->last_non_b_time - s->time); if(s->pp_time <=s->pb_time || s->pp_time <= s->pp_time - s->pb_time || s->pp_time<=0){ printf("messed up order, seeking?, skiping current b frame\n"); return FRAME_SKIPED; } } } // printf("%d %d %d %d %d\n", seq, (int)s->time, (int)s->last_non_b_time, s->pp_time, s->pb_time); mb_pos= ff_h263_decode_mba(s); s->no_rounding= get_bits1(&s->gb); s->f_code = 1; s->unrestricted_mv = 1; s->h263_aic= s->pict_type == I_TYPE; // s->alt_inter_vlc=1; // s->obmc=1; // s->umvplus=1; s->modified_quant=1; s->loop_filter=1; if(s->avctx->debug & FF_DEBUG_PICT_INFO){ av_log(s->avctx, AV_LOG_INFO, "num:%5d x:%2d y:%2d type:%d qscale:%2d rnd:%d\n", seq, s->mb_x, s->mb_y, s->pict_type, s->qscale, s->no_rounding); } assert(s->pict_type != B_TYPE || !s->low_delay); return s->mb_width*s->mb_height - mb_pos; }
true
FFmpeg
bed1707c9c274831173902542aaef1f8428e6331
static int rv20_decode_picture_header(MpegEncContext *s) { int seq, mb_pos, i; if(s->avctx->sub_id == 0x30202002 || s->avctx->sub_id == 0x30203002){ if (get_bits(&s->gb, 3)){ av_log(s->avctx, AV_LOG_ERROR, "unknown triplet set\n"); return -1; } } i= get_bits(&s->gb, 2); switch(i){ case 0: s->pict_type= I_TYPE; break; case 1: s->pict_type= I_TYPE; break; case 2: s->pict_type= P_TYPE; break; case 3: s->pict_type= B_TYPE; break; default: av_log(s->avctx, AV_LOG_ERROR, "unknown frame type\n"); return -1; } if (get_bits(&s->gb, 1)){ av_log(s->avctx, AV_LOG_ERROR, "unknown bit set\n"); return -1; } s->qscale = get_bits(&s->gb, 5); if(s->qscale==0){ av_log(s->avctx, AV_LOG_ERROR, "error, qscale:0\n"); return -1; } if(s->avctx->sub_id == 0x30203002){ if (get_bits(&s->gb, 1)){ av_log(s->avctx, AV_LOG_ERROR, "unknown bit2 set\n"); return -1; } } if(s->avctx->has_b_frames){ if (get_bits(&s->gb, 1)){ av_log(s->avctx, AV_LOG_ERROR, "unknown bit3 set\n"); return -1; } seq= get_bits(&s->gb, 15); }else seq= get_bits(&s->gb, 8)*128; seq |= s->time &~0x7FFF; if(seq - s->time > 0x4000) seq -= 0x8000; if(seq - s->time < -0x4000) seq += 0x8000; if(seq != s->time){ if(s->pict_type!=B_TYPE){ s->time= seq; s->pp_time= s->time - s->last_non_b_time; s->last_non_b_time= s->time; }else{ s->time= seq; s->pb_time= s->pp_time - (s->last_non_b_time - s->time); if(s->pp_time <=s->pb_time || s->pp_time <= s->pp_time - s->pb_time || s->pp_time<=0){ printf("messed up order, seeking?, skiping current b frame\n"); return FRAME_SKIPED; } } } mb_pos= ff_h263_decode_mba(s); s->no_rounding= get_bits1(&s->gb); s->f_code = 1; s->unrestricted_mv = 1; s->h263_aic= s->pict_type == I_TYPE; s->modified_quant=1; s->loop_filter=1; if(s->avctx->debug & FF_DEBUG_PICT_INFO){ av_log(s->avctx, AV_LOG_INFO, "num:%5d x:%2d y:%2d type:%d qscale:%2d rnd:%d\n", seq, s->mb_x, s->mb_y, s->pict_type, s->qscale, s->no_rounding); } assert(s->pict_type != B_TYPE || !s->low_delay); return s->mb_width*s->mb_height - mb_pos; }
{ "code": [ " return -1;" ], "line_no": [ 15 ] }
static int FUNC_0(MpegEncContext *VAR_0) { int VAR_1, VAR_2, VAR_3; if(VAR_0->avctx->sub_id == 0x30202002 || VAR_0->avctx->sub_id == 0x30203002){ if (get_bits(&VAR_0->gb, 3)){ av_log(VAR_0->avctx, AV_LOG_ERROR, "unknown triplet set\n"); return -1; } } VAR_3= get_bits(&VAR_0->gb, 2); switch(VAR_3){ case 0: VAR_0->pict_type= I_TYPE; break; case 1: VAR_0->pict_type= I_TYPE; break; case 2: VAR_0->pict_type= P_TYPE; break; case 3: VAR_0->pict_type= B_TYPE; break; default: av_log(VAR_0->avctx, AV_LOG_ERROR, "unknown frame type\n"); return -1; } if (get_bits(&VAR_0->gb, 1)){ av_log(VAR_0->avctx, AV_LOG_ERROR, "unknown bit set\n"); return -1; } VAR_0->qscale = get_bits(&VAR_0->gb, 5); if(VAR_0->qscale==0){ av_log(VAR_0->avctx, AV_LOG_ERROR, "error, qscale:0\n"); return -1; } if(VAR_0->avctx->sub_id == 0x30203002){ if (get_bits(&VAR_0->gb, 1)){ av_log(VAR_0->avctx, AV_LOG_ERROR, "unknown bit2 set\n"); return -1; } } if(VAR_0->avctx->has_b_frames){ if (get_bits(&VAR_0->gb, 1)){ av_log(VAR_0->avctx, AV_LOG_ERROR, "unknown bit3 set\n"); return -1; } VAR_1= get_bits(&VAR_0->gb, 15); }else VAR_1= get_bits(&VAR_0->gb, 8)*128; VAR_1 |= VAR_0->time &~0x7FFF; if(VAR_1 - VAR_0->time > 0x4000) VAR_1 -= 0x8000; if(VAR_1 - VAR_0->time < -0x4000) VAR_1 += 0x8000; if(VAR_1 != VAR_0->time){ if(VAR_0->pict_type!=B_TYPE){ VAR_0->time= VAR_1; VAR_0->pp_time= VAR_0->time - VAR_0->last_non_b_time; VAR_0->last_non_b_time= VAR_0->time; }else{ VAR_0->time= VAR_1; VAR_0->pb_time= VAR_0->pp_time - (VAR_0->last_non_b_time - VAR_0->time); if(VAR_0->pp_time <=VAR_0->pb_time || VAR_0->pp_time <= VAR_0->pp_time - VAR_0->pb_time || VAR_0->pp_time<=0){ printf("messed up order, seeking?, skiping current b frame\n"); return FRAME_SKIPED; } } } VAR_2= ff_h263_decode_mba(VAR_0); VAR_0->no_rounding= get_bits1(&VAR_0->gb); VAR_0->f_code = 1; VAR_0->unrestricted_mv = 1; VAR_0->h263_aic= VAR_0->pict_type == I_TYPE; VAR_0->modified_quant=1; VAR_0->loop_filter=1; if(VAR_0->avctx->debug & FF_DEBUG_PICT_INFO){ av_log(VAR_0->avctx, AV_LOG_INFO, "num:%5d x:%2d y:%2d type:%d qscale:%2d rnd:%d\n", VAR_1, VAR_0->mb_x, VAR_0->mb_y, VAR_0->pict_type, VAR_0->qscale, VAR_0->no_rounding); } assert(VAR_0->pict_type != B_TYPE || !VAR_0->low_delay); return VAR_0->mb_width*VAR_0->mb_height - VAR_2; }
[ "static int FUNC_0(MpegEncContext *VAR_0)\n{", "int VAR_1, VAR_2, VAR_3;", "if(VAR_0->avctx->sub_id == 0x30202002 || VAR_0->avctx->sub_id == 0x30203002){", "if (get_bits(&VAR_0->gb, 3)){", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"unknown triplet set\\n\");", "return -1;", "}", "}", "VAR_3= get_bits(&VAR_0->gb, 2);", "switch(VAR_3){", "case 0: VAR_0->pict_type= I_TYPE; break;", "case 1: VAR_0->pict_type= I_TYPE; break;", "case 2: VAR_0->pict_type= P_TYPE; break;", "case 3: VAR_0->pict_type= B_TYPE; break;", "default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"unknown frame type\\n\");", "return -1;", "}", "if (get_bits(&VAR_0->gb, 1)){", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"unknown bit set\\n\");", "return -1;", "}", "VAR_0->qscale = get_bits(&VAR_0->gb, 5);", "if(VAR_0->qscale==0){", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"error, qscale:0\\n\");", "return -1;", "}", "if(VAR_0->avctx->sub_id == 0x30203002){", "if (get_bits(&VAR_0->gb, 1)){", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"unknown bit2 set\\n\");", "return -1;", "}", "}", "if(VAR_0->avctx->has_b_frames){", "if (get_bits(&VAR_0->gb, 1)){", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"unknown bit3 set\\n\");", "return -1;", "}", "VAR_1= get_bits(&VAR_0->gb, 15);", "}else", "VAR_1= get_bits(&VAR_0->gb, 8)*128;", "VAR_1 |= VAR_0->time &~0x7FFF;", "if(VAR_1 - VAR_0->time > 0x4000) VAR_1 -= 0x8000;", "if(VAR_1 - VAR_0->time < -0x4000) VAR_1 += 0x8000;", "if(VAR_1 != VAR_0->time){", "if(VAR_0->pict_type!=B_TYPE){", "VAR_0->time= VAR_1;", "VAR_0->pp_time= VAR_0->time - VAR_0->last_non_b_time;", "VAR_0->last_non_b_time= VAR_0->time;", "}else{", "VAR_0->time= VAR_1;", "VAR_0->pb_time= VAR_0->pp_time - (VAR_0->last_non_b_time - VAR_0->time);", "if(VAR_0->pp_time <=VAR_0->pb_time || VAR_0->pp_time <= VAR_0->pp_time - VAR_0->pb_time || VAR_0->pp_time<=0){", "printf(\"messed up order, seeking?, skiping current b frame\\n\");", "return FRAME_SKIPED;", "}", "}", "}", "VAR_2= ff_h263_decode_mba(VAR_0);", "VAR_0->no_rounding= get_bits1(&VAR_0->gb);", "VAR_0->f_code = 1;", "VAR_0->unrestricted_mv = 1;", "VAR_0->h263_aic= VAR_0->pict_type == I_TYPE;", "VAR_0->modified_quant=1;", "VAR_0->loop_filter=1;", "if(VAR_0->avctx->debug & FF_DEBUG_PICT_INFO){", "av_log(VAR_0->avctx, AV_LOG_INFO, \"num:%5d x:%2d y:%2d type:%d qscale:%2d rnd:%d\\n\",\nVAR_1, VAR_0->mb_x, VAR_0->mb_y, VAR_0->pict_type, VAR_0->qscale, VAR_0->no_rounding);", "}", "assert(VAR_0->pict_type != B_TYPE || !VAR_0->low_delay);", "return VAR_0->mb_width*VAR_0->mb_height - VAR_2;", "}" ]
[ 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 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35, 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 135 ], [ 137 ], [ 141 ], [ 143 ], [ 145 ], [ 153 ], [ 155 ], [ 159 ], [ 161, 163 ], [ 165 ], [ 169 ], [ 173 ], [ 175 ] ]
6,113
static void hpet_timer(void *opaque) { HPETTimer *t = (HPETTimer*)opaque; uint64_t diff; uint64_t period = t->period; uint64_t cur_tick = hpet_get_ticks(); if (timer_is_periodic(t) && period != 0) { if (t->config & HPET_TN_32BIT) { while (hpet_time_after(cur_tick, t->cmp)) t->cmp = (uint32_t)(t->cmp + t->period); } else while (hpet_time_after64(cur_tick, t->cmp)) t->cmp += period; diff = hpet_calculate_diff(t, cur_tick); qemu_mod_timer(t->qemu_timer, qemu_get_clock(vm_clock) + (int64_t)ticks_to_ns(diff)); } else if (t->config & HPET_TN_32BIT && !timer_is_periodic(t)) { if (t->wrap_flag) { diff = hpet_calculate_diff(t, cur_tick); qemu_mod_timer(t->qemu_timer, qemu_get_clock(vm_clock) + (int64_t)ticks_to_ns(diff)); t->wrap_flag = 0; } } update_irq(t); }
true
qemu
27bb0b2d6f80f058bdb6fcc8fcdfa69b0c8a6d71
static void hpet_timer(void *opaque) { HPETTimer *t = (HPETTimer*)opaque; uint64_t diff; uint64_t period = t->period; uint64_t cur_tick = hpet_get_ticks(); if (timer_is_periodic(t) && period != 0) { if (t->config & HPET_TN_32BIT) { while (hpet_time_after(cur_tick, t->cmp)) t->cmp = (uint32_t)(t->cmp + t->period); } else while (hpet_time_after64(cur_tick, t->cmp)) t->cmp += period; diff = hpet_calculate_diff(t, cur_tick); qemu_mod_timer(t->qemu_timer, qemu_get_clock(vm_clock) + (int64_t)ticks_to_ns(diff)); } else if (t->config & HPET_TN_32BIT && !timer_is_periodic(t)) { if (t->wrap_flag) { diff = hpet_calculate_diff(t, cur_tick); qemu_mod_timer(t->qemu_timer, qemu_get_clock(vm_clock) + (int64_t)ticks_to_ns(diff)); t->wrap_flag = 0; } } update_irq(t); }
{ "code": [ " } else", " HPETTimer *t = (HPETTimer*)opaque;", " while (hpet_time_after(cur_tick, t->cmp))", " } else", " while (hpet_time_after64(cur_tick, t->cmp))", " qemu_mod_timer(t->qemu_timer, qemu_get_clock(vm_clock)", " + (int64_t)ticks_to_ns(diff));", " qemu_mod_timer(t->qemu_timer, qemu_get_clock(vm_clock)", " + (int64_t)ticks_to_ns(diff));" ], "line_no": [ 25, 5, 21, 25, 27, 35, 37, 45, 47 ] }
static void FUNC_0(void *VAR_0) { HPETTimer *t = (HPETTimer*)VAR_0; uint64_t diff; uint64_t period = t->period; uint64_t cur_tick = hpet_get_ticks(); if (timer_is_periodic(t) && period != 0) { if (t->config & HPET_TN_32BIT) { while (hpet_time_after(cur_tick, t->cmp)) t->cmp = (uint32_t)(t->cmp + t->period); } else while (hpet_time_after64(cur_tick, t->cmp)) t->cmp += period; diff = hpet_calculate_diff(t, cur_tick); qemu_mod_timer(t->qemu_timer, qemu_get_clock(vm_clock) + (int64_t)ticks_to_ns(diff)); } else if (t->config & HPET_TN_32BIT && !timer_is_periodic(t)) { if (t->wrap_flag) { diff = hpet_calculate_diff(t, cur_tick); qemu_mod_timer(t->qemu_timer, qemu_get_clock(vm_clock) + (int64_t)ticks_to_ns(diff)); t->wrap_flag = 0; } } update_irq(t); }
[ "static void FUNC_0(void *VAR_0)\n{", "HPETTimer *t = (HPETTimer*)VAR_0;", "uint64_t diff;", "uint64_t period = t->period;", "uint64_t cur_tick = hpet_get_ticks();", "if (timer_is_periodic(t) && period != 0) {", "if (t->config & HPET_TN_32BIT) {", "while (hpet_time_after(cur_tick, t->cmp))\nt->cmp = (uint32_t)(t->cmp + t->period);", "} else", "while (hpet_time_after64(cur_tick, t->cmp))\nt->cmp += period;", "diff = hpet_calculate_diff(t, cur_tick);", "qemu_mod_timer(t->qemu_timer, qemu_get_clock(vm_clock)\n+ (int64_t)ticks_to_ns(diff));", "} else if (t->config & HPET_TN_32BIT && !timer_is_periodic(t)) {", "if (t->wrap_flag) {", "diff = hpet_calculate_diff(t, cur_tick);", "qemu_mod_timer(t->qemu_timer, qemu_get_clock(vm_clock)\n+ (int64_t)ticks_to_ns(diff));", "t->wrap_flag = 0;", "}", "}", "update_irq(t);", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 27, 29 ], [ 33 ], [ 35, 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ] ]
6,114
static AddrRange addrrange_make(uint64_t start, uint64_t size) { return (AddrRange) { start, size }; }
true
qemu
8417cebfda193c7f9ca70be5e308eaa92cf84b94
static AddrRange addrrange_make(uint64_t start, uint64_t size) { return (AddrRange) { start, size }; }
{ "code": [ "static AddrRange addrrange_make(uint64_t start, uint64_t size)" ], "line_no": [ 1 ] }
static AddrRange FUNC_0(uint64_t start, uint64_t size) { return (AddrRange) { start, size }; }
[ "static AddrRange FUNC_0(uint64_t start, uint64_t size)\n{", "return (AddrRange) { start, size };", "}" ]
[ 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
6,115
int bdrv_file_open(BlockDriverState **pbs, const char *filename, const char *reference, QDict *options, int flags, Error **errp) { BlockDriverState *bs = NULL; BlockDriver *drv; const char *drvname; bool allow_protocol_prefix = false; Error *local_err = NULL; int ret; /* NULL means an empty set of options */ if (options == NULL) { options = qdict_new(); } if (reference) { if (filename || qdict_size(options)) { error_setg(errp, "Cannot reference an existing block device with " "additional options or a new filename"); return -EINVAL; } QDECREF(options); bs = bdrv_find(reference); if (!bs) { error_setg(errp, "Cannot find block device '%s'", reference); return -ENODEV; } bdrv_ref(bs); *pbs = bs; return 0; } bs = bdrv_new(""); bs->options = options; options = qdict_clone_shallow(options); /* Fetch the file name from the options QDict if necessary */ if (!filename) { filename = qdict_get_try_str(options, "filename"); } else if (filename && !qdict_haskey(options, "filename")) { qdict_put(options, "filename", qstring_from_str(filename)); allow_protocol_prefix = true; } else { error_setg(errp, "Can't specify 'file' and 'filename' options at the " "same time"); ret = -EINVAL; goto fail; } /* Find the right block driver */ drvname = qdict_get_try_str(options, "driver"); if (drvname) { drv = bdrv_find_format(drvname); if (!drv) { error_setg(errp, "Unknown driver '%s'", drvname); } qdict_del(options, "driver"); } else if (filename) { drv = bdrv_find_protocol(filename, allow_protocol_prefix); if (!drv) { error_setg(errp, "Unknown protocol"); } } else { error_setg(errp, "Must specify either driver or file"); drv = NULL; } if (!drv) { /* errp has been set already */ ret = -ENOENT; goto fail; } /* Parse the filename and open it */ if (drv->bdrv_parse_filename && filename) { drv->bdrv_parse_filename(filename, options, &local_err); if (error_is_set(&local_err)) { error_propagate(errp, local_err); ret = -EINVAL; goto fail; } qdict_del(options, "filename"); } else if (drv->bdrv_needs_filename && !filename) { error_setg(errp, "The '%s' block driver requires a file name", drv->format_name); ret = -EINVAL; goto fail; } if (!drv->bdrv_file_open) { ret = bdrv_open(bs, filename, options, flags, drv, &local_err); options = NULL; } else { ret = bdrv_open_common(bs, NULL, options, flags, drv, &local_err); } if (ret < 0) { error_propagate(errp, local_err); goto fail; } /* Check if any unknown options were used */ if (options && (qdict_size(options) != 0)) { const QDictEntry *entry = qdict_first(options); error_setg(errp, "Block protocol '%s' doesn't support the option '%s'", drv->format_name, entry->key); ret = -EINVAL; goto fail; } QDECREF(options); bs->growable = 1; *pbs = bs; return 0; fail: QDECREF(options); if (!bs->drv) { QDECREF(bs->options); } bdrv_unref(bs); return ret; }
true
qemu
765003db029ed4660a09807958276e251de84fac
int bdrv_file_open(BlockDriverState **pbs, const char *filename, const char *reference, QDict *options, int flags, Error **errp) { BlockDriverState *bs = NULL; BlockDriver *drv; const char *drvname; bool allow_protocol_prefix = false; Error *local_err = NULL; int ret; if (options == NULL) { options = qdict_new(); } if (reference) { if (filename || qdict_size(options)) { error_setg(errp, "Cannot reference an existing block device with " "additional options or a new filename"); return -EINVAL; } QDECREF(options); bs = bdrv_find(reference); if (!bs) { error_setg(errp, "Cannot find block device '%s'", reference); return -ENODEV; } bdrv_ref(bs); *pbs = bs; return 0; } bs = bdrv_new(""); bs->options = options; options = qdict_clone_shallow(options); if (!filename) { filename = qdict_get_try_str(options, "filename"); } else if (filename && !qdict_haskey(options, "filename")) { qdict_put(options, "filename", qstring_from_str(filename)); allow_protocol_prefix = true; } else { error_setg(errp, "Can't specify 'file' and 'filename' options at the " "same time"); ret = -EINVAL; goto fail; } drvname = qdict_get_try_str(options, "driver"); if (drvname) { drv = bdrv_find_format(drvname); if (!drv) { error_setg(errp, "Unknown driver '%s'", drvname); } qdict_del(options, "driver"); } else if (filename) { drv = bdrv_find_protocol(filename, allow_protocol_prefix); if (!drv) { error_setg(errp, "Unknown protocol"); } } else { error_setg(errp, "Must specify either driver or file"); drv = NULL; } if (!drv) { ret = -ENOENT; goto fail; } if (drv->bdrv_parse_filename && filename) { drv->bdrv_parse_filename(filename, options, &local_err); if (error_is_set(&local_err)) { error_propagate(errp, local_err); ret = -EINVAL; goto fail; } qdict_del(options, "filename"); } else if (drv->bdrv_needs_filename && !filename) { error_setg(errp, "The '%s' block driver requires a file name", drv->format_name); ret = -EINVAL; goto fail; } if (!drv->bdrv_file_open) { ret = bdrv_open(bs, filename, options, flags, drv, &local_err); options = NULL; } else { ret = bdrv_open_common(bs, NULL, options, flags, drv, &local_err); } if (ret < 0) { error_propagate(errp, local_err); goto fail; } if (options && (qdict_size(options) != 0)) { const QDictEntry *entry = qdict_first(options); error_setg(errp, "Block protocol '%s' doesn't support the option '%s'", drv->format_name, entry->key); ret = -EINVAL; goto fail; } QDECREF(options); bs->growable = 1; *pbs = bs; return 0; fail: QDECREF(options); if (!bs->drv) { QDECREF(bs->options); } bdrv_unref(bs); return ret; }
{ "code": [ " } else if (drv->bdrv_needs_filename && !filename) {", " error_setg(errp, \"The '%s' block driver requires a file name\",", " drv->format_name);", " ret = -EINVAL;", " goto fail;" ], "line_no": [ 169, 171, 173, 95, 97 ] }
int FUNC_0(BlockDriverState **VAR_0, const char *VAR_1, const char *VAR_2, QDict *VAR_3, int VAR_4, Error **VAR_5) { BlockDriverState *bs = NULL; BlockDriver *drv; const char *VAR_6; bool allow_protocol_prefix = false; Error *local_err = NULL; int VAR_7; if (VAR_3 == NULL) { VAR_3 = qdict_new(); } if (VAR_2) { if (VAR_1 || qdict_size(VAR_3)) { error_setg(VAR_5, "Cannot VAR_2 an existing block device with " "additional VAR_3 or a new VAR_1"); return -EINVAL; } QDECREF(VAR_3); bs = bdrv_find(VAR_2); if (!bs) { error_setg(VAR_5, "Cannot find block device '%s'", VAR_2); return -ENODEV; } bdrv_ref(bs); *VAR_0 = bs; return 0; } bs = bdrv_new(""); bs->VAR_3 = VAR_3; VAR_3 = qdict_clone_shallow(VAR_3); if (!VAR_1) { VAR_1 = qdict_get_try_str(VAR_3, "VAR_1"); } else if (VAR_1 && !qdict_haskey(VAR_3, "VAR_1")) { qdict_put(VAR_3, "VAR_1", qstring_from_str(VAR_1)); allow_protocol_prefix = true; } else { error_setg(VAR_5, "Can't specify 'file' and 'VAR_1' VAR_3 at the " "same time"); VAR_7 = -EINVAL; goto fail; } VAR_6 = qdict_get_try_str(VAR_3, "driver"); if (VAR_6) { drv = bdrv_find_format(VAR_6); if (!drv) { error_setg(VAR_5, "Unknown driver '%s'", VAR_6); } qdict_del(VAR_3, "driver"); } else if (VAR_1) { drv = bdrv_find_protocol(VAR_1, allow_protocol_prefix); if (!drv) { error_setg(VAR_5, "Unknown protocol"); } } else { error_setg(VAR_5, "Must specify either driver or file"); drv = NULL; } if (!drv) { VAR_7 = -ENOENT; goto fail; } if (drv->bdrv_parse_filename && VAR_1) { drv->bdrv_parse_filename(VAR_1, VAR_3, &local_err); if (error_is_set(&local_err)) { error_propagate(VAR_5, local_err); VAR_7 = -EINVAL; goto fail; } qdict_del(VAR_3, "VAR_1"); } else if (drv->bdrv_needs_filename && !VAR_1) { error_setg(VAR_5, "The '%s' block driver requires a file name", drv->format_name); VAR_7 = -EINVAL; goto fail; } if (!drv->FUNC_0) { VAR_7 = bdrv_open(bs, VAR_1, VAR_3, VAR_4, drv, &local_err); VAR_3 = NULL; } else { VAR_7 = bdrv_open_common(bs, NULL, VAR_3, VAR_4, drv, &local_err); } if (VAR_7 < 0) { error_propagate(VAR_5, local_err); goto fail; } if (VAR_3 && (qdict_size(VAR_3) != 0)) { const QDictEntry *VAR_8 = qdict_first(VAR_3); error_setg(VAR_5, "Block protocol '%s' doesn't support the option '%s'", drv->format_name, VAR_8->key); VAR_7 = -EINVAL; goto fail; } QDECREF(VAR_3); bs->growable = 1; *VAR_0 = bs; return 0; fail: QDECREF(VAR_3); if (!bs->drv) { QDECREF(bs->VAR_3); } bdrv_unref(bs); return VAR_7; }
[ "int FUNC_0(BlockDriverState **VAR_0, const char *VAR_1,\nconst char *VAR_2, QDict *VAR_3, int VAR_4,\nError **VAR_5)\n{", "BlockDriverState *bs = NULL;", "BlockDriver *drv;", "const char *VAR_6;", "bool allow_protocol_prefix = false;", "Error *local_err = NULL;", "int VAR_7;", "if (VAR_3 == NULL) {", "VAR_3 = qdict_new();", "}", "if (VAR_2) {", "if (VAR_1 || qdict_size(VAR_3)) {", "error_setg(VAR_5, \"Cannot VAR_2 an existing block device with \"\n\"additional VAR_3 or a new VAR_1\");", "return -EINVAL;", "}", "QDECREF(VAR_3);", "bs = bdrv_find(VAR_2);", "if (!bs) {", "error_setg(VAR_5, \"Cannot find block device '%s'\", VAR_2);", "return -ENODEV;", "}", "bdrv_ref(bs);", "*VAR_0 = bs;", "return 0;", "}", "bs = bdrv_new(\"\");", "bs->VAR_3 = VAR_3;", "VAR_3 = qdict_clone_shallow(VAR_3);", "if (!VAR_1) {", "VAR_1 = qdict_get_try_str(VAR_3, \"VAR_1\");", "} else if (VAR_1 && !qdict_haskey(VAR_3, \"VAR_1\")) {", "qdict_put(VAR_3, \"VAR_1\", qstring_from_str(VAR_1));", "allow_protocol_prefix = true;", "} else {", "error_setg(VAR_5, \"Can't specify 'file' and 'VAR_1' VAR_3 at the \"\n\"same time\");", "VAR_7 = -EINVAL;", "goto fail;", "}", "VAR_6 = qdict_get_try_str(VAR_3, \"driver\");", "if (VAR_6) {", "drv = bdrv_find_format(VAR_6);", "if (!drv) {", "error_setg(VAR_5, \"Unknown driver '%s'\", VAR_6);", "}", "qdict_del(VAR_3, \"driver\");", "} else if (VAR_1) {", "drv = bdrv_find_protocol(VAR_1, allow_protocol_prefix);", "if (!drv) {", "error_setg(VAR_5, \"Unknown protocol\");", "}", "} else {", "error_setg(VAR_5, \"Must specify either driver or file\");", "drv = NULL;", "}", "if (!drv) {", "VAR_7 = -ENOENT;", "goto fail;", "}", "if (drv->bdrv_parse_filename && VAR_1) {", "drv->bdrv_parse_filename(VAR_1, VAR_3, &local_err);", "if (error_is_set(&local_err)) {", "error_propagate(VAR_5, local_err);", "VAR_7 = -EINVAL;", "goto fail;", "}", "qdict_del(VAR_3, \"VAR_1\");", "} else if (drv->bdrv_needs_filename && !VAR_1) {", "error_setg(VAR_5, \"The '%s' block driver requires a file name\",\ndrv->format_name);", "VAR_7 = -EINVAL;", "goto fail;", "}", "if (!drv->FUNC_0) {", "VAR_7 = bdrv_open(bs, VAR_1, VAR_3, VAR_4, drv, &local_err);", "VAR_3 = NULL;", "} else {", "VAR_7 = bdrv_open_common(bs, NULL, VAR_3, VAR_4, drv, &local_err);", "}", "if (VAR_7 < 0) {", "error_propagate(VAR_5, local_err);", "goto fail;", "}", "if (VAR_3 && (qdict_size(VAR_3) != 0)) {", "const QDictEntry *VAR_8 = qdict_first(VAR_3);", "error_setg(VAR_5, \"Block protocol '%s' doesn't support the option '%s'\",\ndrv->format_name, VAR_8->key);", "VAR_7 = -EINVAL;", "goto fail;", "}", "QDECREF(VAR_3);", "bs->growable = 1;", "*VAR_0 = bs;", "return 0;", "fail:\nQDECREF(VAR_3);", "if (!bs->drv) {", "QDECREF(bs->VAR_3);", "}", "bdrv_unref(bs);", "return VAR_7;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 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 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71 ], [ 73 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91, 93 ], [ 95 ], [ 97 ], [ 99 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 139 ], [ 143 ], [ 145 ], [ 147 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171, 173 ], [ 175 ], [ 177 ], [ 179 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 207 ], [ 209 ], [ 211, 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 225 ], [ 227 ], [ 229 ], [ 233, 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ] ]
6,116
static av_cold int concat_open(URLContext *h, const char *uri, int flags) { char *node_uri = NULL; int err = 0; int64_t size; size_t len, i; URLContext *uc; struct concat_data *data = h->priv_data; struct concat_nodes *nodes; av_strstart(uri, "concat:", &uri); for (i = 0, len = 1; uri[i]; i++) if (uri[i] == *AV_CAT_SEPARATOR) /* integer overflow */ if (++len == UINT_MAX / sizeof(*nodes)) { av_freep(&h->priv_data); return AVERROR(ENAMETOOLONG); } if (!(nodes = av_malloc(sizeof(*nodes) * len))) { return AVERROR(ENOMEM); } else data->nodes = nodes; /* handle input */ if (!*uri) err = AVERROR(ENOENT); for (i = 0; *uri; i++) { /* parsing uri */ len = strcspn(uri, AV_CAT_SEPARATOR); if ((err = av_reallocp(&node_uri, len + 1)) < 0) break; av_strlcpy(node_uri, uri, len+1); uri += len + strspn(uri+len, AV_CAT_SEPARATOR); /* creating URLContext */ if ((err = ffurl_open(&uc, node_uri, flags, &h->interrupt_callback, NULL)) < 0) break; /* creating size */ if ((size = ffurl_size(uc)) < 0) { ffurl_close(uc); err = AVERROR(ENOSYS); break; } /* assembling */ nodes[i].uc = uc; nodes[i].size = size; } av_free(node_uri); data->length = i; if (err < 0) concat_close(h); else if ((err = av_reallocp(&nodes, data->length * sizeof(*nodes))) < 0) concat_close(h); else data->nodes = nodes; return err; }
true
FFmpeg
ad2a08388c82bdec5ac9355ca6e0bc4c98b26423
static av_cold int concat_open(URLContext *h, const char *uri, int flags) { char *node_uri = NULL; int err = 0; int64_t size; size_t len, i; URLContext *uc; struct concat_data *data = h->priv_data; struct concat_nodes *nodes; av_strstart(uri, "concat:", &uri); for (i = 0, len = 1; uri[i]; i++) if (uri[i] == *AV_CAT_SEPARATOR) if (++len == UINT_MAX / sizeof(*nodes)) { av_freep(&h->priv_data); return AVERROR(ENAMETOOLONG); } if (!(nodes = av_malloc(sizeof(*nodes) * len))) { return AVERROR(ENOMEM); } else data->nodes = nodes; if (!*uri) err = AVERROR(ENOENT); for (i = 0; *uri; i++) { len = strcspn(uri, AV_CAT_SEPARATOR); if ((err = av_reallocp(&node_uri, len + 1)) < 0) break; av_strlcpy(node_uri, uri, len+1); uri += len + strspn(uri+len, AV_CAT_SEPARATOR); if ((err = ffurl_open(&uc, node_uri, flags, &h->interrupt_callback, NULL)) < 0) break; if ((size = ffurl_size(uc)) < 0) { ffurl_close(uc); err = AVERROR(ENOSYS); break; } nodes[i].uc = uc; nodes[i].size = size; } av_free(node_uri); data->length = i; if (err < 0) concat_close(h); else if ((err = av_reallocp(&nodes, data->length * sizeof(*nodes))) < 0) concat_close(h); else data->nodes = nodes; return err; }
{ "code": [ " else if ((err = av_reallocp(&nodes, data->length * sizeof(*nodes))) < 0)" ], "line_no": [ 115 ] }
static av_cold int FUNC_0(URLContext *h, const char *uri, int flags) { char *VAR_0 = NULL; int VAR_1 = 0; int64_t size; size_t len, i; URLContext *uc; struct concat_data *VAR_2 = h->priv_data; struct concat_nodes *VAR_3; av_strstart(uri, "concat:", &uri); for (i = 0, len = 1; uri[i]; i++) if (uri[i] == *AV_CAT_SEPARATOR) if (++len == UINT_MAX / sizeof(*VAR_3)) { av_freep(&h->priv_data); return AVERROR(ENAMETOOLONG); } if (!(VAR_3 = av_malloc(sizeof(*VAR_3) * len))) { return AVERROR(ENOMEM); } else VAR_2->VAR_3 = VAR_3; if (!*uri) VAR_1 = AVERROR(ENOENT); for (i = 0; *uri; i++) { len = strcspn(uri, AV_CAT_SEPARATOR); if ((VAR_1 = av_reallocp(&VAR_0, len + 1)) < 0) break; av_strlcpy(VAR_0, uri, len+1); uri += len + strspn(uri+len, AV_CAT_SEPARATOR); if ((VAR_1 = ffurl_open(&uc, VAR_0, flags, &h->interrupt_callback, NULL)) < 0) break; if ((size = ffurl_size(uc)) < 0) { ffurl_close(uc); VAR_1 = AVERROR(ENOSYS); break; } VAR_3[i].uc = uc; VAR_3[i].size = size; } av_free(VAR_0); VAR_2->length = i; if (VAR_1 < 0) concat_close(h); else if ((VAR_1 = av_reallocp(&VAR_3, VAR_2->length * sizeof(*VAR_3))) < 0) concat_close(h); else VAR_2->VAR_3 = VAR_3; return VAR_1; }
[ "static av_cold int FUNC_0(URLContext *h, const char *uri, int flags)\n{", "char *VAR_0 = NULL;", "int VAR_1 = 0;", "int64_t size;", "size_t len, i;", "URLContext *uc;", "struct concat_data *VAR_2 = h->priv_data;", "struct concat_nodes *VAR_3;", "av_strstart(uri, \"concat:\", &uri);", "for (i = 0, len = 1; uri[i]; i++)", "if (uri[i] == *AV_CAT_SEPARATOR)\nif (++len == UINT_MAX / sizeof(*VAR_3)) {", "av_freep(&h->priv_data);", "return AVERROR(ENAMETOOLONG);", "}", "if (!(VAR_3 = av_malloc(sizeof(*VAR_3) * len))) {", "return AVERROR(ENOMEM);", "} else", "VAR_2->VAR_3 = VAR_3;", "if (!*uri)\nVAR_1 = AVERROR(ENOENT);", "for (i = 0; *uri; i++) {", "len = strcspn(uri, AV_CAT_SEPARATOR);", "if ((VAR_1 = av_reallocp(&VAR_0, len + 1)) < 0)\nbreak;", "av_strlcpy(VAR_0, uri, len+1);", "uri += len + strspn(uri+len, AV_CAT_SEPARATOR);", "if ((VAR_1 = ffurl_open(&uc, VAR_0, flags,\n&h->interrupt_callback, NULL)) < 0)\nbreak;", "if ((size = ffurl_size(uc)) < 0) {", "ffurl_close(uc);", "VAR_1 = AVERROR(ENOSYS);", "break;", "}", "VAR_3[i].uc = uc;", "VAR_3[i].size = size;", "}", "av_free(VAR_0);", "VAR_2->length = i;", "if (VAR_1 < 0)\nconcat_close(h);", "else if ((VAR_1 = av_reallocp(&VAR_3, VAR_2->length * sizeof(*VAR_3))) < 0)\nconcat_close(h);", "else\nVAR_2->VAR_3 = VAR_3;", "return VAR_1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 25 ], [ 27, 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 53, 55 ], [ 57 ], [ 61 ], [ 63, 65 ], [ 67 ], [ 69 ], [ 75, 77, 79 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 111, 113 ], [ 115, 117 ], [ 119, 121 ], [ 123 ], [ 125 ] ]
6,117
static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { DCAEncContext *c = avctx->priv_data; const int32_t *samples; int ret, i; if ((ret = ff_alloc_packet2(avctx, avpkt, c->frame_size , 0)) < 0) return ret; samples = (const int32_t *)frame->data[0]; subband_transform(c, samples); if (c->lfe_channel) lfe_downsample(c, samples); calc_masking(c, samples); find_peaks(c); assign_bits(c); calc_scales(c); quantize_all(c); shift_history(c, samples); init_put_bits(&c->pb, avpkt->data, avpkt->size); put_frame_header(c); put_primary_audio_header(c); for (i = 0; i < SUBFRAMES; i++) put_subframe(c, i); flush_put_bits(&c->pb); avpkt->pts = frame->pts; avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples); avpkt->size = c->frame_size + 1; *got_packet_ptr = 1; return 0; }
true
FFmpeg
e322b7061f873e8fd33b9e518caa19b87616a528
static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { DCAEncContext *c = avctx->priv_data; const int32_t *samples; int ret, i; if ((ret = ff_alloc_packet2(avctx, avpkt, c->frame_size , 0)) < 0) return ret; samples = (const int32_t *)frame->data[0]; subband_transform(c, samples); if (c->lfe_channel) lfe_downsample(c, samples); calc_masking(c, samples); find_peaks(c); assign_bits(c); calc_scales(c); quantize_all(c); shift_history(c, samples); init_put_bits(&c->pb, avpkt->data, avpkt->size); put_frame_header(c); put_primary_audio_header(c); for (i = 0; i < SUBFRAMES; i++) put_subframe(c, i); flush_put_bits(&c->pb); avpkt->pts = frame->pts; avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples); avpkt->size = c->frame_size + 1; *got_packet_ptr = 1; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1, const AVFrame *VAR_2, int *VAR_3) { DCAEncContext *c = VAR_0->priv_data; const int32_t *VAR_4; int VAR_5, VAR_6; if ((VAR_5 = ff_alloc_packet2(VAR_0, VAR_1, c->frame_size , 0)) < 0) return VAR_5; VAR_4 = (const int32_t *)VAR_2->data[0]; subband_transform(c, VAR_4); if (c->lfe_channel) lfe_downsample(c, VAR_4); calc_masking(c, VAR_4); find_peaks(c); assign_bits(c); calc_scales(c); quantize_all(c); shift_history(c, VAR_4); init_put_bits(&c->pb, VAR_1->data, VAR_1->size); put_frame_header(c); put_primary_audio_header(c); for (VAR_6 = 0; VAR_6 < SUBFRAMES; VAR_6++) put_subframe(c, VAR_6); flush_put_bits(&c->pb); VAR_1->pts = VAR_2->pts; VAR_1->duration = ff_samples_to_time_base(VAR_0, VAR_2->nb_samples); VAR_1->size = c->frame_size + 1; *VAR_3 = 1; return 0; }
[ "static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,\nconst AVFrame *VAR_2, int *VAR_3)\n{", "DCAEncContext *c = VAR_0->priv_data;", "const int32_t *VAR_4;", "int VAR_5, VAR_6;", "if ((VAR_5 = ff_alloc_packet2(VAR_0, VAR_1, c->frame_size , 0)) < 0)\nreturn VAR_5;", "VAR_4 = (const int32_t *)VAR_2->data[0];", "subband_transform(c, VAR_4);", "if (c->lfe_channel)\nlfe_downsample(c, VAR_4);", "calc_masking(c, VAR_4);", "find_peaks(c);", "assign_bits(c);", "calc_scales(c);", "quantize_all(c);", "shift_history(c, VAR_4);", "init_put_bits(&c->pb, VAR_1->data, VAR_1->size);", "put_frame_header(c);", "put_primary_audio_header(c);", "for (VAR_6 = 0; VAR_6 < SUBFRAMES; VAR_6++)", "put_subframe(c, VAR_6);", "flush_put_bits(&c->pb);", "VAR_1->pts = VAR_2->pts;", "VAR_1->duration = ff_samples_to_time_base(VAR_0, VAR_2->nb_samples);", "VAR_1->size = c->frame_size + 1;", "*VAR_3 = 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 ]
[ [ 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 ] ]
6,118
static void qobject_input_type_null(Visitor *v, const char *name, Error **errp) { QObjectInputVisitor *qiv = to_qiv(v); QObject *qobj = qobject_input_get_object(qiv, name, true, errp); if (!qobj) { return; } if (qobject_type(qobj) != QTYPE_QNULL) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null", "null"); } }
true
qemu
a9fc37f6bc3f2ab90585cb16493da9f6dcfbfbcf
static void qobject_input_type_null(Visitor *v, const char *name, Error **errp) { QObjectInputVisitor *qiv = to_qiv(v); QObject *qobj = qobject_input_get_object(qiv, name, true, errp); if (!qobj) { return; } if (qobject_type(qobj) != QTYPE_QNULL) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null", "null"); } }
{ "code": [ " error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",", " error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",", " error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",", " error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",", " error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",", " error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",", " error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",", " \"null\");" ], "line_no": [ 21, 21, 21, 21, 21, 21, 21, 23 ] }
static void FUNC_0(Visitor *VAR_0, const char *VAR_1, Error **VAR_2) { QObjectInputVisitor *qiv = to_qiv(VAR_0); QObject *qobj = qobject_input_get_object(qiv, VAR_1, true, VAR_2); if (!qobj) { return; } if (qobject_type(qobj) != QTYPE_QNULL) { error_setg(VAR_2, QERR_INVALID_PARAMETER_TYPE, VAR_1 ? VAR_1 : "null", "null"); } }
[ "static void FUNC_0(Visitor *VAR_0, const char *VAR_1, Error **VAR_2)\n{", "QObjectInputVisitor *qiv = to_qiv(VAR_0);", "QObject *qobj = qobject_input_get_object(qiv, VAR_1, true, VAR_2);", "if (!qobj) {", "return;", "}", "if (qobject_type(qobj) != QTYPE_QNULL) {", "error_setg(VAR_2, QERR_INVALID_PARAMETER_TYPE, VAR_1 ? VAR_1 : \"null\",\n\"null\");", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 27 ] ]
6,119
void ff_subblock_synthesis(RA144Context *ractx, const int16_t *lpc_coefs, int cba_idx, int cb1_idx, int cb2_idx, int gval, int gain) { int16_t *block; int m[3]; if (cba_idx) { cba_idx += BLOCKSIZE/2 - 1; ff_copy_and_dup(ractx->buffer_a, ractx->adapt_cb, cba_idx); m[0] = (ff_irms(&ractx->adsp, ractx->buffer_a) * gval) >> 12; } else { m[0] = 0; } m[1] = (ff_cb1_base[cb1_idx] * gval) >> 8; m[2] = (ff_cb2_base[cb2_idx] * gval) >> 8; memmove(ractx->adapt_cb, ractx->adapt_cb + BLOCKSIZE, (BUFFERSIZE - BLOCKSIZE) * sizeof(*ractx->adapt_cb)); block = ractx->adapt_cb + BUFFERSIZE - BLOCKSIZE; add_wav(block, gain, cba_idx, m, cba_idx? ractx->buffer_a: NULL, ff_cb1_vects[cb1_idx], ff_cb2_vects[cb2_idx]); memcpy(ractx->curr_sblock, ractx->curr_sblock + BLOCKSIZE, LPC_ORDER*sizeof(*ractx->curr_sblock)); if (ff_celp_lp_synthesis_filter(ractx->curr_sblock + LPC_ORDER, lpc_coefs, block, BLOCKSIZE, LPC_ORDER, 1, 0, 0xfff)) memset(ractx->curr_sblock, 0, (LPC_ORDER+BLOCKSIZE)*sizeof(*ractx->curr_sblock)); }
true
FFmpeg
4c472c52525fcab4c80cdbc98b4625d318c84fcb
void ff_subblock_synthesis(RA144Context *ractx, const int16_t *lpc_coefs, int cba_idx, int cb1_idx, int cb2_idx, int gval, int gain) { int16_t *block; int m[3]; if (cba_idx) { cba_idx += BLOCKSIZE/2 - 1; ff_copy_and_dup(ractx->buffer_a, ractx->adapt_cb, cba_idx); m[0] = (ff_irms(&ractx->adsp, ractx->buffer_a) * gval) >> 12; } else { m[0] = 0; } m[1] = (ff_cb1_base[cb1_idx] * gval) >> 8; m[2] = (ff_cb2_base[cb2_idx] * gval) >> 8; memmove(ractx->adapt_cb, ractx->adapt_cb + BLOCKSIZE, (BUFFERSIZE - BLOCKSIZE) * sizeof(*ractx->adapt_cb)); block = ractx->adapt_cb + BUFFERSIZE - BLOCKSIZE; add_wav(block, gain, cba_idx, m, cba_idx? ractx->buffer_a: NULL, ff_cb1_vects[cb1_idx], ff_cb2_vects[cb2_idx]); memcpy(ractx->curr_sblock, ractx->curr_sblock + BLOCKSIZE, LPC_ORDER*sizeof(*ractx->curr_sblock)); if (ff_celp_lp_synthesis_filter(ractx->curr_sblock + LPC_ORDER, lpc_coefs, block, BLOCKSIZE, LPC_ORDER, 1, 0, 0xfff)) memset(ractx->curr_sblock, 0, (LPC_ORDER+BLOCKSIZE)*sizeof(*ractx->curr_sblock)); }
{ "code": [ " m[0] = (ff_irms(&ractx->adsp, ractx->buffer_a) * gval) >> 12;" ], "line_no": [ 21 ] }
void FUNC_0(RA144Context *VAR_0, const int16_t *VAR_1, int VAR_2, int VAR_3, int VAR_4, int VAR_5, int VAR_6) { int16_t *block; int VAR_7[3]; if (VAR_2) { VAR_2 += BLOCKSIZE/2 - 1; ff_copy_and_dup(VAR_0->buffer_a, VAR_0->adapt_cb, VAR_2); VAR_7[0] = (ff_irms(&VAR_0->adsp, VAR_0->buffer_a) * VAR_5) >> 12; } else { VAR_7[0] = 0; } VAR_7[1] = (ff_cb1_base[VAR_3] * VAR_5) >> 8; VAR_7[2] = (ff_cb2_base[VAR_4] * VAR_5) >> 8; memmove(VAR_0->adapt_cb, VAR_0->adapt_cb + BLOCKSIZE, (BUFFERSIZE - BLOCKSIZE) * sizeof(*VAR_0->adapt_cb)); block = VAR_0->adapt_cb + BUFFERSIZE - BLOCKSIZE; add_wav(block, VAR_6, VAR_2, VAR_7, VAR_2? VAR_0->buffer_a: NULL, ff_cb1_vects[VAR_3], ff_cb2_vects[VAR_4]); memcpy(VAR_0->curr_sblock, VAR_0->curr_sblock + BLOCKSIZE, LPC_ORDER*sizeof(*VAR_0->curr_sblock)); if (ff_celp_lp_synthesis_filter(VAR_0->curr_sblock + LPC_ORDER, VAR_1, block, BLOCKSIZE, LPC_ORDER, 1, 0, 0xfff)) memset(VAR_0->curr_sblock, 0, (LPC_ORDER+BLOCKSIZE)*sizeof(*VAR_0->curr_sblock)); }
[ "void FUNC_0(RA144Context *VAR_0, const int16_t *VAR_1,\nint VAR_2, int VAR_3, int VAR_4,\nint VAR_5, int VAR_6)\n{", "int16_t *block;", "int VAR_7[3];", "if (VAR_2) {", "VAR_2 += BLOCKSIZE/2 - 1;", "ff_copy_and_dup(VAR_0->buffer_a, VAR_0->adapt_cb, VAR_2);", "VAR_7[0] = (ff_irms(&VAR_0->adsp, VAR_0->buffer_a) * VAR_5) >> 12;", "} else {", "VAR_7[0] = 0;", "}", "VAR_7[1] = (ff_cb1_base[VAR_3] * VAR_5) >> 8;", "VAR_7[2] = (ff_cb2_base[VAR_4] * VAR_5) >> 8;", "memmove(VAR_0->adapt_cb, VAR_0->adapt_cb + BLOCKSIZE,\n(BUFFERSIZE - BLOCKSIZE) * sizeof(*VAR_0->adapt_cb));", "block = VAR_0->adapt_cb + BUFFERSIZE - BLOCKSIZE;", "add_wav(block, VAR_6, VAR_2, VAR_7, VAR_2? VAR_0->buffer_a: NULL,\nff_cb1_vects[VAR_3], ff_cb2_vects[VAR_4]);", "memcpy(VAR_0->curr_sblock, VAR_0->curr_sblock + BLOCKSIZE,\nLPC_ORDER*sizeof(*VAR_0->curr_sblock));", "if (ff_celp_lp_synthesis_filter(VAR_0->curr_sblock + LPC_ORDER, VAR_1,\nblock, BLOCKSIZE, LPC_ORDER, 1, 0, 0xfff))\nmemset(VAR_0->curr_sblock, 0, (LPC_ORDER+BLOCKSIZE)*sizeof(*VAR_0->curr_sblock));", "}" ]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33, 35 ], [ 39 ], [ 43, 45 ], [ 49, 51 ], [ 55, 57, 59 ], [ 61 ] ]
6,120
static struct omap_prcm_s *omap_prcm_init(struct omap_target_agent_s *ta, qemu_irq mpu_int, qemu_irq dsp_int, qemu_irq iva_int, struct omap_mpu_state_s *mpu) { struct omap_prcm_s *s = (struct omap_prcm_s *) g_malloc0(sizeof(struct omap_prcm_s)); s->irq[0] = mpu_int; s->irq[1] = dsp_int; s->irq[2] = iva_int; s->mpu = mpu; omap_prcm_coldreset(s); memory_region_init_io(&s->iomem0, NULL, &omap_prcm_ops, s, "omap.pcrm0", omap_l4_region_size(ta, 0)); memory_region_init_io(&s->iomem1, NULL, &omap_prcm_ops, s, "omap.pcrm1", omap_l4_region_size(ta, 1)); omap_l4_attach(ta, 0, &s->iomem0); omap_l4_attach(ta, 1, &s->iomem1); return s; }
true
qemu
b45c03f585ea9bb1af76c73e82195418c294919d
static struct omap_prcm_s *omap_prcm_init(struct omap_target_agent_s *ta, qemu_irq mpu_int, qemu_irq dsp_int, qemu_irq iva_int, struct omap_mpu_state_s *mpu) { struct omap_prcm_s *s = (struct omap_prcm_s *) g_malloc0(sizeof(struct omap_prcm_s)); s->irq[0] = mpu_int; s->irq[1] = dsp_int; s->irq[2] = iva_int; s->mpu = mpu; omap_prcm_coldreset(s); memory_region_init_io(&s->iomem0, NULL, &omap_prcm_ops, s, "omap.pcrm0", omap_l4_region_size(ta, 0)); memory_region_init_io(&s->iomem1, NULL, &omap_prcm_ops, s, "omap.pcrm1", omap_l4_region_size(ta, 1)); omap_l4_attach(ta, 0, &s->iomem0); omap_l4_attach(ta, 1, &s->iomem1); return s; }
{ "code": [ " struct omap_prcm_s *s = (struct omap_prcm_s *)", " g_malloc0(sizeof(struct omap_prcm_s));" ], "line_no": [ 9, 11 ] }
static struct omap_prcm_s *FUNC_0(struct omap_target_agent_s *VAR_0, qemu_irq VAR_1, qemu_irq VAR_2, qemu_irq VAR_3, struct omap_mpu_state_s *VAR_4) { struct omap_prcm_s *VAR_5 = (struct omap_prcm_s *) g_malloc0(sizeof(struct omap_prcm_s)); VAR_5->irq[0] = VAR_1; VAR_5->irq[1] = VAR_2; VAR_5->irq[2] = VAR_3; VAR_5->VAR_4 = VAR_4; omap_prcm_coldreset(VAR_5); memory_region_init_io(&VAR_5->iomem0, NULL, &omap_prcm_ops, VAR_5, "omap.pcrm0", omap_l4_region_size(VAR_0, 0)); memory_region_init_io(&VAR_5->iomem1, NULL, &omap_prcm_ops, VAR_5, "omap.pcrm1", omap_l4_region_size(VAR_0, 1)); omap_l4_attach(VAR_0, 0, &VAR_5->iomem0); omap_l4_attach(VAR_0, 1, &VAR_5->iomem1); return VAR_5; }
[ "static struct omap_prcm_s *FUNC_0(struct omap_target_agent_s *VAR_0,\nqemu_irq VAR_1, qemu_irq VAR_2, qemu_irq VAR_3,\nstruct omap_mpu_state_s *VAR_4)\n{", "struct omap_prcm_s *VAR_5 = (struct omap_prcm_s *)\ng_malloc0(sizeof(struct omap_prcm_s));", "VAR_5->irq[0] = VAR_1;", "VAR_5->irq[1] = VAR_2;", "VAR_5->irq[2] = VAR_3;", "VAR_5->VAR_4 = VAR_4;", "omap_prcm_coldreset(VAR_5);", "memory_region_init_io(&VAR_5->iomem0, NULL, &omap_prcm_ops, VAR_5, \"omap.pcrm0\",\nomap_l4_region_size(VAR_0, 0));", "memory_region_init_io(&VAR_5->iomem1, NULL, &omap_prcm_ops, VAR_5, \"omap.pcrm1\",\nomap_l4_region_size(VAR_0, 1));", "omap_l4_attach(VAR_0, 0, &VAR_5->iomem0);", "omap_l4_attach(VAR_0, 1, &VAR_5->iomem1);", "return VAR_5;", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9, 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27, 29 ], [ 31, 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ] ]
6,121
static void close_file(OutputStream *os) { int64_t pos = avio_tell(os->out); avio_seek(os->out, 0, SEEK_SET); avio_wb32(os->out, pos); avio_flush(os->out); avio_close(os->out); os->out = NULL; }
false
FFmpeg
9f61abc8111c7c43f49ca012e957a108b9cc7610
static void close_file(OutputStream *os) { int64_t pos = avio_tell(os->out); avio_seek(os->out, 0, SEEK_SET); avio_wb32(os->out, pos); avio_flush(os->out); avio_close(os->out); os->out = NULL; }
{ "code": [], "line_no": [] }
static void FUNC_0(OutputStream *VAR_0) { int64_t pos = avio_tell(VAR_0->out); avio_seek(VAR_0->out, 0, SEEK_SET); avio_wb32(VAR_0->out, pos); avio_flush(VAR_0->out); avio_close(VAR_0->out); VAR_0->out = NULL; }
[ "static void FUNC_0(OutputStream *VAR_0)\n{", "int64_t pos = avio_tell(VAR_0->out);", "avio_seek(VAR_0->out, 0, SEEK_SET);", "avio_wb32(VAR_0->out, pos);", "avio_flush(VAR_0->out);", "avio_close(VAR_0->out);", "VAR_0->out = NULL;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ] ]
6,122
static int g726_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { G726Context *c = avctx->priv_data; const int16_t *samples = (const int16_t *)frame->data[0]; PutBitContext pb; int i, ret, out_size; out_size = (frame->nb_samples * c->code_size + 7) / 8; if ((ret = ff_alloc_packet2(avctx, avpkt, out_size))) return ret; init_put_bits(&pb, avpkt->data, avpkt->size); for (i = 0; i < frame->nb_samples; i++) put_bits(&pb, c->code_size, g726_encode(c, *samples++)); flush_put_bits(&pb); avpkt->size = out_size; *got_packet_ptr = 1; return 0; }
false
FFmpeg
bcaf64b605442e1622d16da89d4ec0e7730b8a8c
static int g726_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { G726Context *c = avctx->priv_data; const int16_t *samples = (const int16_t *)frame->data[0]; PutBitContext pb; int i, ret, out_size; out_size = (frame->nb_samples * c->code_size + 7) / 8; if ((ret = ff_alloc_packet2(avctx, avpkt, out_size))) return ret; init_put_bits(&pb, avpkt->data, avpkt->size); for (i = 0; i < frame->nb_samples; i++) put_bits(&pb, c->code_size, g726_encode(c, *samples++)); flush_put_bits(&pb); avpkt->size = out_size; *got_packet_ptr = 1; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1, const AVFrame *VAR_2, int *VAR_3) { G726Context *c = VAR_0->priv_data; const int16_t *VAR_4 = (const int16_t *)VAR_2->data[0]; PutBitContext pb; int VAR_5, VAR_6, VAR_7; VAR_7 = (VAR_2->nb_samples * c->code_size + 7) / 8; if ((VAR_6 = ff_alloc_packet2(VAR_0, VAR_1, VAR_7))) return VAR_6; init_put_bits(&pb, VAR_1->data, VAR_1->size); for (VAR_5 = 0; VAR_5 < VAR_2->nb_samples; VAR_5++) put_bits(&pb, c->code_size, g726_encode(c, *VAR_4++)); flush_put_bits(&pb); VAR_1->size = VAR_7; *VAR_3 = 1; return 0; }
[ "static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,\nconst AVFrame *VAR_2, int *VAR_3)\n{", "G726Context *c = VAR_0->priv_data;", "const int16_t *VAR_4 = (const int16_t *)VAR_2->data[0];", "PutBitContext pb;", "int VAR_5, VAR_6, VAR_7;", "VAR_7 = (VAR_2->nb_samples * c->code_size + 7) / 8;", "if ((VAR_6 = ff_alloc_packet2(VAR_0, VAR_1, VAR_7)))\nreturn VAR_6;", "init_put_bits(&pb, VAR_1->data, VAR_1->size);", "for (VAR_5 = 0; VAR_5 < VAR_2->nb_samples; VAR_5++)", "put_bits(&pb, c->code_size, g726_encode(c, *VAR_4++));", "flush_put_bits(&pb);", "VAR_1->size = VAR_7;", "*VAR_3 = 1;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19, 21 ], [ 23 ], [ 27 ], [ 29 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ] ]
6,123
static int virtio_rng_load(QEMUFile *f, void *opaque, int version_id) { if (version_id != 1) { return -EINVAL; } return virtio_load(VIRTIO_DEVICE(opaque), f, version_id); }
true
qemu
db12451decf7dfe0f083564183e135f2095228b9
static int virtio_rng_load(QEMUFile *f, void *opaque, int version_id) { if (version_id != 1) { return -EINVAL; } return virtio_load(VIRTIO_DEVICE(opaque), f, version_id); }
{ "code": [ " return virtio_load(VIRTIO_DEVICE(opaque), f, version_id);" ], "line_no": [ 11 ] }
static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, int VAR_2) { if (VAR_2 != 1) { return -EINVAL; } return virtio_load(VIRTIO_DEVICE(VAR_1), VAR_0, VAR_2); }
[ "static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, int VAR_2)\n{", "if (VAR_2 != 1) {", "return -EINVAL;", "}", "return virtio_load(VIRTIO_DEVICE(VAR_1), VAR_0, VAR_2);", "}" ]
[ 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ] ]
6,124
static void dpy_refresh(DisplayState *s) { DisplayChangeListener *dcl; QLIST_FOREACH(dcl, &s->listeners, next) { if (dcl->ops->dpy_refresh) { dcl->ops->dpy_refresh(dcl); } } }
true
qemu
8bb93c6f99a42c2e0943bc904b283cd622d302c5
static void dpy_refresh(DisplayState *s) { DisplayChangeListener *dcl; QLIST_FOREACH(dcl, &s->listeners, next) { if (dcl->ops->dpy_refresh) { dcl->ops->dpy_refresh(dcl); } } }
{ "code": [ " dcl->ops->dpy_refresh(dcl);" ], "line_no": [ 13 ] }
static void FUNC_0(DisplayState *VAR_0) { DisplayChangeListener *dcl; QLIST_FOREACH(dcl, &VAR_0->listeners, next) { if (dcl->ops->FUNC_0) { dcl->ops->FUNC_0(dcl); } } }
[ "static void FUNC_0(DisplayState *VAR_0)\n{", "DisplayChangeListener *dcl;", "QLIST_FOREACH(dcl, &VAR_0->listeners, next) {", "if (dcl->ops->FUNC_0) {", "dcl->ops->FUNC_0(dcl);", "}", "}", "}" ]
[ 0, 0, 0, 0, 1, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
6,126
static void sysbus_ahci_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = sysbus_ahci_realize; dc->vmsd = &vmstate_sysbus_ahci; dc->props = sysbus_ahci_properties; dc->reset = sysbus_ahci_reset; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); }
true
qemu
e4f4fb1eca795e36f363b4647724221e774523c1
static void sysbus_ahci_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = sysbus_ahci_realize; dc->vmsd = &vmstate_sysbus_ahci; dc->props = sysbus_ahci_properties; dc->reset = sysbus_ahci_reset; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); }
{ "code": [], "line_no": [] }
static void FUNC_0(ObjectClass *VAR_0, void *VAR_1) { DeviceClass *dc = DEVICE_CLASS(VAR_0); dc->realize = sysbus_ahci_realize; dc->vmsd = &vmstate_sysbus_ahci; dc->props = sysbus_ahci_properties; dc->reset = sysbus_ahci_reset; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); }
[ "static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{", "DeviceClass *dc = DEVICE_CLASS(VAR_0);", "dc->realize = sysbus_ahci_realize;", "dc->vmsd = &vmstate_sysbus_ahci;", "dc->props = sysbus_ahci_properties;", "dc->reset = sysbus_ahci_reset;", "set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 24 ] ]
6,127
static void read_apic(AVFormatContext *s, AVIOContext *pb, int taglen, char *tag, ID3v2ExtraMeta **extra_meta) { int enc, pic_type; char mimetype[64]; const CodecMime *mime = ff_id3v2_mime_tags; enum AVCodecID id = AV_CODEC_ID_NONE; ID3v2ExtraMetaAPIC *apic = NULL; ID3v2ExtraMeta *new_extra = NULL; int64_t end = avio_tell(pb) + taglen; if (taglen <= 4) goto fail; new_extra = av_mallocz(sizeof(*new_extra)); apic = av_mallocz(sizeof(*apic)); if (!new_extra || !apic) goto fail; enc = avio_r8(pb); taglen--; /* mimetype */ taglen -= avio_get_str(pb, taglen, mimetype, sizeof(mimetype)); while (mime->id != AV_CODEC_ID_NONE) { if (!av_strncasecmp(mime->str, mimetype, sizeof(mimetype))) { id = mime->id; break; } mime++; } if (id == AV_CODEC_ID_NONE) { av_log(s, AV_LOG_WARNING, "Unknown attached picture mimetype: %s, skipping.\n", mimetype); goto fail; } apic->id = id; /* picture type */ pic_type = avio_r8(pb); taglen--; if (pic_type < 0 || pic_type >= FF_ARRAY_ELEMS(ff_id3v2_picture_types)) { av_log(s, AV_LOG_WARNING, "Unknown attached picture type %d.\n", pic_type); pic_type = 0; } apic->type = ff_id3v2_picture_types[pic_type]; /* description and picture data */ if (decode_str(s, pb, enc, &apic->description, &taglen) < 0) { av_log(s, AV_LOG_ERROR, "Error decoding attached picture description.\n"); goto fail; } apic->buf = av_buffer_alloc(taglen); if (!apic->buf || !taglen || avio_read(pb, apic->buf->data, taglen) != taglen) goto fail; new_extra->tag = "APIC"; new_extra->data = apic; new_extra->next = *extra_meta; *extra_meta = new_extra; return; fail: if (apic) free_apic(apic); av_freep(&new_extra); avio_seek(pb, end, SEEK_SET); }
true
FFmpeg
24cfe91a220204e56394c85bca51799b77df175b
static void read_apic(AVFormatContext *s, AVIOContext *pb, int taglen, char *tag, ID3v2ExtraMeta **extra_meta) { int enc, pic_type; char mimetype[64]; const CodecMime *mime = ff_id3v2_mime_tags; enum AVCodecID id = AV_CODEC_ID_NONE; ID3v2ExtraMetaAPIC *apic = NULL; ID3v2ExtraMeta *new_extra = NULL; int64_t end = avio_tell(pb) + taglen; if (taglen <= 4) goto fail; new_extra = av_mallocz(sizeof(*new_extra)); apic = av_mallocz(sizeof(*apic)); if (!new_extra || !apic) goto fail; enc = avio_r8(pb); taglen--; taglen -= avio_get_str(pb, taglen, mimetype, sizeof(mimetype)); while (mime->id != AV_CODEC_ID_NONE) { if (!av_strncasecmp(mime->str, mimetype, sizeof(mimetype))) { id = mime->id; break; } mime++; } if (id == AV_CODEC_ID_NONE) { av_log(s, AV_LOG_WARNING, "Unknown attached picture mimetype: %s, skipping.\n", mimetype); goto fail; } apic->id = id; pic_type = avio_r8(pb); taglen--; if (pic_type < 0 || pic_type >= FF_ARRAY_ELEMS(ff_id3v2_picture_types)) { av_log(s, AV_LOG_WARNING, "Unknown attached picture type %d.\n", pic_type); pic_type = 0; } apic->type = ff_id3v2_picture_types[pic_type]; if (decode_str(s, pb, enc, &apic->description, &taglen) < 0) { av_log(s, AV_LOG_ERROR, "Error decoding attached picture description.\n"); goto fail; } apic->buf = av_buffer_alloc(taglen); if (!apic->buf || !taglen || avio_read(pb, apic->buf->data, taglen) != taglen) goto fail; new_extra->tag = "APIC"; new_extra->data = apic; new_extra->next = *extra_meta; *extra_meta = new_extra; return; fail: if (apic) free_apic(apic); av_freep(&new_extra); avio_seek(pb, end, SEEK_SET); }
{ "code": [ " apic->buf = av_buffer_alloc(taglen);" ], "line_no": [ 103 ] }
static void FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1, int VAR_2, char *VAR_3, ID3v2ExtraMeta **VAR_4) { int VAR_5, VAR_6; char VAR_7[64]; const CodecMime *VAR_8 = ff_id3v2_mime_tags; enum AVCodecID VAR_9 = AV_CODEC_ID_NONE; ID3v2ExtraMetaAPIC *apic = NULL; ID3v2ExtraMeta *new_extra = NULL; int64_t end = avio_tell(VAR_1) + VAR_2; if (VAR_2 <= 4) goto fail; new_extra = av_mallocz(sizeof(*new_extra)); apic = av_mallocz(sizeof(*apic)); if (!new_extra || !apic) goto fail; VAR_5 = avio_r8(VAR_1); VAR_2--; VAR_2 -= avio_get_str(VAR_1, VAR_2, VAR_7, sizeof(VAR_7)); while (VAR_8->VAR_9 != AV_CODEC_ID_NONE) { if (!av_strncasecmp(VAR_8->str, VAR_7, sizeof(VAR_7))) { VAR_9 = VAR_8->VAR_9; break; } VAR_8++; } if (VAR_9 == AV_CODEC_ID_NONE) { av_log(VAR_0, AV_LOG_WARNING, "Unknown attached picture VAR_7: %VAR_0, skipping.\n", VAR_7); goto fail; } apic->VAR_9 = VAR_9; VAR_6 = avio_r8(VAR_1); VAR_2--; if (VAR_6 < 0 || VAR_6 >= FF_ARRAY_ELEMS(ff_id3v2_picture_types)) { av_log(VAR_0, AV_LOG_WARNING, "Unknown attached picture type %d.\n", VAR_6); VAR_6 = 0; } apic->type = ff_id3v2_picture_types[VAR_6]; if (decode_str(VAR_0, VAR_1, VAR_5, &apic->description, &VAR_2) < 0) { av_log(VAR_0, AV_LOG_ERROR, "Error decoding attached picture description.\n"); goto fail; } apic->buf = av_buffer_alloc(VAR_2); if (!apic->buf || !VAR_2 || avio_read(VAR_1, apic->buf->data, VAR_2) != VAR_2) goto fail; new_extra->VAR_3 = "APIC"; new_extra->data = apic; new_extra->next = *VAR_4; *VAR_4 = new_extra; return; fail: if (apic) free_apic(apic); av_freep(&new_extra); avio_seek(VAR_1, end, SEEK_SET); }
[ "static void FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1, int VAR_2, char *VAR_3, ID3v2ExtraMeta **VAR_4)\n{", "int VAR_5, VAR_6;", "char VAR_7[64];", "const CodecMime *VAR_8 = ff_id3v2_mime_tags;", "enum AVCodecID VAR_9 = AV_CODEC_ID_NONE;", "ID3v2ExtraMetaAPIC *apic = NULL;", "ID3v2ExtraMeta *new_extra = NULL;", "int64_t end = avio_tell(VAR_1) + VAR_2;", "if (VAR_2 <= 4)\ngoto fail;", "new_extra = av_mallocz(sizeof(*new_extra));", "apic = av_mallocz(sizeof(*apic));", "if (!new_extra || !apic)\ngoto fail;", "VAR_5 = avio_r8(VAR_1);", "VAR_2--;", "VAR_2 -= avio_get_str(VAR_1, VAR_2, VAR_7, sizeof(VAR_7));", "while (VAR_8->VAR_9 != AV_CODEC_ID_NONE) {", "if (!av_strncasecmp(VAR_8->str, VAR_7, sizeof(VAR_7))) {", "VAR_9 = VAR_8->VAR_9;", "break;", "}", "VAR_8++;", "}", "if (VAR_9 == AV_CODEC_ID_NONE) {", "av_log(VAR_0, AV_LOG_WARNING, \"Unknown attached picture VAR_7: %VAR_0, skipping.\\n\", VAR_7);", "goto fail;", "}", "apic->VAR_9 = VAR_9;", "VAR_6 = avio_r8(VAR_1);", "VAR_2--;", "if (VAR_6 < 0 || VAR_6 >= FF_ARRAY_ELEMS(ff_id3v2_picture_types)) {", "av_log(VAR_0, AV_LOG_WARNING, \"Unknown attached picture type %d.\\n\", VAR_6);", "VAR_6 = 0;", "}", "apic->type = ff_id3v2_picture_types[VAR_6];", "if (decode_str(VAR_0, VAR_1, VAR_5, &apic->description, &VAR_2) < 0) {", "av_log(VAR_0, AV_LOG_ERROR, \"Error decoding attached picture description.\\n\");", "goto fail;", "}", "apic->buf = av_buffer_alloc(VAR_2);", "if (!apic->buf || !VAR_2 || avio_read(VAR_1, apic->buf->data, VAR_2) != VAR_2)\ngoto fail;", "new_extra->VAR_3 = \"APIC\";", "new_extra->data = apic;", "new_extra->next = *VAR_4;", "*VAR_4 = new_extra;", "return;", "fail:\nif (apic)\nfree_apic(apic);", "av_freep(&new_extra);", "avio_seek(VAR_1, end, SEEK_SET);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 27 ], [ 29 ], [ 31, 33 ], [ 37 ], [ 39 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 103 ], [ 105, 107 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 121 ], [ 125, 127, 129 ], [ 131 ], [ 133 ], [ 135 ] ]
6,128
readv_f(int argc, char **argv) { struct timeval t1, t2; int Cflag = 0, qflag = 0, vflag = 0; int c, cnt; char *buf; int64_t offset; int total; int nr_iov; QEMUIOVector qiov; int pattern = 0; int Pflag = 0; while ((c = getopt(argc, argv, "CP:qv")) != EOF) { switch (c) { case 'C': Cflag = 1; break; case 'P': Pflag = 1; pattern = atoi(optarg); break; case 'q': qflag = 1; break; case 'v': vflag = 1; break; default: return command_usage(&readv_cmd); } } if (optind > argc - 2) return command_usage(&readv_cmd); offset = cvtnum(argv[optind]); if (offset < 0) { printf("non-numeric length argument -- %s\n", argv[optind]); return 0; } optind++; if (offset & 0x1ff) { printf("offset %lld is not sector aligned\n", (long long)offset); return 0; } nr_iov = argc - optind; buf = create_iovec(&qiov, &argv[optind], nr_iov, 0xab); gettimeofday(&t1, NULL); cnt = do_aio_readv(&qiov, offset, &total); gettimeofday(&t2, NULL); if (cnt < 0) { printf("readv failed: %s\n", strerror(-cnt)); return 0; } if (Pflag) { void* cmp_buf = malloc(qiov.size); memset(cmp_buf, pattern, qiov.size); if (memcmp(buf, cmp_buf, qiov.size)) { printf("Pattern verification failed at offset %lld, " "%zd bytes\n", (long long) offset, qiov.size); } free(cmp_buf); } if (qflag) return 0; if (vflag) dump_buffer(buf, offset, qiov.size); /* Finally, report back -- -C gives a parsable format */ t2 = tsub(t2, t1); print_report("read", &t2, offset, qiov.size, total, cnt, Cflag); qemu_io_free(buf); return 0; }
true
qemu
7d8abfcb50a33aed369bbd267852cf04009c49e9
readv_f(int argc, char **argv) { struct timeval t1, t2; int Cflag = 0, qflag = 0, vflag = 0; int c, cnt; char *buf; int64_t offset; int total; int nr_iov; QEMUIOVector qiov; int pattern = 0; int Pflag = 0; while ((c = getopt(argc, argv, "CP:qv")) != EOF) { switch (c) { case 'C': Cflag = 1; break; case 'P': Pflag = 1; pattern = atoi(optarg); break; case 'q': qflag = 1; break; case 'v': vflag = 1; break; default: return command_usage(&readv_cmd); } } if (optind > argc - 2) return command_usage(&readv_cmd); offset = cvtnum(argv[optind]); if (offset < 0) { printf("non-numeric length argument -- %s\n", argv[optind]); return 0; } optind++; if (offset & 0x1ff) { printf("offset %lld is not sector aligned\n", (long long)offset); return 0; } nr_iov = argc - optind; buf = create_iovec(&qiov, &argv[optind], nr_iov, 0xab); gettimeofday(&t1, NULL); cnt = do_aio_readv(&qiov, offset, &total); gettimeofday(&t2, NULL); if (cnt < 0) { printf("readv failed: %s\n", strerror(-cnt)); return 0; } if (Pflag) { void* cmp_buf = malloc(qiov.size); memset(cmp_buf, pattern, qiov.size); if (memcmp(buf, cmp_buf, qiov.size)) { printf("Pattern verification failed at offset %lld, " "%zd bytes\n", (long long) offset, qiov.size); } free(cmp_buf); } if (qflag) return 0; if (vflag) dump_buffer(buf, offset, qiov.size); t2 = tsub(t2, t1); print_report("read", &t2, offset, qiov.size, total, cnt, Cflag); qemu_io_free(buf); return 0; }
{ "code": [ "\t\treturn 0;", "\t\treturn 0;", "\t\treturn 0;", "\t\treturn 0;", "\t\treturn 0;", "\t\treturn 0;", "\t\treturn 0;", "\t\treturn 0;", "\tif (optind > argc - 2)", "\tif (optind > argc - 2)" ], "line_no": [ 81, 81, 81, 81, 81, 81, 81, 81, 67, 67 ] }
FUNC_0(int VAR_0, char **VAR_1) { struct timeval VAR_2, VAR_3; int VAR_4 = 0, VAR_5 = 0, VAR_6 = 0; int VAR_7, VAR_8; char *VAR_9; int64_t offset; int VAR_10; int VAR_11; QEMUIOVector qiov; int VAR_12 = 0; int VAR_13 = 0; while ((VAR_7 = getopt(VAR_0, VAR_1, "CP:qv")) != EOF) { switch (VAR_7) { case 'C': VAR_4 = 1; break; case 'P': VAR_13 = 1; VAR_12 = atoi(optarg); break; case 'q': VAR_5 = 1; break; case 'v': VAR_6 = 1; break; default: return command_usage(&readv_cmd); } } if (optind > VAR_0 - 2) return command_usage(&readv_cmd); offset = cvtnum(VAR_1[optind]); if (offset < 0) { printf("non-numeric length argument -- %s\n", VAR_1[optind]); return 0; } optind++; if (offset & 0x1ff) { printf("offset %lld is not sector aligned\n", (long long)offset); return 0; } VAR_11 = VAR_0 - optind; VAR_9 = create_iovec(&qiov, &VAR_1[optind], VAR_11, 0xab); gettimeofday(&VAR_2, NULL); VAR_8 = do_aio_readv(&qiov, offset, &VAR_10); gettimeofday(&VAR_3, NULL); if (VAR_8 < 0) { printf("readv failed: %s\n", strerror(-VAR_8)); return 0; } if (VAR_13) { void* VAR_14 = malloc(qiov.size); memset(VAR_14, VAR_12, qiov.size); if (memcmp(VAR_9, VAR_14, qiov.size)) { printf("Pattern verification failed at offset %lld, " "%zd bytes\n", (long long) offset, qiov.size); } free(VAR_14); } if (VAR_5) return 0; if (VAR_6) dump_buffer(VAR_9, offset, qiov.size); VAR_3 = tsub(VAR_3, VAR_2); print_report("read", &VAR_3, offset, qiov.size, VAR_10, VAR_8, VAR_4); qemu_io_free(VAR_9); return 0; }
[ "FUNC_0(int VAR_0, char **VAR_1)\n{", "struct timeval VAR_2, VAR_3;", "int VAR_4 = 0, VAR_5 = 0, VAR_6 = 0;", "int VAR_7, VAR_8;", "char *VAR_9;", "int64_t offset;", "int VAR_10;", "int VAR_11;", "QEMUIOVector qiov;", "int VAR_12 = 0;", "int VAR_13 = 0;", "while ((VAR_7 = getopt(VAR_0, VAR_1, \"CP:qv\")) != EOF) {", "switch (VAR_7) {", "case 'C':\nVAR_4 = 1;", "break;", "case 'P':\nVAR_13 = 1;", "VAR_12 = atoi(optarg);", "break;", "case 'q':\nVAR_5 = 1;", "break;", "case 'v':\nVAR_6 = 1;", "break;", "default:\nreturn command_usage(&readv_cmd);", "}", "}", "if (optind > VAR_0 - 2)\nreturn command_usage(&readv_cmd);", "offset = cvtnum(VAR_1[optind]);", "if (offset < 0) {", "printf(\"non-numeric length argument -- %s\\n\", VAR_1[optind]);", "return 0;", "}", "optind++;", "if (offset & 0x1ff) {", "printf(\"offset %lld is not sector aligned\\n\",\n(long long)offset);", "return 0;", "}", "VAR_11 = VAR_0 - optind;", "VAR_9 = create_iovec(&qiov, &VAR_1[optind], VAR_11, 0xab);", "gettimeofday(&VAR_2, NULL);", "VAR_8 = do_aio_readv(&qiov, offset, &VAR_10);", "gettimeofday(&VAR_3, NULL);", "if (VAR_8 < 0) {", "printf(\"readv failed: %s\\n\", strerror(-VAR_8));", "return 0;", "}", "if (VAR_13) {", "void* VAR_14 = malloc(qiov.size);", "memset(VAR_14, VAR_12, qiov.size);", "if (memcmp(VAR_9, VAR_14, qiov.size)) {", "printf(\"Pattern verification failed at offset %lld, \"\n\"%zd bytes\\n\",\n(long long) offset, qiov.size);", "}", "free(VAR_14);", "}", "if (VAR_5)\nreturn 0;", "if (VAR_6)\ndump_buffer(VAR_9, offset, qiov.size);", "VAR_3 = tsub(VAR_3, VAR_2);", "print_report(\"read\", &VAR_3, offset, qiov.size, VAR_10, VAR_8, VAR_4);", "qemu_io_free(VAR_9);", "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, 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, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31, 33 ], [ 35 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 45, 47 ], [ 49 ], [ 51, 53 ], [ 55 ], [ 57, 59 ], [ 61 ], [ 63 ], [ 67, 69 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 89 ], [ 91, 93 ], [ 95 ], [ 97 ], [ 101 ], [ 103 ], [ 107 ], [ 109 ], [ 111 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133, 135, 137 ], [ 139 ], [ 141 ], [ 143 ], [ 147, 149 ], [ 153, 155 ], [ 161 ], [ 163 ], [ 167 ], [ 171 ], [ 173 ] ]
6,130
static int opt_vstats(void *optctx, const char *opt, const char *arg) { char filename[40]; time_t today2 = time(NULL); struct tm *today = localtime(&today2); snprintf(filename, sizeof(filename), "vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min, today->tm_sec); return opt_vstats_file(NULL, opt, filename); }
true
FFmpeg
8e91d9652ea5048d9014e7636e12c6ed4732d7b7
static int opt_vstats(void *optctx, const char *opt, const char *arg) { char filename[40]; time_t today2 = time(NULL); struct tm *today = localtime(&today2); snprintf(filename, sizeof(filename), "vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min, today->tm_sec); return opt_vstats_file(NULL, opt, filename); }
{ "code": [], "line_no": [] }
static int FUNC_0(void *VAR_0, const char *VAR_1, const char *VAR_2) { char VAR_3[40]; time_t today2 = time(NULL); struct tm *VAR_4 = localtime(&today2); snprintf(VAR_3, sizeof(VAR_3), "vstats_%02d%02d%02d.log", VAR_4->tm_hour, VAR_4->tm_min, VAR_4->tm_sec); return opt_vstats_file(NULL, VAR_1, VAR_3); }
[ "static int FUNC_0(void *VAR_0, const char *VAR_1, const char *VAR_2)\n{", "char VAR_3[40];", "time_t today2 = time(NULL);", "struct tm *VAR_4 = localtime(&today2);", "snprintf(VAR_3, sizeof(VAR_3), \"vstats_%02d%02d%02d.log\", VAR_4->tm_hour, VAR_4->tm_min,\nVAR_4->tm_sec);", "return opt_vstats_file(NULL, VAR_1, VAR_3);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 2 ], [ 3 ], [ 4 ], [ 5 ], [ 6, 7 ], [ 8 ], [ 9 ] ]
6,131
static void gen_brcond(DisasContext *dc, TCGCond cond, TCGv_i32 t0, TCGv_i32 t1, uint32_t offset) { int label = gen_new_label(); tcg_gen_brcond_i32(cond, t0, t1, label); gen_jumpi(dc, dc->next_pc, 0); gen_set_label(label); gen_jumpi(dc, dc->pc + offset, 1); }
true
qemu
797d780b1375b1af1d7713685589bfdec9908dc3
static void gen_brcond(DisasContext *dc, TCGCond cond, TCGv_i32 t0, TCGv_i32 t1, uint32_t offset) { int label = gen_new_label(); tcg_gen_brcond_i32(cond, t0, t1, label); gen_jumpi(dc, dc->next_pc, 0); gen_set_label(label); gen_jumpi(dc, dc->pc + offset, 1); }
{ "code": [ " gen_jumpi(dc, dc->next_pc, 0);" ], "line_no": [ 13 ] }
static void FUNC_0(DisasContext *VAR_0, TCGCond VAR_1, TCGv_i32 VAR_2, TCGv_i32 VAR_3, uint32_t VAR_4) { int VAR_5 = gen_new_label(); tcg_gen_brcond_i32(VAR_1, VAR_2, VAR_3, VAR_5); gen_jumpi(VAR_0, VAR_0->next_pc, 0); gen_set_label(VAR_5); gen_jumpi(VAR_0, VAR_0->pc + VAR_4, 1); }
[ "static void FUNC_0(DisasContext *VAR_0, TCGCond VAR_1,\nTCGv_i32 VAR_2, TCGv_i32 VAR_3, uint32_t VAR_4)\n{", "int VAR_5 = gen_new_label();", "tcg_gen_brcond_i32(VAR_1, VAR_2, VAR_3, VAR_5);", "gen_jumpi(VAR_0, VAR_0->next_pc, 0);", "gen_set_label(VAR_5);", "gen_jumpi(VAR_0, VAR_0->pc + VAR_4, 1);", "}" ]
[ 0, 0, 0, 1, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
6,132
void palette8tobgr24(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette) { unsigned i; /* writes 1 byte o much and might cause alignment issues on some architectures? for(i=0; i<num_pixels; i++) ((unsigned *)(&dst[i*3])) = ((unsigned *)palette)[ src[i] ]; */ for(i=0; i<num_pixels; i++) { //FIXME slow? dst[0]= palette[ src[i]*4+0 ]; dst[1]= palette[ src[i]*4+1 ]; dst[2]= palette[ src[i]*4+2 ]; dst+= 3; } }
true
FFmpeg
7f526efd17973ec6d2204f7a47b6923e2be31363
void palette8tobgr24(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette) { unsigned i; for(i=0; i<num_pixels; i++) { dst[0]= palette[ src[i]*4+0 ]; dst[1]= palette[ src[i]*4+1 ]; dst[2]= palette[ src[i]*4+2 ]; dst+= 3; } }
{ "code": [ "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "void palette8tobgr24(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette)", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;", "\tunsigned i;" ], "line_no": [ 5, 5, 5, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 ] }
void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, unsigned VAR_2, const uint8_t *VAR_3) { unsigned VAR_4; for(VAR_4=0; VAR_4<VAR_2; VAR_4++) { VAR_1[0]= VAR_3[ VAR_0[VAR_4]*4+0 ]; VAR_1[1]= VAR_3[ VAR_0[VAR_4]*4+1 ]; VAR_1[2]= VAR_3[ VAR_0[VAR_4]*4+2 ]; VAR_1+= 3; } }
[ "void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, unsigned VAR_2, const uint8_t *VAR_3)\n{", "unsigned VAR_4;", "for(VAR_4=0; VAR_4<VAR_2; VAR_4++)", "{", "VAR_1[0]= VAR_3[ VAR_0[VAR_4]*4+0 ];", "VAR_1[1]= VAR_3[ VAR_0[VAR_4]*4+1 ];", "VAR_1[2]= VAR_3[ VAR_0[VAR_4]*4+2 ];", "VAR_1+= 3;", "}", "}" ]
[ 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ] ]
6,134
bool qpci_msix_pending(QPCIDevice *dev, uint16_t entry) { uint32_t pba_entry; uint8_t bit_n = entry % 32; void *addr = dev->msix_pba + (entry / 32) * PCI_MSIX_ENTRY_SIZE / 4; g_assert(dev->msix_enabled); pba_entry = qpci_io_readl(dev, addr); qpci_io_writel(dev, addr, pba_entry & ~(1 << bit_n)); return (pba_entry & (1 << bit_n)) != 0; }
true
qemu
b4ba67d9a702507793c2724e56f98e9b0f7be02b
bool qpci_msix_pending(QPCIDevice *dev, uint16_t entry) { uint32_t pba_entry; uint8_t bit_n = entry % 32; void *addr = dev->msix_pba + (entry / 32) * PCI_MSIX_ENTRY_SIZE / 4; g_assert(dev->msix_enabled); pba_entry = qpci_io_readl(dev, addr); qpci_io_writel(dev, addr, pba_entry & ~(1 << bit_n)); return (pba_entry & (1 << bit_n)) != 0; }
{ "code": [ " void *addr = dev->msix_pba + (entry / 32) * PCI_MSIX_ENTRY_SIZE / 4;", " pba_entry = qpci_io_readl(dev, addr);", " qpci_io_writel(dev, addr, pba_entry & ~(1 << bit_n));" ], "line_no": [ 9, 15, 17 ] }
bool FUNC_0(QPCIDevice *dev, uint16_t entry) { uint32_t pba_entry; uint8_t bit_n = entry % 32; void *VAR_0 = dev->msix_pba + (entry / 32) * PCI_MSIX_ENTRY_SIZE / 4; g_assert(dev->msix_enabled); pba_entry = qpci_io_readl(dev, VAR_0); qpci_io_writel(dev, VAR_0, pba_entry & ~(1 << bit_n)); return (pba_entry & (1 << bit_n)) != 0; }
[ "bool FUNC_0(QPCIDevice *dev, uint16_t entry)\n{", "uint32_t pba_entry;", "uint8_t bit_n = entry % 32;", "void *VAR_0 = dev->msix_pba + (entry / 32) * PCI_MSIX_ENTRY_SIZE / 4;", "g_assert(dev->msix_enabled);", "pba_entry = qpci_io_readl(dev, VAR_0);", "qpci_io_writel(dev, VAR_0, pba_entry & ~(1 << bit_n));", "return (pba_entry & (1 << bit_n)) != 0;", "}" ]
[ 0, 0, 0, 1, 0, 1, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ] ]
6,135
static void init_proc_750cx (CPUPPCState *env) { gen_spr_ne_601(env); gen_spr_7xx(env); /* XXX : not implemented */ spr_register(env, SPR_L2CR, "L2CR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, NULL, 0x00000000); /* Time base */ gen_tbl(env); /* Thermal management */ gen_spr_thrm(env); /* This register is not implemented but is present for compatibility */ spr_register(env, SPR_SDA, "SDA", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* Hardware implementation registers */ /* XXX : not implemented */ spr_register(env, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* XXX : not implemented */ spr_register(env, SPR_HID1, "HID1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); /* Memory management */ gen_low_BATs(env); /* PowerPC 750cx has 8 DBATs and 8 IBATs */ gen_high_BATs(env); init_excp_750cx(env); env->dcache_line_size = 32; env->icache_line_size = 32; /* Allocate hardware IRQ controller */ ppc6xx_irq_init(env); }
true
qemu
9633fcc6a02f23e3ef00aa5fe3fe9c41f57c3456
static void init_proc_750cx (CPUPPCState *env) { gen_spr_ne_601(env); gen_spr_7xx(env); spr_register(env, SPR_L2CR, "L2CR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, NULL, 0x00000000); gen_tbl(env); gen_spr_thrm(env); spr_register(env, SPR_SDA, "SDA", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_HID1, "HID1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); gen_low_BATs(env); gen_high_BATs(env); init_excp_750cx(env); env->dcache_line_size = 32; env->icache_line_size = 32; ppc6xx_irq_init(env); }
{ "code": [ " &spr_read_generic, NULL,", " &spr_read_generic, NULL,", " &spr_read_generic, NULL,", " &spr_read_generic, NULL,", " &spr_read_generic, NULL,", " &spr_read_generic, NULL,", " &spr_read_generic, NULL,", " &spr_read_generic, NULL,", " &spr_read_generic, NULL,", " &spr_read_generic, NULL,", " &spr_read_generic, NULL,", " &spr_read_generic, NULL," ], "line_no": [ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15 ] }
static void FUNC_0 (CPUPPCState *VAR_0) { gen_spr_ne_601(VAR_0); gen_spr_7xx(VAR_0); spr_register(VAR_0, SPR_L2CR, "L2CR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, NULL, 0x00000000); gen_tbl(VAR_0); gen_spr_thrm(VAR_0); spr_register(VAR_0, SPR_SDA, "SDA", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(VAR_0, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(VAR_0, SPR_HID1, "HID1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); gen_low_BATs(VAR_0); gen_high_BATs(VAR_0); init_excp_750cx(VAR_0); VAR_0->dcache_line_size = 32; VAR_0->icache_line_size = 32; ppc6xx_irq_init(VAR_0); }
[ "static void FUNC_0 (CPUPPCState *VAR_0)\n{", "gen_spr_ne_601(VAR_0);", "gen_spr_7xx(VAR_0);", "spr_register(VAR_0, SPR_L2CR, \"L2CR\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, NULL,\n0x00000000);", "gen_tbl(VAR_0);", "gen_spr_thrm(VAR_0);", "spr_register(VAR_0, SPR_SDA, \"SDA\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\n0x00000000);", "spr_register(VAR_0, SPR_HID0, \"HID0\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\n0x00000000);", "spr_register(VAR_0, SPR_HID1, \"HID1\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\n0x00000000);", "gen_low_BATs(VAR_0);", "gen_high_BATs(VAR_0);", "init_excp_750cx(VAR_0);", "VAR_0->dcache_line_size = 32;", "VAR_0->icache_line_size = 32;", "ppc6xx_irq_init(VAR_0);", "}" ]
[ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11, 13, 15, 17 ], [ 21 ], [ 25 ], [ 29, 31, 33, 35 ], [ 41, 43, 45, 47 ], [ 51, 53, 55, 57 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ] ]
6,136
static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_idx, InputStream *ist, int in_program) { AVStream *stream = ist->st; AVCodecParameters *par; AVCodecContext *dec_ctx; char val_str[128]; const char *s; AVRational sar, dar; AVBPrint pbuf; const AVCodecDescriptor *cd; int ret = 0; const char *profile = NULL; av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED); writer_print_section_header(w, in_program ? SECTION_ID_PROGRAM_STREAM : SECTION_ID_STREAM); print_int("index", stream->index); par = stream->codecpar; dec_ctx = ist->dec_ctx; if (cd = avcodec_descriptor_get(par->codec_id)) { print_str("codec_name", cd->name); if (!do_bitexact) { print_str("codec_long_name", cd->long_name ? cd->long_name : "unknown"); } } else { print_str_opt("codec_name", "unknown"); if (!do_bitexact) { print_str_opt("codec_long_name", "unknown"); } } if (!do_bitexact && (profile = avcodec_profile_name(par->codec_id, par->profile))) print_str("profile", profile); else { if (par->profile != FF_PROFILE_UNKNOWN) { char profile_num[12]; snprintf(profile_num, sizeof(profile_num), "%d", par->profile); print_str("profile", profile_num); } else print_str_opt("profile", "unknown"); } s = av_get_media_type_string(par->codec_type); if (s) print_str ("codec_type", s); else print_str_opt("codec_type", "unknown"); #if FF_API_LAVF_AVCTX if (dec_ctx) print_q("codec_time_base", dec_ctx->time_base, '/'); #endif /* print AVI/FourCC tag */ print_str("codec_tag_string", av_fourcc2str(par->codec_tag)); print_fmt("codec_tag", "0x%04"PRIx32, par->codec_tag); switch (par->codec_type) { case AVMEDIA_TYPE_VIDEO: print_int("width", par->width); print_int("height", par->height); if (dec_ctx) { print_int("coded_width", dec_ctx->coded_width); print_int("coded_height", dec_ctx->coded_height); } print_int("has_b_frames", par->video_delay); sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL); if (sar.den) { print_q("sample_aspect_ratio", sar, ':'); av_reduce(&dar.num, &dar.den, par->width * sar.num, par->height * sar.den, 1024*1024); print_q("display_aspect_ratio", dar, ':'); } else { print_str_opt("sample_aspect_ratio", "N/A"); print_str_opt("display_aspect_ratio", "N/A"); } s = av_get_pix_fmt_name(par->format); if (s) print_str ("pix_fmt", s); else print_str_opt("pix_fmt", "unknown"); print_int("level", par->level); if (par->color_range != AVCOL_RANGE_UNSPECIFIED) print_str ("color_range", av_color_range_name(par->color_range)); else print_str_opt("color_range", "N/A"); if (par->color_space != AVCOL_SPC_UNSPECIFIED) print_str("color_space", av_color_space_name(par->color_space)); else print_str_opt("color_space", av_color_space_name(par->color_space)); if (par->color_trc != AVCOL_TRC_UNSPECIFIED) print_str("color_transfer", av_color_transfer_name(par->color_trc)); else print_str_opt("color_transfer", av_color_transfer_name(par->color_trc)); if (par->color_primaries != AVCOL_PRI_UNSPECIFIED) print_str("color_primaries", av_color_primaries_name(par->color_primaries)); else print_str_opt("color_primaries", av_color_primaries_name(par->color_primaries)); if (par->chroma_location != AVCHROMA_LOC_UNSPECIFIED) print_str("chroma_location", av_chroma_location_name(par->chroma_location)); else print_str_opt("chroma_location", av_chroma_location_name(par->chroma_location)); if (par->field_order == AV_FIELD_PROGRESSIVE) print_str("field_order", "progressive"); else if (par->field_order == AV_FIELD_TT) print_str("field_order", "tt"); else if (par->field_order == AV_FIELD_BB) print_str("field_order", "bb"); else if (par->field_order == AV_FIELD_TB) print_str("field_order", "tb"); else if (par->field_order == AV_FIELD_BT) print_str("field_order", "bt"); else print_str_opt("field_order", "unknown"); #if FF_API_PRIVATE_OPT if (dec_ctx && dec_ctx->timecode_frame_start >= 0) { char tcbuf[AV_TIMECODE_STR_SIZE]; av_timecode_make_mpeg_tc_string(tcbuf, dec_ctx->timecode_frame_start); print_str("timecode", tcbuf); } else { print_str_opt("timecode", "N/A"); } #endif if (dec_ctx) print_int("refs", dec_ctx->refs); break; case AVMEDIA_TYPE_AUDIO: s = av_get_sample_fmt_name(par->format); if (s) print_str ("sample_fmt", s); else print_str_opt("sample_fmt", "unknown"); print_val("sample_rate", par->sample_rate, unit_hertz_str); print_int("channels", par->channels); if (par->channel_layout) { av_bprint_clear(&pbuf); av_bprint_channel_layout(&pbuf, par->channels, par->channel_layout); print_str ("channel_layout", pbuf.str); } else { print_str_opt("channel_layout", "unknown"); } print_int("bits_per_sample", av_get_bits_per_sample(par->codec_id)); break; case AVMEDIA_TYPE_SUBTITLE: if (par->width) print_int("width", par->width); else print_str_opt("width", "N/A"); if (par->height) print_int("height", par->height); else print_str_opt("height", "N/A"); break; } if (dec_ctx && dec_ctx->codec && dec_ctx->codec->priv_class && show_private_data) { const AVOption *opt = NULL; while (opt = av_opt_next(dec_ctx->priv_data,opt)) { uint8_t *str; if (opt->flags) continue; if (av_opt_get(dec_ctx->priv_data, opt->name, 0, &str) >= 0) { print_str(opt->name, str); av_free(str); } } } if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS) print_fmt ("id", "0x%x", stream->id); else print_str_opt("id", "N/A"); print_q("r_frame_rate", stream->r_frame_rate, '/'); print_q("avg_frame_rate", stream->avg_frame_rate, '/'); print_q("time_base", stream->time_base, '/'); print_ts ("start_pts", stream->start_time); print_time("start_time", stream->start_time, &stream->time_base); print_ts ("duration_ts", stream->duration); print_time("duration", stream->duration, &stream->time_base); if (par->bit_rate > 0) print_val ("bit_rate", par->bit_rate, unit_bit_per_second_str); else print_str_opt("bit_rate", "N/A"); #if FF_API_LAVF_AVCTX if (stream->codec->rc_max_rate > 0) print_val ("max_bit_rate", stream->codec->rc_max_rate, unit_bit_per_second_str); else print_str_opt("max_bit_rate", "N/A"); #endif if (dec_ctx && dec_ctx->bits_per_raw_sample > 0) print_fmt("bits_per_raw_sample", "%d", dec_ctx->bits_per_raw_sample); else print_str_opt("bits_per_raw_sample", "N/A"); if (stream->nb_frames) print_fmt ("nb_frames", "%"PRId64, stream->nb_frames); else print_str_opt("nb_frames", "N/A"); if (nb_streams_frames[stream_idx]) print_fmt ("nb_read_frames", "%"PRIu64, nb_streams_frames[stream_idx]); else print_str_opt("nb_read_frames", "N/A"); if (nb_streams_packets[stream_idx]) print_fmt ("nb_read_packets", "%"PRIu64, nb_streams_packets[stream_idx]); else print_str_opt("nb_read_packets", "N/A"); if (do_show_data) writer_print_data(w, "extradata", par->extradata, par->extradata_size); writer_print_data_hash(w, "extradata_hash", par->extradata, par->extradata_size); /* Print disposition information */ #define PRINT_DISPOSITION(flagname, name) do { \ print_int(name, !!(stream->disposition & AV_DISPOSITION_##flagname)); \ } while (0) if (do_show_stream_disposition) { writer_print_section_header(w, in_program ? SECTION_ID_PROGRAM_STREAM_DISPOSITION : SECTION_ID_STREAM_DISPOSITION); PRINT_DISPOSITION(DEFAULT, "default"); PRINT_DISPOSITION(DUB, "dub"); PRINT_DISPOSITION(ORIGINAL, "original"); PRINT_DISPOSITION(COMMENT, "comment"); PRINT_DISPOSITION(LYRICS, "lyrics"); PRINT_DISPOSITION(KARAOKE, "karaoke"); PRINT_DISPOSITION(FORCED, "forced"); PRINT_DISPOSITION(HEARING_IMPAIRED, "hearing_impaired"); PRINT_DISPOSITION(VISUAL_IMPAIRED, "visual_impaired"); PRINT_DISPOSITION(CLEAN_EFFECTS, "clean_effects"); PRINT_DISPOSITION(ATTACHED_PIC, "attached_pic"); PRINT_DISPOSITION(TIMED_THUMBNAILS, "timed_thumbnails"); writer_print_section_footer(w); } if (do_show_stream_tags) ret = show_tags(w, stream->metadata, in_program ? SECTION_ID_PROGRAM_STREAM_TAGS : SECTION_ID_STREAM_TAGS); if (stream->nb_side_data) { print_pkt_side_data(w, stream->codecpar, stream->side_data, stream->nb_side_data, SECTION_ID_STREAM_SIDE_DATA_LIST, SECTION_ID_STREAM_SIDE_DATA); } writer_print_section_footer(w); av_bprint_finalize(&pbuf, NULL); fflush(stdout); return ret; }
true
FFmpeg
837cb4325b712ff1aab531bf41668933f61d75d2
static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_idx, InputStream *ist, int in_program) { AVStream *stream = ist->st; AVCodecParameters *par; AVCodecContext *dec_ctx; char val_str[128]; const char *s; AVRational sar, dar; AVBPrint pbuf; const AVCodecDescriptor *cd; int ret = 0; const char *profile = NULL; av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED); writer_print_section_header(w, in_program ? SECTION_ID_PROGRAM_STREAM : SECTION_ID_STREAM); print_int("index", stream->index); par = stream->codecpar; dec_ctx = ist->dec_ctx; if (cd = avcodec_descriptor_get(par->codec_id)) { print_str("codec_name", cd->name); if (!do_bitexact) { print_str("codec_long_name", cd->long_name ? cd->long_name : "unknown"); } } else { print_str_opt("codec_name", "unknown"); if (!do_bitexact) { print_str_opt("codec_long_name", "unknown"); } } if (!do_bitexact && (profile = avcodec_profile_name(par->codec_id, par->profile))) print_str("profile", profile); else { if (par->profile != FF_PROFILE_UNKNOWN) { char profile_num[12]; snprintf(profile_num, sizeof(profile_num), "%d", par->profile); print_str("profile", profile_num); } else print_str_opt("profile", "unknown"); } s = av_get_media_type_string(par->codec_type); if (s) print_str ("codec_type", s); else print_str_opt("codec_type", "unknown"); #if FF_API_LAVF_AVCTX if (dec_ctx) print_q("codec_time_base", dec_ctx->time_base, '/'); #endif print_str("codec_tag_string", av_fourcc2str(par->codec_tag)); print_fmt("codec_tag", "0x%04"PRIx32, par->codec_tag); switch (par->codec_type) { case AVMEDIA_TYPE_VIDEO: print_int("width", par->width); print_int("height", par->height); if (dec_ctx) { print_int("coded_width", dec_ctx->coded_width); print_int("coded_height", dec_ctx->coded_height); } print_int("has_b_frames", par->video_delay); sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL); if (sar.den) { print_q("sample_aspect_ratio", sar, ':'); av_reduce(&dar.num, &dar.den, par->width * sar.num, par->height * sar.den, 1024*1024); print_q("display_aspect_ratio", dar, ':'); } else { print_str_opt("sample_aspect_ratio", "N/A"); print_str_opt("display_aspect_ratio", "N/A"); } s = av_get_pix_fmt_name(par->format); if (s) print_str ("pix_fmt", s); else print_str_opt("pix_fmt", "unknown"); print_int("level", par->level); if (par->color_range != AVCOL_RANGE_UNSPECIFIED) print_str ("color_range", av_color_range_name(par->color_range)); else print_str_opt("color_range", "N/A"); if (par->color_space != AVCOL_SPC_UNSPECIFIED) print_str("color_space", av_color_space_name(par->color_space)); else print_str_opt("color_space", av_color_space_name(par->color_space)); if (par->color_trc != AVCOL_TRC_UNSPECIFIED) print_str("color_transfer", av_color_transfer_name(par->color_trc)); else print_str_opt("color_transfer", av_color_transfer_name(par->color_trc)); if (par->color_primaries != AVCOL_PRI_UNSPECIFIED) print_str("color_primaries", av_color_primaries_name(par->color_primaries)); else print_str_opt("color_primaries", av_color_primaries_name(par->color_primaries)); if (par->chroma_location != AVCHROMA_LOC_UNSPECIFIED) print_str("chroma_location", av_chroma_location_name(par->chroma_location)); else print_str_opt("chroma_location", av_chroma_location_name(par->chroma_location)); if (par->field_order == AV_FIELD_PROGRESSIVE) print_str("field_order", "progressive"); else if (par->field_order == AV_FIELD_TT) print_str("field_order", "tt"); else if (par->field_order == AV_FIELD_BB) print_str("field_order", "bb"); else if (par->field_order == AV_FIELD_TB) print_str("field_order", "tb"); else if (par->field_order == AV_FIELD_BT) print_str("field_order", "bt"); else print_str_opt("field_order", "unknown"); #if FF_API_PRIVATE_OPT if (dec_ctx && dec_ctx->timecode_frame_start >= 0) { char tcbuf[AV_TIMECODE_STR_SIZE]; av_timecode_make_mpeg_tc_string(tcbuf, dec_ctx->timecode_frame_start); print_str("timecode", tcbuf); } else { print_str_opt("timecode", "N/A"); } #endif if (dec_ctx) print_int("refs", dec_ctx->refs); break; case AVMEDIA_TYPE_AUDIO: s = av_get_sample_fmt_name(par->format); if (s) print_str ("sample_fmt", s); else print_str_opt("sample_fmt", "unknown"); print_val("sample_rate", par->sample_rate, unit_hertz_str); print_int("channels", par->channels); if (par->channel_layout) { av_bprint_clear(&pbuf); av_bprint_channel_layout(&pbuf, par->channels, par->channel_layout); print_str ("channel_layout", pbuf.str); } else { print_str_opt("channel_layout", "unknown"); } print_int("bits_per_sample", av_get_bits_per_sample(par->codec_id)); break; case AVMEDIA_TYPE_SUBTITLE: if (par->width) print_int("width", par->width); else print_str_opt("width", "N/A"); if (par->height) print_int("height", par->height); else print_str_opt("height", "N/A"); break; } if (dec_ctx && dec_ctx->codec && dec_ctx->codec->priv_class && show_private_data) { const AVOption *opt = NULL; while (opt = av_opt_next(dec_ctx->priv_data,opt)) { uint8_t *str; if (opt->flags) continue; if (av_opt_get(dec_ctx->priv_data, opt->name, 0, &str) >= 0) { print_str(opt->name, str); av_free(str); } } } if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS) print_fmt ("id", "0x%x", stream->id); else print_str_opt("id", "N/A"); print_q("r_frame_rate", stream->r_frame_rate, '/'); print_q("avg_frame_rate", stream->avg_frame_rate, '/'); print_q("time_base", stream->time_base, '/'); print_ts ("start_pts", stream->start_time); print_time("start_time", stream->start_time, &stream->time_base); print_ts ("duration_ts", stream->duration); print_time("duration", stream->duration, &stream->time_base); if (par->bit_rate > 0) print_val ("bit_rate", par->bit_rate, unit_bit_per_second_str); else print_str_opt("bit_rate", "N/A"); #if FF_API_LAVF_AVCTX if (stream->codec->rc_max_rate > 0) print_val ("max_bit_rate", stream->codec->rc_max_rate, unit_bit_per_second_str); else print_str_opt("max_bit_rate", "N/A"); #endif if (dec_ctx && dec_ctx->bits_per_raw_sample > 0) print_fmt("bits_per_raw_sample", "%d", dec_ctx->bits_per_raw_sample); else print_str_opt("bits_per_raw_sample", "N/A"); if (stream->nb_frames) print_fmt ("nb_frames", "%"PRId64, stream->nb_frames); else print_str_opt("nb_frames", "N/A"); if (nb_streams_frames[stream_idx]) print_fmt ("nb_read_frames", "%"PRIu64, nb_streams_frames[stream_idx]); else print_str_opt("nb_read_frames", "N/A"); if (nb_streams_packets[stream_idx]) print_fmt ("nb_read_packets", "%"PRIu64, nb_streams_packets[stream_idx]); else print_str_opt("nb_read_packets", "N/A"); if (do_show_data) writer_print_data(w, "extradata", par->extradata, par->extradata_size); writer_print_data_hash(w, "extradata_hash", par->extradata, par->extradata_size); #define PRINT_DISPOSITION(flagname, name) do { \ print_int(name, !!(stream->disposition & AV_DISPOSITION_##flagname)); \ } while (0) if (do_show_stream_disposition) { writer_print_section_header(w, in_program ? SECTION_ID_PROGRAM_STREAM_DISPOSITION : SECTION_ID_STREAM_DISPOSITION); PRINT_DISPOSITION(DEFAULT, "default"); PRINT_DISPOSITION(DUB, "dub"); PRINT_DISPOSITION(ORIGINAL, "original"); PRINT_DISPOSITION(COMMENT, "comment"); PRINT_DISPOSITION(LYRICS, "lyrics"); PRINT_DISPOSITION(KARAOKE, "karaoke"); PRINT_DISPOSITION(FORCED, "forced"); PRINT_DISPOSITION(HEARING_IMPAIRED, "hearing_impaired"); PRINT_DISPOSITION(VISUAL_IMPAIRED, "visual_impaired"); PRINT_DISPOSITION(CLEAN_EFFECTS, "clean_effects"); PRINT_DISPOSITION(ATTACHED_PIC, "attached_pic"); PRINT_DISPOSITION(TIMED_THUMBNAILS, "timed_thumbnails"); writer_print_section_footer(w); } if (do_show_stream_tags) ret = show_tags(w, stream->metadata, in_program ? SECTION_ID_PROGRAM_STREAM_TAGS : SECTION_ID_STREAM_TAGS); if (stream->nb_side_data) { print_pkt_side_data(w, stream->codecpar, stream->side_data, stream->nb_side_data, SECTION_ID_STREAM_SIDE_DATA_LIST, SECTION_ID_STREAM_SIDE_DATA); } writer_print_section_footer(w); av_bprint_finalize(&pbuf, NULL); fflush(stdout); return ret; }
{ "code": [ " if (par->color_primaries != AVCOL_PRI_UNSPECIFIED)", " print_str(\"color_primaries\", av_color_primaries_name(par->color_primaries));", " print_str_opt(\"color_primaries\", av_color_primaries_name(par->color_primaries));" ], "line_no": [ 195, 197, 201 ] }
static int FUNC_0(WriterContext *VAR_0, AVFormatContext *VAR_1, int VAR_2, InputStream *VAR_3, int VAR_4) { AVStream *stream = VAR_3->st; AVCodecParameters *par; AVCodecContext *dec_ctx; char VAR_5[128]; const char *VAR_6; AVRational sar, dar; AVBPrint pbuf; const AVCodecDescriptor *VAR_7; int VAR_8 = 0; const char *VAR_9 = NULL; av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED); writer_print_section_header(VAR_0, VAR_4 ? SECTION_ID_PROGRAM_STREAM : SECTION_ID_STREAM); print_int("index", stream->index); par = stream->codecpar; dec_ctx = VAR_3->dec_ctx; if (VAR_7 = avcodec_descriptor_get(par->codec_id)) { print_str("codec_name", VAR_7->name); if (!do_bitexact) { print_str("codec_long_name", VAR_7->long_name ? VAR_7->long_name : "unknown"); } } else { print_str_opt("codec_name", "unknown"); if (!do_bitexact) { print_str_opt("codec_long_name", "unknown"); } } if (!do_bitexact && (VAR_9 = avcodec_profile_name(par->codec_id, par->VAR_9))) print_str("VAR_9", VAR_9); else { if (par->VAR_9 != FF_PROFILE_UNKNOWN) { char VAR_10[12]; snprintf(VAR_10, sizeof(VAR_10), "%d", par->VAR_9); print_str("VAR_9", VAR_10); } else print_str_opt("VAR_9", "unknown"); } VAR_6 = av_get_media_type_string(par->codec_type); if (VAR_6) print_str ("codec_type", VAR_6); else print_str_opt("codec_type", "unknown"); #if FF_API_LAVF_AVCTX if (dec_ctx) print_q("codec_time_base", dec_ctx->time_base, '/'); #endif print_str("codec_tag_string", av_fourcc2str(par->codec_tag)); print_fmt("codec_tag", "0x%04"PRIx32, par->codec_tag); switch (par->codec_type) { case AVMEDIA_TYPE_VIDEO: print_int("width", par->width); print_int("height", par->height); if (dec_ctx) { print_int("coded_width", dec_ctx->coded_width); print_int("coded_height", dec_ctx->coded_height); } print_int("has_b_frames", par->video_delay); sar = av_guess_sample_aspect_ratio(VAR_1, stream, NULL); if (sar.den) { print_q("sample_aspect_ratio", sar, ':'); av_reduce(&dar.num, &dar.den, par->width * sar.num, par->height * sar.den, 1024*1024); print_q("display_aspect_ratio", dar, ':'); } else { print_str_opt("sample_aspect_ratio", "N/A"); print_str_opt("display_aspect_ratio", "N/A"); } VAR_6 = av_get_pix_fmt_name(par->format); if (VAR_6) print_str ("pix_fmt", VAR_6); else print_str_opt("pix_fmt", "unknown"); print_int("level", par->level); if (par->color_range != AVCOL_RANGE_UNSPECIFIED) print_str ("color_range", av_color_range_name(par->color_range)); else print_str_opt("color_range", "N/A"); if (par->color_space != AVCOL_SPC_UNSPECIFIED) print_str("color_space", av_color_space_name(par->color_space)); else print_str_opt("color_space", av_color_space_name(par->color_space)); if (par->color_trc != AVCOL_TRC_UNSPECIFIED) print_str("color_transfer", av_color_transfer_name(par->color_trc)); else print_str_opt("color_transfer", av_color_transfer_name(par->color_trc)); if (par->color_primaries != AVCOL_PRI_UNSPECIFIED) print_str("color_primaries", av_color_primaries_name(par->color_primaries)); else print_str_opt("color_primaries", av_color_primaries_name(par->color_primaries)); if (par->chroma_location != AVCHROMA_LOC_UNSPECIFIED) print_str("chroma_location", av_chroma_location_name(par->chroma_location)); else print_str_opt("chroma_location", av_chroma_location_name(par->chroma_location)); if (par->field_order == AV_FIELD_PROGRESSIVE) print_str("field_order", "progressive"); else if (par->field_order == AV_FIELD_TT) print_str("field_order", "tt"); else if (par->field_order == AV_FIELD_BB) print_str("field_order", "bb"); else if (par->field_order == AV_FIELD_TB) print_str("field_order", "tb"); else if (par->field_order == AV_FIELD_BT) print_str("field_order", "bt"); else print_str_opt("field_order", "unknown"); #if FF_API_PRIVATE_OPT if (dec_ctx && dec_ctx->timecode_frame_start >= 0) { char tcbuf[AV_TIMECODE_STR_SIZE]; av_timecode_make_mpeg_tc_string(tcbuf, dec_ctx->timecode_frame_start); print_str("timecode", tcbuf); } else { print_str_opt("timecode", "N/A"); } #endif if (dec_ctx) print_int("refs", dec_ctx->refs); break; case AVMEDIA_TYPE_AUDIO: VAR_6 = av_get_sample_fmt_name(par->format); if (VAR_6) print_str ("sample_fmt", VAR_6); else print_str_opt("sample_fmt", "unknown"); print_val("sample_rate", par->sample_rate, unit_hertz_str); print_int("channels", par->channels); if (par->channel_layout) { av_bprint_clear(&pbuf); av_bprint_channel_layout(&pbuf, par->channels, par->channel_layout); print_str ("channel_layout", pbuf.str); } else { print_str_opt("channel_layout", "unknown"); } print_int("bits_per_sample", av_get_bits_per_sample(par->codec_id)); break; case AVMEDIA_TYPE_SUBTITLE: if (par->width) print_int("width", par->width); else print_str_opt("width", "N/A"); if (par->height) print_int("height", par->height); else print_str_opt("height", "N/A"); break; } if (dec_ctx && dec_ctx->codec && dec_ctx->codec->priv_class && show_private_data) { const AVOption *VAR_11 = NULL; while (VAR_11 = av_opt_next(dec_ctx->priv_data,VAR_11)) { uint8_t *str; if (VAR_11->flags) continue; if (av_opt_get(dec_ctx->priv_data, VAR_11->name, 0, &str) >= 0) { print_str(VAR_11->name, str); av_free(str); } } } if (VAR_1->iformat->flags & AVFMT_SHOW_IDS) print_fmt ("id", "0x%x", stream->id); else print_str_opt("id", "N/A"); print_q("r_frame_rate", stream->r_frame_rate, '/'); print_q("avg_frame_rate", stream->avg_frame_rate, '/'); print_q("time_base", stream->time_base, '/'); print_ts ("start_pts", stream->start_time); print_time("start_time", stream->start_time, &stream->time_base); print_ts ("duration_ts", stream->duration); print_time("duration", stream->duration, &stream->time_base); if (par->bit_rate > 0) print_val ("bit_rate", par->bit_rate, unit_bit_per_second_str); else print_str_opt("bit_rate", "N/A"); #if FF_API_LAVF_AVCTX if (stream->codec->rc_max_rate > 0) print_val ("max_bit_rate", stream->codec->rc_max_rate, unit_bit_per_second_str); else print_str_opt("max_bit_rate", "N/A"); #endif if (dec_ctx && dec_ctx->bits_per_raw_sample > 0) print_fmt("bits_per_raw_sample", "%d", dec_ctx->bits_per_raw_sample); else print_str_opt("bits_per_raw_sample", "N/A"); if (stream->nb_frames) print_fmt ("nb_frames", "%"PRId64, stream->nb_frames); else print_str_opt("nb_frames", "N/A"); if (nb_streams_frames[VAR_2]) print_fmt ("nb_read_frames", "%"PRIu64, nb_streams_frames[VAR_2]); else print_str_opt("nb_read_frames", "N/A"); if (nb_streams_packets[VAR_2]) print_fmt ("nb_read_packets", "%"PRIu64, nb_streams_packets[VAR_2]); else print_str_opt("nb_read_packets", "N/A"); if (do_show_data) writer_print_data(VAR_0, "extradata", par->extradata, par->extradata_size); writer_print_data_hash(VAR_0, "extradata_hash", par->extradata, par->extradata_size); #define PRINT_DISPOSITION(flagname, name) do { \ print_int(name, !!(stream->disposition & AV_DISPOSITION_##flagname)); \ } while (0) if (do_show_stream_disposition) { writer_print_section_header(VAR_0, VAR_4 ? SECTION_ID_PROGRAM_STREAM_DISPOSITION : SECTION_ID_STREAM_DISPOSITION); PRINT_DISPOSITION(DEFAULT, "default"); PRINT_DISPOSITION(DUB, "dub"); PRINT_DISPOSITION(ORIGINAL, "original"); PRINT_DISPOSITION(COMMENT, "comment"); PRINT_DISPOSITION(LYRICS, "lyrics"); PRINT_DISPOSITION(KARAOKE, "karaoke"); PRINT_DISPOSITION(FORCED, "forced"); PRINT_DISPOSITION(HEARING_IMPAIRED, "hearing_impaired"); PRINT_DISPOSITION(VISUAL_IMPAIRED, "visual_impaired"); PRINT_DISPOSITION(CLEAN_EFFECTS, "clean_effects"); PRINT_DISPOSITION(ATTACHED_PIC, "attached_pic"); PRINT_DISPOSITION(TIMED_THUMBNAILS, "timed_thumbnails"); writer_print_section_footer(VAR_0); } if (do_show_stream_tags) VAR_8 = show_tags(VAR_0, stream->metadata, VAR_4 ? SECTION_ID_PROGRAM_STREAM_TAGS : SECTION_ID_STREAM_TAGS); if (stream->nb_side_data) { print_pkt_side_data(VAR_0, stream->codecpar, stream->side_data, stream->nb_side_data, SECTION_ID_STREAM_SIDE_DATA_LIST, SECTION_ID_STREAM_SIDE_DATA); } writer_print_section_footer(VAR_0); av_bprint_finalize(&pbuf, NULL); fflush(stdout); return VAR_8; }
[ "static int FUNC_0(WriterContext *VAR_0, AVFormatContext *VAR_1, int VAR_2, InputStream *VAR_3, int VAR_4)\n{", "AVStream *stream = VAR_3->st;", "AVCodecParameters *par;", "AVCodecContext *dec_ctx;", "char VAR_5[128];", "const char *VAR_6;", "AVRational sar, dar;", "AVBPrint pbuf;", "const AVCodecDescriptor *VAR_7;", "int VAR_8 = 0;", "const char *VAR_9 = NULL;", "av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);", "writer_print_section_header(VAR_0, VAR_4 ? SECTION_ID_PROGRAM_STREAM : SECTION_ID_STREAM);", "print_int(\"index\", stream->index);", "par = stream->codecpar;", "dec_ctx = VAR_3->dec_ctx;", "if (VAR_7 = avcodec_descriptor_get(par->codec_id)) {", "print_str(\"codec_name\", VAR_7->name);", "if (!do_bitexact) {", "print_str(\"codec_long_name\",\nVAR_7->long_name ? VAR_7->long_name : \"unknown\");", "}", "} else {", "print_str_opt(\"codec_name\", \"unknown\");", "if (!do_bitexact) {", "print_str_opt(\"codec_long_name\", \"unknown\");", "}", "}", "if (!do_bitexact && (VAR_9 = avcodec_profile_name(par->codec_id, par->VAR_9)))\nprint_str(\"VAR_9\", VAR_9);", "else {", "if (par->VAR_9 != FF_PROFILE_UNKNOWN) {", "char VAR_10[12];", "snprintf(VAR_10, sizeof(VAR_10), \"%d\", par->VAR_9);", "print_str(\"VAR_9\", VAR_10);", "} else", "print_str_opt(\"VAR_9\", \"unknown\");", "}", "VAR_6 = av_get_media_type_string(par->codec_type);", "if (VAR_6) print_str (\"codec_type\", VAR_6);", "else print_str_opt(\"codec_type\", \"unknown\");", "#if FF_API_LAVF_AVCTX\nif (dec_ctx)\nprint_q(\"codec_time_base\", dec_ctx->time_base, '/');", "#endif\nprint_str(\"codec_tag_string\", av_fourcc2str(par->codec_tag));", "print_fmt(\"codec_tag\", \"0x%04\"PRIx32, par->codec_tag);", "switch (par->codec_type) {", "case AVMEDIA_TYPE_VIDEO:\nprint_int(\"width\", par->width);", "print_int(\"height\", par->height);", "if (dec_ctx) {", "print_int(\"coded_width\", dec_ctx->coded_width);", "print_int(\"coded_height\", dec_ctx->coded_height);", "}", "print_int(\"has_b_frames\", par->video_delay);", "sar = av_guess_sample_aspect_ratio(VAR_1, stream, NULL);", "if (sar.den) {", "print_q(\"sample_aspect_ratio\", sar, ':');", "av_reduce(&dar.num, &dar.den,\npar->width * sar.num,\npar->height * sar.den,\n1024*1024);", "print_q(\"display_aspect_ratio\", dar, ':');", "} else {", "print_str_opt(\"sample_aspect_ratio\", \"N/A\");", "print_str_opt(\"display_aspect_ratio\", \"N/A\");", "}", "VAR_6 = av_get_pix_fmt_name(par->format);", "if (VAR_6) print_str (\"pix_fmt\", VAR_6);", "else print_str_opt(\"pix_fmt\", \"unknown\");", "print_int(\"level\", par->level);", "if (par->color_range != AVCOL_RANGE_UNSPECIFIED)\nprint_str (\"color_range\", av_color_range_name(par->color_range));", "else\nprint_str_opt(\"color_range\", \"N/A\");", "if (par->color_space != AVCOL_SPC_UNSPECIFIED)\nprint_str(\"color_space\", av_color_space_name(par->color_space));", "else\nprint_str_opt(\"color_space\", av_color_space_name(par->color_space));", "if (par->color_trc != AVCOL_TRC_UNSPECIFIED)\nprint_str(\"color_transfer\", av_color_transfer_name(par->color_trc));", "else\nprint_str_opt(\"color_transfer\", av_color_transfer_name(par->color_trc));", "if (par->color_primaries != AVCOL_PRI_UNSPECIFIED)\nprint_str(\"color_primaries\", av_color_primaries_name(par->color_primaries));", "else\nprint_str_opt(\"color_primaries\", av_color_primaries_name(par->color_primaries));", "if (par->chroma_location != AVCHROMA_LOC_UNSPECIFIED)\nprint_str(\"chroma_location\", av_chroma_location_name(par->chroma_location));", "else\nprint_str_opt(\"chroma_location\", av_chroma_location_name(par->chroma_location));", "if (par->field_order == AV_FIELD_PROGRESSIVE)\nprint_str(\"field_order\", \"progressive\");", "else if (par->field_order == AV_FIELD_TT)\nprint_str(\"field_order\", \"tt\");", "else if (par->field_order == AV_FIELD_BB)\nprint_str(\"field_order\", \"bb\");", "else if (par->field_order == AV_FIELD_TB)\nprint_str(\"field_order\", \"tb\");", "else if (par->field_order == AV_FIELD_BT)\nprint_str(\"field_order\", \"bt\");", "else\nprint_str_opt(\"field_order\", \"unknown\");", "#if FF_API_PRIVATE_OPT\nif (dec_ctx && dec_ctx->timecode_frame_start >= 0) {", "char tcbuf[AV_TIMECODE_STR_SIZE];", "av_timecode_make_mpeg_tc_string(tcbuf, dec_ctx->timecode_frame_start);", "print_str(\"timecode\", tcbuf);", "} else {", "print_str_opt(\"timecode\", \"N/A\");", "}", "#endif\nif (dec_ctx)\nprint_int(\"refs\", dec_ctx->refs);", "break;", "case AVMEDIA_TYPE_AUDIO:\nVAR_6 = av_get_sample_fmt_name(par->format);", "if (VAR_6) print_str (\"sample_fmt\", VAR_6);", "else print_str_opt(\"sample_fmt\", \"unknown\");", "print_val(\"sample_rate\", par->sample_rate, unit_hertz_str);", "print_int(\"channels\", par->channels);", "if (par->channel_layout) {", "av_bprint_clear(&pbuf);", "av_bprint_channel_layout(&pbuf, par->channels, par->channel_layout);", "print_str (\"channel_layout\", pbuf.str);", "} else {", "print_str_opt(\"channel_layout\", \"unknown\");", "}", "print_int(\"bits_per_sample\", av_get_bits_per_sample(par->codec_id));", "break;", "case AVMEDIA_TYPE_SUBTITLE:\nif (par->width)\nprint_int(\"width\", par->width);", "else\nprint_str_opt(\"width\", \"N/A\");", "if (par->height)\nprint_int(\"height\", par->height);", "else\nprint_str_opt(\"height\", \"N/A\");", "break;", "}", "if (dec_ctx && dec_ctx->codec && dec_ctx->codec->priv_class && show_private_data) {", "const AVOption *VAR_11 = NULL;", "while (VAR_11 = av_opt_next(dec_ctx->priv_data,VAR_11)) {", "uint8_t *str;", "if (VAR_11->flags) continue;", "if (av_opt_get(dec_ctx->priv_data, VAR_11->name, 0, &str) >= 0) {", "print_str(VAR_11->name, str);", "av_free(str);", "}", "}", "}", "if (VAR_1->iformat->flags & AVFMT_SHOW_IDS) print_fmt (\"id\", \"0x%x\", stream->id);", "else print_str_opt(\"id\", \"N/A\");", "print_q(\"r_frame_rate\", stream->r_frame_rate, '/');", "print_q(\"avg_frame_rate\", stream->avg_frame_rate, '/');", "print_q(\"time_base\", stream->time_base, '/');", "print_ts (\"start_pts\", stream->start_time);", "print_time(\"start_time\", stream->start_time, &stream->time_base);", "print_ts (\"duration_ts\", stream->duration);", "print_time(\"duration\", stream->duration, &stream->time_base);", "if (par->bit_rate > 0) print_val (\"bit_rate\", par->bit_rate, unit_bit_per_second_str);", "else print_str_opt(\"bit_rate\", \"N/A\");", "#if FF_API_LAVF_AVCTX\nif (stream->codec->rc_max_rate > 0) print_val (\"max_bit_rate\", stream->codec->rc_max_rate, unit_bit_per_second_str);", "else print_str_opt(\"max_bit_rate\", \"N/A\");", "#endif\nif (dec_ctx && dec_ctx->bits_per_raw_sample > 0) print_fmt(\"bits_per_raw_sample\", \"%d\", dec_ctx->bits_per_raw_sample);", "else print_str_opt(\"bits_per_raw_sample\", \"N/A\");", "if (stream->nb_frames) print_fmt (\"nb_frames\", \"%\"PRId64, stream->nb_frames);", "else print_str_opt(\"nb_frames\", \"N/A\");", "if (nb_streams_frames[VAR_2]) print_fmt (\"nb_read_frames\", \"%\"PRIu64, nb_streams_frames[VAR_2]);", "else print_str_opt(\"nb_read_frames\", \"N/A\");", "if (nb_streams_packets[VAR_2]) print_fmt (\"nb_read_packets\", \"%\"PRIu64, nb_streams_packets[VAR_2]);", "else print_str_opt(\"nb_read_packets\", \"N/A\");", "if (do_show_data)\nwriter_print_data(VAR_0, \"extradata\", par->extradata,\npar->extradata_size);", "writer_print_data_hash(VAR_0, \"extradata_hash\", par->extradata,\npar->extradata_size);", "#define PRINT_DISPOSITION(flagname, name) do { \\", "print_int(name, !!(stream->disposition & AV_DISPOSITION_##flagname)); \\", "} while (0)", "if (do_show_stream_disposition) {", "writer_print_section_header(VAR_0, VAR_4 ? SECTION_ID_PROGRAM_STREAM_DISPOSITION : SECTION_ID_STREAM_DISPOSITION);", "PRINT_DISPOSITION(DEFAULT, \"default\");", "PRINT_DISPOSITION(DUB, \"dub\");", "PRINT_DISPOSITION(ORIGINAL, \"original\");", "PRINT_DISPOSITION(COMMENT, \"comment\");", "PRINT_DISPOSITION(LYRICS, \"lyrics\");", "PRINT_DISPOSITION(KARAOKE, \"karaoke\");", "PRINT_DISPOSITION(FORCED, \"forced\");", "PRINT_DISPOSITION(HEARING_IMPAIRED, \"hearing_impaired\");", "PRINT_DISPOSITION(VISUAL_IMPAIRED, \"visual_impaired\");", "PRINT_DISPOSITION(CLEAN_EFFECTS, \"clean_effects\");", "PRINT_DISPOSITION(ATTACHED_PIC, \"attached_pic\");", "PRINT_DISPOSITION(TIMED_THUMBNAILS, \"timed_thumbnails\");", "writer_print_section_footer(VAR_0);", "}", "if (do_show_stream_tags)\nVAR_8 = show_tags(VAR_0, stream->metadata, VAR_4 ? SECTION_ID_PROGRAM_STREAM_TAGS : SECTION_ID_STREAM_TAGS);", "if (stream->nb_side_data) {", "print_pkt_side_data(VAR_0, stream->codecpar, stream->side_data, stream->nb_side_data,\nSECTION_ID_STREAM_SIDE_DATA_LIST,\nSECTION_ID_STREAM_SIDE_DATA);", "}", "writer_print_section_footer(VAR_0);", "av_bprint_finalize(&pbuf, NULL);", "fflush(stdout);", "return VAR_8;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 31 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49, 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69, 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 91 ], [ 93 ], [ 95 ], [ 97, 99, 101 ], [ 103, 109 ], [ 111 ], [ 115 ], [ 117, 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139, 141, 143, 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165, 167 ], [ 169, 171 ], [ 175, 177 ], [ 179, 181 ], [ 185, 187 ], [ 189, 191 ], [ 195, 197 ], [ 199, 201 ], [ 205, 207 ], [ 209, 211 ], [ 215, 217 ], [ 219, 221 ], [ 223, 225 ], [ 227, 229 ], [ 231, 233 ], [ 235, 237 ], [ 241, 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257, 259, 261 ], [ 263 ], [ 267, 269 ], [ 271 ], [ 273 ], [ 275 ], [ 277 ], [ 281 ], [ 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293 ], [ 297 ], [ 299 ], [ 303, 305, 307 ], [ 309, 311 ], [ 313, 315 ], [ 317, 319 ], [ 321 ], [ 323 ], [ 327 ], [ 329 ], [ 331 ], [ 333 ], [ 335 ], [ 337 ], [ 339 ], [ 341 ], [ 343 ], [ 345 ], [ 347 ], [ 351 ], [ 353 ], [ 355 ], [ 357 ], [ 359 ], [ 361 ], [ 363 ], [ 365 ], [ 367 ], [ 369 ], [ 371 ], [ 373, 375 ], [ 377 ], [ 379, 381 ], [ 383 ], [ 385 ], [ 387 ], [ 389 ], [ 391 ], [ 393 ], [ 395 ], [ 397, 399, 401 ], [ 403, 405 ], [ 411 ], [ 413 ], [ 415 ], [ 419 ], [ 421 ], [ 423 ], [ 425 ], [ 427 ], [ 429 ], [ 431 ], [ 433 ], [ 435 ], [ 437 ], [ 439 ], [ 441 ], [ 443 ], [ 445 ], [ 447 ], [ 449 ], [ 453, 455 ], [ 459 ], [ 461, 463, 465 ], [ 467 ], [ 471 ], [ 473 ], [ 475 ], [ 479 ], [ 481 ] ]
6,137
static void openpic_save_IRQ_queue(QEMUFile* f, IRQ_queue_t *q) { unsigned int i; for (i = 0; i < BF_WIDTH(MAX_IRQ); i++) qemu_put_be32s(f, &q->queue[i]); qemu_put_sbe32s(f, &q->next); qemu_put_sbe32s(f, &q->priority); }
true
qemu
af7e9e74c6a62a5bcd911726a9e88d28b61490e0
static void openpic_save_IRQ_queue(QEMUFile* f, IRQ_queue_t *q) { unsigned int i; for (i = 0; i < BF_WIDTH(MAX_IRQ); i++) qemu_put_be32s(f, &q->queue[i]); qemu_put_sbe32s(f, &q->next); qemu_put_sbe32s(f, &q->priority); }
{ "code": [ "static void openpic_save_IRQ_queue(QEMUFile* f, IRQ_queue_t *q)" ], "line_no": [ 1 ] }
static void FUNC_0(QEMUFile* VAR_0, IRQ_queue_t *VAR_1) { unsigned int VAR_2; for (VAR_2 = 0; VAR_2 < BF_WIDTH(MAX_IRQ); VAR_2++) qemu_put_be32s(VAR_0, &VAR_1->queue[VAR_2]); qemu_put_sbe32s(VAR_0, &VAR_1->next); qemu_put_sbe32s(VAR_0, &VAR_1->priority); }
[ "static void FUNC_0(QEMUFile* VAR_0, IRQ_queue_t *VAR_1)\n{", "unsigned int VAR_2;", "for (VAR_2 = 0; VAR_2 < BF_WIDTH(MAX_IRQ); VAR_2++)", "qemu_put_be32s(VAR_0, &VAR_1->queue[VAR_2]);", "qemu_put_sbe32s(VAR_0, &VAR_1->next);", "qemu_put_sbe32s(VAR_0, &VAR_1->priority);", "}" ]
[ 1, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ] ]
6,138
static void qed_is_allocated_cb(void *opaque, int ret, uint64_t offset, size_t len) { QEDIsAllocatedCB *cb = opaque; BDRVQEDState *s = cb->bs->opaque; *cb->pnum = len / BDRV_SECTOR_SIZE; switch (ret) { case QED_CLUSTER_FOUND: offset |= qed_offset_into_cluster(s, cb->pos); cb->status = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | offset; *cb->file = cb->bs->file->bs; break; case QED_CLUSTER_ZERO: cb->status = BDRV_BLOCK_ZERO; break; case QED_CLUSTER_L2: case QED_CLUSTER_L1: cb->status = 0; break; default: assert(ret < 0); cb->status = ret; break; } if (cb->co) { qemu_coroutine_enter(cb->co, NULL); } }
true
qemu
0b8b8753e4d94901627b3e86431230f2319215c4
static void qed_is_allocated_cb(void *opaque, int ret, uint64_t offset, size_t len) { QEDIsAllocatedCB *cb = opaque; BDRVQEDState *s = cb->bs->opaque; *cb->pnum = len / BDRV_SECTOR_SIZE; switch (ret) { case QED_CLUSTER_FOUND: offset |= qed_offset_into_cluster(s, cb->pos); cb->status = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | offset; *cb->file = cb->bs->file->bs; break; case QED_CLUSTER_ZERO: cb->status = BDRV_BLOCK_ZERO; break; case QED_CLUSTER_L2: case QED_CLUSTER_L1: cb->status = 0; break; default: assert(ret < 0); cb->status = ret; break; } if (cb->co) { qemu_coroutine_enter(cb->co, NULL); } }
{ "code": [ " qemu_coroutine_enter(cb->co, NULL);", " qemu_coroutine_enter(cb->co, NULL);" ], "line_no": [ 51, 51 ] }
static void FUNC_0(void *VAR_0, int VAR_1, uint64_t VAR_2, size_t VAR_3) { QEDIsAllocatedCB *cb = VAR_0; BDRVQEDState *s = cb->bs->VAR_0; *cb->pnum = VAR_3 / BDRV_SECTOR_SIZE; switch (VAR_1) { case QED_CLUSTER_FOUND: VAR_2 |= qed_offset_into_cluster(s, cb->pos); cb->status = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | VAR_2; *cb->file = cb->bs->file->bs; break; case QED_CLUSTER_ZERO: cb->status = BDRV_BLOCK_ZERO; break; case QED_CLUSTER_L2: case QED_CLUSTER_L1: cb->status = 0; break; default: assert(VAR_1 < 0); cb->status = VAR_1; break; } if (cb->co) { qemu_coroutine_enter(cb->co, NULL); } }
[ "static void FUNC_0(void *VAR_0, int VAR_1, uint64_t VAR_2, size_t VAR_3)\n{", "QEDIsAllocatedCB *cb = VAR_0;", "BDRVQEDState *s = cb->bs->VAR_0;", "*cb->pnum = VAR_3 / BDRV_SECTOR_SIZE;", "switch (VAR_1) {", "case QED_CLUSTER_FOUND:\nVAR_2 |= qed_offset_into_cluster(s, cb->pos);", "cb->status = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | VAR_2;", "*cb->file = cb->bs->file->bs;", "break;", "case QED_CLUSTER_ZERO:\ncb->status = BDRV_BLOCK_ZERO;", "break;", "case QED_CLUSTER_L2:\ncase QED_CLUSTER_L1:\ncb->status = 0;", "break;", "default:\nassert(VAR_1 < 0);", "cb->status = VAR_1;", "break;", "}", "if (cb->co) {", "qemu_coroutine_enter(cb->co, NULL);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13, 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23, 25 ], [ 27 ], [ 29, 31, 33 ], [ 35 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ] ]
6,139
static av_cold int ffat_close_decoder(AVCodecContext *avctx) { ATDecodeContext *at = avctx->priv_data; if (at->converter) AudioConverterDispose(at->converter); av_packet_unref(&at->new_in_pkt); av_packet_unref(&at->in_pkt); av_free(at->decoded_data); av_free(at->extradata); return 0; }
false
FFmpeg
f4e593f7b51f7cb30986186c187cff939c82d86d
static av_cold int ffat_close_decoder(AVCodecContext *avctx) { ATDecodeContext *at = avctx->priv_data; if (at->converter) AudioConverterDispose(at->converter); av_packet_unref(&at->new_in_pkt); av_packet_unref(&at->in_pkt); av_free(at->decoded_data); av_free(at->extradata); return 0; }
{ "code": [], "line_no": [] }
static av_cold int FUNC_0(AVCodecContext *avctx) { ATDecodeContext *at = avctx->priv_data; if (at->converter) AudioConverterDispose(at->converter); av_packet_unref(&at->new_in_pkt); av_packet_unref(&at->in_pkt); av_free(at->decoded_data); av_free(at->extradata); return 0; }
[ "static av_cold int FUNC_0(AVCodecContext *avctx)\n{", "ATDecodeContext *at = avctx->priv_data;", "if (at->converter)\nAudioConverterDispose(at->converter);", "av_packet_unref(&at->new_in_pkt);", "av_packet_unref(&at->in_pkt);", "av_free(at->decoded_data);", "av_free(at->extradata);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ] ]
6,141
static int rtsp_read_packet(AVFormatContext *s, AVPacket *pkt) { RTSPState *rt = s->priv_data; int ret; RTSPMessageHeader reply1, *reply = &reply1; char cmd[1024]; if (rt->server_type == RTSP_SERVER_REAL) { int i; enum AVDiscard cache[MAX_STREAMS]; for (i = 0; i < s->nb_streams; i++) cache[i] = s->streams[i]->discard; if (!rt->need_subscription) { if (memcmp (cache, rt->real_setup_cache, sizeof(enum AVDiscard) * s->nb_streams)) { snprintf(cmd, sizeof(cmd), "Unsubscribe: %s\r\n", rt->last_subscription); ff_rtsp_send_cmd(s, "SET_PARAMETER", rt->control_uri, cmd, reply, NULL); if (reply->status_code != RTSP_STATUS_OK) return AVERROR_INVALIDDATA; rt->need_subscription = 1; } } if (rt->need_subscription) { int r, rule_nr, first = 1; memcpy(rt->real_setup_cache, cache, sizeof(enum AVDiscard) * s->nb_streams); rt->last_subscription[0] = 0; snprintf(cmd, sizeof(cmd), "Subscribe: "); for (i = 0; i < rt->nb_rtsp_streams; i++) { rule_nr = 0; for (r = 0; r < s->nb_streams; r++) { if (s->streams[r]->priv_data == rt->rtsp_streams[i]) { if (s->streams[r]->discard != AVDISCARD_ALL) { if (!first) av_strlcat(rt->last_subscription, ",", sizeof(rt->last_subscription)); ff_rdt_subscribe_rule( rt->last_subscription, sizeof(rt->last_subscription), i, rule_nr); first = 0; } rule_nr++; } } } av_strlcatf(cmd, sizeof(cmd), "%s\r\n", rt->last_subscription); ff_rtsp_send_cmd(s, "SET_PARAMETER", rt->control_uri, cmd, reply, NULL); if (reply->status_code != RTSP_STATUS_OK) return AVERROR_INVALIDDATA; rt->need_subscription = 0; if (rt->state == RTSP_STATE_STREAMING) rtsp_read_play (s); } } ret = rtsp_fetch_packet(s, pkt); if (ret < 0) return ret; /* send dummy request to keep TCP connection alive */ if ((rt->server_type == RTSP_SERVER_WMS || rt->server_type == RTSP_SERVER_REAL) && (av_gettime() - rt->last_cmd_time) / 1000000 >= rt->timeout / 2) { if (rt->server_type == RTSP_SERVER_WMS) { ff_rtsp_send_cmd_async(s, "GET_PARAMETER", rt->control_uri, NULL); } else { ff_rtsp_send_cmd_async(s, "OPTIONS", "*", NULL); } } return 0; }
false
FFmpeg
be73ba2fa4890b857d987b79958e46af8c5e545b
static int rtsp_read_packet(AVFormatContext *s, AVPacket *pkt) { RTSPState *rt = s->priv_data; int ret; RTSPMessageHeader reply1, *reply = &reply1; char cmd[1024]; if (rt->server_type == RTSP_SERVER_REAL) { int i; enum AVDiscard cache[MAX_STREAMS]; for (i = 0; i < s->nb_streams; i++) cache[i] = s->streams[i]->discard; if (!rt->need_subscription) { if (memcmp (cache, rt->real_setup_cache, sizeof(enum AVDiscard) * s->nb_streams)) { snprintf(cmd, sizeof(cmd), "Unsubscribe: %s\r\n", rt->last_subscription); ff_rtsp_send_cmd(s, "SET_PARAMETER", rt->control_uri, cmd, reply, NULL); if (reply->status_code != RTSP_STATUS_OK) return AVERROR_INVALIDDATA; rt->need_subscription = 1; } } if (rt->need_subscription) { int r, rule_nr, first = 1; memcpy(rt->real_setup_cache, cache, sizeof(enum AVDiscard) * s->nb_streams); rt->last_subscription[0] = 0; snprintf(cmd, sizeof(cmd), "Subscribe: "); for (i = 0; i < rt->nb_rtsp_streams; i++) { rule_nr = 0; for (r = 0; r < s->nb_streams; r++) { if (s->streams[r]->priv_data == rt->rtsp_streams[i]) { if (s->streams[r]->discard != AVDISCARD_ALL) { if (!first) av_strlcat(rt->last_subscription, ",", sizeof(rt->last_subscription)); ff_rdt_subscribe_rule( rt->last_subscription, sizeof(rt->last_subscription), i, rule_nr); first = 0; } rule_nr++; } } } av_strlcatf(cmd, sizeof(cmd), "%s\r\n", rt->last_subscription); ff_rtsp_send_cmd(s, "SET_PARAMETER", rt->control_uri, cmd, reply, NULL); if (reply->status_code != RTSP_STATUS_OK) return AVERROR_INVALIDDATA; rt->need_subscription = 0; if (rt->state == RTSP_STATE_STREAMING) rtsp_read_play (s); } } ret = rtsp_fetch_packet(s, pkt); if (ret < 0) return ret; if ((rt->server_type == RTSP_SERVER_WMS || rt->server_type == RTSP_SERVER_REAL) && (av_gettime() - rt->last_cmd_time) / 1000000 >= rt->timeout / 2) { if (rt->server_type == RTSP_SERVER_WMS) { ff_rtsp_send_cmd_async(s, "GET_PARAMETER", rt->control_uri, NULL); } else { ff_rtsp_send_cmd_async(s, "OPTIONS", "*", NULL); } } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1) { RTSPState *rt = VAR_0->priv_data; int VAR_2; RTSPMessageHeader reply1, *reply = &reply1; char VAR_3[1024]; if (rt->server_type == RTSP_SERVER_REAL) { int VAR_4; enum AVDiscard VAR_5[MAX_STREAMS]; for (VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) VAR_5[VAR_4] = VAR_0->streams[VAR_4]->discard; if (!rt->need_subscription) { if (memcmp (VAR_5, rt->real_setup_cache, sizeof(enum AVDiscard) * VAR_0->nb_streams)) { snprintf(VAR_3, sizeof(VAR_3), "Unsubscribe: %VAR_0\VAR_6\n", rt->last_subscription); ff_rtsp_send_cmd(VAR_0, "SET_PARAMETER", rt->control_uri, VAR_3, reply, NULL); if (reply->status_code != RTSP_STATUS_OK) return AVERROR_INVALIDDATA; rt->need_subscription = 1; } } if (rt->need_subscription) { int VAR_6, VAR_7, VAR_8 = 1; memcpy(rt->real_setup_cache, VAR_5, sizeof(enum AVDiscard) * VAR_0->nb_streams); rt->last_subscription[0] = 0; snprintf(VAR_3, sizeof(VAR_3), "Subscribe: "); for (VAR_4 = 0; VAR_4 < rt->nb_rtsp_streams; VAR_4++) { VAR_7 = 0; for (VAR_6 = 0; VAR_6 < VAR_0->nb_streams; VAR_6++) { if (VAR_0->streams[VAR_6]->priv_data == rt->rtsp_streams[VAR_4]) { if (VAR_0->streams[VAR_6]->discard != AVDISCARD_ALL) { if (!VAR_8) av_strlcat(rt->last_subscription, ",", sizeof(rt->last_subscription)); ff_rdt_subscribe_rule( rt->last_subscription, sizeof(rt->last_subscription), VAR_4, VAR_7); VAR_8 = 0; } VAR_7++; } } } av_strlcatf(VAR_3, sizeof(VAR_3), "%VAR_0\VAR_6\n", rt->last_subscription); ff_rtsp_send_cmd(VAR_0, "SET_PARAMETER", rt->control_uri, VAR_3, reply, NULL); if (reply->status_code != RTSP_STATUS_OK) return AVERROR_INVALIDDATA; rt->need_subscription = 0; if (rt->state == RTSP_STATE_STREAMING) rtsp_read_play (VAR_0); } } VAR_2 = rtsp_fetch_packet(VAR_0, VAR_1); if (VAR_2 < 0) return VAR_2; if ((rt->server_type == RTSP_SERVER_WMS || rt->server_type == RTSP_SERVER_REAL) && (av_gettime() - rt->last_cmd_time) / 1000000 >= rt->timeout / 2) { if (rt->server_type == RTSP_SERVER_WMS) { ff_rtsp_send_cmd_async(VAR_0, "GET_PARAMETER", rt->control_uri, NULL); } else { ff_rtsp_send_cmd_async(VAR_0, "OPTIONS", "*", NULL); } } return 0; }
[ "static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{", "RTSPState *rt = VAR_0->priv_data;", "int VAR_2;", "RTSPMessageHeader reply1, *reply = &reply1;", "char VAR_3[1024];", "if (rt->server_type == RTSP_SERVER_REAL) {", "int VAR_4;", "enum AVDiscard VAR_5[MAX_STREAMS];", "for (VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++)", "VAR_5[VAR_4] = VAR_0->streams[VAR_4]->discard;", "if (!rt->need_subscription) {", "if (memcmp (VAR_5, rt->real_setup_cache,\nsizeof(enum AVDiscard) * VAR_0->nb_streams)) {", "snprintf(VAR_3, sizeof(VAR_3),\n\"Unsubscribe: %VAR_0\\VAR_6\\n\",\nrt->last_subscription);", "ff_rtsp_send_cmd(VAR_0, \"SET_PARAMETER\", rt->control_uri,\nVAR_3, reply, NULL);", "if (reply->status_code != RTSP_STATUS_OK)\nreturn AVERROR_INVALIDDATA;", "rt->need_subscription = 1;", "}", "}", "if (rt->need_subscription) {", "int VAR_6, VAR_7, VAR_8 = 1;", "memcpy(rt->real_setup_cache, VAR_5,\nsizeof(enum AVDiscard) * VAR_0->nb_streams);", "rt->last_subscription[0] = 0;", "snprintf(VAR_3, sizeof(VAR_3),\n\"Subscribe: \");", "for (VAR_4 = 0; VAR_4 < rt->nb_rtsp_streams; VAR_4++) {", "VAR_7 = 0;", "for (VAR_6 = 0; VAR_6 < VAR_0->nb_streams; VAR_6++) {", "if (VAR_0->streams[VAR_6]->priv_data == rt->rtsp_streams[VAR_4]) {", "if (VAR_0->streams[VAR_6]->discard != AVDISCARD_ALL) {", "if (!VAR_8)\nav_strlcat(rt->last_subscription, \",\",\nsizeof(rt->last_subscription));", "ff_rdt_subscribe_rule(\nrt->last_subscription,\nsizeof(rt->last_subscription), VAR_4, VAR_7);", "VAR_8 = 0;", "}", "VAR_7++;", "}", "}", "}", "av_strlcatf(VAR_3, sizeof(VAR_3), \"%VAR_0\\VAR_6\\n\", rt->last_subscription);", "ff_rtsp_send_cmd(VAR_0, \"SET_PARAMETER\", rt->control_uri,\nVAR_3, reply, NULL);", "if (reply->status_code != RTSP_STATUS_OK)\nreturn AVERROR_INVALIDDATA;", "rt->need_subscription = 0;", "if (rt->state == RTSP_STATE_STREAMING)\nrtsp_read_play (VAR_0);", "}", "}", "VAR_2 = rtsp_fetch_packet(VAR_0, VAR_1);", "if (VAR_2 < 0)\nreturn VAR_2;", "if ((rt->server_type == RTSP_SERVER_WMS ||\nrt->server_type == RTSP_SERVER_REAL) &&\n(av_gettime() - rt->last_cmd_time) / 1000000 >= rt->timeout / 2) {", "if (rt->server_type == RTSP_SERVER_WMS) {", "ff_rtsp_send_cmd_async(VAR_0, \"GET_PARAMETER\", rt->control_uri, NULL);", "} else {", "ff_rtsp_send_cmd_async(VAR_0, \"OPTIONS\", \"*\", NULL);", "}", "}", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 29 ], [ 31, 33 ], [ 35, 37, 39 ], [ 41, 43 ], [ 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 63, 65 ], [ 67 ], [ 71, 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85, 87, 89 ], [ 91, 93, 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111, 113 ], [ 115, 117 ], [ 119 ], [ 123, 125 ], [ 127 ], [ 129 ], [ 133 ], [ 135, 137 ], [ 143, 145, 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 163 ], [ 165 ] ]
6,142
static void reset_contexts(SnowContext *s){ int plane_index, level, orientation; for(plane_index=0; plane_index<2; plane_index++){ for(level=0; level<s->spatial_decomposition_count; level++){ for(orientation=level ? 1:0; orientation<4; orientation++){ memset(s->plane[plane_index].band[level][orientation].state, 0, sizeof(s->plane[plane_index].band[level][orientation].state)); } } } memset(s->mb_band.state, 0, sizeof(s->mb_band.state)); memset(s->mv_band[0].state, 0, sizeof(s->mv_band[0].state)); memset(s->mv_band[1].state, 0, sizeof(s->mv_band[1].state)); memset(s->header_state, 0, sizeof(s->header_state)); }
false
FFmpeg
155ec6edf82692bcf3a5f87d2bc697404f4e5aaf
static void reset_contexts(SnowContext *s){ int plane_index, level, orientation; for(plane_index=0; plane_index<2; plane_index++){ for(level=0; level<s->spatial_decomposition_count; level++){ for(orientation=level ? 1:0; orientation<4; orientation++){ memset(s->plane[plane_index].band[level][orientation].state, 0, sizeof(s->plane[plane_index].band[level][orientation].state)); } } } memset(s->mb_band.state, 0, sizeof(s->mb_band.state)); memset(s->mv_band[0].state, 0, sizeof(s->mv_band[0].state)); memset(s->mv_band[1].state, 0, sizeof(s->mv_band[1].state)); memset(s->header_state, 0, sizeof(s->header_state)); }
{ "code": [], "line_no": [] }
static void FUNC_0(SnowContext *VAR_0){ int VAR_1, VAR_2, VAR_3; for(VAR_1=0; VAR_1<2; VAR_1++){ for(VAR_2=0; VAR_2<VAR_0->spatial_decomposition_count; VAR_2++){ for(VAR_3=VAR_2 ? 1:0; VAR_3<4; VAR_3++){ memset(VAR_0->plane[VAR_1].band[VAR_2][VAR_3].state, 0, sizeof(VAR_0->plane[VAR_1].band[VAR_2][VAR_3].state)); } } } memset(VAR_0->mb_band.state, 0, sizeof(VAR_0->mb_band.state)); memset(VAR_0->mv_band[0].state, 0, sizeof(VAR_0->mv_band[0].state)); memset(VAR_0->mv_band[1].state, 0, sizeof(VAR_0->mv_band[1].state)); memset(VAR_0->header_state, 0, sizeof(VAR_0->header_state)); }
[ "static void FUNC_0(SnowContext *VAR_0){", "int VAR_1, VAR_2, VAR_3;", "for(VAR_1=0; VAR_1<2; VAR_1++){", "for(VAR_2=0; VAR_2<VAR_0->spatial_decomposition_count; VAR_2++){", "for(VAR_3=VAR_2 ? 1:0; VAR_3<4; VAR_3++){", "memset(VAR_0->plane[VAR_1].band[VAR_2][VAR_3].state, 0, sizeof(VAR_0->plane[VAR_1].band[VAR_2][VAR_3].state));", "}", "}", "}", "memset(VAR_0->mb_band.state, 0, sizeof(VAR_0->mb_band.state));", "memset(VAR_0->mv_band[0].state, 0, sizeof(VAR_0->mv_band[0].state));", "memset(VAR_0->mv_band[1].state, 0, sizeof(VAR_0->mv_band[1].state));", "memset(VAR_0->header_state, 0, sizeof(VAR_0->header_state));", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1 ], [ 3 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ] ]
6,143
static int encode_frame(AVCodecContext* avc_context, uint8_t *outbuf, int buf_size, void *data) { th_ycbcr_buffer t_yuv_buffer; TheoraContext *h = avc_context->priv_data; AVFrame *frame = data; ogg_packet o_packet; int result, i; // EOS, finish and get 1st pass stats if applicable if (!frame) { th_encode_packetout(h->t_state, 1, &o_packet); if (avc_context->flags & CODEC_FLAG_PASS1) if (get_stats(avc_context, 1)) return -1; return 0; } /* Copy planes to the theora yuv_buffer */ for (i = 0; i < 3; i++) { t_yuv_buffer[i].width = FFALIGN(avc_context->width, 16) >> (i && h->uv_hshift); t_yuv_buffer[i].height = FFALIGN(avc_context->height, 16) >> (i && h->uv_vshift); t_yuv_buffer[i].stride = frame->linesize[i]; t_yuv_buffer[i].data = frame->data[i]; } if (avc_context->flags & CODEC_FLAG_PASS2) if (submit_stats(avc_context)) return -1; /* Now call into theora_encode_YUVin */ result = th_encode_ycbcr_in(h->t_state, t_yuv_buffer); if (result) { const char* message; switch (result) { case -1: message = "differing frame sizes"; break; case TH_EINVAL: message = "encoder is not ready or is finished"; break; default: message = "unknown reason"; break; } av_log(avc_context, AV_LOG_ERROR, "theora_encode_YUVin failed (%s) [%d]\n", message, result); return -1; } if (avc_context->flags & CODEC_FLAG_PASS1) if (get_stats(avc_context, 0)) return -1; /* Pick up returned ogg_packet */ result = th_encode_packetout(h->t_state, 0, &o_packet); switch (result) { case 0: /* No packet is ready */ return 0; case 1: /* Success, we have a packet */ break; default: av_log(avc_context, AV_LOG_ERROR, "theora_encode_packetout failed [%d]\n", result); return -1; } /* Copy ogg_packet content out to buffer */ if (buf_size < o_packet.bytes) { av_log(avc_context, AV_LOG_ERROR, "encoded frame too large\n"); return -1; } memcpy(outbuf, o_packet.packet, o_packet.bytes); // HACK: does not take codec delay into account (neither does the decoder though) avc_context->coded_frame->pts = frame->pts; avc_context->coded_frame->key_frame = !(o_packet.granulepos & h->keyframe_mask); return o_packet.bytes; }
false
FFmpeg
a4914ac70880784d0e9bee814afac1235d1cd92b
static int encode_frame(AVCodecContext* avc_context, uint8_t *outbuf, int buf_size, void *data) { th_ycbcr_buffer t_yuv_buffer; TheoraContext *h = avc_context->priv_data; AVFrame *frame = data; ogg_packet o_packet; int result, i; if (!frame) { th_encode_packetout(h->t_state, 1, &o_packet); if (avc_context->flags & CODEC_FLAG_PASS1) if (get_stats(avc_context, 1)) return -1; return 0; } for (i = 0; i < 3; i++) { t_yuv_buffer[i].width = FFALIGN(avc_context->width, 16) >> (i && h->uv_hshift); t_yuv_buffer[i].height = FFALIGN(avc_context->height, 16) >> (i && h->uv_vshift); t_yuv_buffer[i].stride = frame->linesize[i]; t_yuv_buffer[i].data = frame->data[i]; } if (avc_context->flags & CODEC_FLAG_PASS2) if (submit_stats(avc_context)) return -1; result = th_encode_ycbcr_in(h->t_state, t_yuv_buffer); if (result) { const char* message; switch (result) { case -1: message = "differing frame sizes"; break; case TH_EINVAL: message = "encoder is not ready or is finished"; break; default: message = "unknown reason"; break; } av_log(avc_context, AV_LOG_ERROR, "theora_encode_YUVin failed (%s) [%d]\n", message, result); return -1; } if (avc_context->flags & CODEC_FLAG_PASS1) if (get_stats(avc_context, 0)) return -1; result = th_encode_packetout(h->t_state, 0, &o_packet); switch (result) { case 0: return 0; case 1: break; default: av_log(avc_context, AV_LOG_ERROR, "theora_encode_packetout failed [%d]\n", result); return -1; } if (buf_size < o_packet.bytes) { av_log(avc_context, AV_LOG_ERROR, "encoded frame too large\n"); return -1; } memcpy(outbuf, o_packet.packet, o_packet.bytes); avc_context->coded_frame->pts = frame->pts; avc_context->coded_frame->key_frame = !(o_packet.granulepos & h->keyframe_mask); return o_packet.bytes; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVCodecContext* VAR_0, uint8_t *VAR_1, int VAR_2, void *VAR_3) { th_ycbcr_buffer t_yuv_buffer; TheoraContext *h = VAR_0->priv_data; AVFrame *frame = VAR_3; ogg_packet o_packet; int VAR_4, VAR_5; if (!frame) { th_encode_packetout(h->t_state, 1, &o_packet); if (VAR_0->flags & CODEC_FLAG_PASS1) if (get_stats(VAR_0, 1)) return -1; return 0; } for (VAR_5 = 0; VAR_5 < 3; VAR_5++) { t_yuv_buffer[VAR_5].width = FFALIGN(VAR_0->width, 16) >> (VAR_5 && h->uv_hshift); t_yuv_buffer[VAR_5].height = FFALIGN(VAR_0->height, 16) >> (VAR_5 && h->uv_vshift); t_yuv_buffer[VAR_5].stride = frame->linesize[VAR_5]; t_yuv_buffer[VAR_5].VAR_3 = frame->VAR_3[VAR_5]; } if (VAR_0->flags & CODEC_FLAG_PASS2) if (submit_stats(VAR_0)) return -1; VAR_4 = th_encode_ycbcr_in(h->t_state, t_yuv_buffer); if (VAR_4) { const char* VAR_6; switch (VAR_4) { case -1: VAR_6 = "differing frame sizes"; break; case TH_EINVAL: VAR_6 = "encoder is not ready or is finished"; break; default: VAR_6 = "unknown reason"; break; } av_log(VAR_0, AV_LOG_ERROR, "theora_encode_YUVin failed (%s) [%d]\n", VAR_6, VAR_4); return -1; } if (VAR_0->flags & CODEC_FLAG_PASS1) if (get_stats(VAR_0, 0)) return -1; VAR_4 = th_encode_packetout(h->t_state, 0, &o_packet); switch (VAR_4) { case 0: return 0; case 1: break; default: av_log(VAR_0, AV_LOG_ERROR, "theora_encode_packetout failed [%d]\n", VAR_4); return -1; } if (VAR_2 < o_packet.bytes) { av_log(VAR_0, AV_LOG_ERROR, "encoded frame too large\n"); return -1; } memcpy(VAR_1, o_packet.packet, o_packet.bytes); VAR_0->coded_frame->pts = frame->pts; VAR_0->coded_frame->key_frame = !(o_packet.granulepos & h->keyframe_mask); return o_packet.bytes; }
[ "static int FUNC_0(AVCodecContext* VAR_0, uint8_t *VAR_1,\nint VAR_2, void *VAR_3)\n{", "th_ycbcr_buffer t_yuv_buffer;", "TheoraContext *h = VAR_0->priv_data;", "AVFrame *frame = VAR_3;", "ogg_packet o_packet;", "int VAR_4, VAR_5;", "if (!frame) {", "th_encode_packetout(h->t_state, 1, &o_packet);", "if (VAR_0->flags & CODEC_FLAG_PASS1)\nif (get_stats(VAR_0, 1))\nreturn -1;", "return 0;", "}", "for (VAR_5 = 0; VAR_5 < 3; VAR_5++) {", "t_yuv_buffer[VAR_5].width = FFALIGN(VAR_0->width, 16) >> (VAR_5 && h->uv_hshift);", "t_yuv_buffer[VAR_5].height = FFALIGN(VAR_0->height, 16) >> (VAR_5 && h->uv_vshift);", "t_yuv_buffer[VAR_5].stride = frame->linesize[VAR_5];", "t_yuv_buffer[VAR_5].VAR_3 = frame->VAR_3[VAR_5];", "}", "if (VAR_0->flags & CODEC_FLAG_PASS2)\nif (submit_stats(VAR_0))\nreturn -1;", "VAR_4 = th_encode_ycbcr_in(h->t_state, t_yuv_buffer);", "if (VAR_4) {", "const char* VAR_6;", "switch (VAR_4) {", "case -1:\nVAR_6 = \"differing frame sizes\";", "break;", "case TH_EINVAL:\nVAR_6 = \"encoder is not ready or is finished\";", "break;", "default:\nVAR_6 = \"unknown reason\";", "break;", "}", "av_log(VAR_0, AV_LOG_ERROR, \"theora_encode_YUVin failed (%s) [%d]\\n\", VAR_6, VAR_4);", "return -1;", "}", "if (VAR_0->flags & CODEC_FLAG_PASS1)\nif (get_stats(VAR_0, 0))\nreturn -1;", "VAR_4 = th_encode_packetout(h->t_state, 0, &o_packet);", "switch (VAR_4) {", "case 0:\nreturn 0;", "case 1:\nbreak;", "default:\nav_log(VAR_0, AV_LOG_ERROR, \"theora_encode_packetout failed [%d]\\n\", VAR_4);", "return -1;", "}", "if (VAR_2 < o_packet.bytes) {", "av_log(VAR_0, AV_LOG_ERROR, \"encoded frame too large\\n\");", "return -1;", "}", "memcpy(VAR_1, o_packet.packet, o_packet.bytes);", "VAR_0->coded_frame->pts = frame->pts;", "VAR_0->coded_frame->key_frame = !(o_packet.granulepos & h->keyframe_mask);", "return o_packet.bytes;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 21 ], [ 23 ], [ 25, 27, 29 ], [ 31 ], [ 33 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53, 55, 57 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71, 73 ], [ 75 ], [ 77, 79 ], [ 81 ], [ 83, 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 99, 101, 103 ], [ 109 ], [ 111 ], [ 113, 117 ], [ 119, 123 ], [ 125, 127 ], [ 129 ], [ 131 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 151 ], [ 153 ], [ 157 ], [ 159 ] ]
6,144
static int ipvideo_decode_block_opcode_0xF(IpvideoContext *s) { int x, y; unsigned char sample[2]; /* dithered encoding */ CHECK_STREAM_PTR(2); sample[0] = *s->stream_ptr++; sample[1] = *s->stream_ptr++; for (y = 0; y < 8; y++) { for (x = 0; x < 8; x += 2) { *s->pixel_ptr++ = sample[ y & 1 ]; *s->pixel_ptr++ = sample[!(y & 1)]; } s->pixel_ptr += s->line_inc; } /* report success */ return 0; }
false
FFmpeg
80ca19f766aea8f4724aac1b3faa772d25163c8a
static int ipvideo_decode_block_opcode_0xF(IpvideoContext *s) { int x, y; unsigned char sample[2]; CHECK_STREAM_PTR(2); sample[0] = *s->stream_ptr++; sample[1] = *s->stream_ptr++; for (y = 0; y < 8; y++) { for (x = 0; x < 8; x += 2) { *s->pixel_ptr++ = sample[ y & 1 ]; *s->pixel_ptr++ = sample[!(y & 1)]; } s->pixel_ptr += s->line_inc; } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(IpvideoContext *VAR_0) { int VAR_1, VAR_2; unsigned char VAR_3[2]; CHECK_STREAM_PTR(2); VAR_3[0] = *VAR_0->stream_ptr++; VAR_3[1] = *VAR_0->stream_ptr++; for (VAR_2 = 0; VAR_2 < 8; VAR_2++) { for (VAR_1 = 0; VAR_1 < 8; VAR_1 += 2) { *VAR_0->pixel_ptr++ = VAR_3[ VAR_2 & 1 ]; *VAR_0->pixel_ptr++ = VAR_3[!(VAR_2 & 1)]; } VAR_0->pixel_ptr += VAR_0->line_inc; } return 0; }
[ "static int FUNC_0(IpvideoContext *VAR_0)\n{", "int VAR_1, VAR_2;", "unsigned char VAR_3[2];", "CHECK_STREAM_PTR(2);", "VAR_3[0] = *VAR_0->stream_ptr++;", "VAR_3[1] = *VAR_0->stream_ptr++;", "for (VAR_2 = 0; VAR_2 < 8; VAR_2++) {", "for (VAR_1 = 0; VAR_1 < 8; VAR_1 += 2) {", "*VAR_0->pixel_ptr++ = VAR_3[ VAR_2 & 1 ];", "*VAR_0->pixel_ptr++ = VAR_3[!(VAR_2 & 1)];", "}", "VAR_0->pixel_ptr += VAR_0->line_inc;", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 39 ], [ 41 ] ]
6,145
static int compand_delay(AVFilterContext *ctx, AVFrame *frame) { CompandContext *s = ctx->priv; AVFilterLink *inlink = ctx->inputs[0]; const int channels = inlink->channels; const int nb_samples = frame->nb_samples; int chan, i, av_uninit(dindex), oindex, av_uninit(count); AVFrame *out_frame = NULL; av_assert1(channels > 0); /* would corrupt delay_count and delay_index */ for (chan = 0; chan < channels; chan++) { const double *src = (double *)frame->extended_data[chan]; double *dbuf = (double *)s->delayptrs[chan]; ChanParam *cp = &s->channels[chan]; double *dst; count = s->delay_count; dindex = s->delay_index; for (i = 0, oindex = 0; i < nb_samples; i++) { const double in = src[i]; update_volume(cp, fabs(in)); if (count >= s->delay_samples) { if (!out_frame) { out_frame = ff_get_audio_buffer(inlink, nb_samples - i); if (!out_frame) return AVERROR(ENOMEM); av_frame_copy_props(out_frame, frame); out_frame->pts = s->pts; s->pts += av_rescale_q(nb_samples - i, (AVRational){1, inlink->sample_rate}, inlink->time_base); } dst = (double *)out_frame->extended_data[chan]; dst[oindex++] = av_clipd(dbuf[dindex] * get_volume(s, cp->volume), -1, 1); } else { count++; } dbuf[dindex] = in; dindex = MOD(dindex + 1, s->delay_samples); } } s->delay_count = count; s->delay_index = dindex; av_frame_free(&frame); return out_frame ? ff_filter_frame(ctx->outputs[0], out_frame) : 0; }
true
FFmpeg
709746b6affb5c87aee0c3b8ddb0a078453c6162
static int compand_delay(AVFilterContext *ctx, AVFrame *frame) { CompandContext *s = ctx->priv; AVFilterLink *inlink = ctx->inputs[0]; const int channels = inlink->channels; const int nb_samples = frame->nb_samples; int chan, i, av_uninit(dindex), oindex, av_uninit(count); AVFrame *out_frame = NULL; av_assert1(channels > 0); for (chan = 0; chan < channels; chan++) { const double *src = (double *)frame->extended_data[chan]; double *dbuf = (double *)s->delayptrs[chan]; ChanParam *cp = &s->channels[chan]; double *dst; count = s->delay_count; dindex = s->delay_index; for (i = 0, oindex = 0; i < nb_samples; i++) { const double in = src[i]; update_volume(cp, fabs(in)); if (count >= s->delay_samples) { if (!out_frame) { out_frame = ff_get_audio_buffer(inlink, nb_samples - i); if (!out_frame) return AVERROR(ENOMEM); av_frame_copy_props(out_frame, frame); out_frame->pts = s->pts; s->pts += av_rescale_q(nb_samples - i, (AVRational){1, inlink->sample_rate}, inlink->time_base); } dst = (double *)out_frame->extended_data[chan]; dst[oindex++] = av_clipd(dbuf[dindex] * get_volume(s, cp->volume), -1, 1); } else { count++; } dbuf[dindex] = in; dindex = MOD(dindex + 1, s->delay_samples); } } s->delay_count = count; s->delay_index = dindex; av_frame_free(&frame); return out_frame ? ff_filter_frame(ctx->outputs[0], out_frame) : 0; }
{ "code": [ " if (!out_frame)" ], "line_no": [ 53 ] }
static int FUNC_0(AVFilterContext *VAR_0, AVFrame *VAR_1) { CompandContext *s = VAR_0->priv; AVFilterLink *inlink = VAR_0->inputs[0]; const int VAR_2 = inlink->VAR_2; const int VAR_3 = VAR_1->VAR_3; int VAR_4, VAR_5, FUNC_1(dindex), oindex, FUNC_1(count); AVFrame *out_frame = NULL; av_assert1(VAR_2 > 0); for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++) { const double *VAR_6 = (double *)VAR_1->extended_data[VAR_4]; double *VAR_7 = (double *)s->delayptrs[VAR_4]; ChanParam *cp = &s->VAR_2[VAR_4]; double *VAR_8; count = s->delay_count; dindex = s->delay_index; for (VAR_5 = 0, oindex = 0; VAR_5 < VAR_3; VAR_5++) { const double VAR_9 = VAR_6[VAR_5]; update_volume(cp, fabs(VAR_9)); if (count >= s->delay_samples) { if (!out_frame) { out_frame = ff_get_audio_buffer(inlink, VAR_3 - VAR_5); if (!out_frame) return AVERROR(ENOMEM); av_frame_copy_props(out_frame, VAR_1); out_frame->pts = s->pts; s->pts += av_rescale_q(VAR_3 - VAR_5, (AVRational){1, inlink->sample_rate}, inlink->time_base); } VAR_8 = (double *)out_frame->extended_data[VAR_4]; VAR_8[oindex++] = av_clipd(VAR_7[dindex] * get_volume(s, cp->volume), -1, 1); } else { count++; } VAR_7[dindex] = VAR_9; dindex = MOD(dindex + 1, s->delay_samples); } } s->delay_count = count; s->delay_index = dindex; av_frame_free(&VAR_1); return out_frame ? ff_filter_frame(VAR_0->outputs[0], out_frame) : 0; }
[ "static int FUNC_0(AVFilterContext *VAR_0, AVFrame *VAR_1)\n{", "CompandContext *s = VAR_0->priv;", "AVFilterLink *inlink = VAR_0->inputs[0];", "const int VAR_2 = inlink->VAR_2;", "const int VAR_3 = VAR_1->VAR_3;", "int VAR_4, VAR_5, FUNC_1(dindex), oindex, FUNC_1(count);", "AVFrame *out_frame = NULL;", "av_assert1(VAR_2 > 0);", "for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++) {", "const double *VAR_6 = (double *)VAR_1->extended_data[VAR_4];", "double *VAR_7 = (double *)s->delayptrs[VAR_4];", "ChanParam *cp = &s->VAR_2[VAR_4];", "double *VAR_8;", "count = s->delay_count;", "dindex = s->delay_index;", "for (VAR_5 = 0, oindex = 0; VAR_5 < VAR_3; VAR_5++) {", "const double VAR_9 = VAR_6[VAR_5];", "update_volume(cp, fabs(VAR_9));", "if (count >= s->delay_samples) {", "if (!out_frame) {", "out_frame = ff_get_audio_buffer(inlink, VAR_3 - VAR_5);", "if (!out_frame)\nreturn AVERROR(ENOMEM);", "av_frame_copy_props(out_frame, VAR_1);", "out_frame->pts = s->pts;", "s->pts += av_rescale_q(VAR_3 - VAR_5, (AVRational){1, inlink->sample_rate}, inlink->time_base);", "}", "VAR_8 = (double *)out_frame->extended_data[VAR_4];", "VAR_8[oindex++] = av_clipd(VAR_7[dindex] * get_volume(s, cp->volume), -1, 1);", "} else {", "count++;", "}", "VAR_7[dindex] = VAR_9;", "dindex = MOD(dindex + 1, s->delay_samples);", "}", "}", "s->delay_count = count;", "s->delay_index = dindex;", "av_frame_free(&VAR_1);", "return out_frame ? ff_filter_frame(VAR_0->outputs[0], out_frame) : 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 53, 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 89 ], [ 91 ], [ 95 ], [ 97 ], [ 99 ] ]
6,146
static void vga_reset(void *opaque) { VGAState *s = (VGAState *) opaque; s->lfb_addr = 0; s->lfb_end = 0; s->map_addr = 0; s->map_end = 0; s->lfb_vram_mapped = 0; s->bios_offset = 0; s->bios_size = 0; s->sr_index = 0; memset(s->sr, '\0', sizeof(s->sr)); s->gr_index = 0; memset(s->gr, '\0', sizeof(s->gr)); s->ar_index = 0; memset(s->ar, '\0', sizeof(s->ar)); s->ar_flip_flop = 0; s->cr_index = 0; memset(s->cr, '\0', sizeof(s->cr)); s->msr = 0; s->fcr = 0; s->st00 = 0; s->st01 = 0; s->dac_state = 0; s->dac_sub_index = 0; s->dac_read_index = 0; s->dac_write_index = 0; memset(s->dac_cache, '\0', sizeof(s->dac_cache)); s->dac_8bit = 0; memset(s->palette, '\0', sizeof(s->palette)); s->bank_offset = 0; #ifdef CONFIG_BOCHS_VBE s->vbe_index = 0; memset(s->vbe_regs, '\0', sizeof(s->vbe_regs)); s->vbe_regs[VBE_DISPI_INDEX_ID] = VBE_DISPI_ID0; s->vbe_start_addr = 0; s->vbe_line_offset = 0; s->vbe_bank_mask = (s->vram_size >> 16) - 1; #endif memset(s->font_offsets, '\0', sizeof(s->font_offsets)); s->graphic_mode = -1; /* force full update */ s->shift_control = 0; s->double_scan = 0; s->line_offset = 0; s->line_compare = 0; s->start_addr = 0; s->plane_updated = 0; s->last_cw = 0; s->last_ch = 0; s->last_width = 0; s->last_height = 0; s->last_scr_width = 0; s->last_scr_height = 0; s->cursor_start = 0; s->cursor_end = 0; s->cursor_offset = 0; memset(s->invalidated_y_table, '\0', sizeof(s->invalidated_y_table)); memset(s->last_palette, '\0', sizeof(s->last_palette)); memset(s->last_ch_attr, '\0', sizeof(s->last_ch_attr)); switch (vga_retrace_method) { case VGA_RETRACE_DUMB: break; case VGA_RETRACE_PRECISE: memset(&s->retrace_info, 0, sizeof (s->retrace_info)); break; } }
true
qemu
4abc796d41ee01a698032e74ac17c1cdc5d290c3
static void vga_reset(void *opaque) { VGAState *s = (VGAState *) opaque; s->lfb_addr = 0; s->lfb_end = 0; s->map_addr = 0; s->map_end = 0; s->lfb_vram_mapped = 0; s->bios_offset = 0; s->bios_size = 0; s->sr_index = 0; memset(s->sr, '\0', sizeof(s->sr)); s->gr_index = 0; memset(s->gr, '\0', sizeof(s->gr)); s->ar_index = 0; memset(s->ar, '\0', sizeof(s->ar)); s->ar_flip_flop = 0; s->cr_index = 0; memset(s->cr, '\0', sizeof(s->cr)); s->msr = 0; s->fcr = 0; s->st00 = 0; s->st01 = 0; s->dac_state = 0; s->dac_sub_index = 0; s->dac_read_index = 0; s->dac_write_index = 0; memset(s->dac_cache, '\0', sizeof(s->dac_cache)); s->dac_8bit = 0; memset(s->palette, '\0', sizeof(s->palette)); s->bank_offset = 0; #ifdef CONFIG_BOCHS_VBE s->vbe_index = 0; memset(s->vbe_regs, '\0', sizeof(s->vbe_regs)); s->vbe_regs[VBE_DISPI_INDEX_ID] = VBE_DISPI_ID0; s->vbe_start_addr = 0; s->vbe_line_offset = 0; s->vbe_bank_mask = (s->vram_size >> 16) - 1; #endif memset(s->font_offsets, '\0', sizeof(s->font_offsets)); s->graphic_mode = -1; s->shift_control = 0; s->double_scan = 0; s->line_offset = 0; s->line_compare = 0; s->start_addr = 0; s->plane_updated = 0; s->last_cw = 0; s->last_ch = 0; s->last_width = 0; s->last_height = 0; s->last_scr_width = 0; s->last_scr_height = 0; s->cursor_start = 0; s->cursor_end = 0; s->cursor_offset = 0; memset(s->invalidated_y_table, '\0', sizeof(s->invalidated_y_table)); memset(s->last_palette, '\0', sizeof(s->last_palette)); memset(s->last_ch_attr, '\0', sizeof(s->last_ch_attr)); switch (vga_retrace_method) { case VGA_RETRACE_DUMB: break; case VGA_RETRACE_PRECISE: memset(&s->retrace_info, 0, sizeof (s->retrace_info)); break; } }
{ "code": [ "static void vga_reset(void *opaque)" ], "line_no": [ 1 ] }
static void FUNC_0(void *VAR_0) { VGAState *s = (VGAState *) VAR_0; s->lfb_addr = 0; s->lfb_end = 0; s->map_addr = 0; s->map_end = 0; s->lfb_vram_mapped = 0; s->bios_offset = 0; s->bios_size = 0; s->sr_index = 0; memset(s->sr, '\0', sizeof(s->sr)); s->gr_index = 0; memset(s->gr, '\0', sizeof(s->gr)); s->ar_index = 0; memset(s->ar, '\0', sizeof(s->ar)); s->ar_flip_flop = 0; s->cr_index = 0; memset(s->cr, '\0', sizeof(s->cr)); s->msr = 0; s->fcr = 0; s->st00 = 0; s->st01 = 0; s->dac_state = 0; s->dac_sub_index = 0; s->dac_read_index = 0; s->dac_write_index = 0; memset(s->dac_cache, '\0', sizeof(s->dac_cache)); s->dac_8bit = 0; memset(s->palette, '\0', sizeof(s->palette)); s->bank_offset = 0; #ifdef CONFIG_BOCHS_VBE s->vbe_index = 0; memset(s->vbe_regs, '\0', sizeof(s->vbe_regs)); s->vbe_regs[VBE_DISPI_INDEX_ID] = VBE_DISPI_ID0; s->vbe_start_addr = 0; s->vbe_line_offset = 0; s->vbe_bank_mask = (s->vram_size >> 16) - 1; #endif memset(s->font_offsets, '\0', sizeof(s->font_offsets)); s->graphic_mode = -1; s->shift_control = 0; s->double_scan = 0; s->line_offset = 0; s->line_compare = 0; s->start_addr = 0; s->plane_updated = 0; s->last_cw = 0; s->last_ch = 0; s->last_width = 0; s->last_height = 0; s->last_scr_width = 0; s->last_scr_height = 0; s->cursor_start = 0; s->cursor_end = 0; s->cursor_offset = 0; memset(s->invalidated_y_table, '\0', sizeof(s->invalidated_y_table)); memset(s->last_palette, '\0', sizeof(s->last_palette)); memset(s->last_ch_attr, '\0', sizeof(s->last_ch_attr)); switch (vga_retrace_method) { case VGA_RETRACE_DUMB: break; case VGA_RETRACE_PRECISE: memset(&s->retrace_info, 0, sizeof (s->retrace_info)); break; } }
[ "static void FUNC_0(void *VAR_0)\n{", "VGAState *s = (VGAState *) VAR_0;", "s->lfb_addr = 0;", "s->lfb_end = 0;", "s->map_addr = 0;", "s->map_end = 0;", "s->lfb_vram_mapped = 0;", "s->bios_offset = 0;", "s->bios_size = 0;", "s->sr_index = 0;", "memset(s->sr, '\\0', sizeof(s->sr));", "s->gr_index = 0;", "memset(s->gr, '\\0', sizeof(s->gr));", "s->ar_index = 0;", "memset(s->ar, '\\0', sizeof(s->ar));", "s->ar_flip_flop = 0;", "s->cr_index = 0;", "memset(s->cr, '\\0', sizeof(s->cr));", "s->msr = 0;", "s->fcr = 0;", "s->st00 = 0;", "s->st01 = 0;", "s->dac_state = 0;", "s->dac_sub_index = 0;", "s->dac_read_index = 0;", "s->dac_write_index = 0;", "memset(s->dac_cache, '\\0', sizeof(s->dac_cache));", "s->dac_8bit = 0;", "memset(s->palette, '\\0', sizeof(s->palette));", "s->bank_offset = 0;", "#ifdef CONFIG_BOCHS_VBE\ns->vbe_index = 0;", "memset(s->vbe_regs, '\\0', sizeof(s->vbe_regs));", "s->vbe_regs[VBE_DISPI_INDEX_ID] = VBE_DISPI_ID0;", "s->vbe_start_addr = 0;", "s->vbe_line_offset = 0;", "s->vbe_bank_mask = (s->vram_size >> 16) - 1;", "#endif\nmemset(s->font_offsets, '\\0', sizeof(s->font_offsets));", "s->graphic_mode = -1;", "s->shift_control = 0;", "s->double_scan = 0;", "s->line_offset = 0;", "s->line_compare = 0;", "s->start_addr = 0;", "s->plane_updated = 0;", "s->last_cw = 0;", "s->last_ch = 0;", "s->last_width = 0;", "s->last_height = 0;", "s->last_scr_width = 0;", "s->last_scr_height = 0;", "s->cursor_start = 0;", "s->cursor_end = 0;", "s->cursor_offset = 0;", "memset(s->invalidated_y_table, '\\0', sizeof(s->invalidated_y_table));", "memset(s->last_palette, '\\0', sizeof(s->last_palette));", "memset(s->last_ch_attr, '\\0', sizeof(s->last_ch_attr));", "switch (vga_retrace_method) {", "case VGA_RETRACE_DUMB:\nbreak;", "case VGA_RETRACE_PRECISE:\nmemset(&s->retrace_info, 0, sizeof (s->retrace_info));", "break;", "}", "}" ]
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65, 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79, 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123, 125 ], [ 127, 129 ], [ 131 ], [ 133 ], [ 135 ] ]
6,147
vu_queue_pop(VuDev *dev, VuVirtq *vq, size_t sz) { unsigned int i, head, max; VuVirtqElement *elem; unsigned out_num, in_num; struct iovec iov[VIRTQUEUE_MAX_SIZE]; struct vring_desc *desc; int rc; if (unlikely(dev->broken)) { return NULL; } if (vu_queue_empty(dev, vq)) { return NULL; } /* Needed after virtio_queue_empty(), see comment in * virtqueue_num_heads(). */ smp_rmb(); /* When we start there are none of either input nor output. */ out_num = in_num = 0; max = vq->vring.num; if (vq->inuse >= vq->vring.num) { vu_panic(dev, "Virtqueue size exceeded"); return NULL; } if (!virtqueue_get_head(dev, vq, vq->last_avail_idx++, &head)) { return NULL; } if (vu_has_feature(dev, VIRTIO_RING_F_EVENT_IDX)) { vring_set_avail_event(vq, vq->last_avail_idx); } i = head; desc = vq->vring.desc; if (desc[i].flags & VRING_DESC_F_INDIRECT) { if (desc[i].len % sizeof(struct vring_desc)) { vu_panic(dev, "Invalid size for indirect buffer table"); } /* loop over the indirect descriptor table */ max = desc[i].len / sizeof(struct vring_desc); desc = vu_gpa_to_va(dev, desc[i].addr); i = 0; } /* Collect all the descriptors */ do { if (desc[i].flags & VRING_DESC_F_WRITE) { virtqueue_map_desc(dev, &in_num, iov + out_num, VIRTQUEUE_MAX_SIZE - out_num, true, desc[i].addr, desc[i].len); } else { if (in_num) { vu_panic(dev, "Incorrect order for descriptors"); return NULL; } virtqueue_map_desc(dev, &out_num, iov, VIRTQUEUE_MAX_SIZE, false, desc[i].addr, desc[i].len); } /* If we've got too many, that implies a descriptor loop. */ if ((in_num + out_num) > max) { vu_panic(dev, "Looped descriptor"); } rc = virtqueue_read_next_desc(dev, desc, i, max, &i); } while (rc == VIRTQUEUE_READ_DESC_MORE); if (rc == VIRTQUEUE_READ_DESC_ERROR) { return NULL; } /* Now copy what we have collected and mapped */ elem = virtqueue_alloc_element(sz, out_num, in_num); elem->index = head; for (i = 0; i < out_num; i++) { elem->out_sg[i] = iov[i]; } for (i = 0; i < in_num; i++) { elem->in_sg[i] = iov[out_num + i]; } vq->inuse++; return elem; }
true
qemu
640601c7cb1b6b41d3e1a435b986266c2b71e9bc
vu_queue_pop(VuDev *dev, VuVirtq *vq, size_t sz) { unsigned int i, head, max; VuVirtqElement *elem; unsigned out_num, in_num; struct iovec iov[VIRTQUEUE_MAX_SIZE]; struct vring_desc *desc; int rc; if (unlikely(dev->broken)) { return NULL; } if (vu_queue_empty(dev, vq)) { return NULL; } smp_rmb(); out_num = in_num = 0; max = vq->vring.num; if (vq->inuse >= vq->vring.num) { vu_panic(dev, "Virtqueue size exceeded"); return NULL; } if (!virtqueue_get_head(dev, vq, vq->last_avail_idx++, &head)) { return NULL; } if (vu_has_feature(dev, VIRTIO_RING_F_EVENT_IDX)) { vring_set_avail_event(vq, vq->last_avail_idx); } i = head; desc = vq->vring.desc; if (desc[i].flags & VRING_DESC_F_INDIRECT) { if (desc[i].len % sizeof(struct vring_desc)) { vu_panic(dev, "Invalid size for indirect buffer table"); } max = desc[i].len / sizeof(struct vring_desc); desc = vu_gpa_to_va(dev, desc[i].addr); i = 0; } do { if (desc[i].flags & VRING_DESC_F_WRITE) { virtqueue_map_desc(dev, &in_num, iov + out_num, VIRTQUEUE_MAX_SIZE - out_num, true, desc[i].addr, desc[i].len); } else { if (in_num) { vu_panic(dev, "Incorrect order for descriptors"); return NULL; } virtqueue_map_desc(dev, &out_num, iov, VIRTQUEUE_MAX_SIZE, false, desc[i].addr, desc[i].len); } if ((in_num + out_num) > max) { vu_panic(dev, "Looped descriptor"); } rc = virtqueue_read_next_desc(dev, desc, i, max, &i); } while (rc == VIRTQUEUE_READ_DESC_MORE); if (rc == VIRTQUEUE_READ_DESC_ERROR) { return NULL; } elem = virtqueue_alloc_element(sz, out_num, in_num); elem->index = head; for (i = 0; i < out_num; i++) { elem->out_sg[i] = iov[i]; } for (i = 0; i < in_num; i++) { elem->in_sg[i] = iov[out_num + i]; } vq->inuse++; return elem; }
{ "code": [ " if (unlikely(dev->broken)) {", " if (unlikely(dev->broken)) {", " if (unlikely(dev->broken)) {", " if (unlikely(dev->broken)) {" ], "line_no": [ 19, 19, 19, 19 ] }
FUNC_0(VuDev *VAR_0, VuVirtq *VAR_1, size_t VAR_2) { unsigned int VAR_3, VAR_4, VAR_5; VuVirtqElement *elem; unsigned VAR_6, VAR_7; struct iovec VAR_8[VIRTQUEUE_MAX_SIZE]; struct vring_desc *VAR_9; int VAR_10; if (unlikely(VAR_0->broken)) { return NULL; } if (vu_queue_empty(VAR_0, VAR_1)) { return NULL; } smp_rmb(); VAR_6 = VAR_7 = 0; VAR_5 = VAR_1->vring.num; if (VAR_1->inuse >= VAR_1->vring.num) { vu_panic(VAR_0, "Virtqueue size exceeded"); return NULL; } if (!virtqueue_get_head(VAR_0, VAR_1, VAR_1->last_avail_idx++, &VAR_4)) { return NULL; } if (vu_has_feature(VAR_0, VIRTIO_RING_F_EVENT_IDX)) { vring_set_avail_event(VAR_1, VAR_1->last_avail_idx); } VAR_3 = VAR_4; VAR_9 = VAR_1->vring.VAR_9; if (VAR_9[VAR_3].flags & VRING_DESC_F_INDIRECT) { if (VAR_9[VAR_3].len % sizeof(struct vring_desc)) { vu_panic(VAR_0, "Invalid size for indirect buffer table"); } VAR_5 = VAR_9[VAR_3].len / sizeof(struct vring_desc); VAR_9 = vu_gpa_to_va(VAR_0, VAR_9[VAR_3].addr); VAR_3 = 0; } do { if (VAR_9[VAR_3].flags & VRING_DESC_F_WRITE) { virtqueue_map_desc(VAR_0, &VAR_7, VAR_8 + VAR_6, VIRTQUEUE_MAX_SIZE - VAR_6, true, VAR_9[VAR_3].addr, VAR_9[VAR_3].len); } else { if (VAR_7) { vu_panic(VAR_0, "Incorrect order for descriptors"); return NULL; } virtqueue_map_desc(VAR_0, &VAR_6, VAR_8, VIRTQUEUE_MAX_SIZE, false, VAR_9[VAR_3].addr, VAR_9[VAR_3].len); } if ((VAR_7 + VAR_6) > VAR_5) { vu_panic(VAR_0, "Looped descriptor"); } VAR_10 = virtqueue_read_next_desc(VAR_0, VAR_9, VAR_3, VAR_5, &VAR_3); } while (VAR_10 == VIRTQUEUE_READ_DESC_MORE); if (VAR_10 == VIRTQUEUE_READ_DESC_ERROR) { return NULL; } elem = virtqueue_alloc_element(VAR_2, VAR_6, VAR_7); elem->index = VAR_4; for (VAR_3 = 0; VAR_3 < VAR_6; VAR_3++) { elem->out_sg[VAR_3] = VAR_8[VAR_3]; } for (VAR_3 = 0; VAR_3 < VAR_7; VAR_3++) { elem->in_sg[VAR_3] = VAR_8[VAR_6 + VAR_3]; } VAR_1->inuse++; return elem; }
[ "FUNC_0(VuDev *VAR_0, VuVirtq *VAR_1, size_t VAR_2)\n{", "unsigned int VAR_3, VAR_4, VAR_5;", "VuVirtqElement *elem;", "unsigned VAR_6, VAR_7;", "struct iovec VAR_8[VIRTQUEUE_MAX_SIZE];", "struct vring_desc *VAR_9;", "int VAR_10;", "if (unlikely(VAR_0->broken)) {", "return NULL;", "}", "if (vu_queue_empty(VAR_0, VAR_1)) {", "return NULL;", "}", "smp_rmb();", "VAR_6 = VAR_7 = 0;", "VAR_5 = VAR_1->vring.num;", "if (VAR_1->inuse >= VAR_1->vring.num) {", "vu_panic(VAR_0, \"Virtqueue size exceeded\");", "return NULL;", "}", "if (!virtqueue_get_head(VAR_0, VAR_1, VAR_1->last_avail_idx++, &VAR_4)) {", "return NULL;", "}", "if (vu_has_feature(VAR_0, VIRTIO_RING_F_EVENT_IDX)) {", "vring_set_avail_event(VAR_1, VAR_1->last_avail_idx);", "}", "VAR_3 = VAR_4;", "VAR_9 = VAR_1->vring.VAR_9;", "if (VAR_9[VAR_3].flags & VRING_DESC_F_INDIRECT) {", "if (VAR_9[VAR_3].len % sizeof(struct vring_desc)) {", "vu_panic(VAR_0, \"Invalid size for indirect buffer table\");", "}", "VAR_5 = VAR_9[VAR_3].len / sizeof(struct vring_desc);", "VAR_9 = vu_gpa_to_va(VAR_0, VAR_9[VAR_3].addr);", "VAR_3 = 0;", "}", "do {", "if (VAR_9[VAR_3].flags & VRING_DESC_F_WRITE) {", "virtqueue_map_desc(VAR_0, &VAR_7, VAR_8 + VAR_6,\nVIRTQUEUE_MAX_SIZE - VAR_6, true,\nVAR_9[VAR_3].addr, VAR_9[VAR_3].len);", "} else {", "if (VAR_7) {", "vu_panic(VAR_0, \"Incorrect order for descriptors\");", "return NULL;", "}", "virtqueue_map_desc(VAR_0, &VAR_6, VAR_8,\nVIRTQUEUE_MAX_SIZE, false,\nVAR_9[VAR_3].addr, VAR_9[VAR_3].len);", "}", "if ((VAR_7 + VAR_6) > VAR_5) {", "vu_panic(VAR_0, \"Looped descriptor\");", "}", "VAR_10 = virtqueue_read_next_desc(VAR_0, VAR_9, VAR_3, VAR_5, &VAR_3);", "} while (VAR_10 == VIRTQUEUE_READ_DESC_MORE);", "if (VAR_10 == VIRTQUEUE_READ_DESC_ERROR) {", "return NULL;", "}", "elem = virtqueue_alloc_element(VAR_2, VAR_6, VAR_7);", "elem->index = VAR_4;", "for (VAR_3 = 0; VAR_3 < VAR_6; VAR_3++) {", "elem->out_sg[VAR_3] = VAR_8[VAR_3];", "}", "for (VAR_3 = 0; VAR_3 < VAR_7; VAR_3++) {", "elem->in_sg[VAR_3] = VAR_8[VAR_6 + VAR_3];", "}", "VAR_1->inuse++;", "return elem;", "}" ]
[ 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 37 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 103 ], [ 105 ], [ 107, 109, 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123, 125, 127 ], [ 129 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 147 ], [ 149 ], [ 151 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 175 ], [ 179 ], [ 181 ] ]
6,148
static void rtas_read_pci_config(sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { uint32_t val, size, addr; PCIDevice *dev = find_dev(spapr, 0, rtas_ld(args, 0)); if (!dev) { rtas_st(rets, 0, -1); return; } size = rtas_ld(args, 1); addr = rtas_pci_cfgaddr(rtas_ld(args, 0)); val = pci_default_read_config(dev, addr, size); rtas_st(rets, 0, 0); rtas_st(rets, 1, val); }
true
qemu
c9c3c80af71dd2b7813d1ada9b14cb51df584221
static void rtas_read_pci_config(sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { uint32_t val, size, addr; PCIDevice *dev = find_dev(spapr, 0, rtas_ld(args, 0)); if (!dev) { rtas_st(rets, 0, -1); return; } size = rtas_ld(args, 1); addr = rtas_pci_cfgaddr(rtas_ld(args, 0)); val = pci_default_read_config(dev, addr, size); rtas_st(rets, 0, 0); rtas_st(rets, 1, val); }
{ "code": [ " val = pci_default_read_config(dev, addr, size);", " val = pci_default_read_config(dev, addr, size);" ], "line_no": [ 29, 29 ] }
static void FUNC_0(sPAPREnvironment *VAR_0, uint32_t VAR_1, uint32_t VAR_2, target_ulong VAR_3, uint32_t VAR_4, target_ulong VAR_5) { uint32_t val, size, addr; PCIDevice *dev = find_dev(VAR_0, 0, rtas_ld(VAR_3, 0)); if (!dev) { rtas_st(VAR_5, 0, -1); return; } size = rtas_ld(VAR_3, 1); addr = rtas_pci_cfgaddr(rtas_ld(VAR_3, 0)); val = pci_default_read_config(dev, addr, size); rtas_st(VAR_5, 0, 0); rtas_st(VAR_5, 1, val); }
[ "static void FUNC_0(sPAPREnvironment *VAR_0,\nuint32_t VAR_1, uint32_t VAR_2,\ntarget_ulong VAR_3,\nuint32_t VAR_4, target_ulong VAR_5)\n{", "uint32_t val, size, addr;", "PCIDevice *dev = find_dev(VAR_0, 0, rtas_ld(VAR_3, 0));", "if (!dev) {", "rtas_st(VAR_5, 0, -1);", "return;", "}", "size = rtas_ld(VAR_3, 1);", "addr = rtas_pci_cfgaddr(rtas_ld(VAR_3, 0));", "val = pci_default_read_config(dev, addr, size);", "rtas_st(VAR_5, 0, 0);", "rtas_st(VAR_5, 1, val);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ] ]
6,149
static inline void RENAME(hyscale)(SwsContext *c, uint16_t *dst, int dstWidth, const uint8_t *src, int srcW, int xInc, const int16_t *hLumFilter, const int16_t *hLumFilterPos, int hLumFilterSize, uint8_t *formatConvBuffer, uint32_t *pal, int isAlpha) { void (*toYV12)(uint8_t *, const uint8_t *, int, uint32_t *) = isAlpha ? c->alpToYV12 : c->lumToYV12; void (*convertRange)(uint16_t *, int) = isAlpha ? NULL : c->lumConvertRange; src += isAlpha ? c->alpSrcOffset : c->lumSrcOffset; if (toYV12) { toYV12(formatConvBuffer, src, srcW, pal); src= formatConvBuffer; } if (!c->hyscale_fast) { c->hScale(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize); } else { // fast bilinear upscale / crap downscale c->hyscale_fast(c, dst, dstWidth, src, srcW, xInc); } if (convertRange) convertRange(dst, dstWidth); }
true
FFmpeg
c3ab0004ae4dffc32494ae84dd15cfaa909a7884
static inline void RENAME(hyscale)(SwsContext *c, uint16_t *dst, int dstWidth, const uint8_t *src, int srcW, int xInc, const int16_t *hLumFilter, const int16_t *hLumFilterPos, int hLumFilterSize, uint8_t *formatConvBuffer, uint32_t *pal, int isAlpha) { void (*toYV12)(uint8_t *, const uint8_t *, int, uint32_t *) = isAlpha ? c->alpToYV12 : c->lumToYV12; void (*convertRange)(uint16_t *, int) = isAlpha ? NULL : c->lumConvertRange; src += isAlpha ? c->alpSrcOffset : c->lumSrcOffset; if (toYV12) { toYV12(formatConvBuffer, src, srcW, pal); src= formatConvBuffer; } if (!c->hyscale_fast) { c->hScale(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize); } else { c->hyscale_fast(c, dst, dstWidth, src, srcW, xInc); } if (convertRange) convertRange(dst, dstWidth); }
{ "code": [ "static inline void RENAME(hyscale)(SwsContext *c, uint16_t *dst, int dstWidth, const uint8_t *src, int srcW, int xInc,", " void (*toYV12)(uint8_t *, const uint8_t *, int, uint32_t *) = isAlpha ? c->alpToYV12 : c->lumToYV12;" ], "line_no": [ 1, 13 ] }
VAR_3staticVAR_3 VAR_3inlineVAR_3 VAR_3voidVAR_3 VAR_3RENAMEVAR_3(VAR_3hyscaleVAR_3)(VAR_3SwsContextVAR_3 *VAR_3cVAR_3, VAR_3uint16_tVAR_3 *VAR_3dstVAR_3, VAR_3intVAR_3 VAR_3dstWidthVAR_3, VAR_3constVAR_3 VAR_3uint8_tVAR_3 *VAR_3srcVAR_3, VAR_3intVAR_3 VAR_3srcWVAR_3, VAR_3intVAR_3 VAR_3xIncVAR_3, VAR_3constVAR_3 VAR_3int16_tVAR_3 *VAR_3hLumFilterVAR_3, VAR_3constVAR_3 VAR_3int16_tVAR_3 *VAR_3hLumFilterPosVAR_3, VAR_3intVAR_3 VAR_3hLumFilterSizeVAR_3, VAR_3uint8_tVAR_3 *VAR_3formatConvBufferVAR_3, VAR_3uint32_tVAR_3 *VAR_3palVAR_3, VAR_3intVAR_3 VAR_3isAlphaVAR_3) { VAR_3voidVAR_3 (*VAR_3VAR_0VAR_3)(VAR_3uint8_tVAR_3 *, VAR_3constVAR_3 VAR_3uint8_tVAR_3 *, VAR_3intVAR_3, VAR_3uint32_tVAR_3 *) = VAR_3isAlphaVAR_3 ? VAR_3cVAR_3->VAR_3alpToYV12VAR_3 : VAR_3cVAR_3->VAR_3lumToYV12VAR_3; VAR_3voidVAR_3 (*VAR_3convertRangeVAR_3)(VAR_3uint16_tVAR_3 *, VAR_3intVAR_3) = VAR_3isAlphaVAR_3 ? VAR_3NULLVAR_3 : VAR_3cVAR_3->VAR_3lumConvertRangeVAR_3; VAR_3srcVAR_3 += VAR_3isAlphaVAR_3 ? VAR_3cVAR_3->VAR_3alpSrcOffsetVAR_3 : VAR_3cVAR_3->VAR_3lumSrcOffsetVAR_3; VAR_3ifVAR_3 (VAR_3VAR_0VAR_3) { VAR_3VAR_0VAR_3(VAR_3formatConvBufferVAR_3, VAR_3srcVAR_3, VAR_3srcWVAR_3, VAR_3palVAR_3); VAR_3srcVAR_3= VAR_3formatConvBufferVAR_3; } VAR_3ifVAR_3 (!VAR_3cVAR_3->VAR_3hyscale_fastVAR_3) { VAR_3cVAR_3->VAR_3hScaleVAR_3(VAR_3dstVAR_3, VAR_3dstWidthVAR_3, VAR_3srcVAR_3, VAR_3srcWVAR_3, VAR_3xIncVAR_3, VAR_3hLumFilterVAR_3, VAR_3hLumFilterPosVAR_3, VAR_3hLumFilterSizeVAR_3); } VAR_3elseVAR_3 { VAR_3cVAR_3->VAR_3hyscale_fastVAR_3(VAR_3cVAR_3, VAR_3dstVAR_3, VAR_3dstWidthVAR_3, VAR_3srcVAR_3, VAR_3srcWVAR_3, VAR_3xIncVAR_3); } VAR_3ifVAR_3 (VAR_3convertRangeVAR_3) VAR_3convertRangeVAR_3(VAR_3dstVAR_3, VAR_3dstWidthVAR_3); }
[ "VAR_3staticVAR_3 VAR_3inlineVAR_3 VAR_3voidVAR_3 VAR_3RENAMEVAR_3(VAR_3hyscaleVAR_3)(VAR_3SwsContextVAR_3 *VAR_3cVAR_3, VAR_3uint16_tVAR_3 *VAR_3dstVAR_3, VAR_3intVAR_3 VAR_3dstWidthVAR_3, VAR_3constVAR_3 VAR_3uint8_tVAR_3 *VAR_3srcVAR_3, VAR_3intVAR_3 VAR_3srcWVAR_3, VAR_3intVAR_3 VAR_3xIncVAR_3,\nVAR_3constVAR_3 VAR_3int16_tVAR_3 *VAR_3hLumFilterVAR_3,\nVAR_3constVAR_3 VAR_3int16_tVAR_3 *VAR_3hLumFilterPosVAR_3, VAR_3intVAR_3 VAR_3hLumFilterSizeVAR_3,\nVAR_3uint8_tVAR_3 *VAR_3formatConvBufferVAR_3,\nVAR_3uint32_tVAR_3 *VAR_3palVAR_3, VAR_3intVAR_3 VAR_3isAlphaVAR_3)\n{", "VAR_3voidVAR_3 (*VAR_3VAR_0VAR_3)(VAR_3uint8_tVAR_3 *, VAR_3constVAR_3 VAR_3uint8_tVAR_3 *, VAR_3intVAR_3, VAR_3uint32_tVAR_3 *) = VAR_3isAlphaVAR_3 ? VAR_3cVAR_3->VAR_3alpToYV12VAR_3 : VAR_3cVAR_3->VAR_3lumToYV12VAR_3;", "VAR_3voidVAR_3 (*VAR_3convertRangeVAR_3)(VAR_3uint16_tVAR_3 *, VAR_3intVAR_3) = VAR_3isAlphaVAR_3 ? VAR_3NULLVAR_3 : VAR_3cVAR_3->VAR_3lumConvertRangeVAR_3;", "VAR_3srcVAR_3 += VAR_3isAlphaVAR_3 ? VAR_3cVAR_3->VAR_3alpSrcOffsetVAR_3 : VAR_3cVAR_3->VAR_3lumSrcOffsetVAR_3;", "VAR_3ifVAR_3 (VAR_3VAR_0VAR_3) {", "VAR_3VAR_0VAR_3(VAR_3formatConvBufferVAR_3, VAR_3srcVAR_3, VAR_3srcWVAR_3, VAR_3palVAR_3);", "VAR_3srcVAR_3= VAR_3formatConvBufferVAR_3;", "}", "VAR_3ifVAR_3 (!VAR_3cVAR_3->VAR_3hyscale_fastVAR_3) {", "VAR_3cVAR_3->VAR_3hScaleVAR_3(VAR_3dstVAR_3, VAR_3dstWidthVAR_3, VAR_3srcVAR_3, VAR_3srcWVAR_3, VAR_3xIncVAR_3, VAR_3hLumFilterVAR_3, VAR_3hLumFilterPosVAR_3, VAR_3hLumFilterSizeVAR_3);", "} VAR_3elseVAR_3 {", "VAR_3cVAR_3->VAR_3hyscale_fastVAR_3(VAR_3cVAR_3, VAR_3dstVAR_3, VAR_3dstWidthVAR_3, VAR_3srcVAR_3, VAR_3srcWVAR_3, VAR_3xIncVAR_3);", "}", "VAR_3ifVAR_3 (VAR_3convertRangeVAR_3)\nVAR_3convertRangeVAR_3(VAR_3dstVAR_3, VAR_3dstWidthVAR_3);", "}" ]
[ 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11 ], [ 13 ], [ 15 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45, 47 ], [ 49 ] ]
6,150
static int dxtory_decode_v2(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size) { GetByteContext gb; GetBitContext gb2; int nslices, slice, slice_height, ref_slice_height; int cur_y, next_y; uint32_t off, slice_size; uint8_t *Y, *U, *V; int ret; bytestream2_init(&gb, src, src_size); nslices = bytestream2_get_le16(&gb); off = FFALIGN(nslices * 4 + 2, 16); if (src_size < off) { av_log(avctx, AV_LOG_ERROR, "no slice data\n"); return AVERROR_INVALIDDATA; } if (!nslices || avctx->height % nslices) { avpriv_request_sample(avctx, "%d slices for %dx%d", nslices, avctx->width, avctx->height); return AVERROR(ENOSYS); } ref_slice_height = avctx->height / nslices; if ((avctx->width & 1) || (avctx->height & 1)) { avpriv_request_sample(avctx, "Frame dimensions %dx%d", avctx->width, avctx->height); } avctx->pix_fmt = AV_PIX_FMT_YUV420P; if ((ret = ff_get_buffer(avctx, pic, 0)) < 0) return ret; Y = pic->data[0]; U = pic->data[1]; V = pic->data[2]; cur_y = 0; next_y = ref_slice_height; for (slice = 0; slice < nslices; slice++) { slice_size = bytestream2_get_le32(&gb); slice_height = (next_y & ~1) - (cur_y & ~1); if (slice_size > src_size - off) { av_log(avctx, AV_LOG_ERROR, "invalid slice size %d (only %d bytes left)\n", slice_size, src_size - off); return AVERROR_INVALIDDATA; } if (slice_size <= 16) { av_log(avctx, AV_LOG_ERROR, "invalid slice size %d\n", slice_size); return AVERROR_INVALIDDATA; } if (AV_RL32(src + off) != slice_size - 16) { av_log(avctx, AV_LOG_ERROR, "Slice sizes mismatch: got %d instead of %d\n", AV_RL32(src + off), slice_size - 16); } init_get_bits(&gb2, src + off + 16, (slice_size - 16) * 8); dx2_decode_slice(&gb2, avctx->width, slice_height, Y, U, V, pic->linesize[0], pic->linesize[1], pic->linesize[2]); Y += pic->linesize[0] * slice_height; U += pic->linesize[1] * (slice_height >> 1); V += pic->linesize[2] * (slice_height >> 1); off += slice_size; cur_y = next_y; next_y += ref_slice_height; } return 0; }
true
FFmpeg
025fd76e1a2623c858d8c686a73cc30980a314b0
static int dxtory_decode_v2(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size) { GetByteContext gb; GetBitContext gb2; int nslices, slice, slice_height, ref_slice_height; int cur_y, next_y; uint32_t off, slice_size; uint8_t *Y, *U, *V; int ret; bytestream2_init(&gb, src, src_size); nslices = bytestream2_get_le16(&gb); off = FFALIGN(nslices * 4 + 2, 16); if (src_size < off) { av_log(avctx, AV_LOG_ERROR, "no slice data\n"); return AVERROR_INVALIDDATA; } if (!nslices || avctx->height % nslices) { avpriv_request_sample(avctx, "%d slices for %dx%d", nslices, avctx->width, avctx->height); return AVERROR(ENOSYS); } ref_slice_height = avctx->height / nslices; if ((avctx->width & 1) || (avctx->height & 1)) { avpriv_request_sample(avctx, "Frame dimensions %dx%d", avctx->width, avctx->height); } avctx->pix_fmt = AV_PIX_FMT_YUV420P; if ((ret = ff_get_buffer(avctx, pic, 0)) < 0) return ret; Y = pic->data[0]; U = pic->data[1]; V = pic->data[2]; cur_y = 0; next_y = ref_slice_height; for (slice = 0; slice < nslices; slice++) { slice_size = bytestream2_get_le32(&gb); slice_height = (next_y & ~1) - (cur_y & ~1); if (slice_size > src_size - off) { av_log(avctx, AV_LOG_ERROR, "invalid slice size %d (only %d bytes left)\n", slice_size, src_size - off); return AVERROR_INVALIDDATA; } if (slice_size <= 16) { av_log(avctx, AV_LOG_ERROR, "invalid slice size %d\n", slice_size); return AVERROR_INVALIDDATA; } if (AV_RL32(src + off) != slice_size - 16) { av_log(avctx, AV_LOG_ERROR, "Slice sizes mismatch: got %d instead of %d\n", AV_RL32(src + off), slice_size - 16); } init_get_bits(&gb2, src + off + 16, (slice_size - 16) * 8); dx2_decode_slice(&gb2, avctx->width, slice_height, Y, U, V, pic->linesize[0], pic->linesize[1], pic->linesize[2]); Y += pic->linesize[0] * slice_height; U += pic->linesize[1] * (slice_height >> 1); V += pic->linesize[2] * (slice_height >> 1); off += slice_size; cur_y = next_y; next_y += ref_slice_height; } return 0; }
{ "code": [ " return AVERROR(ENOSYS);" ], "line_no": [ 45 ] }
static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1, const uint8_t *VAR_2, int VAR_3) { GetByteContext gb; GetBitContext gb2; int VAR_4, VAR_5, VAR_6, VAR_7; int VAR_8, VAR_9; uint32_t off, slice_size; uint8_t *Y, *U, *V; int VAR_10; bytestream2_init(&gb, VAR_2, VAR_3); VAR_4 = bytestream2_get_le16(&gb); off = FFALIGN(VAR_4 * 4 + 2, 16); if (VAR_3 < off) { av_log(VAR_0, AV_LOG_ERROR, "no VAR_5 data\n"); return AVERROR_INVALIDDATA; } if (!VAR_4 || VAR_0->height % VAR_4) { avpriv_request_sample(VAR_0, "%d slices for %dx%d", VAR_4, VAR_0->width, VAR_0->height); return AVERROR(ENOSYS); } VAR_7 = VAR_0->height / VAR_4; if ((VAR_0->width & 1) || (VAR_0->height & 1)) { avpriv_request_sample(VAR_0, "Frame dimensions %dx%d", VAR_0->width, VAR_0->height); } VAR_0->pix_fmt = AV_PIX_FMT_YUV420P; if ((VAR_10 = ff_get_buffer(VAR_0, VAR_1, 0)) < 0) return VAR_10; Y = VAR_1->data[0]; U = VAR_1->data[1]; V = VAR_1->data[2]; VAR_8 = 0; VAR_9 = VAR_7; for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) { slice_size = bytestream2_get_le32(&gb); VAR_6 = (VAR_9 & ~1) - (VAR_8 & ~1); if (slice_size > VAR_3 - off) { av_log(VAR_0, AV_LOG_ERROR, "invalid VAR_5 size %d (only %d bytes left)\n", slice_size, VAR_3 - off); return AVERROR_INVALIDDATA; } if (slice_size <= 16) { av_log(VAR_0, AV_LOG_ERROR, "invalid VAR_5 size %d\n", slice_size); return AVERROR_INVALIDDATA; } if (AV_RL32(VAR_2 + off) != slice_size - 16) { av_log(VAR_0, AV_LOG_ERROR, "Slice sizes mismatch: got %d instead of %d\n", AV_RL32(VAR_2 + off), slice_size - 16); } init_get_bits(&gb2, VAR_2 + off + 16, (slice_size - 16) * 8); dx2_decode_slice(&gb2, VAR_0->width, VAR_6, Y, U, V, VAR_1->linesize[0], VAR_1->linesize[1], VAR_1->linesize[2]); Y += VAR_1->linesize[0] * VAR_6; U += VAR_1->linesize[1] * (VAR_6 >> 1); V += VAR_1->linesize[2] * (VAR_6 >> 1); off += slice_size; VAR_8 = VAR_9; VAR_9 += VAR_7; } return 0; }
[ "static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1,\nconst uint8_t *VAR_2, int VAR_3)\n{", "GetByteContext gb;", "GetBitContext gb2;", "int VAR_4, VAR_5, VAR_6, VAR_7;", "int VAR_8, VAR_9;", "uint32_t off, slice_size;", "uint8_t *Y, *U, *V;", "int VAR_10;", "bytestream2_init(&gb, VAR_2, VAR_3);", "VAR_4 = bytestream2_get_le16(&gb);", "off = FFALIGN(VAR_4 * 4 + 2, 16);", "if (VAR_3 < off) {", "av_log(VAR_0, AV_LOG_ERROR, \"no VAR_5 data\\n\");", "return AVERROR_INVALIDDATA;", "}", "if (!VAR_4 || VAR_0->height % VAR_4) {", "avpriv_request_sample(VAR_0, \"%d slices for %dx%d\", VAR_4,\nVAR_0->width, VAR_0->height);", "return AVERROR(ENOSYS);", "}", "VAR_7 = VAR_0->height / VAR_4;", "if ((VAR_0->width & 1) || (VAR_0->height & 1)) {", "avpriv_request_sample(VAR_0, \"Frame dimensions %dx%d\",\nVAR_0->width, VAR_0->height);", "}", "VAR_0->pix_fmt = AV_PIX_FMT_YUV420P;", "if ((VAR_10 = ff_get_buffer(VAR_0, VAR_1, 0)) < 0)\nreturn VAR_10;", "Y = VAR_1->data[0];", "U = VAR_1->data[1];", "V = VAR_1->data[2];", "VAR_8 = 0;", "VAR_9 = VAR_7;", "for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {", "slice_size = bytestream2_get_le32(&gb);", "VAR_6 = (VAR_9 & ~1) - (VAR_8 & ~1);", "if (slice_size > VAR_3 - off) {", "av_log(VAR_0, AV_LOG_ERROR,\n\"invalid VAR_5 size %d (only %d bytes left)\\n\",\nslice_size, VAR_3 - off);", "return AVERROR_INVALIDDATA;", "}", "if (slice_size <= 16) {", "av_log(VAR_0, AV_LOG_ERROR, \"invalid VAR_5 size %d\\n\", slice_size);", "return AVERROR_INVALIDDATA;", "}", "if (AV_RL32(VAR_2 + off) != slice_size - 16) {", "av_log(VAR_0, AV_LOG_ERROR,\n\"Slice sizes mismatch: got %d instead of %d\\n\",\nAV_RL32(VAR_2 + off), slice_size - 16);", "}", "init_get_bits(&gb2, VAR_2 + off + 16, (slice_size - 16) * 8);", "dx2_decode_slice(&gb2, VAR_0->width, VAR_6, Y, U, V,\nVAR_1->linesize[0], VAR_1->linesize[1], VAR_1->linesize[2]);", "Y += VAR_1->linesize[0] * VAR_6;", "U += VAR_1->linesize[1] * (VAR_6 >> 1);", "V += VAR_1->linesize[2] * (VAR_6 >> 1);", "off += slice_size;", "VAR_8 = VAR_9;", "VAR_9 += VAR_7;", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41, 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 55, 57 ], [ 59 ], [ 63 ], [ 65, 67 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91, 93, 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 111 ], [ 113, 115, 117 ], [ 119 ], [ 121 ], [ 123, 125 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 145 ], [ 147 ] ]
6,151
static int decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket* avpkt) { WMAProDecodeCtx *s = avctx->priv_data; GetBitContext* gb = &s->pgb; const uint8_t* buf = avpkt->data; int buf_size = avpkt->size; int num_bits_prev_frame; int packet_sequence_number; *got_frame_ptr = 0; if (s->packet_done || s->packet_loss) { s->packet_done = 0; /** sanity check for the buffer length */ if (buf_size < avctx->block_align) { av_log(avctx, AV_LOG_ERROR, "Input packet too small (%d < %d)\n", buf_size, avctx->block_align); return AVERROR_INVALIDDATA; } s->next_packet_start = buf_size - avctx->block_align; buf_size = avctx->block_align; s->buf_bit_size = buf_size << 3; /** parse packet header */ init_get_bits(gb, buf, s->buf_bit_size); packet_sequence_number = get_bits(gb, 4); skip_bits(gb, 2); /** get number of bits that need to be added to the previous frame */ num_bits_prev_frame = get_bits(gb, s->log2_frame_size); av_dlog(avctx, "packet[%d]: nbpf %x\n", avctx->frame_number, num_bits_prev_frame); /** check for packet loss */ if (!s->packet_loss && ((s->packet_sequence_number + 1) & 0xF) != packet_sequence_number) { s->packet_loss = 1; av_log(avctx, AV_LOG_ERROR, "Packet loss detected! seq %x vs %x\n", s->packet_sequence_number, packet_sequence_number); } s->packet_sequence_number = packet_sequence_number; if (num_bits_prev_frame > 0) { int remaining_packet_bits = s->buf_bit_size - get_bits_count(gb); if (num_bits_prev_frame >= remaining_packet_bits) { num_bits_prev_frame = remaining_packet_bits; s->packet_done = 1; } /** append the previous frame data to the remaining data from the previous packet to create a full frame */ save_bits(s, gb, num_bits_prev_frame, 1); av_dlog(avctx, "accumulated %x bits of frame data\n", s->num_saved_bits - s->frame_offset); /** decode the cross packet frame if it is valid */ if (!s->packet_loss) decode_frame(s, data, got_frame_ptr); } else if (s->num_saved_bits - s->frame_offset) { av_dlog(avctx, "ignoring %x previously saved bits\n", s->num_saved_bits - s->frame_offset); } if (s->packet_loss) { /** reset number of saved bits so that the decoder does not start to decode incomplete frames in the s->len_prefix == 0 case */ s->num_saved_bits = 0; s->packet_loss = 0; } } else { int frame_size; s->buf_bit_size = (avpkt->size - s->next_packet_start) << 3; init_get_bits(gb, avpkt->data, s->buf_bit_size); skip_bits(gb, s->packet_offset); if (s->len_prefix && remaining_bits(s, gb) > s->log2_frame_size && (frame_size = show_bits(gb, s->log2_frame_size)) && frame_size <= remaining_bits(s, gb)) { save_bits(s, gb, frame_size, 0); s->packet_done = !decode_frame(s, data, got_frame_ptr); } else if (!s->len_prefix && s->num_saved_bits > get_bits_count(&s->gb)) { /** when the frames do not have a length prefix, we don't know the compressed length of the individual frames however, we know what part of a new packet belongs to the previous frame therefore we save the incoming packet first, then we append the "previous frame" data from the next packet so that we get a buffer that only contains full frames */ s->packet_done = !decode_frame(s, data, got_frame_ptr); } else s->packet_done = 1; } if (s->packet_done && !s->packet_loss && remaining_bits(s, gb) > 0) { /** save the rest of the data so that it can be decoded with the next packet */ save_bits(s, gb, remaining_bits(s, gb), 0); } s->packet_offset = get_bits_count(gb) & 7; if (s->packet_loss) return AVERROR_INVALIDDATA; return get_bits_count(gb) >> 3; }
true
FFmpeg
c7a7605656633e52ade8a5d32a7c2497b37faef8
static int decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket* avpkt) { WMAProDecodeCtx *s = avctx->priv_data; GetBitContext* gb = &s->pgb; const uint8_t* buf = avpkt->data; int buf_size = avpkt->size; int num_bits_prev_frame; int packet_sequence_number; *got_frame_ptr = 0; if (s->packet_done || s->packet_loss) { s->packet_done = 0; if (buf_size < avctx->block_align) { av_log(avctx, AV_LOG_ERROR, "Input packet too small (%d < %d)\n", buf_size, avctx->block_align); return AVERROR_INVALIDDATA; } s->next_packet_start = buf_size - avctx->block_align; buf_size = avctx->block_align; s->buf_bit_size = buf_size << 3; init_get_bits(gb, buf, s->buf_bit_size); packet_sequence_number = get_bits(gb, 4); skip_bits(gb, 2); num_bits_prev_frame = get_bits(gb, s->log2_frame_size); av_dlog(avctx, "packet[%d]: nbpf %x\n", avctx->frame_number, num_bits_prev_frame); if (!s->packet_loss && ((s->packet_sequence_number + 1) & 0xF) != packet_sequence_number) { s->packet_loss = 1; av_log(avctx, AV_LOG_ERROR, "Packet loss detected! seq %x vs %x\n", s->packet_sequence_number, packet_sequence_number); } s->packet_sequence_number = packet_sequence_number; if (num_bits_prev_frame > 0) { int remaining_packet_bits = s->buf_bit_size - get_bits_count(gb); if (num_bits_prev_frame >= remaining_packet_bits) { num_bits_prev_frame = remaining_packet_bits; s->packet_done = 1; } save_bits(s, gb, num_bits_prev_frame, 1); av_dlog(avctx, "accumulated %x bits of frame data\n", s->num_saved_bits - s->frame_offset); if (!s->packet_loss) decode_frame(s, data, got_frame_ptr); } else if (s->num_saved_bits - s->frame_offset) { av_dlog(avctx, "ignoring %x previously saved bits\n", s->num_saved_bits - s->frame_offset); } if (s->packet_loss) { s->num_saved_bits = 0; s->packet_loss = 0; } } else { int frame_size; s->buf_bit_size = (avpkt->size - s->next_packet_start) << 3; init_get_bits(gb, avpkt->data, s->buf_bit_size); skip_bits(gb, s->packet_offset); if (s->len_prefix && remaining_bits(s, gb) > s->log2_frame_size && (frame_size = show_bits(gb, s->log2_frame_size)) && frame_size <= remaining_bits(s, gb)) { save_bits(s, gb, frame_size, 0); s->packet_done = !decode_frame(s, data, got_frame_ptr); } else if (!s->len_prefix && s->num_saved_bits > get_bits_count(&s->gb)) { s->packet_done = !decode_frame(s, data, got_frame_ptr); } else s->packet_done = 1; } if (s->packet_done && !s->packet_loss && remaining_bits(s, gb) > 0) { save_bits(s, gb, remaining_bits(s, gb), 0); } s->packet_offset = get_bits_count(gb) & 7; if (s->packet_loss) return AVERROR_INVALIDDATA; return get_bits_count(gb) >> 3; }
{ "code": [ " s->packet_done = !decode_frame(s, data, got_frame_ptr);" ], "line_no": [ 167 ] }
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, AVPacket* VAR_3) { WMAProDecodeCtx *s = VAR_0->priv_data; GetBitContext* gb = &s->pgb; const uint8_t* VAR_4 = VAR_3->VAR_1; int VAR_5 = VAR_3->size; int VAR_6; int VAR_7; *VAR_2 = 0; if (s->packet_done || s->packet_loss) { s->packet_done = 0; if (VAR_5 < VAR_0->block_align) { av_log(VAR_0, AV_LOG_ERROR, "Input packet too small (%d < %d)\n", VAR_5, VAR_0->block_align); return AVERROR_INVALIDDATA; } s->next_packet_start = VAR_5 - VAR_0->block_align; VAR_5 = VAR_0->block_align; s->buf_bit_size = VAR_5 << 3; init_get_bits(gb, VAR_4, s->buf_bit_size); VAR_7 = get_bits(gb, 4); skip_bits(gb, 2); VAR_6 = get_bits(gb, s->log2_frame_size); av_dlog(VAR_0, "packet[%d]: nbpf %x\n", VAR_0->frame_number, VAR_6); if (!s->packet_loss && ((s->VAR_7 + 1) & 0xF) != VAR_7) { s->packet_loss = 1; av_log(VAR_0, AV_LOG_ERROR, "Packet loss detected! seq %x vs %x\n", s->VAR_7, VAR_7); } s->VAR_7 = VAR_7; if (VAR_6 > 0) { int VAR_8 = s->buf_bit_size - get_bits_count(gb); if (VAR_6 >= VAR_8) { VAR_6 = VAR_8; s->packet_done = 1; } save_bits(s, gb, VAR_6, 1); av_dlog(VAR_0, "accumulated %x bits of frame VAR_1\n", s->num_saved_bits - s->frame_offset); if (!s->packet_loss) decode_frame(s, VAR_1, VAR_2); } else if (s->num_saved_bits - s->frame_offset) { av_dlog(VAR_0, "ignoring %x previously saved bits\n", s->num_saved_bits - s->frame_offset); } if (s->packet_loss) { s->num_saved_bits = 0; s->packet_loss = 0; } } else { int VAR_9; s->buf_bit_size = (VAR_3->size - s->next_packet_start) << 3; init_get_bits(gb, VAR_3->VAR_1, s->buf_bit_size); skip_bits(gb, s->packet_offset); if (s->len_prefix && remaining_bits(s, gb) > s->log2_frame_size && (VAR_9 = show_bits(gb, s->log2_frame_size)) && VAR_9 <= remaining_bits(s, gb)) { save_bits(s, gb, VAR_9, 0); s->packet_done = !decode_frame(s, VAR_1, VAR_2); } else if (!s->len_prefix && s->num_saved_bits > get_bits_count(&s->gb)) { s->packet_done = !decode_frame(s, VAR_1, VAR_2); } else s->packet_done = 1; } if (s->packet_done && !s->packet_loss && remaining_bits(s, gb) > 0) { save_bits(s, gb, remaining_bits(s, gb), 0); } s->packet_offset = get_bits_count(gb) & 7; if (s->packet_loss) return AVERROR_INVALIDDATA; return get_bits_count(gb) >> 3; }
[ "static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket* VAR_3)\n{", "WMAProDecodeCtx *s = VAR_0->priv_data;", "GetBitContext* gb = &s->pgb;", "const uint8_t* VAR_4 = VAR_3->VAR_1;", "int VAR_5 = VAR_3->size;", "int VAR_6;", "int VAR_7;", "*VAR_2 = 0;", "if (s->packet_done || s->packet_loss) {", "s->packet_done = 0;", "if (VAR_5 < VAR_0->block_align) {", "av_log(VAR_0, AV_LOG_ERROR, \"Input packet too small (%d < %d)\\n\",\nVAR_5, VAR_0->block_align);", "return AVERROR_INVALIDDATA;", "}", "s->next_packet_start = VAR_5 - VAR_0->block_align;", "VAR_5 = VAR_0->block_align;", "s->buf_bit_size = VAR_5 << 3;", "init_get_bits(gb, VAR_4, s->buf_bit_size);", "VAR_7 = get_bits(gb, 4);", "skip_bits(gb, 2);", "VAR_6 = get_bits(gb, s->log2_frame_size);", "av_dlog(VAR_0, \"packet[%d]: nbpf %x\\n\", VAR_0->frame_number,\nVAR_6);", "if (!s->packet_loss &&\n((s->VAR_7 + 1) & 0xF) != VAR_7) {", "s->packet_loss = 1;", "av_log(VAR_0, AV_LOG_ERROR, \"Packet loss detected! seq %x vs %x\\n\",\ns->VAR_7, VAR_7);", "}", "s->VAR_7 = VAR_7;", "if (VAR_6 > 0) {", "int VAR_8 = s->buf_bit_size - get_bits_count(gb);", "if (VAR_6 >= VAR_8) {", "VAR_6 = VAR_8;", "s->packet_done = 1;", "}", "save_bits(s, gb, VAR_6, 1);", "av_dlog(VAR_0, \"accumulated %x bits of frame VAR_1\\n\",\ns->num_saved_bits - s->frame_offset);", "if (!s->packet_loss)\ndecode_frame(s, VAR_1, VAR_2);", "} else if (s->num_saved_bits - s->frame_offset) {", "av_dlog(VAR_0, \"ignoring %x previously saved bits\\n\",\ns->num_saved_bits - s->frame_offset);", "}", "if (s->packet_loss) {", "s->num_saved_bits = 0;", "s->packet_loss = 0;", "}", "} else {", "int VAR_9;", "s->buf_bit_size = (VAR_3->size - s->next_packet_start) << 3;", "init_get_bits(gb, VAR_3->VAR_1, s->buf_bit_size);", "skip_bits(gb, s->packet_offset);", "if (s->len_prefix && remaining_bits(s, gb) > s->log2_frame_size &&\n(VAR_9 = show_bits(gb, s->log2_frame_size)) &&\nVAR_9 <= remaining_bits(s, gb)) {", "save_bits(s, gb, VAR_9, 0);", "s->packet_done = !decode_frame(s, VAR_1, VAR_2);", "} else if (!s->len_prefix", "&& s->num_saved_bits > get_bits_count(&s->gb)) {", "s->packet_done = !decode_frame(s, VAR_1, VAR_2);", "} else", "s->packet_done = 1;", "}", "if (s->packet_done && !s->packet_loss &&\nremaining_bits(s, gb) > 0) {", "save_bits(s, gb, remaining_bits(s, gb), 0);", "}", "s->packet_offset = get_bits_count(gb) & 7;", "if (s->packet_loss)\nreturn AVERROR_INVALIDDATA;", "return get_bits_count(gb) >> 3;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 25 ], [ 27 ], [ 33 ], [ 35, 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 55 ], [ 57 ], [ 59 ], [ 65 ], [ 67, 69 ], [ 75, 77 ], [ 79 ], [ 81, 83 ], [ 85 ], [ 87 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 109 ], [ 111, 113 ], [ 119, 121 ], [ 123 ], [ 125, 127 ], [ 129 ], [ 133 ], [ 141 ], [ 143 ], [ 145 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159, 161, 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 197, 199 ], [ 205 ], [ 207 ], [ 211 ], [ 213, 215 ], [ 219 ], [ 221 ] ]
6,152
static int qpa_init_out (HWVoiceOut *hw, struct audsettings *as) { int error; static pa_sample_spec ss; static pa_buffer_attr ba; struct audsettings obt_as = *as; PAVoiceOut *pa = (PAVoiceOut *) hw; ss.format = audfmt_to_pa (as->fmt, as->endianness); ss.channels = as->nchannels; ss.rate = as->freq; /* * qemu audio tick runs at 250 Hz (by default), so processing * data chunks worth 4 ms of sound should be a good fit. */ ba.tlength = pa_usec_to_bytes (4 * 1000, &ss); ba.minreq = pa_usec_to_bytes (2 * 1000, &ss); ba.maxlength = -1; ba.prebuf = -1; obt_as.fmt = pa_to_audfmt (ss.format, &obt_as.endianness); pa->s = pa_simple_new ( conf.server, "qemu", PA_STREAM_PLAYBACK, conf.sink, "pcm.playback", &ss, NULL, /* channel map */ &ba, /* buffering attributes */ &error ); if (!pa->s) { qpa_logerr (error, "pa_simple_new for playback failed\n"); goto fail1; } audio_pcm_init_info (&hw->info, &obt_as); hw->samples = conf.samples; pa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift); pa->rpos = hw->rpos; if (!pa->pcm_buf) { dolog ("Could not allocate buffer (%d bytes)\n", hw->samples << hw->info.shift); goto fail2; } if (audio_pt_init (&pa->pt, qpa_thread_out, hw, AUDIO_CAP, AUDIO_FUNC)) { goto fail3; } return 0; fail3: g_free (pa->pcm_buf); pa->pcm_buf = NULL; fail2: pa_simple_free (pa->s); pa->s = NULL; fail1: return -1; }
true
qemu
ea9ebc2ce69198f7aca4b43652824c5d621ac978
static int qpa_init_out (HWVoiceOut *hw, struct audsettings *as) { int error; static pa_sample_spec ss; static pa_buffer_attr ba; struct audsettings obt_as = *as; PAVoiceOut *pa = (PAVoiceOut *) hw; ss.format = audfmt_to_pa (as->fmt, as->endianness); ss.channels = as->nchannels; ss.rate = as->freq; ba.tlength = pa_usec_to_bytes (4 * 1000, &ss); ba.minreq = pa_usec_to_bytes (2 * 1000, &ss); ba.maxlength = -1; ba.prebuf = -1; obt_as.fmt = pa_to_audfmt (ss.format, &obt_as.endianness); pa->s = pa_simple_new ( conf.server, "qemu", PA_STREAM_PLAYBACK, conf.sink, "pcm.playback", &ss, NULL, &ba, &error ); if (!pa->s) { qpa_logerr (error, "pa_simple_new for playback failed\n"); goto fail1; } audio_pcm_init_info (&hw->info, &obt_as); hw->samples = conf.samples; pa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift); pa->rpos = hw->rpos; if (!pa->pcm_buf) { dolog ("Could not allocate buffer (%d bytes)\n", hw->samples << hw->info.shift); goto fail2; } if (audio_pt_init (&pa->pt, qpa_thread_out, hw, AUDIO_CAP, AUDIO_FUNC)) { goto fail3; } return 0; fail3: g_free (pa->pcm_buf); pa->pcm_buf = NULL; fail2: pa_simple_free (pa->s); pa->s = NULL; fail1: return -1; }
{ "code": [ " pa->s = pa_simple_new (", " conf.server,", " conf.sink,", " if (!pa->s) {", " hw->samples = conf.samples;", " pa_simple_free (pa->s);", " pa->s = NULL;", " pa->s = pa_simple_new (", " conf.server,", " if (!pa->s) {", " hw->samples = conf.samples;", " pa_simple_free (pa->s);", " pa->s = NULL;" ], "line_no": [ 47, 49, 55, 69, 81, 119, 121, 47, 49, 69, 81, 119, 121 ] }
static int FUNC_0 (HWVoiceOut *VAR_0, struct audsettings *VAR_1) { int VAR_2; static pa_sample_spec VAR_3; static pa_buffer_attr VAR_4; struct audsettings VAR_5 = *VAR_1; PAVoiceOut *pa = (PAVoiceOut *) VAR_0; VAR_3.format = audfmt_to_pa (VAR_1->fmt, VAR_1->endianness); VAR_3.channels = VAR_1->nchannels; VAR_3.rate = VAR_1->freq; VAR_4.tlength = pa_usec_to_bytes (4 * 1000, &VAR_3); VAR_4.minreq = pa_usec_to_bytes (2 * 1000, &VAR_3); VAR_4.maxlength = -1; VAR_4.prebuf = -1; VAR_5.fmt = pa_to_audfmt (VAR_3.format, &VAR_5.endianness); pa->s = pa_simple_new ( conf.server, "qemu", PA_STREAM_PLAYBACK, conf.sink, "pcm.playback", &VAR_3, NULL, &VAR_4, &VAR_2 ); if (!pa->s) { qpa_logerr (VAR_2, "pa_simple_new for playback failed\n"); goto fail1; } audio_pcm_init_info (&VAR_0->info, &VAR_5); VAR_0->samples = conf.samples; pa->pcm_buf = audio_calloc (AUDIO_FUNC, VAR_0->samples, 1 << VAR_0->info.shift); pa->rpos = VAR_0->rpos; if (!pa->pcm_buf) { dolog ("Could not allocate buffer (%d bytes)\n", VAR_0->samples << VAR_0->info.shift); goto fail2; } if (audio_pt_init (&pa->pt, qpa_thread_out, VAR_0, AUDIO_CAP, AUDIO_FUNC)) { goto fail3; } return 0; fail3: g_free (pa->pcm_buf); pa->pcm_buf = NULL; fail2: pa_simple_free (pa->s); pa->s = NULL; fail1: return -1; }
[ "static int FUNC_0 (HWVoiceOut *VAR_0, struct audsettings *VAR_1)\n{", "int VAR_2;", "static pa_sample_spec VAR_3;", "static pa_buffer_attr VAR_4;", "struct audsettings VAR_5 = *VAR_1;", "PAVoiceOut *pa = (PAVoiceOut *) VAR_0;", "VAR_3.format = audfmt_to_pa (VAR_1->fmt, VAR_1->endianness);", "VAR_3.channels = VAR_1->nchannels;", "VAR_3.rate = VAR_1->freq;", "VAR_4.tlength = pa_usec_to_bytes (4 * 1000, &VAR_3);", "VAR_4.minreq = pa_usec_to_bytes (2 * 1000, &VAR_3);", "VAR_4.maxlength = -1;", "VAR_4.prebuf = -1;", "VAR_5.fmt = pa_to_audfmt (VAR_3.format, &VAR_5.endianness);", "pa->s = pa_simple_new (\nconf.server,\n\"qemu\",\nPA_STREAM_PLAYBACK,\nconf.sink,\n\"pcm.playback\",\n&VAR_3,\nNULL,\n&VAR_4,\n&VAR_2\n);", "if (!pa->s) {", "qpa_logerr (VAR_2, \"pa_simple_new for playback failed\\n\");", "goto fail1;", "}", "audio_pcm_init_info (&VAR_0->info, &VAR_5);", "VAR_0->samples = conf.samples;", "pa->pcm_buf = audio_calloc (AUDIO_FUNC, VAR_0->samples, 1 << VAR_0->info.shift);", "pa->rpos = VAR_0->rpos;", "if (!pa->pcm_buf) {", "dolog (\"Could not allocate buffer (%d bytes)\\n\",\nVAR_0->samples << VAR_0->info.shift);", "goto fail2;", "}", "if (audio_pt_init (&pa->pt, qpa_thread_out, VAR_0, AUDIO_CAP, AUDIO_FUNC)) {", "goto fail3;", "}", "return 0;", "fail3:\ng_free (pa->pcm_buf);", "pa->pcm_buf = NULL;", "fail2:\npa_simple_free (pa->s);", "pa->s = NULL;", "fail1:\nreturn -1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89, 91 ], [ 93 ], [ 95 ], [ 99 ], [ 101 ], [ 103 ], [ 107 ], [ 111, 113 ], [ 115 ], [ 117, 119 ], [ 121 ], [ 123, 125 ], [ 127 ] ]
6,154
static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVRBDState *s = bs->opaque; char pool[RBD_MAX_POOL_NAME_SIZE]; char snap_buf[RBD_MAX_SNAP_NAME_SIZE]; char conf[RBD_MAX_CONF_SIZE]; char clientname_buf[RBD_MAX_CONF_SIZE]; char *clientname; QemuOpts *opts; Error *local_err = NULL; const char *filename; int r; opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (local_err) { error_propagate(errp, local_err); qemu_opts_del(opts); return -EINVAL; } filename = qemu_opt_get(opts, "filename"); if (qemu_rbd_parsename(filename, pool, sizeof(pool), snap_buf, sizeof(snap_buf), s->name, sizeof(s->name), conf, sizeof(conf), errp) < 0) { r = -EINVAL; goto failed_opts; } clientname = qemu_rbd_parse_clientname(conf, clientname_buf); r = rados_create(&s->cluster, clientname); if (r < 0) { error_setg(&local_err, "error initializing"); goto failed_opts; } s->snap = NULL; if (snap_buf[0] != '\0') { s->snap = g_strdup(snap_buf); } /* * Fallback to more conservative semantics if setting cache * options fails. Ignore errors from setting rbd_cache because the * only possible error is that the option does not exist, and * librbd defaults to no caching. If write through caching cannot * be set up, fall back to no caching. */ if (flags & BDRV_O_NOCACHE) { rados_conf_set(s->cluster, "rbd_cache", "false"); } else { rados_conf_set(s->cluster, "rbd_cache", "true"); } if (strstr(conf, "conf=") == NULL) { /* try default location, but ignore failure */ rados_conf_read_file(s->cluster, NULL); } if (conf[0] != '\0') { r = qemu_rbd_set_conf(s->cluster, conf, errp); if (r < 0) { goto failed_shutdown; } } r = rados_connect(s->cluster); if (r < 0) { error_setg(&local_err, "error connecting"); goto failed_shutdown; } r = rados_ioctx_create(s->cluster, pool, &s->io_ctx); if (r < 0) { error_setg(&local_err, "error opening pool %s", pool); goto failed_shutdown; } r = rbd_open(s->io_ctx, s->name, &s->image, s->snap); if (r < 0) { error_setg(&local_err, "error reading header from %s", s->name); goto failed_open; } bs->read_only = (s->snap != NULL); qemu_opts_del(opts); return 0; failed_open: rados_ioctx_destroy(s->io_ctx); failed_shutdown: rados_shutdown(s->cluster); g_free(s->snap); failed_opts: qemu_opts_del(opts); return r; }
true
qemu
9281dbe6535d79ecae121f6c3e620c25d55230e9
static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVRBDState *s = bs->opaque; char pool[RBD_MAX_POOL_NAME_SIZE]; char snap_buf[RBD_MAX_SNAP_NAME_SIZE]; char conf[RBD_MAX_CONF_SIZE]; char clientname_buf[RBD_MAX_CONF_SIZE]; char *clientname; QemuOpts *opts; Error *local_err = NULL; const char *filename; int r; opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (local_err) { error_propagate(errp, local_err); qemu_opts_del(opts); return -EINVAL; } filename = qemu_opt_get(opts, "filename"); if (qemu_rbd_parsename(filename, pool, sizeof(pool), snap_buf, sizeof(snap_buf), s->name, sizeof(s->name), conf, sizeof(conf), errp) < 0) { r = -EINVAL; goto failed_opts; } clientname = qemu_rbd_parse_clientname(conf, clientname_buf); r = rados_create(&s->cluster, clientname); if (r < 0) { error_setg(&local_err, "error initializing"); goto failed_opts; } s->snap = NULL; if (snap_buf[0] != '\0') { s->snap = g_strdup(snap_buf); } if (flags & BDRV_O_NOCACHE) { rados_conf_set(s->cluster, "rbd_cache", "false"); } else { rados_conf_set(s->cluster, "rbd_cache", "true"); } if (strstr(conf, "conf=") == NULL) { rados_conf_read_file(s->cluster, NULL); } if (conf[0] != '\0') { r = qemu_rbd_set_conf(s->cluster, conf, errp); if (r < 0) { goto failed_shutdown; } } r = rados_connect(s->cluster); if (r < 0) { error_setg(&local_err, "error connecting"); goto failed_shutdown; } r = rados_ioctx_create(s->cluster, pool, &s->io_ctx); if (r < 0) { error_setg(&local_err, "error opening pool %s", pool); goto failed_shutdown; } r = rbd_open(s->io_ctx, s->name, &s->image, s->snap); if (r < 0) { error_setg(&local_err, "error reading header from %s", s->name); goto failed_open; } bs->read_only = (s->snap != NULL); qemu_opts_del(opts); return 0; failed_open: rados_ioctx_destroy(s->io_ctx); failed_shutdown: rados_shutdown(s->cluster); g_free(s->snap); failed_opts: qemu_opts_del(opts); return r; }
{ "code": [ " error_setg(&local_err, \"error initializing\");", " error_setg(&local_err, \"error connecting\");", " error_setg(&local_err, \"error opening pool %s\", pool);", " error_setg(&local_err, \"error reading header from %s\", s->name);" ], "line_no": [ 71, 143, 155, 167 ] }
static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2, Error **VAR_3) { BDRVRBDState *s = VAR_0->opaque; char VAR_4[RBD_MAX_POOL_NAME_SIZE]; char VAR_5[RBD_MAX_SNAP_NAME_SIZE]; char VAR_6[RBD_MAX_CONF_SIZE]; char VAR_7[RBD_MAX_CONF_SIZE]; char *VAR_8; QemuOpts *opts; Error *local_err = NULL; const char *VAR_9; int VAR_10; opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, VAR_1, &local_err); if (local_err) { error_propagate(VAR_3, local_err); qemu_opts_del(opts); return -EINVAL; } VAR_9 = qemu_opt_get(opts, "VAR_9"); if (qemu_rbd_parsename(VAR_9, VAR_4, sizeof(VAR_4), VAR_5, sizeof(VAR_5), s->name, sizeof(s->name), VAR_6, sizeof(VAR_6), VAR_3) < 0) { VAR_10 = -EINVAL; goto failed_opts; } VAR_8 = qemu_rbd_parse_clientname(VAR_6, VAR_7); VAR_10 = rados_create(&s->cluster, VAR_8); if (VAR_10 < 0) { error_setg(&local_err, "error initializing"); goto failed_opts; } s->snap = NULL; if (VAR_5[0] != '\0') { s->snap = g_strdup(VAR_5); } if (VAR_2 & BDRV_O_NOCACHE) { rados_conf_set(s->cluster, "rbd_cache", "false"); } else { rados_conf_set(s->cluster, "rbd_cache", "true"); } if (strstr(VAR_6, "VAR_6=") == NULL) { rados_conf_read_file(s->cluster, NULL); } if (VAR_6[0] != '\0') { VAR_10 = qemu_rbd_set_conf(s->cluster, VAR_6, VAR_3); if (VAR_10 < 0) { goto failed_shutdown; } } VAR_10 = rados_connect(s->cluster); if (VAR_10 < 0) { error_setg(&local_err, "error connecting"); goto failed_shutdown; } VAR_10 = rados_ioctx_create(s->cluster, VAR_4, &s->io_ctx); if (VAR_10 < 0) { error_setg(&local_err, "error opening VAR_4 %s", VAR_4); goto failed_shutdown; } VAR_10 = rbd_open(s->io_ctx, s->name, &s->image, s->snap); if (VAR_10 < 0) { error_setg(&local_err, "error reading header from %s", s->name); goto failed_open; } VAR_0->read_only = (s->snap != NULL); qemu_opts_del(opts); return 0; failed_open: rados_ioctx_destroy(s->io_ctx); failed_shutdown: rados_shutdown(s->cluster); g_free(s->snap); failed_opts: qemu_opts_del(opts); return VAR_10; }
[ "static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,\nError **VAR_3)\n{", "BDRVRBDState *s = VAR_0->opaque;", "char VAR_4[RBD_MAX_POOL_NAME_SIZE];", "char VAR_5[RBD_MAX_SNAP_NAME_SIZE];", "char VAR_6[RBD_MAX_CONF_SIZE];", "char VAR_7[RBD_MAX_CONF_SIZE];", "char *VAR_8;", "QemuOpts *opts;", "Error *local_err = NULL;", "const char *VAR_9;", "int VAR_10;", "opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);", "qemu_opts_absorb_qdict(opts, VAR_1, &local_err);", "if (local_err) {", "error_propagate(VAR_3, local_err);", "qemu_opts_del(opts);", "return -EINVAL;", "}", "VAR_9 = qemu_opt_get(opts, \"VAR_9\");", "if (qemu_rbd_parsename(VAR_9, VAR_4, sizeof(VAR_4),\nVAR_5, sizeof(VAR_5),\ns->name, sizeof(s->name),\nVAR_6, sizeof(VAR_6), VAR_3) < 0) {", "VAR_10 = -EINVAL;", "goto failed_opts;", "}", "VAR_8 = qemu_rbd_parse_clientname(VAR_6, VAR_7);", "VAR_10 = rados_create(&s->cluster, VAR_8);", "if (VAR_10 < 0) {", "error_setg(&local_err, \"error initializing\");", "goto failed_opts;", "}", "s->snap = NULL;", "if (VAR_5[0] != '\\0') {", "s->snap = g_strdup(VAR_5);", "}", "if (VAR_2 & BDRV_O_NOCACHE) {", "rados_conf_set(s->cluster, \"rbd_cache\", \"false\");", "} else {", "rados_conf_set(s->cluster, \"rbd_cache\", \"true\");", "}", "if (strstr(VAR_6, \"VAR_6=\") == NULL) {", "rados_conf_read_file(s->cluster, NULL);", "}", "if (VAR_6[0] != '\\0') {", "VAR_10 = qemu_rbd_set_conf(s->cluster, VAR_6, VAR_3);", "if (VAR_10 < 0) {", "goto failed_shutdown;", "}", "}", "VAR_10 = rados_connect(s->cluster);", "if (VAR_10 < 0) {", "error_setg(&local_err, \"error connecting\");", "goto failed_shutdown;", "}", "VAR_10 = rados_ioctx_create(s->cluster, VAR_4, &s->io_ctx);", "if (VAR_10 < 0) {", "error_setg(&local_err, \"error opening VAR_4 %s\", VAR_4);", "goto failed_shutdown;", "}", "VAR_10 = rbd_open(s->io_ctx, s->name, &s->image, s->snap);", "if (VAR_10 < 0) {", "error_setg(&local_err, \"error reading header from %s\", s->name);", "goto failed_open;", "}", "VAR_0->read_only = (s->snap != NULL);", "qemu_opts_del(opts);", "return 0;", "failed_open:\nrados_ioctx_destroy(s->io_ctx);", "failed_shutdown:\nrados_shutdown(s->cluster);", "g_free(s->snap);", "failed_opts:\nqemu_opts_del(opts);", "return 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, 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, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 49, 51, 53, 55 ], [ 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 115 ], [ 119 ], [ 121 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 175 ], [ 179 ], [ 181 ], [ 185, 187 ], [ 189, 191 ], [ 193 ], [ 195, 197 ], [ 199 ], [ 201 ] ]
6,156
static void co_schedule_bh_cb(void *opaque) { AioContext *ctx = opaque; QSLIST_HEAD(, Coroutine) straight, reversed; QSLIST_MOVE_ATOMIC(&reversed, &ctx->scheduled_coroutines); QSLIST_INIT(&straight); while (!QSLIST_EMPTY(&reversed)) { Coroutine *co = QSLIST_FIRST(&reversed); QSLIST_REMOVE_HEAD(&reversed, co_scheduled_next); QSLIST_INSERT_HEAD(&straight, co, co_scheduled_next); } while (!QSLIST_EMPTY(&straight)) { Coroutine *co = QSLIST_FIRST(&straight); QSLIST_REMOVE_HEAD(&straight, co_scheduled_next); trace_aio_co_schedule_bh_cb(ctx, co); aio_context_acquire(ctx); qemu_coroutine_enter(co); aio_context_release(ctx); } }
true
qemu
6133b39f3c36623425a6ede9e89d93175fde15cd
static void co_schedule_bh_cb(void *opaque) { AioContext *ctx = opaque; QSLIST_HEAD(, Coroutine) straight, reversed; QSLIST_MOVE_ATOMIC(&reversed, &ctx->scheduled_coroutines); QSLIST_INIT(&straight); while (!QSLIST_EMPTY(&reversed)) { Coroutine *co = QSLIST_FIRST(&reversed); QSLIST_REMOVE_HEAD(&reversed, co_scheduled_next); QSLIST_INSERT_HEAD(&straight, co, co_scheduled_next); } while (!QSLIST_EMPTY(&straight)) { Coroutine *co = QSLIST_FIRST(&straight); QSLIST_REMOVE_HEAD(&straight, co_scheduled_next); trace_aio_co_schedule_bh_cb(ctx, co); aio_context_acquire(ctx); qemu_coroutine_enter(co); aio_context_release(ctx); } }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0) { AioContext *ctx = VAR_0; QSLIST_HEAD(, Coroutine) straight, reversed; QSLIST_MOVE_ATOMIC(&reversed, &ctx->scheduled_coroutines); QSLIST_INIT(&straight); while (!QSLIST_EMPTY(&reversed)) { Coroutine *co = QSLIST_FIRST(&reversed); QSLIST_REMOVE_HEAD(&reversed, co_scheduled_next); QSLIST_INSERT_HEAD(&straight, co, co_scheduled_next); } while (!QSLIST_EMPTY(&straight)) { Coroutine *co = QSLIST_FIRST(&straight); QSLIST_REMOVE_HEAD(&straight, co_scheduled_next); trace_aio_co_schedule_bh_cb(ctx, co); aio_context_acquire(ctx); qemu_coroutine_enter(co); aio_context_release(ctx); } }
[ "static void FUNC_0(void *VAR_0)\n{", "AioContext *ctx = VAR_0;", "QSLIST_HEAD(, Coroutine) straight, reversed;", "QSLIST_MOVE_ATOMIC(&reversed, &ctx->scheduled_coroutines);", "QSLIST_INIT(&straight);", "while (!QSLIST_EMPTY(&reversed)) {", "Coroutine *co = QSLIST_FIRST(&reversed);", "QSLIST_REMOVE_HEAD(&reversed, co_scheduled_next);", "QSLIST_INSERT_HEAD(&straight, co, co_scheduled_next);", "}", "while (!QSLIST_EMPTY(&straight)) {", "Coroutine *co = QSLIST_FIRST(&straight);", "QSLIST_REMOVE_HEAD(&straight, co_scheduled_next);", "trace_aio_co_schedule_bh_cb(ctx, co);", "aio_context_acquire(ctx);", "qemu_coroutine_enter(co);", "aio_context_release(ctx);", "}", "}" ]
[ 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 ] ]
6,157
static int http_connect(URLContext *h, const char *path, const char *local_path, const char *hoststr, const char *auth, const char *proxyauth, int *new_location) { HTTPContext *s = h->priv_data; int post, err; char headers[1024] = ""; char *authstr = NULL, *proxyauthstr = NULL; int64_t off = s->off; int len = 0; const char *method; /* send http header */ post = h->flags & AVIO_FLAG_WRITE; if (s->post_data) { /* force POST method and disable chunked encoding when * custom HTTP post data is set */ post = 1; s->chunked_post = 0; } method = post ? "POST" : "GET"; authstr = ff_http_auth_create_response(&s->auth_state, auth, local_path, method); proxyauthstr = ff_http_auth_create_response(&s->proxy_auth_state, proxyauth, local_path, method); /* set default headers if needed */ if (!has_header(s->headers, "\r\nUser-Agent: ")) len += av_strlcatf(headers + len, sizeof(headers) - len, "User-Agent: %s\r\n", LIBAVFORMAT_IDENT); if (!has_header(s->headers, "\r\nAccept: ")) len += av_strlcpy(headers + len, "Accept: */*\r\n", sizeof(headers) - len); if (!has_header(s->headers, "\r\nRange: ") && !post) len += av_strlcatf(headers + len, sizeof(headers) - len, "Range: bytes=%"PRId64"-\r\n", s->off); if (!has_header(s->headers, "\r\nConnection: ")) { if (s->multiple_requests) { len += av_strlcpy(headers + len, "Connection: keep-alive\r\n", sizeof(headers) - len); } else { len += av_strlcpy(headers + len, "Connection: close\r\n", sizeof(headers) - len); } } if (!has_header(s->headers, "\r\nHost: ")) len += av_strlcatf(headers + len, sizeof(headers) - len, "Host: %s\r\n", hoststr); if (!has_header(s->headers, "\r\nContent-Length: ") && s->post_data) len += av_strlcatf(headers + len, sizeof(headers) - len, "Content-Length: %d\r\n", s->post_datalen); /* now add in custom headers */ if (s->headers) av_strlcpy(headers + len, s->headers, sizeof(headers) - len); snprintf(s->buffer, sizeof(s->buffer), "%s %s HTTP/1.1\r\n" "%s" "%s" "%s" "%s%s" "\r\n", method, path, post && s->chunked_post ? "Transfer-Encoding: chunked\r\n" : "", headers, authstr ? authstr : "", proxyauthstr ? "Proxy-" : "", proxyauthstr ? proxyauthstr : ""); av_freep(&authstr); av_freep(&proxyauthstr); if ((err = ffurl_write(s->hd, s->buffer, strlen(s->buffer))) < 0) return err; if (s->post_data) if ((err = ffurl_write(s->hd, s->post_data, s->post_datalen)) < 0) return err; /* init input buffer */ s->buf_ptr = s->buffer; s->buf_end = s->buffer; s->line_count = 0; s->off = 0; s->filesize = -1; s->willclose = 0; s->end_chunked_post = 0; s->end_header = 0; if (post && !s->post_data) { /* Pretend that it did work. We didn't read any header yet, since * we've still to send the POST data, but the code calling this * function will check http_code after we return. */ s->http_code = 200; return 0; } /* wait for header */ err = http_read_header(h, new_location); if (err < 0) return err; return (off == s->off) ? 0 : -1; }
true
FFmpeg
71549a857b13edf4c4f95037de6ed5bb4c4bd4af
static int http_connect(URLContext *h, const char *path, const char *local_path, const char *hoststr, const char *auth, const char *proxyauth, int *new_location) { HTTPContext *s = h->priv_data; int post, err; char headers[1024] = ""; char *authstr = NULL, *proxyauthstr = NULL; int64_t off = s->off; int len = 0; const char *method; post = h->flags & AVIO_FLAG_WRITE; if (s->post_data) { post = 1; s->chunked_post = 0; } method = post ? "POST" : "GET"; authstr = ff_http_auth_create_response(&s->auth_state, auth, local_path, method); proxyauthstr = ff_http_auth_create_response(&s->proxy_auth_state, proxyauth, local_path, method); if (!has_header(s->headers, "\r\nUser-Agent: ")) len += av_strlcatf(headers + len, sizeof(headers) - len, "User-Agent: %s\r\n", LIBAVFORMAT_IDENT); if (!has_header(s->headers, "\r\nAccept: ")) len += av_strlcpy(headers + len, "Accept: * if (s->headers) av_strlcpy(headers + len, s->headers, sizeof(headers) - len); snprintf(s->buffer, sizeof(s->buffer), "%s %s HTTP/1.1\r\n" "%s" "%s" "%s" "%s%s" "\r\n", method, path, post && s->chunked_post ? "Transfer-Encoding: chunked\r\n" : "", headers, authstr ? authstr : "", proxyauthstr ? "Proxy-" : "", proxyauthstr ? proxyauthstr : ""); av_freep(&authstr); av_freep(&proxyauthstr); if ((err = ffurl_write(s->hd, s->buffer, strlen(s->buffer))) < 0) return err; if (s->post_data) if ((err = ffurl_write(s->hd, s->post_data, s->post_datalen)) < 0) return err; s->buf_ptr = s->buffer; s->buf_end = s->buffer; s->line_count = 0; s->off = 0; s->filesize = -1; s->willclose = 0; s->end_chunked_post = 0; s->end_header = 0; if (post && !s->post_data) { s->http_code = 200; return 0; } err = http_read_header(h, new_location); if (err < 0) return err; return (off == s->off) ? 0 : -1; }
{ "code": [ " if (post && !s->post_data) {" ], "line_no": [ 187 ] }
static int FUNC_0(URLContext *VAR_0, const char *VAR_1, const char *VAR_2, const char *VAR_3, const char *VAR_4, const char *VAR_5, int *VAR_6) { HTTPContext *s = VAR_0->priv_data; int VAR_7, VAR_8; char VAR_9[1024] = ""; char *VAR_10 = NULL, *VAR_11 = NULL; int64_t off = s->off; int VAR_12 = 0; const char *VAR_13; VAR_7 = VAR_0->flags & AVIO_FLAG_WRITE; if (s->post_data) { VAR_7 = 1; s->chunked_post = 0; } VAR_13 = VAR_7 ? "POST" : "GET"; VAR_10 = ff_http_auth_create_response(&s->auth_state, VAR_4, VAR_2, VAR_13); VAR_11 = ff_http_auth_create_response(&s->proxy_auth_state, VAR_5, VAR_2, VAR_13); if (!has_header(s->VAR_9, "\r\nUser-Agent: ")) VAR_12 += av_strlcatf(VAR_9 + VAR_12, sizeof(VAR_9) - VAR_12, "User-Agent: %s\r\n", LIBAVFORMAT_IDENT); if (!has_header(s->VAR_9, "\r\nAccept: ")) VAR_12 += av_strlcpy(VAR_9 + VAR_12, "Accept: * if (s->VAR_9) av_strlcpy(VAR_9 + VAR_12, s->VAR_9, sizeof(VAR_9) - VAR_12); snprintf(s->buffer, sizeof(s->buffer), "%s %s HTTP/1.1\r\n" "%s" "%s" "%s" "%s%s" "\r\n", VAR_13, VAR_1, VAR_7 && s->chunked_post ? "Transfer-Encoding: chunked\r\n" : "", VAR_9, VAR_10 ? VAR_10 : "", VAR_11 ? "Proxy-" : "", VAR_11 ? VAR_11 : ""); av_freep(&VAR_10); av_freep(&VAR_11); if ((VAR_8 = ffurl_write(s->hd, s->buffer, strlen(s->buffer))) < 0) return VAR_8; if (s->post_data) if ((VAR_8 = ffurl_write(s->hd, s->post_data, s->post_datalen)) < 0) return VAR_8; s->buf_ptr = s->buffer; s->buf_end = s->buffer; s->line_count = 0; s->off = 0; s->filesize = -1; s->willclose = 0; s->end_chunked_post = 0; s->end_header = 0; if (VAR_7 && !s->post_data) { s->http_code = 200; return 0; } VAR_8 = http_read_header(VAR_0, VAR_6); if (VAR_8 < 0) return VAR_8; return (off == s->off) ? 0 : -1; }
[ "static int FUNC_0(URLContext *VAR_0, const char *VAR_1, const char *VAR_2,\nconst char *VAR_3, const char *VAR_4,\nconst char *VAR_5, int *VAR_6)\n{", "HTTPContext *s = VAR_0->priv_data;", "int VAR_7, VAR_8;", "char VAR_9[1024] = \"\";", "char *VAR_10 = NULL, *VAR_11 = NULL;", "int64_t off = s->off;", "int VAR_12 = 0;", "const char *VAR_13;", "VAR_7 = VAR_0->flags & AVIO_FLAG_WRITE;", "if (s->post_data) {", "VAR_7 = 1;", "s->chunked_post = 0;", "}", "VAR_13 = VAR_7 ? \"POST\" : \"GET\";", "VAR_10 = ff_http_auth_create_response(&s->auth_state, VAR_4, VAR_2,\nVAR_13);", "VAR_11 = ff_http_auth_create_response(&s->proxy_auth_state, VAR_5,\nVAR_2, VAR_13);", "if (!has_header(s->VAR_9, \"\\r\\nUser-Agent: \"))\nVAR_12 += av_strlcatf(VAR_9 + VAR_12, sizeof(VAR_9) - VAR_12,\n\"User-Agent: %s\\r\\n\", LIBAVFORMAT_IDENT);", "if (!has_header(s->VAR_9, \"\\r\\nAccept: \"))\nVAR_12 += av_strlcpy(VAR_9 + VAR_12, \"Accept: *\nif (s->VAR_9)\nav_strlcpy(VAR_9 + VAR_12, s->VAR_9, sizeof(VAR_9) - VAR_12);", "snprintf(s->buffer, sizeof(s->buffer),\n\"%s %s HTTP/1.1\\r\\n\"\n\"%s\"\n\"%s\"\n\"%s\"\n\"%s%s\"\n\"\\r\\n\",\nVAR_13,\nVAR_1,\nVAR_7 && s->chunked_post ? \"Transfer-Encoding: chunked\\r\\n\" : \"\",\nVAR_9,\nVAR_10 ? VAR_10 : \"\",\nVAR_11 ? \"Proxy-\" : \"\", VAR_11 ? VAR_11 : \"\");", "av_freep(&VAR_10);", "av_freep(&VAR_11);", "if ((VAR_8 = ffurl_write(s->hd, s->buffer, strlen(s->buffer))) < 0)\nreturn VAR_8;", "if (s->post_data)\nif ((VAR_8 = ffurl_write(s->hd, s->post_data, s->post_datalen)) < 0)\nreturn VAR_8;", "s->buf_ptr = s->buffer;", "s->buf_end = s->buffer;", "s->line_count = 0;", "s->off = 0;", "s->filesize = -1;", "s->willclose = 0;", "s->end_chunked_post = 0;", "s->end_header = 0;", "if (VAR_7 && !s->post_data) {", "s->http_code = 200;", "return 0;", "}", "VAR_8 = http_read_header(VAR_0, VAR_6);", "if (VAR_8 < 0)\nreturn VAR_8;", "return (off == s->off) ? 0 : -1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 29 ], [ 33 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49, 51 ], [ 53, 55 ], [ 61, 63, 65 ], [ 67, 69, 117, 119 ], [ 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147 ], [ 151 ], [ 153 ], [ 155, 157 ], [ 161, 163, 165 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 195 ], [ 197 ], [ 199 ], [ 205 ], [ 207, 209 ], [ 213 ], [ 215 ] ]
6,159
static void virtio_serial_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); dc->exit = virtio_serial_device_exit; dc->props = virtio_serial_properties; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); vdc->init = virtio_serial_device_init; vdc->get_features = get_features; vdc->get_config = get_config; vdc->set_config = set_config; vdc->set_status = set_status; vdc->reset = vser_reset; }
true
qemu
0e86c13fe2058adb8c792ebb7c51a6a7ca9d3d55
static void virtio_serial_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); dc->exit = virtio_serial_device_exit; dc->props = virtio_serial_properties; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); vdc->init = virtio_serial_device_init; vdc->get_features = get_features; vdc->get_config = get_config; vdc->set_config = set_config; vdc->set_status = set_status; vdc->reset = vser_reset; }
{ "code": [ " dc->exit = virtio_serial_device_exit;" ], "line_no": [ 9 ] }
static void FUNC_0(ObjectClass *VAR_0, void *VAR_1) { DeviceClass *dc = DEVICE_CLASS(VAR_0); VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(VAR_0); dc->exit = virtio_serial_device_exit; dc->props = virtio_serial_properties; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); vdc->init = virtio_serial_device_init; vdc->get_features = get_features; vdc->get_config = get_config; vdc->set_config = set_config; vdc->set_status = set_status; vdc->reset = vser_reset; }
[ "static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{", "DeviceClass *dc = DEVICE_CLASS(VAR_0);", "VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(VAR_0);", "dc->exit = virtio_serial_device_exit;", "dc->props = virtio_serial_properties;", "set_bit(DEVICE_CATEGORY_INPUT, dc->categories);", "vdc->init = virtio_serial_device_init;", "vdc->get_features = get_features;", "vdc->get_config = get_config;", "vdc->set_config = set_config;", "vdc->set_status = set_status;", "vdc->reset = vser_reset;", "}" ]
[ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ] ]
6,161
static uint64_t get_channel_layout_single(const char *name, int name_len) { int i; char *end; int64_t layout; for (i = 0; i < FF_ARRAY_ELEMS(channel_layout_map); i++) { if (strlen(channel_layout_map[i].name) == name_len && !memcmp(channel_layout_map[i].name, name, name_len)) return channel_layout_map[i].layout; } for (i = 0; i < FF_ARRAY_ELEMS(channel_names); i++) if (channel_names[i].name && strlen(channel_names[i].name) == name_len && !memcmp(channel_names[i].name, name, name_len)) return (int64_t)1 << i; i = strtol(name, &end, 10); if ((end + 1 - name == name_len && *end == 'c')) return av_get_default_channel_layout(i); layout = strtoll(name, &end, 0); if (end - name == name_len) return FFMAX(layout, 0); return 0; }
true
FFmpeg
c9bfd6a8c35a2102e730aca12f6e09d1627f76b3
static uint64_t get_channel_layout_single(const char *name, int name_len) { int i; char *end; int64_t layout; for (i = 0; i < FF_ARRAY_ELEMS(channel_layout_map); i++) { if (strlen(channel_layout_map[i].name) == name_len && !memcmp(channel_layout_map[i].name, name, name_len)) return channel_layout_map[i].layout; } for (i = 0; i < FF_ARRAY_ELEMS(channel_names); i++) if (channel_names[i].name && strlen(channel_names[i].name) == name_len && !memcmp(channel_names[i].name, name, name_len)) return (int64_t)1 << i; i = strtol(name, &end, 10); if ((end + 1 - name == name_len && *end == 'c')) return av_get_default_channel_layout(i); layout = strtoll(name, &end, 0); if (end - name == name_len) return FFMAX(layout, 0); return 0; }
{ "code": [ " if ((end + 1 - name == name_len && *end == 'c'))", " if (end - name == name_len)" ], "line_no": [ 37, 45 ] }
static uint64_t FUNC_0(const char *name, int name_len) { int VAR_0; char *VAR_1; int64_t layout; for (VAR_0 = 0; VAR_0 < FF_ARRAY_ELEMS(channel_layout_map); VAR_0++) { if (strlen(channel_layout_map[VAR_0].name) == name_len && !memcmp(channel_layout_map[VAR_0].name, name, name_len)) return channel_layout_map[VAR_0].layout; } for (VAR_0 = 0; VAR_0 < FF_ARRAY_ELEMS(channel_names); VAR_0++) if (channel_names[VAR_0].name && strlen(channel_names[VAR_0].name) == name_len && !memcmp(channel_names[VAR_0].name, name, name_len)) return (int64_t)1 << VAR_0; VAR_0 = strtol(name, &VAR_1, 10); if ((VAR_1 + 1 - name == name_len && *VAR_1 == 'c')) return av_get_default_channel_layout(VAR_0); layout = strtoll(name, &VAR_1, 0); if (VAR_1 - name == name_len) return FFMAX(layout, 0); return 0; }
[ "static uint64_t FUNC_0(const char *name, int name_len)\n{", "int VAR_0;", "char *VAR_1;", "int64_t layout;", "for (VAR_0 = 0; VAR_0 < FF_ARRAY_ELEMS(channel_layout_map); VAR_0++) {", "if (strlen(channel_layout_map[VAR_0].name) == name_len &&\n!memcmp(channel_layout_map[VAR_0].name, name, name_len))\nreturn channel_layout_map[VAR_0].layout;", "}", "for (VAR_0 = 0; VAR_0 < FF_ARRAY_ELEMS(channel_names); VAR_0++)", "if (channel_names[VAR_0].name &&\nstrlen(channel_names[VAR_0].name) == name_len &&\n!memcmp(channel_names[VAR_0].name, name, name_len))\nreturn (int64_t)1 << VAR_0;", "VAR_0 = strtol(name, &VAR_1, 10);", "if ((VAR_1 + 1 - name == name_len && *VAR_1 == 'c'))\nreturn av_get_default_channel_layout(VAR_0);", "layout = strtoll(name, &VAR_1, 0);", "if (VAR_1 - name == name_len)\nreturn FFMAX(layout, 0);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15, 17, 19 ], [ 21 ], [ 23 ], [ 25, 27, 29, 31 ], [ 33 ], [ 37, 39 ], [ 43 ], [ 45, 47 ], [ 49 ], [ 51 ] ]
6,162
static void get_offset_range(hwaddr phys_addr, ram_addr_t mapping_length, DumpState *s, hwaddr *p_offset, hwaddr *p_filesz) { RAMBlock *block; hwaddr offset = s->memory_offset; int64_t size_in_block, start; /* When the memory is not stored into vmcore, offset will be -1 */ *p_offset = -1; *p_filesz = 0; if (s->has_filter) { if (phys_addr < s->begin || phys_addr >= s->begin + s->length) { return; } } QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (s->has_filter) { if (block->offset >= s->begin + s->length || block->offset + block->length <= s->begin) { /* This block is out of the range */ continue; } if (s->begin <= block->offset) { start = block->offset; } else { start = s->begin; } size_in_block = block->length - (start - block->offset); if (s->begin + s->length < block->offset + block->length) { size_in_block -= block->offset + block->length - (s->begin + s->length); } } else { start = block->offset; size_in_block = block->length; } if (phys_addr >= start && phys_addr < start + size_in_block) { *p_offset = phys_addr - start + offset; /* The offset range mapped from the vmcore file must not spill over * the RAMBlock, clamp it. The rest of the mapping will be * zero-filled in memory at load time; see * <http://refspecs.linuxbase.org/elf/gabi4+/ch5.pheader.html>. */ *p_filesz = phys_addr + mapping_length <= start + size_in_block ? mapping_length : size_in_block - (phys_addr - start); return; } offset += size_in_block; } }
true
qemu
56c4bfb3f07f3107894c00281276aea4f5e8834d
static void get_offset_range(hwaddr phys_addr, ram_addr_t mapping_length, DumpState *s, hwaddr *p_offset, hwaddr *p_filesz) { RAMBlock *block; hwaddr offset = s->memory_offset; int64_t size_in_block, start; *p_offset = -1; *p_filesz = 0; if (s->has_filter) { if (phys_addr < s->begin || phys_addr >= s->begin + s->length) { return; } } QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (s->has_filter) { if (block->offset >= s->begin + s->length || block->offset + block->length <= s->begin) { continue; } if (s->begin <= block->offset) { start = block->offset; } else { start = s->begin; } size_in_block = block->length - (start - block->offset); if (s->begin + s->length < block->offset + block->length) { size_in_block -= block->offset + block->length - (s->begin + s->length); } } else { start = block->offset; size_in_block = block->length; } if (phys_addr >= start && phys_addr < start + size_in_block) { *p_offset = phys_addr - start + offset; *p_filesz = phys_addr + mapping_length <= start + size_in_block ? mapping_length : size_in_block - (phys_addr - start); return; } offset += size_in_block; } }
{ "code": [ " RAMBlock *block;", " RAMBlock *block;", " QTAILQ_FOREACH(block, &ram_list.blocks, next) {", " if (block->offset >= s->begin + s->length ||", " block->offset + block->length <= s->begin) {", " if (s->begin <= block->offset) {", " start = block->offset;", " size_in_block = block->length - (start - block->offset);", " if (s->begin + s->length < block->offset + block->length) {", " size_in_block -= block->offset + block->length -", " (s->begin + s->length);", " start = block->offset;", " size_in_block = block->length;", " if (block->offset >= s->begin + s->length ||", " block->offset + block->length <= s->begin) {", " RAMBlock *block;", " if (s->begin + s->length < block->offset + block->length) {", " RAMBlock *block;", " QTAILQ_FOREACH(block, &ram_list.blocks, next) {", " RAMBlock *block;", " QTAILQ_FOREACH(block, &ram_list.blocks, next) {", " RAMBlock *block;", " QTAILQ_FOREACH(block, &ram_list.blocks, next) {", " RAMBlock *block;" ], "line_no": [ 13, 13, 41, 45, 47, 57, 59, 69, 71, 73, 75, 81, 83, 45, 47, 13, 71, 13, 41, 13, 41, 13, 41, 13 ] }
static void FUNC_0(hwaddr VAR_0, ram_addr_t VAR_1, DumpState *VAR_2, hwaddr *VAR_3, hwaddr *VAR_4) { RAMBlock *block; hwaddr offset = VAR_2->memory_offset; int64_t size_in_block, start; *VAR_3 = -1; *VAR_4 = 0; if (VAR_2->has_filter) { if (VAR_0 < VAR_2->begin || VAR_0 >= VAR_2->begin + VAR_2->length) { return; } } QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (VAR_2->has_filter) { if (block->offset >= VAR_2->begin + VAR_2->length || block->offset + block->length <= VAR_2->begin) { continue; } if (VAR_2->begin <= block->offset) { start = block->offset; } else { start = VAR_2->begin; } size_in_block = block->length - (start - block->offset); if (VAR_2->begin + VAR_2->length < block->offset + block->length) { size_in_block -= block->offset + block->length - (VAR_2->begin + VAR_2->length); } } else { start = block->offset; size_in_block = block->length; } if (VAR_0 >= start && VAR_0 < start + size_in_block) { *VAR_3 = VAR_0 - start + offset; *VAR_4 = VAR_0 + VAR_1 <= start + size_in_block ? VAR_1 : size_in_block - (VAR_0 - start); return; } offset += size_in_block; } }
[ "static void FUNC_0(hwaddr VAR_0,\nram_addr_t VAR_1,\nDumpState *VAR_2,\nhwaddr *VAR_3,\nhwaddr *VAR_4)\n{", "RAMBlock *block;", "hwaddr offset = VAR_2->memory_offset;", "int64_t size_in_block, start;", "*VAR_3 = -1;", "*VAR_4 = 0;", "if (VAR_2->has_filter) {", "if (VAR_0 < VAR_2->begin || VAR_0 >= VAR_2->begin + VAR_2->length) {", "return;", "}", "}", "QTAILQ_FOREACH(block, &ram_list.blocks, next) {", "if (VAR_2->has_filter) {", "if (block->offset >= VAR_2->begin + VAR_2->length ||\nblock->offset + block->length <= VAR_2->begin) {", "continue;", "}", "if (VAR_2->begin <= block->offset) {", "start = block->offset;", "} else {", "start = VAR_2->begin;", "}", "size_in_block = block->length - (start - block->offset);", "if (VAR_2->begin + VAR_2->length < block->offset + block->length) {", "size_in_block -= block->offset + block->length -\n(VAR_2->begin + VAR_2->length);", "}", "} else {", "start = block->offset;", "size_in_block = block->length;", "}", "if (VAR_0 >= start && VAR_0 < start + size_in_block) {", "*VAR_3 = VAR_0 - start + offset;", "*VAR_4 = VAR_0 + VAR_1 <= start + size_in_block ?\nVAR_1 :\nsize_in_block - (VAR_0 - start);", "return;", "}", "offset += size_in_block;", "}", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11 ], [ 13 ], [ 15 ], [ 17 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45, 47 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71 ], [ 73, 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 89 ], [ 91 ], [ 105, 107, 109 ], [ 111 ], [ 113 ], [ 117 ], [ 119 ], [ 121 ] ]
6,163
static int qcow2_update_options(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVQcow2State *s = bs->opaque; QemuOpts *opts = NULL; const char *opt_overlap_check, *opt_overlap_check_template; int overlap_check_template = 0; uint64_t l2_cache_size, refcount_cache_size; Qcow2Cache *l2_table_cache; Qcow2Cache *refcount_block_cache; uint64_t cache_clean_interval; bool use_lazy_refcounts; int i; Error *local_err = NULL; int ret; opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto fail; } /* get L2 table/refcount block cache size from command line options */ read_cache_sizes(bs, opts, &l2_cache_size, &refcount_cache_size, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto fail; } l2_cache_size /= s->cluster_size; if (l2_cache_size < MIN_L2_CACHE_SIZE) { l2_cache_size = MIN_L2_CACHE_SIZE; } if (l2_cache_size > INT_MAX) { error_setg(errp, "L2 cache size too big"); ret = -EINVAL; goto fail; } refcount_cache_size /= s->cluster_size; if (refcount_cache_size < MIN_REFCOUNT_CACHE_SIZE) { refcount_cache_size = MIN_REFCOUNT_CACHE_SIZE; } if (refcount_cache_size > INT_MAX) { error_setg(errp, "Refcount cache size too big"); ret = -EINVAL; goto fail; } /* alloc L2 table/refcount block cache */ l2_table_cache = qcow2_cache_create(bs, l2_cache_size); refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); if (l2_table_cache == NULL || refcount_block_cache == NULL) { error_setg(errp, "Could not allocate metadata caches"); ret = -ENOMEM; goto fail; } /* New interval for cache cleanup timer */ cache_clean_interval = qemu_opt_get_number(opts, QCOW2_OPT_CACHE_CLEAN_INTERVAL, 0); if (cache_clean_interval > UINT_MAX) { error_setg(errp, "Cache clean interval too big"); ret = -EINVAL; goto fail; } /* Enable lazy_refcounts according to image and command line options */ use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); if (use_lazy_refcounts && s->qcow_version < 3) { error_setg(errp, "Lazy refcounts require a qcow2 image with at least " "qemu 1.1 compatibility level"); ret = -EINVAL; goto fail; } /* Overlap check options */ opt_overlap_check = qemu_opt_get(opts, QCOW2_OPT_OVERLAP); opt_overlap_check_template = qemu_opt_get(opts, QCOW2_OPT_OVERLAP_TEMPLATE); if (opt_overlap_check_template && opt_overlap_check && strcmp(opt_overlap_check_template, opt_overlap_check)) { error_setg(errp, "Conflicting values for qcow2 options '" QCOW2_OPT_OVERLAP "' ('%s') and '" QCOW2_OPT_OVERLAP_TEMPLATE "' ('%s')", opt_overlap_check, opt_overlap_check_template); ret = -EINVAL; goto fail; } if (!opt_overlap_check) { opt_overlap_check = opt_overlap_check_template ?: "cached"; } if (!strcmp(opt_overlap_check, "none")) { overlap_check_template = 0; } else if (!strcmp(opt_overlap_check, "constant")) { overlap_check_template = QCOW2_OL_CONSTANT; } else if (!strcmp(opt_overlap_check, "cached")) { overlap_check_template = QCOW2_OL_CACHED; } else if (!strcmp(opt_overlap_check, "all")) { overlap_check_template = QCOW2_OL_ALL; } else { error_setg(errp, "Unsupported value '%s' for qcow2 option " "'overlap-check'. Allowed are any of the following: " "none, constant, cached, all", opt_overlap_check); ret = -EINVAL; goto fail; } /* * Start updating fields in BDRVQcow2State. * After this point no failure is allowed any more. */ s->overlap_check = 0; for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) { /* overlap-check defines a template bitmask, but every flag may be * overwritten through the associated boolean option */ s->overlap_check |= qemu_opt_get_bool(opts, overlap_bool_option_names[i], overlap_check_template & (1 << i)) << i; } s->l2_table_cache = l2_table_cache; s->refcount_block_cache = refcount_block_cache; s->use_lazy_refcounts = use_lazy_refcounts; s->discard_passthrough[QCOW2_DISCARD_NEVER] = false; s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; s->discard_passthrough[QCOW2_DISCARD_REQUEST] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST, flags & BDRV_O_UNMAP); s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true); s->discard_passthrough[QCOW2_DISCARD_OTHER] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); s->cache_clean_interval = cache_clean_interval; cache_clean_timer_init(bs, bdrv_get_aio_context(bs)); ret = 0; fail: qemu_opts_del(opts); opts = NULL; return ret; }
true
qemu
c1344ded70cf7d471aeb6fc08134997414631811
static int qcow2_update_options(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVQcow2State *s = bs->opaque; QemuOpts *opts = NULL; const char *opt_overlap_check, *opt_overlap_check_template; int overlap_check_template = 0; uint64_t l2_cache_size, refcount_cache_size; Qcow2Cache *l2_table_cache; Qcow2Cache *refcount_block_cache; uint64_t cache_clean_interval; bool use_lazy_refcounts; int i; Error *local_err = NULL; int ret; opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto fail; } read_cache_sizes(bs, opts, &l2_cache_size, &refcount_cache_size, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto fail; } l2_cache_size /= s->cluster_size; if (l2_cache_size < MIN_L2_CACHE_SIZE) { l2_cache_size = MIN_L2_CACHE_SIZE; } if (l2_cache_size > INT_MAX) { error_setg(errp, "L2 cache size too big"); ret = -EINVAL; goto fail; } refcount_cache_size /= s->cluster_size; if (refcount_cache_size < MIN_REFCOUNT_CACHE_SIZE) { refcount_cache_size = MIN_REFCOUNT_CACHE_SIZE; } if (refcount_cache_size > INT_MAX) { error_setg(errp, "Refcount cache size too big"); ret = -EINVAL; goto fail; } l2_table_cache = qcow2_cache_create(bs, l2_cache_size); refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); if (l2_table_cache == NULL || refcount_block_cache == NULL) { error_setg(errp, "Could not allocate metadata caches"); ret = -ENOMEM; goto fail; } cache_clean_interval = qemu_opt_get_number(opts, QCOW2_OPT_CACHE_CLEAN_INTERVAL, 0); if (cache_clean_interval > UINT_MAX) { error_setg(errp, "Cache clean interval too big"); ret = -EINVAL; goto fail; } use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); if (use_lazy_refcounts && s->qcow_version < 3) { error_setg(errp, "Lazy refcounts require a qcow2 image with at least " "qemu 1.1 compatibility level"); ret = -EINVAL; goto fail; } opt_overlap_check = qemu_opt_get(opts, QCOW2_OPT_OVERLAP); opt_overlap_check_template = qemu_opt_get(opts, QCOW2_OPT_OVERLAP_TEMPLATE); if (opt_overlap_check_template && opt_overlap_check && strcmp(opt_overlap_check_template, opt_overlap_check)) { error_setg(errp, "Conflicting values for qcow2 options '" QCOW2_OPT_OVERLAP "' ('%s') and '" QCOW2_OPT_OVERLAP_TEMPLATE "' ('%s')", opt_overlap_check, opt_overlap_check_template); ret = -EINVAL; goto fail; } if (!opt_overlap_check) { opt_overlap_check = opt_overlap_check_template ?: "cached"; } if (!strcmp(opt_overlap_check, "none")) { overlap_check_template = 0; } else if (!strcmp(opt_overlap_check, "constant")) { overlap_check_template = QCOW2_OL_CONSTANT; } else if (!strcmp(opt_overlap_check, "cached")) { overlap_check_template = QCOW2_OL_CACHED; } else if (!strcmp(opt_overlap_check, "all")) { overlap_check_template = QCOW2_OL_ALL; } else { error_setg(errp, "Unsupported value '%s' for qcow2 option " "'overlap-check'. Allowed are any of the following: " "none, constant, cached, all", opt_overlap_check); ret = -EINVAL; goto fail; } s->overlap_check = 0; for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) { s->overlap_check |= qemu_opt_get_bool(opts, overlap_bool_option_names[i], overlap_check_template & (1 << i)) << i; } s->l2_table_cache = l2_table_cache; s->refcount_block_cache = refcount_block_cache; s->use_lazy_refcounts = use_lazy_refcounts; s->discard_passthrough[QCOW2_DISCARD_NEVER] = false; s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; s->discard_passthrough[QCOW2_DISCARD_REQUEST] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST, flags & BDRV_O_UNMAP); s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true); s->discard_passthrough[QCOW2_DISCARD_OTHER] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); s->cache_clean_interval = cache_clean_interval; cache_clean_timer_init(bs, bdrv_get_aio_context(bs)); ret = 0; fail: qemu_opts_del(opts); opts = NULL; return ret; }
{ "code": [ " Qcow2Cache *l2_table_cache;", " Qcow2Cache *refcount_block_cache;" ], "line_no": [ 17, 19 ] }
static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2, Error **VAR_3) { BDRVQcow2State *s = VAR_0->opaque; QemuOpts *opts = NULL; const char *VAR_4, *VAR_5; int VAR_6 = 0; uint64_t l2_cache_size, refcount_cache_size; Qcow2Cache *l2_table_cache; Qcow2Cache *refcount_block_cache; uint64_t cache_clean_interval; bool use_lazy_refcounts; int VAR_7; Error *local_err = NULL; int VAR_8; opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, VAR_1, &local_err); if (local_err) { error_propagate(VAR_3, local_err); VAR_8 = -EINVAL; goto fail; } read_cache_sizes(VAR_0, opts, &l2_cache_size, &refcount_cache_size, &local_err); if (local_err) { error_propagate(VAR_3, local_err); VAR_8 = -EINVAL; goto fail; } l2_cache_size /= s->cluster_size; if (l2_cache_size < MIN_L2_CACHE_SIZE) { l2_cache_size = MIN_L2_CACHE_SIZE; } if (l2_cache_size > INT_MAX) { error_setg(VAR_3, "L2 cache size too big"); VAR_8 = -EINVAL; goto fail; } refcount_cache_size /= s->cluster_size; if (refcount_cache_size < MIN_REFCOUNT_CACHE_SIZE) { refcount_cache_size = MIN_REFCOUNT_CACHE_SIZE; } if (refcount_cache_size > INT_MAX) { error_setg(VAR_3, "Refcount cache size too big"); VAR_8 = -EINVAL; goto fail; } l2_table_cache = qcow2_cache_create(VAR_0, l2_cache_size); refcount_block_cache = qcow2_cache_create(VAR_0, refcount_cache_size); if (l2_table_cache == NULL || refcount_block_cache == NULL) { error_setg(VAR_3, "Could not allocate metadata caches"); VAR_8 = -ENOMEM; goto fail; } cache_clean_interval = qemu_opt_get_number(opts, QCOW2_OPT_CACHE_CLEAN_INTERVAL, 0); if (cache_clean_interval > UINT_MAX) { error_setg(VAR_3, "Cache clean interval too big"); VAR_8 = -EINVAL; goto fail; } use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); if (use_lazy_refcounts && s->qcow_version < 3) { error_setg(VAR_3, "Lazy refcounts require a qcow2 image with at least " "qemu 1.1 compatibility level"); VAR_8 = -EINVAL; goto fail; } VAR_4 = qemu_opt_get(opts, QCOW2_OPT_OVERLAP); VAR_5 = qemu_opt_get(opts, QCOW2_OPT_OVERLAP_TEMPLATE); if (VAR_5 && VAR_4 && strcmp(VAR_5, VAR_4)) { error_setg(VAR_3, "Conflicting values for qcow2 VAR_1 '" QCOW2_OPT_OVERLAP "' ('%s') and '" QCOW2_OPT_OVERLAP_TEMPLATE "' ('%s')", VAR_4, VAR_5); VAR_8 = -EINVAL; goto fail; } if (!VAR_4) { VAR_4 = VAR_5 ?: "cached"; } if (!strcmp(VAR_4, "none")) { VAR_6 = 0; } else if (!strcmp(VAR_4, "constant")) { VAR_6 = QCOW2_OL_CONSTANT; } else if (!strcmp(VAR_4, "cached")) { VAR_6 = QCOW2_OL_CACHED; } else if (!strcmp(VAR_4, "all")) { VAR_6 = QCOW2_OL_ALL; } else { error_setg(VAR_3, "Unsupported value '%s' for qcow2 option " "'overlap-check'. Allowed are any of the following: " "none, constant, cached, all", VAR_4); VAR_8 = -EINVAL; goto fail; } s->overlap_check = 0; for (VAR_7 = 0; VAR_7 < QCOW2_OL_MAX_BITNR; VAR_7++) { s->overlap_check |= qemu_opt_get_bool(opts, overlap_bool_option_names[VAR_7], VAR_6 & (1 << VAR_7)) << VAR_7; } s->l2_table_cache = l2_table_cache; s->refcount_block_cache = refcount_block_cache; s->use_lazy_refcounts = use_lazy_refcounts; s->discard_passthrough[QCOW2_DISCARD_NEVER] = false; s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; s->discard_passthrough[QCOW2_DISCARD_REQUEST] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST, VAR_2 & BDRV_O_UNMAP); s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true); s->discard_passthrough[QCOW2_DISCARD_OTHER] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); s->cache_clean_interval = cache_clean_interval; cache_clean_timer_init(VAR_0, bdrv_get_aio_context(VAR_0)); VAR_8 = 0; fail: qemu_opts_del(opts); opts = NULL; return VAR_8; }
[ "static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1,\nint VAR_2, Error **VAR_3)\n{", "BDRVQcow2State *s = VAR_0->opaque;", "QemuOpts *opts = NULL;", "const char *VAR_4, *VAR_5;", "int VAR_6 = 0;", "uint64_t l2_cache_size, refcount_cache_size;", "Qcow2Cache *l2_table_cache;", "Qcow2Cache *refcount_block_cache;", "uint64_t cache_clean_interval;", "bool use_lazy_refcounts;", "int VAR_7;", "Error *local_err = NULL;", "int VAR_8;", "opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort);", "qemu_opts_absorb_qdict(opts, VAR_1, &local_err);", "if (local_err) {", "error_propagate(VAR_3, local_err);", "VAR_8 = -EINVAL;", "goto fail;", "}", "read_cache_sizes(VAR_0, opts, &l2_cache_size, &refcount_cache_size,\n&local_err);", "if (local_err) {", "error_propagate(VAR_3, local_err);", "VAR_8 = -EINVAL;", "goto fail;", "}", "l2_cache_size /= s->cluster_size;", "if (l2_cache_size < MIN_L2_CACHE_SIZE) {", "l2_cache_size = MIN_L2_CACHE_SIZE;", "}", "if (l2_cache_size > INT_MAX) {", "error_setg(VAR_3, \"L2 cache size too big\");", "VAR_8 = -EINVAL;", "goto fail;", "}", "refcount_cache_size /= s->cluster_size;", "if (refcount_cache_size < MIN_REFCOUNT_CACHE_SIZE) {", "refcount_cache_size = MIN_REFCOUNT_CACHE_SIZE;", "}", "if (refcount_cache_size > INT_MAX) {", "error_setg(VAR_3, \"Refcount cache size too big\");", "VAR_8 = -EINVAL;", "goto fail;", "}", "l2_table_cache = qcow2_cache_create(VAR_0, l2_cache_size);", "refcount_block_cache = qcow2_cache_create(VAR_0, refcount_cache_size);", "if (l2_table_cache == NULL || refcount_block_cache == NULL) {", "error_setg(VAR_3, \"Could not allocate metadata caches\");", "VAR_8 = -ENOMEM;", "goto fail;", "}", "cache_clean_interval =\nqemu_opt_get_number(opts, QCOW2_OPT_CACHE_CLEAN_INTERVAL, 0);", "if (cache_clean_interval > UINT_MAX) {", "error_setg(VAR_3, \"Cache clean interval too big\");", "VAR_8 = -EINVAL;", "goto fail;", "}", "use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS,\n(s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS));", "if (use_lazy_refcounts && s->qcow_version < 3) {", "error_setg(VAR_3, \"Lazy refcounts require a qcow2 image with at least \"\n\"qemu 1.1 compatibility level\");", "VAR_8 = -EINVAL;", "goto fail;", "}", "VAR_4 = qemu_opt_get(opts, QCOW2_OPT_OVERLAP);", "VAR_5 = qemu_opt_get(opts, QCOW2_OPT_OVERLAP_TEMPLATE);", "if (VAR_5 && VAR_4 &&\nstrcmp(VAR_5, VAR_4))\n{", "error_setg(VAR_3, \"Conflicting values for qcow2 VAR_1 '\"\nQCOW2_OPT_OVERLAP \"' ('%s') and '\" QCOW2_OPT_OVERLAP_TEMPLATE\n\"' ('%s')\", VAR_4, VAR_5);", "VAR_8 = -EINVAL;", "goto fail;", "}", "if (!VAR_4) {", "VAR_4 = VAR_5 ?: \"cached\";", "}", "if (!strcmp(VAR_4, \"none\")) {", "VAR_6 = 0;", "} else if (!strcmp(VAR_4, \"constant\")) {", "VAR_6 = QCOW2_OL_CONSTANT;", "} else if (!strcmp(VAR_4, \"cached\")) {", "VAR_6 = QCOW2_OL_CACHED;", "} else if (!strcmp(VAR_4, \"all\")) {", "VAR_6 = QCOW2_OL_ALL;", "} else {", "error_setg(VAR_3, \"Unsupported value '%s' for qcow2 option \"\n\"'overlap-check'. Allowed are any of the following: \"\n\"none, constant, cached, all\", VAR_4);", "VAR_8 = -EINVAL;", "goto fail;", "}", "s->overlap_check = 0;", "for (VAR_7 = 0; VAR_7 < QCOW2_OL_MAX_BITNR; VAR_7++) {", "s->overlap_check |=\nqemu_opt_get_bool(opts, overlap_bool_option_names[VAR_7],\nVAR_6 & (1 << VAR_7)) << VAR_7;", "}", "s->l2_table_cache = l2_table_cache;", "s->refcount_block_cache = refcount_block_cache;", "s->use_lazy_refcounts = use_lazy_refcounts;", "s->discard_passthrough[QCOW2_DISCARD_NEVER] = false;", "s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true;", "s->discard_passthrough[QCOW2_DISCARD_REQUEST] =\nqemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST,\nVAR_2 & BDRV_O_UNMAP);", "s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] =\nqemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true);", "s->discard_passthrough[QCOW2_DISCARD_OTHER] =\nqemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false);", "s->cache_clean_interval = cache_clean_interval;", "cache_clean_timer_init(VAR_0, bdrv_get_aio_context(VAR_0));", "VAR_8 = 0;", "fail:\nqemu_opts_del(opts);", "opts = NULL;", "return VAR_8;", "}" ]
[ 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 51, 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 127, 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 145, 147 ], [ 149 ], [ 151, 153 ], [ 155 ], [ 157 ], [ 159 ], [ 165 ], [ 167 ], [ 169, 171, 173 ], [ 175, 177, 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213, 215, 217 ], [ 219 ], [ 221 ], [ 223 ], [ 235 ], [ 237 ], [ 243, 245, 247 ], [ 249 ], [ 253 ], [ 255 ], [ 259 ], [ 263 ], [ 265 ], [ 267, 269, 271 ], [ 273, 275 ], [ 277, 279 ], [ 283 ], [ 285 ], [ 289 ], [ 291, 293 ], [ 295 ], [ 299 ], [ 301 ] ]
6,164
vu_message_read(VuDev *dev, int conn_fd, VhostUserMsg *vmsg) { char control[CMSG_SPACE(VHOST_MEMORY_MAX_NREGIONS * sizeof(int))] = { }; struct iovec iov = { .iov_base = (char *)vmsg, .iov_len = VHOST_USER_HDR_SIZE, }; struct msghdr msg = { .msg_iov = &iov, .msg_iovlen = 1, .msg_control = control, .msg_controllen = sizeof(control), }; size_t fd_size; struct cmsghdr *cmsg; int rc; do { rc = recvmsg(conn_fd, &msg, 0); } while (rc < 0 && (errno == EINTR || errno == EAGAIN)); if (rc <= 0) { vu_panic(dev, "Error while recvmsg: %s", strerror(errno)); return false; } vmsg->fd_num = 0; for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) { if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) { fd_size = cmsg->cmsg_len - CMSG_LEN(0); vmsg->fd_num = fd_size / sizeof(int); memcpy(vmsg->fds, CMSG_DATA(cmsg), fd_size); break; } } if (vmsg->size > sizeof(vmsg->payload)) { vu_panic(dev, "Error: too big message request: %d, size: vmsg->size: %u, " "while sizeof(vmsg->payload) = %zu\n", vmsg->request, vmsg->size, sizeof(vmsg->payload)); goto fail; } if (vmsg->size) { do { rc = read(conn_fd, &vmsg->payload, vmsg->size); } while (rc < 0 && (errno == EINTR || errno == EAGAIN)); if (rc <= 0) { vu_panic(dev, "Error while reading: %s", strerror(errno)); goto fail; } assert(rc == vmsg->size); } return true; fail: vmsg_close_fds(vmsg); return false; }
true
qemu
2566378d6d13bf4d28c7770bdbda5f7682594bbe
vu_message_read(VuDev *dev, int conn_fd, VhostUserMsg *vmsg) { char control[CMSG_SPACE(VHOST_MEMORY_MAX_NREGIONS * sizeof(int))] = { }; struct iovec iov = { .iov_base = (char *)vmsg, .iov_len = VHOST_USER_HDR_SIZE, }; struct msghdr msg = { .msg_iov = &iov, .msg_iovlen = 1, .msg_control = control, .msg_controllen = sizeof(control), }; size_t fd_size; struct cmsghdr *cmsg; int rc; do { rc = recvmsg(conn_fd, &msg, 0); } while (rc < 0 && (errno == EINTR || errno == EAGAIN)); if (rc <= 0) { vu_panic(dev, "Error while recvmsg: %s", strerror(errno)); return false; } vmsg->fd_num = 0; for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) { if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) { fd_size = cmsg->cmsg_len - CMSG_LEN(0); vmsg->fd_num = fd_size / sizeof(int); memcpy(vmsg->fds, CMSG_DATA(cmsg), fd_size); break; } } if (vmsg->size > sizeof(vmsg->payload)) { vu_panic(dev, "Error: too big message request: %d, size: vmsg->size: %u, " "while sizeof(vmsg->payload) = %zu\n", vmsg->request, vmsg->size, sizeof(vmsg->payload)); goto fail; } if (vmsg->size) { do { rc = read(conn_fd, &vmsg->payload, vmsg->size); } while (rc < 0 && (errno == EINTR || errno == EAGAIN)); if (rc <= 0) { vu_panic(dev, "Error while reading: %s", strerror(errno)); goto fail; } assert(rc == vmsg->size); } return true; fail: vmsg_close_fds(vmsg); return false; }
{ "code": [ " if (rc <= 0) {" ], "line_no": [ 43 ] }
FUNC_0(VuDev *VAR_0, int VAR_1, VhostUserMsg *VAR_2) { char VAR_3[CMSG_SPACE(VHOST_MEMORY_MAX_NREGIONS * sizeof(int))] = { }; struct iovec VAR_4 = { .iov_base = (char *)VAR_2, .iov_len = VHOST_USER_HDR_SIZE, }; struct msghdr VAR_5 = { .msg_iov = &VAR_4, .msg_iovlen = 1, .msg_control = VAR_3, .msg_controllen = sizeof(VAR_3), }; size_t fd_size; struct cmsghdr *VAR_6; int VAR_7; do { VAR_7 = recvmsg(VAR_1, &VAR_5, 0); } while (VAR_7 < 0 && (errno == EINTR || errno == EAGAIN)); if (VAR_7 <= 0) { vu_panic(VAR_0, "Error while recvmsg: %s", strerror(errno)); return false; } VAR_2->fd_num = 0; for (VAR_6 = CMSG_FIRSTHDR(&VAR_5); VAR_6 != NULL; VAR_6 = CMSG_NXTHDR(&VAR_5, VAR_6)) { if (VAR_6->cmsg_level == SOL_SOCKET && VAR_6->cmsg_type == SCM_RIGHTS) { fd_size = VAR_6->cmsg_len - CMSG_LEN(0); VAR_2->fd_num = fd_size / sizeof(int); memcpy(VAR_2->fds, CMSG_DATA(VAR_6), fd_size); break; } } if (VAR_2->size > sizeof(VAR_2->payload)) { vu_panic(VAR_0, "Error: too big message request: %d, size: VAR_2->size: %u, " "while sizeof(VAR_2->payload) = %zu\n", VAR_2->request, VAR_2->size, sizeof(VAR_2->payload)); goto fail; } if (VAR_2->size) { do { VAR_7 = read(VAR_1, &VAR_2->payload, VAR_2->size); } while (VAR_7 < 0 && (errno == EINTR || errno == EAGAIN)); if (VAR_7 <= 0) { vu_panic(VAR_0, "Error while reading: %s", strerror(errno)); goto fail; } assert(VAR_7 == VAR_2->size); } return true; fail: vmsg_close_fds(VAR_2); return false; }
[ "FUNC_0(VuDev *VAR_0, int VAR_1, VhostUserMsg *VAR_2)\n{", "char VAR_3[CMSG_SPACE(VHOST_MEMORY_MAX_NREGIONS * sizeof(int))] = { };", "struct iovec VAR_4 = {", ".iov_base = (char *)VAR_2,\n.iov_len = VHOST_USER_HDR_SIZE,\n};", "struct msghdr VAR_5 = {", ".msg_iov = &VAR_4,\n.msg_iovlen = 1,\n.msg_control = VAR_3,\n.msg_controllen = sizeof(VAR_3),\n};", "size_t fd_size;", "struct cmsghdr *VAR_6;", "int VAR_7;", "do {", "VAR_7 = recvmsg(VAR_1, &VAR_5, 0);", "} while (VAR_7 < 0 && (errno == EINTR || errno == EAGAIN));", "if (VAR_7 <= 0) {", "vu_panic(VAR_0, \"Error while recvmsg: %s\", strerror(errno));", "return false;", "}", "VAR_2->fd_num = 0;", "for (VAR_6 = CMSG_FIRSTHDR(&VAR_5);", "VAR_6 != NULL;", "VAR_6 = CMSG_NXTHDR(&VAR_5, VAR_6))\n{", "if (VAR_6->cmsg_level == SOL_SOCKET && VAR_6->cmsg_type == SCM_RIGHTS) {", "fd_size = VAR_6->cmsg_len - CMSG_LEN(0);", "VAR_2->fd_num = fd_size / sizeof(int);", "memcpy(VAR_2->fds, CMSG_DATA(VAR_6), fd_size);", "break;", "}", "}", "if (VAR_2->size > sizeof(VAR_2->payload)) {", "vu_panic(VAR_0,\n\"Error: too big message request: %d, size: VAR_2->size: %u, \"\n\"while sizeof(VAR_2->payload) = %zu\\n\",\nVAR_2->request, VAR_2->size, sizeof(VAR_2->payload));", "goto fail;", "}", "if (VAR_2->size) {", "do {", "VAR_7 = read(VAR_1, &VAR_2->payload, VAR_2->size);", "} while (VAR_7 < 0 && (errno == EINTR || errno == EAGAIN));", "if (VAR_7 <= 0) {", "vu_panic(VAR_0, \"Error while reading: %s\", strerror(errno));", "goto fail;", "}", "assert(VAR_7 == VAR_2->size);", "}", "return true;", "fail:\nvmsg_close_fds(VAR_2);", "return false;", "}" ]
[ 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9, 11, 13 ], [ 15 ], [ 17, 19, 21, 23, 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ], [ 57 ], [ 59, 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81, 83, 85, 87 ], [ 89 ], [ 91 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 115 ], [ 117 ], [ 121 ], [ 125, 127 ], [ 131 ], [ 133 ] ]
6,166
static void entropy_available(void *opaque) { RndRandom *s = RNG_RANDOM(opaque); uint8_t buffer[s->size]; ssize_t len; len = read(s->fd, buffer, s->size); g_assert(len != -1); s->receive_func(s->opaque, buffer, len); s->receive_func = NULL; qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
true
qemu
acbbc036619092fcd2c882222e1be168bd972b3e
static void entropy_available(void *opaque) { RndRandom *s = RNG_RANDOM(opaque); uint8_t buffer[s->size]; ssize_t len; len = read(s->fd, buffer, s->size); g_assert(len != -1); s->receive_func(s->opaque, buffer, len); s->receive_func = NULL; qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0) { RndRandom *s = RNG_RANDOM(VAR_0); uint8_t buffer[s->size]; ssize_t len; len = read(s->fd, buffer, s->size); g_assert(len != -1); s->receive_func(s->VAR_0, buffer, len); s->receive_func = NULL; qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
[ "static void FUNC_0(void *VAR_0)\n{", "RndRandom *s = RNG_RANDOM(VAR_0);", "uint8_t buffer[s->size];", "ssize_t len;", "len = read(s->fd, buffer, s->size);", "g_assert(len != -1);", "s->receive_func(s->VAR_0, buffer, len);", "s->receive_func = NULL;", "qemu_set_fd_handler(s->fd, NULL, NULL, NULL);" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 18 ], [ 22 ], [ 24 ], [ 28 ] ]
6,167
static float32 addFloat32Sigs( float32 a, float32 b, flag zSign STATUS_PARAM) { int16 aExp, bExp, zExp; uint32_t aSig, bSig, zSig; int16 expDiff; aSig = extractFloat32Frac( a ); aExp = extractFloat32Exp( a ); bSig = extractFloat32Frac( b ); bExp = extractFloat32Exp( b ); expDiff = aExp - bExp; aSig <<= 6; bSig <<= 6; if ( 0 < expDiff ) { if ( aExp == 0xFF ) { if ( aSig ) return propagateFloat32NaN( a, b STATUS_VAR ); return a; } if ( bExp == 0 ) { --expDiff; } else { bSig |= 0x20000000; } shift32RightJamming( bSig, expDiff, &bSig ); zExp = aExp; } else if ( expDiff < 0 ) { if ( bExp == 0xFF ) { if ( bSig ) return propagateFloat32NaN( a, b STATUS_VAR ); return packFloat32( zSign, 0xFF, 0 ); } if ( aExp == 0 ) { ++expDiff; } else { aSig |= 0x20000000; } shift32RightJamming( aSig, - expDiff, &aSig ); zExp = bExp; } else { if ( aExp == 0xFF ) { if ( aSig | bSig ) return propagateFloat32NaN( a, b STATUS_VAR ); return a; } if ( aExp == 0 ) { if ( STATUS(flush_to_zero) ) return packFloat32( zSign, 0, 0 ); return packFloat32( zSign, 0, ( aSig + bSig )>>6 ); } zSig = 0x40000000 + aSig + bSig; zExp = aExp; goto roundAndPack; } aSig |= 0x20000000; zSig = ( aSig + bSig )<<1; --zExp; if ( (int32_t) zSig < 0 ) { zSig = aSig + bSig; ++zExp; } roundAndPack: return roundAndPackFloat32( zSign, zExp, zSig STATUS_VAR ); }
true
qemu
e6afc87f804abee7d0479be5e8e31c56d885fafb
static float32 addFloat32Sigs( float32 a, float32 b, flag zSign STATUS_PARAM) { int16 aExp, bExp, zExp; uint32_t aSig, bSig, zSig; int16 expDiff; aSig = extractFloat32Frac( a ); aExp = extractFloat32Exp( a ); bSig = extractFloat32Frac( b ); bExp = extractFloat32Exp( b ); expDiff = aExp - bExp; aSig <<= 6; bSig <<= 6; if ( 0 < expDiff ) { if ( aExp == 0xFF ) { if ( aSig ) return propagateFloat32NaN( a, b STATUS_VAR ); return a; } if ( bExp == 0 ) { --expDiff; } else { bSig |= 0x20000000; } shift32RightJamming( bSig, expDiff, &bSig ); zExp = aExp; } else if ( expDiff < 0 ) { if ( bExp == 0xFF ) { if ( bSig ) return propagateFloat32NaN( a, b STATUS_VAR ); return packFloat32( zSign, 0xFF, 0 ); } if ( aExp == 0 ) { ++expDiff; } else { aSig |= 0x20000000; } shift32RightJamming( aSig, - expDiff, &aSig ); zExp = bExp; } else { if ( aExp == 0xFF ) { if ( aSig | bSig ) return propagateFloat32NaN( a, b STATUS_VAR ); return a; } if ( aExp == 0 ) { if ( STATUS(flush_to_zero) ) return packFloat32( zSign, 0, 0 ); return packFloat32( zSign, 0, ( aSig + bSig )>>6 ); } zSig = 0x40000000 + aSig + bSig; zExp = aExp; goto roundAndPack; } aSig |= 0x20000000; zSig = ( aSig + bSig )<<1; --zExp; if ( (int32_t) zSig < 0 ) { zSig = aSig + bSig; ++zExp; } roundAndPack: return roundAndPackFloat32( zSign, zExp, zSig STATUS_VAR ); }
{ "code": [ " if ( STATUS(flush_to_zero) ) return packFloat32( zSign, 0, 0 );", " if ( STATUS(flush_to_zero) ) return packFloat32( zSign, 0, 0 );" ], "line_no": [ 95, 95 ] }
static float32 FUNC_0( float32 a, float32 b, flag zSign STATUS_PARAM) { int16 aExp, bExp, zExp; uint32_t aSig, bSig, zSig; int16 expDiff; aSig = extractFloat32Frac( a ); aExp = extractFloat32Exp( a ); bSig = extractFloat32Frac( b ); bExp = extractFloat32Exp( b ); expDiff = aExp - bExp; aSig <<= 6; bSig <<= 6; if ( 0 < expDiff ) { if ( aExp == 0xFF ) { if ( aSig ) return propagateFloat32NaN( a, b STATUS_VAR ); return a; } if ( bExp == 0 ) { --expDiff; } else { bSig |= 0x20000000; } shift32RightJamming( bSig, expDiff, &bSig ); zExp = aExp; } else if ( expDiff < 0 ) { if ( bExp == 0xFF ) { if ( bSig ) return propagateFloat32NaN( a, b STATUS_VAR ); return packFloat32( zSign, 0xFF, 0 ); } if ( aExp == 0 ) { ++expDiff; } else { aSig |= 0x20000000; } shift32RightJamming( aSig, - expDiff, &aSig ); zExp = bExp; } else { if ( aExp == 0xFF ) { if ( aSig | bSig ) return propagateFloat32NaN( a, b STATUS_VAR ); return a; } if ( aExp == 0 ) { if ( STATUS(flush_to_zero) ) return packFloat32( zSign, 0, 0 ); return packFloat32( zSign, 0, ( aSig + bSig )>>6 ); } zSig = 0x40000000 + aSig + bSig; zExp = aExp; goto roundAndPack; } aSig |= 0x20000000; zSig = ( aSig + bSig )<<1; --zExp; if ( (int32_t) zSig < 0 ) { zSig = aSig + bSig; ++zExp; } roundAndPack: return roundAndPackFloat32( zSign, zExp, zSig STATUS_VAR ); }
[ "static float32 FUNC_0( float32 a, float32 b, flag zSign STATUS_PARAM)\n{", "int16 aExp, bExp, zExp;", "uint32_t aSig, bSig, zSig;", "int16 expDiff;", "aSig = extractFloat32Frac( a );", "aExp = extractFloat32Exp( a );", "bSig = extractFloat32Frac( b );", "bExp = extractFloat32Exp( b );", "expDiff = aExp - bExp;", "aSig <<= 6;", "bSig <<= 6;", "if ( 0 < expDiff ) {", "if ( aExp == 0xFF ) {", "if ( aSig ) return propagateFloat32NaN( a, b STATUS_VAR );", "return a;", "}", "if ( bExp == 0 ) {", "--expDiff;", "}", "else {", "bSig |= 0x20000000;", "}", "shift32RightJamming( bSig, expDiff, &bSig );", "zExp = aExp;", "}", "else if ( expDiff < 0 ) {", "if ( bExp == 0xFF ) {", "if ( bSig ) return propagateFloat32NaN( a, b STATUS_VAR );", "return packFloat32( zSign, 0xFF, 0 );", "}", "if ( aExp == 0 ) {", "++expDiff;", "}", "else {", "aSig |= 0x20000000;", "}", "shift32RightJamming( aSig, - expDiff, &aSig );", "zExp = bExp;", "}", "else {", "if ( aExp == 0xFF ) {", "if ( aSig | bSig ) return propagateFloat32NaN( a, b STATUS_VAR );", "return a;", "}", "if ( aExp == 0 ) {", "if ( STATUS(flush_to_zero) ) return packFloat32( zSign, 0, 0 );", "return packFloat32( zSign, 0, ( aSig + bSig )>>6 );", "}", "zSig = 0x40000000 + aSig + bSig;", "zExp = aExp;", "goto roundAndPack;", "}", "aSig |= 0x20000000;", "zSig = ( aSig + bSig )<<1;", "--zExp;", "if ( (int32_t) zSig < 0 ) {", "zSig = aSig + bSig;", "++zExp;", "}", "roundAndPack:\nreturn roundAndPackFloat32( zSign, zExp, zSig STATUS_VAR );", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 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 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123, 125 ], [ 129 ] ]
6,168
static void rc4030_write(void *opaque, hwaddr addr, uint64_t data, unsigned int size) { rc4030State *s = opaque; uint32_t val = data; addr &= 0x3fff; trace_rc4030_write(addr, val); switch (addr & ~0x3) { /* Global config register */ case 0x0000: s->config = val; break; /* DMA transl. table base */ case 0x0018: rc4030_dma_tt_update(s, val, s->dma_tl_limit); break; /* DMA transl. table limit */ case 0x0020: rc4030_dma_tt_update(s, s->dma_tl_base, val); break; /* DMA transl. table invalidated */ case 0x0028: break; /* Cache Maintenance */ case 0x0030: s->cache_maint = val; break; /* I/O Cache Physical Tag */ case 0x0048: s->cache_ptag = val; break; /* I/O Cache Logical Tag */ case 0x0050: s->cache_ltag = val; break; /* I/O Cache Byte Mask */ case 0x0058: s->cache_bmask |= val; /* HACK */ break; /* I/O Cache Buffer Window */ case 0x0060: /* HACK */ if (s->cache_ltag == 0x80000001 && s->cache_bmask == 0xf0f0f0f) { hwaddr dest = s->cache_ptag & ~0x1; dest += (s->cache_maint & 0x3) << 3; cpu_physical_memory_write(dest, &val, 4); } break; /* Remote Speed Registers */ case 0x0070: case 0x0078: case 0x0080: case 0x0088: case 0x0090: case 0x0098: case 0x00a0: case 0x00a8: case 0x00b0: case 0x00b8: case 0x00c0: case 0x00c8: case 0x00d0: case 0x00d8: case 0x00e0: case 0x00e8: s->rem_speed[(addr - 0x0070) >> 3] = val; break; /* DMA channel base address */ case 0x0100: case 0x0108: case 0x0110: case 0x0118: case 0x0120: case 0x0128: case 0x0130: case 0x0138: case 0x0140: case 0x0148: case 0x0150: case 0x0158: case 0x0160: case 0x0168: case 0x0170: case 0x0178: case 0x0180: case 0x0188: case 0x0190: case 0x0198: case 0x01a0: case 0x01a8: case 0x01b0: case 0x01b8: case 0x01c0: case 0x01c8: case 0x01d0: case 0x01d8: case 0x01e0: case 0x01e8: case 0x01f0: case 0x01f8: { int entry = (addr - 0x0100) >> 5; int idx = (addr & 0x1f) >> 3; s->dma_regs[entry][idx] = val; } break; /* Memory refresh rate */ case 0x0210: s->memory_refresh_rate = val; break; /* Interval timer reload */ case 0x0228: s->itr = val; qemu_irq_lower(s->timer_irq); set_next_tick(s); break; /* EISA interrupt */ case 0x0238: break; default: qemu_log_mask(LOG_GUEST_ERROR, "rc4030: invalid write of 0x%02x at 0x%x", val, (int)addr); break; } }
true
qemu
c0a3172fa6bbddcc73192f2a2c48d0bf3a7ba61c
static void rc4030_write(void *opaque, hwaddr addr, uint64_t data, unsigned int size) { rc4030State *s = opaque; uint32_t val = data; addr &= 0x3fff; trace_rc4030_write(addr, val); switch (addr & ~0x3) { case 0x0000: s->config = val; break; case 0x0018: rc4030_dma_tt_update(s, val, s->dma_tl_limit); break; case 0x0020: rc4030_dma_tt_update(s, s->dma_tl_base, val); break; case 0x0028: break; case 0x0030: s->cache_maint = val; break; case 0x0048: s->cache_ptag = val; break; case 0x0050: s->cache_ltag = val; break; case 0x0058: s->cache_bmask |= val; break; case 0x0060: if (s->cache_ltag == 0x80000001 && s->cache_bmask == 0xf0f0f0f) { hwaddr dest = s->cache_ptag & ~0x1; dest += (s->cache_maint & 0x3) << 3; cpu_physical_memory_write(dest, &val, 4); } break; case 0x0070: case 0x0078: case 0x0080: case 0x0088: case 0x0090: case 0x0098: case 0x00a0: case 0x00a8: case 0x00b0: case 0x00b8: case 0x00c0: case 0x00c8: case 0x00d0: case 0x00d8: case 0x00e0: case 0x00e8: s->rem_speed[(addr - 0x0070) >> 3] = val; break; case 0x0100: case 0x0108: case 0x0110: case 0x0118: case 0x0120: case 0x0128: case 0x0130: case 0x0138: case 0x0140: case 0x0148: case 0x0150: case 0x0158: case 0x0160: case 0x0168: case 0x0170: case 0x0178: case 0x0180: case 0x0188: case 0x0190: case 0x0198: case 0x01a0: case 0x01a8: case 0x01b0: case 0x01b8: case 0x01c0: case 0x01c8: case 0x01d0: case 0x01d8: case 0x01e0: case 0x01e8: case 0x01f0: case 0x01f8: { int entry = (addr - 0x0100) >> 5; int idx = (addr & 0x1f) >> 3; s->dma_regs[entry][idx] = val; } break; case 0x0210: s->memory_refresh_rate = val; break; case 0x0228: s->itr = val; qemu_irq_lower(s->timer_irq); set_next_tick(s); break; case 0x0238: break; default: qemu_log_mask(LOG_GUEST_ERROR, "rc4030: invalid write of 0x%02x at 0x%x", val, (int)addr); break; } }
{ "code": [ " s->itr = val;" ], "line_no": [ 229 ] }
static void FUNC_0(void *VAR_0, hwaddr VAR_1, uint64_t VAR_2, unsigned int VAR_3) { rc4030State *s = VAR_0; uint32_t val = VAR_2; VAR_1 &= 0x3fff; trace_rc4030_write(VAR_1, val); switch (VAR_1 & ~0x3) { case 0x0000: s->config = val; break; case 0x0018: rc4030_dma_tt_update(s, val, s->dma_tl_limit); break; case 0x0020: rc4030_dma_tt_update(s, s->dma_tl_base, val); break; case 0x0028: break; case 0x0030: s->cache_maint = val; break; case 0x0048: s->cache_ptag = val; break; case 0x0050: s->cache_ltag = val; break; case 0x0058: s->cache_bmask |= val; break; case 0x0060: if (s->cache_ltag == 0x80000001 && s->cache_bmask == 0xf0f0f0f) { hwaddr dest = s->cache_ptag & ~0x1; dest += (s->cache_maint & 0x3) << 3; cpu_physical_memory_write(dest, &val, 4); } break; case 0x0070: case 0x0078: case 0x0080: case 0x0088: case 0x0090: case 0x0098: case 0x00a0: case 0x00a8: case 0x00b0: case 0x00b8: case 0x00c0: case 0x00c8: case 0x00d0: case 0x00d8: case 0x00e0: case 0x00e8: s->rem_speed[(VAR_1 - 0x0070) >> 3] = val; break; case 0x0100: case 0x0108: case 0x0110: case 0x0118: case 0x0120: case 0x0128: case 0x0130: case 0x0138: case 0x0140: case 0x0148: case 0x0150: case 0x0158: case 0x0160: case 0x0168: case 0x0170: case 0x0178: case 0x0180: case 0x0188: case 0x0190: case 0x0198: case 0x01a0: case 0x01a8: case 0x01b0: case 0x01b8: case 0x01c0: case 0x01c8: case 0x01d0: case 0x01d8: case 0x01e0: case 0x01e8: case 0x01f0: case 0x01f8: { int VAR_4 = (VAR_1 - 0x0100) >> 5; int VAR_5 = (VAR_1 & 0x1f) >> 3; s->dma_regs[VAR_4][VAR_5] = val; } break; case 0x0210: s->memory_refresh_rate = val; break; case 0x0228: s->itr = val; qemu_irq_lower(s->timer_irq); set_next_tick(s); break; case 0x0238: break; default: qemu_log_mask(LOG_GUEST_ERROR, "rc4030: invalid write of 0x%02x at 0x%x", val, (int)VAR_1); break; } }
[ "static void FUNC_0(void *VAR_0, hwaddr VAR_1, uint64_t VAR_2,\nunsigned int VAR_3)\n{", "rc4030State *s = VAR_0;", "uint32_t val = VAR_2;", "VAR_1 &= 0x3fff;", "trace_rc4030_write(VAR_1, val);", "switch (VAR_1 & ~0x3) {", "case 0x0000:\ns->config = val;", "break;", "case 0x0018:\nrc4030_dma_tt_update(s, val, s->dma_tl_limit);", "break;", "case 0x0020:\nrc4030_dma_tt_update(s, s->dma_tl_base, val);", "break;", "case 0x0028:\nbreak;", "case 0x0030:\ns->cache_maint = val;", "break;", "case 0x0048:\ns->cache_ptag = val;", "break;", "case 0x0050:\ns->cache_ltag = val;", "break;", "case 0x0058:\ns->cache_bmask |= val;", "break;", "case 0x0060:\nif (s->cache_ltag == 0x80000001 && s->cache_bmask == 0xf0f0f0f) {", "hwaddr dest = s->cache_ptag & ~0x1;", "dest += (s->cache_maint & 0x3) << 3;", "cpu_physical_memory_write(dest, &val, 4);", "}", "break;", "case 0x0070:\ncase 0x0078:\ncase 0x0080:\ncase 0x0088:\ncase 0x0090:\ncase 0x0098:\ncase 0x00a0:\ncase 0x00a8:\ncase 0x00b0:\ncase 0x00b8:\ncase 0x00c0:\ncase 0x00c8:\ncase 0x00d0:\ncase 0x00d8:\ncase 0x00e0:\ncase 0x00e8:\ns->rem_speed[(VAR_1 - 0x0070) >> 3] = val;", "break;", "case 0x0100:\ncase 0x0108:\ncase 0x0110:\ncase 0x0118:\ncase 0x0120:\ncase 0x0128:\ncase 0x0130:\ncase 0x0138:\ncase 0x0140:\ncase 0x0148:\ncase 0x0150:\ncase 0x0158:\ncase 0x0160:\ncase 0x0168:\ncase 0x0170:\ncase 0x0178:\ncase 0x0180:\ncase 0x0188:\ncase 0x0190:\ncase 0x0198:\ncase 0x01a0:\ncase 0x01a8:\ncase 0x01b0:\ncase 0x01b8:\ncase 0x01c0:\ncase 0x01c8:\ncase 0x01d0:\ncase 0x01d8:\ncase 0x01e0:\ncase 0x01e8:\ncase 0x01f0:\ncase 0x01f8:\n{", "int VAR_4 = (VAR_1 - 0x0100) >> 5;", "int VAR_5 = (VAR_1 & 0x1f) >> 3;", "s->dma_regs[VAR_4][VAR_5] = val;", "}", "break;", "case 0x0210:\ns->memory_refresh_rate = val;", "break;", "case 0x0228:\ns->itr = val;", "qemu_irq_lower(s->timer_irq);", "set_next_tick(s);", "break;", "case 0x0238:\nbreak;", "default:\nqemu_log_mask(LOG_GUEST_ERROR,\n\"rc4030: invalid write of 0x%02x at 0x%x\",\nval, (int)VAR_1);", "break;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 19 ], [ 23, 25 ], [ 27 ], [ 31, 33 ], [ 35 ], [ 39, 41 ], [ 43 ], [ 47, 49 ], [ 53, 55 ], [ 57 ], [ 61, 63 ], [ 65 ], [ 69, 71 ], [ 73 ], [ 77, 79 ], [ 81 ], [ 85, 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135 ], [ 137 ], [ 141, 143, 145, 147, 149, 151, 153, 155, 157, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179, 181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 219, 221 ], [ 223 ], [ 227, 229 ], [ 231 ], [ 233 ], [ 235 ], [ 239, 241 ], [ 243, 245, 247, 249 ], [ 251 ], [ 253 ], [ 255 ] ]
6,169
int qcow2_grow_l1_table(BlockDriverState *bs, int min_size, bool exact_size) { BDRVQcowState *s = bs->opaque; int new_l1_size, new_l1_size2, ret, i; uint64_t *new_l1_table; int64_t new_l1_table_offset; uint8_t data[12]; if (min_size <= s->l1_size) return 0; if (exact_size) { new_l1_size = min_size; } else { /* Bump size up to reduce the number of times we have to grow */ new_l1_size = s->l1_size; if (new_l1_size == 0) { new_l1_size = 1; } while (min_size > new_l1_size) { new_l1_size = (new_l1_size * 3 + 1) / 2; } } #ifdef DEBUG_ALLOC2 fprintf(stderr, "grow l1_table from %d to %d\n", s->l1_size, new_l1_size); #endif new_l1_size2 = sizeof(uint64_t) * new_l1_size; new_l1_table = g_malloc0(align_offset(new_l1_size2, 512)); memcpy(new_l1_table, s->l1_table, s->l1_size * sizeof(uint64_t)); /* write new table (align to cluster) */ BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_ALLOC_TABLE); new_l1_table_offset = qcow2_alloc_clusters(bs, new_l1_size2); if (new_l1_table_offset < 0) { g_free(new_l1_table); return new_l1_table_offset; } ret = qcow2_cache_flush(bs, s->refcount_block_cache); if (ret < 0) { goto fail; } BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_WRITE_TABLE); for(i = 0; i < s->l1_size; i++) new_l1_table[i] = cpu_to_be64(new_l1_table[i]); ret = bdrv_pwrite_sync(bs->file, new_l1_table_offset, new_l1_table, new_l1_size2); if (ret < 0) goto fail; for(i = 0; i < s->l1_size; i++) new_l1_table[i] = be64_to_cpu(new_l1_table[i]); /* set new table */ BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_ACTIVATE_TABLE); cpu_to_be32w((uint32_t*)data, new_l1_size); cpu_to_be64wu((uint64_t*)(data + 4), new_l1_table_offset); ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, l1_size), data,sizeof(data)); if (ret < 0) { goto fail; } g_free(s->l1_table); qcow2_free_clusters(bs, s->l1_table_offset, s->l1_size * sizeof(uint64_t)); s->l1_table_offset = new_l1_table_offset; s->l1_table = new_l1_table; s->l1_size = new_l1_size; return 0; fail: g_free(new_l1_table); qcow2_free_clusters(bs, new_l1_table_offset, new_l1_size2); return ret; }
true
qemu
2cf7cfa1cde6672b8a35bbed3fbc989f28c05dce
int qcow2_grow_l1_table(BlockDriverState *bs, int min_size, bool exact_size) { BDRVQcowState *s = bs->opaque; int new_l1_size, new_l1_size2, ret, i; uint64_t *new_l1_table; int64_t new_l1_table_offset; uint8_t data[12]; if (min_size <= s->l1_size) return 0; if (exact_size) { new_l1_size = min_size; } else { new_l1_size = s->l1_size; if (new_l1_size == 0) { new_l1_size = 1; } while (min_size > new_l1_size) { new_l1_size = (new_l1_size * 3 + 1) / 2; } } #ifdef DEBUG_ALLOC2 fprintf(stderr, "grow l1_table from %d to %d\n", s->l1_size, new_l1_size); #endif new_l1_size2 = sizeof(uint64_t) * new_l1_size; new_l1_table = g_malloc0(align_offset(new_l1_size2, 512)); memcpy(new_l1_table, s->l1_table, s->l1_size * sizeof(uint64_t)); BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_ALLOC_TABLE); new_l1_table_offset = qcow2_alloc_clusters(bs, new_l1_size2); if (new_l1_table_offset < 0) { g_free(new_l1_table); return new_l1_table_offset; } ret = qcow2_cache_flush(bs, s->refcount_block_cache); if (ret < 0) { goto fail; } BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_WRITE_TABLE); for(i = 0; i < s->l1_size; i++) new_l1_table[i] = cpu_to_be64(new_l1_table[i]); ret = bdrv_pwrite_sync(bs->file, new_l1_table_offset, new_l1_table, new_l1_size2); if (ret < 0) goto fail; for(i = 0; i < s->l1_size; i++) new_l1_table[i] = be64_to_cpu(new_l1_table[i]); BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_ACTIVATE_TABLE); cpu_to_be32w((uint32_t*)data, new_l1_size); cpu_to_be64wu((uint64_t*)(data + 4), new_l1_table_offset); ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, l1_size), data,sizeof(data)); if (ret < 0) { goto fail; } g_free(s->l1_table); qcow2_free_clusters(bs, s->l1_table_offset, s->l1_size * sizeof(uint64_t)); s->l1_table_offset = new_l1_table_offset; s->l1_table = new_l1_table; s->l1_size = new_l1_size; return 0; fail: g_free(new_l1_table); qcow2_free_clusters(bs, new_l1_table_offset, new_l1_size2); return ret; }
{ "code": [ "int qcow2_grow_l1_table(BlockDriverState *bs, int min_size, bool exact_size)", " int new_l1_size, new_l1_size2, ret, i;", " int64_t new_l1_table_offset;", " fprintf(stderr, \"grow l1_table from %d to %d\\n\", s->l1_size, new_l1_size);" ], "line_no": [ 1, 7, 11, 51 ] }
int FUNC_0(BlockDriverState *VAR_0, int VAR_1, bool VAR_2) { BDRVQcowState *s = VAR_0->opaque; int VAR_3, VAR_4, VAR_5, VAR_6; uint64_t *new_l1_table; int64_t new_l1_table_offset; uint8_t data[12]; if (VAR_1 <= s->l1_size) return 0; if (VAR_2) { VAR_3 = VAR_1; } else { VAR_3 = s->l1_size; if (VAR_3 == 0) { VAR_3 = 1; } while (VAR_1 > VAR_3) { VAR_3 = (VAR_3 * 3 + 1) / 2; } } #ifdef DEBUG_ALLOC2 fprintf(stderr, "grow l1_table from %d to %d\n", s->l1_size, VAR_3); #endif VAR_4 = sizeof(uint64_t) * VAR_3; new_l1_table = g_malloc0(align_offset(VAR_4, 512)); memcpy(new_l1_table, s->l1_table, s->l1_size * sizeof(uint64_t)); BLKDBG_EVENT(VAR_0->file, BLKDBG_L1_GROW_ALLOC_TABLE); new_l1_table_offset = qcow2_alloc_clusters(VAR_0, VAR_4); if (new_l1_table_offset < 0) { g_free(new_l1_table); return new_l1_table_offset; } VAR_5 = qcow2_cache_flush(VAR_0, s->refcount_block_cache); if (VAR_5 < 0) { goto fail; } BLKDBG_EVENT(VAR_0->file, BLKDBG_L1_GROW_WRITE_TABLE); for(VAR_6 = 0; VAR_6 < s->l1_size; VAR_6++) new_l1_table[VAR_6] = cpu_to_be64(new_l1_table[VAR_6]); VAR_5 = bdrv_pwrite_sync(VAR_0->file, new_l1_table_offset, new_l1_table, VAR_4); if (VAR_5 < 0) goto fail; for(VAR_6 = 0; VAR_6 < s->l1_size; VAR_6++) new_l1_table[VAR_6] = be64_to_cpu(new_l1_table[VAR_6]); BLKDBG_EVENT(VAR_0->file, BLKDBG_L1_GROW_ACTIVATE_TABLE); cpu_to_be32w((uint32_t*)data, VAR_3); cpu_to_be64wu((uint64_t*)(data + 4), new_l1_table_offset); VAR_5 = bdrv_pwrite_sync(VAR_0->file, offsetof(QCowHeader, l1_size), data,sizeof(data)); if (VAR_5 < 0) { goto fail; } g_free(s->l1_table); qcow2_free_clusters(VAR_0, s->l1_table_offset, s->l1_size * sizeof(uint64_t)); s->l1_table_offset = new_l1_table_offset; s->l1_table = new_l1_table; s->l1_size = VAR_3; return 0; fail: g_free(new_l1_table); qcow2_free_clusters(VAR_0, new_l1_table_offset, VAR_4); return VAR_5; }
[ "int FUNC_0(BlockDriverState *VAR_0, int VAR_1, bool VAR_2)\n{", "BDRVQcowState *s = VAR_0->opaque;", "int VAR_3, VAR_4, VAR_5, VAR_6;", "uint64_t *new_l1_table;", "int64_t new_l1_table_offset;", "uint8_t data[12];", "if (VAR_1 <= s->l1_size)\nreturn 0;", "if (VAR_2) {", "VAR_3 = VAR_1;", "} else {", "VAR_3 = s->l1_size;", "if (VAR_3 == 0) {", "VAR_3 = 1;", "}", "while (VAR_1 > VAR_3) {", "VAR_3 = (VAR_3 * 3 + 1) / 2;", "}", "}", "#ifdef DEBUG_ALLOC2\nfprintf(stderr, \"grow l1_table from %d to %d\\n\", s->l1_size, VAR_3);", "#endif\nVAR_4 = sizeof(uint64_t) * VAR_3;", "new_l1_table = g_malloc0(align_offset(VAR_4, 512));", "memcpy(new_l1_table, s->l1_table, s->l1_size * sizeof(uint64_t));", "BLKDBG_EVENT(VAR_0->file, BLKDBG_L1_GROW_ALLOC_TABLE);", "new_l1_table_offset = qcow2_alloc_clusters(VAR_0, VAR_4);", "if (new_l1_table_offset < 0) {", "g_free(new_l1_table);", "return new_l1_table_offset;", "}", "VAR_5 = qcow2_cache_flush(VAR_0, s->refcount_block_cache);", "if (VAR_5 < 0) {", "goto fail;", "}", "BLKDBG_EVENT(VAR_0->file, BLKDBG_L1_GROW_WRITE_TABLE);", "for(VAR_6 = 0; VAR_6 < s->l1_size; VAR_6++)", "new_l1_table[VAR_6] = cpu_to_be64(new_l1_table[VAR_6]);", "VAR_5 = bdrv_pwrite_sync(VAR_0->file, new_l1_table_offset, new_l1_table, VAR_4);", "if (VAR_5 < 0)\ngoto fail;", "for(VAR_6 = 0; VAR_6 < s->l1_size; VAR_6++)", "new_l1_table[VAR_6] = be64_to_cpu(new_l1_table[VAR_6]);", "BLKDBG_EVENT(VAR_0->file, BLKDBG_L1_GROW_ACTIVATE_TABLE);", "cpu_to_be32w((uint32_t*)data, VAR_3);", "cpu_to_be64wu((uint64_t*)(data + 4), new_l1_table_offset);", "VAR_5 = bdrv_pwrite_sync(VAR_0->file, offsetof(QCowHeader, l1_size), data,sizeof(data));", "if (VAR_5 < 0) {", "goto fail;", "}", "g_free(s->l1_table);", "qcow2_free_clusters(VAR_0, s->l1_table_offset, s->l1_size * sizeof(uint64_t));", "s->l1_table_offset = new_l1_table_offset;", "s->l1_table = new_l1_table;", "s->l1_size = VAR_3;", "return 0;", "fail:\ng_free(new_l1_table);", "qcow2_free_clusters(VAR_0, new_l1_table_offset, VAR_4);", "return VAR_5;", "}" ]
[ 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17, 19 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49, 51 ], [ 53, 57 ], [ 59 ], [ 61 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99, 101 ], [ 103 ], [ 105 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137, 139 ], [ 141 ], [ 143 ], [ 145 ] ]
6,170
static bool qemu_vmstop_requested(RunState *r) { if (vmstop_requested < RUN_STATE_MAX) { *r = vmstop_requested; vmstop_requested = RUN_STATE_MAX; return true; } return false; }
true
qemu
74892d2468b9f0c56b915ce94848d6f7fac39740
static bool qemu_vmstop_requested(RunState *r) { if (vmstop_requested < RUN_STATE_MAX) { *r = vmstop_requested; vmstop_requested = RUN_STATE_MAX; return true; } return false; }
{ "code": [ "static bool qemu_vmstop_requested(RunState *r)", " if (vmstop_requested < RUN_STATE_MAX) {", " *r = vmstop_requested;", " vmstop_requested = RUN_STATE_MAX;", " return true;", " return false;" ], "line_no": [ 1, 5, 7, 9, 11, 17 ] }
static bool FUNC_0(RunState *r) { if (vmstop_requested < RUN_STATE_MAX) { *r = vmstop_requested; vmstop_requested = RUN_STATE_MAX; return true; } return false; }
[ "static bool FUNC_0(RunState *r)\n{", "if (vmstop_requested < RUN_STATE_MAX) {", "*r = vmstop_requested;", "vmstop_requested = RUN_STATE_MAX;", "return true;", "}", "return false;", "}" ]
[ 1, 1, 1, 1, 1, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ] ]
6,171
int kvm_irqchip_add_adapter_route(KVMState *s, AdapterInfo *adapter) { struct kvm_irq_routing_entry kroute; int virq; if (!kvm_gsi_routing_enabled()) { return -ENOSYS; } virq = kvm_irqchip_get_virq(s); if (virq < 0) { return virq; } kroute.gsi = virq; kroute.type = KVM_IRQ_ROUTING_S390_ADAPTER; kroute.flags = 0; kroute.u.adapter.summary_addr = adapter->summary_addr; kroute.u.adapter.ind_addr = adapter->ind_addr; kroute.u.adapter.summary_offset = adapter->summary_offset; kroute.u.adapter.ind_offset = adapter->ind_offset; kroute.u.adapter.adapter_id = adapter->adapter_id; kvm_add_routing_entry(s, &kroute); kvm_irqchip_commit_routes(s); return virq; }
true
qemu
e9af2fef242ce92f86d3d5c1a94c3199ff1e24c9
int kvm_irqchip_add_adapter_route(KVMState *s, AdapterInfo *adapter) { struct kvm_irq_routing_entry kroute; int virq; if (!kvm_gsi_routing_enabled()) { return -ENOSYS; } virq = kvm_irqchip_get_virq(s); if (virq < 0) { return virq; } kroute.gsi = virq; kroute.type = KVM_IRQ_ROUTING_S390_ADAPTER; kroute.flags = 0; kroute.u.adapter.summary_addr = adapter->summary_addr; kroute.u.adapter.ind_addr = adapter->ind_addr; kroute.u.adapter.summary_offset = adapter->summary_offset; kroute.u.adapter.ind_offset = adapter->ind_offset; kroute.u.adapter.adapter_id = adapter->adapter_id; kvm_add_routing_entry(s, &kroute); kvm_irqchip_commit_routes(s); return virq; }
{ "code": [ " struct kvm_irq_routing_entry kroute;" ], "line_no": [ 5 ] }
int FUNC_0(KVMState *VAR_0, AdapterInfo *VAR_1) { struct kvm_irq_routing_entry VAR_2; int VAR_3; if (!kvm_gsi_routing_enabled()) { return -ENOSYS; } VAR_3 = kvm_irqchip_get_virq(VAR_0); if (VAR_3 < 0) { return VAR_3; } VAR_2.gsi = VAR_3; VAR_2.type = KVM_IRQ_ROUTING_S390_ADAPTER; VAR_2.flags = 0; VAR_2.u.VAR_1.summary_addr = VAR_1->summary_addr; VAR_2.u.VAR_1.ind_addr = VAR_1->ind_addr; VAR_2.u.VAR_1.summary_offset = VAR_1->summary_offset; VAR_2.u.VAR_1.ind_offset = VAR_1->ind_offset; VAR_2.u.VAR_1.adapter_id = VAR_1->adapter_id; kvm_add_routing_entry(VAR_0, &VAR_2); kvm_irqchip_commit_routes(VAR_0); return VAR_3; }
[ "int FUNC_0(KVMState *VAR_0, AdapterInfo *VAR_1)\n{", "struct kvm_irq_routing_entry VAR_2;", "int VAR_3;", "if (!kvm_gsi_routing_enabled()) {", "return -ENOSYS;", "}", "VAR_3 = kvm_irqchip_get_virq(VAR_0);", "if (VAR_3 < 0) {", "return VAR_3;", "}", "VAR_2.gsi = VAR_3;", "VAR_2.type = KVM_IRQ_ROUTING_S390_ADAPTER;", "VAR_2.flags = 0;", "VAR_2.u.VAR_1.summary_addr = VAR_1->summary_addr;", "VAR_2.u.VAR_1.ind_addr = VAR_1->ind_addr;", "VAR_2.u.VAR_1.summary_offset = VAR_1->summary_offset;", "VAR_2.u.VAR_1.ind_offset = VAR_1->ind_offset;", "VAR_2.u.VAR_1.adapter_id = VAR_1->adapter_id;", "kvm_add_routing_entry(VAR_0, &VAR_2);", "kvm_irqchip_commit_routes(VAR_0);", "return VAR_3;", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ] ]
6,172
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *buf) { AVFilterContext *ctx = inlink->dst; AlphaMergeContext *merge = ctx->priv; int is_alpha = (inlink == ctx->inputs[1]); struct FFBufQueue *queue = (is_alpha ? &merge->queue_alpha : &merge->queue_main); ff_bufqueue_add(ctx, queue, buf); while (1) { AVFilterBufferRef *main_buf, *alpha_buf; if (!ff_bufqueue_peek(&merge->queue_main, 0) || !ff_bufqueue_peek(&merge->queue_alpha, 0)) break; main_buf = ff_bufqueue_get(&merge->queue_main); alpha_buf = ff_bufqueue_get(&merge->queue_alpha); merge->frame_requested = 0; draw_frame(ctx, main_buf, alpha_buf); ff_filter_frame(ctx->outputs[0], avfilter_ref_buffer(main_buf, ~0)); avfilter_unref_buffer(alpha_buf); } return 0; }
true
FFmpeg
255be0734d9293309b42d8029d2004ec3732c8bc
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *buf) { AVFilterContext *ctx = inlink->dst; AlphaMergeContext *merge = ctx->priv; int is_alpha = (inlink == ctx->inputs[1]); struct FFBufQueue *queue = (is_alpha ? &merge->queue_alpha : &merge->queue_main); ff_bufqueue_add(ctx, queue, buf); while (1) { AVFilterBufferRef *main_buf, *alpha_buf; if (!ff_bufqueue_peek(&merge->queue_main, 0) || !ff_bufqueue_peek(&merge->queue_alpha, 0)) break; main_buf = ff_bufqueue_get(&merge->queue_main); alpha_buf = ff_bufqueue_get(&merge->queue_alpha); merge->frame_requested = 0; draw_frame(ctx, main_buf, alpha_buf); ff_filter_frame(ctx->outputs[0], avfilter_ref_buffer(main_buf, ~0)); avfilter_unref_buffer(alpha_buf); } return 0; }
{ "code": [ " ff_filter_frame(ctx->outputs[0], avfilter_ref_buffer(main_buf, ~0));" ], "line_no": [ 43 ] }
static int FUNC_0(AVFilterLink *VAR_0, AVFilterBufferRef *VAR_1) { AVFilterContext *ctx = VAR_0->dst; AlphaMergeContext *merge = ctx->priv; int VAR_2 = (VAR_0 == ctx->inputs[1]); struct FFBufQueue *VAR_3 = (VAR_2 ? &merge->queue_alpha : &merge->queue_main); ff_bufqueue_add(ctx, VAR_3, VAR_1); while (1) { AVFilterBufferRef *main_buf, *alpha_buf; if (!ff_bufqueue_peek(&merge->queue_main, 0) || !ff_bufqueue_peek(&merge->queue_alpha, 0)) break; main_buf = ff_bufqueue_get(&merge->queue_main); alpha_buf = ff_bufqueue_get(&merge->queue_alpha); merge->frame_requested = 0; draw_frame(ctx, main_buf, alpha_buf); ff_filter_frame(ctx->outputs[0], avfilter_ref_buffer(main_buf, ~0)); avfilter_unref_buffer(alpha_buf); } return 0; }
[ "static int FUNC_0(AVFilterLink *VAR_0, AVFilterBufferRef *VAR_1)\n{", "AVFilterContext *ctx = VAR_0->dst;", "AlphaMergeContext *merge = ctx->priv;", "int VAR_2 = (VAR_0 == ctx->inputs[1]);", "struct FFBufQueue *VAR_3 =\n(VAR_2 ? &merge->queue_alpha : &merge->queue_main);", "ff_bufqueue_add(ctx, VAR_3, VAR_1);", "while (1) {", "AVFilterBufferRef *main_buf, *alpha_buf;", "if (!ff_bufqueue_peek(&merge->queue_main, 0) ||\n!ff_bufqueue_peek(&merge->queue_alpha, 0)) break;", "main_buf = ff_bufqueue_get(&merge->queue_main);", "alpha_buf = ff_bufqueue_get(&merge->queue_alpha);", "merge->frame_requested = 0;", "draw_frame(ctx, main_buf, alpha_buf);", "ff_filter_frame(ctx->outputs[0], avfilter_ref_buffer(main_buf, ~0));", "avfilter_unref_buffer(alpha_buf);", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13, 15 ], [ 17 ], [ 21 ], [ 23 ], [ 27, 29 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ] ]
6,173
static void id3v2_read_ttag(AVFormatContext *s, int taglen, char *dst, int dstlen) { char *q; int len; if(dstlen > 0) dst[0]= 0; if(taglen < 1) return; taglen--; /* account for encoding type byte */ dstlen--; /* Leave space for zero terminator */ switch(get_byte(s->pb)) { /* encoding type */ case 0: /* ISO-8859-1 (0 - 255 maps directly into unicode) */ q = dst; while(taglen--) { uint8_t tmp; PUT_UTF8(get_byte(s->pb), tmp, if (q - dst < dstlen - 1) *q++ = tmp;) } *q = '\0'; break; case 3: /* UTF-8 */ len = FFMIN(taglen, dstlen); get_buffer(s->pb, dst, len); dst[len] = 0; break; } }
true
FFmpeg
03289958938e91dc9bc398fdf1489677c6030063
static void id3v2_read_ttag(AVFormatContext *s, int taglen, char *dst, int dstlen) { char *q; int len; if(dstlen > 0) dst[0]= 0; if(taglen < 1) return; taglen--; dstlen--; switch(get_byte(s->pb)) { case 0: q = dst; while(taglen--) { uint8_t tmp; PUT_UTF8(get_byte(s->pb), tmp, if (q - dst < dstlen - 1) *q++ = tmp;) } *q = '\0'; break; case 3: len = FFMIN(taglen, dstlen); get_buffer(s->pb, dst, len); dst[len] = 0; break; } }
{ "code": [ " len = FFMIN(taglen, dstlen);" ], "line_no": [ 51 ] }
static void FUNC_0(AVFormatContext *VAR_0, int VAR_1, char *VAR_2, int VAR_3) { char *VAR_4; int VAR_5; if(VAR_3 > 0) VAR_2[0]= 0; if(VAR_1 < 1) return; VAR_1--; VAR_3--; switch(get_byte(VAR_0->pb)) { case 0: VAR_4 = VAR_2; while(VAR_1--) { uint8_t tmp; PUT_UTF8(get_byte(VAR_0->pb), tmp, if (VAR_4 - VAR_2 < VAR_3 - 1) *VAR_4++ = tmp;) } *VAR_4 = '\0'; break; case 3: VAR_5 = FFMIN(VAR_1, VAR_3); get_buffer(VAR_0->pb, VAR_2, VAR_5); VAR_2[VAR_5] = 0; break; } }
[ "static void FUNC_0(AVFormatContext *VAR_0, int VAR_1, char *VAR_2, int VAR_3)\n{", "char *VAR_4;", "int VAR_5;", "if(VAR_3 > 0)\nVAR_2[0]= 0;", "if(VAR_1 < 1)\nreturn;", "VAR_1--;", "VAR_3--;", "switch(get_byte(VAR_0->pb)) {", "case 0:\nVAR_4 = VAR_2;", "while(VAR_1--) {", "uint8_t tmp;", "PUT_UTF8(get_byte(VAR_0->pb), tmp, if (VAR_4 - VAR_2 < VAR_3 - 1) *VAR_4++ = tmp;)", "}", "*VAR_4 = '\\0';", "break;", "case 3:\nVAR_5 = FFMIN(VAR_1, VAR_3);", "get_buffer(VAR_0->pb, VAR_2, VAR_5);", "VAR_2[VAR_5] = 0;", "break;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11, 13 ], [ 15, 17 ], [ 21 ], [ 23 ], [ 27 ], [ 31, 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49, 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ] ]
6,175
static void spatial_decompose97i(DWTELEM *buffer, int width, int height, int stride){ int y; DWTELEM *b0= buffer + mirror(-4-1, height-1)*stride; DWTELEM *b1= buffer + mirror(-4 , height-1)*stride; DWTELEM *b2= buffer + mirror(-4+1, height-1)*stride; DWTELEM *b3= buffer + mirror(-4+2, height-1)*stride; for(y=-4; y<height; y+=2){ DWTELEM *b4= buffer + mirror(y+3, height-1)*stride; DWTELEM *b5= buffer + mirror(y+4, height-1)*stride; {START_TIMER if(b3 <= b5) horizontal_decompose97i(b4, width); if(y+4 < height) horizontal_decompose97i(b5, width); if(width>400){ STOP_TIMER("horizontal_decompose97i") }} {START_TIMER if(b3 <= b5) vertical_decompose97iH0(b3, b4, b5, width); if(b2 <= b4) vertical_decompose97iL0(b2, b3, b4, width); if(b1 <= b3) vertical_decompose97iH1(b1, b2, b3, width); if(b0 <= b2) vertical_decompose97iL1(b0, b1, b2, width); if(width>400){ STOP_TIMER("vertical_decompose97i") }} b0=b2; b1=b3; b2=b4; b3=b5; } }
true
FFmpeg
13705b69ebe9e375fdb52469760a0fbb5f593cc1
static void spatial_decompose97i(DWTELEM *buffer, int width, int height, int stride){ int y; DWTELEM *b0= buffer + mirror(-4-1, height-1)*stride; DWTELEM *b1= buffer + mirror(-4 , height-1)*stride; DWTELEM *b2= buffer + mirror(-4+1, height-1)*stride; DWTELEM *b3= buffer + mirror(-4+2, height-1)*stride; for(y=-4; y<height; y+=2){ DWTELEM *b4= buffer + mirror(y+3, height-1)*stride; DWTELEM *b5= buffer + mirror(y+4, height-1)*stride; {START_TIMER if(b3 <= b5) horizontal_decompose97i(b4, width); if(y+4 < height) horizontal_decompose97i(b5, width); if(width>400){ STOP_TIMER("horizontal_decompose97i") }} {START_TIMER if(b3 <= b5) vertical_decompose97iH0(b3, b4, b5, width); if(b2 <= b4) vertical_decompose97iL0(b2, b3, b4, width); if(b1 <= b3) vertical_decompose97iH1(b1, b2, b3, width); if(b0 <= b2) vertical_decompose97iL1(b0, b1, b2, width); if(width>400){ STOP_TIMER("vertical_decompose97i") }} b0=b2; b1=b3; b2=b4; b3=b5; } }
{ "code": [ " if(b3 <= b5) horizontal_decompose97i(b4, width);", " if(y+4 < height) horizontal_decompose97i(b5, width);", " if(b3 <= b5) vertical_decompose97iH0(b3, b4, b5, width);", " if(b2 <= b4) vertical_decompose97iL0(b2, b3, b4, width);", " if(b1 <= b3) vertical_decompose97iH1(b1, b2, b3, width);", " if(b0 <= b2) vertical_decompose97iL1(b0, b1, b2, width);" ], "line_no": [ 25, 27, 39, 41, 43, 45 ] }
static void FUNC_0(DWTELEM *VAR_0, int VAR_1, int VAR_2, int VAR_3){ int VAR_4; DWTELEM *b0= VAR_0 + mirror(-4-1, VAR_2-1)*VAR_3; DWTELEM *b1= VAR_0 + mirror(-4 , VAR_2-1)*VAR_3; DWTELEM *b2= VAR_0 + mirror(-4+1, VAR_2-1)*VAR_3; DWTELEM *b3= VAR_0 + mirror(-4+2, VAR_2-1)*VAR_3; for(VAR_4=-4; VAR_4<VAR_2; VAR_4+=2){ DWTELEM *b4= VAR_0 + mirror(VAR_4+3, VAR_2-1)*VAR_3; DWTELEM *b5= VAR_0 + mirror(VAR_4+4, VAR_2-1)*VAR_3; {START_TIMER if(b3 <= b5) horizontal_decompose97i(b4, VAR_1); if(VAR_4+4 < VAR_2) horizontal_decompose97i(b5, VAR_1); if(VAR_1>400){ STOP_TIMER("horizontal_decompose97i") }} {START_TIMER if(b3 <= b5) vertical_decompose97iH0(b3, b4, b5, VAR_1); if(b2 <= b4) vertical_decompose97iL0(b2, b3, b4, VAR_1); if(b1 <= b3) vertical_decompose97iH1(b1, b2, b3, VAR_1); if(b0 <= b2) vertical_decompose97iL1(b0, b1, b2, VAR_1); if(VAR_1>400){ STOP_TIMER("vertical_decompose97i") }} b0=b2; b1=b3; b2=b4; b3=b5; } }
[ "static void FUNC_0(DWTELEM *VAR_0, int VAR_1, int VAR_2, int VAR_3){", "int VAR_4;", "DWTELEM *b0= VAR_0 + mirror(-4-1, VAR_2-1)*VAR_3;", "DWTELEM *b1= VAR_0 + mirror(-4 , VAR_2-1)*VAR_3;", "DWTELEM *b2= VAR_0 + mirror(-4+1, VAR_2-1)*VAR_3;", "DWTELEM *b3= VAR_0 + mirror(-4+2, VAR_2-1)*VAR_3;", "for(VAR_4=-4; VAR_4<VAR_2; VAR_4+=2){", "DWTELEM *b4= VAR_0 + mirror(VAR_4+3, VAR_2-1)*VAR_3;", "DWTELEM *b5= VAR_0 + mirror(VAR_4+4, VAR_2-1)*VAR_3;", "{START_TIMER", "if(b3 <= b5) horizontal_decompose97i(b4, VAR_1);", "if(VAR_4+4 < VAR_2) horizontal_decompose97i(b5, VAR_1);", "if(VAR_1>400){", "STOP_TIMER(\"horizontal_decompose97i\")\n}}", "{START_TIMER", "if(b3 <= b5) vertical_decompose97iH0(b3, b4, b5, VAR_1);", "if(b2 <= b4) vertical_decompose97iL0(b2, b3, b4, VAR_1);", "if(b1 <= b3) vertical_decompose97iH1(b1, b2, b3, VAR_1);", "if(b0 <= b2) vertical_decompose97iL1(b0, b1, b2, VAR_1);", "if(VAR_1>400){", "STOP_TIMER(\"vertical_decompose97i\")\n}}", "b0=b2;", "b1=b3;", "b2=b4;", "b3=b5;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1 ], [ 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31, 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51, 53 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ] ]
6,176
static inline void RENAME(yuy2ToY)(uint8_t *dst, const uint8_t *src, int width, uint32_t *unused) { #if COMPILE_TEMPLATE_MMX __asm__ volatile( "movq "MANGLE(bm01010101)", %%mm2 \n\t" "mov %0, %%"REG_a" \n\t" "1: \n\t" "movq (%1, %%"REG_a",2), %%mm0 \n\t" "movq 8(%1, %%"REG_a",2), %%mm1 \n\t" "pand %%mm2, %%mm0 \n\t" "pand %%mm2, %%mm1 \n\t" "packuswb %%mm1, %%mm0 \n\t" "movq %%mm0, (%2, %%"REG_a") \n\t" "add $8, %%"REG_a" \n\t" " js 1b \n\t" : : "g" ((x86_reg)-width), "r" (src+width*2), "r" (dst+width) : "%"REG_a ); #else int i; for (i=0; i<width; i++) dst[i]= src[2*i]; #endif }
true
FFmpeg
c3ab0004ae4dffc32494ae84dd15cfaa909a7884
static inline void RENAME(yuy2ToY)(uint8_t *dst, const uint8_t *src, int width, uint32_t *unused) { #if COMPILE_TEMPLATE_MMX __asm__ volatile( "movq "MANGLE(bm01010101)", %%mm2 \n\t" "mov %0, %%"REG_a" \n\t" "1: \n\t" "movq (%1, %%"REG_a",2), %%mm0 \n\t" "movq 8(%1, %%"REG_a",2), %%mm1 \n\t" "pand %%mm2, %%mm0 \n\t" "pand %%mm2, %%mm1 \n\t" "packuswb %%mm1, %%mm0 \n\t" "movq %%mm0, (%2, %%"REG_a") \n\t" "add $8, %%"REG_a" \n\t" " js 1b \n\t" : : "g" ((x86_reg)-width), "r" (src+width*2), "r" (dst+width) : "%"REG_a ); #else int i; for (i=0; i<width; i++) dst[i]= src[2*i]; #endif }
{ "code": [ "static inline void RENAME(yuy2ToY)(uint8_t *dst, const uint8_t *src, int width, uint32_t *unused)" ], "line_no": [ 1 ] }
static inline void FUNC_0(yuy2ToY)(uint8_t *dst, const uint8_t *src, int width, uint32_t *unused) { #if COMPILE_TEMPLATE_MMX __asm__ volatile( "movq "MANGLE(bm01010101)", %%mm2 \n\t" "mov %0, %%"REG_a" \n\t" "1: \n\t" "movq (%1, %%"REG_a",2), %%mm0 \n\t" "movq 8(%1, %%"REG_a",2), %%mm1 \n\t" "pand %%mm2, %%mm0 \n\t" "pand %%mm2, %%mm1 \n\t" "packuswb %%mm1, %%mm0 \n\t" "movq %%mm0, (%2, %%"REG_a") \n\t" "add $8, %%"REG_a" \n\t" " js 1b \n\t" : : "g" ((x86_reg)-width), "r" (src+width*2), "r" (dst+width) : "%"REG_a ); #else int VAR_0; for (VAR_0=0; VAR_0<width; VAR_0++) dst[VAR_0]= src[2*VAR_0]; #endif }
[ "static inline void FUNC_0(yuy2ToY)(uint8_t *dst, const uint8_t *src, int width, uint32_t *unused)\n{", "#if COMPILE_TEMPLATE_MMX\n__asm__ volatile(\n\"movq \"MANGLE(bm01010101)\", %%mm2 \\n\\t\"\n\"mov %0, %%\"REG_a\" \\n\\t\"\n\"1: \\n\\t\"\n\"movq (%1, %%\"REG_a\",2), %%mm0 \\n\\t\"\n\"movq 8(%1, %%\"REG_a\",2), %%mm1 \\n\\t\"\n\"pand %%mm2, %%mm0 \\n\\t\"\n\"pand %%mm2, %%mm1 \\n\\t\"\n\"packuswb %%mm1, %%mm0 \\n\\t\"\n\"movq %%mm0, (%2, %%\"REG_a\") \\n\\t\"\n\"add $8, %%\"REG_a\" \\n\\t\"\n\" js 1b \\n\\t\"\n: : \"g\" ((x86_reg)-width), \"r\" (src+width*2), \"r\" (dst+width)\n: \"%\"REG_a\n);", "#else\nint VAR_0;", "for (VAR_0=0; VAR_0<width; VAR_0++)", "dst[VAR_0]= src[2*VAR_0];", "#endif\n}" ]
[ 1, 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 ] ]
6,177
static ssize_t gem_receive(VLANClientState *nc, const uint8_t *buf, size_t size) { unsigned desc[2]; target_phys_addr_t packet_desc_addr, last_desc_addr; GemState *s; unsigned rxbufsize, bytes_to_copy; unsigned rxbuf_offset; uint8_t rxbuf[2048]; uint8_t *rxbuf_ptr; s = DO_UPCAST(NICState, nc, nc)->opaque; /* Do nothing if receive is not enabled. */ if (!(s->regs[GEM_NWCTRL] & GEM_NWCTRL_RXENA)) { return -1; } /* Is this destination MAC address "for us" ? */ if (gem_mac_address_filter(s, buf) == GEM_RX_REJECT) { return -1; } /* Discard packets with receive length error enabled ? */ if (s->regs[GEM_NWCFG] & GEM_NWCFG_LERR_DISC) { unsigned type_len; /* Fish the ethertype / length field out of the RX packet */ type_len = buf[12] << 8 | buf[13]; /* It is a length field, not an ethertype */ if (type_len < 0x600) { if (size < type_len) { /* discard */ return -1; } } } /* * Determine configured receive buffer offset (probably 0) */ rxbuf_offset = (s->regs[GEM_NWCFG] & GEM_NWCFG_BUFF_OFST_M) >> GEM_NWCFG_BUFF_OFST_S; /* The configure size of each receive buffer. Determines how many * buffers needed to hold this packet. */ rxbufsize = ((s->regs[GEM_DMACFG] & GEM_DMACFG_RBUFSZ_M) >> GEM_DMACFG_RBUFSZ_S) * GEM_DMACFG_RBUFSZ_MUL; bytes_to_copy = size; /* Strip of FCS field ? (usually yes) */ if (s->regs[GEM_NWCFG] & GEM_NWCFG_STRIP_FCS) { rxbuf_ptr = (void *)buf; } else { unsigned crc_val; int crc_offset; /* The application wants the FCS field, which QEMU does not provide. * We must try and caclculate one. */ memcpy(rxbuf, buf, size); memset(rxbuf + size, 0, sizeof(rxbuf - size)); rxbuf_ptr = rxbuf; crc_val = cpu_to_le32(crc32(0, rxbuf, MAX(size, 60))); if (size < 60) { crc_offset = 60; } else { crc_offset = size; } memcpy(rxbuf + crc_offset, &crc_val, sizeof(crc_val)); bytes_to_copy += 4; size += 4; } /* Pad to minimum length */ if (size < 64) { size = 64; } DB_PRINT("config bufsize: %d packet size: %ld\n", rxbufsize, size); packet_desc_addr = s->rx_desc_addr; while (1) { DB_PRINT("read descriptor 0x%x\n", packet_desc_addr); /* read current descriptor */ cpu_physical_memory_read(packet_desc_addr, (uint8_t *)&desc[0], sizeof(desc)); /* Descriptor owned by software ? */ if (rx_desc_get_ownership(desc) == 1) { DB_PRINT("descriptor 0x%x owned by sw.\n", packet_desc_addr); s->regs[GEM_RXSTATUS] |= GEM_RXSTATUS_NOBUF; /* Handle interrupt consequences */ gem_update_int_status(s); return -1; } DB_PRINT("copy %d bytes to 0x%x\n", MIN(bytes_to_copy, rxbufsize), rx_desc_get_buffer(desc)); /* * Let's have QEMU lend a helping hand. */ if (rx_desc_get_buffer(desc) == 0) { DB_PRINT("Invalid RX buffer (NULL) for descriptor 0x%x\n", packet_desc_addr); break; } /* Copy packet data to emulated DMA buffer */ cpu_physical_memory_write(rx_desc_get_buffer(desc) + rxbuf_offset, rxbuf_ptr, MIN(bytes_to_copy, rxbufsize)); bytes_to_copy -= MIN(bytes_to_copy, rxbufsize); rxbuf_ptr += MIN(bytes_to_copy, rxbufsize); if (bytes_to_copy == 0) { break; } /* Next descriptor */ if (rx_desc_get_wrap(desc)) { packet_desc_addr = s->regs[GEM_RXQBASE]; } else { packet_desc_addr += 8; } } DB_PRINT("set length: %ld, EOF on descriptor 0x%x\n", size, (unsigned)packet_desc_addr); /* Update last descriptor with EOF and total length */ rx_desc_set_eof(desc); rx_desc_set_length(desc, size); cpu_physical_memory_write(packet_desc_addr, (uint8_t *)&desc[0], sizeof(desc)); /* Advance RX packet descriptor Q */ last_desc_addr = packet_desc_addr; packet_desc_addr = s->rx_desc_addr; s->rx_desc_addr = last_desc_addr; if (rx_desc_get_wrap(desc)) { s->rx_desc_addr = s->regs[GEM_RXQBASE]; } else { s->rx_desc_addr += 8; } DB_PRINT("set SOF, OWN on descriptor 0x%08x\n", packet_desc_addr); /* Count it */ gem_receive_updatestats(s, buf, size); /* Update first descriptor (which could also be the last) */ /* read descriptor */ cpu_physical_memory_read(packet_desc_addr, (uint8_t *)&desc[0], sizeof(desc)); rx_desc_set_sof(desc); rx_desc_set_ownership(desc); cpu_physical_memory_write(packet_desc_addr, (uint8_t *)&desc[0], sizeof(desc)); s->regs[GEM_RXSTATUS] |= GEM_RXSTATUS_FRMRCVD; /* Handle interrupt consequences */ gem_update_int_status(s); return size; }
true
qemu
5fbe02e8bb7c62ee55b8edc5fd688c369164c49c
static ssize_t gem_receive(VLANClientState *nc, const uint8_t *buf, size_t size) { unsigned desc[2]; target_phys_addr_t packet_desc_addr, last_desc_addr; GemState *s; unsigned rxbufsize, bytes_to_copy; unsigned rxbuf_offset; uint8_t rxbuf[2048]; uint8_t *rxbuf_ptr; s = DO_UPCAST(NICState, nc, nc)->opaque; if (!(s->regs[GEM_NWCTRL] & GEM_NWCTRL_RXENA)) { return -1; } if (gem_mac_address_filter(s, buf) == GEM_RX_REJECT) { return -1; } if (s->regs[GEM_NWCFG] & GEM_NWCFG_LERR_DISC) { unsigned type_len; type_len = buf[12] << 8 | buf[13]; if (type_len < 0x600) { if (size < type_len) { return -1; } } } rxbuf_offset = (s->regs[GEM_NWCFG] & GEM_NWCFG_BUFF_OFST_M) >> GEM_NWCFG_BUFF_OFST_S; rxbufsize = ((s->regs[GEM_DMACFG] & GEM_DMACFG_RBUFSZ_M) >> GEM_DMACFG_RBUFSZ_S) * GEM_DMACFG_RBUFSZ_MUL; bytes_to_copy = size; if (s->regs[GEM_NWCFG] & GEM_NWCFG_STRIP_FCS) { rxbuf_ptr = (void *)buf; } else { unsigned crc_val; int crc_offset; memcpy(rxbuf, buf, size); memset(rxbuf + size, 0, sizeof(rxbuf - size)); rxbuf_ptr = rxbuf; crc_val = cpu_to_le32(crc32(0, rxbuf, MAX(size, 60))); if (size < 60) { crc_offset = 60; } else { crc_offset = size; } memcpy(rxbuf + crc_offset, &crc_val, sizeof(crc_val)); bytes_to_copy += 4; size += 4; } if (size < 64) { size = 64; } DB_PRINT("config bufsize: %d packet size: %ld\n", rxbufsize, size); packet_desc_addr = s->rx_desc_addr; while (1) { DB_PRINT("read descriptor 0x%x\n", packet_desc_addr); cpu_physical_memory_read(packet_desc_addr, (uint8_t *)&desc[0], sizeof(desc)); if (rx_desc_get_ownership(desc) == 1) { DB_PRINT("descriptor 0x%x owned by sw.\n", packet_desc_addr); s->regs[GEM_RXSTATUS] |= GEM_RXSTATUS_NOBUF; gem_update_int_status(s); return -1; } DB_PRINT("copy %d bytes to 0x%x\n", MIN(bytes_to_copy, rxbufsize), rx_desc_get_buffer(desc)); if (rx_desc_get_buffer(desc) == 0) { DB_PRINT("Invalid RX buffer (NULL) for descriptor 0x%x\n", packet_desc_addr); break; } cpu_physical_memory_write(rx_desc_get_buffer(desc) + rxbuf_offset, rxbuf_ptr, MIN(bytes_to_copy, rxbufsize)); bytes_to_copy -= MIN(bytes_to_copy, rxbufsize); rxbuf_ptr += MIN(bytes_to_copy, rxbufsize); if (bytes_to_copy == 0) { break; } if (rx_desc_get_wrap(desc)) { packet_desc_addr = s->regs[GEM_RXQBASE]; } else { packet_desc_addr += 8; } } DB_PRINT("set length: %ld, EOF on descriptor 0x%x\n", size, (unsigned)packet_desc_addr); rx_desc_set_eof(desc); rx_desc_set_length(desc, size); cpu_physical_memory_write(packet_desc_addr, (uint8_t *)&desc[0], sizeof(desc)); last_desc_addr = packet_desc_addr; packet_desc_addr = s->rx_desc_addr; s->rx_desc_addr = last_desc_addr; if (rx_desc_get_wrap(desc)) { s->rx_desc_addr = s->regs[GEM_RXQBASE]; } else { s->rx_desc_addr += 8; } DB_PRINT("set SOF, OWN on descriptor 0x%08x\n", packet_desc_addr); gem_receive_updatestats(s, buf, size); cpu_physical_memory_read(packet_desc_addr, (uint8_t *)&desc[0], sizeof(desc)); rx_desc_set_sof(desc); rx_desc_set_ownership(desc); cpu_physical_memory_write(packet_desc_addr, (uint8_t *)&desc[0], sizeof(desc)); s->regs[GEM_RXSTATUS] |= GEM_RXSTATUS_FRMRCVD; gem_update_int_status(s); return size; }
{ "code": [ " memset(rxbuf + size, 0, sizeof(rxbuf - size));" ], "line_no": [ 125 ] }
static ssize_t FUNC_0(VLANClientState *nc, const uint8_t *buf, size_t size) { unsigned VAR_0[2]; target_phys_addr_t packet_desc_addr, last_desc_addr; GemState *s; unsigned VAR_1, VAR_2; unsigned VAR_3; uint8_t rxbuf[2048]; uint8_t *rxbuf_ptr; s = DO_UPCAST(NICState, nc, nc)->opaque; if (!(s->regs[GEM_NWCTRL] & GEM_NWCTRL_RXENA)) { return -1; } if (gem_mac_address_filter(s, buf) == GEM_RX_REJECT) { return -1; } if (s->regs[GEM_NWCFG] & GEM_NWCFG_LERR_DISC) { unsigned VAR_4; VAR_4 = buf[12] << 8 | buf[13]; if (VAR_4 < 0x600) { if (size < VAR_4) { return -1; } } } VAR_3 = (s->regs[GEM_NWCFG] & GEM_NWCFG_BUFF_OFST_M) >> GEM_NWCFG_BUFF_OFST_S; VAR_1 = ((s->regs[GEM_DMACFG] & GEM_DMACFG_RBUFSZ_M) >> GEM_DMACFG_RBUFSZ_S) * GEM_DMACFG_RBUFSZ_MUL; VAR_2 = size; if (s->regs[GEM_NWCFG] & GEM_NWCFG_STRIP_FCS) { rxbuf_ptr = (void *)buf; } else { unsigned VAR_5; int VAR_6; memcpy(rxbuf, buf, size); memset(rxbuf + size, 0, sizeof(rxbuf - size)); rxbuf_ptr = rxbuf; VAR_5 = cpu_to_le32(crc32(0, rxbuf, MAX(size, 60))); if (size < 60) { VAR_6 = 60; } else { VAR_6 = size; } memcpy(rxbuf + VAR_6, &VAR_5, sizeof(VAR_5)); VAR_2 += 4; size += 4; } if (size < 64) { size = 64; } DB_PRINT("config bufsize: %d packet size: %ld\n", VAR_1, size); packet_desc_addr = s->rx_desc_addr; while (1) { DB_PRINT("read descriptor 0x%x\n", packet_desc_addr); cpu_physical_memory_read(packet_desc_addr, (uint8_t *)&VAR_0[0], sizeof(VAR_0)); if (rx_desc_get_ownership(VAR_0) == 1) { DB_PRINT("descriptor 0x%x owned by sw.\n", packet_desc_addr); s->regs[GEM_RXSTATUS] |= GEM_RXSTATUS_NOBUF; gem_update_int_status(s); return -1; } DB_PRINT("copy %d bytes to 0x%x\n", MIN(VAR_2, VAR_1), rx_desc_get_buffer(VAR_0)); if (rx_desc_get_buffer(VAR_0) == 0) { DB_PRINT("Invalid RX buffer (NULL) for descriptor 0x%x\n", packet_desc_addr); break; } cpu_physical_memory_write(rx_desc_get_buffer(VAR_0) + VAR_3, rxbuf_ptr, MIN(VAR_2, VAR_1)); VAR_2 -= MIN(VAR_2, VAR_1); rxbuf_ptr += MIN(VAR_2, VAR_1); if (VAR_2 == 0) { break; } if (rx_desc_get_wrap(VAR_0)) { packet_desc_addr = s->regs[GEM_RXQBASE]; } else { packet_desc_addr += 8; } } DB_PRINT("set length: %ld, EOF on descriptor 0x%x\n", size, (unsigned)packet_desc_addr); rx_desc_set_eof(VAR_0); rx_desc_set_length(VAR_0, size); cpu_physical_memory_write(packet_desc_addr, (uint8_t *)&VAR_0[0], sizeof(VAR_0)); last_desc_addr = packet_desc_addr; packet_desc_addr = s->rx_desc_addr; s->rx_desc_addr = last_desc_addr; if (rx_desc_get_wrap(VAR_0)) { s->rx_desc_addr = s->regs[GEM_RXQBASE]; } else { s->rx_desc_addr += 8; } DB_PRINT("set SOF, OWN on descriptor 0x%08x\n", packet_desc_addr); gem_receive_updatestats(s, buf, size); cpu_physical_memory_read(packet_desc_addr, (uint8_t *)&VAR_0[0], sizeof(VAR_0)); rx_desc_set_sof(VAR_0); rx_desc_set_ownership(VAR_0); cpu_physical_memory_write(packet_desc_addr, (uint8_t *)&VAR_0[0], sizeof(VAR_0)); s->regs[GEM_RXSTATUS] |= GEM_RXSTATUS_FRMRCVD; gem_update_int_status(s); return size; }
[ "static ssize_t FUNC_0(VLANClientState *nc, const uint8_t *buf, size_t size)\n{", "unsigned VAR_0[2];", "target_phys_addr_t packet_desc_addr, last_desc_addr;", "GemState *s;", "unsigned VAR_1, VAR_2;", "unsigned VAR_3;", "uint8_t rxbuf[2048];", "uint8_t *rxbuf_ptr;", "s = DO_UPCAST(NICState, nc, nc)->opaque;", "if (!(s->regs[GEM_NWCTRL] & GEM_NWCTRL_RXENA)) {", "return -1;", "}", "if (gem_mac_address_filter(s, buf) == GEM_RX_REJECT) {", "return -1;", "}", "if (s->regs[GEM_NWCFG] & GEM_NWCFG_LERR_DISC) {", "unsigned VAR_4;", "VAR_4 = buf[12] << 8 | buf[13];", "if (VAR_4 < 0x600) {", "if (size < VAR_4) {", "return -1;", "}", "}", "}", "VAR_3 = (s->regs[GEM_NWCFG] & GEM_NWCFG_BUFF_OFST_M) >>\nGEM_NWCFG_BUFF_OFST_S;", "VAR_1 = ((s->regs[GEM_DMACFG] & GEM_DMACFG_RBUFSZ_M) >>\nGEM_DMACFG_RBUFSZ_S) * GEM_DMACFG_RBUFSZ_MUL;", "VAR_2 = size;", "if (s->regs[GEM_NWCFG] & GEM_NWCFG_STRIP_FCS) {", "rxbuf_ptr = (void *)buf;", "} else {", "unsigned VAR_5;", "int VAR_6;", "memcpy(rxbuf, buf, size);", "memset(rxbuf + size, 0, sizeof(rxbuf - size));", "rxbuf_ptr = rxbuf;", "VAR_5 = cpu_to_le32(crc32(0, rxbuf, MAX(size, 60)));", "if (size < 60) {", "VAR_6 = 60;", "} else {", "VAR_6 = size;", "}", "memcpy(rxbuf + VAR_6, &VAR_5, sizeof(VAR_5));", "VAR_2 += 4;", "size += 4;", "}", "if (size < 64) {", "size = 64;", "}", "DB_PRINT(\"config bufsize: %d packet size: %ld\\n\", VAR_1, size);", "packet_desc_addr = s->rx_desc_addr;", "while (1) {", "DB_PRINT(\"read descriptor 0x%x\\n\", packet_desc_addr);", "cpu_physical_memory_read(packet_desc_addr,\n(uint8_t *)&VAR_0[0], sizeof(VAR_0));", "if (rx_desc_get_ownership(VAR_0) == 1) {", "DB_PRINT(\"descriptor 0x%x owned by sw.\\n\", packet_desc_addr);", "s->regs[GEM_RXSTATUS] |= GEM_RXSTATUS_NOBUF;", "gem_update_int_status(s);", "return -1;", "}", "DB_PRINT(\"copy %d bytes to 0x%x\\n\", MIN(VAR_2, VAR_1),\nrx_desc_get_buffer(VAR_0));", "if (rx_desc_get_buffer(VAR_0) == 0) {", "DB_PRINT(\"Invalid RX buffer (NULL) for descriptor 0x%x\\n\",\npacket_desc_addr);", "break;", "}", "cpu_physical_memory_write(rx_desc_get_buffer(VAR_0) + VAR_3,\nrxbuf_ptr, MIN(VAR_2, VAR_1));", "VAR_2 -= MIN(VAR_2, VAR_1);", "rxbuf_ptr += MIN(VAR_2, VAR_1);", "if (VAR_2 == 0) {", "break;", "}", "if (rx_desc_get_wrap(VAR_0)) {", "packet_desc_addr = s->regs[GEM_RXQBASE];", "} else {", "packet_desc_addr += 8;", "}", "}", "DB_PRINT(\"set length: %ld, EOF on descriptor 0x%x\\n\", size,\n(unsigned)packet_desc_addr);", "rx_desc_set_eof(VAR_0);", "rx_desc_set_length(VAR_0, size);", "cpu_physical_memory_write(packet_desc_addr,\n(uint8_t *)&VAR_0[0], sizeof(VAR_0));", "last_desc_addr = packet_desc_addr;", "packet_desc_addr = s->rx_desc_addr;", "s->rx_desc_addr = last_desc_addr;", "if (rx_desc_get_wrap(VAR_0)) {", "s->rx_desc_addr = s->regs[GEM_RXQBASE];", "} else {", "s->rx_desc_addr += 8;", "}", "DB_PRINT(\"set SOF, OWN on descriptor 0x%08x\\n\", packet_desc_addr);", "gem_receive_updatestats(s, buf, size);", "cpu_physical_memory_read(packet_desc_addr,\n(uint8_t *)&VAR_0[0], sizeof(VAR_0));", "rx_desc_set_sof(VAR_0);", "rx_desc_set_ownership(VAR_0);", "cpu_physical_memory_write(packet_desc_addr,\n(uint8_t *)&VAR_0[0], sizeof(VAR_0));", "s->regs[GEM_RXSTATUS] |= GEM_RXSTATUS_FRMRCVD;", "gem_update_int_status(s);", "return size;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 27 ], [ 29 ], [ 31 ], [ 37 ], [ 39 ], [ 41 ], [ 47 ], [ 49 ], [ 55 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 81, 83 ], [ 93, 95 ], [ 97 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 145 ], [ 147 ], [ 149 ], [ 155 ], [ 157 ], [ 159 ], [ 163 ], [ 167 ], [ 169 ], [ 171 ], [ 175, 177 ], [ 183 ], [ 185 ], [ 187 ], [ 191 ], [ 193 ], [ 195 ], [ 199, 201 ], [ 211 ], [ 213, 215 ], [ 217 ], [ 219 ], [ 225, 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 257, 259 ], [ 265 ], [ 267 ], [ 269, 271 ], [ 277 ], [ 279 ], [ 281 ], [ 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 295 ], [ 301 ], [ 309, 311 ], [ 313 ], [ 315 ], [ 317, 319 ], [ 323 ], [ 329 ], [ 333 ], [ 335 ] ]
6,178
static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc, int size) { if (st->codec->codec_tag == MKTAG('t','m','c','d')) { st->codec->extradata_size = size; st->codec->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) return AVERROR(ENOMEM); avio_read(pb, st->codec->extradata, size); } else { /* other codec type, just skip (rtp, mp4s ...) */ avio_skip(pb, size); } return 0; }
true
FFmpeg
5c720657c23afd798ae0db7c7362eb859a89ab3d
static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc, int size) { if (st->codec->codec_tag == MKTAG('t','m','c','d')) { st->codec->extradata_size = size; st->codec->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) return AVERROR(ENOMEM); avio_read(pb, st->codec->extradata, size); } else { avio_skip(pb, size); } return 0; }
{ "code": [ " avio_read(pb, st->codec->extradata, size);" ], "line_no": [ 19 ] }
static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1, AVStream *VAR_2, MOVStreamContext *VAR_3, int VAR_4) { if (VAR_2->codec->codec_tag == MKTAG('t','m','VAR_0','d')) { VAR_2->codec->extradata_size = VAR_4; VAR_2->codec->extradata = av_malloc(VAR_4 + FF_INPUT_BUFFER_PADDING_SIZE); if (!VAR_2->codec->extradata) return AVERROR(ENOMEM); avio_read(VAR_1, VAR_2->codec->extradata, VAR_4); } else { avio_skip(VAR_1, VAR_4); } return 0; }
[ "static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1,\nAVStream *VAR_2, MOVStreamContext *VAR_3,\nint VAR_4)\n{", "if (VAR_2->codec->codec_tag == MKTAG('t','m','VAR_0','d')) {", "VAR_2->codec->extradata_size = VAR_4;", "VAR_2->codec->extradata = av_malloc(VAR_4 + FF_INPUT_BUFFER_PADDING_SIZE);", "if (!VAR_2->codec->extradata)\nreturn AVERROR(ENOMEM);", "avio_read(VAR_1, VAR_2->codec->extradata, VAR_4);", "} else {", "avio_skip(VAR_1, VAR_4);", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15, 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ] ]
6,179
int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg) { struct kvm_irq_routing_entry kroute; if (!kvm_irqchip_in_kernel()) { return -ENOSYS; } kroute.gsi = virq; kroute.type = KVM_IRQ_ROUTING_MSI; kroute.flags = 0; kroute.u.msi.address_lo = (uint32_t)msg.address; kroute.u.msi.address_hi = msg.address >> 32; kroute.u.msi.data = le32_to_cpu(msg.data); return kvm_update_routing_entry(s, &kroute); }
true
qemu
0fbc20740342713f282b118b4a446c4c43df3f4a
int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg) { struct kvm_irq_routing_entry kroute; if (!kvm_irqchip_in_kernel()) { return -ENOSYS; } kroute.gsi = virq; kroute.type = KVM_IRQ_ROUTING_MSI; kroute.flags = 0; kroute.u.msi.address_lo = (uint32_t)msg.address; kroute.u.msi.address_hi = msg.address >> 32; kroute.u.msi.data = le32_to_cpu(msg.data); return kvm_update_routing_entry(s, &kroute); }
{ "code": [ " struct kvm_irq_routing_entry kroute;", " struct kvm_irq_routing_entry kroute;" ], "line_no": [ 5, 5 ] }
int FUNC_0(KVMState *VAR_0, int VAR_1, MSIMessage VAR_2) { struct kvm_irq_routing_entry VAR_3; if (!kvm_irqchip_in_kernel()) { return -ENOSYS; } VAR_3.gsi = VAR_1; VAR_3.type = KVM_IRQ_ROUTING_MSI; VAR_3.flags = 0; VAR_3.u.msi.address_lo = (uint32_t)VAR_2.address; VAR_3.u.msi.address_hi = VAR_2.address >> 32; VAR_3.u.msi.data = le32_to_cpu(VAR_2.data); return kvm_update_routing_entry(VAR_0, &VAR_3); }
[ "int FUNC_0(KVMState *VAR_0, int VAR_1, MSIMessage VAR_2)\n{", "struct kvm_irq_routing_entry VAR_3;", "if (!kvm_irqchip_in_kernel()) {", "return -ENOSYS;", "}", "VAR_3.gsi = VAR_1;", "VAR_3.type = KVM_IRQ_ROUTING_MSI;", "VAR_3.flags = 0;", "VAR_3.u.msi.address_lo = (uint32_t)VAR_2.address;", "VAR_3.u.msi.address_hi = VAR_2.address >> 32;", "VAR_3.u.msi.data = le32_to_cpu(VAR_2.data);", "return kvm_update_routing_entry(VAR_0, &VAR_3);", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ] ]
6,180
static void rv34_gen_vlc(const uint8_t *bits, int size, VLC *vlc, const uint8_t *insyms, const int num) { int i; int counts[17] = {0}, codes[17]; uint16_t cw[size], syms[size]; uint8_t bits2[size]; int maxbits = 0, realsize = 0; for(i = 0; i < size; i++){ if(bits[i]){ bits2[realsize] = bits[i]; syms[realsize] = insyms ? insyms[i] : i; realsize++; maxbits = FFMAX(maxbits, bits[i]); counts[bits[i]]++; } } codes[0] = 0; for(i = 0; i < 16; i++) codes[i+1] = (codes[i] + counts[i]) << 1; for(i = 0; i < realsize; i++) cw[i] = codes[bits2[i]]++; vlc->table = &table_data[table_offs[num]]; vlc->table_allocated = table_offs[num + 1] - table_offs[num]; init_vlc_sparse(vlc, FFMIN(maxbits, 9), realsize, bits2, 1, 1, cw, 2, 2, syms, 2, 2, INIT_VLC_USE_NEW_STATIC); }
false
FFmpeg
3df18b3ed1177037892ce5b3db113d52dcdcdbf3
static void rv34_gen_vlc(const uint8_t *bits, int size, VLC *vlc, const uint8_t *insyms, const int num) { int i; int counts[17] = {0}, codes[17]; uint16_t cw[size], syms[size]; uint8_t bits2[size]; int maxbits = 0, realsize = 0; for(i = 0; i < size; i++){ if(bits[i]){ bits2[realsize] = bits[i]; syms[realsize] = insyms ? insyms[i] : i; realsize++; maxbits = FFMAX(maxbits, bits[i]); counts[bits[i]]++; } } codes[0] = 0; for(i = 0; i < 16; i++) codes[i+1] = (codes[i] + counts[i]) << 1; for(i = 0; i < realsize; i++) cw[i] = codes[bits2[i]]++; vlc->table = &table_data[table_offs[num]]; vlc->table_allocated = table_offs[num + 1] - table_offs[num]; init_vlc_sparse(vlc, FFMIN(maxbits, 9), realsize, bits2, 1, 1, cw, 2, 2, syms, 2, 2, INIT_VLC_USE_NEW_STATIC); }
{ "code": [], "line_no": [] }
static void FUNC_0(const uint8_t *VAR_0, int VAR_1, VLC *VAR_2, const uint8_t *VAR_3, const int VAR_4) { int VAR_5; int VAR_6[17] = {0}, VAR_7[17]; uint16_t cw[VAR_1], syms[VAR_1]; uint8_t bits2[VAR_1]; int VAR_8 = 0, VAR_9 = 0; for(VAR_5 = 0; VAR_5 < VAR_1; VAR_5++){ if(VAR_0[VAR_5]){ bits2[VAR_9] = VAR_0[VAR_5]; syms[VAR_9] = VAR_3 ? VAR_3[VAR_5] : VAR_5; VAR_9++; VAR_8 = FFMAX(VAR_8, VAR_0[VAR_5]); VAR_6[VAR_0[VAR_5]]++; } } VAR_7[0] = 0; for(VAR_5 = 0; VAR_5 < 16; VAR_5++) VAR_7[VAR_5+1] = (VAR_7[VAR_5] + VAR_6[VAR_5]) << 1; for(VAR_5 = 0; VAR_5 < VAR_9; VAR_5++) cw[VAR_5] = VAR_7[bits2[VAR_5]]++; VAR_2->table = &table_data[table_offs[VAR_4]]; VAR_2->table_allocated = table_offs[VAR_4 + 1] - table_offs[VAR_4]; init_vlc_sparse(VAR_2, FFMIN(VAR_8, 9), VAR_9, bits2, 1, 1, cw, 2, 2, syms, 2, 2, INIT_VLC_USE_NEW_STATIC); }
[ "static void FUNC_0(const uint8_t *VAR_0, int VAR_1, VLC *VAR_2, const uint8_t *VAR_3,\nconst int VAR_4)\n{", "int VAR_5;", "int VAR_6[17] = {0}, VAR_7[17];", "uint16_t cw[VAR_1], syms[VAR_1];", "uint8_t bits2[VAR_1];", "int VAR_8 = 0, VAR_9 = 0;", "for(VAR_5 = 0; VAR_5 < VAR_1; VAR_5++){", "if(VAR_0[VAR_5]){", "bits2[VAR_9] = VAR_0[VAR_5];", "syms[VAR_9] = VAR_3 ? VAR_3[VAR_5] : VAR_5;", "VAR_9++;", "VAR_8 = FFMAX(VAR_8, VAR_0[VAR_5]);", "VAR_6[VAR_0[VAR_5]]++;", "}", "}", "VAR_7[0] = 0;", "for(VAR_5 = 0; VAR_5 < 16; VAR_5++)", "VAR_7[VAR_5+1] = (VAR_7[VAR_5] + VAR_6[VAR_5]) << 1;", "for(VAR_5 = 0; VAR_5 < VAR_9; VAR_5++)", "cw[VAR_5] = VAR_7[bits2[VAR_5]]++;", "VAR_2->table = &table_data[table_offs[VAR_4]];", "VAR_2->table_allocated = table_offs[VAR_4 + 1] - table_offs[VAR_4];", "init_vlc_sparse(VAR_2, FFMIN(VAR_8, 9), VAR_9,\nbits2, 1, 1,\ncw, 2, 2,\nsyms, 2, 2, INIT_VLC_USE_NEW_STATIC);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 55, 57, 59, 61 ], [ 63 ] ]
6,181
static int proxy_lremovexattr(FsContext *ctx, V9fsPath *fs_path, const char *name) { int retval; V9fsString xname; v9fs_string_init(&xname); v9fs_string_sprintf(&xname, "%s", name); retval = v9fs_request(ctx->private, T_LREMOVEXATTR, NULL, "ss", fs_path, &xname); v9fs_string_free(&xname); if (retval < 0) { errno = -retval; } return retval; }
false
qemu
494a8ebe713055d3946183f4b395f85a18b43e9e
static int proxy_lremovexattr(FsContext *ctx, V9fsPath *fs_path, const char *name) { int retval; V9fsString xname; v9fs_string_init(&xname); v9fs_string_sprintf(&xname, "%s", name); retval = v9fs_request(ctx->private, T_LREMOVEXATTR, NULL, "ss", fs_path, &xname); v9fs_string_free(&xname); if (retval < 0) { errno = -retval; } return retval; }
{ "code": [], "line_no": [] }
static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1, const char *VAR_2) { int VAR_3; V9fsString xname; v9fs_string_init(&xname); v9fs_string_sprintf(&xname, "%s", VAR_2); VAR_3 = v9fs_request(VAR_0->private, T_LREMOVEXATTR, NULL, "ss", VAR_1, &xname); v9fs_string_free(&xname); if (VAR_3 < 0) { errno = -VAR_3; } return VAR_3; }
[ "static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,\nconst char *VAR_2)\n{", "int VAR_3;", "V9fsString xname;", "v9fs_string_init(&xname);", "v9fs_string_sprintf(&xname, \"%s\", VAR_2);", "VAR_3 = v9fs_request(VAR_0->private, T_LREMOVEXATTR, NULL, \"ss\",\nVAR_1, &xname);", "v9fs_string_free(&xname);", "if (VAR_3 < 0) {", "errno = -VAR_3;", "}", "return VAR_3;", "}" ]
[ 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 ] ]
6,182
static int get_blocksize(BlockDriverState *bdrv) { uint8_t cmd[10]; uint8_t buf[8]; uint8_t sensebuf[8]; sg_io_hdr_t io_header; int ret; memset(cmd, 0, sizeof(cmd)); memset(buf, 0, sizeof(buf)); cmd[0] = READ_CAPACITY_10; memset(&io_header, 0, sizeof(io_header)); io_header.interface_id = 'S'; io_header.dxfer_direction = SG_DXFER_FROM_DEV; io_header.dxfer_len = sizeof(buf); io_header.dxferp = buf; io_header.cmdp = cmd; io_header.cmd_len = sizeof(cmd); io_header.mx_sb_len = sizeof(sensebuf); io_header.sbp = sensebuf; io_header.timeout = 6000; /* XXX */ ret = bdrv_ioctl(bdrv, SG_IO, &io_header); if (ret < 0) return -1; return (buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7]; }
false
qemu
fe0ed71279eb442b920f0080c763438dbaa09f74
static int get_blocksize(BlockDriverState *bdrv) { uint8_t cmd[10]; uint8_t buf[8]; uint8_t sensebuf[8]; sg_io_hdr_t io_header; int ret; memset(cmd, 0, sizeof(cmd)); memset(buf, 0, sizeof(buf)); cmd[0] = READ_CAPACITY_10; memset(&io_header, 0, sizeof(io_header)); io_header.interface_id = 'S'; io_header.dxfer_direction = SG_DXFER_FROM_DEV; io_header.dxfer_len = sizeof(buf); io_header.dxferp = buf; io_header.cmdp = cmd; io_header.cmd_len = sizeof(cmd); io_header.mx_sb_len = sizeof(sensebuf); io_header.sbp = sensebuf; io_header.timeout = 6000; ret = bdrv_ioctl(bdrv, SG_IO, &io_header); if (ret < 0) return -1; return (buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7]; }
{ "code": [], "line_no": [] }
static int FUNC_0(BlockDriverState *VAR_0) { uint8_t cmd[10]; uint8_t buf[8]; uint8_t sensebuf[8]; sg_io_hdr_t io_header; int VAR_1; memset(cmd, 0, sizeof(cmd)); memset(buf, 0, sizeof(buf)); cmd[0] = READ_CAPACITY_10; memset(&io_header, 0, sizeof(io_header)); io_header.interface_id = 'S'; io_header.dxfer_direction = SG_DXFER_FROM_DEV; io_header.dxfer_len = sizeof(buf); io_header.dxferp = buf; io_header.cmdp = cmd; io_header.cmd_len = sizeof(cmd); io_header.mx_sb_len = sizeof(sensebuf); io_header.sbp = sensebuf; io_header.timeout = 6000; VAR_1 = bdrv_ioctl(VAR_0, SG_IO, &io_header); if (VAR_1 < 0) return -1; return (buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7]; }
[ "static int FUNC_0(BlockDriverState *VAR_0)\n{", "uint8_t cmd[10];", "uint8_t buf[8];", "uint8_t sensebuf[8];", "sg_io_hdr_t io_header;", "int VAR_1;", "memset(cmd, 0, sizeof(cmd));", "memset(buf, 0, sizeof(buf));", "cmd[0] = READ_CAPACITY_10;", "memset(&io_header, 0, sizeof(io_header));", "io_header.interface_id = 'S';", "io_header.dxfer_direction = SG_DXFER_FROM_DEV;", "io_header.dxfer_len = sizeof(buf);", "io_header.dxferp = buf;", "io_header.cmdp = cmd;", "io_header.cmd_len = sizeof(cmd);", "io_header.mx_sb_len = sizeof(sensebuf);", "io_header.sbp = sensebuf;", "io_header.timeout = 6000;", "VAR_1 = bdrv_ioctl(VAR_0, SG_IO, &io_header);", "if (VAR_1 < 0)\nreturn -1;", "return (buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7];", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49, 51 ], [ 55 ], [ 57 ] ]
6,184
ssize_t nbd_receive_reply(int csock, struct nbd_reply *reply) { uint8_t buf[NBD_REPLY_SIZE]; uint32_t magic; if (read_sync(csock, buf, sizeof(buf)) != sizeof(buf)) { LOG("read failed"); errno = EINVAL; return -1; } /* Reply [ 0 .. 3] magic (NBD_REPLY_MAGIC) [ 4 .. 7] error (0 == no error) [ 7 .. 15] handle */ magic = be32_to_cpup((uint32_t*)buf); reply->error = be32_to_cpup((uint32_t*)(buf + 4)); reply->handle = be64_to_cpup((uint64_t*)(buf + 8)); TRACE("Got reply: " "{ magic = 0x%x, .error = %d, handle = %" PRIu64" }", magic, reply->error, reply->handle); if (magic != NBD_REPLY_MAGIC) { LOG("invalid magic (got 0x%x)", magic); errno = EINVAL; return -1; } return 0; }
false
qemu
185b43386ad999c80bdc58e41b87f05e5b3e8463
ssize_t nbd_receive_reply(int csock, struct nbd_reply *reply) { uint8_t buf[NBD_REPLY_SIZE]; uint32_t magic; if (read_sync(csock, buf, sizeof(buf)) != sizeof(buf)) { LOG("read failed"); errno = EINVAL; return -1; } magic = be32_to_cpup((uint32_t*)buf); reply->error = be32_to_cpup((uint32_t*)(buf + 4)); reply->handle = be64_to_cpup((uint64_t*)(buf + 8)); TRACE("Got reply: " "{ magic = 0x%x, .error = %d, handle = %" PRIu64" }", magic, reply->error, reply->handle); if (magic != NBD_REPLY_MAGIC) { LOG("invalid magic (got 0x%x)", magic); errno = EINVAL; return -1; } return 0; }
{ "code": [], "line_no": [] }
ssize_t FUNC_0(int csock, struct nbd_reply *reply) { uint8_t buf[NBD_REPLY_SIZE]; uint32_t magic; if (read_sync(csock, buf, sizeof(buf)) != sizeof(buf)) { LOG("read failed"); errno = EINVAL; return -1; } magic = be32_to_cpup((uint32_t*)buf); reply->error = be32_to_cpup((uint32_t*)(buf + 4)); reply->handle = be64_to_cpup((uint64_t*)(buf + 8)); TRACE("Got reply: " "{ magic = 0x%x, .error = %d, handle = %" PRIu64" }", magic, reply->error, reply->handle); if (magic != NBD_REPLY_MAGIC) { LOG("invalid magic (got 0x%x)", magic); errno = EINVAL; return -1; } return 0; }
[ "ssize_t FUNC_0(int csock, struct nbd_reply *reply)\n{", "uint8_t buf[NBD_REPLY_SIZE];", "uint32_t magic;", "if (read_sync(csock, buf, sizeof(buf)) != sizeof(buf)) {", "LOG(\"read failed\");", "errno = EINVAL;", "return -1;", "}", "magic = be32_to_cpup((uint32_t*)buf);", "reply->error = be32_to_cpup((uint32_t*)(buf + 4));", "reply->handle = be64_to_cpup((uint64_t*)(buf + 8));", "TRACE(\"Got reply: \"\n\"{ magic = 0x%x, .error = %d, handle = %\" PRIu64\" }\",", "magic, reply->error, reply->handle);", "if (magic != NBD_REPLY_MAGIC) {", "LOG(\"invalid magic (got 0x%x)\", magic);", "errno = EINVAL;", "return -1;", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 35 ], [ 37 ], [ 39 ], [ 43, 45 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ] ]
6,187
static void usb_mouse_class_initfn(ObjectClass *klass, void *data) { USBDeviceClass *uc = USB_DEVICE_CLASS(klass); uc->init = usb_mouse_initfn; uc->product_desc = "QEMU USB Mouse"; uc->usb_desc = &desc_mouse; uc->handle_packet = usb_generic_handle_packet; uc->handle_reset = usb_hid_handle_reset; uc->handle_control = usb_hid_handle_control; uc->handle_data = usb_hid_handle_data; uc->handle_destroy = usb_hid_handle_destroy; }
false
qemu
7f595609b49615b07c50b7182c4ef125c39cb5da
static void usb_mouse_class_initfn(ObjectClass *klass, void *data) { USBDeviceClass *uc = USB_DEVICE_CLASS(klass); uc->init = usb_mouse_initfn; uc->product_desc = "QEMU USB Mouse"; uc->usb_desc = &desc_mouse; uc->handle_packet = usb_generic_handle_packet; uc->handle_reset = usb_hid_handle_reset; uc->handle_control = usb_hid_handle_control; uc->handle_data = usb_hid_handle_data; uc->handle_destroy = usb_hid_handle_destroy; }
{ "code": [], "line_no": [] }
static void FUNC_0(ObjectClass *VAR_0, void *VAR_1) { USBDeviceClass *uc = USB_DEVICE_CLASS(VAR_0); uc->init = usb_mouse_initfn; uc->product_desc = "QEMU USB Mouse"; uc->usb_desc = &desc_mouse; uc->handle_packet = usb_generic_handle_packet; uc->handle_reset = usb_hid_handle_reset; uc->handle_control = usb_hid_handle_control; uc->handle_data = usb_hid_handle_data; uc->handle_destroy = usb_hid_handle_destroy; }
[ "static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{", "USBDeviceClass *uc = USB_DEVICE_CLASS(VAR_0);", "uc->init = usb_mouse_initfn;", "uc->product_desc = \"QEMU USB Mouse\";", "uc->usb_desc = &desc_mouse;", "uc->handle_packet = usb_generic_handle_packet;", "uc->handle_reset = usb_hid_handle_reset;", "uc->handle_control = usb_hid_handle_control;", "uc->handle_data = usb_hid_handle_data;", "uc->handle_destroy = usb_hid_handle_destroy;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ] ]
6,188
static void test_validate_fail_struct_nested(TestInputVisitorData *data, const void *unused) { UserDefNested *udp = NULL; Error *err = NULL; Visitor *v; v = validate_test_init(data, "{ 'string0': 'string0', 'dict1': { 'string1': 'string1', 'dict2': { 'userdef1': { 'integer': 42, 'string': 'string', 'extra': [42, 23, {'foo':'bar'}] }, 'string2': 'string2'}}}"); visit_type_UserDefNested(v, &udp, NULL, &err); g_assert(err); qapi_free_UserDefNested(udp); }
false
qemu
b6fcf32d9b851a83dedcb609091236b97cc4a985
static void test_validate_fail_struct_nested(TestInputVisitorData *data, const void *unused) { UserDefNested *udp = NULL; Error *err = NULL; Visitor *v; v = validate_test_init(data, "{ 'string0': 'string0', 'dict1': { 'string1': 'string1', 'dict2': { 'userdef1': { 'integer': 42, 'string': 'string', 'extra': [42, 23, {'foo':'bar'}] }, 'string2': 'string2'}}}"); visit_type_UserDefNested(v, &udp, NULL, &err); g_assert(err); qapi_free_UserDefNested(udp); }
{ "code": [], "line_no": [] }
static void FUNC_0(TestInputVisitorData *VAR_0, const void *VAR_1) { UserDefNested *udp = NULL; Error *err = NULL; Visitor *v; v = validate_test_init(VAR_0, "{ 'string0': 'string0', 'dict1': { 'string1': 'string1', 'dict2': { 'userdef1': { 'integer': 42, 'string': 'string', 'extra': [42, 23, {'foo':'bar'}] }, 'string2': 'string2'}}}"); visit_type_UserDefNested(v, &udp, NULL, &err); g_assert(err); qapi_free_UserDefNested(udp); }
[ "static void FUNC_0(TestInputVisitorData *VAR_0,\nconst void *VAR_1)\n{", "UserDefNested *udp = NULL;", "Error *err = NULL;", "Visitor *v;", "v = validate_test_init(VAR_0, \"{ 'string0': 'string0', 'dict1': { 'string1': 'string1', 'dict2': { 'userdef1': { 'integer': 42, 'string': 'string', 'extra': [42, 23, {'foo':'bar'}] }, 'string2': 'string2'}}}\");", "visit_type_UserDefNested(v, &udp, NULL, &err);", "g_assert(err);", "qapi_free_UserDefNested(udp);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ] ]
6,190
static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table, int l1_size, int64_t *visited_l1_entries, int64_t l1_entries, BlockDriverAmendStatusCB *status_cb) { BDRVQcowState *s = bs->opaque; bool is_active_l1 = (l1_table == s->l1_table); uint64_t *l2_table = NULL; int ret; int i, j; if (!is_active_l1) { /* inactive L2 tables require a buffer to be stored in when loading * them from disk */ l2_table = qemu_try_blockalign(bs->file, s->cluster_size); if (l2_table == NULL) { return -ENOMEM; } } for (i = 0; i < l1_size; i++) { uint64_t l2_offset = l1_table[i] & L1E_OFFSET_MASK; bool l2_dirty = false; uint64_t l2_refcount; if (!l2_offset) { /* unallocated */ (*visited_l1_entries)++; if (status_cb) { status_cb(bs, *visited_l1_entries, l1_entries); } continue; } if (offset_into_cluster(s, l2_offset)) { qcow2_signal_corruption(bs, true, -1, -1, "L2 table offset %#" PRIx64 " unaligned (L1 index: %#x)", l2_offset, i); ret = -EIO; goto fail; } if (is_active_l1) { /* get active L2 tables from cache */ ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset, (void **)&l2_table); } else { /* load inactive L2 tables from disk */ ret = bdrv_read(bs->file, l2_offset / BDRV_SECTOR_SIZE, (void *)l2_table, s->cluster_sectors); } if (ret < 0) { goto fail; } ret = qcow2_get_refcount(bs, l2_offset >> s->cluster_bits, &l2_refcount); if (ret < 0) { goto fail; } for (j = 0; j < s->l2_size; j++) { uint64_t l2_entry = be64_to_cpu(l2_table[j]); int64_t offset = l2_entry & L2E_OFFSET_MASK; int cluster_type = qcow2_get_cluster_type(l2_entry); bool preallocated = offset != 0; if (cluster_type != QCOW2_CLUSTER_ZERO) { continue; } if (!preallocated) { if (!bs->backing_hd) { /* not backed; therefore we can simply deallocate the * cluster */ l2_table[j] = 0; l2_dirty = true; continue; } offset = qcow2_alloc_clusters(bs, s->cluster_size); if (offset < 0) { ret = offset; goto fail; } if (l2_refcount > 1) { /* For shared L2 tables, set the refcount accordingly (it is * already 1 and needs to be l2_refcount) */ ret = qcow2_update_cluster_refcount(bs, offset >> s->cluster_bits, refcount_diff(1, l2_refcount), false, QCOW2_DISCARD_OTHER); if (ret < 0) { qcow2_free_clusters(bs, offset, s->cluster_size, QCOW2_DISCARD_OTHER); goto fail; } } } if (offset_into_cluster(s, offset)) { qcow2_signal_corruption(bs, true, -1, -1, "Data cluster offset " "%#" PRIx64 " unaligned (L2 offset: %#" PRIx64 ", L2 index: %#x)", offset, l2_offset, j); if (!preallocated) { qcow2_free_clusters(bs, offset, s->cluster_size, QCOW2_DISCARD_ALWAYS); } ret = -EIO; goto fail; } ret = qcow2_pre_write_overlap_check(bs, 0, offset, s->cluster_size); if (ret < 0) { if (!preallocated) { qcow2_free_clusters(bs, offset, s->cluster_size, QCOW2_DISCARD_ALWAYS); } goto fail; } ret = bdrv_write_zeroes(bs->file, offset / BDRV_SECTOR_SIZE, s->cluster_sectors, 0); if (ret < 0) { if (!preallocated) { qcow2_free_clusters(bs, offset, s->cluster_size, QCOW2_DISCARD_ALWAYS); } goto fail; } if (l2_refcount == 1) { l2_table[j] = cpu_to_be64(offset | QCOW_OFLAG_COPIED); } else { l2_table[j] = cpu_to_be64(offset); } l2_dirty = true; } if (is_active_l1) { if (l2_dirty) { qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table); qcow2_cache_depends_on_flush(s->l2_table_cache); } ret = qcow2_cache_put(bs, s->l2_table_cache, (void **)&l2_table); if (ret < 0) { l2_table = NULL; goto fail; } } else { if (l2_dirty) { ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_INACTIVE_L2 | QCOW2_OL_ACTIVE_L2, l2_offset, s->cluster_size); if (ret < 0) { goto fail; } ret = bdrv_write(bs->file, l2_offset / BDRV_SECTOR_SIZE, (void *)l2_table, s->cluster_sectors); if (ret < 0) { goto fail; } } } (*visited_l1_entries)++; if (status_cb) { status_cb(bs, *visited_l1_entries, l1_entries); } } ret = 0; fail: if (l2_table) { if (!is_active_l1) { qemu_vfree(l2_table); } else { if (ret < 0) { qcow2_cache_put(bs, s->l2_table_cache, (void **)&l2_table); } else { ret = qcow2_cache_put(bs, s->l2_table_cache, (void **)&l2_table); } } } return ret; }
false
qemu
a3f1afb43a09e4577571c044c48f2ba9e6e4ad06
static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table, int l1_size, int64_t *visited_l1_entries, int64_t l1_entries, BlockDriverAmendStatusCB *status_cb) { BDRVQcowState *s = bs->opaque; bool is_active_l1 = (l1_table == s->l1_table); uint64_t *l2_table = NULL; int ret; int i, j; if (!is_active_l1) { l2_table = qemu_try_blockalign(bs->file, s->cluster_size); if (l2_table == NULL) { return -ENOMEM; } } for (i = 0; i < l1_size; i++) { uint64_t l2_offset = l1_table[i] & L1E_OFFSET_MASK; bool l2_dirty = false; uint64_t l2_refcount; if (!l2_offset) { (*visited_l1_entries)++; if (status_cb) { status_cb(bs, *visited_l1_entries, l1_entries); } continue; } if (offset_into_cluster(s, l2_offset)) { qcow2_signal_corruption(bs, true, -1, -1, "L2 table offset %#" PRIx64 " unaligned (L1 index: %#x)", l2_offset, i); ret = -EIO; goto fail; } if (is_active_l1) { ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset, (void **)&l2_table); } else { ret = bdrv_read(bs->file, l2_offset / BDRV_SECTOR_SIZE, (void *)l2_table, s->cluster_sectors); } if (ret < 0) { goto fail; } ret = qcow2_get_refcount(bs, l2_offset >> s->cluster_bits, &l2_refcount); if (ret < 0) { goto fail; } for (j = 0; j < s->l2_size; j++) { uint64_t l2_entry = be64_to_cpu(l2_table[j]); int64_t offset = l2_entry & L2E_OFFSET_MASK; int cluster_type = qcow2_get_cluster_type(l2_entry); bool preallocated = offset != 0; if (cluster_type != QCOW2_CLUSTER_ZERO) { continue; } if (!preallocated) { if (!bs->backing_hd) { l2_table[j] = 0; l2_dirty = true; continue; } offset = qcow2_alloc_clusters(bs, s->cluster_size); if (offset < 0) { ret = offset; goto fail; } if (l2_refcount > 1) { ret = qcow2_update_cluster_refcount(bs, offset >> s->cluster_bits, refcount_diff(1, l2_refcount), false, QCOW2_DISCARD_OTHER); if (ret < 0) { qcow2_free_clusters(bs, offset, s->cluster_size, QCOW2_DISCARD_OTHER); goto fail; } } } if (offset_into_cluster(s, offset)) { qcow2_signal_corruption(bs, true, -1, -1, "Data cluster offset " "%#" PRIx64 " unaligned (L2 offset: %#" PRIx64 ", L2 index: %#x)", offset, l2_offset, j); if (!preallocated) { qcow2_free_clusters(bs, offset, s->cluster_size, QCOW2_DISCARD_ALWAYS); } ret = -EIO; goto fail; } ret = qcow2_pre_write_overlap_check(bs, 0, offset, s->cluster_size); if (ret < 0) { if (!preallocated) { qcow2_free_clusters(bs, offset, s->cluster_size, QCOW2_DISCARD_ALWAYS); } goto fail; } ret = bdrv_write_zeroes(bs->file, offset / BDRV_SECTOR_SIZE, s->cluster_sectors, 0); if (ret < 0) { if (!preallocated) { qcow2_free_clusters(bs, offset, s->cluster_size, QCOW2_DISCARD_ALWAYS); } goto fail; } if (l2_refcount == 1) { l2_table[j] = cpu_to_be64(offset | QCOW_OFLAG_COPIED); } else { l2_table[j] = cpu_to_be64(offset); } l2_dirty = true; } if (is_active_l1) { if (l2_dirty) { qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table); qcow2_cache_depends_on_flush(s->l2_table_cache); } ret = qcow2_cache_put(bs, s->l2_table_cache, (void **)&l2_table); if (ret < 0) { l2_table = NULL; goto fail; } } else { if (l2_dirty) { ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_INACTIVE_L2 | QCOW2_OL_ACTIVE_L2, l2_offset, s->cluster_size); if (ret < 0) { goto fail; } ret = bdrv_write(bs->file, l2_offset / BDRV_SECTOR_SIZE, (void *)l2_table, s->cluster_sectors); if (ret < 0) { goto fail; } } } (*visited_l1_entries)++; if (status_cb) { status_cb(bs, *visited_l1_entries, l1_entries); } } ret = 0; fail: if (l2_table) { if (!is_active_l1) { qemu_vfree(l2_table); } else { if (ret < 0) { qcow2_cache_put(bs, s->l2_table_cache, (void **)&l2_table); } else { ret = qcow2_cache_put(bs, s->l2_table_cache, (void **)&l2_table); } } } return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(BlockDriverState *VAR_0, uint64_t *VAR_1, int VAR_2, int64_t *VAR_3, int64_t VAR_4, BlockDriverAmendStatusCB *VAR_5) { BDRVQcowState *s = VAR_0->opaque; bool is_active_l1 = (VAR_1 == s->VAR_1); uint64_t *l2_table = NULL; int VAR_6; int VAR_7, VAR_8; if (!is_active_l1) { l2_table = qemu_try_blockalign(VAR_0->file, s->cluster_size); if (l2_table == NULL) { return -ENOMEM; } } for (VAR_7 = 0; VAR_7 < VAR_2; VAR_7++) { uint64_t l2_offset = VAR_1[VAR_7] & L1E_OFFSET_MASK; bool l2_dirty = false; uint64_t l2_refcount; if (!l2_offset) { (*VAR_3)++; if (VAR_5) { VAR_5(VAR_0, *VAR_3, VAR_4); } continue; } if (offset_into_cluster(s, l2_offset)) { qcow2_signal_corruption(VAR_0, true, -1, -1, "L2 table offset %#" PRIx64 " unaligned (L1 index: %#x)", l2_offset, VAR_7); VAR_6 = -EIO; goto fail; } if (is_active_l1) { VAR_6 = qcow2_cache_get(VAR_0, s->l2_table_cache, l2_offset, (void **)&l2_table); } else { VAR_6 = bdrv_read(VAR_0->file, l2_offset / BDRV_SECTOR_SIZE, (void *)l2_table, s->cluster_sectors); } if (VAR_6 < 0) { goto fail; } VAR_6 = qcow2_get_refcount(VAR_0, l2_offset >> s->cluster_bits, &l2_refcount); if (VAR_6 < 0) { goto fail; } for (VAR_8 = 0; VAR_8 < s->l2_size; VAR_8++) { uint64_t l2_entry = be64_to_cpu(l2_table[VAR_8]); int64_t offset = l2_entry & L2E_OFFSET_MASK; int cluster_type = qcow2_get_cluster_type(l2_entry); bool preallocated = offset != 0; if (cluster_type != QCOW2_CLUSTER_ZERO) { continue; } if (!preallocated) { if (!VAR_0->backing_hd) { l2_table[VAR_8] = 0; l2_dirty = true; continue; } offset = qcow2_alloc_clusters(VAR_0, s->cluster_size); if (offset < 0) { VAR_6 = offset; goto fail; } if (l2_refcount > 1) { VAR_6 = qcow2_update_cluster_refcount(VAR_0, offset >> s->cluster_bits, refcount_diff(1, l2_refcount), false, QCOW2_DISCARD_OTHER); if (VAR_6 < 0) { qcow2_free_clusters(VAR_0, offset, s->cluster_size, QCOW2_DISCARD_OTHER); goto fail; } } } if (offset_into_cluster(s, offset)) { qcow2_signal_corruption(VAR_0, true, -1, -1, "Data cluster offset " "%#" PRIx64 " unaligned (L2 offset: %#" PRIx64 ", L2 index: %#x)", offset, l2_offset, VAR_8); if (!preallocated) { qcow2_free_clusters(VAR_0, offset, s->cluster_size, QCOW2_DISCARD_ALWAYS); } VAR_6 = -EIO; goto fail; } VAR_6 = qcow2_pre_write_overlap_check(VAR_0, 0, offset, s->cluster_size); if (VAR_6 < 0) { if (!preallocated) { qcow2_free_clusters(VAR_0, offset, s->cluster_size, QCOW2_DISCARD_ALWAYS); } goto fail; } VAR_6 = bdrv_write_zeroes(VAR_0->file, offset / BDRV_SECTOR_SIZE, s->cluster_sectors, 0); if (VAR_6 < 0) { if (!preallocated) { qcow2_free_clusters(VAR_0, offset, s->cluster_size, QCOW2_DISCARD_ALWAYS); } goto fail; } if (l2_refcount == 1) { l2_table[VAR_8] = cpu_to_be64(offset | QCOW_OFLAG_COPIED); } else { l2_table[VAR_8] = cpu_to_be64(offset); } l2_dirty = true; } if (is_active_l1) { if (l2_dirty) { qcow2_cache_entry_mark_dirty(VAR_0, s->l2_table_cache, l2_table); qcow2_cache_depends_on_flush(s->l2_table_cache); } VAR_6 = qcow2_cache_put(VAR_0, s->l2_table_cache, (void **)&l2_table); if (VAR_6 < 0) { l2_table = NULL; goto fail; } } else { if (l2_dirty) { VAR_6 = qcow2_pre_write_overlap_check(VAR_0, QCOW2_OL_INACTIVE_L2 | QCOW2_OL_ACTIVE_L2, l2_offset, s->cluster_size); if (VAR_6 < 0) { goto fail; } VAR_6 = bdrv_write(VAR_0->file, l2_offset / BDRV_SECTOR_SIZE, (void *)l2_table, s->cluster_sectors); if (VAR_6 < 0) { goto fail; } } } (*VAR_3)++; if (VAR_5) { VAR_5(VAR_0, *VAR_3, VAR_4); } } VAR_6 = 0; fail: if (l2_table) { if (!is_active_l1) { qemu_vfree(l2_table); } else { if (VAR_6 < 0) { qcow2_cache_put(VAR_0, s->l2_table_cache, (void **)&l2_table); } else { VAR_6 = qcow2_cache_put(VAR_0, s->l2_table_cache, (void **)&l2_table); } } } return VAR_6; }
[ "static int FUNC_0(BlockDriverState *VAR_0, uint64_t *VAR_1,\nint VAR_2, int64_t *VAR_3,\nint64_t VAR_4,\nBlockDriverAmendStatusCB *VAR_5)\n{", "BDRVQcowState *s = VAR_0->opaque;", "bool is_active_l1 = (VAR_1 == s->VAR_1);", "uint64_t *l2_table = NULL;", "int VAR_6;", "int VAR_7, VAR_8;", "if (!is_active_l1) {", "l2_table = qemu_try_blockalign(VAR_0->file, s->cluster_size);", "if (l2_table == NULL) {", "return -ENOMEM;", "}", "}", "for (VAR_7 = 0; VAR_7 < VAR_2; VAR_7++) {", "uint64_t l2_offset = VAR_1[VAR_7] & L1E_OFFSET_MASK;", "bool l2_dirty = false;", "uint64_t l2_refcount;", "if (!l2_offset) {", "(*VAR_3)++;", "if (VAR_5) {", "VAR_5(VAR_0, *VAR_3, VAR_4);", "}", "continue;", "}", "if (offset_into_cluster(s, l2_offset)) {", "qcow2_signal_corruption(VAR_0, true, -1, -1, \"L2 table offset %#\"\nPRIx64 \" unaligned (L1 index: %#x)\",\nl2_offset, VAR_7);", "VAR_6 = -EIO;", "goto fail;", "}", "if (is_active_l1) {", "VAR_6 = qcow2_cache_get(VAR_0, s->l2_table_cache, l2_offset,\n(void **)&l2_table);", "} else {", "VAR_6 = bdrv_read(VAR_0->file, l2_offset / BDRV_SECTOR_SIZE,\n(void *)l2_table, s->cluster_sectors);", "}", "if (VAR_6 < 0) {", "goto fail;", "}", "VAR_6 = qcow2_get_refcount(VAR_0, l2_offset >> s->cluster_bits,\n&l2_refcount);", "if (VAR_6 < 0) {", "goto fail;", "}", "for (VAR_8 = 0; VAR_8 < s->l2_size; VAR_8++) {", "uint64_t l2_entry = be64_to_cpu(l2_table[VAR_8]);", "int64_t offset = l2_entry & L2E_OFFSET_MASK;", "int cluster_type = qcow2_get_cluster_type(l2_entry);", "bool preallocated = offset != 0;", "if (cluster_type != QCOW2_CLUSTER_ZERO) {", "continue;", "}", "if (!preallocated) {", "if (!VAR_0->backing_hd) {", "l2_table[VAR_8] = 0;", "l2_dirty = true;", "continue;", "}", "offset = qcow2_alloc_clusters(VAR_0, s->cluster_size);", "if (offset < 0) {", "VAR_6 = offset;", "goto fail;", "}", "if (l2_refcount > 1) {", "VAR_6 = qcow2_update_cluster_refcount(VAR_0,\noffset >> s->cluster_bits,\nrefcount_diff(1, l2_refcount), false,\nQCOW2_DISCARD_OTHER);", "if (VAR_6 < 0) {", "qcow2_free_clusters(VAR_0, offset, s->cluster_size,\nQCOW2_DISCARD_OTHER);", "goto fail;", "}", "}", "}", "if (offset_into_cluster(s, offset)) {", "qcow2_signal_corruption(VAR_0, true, -1, -1, \"Data cluster offset \"\n\"%#\" PRIx64 \" unaligned (L2 offset: %#\"\nPRIx64 \", L2 index: %#x)\", offset,\nl2_offset, VAR_8);", "if (!preallocated) {", "qcow2_free_clusters(VAR_0, offset, s->cluster_size,\nQCOW2_DISCARD_ALWAYS);", "}", "VAR_6 = -EIO;", "goto fail;", "}", "VAR_6 = qcow2_pre_write_overlap_check(VAR_0, 0, offset, s->cluster_size);", "if (VAR_6 < 0) {", "if (!preallocated) {", "qcow2_free_clusters(VAR_0, offset, s->cluster_size,\nQCOW2_DISCARD_ALWAYS);", "}", "goto fail;", "}", "VAR_6 = bdrv_write_zeroes(VAR_0->file, offset / BDRV_SECTOR_SIZE,\ns->cluster_sectors, 0);", "if (VAR_6 < 0) {", "if (!preallocated) {", "qcow2_free_clusters(VAR_0, offset, s->cluster_size,\nQCOW2_DISCARD_ALWAYS);", "}", "goto fail;", "}", "if (l2_refcount == 1) {", "l2_table[VAR_8] = cpu_to_be64(offset | QCOW_OFLAG_COPIED);", "} else {", "l2_table[VAR_8] = cpu_to_be64(offset);", "}", "l2_dirty = true;", "}", "if (is_active_l1) {", "if (l2_dirty) {", "qcow2_cache_entry_mark_dirty(VAR_0, s->l2_table_cache, l2_table);", "qcow2_cache_depends_on_flush(s->l2_table_cache);", "}", "VAR_6 = qcow2_cache_put(VAR_0, s->l2_table_cache, (void **)&l2_table);", "if (VAR_6 < 0) {", "l2_table = NULL;", "goto fail;", "}", "} else {", "if (l2_dirty) {", "VAR_6 = qcow2_pre_write_overlap_check(VAR_0,\nQCOW2_OL_INACTIVE_L2 | QCOW2_OL_ACTIVE_L2, l2_offset,\ns->cluster_size);", "if (VAR_6 < 0) {", "goto fail;", "}", "VAR_6 = bdrv_write(VAR_0->file, l2_offset / BDRV_SECTOR_SIZE,\n(void *)l2_table, s->cluster_sectors);", "if (VAR_6 < 0) {", "goto fail;", "}", "}", "}", "(*VAR_3)++;", "if (VAR_5) {", "VAR_5(VAR_0, *VAR_3, VAR_4);", "}", "}", "VAR_6 = 0;", "fail:\nif (l2_table) {", "if (!is_active_l1) {", "qemu_vfree(l2_table);", "} else {", "if (VAR_6 < 0) {", "qcow2_cache_put(VAR_0, s->l2_table_cache, (void **)&l2_table);", "} else {", "VAR_6 = qcow2_cache_put(VAR_0, s->l2_table_cache,\n(void **)&l2_table);", "}", "}", "}", "return VAR_6;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71, 73, 75 ], [ 77 ], [ 79 ], [ 81 ], [ 85 ], [ 89, 91 ], [ 93 ], [ 97, 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 111, 113 ], [ 115 ], [ 117 ], [ 119 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 135 ], [ 137 ], [ 139 ], [ 143 ], [ 145 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 173 ], [ 179, 181, 183, 185 ], [ 187 ], [ 189, 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 203 ], [ 205, 207, 209, 211 ], [ 213 ], [ 215, 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 229 ], [ 231 ], [ 233 ], [ 235, 237 ], [ 239 ], [ 241 ], [ 243 ], [ 247, 249 ], [ 251 ], [ 253 ], [ 255, 257 ], [ 259 ], [ 261 ], [ 263 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 277 ], [ 279 ], [ 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ], [ 299 ], [ 301 ], [ 303 ], [ 305 ], [ 307, 309, 311 ], [ 313 ], [ 315 ], [ 317 ], [ 321, 323 ], [ 325 ], [ 327 ], [ 329 ], [ 331 ], [ 333 ], [ 337 ], [ 339 ], [ 341 ], [ 343 ], [ 345 ], [ 349 ], [ 353, 355 ], [ 357 ], [ 359 ], [ 361 ], [ 363 ], [ 365 ], [ 367 ], [ 369, 371 ], [ 373 ], [ 375 ], [ 377 ], [ 379 ], [ 381 ] ]
6,191
static int request_frame(AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; TrimContext *s = ctx->priv; int ret; s->got_output = 0; while (!s->got_output) { if (s->eof) return AVERROR_EOF; ret = ff_request_frame(ctx->inputs[0]); if (ret < 0) return ret; } return 0; }
false
FFmpeg
ed1c83508ec920bfef773e3aa3ac1764a65826ec
static int request_frame(AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; TrimContext *s = ctx->priv; int ret; s->got_output = 0; while (!s->got_output) { if (s->eof) return AVERROR_EOF; ret = ff_request_frame(ctx->inputs[0]); if (ret < 0) return ret; } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFilterLink *VAR_0) { AVFilterContext *ctx = VAR_0->src; TrimContext *s = ctx->priv; int VAR_1; s->got_output = 0; while (!s->got_output) { if (s->eof) return AVERROR_EOF; VAR_1 = ff_request_frame(ctx->inputs[0]); if (VAR_1 < 0) return VAR_1; } return 0; }
[ "static int FUNC_0(AVFilterLink *VAR_0)\n{", "AVFilterContext *ctx = VAR_0->src;", "TrimContext *s = ctx->priv;", "int VAR_1;", "s->got_output = 0;", "while (!s->got_output) {", "if (s->eof)\nreturn AVERROR_EOF;", "VAR_1 = ff_request_frame(ctx->inputs[0]);", "if (VAR_1 < 0)\nreturn VAR_1;", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17, 19 ], [ 23 ], [ 25, 27 ], [ 29 ], [ 33 ], [ 35 ] ]
6,192
int ff_ivi_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { IVI45DecContext *ctx = avctx->priv_data; const uint8_t *buf = avpkt->data; AVFrame *frame = data; int buf_size = avpkt->size; int result, p, b; init_get_bits(&ctx->gb, buf, buf_size * 8); ctx->frame_data = buf; ctx->frame_size = buf_size; result = ctx->decode_pic_hdr(ctx, avctx); if (result) { av_log(avctx, AV_LOG_ERROR, "Error while decoding picture header: %d\n", result); return result; } if (ctx->gop_invalid) return AVERROR_INVALIDDATA; if (avctx->codec_id == AV_CODEC_ID_INDEO4 && ctx->frame_type == IVI4_FRAMETYPE_NULL_LAST) { if (ctx->got_p_frame) { av_frame_move_ref(data, ctx->p_frame); *got_frame = 1; ctx->got_p_frame = 0; } else { *got_frame = 0; } return buf_size; } if (ctx->gop_flags & IVI5_IS_PROTECTED) { avpriv_report_missing_feature(avctx, "Password-protected clip!\n"); return AVERROR_PATCHWELCOME; } if (!ctx->planes[0].bands) { av_log(avctx, AV_LOG_ERROR, "Color planes not initialized yet\n"); return AVERROR_INVALIDDATA; } ctx->switch_buffers(ctx); //{ START_TIMER; if (ctx->is_nonnull_frame(ctx)) { for (p = 0; p < 3; p++) { for (b = 0; b < ctx->planes[p].num_bands; b++) { result = decode_band(ctx, &ctx->planes[p].bands[b], avctx); if (result < 0) { av_log(avctx, AV_LOG_ERROR, "Error while decoding band: %d, plane: %d\n", b, p); return result; } } } } else { if (ctx->is_scalable) return AVERROR_INVALIDDATA; for (p = 0; p < 3; p++) { if (!ctx->planes[p].bands[0].buf) return AVERROR_INVALIDDATA; } } //STOP_TIMER("decode_planes"); } result = ff_set_dimensions(avctx, ctx->planes[0].width, ctx->planes[0].height); if (result < 0) return result; if ((result = ff_get_buffer(avctx, frame, 0)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return result; } if (ctx->is_scalable) { if (avctx->codec_id == AV_CODEC_ID_INDEO4) ff_ivi_recompose_haar(&ctx->planes[0], frame->data[0], frame->linesize[0]); else ff_ivi_recompose53 (&ctx->planes[0], frame->data[0], frame->linesize[0]); } else { ivi_output_plane(&ctx->planes[0], frame->data[0], frame->linesize[0]); } ivi_output_plane(&ctx->planes[2], frame->data[1], frame->linesize[1]); ivi_output_plane(&ctx->planes[1], frame->data[2], frame->linesize[2]); *got_frame = 1; /* If the bidirectional mode is enabled, next I and the following P * frame will be sent together. Unfortunately the approach below seems * to be the only way to handle the B-frames mode. * That's exactly the same Intel decoders do. */ if (avctx->codec_id == AV_CODEC_ID_INDEO4 && ctx->frame_type == IVI4_FRAMETYPE_INTRA) { int left; while (get_bits(&ctx->gb, 8)); // skip version string left = get_bits_count(&ctx->gb) & 0x18; skip_bits_long(&ctx->gb, 64 - left); if (get_bits_left(&ctx->gb) > 18 && show_bits_long(&ctx->gb, 21) == 0xBFFF8) { // syncheader + inter type AVPacket pkt; pkt.data = avpkt->data + (get_bits_count(&ctx->gb) >> 3); pkt.size = get_bits_left(&ctx->gb) >> 3; ff_ivi_decode_frame(avctx, ctx->p_frame, &ctx->got_p_frame, &pkt); } } return buf_size; }
false
FFmpeg
e121ac634ba324a318f4a97f978dcfb48da6b735
int ff_ivi_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { IVI45DecContext *ctx = avctx->priv_data; const uint8_t *buf = avpkt->data; AVFrame *frame = data; int buf_size = avpkt->size; int result, p, b; init_get_bits(&ctx->gb, buf, buf_size * 8); ctx->frame_data = buf; ctx->frame_size = buf_size; result = ctx->decode_pic_hdr(ctx, avctx); if (result) { av_log(avctx, AV_LOG_ERROR, "Error while decoding picture header: %d\n", result); return result; } if (ctx->gop_invalid) return AVERROR_INVALIDDATA; if (avctx->codec_id == AV_CODEC_ID_INDEO4 && ctx->frame_type == IVI4_FRAMETYPE_NULL_LAST) { if (ctx->got_p_frame) { av_frame_move_ref(data, ctx->p_frame); *got_frame = 1; ctx->got_p_frame = 0; } else { *got_frame = 0; } return buf_size; } if (ctx->gop_flags & IVI5_IS_PROTECTED) { avpriv_report_missing_feature(avctx, "Password-protected clip!\n"); return AVERROR_PATCHWELCOME; } if (!ctx->planes[0].bands) { av_log(avctx, AV_LOG_ERROR, "Color planes not initialized yet\n"); return AVERROR_INVALIDDATA; } ctx->switch_buffers(ctx); if (ctx->is_nonnull_frame(ctx)) { for (p = 0; p < 3; p++) { for (b = 0; b < ctx->planes[p].num_bands; b++) { result = decode_band(ctx, &ctx->planes[p].bands[b], avctx); if (result < 0) { av_log(avctx, AV_LOG_ERROR, "Error while decoding band: %d, plane: %d\n", b, p); return result; } } } } else { if (ctx->is_scalable) return AVERROR_INVALIDDATA; for (p = 0; p < 3; p++) { if (!ctx->planes[p].bands[0].buf) return AVERROR_INVALIDDATA; } } result = ff_set_dimensions(avctx, ctx->planes[0].width, ctx->planes[0].height); if (result < 0) return result; if ((result = ff_get_buffer(avctx, frame, 0)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return result; } if (ctx->is_scalable) { if (avctx->codec_id == AV_CODEC_ID_INDEO4) ff_ivi_recompose_haar(&ctx->planes[0], frame->data[0], frame->linesize[0]); else ff_ivi_recompose53 (&ctx->planes[0], frame->data[0], frame->linesize[0]); } else { ivi_output_plane(&ctx->planes[0], frame->data[0], frame->linesize[0]); } ivi_output_plane(&ctx->planes[2], frame->data[1], frame->linesize[1]); ivi_output_plane(&ctx->planes[1], frame->data[2], frame->linesize[2]); *got_frame = 1; if (avctx->codec_id == AV_CODEC_ID_INDEO4 && ctx->frame_type == IVI4_FRAMETYPE_INTRA) { int left; while (get_bits(&ctx->gb, 8)); left = get_bits_count(&ctx->gb) & 0x18; skip_bits_long(&ctx->gb, 64 - left); if (get_bits_left(&ctx->gb) > 18 && show_bits_long(&ctx->gb, 21) == 0xBFFF8) { AVPacket pkt; pkt.data = avpkt->data + (get_bits_count(&ctx->gb) >> 3); pkt.size = get_bits_left(&ctx->gb) >> 3; ff_ivi_decode_frame(avctx, ctx->p_frame, &ctx->got_p_frame, &pkt); } } return buf_size; }
{ "code": [], "line_no": [] }
int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, AVPacket *VAR_3) { IVI45DecContext *ctx = VAR_0->priv_data; const uint8_t *VAR_4 = VAR_3->VAR_1; AVFrame *frame = VAR_1; int VAR_5 = VAR_3->size; int VAR_6, VAR_7, VAR_8; init_get_bits(&ctx->gb, VAR_4, VAR_5 * 8); ctx->frame_data = VAR_4; ctx->frame_size = VAR_5; VAR_6 = ctx->decode_pic_hdr(ctx, VAR_0); if (VAR_6) { av_log(VAR_0, AV_LOG_ERROR, "Error while decoding picture header: %d\n", VAR_6); return VAR_6; } if (ctx->gop_invalid) return AVERROR_INVALIDDATA; if (VAR_0->codec_id == AV_CODEC_ID_INDEO4 && ctx->frame_type == IVI4_FRAMETYPE_NULL_LAST) { if (ctx->got_p_frame) { av_frame_move_ref(VAR_1, ctx->p_frame); *VAR_2 = 1; ctx->got_p_frame = 0; } else { *VAR_2 = 0; } return VAR_5; } if (ctx->gop_flags & IVI5_IS_PROTECTED) { avpriv_report_missing_feature(VAR_0, "Password-protected clip!\n"); return AVERROR_PATCHWELCOME; } if (!ctx->planes[0].bands) { av_log(VAR_0, AV_LOG_ERROR, "Color planes not initialized yet\n"); return AVERROR_INVALIDDATA; } ctx->switch_buffers(ctx); if (ctx->is_nonnull_frame(ctx)) { for (VAR_7 = 0; VAR_7 < 3; VAR_7++) { for (VAR_8 = 0; VAR_8 < ctx->planes[VAR_7].num_bands; VAR_8++) { VAR_6 = decode_band(ctx, &ctx->planes[VAR_7].bands[VAR_8], VAR_0); if (VAR_6 < 0) { av_log(VAR_0, AV_LOG_ERROR, "Error while decoding band: %d, plane: %d\n", VAR_8, VAR_7); return VAR_6; } } } } else { if (ctx->is_scalable) return AVERROR_INVALIDDATA; for (VAR_7 = 0; VAR_7 < 3; VAR_7++) { if (!ctx->planes[VAR_7].bands[0].VAR_4) return AVERROR_INVALIDDATA; } } VAR_6 = ff_set_dimensions(VAR_0, ctx->planes[0].width, ctx->planes[0].height); if (VAR_6 < 0) return VAR_6; if ((VAR_6 = ff_get_buffer(VAR_0, frame, 0)) < 0) { av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n"); return VAR_6; } if (ctx->is_scalable) { if (VAR_0->codec_id == AV_CODEC_ID_INDEO4) ff_ivi_recompose_haar(&ctx->planes[0], frame->VAR_1[0], frame->linesize[0]); else ff_ivi_recompose53 (&ctx->planes[0], frame->VAR_1[0], frame->linesize[0]); } else { ivi_output_plane(&ctx->planes[0], frame->VAR_1[0], frame->linesize[0]); } ivi_output_plane(&ctx->planes[2], frame->VAR_1[1], frame->linesize[1]); ivi_output_plane(&ctx->planes[1], frame->VAR_1[2], frame->linesize[2]); *VAR_2 = 1; if (VAR_0->codec_id == AV_CODEC_ID_INDEO4 && ctx->frame_type == IVI4_FRAMETYPE_INTRA) { int VAR_9; while (get_bits(&ctx->gb, 8)); VAR_9 = get_bits_count(&ctx->gb) & 0x18; skip_bits_long(&ctx->gb, 64 - VAR_9); if (get_bits_left(&ctx->gb) > 18 && show_bits_long(&ctx->gb, 21) == 0xBFFF8) { AVPacket pkt; pkt.VAR_1 = VAR_3->VAR_1 + (get_bits_count(&ctx->gb) >> 3); pkt.size = get_bits_left(&ctx->gb) >> 3; FUNC_0(VAR_0, ctx->p_frame, &ctx->got_p_frame, &pkt); } } return VAR_5; }
[ "int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{", "IVI45DecContext *ctx = VAR_0->priv_data;", "const uint8_t *VAR_4 = VAR_3->VAR_1;", "AVFrame *frame = VAR_1;", "int VAR_5 = VAR_3->size;", "int VAR_6, VAR_7, VAR_8;", "init_get_bits(&ctx->gb, VAR_4, VAR_5 * 8);", "ctx->frame_data = VAR_4;", "ctx->frame_size = VAR_5;", "VAR_6 = ctx->decode_pic_hdr(ctx, VAR_0);", "if (VAR_6) {", "av_log(VAR_0, AV_LOG_ERROR,\n\"Error while decoding picture header: %d\\n\", VAR_6);", "return VAR_6;", "}", "if (ctx->gop_invalid)\nreturn AVERROR_INVALIDDATA;", "if (VAR_0->codec_id == AV_CODEC_ID_INDEO4 &&\nctx->frame_type == IVI4_FRAMETYPE_NULL_LAST) {", "if (ctx->got_p_frame) {", "av_frame_move_ref(VAR_1, ctx->p_frame);", "*VAR_2 = 1;", "ctx->got_p_frame = 0;", "} else {", "*VAR_2 = 0;", "}", "return VAR_5;", "}", "if (ctx->gop_flags & IVI5_IS_PROTECTED) {", "avpriv_report_missing_feature(VAR_0, \"Password-protected clip!\\n\");", "return AVERROR_PATCHWELCOME;", "}", "if (!ctx->planes[0].bands) {", "av_log(VAR_0, AV_LOG_ERROR, \"Color planes not initialized yet\\n\");", "return AVERROR_INVALIDDATA;", "}", "ctx->switch_buffers(ctx);", "if (ctx->is_nonnull_frame(ctx)) {", "for (VAR_7 = 0; VAR_7 < 3; VAR_7++) {", "for (VAR_8 = 0; VAR_8 < ctx->planes[VAR_7].num_bands; VAR_8++) {", "VAR_6 = decode_band(ctx, &ctx->planes[VAR_7].bands[VAR_8], VAR_0);", "if (VAR_6 < 0) {", "av_log(VAR_0, AV_LOG_ERROR,\n\"Error while decoding band: %d, plane: %d\\n\", VAR_8, VAR_7);", "return VAR_6;", "}", "}", "}", "} else {", "if (ctx->is_scalable)\nreturn AVERROR_INVALIDDATA;", "for (VAR_7 = 0; VAR_7 < 3; VAR_7++) {", "if (!ctx->planes[VAR_7].bands[0].VAR_4)\nreturn AVERROR_INVALIDDATA;", "}", "}", "VAR_6 = ff_set_dimensions(VAR_0, ctx->planes[0].width, ctx->planes[0].height);", "if (VAR_6 < 0)\nreturn VAR_6;", "if ((VAR_6 = ff_get_buffer(VAR_0, frame, 0)) < 0) {", "av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\n\");", "return VAR_6;", "}", "if (ctx->is_scalable) {", "if (VAR_0->codec_id == AV_CODEC_ID_INDEO4)\nff_ivi_recompose_haar(&ctx->planes[0], frame->VAR_1[0], frame->linesize[0]);", "else\nff_ivi_recompose53 (&ctx->planes[0], frame->VAR_1[0], frame->linesize[0]);", "} else {", "ivi_output_plane(&ctx->planes[0], frame->VAR_1[0], frame->linesize[0]);", "}", "ivi_output_plane(&ctx->planes[2], frame->VAR_1[1], frame->linesize[1]);", "ivi_output_plane(&ctx->planes[1], frame->VAR_1[2], frame->linesize[2]);", "*VAR_2 = 1;", "if (VAR_0->codec_id == AV_CODEC_ID_INDEO4 &&\nctx->frame_type == IVI4_FRAMETYPE_INTRA) {", "int VAR_9;", "while (get_bits(&ctx->gb, 8));", "VAR_9 = get_bits_count(&ctx->gb) & 0x18;", "skip_bits_long(&ctx->gb, 64 - VAR_9);", "if (get_bits_left(&ctx->gb) > 18 &&\nshow_bits_long(&ctx->gb, 21) == 0xBFFF8) {", "AVPacket pkt;", "pkt.VAR_1 = VAR_3->VAR_1 + (get_bits_count(&ctx->gb) >> 3);", "pkt.size = get_bits_left(&ctx->gb) >> 3;", "FUNC_0(VAR_0, ctx->p_frame, &ctx->got_p_frame, &pkt);", "}", "}", "return VAR_5;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31, 33 ], [ 35 ], [ 37 ], [ 39, 41 ], [ 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 89 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107, 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121, 123 ], [ 127 ], [ 129, 131 ], [ 133 ], [ 135 ], [ 143 ], [ 145, 147 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 161 ], [ 163, 165 ], [ 167, 169 ], [ 171 ], [ 173 ], [ 175 ], [ 179 ], [ 181 ], [ 185 ], [ 199, 201 ], [ 203 ], [ 207 ], [ 209 ], [ 211 ], [ 213, 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 231 ], [ 233 ] ]
6,194
static void tcg_out_brcond32(TCGContext *s, TCGCond cond, TCGArg arg1, TCGArg arg2, int const_arg2, int label_index, int small) { tcg_out_cmp(s, arg1, arg2, const_arg2, 0); tcg_out_jxx(s, tcg_cond_to_jcc[cond], label_index, small); }
false
qemu
bec1631100323fac0900aea71043d5c4e22fc2fa
static void tcg_out_brcond32(TCGContext *s, TCGCond cond, TCGArg arg1, TCGArg arg2, int const_arg2, int label_index, int small) { tcg_out_cmp(s, arg1, arg2, const_arg2, 0); tcg_out_jxx(s, tcg_cond_to_jcc[cond], label_index, small); }
{ "code": [], "line_no": [] }
static void FUNC_0(TCGContext *VAR_0, TCGCond VAR_1, TCGArg VAR_2, TCGArg VAR_3, int VAR_4, int VAR_5, int VAR_6) { tcg_out_cmp(VAR_0, VAR_2, VAR_3, VAR_4, 0); tcg_out_jxx(VAR_0, tcg_cond_to_jcc[VAR_1], VAR_5, VAR_6); }
[ "static void FUNC_0(TCGContext *VAR_0, TCGCond VAR_1,\nTCGArg VAR_2, TCGArg VAR_3, int VAR_4,\nint VAR_5, int VAR_6)\n{", "tcg_out_cmp(VAR_0, VAR_2, VAR_3, VAR_4, 0);", "tcg_out_jxx(VAR_0, tcg_cond_to_jcc[VAR_1], VAR_5, VAR_6);", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ] ]
6,195
void qemu_chr_free(CharDriverState *chr) { if (chr->chr_close) { chr->chr_close(chr); } g_free(chr->filename); g_free(chr->label); qemu_opts_del(chr->opts); g_free(chr); }
false
qemu
d0d7708ba29cbcc343364a46bff981e0ff88366f
void qemu_chr_free(CharDriverState *chr) { if (chr->chr_close) { chr->chr_close(chr); } g_free(chr->filename); g_free(chr->label); qemu_opts_del(chr->opts); g_free(chr); }
{ "code": [], "line_no": [] }
void FUNC_0(CharDriverState *VAR_0) { if (VAR_0->chr_close) { VAR_0->chr_close(VAR_0); } g_free(VAR_0->filename); g_free(VAR_0->label); qemu_opts_del(VAR_0->opts); g_free(VAR_0); }
[ "void FUNC_0(CharDriverState *VAR_0)\n{", "if (VAR_0->chr_close) {", "VAR_0->chr_close(VAR_0);", "}", "g_free(VAR_0->filename);", "g_free(VAR_0->label);", "qemu_opts_del(VAR_0->opts);", "g_free(VAR_0);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
6,200
void replay_shutdown_request(void) { if (replay_mode == REPLAY_MODE_RECORD) { replay_mutex_lock(); replay_put_event(EVENT_SHUTDOWN); replay_mutex_unlock(); } }
false
qemu
802f045a5f61b781df55e4492d896b4d20503ba7
void replay_shutdown_request(void) { if (replay_mode == REPLAY_MODE_RECORD) { replay_mutex_lock(); replay_put_event(EVENT_SHUTDOWN); replay_mutex_unlock(); } }
{ "code": [], "line_no": [] }
void FUNC_0(void) { if (replay_mode == REPLAY_MODE_RECORD) { replay_mutex_lock(); replay_put_event(EVENT_SHUTDOWN); replay_mutex_unlock(); } }
[ "void FUNC_0(void)\n{", "if (replay_mode == REPLAY_MODE_RECORD) {", "replay_mutex_lock();", "replay_put_event(EVENT_SHUTDOWN);", "replay_mutex_unlock();", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ] ]
6,201
target_phys_addr_t memory_region_section_get_iotlb(CPUArchState *env, MemoryRegionSection *section, target_ulong vaddr, target_phys_addr_t paddr, int prot, target_ulong *address) { target_phys_addr_t iotlb; CPUWatchpoint *wp; if (memory_region_is_ram(section->mr)) { /* Normal RAM. */ iotlb = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK) + memory_region_section_addr(section, paddr); if (!section->readonly) { iotlb |= phys_section_notdirty; } else { iotlb |= phys_section_rom; } } else { /* IO handlers are currently passed a physical address. It would be nice to pass an offset from the base address of that region. This would avoid having to special case RAM, and avoid full address decoding in every device. We can't use the high bits of pd for this because IO_MEM_ROMD uses these as a ram address. */ iotlb = section - phys_sections; iotlb += memory_region_section_addr(section, paddr); } /* Make accesses to pages with watchpoints go via the watchpoint trap routines. */ QTAILQ_FOREACH(wp, &env->watchpoints, entry) { if (vaddr == (wp->vaddr & TARGET_PAGE_MASK)) { /* Avoid trapping reads of pages with a write breakpoint. */ if ((prot & PAGE_WRITE) || (wp->flags & BP_MEM_READ)) { iotlb = phys_section_watch + paddr; *address |= TLB_MMIO; break; } } } return iotlb; }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
target_phys_addr_t memory_region_section_get_iotlb(CPUArchState *env, MemoryRegionSection *section, target_ulong vaddr, target_phys_addr_t paddr, int prot, target_ulong *address) { target_phys_addr_t iotlb; CPUWatchpoint *wp; if (memory_region_is_ram(section->mr)) { iotlb = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK) + memory_region_section_addr(section, paddr); if (!section->readonly) { iotlb |= phys_section_notdirty; } else { iotlb |= phys_section_rom; } } else { iotlb = section - phys_sections; iotlb += memory_region_section_addr(section, paddr); } QTAILQ_FOREACH(wp, &env->watchpoints, entry) { if (vaddr == (wp->vaddr & TARGET_PAGE_MASK)) { if ((prot & PAGE_WRITE) || (wp->flags & BP_MEM_READ)) { iotlb = phys_section_watch + paddr; *address |= TLB_MMIO; break; } } } return iotlb; }
{ "code": [], "line_no": [] }
target_phys_addr_t FUNC_0(CPUArchState *env, MemoryRegionSection *section, target_ulong vaddr, target_phys_addr_t paddr, int prot, target_ulong *address) { target_phys_addr_t iotlb; CPUWatchpoint *wp; if (memory_region_is_ram(section->mr)) { iotlb = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK) + memory_region_section_addr(section, paddr); if (!section->readonly) { iotlb |= phys_section_notdirty; } else { iotlb |= phys_section_rom; } } else { iotlb = section - phys_sections; iotlb += memory_region_section_addr(section, paddr); } QTAILQ_FOREACH(wp, &env->watchpoints, entry) { if (vaddr == (wp->vaddr & TARGET_PAGE_MASK)) { if ((prot & PAGE_WRITE) || (wp->flags & BP_MEM_READ)) { iotlb = phys_section_watch + paddr; *address |= TLB_MMIO; break; } } } return iotlb; }
[ "target_phys_addr_t FUNC_0(CPUArchState *env,\nMemoryRegionSection *section,\ntarget_ulong vaddr,\ntarget_phys_addr_t paddr,\nint prot,\ntarget_ulong *address)\n{", "target_phys_addr_t iotlb;", "CPUWatchpoint *wp;", "if (memory_region_is_ram(section->mr)) {", "iotlb = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK)\n+ memory_region_section_addr(section, paddr);", "if (!section->readonly) {", "iotlb |= phys_section_notdirty;", "} else {", "iotlb |= phys_section_rom;", "}", "} else {", "iotlb = section - phys_sections;", "iotlb += memory_region_section_addr(section, paddr);", "}", "QTAILQ_FOREACH(wp, &env->watchpoints, entry) {", "if (vaddr == (wp->vaddr & TARGET_PAGE_MASK)) {", "if ((prot & PAGE_WRITE) || (wp->flags & BP_MEM_READ)) {", "iotlb = phys_section_watch + paddr;", "*address |= TLB_MMIO;", "break;", "}", "}", "}", "return iotlb;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11, 13 ], [ 15 ], [ 17 ], [ 21 ], [ 25, 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 53 ], [ 55 ], [ 57 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 87 ], [ 89 ] ]
6,203
static int vpx_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { VPxContext *ctx = avctx->priv_data; AVFrame *picture = data; const void *iter = NULL; const void *iter_alpha = NULL; struct vpx_image *img, *img_alpha; int ret; uint8_t *side_data = NULL; int side_data_size = 0; ret = decode_frame(avctx, &ctx->decoder, avpkt->data, avpkt->size); if (ret) return ret; side_data = av_packet_get_side_data(avpkt, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size); if (side_data_size > 1) { const uint64_t additional_id = AV_RB64(side_data); side_data += 8; side_data_size -= 8; if (additional_id == 1) { // 1 stands for alpha channel data. if (!ctx->has_alpha_channel) { ctx->has_alpha_channel = 1; ret = vpx_init(avctx, #if CONFIG_LIBVPX_VP8_DECODER && CONFIG_LIBVPX_VP9_DECODER (avctx->codec_id == AV_CODEC_ID_VP8) ? &vpx_codec_vp8_dx_algo : &vpx_codec_vp9_dx_algo, #elif CONFIG_LIBVPX_VP8_DECODER &vpx_codec_vp8_dx_algo, #else &vpx_codec_vp9_dx_algo, #endif 1); if (ret) return ret; ret = decode_frame(avctx, &ctx->decoder_alpha, side_data, side_data_size); if (ret) return ret; if ((img = vpx_codec_get_frame(&ctx->decoder, &iter)) && (!ctx->has_alpha_channel || (img_alpha = vpx_codec_get_frame(&ctx->decoder_alpha, &iter_alpha)))) { uint8_t *planes[4]; int linesizes[4]; if ((ret = set_pix_fmt(avctx, img, ctx->has_alpha_channel)) < 0) { #ifdef VPX_IMG_FMT_HIGHBITDEPTH av_log(avctx, AV_LOG_ERROR, "Unsupported output colorspace (%d) / bit_depth (%d)\n", img->fmt, img->bit_depth); #else av_log(avctx, AV_LOG_ERROR, "Unsupported output colorspace (%d) / bit_depth (%d)\n", img->fmt, 8); #endif return ret; if ((int) img->d_w != avctx->width || (int) img->d_h != avctx->height) { av_log(avctx, AV_LOG_INFO, "dimension change! %dx%d -> %dx%d\n", avctx->width, avctx->height, img->d_w, img->d_h); ret = ff_set_dimensions(avctx, img->d_w, img->d_h); if (ret < 0) return ret; if ((ret = ff_get_buffer(avctx, picture, 0)) < 0) return ret; planes[0] = img->planes[VPX_PLANE_Y]; planes[1] = img->planes[VPX_PLANE_U]; planes[2] = img->planes[VPX_PLANE_V]; planes[3] = ctx->has_alpha_channel ? img_alpha->planes[VPX_PLANE_Y] : NULL; linesizes[0] = img->stride[VPX_PLANE_Y]; linesizes[1] = img->stride[VPX_PLANE_U]; linesizes[2] = img->stride[VPX_PLANE_V]; linesizes[3] = ctx->has_alpha_channel ? img_alpha->stride[VPX_PLANE_Y] : 0; av_image_copy(picture->data, picture->linesize, (const uint8_t**)planes, linesizes, avctx->pix_fmt, img->d_w, img->d_h); *got_frame = 1; return avpkt->size;
true
FFmpeg
f8593c2f492a514b67533a877b716a25d3770418
static int vpx_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { VPxContext *ctx = avctx->priv_data; AVFrame *picture = data; const void *iter = NULL; const void *iter_alpha = NULL; struct vpx_image *img, *img_alpha; int ret; uint8_t *side_data = NULL; int side_data_size = 0; ret = decode_frame(avctx, &ctx->decoder, avpkt->data, avpkt->size); if (ret) return ret; side_data = av_packet_get_side_data(avpkt, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size); if (side_data_size > 1) { const uint64_t additional_id = AV_RB64(side_data); side_data += 8; side_data_size -= 8; if (additional_id == 1) { if (!ctx->has_alpha_channel) { ctx->has_alpha_channel = 1; ret = vpx_init(avctx, #if CONFIG_LIBVPX_VP8_DECODER && CONFIG_LIBVPX_VP9_DECODER (avctx->codec_id == AV_CODEC_ID_VP8) ? &vpx_codec_vp8_dx_algo : &vpx_codec_vp9_dx_algo, #elif CONFIG_LIBVPX_VP8_DECODER &vpx_codec_vp8_dx_algo, #else &vpx_codec_vp9_dx_algo, #endif 1); if (ret) return ret; ret = decode_frame(avctx, &ctx->decoder_alpha, side_data, side_data_size); if (ret) return ret; if ((img = vpx_codec_get_frame(&ctx->decoder, &iter)) && (!ctx->has_alpha_channel || (img_alpha = vpx_codec_get_frame(&ctx->decoder_alpha, &iter_alpha)))) { uint8_t *planes[4]; int linesizes[4]; if ((ret = set_pix_fmt(avctx, img, ctx->has_alpha_channel)) < 0) { #ifdef VPX_IMG_FMT_HIGHBITDEPTH av_log(avctx, AV_LOG_ERROR, "Unsupported output colorspace (%d) / bit_depth (%d)\n", img->fmt, img->bit_depth); #else av_log(avctx, AV_LOG_ERROR, "Unsupported output colorspace (%d) / bit_depth (%d)\n", img->fmt, 8); #endif return ret; if ((int) img->d_w != avctx->width || (int) img->d_h != avctx->height) { av_log(avctx, AV_LOG_INFO, "dimension change! %dx%d -> %dx%d\n", avctx->width, avctx->height, img->d_w, img->d_h); ret = ff_set_dimensions(avctx, img->d_w, img->d_h); if (ret < 0) return ret; if ((ret = ff_get_buffer(avctx, picture, 0)) < 0) return ret; planes[0] = img->planes[VPX_PLANE_Y]; planes[1] = img->planes[VPX_PLANE_U]; planes[2] = img->planes[VPX_PLANE_V]; planes[3] = ctx->has_alpha_channel ? img_alpha->planes[VPX_PLANE_Y] : NULL; linesizes[0] = img->stride[VPX_PLANE_Y]; linesizes[1] = img->stride[VPX_PLANE_U]; linesizes[2] = img->stride[VPX_PLANE_V]; linesizes[3] = ctx->has_alpha_channel ? img_alpha->stride[VPX_PLANE_Y] : 0; av_image_copy(picture->data, picture->linesize, (const uint8_t**)planes, linesizes, avctx->pix_fmt, img->d_w, img->d_h); *got_frame = 1; return avpkt->size;
{ "code": [], "line_no": [] }
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, AVPacket *VAR_3) { VPxContext *ctx = VAR_0->priv_data; AVFrame *picture = VAR_1; const void *VAR_4 = NULL; const void *VAR_5 = NULL; struct vpx_image *VAR_6, *VAR_7; int VAR_8; uint8_t *side_data = NULL; int VAR_9 = 0; VAR_8 = decode_frame(VAR_0, &ctx->decoder, VAR_3->VAR_1, VAR_3->size); if (VAR_8) return VAR_8; side_data = av_packet_get_side_data(VAR_3, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &VAR_9); if (VAR_9 > 1) { const uint64_t VAR_10 = AV_RB64(side_data); side_data += 8; VAR_9 -= 8; if (VAR_10 == 1) { if (!ctx->has_alpha_channel) { ctx->has_alpha_channel = 1; VAR_8 = vpx_init(VAR_0, #if CONFIG_LIBVPX_VP8_DECODER && CONFIG_LIBVPX_VP9_DECODER (VAR_0->codec_id == AV_CODEC_ID_VP8) ? &vpx_codec_vp8_dx_algo : &vpx_codec_vp9_dx_algo, #elif CONFIG_LIBVPX_VP8_DECODER &vpx_codec_vp8_dx_algo, #else &vpx_codec_vp9_dx_algo, #endif 1); if (VAR_8) return VAR_8; VAR_8 = decode_frame(VAR_0, &ctx->decoder_alpha, side_data, VAR_9); if (VAR_8) return VAR_8; if ((VAR_6 = vpx_codec_get_frame(&ctx->decoder, &VAR_4)) && (!ctx->has_alpha_channel || (VAR_7 = vpx_codec_get_frame(&ctx->decoder_alpha, &VAR_5)))) { uint8_t *planes[4]; int VAR_11[4]; if ((VAR_8 = set_pix_fmt(VAR_0, VAR_6, ctx->has_alpha_channel)) < 0) { #ifdef VPX_IMG_FMT_HIGHBITDEPTH av_log(VAR_0, AV_LOG_ERROR, "Unsupported output colorspace (%d) / bit_depth (%d)\n", VAR_6->fmt, VAR_6->bit_depth); #else av_log(VAR_0, AV_LOG_ERROR, "Unsupported output colorspace (%d) / bit_depth (%d)\n", VAR_6->fmt, 8); #endif return VAR_8; if ((int) VAR_6->d_w != VAR_0->width || (int) VAR_6->d_h != VAR_0->height) { av_log(VAR_0, AV_LOG_INFO, "dimension change! %dx%d -> %dx%d\n", VAR_0->width, VAR_0->height, VAR_6->d_w, VAR_6->d_h); VAR_8 = ff_set_dimensions(VAR_0, VAR_6->d_w, VAR_6->d_h); if (VAR_8 < 0) return VAR_8; if ((VAR_8 = ff_get_buffer(VAR_0, picture, 0)) < 0) return VAR_8; planes[0] = VAR_6->planes[VPX_PLANE_Y]; planes[1] = VAR_6->planes[VPX_PLANE_U]; planes[2] = VAR_6->planes[VPX_PLANE_V]; planes[3] = ctx->has_alpha_channel ? VAR_7->planes[VPX_PLANE_Y] : NULL; VAR_11[0] = VAR_6->stride[VPX_PLANE_Y]; VAR_11[1] = VAR_6->stride[VPX_PLANE_U]; VAR_11[2] = VAR_6->stride[VPX_PLANE_V]; VAR_11[3] = ctx->has_alpha_channel ? VAR_7->stride[VPX_PLANE_Y] : 0; av_image_copy(picture->VAR_1, picture->linesize, (const uint8_t**)planes, VAR_11, VAR_0->pix_fmt, VAR_6->d_w, VAR_6->d_h); *VAR_2 = 1; return VAR_3->size;
[ "static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2, AVPacket *VAR_3)\n{", "VPxContext *ctx = VAR_0->priv_data;", "AVFrame *picture = VAR_1;", "const void *VAR_4 = NULL;", "const void *VAR_5 = NULL;", "struct vpx_image *VAR_6, *VAR_7;", "int VAR_8;", "uint8_t *side_data = NULL;", "int VAR_9 = 0;", "VAR_8 = decode_frame(VAR_0, &ctx->decoder, VAR_3->VAR_1, VAR_3->size);", "if (VAR_8)\nreturn VAR_8;", "side_data = av_packet_get_side_data(VAR_3,\nAV_PKT_DATA_MATROSKA_BLOCKADDITIONAL,\n&VAR_9);", "if (VAR_9 > 1) {", "const uint64_t VAR_10 = AV_RB64(side_data);", "side_data += 8;", "VAR_9 -= 8;", "if (VAR_10 == 1) {", "if (!ctx->has_alpha_channel) {", "ctx->has_alpha_channel = 1;", "VAR_8 = vpx_init(VAR_0,\n#if CONFIG_LIBVPX_VP8_DECODER && CONFIG_LIBVPX_VP9_DECODER\n(VAR_0->codec_id == AV_CODEC_ID_VP8) ?\n&vpx_codec_vp8_dx_algo : &vpx_codec_vp9_dx_algo,\n#elif CONFIG_LIBVPX_VP8_DECODER\n&vpx_codec_vp8_dx_algo,\n#else\n&vpx_codec_vp9_dx_algo,\n#endif\n1);", "if (VAR_8)\nreturn VAR_8;", "VAR_8 = decode_frame(VAR_0, &ctx->decoder_alpha, side_data,\nVAR_9);", "if (VAR_8)\nreturn VAR_8;", "if ((VAR_6 = vpx_codec_get_frame(&ctx->decoder, &VAR_4)) &&\n(!ctx->has_alpha_channel ||\n(VAR_7 = vpx_codec_get_frame(&ctx->decoder_alpha, &VAR_5)))) {", "uint8_t *planes[4];", "int VAR_11[4];", "if ((VAR_8 = set_pix_fmt(VAR_0, VAR_6, ctx->has_alpha_channel)) < 0) {", "#ifdef VPX_IMG_FMT_HIGHBITDEPTH\nav_log(VAR_0, AV_LOG_ERROR, \"Unsupported output colorspace (%d) / bit_depth (%d)\\n\",\nVAR_6->fmt, VAR_6->bit_depth);", "#else\nav_log(VAR_0, AV_LOG_ERROR, \"Unsupported output colorspace (%d) / bit_depth (%d)\\n\",\nVAR_6->fmt, 8);", "#endif\nreturn VAR_8;", "if ((int) VAR_6->d_w != VAR_0->width || (int) VAR_6->d_h != VAR_0->height) {", "av_log(VAR_0, AV_LOG_INFO, \"dimension change! %dx%d -> %dx%d\\n\",\nVAR_0->width, VAR_0->height, VAR_6->d_w, VAR_6->d_h);", "VAR_8 = ff_set_dimensions(VAR_0, VAR_6->d_w, VAR_6->d_h);", "if (VAR_8 < 0)\nreturn VAR_8;", "if ((VAR_8 = ff_get_buffer(VAR_0, picture, 0)) < 0)\nreturn VAR_8;", "planes[0] = VAR_6->planes[VPX_PLANE_Y];", "planes[1] = VAR_6->planes[VPX_PLANE_U];", "planes[2] = VAR_6->planes[VPX_PLANE_V];", "planes[3] =\nctx->has_alpha_channel ? VAR_7->planes[VPX_PLANE_Y] : NULL;", "VAR_11[0] = VAR_6->stride[VPX_PLANE_Y];", "VAR_11[1] = VAR_6->stride[VPX_PLANE_U];", "VAR_11[2] = VAR_6->stride[VPX_PLANE_V];", "VAR_11[3] =\nctx->has_alpha_channel ? VAR_7->stride[VPX_PLANE_Y] : 0;", "av_image_copy(picture->VAR_1, picture->linesize, (const uint8_t**)planes,\nVAR_11, VAR_0->pix_fmt, VAR_6->d_w, VAR_6->d_h);", "*VAR_2 = 1;", "return VAR_3->size;" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 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 ], [ 50, 51, 52 ], [ 53, 54 ], [ 55 ], [ 56, 57 ], [ 58 ], [ 59, 60 ], [ 61, 62 ], [ 63 ], [ 64 ], [ 65 ], [ 66, 67 ], [ 68 ], [ 69 ], [ 70 ], [ 71, 72 ], [ 73, 74 ], [ 75 ], [ 76 ] ]
6,204
static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg, bool in_prologue) { intptr_t tb_diff; tcg_target_long tmp; int shift; tcg_debug_assert(TCG_TARGET_REG_BITS == 64 || type == TCG_TYPE_I32); if (TCG_TARGET_REG_BITS == 64 && type == TCG_TYPE_I32) { arg = (int32_t)arg; } /* Load 16-bit immediates with one insn. */ if (tcg_out_movi_one(s, ret, arg)) { return; } /* Load addresses within the TB with one insn. */ tb_diff = arg - (intptr_t)s->code_gen_ptr; if (!in_prologue && USE_REG_TB && tb_diff == (int16_t)tb_diff) { tcg_out32(s, ADDI | TAI(ret, TCG_REG_TB, tb_diff)); return; } /* Load 32-bit immediates with two insns. Note that we've already eliminated bare ADDIS, so we know both insns are required. */ if (TCG_TARGET_REG_BITS == 32 || arg == (int32_t)arg) { tcg_out32(s, ADDIS | TAI(ret, 0, arg >> 16)); tcg_out32(s, ORI | SAI(ret, ret, arg)); return; } if (arg == (uint32_t)arg && !(arg & 0x8000)) { tcg_out32(s, ADDI | TAI(ret, 0, arg)); tcg_out32(s, ORIS | SAI(ret, ret, arg >> 16)); return; } /* Load masked 16-bit value. */ if (arg > 0 && (arg & 0x8000)) { tmp = arg | 0x7fff; if ((tmp & (tmp + 1)) == 0) { int mb = clz64(tmp + 1) + 1; tcg_out32(s, ADDI | TAI(ret, 0, arg)); tcg_out_rld(s, RLDICL, ret, ret, 0, mb); return; } } /* Load common masks with 2 insns. */ shift = ctz64(arg); tmp = arg >> shift; if (tmp == (int16_t)tmp) { tcg_out32(s, ADDI | TAI(ret, 0, tmp)); tcg_out_shli64(s, ret, ret, shift); return; } shift = clz64(arg); if (tcg_out_movi_one(s, ret, arg << shift)) { tcg_out_shri64(s, ret, ret, shift); return; } /* Load addresses within 2GB of TB with 2 (or rarely 3) insns. */ if (!in_prologue && USE_REG_TB && tb_diff == (int32_t)tb_diff) { tcg_out_mem_long(s, ADDI, ADD, ret, TCG_REG_TB, tb_diff); return; } /* Use the constant pool, if possible. */ if (!in_prologue && USE_REG_TB) { new_pool_label(s, arg, R_PPC_ADDR16, s->code_ptr, -(intptr_t)s->code_gen_ptr); tcg_out32(s, LD | TAI(ret, TCG_REG_TB, 0)); return; } tmp = arg >> 31 >> 1; tcg_out_movi(s, TCG_TYPE_I32, ret, tmp); if (tmp) { tcg_out_shli64(s, ret, ret, 32); } if (arg & 0xffff0000) { tcg_out32(s, ORIS | SAI(ret, ret, arg >> 16)); } if (arg & 0xffff) { tcg_out32(s, ORI | SAI(ret, ret, arg)); } }
true
qemu
030ffe39dd4128eb90483af82a5b23b23054a466
static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg, bool in_prologue) { intptr_t tb_diff; tcg_target_long tmp; int shift; tcg_debug_assert(TCG_TARGET_REG_BITS == 64 || type == TCG_TYPE_I32); if (TCG_TARGET_REG_BITS == 64 && type == TCG_TYPE_I32) { arg = (int32_t)arg; } if (tcg_out_movi_one(s, ret, arg)) { return; } tb_diff = arg - (intptr_t)s->code_gen_ptr; if (!in_prologue && USE_REG_TB && tb_diff == (int16_t)tb_diff) { tcg_out32(s, ADDI | TAI(ret, TCG_REG_TB, tb_diff)); return; } if (TCG_TARGET_REG_BITS == 32 || arg == (int32_t)arg) { tcg_out32(s, ADDIS | TAI(ret, 0, arg >> 16)); tcg_out32(s, ORI | SAI(ret, ret, arg)); return; } if (arg == (uint32_t)arg && !(arg & 0x8000)) { tcg_out32(s, ADDI | TAI(ret, 0, arg)); tcg_out32(s, ORIS | SAI(ret, ret, arg >> 16)); return; } if (arg > 0 && (arg & 0x8000)) { tmp = arg | 0x7fff; if ((tmp & (tmp + 1)) == 0) { int mb = clz64(tmp + 1) + 1; tcg_out32(s, ADDI | TAI(ret, 0, arg)); tcg_out_rld(s, RLDICL, ret, ret, 0, mb); return; } } shift = ctz64(arg); tmp = arg >> shift; if (tmp == (int16_t)tmp) { tcg_out32(s, ADDI | TAI(ret, 0, tmp)); tcg_out_shli64(s, ret, ret, shift); return; } shift = clz64(arg); if (tcg_out_movi_one(s, ret, arg << shift)) { tcg_out_shri64(s, ret, ret, shift); return; } if (!in_prologue && USE_REG_TB && tb_diff == (int32_t)tb_diff) { tcg_out_mem_long(s, ADDI, ADD, ret, TCG_REG_TB, tb_diff); return; } if (!in_prologue && USE_REG_TB) { new_pool_label(s, arg, R_PPC_ADDR16, s->code_ptr, -(intptr_t)s->code_gen_ptr); tcg_out32(s, LD | TAI(ret, TCG_REG_TB, 0)); return; } tmp = arg >> 31 >> 1; tcg_out_movi(s, TCG_TYPE_I32, ret, tmp); if (tmp) { tcg_out_shli64(s, ret, ret, 32); } if (arg & 0xffff0000) { tcg_out32(s, ORIS | SAI(ret, ret, arg >> 16)); } if (arg & 0xffff) { tcg_out32(s, ORI | SAI(ret, ret, arg)); } }
{ "code": [ " tcg_out32(s, LD | TAI(ret, TCG_REG_TB, 0));" ], "line_no": [ 147 ] }
static void FUNC_0(TCGContext *VAR_0, TCGType VAR_1, TCGReg VAR_2, tcg_target_long VAR_3, bool VAR_4) { intptr_t tb_diff; tcg_target_long tmp; int VAR_5; tcg_debug_assert(TCG_TARGET_REG_BITS == 64 || VAR_1 == TCG_TYPE_I32); if (TCG_TARGET_REG_BITS == 64 && VAR_1 == TCG_TYPE_I32) { VAR_3 = (int32_t)VAR_3; } if (tcg_out_movi_one(VAR_0, VAR_2, VAR_3)) { return; } tb_diff = VAR_3 - (intptr_t)VAR_0->code_gen_ptr; if (!VAR_4 && USE_REG_TB && tb_diff == (int16_t)tb_diff) { tcg_out32(VAR_0, ADDI | TAI(VAR_2, TCG_REG_TB, tb_diff)); return; } if (TCG_TARGET_REG_BITS == 32 || VAR_3 == (int32_t)VAR_3) { tcg_out32(VAR_0, ADDIS | TAI(VAR_2, 0, VAR_3 >> 16)); tcg_out32(VAR_0, ORI | SAI(VAR_2, VAR_2, VAR_3)); return; } if (VAR_3 == (uint32_t)VAR_3 && !(VAR_3 & 0x8000)) { tcg_out32(VAR_0, ADDI | TAI(VAR_2, 0, VAR_3)); tcg_out32(VAR_0, ORIS | SAI(VAR_2, VAR_2, VAR_3 >> 16)); return; } if (VAR_3 > 0 && (VAR_3 & 0x8000)) { tmp = VAR_3 | 0x7fff; if ((tmp & (tmp + 1)) == 0) { int VAR_6 = clz64(tmp + 1) + 1; tcg_out32(VAR_0, ADDI | TAI(VAR_2, 0, VAR_3)); tcg_out_rld(VAR_0, RLDICL, VAR_2, VAR_2, 0, VAR_6); return; } } VAR_5 = ctz64(VAR_3); tmp = VAR_3 >> VAR_5; if (tmp == (int16_t)tmp) { tcg_out32(VAR_0, ADDI | TAI(VAR_2, 0, tmp)); tcg_out_shli64(VAR_0, VAR_2, VAR_2, VAR_5); return; } VAR_5 = clz64(VAR_3); if (tcg_out_movi_one(VAR_0, VAR_2, VAR_3 << VAR_5)) { tcg_out_shri64(VAR_0, VAR_2, VAR_2, VAR_5); return; } if (!VAR_4 && USE_REG_TB && tb_diff == (int32_t)tb_diff) { tcg_out_mem_long(VAR_0, ADDI, ADD, VAR_2, TCG_REG_TB, tb_diff); return; } if (!VAR_4 && USE_REG_TB) { new_pool_label(VAR_0, VAR_3, R_PPC_ADDR16, VAR_0->code_ptr, -(intptr_t)VAR_0->code_gen_ptr); tcg_out32(VAR_0, LD | TAI(VAR_2, TCG_REG_TB, 0)); return; } tmp = VAR_3 >> 31 >> 1; tcg_out_movi(VAR_0, TCG_TYPE_I32, VAR_2, tmp); if (tmp) { tcg_out_shli64(VAR_0, VAR_2, VAR_2, 32); } if (VAR_3 & 0xffff0000) { tcg_out32(VAR_0, ORIS | SAI(VAR_2, VAR_2, VAR_3 >> 16)); } if (VAR_3 & 0xffff) { tcg_out32(VAR_0, ORI | SAI(VAR_2, VAR_2, VAR_3)); } }
[ "static void FUNC_0(TCGContext *VAR_0, TCGType VAR_1, TCGReg VAR_2,\ntcg_target_long VAR_3, bool VAR_4)\n{", "intptr_t tb_diff;", "tcg_target_long tmp;", "int VAR_5;", "tcg_debug_assert(TCG_TARGET_REG_BITS == 64 || VAR_1 == TCG_TYPE_I32);", "if (TCG_TARGET_REG_BITS == 64 && VAR_1 == TCG_TYPE_I32) {", "VAR_3 = (int32_t)VAR_3;", "}", "if (tcg_out_movi_one(VAR_0, VAR_2, VAR_3)) {", "return;", "}", "tb_diff = VAR_3 - (intptr_t)VAR_0->code_gen_ptr;", "if (!VAR_4 && USE_REG_TB && tb_diff == (int16_t)tb_diff) {", "tcg_out32(VAR_0, ADDI | TAI(VAR_2, TCG_REG_TB, tb_diff));", "return;", "}", "if (TCG_TARGET_REG_BITS == 32 || VAR_3 == (int32_t)VAR_3) {", "tcg_out32(VAR_0, ADDIS | TAI(VAR_2, 0, VAR_3 >> 16));", "tcg_out32(VAR_0, ORI | SAI(VAR_2, VAR_2, VAR_3));", "return;", "}", "if (VAR_3 == (uint32_t)VAR_3 && !(VAR_3 & 0x8000)) {", "tcg_out32(VAR_0, ADDI | TAI(VAR_2, 0, VAR_3));", "tcg_out32(VAR_0, ORIS | SAI(VAR_2, VAR_2, VAR_3 >> 16));", "return;", "}", "if (VAR_3 > 0 && (VAR_3 & 0x8000)) {", "tmp = VAR_3 | 0x7fff;", "if ((tmp & (tmp + 1)) == 0) {", "int VAR_6 = clz64(tmp + 1) + 1;", "tcg_out32(VAR_0, ADDI | TAI(VAR_2, 0, VAR_3));", "tcg_out_rld(VAR_0, RLDICL, VAR_2, VAR_2, 0, VAR_6);", "return;", "}", "}", "VAR_5 = ctz64(VAR_3);", "tmp = VAR_3 >> VAR_5;", "if (tmp == (int16_t)tmp) {", "tcg_out32(VAR_0, ADDI | TAI(VAR_2, 0, tmp));", "tcg_out_shli64(VAR_0, VAR_2, VAR_2, VAR_5);", "return;", "}", "VAR_5 = clz64(VAR_3);", "if (tcg_out_movi_one(VAR_0, VAR_2, VAR_3 << VAR_5)) {", "tcg_out_shri64(VAR_0, VAR_2, VAR_2, VAR_5);", "return;", "}", "if (!VAR_4 && USE_REG_TB && tb_diff == (int32_t)tb_diff) {", "tcg_out_mem_long(VAR_0, ADDI, ADD, VAR_2, TCG_REG_TB, tb_diff);", "return;", "}", "if (!VAR_4 && USE_REG_TB) {", "new_pool_label(VAR_0, VAR_3, R_PPC_ADDR16, VAR_0->code_ptr,\n-(intptr_t)VAR_0->code_gen_ptr);", "tcg_out32(VAR_0, LD | TAI(VAR_2, TCG_REG_TB, 0));", "return;", "}", "tmp = VAR_3 >> 31 >> 1;", "tcg_out_movi(VAR_0, TCG_TYPE_I32, VAR_2, tmp);", "if (tmp) {", "tcg_out_shli64(VAR_0, VAR_2, VAR_2, 32);", "}", "if (VAR_3 & 0xffff0000) {", "tcg_out32(VAR_0, ORIS | SAI(VAR_2, VAR_2, VAR_3 >> 16));", "}", "if (VAR_3 & 0xffff) {", "tcg_out32(VAR_0, ORI | SAI(VAR_2, VAR_2, VAR_3));", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 29 ], [ 31 ], [ 33 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 141 ], [ 143, 145 ], [ 147 ], [ 149 ], [ 151 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ] ]
6,205
static int mpjpeg_read_probe(AVProbeData *p) { AVIOContext *pb; char line[128] = { 0 }; int ret = 0; pb = avio_alloc_context(p->buf, p->buf_size, 0, NULL, NULL, NULL, NULL); if (!pb) return AVERROR(ENOMEM); if (p->buf_size < 2 || p->buf[0] != '-' || p->buf[1] != '-') return 0; while (!pb->eof_reached) { ret = get_line(pb, line, sizeof(line)); if (ret < 0) break; ret = check_content_type(line); if (!ret) { ret = AVPROBE_SCORE_MAX; break; } } av_free(pb); return ret; }
true
FFmpeg
caf7be30b11288c498fae67be4741bfbf083d977
static int mpjpeg_read_probe(AVProbeData *p) { AVIOContext *pb; char line[128] = { 0 }; int ret = 0; pb = avio_alloc_context(p->buf, p->buf_size, 0, NULL, NULL, NULL, NULL); if (!pb) return AVERROR(ENOMEM); if (p->buf_size < 2 || p->buf[0] != '-' || p->buf[1] != '-') return 0; while (!pb->eof_reached) { ret = get_line(pb, line, sizeof(line)); if (ret < 0) break; ret = check_content_type(line); if (!ret) { ret = AVPROBE_SCORE_MAX; break; } } av_free(pb); return ret; }
{ "code": [ " return 0;" ], "line_no": [ 23 ] }
static int FUNC_0(AVProbeData *VAR_0) { AVIOContext *pb; char VAR_1[128] = { 0 }; int VAR_2 = 0; pb = avio_alloc_context(VAR_0->buf, VAR_0->buf_size, 0, NULL, NULL, NULL, NULL); if (!pb) return AVERROR(ENOMEM); if (VAR_0->buf_size < 2 || VAR_0->buf[0] != '-' || VAR_0->buf[1] != '-') return 0; while (!pb->eof_reached) { VAR_2 = get_line(pb, VAR_1, sizeof(VAR_1)); if (VAR_2 < 0) break; VAR_2 = check_content_type(VAR_1); if (!VAR_2) { VAR_2 = AVPROBE_SCORE_MAX; break; } } av_free(pb); return VAR_2; }
[ "static int FUNC_0(AVProbeData *VAR_0)\n{", "AVIOContext *pb;", "char VAR_1[128] = { 0 };", "int VAR_2 = 0;", "pb = avio_alloc_context(VAR_0->buf, VAR_0->buf_size, 0, NULL, NULL, NULL, NULL);", "if (!pb)\nreturn AVERROR(ENOMEM);", "if (VAR_0->buf_size < 2 || VAR_0->buf[0] != '-' || VAR_0->buf[1] != '-')\nreturn 0;", "while (!pb->eof_reached) {", "VAR_2 = get_line(pb, VAR_1, sizeof(VAR_1));", "if (VAR_2 < 0)\nbreak;", "VAR_2 = check_content_type(VAR_1);", "if (!VAR_2) {", "VAR_2 = AVPROBE_SCORE_MAX;", "break;", "}", "}", "av_free(pb);", "return VAR_2;", "}" ]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15, 17 ], [ 21, 23 ], [ 27 ], [ 29 ], [ 31, 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 55 ], [ 57 ] ]
6,208
static int flic_read_header(AVFormatContext *s) { FlicDemuxContext *flic = s->priv_data; AVIOContext *pb = s->pb; unsigned char header[FLIC_HEADER_SIZE]; AVStream *st, *ast; int speed; int magic_number; unsigned char preamble[FLIC_PREAMBLE_SIZE]; flic->frame_number = 0; /* load the whole header and pull out the width and height */ if (avio_read(pb, header, FLIC_HEADER_SIZE) != FLIC_HEADER_SIZE) return AVERROR(EIO); magic_number = AV_RL16(&header[4]); speed = AV_RL32(&header[0x10]); if (speed == 0) speed = FLIC_DEFAULT_SPEED; /* initialize the decoder streams */ st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); flic->video_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = AV_CODEC_ID_FLIC; st->codec->codec_tag = 0; /* no fourcc */ st->codec->width = AV_RL16(&header[0x08]); st->codec->height = AV_RL16(&header[0x0A]); if (!st->codec->width || !st->codec->height) { /* Ugly hack needed for the following sample: */ /* http://samples.mplayerhq.hu/fli-flc/fli-bugs/specular.flc */ av_log(s, AV_LOG_WARNING, "File with no specified width/height. Trying 640x480.\n"); st->codec->width = 640; st->codec->height = 480; } /* send over the whole 128-byte FLIC header */ st->codec->extradata_size = FLIC_HEADER_SIZE; st->codec->extradata = av_malloc(FLIC_HEADER_SIZE); memcpy(st->codec->extradata, header, FLIC_HEADER_SIZE); /* peek at the preamble to detect TFTD videos - they seem to always start with an audio chunk */ if (avio_read(pb, preamble, FLIC_PREAMBLE_SIZE) != FLIC_PREAMBLE_SIZE) { av_log(s, AV_LOG_ERROR, "Failed to peek at preamble\n"); return AVERROR(EIO); } avio_seek(pb, -FLIC_PREAMBLE_SIZE, SEEK_CUR); /* Time to figure out the framerate: * If the first preamble's magic number is 0xAAAA then this file is from * X-COM: Terror from the Deep. If on the other hand there is a FLIC chunk * magic number at offset 0x10 assume this file is from Magic Carpet instead. * If neither of the above is true then this is a normal FLIC file. */ if (AV_RL16(&preamble[4]) == FLIC_TFTD_CHUNK_AUDIO) { /* TFTD videos have an extra 22050 Hz 8-bit mono audio stream */ ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); flic->audio_stream_index = ast->index; /* all audio frames are the same size, so use the size of the first chunk for block_align */ ast->codec->block_align = AV_RL32(&preamble[0]); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast->codec->codec_id = AV_CODEC_ID_PCM_U8; ast->codec->codec_tag = 0; ast->codec->sample_rate = FLIC_TFTD_SAMPLE_RATE; ast->codec->channels = 1; ast->codec->bit_rate = st->codec->sample_rate * 8; ast->codec->bits_per_coded_sample = 8; ast->codec->channel_layout = AV_CH_LAYOUT_MONO; ast->codec->extradata_size = 0; /* Since the header information is incorrect we have to figure out the * framerate using block_align and the fact that the audio is 22050 Hz. * We usually have two cases: 2205 -> 10 fps and 1470 -> 15 fps */ avpriv_set_pts_info(st, 64, ast->codec->block_align, FLIC_TFTD_SAMPLE_RATE); avpriv_set_pts_info(ast, 64, 1, FLIC_TFTD_SAMPLE_RATE); } else if (AV_RL16(&header[0x10]) == FLIC_CHUNK_MAGIC_1) { avpriv_set_pts_info(st, 64, FLIC_MC_SPEED, 70); /* rewind the stream since the first chunk is at offset 12 */ avio_seek(pb, 12, SEEK_SET); /* send over abbreviated FLIC header chunk */ av_free(st->codec->extradata); st->codec->extradata_size = 12; st->codec->extradata = av_malloc(12); memcpy(st->codec->extradata, header, 12); } else if (magic_number == FLIC_FILE_MAGIC_1) { avpriv_set_pts_info(st, 64, speed, 70); } else if ((magic_number == FLIC_FILE_MAGIC_2) || (magic_number == FLIC_FILE_MAGIC_3)) { avpriv_set_pts_info(st, 64, speed, 1000); } else { av_log(s, AV_LOG_ERROR, "Invalid or unsupported magic chunk in file\n"); return AVERROR_INVALIDDATA; } return 0; }
true
FFmpeg
00e1bf8a587e26029f8fb20a35c65b99fe14196b
static int flic_read_header(AVFormatContext *s) { FlicDemuxContext *flic = s->priv_data; AVIOContext *pb = s->pb; unsigned char header[FLIC_HEADER_SIZE]; AVStream *st, *ast; int speed; int magic_number; unsigned char preamble[FLIC_PREAMBLE_SIZE]; flic->frame_number = 0; if (avio_read(pb, header, FLIC_HEADER_SIZE) != FLIC_HEADER_SIZE) return AVERROR(EIO); magic_number = AV_RL16(&header[4]); speed = AV_RL32(&header[0x10]); if (speed == 0) speed = FLIC_DEFAULT_SPEED; st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); flic->video_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = AV_CODEC_ID_FLIC; st->codec->codec_tag = 0; st->codec->width = AV_RL16(&header[0x08]); st->codec->height = AV_RL16(&header[0x0A]); if (!st->codec->width || !st->codec->height) { av_log(s, AV_LOG_WARNING, "File with no specified width/height. Trying 640x480.\n"); st->codec->width = 640; st->codec->height = 480; } st->codec->extradata_size = FLIC_HEADER_SIZE; st->codec->extradata = av_malloc(FLIC_HEADER_SIZE); memcpy(st->codec->extradata, header, FLIC_HEADER_SIZE); if (avio_read(pb, preamble, FLIC_PREAMBLE_SIZE) != FLIC_PREAMBLE_SIZE) { av_log(s, AV_LOG_ERROR, "Failed to peek at preamble\n"); return AVERROR(EIO); } avio_seek(pb, -FLIC_PREAMBLE_SIZE, SEEK_CUR); if (AV_RL16(&preamble[4]) == FLIC_TFTD_CHUNK_AUDIO) { ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); flic->audio_stream_index = ast->index; ast->codec->block_align = AV_RL32(&preamble[0]); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast->codec->codec_id = AV_CODEC_ID_PCM_U8; ast->codec->codec_tag = 0; ast->codec->sample_rate = FLIC_TFTD_SAMPLE_RATE; ast->codec->channels = 1; ast->codec->bit_rate = st->codec->sample_rate * 8; ast->codec->bits_per_coded_sample = 8; ast->codec->channel_layout = AV_CH_LAYOUT_MONO; ast->codec->extradata_size = 0; avpriv_set_pts_info(st, 64, ast->codec->block_align, FLIC_TFTD_SAMPLE_RATE); avpriv_set_pts_info(ast, 64, 1, FLIC_TFTD_SAMPLE_RATE); } else if (AV_RL16(&header[0x10]) == FLIC_CHUNK_MAGIC_1) { avpriv_set_pts_info(st, 64, FLIC_MC_SPEED, 70); avio_seek(pb, 12, SEEK_SET); av_free(st->codec->extradata); st->codec->extradata_size = 12; st->codec->extradata = av_malloc(12); memcpy(st->codec->extradata, header, 12); } else if (magic_number == FLIC_FILE_MAGIC_1) { avpriv_set_pts_info(st, 64, speed, 70); } else if ((magic_number == FLIC_FILE_MAGIC_2) || (magic_number == FLIC_FILE_MAGIC_3)) { avpriv_set_pts_info(st, 64, speed, 1000); } else { av_log(s, AV_LOG_ERROR, "Invalid or unsupported magic chunk in file\n"); return AVERROR_INVALIDDATA; } return 0; }
{ "code": [ " st->codec->extradata_size = FLIC_HEADER_SIZE;", " st->codec->extradata_size = 12;" ], "line_no": [ 85, 187 ] }
static int FUNC_0(AVFormatContext *VAR_0) { FlicDemuxContext *flic = VAR_0->priv_data; AVIOContext *pb = VAR_0->pb; unsigned char VAR_1[FLIC_HEADER_SIZE]; AVStream *st, *ast; int VAR_2; int VAR_3; unsigned char VAR_4[FLIC_PREAMBLE_SIZE]; flic->frame_number = 0; if (avio_read(pb, VAR_1, FLIC_HEADER_SIZE) != FLIC_HEADER_SIZE) return AVERROR(EIO); VAR_3 = AV_RL16(&VAR_1[4]); VAR_2 = AV_RL32(&VAR_1[0x10]); if (VAR_2 == 0) VAR_2 = FLIC_DEFAULT_SPEED; st = avformat_new_stream(VAR_0, NULL); if (!st) return AVERROR(ENOMEM); flic->video_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = AV_CODEC_ID_FLIC; st->codec->codec_tag = 0; st->codec->width = AV_RL16(&VAR_1[0x08]); st->codec->height = AV_RL16(&VAR_1[0x0A]); if (!st->codec->width || !st->codec->height) { av_log(VAR_0, AV_LOG_WARNING, "File with no specified width/height. Trying 640x480.\n"); st->codec->width = 640; st->codec->height = 480; } st->codec->extradata_size = FLIC_HEADER_SIZE; st->codec->extradata = av_malloc(FLIC_HEADER_SIZE); memcpy(st->codec->extradata, VAR_1, FLIC_HEADER_SIZE); if (avio_read(pb, VAR_4, FLIC_PREAMBLE_SIZE) != FLIC_PREAMBLE_SIZE) { av_log(VAR_0, AV_LOG_ERROR, "Failed to peek at VAR_4\n"); return AVERROR(EIO); } avio_seek(pb, -FLIC_PREAMBLE_SIZE, SEEK_CUR); if (AV_RL16(&VAR_4[4]) == FLIC_TFTD_CHUNK_AUDIO) { ast = avformat_new_stream(VAR_0, NULL); if (!ast) return AVERROR(ENOMEM); flic->audio_stream_index = ast->index; ast->codec->block_align = AV_RL32(&VAR_4[0]); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast->codec->codec_id = AV_CODEC_ID_PCM_U8; ast->codec->codec_tag = 0; ast->codec->sample_rate = FLIC_TFTD_SAMPLE_RATE; ast->codec->channels = 1; ast->codec->bit_rate = st->codec->sample_rate * 8; ast->codec->bits_per_coded_sample = 8; ast->codec->channel_layout = AV_CH_LAYOUT_MONO; ast->codec->extradata_size = 0; avpriv_set_pts_info(st, 64, ast->codec->block_align, FLIC_TFTD_SAMPLE_RATE); avpriv_set_pts_info(ast, 64, 1, FLIC_TFTD_SAMPLE_RATE); } else if (AV_RL16(&VAR_1[0x10]) == FLIC_CHUNK_MAGIC_1) { avpriv_set_pts_info(st, 64, FLIC_MC_SPEED, 70); avio_seek(pb, 12, SEEK_SET); av_free(st->codec->extradata); st->codec->extradata_size = 12; st->codec->extradata = av_malloc(12); memcpy(st->codec->extradata, VAR_1, 12); } else if (VAR_3 == FLIC_FILE_MAGIC_1) { avpriv_set_pts_info(st, 64, VAR_2, 70); } else if ((VAR_3 == FLIC_FILE_MAGIC_2) || (VAR_3 == FLIC_FILE_MAGIC_3)) { avpriv_set_pts_info(st, 64, VAR_2, 1000); } else { av_log(VAR_0, AV_LOG_ERROR, "Invalid or unsupported magic chunk in file\n"); return AVERROR_INVALIDDATA; } return 0; }
[ "static int FUNC_0(AVFormatContext *VAR_0)\n{", "FlicDemuxContext *flic = VAR_0->priv_data;", "AVIOContext *pb = VAR_0->pb;", "unsigned char VAR_1[FLIC_HEADER_SIZE];", "AVStream *st, *ast;", "int VAR_2;", "int VAR_3;", "unsigned char VAR_4[FLIC_PREAMBLE_SIZE];", "flic->frame_number = 0;", "if (avio_read(pb, VAR_1, FLIC_HEADER_SIZE) != FLIC_HEADER_SIZE)\nreturn AVERROR(EIO);", "VAR_3 = AV_RL16(&VAR_1[4]);", "VAR_2 = AV_RL32(&VAR_1[0x10]);", "if (VAR_2 == 0)\nVAR_2 = FLIC_DEFAULT_SPEED;", "st = avformat_new_stream(VAR_0, NULL);", "if (!st)\nreturn AVERROR(ENOMEM);", "flic->video_stream_index = st->index;", "st->codec->codec_type = AVMEDIA_TYPE_VIDEO;", "st->codec->codec_id = AV_CODEC_ID_FLIC;", "st->codec->codec_tag = 0;", "st->codec->width = AV_RL16(&VAR_1[0x08]);", "st->codec->height = AV_RL16(&VAR_1[0x0A]);", "if (!st->codec->width || !st->codec->height) {", "av_log(VAR_0, AV_LOG_WARNING,\n\"File with no specified width/height. Trying 640x480.\\n\");", "st->codec->width = 640;", "st->codec->height = 480;", "}", "st->codec->extradata_size = FLIC_HEADER_SIZE;", "st->codec->extradata = av_malloc(FLIC_HEADER_SIZE);", "memcpy(st->codec->extradata, VAR_1, FLIC_HEADER_SIZE);", "if (avio_read(pb, VAR_4, FLIC_PREAMBLE_SIZE) != FLIC_PREAMBLE_SIZE) {", "av_log(VAR_0, AV_LOG_ERROR, \"Failed to peek at VAR_4\\n\");", "return AVERROR(EIO);", "}", "avio_seek(pb, -FLIC_PREAMBLE_SIZE, SEEK_CUR);", "if (AV_RL16(&VAR_4[4]) == FLIC_TFTD_CHUNK_AUDIO) {", "ast = avformat_new_stream(VAR_0, NULL);", "if (!ast)\nreturn AVERROR(ENOMEM);", "flic->audio_stream_index = ast->index;", "ast->codec->block_align = AV_RL32(&VAR_4[0]);", "ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;", "ast->codec->codec_id = AV_CODEC_ID_PCM_U8;", "ast->codec->codec_tag = 0;", "ast->codec->sample_rate = FLIC_TFTD_SAMPLE_RATE;", "ast->codec->channels = 1;", "ast->codec->bit_rate = st->codec->sample_rate * 8;", "ast->codec->bits_per_coded_sample = 8;", "ast->codec->channel_layout = AV_CH_LAYOUT_MONO;", "ast->codec->extradata_size = 0;", "avpriv_set_pts_info(st, 64, ast->codec->block_align, FLIC_TFTD_SAMPLE_RATE);", "avpriv_set_pts_info(ast, 64, 1, FLIC_TFTD_SAMPLE_RATE);", "} else if (AV_RL16(&VAR_1[0x10]) == FLIC_CHUNK_MAGIC_1) {", "avpriv_set_pts_info(st, 64, FLIC_MC_SPEED, 70);", "avio_seek(pb, 12, SEEK_SET);", "av_free(st->codec->extradata);", "st->codec->extradata_size = 12;", "st->codec->extradata = av_malloc(12);", "memcpy(st->codec->extradata, VAR_1, 12);", "} else if (VAR_3 == FLIC_FILE_MAGIC_1) {", "avpriv_set_pts_info(st, 64, VAR_2, 70);", "} else if ((VAR_3 == FLIC_FILE_MAGIC_2) ||", "(VAR_3 == FLIC_FILE_MAGIC_3)) {", "avpriv_set_pts_info(st, 64, VAR_2, 1000);", "} else {", "av_log(VAR_0, AV_LOG_ERROR, \"Invalid or unsupported magic chunk in file\\n\");", "return AVERROR_INVALIDDATA;", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 27, 29 ], [ 33 ], [ 35 ], [ 37, 39 ], [ 45 ], [ 47, 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 65 ], [ 71, 73 ], [ 75 ], [ 77 ], [ 79 ], [ 85 ], [ 87 ], [ 89 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 105 ], [ 121 ], [ 125 ], [ 127, 129 ], [ 133 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 179 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 215 ], [ 217 ] ]
6,209
ds1225y_t *ds1225y_init(target_phys_addr_t mem_base, const char *filename) { ds1225y_t *s; int mem_index1, mem_index2; s = qemu_mallocz(sizeof(ds1225y_t)); if (!s) return NULL; s->mem_base = mem_base; s->capacity = 0x2000; /* Fixed for ds1225y chip: 8K */ s->filename = filename; /* Read/write memory */ mem_index1 = cpu_register_io_memory(0, nvram_read, nvram_write, s); cpu_register_physical_memory(mem_base, s->capacity, mem_index1); /* Read-only memory */ mem_index2 = cpu_register_io_memory(0, nvram_read, nvram_none, s); cpu_register_physical_memory(mem_base + s->capacity, s->capacity, mem_index2); return s; }
true
qemu
30aa5c0d303c334c646e9db1ebadda0c0db8b13f
ds1225y_t *ds1225y_init(target_phys_addr_t mem_base, const char *filename) { ds1225y_t *s; int mem_index1, mem_index2; s = qemu_mallocz(sizeof(ds1225y_t)); if (!s) return NULL; s->mem_base = mem_base; s->capacity = 0x2000; s->filename = filename; mem_index1 = cpu_register_io_memory(0, nvram_read, nvram_write, s); cpu_register_physical_memory(mem_base, s->capacity, mem_index1); mem_index2 = cpu_register_io_memory(0, nvram_read, nvram_none, s); cpu_register_physical_memory(mem_base + s->capacity, s->capacity, mem_index2); return s; }
{ "code": [ "ds1225y_t *ds1225y_init(target_phys_addr_t mem_base, const char *filename)\r", " ds1225y_t *s;\r", " int mem_index1, mem_index2;\r", " s = qemu_mallocz(sizeof(ds1225y_t));\r", " if (!s)\r", " return NULL;\r", " s->mem_base = mem_base;\r", " s->filename = filename;\r", " mem_index1 = cpu_register_io_memory(0, nvram_read, nvram_write, s);\r", " cpu_register_physical_memory(mem_base, s->capacity, mem_index1);\r", " mem_index2 = cpu_register_io_memory(0, nvram_read, nvram_none, s);\r", " cpu_register_physical_memory(mem_base + s->capacity, s->capacity, mem_index2);\r", " return s;\r" ], "line_no": [ 1, 5, 7, 11, 13, 15, 17, 21, 27, 29, 33, 35, 37 ] }
ds1225y_t *FUNC_0(target_phys_addr_t mem_base, const char *filename) { ds1225y_t *s; int VAR_0, VAR_1; s = qemu_mallocz(sizeof(ds1225y_t)); if (!s) return NULL; s->mem_base = mem_base; s->capacity = 0x2000; s->filename = filename; VAR_0 = cpu_register_io_memory(0, nvram_read, nvram_write, s); cpu_register_physical_memory(mem_base, s->capacity, VAR_0); VAR_1 = cpu_register_io_memory(0, nvram_read, nvram_none, s); cpu_register_physical_memory(mem_base + s->capacity, s->capacity, VAR_1); return s; }
[ "ds1225y_t *FUNC_0(target_phys_addr_t mem_base, const char *filename)\n{", "ds1225y_t *s;", "int VAR_0, VAR_1;", "s = qemu_mallocz(sizeof(ds1225y_t));", "if (!s)\nreturn NULL;", "s->mem_base = mem_base;", "s->capacity = 0x2000;", "s->filename = filename;", "VAR_0 = cpu_register_io_memory(0, nvram_read, nvram_write, s);", "cpu_register_physical_memory(mem_base, s->capacity, VAR_0);", "VAR_1 = cpu_register_io_memory(0, nvram_read, nvram_none, s);", "cpu_register_physical_memory(mem_base + s->capacity, s->capacity, VAR_1);", "return s;", "}" ]
[ 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13, 15 ], [ 17 ], [ 19 ], [ 21 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ] ]
6,210
static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, int letter, const char *buf) { RTSPState *rt = s->priv_data; char buf1[64], st_type[64]; const char *p; enum AVMediaType codec_type; int payload_type; AVStream *st; RTSPStream *rtsp_st; RTSPSource *rtsp_src; struct sockaddr_storage sdp_ip; int ttl; av_dlog(s, "sdp: %c='%s'\n", letter, buf); p = buf; if (s1->skip_media && letter != 'm') return; switch (letter) { case 'c': get_word(buf1, sizeof(buf1), &p); if (strcmp(buf1, "IN") != 0) return; get_word(buf1, sizeof(buf1), &p); if (strcmp(buf1, "IP4") && strcmp(buf1, "IP6")) return; get_word_sep(buf1, sizeof(buf1), "/", &p); if (get_sockaddr(buf1, &sdp_ip)) return; ttl = 16; if (*p == '/') { p++; get_word_sep(buf1, sizeof(buf1), "/", &p); ttl = atoi(buf1); } if (s->nb_streams == 0) { s1->default_ip = sdp_ip; s1->default_ttl = ttl; } else { rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; rtsp_st->sdp_ip = sdp_ip; rtsp_st->sdp_ttl = ttl; } break; case 's': av_dict_set(&s->metadata, "title", p, 0); break; case 'i': if (s->nb_streams == 0) { av_dict_set(&s->metadata, "comment", p, 0); break; } break; case 'm': /* new stream */ s1->skip_media = 0; s1->seen_fmtp = 0; s1->seen_rtpmap = 0; codec_type = AVMEDIA_TYPE_UNKNOWN; get_word(st_type, sizeof(st_type), &p); if (!strcmp(st_type, "audio")) { codec_type = AVMEDIA_TYPE_AUDIO; } else if (!strcmp(st_type, "video")) { codec_type = AVMEDIA_TYPE_VIDEO; } else if (!strcmp(st_type, "application")) { codec_type = AVMEDIA_TYPE_DATA; } if (codec_type == AVMEDIA_TYPE_UNKNOWN || !(rt->media_type_mask & (1 << codec_type))) { s1->skip_media = 1; return; } rtsp_st = av_mallocz(sizeof(RTSPStream)); if (!rtsp_st) return; rtsp_st->stream_index = -1; dynarray_add(&rt->rtsp_streams, &rt->nb_rtsp_streams, rtsp_st); rtsp_st->sdp_ip = s1->default_ip; rtsp_st->sdp_ttl = s1->default_ttl; copy_default_source_addrs(s1->default_include_source_addrs, s1->nb_default_include_source_addrs, &rtsp_st->include_source_addrs, &rtsp_st->nb_include_source_addrs); copy_default_source_addrs(s1->default_exclude_source_addrs, s1->nb_default_exclude_source_addrs, &rtsp_st->exclude_source_addrs, &rtsp_st->nb_exclude_source_addrs); get_word(buf1, sizeof(buf1), &p); /* port */ rtsp_st->sdp_port = atoi(buf1); get_word(buf1, sizeof(buf1), &p); /* protocol */ if (!strcmp(buf1, "udp")) rt->transport = RTSP_TRANSPORT_RAW; else if (strstr(buf1, "/AVPF") || strstr(buf1, "/SAVPF")) rtsp_st->feedback = 1; /* XXX: handle list of formats */ get_word(buf1, sizeof(buf1), &p); /* format list */ rtsp_st->sdp_payload_type = atoi(buf1); if (!strcmp(ff_rtp_enc_name(rtsp_st->sdp_payload_type), "MP2T")) { /* no corresponding stream */ if (rt->transport == RTSP_TRANSPORT_RAW) { if (!rt->ts && CONFIG_RTPDEC) rt->ts = ff_mpegts_parse_open(s); } else { RTPDynamicProtocolHandler *handler; handler = ff_rtp_handler_find_by_id( rtsp_st->sdp_payload_type, AVMEDIA_TYPE_DATA); init_rtp_handler(handler, rtsp_st, NULL); if (handler && handler->init) handler->init(s, -1, rtsp_st->dynamic_protocol_context); } } else if (rt->server_type == RTSP_SERVER_WMS && codec_type == AVMEDIA_TYPE_DATA) { /* RTX stream, a stream that carries all the other actual * audio/video streams. Don't expose this to the callers. */ } else { st = avformat_new_stream(s, NULL); if (!st) return; st->id = rt->nb_rtsp_streams - 1; rtsp_st->stream_index = st->index; st->codec->codec_type = codec_type; if (rtsp_st->sdp_payload_type < RTP_PT_PRIVATE) { RTPDynamicProtocolHandler *handler; /* if standard payload type, we can find the codec right now */ ff_rtp_get_codec_info(st->codec, rtsp_st->sdp_payload_type); if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->codec->sample_rate > 0) avpriv_set_pts_info(st, 32, 1, st->codec->sample_rate); /* Even static payload types may need a custom depacketizer */ handler = ff_rtp_handler_find_by_id( rtsp_st->sdp_payload_type, st->codec->codec_type); init_rtp_handler(handler, rtsp_st, st->codec); if (handler && handler->init) handler->init(s, st->index, rtsp_st->dynamic_protocol_context); } } /* put a default control url */ av_strlcpy(rtsp_st->control_url, rt->control_uri, sizeof(rtsp_st->control_url)); break; case 'a': if (av_strstart(p, "control:", &p)) { if (s->nb_streams == 0) { if (!strncmp(p, "rtsp://", 7)) av_strlcpy(rt->control_uri, p, sizeof(rt->control_uri)); } else { char proto[32]; /* get the control url */ rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; /* XXX: may need to add full url resolution */ av_url_split(proto, sizeof(proto), NULL, 0, NULL, 0, NULL, NULL, 0, p); if (proto[0] == '\0') { /* relative control URL */ if (rtsp_st->control_url[strlen(rtsp_st->control_url)-1]!='/') av_strlcat(rtsp_st->control_url, "/", sizeof(rtsp_st->control_url)); av_strlcat(rtsp_st->control_url, p, sizeof(rtsp_st->control_url)); } else av_strlcpy(rtsp_st->control_url, p, sizeof(rtsp_st->control_url)); } } else if (av_strstart(p, "rtpmap:", &p) && s->nb_streams > 0) { /* NOTE: rtpmap is only supported AFTER the 'm=' tag */ get_word(buf1, sizeof(buf1), &p); payload_type = atoi(buf1); rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; if (rtsp_st->stream_index >= 0) { st = s->streams[rtsp_st->stream_index]; sdp_parse_rtpmap(s, st, rtsp_st, payload_type, p); } s1->seen_rtpmap = 1; if (s1->seen_fmtp) { parse_fmtp(s, rt, payload_type, s1->delayed_fmtp); } } else if (av_strstart(p, "fmtp:", &p) || av_strstart(p, "framesize:", &p)) { // let dynamic protocol handlers have a stab at the line. get_word(buf1, sizeof(buf1), &p); payload_type = atoi(buf1); if (s1->seen_rtpmap) { parse_fmtp(s, rt, payload_type, buf); } else { s1->seen_fmtp = 1; av_strlcpy(s1->delayed_fmtp, buf, sizeof(s1->delayed_fmtp)); } } else if (av_strstart(p, "range:", &p)) { int64_t start, end; // this is so that seeking on a streamed file can work. rtsp_parse_range_npt(p, &start, &end); s->start_time = start; /* AV_NOPTS_VALUE means live broadcast (and can't seek) */ s->duration = (end == AV_NOPTS_VALUE) ? AV_NOPTS_VALUE : end - start; } else if (av_strstart(p, "IsRealDataType:integer;",&p)) { if (atoi(p) == 1) rt->transport = RTSP_TRANSPORT_RDT; } else if (av_strstart(p, "SampleRate:integer;", &p) && s->nb_streams > 0) { st = s->streams[s->nb_streams - 1]; st->codec->sample_rate = atoi(p); } else if (av_strstart(p, "crypto:", &p) && s->nb_streams > 0) { // RFC 4568 rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; get_word(buf1, sizeof(buf1), &p); // ignore tag get_word(rtsp_st->crypto_suite, sizeof(rtsp_st->crypto_suite), &p); p += strspn(p, SPACE_CHARS); if (av_strstart(p, "inline:", &p)) get_word(rtsp_st->crypto_params, sizeof(rtsp_st->crypto_params), &p); } else if (av_strstart(p, "source-filter:", &p)) { int exclude = 0; get_word(buf1, sizeof(buf1), &p); if (strcmp(buf1, "incl") && strcmp(buf1, "excl")) return; exclude = !strcmp(buf1, "excl"); get_word(buf1, sizeof(buf1), &p); if (strcmp(buf1, "IN") != 0) return; get_word(buf1, sizeof(buf1), &p); if (strcmp(buf1, "IP4") && strcmp(buf1, "IP6") && strcmp(buf1, "*")) return; // not checking that the destination address actually matches or is wildcard get_word(buf1, sizeof(buf1), &p); while (*p != '\0') { rtsp_src = av_mallocz(sizeof(*rtsp_src)); if (!rtsp_src) return; get_word(rtsp_src->addr, sizeof(rtsp_src->addr), &p); if (exclude) { if (s->nb_streams == 0) { dynarray_add(&s1->default_exclude_source_addrs, &s1->nb_default_exclude_source_addrs, rtsp_src); } else { rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; dynarray_add(&rtsp_st->exclude_source_addrs, &rtsp_st->nb_exclude_source_addrs, rtsp_src); } } else { if (s->nb_streams == 0) { dynarray_add(&s1->default_include_source_addrs, &s1->nb_default_include_source_addrs, rtsp_src); } else { rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; dynarray_add(&rtsp_st->include_source_addrs, &rtsp_st->nb_include_source_addrs, rtsp_src); } } } } else { if (rt->server_type == RTSP_SERVER_WMS) ff_wms_parse_sdp_a_line(s, p); if (s->nb_streams > 0) { rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; if (rt->server_type == RTSP_SERVER_REAL) ff_real_parse_sdp_a_line(s, rtsp_st->stream_index, p); if (rtsp_st->dynamic_handler && rtsp_st->dynamic_handler->parse_sdp_a_line) rtsp_st->dynamic_handler->parse_sdp_a_line(s, rtsp_st->stream_index, rtsp_st->dynamic_protocol_context, buf); } } break; } }
true
FFmpeg
604c9b1196c70d79bbbc1f23e75f6a8253a74da3
static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, int letter, const char *buf) { RTSPState *rt = s->priv_data; char buf1[64], st_type[64]; const char *p; enum AVMediaType codec_type; int payload_type; AVStream *st; RTSPStream *rtsp_st; RTSPSource *rtsp_src; struct sockaddr_storage sdp_ip; int ttl; av_dlog(s, "sdp: %c='%s'\n", letter, buf); p = buf; if (s1->skip_media && letter != 'm') return; switch (letter) { case 'c': get_word(buf1, sizeof(buf1), &p); if (strcmp(buf1, "IN") != 0) return; get_word(buf1, sizeof(buf1), &p); if (strcmp(buf1, "IP4") && strcmp(buf1, "IP6")) return; get_word_sep(buf1, sizeof(buf1), "/", &p); if (get_sockaddr(buf1, &sdp_ip)) return; ttl = 16; if (*p == '/') { p++; get_word_sep(buf1, sizeof(buf1), "/", &p); ttl = atoi(buf1); } if (s->nb_streams == 0) { s1->default_ip = sdp_ip; s1->default_ttl = ttl; } else { rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; rtsp_st->sdp_ip = sdp_ip; rtsp_st->sdp_ttl = ttl; } break; case 's': av_dict_set(&s->metadata, "title", p, 0); break; case 'i': if (s->nb_streams == 0) { av_dict_set(&s->metadata, "comment", p, 0); break; } break; case 'm': s1->skip_media = 0; s1->seen_fmtp = 0; s1->seen_rtpmap = 0; codec_type = AVMEDIA_TYPE_UNKNOWN; get_word(st_type, sizeof(st_type), &p); if (!strcmp(st_type, "audio")) { codec_type = AVMEDIA_TYPE_AUDIO; } else if (!strcmp(st_type, "video")) { codec_type = AVMEDIA_TYPE_VIDEO; } else if (!strcmp(st_type, "application")) { codec_type = AVMEDIA_TYPE_DATA; } if (codec_type == AVMEDIA_TYPE_UNKNOWN || !(rt->media_type_mask & (1 << codec_type))) { s1->skip_media = 1; return; } rtsp_st = av_mallocz(sizeof(RTSPStream)); if (!rtsp_st) return; rtsp_st->stream_index = -1; dynarray_add(&rt->rtsp_streams, &rt->nb_rtsp_streams, rtsp_st); rtsp_st->sdp_ip = s1->default_ip; rtsp_st->sdp_ttl = s1->default_ttl; copy_default_source_addrs(s1->default_include_source_addrs, s1->nb_default_include_source_addrs, &rtsp_st->include_source_addrs, &rtsp_st->nb_include_source_addrs); copy_default_source_addrs(s1->default_exclude_source_addrs, s1->nb_default_exclude_source_addrs, &rtsp_st->exclude_source_addrs, &rtsp_st->nb_exclude_source_addrs); get_word(buf1, sizeof(buf1), &p); rtsp_st->sdp_port = atoi(buf1); get_word(buf1, sizeof(buf1), &p); if (!strcmp(buf1, "udp")) rt->transport = RTSP_TRANSPORT_RAW; else if (strstr(buf1, "/AVPF") || strstr(buf1, "/SAVPF")) rtsp_st->feedback = 1; get_word(buf1, sizeof(buf1), &p); rtsp_st->sdp_payload_type = atoi(buf1); if (!strcmp(ff_rtp_enc_name(rtsp_st->sdp_payload_type), "MP2T")) { if (rt->transport == RTSP_TRANSPORT_RAW) { if (!rt->ts && CONFIG_RTPDEC) rt->ts = ff_mpegts_parse_open(s); } else { RTPDynamicProtocolHandler *handler; handler = ff_rtp_handler_find_by_id( rtsp_st->sdp_payload_type, AVMEDIA_TYPE_DATA); init_rtp_handler(handler, rtsp_st, NULL); if (handler && handler->init) handler->init(s, -1, rtsp_st->dynamic_protocol_context); } } else if (rt->server_type == RTSP_SERVER_WMS && codec_type == AVMEDIA_TYPE_DATA) { } else { st = avformat_new_stream(s, NULL); if (!st) return; st->id = rt->nb_rtsp_streams - 1; rtsp_st->stream_index = st->index; st->codec->codec_type = codec_type; if (rtsp_st->sdp_payload_type < RTP_PT_PRIVATE) { RTPDynamicProtocolHandler *handler; ff_rtp_get_codec_info(st->codec, rtsp_st->sdp_payload_type); if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->codec->sample_rate > 0) avpriv_set_pts_info(st, 32, 1, st->codec->sample_rate); handler = ff_rtp_handler_find_by_id( rtsp_st->sdp_payload_type, st->codec->codec_type); init_rtp_handler(handler, rtsp_st, st->codec); if (handler && handler->init) handler->init(s, st->index, rtsp_st->dynamic_protocol_context); } } av_strlcpy(rtsp_st->control_url, rt->control_uri, sizeof(rtsp_st->control_url)); break; case 'a': if (av_strstart(p, "control:", &p)) { if (s->nb_streams == 0) { if (!strncmp(p, "rtsp: av_strlcpy(rt->control_uri, p, sizeof(rt->control_uri)); } else { char proto[32]; rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; av_url_split(proto, sizeof(proto), NULL, 0, NULL, 0, NULL, NULL, 0, p); if (proto[0] == '\0') { if (rtsp_st->control_url[strlen(rtsp_st->control_url)-1]!='/') av_strlcat(rtsp_st->control_url, "/", sizeof(rtsp_st->control_url)); av_strlcat(rtsp_st->control_url, p, sizeof(rtsp_st->control_url)); } else av_strlcpy(rtsp_st->control_url, p, sizeof(rtsp_st->control_url)); } } else if (av_strstart(p, "rtpmap:", &p) && s->nb_streams > 0) { get_word(buf1, sizeof(buf1), &p); payload_type = atoi(buf1); rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; if (rtsp_st->stream_index >= 0) { st = s->streams[rtsp_st->stream_index]; sdp_parse_rtpmap(s, st, rtsp_st, payload_type, p); } s1->seen_rtpmap = 1; if (s1->seen_fmtp) { parse_fmtp(s, rt, payload_type, s1->delayed_fmtp); } } else if (av_strstart(p, "fmtp:", &p) || av_strstart(p, "framesize:", &p)) { get_word(buf1, sizeof(buf1), &p); payload_type = atoi(buf1); if (s1->seen_rtpmap) { parse_fmtp(s, rt, payload_type, buf); } else { s1->seen_fmtp = 1; av_strlcpy(s1->delayed_fmtp, buf, sizeof(s1->delayed_fmtp)); } } else if (av_strstart(p, "range:", &p)) { int64_t start, end; rtsp_parse_range_npt(p, &start, &end); s->start_time = start; s->duration = (end == AV_NOPTS_VALUE) ? AV_NOPTS_VALUE : end - start; } else if (av_strstart(p, "IsRealDataType:integer;",&p)) { if (atoi(p) == 1) rt->transport = RTSP_TRANSPORT_RDT; } else if (av_strstart(p, "SampleRate:integer;", &p) && s->nb_streams > 0) { st = s->streams[s->nb_streams - 1]; st->codec->sample_rate = atoi(p); } else if (av_strstart(p, "crypto:", &p) && s->nb_streams > 0) { rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; get_word(buf1, sizeof(buf1), &p); get_word(rtsp_st->crypto_suite, sizeof(rtsp_st->crypto_suite), &p); p += strspn(p, SPACE_CHARS); if (av_strstart(p, "inline:", &p)) get_word(rtsp_st->crypto_params, sizeof(rtsp_st->crypto_params), &p); } else if (av_strstart(p, "source-filter:", &p)) { int exclude = 0; get_word(buf1, sizeof(buf1), &p); if (strcmp(buf1, "incl") && strcmp(buf1, "excl")) return; exclude = !strcmp(buf1, "excl"); get_word(buf1, sizeof(buf1), &p); if (strcmp(buf1, "IN") != 0) return; get_word(buf1, sizeof(buf1), &p); if (strcmp(buf1, "IP4") && strcmp(buf1, "IP6") && strcmp(buf1, "*")) return; get_word(buf1, sizeof(buf1), &p); while (*p != '\0') { rtsp_src = av_mallocz(sizeof(*rtsp_src)); if (!rtsp_src) return; get_word(rtsp_src->addr, sizeof(rtsp_src->addr), &p); if (exclude) { if (s->nb_streams == 0) { dynarray_add(&s1->default_exclude_source_addrs, &s1->nb_default_exclude_source_addrs, rtsp_src); } else { rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; dynarray_add(&rtsp_st->exclude_source_addrs, &rtsp_st->nb_exclude_source_addrs, rtsp_src); } } else { if (s->nb_streams == 0) { dynarray_add(&s1->default_include_source_addrs, &s1->nb_default_include_source_addrs, rtsp_src); } else { rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; dynarray_add(&rtsp_st->include_source_addrs, &rtsp_st->nb_include_source_addrs, rtsp_src); } } } } else { if (rt->server_type == RTSP_SERVER_WMS) ff_wms_parse_sdp_a_line(s, p); if (s->nb_streams > 0) { rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; if (rt->server_type == RTSP_SERVER_REAL) ff_real_parse_sdp_a_line(s, rtsp_st->stream_index, p); if (rtsp_st->dynamic_handler && rtsp_st->dynamic_handler->parse_sdp_a_line) rtsp_st->dynamic_handler->parse_sdp_a_line(s, rtsp_st->stream_index, rtsp_st->dynamic_protocol_context, buf); } } break; } }
{ "code": [ " if (!rt->ts && CONFIG_RTPDEC)" ], "line_no": [ 213 ] }
static void FUNC_0(AVFormatContext *VAR_0, SDPParseState *VAR_1, int VAR_2, const char *VAR_3) { RTSPState *rt = VAR_0->priv_data; char VAR_4[64], VAR_5[64]; const char *VAR_6; enum AVMediaType VAR_7; int VAR_8; AVStream *st; RTSPStream *rtsp_st; RTSPSource *rtsp_src; struct sockaddr_storage VAR_9; int VAR_10; av_dlog(VAR_0, "sdp: %c='%VAR_0'\n", VAR_2, VAR_3); VAR_6 = VAR_3; if (VAR_1->skip_media && VAR_2 != 'm') return; switch (VAR_2) { case 'c': get_word(VAR_4, sizeof(VAR_4), &VAR_6); if (strcmp(VAR_4, "IN") != 0) return; get_word(VAR_4, sizeof(VAR_4), &VAR_6); if (strcmp(VAR_4, "IP4") && strcmp(VAR_4, "IP6")) return; get_word_sep(VAR_4, sizeof(VAR_4), "/", &VAR_6); if (get_sockaddr(VAR_4, &VAR_9)) return; VAR_10 = 16; if (*VAR_6 == '/') { VAR_6++; get_word_sep(VAR_4, sizeof(VAR_4), "/", &VAR_6); VAR_10 = atoi(VAR_4); } if (VAR_0->nb_streams == 0) { VAR_1->default_ip = VAR_9; VAR_1->default_ttl = VAR_10; } else { rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; rtsp_st->VAR_9 = VAR_9; rtsp_st->sdp_ttl = VAR_10; } break; case 'VAR_0': av_dict_set(&VAR_0->metadata, "title", VAR_6, 0); break; case 'i': if (VAR_0->nb_streams == 0) { av_dict_set(&VAR_0->metadata, "comment", VAR_6, 0); break; } break; case 'm': VAR_1->skip_media = 0; VAR_1->seen_fmtp = 0; VAR_1->seen_rtpmap = 0; VAR_7 = AVMEDIA_TYPE_UNKNOWN; get_word(VAR_5, sizeof(VAR_5), &VAR_6); if (!strcmp(VAR_5, "audio")) { VAR_7 = AVMEDIA_TYPE_AUDIO; } else if (!strcmp(VAR_5, "video")) { VAR_7 = AVMEDIA_TYPE_VIDEO; } else if (!strcmp(VAR_5, "application")) { VAR_7 = AVMEDIA_TYPE_DATA; } if (VAR_7 == AVMEDIA_TYPE_UNKNOWN || !(rt->media_type_mask & (1 << VAR_7))) { VAR_1->skip_media = 1; return; } rtsp_st = av_mallocz(sizeof(RTSPStream)); if (!rtsp_st) return; rtsp_st->stream_index = -1; dynarray_add(&rt->rtsp_streams, &rt->nb_rtsp_streams, rtsp_st); rtsp_st->VAR_9 = VAR_1->default_ip; rtsp_st->sdp_ttl = VAR_1->default_ttl; copy_default_source_addrs(VAR_1->default_include_source_addrs, VAR_1->nb_default_include_source_addrs, &rtsp_st->include_source_addrs, &rtsp_st->nb_include_source_addrs); copy_default_source_addrs(VAR_1->default_exclude_source_addrs, VAR_1->nb_default_exclude_source_addrs, &rtsp_st->exclude_source_addrs, &rtsp_st->nb_exclude_source_addrs); get_word(VAR_4, sizeof(VAR_4), &VAR_6); rtsp_st->sdp_port = atoi(VAR_4); get_word(VAR_4, sizeof(VAR_4), &VAR_6); if (!strcmp(VAR_4, "udp")) rt->transport = RTSP_TRANSPORT_RAW; else if (strstr(VAR_4, "/AVPF") || strstr(VAR_4, "/SAVPF")) rtsp_st->feedback = 1; get_word(VAR_4, sizeof(VAR_4), &VAR_6); rtsp_st->sdp_payload_type = atoi(VAR_4); if (!strcmp(ff_rtp_enc_name(rtsp_st->sdp_payload_type), "MP2T")) { if (rt->transport == RTSP_TRANSPORT_RAW) { if (!rt->ts && CONFIG_RTPDEC) rt->ts = ff_mpegts_parse_open(VAR_0); } else { RTPDynamicProtocolHandler *handler; handler = ff_rtp_handler_find_by_id( rtsp_st->sdp_payload_type, AVMEDIA_TYPE_DATA); init_rtp_handler(handler, rtsp_st, NULL); if (handler && handler->init) handler->init(VAR_0, -1, rtsp_st->dynamic_protocol_context); } } else if (rt->server_type == RTSP_SERVER_WMS && VAR_7 == AVMEDIA_TYPE_DATA) { } else { st = avformat_new_stream(VAR_0, NULL); if (!st) return; st->id = rt->nb_rtsp_streams - 1; rtsp_st->stream_index = st->index; st->codec->VAR_7 = VAR_7; if (rtsp_st->sdp_payload_type < RTP_PT_PRIVATE) { RTPDynamicProtocolHandler *handler; ff_rtp_get_codec_info(st->codec, rtsp_st->sdp_payload_type); if (st->codec->VAR_7 == AVMEDIA_TYPE_AUDIO && st->codec->sample_rate > 0) avpriv_set_pts_info(st, 32, 1, st->codec->sample_rate); handler = ff_rtp_handler_find_by_id( rtsp_st->sdp_payload_type, st->codec->VAR_7); init_rtp_handler(handler, rtsp_st, st->codec); if (handler && handler->init) handler->init(VAR_0, st->index, rtsp_st->dynamic_protocol_context); } } av_strlcpy(rtsp_st->control_url, rt->control_uri, sizeof(rtsp_st->control_url)); break; case 'a': if (av_strstart(VAR_6, "control:", &VAR_6)) { if (VAR_0->nb_streams == 0) { if (!strncmp(VAR_6, "rtsp: av_strlcpy(rt->control_uri, VAR_6, sizeof(rt->control_uri)); } else { char proto[32]; rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; av_url_split(proto, sizeof(proto), NULL, 0, NULL, 0, NULL, NULL, 0, VAR_6); if (proto[0] == '\0') { if (rtsp_st->control_url[strlen(rtsp_st->control_url)-1]!='/') av_strlcat(rtsp_st->control_url, "/", sizeof(rtsp_st->control_url)); av_strlcat(rtsp_st->control_url, VAR_6, sizeof(rtsp_st->control_url)); } else av_strlcpy(rtsp_st->control_url, VAR_6, sizeof(rtsp_st->control_url)); } } else if (av_strstart(VAR_6, "rtpmap:", &VAR_6) && VAR_0->nb_streams > 0) { get_word(VAR_4, sizeof(VAR_4), &VAR_6); VAR_8 = atoi(VAR_4); rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; if (rtsp_st->stream_index >= 0) { st = VAR_0->streams[rtsp_st->stream_index]; sdp_parse_rtpmap(VAR_0, st, rtsp_st, VAR_8, VAR_6); } VAR_1->seen_rtpmap = 1; if (VAR_1->seen_fmtp) { parse_fmtp(VAR_0, rt, VAR_8, VAR_1->delayed_fmtp); } } else if (av_strstart(VAR_6, "fmtp:", &VAR_6) || av_strstart(VAR_6, "framesize:", &VAR_6)) { get_word(VAR_4, sizeof(VAR_4), &VAR_6); VAR_8 = atoi(VAR_4); if (VAR_1->seen_rtpmap) { parse_fmtp(VAR_0, rt, VAR_8, VAR_3); } else { VAR_1->seen_fmtp = 1; av_strlcpy(VAR_1->delayed_fmtp, VAR_3, sizeof(VAR_1->delayed_fmtp)); } } else if (av_strstart(VAR_6, "range:", &VAR_6)) { int64_t start, end; rtsp_parse_range_npt(VAR_6, &start, &end); VAR_0->start_time = start; VAR_0->duration = (end == AV_NOPTS_VALUE) ? AV_NOPTS_VALUE : end - start; } else if (av_strstart(VAR_6, "IsRealDataType:integer;",&VAR_6)) { if (atoi(VAR_6) == 1) rt->transport = RTSP_TRANSPORT_RDT; } else if (av_strstart(VAR_6, "SampleRate:integer;", &VAR_6) && VAR_0->nb_streams > 0) { st = VAR_0->streams[VAR_0->nb_streams - 1]; st->codec->sample_rate = atoi(VAR_6); } else if (av_strstart(VAR_6, "crypto:", &VAR_6) && VAR_0->nb_streams > 0) { rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; get_word(VAR_4, sizeof(VAR_4), &VAR_6); get_word(rtsp_st->crypto_suite, sizeof(rtsp_st->crypto_suite), &VAR_6); VAR_6 += strspn(VAR_6, SPACE_CHARS); if (av_strstart(VAR_6, "inline:", &VAR_6)) get_word(rtsp_st->crypto_params, sizeof(rtsp_st->crypto_params), &VAR_6); } else if (av_strstart(VAR_6, "source-filter:", &VAR_6)) { int exclude = 0; get_word(VAR_4, sizeof(VAR_4), &VAR_6); if (strcmp(VAR_4, "incl") && strcmp(VAR_4, "excl")) return; exclude = !strcmp(VAR_4, "excl"); get_word(VAR_4, sizeof(VAR_4), &VAR_6); if (strcmp(VAR_4, "IN") != 0) return; get_word(VAR_4, sizeof(VAR_4), &VAR_6); if (strcmp(VAR_4, "IP4") && strcmp(VAR_4, "IP6") && strcmp(VAR_4, "*")) return; get_word(VAR_4, sizeof(VAR_4), &VAR_6); while (*VAR_6 != '\0') { rtsp_src = av_mallocz(sizeof(*rtsp_src)); if (!rtsp_src) return; get_word(rtsp_src->addr, sizeof(rtsp_src->addr), &VAR_6); if (exclude) { if (VAR_0->nb_streams == 0) { dynarray_add(&VAR_1->default_exclude_source_addrs, &VAR_1->nb_default_exclude_source_addrs, rtsp_src); } else { rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; dynarray_add(&rtsp_st->exclude_source_addrs, &rtsp_st->nb_exclude_source_addrs, rtsp_src); } } else { if (VAR_0->nb_streams == 0) { dynarray_add(&VAR_1->default_include_source_addrs, &VAR_1->nb_default_include_source_addrs, rtsp_src); } else { rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; dynarray_add(&rtsp_st->include_source_addrs, &rtsp_st->nb_include_source_addrs, rtsp_src); } } } } else { if (rt->server_type == RTSP_SERVER_WMS) ff_wms_parse_sdp_a_line(VAR_0, VAR_6); if (VAR_0->nb_streams > 0) { rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; if (rt->server_type == RTSP_SERVER_REAL) ff_real_parse_sdp_a_line(VAR_0, rtsp_st->stream_index, VAR_6); if (rtsp_st->dynamic_handler && rtsp_st->dynamic_handler->parse_sdp_a_line) rtsp_st->dynamic_handler->parse_sdp_a_line(VAR_0, rtsp_st->stream_index, rtsp_st->dynamic_protocol_context, VAR_3); } } break; } }
[ "static void FUNC_0(AVFormatContext *VAR_0, SDPParseState *VAR_1,\nint VAR_2, const char *VAR_3)\n{", "RTSPState *rt = VAR_0->priv_data;", "char VAR_4[64], VAR_5[64];", "const char *VAR_6;", "enum AVMediaType VAR_7;", "int VAR_8;", "AVStream *st;", "RTSPStream *rtsp_st;", "RTSPSource *rtsp_src;", "struct sockaddr_storage VAR_9;", "int VAR_10;", "av_dlog(VAR_0, \"sdp: %c='%VAR_0'\\n\", VAR_2, VAR_3);", "VAR_6 = VAR_3;", "if (VAR_1->skip_media && VAR_2 != 'm')\nreturn;", "switch (VAR_2) {", "case 'c':\nget_word(VAR_4, sizeof(VAR_4), &VAR_6);", "if (strcmp(VAR_4, \"IN\") != 0)\nreturn;", "get_word(VAR_4, sizeof(VAR_4), &VAR_6);", "if (strcmp(VAR_4, \"IP4\") && strcmp(VAR_4, \"IP6\"))\nreturn;", "get_word_sep(VAR_4, sizeof(VAR_4), \"/\", &VAR_6);", "if (get_sockaddr(VAR_4, &VAR_9))\nreturn;", "VAR_10 = 16;", "if (*VAR_6 == '/') {", "VAR_6++;", "get_word_sep(VAR_4, sizeof(VAR_4), \"/\", &VAR_6);", "VAR_10 = atoi(VAR_4);", "}", "if (VAR_0->nb_streams == 0) {", "VAR_1->default_ip = VAR_9;", "VAR_1->default_ttl = VAR_10;", "} else {", "rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];", "rtsp_st->VAR_9 = VAR_9;", "rtsp_st->sdp_ttl = VAR_10;", "}", "break;", "case 'VAR_0':\nav_dict_set(&VAR_0->metadata, \"title\", VAR_6, 0);", "break;", "case 'i':\nif (VAR_0->nb_streams == 0) {", "av_dict_set(&VAR_0->metadata, \"comment\", VAR_6, 0);", "break;", "}", "break;", "case 'm':\nVAR_1->skip_media = 0;", "VAR_1->seen_fmtp = 0;", "VAR_1->seen_rtpmap = 0;", "VAR_7 = AVMEDIA_TYPE_UNKNOWN;", "get_word(VAR_5, sizeof(VAR_5), &VAR_6);", "if (!strcmp(VAR_5, \"audio\")) {", "VAR_7 = AVMEDIA_TYPE_AUDIO;", "} else if (!strcmp(VAR_5, \"video\")) {", "VAR_7 = AVMEDIA_TYPE_VIDEO;", "} else if (!strcmp(VAR_5, \"application\")) {", "VAR_7 = AVMEDIA_TYPE_DATA;", "}", "if (VAR_7 == AVMEDIA_TYPE_UNKNOWN || !(rt->media_type_mask & (1 << VAR_7))) {", "VAR_1->skip_media = 1;", "return;", "}", "rtsp_st = av_mallocz(sizeof(RTSPStream));", "if (!rtsp_st)\nreturn;", "rtsp_st->stream_index = -1;", "dynarray_add(&rt->rtsp_streams, &rt->nb_rtsp_streams, rtsp_st);", "rtsp_st->VAR_9 = VAR_1->default_ip;", "rtsp_st->sdp_ttl = VAR_1->default_ttl;", "copy_default_source_addrs(VAR_1->default_include_source_addrs,\nVAR_1->nb_default_include_source_addrs,\n&rtsp_st->include_source_addrs,\n&rtsp_st->nb_include_source_addrs);", "copy_default_source_addrs(VAR_1->default_exclude_source_addrs,\nVAR_1->nb_default_exclude_source_addrs,\n&rtsp_st->exclude_source_addrs,\n&rtsp_st->nb_exclude_source_addrs);", "get_word(VAR_4, sizeof(VAR_4), &VAR_6);", "rtsp_st->sdp_port = atoi(VAR_4);", "get_word(VAR_4, sizeof(VAR_4), &VAR_6);", "if (!strcmp(VAR_4, \"udp\"))\nrt->transport = RTSP_TRANSPORT_RAW;", "else if (strstr(VAR_4, \"/AVPF\") || strstr(VAR_4, \"/SAVPF\"))\nrtsp_st->feedback = 1;", "get_word(VAR_4, sizeof(VAR_4), &VAR_6);", "rtsp_st->sdp_payload_type = atoi(VAR_4);", "if (!strcmp(ff_rtp_enc_name(rtsp_st->sdp_payload_type), \"MP2T\")) {", "if (rt->transport == RTSP_TRANSPORT_RAW) {", "if (!rt->ts && CONFIG_RTPDEC)\nrt->ts = ff_mpegts_parse_open(VAR_0);", "} else {", "RTPDynamicProtocolHandler *handler;", "handler = ff_rtp_handler_find_by_id(\nrtsp_st->sdp_payload_type, AVMEDIA_TYPE_DATA);", "init_rtp_handler(handler, rtsp_st, NULL);", "if (handler && handler->init)\nhandler->init(VAR_0, -1, rtsp_st->dynamic_protocol_context);", "}", "} else if (rt->server_type == RTSP_SERVER_WMS &&", "VAR_7 == AVMEDIA_TYPE_DATA) {", "} else {", "st = avformat_new_stream(VAR_0, NULL);", "if (!st)\nreturn;", "st->id = rt->nb_rtsp_streams - 1;", "rtsp_st->stream_index = st->index;", "st->codec->VAR_7 = VAR_7;", "if (rtsp_st->sdp_payload_type < RTP_PT_PRIVATE) {", "RTPDynamicProtocolHandler *handler;", "ff_rtp_get_codec_info(st->codec, rtsp_st->sdp_payload_type);", "if (st->codec->VAR_7 == AVMEDIA_TYPE_AUDIO &&\nst->codec->sample_rate > 0)\navpriv_set_pts_info(st, 32, 1, st->codec->sample_rate);", "handler = ff_rtp_handler_find_by_id(\nrtsp_st->sdp_payload_type, st->codec->VAR_7);", "init_rtp_handler(handler, rtsp_st, st->codec);", "if (handler && handler->init)\nhandler->init(VAR_0, st->index,\nrtsp_st->dynamic_protocol_context);", "}", "}", "av_strlcpy(rtsp_st->control_url, rt->control_uri,\nsizeof(rtsp_st->control_url));", "break;", "case 'a':\nif (av_strstart(VAR_6, \"control:\", &VAR_6)) {", "if (VAR_0->nb_streams == 0) {", "if (!strncmp(VAR_6, \"rtsp:\nav_strlcpy(rt->control_uri, VAR_6,\nsizeof(rt->control_uri));", "} else {", "char proto[32];", "rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];", "av_url_split(proto, sizeof(proto), NULL, 0, NULL, 0,\nNULL, NULL, 0, VAR_6);", "if (proto[0] == '\\0') {", "if (rtsp_st->control_url[strlen(rtsp_st->control_url)-1]!='/')\nav_strlcat(rtsp_st->control_url, \"/\",\nsizeof(rtsp_st->control_url));", "av_strlcat(rtsp_st->control_url, VAR_6,\nsizeof(rtsp_st->control_url));", "} else", "av_strlcpy(rtsp_st->control_url, VAR_6,\nsizeof(rtsp_st->control_url));", "}", "} else if (av_strstart(VAR_6, \"rtpmap:\", &VAR_6) && VAR_0->nb_streams > 0) {", "get_word(VAR_4, sizeof(VAR_4), &VAR_6);", "VAR_8 = atoi(VAR_4);", "rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];", "if (rtsp_st->stream_index >= 0) {", "st = VAR_0->streams[rtsp_st->stream_index];", "sdp_parse_rtpmap(VAR_0, st, rtsp_st, VAR_8, VAR_6);", "}", "VAR_1->seen_rtpmap = 1;", "if (VAR_1->seen_fmtp) {", "parse_fmtp(VAR_0, rt, VAR_8, VAR_1->delayed_fmtp);", "}", "} else if (av_strstart(VAR_6, \"fmtp:\", &VAR_6) ||", "av_strstart(VAR_6, \"framesize:\", &VAR_6)) {", "get_word(VAR_4, sizeof(VAR_4), &VAR_6);", "VAR_8 = atoi(VAR_4);", "if (VAR_1->seen_rtpmap) {", "parse_fmtp(VAR_0, rt, VAR_8, VAR_3);", "} else {", "VAR_1->seen_fmtp = 1;", "av_strlcpy(VAR_1->delayed_fmtp, VAR_3, sizeof(VAR_1->delayed_fmtp));", "}", "} else if (av_strstart(VAR_6, \"range:\", &VAR_6)) {", "int64_t start, end;", "rtsp_parse_range_npt(VAR_6, &start, &end);", "VAR_0->start_time = start;", "VAR_0->duration = (end == AV_NOPTS_VALUE) ?\nAV_NOPTS_VALUE : end - start;", "} else if (av_strstart(VAR_6, \"IsRealDataType:integer;\",&VAR_6)) {", "if (atoi(VAR_6) == 1)\nrt->transport = RTSP_TRANSPORT_RDT;", "} else if (av_strstart(VAR_6, \"SampleRate:integer;\", &VAR_6) &&", "VAR_0->nb_streams > 0) {", "st = VAR_0->streams[VAR_0->nb_streams - 1];", "st->codec->sample_rate = atoi(VAR_6);", "} else if (av_strstart(VAR_6, \"crypto:\", &VAR_6) && VAR_0->nb_streams > 0) {", "rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];", "get_word(VAR_4, sizeof(VAR_4), &VAR_6);", "get_word(rtsp_st->crypto_suite, sizeof(rtsp_st->crypto_suite), &VAR_6);", "VAR_6 += strspn(VAR_6, SPACE_CHARS);", "if (av_strstart(VAR_6, \"inline:\", &VAR_6))\nget_word(rtsp_st->crypto_params, sizeof(rtsp_st->crypto_params), &VAR_6);", "} else if (av_strstart(VAR_6, \"source-filter:\", &VAR_6)) {", "int exclude = 0;", "get_word(VAR_4, sizeof(VAR_4), &VAR_6);", "if (strcmp(VAR_4, \"incl\") && strcmp(VAR_4, \"excl\"))\nreturn;", "exclude = !strcmp(VAR_4, \"excl\");", "get_word(VAR_4, sizeof(VAR_4), &VAR_6);", "if (strcmp(VAR_4, \"IN\") != 0)\nreturn;", "get_word(VAR_4, sizeof(VAR_4), &VAR_6);", "if (strcmp(VAR_4, \"IP4\") && strcmp(VAR_4, \"IP6\") && strcmp(VAR_4, \"*\"))\nreturn;", "get_word(VAR_4, sizeof(VAR_4), &VAR_6);", "while (*VAR_6 != '\\0') {", "rtsp_src = av_mallocz(sizeof(*rtsp_src));", "if (!rtsp_src)\nreturn;", "get_word(rtsp_src->addr, sizeof(rtsp_src->addr), &VAR_6);", "if (exclude) {", "if (VAR_0->nb_streams == 0) {", "dynarray_add(&VAR_1->default_exclude_source_addrs, &VAR_1->nb_default_exclude_source_addrs, rtsp_src);", "} else {", "rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];", "dynarray_add(&rtsp_st->exclude_source_addrs, &rtsp_st->nb_exclude_source_addrs, rtsp_src);", "}", "} else {", "if (VAR_0->nb_streams == 0) {", "dynarray_add(&VAR_1->default_include_source_addrs, &VAR_1->nb_default_include_source_addrs, rtsp_src);", "} else {", "rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];", "dynarray_add(&rtsp_st->include_source_addrs, &rtsp_st->nb_include_source_addrs, rtsp_src);", "}", "}", "}", "} else {", "if (rt->server_type == RTSP_SERVER_WMS)\nff_wms_parse_sdp_a_line(VAR_0, VAR_6);", "if (VAR_0->nb_streams > 0) {", "rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];", "if (rt->server_type == RTSP_SERVER_REAL)\nff_real_parse_sdp_a_line(VAR_0, rtsp_st->stream_index, VAR_6);", "if (rtsp_st->dynamic_handler &&\nrtsp_st->dynamic_handler->parse_sdp_a_line)\nrtsp_st->dynamic_handler->parse_sdp_a_line(VAR_0,\nrtsp_st->stream_index,\nrtsp_st->dynamic_protocol_context, VAR_3);", "}", "}", "break;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 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, 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147, 149 ], [ 151 ], [ 153 ], [ 157 ], [ 159 ], [ 163, 165, 167, 169 ], [ 171, 173, 175, 177 ], [ 181 ], [ 183 ], [ 187 ], [ 189, 191 ], [ 193, 195 ], [ 201 ], [ 203 ], [ 207 ], [ 211 ], [ 213, 215 ], [ 217 ], [ 219 ], [ 221, 223 ], [ 225 ], [ 227, 229 ], [ 231 ], [ 233 ], [ 235 ], [ 241 ], [ 243 ], [ 245, 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 261 ], [ 263, 265, 267 ], [ 271, 273 ], [ 275 ], [ 277, 279, 281 ], [ 283 ], [ 285 ], [ 289, 291 ], [ 293 ], [ 295, 297 ], [ 299 ], [ 301, 303, 305 ], [ 307 ], [ 309 ], [ 313 ], [ 319, 321 ], [ 323 ], [ 327, 329, 331 ], [ 333, 335 ], [ 337 ], [ 339, 341 ], [ 343 ], [ 345 ], [ 349 ], [ 351 ], [ 353 ], [ 355 ], [ 357 ], [ 359 ], [ 361 ], [ 363 ], [ 365 ], [ 367 ], [ 369 ], [ 371 ], [ 373 ], [ 377 ], [ 379 ], [ 381 ], [ 383 ], [ 385 ], [ 387 ], [ 389 ], [ 391 ], [ 393 ], [ 395 ], [ 401 ], [ 403 ], [ 407, 409 ], [ 411 ], [ 413, 415 ], [ 417 ], [ 419 ], [ 421 ], [ 423 ], [ 425 ], [ 429 ], [ 431 ], [ 433 ], [ 435 ], [ 437, 439 ], [ 441 ], [ 443 ], [ 445 ], [ 447, 449 ], [ 451 ], [ 455 ], [ 457, 459 ], [ 461 ], [ 463, 465 ], [ 469 ], [ 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 ], [ 527, 529 ], [ 533, 535, 537, 539, 541 ], [ 543 ], [ 545 ], [ 547 ], [ 549 ], [ 551 ] ]
6,211
av_cold void ff_mlpdsp_init(MLPDSPContext *c) { c->mlp_filter_channel = mlp_filter_channel; if (ARCH_X86) ff_mlpdsp_init_x86(c); }
true
FFmpeg
15a29c39d9ef15b0783c04b3228e1c55f6701ee3
av_cold void ff_mlpdsp_init(MLPDSPContext *c) { c->mlp_filter_channel = mlp_filter_channel; if (ARCH_X86) ff_mlpdsp_init_x86(c); }
{ "code": [], "line_no": [] }
av_cold void FUNC_0(MLPDSPContext *c) { c->mlp_filter_channel = mlp_filter_channel; if (ARCH_X86) ff_mlpdsp_init_x86(c); }
[ "av_cold void FUNC_0(MLPDSPContext *c)\n{", "c->mlp_filter_channel = mlp_filter_channel;", "if (ARCH_X86)\nff_mlpdsp_init_x86(c);", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9, 11 ], [ 13 ] ]
6,212
int coroutine_fn qemu_co_sendv(int sockfd, struct iovec *iov, int len, int iov_offset) { int total = 0; int ret; while (len) { ret = qemu_sendv(sockfd, iov, len, iov_offset + total); if (ret < 0) { if (errno == EAGAIN) { qemu_coroutine_yield(); continue; } if (total == 0) { total = -1; } break; } total += ret, len -= ret; } return total; }
true
qemu
3e80bf9351f8fec9085c46df6da075efd5e71003
int coroutine_fn qemu_co_sendv(int sockfd, struct iovec *iov, int len, int iov_offset) { int total = 0; int ret; while (len) { ret = qemu_sendv(sockfd, iov, len, iov_offset + total); if (ret < 0) { if (errno == EAGAIN) { qemu_coroutine_yield(); continue; } if (total == 0) { total = -1; } break; } total += ret, len -= ret; } return total; }
{ "code": [ " ret = qemu_sendv(sockfd, iov, len, iov_offset + total);" ], "line_no": [ 13 ] }
int VAR_0 qemu_co_sendv(int sockfd, struct iovec *iov, int len, int iov_offset) { int total = 0; int ret; while (len) { ret = qemu_sendv(sockfd, iov, len, iov_offset + total); if (ret < 0) { if (errno == EAGAIN) { qemu_coroutine_yield(); continue; } if (total == 0) { total = -1; } break; } total += ret, len -= ret; } return total; }
[ "int VAR_0 qemu_co_sendv(int sockfd, struct iovec *iov,\nint len, int iov_offset)\n{", "int total = 0;", "int ret;", "while (len) {", "ret = qemu_sendv(sockfd, iov, len, iov_offset + total);", "if (ret < 0) {", "if (errno == EAGAIN) {", "qemu_coroutine_yield();", "continue;", "}", "if (total == 0) {", "total = -1;", "}", "break;", "}", "total += ret, len -= ret;", "}", "return total;", "}" ]
[ 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 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ] ]
6,213
static PullupField *make_field_queue(PullupContext *s, int len) { PullupField *head, *f; f = head = av_mallocz(sizeof(*head)); if (!f) return NULL; if (alloc_metrics(s, f) < 0) { av_free(f); return NULL; } for (; len > 0; len--) { f->next = av_mallocz(sizeof(*f->next)); if (!f->next) { free_field_queue(head, &f); return NULL; } f->next->prev = f; f = f->next; if (alloc_metrics(s, f) < 0) { free_field_queue(head, &f); return NULL; } } f->next = head; head->prev = f; return head; }
true
FFmpeg
5b0ce5d4e3660fb0fc86779cbd027b47b1758c9f
static PullupField *make_field_queue(PullupContext *s, int len) { PullupField *head, *f; f = head = av_mallocz(sizeof(*head)); if (!f) return NULL; if (alloc_metrics(s, f) < 0) { av_free(f); return NULL; } for (; len > 0; len--) { f->next = av_mallocz(sizeof(*f->next)); if (!f->next) { free_field_queue(head, &f); return NULL; } f->next->prev = f; f = f->next; if (alloc_metrics(s, f) < 0) { free_field_queue(head, &f); return NULL; } } f->next = head; head->prev = f; return head; }
{ "code": [ " f = f->next;", " free_field_queue(head, &f);", " free_field_queue(head, &f);" ], "line_no": [ 43, 33, 33 ] }
static PullupField *FUNC_0(PullupContext *s, int len) { PullupField *head, *f; f = head = av_mallocz(sizeof(*head)); if (!f) return NULL; if (alloc_metrics(s, f) < 0) { av_free(f); return NULL; } for (; len > 0; len--) { f->next = av_mallocz(sizeof(*f->next)); if (!f->next) { free_field_queue(head, &f); return NULL; } f->next->prev = f; f = f->next; if (alloc_metrics(s, f) < 0) { free_field_queue(head, &f); return NULL; } } f->next = head; head->prev = f; return head; }
[ "static PullupField *FUNC_0(PullupContext *s, int len)\n{", "PullupField *head, *f;", "f = head = av_mallocz(sizeof(*head));", "if (!f)\nreturn NULL;", "if (alloc_metrics(s, f) < 0) {", "av_free(f);", "return NULL;", "}", "for (; len > 0; len--) {", "f->next = av_mallocz(sizeof(*f->next));", "if (!f->next) {", "free_field_queue(head, &f);", "return NULL;", "}", "f->next->prev = f;", "f = f->next;", "if (alloc_metrics(s, f) < 0) {", "free_field_queue(head, &f);", "return NULL;", "}", "}", "f->next = head;", "head->prev = f;", "return head;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11, 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 63 ], [ 65 ] ]
6,214
static void lan9118_writel(void *opaque, target_phys_addr_t offset, uint32_t val) { lan9118_state *s = (lan9118_state *)opaque; offset &= 0xff; //DPRINTF("Write reg 0x%02x = 0x%08x\n", (int)offset, val); if (offset >= 0x20 && offset < 0x40) { /* TX FIFO */ tx_fifo_push(s, val); return; } switch (offset) { case CSR_IRQ_CFG: /* TODO: Implement interrupt deassertion intervals. */ s->irq_cfg = (s->irq_cfg & IRQ_INT) | (val & IRQ_EN); break; case CSR_INT_STS: s->int_sts &= ~val; break; case CSR_INT_EN: s->int_en = val & ~RESERVED_INT; s->int_sts |= val & SW_INT; break; case CSR_FIFO_INT: DPRINTF("FIFO INT levels %08x\n", val); s->fifo_int = val; break; case CSR_RX_CFG: if (val & 0x8000) { /* RX_DUMP */ s->rx_fifo_used = 0; s->rx_status_fifo_used = 0; s->rx_packet_size_tail = s->rx_packet_size_head; s->rx_packet_size[s->rx_packet_size_head] = 0; } s->rx_cfg = val & 0xcfff1ff0; break; case CSR_TX_CFG: if (val & 0x8000) { s->tx_status_fifo_used = 0; } if (val & 0x4000) { s->txp->state = TX_IDLE; s->txp->fifo_used = 0; s->txp->cmd_a = 0xffffffff; } s->tx_cfg = val & 6; break; case CSR_HW_CFG: if (val & 1) { /* SRST */ lan9118_reset(&s->busdev.qdev); } else { s->hw_cfg = val & 0x003f300; } break; case CSR_RX_DP_CTRL: if (val & 0x80000000) { /* Skip forward to next packet. */ s->rxp_pad = 0; s->rxp_offset = 0; if (s->rxp_size == 0) { /* Pop a word to start the next packet. */ rx_fifo_pop(s); s->rxp_pad = 0; s->rxp_offset = 0; } s->rx_fifo_head += s->rxp_size; if (s->rx_fifo_head >= s->rx_fifo_size) { s->rx_fifo_head -= s->rx_fifo_size; } } break; case CSR_PMT_CTRL: if (val & 0x400) { phy_reset(s); } s->pmt_ctrl &= ~0x34e; s->pmt_ctrl |= (val & 0x34e); break; case CSR_GPIO_CFG: /* Probably just enabling LEDs. */ s->gpio_cfg = val & 0x7777071f; break; case CSR_GPT_CFG: if ((s->gpt_cfg ^ val) & GPT_TIMER_EN) { if (val & GPT_TIMER_EN) { ptimer_set_count(s->timer, val & 0xffff); ptimer_run(s->timer, 0); } else { ptimer_stop(s->timer); ptimer_set_count(s->timer, 0xffff); } } s->gpt_cfg = val & (GPT_TIMER_EN | 0xffff); break; case CSR_WORD_SWAP: /* Ignored because we're in 32-bit mode. */ s->word_swap = val; break; case CSR_MAC_CSR_CMD: s->mac_cmd = val & 0x4000000f; if (val & 0x80000000) { if (val & 0x40000000) { s->mac_data = do_mac_read(s, val & 0xf); DPRINTF("MAC read %d = 0x%08x\n", val & 0xf, s->mac_data); } else { DPRINTF("MAC write %d = 0x%08x\n", val & 0xf, s->mac_data); do_mac_write(s, val & 0xf, s->mac_data); } } break; case CSR_MAC_CSR_DATA: s->mac_data = val; break; case CSR_AFC_CFG: s->afc_cfg = val & 0x00ffffff; break; case CSR_E2P_CMD: lan9118_eeprom_cmd(s, (val >> 28) & 7, val & 0xff); break; case CSR_E2P_DATA: s->e2p_data = val & 0xff; break; default: hw_error("lan9118_write: Bad reg 0x%x = %x\n", (int)offset, val); break; } lan9118_update(s); }
true
qemu
c46a3ea025b147d58e4c7a222307ccba1e9e376f
static void lan9118_writel(void *opaque, target_phys_addr_t offset, uint32_t val) { lan9118_state *s = (lan9118_state *)opaque; offset &= 0xff; if (offset >= 0x20 && offset < 0x40) { tx_fifo_push(s, val); return; } switch (offset) { case CSR_IRQ_CFG: s->irq_cfg = (s->irq_cfg & IRQ_INT) | (val & IRQ_EN); break; case CSR_INT_STS: s->int_sts &= ~val; break; case CSR_INT_EN: s->int_en = val & ~RESERVED_INT; s->int_sts |= val & SW_INT; break; case CSR_FIFO_INT: DPRINTF("FIFO INT levels %08x\n", val); s->fifo_int = val; break; case CSR_RX_CFG: if (val & 0x8000) { s->rx_fifo_used = 0; s->rx_status_fifo_used = 0; s->rx_packet_size_tail = s->rx_packet_size_head; s->rx_packet_size[s->rx_packet_size_head] = 0; } s->rx_cfg = val & 0xcfff1ff0; break; case CSR_TX_CFG: if (val & 0x8000) { s->tx_status_fifo_used = 0; } if (val & 0x4000) { s->txp->state = TX_IDLE; s->txp->fifo_used = 0; s->txp->cmd_a = 0xffffffff; } s->tx_cfg = val & 6; break; case CSR_HW_CFG: if (val & 1) { lan9118_reset(&s->busdev.qdev); } else { s->hw_cfg = val & 0x003f300; } break; case CSR_RX_DP_CTRL: if (val & 0x80000000) { s->rxp_pad = 0; s->rxp_offset = 0; if (s->rxp_size == 0) { rx_fifo_pop(s); s->rxp_pad = 0; s->rxp_offset = 0; } s->rx_fifo_head += s->rxp_size; if (s->rx_fifo_head >= s->rx_fifo_size) { s->rx_fifo_head -= s->rx_fifo_size; } } break; case CSR_PMT_CTRL: if (val & 0x400) { phy_reset(s); } s->pmt_ctrl &= ~0x34e; s->pmt_ctrl |= (val & 0x34e); break; case CSR_GPIO_CFG: s->gpio_cfg = val & 0x7777071f; break; case CSR_GPT_CFG: if ((s->gpt_cfg ^ val) & GPT_TIMER_EN) { if (val & GPT_TIMER_EN) { ptimer_set_count(s->timer, val & 0xffff); ptimer_run(s->timer, 0); } else { ptimer_stop(s->timer); ptimer_set_count(s->timer, 0xffff); } } s->gpt_cfg = val & (GPT_TIMER_EN | 0xffff); break; case CSR_WORD_SWAP: s->word_swap = val; break; case CSR_MAC_CSR_CMD: s->mac_cmd = val & 0x4000000f; if (val & 0x80000000) { if (val & 0x40000000) { s->mac_data = do_mac_read(s, val & 0xf); DPRINTF("MAC read %d = 0x%08x\n", val & 0xf, s->mac_data); } else { DPRINTF("MAC write %d = 0x%08x\n", val & 0xf, s->mac_data); do_mac_write(s, val & 0xf, s->mac_data); } } break; case CSR_MAC_CSR_DATA: s->mac_data = val; break; case CSR_AFC_CFG: s->afc_cfg = val & 0x00ffffff; break; case CSR_E2P_CMD: lan9118_eeprom_cmd(s, (val >> 28) & 7, val & 0xff); break; case CSR_E2P_DATA: s->e2p_data = val & 0xff; break; default: hw_error("lan9118_write: Bad reg 0x%x = %x\n", (int)offset, val); break; } lan9118_update(s); }
{ "code": [ " lan9118_eeprom_cmd(s, (val >> 28) & 7, val & 0xff);" ], "line_no": [ 241 ] }
static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint32_t VAR_2) { lan9118_state *s = (lan9118_state *)VAR_0; VAR_1 &= 0xff; if (VAR_1 >= 0x20 && VAR_1 < 0x40) { tx_fifo_push(s, VAR_2); return; } switch (VAR_1) { case CSR_IRQ_CFG: s->irq_cfg = (s->irq_cfg & IRQ_INT) | (VAR_2 & IRQ_EN); break; case CSR_INT_STS: s->int_sts &= ~VAR_2; break; case CSR_INT_EN: s->int_en = VAR_2 & ~RESERVED_INT; s->int_sts |= VAR_2 & SW_INT; break; case CSR_FIFO_INT: DPRINTF("FIFO INT levels %08x\n", VAR_2); s->fifo_int = VAR_2; break; case CSR_RX_CFG: if (VAR_2 & 0x8000) { s->rx_fifo_used = 0; s->rx_status_fifo_used = 0; s->rx_packet_size_tail = s->rx_packet_size_head; s->rx_packet_size[s->rx_packet_size_head] = 0; } s->rx_cfg = VAR_2 & 0xcfff1ff0; break; case CSR_TX_CFG: if (VAR_2 & 0x8000) { s->tx_status_fifo_used = 0; } if (VAR_2 & 0x4000) { s->txp->state = TX_IDLE; s->txp->fifo_used = 0; s->txp->cmd_a = 0xffffffff; } s->tx_cfg = VAR_2 & 6; break; case CSR_HW_CFG: if (VAR_2 & 1) { lan9118_reset(&s->busdev.qdev); } else { s->hw_cfg = VAR_2 & 0x003f300; } break; case CSR_RX_DP_CTRL: if (VAR_2 & 0x80000000) { s->rxp_pad = 0; s->rxp_offset = 0; if (s->rxp_size == 0) { rx_fifo_pop(s); s->rxp_pad = 0; s->rxp_offset = 0; } s->rx_fifo_head += s->rxp_size; if (s->rx_fifo_head >= s->rx_fifo_size) { s->rx_fifo_head -= s->rx_fifo_size; } } break; case CSR_PMT_CTRL: if (VAR_2 & 0x400) { phy_reset(s); } s->pmt_ctrl &= ~0x34e; s->pmt_ctrl |= (VAR_2 & 0x34e); break; case CSR_GPIO_CFG: s->gpio_cfg = VAR_2 & 0x7777071f; break; case CSR_GPT_CFG: if ((s->gpt_cfg ^ VAR_2) & GPT_TIMER_EN) { if (VAR_2 & GPT_TIMER_EN) { ptimer_set_count(s->timer, VAR_2 & 0xffff); ptimer_run(s->timer, 0); } else { ptimer_stop(s->timer); ptimer_set_count(s->timer, 0xffff); } } s->gpt_cfg = VAR_2 & (GPT_TIMER_EN | 0xffff); break; case CSR_WORD_SWAP: s->word_swap = VAR_2; break; case CSR_MAC_CSR_CMD: s->mac_cmd = VAR_2 & 0x4000000f; if (VAR_2 & 0x80000000) { if (VAR_2 & 0x40000000) { s->mac_data = do_mac_read(s, VAR_2 & 0xf); DPRINTF("MAC read %d = 0x%08x\n", VAR_2 & 0xf, s->mac_data); } else { DPRINTF("MAC write %d = 0x%08x\n", VAR_2 & 0xf, s->mac_data); do_mac_write(s, VAR_2 & 0xf, s->mac_data); } } break; case CSR_MAC_CSR_DATA: s->mac_data = VAR_2; break; case CSR_AFC_CFG: s->afc_cfg = VAR_2 & 0x00ffffff; break; case CSR_E2P_CMD: lan9118_eeprom_cmd(s, (VAR_2 >> 28) & 7, VAR_2 & 0xff); break; case CSR_E2P_DATA: s->e2p_data = VAR_2 & 0xff; break; default: hw_error("lan9118_write: Bad reg 0x%x = %x\n", (int)VAR_1, VAR_2); break; } lan9118_update(s); }
[ "static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint32_t VAR_2)\n{", "lan9118_state *s = (lan9118_state *)VAR_0;", "VAR_1 &= 0xff;", "if (VAR_1 >= 0x20 && VAR_1 < 0x40) {", "tx_fifo_push(s, VAR_2);", "return;", "}", "switch (VAR_1) {", "case CSR_IRQ_CFG:\ns->irq_cfg = (s->irq_cfg & IRQ_INT) | (VAR_2 & IRQ_EN);", "break;", "case CSR_INT_STS:\ns->int_sts &= ~VAR_2;", "break;", "case CSR_INT_EN:\ns->int_en = VAR_2 & ~RESERVED_INT;", "s->int_sts |= VAR_2 & SW_INT;", "break;", "case CSR_FIFO_INT:\nDPRINTF(\"FIFO INT levels %08x\\n\", VAR_2);", "s->fifo_int = VAR_2;", "break;", "case CSR_RX_CFG:\nif (VAR_2 & 0x8000) {", "s->rx_fifo_used = 0;", "s->rx_status_fifo_used = 0;", "s->rx_packet_size_tail = s->rx_packet_size_head;", "s->rx_packet_size[s->rx_packet_size_head] = 0;", "}", "s->rx_cfg = VAR_2 & 0xcfff1ff0;", "break;", "case CSR_TX_CFG:\nif (VAR_2 & 0x8000) {", "s->tx_status_fifo_used = 0;", "}", "if (VAR_2 & 0x4000) {", "s->txp->state = TX_IDLE;", "s->txp->fifo_used = 0;", "s->txp->cmd_a = 0xffffffff;", "}", "s->tx_cfg = VAR_2 & 6;", "break;", "case CSR_HW_CFG:\nif (VAR_2 & 1) {", "lan9118_reset(&s->busdev.qdev);", "} else {", "s->hw_cfg = VAR_2 & 0x003f300;", "}", "break;", "case CSR_RX_DP_CTRL:\nif (VAR_2 & 0x80000000) {", "s->rxp_pad = 0;", "s->rxp_offset = 0;", "if (s->rxp_size == 0) {", "rx_fifo_pop(s);", "s->rxp_pad = 0;", "s->rxp_offset = 0;", "}", "s->rx_fifo_head += s->rxp_size;", "if (s->rx_fifo_head >= s->rx_fifo_size) {", "s->rx_fifo_head -= s->rx_fifo_size;", "}", "}", "break;", "case CSR_PMT_CTRL:\nif (VAR_2 & 0x400) {", "phy_reset(s);", "}", "s->pmt_ctrl &= ~0x34e;", "s->pmt_ctrl |= (VAR_2 & 0x34e);", "break;", "case CSR_GPIO_CFG:\ns->gpio_cfg = VAR_2 & 0x7777071f;", "break;", "case CSR_GPT_CFG:\nif ((s->gpt_cfg ^ VAR_2) & GPT_TIMER_EN) {", "if (VAR_2 & GPT_TIMER_EN) {", "ptimer_set_count(s->timer, VAR_2 & 0xffff);", "ptimer_run(s->timer, 0);", "} else {", "ptimer_stop(s->timer);", "ptimer_set_count(s->timer, 0xffff);", "}", "}", "s->gpt_cfg = VAR_2 & (GPT_TIMER_EN | 0xffff);", "break;", "case CSR_WORD_SWAP:\ns->word_swap = VAR_2;", "break;", "case CSR_MAC_CSR_CMD:\ns->mac_cmd = VAR_2 & 0x4000000f;", "if (VAR_2 & 0x80000000) {", "if (VAR_2 & 0x40000000) {", "s->mac_data = do_mac_read(s, VAR_2 & 0xf);", "DPRINTF(\"MAC read %d = 0x%08x\\n\", VAR_2 & 0xf, s->mac_data);", "} else {", "DPRINTF(\"MAC write %d = 0x%08x\\n\", VAR_2 & 0xf, s->mac_data);", "do_mac_write(s, VAR_2 & 0xf, s->mac_data);", "}", "}", "break;", "case CSR_MAC_CSR_DATA:\ns->mac_data = VAR_2;", "break;", "case CSR_AFC_CFG:\ns->afc_cfg = VAR_2 & 0x00ffffff;", "break;", "case CSR_E2P_CMD:\nlan9118_eeprom_cmd(s, (VAR_2 >> 28) & 7, VAR_2 & 0xff);", "break;", "case CSR_E2P_DATA:\ns->e2p_data = VAR_2 & 0xff;", "break;", "default:\nhw_error(\"lan9118_write: Bad reg 0x%x = %x\\n\", (int)VAR_1, VAR_2);", "break;", "}", "lan9118_update(s);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27, 31 ], [ 33 ], [ 35, 37 ], [ 39 ], [ 41, 43 ], [ 45 ], [ 47 ], [ 49, 51 ], [ 53 ], [ 55 ], [ 57, 59 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77, 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99, 101 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115, 117 ], [ 121 ], [ 123 ], [ 125 ], [ 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 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195, 199 ], [ 201 ], [ 203, 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227, 229 ], [ 231 ], [ 233, 235 ], [ 237 ], [ 239, 241 ], [ 243 ], [ 245, 247 ], [ 249 ], [ 253, 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ] ]