Subrata Banik | 20fe24b | 2021-12-09 02:46:38 +0530 | [diff] [blame] | 1 | /** @file |
| 2 | This protocol provides generic image decoder interfaces to various image formats. |
| 3 | |
| 4 | (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR> |
| 5 | Copyright (c) 2016-2018, Intel Corporation. All rights reserved.<BR> |
| 6 | |
| 7 | SPDX-License-Identifier: BSD-2-Clause-Patent |
| 8 | |
| 9 | @par Revision Reference: |
| 10 | This Protocol was introduced in UEFI Specification 2.6. |
| 11 | |
| 12 | **/ |
| 13 | #ifndef __HII_IMAGE_DECODER_H__ |
| 14 | #define __HII_IMAGE_DECODER_H__ |
| 15 | |
| 16 | #include <Protocol/HiiImage.h> |
| 17 | |
| 18 | #define EFI_HII_IMAGE_DECODER_PROTOCOL_GUID \ |
| 19 | {0x9e66f251, 0x727c, 0x418c, { 0xbf, 0xd6, 0xc2, 0xb4, 0x25, 0x28, 0x18, 0xea }} |
| 20 | |
| 21 | |
| 22 | #define EFI_HII_IMAGE_DECODER_NAME_JPEG_GUID \ |
| 23 | {0xefefd093, 0xd9b, 0x46eb, { 0xa8, 0x56, 0x48, 0x35, 0x7, 0x0, 0xc9, 0x8 }} |
| 24 | |
| 25 | #define EFI_HII_IMAGE_DECODER_NAME_PNG_GUID \ |
| 26 | {0xaf060190, 0x5e3a, 0x4025, { 0xaf, 0xbd, 0xe1, 0xf9, 0x5, 0xbf, 0xaa, 0x4c }} |
| 27 | |
| 28 | typedef struct _EFI_HII_IMAGE_DECODER_PROTOCOL EFI_HII_IMAGE_DECODER_PROTOCOL; |
| 29 | |
| 30 | typedef enum { |
| 31 | EFI_HII_IMAGE_DECODER_COLOR_TYPE_RGB = 0x0, |
| 32 | EFI_HII_IMAGE_DECODER_COLOR_TYPE_RGBA = 0x1, |
| 33 | EFI_HII_IMAGE_DECODER_COLOR_TYPE_CMYK = 0x2, |
| 34 | EFI_HII_IMAGE_DECODER_COLOR_TYPE_UNKNOWN = 0xFF |
| 35 | } EFI_HII_IMAGE_DECODER_COLOR_TYPE; |
| 36 | |
| 37 | // |
| 38 | // EFI_HII_IMAGE_DECODER_IMAGE_INFO_HEADER |
| 39 | // |
| 40 | // DecoderName Name of the decoder |
| 41 | // ImageInfoSize The size of entire image information structure in bytes |
| 42 | // ImageWidth The image width |
| 43 | // ImageHeight The image height |
| 44 | // ColorType The color type, see EFI_HII_IMAGE_DECODER_COLOR_TYPE. |
| 45 | // ColorDepthInBits The color depth in bits |
| 46 | // |
| 47 | typedef struct _EFI_HII_IMAGE_DECODER_IMAGE_INFO_HEADER { |
| 48 | EFI_GUID DecoderName; |
| 49 | UINT16 ImageInfoSize; |
| 50 | UINT16 ImageWidth; |
| 51 | UINT16 ImageHeight; |
| 52 | EFI_HII_IMAGE_DECODER_COLOR_TYPE ColorType; |
| 53 | UINT8 ColorDepthInBits; |
| 54 | } EFI_HII_IMAGE_DECODER_IMAGE_INFO_HEADER; |
| 55 | |
| 56 | #define EFI_IMAGE_JPEG_SCANTYPE_PROGREESSIVE 0x01 |
| 57 | #define EFI_IMAGE_JPEG_SCANTYPE_INTERLACED 0x02 |
| 58 | |
| 59 | // |
| 60 | // EFI_HII_IMAGE_DECODER_JPEG_INFO |
| 61 | // Header The common header |
| 62 | // ScanType The scan type of JPEG image |
| 63 | // Reserved Reserved |
| 64 | // |
| 65 | typedef struct _EFI_HII_IMAGE_DECODER_JPEG_INFO { |
| 66 | EFI_HII_IMAGE_DECODER_IMAGE_INFO_HEADER Header; |
| 67 | UINT16 ScanType; |
| 68 | UINT64 Reserved; |
| 69 | } EFI_HII_IMAGE_DECODER_JPEG_INFO; |
| 70 | |
| 71 | // |
| 72 | // EFI_HII_IMAGE_DECODER_PNG_INFO |
| 73 | // Header The common header |
| 74 | // Channels Number of channels in the PNG image |
| 75 | // Reserved Reserved |
| 76 | // |
| 77 | typedef struct _EFI_HII_IMAGE_DECODER_PNG_INFO { |
| 78 | EFI_HII_IMAGE_DECODER_IMAGE_INFO_HEADER Header; |
| 79 | UINT16 Channels; |
| 80 | UINT64 Reserved; |
| 81 | } EFI_HII_IMAGE_DECODER_PNG_INFO; |
| 82 | |
| 83 | // |
| 84 | // EFI_HII_IMAGE_DECODER_OTHER_INFO |
| 85 | // |
| 86 | typedef struct _EFI_HII_IMAGE_DECODER_OTHER_INFO { |
| 87 | EFI_HII_IMAGE_DECODER_IMAGE_INFO_HEADER Header; |
| 88 | CHAR16 ImageExtenion[1]; |
| 89 | // |
| 90 | // Variable length of image file extension name. |
| 91 | // |
| 92 | } EFI_HII_IMAGE_DECODER_OTHER_INFO; |
| 93 | |
| 94 | /** |
| 95 | There could be more than one EFI_HII_IMAGE_DECODER_PROTOCOL instances installed |
| 96 | in the system for different image formats. This function returns the decoder |
| 97 | name which callers can use to find the proper image decoder for the image. It |
| 98 | is possible to support multiple image formats in one EFI_HII_IMAGE_DECODER_PROTOCOL. |
| 99 | The capability of the supported image formats is returned in DecoderName and |
| 100 | NumberOfDecoderName. |
| 101 | |
| 102 | @param This EFI_HII_IMAGE_DECODER_PROTOCOL instance. |
| 103 | @param DecoderName Pointer to a dimension to retrieve the decoder |
| 104 | names in EFI_GUID format. The number of the |
| 105 | decoder names is returned in NumberOfDecoderName. |
| 106 | @param NumberofDecoderName Pointer to retrieve the number of decoders which |
| 107 | supported by this decoder driver. |
| 108 | |
| 109 | @retval EFI_SUCCESS Get decoder name success. |
| 110 | @retval EFI_UNSUPPORTED Get decoder name fail. |
| 111 | |
| 112 | **/ |
| 113 | typedef |
| 114 | EFI_STATUS |
| 115 | (EFIAPI *EFI_HII_IMAGE_DECODER_GET_NAME)( |
| 116 | IN EFI_HII_IMAGE_DECODER_PROTOCOL *This, |
| 117 | IN OUT EFI_GUID **DecoderName, |
| 118 | IN OUT UINT16 *NumberOfDecoderName |
| 119 | ); |
| 120 | |
| 121 | /** |
| 122 | This function returns the image information of the given image raw data. This |
| 123 | function first checks whether the image raw data is supported by this decoder |
| 124 | or not. This function may go through the first few bytes in the image raw data |
| 125 | for the specific data structure or the image signature. If the image is not supported |
| 126 | by this image decoder, this function returns EFI_UNSUPPORTED to the caller. |
| 127 | Otherwise, this function returns the proper image information to the caller. |
| 128 | It is the caller?s responsibility to free the ImageInfo. |
| 129 | |
| 130 | @param This EFI_HII_IMAGE_DECODER_PROTOCOL instance. |
| 131 | @param Image Pointer to the image raw data. |
| 132 | @param SizeOfImage Size of the entire image raw data. |
| 133 | @param ImageInfo Pointer to receive EFI_HII_IMAGE_DECODER_IMAGE_INFO_HEADER. |
| 134 | |
| 135 | @retval EFI_SUCCESS Get image info success. |
| 136 | @retval EFI_UNSUPPORTED Unsupported format of image. |
| 137 | @retval EFI_INVALID_PARAMETER Incorrect parameter. |
| 138 | @retval EFI_BAD_BUFFER_SIZE Not enough memory. |
| 139 | |
| 140 | **/ |
| 141 | typedef |
| 142 | EFI_STATUS |
| 143 | (EFIAPI *EFI_HII_IMAGE_DECODER_GET_IMAGE_INFO)( |
| 144 | IN EFI_HII_IMAGE_DECODER_PROTOCOL *This, |
| 145 | IN VOID *Image, |
| 146 | IN UINTN SizeOfImage, |
| 147 | IN OUT EFI_HII_IMAGE_DECODER_IMAGE_INFO_HEADER **ImageInfo |
| 148 | ); |
| 149 | |
| 150 | /** |
| 151 | This function decodes the image which the image type of this image is supported |
| 152 | by this EFI_HII_IMAGE_DECODER_PROTOCOL. If **Bitmap is not NULL, the caller intends |
| 153 | to put the image in the given image buffer. That allows the caller to put an |
| 154 | image overlap on the original image. The transparency is handled by the image |
| 155 | decoder because the transparency capability depends on the image format. Callers |
| 156 | can set Transparent to FALSE to force disabling the transparency process on the |
| 157 | image. Forcing Transparent to FALSE may also improve the performance of the image |
| 158 | decoding because the image decoder can skip the transparency processing. If **Bitmap |
| 159 | is NULL, the image decoder allocates the memory buffer for the EFI_IMAGE_OUTPUT |
| 160 | and decodes the image to the image buffer. It is the caller?s responsibility to |
| 161 | free the memory for EFI_IMAGE_OUTPUT. Image decoder doesn?t have to handle the |
| 162 | transparency in this case because there is no background image given by the caller. |
| 163 | The background color in this case is all black (#00000000). |
| 164 | |
| 165 | @param This EFI_HII_IMAGE_DECODER_PROTOCOL instance. |
| 166 | @param Image Pointer to the image raw data. |
| 167 | @param ImageRawDataSize Size of the entire image raw data. |
| 168 | @param Blt EFI_IMAGE_OUTPUT to receive the image or overlap |
| 169 | the image on the original buffer. |
| 170 | @param Transparent BOOLEAN value indicates whether the image decoder |
| 171 | has to handle the transparent image or not. |
| 172 | |
| 173 | |
| 174 | @retval EFI_SUCCESS Image decode success. |
| 175 | @retval EFI_UNSUPPORTED Unsupported format of image. |
| 176 | @retval EFI_INVALID_PARAMETER Incorrect parameter. |
| 177 | @retval EFI_BAD_BUFFER_SIZE Not enough memory. |
| 178 | |
| 179 | **/ |
| 180 | typedef |
| 181 | EFI_STATUS |
| 182 | (EFIAPI *EFI_HII_IMAGE_DECODER_DECODE)( |
| 183 | IN EFI_HII_IMAGE_DECODER_PROTOCOL *This, |
| 184 | IN VOID *Image, |
| 185 | IN UINTN ImageRawDataSize, |
| 186 | IN OUT EFI_IMAGE_OUTPUT **Bitmap, |
| 187 | IN BOOLEAN Transparent |
| 188 | ); |
| 189 | |
| 190 | struct _EFI_HII_IMAGE_DECODER_PROTOCOL { |
| 191 | EFI_HII_IMAGE_DECODER_GET_NAME GetImageDecoderName; |
| 192 | EFI_HII_IMAGE_DECODER_GET_IMAGE_INFO GetImageInfo; |
| 193 | EFI_HII_IMAGE_DECODER_DECODE DecodeImage; |
| 194 | }; |
| 195 | |
| 196 | extern EFI_GUID gEfiHiiImageDecoderProtocolGuid; |
| 197 | extern EFI_GUID gEfiHiiImageDecoderNameJpegGuid; |
| 198 | extern EFI_GUID gEfiHiiImageDecoderNamePngGuid; |
| 199 | |
| 200 | #endif |