OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
Mp3.c
Go to the documentation of this file.
1
15#include <Library/BaseMemoryLib.h>
16#include <Library/DebugLib.h>
17#include <Library/MemoryAllocationLib.h>
18#include <Library/OcMp3Lib.h>
19#include <Library/OcMiscLib.h>
20
21#include <UserFile.h>
22
23int
25 int argc,
26 char *argv[]
27 )
28{
29 UINT32 Size;
30 UINT8 *Buffer;
31
32 if ((Buffer = UserReadFile ((argc > 1) ? argv[1] : "test.mp3", &Size)) == NULL) {
33 DEBUG ((DEBUG_ERROR, "Read fail\n"));
34 return -1;
35 }
36
37 VOID *OutBuffer;
38 UINT32 OutSize;
41 UINT8 Channels;
42 EFI_STATUS Status;
43
44 Status = OcDecodeMp3 (
45 Buffer,
46 Size,
47 &OutBuffer,
48 &OutSize,
49 &Freq,
50 &Bits,
51 &Channels
52 );
53
54 FreePool (Buffer);
55
56 if (!EFI_ERROR (Status)) {
57 DEBUG ((DEBUG_ERROR, "Decode success %u\n", OutSize));
58 UserWriteFile ("test.bin", OutBuffer, OutSize);
59 FreePool (OutBuffer);
60 return 0;
61 }
62
63 DEBUG ((DEBUG_WARN, "Decode failure - %r\n", Status));
64 return 1;
65}
66
67int
69 const uint8_t *Data,
70 size_t Size
71 )
72{
73 VOID *OutBuffer;
74 UINT32 OutSize;
75 EFI_STATUS Status;
76
77 if (Size > 0) {
80 UINT8 Channels;
81
82 Status = OcDecodeMp3 (
83 Data,
84 Size,
85 &OutBuffer,
86 &OutSize,
87 &Freq,
88 &Bits,
89 &Channels
90 );
91 if (!EFI_ERROR (Status)) {
92 FreePool (OutBuffer);
93 }
94 }
95
96 return 0;
97}
EFI_AUDIO_IO_PROTOCOL_FREQ
Definition AudioIo.h:104
EFI_AUDIO_IO_PROTOCOL_BITS
Definition AudioIo.h:93
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
Definition Mp3.c:68
DMG_SIZE_DEVICE_PATH Size
EFI_STATUS OcDecodeMp3(IN CONST VOID *InBuffer, IN UINT32 InBufferSize, OUT VOID **OutBuffer, OUT UINT32 *OutBufferSize, OUT EFI_AUDIO_IO_PROTOCOL_FREQ *Frequency, OUT EFI_AUDIO_IO_PROTOCOL_BITS *Bits, OUT UINT8 *Channels)
Definition OcMp3Lib.c:89
OC_TYPING_BUFFER_ENTRY Buffer[OC_TYPING_BUFFER_SIZE]
Definition OcTypingLib.h:42
UINT8 * UserReadFile(IN CONST CHAR8 *FileName, OUT UINT32 *Size)
Definition UserFile.c:62
VOID UserWriteFile(IN CONST CHAR8 *FileName, IN CONST VOID *Data, IN UINT32 Size)
Definition UserFile.c:116
#define Freq
Definition deflate.h:79
UINT8 uint8_t
int ENTRY_POINT(void)