From 65fe93fb5739a6035ee8e7a861b7a34c4ca8e764 Mon Sep 17 00:00:00 2001 From: Matt Mascarenhas Date: Sun, 30 May 2021 18:42:02 +0100 Subject: [PATCH] hmmlib2 2.0.10: Rename annotation to timestamp --- hmmlib2/hmmlib.h | 64 ++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/hmmlib2/hmmlib.h b/hmmlib2/hmmlib.h index f4a66b4..e3381b3 100644 --- a/hmmlib2/hmmlib.h +++ b/hmmlib2/hmmlib.h @@ -86,7 +86,7 @@ typedef struct { size_t marker_count; HMML_Quote quote; -} HMML_Annotation; +} HMML_Timestamp; typedef struct { int line; @@ -97,8 +97,8 @@ typedef struct { typedef struct { _Bool well_formed; HMML_VideoMetaData metadata; - HMML_Annotation* annotations; - size_t annotation_count; + HMML_Timestamp* timestamps; + size_t timestamp_count; HMML_Error error; void* free_list; // implementation detail } HMML_Output; @@ -467,7 +467,7 @@ next_attr: return ref; } -static void _hmml_parse_timecode(struct _hmml_parser* p, HMML_Annotation* anno) +static void _hmml_parse_timecode(struct _hmml_parser* p, HMML_Timestamp* ts) { unsigned int h = 0, m = 0, s = 0; int offset = 0; @@ -507,16 +507,16 @@ static void _hmml_parse_timecode(struct _hmml_parser* p, HMML_Annotation* anno) _hmml_err(p, "Minutes cannot exceed 59"); } - anno->h = h; - anno->m = m; - anno->s = s; + ts->h = h; + ts->m = m; + ts->s = s; } -static void _hmml_store_marker(struct _hmml_parser* p, HMML_Annotation* anno, char** out, char* text_mem, size_t text_mem_size) +static void _hmml_store_marker(struct _hmml_parser* p, HMML_Timestamp* ts, char** out, char* text_mem, size_t text_mem_size) { HMML_Marker m = _hmml_parse_marker(p); m.offset = (*out) - text_mem; - _hmml_persist_array(p, &anno->markers, &anno->marker_count, m); + _hmml_persist_array(p, &ts->markers, &ts->marker_count, m); const char* marker_text = m.parameter ? m.parameter @@ -531,7 +531,7 @@ static void _hmml_store_marker(struct _hmml_parser* p, HMML_Annotation* anno, ch *out += text_len; } -static size_t _hmml_parse_text(struct _hmml_parser* p, HMML_Annotation* anno) +static size_t _hmml_parse_text(struct _hmml_parser* p, HMML_Timestamp* ts) { static char text_mem[4096]; char* out = text_mem; @@ -579,9 +579,9 @@ static size_t _hmml_parse_text(struct _hmml_parser* p, HMML_Annotation* anno) p->cursor += 4; HMML_Reference ref = _hmml_parse_ref(p); ref.offset = out - text_mem; - _hmml_persist_array(p, &anno->references, &anno->reference_count, ref); + _hmml_persist_array(p, &ts->references, &ts->reference_count, ref); } else { - _hmml_store_marker(p, anno, &out, text_mem, sizeof(text_mem)); + _hmml_store_marker(p, ts, &out, text_mem, sizeof(text_mem)); } } @@ -593,7 +593,7 @@ static size_t _hmml_parse_text(struct _hmml_parser* p, HMML_Annotation* anno) *out++ = c; ++p->cursor; } else { - _hmml_store_marker(p, anno, &out, text_mem, sizeof(text_mem)); + _hmml_store_marker(p, ts, &out, text_mem, sizeof(text_mem)); } } @@ -609,24 +609,24 @@ static size_t _hmml_parse_text(struct _hmml_parser* p, HMML_Annotation* anno) } size_t text_size = out - text_mem; - anno->text = _hmml_persist_str(p, (struct _hmml_str){ text_mem, text_size }); + ts->text = _hmml_persist_str(p, (struct _hmml_str){ text_mem, text_size }); return text_size; } -static void _hmml_parse_quote(struct _hmml_parser* p, HMML_Annotation* anno) +static void _hmml_parse_quote(struct _hmml_parser* p, HMML_Timestamp* ts) { char member[256]; int id; int off = 0; if(sscanf(p->cursor, "[quote %255s %d]%n", member, &id, &off) == 2 && off) { - anno->quote.present = 1; - anno->quote.id = id; - anno->quote.author = _hmml_persist_str(p, (struct _hmml_str){ member, strlen(member) }); + ts->quote.present = 1; + ts->quote.id = id; + ts->quote.author = _hmml_persist_str(p, (struct _hmml_str){ member, strlen(member) }); } else if(sscanf(p->cursor, "[quote %d]%n", &id, &off) == 1 && off) { - anno->quote.present = 1; - anno->quote.id = id; + ts->quote.present = 1; + ts->quote.id = id; } else { _hmml_err(p, "Unable to parse quote"); } @@ -634,7 +634,7 @@ static void _hmml_parse_quote(struct _hmml_parser* p, HMML_Annotation* anno) p->cursor += off; } -static void _hmml_parse_annotations(struct _hmml_parser* p) +static void _hmml_parse_timestamps(struct _hmml_parser* p) { for(;;) { _hmml_skip_ws(p); @@ -647,11 +647,11 @@ static void _hmml_parse_annotations(struct _hmml_parser* p) break; } - HMML_Annotation anno = { + HMML_Timestamp ts = { .line = p->line }; - _hmml_parse_timecode(p, &anno); + _hmml_parse_timecode(p, &ts); if(*p->cursor != '[') { _hmml_err(p, "Expected '['"); @@ -659,18 +659,18 @@ static void _hmml_parse_annotations(struct _hmml_parser* p) if(p->cursor[1] == '@') { HMML_Marker m = _hmml_parse_marker(p); - anno.author = m.marker; + ts.author = m.marker; } ++p->cursor; - int text_len = _hmml_parse_text(p, &anno); + int text_len = _hmml_parse_text(p, &ts); if(p->cursor[0] == '[' && p->cursor[1] == ':') { ++p->cursor; do { HMML_Marker m = _hmml_parse_marker(p); - _hmml_persist_array(p, &anno.markers, &anno.marker_count, m); + _hmml_persist_array(p, &ts.markers, &ts.marker_count, m); _hmml_skip_ws(p); if(*p->cursor != ':' && *p->cursor != ']') { _hmml_err(p, "Unterminated post-text category node"); @@ -680,12 +680,12 @@ static void _hmml_parse_annotations(struct _hmml_parser* p) } if(p->cursor[0] == '[' && p->cursor[1] == 'q') { - _hmml_parse_quote(p, &anno); + _hmml_parse_quote(p, &ts); } // convert all markers to lowercase, fix any out of range offsets - for(size_t i = 0; i < anno.marker_count; ++i) { - HMML_Marker* m = anno.markers + i; + for(size_t i = 0; i < ts.marker_count; ++i) { + HMML_Marker* m = ts.markers + i; for(char* c = m->marker; *c; ++c) { if(*c >= 'A' && *c <= 'Z') { *c = (*c - ('A' - 'a')); @@ -696,7 +696,7 @@ static void _hmml_parse_annotations(struct _hmml_parser* p) } } - _hmml_persist_array(p, &p->out.annotations, &p->out.annotation_count, anno); + _hmml_persist_array(p, &p->out.timestamps, &p->out.timestamp_count, ts); } } @@ -736,7 +736,7 @@ next_attr: if(*p->cursor == ']') { ++p->cursor; - _hmml_parse_annotations(p); + _hmml_parse_timestamps(p); return; } @@ -813,7 +813,7 @@ void hmml_free(HMML_Output* out) } const struct HMML_Version hmml_version = { - 2, 0, 9 + 2, 0, 10 }; #undef HSTX