Changeset 45922 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- May 6, 2013 7:11:54 PM (12 years ago)
- Location:
- trunk/src/VBox/Main/src-client
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/EbmlWriter.cpp
r45914 r45922 28 28 29 29 #include "EbmlWriter.h" 30 #include <iprt/asm.h> 30 31 #include <iprt/mem.h> 31 32 #include <iprt/string.h> 32 33 #include <VBox/log.h> 33 34 34 35 int Ebml_Write(EbmlGlobal *glob, const void *buffer_in, uint64_t len) 36 { 37 return RTFileWrite(glob->file, buffer_in, len, NULL); 38 } 39 40 int Ebml_Serialize(EbmlGlobal *glob, const void *buffer_in, uint64_t len) 41 { 42 const unsigned char *q = (const unsigned char *)buffer_in + len - 1; 43 44 for (; len; len--) 45 { 46 int rc = Ebml_Write(glob, q--, 1); 35 static int ebml_Write(EbmlGlobal *glob, const void *pv, size_t cb) 36 { 37 return RTFileWrite(glob->file, pv, cb, NULL); 38 } 39 40 static int ebml_WriteU8(EbmlGlobal *glob, uint8_t u8) 41 { 42 return ebml_Write(glob, &u8, 1); 43 } 44 45 static int ebml_WriteU16(EbmlGlobal *glob, uint16_t u16) 46 { 47 return ebml_Write(glob, &u16, 2); 48 } 49 50 static int ebml_WriteU32(EbmlGlobal *glob, uint32_t u32) 51 { 52 return ebml_Write(glob, &u32, 4); 53 } 54 55 static int ebml_WriteU64(EbmlGlobal *glob, uint64_t u64) 56 { 57 return ebml_Write(glob, &u64, 8); 58 } 59 60 static int ebml_Serialize(EbmlGlobal *glob, const uint8_t *pb, size_t cb) 61 { 62 for (; cb; cb--) 63 { 64 int rc = ebml_WriteU8(glob, pb[cb-1]); 47 65 if (RT_FAILURE(rc)) 48 66 return rc; … … 51 69 } 52 70 53 int Ebml_SerializeUnsigned32(EbmlGlobal *glob, uint32_t class_id, uint64_t ui) 54 { 55 unsigned char sizeSerialized = 4 | 0x80; 56 int rc = Ebml_WriteID(glob, class_id); 57 rc = Ebml_Serialize(glob, &sizeSerialized, 1); 58 if (RT_SUCCESS(rc)) 59 rc = Ebml_Serialize(glob, &ui, 4); 60 return rc; 61 } 62 63 int Ebml_StartSubElement(EbmlGlobal *glob, uint64_t *ebmlLoc, uint32_t class_id) 71 static int ebml_WriteID(EbmlGlobal *glob, uint32_t class_id) 72 { 73 int rc; 74 if (class_id >= 0x01000000) 75 rc = ebml_WriteU32(glob, RT_H2BE_U32(class_id)); 76 else if (class_id >= 0x00010000) 77 rc = ebml_Serialize(glob, (uint8_t*)&class_id, 3); 78 else if (class_id >= 0x00000100) 79 rc = ebml_WriteU16(glob, RT_H2BE_U16((uint16_t)class_id)); 80 else 81 rc = ebml_WriteU8(glob, (uint8_t)class_id); 82 return rc; 83 } 84 85 static int ebml_SerializeUnsigned32(EbmlGlobal *glob, uint32_t class_id, uint32_t ui) 86 { 87 int rc = ebml_WriteID(glob, class_id); 88 rc = ebml_WriteU8(glob, 4 | 0x80); 89 if (RT_SUCCESS(rc)) 90 rc = ebml_WriteU32(glob, RT_H2BE_U32(ui)); 91 return rc; 92 } 93 94 static int ebml_StartSubElement(EbmlGlobal *glob, uint64_t *ebmlLoc, uint32_t class_id) 64 95 { 65 96 // todo this is always taking 8 bytes, this may need later optimization … … 67 98 uint64_t unknownLen = UINT64_C(0x01FFFFFFFFFFFFFF); 68 99 69 Ebml_WriteID(glob, class_id);100 ebml_WriteID(glob, class_id); 70 101 *ebmlLoc = RTFileTell(glob->file); 71 return Ebml_Serialize(glob, &unknownLen, 8);72 } 73 74 int Ebml_EndSubElement(EbmlGlobal *glob, uint64_t *ebmlLoc)102 return ebml_WriteU64(glob, RT_H2BE_U64(unknownLen)); 103 } 104 105 static int ebml_EndSubElement(EbmlGlobal *glob, uint64_t ebmlLoc) 75 106 { 76 107 /* Save the current file pointer */ … … 78 109 79 110 /* Calculate the size of this element */ 80 uint64_t size = pos - *ebmlLoc - 8;111 uint64_t size = pos - ebmlLoc - 8; 81 112 size |= UINT64_C(0x0100000000000000); 82 113 83 114 /* Seek back to the beginning of the element and write the new size */ 84 RTFileSeek(glob->file, *ebmlLoc, RTFILE_SEEK_BEGIN, NULL);85 int rc = Ebml_Serialize(glob, &size, 8);115 RTFileSeek(glob->file, ebmlLoc, RTFILE_SEEK_BEGIN, NULL); 116 int rc = ebml_WriteU64(glob, RT_H2BE_U64(size)); 86 117 87 118 /* Reset the file pointer */ … … 91 122 } 92 123 93 int Ebml_WriteLen(EbmlGlobal *glob, uint64_t val)124 static int ebml_WriteLen(EbmlGlobal *glob, uint64_t val) 94 125 { 95 126 //TODO check and make sure we are not > than 0x0100000000000000LLU 96 unsigned char size = 8; //size in bytes to output127 size_t size = 8; 97 128 uint64_t minVal = UINT64_C(0x00000000000000ff); //mask to compare for byte size 98 129 … … 107 138 val |= (UINT64_C(0x000000000000080) << ((size - 1) * 7)); 108 139 109 return Ebml_Serialize(glob, (void *) &val, size); 110 } 111 112 int Ebml_WriteString(EbmlGlobal *glob, const char *str) 113 { 114 const size_t size_ = strlen(str); 115 const uint64_t size = size_; 116 int rc = Ebml_WriteLen(glob, size); 140 return ebml_Serialize(glob, (uint8_t *)&val, size); 141 } 142 143 static int ebml_WriteString(EbmlGlobal *glob, const char *str) 144 { 145 const size_t cb = strlen(str); 146 int rc = ebml_WriteLen(glob, cb); 117 147 //TODO: it's not clear from the spec whether the nul terminator 118 148 //should be serialized too. For now we omit the null terminator. 119 149 if (RT_SUCCESS(rc)) 120 rc = Ebml_Write(glob, str, size); 121 return rc; 122 } 123 124 int Ebml_WriteID(EbmlGlobal *glob, uint32_t class_id) 125 { 126 int rc; 127 if (class_id >= 0x01000000) 128 rc = Ebml_Serialize(glob, (void *)&class_id, 4); 129 else if (class_id >= 0x00010000) 130 rc = Ebml_Serialize(glob, (void *)&class_id, 3); 131 else if (class_id >= 0x00000100) 132 rc = Ebml_Serialize(glob, (void *)&class_id, 2); 133 else 134 rc = Ebml_Serialize(glob, (void *)&class_id, 1); 135 return rc; 136 } 150 rc = ebml_Write(glob, str, cb); 151 return rc; 152 } 153 137 154 int Ebml_SerializeUnsigned64(EbmlGlobal *glob, uint32_t class_id, uint64_t ui) 138 155 { 139 unsigned char sizeSerialized = 8 | 0x80; 140 int rc = Ebml_WriteID(glob, class_id); 141 if (RT_SUCCESS(rc)) 142 rc = Ebml_Serialize(glob, &sizeSerialized, 1); 143 if (RT_SUCCESS(rc)) 144 rc = Ebml_Serialize(glob, &ui, 8); 156 int rc = ebml_WriteID(glob, class_id); 157 if (RT_SUCCESS(rc)) 158 rc = ebml_WriteU8(glob, 8 | 0x80); 159 if (RT_SUCCESS(rc)) 160 rc = ebml_WriteU64(glob, RT_H2BE_U64(ui)); 145 161 return rc; 146 162 } … … 148 164 int Ebml_SerializeUnsigned(EbmlGlobal *glob, uint32_t class_id, uint32_t ui) 149 165 { 150 unsigned char size = 8; //size in bytes to output 151 unsigned char sizeSerialized = 0; 152 uint32_t minVal; 153 154 int rc = Ebml_WriteID(glob, class_id); 166 int rc = ebml_WriteID(glob, class_id); 155 167 if (RT_FAILURE(rc)) 156 168 return rc; 157 minVal = 0x7fLU; //mask to compare for byte size 158 169 170 uint32_t minVal = 0x7fLU; //mask to compare for byte size 171 size_t size = 8; //size in bytes to output 159 172 for (size = 1; size < 4; size ++) 160 173 { … … 165 178 } 166 179 167 sizeSerialized = 0x80 | size; 168 rc = Ebml_Serialize(glob, &sizeSerialized, 1); 169 if (RT_SUCCESS(rc)) 170 rc = Ebml_Serialize(glob, &ui, size); 180 rc = ebml_WriteU8(glob, 0x80 | size); 181 if (RT_SUCCESS(rc)) 182 rc = ebml_Serialize(glob, (uint8_t*)&ui, size); 171 183 return rc; 172 184 } … … 181 193 break; 182 194 } 183 int rc = Ebml_WriteID(glob, class_id);184 if (RT_SUCCESS(rc)) 185 rc = Ebml_WriteLen(glob, size);186 if (RT_SUCCESS(rc)) 187 rc = Ebml_WriteID(glob, bin);195 int rc = ebml_WriteID(glob, class_id); 196 if (RT_SUCCESS(rc)) 197 rc = ebml_WriteLen(glob, size); 198 if (RT_SUCCESS(rc)) 199 rc = ebml_WriteID(glob, bin); 188 200 return rc; 189 201 } … … 191 203 int Ebml_SerializeFloat(EbmlGlobal *glob, uint32_t class_id, double d) 192 204 { 193 unsigned char len = 0x88; 194 195 int rc = Ebml_WriteID(glob, class_id); 196 if (RT_SUCCESS(rc)) 197 rc = Ebml_Serialize(glob, &len, 1); 198 if (RT_SUCCESS(rc)) 199 rc = Ebml_Serialize(glob, &d, 8); 205 int rc = ebml_WriteID(glob, class_id); 206 if (RT_SUCCESS(rc)) 207 rc = ebml_WriteU8(glob, 0x80 | 8); 208 if (RT_SUCCESS(rc)) 209 rc = ebml_WriteU64(glob, RT_H2BE_U64(*(uint64_t*)&d)); 200 210 return rc; 201 211 } … … 203 213 int Ebml_SerializeString(EbmlGlobal *glob, uint32_t class_id, const char *s) 204 214 { 205 int rc = Ebml_WriteID(glob, class_id);206 if (RT_SUCCESS(rc)) 207 rc = Ebml_WriteString(glob, s);215 int rc = ebml_WriteID(glob, class_id); 216 if (RT_SUCCESS(rc)) 217 rc = ebml_WriteString(glob, s); 208 218 return rc; 209 219 } … … 213 223 uint64_t offset = pos - ebml->position_reference; 214 224 uint64_t start; 215 int rc = Ebml_StartSubElement(ebml, &start, Seek);225 int rc = ebml_StartSubElement(ebml, &start, Seek); 216 226 if (RT_SUCCESS(rc)) 217 227 rc = Ebml_SerializeBinary(ebml, SeekID, id); … … 219 229 rc = Ebml_SerializeUnsigned64(ebml, SeekPosition, offset); 220 230 if (RT_SUCCESS(rc)) 221 rc = Ebml_EndSubElement(ebml, &start);231 rc = ebml_EndSubElement(ebml, start); 222 232 return rc; 223 233 } … … 225 235 int Ebml_WriteWebMSeekInfo(EbmlGlobal *ebml) 226 236 { 227 uint64_t pos;228 237 int rc = VINF_SUCCESS; 229 238 230 239 /* Save the current file pointer */ 231 pos = RTFileTell(ebml->file);240 uint64_t pos = RTFileTell(ebml->file); 232 241 233 242 if (ebml->seek_info_pos) … … 240 249 241 250 if (RT_SUCCESS(rc)) 242 rc = Ebml_StartSubElement(ebml, &start, SeekHead);251 rc = ebml_StartSubElement(ebml, &start, SeekHead); 243 252 if (RT_SUCCESS(rc)) 244 253 rc = Ebml_WriteWebMSeekElement(ebml, Tracks, ebml->track_pos); 245 254 if (RT_SUCCESS(rc)) 246 rc = Ebml_WriteWebMSeekElement(ebml, Cues, 247 if (RT_SUCCESS(rc)) 248 rc = Ebml_WriteWebMSeekElement(ebml, Info, 249 if (RT_SUCCESS(rc)) 250 rc = Ebml_EndSubElement(ebml, &start);255 rc = Ebml_WriteWebMSeekElement(ebml, Cues, ebml->cue_pos); 256 if (RT_SUCCESS(rc)) 257 rc = Ebml_WriteWebMSeekElement(ebml, Info, ebml->segment_info_pos); 258 if (RT_SUCCESS(rc)) 259 rc = ebml_EndSubElement(ebml, start); 251 260 } 252 261 { … … 255 264 uint64_t frame_time; 256 265 257 frame_time = (uint64_t)1000 * ebml->framerate.den 258 / ebml->framerate.num; 266 frame_time = (uint64_t)1000 * ebml->framerate.den / ebml->framerate.num; 259 267 ebml->segment_info_pos = RTFileTell(ebml->file); 260 268 if (RT_SUCCESS(rc)) 261 rc = Ebml_StartSubElement(ebml, &startInfo, Info);269 rc = ebml_StartSubElement(ebml, &startInfo, Info); 262 270 if (RT_SUCCESS(rc)) 263 271 rc = Ebml_SerializeUnsigned(ebml, TimecodeScale, 1000000); … … 269 277 ebml->debug ? vpx_codec_version_str() : ""); 270 278 if (RT_SUCCESS(rc)) 271 rc = Ebml_SerializeString(ebml, 0x4D80, szVersion);272 if (RT_SUCCESS(rc)) 273 rc = Ebml_SerializeString(ebml, 0x5741, szVersion);274 if (RT_SUCCESS(rc)) 275 rc = Ebml_EndSubElement(ebml, &startInfo);279 rc = Ebml_SerializeString(ebml, MuxingApp, szVersion); 280 if (RT_SUCCESS(rc)) 281 rc = Ebml_SerializeString(ebml, WritingApp, szVersion); 282 if (RT_SUCCESS(rc)) 283 rc = ebml_EndSubElement(ebml, startInfo); 276 284 } 277 285 return rc; … … 285 293 { 286 294 uint64_t start; 287 rc = Ebml_StartSubElement(glob, &start, EBML);295 rc = ebml_StartSubElement(glob, &start, EBML); 288 296 if (RT_SUCCESS(rc)) 289 297 rc = Ebml_SerializeUnsigned(glob, EBMLVersion, 1); 290 298 if (RT_SUCCESS(rc)) 291 rc = Ebml_SerializeUnsigned(glob, EBMLReadVersion, 1); //EBML Read Version292 if (RT_SUCCESS(rc)) 293 rc = Ebml_SerializeUnsigned(glob, EBMLMaxIDLength, 4); //EBML Max ID Length294 if (RT_SUCCESS(rc)) 295 rc = Ebml_SerializeUnsigned(glob, EBMLMaxSizeLength, 8); //EBML Max Size Length296 if (RT_SUCCESS(rc)) 297 rc = Ebml_SerializeString(glob, DocType, "webm"); //Doc Type298 if (RT_SUCCESS(rc)) 299 rc = Ebml_SerializeUnsigned(glob, DocTypeVersion, 2); //Doc Type Version300 if (RT_SUCCESS(rc)) 301 rc = Ebml_SerializeUnsigned(glob, DocTypeReadVersion, 2); //Doc Type Read Version302 if (RT_SUCCESS(rc)) 303 rc = Ebml_EndSubElement(glob, &start);304 } 305 { 306 if (RT_SUCCESS(rc)) 307 rc = Ebml_StartSubElement(glob, &glob->startSegment, Segment); //segment299 rc = Ebml_SerializeUnsigned(glob, EBMLReadVersion, 1); 300 if (RT_SUCCESS(rc)) 301 rc = Ebml_SerializeUnsigned(glob, EBMLMaxIDLength, 4); 302 if (RT_SUCCESS(rc)) 303 rc = Ebml_SerializeUnsigned(glob, EBMLMaxSizeLength, 8); 304 if (RT_SUCCESS(rc)) 305 rc = Ebml_SerializeString(glob, DocType, "webm"); 306 if (RT_SUCCESS(rc)) 307 rc = Ebml_SerializeUnsigned(glob, DocTypeVersion, 2); 308 if (RT_SUCCESS(rc)) 309 rc = Ebml_SerializeUnsigned(glob, DocTypeReadVersion, 2); 310 if (RT_SUCCESS(rc)) 311 rc = ebml_EndSubElement(glob, start); 312 } 313 { 314 if (RT_SUCCESS(rc)) 315 rc = ebml_StartSubElement(glob, &glob->startSegment, Segment); 308 316 glob->position_reference = RTFileTell(glob->file); 309 317 glob->framerate = *fps; … … 314 322 glob->track_pos = RTFileTell(glob->file); 315 323 if (RT_SUCCESS(rc)) 316 rc = Ebml_StartSubElement(glob, &trackStart, Tracks);324 rc = ebml_StartSubElement(glob, &trackStart, Tracks); 317 325 { 318 u nsigned int trackNumber = 1;319 uint 64_ttrackID = 0;326 uint32_t trackNumber = 1; 327 uint32_t trackID = 0; 320 328 321 329 uint64_t start; 322 330 if (RT_SUCCESS(rc)) 323 rc = Ebml_StartSubElement(glob, &start, TrackEntry);331 rc = ebml_StartSubElement(glob, &start, TrackEntry); 324 332 if (RT_SUCCESS(rc)) 325 333 rc = Ebml_SerializeUnsigned(glob, TrackNumber, trackNumber); 326 334 glob->track_id_pos = RTFileTell(glob->file); 327 Ebml_SerializeUnsigned32(glob, TrackUID, trackID);335 ebml_SerializeUnsigned32(glob, TrackUID, trackID); 328 336 Ebml_SerializeUnsigned(glob, TrackType, 1); //video is always 1 329 337 Ebml_SerializeString(glob, CodecID, "V_VP8"); 330 338 { 331 unsigned int pixelWidth = cfg->g_w;332 unsigned int pixelHeight = cfg->g_h;333 double frameRate = (double)fps->num/(double)fps->den;334 335 339 uint64_t videoStart; 336 340 if (RT_SUCCESS(rc)) 337 rc = Ebml_StartSubElement(glob, &videoStart, Video); 341 rc = ebml_StartSubElement(glob, &videoStart, Video); 342 uint32_t pixelWidth = cfg->g_w; 338 343 if (RT_SUCCESS(rc)) 339 344 rc = Ebml_SerializeUnsigned(glob, PixelWidth, pixelWidth); 345 uint32_t pixelHeight = cfg->g_h; 340 346 if (RT_SUCCESS(rc)) 341 347 rc = Ebml_SerializeUnsigned(glob, PixelHeight, pixelHeight); 348 double frameRate = (double)fps->num / (double)fps->den; 342 349 if (RT_SUCCESS(rc)) 343 350 rc = Ebml_SerializeFloat(glob, FrameRate, frameRate); 344 351 if (RT_SUCCESS(rc)) 345 rc = Ebml_EndSubElement(glob, &videoStart); //Video352 rc = ebml_EndSubElement(glob, videoStart); 346 353 } 347 354 if (RT_SUCCESS(rc)) 348 rc = Ebml_EndSubElement(glob, &start); //Track Entry355 rc = ebml_EndSubElement(glob, start); //Track Entry 349 356 } 350 357 if (RT_SUCCESS(rc)) 351 rc = Ebml_EndSubElement(glob, &trackStart);358 rc = ebml_EndSubElement(glob, trackStart); 352 359 } 353 360 // segment element is open … … 360 367 const vpx_codec_cx_pkt_t *pkt) 361 368 { 362 uint64_t block_length; 363 unsigned char track_number; 364 unsigned short block_timecode = 0; 365 unsigned char flags; 366 int64_t pts_ms; 367 int start_cluster = 0, is_keyframe; 368 int rc = VINF_SUCCESS; 369 uint16_t block_timecode = 0; 370 int64_t pts_ms; 371 int start_cluster = 0; 372 int rc = VINF_SUCCESS; 369 373 370 374 /* Calculate the PTS of this frame in milliseconds */ … … 379 383 start_cluster = 1; 380 384 else 381 block_timecode = (u nsigned short)(pts_ms - glob->cluster_timecode);382 383 i s_keyframe = (pkt->data.frame.flags & VPX_FRAME_IS_KEY);384 if (start_cluster || is_keyframe)385 block_timecode = (uint16_t)(pts_ms - glob->cluster_timecode); 386 387 int fKeyframe = (pkt->data.frame.flags & VPX_FRAME_IS_KEY); 388 if (start_cluster || fKeyframe) 385 389 { 386 390 if (glob->cluster_open) 387 rc = Ebml_EndSubElement(glob, &glob->startCluster);391 rc = ebml_EndSubElement(glob, glob->startCluster); 388 392 389 393 /* Open the new cluster */ … … 393 397 glob->cluster_pos = RTFileTell(glob->file); 394 398 if (RT_SUCCESS(rc)) 395 rc = Ebml_StartSubElement(glob, &glob->startCluster, Cluster); //cluster399 rc = ebml_StartSubElement(glob, &glob->startCluster, Cluster); //cluster 396 400 if (RT_SUCCESS(rc)) 397 401 rc = Ebml_SerializeUnsigned(glob, Timecode, glob->cluster_timecode); 398 402 399 403 /* Save a cue point if this is a keyframe. */ 400 if ( is_keyframe)404 if (fKeyframe) 401 405 { 402 406 struct cue_entry *cue; … … 412 416 /* Write the Simple Block */ 413 417 if (RT_SUCCESS(rc)) 414 rc = Ebml_WriteID(glob, SimpleBlock);415 416 block_length = pkt->data.frame.sz + 4;418 rc = ebml_WriteID(glob, SimpleBlock); 419 420 uint64_t block_length = pkt->data.frame.sz + 4; 417 421 block_length |= 0x10000000; 418 422 if (RT_SUCCESS(rc)) 419 rc = Ebml_Serialize(glob, &block_length, 4); 420 421 track_number = 1; 422 track_number |= 0x80; 423 if (RT_SUCCESS(rc)) 424 rc = Ebml_Write(glob, &track_number, 1); 425 426 if (RT_SUCCESS(rc)) 427 rc = Ebml_Serialize(glob, &block_timecode, 2); 428 429 flags = 0; 430 if (is_keyframe) 423 rc = ebml_WriteU32(glob, RT_H2BE_U32(block_length)); 424 425 uint8_t track_number = 0x80 | 1; 426 if (RT_SUCCESS(rc)) 427 rc = ebml_WriteU8(glob, track_number); 428 429 if (RT_SUCCESS(rc)) 430 rc = ebml_WriteU16(glob, RT_H2BE_U16(block_timecode)); 431 432 uint8_t flags = 0; 433 if (fKeyframe) 431 434 flags |= 0x80; 432 435 if (pkt->data.frame.flags & VPX_FRAME_IS_INVISIBLE) 433 436 flags |= 0x08; 434 437 if (RT_SUCCESS(rc)) 435 rc = Ebml_Write(glob, &flags, 1); 436 437 if (RT_SUCCESS(rc)) 438 rc = Ebml_Write(glob, pkt->data.frame.buf, pkt->data.frame.sz); 439 440 return rc; 441 } 442 438 rc = ebml_WriteU8(glob, flags); 439 440 if (RT_SUCCESS(rc)) 441 rc = ebml_Write(glob, pkt->data.frame.buf, pkt->data.frame.sz); 442 443 return rc; 444 } 443 445 444 446 int Ebml_WriteWebMFileFooter(EbmlGlobal *glob, long hash) … … 446 448 int rc = VINF_SUCCESS; 447 449 if (glob->cluster_open) 448 rc = Ebml_EndSubElement(glob, &glob->startCluster);450 rc = ebml_EndSubElement(glob, glob->startCluster); 449 451 450 452 { 451 453 uint64_t start; 452 unsigned int i;453 454 454 455 glob->cue_pos = RTFileTell(glob->file); 455 456 if (RT_SUCCESS(rc)) 456 rc = Ebml_StartSubElement(glob, &start, Cues);457 for ( i=0; i<glob->cues; i++)457 rc = ebml_StartSubElement(glob, &start, Cues); 458 for (unsigned i = 0; i < glob->cues; i++) 458 459 { 459 460 struct cue_entry *cue = &glob->cue_list[i]; … … 461 462 462 463 if (RT_SUCCESS(rc)) 463 rc = Ebml_StartSubElement(glob, &startSub, CuePoint);464 rc = ebml_StartSubElement(glob, &startSub, CuePoint); 464 465 { 465 466 uint64_t startSubsub; … … 468 469 rc = Ebml_SerializeUnsigned(glob, CueTime, cue->time); 469 470 if (RT_SUCCESS(rc)) 470 rc = Ebml_StartSubElement(glob, &startSubsub, CueTrackPositions);471 rc = ebml_StartSubElement(glob, &startSubsub, CueTrackPositions); 471 472 if (RT_SUCCESS(rc)) 472 473 rc = Ebml_SerializeUnsigned(glob, CueTrack, 1); … … 476 477 //Ebml_SerializeUnsigned(glob, CueBlockNumber, cue->blockNumber); 477 478 if (RT_SUCCESS(rc)) 478 rc = Ebml_EndSubElement(glob, &startSubsub);479 rc = ebml_EndSubElement(glob, startSubsub); 479 480 } 480 481 if (RT_SUCCESS(rc)) 481 rc = Ebml_EndSubElement(glob, &startSub);482 rc = ebml_EndSubElement(glob, startSub); 482 483 } 483 484 if (RT_SUCCESS(rc)) 484 rc = Ebml_EndSubElement(glob, &start);485 } 486 487 if (RT_SUCCESS(rc)) 488 rc = Ebml_EndSubElement(glob, &glob->startSegment);485 rc = ebml_EndSubElement(glob, start); 486 } 487 488 if (RT_SUCCESS(rc)) 489 rc = ebml_EndSubElement(glob, glob->startSegment); 489 490 490 491 /* Patch up the seek info block */ … … 496 497 rc = RTFileSeek(glob->file, glob->track_id_pos, RTFILE_SEEK_BEGIN, NULL); 497 498 if (RT_SUCCESS(rc)) 498 rc = Ebml_SerializeUnsigned32(glob, TrackUID, glob->debug ? 0xDEADBEEF : hash);499 rc = ebml_SerializeUnsigned32(glob, TrackUID, glob->debug ? 0xDEADBEEF : hash); 499 500 500 501 if (RT_SUCCESS(rc)) -
trunk/src/VBox/Main/src-client/EbmlWriter.h
r45914 r45922 283 283 }; 284 284 285 int Ebml_Serialize(EbmlGlobal *glob, const void *, uint64_t);286 int Ebml_SerializeUnsigned32(EbmlGlobal *glob, uint32_t class_id, uint64_t ui);287 int Ebml_Write(EbmlGlobal *glob, const void *, uint64_t);288 int Ebml_StartSubElement(EbmlGlobal *glob, uint64_t *ebmlLoc, uint32_t class_id);289 int Ebml_EndSubElement(EbmlGlobal *glob, uint64_t *ebmlLoc);290 291 int Ebml_WriteLen(EbmlGlobal *glob, uint64_t val);292 int Ebml_WriteString(EbmlGlobal *glob, const char *str);293 int Ebml_WriteID(EbmlGlobal *glob, uint32_t class_id);294 int Ebml_SerializeUnsigned64(EbmlGlobal *glob, uint32_t class_id, uint64_t ui);295 int Ebml_SerializeUnsigned(EbmlGlobal *glob, uint32_t class_id, uint32_t ui);296 int Ebml_SerializeBinary(EbmlGlobal *glob, uint32_t class_id, uint32_t ui);297 int Ebml_SerializeFloat(EbmlGlobal *glob, uint32_t class_id, double d);298 299 int Ebml_SerializeString(EbmlGlobal *glob, uint32_t class_id, const char *s);300 301 285 int Ebml_WriteWebMSeekElement(EbmlGlobal *ebml, uint32_t id, uint64_t pos); 302 286 int Ebml_WriteWebMSeekInfo(EbmlGlobal *ebml); -
trunk/src/VBox/Main/src-client/VideoRec.cpp
r45911 r45922 405 405 ASMAtomicWriteBool(&pVideoRecCtx->fRgbFilled, false); 406 406 if (RT_SUCCESS(rc)) 407 videoRecEncodeAndWrite(pVideoRecCtx); 407 rc = videoRecEncodeAndWrite(pVideoRecCtx); 408 if (RT_FAILURE(rc)) 409 LogRel(("Error %Rrc encoding video frame\n", rc)); 408 410 } 409 411 } … … 554 556 vpx_codec_pts_t pts = pVideoRecCtx->u64TimeStamp; 555 557 vpx_codec_err_t rcv = vpx_codec_encode(&pVideoRecCtx->VpxCodec, 556 557 558 10/* how long to show this frame */,559 0/* flags */,560 558 &pVideoRecCtx->VpxRawImage, 559 pts /* time stamp */, 560 10 /* how long to show this frame */, 561 0 /* flags */, 562 VPX_DL_REALTIME /* deadline */); 561 563 if (rcv != VPX_CODEC_OK) 562 564 { … … 566 568 567 569 vpx_codec_iter_t iter = NULL; 568 int rc = V INF_SUCCESS;570 int rc = VERR_NO_DATA; 569 571 for (;;) 570 572 { 571 573 const vpx_codec_cx_pkt_t *pkt = vpx_codec_get_cx_data(&pVideoRecCtx->VpxCodec, &iter); 572 574 if (!pkt) 573 return VERR_NO_DATA;575 break; 574 576 switch (pkt->kind) 575 577 {
Note:
See TracChangeset
for help on using the changeset viewer.