177 lines
6.0 KiB
C
177 lines
6.0 KiB
C
/** @file
|
|
|
|
;******************************************************************************
|
|
;* Copyright (c) 2012 - 2020, Insyde Software Corp. All Rights Reserved.
|
|
;*
|
|
;* You may not reproduce, distribute, publish, display, perform, modify, adapt,
|
|
;* transmit, broadcast, present, recite, release, license or otherwise exploit
|
|
;* any part of this publication in any form, by any means, without the prior
|
|
;* written permission of Insyde Software Corporation.
|
|
;*
|
|
;******************************************************************************
|
|
*/
|
|
|
|
/*++
|
|
|
|
Copyright (c) 1999 - 2002 Intel Corporation. All rights reserved
|
|
This software and associated documentation (if any) is furnished
|
|
under a license and may only be used or copied in accordance
|
|
with the terms of the license. Except as permitted by such
|
|
license, no part of this software or documentation may be
|
|
reproduced, stored in a retrieval system, or transmitted in any
|
|
form or by any means without the express written consent of
|
|
Intel Corporation.
|
|
|
|
|
|
Module Name:
|
|
|
|
JpegDecoder.c
|
|
|
|
Abstract:
|
|
|
|
This code supports a the private implementation
|
|
of the JPEG Decoder protocol
|
|
--*/
|
|
|
|
#include "JpegDecoder.h"
|
|
|
|
JPEG_DECODER_INSTANCE mPrivateData;
|
|
|
|
|
|
|
|
|
|
/**
|
|
Decodes a JFIF image into a UGA formatted image,
|
|
and returns the decoded image, image's width and image's height
|
|
|
|
@param [in] This Protocol instance structure
|
|
@param [in] ImageData The data of the JFIF image, which will be decoded
|
|
@param [in] ImageDataSize The size in bytes of ImageData
|
|
@param [out] DecodedData The decoded data, this output parameter contains
|
|
a newly allocated memory space, and it is the
|
|
caller's responsibility to free this memory buffer.
|
|
@param [out] DecodedDataSize The size in bytes of DecodedData
|
|
@param [out] Height The height of the image's displaying
|
|
@param [out] Width The width of the image's displaying
|
|
@param [out] DecoderStatus The status of the decoding progress, defined in
|
|
\Protocol\JpegDecoder\JpegDecoder.h.
|
|
|
|
@retval EFI_SUCCESS The JFIF image is decoded successfully.
|
|
@retval EFI_INVALID_PARAMETER Either one of ImageData, Width, Height, DecodedDataSize
|
|
and DecoderStatus is NULL, or ImageDataSize is zero.
|
|
@retval EFI_OUT_OF_RESOURCES The memory for DecodedData could not be allocated.
|
|
@retval EFI_UNSUPPORTED The JFIF image can not be decoded, and the detail error info
|
|
will be returned by the output parameter DecoderStatus.
|
|
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
JpegDecoderDecodeImage (
|
|
IN EFI_JPEG_DECODER_PROTOCOL *This,
|
|
IN UINT8 *ImageData,
|
|
IN UINTN ImageDataSize,
|
|
OUT UINT8 **DecodedData,
|
|
OUT UINTN *DecodedDataSize,
|
|
OUT UINTN *Height,
|
|
OUT UINTN *Width,
|
|
OUT EFI_JPEG_DECODER_STATUS *DecoderStatus
|
|
)
|
|
{
|
|
EFI_STATUS Status;
|
|
|
|
Status = H2OHiiJpegDecode (
|
|
ImageData,
|
|
ImageDataSize,
|
|
DecodedData,
|
|
DecodedDataSize,
|
|
Height,
|
|
Width,
|
|
DecoderStatus
|
|
);
|
|
|
|
return Status;
|
|
}
|
|
|
|
|
|
/**
|
|
Get a special Marker info of the JFIF image
|
|
|
|
@param [in] This Protocol instance structure
|
|
@param [in] Start The start of the JFIF image,
|
|
or the output Next parameter from a previous call.
|
|
@param [in] End The end of the JFIF image.
|
|
@param [in, out] MarkerType The type of the marker in the JFIF image
|
|
@param [out] MarkerData The pointer of the marker specified by the special MarkerType in the JFIF image.
|
|
@param [out] DataSize The size in bytes of MarkerData (with the marker bytes and length bytes).
|
|
@param [out] Next The next pointer following the "MarkerType" marker,
|
|
it is next marker pointer, or the compressed data pointer after SOS marker.
|
|
|
|
@retval EFI_SUCCESS The marker's information is retrieved sucessfully.
|
|
@retval EFI_INVALID_PARAMETER Either one of Start, End and DataSize is NULL,
|
|
or End is less than Start.
|
|
@retval EFI_NOT_FOUND The marker can not be found in the JFIF image.
|
|
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
JpegDecoderGetMarkerData (
|
|
IN EFI_JPEG_DECODER_PROTOCOL *This,
|
|
IN UINT8 *Start,
|
|
IN UINT8 *End,
|
|
IN OUT EFI_JPEG_MARKER_TYPE *MarkerType,
|
|
OUT UINT8 **MarkerData,
|
|
OUT UINT32 *DataSize,
|
|
OUT UINT8 **Next OPTIONAL
|
|
)
|
|
{
|
|
EFI_STATUS Status;
|
|
|
|
Status = H2OHiiJpegDecoderGetMarkerData (
|
|
Start,
|
|
End,
|
|
MarkerType,
|
|
MarkerData,
|
|
DataSize,
|
|
Next
|
|
);
|
|
|
|
return Status;
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
Install Driver to produce JPEG Decoder protocol.
|
|
|
|
@param [in] ImageHandle
|
|
@param [in] SystemTable
|
|
|
|
@retval EFI_SUCCESS JPEG Decoder protocol installed
|
|
@return Other No protocol installed, unload driver.
|
|
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
JpegDecoderInstall (
|
|
IN EFI_HANDLE ImageHandle,
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
)
|
|
{
|
|
EFI_STATUS Status;
|
|
|
|
//
|
|
// Initialize Private Data required by this protocol
|
|
//
|
|
mPrivateData.Signature = JPEG_DECODER_INSTANCE_SIGNATURE;
|
|
mPrivateData.JpegDecoder.DecodeImage = JpegDecoderDecodeImage;
|
|
mPrivateData.JpegDecoder.GetMarkerData = JpegDecoderGetMarkerData;
|
|
|
|
mPrivateData.Handle = NULL;
|
|
Status = gBS->InstallProtocolInterface (
|
|
&mPrivateData.Handle,
|
|
&gEfiJpegDecoderProtocolGuid,
|
|
EFI_NATIVE_INTERFACE,
|
|
&mPrivateData.JpegDecoder
|
|
);
|
|
return Status;
|
|
} |