problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static XICSState *try_create_xics(const char *type, int nr_servers,
int nr_irqs)
{
DeviceState *dev;
dev = qdev_create(NULL, type);
qdev_prop_set_uint32(dev, "nr_servers", nr_servers);
qdev_prop_set_uint32(dev, "nr_irqs", nr_irqs);
if (qdev_init(dev) < 0) {
return NULL;
}
return XICS_COMMON(dev);
}
| 1threat
|
static void spr_read_tbl(DisasContext *ctx, int gprn, int sprn)
{
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_load_tbl(cpu_gpr[gprn], cpu_env);
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_end();
gen_stop_exception(ctx);
}
}
| 1threat
|
Regex! I need to extract from html : Hey please i need to extract the first image from this html:
> [size=5]test.[/size]
> [size=5]first.[/size]
[img=http://i64.tinypic.com/n337ap.png]
> [size=5]Added:[/size]
[img=http://i63.tinypic.com/2m578i1.png]
[img=http://i65.tinypic.com/ev7653.png]
Example i wanna extract: http://i64.tinypic.com/n337ap.png
Thanks you!
| 0debug
|
How to make Android app from PHP, HTML and Javascript? : <p>I made an web application using PHP, HTML and Javascript.
Now, I want to make it become a Android app.</p>
<p>How to convert an web application into Android app?<br>
What tools I need?</p>
<p>Thanks. </p>
| 0debug
|
void drive_uninit(BlockDriverState *bdrv)
{
DriveInfo *dinfo;
TAILQ_FOREACH(dinfo, &drives, next) {
if (dinfo->bdrv != bdrv)
continue;
qemu_opts_del(dinfo->opts);
TAILQ_REMOVE(&drives, dinfo, next);
qemu_free(dinfo);
break;
}
}
| 1threat
|
I want upload image in https://stroage.3d.io : I want to store mu product image in stroage.3d.io website .how is possible
| 0debug
|
static void test_visitor_in_int(TestInputVisitorData *data,
const void *unused)
{
int64_t res = 0, value = -42;
Visitor *v;
v = visitor_input_test_init(data, "%" PRId64, value);
visit_type_int(v, NULL, &res, &error_abort);
g_assert_cmpint(res, ==, value);
}
| 1threat
|
Compiling and Run C file in Java Application : I am trying to build a Java application that compiles and runs C++ files. It also stores the output of the exe file in a text file. Can anyone provide a complete walk through on how to do it ?
I have already tried the solution provided [here](http://stackoverflow.com/questions/14826814/compiling-and-running-c-program-in-java) and the program showed `compilation successful` message. But I couldn't find the .o file or .exe file in the directory.
| 0debug
|
Get all data from JSON array : <p>I've a little problem with a simple thing.I believe.
this is my code...</p>
<p><a href="http://i.stack.imgur.com/p8A8D.png" rel="nofollow">javascript code</a></p>
<p>I'm able to grab the first object element but I need all the data object, I guess I've to change something in this code line...</p>
<pre><code>value[0]['firstName'];
</code></pre>
| 0debug
|
static hwaddr ppc_hash64_htab_lookup(PowerPCCPU *cpu,
ppc_slb_t *slb, target_ulong eaddr,
ppc_hash_pte64_t *pte, unsigned *pshift)
{
CPUPPCState *env = &cpu->env;
hwaddr hash, ptex;
uint64_t vsid, epnmask, epn, ptem;
const struct ppc_one_seg_page_size *sps = slb->sps;
assert(sps);
if (env->spr[SPR_LPCR] & LPCR_ISL) {
sps = &env->sps.sps[0];
assert(sps->page_shift == 12);
}
epnmask = ~((1ULL << sps->page_shift) - 1);
if (slb->vsid & SLB_VSID_B) {
vsid = (slb->vsid & SLB_VSID_VSID) >> SLB_VSID_SHIFT_1T;
epn = (eaddr & ~SEGMENT_MASK_1T) & epnmask;
hash = vsid ^ (vsid << 25) ^ (epn >> sps->page_shift);
} else {
vsid = (slb->vsid & SLB_VSID_VSID) >> SLB_VSID_SHIFT;
epn = (eaddr & ~SEGMENT_MASK_256M) & epnmask;
hash = vsid ^ (epn >> sps->page_shift);
}
ptem = (slb->vsid & SLB_VSID_PTEM) | ((epn >> 16) & HPTE64_V_AVPN);
ptem |= HPTE64_V_VALID;
qemu_log_mask(CPU_LOG_MMU,
"htab_base " TARGET_FMT_plx " htab_mask " TARGET_FMT_plx
" hash " TARGET_FMT_plx "\n",
env->htab_base, env->htab_mask, hash);
qemu_log_mask(CPU_LOG_MMU,
"0 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=" TARGET_FMT_lx " ptem=" TARGET_FMT_lx
" hash=" TARGET_FMT_plx "\n",
env->htab_base, env->htab_mask, vsid, ptem, hash);
ptex = ppc_hash64_pteg_search(cpu, hash, sps, ptem, pte, pshift);
if (ptex == -1) {
ptem |= HPTE64_V_SECONDARY;
qemu_log_mask(CPU_LOG_MMU,
"1 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=" TARGET_FMT_lx " api=" TARGET_FMT_lx
" hash=" TARGET_FMT_plx "\n", env->htab_base,
env->htab_mask, vsid, ptem, ~hash);
ptex = ppc_hash64_pteg_search(cpu, ~hash, sps, ptem, pte, pshift);
}
return ptex;
}
| 1threat
|
i have given a timer, to start from zero and end at 10th second and after 10th second timer should become 0 : if (coinMag == true)
{
Timer += 1 * Time.deltaTime;
if (Timer >= 10)
{
coinMag = false;
Timer = 0;
}
}
what i want is when the CoinMag is true the timer should start...i have intialized timer as public float Timer=0.0f; ..and after timer starts exactly after 10 seconds timer should be reinitialized to 0.
| 0debug
|
Why does the fit and the partial_fit of the sklearn LatentDirichletAllocation return different results ? : <p>What is strange is that it seems to be exactly the same code for the fit and for the partial_fit. </p>
<p>You can see the code at the following link : </p>
<p><a href="https://github.com/scikit-learn/scikit-learn/blob/c957249/sklearn/decomposition/online_lda.py#L478" rel="noreferrer">https://github.com/scikit-learn/scikit-learn/blob/c957249/sklearn/decomposition/online_lda.py#L478</a></p>
| 0debug
|
static int wmavoice_decode_packet(AVCodecContext *ctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
WMAVoiceContext *s = ctx->priv_data;
GetBitContext *gb = &s->gb;
int size, res, pos;
for (size = avpkt->size; size > ctx->block_align; size -= ctx->block_align);
init_get_bits(&s->gb, avpkt->data, size << 3);
if (!(size % ctx->block_align)) {
if (!size) {
s->spillover_nbits = 0;
s->nb_superframes = 0;
} else {
if ((res = parse_packet_header(s)) < 0)
return res;
s->nb_superframes = res;
}
if (s->sframe_cache_size > 0) {
int cnt = get_bits_count(gb);
copy_bits(&s->pb, avpkt->data, size, gb, s->spillover_nbits);
flush_put_bits(&s->pb);
s->sframe_cache_size += s->spillover_nbits;
if ((res = synth_superframe(ctx, data, got_frame_ptr)) == 0 &&
*got_frame_ptr) {
cnt += s->spillover_nbits;
s->skip_bits_next = cnt & 7;
res = cnt >> 3;
if (res > avpkt->size) {
av_log(ctx, AV_LOG_ERROR,
"Trying to skip %d bytes in packet of size %d\n",
res, avpkt->size);
return AVERROR_INVALIDDATA;
}
return res;
} else
skip_bits_long (gb, s->spillover_nbits - cnt +
get_bits_count(gb));
} else if (s->spillover_nbits) {
skip_bits_long(gb, s->spillover_nbits);
}
} else if (s->skip_bits_next)
skip_bits(gb, s->skip_bits_next);
s->sframe_cache_size = 0;
s->skip_bits_next = 0;
pos = get_bits_left(gb);
if (s->nb_superframes-- == 0) {
*got_frame_ptr = 0;
return size;
} else if (s->nb_superframes > 0) {
if ((res = synth_superframe(ctx, data, got_frame_ptr)) < 0) {
return res;
} else if (*got_frame_ptr) {
int cnt = get_bits_count(gb);
s->skip_bits_next = cnt & 7;
res = cnt >> 3;
if (res > avpkt->size) {
av_log(ctx, AV_LOG_ERROR,
"Trying to skip %d bytes in packet of size %d\n",
res, avpkt->size);
return AVERROR_INVALIDDATA;
}
return res;
}
} else if ((s->sframe_cache_size = pos) > 0) {
init_put_bits(&s->pb, s->sframe_cache, SFRAME_CACHE_MAXSIZE);
copy_bits(&s->pb, avpkt->data, size, gb, s->sframe_cache_size);
}
return size;
}
| 1threat
|
I just converted my project to Swift 3 : override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath) as UITableViewCell
// Configure the cell...
let rowArray:AnyObject = (model.allEmployees() [indexPath.row])
print("ID = \(rowArray[0])")
let fName = rowArray[1] as! String
let lName = rowArray[2] as! String
let fullName = "\(fName)\(lName)"
let phone = rowArray[3] as! String
cell.textLabel?.text = fullName
cell.textLabel?.text = phone
return cell
}
**i am getting an error: "Type [Any] has no subscript members "**
| 0debug
|
static void l2cap_channel_close(struct l2cap_instance_s *l2cap,
int cid, int source_cid)
{
struct l2cap_chan_s *ch = NULL;
if (unlikely(cid < L2CAP_CID_ALLOC)) {
l2cap_command_reject_cid(l2cap, l2cap->last_id, L2CAP_REJ_CID_INVAL,
cid, source_cid);
return;
}
if (likely(cid >= L2CAP_CID_ALLOC && cid < L2CAP_CID_MAX))
ch = l2cap->cid[cid];
if (likely(ch)) {
if (ch->remote_cid != source_cid) {
fprintf(stderr, "%s: Ignoring a Disconnection Request with the "
"invalid SCID %04x.\n", __func__, source_cid);
return;
}
l2cap->cid[cid] = NULL;
ch->params.close(ch->params.opaque);
g_free(ch);
}
l2cap_disconnection_response(l2cap, cid, source_cid);
}
| 1threat
|
unable to push value in an Array in ionic : i am trying to push a value into an array but i am getting error
**Cannot read property 'push' of undefined**
my html code is
<ion-item *ngFor="let item of items" (click)="clicked(item.title)">
{{item.title}}
</ion-item>
</ion-list>
and my ts code is
clicked(item){
this.addedtags.push(item);
console.log(this.addedtags);
}
| 0debug
|
can i parse my json data like this,,? : String json = new Gson().toJson(cList);
JSONArray jasonlist = new JSONArray(json);
Map<String, Object> obj = new HashMap<>();
String dob1 = (String)obj.get("createdDate");
Date dtDob = new Date(dob1);
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
String newDate = sdf.format(dtDob);
obj.put("companymasterdata", jasonlist);
obj.put("EVENTNAME", "COMPANY_DATA");
obj.put( "SOURCENAME", "COMPANY_KAFKA");
i just want to know whether my "createdDate" is parsed or it throw run time errors or not
| 0debug
|
static int dxtory_decode_v1_420(AVCodecContext *avctx, AVFrame *pic,
const uint8_t *src, int src_size)
{
int h, w;
uint8_t *Y1, *Y2, *U, *V;
int ret;
if (src_size < avctx->width * avctx->height * 3 / 2) {
av_log(avctx, AV_LOG_ERROR, "packet too small\n");
return AVERROR_INVALIDDATA;
}
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
return ret;
Y1 = pic->data[0];
Y2 = pic->data[0] + pic->linesize[0];
U = pic->data[1];
V = pic->data[2];
for (h = 0; h < avctx->height; h += 2) {
for (w = 0; w < avctx->width; w += 2) {
AV_COPY16(Y1 + w, src);
AV_COPY16(Y2 + w, src + 2);
U[w >> 1] = src[4] + 0x80;
V[w >> 1] = src[5] + 0x80;
src += 6;
}
Y1 += pic->linesize[0] << 1;
Y2 += pic->linesize[0] << 1;
U += pic->linesize[1];
V += pic->linesize[2];
}
return 0;
}
| 1threat
|
Why $_GET won't work with sessions : I'am getting varriable value from other page and why it's not working.
Here is the code:
Page 1:
<h1 align="center">
<form name="form" action="" method="get">
<input type="text" name="wonorlose" id="wonorlose" value="50">
</form>
</h1>
On button push:
<script>
function rollHead(){
var die1 = document.getElementById("die1");
var status = document.getElementById("status");
var d1 = Math.floor(Math.random() * 2) + 1;
<?php
$_SESSION['wonorlose'] = $_GET["wonorlose"];
?>
if(d1 == 1)
{
die1.innerHTML = "You lose!";
fliped.innerHTML = "Fliped Tail!";
var ajax = new XMLHttpRequest();
ajax.open('POST','lose.php',true);
ajax.send();
}
else if (d1 == 2)
{
die1.innerHTML = "You won!";
fliped.innerHTML = "Fliped Head!";
var ajax = new XMLHttpRequest();
ajax.open('POST','won.php',true);
ajax.send();
}
}
</script>
Page 2:
$_SESSION['wonorlose'] = $wonorlose;
echo $wonorlose;
mysql_query("UPDATE `users` SET money=money+'$wonorlose' WHERE user_id=".$_SESSION['user']);
P.S rool system works and I get message won or lose but nothing happens in my database...
| 0debug
|
How change number of columns in bootstrap 4 : <p>How to change a <strong>number of columns in Bootstrap</strong> 4?</p>
<p></p>
<pre><code></div>
</code></pre>
| 0debug
|
I don't understand what does" double *array[50]" mean? : <p>does it mean that there is an array of 50, and each one of the 50 is a pointer to double? if so then does that mean that array[i] will contain addresses only that point to another place in the heap ?</p>
| 0debug
|
Seperate MYSQL results into seperate HTML Tables : I have the following in which I am trying to make seperate HTML tables after each group:
` $query = "SELECT * FROM NonBillableTime WHERE TimeIn LIKE '$MondayP2%' ORDER BY CreatedUser ASC";
$members = mysql_query($query) or die($query."<br/><br/>".mysql_error());
while ($row = mysql_fetch_assoc($members)) {`
**Example
HTML Table 1 would return everything with CreatedUser number 5
Then the table would end and a new table would start and return everything with the CreatedUser number 6.**
I am facing two issues
1. I don't know ahead how many users I have since it changes.
2. It needs to execute from `while ($row = mysql_fetch_assoc($members)) {` since I am doing other calculations on the fly
*Yes I want to use MYSQL and am aware of adding injection prevention*
| 0debug
|
JavaScript: what's wrong with this code? (Please, help!) : This error is driving me CRAZY. The function throws this error:
> Uncaught ReferenceError: Invalid left-hand side in assignmen*t
Could someone point out ***where*** is the damned error?
function listo()
{
if (document.getElementById('titulo')='') {
AbreSnackBar('Debes especificar un título para esta obra','rojo');
exit();
}
var data=
'titulo=' + document.getElementById('titulo').value +
'&plantilla=' + document.getElementById('plantilla').value +
'&pags=' + document.getElementById('pags').value +
'&genero=' + document.getElementById('gen').value +
'&comp_real=' + document.getElementById('comp_orig').value +
'&ano=' + document.getElementById('ano').value +
'&up_im1=' + document.getElementById('up_im1').value +
'&up_im2=' + document.getElementById('up_im2').value +
'&up_im3=' + document.getElementById('up_im3').value +
'&up_ref=' + document.getElementById('up_ref').value +
'&video=' + document.getElementById('link').value +
'&descr=' + document.getElementById('descr').value +
'&descr_ing=' + document.getElementById('descr_ing').value +
'&minutos=' + document.getElementById('minutos').value +
'&dificultad=' + document.getElementById('dif').value +
'&up_PDF=' + document.getElementById('up_PDF').value +
'&up_RAR=' + document.getElementById('up_RAR').value +
'&up_MUS=' + document.getElementById('up_MUS').value +
'&up_SIB=' + document.getElementById('up_SIB').value +
//'&tags=' + document.getElementById('tags').value +
'&modo=' + document.getElementById('modo').value +
'&id_concurso=' + document.getElementById('id_concurso').value +
'&copias_min=' + document.getElementById('copias_min').value;
AbreSnackBar('Espera...');
$.ajax({
type: "POST", url: "acc_sube_obra.php", data: data ,
success: function (data)
{
alert(data);
switch (data.trim())
{
case '0':
AbreSnackBar('Ocurrió un error','rojo');
break;
default: //id
AbreSnackBar('Bien','verde');
window.location.href = 'http://www.aboutscores.com/obra_subida.php?id='+ data.trim;
}
}
});
}
I've seen that the cause could be that I'm *trying to assign a new value to the result of a function*, but I don't see that's the case.
| 0debug
|
callback() missing 1 required positional argument: 'event' : <p>I am trying to create a Tkinter-GUI for selection of data points for analysis. This GUI will be part of a bigger Python routine that reduces the data.</p>
<p>The data points are numbered sequentially (#1, #2, #3, ...) and there is one checkbutton for each data point. When one button is clicked on, the corresponding data point number should be added to a list, like so [1, 3, 7]. The code I have written is as follows,</p>
<pre><code>"""
GRAPHICAL SELECTION OF DATA POINTS FOR ANALYSIS
"""
# create an empty list of data points
selection = []
# import libraries and modules
from tkinter import *
# create parent window
parent = Tk()
parent.title('SELECT DATA POINTS FOR ANALYSIS')
# create callback functions
def callback1(event):
selection.append(1)
def callback2(event):
selection.append(2)
def callback3(event):
selection.append(3)
def callback4(event):
selection.append(4)
def callback5(event):
selection.append(5)
# create list call
Label(parent,
text="Check data points to be analyzed:",
font=('arial', 12, 'bold')).grid(row=1,column=0,columnspan=11,sticky='w')
# create checkbuttons
button1 = Checkbutton(parent,text='#1',command=callback1) # create widget
button1.grid(row =2,column=0,columnspan=4,sticky='w') # position widget
button1.bind("<Button-1>",callback) # bind widget to left mouse click
button2 = Checkbutton(parent,text='#2',command=callback2)
button2.grid(row =3,column=0,columnspan=4,sticky='w')
button2.bind("<Button-1>",callback)
button3 = Checkbutton(parent,text='#3',command=callback3)
button3.grid(row =4,column=0,columnspan=4,sticky='w')
button3.bind("<Button-1>",callback)
button4 = Checkbutton(parent,text='#4',command=callback4)
button4.grid(row =5,column=0,columnspan=4,sticky='w')
button4.bind("<Button-1>",callback)
button5 = Checkbutton(parent,text='#5',command=callback5)
button5.grid(row =6,column=0,columnspan=4,sticky='w')
button5.bind("<Button-1>",callback)
parent.mainloop()
print("selection =",selection)
</code></pre>
<p>I have created the checkbuttons and bound them to the corresponding callback function. Apparently, the event (left button mouse click) is also correctly specified, i.e. "". </p>
<p>When I run this code, the GUI is properly created and shown. However, upon clicking on any button I get the following error message:</p>
<pre><code>Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\ridim\Anaconda3\lib\tkinter\__init__.py", line 1558, in __call__
return self.func(*args)
TypeError: callback1() missing 1 required positional argument: 'event'
</code></pre>
<p>I am relatively new to Tkinter and I could not figure out what I am doing wrong. The syntax callback is apparently correct and the word "event" appears in the function definitions.</p>
<p>I would be very grateful if someone could tell me what is wrong with my code. In addition, I would like to ask whether there is a more efficient way of setting up the callback functions. Maybe, a single callback function with "if" statements.</p>
<p>Many thanks,</p>
<p>Carvalho</p>
| 0debug
|
Find sudoku grid using OpenCV and Python : <p>I'm trying to detect the grid in sudoku puzzles using OpenCV but I'm having troubles with the last steps (I guess).</p>
<p>What I'm doing is:</p>
<ul>
<li>Downsaple the image</li>
<li>Blur it</li>
<li>Applying a highpass filter (bilateral)</li>
<li>Thresholding the image, using adaptive threshold</li>
<li>Some dilations and erosions</li>
</ul>
<p>All this gives me the following images:</p>
<p><a href="https://i.stack.imgur.com/BoCzp.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/BoCzp.jpg" alt="Original image downsampled and blurred."></a></p>
<p><a href="https://i.stack.imgur.com/DfJio.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/DfJio.jpg" alt="enter image description here"></a></p>
<p>From now on, I need to detect the grid, and I found a few methods of how to do that but none of them gave me the confidence of being robust enough. </p>
<p>The first one is to find lines using Hough transform but I find a lot of spurious lines. </p>
<p><a href="https://i.stack.imgur.com/EZuOj.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/EZuOj.jpg" alt="Hough transform."></a></p>
<p>The other is using connected components, which gives me the best results. I tried to implement RANSAC as a way to get the right centroids, but I'm not having good results and also takes a while to get the answer ("a while" is less than 2 seconds, but later I want to use it in real time video).</p>
<p><a href="https://i.stack.imgur.com/q17rj.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/q17rj.jpg" alt="enter image description here"></a></p>
<p><a href="https://i.stack.imgur.com/ToPpJ.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/ToPpJ.jpg" alt="enter image description here"></a></p>
<p>Any idea how this can be done? I mean, how can I discard the wrong centroids and start solving the sudoku? </p>
| 0debug
|
static void spapr_cpu_core_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
dc->realize = spapr_cpu_core_realize;
}
| 1threat
|
How to compare single string chars in C++? : <p>I wanted to compare two single string variable in my SC and if they were different, I wanted to add +1 to my int data "fights", let's say <em>X[1] = A, Y[1] = B, add +1 to <strong>fights</em></strong>.</p>
<pre><code> int N;
char X;
char Y;
int fights = 0;
1 <= N <= 100000;
for (int i = 0; i < N; i++){
cin >> X[i];
cin >> Y[i];
if (Y[i] != X[i]){
fights += 1;
}
}
cout << fights;
return 0;
}
</code></pre>
<p>However, it seems like the program is not detecting any differences when I input different letters and does not add +1 to <strong><em>fights</em></strong>.</p>
| 0debug
|
What is the difference between QQmlApplicationEngine and QQuickView? : <p>I'm using <code>QQmlApplicationEngine</code> as follows:</p>
<pre><code>QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
app.exec();
</code></pre>
<p>But now I want to enable multisampling for my app, and <code>QQmlApplicationEngine</code> doesn't seem to have a <code>setFormat</code> method for enabling multisampling.</p>
<p>I found a way to do it with a <code>QQmlApplicationEngine</code> <a href="https://v-play.net/developers/forums/t/antialiasing#post-9745" rel="noreferrer">in a forum</a>:</p>
<pre><code>QQuickWindow* window = (QQuickWindow*) engine.rootObjects().first();
QSurfaceFormat format;
format.setSamples(16);
window->setFormat(format)
</code></pre>
<p>But it relies on the first root object of the engine being a <code>QQuickWindow</code>, which is not documented in Qt docs. So I don't want to use that technique.</p>
<p>Another way would be to skip <code>QQmlApplicationEngine</code> and create a <code>QQuickView</code> instead. This does have a <code>setFormat</code> method letting me enable multisampling, but I'm wondering, am I losing anything by switching from <code>QQmlApplicationEngine</code> to <code>QQuickView</code>?</p>
<p>In other words, what are the differences between these two classes?</p>
<p>One difference I found is this (from <a href="http://doc.qt.io/qt-5/qqmlapplicationengine.html#details" rel="noreferrer">here</a>):</p>
<blockquote>
<p>Unlike QQuickView, QQmlApplicationEngine does not automatically create a root window. If you are using visual items from Qt Quick, you will need to place them inside of a Window.</p>
</blockquote>
<p>This particular difference doesn't matter to me.</p>
<p>Any other differences?</p>
| 0debug
|
static void omap2_inth_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) opaque;
int offset = addr;
int bank_no, line_no;
struct omap_intr_handler_bank_s *bank = NULL;
if ((offset & 0xf80) == 0x80) {
bank_no = (offset & 0x60) >> 5;
if (bank_no < s->nbanks) {
offset &= ~0x60;
bank = &s->bank[bank_no];
}
}
switch (offset) {
case 0x10:
s->autoidle &= 4;
s->autoidle |= (value & 1) << 2;
if (value & 2)
omap_inth_reset(s);
return;
case 0x48:
s->mask = (value & 4) ? 0 : ~0;
if (value & 2) {
qemu_set_irq(s->parent_intr[1], 0);
s->new_agr[1] = ~0;
omap_inth_update(s, 1);
}
if (value & 1) {
qemu_set_irq(s->parent_intr[0], 0);
s->new_agr[0] = ~0;
omap_inth_update(s, 0);
}
return;
case 0x4c:
if (value & 1)
fprintf(stderr, "%s: protection mode enable attempt\n",
__FUNCTION__);
return;
case 0x50:
s->autoidle &= ~3;
s->autoidle |= value & 3;
return;
case 0x84:
bank->mask = value;
omap_inth_update(s, 0);
omap_inth_update(s, 1);
return;
case 0x88:
bank->mask &= ~value;
omap_inth_update(s, 0);
omap_inth_update(s, 1);
return;
case 0x8c:
bank->mask |= value;
return;
case 0x90:
bank->irqs |= bank->swi |= value;
omap_inth_update(s, 0);
omap_inth_update(s, 1);
return;
case 0x94:
bank->swi &= ~value;
bank->irqs = bank->swi & bank->inputs;
return;
case 0x100 ... 0x300:
bank_no = (offset - 0x100) >> 7;
if (bank_no > s->nbanks)
break;
bank = &s->bank[bank_no];
line_no = (offset & 0x7f) >> 2;
bank->priority[line_no] = (value >> 2) & 0x3f;
bank->fiq &= ~(1 << line_no);
bank->fiq |= (value & 1) << line_no;
return;
case 0x00:
case 0x14:
case 0x40:
case 0x44:
case 0x80:
case 0x98:
case 0x9c:
OMAP_RO_REG(addr);
return;
}
OMAP_BAD_REG(addr);
}
| 1threat
|
qemu_inject_x86_mce(Monitor *mon, CPUState *cenv, int bank, uint64_t status,
uint64_t mcg_status, uint64_t addr, uint64_t misc,
int flags)
{
uint64_t mcg_cap = cenv->mcg_cap;
uint64_t *banks = cenv->mce_banks + 4 * bank;
if (!(flags & MCE_INJECT_UNCOND_AO) && !(status & MCI_STATUS_AR)
&& (cenv->mcg_status & MCG_STATUS_MCIP)) {
return;
}
if (status & MCI_STATUS_UC) {
if ((mcg_cap & MCG_CTL_P) && cenv->mcg_ctl != ~(uint64_t)0) {
monitor_printf(mon,
"CPU %d: Uncorrected error reporting disabled\n",
cenv->cpu_index);
return;
}
if (banks[0] != ~(uint64_t)0) {
monitor_printf(mon, "CPU %d: Uncorrected error reporting disabled "
"for bank %d\n", cenv->cpu_index, bank);
return;
}
if ((cenv->mcg_status & MCG_STATUS_MCIP) ||
!(cenv->cr[4] & CR4_MCE_MASK)) {
monitor_printf(mon, "CPU %d: Previous MCE still in progress, "
"raising triple fault\n", cenv->cpu_index);
qemu_log_mask(CPU_LOG_RESET, "Triple fault\n");
qemu_system_reset_request();
return;
}
if (banks[1] & MCI_STATUS_VAL) {
status |= MCI_STATUS_OVER;
}
banks[2] = addr;
banks[3] = misc;
cenv->mcg_status = mcg_status;
banks[1] = status;
cpu_interrupt(cenv, CPU_INTERRUPT_MCE);
} else if (!(banks[1] & MCI_STATUS_VAL)
|| !(banks[1] & MCI_STATUS_UC)) {
if (banks[1] & MCI_STATUS_VAL) {
status |= MCI_STATUS_OVER;
}
banks[2] = addr;
banks[3] = misc;
banks[1] = status;
} else {
banks[1] |= MCI_STATUS_OVER;
}
}
| 1threat
|
How to fix "Issue: Violation of Families Policy Requirements" : <p>I've tried to publish an app on Play store but it's rejected and I've received an email titled: "Issue: Violation of Families Policy Requirements"</p>
<p>And it also followed by: "Apps that contain elements that appeal to children must comply with all Families Policy Requirements. We found the following issue(s) with your app:</p>
<p>Eligibility Issue
<>
In order to review your app for “Designed for Families” eligibility, we will need you to provide a test login account. Please provide login credentials to the support team before you submit any updated version for another review (select “Test Login Needed” and include the test login account and password details in the open box field)."</p>
<p>I sent the test login account and password as requested, and I'm sure that my app doesn't violate Families Policy Requirements that includes these items:</p>
<p><a href="https://play.google.com/about/families/children-and-families/families-policy/" rel="noreferrer">https://play.google.com/about/families/children-and-families/families-policy/</a></p>
<p>I've received the same email several time without any further detailed information about this issue.</p>
<p>How can I contact Play_store to Know more about my Problem?</p>
| 0debug
|
How can a file contain null bytes? : <p>How is it possible that files can contain null bytes in operating systems written in a language with null-terminating strings (namely, C)?</p>
<p>For example, if I run this shell code:</p>
<pre><code>$ printf "Hello\00, World!" > test.txt
$ xxd test.txt
0000000: 4865 6c6c 6f00 2c20 576f 726c 6421 Hello., World!
</code></pre>
<p>I see a null byte in <code>test.txt</code> (at least in OS X). If C uses null-terminating strings, and OS X is written in C, then how come the file isn't terminated at the null byte, resulting in the file containing <code>Hello</code> instead of <code>Hello\00, World!</code>? Is there a fundamental difference between files and strings?</p>
| 0debug
|
ARDUINO - how to take photo and measure to pixels of specific color : I am a PhD student in Faculty of Agriculture in Turkey. We are measure the leaf area of some plants in our studies. I have used a method that accepted and give almost realistic result.
I cut off leaves from plants and put them on A4 size white paper as don't touching each other. Then, take pictures vertically from A4 paper with leaves. Later, I get the pictures to Photoshop programme. Select the leaves by color range tool and check the pixel numbers of leaves from histogram. So I have A4 paper real size and pixel number, and I have leaves pixel numbers. I can calculate to realistic leaf area by using these components.
So this manual method is so effective from old methods, but if you have to measure lot of sample, It is also take time a lot. I need to make my own device that arduino based and It has to take pictures and analyse leaf area by pixel counting method as I explain above.
Is it possible to do it with arduino? Any idea will be beneficial for me.
Best regards.
| 0debug
|
Has set been deprecated in python 2? : <p>Has <code>set</code> been deprecated in python?</p>
<p>I am learning python online <a href="http://www.python-course.eu/sets_frozensets.php" rel="nofollow">here</a> and trying to implement the following command - </p>
<pre><code>x = set(["Perl", "Python", "Java"])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'list' object is not callable
</code></pre>
<p>So has it been deprecated in python 2.7?</p>
| 0debug
|
connection.query('SELECT * FROM users WHERE username = ' + input_string)
| 1threat
|
int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
MemoryRegion **ram_memory)
{
int i, rc;
unsigned long ioreq_pfn;
unsigned long bufioreq_evtchn;
XenIOState *state;
state = g_malloc0(sizeof (XenIOState));
state->xce_handle = xen_xc_evtchn_open(NULL, 0);
if (state->xce_handle == XC_HANDLER_INITIAL_VALUE) {
perror("xen: event channel open");
return -1;
}
state->xenstore = xs_daemon_open();
if (state->xenstore == NULL) {
perror("xen: xenstore open");
return -1;
}
state->exit.notify = xen_exit_notifier;
qemu_add_exit_notifier(&state->exit);
state->suspend.notify = xen_suspend_notifier;
qemu_register_suspend_notifier(&state->suspend);
state->wakeup.notify = xen_wakeup_notifier;
qemu_register_wakeup_notifier(&state->wakeup);
xc_get_hvm_param(xen_xc, xen_domid, HVM_PARAM_IOREQ_PFN, &ioreq_pfn);
DPRINTF("shared page at pfn %lx\n", ioreq_pfn);
state->shared_page = xc_map_foreign_range(xen_xc, xen_domid, XC_PAGE_SIZE,
PROT_READ|PROT_WRITE, ioreq_pfn);
if (state->shared_page == NULL) {
hw_error("map shared IO page returned error %d handle=" XC_INTERFACE_FMT,
errno, xen_xc);
}
rc = xen_get_vmport_regs_pfn(xen_xc, xen_domid, &ioreq_pfn);
if (!rc) {
DPRINTF("shared vmport page at pfn %lx\n", ioreq_pfn);
state->shared_vmport_page =
xc_map_foreign_range(xen_xc, xen_domid, XC_PAGE_SIZE,
PROT_READ|PROT_WRITE, ioreq_pfn);
if (state->shared_vmport_page == NULL) {
hw_error("map shared vmport IO page returned error %d handle="
XC_INTERFACE_FMT, errno, xen_xc);
}
} else if (rc != -ENOSYS) {
hw_error("get vmport regs pfn returned error %d, rc=%d", errno, rc);
}
xc_get_hvm_param(xen_xc, xen_domid, HVM_PARAM_BUFIOREQ_PFN, &ioreq_pfn);
DPRINTF("buffered io page at pfn %lx\n", ioreq_pfn);
state->buffered_io_page = xc_map_foreign_range(xen_xc, xen_domid, XC_PAGE_SIZE,
PROT_READ|PROT_WRITE, ioreq_pfn);
if (state->buffered_io_page == NULL) {
hw_error("map buffered IO page returned error %d", errno);
}
state->cpu_by_vcpu_id = g_malloc0(max_cpus * sizeof(CPUState *));
state->ioreq_local_port = g_malloc0(max_cpus * sizeof (evtchn_port_t));
for (i = 0; i < max_cpus; i++) {
rc = xc_evtchn_bind_interdomain(state->xce_handle, xen_domid,
xen_vcpu_eport(state->shared_page, i));
if (rc == -1) {
fprintf(stderr, "bind interdomain ioctl error %d\n", errno);
return -1;
}
state->ioreq_local_port[i] = rc;
}
rc = xc_get_hvm_param(xen_xc, xen_domid, HVM_PARAM_BUFIOREQ_EVTCHN,
&bufioreq_evtchn);
if (rc < 0) {
fprintf(stderr, "failed to get HVM_PARAM_BUFIOREQ_EVTCHN\n");
return -1;
}
rc = xc_evtchn_bind_interdomain(state->xce_handle, xen_domid,
(uint32_t)bufioreq_evtchn);
if (rc == -1) {
fprintf(stderr, "bind interdomain ioctl error %d\n", errno);
return -1;
}
state->bufioreq_local_port = rc;
xen_map_cache_init(xen_phys_offset_to_gaddr, state);
xen_ram_init(below_4g_mem_size, above_4g_mem_size, ram_size, ram_memory);
qemu_add_vm_change_state_handler(xen_hvm_change_state_handler, state);
state->memory_listener = xen_memory_listener;
QLIST_INIT(&state->physmap);
memory_listener_register(&state->memory_listener, &address_space_memory);
state->log_for_dirtybit = NULL;
if (xen_be_init() != 0) {
fprintf(stderr, "%s: xen backend core setup failed\n", __FUNCTION__);
return -1;
}
xen_be_register("console", &xen_console_ops);
xen_be_register("vkbd", &xen_kbdmouse_ops);
xen_be_register("qdisk", &xen_blkdev_ops);
xen_read_physmap(state);
return 0;
}
| 1threat
|
conversion from lptstr to wstring : I came up with the same issue,in which I got a LPTSTR portname param as input from a function.I have to convert this into wstring,so that I can fetch the Port paramaters.
below is the code snippet in which am trying to copy lptstr to wstring.
void C_PORT_MONITOR::SetPrinterComPortParam(LPTSTR PortName)
{
#ifdef _UNICODE
std::wstring l_ComPortName;
#else
std::string l_ComPortName;
#endif
DWORD dwSize,le = 0;
dwSize = sizeof(COMMCONFIG);
LPCOMMCONFIG lpCC = (LPCOMMCONFIG) new BYTE[dwSize];
l_ComPortName = PortName;//mPortName;
if(l_ComPortName.length() <= 0 )
return;
bool SetFlag = false;
//Get COMM port params called to get size of config. block
int length = l_ComPortName.length();
int iPos = l_ComPortName.find_first_of(':');
int iChc = length- iPos; //remove the charactrers after :
l_ComPortName = l_ComPortName.substr(0, (length- iChc)); //remove the characters from colon //COM1
//Get COMM port params with defined size
BOOL ret = GetDefaultCommConfig(l_ComPortName.c_str(), lpCC, &dwSize);
_RPT1(_CRT_WARN, "C_PORT_MONITOR::SetPrinterComPortParam length=%x,iPos=%x,iChc=%x,l_ComPortName=%s",length, iPos, iChc, l_ComPortName);
if(!ret)
{
le = GetLastError();
_RPT1(_CRT_WARN ,"C_PORT_MONITOR::SetPrinterComPortParam LastError=%x",le);
}
I need to assign this portname to l_comportname. and I need to create a substring from this l_comportname as COM1 and I have to use this substring in getdafaultcommconfig()
| 0debug
|
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
| 1threat
|
static coroutine_fn int qcow2_co_readv(BlockDriverState *bs, int64_t sector_num,
int remaining_sectors, QEMUIOVector *qiov)
{
BDRVQcowState *s = bs->opaque;
int index_in_cluster, n1;
int ret;
int cur_nr_sectors;
uint64_t cluster_offset = 0;
uint64_t bytes_done = 0;
QEMUIOVector hd_qiov;
uint8_t *cluster_data = NULL;
qemu_iovec_init(&hd_qiov, qiov->niov);
qemu_co_mutex_lock(&s->lock);
while (remaining_sectors != 0) {
cur_nr_sectors = remaining_sectors;
if (s->crypt_method) {
cur_nr_sectors = MIN(cur_nr_sectors,
QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors);
}
ret = qcow2_get_cluster_offset(bs, sector_num << 9,
&cur_nr_sectors, &cluster_offset);
if (ret < 0) {
goto fail;
}
index_in_cluster = sector_num & (s->cluster_sectors - 1);
qemu_iovec_reset(&hd_qiov);
qemu_iovec_concat(&hd_qiov, qiov, bytes_done,
cur_nr_sectors * 512);
switch (ret) {
case QCOW2_CLUSTER_UNALLOCATED:
if (bs->backing_hd) {
n1 = qcow2_backing_read1(bs->backing_hd, &hd_qiov,
sector_num, cur_nr_sectors);
if (n1 > 0) {
QEMUIOVector local_qiov;
qemu_iovec_init(&local_qiov, hd_qiov.niov);
qemu_iovec_concat(&local_qiov, &hd_qiov, 0,
n1 * BDRV_SECTOR_SIZE);
BLKDBG_EVENT(bs->file, BLKDBG_READ_BACKING_AIO);
qemu_co_mutex_unlock(&s->lock);
ret = bdrv_co_readv(bs->backing_hd, sector_num,
n1, &local_qiov);
qemu_co_mutex_lock(&s->lock);
qemu_iovec_destroy(&local_qiov);
if (ret < 0) {
goto fail;
}
}
} else {
qemu_iovec_memset(&hd_qiov, 0, 0, 512 * cur_nr_sectors);
}
break;
case QCOW2_CLUSTER_ZERO:
qemu_iovec_memset(&hd_qiov, 0, 0, 512 * cur_nr_sectors);
break;
case QCOW2_CLUSTER_COMPRESSED:
ret = qcow2_decompress_cluster(bs, cluster_offset);
if (ret < 0) {
goto fail;
}
qemu_iovec_from_buf(&hd_qiov, 0,
s->cluster_cache + index_in_cluster * 512,
512 * cur_nr_sectors);
break;
case QCOW2_CLUSTER_NORMAL:
if ((cluster_offset & 511) != 0) {
ret = -EIO;
goto fail;
}
if (s->crypt_method) {
if (!cluster_data) {
cluster_data =
qemu_try_blockalign(bs->file, QCOW_MAX_CRYPT_CLUSTERS
* s->cluster_size);
if (cluster_data == NULL) {
ret = -ENOMEM;
goto fail;
}
}
assert(cur_nr_sectors <=
QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors);
qemu_iovec_reset(&hd_qiov);
qemu_iovec_add(&hd_qiov, cluster_data,
512 * cur_nr_sectors);
}
BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO);
qemu_co_mutex_unlock(&s->lock);
ret = bdrv_co_readv(bs->file,
(cluster_offset >> 9) + index_in_cluster,
cur_nr_sectors, &hd_qiov);
qemu_co_mutex_lock(&s->lock);
if (ret < 0) {
goto fail;
}
if (s->crypt_method) {
qcow2_encrypt_sectors(s, sector_num, cluster_data,
cluster_data, cur_nr_sectors, 0, &s->aes_decrypt_key);
qemu_iovec_from_buf(qiov, bytes_done,
cluster_data, 512 * cur_nr_sectors);
}
break;
default:
g_assert_not_reached();
ret = -EIO;
goto fail;
}
remaining_sectors -= cur_nr_sectors;
sector_num += cur_nr_sectors;
bytes_done += cur_nr_sectors * 512;
}
ret = 0;
fail:
qemu_co_mutex_unlock(&s->lock);
qemu_iovec_destroy(&hd_qiov);
qemu_vfree(cluster_data);
return ret;
}
| 1threat
|
static bool virtio_queue_host_notifier_aio_poll(void *opaque)
{
EventNotifier *n = opaque;
VirtQueue *vq = container_of(n, VirtQueue, host_notifier);
bool progress;
if (virtio_queue_empty(vq)) {
return false;
}
progress = virtio_queue_notify_aio_vq(vq);
virtio_queue_set_notification(vq, 0);
return progress;
}
| 1threat
|
Using threading to make a function wait until button click in C# : <p>I am having a problem handling threads in my code. I want to make a function wait until the button within its own form is clicked.
A simple scenario looks like this. This is just an overview of my real problem. Suppose that myFunction() is called from another class and uses its returned value.</p>
<pre><code>public class myForm: Form
{ int x=0;
public dialogForm()
{
InitializeComponent();
}
public int myFunction() {
//do something
//wait for button1's click
return x;
}
private void button1_Click(object sender, EventArgs e)
{
// using this button to change the value of x
x=2;
}
</code></pre>
<p>Thanks in advance. Hope anyone helps. </p>
| 0debug
|
What is equivalent to `MapSpaFallbackRoute` for ASP.NET Core 3.0 endpoints? : <p>In ASP.NET Core 2.x I used standard routes registation <code>Configure</code> method of <code>Startup</code> class to <strong>register fallback route</strong> for SPA application using <code>MapSpaFallbackRoute</code> extension method from <code>Microsoft.AspNetCore.SpaServices.Extensions</code> Nuget package:</p>
<pre class="lang-cs prettyprint-override"><code>public void Configure(IApplicationBuilder app)
{
// ...
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
routes.MapSpaFallbackRoute(
name: "spa-fallback",
defaults: new { controller = "Home", action = "Index" });
});
}
</code></pre>
<p>I cannot find similar extension method when using ASP.NET Core 3.0 recommended <code>UseEndpoints</code> extension method for endpoints registration.</p>
| 0debug
|
Add missing lines in file if timestamp isn't continous : <p>I have .csv file containing continous data with timestamp (but in some cases some lines-minutes can be missing) and I need to write some script which will go through this file and add these missing lines with average values of neighboring lines.</p>
<p>Example of current data:</p>
<pre><code>_yyyy,_mm,_dd,_HH,_MM,_SS,T
2015,01,01,00,00,00,-5.0
2015,01,01,00,02,00,-5.2
2015,01,01,00,03,00,-5.3
2015,01,01,00,04,00,-5.3
2015,01,01,00,05,00,-5.3
2015,01,01,00,06,00,-5.3
2015,01,01,00,07,00,-5.3
2015,01,01,00,08,00,-5.3
2015,01,01,00,09,00,-5.3
2015,01,01,00,11,00,-5.3
2015,01,01,00,14,00,-5.3
</code></pre>
<p>and I would like to add these lines to their correct place:</p>
<pre><code>2015,01,01,00,01,00,-5.1
2015,01,01,00,10,00,-5.3
2015,01,01,00,12,00,-5.3
2015,01,01,00,13,00,-5.3
</code></pre>
<p>Thanks a lot for your answers</p>
| 0debug
|
can any tell me what i am doing wrong? : am trying to position a div to the left of the screen and am also trying to make it work on any screen resolution and browser . below is my code
<div id="Biography">
<div class="container">
<div class="tittle">
</div>
<div id="info">
<div class="col-md-8">
<div class=" wow bounceInDown" data-wow-delay="0.5s">
<div class="view view-fifth" style="height: 20%">
<img src="images/Dan.jpeg" alt="" style="height:80%; width:100%">
<h4> NAME</h4>
<h5> sean</h5>
<h4> OCCUPATION</h4>
<h5> Computer Programmer,Software Developer,Student</h5>
</div>
</div>
</div>
</div>
here is my css
#Biography {
background:#ffffff ;
text-align:center ;
text-transform:uppercase ;
color:#fff ;
padding:5em 0;
width:100%;
font-family:'Conv_Lato-Regular',Sans-Serif;
margin:0;
}
#info{
left: -10px;
float:left;
top: -80px;
position: relative;
color:#000;
}
i don't know what am doing wrong
| 0debug
|
static void apply_unsharp( uint8_t *dst, int dst_stride,
const uint8_t *src, int src_stride,
int width, int height, FilterParam *fp)
{
uint32_t **sc = fp->sc;
uint32_t sr[MAX_MATRIX_SIZE - 1], tmp1, tmp2;
int32_t res;
int x, y, z;
const uint8_t *src2 = NULL;
if (!fp->amount) {
if (dst_stride == src_stride)
memcpy(dst, src, src_stride * height);
else
for (y = 0; y < height; y++, dst += dst_stride, src += src_stride)
memcpy(dst, src, width);
return;
}
for (y = 0; y < 2 * fp->steps_y; y++)
memset(sc[y], 0, sizeof(sc[y][0]) * (width + 2 * fp->steps_x));
for (y = -fp->steps_y; y < height + fp->steps_y; y++) {
if (y < height)
src2 = src;
memset(sr, 0, sizeof(sr[0]) * (2 * fp->steps_x - 1));
for (x = -fp->steps_x; x < width + fp->steps_x; x++) {
tmp1 = x <= 0 ? src2[0] : x >= width ? src2[width-1] : src2[x];
for (z = 0; z < fp->steps_x * 2; z += 2) {
tmp2 = sr[z + 0] + tmp1; sr[z + 0] = tmp1;
tmp1 = sr[z + 1] + tmp2; sr[z + 1] = tmp2;
}
for (z = 0; z < fp->steps_y * 2; z += 2) {
tmp2 = sc[z + 0][x + fp->steps_x] + tmp1; sc[z + 0][x + fp->steps_x] = tmp1;
tmp1 = sc[z + 1][x + fp->steps_x] + tmp2; sc[z + 1][x + fp->steps_x] = tmp2;
}
if (x >= fp->steps_x && y >= fp->steps_y) {
const uint8_t *srx = src - fp->steps_y * src_stride + x - fp->steps_x;
uint8_t *dsx = dst - fp->steps_y * dst_stride + x - fp->steps_x;
res = (int32_t)*srx + ((((int32_t) * srx - (int32_t)((tmp1 + fp->halfscale) >> fp->scalebits)) * fp->amount) >> 16);
*dsx = av_clip_uint8(res);
}
}
if (y >= 0) {
dst += dst_stride;
src += src_stride;
}
}
}
| 1threat
|
static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt,
const uint8_t *buf, int len)
{
unsigned int ssrc, h;
int payload_type, seq, ret, flags = 0;
int ext;
AVStream *st;
uint32_t timestamp;
int rv = 0;
ext = buf[0] & 0x10;
payload_type = buf[1] & 0x7f;
if (buf[1] & 0x80)
flags |= RTP_FLAG_MARKER;
seq = AV_RB16(buf + 2);
timestamp = AV_RB32(buf + 4);
ssrc = AV_RB32(buf + 8);
s->ssrc = ssrc;
if (s->payload_type != payload_type)
return -1;
st = s->st;
if (!rtp_valid_packet_in_sequence(&s->statistics, seq)) {
av_log(st ? st->codec : NULL, AV_LOG_ERROR,
"RTP: PT=%02x: bad cseq %04x expected=%04x\n",
payload_type, seq, ((s->seq + 1) & 0xffff));
return -1;
}
if (buf[0] & 0x20) {
int padding = buf[len - 1];
if (len >= 12 + padding)
len -= padding;
}
s->seq = seq;
len -= 12;
buf += 12;
if (ext) {
if (len < 4)
return -1;
ext = (AV_RB16(buf + 2) + 1) << 2;
if (len < ext)
return -1;
len -= ext;
buf += ext;
}
if (!st) {
ret = ff_mpegts_parse_packet(s->ts, pkt, buf, len);
if (ret < 0)
return AVERROR(EAGAIN);
if (ret < len) {
s->read_buf_size = len - ret;
memcpy(s->buf, buf + ret, s->read_buf_size);
s->read_buf_index = 0;
return 1;
}
return 0;
} else if (s->parse_packet) {
rv = s->parse_packet(s->ic, s->dynamic_protocol_context,
s->st, pkt, ×tamp, buf, len, flags);
} else {
switch (st->codec->codec_id) {
case AV_CODEC_ID_MP2:
case AV_CODEC_ID_MP3:
if (len <= 4)
return -1;
h = AV_RB32(buf);
len -= 4;
buf += 4;
av_new_packet(pkt, len);
memcpy(pkt->data, buf, len);
break;
case AV_CODEC_ID_MPEG1VIDEO:
case AV_CODEC_ID_MPEG2VIDEO:
if (len <= 4)
return -1;
h = AV_RB32(buf);
buf += 4;
len -= 4;
if (h & (1 << 26)) {
if (len <= 4)
return -1;
buf += 4;
len -= 4;
}
av_new_packet(pkt, len);
memcpy(pkt->data, buf, len);
break;
default:
av_new_packet(pkt, len);
memcpy(pkt->data, buf, len);
break;
}
pkt->stream_index = st->index;
}
finalize_packet(s, pkt, timestamp);
return rv;
}
| 1threat
|
Scrolling is not smooth, its too slow. I've reterive videos form SD card and showing them listview : Please tell me a way how i can smooth scrolling. When i try to scroll down it takes a lot of time to load videos thumbnails. So please check my code and give me a easy solution. Many thanks.
I have tried a lot of ways but not working. Dont know how to deal with this issue. I hope experts will help me to complete my project.
public class VideoAdapter extends BaseAdapter {
private Context vContext;
public VideoAdapter(Context c) {
vContext = c;
}
public int getCount() {
return count;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
System.gc();
ViewHolder holder;
String id = null;
convertView = null;
if (convertView == null) {
try {
convertView = LayoutInflater.from(vContext).inflate(
R.layout.itemlist, parent, false);
}
catch (Exception e)
{
Toast.makeText(getContext(),"Permission Granted" + e, Toast.LENGTH_SHORT).show();
}
holder = new ViewHolder();
try {
holder.txtTitle = (TextView) convertView
.findViewById(R.id.txtTitle);
holder.txtSize = (TextView) convertView
.findViewById(R.id.txtSize);
holder.thumbImage = (ImageView) convertView
.findViewById(R.id.imgIcon);
}
catch (Exception e)
{
Toast.makeText(getContext(),"Permission Granted" + e, Toast.LENGTH_SHORT).show();
}
try {
video_column_index = songCursor
.getColumnIndexOrThrow(MediaStore.Video.Media.DISPLAY_NAME);
songCursor.moveToPosition(position);
id = songCursor.getString(video_column_index);
video_column_index = songCursor
.getColumnIndexOrThrow(MediaStore.Video.Media.SIZE);
songCursor.moveToPosition(position);
} catch (Exception e)
{
Toast.makeText(getContext(),"Permission Granted" + e, Toast.LENGTH_SHORT).show();
}
// id += " Size(KB):" +
// videocursor.getString(video_column_index);
holder.txtTitle.setText(id);
holder.txtSize.setText(" Size(KB):"
+ songCursor.getString(video_column_index));
try {
String[] proj = {MediaStore.Video.Media._ID,
MediaStore.Video.Media.DISPLAY_NAME,
MediaStore.Video.Media.DATA};
@SuppressWarnings("deprecation")
Cursor cursor = getActivity().getContentResolver().query(
MediaStore.Video.Media.EXTERNAL_CONTENT_URI, proj,
MediaStore.Video.Media.DISPLAY_NAME + "=?",
new String[]{id}, null);
cursor.moveToFirst();
}
catch (Exception e)
{
Toast.makeText(getContext(),"nO Permission Granted" + e, Toast.LENGTH_SHORT).show();
}
long ids = songCursor.getLong(songCursor
.getColumnIndex(MediaStore.Video.Media._ID));
ContentResolver crThumb = getActivity().getContentResolver();
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 1;
Bitmap curThumb = MediaStore.Video.Thumbnails.getThumbnail(crThumb, ids, MediaStore.Video.Thumbnails.MICRO_KIND, options);
/// if (holder.thumbImage !=null) {
holder.thumbImage.setImageBitmap(curThumb);
// }
// else {
// Drawable a = getContext().getResources().getDrawable(R.drawable.index);
/// holder.thumbImage.setImageDrawable(a);
// }
curThumb = null;
}
return convertView;
}
}
static class ViewHolder {
TextView txtTitle;
TextView txtSize;
ImageView thumbImage;
}
| 0debug
|
static inline void tlb_protect_code1(CPUTLBEntry *tlb_entry, uint32_t addr)
{
if (addr == (tlb_entry->address &
(TARGET_PAGE_MASK | TLB_INVALID_MASK)) &&
(tlb_entry->address & ~TARGET_PAGE_MASK) != IO_MEM_CODE) {
tlb_entry->address |= IO_MEM_CODE;
tlb_entry->addend -= (unsigned long)phys_ram_base;
}
}
| 1threat
|
I believe this is close, but I haven't quite got it yet. : Thank you for reading, I am very new with python and this is my first actual post. I'm having a hard time understanding how return values work, and how parameters can receive data. Is this close, and what resources should I use to improve it. Thank you.
def getInfo():
a = int(input('Please enter the first number in the range:'))
b = int(input('Please enter then second number in the range:'))
return a, b
def loopIt(a, b):
for i in range(a, b):
print('i is now {}'.format(i))
getInfo()
loopIt(a, b)
| 0debug
|
int av_metadata_set(AVMetadata **pm, const char *key, const char *value)
{
AVMetadata *m= *pm;
AVMetadataTag *tag= av_metadata_get(m, key, NULL, AV_METADATA_MATCH_CASE);
if(!m)
m=*pm= av_mallocz(sizeof(*m));
if(tag){
av_free(tag->value);
av_free(tag->key);
*tag= m->elems[--m->count];
}else{
AVMetadataTag *tmp= av_realloc(m->elems, (m->count+1) * sizeof(*m->elems));
if(tmp){
m->elems= tmp;
}else
return AVERROR(ENOMEM);
}
if(value){
m->elems[m->count].key = av_strdup(key );
m->elems[m->count].value= av_strdup(value);
m->count++;
}
if(!m->count) {
av_free(m->elems);
av_freep(pm);
}
return 0;
}
| 1threat
|
Verilog: if else to Casex conversion : <pre><code>reg A, B, C, D, E, F, G, H;
always@(*)
if (A) H = F & G;
else if (B) H = F | G;
else if (C) H = F ^ G;
else H = D & E;
</code></pre>
<p>I have to replace these statements with a casex statement. Can someone help me with the code</p>
<p>My code is this which is wrong ....</p>
<pre><code>reg A, B, C, D, E, F, G, H;
always@(*)
begin
casex(A or B or C or D or E or F or G or H)
A: H= F & G;
B: H = F | G;
C: H = F ^ G;
default: H = D & E;
endcase
</code></pre>
| 0debug
|
How to connect an asp.net web app to SQL Server : <p>I'm having some difficulty finding how to do this. I have an asp.net web app that I'm creating. I need to connect it to SQL Server to pull data from a couple of tables. I've found what I think are the correct connection strings, but I don't know where to put them so that I can use them for several pages?</p>
<p>I found this <a href="https://msdn.microsoft.com/en-us/library/jj653752(v=vs.110).aspx#sqlserver" rel="nofollow noreferrer">connection string</a> and this <a href="https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring(v=vs.110).aspx#Examples" rel="nofollow noreferrer">example</a> that I am pretty sure I can use.</p>
<p>What I need to know is where do I put this so that I can use it on 5 - 6 different pages? If someone can point me in the right direction that would be enough.</p>
| 0debug
|
No information on google : I am trying to put in in to MYSQL and XML files but when i press to put in MYSQL it does that, and when i press to put in XML it puts in to MYSQL. I don't know how to fix that.
Well i looked all over the internet and couldn't find any information that could help me
I tried to fix this code for like 8 hours but couldn't find what was the problem with it.
<?php
include_once 'includes/DuombazesInfo.php'
?>
<?php
if(isset($_REQUEST['Ikelimas'])) {
$xml = new DOMDocument ("1.0","UTF-8");
$xml -> load("pavyzdysxml.xml");
$rootTag = $xml -> getElementsByTagName ("document") -> item(0);
$dataTag = $xml -> createElement("data");
$nameTag = $xml -> createElement("name", $_REQUEST['name']);
$lastnameTag = $xml -> createElement("lastname", $_REQUEST['lastname']);
$emailTag = $xml -> createElement("email", $_REQUEST['email']);
$passwordTag = $xml -> createElement("password", $_REQUEST['password']);
$dataTag -> appendChild($nameTag);
$dataTag -> appendChild($lastnameTag);
$dataTag -> appendChild($emailTag);
$dataTag -> appendChild($passwordTag);
$rootTag -> appendChild($dataTag);
$xml -> save("PavyzdysXML.xml");
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = test_input($_POST["name"]);
$lastname = test_input($_POST["lastname"]);
$email = test_input($_POST["email"]);
$password = test_input($_POST["password"]);
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Lentele su duomenu baze</title>
</head>
<body>
<h2>Savarankiškas darbas</h2>
<form action="includes/prisijungimas.php" method="POST">
<input type="text" name="name" placeholder="Vardas" required>
<br><br>
<input type="text" name="lastname" placeholder="Pavardė" required>
<br><br>
<input type="email" name="email" placeholder="El. Paštas">
<br><br>
<input type="text" name="password" placeholder="Slaptažodis" required>
<br><br>
<button type="submit" name="Įkelti"> Įkelti į duomenų bazę </button>
<input type="button" value="Peržiūrėti duomenų bazės informaciją"
class="homebutton" id="btnHome" onClick="parent.location='index1.php'"/>
<input type="button" value="Peržiūrėti XML failą" class="homebutton"
id="btnHome" onClick="parent.location='PavyzdysXML.xml'" />
<input type="submit" name="Ikelimas" value ="Įkelti į XML failą">
</form>
</body>
</html>
| 0debug
|
Webpack 2 eslint-loader auto fix : <p>In webpack 1.x I could use the eslint property in my webpack config to enable autofixing my linting errors using:</p>
<pre><code>...
module.exports = {
devtool: 'source-map',
entry: './src/app.js',
eslint: {
configFile: '.eslintrc',
fix: true
},
...
</code></pre>
<p>However, in webpack 2.x, thusfar I have been unable to use the auto fix functionality, because I don't know where to set it in my webpack config. Using the eslint property in my webpack configFile throws an <code>WebpackOptionsValidationError</code>.</p>
| 0debug
|
How to get the last n files in a directory : <p>I need help with getting the last 3 files in a directory.
I have an application that creates files in it and they have dates in the file names displayed as MMDD eg 0301.
There are a few files that have differents names but all have the dates on them and I'm new to C programming and don't know how to display only the last 3 file names.
If someone could help me it would be really appreciated.
Thank you</p>
| 0debug
|
Why this this code only output ""? (Codeingame's Thor challenge) : <p>I need help finding the mistake I have made with an alternative approach through diferences of the x and y values on the Thor-challenge of Codeingame.</p>
<p>Here is the code of the game loop:</p>
<pre><code>// game loop
while (1) {
int remainingTurns; // The remaining amount of turns Thor can move. Do not remove this line.
cin >> remainingTurns; cin.ignore();
int difx = lightX-initialTX;
int dify = lightY-initialTY;
float mathquot=dify/difx;
string out ="";
if(difx==0 || dify==0){
if(difx=0){
if(dify<0) out="W"; initialTY-=1;
if(dify>0) out="E"; initialTY+=1;
}
if(dify=0){
if(difx<0) out="N"; initialTX-=1;
if(difx>0) out="S"; initialTX+=1;
}
}else{
if(mathquot>0 && (difx>0 && dify>0)) out="SE"; initialTY +=1; initialTX+=1;
if(mathquot>0 && (difx<0 && dify<0)) out="NW"; initialTY -=1; initialTX-=1;
if(mathquot<0 && difx<0) out="SW"; initialTY +=1; initialTX-=1;
if(mathquot<0 && dify<0) out="NE"; initialTY -=1; initialTX+=1;
}
// Write an action using cout. DON'T FORGET THE "<< endl"
// To debug: cerr << "Debug messages..." << endl;
// A single line providing the move to be made: N NE E SE S SW W or NW
cout << out << endl;
}
</code></pre>
| 0debug
|
How to explode multiple columns of a dataframe in pyspark : <p>I have a dataframe which consists lists in columns similar to the following. The length of the lists in all columns is not same. </p>
<pre><code>Name Age Subjects Grades
[Bob] [16] [Maths,Physics,Chemistry] [A,B,C]
</code></pre>
<p>I want to explode the dataframe in such a way that i get the following output-</p>
<pre><code>Name Age Subjects Grades
Bob 16 Maths A
Bob 16 Physics B
Bob 16 Chemistry C
</code></pre>
<p>How can I achieve this?</p>
| 0debug
|
How to reduce ul size after tansform rotateZ? : I've found a cool double helix visualization in html and css and I tried to change it a little bit by change transform: rotateZ from 10deg to 90deg and after that I realized ul height is not reducing I've tried different ways to minimalize that, but no one worked(li size is acting strange too so maybe this affect on ul size so please help me out with both)<br/><br/>
Link: `codepen.io/hugo/pen/AjJFL`
| 0debug
|
Print in python 3.5.2 : I have typed print ("Hello World!") into python 3.4.2 and instead of printing Hello World! It prints Syntax error: invalid character in identifier. I am a complete beginner and am using a raspberry pi 3
| 0debug
|
Docker ignores patterns in .dockerignore : <p>I intended to exclude python generated files from the docker image. So I added <code>.dockerignore</code> at the root of the context directory:</p>
<pre><code># Ignore generated files
*.pyc
</code></pre>
<p>Alas <code>docker build</code> ignores this and copies the entire directory tree that looks like the following:</p>
<pre><code>/contextdir/
|-- Dockerfile
\-- src/
|-- a.py # this is copies - all right
\-- a.pyc # this should be ignored, but is copied too. Why?
</code></pre>
| 0debug
|
how to fix SytaxError in conda : I'm testing new software, everything is ok and set up. while running this command on terminal
python data-processing/run_pipeline.py default.yaml test.fasta ./tmp_feature
I'm getting this error
> File "data-processing/run_pipeline.py", line 29
print "=" * 60
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("=" * 60)?
Please, can you help me to fix this error?
I tried to change the command by adding a parentheses,
python (data-processing/run_pipeline.py) default.yaml test.fasta ./tmp_feature
since run_pipeline.py is file included in data-processing but it didn't work and I got this error
> bash: syntax error near unexpected token `data-processing/run_pipeline.py'
| 0debug
|
Automatically fetch date from string in javascript and return same string with formatted Date : I'm having input string like -
Hi, I'll reach on 17 Dec 2019
Its basically -
[some words] + [date in any format] + [any other words optional]
Will be whatever user enters.
My requirement is to fetch the date form the given string and format it and store it with same string. So the result would be like -
[some words] + [date in my format] + [any other words optional]
Would this be possible in javascript (without nodejs) as Im running this on browser directly.
Tried new Date(fullString) and I get the date but loose the other parts of the string
var input = "Hi, I'll reach on 17/12/2019. Please wait."
var userDate = new Date(input);
Expected - "Hi, I'll reach on Dec 17, 2019. Please wait."
| 0debug
|
didSet in Swift has a weird knock-on effect on mutating func : <p>I just learned that mutating func is just a curried func with first parameter as inout, so the code below will work and change <code>firstName</code> to <code>"John"</code></p>
<pre><code>struct Person {
var firstName = "Matt"
mutating func changeName(fn: String) {
firstName = fn
}
}
var p = Person()
let changer = Person.changeName
changer(&p)("John")
p.firstName
</code></pre>
<p>but the odd thing happend when I add property observer to <code>p</code> like below, you can see <code>firstName</code> is still "Matt", why?
<a href="https://i.stack.imgur.com/uLchZ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/uLchZ.png" alt="enter image description here"></a></p>
| 0debug
|
How to fix commit order in GitHub pull requests, broken by git rebase? : <p>When I write code I break it into small logical changes that are easy and quick to review.</p>
<p>To do so, I use <code>git rebase -i</code> (interactive) to squash, drop and change order of commits.</p>
<p>I've noticed this sometimes leads to a different order of commits on a GitHub pull request (though the order is retained on the remote branch). </p>
<p>For example,</p>
<ul>
<li>commit 1</li>
<li>commit 2</li>
<li>commit 3</li>
</ul>
<p>might show up in the PR as:</p>
<ul>
<li>commit 3</li>
<li>commit 1</li>
<li>commit 2</li>
</ul>
<p>I've searched the internet and only managed to find this GitHub help page: <a href="https://help.github.com/articles/why-are-my-commits-in-the-wrong-order/" rel="noreferrer">Why are my commits in the wrong order?</a> Their answer:</p>
<blockquote>
<p>If you rewrite your commit history via git rebase or a force push, you
may notice that your commit sequence is out of order when opening a
pull request.</p>
<p>GitHub emphasizes Pull Requests as a space for discussion. All aspects
of it--comments, references, and commits--are represented in a
chronological order. Rewriting your Git commit history <a href="https://help.github.com/articles/about-git-rebase" rel="noreferrer">while
performing rebases</a> alters the space-time continuum, which means
that commits may not be represented the way you expect them to in the
GitHub interface.</p>
<p>If you always want to see commits in order, we recommend not using
<code>git rebase</code>. However, rest assured that nothing is broken when you
see things outside of a chronological order!</p>
</blockquote>
<p>Is there a way to work around this?</p>
| 0debug
|
static uint32_t ehci_mem_readw(void *ptr, target_phys_addr_t addr)
{
EHCIState *s = ptr;
uint32_t val;
val = s->mmio[addr] | (s->mmio[addr+1] << 8);
return val;
}
| 1threat
|
Xamarin Forms iOS status bar text color : <p>I am unable to change the status bar text color of my Xamarin Forms iOS app to white. I have change in my info.plist as follow:</p>
<pre><code><key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</code></pre>
<p>Yet the color still remain black.. Is there another way to change the status bar text color?</p>
| 0debug
|
OpenJDK vs Java HotspotVM : <p>Are OpenJDK VM and Oracle Hotspot VM still two different JVMs?</p>
<p>I can't seem to find any somewhat official documentation on anything about OpenJDK VM. Even in OpenJDK homepage there is an HotSpot Group which develops HotSpot VM.</p>
<blockquote>
<p>The HotSpot group is comprised of developers involved in the design, implementation, and maintanence of the HotSpot virtual machine</p>
</blockquote>
<p>However if I check java -version on my Windows machine it prints out</p>
<blockquote>
<p>Java HotSpot(TM) 64-Bit Server VM</p>
</blockquote>
<p>But on my Ubuntu VPS </p>
<blockquote>
<p>OpenJDK 64-Bit Server VM</p>
</blockquote>
<p>If those are two different VMs what are the main differences between them? Do they have different runtime flag sets?</p>
| 0debug
|
How can i read file contents(ex: doc file) from svn(subversion) using python? Thanks in advance : import subprocess
import os
filename="D:\MAINTRUNK\ar_ctrl_handle_ar_expand_menu.ptu"
r = subprocess.Popen("open " + filename, stdout=subprocess.PIPE, shell=True, universal_newlines=True)
stdout, stderr = r.communicate()
print stdout
| 0debug
|
javascript multidimentional array : var givenArray = [23, 6, [2,[6,2,1,2], 2], 5, 2];
INPUT: var givenArray is any array, may or may not be a multi-dimensional array. PROCESS: Please use HTML CSS and JavaScript (control structure, built-in function, recursive function) to output the array elements by maintaining their level. SAMPLE OUTPUT: 23
6
2
6
2
1
2
2
5
2
| 0debug
|
Text editor that can be used inside an android application : How can i integrate a text editor in my android app. I need a text editor like stack exchange which can allow the user to post questions along with code snippets.
| 0debug
|
static uint32_t omap_sysctl_read8(void *opaque, target_phys_addr_t addr)
{
struct omap_sysctl_s *s = (struct omap_sysctl_s *) opaque;
int pad_offset, byte_offset;
int value;
switch (addr) {
case 0x030 ... 0x140:
pad_offset = (addr - 0x30) >> 2;
byte_offset = (addr - 0x30) & (4 - 1);
value = s->padconf[pad_offset];
value = (value >> (byte_offset * 8)) & 0xff;
return value;
default:
break;
}
OMAP_BAD_REG(addr);
return 0;
}
| 1threat
|
How to split array in javascript for d3 : <p>I want to split array something like this:</p>
<pre><code>input: [a,b,c,d,e];
output: [[a,b], [b,c], [c,d], [d,e]];
</code></pre>
| 0debug
|
How to disable right click menu in html? : <p>How can I disable the right click menu in html?</p>
<p>Please don't say its unprofessional, I am developing a public touch screen display for a museum.</p>
<p>I have already disabled text selection but if you touch and hold it brings the right click menu- very unprofessional :D </p>
<p>Thanks in advance.</p>
| 0debug
|
Stop and remove all docker containers : <p>What is the best way to create a clean slate with your Docker containers? Lots of times I feel it is easier to start from scratch, but I have a bunch of containers that I am not sure what their states are, then when I run <code>docker rm</code> it won't let me because the docker container could still be in use. </p>
| 0debug
|
static int get_sot(Jpeg2000DecoderContext *s, int n)
{
Jpeg2000TilePart *tp;
uint16_t Isot;
uint32_t Psot;
uint8_t TPsot;
if (bytestream2_get_bytes_left(&s->g) < 8)
return AVERROR_INVALIDDATA;
s->curtileno = 0;
Isot = bytestream2_get_be16u(&s->g);
if (Isot >= s->numXtiles * s->numYtiles)
return AVERROR_INVALIDDATA;
s->curtileno = Isot;
Psot = bytestream2_get_be32u(&s->g);
TPsot = bytestream2_get_byteu(&s->g);
bytestream2_get_byteu(&s->g);
if (!Psot)
Psot = bytestream2_get_bytes_left(&s->g) + n + 2;
if (Psot > bytestream2_get_bytes_left(&s->g) + n + 2) {
av_log(s->avctx, AV_LOG_ERROR, "Psot %"PRIu32" too big\n", Psot);
return AVERROR_INVALIDDATA;
}
if (TPsot >= FF_ARRAY_ELEMS(s->tile[Isot].tile_part)) {
avpriv_request_sample(s->avctx, "Support for %"PRIu8" components", TPsot);
return AVERROR_PATCHWELCOME;
}
s->tile[Isot].tp_idx = TPsot;
tp = s->tile[Isot].tile_part + TPsot;
tp->tile_index = Isot;
tp->tp_end = s->g.buffer + Psot - n - 2;
if (!TPsot) {
Jpeg2000Tile *tile = s->tile + s->curtileno;
memcpy(tile->codsty, s->codsty, s->ncomponents * sizeof(Jpeg2000CodingStyle));
memcpy(tile->qntsty, s->qntsty, s->ncomponents * sizeof(Jpeg2000QuantStyle));
}
return 0;
}
| 1threat
|
static int dxva2_vp9_start_frame(AVCodecContext *avctx,
av_unused const uint8_t *buffer,
av_unused uint32_t size)
{
const VP9SharedContext *h = avctx->priv_data;
AVDXVAContext *ctx = avctx->hwaccel_context;
struct vp9_dxva2_picture_context *ctx_pic = h->frames[CUR_FRAME].hwaccel_picture_private;
if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL ||
DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
return -1;
av_assert0(ctx_pic);
if (fill_picture_parameters(avctx, ctx, h, &ctx_pic->pp) < 0)
return -1;
ctx_pic->bitstream_size = 0;
ctx_pic->bitstream = NULL;
return 0;
}
| 1threat
|
Why Rails 5 uses ApplicationRecord instead of ActiveRecord::Base? : <p>We know that Rails 5 added <code>ApplicationRecord</code> as an abstract class which was inherited by our models (ActiveRecord).</p>
<p>But basically, I think every technical requirement we do with ApplicationRecord, we can also do with <code>ActiveRecord::Base</code>. For instance:</p>
<pre><code>module MyFeatures
def do_something
puts "Doing something"
end
end
class ApplicationRecord < ActiveRecord::Base
include MyFeatures
self.abstract_class = true
end
</code></pre>
<p>So now every model will be attached the behaviors of <code>MyFeatures</code>. But we can also achieve this in Rails 4:</p>
<pre><code>ActiveRecord::Base.include(MyFeatures)
</code></pre>
<p>So what is the benefit of using <code>ApplicationRecord</code>, do you think it is necessary to add <code>ApplicationRecord</code>?</p>
| 0debug
|
Wocommerce search by attributes not works fine : i developed a search by attributes in woocommerce and everything be ok. But one attribute not work in the search. The only difference that i find is that is an alphabetical attributes and the others are numeric.
For example the url
http://neumaticos.7vidas.com.ar/?s=&post_type=product&product_cat=neumaticos&categories=neumaticos&pa_vehiculo=&pa_ancho=175&pa_talon=&pa_rodado=
returns the correctly results but when i search by vehiculo (pa_vehiculo) returns all the products.
Someone know what can be happen?
Thank you!
| 0debug
|
int tlb_set_page_exec(CPUState *env, target_ulong vaddr,
target_phys_addr_t paddr, int prot,
int is_user, int is_softmmu)
{
PhysPageDesc *p;
unsigned long pd;
unsigned int index;
target_ulong address;
target_phys_addr_t addend;
int ret;
CPUTLBEntry *te;
int i;
p = phys_page_find(paddr >> TARGET_PAGE_BITS);
if (!p) {
pd = IO_MEM_UNASSIGNED;
pd = p->phys_offset;
#if defined(DEBUG_TLB)
printf("tlb_set_page: vaddr=" TARGET_FMT_lx " paddr=0x%08x prot=%x u=%d smmu=%d pd=0x%08lx\n",
vaddr, (int)paddr, prot, is_user, is_softmmu, pd);
#endif
ret = 0;
#if !defined(CONFIG_SOFTMMU)
if (is_softmmu)
#endif
{
if ((pd & ~TARGET_PAGE_MASK) > IO_MEM_ROM && !(pd & IO_MEM_ROMD)) {
address = vaddr | pd;
addend = paddr;
address = vaddr;
addend = (unsigned long)phys_ram_base + (pd & TARGET_PAGE_MASK);
index = (vaddr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
addend -= vaddr;
te = &env->tlb_table[is_user][index];
te->addend = addend;
if (prot & PAGE_READ) {
te->addr_read = address;
te->addr_read = -1;
if (prot & PAGE_EXEC) {
te->addr_code = address;
te->addr_code = -1;
if (prot & PAGE_WRITE) {
if ((pd & ~TARGET_PAGE_MASK) == IO_MEM_ROM ||
(pd & IO_MEM_ROMD)) {
te->addr_write = vaddr |
(pd & ~(TARGET_PAGE_MASK | IO_MEM_ROMD));
} else if ((pd & ~TARGET_PAGE_MASK) == IO_MEM_RAM &&
!cpu_physical_memory_is_dirty(pd)) {
te->addr_write = vaddr | IO_MEM_NOTDIRTY;
te->addr_write = address;
te->addr_write = -1;
#if !defined(CONFIG_SOFTMMU)
else {
if ((pd & ~TARGET_PAGE_MASK) > IO_MEM_ROM) {
if (!(env->hflags & HF_SOFTMMU_MASK))
ret = 2;
void *map_addr;
if (vaddr >= MMAP_AREA_END) {
ret = 2;
if (prot & PROT_WRITE) {
if ((pd & ~TARGET_PAGE_MASK) == IO_MEM_ROM ||
#if defined(TARGET_HAS_SMC) || 1
first_tb ||
#endif
((pd & ~TARGET_PAGE_MASK) == IO_MEM_RAM &&
!cpu_physical_memory_is_dirty(pd))) {
VirtPageDesc *vp;
vp = virt_page_find_alloc(vaddr >> TARGET_PAGE_BITS, 1);
vp->phys_addr = pd;
vp->prot = prot;
vp->valid_tag = virt_valid_tag;
prot &= ~PAGE_WRITE;
map_addr = mmap((void *)vaddr, TARGET_PAGE_SIZE, prot,
MAP_SHARED | MAP_FIXED, phys_ram_fd, (pd & TARGET_PAGE_MASK));
if (map_addr == MAP_FAILED) {
cpu_abort(env, "mmap failed when mapped physical address 0x%08x to virtual address 0x%08x\n",
paddr, vaddr);
#endif
return ret;
| 1threat
|
int cpu_breakpoint_insert(CPUState *env, target_ulong pc, int flags,
CPUBreakpoint **breakpoint)
{
#if defined(TARGET_HAS_ICE)
CPUBreakpoint *bp;
bp = qemu_malloc(sizeof(*bp));
bp->pc = pc;
bp->flags = flags;
if (flags & BP_GDB)
TAILQ_INSERT_HEAD(&env->breakpoints, bp, entry);
else
TAILQ_INSERT_TAIL(&env->breakpoints, bp, entry);
breakpoint_invalidate(env, pc);
if (breakpoint)
*breakpoint = bp;
return 0;
#else
return -ENOSYS;
#endif
}
| 1threat
|
Google Cloud Platform - one test app - $90/month cost - why? : <p>I have a small test Angular static html app(10MB) deployed via Firebase Console and thought it is completely free. It's not a Node.js app.
When I take a look a the billing panel a month later I sow these nice lines:</p>
<p>Compute Engine N1 Predefined Instance Core running in Americas: 2159.983 Hours - $68.28.</p>
<p>Compute Engine N1 Predefined Instance Ram running in Americas: 8099.938 Gibibyte-hours - $34.32</p>
<p><a href="https://i.stack.imgur.com/sQuTk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sQuTk.jpg" alt="enter image description here"></a></p>
<p>GCP, I love you much!!!</p>
<p>Tell me guys, how this can be? I almost didn't use this app, just opened it 10 - 15 times during a month.</p>
<p>Sorry but I completely can't see the benefits of GCP. I can have Apache hosting in my country just for $3 - $5 per a MONTH but not per a day and no pain at all.</p>
| 0debug
|
How would I get tomorrow's day of the month using JS? : <p>I want to get the next day's date in Javascript. I can't find anything that will return it like the getDate() function. Thanks!</p>
| 0debug
|
static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
{
IDEBus *bus = DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus);
IDEState *s = bus->ifs + dev->unit;
const char *serial;
DriveInfo *dinfo;
if (dev->conf.discard_granularity && dev->conf.discard_granularity != 512) {
error_report("discard_granularity must be 512 for ide");
return -1;
}
serial = dev->serial;
if (!serial) {
dinfo = drive_get_by_blockdev(dev->conf.bs);
if (*dinfo->serial) {
serial = dinfo->serial;
}
}
if (ide_init_drive(s, dev->conf.bs, kind, dev->version, serial) < 0) {
return -1;
}
if (!dev->version) {
dev->version = g_strdup(s->version);
}
if (!dev->serial) {
dev->serial = g_strdup(s->drive_serial_str);
}
add_boot_device_path(dev->conf.bootindex, &dev->qdev,
dev->unit ? "/disk@1" : "/disk@0");
return 0;
}
| 1threat
|
Dynamically construct insert statement : <p>My insert statement looks as follows:</p>
<pre><code>using (OleDbCommand cmd2 = conn2.CreateCommand())
{
conn2.Open();
cmd2.CommandText = "INSERT INTO Panel " + "([Symbol Name SE], [Symbol Name EP]) " + "VALUES(@Type01, @Type02)";
cmd2.Parameters.AddRange(new OleDbParameter[]
{
new OleDbParameter("@Type01", variable1),
new OleDbParameter("@Type02", variable2),
});
cmd2.ExecuteNonQuery();
conn2.Close();
}
</code></pre>
<p>I'd like to convert this into a generic insert function to which I can pass a table name, several columns and values, both as arrays and the function will construct the insert statement and execute it. I did try creating it with StringBuilder but I was not able to do it successfully. Any help is appreciated. Thanks!</p>
| 0debug
|
calling LoaderManager in onItemSelectedListener in AdapterView inside Fragment in Android : please i'm trying to initiate LoaderManager on spinner item selected in FragmentActivity but have been getting error, i call the same loaderManager passing this as context outside onItemSelectedListener and it worked perfectly but unable to call it inside onItemSelectedListener. please kindly help
cryptoSpinners.setOnItemSelectedListener (new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
selected = adapterView.getItemAtPosition(position).toString();
LoaderManager loaderManager = getLoaderManager();
loaderManager.restartLoader(EARTHQUAKE_LOADER_ID, null, getActivity());
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
| 0debug
|
Doctrine in Symfony : I try to update my database with the command
php app/console doctrine:schema:update --force
and I get the error "No Metadata classes to
process"
| 0debug
|
static char *isabus_get_fw_dev_path(DeviceState *dev)
{
ISADevice *d = (ISADevice*)dev;
char path[40];
int off;
off = snprintf(path, sizeof(path), "%s", qdev_fw_name(dev));
if (d->ioport_id) {
snprintf(path + off, sizeof(path) - off, "@%04x", d->ioport_id);
}
return strdup(path);
}
| 1threat
|
What is the regex expression to extract 3 letter word starting with M followed by 2 number? : <p>I want to extract first 3 letters of the sentence which start with M and are followed by 2 digits. </p>
<p>If sentence is M30 INTHE SKY then output should be M30. IF sentence is THE INTHE SKY then answer should be np.nan(i.e. false as it didnot start with M)</p>
| 0debug
|
What does s.split("\\s+")) means here in the below code? : <p>I am given a String name say String s in below code. This String contains a phrase i.e. one or more words separated by single spaces. This program computes and return the acronym of this phrase.</p>
<pre><code>import java.math.*;
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;
public class Initials {
public String getInitials(String s) {
String r = "";
for(String t:s.split("\\s+")){
r += t.charAt(0);
}
return r;
}
void p(Object... o) {
System.out.println(deepToString(o));
}
}
</code></pre>
<p>Example:
"john fitzgerald kennedy"</p>
<p>Returns: "jfk"</p>
| 0debug
|
Disable home ,menu and back button in LockScreen Activity? : <p>Hi guys i am working on Pattern Lock App.I want to Disable home , app switch menu and back buttons on lock-screen Activity actually These button are not disable in KITKAT , JELLYBEANS AND OTHER DEVICE ALL BUTTON DISABLE INSTEAD OF HOME BUTTON .please help me i am already in tension. thanks in Advance.</p>
| 0debug
|
static void opt_qscale(const char *arg)
{
video_qscale = atof(arg);
if (video_qscale <= 0 ||
video_qscale > 255) {
fprintf(stderr, "qscale must be > 0.0 and <= 255\n");
ffmpeg_exit(1);
}
}
| 1threat
|
static void coroutine_fn v9fs_fix_fid_paths(V9fsPDU *pdu, V9fsPath *olddir,
V9fsString *old_name,
V9fsPath *newdir,
V9fsString *new_name)
{
V9fsFidState *tfidp;
V9fsPath oldpath, newpath;
V9fsState *s = pdu->s;
v9fs_path_init(&oldpath);
v9fs_path_init(&newpath);
v9fs_co_name_to_path(pdu, olddir, old_name->data, &oldpath);
v9fs_co_name_to_path(pdu, newdir, new_name->data, &newpath);
for (tfidp = s->fid_list; tfidp; tfidp = tfidp->next) {
if (v9fs_path_is_ancestor(&oldpath, &tfidp->path)) {
v9fs_fix_path(&tfidp->path, &newpath, strlen(oldpath.data));
}
}
v9fs_path_free(&oldpath);
v9fs_path_free(&newpath);
}
| 1threat
|
heroku: set SSL certificates on Free Plan? : <p>I would like to set some SSL certificates for one app I have on heroku (a simple application based on nodeJS + Vue).</p>
<p>I know if I upgrade to the Hobby Plan (7$ for month) I can have it automatically.</p>
<p>But for now it would too much money for a test application, so I am wondering if I can achieve some similar goal also with a Free Plan.</p>
<p>so:
Is it possible to set SSL certificate for an app on Heroku JUST with the Free Plan?
Maybe in a complicated/tricky way via CLI?</p>
<p>From the Heroku pages and documentation it looks not possible.
But I have to ask :)</p>
| 0debug
|
How to change the location of a groupbox programmatically : <p>Hello guys i Need to know how to Change the Location of the groupbox with code.
The Groupbox is in a Canvas.</p>
| 0debug
|
how can I fix this code : <p>Somethings wrong with this code.I input “gender-m,age-20,tickets-10”
and it gives me 3200.It supposed to be 3500. I have no idea what's wrong with it, can you please help me? iiiiiiiiiiiiiiiiiiii</p>
<pre><code>#include<iostream>
using namespace std;
int main()
{
char gender;
int age, numTix, premium;
cout << "Enter your gender: ";
cin >> gender;
cout << "Enter your age: ";
cin >> age;
cout << "Tickets you have gotten: ";
cin >> numTix;
if (gender == 'M')
{
if (age < 21)
{
premium = 1500 + 200 * numTix;
}
else if (age >= 21 && age < 30)
{
premium = 1200 + 100 * numTix;
}
else
{
premium = 1000 + 100 * numTix;
}
}
else
{
if (age < 21)
{
premium = 1200 + 200 * numTix;
}
else
{
premium = 1000 + 100 * numTix;
}
cout << "Your premium is $" << premium << endl;
}
system("pause");
return 0;
}
</code></pre>
| 0debug
|
sort array of objects by it's string value : <p>I have this object</p>
<pre><code>var obj = [
{id: 31, name: "Tiebreak 1", type: 2},
{id: 32, name: "Tiebreak 2", type: 2},
{id: 25, name: "Set 1", type: 0},
{id: 33, name: "Tiebreak 3", type: 2},
{id: 26, name: "Set 2", type: 0},
{id: 34, name: "Tiebreak 4", type: 2},
{id: 35, name: "Tiebreak 5", type: 2},
{id: 27, name: "Set 3", type: 0},
{id: 28, name: "Set 4", type: 0},
{id: 29, name: "Set 5", type: 0}
]
</code></pre>
<p>How can I sort it like this?</p>
<pre><code>var obj = [
{id: 25, name: "Set 1", type: 0},
{id: 31, name: "Tiebreak 1", type: 2},
{id: 26, name: "Set 2", type: 0},
{id: 32, name: "Tiebreak 2", type: 2},
...
]
</code></pre>
| 0debug
|
GraphQL pass args to sub resolve : <p>I have a relationship between User and Post. This is how I query the User Posts.</p>
<pre><code>const UserType = new GraphQLObjectType({
name: 'User'
fields: () => ({
name: {
type: GraphQLString
},
posts: {
type: new GraphQLList(PostType),
resolve(parent, args , { db }) {
// I want to get here the args.someBooleanArg
return someLogicToGetUserPosts();
}
}
})
});
</code></pre>
<p>The main query is:</p>
<pre><code>const queryType = new GraphQLObjectType({
name: 'RootQuery',
fields: {
users: {
type: new GraphQLList(UserType),
args: {
id: {
type: GraphQLInt
},
someBooleanArg: {
type: GraphQLInt
}
},
resolve: (root, { id, someBooleanArg }, { db }) => {
return someLogicToGetUsers();
}
}
}
});
</code></pre>
<p>The problem is the args in the resolve function of the UserType posts is empty object, how do i pass the args from the main query to sub resolves functions?</p>
| 0debug
|
static int megasas_ld_get_info_submit(SCSIDevice *sdev, int lun,
MegasasCmd *cmd)
{
struct mfi_ld_info *info = cmd->iov_buf;
size_t dcmd_size = sizeof(struct mfi_ld_info);
uint8_t cdb[6];
SCSIRequest *req;
ssize_t len, resid;
uint16_t sdev_id = ((sdev->id & 0xFF) << 8) | (lun & 0xFF);
uint64_t ld_size;
if (!cmd->iov_buf) {
cmd->iov_buf = g_malloc0(dcmd_size);
info = cmd->iov_buf;
megasas_setup_inquiry(cdb, 0x83, sizeof(info->vpd_page83));
req = scsi_req_new(sdev, cmd->index, lun, cdb, cmd);
if (!req) {
trace_megasas_dcmd_req_alloc_failed(cmd->index,
"LD get info vpd inquiry");
g_free(cmd->iov_buf);
cmd->iov_buf = NULL;
return MFI_STAT_FLASH_ALLOC_FAIL;
}
trace_megasas_dcmd_internal_submit(cmd->index,
"LD get info vpd inquiry", lun);
len = scsi_req_enqueue(req);
if (len > 0) {
cmd->iov_size = len;
scsi_req_continue(req);
}
return MFI_STAT_INVALID_STATUS;
}
info->ld_config.params.state = MFI_LD_STATE_OPTIMAL;
info->ld_config.properties.ld.v.target_id = lun;
info->ld_config.params.stripe_size = 3;
info->ld_config.params.num_drives = 1;
info->ld_config.params.is_consistent = 1;
blk_get_geometry(sdev->conf.blk, &ld_size);
info->size = cpu_to_le64(ld_size);
memset(info->ld_config.span, 0, sizeof(info->ld_config.span));
info->ld_config.span[0].start_block = 0;
info->ld_config.span[0].num_blocks = info->size;
info->ld_config.span[0].array_ref = cpu_to_le16(sdev_id);
resid = dma_buf_read(cmd->iov_buf, dcmd_size, &cmd->qsg);
g_free(cmd->iov_buf);
cmd->iov_size = dcmd_size - resid;
cmd->iov_buf = NULL;
return MFI_STAT_OK;
}
| 1threat
|
jquery - count character in textarea : <p>So I have this textarea where their is a character limit. How to do it? I don't want the "character remaining type" like: "250 characters remaining". I want this type: "250/250" until it will go "0/250". How to do this?</p>
<p>HTML:</p>
<pre><code><textarea maxlength=250>Text Here</textarea>
<span id="charCount">250/250</span>
</code></pre>
| 0debug
|
static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
{
VideoData *s = s1->priv_data;
AVStream *st;
int width, height;
int video_fd, frame_size;
int ret, frame_rate, frame_rate_base;
int desired_palette, desired_depth;
struct video_tuner tuner;
struct video_audio audio;
struct video_picture pict;
int j;
int vformat_num = sizeof(video_formats) / sizeof(video_formats[0]);
if (ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0) {
av_log(s1, AV_LOG_ERROR, "Bad capture size (%dx%d) or wrong time base (%d)\n",
ap->width, ap->height, ap->time_base.den);
return -1;
}
width = ap->width;
height = ap->height;
frame_rate = ap->time_base.den;
frame_rate_base = ap->time_base.num;
if((unsigned)width > 32767 || (unsigned)height > 32767) {
av_log(s1, AV_LOG_ERROR, "Capture size is out of range: %dx%d\n",
width, height);
return -1;
}
st = av_new_stream(s1, 0);
if (!st)
return AVERROR(ENOMEM);
av_set_pts_info(st, 64, 1, 1000000);
s->width = width;
s->height = height;
s->frame_rate = frame_rate;
s->frame_rate_base = frame_rate_base;
video_fd = open(s1->filename, O_RDWR);
if (video_fd < 0) {
av_log(s1, AV_LOG_ERROR, "%s: %s\n", s1->filename, strerror(errno));
goto fail;
}
if (ioctl(video_fd,VIDIOCGCAP, &s->video_cap) < 0) {
av_log(s1, AV_LOG_ERROR, "VIDIOCGCAP: %s\n", strerror(errno));
goto fail;
}
if (!(s->video_cap.type & VID_TYPE_CAPTURE)) {
av_log(s1, AV_LOG_ERROR, "Fatal: grab device does not handle capture\n");
goto fail;
}
desired_palette = -1;
desired_depth = -1;
for (j = 0; j < vformat_num; j++) {
if (ap->pix_fmt == video_formats[j].pix_fmt) {
desired_palette = video_formats[j].palette;
desired_depth = video_formats[j].depth;
break;
}
}
if (ap->standard && !ioctl(video_fd, VIDIOCGTUNER, &tuner)) {
if (!strcasecmp(ap->standard, "pal"))
tuner.mode = VIDEO_MODE_PAL;
else if (!strcasecmp(ap->standard, "secam"))
tuner.mode = VIDEO_MODE_SECAM;
else
tuner.mode = VIDEO_MODE_NTSC;
ioctl(video_fd, VIDIOCSTUNER, &tuner);
}
audio.audio = 0;
ioctl(video_fd, VIDIOCGAUDIO, &audio);
memcpy(&s->audio_saved, &audio, sizeof(audio));
audio.flags &= ~VIDEO_AUDIO_MUTE;
ioctl(video_fd, VIDIOCSAUDIO, &audio);
ioctl(video_fd, VIDIOCGPICT, &pict);
#if 0
printf("v4l: colour=%d hue=%d brightness=%d constrast=%d whiteness=%d\n",
pict.colour,
pict.hue,
pict.brightness,
pict.contrast,
pict.whiteness);
#endif
pict.palette = desired_palette;
pict.depth= desired_depth;
if (desired_palette == -1 || (ret = ioctl(video_fd, VIDIOCSPICT, &pict)) < 0) {
for (j = 0; j < vformat_num; j++) {
pict.palette = video_formats[j].palette;
pict.depth = video_formats[j].depth;
if (-1 != ioctl(video_fd, VIDIOCSPICT, &pict))
break;
}
if (j >= vformat_num)
goto fail1;
}
ret = ioctl(video_fd,VIDIOCGMBUF,&s->gb_buffers);
if (ret < 0) {
struct video_window win;
int val;
win.x = 0;
win.y = 0;
win.width = width;
win.height = height;
win.chromakey = -1;
win.flags = 0;
ioctl(video_fd, VIDIOCSWIN, &win);
s->frame_format = pict.palette;
val = 1;
ioctl(video_fd, VIDIOCCAPTURE, &val);
s->time_frame = av_gettime() * s->frame_rate / s->frame_rate_base;
s->use_mmap = 0;
} else {
s->video_buf = mmap(0,s->gb_buffers.size,PROT_READ|PROT_WRITE,MAP_SHARED,video_fd,0);
if ((unsigned char*)-1 == s->video_buf) {
s->video_buf = mmap(0,s->gb_buffers.size,PROT_READ|PROT_WRITE,MAP_PRIVATE,video_fd,0);
if ((unsigned char*)-1 == s->video_buf) {
av_log(s1, AV_LOG_ERROR, "mmap: %s\n", strerror(errno));
goto fail;
}
}
s->gb_frame = 0;
s->time_frame = av_gettime() * s->frame_rate / s->frame_rate_base;
s->gb_buf.frame = s->gb_frame % s->gb_buffers.frames;
s->gb_buf.height = height;
s->gb_buf.width = width;
s->gb_buf.format = pict.palette;
ret = ioctl(video_fd, VIDIOCMCAPTURE, &s->gb_buf);
if (ret < 0) {
if (errno != EAGAIN) {
fail1:
av_log(s1, AV_LOG_ERROR, "Fatal: grab device does not support suitable format\n");
} else {
av_log(s1, AV_LOG_ERROR,"Fatal: grab device does not receive any video signal\n");
}
goto fail;
}
for (j = 1; j < s->gb_buffers.frames; j++) {
s->gb_buf.frame = j;
ioctl(video_fd, VIDIOCMCAPTURE, &s->gb_buf);
}
s->frame_format = s->gb_buf.format;
s->use_mmap = 1;
}
for (j = 0; j < vformat_num; j++) {
if (s->frame_format == video_formats[j].palette) {
frame_size = width * height * video_formats[j].depth / 8;
st->codec->pix_fmt = video_formats[j].pix_fmt;
break;
}
}
if (j >= vformat_num)
goto fail;
s->fd = video_fd;
s->frame_size = frame_size;
st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_RAWVIDEO;
st->codec->width = width;
st->codec->height = height;
st->codec->time_base.den = frame_rate;
st->codec->time_base.num = frame_rate_base;
st->codec->bit_rate = frame_size * 1/av_q2d(st->codec->time_base) * 8;
return 0;
fail:
if (video_fd >= 0)
close(video_fd);
av_free(st);
return AVERROR(EIO);
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.