What's new

C Programmers: HELP!!! (1 Viewer)

Andy Olivera

Screenwriter
Joined
Jul 25, 2000
Messages
1,303
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'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.
 

Sean Eldridge

Second Unit
Joined
Jan 13, 2000
Messages
272
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.
 

Steven K

Supporting Actor
Joined
Jan 10, 2000
Messages
830
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 VCDMPEG-1 by default)
 

Ken Chan

Senior HTF Member
Joined
Apr 11, 1999
Messages
3,302
Real Name
Ken
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
 

MikeAlletto

Senior HTF Member
Joined
Mar 11, 2000
Messages
2,369
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.
 

Steven K

Supporting Actor
Joined
Jan 10, 2000
Messages
830
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.
 

Sean Eldridge

Second Unit
Joined
Jan 13, 2000
Messages
272
I never use ints, always longs. Doing my best Forrest Gump impersonation-

You never know what you're going to get.

Sean
 

Ken Chan

Senior HTF Member
Joined
Apr 11, 1999
Messages
3,302
Real Name
Ken
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
 

Andy Olivera

Screenwriter
Joined
Jul 25, 2000
Messages
1,303
About the use of int, one of the things I remembered from the course was that it varies, so I've always used short/long. That said, Ken is right. I used int instead and now it's behaving as it should. I wasn't sure about the %d specifier, but I looked up a reference and couldn't find a specifier meant specifically for short.

Steven, I'll be running this on files I get from the net. The problem with just doing Inverse Telecine is that I get weird patterns sometimes and it deletes the wrong frames. I also tried the VirtualDub/AVISynth decimate filters, but I couldn't get those to work right, either. So, I figured the only reliable way to do it would be to have them removed according to the specific pattern.

Anyway, thanks for all the help, guys! This definitely brought back some memories. One of them being my not having enough patience to do this on any large scale(aka, as a career)... :D
 

Users who are viewing this thread

Sign up for our newsletter

and receive essential news, curated deals, and much more







You will only receive emails from us. We will never sell or distribute your email address to third party companies at any time.

Forum statistics

Threads
357,037
Messages
5,129,360
Members
144,284
Latest member
Ertugrul
Recent bookmarks
0
Top