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

Michael Niedermayer michaelni
Thu Feb 2 11:05:22 CET 2006


Hi

On Thu, Feb 02, 2006 at 10:31:17AM +0100, Luca Abeni wrote:
[...]
> > > or an extended version
> > > like:
> > > av_new_packet_dest(void *data, void (*destruct)(void *, void *), void *
> > > cookie);
> > > 
> > > 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.
> > 
> > well, yes thats possible but why would we want that extra layer? is there
> > some advatge i dont see?
> I guess Fran?ois does not like these parts of my patch:
> +       pkt->priv = (void *)((res & 0xFF) | ((s->fd & 0xFFFFFF) << 8));
> 
> +    buf.index = (int)pkt->priv & 0xFF;
> +    fd = (int)pkt->priv >> 8;
> 
> This was just a quick hack to get things working in a short time.
> - I think on some architectures there might be problems casting int to
> void*, but the C standard probably defines an int type that can be
> casted to pointers (going to search for it...).
> - The "res & 0xFF" and "buf.index = (int)pkt->priv & 0xFF" part is safe
> if I change desired_video_buffers to 255
> - There still is a problem if s->fd > (2 << 24) - 1, but I hope I can
> reasonably assume this will not happen? I'll add a check anyway.
> 
> Or do you think it is better to define a
> struct buffer_descriptor{
>   int fd;
>   int index;
> };
> and to use pkt->priv as a pointer to it?

maybe ...

[...]
-- 
Michael





More information about the ffmpeg-devel mailing list