problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
How to scrape tables from some URL in Javascript? : <p>In Python it is very simple: pandas.read_html("some URL");</p>
<p>I am wondering what's the best way to do this in Javascript. Is there some existing library that can help with this?</p>
| 0debug
|
static void guest_fsfreeze_cleanup(void)
{
int64_t ret;
Error *err = NULL;
if (guest_fsfreeze_state.status == GUEST_FSFREEZE_STATUS_FROZEN) {
ret = qmp_guest_fsfreeze_thaw(&err);
if (ret < 0 || err) {
slog("failed to clean up frozen filesystems");
}
}
}
| 1threat
|
int qcow2_update_snapshot_refcount(BlockDriverState *bs,
int64_t l1_table_offset, int l1_size, int addend)
{
BDRVQcowState *s = bs->opaque;
uint64_t *l1_table, *l2_table, l2_offset, offset, l1_size2, l1_allocated;
int64_t old_offset, old_l2_offset;
int i, j, l1_modified = 0, nb_csectors, refcount;
int ret;
l2_table = NULL;
l1_table = NULL;
l1_size2 = l1_size * sizeof(uint64_t);
if (l1_table_offset != s->l1_table_offset) {
l1_table = g_malloc0(align_offset(l1_size2, 512));
l1_allocated = 1;
ret = bdrv_pread(bs->file, l1_table_offset, l1_table, l1_size2);
if (ret < 0) {
goto fail;
}
for(i = 0;i < l1_size; i++)
be64_to_cpus(&l1_table[i]);
} else {
assert(l1_size == s->l1_size);
l1_table = s->l1_table;
l1_allocated = 0;
}
for(i = 0; i < l1_size; i++) {
l2_offset = l1_table[i];
if (l2_offset) {
old_l2_offset = l2_offset;
l2_offset &= L1E_OFFSET_MASK;
ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset,
(void**) &l2_table);
if (ret < 0) {
goto fail;
}
for(j = 0; j < s->l2_size; j++) {
offset = be64_to_cpu(l2_table[j]);
if (offset != 0) {
old_offset = offset;
offset &= ~QCOW_OFLAG_COPIED;
if (offset & QCOW_OFLAG_COMPRESSED) {
nb_csectors = ((offset >> s->csize_shift) &
s->csize_mask) + 1;
if (addend != 0) {
int ret;
ret = update_refcount(bs,
(offset & s->cluster_offset_mask) & ~511,
nb_csectors * 512, addend);
if (ret < 0) {
goto fail;
}
}
refcount = 2;
} else {
uint64_t cluster_index = (offset & L2E_OFFSET_MASK) >> s->cluster_bits;
if (addend != 0) {
refcount = update_cluster_refcount(bs, cluster_index, addend);
} else {
refcount = get_refcount(bs, cluster_index);
}
if (refcount < 0) {
ret = refcount;
goto fail;
}
}
if (refcount == 1) {
offset |= QCOW_OFLAG_COPIED;
}
if (offset != old_offset) {
if (addend > 0) {
qcow2_cache_set_dependency(bs, s->l2_table_cache,
s->refcount_block_cache);
}
l2_table[j] = cpu_to_be64(offset);
qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
}
}
}
ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
if (ret < 0) {
goto fail;
}
if (addend != 0) {
refcount = update_cluster_refcount(bs, l2_offset >> s->cluster_bits, addend);
} else {
refcount = get_refcount(bs, l2_offset >> s->cluster_bits);
}
if (refcount < 0) {
ret = refcount;
goto fail;
} else if (refcount == 1) {
l2_offset |= QCOW_OFLAG_COPIED;
}
if (l2_offset != old_l2_offset) {
l1_table[i] = l2_offset;
l1_modified = 1;
}
}
}
ret = bdrv_flush(bs);
fail:
if (l2_table) {
qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
}
if (addend >= 0 && l1_modified) {
for(i = 0; i < l1_size; i++)
cpu_to_be64s(&l1_table[i]);
if (bdrv_pwrite_sync(bs->file, l1_table_offset, l1_table,
l1_size2) < 0)
goto fail;
for(i = 0; i < l1_size; i++)
be64_to_cpus(&l1_table[i]);
}
if (l1_allocated)
g_free(l1_table);
return ret;
}
| 1threat
|
Programatically define second and third points of a triangle from two points and angles : <p>If I have two points, one being the starting point or vertex (A) and the other being the median point of A, and I also have the three angles, how do I programatically determine points B and C?</p>
<p><a href="https://i.stack.imgur.com/6Th9B.jpg" rel="nofollow noreferrer">Triangle problem</a></p>
| 0debug
|
build_dmar_q35(GArray *table_data, BIOSLinker *linker)
{
int dmar_start = table_data->len;
AcpiTableDmar *dmar;
AcpiDmarHardwareUnit *drhd;
AcpiDmarRootPortATS *atsr;
uint8_t dmar_flags = 0;
X86IOMMUState *iommu = x86_iommu_get_default();
AcpiDmarDeviceScope *scope = NULL;
size_t ioapic_scope_size = sizeof(*scope) + sizeof(scope->path[0]);
assert(iommu);
if (iommu->intr_supported) {
dmar_flags |= 0x1;
}
dmar = acpi_data_push(table_data, sizeof(*dmar));
dmar->host_address_width = VTD_HOST_ADDRESS_WIDTH - 1;
dmar->flags = dmar_flags;
drhd = acpi_data_push(table_data, sizeof(*drhd) + ioapic_scope_size);
drhd->type = cpu_to_le16(ACPI_DMAR_TYPE_HARDWARE_UNIT);
drhd->length = cpu_to_le16(sizeof(*drhd) + ioapic_scope_size);
drhd->flags = ACPI_DMAR_INCLUDE_PCI_ALL;
drhd->pci_segment = cpu_to_le16(0);
drhd->address = cpu_to_le64(Q35_HOST_BRIDGE_IOMMU_ADDR);
scope = &drhd->scope[0];
scope->entry_type = 0x03;
scope->length = ioapic_scope_size;
scope->enumeration_id = ACPI_BUILD_IOAPIC_ID;
scope->bus = Q35_PSEUDO_BUS_PLATFORM;
scope->path[0].device = PCI_SLOT(Q35_PSEUDO_DEVFN_IOAPIC);
scope->path[0].function = PCI_FUNC(Q35_PSEUDO_DEVFN_IOAPIC);
if (iommu->dt_supported) {
atsr = acpi_data_push(table_data, sizeof(*atsr));
atsr->type = cpu_to_le16(ACPI_DMAR_TYPE_ATSR);
atsr->length = cpu_to_le16(sizeof(*atsr));
atsr->flags = ACPI_DMAR_ATSR_ALL_PORTS;
atsr->pci_segment = cpu_to_le16(0);
}
build_header(linker, table_data, (void *)(table_data->data + dmar_start),
"DMAR", table_data->len - dmar_start, 1, NULL, NULL);
}
| 1threat
|
Regular expression to remove characters at the end of a line : <p><br>
I need a regular expression to remove sentences at the end of a line (after a period) containing more than 2 digits,
example:</p>
<p>Before<br>
Some text1. Text (270) 6265204<br>
Some text2. text97 66 48 35<br>
Some text3. text 504-791-4972<br>
Some text4. (414)5290192<br>
Some text5. text6.<br></p>
<p>After <br>
Some text1.<br>
Some text2.<br>
Some text3.<br>
Some text4.<br>
Some text5. text6.</p>
| 0debug
|
static void minimac2_cleanup(NetClientState *nc)
{
MilkymistMinimac2State *s = qemu_get_nic_opaque(nc);
s->nic = NULL;
}
| 1threat
|
av_cold void ff_dither_init_x86(DitherDSPContext *ddsp,
enum AVResampleDitherMethod method)
{
int cpu_flags = av_get_cpu_flags();
if (EXTERNAL_SSE2(cpu_flags)) {
ddsp->quantize = ff_quantize_sse2;
ddsp->ptr_align = 16;
ddsp->samples_align = 8;
}
if (method == AV_RESAMPLE_DITHER_RECTANGULAR) {
if (EXTERNAL_SSE2(cpu_flags)) {
ddsp->dither_int_to_float = ff_dither_int_to_float_rectangular_sse2;
}
if (EXTERNAL_AVX(cpu_flags)) {
ddsp->dither_int_to_float = ff_dither_int_to_float_rectangular_avx;
}
} else {
if (EXTERNAL_SSE2(cpu_flags)) {
ddsp->dither_int_to_float = ff_dither_int_to_float_triangular_sse2;
}
if (EXTERNAL_AVX(cpu_flags)) {
ddsp->dither_int_to_float = ff_dither_int_to_float_triangular_avx;
}
}
}
| 1threat
|
Why is variable being modified from a method? : <h2>Background</h2>
<p>I am making an array tools class for adding Python functionality to a Java array, and I came across this problem. This is obviously a simplified, more universal version.</p>
<h2>Question</h2>
<p>In this example:</p>
<pre><code>public class ArrayTest
{
public static void main(String[] args)
{
// initial setup
int[] given = {1, 2, 3, 4, 5};
// change array
int[] changed = adjust(given);
// these end up being the same...
System.out.println(Arrays.toString(changed));
System.out.println(Arrays.toString(given));
}
private static int[] adjust(int[] a)
{
for (int i = 0; i < a.length; i++)
{
a[i]++;
}
return a;
}
}
</code></pre>
<p>...why is <code>changed</code> and <code>given</code> the same thing?</p>
<h2>Disclaimer</h2>
<p>I am guessing that this has been asked before, but I couldn't find an answer, so I apologize for that.</p>
| 0debug
|
store multiple value in same column seprated by comma : <p>String: 23456,16524,84755,98457,06978,05986,73454,34785 </p>
<h2>Result</h2>
<p>23456</p>
<p>16524 </p>
<p>84755 </p>
<p>98457 </p>
<p>06978 </p>
<p>05986 </p>
<p>73454 </p>
<p>34785</p>
| 0debug
|
Get TimeZone in C# based on offset from browser : <p>Is it a way to get TimeZone Name or ID in C# just knowing offset fetched from Javascript in browser?</p>
| 0debug
|
One way data binding in Angular2 : <p>I got the following html</p>
<pre><code><app-grid [columns]="columns" [data]="data" ></app-grid>
</code></pre>
<p>I want the data and columns properties to be immutable. The Grid should only show it. But in cases of sort or filtering the data would change, at least the order. </p>
<p>But here is my problem. If I access the data array and modify one property of an containing object. Like this.</p>
<pre><code>this.data[0].name = "test"
</code></pre>
<p>The original gets changed. But I thought [data] is only one way data bound.</p>
<p>Could somebody point me in the right direction, to why this is happening and how I can omit it. I come from React where this would be pretty straight forward.</p>
| 0debug
|
How do I implement a write rate limit in Cloud Firestore security rules? : <p>I have an app that uses the Firebase SDK to directly talk to <a href="https://firebase.google.com/docs/firestore" rel="noreferrer">Cloud Firestore</a> from within the application. My code makes sure to only write data at reasonable intervals. But a malicious user might take the configuration data from my app, and use it to write an endless stream of data to my database.</p>
<p>How can I make sure a user can only write say once every few seconds, without having to write any server-side code.</p>
| 0debug
|
Testing in-app purchases : <p>I want to test in-app purchases in my app on device with different Apple ID(not developer Apple ID). I add device in Apple Developer. But I still can’t do it. How I test purchases on device with not developer Apple ID?</p>
| 0debug
|
What is better to return a pointer to an array for have the function set values in a existing array : What is considered better to have something like this:
int * foo(int n) {
int * output = new int[n];
for (int i = 0; i < n; i++) {
output[i] = i;
}
return output;
}
int main() {
int * arr = foo(10);
return 0;
}
and have the fuction return a pointer to the array or is it better to have something like this:
void foo(int n, int output[]) {
for (int i = 0; i < n; i++) {
output[i] = i;
}
}
int main() {
int arr[10];
foo(10, arr);
return 0;
}
where the function doesn't return anything but just sets the values of an array given in the parameters. Thanks.
| 0debug
|
Can we use angularjs for job portals? : <p>For job portals, do we make SEO? If we use angularjs for jobportal site, will it make any issues on SEO?</p>
<p>Kindly help me to get an idea on this. Thanks in advance</p>
| 0debug
|
How to get user's full name only from gmail in java/javascript : <p>I'm trying to make a website and I need to have a code in my server side (JAVA) or even in front (Javascript) so that when user enters someone's gmail, it automatically gets first and last name associated with that gmail and puts it in database. How is that possible to get full name from only gmail (if it exists) ?</p>
| 0debug
|
uint64_t pc_dimm_get_free_addr(uint64_t address_space_start,
uint64_t address_space_size,
uint64_t *hint, uint64_t size,
Error **errp)
{
GSList *list = NULL, *item;
uint64_t new_addr, ret = 0;
uint64_t address_space_end = address_space_start + address_space_size;
assert(address_space_end > address_space_size);
object_child_foreach(qdev_get_machine(), pc_dimm_built_list, &list);
if (hint) {
new_addr = *hint;
} else {
new_addr = address_space_start;
}
for (item = list; item; item = g_slist_next(item)) {
PCDIMMDevice *dimm = item->data;
uint64_t dimm_size = object_property_get_int(OBJECT(dimm),
PC_DIMM_SIZE_PROP,
errp);
if (errp && *errp) {
goto out;
}
if (ranges_overlap(dimm->addr, dimm_size, new_addr, size)) {
if (hint) {
DeviceState *d = DEVICE(dimm);
error_setg(errp, "address range conflicts with '%s'", d->id);
goto out;
}
new_addr = dimm->addr + dimm_size;
}
}
ret = new_addr;
if (new_addr < address_space_start) {
error_setg(errp, "can't add memory [0x%" PRIx64 ":0x%" PRIx64
"] at 0x%" PRIx64, new_addr, size, address_space_start);
} else if ((new_addr + size) > address_space_end) {
error_setg(errp, "can't add memory [0x%" PRIx64 ":0x%" PRIx64
"] beyond 0x%" PRIx64, new_addr, size, address_space_end);
}
out:
g_slist_free(list);
return ret;
}
| 1threat
|
static TargetFdDataFunc fd_trans_host_to_target_data(int fd)
{
if (fd < target_fd_max && target_fd_trans[fd]) {
return target_fd_trans[fd]->host_to_target_data;
}
return NULL;
}
| 1threat
|
Very weird array declaration issue - C : <p>I call this function using "funcName 4"</p>
<pre><code>int main(int argc, char** argv) {
int numPassedIn = atoi(argv[1]);
printf("%d", numPassedIn);
pid_t kidPID[numPassedIn];
</code></pre>
<p>The print statement prints "4". Makes sense.</p>
<p>The array kidPID, however, is not initialized (declared?) properly. There is no space for pid_t's to be stored.</p>
<p>If I alter the code to read </p>
<pre><code>int main(int argc, char** argv) {
int numPassedIn = atoi(argv[1]);
printf("%d", numPassedIn);
pid_t kidPID[4];
</code></pre>
<p>it does provide space. What's going on here? Thanks in advance!</p>
| 0debug
|
static int check_host_key(BDRVSSHState *s, const char *host, int port,
const char *host_key_check)
{
if (strcmp(host_key_check, "no") == 0) {
return 0;
}
if (strncmp(host_key_check, "md5:", 4) == 0) {
return check_host_key_hash(s, &host_key_check[4],
LIBSSH2_HOSTKEY_HASH_MD5, 16);
}
if (strncmp(host_key_check, "sha1:", 5) == 0) {
return check_host_key_hash(s, &host_key_check[5],
LIBSSH2_HOSTKEY_HASH_SHA1, 20);
}
if (strcmp(host_key_check, "yes") == 0) {
return check_host_key_knownhosts(s, host, port);
}
error_report("unknown host_key_check setting (%s)", host_key_check);
return -EINVAL;
}
| 1threat
|
PHP regex content between tags with square brackets : <p>I am trying to create a regex that will give me everything that appears between <code>[start-flashcards]</code> and <code>[end-flashcards]</code></p>
<p>I am using <code>\[start-flashcards\](.*?)\[end-flashcards\]</code> but this doesn't match. I must be missing something? </p>
<pre><code><p>[start-flashcards]</p>
<p>[London|This is the capital city of the United Kingdom]</p>
<p>[Paris|This is the capital city of France]</p>
<p>[Madrid|This is the capital city of Spain]</p>
<p>[Tokyo|This is the capital city of Japan]</p>
<p>[Moscow|This is the capital city of Russia]</p>
<p>[end-flashcards]</p>
</code></pre>
| 0debug
|
static int kmvc_decode_inter_8x8(KmvcContext * ctx, int w, int h)
{
BitBuf bb;
int res, val;
int i, j;
int bx, by;
int l0x, l1x, l0y, l1y;
int mx, my;
kmvc_init_getbits(bb, &ctx->g);
for (by = 0; by < h; by += 8)
for (bx = 0; bx < w; bx += 8) {
kmvc_getbit(bb, &ctx->g, res);
if (!res) {
kmvc_getbit(bb, &ctx->g, res);
if (!res) {
if (!bytestream2_get_bytes_left(&ctx->g)) {
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
return AVERROR_INVALIDDATA;
}
val = bytestream2_get_byte(&ctx->g);
for (i = 0; i < 64; i++)
BLK(ctx->cur, bx + (i & 0x7), by + (i >> 3)) = val;
} else {
for (i = 0; i < 64; i++)
BLK(ctx->cur, bx + (i & 0x7), by + (i >> 3)) =
BLK(ctx->prev, bx + (i & 0x7), by + (i >> 3));
}
} else {
if (!bytestream2_get_bytes_left(&ctx->g)) {
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
return AVERROR_INVALIDDATA;
}
for (i = 0; i < 4; i++) {
l0x = bx + (i & 1) * 4;
l0y = by + (i & 2) * 2;
kmvc_getbit(bb, &ctx->g, res);
if (!res) {
kmvc_getbit(bb, &ctx->g, res);
if (!res) {
val = bytestream2_get_byte(&ctx->g);
for (j = 0; j < 16; j++)
BLK(ctx->cur, l0x + (j & 3), l0y + (j >> 2)) = val;
} else {
val = bytestream2_get_byte(&ctx->g);
mx = (val & 0xF) - 8;
my = (val >> 4) - 8;
if ((l0x+mx) + 320*(l0y+my) < 0 || (l0x+mx) + 320*(l0y+my) > 318*198) {
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid MV\n");
return AVERROR_INVALIDDATA;
}
for (j = 0; j < 16; j++)
BLK(ctx->cur, l0x + (j & 3), l0y + (j >> 2)) =
BLK(ctx->prev, l0x + (j & 3) + mx, l0y + (j >> 2) + my);
}
} else {
for (j = 0; j < 4; j++) {
l1x = l0x + (j & 1) * 2;
l1y = l0y + (j & 2);
kmvc_getbit(bb, &ctx->g, res);
if (!res) {
kmvc_getbit(bb, &ctx->g, res);
if (!res) {
val = bytestream2_get_byte(&ctx->g);
BLK(ctx->cur, l1x, l1y) = val;
BLK(ctx->cur, l1x + 1, l1y) = val;
BLK(ctx->cur, l1x, l1y + 1) = val;
BLK(ctx->cur, l1x + 1, l1y + 1) = val;
} else {
val = bytestream2_get_byte(&ctx->g);
mx = (val & 0xF) - 8;
my = (val >> 4) - 8;
if ((l1x+mx) + 320*(l1y+my) < 0 || (l1x+mx) + 320*(l1y+my) > 318*198) {
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid MV\n");
return AVERROR_INVALIDDATA;
}
BLK(ctx->cur, l1x, l1y) = BLK(ctx->prev, l1x + mx, l1y + my);
BLK(ctx->cur, l1x + 1, l1y) =
BLK(ctx->prev, l1x + 1 + mx, l1y + my);
BLK(ctx->cur, l1x, l1y + 1) =
BLK(ctx->prev, l1x + mx, l1y + 1 + my);
BLK(ctx->cur, l1x + 1, l1y + 1) =
BLK(ctx->prev, l1x + 1 + mx, l1y + 1 + my);
}
} else {
BLK(ctx->cur, l1x, l1y) = bytestream2_get_byte(&ctx->g);
BLK(ctx->cur, l1x + 1, l1y) = bytestream2_get_byte(&ctx->g);
BLK(ctx->cur, l1x, l1y + 1) = bytestream2_get_byte(&ctx->g);
BLK(ctx->cur, l1x + 1, l1y + 1) = bytestream2_get_byte(&ctx->g);
}
}
}
}
}
}
return 0;
}
| 1threat
|
Is it possible to access mouse events in a Visual Studio Code extension : <p>I would like to write a simple extension for Visual Studio Code to allow basic drag and drop copy/paste functionality but I can't find any way to be notified of mouse events. Have I overlooked something obvious or has the editor intentionally been designed to be keyboard only (well mostly)?</p>
<p><strong>Note:</strong> I am referring to the TypeScript based <strong>Visual Studio Code</strong> editor not the full-blown Visual Studio.</p>
| 0debug
|
When is using a good idea? : By reading this article i got a bit confused:
> https://www.dotnetperls.com/using
They demonstrated that calling using for 2 disposable objects, ended with more memory usage, while the method without usings, doing the same instructions, used lower memory.
Can you explain me why and when should i use the "using"?
I tought that dispose was a good idea to free memory, but it looks like I was wrong ^^
I didn't understand too, what's the difference between:
using (MemoryStream ms = new MemoryStream())
{
//do things..
}
and
MemoryStream ms = new MemoryStream();
//do things..
ms.Dispose();
| 0debug
|
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
TiffEncoderContext *s = avctx->priv_data;
const AVFrame *const p = pict;
int i;
uint8_t *ptr;
uint8_t *offset;
uint32_t strips;
uint32_t *strip_sizes = NULL;
uint32_t *strip_offsets = NULL;
int bytes_per_row;
uint32_t res[2] = { 72, 1 };
uint16_t bpp_tab[] = { 8, 8, 8, 8 };
int ret;
int is_yuv = 0;
uint8_t *yuv_line = NULL;
int shift_h, shift_v;
int packet_size;
const AVPixFmtDescriptor *pfd;
s->avctx = avctx;
s->width = avctx->width;
s->height = avctx->height;
s->subsampling[0] = 1;
s->subsampling[1] = 1;
switch (avctx->pix_fmt) {
case AV_PIX_FMT_RGB48LE:
case AV_PIX_FMT_GRAY16LE:
case AV_PIX_FMT_RGBA:
case AV_PIX_FMT_RGB24:
case AV_PIX_FMT_GRAY8:
case AV_PIX_FMT_PAL8:
pfd = av_pix_fmt_desc_get(avctx->pix_fmt);
s->bpp = av_get_bits_per_pixel(pfd);
if (pfd->flags & AV_PIX_FMT_FLAG_PAL)
s->photometric_interpretation = TIFF_PHOTOMETRIC_PALETTE;
else if (pfd->flags & AV_PIX_FMT_FLAG_RGB)
s->photometric_interpretation = TIFF_PHOTOMETRIC_RGB;
else
s->photometric_interpretation = TIFF_PHOTOMETRIC_BLACK_IS_ZERO;
s->bpp_tab_size = pfd->nb_components;
for (i = 0; i < s->bpp_tab_size; i++)
bpp_tab[i] = s->bpp / s->bpp_tab_size;
break;
case AV_PIX_FMT_MONOBLACK:
s->bpp = 1;
s->photometric_interpretation = TIFF_PHOTOMETRIC_BLACK_IS_ZERO;
s->bpp_tab_size = 0;
break;
case AV_PIX_FMT_MONOWHITE:
s->bpp = 1;
s->photometric_interpretation = TIFF_PHOTOMETRIC_WHITE_IS_ZERO;
s->bpp_tab_size = 0;
break;
case AV_PIX_FMT_YUV420P:
case AV_PIX_FMT_YUV422P:
case AV_PIX_FMT_YUV444P:
case AV_PIX_FMT_YUV410P:
case AV_PIX_FMT_YUV411P:
av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &shift_h, &shift_v);
s->photometric_interpretation = TIFF_PHOTOMETRIC_YCBCR;
s->bpp = 8 + (16 >> (shift_h + shift_v));
s->subsampling[0] = 1 << shift_h;
s->subsampling[1] = 1 << shift_v;
s->bpp_tab_size = 3;
is_yuv = 1;
break;
default:
av_log(s->avctx, AV_LOG_ERROR,
"This colors format is not supported\n");
return -1;
}
if (s->compr == TIFF_DEFLATE ||
s->compr == TIFF_ADOBE_DEFLATE ||
s->compr == TIFF_LZW)
s->rps = s->height;
else
s->rps = FFMAX(8192 / (((s->width * s->bpp) >> 3) + 1), 1);
s->rps = ((s->rps - 1) / s->subsampling[1] + 1) * s->subsampling[1];
strips = (s->height - 1) / s->rps + 1;
packet_size = avctx->height * ((avctx->width * s->bpp + 7) >> 3) * 2 +
avctx->height * 4 + FF_MIN_BUFFER_SIZE;
if (!pkt->data &&
(ret = av_new_packet(pkt, packet_size)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
return ret;
}
ptr = pkt->data;
s->buf_start = pkt->data;
s->buf = &ptr;
s->buf_size = pkt->size;
if (check_size(s, 8))
goto fail;
bytestream_put_le16(&ptr, 0x4949);
bytestream_put_le16(&ptr, 42);
offset = ptr;
bytestream_put_le32(&ptr, 0);
strip_sizes = av_mallocz_array(strips, sizeof(*strip_sizes));
strip_offsets = av_mallocz_array(strips, sizeof(*strip_offsets));
if (!strip_sizes || !strip_offsets) {
ret = AVERROR(ENOMEM);
goto fail;
}
bytes_per_row = (((s->width - 1) / s->subsampling[0] + 1) * s->bpp *
s->subsampling[0] * s->subsampling[1] + 7) >> 3;
if (is_yuv) {
yuv_line = av_malloc(bytes_per_row);
if (!yuv_line) {
av_log(s->avctx, AV_LOG_ERROR, "Not enough memory\n");
ret = AVERROR(ENOMEM);
goto fail;
}
}
#if CONFIG_ZLIB
if (s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE) {
uint8_t *zbuf;
int zlen, zn;
int j;
zlen = bytes_per_row * s->rps;
zbuf = av_malloc(zlen);
if (!zbuf) {
ret = AVERROR(ENOMEM);
goto fail;
}
strip_offsets[0] = ptr - pkt->data;
zn = 0;
for (j = 0; j < s->rps; j++) {
if (is_yuv) {
pack_yuv(s, p, yuv_line, j);
memcpy(zbuf + zn, yuv_line, bytes_per_row);
j += s->subsampling[1] - 1;
} else
memcpy(zbuf + j * bytes_per_row,
p->data[0] + j * p->linesize[0], bytes_per_row);
zn += bytes_per_row;
}
ret = encode_strip(s, zbuf, ptr, zn, s->compr);
av_free(zbuf);
if (ret < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Encode strip failed\n");
goto fail;
}
ptr += ret;
strip_sizes[0] = ptr - pkt->data - strip_offsets[0];
} else
#endif
if (s->compr == TIFF_LZW) {
s->lzws = av_malloc(ff_lzw_encode_state_size);
if (!s->lzws) {
ret = AVERROR(ENOMEM);
goto fail;
}
}
for (i = 0; i < s->height; i++) {
if (strip_sizes[i / s->rps] == 0) {
if (s->compr == TIFF_LZW) {
ff_lzw_encode_init(s->lzws, ptr,
s->buf_size - (*s->buf - s->buf_start),
12, FF_LZW_TIFF, put_bits);
}
strip_offsets[i / s->rps] = ptr - pkt->data;
}
if (is_yuv) {
pack_yuv(s, p, yuv_line, i);
ret = encode_strip(s, yuv_line, ptr, bytes_per_row, s->compr);
i += s->subsampling[1] - 1;
} else
ret = encode_strip(s, p->data[0] + i * p->linesize[0],
ptr, bytes_per_row, s->compr);
if (ret < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Encode strip failed\n");
goto fail;
}
strip_sizes[i / s->rps] += ret;
ptr += ret;
if (s->compr == TIFF_LZW &&
(i == s->height - 1 || i % s->rps == s->rps - 1)) {
ret = ff_lzw_encode_flush(s->lzws, flush_put_bits);
strip_sizes[(i / s->rps)] += ret;
ptr += ret;
}
}
if (s->compr == TIFF_LZW)
av_free(s->lzws);
s->num_entries = 0;
add_entry1(s, TIFF_SUBFILE, TIFF_LONG, 0);
add_entry1(s, TIFF_WIDTH, TIFF_LONG, s->width);
add_entry1(s, TIFF_HEIGHT, TIFF_LONG, s->height);
if (s->bpp_tab_size)
add_entry(s, TIFF_BPP, TIFF_SHORT, s->bpp_tab_size, bpp_tab);
add_entry1(s, TIFF_COMPR, TIFF_SHORT, s->compr);
add_entry1(s, TIFF_PHOTOMETRIC, TIFF_SHORT, s->photometric_interpretation);
add_entry(s, TIFF_STRIP_OFFS, TIFF_LONG, strips, strip_offsets);
if (s->bpp_tab_size)
add_entry1(s, TIFF_SAMPLES_PER_PIXEL, TIFF_SHORT, s->bpp_tab_size);
add_entry1(s, TIFF_ROWSPERSTRIP, TIFF_LONG, s->rps);
add_entry(s, TIFF_STRIP_SIZE, TIFF_LONG, strips, strip_sizes);
add_entry(s, TIFF_XRES, TIFF_RATIONAL, 1, res);
add_entry(s, TIFF_YRES, TIFF_RATIONAL, 1, res);
add_entry1(s, TIFF_RES_UNIT, TIFF_SHORT, 2);
if (!(avctx->flags & CODEC_FLAG_BITEXACT))
add_entry(s, TIFF_SOFTWARE_NAME, TIFF_STRING,
strlen(LIBAVCODEC_IDENT) + 1, LIBAVCODEC_IDENT);
if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
uint16_t pal[256 * 3];
for (i = 0; i < 256; i++) {
uint32_t rgb = *(uint32_t *) (p->data[1] + i * 4);
pal[i] = ((rgb >> 16) & 0xff) * 257;
pal[i + 256] = ((rgb >> 8) & 0xff) * 257;
pal[i + 512] = (rgb & 0xff) * 257;
}
add_entry(s, TIFF_PAL, TIFF_SHORT, 256 * 3, pal);
}
if (is_yuv) {
uint32_t refbw[12] = { 15, 1, 235, 1, 128, 1, 240, 1, 128, 1, 240, 1 };
add_entry(s, TIFF_YCBCR_SUBSAMPLING, TIFF_SHORT, 2, s->subsampling);
add_entry(s, TIFF_REFERENCE_BW, TIFF_RATIONAL, 6, refbw);
}
bytestream_put_le32(&offset, ptr - pkt->data);
if (check_size(s, 6 + s->num_entries * 12)) {
ret = AVERROR(EINVAL);
goto fail;
}
bytestream_put_le16(&ptr, s->num_entries);
bytestream_put_buffer(&ptr, s->entries, s->num_entries * 12);
bytestream_put_le32(&ptr, 0);
pkt->size = ptr - pkt->data;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
fail:
av_free(strip_sizes);
av_free(strip_offsets);
av_free(yuv_line);
return ret;
}
| 1threat
|
static void visit_nested_struct(Visitor *v, void **native, Error **errp)
{
visit_type_UserDefNested(v, (UserDefNested **)native, NULL, errp);
}
| 1threat
|
qcrypto_tls_creds_check_cert_key_purpose(QCryptoTLSCredsX509 *creds,
gnutls_x509_crt_t cert,
const char *certFile,
bool isServer,
Error **errp)
{
int status;
size_t i;
unsigned int purposeCritical;
unsigned int critical;
char *buffer = NULL;
size_t size;
bool allowClient = false, allowServer = false;
critical = 0;
for (i = 0; ; i++) {
size = 0;
status = gnutls_x509_crt_get_key_purpose_oid(cert, i, buffer,
&size, NULL);
if (status == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) {
if (i == 0) {
allowServer = allowClient = true;
}
break;
}
if (status != GNUTLS_E_SHORT_MEMORY_BUFFER) {
error_setg(errp,
"Unable to query certificate %s key purpose: %s",
certFile, gnutls_strerror(status));
return -1;
}
buffer = g_new0(char, size);
status = gnutls_x509_crt_get_key_purpose_oid(cert, i, buffer,
&size, &purposeCritical);
if (status < 0) {
trace_qcrypto_tls_creds_x509_check_key_purpose(
creds, certFile, status, "<none>", purposeCritical);
g_free(buffer);
error_setg(errp,
"Unable to query certificate %s key purpose: %s",
certFile, gnutls_strerror(status));
return -1;
}
trace_qcrypto_tls_creds_x509_check_key_purpose(
creds, certFile, status, buffer, purposeCritical);
if (purposeCritical) {
critical = true;
}
if (g_str_equal(buffer, GNUTLS_KP_TLS_WWW_SERVER)) {
allowServer = true;
} else if (g_str_equal(buffer, GNUTLS_KP_TLS_WWW_CLIENT)) {
allowClient = true;
} else if (g_str_equal(buffer, GNUTLS_KP_ANY)) {
allowServer = allowClient = true;
}
g_free(buffer);
}
if (isServer) {
if (!allowServer) {
if (critical) {
error_setg(errp,
"Certificate %s purpose does not allow "
"use with a TLS server", certFile);
return -1;
}
}
} else {
if (!allowClient) {
if (critical) {
error_setg(errp,
"Certificate %s purpose does not allow use "
"with a TLS client", certFile);
return -1;
}
}
}
return 0;
}
| 1threat
|
stack overflow c copystring with pointers : <p>I'm writing a recursive copystring function in c and I'm receiving a write access violation. The funcion doesn't terminate when the function reaches the final letter in the string.</p>
<p>Here's the code:</p>
<pre><code>#include <stdio.h>
void copy(char*, char*, int);
int main()
{
char str1[10] = { 'H', 'e', ' j',' h','e', 'j' };
char str2[10] = { '/0' };
copy(str1, str2, 0);
printf(str2);
getchar();
return 0;
}
void copy(char* str1, char* str2, int index) {
while (str1[index] != '/0') {
str2[index] = str1[index];
index++;
copy(str1, str2, index);
}
return;
}
</code></pre>
| 0debug
|
Whant 's diffrent creating instance of class? : Please help to answer me what's different between when create object with Line().setLength(6.0);
and
Line line;
line.setLength(6.0);
After commplie the result will be same or not ?
Thanks
#include <iostream>
using namespace std;
class Line {
public:
void setLength( double len );
double getLength( void );
Line(); // This is the constructor declaration
~Line(); // This is the destructor: declaration
private:
double length;
};
// Member functions definitions including constructor
Line::Line(void) {
cout << "Object is being created" << endl;
}
Line::~Line(void) {
cout << "Object is being deleted" << endl;
}
void Line::setLength( double len ) {
length = len;
}
double Line::getLength( void ) {
return length;
}
// Main function for the program
int main( ) {
Line().setLength(6.0);
Line line;
line.setLength(6.0);
return 0;
}
| 0debug
|
void qemu_chr_close(CharDriverState *chr)
{
TAILQ_REMOVE(&chardevs, chr, next);
if (chr->chr_close)
chr->chr_close(chr);
qemu_free(chr->filename);
qemu_free(chr->label);
qemu_free(chr);
}
| 1threat
|
Android error "java.lang.NullPointerException" setImageBitmap : Android get error "java.lang.NullPointerException" assign setImageBitmap
Can you help me, please?
**"result"** is a valid bitmap.
Here is my code:
protected void onPostExecute(Bitmap result) {
super.onPostExecute(result);
try {
ImageView imageView1;
imageView1 = (ImageView) findViewById(R.id.imgbanner);
imageView1.setImageBitmap(result);
return;
} catch (Exception e) {
logMensajes("Error imageload onPostExecute: "+e.toString());
}
}
XML
<ImageView
android:id="@+id/imgbanner"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_below="@+id/txtTitulo"/>
| 0debug
|
Security project ideas, involving encryption : <p>I am a honours student in Computer Science. I am looking for some ideas to create software dealing with encryption. The software ideas that I am looking for are dealing with confidential data and encrypting such to be stored in a secure remote location. </p>
<p>I have done a lot of research and haven't been able to come up with a security encryption software idea that is really unique and out of the ordinary. </p>
<p>Please could you give some unique ideas based around encyption.</p>
<p>Much appreciated for all your insights and ideas.</p>
| 0debug
|
Change div's background from one color to another like gradient : <p>I want to change background of div from red to green depending on variable value. If var value is 1, the background is red. But as the value increases to 1000, div background becomes greener. Like it goes through red-to-green gradient. How can I do this not using jQuery?</p>
<p>P.S. variable value increases every 2 seconds btw</p>
| 0debug
|
static int get_para_features(CPUState *env)
{
int i, features = 0;
for (i = 0; i < ARRAY_SIZE(para_features) - 1; i++) {
if (kvm_check_extension(env->kvm_state, para_features[i].cap))
features |= (1 << para_features[i].feature);
}
return features;
}
| 1threat
|
sd_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
int *pnum)
{
BDRVSheepdogState *s = bs->opaque;
SheepdogInode *inode = &s->inode;
uint32_t object_size = (UINT32_C(1) << inode->block_size_shift);
uint64_t offset = sector_num * BDRV_SECTOR_SIZE;
unsigned long start = offset / object_size,
end = DIV_ROUND_UP((sector_num + nb_sectors) *
BDRV_SECTOR_SIZE, object_size);
unsigned long idx;
int64_t ret = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | offset;
for (idx = start; idx < end; idx++) {
if (inode->data_vdi_id[idx] == 0) {
break;
}
}
if (idx == start) {
ret = 0;
for (idx = start + 1; idx < end; idx++) {
if (inode->data_vdi_id[idx] != 0) {
break;
}
}
}
*pnum = (idx - start) * object_size / BDRV_SECTOR_SIZE;
if (*pnum > nb_sectors) {
*pnum = nb_sectors;
}
return ret;
}
| 1threat
|
alert('Hello ' + user_input);
| 1threat
|
static long do_rt_sigreturn_v2(CPUARMState *env)
{
abi_ulong frame_addr;
struct rt_sigframe_v2 *frame = NULL;
frame_addr = env->regs[13];
trace_user_do_rt_sigreturn(env, frame_addr);
if (frame_addr & 7) {
goto badframe;
}
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
goto badframe;
}
if (do_sigframe_return_v2(env, frame_addr, &frame->uc)) {
goto badframe;
}
unlock_user_struct(frame, frame_addr, 0);
return env->regs[0];
badframe:
unlock_user_struct(frame, frame_addr, 0);
force_sig(TARGET_SIGSEGV );
return 0;
}
| 1threat
|
SwiftUI: Global Overlay That Can Be Triggered From Any View : <p>I'm quite new to the SwiftUI framework and I haven't wrapped my head around all of it yet so please bear with me.</p>
<p>Is there a way to trigger an "overlay view" from inside "another view" when its binding changes? See illustration below:</p>
<p><a href="https://i.stack.imgur.com/sziqy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sziqy.png" alt="enter image description here"></a></p>
<p>I figure this "overlay view" would wrap all my views. I'm not sure how to do this yet - maybe using <code>ZIndex</code>. I also guess I'd need some sort of callback when the binding changes, but I'm also not sure how to do that either.</p>
<p>This is what I've got so far:</p>
<p><strong>ContentView</strong></p>
<pre><code>struct ContentView : View {
@State private var liked: Bool = false
var body: some View {
VStack {
LikeButton(liked: $liked)
}
}
}
</code></pre>
<p><strong>LikeButton</strong></p>
<pre><code>struct LikeButton : View {
@Binding var liked: Bool
var body: some View {
Button(action: { self.toggleLiked() }) {
Image(systemName: liked ? "heart" : "heart.fill")
}
}
private func toggleLiked() {
self.liked = !self.liked
// NEED SOME SORT OF TOAST CALLBACK HERE
}
}
</code></pre>
<p>I feel like I need some sort of callback inside my <code>LikeButton</code>, but I'm not sure how this all works in Swift.</p>
<p>Any help with this would be appreciated. Thanks in advance!</p>
| 0debug
|
Add text to a textBox : Im trying to add a text to a text box but when I write "AppendText" an error occurs that says "cannot convert from string[] to 'string'". Should I use another "add method" or can I remove the [] signs or what should I do?
private void comboBoxCategory_SelectedIndexChanged(object sender, EventArgs e)
{
textBoxCategory.AppendText(new string[] { "Komedi", "Skräck", "Romantik", "Action", "Livsstil" });
}
| 0debug
|
static void serial_xmit(void *opaque)
{
SerialState *s = opaque;
uint64_t new_xmit_ts = qemu_get_clock_ns(vm_clock);
if (s->tsr_retry <= 0) {
if (s->fcr & UART_FCR_FE) {
s->tsr = fifo_get(s,XMIT_FIFO);
if (!s->xmit_fifo.count)
s->lsr |= UART_LSR_THRE;
} else {
s->tsr = s->thr;
s->lsr |= UART_LSR_THRE;
}
}
if (s->mcr & UART_MCR_LOOP) {
serial_receive1(s, &s->tsr, 1);
} else if (qemu_chr_fe_write(s->chr, &s->tsr, 1) != 1) {
if ((s->tsr_retry > 0) && (s->tsr_retry <= MAX_XMIT_RETRY)) {
s->tsr_retry++;
qemu_mod_timer(s->transmit_timer, new_xmit_ts + s->char_transmit_time);
return;
} else if (s->poll_msl < 0) {
s->tsr_retry = -1;
}
}
else {
s->tsr_retry = 0;
}
s->last_xmit_ts = qemu_get_clock_ns(vm_clock);
if (!(s->lsr & UART_LSR_THRE))
qemu_mod_timer(s->transmit_timer, s->last_xmit_ts + s->char_transmit_time);
if (s->lsr & UART_LSR_THRE) {
s->lsr |= UART_LSR_TEMT;
s->thr_ipending = 1;
serial_update_irq(s);
}
}
| 1threat
|
difficulty with prob.3 on project euler (in c++) : <p>so, I've been trying to solve this problem for a few hours now.
shortly I arrived to a solution that logically - should work and is working, but only for numbers no bigger than 10^7. I guess I could just const the specific number they asked for (600851475143) but I would really love to know - why my code isn't working with big numbers?</p>
<p>this is my code for the solution :</p>
<pre><code>#include <iostream>
#include <stdlib.h>
#include <cmath>
using namespace std;
//enter any number and its largest prime factor will be detected.
int main()
{
long largest(1),num(0);
bool primecheck;
cout<<"enter the desired number :"<<endl;
cin>>num;
if (num%2==0)
largest=2;
cout<<"the relevant factors are: ";
for (int i=3;i<=int((sqrt(num))/2);i+=2)
{
primecheck=true;
for(int j=2;j<i;j++)
{
if(i%j==0)
primecheck=false;
}
if(primecheck)
if(num%i==0)
{
largest=i;
cout<< largest<<"\t";
}
}
cout<<endl<< "the largest prime factor of the number you have entered is: " <<largest;
return 0;
}
</code></pre>
<p>thanks in advance! :)</p>
| 0debug
|
int raw_get_aio_fd(BlockDriverState *bs)
{
BDRVRawState *s;
if (!bs->drv) {
return -ENOMEDIUM;
}
if (bs->drv == bdrv_find_format("raw")) {
bs = bs->file;
}
if (bs->drv->bdrv_aio_readv != raw_aio_readv) {
return -ENOTSUP;
}
s = bs->opaque;
if (!s->use_aio) {
return -ENOTSUP;
}
return s->fd;
}
| 1threat
|
Is there a way to access and view html report in Travis CI for maven tests? : <p>Is there a way to access and view html report in Travis CI for maven testng tests ?</p>
<p>At this moment, Travis CI logs is the only way I see how many tests passed/failed/skipped etc.</p>
<p>Something like this:
Tests run: 34, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 50.427 sec</p>
<p>Results :</p>
<p>Tests run: 34, Failures: 0, Errors: 0, Skipped: 0</p>
<p>However there are surefire reports generated in this directory:</p>
<p>[INFO] Surefire report directory: /home/travis/build/xxxx/yyyy/target/surefire-reports</p>
<p>I want to access the surefire-reports/index.html file and view the results.</p>
<p>Is this possible,could someone help?</p>
| 0debug
|
I can start my video but can't play it : <p>I have this video:</p>
<pre><code><video src='videos/StressedOut.mp4' class='prize_video' controls></video>
</code></pre>
<p>I've <em>checked</em>, the URL is working. <code>.prize_video</code> doesn't affect the function of the video, only the style:</p>
<pre><code>.prize_video {
width: 800px;
height: 480px;
position: relative;
left: 22px;
}
</code></pre>
<p><strong>I can click play, but the video won't start...</strong></p>
| 0debug
|
Angular 2 Cli adding routes to existing project : <p>I have an existing Angular 2 App. Now I would like to use routing for navigation.
Is there a way to add routing to an existing Angular 2 Project using the Angular 2 Cli?</p>
<p>Lets say I have an Component "test" and want a route to this in a global Scope.</p>
| 0debug
|
Apply global variable to Vuejs : <p>I have a javascript variable which I want to pass globally to Vue components upon instantiation thus either each registered component has it as a property or it can be accessed globally.</p>
<p>Note:: I need to set this global variable for vuejs as a <strong>READ ONLY</strong> property</p>
| 0debug
|
Why does my google colab session keep crashing? : <p>I am using google colab on a dataset with 4 million rows and 29 columns. When I run the statement sns.heatmap(dataset.isnull()) it runs for some time but after a while the session crashes and the instance restarts. It has been happening a lot and I till now haven't really seen an output. What can be the possible reason ? Is the data/calculation too much ? What can I do ?</p>
| 0debug
|
How to extract only specific parts from an image in java android? : [Sample Image][1]
[1]: https://i.stack.imgur.com/O3O0s.jpg
Hello, I have a task to build an android app that extracts only specific parts of an image.Like, for example, extract only the part that contains the phone number from the sample image above and then use an OCR to extract the text in that part.
I have already implemented Google's Text Recognition API to extract text from an image and it works good, but I don't want to extract everything, just a specific part.
Is that possible? and if it is, what techniques should I use to solve this problem?
Thank you
| 0debug
|
How to check if input string is a hash of algorhitms from list: ["md5", "sha1", "sha256"] : <p>I have to write method like this:</p>
<pre><code>boolean isHash(String str){
...
}
</code></pre>
<p>Method should return true if input string is <code>md5</code> hash or <code>sha1</code> hash or <code>sha256</code> hash.</p>
<p>Is it possible to implement such method ?</p>
| 0debug
|
What is the Big O and the runtime of this function? : <p>Assume that each take 1 time unit:</p>
<ul>
<li>Arithmetic operations</li>
<li>Assignment(=) </li>
<li>Boolean comparison</li>
<li>Function activation/return</li>
<li>Array element assignment/access</li>
<li><p>Variable declaration</p>
<pre><code>public static int foo5(int x){
if (x<=0) return 0;
int half = x/2;
return 1 + foo5(half);
}
</code></pre></li>
</ul>
| 0debug
|
int put_wav_header(ByteIOContext *pb, AVCodecContext *enc)
{
int bps, blkalign, bytespersec;
int hdrsize = 18;
if(!enc->codec_tag || enc->codec_tag > 0xffff)
enc->codec_tag = codec_get_tag(codec_wav_tags, enc->codec_id);
if(!enc->codec_tag)
return -1;
put_le16(pb, enc->codec_tag);
put_le16(pb, enc->channels);
put_le32(pb, enc->sample_rate);
if (enc->codec_id == CODEC_ID_PCM_U8 ||
enc->codec_id == CODEC_ID_PCM_ALAW ||
enc->codec_id == CODEC_ID_PCM_MULAW) {
bps = 8;
} else if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3) {
bps = 0;
} else if (enc->codec_id == CODEC_ID_ADPCM_IMA_WAV || enc->codec_id == CODEC_ID_ADPCM_MS || enc->codec_id == CODEC_ID_ADPCM_G726 || enc->codec_id == CODEC_ID_ADPCM_YAMAHA) {
bps = 4;
} else if (enc->codec_id == CODEC_ID_PCM_S24LE) {
bps = 24;
} else if (enc->codec_id == CODEC_ID_PCM_S32LE) {
bps = 32;
} else {
bps = 16;
}
if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3) {
blkalign = enc->frame_size; this is wrong, but seems many demuxers dont work if this is set correctly
blkalign = 144 * enc->bit_rate/enc->sample_rate;
} else if (enc->codec_id == CODEC_ID_ADPCM_G726) {
blkalign = 1;
} else if (enc->block_align != 0) {
blkalign = enc->block_align;
} else
blkalign = enc->channels*bps >> 3;
if (enc->codec_id == CODEC_ID_PCM_U8 ||
enc->codec_id == CODEC_ID_PCM_S24LE ||
enc->codec_id == CODEC_ID_PCM_S32LE ||
enc->codec_id == CODEC_ID_PCM_S16LE) {
bytespersec = enc->sample_rate * blkalign;
} else {
bytespersec = enc->bit_rate / 8;
}
put_le32(pb, bytespersec);
put_le16(pb, blkalign);
put_le16(pb, bps);
if (enc->codec_id == CODEC_ID_MP3) {
put_le16(pb, 12);
hdrsize += 12;
put_le16(pb, 1);
put_le32(pb, 2);
put_le16(pb, 1152);
put_le16(pb, 1);
put_le16(pb, 1393);
} else if (enc->codec_id == CODEC_ID_MP2) {
put_le16(pb, 22);
hdrsize += 22;
put_le16(pb, 2);
put_le32(pb, enc->bit_rate);
put_le16(pb, enc->channels == 2 ? 1 : 8);
put_le16(pb, 0);
put_le16(pb, 1);
put_le16(pb, 16);
put_le32(pb, 0);
put_le32(pb, 0);
} else if (enc->codec_id == CODEC_ID_ADPCM_IMA_WAV) {
put_le16(pb, 2);
hdrsize += 2;
put_le16(pb, ((enc->block_align - 4 * enc->channels) / (4 * enc->channels)) * 8 + 1);
} else if(enc->extradata_size){
put_le16(pb, enc->extradata_size);
put_buffer(pb, enc->extradata, enc->extradata_size);
hdrsize += enc->extradata_size;
if(hdrsize&1){
hdrsize++;
put_byte(pb, 0);
}
} else {
hdrsize -= 2;
}
return hdrsize;
}
| 1threat
|
I made a platformer! wait... something went wrong :\ : i have started with making a platformer. but my first attempt was a biiiig failure.
code:
sorry, the code is not working, it says 'invalid code format'
i'll just leave the link to download it...
https://yadi.sk/d/dtiUXyAL-KV8vQ
The error is:
Traceback (most recent call last):
File "it dosen't matter", line 68, in <module>
draw()
File "it dosen't matter", line 30, in draw
win.blit(bg, (0, 0))
TypeError: argument 1 must be pygame.Surface, not list
i don't know what the heck is this...
i watched a loooooooooot of videos but nobody helped!
so i tried ALL ide's i know, but all give that freaking error!
tried to re-write the programm, but still i see this.
waht have i do?
| 0debug
|
Why am I getting more characters printed? : Currently tasked with replacing the "SUPER MAN" with
"S^U^P^E^R M^A^N"
I've tried print(hero.replace("" "", "^")) but end up with
^S^U^P^E^R^ ^M^A^N^
| 0debug
|
Pointers code not functioning : trying to create a simple function parsing an array and copying into another all the values between an interval. here is the code:
#include<stdio.h>
#define LEN 5
int* vediValori(int *valori, int inf, int sup, float *media);
int main()
{
int val[LEN] = {10,20,30,40,50}, inf, sup, *valScelti = NULL;
float media = 0.0;
printf("Inserisci estremo inferiore: ");
scanf("%d", &inf);
printf("Inserisci estremo superiore: ");
scanf("%d", &sup);
printf("\nVerranno ora isolati tutti i valori compresi fra gli estremi...\n");
valScelti = vediValori(val, inf, sup, &media);
printf("\nNUOVO VETTORE CREATO:\n\n");
for(int i = 0; i < LEN; i++)
{
printf("%d\n", valScelti[i]);
}
}
int* vediValori(int *valori, int inf, int sup, float *media)
{
int *tmp, i = 0, j = 0;
while(i < LEN)
{
if(*(valori+i) >= inf && *(valori+i) <= sup)
{
*(tmp+j) = *(valori+i);
*media += *(valori+i);
j++;
}
i++;
}
return tmp;
}
Why does it not function? Where am I wrong ??? Any help will be appreciated thanks :)
| 0debug
|
Optional({ message = Hello; success = true; user = { fullname = "xyz"; id = 0; }; }) : I Want To Access "fullname" In User Array In UserDefaults By This Statement
if currentUser?[""] != nil {
// do something
}
| 0debug
|
static int mxf_read_cryptographic_context(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
MXFCryptoContext *cryptocontext = arg;
if (size != 16)
return -1;
if (IS_KLV_KEY(uid, mxf_crypto_source_container_ul))
avio_read(pb, cryptocontext->source_container_ul, 16);
return 0;
}
| 1threat
|
How can I check if vector elements are in order? : I need to check if in my vector the elements are in order
for(i=1; i<=K; i++)
if(v[i]=v[i+1]-1)
If the statement would be true I want to return the biggest integer.
> ex. 4 5 6 7
7
| 0debug
|
How to perform a left join in SQLALchemy? : <p>I have a SQL query which perfroms a series of left joins on a few tables:</p>
<pre><code>SELECT
<some attributes>
FROM table1 t1
INNER JOIN table2 t2
ON attr = 1 AND attr2 = 1
LEFT JOIN table3 t3
ON t1.Code = t2.Code AND t3.Date_ = t1.Date_
LEFT JOIN tabl4 t4
ON t4.Code = t1.code AND t4.Date_ = t1.Date_
</code></pre>
<p>So far, I have:</p>
<pre><code>(sa.select([idc.c.Code])
.select_from(
t1.join(t2, and_(t1.c.attr == 1, t2.c.attr2 = 1))
.join(t3, t3.c.Code == t1.c.Code)))
</code></pre>
<p>but I can't figure out how to make the join a <code>LEFT JOIN</code>.</p>
| 0debug
|
trouble making c++ student class : <p>For my assignment I have to make a program to read student data from standard input, sort it by last name / first name, and print out the result to standard output. Students consists of a last name, first name, and a grade point average. It says to there are no more than 50 students.
It also says you should not rely on an external library function to do the sort.</p>
<p>Here is the example:</p>
<p>Ware Henry 87.2</p>
<p>Dantes Edmond 91.4</p>
<p>Earhart Amelia 92.6</p>
<p>Here is how it should be sorted:</p>
<p>Dantes Edmond 91.4</p>
<p>Earhart Amelia 92.6</p>
<p>Ware Henry 87.2</p>
<p>Here is the code I have so far that is not working properly:</p>
<pre><code>#include <iostream>
#include <string>
using namespace std;
class student
{
public:
student();
void input();
void output();
void sort();
private:
string Fname;
string Lname;
float gpa;
}
student::student()
{
Fname = "";
Lname = "";
gpa = 0;
}
void student::input()
{
cout << "Enter first name, last name, and gpa"<<endl;
cin >> Fname >> Lname >> gpa;
}
void student::sort()
{
char temp;
int count = 0;
int i = 1;
while (i < word.size()) {
if (word[i - 1] > word[i]) {
temp = word[i];
word[i] = word[i + 1];
word[i + 1] = temp;
i++;
if (i >= word.size())
{
alpha(word);
}
}
else
{
count++;
}
}
return word;
}
void main()
{
student.input();
}
</code></pre>
<p>Any advice on where I went wrong and any possible solutions?</p>
| 0debug
|
My comand prompt exits right after I test my code : <p>Right after I start my PYTHON code my comand prompt exits.I can't even test it out or see the result becaues it exits too fast.Any help?</p>
| 0debug
|
java script for image thumbnail? :
My image thumbnails are cropping not showing the original image
blog link : ravitejasps.blogspot.in
[This is the original image on my blog.][2]
[On home page it is showing cropped image][3]
<a expr:href='data:post.url'><div class='img-thumbnail'><span class='overlay'/><script type='text/javascript'>
document.write(bp_thumbnail_resize("<data:post.thumbnailUrl/>"enter code here;,'<data:post.title/>'));
</script></div>
</a>
function bp_thumbnail_resize(image_url,post_title)
{
var image_width=200;
var image_height=160;
image_tag='<img width="'+image_width+'" height="'+image_height+'" src="'+image_url.replace('/s72-c/','/w'+image_width+'-h'+image_height+'-c/')+'" alt="'+post_title.replace(/"/g,"")+'" title="'+post_title.replace(/"/g,"")+'"/>';
if(post_title!="") return image_tag; else return "";
}
[1]: http://ravitejasps.blogspot.in/
[2]: https://i.stack.imgur.com/lF3HH.png
[3]: https://i.stack.imgur.com/NuHT9.png
| 0debug
|
Using php in python language is really a good practice? : <p>I'm a PHP Developer, i have some projects in python.</p>
<p>But already i done some core concepts in PHP. so is it good for reuse the those php code in python by calling via "php file.php" to return the output.</p>
<p>Is it's really a good practice ?</p>
<p>Or I should develop from scratch ?</p>
| 0debug
|
static void GCC_FMT_ATTR(2, 3) qtest_send(CharDriverState *chr,
const char *fmt, ...)
{
va_list ap;
char buffer[1024];
size_t len;
va_start(ap, fmt);
len = vsnprintf(buffer, sizeof(buffer), fmt, ap);
va_end(ap);
qemu_chr_fe_write_all(chr, (uint8_t *)buffer, len);
if (qtest_log_fp && qtest_opened) {
fprintf(qtest_log_fp, "%s", buffer);
}
}
| 1threat
|
Why is my heading and text not appearing? : <p>I'm sure this is really simple, sorry but I'm a web noob. I can't get the headings to show up on the page.</p>
<pre><code><html>
<style>
body {
background: linear-gradient(to right, #bdc3c7, #2c3e50);
}
<style/>
<body>
<h1>That Was Then<h1/>
<p> A toronto based band <p>
<body/>
<html/>
</code></pre>
| 0debug
|
C++ showing 2 Char instead of 1 : This is my 1st post here and i am hoping someone can help me understand something i am missing, i have gone multiple ways and cannot seem to get my program to show both values i have listed within the '', i have it listed as 'Aa', 'Bb' and so on but when i run the code it only shows the 2nd letter (lowercase letter) -- i have tried changing up from int conversions, pointers and other things but cannot figure this part out, any help is greatly appreciated!
Here is my code i have:
#include "stdafx.h"
#include <iostream>
#include <cctype>
#include <string>
using std::cin;
using std::cout;
using std::endl;
int main()
{
char letters[] = { 'Aa', 'Bb', 'Cc', 'Dd', 'Ee', 'Ff', 'Gg', 'Hh',
'Ii', 'Jj', 'Kk', 'Ll', 'Mm', 'Nn', 'Oo', 'Pp', 'Qq', 'Rr', 'Ss',
'Tt', 'Uu', 'Vv', 'Ww', 'Xx', 'Yy', 'Zz', '\0'};
for (char * cp = letters; *cp; ++cp)
{
if (*cp == 0) break;
printf("%c", *cp);
}
cout << endl;
Using this it displays the alphabet but just the lowercase values, how can i get it to display both the uppercase and lowercase values as the 1 item between the 2 ''
Than you!
| 0debug
|
How can I build a GUI to use inside a jupyter notebook? : <p>The idea is to be able to build and use the GUI inside the notebook, so working with a long function that has a lot of parameters is more efficient than just typing the characters in the notebook.</p>
<p>Obviously not specifics, but if someone can point some library, project, links or any resources that might help.</p>
| 0debug
|
static int proxy_link(FsContext *ctx, V9fsPath *oldpath,
V9fsPath *dirpath, const char *name)
{
int retval;
V9fsString newpath;
v9fs_string_init(&newpath);
v9fs_string_sprintf(&newpath, "%s/%s", dirpath->data, name);
retval = v9fs_request(ctx->private, T_LINK, NULL, "ss", oldpath, &newpath);
v9fs_string_free(&newpath);
if (retval < 0) {
errno = -retval;
retval = -1;
}
return retval;
}
| 1threat
|
static int of_dpa_cmd_group_add(OfDpa *of_dpa, uint32_t group_id,
RockerTlv **group_tlvs)
{
OfDpaGroup *group = of_dpa_group_find(of_dpa, group_id);
int err;
if (group) {
return -ROCKER_EEXIST;
}
group = of_dpa_group_alloc(group_id);
if (!group) {
return -ROCKER_ENOMEM;
}
err = of_dpa_cmd_group_do(of_dpa, group_id, group, group_tlvs);
if (err) {
goto err_cmd_add;
}
err = of_dpa_group_add(of_dpa, group);
if (err) {
goto err_cmd_add;
}
return ROCKER_OK;
err_cmd_add:
g_free(group);
return err;
}
| 1threat
|
Failed to initialise psql dB cluster on windows : I am beginning in postgresql, and I have this problem after installing it on windows. Any idea?
[1]: https://i.stack.imgur.com/HJvXJ.jpg
| 0debug
|
Moshi generic type adapter : <p>Suppose have the following parameterised data class representing a server response:</p>
<pre><code>public class SocketResponse<T> {
private String responseMessage;
private int responseCode;
private T entity;
}
</code></pre>
<p>I know at runtime what type T will be. does moshi support generic type adapter the same way Gson does? With Gson id do the following to parse this. </p>
<pre><code>Type typeA = new TypeToken<SocketResponse<MyResponseA>>(){}.getType();
SocketResponse<MyResponseA> responseA = getResponse("json", typeA);
Type typeB = new TypeToken<SocketResponse<MyResponseB>>(){}.getType();
SocketResponse<MyResponseB> responseB = getResponse("json", typeB);
private String getResponse(Type t){
return gson.fromJson(response, type);
}
</code></pre>
| 0debug
|
Python 3 Help. I need help detecting if a random integer is Odd or Even using an If statement :
#As my first coding project I am trying to make a dice game and I want to make it so it will detect if the number on the dice is odd or even. This is what I tried and it didnt work. You can change everything or chance some of the code I made. THANKS!
from random import randrange
import random
import time
Even = [2, 4, 6]
Odd = [1, 3, 5]
x = random.randint(1, 6)
print("Rolling Dice...")
print("Your number is...." + str(x))
if str(x) == Even:
print("It is an Even number!")
if str(x) == Odd:
print("It is an Odd number!")
#I need to know how to do the if statments and to make it detect if its even or odd. I am a beginner so my coding isnt that great btw. Thanks in advance!
| 0debug
|
Need help debugging this SQL Procedure for MSSQL : Hi I've been trying to create the Procedure as below but after queriing it kept giving me these errors
sg 137, Level 15, State 1, Procedure PKG_BNLX5_INSERT_DMBATCHERRLOG, Line 164
Must declare the scalar variable "@V_ERR_REC".
Msg 137, Level 15, State 1, Procedure PKG_BNLX5_INSERT_DMBATCHERRLOG, Line 165
Must declare the scalar variable "@V_ERR_REC".
Msg 137, Level 15, State 1, Procedure PKG_BNLX5_INSERT_DMBATCHERRLOG, Line 166
Must declare the scalar variable "@V_ERR_REC".
Msg 137, Level 15, State 1, Procedure PKG_BNLX5_INSERT_DMBATCHERRLOG, Line 167
Must declare the scalar variable "@V_ERR_REC".
Msg 137, Level 15, State 1, Procedure PKG_BNLX5_INSERT_DMBATCHERRLOG, Line 168
Must declare the scalar variable "@V_ERR_REC".
Msg 137, Level 15, State 1, Procedure PKG_BNLX5_INSERT_DMBATCHERRLOG, Line 169
Must declare the scalar variable "@V_ERR_REC".
Msg 137, Level 15, State 1, Procedure PKG_BNLX5_INSERT_DMBATCHERRLOG, Line 170
Must declare the scalar variable "@V_ERR_REC".
Msg 137, Level 15, State 1, Procedure PKG_BNLX5_INSERT_DMBATCHERRLOG, Line 171
Must declare the scalar variable "@V_ERR_REC".
Msg 102, Level 15, State 1, Procedure PKG_BNLX5_INSERT_DMBATCHERRLOG, Line 172
Incorrect syntax near '@V_ERR_REC'.
CREATE PROCEDURE "PKG_BNLX5_INSERT_DMBATCHERRLOG"(@IN_PROCNAME VARCHAR(4000),
@IN_TARNAME VARCHAR(4000),
@IN_CURSOR VARCHAR(4000),
@IN_UNIQUE_NUMBER FLOAT,
@IN_SQLCODE VARCHAR(4000),
@IN_SQLERRM VARCHAR(4000),
@IN_REMARK VARCHAR(4000)) AS
BEGIN
SET NOCOUNT ON;
SET @V_ERR_REC.PROCNAME = @IN_PROCNAME;
SET @V_ERR_REC.TARNAME = @IN_TARNAME;
SET @V_ERR_REC.CURSOR = @IN_CURSOR;
SET @V_ERR_REC.UNIQUE_NUMBER = @IN_UNIQUE_NUMBER;
SET @V_ERR_REC.DATIME = GETDATE();
SET @V_ERR_REC.ERRCODE = @IN_SQLCODE;
SET @V_ERR_REC.ERRDESC = @IN_SQLERRM;
SET @V_ERR_REC.REMARK = @IN_REMARK;
INSERT INTO VM1DTA.DMBATCHERRLOG VALUES @V_ERR_REC;
COMMIT;
END;
| 0debug
|
static void qpi_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
{
}
| 1threat
|
What is the simplest solution for a program to draw lines and pixels using C++? : <p>I am an electronic engineer and shall be designing a hardware system that renders 2D and later 3D graphics. Before I can do things in hardware I will need to test the algorithms that I read in books. Basically I need to write C++ program that can draw lines and individual pixels on screen. I shall use this to test all of algorithms before I write VHDL to achieve the same in hardware.</p>
<p>What method/solution do I use to get a window that I can draw pixels and lines in using C++? I will test my projection matrix code and bresenham integer line algorithm code among other things. I do not need anything more complex as it will defeat the purpose e.g if the program automatically shades surfaces or does automatic hiding of hidden surface then the purpose is defeated.</p>
| 0debug
|
Distance between two polylines : <p>I want to calculate the distance <em>d</em> between two polylines:</p>
<p><a href="https://i.stack.imgur.com/1mdId.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1mdId.png" alt="polyline-polyline-distance"></a></p>
<p>Obviously I could check the distance for all pairs of line-segments and choose the smallest distance, but this ways the algorithmn would have a runtime of <em>O(n<sup>2</sup>)</em>. Is there any better approach?</p>
| 0debug
|
Converting OModel into JSON Model : Because of Problems with reading all lines of a UI5 common table and the getModel() method from table offers a model.
I thought I could use an JSONModel instead of my OModel the problem now is how to get the OModel too the Json Model.
Because JSON offers some Two Way Binding options which should be helpfull know what did I try.
I tried to read some Set and bind it to the JSONModel the problem is that i couldn't bind know the new Model two the View because it doesn't overs some set here is a snippet of my code hopefully this should be easyer too fix as the reading all table rows:
oModel2.read("/SEARCH_DLSet" + filterString, null, null, false, function (oData, oResponse) {
oODataJSONModelDLSet.setData(oData);
});
I saw that the table row binding has found the correct length of the data that it should get but the column binding want work here is snippet of code of row binding and then the column
<t:Table class="table0" id="table1" selectionMode="MultiToggle" rows="{jsonmodel>/oData/results}">
<t:columns>
<t:Column class="columns" width="105.27px">
<Label text="Kontrakt Nr." id="lKontrakt" >
</Label>
<t:template >
<commons:TextField id="Kontrakt" editable="false" value="{KontraktNr}" ></commons:TextField>
</t:template>
</t:Column>
too my model doesn't show the model propertys in the debuger.
So where is my failuer and how can i fix the convert?
I could too over some screens if it is helpfull of debugging and few
| 0debug
|
how to accept tcp stream from client (video stream )? : I trying to get video stream from client on TCP connection.
I define a socket on the code below - but i don't know how to continue it.
I need to wait until client will connect - and listen until the client will close the tcp connection -
public void Connect(int port)
{
Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
server.Bind(new IPEndPoint(IPAddress.Any, port));
server.Listen(100);
while (true)
{
Socket clientSocket = server.Accept();
}
}
// how to wait client connection and listen the stream ?
| 0debug
|
Node exe is killing automatically. No event logs and silently exiting in less than one second. node js version is 0.10 : Additional information is that node.exe is exiting in different places every time. This we found by adding logs. Node.exe at max will be alive for 2 sec.
Please provide some pointer on how to proceed & check what is the trigger for exit of node.exe
| 0debug
|
Use two nested for structures to log the following pattern. Any ideas? : <pre><code> 0 1 0 1
1 0 1 0
0 1 0 1
1 0 1 0
</code></pre>
<p>Any ideas on how to get this done in JavaScript using 2 nested for loops? </p>
| 0debug
|
Android Studio 2.2.1: Slow Debugging : <p>Since the update to version 2.21 the <code>Debugging</code> has become very slow. One exmaple: When I start my app without the debugger in completes one function in less than 2 seconds. With the debugger connected I have to wait more than 4 minutes for its completion. The update <code>2.2.2</code> did not solve this problem. What can I do to increase the debug speed again?</p>
| 0debug
|
static int transcode(OutputFile *output_files,
int nb_output_files,
InputFile *input_files,
int nb_input_files)
{
int ret = 0, i;
AVFormatContext *is, *os;
AVCodecContext *codec, *icodec;
OutputStream *ost;
InputStream *ist;
char error[1024];
int key;
int want_sdp = 1;
uint8_t *no_packet;
int no_packet_count=0;
int64_t timer_start;
if (!(no_packet = av_mallocz(nb_input_files)))
exit_program(1);
if (rate_emu)
for (i = 0; i < nb_input_streams; i++)
input_streams[i].start = av_gettime();
for(i=0;i<nb_output_files;i++) {
os = output_files[i].ctx;
if (!os->nb_streams && !(os->oformat->flags & AVFMT_NOSTREAMS)) {
av_dump_format(os, i, os->filename, 1);
fprintf(stderr, "Output file #%d does not contain any stream\n", i);
ret = AVERROR(EINVAL);
goto fail;
}
}
for (i = 0; i < nb_output_streams; i++) {
ost = &output_streams[i];
os = output_files[ost->file_index].ctx;
ist = &input_streams[ost->source_index];
codec = ost->st->codec;
icodec = ist->st->codec;
ost->st->disposition = ist->st->disposition;
codec->bits_per_raw_sample= icodec->bits_per_raw_sample;
codec->chroma_sample_location = icodec->chroma_sample_location;
if (ost->st->stream_copy) {
uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE;
if (extra_size > INT_MAX) {
ret = AVERROR(EINVAL);
goto fail;
}
codec->codec_id = icodec->codec_id;
codec->codec_type = icodec->codec_type;
if(!codec->codec_tag){
if( !os->oformat->codec_tag
|| av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id
|| av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0)
codec->codec_tag = icodec->codec_tag;
}
codec->bit_rate = icodec->bit_rate;
codec->rc_max_rate = icodec->rc_max_rate;
codec->rc_buffer_size = icodec->rc_buffer_size;
codec->extradata= av_mallocz(extra_size);
if (!codec->extradata) {
ret = AVERROR(ENOMEM);
goto fail;
}
memcpy(codec->extradata, icodec->extradata, icodec->extradata_size);
codec->extradata_size= icodec->extradata_size;
codec->time_base = ist->st->time_base;
if(!strcmp(os->oformat->name, "avi")) {
if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > 2*av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){
codec->time_base = icodec->time_base;
codec->time_base.num *= icodec->ticks_per_frame;
codec->time_base.den *= 2;
}
} else if(!(os->oformat->flags & AVFMT_VARIABLE_FPS)) {
if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){
codec->time_base = icodec->time_base;
codec->time_base.num *= icodec->ticks_per_frame;
}
}
av_reduce(&codec->time_base.num, &codec->time_base.den,
codec->time_base.num, codec->time_base.den, INT_MAX);
switch(codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if(audio_volume != 256) {
fprintf(stderr,"-acodec copy and -vol are incompatible (frames are not decoded)\n");
exit_program(1);
}
codec->channel_layout = icodec->channel_layout;
codec->sample_rate = icodec->sample_rate;
codec->channels = icodec->channels;
codec->frame_size = icodec->frame_size;
codec->audio_service_type = icodec->audio_service_type;
codec->block_align= icodec->block_align;
if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3)
codec->block_align= 0;
if(codec->codec_id == CODEC_ID_AC3)
codec->block_align= 0;
break;
case AVMEDIA_TYPE_VIDEO:
codec->pix_fmt = icodec->pix_fmt;
codec->width = icodec->width;
codec->height = icodec->height;
codec->has_b_frames = icodec->has_b_frames;
if (!codec->sample_aspect_ratio.num) {
codec->sample_aspect_ratio =
ost->st->sample_aspect_ratio =
ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio :
ist->st->codec->sample_aspect_ratio.num ?
ist->st->codec->sample_aspect_ratio : (AVRational){0, 1};
}
break;
case AVMEDIA_TYPE_SUBTITLE:
codec->width = icodec->width;
codec->height = icodec->height;
break;
case AVMEDIA_TYPE_DATA:
break;
default:
abort();
}
} else {
if (!ost->enc)
ost->enc = avcodec_find_encoder(ost->st->codec->codec_id);
switch(codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
ost->fifo= av_fifo_alloc(1024);
if (!ost->fifo) {
ret = AVERROR(ENOMEM);
goto fail;
}
ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE);
if (!codec->sample_rate) {
codec->sample_rate = icodec->sample_rate;
}
choose_sample_rate(ost->st, ost->enc);
codec->time_base = (AVRational){1, codec->sample_rate};
if (codec->sample_fmt == AV_SAMPLE_FMT_NONE)
codec->sample_fmt = icodec->sample_fmt;
choose_sample_fmt(ost->st, ost->enc);
if (!codec->channels) {
codec->channels = icodec->channels;
codec->channel_layout = icodec->channel_layout;
}
if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels)
codec->channel_layout = 0;
ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1;
icodec->request_channels = codec->channels;
ist->decoding_needed = 1;
ost->encoding_needed = 1;
ost->resample_sample_fmt = icodec->sample_fmt;
ost->resample_sample_rate = icodec->sample_rate;
ost->resample_channels = icodec->channels;
break;
case AVMEDIA_TYPE_VIDEO:
if (codec->pix_fmt == PIX_FMT_NONE)
codec->pix_fmt = icodec->pix_fmt;
choose_pixel_fmt(ost->st, ost->enc);
if (ost->st->codec->pix_fmt == PIX_FMT_NONE) {
fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\n");
exit_program(1);
}
if (!codec->width || !codec->height) {
codec->width = icodec->width;
codec->height = icodec->height;
}
ost->video_resample = codec->width != icodec->width ||
codec->height != icodec->height ||
codec->pix_fmt != icodec->pix_fmt;
if (ost->video_resample) {
codec->bits_per_raw_sample= frame_bits_per_raw_sample;
}
ost->resample_height = icodec->height;
ost->resample_width = icodec->width;
ost->resample_pix_fmt= icodec->pix_fmt;
ost->encoding_needed = 1;
ist->decoding_needed = 1;
if (!ost->frame_rate.num)
ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25,1};
if (ost->enc && ost->enc->supported_framerates && !force_fps) {
int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates);
ost->frame_rate = ost->enc->supported_framerates[idx];
}
codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num};
if( av_q2d(codec->time_base) < 0.001 && video_sync_method
&& (video_sync_method==1 || (video_sync_method<0 && !(os->oformat->flags & AVFMT_VARIABLE_FPS)))){
av_log(os, AV_LOG_WARNING, "Frame rate very high for a muxer not effciciently supporting it.\n"
"Please consider specifiying a lower framerate, a different muxer or -vsync 2\n");
}
#if CONFIG_AVFILTER
if (configure_video_filters(ist, ost)) {
fprintf(stderr, "Error opening filters!\n");
exit(1);
}
#endif
break;
case AVMEDIA_TYPE_SUBTITLE:
ost->encoding_needed = 1;
ist->decoding_needed = 1;
break;
default:
abort();
break;
}
if (ost->encoding_needed && codec->codec_id != CODEC_ID_H264 &&
(codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {
char logfilename[1024];
FILE *f;
snprintf(logfilename, sizeof(logfilename), "%s-%d.log",
pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX,
i);
if (codec->flags & CODEC_FLAG_PASS1) {
f = fopen(logfilename, "wb");
if (!f) {
fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\n", logfilename, strerror(errno));
exit_program(1);
}
ost->logfile = f;
} else {
char *logbuffer;
size_t logbuffer_size;
if (read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {
fprintf(stderr, "Error reading log file '%s' for pass-2 encoding\n", logfilename);
exit_program(1);
}
codec->stats_in = logbuffer;
}
}
}
if(codec->codec_type == AVMEDIA_TYPE_VIDEO){
int size= codec->width * codec->height;
bit_buffer_size= FFMAX(bit_buffer_size, 6*size + 1664);
}
}
if (!bit_buffer)
bit_buffer = av_malloc(bit_buffer_size);
if (!bit_buffer) {
fprintf(stderr, "Cannot allocate %d bytes output buffer\n",
bit_buffer_size);
ret = AVERROR(ENOMEM);
goto fail;
}
for (i = 0; i < nb_output_streams; i++) {
ost = &output_streams[i];
if (ost->encoding_needed) {
AVCodec *codec = ost->enc;
AVCodecContext *dec = input_streams[ost->source_index].st->codec;
if (!codec) {
snprintf(error, sizeof(error), "Encoder (codec %s) not found for output stream #%d.%d",
avcodec_get_name(ost->st->codec->codec_id), ost->file_index, ost->index);
ret = AVERROR(EINVAL);
goto dump_format;
}
if (dec->subtitle_header) {
ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size);
if (!ost->st->codec->subtitle_header) {
ret = AVERROR(ENOMEM);
goto dump_format;
}
memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);
ost->st->codec->subtitle_header_size = dec->subtitle_header_size;
}
if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) {
snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height",
ost->file_index, ost->index);
ret = AVERROR(EINVAL);
goto dump_format;
}
assert_codec_experimental(ost->st->codec, 1);
assert_avoptions(ost->opts);
if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000)
av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low."
"It takes bits/s as argument, not kbits/s\n");
extra_size += ost->st->codec->extradata_size;
}
}
for (i = 0; i < nb_input_streams; i++)
if ((ret = init_input_stream(i, output_streams, nb_output_streams, error, sizeof(error)) < 0))
goto dump_format;
for (i = 0; i < nb_output_files; i++) {
os = output_files[i].ctx;
if (avformat_write_header(os, &output_files[i].opts) < 0) {
snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i);
ret = AVERROR(EINVAL);
goto dump_format;
}
if (strcmp(os->oformat->name, "rtp")) {
want_sdp = 0;
}
}
dump_format:
for(i=0;i<nb_output_files;i++) {
av_dump_format(output_files[i].ctx, i, output_files[i].ctx->filename, 1);
}
if (verbose >= 0) {
fprintf(stderr, "Stream mapping:\n");
for (i = 0; i < nb_output_streams;i ++) {
ost = &output_streams[i];
fprintf(stderr, " Stream #%d.%d -> #%d.%d",
input_streams[ost->source_index].file_index,
input_streams[ost->source_index].st->index,
ost->file_index,
ost->index);
if (ost->sync_ist != &input_streams[ost->source_index])
fprintf(stderr, " [sync #%d.%d]",
ost->sync_ist->file_index,
ost->sync_ist->st->index);
if(ost->encoding_needed)
fprintf(stderr, ": %s -> %s",
input_streams[ost->source_index].dec ?
input_streams[ost->source_index].dec->name : "?",
ost->enc ? ost->enc->name : "?");
else
fprintf(stderr, ": copy");
fprintf(stderr, "\n");
}
}
if (ret) {
fprintf(stderr, "%s\n", error);
goto fail;
}
if (want_sdp) {
print_sdp(output_files, nb_output_files);
}
if (!using_stdin) {
if(verbose >= 0)
fprintf(stderr, "Press [q] to stop, [?] for help\n");
avio_set_interrupt_cb(decode_interrupt_cb);
}
term_init();
timer_start = av_gettime();
for(; received_sigterm == 0;) {
int file_index, ist_index;
AVPacket pkt;
int64_t ipts_min;
double opts_min;
redo:
ipts_min= INT64_MAX;
opts_min= 1e100;
if (!using_stdin) {
if (q_pressed)
break;
key = read_key();
if (key == 'q')
break;
if (key == '+') verbose++;
if (key == '-') verbose--;
if (key == 's') qp_hist ^= 1;
if (key == 'h'){
if (do_hex_dump){
do_hex_dump = do_pkt_dump = 0;
} else if(do_pkt_dump){
do_hex_dump = 1;
} else
do_pkt_dump = 1;
av_log_set_level(AV_LOG_DEBUG);
}
if (key == 'c' || key == 'C'){
char ret[4096], target[64], cmd[256], arg[256]={0};
double ts;
fprintf(stderr, "\nEnter command: <target> <time> <command>[ <argument>]\n");
if(scanf("%4095[^\n\r]%*c", ret) == 1 && sscanf(ret, "%63[^ ] %lf %255[^ ] %255[^\n]", target, &ts, cmd, arg) >= 3){
for(i=0;i<nb_output_streams;i++) {
int r;
ost = &output_streams[i];
if(ost->graph){
if(ts<0){
r= avfilter_graph_send_command(ost->graph, target, cmd, arg, ret, sizeof(ret), key == 'c' ? AVFILTER_CMD_FLAG_ONE : 0);
fprintf(stderr, "Command reply for %d: %d, %s\n", i, r, ret);
}else{
r= avfilter_graph_queue_command(ost->graph, target, cmd, arg, 0, ts);
}
}
}
}else{
fprintf(stderr, "Parse error\n");
}
}
if (key == 'd' || key == 'D'){
int debug=0;
if(key == 'D') {
debug = input_streams[0].st->codec->debug<<1;
if(!debug) debug = 1;
while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE))
debug += debug;
}else
scanf("%d", &debug);
for(i=0;i<nb_input_streams;i++) {
input_streams[i].st->codec->debug = debug;
}
for(i=0;i<nb_output_streams;i++) {
ost = &output_streams[i];
ost->st->codec->debug = debug;
}
if(debug) av_log_set_level(AV_LOG_DEBUG);
fprintf(stderr,"debug=%d\n", debug);
}
if (key == '?'){
fprintf(stderr, "key function\n"
"? show this help\n"
"+ increase verbosity\n"
"- decrease verbosity\n"
"c Send command to filtergraph\n"
"D cycle through available debug modes\n"
"h dump packets/hex press to cycle through the 3 states\n"
"q quit\n"
"s Show QP histogram\n"
);
}
}
file_index = -1;
for (i = 0; i < nb_output_streams; i++) {
OutputFile *of;
int64_t ipts;
double opts;
ost = &output_streams[i];
of = &output_files[ost->file_index];
os = output_files[ost->file_index].ctx;
ist = &input_streams[ost->source_index];
if (ost->is_past_recording_time || no_packet[ist->file_index] ||
(os->pb && avio_tell(os->pb) >= of->limit_filesize))
continue;
opts = ost->st->pts.val * av_q2d(ost->st->time_base);
ipts = ist->pts;
if (!input_files[ist->file_index].eof_reached){
if(ipts < ipts_min) {
ipts_min = ipts;
if(input_sync ) file_index = ist->file_index;
}
if(opts < opts_min) {
opts_min = opts;
if(!input_sync) file_index = ist->file_index;
}
}
if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){
file_index= -1;
break;
}
}
if (file_index < 0) {
if(no_packet_count){
no_packet_count=0;
memset(no_packet, 0, nb_input_files);
usleep(10000);
continue;
}
break;
}
is = input_files[file_index].ctx;
ret= av_read_frame(is, &pkt);
if(ret == AVERROR(EAGAIN)){
no_packet[file_index]=1;
no_packet_count++;
continue;
}
if (ret < 0) {
input_files[file_index].eof_reached = 1;
if (opt_shortest)
break;
else
continue;
}
no_packet_count=0;
memset(no_packet, 0, nb_input_files);
if (do_pkt_dump) {
av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,
is->streams[pkt.stream_index]);
}
if (pkt.stream_index >= input_files[file_index].nb_streams)
goto discard_packet;
ist_index = input_files[file_index].ist_index + pkt.stream_index;
ist = &input_streams[ist_index];
if (ist->discard)
goto discard_packet;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (ist->ts_scale) {
if(pkt.pts != AV_NOPTS_VALUE)
pkt.pts *= ist->ts_scale;
if(pkt.dts != AV_NOPTS_VALUE)
pkt.dts *= ist->ts_scale;
}
if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE
&& (is->iformat->flags & AVFMT_TS_DISCONT)) {
int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);
int64_t delta= pkt_dts - ist->next_pts;
if((delta < -1LL*dts_delta_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_delta_threshold*AV_TIME_BASE &&
ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) ||
pkt_dts+1<ist->pts)&& !copy_ts){
input_files[ist->file_index].ts_offset -= delta;
if (verbose > 2)
fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n",
delta, input_files[ist->file_index].ts_offset);
pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
if(pkt.pts != AV_NOPTS_VALUE)
pkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
}
}
if (output_packet(ist, ist_index, output_streams, nb_output_streams, &pkt) < 0) {
if (verbose >= 0)
fprintf(stderr, "Error while decoding stream #%d.%d\n",
ist->file_index, ist->st->index);
if (exit_on_error)
exit_program(1);
av_free_packet(&pkt);
goto redo;
}
discard_packet:
av_free_packet(&pkt);
print_report(output_files, output_streams, nb_output_streams, 0, timer_start);
}
for (i = 0; i < nb_input_streams; i++) {
ist = &input_streams[i];
if (ist->decoding_needed) {
output_packet(ist, i, output_streams, nb_output_streams, NULL);
}
}
flush_encoders(output_streams, nb_output_streams);
term_exit();
for(i=0;i<nb_output_files;i++) {
os = output_files[i].ctx;
av_write_trailer(os);
}
print_report(output_files, output_streams, nb_output_streams, 1, timer_start);
for (i = 0; i < nb_output_streams; i++) {
ost = &output_streams[i];
if (ost->encoding_needed) {
av_freep(&ost->st->codec->stats_in);
avcodec_close(ost->st->codec);
}
#if CONFIG_AVFILTER
avfilter_graph_free(&ost->graph);
#endif
}
for (i = 0; i < nb_input_streams; i++) {
ist = &input_streams[i];
if (ist->decoding_needed) {
avcodec_close(ist->st->codec);
}
}
ret = 0;
fail:
av_freep(&bit_buffer);
av_freep(&no_packet);
if (output_streams) {
for (i = 0; i < nb_output_streams; i++) {
ost = &output_streams[i];
if (ost) {
if (ost->st->stream_copy)
av_freep(&ost->st->codec->extradata);
if (ost->logfile) {
fclose(ost->logfile);
ost->logfile = NULL;
}
av_fifo_free(ost->fifo);
av_freep(&ost->st->codec->subtitle_header);
av_free(ost->resample_frame.data[0]);
av_free(ost->forced_kf_pts);
if (ost->video_resample)
sws_freeContext(ost->img_resample_ctx);
if (ost->resample)
audio_resample_close(ost->resample);
if (ost->reformat_ctx)
av_audio_convert_free(ost->reformat_ctx);
av_dict_free(&ost->opts);
}
}
}
return ret;
}
| 1threat
|
Benefits of Azure PluralSight : <p>I am a beginner in the IT world.
I would like to know what are the advantages of doing the Microsoft Azure PluralSight courses? What kind of It jobs could I Apply having this certificate?</p>
| 0debug
|
Is it correct to return null shared_ptr? : <p>For example, there is a function that finds an object and returns shared_ptr if object is found, and must indicate somehow that no object was found.</p>
<pre><code>std::vector<std::shared_ptr> Storage::objects;
std::shared_ptr<Object> Storage::findObject()
{
if (objects.find)
{
return objects[x];
}
else
{
return nullptr;
}
}
std::shared_ptr<Object> obj = Storage::findObject();
if (obj)
{
print("found");
}
else
{
print("not found");
}
</code></pre>
<ol>
<li><p>Is it correct to return shared_ptr implicitly initialized with nullptr like in upper example? It will work, but can be it done this way? Or should I return shared_ptr default constructed instead?</p></li>
<li><p>What in case it would be weak_ptr? What is proper way to check that empty weak_ptr has been returned? by weak_ptr::expired function or are there other ways? If checking by weak_ptr::expired is the only way then how can I distinguish that function returned empty pointer, or object was just deleted(multi-thread environment)?</p></li>
</ol>
| 0debug
|
How to pass a very long integer to a function in vbscript : I have a number which is very long and need to use it as a parameter in a sql statement to be executed. I am trying to convert that 'testSessionID' string to double or Long, the function returns Err.description. but when i use testSessionID = "2784863" it works fine. Can someone help asap. here is my code:
testSessionID = "1030000000000000005"
Dim TSID
TSID = CDbl (testSessionID)
Dim script_testSessionStatus, testSessionStatus
'Getting the TestSession Status of TestSessionID
script_testSessionStatus = ("exec GetTestSession @TestSessionID ='" & TSID & "'")
testSessionStatus = ExecuteSQLStatement_String(script_testSessionStatus, "Value")
Public Function ExecuteSQLStatement_String(Sql_Statement, colname)
Err.Clear
On Error Resume Next
objRecordSet.open Sql_Statement,objconnection,1
If Err.Number <> 0 Then
ExecuteSQLStatement_String = Err.description
objRecordSet.Close
Err.Clear
Else
ExecuteSQLStatement_String = objRecordSet.Fields(colname).Value
objRecordSet.Close
End If
On Error GoTo 0
End Function
| 0debug
|
I need this to sort in order from highest to low based of the rating : games = []
def gamef():
print("Here you will type your favorite games and then rate then out of 10 and this will sort them for you. ")
while True:
name = input("Enter your game for the games list: ")
rating = [int(i) for i in input("Enter your rating for the game: ")]
games.append({
"Game Title": name,
"Game Rating": rating
})
cont = input("Want to add another? (Y/N)")
if cont == "N":
break;
if cont == "n":
break;
gamef()
print("Here's your games list: ")
print(games)
games.sort()
print("Here's your list of games in order by rating.")
print(games)
| 0debug
|
av_cold void ff_rv34dsp_init(RV34DSPContext *c, DSPContext* dsp) {
c->rv34_inv_transform = rv34_inv_transform_noround_c;
c->rv34_inv_transform_dc = rv34_inv_transform_dc_noround_c;
c->rv34_idct_add = rv34_idct_add_c;
c->rv34_idct_dc_add = rv34_idct_dc_add_c;
if (HAVE_NEON)
ff_rv34dsp_init_neon(c, dsp);
if (ARCH_X86)
ff_rv34dsp_init_x86(c, dsp);
}
| 1threat
|
use data from excel file in another,python script : I want to write a python script that takes data from one excel file and uses this data and inputs it in another excel file to get the output. For eg, if i have input.csv, it takes the data from there, and replaces certain cells of output.csv and gets the value based of the calculation
| 0debug
|
Format template string to remove whitespace but support indentation : <p>Say I have the following template string:</p>
<pre><code>const str1 = `
const x = 5;
`
</code></pre>
<p>If I were to render it in the DOM it would take into consideration the whitespace before the string begins and render it with the whitespace. I could solve this using <code>str1.trim()</code>, but, lets say we have another string:</p>
<pre><code>const str2 = `
const x = 1;
const y = 2;
const z = 3;
`
</code></pre>
<p>I would like to remove the whitespace before each string row but preserve the indentation. An expected result would look something like:</p>
<pre><code>const x = 1;
const y = 2;
const z = 3;
</code></pre>
<p>Is there a way I could achieve this with either regex or js ?</p>
| 0debug
|
Need help converting if / else to JS / Jquery : What I need is to first change the php array to js array:
$url = "web.com";
<script type="text/javascript">
var url = <?php echo json_encode($url); ?>;
</script>
Now with JS / Jquery I need to do this action:
if(strpos($url, "com") !== false){
echo "<p><b style="background-color:blue; color:white;">TEST</b></p>";}
else{
echo "<p><b style="background-color:yellow; color:white;">TEST</b></p>";}
How can I do this?
| 0debug
|
gcc: error trying to exec 'cc1plus': execvp: No such file or directory : <p>I'm trying to install this python module, which requires compilation (on Ubuntu 16.04). I'm struggling to understand exactly what's causing it stall; what am I missing?</p>
<pre><code>(xenial)chris@localhost:~$ pip install swigibpy
Collecting swigibpy
Using cached swigibpy-0.4.1.tar.gz
Building wheels for collected packages: swigibpy
Running setup.py bdist_wheel for swigibpy ... error
Complete output from command /home/chris/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-162vhh_i/swigibpy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmptqb6ctskpip-wheel- --python-tag cp35:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.5
copying swigibpy.py -> build/lib.linux-x86_64-3.5
running build_ext
building '_swigibpy' extension
creating build/temp.linux-x86_64-3.5
creating build/temp.linux-x86_64-3.5/IB
creating build/temp.linux-x86_64-3.5/IB/PosixSocketClient
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DIB_USE_STD_STRING=1 -IIB -IIB/PosixSocketClient -IIB/Shared -I/home/chris/anaconda3/include/python3.5m -c IB/PosixSocketClient/EClientSocketBase.cpp -o build/temp.linux-x86_64-3.5/IB/PosixSocketClient/EClientSocketBase.o -Wno-switch
gcc: error trying to exec 'cc1plus': execvp: No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
Failed building wheel for swigibpy
Running setup.py clean for swigibpy
Failed to build swigibpy
Installing collected packages: swigibpy
Running setup.py install for swigibpy ... error
Complete output from command /home/chris/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-162vhh_i/swigibpy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-yv9u0wok-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.5
copying swigibpy.py -> build/lib.linux-x86_64-3.5
running build_ext
building '_swigibpy' extension
creating build/temp.linux-x86_64-3.5
creating build/temp.linux-x86_64-3.5/IB
creating build/temp.linux-x86_64-3.5/IB/PosixSocketClient
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DIB_USE_STD_STRING=1 -IIB -IIB/PosixSocketClient -IIB/Shared -I/home/chris/anaconda3/include/python3.5m -c IB/PosixSocketClient/EClientSocketBase.cpp -o build/temp.linux-x86_64-3.5/IB/PosixSocketClient/EClientSocketBase.o -Wno-switch
gcc: error trying to exec 'cc1plus': execvp: No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/home/chris/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-162vhh_i/swigibpy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-yv9u0wok-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-162vhh_i/swigibpy/
</code></pre>
| 0debug
|
static int dmg_read_resource_fork(BlockDriverState *bs, DmgHeaderState *ds,
uint64_t info_begin, uint64_t info_length)
{
BDRVDMGState *s = bs->opaque;
int ret;
uint32_t count, rsrc_data_offset;
uint8_t *buffer = NULL;
uint64_t info_end;
uint64_t offset;
ret = read_uint32(bs, info_begin, &rsrc_data_offset);
if (ret < 0) {
goto fail;
} else if (rsrc_data_offset > info_length) {
ret = -EINVAL;
goto fail;
}
ret = read_uint32(bs, info_begin + 8, &count);
if (ret < 0) {
goto fail;
} else if (count == 0 || rsrc_data_offset + count > info_length) {
ret = -EINVAL;
goto fail;
}
offset = info_begin + rsrc_data_offset;
info_end = offset + count;
while (offset < info_end) {
ret = read_uint32(bs, offset, &count);
if (ret < 0) {
goto fail;
} else if (count == 0) {
ret = -EINVAL;
goto fail;
}
offset += 4;
buffer = g_realloc(buffer, count);
ret = bdrv_pread(bs->file, offset, buffer, count);
if (ret < 0) {
goto fail;
}
ret = dmg_read_mish_block(s, ds, buffer, count);
if (ret < 0) {
goto fail;
}
offset += count;
}
ret = 0;
fail:
g_free(buffer);
return ret;
}
| 1threat
|
MySQL Workbench not saving passwords in keychain : <p>Using Kubuntu 16.10, I'm saving a password into the keyring in MySQL Workbench, checking the <em>"Store password in keychain"</em> checkbox.</p>
<p>It works as long as it's open (doesn't ask for password), but when I re-open the program it prompts for the password again.</p>
<p>Not many people seem to have this problem. It might have something to do with my OS, but I'm not sure.</p>
| 0debug
|
static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
{
ASFContext *asf = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *st;
ASFStream *asf_st;
ff_asf_guid g;
enum AVMediaType type;
int type_specific_size, sizeX;
uint64_t total_size;
unsigned int tag1;
int64_t pos1, pos2, start_time;
int test_for_ext_stream_audio, is_dvr_ms_audio=0;
if (s->nb_streams == ASF_MAX_STREAMS) {
av_log(s, AV_LOG_ERROR, "too many streams\n");
return AVERROR(EINVAL);
}
pos1 = avio_tell(pb);
st = av_new_stream(s, 0);
if (!st)
return AVERROR(ENOMEM);
av_set_pts_info(st, 32, 1, 1000);
asf_st = av_mallocz(sizeof(ASFStream));
if (!asf_st)
return AVERROR(ENOMEM);
st->priv_data = asf_st;
st->start_time = 0;
start_time = asf->hdr.preroll;
asf_st->stream_language_index = 128;
if(!(asf->hdr.flags & 0x01)) {
st->duration = asf->hdr.play_time /
(10000000 / 1000) - start_time;
}
ff_get_guid(pb, &g);
test_for_ext_stream_audio = 0;
if (!ff_guidcmp(&g, &ff_asf_audio_stream)) {
type = AVMEDIA_TYPE_AUDIO;
} else if (!ff_guidcmp(&g, &ff_asf_video_stream)) {
type = AVMEDIA_TYPE_VIDEO;
} else if (!ff_guidcmp(&g, &ff_asf_jfif_media)) {
type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_MJPEG;
} else if (!ff_guidcmp(&g, &ff_asf_command_stream)) {
type = AVMEDIA_TYPE_DATA;
} else if (!ff_guidcmp(&g, &ff_asf_ext_stream_embed_stream_header)) {
test_for_ext_stream_audio = 1;
type = AVMEDIA_TYPE_UNKNOWN;
} else {
return -1;
}
ff_get_guid(pb, &g);
total_size = avio_rl64(pb);
type_specific_size = avio_rl32(pb);
avio_rl32(pb);
st->id = avio_rl16(pb) & 0x7f;
asf->asfid2avid[st->id] = s->nb_streams - 1;
avio_rl32(pb);
if (test_for_ext_stream_audio) {
ff_get_guid(pb, &g);
if (!ff_guidcmp(&g, &ff_asf_ext_stream_audio_stream)) {
type = AVMEDIA_TYPE_AUDIO;
is_dvr_ms_audio=1;
ff_get_guid(pb, &g);
avio_rl32(pb);
avio_rl32(pb);
avio_rl32(pb);
ff_get_guid(pb, &g);
avio_rl32(pb);
}
}
st->codec->codec_type = type;
if (type == AVMEDIA_TYPE_AUDIO) {
ff_get_wav_header(pb, st->codec, type_specific_size);
if (is_dvr_ms_audio) {
st->codec->codec_id = CODEC_ID_PROBE;
st->codec->codec_tag = 0;
}
if (st->codec->codec_id == CODEC_ID_AAC) {
st->need_parsing = AVSTREAM_PARSE_NONE;
} else {
st->need_parsing = AVSTREAM_PARSE_FULL;
}
pos2 = avio_tell(pb);
if (size >= (pos2 + 8 - pos1 + 24)) {
asf_st->ds_span = avio_r8(pb);
asf_st->ds_packet_size = avio_rl16(pb);
asf_st->ds_chunk_size = avio_rl16(pb);
avio_rl16(pb);
avio_r8(pb);
}
if (asf_st->ds_span > 1) {
if (!asf_st->ds_chunk_size
|| (asf_st->ds_packet_size/asf_st->ds_chunk_size <= 1)
|| asf_st->ds_packet_size % asf_st->ds_chunk_size)
asf_st->ds_span = 0;
}
switch (st->codec->codec_id) {
case CODEC_ID_MP3:
st->codec->frame_size = MPA_FRAME_SIZE;
break;
case CODEC_ID_PCM_S16LE:
case CODEC_ID_PCM_S16BE:
case CODEC_ID_PCM_U16LE:
case CODEC_ID_PCM_U16BE:
case CODEC_ID_PCM_S8:
case CODEC_ID_PCM_U8:
case CODEC_ID_PCM_ALAW:
case CODEC_ID_PCM_MULAW:
st->codec->frame_size = 1;
break;
default:
st->codec->frame_size = 1;
break;
}
} else if (type == AVMEDIA_TYPE_VIDEO &&
size - (avio_tell(pb) - pos1 + 24) >= 51) {
avio_rl32(pb);
avio_rl32(pb);
avio_r8(pb);
avio_rl16(pb);
sizeX= avio_rl32(pb);
st->codec->width = avio_rl32(pb);
st->codec->height = avio_rl32(pb);
avio_rl16(pb);
st->codec->bits_per_coded_sample = avio_rl16(pb);
tag1 = avio_rl32(pb);
avio_skip(pb, 20);
if (sizeX > 40) {
st->codec->extradata_size = sizeX - 40;
st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
avio_read(pb, st->codec->extradata, st->codec->extradata_size);
}
if (st->codec->extradata_size && (st->codec->bits_per_coded_sample <= 8)) {
int av_unused i;
st->codec->palctrl = av_mallocz(sizeof(AVPaletteControl));
#if HAVE_BIGENDIAN
for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)/4; i++)
st->codec->palctrl->palette[i] = av_bswap32(((uint32_t*)st->codec->extradata)[i]);
#else
memcpy(st->codec->palctrl->palette, st->codec->extradata,
FFMIN(st->codec->extradata_size, AVPALETTE_SIZE));
#endif
st->codec->palctrl->palette_changed = 1;
}
st->codec->codec_tag = tag1;
st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag1);
if(tag1 == MKTAG('D', 'V', 'R', ' ')){
st->need_parsing = AVSTREAM_PARSE_FULL;
st->codec->width =
st->codec->height = 0;
av_freep(&st->codec->extradata);
st->codec->extradata_size=0;
}
if(st->codec->codec_id == CODEC_ID_H264)
st->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
}
pos2 = avio_tell(pb);
avio_skip(pb, size - (pos2 - pos1 + 24));
return 0;
}
| 1threat
|
static void vhost_scsi_unrealize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VHostSCSI *s = VHOST_SCSI(dev);
migrate_del_blocker(s->migration_blocker);
error_free(s->migration_blocker);
vhost_scsi_set_status(vdev, 0);
g_free(s->dev.vqs);
virtio_scsi_common_unrealize(dev, errp);
}
| 1threat
|
Using python together with knitr : <p>I would like to use python together with knitr. However, python chunks seem to get evaluated separately, and variable definitions are lost between chunks.</p>
<p>How to solve this? </p>
<p>Minimal example:</p>
<h3>test.pymd</h3>
<pre><code>---
title: "Minimal example"
---
With a print statement.
```{r hello}
x = 'Hello, Python World!'
print(x)
```
Without a print statement.
```{r world}
print(x)
```
</code></pre>
<h3>test.md</h3>
<pre><code>---
title: "Minimal example"
---
With a print statement.
```python
x = 'Hello, Python World!'
print(x)
```
```
Hello, Python World!
```
Without a print statement.
```python
print(x)
```
```
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'x' is not defined
```
</code></pre>
<h3>knit2py.r</h3>
<pre><code>#! /usr/bin/Rscript --vanilla
args <- commandArgs(TRUE)
if(length(args) < 1) {
message("Need arguments in the format: %.pymd [%.md]")
q(status=1)
}
name <- substr(args[1],1,nchar(args[1])-4)
if(length(args) < 2) {
args[2] <- paste0(name,".md")
}
library(knitr)
opts_chunk$set(engine = 'python')
res <- try(knit(args[1], args[2]))
if(inherits(res, "try-error")) {
message("Could not successfully knit RMD (or PYMD) to MD")
q(status=1)
} else q()
</code></pre>
<p>And now run:</p>
<pre><code>./knit2py.r test.pymd test.md
</code></pre>
| 0debug
|
I am very Beginner to android studio, unable to solve these errors even after i reinstall can some please : So here is screen shot of my android studio and you can see those errors at bottom messages and the render errors. Please hem to fix this.[enter image description here][1]
[1]: https://i.stack.imgur.com/Rxpzd.png
| 0debug
|
static av_always_inline void decode_dc_coeffs(GetBitContext *gb, DCTELEM *out,
int blocks_per_slice)
{
DCTELEM prev_dc;
int code, i, sign;
OPEN_READER(re, gb);
DECODE_CODEWORD(code, FIRST_DC_CB);
prev_dc = TOSIGNED(code);
out[0] = prev_dc;
out += 64;
code = 5;
sign = 0;
for (i = 1; i < blocks_per_slice; i++, out += 64) {
DECODE_CODEWORD(code, dc_codebook[FFMIN(code, 6)]);
if(code) sign ^= -(code & 1);
else sign = 0;
prev_dc += (((code + 1) >> 1) ^ sign) - sign;
out[0] = prev_dc;
}
CLOSE_READER(re, gb);
}
| 1threat
|
void qemu_cond_init(QemuCond *cond)
{
memset(cond, 0, sizeof(*cond));
cond->sema = CreateSemaphore(NULL, 0, LONG_MAX, NULL);
if (!cond->sema) {
error_exit(GetLastError(), __func__);
}
cond->continue_event = CreateEvent(NULL,
FALSE,
FALSE,
NULL);
if (!cond->continue_event) {
error_exit(GetLastError(), __func__);
}
}
| 1threat
|
How can I make this code better? (C++ temperature converter) : <p>I wrote this temperature conversion program while practicing classes and functions in C++. While the code works, I am not entirely satisfied with it.
Is there any way to make this code more efficient? Are there any
persistent mistakes in my code?
I would love it if you would critique my code. Thanks.</p>
<pre><code> #include<iostream>
#include<string>
class convert{
public:
int c_con(float y){
float f;
std::cout << "Converting to Fahrenheit: ";
f=y*9/5+32;
std::cout << f << std::endl;
return 0;
}
int f_con(float x){
float c;
std::cout << "Converting to Celsius:";
c=(x-32)*5/9;
std::cout << c << std::endl;
return 0;
}
};
int main(){
char a;
int b;
convert temp;
std::cout << "__________Temp Converter-----------" << std::endl;
std::cout << "What would like to convert? (c/f): ";
std::cin >> a;
switch(a)
{
case 'c' : std::cout << "Input Celsius: ";
std::cin >> b;
temp.c_con(b);
break;
case 'f' :std::cout << "Input Fahrenheit: ";
std::cin >> b;
temp.f_con(b);
break;
default: std::cout << "Wrong input.";
}
return 0;
}
</code></pre>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.