problem
stringlengths
26
131k
labels
class label
2 classes
static int ftp_type(FTPContext *s) { const char *command = "TYPE I\r\n"; const int type_codes[] = {200, 0}; if (!ftp_send_command(s, command, type_codes, NULL)) return AVERROR(EIO); return 0; }
1threat
Y2 axis showing in decimal in C# combination chart : I have tried C3 Combination chart with the below data. it showing Y2 axis in decimal points. So I couldn't see data2 points in my chart. var chart = c3.generate({data: {columns: [['data1', 30543, 2045346, 50765767, 4067657, 605676, 50665],['data2', 200, 130, 90, 240, 130, 220]],type: 'bar',types: {data2: 'line'}},axis: {y2: {show: true}}}); Let me know the solution
0debug
Android application close while scrolling down custom ListView : I'm using custom `ListView` and `Adapter` for load image and description into `ListView`. All the data loading from MySQL database. Then I try to scroll my list then automatically close my application. How can I solve this close problem? > Adapter class public class ItemAdapter extends BaseAdapter { private Context mContext; private List<Item> mItemList; public ItemAdapter(Context mContext, List<Item> mItemList) { this.mContext = mContext; this.mItemList = mItemList; } @Override public int getCount() { return mItemList.size(); } @Override public Object getItem(int position) { return mItemList.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder = null; if (convertView == null) { convertView = View.inflate(mContext, R.layout.item_item, null); holder = new ItemAdapter.ViewHolder(convertView); convertView.setTag(holder); } else { holder = (ItemAdapter.ViewHolder) convertView.getTag(); } holder.name.setText(mItemList.get(position).getItemName()); holder.desc.setText(mItemList.get(position).getItemDesc()); Picasso.with(mContext).load(mItemList.get(position).getImgUrl()).into(holder.image); convertView.setTag(mItemList.get(position).getItemId()); return convertView; } private static class ViewHolder { private TextView name; private TextView desc; private ImageView image; public ViewHolder(View v) { name = (TextView) v.findViewById(R.id.item_name); desc = (TextView) v.findViewById(R.id.item_description); image = (ImageView) v.findViewById(R.id.img_item); } } } > Item custom layout <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:card_view="http://schemas.android.com/tools" android:orientation="vertical" android:layout_marginTop="10dp" android:paddingLeft="10dp" android:paddingBottom="5dp" android:paddingTop="5dp" android:background="#ffffff" android:scrollbars="vertical"> <android.support.v7.widget.CardView android:id="@+id/item_cardview" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" android:elevation="3dp" card_view:cardUseCompatPadding="true" card_view:cardElevation="4dp" card_view:cardCornerRadius="1dp" app:cardCornerRadius="6dp" app:cardElevation="3dp" app:cardUseCompatPadding="true"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/img_item" android:layout_width="match_parent" android:layout_height="100dp" android:src="@drawable/dap_launcher" android:layout_marginLeft="15dp" android:clickable="true"/> <TextView android:id="@+id/item_name" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/img_item" android:paddingLeft="5dp" android:paddingRight="5dp" android:paddingTop="5dp" android:textStyle="bold" android:text="Item Name" android:textSize="15dp" android:layout_marginTop="2dp"/> <TextView android:id="@+id/item_description" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/item_name" android:layout_marginTop="5dp" android:paddingLeft="5dp" android:paddingRight="5dp" android:paddingTop="5dp" android:text="Item Description"/> </RelativeLayout> </android.support.v7.widget.CardView> </LinearLayout> > List layout <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:scrollbars="vertical"> <ListView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/listview_item" android:layout_marginTop="10dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:dividerHeight="10dp" android:divider="#d1d1d1"> </ListView> </RelativeLayout>
0debug
Restrict scipy.optimize.minimize to integer values : <p>I'm using <code>scipy.optimize.minimize</code> to optimize a real-world problem for which the answers can only be integers. My current code looks like this: </p> <pre><code>from scipy.optimize import minimize def f(x): return (481.79/(5+x[0]))+(412.04/(4+x[1]))+(365.54/(3+x[2]))+(375.88/(3+x[3]))+(379.75/(3+x[4]))+(632.92/(5+x[5]))+(127.89/(1+x[6]))+(835.71/(6+x[7]))+(200.21/(1+x[8])) def con(x): return sum(x)-7 cons = {'type':'eq', 'fun': con} print scipy.optimize.minimize(f, [1,1,1,1,1,1,1,0,0], constraints=cons, bounds=([0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7])) </code></pre> <p>This yields: </p> <pre><code>x: array([ 2.91950510e-16, 2.44504019e-01, 9.97850733e-01, 1.05398840e+00, 1.07481251e+00, 2.60570253e-01, 1.36470363e+00, 4.48527831e-02, 1.95871767e+00] </code></pre> <p>But I want it optimized with integer values (rounding all <code>x</code> to the nearest whole number doesn't always give the minimum). </p> <p>Is there a way to use <code>scipy.optimize.minimize</code> with only integer values?</p> <p>(I guess I could create an array with all possible permutations of <code>x</code> and evaluate f(x) for each combination, but that doesn't seem like a very elegant or quick solution.)</p>
0debug
static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) { DisasContext *dc = container_of(dcbase, DisasContext, base); if (dc->base.tb->cflags & CF_LAST_IO && dc->condjmp) { cpu_abort(cpu, "IO on conditional branch instruction"); } gen_set_condexec(dc); if (dc->base.is_jmp == DISAS_BX_EXCRET) { gen_bx_excret_final_code(dc); } else if (unlikely(is_singlestepping(dc))) { switch (dc->base.is_jmp) { case DISAS_SWI: gen_ss_advance(dc); gen_exception(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb), default_exception_el(dc)); break; case DISAS_HVC: gen_ss_advance(dc); gen_exception(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2); break; case DISAS_SMC: gen_ss_advance(dc); gen_exception(EXCP_SMC, syn_aa32_smc(), 3); break; case DISAS_NEXT: case DISAS_TOO_MANY: case DISAS_UPDATE: gen_set_pc_im(dc, dc->pc); default: gen_singlestep_exception(dc); break; case DISAS_NORETURN: break; } } else { switch(dc->base.is_jmp) { case DISAS_NEXT: case DISAS_TOO_MANY: gen_goto_tb(dc, 1, dc->pc); break; case DISAS_JUMP: gen_goto_ptr(); break; case DISAS_UPDATE: gen_set_pc_im(dc, dc->pc); default: tcg_gen_exit_tb(0); break; case DISAS_NORETURN: break; case DISAS_WFI: gen_helper_wfi(cpu_env); tcg_gen_exit_tb(0); break; case DISAS_WFE: gen_helper_wfe(cpu_env); break; case DISAS_YIELD: gen_helper_yield(cpu_env); break; case DISAS_SWI: gen_exception(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb), default_exception_el(dc)); break; case DISAS_HVC: gen_exception(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2); break; case DISAS_SMC: gen_exception(EXCP_SMC, syn_aa32_smc(), 3); break; } } if (dc->condjmp) { gen_set_label(dc->condlabel); gen_set_condexec(dc); if (unlikely(is_singlestepping(dc))) { gen_set_pc_im(dc, dc->pc); gen_singlestep_exception(dc); } else { gen_goto_tb(dc, 1, dc->pc); } } dc->base.pc_next = dc->pc; }
1threat
static void cpu_handle_ioreq(void *opaque) { XenIOState *state = opaque; ioreq_t *req = cpu_get_ioreq(state); handle_buffered_iopage(state); if (req) { handle_ioreq(state, req); if (req->state != STATE_IOREQ_INPROCESS) { fprintf(stderr, "Badness in I/O request ... not in service?!: " "%x, ptr: %x, port: %"PRIx64", " "data: %"PRIx64", count: %" FMT_ioreq_size ", size: %" FMT_ioreq_size ", type: %"FMT_ioreq_size"\n", req->state, req->data_is_ptr, req->addr, req->data, req->count, req->size, req->type); destroy_hvm_domain(false); return; } xen_wmb(); if (runstate_is_running()) { if (qemu_shutdown_requested_get()) { destroy_hvm_domain(false); } if (qemu_reset_requested_get()) { qemu_system_reset(VMRESET_REPORT); destroy_hvm_domain(true); } } req->state = STATE_IORESP_READY; xc_evtchn_notify(state->xce_handle, state->ioreq_local_port[state->send_vcpu]); } }
1threat
How to disable a link using CSS? : <p>I have the following link in a <code>wordpress</code> page.</p> <p>This class is a link. Is it possible to disable the link using only <code>CSS</code>?</p> <pre><code>&lt;a class="select-slot__serviceStaffOrLocationButton___5GUjl"&gt;&lt;i class="material-icons select-slot__serviceStaffOrLocationIcon___3WFzp"&gt;timelapse&lt;/i&gt;&lt;span class="select-slot__serviceName___14MHL"&gt;Employee Assistance Line&lt;/span&gt;&lt;/a&gt; </code></pre>
0debug
What is columnstore index and how is different from clustered and non-clustered : <p>Hi I am confused about columnstore index, what is column store index and how it is different from clustered and non-clustered index..</p>
0debug
int inet_connect_opts(QemuOpts *opts, Error **errp) { struct addrinfo ai,*res,*e; const char *addr; const char *port; char uaddr[INET6_ADDRSTRLEN+1]; char uport[33]; int sock,rc; bool block; memset(&ai,0, sizeof(ai)); ai.ai_flags = AI_CANONNAME | AI_ADDRCONFIG; ai.ai_family = PF_UNSPEC; ai.ai_socktype = SOCK_STREAM; addr = qemu_opt_get(opts, "host"); port = qemu_opt_get(opts, "port"); block = qemu_opt_get_bool(opts, "block", 0); if (addr == NULL || port == NULL) { fprintf(stderr, "inet_connect: host and/or port not specified\n"); error_set(errp, QERR_SOCKET_CREATE_FAILED); return -1; } if (qemu_opt_get_bool(opts, "ipv4", 0)) ai.ai_family = PF_INET; if (qemu_opt_get_bool(opts, "ipv6", 0)) ai.ai_family = PF_INET6; if (0 != (rc = getaddrinfo(addr, port, &ai, &res))) { fprintf(stderr,"getaddrinfo(%s,%s): %s\n", addr, port, gai_strerror(rc)); error_set(errp, QERR_SOCKET_CREATE_FAILED); return -1; } for (e = res; e != NULL; e = e->ai_next) { if (getnameinfo((struct sockaddr*)e->ai_addr,e->ai_addrlen, uaddr,INET6_ADDRSTRLEN,uport,32, NI_NUMERICHOST | NI_NUMERICSERV) != 0) { fprintf(stderr,"%s: getnameinfo: oops\n", __FUNCTION__); continue; } sock = qemu_socket(e->ai_family, e->ai_socktype, e->ai_protocol); if (sock < 0) { fprintf(stderr,"%s: socket(%s): %s\n", __FUNCTION__, inet_strfamily(e->ai_family), strerror(errno)); continue; } setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,(void*)&on,sizeof(on)); if (!block) { socket_set_nonblock(sock); } do { rc = 0; if (connect(sock, e->ai_addr, e->ai_addrlen) < 0) { rc = -socket_error(); } } while (rc == -EINTR); #ifdef _WIN32 if (!block && (rc == -EINPROGRESS || rc == -EWOULDBLOCK || rc == -WSAEALREADY)) { #else if (!block && (rc == -EINPROGRESS)) { #endif error_set(errp, QERR_SOCKET_CONNECT_IN_PROGRESS); } else if (rc < 0) { if (NULL == e->ai_next) fprintf(stderr, "%s: connect(%s,%s,%s,%s): %s\n", __FUNCTION__, inet_strfamily(e->ai_family), e->ai_canonname, uaddr, uport, strerror(errno)); closesocket(sock); continue; } freeaddrinfo(res); return sock; } error_set(errp, QERR_SOCKET_CONNECT_FAILED); freeaddrinfo(res); return -1; }
1threat
void msix_unuse_all_vectors(PCIDevice *dev) { if (!(dev->cap_present & QEMU_PCI_CAP_MSIX)) return; msix_free_irq_entries(dev); }
1threat
Copy first 7 keys in object into a new object : <p>As the title suggests, how do I make a new object containing the 7 first keys of another object using JS? :) This is the structure of the object I would like to copy the data from.</p> <pre><code>{"data":[{"id":2338785,"team1":{"id":10531,"name":"Just For Fun"},"team2":{"id":10017,"name":"Rugratz"},"result":"2 - 0","event":{"name":"Mythic Cup 5","id":5148},"format":"bo3","stars":0,"date":1578279271000},....],"last_update":1578329378792} </code></pre> <p>Let's say there are 100 keys like this one, and I only want to copy the 7 first ones into a new object in JS.</p>
0debug
Cant add item to listview C# : Hello i have this code in C# to get the files and list them in listview but nothing happens string[] files = Directory.GetFiles("plugins/"); foreach (string file in files) { string fileName = Path.GetFileNameWithoutExtension(file); ListViewItem item = new ListViewItem(fileName); item.Tag = file; listView1.Items.Clear(); listView1.Items.Add(item); } i even tried to insert a different one with single line of code listView1.Items.Clear(); listView1.Items.Add("item"); but it did not work Thank You
0debug
How to write 2 byte arrays to a file c#? : I have 2 arrays from my own created zip program.<br> farArray and bytes.<br> they are both byte arrays.<br><br> Now I want to save that in a file (example: "file.zip").<br><br> I know that I can write bytes with this code:<br> File.WriteAllBytes(savefile.FileName, bytes); But I only save 1 byteArray now.<br> How to save 2 of them?<br><br> And can I get back the 2 arrays if I open the file in my script?<br>
0debug
docker-compose start "ERROR: No containers to start" : <p>I am trying to use Docker Compose (with Docker Machine on Windows) to launch a group of Docker containers. </p> <p>My docker-compose.yml:</p> <pre><code>version: '2' services: postgres: build: ./postgres environment: - POSTGRES_PASSWORD=mysecretpassword frontend: build: ./frontend ports: - "4567:4567" depends_on: - postgres backend: build: ./backend ports: - "5000:5000" depends_on: - postgres </code></pre> <p><code>docker-compose build</code> runs successfully. When I run <code>docker-compose start</code> I get the following output:</p> <pre><code>Starting postgres ... done Starting frontend ... done Starting backend ... done ERROR: No containers to start </code></pre> <p>I did confirm that the docker containers are not running. How do I get my containers to start?</p>
0debug
static int mov_read_stsz(MOVContext *c, ByteIOContext *pb, MOVAtom atom) { AVStream *st = c->fc->streams[c->fc->nb_streams-1]; MOVStreamContext *sc = st->priv_data; unsigned int i, entries, sample_size, field_size, num_bytes; GetBitContext gb; unsigned char* buf; get_byte(pb); get_be24(pb); if (atom.type == MKTAG('s','t','s','z')) { sample_size = get_be32(pb); if (!sc->sample_size) sc->sample_size = sample_size; field_size = 32; } else { sample_size = 0; get_be24(pb); field_size = get_byte(pb); } entries = get_be32(pb); dprintf(c->fc, "sample_size = %d sample_count = %d\n", sc->sample_size, entries); sc->sample_count = entries; if (sample_size) return 0; if (field_size != 4 && field_size != 8 && field_size != 16 && field_size != 32) { av_log(c->fc, AV_LOG_ERROR, "Invalid sample field size %d\n", field_size); return -1; } if(entries >= UINT_MAX / sizeof(int)) return -1; sc->sample_sizes = av_malloc(entries * sizeof(int)); if (!sc->sample_sizes) return AVERROR(ENOMEM); num_bytes = (entries*field_size+4)>>3; buf = av_malloc(num_bytes+FF_INPUT_BUFFER_PADDING_SIZE); if (!buf) { av_freep(&sc->sample_sizes); return AVERROR(ENOMEM); } if (get_buffer(pb, buf, num_bytes) < num_bytes) { av_freep(&sc->sample_sizes); av_free(buf); return -1; } init_get_bits(&gb, buf, 8*num_bytes); for(i=0; i<entries; i++) sc->sample_sizes[i] = get_bits_long(&gb, field_size); av_free(buf); return 0; }
1threat
static void virtio_host_initfn(Object *obj) { VirtIOInputHostPCI *dev = VIRTIO_INPUT_HOST_PCI(obj); virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_INPUT_HOST); }
1threat
sql sever date column sorting dates automatically : I have a table with a date column. I am inserting dates in that column using DateTimePicker in c#. Everything works fine. But I want the dates inserted in the table to be ordered. Currently when I add today's date in one row and then add yesterday's date or any past date, it gets added in the 2nd row ofc. I want that to be added in 1st row instead. Before today's date, to make all the dates in order. Is there any property of the date column I can use to ensure the dates order?
0debug
In Which situation MYISAM AND INNODB Engine should be used : <p>Give me some practical examples in which I can understand use of both myisam and innodb engine</p>
0debug
Getting error CreateListFromArrayLike called on non-object when trying to use .apply() : <p>I've created a simple little route parsing function so that I can keep my code clean and easily maintainable, this is the little function that gets ran when the app starts up and parses the <code>config.json</code> file and binds the appropriate methods and request paths:</p> <pre><code>const fs = require('fs'); const path = require('path'); module.exports = function(app, root) { fs.readdirSync(root).forEach((file) =&gt; { let dir = path.resolve(root, file); let stats = fs.lstatSync(dir); if (stats.isDirectory()) { let conf = require(dir + '/config.json'); conf.name = file; conf.directory = dir; if (conf.routes) route(app, conf); } }) } function route(app, conf) { let mod = require(conf.directory); for (let key in conf.routes) { let prop = conf.routes[key]; let method = key.split(' ')[0]; let path = key.split(' ')[1]; let fn = mod[prop]; if (!fn) throw new Error(conf.name + ': exports.' + prop + ' is not defined'); if (Array.isArray(fn)) { app[method.toLowerCase()].apply(this, path, fn); } else { app[method.toLowerCase()](path, fn); } } } </code></pre> <p>The problem I have is some times I need to pass in multiple arguments to an express router, e.g. in the case of using passport something like this:</p> <pre><code>exports.authSteam = [ passport.authenticate('facebook', { failureRedirect: '/' }), function(req, res) { res.redirect("/"); } ]; </code></pre> <p>So I figure I can just pass them as an array, and then parse them into the router appropriately, my config for example looks like this:</p> <pre><code>{ "name": "Routes for the authentication", "description": "Handles the authentication", "routes": { "GET /auth/facebook": "authFacebook", "GET /auth/facebook/return": "authFacebookReturn" } } </code></pre> <p>The only problem is I'm getting this error:</p> <pre><code> app[method.toLowerCase()].apply(this, path, fn); ^ TypeError: CreateListFromArrayLike called on non-object </code></pre> <p>if I <code>console.log(fn)</code> I see <code>[ [Function: authenticate], [Function] ]</code></p> <p>I'm not exactly sure what I am doing wrong, any information would be great thanks.</p>
0debug
<div> cannot appear as a descendant of <p> : <p>I'm seeing this. It's not a mystery what it is complaining about:</p> <pre><code>Warning: validateDOMnesting(...): &lt;div&gt; cannot appear as a descendant of &lt;p&gt;. See ... SomeComponent &gt; p &gt; ... &gt; SomeOtherComponent &gt; ReactTooltip &gt; div. </code></pre> <p>I'm the author of <code>SomeComponent</code> and <code>SomeOtherComponent</code>. But the latter is using an external dependency (<code>ReactTooltip</code> from <a href="https://github.com/wwayne/react-tooltip" rel="noreferrer"><code>react-tooltip</code></a>). It's probably not essential that this is an external dependency, but it lets me try the argument here that it is "some code that's out of my control".</p> <p>How worried should I be about this warning, given that the nested component is working just fine (seemingly)? And how would I go about changing this anyway (provided I don't want to re-implement an external dependency)? Is there maybe a better design that I'm yet unaware of?</p> <p>For completeness sake, here's the implementation of <code>SomeOtherComponent</code>. It just renders <code>this.props.value</code>, and when hovered: a tooltip that says "Some tooltip message":</p> <pre><code>class SomeOtherComponent extends React.Component { constructor(props) { super(props) } render() { const {value, ...rest} = this.props; return &lt;span className="some-other-component"&gt; &lt;a href="#" data-tip="Some tooltip message" {...rest}&gt;{value}&lt;/a&gt; &lt;ReactTooltip /&gt; &lt;/span&gt; } } </code></pre> <p>Thank you.</p>
0debug
UserDefTwo *qmp_user_def_cmd2(UserDefOne *ud1a, bool has_udb1, UserDefOne *ud1b, Error **errp) { UserDefTwo *ret; UserDefOne *ud1c = g_malloc0(sizeof(UserDefOne)); UserDefOne *ud1d = g_malloc0(sizeof(UserDefOne)); ud1c->string = strdup(ud1a->string); ud1c->base = g_new0(UserDefZero, 1); ud1c->base->integer = ud1a->base->integer; ud1d->string = strdup(has_udb1 ? ud1b->string : "blah0"); ud1d->base = g_new0(UserDefZero, 1); ud1d->base->integer = has_udb1 ? ud1b->base->integer : 0; ret = g_new0(UserDefTwo, 1); ret->string0 = strdup("blah1"); ret->dict1 = g_new0(UserDefTwoDict, 1); ret->dict1->string1 = strdup("blah2"); ret->dict1->dict2 = g_new0(UserDefTwoDictDict, 1); ret->dict1->dict2->userdef = ud1c; ret->dict1->dict2->string = strdup("blah3"); ret->dict1->dict3 = g_new0(UserDefTwoDictDict, 1); ret->dict1->has_dict3 = true; ret->dict1->dict3->userdef = ud1d; ret->dict1->dict3->string = strdup("blah4"); return ret; }
1threat
static int idcin_probe(AVProbeData *p) { unsigned int number, sample_rate; if (p->buf_size < 20) return 0; number = AV_RL32(&p->buf[0]); if ((number == 0) || (number > 1024)) return 0; number = AV_RL32(&p->buf[4]); if ((number == 0) || (number > 1024)) return 0; sample_rate = AV_RL32(&p->buf[8]); if (sample_rate && (sample_rate < 8000 || sample_rate > 48000)) return 0; number = AV_RL32(&p->buf[12]); if (number > 2 || sample_rate && !number) return 0; number = AV_RL32(&p->buf[16]); if (number > 2 || sample_rate && !number) return 0; return AVPROBE_SCORE_EXTENSION; }
1threat
static int dvbsub_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size) { DVBSubParseContext *pc = s->priv_data; uint8_t *p, *p_end; int i, len, buf_pos = 0; av_dlog(avctx, "DVB parse packet pts=%"PRIx64", lpts=%"PRIx64", cpts=%"PRIx64":\n", s->pts, s->last_pts, s->cur_frame_pts[s->cur_frame_start_index]); for (i=0; i < buf_size; i++) { av_dlog(avctx, "%02x ", buf[i]); if (i % 16 == 15) av_dlog(avctx, "\n"); } if (i % 16 != 0) av_dlog(avctx, "\n"); *poutbuf = NULL; *poutbuf_size = 0; s->fetch_timestamp = 1; if (s->last_pts != s->pts && s->pts != AV_NOPTS_VALUE) { if (pc->packet_index != pc->packet_start) { av_dlog(avctx, "Discarding %d bytes\n", pc->packet_index - pc->packet_start); } pc->packet_start = 0; pc->packet_index = 0; if (buf_size < 2 || buf[0] != 0x20 || buf[1] != 0x00) { av_dlog(avctx, "Bad packet header\n"); return -1; } buf_pos = 2; pc->in_packet = 1; } else { if (pc->packet_start != 0) { if (pc->packet_index != pc->packet_start) { memmove(pc->packet_buf, pc->packet_buf + pc->packet_start, pc->packet_index - pc->packet_start); pc->packet_index -= pc->packet_start; pc->packet_start = 0; } else { pc->packet_start = 0; pc->packet_index = 0; } } } if (buf_size - buf_pos + pc->packet_index > PARSE_BUF_SIZE) return -1; if (pc->in_packet == 0) return buf_size; memcpy(pc->packet_buf + pc->packet_index, buf + buf_pos, buf_size - buf_pos); pc->packet_index += buf_size - buf_pos; p = pc->packet_buf; p_end = pc->packet_buf + pc->packet_index; while (p < p_end) { if (*p == 0x0f) { if (p + 6 <= p_end) { len = AV_RB16(p + 4); if (p + len + 6 <= p_end) { *poutbuf_size += len + 6; p += len + 6; } else break; } else break; } else if (*p == 0xff) { if (p + 1 < p_end) { av_dlog(avctx, "Junk at end of packet\n"); } pc->packet_index = p - pc->packet_buf; pc->in_packet = 0; break; } else { av_log(avctx, AV_LOG_ERROR, "Junk in packet\n"); pc->packet_index = p - pc->packet_buf; pc->in_packet = 0; break; } } if (*poutbuf_size > 0) { *poutbuf = pc->packet_buf; pc->packet_start = *poutbuf_size; } if (s->pts == AV_NOPTS_VALUE) s->pts = s->last_pts; return buf_size; }
1threat
C command similar to "if x in list" of Python : <p>In Python we could use <code>if x in list:</code> so I was wondering if there's a similar command in C, so that we don't have to go through the whole thing using a <code>for</code>.</p>
0debug
a code for checking leap year and counting no of days in a month in python : this is my code: def cal(month): if month in ['January', 'march','may','july','august','oct','dec']: print ("this month has 31 days") elif month in ['april','june','sept','nov']: print ("this month has 30 days") elif month == 'feb' and leap(year)== True: print ("this month has 29 days") elif month == 'feb' and leap(year) == False: print ("this month has 28 days") else: print ("invalid input") def leap(year): if (year % 4== 0) or (year % 400 == 0): print ("its a leap year!") else: print ("is not a leap year") year = int(input('type a year: ')) print ('you typed in :' , year) month = str(input('type a month: ')) print ('you typed in :', month) cal(month) leap(year) o/p: type a year: 2013 you typed in : 2013 type a month: feb you typed in : feb is not a leap year is not a leap year invalid input is not a leap year why am i not getting the output for count of days in feb if it is a 28 day month or 29? why am i getting the invalid input part even though its an else? Help is appreciated. Thanks.
0debug
Parallel execution in testNG Selenium : I am not able to invoke the browsers in parallel which invokes one after another. So please suggest an idea to invoke parallel. NOTE: In my .xml file i have thread count as 2
0debug
How to parse array using decodable? : <p>How can I parse this kind of array using decodable protocol ? </p> <p>any advice or sample code please ?</p> <pre><code>{ "prices": [ [ 1543165872687, 3806.312680456958 ], [ 1543166191453, 3773.774449897494 ], [ 1543166462780, 3761.2358246729386 ], [ 1543166765273, 3765.5068929779973 ] ] } </code></pre> <p><strong>My call service func like this :</strong> </p> <pre><code> ServiceConnector.shared.connect(.GetCoinGeckoChartData(id: id, currcy: currency, days: days), success: { (target,data) in self.hideProgressHUD() do { let array = try JSONDecoder().decode([CoinGeckoChartData].self, from: data) } catch let err { print("CoinGeckoChartData json parsing err : ",err) } }) </code></pre>
0debug
Trigger a GitHub Action when another repository creates a new release : <p>I'm trying to build a GitHub workflow that will be triggered when another repository creates a new release.</p> <p>In the documentation, there is the paragraph: <a href="https://help.github.com/en/articles/workflow-syntax-for-github-actions#onevent_nametypes" rel="noreferrer"><code>on.event_name.types</code></a> where <code>event_name</code> will be <code>release</code>.</p> <p>The question is: Is there any way to refer to the <code>release</code> event of another repository?</p>
0debug
Change dates to first day of the month in R : <p>How do I change my dates to the first day of the month...so 3/31/19 becomes 3/1/19, 2/28/19 becomes 2/1/19, and so on.</p> <p>Thanks</p>
0debug
av_cold void ff_hpeldsp_vp3_init_x86(HpelDSPContext *c, int cpu_flags, int flags) { if (EXTERNAL_AMD3DNOW(cpu_flags)) { if (flags & AV_CODEC_FLAG_BITEXACT) { c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_exact_3dnow; c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_exact_3dnow; } } if (EXTERNAL_MMXEXT(cpu_flags)) { if (flags & AV_CODEC_FLAG_BITEXACT) { c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_exact_mmxext; c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_exact_mmxext; } } }
1threat
How to set C# application to accept Command Line Parameters? : <p>I have created a C# command line application that creates a few reports automatically for my client. However, even though they use 95% of the same code I would like to split them in to different processes. I am using Windows task scheduler to run them. How do I set up the C# application to accept Command line parameters upon runtime?</p> <p>I cannot find any explanation of this on the internet. </p>
0debug
Algorithm to find the optimal payment schedule : I've got an array of bank accounts that have a minimum monthly payment requirement and I'm trying to figure out the logic to get the optimal payment schedule. Here's the array structure: array(4) { ["account_one"]=> array(9) { ["account"]=> string(21) "Account One" ["balance"]=> int(2500) ["minimum_payment"]=> int(1000) } ["account_two"]=> array(9) { ["account"]=> string(16) "Account Two" ["balance"]=> int(1500) ["minimum_payment"]=> int(500) } ["account_three"]=> array(9) { ["account"]=> string(10) "Account Three" ["balance"]=> int(3000) ["minimum_payment"]=> int(750) } ["account_four"]=> array(9) { ["account"]=> string(14) "Account Four" ["balance"]=> int(3000) ["minimum_payment"]=> int(750) } } In this example, the total amount of money in the accounts is 10000 and it needs to be moved between each account to meet the minimum payment requirement. The payment schedule also needs to be as efficient as possible, with the fewest number of payments to meet the requirements. This is a simple example, but in production we might have 15 or more accounts with varying minimum payment amounts. What I've got so far isn't very much as I'm struggling to grasp the overall logic I need: $accounts_by_amount (array of accounts sorted by balance high to low) $accounts_reversed ($accounts_by_amount in reverse order) $schedule = array() foreach $accounts_by_amount as $account_a foreach $accounts_reversed as $account_b if $account_a['minimum_payment'] > $account_b['mininum_payment'] // use higher minimum payment to reduce total payments needed $schedule_b[] = array( 'from' => $account_a['account'], 'to' => $account_b['account'], 'amount' => $account_a['minimum_payment'], ); else continue; if $schedule_b $schedule += $schedule_b else continue This doesn't work, obviously, but I think I might be making this overly complex with the loop within a loop. I'm not looking for somebody to actually write code for me, more to tell me how dumb I'm being with the logic and a rough idea of how to pull this schedule together with the minimum number of payments. Any ideas greatly appreciated/please don't downvote :P
0debug
Is there a declarative way to transform Array to Dictionary? : <p>I want to get from this array of strings</p> <pre><code>let entries = ["x=5", "y=7", "z=10"] </code></pre> <p>to this</p> <pre><code>let keyValuePairs = ["x" : "5", "y" : "7", "z" : "10"] </code></pre> <p>I tried to use <code>map</code> but the problem seems to be that a key - value pair in a dictionary is not a distinct type, it's just in my mind, but not in the Dictionary type so I couldn't really provide a transform function because there is nothing to transform to. Plus <code>map</code> return an array so it's a no go.</p> <p>Any ideas?</p>
0debug
how to look up a word if a certain word exists write a dictionary : I have a .txt file looks like this [enter image description here][1] [1]: https://i.stack.imgur.com/WtyjV.png As you can see its a several relationships between the verbs (dont care about the numbers) the file has 5,000 lines. what I want is a dict for each relationship, so that we could say for example similar-to['anger'] = 'energize' happens-before['X'] = 'Y' stronger-than ['A'] = 'B' and so on. So What I have so far is working perfectly for only [stronger-than] relationship. how should I extend it in a way that does all other relationships as well? import csv file = open("C:\\Users\\shide\\Desktop\\Independent study\\data.txt") counter = 1 stronger = {} strongerverb = [] secondverb = [] term1 = "[stronger-than]" #Look for stronger-than words = line.split() #split sentence if term1 in words: #if ['Stronger-than'] exists in the line then add the first word strongerverb.append(line.split(None, 1)[0]) # add only first verb secondverb.append(line.split()[2]) #add second verb if term1 in words: # if ['Stronger-than'] exists in the line then add the first word strongerverb.append(line.split(None, 1)[0]) # add only first verb secondverb.append(line.split()[2]) # add second verb capacity = len(strongerverb) index = 0 while index!=capacity: line = strongerverb[index] for word in line.split(): # print(word) index = index+1 #print("First verb:",firstverb) #print("Second verb:",secondverb) for i in range(len(strongerverb)): stronger[strongerverb[i]] = secondverb[i] #Write a CSV file that fist coloum is containing verbs that is stronger than the second coloum. with open('output.csv', 'w') as output: writer = csv.writer(output, lineterminator='\n') for secondverb, strongerverb in stronger.items(): writer.writerow([strongerverb, secondverb]) One way is to do same way for all other relationships but I guess that would not be a smart thing. Any ideas? what I want is a dict for each relationship, so that we could say: similar-to['anger'] = 'energize' happens-before['X'] = 'Y' stronger-than ['A'] = 'B' I am new to python and any help would be greatly appreciated.
0debug
How should I save the data from the json response in Android? : <p>lets say I'm creating an app to browse reddit using their API. I'm getting a json response containing submissions, which I plan to populate a listview with. My question is how I should save this data? Should I create a bunch of objects or is there a better way to save it? I will need to be able to identify which submission the user clicks on so they can view the full thread etc.</p>
0debug
What are these seemingly-useless callq instructions in my x86 object files for? : <p>I have some template-heavy C++ code that I want to ensure the compiler optimizes as much as possible due to the large amount of information it has at compile time. To evaluate its performance, I decided to take a look at the disassembly of the object file that it generates. Below is a snippet of what I got from <code>objdump -dC</code>:</p> <pre><code>0000000000000000 &lt;bar&lt;foo, 0u&gt;::get(bool)&gt;: 0: 41 57 push %r15 2: 49 89 f7 mov %rsi,%r15 5: 41 56 push %r14 7: 41 55 push %r13 9: 41 54 push %r12 b: 55 push %rbp c: 53 push %rbx d: 48 81 ec 68 02 00 00 sub $0x268,%rsp 14: 48 89 7c 24 10 mov %rdi,0x10(%rsp) 19: 48 89 f7 mov %rsi,%rdi 1c: 89 54 24 1c mov %edx,0x1c(%rsp) 20: e8 00 00 00 00 callq 25 &lt;bar&lt;foo, 0u&gt;::get(bool)+0x25&gt; 25: 84 c0 test %al,%al 27: 0f 85 eb 00 00 00 jne 118 &lt;bar&lt;foo, 0u&gt;::get(bool)+0x118&gt; 2d: 48 c7 44 24 08 00 00 movq $0x0,0x8(%rsp) 34: 00 00 36: 4c 89 ff mov %r15,%rdi 39: 4d 8d b7 30 01 00 00 lea 0x130(%r15),%r14 40: e8 00 00 00 00 callq 45 &lt;bar&lt;foo, 0u&gt;::get(bool)+0x45&gt; 45: 84 c0 test %al,%al 47: 88 44 24 1b mov %al,0x1b(%rsp) 4b: 0f 85 ef 00 00 00 jne 140 &lt;bar&lt;foo, 0u&gt;::get(bool)+0x140&gt; 51: 80 7c 24 1c 00 cmpb $0x0,0x1c(%rsp) 56: 0f 85 24 03 00 00 jne 380 &lt;bar&lt;foo, 0u&gt;::get(bool)+0x380&gt; 5c: 48 8b 44 24 10 mov 0x10(%rsp),%rax 61: c6 00 00 movb $0x0,(%rax) 64: 80 7c 24 1b 00 cmpb $0x0,0x1b(%rsp) 69: 75 25 jne 90 &lt;bar&lt;foo, 0u&gt;::get(bool)+0x90&gt; 6b: 48 8b 74 24 10 mov 0x10(%rsp),%rsi 70: 4c 89 ff mov %r15,%rdi 73: e8 00 00 00 00 callq 78 &lt;bar&lt;foo, 0u&gt;::get(bool)+0x78&gt; 78: 48 8b 44 24 10 mov 0x10(%rsp),%rax 7d: 48 81 c4 68 02 00 00 add $0x268,%rsp 84: 5b pop %rbx 85: 5d pop %rbp 86: 41 5c pop %r12 88: 41 5d pop %r13 8a: 41 5e pop %r14 8c: 41 5f pop %r15 8e: c3 retq 8f: 90 nop 90: 4c 89 f7 mov %r14,%rdi 93: e8 00 00 00 00 callq 98 &lt;bar&lt;foo, 0u&gt;::get(bool)+0x98&gt; 98: 83 f8 04 cmp $0x4,%eax 9b: 74 f3 je 90 &lt;bar&lt;foo, 0u&gt;::get(bool)+0x90&gt; 9d: 85 c0 test %eax,%eax 9f: 0f 85 e4 08 00 00 jne 989 &lt;bar&lt;foo, 0u&gt;::get(bool)+0x989&gt; a5: 49 83 87 b0 01 00 00 addq $0x1,0x1b0(%r15) ac: 01 ad: 49 8d 9f 58 01 00 00 lea 0x158(%r15),%rbx b4: 48 89 df mov %rbx,%rdi b7: e8 00 00 00 00 callq bc &lt;bar&lt;foo, 0u&gt;::get(bool)+0xbc&gt; bc: 49 8d bf 80 01 00 00 lea 0x180(%r15),%rdi c3: e8 00 00 00 00 callq c8 &lt;bar&lt;foo, 0u&gt;::get(bool)+0xc8&gt; c8: 48 89 df mov %rbx,%rdi cb: e8 00 00 00 00 callq d0 &lt;bar&lt;foo, 0u&gt;::get(bool)+0xd0&gt; d0: 4c 89 f7 mov %r14,%rdi d3: e8 00 00 00 00 callq d8 &lt;bar&lt;foo, 0u&gt;::get(bool)+0xd8&gt; d8: 83 f8 04 cmp $0x4,%eax </code></pre> <p>The disassembly of this particular function continues on, but one thing I noticed is the relatively large number of <code>call</code> instructions like this one:</p> <pre><code>20: e8 00 00 00 00 callq 25 &lt;bar&lt;foo, 0u&gt;::get(bool)+0x25&gt; </code></pre> <p>These instructions, always with the opcode <code>e8 00 00 00 00</code>, occur frequently throughout the generated code, and from what I can tell, are nothing more than no-ops; they all seem to just fall through to the next instruction. This begs the question, then, is there a good reason why all these instructions are generated? </p> <p>I'm concerned about the instruction cache footprint of the generated code, so wasting 5 bytes many times throughout a function seems counterproductive. It seems a bit heavyweight for a <code>nop</code>, unless the compiler is trying to preserve some kind of memory alignment or something. I wouldn't be surprised if this were the case.</p> <p>I compiled my code using g++ 4.8.5 using <code>-O3 -fomit-frame-pointer</code>. For what it's worth, I saw similar code generation using clang 3.7.</p>
0debug
PHP Why does my foreach loop only give 1 result? : <p>Why does my foreach only show 1 result and why not both results, since it clearly shows in my database there are 2 results with Com_Id 1 but still it only gives me 1 result. This is how my Database looks like <a href="https://i.stack.imgur.com/xuXjt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xuXjt.jpg" alt="database"></a></p> <p>this are the results that I get</p> <p><a href="https://i.stack.imgur.com/0U3es.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0U3es.jpg" alt="enter image description here"></a></p> <pre><code>$id = $_GET['view']; </code></pre> <p>Mycode:</p> <pre><code>&lt;?php $sql = "SELECT * FROM IA_Monitor WHERE Com_ID = :id"; $query = $conn-&gt;prepare($sql); $query-&gt;execute(array(':id' =&gt; $id)); while($row = $query-&gt;fetch(PDO::FETCH_ASSOC)){ $mon_comid = $row['Com_ID']; $mon_barcode[0] = $row['Barcode']; $mon_merk = $row['Merk']; $mon_type = $row['Type']; $mon_inch = $row['Inch']; $mon_a_dat = $row['Aanschaf_dat']; $mon_a_prijs = $row['Aanschaf_waarde']; } $monnewDate = date("d-m-Y", strtotime($mon_a_dat)); if($id==$mon_comid){ foreach($mon_barcode as $key =&gt; $value){ ?&gt; &lt;title&gt;&lt;?php echo $value; ?&gt;&lt;/title&gt; &lt;table&gt; &lt;tr&gt;&lt;td&gt;Monitorbarcode: &lt;/td&gt;&lt;td&gt;&lt;?php echo $value;?&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Merk: &lt;/td&gt;&lt;td&gt;&lt;?php echo $mon_merk;?&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Type: &lt;/td&gt;&lt;td&gt;&lt;?php echo $mon_type;?&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Inch: &lt;/td&gt;&lt;td&gt;&lt;?php echo $mon_inch;?&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Aanschaf datum: &lt;/td&gt;&lt;td&gt;&lt;?php echo $monnewDate;?&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Aanschaf waarde: &lt;/td&gt;&lt;td&gt;&lt;?php echo "&amp;euro;".number_format((float)$mon_a_prijs, 2, '.', '')."";?&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;?php }}else{ echo "&lt;i&gt;Geen monitoren gevonden&lt;/i&gt;"; } ?&gt; </code></pre> <p>Does anyone have any idea why it doesnt work and could you maybe help me understand and help me with fixing this?</p>
0debug
How to line up/indent this text evenly? : <p><a href="https://i.stack.imgur.com/AMGg8.png" rel="nofollow noreferrer">Pic of Uneven text</a></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-html lang-html prettyprint-override"><code> &lt;img src="https://maxcdn.icons8.com/iOS7/PNG/25/Business/pricing_structure-25.png" title="Pricing Structure" width="25" style="margin-right: 8px"&gt; Choose ones of our packages or build your own. Choose ones of our packages or build your own. &lt;a href="pricing.html"&gt;View pricing.&lt;/a&gt;</code></pre> </div> </div> </p>
0debug
Axios is not defined : <p>I am using axios for building a simple weather app with React.js. I just completed the code but there is a problem. When I launch that app, it's not working at all and I see a reference error that says <code>axios is not defined</code>.</p> <p>Here is my webpack.config.js file:</p> <pre><code>module.exports = { entry: './public/app/app.jsx', output: { path: __dirname, filename: './public/js/bundle.js' }, externals: ['axios'], resolve: { root: __dirname, alias: { OpenWeatherMap: 'public/components/OpenWeatherMap.jsx', Main: 'public/components/Main.jsx', Nav: 'public/components/Nav.jsx', Weather: 'public/components/Weather.jsx', WeatherForm: 'public/components/WeatherForm.jsx', WeatherMessage: 'public/components/WeatherMessage.jsx', About: 'public/components/About.jsx' }, extensions: ['', '.js', '.jsx'] }, module: { loaders: [{ loader: 'babel-loader', query: { presets: ['react','es2015', 'stage-0'] }, test: /\.jsx?$/, exclude: /(node_modules|bower_components)/ },{ loader: 'json-loader', test: /\.json?$/ }] } }; </code></pre> <p>and package.json file:</p> <pre><code>{ "name": "weather", "version": "1.0.0", "description": "Simple Weather App", "main": "ext.js", "scripts": { "test": "echo \"Error: no test specified\" &amp;&amp; exit 1" }, "author": "Milad Fattahi", "license": "ISC", "dependencies": { "axios": "^0.16.1", "express": "^4.15.3", "json": "^9.0.6", "json-loader": "^0.5.4", "react": "^15.5.4", "react-dom": "^15.5.4", "react-router": "^4.1.1", "react-router-dom": "^4.1.1" }, "devDependencies": { "babel-core": "^6.5.1", "babel-loader": "^6.2.2", "babel-preset-es2015": "^6.5.0", "babel-preset-react": "^6.5.0", "babel-preset-stage-0": "^6.24.1", "webpack": "^1.12.13" } } </code></pre>
0debug
Default value of minimum_should_match? : <p>Cant find which is the default value of <code>minimum_should_match</code> in the docs</p> <p><a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-minimum-should-match.html" rel="noreferrer">https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-minimum-should-match.html</a></p> <p>Is it <code>0</code> or <code>1</code>, or depends if the query has just <code>should</code> or <code>filter</code> context?</p>
0debug
static int encode_thread(AVCodecContext *c, void *arg){ MpegEncContext *s= *(void**)arg; int mb_x, mb_y, pdif = 0; int chr_h= 16>>s->chroma_y_shift; int i, j; MpegEncContext best_s, backup_s; uint8_t bit_buf[2][MAX_MB_BYTES]; uint8_t bit_buf2[2][MAX_MB_BYTES]; uint8_t bit_buf_tex[2][MAX_MB_BYTES]; PutBitContext pb[2], pb2[2], tex_pb[2]; for(i=0; i<2; i++){ init_put_bits(&pb [i], bit_buf [i], MAX_MB_BYTES); init_put_bits(&pb2 [i], bit_buf2 [i], MAX_MB_BYTES); init_put_bits(&tex_pb[i], bit_buf_tex[i], MAX_MB_BYTES); } s->last_bits= put_bits_count(&s->pb); s->mv_bits=0; s->misc_bits=0; s->i_tex_bits=0; s->p_tex_bits=0; s->i_count=0; s->f_count=0; s->b_count=0; s->skip_count=0; for(i=0; i<3; i++){ s->last_dc[i] = 128 << s->intra_dc_precision; s->current_picture.f.error[i] = 0; } s->mb_skip_run = 0; memset(s->last_mv, 0, sizeof(s->last_mv)); s->last_mv_dir = 0; switch(s->codec_id){ case AV_CODEC_ID_H263: case AV_CODEC_ID_H263P: case AV_CODEC_ID_FLV1: if (CONFIG_H263_ENCODER) s->gob_index = ff_h263_get_gob_height(s); break; case AV_CODEC_ID_MPEG4: if(CONFIG_MPEG4_ENCODER && s->partitioned_frame) ff_mpeg4_init_partitions(s); break; } s->resync_mb_x=0; s->resync_mb_y=0; s->first_slice_line = 1; s->ptr_lastgob = s->pb.buf; for(mb_y= s->start_mb_y; mb_y < s->end_mb_y; mb_y++) { s->mb_x=0; s->mb_y= mb_y; ff_set_qscale(s, s->qscale); ff_init_block_index(s); for(mb_x=0; mb_x < s->mb_width; mb_x++) { int xy= mb_y*s->mb_stride + mb_x; int mb_type= s->mb_type[xy]; int dmin= INT_MAX; int dir; if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < MAX_MB_BYTES){ av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n"); return -1; } if(s->data_partitioning){ if( s->pb2 .buf_end - s->pb2 .buf - (put_bits_count(&s-> pb2)>>3) < MAX_MB_BYTES || s->tex_pb.buf_end - s->tex_pb.buf - (put_bits_count(&s->tex_pb )>>3) < MAX_MB_BYTES){ av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n"); return -1; } } s->mb_x = mb_x; s->mb_y = mb_y; ff_update_block_index(s); if(CONFIG_H261_ENCODER && s->codec_id == AV_CODEC_ID_H261){ ff_h261_reorder_mb_index(s); xy= s->mb_y*s->mb_stride + s->mb_x; mb_type= s->mb_type[xy]; } if(s->rtp_mode){ int current_packet_size, is_gob_start; current_packet_size= ((put_bits_count(&s->pb)+7)>>3) - (s->ptr_lastgob - s->pb.buf); is_gob_start= s->avctx->rtp_payload_size && current_packet_size >= s->avctx->rtp_payload_size && mb_y + mb_x>0; if(s->start_mb_y == mb_y && mb_y > 0 && mb_x==0) is_gob_start=1; switch(s->codec_id){ case AV_CODEC_ID_H263: case AV_CODEC_ID_H263P: if(!s->h263_slice_structured) if(s->mb_x || s->mb_y%s->gob_index) is_gob_start=0; break; case AV_CODEC_ID_MPEG2VIDEO: if(s->mb_x==0 && s->mb_y!=0) is_gob_start=1; case AV_CODEC_ID_MPEG1VIDEO: if(s->mb_skip_run) is_gob_start=0; break; } if(is_gob_start){ if(s->start_mb_y != mb_y || mb_x!=0){ write_slice_end(s); if(CONFIG_MPEG4_ENCODER && s->codec_id==AV_CODEC_ID_MPEG4 && s->partitioned_frame){ ff_mpeg4_init_partitions(s); } } assert((put_bits_count(&s->pb)&7) == 0); current_packet_size= put_bits_ptr(&s->pb) - s->ptr_lastgob; if (s->error_rate && s->resync_mb_x + s->resync_mb_y > 0) { int r= put_bits_count(&s->pb)/8 + s->picture_number + 16 + s->mb_x + s->mb_y; int d = 100 / s->error_rate; if(r % d == 0){ current_packet_size=0; s->pb.buf_ptr= s->ptr_lastgob; assert(put_bits_ptr(&s->pb) == s->ptr_lastgob); } } if (s->avctx->rtp_callback){ int number_mb = (mb_y - s->resync_mb_y)*s->mb_width + mb_x - s->resync_mb_x; s->avctx->rtp_callback(s->avctx, s->ptr_lastgob, current_packet_size, number_mb); } update_mb_info(s, 1); switch(s->codec_id){ case AV_CODEC_ID_MPEG4: if (CONFIG_MPEG4_ENCODER) { ff_mpeg4_encode_video_packet_header(s); ff_mpeg4_clean_buffers(s); } break; case AV_CODEC_ID_MPEG1VIDEO: case AV_CODEC_ID_MPEG2VIDEO: if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER) { ff_mpeg1_encode_slice_header(s); ff_mpeg1_clean_buffers(s); } break; case AV_CODEC_ID_H263: case AV_CODEC_ID_H263P: if (CONFIG_H263_ENCODER) ff_h263_encode_gob_header(s, mb_y); break; } if(s->flags&CODEC_FLAG_PASS1){ int bits= put_bits_count(&s->pb); s->misc_bits+= bits - s->last_bits; s->last_bits= bits; } s->ptr_lastgob += current_packet_size; s->first_slice_line=1; s->resync_mb_x=mb_x; s->resync_mb_y=mb_y; } } if( (s->resync_mb_x == s->mb_x) && s->resync_mb_y+1 == s->mb_y){ s->first_slice_line=0; } s->mb_skipped=0; s->dquant=0; update_mb_info(s, 0); if (mb_type & (mb_type-1) || (s->mpv_flags & FF_MPV_FLAG_QP_RD)) { int next_block=0; int pb_bits_count, pb2_bits_count, tex_pb_bits_count; copy_context_before_encode(&backup_s, s, -1); backup_s.pb= s->pb; best_s.data_partitioning= s->data_partitioning; best_s.partitioned_frame= s->partitioned_frame; if(s->data_partitioning){ backup_s.pb2= s->pb2; backup_s.tex_pb= s->tex_pb; } if(mb_type&CANDIDATE_MB_TYPE_INTER){ s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_16X16; s->mb_intra= 0; s->mv[0][0][0] = s->p_mv_table[xy][0]; s->mv[0][0][1] = s->p_mv_table[xy][1]; encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER, pb, pb2, tex_pb, &dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]); } if(mb_type&CANDIDATE_MB_TYPE_INTER_I){ s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_FIELD; s->mb_intra= 0; for(i=0; i<2; i++){ j= s->field_select[0][i] = s->p_field_select_table[i][xy]; s->mv[0][i][0] = s->p_field_mv_table[i][j][xy][0]; s->mv[0][i][1] = s->p_field_mv_table[i][j][xy][1]; } encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER_I, pb, pb2, tex_pb, &dmin, &next_block, 0, 0); } if(mb_type&CANDIDATE_MB_TYPE_SKIPPED){ s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_16X16; s->mb_intra= 0; s->mv[0][0][0] = 0; s->mv[0][0][1] = 0; encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_SKIPPED, pb, pb2, tex_pb, &dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]); } if(mb_type&CANDIDATE_MB_TYPE_INTER4V){ s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_8X8; s->mb_intra= 0; for(i=0; i<4; i++){ s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0]; s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1]; } encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER4V, pb, pb2, tex_pb, &dmin, &next_block, 0, 0); } if(mb_type&CANDIDATE_MB_TYPE_FORWARD){ s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_16X16; s->mb_intra= 0; s->mv[0][0][0] = s->b_forw_mv_table[xy][0]; s->mv[0][0][1] = s->b_forw_mv_table[xy][1]; encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD, pb, pb2, tex_pb, &dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]); } if(mb_type&CANDIDATE_MB_TYPE_BACKWARD){ s->mv_dir = MV_DIR_BACKWARD; s->mv_type = MV_TYPE_16X16; s->mb_intra= 0; s->mv[1][0][0] = s->b_back_mv_table[xy][0]; s->mv[1][0][1] = s->b_back_mv_table[xy][1]; encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD, pb, pb2, tex_pb, &dmin, &next_block, s->mv[1][0][0], s->mv[1][0][1]); } if(mb_type&CANDIDATE_MB_TYPE_BIDIR){ s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD; s->mv_type = MV_TYPE_16X16; s->mb_intra= 0; s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0]; s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1]; s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0]; s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1]; encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR, pb, pb2, tex_pb, &dmin, &next_block, 0, 0); } if(mb_type&CANDIDATE_MB_TYPE_FORWARD_I){ s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_FIELD; s->mb_intra= 0; for(i=0; i<2; i++){ j= s->field_select[0][i] = s->b_field_select_table[0][i][xy]; s->mv[0][i][0] = s->b_field_mv_table[0][i][j][xy][0]; s->mv[0][i][1] = s->b_field_mv_table[0][i][j][xy][1]; } encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD_I, pb, pb2, tex_pb, &dmin, &next_block, 0, 0); } if(mb_type&CANDIDATE_MB_TYPE_BACKWARD_I){ s->mv_dir = MV_DIR_BACKWARD; s->mv_type = MV_TYPE_FIELD; s->mb_intra= 0; for(i=0; i<2; i++){ j= s->field_select[1][i] = s->b_field_select_table[1][i][xy]; s->mv[1][i][0] = s->b_field_mv_table[1][i][j][xy][0]; s->mv[1][i][1] = s->b_field_mv_table[1][i][j][xy][1]; } encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD_I, pb, pb2, tex_pb, &dmin, &next_block, 0, 0); } if(mb_type&CANDIDATE_MB_TYPE_BIDIR_I){ s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD; s->mv_type = MV_TYPE_FIELD; s->mb_intra= 0; for(dir=0; dir<2; dir++){ for(i=0; i<2; i++){ j= s->field_select[dir][i] = s->b_field_select_table[dir][i][xy]; s->mv[dir][i][0] = s->b_field_mv_table[dir][i][j][xy][0]; s->mv[dir][i][1] = s->b_field_mv_table[dir][i][j][xy][1]; } } encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR_I, pb, pb2, tex_pb, &dmin, &next_block, 0, 0); } if(mb_type&CANDIDATE_MB_TYPE_INTRA){ s->mv_dir = 0; s->mv_type = MV_TYPE_16X16; s->mb_intra= 1; s->mv[0][0][0] = 0; s->mv[0][0][1] = 0; encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTRA, pb, pb2, tex_pb, &dmin, &next_block, 0, 0); if(s->h263_pred || s->h263_aic){ if(best_s.mb_intra) s->mbintra_table[mb_x + mb_y*s->mb_stride]=1; else ff_clean_intra_table_entries(s); } } if ((s->mpv_flags & FF_MPV_FLAG_QP_RD) && dmin < INT_MAX) { if(best_s.mv_type==MV_TYPE_16X16){ const int last_qp= backup_s.qscale; int qpi, qp, dc[6]; int16_t ac[6][16]; const int mvdir= (best_s.mv_dir&MV_DIR_BACKWARD) ? 1 : 0; static const int dquant_tab[4]={-1,1,-2,2}; assert(backup_s.dquant == 0); s->mv_dir= best_s.mv_dir; s->mv_type = MV_TYPE_16X16; s->mb_intra= best_s.mb_intra; s->mv[0][0][0] = best_s.mv[0][0][0]; s->mv[0][0][1] = best_s.mv[0][0][1]; s->mv[1][0][0] = best_s.mv[1][0][0]; s->mv[1][0][1] = best_s.mv[1][0][1]; qpi = s->pict_type == AV_PICTURE_TYPE_B ? 2 : 0; for(; qpi<4; qpi++){ int dquant= dquant_tab[qpi]; qp= last_qp + dquant; if(qp < s->avctx->qmin || qp > s->avctx->qmax) continue; backup_s.dquant= dquant; if(s->mb_intra && s->dc_val[0]){ for(i=0; i<6; i++){ dc[i]= s->dc_val[0][ s->block_index[i] ]; memcpy(ac[i], s->ac_val[0][s->block_index[i]], sizeof(int16_t)*16); } } encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER , pb, pb2, tex_pb, &dmin, &next_block, s->mv[mvdir][0][0], s->mv[mvdir][0][1]); if(best_s.qscale != qp){ if(s->mb_intra && s->dc_val[0]){ for(i=0; i<6; i++){ s->dc_val[0][ s->block_index[i] ]= dc[i]; memcpy(s->ac_val[0][s->block_index[i]], ac[i], sizeof(int16_t)*16); } } } } } } if(CONFIG_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT){ int mx= s->b_direct_mv_table[xy][0]; int my= s->b_direct_mv_table[xy][1]; backup_s.dquant = 0; s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT; s->mb_intra= 0; ff_mpeg4_set_direct_mv(s, mx, my); encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb, &dmin, &next_block, mx, my); } if(CONFIG_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT0){ backup_s.dquant = 0; s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT; s->mb_intra= 0; ff_mpeg4_set_direct_mv(s, 0, 0); encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb, &dmin, &next_block, 0, 0); } if (!best_s.mb_intra && s->mpv_flags & FF_MPV_FLAG_SKIP_RD) { int coded=0; for(i=0; i<6; i++) coded |= s->block_last_index[i]; if(coded){ int mx,my; memcpy(s->mv, best_s.mv, sizeof(s->mv)); if(CONFIG_MPEG4_ENCODER && best_s.mv_dir & MV_DIRECT){ mx=my=0; ff_mpeg4_set_direct_mv(s, mx, my); }else if(best_s.mv_dir&MV_DIR_BACKWARD){ mx= s->mv[1][0][0]; my= s->mv[1][0][1]; }else{ mx= s->mv[0][0][0]; my= s->mv[0][0][1]; } s->mv_dir= best_s.mv_dir; s->mv_type = best_s.mv_type; s->mb_intra= 0; backup_s.dquant= 0; s->skipdct=1; encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER , pb, pb2, tex_pb, &dmin, &next_block, mx, my); s->skipdct=0; } } s->current_picture.qscale_table[xy] = best_s.qscale; copy_context_after_encode(s, &best_s, -1); pb_bits_count= put_bits_count(&s->pb); flush_put_bits(&s->pb); avpriv_copy_bits(&backup_s.pb, bit_buf[next_block^1], pb_bits_count); s->pb= backup_s.pb; if(s->data_partitioning){ pb2_bits_count= put_bits_count(&s->pb2); flush_put_bits(&s->pb2); avpriv_copy_bits(&backup_s.pb2, bit_buf2[next_block^1], pb2_bits_count); s->pb2= backup_s.pb2; tex_pb_bits_count= put_bits_count(&s->tex_pb); flush_put_bits(&s->tex_pb); avpriv_copy_bits(&backup_s.tex_pb, bit_buf_tex[next_block^1], tex_pb_bits_count); s->tex_pb= backup_s.tex_pb; } s->last_bits= put_bits_count(&s->pb); if (CONFIG_H263_ENCODER && s->out_format == FMT_H263 && s->pict_type!=AV_PICTURE_TYPE_B) ff_h263_update_motion_val(s); if(next_block==0){ s->hdsp.put_pixels_tab[0][0](s->dest[0], s->rd_scratchpad , s->linesize ,16); s->hdsp.put_pixels_tab[1][0](s->dest[1], s->rd_scratchpad + 16*s->linesize , s->uvlinesize, 8); s->hdsp.put_pixels_tab[1][0](s->dest[2], s->rd_scratchpad + 16*s->linesize + 8, s->uvlinesize, 8); } if(s->avctx->mb_decision == FF_MB_DECISION_BITS) ff_MPV_decode_mb(s, s->block); } else { int motion_x = 0, motion_y = 0; s->mv_type=MV_TYPE_16X16; switch(mb_type){ case CANDIDATE_MB_TYPE_INTRA: s->mv_dir = 0; s->mb_intra= 1; motion_x= s->mv[0][0][0] = 0; motion_y= s->mv[0][0][1] = 0; break; case CANDIDATE_MB_TYPE_INTER: s->mv_dir = MV_DIR_FORWARD; s->mb_intra= 0; motion_x= s->mv[0][0][0] = s->p_mv_table[xy][0]; motion_y= s->mv[0][0][1] = s->p_mv_table[xy][1]; break; case CANDIDATE_MB_TYPE_INTER_I: s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_FIELD; s->mb_intra= 0; for(i=0; i<2; i++){ j= s->field_select[0][i] = s->p_field_select_table[i][xy]; s->mv[0][i][0] = s->p_field_mv_table[i][j][xy][0]; s->mv[0][i][1] = s->p_field_mv_table[i][j][xy][1]; } break; case CANDIDATE_MB_TYPE_INTER4V: s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_8X8; s->mb_intra= 0; for(i=0; i<4; i++){ s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0]; s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1]; } break; case CANDIDATE_MB_TYPE_DIRECT: if (CONFIG_MPEG4_ENCODER) { s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD|MV_DIRECT; s->mb_intra= 0; motion_x=s->b_direct_mv_table[xy][0]; motion_y=s->b_direct_mv_table[xy][1]; ff_mpeg4_set_direct_mv(s, motion_x, motion_y); } break; case CANDIDATE_MB_TYPE_DIRECT0: if (CONFIG_MPEG4_ENCODER) { s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD|MV_DIRECT; s->mb_intra= 0; ff_mpeg4_set_direct_mv(s, 0, 0); } break; case CANDIDATE_MB_TYPE_BIDIR: s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD; s->mb_intra= 0; s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0]; s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1]; s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0]; s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1]; break; case CANDIDATE_MB_TYPE_BACKWARD: s->mv_dir = MV_DIR_BACKWARD; s->mb_intra= 0; motion_x= s->mv[1][0][0] = s->b_back_mv_table[xy][0]; motion_y= s->mv[1][0][1] = s->b_back_mv_table[xy][1]; break; case CANDIDATE_MB_TYPE_FORWARD: s->mv_dir = MV_DIR_FORWARD; s->mb_intra= 0; motion_x= s->mv[0][0][0] = s->b_forw_mv_table[xy][0]; motion_y= s->mv[0][0][1] = s->b_forw_mv_table[xy][1]; break; case CANDIDATE_MB_TYPE_FORWARD_I: s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_FIELD; s->mb_intra= 0; for(i=0; i<2; i++){ j= s->field_select[0][i] = s->b_field_select_table[0][i][xy]; s->mv[0][i][0] = s->b_field_mv_table[0][i][j][xy][0]; s->mv[0][i][1] = s->b_field_mv_table[0][i][j][xy][1]; } break; case CANDIDATE_MB_TYPE_BACKWARD_I: s->mv_dir = MV_DIR_BACKWARD; s->mv_type = MV_TYPE_FIELD; s->mb_intra= 0; for(i=0; i<2; i++){ j= s->field_select[1][i] = s->b_field_select_table[1][i][xy]; s->mv[1][i][0] = s->b_field_mv_table[1][i][j][xy][0]; s->mv[1][i][1] = s->b_field_mv_table[1][i][j][xy][1]; } break; case CANDIDATE_MB_TYPE_BIDIR_I: s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD; s->mv_type = MV_TYPE_FIELD; s->mb_intra= 0; for(dir=0; dir<2; dir++){ for(i=0; i<2; i++){ j= s->field_select[dir][i] = s->b_field_select_table[dir][i][xy]; s->mv[dir][i][0] = s->b_field_mv_table[dir][i][j][xy][0]; s->mv[dir][i][1] = s->b_field_mv_table[dir][i][j][xy][1]; } } break; default: av_log(s->avctx, AV_LOG_ERROR, "illegal MB type\n"); } encode_mb(s, motion_x, motion_y); s->last_mv_dir = s->mv_dir; if (CONFIG_H263_ENCODER && s->out_format == FMT_H263 && s->pict_type!=AV_PICTURE_TYPE_B) ff_h263_update_motion_val(s); ff_MPV_decode_mb(s, s->block); } if(s->mb_intra ){ s->p_mv_table[xy][0]=0; s->p_mv_table[xy][1]=0; } if(s->flags&CODEC_FLAG_PSNR){ int w= 16; int h= 16; if(s->mb_x*16 + 16 > s->width ) w= s->width - s->mb_x*16; if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16; s->current_picture.f.error[0] += sse( s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], w, h, s->linesize); s->current_picture.f.error[1] += sse( s, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h, s->dest[1], w>>1, h>>s->chroma_y_shift, s->uvlinesize); s->current_picture.f.error[2] += sse( s, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*chr_h, s->dest[2], w>>1, h>>s->chroma_y_shift, s->uvlinesize); } if(s->loop_filter){ if(CONFIG_H263_ENCODER && s->out_format == FMT_H263) ff_h263_loop_filter(s); } av_dlog(s->avctx, "MB %d %d bits\n", s->mb_x + s->mb_y * s->mb_stride, put_bits_count(&s->pb)); } } if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type == AV_PICTURE_TYPE_I) ff_msmpeg4_encode_ext_header(s); write_slice_end(s); if (s->avctx->rtp_callback) { int number_mb = (mb_y - s->resync_mb_y)*s->mb_width - s->resync_mb_x; pdif = put_bits_ptr(&s->pb) - s->ptr_lastgob; emms_c(); s->avctx->rtp_callback(s->avctx, s->ptr_lastgob, pdif, number_mb); } return 0; }
1threat
static void gdb_breakpoint_remove_all(CPUState *env) { cpu_breakpoint_remove_all(env, BP_GDB); #ifndef CONFIG_USER_ONLY cpu_watchpoint_remove_all(env, BP_GDB); #endif }
1threat
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { PNGDecContext *const s = avctx->priv_data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; AVFrame *p = data; uint8_t *crow_buf_base = NULL; uint32_t tag, length; int ret; if (buf_size < 8 || memcmp(buf, ff_pngsig, 8) != 0 && memcmp(buf, ff_mngsig, 8) != 0) return -1; bytestream2_init(&s->gb, buf + 8, buf_size - 8); s->y = s->state = 0; s->zstream.zalloc = ff_png_zalloc; s->zstream.zfree = ff_png_zfree; s->zstream.opaque = NULL; ret = inflateInit(&s->zstream); if (ret != Z_OK) return -1; for (;;) { if (bytestream2_get_bytes_left(&s->gb) <= 0) goto fail; length = bytestream2_get_be32(&s->gb); if (length > 0x7fffffff) goto fail; tag = bytestream2_get_le32(&s->gb); av_dlog(avctx, "png: tag=%c%c%c%c length=%u\n", (tag & 0xff), ((tag >> 8) & 0xff), ((tag >> 16) & 0xff), ((tag >> 24) & 0xff), length); switch (tag) { case MKTAG('I', 'H', 'D', 'R'): if (length != 13) goto fail; s->width = bytestream2_get_be32(&s->gb); s->height = bytestream2_get_be32(&s->gb); if (av_image_check_size(s->width, s->height, 0, avctx)) { s->width = s->height = 0; goto fail; } s->bit_depth = bytestream2_get_byte(&s->gb); s->color_type = bytestream2_get_byte(&s->gb); s->compression_type = bytestream2_get_byte(&s->gb); s->filter_type = bytestream2_get_byte(&s->gb); s->interlace_type = bytestream2_get_byte(&s->gb); bytestream2_skip(&s->gb, 4); s->state |= PNG_IHDR; av_dlog(avctx, "width=%d height=%d depth=%d color_type=%d " "compression_type=%d filter_type=%d interlace_type=%d\n", s->width, s->height, s->bit_depth, s->color_type, s->compression_type, s->filter_type, s->interlace_type); break; case MKTAG('I', 'D', 'A', 'T'): if (!(s->state & PNG_IHDR)) goto fail; if (!(s->state & PNG_IDAT)) { avctx->width = s->width; avctx->height = s->height; s->channels = ff_png_get_nb_channels(s->color_type); s->bits_per_pixel = s->bit_depth * s->channels; s->bpp = (s->bits_per_pixel + 7) >> 3; s->row_size = (avctx->width * s->bits_per_pixel + 7) >> 3; if (s->bit_depth == 8 && s->color_type == PNG_COLOR_TYPE_RGB) { avctx->pix_fmt = AV_PIX_FMT_RGB24; } else if (s->bit_depth == 8 && s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { avctx->pix_fmt = AV_PIX_FMT_RGB32; } else if (s->bit_depth == 8 && s->color_type == PNG_COLOR_TYPE_GRAY) { avctx->pix_fmt = AV_PIX_FMT_GRAY8; } else if (s->bit_depth == 16 && s->color_type == PNG_COLOR_TYPE_GRAY) { avctx->pix_fmt = AV_PIX_FMT_GRAY16BE; } else if (s->bit_depth == 16 && s->color_type == PNG_COLOR_TYPE_RGB) { avctx->pix_fmt = AV_PIX_FMT_RGB48BE; } else if (s->bit_depth == 1 && s->color_type == PNG_COLOR_TYPE_GRAY) { avctx->pix_fmt = AV_PIX_FMT_MONOBLACK; } else if (s->bit_depth == 8 && s->color_type == PNG_COLOR_TYPE_PALETTE) { avctx->pix_fmt = AV_PIX_FMT_PAL8; } else if (s->bit_depth == 8 && s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { avctx->pix_fmt = AV_PIX_FMT_YA8; } else if (s->bit_depth == 16 && s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { avctx->pix_fmt = AV_PIX_FMT_YA16BE; } else { goto fail; } if (ff_get_buffer(avctx, p, AV_GET_BUFFER_FLAG_REF) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); goto fail; } p->pict_type = AV_PICTURE_TYPE_I; p->key_frame = 1; p->interlaced_frame = !!s->interlace_type; if (!s->interlace_type) { s->crow_size = s->row_size + 1; } else { s->pass = 0; s->pass_row_size = ff_png_pass_row_size(s->pass, s->bits_per_pixel, s->width); s->crow_size = s->pass_row_size + 1; } av_dlog(avctx, "row_size=%d crow_size =%d\n", s->row_size, s->crow_size); s->image_buf = p->data[0]; s->image_linesize = p->linesize[0]; if (s->color_type == PNG_COLOR_TYPE_PALETTE) memcpy(p->data[1], s->palette, 256 * sizeof(uint32_t)); s->last_row = av_mallocz(s->row_size); if (!s->last_row) goto fail; if (s->interlace_type || s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { s->tmp_row = av_malloc(s->row_size); if (!s->tmp_row) goto fail; } crow_buf_base = av_malloc(s->row_size + 16); if (!crow_buf_base) goto fail; s->crow_buf = crow_buf_base + 15; s->zstream.avail_out = s->crow_size; s->zstream.next_out = s->crow_buf; } s->state |= PNG_IDAT; if (png_decode_idat(s, length) < 0) goto fail; bytestream2_skip(&s->gb, 4); break; case MKTAG('P', 'L', 'T', 'E'): { int n, i, r, g, b; if ((length % 3) != 0 || length > 256 * 3) goto skip_tag; n = length / 3; for (i = 0; i < n; i++) { r = bytestream2_get_byte(&s->gb); g = bytestream2_get_byte(&s->gb); b = bytestream2_get_byte(&s->gb); s->palette[i] = (0xff << 24) | (r << 16) | (g << 8) | b; } for (; i < 256; i++) s->palette[i] = (0xff << 24); s->state |= PNG_PLTE; bytestream2_skip(&s->gb, 4); } break; case MKTAG('t', 'R', 'N', 'S'): { int v, i; if (s->color_type != PNG_COLOR_TYPE_PALETTE || length > 256 || !(s->state & PNG_PLTE)) goto skip_tag; for (i = 0; i < length; i++) { v = bytestream2_get_byte(&s->gb); s->palette[i] = (s->palette[i] & 0x00ffffff) | (v << 24); } bytestream2_skip(&s->gb, 4); } break; case MKTAG('I', 'E', 'N', 'D'): if (!(s->state & PNG_ALLIMAGE)) goto fail; bytestream2_skip(&s->gb, 4); goto exit_loop; default: skip_tag: bytestream2_skip(&s->gb, length + 4); break; } } exit_loop: if (s->prev->data[0]) { if (!(avpkt->flags & AV_PKT_FLAG_KEY)) { int i, j; uint8_t *pd = p->data[0]; uint8_t *pd_last = s->prev->data[0]; for (j = 0; j < s->height; j++) { for (i = 0; i < s->width * s->bpp; i++) pd[i] += pd_last[i]; pd += s->image_linesize; pd_last += s->image_linesize; } } } av_frame_unref(s->prev); if ((ret = av_frame_ref(s->prev, p)) < 0) goto fail; *got_frame = 1; ret = bytestream2_tell(&s->gb); the_end: inflateEnd(&s->zstream); av_free(crow_buf_base); s->crow_buf = NULL; av_freep(&s->last_row); av_freep(&s->tmp_row); return ret; fail: ret = -1; goto the_end; }
1threat
void qemu_system_killed(int signal, pid_t pid) { shutdown_signal = signal; shutdown_pid = pid; no_shutdown = 0; qemu_system_shutdown_request(); }
1threat
How to use K.get_session in Tensorflow 2.0 or how to migrate it? : <pre><code>def __init__(self, **kwargs): self.__dict__.update(self._defaults) # set up default values self.__dict__.update(kwargs) # and update with user overrides self.class_names = self._get_class() self.anchors = self._get_anchors() self.sess = K.get_session() </code></pre> <p>RuntimeError: <code>get_session</code> is not available when using TensorFlow 2.0.</p>
0debug
How to implement the whitespace in my python 3.7 and implement In[1]: : **In[1]:** listofNumbers = [1, 2, 3, 4, 5, 6] for number in listofNumbers: print (number), if (number % 2 ==0): print (" is even") else : print(" is odd") print("All done.") I wanted my codes to print 1,2,3,4,5,6 and specific if each is even or odd, but it only brings the figures, no remarks,
0debug
static void qmp_input_type_number(Visitor *v, double *obj, const char *name, Error **errp) { QmpInputVisitor *qiv = to_qiv(v); QObject *qobj = qmp_input_get_object(qiv, name, true); if (!qobj || (qobject_type(qobj) != QTYPE_QFLOAT && qobject_type(qobj) != QTYPE_QINT)) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null", "number"); return; } if (qobject_type(qobj) == QTYPE_QINT) { *obj = qint_get_int(qobject_to_qint(qobj)); } else { *obj = qfloat_get_double(qobject_to_qfloat(qobj)); } }
1threat
static int mpegts_raw_read_packet(AVFormatContext *s, AVPacket *pkt) { MpegTSContext *ts = s->priv_data; int ret, i; int64_t pcr_h, next_pcr_h, pos; int pcr_l, next_pcr_l; uint8_t pcr_buf[12]; uint8_t *data; if (av_new_packet(pkt, TS_PACKET_SIZE) < 0) return AVERROR(ENOMEM); pkt->pos= avio_tell(s->pb); ret = read_packet(s, pkt->data, ts->raw_packet_size, &data); if (ret < 0) { av_free_packet(pkt); return ret; } if (data != pkt->data) memcpy(pkt->data, data, ts->raw_packet_size); finished_reading_packet(s, ts->raw_packet_size); if (ts->mpeg2ts_compute_pcr) { if (parse_pcr(&pcr_h, &pcr_l, pkt->data) == 0) { pos = avio_tell(s->pb); for(i = 0; i < MAX_PACKET_READAHEAD; i++) { avio_seek(s->pb, pos + i * ts->raw_packet_size, SEEK_SET); avio_read(s->pb, pcr_buf, 12); if (parse_pcr(&next_pcr_h, &next_pcr_l, pcr_buf) == 0) { ts->pcr_incr = ((next_pcr_h - pcr_h) * 300 + (next_pcr_l - pcr_l)) / (i + 1); break; } } avio_seek(s->pb, pos, SEEK_SET); ts->cur_pcr = pcr_h * 300 + pcr_l; } pkt->pts = ts->cur_pcr; pkt->duration = ts->pcr_incr; ts->cur_pcr += ts->pcr_incr; } pkt->stream_index = 0; return 0; }
1threat
How do i add incoming text from textbox to json link : Following is my code for c# in which I get data from json link. string email = textBox1.Text; string password = textBox2.Text; string s = client.DownloadString("https://cunctatious-objecti.000webhostapp.com/Moderator_signup.php?name= +email & password= + password" ); the actual link is https://cunctatious-objecti.000webhostapp.com/Moderator_signup.php?name='faizan' & password='123'. problem is that i want to take name and password from user in textboxes and insert them in the link but i cant solve it atm. I dont want to change the method too. but still it will be welcomed.
0debug
static int qcow2_change_backing_file(BlockDriverState *bs, const char *backing_file, const char *backing_fmt) { if (backing_fmt && !backing_file) { return -EINVAL; } pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_file ?: ""); pstrcpy(bs->backing_format, sizeof(bs->backing_format), backing_fmt ?: ""); return qcow2_update_header(bs); }
1threat
How to email an HTML table through javascript : I am writing a program where the user's input is sent to a table, and then the table is to be emailed to a certain email address. I made the table in javascript using the id of my table. I'm currently trying to use jsPDF to send it to a PDF but not finding much luck. Is this possible, and if so, how can I go about doing this?
0debug
onClick = {function(){model.clicks += 1; render(); }} : My question is how do I convert the function below into an arrow function? onClick = {function(){model.clicks += 1; render(); }}
0debug
Problem with calculating Primes within a given Range in C++ : <p>Im trying to create a program that does various math operations, and i wanted to start with calculating prime numbers within a given range. However, when i try to execute the code, it just returns <code>exit status -1</code>. What is wrong with the program and how do i fix it?</p> <pre><code>#include &lt;iostream&gt; #include &lt;vector&gt; using namespace std; void getPrimes(int min, int max) { int range = max - min; std::vector&lt; int &gt; possible_values; for (int q = 0; q &lt; range; q++) { possible_values.push_back(min + q); } for (int i = 0; i &lt; range; i++) { int num_of_factors = 0; int num = possible_values.at(i); for (int c = 0; c &lt; num; c++) { if (num % c == 0) { num_of_factors++; } } if (num_of_factors == 0) { std::cout &lt;&lt; num &lt;&lt; endl; } } } int main() { int min, max; std::cout &lt;&lt; "min: "; std::cin &gt;&gt; min; std::cout &lt;&lt; "max: "; std::cin &gt;&gt; max; getPrimes(min, max); } </code></pre>
0debug
static av_cold int MPA_encode_init(AVCodecContext *avctx) { MpegAudioContext *s = avctx->priv_data; int freq = avctx->sample_rate; int bitrate = avctx->bit_rate; int channels = avctx->channels; int i, v, table; float a; if (channels <= 0 || channels > 2){ av_log(avctx, AV_LOG_ERROR, "encoding %d channel(s) is not allowed in mp2\n", channels); return AVERROR(EINVAL); } bitrate = bitrate / 1000; s->nb_channels = channels; avctx->frame_size = MPA_FRAME_SIZE; avctx->delay = 512 - 32 + 1; s->lsf = 0; for(i=0;i<3;i++) { if (avpriv_mpa_freq_tab[i] == freq) break; if ((avpriv_mpa_freq_tab[i] / 2) == freq) { s->lsf = 1; break; } } if (i == 3){ av_log(avctx, AV_LOG_ERROR, "Sampling rate %d is not allowed in mp2\n", freq); return AVERROR(EINVAL); } s->freq_index = i; for(i=0;i<15;i++) { if (avpriv_mpa_bitrate_tab[s->lsf][1][i] == bitrate) break; } if (i == 15){ av_log(avctx, AV_LOG_ERROR, "bitrate %d is not allowed in mp2\n", bitrate); return AVERROR(EINVAL); } s->bitrate_index = i; a = (float)(bitrate * 1000 * MPA_FRAME_SIZE) / (freq * 8.0); s->frame_size = ((int)a) * 8; s->frame_frac = 0; s->frame_frac_incr = (int)((a - floor(a)) * 65536.0); table = ff_mpa_l2_select_table(bitrate, s->nb_channels, freq, s->lsf); s->sblimit = ff_mpa_sblimit_table[table]; s->alloc_table = ff_mpa_alloc_tables[table]; av_dlog(avctx, "%d kb/s, %d Hz, frame_size=%d bits, table=%d, padincr=%x\n", bitrate, freq, s->frame_size, table, s->frame_frac_incr); for(i=0;i<s->nb_channels;i++) s->samples_offset[i] = 0; for(i=0;i<257;i++) { int v; v = ff_mpa_enwindow[i]; #if WFRAC_BITS != 16 v = (v + (1 << (16 - WFRAC_BITS - 1))) >> (16 - WFRAC_BITS); #endif s->filter_bank[i] = v; if ((i & 63) != 0) v = -v; if (i != 0) s->filter_bank[512 - i] = v; } for(i=0;i<64;i++) { v = (int)(pow(2.0, (3 - i) / 3.0) * (1 << 20)); if (v <= 0) v = 1; s->scale_factor_table[i] = v; s->scale_factor_inv_table[i] = pow(2.0, -(3 - i) / 3.0) / (float)(1 << 20); } for(i=0;i<128;i++) { v = i - 64; if (v <= -3) v = 0; else if (v < 0) v = 1; else if (v == 0) v = 2; else if (v < 3) v = 3; else v = 4; s->scale_diff_table[i] = v; } for(i=0;i<17;i++) { v = ff_mpa_quant_bits[i]; if (v < 0) v = -v; else v = v * 3; s->total_quant_bits[i] = 12 * v; } return 0; }
1threat
Deep linking from Web to PWA (Standalone Version) : <p>I have a web app that it can be installed as standalone application in the homescreen thanks to PWA standard.</p> <p>When a user forget his password, a email is sent to him with a link to reset the password.</p> <p>Question is:</p> <p>Can I deep-link to the already-installed standalone version instead of the web application in chrome browser? I'd like to achieve this behaviour:</p> <ul> <li>User clicks in email link from gmail application.</li> <li>OS check if link matches with any url schema pre-registered in the system (This is the step that I don't really know if it's possible from web right now)</li> <li>If found, open the standalone version. Otherwise, open the browser.</li> </ul> <p>Thanks in advance!</p> <p>Cheers</p>
0debug
Python double for function : <p>I built this Python code with the intent to match each first name with the last name:</p> <pre><code>first_names = ['Jane','Sam','Deborah'] last_names = ['Simmons','Kaybone','Stone'] for f_name in first_names: for l_name in last_names: print(f_name.title() + " " + l_name.title()) </code></pre> <p>But apparently my code prints out all first names with all last_names instead of just (1,1), (2,2), (3,3). How do I tweak this code? Thanks!</p>
0debug
Strongly typing props of vue components using composition api and typescript typing system : <p>I am using vue composition api with typescript.</p> <p>How can I strongly type the component props using typescript typing system?</p>
0debug
Validation Using MVVM Light in a Universal Windows App : <p>After done with setting up MVVM Light in a Universal Windows App application, I have the following structure, and I wonder what is the cleanest way to do validation in 2017 using UWP and mvvmlight to notify users with errors and possibly reset the textbox value when needed. The only trick is that the Textbox is part of a UserControl (cleaned up unnecessary xaml code for clarity) since it will be used multiple times. Also I added DataAnnotations and ValidationResult for demonstration and not to suggest that this is the best way to do it or that it is working in any way so far.</p> <p>The code works fine as far as binding and adding and removing values</p> <ul> <li><p><strong>ViewModel</strong></p> <pre><code>using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Views; using System; using System.ComponentModel.DataAnnotations; public class ValidationTestViewModel : ViewModelBase { private int _age; [Required(ErrorMessage = "Age is required")] [Range(1, 100, ErrorMessage = "Age should be between 1 to 100")] [CustomValidation(typeof(int), "ValidateAge")] public int Age { get { return _age; } set { if ((value &gt; 1) &amp;&amp; (value =&lt; 100)) _age= value; } } public static ValidationResult ValidateAge(object value, ValidationContext validationContext) { return null; } } </code></pre></li> <li><p><strong>View</strong></p> <pre><code>&lt;Page x:Class="ValidationTest.Views.ValidationTestPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:ValidationTest.Views" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" DataContext="{Binding ValidationTestPageInstance, Source={StaticResource Locator}}" xmlns:views="using:ValidationTest.Views"&gt; &lt;views:NumberEdit TextInControl="{Binding Age, Mode=TwoWay}" /&gt; &lt;/Page&gt; </code></pre></li> <li><p><strong>UserControl</strong></p> <pre><code>&lt;UserControl x:Class="ValidationTest.Views.Number" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:ValidationTest.Views" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" x:Name="userControl1"&gt; &lt;Grid&gt; &lt;TextBox x:Name="content" Text="{Binding TextInControl, ElementName=userControl1, Mode=TwoWay}"&gt;&lt;/TextBox&gt; &lt;/Grid&gt; &lt;/UserControl&gt; </code></pre></li> <li><p><strong>UserControl Code Behind</strong>:</p> <pre><code>public partial class NumberEdit : UserControl { public string TextInControl { get { return (string)GetValue(TextInControlProperty); } set { SetValue(TextInControlProperty, value); } } public static readonly DependencyProperty TextInControlProperty = DependencyProperty.Register("TextInControl", typeof(string), typeof(NumberEdit), new PropertyMetadata(null)); } </code></pre></li> </ul>
0debug
Why String.split(":") doesn't work correctly : I have problem with `split()` method. I am parsing response from `api` and splitting time to hours and minutes. I've found out that split() gives me wrong values. I've made screenshot of my code while debugging because I didn't know how can i show it to you<br> [![enter image description here][1]][1] <br><br> As you can see `time` value is "08:15" but `tTime[0]` is "".<br> Weird thing is while parsing I am getting `time` inside `for` loop and I get "08:15" when I'm reading 10th item, all from 0 to 8 are fine. Is it problem with code or `split()` method itself? [1]: https://i.stack.imgur.com/32KZ1.png
0debug
non-declaration statement outside function body when trying to read JSON : <p>I'm getting the following two errors on the following code and it won't compile. I'm not really sure what I've done wrong in this code. Here are my errors: .\app.go:52:52: syntax error: unexpected }, expecting comma or ) .\app.go:55:1: syntax error: non-declaration statement outside function body. I don't know what else to check in the following code. Any help would be appreciated</p> <pre><code>package main import ( "encoding/json" "fmt" "io/ioutil" "log" "net/http" "time" ) type Results struct { Results []Result `json:"results"` } type Result struct { Name string `json:"name"` Rating float64 `json:"rating"` } func main() { url := "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=33.985,-118.4695&amp;radius=500&amp;type=restaurant&amp;key=MYKEY" resultClient := http.Client{ Timeout: time.Second * 2, } req, err := http.NewRequest(http.MethodGet, url, nil) if err != nil { log.Fatal(err) } req.Header.Set("User-Agent", "eattheshoals") res, getErr := resultClient.Do(req) if getErr != nil { log.Fatal(getErr) } byteValue, _ := ioutil.ReadAll(res.Body) //if readErr != nil { // log.Fatal(readErr) //} var results Results jsonErr := json.Unmarshal(byteValue, &amp;results) if jsonErr != nil { log.Fatal(jsonErr) } for i := 0; i &lt; len(results.Results); i++ { fmt.Println("Name " + results.Results[i].Name) fmt.Println("Rating " + results.Results[i].Rating}) } } </code></pre>
0debug
What should be the logic of hashfunction() in order to check that two strings are anagrams or not ? : I want to write a function that takes string as a parameter and returns a number corresponding to that string. Integer hashfunction(String a) { //logic } Actually the question im solving is as follows : Given an array of strings, return all groups of strings that are anagrams. Represent a group by a list of integers representing the index in the original list. Input : cat dog god tca Output : [[1, 4], [2, 3]] Here is my implementation :- public class Solution { Integer hashfunction(String a) { int i=0;int ans=0; for(i=0;i<a.length();i++) { ans+=(int)(a.charAt(i)); //Adding all ASCII values } return new Integer(ans); } **Obviously this approach is incorrect** public ArrayList<ArrayList<Integer>> anagrams(final List<String> a) { int i=0; HashMap<String,Integer> hashtable=new HashMap<String,Integer>(); ArrayList<Integer> mylist=new ArrayList<Integer>(); ArrayList<ArrayList<Integer>> answer=new ArrayList<ArrayList<Integer>>(); if(a.size()==1) { mylist.add(new Integer(1)); answer.add(mylist); return answer; } int j=1; for(i=0;i<a.size()-1;i++) { hashtable.put(a.get(i),hashfunction(a.get(i))); for(j=i+1;j<a.size();j++) { if(hashtable.containsValue(hashfunction(a.get(j)))) { mylist.add(new Integer(i+1)); mylist.add(new Integer(j+1)); answer.add(mylist); mylist.clear(); } } } return answer; } }
0debug
Please can somebody help me figure out what is wrong in this code : var myObject={name: function(){return "Michael";}(),age: 28,sayName: function(){alert(this.name + ":" + this.age);}(),specialFunction : function(){myObject=this;if(this==myObject)altert(console.log(this.sayName));}}()}; please can somebody help me figure out what is wrong in this code. I am trying to call the methods of an object from other methods in the same object but I'm just getting undefined. I'm thinking that inner scope object are allowed to access outer scope objects but this case disregards that rule. Thanks in advance.
0debug
How change the color of rulers in Visual Studio Code : <p>Not sure if this feature is included in the VSCode settings yet, but I'd love to change the ruler color from it's default grey.</p> <p>Tried:</p> <pre><code>"editor.rulers.color": "color" </code></pre> <p>But got an "unknown configuration setting error.</p>
0debug
"this.getClient(...).watchQuery is not a function" - remote schema stitching with Apollo 2 / Next.js : <p>So I'm attempting to stitch multiple remote GraphCMS endpoints together on the clientside of a Next.js app, and after trying/combining about every example on the face of the internet, I've gotten it to a place that's worth asking about. My error:</p> <p><code>TypeError: this.getClient(...).watchQuery is not a function at GraphQL.createQuery</code></p> <p><strong><a href="https://github.com/willmeierart/next-apollo-schema-stitching" rel="noreferrer">github repo here</a></strong>, where you can see this initApollo.js in context:</p> <pre><code>import { ApolloClient } from 'apollo-client' import { makeRemoteExecutableSchema, mergeSchemas, introspectSchema } from 'graphql-tools' import { HttpLink } from 'apollo-link-http' import { InMemoryCache } from 'apollo-cache-inmemory' import fetch from 'node-fetch' import { Observable, ApolloLink } from 'apollo-link' import { graphql, print } from 'graphql' import { createApolloFetch } from 'apollo-fetch' let apolloClient = null if (!process.browser) { global.fetch = fetch } const PRIMARY_API = 'https://api.graphcms.com/simple/v1/cjfipt3m23x9i0190pgetwf8c' const SECONDARY_API = 'https://api.graphcms.com/simple/v1/cjfipwwve7vl901427mf2vkog' const ALL_ENDPOINTS = [PRIMARY_API, SECONDARY_API] async function createClient (initialState) { const AllLinks = ALL_ENDPOINTS.map(endpoint =&gt; { return new HttpLink({ uri: endpoint, fetch }) }) const allSchemas = [] for (let link of AllLinks) { try { allSchemas.push( makeRemoteExecutableSchema({ schema: await introspectSchema(link), link }) ) } catch (e) { console.log(e) } } const mergedSchema = mergeSchemas({ schemas: allSchemas }) const mergedLink = operation =&gt; { return new Observable(observer =&gt; { const { query, variables, operationName } = operation graphql(mergedSchema, print(query), {}, {}, variables, operationName) .then(result =&gt; { observer.next(result) observer.complete() }) .catch(e =&gt; observer.error(e)) }) } return new ApolloClient({ connectToDevTools: process.browser, ssrMode: !process.browser, link: mergedLink, cache: new InMemoryCache().restore(initialState || {}) }) } export default function initApollo (initialState) { if (!process.browser) { return createClient(initialState) } if (!apolloClient) { apolloClient = createClient(initialState) } console.log('\x1b[37m%s\x1b[0m', apolloClient) return apolloClient } </code></pre> <p>I'm getting useful data all the way up into the <code>.then()</code> inside the <code>Observable</code>, where I can log the <code>result</code></p>
0debug
static void cas_handle_compat_cpu(PowerPCCPUClass *pcc, uint32_t pvr, unsigned max_lvl, unsigned *compat_lvl, unsigned *cpu_version) { unsigned lvl = get_compat_level(pvr); bool is205, is206; if (!lvl) { return; } is205 = (pcc->pcr_mask & PCR_COMPAT_2_05) && (lvl == get_compat_level(CPU_POWERPC_LOGICAL_2_05)); is206 = (pcc->pcr_mask & PCR_COMPAT_2_06) && ((lvl == get_compat_level(CPU_POWERPC_LOGICAL_2_06)) || (lvl == get_compat_level(CPU_POWERPC_LOGICAL_2_06_PLUS))); if (is205 || is206) { if (!max_lvl) { if (*compat_lvl <= lvl) { *compat_lvl = lvl; *cpu_version = pvr; } } else if (max_lvl >= lvl) { *compat_lvl = lvl; *cpu_version = pvr; } } }
1threat
static void ppc_cpu_initfn(Object *obj) { CPUState *cs = CPU(obj); PowerPCCPU *cpu = POWERPC_CPU(obj); PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); CPUPPCState *env = &cpu->env; cs->env_ptr = env; cpu_exec_init(env, &error_abort); cpu->cpu_dt_id = cs->cpu_index; env->msr_mask = pcc->msr_mask; env->mmu_model = pcc->mmu_model; env->excp_model = pcc->excp_model; env->bus_model = pcc->bus_model; env->insns_flags = pcc->insns_flags; env->insns_flags2 = pcc->insns_flags2; env->flags = pcc->flags; env->bfd_mach = pcc->bfd_mach; env->check_pow = pcc->check_pow; #if defined(TARGET_PPC64) if (pcc->sps) { env->sps = *pcc->sps; } else if (env->mmu_model & POWERPC_MMU_64) { static const struct ppc_segment_page_sizes defsps = { .sps = { { .page_shift = 12, .slb_enc = 0, .enc = { { .page_shift = 12, .pte_enc = 0 } } }, { .page_shift = 24, .slb_enc = 0x100, .enc = { { .page_shift = 24, .pte_enc = 0 } } }, }, }; env->sps = defsps; } #endif if (tcg_enabled()) { ppc_translate_init(); } }
1threat
PCR (Doller weighted Put Call Ratio)calculation issues : I am trying to generate a Put / Call Ratio calculation program for my own purpose.Here is the code: problem is I am stuck in some places. 1.I need to generate a summation of all strikes volume * all strikes prices 2. and final one is generating the ratio. So far I tried a lot and ended up having buggy program.However I am providing the code for now for further so that I can complete the rest of the part get the OutPut properly.(nse DO not provide PCR as CBO does provide a solution) from nsepy import get_history from datetime import date import pandas as pd import requests from io import BytesIO import certifi from scipy import stats from dateutil.relativedelta import relativedelta import numpy as np #import matplotlib.pyplot as plt import datetime import numpy as np import matplotlib.colors as colors import matplotlib.finance as finance import matplotlib.dates as mdates import matplotlib.ticker as mticker import matplotlib.mlab as mlab import matplotlib.pyplot as plt import matplotlib.font_manager as font_manager import talib as ta from talib import MA_Type import statsmodels as sm nf_calls=[] nf_puts=[] wPCR=[] #nf_calls[['VolumeCalls']]=np.nan #nf_puts[['VolumeCalls']]=np.nan i=min_avalable_strikes=4850 max_avalable_strike=9400 while i in range(min_avalable_strikes,max_avalable_strike): nf_opt_CE = get_history(symbol="NIFTY", start=date(2016,4,1), end=date(2016,4,22), index=True, option_type="CE", strike_price=i, expiry_date=date(2016,4,28)) #print(nf_opt_CE.head()) #if nf_opt_CE['Number of Contracts'].values >0 : '''if nf_opt_CE.empty : nf_opt_CE.append(0) ''' nf_opt_PE = get_history(symbol="NIFTY", start=date(2016,1,1), end=date(2016,4,18), index=True, option_type="PE", strike_price=i, expiry_date=date(2016,4,28)) print(nf_opt_PE.head()) #print(nf_opt_PE.head()) #print(i) #if nf_opt_PE['Number of Contracts'].values>0 : '''if nf_opt_CE.empty : nf_opt_PE.append(0) ''' i=i+50 #print(wPCR) '''def PCRForSym(): return NULL ''' nf_opt_PE['NewCols']=nf_opt_PE['Number of Contracts']* nf_opt_PE['Close'] nf_opt_CE['NewCols']= nf_opt_CE['Number of Contracts']*nf_opt_CE['Close'] #wPCR=nf_puts print(nf_opt_PE.head())
0debug
How to read a single Contact from sql of android : I am here with a problem in SQL of android to read a single contact. I have tried every thing to solve the issue butt failed to do so. When I called the method form main my app crashed. Here is my code, I need quick solution kindly help me out fast. public contactsdetail readContact(int id) { SQLiteDatabase db = this.getReadableDatabase(); contactsdetail contact = new contactsdetail(); // get contact query Cursor cursor = db.query(table_Contact,new String[] { name_ID, contact_NAME, contact_NUMBER }, name_ID + "=?", new String[]{ String.valueOf(id) }, null, null, null, null); // if results !=null, parse the first one if(cursor != null) cursor.moveToFirst(); contactsdetail contact = new contactsdetail(Integer.parseInt(cursor.getString(0)),cursor.getString(1), cursor.getString(2)); return contact; }
0debug
React Hook "useEffect" is called conditionally : <p>React is complaining about code below, saying it useEffect is being called conditionally:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="true"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>import React, { useEffect, useState } from 'react' import VerifiedUserOutlined from '@material-ui/icons/VerifiedUserOutlined' import withStyles from '@material-ui/core/styles/withStyles' import firebase from '../firebase' import { withRouter } from 'react-router-dom' function Dashboard(props) { const { classes } = props const [quote, setQuote] = useState('') if(!firebase.getCurrentUsername()) { // not logged in alert('Please login first') props.history.replace('/login') return null } useEffect(() =&gt; { firebase.getCurrentUserQuote().then(setQuote) }) return ( &lt;main&gt; // some code here &lt;/main&gt; ) async function logout() { await firebase.logout() props.history.push('/') } } export default withRouter(withStyles(styles)(Dashboard))</code></pre> </div> </div> </p> <p>And that returns me the error:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code> Line 48: React Hook "useEffect" is called conditionally. React Hooks must be called in the exact same order in every component render react-hooks/rules-of-hooks</code></pre> </div> </div> </p> <p>Does anyone happen to know what the problem here is?</p>
0debug
static int eval_refl(int *refl, const int16_t *coefs, RA144Context *ractx) { int b, c, i; unsigned int u; int buffer1[10]; int buffer2[10]; int *bp1 = buffer1; int *bp2 = buffer2; for (i=0; i < 10; i++) buffer2[i] = coefs[i]; refl[9] = bp2[9]; if ((unsigned) bp2[9] + 0x1000 > 0x1fff) { av_log(ractx, AV_LOG_ERROR, "Overflow. Broken sample?\n"); return 1; } for (c=8; c >= 0; c--) { b = 0x1000-((bp2[c+1] * bp2[c+1]) >> 12); if (!b) b = -2; for (u=0; u<=c; u++) bp1[u] = ((bp2[u] - ((refl[c+1] * bp2[c-u]) >> 12)) * (0x1000000 / b)) >> 12; refl[c] = bp1[c]; if ((unsigned) bp1[c] + 0x1000 > 0x1fff) return 1; FFSWAP(int *, bp1, bp2); } return 0; }
1threat
lin shel scrip Assignm probl 3 : hi i wrote a program for this question : When a person works for someone else or company, (s) he is then said to hold a job and is called Employee. The person or the company he or she works for is called Employer. Money that is paid is called as Salary or Income or Wage. The salary consists of following part: Basic Salary: As the name suggests, this forms the very basis of salary and many other components may be calculated based on this amount. It usually depends on one’s grade within the company’s salary structure. It is a fixed part of one’s compensation structure. (Allowance: It is the amount received by an individual paid by his/her employer in addition to salary to meet some service requirements such as Dearness Allowance (DA), House Rent Allowance (HRA), Leave Travel Assistance (LTA), Lunch Allowance, Conveyance Allowance, Children’s Education Allowance, and City compensatory Allowance etc.) Allowance can be fully taxable, partly or non-taxable. Provident Fund (PF) Contribution is made for the employee's welfare by the employer. The deduction is based on PF and Income Tax (IT). Try to understand the components of the salary structure and taxation for more details. * Using the proper shell scripting, calculate the net salary of an employee. Basic Salary, DA, HRA, TA and Other Allowances (OA) are given. Follow the constraints and find out the amount to be deducted using the proper PF and IT calculation. Basic salary: $ 15000 DA: 14% of Basic salary HRA: $175 TA: $150 other allowances (OA): $400 Deduction – a) PF: 12% of Basic salary and b) IT: 15% of Basic salary Net Salary = Basic Salary + DA + HRA + TA + OA – (PF + IT) but this is not working please help me thank you so mush the program is : echo "please enter Basic Salary" read basic echo "please enter your HRA" read HRA echo "please enter your TA" read TA echo "please enter your OA" read OA DA echo = "scale=3, $basic*0.14" | bc PF echo = "scale=3, $basic*0.12" | bc IT echo = "scale=3, $basic*0.15" | bc echo "DA is: $DA" echo "PF is: $PF" echo "TA is: $IT" Ns = echo "scale=3: $basic + $DA + $HRA + $TA + $OA + : bc echo "Net salary: $ NA "
0debug
Sql result set value as Column header in SQL : I need to use result values in column header. Please see below script and the result of the script i need to use it as column headers. select convert(varchar,DATEADD(month, -12, dateadd(d,-day(convert(date,dateadd(d,-(day(getdate())),getdate()))),convert(date,dateadd(d,+1-(day(getdate())),getdate())))),107), convert(varchar,convert(date,dateadd(d,-day(convert(date,dateadd(d,-(day(getdate())),getdate()))),convert(date,dateadd(d,+1-(day(getdate())),getdate())))),107) I need the answer for my question as soon as possible.
0debug
Which is better to store data a database or internal storage? : <p>I just finish learning about SQlite database and i need to implement what i have learnt to a note application and display those notes in a grid view so my question is. Which is better way to save my notes in a database or in a file in the internal storage of the device and when to use each one of them?</p> <p>thanks</p>
0debug
static void new_pes_packet(PESContext *pes, AVPacket *pkt) { av_init_packet(pkt); pkt->destruct = av_destruct_packet; pkt->data = pes->buffer; pkt->size = pes->data_index; memset(pkt->data+pkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE); if (pes->sub_st && pes->stream_type == 0x83 && pes->extended_stream_id == 0x76) pkt->stream_index = pes->sub_st->index; else pkt->stream_index = pes->st->index; pkt->pts = pes->pts; pkt->dts = pes->dts; pkt->pos = pes->ts_packet_pos; pes->pts = AV_NOPTS_VALUE; pes->dts = AV_NOPTS_VALUE; pes->buffer = NULL; pes->data_index = 0; }
1threat
Defining JavaScript functions inside vs. outside of a class : <p>I'm trying to figure out if there's any different when defining functions inside or outside of a class in JavaScript. <strong>Why would I choose to do it one way over the other?</strong> (Notice my getName [inside class] and getName2 [outside of class]).</p> <pre><code>class TestClass { constructor(myName) { this.name = myName; } getName() { return this.name; } } TestClass.getName2 = function() { //won't actually print the name variable set since not associated with an instance of the class? console.log(this.name); }; var test = new TestClass("Joe"); console.log(test.getName()); /////////////// TestClass.getName2(); </code></pre> <p>Output:</p> <pre><code>Joe TestClass </code></pre> <p>The only difference I can really see so far through my testing here is that I cannot access <code>this.name</code> within my getName2 since I believe it's not associated with any instance of the TestClass. So my getName2 is almost like a static class function where it's not associated with an instance of the class?? Please help me clarify this and why I would choose to implement a function one way over the other.</p>
0debug
C# File.ReadAllLines only recognizing the first line : <p>I am trying to using File.ReadAllLines to obtain an array containing every line. My text file contains one word per line so every index of the array should contain one word, although when I run the code it only prints out the first line.</p> <pre><code>foreach (string emotion in emotions) { var lines = File.ReadAllLines("C:\\Users\\Griffin\\Documents\\C#\\thavma\\thavma\\bin\\Debug\\libraries\\" + emotion + ".lib"); emotiondict.Add(emotion, lines); foreach (string f in lines) { Console.WriteLine(f); Console.ReadLine(); } } </code></pre> <p>For reference here is string[] emotions:</p> <pre><code>string[] emotions = new string[] { "anger","anticipation","disgust", "fear", "joy", "negative", "positive", "sadness", "surprise", "trust"}; </code></pre> <p>As well as a sample of part of the file I am trying to read:</p> <pre><code>abandoned abandonment abhor abhorrent abolish abomination abuse accursed accusation accused accuser ... </code></pre> <p>When I run the code all that prints is the word "abandoned", and I am not sure exactly what I am doing wrong. Thanks!</p>
0debug
Assignment or increment operator in c++ : <p>I have been running this code at different compilers. At Microsft VS. it prints 1, but at gcc, it prints 0. What is the result according to the standard c++. I don't if there is standardization for this piece of code as well.</p> <pre><code>int a=0; a=a++; cout &lt;&lt; a&lt;&lt; endl; </code></pre>
0debug
How to get handle of MessageBox in order to change font of MessageBox c++ builder : *I'm using c++ builder (bcb6) I would like change the font of MessageBox. I searched over google and find that it's possible to use by WM_SETFONT. My question is how can I get the handle of the MessageBox? HFONT hFont=CreateFont(18,0,0,0,FW_DONTCARE,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY, VARIABLE_PITCH,TEXT("Courier New")); MessageBox(NULL,message.c_str(),"Info",MB_OK | MB_ICONINFORMATION); SendMessage(??handle of the message box??, WM_SETFONT,(WPARAM) hFont, MAKELPARAM(TRUE, 0)); Any suggestions please? Your help is very appreciated.
0debug
static void grackle_pci_class_init(ObjectClass *klass, void *data) { PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); DeviceClass *dc = DEVICE_CLASS(klass); k->init = grackle_pci_host_init; k->vendor_id = PCI_VENDOR_ID_MOTOROLA; k->device_id = PCI_DEVICE_ID_MOTOROLA_MPC106; k->revision = 0x00; k->class_id = PCI_CLASS_BRIDGE_HOST; dc->no_user = 1; }
1threat
nodejs use local variable into object title : <p>I'm wondering why my variables do not recognized into my object title? I'm using query variable like this :</p> <pre><code>var query_type = req.query.type; // age (12) var query_search = req.query.search; // name (robert) var map = { query_type : query_search } </code></pre> <p>When I try to print the map, the output has something wrong.</p> <pre><code>console.dir(map); {query_type : "robert"} </code></pre> <p>Why my query_type do not recognize in my object? I want to print like below :</p> <pre><code>{"age" : "robert"} </code></pre>
0debug
Parentheses in Python function returns: why are they sometimes mandatory and sometimes not? : I'm learning Python and, so far, I absolutely love it. Everything about it. I just have one question about a seeming inconsistency in function returns, and I'm interested in learning the logic behind the rule. If I'm returning a literal or variable in a function return, no parentheses are needed: > def fun_with_functions(a, b): >> total = a + b<br> >> return total However, when I'm returning the result of another function call, the function is wrapped around a set of parentheses. To wit: > def lets_have_fun(): >> return(fun_with_functions(42, 9000)) This is, at least, the way I've been taught, using the [A Smarter Way to Learn Python][1] book. I came across this discrepancy and it was given without an explanation. You can see the online exercise [here][2] (skip to Exercize 10). Can someone explain to me why this is necessary? Is it even necessary in the first place? And are there other similar variations in parenthetical syntax that I should be aware of? [1]: https://www.amazon.com/Smarter-Way-Learn-Python-Remember/dp/1974431479 [2]: http://asmarterwaytolearn.com/python/50.html
0debug
static void pci_vpb_init(Object *obj) { PCIHostState *h = PCI_HOST_BRIDGE(obj); PCIVPBState *s = PCI_VPB(obj); memory_region_init(&s->pci_io_space, OBJECT(s), "pci_io", 1ULL << 32); memory_region_init(&s->pci_mem_space, OBJECT(s), "pci_mem", 1ULL << 32); pci_bus_new_inplace(&s->pci_bus, sizeof(s->pci_bus), DEVICE(obj), "pci", &s->pci_mem_space, &s->pci_io_space, PCI_DEVFN(11, 0), TYPE_PCI_BUS); h->bus = &s->pci_bus; object_initialize(&s->pci_dev, sizeof(s->pci_dev), TYPE_VERSATILE_PCI_HOST); qdev_set_parent_bus(DEVICE(&s->pci_dev), BUS(&s->pci_bus)); s->mem_win_size[0] = 0x0c000000; s->mem_win_size[1] = 0x10000000; s->mem_win_size[2] = 0x10000000; }
1threat
static const char *exynos4210_uart_regname(target_phys_addr_t offset) { int regs_number = sizeof(exynos4210_uart_regs) / sizeof(Exynos4210UartReg); int i; for (i = 0; i < regs_number; i++) { if (offset == exynos4210_uart_regs[i].offset) { return exynos4210_uart_regs[i].name; } } return NULL; }
1threat
how to load picasso in listview android studio : I have code below and how I Load Picasso in listview android studio ListAdapter adapter = new SimpleAdapter( tampil_semua_laporan.this, list, R.layout.list_item, new String[]{konfigurasi.TAG_TANGGAL,konfigurasi.TAG_JUDUL,konfigurasi.TAG_DESKRIPSI}, new int[]{R.id.tanggal, R.id.judul, R.id.deskripsi}); listView.setAdapter(adapter); Please Help and thanks
0debug
static int decode_update_thread_context(AVCodecContext *dst, const AVCodecContext *src){ H264Context *h= dst->priv_data, *h1= src->priv_data; MpegEncContext * const s = &h->s, * const s1 = &h1->s; int inited = s->context_initialized, err; int i; if(dst == src || !s1->context_initialized) return 0; err = ff_mpeg_update_thread_context(dst, src); if(err) return err; if(!inited){ for(i = 0; i < MAX_SPS_COUNT; i++) av_freep(h->sps_buffers + i); for(i = 0; i < MAX_PPS_COUNT; i++) av_freep(h->pps_buffers + i); memcpy(&h->s + 1, &h1->s + 1, sizeof(H264Context) - sizeof(MpegEncContext)); memset(h->sps_buffers, 0, sizeof(h->sps_buffers)); memset(h->pps_buffers, 0, sizeof(h->pps_buffers)); ff_h264_alloc_tables(h); context_init(h); for(i=0; i<2; i++){ h->rbsp_buffer[i] = NULL; h->rbsp_buffer_size[i] = 0; } h->thread_context[0] = h; h->s.obmc_scratchpad = av_malloc(16*2*s->linesize + 8*2*s->uvlinesize); s->dsp.clear_blocks(h->mb); } h->is_avc = h1->is_avc; copy_parameter_set((void**)h->sps_buffers, (void**)h1->sps_buffers, MAX_SPS_COUNT, sizeof(SPS)); h->sps = h1->sps; copy_parameter_set((void**)h->pps_buffers, (void**)h1->pps_buffers, MAX_PPS_COUNT, sizeof(PPS)); h->pps = h1->pps; copy_fields(h, h1, dequant4_buffer, dequant4_coeff); for(i=0; i<6; i++) h->dequant4_coeff[i] = h->dequant4_buffer[0] + (h1->dequant4_coeff[i] - h1->dequant4_buffer[0]); for(i=0; i<2; i++) h->dequant8_coeff[i] = h->dequant8_buffer[0] + (h1->dequant8_coeff[i] - h1->dequant8_buffer[0]); h->dequant_coeff_pps = h1->dequant_coeff_pps; copy_fields(h, h1, poc_lsb, redundant_pic_count); copy_fields(h, h1, ref_count, intra_gb); copy_fields(h, h1, short_ref, cabac_init_idc); copy_picture_range(h->short_ref, h1->short_ref, 32, s, s1); copy_picture_range(h->long_ref, h1->long_ref, 32, s, s1); copy_picture_range(h->delayed_pic, h1->delayed_pic, MAX_DELAYED_PIC_COUNT+2, s, s1); h->last_slice_type = h1->last_slice_type; if(!s->current_picture_ptr) return 0; if(!s->dropable) { ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index); h->prev_poc_msb = h->poc_msb; h->prev_poc_lsb = h->poc_lsb; } h->prev_frame_num_offset= h->frame_num_offset; h->prev_frame_num = h->frame_num; h->outputed_poc = h->next_outputed_poc; return 0; }
1threat
static void qemu_mutex_unlock_iothread(void) { qemu_mutex_unlock(&qemu_global_mutex); }
1threat
static int cllc_decode_frame(AVCodecContext *avctx, void *data, int *got_picture_ptr, AVPacket *avpkt) { CLLCContext *ctx = avctx->priv_data; AVFrame *pic = data; uint8_t *src = avpkt->data; uint32_t info_tag, info_offset; int data_size; GetBitContext gb; int coding_type, ret; info_offset = 0; info_tag = AV_RL32(src); if (info_tag == MKTAG('I', 'N', 'F', 'O')) { info_offset = AV_RL32(src + 4); if (info_offset > UINT32_MAX - 8 || info_offset + 8 > avpkt->size) { av_log(avctx, AV_LOG_ERROR, "Invalid INFO header offset: 0x%08"PRIX32" is too large.\n", info_offset); return AVERROR_INVALIDDATA; } info_offset += 8; src += info_offset; av_log(avctx, AV_LOG_DEBUG, "Skipping INFO chunk.\n"); } data_size = (avpkt->size - info_offset) & ~1; av_fast_padded_malloc(&ctx->swapped_buf, &ctx->swapped_buf_size, data_size); if (!ctx->swapped_buf) { av_log(avctx, AV_LOG_ERROR, "Could not allocate swapped buffer.\n"); return AVERROR(ENOMEM); } ctx->bdsp.bswap16_buf((uint16_t *) ctx->swapped_buf, (uint16_t *) src, data_size / 2); init_get_bits(&gb, ctx->swapped_buf, data_size * 8); coding_type = (AV_RL32(src) >> 8) & 0xFF; av_log(avctx, AV_LOG_DEBUG, "Frame coding type: %d\n", coding_type); switch (coding_type) { case 0: avctx->pix_fmt = AV_PIX_FMT_YUV422P; avctx->bits_per_raw_sample = 8; ret = ff_get_buffer(avctx, pic, 0); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Could not allocate buffer.\n"); return ret; } ret = decode_yuv_frame(ctx, &gb, pic); if (ret < 0) return ret; break; case 1: case 2: avctx->pix_fmt = AV_PIX_FMT_RGB24; avctx->bits_per_raw_sample = 8; ret = ff_get_buffer(avctx, pic, 0); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Could not allocate buffer.\n"); return ret; } ret = decode_rgb24_frame(ctx, &gb, pic); if (ret < 0) return ret; break; case 3: avctx->pix_fmt = AV_PIX_FMT_ARGB; avctx->bits_per_raw_sample = 8; ret = ff_get_buffer(avctx, pic, 0); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Could not allocate buffer.\n"); return ret; } ret = decode_argb_frame(ctx, &gb, pic); if (ret < 0) return ret; break; default: av_log(avctx, AV_LOG_ERROR, "Unknown coding type: %d.\n", coding_type); return AVERROR_INVALIDDATA; } pic->key_frame = 1; pic->pict_type = AV_PICTURE_TYPE_I; *got_picture_ptr = 1; return avpkt->size; }
1threat
static int uhci_handle_td(UHCIState *s, UHCIQueue *q, uint32_t qh_addr, UHCI_TD *td, uint32_t td_addr, uint32_t *int_mask) { int ret, max_len; bool spd; bool queuing = (q != NULL); uint8_t pid = td->token & 0xff; UHCIAsync *async; switch (pid) { case USB_TOKEN_OUT: case USB_TOKEN_SETUP: case USB_TOKEN_IN: break; default: s->status |= UHCI_STS_HCPERR; s->cmd &= ~UHCI_CMD_RS; uhci_update_irq(s); return TD_RESULT_STOP_FRAME; } async = uhci_async_find_td(s, td_addr); if (async) { if (uhci_queue_verify(async->queue, qh_addr, td, td_addr, queuing)) { assert(q == NULL || q == async->queue); q = async->queue; } else { uhci_queue_free(async->queue, "guest re-used pending td"); async = NULL; } } if (q == NULL) { q = uhci_queue_find(s, td); if (q && !uhci_queue_verify(q, qh_addr, td, td_addr, queuing)) { uhci_queue_free(q, "guest re-used qh"); q = NULL; } } if (q) { q->valid = QH_VALID; } if (!(td->ctrl & TD_CTRL_ACTIVE)) { if (async) { uhci_queue_free(async->queue, "pending td non-active"); } if (td->ctrl & TD_CTRL_IOC) { *int_mask |= 0x01; } return TD_RESULT_NEXT_QH; } if (async) { if (queuing) { return TD_RESULT_ASYNC_CONT; } if (!async->done) { UHCI_TD last_td; UHCIAsync *last = QTAILQ_LAST(&async->queue->asyncs, asyncs_head); uhci_read_td(s, &last_td, last->td_addr); uhci_queue_fill(async->queue, &last_td); return TD_RESULT_ASYNC_CONT; } uhci_async_unlink(async); goto done; } if (s->completions_only) { return TD_RESULT_ASYNC_CONT; } if (q == NULL) { USBDevice *dev = uhci_find_device(s, (td->token >> 8) & 0x7f); USBEndpoint *ep = usb_ep_get(dev, pid, (td->token >> 15) & 0xf); if (ep == NULL) { return uhci_handle_td_error(s, td, td_addr, USB_RET_NODEV, int_mask); } q = uhci_queue_new(s, qh_addr, td, ep); } async = uhci_async_alloc(q, td_addr); max_len = ((td->token >> 21) + 1) & 0x7ff; spd = (pid == USB_TOKEN_IN && (td->ctrl & TD_CTRL_SPD) != 0); usb_packet_setup(&async->packet, pid, q->ep, 0, td_addr, spd, (td->ctrl & TD_CTRL_IOC) != 0); if (max_len <= sizeof(async->static_buf)) { async->buf = async->static_buf; } else { async->buf = g_malloc(max_len); } usb_packet_addbuf(&async->packet, async->buf, max_len); switch(pid) { case USB_TOKEN_OUT: case USB_TOKEN_SETUP: pci_dma_read(&s->dev, td->buffer, async->buf, max_len); usb_handle_packet(q->ep->dev, &async->packet); if (async->packet.status == USB_RET_SUCCESS) { async->packet.actual_length = max_len; } break; case USB_TOKEN_IN: usb_handle_packet(q->ep->dev, &async->packet); break; default: abort(); } if (async->packet.status == USB_RET_ASYNC) { uhci_async_link(async); if (!queuing) { uhci_queue_fill(q, td); } return TD_RESULT_ASYNC_START; } done: ret = uhci_complete_td(s, td, async, int_mask); uhci_async_free(async); return ret; }
1threat
SQL - add column from table to table : I got 2 tables: first with 'CustomerID' and 'CustomerName' columns second with 'CustomerName' and 'Product' columns I want to add the 'CustomerID' column to the second table so it fit to corect customer (which can appear more than one time on this table) tnx!
0debug
static void kvm_init_irq_routing(KVMState *s) { int gsi_count; gsi_count = kvm_check_extension(s, KVM_CAP_IRQ_ROUTING); if (gsi_count > 0) { unsigned int gsi_bits, i; gsi_bits = ALIGN(gsi_count, 32); s->used_gsi_bitmap = g_malloc0(gsi_bits / 8); s->max_gsi = gsi_bits; for (i = gsi_count; i < gsi_bits; i++) { set_gsi(s, i); } } s->irq_routes = g_malloc0(sizeof(*s->irq_routes)); s->nr_allocated_irq_routes = 0; kvm_arch_init_irq_routing(s); }
1threat
when i run this program without ''static '' keyword .it runs fine,but with '''static'' keyword it shows error. : class Ideone { static final int iop;// your code goes here public Ideone() { iop=56; System.out.println(iop); } public static void main (String[] args) throws java.lang.Exception { new Ideone(); } }
0debug
DateTime.now in Elixir and Ecto : <p>I want to get the current date-time stamp in Phoenix/Elixir without a third-party library. Or simply, I want something like <code>DateTime.now()</code>. How can I do that?</p>
0debug
static void virtio_net_tx_timer(void *opaque) { VirtIONetQueue *q = opaque; VirtIONet *n = q->n; VirtIODevice *vdev = VIRTIO_DEVICE(n); assert(vdev->vm_running); q->tx_waiting = 0; if (!(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) { return; } virtio_queue_set_notification(q->tx_vq, 1); virtio_net_flush_tx(q); }
1threat
Xcode 8: Your account does not have sufficient permissions to modify containers : <p>I'm getting this error with code signing with Xcode 8:</p> <blockquote> <p>Your account does not have sufficient permissions to modify containers</p> </blockquote> <p><a href="https://i.stack.imgur.com/9nx1E.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9nx1E.png" alt="enter image description here"></a></p> <p>What does it want from me?</p>
0debug
Where to place the aria-controls attribute in my tabs markup : <p>I'm setting up a tabbed content section in my page using a script that follows the following syntax:</p> <pre><code>&lt;!-- Clickable tab links --&gt; &lt;ul class="js-tablist"&gt; &lt;li id="tab1" class="js-tab active"&gt;&lt;a href="#tabpanel1"&gt;Tab 1&lt;/a&gt;&lt;/li&gt; &lt;li id="tab2" class="js-tab"&gt;&lt;a href="#tabpanel2"&gt;Tab 2&lt;/a&gt;&lt;/li&gt; &lt;li id="tab3" class="js-tab"&gt;&lt;a href="#tabpanel3"&gt;Tab 3&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;!-- Tab panels --&gt; &lt;div id="tab-set" class="js-tabpanel-group"&gt; &lt;section id="tabpanel1" class="js-tabpanel"&gt;__CONTENT__&lt;/section&gt; &lt;section id="tabpanel2" class="js-tabpanel"&gt;__CONTENT__&lt;/section&gt; &lt;section id="tabpanel3" class="js-tabpanel"&gt;__CONTENT__&lt;/section&gt; &lt;/div&gt; </code></pre> <p>I will be setting various ARIA roles (<code>role="tablist"</code>, <code>role="tab"</code>, <code>role="tabpanel"</code>, etc) on this structural markup via javascript (since if there's no scripting then there are no tabs) but I'm unsure quite where to place my ‘aria-controls’ attributes. Should they go on the <code>&lt;li&gt;</code> element or on its <code>&lt;a&gt;</code> child element? Or does it not matter? Indeed, the same question could be asked about <code>role="tab"</code> and <code>tabindex="0"</code> -- should these things go on the list item or the anchor?</p>
0debug
How to save Mobx state in sessionStorage : <p>Trying to essentially accomplish this <a href="https://github.com/elgerlambert/redux-localstorage" rel="noreferrer">https://github.com/elgerlambert/redux-localstorage</a> which is for Redux but do it for Mobx. And preferably would like to use sessionStorage. Is there an easy way to accomplish this with minimal boilerplate?</p>
0debug
How to automatic update status? : [this is the image][1]I have a problem on how to update all status in one click. As you can see in the picture, if I click the lock it will then automatically update all status of the student to "lock", if I click the unlock button also it will automatic the status into "unlock", how to do that? Here's my code: <a href="unlock.php" title="Lock"><img src="images/lock.png" height="40" width="40"></a> <a href="lock.php" title="Unlock"><img style="margin-left:8px;" src="images/unlock.png" height="40" width="40"></a> when I click the lock.php here's what the codes like: <?php include '../connection/connect.php'; include '../dbcon.php'; $idnum=$_POST['idnum']; $stat='LOCK'; $sqla = "UPDATE student SET status=? WHERE idno=?"; $qa = $db->prepare($sqla); $qa->execute(array($stat,$idnum)); Header ('Location:lock_unlock.php'); } ?> [1]: http://i.stack.imgur.com/CMUVY.png
0debug
Tryng to loop my game back to the start dont know how : Im making a simple fighting game and if you die I want it to loop to the start and if you win stage 2 is unlocked and they deal more damage, I've got to a point where you enter y or no to start stage 2 but it doesn't do anything, completely stuck. When you answer please tell me exactly what to do if you say oh just make a while loop that wont help at all lol here's my code thanks. import random xp = 0 level = 1 player1 = raw_input("player1 enter name") enemyhealth = 100 playerhealth = 100 stage2 = "false" difficulty = raw_input("choose difficulty, rookie,pro,master,legend or god") if difficulty == "rookie": enemyhealth = enemyhealth - 15 if difficulty == "pro": enemyhealth = enemyhealth + 10 if difficulty == "master": enemyhealth = enemyhealth + 35 if difficulty == "legend": enemyhealth = enemyhealth + 40 if difficulty == "god": enemyhealth = enemyhealth + 60 print ("A quick tutorial: Make sure you type you actions with no spaces, heres a list of the moves you can perform") print ("Punch: A simple attack that has a short range of damage but is reliable.") print ("flyingkick: not 100 percent reliable but if pulled off correctly can deal good damage.") print ("uppercut: A somewhat reliable move that deals decent damage.") print ("kick: A simple attack that has a short range of damage but is reliable.") print ("stab: can be very powerful or deal next to no damage.") print ("shoot: deadly if it hits, less so if you miss.") print ("A man in the street starts a fight with you, beat him!") while(1): while enemyhealth >0: fight = raw_input("fight") if fight == "punch": print ("You punched the enemy") enemyhealth = enemyhealth - random.randint(5,10) xp = xp + 1 print "the enemy now has", enemyhealth, "health" print "they fight back!" playerhealth = playerhealth - random.randint(5,10) if stage2 == "true": playerhealth = playerhealth - random.randit (0,5) print "you now have..", playerhealth elif fight =="flyingkick": print "you flying kicked the enemy" enemyhealth = enemyhealth - random.randint(5,25) xp = xp + 1 print "the enemy now has", enemyhealth, "health" print "they fight back!" playerhealth = playerhealth - random.randint(5,15) if stage2 == "true": playerhealth = playerhealth - random.randit (0,5) print "you now have..", playerhealth elif fight =="uppercut": print "you uppercutted the enemy" enemyhealth = enemyhealth - random.randint(10,25) xp = xp + 1 print "the enemy now has", enemyhealth, "health" print "they fight back!" playerhealth = playerhealth - random.randint(5,15) if stage2 == "true": playerhealth = playerhealth - random.randit (1,5) print "you now have..", playerhealth elif fight =="rko": print "you rko'ed the enemy, out of nowhere!" enemyhealth = enemyhealth - random.randint(9,29) xp = xp + 1 print "the enemy now has", enemyhealth, "health" print "they fight back!" playerhealth = playerhealth - random.randint(5,12) if stage2 == "true": playerhealth = playerhealth - random.randit (1,5) print "you now have..", playerhealth elif fight =="kick": print "you kicked the enemy" enemyhealth = enemyhealth - random.randint(5,10) xp = xp + 1 print "the enemy now has", enemyhealth, "health" print "they fight back!" playerhealth = playerhealth - random.randint(5,10) if stage2 == "true": playerhealth = playerhealth - random.randit (1,5) print "you now have..", playerhealth elif fight =="ninjastar": print "you ninjastarred the enemy" enemyhealth = enemyhealth - random.randint(5,20) xp = xp + 1 print "the enemy now has", enemyhealth, "health" print "they fight back!" playerhealth = playerhealth - random.randint(5,10) if stage2 == "true": playerhealth = playerhealth - random.randit (1,5) print "you now have..", playerhealth elif fight =="headbutt": print "you headbutted the enemy" enemyhealth = enemyhealth - random.randint(5,18) xp = xp + 1 print "the enemy now has", enemyhealth, "health" print "they fight back!" playerhealth = playerhealth - random.randint(5,10) if stage2 == "true": playerhealth = playerhealth - random.randit (1,5) print "you now have..", playerhealth elif fight =="deathray": print "you deathrayed the enemy" enemyhealth = enemyhealth - random.randint(1,50) xp = xp + 1 print "the enemy now has", enemyhealth, "health" print "they fight back!" playerhealth = playerhealth - random.randint(1,30) if stage2 == "true": playerhealth = playerhealth - random.randit (1,5) print "you now have..", playerhealth elif fight =="stab": print "you stabbed the enemy" enemyhealth = enemyhealth - random.randint(3,40) xp = xp + 1 print "the enemy now has", enemyhealth, "health" print "they fight back!" playerhealth = playerhealth - random.randint(2,20) if stage2 == "true": playerhealth = playerhealth - random.randit (1,5) print "you now have..", playerhealth elif fight =="shoot": print "you shot the enemy" enemyhealth = enemyhealth - random.randint(1,50) xp = xp + 1 print "the enemy now has", enemyhealth, "health" print "they fight back!" playerhealth = playerhealth - random.randint(1,30) if stage2 == "true": playerhealth = playerhealth - random.randit (1,5) print "you now have..", playerhealth if xp == 5: print "you leveled up! move unlocked: 'rko'" if xp == 7: print "you leveled up! move unlocked: 'ninjastar'" if xp == 10: print "you leveled up! move unlocked: 'headbutt'" if xp == 100: print " you reached the max level! move 'deathray' is now unlocked" if playerhealth <1: again = raw_input('you died! Play agian? [y/n]') if again is "y": next else: print('Thanks for playing!\n') exit() if enemyhealth < 1: again = raw_input('You Won! stage 2 is unlocked would you like to try and beat it?[y/n]:') if again is "y": next else: print('Thanks for playing!\n') exit() stage2 = "true" else: None
0debug
def rev(num): rev_num = 0 while (num > 0): rev_num = (rev_num * 10 + num % 10) num = num // 10 return rev_num def check(n): return (2 * rev(n) == n + 1)
0debug
Kubernetes check serviceaccount permissions : <p>When deploying a service via a Helm Chart, the installation failed because the <code>tiller</code> serviceaccount was not allowed to create a <code>ServiceMonitor</code> resource.</p> <p>Note:</p> <ul> <li><code>ServiceMonitor</code> is a CRD defined by the Prometheus Operator to automagically get metrics of running containers in Pods.</li> <li>Helm Tiller is installed in a single namespace and the RBAC has been setup using Role and RoleBinding.</li> </ul> <p>I wanted to verify the permissions of the <code>tiller</code> serviceaccount.<br> <code>kubectl</code> has the <code>auth can-i</code> command, queries like these (see below) always return <code>no</code>.</p> <ul> <li><code>kubectl auth can-i list deployment --as=tiller</code></li> <li><code>kubectl auth can-i list deployment --as=staging:tiller</code></li> </ul> <p>What is the proper way to check permissions for a serviceaccount?<br> How to enable the <code>tiller</code> account to create a ServiceMonitor resource?</p>
0debug