problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static int write_representation(AVFormatContext *s, AVStream *stream, char *id,
int output_width, int output_height,
int output_sample_rate) {
WebMDashMuxContext *w = s->priv_data;
AVDictionaryEntry *irange = av_dict_get(stream->metadata, INITIALIZATION_RANGE, NULL, 0);
AVDictionaryEntry *cues_start = av_dict_get(stream->metadata, CUES_START, NULL, 0);
AVDictionaryEntry *cues_end = av_dict_get(stream->metadata, CUES_END, NULL, 0);
AVDictionaryEntry *filename = av_dict_get(stream->metadata, FILENAME, NULL, 0);
AVDictionaryEntry *bandwidth = av_dict_get(stream->metadata, BANDWIDTH, NULL, 0);
if ((w->is_live && (!filename)) ||
(!w->is_live && (!irange || !cues_start || !cues_end || !filename || !bandwidth))) {
return -1;
}
avio_printf(s->pb, "<Representation id=\"%s\"", id);
avio_printf(s->pb, " bandwidth=\"%s\"",
w->is_live ? (stream->codec->codec_type == AVMEDIA_TYPE_AUDIO ? "128000" : "1000000") : bandwidth->value);
if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO && output_width)
avio_printf(s->pb, " width=\"%d\"", stream->codec->width);
if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO && output_height)
avio_printf(s->pb, " height=\"%d\"", stream->codec->height);
if (stream->codec->codec_type = AVMEDIA_TYPE_AUDIO && output_sample_rate)
avio_printf(s->pb, " audioSamplingRate=\"%d\"", stream->codec->sample_rate);
if (w->is_live) {
avio_printf(s->pb, " codecs=\"%s\"", get_codec_name(stream->codec->codec_id));
avio_printf(s->pb, " mimeType=\"%s/webm\"",
stream->codec->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio");
avio_printf(s->pb, " startsWithSAP=\"1\"");
avio_printf(s->pb, ">");
} else {
avio_printf(s->pb, ">\n");
avio_printf(s->pb, "<BaseURL>%s</BaseURL>\n", filename->value);
avio_printf(s->pb, "<SegmentBase\n");
avio_printf(s->pb, " indexRange=\"%s-%s\">\n", cues_start->value, cues_end->value);
avio_printf(s->pb, "<Initialization\n");
avio_printf(s->pb, " range=\"0-%s\" />\n", irange->value);
avio_printf(s->pb, "</SegmentBase>\n");
}
avio_printf(s->pb, "</Representation>\n");
return 0;
}
| 1threat
|
Python 2 parameters, as independent. : First of all thanks for the attention, and on the other hand I don't think is so difficult what I try to do, only that I've been stuck for 2 days and I do not know what to do.
I have software to which a script is added. This software passes 2 parameters
`sys.argv[1]` and `sys.argv [2]`
But the software passes the 2 parameters as a string.
How can I separate these 2 parameters to interpret them as independent parameters?
| 0debug
|
Where do i download XNA? (in visual studio) : <p>I was looking to start learning XNA and make games with it.When i tried looking online for videos and websites it didn't work, I saw videos about XNA but i didn't download button.</p>
| 0debug
|
static void handle_pending_signal(CPUArchState *cpu_env, int sig)
{
CPUState *cpu = ENV_GET_CPU(cpu_env);
abi_ulong handler;
sigset_t set;
target_sigset_t target_old_set;
struct target_sigaction *sa;
TaskState *ts = cpu->opaque;
struct emulated_sigtable *k = &ts->sigtab[sig - 1];
trace_user_handle_signal(cpu_env, sig);
k->pending = 0;
sig = gdb_handlesig(cpu, sig);
if (!sig) {
sa = NULL;
handler = TARGET_SIG_IGN;
} else {
sa = &sigact_table[sig - 1];
handler = sa->_sa_handler;
}
if (sig == TARGET_SIGSEGV && sigismember(&ts->signal_mask, SIGSEGV)) {
handler = TARGET_SIG_DFL;
}
if (handler == TARGET_SIG_DFL) {
if (sig == TARGET_SIGTSTP || sig == TARGET_SIGTTIN || sig == TARGET_SIGTTOU) {
kill(getpid(),SIGSTOP);
} else if (sig != TARGET_SIGCHLD &&
sig != TARGET_SIGURG &&
sig != TARGET_SIGWINCH &&
sig != TARGET_SIGCONT) {
force_sig(sig);
}
} else if (handler == TARGET_SIG_IGN) {
} else if (handler == TARGET_SIG_ERR) {
force_sig(sig);
} else {
sigset_t *blocked_set;
target_to_host_sigset(&set, &sa->sa_mask);
if (!(sa->sa_flags & TARGET_SA_NODEFER))
sigaddset(&set, target_to_host_signal(sig));
host_to_target_sigset_internal(&target_old_set, &ts->signal_mask);
blocked_set = ts->in_sigsuspend ?
&ts->sigsuspend_mask : &ts->signal_mask;
sigorset(&ts->signal_mask, blocked_set, &set);
ts->in_sigsuspend = 0;
#if defined(TARGET_I386) && !defined(TARGET_X86_64)
{
CPUX86State *env = cpu_env;
if (env->eflags & VM_MASK)
save_v86_state(env);
}
#endif
#if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64) \
|| defined(TARGET_OPENRISC) || defined(TARGET_TILEGX)
setup_rt_frame(sig, sa, &k->info, &target_old_set, cpu_env);
#else
if (sa->sa_flags & TARGET_SA_SIGINFO)
setup_rt_frame(sig, sa, &k->info, &target_old_set, cpu_env);
else
setup_frame(sig, sa, &target_old_set, cpu_env);
#endif
if (sa->sa_flags & TARGET_SA_RESETHAND) {
sa->_sa_handler = TARGET_SIG_DFL;
}
}
}
| 1threat
|
How Do I Get Started With Springboot : Are there any good resources to get started with Springboot? Any good tutorials, blogs or books?
| 0debug
|
static int tight_palette_insert(QDict *palette, uint32_t rgb, int bpp, int max)
{
uint8_t key[6];
int idx = qdict_size(palette);
bool present;
tight_palette_rgb2buf(rgb, bpp, key);
present = qdict_haskey(palette, (char *)key);
if (idx >= max && !present) {
return 0;
}
if (!present) {
qdict_put(palette, (char *)key, qint_from_int(idx));
}
return qdict_size(palette);
}
| 1threat
|
int ff_unlock_avcodec(const AVCodec *codec)
{
_Bool exp = 1;
if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init)
return 0;
av_assert0(atomic_compare_exchange_strong(&ff_avcodec_locked, &exp, 0));
atomic_fetch_add(&entangled_thread_counter, -1);
if (lockmgr_cb) {
if ((*lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE))
return -1;
}
return 0;
}
| 1threat
|
static int decode_blck(uint8_t *frame, int width, int height,
const uint8_t *src, const uint8_t *src_end)
{
memset(frame, 0, width * height);
return 0;
}
| 1threat
|
How to write correctly regex pattern for less comman : How convert this pattern
Some_Word>[\n\t\r].*?[\n\t\r].*?[\n\t\r].*?<symbol>BK<\/symbol>
to be **less** recognize his?
P.S. I checked [here][1] that patter with the text and it work correctly:
before bla bla<Some_Word>
ssssssssssssssssssss>
dddddddddddddddddddd>
ccccccccccccccccccccc <symbol>BK</symbol>
after bla bla>
Help me please.
Thanks for advance!
[1]: https://regex101.com/
| 0debug
|
How to make vutejs template out of html? : How can I separate the script template and the html. This template made the doc too large. What should I do to cache it?
<script id="search-game-result-tpl" type="text/html">
<li class="" data-id='<%=data['id']%>'>
<a class="flex-box" href="/game/<%=data['url_slug']%>">
<img class="gl-border" src="<%=data['pic']%>">
<span><%==data['title']%></span>
</a>
</li>
</script>
<script id="search-tag-result-tpl" type="text/html">
<li class="" data-id='<%=data['id']%>'>
<a class="clearfix" href="/element/<%=data['id']%>">
<img class="gl-border" src="<%=data['pic']%>">
<span><%==data['name']%></span>
</a>
</li>
</script>
<script id="search-question-result-tpl" type="text/html">
<li class="clearfix " data-id='<%=data['id']%>'>
<a class="clearfix" href="/question/<%=data['id']%>">
<span><%==data['title']%></span>
</a>
</li>
</script>
| 0debug
|
How to clear Firestore persistence data? : <p>My iOS app's firestore cache seems to have got out of sync with Firestore. As a result I've had to disable persistence. Is there anyway to reset the cache? And is there a way to make sure it's constantly in sync? All I did was delete documents from the database!</p>
| 0debug
|
Pass a string throudght on Click function - PHP : I am trying to pass a string in the onClick event handler function's arguments.
I am not able to pass the string to the function, but i am able to pass the number integer to the function.
Please help me in this. Thanks in advance.
php :
echo '<tr style="background: #D6EAF8" class="clickable-row" OnClick="DisplayEnterOrderModal('.$order["id_order"].','.$order["id_customer"].','.$order[7].','"wanted to be passed"');" value="'.$order["id_order"].'" > ';
error :
( ! ) Parse error: syntax error, unexpected '"wanted to be passed"' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';' in C:\wamp32\www\EK\index.php on line 644
| 0debug
|
What is progressive web app solution for IOS : <p>I was wondering what's the solution of progressive web app for IOS devices since their default brower SAFARI doesn't yet support progressive web apps.
Whats the alternate then for IOS counterparts?</p>
| 0debug
|
static void FUNCC(pred4x4_129_dc)(uint8_t *_src, const uint8_t *topright, int _stride){
pixel *src = (pixel*)_src;
int stride = _stride/sizeof(pixel);
((pixel4*)(src+0*stride))[0]=
((pixel4*)(src+1*stride))[0]=
((pixel4*)(src+2*stride))[0]=
((pixel4*)(src+3*stride))[0]= PIXEL_SPLAT_X4((1<<(BIT_DEPTH-1))+1);
}
| 1threat
|
Alphabetically sort array by sub-array's first element : <p>I'm looking for a way to sort an array that looks like this:</p>
<pre><code>$array = array(
[0] => array('a', '1', '2', '3', '4,' test'),
[1] => array('c', '1', '2', '3', '5', 'test'),
[2] => array('b', '1', '3', '4,' 5,', 'test),
);
</code></pre>
<p>so that it sorts the sub-array's according to the sub-array's first element, such that it returns:</p>
<pre><code>$array = array(
[0] => array('a', '1', '2', '3', '4,' test'),
[1] => array('b', '1', '3', '4,' 5,', 'test),
[2] => array('c', '1', '2', '3', '5', 'test'),
);
</code></pre>
<p>Does anyone have a good way about doing this?</p>
<p>Thank you!</p>
| 0debug
|
How to increase SMTP limit ? - andoird : I'm using an **SMTP** for sending an email from the application but as I have searched it only allowed to send **500 emails** per day so is there any way through which I can send more than **10K SMTP email** per day ? Else any other source through which we can send number of emails in android application
Regard
**Mahak Singhvi**
| 0debug
|
static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb,
dirac_source_params *source)
{
AVRational frame_rate = {0,0};
unsigned luma_depth = 8, luma_offset = 16;
int idx;
int chroma_x_shift, chroma_y_shift;
if (get_bits1(gb)) {
source->width = svq3_get_ue_golomb(gb);
source->height = svq3_get_ue_golomb(gb);
}
if (get_bits1(gb))
source->chroma_format = svq3_get_ue_golomb(gb);
if (source->chroma_format > 2U) {
av_log(avctx, AV_LOG_ERROR, "Unknown chroma format %d\n",
source->chroma_format);
return AVERROR_INVALIDDATA;
}
if (get_bits1(gb))
source->interlaced = svq3_get_ue_golomb(gb);
if (source->interlaced > 1U)
return AVERROR_INVALIDDATA;
if (get_bits1(gb)) {
source->frame_rate_index = svq3_get_ue_golomb(gb);
if (source->frame_rate_index > 10U)
return AVERROR_INVALIDDATA;
if (!source->frame_rate_index) {
frame_rate.num = svq3_get_ue_golomb(gb);
frame_rate.den = svq3_get_ue_golomb(gb);
}
}
if (source->frame_rate_index > 0) {
if (source->frame_rate_index <= 8)
frame_rate = ff_mpeg12_frame_rate_tab[source->frame_rate_index];
else
frame_rate = dirac_frame_rate[source->frame_rate_index-9];
}
av_reduce(&avctx->time_base.num, &avctx->time_base.den,
frame_rate.den, frame_rate.num, 1<<30);
if (get_bits1(gb)) {
source->aspect_ratio_index = svq3_get_ue_golomb(gb);
if (source->aspect_ratio_index > 6U)
return AVERROR_INVALIDDATA;
if (!source->aspect_ratio_index) {
avctx->sample_aspect_ratio.num = svq3_get_ue_golomb(gb);
avctx->sample_aspect_ratio.den = svq3_get_ue_golomb(gb);
}
}
if (source->aspect_ratio_index > 0)
avctx->sample_aspect_ratio =
dirac_preset_aspect_ratios[source->aspect_ratio_index-1];
if (get_bits1(gb)) {
source->clean_width = svq3_get_ue_golomb(gb);
source->clean_height = svq3_get_ue_golomb(gb);
source->clean_left_offset = svq3_get_ue_golomb(gb);
source->clean_right_offset = svq3_get_ue_golomb(gb);
}
if (get_bits1(gb)) {
source->pixel_range_index = svq3_get_ue_golomb(gb);
if (source->pixel_range_index > 4U)
return AVERROR_INVALIDDATA;
if (!source->pixel_range_index) {
luma_offset = svq3_get_ue_golomb(gb);
luma_depth = av_log2(svq3_get_ue_golomb(gb))+1;
svq3_get_ue_golomb(gb);
svq3_get_ue_golomb(gb);
avctx->color_range = luma_offset ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
}
}
if (source->pixel_range_index > 0) {
idx = source->pixel_range_index-1;
luma_depth = pixel_range_presets[idx].bitdepth;
avctx->color_range = pixel_range_presets[idx].color_range;
}
if (luma_depth > 8)
av_log(avctx, AV_LOG_WARNING, "Bitdepth greater than 8\n");
avctx->pix_fmt = dirac_pix_fmt[!luma_offset][source->chroma_format];
avcodec_get_chroma_sub_sample(avctx->pix_fmt, &chroma_x_shift, &chroma_y_shift);
if (!(source->width % (1<<chroma_x_shift)) || !(source->height % (1<<chroma_y_shift))) {
av_log(avctx, AV_LOG_ERROR, "Dimensions must be a integer multiply of the chroma subsampling\n");
return AVERROR_INVALIDDATA;
}
if (get_bits1(gb)) {
idx = source->color_spec_index = svq3_get_ue_golomb(gb);
if (source->color_spec_index > 4U)
return AVERROR_INVALIDDATA;
avctx->color_primaries = dirac_color_presets[idx].color_primaries;
avctx->colorspace = dirac_color_presets[idx].colorspace;
avctx->color_trc = dirac_color_presets[idx].color_trc;
if (!source->color_spec_index) {
if (get_bits1(gb)) {
idx = svq3_get_ue_golomb(gb);
if (idx < 3U)
avctx->color_primaries = dirac_primaries[idx];
}
if (get_bits1(gb)) {
idx = svq3_get_ue_golomb(gb);
if (!idx)
avctx->colorspace = AVCOL_SPC_BT709;
else if (idx == 1)
avctx->colorspace = AVCOL_SPC_BT470BG;
}
if (get_bits1(gb) && !svq3_get_ue_golomb(gb))
avctx->color_trc = AVCOL_TRC_BT709;
}
} else {
idx = source->color_spec_index;
avctx->color_primaries = dirac_color_presets[idx].color_primaries;
avctx->colorspace = dirac_color_presets[idx].colorspace;
avctx->color_trc = dirac_color_presets[idx].color_trc;
}
return 0;
}
| 1threat
|
import re
def extract_date(url):
return re.findall(r'/(\d{4})/(\d{1,2})/(\d{1,2})/', url)
| 0debug
|
FlatList vs map react-native : <p>I have recently started using <code>react-native</code> and have come across the <code>FlatList</code> component. When using <code>react</code> I have always used <code>map</code> with an array. </p>
<p>I was using <code>FlatList</code> but there was issues when I wanted to change the <code>flex-direction</code> of items in the <code>FlatList</code> so I reverted to using <code>map</code>.</p>
<p>Here are the two examples using both methods:</p>
<p><code>map</code></p>
<pre><code>{
this.state.images.map(image => {
return (
<UsersImage key={ image } source={{ uri: image }} />
)
})
}
</code></pre>
<p><code>FlatList</code></p>
<pre><code><FlatList
data={ this.state.images }
renderItem={({item}) => {
return (
<UsersImage source={{ uri: item }} />
)
}}
keyExtractor={(item, index) => index}
/>
</code></pre>
<p>Can anyone explain why one should use <code>FlatList</code> over <code>map</code> or vice versa?</p>
| 0debug
|
int vnc_tight_send_framebuffer_update(VncState *vs, int x, int y,
int w, int h)
{
int max_rows;
if (vs->clientds.pf.bytes_per_pixel == 4 && vs->clientds.pf.rmax == 0xFF &&
vs->clientds.pf.bmax == 0xFF && vs->clientds.pf.gmax == 0xFF) {
vs->tight_pixel24 = true;
} else {
vs->tight_pixel24 = false;
}
if (w * h < VNC_TIGHT_MIN_SPLIT_RECT_SIZE)
return send_rect_simple(vs, x, y, w, h);
max_rows = tight_conf[vs->tight_compression].max_rect_size;
max_rows /= MIN(tight_conf[vs->tight_compression].max_rect_width, w);
return find_large_solid_color_rect(vs, x, y, w, h, max_rows);
}
| 1threat
|
IFileOperation SetOperationFlags FOFX_RECYCLEONDELETE Flag : Super quick question - according to [here][1] FOFX_RECYCLEONDELETE flag was introduced in Win 8 - will it work in Vista/7? I'm just moving files/folders to the recycle bin instead of deleting completely. There's always SHFileOperation but I'd rather use a more up-to-date Win32 API method. Anything else to know?
Any alternate ways of recycling files/folders? Thanks.
[1]: https://msdn.microsoft.com/en-us/library/windows/desktop/bb775799%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
| 0debug
|
When i want to install the MySQL i faced this issue "root account password" i forgot it : [This is when installation of MySQL and its request the root password but i forgot the password][1]
[1]: https://i.stack.imgur.com/GQl2E.png
| 0debug
|
static uint32_t mvc_asc(CPUS390XState *env, int64_t l, uint64_t a1,
uint64_t mode1, uint64_t a2, uint64_t mode2)
{
CPUState *cs = CPU(s390_env_get_cpu(env));
target_ulong src, dest;
int flags, cc = 0, i;
if (!l) {
return 0;
} else if (l > 256) {
l = 256;
cc = 3;
}
if (mmu_translate(env, a1, 1, mode1, &dest, &flags, true)) {
cpu_loop_exit(CPU(s390_env_get_cpu(env)));
}
dest |= a1 & ~TARGET_PAGE_MASK;
if (mmu_translate(env, a2, 0, mode2, &src, &flags, true)) {
cpu_loop_exit(CPU(s390_env_get_cpu(env)));
}
src |= a2 & ~TARGET_PAGE_MASK;
for (i = 0; i < l; i++) {
if ((((dest + i) & TARGET_PAGE_MASK) != (dest & TARGET_PAGE_MASK)) ||
(((src + i) & TARGET_PAGE_MASK) != (src & TARGET_PAGE_MASK))) {
mvc_asc(env, l - i, a1 + i, mode1, a2 + i, mode2);
break;
}
stb_phys(cs->as, dest + i, ldub_phys(cs->as, src + i));
}
return cc;
}
| 1threat
|
static inline void RENAME(yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
long width, long height,
long lumStride, long chromStride, long dstStride)
{
RENAME(yuvPlanartoyuy2)(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride, 2);
}
| 1threat
|
static uint64_t boston_lcd_read(void *opaque, hwaddr addr,
unsigned size)
{
BostonState *s = opaque;
uint64_t val = 0;
switch (size) {
case 8:
val |= (uint64_t)s->lcd_content[(addr + 7) & 0x7] << 56;
val |= (uint64_t)s->lcd_content[(addr + 6) & 0x7] << 48;
val |= (uint64_t)s->lcd_content[(addr + 5) & 0x7] << 40;
val |= (uint64_t)s->lcd_content[(addr + 4) & 0x7] << 32;
case 4:
val |= (uint64_t)s->lcd_content[(addr + 3) & 0x7] << 24;
val |= (uint64_t)s->lcd_content[(addr + 2) & 0x7] << 16;
case 2:
val |= (uint64_t)s->lcd_content[(addr + 1) & 0x7] << 8;
case 1:
val |= (uint64_t)s->lcd_content[(addr + 0) & 0x7];
break;
}
return val;
}
| 1threat
|
Assets not referencing to public folder (Laravel) : <p>I have the public folder inside my laravel project and I have some js and css files inside it. </p>
<p>I'm using the asset function and even though it's referencing to the public folder, my files aren't loaded on the page.</p>
<p>I'm using this code to load (it's only one example, there are more files):</p>
<pre><code><link href="{{ asset('css/style.css') }}" rel="stylesheet">
</code></pre>
<p>And on the browser's console, I'm geting something like this:</p>
<blockquote>
<p>Failed to load resource: the server responded with a status of 404 (Not Found)
<a href="http://localhost:8000/css/style.css" rel="noreferrer">http://localhost:8000/css/style.css</a></p>
</blockquote>
<p>Well, I tried to revert the last commit, but no success. Tried to change to URL::asset() function, nothing. Tried everything from the following link: <a href="http://laravel.io/forum/09-17-2014-problem-asset-not-point-to-public-folder?page=1" rel="noreferrer">http://laravel.io/forum/09-17-2014-problem-asset-not-point-to-public-folder?page=1</a> and success.</p>
<p>Please, a little help?</p>
<p>Thanks!</p>
| 0debug
|
How to vertically center a text in a column (bootstrap 4)? : <p>How to vertically center a text in a column (bootstrap 4)? The structure is basic, see:</p>
<pre><code><div class="row">
<div class="col-md-6">
<span>Text to center</span>
</div
</div>
</code></pre>
<p>Ty guys!</p>
| 0debug
|
Jquery + Javascript Afficher DIV : Bonjour,
Avez-vous une idée pour faire afficher ma DIV "Transparent" (Jquery) via ma fonction test() en javascript ? merci d'avance
| 0debug
|
Is there another user authentication gem that doesn't depend on bcrypt? : <p>I've been having a hard time with bcrypt and devise and it's messing my whole website up. Is there any other gem like devise which doesn't depend on bcrypt? Or is there another gem such as bcrypt that's compatible with devise? </p>
<p>Thanks. </p>
| 0debug
|
AutoIT Q. How to click a button not coded as one using autoIt : I have a button on a page which is like this.
<input ng-disabled="form.$invalid" type="submit" value="Log On" class="btn btn-default" style="float: right" />
How do I click such a button using autoIt.
TIA
| 0debug
|
unable to start new activity involving firebase : I am building an app that has a charity and restuarant .they registers themselves and then proceed.using firebase for database handling.
when i register charity register charity should open but it shows error.
logcat and register charity file attached.Pls help asap.
thanks in advance.
#activity register charity #
package com.example.aayu.myapplication;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
/**
* Created by AAYU on 30-May-17.
*/
public class regc extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.reg_c);
final DatabaseReference rootref = FirebaseDatabase.getInstance()
.getReferenceFromUrl("https://myapplication-6e0b9.firebaseio.com/charity");
final EditText mname = (EditText) findViewById(R.id.cname);
final EditText madd = (EditText) findViewById(R.id.cadd);
final EditText mcity = (EditText) findViewById(R.id.ccity);
final EditText mstate = (EditText) findViewById(R.id.cstate);
final EditText mpin = (EditText) findViewById(R.id.cpin);
final Button mnext= (Button) findViewById(R.id.cnext);
mnext.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
String name = mname.getText().toString();
String add = madd.getText().toString();
String city = mcity.getText().toString();
String state = mstate.getText().toString();
String pin = mpin.getText().toString();
DatabaseReference childref = rootref.child("Charity Name");
childref.setValue(name);
childref = rootref.child("Address");
childref.setValue(add);
childref = rootref.child("City");
childref.setValue(city);
childref = rootref.child("State");
childref.setValue(state);
childref = rootref.child("Pincode");
childref.setValue(pin);
}
});
//setContentView(R.layout.reg2_c);
final EditText memail = (EditText) findViewById(R.id.cemail);
final EditText mph = (EditText) findViewById(R.id.cph);
final EditText muname = (EditText) findViewById(R.id.cuname);
final EditText mpwd = (EditText) findViewById(R.id.cpwd);
final Button mreg=(Button) findViewById(R.id.creg);
mreg.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
String email = memail.getText().toString();
String ph = mph.getText().toString();
String uname = muname.getText().toString();
String pwd = mpwd.getText().toString();
DatabaseReference childref = rootref.child("Email Id");
childref.setValue(email);
childref = rootref.child("Phone No");
childref.setValue(ph);
childref = rootref.child("Username");
childref.setValue(uname);
childref = rootref.child("Password");
childref.setValue(pwd);
Toast.makeText(view.getContext(), "Registration done successfully", Toast.LENGTH_SHORT).show();
}
});
// Intent loginc = new Intent(this, loginc.class);
// startActivity(loginc);
}
}
#logcat#
W/GooglePlayServicesUtil: Google Play services out of date. Requires 11011000 but found 9877470
V/FA: Activity paused, time: 32230643
V/FA: Processing queued up service tasks: 2
E/FA: Failed to send current screen to service
E/FA: Discarding data. Failed to send event to service
D/AndroidRuntime: Shutting down VM
E/UncaughtException: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.aayu.myapplication/com.example.aayu.myapplication.regc}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at com.example.aayu.myapplication.regc.onCreate(regc.java:76)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.aayu.myapplication, PID: 9023
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.aayu.myapplication/com.example.aayu.myapplication.regc}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at com.example.aayu.myapplication.regc.onCreate(regc.java:76)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
Application terminated.
| 0debug
|
static int sad16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
{
int i;
int s;
const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
vector unsigned char perm1, perm2, *pix1v, *pix2v;
vector unsigned char t1, t2, t3,t4, t5;
vector unsigned int sad;
vector signed int sumdiffs;
sad = (vector unsigned int)vec_splat_u32(0);
for (i = 0; i < h; i++) {
perm1 = vec_lvsl(0, pix1);
pix1v = (vector unsigned char *) pix1;
perm2 = vec_lvsl(0, pix2);
pix2v = (vector unsigned char *) pix2;
t1 = vec_perm(pix1v[0], pix1v[1], perm1);
t2 = vec_perm(pix2v[0], pix2v[1], perm2);
t3 = vec_max(t1, t2);
t4 = vec_min(t1, t2);
t5 = vec_sub(t3, t4);
sad = vec_sum4s(t5, sad);
pix1 += line_size;
pix2 += line_size;
}
sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
sumdiffs = vec_splat(sumdiffs, 3);
vec_ste(sumdiffs, 0, &s);
return s;
}
| 1threat
|
Kubernetes Logs - How to get logs for kube-system pods : <p>How do you get logs from kube-system pods? Running <code>kubectl logs pod_name_of_system_pod</code> does not work:</p>
<pre><code>λ kubectl logs kube-dns-1301475494-91vzs
Error from server (NotFound): pods "kube-dns-1301475494-91vzs" not found
</code></pre>
<p>Here is the output from <code>get pods</code>:</p>
<pre><code>λ kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
default alternating-platypus-rabbitmq-3309937619-ddl6b 1/1 Running 1 1d
kube-system kube-addon-manager-minikube 1/1 Running 1 1d
kube-system kube-dns-1301475494-91vzs 3/3 Running 3 1d
kube-system kubernetes-dashboard-rvm78 1/1 Running 1 1d
kube-system tiller-deploy-3703072393-x7xgb 1/1 Running 1 1d
</code></pre>
| 0debug
|
Are inline variables unique across boundaries? : <p>This is a follow up of <a href="https://stackoverflow.com/questions/51332851/alternative-id-generators-for-types/51334917#comment89715080_51334917">this question</a>.<br>
As mentioned in the comments to the answer:</p>
<blockquote>
<p>An inline variable has the property that - <em>It has the same address in every translation unit</em>. [...] Usually you achieved that by defining the variable in a cpp file, but with the inline specifier you can just declare/define your variables in a header file and every translation unit using this inline variable uses exactly the same object.</p>
</blockquote>
<p>Moreover, from the answer itself:</p>
<blockquote>
<p>While the language does not guarantee (or even mention) what happens when you use this new feature across shared libraries boundaries, it does work on my machine.</p>
</blockquote>
<p>In other terms, it isn't clear if an inline variable is guaranteed to be unique across boundaries when shared libraries are involved. Someone proved empirically that <em>it works</em> on some platforms, but it isn't properly an answer and it could just break everything on other platforms.</p>
<p>Is there any guarantee regarding the uniqueness of an inline variable when it is used across boundaries or is it simply an implementation detail that I should not rely on?</p>
| 0debug
|
Sending Docker container logs to ELK Stack by configuring the logging drivers - Easy Method : <p>I usually run applications as docker containers because of its high flexibility and availability. Is there a way to get the container logs into my <em>logstash</em> server. </p>
| 0debug
|
static void fill_elf_header(struct elfhdr *elf, int segs, uint16_t machine,
uint32_t flags)
{
(void) memset(elf, 0, sizeof(*elf));
(void) memcpy(elf->e_ident, ELFMAG, SELFMAG);
elf->e_ident[EI_CLASS] = ELF_CLASS;
elf->e_ident[EI_DATA] = ELF_DATA;
elf->e_ident[EI_VERSION] = EV_CURRENT;
elf->e_ident[EI_OSABI] = ELF_OSABI;
elf->e_type = ET_CORE;
elf->e_machine = machine;
elf->e_version = EV_CURRENT;
elf->e_phoff = sizeof(struct elfhdr);
elf->e_flags = flags;
elf->e_ehsize = sizeof(struct elfhdr);
elf->e_phentsize = sizeof(struct elf_phdr);
elf->e_phnum = segs;
#ifdef BSWAP_NEEDED
bswap_ehdr(elf);
#endif
}
| 1threat
|
static int vnc_update_client(VncState *vs, int has_dirty, bool sync)
{
vs->has_dirty += has_dirty;
if (vs->need_update && vs->ioc != NULL) {
VncDisplay *vd = vs->vd;
VncJob *job;
int y;
int height, width;
int n = 0;
if (vs->output.offset && !vs->audio_cap && !vs->force_update)
return 0;
if (!vs->has_dirty && !vs->audio_cap && !vs->force_update)
return 0;
job = vnc_job_new(vs);
height = pixman_image_get_height(vd->server);
width = pixman_image_get_width(vd->server);
y = 0;
for (;;) {
int x, h;
unsigned long x2;
unsigned long offset = find_next_bit((unsigned long *) &vs->dirty,
height * VNC_DIRTY_BPL(vs),
y * VNC_DIRTY_BPL(vs));
if (offset == height * VNC_DIRTY_BPL(vs)) {
break;
}
y = offset / VNC_DIRTY_BPL(vs);
x = offset % VNC_DIRTY_BPL(vs);
x2 = find_next_zero_bit((unsigned long *) &vs->dirty[y],
VNC_DIRTY_BPL(vs), x);
bitmap_clear(vs->dirty[y], x, x2 - x);
h = find_and_clear_dirty_height(vs, y, x, x2, height);
x2 = MIN(x2, width / VNC_DIRTY_PIXELS_PER_BIT);
if (x2 > x) {
n += vnc_job_add_rect(job, x * VNC_DIRTY_PIXELS_PER_BIT, y,
(x2 - x) * VNC_DIRTY_PIXELS_PER_BIT, h);
}
if (!x && x2 == width / VNC_DIRTY_PIXELS_PER_BIT) {
y += h;
if (y == height) {
break;
}
}
}
vnc_job_push(job);
if (sync) {
vnc_jobs_join(vs);
}
vs->force_update = 0;
vs->has_dirty = 0;
return n;
}
if (vs->disconnecting) {
vnc_disconnect_finish(vs);
} else if (sync) {
vnc_jobs_join(vs);
}
return 0;
}
| 1threat
|
Angular Material2 theming - how to set app background? : <p>I am building an angular2 app using angular material2. I am trying to set the background of my application "the correct way", but I can't figure out how.</p>
<p>I found a class I can use on my <code><body></code> element: <code>mat-app-background</code> which I can add, that gives me a default color (depending on whether I'm using the light or dark themes).</p>
<p>I wish to define this background color to use my brands' color, but I cannot figure out how to do it.</p>
<p>In <code>_theming.scss</code> it is defined like so:</p>
<pre><code>// Mixin that renders all of the core styles that depend on the theme.
@mixin mat-core-theme($theme) {
@include mat-ripple-theme($theme);
@include mat-option-theme($theme);
@include mat-pseudo-checkbox-theme($theme);
// Wrapper element that provides the theme background when the
// user's content isn't inside of a `md-sidenav-container`.
.mat-app-background {
$background: map-get($theme, background);
background-color: mat-color($background, background);
}
...
}
</code></pre>
<p>So I thought it would make sense to try adding the background color to my custom theme, somehow, but I couldn't understand how to do so.</p>
<p>On the Material2 <a href="https://github.com/angular/material2/blob/master/guides/theming.md" rel="noreferrer">theming</a> documentation it only says:</p>
<p>"In Angular Material, a theme is created by composing multiple palettes. In particular, a theme consists of:</p>
<ul>
<li>A primary palette: colors most widely used across all screens and components.</li>
<li>An accent palette: colors used for the floating action button and interactive elements.</li>
<li>A warn palette: colors used to convey error state. </li>
<li>A foreground palette: colors for text and icons.</li>
<li>A background palette: colors used for element backgrounds.
"</li>
</ul>
<p>How can I add my background to the theme, or do it in any other way?</p>
| 0debug
|
Variable could't be recognized by server : <pre><code><pre>
$query = "select * from user WHERE username = '$username'";
$query_run = mysqli_query($con,$query);
</pre>
</code></pre>
<p>When I execute the program it show me this message. Undefined variable: con in </p>
| 0debug
|
static void decode_channel_map(uint8_t layout_map[][3],
enum ChannelPosition type,
GetBitContext *gb, int n)
{
while (n--) {
enum RawDataBlockType syn_ele;
switch (type) {
case AAC_CHANNEL_FRONT:
case AAC_CHANNEL_BACK:
case AAC_CHANNEL_SIDE:
syn_ele = get_bits1(gb);
break;
case AAC_CHANNEL_CC:
skip_bits1(gb);
syn_ele = TYPE_CCE;
break;
case AAC_CHANNEL_LFE:
syn_ele = TYPE_LFE;
break;
}
layout_map[0][0] = syn_ele;
layout_map[0][1] = get_bits(gb, 4);
layout_map[0][2] = type;
layout_map++;
}
}
| 1threat
|
What are the various join types in Spark? : <p>I looked at the docs and it says the following join types are supported: </p>
<blockquote>
<p>Type of join to perform. Default inner. Must be one of: inner, cross,
outer, full, full_outer, left, left_outer, right, right_outer,
left_semi, left_anti.</p>
</blockquote>
<p>I looked at the <a href="https://stackoverflow.com/questions/17946221/sql-join-and-different-types-of-joins">StackOverflow answer</a> on SQL joins and top couple of answers do not mention some of the joins from above e.g. <code>left_semi</code> and <code>left_anti</code>. What do they mean in Spark?</p>
| 0debug
|
how to get random questions picked by machine in C : <p>i am making a program in C where i ask the user 10 questions and i have a list of 20 questions. I want the machine to randomly pick and ask any 10 questions. Can anyone help me how to do that?</p>
| 0debug
|
reading excel sheet with visual basic : I'm writing the code below to read data from excel sheet and display data into a combo box in visual basic >>>
when I click run nothing display
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim MyConnection As New OleDb.OleDbConnection
Dim MyCommand As New OleDb.OleDbCommand
Dim filePath, sql As String
filePath = "C:\Users\Nour\Desktop\projects\grade10\grade10\atlas.xlsx"
sql = "Select continent from [Sheet1]"
MyConnection.ConnectionString = $"Provider= Microsoft.Jet._OLEDB 11.0;data source = {filePath};Extended_Properties=Excel 8.0"
MyConnection.Open()
MyCommand.Connection = MyConnection
MyCommand.CommandText = sql
Dim da As New OleDb.OleDbDataAdapter
da.SelectCommand = MyCommand
Dim dt As New DataTable
da.Fill(dt)
Me.ComboBox1.DataSource = dt
Me.ComboBox1.DisplayMember = dt.Columns(0).ToString
MyConnection.Close()
| 0debug
|
Can I use onbeforeunload only when the site is being redirected to a particular website : <p>I want to use the onbeforeunload only when the site is being redirected to a particular page. How can I do that?</p>
| 0debug
|
Scaffold-DbContext creating model for table without a primary key : <p>I am trying to create DBcontext and corresponding model for a particular table in ASP.NET core MVC application. This table doesn't have any primary key.</p>
<p>I am running following Scaffold-DbContext command-</p>
<pre><code>Scaffold-DbContext "Server=XXXXX;Database=XXXXXXX;User Id=XXXXXXX;password=XXXXXXX" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -t TABLE_NAME -force -verbose
</code></pre>
<p>In Package Manager Console, I can see this verbose output-</p>
<pre><code>...............
...............
Unable to identify the primary key for table 'dbo.TABLE_NAME'.
Unable to generate entity type for table 'dbo.TABLE_NAME'.
</code></pre>
<p>My Environment is - VS2015 update3, .NET core 1.0.0, ASP.NET MVC core application.</p>
<p>Is there anyway to create a model for a table without primary key?</p>
| 0debug
|
How to insert a javascript variable in <a href=""> : <pre><code>I have a javascript variable BASE_URL='http://localhost/BKTHP_WEB_NEW/';
</code></pre>
<p>Now I want to insert it inside a </p>
<pre><code>something like <a href="BASE_URL+\view">
</code></pre>
| 0debug
|
Related with numbers printing : How to print the digits of a number input from a user.suppose I input a number 123 then I want one-two-three to be printed. The language which I am using is c.
| 0debug
|
Android Native Build Issue error while building apk : <p>Hello I Imorted a Github source code of Telegram. But when I am trying to build the apk then I got thwo type of error-
First is - <b>External Native Build Issues</b> which contain below details-</p>
<pre>Build command failed.
Error while executing process C:\Users\The\AppData\Local\Android\Sdk\ndk-bundle\ndk-build.cmd with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=C:\Users\The\Desktop\ProjectXYZ\Appcode1\TMessagesProj\jni\Android.mk NDK_APPLICATION_MK=C:\Users\The\Desktop\ProjectXYZ\Appcode1\TMessagesProj\jni\Application.mk APP_ABI=armeabi-v7a NDK_ALL_ABIS=armeabi-v7a NDK_DEBUG=0 APP_PLATFORM=android-23 NDK_OUT=C:/Users/The/Desktop/ProjectXYZ/Appcode1/TMessagesProj/build/intermediates/ndkBuild/armv7_SDK23/release/obj NDK_LIBS_OUT=C:\Users\The\Desktop\ProjectXYZ\Appcode1\TMessagesProj\build\intermediates\ndkBuild\armv7_SDK23\release\lib NDK_APPLICATION_MK:=jni/Application.mk APP_PLATFORM:=android-14 APP_SHORT_COMMANDS=false LOCAL_SHORT_COMMANDS=false -B -n}
Android NDK: ERROR:C:\Users\The\Desktop\ProjectXYZ\Appcode1\TMessagesProj\jni\Android.mk:WebRtcAec: LOCAL_SRC_FILES points to a missing file
Android NDK: Check that C:/Users/The/Desktop/ProjectXYZ/Appcode1/TMessagesProj/jni/./libtgvoip/external/libWebRtcAec_android_armeabi-v7a.a exists or that its path is correct
process_begin: CreateProcess(NULL, "", ...) failed.</pre>
<p>Second error pointed to toward file- <b>C:\Users\The\AppData\Local\Android\sdk\ndk-bundle\build\core\prebuilt-library.mk</b> which contains this - </p>
<pre>Error:(44, 0) *** Android NDK: Aborting. Stop.
Open File</pre>
<p><strong>Code of prebuilt-library.mk file</strong>- <a href="https://gist.github.com/AmitSinghLive/39ecc66092cc23aa9d30abef3b013dfa" rel="noreferrer">https://gist.github.com/AmitSinghLive/39ecc66092cc23aa9d30abef3b013dfa</a></p>
<p>I am using latest android studio and source can be found from here- <a href="https://github.com/DrKLO/Telegram" rel="noreferrer">https://github.com/DrKLO/Telegram</a></p>
| 0debug
|
static int qemu_rdma_block_for_wrid(RDMAContext *rdma, int wrid_requested,
uint32_t *byte_len)
{
int num_cq_events = 0, ret = 0;
struct ibv_cq *cq;
void *cq_ctx;
uint64_t wr_id = RDMA_WRID_NONE, wr_id_in;
if (ibv_req_notify_cq(rdma->cq, 0)) {
return -1;
}
while (wr_id != wrid_requested) {
ret = qemu_rdma_poll(rdma, &wr_id_in, byte_len);
if (ret < 0) {
return ret;
}
wr_id = wr_id_in & RDMA_WRID_TYPE_MASK;
if (wr_id == RDMA_WRID_NONE) {
break;
}
if (wr_id != wrid_requested) {
DDDPRINTF("A Wanted wrid %s (%d) but got %s (%" PRIu64 ")\n",
print_wrid(wrid_requested),
wrid_requested, print_wrid(wr_id), wr_id);
}
}
if (wr_id == wrid_requested) {
return 0;
}
while (1) {
if (rdma->migration_started_on_destination) {
yield_until_fd_readable(rdma->comp_channel->fd);
}
if (ibv_get_cq_event(rdma->comp_channel, &cq, &cq_ctx)) {
perror("ibv_get_cq_event");
goto err_block_for_wrid;
}
num_cq_events++;
if (ibv_req_notify_cq(cq, 0)) {
goto err_block_for_wrid;
}
while (wr_id != wrid_requested) {
ret = qemu_rdma_poll(rdma, &wr_id_in, byte_len);
if (ret < 0) {
goto err_block_for_wrid;
}
wr_id = wr_id_in & RDMA_WRID_TYPE_MASK;
if (wr_id == RDMA_WRID_NONE) {
break;
}
if (wr_id != wrid_requested) {
DDDPRINTF("B Wanted wrid %s (%d) but got %s (%" PRIu64 ")\n",
print_wrid(wrid_requested), wrid_requested,
print_wrid(wr_id), wr_id);
}
}
if (wr_id == wrid_requested) {
goto success_block_for_wrid;
}
}
success_block_for_wrid:
if (num_cq_events) {
ibv_ack_cq_events(cq, num_cq_events);
}
return 0;
err_block_for_wrid:
if (num_cq_events) {
ibv_ack_cq_events(cq, num_cq_events);
}
return ret;
}
| 1threat
|
How the number of parameters associated with BatchNormalization layer is 2048? : <p>I have the following code.</p>
<pre><code>x = keras.layers.Input(batch_shape = (None, 4096))
hidden = keras.layers.Dense(512, activation = 'relu')(x)
hidden = keras.layers.BatchNormalization()(hidden)
hidden = keras.layers.Dropout(0.5)(hidden)
predictions = keras.layers.Dense(80, activation = 'sigmoid')(hidden)
mlp_model = keras.models.Model(input = [x], output = [predictions])
mlp_model.summary()
</code></pre>
<p>And this is the model summary:</p>
<pre><code>____________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
====================================================================================================
input_3 (InputLayer) (None, 4096) 0
____________________________________________________________________________________________________
dense_1 (Dense) (None, 512) 2097664 input_3[0][0]
____________________________________________________________________________________________________
batchnormalization_1 (BatchNorma (None, 512) 2048 dense_1[0][0]
____________________________________________________________________________________________________
dropout_1 (Dropout) (None, 512) 0 batchnormalization_1[0][0]
____________________________________________________________________________________________________
dense_2 (Dense) (None, 80) 41040 dropout_1[0][0]
====================================================================================================
Total params: 2,140,752
Trainable params: 2,139,728
Non-trainable params: 1,024
____________________________________________________________________________________________________
</code></pre>
<p>The size of the input for the BatchNormalization (BN) layer is 512. According to <a href="https://keras.io/layers/normalization/" rel="noreferrer">Keras documentation</a>, shape of the output for BN layer is same as input which is 512.</p>
<p>Then how the number of parameters associated with BN layer is 2048?</p>
| 0debug
|
static int vhdx_log_flush(BlockDriverState *bs, BDRVVHDXState *s,
VHDXLogSequence *logs)
{
int ret = 0;
int i;
uint32_t cnt, sectors_read;
uint64_t new_file_size;
void *data = NULL;
int64_t file_length;
VHDXLogDescEntries *desc_entries = NULL;
VHDXLogEntryHeader hdr_tmp = { 0 };
cnt = logs->count;
data = qemu_blockalign(bs, VHDX_LOG_SECTOR_SIZE);
ret = vhdx_user_visible_write(bs, s);
if (ret < 0) {
goto exit;
}
while (cnt--) {
ret = vhdx_log_peek_hdr(bs, &logs->log, &hdr_tmp);
if (ret < 0) {
goto exit;
}
file_length = bdrv_getlength(bs->file->bs);
if (file_length < 0) {
ret = file_length;
goto exit;
}
if (hdr_tmp.flushed_file_offset > file_length) {
ret = -EINVAL;
goto exit;
}
ret = vhdx_log_read_desc(bs, s, &logs->log, &desc_entries, true);
if (ret < 0) {
goto exit;
}
for (i = 0; i < desc_entries->hdr.descriptor_count; i++) {
if (desc_entries->desc[i].signature == VHDX_LOG_DESC_SIGNATURE) {
ret = vhdx_log_read_sectors(bs, &logs->log, §ors_read,
data, 1, false);
if (ret < 0) {
goto exit;
}
if (sectors_read != 1) {
ret = -EINVAL;
goto exit;
}
vhdx_log_data_le_import(data);
}
ret = vhdx_log_flush_desc(bs, &desc_entries->desc[i], data);
if (ret < 0) {
goto exit;
}
}
if (file_length < desc_entries->hdr.last_file_offset) {
new_file_size = desc_entries->hdr.last_file_offset;
if (new_file_size % (1024*1024)) {
new_file_size = QEMU_ALIGN_UP(new_file_size, MiB);
if (new_file_size > INT64_MAX) {
ret = -EINVAL;
goto exit;
}
bdrv_truncate(bs->file, new_file_size, PREALLOC_MODE_OFF, NULL);
}
}
qemu_vfree(desc_entries);
desc_entries = NULL;
}
ret = bdrv_flush(bs);
if (ret < 0) {
goto exit;
}
vhdx_log_reset(bs, s);
exit:
qemu_vfree(data);
qemu_vfree(desc_entries);
return ret;
}
| 1threat
|
static void ohci_sof(OHCIState *ohci)
{
ohci->sof_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
timer_mod(ohci->eof_timer, ohci->sof_time + usb_frame_time);
ohci_set_interrupt(ohci, OHCI_INTR_SF);
}
| 1threat
|
static int avi_load_index(AVFormatContext *s)
{
AVIContext *avi = s->priv_data;
ByteIOContext *pb = s->pb;
uint32_t tag, size;
int64_t pos= url_ftell(pb);
url_fseek(pb, avi->movi_end, SEEK_SET);
#ifdef DEBUG_SEEK
printf("movi_end=0x%"PRIx64"\n", avi->movi_end);
#endif
for(;;) {
if (url_feof(pb))
break;
tag = get_le32(pb);
size = get_le32(pb);
#ifdef DEBUG_SEEK
printf("tag=%c%c%c%c size=0x%x\n",
tag & 0xff,
(tag >> 8) & 0xff,
(tag >> 16) & 0xff,
(tag >> 24) & 0xff,
size);
#endif
switch(tag) {
case MKTAG('i', 'd', 'x', '1'):
if (avi_read_idx1(s, size) < 0)
goto skip;
else
goto the_end;
break;
default:
skip:
size += (size & 1);
url_fskip(pb, size);
break;
}
}
the_end:
url_fseek(pb, pos, SEEK_SET);
return 0;
}
| 1threat
|
Random select value on array factory Laravel : <p>I had user migration:</p>
<pre><code>$table->enum('type',['seller','buyer'])->default('seller');
</code></pre>
<p>I want when using ModelFactory how to get random value seller or buyer?</p>
<pre><code>$factory->define(App\User::class, function (Faker\Generator $faker) {
static $password;
return [
'firstName' => $faker->name,
'lastName' => $faker->name,
'username' => $faker->unique()->username,
'email' => $faker->unique()->safeEmail,
'password' => md5('user123'),
'bio' => $faker->sentence(3, true),
'type' => ???,
];
});
</code></pre>
| 0debug
|
Kotlin optional generic parameter : <p>Here is the problem I am trying to resolve, I am trying to use a void type as a generic type:</p>
<pre><code>class Parent {
private abstract class Item<out T>(val data: T)
// This subclass should contain data
private class ItemContent(val data: String): Item<String>(data)
// This subclass doesn't contain data
private class ItemNoContent: Item<Any?>(null)
}
</code></pre>
<p>Some base classes like ItemNoContent doesn't contain meaningful data so I make ItemNoContent extends Item(null). It works but I feel that the use of Any? and null is inappropriate here. Is there a more Kotlin way to solve this optional generic problem? </p>
| 0debug
|
How can i resolve this error?C# : <p>i have a private method is ball.cs class in witch i want to modify a bool type from margins.cs class, but i get the Error An object reference is required for the non-static field, method, or property 'PingPong.Margins.win'.
Can someone help me with this?</p>
<p>this is the ball class code :</p>
<pre><code>namespace PingPong
{
public class Ball
{
private PictureBox ball;
Random rand= new Random();
Player leftSidePlayer, rightSidePlayer;
int xSpeed, ySpeed;
public Ball(PictureBox aBall, Player leftSidePlayer, Player rightSidePlayer)
{
this.ball = aBall;
this.leftSidePlayer = leftSidePlayer;
this.rightSidePlayer = rightSidePlayer;
xSpeed = 1;
ySpeed = 2;
resetBall();
}
internal void processmove()
{
var bottom = Margins.bottomOfWorld - ball.Height;
DoMove();
if(ball.Location.Y >= bottom || ball.Location.Y <= Margins.topOfWorld)
{
ySpeed *= -1;
}
if (ball.Location.X <= Margins.leftOfWorld)
{
Score(leftSidePlayer);
}
else if (ball.Location.X >= Margins.rightOfWorld - ball.Width)
{
Score(rightSidePlayer);
}
if ((leftSidePlayer.paddle.Bounds.IntersectsWith(ball.Bounds)) || (rightSidePlayer.paddle.Bounds.IntersectsWith(ball.Bounds)))
{
xSpeed *= -1;
if ((ySpeed <= 6 && ySpeed >=-6) && (xSpeed <= 5 && xSpeed >=-5) )
{
if(ySpeed < 0)
{
ySpeed -= 1;
}else
{
ySpeed += 1;
}
if (xSpeed < 0)
{
xSpeed -= 1;
}
else
{
xSpeed += 1;
}
}
}
}
private int DoMove()
{
var bottom = Margins.bottomOfWorld - ball.Height;
ball.Location = new Point(ball.Location.X + xSpeed, Math.Max(Margins.topOfWorld, Math.Min(bottom, ball.Location.Y + ySpeed)));
return bottom;
}
private void Score(Player winningPlayer)
{
winningPlayer.scoreNumber++;
if(winningPlayer.scoreNumber == 7)
{
if(winningPlayer == leftSidePlayer )
{
Margins.win = true;
}else if(winningPlayer == rightSidePlayer)
{
Margins.win = false;
}
}
resetBall();
}
private void resetBall()
{
ball.Location = new Point((Margins.leftOfWorld + Margins.rightOfWorld) / 2, (Margins.bottomOfWorld + Margins.topOfWorld) / 2);
do
{
xSpeed = rand.Next(-3, 3);
ySpeed = rand.Next(-3, 3);
} while(Math.Abs(xSpeed) + Math.Abs(ySpeed) <= 3);
}
}
</code></pre>
<p>}</p>
<p>and this is the margins class code :</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PingPong
{
public class Margins
{ //Marimea ferestrei 1000; 600
public const int topOfWorld = 0, bottomOfWorld = 560, leftOfWorld =0, rightOfWorld = 1000;
public bool? win = null;
}
}
</code></pre>
<p>the error i get is in private void score when i use the margins.win = true
and margins.win = false .</p>
| 0debug
|
Notification Badge On Action Item Android : <p>I wana add a notification badge on the cart image placed in action bar and manipulate it programmatically. Any Help?</p>
| 0debug
|
How to use `blur` and `change` the same time : jquery : <p>According to my <code>autosave</code> function (<a href="https://stackoverflow.com/q/46152759/1620626">link here</a>). Which is triggered by something change to the element. In this case <code>blur</code> and <code>change</code> - input text and checkbox.</p>
<p>I want to make the function working on both <code>typing</code> and <code>clicking</code> the box. Because there're both element type in the same line.</p>
<p>I tried <code>$('xxx').on('blur change',function()...</code></p>
<p>But only change is working. Any idea???</p>
| 0debug
|
NoMethodError (undefined method `permit' for #<Array:0x007f51c020bd18> : <p>I am getting this error and using Rails 5.</p>
<blockquote>
<p>NoMethodError (undefined method <code>permit' for #<Array:0x007f51cf4dc948>
app/controllers/traumas_controller.rb:99:in</code>trauma_params'
app/controllers/traumas_controller.rb:25:in `create_multiple'</p>
</blockquote>
<p>Controller params are as below.</p>
<blockquote>
<p>Started POST "/traumas/create_multiple" for 127.0.0.1 at 2016-10-04
20:09:36 +0530 Processing by TraumasController#create_multiple as JS<br>
Parameters: {"utf8"=>"✓", "fields"=>[{"contusions"=>"1", "burns"=>"",
"at_scene"=>"At Scene", "emergency_detail_id"=>"96",
"trauma_region"=>"Head-Back"}], "commit"=>"Submit"}</p>
</blockquote>
<p>I am trying to create record as below in controller:</p>
<pre><code> def create_multiple
trauma_params
params[:fields].each do |values|
u = Trauma.create(values)
end
end
def trauma_params
params.require(:fields).permit(:fields => [])
end
</code></pre>
<p>Please help me to resolve this issue.</p>
<p>Thanks in advance.</p>
<p>Kiran.</p>
| 0debug
|
static int ape_read_header(AVFormatContext * s)
{
AVIOContext *pb = s->pb;
APEContext *ape = s->priv_data;
AVStream *st;
uint32_t tag;
int i;
int total_blocks, final_size = 0;
int64_t pts, file_size;
ape->junklength = avio_tell(pb);
tag = avio_rl32(pb);
if (tag != MKTAG('M', 'A', 'C', ' '))
return -1;
ape->fileversion = avio_rl16(pb);
if (ape->fileversion < APE_MIN_VERSION || ape->fileversion > APE_MAX_VERSION) {
av_log(s, AV_LOG_ERROR, "Unsupported file version - %d.%02d\n",
ape->fileversion / 1000, (ape->fileversion % 1000) / 10);
return -1;
}
if (ape->fileversion >= 3980) {
ape->padding1 = avio_rl16(pb);
ape->descriptorlength = avio_rl32(pb);
ape->headerlength = avio_rl32(pb);
ape->seektablelength = avio_rl32(pb);
ape->wavheaderlength = avio_rl32(pb);
ape->audiodatalength = avio_rl32(pb);
ape->audiodatalength_high = avio_rl32(pb);
ape->wavtaillength = avio_rl32(pb);
avio_read(pb, ape->md5, 16);
if (ape->descriptorlength > 52)
avio_skip(pb, ape->descriptorlength - 52);
ape->compressiontype = avio_rl16(pb);
ape->formatflags = avio_rl16(pb);
ape->blocksperframe = avio_rl32(pb);
ape->finalframeblocks = avio_rl32(pb);
ape->totalframes = avio_rl32(pb);
ape->bps = avio_rl16(pb);
ape->channels = avio_rl16(pb);
ape->samplerate = avio_rl32(pb);
} else {
ape->descriptorlength = 0;
ape->headerlength = 32;
ape->compressiontype = avio_rl16(pb);
ape->formatflags = avio_rl16(pb);
ape->channels = avio_rl16(pb);
ape->samplerate = avio_rl32(pb);
ape->wavheaderlength = avio_rl32(pb);
ape->wavtaillength = avio_rl32(pb);
ape->totalframes = avio_rl32(pb);
ape->finalframeblocks = avio_rl32(pb);
if (ape->formatflags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL) {
avio_skip(pb, 4);
ape->headerlength += 4;
}
if (ape->formatflags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS) {
ape->seektablelength = avio_rl32(pb);
ape->headerlength += 4;
ape->seektablelength *= sizeof(int32_t);
} else
ape->seektablelength = ape->totalframes * sizeof(int32_t);
if (ape->formatflags & MAC_FORMAT_FLAG_8_BIT)
ape->bps = 8;
else if (ape->formatflags & MAC_FORMAT_FLAG_24_BIT)
ape->bps = 24;
else
ape->bps = 16;
if (ape->fileversion >= 3950)
ape->blocksperframe = 73728 * 4;
else if (ape->fileversion >= 3900 || (ape->fileversion >= 3800 && ape->compressiontype >= 4000))
ape->blocksperframe = 73728;
else
ape->blocksperframe = 9216;
if (!(ape->formatflags & MAC_FORMAT_FLAG_CREATE_WAV_HEADER))
avio_skip(pb, ape->wavheaderlength);
}
if(!ape->totalframes){
av_log(s, AV_LOG_ERROR, "No frames in the file!\n");
return AVERROR(EINVAL);
}
if(ape->totalframes > UINT_MAX / sizeof(APEFrame)){
av_log(s, AV_LOG_ERROR, "Too many frames: %"PRIu32"\n",
ape->totalframes);
return -1;
}
if (ape->seektablelength / sizeof(*ape->seektable) < ape->totalframes) {
av_log(s, AV_LOG_ERROR,
"Number of seek entries is less than number of frames: %zu vs. %"PRIu32"\n",
ape->seektablelength / sizeof(*ape->seektable), ape->totalframes);
return AVERROR_INVALIDDATA;
}
ape->frames = av_malloc(ape->totalframes * sizeof(APEFrame));
if(!ape->frames)
return AVERROR(ENOMEM);
ape->firstframe = ape->junklength + ape->descriptorlength + ape->headerlength + ape->seektablelength + ape->wavheaderlength;
if (ape->fileversion < 3810)
ape->firstframe += ape->totalframes;
ape->currentframe = 0;
ape->totalsamples = ape->finalframeblocks;
if (ape->totalframes > 1)
ape->totalsamples += ape->blocksperframe * (ape->totalframes - 1);
if (ape->seektablelength > 0) {
ape->seektable = av_malloc(ape->seektablelength);
if (!ape->seektable)
return AVERROR(ENOMEM);
for (i = 0; i < ape->seektablelength / sizeof(uint32_t) && !pb->eof_reached; i++)
ape->seektable[i] = avio_rl32(pb);
if (ape->fileversion < 3810) {
ape->bittable = av_malloc(ape->totalframes);
if (!ape->bittable)
return AVERROR(ENOMEM);
for (i = 0; i < ape->totalframes && !pb->eof_reached; i++)
ape->bittable[i] = avio_r8(pb);
}
}
ape->frames[0].pos = ape->firstframe;
ape->frames[0].nblocks = ape->blocksperframe;
ape->frames[0].skip = 0;
for (i = 1; i < ape->totalframes; i++) {
ape->frames[i].pos = ape->seektable[i] + ape->junklength;
ape->frames[i].nblocks = ape->blocksperframe;
ape->frames[i - 1].size = ape->frames[i].pos - ape->frames[i - 1].pos;
ape->frames[i].skip = (ape->frames[i].pos - ape->frames[0].pos) & 3;
}
ape->frames[ape->totalframes - 1].nblocks = ape->finalframeblocks;
file_size = avio_size(pb);
if (file_size > 0) {
final_size = file_size - ape->frames[ape->totalframes - 1].pos -
ape->wavtaillength;
final_size -= final_size & 3;
}
if (file_size <= 0 || final_size <= 0)
final_size = ape->finalframeblocks * 8;
ape->frames[ape->totalframes - 1].size = final_size;
for (i = 0; i < ape->totalframes; i++) {
if(ape->frames[i].skip){
ape->frames[i].pos -= ape->frames[i].skip;
ape->frames[i].size += ape->frames[i].skip;
}
ape->frames[i].size = (ape->frames[i].size + 3) & ~3;
}
if (ape->fileversion < 3810) {
for (i = 0; i < ape->totalframes; i++) {
if (i < ape->totalframes - 1 && ape->bittable[i + 1])
ape->frames[i].size += 4;
ape->frames[i].skip <<= 3;
ape->frames[i].skip += ape->bittable[i];
}
}
ape_dumpinfo(s, ape);
av_log(s, AV_LOG_DEBUG, "Decoding file - v%d.%02d, compression level %"PRIu16"\n",
ape->fileversion / 1000, (ape->fileversion % 1000) / 10,
ape->compressiontype);
st = avformat_new_stream(s, NULL);
if (!st)
return -1;
total_blocks = (ape->totalframes == 0) ? 0 : ((ape->totalframes - 1) * ape->blocksperframe) + ape->finalframeblocks;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_APE;
st->codecpar->codec_tag = MKTAG('A', 'P', 'E', ' ');
st->codecpar->channels = ape->channels;
st->codecpar->sample_rate = ape->samplerate;
st->codecpar->bits_per_coded_sample = ape->bps;
st->nb_frames = ape->totalframes;
st->start_time = 0;
st->duration = total_blocks / MAC_SUBFRAME_SIZE;
avpriv_set_pts_info(st, 64, MAC_SUBFRAME_SIZE, ape->samplerate);
st->codecpar->extradata = av_malloc(APE_EXTRADATA_SIZE);
st->codecpar->extradata_size = APE_EXTRADATA_SIZE;
AV_WL16(st->codecpar->extradata + 0, ape->fileversion);
AV_WL16(st->codecpar->extradata + 2, ape->compressiontype);
AV_WL16(st->codecpar->extradata + 4, ape->formatflags);
pts = 0;
for (i = 0; i < ape->totalframes; i++) {
ape->frames[i].pts = pts;
av_add_index_entry(st, ape->frames[i].pos, ape->frames[i].pts, 0, 0, AVINDEX_KEYFRAME);
pts += ape->blocksperframe / MAC_SUBFRAME_SIZE;
}
if (pb->seekable) {
ff_ape_parse_tag(s);
avio_seek(pb, 0, SEEK_SET);
}
return 0;
}
| 1threat
|
How to reveal hidden paragraph with each click in jQuery? : <p>I have a 5 paragraphs that i want to reveal one by one with each click. I think that they must be hidden (
<code>visibility: hidden</code>) and reveals one by one with jQuery .show().</p>
| 0debug
|
Automatic cell execution timing in jupyter lab : <p>In jupyter <strong>notebook</strong>, I can configure an automatic cell timing with <a href="https://github.com/ipython-contrib/jupyter_contrib_nbextensions" rel="noreferrer">nbextensions</a>, the result is like so:</p>
<p><img src="https://i.ibb.co/n78VmMs/Screenshot-1.png" alt="jupyter_notebook"></p>
<p>How can i do this in jupyter <strong>lab</strong>? I didn't found any extensions that did a similar thing.</p>
<p>Obs.: I know that a similar result can be achieved with <code>%%time</code> magic, but i want it to be automatic, so I don't have to place the magic function at the begining of each cell</p>
| 0debug
|
Installing pycurl with 'fatal error: gnutls/gnutls.h: No such file or directory' : <p>I use ubuntu 16.04 and python 2.7.12.</p>
<p>When I try to install pycurl with pip, I could see below log.</p>
<pre><code>aaa@bbb:~/git/ccc$ sudo pip install pycurl
Downloading pycurl-7.43.0.tar.gz (182kB)
100% |████████████████████████████████| 184kB 515kB/s
Installing collected packages: pycurl
Running setup.py install for pycurl ... error
...
In file included from src/docstrings.c:4:0:
src/pycurl.h:173:30: fatal error: gnutls/gnutls.h: No such file or directory
compilation terminated.
</code></pre>
<p>How to install pycurl with above log?</p>
| 0debug
|
How to insert to a database with foreach? : <p>Hi a have a small problem. I can't insert into db array... this is my code</p>
<pre><code>$qurum1 = implode('|',$_POST['qurum1']);
$qurum = explode('|', $qurum1);
foreach ($qurum as $value) {
$query2 = "INSERT INTO test (data_id, col2) VALUES ('$id', '$value')";
}
</code></pre>
<p>This code inserts only last value</p>
| 0debug
|
Buttons not changing : <pre><code> long totalMilliSeconds = System.currentTimeMillis();
long totalSeconds = totalMilliSeconds / 1000;
long currentSecond = totalSeconds % 60;
long totalMinutes = totalSeconds / 60;
long currentMinute = totalMinutes % 60;
long totalHours = totalMinutes / 60;
long currentHour = totalHours % 24;
System.out.println("Current time is:" + currentHour + ":" + currentMinute + ":" + currentSecond);
if(currentHour <= 9 && currentHour >=18)
readFile.setForeground(YELLOW);
readFile.setBackground(BLACK);
graph.setForeground(YELLOW);
graph.setBackground(BLACK);
search.setForeground(YELLOW);
search.setBackground(BLACK);
snippet.setForeground(YELLOW);
snippet.setBackground(BLACK);
prediction.setForeground(YELLOW);
prediction.setBackground(BLACK);
export.setForeground(YELLOW);
export.setBackground(BLACK);
back.setForeground(YELLOW);
back.setBackground(BLACK);
</code></pre>
<p>The program is supposed to change the colours of buttons from 6pm up until 9am but im not sure why its still changing before the set time. Any ideas would be appreciated.</p>
| 0debug
|
static void pci_update_mappings(PCIDevice *d)
{
PCIIORegion *r;
int cmd, i;
uint32_t last_addr, new_addr, config_ofs;
cmd = le16_to_cpu(*(uint16_t *)(d->config + PCI_COMMAND));
for(i = 0; i < PCI_NUM_REGIONS; i++) {
r = &d->io_regions[i];
if (i == PCI_ROM_SLOT) {
config_ofs = 0x30;
} else {
config_ofs = 0x10 + i * 4;
}
if (r->size != 0) {
if (r->type & PCI_ADDRESS_SPACE_IO) {
if (cmd & PCI_COMMAND_IO) {
new_addr = le32_to_cpu(*(uint32_t *)(d->config +
config_ofs));
new_addr = new_addr & ~(r->size - 1);
last_addr = new_addr + r->size - 1;
if (last_addr <= new_addr || new_addr == 0 ||
last_addr >= 0x10000) {
new_addr = -1;
}
} else {
new_addr = -1;
}
} else {
if (cmd & PCI_COMMAND_MEMORY) {
new_addr = le32_to_cpu(*(uint32_t *)(d->config +
config_ofs));
if (i == PCI_ROM_SLOT && !(new_addr & 1))
goto no_mem_map;
new_addr = new_addr & ~(r->size - 1);
last_addr = new_addr + r->size - 1;
if (last_addr <= new_addr || new_addr == 0 ||
last_addr == -1) {
new_addr = -1;
}
} else {
no_mem_map:
new_addr = -1;
}
}
if (new_addr != r->addr) {
if (r->addr != -1) {
if (r->type & PCI_ADDRESS_SPACE_IO) {
int class;
class = d->config[0x0a] | (d->config[0x0b] << 8);
if (class == 0x0101 && r->size == 4) {
isa_unassign_ioport(r->addr + 2, 1);
} else {
isa_unassign_ioport(r->addr, r->size);
}
} else {
cpu_register_physical_memory(pci_to_cpu_addr(r->addr),
r->size,
IO_MEM_UNASSIGNED);
}
}
r->addr = new_addr;
if (r->addr != -1) {
r->map_func(d, i, r->addr, r->size, r->type);
}
}
}
}
}
| 1threat
|
Kotlin Remove all non alphanumeric characters : <p>I am trying to remove all non alphanumeric characters from a string.</p>
<p>I tried using <code>replace()</code> with a regex as followed:</p>
<pre><code>var answer = answerEditText.text.toString()
Log.d("debug", answer)
answer = answer.replace("[^A-Za-z0-9 ]", "").toLowerCase()
Log.d("debug", answer)
</code></pre>
<blockquote>
<p>D/debug: Test. ,replace</p>
<p>D/debug: test. ,replace</p>
</blockquote>
<p>Why are the punctuation characters still present? How to get only the alphanumeric characters?</p>
| 0debug
|
Nodejs write file progress bar in html : <p>I am trying to generate a file in nodejs and I want to show writing file progress bar in the client-side HTML page. because I am writing a 5 lakh data into a file. once files generates complete in nodejs, it should notify users on the client side.</p>
| 0debug
|
static int rscc_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
RsccContext *ctx = avctx->priv_data;
GetByteContext *gbc = &ctx->gbc;
GetByteContext tiles_gbc;
AVFrame *frame = data;
const uint8_t *pixels, *raw;
uint8_t *inflated_tiles = NULL;
int tiles_nb, packed_size, pixel_size = 0;
int i, ret = 0;
bytestream2_init(gbc, avpkt->data, avpkt->size);
if (bytestream2_get_bytes_left(gbc) < 12) {
av_log(avctx, AV_LOG_ERROR, "Packet too small (%d)\n", avpkt->size);
return AVERROR_INVALIDDATA;
tiles_nb = bytestream2_get_le16(gbc);
av_fast_malloc(&ctx->tiles, &ctx->tiles_size,
tiles_nb * sizeof(*ctx->tiles));
if (!ctx->tiles) {
ret = AVERROR(ENOMEM);
av_log(avctx, AV_LOG_DEBUG, "Frame with %d tiles.\n", tiles_nb);
if (tiles_nb > 5) {
uLongf packed_tiles_size;
if (tiles_nb < 32)
packed_tiles_size = bytestream2_get_byte(gbc);
else
packed_tiles_size = bytestream2_get_le16(gbc);
ff_dlog(avctx, "packed tiles of size %lu.\n", packed_tiles_size);
if (packed_tiles_size != tiles_nb * TILE_SIZE) {
uLongf length = tiles_nb * TILE_SIZE;
inflated_tiles = av_malloc(length);
if (!inflated_tiles) {
ret = AVERROR(ENOMEM);
ret = uncompress(inflated_tiles, &length,
gbc->buffer, packed_tiles_size);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "Tile deflate error %d.\n", ret);
ret = AVERROR_UNKNOWN;
bytestream2_skip(gbc, packed_tiles_size);
bytestream2_init(&tiles_gbc, inflated_tiles, length);
gbc = &tiles_gbc;
for (i = 0; i < tiles_nb; i++) {
ctx->tiles[i].x = bytestream2_get_le16(gbc);
ctx->tiles[i].w = bytestream2_get_le16(gbc);
ctx->tiles[i].y = bytestream2_get_le16(gbc);
ctx->tiles[i].h = bytestream2_get_le16(gbc);
pixel_size += ctx->tiles[i].w * ctx->tiles[i].h * ctx->component_size;
ff_dlog(avctx, "tile %d orig(%d,%d) %dx%d.\n", i,
ctx->tiles[i].x, ctx->tiles[i].y,
ctx->tiles[i].w, ctx->tiles[i].h);
if (ctx->tiles[i].w == 0 || ctx->tiles[i].h == 0) {
av_log(avctx, AV_LOG_ERROR,
"invalid tile %d at (%d.%d) with size %dx%d.\n", i,
ctx->tiles[i].x, ctx->tiles[i].y,
ctx->tiles[i].w, ctx->tiles[i].h);
} else if (ctx->tiles[i].x + ctx->tiles[i].w > avctx->width ||
ctx->tiles[i].y + ctx->tiles[i].h > avctx->height) {
av_log(avctx, AV_LOG_ERROR,
"out of bounds tile %d at (%d.%d) with size %dx%d.\n", i,
ctx->tiles[i].x, ctx->tiles[i].y,
ctx->tiles[i].w, ctx->tiles[i].h);
gbc = &ctx->gbc;
if (pixel_size < 0x100)
packed_size = bytestream2_get_byte(gbc);
else if (pixel_size < 0x10000)
packed_size = bytestream2_get_le16(gbc);
else if (pixel_size < 0x1000000)
packed_size = bytestream2_get_le24(gbc);
else
packed_size = bytestream2_get_le32(gbc);
ff_dlog(avctx, "pixel_size %d packed_size %d.\n", pixel_size, packed_size);
if (packed_size < 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid tile size %d\n", packed_size);
if (pixel_size == packed_size) {
if (bytestream2_get_bytes_left(gbc) < pixel_size) {
av_log(avctx, AV_LOG_ERROR, "Insufficient input for %d\n", pixel_size);
pixels = gbc->buffer;
} else {
uLongf len = ctx->inflated_size;
ret = uncompress(ctx->inflated_buf, &len, gbc->buffer, packed_size);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "Pixel deflate error %d.\n", ret);
ret = AVERROR_UNKNOWN;
pixels = ctx->inflated_buf;
ret = ff_reget_buffer(avctx, ctx->reference);
if (ret < 0)
raw = pixels;
for (i = 0; i < tiles_nb; i++) {
uint8_t *dst = ctx->reference->data[0] + ctx->reference->linesize[0] *
(avctx->height - ctx->tiles[i].y - 1) +
ctx->tiles[i].x * ctx->component_size;
av_image_copy_plane(dst, -1 * ctx->reference->linesize[0],
raw, ctx->tiles[i].w * ctx->component_size,
ctx->tiles[i].w * ctx->component_size,
ctx->tiles[i].h);
raw += ctx->tiles[i].w * ctx->component_size * ctx->tiles[i].h;
ret = av_frame_ref(frame, ctx->reference);
if (ret < 0)
if (pixel_size == ctx->inflated_size) {
frame->pict_type = AV_PICTURE_TYPE_I;
frame->key_frame = 1;
} else {
frame->pict_type = AV_PICTURE_TYPE_P;
*got_frame = 1;
end:
av_free(inflated_tiles);
return ret;
| 1threat
|
static VideoState *stream_open(const char *filename, AVInputFormat *iformat)
{
VideoState *is;
is = av_mallocz(sizeof(VideoState));
if (!is)
return NULL;
av_strlcpy(is->filename, filename, sizeof(is->filename));
is->iformat = iformat;
is->ytop = 0;
is->xleft = 0;
is->pictq_mutex = SDL_CreateMutex();
is->pictq_cond = SDL_CreateCond();
is->subpq_mutex = SDL_CreateMutex();
is->subpq_cond = SDL_CreateCond();
packet_queue_init(&is->videoq);
packet_queue_init(&is->audioq);
packet_queue_init(&is->subtitleq);
is->continue_read_thread = SDL_CreateCond();
update_external_clock_pts(is, (double)AV_NOPTS_VALUE);
update_external_clock_speed(is, 1.0);
is->audio_current_pts_drift = -av_gettime() / 1000000.0;
is->video_current_pts_drift = is->audio_current_pts_drift;
is->audio_clock_serial = -1;
is->video_clock_serial = -1;
is->av_sync_type = av_sync_type;
is->read_tid = SDL_CreateThread(read_thread, is);
if (!is->read_tid) {
av_free(is);
return NULL;
}
return is;
}
| 1threat
|
What is the reverse of "kubectl apply"? : <p>I was playing around in minikube and installed the wrong version of istio. I ran:</p>
<pre><code>kubectl apply -f install/kubernetes/istio-demo-auth.yaml
</code></pre>
<p>instead of:</p>
<pre><code>kubectl apply -f install/kubernetes/istio-demo.yaml
</code></pre>
<p>I figured I would just undo it and install the right one.</p>
<p>But I cannot seem to find an <code>unapply</code> command.</p>
<p><strong>How do I <em>undo</em> a "kubectl apply" command?</strong></p>
| 0debug
|
float64 HELPER(ucf64_muld)(float64 a, float64 b, CPUUniCore32State *env)
{
return float64_mul(a, b, &env->ucf64.fp_status);
}
| 1threat
|
{JAVA} Need help getting percent of a number : Basically in this website you can get credits and buy stuff with them. If you keep the credits in your bank, you get 0.12% added daily.
[Picture to understand this.][1]
I wanted to code a quick program to calculate this but I need help, here's my code.
import java.util.Scanner;
public class project {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("-------------------------");
System.out.println("| NextGenUpdate Credits |");
System.out.println("-------------------------");
System.out.println("Credits: ");
double credits = input.nextDouble();
System.out.println("Days: ");
int days = input.nextInt();
int total = //DON'T KNOW WHAT TO PUT HERE
System.out.println("You will have have " + total + " credits in " + days + " days.");
}
}
[1]: http://i.stack.imgur.com/0NFEJ.png
| 0debug
|
MS SQL 2014 help Creating Tables : I am new to mssql and my prof listed these steps to make a table help.
1. Create and populate (Insert Values) the following tables per Table Description and Data Values provided
• DEPARTMENT
• EMPLOYEE
• PROJECT
• ASSIGNMENT
2. Add a SQL Comment to include /* *** Your First Name_Your Last Name*** */ when inserting corresponding values for each table.
[table 1][1]
[table 2][2]
[1]: http://i.stack.imgur.com/mxXcw.png
[2]: http://i.stack.imgur.com/99kOW.png
| 0debug
|
Using PERL extract data between two symbols (: and ;) line by line from a log file : I have to extract data between two symbols (: and ;) line by line from a log file. My data is:
INFO @3035155 mti_lane1_bw_mon: total bytes = 0, at time = 3035155; T=3035155
I'm using this code to extract data after colon(:)
use strict;
use warnings;
my $filename = 'log1';
my @fields;
open(FILE, $filename) or die "Could not read from $filename, program halting.";
while(<FILE>)
{
chomp;
@fields = split(':', $_);
print "$fields[1]\n";
}
close FILE;
Current Output :
total bytes = 0, at time = 3035155; T=3035155
Required Output
total bytes = 0, at time = 3035155
| 0debug
|
How to specify Lumen (or Laravel) version on new installation? : <p>I want to install a specific version of Laravel Lumen (5.1 instead of the lastest one 5.2) on a new project.</p>
<p>From the documentation :</p>
<pre><code>lumen new blog
</code></pre>
<p>or : </p>
<pre><code>composer create-project laravel/lumen --prefer-dist
</code></pre>
<p>Does not work : it install the lastest one.</p>
| 0debug
|
How do I insert PHP variables in a MySQL table? : <p>I have the following code that should create a table and populate it with two users. The create table query works, but the insert does not. Any help would be appreciated.</p>
<pre><code> <?php
require_once 'login12.php';
$link = mysqli_connect($db_hostname, $db_username, $db_password);
if (!$link) die ("Unable to connect to MySQL: " .mysqli_error());
mysqli_select_db($link, $db_database) or die("Unable to select database: " .mysqli_error());
$query = "CREATE TABLE `users` (
forename VARCHAR(32) NOT NULL,
surname VARCHAR(32) NOT NULL,
username VARCHAR(32) NOT NULL UNIQUE,
password VARCHAR(32) NOT NULL)";
$result = mysqli_query($link, $query);
if (!$result) die ("Database access failed: " .mysqli_error());
$salt1 = 'G3tD0wnonIT!';
$salt2 = 'Y0uwant2';
$forename = 'Bill';
$surname = 'Smith';
$username = 'bsmith';
$password = 'mysecret';
$token = sha1("$salt2$password$salt1");
add_user($forename, $surname, $username, $token);
$forename = 'Pauline';
$surname = 'Jones';
$username = 'pjones';
$password = 'acrobat';
$token = sha1("$salt2$password$salt1");
add_user($forename, $surname, $username, $token);
function add_user($fn, $sn, $un, $pw) {
$query = "INSERT INTO `users` (`forename`, `surname`, `username`, `password`) VALUES ('$fn', '$sn', '$un', '$pw')";
$result = mysqli_query($link, $query);
if (!$result) die ("Database access failed: " .mysqli_error());
}
?>
</code></pre>
| 0debug
|
sql dividing numbers by different group by results : Basically I have a table with several columns but I'm only interested in 4. My table looks like that:
colA colB, colC, **date**, colE, **country**, colF, **city**, colH, **quantity**.
What I want to achieve is to get 5 columns like this:
[results][1]
So far my script looks like this:
select country, city, sum(quantity)
from table
where date > dateadd(month,-1,getdate())
group by country, city
order by country, city
The where condition is because I only want the last month of data so consider it irrelevant.
How can I achieve what I want with a simple script?
[1]: https://i.stack.imgur.com/bpkc7.png
| 0debug
|
Laravel JWT Auth get user on Login : <p>Is it possible with <a href="https://github.com/tymondesigns/jwt-auth" rel="noreferrer">https://github.com/tymondesigns/jwt-auth</a>
to get the <code>current user</code>? Because right now I can only generate a token (when a user sign in). </p>
<pre><code>public function login(Request $request)
{
$credentials = $request->only('email', 'password');
try {
if (! $token = JWTAuth::attempt($credentials)) {
return response()->json(['error' => 'invalid_credentials'], 401);
}
} catch (Tymon\JWTAuth\Exceptions\JWTException $e) {
return response()->json(['error' => 'could_not_create_token'], 500);
}
return response()->json(compact('token'));
}
</code></pre>
| 0debug
|
What is hooks in codigniter? : <p>I want to know about hooks.Is is class or package or function or other?</p>
<blockquote>
<blockquote>
<p>Hooks is a concept?</p>
</blockquote>
</blockquote>
| 0debug
|
Haskell Stack Ghci test-suite : <p>I'm trying to use stack to load my test-suite in ghci and have it load the QuickCheck and hspec dependency.</p>
<p>How can I do this?</p>
<p>I'm using the franklinchen template. <br />
<a href="https://github.com/commercialhaskell/stack-templates/blob/master/franklinchen.hsfiles">https://github.com/commercialhaskell/stack-templates/blob/master/franklinchen.hsfiles</a></p>
<p>I have tried <br />
stack ghci spec <br />
stack ghci test-suite <br />
stack ghci --main-is spec <br /></p>
<p>I modified the test-suite spec to target the main-is: LibSpec.hs file</p>
<pre><code>test-suite spec
default-language: Haskell2010
ghc-options: -Wall
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: LibSpec.hs
build-depends: base
, chapterexercises
, hspec
, QuickCheck
</code></pre>
| 0debug
|
SCSIRequest *scsi_req_alloc(size_t size, SCSIDevice *d, uint32_t tag, uint32_t lun)
{
SCSIRequest *req;
req = qemu_mallocz(size);
req->refcount = 2;
req->bus = scsi_bus_from_device(d);
req->dev = d;
req->tag = tag;
req->lun = lun;
req->status = -1;
req->enqueued = true;
trace_scsi_req_alloc(req->dev->id, req->lun, req->tag);
QTAILQ_INSERT_TAIL(&d->requests, req, next);
return req;
}
| 1threat
|
Find if AWS instance is running Amazon Linux 1 or 2? : <p>In AWS I need to add amazon linux instance to domain based on this <a href="https://docs.aws.amazon.com/directoryservice/latest/admin-guide/join_linux_instance.html" rel="noreferrer">article</a>.
However how do i know which Amazon Linux version the instance is using.
I do not have access to AWS console. But i do have access to actual instance.
What linux command i should be using.</p>
<p>I use <code>uname -srm</code> command which returns <code>Linux 4.4.0-1057-aws x86_64</code></p>
<p>Not sure if this is Amazon Linux 1 or Amazon Linux 2</p>
| 0debug
|
How do I check if a string contains no characters? : <p>I know this is a similar post to <a href="https://stackoverflow.com/questions/2405292/how-to-check-if-text-is-empty-spaces-tabs-newlines-in-python">How to check if text is "empty" (spaces, tabs, newlines) in Python?</a>
, however I'm still having troubles.</p>
<p>I don't understand how to use it, I'm trying to check if a variable, which contains a string, consists of only spaces, tabs and newlines. How would I use issppace() as I'm confused with it always being False?.</p>
<p>Help would be much appreciated.</p>
| 0debug
|
static void test2_fill_picture(AVFilterContext *ctx, AVFrame *frame)
{
TestSourceContext *s = ctx->priv;
FFDrawColor color;
unsigned alpha = (uint32_t)s->alpha << 24;
{
unsigned i, x = 0, x2;
x = 0;
for (i = 1; i < 7; i++) {
x2 = av_rescale(i, s->w, 6);
x2 = ff_draw_round_to_sub(&s->draw, 0, 0, x2);
set_color(s, &color, ((i & 1) ? 0xFF0000 : 0) |
((i & 2) ? 0x00FF00 : 0) |
((i & 4) ? 0x0000FF : 0) |
alpha);
ff_fill_rectangle(&s->draw, &color, frame->data, frame->linesize,
x, 0, x2 - x, frame->height);
x = x2;
}
}
if (s->h >= 64) {
unsigned x, dx, y0, y, g0, g;
dx = ff_draw_round_to_sub(&s->draw, 0, +1, 1);
y0 = av_rescale_q(s->pts, s->time_base, av_make_q(2, s->h - 16));
g0 = av_rescale_q(s->pts, s->time_base, av_make_q(1, 128));
for (x = 0; x < s->w; x += dx) {
g = (av_rescale(x, 6 * 256, s->w) + g0) % (6 * 256);
set_color(s, &color, color_gradient(g) | alpha);
y = y0 + av_rescale(x, s->h / 2, s->w);
y %= 2 * (s->h - 16);
if (y > s->h - 16)
y = 2 * (s->h - 16) - y;
y = ff_draw_round_to_sub(&s->draw, 1, 0, y);
ff_fill_rectangle(&s->draw, &color, frame->data, frame->linesize,
x, y, dx, 16);
}
}
if (s->w >= 64 && s->h >= 64) {
int l = (FFMIN(s->w, s->h) - 32) >> 1;
int steps = FFMAX(4, l >> 5);
int xc = (s->w >> 2) + (s->w >> 1);
int yc = (s->h >> 2);
int cycle = l << 2;
int pos, xh, yh;
int c, i;
for (c = 0; c < 3; c++) {
set_color(s, &color, (0xBBBBBB ^ (0xFF << (c << 3))) | alpha);
pos = av_rescale_q(s->pts, s->time_base, av_make_q(64 >> (c << 1), cycle)) % cycle;
xh = pos < 1 * l ? pos :
pos < 2 * l ? l :
pos < 3 * l ? 3 * l - pos : 0;
yh = pos < 1 * l ? 0 :
pos < 2 * l ? pos - l :
pos < 3 * l ? l :
cycle - pos;
xh -= l >> 1;
yh -= l >> 1;
for (i = 1; i <= steps; i++) {
int x = av_rescale(xh, i, steps) + xc;
int y = av_rescale(yh, i, steps) + yc;
x = ff_draw_round_to_sub(&s->draw, 0, -1, x);
y = ff_draw_round_to_sub(&s->draw, 1, -1, y);
ff_fill_rectangle(&s->draw, &color, frame->data, frame->linesize,
x, y, 8, 8);
}
}
}
if (s->w >= 64 && s->h >= 64) {
int l = (FFMIN(s->w, s->h) - 16) >> 2;
int cycle = l << 3;
int xc = (s->w >> 2);
int yc = (s->h >> 2) + (s->h >> 1);
int xm1 = ff_draw_round_to_sub(&s->draw, 0, -1, xc - 8);
int xm2 = ff_draw_round_to_sub(&s->draw, 0, +1, xc + 8);
int ym1 = ff_draw_round_to_sub(&s->draw, 1, -1, yc - 8);
int ym2 = ff_draw_round_to_sub(&s->draw, 1, +1, yc + 8);
int size, step, x1, x2, y1, y2;
size = av_rescale_q(s->pts, s->time_base, av_make_q(4, cycle));
step = size / l;
size %= l;
if (step & 1)
size = l - size;
step = (step >> 1) & 3;
set_color(s, &color, 0xFF808080);
x1 = ff_draw_round_to_sub(&s->draw, 0, -1, xc - 4 - size);
x2 = ff_draw_round_to_sub(&s->draw, 0, +1, xc + 4 + size);
y1 = ff_draw_round_to_sub(&s->draw, 1, -1, yc - 4 - size);
y2 = ff_draw_round_to_sub(&s->draw, 1, +1, yc + 4 + size);
if (step == 0 || step == 2)
ff_fill_rectangle(&s->draw, &color, frame->data, frame->linesize,
x1, ym1, x2 - x1, ym2 - ym1);
if (step == 1 || step == 2)
ff_fill_rectangle(&s->draw, &color, frame->data, frame->linesize,
xm1, y1, xm2 - xm1, y2 - y1);
if (step == 3)
ff_fill_rectangle(&s->draw, &color, frame->data, frame->linesize,
x1, y1, x2 - x1, y2 - y1);
}
{
unsigned xmin = av_rescale(5, s->w, 8);
unsigned xmax = av_rescale(7, s->w, 8);
unsigned ymin = av_rescale(5, s->h, 8);
unsigned ymax = av_rescale(7, s->h, 8);
unsigned x, y, i, r;
uint8_t alpha[256];
r = s->pts;
for (y = ymin; y < ymax - 15; y += 16) {
for (x = xmin; x < xmax - 15; x += 16) {
if ((x ^ y) & 16)
continue;
for (i = 0; i < 256; i++) {
r = r * 1664525 + 1013904223;
alpha[i] = r >> 24;
}
set_color(s, &color, 0xFF00FF80);
ff_blend_mask(&s->draw, &color, frame->data, frame->linesize,
frame->width, frame->height,
alpha, 16, 16, 16, 3, 0, x, y);
}
}
}
if (s->w >= 16 && s->h >= 16) {
unsigned w = s->w - 8;
unsigned h = s->h - 8;
unsigned x = av_rescale_q(s->pts, s->time_base, av_make_q(233, 55 * w)) % (w << 1);
unsigned y = av_rescale_q(s->pts, s->time_base, av_make_q(233, 89 * h)) % (h << 1);
if (x > w)
x = (w << 1) - x;
if (y > h)
y = (h << 1) - y;
x = ff_draw_round_to_sub(&s->draw, 0, -1, x);
y = ff_draw_round_to_sub(&s->draw, 1, -1, y);
set_color(s, &color, 0xFF8000FF);
ff_fill_rectangle(&s->draw, &color, frame->data, frame->linesize,
x, y, 8, 8);
}
{
char buf[256];
unsigned time;
time = av_rescale_q(s->pts, s->time_base, av_make_q(1, 1000)) % 86400000;
set_color(s, &color, 0xC0000000);
ff_blend_rectangle(&s->draw, &color, frame->data, frame->linesize,
frame->width, frame->height,
2, 2, 100, 36);
set_color(s, &color, 0xFFFF8000);
snprintf(buf, sizeof(buf), "%02d:%02d:%02d.%03d\n%12"PRIi64,
time / 3600000, (time / 60000) % 60, (time / 1000) % 60,
time % 1000, s->pts);
draw_text(s, frame, &color, 4, 4, buf);
}
}
| 1threat
|
e1000_receive(void *opaque, const uint8_t *buf, size_t size)
{
E1000State *s = opaque;
struct e1000_rx_desc desc;
target_phys_addr_t base;
unsigned int n, rdt;
uint32_t rdh_start;
uint16_t vlan_special = 0;
uint8_t vlan_status = 0, vlan_offset = 0;
if (!(s->mac_reg[RCTL] & E1000_RCTL_EN))
return;
if (size > s->rxbuf_size) {
DBGOUT(RX, "packet too large for buffers (%lu > %d)\n",
(unsigned long)size, s->rxbuf_size);
return;
}
if (!receive_filter(s, buf, size))
return;
if (vlan_enabled(s) && is_vlan_packet(s, buf)) {
vlan_special = cpu_to_le16(be16_to_cpup((uint16_t *)(buf + 14)));
memmove((void *)(buf + 4), buf, 12);
vlan_status = E1000_RXD_STAT_VP;
vlan_offset = 4;
size -= 4;
}
rdh_start = s->mac_reg[RDH];
size += 4;
do {
if (s->mac_reg[RDH] == s->mac_reg[RDT] && s->check_rxov) {
set_ics(s, 0, E1000_ICS_RXO);
return;
}
base = ((uint64_t)s->mac_reg[RDBAH] << 32) + s->mac_reg[RDBAL] +
sizeof(desc) * s->mac_reg[RDH];
cpu_physical_memory_read(base, (void *)&desc, sizeof(desc));
desc.special = vlan_special;
desc.status |= (vlan_status | E1000_RXD_STAT_DD);
if (desc.buffer_addr) {
cpu_physical_memory_write(le64_to_cpu(desc.buffer_addr),
(void *)(buf + vlan_offset), size);
desc.length = cpu_to_le16(size);
desc.status |= E1000_RXD_STAT_EOP|E1000_RXD_STAT_IXSM;
} else
DBGOUT(RX, "Null RX descriptor!!\n");
cpu_physical_memory_write(base, (void *)&desc, sizeof(desc));
if (++s->mac_reg[RDH] * sizeof(desc) >= s->mac_reg[RDLEN])
s->mac_reg[RDH] = 0;
s->check_rxov = 1;
if (s->mac_reg[RDH] == rdh_start) {
DBGOUT(RXERR, "RDH wraparound @%x, RDT %x, RDLEN %x\n",
rdh_start, s->mac_reg[RDT], s->mac_reg[RDLEN]);
set_ics(s, 0, E1000_ICS_RXO);
return;
}
} while (desc.buffer_addr == 0);
s->mac_reg[GPRC]++;
s->mac_reg[TPR]++;
n = s->mac_reg[TORL];
if ((s->mac_reg[TORL] += size) < n)
s->mac_reg[TORH]++;
n = E1000_ICS_RXT0;
if ((rdt = s->mac_reg[RDT]) < s->mac_reg[RDH])
rdt += s->mac_reg[RDLEN] / sizeof(desc);
if (((rdt - s->mac_reg[RDH]) * sizeof(desc)) <= s->mac_reg[RDLEN] >>
s->rxbuf_min_shift)
n |= E1000_ICS_RXDMT0;
set_ics(s, 0, n);
}
| 1threat
|
static void qtrle_decode_8bpp(QtrleContext *s, int stream_ptr, int row_ptr, int lines_to_change)
{
int rle_code;
int pixel_ptr;
int row_inc = s->frame.linesize[0];
unsigned char pi1, pi2, pi3, pi4;
unsigned char *rgb = s->frame.data[0];
int pixel_limit = s->frame.linesize[0] * s->avctx->height;
while (lines_to_change--) {
CHECK_STREAM_PTR(2);
pixel_ptr = row_ptr + (4 * (s->buf[stream_ptr++] - 1));
while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) {
if (rle_code == 0) {
CHECK_STREAM_PTR(1);
pixel_ptr += (4 * (s->buf[stream_ptr++] - 1));
} else if (rle_code < 0) {
rle_code = -rle_code;
CHECK_STREAM_PTR(4);
pi1 = s->buf[stream_ptr++];
pi2 = s->buf[stream_ptr++];
pi3 = s->buf[stream_ptr++];
pi4 = s->buf[stream_ptr++];
CHECK_PIXEL_PTR(rle_code * 4);
while (rle_code--) {
rgb[pixel_ptr++] = pi1;
rgb[pixel_ptr++] = pi2;
rgb[pixel_ptr++] = pi3;
rgb[pixel_ptr++] = pi4;
}
} else {
rle_code *= 4;
CHECK_STREAM_PTR(rle_code);
CHECK_PIXEL_PTR(rle_code);
while (rle_code--) {
rgb[pixel_ptr++] = s->buf[stream_ptr++];
}
}
}
row_ptr += row_inc;
}
}
| 1threat
|
swap string a in place to string b in C++ : <p>swap string a in reverse to b.
swap string a in place to string b in C++</p>
<p>// 1e9+5</p>
<pre><code>#include <iostream>
#include <string>
using namespace std;
int main ()
{
string a="Hello,Sir";
string b="";
int k=5;
int last=k;
for (int i=0;i<k;i++)
b[i]=a[last--];
cout << b;
return 0;
}
</code></pre>
| 0debug
|
static void bonito_ldma_writel(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
PCIBonitoState *s = opaque;
((uint32_t *)(&s->bonldma))[addr/sizeof(uint32_t)] = val & 0xffffffff;
}
| 1threat
|
The operator * is undefined for the argument type(s) double : I'm working through an old MIT course trying to learn java in my spare time. This early assignment is about calculating pay with overtime. How do I produce output that combines the output for each employee so I get output like this:
Employee 1 gets paid $262.5 but gets paid below the minimum wage at $7.5
Employee 3 works 73.0 hours which is over the legal limit and gets paid $895.0
public class FooCorporation {
public static void main(String[] arguments) {
double[] basePay = { 7.50, 8.20, 10.00 };
double[] hoursWorked = { 35, 47, 73 };
double[] totalPay = new double[basePay.length];
String[] Employee = { "Employee 1", "Employee 2", "Employee 3" };
{
for (int x = 0; x < basePay.length; x++) {
if (basePay[x] < 8.0) {
System.out.println(Employee[x] + " gets paid below the minimum wage at $" + basePay[x]);
}
if (hoursWorked[x] > 60) {
System.out.println(Employee[x] + " works " + hoursWorked[x] + " hours which is over the legal limit" );
}
if (hoursWorked[x] > 40) {
totalPay[x] = (40.0 * basePay[x]) + ((hoursWorked[x] - 40.0) * (basePay[x] * 1.5));
} else if (hoursWorked[x] < 40.0)
totalPay[x] = hoursWorked[x] * basePay[x];
System.out.println(Employee[x] + " gets paid $" + totalPay[x]);
}
}
}
}
| 0debug
|
Is there is a similar library to RXAndriod in iOS : Is there is a library or API in iOS similar to RX Android ?
API that I can use to call multiple requests at the same time and combine the results?
| 0debug
|
int ff_draw_init(FFDrawContext *draw, enum PixelFormat format, unsigned flags)
{
const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[format];
const AVComponentDescriptor *c;
unsigned i, nb_planes = 0;
int pixelstep[MAX_PLANES] = { 0 };
if (!desc->name)
return AVERROR(EINVAL);
if (desc->flags & ~(PIX_FMT_PLANAR | PIX_FMT_RGB))
return AVERROR(ENOSYS);
for (i = 0; i < desc->nb_components; i++) {
c = &desc->comp[i];
if (c->depth_minus1 != 8 - 1)
return AVERROR(ENOSYS);
if (c->plane >= MAX_PLANES)
return AVERROR(ENOSYS);
if (pixelstep[c->plane] != 0 &&
pixelstep[c->plane] != c->step_minus1 + 1)
return AVERROR(ENOSYS);
pixelstep[c->plane] = c->step_minus1 + 1;
if (pixelstep[c->plane] >= 8)
return AVERROR(ENOSYS);
nb_planes = FFMAX(nb_planes, c->plane + 1);
}
if ((desc->log2_chroma_w || desc->log2_chroma_h) && nb_planes < 3)
return AVERROR(ENOSYS);
memset(draw, 0, sizeof(*draw));
draw->desc = desc;
draw->format = format;
draw->nb_planes = nb_planes;
memcpy(draw->pixelstep, pixelstep, sizeof(draw->pixelstep));
if (nb_planes >= 3 && !(desc->flags & PIX_FMT_RGB)) {
draw->hsub[1] = draw->hsub[2] = draw->hsub_max = desc->log2_chroma_w;
draw->vsub[1] = draw->vsub[2] = draw->vsub_max = desc->log2_chroma_h;
}
for (i = 0; i < ((desc->nb_components - 1) | 1); i++)
draw->comp_mask[desc->comp[i].plane] |=
1 << (desc->comp[i].offset_plus1 - 1);
return 0;
}
| 1threat
|
why is this SQL shown invalid.? : create table paydetails
( emp_id integer (20),
dept_id integer (20),
basic integer(20),
deductions integer(20),
additions integer (20),
joining_date date(20,20,20));
| 0debug
|
def find_first_duplicate(nums):
num_set = set()
no_duplicate = -1
for i in range(len(nums)):
if nums[i] in num_set:
return nums[i]
else:
num_set.add(nums[i])
return no_duplicate
| 0debug
|
To replace alternate comas in a string with dots : <p>Can someone help me with the code to replace the alternate comas in a string to be replace with dots?</p>
| 0debug
|
When I run it I get indentation Errors in many lines, such as line 6 and lines where I put exit(0). : from sys import exit
def gold_room():
print "This room is full of gold, How much do you take?"
next = raw_input("> ")
if "0" in next or "1" in next:
how_much = int(next)
else:
dead("Man learn to type a number!")
if how_much < 50:
print "Nice, you're not greedy, you win!"
exit(0)
else:
dead("You greedy bastard!")
def bear_room():
print "There is a bear here."
print "The bear has a bunch of honey."
print "The fat bear is in front of another door."
print "How are you going to move a bear?"
bear_moved = False
while True:
next = raw_input("> ")
if next == "take honey":
dead("The bear looks at you and slaps your face off.")
elif next == "taunt bear" and not bear_moved:
print "The bear has moved from the door and you can go now."
bear_moved = True
elif next == "taunt bear" and bear_moved:
dead("The bear gets pissed off and chews your leg off.")
elif next == "open door" and bear_moved:
gold_room()
else:
print "I got no idea waht that means."
def cthulhu_room():
print "Here you see the great evil Cthulhu."
print " He, it, whatever stares at you and you go insane."
print "Do you flee for your life or eat your head?"
next = raw_input("> ")
if "flee" in next:
start()
elif "head" in next:
dead("Well that was tasty!")
else:
cthulhu_room()
def dead(why):
print why, "Good job!"
exit(0)
def start():
print "You are in dark room."
print "There is a door on your right and left."
print "Which one do you take?"
next = raw_input("> ")
if next == "left":
bear_room()
elif next == "right":
cthulhu_room()
else:
dead("You stumble around the room until you starved.")
start()
| 0debug
|
How to install gcc make perl package in virtual box with rhel 7.5 os : <p>I couldn't install guest addition on virtual box version 5.2.12 error caused-
This system is currently not set up to build kernel modules.
Please install the gcc make perl packages from your distribution.</p>
| 0debug
|
static int v210_read_header(AVFormatContext *ctx)
{
V210DemuxerContext *s = ctx->priv_data;
AVStream *st;
st = avformat_new_stream(ctx, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = ctx->iformat->raw_codec_id;
avpriv_set_pts_info(st, 64, s->framerate.den, s->framerate.num);
st->codec->width = s->width;
st->codec->height = s->height;
st->codec->pix_fmt = ctx->iformat->raw_codec_id == AV_CODEC_ID_V210 ?
AV_PIX_FMT_YUV422P10 : AV_PIX_FMT_YUV422P16;
st->codec->bit_rate = av_rescale_q(GET_PACKET_SIZE(s->width, s->height),
(AVRational){8,1}, st->time_base);
return 0;
}
| 1threat
|
Uniqe ID in list of indexed 2D/3D Image masks (or 2D/3D matrix) in R : <p>I want to make a "global" ID of 2D/3D nuclear masks across a list of images.
When i segment my cells they are numbered from 1:numberOfCellsInEachImage. but I would like to have an uniqe Id for each cells across all images.</p>
<p>I have already tried to make a forloop with a global counter and assigned IDs acording to the counter, but It became a messy large thing that I do not trust compleatly</p>
<pre><code># minimal exampe
img1 = matrix(data = 0, nrow = 15, ncol = 15)
img1[2:3, 2:3] = 1
img1[9:10, 5:6] = 2
img1[2:4, 11:13] = 3
img1
# Example indexed image 1
# [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15]
# [1,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# [2,] 0 1 1 0 0 0 0 0 0 0 3 3 3 0 0
# [3,] 0 1 1 0 0 0 0 0 0 0 3 3 3 0 0
# [4,] 0 0 0 0 0 0 0 0 0 0 3 3 3 0 0
# [5,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# [6,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# [7,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# [8,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# [9,] 0 0 0 0 2 2 0 0 0 0 0 0 0 0 0
#[10,] 0 0 0 0 2 2 0 0 0 0 0 0 0 0 0
#[11,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#[12,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#[13,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#[14,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#[15,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
img2 = matrix(data = 0, nrow = 15, ncol = 15)
img2[3:4, 2:4] = 1
img2[10:11, 5:7] = 2
img2[3:5, 11:14] = 3
img2
# [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15]
# [1,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# [2,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# [3,] 0 1 1 1 0 0 0 0 0 0 3 3 3 3 0
# [4,] 0 1 1 1 0 0 0 0 0 0 3 3 3 3 0
# [5,] 0 0 0 0 0 0 0 0 0 0 3 3 3 3 0
# [6,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# [7,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# [8,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# [9,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#[10,] 0 0 0 0 2 2 2 0 0 0 0 0 0 0 0
#[11,] 0 0 0 0 2 2 2 0 0 0 0 0 0 0 0
#[12,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#[13,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#[14,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#[15,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# This is the data structure I have
#
listOfImages2D = list(img1, img2)
#x = listOfImages2D[[1]]
listOfImages3D = lapply(listOfImages2D, function(x){
x_out = array(data = 0, dim = c(15, 15, 3) )
x_out[,,2] = x
return(x_out)
})
</code></pre>
<pre><code>#What I want
# I want all numbers to become an uniqe ID across images
# All zeros should remain zero
# I use img1[img1 == 0 ] = 0 #after giving uniqe IDs
# Image one should ideally start at 1
# ## desired output
# listOfImages2D_global_index[[1]]
# # same as above
#
# listOfImages2D_global_index[[2]]
# # [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15]
# # [1,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# # [2,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# # [3,] 0 4 4 4 0 0 0 0 0 0 6 6 6 6 0
# # [4,] 0 4 4 4 0 0 0 0 0 0 6 6 6 6 0
# # [5,] 0 0 0 0 0 0 0 0 0 0 6 6 6 6 0
# # [6,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# # [7,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# # [8,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# # [9,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# #[10,] 0 0 0 0 5 5 5 0 0 0 0 0 0 0 0
# #[11,] 0 0 0 0 5 5 5 0 0 0 0 0 0 0 0
# #[12,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# #[13,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# #[14,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# #[15,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#
# # the code should also work for 3 dimensions
</code></pre>
| 0debug
|
av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
{
MpegEncContext *s = avctx->priv_data;
int i, ret;
MPV_encode_defaults(s);
switch (avctx->codec_id) {
case AV_CODEC_ID_MPEG2VIDEO:
if (avctx->pix_fmt != AV_PIX_FMT_YUV420P &&
avctx->pix_fmt != AV_PIX_FMT_YUV422P) {
av_log(avctx, AV_LOG_ERROR,
"only YUV420 and YUV422 are supported\n");
return -1;
}
break;
case AV_CODEC_ID_MJPEG:
if (avctx->pix_fmt != AV_PIX_FMT_YUVJ420P &&
avctx->pix_fmt != AV_PIX_FMT_YUVJ422P &&
((avctx->pix_fmt != AV_PIX_FMT_YUV420P &&
avctx->pix_fmt != AV_PIX_FMT_YUV422P) ||
avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL)) {
av_log(avctx, AV_LOG_ERROR, "colorspace not supported in jpeg\n");
return -1;
}
break;
default:
if (avctx->pix_fmt != AV_PIX_FMT_YUV420P) {
av_log(avctx, AV_LOG_ERROR, "only YUV420 is supported\n");
return -1;
}
}
switch (avctx->pix_fmt) {
case AV_PIX_FMT_YUVJ422P:
case AV_PIX_FMT_YUV422P:
s->chroma_format = CHROMA_422;
break;
case AV_PIX_FMT_YUVJ420P:
case AV_PIX_FMT_YUV420P:
default:
s->chroma_format = CHROMA_420;
break;
}
s->bit_rate = avctx->bit_rate;
s->width = avctx->width;
s->height = avctx->height;
if (avctx->gop_size > 600 &&
avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
av_log(avctx, AV_LOG_ERROR,
"Warning keyframe interval too large! reducing it ...\n");
avctx->gop_size = 600;
}
s->gop_size = avctx->gop_size;
s->avctx = avctx;
s->flags = avctx->flags;
s->flags2 = avctx->flags2;
if (avctx->max_b_frames > MAX_B_FRAMES) {
av_log(avctx, AV_LOG_ERROR, "Too many B-frames requested, maximum "
"is %d.\n", MAX_B_FRAMES);
}
s->max_b_frames = avctx->max_b_frames;
s->codec_id = avctx->codec->id;
s->strict_std_compliance = avctx->strict_std_compliance;
s->quarter_sample = (avctx->flags & CODEC_FLAG_QPEL) != 0;
s->mpeg_quant = avctx->mpeg_quant;
s->rtp_mode = !!avctx->rtp_payload_size;
s->intra_dc_precision = avctx->intra_dc_precision;
s->user_specified_pts = AV_NOPTS_VALUE;
if (s->gop_size <= 1) {
s->intra_only = 1;
s->gop_size = 12;
} else {
s->intra_only = 0;
}
s->me_method = avctx->me_method;
s->fixed_qscale = !!(avctx->flags & CODEC_FLAG_QSCALE);
s->adaptive_quant = (s->avctx->lumi_masking ||
s->avctx->dark_masking ||
s->avctx->temporal_cplx_masking ||
s->avctx->spatial_cplx_masking ||
s->avctx->p_masking ||
s->avctx->border_masking ||
(s->mpv_flags & FF_MPV_FLAG_QP_RD)) &&
!s->fixed_qscale;
s->loop_filter = !!(s->flags & CODEC_FLAG_LOOP_FILTER);
if (avctx->rc_max_rate && !avctx->rc_buffer_size) {
av_log(avctx, AV_LOG_ERROR,
"a vbv buffer size is needed, "
"for encoding with a maximum bitrate\n");
return -1;
}
if (avctx->rc_min_rate && avctx->rc_max_rate != avctx->rc_min_rate) {
av_log(avctx, AV_LOG_INFO,
"Warning min_rate > 0 but min_rate != max_rate isn't recommended!\n");
}
if (avctx->rc_min_rate && avctx->rc_min_rate > avctx->bit_rate) {
av_log(avctx, AV_LOG_ERROR, "bitrate below min bitrate\n");
return -1;
}
if (avctx->rc_max_rate && avctx->rc_max_rate < avctx->bit_rate) {
av_log(avctx, AV_LOG_INFO, "bitrate above max bitrate\n");
return -1;
}
if (avctx->rc_max_rate &&
avctx->rc_max_rate == avctx->bit_rate &&
avctx->rc_max_rate != avctx->rc_min_rate) {
av_log(avctx, AV_LOG_INFO,
"impossible bitrate constraints, this will fail\n");
}
if (avctx->rc_buffer_size &&
avctx->bit_rate * (int64_t)avctx->time_base.num >
avctx->rc_buffer_size * (int64_t)avctx->time_base.den) {
av_log(avctx, AV_LOG_ERROR, "VBV buffer too small for bitrate\n");
return -1;
}
if (!s->fixed_qscale &&
avctx->bit_rate * av_q2d(avctx->time_base) >
avctx->bit_rate_tolerance) {
av_log(avctx, AV_LOG_ERROR,
"bitrate tolerance too small for bitrate\n");
return -1;
}
if (s->avctx->rc_max_rate &&
s->avctx->rc_min_rate == s->avctx->rc_max_rate &&
(s->codec_id == AV_CODEC_ID_MPEG1VIDEO ||
s->codec_id == AV_CODEC_ID_MPEG2VIDEO) &&
90000LL * (avctx->rc_buffer_size - 1) >
s->avctx->rc_max_rate * 0xFFFFLL) {
av_log(avctx, AV_LOG_INFO,
"Warning vbv_delay will be set to 0xFFFF (=VBR) as the "
"specified vbv buffer is too large for the given bitrate!\n");
}
if ((s->flags & CODEC_FLAG_4MV) && s->codec_id != AV_CODEC_ID_MPEG4 &&
s->codec_id != AV_CODEC_ID_H263 && s->codec_id != AV_CODEC_ID_H263P &&
s->codec_id != AV_CODEC_ID_FLV1) {
av_log(avctx, AV_LOG_ERROR, "4MV not supported by codec\n");
return -1;
}
if (s->obmc && s->avctx->mb_decision != FF_MB_DECISION_SIMPLE) {
av_log(avctx, AV_LOG_ERROR,
"OBMC is only supported with simple mb decision\n");
return -1;
}
if (s->quarter_sample && s->codec_id != AV_CODEC_ID_MPEG4) {
av_log(avctx, AV_LOG_ERROR, "qpel not supported by codec\n");
return -1;
}
if (s->max_b_frames &&
s->codec_id != AV_CODEC_ID_MPEG4 &&
s->codec_id != AV_CODEC_ID_MPEG1VIDEO &&
s->codec_id != AV_CODEC_ID_MPEG2VIDEO) {
av_log(avctx, AV_LOG_ERROR, "b frames not supported by codec\n");
return -1;
}
if ((s->codec_id == AV_CODEC_ID_MPEG4 ||
s->codec_id == AV_CODEC_ID_H263 ||
s->codec_id == AV_CODEC_ID_H263P) &&
(avctx->sample_aspect_ratio.num > 255 ||
avctx->sample_aspect_ratio.den > 255)) {
av_log(avctx, AV_LOG_ERROR,
"Invalid pixel aspect ratio %i/%i, limit is 255/255\n",
avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den);
return -1;
}
if ((s->flags & (CODEC_FLAG_INTERLACED_DCT | CODEC_FLAG_INTERLACED_ME)) &&
s->codec_id != AV_CODEC_ID_MPEG4 && s->codec_id != AV_CODEC_ID_MPEG2VIDEO) {
av_log(avctx, AV_LOG_ERROR, "interlacing not supported by codec\n");
return -1;
}
if (s->mpeg_quant && s->codec_id != AV_CODEC_ID_MPEG4) {
av_log(avctx, AV_LOG_ERROR,
"mpeg2 style quantization not supported by codec\n");
return -1;
}
if ((s->mpv_flags & FF_MPV_FLAG_CBP_RD) && !avctx->trellis) {
av_log(avctx, AV_LOG_ERROR, "CBP RD needs trellis quant\n");
return -1;
}
if ((s->mpv_flags & FF_MPV_FLAG_QP_RD) &&
s->avctx->mb_decision != FF_MB_DECISION_RD) {
av_log(avctx, AV_LOG_ERROR, "QP RD needs mbd=2\n");
return -1;
}
if (s->avctx->scenechange_threshold < 1000000000 &&
(s->flags & CODEC_FLAG_CLOSED_GOP)) {
av_log(avctx, AV_LOG_ERROR,
"closed gop with scene change detection are not supported yet, "
"set threshold to 1000000000\n");
return -1;
}
if (s->flags & CODEC_FLAG_LOW_DELAY) {
if (s->codec_id != AV_CODEC_ID_MPEG2VIDEO) {
av_log(avctx, AV_LOG_ERROR,
"low delay forcing is only available for mpeg2\n");
return -1;
}
if (s->max_b_frames != 0) {
av_log(avctx, AV_LOG_ERROR,
"b frames cannot be used with low delay\n");
return -1;
}
}
if (s->q_scale_type == 1) {
if (avctx->qmax > 12) {
av_log(avctx, AV_LOG_ERROR,
"non linear quant only supports qmax <= 12 currently\n");
return -1;
}
}
if (s->avctx->thread_count > 1 &&
s->codec_id != AV_CODEC_ID_MPEG4 &&
s->codec_id != AV_CODEC_ID_MPEG1VIDEO &&
s->codec_id != AV_CODEC_ID_MPEG2VIDEO &&
(s->codec_id != AV_CODEC_ID_H263P)) {
av_log(avctx, AV_LOG_ERROR,
"multi threaded encoding not supported by codec\n");
return -1;
}
if (s->avctx->thread_count < 1) {
av_log(avctx, AV_LOG_ERROR,
"automatic thread number detection not supported by codec,"
"patch welcome\n");
return -1;
}
if (s->avctx->thread_count > 1)
s->rtp_mode = 1;
if (!avctx->time_base.den || !avctx->time_base.num) {
av_log(avctx, AV_LOG_ERROR, "framerate not set\n");
return -1;
}
i = (INT_MAX / 2 + 128) >> 8;
if (avctx->mb_threshold >= i) {
av_log(avctx, AV_LOG_ERROR, "mb_threshold too large, max is %d\n",
i - 1);
return -1;
}
if (avctx->b_frame_strategy && (avctx->flags & CODEC_FLAG_PASS2)) {
av_log(avctx, AV_LOG_INFO,
"notice: b_frame_strategy only affects the first pass\n");
avctx->b_frame_strategy = 0;
}
i = av_gcd(avctx->time_base.den, avctx->time_base.num);
if (i > 1) {
av_log(avctx, AV_LOG_INFO, "removing common factors from framerate\n");
avctx->time_base.den /= i;
avctx->time_base.num /= i;
}
if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG1VIDEO ||
s->codec_id == AV_CODEC_ID_MPEG2VIDEO || s->codec_id == AV_CODEC_ID_MJPEG) {
s->intra_quant_bias = 3 << (QUANT_BIAS_SHIFT - 3);
s->inter_quant_bias = 0;
} else {
s->intra_quant_bias = 0;
s->inter_quant_bias = -(1 << (QUANT_BIAS_SHIFT - 2));
}
if (avctx->intra_quant_bias != FF_DEFAULT_QUANT_BIAS)
s->intra_quant_bias = avctx->intra_quant_bias;
if (avctx->inter_quant_bias != FF_DEFAULT_QUANT_BIAS)
s->inter_quant_bias = avctx->inter_quant_bias;
if (avctx->codec_id == AV_CODEC_ID_MPEG4 &&
s->avctx->time_base.den > (1 << 16) - 1) {
av_log(avctx, AV_LOG_ERROR,
"timebase %d/%d not supported by MPEG 4 standard, "
"the maximum admitted value for the timebase denominator "
"is %d\n", s->avctx->time_base.num, s->avctx->time_base.den,
(1 << 16) - 1);
return -1;
}
s->time_increment_bits = av_log2(s->avctx->time_base.den - 1) + 1;
switch (avctx->codec->id) {
case AV_CODEC_ID_MPEG1VIDEO:
s->out_format = FMT_MPEG1;
s->low_delay = !!(s->flags & CODEC_FLAG_LOW_DELAY);
avctx->delay = s->low_delay ? 0 : (s->max_b_frames + 1);
break;
case AV_CODEC_ID_MPEG2VIDEO:
s->out_format = FMT_MPEG1;
s->low_delay = !!(s->flags & CODEC_FLAG_LOW_DELAY);
avctx->delay = s->low_delay ? 0 : (s->max_b_frames + 1);
s->rtp_mode = 1;
break;
case AV_CODEC_ID_MJPEG:
s->out_format = FMT_MJPEG;
s->intra_only = 1;
if (!CONFIG_MJPEG_ENCODER ||
ff_mjpeg_encode_init(s) < 0)
return -1;
avctx->delay = 0;
s->low_delay = 1;
break;
case AV_CODEC_ID_H261:
if (!CONFIG_H261_ENCODER)
return -1;
if (ff_h261_get_picture_format(s->width, s->height) < 0) {
av_log(avctx, AV_LOG_ERROR,
"The specified picture size of %dx%d is not valid for the "
"H.261 codec.\nValid sizes are 176x144, 352x288\n",
s->width, s->height);
return -1;
}
s->out_format = FMT_H261;
avctx->delay = 0;
s->low_delay = 1;
break;
case AV_CODEC_ID_H263:
if (!CONFIG_H263_ENCODER)
return -1;
if (ff_match_2uint16(ff_h263_format, FF_ARRAY_ELEMS(ff_h263_format),
s->width, s->height) == 8) {
av_log(avctx, AV_LOG_INFO,
"The specified picture size of %dx%d is not valid for "
"the H.263 codec.\nValid sizes are 128x96, 176x144, "
"352x288, 704x576, and 1408x1152."
"Try H.263+.\n", s->width, s->height);
return -1;
}
s->out_format = FMT_H263;
avctx->delay = 0;
s->low_delay = 1;
break;
case AV_CODEC_ID_H263P:
s->out_format = FMT_H263;
s->h263_plus = 1;
s->h263_aic = (avctx->flags & CODEC_FLAG_AC_PRED) ? 1 : 0;
s->modified_quant = s->h263_aic;
s->loop_filter = (avctx->flags & CODEC_FLAG_LOOP_FILTER) ? 1 : 0;
s->unrestricted_mv = s->obmc || s->loop_filter || s->umvplus;
avctx->delay = 0;
s->low_delay = 1;
break;
case AV_CODEC_ID_FLV1:
s->out_format = FMT_H263;
s->h263_flv = 2;
s->unrestricted_mv = 1;
s->rtp_mode = 0;
avctx->delay = 0;
s->low_delay = 1;
break;
case AV_CODEC_ID_RV10:
s->out_format = FMT_H263;
avctx->delay = 0;
s->low_delay = 1;
break;
case AV_CODEC_ID_RV20:
s->out_format = FMT_H263;
avctx->delay = 0;
s->low_delay = 1;
s->modified_quant = 1;
s->h263_aic = 1;
s->h263_plus = 1;
s->loop_filter = 1;
s->unrestricted_mv = 0;
break;
case AV_CODEC_ID_MPEG4:
s->out_format = FMT_H263;
s->h263_pred = 1;
s->unrestricted_mv = 1;
s->low_delay = s->max_b_frames ? 0 : 1;
avctx->delay = s->low_delay ? 0 : (s->max_b_frames + 1);
break;
case AV_CODEC_ID_MSMPEG4V2:
s->out_format = FMT_H263;
s->h263_pred = 1;
s->unrestricted_mv = 1;
s->msmpeg4_version = 2;
avctx->delay = 0;
s->low_delay = 1;
break;
case AV_CODEC_ID_MSMPEG4V3:
s->out_format = FMT_H263;
s->h263_pred = 1;
s->unrestricted_mv = 1;
s->msmpeg4_version = 3;
s->flipflop_rounding = 1;
avctx->delay = 0;
s->low_delay = 1;
break;
case AV_CODEC_ID_WMV1:
s->out_format = FMT_H263;
s->h263_pred = 1;
s->unrestricted_mv = 1;
s->msmpeg4_version = 4;
s->flipflop_rounding = 1;
avctx->delay = 0;
s->low_delay = 1;
break;
case AV_CODEC_ID_WMV2:
s->out_format = FMT_H263;
s->h263_pred = 1;
s->unrestricted_mv = 1;
s->msmpeg4_version = 5;
s->flipflop_rounding = 1;
avctx->delay = 0;
s->low_delay = 1;
break;
default:
return -1;
}
avctx->has_b_frames = !s->low_delay;
s->encoding = 1;
s->progressive_frame =
s->progressive_sequence = !(avctx->flags & (CODEC_FLAG_INTERLACED_DCT |
CODEC_FLAG_INTERLACED_ME) ||
s->alternate_scan);
if (ff_MPV_common_init(s) < 0)
return -1;
if (ARCH_X86)
ff_MPV_encode_init_x86(s);
s->avctx->coded_frame = &s->current_picture.f;
if (s->msmpeg4_version) {
FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_stats,
2 * 2 * (MAX_LEVEL + 1) *
(MAX_RUN + 1) * 2 * sizeof(int), fail);
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->avctx->stats_out, 256, fail);
FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix, 64 * 32 * sizeof(int), fail);
FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix, 64 * 32 * sizeof(int), fail);
FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix16, 64 * 32 * 2 * sizeof(uint16_t), fail);
FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix16, 64 * 32 * 2 * sizeof(uint16_t), fail);
FF_ALLOCZ_OR_GOTO(s->avctx, s->input_picture,
MAX_PICTURE_COUNT * sizeof(Picture *), fail);
FF_ALLOCZ_OR_GOTO(s->avctx, s->reordered_input_picture,
MAX_PICTURE_COUNT * sizeof(Picture *), fail);
if (s->avctx->noise_reduction) {
FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset,
2 * 64 * sizeof(uint16_t), fail);
}
if (CONFIG_H263_ENCODER)
ff_h263dsp_init(&s->h263dsp);
if (!s->dct_quantize)
s->dct_quantize = ff_dct_quantize_c;
if (!s->denoise_dct)
s->denoise_dct = denoise_dct_c;
s->fast_dct_quantize = s->dct_quantize;
if (avctx->trellis)
s->dct_quantize = dct_quantize_trellis_c;
if ((CONFIG_H263P_ENCODER || CONFIG_RV20_ENCODER) && s->modified_quant)
s->chroma_qscale_table = ff_h263_chroma_qscale_table;
s->quant_precision = 5;
ff_set_cmp(&s->dsp, s->dsp.ildct_cmp, s->avctx->ildct_cmp);
ff_set_cmp(&s->dsp, s->dsp.frame_skip_cmp, s->avctx->frame_skip_cmp);
if (CONFIG_H261_ENCODER && s->out_format == FMT_H261)
ff_h261_encode_init(s);
if (CONFIG_H263_ENCODER && s->out_format == FMT_H263)
ff_h263_encode_init(s);
if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version)
ff_msmpeg4_encode_init(s);
if ((CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)
&& s->out_format == FMT_MPEG1)
ff_mpeg1_encode_init(s);
for (i = 0; i < 64; i++) {
int j = s->dsp.idct_permutation[i];
if (CONFIG_MPEG4_ENCODER && s->codec_id == AV_CODEC_ID_MPEG4 &&
s->mpeg_quant) {
s->intra_matrix[j] = ff_mpeg4_default_intra_matrix[i];
s->inter_matrix[j] = ff_mpeg4_default_non_intra_matrix[i];
} else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) {
s->intra_matrix[j] =
s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i];
} else {
s->intra_matrix[j] = ff_mpeg1_default_intra_matrix[i];
s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i];
}
if (s->avctx->intra_matrix)
s->intra_matrix[j] = s->avctx->intra_matrix[i];
if (s->avctx->inter_matrix)
s->inter_matrix[j] = s->avctx->inter_matrix[i];
}
if (s->out_format != FMT_MJPEG) {
ff_convert_matrix(&s->dsp, s->q_intra_matrix, s->q_intra_matrix16,
s->intra_matrix, s->intra_quant_bias, avctx->qmin,
31, 1);
ff_convert_matrix(&s->dsp, s->q_inter_matrix, s->q_inter_matrix16,
s->inter_matrix, s->inter_quant_bias, avctx->qmin,
31, 0);
}
if (ff_rate_control_init(s) < 0)
return -1;
#if FF_API_ERROR_RATE
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->error_rate)
s->error_rate = avctx->error_rate;
FF_ENABLE_DEPRECATION_WARNINGS;
#endif
if (avctx->b_frame_strategy == 2) {
for (i = 0; i < s->max_b_frames + 2; i++) {
s->tmp_frames[i] = av_frame_alloc();
if (!s->tmp_frames[i])
return AVERROR(ENOMEM);
s->tmp_frames[i]->format = AV_PIX_FMT_YUV420P;
s->tmp_frames[i]->width = s->width >> avctx->brd_scale;
s->tmp_frames[i]->height = s->height >> avctx->brd_scale;
ret = av_frame_get_buffer(s->tmp_frames[i], 32);
if (ret < 0)
return ret;
}
}
return 0;
fail:
ff_MPV_encode_end(avctx);
return AVERROR_UNKNOWN;
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.