Mercurial > libedl
annotate src/edl.c @ 6:7137fbac0b85
edl: expose EDL_reallocate() API to allow resizing the array
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Thu, 28 Dec 2023 16:47:24 -0500 |
parents | c2408abb258a |
children | 0c98b46eaf73 |
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" |
4
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
7 #include "str.h" |
3
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
8 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
9 #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
|
10 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
11 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
|
12 uint32_t crc = 0xFFFFFFFF; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
13 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
14 size_t i; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
15 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
|
16 crc = crc ^ message[i]; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
17 size_t j; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
18 for (j = 0; j < 8; j++) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
19 crc = (crc >> 1) ^ (0xEDB88320 & -(crc & 1)); |
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 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
22 return ~crc; |
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 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
25 /* 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
|
26 * 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
|
27 * the order of the strings. |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
28 */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
29 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
|
30 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
|
31 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
|
32 |
4
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
33 size_t len_until_newline = strchr(data, '\n') - data, len_until_cr = strchr(data, '\r') - data; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
34 size_t i, b; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
35 for (i = 0, b = 0; i <= len_until_newline && i <= len_until_cr; i++, b++) { |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
36 if (data[i] == ';' || data[i] == ':' || data[i] == '\r' || data[i] == '\n') { |
3
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
37 if (current_hash >= hashes_size) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
38 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
|
39 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
|
40 b = -1; // ew |
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 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
43 |
4
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
44 *length = current_hash; // wtf? |
3
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 return hashes; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
47 } |
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 /* -- Functions to extract different datatypes -- */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
50 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
51 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
|
52 size_t s = 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
53 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
54 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
|
55 if (s + offset > length) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
56 return s; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
57 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
58 s += strspn(&input[offset + s], ";\t "); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
59 if (s + offset > length) |
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 return s; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
63 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
64 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
65 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
|
66 if (offset > length) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
67 return 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
68 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
69 { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
70 char* ptr_return; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
71 *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
|
72 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
73 if (!ptr_return) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
74 return 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
75 } |
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 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
|
78 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
79 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
80 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
|
81 if (offset > length) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
82 return 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
83 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
84 { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
85 char* ptr_return; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
86 *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
|
87 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
88 if (!ptr_return) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
89 return 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
90 } |
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 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
|
93 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
94 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
95 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
|
96 if (offset > length) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
97 return 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
98 |
4
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
99 if (!strncmp(&input[offset], "TRUE", 4)) |
3
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
100 *bool_return = true; |
4
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
101 else if (!strncmp(&input[offset], "FALSE", 5)) |
3
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
102 *bool_return = false; |
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 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
|
105 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
106 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
107 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
|
108 if (offset > length) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
109 return 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
110 |
4
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
111 if (!strncmp(&input[offset], "VIDEO", 5)) |
3
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
112 *media_return = MEDIATYPE_VIDEO; |
4
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
113 else if (!strncmp(&input[offset], "AUDIO", 5)) |
3
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
114 *media_return = MEDIATYPE_AUDIO; |
4
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
115 else |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
116 *media_return = MEDIATYPE_UNKNOWN; |
3
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
117 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
118 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
|
119 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
120 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
121 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
|
122 /* 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
|
123 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
|
124 if (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 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
|
128 if (start + 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 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
|
132 if (start + s_length + offset > length) |
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 *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
|
136 if (!*string_return) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
137 return 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
138 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
139 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
|
140 (*string_return)[s_length] = '\0'; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
141 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
142 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
|
143 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
144 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
145 /* memory management routines */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
146 |
6
7137fbac0b85
edl: expose EDL_reallocate() API to allow resizing the array
Paper <mrpapersonic@gmail.com>
parents:
4
diff
changeset
|
147 int EDL_reallocate(EDL* input, size_t new_capacity) { |
3
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
148 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
|
149 if (!input->arr) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
150 return 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
151 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
152 if (new_capacity > input->capacity) |
4
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
153 memset(&input->arr[input->capacity], 0, (new_capacity - input->capacity) * sizeof(EDL_line)); |
3
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 input->capacity = new_capacity; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
156 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
157 return 1; |
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 /* the important function */ |
4
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
161 EDL EDL_parse(const char* data, size_t length) { |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
162 EDL edl = {0}; |
6
7137fbac0b85
edl: expose EDL_reallocate() API to allow resizing the array
Paper <mrpapersonic@gmail.com>
parents:
4
diff
changeset
|
163 if (!EDL_reallocate(&edl, 16)) |
3
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
164 return edl; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
165 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
166 size_t order_size = 0; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
167 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
|
168 |
4
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
169 size_t offset = 0; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
170 while ((offset = strnchr(&data[offset], '\n', length - offset) - data + 1) < length) { |
3
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
171 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
|
172 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
173 bool ok = true; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
174 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
175 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
|
176 #define ADD_TO_OFFSET(x, a) \ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
177 { \ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
178 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
|
179 if (!o) \ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
180 ok = false; \ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
181 local_offset += o; \ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
182 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
183 switch (order[i]) { |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
184 case 0x1541c503: /* ID */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
185 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
|
186 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
187 case 0x4b211812: /* Track */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
188 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
|
189 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
190 case 0xbb46516f: /* StartTime */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
191 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
|
192 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
193 case 0xaeac5df7: /* Length */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
194 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
|
195 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
196 case 0x03834606: /* PlayRate */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
197 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
|
198 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
199 case 0x0c2083d3: /* Locked */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
200 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
|
201 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
202 case 0xe60c8b1d: /* Normalized */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
203 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
|
204 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
205 case 0xbe5802c9: /* StretchMethod */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
206 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
|
207 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
208 case 0x4ec8be4c: /* Looped */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
209 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
|
210 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
211 case 0xe6cb84d1: /* OnRuler */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
212 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
|
213 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
214 case 0x035f84c2: /* MediaType */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
215 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
|
216 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
217 case 0x379d32c5: /* FileName */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
218 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
|
219 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
220 case 0x9f334738: /* Stream */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
221 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
|
222 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
223 case 0x07b4e0e7: /* StreamStart */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
224 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
|
225 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
226 case 0x8f16c7b8: /* StreamLength */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
227 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
|
228 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
229 case 0xd2edd7e4: /* FadeTimeIn */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
230 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
|
231 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
232 case 0x792e8c40: /* FadeTimeOut */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
233 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
|
234 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
235 case 0x98374657: /* SustainGain */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
236 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
|
237 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
238 case 0x3e998b1f: /* CurveIn */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
239 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
|
240 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
241 case 0x82fb09c4: /* GainIn */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
242 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
|
243 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
244 case 0x53add388: /* CurveOut */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
245 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
|
246 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
247 case 0x4210ba56: /* GainOut */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
248 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
|
249 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
250 case 0x89c4df6c: /* Layer */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
251 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
|
252 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
253 case 0xadf2f1a3: /* Color */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
254 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
|
255 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
256 case 0xa56b43e1: /* CurveInR */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
257 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
|
258 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
259 case 0xcb6d715e: /* CurveOutR */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
260 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
|
261 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
262 case 0x9da1b9ed: /* PlayPitch */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
263 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
|
264 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
265 case 0x2bda6ed4: /* LockPitch */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
266 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
|
267 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
268 case 0x3071a4c6: /* FirstChannel */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
269 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
|
270 break; |
4
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
271 case 0xe94981a4: /* Channels */ |
3
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
272 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
|
273 break; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
274 default: |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
275 /* ... what */ |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
276 break; |
4
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
277 #undef ADD_TO_OFFSET |
3
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
278 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
279 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
280 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
281 if (!ok) |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
282 break; |
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 (++edl.size >= edl.capacity) |
6
7137fbac0b85
edl: expose EDL_reallocate() API to allow resizing the array
Paper <mrpapersonic@gmail.com>
parents:
4
diff
changeset
|
285 EDL_reallocate(&edl, edl.capacity * 2); |
3
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 |
6
7137fbac0b85
edl: expose EDL_reallocate() API to allow resizing the array
Paper <mrpapersonic@gmail.com>
parents:
4
diff
changeset
|
288 EDL_reallocate(&edl, edl.size); |
3
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 free(order); |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
291 |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
292 return edl; |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
293 } |
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
294 |
4
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
295 static char* EDL_internal_integer_to_string(int value) { |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
296 char out[256] = {0}; // this ought to be enough. |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
297 snprintf(out, 256, "%d", value); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
298 out[255] = '\0'; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
299 return strdup(out); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
300 } |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
301 |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
302 static char* EDL_internal_double_to_string(double value) { |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
303 char out[256] = {0}; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
304 snprintf(out, 256, "%.6f", value); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
305 out[255] = '\0'; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
306 return strdup(out); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
307 } |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
308 |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
309 static char* EDL_internal_bool_to_string(bool value) { |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
310 return strdup(value ? "TRUE" : "FALSE"); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
311 } |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
312 |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
313 static char* EDL_internal_media_type_to_string(MediaType value) { |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
314 switch (value) { |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
315 case MEDIATYPE_AUDIO: |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
316 return strdup("AUDIO"); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
317 case MEDIATYPE_VIDEO: |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
318 case MEDIATYPE_UNKNOWN: |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
319 default: |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
320 return strdup("VIDEO"); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
321 } |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
322 } |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
323 |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
324 static void EDL_dump_line(EDL_internal_string* str, EDL_line line, const uint32_t* order, const size_t order_len) { |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
325 for (size_t i = 0; i < order_len; i++) { |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
326 switch (order[i]) { |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
327 #define APPEND_ITEM(a, x) \ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
328 { \ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
329 char* tstr = x(line.a); \ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
330 EDL_internal_string_append(str, tstr, strlen(tstr)); \ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
331 free(tstr); \ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
332 } |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
333 case 0x1541c503: /* ID */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
334 APPEND_ITEM(id, EDL_internal_integer_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
335 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
336 case 0x4b211812: /* Track */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
337 APPEND_ITEM(track, EDL_internal_integer_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
338 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
339 case 0xbb46516f: /* StartTime */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
340 APPEND_ITEM(start_time, EDL_internal_double_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
341 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
342 case 0xaeac5df7: /* Length */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
343 APPEND_ITEM(length, EDL_internal_double_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
344 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
345 case 0x03834606: /* PlayRate */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
346 APPEND_ITEM(play_rate, EDL_internal_double_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
347 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
348 case 0x0c2083d3: /* Locked */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
349 APPEND_ITEM(locked, EDL_internal_bool_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
350 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
351 case 0xe60c8b1d: /* Normalized */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
352 APPEND_ITEM(normalized, EDL_internal_bool_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
353 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
354 case 0xbe5802c9: /* StretchMethod */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
355 APPEND_ITEM(stretch_method, EDL_internal_integer_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
356 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
357 case 0x4ec8be4c: /* Looped */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
358 APPEND_ITEM(looped, EDL_internal_bool_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
359 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
360 case 0xe6cb84d1: /* OnRuler */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
361 APPEND_ITEM(on_ruler, EDL_internal_bool_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
362 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
363 case 0x035f84c2: /* MediaType */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
364 APPEND_ITEM(media_type, EDL_internal_media_type_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
365 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
366 case 0x379d32c5: /* FileName */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
367 EDL_internal_string_append(str, "\"", 1); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
368 EDL_internal_string_append(str, line.filename, strlen(line.filename)); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
369 EDL_internal_string_append(str, "\"", 1); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
370 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
371 case 0x9f334738: /* Stream */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
372 APPEND_ITEM(stream, EDL_internal_integer_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
373 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
374 case 0x07b4e0e7: /* StreamStart */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
375 APPEND_ITEM(stream_start, EDL_internal_double_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
376 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
377 case 0x8f16c7b8: /* StreamLength */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
378 APPEND_ITEM(stream_length, EDL_internal_double_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
379 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
380 case 0xd2edd7e4: /* FadeTimeIn */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
381 APPEND_ITEM(fade_time_in, EDL_internal_double_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
382 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
383 case 0x792e8c40: /* FadeTimeOut */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
384 APPEND_ITEM(fade_time_out, EDL_internal_double_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
385 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
386 case 0x98374657: /* SustainGain */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
387 APPEND_ITEM(sustain_gain, EDL_internal_double_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
388 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
389 case 0x3e998b1f: /* CurveIn */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
390 APPEND_ITEM(curve_in, EDL_internal_integer_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
391 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
392 case 0x82fb09c4: /* GainIn */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
393 APPEND_ITEM(gain_in, EDL_internal_double_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
394 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
395 case 0x53add388: /* CurveOut */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
396 APPEND_ITEM(curve_out, EDL_internal_integer_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
397 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
398 case 0x4210ba56: /* GainOut */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
399 APPEND_ITEM(gain_out, EDL_internal_double_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
400 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
401 case 0x89c4df6c: /* Layer */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
402 APPEND_ITEM(layer, EDL_internal_integer_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
403 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
404 case 0xadf2f1a3: /* Color */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
405 APPEND_ITEM(color, EDL_internal_integer_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
406 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
407 case 0xa56b43e1: /* CurveInR */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
408 APPEND_ITEM(curve_in_r, EDL_internal_integer_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
409 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
410 case 0xcb6d715e: /* CurveOutR */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
411 APPEND_ITEM(curve_out_r, EDL_internal_integer_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
412 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
413 case 0x9da1b9ed: /* PlayPitch */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
414 APPEND_ITEM(play_pitch, EDL_internal_double_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
415 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
416 case 0x2bda6ed4: /* LockPitch */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
417 APPEND_ITEM(lock_pitch, EDL_internal_bool_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
418 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
419 case 0x3071a4c6: /* FirstChannel */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
420 APPEND_ITEM(first_channel, EDL_internal_integer_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
421 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
422 case 0xe94981a4: /* Channels */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
423 APPEND_ITEM(channels, EDL_internal_integer_to_string); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
424 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
425 default: |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
426 /* ... what */ |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
427 break; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
428 #undef APPEND_ITEM |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
429 } |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
430 |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
431 if (i < order_len - 1) |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
432 EDL_internal_string_append(str, ";\t", 2); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
433 else |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
434 EDL_internal_string_append(str, ";", 1); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
435 } |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
436 |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
437 EDL_internal_string_append(str, "\n", 1); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
438 } |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
439 |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
440 char* EDL_dump(EDL edl) { |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
441 EDL_internal_string ret; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
442 EDL_internal_string_init(&ret); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
443 |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
444 static const char order_str[] = "\"ID\";\"Track\";\"StartTime\";\"Length\";\"PlayRate\";\"Locked\";\"Normalized\";\"StretchMethod\";\"Looped\";\"OnRuler\";\"MediaType\";\"FileName\";\"Stream\";\"StreamStart\";\"StreamLength\";\"FadeTimeIn\";\"FadeTimeOut\";\"SustainGain\";\"CurveIn\";\"GainIn\";\"CurveOut\";\"GainOut\";\"Layer\";\"Color\";\"CurveInR\";\"CurveOutR\":\"PlayPitch\";\"LockPitch\";\"FirstChannel\";\"Channels\"\n"; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
445 EDL_internal_string_append(&ret, order_str, strlen(order_str)); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
446 |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
447 size_t order_len; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
448 uint32_t* order = EDL_internal_parse_first_line(order_str, &order_len); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
449 |
3
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
450 size_t i; |
4
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
451 for (i = 0; i < edl.size; i++) |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
452 EDL_dump_line(&ret, edl.arr[i], order, order_len); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
453 |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
454 free(order); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
455 |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
456 EDL_internal_string_allocate(&ret, ret.size); |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
457 |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
458 return ret.data; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
459 } |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
460 |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
461 void EDL_free(EDL edl) { |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
462 size_t i; |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
463 for (i = 0; i < edl.size; i++) { |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
464 if (edl.arr[i].filename) |
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
465 free(edl.arr[i].filename); |
3
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
466 } |
4
c2408abb258a
*: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents:
3
diff
changeset
|
467 free(edl.arr); |
3
bd99b6549eb4
*: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
468 } |