diff libmpcodecs/vf_spp.c @ 12157:e26d5e388618

check for invalid user input
author iive
date Thu, 08 Apr 2004 12:03:24 +0000
parents a7751694c177
children 012b55951076
line wrap: on
line diff
--- a/libmpcodecs/vf_spp.c	Wed Apr 07 22:51:42 2004 +0000
+++ b/libmpcodecs/vf_spp.c	Thu Apr 08 12:03:24 2004 +0000
@@ -316,7 +316,7 @@
 	dst[x + y*dst_stride + pos]= temp;
 
 	for(y=0; y<height; y++){
-		uint8_t *d= dither[y];
+		const uint8_t *d= dither[y];
 		for(x=0; x<width; x+=8){
 			int temp;
 			STORE(0);
@@ -565,6 +565,9 @@
 }
 
 static int open(vf_instance_t *vf, char* args){
+
+    int log2c;
+    
     vf->config=config;
     vf->put_image=put_image;
     vf->get_image=get_image;
@@ -581,8 +584,18 @@
     
     vf->priv->log2_count= 3;
     
-    if (args) sscanf(args, "%d:%d:%d", &vf->priv->log2_count, &vf->priv->qp, &vf->priv->mode);
+    if (args) sscanf(args, "%d:%d:%d", &log2c, &vf->priv->qp, &vf->priv->mode);
+
+    if( log2c >=0 && log2c <=6 )
+        vf->priv->log2_count = log2c;
+
+    if(vf->priv->qp < 0)
+        vf->priv->qp = 0;
+    if(vf->priv->qp > 31 )
+        vf->priv->qp = 31;
+
     switch(vf->priv->mode){
+        default:
 	case 0: requantize= hardthresh_c; break;
 	case 1: requantize= softthresh_c; break;
     }