replace tabs w/ spaces

This commit is contained in:
jacob 2024-03-28 10:22:55 -05:00
parent fb43d04f8f
commit 6122905949
6 changed files with 67 additions and 66 deletions

View File

@ -482,8 +482,8 @@ struct cel {
* https://github.com/RandyGaul/cute_headers/blob/master/cute_aseprite.h#L870 */
INTERNAL u32 mul_u8(u32 a, u32 b)
{
u32 t = (a * b) + 0x80;
return ((t >> 8) + t) >> 8;
u32 t = (a * b) + 0x80;
return ((t >> 8) + t) >> 8;
}
INTERNAL u32 blend(u32 src, u32 dest, u8 opacity)
@ -498,16 +498,16 @@ INTERNAL u32 blend(u32 src, u32 dest, u8 opacity)
u32 src_b = (src >> 16) & 0xff;
u32 src_a = (src >> 24) & 0xff;
src_a = (u8)mul_u8(src_a, opacity);
u32 a = src_a + dest_a - mul_u8(src_a, dest_a);
u32 r, g, b;
if (a == 0) {
r = g = b = 0;
} else {
r = dest_r + (src_r - dest_r) * src_a / a;
g = dest_g + (src_g - dest_g) * src_a / a;
b = dest_b + (src_b - dest_b) * src_a / a;
}
src_a = (u8)mul_u8(src_a, opacity);
u32 a = src_a + dest_a - mul_u8(src_a, dest_a);
u32 r, g, b;
if (a == 0) {
r = g = b = 0;
} else {
r = dest_r + (src_r - dest_r) * src_a / a;
g = dest_g + (src_g - dest_g) * src_a / a;
b = dest_b + (src_b - dest_b) * src_a / a;
}
return r | (g << 8) | (b << 16) | (a << 24);
}

View File

@ -3,7 +3,8 @@
/* This is the file that actually includes binary data meant to be embedded in
* the executable. Embedded files should be added as dependencies to this source
* file via the build system. */
* file via the build system to ensure this unit is recompiled upon changes to
* an embedded file. */
#if RESOURCES_EMBEDDED
INCBIN_INCLUDE(res_tar, "../build/res.tar");

View File

