[MPlayer-dev-eng] [PATCH] vf_noformat

Joey Parrish joey at nicewarrior.org
Fri Jan 30 20:03:24 CET 2004


Hello,

Attached is a patch for a new video filter.  It's very simple, and very
similar to vf_format, except in reverse.  Instead of forcing only one
video format to be accepted, it accepts all but one format.  This is
useful as a workaround for crappy video drivers.  My video card does not
support yv12, but the drivers report that it does, then they do the
conversion themselves.

Without this patch, I would either have to force unaccelerated display
(which sucks) or use vf_format to force bgr16 or so.  But if my display
depth changes, I would have to change the vf_format parameter each time
to match my primary colorspace.

It makes more sense to eliminate the cspace that doesn't work right
(yv12) and let MPlayer decide the next best space to use based on the
other info from my video drivers.  And vf=noformat=yv12 can stay in my
config file all the time.  :)

Comments?
Reject/Commit now/Commit after release?

--Joey

-- 
"I know Kung Fu." --Darth Vader
-------------- next part --------------
diff -ur main.cvs/libmpcodecs/Makefile main.dev/libmpcodecs/Makefile
--- main.cvs/libmpcodecs/Makefile	2004-01-02 17:43:30.542020800 -0600
+++ main.dev/libmpcodecs/Makefile	2004-01-09 12:01:30.583548800 -0600
@@ -14,7 +14,7 @@
 VIDEO_SRCS_OPT=vd_realvid.c vd_ffmpeg.c vd_dshow.c vd_dmo.c vd_vfw.c vd_vfwex.c vd_odivx.c vd_divx4.c vd_zrmjpeg.c vd_xanim.c vd_xvid.c vd_xvid4.c vd_libdv.c vd_qtvideo.c vd_theora.c
 VIDEO_SRCS=dec_video.c vd.c $(VIDEO_SRCS_NAT) $(VIDEO_SRCS_LIB) $(VIDEO_SRCS_OPT)
 
-VFILTER_SRCS=vf.c vf_vo.c vf_crop.c vf_expand.c vf_scale.c vf_format.c vf_yuy2.c vf_flip.c vf_rgb2bgr.c vf_rotate.c vf_mirror.c vf_palette.c vf_lavc.c vf_dvbscale.c vf_cropdetect.c vf_test.c vf_noise.c vf_yvu9.c vf_rectangle.c vf_lavcdeint.c vf_eq.c vf_eq2.c vf_halfpack.c vf_dint.c vf_1bpp.c vf_bmovl.c vf_2xsai.c vf_unsharp.c vf_swapuv.c vf_il.c vf_boxblur.c vf_sab.c vf_smartblur.c vf_perspective.c vf_down3dright.c vf_field.c vf_denoise3d.c vf_hqdn3d.c vf_detc.c vf_telecine.c vf_tfields.c vf_ivtc.c vf_ilpack.c vf_dsize.c vf_decimate.c vf_softpulldown.c vf_tinterlace.c vf_pullup.c pullup.c vf_framestep.c vf_tile.c vf_delogo.c vf_fil.c vf_hue.c vf_spp.c vf_yuvcsp.c vf_filmdint.c
+VFILTER_SRCS=vf.c vf_vo.c vf_crop.c vf_expand.c vf_scale.c vf_format.c vf_noformat.c vf_yuy2.c vf_flip.c vf_rgb2bgr.c vf_rotate.c vf_mirror.c vf_palette.c vf_lavc.c vf_dvbscale.c vf_cropdetect.c vf_test.c vf_noise.c vf_yvu9.c vf_rectangle.c vf_lavcdeint.c vf_eq.c vf_eq2.c vf_halfpack.c vf_dint.c vf_1bpp.c vf_bmovl.c vf_2xsai.c vf_unsharp.c vf_swapuv.c vf_il.c vf_boxblur.c vf_sab.c vf_smartblur.c vf_perspective.c vf_down3dright.c vf_field.c vf_denoise3d.c vf_hqdn3d.c vf_detc.c vf_telecine.c vf_tfields.c vf_ivtc.c vf_ilpack.c vf_dsize.c vf_decimate.c vf_softpulldown.c vf_tinterlace.c vf_pullup.c pullup.c vf_framestep.c vf_tile.c vf_delogo.c vf_fil.c vf_hue.c vf_spp.c vf_yuvcsp.c vf_filmdint.c
 ifeq ($(HAVE_FFPOSTPROCESS),yes)
 VFILTER_SRCS += vf_pp.c
 endif
diff -ur main.cvs/libmpcodecs/vf.c main.dev/libmpcodecs/vf.c
--- main.cvs/libmpcodecs/vf.c	2004-01-02 17:43:30.932582400 -0600
+++ main.dev/libmpcodecs/vf.c	2004-01-09 12:00:39.640296000 -0600
@@ -34,6 +34,7 @@
 extern vf_info_t vf_info_fame;
 #endif
 extern vf_info_t vf_info_format;
+extern vf_info_t vf_info_noformat;
 extern vf_info_t vf_info_yuy2;
 extern vf_info_t vf_info_flip;
 extern vf_info_t vf_info_rgb2bgr;
