annotate src/edl.c @ 9:21aad49ed2c9

Added tag v2.0 for changeset 0c98b46eaf73
author Paper <paper@paper.us.eu.org>
date Fri, 22 Mar 2024 20:50:47 -0400
parents 0c98b46eaf73
children 0cc2555db371
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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>
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
6
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
7 #include "edl.h"
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
8 #include "str.h"
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
9 #include "datatypes.h"
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
10 #include "util.h"
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
11
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
12 /* CRC32 hashes of EDL headers */
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
13 #define EDL_HEADER_ID 0x1541c503
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
14 #define EDL_HEADER_TRACK 0x4b211812
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
15 #define EDL_HEADER_STARTTIME 0xbb46516f
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
16 #define EDL_HEADER_LENGTH 0xaeac5df7
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
17 #define EDL_HEADER_PLAYRATE 0x03834606
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
18 #define EDL_HEADER_LOCKED 0x0c2083d3
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
19 #define EDL_HEADER_NORMALIZED 0xe60c8b1d
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
20 #define EDL_HEADER_STRETCHMETHOD 0xbe5802c9
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
21 #define EDL_HEADER_LOOPED 0x4ec8be4c
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
22 #define EDL_HEADER_ONRULER 0xe6cb84d1
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
23 #define EDL_HEADER_MEDIATYPE 0x035f84c2
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
24 #define EDL_HEADER_FILENAME 0x379d32c5
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
25 #define EDL_HEADER_STREAM 0x9f334738
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
26 #define EDL_HEADER_STREAMSTART 0x07b4e0e7
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
27 #define EDL_HEADER_STREAMLENGTH 0x8f16c7b8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
28 #define EDL_HEADER_FADETIMEIN 0xd2edd7e4
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
29 #define EDL_HEADER_FADETIMEOUT 0x792e8c40
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
30 #define EDL_HEADER_SUSTAINGAIN 0x98374657
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
31 #define EDL_HEADER_CURVEIN 0x3e998b1f
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
32 #define EDL_HEADER_GAININ 0x82fb09c4
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
33 #define EDL_HEADER_CURVEOUT 0x53add388
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
34 #define EDL_HEADER_GAINOUT 0x4210ba56
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
35 #define EDL_HEADER_LAYER 0x89c4df6c
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
36 #define EDL_HEADER_COLOR 0xadf2f1a3
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
37 #define EDL_HEADER_CURVEINR 0xa56b43e1
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
38 #define EDL_HEADER_CURVEOUTR 0xcb6d715e
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
39 #define EDL_HEADER_PLAYPITCH 0x9da1b9ed
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
40 #define EDL_HEADER_LOCKPITCH 0x2bda6ed4
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
41 #define EDL_HEADER_FIRSTCHANNEL 0x3071a4c6
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
42 #define EDL_HEADER_CHANNELS 0xe94981a4
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
43
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
44 /* use a CRC32 hash function to process the headers */
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
45 static uint32_t EDL_internal_crcn32b(const unsigned char* message, size_t length) {
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
46 uint32_t crc = 0xffffffff;
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
47 size_t i;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
48
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
49 for (i = 0; i < length && message[i]; i++) {
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
50 size_t j;
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
51
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
52 crc = crc ^ message[i];
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
53 for (j = 0; j < 8; j++)
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
54 crc = (crc >> 1) ^ (0xedb88320 & -(crc & 1));
3
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
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
57 return ~crc;
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
58 }
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
59
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
60 static size_t EDL_internal_size_t_min(size_t a, size_t b) {
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
61 return (a < b) ? a : b;
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
62 }
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
63
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
64 /* This parses the header of the EDL and creates an array with CRC32 hashes
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
65 * in the order of the strings.
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
66 */
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
67 static uint32_t* EDL_internal_parse_header(const char* data, size_t* length) {
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
68 /* */
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
69 const size_t newline = EDL_internal_size_t_min(strchr(data, '\n') - data, strchr(data, '\r') - data);
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
70
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
71 size_t current_hash = 0, hashes_size = 32;
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
72 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
73
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
74 /* overall iterates over the entire line,
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
75 * column stores the length of the current column */
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
76 size_t overall, column;
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
77
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
78 for (overall = 0, column = 0; overall <= newline; overall++) {
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
79 if (data[overall] == ';' || data[overall] == ':') {
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
80 /* process the current column */
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
81 if (hashes_size < current_hash)
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
82 hashes = realloc(hashes, (hashes_size *= 2) * sizeof(uint32_t));
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
83
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
84 hashes[current_hash++] = EDL_internal_crcn32b((const unsigned char*)&data[overall - column], column);
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
85 column = 0; /* reset */
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
86 } else column++;
3
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
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
89 *length = current_hash;
3
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 return hashes;
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
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
94 int EDL_reallocate(EDL* edl, size_t new_capacity) {
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
95 edl->arr = realloc(edl->arr, new_capacity * sizeof(EDL_line));
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
96 if (!edl->arr)
3
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
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
99 if (new_capacity > edl->capacity)
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
100 memset(&edl->arr[edl->capacity], 0, (new_capacity - edl->capacity) * sizeof(EDL_line));
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
101
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
102 edl->capacity = new_capacity;
3
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 1;
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
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
107 int EDL_append(EDL* edl, EDL_line line) {
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
108 if (edl->size + 1 < edl->capacity && !EDL_reallocate(edl, edl->capacity))
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
109 return 0;
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
110
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
111 edl->arr[++edl->size] = line;
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
112 return 1;
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
113 }
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
114
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
115 /* the big important function */
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
116 EDL_parse_error_t EDL_parse(EDL* edl, const char* data, size_t length) {
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
117 size_t order_size = 0;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
118 uint32_t* order = NULL;
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
119 size_t offset = 0;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
120
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
121 if (!EDL_reallocate(edl, 16))
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
122 return EDL_PARSE_ERROR_OUT_OF_MEMORY;
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
123
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
124 order = EDL_internal_parse_header(data, &order_size);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
125
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
126 while ((offset = EDL_internal_strnchr(&data[offset], '\n', length - offset) - data + 1) < length) {
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
127 size_t local_offset = offset; /* original offset stays intact */
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
128 bool ok = true;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
129 int i;
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
130
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
131 for (i = 0; i < order_size; i++) {
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
132 #define ADD_TO_OFFSET(x, a) \
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
133 { \
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
134 size_t o = a(data, local_offset, length, &edl->arr[edl->size].x); \
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
135 if (!o) \
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
136 ok = false; \
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
137 local_offset += o; \
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 switch (order[i]) {
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
140 case EDL_HEADER_ID:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
141 ADD_TO_OFFSET(id, EDL_internal_parse_int);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
142 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
143 case EDL_HEADER_TRACK:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
144 ADD_TO_OFFSET(track, EDL_internal_parse_int);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
145 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
146 case EDL_HEADER_STARTTIME:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
147 ADD_TO_OFFSET(start_time, EDL_internal_parse_double);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
148 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
149 case EDL_HEADER_LENGTH:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
150 ADD_TO_OFFSET(length, EDL_internal_parse_double);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
151 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
152 case EDL_HEADER_PLAYRATE:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
153 ADD_TO_OFFSET(play_rate, EDL_internal_parse_double);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
154 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
155 case EDL_HEADER_LOCKED:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
156 ADD_TO_OFFSET(locked, EDL_internal_parse_bool);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
157 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
158 case EDL_HEADER_NORMALIZED:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
159 ADD_TO_OFFSET(normalized, EDL_internal_parse_bool);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
160 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
161 case EDL_HEADER_STRETCHMETHOD:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
162 ADD_TO_OFFSET(stretch_method, EDL_internal_parse_int);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
163 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
164 case EDL_HEADER_LOOPED:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
165 ADD_TO_OFFSET(looped, EDL_internal_parse_bool);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
166 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
167 case EDL_HEADER_ONRULER:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
168 ADD_TO_OFFSET(on_ruler, EDL_internal_parse_bool);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
169 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
170 case EDL_HEADER_MEDIATYPE:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
171 ADD_TO_OFFSET(media_type, EDL_internal_parse_media_type);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
172 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
173 case EDL_HEADER_FILENAME:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
174 ADD_TO_OFFSET(filename, EDL_internal_parse_string);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
175 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
176 case EDL_HEADER_STREAM:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
177 ADD_TO_OFFSET(stream, EDL_internal_parse_int);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
178 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
179 case EDL_HEADER_STREAMSTART:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
180 ADD_TO_OFFSET(stream_start, EDL_internal_parse_double);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
181 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
182 case EDL_HEADER_STREAMLENGTH:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
183 ADD_TO_OFFSET(stream_length, EDL_internal_parse_double);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
184 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
185 case EDL_HEADER_FADETIMEIN:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
186 ADD_TO_OFFSET(fade_time_in, EDL_internal_parse_double);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
187 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
188 case EDL_HEADER_FADETIMEOUT:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
189 ADD_TO_OFFSET(fade_time_out, EDL_internal_parse_double);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
190 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
191 case EDL_HEADER_SUSTAINGAIN:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
192 ADD_TO_OFFSET(sustain_gain, EDL_internal_parse_double);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
193 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
194 case EDL_HEADER_CURVEIN:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
195 ADD_TO_OFFSET(curve_in, EDL_internal_parse_int);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
196 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
197 case EDL_HEADER_GAININ:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
198 ADD_TO_OFFSET(gain_in, EDL_internal_parse_double);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
199 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
200 case EDL_HEADER_CURVEOUT:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
201 ADD_TO_OFFSET(curve_out, EDL_internal_parse_int);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
202 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
203 case EDL_HEADER_GAINOUT:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
204 ADD_TO_OFFSET(gain_out, EDL_internal_parse_double);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
205 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
206 case EDL_HEADER_LAYER:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
207 ADD_TO_OFFSET(layer, EDL_internal_parse_int);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
208 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
209 case EDL_HEADER_COLOR:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
210 ADD_TO_OFFSET(color, EDL_internal_parse_int);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
211 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
212 case EDL_HEADER_CURVEINR:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
213 ADD_TO_OFFSET(curve_in_r, EDL_internal_parse_int);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
214 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
215 case EDL_HEADER_CURVEOUTR:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
216 ADD_TO_OFFSET(curve_out_r, EDL_internal_parse_int);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
217 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
218 case EDL_HEADER_PLAYPITCH:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
219 ADD_TO_OFFSET(play_pitch, EDL_internal_parse_double);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
220 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
221 case EDL_HEADER_LOCKPITCH:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
222 ADD_TO_OFFSET(lock_pitch, EDL_internal_parse_bool);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
223 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
224 case EDL_HEADER_FIRSTCHANNEL:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
225 ADD_TO_OFFSET(first_channel, EDL_internal_parse_int);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
226 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
227 case EDL_HEADER_CHANNELS:
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
228 ADD_TO_OFFSET(channels, EDL_internal_parse_int);
3
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 default:
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
231 /* ... what */
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
232 break;
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
233 #undef ADD_TO_OFFSET
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
234 }
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
235 }
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
236
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
237 if (!ok)
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
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
240 if (++edl->size >= edl->capacity)
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
241 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
242 }
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
243
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
244 /* put on the shrinkwrap */
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
245 EDL_reallocate(edl, edl->size);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
246
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
247 free(order);
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
248
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
249 return EDL_PARSE_ERROR_SUCCESS;
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
250 }
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
251
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
252 static void EDL_dump_line(EDL_internal_string* str, const EDL_line* line, const uint32_t* order, const size_t order_len) {
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
253 size_t i;
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
254
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
255 for (i = 0; i < order_len; i++) {
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
256 switch (order[i]) {
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
257 #define APPEND_ITEM(a, x) \
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
258 { \
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
259 char* tstr = x(line->a); \
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
260 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
261 free(tstr); \
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
262 }
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
263 case EDL_HEADER_ID:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
264 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
265 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
266 case EDL_HEADER_TRACK:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
267 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
268 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
269 case EDL_HEADER_STARTTIME:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
270 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
271 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
272 case EDL_HEADER_LENGTH:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
273 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
274 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
275 case EDL_HEADER_PLAYRATE:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
276 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
277 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
278 case EDL_HEADER_LOCKED:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
279 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
280 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
281 case EDL_HEADER_NORMALIZED:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
282 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
283 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
284 case EDL_HEADER_STRETCHMETHOD:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
285 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
286 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
287 case EDL_HEADER_LOOPED:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
288 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
289 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
290 case EDL_HEADER_ONRULER:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
291 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
292 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
293 case EDL_HEADER_MEDIATYPE:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
294 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
295 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
296 case EDL_HEADER_FILENAME:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
297 EDL_internal_string_append(str, "\"", 1);
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
298 EDL_internal_string_append(str, line->filename, strlen(line->filename));
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
299 EDL_internal_string_append(str, "\"", 1);
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
300 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
301 case EDL_HEADER_STREAM:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
302 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
303 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
304 case EDL_HEADER_STREAMSTART:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
305 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
306 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
307 case EDL_HEADER_STREAMLENGTH:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
308 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
309 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
310 case EDL_HEADER_FADETIMEIN:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
311 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
312 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
313 case EDL_HEADER_FADETIMEOUT:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
314 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
315 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
316 case EDL_HEADER_SUSTAINGAIN:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
317 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
318 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
319 case EDL_HEADER_CURVEIN:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
320 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
321 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
322 case EDL_HEADER_GAININ:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
323 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
324 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
325 case EDL_HEADER_CURVEOUT:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
326 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
327 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
328 case EDL_HEADER_GAINOUT:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
329 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
330 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
331 case EDL_HEADER_LAYER:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
332 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
333 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
334 case EDL_HEADER_COLOR:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
335 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
336 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
337 case EDL_HEADER_CURVEINR:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
338 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
339 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
340 case EDL_HEADER_CURVEOUTR:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
341 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
342 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
343 case EDL_HEADER_PLAYPITCH:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
344 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
345 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
346 case EDL_HEADER_LOCKPITCH:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
347 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
348 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
349 case EDL_HEADER_FIRSTCHANNEL:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
350 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
351 break;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
352 case EDL_HEADER_CHANNELS:
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
353 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
354 break;
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
355 default:
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
356 /* ... what */
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
357 break;
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
358 #undef APPEND_ITEM
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
359 }
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
360
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
361 if (i < order_len - 1)
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
362 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
363 else
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
364 EDL_internal_string_append(str, ";", 1);
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
365 }
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
366
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
367 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
368 }
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
369
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
370 /* this gets progressively slower and slower... oops */
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
371 char* EDL_dump(const EDL* edl) {
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
372 static const char order_str[] =
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
373 "\"ID\";\"Track\";\"StartTime\";\"Length\";\"PlayRate\";\"Locked\";\"Normalized\";\"StretchMethod\";"
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
374 "\"Looped\";\"OnRuler\";\"MediaType\";\"FileName\";\"Stream\";\"StreamStart\";\"StreamLength\";"
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
375 "\"FadeTimeIn\";\"FadeTimeOut\";\"SustainGain\";\"CurveIn\";\"GainIn\";\"CurveOut\";\"GainOut\";"
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
376 "\"Layer\";\"Color\";\"CurveInR\";\"CurveOutR\":\"PlayPitch\";\"LockPitch\";\"FirstChannel\";\"Channels\"\n";
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
377
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
378 EDL_internal_string ret;
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
379 EDL_internal_string_init(&ret);
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
380
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
381 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
382
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
383 {
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
384 size_t order_len;
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
385 uint32_t* order = EDL_internal_parse_header(order_str, &order_len);
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
386
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
387 size_t i;
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
388 for (i = 0; i < edl->size; i++)
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
389 EDL_dump_line(&ret, &edl->arr[i], order, order_len);
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
390
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
391 free(order);
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
392 }
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
393
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
394 return ret.data;
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
395 }
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
396
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
397 void EDL_free(EDL* edl) {
4
c2408abb258a *: add dumping to string, rename EDL_file to EDL
Paper <mrpapersonic@gmail.com>
parents: 3
diff changeset
398 size_t i;
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
399 for (i = 0; i < edl->size; i++) {
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
400 if (edl->arr[i].filename)
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
401 free(edl->arr[i].filename);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
402 }
8
0c98b46eaf73 *: update API to 2.0, big changes
Paper <paper@paper.us.eu.org>
parents: 6
diff changeset
403 free(edl->arr);
3
bd99b6549eb4 *: expand in readme and rename src/main to src/edl
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
404 }