problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
multiple text colors in fabricJS : <p>Is there any way of adding more than one text color to a single Text or iText element in FabricJS? I am trying to use it to create a poster and the text needs different colors in the same paragraph.</p>
| 0debug
|
def get_item(tup1,index):
item = tup1[index]
return item
| 0debug
|
static int mov_read_wave(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
{
AVStream *st = c->fc->streams[c->fc->nb_streams-1];
if((uint64_t)atom.size > (1<<30))
return -1;
if (st->codec->codec_id == CODEC_ID_QDM2) {
av_free(st->codec->extradata);
st->codec->extradata_size = atom.size;
st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (st->codec->extradata) {
get_buffer(pb, st->codec->extradata, atom.size);
} else
url_fskip(pb, atom.size);
} else if (atom.size > 8) {
mov_read_default(c, pb, atom);
} else
url_fskip(pb, atom.size);
return 0;
}
| 1threat
|
What is the most efficient way to calculate PI in C? : <p>I'm have to write a C program, what it does is takes a integer as input. And gives output to the input(th) number of PI after decimal. Like if input is 100, output will be 9(100th digit of pi, after decimal is 9).
What will be the best algorithm for that?</p>
<p>p.s I don't want to save the value of pi into the string, and do it.</p>
| 0debug
|
def sum_div(number):
divisors = [1]
for i in range(2, number):
if (number % i)==0:
divisors.append(i)
return sum(divisors)
| 0debug
|
static void RENAME(sws_init_swScale)(SwsContext *c)
{
enum PixelFormat srcFormat = c->srcFormat;
if (!(c->flags & SWS_BITEXACT)) {
if (c->flags & SWS_ACCURATE_RND) {
c->yuv2yuv1 = RENAME(yuv2yuv1_ar );
c->yuv2yuvX = RENAME(yuv2yuvX_ar );
switch (c->dstFormat) {
case PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X_ar); break;
case PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X_ar); break;
case PIX_FMT_RGB555: c->yuv2packedX = RENAME(yuv2rgb555_X_ar); break;
case PIX_FMT_RGB565: c->yuv2packedX = RENAME(yuv2rgb565_X_ar); break;
case PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X_ar); break;
default: break;
}
} else {
c->yuv2yuv1 = RENAME(yuv2yuv1 );
c->yuv2yuvX = RENAME(yuv2yuvX );
switch (c->dstFormat) {
case PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X); break;
case PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X); break;
case PIX_FMT_RGB555: c->yuv2packedX = RENAME(yuv2rgb555_X); break;
case PIX_FMT_RGB565: c->yuv2packedX = RENAME(yuv2rgb565_X); break;
case PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X); break;
default: break;
}
}
switch (c->dstFormat) {
case PIX_FMT_RGB32:
c->yuv2packed1 = RENAME(yuv2rgb32_1);
c->yuv2packed2 = RENAME(yuv2rgb32_2);
break;
case PIX_FMT_BGR24:
c->yuv2packed1 = RENAME(yuv2bgr24_1);
c->yuv2packed2 = RENAME(yuv2bgr24_2);
break;
case PIX_FMT_RGB555:
c->yuv2packed1 = RENAME(yuv2rgb555_1);
c->yuv2packed2 = RENAME(yuv2rgb555_2);
break;
case PIX_FMT_RGB565:
c->yuv2packed1 = RENAME(yuv2rgb565_1);
c->yuv2packed2 = RENAME(yuv2rgb565_2);
break;
case PIX_FMT_YUYV422:
c->yuv2packed1 = RENAME(yuv2yuyv422_1);
c->yuv2packed2 = RENAME(yuv2yuyv422_2);
break;
default:
break;
}
}
#if !COMPILE_TEMPLATE_MMX2
c->hScale = RENAME(hScale );
#endif
#if COMPILE_TEMPLATE_MMX2
if (c->flags & SWS_FAST_BILINEAR && c->canMMX2BeUsed)
{
c->hyscale_fast = RENAME(hyscale_fast);
c->hcscale_fast = RENAME(hcscale_fast);
} else {
#endif
c->hyscale_fast = NULL;
c->hcscale_fast = NULL;
#if COMPILE_TEMPLATE_MMX2
}
#endif
#if !COMPILE_TEMPLATE_MMX2
switch(srcFormat) {
case PIX_FMT_YUYV422 : c->chrToYV12 = RENAME(yuy2ToUV); break;
case PIX_FMT_UYVY422 : c->chrToYV12 = RENAME(uyvyToUV); break;
case PIX_FMT_NV12 : c->chrToYV12 = RENAME(nv12ToUV); break;
case PIX_FMT_NV21 : c->chrToYV12 = RENAME(nv21ToUV); break;
case PIX_FMT_GRAY16LE :
case PIX_FMT_YUV420P9LE:
case PIX_FMT_YUV422P10LE:
case PIX_FMT_YUV420P10LE:
case PIX_FMT_YUV420P16LE:
case PIX_FMT_YUV422P16LE:
case PIX_FMT_YUV444P16LE: c->hScale16= RENAME(hScale16); break;
}
#endif
if (!c->chrSrcHSubSample) {
switch(srcFormat) {
case PIX_FMT_BGR24 : c->chrToYV12 = RENAME(bgr24ToUV); break;
case PIX_FMT_RGB24 : c->chrToYV12 = RENAME(rgb24ToUV); break;
default: break;
}
}
switch (srcFormat) {
#if !COMPILE_TEMPLATE_MMX2
case PIX_FMT_YUYV422 :
case PIX_FMT_Y400A :
c->lumToYV12 = RENAME(yuy2ToY); break;
case PIX_FMT_UYVY422 :
c->lumToYV12 = RENAME(uyvyToY); break;
#endif
case PIX_FMT_BGR24 : c->lumToYV12 = RENAME(bgr24ToY); break;
case PIX_FMT_RGB24 : c->lumToYV12 = RENAME(rgb24ToY); break;
default: break;
}
#if !COMPILE_TEMPLATE_MMX2
if (c->alpPixBuf) {
switch (srcFormat) {
case PIX_FMT_Y400A : c->alpToYV12 = RENAME(yuy2ToY); break;
default: break;
}
}
#endif
if(isAnyRGB(c->srcFormat))
c->hScale16= RENAME(hScale16);
}
| 1threat
|
How to rename values in a column of data which appear less than x time in R? : I want to rename some values in a column of my data which appears less than 5 time. I know how to delete them but I need to rename them.
| 0debug
|
How to uppse fraction with Android? : Hello I have a really simple qestion, in my app I have an EditText and what I would like for instance is this :
if I write 1/2 I would like 0.5 in the field...
How can I do this ?
Thank you very much !
| 0debug
|
Problems with iterators : <pre><code>void Reverse(vector<int> v)
{
vector<int>::iterator itr1 = v.begin();
vector<int>::reverse_iterator itr2 = v.rbegin();
while(true)
{
swap(*itr1,*itr2);
itr1++;
if(itr1 == itr2.base() - 1) break;
itr2++;
}
}
</code></pre>
<p>Function should reverse the vector, but it is not working.
Can anyone explain why?</p>
| 0debug
|
vmxnet3_indicate_packet(VMXNET3State *s)
{
struct Vmxnet3_RxDesc rxd;
bool is_head = true;
uint32_t rxd_idx;
uint32_t rx_ridx;
struct Vmxnet3_RxCompDesc rxcd;
uint32_t new_rxcd_gen = VMXNET3_INIT_GEN;
hwaddr new_rxcd_pa = 0;
hwaddr ready_rxcd_pa = 0;
struct iovec *data = vmxnet_rx_pkt_get_iovec(s->rx_pkt);
size_t bytes_copied = 0;
size_t bytes_left = vmxnet_rx_pkt_get_total_len(s->rx_pkt);
uint16_t num_frags = 0;
size_t chunk_size;
vmxnet_rx_pkt_dump(s->rx_pkt);
while (bytes_left > 0) {
if (num_frags == s->max_rx_frags) {
break;
}
new_rxcd_pa = vmxnet3_pop_rxc_descr(s, RXQ_IDX, &new_rxcd_gen);
if (!new_rxcd_pa) {
break;
}
if (!vmxnet3_get_next_rx_descr(s, is_head, &rxd, &rxd_idx, &rx_ridx)) {
break;
}
chunk_size = MIN(bytes_left, rxd.len);
vmxnet3_physical_memory_writev(data, bytes_copied,
le64_to_cpu(rxd.addr), chunk_size);
bytes_copied += chunk_size;
bytes_left -= chunk_size;
vmxnet3_dump_rx_descr(&rxd);
if (0 != ready_rxcd_pa) {
cpu_physical_memory_write(ready_rxcd_pa, &rxcd, sizeof(rxcd));
}
memset(&rxcd, 0, sizeof(struct Vmxnet3_RxCompDesc));
rxcd.rxdIdx = rxd_idx;
rxcd.len = chunk_size;
rxcd.sop = is_head;
rxcd.gen = new_rxcd_gen;
rxcd.rqID = RXQ_IDX + rx_ridx * s->rxq_num;
if (0 == bytes_left) {
vmxnet3_rx_update_descr(s->rx_pkt, &rxcd);
}
VMW_RIPRN("RX Completion descriptor: rxRing: %lu rxIdx %lu len %lu "
"sop %d csum_correct %lu",
(unsigned long) rx_ridx,
(unsigned long) rxcd.rxdIdx,
(unsigned long) rxcd.len,
(int) rxcd.sop,
(unsigned long) rxcd.tuc);
is_head = false;
ready_rxcd_pa = new_rxcd_pa;
new_rxcd_pa = 0;
}
if (0 != ready_rxcd_pa) {
rxcd.eop = 1;
rxcd.err = (0 != bytes_left);
cpu_physical_memory_write(ready_rxcd_pa, &rxcd, sizeof(rxcd));
smp_wmb();
}
if (0 != new_rxcd_pa) {
vmxnet3_revert_rxc_descr(s, RXQ_IDX);
}
vmxnet3_trigger_interrupt(s, s->rxq_descr[RXQ_IDX].intr_idx);
if (bytes_left == 0) {
vmxnet3_on_rx_done_update_stats(s, RXQ_IDX, VMXNET3_PKT_STATUS_OK);
return true;
} else if (num_frags == s->max_rx_frags) {
vmxnet3_on_rx_done_update_stats(s, RXQ_IDX, VMXNET3_PKT_STATUS_ERROR);
return false;
} else {
vmxnet3_on_rx_done_update_stats(s, RXQ_IDX,
VMXNET3_PKT_STATUS_OUT_OF_BUF);
return false;
}
}
| 1threat
|
c# recursion method for arraylist : Good evening guys, I got a little bit stuck in recursive sum calculation. I have a container class of Students and all students are in object class Student(student has his name ,last name ... and his grades).I am saving student's grades in arraylist and I want a recursive method in container class wich could calculate those grades inside the ArrayList.I know how to do it in iterative way , but not sure about recursive version of it.
**Student class**
class Student
{
public ArrayList grades = new ArrayList();
public Student(ArrayList grades)
{
this.grades = grades;
}
}
**Students class(Container)**
class Students
{
private Student[] studentOb{ get; set; }
public int containerNumber{ get; private set; }
}
public Students(int size)
{
studentOb = new Student[size];
}
public void AddElement(Student info)
{
studentOb[containerNumber++] = info;
}
public Student TakeElement(int index)
{
return studentOb[index];
}
//this is where I am trying to build that Sum method, and yeah my code is just nonsense
public int Sum(ArrayList collection)
{
int ret = collection.Count;
foreach (ArrayList newList in collection)
{
ret += Sum(newList)
}
}
| 0debug
|
How to support ES7 in ESLint : <p>I have a project setup with WebPack to use ESLint and I'm wanting to use ES7 for the inline bind operator <code>::</code>. Currently I'm getting the parse errors shown below</p>
<pre><code>/Users/ryanvice/Documents/Code/pluralsight-redux-starter/src/components/project/ProjectsPage.js (1/0)
✖ 7:27 Parsing error: Unexpected token :
/Users/ryanvice/Documents/Code/pluralsight-redux-starter/src/routes.js (2/2)
✖ 6:26 Parse errors in imported module './components/project/ProjectsPage': Unexpected token : (7:27) import/namespace
✖ 6:26 Parse errors in imported module './components/project/ProjectsPage': Unexpected token : (7:27) import/default
! 6:26 Parse errors in imported module './components/project/ProjectsPage': Unexpected token : (7:27) import/no-named-as-default
! 6:26 Parse errors in imported module './components/project/ProjectsPage': Unexpected token : (7:27) import/no-named-as-default-member
✖ 3 errors ! 2 warnings (4:45:40 PM)
</code></pre>
<p>using the following <code>.eslintrc</code> configuration which include <code>"ecmaVersion": 7</code></p>
<pre><code>{
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings"
],
"plugins": [
"react"
],
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"es6": true,
"browser": true,
"node": true,
"jquery": true,
"mocha": true
},
"rules": {
"quotes": 0,
"no-console": 1,
"no-debugger": 1,
"no-var": 1,
"semi": [1, "always"],
"no-trailing-spaces": 0,
"eol-last": 0,
"no-unused-vars": 0,
"no-underscore-dangle": 0,
"no-alert": 0,
"no-lone-blocks": 0,
"jsx-quotes": 1,
"react/display-name": [ 1, {"ignoreTranspilerName": false }],
"react/forbid-prop-types": [1, {"forbid": ["any"]}],
"react/jsx-boolean-value": 1,
"react/jsx-closing-bracket-location": 0,
"react/jsx-curly-spacing": 1,
"react/jsx-indent-props": 0,
"react/jsx-key": 1,
"react/jsx-max-props-per-line": 0,
"react/jsx-no-bind": 1,
"react/jsx-no-duplicate-props": 1,
"react/jsx-no-literals": 0,
"react/jsx-no-undef": 1,
"react/jsx-pascal-case": 1,
"react/jsx-sort-prop-types": 0,
"react/jsx-sort-props": 0,
"react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1,
"react/no-danger": 1,
"react/no-did-mount-set-state": 1,
"react/no-did-update-set-state": 1,
"react/no-direct-mutation-state": 1,
"react/no-multi-comp": 1,
"react/no-set-state": 0,
"react/no-unknown-property": 1,
"react/prefer-es6-class": 1,
"react/prop-types": 1,
"react/react-in-jsx-scope": 1,
"react/require-extension": 1,
"react/self-closing-comp": 1,
"react/sort-comp": 1,
"react/wrap-multilines": 1
}
}
</code></pre>
| 0debug
|
I have got too many sms from my php json sms api : <p>I have tried PHP JSON request on my web site.
I use that for SMS sending purposes.
But I have got many SMS.</p>
<pre><code><?php
// Your code here!
// Takes raw data from the request
$json = file_get_contents('URL');
// Converts it into a PHP object
$data = json_decode($json,true);
print_r($data);
?>
</code></pre>
<p>Are there any other methods to do that instead of this method?</p>
<p>I want to send SMS with my back end.</p>
| 0debug
|
void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
{
CPUARMState *env = &cpu->env;
int kernel_size;
int initrd_size;
int n;
int is_linux = 0;
uint64_t elf_entry;
target_phys_addr_t entry;
int big_endian;
QemuOpts *machine_opts;
if (!info->kernel_filename) {
fprintf(stderr, "Kernel image must be specified\n");
exit(1);
}
machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
if (machine_opts) {
info->dtb_filename = qemu_opt_get(machine_opts, "dtb");
} else {
info->dtb_filename = NULL;
}
if (!info->secondary_cpu_reset_hook) {
info->secondary_cpu_reset_hook = default_reset_secondary;
}
if (!info->write_secondary_boot) {
info->write_secondary_boot = default_write_secondary;
}
if (info->nb_cpus == 0)
info->nb_cpus = 1;
#ifdef TARGET_WORDS_BIGENDIAN
big_endian = 1;
#else
big_endian = 0;
#endif
kernel_size = load_elf(info->kernel_filename, NULL, NULL, &elf_entry,
NULL, NULL, big_endian, ELF_MACHINE, 1);
entry = elf_entry;
if (kernel_size < 0) {
kernel_size = load_uimage(info->kernel_filename, &entry, NULL,
&is_linux);
}
if (kernel_size < 0) {
entry = info->loader_start + KERNEL_LOAD_ADDR;
kernel_size = load_image_targphys(info->kernel_filename, entry,
info->ram_size - KERNEL_LOAD_ADDR);
is_linux = 1;
}
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
info->kernel_filename);
exit(1);
}
info->entry = entry;
if (is_linux) {
if (info->initrd_filename) {
initrd_size = load_image_targphys(info->initrd_filename,
info->loader_start
+ INITRD_LOAD_ADDR,
info->ram_size
- INITRD_LOAD_ADDR);
if (initrd_size < 0) {
fprintf(stderr, "qemu: could not load initrd '%s'\n",
info->initrd_filename);
exit(1);
}
} else {
initrd_size = 0;
}
info->initrd_size = initrd_size;
bootloader[4] = info->board_id;
if (info->dtb_filename) {
target_phys_addr_t dtb_start = TARGET_PAGE_ALIGN(info->loader_start
+ INITRD_LOAD_ADDR
+ initrd_size);
if (load_dtb(dtb_start, info)) {
exit(1);
}
bootloader[5] = dtb_start;
} else {
bootloader[5] = info->loader_start + KERNEL_ARGS_ADDR;
if (info->ram_size >= (1ULL << 32)) {
fprintf(stderr, "qemu: RAM size must be less than 4GB to boot"
" Linux kernel using ATAGS (try passing a device tree"
" using -dtb)\n");
exit(1);
}
}
bootloader[6] = entry;
for (n = 0; n < sizeof(bootloader) / 4; n++) {
bootloader[n] = tswap32(bootloader[n]);
}
rom_add_blob_fixed("bootloader", bootloader, sizeof(bootloader),
info->loader_start);
if (info->nb_cpus > 1) {
info->write_secondary_boot(cpu, info);
}
}
info->is_linux = is_linux;
for (; env; env = env->next_cpu) {
cpu = arm_env_get_cpu(env);
env->boot_info = info;
qemu_register_reset(do_cpu_reset, cpu);
}
}
| 1threat
|
What is a compute node? : <p>I understand this may be a very juvenile question, but I'm learning about linked lists in C#, and they keep referencing Nodes, which I somewhat understand at an intuitive level, but I've never gotten a formal explanation of what exactly a node is, especially in this context, can someone give me a rundown on the definition of a node in moderately plain english? </p>
<p>I've read this: <a href="https://msdn.microsoft.com/en-us/library/microsoft.computecluster.node(v=vs.85).aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/microsoft.computecluster.node(v=vs.85).aspx</a> but it doesn't help much as it uses other concepts/jargon that I don't quite understand just yet. </p>
<p>Thanks!</p>
| 0debug
|
Creating sub sites using one main site, Like wordpres does : I have a project to do with a client he refused to do it by WordPress
The idea is simple creating one main site which you can enter and purchase a cms for your hospital
My question is how to make the main site creates Sub-sites with a domain once customer purchased ?
Is it possible to be done using raw php?
I dont want the code just suggest me something to read or to look for
| 0debug
|
void add_migration_state_change_notifier(Notifier *notify)
{
notifier_list_add(&migration_state_notifiers, notify);
}
| 1threat
|
How to show a dropdown type of menu on tap of button? : <p>I have made a button on navigation bar and want to show a list kind of view on tap of it. What can I do?</p>
| 0debug
|
What's the difference between public STATIC and public function in php? : <p>I know there are a lot of information according to this, but I couldn't find any really useful and understandable. So what is the difference between <code>public static function</code> and <code>public function</code>? Why sometimes I have to use the word <code>static</code>? </p>
<p>I know that static functions are called by <code>::</code> and non-static by <code>-></code>, but the real difference (why sometimes I should use <code>static</code> I don't get). As I understand now, when I use <code>static</code>, I can call it from another class. Without it - I cannot. But I'm pretty sure that I'm wrong.</p>
<p>I think this information would be really helpful for a lot of ppl. Thanks for your time in trying to explain it.</p>
| 0debug
|
void *qemu_try_blockalign(BlockDriverState *bs, size_t size)
{
size_t align = bdrv_opt_mem_align(bs);
assert(align > 0);
if (size == 0) {
size = align;
}
return qemu_try_memalign(align, size);
}
| 1threat
|
static void smc_decode_stream(SmcContext *s)
{
int width = s->avctx->width;
int height = s->avctx->height;
int stride = s->frame.linesize[0];
int i;
int stream_ptr = 0;
int chunk_size;
unsigned char opcode;
int n_blocks;
unsigned int color_flags;
unsigned int color_flags_a;
unsigned int color_flags_b;
unsigned int flag_mask;
unsigned char *pixels = s->frame.data[0];
int image_size = height * s->frame.linesize[0];
int row_ptr = 0;
int pixel_ptr = 0;
int pixel_x, pixel_y;
int row_inc = stride - 4;
int block_ptr;
int prev_block_ptr;
int prev_block_ptr1, prev_block_ptr2;
int prev_block_flag;
int total_blocks;
int color_table_index;
int pixel;
int color_pair_index = 0;
int color_quad_index = 0;
int color_octet_index = 0;
memcpy(s->frame.data[1], s->pal, AVPALETTE_SIZE);
chunk_size = AV_RB32(&s->buf[stream_ptr]) & 0x00FFFFFF;
stream_ptr += 4;
if (chunk_size != s->size)
av_log(s->avctx, AV_LOG_INFO, "warning: MOV chunk size != encoded chunk size (%d != %d); using MOV chunk size\n",
chunk_size, s->size);
chunk_size = s->size;
total_blocks = ((s->avctx->width + 3) / 4) * ((s->avctx->height + 3) / 4);
while (total_blocks) {
if (stream_ptr > chunk_size) {
av_log(s->avctx, AV_LOG_INFO, "SMC decoder just went out of bounds (stream ptr = %d, chunk size = %d)\n",
stream_ptr, chunk_size);
return;
}
if (row_ptr >= image_size) {
av_log(s->avctx, AV_LOG_INFO, "SMC decoder just went out of bounds (row ptr = %d, height = %d)\n",
row_ptr, image_size);
return;
}
opcode = s->buf[stream_ptr++];
switch (opcode & 0xF0) {
case 0x00:
case 0x10:
n_blocks = GET_BLOCK_COUNT();
while (n_blocks--) {
ADVANCE_BLOCK();
}
break;
case 0x20:
case 0x30:
n_blocks = GET_BLOCK_COUNT();
if ((row_ptr == 0) && (pixel_ptr == 0)) {
av_log(s->avctx, AV_LOG_INFO, "encountered repeat block opcode (%02X) but no blocks rendered yet\n",
opcode & 0xF0);
break;
}
if (pixel_ptr == 0)
prev_block_ptr1 =
(row_ptr - s->avctx->width * 4) + s->avctx->width - 4;
else
prev_block_ptr1 = row_ptr + pixel_ptr - 4;
while (n_blocks--) {
block_ptr = row_ptr + pixel_ptr;
prev_block_ptr = prev_block_ptr1;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++) {
pixels[block_ptr++] = pixels[prev_block_ptr++];
}
block_ptr += row_inc;
prev_block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
case 0x40:
case 0x50:
n_blocks = GET_BLOCK_COUNT();
n_blocks *= 2;
if ((row_ptr == 0) && (pixel_ptr < 2 * 4)) {
av_log(s->avctx, AV_LOG_INFO, "encountered repeat block opcode (%02X) but not enough blocks rendered yet\n",
opcode & 0xF0);
break;
}
if (pixel_ptr == 0)
prev_block_ptr1 = (row_ptr - s->avctx->width * 4) +
s->avctx->width - 4 * 2;
else if (pixel_ptr == 4)
prev_block_ptr1 = (row_ptr - s->avctx->width * 4) + row_inc;
else
prev_block_ptr1 = row_ptr + pixel_ptr - 4 * 2;
if (pixel_ptr == 0)
prev_block_ptr2 = (row_ptr - s->avctx->width * 4) + row_inc;
else
prev_block_ptr2 = row_ptr + pixel_ptr - 4;
prev_block_flag = 0;
while (n_blocks--) {
block_ptr = row_ptr + pixel_ptr;
if (prev_block_flag)
prev_block_ptr = prev_block_ptr2;
else
prev_block_ptr = prev_block_ptr1;
prev_block_flag = !prev_block_flag;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++) {
pixels[block_ptr++] = pixels[prev_block_ptr++];
}
block_ptr += row_inc;
prev_block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
case 0x60:
case 0x70:
n_blocks = GET_BLOCK_COUNT();
pixel = s->buf[stream_ptr++];
while (n_blocks--) {
block_ptr = row_ptr + pixel_ptr;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++) {
pixels[block_ptr++] = pixel;
}
block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
case 0x80:
case 0x90:
n_blocks = (opcode & 0x0F) + 1;
if ((opcode & 0xF0) == 0x80) {
for (i = 0; i < CPAIR; i++) {
pixel = s->buf[stream_ptr++];
color_table_index = CPAIR * color_pair_index + i;
s->color_pairs[color_table_index] = pixel;
}
color_table_index = CPAIR * color_pair_index;
color_pair_index++;
if (color_pair_index == COLORS_PER_TABLE)
color_pair_index = 0;
} else
color_table_index = CPAIR * s->buf[stream_ptr++];
while (n_blocks--) {
color_flags = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 2;
flag_mask = 0x8000;
block_ptr = row_ptr + pixel_ptr;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++) {
if (color_flags & flag_mask)
pixel = color_table_index + 1;
else
pixel = color_table_index;
flag_mask >>= 1;
pixels[block_ptr++] = s->color_pairs[pixel];
}
block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
case 0xA0:
case 0xB0:
n_blocks = (opcode & 0x0F) + 1;
if ((opcode & 0xF0) == 0xA0) {
for (i = 0; i < CQUAD; i++) {
pixel = s->buf[stream_ptr++];
color_table_index = CQUAD * color_quad_index + i;
s->color_quads[color_table_index] = pixel;
}
color_table_index = CQUAD * color_quad_index;
color_quad_index++;
if (color_quad_index == COLORS_PER_TABLE)
color_quad_index = 0;
} else
color_table_index = CQUAD * s->buf[stream_ptr++];
while (n_blocks--) {
color_flags = AV_RB32(&s->buf[stream_ptr]);
stream_ptr += 4;
flag_mask = 30;
block_ptr = row_ptr + pixel_ptr;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++) {
pixel = color_table_index +
((color_flags >> flag_mask) & 0x03);
flag_mask -= 2;
pixels[block_ptr++] = s->color_quads[pixel];
}
block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
case 0xC0:
case 0xD0:
n_blocks = (opcode & 0x0F) + 1;
if ((opcode & 0xF0) == 0xC0) {
for (i = 0; i < COCTET; i++) {
pixel = s->buf[stream_ptr++];
color_table_index = COCTET * color_octet_index + i;
s->color_octets[color_table_index] = pixel;
}
color_table_index = COCTET * color_octet_index;
color_octet_index++;
if (color_octet_index == COLORS_PER_TABLE)
color_octet_index = 0;
} else
color_table_index = COCTET * s->buf[stream_ptr++];
while (n_blocks--) {
color_flags_a =
((AV_RB16(s->buf + stream_ptr ) & 0xFFF0) << 8) |
(AV_RB16(s->buf + stream_ptr + 2) >> 4);
color_flags_b =
((AV_RB16(s->buf + stream_ptr + 4) & 0xFFF0) << 8) |
((s->buf[stream_ptr + 1] & 0x0F) << 8) |
((s->buf[stream_ptr + 3] & 0x0F) << 4) |
(s->buf[stream_ptr + 5] & 0x0F);
stream_ptr += 6;
color_flags = color_flags_a;
flag_mask = 21;
block_ptr = row_ptr + pixel_ptr;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
if (pixel_y == 2) {
color_flags = color_flags_b;
flag_mask = 21;
}
for (pixel_x = 0; pixel_x < 4; pixel_x++) {
pixel = color_table_index +
((color_flags >> flag_mask) & 0x07);
flag_mask -= 3;
pixels[block_ptr++] = s->color_octets[pixel];
}
block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
case 0xE0:
n_blocks = (opcode & 0x0F) + 1;
while (n_blocks--) {
block_ptr = row_ptr + pixel_ptr;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++) {
pixels[block_ptr++] = s->buf[stream_ptr++];
}
block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
case 0xF0:
av_log(s->avctx, AV_LOG_INFO, "0xF0 opcode seen in SMC chunk (contact the developers)\n");
break;
}
}
}
| 1threat
|
Safari Print Media Queries not matching other browsers / cutting off : <p>I have a web app that looks fine when rendered in Safari but the print media queries are not being respected by the browser. In Chrome the entire printable area looks fine, however in Safari it appears to be only some variation of visible content.</p>
<p>When scrolling down on the page the header or top area is cut off, when printing higher on the page the bottom is cut off.</p>
<p>I've tried the following for the print media queries (with no effect) -</p>
<ol>
<li>Setting a <code>min-height</code> </li>
<li>Setting any variation of a <code>height</code> value on the container</li>
<li>Zooming out and printing </li>
<li>Changing resolution / scale</li>
</ol>
<p>Nothing appears to have any effect at all.</p>
<p>Unlike Chrome, I can't find a way to debug why it is happening nor a way to debug the print styles themselves.</p>
<p>Note - I am using Bootstrap for styles so there are containers, rows, spans, etc... but even removing them completely and everything being on it's own line makes no difference, the same "height" of the content is shown on print.</p>
| 0debug
|
Java lottery game efficiency, swing : <p>I believe this is not the kind of question I should be asking here so I apologize in advance. I have an exam in 2 days and the teacher that was supposed to give me a lesson clearing out all of my questions had to cancel, so now I have no one to ask. I am resolving an exam from last year, and one of the questions is to make a little java program where we pretty much simulate a lottery game of 6 numbers. My question is about efficiency, the exam is written on paper and I feel like if I was to write everything I typed on the computer I would not have enough time, we have 90 minutes and this is only one of the problems, swing is not my strong point so that leads me to think that I could write this in much fewer lines. The public instance variable 'key' is there to simulate a method from another class that generates a random key that we do not need to implement. We are only allowed to use FlowLayout, BorderLayout, CardLayout and GridLayout.</p>
<p>public class Grupo2A extends JFrame {</p>
<pre><code>private JPanel panelCont = new JPanel();
private JPanel panelUser = new JPanel();
private JPanel panelResult = new JPanel();
private JPanel p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11;
private JLabel l1, l2, l3, l4, l5, l6, l7, l8, l9;
private JTextField t1, t2, t3, t4, t5, t6;
private JButton b1, b2, b3;
private int[] userKey = new int[6];
private CardLayout cl = new CardLayout();
private GridLayout gl1 = new GridLayout(8, 1);
private GridLayout gl2 = new GridLayout(3, 1);
public int[] key = {12, 13, 16, 22, 33, 40};
private static final int WINDOW_HEIGHT1 = 600;
private static final int WINDOW_HEIGHT2 = 150;
private static final int WINDOW_WIDTH1 = 300;
public Grupo2A() {
panelCont.setLayout(cl);
panelCont.add(panelUser, "panelUser");
panelCont.add(panelResult, "panelResult");
panelUser.setLayout(gl1);
panelResult.setLayout(gl2);
setSize(WINDOW_WIDTH1, WINDOW_HEIGHT1);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
add(panelCont);
createComponents();
createPanelUser();
createPanelResult();
cl.show(panelCont, "panelUser");
setVisible(true);
}
private void createComponents() {
l1 = new JLabel("Lottery");
l2 = new JLabel("1");
l3 = new JLabel("2");
l4 = new JLabel("3");
l5 = new JLabel("4");
l6 = new JLabel("5");
l7 = new JLabel("6");
t1 = new JTextField(10);
t2 = new JTextField(10);
t3 = new JTextField(10);
t4 = new JTextField(10);
t5 = new JTextField(10);
t6 = new JTextField(10);
b1 = new JButton("Play");
b1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
int[] userKey = new int[6];
userKey[0] = Integer.parseInt(t1.getText());
userKey[1] = Integer.parseInt(t2.getText());
userKey[2] = Integer.parseInt(t3.getText());
userKey[3] = Integer.parseInt(t4.getText());
userKey[4] = Integer.parseInt(t5.getText());
userKey[5] = Integer.parseInt(t6.getText());
setUserKey(userKey);
l8.setText("You got " + correctNumbers() + " numbers");
l9.setText("The key was: " + Arrays.toString(key));
cl.show(panelCont, "panelResult");
setSize(WINDOW_WIDTH1, WINDOW_HEIGHT2);
}
});
b2 = new JButton("Clear");
b2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
t1.setText("");
t2.setText("");
t3.setText("");
t4.setText("");
t5.setText("");
t6.setText("");
}
});
p1 = new JPanel();
p2 = new JPanel();
p3 = new JPanel();
p4 = new JPanel();
p5 = new JPanel();
p6 = new JPanel();
p7 = new JPanel();
p8 = new JPanel();
p9 = new JPanel();
p10 = new JPanel();
p11 = new JPanel();
}
private void createPanelUser() {
p1.add(l1);
panelUser.add(p1);
p2.add(l2);
p2.add(t1);
panelUser.add(p2);
p3.add(l3);
p3.add(t2);
panelUser.add(p3);
p4.add(l4);
p4.add(t3);
panelUser.add(p4);
p5.add(l5);
p5.add(t4);
panelUser.add(p5);
p6.add(l6);
p6.add(t5);
panelUser.add(p6);
p7.add(l7);
p7.add(t6);
panelUser.add(p7);
p8.add(b1);
p8.add(b2);
panelUser.add(p8);
}
private void createPanelResult() {
l8 = new JLabel("You got " + correctNumbers() + " numbers");
l9 = new JLabel("The key was: " + Arrays.toString(key));
b3 = new JButton("Ok");
b3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
cl.show(panelCont, "panelUser");
setSize(WINDOW_WIDTH1, WINDOW_HEIGHT1);
}
});
p9.add(l8);
p10.add(l9);
p11.add(b3);
panelResult.add(p9);
panelResult.add(p10);
panelResult.add(p11);
}
private int correctNumbers() {
int cont = 0;
for (int i = 0; i < userKey.length; i++) {
for (int j = 0; j < key.length; j++) {
if (userKey[i] == key[j]) {
cont++;
break;
}
}
}
System.out.println(cont);
return cont;
}
private void setUserKey(int[] userKey) {
this.userKey = userKey;
}
</code></pre>
<p>}</p>
| 0debug
|
Fast Speed Distributed File System For Small File : Our Company Has five million users,we storage user's code file, we used the **MooseFS** but when we read the files in the program, in particular the slow loading speed.
So,we need to replace the file system , I hope someone can give me some advice , we have a huge number of **small files** , which distributed file system should be used .
| 0debug
|
static void pred_temp_direct_motion(const H264Context *const h, H264SliceContext *sl,
int *mb_type)
{
int b8_stride = 2;
int b4_stride = h->b_stride;
int mb_xy = sl->mb_xy, mb_y = sl->mb_y;
int mb_type_col[2];
const int16_t (*l1mv0)[2], (*l1mv1)[2];
const int8_t *l1ref0, *l1ref1;
const int is_b8x8 = IS_8X8(*mb_type);
unsigned int sub_mb_type;
int i8, i4;
assert(sl->ref_list[1][0].reference & 3);
await_reference_mb_row(h, sl->ref_list[1][0].parent,
sl->mb_y + !!IS_INTERLACED(*mb_type));
if (IS_INTERLACED(sl->ref_list[1][0].parent->mb_type[mb_xy])) {
if (!IS_INTERLACED(*mb_type)) {
mb_y = (sl->mb_y & ~1) + sl->col_parity;
mb_xy = sl->mb_x +
((sl->mb_y & ~1) + sl->col_parity) * h->mb_stride;
b8_stride = 0;
} else {
mb_y += sl->col_fieldoff;
mb_xy += h->mb_stride * sl->col_fieldoff;
}
goto single_col;
} else {
if (IS_INTERLACED(*mb_type)) {
mb_y = sl->mb_y & ~1;
mb_xy = sl->mb_x + (sl->mb_y & ~1) * h->mb_stride;
mb_type_col[0] = sl->ref_list[1][0].parent->mb_type[mb_xy];
mb_type_col[1] = sl->ref_list[1][0].parent->mb_type[mb_xy + h->mb_stride];
b8_stride = 2 + 4 * h->mb_stride;
b4_stride *= 6;
if (IS_INTERLACED(mb_type_col[0]) !=
IS_INTERLACED(mb_type_col[1])) {
mb_type_col[0] &= ~MB_TYPE_INTERLACED;
mb_type_col[1] &= ~MB_TYPE_INTERLACED;
}
sub_mb_type = MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 |
MB_TYPE_DIRECT2;
if ((mb_type_col[0] & MB_TYPE_16x16_OR_INTRA) &&
(mb_type_col[1] & MB_TYPE_16x16_OR_INTRA) &&
!is_b8x8) {
*mb_type |= MB_TYPE_16x8 | MB_TYPE_L0L1 |
MB_TYPE_DIRECT2;
} else {
*mb_type |= MB_TYPE_8x8 | MB_TYPE_L0L1;
}
} else {
single_col:
mb_type_col[0] =
mb_type_col[1] = sl->ref_list[1][0].parent->mb_type[mb_xy];
sub_mb_type = MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 |
MB_TYPE_DIRECT2;
if (!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)) {
*mb_type |= MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 |
MB_TYPE_DIRECT2;
} else if (!is_b8x8 &&
(mb_type_col[0] & (MB_TYPE_16x8 | MB_TYPE_8x16))) {
*mb_type |= MB_TYPE_L0L1 | MB_TYPE_DIRECT2 |
(mb_type_col[0] & (MB_TYPE_16x8 | MB_TYPE_8x16));
} else {
if (!h->ps.sps->direct_8x8_inference_flag) {
sub_mb_type = MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 |
MB_TYPE_DIRECT2;
}
*mb_type |= MB_TYPE_8x8 | MB_TYPE_L0L1;
}
}
}
await_reference_mb_row(h, sl->ref_list[1][0].parent, mb_y);
l1mv0 = &sl->ref_list[1][0].parent->motion_val[0][h->mb2b_xy[mb_xy]];
l1mv1 = &sl->ref_list[1][0].parent->motion_val[1][h->mb2b_xy[mb_xy]];
l1ref0 = &sl->ref_list[1][0].parent->ref_index[0][4 * mb_xy];
l1ref1 = &sl->ref_list[1][0].parent->ref_index[1][4 * mb_xy];
if (!b8_stride) {
if (sl->mb_y & 1) {
l1ref0 += 2;
l1ref1 += 2;
l1mv0 += 2 * b4_stride;
l1mv1 += 2 * b4_stride;
}
}
{
const int *map_col_to_list0[2] = { sl->map_col_to_list0[0],
sl->map_col_to_list0[1] };
const int *dist_scale_factor = sl->dist_scale_factor;
int ref_offset;
if (FRAME_MBAFF(h) && IS_INTERLACED(*mb_type)) {
map_col_to_list0[0] = sl->map_col_to_list0_field[sl->mb_y & 1][0];
map_col_to_list0[1] = sl->map_col_to_list0_field[sl->mb_y & 1][1];
dist_scale_factor = sl->dist_scale_factor_field[sl->mb_y & 1];
}
ref_offset = (sl->ref_list[1][0].parent->mbaff << 4) & (mb_type_col[0] >> 3);
if (IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])) {
int y_shift = 2 * !IS_INTERLACED(*mb_type);
assert(h->ps.sps->direct_8x8_inference_flag);
for (i8 = 0; i8 < 4; i8++) {
const int x8 = i8 & 1;
const int y8 = i8 >> 1;
int ref0, scale;
const int16_t (*l1mv)[2] = l1mv0;
if (is_b8x8 && !IS_DIRECT(sl->sub_mb_type[i8]))
continue;
sl->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&sl->ref_cache[1][scan8[i8 * 4]], 2, 2, 8, 0, 1);
if (IS_INTRA(mb_type_col[y8])) {
fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8, 0, 1);
fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2, 8, 0, 4);
fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2, 8, 0, 4);
continue;
}
ref0 = l1ref0[x8 + y8 * b8_stride];
if (ref0 >= 0)
ref0 = map_col_to_list0[0][ref0 + ref_offset];
else {
ref0 = map_col_to_list0[1][l1ref1[x8 + y8 * b8_stride] +
ref_offset];
l1mv = l1mv1;
}
scale = dist_scale_factor[ref0];
fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8,
ref0, 1);
{
const int16_t *mv_col = l1mv[x8 * 3 + y8 * b4_stride];
int my_col = (mv_col[1] << y_shift) / 2;
int mx = (scale * mv_col[0] + 128) >> 8;
int my = (scale * my_col + 128) >> 8;
fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2, 8,
pack16to32(mx, my), 4);
fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2, 8,
pack16to32(mx - mv_col[0], my - my_col), 4);
}
}
return;
}
if (IS_16X16(*mb_type)) {
int ref, mv0, mv1;
fill_rectangle(&sl->ref_cache[1][scan8[0]], 4, 4, 8, 0, 1);
if (IS_INTRA(mb_type_col[0])) {
ref = mv0 = mv1 = 0;
} else {
const int ref0 = l1ref0[0] >= 0 ? map_col_to_list0[0][l1ref0[0] + ref_offset]
: map_col_to_list0[1][l1ref1[0] + ref_offset];
const int scale = dist_scale_factor[ref0];
const int16_t *mv_col = l1ref0[0] >= 0 ? l1mv0[0] : l1mv1[0];
int mv_l0[2];
mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
ref = ref0;
mv0 = pack16to32(mv_l0[0], mv_l0[1]);
mv1 = pack16to32(mv_l0[0] - mv_col[0], mv_l0[1] - mv_col[1]);
}
fill_rectangle(&sl->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1);
fill_rectangle(&sl->mv_cache[0][scan8[0]], 4, 4, 8, mv0, 4);
fill_rectangle(&sl->mv_cache[1][scan8[0]], 4, 4, 8, mv1, 4);
} else {
for (i8 = 0; i8 < 4; i8++) {
const int x8 = i8 & 1;
const int y8 = i8 >> 1;
int ref0, scale;
const int16_t (*l1mv)[2] = l1mv0;
if (is_b8x8 && !IS_DIRECT(sl->sub_mb_type[i8]))
continue;
sl->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&sl->ref_cache[1][scan8[i8 * 4]], 2, 2, 8, 0, 1);
if (IS_INTRA(mb_type_col[0])) {
fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8, 0, 1);
fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2, 8, 0, 4);
fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2, 8, 0, 4);
continue;
}
assert(b8_stride == 2);
ref0 = l1ref0[i8];
if (ref0 >= 0)
ref0 = map_col_to_list0[0][ref0 + ref_offset];
else {
ref0 = map_col_to_list0[1][l1ref1[i8] + ref_offset];
l1mv = l1mv1;
}
scale = dist_scale_factor[ref0];
fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8,
ref0, 1);
if (IS_SUB_8X8(sub_mb_type)) {
const int16_t *mv_col = l1mv[x8 * 3 + y8 * 3 * b4_stride];
int mx = (scale * mv_col[0] + 128) >> 8;
int my = (scale * mv_col[1] + 128) >> 8;
fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2, 8,
pack16to32(mx, my), 4);
fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2, 8,
pack16to32(mx - mv_col[0], my - mv_col[1]), 4);
} else {
for (i4 = 0; i4 < 4; i4++) {
const int16_t *mv_col = l1mv[x8 * 2 + (i4 & 1) +
(y8 * 2 + (i4 >> 1)) * b4_stride];
int16_t *mv_l0 = sl->mv_cache[0][scan8[i8 * 4 + i4]];
mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
AV_WN32A(sl->mv_cache[1][scan8[i8 * 4 + i4]],
pack16to32(mv_l0[0] - mv_col[0],
mv_l0[1] - mv_col[1]));
}
}
}
}
}
}
| 1threat
|
static int dpcm_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
DPCMContext *s = avctx->priv_data;
int in, out = 0;
int predictor[2];
int channel_number = 0;
short *output_samples = data;
int shift[2];
unsigned char byte;
short diff;
if (!buf_size)
return 0;
if(*data_size/2 < buf_size)
switch(avctx->codec->id) {
case CODEC_ID_ROQ_DPCM:
if (s->channels == 1)
predictor[0] = AV_RL16(&buf[6]);
else {
predictor[0] = buf[7] << 8;
predictor[1] = buf[6] << 8;
}
SE_16BIT(predictor[0]);
SE_16BIT(predictor[1]);
for (in = 8, out = 0; in < buf_size; in++, out++) {
predictor[channel_number] += s->roq_square_array[buf[in]];
predictor[channel_number] = av_clip_int16(predictor[channel_number]);
output_samples[out] = predictor[channel_number];
channel_number ^= s->channels - 1;
}
break;
case CODEC_ID_INTERPLAY_DPCM:
in = 6;
predictor[0] = AV_RL16(&buf[in]);
in += 2;
SE_16BIT(predictor[0])
output_samples[out++] = predictor[0];
if (s->channels == 2) {
predictor[1] = AV_RL16(&buf[in]);
in += 2;
SE_16BIT(predictor[1])
output_samples[out++] = predictor[1];
}
while (in < buf_size) {
predictor[channel_number] += interplay_delta_table[buf[in++]];
predictor[channel_number] = av_clip_int16(predictor[channel_number]);
output_samples[out++] = predictor[channel_number];
channel_number ^= s->channels - 1;
}
break;
case CODEC_ID_XAN_DPCM:
in = 0;
shift[0] = shift[1] = 4;
predictor[0] = AV_RL16(&buf[in]);
in += 2;
SE_16BIT(predictor[0]);
if (s->channels == 2) {
predictor[1] = AV_RL16(&buf[in]);
in += 2;
SE_16BIT(predictor[1]);
}
while (in < buf_size) {
byte = buf[in++];
diff = (byte & 0xFC) << 8;
if ((byte & 0x03) == 3)
shift[channel_number]++;
else
shift[channel_number] -= (2 * (byte & 3));
if (shift[channel_number] < 0)
shift[channel_number] = 0;
diff >>= shift[channel_number];
predictor[channel_number] += diff;
predictor[channel_number] = av_clip_int16(predictor[channel_number]);
output_samples[out++] = predictor[channel_number];
channel_number ^= s->channels - 1;
}
break;
case CODEC_ID_SOL_DPCM:
in = 0;
if (avctx->codec_tag != 3) {
while (in < buf_size) {
int n1, n2;
n1 = (buf[in] >> 4) & 0xF;
n2 = buf[in++] & 0xF;
s->sample[0] += s->sol_table[n1];
if (s->sample[0] < 0) s->sample[0] = 0;
if (s->sample[0] > 255) s->sample[0] = 255;
output_samples[out++] = (s->sample[0] - 128) << 8;
s->sample[s->channels - 1] += s->sol_table[n2];
if (s->sample[s->channels - 1] < 0) s->sample[s->channels - 1] = 0;
if (s->sample[s->channels - 1] > 255) s->sample[s->channels - 1] = 255;
output_samples[out++] = (s->sample[s->channels - 1] - 128) << 8;
}
} else {
while (in < buf_size) {
int n;
n = buf[in++];
if (n & 0x80) s->sample[channel_number] -= s->sol_table[n & 0x7F];
else s->sample[channel_number] += s->sol_table[n & 0x7F];
s->sample[channel_number] = av_clip_int16(s->sample[channel_number]);
output_samples[out++] = s->sample[channel_number];
channel_number ^= s->channels - 1;
}
}
break;
}
*data_size = out * sizeof(short);
return buf_size;
}
| 1threat
|
Getting unknown error about "dynamic accessors failing" after updating to macOS : <p>After upgrading to macOS Sierra (10.12) and Xcode 8.0 (8A218a), I began getting many error messages in my macOS/Cocoa app (written in Objective-C) that follow this format:</p>
<pre><code>[error] warning: dynamic accessors failed to find @property implementation for 'uniqueId' for entity ABCDInfo while resolving selector 'uniqueId' on class 'ABCDInfo'. Did you remember to declare it @dynamic or @synthesized in the @implementation ?
[error] warning: dynamic accessors failed to find @property implementation for 'uniqueId' for entity ABCDContact while resolving selector 'uniqueId' on class 'ABCDContact'. Did you remember to declare it @dynamic or @synthesized in the @implementation ?
[error] warning: dynamic accessors failed to find @property implementation for 'uniqueId' for entity ABCDEmailAddress while resolving selector 'uniqueId' on class 'ABCDEmailAddress'. Did you remember to declare it @dynamic or @synthesized in the @implementation ?
[error] warning: dynamic accessors failed to find @property implementation for 'address' for entity ABCDEmailAddress while resolving selector 'address' on class 'ABCDEmailAddress'. Did you remember to declare it @dynamic or @synthesized in the @implementation ?
</code></pre>
<p>None of this is my code or code from 3rd party developer libraries that I'm using, and doing a search on those variable names (i.e: 'uniqueId' or 'ABCDInfo') does not pull anything up, indicating it's not in my project.</p>
<p>I saw that this issue was also reported on Apple's Developer Forums twice (<a href="https://forums.developer.apple.com/thread/64189">Issue 1</a> and <a href="https://forums.developer.apple.com/thread/64274">Issue 2</a>), but both questions remain unanswered </p>
<p>My question is: What causes these error messages and how can I fix them?
It doesn't cause my app to crash, but I'd rather figure out and understand what's wrong.</p>
| 0debug
|
Convert a string of characters to an unsigned integers C : I am searching a way to convert a string of characters into a string of unsigned integers.
What i am trying to do is encrypting a text file using an algorithm that encrypts hexadecimal characters.
I am reading an array of 16 characters from the file and i want to convert it to a hexadecimal array so i can encrypt it in my algorithm.
Your support is highly appreciated.
| 0debug
|
void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
int log2_trafo_size,
int slice_or_tiles_up_boundary,
int slice_or_tiles_left_boundary)
{
MvField *tab_mvf = s->ref->tab_mvf;
int log2_min_pu_size = s->sps->log2_min_pu_size;
int log2_min_tu_size = s->sps->log2_min_tb_size;
int min_pu_width = s->sps->min_pu_width;
int min_tu_width = s->sps->min_tb_width;
int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * min_pu_width +
(x0 >> log2_min_pu_size)].is_intra;
int i, j, bs;
if (y0 > 0 && (y0 & 7) == 0) {
int yp_pu = (y0 - 1) >> log2_min_pu_size;
int yq_pu = y0 >> log2_min_pu_size;
int yp_tu = (y0 - 1) >> log2_min_tu_size;
int yq_tu = y0 >> log2_min_tu_size;
for (i = 0; i < (1 << log2_trafo_size); i += 4) {
int x_pu = (x0 + i) >> log2_min_pu_size;
int x_tu = (x0 + i) >> log2_min_tu_size;
MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu];
MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu];
uint8_t top_cbf_luma = s->cbf_luma[yp_tu * min_tu_width + x_tu];
uint8_t curr_cbf_luma = s->cbf_luma[yq_tu * min_tu_width + x_tu];
RefPicList *top_refPicList = ff_hevc_get_ref_list(s, s->ref,
x0 + i, y0 - 1);
bs = boundary_strength(s, curr, curr_cbf_luma,
top, top_cbf_luma, top_refPicList, 1);
if (!s->sh.slice_loop_filter_across_slices_enabled_flag &&
(slice_or_tiles_up_boundary & 1) &&
(y0 % (1 << s->sps->log2_ctb_size)) == 0)
bs = 0;
else if (!s->pps->loop_filter_across_tiles_enabled_flag &&
(slice_or_tiles_up_boundary & 2) &&
(y0 % (1 << s->sps->log2_ctb_size)) == 0)
bs = 0;
if (y0 == 0 || s->sh.disable_deblocking_filter_flag == 1)
bs = 0;
if (bs)
s->horizontal_bs[((x0 + i) + y0 * s->bs_width) >> 2] = bs;
}
}
if (log2_trafo_size > s->sps->log2_min_pu_size && !is_intra)
for (j = 8; j < (1 << log2_trafo_size); j += 8) {
int yp_pu = (y0 + j - 1) >> log2_min_pu_size;
int yq_pu = (y0 + j) >> log2_min_pu_size;
int yp_tu = (y0 + j - 1) >> log2_min_tu_size;
int yq_tu = (y0 + j) >> log2_min_tu_size;
for (i = 0; i < (1 << log2_trafo_size); i += 4) {
int x_pu = (x0 + i) >> log2_min_pu_size;
int x_tu = (x0 + i) >> log2_min_tu_size;
MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu];
MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu];
uint8_t top_cbf_luma = s->cbf_luma[yp_tu * min_tu_width + x_tu];
uint8_t curr_cbf_luma = s->cbf_luma[yq_tu * min_tu_width + x_tu];
RefPicList *top_refPicList = ff_hevc_get_ref_list(s, s->ref,
x0 + i,
y0 + j - 1);
bs = boundary_strength(s, curr, curr_cbf_luma,
top, top_cbf_luma, top_refPicList, 0);
if (s->sh.disable_deblocking_filter_flag == 1)
bs = 0;
if (bs)
s->horizontal_bs[((x0 + i) + (y0 + j) * s->bs_width) >> 2] = bs;
}
}
if (x0 > 0 && (x0 & 7) == 0) {
int xp_pu = (x0 - 1) >> log2_min_pu_size;
int xq_pu = x0 >> log2_min_pu_size;
int xp_tu = (x0 - 1) >> log2_min_tu_size;
int xq_tu = x0 >> log2_min_tu_size;
for (i = 0; i < (1 << log2_trafo_size); i += 4) {
int y_pu = (y0 + i) >> log2_min_pu_size;
int y_tu = (y0 + i) >> log2_min_tu_size;
MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu];
MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu];
uint8_t left_cbf_luma = s->cbf_luma[y_tu * min_tu_width + xp_tu];
uint8_t curr_cbf_luma = s->cbf_luma[y_tu * min_tu_width + xq_tu];
RefPicList *left_refPicList = ff_hevc_get_ref_list(s, s->ref,
x0 - 1, y0 + i);
bs = boundary_strength(s, curr, curr_cbf_luma,
left, left_cbf_luma, left_refPicList, 1);
if (!s->sh.slice_loop_filter_across_slices_enabled_flag &&
(slice_or_tiles_left_boundary & 1) &&
(x0 % (1 << s->sps->log2_ctb_size)) == 0)
bs = 0;
else if (!s->pps->loop_filter_across_tiles_enabled_flag &&
(slice_or_tiles_left_boundary & 2) &&
(x0 % (1 << s->sps->log2_ctb_size)) == 0)
bs = 0;
if (x0 == 0 || s->sh.disable_deblocking_filter_flag == 1)
bs = 0;
if (bs)
s->vertical_bs[(x0 >> 3) + ((y0 + i) >> 2) * s->bs_width] = bs;
}
}
if (log2_trafo_size > log2_min_pu_size && !is_intra)
for (j = 0; j < (1 << log2_trafo_size); j += 4) {
int y_pu = (y0 + j) >> log2_min_pu_size;
int y_tu = (y0 + j) >> log2_min_tu_size;
for (i = 8; i < (1 << log2_trafo_size); i += 8) {
int xp_pu = (x0 + i - 1) >> log2_min_pu_size;
int xq_pu = (x0 + i) >> log2_min_pu_size;
int xp_tu = (x0 + i - 1) >> log2_min_tu_size;
int xq_tu = (x0 + i) >> log2_min_tu_size;
MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu];
MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu];
uint8_t left_cbf_luma = s->cbf_luma[y_tu * min_tu_width + xp_tu];
uint8_t curr_cbf_luma = s->cbf_luma[y_tu * min_tu_width + xq_tu];
RefPicList *left_refPicList = ff_hevc_get_ref_list(s, s->ref,
x0 + i - 1,
y0 + j);
bs = boundary_strength(s, curr, curr_cbf_luma,
left, left_cbf_luma, left_refPicList, 0);
if (s->sh.disable_deblocking_filter_flag == 1)
bs = 0;
if (bs)
s->vertical_bs[((x0 + i) >> 3) + ((y0 + j) >> 2) * s->bs_width] = bs;
}
}
}
| 1threat
|
How do I check which merge tool I use? : <p>I want to check which merge tool my git is set to - I just don't remember the name. I know I can wait till the next merge opportunity to run it via <code>git merge tool</code> and see what was it, but I'd like to type something like <code>git mergetool status</code> to see what is the tool (and what is the version, for instance).</p>
| 0debug
|
Contact form not working from free template : <p>I got this free template but the contact form is not working at all. It says the message was sent but I don't receive any email. The form looks really nice that's why I don't want to change it but it's not working. The developer does not provide technical help for free templates. Please help me and thank you in advance!</p>
<p>HTML</p>
<pre><code> <form id="main-contact-form" name="contact-form" role="form" method="post" action="sendemail.php">
<div class="form_status" style="display: none;"><p class="text-success">Thank you for contacting us. We'll get back to you shortly.</p></div>
<div class="form-group">
<input type="text" name="name" class="form-control" placeholder="Name" required>
</div>
<div class="form-group">
<input type="email" name="email" class="form-control" placeholder="Email" required>
</div>
<div class="form-group">
<input type="text" name="subject" class="form-control" placeholder="Subject" required>
</div>
<div class="form-group">
<textarea name="message" class="form-control" rows="8" placeholder="Message" required></textarea>
</div>
<button type="submit" class="btn btn-primary">Send Message</button>
</form>
</code></pre>
<p>PHP</p>
<pre><code><?php
$name = @trim(stripslashes($_POST['name']));
$from = @trim(stripslashes($_POST['email']));
$subject = @trim(stripslashes($_POST['subject']));
$message = @trim(stripslashes($_POST['message']));
$to = 'nikita_lim@rocketmail.com';//replace with your email
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=iso-8859-1";
$headers[] = "From: {$name} <{$from}>";
$headers[] = "Reply-To: <{$from}>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();
mail($to, $subject, $message, $headers);
die;
</code></pre>
<p>JS</p>
<pre><code>var form = $('#main-contact-form');
form.submit(function(event){
event.preventDefault();
var form_status = $('<div class="form_status"></div>');
$.ajax({
url: $(this).attr('action'),
url: '../sendemail.php',
//type : $(this).attr('method'),
//data : $(this).serialize(),
beforeSend: function(){
form.prepend( form_status.html('<p><i class="fa fa-spinner fa-spin"></i> Email is sending...</p>').fadeIn() );
}
}).done(function(data){
form_status.html('<p class="text-success">Thank you for contacting us. We will get back to you shortly</p>').delay(3000).fadeOut();
});
});
</code></pre>
| 0debug
|
pandas - Merge nearly duplicate rows based on column value : <p>I have a <code>pandas</code> dataframe with several rows that are near duplicates of each other, except for one value. My goal is to merge or "coalesce" these rows into a single row, without summing the numerical values. </p>
<p>Here is an example of what I'm working with:</p>
<pre><code>Name Sid Use_Case Revenue
A xx01 Voice $10.00
A xx01 SMS $10.00
B xx02 Voice $5.00
C xx03 Voice $15.00
C xx03 SMS $15.00
C xx03 Video $15.00
</code></pre>
<p>And here is what I would like:</p>
<pre><code>Name Sid Use_Case Revenue
A xx01 Voice, SMS $10.00
B xx02 Voice $5.00
C xx03 Voice, SMS, Video $15.00
</code></pre>
<p>The reason I don't want to sum the "Revenue" column is because my table is the result of doing a pivot over several time periods where "Revenue" simply ends up getting listed multiple times instead of having a different value per "Use_Case". </p>
<p>What would be the best way to tackle this issue? I've looked into the <code>groupby()</code> function but I still don't understand it very well.</p>
| 0debug
|
SDL2 libSDL2_image.so: undefined reference to ... [gcc, c, SDL2] : I'm using Kubuntu 18.04
So i recently tried to use SDL2, i wanted to create a simple window showing a few pictures following a tutorial but i was unable to compile the example code.
When i try to compile the code i get:
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libSDL2_image.so: undefined reference to `SDL_ceilf'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libSDL2_image.so: undefined reference to `SDL_acosf'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libSDL2_image.so: undefined reference to `SDL_floorf'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libSDL2_image.so: undefined reference to `SDL_fabsf'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libSDL2_image.so: undefined reference to `SDL_LoadFile_RW'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libSDL2_image.so: undefined reference to `SDL_fmodf'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libSDL2_image.so: undefined reference to `SDL_atan2f'
collect2: error: ld returned 1 exit status
Command used:
gcc SDLProject.c -o SDLProject `sdl2-config --cflags --libs` -lSDL2_gfx -lSDL2_image
Command used to install SDL2 libs:
sudo apt install libsdl2-dev libsdl2-gfx-dev libsdl2-image-dev libsdl2-ttf-dev libsdl2-mixer-dev
Installed packages:
sudo apt list --installed | grep "sdl"
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
libsdl2-2.0-0/bionic-updates,now 2.0.8+dfsg1-1ubuntu1.18.04.3 amd64 [installed]
libsdl2-dev/bionic-updates,now 2.0.8+dfsg1-1ubuntu1.18.04.3 amd64 [installed]
libsdl2-gfx-1.0-0/bionic,now 1.0.4+dfsg-1 amd64 [installed,automatic]
libsdl2-gfx-dev/bionic,now 1.0.4+dfsg-1 amd64 [installed]
libsdl2-image-2.0-0/bionic,now 2.0.3+dfsg1-1 amd64 [installed,automatic]
libsdl2-image-dev/bionic,now 2.0.3+dfsg1-1 amd64 [installed]
libsdl2-mixer-2.0-0/bionic,now 2.0.2+dfsg1-2 amd64 [installed,automatic]
libsdl2-mixer-dev/bionic,now 2.0.2+dfsg1-2 amd64 [installed]
libsdl2-ttf-2.0-0/bionic,now 2.0.14+dfsg1-2 amd64 [installed,automatic]
libsdl2-ttf-dev/bionic,now 2.0.14+dfsg1-2 amd64 [installed]
I already tried deleting everything that is related to SDL / SDL2 and only reinstalling the ones the project uses (SDL2, gfx and image) and **i found out that this error only happens when i try to inlude the SDL_image.h and I'm able to run other exmaple codes that does not use it.**
I do not think that the error is related to the code itself but:
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL2_gfxPrimitives.h>
#include <stdlib.h>
typedef enum Babu {
VKiraly, VVezer, VBastya, VFuto, VHuszar, VGyalog,
SKiraly, SVezer, SSastya, SFuto, SHuszar, SGyalog
} Babu;
enum { MERET = 52 };
void babu_rajzol(SDL_Renderer *renderer, SDL_Texture *babuk, Babu melyik, int x, int y) {
SDL_Rect src = { (melyik % 6) * 62 + 10, (melyik / 6) * 60 + 10, MERET, MERET };
SDL_Rect dest = { x, y, MERET, MERET };
SDL_RenderCopy(renderer, babuk, &src, &dest);
}
void sdl_init(int szeles, int magas, SDL_Window **pwindow, SDL_Renderer **prenderer) {
if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
SDL_Log("Nem indithato az SDL: %s", SDL_GetError());
exit(1);
}
SDL_Window *window = SDL_CreateWindow("SDL peldaprogram", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, szeles, magas, 0);
if (window == NULL) {
SDL_Log("Nem hozhato letre az ablak: %s", SDL_GetError());
exit(1);
}
SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
if (renderer == NULL) {
SDL_Log("Nem hozhato letre a megjelenito: %s", SDL_GetError());
exit(1);
}
SDL_RenderClear(renderer);
*pwindow = window;
*prenderer = renderer;
}
int main(int argc, char *argv[]) {
SDL_Window *window;
SDL_Renderer *renderer;
sdl_init(320, 200, &window, &renderer);
SDL_Texture *babuk = IMG_LoadTexture(renderer, "pieces.png");
if (babuk == NULL) {
SDL_Log("Nem nyithato meg a kepfajl: %s", IMG_GetError());
exit(1);
}
boxRGBA(renderer, 0, 0, 319, 199, 0x90, 0xE0, 0x90, 0xFF);
babu_rajzol(renderer, babuk, VKiraly, 82, 74);
babu_rajzol(renderer, babuk, SGyalog, 82+MERET, 74);
babu_rajzol(renderer, babuk, VHuszar, 82+2*MERET, 74);
SDL_RenderPresent(renderer);
SDL_DestroyTexture(babuk);
SDL_Event event;
while (SDL_WaitEvent(&event) && event.type != SDL_QUIT) {
}
SDL_Quit();
return 0;
}
| 0debug
|
QEMUFile *qemu_fopen_ops_buffered(void *opaque,
size_t bytes_per_sec,
BufferedPutFunc *put_buffer,
BufferedPutReadyFunc *put_ready,
BufferedWaitForUnfreezeFunc *wait_for_unfreeze,
BufferedCloseFunc *close)
{
QEMUFileBuffered *s;
s = qemu_mallocz(sizeof(*s));
s->opaque = opaque;
s->xfer_limit = bytes_per_sec / 10;
s->put_buffer = put_buffer;
s->put_ready = put_ready;
s->wait_for_unfreeze = wait_for_unfreeze;
s->close = close;
s->file = qemu_fopen_ops(s, buffered_put_buffer, NULL,
buffered_close, buffered_rate_limit,
buffered_set_rate_limit,
buffered_get_rate_limit);
s->timer = qemu_new_timer(rt_clock, buffered_rate_tick, s);
qemu_mod_timer(s->timer, qemu_get_clock(rt_clock) + 100);
return s->file;
}
| 1threat
|
static void init_native_list(UserDefNativeListUnion *cvalue)
{
int i;
switch (cvalue->type) {
case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: {
intList **list = &cvalue->u.integer.data;
for (i = 0; i < 32; i++) {
*list = g_new0(intList, 1);
(*list)->value = i;
(*list)->next = NULL;
list = &(*list)->next;
}
break;
}
case USER_DEF_NATIVE_LIST_UNION_KIND_S8: {
int8List **list = &cvalue->u.s8.data;
for (i = 0; i < 32; i++) {
*list = g_new0(int8List, 1);
(*list)->value = i;
(*list)->next = NULL;
list = &(*list)->next;
}
break;
}
case USER_DEF_NATIVE_LIST_UNION_KIND_S16: {
int16List **list = &cvalue->u.s16.data;
for (i = 0; i < 32; i++) {
*list = g_new0(int16List, 1);
(*list)->value = i;
(*list)->next = NULL;
list = &(*list)->next;
}
break;
}
case USER_DEF_NATIVE_LIST_UNION_KIND_S32: {
int32List **list = &cvalue->u.s32.data;
for (i = 0; i < 32; i++) {
*list = g_new0(int32List, 1);
(*list)->value = i;
(*list)->next = NULL;
list = &(*list)->next;
}
break;
}
case USER_DEF_NATIVE_LIST_UNION_KIND_S64: {
int64List **list = &cvalue->u.s64.data;
for (i = 0; i < 32; i++) {
*list = g_new0(int64List, 1);
(*list)->value = i;
(*list)->next = NULL;
list = &(*list)->next;
}
break;
}
case USER_DEF_NATIVE_LIST_UNION_KIND_U8: {
uint8List **list = &cvalue->u.u8.data;
for (i = 0; i < 32; i++) {
*list = g_new0(uint8List, 1);
(*list)->value = i;
(*list)->next = NULL;
list = &(*list)->next;
}
break;
}
case USER_DEF_NATIVE_LIST_UNION_KIND_U16: {
uint16List **list = &cvalue->u.u16.data;
for (i = 0; i < 32; i++) {
*list = g_new0(uint16List, 1);
(*list)->value = i;
(*list)->next = NULL;
list = &(*list)->next;
}
break;
}
case USER_DEF_NATIVE_LIST_UNION_KIND_U32: {
uint32List **list = &cvalue->u.u32.data;
for (i = 0; i < 32; i++) {
*list = g_new0(uint32List, 1);
(*list)->value = i;
(*list)->next = NULL;
list = &(*list)->next;
}
break;
}
case USER_DEF_NATIVE_LIST_UNION_KIND_U64: {
uint64List **list = &cvalue->u.u64.data;
for (i = 0; i < 32; i++) {
*list = g_new0(uint64List, 1);
(*list)->value = i;
(*list)->next = NULL;
list = &(*list)->next;
}
break;
}
case USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN: {
boolList **list = &cvalue->u.boolean.data;
for (i = 0; i < 32; i++) {
*list = g_new0(boolList, 1);
(*list)->value = (i % 3 == 0);
(*list)->next = NULL;
list = &(*list)->next;
}
break;
}
case USER_DEF_NATIVE_LIST_UNION_KIND_STRING: {
strList **list = &cvalue->u.string.data;
for (i = 0; i < 32; i++) {
*list = g_new0(strList, 1);
(*list)->value = g_strdup_printf("%d", i);
(*list)->next = NULL;
list = &(*list)->next;
}
break;
}
case USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER: {
numberList **list = &cvalue->u.number.data;
for (i = 0; i < 32; i++) {
*list = g_new0(numberList, 1);
(*list)->value = (double)i / 3;
(*list)->next = NULL;
list = &(*list)->next;
}
break;
}
default:
g_assert_not_reached();
}
}
| 1threat
|
How to solve Msg 4104 for SQl server in a Stored proc : I am modifying a stored proc which is joining some tables and giving the output.I want to include a new table that will perform a join operation and with those existing table.And while doing that i am getting an Msg 4104 while including that condition. I saw that it is for an alias problem which is in the select statement,but i am new to Sp can not figure out how it is occurring.I am posting my code please someone help.This is portion of the code which i am developing
CREATE TABLE #es_ediconsolidate
(
[txtype] [CHAR](2) NULL,
[txdesc] [VARCHAR](40) NULL,
[txrefno] [CHAR](25) NULL,
[clntcode] [CHAR](5) NULL,
[polno] [CHAR](10) NULL,
[certno] [CHAR](10) NULL,
[depcode] [DECIMAL](5, 0) NULL,
[deptype] [CHAR](1) NULL,
[namefirst] [CHAR](50) NULL,
[namelast] [CHAR](50) NULL,
[namemid] [CHAR](2) NULL,
[inieffdt] [DATETIME] NULL,
[status] [CHAR](1) NULL,
[chgeffdt] [DATETIME] NULL,
[suboffcode] [CHAR](3) NULL,
[departcd] [CHAR](6) NULL,
[memidno] [CHAR](12) NULL,
[dob] [DATETIME] NULL,
[sex] [CHAR](1) NULL,
[marital] [CHAR](1) NULL,
[occupation] [CHAR](20) NULL,
[empno] [CHAR](10) NULL,
[empdt] [DATETIME] NULL,
[salary] [DECIMAL](13, 2) NULL,
[bankac] [CHAR](40) NULL,
[memnation] [CHAR](3) NULL,
[effdate] [DATETIME] NULL,
[bankcode] [CHAR](4) NULL,
[salarymode] [CHAR](1) NULL,
[bankactype] [CHAR](1) NULL,
[bankaceffdate] [DATETIME] NULL,
[bankacstatus] [CHAR](1) NULL,
[firstcovdt] [DATETIME] NULL,
[maxageexemptind] [CHAR](1) NULL,
[vipstatus] [CHAR](1) NULL,
[sponsoridno] [VARCHAR](20) NULL,
[passportno] [CHAR](15) NULL,
[nationalidno] [CHAR](30) NULL,
[bankname] [CHAR](40) NULL,
[branchname] [CHAR](40) NULL,
[branchaddress] [CHAR](40) NULL,
[bankcurrency] [CHAR](3) NULL,
[swiftcode] [CHAR](15) NULL,
[servicedeskid] [CHAR](10) NULL,
[servicedeskdate] [DATETIME] NULL,
[dmpindicator] [CHAR](1) NULL,
[salarychgeffdt] [DATETIME] NULL,
[studentind] [CHAR](1) NULL,
[outcntyind] [CHAR](1) NULL,
[prodcode] [CHAR](5) NULL,
[benplncd] [CHAR](3) NULL,
[covgcode] [CHAR](5) NULL,
[proposedsa] [DECIMAL](11, 0) NULL,
[prdstatus] [CHAR](1) NULL,
[benid] [CHAR](20) NULL,
[benname] [CHAR](40) NULL,
[benrelat] [CHAR](15) NULL,
[beneffdt] [DATETIME] NULL,
[benshare] [DECIMAL](5, 4) NULL,
[remark] [CHAR](16) NULL,
[rcdsts] [CHAR](1) NULL,
[rcdusrid] [CHAR](20) NULL,
[rcddtstmp] [DATETIME] NULL,
[txstatus] [CHAR](1) NULL,
[uploadusrid] [VARCHAR](20) NULL,
[uploadtime] [DATETIME] NULL,
[errorcode] [CHAR](6) NULL,
[errormsg] [VARCHAR](100) NULL,
[isprocessing] [CHAR](1) NULL,
[parentclient] [VARCHAR](40) NULL,
[agentname] [VARCHAR](101) NULL,
[packagecode] [CHAR](35) NULL,
[province] [CHAR](20) NULL,
[cardprinteddate] [DATETIME] NULL,
[processedtime] [DATETIME] NULL,
[adminuserid] [VARCHAR](20) NULL,
[email] [VARCHAR](60) NULL,
[mobileno] [VARCHAR](20) NULL,
[city] [VARCHAR] (28),
[iqamaExpDate] [DATETIME] NULL,
[terminationReason] [VARCHAR] (1),
[LifeVestInd] [CHAR](1),
[LSBIndicator] [CHAR](1),
[UIDnumber] [VARCHAR] (20),
[VisaPlaceOfIssue] [VARCHAR] (50),
[eligdays] [DECIMAL](3, 0) NULL,
[certtype] [VARCHAR](50) NULL,
[BENIDTYPE] [VARCHAR](30) NULL,
[BENADDR1] [VARCHAR](30) NULL,
[BENADDR2] [VARCHAR](30) NULL,
[BENADDR3] [VARCHAR](30) NULL,
[BENADDR4] [VARCHAR](30) NULL,
[BENNATIONALITY] [CHAR](3) NULL,
[BENDOB] [DATETIME] NULL,
[BENFILE] [CHAR](1) NULL,
[FILETYPE] [CHAR](5) NULL,
[FILETYPEDESC] [VARCHAR](255) NULL,
[FILEFORMAT] [VARCHAR](255) NULL,
[FILESIZE] [INT] NULL,
[FILEPATH] [CHAR](1) NULL,
[FILETYPEFLAG] [CHAR](2) NULL,
[oldPolicyNo] [CHAR](10) NULL,
[oldSubOffCode] [CHAR](3) NULL,
[roleid] [CHAR](20) NULL,
[submitted by] [char] (200) NULL,
[oldbenplncd] [char] (3) NULL,
[SPONSORTYPE] [INT] NULL ,
[GROSSSALARYRANGE][CHAR](1) NULL,
[SALARYBASEDONCOMMISSION][CHAR](3) NULL,
[RESIDINGEMIRATE][CHAR](20) NULL,
[RESIDINGLOCATION][CHAR](20) NULL,
[WORKLOCATIONEMIRATE][CHAR](20) NULL,
[WORKLOCATION][CHAR](20) NULL,
[MEMBERINSURANCEINSIXMONTH][CHAR](50) NULL,
[VISASPONSORID][CHAR](20) NULL,
[SPONSORCONTACTNUMBER][CHAR](50) NULL,
[SPONSOREMAILID][CHAR](50) NULL,
)
/* End Temp table for Distributed out put*/
INSERT INTO #es_ediconsolidate
SELECT DISTINCT A.txtype,X.txdesc,txrefno,A.clntcode,A.polno,A.certno,A.depcode,deptype,namefirst,namelast,
namemid,A.inieffdt,A.status,A.chgeffdt,suboffcode,departcd,memidno,dob,sex,marital,occupation,empno,
empdt,salary,A.bankac,memnation,A.effdate,A.bankcode,A.salarymode,bankactype,bankaceffdate,bankacstatus,
firstcovdt,maxageexemptind,vipstatus,sponsoridno,passportno,nationalidno,bankname,branchname,branchaddress,
bankcurrency,swiftcode,servicedeskid,servicedeskdate,dmpindicator,salarychgeffdt,studentind, outcntyind,
PRODCODE =NULL,BENPLNCD =NULL,COVGCODE =NULL,PROPOSEDSA =NULL,PRDSTATUS =NULL,BENID = NULL,BENNAME =NULL,
BENRELAT =NULL,BENEFFDT =NULL,BENSHARE = NULL,REMARK =NULL,A.rcdsts,A.rcdusrid,A.rcddtstmp,txstatus,uploadusrid,
uploadtime,errorcode,errormsg, isprocessing,TR.SPONSORTYPE,TR.GROSSSALARYRANGE,TR.SALARYBASEDONCOMMISSION,
TR.RESIDINGEMIRATE,TR.RESIDINGLOCATION,TR.WORKLOCATIONEMIRATE,TR.WORKLOCATION,TR.MEMBERINSURANCEINSIXMONTH,
TR.VISASPONSORID,TR.SPONSORCONTACTNUMBER,TR.SPONSOREMAILID,
FROM tmemtrans A (NOLOCK)
INNER JOIN es_txtypes X (NOLOCK)
ON A.txtype = X.txtype
INNER JOIN tpolicy P (NOLOCK)
ON A.polno = P.polno
INNER JOIN tpolpdt TP (nolock)
ON A.polno = tp.polno
--INNER JOIN tpolpdtcom tcom (nolock)
-- ON tp.polno = tcom.polno and tp.prodcode = tcom.prodcode and tp.effdate = tcom.effdate and tcom.prducode in (select es_usercode.code from es_usercode where es_usercode.userid= a.UPLOADUSRID union select es_usercode.code from es_usercode, es_userrole where es_usercode.userid=es_userrole.supervisorid and es_userrole.userid=a.UPLOADUSRID)
left JOIN tclient C (nolock)
ON --A.profilecode = c.clntcode
--AND
P.clntcode = c.clntcode
--Here i am including the join ----
JOIN TMEMBERREGULATORYINFO TR (nolock)
ON TR.CLNTCODE = A.CLNTCODE
AND TR.CERTNO = A.CERTNO
AND TR.DEPCODE = A.DEPCODE
INNER JOIN @PolNosCanAccess polnos on polnos.polno= A.polno
But i am getting the error
Msg 4104, Level 16, State 1, Procedure ES_CONSOLIDATELIST_ADMIN_MEMBER, Line 360
The multi-part identifier "TR.SPONSORTYPE" could not be bound.
Somebody please help
| 0debug
|
How to change text file extension type in Linux? : <p>Using gedit, I want to create a config.env file, how do I change the extension as simply naming it config.env doesn't work. </p>
<p>THanks in advance</p>
| 0debug
|
How to properly create regex from string in Javascript? : <p>I'm struggle with an issue and don't understand why is this happen. I have an regex, which store in DB and for validation it's taken from server.</p>
<p>But on client side when I'm trying to transform my regex from string using <code>new RegExp()</code> I'm struggle with a problem.</p>
<p>My code <code>new RegExp('\d');</code> returns <code>/d/</code>, but should <code>/\d/</code>, is anybody can help me with this? Where I miss the things?</p>
<p>I was looked this answer <a href="https://stackoverflow.com/questions/6521572/javascript-regex-not-working">Javascript RegEx Not Working</a> but I don't think that my issue is duplicate of existing one. Because of here is explained how to convert to regex from string, but in my issue new regExp eat '\' symbol and I'm not understand why and what should to do to avoid this?</p>
| 0debug
|
Project segregation in Sonar Qube : <p>I have a projects structure like as shown below.</p>
<p><a href="https://i.stack.imgur.com/HONW9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HONW9.png" alt="enter image description here"></a></p>
<p><strong>Cloud projects</strong> folder are having four type projects (<strong>eco-projects, evn-projects, met-projects, svn-projects</strong>)</p>
<p>Each type of projects contains again four different projects, like for example in <strong>eco-projects</strong> we have <strong>eco-1-projects, eco-2-projects, eco-3-projects,eco-4-projects</strong>.</p>
<p>I have integrated this in Sonar Qube which I got only one Project as <strong>Cloud projects</strong> like as shown below, when shows all the combined projects source code.</p>
<p><a href="https://i.stack.imgur.com/HltYS.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HltYS.png" alt="enter image description here"></a></p>
<p>Can we have a hierarchy like visualization in Sonar Qube, like for example lets say when I click the <strong>Cloud Projects</strong> in Sonar Dashbaord, It will navigate to another four project such as <strong>eco-projects, evn-projects, met-projects, svn-projects</strong> and now lets say when I click <strong>eco-projects</strong> it will show me <strong>eco-1-projects, eco-2-projects, eco-3-projects,eco-4-projects</strong> and now when I click <strong>eco-1-projects</strong> it will show its source code related dashboard and coverages</p>
<p>My <strong>sonar-project.properties</strong> is given below</p>
<pre><code># Required metadata
sonar.projectKey=cloud-projects
sonar.projectName=Cloud Projects
sonar.projectVersion=1.0
# Language
sonar.language=java
# Encoding of the source files
sonar.sourceEncoding=UTF-8
sonar.modules=eco-projects, evn-projects, met-projects, svn-projects
eco-projects.sonar.projectName=eco-projects
eco-projects.sonar.language=java
eco-projects.sonar.modules=eco-1-projects, eco-2-projects, eco-3-projects,eco-4-projects
eco-projects.eco-1-projects.sonar.projectName=eco-1-projects
eco-projects.eco-1-projects.sonar.sources=docroot/WEB-INF/src
eco-projects.eco-1-projects.sonar.language=java
eco-projects.eco-2-projects.sonar.projectName=eco-2-projects
eco-projects.eco-2-projects.sonar.sources=docroot/WEB-INF/src
eco-projects.eco-2-projects.sonar.language=java
eco-projects.eco-3-projects.sonar.projectName=eco-3-projects
eco-projects.eco-3-projects.sonar.sources=docroot/WEB-INF/src
eco-projects.eco-3-projects.sonar.language=java
eco-projects.eco-4-projects.sonar.projectName=eco-4-projects
eco-projects.eco-4-projects.sonar.sources=docroot/WEB-INF/src
eco-projects.eco-4-projects.sonar.language=java
:
:
:
</code></pre>
<p>Can anyone please tell me some solution for this</p>
| 0debug
|
static int get_cod(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c,
uint8_t *properties)
{
Jpeg2000CodingStyle tmp;
int compno, ret;
if (bytestream2_get_bytes_left(&s->g) < 5)
tmp.csty = bytestream2_get_byteu(&s->g);
tmp.prog_order = bytestream2_get_byteu(&s->g);
tmp.nlayers = bytestream2_get_be16u(&s->g);
tmp.mct = bytestream2_get_byteu(&s->g);
if ((ret = get_cox(s, &tmp)) < 0)
return ret;
for (compno = 0; compno < s->ncomponents; compno++)
if (!(properties[compno] & HAD_COC))
memcpy(c + compno, &tmp, sizeof(tmp));
return 0;
| 1threat
|
change the text of attributes string in uilable in swift : I am using attributes string to add some text to my uilable, and I want to change this text when user press the uilabel
here is my code
let likes: UILabel = UILabel(frame: CGRectMake(5, CGFloat(totalHeight + 5), 50, 21));
let likesString: NSAttributedString = NSAttributedString (string: String(selectedItem.noLikes))
var myString: NSMutableAttributedString = NSMutableAttributedString(string: " ")
myString.appendAttributedString(likesString)
likes.attributedText = myString
mainScrollView.addSubview(likes)
what I want to change the value of `likesString` from `(selectedItem.noLikes)` to `(selectedItem.noLikes + 1)`
can any one help me please ?
| 0debug
|
how can i convert this query to a larvel syntax to use pagenation : $db = DB::connection()->getPdo();
$query = "
SELECT
c.id, sys_id, cam_name, description, brand, product, c.status, update_by, start_date, end_date,
DATE_FORMAT(CONVERT_TZ(c.created_at, @@session.time_zone, '" . Common::utc_offset() . "'), '%Y-%m-%d %H:%i:%s') as created_at,
DATE_FORMAT(CONVERT_TZ(c.updated_at, @@session.time_zone, '" . Common::utc_offset() . "'), '%Y-%m-%d %H:%i:%s') as updated_at,
hashid, blm_field, inactive_period, is_testing, signature, camp_type,
SUM(IF(p.inter = 1 AND p.admin_res = 0, 1, 0)) as Bi_count
FROM camp c
LEFT JOIN pros p on c.id = p.camp_id "
;
if ($campaign_type != null) $query = $query . ' WHERE c.campaign_type = "' . $camp_type . '" ';
$query = $query . ' GROUP BY c.id ';
$excute= $db->prepare($query);
i am really new at laravel so m wondering if there is a way i can convert this query to laravel syntax to use `pagination()`
| 0debug
|
static int svq1_decode_block_intra(GetBitContext *bitbuf, uint8_t *pixels,
int pitch)
{
uint32_t bit_cache;
uint8_t *list[63];
uint32_t *dst;
const uint32_t *codebook;
int entries[6];
int i, j, m, n;
int mean, stages;
unsigned x, y, width, height, level;
uint32_t n1, n2, n3, n4;
list[0] = pixels;
for (i = 0, m = 1, n = 1, level = 5; i < n; i++) {
SVQ1_PROCESS_VECTOR();
dst = (uint32_t *)list[i];
width = 1 << ((4 + level) / 2);
height = 1 << ((3 + level) / 2);
stages = get_vlc2(bitbuf, svq1_intra_multistage[level].table, 3, 3) - 1;
if (stages == -1) {
for (y = 0; y < height; y++)
memset(&dst[y * (pitch / 4)], 0, width);
continue;
}
if (stages > 0 && level >= 4) {
av_dlog(NULL,
"Error (svq1_decode_block_intra): invalid vector: stages=%i level=%i\n",
stages, level);
return AVERROR_INVALIDDATA;
}
mean = get_vlc2(bitbuf, svq1_intra_mean.table, 8, 3);
if (stages == 0) {
for (y = 0; y < height; y++)
memset(&dst[y * (pitch / 4)], mean, width);
} else {
SVQ1_CALC_CODEBOOK_ENTRIES(ff_svq1_intra_codebooks);
for (y = 0; y < height; y++) {
for (x = 0; x < width / 4; x++, codebook++) {
n1 = n4;
n2 = n4;
SVQ1_ADD_CODEBOOK()
dst[x] = n1 << 8 | n2;
}
dst += pitch / 4;
}
}
}
return 0;
}
| 1threat
|
Email send on Link Click : I want to send a mail. when some click on my Website Download Link. So How can i do that using PHP and Javascript.
<form method="post">
<div class="form-group">
<input type="email" class="form-control" placeholder="Enter Email ID" id="email" onchange="check();" require pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$"/>
</div>
<div class="form-group">
<label style="font-size:14px;"><input type="checkbox" id="toggle"> I agree to receive emails from MarketerBoard. We will not share your any personal information with anyone.</label>
</div>
<div class="form-group" style="min-height:40px;">
<a style="display:none;" href="/images/docs/EMAIL-MARKETING-GUIDE.pdf" name="downloadBtn" download class="mb-button" id="dwn-btn" onchange="check();" onClick="sendmail();">Get your free guide</a>
</div>
</form>
| 0debug
|
static int rm_probe(AVProbeData *p)
{
if (p->buf_size <= 32)
return 0;
if ((p->buf[0] == '.' && p->buf[1] == 'R' &&
p->buf[2] == 'M' && p->buf[3] == 'F' &&
p->buf[4] == 0 && p->buf[5] == 0) ||
(p->buf[0] == '.' && p->buf[1] == 'r' &&
p->buf[2] == 'a' && p->buf[3] == 0xfd))
return AVPROBE_SCORE_MAX;
else
return 0;
}
| 1threat
|
Script to move through multiple folders and copy only files with specific ext to another single folder : <p>How to make a script (preferably in python, but I'm open for other ways as well) to parse through multiple subfolders and copy only files with certain extension (like .mp3 & .mp4 etc) to another folder in Linux/Ubuntu?</p>
| 0debug
|
gen_intermediate_code_internal(CRISCPU *cpu, TranslationBlock *tb,
bool search_pc)
{
CPUState *cs = CPU(cpu);
CPUCRISState *env = &cpu->env;
uint32_t pc_start;
unsigned int insn_len;
int j, lj;
struct DisasContext ctx;
struct DisasContext *dc = &ctx;
uint32_t next_page_start;
target_ulong npc;
int num_insns;
int max_insns;
if (env->pregs[PR_VR] == 32) {
dc->decoder = crisv32_decoder;
dc->clear_locked_irq = 0;
} else {
dc->decoder = crisv10_decoder;
dc->clear_locked_irq = 1;
}
pc_start = tb->pc & ~1;
dc->cpu = cpu;
dc->tb = tb;
dc->is_jmp = DISAS_NEXT;
dc->ppc = pc_start;
dc->pc = pc_start;
dc->singlestep_enabled = cs->singlestep_enabled;
dc->flags_uptodate = 1;
dc->flagx_known = 1;
dc->flags_x = tb->flags & X_FLAG;
dc->cc_x_uptodate = 0;
dc->cc_mask = 0;
dc->update_cc = 0;
dc->clear_prefix = 0;
cris_update_cc_op(dc, CC_OP_FLAGS, 4);
dc->cc_size_uptodate = -1;
dc->tb_flags = tb->flags & (S_FLAG | P_FLAG | U_FLAG \
| X_FLAG | PFIX_FLAG);
dc->delayed_branch = !!(tb->flags & 7);
if (dc->delayed_branch) {
dc->jmp = JMP_INDIRECT;
} else {
dc->jmp = JMP_NOJMP;
}
dc->cpustate_changed = 0;
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log(
"srch=%d pc=%x %x flg=%" PRIx64 " bt=%x ds=%u ccs=%x\n"
"pid=%x usp=%x\n"
"%x.%x.%x.%x\n"
"%x.%x.%x.%x\n"
"%x.%x.%x.%x\n"
"%x.%x.%x.%x\n",
search_pc, dc->pc, dc->ppc,
(uint64_t)tb->flags,
env->btarget, (unsigned)tb->flags & 7,
env->pregs[PR_CCS],
env->pregs[PR_PID], env->pregs[PR_USP],
env->regs[0], env->regs[1], env->regs[2], env->regs[3],
env->regs[4], env->regs[5], env->regs[6], env->regs[7],
env->regs[8], env->regs[9],
env->regs[10], env->regs[11],
env->regs[12], env->regs[13],
env->regs[14], env->regs[15]);
qemu_log("--------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
}
next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
lj = -1;
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0) {
max_insns = CF_COUNT_MASK;
}
gen_tb_start(tb);
do {
check_breakpoint(env, dc);
if (search_pc) {
j = tcg_op_buf_count();
if (lj < j) {
lj++;
while (lj < j) {
tcg_ctx.gen_opc_instr_start[lj++] = 0;
}
}
if (dc->delayed_branch == 1) {
tcg_ctx.gen_opc_pc[lj] = dc->ppc | 1;
} else {
tcg_ctx.gen_opc_pc[lj] = dc->pc;
}
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
LOG_DIS("%8.8x:\t", dc->pc);
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
}
dc->clear_x = 1;
insn_len = dc->decoder(env, dc);
dc->ppc = dc->pc;
dc->pc += insn_len;
if (dc->clear_x) {
cris_clear_x_flag(dc);
}
num_insns++;
if (dc->delayed_branch) {
dc->delayed_branch--;
if (dc->delayed_branch == 0) {
if (tb->flags & 7) {
t_gen_mov_env_TN(dslot, tcg_const_tl(0));
}
if (dc->cpustate_changed || !dc->flagx_known
|| (dc->flags_x != (tb->flags & X_FLAG))) {
cris_store_direct_jmp(dc);
}
if (dc->clear_locked_irq) {
dc->clear_locked_irq = 0;
t_gen_mov_env_TN(locked_irq, tcg_const_tl(0));
}
if (dc->jmp == JMP_DIRECT_CC) {
int l1;
l1 = gen_new_label();
cris_evaluate_flags(dc);
tcg_gen_brcondi_tl(TCG_COND_EQ,
env_btaken, 0, l1);
gen_goto_tb(dc, 1, dc->jmp_pc);
gen_set_label(l1);
gen_goto_tb(dc, 0, dc->pc);
dc->is_jmp = DISAS_TB_JUMP;
dc->jmp = JMP_NOJMP;
} else if (dc->jmp == JMP_DIRECT) {
cris_evaluate_flags(dc);
gen_goto_tb(dc, 0, dc->jmp_pc);
dc->is_jmp = DISAS_TB_JUMP;
dc->jmp = JMP_NOJMP;
} else {
t_gen_cc_jmp(env_btarget, tcg_const_tl(dc->pc));
dc->is_jmp = DISAS_JUMP;
}
break;
}
}
if (!(tb->pc & 1) && cs->singlestep_enabled) {
break;
}
} while (!dc->is_jmp && !dc->cpustate_changed
&& !tcg_op_buf_full()
&& !singlestep
&& (dc->pc < next_page_start)
&& num_insns < max_insns);
if (dc->clear_locked_irq) {
t_gen_mov_env_TN(locked_irq, tcg_const_tl(0));
}
npc = dc->pc;
if (tb->cflags & CF_LAST_IO)
gen_io_end();
if (dc->is_jmp == DISAS_NEXT
&& (dc->cpustate_changed || !dc->flagx_known
|| (dc->flags_x != (tb->flags & X_FLAG)))) {
dc->is_jmp = DISAS_UPDATE;
tcg_gen_movi_tl(env_pc, npc);
}
if (dc->delayed_branch == 1) {
t_gen_mov_env_TN(dslot, tcg_const_tl(dc->pc - dc->ppc));
cris_store_direct_jmp(dc);
}
cris_evaluate_flags(dc);
if (unlikely(cs->singlestep_enabled)) {
if (dc->is_jmp == DISAS_NEXT) {
tcg_gen_movi_tl(env_pc, npc);
}
t_gen_raise_exception(EXCP_DEBUG);
} else {
switch (dc->is_jmp) {
case DISAS_NEXT:
gen_goto_tb(dc, 1, npc);
break;
default:
case DISAS_JUMP:
case DISAS_UPDATE:
tcg_gen_exit_tb(0);
break;
case DISAS_SWI:
case DISAS_TB_JUMP:
break;
}
}
gen_tb_end(tb, num_insns);
if (search_pc) {
j = tcg_op_buf_count();
lj++;
while (lj <= j) {
tcg_ctx.gen_opc_instr_start[lj++] = 0;
}
} else {
tb->size = dc->pc - pc_start;
tb->icount = num_insns;
}
#ifdef DEBUG_DISAS
#if !DISAS_CRIS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
log_target_disas(env, pc_start, dc->pc - pc_start,
env->pregs[PR_VR]);
qemu_log("\nisize=%d osize=%d\n",
dc->pc - pc_start, tcg_op_buf_count());
}
#endif
#endif
}
| 1threat
|
Machine Learning for Dummies - Need help/pointers on where to start : <p>I want to create a system that detects the type of image based on the color composition.</p>
<p>E.G = </p>
<p>Object A = Blue, Red, Orange, Green.
Object B = Red, Green, Blue, Black.</p>
<p>Whenever i scan an image with a color composition of Blue-red- Orange- Green, the answer will be Object A. </p>
<p>I scanned a couple of tuts but i can't grasp it. I want to ask on what algo to use, and where do i start. </p>
<p>So far, what i've found that will help me with my problem is the K-Nearest Neighbor Algo, but i'm still looking for a more options. Any help will do! </p>
| 0debug
|
MongoDB Failing to Start - ***aborting after fassert() failure : <p>I am new to Ubuntu (Linux tbh). I encountered problem with starting MongoDB service. I want to created web app using Ruby on Rails and MongoDB but mongo seems to fail to start.</p>
<p>I followed this <a href="https://docs.mongodb.org/v3.0/tutorial/install-mongodb-on-ubuntu/">MongoDB installation on Ubuntu</a> all of installation went without problems until I got to <code>sudo service mongod start</code> </p>
<p><strong>mongod.log</strong></p>
<pre><code>2016-01-01T10:58:15.545+0000 I CONTROL ***** SERVER RESTARTED *****
2016-01-01T10:58:15.548+0000 I CONTROL [initandlisten] MongoDB starting : pid=3868 port=27017 dbpath=/var/lib/mongodb 64-bit host=damian-CX61-0NC-CX61-0ND-CX61-0NF-CX61-0NE
2016-01-01T10:58:15.548+0000 I CONTROL [initandlisten] db version v3.0.8
2016-01-01T10:58:15.548+0000 I CONTROL [initandlisten] git version: 83d8cc25e00e42856924d84e220fbe4a839e605d
2016-01-01T10:58:15.548+0000 I CONTROL [initandlisten] build info: Linux ip-10-187-89-126 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2016-01-01T10:58:15.548+0000 I CONTROL [initandlisten] allocator: tcmalloc
2016-01-01T10:58:15.548+0000 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2016-01-01T10:58:15.567+0000 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2016-01-01T10:58:15.567+0000 I - [initandlisten] Fatal Assertion 28578
2016-01-01T10:58:15.567+0000 I - [initandlisten]
***aborting after fassert() failure
</code></pre>
<p>So what I am doing wrong or its different issue?</p>
| 0debug
|
How to generate FB Page access token : <p>I have a Page with ID: 1620295414849355
I need to generate Page Access Token.
Need Page access token to post content on FB page from my website.</p>
| 0debug
|
How do i call a macro from from another macro in google sheets : In google sheets, I have a macro that runs until an IFS statement wants to call another macro when true, but I get an error message instead.
`enter code here`function BeginTournamentMacro() {
`enter code here` var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
`enter code here`var sheet = spreadsheet.getSheetByName('SIGNUP SHEET').activate();
`enter code here` var COLUMN = 3;
`enter code here`var spreadsheet = SpreadsheetApp.getActive();
`enter code here`spreadsheet.getCurrentCell().offset(3, 3, 50, 3).activate();
`enter code here`spreadsheet.getActiveRange().copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_VALUES, false);
`enter code here`spreadsheet.getCurrentCell().offset(-1, -1, 48, 4).activate()
.sort({column: spreadsheet.getActiveRange().getColumn(), ascending: true});
`enter code here`spreadsheet.getCurrentCell().getNextDataCell(SpreadsheetApp.Direction.DOWN).activate();
`enter code here`spreadsheet.getCurrentCell().offset( 1, 0).activate(); //moves down one row.
`enter code here`spreadsheet.getCurrentCell().offset(0, 0, 48, 4).activate();
`enter code here`spreadsheet.getActiveRangeList().clear({contentsOnly: true, skipFilteredRows: true});
`enter code here`spreadsheet.getActiveRange().If Range('B2').value = 10, Then Call Ten;
I expected the macro named Ten to run, and then return to run the final 2 rows of code (not shown).
Error message: Missing ; before statement. (line 16, file "macros")Dismiss
| 0debug
|
static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AVFrame *const p = data;
int compressed, xmin, ymin, xmax, ymax;
unsigned int w, h, bits_per_pixel, bytes_per_line, nplanes, stride, y, x,
bytes_per_scanline;
uint8_t *ptr;
const uint8_t *buf_end = buf + buf_size;
const uint8_t *bufstart = buf;
uint8_t *scanline;
int ret = -1;
if (buf[0] != 0x0a || buf[1] > 5) {
av_log(avctx, AV_LOG_ERROR, "this is not PCX encoded data\n");
return AVERROR_INVALIDDATA;
}
compressed = buf[2];
xmin = AV_RL16(buf + 4);
ymin = AV_RL16(buf + 6);
xmax = AV_RL16(buf + 8);
ymax = AV_RL16(buf + 10);
if (xmax < xmin || ymax < ymin) {
av_log(avctx, AV_LOG_ERROR, "invalid image dimensions\n");
return AVERROR_INVALIDDATA;
}
w = xmax - xmin + 1;
h = ymax - ymin + 1;
bits_per_pixel = buf[3];
bytes_per_line = AV_RL16(buf + 66);
nplanes = buf[65];
bytes_per_scanline = nplanes * bytes_per_line;
if (bytes_per_scanline < (w * bits_per_pixel * nplanes + 7) / 8 ||
(!compressed && bytes_per_scanline > buf_size / h)) {
av_log(avctx, AV_LOG_ERROR, "PCX data is corrupted\n");
return AVERROR_INVALIDDATA;
}
switch ((nplanes << 8) + bits_per_pixel) {
case 0x0308:
avctx->pix_fmt = AV_PIX_FMT_RGB24;
break;
case 0x0108:
case 0x0104:
case 0x0102:
case 0x0101:
case 0x0401:
case 0x0301:
case 0x0201:
avctx->pix_fmt = AV_PIX_FMT_PAL8;
break;
default:
av_log(avctx, AV_LOG_ERROR, "invalid PCX file\n");
return AVERROR_INVALIDDATA;
}
buf += 128;
if ((ret = ff_set_dimensions(avctx, w, h)) < 0)
return ret;
if ((ret = ff_get_buffer(avctx, p, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
p->pict_type = AV_PICTURE_TYPE_I;
ptr = p->data[0];
stride = p->linesize[0];
scanline = av_malloc(bytes_per_scanline);
if (!scanline)
return AVERROR(ENOMEM);
if (nplanes == 3 && bits_per_pixel == 8) {
for (y = 0; y < h; y++) {
buf = pcx_rle_decode(buf, buf_end,
scanline, bytes_per_scanline, compressed);
for (x = 0; x < w; x++) {
ptr[3 * x] = scanline[x];
ptr[3 * x + 1] = scanline[x + bytes_per_line];
ptr[3 * x + 2] = scanline[x + (bytes_per_line << 1)];
}
ptr += stride;
}
} else if (nplanes == 1 && bits_per_pixel == 8) {
const uint8_t *palstart = bufstart + buf_size - 769;
if (buf_size < 769) {
av_log(avctx, AV_LOG_ERROR, "File is too short\n");
ret = avctx->err_recognition & AV_EF_EXPLODE ?
AVERROR_INVALIDDATA : buf_size;
goto end;
}
for (y = 0; y < h; y++, ptr += stride) {
buf = pcx_rle_decode(buf, buf_end,
scanline, bytes_per_scanline, compressed);
memcpy(ptr, scanline, w);
}
if (buf != palstart) {
av_log(avctx, AV_LOG_WARNING, "image data possibly corrupted\n");
buf = palstart;
}
if (*buf++ != 12) {
av_log(avctx, AV_LOG_ERROR, "expected palette after image data\n");
ret = avctx->err_recognition & AV_EF_EXPLODE ?
AVERROR_INVALIDDATA : buf_size;
goto end;
}
} else if (nplanes == 1) {
GetBitContext s;
for (y = 0; y < h; y++) {
init_get_bits(&s, scanline, bytes_per_scanline << 3);
buf = pcx_rle_decode(buf, buf_end,
scanline, bytes_per_scanline, compressed);
for (x = 0; x < w; x++)
ptr[x] = get_bits(&s, bits_per_pixel);
ptr += stride;
}
} else {
int i;
for (y = 0; y < h; y++) {
buf = pcx_rle_decode(buf, buf_end,
scanline, bytes_per_scanline, compressed);
for (x = 0; x < w; x++) {
int m = 0x80 >> (x & 7), v = 0;
for (i = nplanes - 1; i >= 0; i--) {
v <<= 1;
v += !!(scanline[i * bytes_per_line + (x >> 3)] & m);
}
ptr[x] = v;
}
ptr += stride;
}
}
if (nplanes == 1 && bits_per_pixel == 8) {
pcx_palette(&buf, (uint32_t *)p->data[1], 256);
} else if (bits_per_pixel < 8) {
const uint8_t *palette = bufstart + 16;
pcx_palette(&palette, (uint32_t *)p->data[1], 16);
}
*got_frame = 1;
ret = buf - bufstart;
end:
av_free(scanline);
return ret;
}
| 1threat
|
int ff_lpc_calc_coefs(DSPContext *s,
const int32_t *samples, int blocksize, int min_order,
int max_order, int precision,
int32_t coefs[][MAX_LPC_ORDER], int *shift, int use_lpc,
int omethod, int max_shift, int zero_shift)
{
double autoc[MAX_LPC_ORDER+1];
double ref[MAX_LPC_ORDER];
double lpc[MAX_LPC_ORDER][MAX_LPC_ORDER];
int i, j, pass;
int opt_order;
assert(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER && use_lpc > 0);
if(use_lpc == 1){
s->flac_compute_autocorr(samples, blocksize, max_order, autoc);
compute_lpc_coefs(autoc, max_order, &lpc[0][0], MAX_LPC_ORDER, 0, 1);
for(i=0; i<max_order; i++)
ref[i] = fabs(lpc[i][i]);
}else{
LLSModel m[2];
double var[MAX_LPC_ORDER+1], weight;
for(pass=0; pass<use_lpc-1; pass++){
av_init_lls(&m[pass&1], max_order);
weight=0;
for(i=max_order; i<blocksize; i++){
for(j=0; j<=max_order; j++)
var[j]= samples[i-j];
if(pass){
double eval, inv, rinv;
eval= av_evaluate_lls(&m[(pass-1)&1], var+1, max_order-1);
eval= (512>>pass) + fabs(eval - var[0]);
inv = 1/eval;
rinv = sqrt(inv);
for(j=0; j<=max_order; j++)
var[j] *= rinv;
weight += inv;
}else
weight++;
av_update_lls(&m[pass&1], var, 1.0);
}
av_solve_lls(&m[pass&1], 0.001, 0);
}
for(i=0; i<max_order; i++){
for(j=0; j<max_order; j++)
lpc[i][j]=-m[(pass-1)&1].coeff[i][j];
ref[i]= sqrt(m[(pass-1)&1].variance[i] / weight) * (blocksize - max_order) / 4000;
}
for(i=max_order-1; i>0; i--)
ref[i] = ref[i-1] - ref[i];
}
opt_order = max_order;
if(omethod == ORDER_METHOD_EST) {
opt_order = estimate_best_order(ref, min_order, max_order);
i = opt_order-1;
quantize_lpc_coefs(lpc[i], i+1, precision, coefs[i], &shift[i], max_shift, zero_shift);
} else {
for(i=min_order-1; i<max_order; i++) {
quantize_lpc_coefs(lpc[i], i+1, precision, coefs[i], &shift[i], max_shift, zero_shift);
}
}
return opt_order;
}
| 1threat
|
How do I fix this infanite while loop : I'm making this to be able to calculate factorials. I need it to say a sentence if they input a value over 20 but I have created and infinite loop. My line that says
System.out.print ("ERROR: The result is inaccurate because the number was too large for the data type");}
is an infinite loop. I Cant seem to figue out how to fix it. I have tried moving the placement of things but I cant figure it out. Any help is appreciated.
import java.util.Scanner;
import java.text.NumberFormat;
public class FactoralApp
{
public static void main(String[] arge)
{
//Welcome users the the application and get user input
System.out.print("Welcome to the Factoral Calculator" + "\n");
int num;
Scanner sc = new Scanner(System.in);
String choice = "y";
while (choice.equalsIgnoreCase("y")) { //set up the while loop so that users can find many factorials
long factorial=1; //initialize variables
System.out.print("\n" + "Enter an integer between 1 and 20: "); //promt users for input
num = sc.nextInt();
for (int i = num; i >= 1; i--){ //Calculate factorial
factorial = factorial * i;}
while (num > 20) {
System.out.print ("ERROR: The result is inaccurate because the number was too large for the data type");}
// Format and display the results
NumberFormat number = NumberFormat.getNumberInstance();
String message =
("\n" + "The factoral of " + num + " is " + number.format(factorial) + "." + "\n"); //create message
System.out.println(message); // Output the formated message
System.out.print ("Continue (y/n): "); //promt users for input
choice = sc.next();
} // End While
} // End main ()
} // End Class
| 0debug
|
I want to print all permutations of 123 in python? : <p>123
132
213
231
312
321
How to get all permutations as a seperate numbers?</p>
| 0debug
|
Passing data to function. What is the better way? : <p>Way 1:</p>
<pre><code>public $foo = 1;
function(){
return $this->foo+1;
}
</code></pre>
<p>Way 2:</p>
<pre><code>// with $foo = 1 in other function
function($foo){
return $foo+1;
}
</code></pre>
<p>Sorry for a 'dumb' question, someone can tell me what is the better way?</p>
| 0debug
|
float32 helper_fqtos(CPUSPARCState *env)
{
float32 ret;
clear_float_exceptions(env);
ret = float128_to_float32(QT1, &env->fp_status);
check_ieee_exceptions(env);
return ret;
}
| 1threat
|
I have Textbox in ASP.Net, to which cursor should not be entered by the user but just to display. I cant use enable property : <p></p>
<p>I have Textbox in ASP.Net, to which cursor should not be entered.</p>
| 0debug
|
static int xen_pt_status_reg_init(XenPCIPassthroughState *s,
XenPTRegInfo *reg, uint32_t real_offset,
uint32_t *data)
{
XenPTRegGroup *reg_grp_entry = NULL;
XenPTReg *reg_entry = NULL;
uint32_t reg_field = 0;
reg_grp_entry = xen_pt_find_reg_grp(s, PCI_CAPABILITY_LIST);
if (reg_grp_entry) {
reg_entry = xen_pt_find_reg(reg_grp_entry, PCI_CAPABILITY_LIST);
if (reg_entry) {
if (reg_entry->data) {
reg_field |= PCI_STATUS_CAP_LIST;
} else {
reg_field &= ~PCI_STATUS_CAP_LIST;
}
} else {
xen_shutdown_fatal_error("Internal error: Couldn't find XenPTReg*"
" for Capabilities Pointer register."
" (%s)\n", __func__);
return -1;
}
} else {
xen_shutdown_fatal_error("Internal error: Couldn't find XenPTRegGroup"
" for Header. (%s)\n", __func__);
return -1;
}
*data = reg_field;
return 0;
}
| 1threat
|
Why did the HTTP transport appear grabled after I built my javaFX project by ANT : My development environment is as follows:
> OS:Win10
> IDE:Eclipse Oxygen
> JDK:1.8
No matter how I execute the program(including debug and run) before I building it by ant,HTTP transports characters normally.
No errors occurred during building.
It can also receive messages from ActiveMQ normally.I can even log those characters correctly before transporting it.
Where's the problem?
| 0debug
|
static void local_mapped_file_attr(FsContext *ctx, const char *path,
struct stat *stbuf)
{
FILE *fp;
char buf[ATTR_MAX];
char attr_path[PATH_MAX];
local_mapped_attr_path(ctx, path, attr_path);
fp = local_fopen(attr_path, "r");
if (!fp) {
return;
}
memset(buf, 0, ATTR_MAX);
while (fgets(buf, ATTR_MAX, fp)) {
if (!strncmp(buf, "virtfs.uid", 10)) {
stbuf->st_uid = atoi(buf+11);
} else if (!strncmp(buf, "virtfs.gid", 10)) {
stbuf->st_gid = atoi(buf+11);
} else if (!strncmp(buf, "virtfs.mode", 11)) {
stbuf->st_mode = atoi(buf+12);
} else if (!strncmp(buf, "virtfs.rdev", 11)) {
stbuf->st_rdev = atoi(buf+12);
}
memset(buf, 0, ATTR_MAX);
}
fclose(fp);
}
| 1threat
|
a program to sum 2 arrays and display output in third array .Error: 'c' was not declared in this scope : Why it's giving error that 'c' was not declared in this scope ? Logically 'c' is declared before the for loop, so it can be accessed inside the for loop. Isn't it ?This is a program to sum 2 arrays and display output in third array.
I also wanted to know if this code could be optimized ?
void sumOfTwoArrays(int arr[], int size1, int brr[], int size2, int crr[]){
if(size1>size2){
int crr[size1+1];
int c = size1;
}
else{
int crr[size2+1];
int c = size2;
}
int r = 0;
for(int i=size1-1,j=size2-1;i>=0&&j>=0;i--,j--){
int n = arr[i] + brr[j] + r;
if(n<=9){
crr[c] = n;
}
else
{
int r = n/10;
n = n%10;
crr[c] = n;
}
c--;
}
while(arr[i]>=0){
crr[c] = arr[i] + r;
r = 0;
c--;
}
while(brr[j]>=0){
crr[c] = brr[j] + r;
r = 0;
c--;
}
if(r!=0){
crr[c] = r;
}
}
| 0debug
|
PERL - Receive JSON and render on template : I'm trying to expand some app, but I never used Perl before. This uses de framework Mojolicious.
use JSON::XS;
use JSON qw( decode_json );
my $self = shift;
my $req = HTTP::Request->new("GET", "https://jsonplaceholder.typicode.com/comments");
my $ua = LWP::UserAgent->new(
keep_alive => 1,
timeout => 3000,
ssl_opts => {
verify_hostname => 0,
SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE
},
);
my $response = $ua->request($req);
my $body = $response->decoded_content();
my $json = JSON->new();
my $tempHash = $json->decode($body);
At the moment I tried to do something like this, however I'm kinda stuck.
The expected result would allow me to send the data (array?) to the template, in order to create a table.
$self->stash(
'comments' => $comments
);
$self->render('view_');
return;
Thanks
| 0debug
|
how to print "Hello [your_name]" in output screen of python? : <p>"" these quotes are included in python's basic structure.
What if we want output with these quotes like I mentioned in question?</p>
| 0debug
|
React-router-dom and Redirect not being added to history? : <p><strong>Outline:</strong></p>
<p>I'm currently trying to learn <code>react/redux/router</code>. As a practice project, I'm working on a basic contact/client management app. While using <code>react-router-dom</code>s <code>Redirect</code> component. I can't get the back/forward navigation to work as expected.</p>
<p><strong>Details:</strong></p>
<p>I have a table with a list of entries located at <code>/contacts/</code> and when you click on one of the table rows, I want to <code>Redirect</code> using a value set by the <code><tr></code>s onClick attribute.</p>
<p>The click on <code><tr key={d._id} onClick={()=>this.setState({ id: d._id })}></code> changes <code>state.id</code> to the <code>clientID</code>s unique value. This results in a <code>Redirect</code> being true in the tables render method, triggering the <code>Redirect</code>.</p>
<pre><code>render() { // render method of '/contacts/' {Contacts} component
return(
... // table head
{ this.state.id && <Redirect to={"/contacts/card/"+this.state.id}/> }
...// table content
)
}
</code></pre>
<p>This is the router which is located in the parent <code>App.js</code></p>
<pre><code>render() {
return (
<BrowserRouter basename="/" >
<div>
<NavBar/>
<main>
<Switch>
<Route exact path="/" component={Login}/>
<Route
exact path="/contacts" component={Contacts}/>
<Route
exact
path="/contacts/card/:clientID" component={ContactCard}/>
</Switch>
</main>
</div>
</BrowserRouter>
);
}
</code></pre>
<p><strong>Question:</strong></p>
<p>After the redirect, if you click the back button from <code>/contacts/card/:clientID</code>, the browser doesn't go back to <code>/contacts/</code>. instead, it cycles through any previous <code>:clientID</code> URLs that I've looked at.</p>
<p>I have tried wrapping the <code><tr></code> in a router <code><Link to={}></code> tag, but it destroyed styles.</p>
<p><strong>Caveat:</strong> (<code>this.state.id</code>)</p>
<p>I know that I should be using <code>Redux</code> to hold the value of <code>this.state.id</code> for my redirect function. I haven't fully grasped how to mange multiple values with a single redux reducer yet. I will update question with the appropriate method once I do.</p>
| 0debug
|
static void dec_sl(DisasContext *dc)
{
if (dc->format == OP_FMT_RI) {
LOG_DIS("sli r%d, r%d, %d\n", dc->r1, dc->r0, dc->imm5);
} else {
LOG_DIS("sl r%d, r%d, r%d\n", dc->r2, dc->r0, dc->r1);
}
if (!(dc->env->features & LM32_FEATURE_SHIFT)) {
cpu_abort(dc->env, "hardware shifter is not available\n");
}
if (dc->format == OP_FMT_RI) {
tcg_gen_shli_tl(cpu_R[dc->r1], cpu_R[dc->r0], dc->imm5);
} else {
TCGv t0 = tcg_temp_new();
tcg_gen_andi_tl(t0, cpu_R[dc->r1], 0x1f);
tcg_gen_shl_tl(cpu_R[dc->r2], cpu_R[dc->r0], t0);
tcg_temp_free(t0);
}
}
| 1threat
|
Where are logs located? : <p>I'm debugging a JSON endpoint and need to view internal server errors. However, my <code>app/storage/logs</code> dir is empty and it seems there are no other directories dedicated to logs in the project. I've tried googling the subject to no avail.</p>
<p>How can I enable logging, if it's not already enabled and view the logs?</p>
| 0debug
|
Card Hangover C : <p>I am trying to do this problem: <a href="http://poj.org/problem?id=1003" rel="nofollow">http://poj.org/problem?id=1003</a> </p>
<pre><code> #include <stdio.h>
int c;
int a = 0;
int i;
int main()
{
scanf("%.2f", &c);
if (0.01 <= c <= 5.20){
for (i = 1; a < c; ++i){
a += (1/(i + 1));
}
printf("%d card(s)", i + 1);
}
return 0;
}
</code></pre>
<p>My code isn't working? For some reason it always returns 2 card(s) no matter what I enter. Can someone find the problem?</p>
<p>Thanks!</p>
| 0debug
|
How can I change my ui object fron main.cpp in qt? : I have a Qt project including a mainwindow object. I need to change a textEdit's text in ui while I'm in main.cpp. How should I get access to it?
I tried making the ui object public in my mainwindow.h but didn't work.
| 0debug
|
static void common_end(SnowContext *s){
av_freep(&s->spatial_dwt_buffer);
av_freep(&s->mb_band.buf);
av_freep(&s->mv_band[0].buf);
av_freep(&s->mv_band[1].buf);
av_freep(&s->m.me.scratchpad);
av_freep(&s->m.me.map);
av_freep(&s->m.me.score_map);
av_freep(&s->mb_type);
av_freep(&s->mb_mean);
av_freep(&s->dummy);
av_freep(&s->motion_val8);
av_freep(&s->motion_val16);
}
| 1threat
|
EF Core Add function returns negative id : <p>I noticed a weird thing today when I tried to save an entity and return its id in EF Core </p>
<p>Before:
<a href="https://i.stack.imgur.com/gdLcO.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gdLcO.png" alt="The Id is 0 before it was added to database"></a>
After:
<a href="https://i.stack.imgur.com/C8YKv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/C8YKv.png" alt="Now the id has been changed to a negative value"></a></p>
<p>I was thinking about if it was before calling saveChanges() but it works with another entity with a similar setup.</p>
<p>ps: I use unit of work to save all changes at the end.</p>
<p>What was the reason?</p>
| 0debug
|
Why isn't this recursion working in Java? : <p>I am trying to calculate the factorial of the integer user inputs, but it does not return anything. Why?</p>
<p>Thanks.</p>
<pre><code> import java.util.Scanner;
`class App {
public static int factorial(int n) {
if (n == 0) {
return 1;
} else {
int recurse = factorial(n - 1);
int result = n * recurse;
return result;
}
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter an integer to calculate its factorial: ");
int users = input.nextInt();
factorial(users);
}
}
</code></pre>
| 0debug
|
Changing HTML image size with Javascript : <p>So I am trying to create a select menu for changing the size of an image but I have no idea whats wrong with this piece of code or how to fix it.</p>
<p>HTML:</p>
<pre><code><img id="dogpicture" src="dog1.png" alt="dog" height="150" width="150"></img>
<select id="dogsize" name="sizeofdog" onchange="dogsize(this.value);">
<option value="small"> small </option>
<option value="default" selected> default </option>
<option value="big"> big </option>
</select>
</code></pre>
<p>JS:</p>
<pre><code>function dogsize(option){
if (option == "small"){
document.getElementById('dogpicture').height = "50";
document.getElementById('dogpicture').width = "50";
}
if (option == "default"){
document.getElementById('dogpicture').height = "100";
document.getElementById('dogpicture').width = "100";
}
if (option == "big"){
document.getElementById('dogpicture').height = "150";
document.getElementById('dogpicture').width = "150";
}
}
</code></pre>
| 0debug
|
Extacting python List : I have a pandas data frame which has strings in it like this
ID value
1 2
2 25,35
3 1,25,3,40
I would like to count the number of times each value occurs.
The values are strings not integers or floats
Any help is greatly appreciated.
thank you,
| 0debug
|
Angular2 parse string to html : <p>I'm importing rss items where in description there is a lot of html code (links, paragraphs, etc...). When I'm viewing it in component's view like:</p>
<pre><code>{{rss.description}}
</code></pre>
<p>the output in site is like:</p>
<pre><code><a href="http://link.com">Something</a> <p>Long text</p>
</code></pre>
<p>How can I quickly and easy parse it to html? I don't want to cross it with jQuery. Thank you</p>
| 0debug
|
Using scilearn to decide if a given text is similiar to previously learnt texts : I am a newbie to skilearn.
What I want to do is quite simple - just feed my model with a bunch of similiar texts.
Then, I want to be able to give it a new text, and see if it is similiar to the existing texts in the dataset.
How should this be done?
Thanks very much in advance.
| 0debug
|
How to set Auto Reconnect with Unified Topology : <p>After setting <code>useUnifiedTopology=true</code>, the Auto Reconnect stopped working and generates the following ERRORS:</p>
<pre><code>DeprecationWarning: The option `reconnectInterval` is incompatible with the unified topology
DeprecationWarning: The option `reconnectTries` is incompatible with the unified topology
DeprecationWarning: The option `autoReconnect` is incompatible with the unified topology
</code></pre>
<p>How can i get the server to auto-reconnect with that new flag?</p>
<p>I'm using <code>mongoose.createConnection</code> to connect with the following options:</p>
<pre><code>{
autoReconnect: true,
keepAliveInitialDelay: 300000,
connectTimeoutMS: 300000,
reconnectTries: Number.MAX_VALUE,
reconnectInterval: 1000,
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
poolSize: 10,
auth: {
authSource: "admin"
},
user: process.env.MONGO_USER,
pass: process.env.MONGO_PASS
}
</code></pre>
| 0debug
|
static void ir2_decode_plane_inter(Ir2Context *ctx, int width, int height, uint8_t *dst, int stride,
const uint8_t *table)
{
int j;
int out = 0;
int c;
int t;
for (j = 0; j < height; j++){
out = 0;
while (out < width){
c = ir2_get_code(&ctx->gb);
if(c > 0x80) {
c -= 0x80;
out += c * 2;
} else {
t = dst[out] + (table[c * 2] - 128);
CLAMP_TO_BYTE(t);
dst[out] = t;
out++;
t = dst[out] + (table[(c * 2) + 1] - 128);
CLAMP_TO_BYTE(t);
dst[out] = t;
out++;
}
}
dst += stride;
}
}
| 1threat
|
How to inject mobx store into a stateless component : <p>I am using <code>mobx</code> and <code>react</code> in a web application and I want to find a way to pass <code>mobx</code> store state to a stateless component. Below is my current component source code:</p>
<pre><code>import React from 'react';
import Panel from './Panel';
import {inject, observer} from 'mobx-react';
@inject(allStores => ({
form: allStores.store.form,
}))
@observer
export default class Creator extends React.Component {
connect() {
console.log(this.props.form);
};
render() {
return (
<Panel form={this.props.form} connect={this.connect.bind(this)}/>
);
}
};
</code></pre>
<p>How can I change it to be stateless? I tried below code but didn't work:</p>
<pre><code>const Creator = ({form}) => {
const connect = ()=>{
console.log('xxxx,', form);
}
return (
<Panel form={form} connect={connect}/>
);
}
export default observer(Creator);
</code></pre>
<p>when I run above code, I got <code>undefined</code> value for <code>form</code> on the <code>connect</code> method. How can I inject the store into stateless component? I tried to use <code>@inject</code> on top of stateless component, but got a syntax error.</p>
| 0debug
|
How to use Xamarin forms' Button.ContentLayout property? : <p>Using the latest pre-release, I noticed that the button now has a Button.ContentLayout property, which I am hoping will allow us to add custom views to buttons whilst retaining the rest of the buttons functionality.</p>
<p>The questions are, is this what this is for? And if so, how is it used?</p>
<p>Kind Regards</p>
<p>Brian</p>
| 0debug
|
How do i know if there are records stored in my mysql database? : <p>I have 2 php files. One of them creates a table and inserts data into MySql using php. The other php selects the table in the database and outputs the data from the table. The table is outputting 0 results as in there aren't any record being stored into the table.</p>
<p><strong>Need help, Thanks!</strong></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>//select from table
$sql = "SELECT * FROM post02";
$result = mysql_query($link, $sql);
echo 'selecting table works';
//output from table
if (mysql_num_rows($result) > 0) {
while($row = mysql_fetch_assoc($result)) {
echo "id: " . $row["id"]. " - Name: " . $row["title"]. " " . $row["content"]. "" . $row["date"]."<br>";
}
} else {
echo "0 results";
}
</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>// create a table
$sql="create table post02(id INT(6) unsigned auto_increment primary key , title varchar(30) not null, content varchar(255) not null, date TIMESTAMP)";
$result = mysql_query($sql);
if (! $result ) {
die ( 'Cant create table : ' . mysql_error ());
}
echo 'Created a table successfuly' ;
//insert to table
echo'insert table - initializing';
if($_POST['submit']){
$title = $_POST['title'];
$content = $_POST['content'];
$date = date('l jS \of F Y h:i:s A');
}
$sql = "INSERT INTO post02(title, content, date) VALUES ($title, $content,$date))";
if($title =="" || $content=="" ){
echo "please compelete your post!";
return;
}
echo'insert table completed';
mysql_query($db ,$sql);
header("location: viewblog.php");</code></pre>
</div>
</div>
</p>
| 0debug
|
static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host)
{
int ret, rc = 0;
unsigned int xh_len;
int xh_flags;
if (!XBZRLE.decoded_buf) {
XBZRLE.decoded_buf = g_malloc(TARGET_PAGE_SIZE);
}
xh_flags = qemu_get_byte(f);
xh_len = qemu_get_be16(f);
if (xh_flags != ENCODING_FLAG_XBZRLE) {
fprintf(stderr, "Failed to load XBZRLE page - wrong compression!\n");
return -1;
}
if (xh_len > TARGET_PAGE_SIZE) {
fprintf(stderr, "Failed to load XBZRLE page - len overflow!\n");
return -1;
}
qemu_get_buffer(f, XBZRLE.decoded_buf, xh_len);
ret = xbzrle_decode_buffer(XBZRLE.decoded_buf, xh_len, host,
TARGET_PAGE_SIZE);
if (ret == -1) {
fprintf(stderr, "Failed to load XBZRLE page - decode error!\n");
rc = -1;
} else if (ret > TARGET_PAGE_SIZE) {
fprintf(stderr, "Failed to load XBZRLE page - size %d exceeds %d!\n",
ret, TARGET_PAGE_SIZE);
abort();
}
return rc;
}
| 1threat
|
Not adding recyclerview to android studio : Unfortunately, recyclerview does not add to my project either online or offline.
[shot][1]
[1]: http://uupload.ir/files/whv_image.png
| 0debug
|
connection.query('SELECT * FROM users WHERE username = ' + input_string)
| 1threat
|
how can i clear a stack in c++ efficiently? : <p>I have a c++ stack named pages.
As I have no clear() function to clear a stack, I wrote the following code:</p>
<pre><code>stack<string> pages;
//here is some operation
//now clearing the stack
while(!pages.empty())
pages.pop();
</code></pre>
<p>Now my question: is there a better efficient way to clear the stack?
Thanks in advance. </p>
| 0debug
|
keycloak - CODE_TO_TOKEN_ERROR after user is authenticated : <p>I am working with the nodeJS keycloak adapter and so far have my client application redirecting to the keycloak login.</p>
<p>When attempting to login, I get an error in the keycloak logs as follows:</p>
<blockquote>
<p>12:07:12,341 WARN [org.keycloak.events] (default task-30)
type=CODE_TO_TOKEN_ERROR, realmId=myrealm, clientId=client-test,
userId=xxx, ipAddress=xxx.xxx.xxx.xx,
error=invalid_code, grant_type=authorization_code,
code_id=xxx,
client_auth_method=client-secret</p>
</blockquote>
<p>The error message sent back to my express application reads as 'Could not obtain grant code'.</p>
<p>Can someone shed some light on what this means exactly? I can only think I have configured something incorrectly in my realm\client\user settings.</p>
<p>Thanks</p>
| 0debug
|
Access Token for Dockerhub : <p>I created a repository on <code>hub.docker.com</code> and now want to push my image to the Dockerhub using my credentials. I am wondering whether I have to use my username and password or whether I can create some kind of access token to push the docker image.</p>
<p>What I want to do is using the <code>docker-image</code> resource from Concourse to push an image to Dockerhub. Therefore I have to configure credentials like:</p>
<pre><code>type: docker-image
source:
email: {{docker-hub-email}}
username: {{docker-hub-username}}
password: {{docker-hub-password}}
repository: {{docker-hub-image-dummy-resource}}
</code></pre>
<p>and I don't want to use my Dockerhub password for that.</p>
| 0debug
|
How create differents objects with a constructor list : I have a list which has differents constructors of differents classes.But the constructors always return me the same object because they have the same memory direction.
I have something like this:
l=[class1(),class2(),class3()]
l2 = []
if I try to create differents objects with it, it returns the same object with the same memory direction. I mean, I'm doing this:
for i in range(50):
obj = l[random]
l2.append(obj)
l2 has 50 objects but all the objects of the first class are the same and they have the same memory direction. Same happens with the other classes.
I would like to have 50 differents objects.
| 0debug
|
How does `db.serialize` work in `node-sqlite3` : <p>Recently I'm learning to use node and <a href="https://github.com/mapbox/node-sqlite3" rel="noreferrer">node-sqlite3</a> to manipulate sqlite3, here is a sample.</p>
<pre><code>var sqlite3 = require('sqlite3');
var db = new sqlite3.Database(':memory:');
db.serialize(function() {
db.run("CREATE TABLE test(info TEXT)");
db.run("INSERT INTO test (info) VALUES ('info1')");
})
db.close();
</code></pre>
<p>The documentation said that <code>db.serialized</code> was used to ensure SQL lines were executed in order, but I was confused, why wouldn't they get executed in order without <code>db.serialize</code>, after all they would be pulled from the event queue and executed in order? How does it work here?</p>
<p>And if there is only one sql to be executed, is it safe to run it without <code>db.serialize</code> as follows?</p>
<pre><code>var sqlite3 = require('sqlite3');
var db = new sqlite3.Database(':memory:');
db.run("CREATE TABLE test(info TEXT)");
db.close();
</code></pre>
| 0debug
|
find element in std::vector which is also resent in in a std::map : I would like to get an iterator of each element in a `std::vector` that's also present in a `std::map` (as `.first`). How would I best go about this in an efficient manner?
| 0debug
|
How to combine PHP and HTML files to access/manipulate database : <p><strong>Goal:</strong></p>
<p>I am trying to create a web app that will access to my database, and be able to SELECT, INSERT, UPDATE and DELETE records. I am new to using databases and PHP, and have looked at other questions trying to make a breakthrough in my understanding, so please be kind and don't mark this as a duplicate.</p>
<hr>
<p><strong>Problem:</strong></p>
<p>I have an html file containing my webpage that is a scheduling tool, where users can plan meetings with others. I have created a database and understand the PHP code to manipulate that database, but I don't know where to do this.</p>
<hr>
<p><strong>Question:</strong></p>
<p>Say, for example, I have a PHP function that takes in a meeting time, and meeting description, and logs it into the database (not exactly what I'm trying to do but will be good enough for me to understand). I want it so that when a user clicks a segment on my page and logs in that meeting info, for it to call that PHP function and log in the data. Currently, I have one html file and 3 js files containing all the information for my page. I see that html information can be put into a php file, but not vice versa. So, do I:</p>
<p><strong>A.)</strong> Create a separate php file with all of the functions I will need to manipulate my database, and call those functions from my html and javascript files?</p>
<p><strong>B.)</strong> Create my entire page in a php file, rather than an html file, so I can intersperse snippets of php to manipulate my database?</p>
<p><strong>C.)</strong> I'm not understanding it correctly and there is something else I should do?</p>
<p>I understand this is a very basic question but I haven't found an answer that has enlightened me thus far, and I think this could be a useful question for beginners in the future.</p>
| 0debug
|
Get date prior to 30 days from today and prior to 12 months from today : <p>I want to get date prior to 30 days from today and prior to 12 months from today. How Do I do that and format as mm/dd/yyyy</p>
<p>This is what I have done to set current date so far:</p>
<pre><code> var today = new Date();
var dd = today.getDate();
var mm = today.getMonth() + 1;
var yyyy = today.getFullYear();
if (dd<10)
dd = '0'+dd;
if (mm<10)
mm = '0'+mm;
today = mm+'/'+dd+'/'+yyyy;
</code></pre>
| 0debug
|
static void test_redirector_tx(void)
{
#ifndef _WIN32
int backend_sock[2], recv_sock;
char *cmdline;
uint32_t ret = 0, len = 0;
char send_buf[] = "Hello!!";
char sock_path0[] = "filter-redirector0.XXXXXX";
char sock_path1[] = "filter-redirector1.XXXXXX";
char *recv_buf;
uint32_t size = sizeof(send_buf);
size = htonl(size);
ret = socketpair(PF_UNIX, SOCK_STREAM, 0, backend_sock);
g_assert_cmpint(ret, !=, -1);
ret = mkstemp(sock_path0);
g_assert_cmpint(ret, !=, -1);
ret = mkstemp(sock_path1);
g_assert_cmpint(ret, !=, -1);
cmdline = g_strdup_printf("-netdev socket,id=qtest-bn0,fd=%d "
"-device rtl8139,netdev=qtest-bn0,id=qtest-e0 "
"-chardev socket,id=redirector0,path=%s,server,nowait "
"-chardev socket,id=redirector1,path=%s,server,nowait "
"-chardev socket,id=redirector2,path=%s,nowait "
"-object filter-redirector,id=qtest-f0,netdev=qtest-bn0,"
"queue=tx,outdev=redirector0 "
"-object filter-redirector,id=qtest-f1,netdev=qtest-bn0,"
"queue=tx,indev=redirector2 "
"-object filter-redirector,id=qtest-f2,netdev=qtest-bn0,"
"queue=tx,outdev=redirector1 "
, backend_sock[1], sock_path0, sock_path1, sock_path0);
qtest_start(cmdline);
g_free(cmdline);
recv_sock = unix_connect(sock_path1, NULL);
g_assert_cmpint(recv_sock, !=, -1);
qmp("{ 'execute' : 'query-status'}");
struct iovec iov[] = {
{
.iov_base = &size,
.iov_len = sizeof(size),
}, {
.iov_base = send_buf,
.iov_len = sizeof(send_buf),
},
};
ret = iov_send(backend_sock[0], iov, 2, 0, sizeof(size) + sizeof(send_buf));
g_assert_cmpint(ret, ==, sizeof(send_buf) + sizeof(size));
close(backend_sock[0]);
ret = qemu_recv(recv_sock, &len, sizeof(len), 0);
g_assert_cmpint(ret, ==, sizeof(len));
len = ntohl(len);
g_assert_cmpint(len, ==, sizeof(send_buf));
recv_buf = g_malloc(len);
ret = qemu_recv(recv_sock, recv_buf, len, 0);
g_assert_cmpstr(recv_buf, ==, send_buf);
g_free(recv_buf);
close(recv_sock);
unlink(sock_path0);
unlink(sock_path1);
qtest_end();
#endif
}
| 1threat
|
git - ignore the modified files in site1 : we have site1 & site2 .
From site 2 , when we tried to pull using below command, we got below error :
**git pull staging development**
[![enter image description here][1]][1]
[![enter image description here][3]][3]
so we tried this command : **git stash pop**
now it displaying like this :
[![enter image description here][2]][2]
I want all site1 changes to be overrided by site2.
[1]: http://i.stack.imgur.com/trRop.png
[2]: http://i.stack.imgur.com/uyJh8.png
[3]: http://i.stack.imgur.com/W48re.png
| 0debug
|
static int adpcm_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
ADPCMContext *c = avctx->priv_data;
ADPCMChannelStatus *cs;
int n, m, channel, i;
int block_predictor[2];
short *samples;
short *samples_end;
uint8_t *src;
int st;
unsigned char last_byte = 0;
unsigned char nibble;
int decode_top_nibble_next = 0;
int diff_channel;
uint32_t samples_in_chunk;
int32_t previous_left_sample, previous_right_sample;
int32_t current_left_sample, current_right_sample;
int32_t next_left_sample, next_right_sample;
int32_t coeff1l, coeff2l, coeff1r, coeff2r;
uint8_t shift_left, shift_right;
int count1, count2;
if (!buf_size)
return 0;
if(*data_size/4 < buf_size + 8)
return -1;
samples = data;
samples_end= samples + *data_size/2;
*data_size= 0;
src = buf;
st = avctx->channels == 2 ? 1 : 0;
switch(avctx->codec->id) {
case CODEC_ID_ADPCM_IMA_QT:
n = (buf_size - 2);
channel = c->channel;
cs = &(c->status[channel]);
cs->predictor = (*src++) << 8;
cs->predictor |= (*src & 0x80);
cs->predictor &= 0xFF80;
if(cs->predictor & 0x8000)
cs->predictor -= 0x10000;
cs->predictor = av_clip_int16(cs->predictor);
cs->step_index = (*src++) & 0x7F;
if (cs->step_index > 88){
av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index);
cs->step_index = 88;
}
cs->step = step_table[cs->step_index];
if (st && channel)
samples++;
for(m=32; n>0 && m>0; n--, m--) {
*samples = adpcm_ima_expand_nibble(cs, src[0] & 0x0F, 3);
samples += avctx->channels;
*samples = adpcm_ima_expand_nibble(cs, (src[0] >> 4) & 0x0F, 3);
samples += avctx->channels;
src ++;
}
if(st) {
c->channel = (channel + 1) % 2;
if(channel == 1) {
return src - buf;
}
}
break;
case CODEC_ID_ADPCM_IMA_WAV:
if (avctx->block_align != 0 && buf_size > avctx->block_align)
buf_size = avctx->block_align;
samples_per_block= (block_align-4*chanels)*8 / (bits_per_sample * chanels) + 1;
for(i=0; i<avctx->channels; i++){
cs = &(c->status[i]);
cs->predictor = (int16_t)(src[0] + (src[1]<<8));
src+=2;
XXX: is this correct ??: *samples++ = cs->predictor;
cs->step_index = *src++;
if (cs->step_index > 88){
av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index);
cs->step_index = 88;
}
if (*src++) av_log(avctx, AV_LOG_ERROR, "unused byte should be null but is %d!!\n", src[-1]);
}
while(src < buf + buf_size){
for(m=0; m<4; m++){
for(i=0; i<=st; i++)
*samples++ = adpcm_ima_expand_nibble(&c->status[i], src[4*i] & 0x0F, 3);
for(i=0; i<=st; i++)
*samples++ = adpcm_ima_expand_nibble(&c->status[i], src[4*i] >> 4 , 3);
src++;
}
src += 4*st;
}
break;
case CODEC_ID_ADPCM_4XM:
cs = &(c->status[0]);
c->status[0].predictor= (int16_t)(src[0] + (src[1]<<8)); src+=2;
if(st){
c->status[1].predictor= (int16_t)(src[0] + (src[1]<<8)); src+=2;
}
c->status[0].step_index= (int16_t)(src[0] + (src[1]<<8)); src+=2;
if(st){
c->status[1].step_index= (int16_t)(src[0] + (src[1]<<8)); src+=2;
}
if (cs->step_index < 0) cs->step_index = 0;
if (cs->step_index > 88) cs->step_index = 88;
m= (buf_size - (src - buf))>>st;
for(i=0; i<m; i++) {
*samples++ = adpcm_ima_expand_nibble(&c->status[0], src[i] & 0x0F, 4);
if (st)
*samples++ = adpcm_ima_expand_nibble(&c->status[1], src[i+m] & 0x0F, 4);
*samples++ = adpcm_ima_expand_nibble(&c->status[0], src[i] >> 4, 4);
if (st)
*samples++ = adpcm_ima_expand_nibble(&c->status[1], src[i+m] >> 4, 4);
}
src += m<<st;
break;
case CODEC_ID_ADPCM_MS:
if (avctx->block_align != 0 && buf_size > avctx->block_align)
buf_size = avctx->block_align;
n = buf_size - 7 * avctx->channels;
if (n < 0)
return -1;
block_predictor[0] = av_clip(*src++, 0, 7);
block_predictor[1] = 0;
if (st)
block_predictor[1] = av_clip(*src++, 0, 7);
c->status[0].idelta = (int16_t)((*src & 0xFF) | ((src[1] << 8) & 0xFF00));
src+=2;
if (st){
c->status[1].idelta = (int16_t)((*src & 0xFF) | ((src[1] << 8) & 0xFF00));
src+=2;
}
c->status[0].coeff1 = AdaptCoeff1[block_predictor[0]];
c->status[0].coeff2 = AdaptCoeff2[block_predictor[0]];
c->status[1].coeff1 = AdaptCoeff1[block_predictor[1]];
c->status[1].coeff2 = AdaptCoeff2[block_predictor[1]];
c->status[0].sample1 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00));
src+=2;
if (st) c->status[1].sample1 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00));
if (st) src+=2;
c->status[0].sample2 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00));
src+=2;
if (st) c->status[1].sample2 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00));
if (st) src+=2;
*samples++ = c->status[0].sample1;
if (st) *samples++ = c->status[1].sample1;
*samples++ = c->status[0].sample2;
if (st) *samples++ = c->status[1].sample2;
for(;n>0;n--) {
*samples++ = adpcm_ms_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F);
*samples++ = adpcm_ms_expand_nibble(&c->status[st], src[0] & 0x0F);
src ++;
}
break;
case CODEC_ID_ADPCM_IMA_DK4:
if (avctx->block_align != 0 && buf_size > avctx->block_align)
buf_size = avctx->block_align;
c->status[0].predictor = (int16_t)(src[0] | (src[1] << 8));
c->status[0].step_index = src[2];
src += 4;
*samples++ = c->status[0].predictor;
if (st) {
c->status[1].predictor = (int16_t)(src[0] | (src[1] << 8));
c->status[1].step_index = src[2];
src += 4;
*samples++ = c->status[1].predictor;
}
while (src < buf + buf_size) {
*samples++ = adpcm_ima_expand_nibble(&c->status[0],
(src[0] >> 4) & 0x0F, 3);
if (st)
*samples++ = adpcm_ima_expand_nibble(&c->status[1],
src[0] & 0x0F, 3);
else
*samples++ = adpcm_ima_expand_nibble(&c->status[0],
src[0] & 0x0F, 3);
src++;
}
break;
case CODEC_ID_ADPCM_IMA_DK3:
if (avctx->block_align != 0 && buf_size > avctx->block_align)
buf_size = avctx->block_align;
if(buf_size + 16 > (samples_end - samples)*3/8)
return -1;
c->status[0].predictor = (int16_t)(src[10] | (src[11] << 8));
c->status[1].predictor = (int16_t)(src[12] | (src[13] << 8));
c->status[0].step_index = src[14];
c->status[1].step_index = src[15];
src += 16;
diff_channel = c->status[1].predictor;
while (1) {
DK3_GET_NEXT_NIBBLE();
adpcm_ima_expand_nibble(&c->status[0], nibble, 3);
DK3_GET_NEXT_NIBBLE();
adpcm_ima_expand_nibble(&c->status[1], nibble, 3);
diff_channel = (diff_channel + c->status[1].predictor) / 2;
*samples++ = c->status[0].predictor + c->status[1].predictor;
*samples++ = c->status[0].predictor - c->status[1].predictor;
DK3_GET_NEXT_NIBBLE();
adpcm_ima_expand_nibble(&c->status[0], nibble, 3);
diff_channel = (diff_channel + c->status[1].predictor) / 2;
*samples++ = c->status[0].predictor + c->status[1].predictor;
*samples++ = c->status[0].predictor - c->status[1].predictor;
}
break;
case CODEC_ID_ADPCM_IMA_WS:
while (src < buf + buf_size) {
if (st) {
*samples++ = adpcm_ima_expand_nibble(&c->status[0],
(src[0] >> 4) & 0x0F, 3);
*samples++ = adpcm_ima_expand_nibble(&c->status[1],
src[0] & 0x0F, 3);
} else {
*samples++ = adpcm_ima_expand_nibble(&c->status[0],
(src[0] >> 4) & 0x0F, 3);
*samples++ = adpcm_ima_expand_nibble(&c->status[0],
src[0] & 0x0F, 3);
}
src++;
}
break;
case CODEC_ID_ADPCM_XA:
c->status[0].sample1 = c->status[0].sample2 =
c->status[1].sample1 = c->status[1].sample2 = 0;
while (buf_size >= 128) {
xa_decode(samples, src, &c->status[0], &c->status[1],
avctx->channels);
src += 128;
samples += 28 * 8;
buf_size -= 128;
}
break;
case CODEC_ID_ADPCM_EA:
samples_in_chunk = AV_RL32(src);
if (samples_in_chunk >= ((buf_size - 12) * 2)) {
src += buf_size;
break;
}
src += 4;
current_left_sample = (int16_t)AV_RL16(src);
src += 2;
previous_left_sample = (int16_t)AV_RL16(src);
src += 2;
current_right_sample = (int16_t)AV_RL16(src);
src += 2;
previous_right_sample = (int16_t)AV_RL16(src);
src += 2;
for (count1 = 0; count1 < samples_in_chunk/28;count1++) {
coeff1l = ea_adpcm_table[(*src >> 4) & 0x0F];
coeff2l = ea_adpcm_table[((*src >> 4) & 0x0F) + 4];
coeff1r = ea_adpcm_table[*src & 0x0F];
coeff2r = ea_adpcm_table[(*src & 0x0F) + 4];
src++;
shift_left = ((*src >> 4) & 0x0F) + 8;
shift_right = (*src & 0x0F) + 8;
src++;
for (count2 = 0; count2 < 28; count2++) {
next_left_sample = (((*src & 0xF0) << 24) >> shift_left);
next_right_sample = (((*src & 0x0F) << 28) >> shift_right);
src++;
next_left_sample = (next_left_sample +
(current_left_sample * coeff1l) +
(previous_left_sample * coeff2l) + 0x80) >> 8;
next_right_sample = (next_right_sample +
(current_right_sample * coeff1r) +
(previous_right_sample * coeff2r) + 0x80) >> 8;
previous_left_sample = current_left_sample;
current_left_sample = av_clip_int16(next_left_sample);
previous_right_sample = current_right_sample;
current_right_sample = av_clip_int16(next_right_sample);
*samples++ = (unsigned short)current_left_sample;
*samples++ = (unsigned short)current_right_sample;
}
}
break;
case CODEC_ID_ADPCM_IMA_AMV:
case CODEC_ID_ADPCM_IMA_SMJPEG:
c->status[0].predictor = *src;
src += 2;
c->status[0].step_index = *src++;
src++;
if (avctx->codec->id == CODEC_ID_ADPCM_IMA_AMV)
src+=4;
while (src < buf + buf_size) {
char hi, lo;
lo = *src & 0x0F;
hi = (*src >> 4) & 0x0F;
if (avctx->codec->id == CODEC_ID_ADPCM_IMA_AMV)
FFSWAP(char, hi, lo);
*samples++ = adpcm_ima_expand_nibble(&c->status[0],
lo, 3);
*samples++ = adpcm_ima_expand_nibble(&c->status[0],
hi, 3);
src++;
}
break;
case CODEC_ID_ADPCM_CT:
while (src < buf + buf_size) {
if (st) {
*samples++ = adpcm_ct_expand_nibble(&c->status[0],
(src[0] >> 4) & 0x0F);
*samples++ = adpcm_ct_expand_nibble(&c->status[1],
src[0] & 0x0F);
} else {
*samples++ = adpcm_ct_expand_nibble(&c->status[0],
(src[0] >> 4) & 0x0F);
*samples++ = adpcm_ct_expand_nibble(&c->status[0],
src[0] & 0x0F);
}
src++;
}
break;
case CODEC_ID_ADPCM_SBPRO_4:
case CODEC_ID_ADPCM_SBPRO_3:
case CODEC_ID_ADPCM_SBPRO_2:
if (!c->status[0].step_index) {
*samples++ = 128 * (*src++ - 0x80);
if (st)
*samples++ = 128 * (*src++ - 0x80);
c->status[0].step_index = 1;
}
if (avctx->codec->id == CODEC_ID_ADPCM_SBPRO_4) {
while (src < buf + buf_size) {
*samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
(src[0] >> 4) & 0x0F, 4, 0);
*samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
src[0] & 0x0F, 4, 0);
src++;
}
} else if (avctx->codec->id == CODEC_ID_ADPCM_SBPRO_3) {
while (src < buf + buf_size && samples + 2 < samples_end) {
*samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
(src[0] >> 5) & 0x07, 3, 0);
*samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
(src[0] >> 2) & 0x07, 3, 0);
*samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
src[0] & 0x03, 2, 0);
src++;
}
} else {
while (src < buf + buf_size && samples + 3 < samples_end) {
*samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
(src[0] >> 6) & 0x03, 2, 2);
*samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
(src[0] >> 4) & 0x03, 2, 2);
*samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
(src[0] >> 2) & 0x03, 2, 2);
*samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
src[0] & 0x03, 2, 2);
src++;
}
}
break;
case CODEC_ID_ADPCM_SWF:
{
GetBitContext gb;
const int *table;
int k0, signmask, nb_bits, count;
int size = buf_size*8;
init_get_bits(&gb, buf, size);
read bits & initial values
nb_bits = get_bits(&gb, 2)+2;
av_log(NULL,AV_LOG_INFO,"nb_bits: %d\n", nb_bits);
table = swf_index_tables[nb_bits-2];
k0 = 1 << (nb_bits-2);
signmask = 1 << (nb_bits-1);
while (get_bits_count(&gb) <= size - 22*avctx->channels) {
for (i = 0; i < avctx->channels; i++) {
*samples++ = c->status[i].predictor = get_sbits(&gb, 16);
c->status[i].step_index = get_bits(&gb, 6);
}
for (count = 0; get_bits_count(&gb) <= size - nb_bits*avctx->channels && count < 4095; count++) {
int i;
for (i = 0; i < avctx->channels; i++) {
similar to IMA adpcm
int delta = get_bits(&gb, nb_bits);
int step = step_table[c->status[i].step_index];
long vpdiff = 0; vpdiff = (delta+0.5)*step/4
int k = k0;
do {
if (delta & k)
vpdiff += step;
step >>= 1;
k >>= 1;
} while(k);
vpdiff += step;
if (delta & signmask)
c->status[i].predictor -= vpdiff;
else
c->status[i].predictor += vpdiff;
c->status[i].step_index += table[delta & (~signmask)];
c->status[i].step_index = av_clip(c->status[i].step_index, 0, 88);
c->status[i].predictor = av_clip_int16(c->status[i].predictor);
*samples++ = c->status[i].predictor;
if (samples >= samples_end) {
av_log(avctx, AV_LOG_ERROR, "allocated output buffer is too small\n");
return -1;
}
}
}
}
src += buf_size;
break;
}
case CODEC_ID_ADPCM_YAMAHA:
while (src < buf + buf_size) {
if (st) {
*samples++ = adpcm_yamaha_expand_nibble(&c->status[0],
src[0] & 0x0F);
*samples++ = adpcm_yamaha_expand_nibble(&c->status[1],
(src[0] >> 4) & 0x0F);
} else {
*samples++ = adpcm_yamaha_expand_nibble(&c->status[0],
src[0] & 0x0F);
*samples++ = adpcm_yamaha_expand_nibble(&c->status[0],
(src[0] >> 4) & 0x0F);
}
src++;
}
break;
case CODEC_ID_ADPCM_THP:
{
int table[2][16];
unsigned int samplecnt;
int prev[2][2];
int ch;
if (buf_size < 80) {
av_log(avctx, AV_LOG_ERROR, "frame too small\n");
return -1;
}
src+=4;
samplecnt = bytestream_get_be32(&src);
for (i = 0; i < 32; i++)
table[0][i] = (int16_t)bytestream_get_be16(&src);
for (i = 0; i < 4; i++)
prev[0][i] = (int16_t)bytestream_get_be16(&src);
if (samplecnt >= (samples_end - samples) / (st + 1)) {
av_log(avctx, AV_LOG_ERROR, "allocated output buffer is too small\n");
return -1;
}
for (ch = 0; ch <= st; ch++) {
samples = (unsigned short *) data + ch;
for (i = 0; i < samplecnt / 14; i++) {
int index = (*src >> 4) & 7;
unsigned int exp = 28 - (*src++ & 15);
int factor1 = table[ch][index * 2];
int factor2 = table[ch][index * 2 + 1];
for (n = 0; n < 14; n++) {
int32_t sampledat;
if(n&1) sampledat= *src++ <<28;
else sampledat= (*src&0xF0)<<24;
sampledat = ((prev[ch][0]*factor1
+ prev[ch][1]*factor2) >> 11) + (sampledat>>exp);
*samples = av_clip_int16(sampledat);
prev[ch][1] = prev[ch][0];
prev[ch][0] = *samples++;
samples += st;
}
}
}
samples -= st;
break;
}
default:
return -1;
}
*data_size = (uint8_t *)samples - (uint8_t *)data;
return src - buf;
}
| 1threat
|
static always_inline void gen_fbcond (DisasContext *ctx,
void* func,
int ra, int32_t disp16)
{
int l1, l2;
TCGv tmp;
l1 = gen_new_label();
l2 = gen_new_label();
if (ra != 31) {
tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_helper_1_1(func, tmp, cpu_fir[ra]);
} else {
tmp = tcg_const_i64(0);
tcg_gen_helper_1_1(func, tmp, tmp);
}
tcg_gen_brcondi_i64(TCG_COND_NE, tmp, 0, l1);
tcg_gen_movi_i64(cpu_pc, ctx->pc);
tcg_gen_br(l2);
gen_set_label(l1);
tcg_gen_movi_i64(cpu_pc, ctx->pc + (int64_t)(disp16 << 2));
gen_set_label(l2);
}
| 1threat
|
run button working, when website will be load : <p>i want with Javascript after website load, automatic run one button click (so run button)</p>
<p><a href="https://i.stack.imgur.com/sVXSm.png" rel="nofollow noreferrer">this is button information and i want this button run when website will be load</a></p>
| 0debug
|
How to get the Gradient and Hessian | Sympy : <p>Here is the situation: I have a symbolic function <strong>lamb</strong> which is function of the elements of the variable z and the functions elements of the variable h. Here is an image of the lamb symbolic function</p>
<p><a href="https://i.stack.imgur.com/ESNXb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ESNXb.png" alt="enter image description here"></a>.</p>
<p>Now I would like the compute the Gradient and Hessian of this function with respect to the variables eta and xi. Of course I googled for it but I could not find a straight way for doing this. What I found is <a href="http://docs.sympy.org/dev/modules/vector/fields.html" rel="noreferrer">here</a>, but as I said it does not seen to be the best approach for this situation. Any idea?
Bellow, the source code. Thanks.</p>
<pre><code>from sympy import Symbol, Matrix, Function, simplify
eta = Symbol('eta')
xi = Symbol('xi')
x = Matrix([[xi],[eta]])
h = [Function('h_'+str(i+1))(x[0],x[1]) for i in range(3)]
z = [Symbol('z_'+str(i+1)) for i in range(3)]
lamb = 0
for i in range(3):
lamb += 1/(2*sigma**2)*(z[i]-h[i])**2
simplify(lamb)
</code></pre>
| 0debug
|
How to implement process of getting updates from a server? : <p>I'm working on an application that will often (for example, once per 5 minutes) ask server for updated version of configuration using HTTP requests.</p>
<p>What is the best way to implement it?</p>
<p>Is <a href="https://developer.android.com/reference/android/app/Service.html" rel="nofollow"><code>Service</code></a> suitable for such case? Or may be just a Thread with a loop would be enough?</p>
| 0debug
|
Using user input from keyboard with raspberry pi : <p>I'm working on a project that takes the user input from the keyboard and test that input based on condition and then do either of two things.
What is the function that is used to input from the keyboard?</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.