|
|
 |
 |
 |
05-15-2003, 08:03 PM
|
#1 of 12
|
|
Member
Join Date: Jul 2000
Local Time: 11:20 AM
Local Date: 10-12-2008
Posts: 1,583
|
Using the meager knowledge from a C course I took 6+ years ago, I'm trying to write a small program that outputs an AVISynth script for decimating frames based on a specific pattern. I don't have the output in the correct order, yet, but that's not the problem. One loop seems to be getting ignored. The particular loop:
while(i < unique)
{
printf("\nSequence:");
scanf("%d", &pattern[i]);
i++;
}
I've tried using do/while and for loops as well, but I get the same result. I tried running the commands outside the loop and it worked fine(but it only runs once, obviously).
The whole couple dozen lines of code are here. I know it's probably something simple I'm missing, but I've looked over everything a dozen or so times and I don't see it. Any help would be appreciated.
\"It is not, and never should be, the policy of the law to require the protection of the foolhardy or reckless few and therefore to deprive, or interfere with, the enjoyment by the remainder of society of the liberties and amenities to which they are rightly entitled.\" -unknown
\"As a society, we tend to believe that every opinion is valid, that there are often no wrong answers, and that self esteem is more important than knowledge. So we grow more confident and more ignorant.\" -Stephen W. Stanton
DVD Count: 205 / LD Count: 51 / My Top & Bottom 20 Films Of All Time
|
|
|
 |
 |
05-15-2003, 09:17 PM
|
#2 of 12
|
|
Member
Join Date: Jan 2000
Local Time: 02:20 PM
Local Date: 10-12-2008
Posts: 888
|
What are you intializing "i" to and what is "unique?"
Sean
edit: Found your code and I'm looking at it now. Don't know if I'll be able to help.
|
|
|
05-15-2003, 09:24 PM
|
#3 of 12
|
|
Member
Join Date: Jan 2000
Local Time: 02:20 PM
Local Date: 10-12-2008
Posts: 888
|
Try making it less than or equal to:
while(i <= unique)
or
for(i = 0; i <= unique; i++)
Sean
|
|
|
05-15-2003, 11:11 PM
|
#4 of 12
|
|
Join Date: Jan 2000
Local Time: 01:20 PM
Local Date: 10-12-2008
Posts: 1,672
|
Hi Andy,
Not related to the C help you are looking for (looks like Sean provided help but let me know if you need further help) but what are you using AVISynth for exactly?
Are you using it as a frameserver for an MPEG encoder? Why are you trying to decimate frames? One possibility that I can think of is that you are trying to convert an NTSC Video SVCD (29.97 FPS) to an NTSC Film SVCD (23.97 FPS) known as "Inverse Telecining."
You might be able to use a utility called "pulldown.exe" to do this. I use it all the time to do the reverse of this... I encode my SVCDs as 23.97 FPS then use pulldown.exe to write the pulldown flags inside of the file (still 24 FPS but the player is "tricked" into thinking it is 30). This way, your DVD player will perform its own telecine (which it can do for VCD\MPEG-1 by default)
|
|
|
05-16-2003, 03:08 AM
|
#5 of 12
|
|
Member
Join Date: Apr 1999
Local Time: 11:20 AM
Local Date: 10-12-2008
Posts: 3,303
|
As a general rule, you should use int, which is the "natural size" for an integer, unless you have a specific reason otherwise. The %d specifier expects an int, not a short. So just change the variable type declaration.
//Ken
|
|
|
05-16-2003, 07:43 AM
|
#6 of 12
|
|
Join Date: Jan 2000
Local Time: 01:20 PM
Local Date: 10-12-2008
Posts: 1,672
|
Quote:
|
As a general rule, you should use int
|
I disagree... and int has a platform specific size, so writing code which uses ints can lead to the code being unportable.
|
|
|
05-16-2003, 11:53 AM
|
#7 of 12
|
|
Member
Join Date: Mar 2000
Local Time: 01:20 PM
Local Date: 10-12-2008
Posts: 2,751
|
Quote:
|
I disagree... and int has a platform specific size, so writing code which uses ints can lead to the code being unportable.
|
But if he's just writing this for his own use on his own machine and noone else who cares about portability. If he does care at a later date its not like its a massively complex little program. It'll take about 5 seconds to fix whatever is wrong at a later date to make it compile.
Michael Alletto
|
|
|
05-16-2003, 12:38 PM
|
#8 of 12
|
|
Join Date: Jan 2000
Local Time: 01:20 PM
Local Date: 10-12-2008
Posts: 1,672
|
Mike,
I agree that in THIS case, using its wont hurt.
However, I was responding to Ken's post in which he said "As a general rule, you should use int." I think that, in general, this is not the best solution.
Why not just use long? Then, you always know what size your data type is.
|
|
|
05-16-2003, 03:11 PM
|
#9 of 12
|
|
Member
Join Date: Jan 2000
Local Time: 02:20 PM
Local Date: 10-12-2008
Posts: 888
|
I never use ints, always longs. Doing my best Forrest Gump impersonation-
You never know what you're going to get.
Sean
|
|
|
05-16-2003, 05:39 PM
|
#10 of 12
|
|
Member
Join Date: Apr 1999
Local Time: 11:20 AM
Local Date: 10-12-2008
Posts: 3,303
|
A long is also platform-specific; it is only guaranteed to be at least 32 bits. On platforms where int is 16, then long will be 32. If int is 32, then long could be 32 or 64. That's what makes C so much fun
longs are probably bigger and slower, and absurdly large for most operations.
//Ken
|
|
|
05-16-2003, 0 | |