[Ffmpeg-devel] Eliminating some memcpy() & memory allocations from the v4l2 input

François Revol revol
Wed Feb 1 16:25:58 CET 2006

> So, my idea is to avoid dinamically allocating the memory for the
> packet, and to set pkt->data = <pointer to buffer returned by
> VIDIOC_DQBUF>. VIDIOC_QBUF will be called only when libavformat does 
> not
> need the packet anymore, and I am planning to use the destruct() 
> method
> of AVPacket for this. Does this usage of AVPacket (and of its 
> destruct()
> method) make sense? Or am I misunderstanding its purpose?

You could add some args to av_new_packet(), or an extended version 
av_new_packet_dest(void *data, void (*destruct)(void *, void *), void *

and keep the cookie in AVPacket, then call destruct() with both data 
and cookie.
So you can pass the fd to ioctl() in the cookie.


More information about the ffmpeg-devel mailing list