changeset 12157:e26d5e388618

check for invalid user input
author iive
date Thu, 08 Apr 2004 12:03:24 +0000
parents ff9f315741a7
children 613cc5d45ba4
files libmpcodecs/vf_spp.c
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
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;
     }