>>   What I think we can do is
>> have the wrapper for each module's process function return the frame
>> buffer to the free pool after the function returns, e.g.:
>> 
>>     tc_filter_process(ptr);
>>     framebuffer_free(ptr);
>> 
>> and have each module allocate a new frame buffer for each frame in the
>> stream it outputs.
>
>If I understood correctly, you're worried about the need to do a full
>copy of a frame when it's cloned, given this new model, am I right?

Not just for cloned frames, but for every frame in the resulting stream.
Under the basic model I'm thinking of, intermediate processors (like
filters) will allocate a new frame buffer for every frame they produce,
disposing of every frame they receive once they're done with it.  In the
pathological no-op case, the filter code would look like

    FrameBuffer *outframe = framebuffer_get();  // from framebuffer pool
    outframe->frame_num = my_frame_num++;
    memcpy(outframe->data, inframe->data, inframe->data_size);
    framebuffer_free(inframe);  // probably done by the function wrapper
                                // (as I suggested before) to avoid code
                                // duplication in all the filters

which is an obvious waste of time compared to the zero-copy method.

That said, copying frames is pretty cheap compared to other processing
(especially encoding) so I think we can leave it off for the moment if
it looks like it'll complicate things, and come back to it later once
the basic model is functioning.

  --Andrew Church
    achu...@achurch.org
    http://achurch.org/

Reply via email to