]> granicus.if.org Git - imagemagick/blobdiff - coders/uyvy.c
(no commit message)
[imagemagick] / coders / uyvy.c
index 7876ea9216fbd582b0a065c7aa37885477f5d8a3..0bd1ff4c28d5d0b87a2a7e2d51370c4ccf18c098 100644 (file)
@@ -17,7 +17,7 @@
 %                                 July 1992                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
@@ -91,7 +91,6 @@ static MagickBooleanType
 %
 %    o exception: return any errors or warnings in this structure.
 %
-%
 */
 static Image *ReadUYVYImage(const ImageInfo *image_info,
   ExceptionInfo *exception)
@@ -99,9 +98,6 @@ static Image *ReadUYVYImage(const ImageInfo *image_info,
   Image
     *image;
 
-  ssize_t
-    y;
-
   MagickBooleanType
     status;
 
@@ -111,8 +107,8 @@ static Image *ReadUYVYImage(const ImageInfo *image_info,
   register PixelPacket
     *q;
 
-  register ssize_t
-    i;
+  ssize_t
+    y;
 
   unsigned char
     u,
@@ -139,13 +135,9 @@ static Image *ReadUYVYImage(const ImageInfo *image_info,
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == MagickFalse)
     return((Image *) NULL);
-  for (i=0; i < image->offset; i++)
-    if (ReadBlobByte(image) == EOF)
-      {
-        ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
-          image->filename);
-        break;
-      }
+  if (DiscardBlobBytes(image,image->offset) == MagickFalse)
+    ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+      image->filename);
   image->depth=8;
   if (image_info->ping != MagickFalse)
     {
@@ -166,18 +158,19 @@ static Image *ReadUYVYImage(const ImageInfo *image_info,
       y1=(unsigned char) ReadBlobByte(image);
       v=(unsigned char) ReadBlobByte(image);
       y2=(unsigned char) ReadBlobByte(image);
-      q->red=ScaleCharToQuantum(y1);
-      q->green=ScaleCharToQuantum(u);
-      q->blue=ScaleCharToQuantum(v);
+      SetRedPixelComponent(q,ScaleCharToQuantum(y1));
+      SetGreenPixelComponent(q,ScaleCharToQuantum(u));
+      SetBluePixelComponent(q,ScaleCharToQuantum(v));
       q++;
-      q->red=ScaleCharToQuantum(y2);
-      q->green=ScaleCharToQuantum(u);
-      q->blue=ScaleCharToQuantum(v);
+      SetRedPixelComponent(q,ScaleCharToQuantum(y2));
+      SetGreenPixelComponent(q,ScaleCharToQuantum(u));
+      SetBluePixelComponent(q,ScaleCharToQuantum(v));
       q++;
     }
     if (SyncAuthenticPixels(image,exception) == MagickFalse)
       break;
-    status=SetImageProgress(image,LoadImageTag,y,image->rows);
+    status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
+      image->rows);
     if (status == MagickFalse)
       break;
   }
@@ -300,9 +293,6 @@ static MagickBooleanType WriteUYVYImage(const ImageInfo *image_info,
   Image
     *uyvy_image;
 
-  ssize_t
-    y;
-
   MagickBooleanType
     full,
     status;
@@ -313,6 +303,9 @@ static MagickBooleanType WriteUYVYImage(const ImageInfo *image_info,
   register ssize_t
     x;
 
+  ssize_t
+    y;
+
   /*
     Open output image file.
   */
@@ -350,7 +343,8 @@ static MagickBooleanType WriteUYVYImage(const ImageInfo *image_info,
           (void) WriteBlobByte(image,ScaleQuantumToChar((Quantum) pixel.green));
           (void) WriteBlobByte(image,ScaleQuantumToChar((Quantum) pixel.red));
           (void) WriteBlobByte(image,ScaleQuantumToChar((Quantum) pixel.blue));
-          (void) WriteBlobByte(image,ScaleQuantumToChar(GetRedPixelComponent(p)));
+          (void) WriteBlobByte(image,ScaleQuantumToChar(
+             GetRedPixelComponent(p)));
         }
       pixel.red=(double) GetRedPixelComponent(p);
       pixel.green=(double) GetGreenPixelComponent(p);
@@ -358,7 +352,8 @@ static MagickBooleanType WriteUYVYImage(const ImageInfo *image_info,
       full=full == MagickFalse ? MagickTrue : MagickFalse;
       p++;
     }
-    status=SetImageProgress(image,LoadImageTag,y,image->rows);
+    status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
+      image->rows);
     if (status == MagickFalse)
       break;
   }