@@ -102,6 +103,7 @@
     &vf_info_fame,
 #endif
     &vf_info_format,
+    &vf_info_noformat,
     &vf_info_yuy2,
     &vf_info_flip,
     &vf_info_rgb2bgr,
--- main.cvs/libmpcodecs/vf_noformat.c	1969-12-31 18:00:00.000000000 -0600
+++ main.dev/libmpcodecs/vf_noformat.c	2004-01-09 12:01:13.729313600 -0600
@@ -0,0 +1,93 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "../config.h"
+#include "../mp_msg.h"
+
+#include "img_format.h"
+#include "mp_image.h"
+#include "vf.h"
+
+#include "m_option.h"
+#include "m_struct.h"
+
+static struct vf_priv_s {
+    unsigned int fmt;
+} vf_priv_dflt = {
+  IMGFMT_YV12
+};
+
+//===========================================================================//
+
+static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+    if(fmt!=vf->priv->fmt)
+	return vf_next_query_format(vf,fmt);
+    return 0;
+}
+
+static int open(vf_instance_t *vf, char* args){
+    vf->query_format=query_format;
+    vf->default_caps=0;
+    if(!vf->priv) {
+      vf->priv=malloc(sizeof(struct vf_priv_s));
+      vf->priv->fmt=IMGFMT_YV12;
+    }
+    if(args){
+	if(!strcasecmp(args,"444p")) vf->priv->fmt=IMGFMT_444P; else
+	if(!strcasecmp(args,"422p")) vf->priv->fmt=IMGFMT_422P; else
+	if(!strcasecmp(args,"411p")) vf->priv->fmt=IMGFMT_411P; else
+	if(!strcasecmp(args,"yuy2")) vf->priv->fmt=IMGFMT_YUY2; else
+	if(!strcasecmp(args,"yv12")) vf->priv->fmt=IMGFMT_YV12; else
+	if(!strcasecmp(args,"i420")) vf->priv->fmt=IMGFMT_I420; else
+	if(!strcasecmp(args,"yvu9")) vf->priv->fmt=IMGFMT_YVU9; else
+	if(!strcasecmp(args,"if09")) vf->priv->fmt=IMGFMT_IF09; else
+	if(!strcasecmp(args,"iyuv")) vf->priv->fmt=IMGFMT_IYUV; else
+	if(!strcasecmp(args,"uyvy")) vf->priv->fmt=IMGFMT_UYVY; else
+	if(!strcasecmp(args,"bgr24")) vf->priv->fmt=IMGFMT_BGR24; else
+	if(!strcasecmp(args,"bgr32")) vf->priv->fmt=IMGFMT_BGR32; else
+	if(!strcasecmp(args,"bgr16")) vf->priv->fmt=IMGFMT_BGR16; else
+	if(!strcasecmp(args,"bgr15")) vf->priv->fmt=IMGFMT_BGR15; else
+	if(!strcasecmp(args,"bgr8")) vf->priv->fmt=IMGFMT_BGR8; else
+	if(!strcasecmp(args,"bgr4")) vf->priv->fmt=IMGFMT_BGR4; else
+	if(!strcasecmp(args,"bg4b")) vf->priv->fmt=IMGFMT_BG4B; else
+	if(!strcasecmp(args,"bgr1")) vf->priv->fmt=IMGFMT_BGR1; else
+	if(!strcasecmp(args,"rgb24")) vf->priv->fmt=IMGFMT_RGB24; else
+	if(!strcasecmp(args,"rgb32")) vf->priv->fmt=IMGFMT_RGB32; else
+	if(!strcasecmp(args,"rgb16")) vf->priv->fmt=IMGFMT_RGB16; else
+	if(!strcasecmp(args,"rgb15")) vf->priv->fmt=IMGFMT_RGB15; else
+	if(!strcasecmp(args,"rgb8")) vf->priv->fmt=IMGFMT_RGB8; else
+	if(!strcasecmp(args,"rgb4")) vf->priv->fmt=IMGFMT_RGB4; else
+	if(!strcasecmp(args,"rg4b")) vf->priv->fmt=IMGFMT_RG4B; else
+	if(!strcasecmp(args,"rgb1")) vf->priv->fmt=IMGFMT_RGB1; else
+	{ printf("Unknown format name: '%s'\n",args);return 0;}
+    }
+        
+
+    return 1;
+}
+
+#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
+static m_option_t vf_opts_fields[] = {
+  {"fmt", ST_OFF(fmt), CONF_TYPE_IMGFMT, 0,0 ,0, NULL},
+  { NULL, NULL, 0, 0, 0, 0,  NULL }
+};
+
+static m_struct_t vf_opts = {
+  "noformat",
+  sizeof(struct vf_priv_s),
+  &vf_priv_dflt,
+  vf_opts_fields
+};
+
+vf_info_t vf_info_noformat = {
+    "disallow one output format",
+    "noformat",
+    "Joey",
+    "",
+    open,
+    &vf_opts
+};
+
+//===========================================================================//


More information about the MPlayer-dev-eng mailing list