|
Would GetDiskFreeSpaceEx or similar do the trick?
I am not sure if your concern about fragmenting the disk is necessary.
Why do you want to second guess the OS? Just my opinion of course.
Vaclav
|
|
|
|
|
Hi Friends
I Am new to this site
i got one problem regarding playback of mpeg compressed files
iam using windows mfc for this
iam receiving the file from the board via tcp protocol and iam storing in the hard disk and then calling decompression function like this
Decompression("filename.M4V");
HERE I WANT DIRECTLY WITHOUT STORING IN THE HARD DISK
IF WE WON'T GIVE EXTENSION TO FILE(LIKE .M4V,.MP4 ETC)IT IS NOT WORKING AT THE FUNCTION guess_format OF AV LIBRARY.
THE DETAILS OF THIS guess_format FUNCTION I DON'T KNOW
while i am storing the file (around 2 mb) in the buffer and calling decompression it is not working.but if you take from hard disk it is working....
pls help me
Girish
|
|
|
|
|
Can you post your code?
I am "guessing" - do you have your data somewhere in memory (buffer) also?
Since I know nothing about M4V file type - is the M4V extension embedded in file header? If not how can your function "guess" the format without the extension?
PS Just the name "guess_format" makes me suspicious. Computers are no good in "guessing".
Vaclav
|
|
|
|
|
|
Got the code and will take a look in the morning.
It is late here - 23:10 !
You may want to delete it from here so you do not get into trouble taking too much space. Just FYI.
Vaclav
|
|
|
|
|
thanks man
iam deleting the code from post
waiting for u r reply
good night
bye
Girish
|
|
|
|
|
hi vaclav
what happen 2 my problem,u got the code na
give me response
Girish
|
|
|
|
|
hi
please give me solution
i am still not able to find the solution
Girish
|
|
|
|
|
Hi all,
I have a problem with Visual c++ 6.0 compiler.
First, I define this template class and these 2 operators:
template <class T>
class mat
{};
template <class T> inline mat<T> operator +(mat<T> m1,T el){return m1;};
inline mat<double> operator -(mat<double> m1,double el){return m1;};
Then, I try to compile these istructions:
mat<double> A,B;
B=A+1;
B=A+1.0;
B=A-1;
The compiler give an error for the first operator if I don't specify the correct type of the right-hand operand; for the second operator there are no problems. Anyone can explain me why there is a difference between the two operators in the implicit casting? Are there a way to avoid this problem?
Thanks in advance!
|
|
|
|
|
Well, I made a test of your code on my VS2005 and a got an additional warning that, IMHO, gives new insight to the argument.
error C2782: 'mat<t> operator +(mat<t>,T)' : template parameter 'T' is ambiguous
It seems that, in the statement B=A+1; , the compiler has to choose between forcing the int to double and the opposite while in the statement B=A-1; there is no alternative to casting int to double (hence specialization turns out to be useful).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Thank you for the reply! Now I understand the problem, but I prefer that the class works without this type casting. The only solution I have in mind is to write a different version of the operators for each fundamental type (I hoped to avoid that).
|
|
|
|
|
dear all
double a [3][4] = {{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767}};
for (int number = 1; number <= 10; number ++)
{
cout << setw(4) << number << endl;
printArray(a);
}
number ++;
from above, i can get 10 3x4 matrix, but they are all same values, so how to do they will be random?
thanks a lot.
by the way, how to brief definition of array a?
thanks
Li Zhiyuan
3/01/2008
|
|
|
|
|
li zhiyuan wrote: from above, i can get 10 3x4 matrix, but they are all same values, so how to do they will be random?
because rand() is evaluated once, and the returned value used to initialise all of the matrix elements.
see David Crow point [^].
li zhiyuan wrote: by the way, how to brief definition of array a?
To solve both problems, to compact source code, assign dynamically the matrix elements, i.e.
for (i=0; i<3; i++)
for (j=0; j<4; j++)
a[i][j] = (double)rand()/RAND_MAX;
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
modified on Thursday, January 03, 2008 9:18:29 AM
|
|
|
|
|
CPallini wrote: because rand() is evaluated once...
Then why is it being called 12 times?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
You're right. With a look at disassembly,I supposed a weird kind of optimization happend, but I was wrong : hence no initialization problem, maybe, in fact, that, as you suppose, his output function has flaws.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
dear all
actually i had finished this case, but i would like to brief this code, so after tried, but couldn't.the orignal code is here, anyone can brief it? thanks..
int main()
{
int number;
double a [3][4] = {{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767}};
double a2 [3][4] = {{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767}};
double a3 [3][4] = {{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767}};
double a4 [3][4] = {{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767}};
double a5 [3][4] = {{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767}};
double a6 [3][4] = {{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767}};
double a7 [3][4] = {{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767}};
double a8 [3][4] = {{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767}};
double a9 [3][4] = {{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767}};
double a10 [3][4] = {{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767}};
for (int number = 1; number <= 10; number ++)
{
cout << setw(4) << number << endl;
printArray(a);
}
number ++;
cout << setw(6) << "\na1:" << endl;
printArray(a1);
cout << endl;
cout << setw(6) << "\na2:" << endl;
printArray(a2);
cout << endl;
cout << setw(6) << "\na3:" << endl;
printArray(a3);
cout << endl;
cout << setw(6) << "\na4:" << endl;
printArray(a4);
cout << endl;
cout << setw(6) << "\na5:" << endl;
printArray(a5);
cout << endl;
cout << setw(6) << "\na6:" << endl;
printArray(a6);
cout << endl;
cout << setw(6) << "\na7:" << endl;
printArray(a7);
cout << endl;
cout << setw(6) << "\na8:" << endl;
printArray(a8);
cout << endl;
cout << setw(6) << "\na9:" << endl;
printArray(a9);
cout << endl;
cout << setw(6) << "\na10:" << endl;
printArray(a10);
cout << endl;
return 0;
}
void printArray(double a[3][4])
{
for ( int i =0; i< 3; i++)
{
for (int j = 0; j < 4; j++)
cout <<setw(10) << setprecision(6) << setiosflags(ios::fixed|ios::showpoint) << a[i][j] << setw(10) ;
cout << endl;
}
}
from above code, i can obtain 10 3x4 random real number matrix, but i need to brief it.
thanks a lot in advance
Li Zhiyuan
4/01/2008
|
|
|
|
|
li zhiyuan wrote: anyone can brief it?
double a[3][4];
double a2[3][4];
double a3[3][4];
...
initArray(a);
initArray(a2);
initArray(a3);
...
printArray(a);
printArray(a2);
printArray(a3);
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Perhaps maybe nicer with an array of matrices:
int main()
{
double [10][3][4];
int i, j, k;
for (i=0; i<10; i++)
for (j=0; j<3; j++)
for (k=0; k<4; k++)
a[i][j][k] = (double)rand()/RAND_MAX;
for (i=0; i<10; i++)
{
cout << "\na[" << i << "]:" << endl;
printArray(a[i]);
}
return 0;
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
li zhiyuan wrote: printArray(a);
Your array a is being initialized correctly, so the problem lies within the printArray() function.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
You should seed the random number generator before each retrieval of a random number.
I suggest to create a function which returns a random integer.
Note:
Functions such as time(NULL) or clock() have a high probability of seeding the generator with the same seed since your code will execute faster than the time quantum available to such functions.
Try something like the following:
double DblRand()
{
unsigned __int64 ui64Seed;
__asm
{
rdtsc;
mov dword ptr ui64Seed, eax;
mov dword ptr ui64Seed + 4, edx;
}
srand((unsigned int)ui64Seed + clock());
return (double)rand() / 32767;
}
Best Wishes,
-David Delaune
|
|
|
|
|
Randor wrote: You should seed the random number generator before each retrieval of a random number.
Actually this is not true.
You should seed random number generator only when you need to re-start the sequence from another point.
For instance, if you develop a card game using the random generator to shuffle the cards then maybe nice to restart the random number generator from a different point of the sequence on every new game.
Randor wrote: double DblRand()
{
unsigned __int64 ui64Seed;
__asm
{
rdtsc;
mov dword ptr ui64Seed, eax;
mov dword ptr ui64Seed + 4, edx;
}
srand((unsigned int)ui64Seed + clock());
return (double)rand() / 32767;
}
Are you sure that such a function satisfy random number generation better that random generator itself?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
CPallini wrote: Actually this is not true.
I think you are misunderstanding my suggestion. I am giving the author of the question a best-practice tip on secure number generation. I was not saying that the re-seeding was neccessary.
Best Wishes,
-David Delaune
|
|
|
|
|
Randor wrote: I think you are misunderstanding my suggestion.
Maybe.
Randor wrote: I am giving the author of the question a best-practice tip on secure number generation.
Re-seeding the random number generator each time you need a random number is not a best-practice behaviour (at least IMHO )
Happy new year & best wishes to you.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
dear all
this is main function:
double a [3][4] = {{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767},{(double)rand()/32767,(double)rand()/32767,(double)rand()/32767,(double)rand()/32767}};
for (int number = 1; number <= 10; number ++)
{
cout << setw(4) << number << endl;
printArray(a);
}
number ++;
void printArray ( double a [3][4])
{
for ( int i =0; i< 3; i++)
{
for (int j = 0; j < 4; j++)
cout <<setw(10) << setprecision(6) << setiosflags(ios::fixed|ios::showpoint) << a[i][j] << setw(10) ;
cout << endl;
}
}
how can i get 10 3x4 matrix and the each value inside array a is random real number....thanks a lot.
Li Zhiyuan
4/01/2008
|
|
|
|
|
I read that answer and yes, I saw before that tutorial but it really could not help too much
I just want an opinion of someone who made a project with XPCOM components before and know how to start things up. Is there anybody....?
Thanks again
|
|
|
|
|