C Programmers: HELP!!!

Discussion in 'Computers' started by Andy Olivera, May 15, 2003.

  1. Andy Olivera

    Andy Olivera Screenwriter

    Joined:
    Jul 25, 2000
    Messages:
    1,303
    Likes Received:
    0
    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.
     
  2. Sean Eldridge

    Sean Eldridge Second Unit

    Joined:
    Jan 13, 2000
    Messages:
    272
    Likes Received:
    0
    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.
     
  3. Sean Eldridge

    Sean Eldridge Second Unit

    Joined:
    Jan 13, 2000
    Messages:
    272
    Likes Received:
    0
    Try making it less than or equal to:

    while(i
     
  4. Steven K

    Steven K Supporting Actor

    Joined:
    Jan 10, 2000
    Messages:
    830
    Likes Received:
    0
    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)
     
  5. Ken Chan

    Ken Chan Producer

    Joined:
    Apr 11, 1999
    Messages:
    3,301
    Likes Received:
    0
    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
     
  6. Steven K

    Steven K Supporting Actor

    Joined:
    Jan 10, 2000
    Messages:
    830
    Likes Received:
    0
     
  7. MikeAlletto

    MikeAlletto Cinematographer

    Joined:
    Mar 11, 2000
    Messages:
    2,369
    Likes Received:
    0
     
  8. Steven K

    Steven K Supporting Actor

    Joined:
    Jan 10, 2000
    Messages:
    830
    Likes Received:
    0
    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.
     
  9. Sean Eldridge

    Sean Eldridge Second Unit

    Joined:
    Jan 13, 2000
    Messages:
    272
    Likes Received:
    0
    I never use ints, always longs. Doing my best Forrest Gump impersonation-

    You never know what you're going to get.

    Sean
     
  10. Ken Chan

    Ken Chan Producer

    Joined:
    Apr 11, 1999
    Messages:
    3,301
    Likes Received:
    0
    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 [​IMG]

    longs are probably bigger and slower, and absurdly large for most operations.

    //Ken
     
  11. Steven K

    Steven K Supporting Actor

    Joined:
    Jan 10, 2000
    Messages:
    830
    Likes Received:
    0
    DEADBEEF!
    DEADBEEF!

    [​IMG]

    (Unix programmers will understand...)
     
  12. Andy Olivera

    Andy Olivera Screenwriter

    Joined:
    Jul 25, 2000
    Messages:
    1,303
    Likes Received:
    0
    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)... [​IMG]
     

Share This Page