replace tabs w/ spaces
This commit is contained in:
parent
fb43d04f8f
commit
6122905949
24
src/ase.c
24
src/ase.c
@ -482,8 +482,8 @@ struct cel {
|
|||||||
* https://github.com/RandyGaul/cute_headers/blob/master/cute_aseprite.h#L870 */
|
* https://github.com/RandyGaul/cute_headers/blob/master/cute_aseprite.h#L870 */
|
||||||
INTERNAL u32 mul_u8(u32 a, u32 b)
|
INTERNAL u32 mul_u8(u32 a, u32 b)
|
||||||
{
|
{
|
||||||
u32 t = (a * b) + 0x80;
|
u32 t = (a * b) + 0x80;
|
||||||
return ((t >> 8) + t) >> 8;
|
return ((t >> 8) + t) >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
INTERNAL u32 blend(u32 src, u32 dest, u8 opacity)
|
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_b = (src >> 16) & 0xff;
|
||||||
u32 src_a = (src >> 24) & 0xff;
|
u32 src_a = (src >> 24) & 0xff;
|
||||||
|
|
||||||
src_a = (u8)mul_u8(src_a, opacity);
|
src_a = (u8)mul_u8(src_a, opacity);
|
||||||
u32 a = src_a + dest_a - mul_u8(src_a, dest_a);
|
u32 a = src_a + dest_a - mul_u8(src_a, dest_a);
|
||||||
u32 r, g, b;
|
u32 r, g, b;
|
||||||
if (a == 0) {
|
if (a == 0) {
|
||||||
r = g = b = 0;
|
r = g = b = 0;
|
||||||
} else {
|
} else {
|
||||||
r = dest_r + (src_r - dest_r) * src_a / a;
|
r = dest_r + (src_r - dest_r) * src_a / a;
|
||||||
g = dest_g + (src_g - dest_g) * src_a / a;
|
g = dest_g + (src_g - dest_g) * src_a / a;
|
||||||
b = dest_b + (src_b - dest_b) * src_a / a;
|
b = dest_b + (src_b - dest_b) * src_a / a;
|
||||||
}
|
}
|
||||||
|
|
||||||
return r | (g << 8) | (b << 16) | (a << 24);
|
return r | (g << 8) | (b << 16) | (a << 24);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
/* This is the file that actually includes binary data meant to be embedded in
|
/* 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
|
* 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
|
#if RESOURCES_EMBEDDED
|
||||||
INCBIN_INCLUDE(res_tar, "../build/res.tar");
|
INCBIN_INCLUDE(res_tar, "../build/res.tar");
|
||||||
|
|||||||
@ -46,31 +46,31 @@ struct mp3_decode_result mp3_decode(struct arena *arena, struct buffer encoded,
|
|||||||
MFCreateMFByteStreamOnStream(i_stream, &byte_stream);
|
MFCreateMFByteStreamOnStream(i_stream, &byte_stream);
|
||||||
|
|
||||||
/* Create reader from IMFByteStream */
|
/* Create reader from IMFByteStream */
|
||||||
IMFSourceReader *reader;
|
IMFSourceReader *reader;
|
||||||
MFCreateSourceReaderFromByteStream(byte_stream, NULL, &reader);
|
MFCreateSourceReaderFromByteStream(byte_stream, NULL, &reader);
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
* Get media type
|
* Get media type
|
||||||
* ========================== */
|
* ========================== */
|
||||||
|
|
||||||
/* Read only first audio stream */
|
/* Read only first audio stream */
|
||||||
IMFSourceReader_SetStreamSelection(reader, (DWORD)MF_SOURCE_READER_ALL_STREAMS, FALSE);
|
IMFSourceReader_SetStreamSelection(reader, (DWORD)MF_SOURCE_READER_ALL_STREAMS, FALSE);
|
||||||
IMFSourceReader_SetStreamSelection(reader, (DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, TRUE);
|
IMFSourceReader_SetStreamSelection(reader, (DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, TRUE);
|
||||||
|
|
||||||
WAVEFORMATEXTENSIBLE format = {
|
WAVEFORMATEXTENSIBLE format = {
|
||||||
.Format = {
|
.Format = {
|
||||||
.wFormatTag = WAVE_FORMAT_EXTENSIBLE,
|
.wFormatTag = WAVE_FORMAT_EXTENSIBLE,
|
||||||
.nChannels = (WORD)channel_count,
|
.nChannels = (WORD)channel_count,
|
||||||
.nSamplesPerSec = (WORD)sample_rate,
|
.nSamplesPerSec = (WORD)sample_rate,
|
||||||
.nAvgBytesPerSec = (DWORD)(sample_rate * channel_count * bytes_per_sample),
|
.nAvgBytesPerSec = (DWORD)(sample_rate * channel_count * bytes_per_sample),
|
||||||
.nBlockAlign = (WORD)(channel_count * bytes_per_sample),
|
.nBlockAlign = (WORD)(channel_count * bytes_per_sample),
|
||||||
.wBitsPerSample = (WORD)(8 * bytes_per_sample),
|
.wBitsPerSample = (WORD)(8 * bytes_per_sample),
|
||||||
.cbSize = sizeof(format) - sizeof(format.Format)
|
.cbSize = sizeof(format) - sizeof(format.Format)
|
||||||
},
|
},
|
||||||
.Samples.wValidBitsPerSample = 8 * bytes_per_sample,
|
.Samples.wValidBitsPerSample = 8 * bytes_per_sample,
|
||||||
.dwChannelMask = channel_mask,
|
.dwChannelMask = channel_mask,
|
||||||
.SubFormat = MEDIASUBTYPE_PCM
|
.SubFormat = MEDIASUBTYPE_PCM
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Media Foundation in Windows 8+ allows reader to convert output to different format than native */
|
/* Media Foundation in Windows 8+ allows reader to convert output to different format than native */
|
||||||
IMFMediaType *type;
|
IMFMediaType *type;
|
||||||
@ -88,23 +88,23 @@ struct mp3_decode_result mp3_decode(struct arena *arena, struct buffer encoded,
|
|||||||
|
|
||||||
u64 sample_bytes_read = 0;
|
u64 sample_bytes_read = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
IMFSample *sample;
|
IMFSample *sample;
|
||||||
DWORD sample_flags = 0;
|
DWORD sample_flags = 0;
|
||||||
HRESULT hr = IMFSourceReader_ReadSample(reader, (DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, NULL, &sample_flags, NULL, &sample);
|
HRESULT hr = IMFSourceReader_ReadSample(reader, (DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, NULL, &sample_flags, NULL, &sample);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if done */
|
/* Check if done */
|
||||||
if (sample_flags & MF_SOURCE_READERF_ENDOFSTREAM) {
|
if (sample_flags & MF_SOURCE_READERF_ENDOFSTREAM) {
|
||||||
res.success = true;
|
res.success = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ASSERT(sample_flags == 0);
|
ASSERT(sample_flags == 0);
|
||||||
|
|
||||||
/* Read samples */
|
/* Read samples */
|
||||||
IMFMediaBuffer *buffer;
|
IMFMediaBuffer *buffer;
|
||||||
IMFSample_ConvertToContiguousBuffer(sample, &buffer);
|
IMFSample_ConvertToContiguousBuffer(sample, &buffer);
|
||||||
|
|
||||||
BYTE *data;
|
BYTE *data;
|
||||||
DWORD size;
|
DWORD size;
|
||||||
@ -116,8 +116,8 @@ struct mp3_decode_result mp3_decode(struct arena *arena, struct buffer encoded,
|
|||||||
}
|
}
|
||||||
IMFMediaBuffer_Unlock(buffer);
|
IMFMediaBuffer_Unlock(buffer);
|
||||||
|
|
||||||
IMediaBuffer_Release(buffer);
|
IMediaBuffer_Release(buffer);
|
||||||
IMFSample_Release(sample);
|
IMFSample_Release(sample);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.pcm.count = sample_bytes_read / bytes_per_sample;
|
res.pcm.count = sample_bytes_read / bytes_per_sample;
|
||||||
|
|||||||
@ -6,11 +6,11 @@
|
|||||||
/* Represents raw bytes that can back a resource. This can be file data or embedded
|
/* Represents raw bytes that can back a resource. This can be file data or embedded
|
||||||
* data in the executable. */
|
* data in the executable. */
|
||||||
struct resource {
|
struct resource {
|
||||||
struct buffer bytes;
|
struct buffer bytes;
|
||||||
|
|
||||||
#if !RESOURCES_EMBEDDED
|
#if !RESOURCES_EMBEDDED
|
||||||
struct sys_file file;
|
struct sys_file file;
|
||||||
struct sys_file_map file_map;
|
struct sys_file_map file_map;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1675,9 +1675,9 @@ INTERNAL void win32_classic_sleep(f64 seconds)
|
|||||||
i64 qpc_per_second = L.timer_frequency.QuadPart;
|
i64 qpc_per_second = L.timer_frequency.QuadPart;
|
||||||
i32 scheduler_period_ms = L.scheduler_period_ms;
|
i32 scheduler_period_ms = L.scheduler_period_ms;
|
||||||
|
|
||||||
LARGE_INTEGER qpc;
|
LARGE_INTEGER qpc;
|
||||||
QueryPerformanceCounter(&qpc);
|
QueryPerformanceCounter(&qpc);
|
||||||
i64 target_qpc = (i64)(qpc.QuadPart + seconds * qpc_per_second);
|
i64 target_qpc = (i64)(qpc.QuadPart + seconds * qpc_per_second);
|
||||||
|
|
||||||
/* TODO: Calculate tolerance */
|
/* TODO: Calculate tolerance */
|
||||||
|
|
||||||
@ -1718,9 +1718,9 @@ INTERNAL void win32_timer_sleep(f64 seconds, HANDLE timer)
|
|||||||
i64 qpc_per_second = L.timer_frequency.QuadPart;;
|
i64 qpc_per_second = L.timer_frequency.QuadPart;;
|
||||||
i32 scheduler_period_ms = L.scheduler_period_ms;
|
i32 scheduler_period_ms = L.scheduler_period_ms;
|
||||||
|
|
||||||
LARGE_INTEGER qpc;
|
LARGE_INTEGER qpc;
|
||||||
QueryPerformanceCounter(&qpc);
|
QueryPerformanceCounter(&qpc);
|
||||||
INT64 target_qpc = (INT64)(qpc.QuadPart + seconds * qpc_per_second);
|
INT64 target_qpc = (INT64)(qpc.QuadPart + seconds * qpc_per_second);
|
||||||
|
|
||||||
/* TODO: Maybe increase tolerance for higher precision but more power usage */
|
/* TODO: Maybe increase tolerance for higher precision but more power usage */
|
||||||
//const double tolerance = 0.001200 * scheduler_period_ms;
|
//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);
|
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||||
|
|
||||||
/* Query system info */
|
/* Query system info */
|
||||||
GetSystemInfo(&L.info);
|
GetSystemInfo(&L.info);
|
||||||
QueryPerformanceFrequency(&L.timer_frequency);
|
QueryPerformanceFrequency(&L.timer_frequency);
|
||||||
QueryPerformanceCounter(&L.timer_start);
|
QueryPerformanceCounter(&L.timer_start);
|
||||||
{
|
{
|
||||||
|
|||||||
22
src/tar.c
22
src/tar.c
@ -6,17 +6,17 @@
|
|||||||
#define ARCHIVE_LOOKUP_TABLE_CAPACITY_FACTOR 2.0
|
#define ARCHIVE_LOOKUP_TABLE_CAPACITY_FACTOR 2.0
|
||||||
|
|
||||||
/* File types:
|
/* File types:
|
||||||
* '0' or (ASCII NUL) Normal file
|
* '0' or (ASCII NUL) Normal file
|
||||||
* '1' Hard link
|
* '1' Hard link
|
||||||
* '2' Symbolic link
|
* '2' Symbolic link
|
||||||
* '3' Character special
|
* '3' Character special
|
||||||
* '4' Block special
|
* '4' Block special
|
||||||
* '5' Directory
|
* '5' Directory
|
||||||
* '6' FIFO
|
* '6' FIFO
|
||||||
* '7' Contiguous file
|
* '7' Contiguous file
|
||||||
* 'g' Global extended header with meta data(POSIX.1 - 2001)
|
* '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)
|
* 'x' Extended header with metadata for the next file in the archive(POSIX.1 - 2001)
|
||||||
* 'A'-'Z' Vendor specific extensions(POSIX.1 - 1988)
|
* 'A'-'Z' Vendor specific extensions(POSIX.1 - 1988)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TAR_TYPE_FILE '0'
|
#define TAR_TYPE_FILE '0'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user