Mercurial > libedl
annotate src/edl.c @ 3:bd99b6549eb4
*: expand in readme and rename src/main to src/edl
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sun, 24 Dec 2023 20:22:54 -0500 |
parents | |
children | c2408abb258a |
rev | line source |
---|---|
3
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
1 #include <string.h> |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
2 #include <stdbool.h> |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
3 #include <stdio.h> |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
4 #include <stdlib.h> |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
5 #include <stdint.h> |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
6 #include "edl.h" |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
7 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
8 #define strnchr(haystack, needle, length) (char*)memchr(haystack, needle, strnlen(haystack, length)) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
9 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
10 static uint32_t EDL_internal_crcn32b(const unsigned char* restrict message, size_t length) { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
11 uint32_t crc = 0xFFFFFFFF; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
12 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
13 size_t i; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
14 for (i = 0; i < length && message[i]; i++) { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
15 crc = crc ^ message[i]; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
16 size_t j; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
17 for (j = 0; j < 8; j++) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
18 crc = (crc >> 1) ^ (0xEDB88320 & -(crc & 1)); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
19 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
20 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
21 return ~crc; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
22 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
23 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
24 /* This parses the first line of the EDL and |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
25 * creates an array with CRC32 hashes in |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
26 * the order of the strings. |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
27 */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
28 static uint32_t* EDL_internal_parse_first_line(const char* data, size_t* restrict length) { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
29 size_t hashes_size = 32, current_hash = 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
30 uint32_t* hashes = malloc(hashes_size * sizeof(uint32_t)); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
31 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
32 size_t len_until_newline = strchr(data, '\n') - data, i, b; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
33 for (i = 0, b = 0; i < len_until_newline; i++, b++) { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
34 if (data[i] == ';') { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
35 if (current_hash >= hashes_size) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
36 hashes = realloc(hashes, (hashes_size *= 2) * sizeof(uint32_t)); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
37 hashes[current_hash++] = EDL_internal_crcn32b((const unsigned char*)&data[i - b], b); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
38 b = -1; // ew |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
39 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
40 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
41 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
42 *length = current_hash; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
43 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
44 return hashes; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
45 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
46 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
47 /* -- Functions to extract different datatypes -- */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
48 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
49 static size_t EDL_internal_append_offset(const char* input, size_t offset, size_t length) { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
50 size_t s = 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
51 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
52 s += strchr(&input[offset + s], ';') - &input[offset]; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
53 if (s + offset > length) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
54 return s; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
55 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
56 s += strspn(&input[offset + s], ";\t "); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
57 if (s + offset > length) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
58 return s; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
59 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
60 return s; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
61 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
62 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
63 static size_t EDL_internal_get_int(const char* input, size_t offset, size_t length, int* int_return) { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
64 if (offset > length) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
65 return 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
66 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
67 { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
68 char* ptr_return; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
69 *int_return = strtol(&input[offset], &ptr_return, 10); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
70 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
71 if (!ptr_return) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
72 return 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
73 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
74 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
75 return EDL_internal_append_offset(input, offset, length); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
76 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
77 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
78 static size_t EDL_internal_get_double(const char* input, size_t offset, size_t length, double* double_return) { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
79 if (offset > length) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
80 return 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
81 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
82 { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
83 char* ptr_return; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
84 *double_return = strtod(&input[offset], &ptr_return); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
85 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
86 if (!ptr_return) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
87 return 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
88 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
89 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
90 return EDL_internal_append_offset(input, offset, length); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
91 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
92 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
93 static size_t EDL_internal_get_bool(const char* input, size_t offset, size_t length, bool* bool_return) { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
94 if (offset > length) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
95 return 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
96 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
97 if (strncmp((input + offset), "TRUE", 4)) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
98 *bool_return = true; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
99 else if (strncmp((input + offset), "FALSE", 5)) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
100 *bool_return = false; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
101 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
102 return EDL_internal_append_offset(input, offset, length); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
103 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
104 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
105 static size_t EDL_internal_get_media_type(const char* input, size_t offset, size_t length, MediaType* media_return) { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
106 if (offset > length) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
107 return 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
108 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
109 if (strncmp(input + offset, "VIDEO", 5)) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
110 *media_return = MEDIATYPE_VIDEO; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
111 else if (strncmp(input + offset, "AUDIO", 5)) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
112 *media_return = MEDIATYPE_AUDIO; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
113 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
114 return EDL_internal_append_offset(input, offset, length); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
115 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
116 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
117 static size_t EDL_internal_get_string(const char* input, size_t offset, size_t length, char** string_return) { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
118 /* Windows filenames will *NEVER* include double quotes. |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
119 This might break with EDL files created with Reaper on Linux. */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
120 if (offset > length) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
121 return 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
122 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
123 size_t start = strchr(&input[offset], '\"') - &input[offset] + 1; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
124 if (start + offset > length) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
125 return 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
126 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
127 size_t s_length = strchr(&input[offset + start], '\"') - &input[offset] - start; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
128 if (start + s_length + offset > length) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
129 return 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
130 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
131 *string_return = malloc((s_length + 1) * sizeof(char)); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
132 if (!*string_return) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
133 return 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
134 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
135 memcpy(*string_return, &input[offset + start], s_length); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
136 (*string_return)[s_length] = '\0'; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
137 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
138 return EDL_internal_append_offset(input, offset, length); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
139 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
140 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
141 /* memory management routines */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
142 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
143 static int EDL_internal_reallocate(EDL_file* input, size_t new_capacity) { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
144 input->arr = realloc(input->arr, new_capacity * sizeof(EDL_line)); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
145 if (!input->arr) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
146 return 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
147 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
148 if (new_capacity > input->capacity) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
149 memset(input->arr + input->capacity, 0, new_capacity - input->capacity); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
150 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
151 input->capacity = new_capacity; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
152 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
153 return 1; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
154 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
155 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
156 static int EDL_internal_allocate_memory(EDL_file* input) { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
157 return EDL_internal_reallocate(input, input->capacity ? input->capacity * 2 : 16); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
158 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
159 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
160 static int EDL_internal_shrink_memory_to_fit(EDL_file* input) { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
161 return EDL_internal_reallocate(input, input->size); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
162 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
163 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
164 /* the important function */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
165 EDL_file EDL_parse(const char* data, size_t length) { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
166 EDL_file edl = {0}; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
167 if (!EDL_internal_allocate_memory(&edl)) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
168 return edl; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
169 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
170 size_t order_size = 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
171 uint32_t* order = EDL_internal_parse_first_line(data, &order_size); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
172 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
173 size_t offset = strnchr(data, '\n', length) - data + 1; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
174 while ((offset = strnchr(data + offset, '\n', length - offset) - data + 1) < length) { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
175 size_t local_offset = offset; // this is so our original offset stays intact |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
176 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
177 bool ok = true; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
178 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
179 for (int i = 0; i < order_size; i++) { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
180 #define ADD_TO_OFFSET(x, a) \ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
181 { \ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
182 size_t o = a(data, local_offset, length, &edl.arr[edl.size].x); \ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
183 if (!o) \ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
184 ok = false; \ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
185 local_offset += o; \ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
186 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
187 switch (order[i]) { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
188 case 0x1541c503: /* ID */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
189 ADD_TO_OFFSET(id, EDL_internal_get_int); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
190 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
191 case 0x4b211812: /* Track */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
192 ADD_TO_OFFSET(track, EDL_internal_get_int); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
193 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
194 case 0xbb46516f: /* StartTime */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
195 ADD_TO_OFFSET(start_time, EDL_internal_get_double); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
196 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
197 case 0xaeac5df7: /* Length */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
198 ADD_TO_OFFSET(length, EDL_internal_get_double); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
199 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
200 case 0x03834606: /* PlayRate */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
201 ADD_TO_OFFSET(play_rate, EDL_internal_get_double); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
202 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
203 case 0x0c2083d3: /* Locked */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
204 ADD_TO_OFFSET(locked, EDL_internal_get_bool); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
205 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
206 case 0xe60c8b1d: /* Normalized */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
207 ADD_TO_OFFSET(normalized, EDL_internal_get_bool); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
208 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
209 case 0xbe5802c9: /* StretchMethod */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
210 ADD_TO_OFFSET(stretch_method, EDL_internal_get_int); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
211 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
212 case 0x4ec8be4c: /* Looped */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
213 ADD_TO_OFFSET(looped, EDL_internal_get_bool); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
214 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
215 case 0xe6cb84d1: /* OnRuler */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
216 ADD_TO_OFFSET(on_ruler, EDL_internal_get_bool); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
217 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
218 case 0x035f84c2: /* MediaType */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
219 ADD_TO_OFFSET(media_type, EDL_internal_get_media_type); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
220 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
221 case 0x379d32c5: /* FileName */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
222 ADD_TO_OFFSET(filename, EDL_internal_get_string); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
223 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
224 case 0x9f334738: /* Stream */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
225 ADD_TO_OFFSET(stream, EDL_internal_get_int); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
226 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
227 case 0x07b4e0e7: /* StreamStart */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
228 ADD_TO_OFFSET(stream_start, EDL_internal_get_double); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
229 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
230 case 0x8f16c7b8: /* StreamLength */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
231 ADD_TO_OFFSET(stream_length, EDL_internal_get_double); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
232 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
233 case 0xd2edd7e4: /* FadeTimeIn */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
234 ADD_TO_OFFSET(fade_time_in, EDL_internal_get_double); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
235 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
236 case 0x792e8c40: /* FadeTimeOut */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
237 ADD_TO_OFFSET(fade_time_out, EDL_internal_get_double); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
238 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
239 case 0x98374657: /* SustainGain */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
240 ADD_TO_OFFSET(sustain_gain, EDL_internal_get_double); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
241 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
242 case 0x3e998b1f: /* CurveIn */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
243 ADD_TO_OFFSET(curve_in, EDL_internal_get_int); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
244 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
245 case 0x82fb09c4: /* GainIn */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
246 ADD_TO_OFFSET(gain_in, EDL_internal_get_double); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
247 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
248 case 0x53add388: /* CurveOut */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
249 ADD_TO_OFFSET(curve_out, EDL_internal_get_int); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
250 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
251 case 0x4210ba56: /* GainOut */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
252 ADD_TO_OFFSET(gain_out, EDL_internal_get_double); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
253 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
254 case 0x89c4df6c: /* Layer */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
255 ADD_TO_OFFSET(layer, EDL_internal_get_int); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
256 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
257 case 0xadf2f1a3: /* Color */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
258 ADD_TO_OFFSET(color, EDL_internal_get_int); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
259 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
260 case 0xa56b43e1: /* CurveInR */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
261 ADD_TO_OFFSET(curve_in_r, EDL_internal_get_int); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
262 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
263 case 0xcb6d715e: /* CurveOutR */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
264 ADD_TO_OFFSET(curve_out_r, EDL_internal_get_int); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
265 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
266 case 0x9da1b9ed: /* PlayPitch */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
267 ADD_TO_OFFSET(play_pitch, EDL_internal_get_double); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
268 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
269 case 0x2bda6ed4: /* LockPitch */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
270 ADD_TO_OFFSET(lock_pitch, EDL_internal_get_bool); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
271 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
272 case 0x3071a4c6: /* FirstChannel */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
273 ADD_TO_OFFSET(first_channel, EDL_internal_get_int); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
274 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
275 case 0x7de1bd40: /* Channels */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
276 ADD_TO_OFFSET(channels, EDL_internal_get_int); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
277 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
278 default: |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
279 /* ... what */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
280 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
281 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
282 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
283 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
284 if (!ok) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
285 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
286 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
287 if (++edl.size >= edl.capacity) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
288 EDL_internal_allocate_memory(&edl); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
289 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
290 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
291 EDL_internal_shrink_memory_to_fit(&edl); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
292 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
293 free(order); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
294 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
295 return edl; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
296 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
297 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
298 void EDL_free(EDL_file file) { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
299 size_t i; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
300 for (i = 0; i < file.size; i++) { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
301 if (file.arr[i].filename) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
302 free(file.arr[i].filename); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
303 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
304 free(file.arr); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
305 } |