diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..00b6c07
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,20 @@
+CC=gcc
+CFLAGS=-std=c2x -I./include
+
+SRC_DIR=./src
+LIB_DIR=./lib
+LIB_NAME=ivafl
+
+SRCS=$(shell find $(SRC_DIR) -name '*.c')
+OBJS=$(patsubst $(SRC_DIR)/%.c,$(SRC_DIR)/%.o,$(SRCS))
+
+all: lib$(LIB_NAME).a
+
+lib$(LIB_NAME).a: $(OBJS)
+ ar rcs $@ $^
+
+$(SRC_DIR)/%.o: $(SRC_DIR)/%.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+clean:
+ rm -rf $(OBJS) lib$(LIB_NAME).a
\ No newline at end of file
diff --git a/examples/wav/PinkPanther30.wav b/examples/wav/PinkPanther30.wav
new file mode 100644
index 0000000..6ebbaaf
Binary files /dev/null and b/examples/wav/PinkPanther30.wav differ
diff --git a/examples/wav/a.out b/examples/wav/a.out
new file mode 100644
index 0000000..45bc879
Binary files /dev/null and b/examples/wav/a.out differ
diff --git a/examples/wav/build.sh b/examples/wav/build.sh
new file mode 100644
index 0000000..8a085ce
--- /dev/null
+++ b/examples/wav/build.sh
@@ -0,0 +1 @@
+gcc wav_ivafl_test.c ../../libivafl.a -I../../include -O3 -std=c2x
\ No newline at end of file
diff --git a/examples/wav/wav_ivalf_test.c b/examples/wav/wav_ivalf_test.c
new file mode 100644
index 0000000..cafaed7
--- /dev/null
+++ b/examples/wav/wav_ivalf_test.c
@@ -0,0 +1,52 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
+
+#include
+
+#include
+#include
+
+int
+main(int argc, char** argv)
+{
+ printf("Testing ivafl wav library.\n");
+ printf("First function: ivafl_is_file_wav\n");
+
+ FILE* f = fopen("PinkPanther30.wav", "rb");
+ if (f == NULL)
+ {
+ printf("File doesn't exists\n");
+ return EXIT_FAILURE;
+ }
+
+ ivafl_wav_header_t* wav_header = ivafl_parse_file_into_wav_header(f);
+
+ if (ivafl_is_file_wav(wav_header) == 0)
+ printf("`PinkPanther30.wav` is a wav file\n");
+ else
+ {
+ printf("`PinkPanther30.wav` isn't a wav file\n");
+ return EXIT_FAILURE;
+ }
+
+ printf("riff: %.4s\n", wav_header->wav_header_info->riff_magic);
+ printf("bytes_sec: %u\n", wav_header->wav_header_info->bytes_sec);
+ printf("bytes_sec: %u\n", wav_header->wav_header_info->length_format_data);
+ printf("length ms: %lu\n", ivafl_wav_get_file_length_ms(wav_header));
+ printf("length sec: %.2f\n", ivafl_wav_get_file_length_sec(wav_header));
+}
\ No newline at end of file
diff --git a/include/ivafl_alloc.h b/include/ivafl_alloc.h
new file mode 100644
index 0000000..2a69673
--- /dev/null
+++ b/include/ivafl_alloc.h
@@ -0,0 +1,59 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
+
+#ifndef __ivafl_ALLOC_H
+#define __ivafl_ALLOC_H
+
+#include "ivafl_platform.h"
+#include "ivafl_utils.h"
+
+/*
+ * Function for reallocating memory at given pointer.
+ * Basically it can grow size of our allocation. If
+ * return equals NULL ((void*)0) then allocating
+ * failed
+*/
+void* __ivafl_realloc(const void* ptr, size_t nsize);
+
+/*
+ * Easier allocating that does simple math (n * size)
+ * that does call malloc to allocate memory. If return
+ * equals NULL ((void*)0) then allocating failed
+ */
+void* __ivafl_calloc(int n, size_t size);
+
+/*
+ * Allocating given amount of bytes. If return equals
+ * NULL ((void*)0) then allocating failed
+ */
+void* __ivafl_malloc(size_t size);
+
+/*
+ * Free allocated memory at given pointer.
+ */
+void __ivafl_free(const void* ptr);
+
+/*
+ * Binding for memory allocation functions
+ */
+#define ivafl_realloc(ptr, ns) __ivafl_calloc((const void*)ptr, (size_t)ns)
+#define ivafl_malloc(size) __ivafl_malloc((size_t)size)
+#define ivafl_calloc(n, size) __ivafl_calloc((int)n, (size_t)size)
+#define ivafl_free(ptr) __ivafl_free((const void*)ptr)
+
+#endif /* __ivafl_ALLOC_H */
\ No newline at end of file
diff --git a/include/ivafl_log.h b/include/ivafl_log.h
new file mode 100644
index 0000000..c7fa2a3
--- /dev/null
+++ b/include/ivafl_log.h
@@ -0,0 +1,31 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
+
+#ifndef __ivafl_LOG_H
+#define __ivafl_LOG_H
+
+#include "ivafl_platform.h"
+
+/*
+ * The ivafl_logf does print log that shows in the console.
+ * logs are for developer to know where's the error. ivafl_logf
+ * uses c format to give additional informations
+ */
+void ivafl_logf(const char* fmt, ...);
+
+#endif /* __ivafl_LOG_H */
\ No newline at end of file
diff --git a/include/ivafl_platform.h b/include/ivafl_platform.h
new file mode 100644
index 0000000..2832cef
--- /dev/null
+++ b/include/ivafl_platform.h
@@ -0,0 +1,26 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
+
+#ifndef __ivafl_PLATFORM_H
+#define __ivafl_PLATFORM_H
+
+// #if !defined(_WIN32) || !defined(__unix__) || !defined(__APPLE__) || !defined(__linux__)
+// # error "You are trying to compile ivafl on not supported platform"
+// #endif
+
+#endif /* __ivafl_PLATFORM_H */
\ No newline at end of file
diff --git a/include/ivafl_utils.h b/include/ivafl_utils.h
new file mode 100644
index 0000000..9ff998a
--- /dev/null
+++ b/include/ivafl_utils.h
@@ -0,0 +1,51 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
+
+#ifndef __ivafl_UTILS_H
+#define __ivafl_UTILS_H
+
+typedef long unsigned int size_t;
+
+#define ivafl_NULL ((void*)0)
+
+#include
+
+/*
+ * This function does read given file and return
+ * unsigned char* (array of bytes) that then can
+ * be used to for example parse wav file or other
+ * format
+ */
+unsigned char* ivafl_read_bytes(const char* filename);
+
+/*
+ * This function does read given FILE* structure
+ * that need to be opened with "rb" mode. Function
+ * does return unsigned char* (array of bytes) that
+ * then can be used to for example parse wav file
+ * or other format
+ */
+unsigned char* ivafl_read_bytes_from_file(FILE* f);
+
+/*
+ * The `ivafl_get_size_file` function does return `size_t`
+ * that indicates the given `FILE*` structure content length
+ */
+size_t ivafl_get_size_file(FILE* f);
+
+#endif /* __ivafl_UTILS_H */
\ No newline at end of file
diff --git a/include/ivafl_wav.h b/include/ivafl_wav.h
new file mode 100644
index 0000000..f002772
--- /dev/null
+++ b/include/ivafl_wav.h
@@ -0,0 +1,158 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
+
+/*
+ * These pages helped me a lot while writing wav decoder and encoder
+ * - https://docs.fileformat.com/audio/wav/
+ * - http://www.topherlee.com/software/pcm-tut-wavformat.html
+*/
+
+#ifndef __ivafl_WAV_H
+#define __ivafl_WAV_H
+
+#include
+
+#include
+
+/*
+ * ----------------------
+ * Wav structure
+ * ----------------------
+ */
+
+/*
+ * Wav Calculate macros
+ */
+
+#define WAV_BYTES_SEC_CALCULATE(sample_rate, bits_per_sample, channels) \
+ (sample_rate * bits_per_sample * channels) / 8 \
+
+#define WAV_BLOCK_ALIGN_CALCULATE(bits_per_sample, channels) \
+ (bits_per_sample * channels) / 8 \
+
+/*
+ * WAV Channels
+ */
+#define WAV_MONO_CHANNLES (unsigned short)0x01
+#define WAV_STEREO_CHANNELS (unsigned short)0x02
+
+/*
+ * RIFF Magic is a field with which we can be 100% certain
+ * that file that we are reading is a wav
+ */
+
+#define __RIFF_MAGIC 'R', 'I', 'F', 'F'
+#define __FORMAT_CHUNK_MAGIC 'f', 'm', 't', ' '
+#define __FILE_HEADER 'W', 'A', 'V', 'E'
+#define __DATA_START 'd', 'a', 't', 'a'
+
+static const unsigned char RIFF_MAGIC[4] = { __RIFF_MAGIC };
+
+/*
+ * This header does take the most important informations about
+ * the wav file
+ */
+typedef struct ivafl_wav_header_info_t {
+ unsigned char riff_magic[4];
+ unsigned int file_size;
+ unsigned char file_header[4];
+ unsigned char format_chunk[4];
+ unsigned int length_format_data;
+ unsigned short type_format;
+ unsigned short channels_number;
+ unsigned int sample_rate;
+ unsigned int bytes_sec;
+ unsigned short block_align;
+ unsigned short bits_per_sample;
+ unsigned char data_start[4];
+ unsigned int data_section_length;
+} ivafl_wav_header_info_t;
+
+/*
+ * Look of a wav file
+ * 0 - 44 : wav header
+ * 44 - ... : wav data
+ */
+typedef struct ivafl_wav_header_t {
+ ivafl_wav_header_info_t* wav_header_info;
+ unsigned char* wav_data_section;
+ void* wav_allocated_bytes;
+} ivafl_wav_header_t;
+
+/*
+ * ----------------------
+ * Decode
+ * ----------------------
+ */
+
+/*
+ * Function `ivafl_create_wav` does create a wav structure
+ * that can be written to a file by `ivafl_write_wav_file`
+ * function
+ */
+ivafl_wav_header_t* ivafl_create_wav(unsigned short channels,
+ unsigned int sample_rate,
+ unsigned int bits_per_sample,
+ unsigned char* wav_data,
+ unsigned long wav_data_len);
+
+/*
+ * ----------------------
+ * Encode
+ * ----------------------
+ */
+
+/*
+ * The `ivafl_is_file_wav` function does take one argument which
+ * is `FILE*` that is pointer from file structure. This function
+ * does take first 4 bytes and look are they are equal to `'RIFF'`
+ * (`RIFF_MAGIC` constant defined in `ivafl_wav.h`) which is always
+ * the start of WAV file. If the file is WAV then this function will
+ * return `0` on success and `-1` on error
+ */
+int ivafl_is_file_wav(ivafl_wav_header_t* wav_header);
+
+/*
+ * Function `ivafl_parse_file_into_wav` does take one argument which
+ * is `FILE*` that is pointer from file structure. Function does parse
+ * whole file into wav_header (`ivafl_wav_header_t` structure). Structure
+ * `ivafl_wav_header_t` does have every information about wav file.
+ */
+ivafl_wav_header_t* ivafl_parse_file_into_wav_header(FILE* f);
+
+/*
+ * The `ivafl_wav_clean` does clean up allocated memory for `ivafl_wav_header_t*`
+ * structure
+ */
+void ivafl_wav_clean(ivafl_wav_header_t* wav_header);
+
+/*
+ * The `ivafl_wav_get_file_length_ms` does take `ivafl_wav_header_t`
+ * structure which defines all informations about wav file. Function
+ * will return file length in miliseconds
+ */
+long ivafl_wav_get_file_length_ms(ivafl_wav_header_t* wav_header);
+
+/*
+ * The `ivafl_wav_get_file_length_sec` does take `ivafl_wav_header_t`
+ * structure which defines all informations about wav file. Function
+ * will return file length in seconds
+ */
+double ivafl_wav_get_file_length_sec(ivafl_wav_header_t* wav_header);
+
+ #endif /* __ivafl_WAV_H */
\ No newline at end of file
diff --git a/src/avi/ivafl_avi_decode.c b/src/avi/ivafl_avi_decode.c
new file mode 100644
index 0000000..7c43d26
--- /dev/null
+++ b/src/avi/ivafl_avi_decode.c
@@ -0,0 +1,17 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
\ No newline at end of file
diff --git a/src/avi/ivafl_avi_encode.c b/src/avi/ivafl_avi_encode.c
new file mode 100644
index 0000000..7c43d26
--- /dev/null
+++ b/src/avi/ivafl_avi_encode.c
@@ -0,0 +1,17 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
\ No newline at end of file
diff --git a/src/bmp/ivafl_bmp_decode.c b/src/bmp/ivafl_bmp_decode.c
new file mode 100644
index 0000000..7c43d26
--- /dev/null
+++ b/src/bmp/ivafl_bmp_decode.c
@@ -0,0 +1,17 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
\ No newline at end of file
diff --git a/src/bmp/ivafl_bmp_encode.c b/src/bmp/ivafl_bmp_encode.c
new file mode 100644
index 0000000..7c43d26
--- /dev/null
+++ b/src/bmp/ivafl_bmp_encode.c
@@ -0,0 +1,17 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
\ No newline at end of file
diff --git a/src/ivafl_alloc.c b/src/ivafl_alloc.c
new file mode 100644
index 0000000..a9774e9
--- /dev/null
+++ b/src/ivafl_alloc.c
@@ -0,0 +1,77 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
+
+#include
+#include
+#include
+
+#include
+
+/*
+ * Function for reallocating memory at given pointer.
+ * Basically it can grow size of our allocation. If
+ * return equals NULL ((void*)0) then allocating
+ * failed
+*/
+void*
+__ivafl_realloc(const void* ptr, size_t nsize)
+{
+ void* allocated_ptr = realloc((void*)ptr, nsize);
+ if (allocated_ptr == ivafl_NULL)
+ ivafl_logf("(__ivafl_realloc) Couldn't reallocate %lu bytes", nsize);
+
+ return allocated_ptr;
+}
+
+/*
+ * Easier allocating that does simple math (n * size)
+ * that does call malloc to allocate memory. If return
+ * equals NULL ((void*)0) then allocating failed
+ */
+void*
+__ivafl_calloc(int n, size_t size)
+{
+ void* allocated_ptr = calloc(n, size);
+ if (allocated_ptr == ivafl_NULL)
+ ivafl_logf("(__ivafl_calloc) Couldn't allocate %lu bytes", size);
+
+ return allocated_ptr;
+}
+
+/*
+ * Allocating given amount of bytes. If return equals
+ * NULL ((void*)0) then allocating failed
+ */
+void*
+__ivafl_malloc(size_t size)
+{
+ void* allocated_ptr = malloc(size);
+ if (allocated_ptr == ivafl_NULL)
+ ivafl_logf("(__ivafl_malloc) Couldn't allocate %lu bytes", size);
+
+ return allocated_ptr;
+}
+
+/*
+ * Free allocated memory at given pointer.
+ */
+void
+__ivafl_free(const void* ptr)
+{
+ free((void*)ptr);
+}
\ No newline at end of file
diff --git a/src/ivafl_log.c b/src/ivafl_log.c
new file mode 100644
index 0000000..7ccd019
--- /dev/null
+++ b/src/ivafl_log.c
@@ -0,0 +1,51 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+/*
+ * The ivafl_logf does print log that shows in the console.
+ * logs are for developer to know where's the error. ivafl_logf
+ * uses c format to give additional informations
+ */
+void
+ivafl_logf(const char* fmt, ...)
+{
+ va_list list;
+ va_start(list, fmt);
+
+ // Why (strlen(fmt) * 1.5) I think this is a safe value in which
+ // everything can fit without any problems with overflows.
+ char* buf = ivafl_malloc((size_t)(strlen(fmt) * 1.5));
+ if (buf != NULL)
+ {
+ sprintf(buf, fmt, list);
+ printf("[LOG]: %s\n", buf);
+ }
+ else
+ exit(EXIT_FAILURE);
+
+ ivafl_free(buf);
+ va_end(list);
+}
\ No newline at end of file
diff --git a/src/ivafl_utils.c b/src/ivafl_utils.c
new file mode 100644
index 0000000..cdc2fcc
--- /dev/null
+++ b/src/ivafl_utils.c
@@ -0,0 +1,97 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
+
+#include
+#include
+#include
+
+#include
+#include
+
+#define ivafl_DEFAULT_BYTES_FOPEN_MODE ("rb")
+
+/*
+ * This function does read given file and return
+ * `unsigned char*` (array of bytes) that then can
+ * be used to for example parse wav file or other
+ * format
+ */
+unsigned char*
+ivafl_read_bytes(const char* filename)
+{
+ FILE* f = fopen(filename, ivafl_DEFAULT_BYTES_FOPEN_MODE);
+ if (f == ivafl_NULL)
+ {
+ ivafl_logf("(ivafl_read_bytes) Failed while opening `%s` file", filename);
+ exit(EXIT_FAILURE);
+ }
+
+ unsigned char* bytes = ivafl_read_bytes_from_file(f);
+ fclose(f);
+
+ return bytes;
+}
+
+/*
+ * This function does read given `FILE*` structure
+ * that need to be opened with `"rb"` mode. Function
+ * does return unsigned char* (array of bytes) that
+ * then can be used to for example parse wav file
+ * or other format
+ */
+unsigned char*
+ivafl_read_bytes_from_file(FILE* f)
+{
+ if (f == ivafl_NULL)
+ {
+ ivafl_logf("(ivafl_read_bytes_from_file) Failed given file is `NULL`");
+ exit(EXIT_FAILURE);
+ }
+
+ size_t file_len = ivafl_get_size_file(f);
+ unsigned char* bytes = ivafl_malloc((sizeof(unsigned char) * file_len) + 1);
+ char curr_char = 'A';
+
+ for (size_t i = 0; i < file_len; i++)
+ {
+ curr_char = fgetc(f);
+ bytes[i] = curr_char;
+ }
+
+ return bytes;
+}
+
+/*
+ * The `ivafl_get_size_file` function does return `size_t`
+ * that indicates the given `FILE*` structure content length
+ */
+size_t
+ivafl_get_size_file(FILE* f)
+{
+ if (f == ivafl_NULL)
+ {
+ ivafl_logf("(ivafl_get_size_file) Failed given file is `NULL`");
+ exit(EXIT_FAILURE);
+ }
+
+ fseek(f, 0, SEEK_END);
+ size_t len = ftell(f);
+ fseek(f, 0, SEEK_SET);
+
+ return len;
+}
\ No newline at end of file
diff --git a/src/ivalf_log.o b/src/ivalf_log.o
new file mode 100644
index 0000000..67227b7
Binary files /dev/null and b/src/ivalf_log.o differ
diff --git a/src/jpeg/ivafl_jpeg_decode.c b/src/jpeg/ivafl_jpeg_decode.c
new file mode 100644
index 0000000..7c43d26
--- /dev/null
+++ b/src/jpeg/ivafl_jpeg_decode.c
@@ -0,0 +1,17 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
\ No newline at end of file
diff --git a/src/jpeg/ivafl_jpeg_encode.c b/src/jpeg/ivafl_jpeg_encode.c
new file mode 100644
index 0000000..7c43d26
--- /dev/null
+++ b/src/jpeg/ivafl_jpeg_encode.c
@@ -0,0 +1,17 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
\ No newline at end of file
diff --git a/src/mp3/ivafl_mp3_decode.c b/src/mp3/ivafl_mp3_decode.c
new file mode 100644
index 0000000..7c43d26
--- /dev/null
+++ b/src/mp3/ivafl_mp3_decode.c
@@ -0,0 +1,17 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
\ No newline at end of file
diff --git a/src/mp3/ivafl_mp3_encode.c b/src/mp3/ivafl_mp3_encode.c
new file mode 100644
index 0000000..7c43d26
--- /dev/null
+++ b/src/mp3/ivafl_mp3_encode.c
@@ -0,0 +1,17 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
\ No newline at end of file
diff --git a/src/mp4/ivafl_mp4_decode.c b/src/mp4/ivafl_mp4_decode.c
new file mode 100644
index 0000000..7c43d26
--- /dev/null
+++ b/src/mp4/ivafl_mp4_decode.c
@@ -0,0 +1,17 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
\ No newline at end of file
diff --git a/src/mp4/ivafl_mp4_encode.c b/src/mp4/ivafl_mp4_encode.c
new file mode 100644
index 0000000..7c43d26
--- /dev/null
+++ b/src/mp4/ivafl_mp4_encode.c
@@ -0,0 +1,17 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
\ No newline at end of file
diff --git a/src/png/ivafl_png_decode.c b/src/png/ivafl_png_decode.c
new file mode 100644
index 0000000..7c43d26
--- /dev/null
+++ b/src/png/ivafl_png_decode.c
@@ -0,0 +1,17 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
\ No newline at end of file
diff --git a/src/png/ivafl_png_encode.c b/src/png/ivafl_png_encode.c
new file mode 100644
index 0000000..7c43d26
--- /dev/null
+++ b/src/png/ivafl_png_encode.c
@@ -0,0 +1,17 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
\ No newline at end of file
diff --git a/src/wav/ivafl_wav_decode.c b/src/wav/ivafl_wav_decode.c
new file mode 100644
index 0000000..826d015
--- /dev/null
+++ b/src/wav/ivafl_wav_decode.c
@@ -0,0 +1,59 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
+
+#include
+#include
+#include
+
+#include
+
+/*
+ * Function `ivafl_create_wav` does create a wav structure
+ * that can be written to a file by `ivafl_write_wav_file`
+ * function
+ */
+ivafl_wav_header_t*
+ivafl_create_wav(unsigned short channels,
+ unsigned int sample_rate,
+ unsigned int bits_per_sample,
+ unsigned char* wav_data,
+ unsigned long wav_data_len)
+{
+ ivafl_wav_header_t* wav_header = (ivafl_wav_header_t*)ivafl_malloc(sizeof(ivafl_wav_header_t));
+ ivafl_wav_header_info_t wav_header_info = {
+ .riff_magic = { __RIFF_MAGIC },
+ .file_size = wav_data_len + sizeof(ivafl_wav_header_info_t), // I'm not sure is this a correct way
+ .file_header = { __FILE_HEADER },
+ .format_chunk = { __FORMAT_CHUNK_MAGIC },
+ .length_format_data = 16,
+ .type_format = 1,
+ .channels_number = channels,
+ .sample_rate = sample_rate,
+ .bytes_sec = WAV_BYTES_SEC_CALCULATE(sample_rate, bits_per_sample, channels),
+ .block_align = WAV_BLOCK_ALIGN_CALCULATE(bits_per_sample, channels),
+ .bits_per_sample = bits_per_sample,
+ .data_start = { __DATA_START },
+ .data_section_length = wav_data_len
+ };
+
+ wav_header->wav_header_info = &wav_header_info;
+ wav_header->wav_allocated_bytes = NULL;
+ wav_header->wav_data_section = wav_data;
+
+ return wav_header;
+}
\ No newline at end of file
diff --git a/src/wav/ivafl_wav_encode.c b/src/wav/ivafl_wav_encode.c
new file mode 100644
index 0000000..df565f2
--- /dev/null
+++ b/src/wav/ivafl_wav_encode.c
@@ -0,0 +1,94 @@
+/*
+ * ivafl - Image, Video, Aufio formats library
+ * Copyright (C) 2023 SolindekDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
+
+#include
+#include
+#include
+
+#include
+
+/*
+ * The `ivafl_is_file_wav` function does take one argument which
+ * is `FILE*` that is pointer from file structure. This function
+ * does take first 4 bytes and look are they are equal to `'RIFF'`
+ * (`RIFF_MAGIC` constant defined in `ivafl_wav.h`) which is always
+ * the start of WAV file. If the file is WAV then this function will
+ * return `0` on success and `-1` on error
+ */
+int
+ivafl_is_file_wav(ivafl_wav_header_t* wav_header)
+{
+ if (memcmp(wav_header->wav_header_info->riff_magic, RIFF_MAGIC, 4) != 0)
+ {
+ // error
+ return -1;
+ }
+
+ // success
+ return 0;
+}
+
+/*
+ * Function `ivafl_parse_file_into_wav` does take one argument which
+ * is `FILE*` that is pointer from file structure. Function does parse
+ * whole file into wav_header (`ivafl_wav_header_t` structure). Structure
+ * `ivafl_wav_header_t` does have every information about wav file.
+ */
+ivafl_wav_header_t*
+ivafl_parse_file_into_wav_header(FILE* f)
+{
+ unsigned char* bytes = ivafl_read_bytes_from_file(f);
+
+ ivafl_wav_header_t* wav_header_info = (ivafl_wav_header_t*)ivafl_malloc(sizeof(ivafl_wav_header_t));
+ wav_header_info->wav_header_info = ((ivafl_wav_header_info_t*)bytes);
+ wav_header_info->wav_data_section = ((unsigned char*)(bytes + sizeof(ivafl_wav_header_info_t)));
+ wav_header_info->wav_allocated_bytes = ((void*)bytes);
+
+ return wav_header_info;
+}
+
+/*
+ * The `ivafl_wav_clean` does clean up allocated memory for `ivafl_wav_header_t*`
+ * structure
+ */
+void
+ivafl_wav_clean(ivafl_wav_header_t* wav_header)
+{
+ ivafl_free(wav_header->wav_allocated_bytes);
+ ivafl_free(wav_header);
+}
+
+/*
+ * The `ivafl_wav_get_file_length_ms` does take `ivafl_wav_header_t`
+ * structure which defines all informations about wav file. Function
+ * will return file length in miliseconds
+ */
+long ivafl_wav_get_file_length_ms(ivafl_wav_header_t* wav_header)
+{
+ return (ivafl_wav_get_file_length_sec(wav_header)) * 1000;
+}
+
+/*
+ * The `ivafl_wav_get_file_length_sec` does take `ivafl_wav_header_t`
+ * structure which defines all informations about wav file. Function
+ * will return file length in seconds
+ */
+double ivafl_wav_get_file_length_sec(ivafl_wav_header_t* wav_header)
+{
+ return ((double)wav_header->wav_header_info->data_section_length / wav_header->wav_header_info->bytes_sec);
+}
\ No newline at end of file