]> granicus.if.org Git - imagemagick/blobdiff - coders/uyvy.c
...
[imagemagick] / coders / uyvy.c
index e74297bad17257ba2231e97294598b3b27058eda..d9e71e25157b379d7743531c69695eac964b6ec9 100644 (file)
 %            Read/Write 16bit/pixel Interleaved YUV Image Format              %
 %                                                                             %
 %                              Software Design                                %
-%                                John Cristy                                  %
+%                                   Cristy                                    %
 %                                 July 1992                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2018 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  %
 %  obtain a copy of the License at                                            %
 %                                                                             %
-%    http://www.imagemagick.org/script/license.php                            %
+%    https://www.imagemagick.org/script/license.php                           %
 %                                                                             %
 %  Unless required by applicable law or agreed to in writing, software        %
 %  distributed under the License is distributed on an "AS IS" BASIS,          %
@@ -64,7 +64,7 @@
   Forward declarations.
 */
 static MagickBooleanType
-  WriteUYVYImage(const ImageInfo *,Image *);
+  WriteUYVYImage(const ImageInfo *,Image *,ExceptionInfo *);
 \f
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -121,18 +121,18 @@ static Image *ReadUYVYImage(const ImageInfo *image_info,
     Open image file.
   */
   assert(image_info != (const ImageInfo *) NULL);
-  assert(image_info->signature == MagickSignature);
+  assert(image_info->signature == MagickCoreSignature);
   if (image_info->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
       image_info->filename);
   assert(exception != (ExceptionInfo *) NULL);
-  assert(exception->signature == MagickSignature);
-  image=AcquireImage(image_info);
+  assert(exception->signature == MagickCoreSignature);
+  image=AcquireImage(image_info,exception);
   if ((image->columns == 0) || (image->rows == 0))
     ThrowReaderException(OptionError,"MustSpecifyImageSize");
   if ((image->columns % 2) != 0)
     image->columns++;
-  (void) CopyMagickString(image->filename,image_info->filename,MaxTextExtent);
+  (void) CopyMagickString(image->filename,image_info->filename,MagickPathExtent);
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == MagickFalse)
     return((Image *) NULL);
@@ -145,13 +145,16 @@ static Image *ReadUYVYImage(const ImageInfo *image_info,
       (void) CloseBlob(image);
       return(GetFirstImageInList(image));
     }
+  status=SetImageExtent(image,image->columns,image->rows,exception);
+  if (status == MagickFalse)
+    return(DestroyImageList(image));
   /*
     Accumulate UYVY, then unpack into two pixels.
   */
   for (y=0; y < (ssize_t) image->rows; y++)
   {
     q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
-    if (q == (const Quantum *) NULL)
+    if (q == (Quantum *) NULL)
       break;
     for (x=0; x < (ssize_t) (image->columns >> 1); x++)
     {
@@ -175,7 +178,7 @@ static Image *ReadUYVYImage(const ImageInfo *image_info,
     if (status == MagickFalse)
       break;
   }
-  image->colorspace=YCbCrColorspace;
+  SetImageColorspace(image,YCbCrColorspace,exception);
   if (EOFBlob(image) != MagickFalse)
     ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
       image->filename);
@@ -211,23 +214,19 @@ ModuleExport size_t RegisterUYVYImage(void)
   MagickInfo
     *entry;
 
-  entry=SetMagickInfo("PAL");
+  entry=AcquireMagickInfo("UYVY","PAL","16bit/pixel interleaved YUV");
   entry->decoder=(DecodeImageHandler *) ReadUYVYImage;
   entry->encoder=(EncodeImageHandler *) WriteUYVYImage;
-  entry->adjoin=MagickFalse;
-  entry->raw=MagickTrue;
-  entry->endian_support=MagickTrue;
-  entry->description=ConstantString("16bit/pixel interleaved YUV");
-  entry->module=ConstantString("UYVY");
+  entry->flags^=CoderAdjoinFlag;
+  entry->flags|=CoderRawSupportFlag;
+  entry->flags|=CoderEndianSupportFlag;
   (void) RegisterMagickInfo(entry);
-  entry=SetMagickInfo("UYVY");
+  entry=AcquireMagickInfo("UYVY","UYVY","16bit/pixel interleaved YUV");
   entry->decoder=(DecodeImageHandler *) ReadUYVYImage;
   entry->encoder=(EncodeImageHandler *) WriteUYVYImage;
-  entry->adjoin=MagickFalse;
-  entry->raw=MagickTrue;
-  entry->endian_support=MagickTrue;
-  entry->description=ConstantString("16bit/pixel interleaved YUV");
-  entry->module=ConstantString("UYVY");
+  entry->flags^=CoderAdjoinFlag;
+  entry->flags|=CoderRawSupportFlag;
+  entry->flags|=CoderEndianSupportFlag;
   (void) RegisterMagickInfo(entry);
   return(MagickImageCoderSignature);
 }
@@ -275,18 +274,19 @@ ModuleExport void UnregisterUYVYImage(void)
 %  The format of the WriteUYVYImage method is:
 %
 %      MagickBooleanType WriteUYVYImage(const ImageInfo *image_info,
-%        Image *image)
+%        Image *image,ExceptionInfo *exception)
 %
 %  A description of each parameter follows.
 %
 %    o image_info: the image info.
 %
-%    o image:  The image.
-%      Implicit assumption: number of columns is even.
+%    o image:  The image.  Implicit assumption: number of columns is even.
+%
+%    o exception: return any errors or warnings in this structure.
 %
 */
 static MagickBooleanType WriteUYVYImage(const ImageInfo *image_info,
-  Image *image)
+  Image *image,ExceptionInfo *exception)
 {
   PixelInfo
     pixel;
@@ -311,28 +311,30 @@ static MagickBooleanType WriteUYVYImage(const ImageInfo *image_info,
     Open output image file.
   */
   assert(image_info != (const ImageInfo *) NULL);
-  assert(image_info->signature == MagickSignature);
+  assert(image_info->signature == MagickCoreSignature);
   assert(image != (Image *) NULL);
-  assert(image->signature == MagickSignature);
+  assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   if ((image->columns % 2) != 0)
     image->columns++;
-  status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
+  assert(exception != (ExceptionInfo *) NULL);
+  assert(exception->signature == MagickCoreSignature);
+  status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
   if (status == MagickFalse)
     return(status);
   /*
     Accumulate two pixels, then output.
   */
-  uyvy_image=CloneImage(image,0,0,MagickTrue,&image->exception);
+  uyvy_image=CloneImage(image,0,0,MagickTrue,exception);
   if (uyvy_image == (Image *) NULL)
-    ThrowWriterException(ResourceLimitError,image->exception.reason);
-  (void) TransformImageColorspace(uyvy_image,YCbCrColorspace);
+    return(MagickFalse);
+  (void) TransformImageColorspace(uyvy_image,YCbCrColorspace,exception);
   full=MagickFalse;
   (void) ResetMagickMemory(&pixel,0,sizeof(PixelInfo));
   for (y=0; y < (ssize_t) image->rows; y++)
   {
-    p=GetVirtualPixels(uyvy_image,0,y,image->columns,1,&image->exception);
+    p=GetVirtualPixels(uyvy_image,0,y,image->columns,1,exception);
     if (p == (const Quantum *) NULL)
       break;
     for (x=0; x < (ssize_t) image->columns; x++)