VideoHelp Forum




+ Reply to Thread
Results 1 to 12 of 12
  1. Need caching in a small video app im making to speed it up, and is looking for the fastest way to extend an array, since i cant know in advance how many records will be needed, or a fast workaround. The best in my opinion would be to use something similar to a C++ linked list, but i have no idea how to do this in VB. I have extended arrays in VB by copying them and using redim in apps i wrote before, but i dont consider this to be optimal for speed, even less so because i need to use at least 2 big arrays for the cached info. Does anyone know a faster way to extend an array or a workaround?
    Quote Quote  
  2. Normally ReDim is quite fast (it is used in game programming too). If the problem is that you will have to extend your array every few msec, then I would try to use a big array and only extend this if needed.
    Quote Quote  
  3. I guess it will have to do then, if thats how they usually do it. i cant find a way to make linked lists without writing a support app in C++, and i like to keep it all in one app if possible. I thought there were better ways but if you say this is the method most commonly used i guess its the best way after all. Thanx.
    Remember VB4? Coulnt even set an array equal to another, had to loop the shit, then loop back again, that sucked.
    Quote Quote  
  4. Member SaSi's Avatar
    Join Date
    Jan 2003
    Location
    Hellas
    Search Comp PM
    Using

    Redim Preserve

    in VB is almost as fast as malloc() in C.

    The trick to gain performance is to redim in chunks. If, for example, you array is known to span in the hundreds of rows, starting with 50 rows or so and expanding by 10 additional rows at a time will cut the redim cost by a factor of 10.

    An even better approach is the following:

    If your array grows to handle an input file (of a known size), then as you parse the input file you can tell how much of the file you have parsed (use the loc() function.)

    If you have parsed, say, 13% of the file and your array currently has, say, 121 rows, then a good guess is that the array will need to grow to:

    100/13 x 121 rows.

    You can be conservative and expand the array by 25% of the "guessed" total size every time you need to.

    I have written an MPEG-2 parser in VB and this trick worked wonders in performance.

    Another hint: Don't use integers. If your array holds integer values, declare it as long. If the array is based on a structure, use long data types for the integer values. It can be upto 20% faster in handling that way.
    The more I learn, the more I come to realize how little it is I know.
    Quote Quote  
  5. Thanx Sasi, sorry to say you are a bit late, i already did that . I still think a linked list would be the best, easiest to work with also. I use 4 arrays for cache, 1 with full file path, 1 with file modifieddate (to determine if cache is up to date), and 2 for the info. 1 of the last two will barely be used at all, its like "reserved" for AVIs with multipple sound tracks, but would be quite important if this app was to work with VOBS also, who knows the future...
    Quote Quote  
  6. @SaSi
    I have written an MPEG-2 parser in VB...
    Is it allowed to ask what your parser is doing? Maybe there is something I could use in my GUI for dvdauthor?
    Quote Quote  
  7. Borax, why not post what you need and some small info, and maybe someone can help you with some small lines of code?
    Quote Quote  
  8. Member
    Join Date
    Mar 2003
    Location
    Uranus
    Search Comp PM
    If you want low level control . or any control at at all ,
    don't use VB . It won't even do unsigned integers.
    It's the best thing since sliced bread for getting an easy windows
    app out in 5 minutes , but it does what it wants.
    Quote Quote  
  9. Borax, why not post what you need...
    Actually I have written a MPEG2 info function by myself which retrieves the information about resolution, aspectratio, fps and duration. But maybe SaSis parser does more or in a better way than my function. Therefore I just ask what it actually does, as I have no specific needs ATM (If someone wants to have my function for this info, I can post it here).
    Where I would be very interested in is a function that can calculate the duration of an AC3 sound file.

    @FOO
    I know it is cumbersome to work with VB on low level. But nevertheless it is possible (unfortunately not with 'standard DLLs' like mpeg2lib . )
    Quote Quote  
  10. I have written a COM DLL for vb to retrieve info about media files, based on MediaInfo.exe, it works well with mpeg2 and so on, but there seem to be a problem with VOB audiostreams. Its very easy to integrate into any VB app (or delphi), i can send you a copy if you are like to try it. Cant publish it you see, lost the password for the ftp to my homepage
    Quote Quote  
  11. Member SaSi's Avatar
    Join Date
    Jan 2003
    Location
    Hellas
    Search Comp PM
    Originally Posted by borax
    @SaSi
    I have written an MPEG-2 parser in VB...
    Is it allowed to ask what your parser is doing? Maybe there is something I could use in my GUI for dvdauthor?
    It all started during summer vacation last year, because I wanted to understand the MPEG-2 encoding settings. So I started reading the MPEG-2 video specs and understood nothing. So I started writing code to parse the video stream and "see" what the specs talked about.

    The parser reads the video stream, identify the start codes and header info for stream, GOP, picture and slice and then goes on decoding the motion vectors and macroblocks. I also wrote code for a quick and dirty bitrate graph. My ambition was to fully decode the macroblocks and display them on a picture box and compare the image with a source reference uncompressed stream. Why? In search for an automated picture quality tester.

    I never got to complete the code for two reasons. First, the more I progressed in understanding and coding, the larger the structures became and VB is not good enough to handle this kind of code. It showed up with an "increasing rate of slowness" in performance.

    The second reason is that I came across the same functionality built into DVD-LAB (MPEG parser and bitrate viewer). It's so good, it's enough justification (IMO) to buy DVDLab, even if you don't use it to author DVDs.

    And, mind you, some of the code in the app is written in C++ in the form of a DLL that converts a binary string into a bitstream, i.e. a basic string 8 times as large as the binary stream but comprising of digits 0 or 1. VB is parsing this to scan the video. The C++ code that converts binary to binary string runs something like 30-40 times faster than the equivalent VB code, both of them optimized for performance.

    At least I found out what MPEG-2 video is.

    The source code can be made freely available to anyone who wishes to spend time going through it. Send me an e-mail address by PM if you need it.
    The more I learn, the more I come to realize how little it is I know.
    Quote Quote  
  12. Member
    Join Date
    Mar 2003
    Location
    Uranus
    Search Comp PM
    The C++ code that converts binary to binary string runs something like 30-40 times faster than the equivalent VB code, both of them optimized for performance.
    Yep.. even if you don't like C++ you can do a console app in regular C

    You ever notice that most of the Video apps are in C , and then
    somebody adds a GUI to it . Why , because it takes about a year
    to get used to the insane MFC shit.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!