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?
+ Reply to Thread
Results 1 to 12 of 12
-
-
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.
-
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. -
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. -
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...
-
@SaSi
I have written an MPEG-2 parser in VB... -
Borax, why not post what you need and some small info, and maybe someone can help you with some small lines of code?
-
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. -
Borax, why not post what you need...
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 .)
-
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
-
Originally Posted by borax
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. -
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.
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.
Similar Threads
-
Saving/capture solutions for saving off (extending) DVR
By ET3D in forum Newbie / General discussionsReplies: 1Last Post: 28th Oct 2011, 18:13 -
Chip Choices and Raid Arrays
By Sckinhunter in forum ComputerReplies: 13Last Post: 30th Mar 2011, 21:02 -
Extending VGA Signals For Video Post Production House
By avsubvert in forum DVB / IPTVReplies: 0Last Post: 27th Nov 2009, 06:47 -
Fastest Conversion
By ZoNE97 in forum Video ConversionReplies: 13Last Post: 5th Apr 2008, 07:28 -
extending firewire
By marksk918 in forum ComputerReplies: 6Last Post: 6th Feb 2008, 12:57