Lines Matching refs:glob
18 void Ebml_Write(struct EbmlGlobal *glob,
21 (void) fwrite(buffer_in, 1, len, glob->stream);
27 Ebml_Write(glob, &x, 1); \
30 void Ebml_Serialize(struct EbmlGlobal *glob,
65 static void Ebml_SerializeUnsigned32(struct EbmlGlobal *glob,
69 Ebml_WriteID(glob, class_id);
70 Ebml_Serialize(glob, &sizeSerialized, sizeof(sizeSerialized), 1);
71 Ebml_Serialize(glob, &ui, sizeof(ui), 4);
74 static void Ebml_StartSubElement(struct EbmlGlobal *glob,
78 Ebml_WriteID(glob, class_id);
79 *ebmlLoc = ftello(glob->stream);
80 Ebml_Serialize(glob, &kEbmlUnknownLength, sizeof(kEbmlUnknownLength), 8);
83 static void Ebml_EndSubElement(struct EbmlGlobal *glob, EbmlLoc *ebmlLoc) {
88 pos = ftello(glob->stream);
95 fseeko(glob->stream, *ebmlLoc, SEEK_SET);
96 Ebml_Serialize(glob, &size, sizeof(size), 8);
99 fseeko(glob->stream, pos, SEEK_SET);
156 void write_webm_file_header(struct EbmlGlobal *glob,
170 Ebml_StartSubElement(glob, &start, EBML);
171 Ebml_SerializeUnsigned(glob, EBMLVersion, 1);
172 Ebml_SerializeUnsigned(glob, EBMLReadVersion, 1);
173 Ebml_SerializeUnsigned(glob, EBMLMaxIDLength, 4);
174 Ebml_SerializeUnsigned(glob, EBMLMaxSizeLength, 8);
175 Ebml_SerializeString(glob, DocType, "webm");
176 Ebml_SerializeUnsigned(glob, DocTypeVersion, 2);
177 Ebml_SerializeUnsigned(glob, DocTypeReadVersion, 2);
178 Ebml_EndSubElement(glob, &start);
181 Ebml_StartSubElement(glob, &glob->startSegment, Segment);
182 glob->position_reference = ftello(glob->stream);
183 glob->framerate = *fps;
184 write_webm_seek_info(glob);
187 glob->track_pos = ftello(glob->stream);
188 Ebml_StartSubElement(glob, &trackStart, Tracks);
191 Ebml_StartSubElement(glob, &start, TrackEntry);
192 Ebml_SerializeUnsigned(glob, TrackNumber, trackNumber);
193 glob->track_id_pos = ftello(glob->stream);
194 Ebml_SerializeUnsigned32(glob, TrackUID, trackID);
195 Ebml_SerializeUnsigned(glob, TrackType, 1);
196 Ebml_SerializeString(glob, CodecID,
198 Ebml_StartSubElement(glob, &videoStart, Video);
199 Ebml_SerializeUnsigned(glob, PixelWidth, pixelWidth);
200 Ebml_SerializeUnsigned(glob, PixelHeight, pixelHeight);
201 Ebml_SerializeUnsigned(glob, StereoMode, stereo_fmt);
202 Ebml_EndSubElement(glob, &videoStart);
205 Ebml_EndSubElement(glob, &start);
208 Ebml_EndSubElement(glob, &trackStart);
213 void write_webm_block(struct EbmlGlobal *glob,
227 if (pts_ms <= glob->last_pts_ms)
228 pts_ms = glob->last_pts_ms + 1;
230 glob->last_pts_ms = pts_ms;
233 if (pts_ms - glob->cluster_timecode > SHRT_MAX)
236 block_timecode = (uint16_t)pts_ms - glob->cluster_timecode;
240 if (glob->cluster_open)
241 Ebml_EndSubElement(glob, &glob->startCluster);
245 glob->cluster_open = 1;
246 glob->cluster_timecode = (uint32_t)pts_ms;
247 glob->cluster_pos = ftello(glob->stream);
248 Ebml_StartSubElement(glob, &glob->startCluster, Cluster);
249 Ebml_SerializeUnsigned(glob, Timecode, glob->cluster_timecode);
255 new_cue_list = realloc(glob->cue_list,
256 (glob->cues + 1) * sizeof(struct cue_entry));
258 glob->cue_list = new_cue_list;
262 cue = &glob->cue_list[glob->cues];
263 cue->time = glob->cluster_timecode;
264 cue->loc = glob->cluster_pos;
265 glob->cues++;
270 Ebml_WriteID(glob, SimpleBlock);
274 Ebml_Serialize(glob, &block_length, sizeof(block_length), 4);
278 Ebml_Write(glob, &track_number, 1);
280 Ebml_Serialize(glob, &block_timecode, sizeof(block_timecode), 2);
287 Ebml_Write(glob, &flags, 1);
289 Ebml_Write(glob, pkt->data.frame.buf, (unsigned int)pkt->data.frame.sz);
292 void write_webm_file_footer(struct EbmlGlobal *glob, int hash) {
298 if (glob->cluster_open)
299 Ebml_EndSubElement(glob, &glob->startCluster);
301 glob->cue_pos = ftello(glob->stream);
302 Ebml_StartSubElement(glob, &start_cues, Cues);
304 for (i = 0; i < glob->cues; i++) {
305 struct cue_entry *cue = &glob->cue_list[i];
306 Ebml_StartSubElement(glob, &start_cue_point, CuePoint);
307 Ebml_SerializeUnsigned(glob, CueTime, cue->time);
309 Ebml_StartSubElement(glob, &start_cue_tracks, CueTrackPositions);
310 Ebml_SerializeUnsigned(glob, CueTrack, 1);
311 Ebml_SerializeUnsigned64(glob, CueClusterPosition,
312 cue->loc - glob->position_reference);
313 Ebml_EndSubElement(glob, &start_cue_tracks);
315 Ebml_EndSubElement(glob, &start_cue_point);
318 Ebml_EndSubElement(glob, &start_cues);
321 Ebml_EndSubElement(glob, &glob->startSegment);
324 write_webm_seek_info(glob);
327 fseeko(glob->stream, glob->track_id_pos, SEEK_SET);
328 Ebml_SerializeUnsigned32(glob, TrackUID, glob->debug ? 0xDEADBEEF : hash);
330 fseeko(glob->stream, 0, SEEK_END);