PDA

View Full Version : MemBufferCollection buffer access



bitsnbites13
April 18, 2005, 17:16:35
I have 3 questions:

1- This seems to be a syntax problem. I want to access a specific MemBuffer from a MemBufferCollection that was allocated with newMemBufferCollection(). I want to access via the operator [] the individual buffers for saving to jpegs.

I want to lock the individual buffers as I collect them:
dlg -> m_buf1Collection0[DWORD idx] -> lock();
But I have these errors on compilation:
":left of '->lock' must point to class/struct/union."
":binary '[':'DshowLib::Grabber::tMemBufferCollectionPtr' does not define this operator or a conversion to a type acceptable to the predefined operator.

2- Is there a way to set an active MemBufferCollection to a particular buffer index? That would be the best way for me to use of the MemBufferCollections in my application.

3- Using the 4 channel frame grabber DFG/LC4, I collect 1 frame then jump to the next (up to the 4) channel(s) and rotate through again the channels in a loop until I filled (up to 4) the MemBufferCollections.

It appears that when I set a MemBufferCollection to an active state, the active MemBuffer index is reset internally to the first buffer in the collection. Will locking each MemBuffer as I go along cause the next snapImages(1) call put the next frame written in the first available unlocked buffer of a given collection (after channel rotation)?

That is, when I call (again) startLive() and snapImages(1) after I set a previously partially filled MemBufferCollection active again?)

Thanks

Stefan Geissler
April 19, 2005, 08:55:24
Hello


I want to lock the individual buffers as I collect them:
dlg -> m_buf1Collection0[DWORD idx] -> lock();
But I have these errors on compilation:

You should try “dlg->m_buf1Collection0[idx].lock();”



2- Is there a way to set an active MemBufferCollection to a particular buffer index? That would be the best way for me to use of the MemBufferCollections in my application.

No. The only way is to create it new and assign it to the grabber object.



3- Using the 4 channel frame grabber DFG/LC4, I collect 1 frame then jump to the next (up to the 4) channel(s) and rotate through again the channels in a loop until I filled (up to 4) the MemBufferCollections.
It appears that when I set a MemBufferCollection to an active state, the active MemBuffer index is reset internally to the first buffer in the collection. Will locking each MemBuffer as I go along cause the next snapImages(1) call put the next frame written in the first available unlocked buffer of a given collection (after channel rotation)?

Yes. But i never particularly tested this in this context.

Just an idea:
Why don't use only one memory buffer collection, that contains 4 buffers. Just lock them all at first. Then call startlive only once at start of your program. During the live video runs, you can change the input channel. The grabber needs up to three frames to synchronize, but this is much more faster than calling live start every time you change the input channel. Then unlock the first memory buffer in your memory buffer collection and call snapImages. After snapImages returned successfully, lock the first buffer. Then change the input channel to the second one, unlock the second memory buffer and call snapImages. Then lock the second buffer. Perform the same with the other input channels.
This should work faster and you exactly know, where to find which image in memory buffer.

bitsnbites13
April 19, 2005, 14:06:22
I did try this at first (dlg->m_buf1Collection0[idx].lock()), but "dlg->m_buf1Collection0" is a buffer collection pointer "tMemBufferCollectionPtr", and this statement does not work. I just can't get my head around to finding the correct/casting syntax so that I can access the MemBuffers via the '[]' operator.

Your idea for question 3 is a good one and I will try it, especially since the max frame rate is 3.75Hz with 1 channel only, and drops to 2.3 Hz with 2 active channels and slower still with the other channels active.

But first I need to be able access the individual MemBuffers of a MemBufferCollection that was created with newMemBufferCollection(). I can always use user allocated buffers by would rather use the functionality of the library.

You have been/are a great help,

Thanks

Stefan Geissler
April 19, 2005, 17:12:19
Try this:

(*dlg->m_buf1Collection0)[idx]-> lock();