Skip to content

Commit dc26385

Browse files
committed
Additional format_ebml.c comments.
1 parent af238d9 commit dc26385

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

src/format_ebml.c

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,17 @@
3636

3737
#include "logging.h"
3838

39+
/* The size of the header buffer; should be large enough to contain
40+
* everything before the first Cluster in a reasonable stream
41+
*/
3942
#define EBML_HEADER_MAX_SIZE 131072
43+
44+
/* The size of the input/staging buffers; this much of a cluster
45+
* will be buffered before being returned. Should be large enough
46+
* that the first video block will be encountered before it is full,
47+
* to allow probing for the keyframe flag while we still have the
48+
* option to mark the cluster as a sync point.
49+
*/
4050
#define EBML_SLICE_SIZE 4096
4151

4252
/* A value that no EBML var-int is allowed to take. */
@@ -63,28 +73,55 @@
6373
#define TRACK_TYPE_MAGIC "\x83"
6474
#define SIMPLE_BLOCK_MAGIC "\xA3"
6575

76+
/* If support for Tags gets added, it may make sense
77+
* to convert this into a pair of flags signaling
78+
* "new headers" and "new tags"
79+
*/
6680
typedef enum ebml_read_mode {
81+
/* The header buffer has not been extracted yet */
6782
EBML_STATE_READING_HEADER = 0,
83+
/* The header buffer has been read, begin normal operation */
6884
EBML_STATE_READING_CLUSTERS
6985
} ebml_read_mode;
7086

7187
typedef enum ebml_parsing_state {
88+
/* Examine EBML elements, output to header buffer */
7289
EBML_STATE_PARSING_HEADER = 0,
90+
91+
/* Blindly copy a specified number of bytes to the header buffer */
7392
EBML_STATE_COPYING_TO_HEADER,
93+
94+
/* Finalize header buffer and wait for previous cluster to flush (as necessary) */
7495
EBML_STATE_START_CLUSTER,
96+
97+
/* Examine EBML elements, output to data buffer */
7598
EBML_STATE_PARSING_CLUSTERS,
99+
100+
/* Blindly copy a specified number of bytes to the data buffer */
76101
EBML_STATE_COPYING_TO_DATA
77102
} ebml_parsing_state;
78103

79104
typedef enum ebml_chunk_type {
105+
/* This chunk is the header buffer */
80106
EBML_CHUNK_HEADER = 0,
107+
108+
/* This chunk starts a cluster that works as a sync point */
81109
EBML_CHUNK_CLUSTER_START,
110+
111+
/* This chunk continues the previous cluster, or
112+
* else starts a non-sync-point cluster
113+
*/
82114
EBML_CHUNK_CLUSTER_CONTINUE
83115
} ebml_chunk_type;
84116

85117
typedef enum ebml_keyframe_status {
118+
/* Have not found a video track block yet */
86119
EBML_KEYFRAME_UNKNOWN = -1,
120+
121+
/* Found the first video track block, it was not a keyframe */
87122
EBML_KEYFRAME_DOES_NOT_START_CLUSTER = 0,
123+
124+
/* Found the first video track block, it was a keyframe */
88125
EBML_KEYFRAME_STARTS_CLUSTER = 1
89126
} ebml_keyframe_status;
90127

@@ -695,9 +732,8 @@ static int ebml_wrote(ebml_t *ebml, int len)
695732
}
696733
}
697734

698-
/* Copy any data we don't need to probe any more */
699735
if (processing) {
700-
/* Non-cluster tag, copy it & children into buffer */
736+
/* Moving to next element, copy current to buffer */
701737
ebml->copy_len = tag_length + payload_length;
702738
ebml->parse_state = copy_state;
703739
}

0 commit comments

Comments
 (0)