Revision: 18770
          http://sourceforge.net/p/edk2/code/18770
Author:   niruiyu
Date:     2015-11-12 05:21:38 +0000 (Thu, 12 Nov 2015)
Log Message:
-----------
MdeModulePkg: Add ImageDecoderLib to provide image decoding service.

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 <[email protected]>
Reviewed-by: Feng Tian <[email protected]>
Reviewed-by: Jordan Justen <[email protected]>

Modified Paths:
--------------
    trunk/edk2/MdeModulePkg/MdeModulePkg.dec
    trunk/edk2/MdeModulePkg/MdeModulePkg.dsc

Added Paths:
-----------
    trunk/edk2/MdeModulePkg/Include/Library/ImageDecoderLib.h
    trunk/edk2/MdeModulePkg/Library/ImageDecoderLib/
    trunk/edk2/MdeModulePkg/Library/ImageDecoderLib/ImageDecoderLib.c
    trunk/edk2/MdeModulePkg/Library/ImageDecoderLib/ImageDecoderLib.inf

Added: trunk/edk2/MdeModulePkg/Include/Library/ImageDecoderLib.h
===================================================================
--- trunk/edk2/MdeModulePkg/Include/Library/ImageDecoderLib.h                   
        (rev 0)
+++ trunk/edk2/MdeModulePkg/Include/Library/ImageDecoderLib.h   2015-11-12 
05:21:38 UTC (rev 18770)
@@ -0,0 +1,76 @@
+/** @file
+  This library provides image decoding service by managing the different
+  image decoding libraries.
+
+Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available 
under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+#ifndef __IMAGE_DECODER_LIB_H__
+#define __IMAGE_DECODER_LIB_H__
+#include <Protocol/PlatformLogo.h>
+
+typedef
+EFI_STATUS
+(EFIAPI *DECODE_IMAGE)(
+  IN  IMAGE_FORMAT                  ImageFormat,
+  IN  UINT8                         *Image,
+  IN  UINTN                         ImageSize,
+  OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **GopBlt,
+  OUT UINTN                         *GopBltSize,
+  OUT UINTN                         *PixelWidth,
+  OUT UINTN                         *PixelHeight
+  );
+
+/**
+  Convert a graphics image to a callee allocated GOP blt buffer.
+
+  @param  ImageFormat   Format of the image file.
+  @param  Image         Pointer to image file.
+  @param  ImageSize     Number of bytes in Image.
+  @param  GopBlt        Buffer containing GOP version of Image.
+  @param  GopBltSize    Size of GopBlt in bytes.
+  @param  PixelWidth    Width of GopBlt/Image in pixels.
+  @param  PixelHeight   Height of GopBlt/Image in pixels.
+
+  @retval EFI_SUCCESS           GopBlt and GopBltSize are returned.
+  @retval EFI_INVALID_PARAMETER GopBlt or GopBltSize is NULL.
+  @retval EFI_INVALID_PARAMETER Image is NULL or ImageSize is 0.
+  @retval EFI_UNSUPPORTED       Image is not supported.
+  @retval EFI_OUT_OF_RESOURCES  No enough buffer to allocate.
+
+**/
+EFI_STATUS
+EFIAPI
+DecodeImage (
+  IN  IMAGE_FORMAT                  ImageFormat,
+  IN  UINT8                         *Image,
+  IN  UINTN                         ImageSize,
+  OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **GopBlt,
+  OUT UINTN                         *GopBltSize,
+  OUT UINTN                         *PixelWidth,
+  OUT UINTN                         *PixelHeight
+  );
+
+/**
+  Register an image decoder.
+
+  @param Decoder  An image decoder.
+
+  @retval EFI_SUCCESS          The decoder was successfully registered.
+  @retval EFI_OUT_OF_RESOURCES No enough resource to register the decoder.
+
+**/
+EFI_STATUS
+EFIAPI
+RegisterImageDecoder (
+  IN  DECODE_IMAGE     Decoder
+  );
+
+#endif