@ -46,31 +46,31 @@ struct mp3_decode_result mp3_decode(struct arena *arena, struct buffer encoded,
MFCreateMFByteStreamOnStream(i_stream, &byte_stream);
/* Create reader from IMFByteStream */
IMFSourceReader *reader;
MFCreateSourceReaderFromByteStream(byte_stream, NULL, &reader);
IMFSourceReader *reader;
MFCreateSourceReaderFromByteStream(byte_stream, NULL, &reader);
/* ========================== *
* Get media type
* ========================== */
/* Read only first audio stream */
IMFSourceReader_SetStreamSelection(reader, (DWORD)MF_SOURCE_READER_ALL_STREAMS, FALSE);
IMFSourceReader_SetStreamSelection(reader, (DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, TRUE);
/* Read only first audio stream */
IMFSourceReader_SetStreamSelection(reader, (DWORD)MF_SOURCE_READER_ALL_STREAMS, FALSE);
IMFSourceReader_SetStreamSelection(reader, (DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, TRUE);
WAVEFORMATEXTENSIBLE format = {
.Format = {
.wFormatTag = WAVE_FORMAT_EXTENSIBLE,
.nChannels = (WORD)channel_count,
.nSamplesPerSec = (WORD)sample_rate,
.nAvgBytesPerSec = (DWORD)(sample_rate * channel_count * bytes_per_sample),
.nBlockAlign = (WORD)(channel_count * bytes_per_sample),
.wBitsPerSample = (WORD)(8 * bytes_per_sample),
.cbSize = sizeof(format) - sizeof(format.Format)
},
.Samples.wValidBitsPerSample = 8 * bytes_per_sample,
.dwChannelMask = channel_mask,
.SubFormat = MEDIASUBTYPE_PCM
};
WAVEFORMATEXTENSIBLE format = {
.Format = {
.wFormatTag = WAVE_FORMAT_EXTENSIBLE,
.nChannels = (WORD)channel_count,
.nSamplesPerSec = (WORD)sample_rate,
.nAvgBytesPerSec = (DWORD)(sample_rate * channel_count * bytes_per_sample),
.nBlockAlign = (WORD)(channel_count * bytes_per_sample),
.wBitsPerSample = (WORD)(8 * bytes_per_sample),
.cbSize = sizeof(format) - sizeof(format.Format)
},
.Samples.wValidBitsPerSample = 8 * bytes_per_sample,
.dwChannelMask = channel_mask,
.SubFormat = MEDIASUBTYPE_PCM
};
/* Media Foundation in Windows 8+ allows reader to convert output to different format than native */
IMFMediaType *type;
@ -88,23 +88,23 @@ struct mp3_decode_result mp3_decode(struct arena *arena, struct buffer encoded,
u64 sample_bytes_read = 0;
while (true) {
IMFSample *sample;
DWORD sample_flags = 0;
HRESULT hr = IMFSourceReader_ReadSample(reader, (DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, NULL, &sample_flags, NULL, &sample);
IMFSample *sample;
DWORD sample_flags = 0;
HRESULT hr = IMFSourceReader_ReadSample(reader, (DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, NULL, &sample_flags, NULL, &sample);
if (FAILED(hr)) {
break;
}
break;
}
/* Check if done */
if (sample_flags & MF_SOURCE_READERF_ENDOFSTREAM) {
if (sample_flags & MF_SOURCE_READERF_ENDOFSTREAM) {
res.success = true;
break;
}
ASSERT(sample_flags == 0);
break;
}
ASSERT(sample_flags == 0);
/* Read samples */
IMFMediaBuffer *buffer;
IMFSample_ConvertToContiguousBuffer(sample, &buffer);
IMFMediaBuffer *buffer;
IMFSample_ConvertToContiguousBuffer(sample, &buffer);
BYTE *data;
DWORD size;
@ -116,8 +116,8 @@ struct mp3_decode_result mp3_decode(struct arena *arena, struct buffer encoded,
}
IMFMediaBuffer_Unlock(buffer);
IMediaBuffer_Release(buffer);
IMFSample_Release(sample);
IMediaBuffer_Release(buffer);
IMFSample_Release(sample);
}
res.pcm.count = sample_bytes_read / bytes_per_sample;

View File

@ -6,11 +6,11 @@
/* Represents raw bytes that can back a resource. This can be file data or embedded
* data in the executable. */
struct resource {
struct buffer bytes;
struct buffer bytes;
#if !RESOURCES_EMBEDDED
struct sys_file file;
struct sys_file_map file_map;
struct sys_file file;
struct sys_file_map file_map;
#endif
};

View File

@ -1675,9 +1675,9 @@ INTERNAL void win32_classic_sleep(f64 seconds)
i64 qpc_per_second = L.timer_frequency.QuadPart;
i32 scheduler_period_ms = L.scheduler_period_ms;
LARGE_INTEGER qpc;
QueryPerformanceCounter(&qpc);
i64 target_qpc = (i64)(qpc.QuadPart + seconds * qpc_per_second);
LARGE_INTEGER qpc;
QueryPerformanceCounter(&qpc);
i64 target_qpc = (i64)(qpc.QuadPart + seconds * qpc_per_second);
/* TODO: Calculate tolerance */
@ -1718,9 +1718,9 @@ INTERNAL void win32_timer_sleep(f64 seconds, HANDLE timer)
i64 qpc_per_second = L.timer_frequency.QuadPart;;
i32 scheduler_period_ms = L.scheduler_period_ms;
LARGE_INTEGER qpc;
QueryPerformanceCounter(&qpc);
INT64 target_qpc = (INT64)(qpc.QuadPart + seconds * qpc_per_second);
LARGE_INTEGER qpc;
QueryPerformanceCounter(&qpc);
INT64 target_qpc = (INT64)(qpc.QuadPart + seconds * qpc_per_second);
/* TODO: Maybe increase tolerance for higher precision but more power usage */
//const double tolerance = 0.001200 * scheduler_period_ms;
@ -1786,7 +1786,7 @@ int CALLBACK WinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance,
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
/* Query system info */
GetSystemInfo(&L.info);
GetSystemInfo(&L.info);
QueryPerformanceFrequency(&L.timer_frequency);
QueryPerformanceCounter(&L.timer_start);
{

View File

@ -6,17 +6,17 @@
#define ARCHIVE_LOOKUP_TABLE_CAPACITY_FACTOR 2.0
/* File types:
* '0' or (ASCII NUL) Normal file
* '1' Hard link
* '2' Symbolic link
* '3' Character special
* '4' Block special
* '5' Directory
* '6' FIFO
* '7' Contiguous file
* 'g' Global extended header with meta data(POSIX.1 - 2001)
* 'x' Extended header with metadata for the next file in the archive(POSIX.1 - 2001)
* 'A'-'Z' Vendor specific extensions(POSIX.1 - 1988)
* '0' or (ASCII NUL) Normal file
* '1' Hard link
* '2' Symbolic link
* '3' Character special
* '4' Block special
* '5' Directory
* '6' FIFO
* '7' Contiguous file
* 'g' Global extended header with meta data(POSIX.1 - 2001)
* 'x' Extended header with metadata for the next file in the archive(POSIX.1 - 2001)
* 'A'-'Z' Vendor specific extensions(POSIX.1 - 1988)
*/
#define TAR_TYPE_FILE '0'