changeset 9599:77bddc6d9266

Support for the new options stuff
author albeu
date Sat, 15 Mar 2003 20:45:03 +0000
parents ec21eefff17e
children f55ea7b2fa50
files libmpcodecs/vf_crop.c libmpcodecs/vf_eq.c
diffstat 2 files changed, 51 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vf_crop.c	Sat Mar 15 20:39:05 2003 +0000
+++ b/libmpcodecs/vf_crop.c	Sat Mar 15 20:45:03 2003 +0000
@@ -9,9 +9,15 @@
 #include "mp_image.h"
 #include "vf.h"
 
-struct vf_priv_s {
+#include "m_option.h"
+#include "m_struct.h"
+
+static struct vf_priv_s {
     int crop_w,crop_h;
     int crop_x,crop_y;
+} vf_priv_dflt = {
+  -1,-1,
+  -1,-1
 };
 
 extern int opt_screen_size_x;
@@ -91,12 +97,14 @@
     vf->config=config;
     vf->put_image=put_image;
     vf->default_reqs=VFCAP_ACCEPT_STRIDE;
+    if(!vf->priv) {
     vf->priv=malloc(sizeof(struct vf_priv_s));
     // TODO: parse args ->
     vf->priv->crop_x=
     vf->priv->crop_y=
     vf->priv->crop_w=
     vf->priv->crop_h=-1;
+    } //if(!vf->priv)
     if(args) sscanf(args, "%d:%d:%d:%d", 
     &vf->priv->crop_w,
     &vf->priv->crop_h,
@@ -110,13 +118,29 @@
     return 1;
 }
 
+#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
+static m_option_t vf_opts_fields[] = {
+  {"w", ST_OFF(crop_w), CONF_TYPE_INT, M_OPT_MIN,1 ,0, NULL},
+  {"h", ST_OFF(crop_h), CONF_TYPE_INT, M_OPT_MIN,1 ,0, NULL},
+  {"x", ST_OFF(crop_x), CONF_TYPE_INT, M_OPT_MIN,0 ,0, NULL},
+  {"y", ST_OFF(crop_y), CONF_TYPE_INT, M_OPT_MIN,0 ,0, NULL},
+  { NULL, NULL, 0, 0, 0, 0,  NULL }
+};
+
+static m_struct_t vf_opts = {
+  "crop",
+  sizeof(struct vf_priv_s),
+  &vf_priv_dflt,
+  vf_opts_fields
+};
+
 vf_info_t vf_info_crop = {
     "cropping",
     "crop",
     "A'rpi",
     "",
     open,
-    NULL
+    &vf_opts
 };
 
 //===========================================================================//
--- a/libmpcodecs/vf_eq.c	Sat Mar 15 20:39:05 2003 +0000
+++ b/libmpcodecs/vf_eq.c	Sat Mar 15 20:45:03 2003 +0000
@@ -15,10 +15,17 @@
 #include "../libvo/fastmemcpy.h"
 #include "../postproc/rgb2rgb.h"
 
-struct vf_priv_s {
+#include "m_option.h"
+#include "m_struct.h"
+
+static struct vf_priv_s {
 	unsigned char *buf;
 	int brightness;
 	int contrast;
+} vf_priv_dflt = {
+  NULL,
+  0,
+  0
 };
 
 #ifdef HAVE_MMX
@@ -202,8 +209,10 @@
 	vf->put_image=put_image;
 	vf->uninit=uninit;
 	
+	if(!vf->priv) {
 	vf->priv = malloc(sizeof(struct vf_priv_s));
 	memset(vf->priv, 0, sizeof(struct vf_priv_s));
+	}
 	if (args) sscanf(args, "%d:%d", &vf->priv->brightness, &vf->priv->contrast);
 
 	process = process_C;
@@ -214,12 +223,26 @@
 	return 1;
 }
 
+#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
+static m_option_t vf_opts_fields[] = {
+  {"brightness", ST_OFF(brightness), CONF_TYPE_INT, M_OPT_RANGE,-100 ,100, NULL},
+  {"contrast", ST_OFF(contrast), CONF_TYPE_INT, M_OPT_RANGE,-100 ,100, NULL},
+  { NULL, NULL, 0, 0, 0, 0,  NULL }
+};
+
+static m_struct_t vf_opts = {
+  "eq",
+  sizeof(struct vf_priv_s),
+  &vf_priv_dflt,
+  vf_opts_fields
+};
+
 vf_info_t vf_info_eq = {
 	"soft video equalizer",
 	"eq",
 	"Richard Felker",
 	"",
 	open,
-	NULL
+	&vf_opts
 };