[MPlayer-G2-dev] A new vf layer proposal...

D Richard Felker III dalias at aerifal.cx
Wed Sep 17 06:37:43 CEST 2003


OK, as much as I appreciate the tangential discussion about branching
filters and multi-monitor displays and stuff...

What I was really looking for was comments on the design, whether
there are any obvious mistakes or problems I'm overlooking, etc. It
might also be nice to hear some thoughts on the way filter config and
format negotiation should work, since I didn't address that at all, as
well as how window resizing should be handled (special dynamically
inserted scale filter, or swscaler code in vf_vo2) and how format
conversion should be handled between filters...

My original idea was to put in some minor, isolated hacks to allow a
(swscaler) filter to be inserted dynamically between the called filter
and the calling filter. But since then I've had a couple more ideas...

1) Put format conversion directly in the vf layer, like:

vf_pull_image(vf_instance_t *vf_src, *vf_dest)
{
	mpi = vf_src->pull_image(vf_src, vf_dest);
	if (mpi->imgfmt not usable by vf_dest) {
		mpi2 = vf_get_buffer(vf_dest, ...);
		swScale(mpi2, mpi, ...); /* Michael's coolJavaCaps! */
		vf_release_buffer(mpi);
		return mpi2;
	}
	return mpi;
}

2) Require filters to accept any input format (but their get_buffer
   can restrict which formats allow DR, and their query_format can
   report which formats are natively supported. Then, once a filter
   gets an image from vf_pull_image, it checks to see if it can use
   the format as-is. If not, it calls a conversion function in the vf
   api:

	mpi = vf_pull_image(vf->prev, vf);
	if (mpi->imgfmt not supported) mpi = vf_convert(vf, mpi, fmt);


Don't assume I'm being sloppy in the way these functions are called
for the sake of providing a simplified example. The idea is that the
buffer lock count and ownership semantics would automatically "do the
right thing" with code just about as simple as what I've written
above. For instance, vf_convert woulc call vf_get_buffer(vf, ...),
allowing direct rendering, and would decrement the lock count on the
mpi passed into it (releasing this buffer as long as the current vf or
the one that returned it hadn't established an extra lock with
vf_lock_buffer).

Actually, with this in mind, approaches (1) and (2) above are
basically identical. It's just a matter of where the conversion code
goes.

After thinking about things more, I have various reasons of preferring
approaches like the following instead of dynamically inserting a scale
filter wherever there's a format mismatch. Please reply and make
comments if you particularly like or dislike any of the approaches
I've described.

Rich




More information about the MPlayer-G2-dev mailing list