]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Add ImageDecoderLib to provide image decoding service.
authorRuiyu Ni <ruiyu.ni@intel.com>
Thu, 12 Nov 2015 05:21:38 +0000 (05:21 +0000)
committerniruiyu <niruiyu@Edk2>
Thu, 12 Nov 2015 05:21:38 +0000 (05:21 +0000)
The library itself doesn't provide any image decoding capabilities but
manages the different image decoders.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18770 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Include/Library/ImageDecoderLib.h [new file with mode: 0644]
MdeModulePkg/Library/ImageDecoderLib/ImageDecoderLib.c [new file with mode: 0644]
MdeModulePkg/Library/ImageDecoderLib/ImageDecoderLib.inf [new file with mode: 0644]
MdeModulePkg/MdeModulePkg.dec
MdeModulePkg/MdeModulePkg.dsc

diff --git a/MdeModulePkg/Include/Library/ImageDecoderLib.h b/MdeModulePkg/Include/Library/ImageDecoderLib.h
new file mode 100644 (file)
index 0000000..928a094
--- /dev/null
@@ -0,0 +1,76 @@
+/** @file\r
+  This library provides image decoding service by managing the different\r
+  image decoding libraries.\r
+\r
+Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials are licensed and made available under\r
+the terms and conditions of the BSD License that accompanies this distribution.\r
+The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php.\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+#ifndef __IMAGE_DECODER_LIB_H__\r
+#define __IMAGE_DECODER_LIB_H__\r
+#include <Protocol/PlatformLogo.h>\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *DECODE_IMAGE)(\r
+  IN  IMAGE_FORMAT                  ImageFormat,\r
+  IN  UINT8                         *Image,\r
+  IN  UINTN                         ImageSize,\r
+  OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **GopBlt,\r
+  OUT UINTN                         *GopBltSize,\r
+  OUT UINTN                         *PixelWidth,\r
+  OUT UINTN                         *PixelHeight\r
+  );\r
+\r
+/**\r
+  Convert a graphics image to a callee allocated GOP blt buffer.\r
+\r
+  @param  ImageFormat   Format of the image file.\r
+  @param  Image         Pointer to image file.\r
+  @param  ImageSize     Number of bytes in Image.\r
+  @param  GopBlt        Buffer containing GOP version of Image.\r
+  @param  GopBltSize    Size of GopBlt in bytes.\r
+  @param  PixelWidth    Width of GopBlt/Image in pixels.\r
+  @param  PixelHeight   Height of GopBlt/Image in pixels.\r
+\r
+  @retval EFI_SUCCESS           GopBlt and GopBltSize are returned.\r
+  @retval EFI_INVALID_PARAMETER GopBlt or GopBltSize is NULL.\r
+  @retval EFI_INVALID_PARAMETER Image is NULL or ImageSize is 0.\r
+  @retval EFI_UNSUPPORTED       Image is not supported.\r
+  @retval EFI_OUT_OF_RESOURCES  No enough buffer to allocate.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DecodeImage (\r
+  IN  IMAGE_FORMAT                  ImageFormat,\r
+  IN  UINT8                         *Image,\r
+  IN  UINTN                         ImageSize,\r
+  OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **GopBlt,\r
+  OUT UINTN                         *GopBltSize,\r
+  OUT UINTN                         *PixelWidth,\r
+  OUT UINTN                         *PixelHeight\r
+  );\r
+\r
+/**\r
+  Register an image decoder.\r
+\r
+  @param Decoder  An image decoder.\r
+\r
+  @retval EFI_SUCCESS          The decoder was successfully registered.\r
+  @retval EFI_OUT_OF_RESOURCES No enough resource to register the decoder.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+RegisterImageDecoder (\r
+  IN  DECODE_IMAGE     Decoder\r
+  );\r
+\r
+#endif\r
diff --git a/MdeModulePkg/Library/ImageDecoderLib/ImageDecoderLib.c b/MdeModulePkg/Library/ImageDecoderLib/ImageDecoderLib.c
new file mode 100644 (file)
index 0000000..4a6219b
--- /dev/null
@@ -0,0 +1,121 @@
+/** @file\r
+  This library provides image decoding service by managing the different\r
+  image decoding libraries.\r
+\r
+Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials are licensed and made available under\r
+the terms and conditions of the BSD License that accompanies this distribution.\r
+The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php.\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <Uefi.h>\r
+#include <Protocol/GraphicsOutput.h>\r
+#include <Library/ImageDecoderLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+typedef struct {\r
+  UINT32       Signature;\r
+  DECODE_IMAGE Decoder;\r
+  LIST_ENTRY   Link;\r
+} IMAGE_DECODER_ENTRY;\r
+#define IMAGE_DECODER_ENTRY_SIGNATURE  SIGNATURE_32 ('i', 'm', 'g', 'd')\r
+#define IMAGE_DECODER_ENTRY_FROM_LINK(Link) \\r
+        CR (Link, IMAGE_DECODER_ENTRY, Link, IMAGE_DECODER_ENTRY_SIGNATURE)\r
+\r
+LIST_ENTRY mImageDecoderLibDecoders = INITIALIZE_LIST_HEAD_VARIABLE (mImageDecoderLibDecoders);\r
+\r
+/**\r
+  Convert a graphics image to a callee allocated GOP blt buffer.\r
+\r
+  @param  ImageFormat   Format of the image file.\r
+  @param  Image         Pointer to image file.\r
+  @param  ImageSize     Number of bytes in Image.\r
+  @param  GopBlt        Buffer containing GOP version of Image.\r
+  @param  GopBltSize    Size of GopBlt in bytes.\r
+  @param  PixelWidth    Width of GopBlt/Image in pixels.\r
+  @param  PixelHeight   Height of GopBlt/Image in pixels.\r
+\r
+  @retval EFI_SUCCESS           GopBlt and GopBltSize are returned.\r
+  @retval EFI_INVALID_PARAMETER GopBlt or GopBltSize is NULL.\r
+  @retval EFI_INVALID_PARAMETER Image is NULL or ImageSize is 0.\r
+  @retval EFI_UNSUPPORTED       Image is not supported.\r
+  @retval EFI_OUT_OF_RESOURCES  No enough buffer to allocate.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DecodeImage (\r
+  IN  IMAGE_FORMAT                  ImageFormat,\r
+  IN  UINT8                         *Image,\r
+  IN  UINTN                         ImageSize,\r
+  OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **GopBlt,\r
+  OUT UINTN                         *GopBltSize,\r
+  OUT UINTN                         *PixelWidth,\r
+  OUT UINTN                         *PixelHeight\r
+  )\r
+{\r
+  IMAGE_DECODER_ENTRY               *Entry;\r
+  LIST_ENTRY                        *Link;\r
+  EFI_STATUS                        Status;\r
+\r
+  if ((GopBlt == NULL) || (GopBltSize == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if ((Image == NULL) || (ImageSize == 0)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  for ( Link = GetFirstNode (&mImageDecoderLibDecoders)\r
+      ; !IsNull (&mImageDecoderLibDecoders, Link)\r
+      ; Link = GetNextNode (&mImageDecoderLibDecoders, Link)\r
+      ) {\r
+    Entry = IMAGE_DECODER_ENTRY_FROM_LINK (Link);\r
+    Status = Entry->Decoder (ImageFormat, Image, ImageSize, GopBlt, GopBltSize, PixelWidth, PixelHeight);\r
+    if (!EFI_ERROR (Status)) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (IsNull (&mImageDecoderLibDecoders, Link)) {\r
+    return EFI_UNSUPPORTED;\r
+  } else {\r
+    return EFI_SUCCESS;\r
+  }\r
+}\r
+\r
+/**\r
+  Register an image decoder.\r
+\r
+  @param Decoder  An image decoder.\r
+\r
+  @retval EFI_SUCCESS          The decoder was successfully registered.\r
+  @retval EFI_OUT_OF_RESOURCES No enough resource to register the decoder.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+RegisterImageDecoder (\r
+  IN  DECODE_IMAGE     Decoder\r
+  )\r
+{\r
+  IMAGE_DECODER_ENTRY  *Entry;\r
+\r
+  Entry = AllocatePool (sizeof (IMAGE_DECODER_ENTRY));\r
+  if (Entry == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  Entry->Signature = IMAGE_DECODER_ENTRY_SIGNATURE;\r
+  Entry->Decoder   = Decoder;\r
+  InsertTailList (&mImageDecoderLibDecoders, &Entry->Link);\r
+\r
+  return EFI_SUCCESS;\r
+}
\ No newline at end of file
diff --git a/MdeModulePkg/Library/ImageDecoderLib/ImageDecoderLib.inf b/MdeModulePkg/Library/ImageDecoderLib/ImageDecoderLib.inf
new file mode 100644 (file)
index 0000000..5d2ee7b
--- /dev/null
@@ -0,0 +1,42 @@
+## @file\r
+#  This library provides image decoding service by managing the different\r
+#  image decoding libraries.\r
+#  \r
+#  Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>\r
+#  This program and the accompanying materials are licensed and made available under\r
+#  the terms and conditions of the BSD License that accompanies this distribution.\r
+#  The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php.\r
+#  \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#  \r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = ImageDecoderLib\r
+  FILE_GUID                      = 5ACDA5F7-AE20-4A17-90C1-7D087F730202\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = ImageDecoderLib|DXE_DRIVER UEFI_APPLICATION\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  ImageDecoderLib.c\r
+  \r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+  MemoryAllocationLib\r
+  UefiLib\r
+  BaseMemoryLib\r
+  DebugLib
\ No newline at end of file
index 08148e39d938e3cfd7a4550682cc619fe04faf18..c35f533adc9b5bd727d7a6f7714c4d62480c7ea8 100644 (file)
   #\r
   PlatformVarCleanupLib|Include/Library/PlatformVarCleanupLib.h\r
 \r
+  ## @libraryclass  Provides image decoding service.\r
+  #\r
+  ImageDecoderLib|Include/Library/ImageDecoderLib.h\r
+\r
 [Guids]\r
   ## MdeModule package token space guid\r
   # Include/Guid/MdeModulePkgTokenSpace.h\r
index 62f596db7331b9d106eb7b3c206dc953e151d3db..20af2d442ca1b484ad2e06f25c4f838023c162c3 100644 (file)
@@ -47,6 +47,7 @@
   PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf\r
   PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf\r
   SortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf\r
+  ImageDecoderLib|MdeModulePkg/Library/ImageDecoderLib/ImageDecoderLib.inf\r
   #\r
   # UEFI & PI\r
   #\r
   MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf\r
   MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf\r
   MdeModulePkg/Library/PlatformBootManagerLibNull/PlatformBootManagerLibNull.inf\r
+  MdeModulePkg/Library/ImageDecoderLib/ImageDecoderLib.inf\r
   MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf\r
   MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf\r
   MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf\r