29 if (Private->BuffSize >= Size) {
31 Private->Buff = (VOID *)((UINT8 *)Addr + Size);
32 Private->BuffSize -= Size;
84 IN OUT VOID *Destination,
97 BrotliDecoderResult Result;
98 BrotliDecoderState *BroState;
101 AvailableOut = FILE_BUFFER_SIZE;
102 Result = BROTLI_DECODER_RESULT_ERROR;
103 BroState = BrotliDecoderCreateInstance (
BrAlloc,
BrFree, BuffInfo);
106 if (BroState ==
NULL) {
107 return EFI_INVALID_PARAMETER;
111 Output = (UINT8 *)
BrAlloc (BuffInfo, FILE_BUFFER_SIZE);
114 BrFree (BuffInfo, Output);
115 BrotliDecoderDestroyInstance (BroState);
116 return EFI_INVALID_PARAMETER;
120 Result = BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT;
122 if (Result == BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT) {
123 if (SourceSize == 0) {
127 if (SourceSize >= FILE_BUFFER_SIZE) {
128 AvailableIn = FILE_BUFFER_SIZE;
130 AvailableIn = SourceSize;
134 Source = (VOID *)((UINT8 *)Source + AvailableIn);
135 SourceSize -= AvailableIn;
137 }
else if (Result == BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT) {
138 CopyMem (Temp, Output, FILE_BUFFER_SIZE);
139 AvailableOut = FILE_BUFFER_SIZE;
140 Temp = (VOID *)((UINT8 *)Temp +FILE_BUFFER_SIZE);
146 Result = BrotliDecoderDecompressStream (
156 if (NextOut != Output) {
157 CopyMem (Temp, Output, (
size_t)(NextOut - Output));
163 BrFree (BuffInfo, Output);
164 BrotliDecoderDestroyInstance (BroState);
165 return (Result == BROTLI_DECODER_RESULT_SUCCESS) ?
EFI_SUCCESS : EFI_INVALID_PARAMETER;
179 IN UINT8 *EncodedData,
180 IN UINT8 StartOffset,
189 for (Index = EndOffset - 1; Index >= StartOffset; Index--) {
190 DecodedSize =
LShiftU64 (DecodedSize, 8) + EncodedData[Index];
229 IN UINT32 SourceSize,
230 OUT UINT32 *DestinationSize,
231 OUT UINT32 *ScratchSize
237 ASSERT (SourceSize >= BROTLI_SCRATCH_MAX);
239 MaxOffset = BROTLI_DECODE_MAX;
241 *DestinationSize = (UINT32)GetSize;
242 MaxOffset = BROTLI_SCRATCH_MAX;
244 *ScratchSize = (UINT32)GetSize;
275 IN OUT VOID *Destination,
285 MaxOffset = BROTLI_SCRATCH_MAX;
288 BroBuff.Buff = Scratch;
289 BroBuff.BuffSize = (
UINTN)GetSize;
292 (VOID *)((UINT8 *)Source + BROTLI_SCRATCH_MAX),
293 SourceSize - BROTLI_SCRATCH_MAX,
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
EFI_STATUS BrotliDecompress(IN CONST VOID *Source, IN UINTN SourceSize, IN OUT VOID *Destination, IN OUT UINTN DestSize, IN VOID *BuffInfo)
EFI_STATUS EFIAPI BrotliUefiDecompressGetInfo(IN CONST VOID *Source, IN UINT32 SourceSize, OUT UINT32 *DestinationSize, OUT UINT32 *ScratchSize)
VOID * BrAlloc(IN VOID *Ptr, IN size_t Size)
EFI_STATUS EFIAPI BrotliUefiDecompress(IN CONST VOID *Source, IN UINTN SourceSize, IN OUT VOID *Destination, IN OUT VOID *Scratch)
VOID BrFree(IN VOID *Ptr, IN VOID *Address)
UINT64 BrGetDecodedSizeOfBuf(IN UINT8 *EncodedData, IN UINT8 StartOffset, IN UINT8 EndOffset)
VOID EFIAPI Input(IN CHAR16 *Prompt OPTIONAL, OUT CHAR16 *InStr, IN UINTN StrLen)