Added: trunk/edk2/MdeModulePkg/Library/ImageDecoderLib/ImageDecoderLib.c
===================================================================
--- trunk/edk2/MdeModulePkg/Library/ImageDecoderLib/ImageDecoderLib.c           
                (rev 0)
+++ trunk/edk2/MdeModulePkg/Library/ImageDecoderLib/ImageDecoderLib.c   
2015-11-12 05:21:38 UTC (rev 18770)
@@ -0,0 +1,121 @@
+/** @file
+  This library provides image decoding service by managing the different
+  image decoding libraries.
+
+Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available 
under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <Protocol/GraphicsOutput.h>
+#include <Library/ImageDecoderLib.h>
+#include <Library/BaseLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/DebugLib.h>
+
+typedef struct {
+  UINT32       Signature;
+  DECODE_IMAGE Decoder;
+  LIST_ENTRY   Link;
+} IMAGE_DECODER_ENTRY;
+#define IMAGE_DECODER_ENTRY_SIGNATURE  SIGNATURE_32 ('i', 'm', 'g', 'd')
+#define IMAGE_DECODER_ENTRY_FROM_LINK(Link) \
+        CR (Link, IMAGE_DECODER_ENTRY, Link, IMAGE_DECODER_ENTRY_SIGNATURE)
+
+LIST_ENTRY mImageDecoderLibDecoders = INITIALIZE_LIST_HEAD_VARIABLE 
(mImageDecoderLibDecoders);
+
+/**
+  Convert a graphics image to a callee allocated GOP blt buffer.
+
+  @param  ImageFormat   Format of the image file.
+  @param  Image         Pointer to image file.
+  @param  ImageSize     Number of bytes in Image.
+  @param  GopBlt        Buffer containing GOP version of Image.
+  @param  GopBltSize    Size of GopBlt in bytes.
+  @param  PixelWidth    Width of GopBlt/Image in pixels.
+  @param  PixelHeight   Height of GopBlt/Image in pixels.
+
+  @retval EFI_SUCCESS           GopBlt and GopBltSize are returned.
+  @retval EFI_INVALID_PARAMETER GopBlt or GopBltSize is NULL.
+  @retval EFI_INVALID_PARAMETER Image is NULL or ImageSize is 0.
+  @retval EFI_UNSUPPORTED       Image is not supported.
+  @retval EFI_OUT_OF_RESOURCES  No enough buffer to allocate.
+
+**/
+EFI_STATUS
+EFIAPI
+DecodeImage (
+  IN  IMAGE_FORMAT                  ImageFormat,
+  IN  UINT8                         *Image,
+  IN  UINTN                         ImageSize,
+  OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **GopBlt,
+  OUT UINTN                         *GopBltSize,
+  OUT UINTN                         *PixelWidth,
+  OUT UINTN                         *PixelHeight
+  )
+{
+  IMAGE_DECODER_ENTRY               *Entry;
+  LIST_ENTRY                        *Link;
+  EFI_STATUS                        Status;
+
+  if ((GopBlt == NULL) || (GopBltSize == NULL)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  if ((Image == NULL) || (ImageSize == 0)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  for ( Link = GetFirstNode (&mImageDecoderLibDecoders)
+      ; !IsNull (&mImageDecoderLibDecoders, Link)
+      ; Link = GetNextNode (&mImageDecoderLibDecoders, Link)
+      ) {
+    Entry = IMAGE_DECODER_ENTRY_FROM_LINK (Link);
+    Status = Entry->Decoder (ImageFormat, Image, ImageSize, GopBlt, 
GopBltSize, PixelWidth, PixelHeight);
+    if (!EFI_ERROR (Status)) {
+      break;
+    }
+  }
+
+  if (IsNull (&mImageDecoderLibDecoders, Link)) {
+    return EFI_UNSUPPORTED;
+  } else {
+    return EFI_SUCCESS;
+  }
+}
+
+/**
+  Register an image decoder.
+
+  @param Decoder  An image decoder.
+
+  @retval EFI_SUCCESS          The decoder was successfully registered.
+  @retval EFI_OUT_OF_RESOURCES No enough resource to register the decoder.
+
+**/
+EFI_STATUS
+EFIAPI
+RegisterImageDecoder (
+  IN  DECODE_IMAGE     Decoder
+  )
+{
+  IMAGE_DECODER_ENTRY  *Entry;
+
+  Entry = AllocatePool (sizeof (IMAGE_DECODER_ENTRY));
+  if (Entry == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+
+  Entry->Signature = IMAGE_DECODER_ENTRY_SIGNATURE;
+  Entry->Decoder   = Decoder;
+  InsertTailList (&mImageDecoderLibDecoders, &Entry->Link);
+
+  return EFI_SUCCESS;
+}
\ No newline at end of file

Added: trunk/edk2/MdeModulePkg/Library/ImageDecoderLib/ImageDecoderLib.inf
===================================================================
--- trunk/edk2/MdeModulePkg/Library/ImageDecoderLib/ImageDecoderLib.inf         
                (rev 0)
+++ trunk/edk2/MdeModulePkg/Library/ImageDecoderLib/ImageDecoderLib.inf 
2015-11-12 05:21:38 UTC (rev 18770)
@@ -0,0 +1,42 @@
+## @file
+#  This library provides image decoding service by managing the different
+#  image decoding libraries.
+#  
+#  Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
+#  This program and the accompanying materials are licensed and made available 
under
+#  the terms and conditions of the BSD License that accompanies this 
distribution.
+#  The full text of the license may be found at
+#  http://opensource.org/licenses/bsd-license.php.
+#  
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+#  
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = ImageDecoderLib
+  FILE_GUID                      = 5ACDA5F7-AE20-4A17-90C1-7D087F730202
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = ImageDecoderLib|DXE_DRIVER UEFI_APPLICATION
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC
+#
+
+[Sources]
+  ImageDecoderLib.c
+  
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+  BaseLib
+  MemoryAllocationLib
+  UefiLib
+  BaseMemoryLib
+  DebugLib
\ No newline at end of file

Modified: trunk/edk2/MdeModulePkg/MdeModulePkg.dec
===================================================================
--- trunk/edk2/MdeModulePkg/MdeModulePkg.dec    2015-11-12 05:19:22 UTC (rev 
18769)
+++ trunk/edk2/MdeModulePkg/MdeModulePkg.dec    2015-11-12 05:21:38 UTC (rev 
18770)
@@ -131,6 +131,10 @@
   #
   PlatformVarCleanupLib|Include/Library/PlatformVarCleanupLib.h
 
+  ## @libraryclass  Provides image decoding service.
+  #
+  ImageDecoderLib|Include/Library/ImageDecoderLib.h
+
 [Guids]
   ## MdeModule package token space guid
   # Include/Guid/MdeModulePkgTokenSpace.h

Modified: trunk/edk2/MdeModulePkg/MdeModulePkg.dsc
===================================================================
--- trunk/edk2/MdeModulePkg/MdeModulePkg.dsc    2015-11-12 05:19:22 UTC (rev 
18769)
+++ trunk/edk2/MdeModulePkg/MdeModulePkg.dsc    2015-11-12 05:21:38 UTC (rev 
18770)
@@ -47,6 +47,7 @@
   PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
   
PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
   SortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf
+  ImageDecoderLib|MdeModulePkg/Library/ImageDecoderLib/ImageDecoderLib.inf
   #
   # UEFI & PI
   #
@@ -276,6 +277,7 @@
   
MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
   MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
   
MdeModulePkg/Library/PlatformBootManagerLibNull/PlatformBootManagerLibNull.inf
+  MdeModulePkg/Library/ImageDecoderLib/ImageDecoderLib.inf
   MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
   MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
   MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf


------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to