problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Unknown ending signal when using debugger gdb : <p>I have installed GDB on Mac OS X and to test that it works I have used this following C program. </p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int *my_array = (int *) malloc(5 * sizeof(int));
int i;
for (i = 0; i < 1000000; i++) {
my_array[i] = i;
}
free(my_array);
return 0;
}
</code></pre>
<p>I have an error when compiling it, which is normal (segmentation fault)</p>
<p>However, when <strong>adding the -g flag</strong> in the compiling command and running gdb on my compiled program, I have this message after launching the command <strong>run</strong> </p>
<pre><code>During startup program terminated with signal ?, Unknown signal.
</code></pre>
<p>Really don't know where it comes from. I have added a certificate to ensure that gdb works correctly on OS X but I have found nothing to fix this issue.</p>
| 0debug
|
static int pcm_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
const uint8_t *buf, int buf_size)
{
PCMDecode *s = avctx->priv_data;
int sample_size, c, n;
short *samples;
const uint8_t *src, *src8, *src2[MAX_CHANNELS];
uint8_t *dstu8;
int16_t *dst_int16_t;
int32_t *dst_int32_t;
int64_t *dst_int64_t;
uint16_t *dst_uint16_t;
uint32_t *dst_uint32_t;
samples = data;
src = buf;
if (avctx->sample_fmt!=avctx->codec->sample_fmts[0]) {
av_log(avctx, AV_LOG_ERROR, "invalid sample_fmt\n");
return -1;
}
if(avctx->channels <= 0 || avctx->channels > MAX_CHANNELS){
av_log(avctx, AV_LOG_ERROR, "PCM channels out of bounds\n");
return -1;
}
sample_size = av_get_bits_per_sample(avctx->codec_id)/8;
if (CODEC_ID_PCM_DVD == avctx->codec_id)
sample_size = avctx->bits_per_coded_sample * 2 / 8;
n = avctx->channels * sample_size;
if(n && buf_size % n){
av_log(avctx, AV_LOG_ERROR, "invalid PCM packet\n");
return -1;
}
buf_size= FFMIN(buf_size, *data_size/2);
*data_size=0;
n = buf_size/sample_size;
switch(avctx->codec->id) {
case CODEC_ID_PCM_U32LE:
DECODE(uint32_t, le32, src, samples, n, 0, 0x80000000)
break;
case CODEC_ID_PCM_U32BE:
DECODE(uint32_t, be32, src, samples, n, 0, 0x80000000)
break;
case CODEC_ID_PCM_S24LE:
DECODE(int32_t, le24, src, samples, n, 8, 0)
break;
case CODEC_ID_PCM_S24BE:
DECODE(int32_t, be24, src, samples, n, 8, 0)
break;
case CODEC_ID_PCM_U24LE:
DECODE(uint32_t, le24, src, samples, n, 8, 0x800000)
break;
case CODEC_ID_PCM_U24BE:
DECODE(uint32_t, be24, src, samples, n, 8, 0x800000)
break;
case CODEC_ID_PCM_S24DAUD:
for(;n>0;n--) {
uint32_t v = bytestream_get_be24(&src);
v >>= 4;
*samples++ = ff_reverse[(v >> 8) & 0xff] +
(ff_reverse[v & 0xff] << 8);
}
break;
case CODEC_ID_PCM_S16LE_PLANAR:
n /= avctx->channels;
for(c=0;c<avctx->channels;c++)
src2[c] = &src[c*n*2];
for(;n>0;n--)
for(c=0;c<avctx->channels;c++)
*samples++ = bytestream_get_le16(&src2[c]);
src = src2[avctx->channels-1];
break;
case CODEC_ID_PCM_U16LE:
DECODE(uint16_t, le16, src, samples, n, 0, 0x8000)
break;
case CODEC_ID_PCM_U16BE:
DECODE(uint16_t, be16, src, samples, n, 0, 0x8000)
break;
case CODEC_ID_PCM_S8:
dstu8= (uint8_t*)samples;
for(;n>0;n--) {
*dstu8++ = *src++ + 128;
}
samples= (short*)dstu8;
break;
#if WORDS_BIGENDIAN
case CODEC_ID_PCM_F64LE:
DECODE(int64_t, le64, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_S32LE:
case CODEC_ID_PCM_F32LE:
DECODE(int32_t, le32, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_S16LE:
DECODE(int16_t, le16, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_F64BE:
case CODEC_ID_PCM_F32BE:
case CODEC_ID_PCM_S32BE:
case CODEC_ID_PCM_S16BE:
#else
case CODEC_ID_PCM_F64BE:
DECODE(int64_t, be64, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_F32BE:
case CODEC_ID_PCM_S32BE:
DECODE(int32_t, be32, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_S16BE:
DECODE(int16_t, be16, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_F64LE:
case CODEC_ID_PCM_F32LE:
case CODEC_ID_PCM_S32LE:
case CODEC_ID_PCM_S16LE:
#endif
case CODEC_ID_PCM_U8:
memcpy(samples, src, n*sample_size);
src += n*sample_size;
samples = (short*)((uint8_t*)data + n*sample_size);
break;
case CODEC_ID_PCM_ZORK:
for(;n>0;n--) {
int x= *src++;
if(x&128) x-= 128;
else x = -x;
*samples++ = x << 8;
}
break;
case CODEC_ID_PCM_ALAW:
case CODEC_ID_PCM_MULAW:
for(;n>0;n--) {
*samples++ = s->table[*src++];
}
break;
case CODEC_ID_PCM_DVD:
dst_int32_t = data;
n /= avctx->channels;
switch (avctx->bits_per_coded_sample) {
case 20:
while (n--) {
c = avctx->channels;
src8 = src + 4*c;
while (c--) {
*dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8 &0xf0) << 8);
*dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++ &0x0f) << 12);
}
src = src8;
}
break;
case 24:
while (n--) {
c = avctx->channels;
src8 = src + 4*c;
while (c--) {
*dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++) << 8);
*dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++) << 8);
}
src = src8;
}
break;
default:
av_log(avctx, AV_LOG_ERROR, "PCM DVD unsupported sample depth\n");
return -1;
break;
}
samples = (short *) dst_int32_t;
break;
default:
return -1;
}
*data_size = (uint8_t *)samples - (uint8_t *)data;
return src - buf;
}
| 1threat
|
htmlagilitypack getting a value from a specific child node : I have an html and using htmlagilitypack with c#. I need to get a specific child node value. I need to get the text of the child "strong/em" in the html. how can i get it?
<!-- begin snippet: js hide: false -->
<!-- language: lang-html -->
<div id="top3">
<li> February 1, 2016:
<a target="_blank" href="test1.html">
<strong>
<em>test1</em></strong>
</a>
<br><strong>desc1</strong></li>
<li> February 2, 2016:
<a target="_blank" href="test2.html">
<strong>
<em>test2</em></strong>
</a>
<br><strong>desc2</strong></li>
</div>
<!-- end snippet -->
foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//div[@id='top3']//li"))
{
sb.Append("<p'>" + node.SelectSingleNode("a[1]/preceding-sibling::text()[1]").InnerText + "</p>");
linkNode = node.SelectSingleNode("a[1]");
sb.Append("<p class='event'><a href='" + linkNode.Attributes["href"].Value + "'>" +
//**********Need to have text from /strong/em/ here *********
+ "</a></p>");
}
| 0debug
|
How to fix "Use Of Unassigned local variable in citra" when citra is defined? (with Object Oreinted Programming, bools, and switch statements) : <p>Recently I was attempting to make an advanced choose your own adventure game to practice my fresh new C# skills but I have came across a powerful error that is preventing me from continuing my project."Use Of Unassigned local variable in citra" on line 58 inside the story_Confirmation method is an error I came across that is not allowing me to return citra for some odd reason. Can I please get some assistance?</p>
<p>Code is below:</p>
<pre><code>using System;
namespace FirstConsoleProgram
{
public class Game{} //Currently Nothing
public class Story : Game
{
public int stro;
private string intro;
public Story(int _stro)
{
stro = _stro;
if(stro == 1)
{
SetIntroTXT("how you \"The Avatar\" have to save the world from pain and destruction. \n You travel the world gaining new spells and abilities until the ultimate battle \n where you have to fight Lord Ozai");
bool reply = story_Confirmation(5);
Console.WriteLine(reply);
}
}
void FirstStory()
{
; //Currently Nothing
}
void SetIntroTXT(string txt)
{
intro = txt;
}
bool story_Confirmation(int cont)
{
Console.Clear();
Console.WriteLine(intro);
Console.WriteLine();
bool citra;
Console.WriteLine("Are you sure you want to confirm? (y/n)");
string awn = Console.ReadLine().ToUpper();
if(awn == "YES" || awn == "Y")
{
cont = 1;
}
else if(awn == "NO" || awn == "N")
{
cont = 2;
}
switch(cont)
{
case 1:
citra = true;
break;
case 2:
citra = false;
break;
}
return citra;
}
}
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Welcome to Choose your adventure!");
Console.WriteLine();
Console.WriteLine("Out of the 5 Stories, which one would you like to play?");
string stro_sel = Console.ReadLine();
Story GameStory = new Story(1);
}
}
}
</code></pre>
<p>Any help apreciated! Thanks!</p>
<p>Warning: Please mind my English grammar and note that I had to copy and paste the code and make it look neat(because the whitespace was terrible when I pasted it in). That could explain why it might look sloppy without whitespace.</p>
<p>Another sidenote is that this is not a duplicate because the other questions on this topic did not awnser my question nor did it help me solve my programming problem. My problem takes a statement into object oreinted programming(with classes and methods) and uses switch statements. The previous questions on this topic has unique problems that I did not face, and by asking this I am trying to resolve my issue, not a general issue on the error, but what I did wrong in my code.</p>
<p>In best regards, thanks.</p>
| 0debug
|
Creating a loop and calculateing average at the end : I'm a beginner when it comes to programming and coding, so please excuse me if i ask any silly or obvious questions. I just started out learning Python and got an assignment which has one question i'm just not sure how to start with it. The question goes as follows:
"Write a program that repeatedly asks the user to enter a number, either float or integer until a value -88 is entered. The program should then output the average of the numbers entered with two decimal places. Please note that -88 should not be counted as it is the value entered to terminate the loop"
this will probably be a very simple thing to do for all of you :-) but for a total beginner as myself, it through me off a little. I have gotten the program to ask a number repeatedly and terminate the loop with -99 but I'm struggling to get it to accept integer numbers (1.1 etc) and calculate the average of the numbers entered.
Any help or tips will be gladly appreciated to help me solve this little puzzle i got.
Thanks in advanced
Dio
| 0debug
|
Access arraylist from another class inside main class : <p>I don't have any idea on how to make this since i'm a new in java. I want to display all my objects in the arraylist of my TimeSlot class into the main class. I've tried few ways like using for (int = 0; i < bookingList.size(); i++) but still can't work. I'm getting nullPointerException so i dont know if there's other way to solve this. Please help.</p>
<p>TimeSlot.java</p>
<pre><code>import java.util.ArrayList;
public class TimeSlot {
private String slotName;
private ArrayList<Booking> bookingList;
public TimeSlot(String sn) {
this.slotName = sn;
this.bookingList = new ArrayList<Booking>();
Booking booking1 = new Booking("CS1011", "A04", "Aiman");
Booking booking2 = new Booking("CS1012", "A13", "Nazim");
Booking booking3 = new Booking("CS1013", "A06", "Sarah");
Booking booking4 = new Booking("CS1014", "A21", "Majid");
bookingList.add(booking1);
bookingList.add(booking2);
bookingList.add(booking3);
bookingList.add(booking4);
}
public String getSlotName() {
return slotName;
}
public ArrayList<Booking> getBookingList() {
return bookingList;
}
public boolean isBooking (String bId, String cId, String sId) {
boolean isVerifyBooking = false;
for(Booking newBooking: bookingList){
if((newBooking.getBookingId().equals(bId)) && newBooking.getComputerId().equals(cId) && newBooking.getStudentId().equals(sId)) {
return true;
}
}
return isVerifyBooking;
}
}
</code></pre>
<p>Main.java</p>
<pre><code>public static void main(String[] args) {
// TODO Auto-generated method stub
Faculty faculty = new Faculty("Computer Science and Technology", "");
Lab lab = new Lab("");
ArrayList<Computer> computerList = new ArrayList<Computer>();
ArrayList<Booking> isBookingList = new Booking(null, null, null).getBookingList();
if (option.equals("1")) {
System.out.println("\nChoose day: ");
String days = sc.next();
System.out.println("\nChoose date: ");
String date = sc.next();
boolean isValidDay = lab.verifyDate(days, date);
if (isValidDay) {
Day day = new Day(days, date);
System.out.println("\nBooking date: " + day.getDay() + " " + day.getDate());
System.out.println("\nPlease select a computer (A01 ~ A40): ");
String cId = sc.next();
System.out.println(isBookingList.size());
}
} else if (option.equals("2")) {
// I want to display it here
for (Booking booking: isBookingList) {
System.out.println(booking.getBookingList());
}
}
</code></pre>
| 0debug
|
Proper filenames in iOS project : <p>I've been told during a job assignment review, that I used weird filenames in my iOS project.</p>
<p>I've added a picture of my project tree. Could you explain me what's weird about these names or if there are any flaws in the tree structure?</p>
<p>Thanks</p>
<p><a href="https://i.stack.imgur.com/VQkkK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VQkkK.png" alt="enter image description here"></a></p>
| 0debug
|
connection.query('SELECT * FROM users WHERE username = ' + input_string)
| 1threat
|
Error in def_main(), excecute takes 1 positional argument, but two was given. If I give only 1 argument the same result : def execute_command(cmd):
f = open(log.name, "w")
try:
subprocess.Popen(cmd, 0, f, f)
except WindowsError:
cmd[0] = cmd[0] + ".com"
subprocess.Popen(cmd, 0, f, f) #work-around
rc = process.wait()
if rc != 0:
print("Error: failed to execute command:", cmd)
print(error)
return result
def_main():
execute_command(["tree", "C:\\"], "treelog.txt")
return
| 0debug
|
Track multiple users live location on the map in android : I'm searching for the track live location of the multiple users. Like Ola cabs and Uber Taxi live location. I try to find so many things but didn't find anything.
I also try with the Pubnub. but not success on it.
Thanks in advance.
| 0debug
|
Could anyone help me to install Intel package fortran in Mac OS Catalina? : <p>I have downloaded the installation file from the link below but after finishing installation I am not seeing anything to open the application.
<a href="https://software.intel.com/en-us/fortran-compilers/choose-download" rel="nofollow noreferrer">https://software.intel.com/en-us/fortran-compilers/choose-download</a></p>
| 0debug
|
'Could not load file or assembly 'System.Web.Helpers' or one of its dependencies : <p>I'm getting the follow error when trying to run my ASP.NET project. Can anyone advise?</p>
<pre><code>Could not load file or assembly 'System.Web.Helpers' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileLoadException: Could not load file or assembly 'System.Web.Helpers' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Helpers' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = System.Web.Helpers
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: System.Web.Helpers | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = .../.../
LOG: Initial PrivatePath = \...\WebInterface\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: \...\WebInterface\web.config
LOG: Using host configuration file: \Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL /AppData/Local/Temp/Temporary ASP.NET Files/vs/0418a60d/21ffd41/System.Web.Helpers.DLL.
LOG: Attempting download of new URL /AppData/Local/Temp/Temporary ASP.NET Files/vs/0418a60d/21ffd41/System.Web.Helpers/System.Web.Helpers.DLL.
LOG: Attempting download of new URL .../.../bin/System.Web.Helpers.DLL.
LOG: Using application configuration file: \...\WebInterface\web.config
LOG: Using host configuration file: \Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 2.0.0.0 redirected to 3.0.0.0.
LOG: Post-policy reference: System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL /AppData/Local/Temp/Temporary ASP.NET Files/vs/0418a60d/21ffd41/System.Web.Helpers.DLL.
LOG: Attempting download of new URL /AppData/Local/Temp/Temporary ASP.NET Files/vs/0418a60d/21ffd41/System.Web.Helpers/System.Web.Helpers.DLL.
LOG: Attempting download of new URL .../.../bin/System.Web.Helpers.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
Stack Trace:
[FileLoadException: Could not load file or assembly 'System.Web.Helpers' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
[FileLoadException: Could not load file or assembly 'System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +36
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +21
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38
[ConfigurationErrorsException: Could not load file or assembly 'System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +738
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +217
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +92
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +290
System.Web.Compilation.BuildManager.ExecutePreAppStart() +157
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +531
[HttpException (0x80004005): Could not load file or assembly 'System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9963380
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
</code></pre>
<p>I've tried the following based on other answers:</p>
<ul>
<li>Installing ASP.NET MVC 4 separately from <a href="https://www.microsoft.com/en-us/download/details.aspx?id=30683" rel="noreferrer">https://www.microsoft.com/en-us/download/details.aspx?id=30683</a></li>
<li>Updating NuGet packages</li>
<li>Settings System.Web.Helpers Copy Local to True</li>
</ul>
| 0debug
|
New warning when building android app with gradle : <p>Yesterday it was fine, today it shows this warning when I clean or build the project:</p>
<blockquote>
<p>WARNING: Ignoring Android API artifact
com.google.android:android:2.1_r1 for appDebug WARNING: Ignoring Android
API artifact com.google.android:android:2.1_r1 for appRelease</p>
</blockquote>
<p>I think it was caused by an update of the gradle plugin for android.</p>
<p>Anyone knows what it means ?</p>
| 0debug
|
How to add a mask over background image in activity? : <p>I want to add an image as a background of an activity, and I want to add another image .png over it</p>
| 0debug
|
i m coding in c#.net. i am using service based database. i am getting an error while inserting a record. textbox1 is a varchar type : private void button2_Click_1(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection(global::CFMSApp.Properties.Settings.Default.CFMSConnectionString);
try
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into io values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "')";
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("adding new record done");
textBox1.Text = " ";
textBox2.Text = " ";
textBox3.Text = " ";
textBox4.Text = " ";
textBox5.Text = " ";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "error");
}
finally
{
cn.Close();
con.Close();
}
| 0debug
|
I am using fat arrow function in php : $mul2 = fn($x) => $x * 2;
$mul2(3);
I am getting an error at =>
Error- Unexpected => How do I resolve the error.
| 0debug
|
av_cold void ff_vp9dsp_init_x86(VP9DSPContext *dsp)
{
#if HAVE_YASM
int cpu_flags = av_get_cpu_flags();
#define init_fpel(idx1, idx2, sz, type, opt) \
dsp->mc[idx1][FILTER_8TAP_SMOOTH ][idx2][0][0] = \
dsp->mc[idx1][FILTER_8TAP_REGULAR][idx2][0][0] = \
dsp->mc[idx1][FILTER_8TAP_SHARP ][idx2][0][0] = \
dsp->mc[idx1][FILTER_BILINEAR ][idx2][0][0] = ff_vp9_##type##sz##_##opt
#define init_subpel1(idx1, idx2, idxh, idxv, sz, dir, type, opt) \
dsp->mc[idx1][FILTER_8TAP_SMOOTH ][idx2][idxh][idxv] = type##_8tap_smooth_##sz##dir##_##opt; \
dsp->mc[idx1][FILTER_8TAP_REGULAR][idx2][idxh][idxv] = type##_8tap_regular_##sz##dir##_##opt; \
dsp->mc[idx1][FILTER_8TAP_SHARP ][idx2][idxh][idxv] = type##_8tap_sharp_##sz##dir##_##opt
#define init_subpel2_32_64(idx, idxh, idxv, dir, type, opt) \
init_subpel1(0, idx, idxh, idxv, 64, dir, type, opt); \
init_subpel1(1, idx, idxh, idxv, 32, dir, type, opt)
#define init_subpel2(idx, idxh, idxv, dir, type, opt) \
init_subpel2_32_64(idx, idxh, idxv, dir, type, opt); \
init_subpel1(2, idx, idxh, idxv, 16, dir, type, opt); \
init_subpel1(3, idx, idxh, idxv, 8, dir, type, opt); \
init_subpel1(4, idx, idxh, idxv, 4, dir, type, opt)
#define init_subpel3(idx, type, opt) \
init_subpel2(idx, 1, 1, hv, type, opt); \
init_subpel2(idx, 0, 1, v, type, opt); \
init_subpel2(idx, 1, 0, h, type, opt)
#define init_lpf(opt) do { \
if (ARCH_X86_64) { \
dsp->loop_filter_16[0] = ff_vp9_loop_filter_h_16_16_##opt; \
dsp->loop_filter_16[1] = ff_vp9_loop_filter_v_16_16_##opt; \
dsp->loop_filter_mix2[0][0][0] = ff_vp9_loop_filter_h_44_16_##opt; \
dsp->loop_filter_mix2[0][0][1] = ff_vp9_loop_filter_v_44_16_##opt; \
dsp->loop_filter_mix2[0][1][0] = ff_vp9_loop_filter_h_48_16_##opt; \
dsp->loop_filter_mix2[0][1][1] = ff_vp9_loop_filter_v_48_16_##opt; \
dsp->loop_filter_mix2[1][0][0] = ff_vp9_loop_filter_h_84_16_##opt; \
dsp->loop_filter_mix2[1][0][1] = ff_vp9_loop_filter_v_84_16_##opt; \
dsp->loop_filter_mix2[1][1][0] = ff_vp9_loop_filter_h_88_16_##opt; \
dsp->loop_filter_mix2[1][1][1] = ff_vp9_loop_filter_v_88_16_##opt; \
} \
} while (0)
#define init_ipred(tx, sz, opt) do { \
dsp->intra_pred[tx][HOR_PRED] = ff_vp9_ipred_h_##sz##x##sz##_##opt; \
dsp->intra_pred[tx][DIAG_DOWN_LEFT_PRED] = ff_vp9_ipred_dl_##sz##x##sz##_##opt; \
dsp->intra_pred[tx][DIAG_DOWN_RIGHT_PRED] = ff_vp9_ipred_dr_##sz##x##sz##_##opt; \
dsp->intra_pred[tx][HOR_DOWN_PRED] = ff_vp9_ipred_hd_##sz##x##sz##_##opt; \
dsp->intra_pred[tx][VERT_LEFT_PRED] = ff_vp9_ipred_vl_##sz##x##sz##_##opt; \
dsp->intra_pred[tx][HOR_UP_PRED] = ff_vp9_ipred_hu_##sz##x##sz##_##opt; \
if (ARCH_X86_64 || tx != TX_32X32) { \
dsp->intra_pred[tx][VERT_RIGHT_PRED] = ff_vp9_ipred_vr_##sz##x##sz##_##opt; \
dsp->intra_pred[tx][TM_VP8_PRED] = ff_vp9_ipred_tm_##sz##x##sz##_##opt; \
} \
} while (0)
#define init_dc_ipred(tx, sz, opt) do { \
init_ipred(tx, sz, opt); \
dsp->intra_pred[tx][DC_PRED] = ff_vp9_ipred_dc_##sz##x##sz##_##opt; \
dsp->intra_pred[tx][LEFT_DC_PRED] = ff_vp9_ipred_dc_left_##sz##x##sz##_##opt; \
dsp->intra_pred[tx][TOP_DC_PRED] = ff_vp9_ipred_dc_top_##sz##x##sz##_##opt; \
} while (0)
if (EXTERNAL_MMX(cpu_flags)) {
init_fpel(4, 0, 4, put, mmx);
init_fpel(3, 0, 8, put, mmx);
dsp->itxfm_add[4 ][DCT_DCT] =
dsp->itxfm_add[4 ][ADST_DCT] =
dsp->itxfm_add[4 ][DCT_ADST] =
dsp->itxfm_add[4 ][ADST_ADST] = ff_vp9_iwht_iwht_4x4_add_mmx;
dsp->intra_pred[TX_8X8][VERT_PRED] = ff_vp9_ipred_v_8x8_mmx;
}
if (EXTERNAL_MMXEXT(cpu_flags)) {
init_fpel(4, 1, 4, avg, mmxext);
init_fpel(3, 1, 8, avg, mmxext);
dsp->itxfm_add[TX_4X4][DCT_DCT] = ff_vp9_idct_idct_4x4_add_mmxext;
}
if (EXTERNAL_SSE(cpu_flags)) {
init_fpel(2, 0, 16, put, sse);
init_fpel(1, 0, 32, put, sse);
init_fpel(0, 0, 64, put, sse);
}
if (EXTERNAL_SSE2(cpu_flags)) {
init_fpel(2, 1, 16, avg, sse2);
init_fpel(1, 1, 32, avg, sse2);
init_fpel(0, 1, 64, avg, sse2);
init_lpf(sse2);
dsp->itxfm_add[TX_4X4][ADST_DCT] = ff_vp9_idct_iadst_4x4_add_sse2;
dsp->itxfm_add[TX_4X4][DCT_ADST] = ff_vp9_iadst_idct_4x4_add_sse2;
dsp->itxfm_add[TX_4X4][ADST_ADST] = ff_vp9_iadst_iadst_4x4_add_sse2;
dsp->itxfm_add[TX_8X8][DCT_DCT] = ff_vp9_idct_idct_8x8_add_sse2;
dsp->itxfm_add[TX_8X8][ADST_DCT] = ff_vp9_idct_iadst_8x8_add_sse2;
dsp->itxfm_add[TX_8X8][DCT_ADST] = ff_vp9_iadst_idct_8x8_add_sse2;
dsp->itxfm_add[TX_8X8][ADST_ADST] = ff_vp9_iadst_iadst_8x8_add_sse2;
dsp->itxfm_add[TX_16X16][DCT_DCT] = ff_vp9_idct_idct_16x16_add_sse2;
dsp->itxfm_add[TX_16X16][ADST_DCT] = ff_vp9_idct_iadst_16x16_add_sse2;
dsp->itxfm_add[TX_16X16][DCT_ADST] = ff_vp9_iadst_idct_16x16_add_sse2;
dsp->itxfm_add[TX_16X16][ADST_ADST] = ff_vp9_iadst_iadst_16x16_add_sse2;
dsp->itxfm_add[TX_32X32][ADST_ADST] =
dsp->itxfm_add[TX_32X32][ADST_DCT] =
dsp->itxfm_add[TX_32X32][DCT_ADST] =
dsp->itxfm_add[TX_32X32][DCT_DCT] = ff_vp9_idct_idct_32x32_add_sse2;
dsp->intra_pred[TX_16X16][VERT_PRED] = ff_vp9_ipred_v_16x16_sse2;
dsp->intra_pred[TX_32X32][VERT_PRED] = ff_vp9_ipred_v_32x32_sse2;
}
if (EXTERNAL_SSSE3(cpu_flags)) {
init_subpel3(0, put, ssse3);
init_subpel3(1, avg, ssse3);
dsp->itxfm_add[TX_4X4][DCT_DCT] = ff_vp9_idct_idct_4x4_add_ssse3;
dsp->itxfm_add[TX_4X4][ADST_DCT] = ff_vp9_idct_iadst_4x4_add_ssse3;
dsp->itxfm_add[TX_4X4][DCT_ADST] = ff_vp9_iadst_idct_4x4_add_ssse3;
dsp->itxfm_add[TX_4X4][ADST_ADST] = ff_vp9_iadst_iadst_4x4_add_ssse3;
dsp->itxfm_add[TX_8X8][DCT_DCT] = ff_vp9_idct_idct_8x8_add_ssse3;
dsp->itxfm_add[TX_8X8][ADST_DCT] = ff_vp9_idct_iadst_8x8_add_ssse3;
dsp->itxfm_add[TX_8X8][DCT_ADST] = ff_vp9_iadst_idct_8x8_add_ssse3;
dsp->itxfm_add[TX_8X8][ADST_ADST] = ff_vp9_iadst_iadst_8x8_add_ssse3;
dsp->itxfm_add[TX_16X16][DCT_DCT] = ff_vp9_idct_idct_16x16_add_ssse3;
dsp->itxfm_add[TX_16X16][ADST_DCT] = ff_vp9_idct_iadst_16x16_add_ssse3;
dsp->itxfm_add[TX_16X16][DCT_ADST] = ff_vp9_iadst_idct_16x16_add_ssse3;
dsp->itxfm_add[TX_16X16][ADST_ADST] = ff_vp9_iadst_iadst_16x16_add_ssse3;
dsp->itxfm_add[TX_32X32][ADST_ADST] =
dsp->itxfm_add[TX_32X32][ADST_DCT] =
dsp->itxfm_add[TX_32X32][DCT_ADST] =
dsp->itxfm_add[TX_32X32][DCT_DCT] = ff_vp9_idct_idct_32x32_add_ssse3;
init_lpf(ssse3);
init_dc_ipred(TX_4X4, 4, ssse3);
init_dc_ipred(TX_8X8, 8, ssse3);
init_dc_ipred(TX_16X16, 16, ssse3);
init_dc_ipred(TX_32X32, 32, ssse3);
}
if (EXTERNAL_AVX(cpu_flags)) {
dsp->itxfm_add[TX_8X8][DCT_DCT] = ff_vp9_idct_idct_8x8_add_avx;
dsp->itxfm_add[TX_8X8][ADST_DCT] = ff_vp9_idct_iadst_8x8_add_avx;
dsp->itxfm_add[TX_8X8][DCT_ADST] = ff_vp9_iadst_idct_8x8_add_avx;
dsp->itxfm_add[TX_8X8][ADST_ADST] = ff_vp9_iadst_iadst_8x8_add_avx;
dsp->itxfm_add[TX_16X16][DCT_DCT] = ff_vp9_idct_idct_16x16_add_avx;
dsp->itxfm_add[TX_16X16][ADST_DCT] = ff_vp9_idct_iadst_16x16_add_avx;
dsp->itxfm_add[TX_16X16][DCT_ADST] = ff_vp9_iadst_idct_16x16_add_avx;
dsp->itxfm_add[TX_16X16][ADST_ADST] = ff_vp9_iadst_iadst_16x16_add_avx;
dsp->itxfm_add[TX_32X32][ADST_ADST] =
dsp->itxfm_add[TX_32X32][ADST_DCT] =
dsp->itxfm_add[TX_32X32][DCT_ADST] =
dsp->itxfm_add[TX_32X32][DCT_DCT] = ff_vp9_idct_idct_32x32_add_avx;
init_fpel(1, 0, 32, put, avx);
init_fpel(0, 0, 64, put, avx);
init_lpf(avx);
init_ipred(TX_8X8, 8, avx);
init_ipred(TX_16X16, 16, avx);
init_ipred(TX_32X32, 32, avx);
}
if (EXTERNAL_AVX2(cpu_flags)) {
init_fpel(1, 1, 32, avg, avx2);
init_fpel(0, 1, 64, avg, avx2);
if (ARCH_X86_64) {
#if ARCH_X86_64 && HAVE_AVX2_EXTERNAL
init_subpel2_32_64(0, 1, 1, hv, put, avx2);
init_subpel2_32_64(0, 0, 1, v, put, avx2);
init_subpel2_32_64(0, 1, 0, h, put, avx2);
init_subpel2_32_64(1, 1, 1, hv, avg, avx2);
init_subpel2_32_64(1, 0, 1, v, avg, avx2);
init_subpel2_32_64(1, 1, 0, h, avg, avx2);
#endif
}
dsp->intra_pred[TX_32X32][DC_PRED] = ff_vp9_ipred_dc_32x32_avx2;
dsp->intra_pred[TX_32X32][LEFT_DC_PRED] = ff_vp9_ipred_dc_left_32x32_avx2;
dsp->intra_pred[TX_32X32][TOP_DC_PRED] = ff_vp9_ipred_dc_top_32x32_avx2;
dsp->intra_pred[TX_32X32][VERT_PRED] = ff_vp9_ipred_v_32x32_avx2;
dsp->intra_pred[TX_32X32][HOR_PRED] = ff_vp9_ipred_h_32x32_avx2;
dsp->intra_pred[TX_32X32][TM_VP8_PRED] = ff_vp9_ipred_tm_32x32_avx2;
}
#undef init_fpel
#undef init_subpel1
#undef init_subpel2
#undef init_subpel3
#endif
}
| 1threat
|
static int adb_mouse_request(ADBDevice *d, uint8_t *obuf,
const uint8_t *buf, int len)
{
MouseState *s = ADB_MOUSE(d);
int cmd, reg, olen;
if ((buf[0] & 0x0f) == ADB_FLUSH) {
s->buttons_state = s->last_buttons_state;
s->dx = 0;
s->dy = 0;
s->dz = 0;
return 0;
}
cmd = buf[0] & 0xc;
reg = buf[0] & 0x3;
olen = 0;
switch(cmd) {
case ADB_WRITEREG:
ADB_DPRINTF("write reg %d val 0x%2.2x\n", reg, buf[1]);
switch(reg) {
case 2:
break;
case 3:
switch(buf[2]) {
case ADB_CMD_SELF_TEST:
break;
case ADB_CMD_CHANGE_ID:
case ADB_CMD_CHANGE_ID_AND_ACT:
case ADB_CMD_CHANGE_ID_AND_ENABLE:
d->devaddr = buf[1] & 0xf;
break;
default:
d->devaddr = buf[1] & 0xf;
if (buf[2] == 1 || buf[2] == 2) {
d->handler = buf[2];
}
break;
}
}
break;
case ADB_READREG:
switch(reg) {
case 0:
olen = adb_mouse_poll(d, obuf);
break;
case 1:
break;
case 3:
obuf[0] = d->handler;
obuf[1] = d->devaddr;
olen = 2;
break;
}
ADB_DPRINTF("read reg %d obuf[0] 0x%2.2x obuf[1] 0x%2.2x\n", reg,
obuf[0], obuf[1]);
break;
}
return olen;
}
| 1threat
|
How to fix "Parse error: syntax error, unexpected '}" : <p>I'm working with if statements, and I cannot seem to find where I'm going wrong, I'm fairly new to PHP so If someone can maybe guide me in the right direction it would be awesome, thanks.</p>
<p>I've tried to rewrite the whole code, and experimented by adding more "}" on the end of the code, which did not seem to work at all.</p>
<pre class="lang-php prettyprint-override"><code><?php
$username = "";
$email = "";
$errors = array();
//Connect to the database
$db = mysqli_connect('localhost', 'root', '', 'registration');
//If the register button is clicked
if (isset($_POST['register'])){
$username = mysql_real_escape_string($_POST['username']);
$email = mysql_real_escape_string($_POST['email']);
$password_1 = mysql_real_escape_string($_POST['password_1']);
$password_2 = mysql_real_escape_string($_POST['password_2']);
//Ensure that the form fields are filled correctly.
if (empty($username)){
array_push($errors, "A username is required.")}
if (empty($email)){
array_push($errors, "An email is required.")}
if (empty($password_1 != $password_2)){
array_push($errors, "Passwords do not match.")}
}
</code></pre>
| 0debug
|
Connot write a file : I have the following code:
import csv
import operator
import sys
with open('countryInfo.csv','r', encoding='utf-8') as csvfile:
reader = csv.DictReader(csvfile, delimiter='\t')
result = sorted(reader, key = lambda d: float(d['population']),reverse = True)
# for row in result:
# print(row)
# for row in result:
# print(row['name'], row['capital'], row['population'])
writer = csv.DictWriter(open('country_simple_info.csv', 'w', encoding='utf-8'), reader.fieldnames)
#with open("country_simple_info.csv", "w", encoding='utf-8') as csvoutfile:
writer.writeheader()
writer.writerows(result)
The goal of this code is to write a program that opens a countryInfo.csv file and extracts the country name, capital city and population from each row, then writes a new file named country_simple_info.csv with country, capital and population in each row, with the rows sorted by population size, largest first. The file has columns with other information such as continent, languages, etc. but the code should ignore those. In my code above, when I uncomment the print statements, the code can print the expected output- something in the following format:
country,capital,population
China,Beijing,1330044000
India,New Delhi,1173108018
United States,Washington,310232863
.......
However, I cannot get the file to be written. Any ideas? And also, I am not allowed to use pandas.
| 0debug
|
how to solve prime number program? : I'm trying to print all the prime numbers between 2 and 100, but i'm getting only 2 & 3.
I've tried every possible alternates, and it comes up with different error or different output.
```class vision{
```public static void main(String args[]){
```boolean flag=true;
```for( int i=2;i<=100;i++){
```for(int j=2;j<i;j++){
```if(i%j==0){
```flag=false;
```break;
```}
```}
```if(flag){
```System.out.println(i);
```}
```}
```}
```}
i don't need any alternate way , i just wanna know what's happening in my code and why it gives only 2 & 3.
| 0debug
|
static int vc1_decode_b_mb_intfr(VC1Context *v)
{
MpegEncContext *s = &v->s;
GetBitContext *gb = &s->gb;
int i, j;
int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
int cbp = 0;
int mqdiff, mquant;
int ttmb = v->ttfrm;
int mvsw = 0;
int mb_has_coeffs = 1;
int dmv_x, dmv_y;
int val;
int first_block = 1;
int dst_idx, off;
int skipped, direct, twomv = 0;
int block_cbp = 0, pat, block_tt = 0;
int idx_mbmode = 0, mvbp;
int stride_y, fieldtx;
int bmvtype = BMV_TYPE_BACKWARD;
int dir, dir2;
mquant = v->pq;
s->mb_intra = 0;
if (v->skip_is_raw)
skipped = get_bits1(gb);
else
skipped = v->s.mbskip_table[mb_pos];
if (!skipped) {
idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 2);
if (ff_vc1_mbmode_intfrp[0][idx_mbmode][0] == MV_PMODE_INTFR_2MV_FIELD) {
twomv = 1;
v->blk_mv_type[s->block_index[0]] = 1;
v->blk_mv_type[s->block_index[1]] = 1;
v->blk_mv_type[s->block_index[2]] = 1;
v->blk_mv_type[s->block_index[3]] = 1;
} else {
v->blk_mv_type[s->block_index[0]] = 0;
v->blk_mv_type[s->block_index[1]] = 0;
v->blk_mv_type[s->block_index[2]] = 0;
v->blk_mv_type[s->block_index[3]] = 0;
}
}
if (v->dmb_is_raw)
direct = get_bits1(gb);
else
direct = v->direct_mb_plane[mb_pos];
if (direct) {
s->mv[0][0][0] = s->current_picture.motion_val[0][s->block_index[0]][0] = scale_mv(s->next_picture.motion_val[1][s->block_index[0]][0], v->bfraction, 0, s->quarter_sample);
s->mv[0][0][1] = s->current_picture.motion_val[0][s->block_index[0]][1] = scale_mv(s->next_picture.motion_val[1][s->block_index[0]][1], v->bfraction, 0, s->quarter_sample);
s->mv[1][0][0] = s->current_picture.motion_val[1][s->block_index[0]][0] = scale_mv(s->next_picture.motion_val[1][s->block_index[0]][0], v->bfraction, 1, s->quarter_sample);
s->mv[1][0][1] = s->current_picture.motion_val[1][s->block_index[0]][1] = scale_mv(s->next_picture.motion_val[1][s->block_index[0]][1], v->bfraction, 1, s->quarter_sample);
if (twomv) {
s->mv[0][2][0] = s->current_picture.motion_val[0][s->block_index[2]][0] = scale_mv(s->next_picture.motion_val[1][s->block_index[2]][0], v->bfraction, 0, s->quarter_sample);
s->mv[0][2][1] = s->current_picture.motion_val[0][s->block_index[2]][1] = scale_mv(s->next_picture.motion_val[1][s->block_index[2]][1], v->bfraction, 0, s->quarter_sample);
s->mv[1][2][0] = s->current_picture.motion_val[1][s->block_index[2]][0] = scale_mv(s->next_picture.motion_val[1][s->block_index[2]][0], v->bfraction, 1, s->quarter_sample);
s->mv[1][2][1] = s->current_picture.motion_val[1][s->block_index[2]][1] = scale_mv(s->next_picture.motion_val[1][s->block_index[2]][1], v->bfraction, 1, s->quarter_sample);
for (i = 1; i < 4; i += 2) {
s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0] = s->mv[0][i-1][0];
s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1] = s->mv[0][i-1][1];
s->mv[1][i][0] = s->current_picture.motion_val[1][s->block_index[i]][0] = s->mv[1][i-1][0];
s->mv[1][i][1] = s->current_picture.motion_val[1][s->block_index[i]][1] = s->mv[1][i-1][1];
}
} else {
for (i = 1; i < 4; i++) {
s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0] = s->mv[0][0][0];
s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1] = s->mv[0][0][1];
s->mv[1][i][0] = s->current_picture.motion_val[1][s->block_index[i]][0] = s->mv[1][0][0];
s->mv[1][i][1] = s->current_picture.motion_val[1][s->block_index[i]][1] = s->mv[1][0][1];
}
}
}
if (ff_vc1_mbmode_intfrp[0][idx_mbmode][0] == MV_PMODE_INTFR_INTRA) {
for (i = 0; i < 4; i++) {
s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0] = 0;
s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1] = 0;
s->mv[1][i][0] = s->current_picture.motion_val[1][s->block_index[i]][0] = 0;
s->mv[1][i][1] = s->current_picture.motion_val[1][s->block_index[i]][1] = 0;
}
s->current_picture.mb_type[mb_pos] = MB_TYPE_INTRA;
s->mb_intra = v->is_intra[s->mb_x] = 1;
for (i = 0; i < 6; i++)
v->mb_type[0][s->block_index[i]] = 1;
fieldtx = v->fieldtx_plane[mb_pos] = get_bits1(gb);
mb_has_coeffs = get_bits1(gb);
if (mb_has_coeffs)
cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb);
GET_MQUANT();
s->current_picture.qscale_table[mb_pos] = mquant;
s->y_dc_scale = s->y_dc_scale_table[mquant];
s->c_dc_scale = s->c_dc_scale_table[mquant];
dst_idx = 0;
for (i = 0; i < 6; i++) {
s->dc_val[0][s->block_index[i]] = 0;
dst_idx += i >> 2;
val = ((cbp >> (5 - i)) & 1);
v->mb_type[0][s->block_index[i]] = s->mb_intra;
v->a_avail = v->c_avail = 0;
if (i == 2 || i == 3 || !s->first_slice_line)
v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];
if (i == 1 || i == 3 || s->mb_x)
v->c_avail = v->mb_type[0][s->block_index[i] - 1];
vc1_decode_intra_block(v, s->block[i], i, val, mquant,
(i & 4) ? v->codingset2 : v->codingset);
if (i > 3 && (s->flags & CODEC_FLAG_GRAY))
continue;
v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
if (i < 4) {
stride_y = s->linesize << fieldtx;
off = (fieldtx) ? ((i & 1) * 8) + ((i & 2) >> 1) * s->linesize : (i & 1) * 8 + 4 * (i & 2) * s->linesize;
} else {
stride_y = s->uvlinesize;
off = 0;
}
s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, stride_y);
}
} else {
s->mb_intra = v->is_intra[s->mb_x] = 0;
if (!direct) {
if (skipped || !s->mb_intra) {
bmvtype = decode012(gb);
switch (bmvtype) {
case 0:
bmvtype = (v->bfraction >= (B_FRACTION_DEN/2)) ? BMV_TYPE_BACKWARD : BMV_TYPE_FORWARD;
break;
case 1:
bmvtype = (v->bfraction >= (B_FRACTION_DEN/2)) ? BMV_TYPE_FORWARD : BMV_TYPE_BACKWARD;
break;
case 2:
bmvtype = BMV_TYPE_INTERPOLATED;
}
}
if (twomv && bmvtype != BMV_TYPE_INTERPOLATED)
mvsw = get_bits1(gb);
}
if (!skipped) {
mb_has_coeffs = ff_vc1_mbmode_intfrp[0][idx_mbmode][3];
if (mb_has_coeffs)
cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
if (!direct) {
if (bmvtype == BMV_TYPE_INTERPOLATED && twomv) {
v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
} else if (bmvtype == BMV_TYPE_INTERPOLATED || twomv) {
v->twomvbp = get_vlc2(gb, v->twomvbp_vlc->table, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 1);
}
}
for (i = 0; i < 6; i++)
v->mb_type[0][s->block_index[i]] = 0;
fieldtx = v->fieldtx_plane[mb_pos] = ff_vc1_mbmode_intfrp[0][idx_mbmode][1];
dst_idx = 0;
if (direct) {
if (twomv) {
for (i = 0; i < 4; i++) {
vc1_mc_4mv_luma(v, i, 0, 0);
vc1_mc_4mv_luma(v, i, 1, 1);
}
vc1_mc_4mv_chroma4(v, 0, 0, 0);
vc1_mc_4mv_chroma4(v, 1, 1, 1);
} else {
vc1_mc_1mv(v, 0);
vc1_interp_mc(v);
}
} else if (twomv && bmvtype == BMV_TYPE_INTERPOLATED) {
mvbp = v->fourmvbp;
for (i = 0; i < 4; i++) {
dir = i==1 || i==3;
dmv_x = dmv_y = 0;
val = ((mvbp >> (3 - i)) & 1);
if (val)
get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
j = i > 1 ? 2 : 0;
vc1_pred_mv_intfr(v, j, dmv_x, dmv_y, 2, v->range_x, v->range_y, v->mb_type[0], dir);
vc1_mc_4mv_luma(v, j, dir, dir);
vc1_mc_4mv_luma(v, j+1, dir, dir);
}
vc1_mc_4mv_chroma4(v, 0, 0, 0);
vc1_mc_4mv_chroma4(v, 1, 1, 1);
} else if (bmvtype == BMV_TYPE_INTERPOLATED) {
mvbp = v->twomvbp;
dmv_x = dmv_y = 0;
if (mvbp & 2)
get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0], 0);
vc1_mc_1mv(v, 0);
dmv_x = dmv_y = 0;
if (mvbp & 1)
get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0], 1);
vc1_interp_mc(v);
} else if (twomv) {
dir = bmvtype == BMV_TYPE_BACKWARD;
dir2 = dir;
if (mvsw)
dir2 = !dir;
mvbp = v->twomvbp;
dmv_x = dmv_y = 0;
if (mvbp & 2)
get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 2, v->range_x, v->range_y, v->mb_type[0], dir);
dmv_x = dmv_y = 0;
if (mvbp & 1)
get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
vc1_pred_mv_intfr(v, 2, dmv_x, dmv_y, 2, v->range_x, v->range_y, v->mb_type[0], dir2);
if (mvsw) {
for (i = 0; i < 2; i++) {
s->mv[dir][i+2][0] = s->mv[dir][i][0] = s->current_picture.motion_val[dir][s->block_index[i+2]][0] = s->current_picture.motion_val[dir][s->block_index[i]][0];
s->mv[dir][i+2][1] = s->mv[dir][i][1] = s->current_picture.motion_val[dir][s->block_index[i+2]][1] = s->current_picture.motion_val[dir][s->block_index[i]][1];
s->mv[dir2][i+2][0] = s->mv[dir2][i][0] = s->current_picture.motion_val[dir2][s->block_index[i]][0] = s->current_picture.motion_val[dir2][s->block_index[i+2]][0];
s->mv[dir2][i+2][1] = s->mv[dir2][i][1] = s->current_picture.motion_val[dir2][s->block_index[i]][1] = s->current_picture.motion_val[dir2][s->block_index[i+2]][1];
}
} else {
vc1_pred_mv_intfr(v, 0, 0, 0, 2, v->range_x, v->range_y, v->mb_type[0], !dir);
vc1_pred_mv_intfr(v, 2, 0, 0, 2, v->range_x, v->range_y, v->mb_type[0], !dir);
}
vc1_mc_4mv_luma(v, 0, dir, 0);
vc1_mc_4mv_luma(v, 1, dir, 0);
vc1_mc_4mv_luma(v, 2, dir2, 0);
vc1_mc_4mv_luma(v, 3, dir2, 0);
vc1_mc_4mv_chroma4(v, dir, dir2, 0);
} else {
dir = bmvtype == BMV_TYPE_BACKWARD;
mvbp = ff_vc1_mbmode_intfrp[0][idx_mbmode][2];
dmv_x = dmv_y = 0;
if (mvbp)
get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0], dir);
v->blk_mv_type[s->block_index[0]] = 1;
v->blk_mv_type[s->block_index[1]] = 1;
v->blk_mv_type[s->block_index[2]] = 1;
v->blk_mv_type[s->block_index[3]] = 1;
vc1_pred_mv_intfr(v, 0, 0, 0, 2, v->range_x, v->range_y, 0, !dir);
for (i = 0; i < 2; i++) {
s->mv[!dir][i+2][0] = s->mv[!dir][i][0] = s->current_picture.motion_val[!dir][s->block_index[i+2]][0] = s->current_picture.motion_val[!dir][s->block_index[i]][0];
s->mv[!dir][i+2][1] = s->mv[!dir][i][1] = s->current_picture.motion_val[!dir][s->block_index[i+2]][1] = s->current_picture.motion_val[!dir][s->block_index[i]][1];
}
vc1_mc_1mv(v, dir);
}
if (cbp)
GET_MQUANT();
s->current_picture.qscale_table[mb_pos] = mquant;
if (!v->ttmbf && cbp)
ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
for (i = 0; i < 6; i++) {
s->dc_val[0][s->block_index[i]] = 0;
dst_idx += i >> 2;
val = ((cbp >> (5 - i)) & 1);
if (!fieldtx)
off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
else
off = (i & 4) ? 0 : ((i & 1) * 8 + ((i > 1) * s->linesize));
if (val) {
pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,
first_block, s->dest[dst_idx] + off,
(i & 4) ? s->uvlinesize : (s->linesize << fieldtx),
(i & 4) && (s->flags & CODEC_FLAG_GRAY), &block_tt);
block_cbp |= pat << (i << 2);
if (!v->ttmbf && ttmb < 8)
ttmb = -1;
first_block = 0;
}
}
} else {
dir = 0;
for (i = 0; i < 6; i++) {
v->mb_type[0][s->block_index[i]] = 0;
s->dc_val[0][s->block_index[i]] = 0;
}
s->current_picture.mb_type[mb_pos] = MB_TYPE_SKIP;
s->current_picture.qscale_table[mb_pos] = 0;
v->blk_mv_type[s->block_index[0]] = 0;
v->blk_mv_type[s->block_index[1]] = 0;
v->blk_mv_type[s->block_index[2]] = 0;
v->blk_mv_type[s->block_index[3]] = 0;
if (!direct) {
if (bmvtype == BMV_TYPE_INTERPOLATED) {
vc1_pred_mv_intfr(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0], 0);
vc1_pred_mv_intfr(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0], 1);
} else {
dir = bmvtype == BMV_TYPE_BACKWARD;
vc1_pred_mv_intfr(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0], dir);
if (mvsw) {
int dir2 = dir;
if (mvsw)
dir2 = !dir;
for (i = 0; i < 2; i++) {
s->mv[dir][i+2][0] = s->mv[dir][i][0] = s->current_picture.motion_val[dir][s->block_index[i+2]][0] = s->current_picture.motion_val[dir][s->block_index[i]][0];
s->mv[dir][i+2][1] = s->mv[dir][i][1] = s->current_picture.motion_val[dir][s->block_index[i+2]][1] = s->current_picture.motion_val[dir][s->block_index[i]][1];
s->mv[dir2][i+2][0] = s->mv[dir2][i][0] = s->current_picture.motion_val[dir2][s->block_index[i]][0] = s->current_picture.motion_val[dir2][s->block_index[i+2]][0];
s->mv[dir2][i+2][1] = s->mv[dir2][i][1] = s->current_picture.motion_val[dir2][s->block_index[i]][1] = s->current_picture.motion_val[dir2][s->block_index[i+2]][1];
}
} else {
v->blk_mv_type[s->block_index[0]] = 1;
v->blk_mv_type[s->block_index[1]] = 1;
v->blk_mv_type[s->block_index[2]] = 1;
v->blk_mv_type[s->block_index[3]] = 1;
vc1_pred_mv_intfr(v, 0, 0, 0, 2, v->range_x, v->range_y, 0, !dir);
for (i = 0; i < 2; i++) {
s->mv[!dir][i+2][0] = s->mv[!dir][i][0] = s->current_picture.motion_val[!dir][s->block_index[i+2]][0] = s->current_picture.motion_val[!dir][s->block_index[i]][0];
s->mv[!dir][i+2][1] = s->mv[!dir][i][1] = s->current_picture.motion_val[!dir][s->block_index[i+2]][1] = s->current_picture.motion_val[!dir][s->block_index[i]][1];
}
}
}
}
vc1_mc_1mv(v, dir);
if (direct || bmvtype == BMV_TYPE_INTERPOLATED) {
vc1_interp_mc(v);
}
}
}
if (s->mb_x == s->mb_width - 1)
memmove(v->is_intra_base, v->is_intra, sizeof(v->is_intra_base[0]) * s->mb_stride);
v->cbp[s->mb_x] = block_cbp;
v->ttblk[s->mb_x] = block_tt;
return 0;
}
| 1threat
|
why i cant write just meter instead of "meter' in python 2.7.14? : i use python 2.7.14.....i wrote this code in python andriod Qpython3 version....but when i used it in python 2.7.14 the programme accepts strings with these " " or ' ' .......in Qpython3 i just had to to write meter....here i have to write "meter" .....
any suggestion how to solve it?
here is the code:
import time
print("This is a converter.Here, you have to spell the whole name of a unit otherwise it wont work")
print(' ')
def converter():
a=float(input("Enter a number:" ))
print(" ")
x=input("from:" )
print(" ")
y=input("to:" )
print(" ")
if x=="meter" and y=="kilometer" or x=="gram" and y=="kilogram":
print(a/1000)
elif x=="kilometer" and y=="meter" or x=="kilogram" and y=="gram":
print(a*1000)
#just keep adding more convertions starting with elifs inside the define function
#and keep the else statement at the end of all elifs...
#and that converter() function call it at the all end just once...
#infact dont do anything escept adding elif statements....good luck
#dont change that float it accepts both integer and float
else :
print("wrong")
print(" ")
print('To continue type "next",Thank you.')
print(" ")
print('To exit type "quit",Thank you.')
print(" ")
s=input()
if s=="next":
print(" ")
converter()
elif s=="quit":
time.sleep(1)
else:
print("I Can't understand your command")
converter()
| 0debug
|
Server only receiving null string from client? : <p>So I have a basic client/server c++ program. Right now, when the client connects to the server I want the server sends a "Hello, world" message and the client to respond "Hello, server" just to make sure I am sending and relieving messages correctly. </p>
<p>When I run, the client receives the message from the server, but the server only receives a null string from the client. </p>
<p>Here is the code for the client</p>
<pre><code>int main(int argc, char *argv[]) {
int sockfd, numbytes;
char buf[MAXDATASIZE];
struct addrinfo hints, *servinfo, *p;
int rv;
char s[INET6_ADDRSTRLEN];
if (argc != 2) {
fprintf(stderr,"usage: client hostname\n");
exit(1);
}
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
if ((rv = getaddrinfo(argv[1], PORT, &hints, &servinfo)) != 0) {
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
return 1;
}
// loop through all the results and connect to the first we can
for(p = servinfo; p != NULL; p = p->ai_next) {
if ((sockfd = socket(p->ai_family, p->ai_socktype,
p->ai_protocol)) == -1) {
perror("client: socket");
continue;
}
if (connect(sockfd, p->ai_addr, p->ai_addrlen) == -1) {
close(sockfd);
perror("client: connect");
continue;
}
break;
}
if (p == NULL) {
fprintf(stderr, "client: failed to connect\n");
return 2;
}
inet_ntop(p->ai_family, get_in_addr((struct sockaddr *)p->ai_addr),
s, sizeof s);
printf("client: connecting to %s\n", s);
freeaddrinfo(servinfo); // all done with this structure
if ((numbytes = recv(sockfd, buf, MAXDATASIZE-1, 0)) == -1) {
perror("recv");
exit(1);
}
if (send(sockfd, "Hello, client!", 13, 0) == -1) {
perror("send");
}
buf[numbytes] = '\0';
printf("client: received '%s'\n",buf);
close(sockfd);
return 0;
}
</code></pre>
<p>and Here's the code for the server</p>
<pre><code>int main(void)
{
int sockfd, new_fd, numbytes; // listen on sock_fd, new connection on new_fd
char buf[MAXDATASIZE];
struct addrinfo hints, *servinfo, *p;
struct sockaddr_storage their_addr; // connector's address information
socklen_t sin_size;
struct sigaction sa;
int yes=1;
char s[INET6_ADDRSTRLEN];
int rv;
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE; // use my IP
if ((rv = getaddrinfo(NULL, PORT, &hints, &servinfo)) != 0) {
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
return 1;
}
// loop through all the results and bind to the first we can
for(p = servinfo; p != NULL; p = p->ai_next) {
if ((sockfd = socket(p->ai_family, p->ai_socktype,
p->ai_protocol)) == -1) {
perror("server: socket");
continue;
}
if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &yes,
sizeof(int)) == -1) {
perror("setsockopt");
exit(1);
}
if (bind(sockfd, p->ai_addr, p->ai_addrlen) == -1) {
close(sockfd);
perror("server: bind");
continue;
}
break;
}
freeaddrinfo(servinfo); // all done with this structure
if (p == NULL) {
fprintf(stderr, "server: failed to bind\n");
exit(1);
}
if (listen(sockfd, BACKLOG) == -1) {
perror("listen");
exit(1);
}
sa.sa_handler = sigchld_handler; // reap all dead processes
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART;
if (sigaction(SIGCHLD, &sa, NULL) == -1) {
perror("sigaction");
exit(1);
}
printf("server: waiting for connections...\n");
while(1) { // main accept() loop
sin_size = sizeof their_addr;
new_fd = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size);
if (new_fd == -1) {
perror("accept");
continue;
}
inet_ntop(their_addr.ss_family,
get_in_addr((struct sockaddr *)&their_addr),
s, sizeof s);
printf("server: got connection from %s\n", s);
if (!fork()) { // this is the child process
close(sockfd); // child doesn't need the listener
if (send(new_fd, "Hello, world!", 13, 0) == -1)
perror("send");
if (numbytes = recv(new_fd, &buf, MAXDATASIZE-1, 0) == -1) {
perror("recv");
exit(1);
}
buf[numbytes] = '\0';
printf("server: received '%s'\n",buf);
close(new_fd);
exit(0);
}
close(new_fd); // parent doesn't need this
}
return 0;
}
</code></pre>
| 0debug
|
static void usb_host_auto_check(void *unused)
{
struct USBHostDevice *s;
int unconnected = 0;
usb_host_scan(NULL, usb_host_auto_scan);
QTAILQ_FOREACH(s, &hostdevs, next) {
if (s->fd == -1) {
unconnected++;
}
}
if (unconnected == 0) {
if (usb_auto_timer) {
qemu_del_timer(usb_auto_timer);
}
return;
}
if (!usb_auto_timer) {
usb_auto_timer = qemu_new_timer(rt_clock, usb_host_auto_check, NULL);
if (!usb_auto_timer) {
return;
}
}
qemu_mod_timer(usb_auto_timer, qemu_get_clock(rt_clock) + 2000);
}
| 1threat
|
static int smka_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
GetBitContext gb;
HuffContext h[4] = { { 0 } };
VLC vlc[4] = { { 0 } };
int16_t *samples;
uint8_t *samples8;
int val;
int i, res, ret;
int unp_size;
int bits, stereo;
int pred[2] = {0, 0};
if (buf_size <= 4) {
av_log(avctx, AV_LOG_ERROR, "packet is too small\n");
return AVERROR(EINVAL);
}
unp_size = AV_RL32(buf);
init_get_bits(&gb, buf + 4, (buf_size - 4) * 8);
if(!get_bits1(&gb)){
av_log(avctx, AV_LOG_INFO, "Sound: no data\n");
*got_frame_ptr = 0;
return 1;
}
stereo = get_bits1(&gb);
bits = get_bits1(&gb);
if (stereo ^ (avctx->channels != 1)) {
av_log(avctx, AV_LOG_ERROR, "channels mismatch\n");
return AVERROR(EINVAL);
}
if (bits && avctx->sample_fmt == AV_SAMPLE_FMT_U8) {
av_log(avctx, AV_LOG_ERROR, "sample format mismatch\n");
return AVERROR(EINVAL);
}
frame->nb_samples = unp_size / (avctx->channels * (bits + 1));
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
samples = (int16_t *)frame->data[0];
samples8 = frame->data[0];
for(i = 0; i < (1 << (bits + stereo)); i++) {
h[i].length = 256;
h[i].maxlength = 0;
h[i].current = 0;
h[i].bits = av_mallocz(256 * 4);
h[i].lengths = av_mallocz(256 * sizeof(int));
h[i].values = av_mallocz(256 * sizeof(int));
skip_bits1(&gb);
smacker_decode_tree(&gb, &h[i], 0, 0);
skip_bits1(&gb);
if(h[i].current > 1) {
res = init_vlc(&vlc[i], SMKTREE_BITS, h[i].length,
h[i].lengths, sizeof(int), sizeof(int),
h[i].bits, sizeof(uint32_t), sizeof(uint32_t), INIT_VLC_LE);
if(res < 0) {
av_log(avctx, AV_LOG_ERROR, "Cannot build VLC table\n");
return -1;
}
}
}
if(bits) {
for(i = stereo; i >= 0; i--)
pred[i] = sign_extend(av_bswap16(get_bits(&gb, 16)), 16);
for(i = 0; i <= stereo; i++)
*samples++ = pred[i];
for(; i < unp_size / 2; i++) {
if(i & stereo) {
if(vlc[2].table)
res = get_vlc2(&gb, vlc[2].table, SMKTREE_BITS, 3);
else
res = 0;
val = h[2].values[res];
if(vlc[3].table)
res = get_vlc2(&gb, vlc[3].table, SMKTREE_BITS, 3);
else
res = 0;
val |= h[3].values[res] << 8;
pred[1] += sign_extend(val, 16);
*samples++ = pred[1];
} else {
if(vlc[0].table)
res = get_vlc2(&gb, vlc[0].table, SMKTREE_BITS, 3);
else
res = 0;
val = h[0].values[res];
if(vlc[1].table)
res = get_vlc2(&gb, vlc[1].table, SMKTREE_BITS, 3);
else
res = 0;
val |= h[1].values[res] << 8;
pred[0] += sign_extend(val, 16);
*samples++ = pred[0];
}
}
} else {
for(i = stereo; i >= 0; i--)
pred[i] = get_bits(&gb, 8);
for(i = 0; i <= stereo; i++)
*samples8++ = pred[i];
for(; i < unp_size; i++) {
if(i & stereo){
if(vlc[1].table)
res = get_vlc2(&gb, vlc[1].table, SMKTREE_BITS, 3);
else
res = 0;
pred[1] += sign_extend(h[1].values[res], 8);
*samples8++ = pred[1];
} else {
if(vlc[0].table)
res = get_vlc2(&gb, vlc[0].table, SMKTREE_BITS, 3);
else
res = 0;
pred[0] += sign_extend(h[0].values[res], 8);
*samples8++ = pred[0];
}
}
}
for(i = 0; i < 4; i++) {
if(vlc[i].table)
ff_free_vlc(&vlc[i]);
av_free(h[i].bits);
av_free(h[i].lengths);
av_free(h[i].values);
}
*got_frame_ptr = 1;
return buf_size;
}
| 1threat
|
VBScript: Reading and Writing text file when condition are meet : I have a text file Sample.txt with that contains thousands of records.
See below. I have created vbscript that accept input box for the cut-off record. In this example I inputted 10005 as the cut-off record.
The script will then read all records after the cut-off record, in this case starting at 10006 down to 10010, then write to a new text file with the current date as file name like 20180920.txt
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
Expected output:
10006
10007
10008
10009
10010
| 0debug
|
int ff_thread_can_start_frame(AVCodecContext *avctx)
{
PerThreadContext *p = avctx->thread_opaque;
if ((avctx->active_thread_type&FF_THREAD_FRAME) && p->state != STATE_SETTING_UP &&
(avctx->codec->update_thread_context || (!avctx->thread_safe_callbacks &&
avctx->get_buffer != avcodec_default_get_buffer))) {
return 0;
}
return 1;
}
| 1threat
|
target_ulong do_load_msr (CPUPPCState *env)
{
return
#if defined (TARGET_PPC64)
((target_ulong)msr_sf << MSR_SF) |
((target_ulong)msr_isf << MSR_ISF) |
((target_ulong)msr_hv << MSR_HV) |
#endif
((target_ulong)msr_ucle << MSR_UCLE) |
((target_ulong)msr_vr << MSR_VR) |
((target_ulong)msr_ap << MSR_AP) |
((target_ulong)msr_sa << MSR_SA) |
((target_ulong)msr_key << MSR_KEY) |
((target_ulong)msr_pow << MSR_POW) |
((target_ulong)msr_tgpr << MSR_TGPR) |
((target_ulong)msr_ile << MSR_ILE) |
((target_ulong)msr_ee << MSR_EE) |
((target_ulong)msr_pr << MSR_PR) |
((target_ulong)msr_fp << MSR_FP) |
((target_ulong)msr_me << MSR_ME) |
((target_ulong)msr_fe0 << MSR_FE0) |
((target_ulong)msr_se << MSR_SE) |
((target_ulong)msr_be << MSR_BE) |
((target_ulong)msr_fe1 << MSR_FE1) |
((target_ulong)msr_al << MSR_AL) |
((target_ulong)msr_ip << MSR_IP) |
((target_ulong)msr_ir << MSR_IR) |
((target_ulong)msr_dr << MSR_DR) |
((target_ulong)msr_pe << MSR_PE) |
((target_ulong)msr_px << MSR_PX) |
((target_ulong)msr_ri << MSR_RI) |
((target_ulong)msr_le << MSR_LE);
}
| 1threat
|
Winston: Attempt to write logs with no transports : <p>I'm trying to set up an access log and an error log for my express server using Winston, but I seem to be doing something wrong.</p>
<p>Here is my attempt at a config file:</p>
<pre><code>const winston = require('winston'),
fs = require('fs');
const tsFormat = () => (new Date()).toLocaleTimeString();
winston.loggers.add('errorLog', {
file: {
filename: '<path>/errors.log', //<path> is replaced by the
timestamp: tsFormat, //absolute path of the log
level: 'info'
}
});
winston.loggers.add('accessLog', {
file: {
filename: '<path>/access.log', //same as before
timestamp: tsFormat,
level: 'info'
}
});
</code></pre>
<p>And this is how I'm including it in my other files:</p>
<pre><code>var winston = require('winston'),
accessLog = winston.loggers.get('accessLog'),
errorLog = winston.loggers.get('errorLog');
</code></pre>
<p>This seems to me like it follows the documentation (<a href="https://github.com/winstonjs/winston/tree/2.4.0#working-with-multiple-loggers-in-winston" rel="noreferrer">https://github.com/winstonjs/winston/tree/2.4.0#working-with-multiple-loggers-in-winston</a>)
but I'm getting this error when I try to log to it:</p>
<pre><code>[winston] Attempt to write logs with no transports {"message":"pls","level":"info"}
[winston] Attempt to write logs with no transports {"message":"Bad request: undefined","level":"warn"}
</code></pre>
<p>Any help would be greatly appreciated, I've been pretty stumped for a couple days now.</p>
| 0debug
|
Can't access open cart Admin from iphone : <p>I have installed opencart on my server and everything seems to be working fine except for the fact that I can't access the admin dashboard through my iphone. It works fine on my PC, on a Mac, and on an android Phone like a Galaxy note 4.</p>
<p>I can't seem to find any information on this. It doesn't generate any errors. the only thing it does is reload the admin sign in screen. If the password is incorrect it displays the error message but if the username and password are correct it doesn't go in.</p>
<p>Any ideas as to what might be happening?</p>
| 0debug
|
Difference between MappingProxyType and PEP 416 frozendict : <p>While <code>frozendict</code> <a href="https://www.python.org/dev/peps/pep-0416/#rejection-notice" rel="noreferrer">was rejected</a>, a related class <code>types.MappingProxyType</code> was added to public API in python 3.3.</p>
<p>I understand <code>MappingProxyType</code> is just a wrapper around the underlying <code>dict</code>, but despite that isn't it functionally equivalent to <code>frozendict</code>?</p>
<p>In other words, what's the substantive difference between the original PEP 416 <code>frozendict</code> and this:</p>
<pre><code>from types import MappingProxyType
def frozendict(*args, **kwargs):
return MappingProxyType(dict(*args, **kwargs))
</code></pre>
<p>Of course <code>MappingProxyType</code> is not hashable as is, but just as <a href="https://www.python.org/dev/peps/pep-0416/#recipe-hashable-dict" rel="noreferrer">the PEP suggested for <code>frozendict</code></a>, it can be made hashable after ensuring that all its values are hashable (MappingProxyType cannot be subclassed, so it would be require composition and forwarding of methods).</p>
| 0debug
|
static void dec_divu(DisasContext *dc)
{
int l1;
LOG_DIS("divu r%d, r%d, r%d\n", dc->r2, dc->r0, dc->r1);
if (!(dc->features & LM32_FEATURE_DIVIDE)) {
qemu_log_mask(LOG_GUEST_ERROR, "hardware divider is not available\n");
t_gen_illegal_insn(dc);
return;
}
l1 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_NE, cpu_R[dc->r1], 0, l1);
tcg_gen_movi_tl(cpu_pc, dc->pc);
t_gen_raise_exception(dc, EXCP_DIVIDE_BY_ZERO);
gen_set_label(l1);
tcg_gen_divu_tl(cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]);
}
| 1threat
|
what is the difference between "FCM(Fuzzy C Means)" and "GMM(Gaussian Mixture Model)"? : I am having pattern recognition class. My teacher need us to find out the difference between FCM and GMM,but I think this two clusting algorithm have no similarity.Hoping someone who knows could help me.
| 0debug
|
static int protocol_client_auth(VncState *vs, uint8_t *data, size_t len)
{
if (data[0] != vs->auth) {
VNC_DEBUG("Reject auth %d because it didn't match advertized\n", (int)data[0]);
vnc_write_u32(vs, 1);
if (vs->minor >= 8) {
static const char err[] = "Authentication failed";
vnc_write_u32(vs, sizeof(err));
vnc_write(vs, err, sizeof(err));
}
vnc_client_error(vs);
} else {
VNC_DEBUG("Client requested auth %d\n", (int)data[0]);
switch (vs->auth) {
case VNC_AUTH_NONE:
VNC_DEBUG("Accept auth none\n");
if (vs->minor >= 8) {
vnc_write_u32(vs, 0);
vnc_flush(vs);
}
start_client_init(vs);
break;
case VNC_AUTH_VNC:
VNC_DEBUG("Start VNC auth\n");
start_auth_vnc(vs);
break;
case VNC_AUTH_VENCRYPT:
VNC_DEBUG("Accept VeNCrypt auth\n");
start_auth_vencrypt(vs);
break;
#ifdef CONFIG_VNC_SASL
case VNC_AUTH_SASL:
VNC_DEBUG("Accept SASL auth\n");
start_auth_sasl(vs);
break;
#endif
default:
VNC_DEBUG("Reject auth %d server code bug\n", vs->auth);
vnc_write_u8(vs, 1);
if (vs->minor >= 8) {
static const char err[] = "Authentication failed";
vnc_write_u32(vs, sizeof(err));
vnc_write(vs, err, sizeof(err));
}
vnc_client_error(vs);
}
}
return 0;
}
| 1threat
|
Why does developer tools have a different server response time to a profiler? : I have enabled a PHP profiler, well magento, but it is still a profiler.
The results show pretty decent server response times, but on the chrome developer tools the time is much higher.
Profiler:
[![magento-profiler-server-response][1]][1]
Developer tools:
[![TTFB-chrome-developer-tools][2]][2]
[1]: http://i.stack.imgur.com/13kag.png
[2]: http://i.stack.imgur.com/ltfPC.png
| 0debug
|
AVD3D11VAContext *av_d3d11va_alloc_context(void)
{
AVD3D11VAContext* res = av_mallocz(sizeof(AVD3D11VAContext));
res->context_mutex = INVALID_HANDLE_VALUE;
return res;
}
| 1threat
|
i got this error : Parse error: syntax error, unexpected ';' : <p>please help me with this error
i could not find the solution. here's the code :</p>
<pre><code>public function store_image($id) {
$db = connection();
$if ($db->connect_errno == 0) {
$sql = "SELECT * from car where id='$id'";
$res = $db->query($sql);
while ($row = $db->fetch_assoc($res)) {
$pic = $row['pic'];
}
header("content_type: image/jpg");
}
}
</code></pre>
<p>the error says "Parse error: syntax error, unexpected ';'" on this line :</p>
<pre><code>$sql = "SELECT * from car where id='$id'";
</code></pre>
<p>thanks in advance</p>
| 0debug
|
int ff_nvdec_start_frame(AVCodecContext *avctx, AVFrame *frame)
{
NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
FrameDecodeData *fdd = (FrameDecodeData*)frame->private_ref->data;
NVDECFrame *cf = NULL;
int ret;
ctx->bitstream_len = 0;
ctx->nb_slices = 0;
if (fdd->hwaccel_priv)
return 0;
cf = av_mallocz(sizeof(*cf));
if (!cf)
return AVERROR(ENOMEM);
cf->decoder_ref = av_buffer_ref(ctx->decoder_ref);
if (!cf->decoder_ref)
goto fail;
cf->idx_ref = av_buffer_pool_get(ctx->decoder_pool);
if (!cf->idx_ref) {
av_log(avctx, AV_LOG_ERROR, "No decoder surfaces left\n");
ret = AVERROR(ENOMEM);
goto fail;
}
cf->idx = *(unsigned int*)cf->idx_ref->data;
fdd->hwaccel_priv = cf;
fdd->hwaccel_priv_free = nvdec_fdd_priv_free;
fdd->post_process = nvdec_retrieve_data;
return 0;
fail:
nvdec_fdd_priv_free(cf);
return ret;
}
| 1threat
|
static uint64_t mv88w8618_eth_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
mv88w8618_eth_state *s = opaque;
switch (offset) {
case MP_ETH_SMIR:
if (s->smir & MP_ETH_SMIR_OPCODE) {
switch (s->smir & MP_ETH_SMIR_ADDR) {
case MP_ETH_PHY1_BMSR:
return MP_PHY_BMSR_LINK | MP_PHY_BMSR_AUTONEG |
MP_ETH_SMIR_RDVALID;
case MP_ETH_PHY1_PHYSID1:
return (MP_PHY_88E3015 >> 16) | MP_ETH_SMIR_RDVALID;
case MP_ETH_PHY1_PHYSID2:
return (MP_PHY_88E3015 & 0xFFFF) | MP_ETH_SMIR_RDVALID;
default:
return MP_ETH_SMIR_RDVALID;
}
}
return 0;
case MP_ETH_ICR:
return s->icr;
case MP_ETH_IMR:
return s->imr;
case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
return s->frx_queue[(offset - MP_ETH_FRDP0)/4];
case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
return s->rx_queue[(offset - MP_ETH_CRDP0)/4];
case MP_ETH_CTDP0 ... MP_ETH_CTDP3:
return s->tx_queue[(offset - MP_ETH_CTDP0)/4];
default:
return 0;
}
}
| 1threat
|
static void show_parts(const char *device)
{
if (fork() == 0) {
int nbd;
nbd = open(device, O_RDWR);
if (nbd != -1)
close(nbd);
exit(0);
}
}
| 1threat
|
How to make sublists comprised of unique values from a larger list - python : <p>I have a large list that I want to divide into smaller lists with unique values.</p>
<pre><code>BigList = [2, 1, 0, 2, 2, 1, 2, 1, 0, 3, 0, 1, 3]
</code></pre>
<p>How do I divide it into smaller lists of unique values, which were originally in the bigger list (desired output below):</p>
<pre><code>L1 = [2, 1, 0]
L2 = [2]
L3 = [2, 1]
L4 = [2, 1, 0, 3]
L5 = [0, 1, 3]
</code></pre>
<p>Note that each of the sublists don't have duplicate values, they can have a different number of indexes and all the values in all the sublists are present in the original list.</p>
| 0debug
|
static int select_voice(cst_voice **voice, const char *voice_name, void *log_ctx)
{
int i;
for (i = 0; i < FF_ARRAY_ELEMS(voice_entries); i++) {
struct voice_entry *entry = &voice_entries[i];
if (!strcmp(entry->name, voice_name)) {
*voice = entry->register_fn(NULL);
if (!*voice) {
av_log(log_ctx, AV_LOG_ERROR,
"Could not register voice '%s'\n", voice_name);
return AVERROR_UNKNOWN;
}
return 0;
}
}
av_log(log_ctx, AV_LOG_ERROR, "Could not find voice '%s'\n", voice_name);
av_log(log_ctx, AV_LOG_INFO, "Choose between the voices: ");
list_voices(log_ctx, ", ");
return AVERROR(EINVAL);
}
| 1threat
|
Using the ‘stage’ step without a block argument is deprecated : <p>When building a Jenkins pipeline job (Jenkins ver. 2.7.4), I get this warning:</p>
<pre><code>Using the ‘stage’ step without a block argument is deprecated
</code></pre>
<p>How do I fix it?</p>
<p>Pipeline script snippet:</p>
<pre><code>stage 'Workspace Cleanup'
deleteDir()
</code></pre>
| 0debug
|
Sort Array based on value in java : <p>Peace and blessing be upon you.</p>
<p>Say I have:</p>
<pre><code>int[] array = {1,3,5,2,9,7,0};
</code></pre>
<p>Simply wanna sort this as:</p>
<pre><code>{0,1,2,3,5,7,9};
</code></pre>
| 0debug
|
how to align text width in android Textview : i want to align text in My TextView like this
[![enter image description here][1]][1]
and my current appearance of text is like
[![enter image description here][2]][2]
[1]: https://i.stack.imgur.com/dVTQ0.png
[2]: https://i.stack.imgur.com/wmloh.jpg
how ca i achieve text layout without using Webview
| 0debug
|
Making A Window With C : <p>I have been using the below code to make a simple window within C. When Compiling a get the error C4133, ive brought up the error in visual online but unable to resolve. (Apologies this is badly written) </p>
<pre><code>#include <windows.h>
const char g_szClassName[] = "myWindowClass";
// Step 4: the Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;
//Step 1: Registering the Window Class
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if (!RegisterClassEx(&wc))
{
MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
// Step 2: Creating the Window
hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_szClassName,
"The title of my window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
NULL, NULL, hInstance, NULL);
if (hwnd == NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
// Step 3: The Message Loop
while (GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
</code></pre>
<p>}</p>
| 0debug
|
static inline int check_ap(CPUARMState *env, int ap, int domain_prot,
int access_type, int is_user)
{
int prot_ro;
if (domain_prot == 3) {
return PAGE_READ | PAGE_WRITE;
}
if (access_type == 1)
prot_ro = 0;
else
prot_ro = PAGE_READ;
switch (ap) {
case 0:
if (access_type == 1)
return 0;
switch ((env->cp15.c1_sys >> 8) & 3) {
case 1:
return is_user ? 0 : PAGE_READ;
case 2:
return PAGE_READ;
default:
return 0;
}
case 1:
return is_user ? 0 : PAGE_READ | PAGE_WRITE;
case 2:
if (is_user)
return prot_ro;
else
return PAGE_READ | PAGE_WRITE;
case 3:
return PAGE_READ | PAGE_WRITE;
case 4:
return 0;
case 5:
return is_user ? 0 : prot_ro;
case 6:
return prot_ro;
case 7:
if (!arm_feature (env, ARM_FEATURE_V6K))
return 0;
return prot_ro;
default:
abort();
}
}
| 1threat
|
static uint32_t vmsvga_value_read(void *opaque, uint32_t address)
{
uint32_t caps;
struct vmsvga_state_s *s = opaque;
switch (s->index) {
case SVGA_REG_ID:
return s->svgaid;
case SVGA_REG_ENABLE:
return s->enable;
case SVGA_REG_WIDTH:
return s->width;
case SVGA_REG_HEIGHT:
return s->height;
case SVGA_REG_MAX_WIDTH:
return SVGA_MAX_WIDTH;
case SVGA_REG_MAX_HEIGHT:
return SVGA_MAX_HEIGHT;
case SVGA_REG_DEPTH:
return s->depth;
case SVGA_REG_BITS_PER_PIXEL:
return (s->depth + 7) & ~7;
case SVGA_REG_PSEUDOCOLOR:
return 0x0;
case SVGA_REG_RED_MASK:
return s->wred;
case SVGA_REG_GREEN_MASK:
return s->wgreen;
case SVGA_REG_BLUE_MASK:
return s->wblue;
case SVGA_REG_BYTES_PER_LINE:
return ((s->depth + 7) >> 3) * s->new_width;
case SVGA_REG_FB_START: {
struct pci_vmsvga_state_s *pci_vmsvga
= container_of(s, struct pci_vmsvga_state_s, chip);
return pci_get_bar_addr(&pci_vmsvga->card, 1);
}
case SVGA_REG_FB_OFFSET:
return 0x0;
case SVGA_REG_VRAM_SIZE:
return s->vga.vram_size;
case SVGA_REG_FB_SIZE:
return s->fb_size;
case SVGA_REG_CAPABILITIES:
caps = SVGA_CAP_NONE;
#ifdef HW_RECT_ACCEL
caps |= SVGA_CAP_RECT_COPY;
#endif
#ifdef HW_FILL_ACCEL
caps |= SVGA_CAP_RECT_FILL;
#endif
#ifdef HW_MOUSE_ACCEL
if (dpy_cursor_define_supported(s->vga.ds)) {
caps |= SVGA_CAP_CURSOR | SVGA_CAP_CURSOR_BYPASS_2 |
SVGA_CAP_CURSOR_BYPASS;
}
#endif
return caps;
case SVGA_REG_MEM_START: {
struct pci_vmsvga_state_s *pci_vmsvga
= container_of(s, struct pci_vmsvga_state_s, chip);
return pci_get_bar_addr(&pci_vmsvga->card, 2);
}
case SVGA_REG_MEM_SIZE:
return s->fifo_size;
case SVGA_REG_CONFIG_DONE:
return s->config;
case SVGA_REG_SYNC:
case SVGA_REG_BUSY:
return s->syncing;
case SVGA_REG_GUEST_ID:
return s->guest;
case SVGA_REG_CURSOR_ID:
return s->cursor.id;
case SVGA_REG_CURSOR_X:
return s->cursor.x;
case SVGA_REG_CURSOR_Y:
return s->cursor.x;
case SVGA_REG_CURSOR_ON:
return s->cursor.on;
case SVGA_REG_HOST_BITS_PER_PIXEL:
return (s->depth + 7) & ~7;
case SVGA_REG_SCRATCH_SIZE:
return s->scratch_size;
case SVGA_REG_MEM_REGS:
case SVGA_REG_NUM_DISPLAYS:
case SVGA_REG_PITCHLOCK:
case SVGA_PALETTE_BASE ... SVGA_PALETTE_END:
return 0;
default:
if (s->index >= SVGA_SCRATCH_BASE &&
s->index < SVGA_SCRATCH_BASE + s->scratch_size)
return s->scratch[s->index - SVGA_SCRATCH_BASE];
printf("%s: Bad register %02x\n", __FUNCTION__, s->index);
}
return 0;
}
| 1threat
|
how do i get a word in a string depending of there last 2 words php : so i have this string and i want to output all of the words that ends in "ly".
$desi = "DESIDERATA
Go placidly amid the noise and the haste,
and remember what peace there may be in silence.
As far as possible, without surrender,
be on good terms with all persons.
Speak your truth quietly and clearly;
and listen to others,
even to the dull and the ignorant;
they too have their story.
Avoid loud and aggressive persons;
they are vexatious to the spirit.
If you compare yourself with others,
you may become vain or bitter,
for always there will be greater and lesser persons than yourself.
Enjoy your achievements as well as your plans.
Keep interested in your own career, however humble;
it is a real possession in the changing fortunes of time.
Exercise caution in your business affairs,
for the world is full of trickery.
But let this not blind you to what virtue there is;
many persons strive for high ideals,
and everywhere life is full of heroism.
Be yourself. Especially do not feign affection.
Neither be cynical about love,
for in the face of all aridity and disenchantment,
it is as perennial as the grass.
Take kindly the counsel of the years,
gracefully surrendering the things of youth.
Nurture strength of spirit to shield you in sudden misfortune. But do
not distress yourself with dark imaginings. Many fears are born of
fatigue and loneliness.
Beyond a wholesome discipline, be gentle with yourself.
You are a child of the universe no less than the trees and the
stars; you have a right to be here.
And whether or not it is clear to you,
no doubt the universe is unfolding as it should.
Therefore be at peace with God, whatever you conceive Him to be. And
whatever your labors and aspirations,
in the noisy confusion of life, keep peace in your soul.
With all its sham, drudgery, and broken dreams,
it is still a beautiful world.
Be cheerful. Strive to be happy.";
how can I get all the words that ends in "ly" in this string??
| 0debug
|
Antiforgery tokens are reusable : <p>We use ASP.NET MVC's default Antiforgery technique.
Recently a security company did a scan of a form and made note that they could use the same <code>_RequestVerificationToken</code> combination (cookie + hidden field) multiple times.
Or how they put it: <em>"The CSRF token in the body is validated on server side but is not revoked after use even though the server
generates a new CSRF token."</em></p>
<p>After reading the documentation and multiple articles on the implementation of Antiforgery, it is my understanding that this is indeed possible as long as the session user matches the user in the tokens.</p>
<p>Part of their recommendation: <em>"Such tokens should, at
a minimum, be unique per user session"</em>
In my understanding this is already the case, except for anonymous users, correct?</p>
<p>My questions: Is this a security issue? How much of a risk is it? Is there a library that makes sure tokens are not reusable/invalidated.</p>
<p>If not, including an extra random token in session that will be reset on every request sounds like it would solve the issue.</p>
| 0debug
|
How to use xmltodict to get items out of an xml file : <p>I am trying to easily access values from an xml file.</p>
<pre><code><artikelen>
<artikel nummer="121">
<code>ABC123</code>
<naam>Highlight pen</naam>
<voorraad>231</voorraad>
<prijs>0.56</prijs>
</artikel>
<artikel nummer="123">
<code>PQR678</code>
<naam>Nietmachine</naam>
<voorraad>587</voorraad>
<prijs>9.99</prijs>
</artikel>
..... etc
</code></pre>
<p>If i want to acces the value ABC123, how do I get it?</p>
<pre><code>import xmltodict
with open('8_1.html') as fd:
doc = xmltodict.parse(fd.read())
print(doc[fd]['code'])
</code></pre>
| 0debug
|
static void test_qemu_strtoull_invalid(void)
{
const char *str = " xxxx \t abc";
char f = 'X';
const char *endptr = &f;
uint64_t res = 999;
int err;
err = qemu_strtoull(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert(endptr == str);
}
| 1threat
|
int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
H264ParamSets *ps, int ignore_truncation)
{
AVBufferRef *sps_buf;
int profile_idc, level_idc, constraint_set_flags = 0;
unsigned int sps_id;
int i, log2_max_frame_num_minus4;
SPS *sps;
sps_buf = av_buffer_allocz(sizeof(*sps));
if (!sps_buf)
return AVERROR(ENOMEM);
sps = (SPS*)sps_buf->data;
sps->data_size = gb->buffer_end - gb->buffer;
if (sps->data_size > sizeof(sps->data)) {
av_log(avctx, AV_LOG_WARNING, "Truncating likely oversized SPS\n");
sps->data_size = sizeof(sps->data);
}
memcpy(sps->data, gb->buffer, sps->data_size);
profile_idc = get_bits(gb, 8);
constraint_set_flags |= get_bits1(gb) << 0;
constraint_set_flags |= get_bits1(gb) << 1;
constraint_set_flags |= get_bits1(gb) << 2;
constraint_set_flags |= get_bits1(gb) << 3;
constraint_set_flags |= get_bits1(gb) << 4;
constraint_set_flags |= get_bits1(gb) << 5;
skip_bits(gb, 2);
level_idc = get_bits(gb, 8);
sps_id = get_ue_golomb_31(gb);
if (sps_id >= MAX_SPS_COUNT) {
av_log(avctx, AV_LOG_ERROR, "sps_id %u out of range\n", sps_id);
goto fail;
}
sps->sps_id = sps_id;
sps->time_offset_length = 24;
sps->profile_idc = profile_idc;
sps->constraint_set_flags = constraint_set_flags;
sps->level_idc = level_idc;
sps->full_range = -1;
memset(sps->scaling_matrix4, 16, sizeof(sps->scaling_matrix4));
memset(sps->scaling_matrix8, 16, sizeof(sps->scaling_matrix8));
sps->scaling_matrix_present = 0;
sps->colorspace = 2;
if (sps->profile_idc == 100 ||
sps->profile_idc == 110 ||
sps->profile_idc == 122 ||
sps->profile_idc == 244 ||
sps->profile_idc == 44 ||
sps->profile_idc == 83 ||
sps->profile_idc == 86 ||
sps->profile_idc == 118 ||
sps->profile_idc == 128 ||
sps->profile_idc == 138 ||
sps->profile_idc == 144) {
sps->chroma_format_idc = get_ue_golomb_31(gb);
if (sps->chroma_format_idc > 3U) {
avpriv_request_sample(avctx, "chroma_format_idc %u",
sps->chroma_format_idc);
goto fail;
} else if (sps->chroma_format_idc == 3) {
sps->residual_color_transform_flag = get_bits1(gb);
if (sps->residual_color_transform_flag) {
av_log(avctx, AV_LOG_ERROR, "separate color planes are not supported\n");
goto fail;
}
}
sps->bit_depth_luma = get_ue_golomb(gb) + 8;
sps->bit_depth_chroma = get_ue_golomb(gb) + 8;
if (sps->bit_depth_chroma != sps->bit_depth_luma) {
avpriv_request_sample(avctx,
"Different chroma and luma bit depth");
goto fail;
}
if (sps->bit_depth_luma < 8 || sps->bit_depth_luma > 14 ||
sps->bit_depth_chroma < 8 || sps->bit_depth_chroma > 14) {
av_log(avctx, AV_LOG_ERROR, "illegal bit depth value (%d, %d)\n",
sps->bit_depth_luma, sps->bit_depth_chroma);
goto fail;
}
sps->transform_bypass = get_bits1(gb);
sps->scaling_matrix_present |= decode_scaling_matrices(gb, sps, NULL, 1,
sps->scaling_matrix4, sps->scaling_matrix8);
} else {
sps->chroma_format_idc = 1;
sps->bit_depth_luma = 8;
sps->bit_depth_chroma = 8;
}
log2_max_frame_num_minus4 = get_ue_golomb(gb);
if (log2_max_frame_num_minus4 < MIN_LOG2_MAX_FRAME_NUM - 4 ||
log2_max_frame_num_minus4 > MAX_LOG2_MAX_FRAME_NUM - 4) {
av_log(avctx, AV_LOG_ERROR,
"log2_max_frame_num_minus4 out of range (0-12): %d\n",
log2_max_frame_num_minus4);
goto fail;
}
sps->log2_max_frame_num = log2_max_frame_num_minus4 + 4;
sps->poc_type = get_ue_golomb_31(gb);
if (sps->poc_type == 0) {
unsigned t = get_ue_golomb(gb);
if (t>12) {
av_log(avctx, AV_LOG_ERROR, "log2_max_poc_lsb (%d) is out of range\n", t);
goto fail;
}
sps->log2_max_poc_lsb = t + 4;
} else if (sps->poc_type == 1) {
sps->delta_pic_order_always_zero_flag = get_bits1(gb);
sps->offset_for_non_ref_pic = get_se_golomb(gb);
sps->offset_for_top_to_bottom_field = get_se_golomb(gb);
sps->poc_cycle_length = get_ue_golomb(gb);
if ((unsigned)sps->poc_cycle_length >=
FF_ARRAY_ELEMS(sps->offset_for_ref_frame)) {
av_log(avctx, AV_LOG_ERROR,
"poc_cycle_length overflow %d\n", sps->poc_cycle_length);
goto fail;
}
for (i = 0; i < sps->poc_cycle_length; i++)
sps->offset_for_ref_frame[i] = get_se_golomb(gb);
} else if (sps->poc_type != 2) {
av_log(avctx, AV_LOG_ERROR, "illegal POC type %d\n", sps->poc_type);
goto fail;
}
sps->ref_frame_count = get_ue_golomb_31(gb);
if (avctx->codec_tag == MKTAG('S', 'M', 'V', '2'))
sps->ref_frame_count = FFMAX(2, sps->ref_frame_count);
if (sps->ref_frame_count > H264_MAX_PICTURE_COUNT - 2 ||
sps->ref_frame_count > 16U) {
av_log(avctx, AV_LOG_ERROR,
"too many reference frames %d\n", sps->ref_frame_count);
goto fail;
}
sps->gaps_in_frame_num_allowed_flag = get_bits1(gb);
sps->mb_width = get_ue_golomb(gb) + 1;
sps->mb_height = get_ue_golomb(gb) + 1;
if ((unsigned)sps->mb_width >= INT_MAX / 16 ||
(unsigned)sps->mb_height >= INT_MAX / 16 ||
av_image_check_size(16 * sps->mb_width,
16 * sps->mb_height, 0, avctx)) {
av_log(avctx, AV_LOG_ERROR, "mb_width/height overflow\n");
goto fail;
}
sps->frame_mbs_only_flag = get_bits1(gb);
if (!sps->frame_mbs_only_flag)
sps->mb_aff = get_bits1(gb);
else
sps->mb_aff = 0;
sps->direct_8x8_inference_flag = get_bits1(gb);
#ifndef ALLOW_INTERLACE
if (sps->mb_aff)
av_log(avctx, AV_LOG_ERROR,
"MBAFF support not included; enable it at compile-time.\n");
#endif
sps->crop = get_bits1(gb);
if (sps->crop) {
unsigned int crop_left = get_ue_golomb(gb);
unsigned int crop_right = get_ue_golomb(gb);
unsigned int crop_top = get_ue_golomb(gb);
unsigned int crop_bottom = get_ue_golomb(gb);
int width = 16 * sps->mb_width;
int height = 16 * sps->mb_height * (2 - sps->frame_mbs_only_flag);
if (avctx->flags2 & AV_CODEC_FLAG2_IGNORE_CROP) {
av_log(avctx, AV_LOG_DEBUG, "discarding sps cropping, original "
"values are l:%d r:%d t:%d b:%d\n",
crop_left, crop_right, crop_top, crop_bottom);
sps->crop_left =
sps->crop_right =
sps->crop_top =
sps->crop_bottom = 0;
} else {
int vsub = (sps->chroma_format_idc == 1) ? 1 : 0;
int hsub = (sps->chroma_format_idc == 1 ||
sps->chroma_format_idc == 2) ? 1 : 0;
int step_x = 1 << hsub;
int step_y = (2 - sps->frame_mbs_only_flag) << vsub;
if (crop_left & (0x1F >> (sps->bit_depth_luma > 8)) &&
!(avctx->flags & AV_CODEC_FLAG_UNALIGNED)) {
crop_left &= ~(0x1F >> (sps->bit_depth_luma > 8));
av_log(avctx, AV_LOG_WARNING,
"Reducing left cropping to %d "
"chroma samples to preserve alignment.\n",
crop_left);
}
if (crop_left > (unsigned)INT_MAX / 4 / step_x ||
crop_right > (unsigned)INT_MAX / 4 / step_x ||
crop_top > (unsigned)INT_MAX / 4 / step_y ||
crop_bottom> (unsigned)INT_MAX / 4 / step_y ||
(crop_left + crop_right ) * step_x >= width ||
(crop_top + crop_bottom) * step_y >= height
) {
av_log(avctx, AV_LOG_ERROR, "crop values invalid %d %d %d %d / %d %d\n", crop_left, crop_right, crop_top, crop_bottom, width, height);
goto fail;
}
sps->crop_left = crop_left * step_x;
sps->crop_right = crop_right * step_x;
sps->crop_top = crop_top * step_y;
sps->crop_bottom = crop_bottom * step_y;
}
} else {
sps->crop_left =
sps->crop_right =
sps->crop_top =
sps->crop_bottom =
sps->crop = 0;
}
sps->vui_parameters_present_flag = get_bits1(gb);
if (sps->vui_parameters_present_flag) {
int ret = decode_vui_parameters(gb, avctx, sps);
if (ret < 0)
goto fail;
}
if (get_bits_left(gb) < 0) {
av_log(avctx, ignore_truncation ? AV_LOG_WARNING : AV_LOG_ERROR,
"Overread %s by %d bits\n", sps->vui_parameters_present_flag ? "VUI" : "SPS", -get_bits_left(gb));
if (!ignore_truncation)
goto fail;
}
if (!sps->bitstream_restriction_flag) {
sps->num_reorder_frames = MAX_DELAYED_PIC_COUNT - 1;
for (i = 0; i < FF_ARRAY_ELEMS(level_max_dpb_mbs); i++) {
if (level_max_dpb_mbs[i][0] == sps->level_idc) {
sps->num_reorder_frames = FFMIN(level_max_dpb_mbs[i][1] / (sps->mb_width * sps->mb_height),
sps->num_reorder_frames);
break;
}
}
}
if (!sps->sar.den)
sps->sar.den = 1;
if (avctx->debug & FF_DEBUG_PICT_INFO) {
static const char csp[4][5] = { "Gray", "420", "422", "444" };
av_log(avctx, AV_LOG_DEBUG,
"sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%u/%u/%u/%u %s %s %"PRId32"/%"PRId32" b%d reo:%d\n",
sps_id, sps->profile_idc, sps->level_idc,
sps->poc_type,
sps->ref_frame_count,
sps->mb_width, sps->mb_height,
sps->frame_mbs_only_flag ? "FRM" : (sps->mb_aff ? "MB-AFF" : "PIC-AFF"),
sps->direct_8x8_inference_flag ? "8B8" : "",
sps->crop_left, sps->crop_right,
sps->crop_top, sps->crop_bottom,
sps->vui_parameters_present_flag ? "VUI" : "",
csp[sps->chroma_format_idc],
sps->timing_info_present_flag ? sps->num_units_in_tick : 0,
sps->timing_info_present_flag ? sps->time_scale : 0,
sps->bit_depth_luma,
sps->bitstream_restriction_flag ? sps->num_reorder_frames : -1
);
}
if (ps->sps_list[sps_id] &&
!memcmp(ps->sps_list[sps_id]->data, sps_buf->data, sps_buf->size)) {
av_buffer_unref(&sps_buf);
} else {
remove_sps(ps, sps_id);
ps->sps_list[sps_id] = sps_buf;
}
return 0;
fail:
av_buffer_unref(&sps_buf);
return AVERROR_INVALIDDATA;
}
| 1threat
|
AVStream *av_new_stream(AVFormatContext *s, int id)
{
AVStream *st;
int i;
#if LIBAVFORMAT_VERSION_MAJOR >= 53
AVStream **streams;
if (s->nb_streams >= INT_MAX/sizeof(*streams))
return NULL;
streams = av_realloc(s->streams, (s->nb_streams + 1) * sizeof(*streams));
if (!streams)
return NULL;
s->streams = streams;
#else
if (s->nb_streams >= MAX_STREAMS){
av_log(s, AV_LOG_ERROR, "Too many streams\n");
return NULL;
}
#endif
st = av_mallocz(sizeof(AVStream));
if (!st)
return NULL;
st->codec= avcodec_alloc_context();
if (s->iformat) {
st->codec->bit_rate = 0;
}
st->index = s->nb_streams;
st->id = id;
st->start_time = AV_NOPTS_VALUE;
st->duration = AV_NOPTS_VALUE;
st->cur_dts = 0;
st->first_dts = AV_NOPTS_VALUE;
st->probe_packets = MAX_PROBE_PACKETS;
av_set_pts_info(st, 33, 1, 90000);
st->last_IP_pts = AV_NOPTS_VALUE;
for(i=0; i<MAX_REORDER_DELAY+1; i++)
st->pts_buffer[i]= AV_NOPTS_VALUE;
st->reference_dts = AV_NOPTS_VALUE;
st->sample_aspect_ratio = (AVRational){0,1};
s->streams[s->nb_streams++] = st;
return st;
}
| 1threat
|
void ff_h264_pred_direct_motion(H264Context * const h, int *mb_type){
MpegEncContext * const s = &h->s;
int b8_stride = h->b8_stride;
int b4_stride = h->b_stride;
int mb_xy = h->mb_xy;
int mb_type_col[2];
const int16_t (*l1mv0)[2], (*l1mv1)[2];
const int8_t *l1ref0, *l1ref1;
const int is_b8x8 = IS_8X8(*mb_type);
unsigned int sub_mb_type;
int i8, i4;
assert(h->ref_list[1][0].reference&3);
#define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16|MB_TYPE_INTRA4x4|MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM)
if(IS_INTERLACED(h->ref_list[1][0].mb_type[mb_xy])){
if(!IS_INTERLACED(*mb_type)){
mb_xy= s->mb_x + ((s->mb_y&~1) + h->col_parity)*s->mb_stride;
b8_stride = 0;
}else{
mb_xy += h->col_fieldoff;
}
goto single_col;
}else{
if(IS_INTERLACED(*mb_type)){
mb_xy= s->mb_x + (s->mb_y&~1)*s->mb_stride;
mb_type_col[0] = h->ref_list[1][0].mb_type[mb_xy];
mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy + s->mb_stride];
b8_stride *= 3;
b4_stride *= 6;
sub_mb_type = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2;
if( (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)
&& (mb_type_col[1] & MB_TYPE_16x16_OR_INTRA)
&& !is_b8x8){
*mb_type |= MB_TYPE_16x8 |MB_TYPE_L0L1|MB_TYPE_DIRECT2;
}else{
*mb_type |= MB_TYPE_8x8|MB_TYPE_L0L1;
}
}else{
single_col:
mb_type_col[0] =
mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy];
if(IS_8X8(mb_type_col[0]) && !h->sps.direct_8x8_inference_flag){
sub_mb_type = MB_TYPE_8x8|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2;
*mb_type |= MB_TYPE_8x8|MB_TYPE_L0L1;
}else if(!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)){
sub_mb_type = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2;
*mb_type |= MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2;
}else if(!is_b8x8 && (mb_type_col[0] & (MB_TYPE_16x8|MB_TYPE_8x16))){
sub_mb_type = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2;
*mb_type |= MB_TYPE_L0L1|MB_TYPE_DIRECT2 | (mb_type_col[0] & (MB_TYPE_16x8|MB_TYPE_8x16));
}else{
sub_mb_type = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2;
*mb_type |= MB_TYPE_8x8|MB_TYPE_L0L1;
}
}
}
l1mv0 = &h->ref_list[1][0].motion_val[0][h->mb2b_xy [mb_xy]];
l1mv1 = &h->ref_list[1][0].motion_val[1][h->mb2b_xy [mb_xy]];
l1ref0 = &h->ref_list[1][0].ref_index [0][h->mb2b8_xy[mb_xy]];
l1ref1 = &h->ref_list[1][0].ref_index [1][h->mb2b8_xy[mb_xy]];
if(!b8_stride){
if(s->mb_y&1){
l1ref0 += h->b8_stride;
l1ref1 += h->b8_stride;
l1mv0 += 2*b4_stride;
l1mv1 += 2*b4_stride;
}
}
if(h->direct_spatial_mv_pred){
int ref[2];
int mv[2][2];
int list;
for(list=0; list<2; list++){
int refa = h->ref_cache[list][scan8[0] - 1];
int refb = h->ref_cache[list][scan8[0] - 8];
int refc = h->ref_cache[list][scan8[0] - 8 + 4];
if(refc == PART_NOT_AVAILABLE)
refc = h->ref_cache[list][scan8[0] - 8 - 1];
ref[list] = FFMIN3((unsigned)refa, (unsigned)refb, (unsigned)refc);
if(ref[list] >= 0){
pred_motion(h, 0, 4, list, ref[list], &mv[list][0], &mv[list][1]);
}else{
int mask= ~(MB_TYPE_L0 << (2*list));
mv[list][0] = mv[list][1] = 0;
ref[list] = -1;
if(!is_b8x8)
*mb_type &= mask;
sub_mb_type &= mask;
}
}
if(ref[0] < 0 && ref[1] < 0){
ref[0] = ref[1] = 0;
if(!is_b8x8)
*mb_type |= MB_TYPE_L0L1;
sub_mb_type |= MB_TYPE_L0L1;
}
if(IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])){
for(i8=0; i8<4; i8++){
int x8 = i8&1;
int y8 = i8>>1;
int xy8 = x8+y8*b8_stride;
int xy4 = 3*x8+y8*b4_stride;
int a,b;
if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8]))
continue;
h->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[0], 1);
fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[1], 1);
if(!IS_INTRA(mb_type_col[y8]) && !h->ref_list[1][0].long_ref
&& ( (l1ref0[xy8] == 0 && FFABS(l1mv0[xy4][0]) <= 1 && FFABS(l1mv0[xy4][1]) <= 1)
|| (l1ref0[xy8] < 0 && l1ref1[xy8] == 0 && FFABS(l1mv1[xy4][0]) <= 1 && FFABS(l1mv1[xy4][1]) <= 1))){
a=b=0;
if(ref[0] > 0)
a= pack16to32(mv[0][0],mv[0][1]);
if(ref[1] > 0)
b= pack16to32(mv[1][0],mv[1][1]);
}else{
a= pack16to32(mv[0][0],mv[0][1]);
b= pack16to32(mv[1][0],mv[1][1]);
}
fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, a, 4);
fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, b, 4);
}
}else if(IS_16X16(*mb_type)){
int a,b;
fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, (uint8_t)ref[0], 1);
fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, (uint8_t)ref[1], 1);
if(!IS_INTRA(mb_type_col[0]) && !h->ref_list[1][0].long_ref
&& ( (l1ref0[0] == 0 && FFABS(l1mv0[0][0]) <= 1 && FFABS(l1mv0[0][1]) <= 1)
|| (l1ref0[0] < 0 && l1ref1[0] == 0 && FFABS(l1mv1[0][0]) <= 1 && FFABS(l1mv1[0][1]) <= 1
&& (h->x264_build>33 || !h->x264_build)))){
a=b=0;
if(ref[0] > 0)
a= pack16to32(mv[0][0],mv[0][1]);
if(ref[1] > 0)
b= pack16to32(mv[1][0],mv[1][1]);
}else{
a= pack16to32(mv[0][0],mv[0][1]);
b= pack16to32(mv[1][0],mv[1][1]);
}
fill_rectangle(&h->mv_cache[0][scan8[0]], 4, 4, 8, a, 4);
fill_rectangle(&h->mv_cache[1][scan8[0]], 4, 4, 8, b, 4);
}else{
for(i8=0; i8<4; i8++){
const int x8 = i8&1;
const int y8 = i8>>1;
if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8]))
continue;
h->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, pack16to32(mv[0][0],mv[0][1]), 4);
fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, pack16to32(mv[1][0],mv[1][1]), 4);
fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[0], 1);
fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[1], 1);
if(!IS_INTRA(mb_type_col[0]) && !h->ref_list[1][0].long_ref && ( l1ref0[x8 + y8*b8_stride] == 0
|| (l1ref0[x8 + y8*b8_stride] < 0 && l1ref1[x8 + y8*b8_stride] == 0
&& (h->x264_build>33 || !h->x264_build)))){
const int16_t (*l1mv)[2]= l1ref0[x8 + y8*b8_stride] == 0 ? l1mv0 : l1mv1;
if(IS_SUB_8X8(sub_mb_type)){
const int16_t *mv_col = l1mv[x8*3 + y8*3*b4_stride];
if(FFABS(mv_col[0]) <= 1 && FFABS(mv_col[1]) <= 1){
if(ref[0] == 0)
fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, 0, 4);
if(ref[1] == 0)
fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, 0, 4);
}
}else
for(i4=0; i4<4; i4++){
const int16_t *mv_col = l1mv[x8*2 + (i4&1) + (y8*2 + (i4>>1))*b4_stride];
if(FFABS(mv_col[0]) <= 1 && FFABS(mv_col[1]) <= 1){
if(ref[0] == 0)
*(uint32_t*)h->mv_cache[0][scan8[i8*4+i4]] = 0;
if(ref[1] == 0)
*(uint32_t*)h->mv_cache[1][scan8[i8*4+i4]] = 0;
}
}
}
}
}
}else{
const int *map_col_to_list0[2] = {h->map_col_to_list0[0], h->map_col_to_list0[1]};
const int *dist_scale_factor = h->dist_scale_factor;
int ref_offset= 0;
if(FRAME_MBAFF && IS_INTERLACED(*mb_type)){
map_col_to_list0[0] = h->map_col_to_list0_field[s->mb_y&1][0];
map_col_to_list0[1] = h->map_col_to_list0_field[s->mb_y&1][1];
dist_scale_factor =h->dist_scale_factor_field[s->mb_y&1];
}
if(h->ref_list[1][0].mbaff && IS_INTERLACED(mb_type_col[0]))
ref_offset += 16;
if(IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])){
int y_shift = 2*!IS_INTERLACED(*mb_type);
assert(h->sps.direct_8x8_inference_flag);
for(i8=0; i8<4; i8++){
const int x8 = i8&1;
const int y8 = i8>>1;
int ref0, scale;
const int16_t (*l1mv)[2]= l1mv0;
if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8]))
continue;
h->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, 0, 1);
if(IS_INTRA(mb_type_col[y8])){
fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, 0, 1);
fill_rectangle(&h-> mv_cache[0][scan8[i8*4]], 2, 2, 8, 0, 4);
fill_rectangle(&h-> mv_cache[1][scan8[i8*4]], 2, 2, 8, 0, 4);
continue;
}
ref0 = l1ref0[x8 + y8*b8_stride];
if(ref0 >= 0)
ref0 = map_col_to_list0[0][ref0 + ref_offset];
else{
ref0 = map_col_to_list0[1][l1ref1[x8 + y8*b8_stride] + ref_offset];
l1mv= l1mv1;
}
scale = dist_scale_factor[ref0];
fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, ref0, 1);
{
const int16_t *mv_col = l1mv[x8*3 + y8*b4_stride];
int my_col = (mv_col[1]<<y_shift)/2;
int mx = (scale * mv_col[0] + 128) >> 8;
int my = (scale * my_col + 128) >> 8;
fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, pack16to32(mx,my), 4);
fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, pack16to32(mx-mv_col[0],my-my_col), 4);
}
}
return;
}
if(IS_16X16(*mb_type)){
int ref, mv0, mv1;
fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, 0, 1);
if(IS_INTRA(mb_type_col[0])){
ref=mv0=mv1=0;
}else{
const int ref0 = l1ref0[0] >= 0 ? map_col_to_list0[0][l1ref0[0] + ref_offset]
: map_col_to_list0[1][l1ref1[0] + ref_offset];
const int scale = dist_scale_factor[ref0];
const int16_t *mv_col = l1ref0[0] >= 0 ? l1mv0[0] : l1mv1[0];
int mv_l0[2];
mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
ref= ref0;
mv0= pack16to32(mv_l0[0],mv_l0[1]);
mv1= pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1]);
}
fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1);
fill_rectangle(&h-> mv_cache[0][scan8[0]], 4, 4, 8, mv0, 4);
fill_rectangle(&h-> mv_cache[1][scan8[0]], 4, 4, 8, mv1, 4);
}else{
for(i8=0; i8<4; i8++){
const int x8 = i8&1;
const int y8 = i8>>1;
int ref0, scale;
const int16_t (*l1mv)[2]= l1mv0;
if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8]))
continue;
h->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, 0, 1);
if(IS_INTRA(mb_type_col[0])){
fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, 0, 1);
fill_rectangle(&h-> mv_cache[0][scan8[i8*4]], 2, 2, 8, 0, 4);
fill_rectangle(&h-> mv_cache[1][scan8[i8*4]], 2, 2, 8, 0, 4);
continue;
}
ref0 = l1ref0[x8 + y8*b8_stride];
if(ref0 >= 0)
ref0 = map_col_to_list0[0][ref0 + ref_offset];
else{
ref0 = map_col_to_list0[1][l1ref1[x8 + y8*b8_stride] + ref_offset];
l1mv= l1mv1;
}
scale = dist_scale_factor[ref0];
fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, ref0, 1);
if(IS_SUB_8X8(sub_mb_type)){
const int16_t *mv_col = l1mv[x8*3 + y8*3*b4_stride];
int mx = (scale * mv_col[0] + 128) >> 8;
int my = (scale * mv_col[1] + 128) >> 8;
fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, pack16to32(mx,my), 4);
fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, pack16to32(mx-mv_col[0],my-mv_col[1]), 4);
}else
for(i4=0; i4<4; i4++){
const int16_t *mv_col = l1mv[x8*2 + (i4&1) + (y8*2 + (i4>>1))*b4_stride];
int16_t *mv_l0 = h->mv_cache[0][scan8[i8*4+i4]];
mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
*(uint32_t*)h->mv_cache[1][scan8[i8*4+i4]] =
pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1]);
}
}
}
}
}
| 1threat
|
static void zynq_init(QEMUMachineInitArgs *args)
{
ram_addr_t ram_size = args->ram_size;
const char *cpu_model = args->cpu_model;
const char *kernel_filename = args->kernel_filename;
const char *kernel_cmdline = args->kernel_cmdline;
const char *initrd_filename = args->initrd_filename;
ObjectClass *cpu_oc;
ARMCPU *cpu;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *ext_ram = g_new(MemoryRegion, 1);
MemoryRegion *ocm_ram = g_new(MemoryRegion, 1);
DeviceState *dev;
SysBusDevice *busdev;
qemu_irq pic[64];
NICInfo *nd;
Error *err = NULL;
int n;
if (!cpu_model) {
cpu_model = "cortex-a9";
}
cpu_oc = cpu_class_by_name(TYPE_ARM_CPU, cpu_model);
cpu = ARM_CPU(object_new(object_class_get_name(cpu_oc)));
object_property_set_int(OBJECT(cpu), MPCORE_PERIPHBASE, "reset-cbar", &err);
if (err) {
error_report("%s", error_get_pretty(err));
exit(1);
}
object_property_set_bool(OBJECT(cpu), true, "realized", &err);
if (err) {
error_report("%s", error_get_pretty(err));
exit(1);
}
if (ram_size > 0x80000000) {
ram_size = 0x80000000;
}
memory_region_init_ram(ext_ram, NULL, "zynq.ext_ram", ram_size);
vmstate_register_ram_global(ext_ram);
memory_region_add_subregion(address_space_mem, 0, ext_ram);
memory_region_init_ram(ocm_ram, NULL, "zynq.ocm_ram", 256 << 10);
vmstate_register_ram_global(ocm_ram);
memory_region_add_subregion(address_space_mem, 0xFFFC0000, ocm_ram);
DriveInfo *dinfo = drive_get(IF_PFLASH, 0, 0);
pflash_cfi02_register(0xe2000000, NULL, "zynq.pflash", FLASH_SIZE,
dinfo ? dinfo->bdrv : NULL, FLASH_SECTOR_SIZE,
FLASH_SIZE/FLASH_SECTOR_SIZE, 1,
1, 0x0066, 0x0022, 0x0000, 0x0000, 0x0555, 0x2aa,
0);
dev = qdev_create(NULL, "xilinx,zynq_slcr");
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xF8000000);
dev = qdev_create(NULL, "a9mpcore_priv");
qdev_prop_set_uint32(dev, "num-cpu", 1);
qdev_init_nofail(dev);
busdev = SYS_BUS_DEVICE(dev);
sysbus_mmio_map(busdev, 0, MPCORE_PERIPHBASE);
sysbus_connect_irq(busdev, 0,
qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ));
for (n = 0; n < 64; n++) {
pic[n] = qdev_get_gpio_in(dev, n);
}
zynq_init_spi_flashes(0xE0006000, pic[58-IRQ_OFFSET], false);
zynq_init_spi_flashes(0xE0007000, pic[81-IRQ_OFFSET], false);
zynq_init_spi_flashes(0xE000D000, pic[51-IRQ_OFFSET], true);
sysbus_create_simple("xlnx,ps7-usb", 0xE0002000, pic[53-IRQ_OFFSET]);
sysbus_create_simple("xlnx,ps7-usb", 0xE0003000, pic[76-IRQ_OFFSET]);
sysbus_create_simple("cadence_uart", 0xE0000000, pic[59-IRQ_OFFSET]);
sysbus_create_simple("cadence_uart", 0xE0001000, pic[82-IRQ_OFFSET]);
sysbus_create_varargs("cadence_ttc", 0xF8001000,
pic[42-IRQ_OFFSET], pic[43-IRQ_OFFSET], pic[44-IRQ_OFFSET], NULL);
sysbus_create_varargs("cadence_ttc", 0xF8002000,
pic[69-IRQ_OFFSET], pic[70-IRQ_OFFSET], pic[71-IRQ_OFFSET], NULL);
for (n = 0; n < nb_nics; n++) {
nd = &nd_table[n];
if (n == 0) {
gem_init(nd, 0xE000B000, pic[54-IRQ_OFFSET]);
} else if (n == 1) {
gem_init(nd, 0xE000C000, pic[77-IRQ_OFFSET]);
}
}
dev = qdev_create(NULL, "generic-sdhci");
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0100000);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[56-IRQ_OFFSET]);
dev = qdev_create(NULL, "generic-sdhci");
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0101000);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[79-IRQ_OFFSET]);
dev = qdev_create(NULL, "pl330");
qdev_prop_set_uint8(dev, "num_chnls", 8);
qdev_prop_set_uint8(dev, "num_periph_req", 4);
qdev_prop_set_uint8(dev, "num_events", 16);
qdev_prop_set_uint8(dev, "data_width", 64);
qdev_prop_set_uint8(dev, "wr_cap", 8);
qdev_prop_set_uint8(dev, "wr_q_dep", 16);
qdev_prop_set_uint8(dev, "rd_cap", 8);
qdev_prop_set_uint8(dev, "rd_q_dep", 16);
qdev_prop_set_uint16(dev, "data_buffer_dep", 256);
qdev_init_nofail(dev);
busdev = SYS_BUS_DEVICE(dev);
sysbus_mmio_map(busdev, 0, 0xF8003000);
sysbus_connect_irq(busdev, 0, pic[45-IRQ_OFFSET]);
for (n = 0; n < 8; ++n) {
sysbus_connect_irq(busdev, n + 1, pic[dma_irqs[n] - IRQ_OFFSET]);
}
zynq_binfo.ram_size = ram_size;
zynq_binfo.kernel_filename = kernel_filename;
zynq_binfo.kernel_cmdline = kernel_cmdline;
zynq_binfo.initrd_filename = initrd_filename;
zynq_binfo.nb_cpus = 1;
zynq_binfo.board_id = 0xd32;
zynq_binfo.loader_start = 0;
arm_load_kernel(ARM_CPU(first_cpu), &zynq_binfo);
}
| 1threat
|
query = 'SELECT * FROM customers WHERE email = ' + email_input
| 1threat
|
Javascript insert element at nth index in array, insertion elements from another array : <p>I have 2 Javascript arrays:</p>
<pre><code>['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']
['a', 'b', 'c']
</code></pre>
<p>I need to insert elements of second array into the first array every 4th or nth index of the first array, resulting in:</p>
<pre><code>['a', '1', '2', '3', '4', 'b', '5', '6', '7', '8', 'c', '9', '10', '11', '12']
</code></pre>
<p>n needs to be a parameter, so I can move n to the 5th location, or 3rd location when needed.</p>
<p>Any solutions appreciated. ES6 ones would be great! Thank you in advance.</p>
| 0debug
|
What HTML element for semantic sidenotes? : <p>I like to add responsive sidenotes to my blog posts. Responsive as in: hidden on small viewports, visible in the margin on wide viewports.</p>
<p>When hidden on small screens, a visible element ('link') is needed indicating there's more to read. My solution for this so far is: </p>
<pre><code><p>Some sentence with
<span class="sidenote" onclick="this.classList.toggle('active');">
underlined text
<span class="sidenote__content">
Sidenote content
</span>
</span>, which is clickable on small viewports.</p>
</code></pre>
<p>(with added line breaks for readability)</p>
<p>With CSS I add asterisks to both the underlined text and the sidenote content to visually connect them on large screens.</p>
<p>The problems with this solution are that the <code>sidenote__content</code> correct display depends on CSS. It's shown in readers like Pocket, with:</p>
<ul>
<li>The sidenote content showing up mid sentence without any visual cues</li>
<li>No space between the underlined text and the sidenote content. </li>
</ul>
<p>I'm hoping that there's a more semantic solution than simple spans. <code><aside></code> and <code><section></code> can't be used as they're block elements and <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/p" rel="noreferrer">can automatically close</a> the parent's p element.</p>
<p>A solution could be to separate the sidenote content from the link. However I'd prefer to keep the set of sidenote and its link as one set or pair, so they can be inserted as such into posts. Splitting them up would require javascript logic to match links with their content and can cause maintenance issues when one half of the set is missing.</p>
| 0debug
|
MigrationState *tcp_start_outgoing_migration(Monitor *mon,
const char *host_port,
int64_t bandwidth_limit,
int detach,
int blk,
int inc)
{
struct sockaddr_in addr;
FdMigrationState *s;
int ret;
if (parse_host_port(&addr, host_port) < 0)
return NULL;
s = qemu_mallocz(sizeof(*s));
s->get_error = socket_errno;
s->write = socket_write;
s->close = tcp_close;
s->mig_state.cancel = migrate_fd_cancel;
s->mig_state.get_status = migrate_fd_get_status;
s->mig_state.release = migrate_fd_release;
s->mig_state.blk = blk;
s->mig_state.shared = inc;
s->state = MIG_STATE_ACTIVE;
s->mon = NULL;
s->bandwidth_limit = bandwidth_limit;
s->fd = socket(PF_INET, SOCK_STREAM, 0);
if (s->fd == -1) {
qemu_free(s);
return NULL;
}
socket_set_nonblock(s->fd);
if (!detach) {
migrate_fd_monitor_suspend(s, mon);
}
do {
ret = connect(s->fd, (struct sockaddr *)&addr, sizeof(addr));
if (ret == -1)
ret = -(s->get_error(s));
if (ret == -EINPROGRESS || ret == -EWOULDBLOCK)
qemu_set_fd_handler2(s->fd, NULL, NULL, tcp_wait_for_connect, s);
} while (ret == -EINTR);
if (ret < 0 && ret != -EINPROGRESS && ret != -EWOULDBLOCK) {
dprintf("connect failed\n");
close(s->fd);
qemu_free(s);
return NULL;
} else if (ret >= 0)
migrate_fd_connect(s);
return &s->mig_state;
}
| 1threat
|
How get the value from pushpin image in google maps : When I search for a place it will display the locations along with the number in the map pointer. but I want to print that number which I could not get the number. because it is showing as an image which does not have value attribute in the HTML page.. See the attached screenshot. Could you please help me
[1]: https://i.stack.imgur.com/KpNuU.png
| 0debug
|
How to change a property on an object without mutating it? : <pre><code>const a = {x: "Hi", y: "Test"}
const b = ???
// b = {x: "Bye", y: "Test"}
// a = {x: "Hi", y: "Test"}
</code></pre>
<p>How can I set x to "Bye" without mutating a?</p>
| 0debug
|
Why do we need locks for threads, if we have GIL? : <p>I believe it is a stupid question but I still can't find it. Actually it's better to separate it into two questions:</p>
<p>1) Am I right that we could have a lot of threads but because of GIL in one moment only one thread is executing?</p>
<p>2) If so, why do we still need locks? We use locks to avoid the case when two threads are trying to read/write some shared object, because of GIL twi threads can't be executed in one moment, can they?</p>
| 0debug
|
Attempt to invoke virtual method when displaying TOAST? : <p>when you click a button in my activity it starts/displays a <code>DatePickerDialog</code>. When the user selects a date and clicks "ok" i want to run an <code>AsyncTask</code> in the original class (the activity where the button was clicked). Everything works but i want to display to the user a TOAST when the AsyncTask is finished but it keep on getting an error when doing so.</p>
<p>Heres my code:</p>
<p>Button method in the BuyerHomePage.java</p>
<pre><code> public void MeetingCreator(){
CalenderImageButton = (ImageButton)findViewById(R.id.CalenderImageButton);
CalenderImageButton.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
DialogFragment picker = new DatePickerFragment();
picker.show(getFragmentManager(), "datePicker");
}
}
);
}
</code></pre>
<p>DatePickerFragment.java code</p>
<pre><code> public class DatePickerFragment extends DialogFragment
implements DatePickerDialog.OnDateSetListener {
public static String formattedDate;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
// Create a new instance of DatePickerDialog and return it
return new DatePickerDialog(getActivity(), this, year, month, day);
}
@Override
public void onDateSet(DatePicker view, int year, int month, int day) {
Calendar c = Calendar.getInstance();
c.set(year, month, day);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
formattedDate = sdf.format(c.getTime());
BuyerHomePage Meeting = new BuyerHomePage();
Meeting.new MeetingSender().execute();
}
}
</code></pre>
<p>BuyerHomePage.java (post method in the AsyncTask)</p>
<pre><code>@Override
protected void onPostExecute (String result){
if (result.equals("email sent")) {
//This is where i get the error
Toast.makeText(BuyerHomePage.this, "Email sent!", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(BuyerHomePage.this, "Can't send email", Toast.LENGTH_LONG).show();
}
}
</code></pre>
<p>Error Logs:</p>
<pre><code>04-23 02:25:31.631 22071-22071/com.wilsapp.wilsapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.wilsapp.wilsapp, PID: 22071
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
at android.content.ContextWrapper.getResources(ContextWrapper.java:87)
at android.view.ContextThemeWrapper.getResources(ContextThemeWrapper.java:81)
at android.widget.Toast.<init>(Toast.java:102)
at android.widget.Toast.makeText(Toast.java:259)
at com.wilsapp.wilsapp.BuyerHomePage$MeetingSender.onPostExecute(BuyerHomePage.java:930)
at com.wilsapp.wilsapp.BuyerHomePage$MeetingSender.onPostExecute(BuyerHomePage.java:836)
at android.os.AsyncTask.finish(AsyncTask.java:651)
at android.os.AsyncTask.-wrap1(AsyncTask.java)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
</code></pre>
<p>if there's any confusion or i need to explain anything please comment! Thank you!</p>
| 0debug
|
I am getting absurd values for the variable 'credits' : <pre><code>#include <stdio.h>
int main (void)
{
int hist,geo,phy,chem,bio;
int credits=0;
printf("Enter marks in history : ");
scanf("%d",&hist);
if(hist>40)
credits =10;
else
printf("No credits awarded for history");
printf("Credits obtained is %d",&credits);
return(0);
}
</code></pre>
<p>when I run the code, and I get a value of 230586 for the variable 'Credits'. Please help. I am a beginner in C</p>
| 0debug
|
static void gdb_set_cpu_pc(GDBState *s, target_ulong pc)
{
#if defined(TARGET_I386)
cpu_synchronize_state(s->c_cpu);
s->c_cpu->eip = pc;
#elif defined (TARGET_PPC)
s->c_cpu->nip = pc;
#elif defined (TARGET_SPARC)
s->c_cpu->npc = pc + 4;
#elif defined (TARGET_ARM)
s->c_cpu->regs[15] = pc;
#elif defined (TARGET_SH4)
#elif defined (TARGET_MIPS)
s->c_cpu->active_tc.PC = pc & ~(target_ulong)1;
if (pc & 1) {
s->c_cpu->hflags |= MIPS_HFLAG_M16;
} else {
s->c_cpu->hflags &= ~(MIPS_HFLAG_M16);
}
#elif defined (TARGET_MICROBLAZE)
s->c_cpu->sregs[SR_PC] = pc;
#elif defined (TARGET_CRIS)
#elif defined (TARGET_ALPHA)
#elif defined (TARGET_S390X)
cpu_synchronize_state(s->c_cpu);
s->c_cpu->psw.addr = pc;
#elif defined (TARGET_LM32)
#endif
}
| 1threat
|
static const unsigned char *seq_decode_op1(SeqVideoContext *seq, const unsigned char *src, unsigned char *dst)
{
const unsigned char *color_table;
int b, i, len, bits;
GetBitContext gb;
unsigned char block[8 * 8];
len = *src++;
if (len & 0x80) {
switch (len & 3) {
case 1:
src = seq_unpack_rle_block(src, block, sizeof(block));
for (b = 0; b < 8; b++) {
memcpy(dst, &block[b * 8], 8);
dst += seq->frame.linesize[0];
}
break;
case 2:
src = seq_unpack_rle_block(src, block, sizeof(block));
for (i = 0; i < 8; i++) {
for (b = 0; b < 8; b++)
dst[b * seq->frame.linesize[0]] = block[i * 8 + b];
++dst;
}
break;
}
} else {
color_table = src;
src += len;
bits = ff_log2_tab[len - 1] + 1;
init_get_bits(&gb, src, bits * 8 * 8); src += bits * 8;
for (b = 0; b < 8; b++) {
for (i = 0; i < 8; i++)
dst[i] = color_table[get_bits(&gb, bits)];
dst += seq->frame.linesize[0];
}
}
return src;
}
| 1threat
|
Read appsettings.json in Main Program.cs : <p>First of all my main purpose is to setup the IP and Port for my application dynamically.</p>
<p>I'm using <code>IConfiguration</code> to inject a json config file, like some tutorial mentioned.</p>
<p>However, I can't retrieve the configuration in Program.cs, because my <code>WebHostBuilder</code> will use the StartUp and Url at the same time.</p>
<p>So at the time the host build up, there is nothing in my configuration.</p>
<pre><code>WebProtocolSettings settings_Web = new WebProtocolSettings();
var host = new WebHostBuilder()
.UseIISIntegration()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.UseUrls(settings_Web.Url + ":" + settings_Web.Port)
.Build();
</code></pre>
<p>In Startup.cs</p>
<pre><code>public Startup(IHostingEnvironment env)
{
// Set up configuration sources.
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
Configuration = builder.Build();
}
public IConfigurationRoot Configuration { get; set; }
public void ConfigureServices(IServiceCollection services)
{
// Adds services required for using options.
services.AddOptions();
var _WebProtocolSettings = Configuration.GetSection("WebProtocolSettings");
// Register the IConfiguration instance
services.Configure<WebProtocolSettings>(_WebProtocolSettings);
}
</code></pre>
<p>My appsettings.json:</p>
<pre><code>{
"WebProtocolSettings": {
"Url": "127.0.0.1",
"Port": 5050
}
}
</code></pre>
<p>My WebProtocolSettings.cs:</p>
<pre><code>public class WebProtocolSettings
{
public string Url { get; set; }
public int Port { get; set; }
}
</code></pre>
| 0debug
|
why my python app exist immediately after show graph diagram? : I use below code to show a data graph but the graph window is just shown for one second then the application exists. Below is my code. Is there anything wrong with it?
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
train_df = pd.read_csv('./data/tra
in.csv')
g = sns.FacetGrid(train_df, col='Survived')
g.map(plt.hist, 'Age', bins=20)
| 0debug
|
iOS 11 Navigation bar large title have black color when push on pop view controller : <p>I have a problem with the new navigation bar for iOS 11.</p>
<p>In root view set new navigation by code: </p>
<pre><code>if (@available(iOS 11.0, *)) {
self.navigationController.navigationBar.prefersLargeTitles = YES;
self.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeAlways;
}
</code></pre>
<p>Then from root view, I pushed to another view and set code navigation bar by </p>
<pre><code>if (@available(iOS 11.0, *)) {
self.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeNever;
}
</code></pre>
<p>It works well. However, when push and pop view a black color appeared like the image below: </p>
<p><a href="https://i.stack.imgur.com/L2cUU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/L2cUU.png" alt="enter image description here"></a></p>
<p>I don't know why the black color appeared on this view although I did not set back ground for navigation bar is a black color for the whole screen in my app. </p>
<p>Someone have any idea for the problem. Please drop me some suggestion to solve that bug. Thanks.</p>
| 0debug
|
static void m5206_mbar_writew(void *opaque, target_phys_addr_t offset,
uint32_t value)
{
m5206_mbar_state *s = (m5206_mbar_state *)opaque;
int width;
offset &= 0x3ff;
if (offset >= 0x200) {
hw_error("Bad MBAR write offset 0x%x", (int)offset);
}
width = m5206_mbar_width[offset >> 2];
if (width > 2) {
uint32_t tmp;
tmp = m5206_mbar_readl(opaque, offset & ~3);
if (offset & 3) {
tmp = (tmp & 0xffff0000) | value;
} else {
tmp = (tmp & 0x0000ffff) | (value << 16);
}
m5206_mbar_writel(opaque, offset & ~3, tmp);
return;
} else if (width < 2) {
m5206_mbar_writeb(opaque, offset, value >> 8);
m5206_mbar_writeb(opaque, offset + 1, value & 0xff);
return;
}
m5206_mbar_write(s, offset, value, 2);
}
| 1threat
|
How To Create Associative Array In EcmaScript : <p>I want to create an associative array within the constructor. But the below code throws error. Uncaught TypeError: Cannot set property 'num' of undefined</p>
<pre><code>class Validate{
constructor(){
this.name['num'] = ['one','two'];
}
display() {
console.log(this.name['num']);
}
}
</code></pre>
| 0debug
|
I want to close this android dialogbox after click on listitem : button2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final AlertDialog.Builder alertDialog = new AlertDialog.Builder(PersonalizeSettingsActivity.this);
LayoutInflater inflater = getLayoutInflater();
View convertView = (View) inflater.inflate(R.layout.custom, null);
alertDialog.setView(convertView);
alertDialog.setTitle("Branches");
ListView lv = (ListView) convertView.findViewById(R.id.listView1);
ListViewAdapterBranch adapter = new ListViewAdapterBranch(branchList, getApplicationContext());
lv.setAdapter(adapter);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
Branch branch = branchList.get(position);
button2.setText("Branch: "+branch.getName());
}
});
alertDialog.show();
}
});
here branch list contain the list of item.
now i want to hide or close this custom dialog box when i click on the list item
| 0debug
|
What Linux-Hosted Web Language/Framework is most like asp.net mvc 5+ : <p>I know this is the kind of question that usually gets deleted, but I have to find some answers. I want to build a project in a new technology more suitable to hosting on a Linux server, but I like the way things are done in ASP.NET MVC. I've looked at Rails a bit but I've heard that Rails performs and scales poorly. Any suggestions appreciated.</p>
| 0debug
|
I am using azure devops , and getting unknown field "imagePullPolicy" in io.k8s.api.core.v1.PodSpec while doing helm install : 2019-07-05T09:56:41.1837910Z Error: validation failed: error validating "": error validating data: ValidationError(Deployment.spec.template.spec): unknown field "imagePullPolicy" in io.k8s.api.core.v1.PodSpec
2019-07-05T09:56:41.1980030Z ##[error]Error: validation failed: error validating "": error validating data: ValidationError(Deployment.spec.template.spec): unknown field "imagePullPolicy" in io.k8s.api.core.v1.PodSpec
| 0debug
|
static int encode_frame(AVCodecContext *avctx,
uint8_t *buf, int buf_size,
void *data)
{
int tileno, ret;
J2kEncoderContext *s = avctx->priv_data;
s->buf = s->buf_start = buf;
s->buf_end = buf + buf_size;
s->picture = data;
s->lambda = s->picture->quality * LAMBDA_SCALE;
copy_frame(s);
reinit(s);
if (s->buf_end - s->buf < 2)
return -1;
bytestream_put_be16(&s->buf, J2K_SOC);
if (ret = put_siz(s))
return ret;
if (ret = put_cod(s))
return ret;
if (ret = put_qcd(s, 0))
return ret;
for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){
uint8_t *psotptr;
if ((psotptr = put_sot(s, tileno)) < 0)
return psotptr;
if (s->buf_end - s->buf < 2)
return -1;
bytestream_put_be16(&s->buf, J2K_SOD);
if (ret = encode_tile(s, s->tile + tileno, tileno))
return ret;
bytestream_put_be32(&psotptr, s->buf - psotptr + 6);
}
if (s->buf_end - s->buf < 2)
return -1;
bytestream_put_be16(&s->buf, J2K_EOC);
av_log(s->avctx, AV_LOG_DEBUG, "end\n");
return s->buf - s->buf_start;
}
| 1threat
|
static struct ioreq *ioreq_start(struct XenBlkDev *blkdev)
{
struct ioreq *ioreq = NULL;
if (QLIST_EMPTY(&blkdev->freelist)) {
if (blkdev->requests_total >= max_requests) {
goto out;
}
ioreq = g_malloc0(sizeof(*ioreq));
ioreq->blkdev = blkdev;
blkdev->requests_total++;
qemu_iovec_init(&ioreq->v, BLKIF_MAX_SEGMENTS_PER_REQUEST);
} else {
ioreq = QLIST_FIRST(&blkdev->freelist);
QLIST_REMOVE(ioreq, list);
qemu_iovec_reset(&ioreq->v);
}
QLIST_INSERT_HEAD(&blkdev->inflight, ioreq, list);
blkdev->requests_inflight++;
out:
return ioreq;
}
| 1threat
|
find if a backslash exists in a string Go : <p>I have a string like this:</p>
<p><code>id=PS\\ Old\\ Gen</code></p>
<p>and I would to build a regex to find out if it contains a backslash; one after the other. So in this case, the regex should find 2 occurances as there are 2 <code>\\</code>.</p>
<p>I tried building up the query but couldn't figure out the right way.</p>
<p>i need the regex that's compatiable with Go.</p>
| 0debug
|
React Native styling with conditional : <p>I'm new to react native. I'm trying to change the styling of the TextInput when there is an error.</p>
<p>How can I make my code not as ugly?</p>
<pre><code><TextInput
style={touched && invalid?
{height: 40, backgroundColor: 'white', borderRadius: 5, padding: 10, borderWidth: 2, borderColor: 'red'} :
{height: 40, backgroundColor: 'white', borderRadius: 5, padding: 10}}
</TextInput>
</code></pre>
| 0debug
|
static int dirac_unpack_prediction_parameters(DiracContext *s)
{
static const uint8_t default_blen[] = { 4, 12, 16, 24 };
static const uint8_t default_bsep[] = { 4, 8, 12, 16 };
GetBitContext *gb = &s->gb;
unsigned idx, ref;
align_get_bits(gb);
idx = svq3_get_ue_golomb(gb);
if (idx > 4) {
av_log(s->avctx, AV_LOG_ERROR, "Block prediction index too high\n");
return -1;
}
if (idx == 0) {
s->plane[0].xblen = svq3_get_ue_golomb(gb);
s->plane[0].yblen = svq3_get_ue_golomb(gb);
s->plane[0].xbsep = svq3_get_ue_golomb(gb);
s->plane[0].ybsep = svq3_get_ue_golomb(gb);
} else {
s->plane[0].xblen = default_blen[idx-1];
s->plane[0].yblen = default_blen[idx-1];
s->plane[0].xbsep = default_bsep[idx-1];
s->plane[0].ybsep = default_bsep[idx-1];
}
if (s->plane[0].xbsep < s->plane[0].xblen/2 || s->plane[0].ybsep < s->plane[0].yblen/2) {
av_log(s->avctx, AV_LOG_ERROR, "Block separation too small\n");
return -1;
}
if (s->plane[0].xbsep > s->plane[0].xblen || s->plane[0].ybsep > s->plane[0].yblen) {
av_log(s->avctx, AV_LOG_ERROR, "Block seperation greater than size\n");
return -1;
}
if (FFMAX(s->plane[0].xblen, s->plane[0].yblen) > MAX_BLOCKSIZE) {
av_log(s->avctx, AV_LOG_ERROR, "Unsupported large block size\n");
return -1;
}
s->mv_precision = svq3_get_ue_golomb(gb);
if (s->mv_precision > 3) {
av_log(s->avctx, AV_LOG_ERROR, "MV precision finer than eighth-pel\n");
return -1;
}
s->globalmc_flag = get_bits1(gb);
if (s->globalmc_flag) {
memset(s->globalmc, 0, sizeof(s->globalmc));
for (ref = 0; ref < s->num_refs; ref++) {
if (get_bits1(gb)) {
s->globalmc[ref].pan_tilt[0] = dirac_get_se_golomb(gb);
s->globalmc[ref].pan_tilt[1] = dirac_get_se_golomb(gb);
}
if (get_bits1(gb)) {
s->globalmc[ref].zrs_exp = svq3_get_ue_golomb(gb);
s->globalmc[ref].zrs[0][0] = dirac_get_se_golomb(gb);
s->globalmc[ref].zrs[0][1] = dirac_get_se_golomb(gb);
s->globalmc[ref].zrs[1][0] = dirac_get_se_golomb(gb);
s->globalmc[ref].zrs[1][1] = dirac_get_se_golomb(gb);
} else {
s->globalmc[ref].zrs[0][0] = 1;
s->globalmc[ref].zrs[1][1] = 1;
}
if (get_bits1(gb)) {
s->globalmc[ref].perspective_exp = svq3_get_ue_golomb(gb);
s->globalmc[ref].perspective[0] = dirac_get_se_golomb(gb);
s->globalmc[ref].perspective[1] = dirac_get_se_golomb(gb);
}
}
}
if (svq3_get_ue_golomb(gb)) {
av_log(s->avctx, AV_LOG_ERROR, "Unknown picture prediction mode\n");
return -1;
}
s->weight_log2denom = 1;
s->weight[0] = 1;
s->weight[1] = 1;
if (get_bits1(gb)) {
s->weight_log2denom = svq3_get_ue_golomb(gb);
s->weight[0] = dirac_get_se_golomb(gb);
if (s->num_refs == 2)
s->weight[1] = dirac_get_se_golomb(gb);
}
return 0;
}
| 1threat
|
Is it possible to continuing running JavaScript code after a redirect? : <p>So, on my website, a user types in a subject they want the gist of, then after searching, it redirects them to a Wikipedia API displaying the general idea of the subject. However, there's a bunch of information about the API that gets in the way on the webpage, so I need to use JavaScript to get rid of that excess stuff.</p>
<p>Unfortunately, after changing webpages, it seems I can't run any more code from my website.
Any solution to this?</p>
| 0debug
|
Unable to run python script on Windows computer. I am able on Ubuntu computer : <p>I am unable to successfully run my python script (a simple text-based game) using cmd prompt on my Windows machine. It throws an error on the first "print" statement as I don't have the string enclosed in brackets. I have the entire Python 3.6 package installed.</p>
<p>This does not happen if I run it using the Terminal on my Ubuntu machine, the machine where the code was written.</p>
| 0debug
|
static void lsi_io_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
LSIState *s = opaque;
lsi_reg_writeb(s, addr & 0xff, val);
}
| 1threat
|
Illegal instruction (core dumped) neural network : I have a 3-layed neural network, and I keep getting the above error. I tried the fix here: http://stackoverflow.com/questions/10354147/find-which-assembly-instruction-caused-an-illegal-instruction-error-without-debu
And that actually did fix something because before it wasn't saying (core dumped)
Here's the code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <fcntl.h>
#define NUMPAT 51
#define NUMIN 51
#define NUMHID 20
#define NUMOUT 20
#define rando() ((double)rand()/(RAND_MAX+1))
int main() {
int i, j, k, p, np, op, ranpat[NUMPAT+1], epoch, temp1, temp2, game;
int NumPattern = NUMPAT, NumInput = NUMIN, NumHidden = NUMHID, NumOutput = NUMOUT;
// double Input[NUMPAT+1][NUMIN+1] = { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1 };
double Input[20][2][51] = { ...blah blah a bunch of data the problem isn't here...
double Target[20] = {10,10,3,-4,11,-2,13,-5,4,3,4,5,-5,25,13,25,3,2,5,17};
double SumH[NUMPAT+1][NUMHID+1], WeightIH[NUMIN+1][NUMHID+1], Hidden[NUMPAT+1][NUMHID+1];
double SumO[NUMPAT+1][NUMOUT+1], WeightHO[NUMHID+1][NUMOUT+1], Output[NUMPAT][20];
double DeltaO[NUMOUT+1], SumDOW[NUMHID+1], DeltaH[NUMHID+1];
double DeltaWeightIH[NUMIN+1][NUMHID+1], DeltaWeightHO[NUMHID+1][NUMOUT+1];
double Error, eta = 0.5, alpha = 0.9, smallwt = 0.5;
for( j = 0 ; j < NumHidden ; j++ ) { /* initialize WeightIH and DeltaWeightIH */
for( i = 0 ; i < NumInput ; i++ ) {
DeltaWeightIH[i][j] = 0.0 ;
WeightIH[i][j] = 2.0 * ( rando() - 0.5 ) * smallwt ;
}
}
for( k = 0 ; k < NumOutput ; k ++ ) { /* initialize WeightHO and DeltaWeightHO */
for( j = 0 ; j < NumHidden ; j++ ) {
DeltaWeightHO[j][k] = 0.0 ;
WeightHO[j][k] = 2.0 * ( rando() - 0.5 ) * smallwt ;
}
}
for( epoch = 0 ; epoch < 100000 ; epoch++) { /* iterate weight updates */
for( p = 1 ; p <= NumPattern ; p++ ) { /* randomize order of individuals */
ranpat[p] = p ;
}
for( p = 1 ; p <= NumPattern ; p++) {
np = p + rand() * ( NumPattern + 1 - p ) ;
op = ranpat[p] ; ranpat[p] = ranpat[np] ; ranpat[np] = op ;
}
Error = 0.0 ;
for( np = 1 ; np <= NumPattern ; np++ ) { /* repeat for all the training patterns */
p = ranpat[np];
for (game = 0; game < 20; game++){
for( j = 0 ; j < NumHidden ; j++ ) { /* compute hidden unit activations */
SumH[p][j] = WeightIH[0][j] ;
for( i = 0 ; i < NumInput ; i++ ) {
temp1 = Input[game][0][i] * WeightIH[i][j] ;
temp2 = Input[game][1][i] * WeightIH[i][j] ;
SumH[p][j] += temp1 - temp2 ;
}
Hidden[p][j] = 1.0/(1.0 + exp(-SumH[p][j])) ;
}
for( k = 0 ; k < NumOutput ; k++ ) { /* compute output unit activations and errors */
SumO[p][k] = WeightHO[0][k] ;
for( j = 0 ; j < NumHidden ; j++ ) {
SumO[p][k] += Hidden[p][j] * WeightHO[j][k] ;
}
Output[p][k] = 1.0/(1.0 + exp(-SumO[p][k])) ; /* Sigmoidal Outputs */
/* Output[p][k] = SumO[p][k]; L
ear Outputs */
Error += 0.5 * (Target[k] - Output[p][k]) * (Target[k] - Output[p][k]) ; /* SSE */
/* Error -= ( Target[p][k] * log( Output[p][k] ) + ( 1.0 - Target[p][k] ) * log( 1.0 - Output[p][k] ) ) ; Cross-Entropy Error */
DeltaO[k] = (Target[k] - Output[p][k]) * Output[p][k] * (1.0 - Output[p][k]) ; /* Sigmoidal Outputs, SSE */
/* DeltaO[k] = Target[p][k] - Output[p][k]; Sigmoidal Outputs, Cross-Entropy Error */
/* DeltaO[k] = Target[p][k] - Output[p][k]; Linear Outputs, SSE */
}
for( j = 0 ; j < NumHidden ; j++ ) { /* 'back-propagate' errors to hidden layer */
SumDOW[j] = 0.0 ;
for( k = 0 ; k < NumOutput ; k++ ) {
SumDOW[j] += WeightHO[j][k] * DeltaO[k] ;
}
DeltaH[j] = SumDOW[j] * Hidden[p][j] * (1.0 - Hidden[p][j]) ;
}
for( j = 0 ; j < NumHidden ; j++ ) { /* update weights WeightIH */
DeltaWeightIH[0][j] = eta * DeltaH[j] + alpha * DeltaWeightIH[0][j] ;
WeightIH[0][j] += DeltaWeightIH[0][j] ;
for( i = 0 ; i < NumInput ; i++ ) {
DeltaWeightIH[i][j] = eta * Input[game][0][i] * DeltaH[j] + alpha * DeltaWeightIH[i][j];
WeightIH[i][j] += DeltaWeightIH[i][j] ;
}
}
for( k = 0 ; k < NumOutput ; k ++ ) { /* update weights WeightHO */
DeltaWeightHO[0][k] = eta * DeltaO[k] + alpha * DeltaWeightHO[0][k] ;
WeightHO[0][k] += DeltaWeightHO[0][k] ;
for( j = 0 ; j < NumHidden ; j++ ) {
DeltaWeightHO[j][k] = eta * Hidden[p][j] * DeltaO[k] + alpha * DeltaWeightHO[j][k] ;
WeightHO[j][k] += DeltaWeightHO[j][k] ;
}
}
}
}
if( epoch%100 == 0 ) fprintf(stdout, "\nEpoch %-5d : Error = %f", epoch, Error) ;
if( Error < 0.0004 ) break ; /* stop learning when 'near enough' */
}
int sum = 0;
double weights[51];
for (i = 0; i < NumInput; i++){
for (j = 0; j < NumHidden; j++){
sum = WeightIH[i][j];
}
sum /= 51;
weights[i] = sum;
}
for (i = 0; i < 51; i++){
printf("weight[%d] = %G\n", i, weights[i]);
}
return 1 ;
}
I'm compiling with: `gcc nn.c -O -lm -o nn -mmacosx-version-min=10.11` and it compiles fine.
Any idea what's going on here?
| 0debug
|
av_cold int swri_rematrix_init(SwrContext *s){
int i, j;
int nb_in = av_get_channel_layout_nb_channels(s->in_ch_layout);
int nb_out = av_get_channel_layout_nb_channels(s->out_ch_layout);
s->mix_any_f = NULL;
if (!s->rematrix_custom) {
int r = auto_matrix(s);
if (r)
return r;
}
if (s->midbuf.fmt == AV_SAMPLE_FMT_S16P){
s->native_matrix = av_calloc(nb_in * nb_out, sizeof(int));
s->native_one = av_mallocz(sizeof(int));
for (i = 0; i < nb_out; i++)
for (j = 0; j < nb_in; j++)
((int*)s->native_matrix)[i * nb_in + j] = lrintf(s->matrix[i][j] * 32768);
*((int*)s->native_one) = 32768;
s->mix_1_1_f = (mix_1_1_func_type*)copy_s16;
s->mix_2_1_f = (mix_2_1_func_type*)sum2_s16;
s->mix_any_f = (mix_any_func_type*)get_mix_any_func_s16(s);
}else if(s->midbuf.fmt == AV_SAMPLE_FMT_FLTP){
s->native_matrix = av_calloc(nb_in * nb_out, sizeof(float));
s->native_one = av_mallocz(sizeof(float));
for (i = 0; i < nb_out; i++)
for (j = 0; j < nb_in; j++)
((float*)s->native_matrix)[i * nb_in + j] = s->matrix[i][j];
*((float*)s->native_one) = 1.0;
s->mix_1_1_f = (mix_1_1_func_type*)copy_float;
s->mix_2_1_f = (mix_2_1_func_type*)sum2_float;
s->mix_any_f = (mix_any_func_type*)get_mix_any_func_float(s);
}else if(s->midbuf.fmt == AV_SAMPLE_FMT_DBLP){
s->native_matrix = av_calloc(nb_in * nb_out, sizeof(double));
s->native_one = av_mallocz(sizeof(double));
for (i = 0; i < nb_out; i++)
for (j = 0; j < nb_in; j++)
((double*)s->native_matrix)[i * nb_in + j] = s->matrix[i][j];
*((double*)s->native_one) = 1.0;
s->mix_1_1_f = (mix_1_1_func_type*)copy_double;
s->mix_2_1_f = (mix_2_1_func_type*)sum2_double;
s->mix_any_f = (mix_any_func_type*)get_mix_any_func_double(s);
}else if(s->midbuf.fmt == AV_SAMPLE_FMT_S32P){
s->native_one = av_mallocz(sizeof(int));
*((int*)s->native_one) = 32768;
s->mix_1_1_f = (mix_1_1_func_type*)copy_s32;
s->mix_2_1_f = (mix_2_1_func_type*)sum2_s32;
s->mix_any_f = (mix_any_func_type*)get_mix_any_func_s32(s);
}else
av_assert0(0);
for (i = 0; i < SWR_CH_MAX; i++) {
int ch_in=0;
for (j = 0; j < SWR_CH_MAX; j++) {
s->matrix32[i][j]= lrintf(s->matrix[i][j] * 32768);
if(s->matrix[i][j])
s->matrix_ch[i][++ch_in]= j;
}
s->matrix_ch[i][0]= ch_in;
}
if(HAVE_YASM && HAVE_MMX) swri_rematrix_init_x86(s);
return 0;
}
| 1threat
|
Installed a package with Anaconda, can't import in Python : <p>Forgive me but I'm new to python. I've installed a package (theano) using
<code>conda install theano</code>, and when I type <code>conda list</code>, the package exists</p>
<p>However, when I enter the python interpreter by running <code>python</code>, and try to import it with <code>import theano</code>, I get an error: "no module named theano", and when I list all python modules, theano doesn't exist.</p>
<p>What am I missing?</p>
| 0debug
|
static int parallels_open(BlockDriverState *bs, int flags)
{
BDRVParallelsState *s = bs->opaque;
int i;
struct parallels_header ph;
bs->read_only = 1;
if (bdrv_pread(bs->file, 0, &ph, sizeof(ph)) != sizeof(ph))
goto fail;
if (memcmp(ph.magic, HEADER_MAGIC, 16) ||
(le32_to_cpu(ph.version) != HEADER_VERSION)) {
goto fail;
}
bs->total_sectors = le32_to_cpu(ph.nb_sectors);
s->tracks = le32_to_cpu(ph.tracks);
s->catalog_size = le32_to_cpu(ph.catalog_entries);
s->catalog_bitmap = g_malloc(s->catalog_size * 4);
if (bdrv_pread(bs->file, 64, s->catalog_bitmap, s->catalog_size * 4) !=
s->catalog_size * 4)
goto fail;
for (i = 0; i < s->catalog_size; i++)
le32_to_cpus(&s->catalog_bitmap[i]);
qemu_co_mutex_init(&s->lock);
return 0;
fail:
if (s->catalog_bitmap)
g_free(s->catalog_bitmap);
return -1;
}
| 1threat
|
new operator allocates more size than declared . WHY : <p>I am using codeblocks 16.01. And here in the code given below I have used new operator and declared array - pointer .</p>
<pre><code>#include <iostream>
using namespace std;
int main()
{
int *p = new int[2];
for(int i=0; i<10;i++)
{
cout<<"\n Enter the element "<<i << " : ";
cin>>*(p+i);
}
for(int i=0; i<10;i++)
cout<<"\n"<<*(p+i)<<" : "<< i << "th element ";
}
</code></pre>
<p>Here is the image why i have doubt<a href="https://i.stack.imgur.com/WilsX.png" rel="nofollow noreferrer">the size declared is 2 but the array is able to store for 7 elements also why is this happening ??. Even I tried to increase the size to 5 then also it took and stored 7 elements value but rest it gave the address. Why ? </a> </p>
| 0debug
|
String Error when using system.out.println : <p>HERE IS MY CODE</p>
<pre><code>import java.util.Scanner; //needed to use Scanner for input
public class Pandora {
public static void main(String[] args) {
//Declare variables
String lastName = "";
String newChannel = "";
int Selection=0;
//Create a Scanner object
Scanner input = new Scanner(System.in);
//Display the Opening Statement which includes the Pandora Menu
System.out.println("******WELCOME TO PANDORA!*******" );
System.out.println(" Pandora Menu:" );
System.out.println(" 1- Create New Pandora Channel" );
System.out.println(" 2- Play Pandora Channel" );
System.out.println(" 3 -Exit Pandora" );
//Prompt the user for their last name and menu choice option
System.out.print("Please Input last Name and Menu Choice");
//Read the user's lastname and read the user's menu choice; Parse string if necessary!
lastName = input.nextLine();
Selection = input.nextInt();
//Convert last name to uppercase
lastName = lastName.toUpperCase();
input.nextLine();
//Control statement (if()/else if() or switch()) that is based on the user's menu choice
//process the user's menu choice (options: 1, 2, 3, other)
if (Selection == 1){
System.out.println(" You have selected the CREATE NEW PANDORA CHANNEL menu item!");
System.out.println(" Please enter the name of the New Channel:");
newChannel = input.nextLine();
newChannel = newChannel.toUpperCase();
System.out.println( " You have successfully created the following Pandora Channel:)"+newChannel = newChannel.toUpperCase();
}else if (Selection == 2){
System.out.println("You have selected the PLAY PANDORA CHANNEL menu item!");
System.out.println("The user:currently has the following channels");
System.out.println(" 1- Justin Bieber");
System.out.println(" 2- Heartland");
System.out.println(" 3- Carrie Underwood");
System.out.println(" 4- The Band Perry");
System.out.println(" 5- Kelly Clarkson");
System.out.println(" 6- Florida Georgia Line");
System.out.println(" 7- Blake Shelton");
System.out.println(" 8- Rihanna");
System.out.println(" 9- Daughtry");
System.out.println(" 10- Ashley Tisdale");
//Prompt the user for their selection
System.out.print("\n Which channel would you like to listen to? (Enter 1, 2, 3, 4, 5, 6, 7, 8, 9 , or 10): ");
int selection = input.nextInt();
switch(selection){
case 1: System.out.println("You are now listening to: Justin Beiber");
break;
case 2: System.out.println(" You are now listening to: Heartland");
break;
case 3: System.out.println(" You are now listening to: Carrie Underwood");
break;
case 4: System.out.println(" You are now listening to: The Band Perry");
break;
case 5: System.out.println(" You are now listening to: Kelly Clarkson");
break;
case 6: System.out.println(" You are now listening to: Florida Georgia Line");
break;
case 7: System.out.println(" You are now listening to: Blake Shelton");
break;
case 8: System.out.println(" You are now listening to: Rihanna");
break;
case 9: System.out.println(" You are now listening to: Daughtry");
break;
case 10: System.out.println(" You are now listening to: Ashley Tisdale");
break;
default: System.out.println("Incorrect Selection");
break;
}
System.out.println(lastName = lastName.toUpperCase() +" Thank you being a valued listener!" );
}else if (Selection == 3) {
System.out.println("You have selected the EXIT PANDORA menu item");
System.out.println(lastName = lastName.toUpperCase() +" Thank you being a valued listener!" );
}else{
System.out.println(Selection + "is not a valid selection. Please try again.");
System.out.println(lastName = lastName.toUpperCase() +" Thank you being a valued listener!" );
//Display Thank you message
System.out.println("*******GOODBYE PANDORA LISTENER*******");
}
}
}//end of class
</code></pre>
<p>And tHis is the error I get
Pandora.java:41: error: ')' expected
System.out.println( " You have successfully created the following Pandora Channel:)"+newChannel = newChannel.toUpperCase();</p>
| 0debug
|
Force not working in non-interactive mode : <pre><code>Deleting folder 'C:\agent\_work\2\a\Foo\_PublishedWebsites\Foo\sourcejs'
Remove-Item : Windows PowerShell is in NonInteractive mode. Read and Prompt functionality is not available.
At C:\agent\_work\2\s\Build\Deployment\PrepareWebsites.ps1:29 char:2
+ Remove-Item -Path $source -Force -Confirm:$false | Where { $_.PSIsContainer }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Remove-Item], PSInvalidOperationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.RemoveItemCommand
Process completed with exit code 1 and had 1 error(s) written to the error stream.
</code></pre>
<p>I have tried adding -Force and -Confirm:$false but I still get this error. Using TFS 2015 builds. Anyone got any ideas?</p>
| 0debug
|
nginx v1.10.2 Passenger 403 : Multiple virtual hosts on my workstation, just stopped working. Upon an update of `nginx` to v1.10.2 and a new `Passenger` `locations.ini` file pointer in the `nginx.conf` file, I'm getting `403 Forbidden` permissions errors on all of these vhosts. No clue what to look at.
passenger_root /usr/local/opt/passenger/libexec/src/ruby_supportlib/phusion_passenger/locations.ini;
passenger_ruby /usr/bin/ruby;
But, `which ruby`:
/Users/rich/.rbenv/shims/ruby
So I changed that directive to the one above. Restart `nginx`, and still the same. The error reported:
2017/10/23 19:51:36 [error] 10863#0: *61 directory index of "/Library/WebServer/Documents/HQ/public/" is forbidden, client: 127.0.0.1, server: hq.local, request: "GET / HTTP/1.1", host: "hq.local"
Permissions haven't changed ever. Not to mention they are relaxed (only seen by me):
drwxrwxrwx 20 rich admin 680B Jun 17 01:52 HQ
cd HQ:
drwxr-xr-x 8 rich admin 272B Jul 12 17:32 public
Odd stuff. Any ideas appreciated how to get all this serving again properly. It seems permissions were completely thrown off, and I'm not sure if it was the `nginx` update or not. Cheers
| 0debug
|
document.getElementById('input').innerHTML = user_input;
| 1threat
|
conversion of integers to roman numerals (python) : I understand there were many similar questions being asked on this topic.But I still have some doubts need to be clear
def int_to_roman(input):
if type(input) != type(1):
raise TypeError, "expected integer, got %s" % type(input)
if not 0 < input < 4000:
raise ValueError, "Argument must be between 1 and 3999"
ints = (1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1)
nums = ('M', 'CM', 'D', 'CD','C', 'XC','L','XL','X','IX','V','IV','I')
result = ""
for i in range(len(ints)):
count = int(input / ints[i])
result += nums[i] * count
input -= ints[i] * count
return result
I dont really understand the code below:
for i in range(len(ints)):
count = int(input / ints[i])
result += nums[i] * count
input -= ints[i] * count
anyone please explain this code?? Thanks!! If there is any example it would be best!!!
| 0debug
|
No output on console after ctrl^D? : From K&R ansi c, section 1.5.3:
the line count program is replicated exactly in clion. I'm using Mngw64. There's no output on console when the getchar() comparison is made with EOF. it wotks fine with other characters. Using CTRL^D exits the program with 'code 0' without any output on console. I've tried running it in bash but still no output. Stuck at this from a very long time.
| 0debug
|
How to pass data between components in angular : <pre><code><div class="container-fluid fill">
<app-navbar></app-navbar>
<div class="container fill">
<div class="row padding">
<div class="col-md-3 ">
<app-sidebar></app-sidebar>
</div>
<div class="col-md-6 text-center">
<app-menu-section></app-menu-section>
</div>
<div class="col-md-3 ">
<app-cart></app-cart>
</div>
</div>
</div>
</div>
</code></pre>
<p>app-sidebar renders a category menu and when a category is Selected I want to pass the value to menu section component to render appropriate category</p>
<p>So how to pass the value between two components which are not parent child</p>
| 0debug
|
cut the text length as the screen gets smaller : I want the text length to shrink when the screen gets smaller
`<div class="dress-card hvr-bob">
<div class="dress-card-head">
<img class="dress-card-img-top" src="img/rdr2.jpg" alt="">
</div>
<div class="dress-card-body">
<h2 class="dress-card-title">Red Dead Redemption 2</h2>
<p class="dress-card-para">Social Club Key</p>
<p class="dress-card-para"><span class="dress-card-price">200TL  </span><!--<span class="dress-card-crossed">300TL</span><span class="dress-card-off"> İndirim!</span>--></p>
<div class="row">
<div class="col-md-6 card-button"><a style="text-decoration: none;" href=""><div class="card-button-inner bag-button"><i class="fas fa-shopping-cart"></i> Satın Al</div></a></div>
<div class="col-md-6 card-button"><a style="text-decoration: none;" href=""><div class="card-button-inner wish-button"><i class="fas fa-shopping-basket"></i> Sepete Ekle</div></a></div>
</div>
</div>
</div>
</div>`
help
| 0debug
|
static void block_job_defer_to_main_loop_bh(void *opaque)
{
BlockJobDeferToMainLoopData *data = opaque;
AioContext *aio_context;
aio_context_acquire(data->aio_context);
aio_context = blk_get_aio_context(data->job->blk);
if (aio_context != data->aio_context) {
aio_context_acquire(aio_context);
}
data->job->deferred_to_main_loop = false;
data->fn(data->job, data->opaque);
if (aio_context != data->aio_context) {
aio_context_release(aio_context);
}
aio_context_release(data->aio_context);
g_free(data);
}
| 1threat
|
onResume() and onPause() for widgets on Flutter : <p>Right now, a widget only has initeState() that gets triggered the very first time a widget is created, and dispose(), which gets triggered when the widget is destroyed. Is there a method to detect when a widget comes back to the foreground? and when a widget is about to go to the background because another widget just was foregrounded?
It's the equivalent of onResume and onPause being triggered for Android, and viewWillAppear and viewWillDisappear for ios</p>
| 0debug
|
static void virtio_ccw_device_plugged(DeviceState *d)
{
VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
SubchDev *sch = dev->sch;
sch->id.cu_model = virtio_bus_get_vdev_id(&dev->bus);
css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid,
d->hotplugged, 1);
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.