[MPlayer-dev-eng] [PATCH] introducing -vf pretend (was: removing libmpcodecs/vf_rbg2bgr.c)

Reimar Döffinger Reimar.Doeffinger at gmx.de
Tue May 25 00:28:08 CEST 2010


On Mon, May 24, 2010 at 11:30:51PM +0200, Attila Kinali wrote:
> Moin,
> 
> On Fri, 14 May 2010 00:40:16 +0200
> Reimar Döffinger <Reimar.Doeffinger at gmx.de> wrote:
> 
> > On Thu, May 13, 2010 at 09:54:28PM +0200, Attila Kinali wrote:
> > > As with -vf yuy2, -vf rgb2bgr seems to be superceeded by sws a long
> > > time ago.
> > 
> > Unfortunately no, there is no substitute for the "swap" option.
> > Should be trivial to implement a filter to do that (it does not
> > need to do any conversion or anything at all, just change the format),
> > but it is something I needed only reasonably (for a device with buggy
> > framebuffer driver).
> 
> Ok, here is a patch that introduces a pretend filter, that does
> (almost) exactly what the swap option did. It is a bit more general
> as it accepts any format parameter, not just from the RGB/BGR class.
> 
> To apply the patch, run first 
> `svn cp libmpcodecs/vf_format.c libmpcodecs/vf_pretend.c` 
> (yes, i was lazy).

Hmm... Surprised this actually works... I was working on extending
-vf format to do something like this but expected it to not work...
The "problem" I have with it is that
> +The user is responsible that input and output formats are structurally
> +similar. Otherwise all odd effects can occur.
means you actually can only use it with a format filter in front, otherwise
you can't know what will happen.
Another minor annoyance is that it won't automatically select the "best" RGB/BGR
format, however I think it's reasonable to ignore that.
Maybe you could have a look at what I did for -vf format and see if you think
this might be a better solution (assuming we can get it to work)?
Index: libmpcodecs/vf_format.c
===================================================================
--- libmpcodecs/vf_format.c	(revision 31207)
+++ libmpcodecs/vf_format.c	(working copy)
@@ -34,15 +34,20 @@
 
 static struct vf_priv_s {
     unsigned int fmt;
+    unsigned int outfmt;
 } const vf_priv_dflt = {
-  IMGFMT_YUY2
+  IMGFMT_YUY2,
+  0
 };
 
 //===========================================================================//
 
 static int query_format(struct vf_instance *vf, unsigned int fmt){
-    if(fmt==vf->priv->fmt)
+    if(fmt==vf->priv->fmt) {
+        if (vf->priv->outfmt)
+            fmt = vf->priv->outfmt;
 	return vf_next_query_format(vf,fmt);
+    }
     return 0;
 }
 
@@ -55,6 +60,7 @@
 #define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
 static const m_option_t vf_opts_fields[] = {
   {"fmt", ST_OFF(fmt), CONF_TYPE_IMGFMT, 0,0 ,0, NULL},
+  {"outfmt", ST_OFF(outfmt), CONF_TYPE_IMGFMT, 0,0 ,0, NULL},
   { NULL, NULL, 0, 0, 0, 0,  NULL }
 };



More information about the MPlayer-dev-eng mailing list