]> Creatis software - gdcm.git/blobdiff - src/gdcmmpeg2/src/mpeg2enc/readpic.c
avoid segfault when unaware user sets SplitOnly to true, and the asks for ImageDataVector
[gdcm.git] / src / gdcmmpeg2 / src / mpeg2enc / readpic.c
index 464ecbf64c16dac5d43244600ee8b1a50eeaa19c..2549d5e2aa241fedc226b3cf8d40b6f9153d8606 100644 (file)
@@ -41,7 +41,7 @@ static void border_extend _ANSI_ARGS_((unsigned char *frame, int w1, int h1,
 static void conv444to422 _ANSI_ARGS_((unsigned char *src, unsigned char *dst));
 static void conv422to420 _ANSI_ARGS_((unsigned char *src, unsigned char *dst));
 
-int pbm_getint(FILE *file); //forward declaration
+int pbm_getint(FILE *file); /*forward declaration */
 
 void readframe(fname,frame)
 char *fname;
@@ -229,9 +229,9 @@ unsigned char *frame[];
       y = cr*r + cg*g + cb*b;
       u = cu*(b-y);
       v = cv*(r-y);
-      yp[j] = (219.0/256.0)*y + 16.5;  /* nominal range: 16..235 */
-      up[j] = (224.0/256.0)*u + 128.5; /* 16..240 */
-      vp[j] = (224.0/256.0)*v + 128.5; /* 16..240 */
+      yp[j] = (unsigned char)((219.0/256.0)*y + 16.5);  /* nominal range: 16..235 */
+      up[j] = (unsigned char)((224.0/256.0)*u + 128.5); /* 16..240 */
+      vp[j] = (unsigned char)((224.0/256.0)*v + 128.5); /* 16..240 */
     }
   }
   fclose(fd);
@@ -303,7 +303,7 @@ unsigned char *src, *dst;
         ip3 = (i<width-3) ? i+3 : width-1;
         ip4 = (i<width-4) ? i+4 : width-1;
         ip5 = (i<width-5) ? i+5 : width-1;
-        ip6 = (i<width-5) ? i+6 : width-1;
+        ip6 = (i<width-6) ? i+6 : width-1;
 
         /* FIR filter with 0.5 sample interval phase shift */
         dst[i>>1] = clp[(int)(228*(src[i]+src[ip1])