1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
//
// Heavily based on ffmpeg code.
//
// Copyright (c) 2001 Fabrice Bellard.
// First version by Francois Revol revol@free.fr
// Seek function by Gael Chardon gael.dev@4now.net
//
#include "common/debug.h"
#include "common/endian.h"
#include "common/macresman.h"
#include "common/memstream.h"
#include "common/formats/quicktime.h"
#include "common/textconsole.h"
#include "common/util.h"
#include "common/compression/deflate.h"
namespace Common {
////////////////////////////////////////////
// QuickTimeParser
////////////////////////////////////////////
QuickTimeParser::QuickTimeParser() {
_beginOffset = 0;
_fd = nullptr;
_scaleFactorX = 1;
_scaleFactorY = 1;
_resFork = new MacResManager();
_disposeFileHandle = DisposeAfterUse::YES;
_timeScale = 1;
_qtvrType = QTVRType::OTHER;
_winX = 0;
_winY = 0;
_panoTrack = nullptr;
initParseTable();
}
QuickTimeParser::~QuickTimeParser() {
close();
delete _resFork;
}
bool QuickTimeParser::parseFile(const Path &filename) {
if (!_resFork->open(filename))
return false;
_foundMOOV = false;
_disposeFileHandle = DisposeAfterUse::YES;
Atom atom = { 0, 0, 0 };
if (_resFork->hasResFork()) {
// Search for a 'moov' resource
MacResIDArray idArray = _resFork->getResIDArray(MKTAG('m', 'o', 'o', 'v'));
if (!idArray.empty())
_fd = _resFork->getResource(MKTAG('m', 'o', 'o', 'v'), idArray[0]);
if (_fd) {
atom.size = _fd->size();
if (readDefault(atom) < 0 || !_foundMOOV)
return false;
}
delete _fd;
}
_fd = Common::MacResManager::openFileOrDataFork(filename);
if (!_fd)
return false;
atom.size = _fd->size();
if (readDefault(atom) < 0 || !_foundMOOV)
return false;
if (_qtvrType == QTVRType::PANORAMA) {
if (!parsePanoramaAtoms())
return false;
}
init();
return true;
}
bool QuickTimeParser::parseStream(SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle) {
_fd = stream;
_foundMOOV = false;
_disposeFileHandle = disposeFileHandle;
Atom atom = { 0, 0, 0xffffffff };
if (readDefault(atom) < 0 || !_foundMOOV) {
close();
return false;
}
if (_qtvrType == QTVRType::PANORAMA) {
if (!parsePanoramaAtoms())
return false;
}
init();
return true;
}
bool QuickTimeParser::parsePanoramaAtoms() {
for (uint i = 0; i < _tracks.size(); i++) {
if (_tracks[i]->codecType == CODEC_TYPE_PANO) {
_panoTrack = _tracks[i];
break;
}
}
if (!_panoTrack) {
warning("QuickTimeParser::parsePanoramaAtoms(): No panoramic track found");
return false;
}
Array<uint32> sizes;
if (_panoTrack->sampleSize) {
sizes = { _panoTrack->sampleSize };
} else {
sizes.resize(_panoTrack->sampleCount);
for (uint32 i = 0; i < _panoTrack->sampleCount; i++)
sizes[i] = _panoTrack->sampleSizes[i];
}
for (uint32 i = 0; i < sizes.size() && i < _panoTrack->chunkCount; i++) {
_panoTrack->panoSamples.resize(_panoTrack->panoSamples.size() + 1);
Atom atom = { 0, _panoTrack->chunkOffsets[i], sizes[i] };
_fd->seek(_panoTrack->chunkOffsets[i], SEEK_SET);
if (readDefault(atom) < 0)
return false;
}
return true;
}
void QuickTimeParser::init() {
for (uint32 i = 0; i < _tracks.size(); i++) {
// Remove unknown/unhandled tracks
if (_tracks[i]->codecType == CODEC_TYPE_MOV_OTHER) {
delete _tracks[i];
_tracks.remove_at(i);
i--;
} else {
// If this track doesn't have a declared scale, use the movie scale
if (_tracks[i]->timeScale == 0)
_tracks[i]->timeScale = _timeScale;
// If this track doesn't have an edit list (like in MPEG-4 files),
// fake an entry of one edit that takes up the entire sample
if (_tracks[i]->editList.size() == 0) {
_tracks[i]->editList.resize(1);
_tracks[i]->editList[0].trackDuration = _tracks[i]->duration;
_tracks[i]->editList[0].timeOffset = 0;
_tracks[i]->editList[0].mediaTime = 0;
_tracks[i]->editList[0].mediaRate = 1;
}
}
}
}
void QuickTimeParser::initParseTable() {
static const ParseTable p[] = {
{ &QuickTimeParser::readDefault, MKTAG('d', 'i', 'n', 'f') },
{ &QuickTimeParser::readDREF, MKTAG('d', 'r', 'e', 'f') },
{ &QuickTimeParser::readDefault, MKTAG('e', 'd', 't', 's') },
{ &QuickTimeParser::readELST, MKTAG('e', 'l', 's', 't') },
{ &QuickTimeParser::readHDLR, MKTAG('h', 'd', 'l', 'r') },
{ &QuickTimeParser::readLeaf, MKTAG('m', 'd', 'a', 't') },
{ &QuickTimeParser::readMDHD, MKTAG('m', 'd', 'h', 'd') },
{ &QuickTimeParser::readDefault, MKTAG('m', 'd', 'i', 'a') },
{ &QuickTimeParser::readDefault, MKTAG('m', 'i', 'n', 'f') },
{ &QuickTimeParser::readMOOV, MKTAG('m', 'o', 'o', 'v') },
{ &QuickTimeParser::readMVHD, MKTAG('m', 'v', 'h', 'd') },
{ &QuickTimeParser::readSMHD, MKTAG('s', 'm', 'h', 'd') },
{ &QuickTimeParser::readDefault, MKTAG('s', 't', 'b', 'l') },
{ &QuickTimeParser::readSTCO, MKTAG('s', 't', 'c', 'o') },
{ &QuickTimeParser::readSTSC, MKTAG('s', 't', 's', 'c') },
{ &QuickTimeParser::readSTSD, MKTAG('s', 't', 's', 'd') },
{ &QuickTimeParser::readSTSS, MKTAG('s', 't', 's', 's') },
{ &QuickTimeParser::readSTSZ, MKTAG('s', 't', 's', 'z') },
{ &QuickTimeParser::readSTTS, MKTAG('s', 't', 't', 's') },
{ &QuickTimeParser::readTKHD, MKTAG('t', 'k', 'h', 'd') },
{ &QuickTimeParser::readTRAK, MKTAG('t', 'r', 'a', 'k') },
{ &QuickTimeParser::readDefault, MKTAG('u', 'd', 't', 'a') },
{ &QuickTimeParser::readCTYP, MKTAG('c', 't', 'y', 'p') },
{ &QuickTimeParser::readWLOC, MKTAG('W', 'L', 'O', 'C') },
{ &QuickTimeParser::readNAVG, MKTAG('N', 'A', 'V', 'G') },
{ &QuickTimeParser::readVMHD, MKTAG('v', 'm', 'h', 'd') },
{ &QuickTimeParser::readCMOV, MKTAG('c', 'm', 'o', 'v') },
{ &QuickTimeParser::readWAVE, MKTAG('w', 'a', 'v', 'e') },
{ &QuickTimeParser::readESDS, MKTAG('e', 's', 'd', 's') },
{ &QuickTimeParser::readSMI, MKTAG('S', 'M', 'I', ' ') },
{ &QuickTimeParser::readDefault, MKTAG('g', 'm', 'h', 'd') },
{ &QuickTimeParser::readGMIN, MKTAG('g', 'm', 'i', 'n') },
{ &QuickTimeParser::readDefault, MKTAG('S', 'T', 'p', 'n') },
{ &QuickTimeParser::readPINF, MKTAG('p', 'I', 'n', 'f') },
{ &QuickTimeParser::readDefault, MKTAG('S', 'T', 'p', 'n') },
{ &QuickTimeParser::readPHDR, MKTAG('p', 'H', 'd', 'r') },
{ &QuickTimeParser::readPHOT, MKTAG('p', 'H', 'o', 't') },
{ &QuickTimeParser::readSTRT, MKTAG('s', 't', 'r', 'T') },
{ &QuickTimeParser::readPLNK, MKTAG('p', 'L', 'n', 'k') },
{ &QuickTimeParser::readPNAV, MKTAG('p', 'N', 'a', 'v') },
{ nullptr, 0 }
};
_parseTable = p;
}
int QuickTimeParser::readDefault(Atom atom) {
uint32 total_size = 0;
Atom a;
int err = 0;
a.offset = atom.offset;
if (_fd->eos() || _fd->err() || (_fd->pos() == _fd->size()))
return -1;
while(((total_size + 8) < atom.size) && !_fd->eos() && _fd->pos() < _fd->size() && !err) {
a.size = atom.size;
a.type = 0;
if (atom.size >= 8) {
a.size = _fd->readUint32BE();
a.type = _fd->readUint32BE();
// Some QuickTime videos with resource forks have mdat chunks
// that are of size 0. Adjust it so it's the correct size.
if (a.type == MKTAG('m', 'd', 'a', 't') && a.size == 0)
a.size = _fd->size();
}
total_size += 8;
a.offset += 8;
debug(4, "type: %08x %.4s sz: %x %x %x", a.type, tag2str(a.type), a.size, atom.size, total_size);
if (a.size == 1) { // 64 bit extended size
warning("64 bit extended size is not supported in QuickTime");
return -1;
}
if (a.size == 0) {
a.size = atom.size - total_size;
if (a.size <= 8)
break;
}
uint32 i = 0;
for (; _parseTable[i].type != 0 && _parseTable[i].type != a.type; i++)
; // Empty
if (a.size < 8)
break;
a.size -= 8;
if (a.size + (uint32)_fd->pos() > (uint32)_fd->size()) {
_fd->seek(_fd->size());
debug(0, "Skipping junk found at the end of the QuickTime file");
return 0;
} else if (_parseTable[i].type == 0) { // skip leaf atom data
debug(0, ">>> Skipped [%s]", tag2str(a.type));
_fd->seek(a.size, SEEK_CUR);
} else {
uint32 start_pos = _fd->pos();
err = (this->*_parseTable[i].func)(a);
if (!err && (_fd->eos() || _fd->err()))
err = -1;
uint32 left = a.size - _fd->pos() + start_pos;
if (left > 0) // skip garbage at atom end
_fd->seek(left, SEEK_CUR);
}
a.offset += a.size;
total_size += a.size;
}
if (!err && total_size < atom.size)
_fd->seek(atom.size - total_size, SEEK_SET);
return err;
}
int QuickTimeParser::readLeaf(Atom atom) {
if (atom.size > 1)
_fd->seek(atom.size, SEEK_SET);
return 0;
}
int QuickTimeParser::readMOOV(Atom atom) {
if (readDefault(atom) < 0)
return -1;
// We parsed the 'moov' atom, so we don't need anything else
_foundMOOV = true;
return 1;
}
int QuickTimeParser::readCMOV(Atom atom) {
// Read in the dcom atom
_fd->readUint32BE();
if (_fd->readUint32BE() != MKTAG('d', 'c', 'o', 'm'))
return -1;
if (_fd->readUint32BE() != MKTAG('z', 'l', 'i', 'b')) {
warning("Unknown cmov compression type");
return -1;
}
// Read in the cmvd atom
uint32 compressedSize = _fd->readUint32BE() - 12;
if (_fd->readUint32BE() != MKTAG('c', 'm', 'v', 'd'))
return -1;
uint32 uncompressedSize = _fd->readUint32BE();
// Read in data
byte *compressedData = (byte *)malloc(compressedSize);
_fd->read(compressedData, compressedSize);
// Create uncompressed stream
byte *uncompressedData = (byte *)malloc(uncompressedSize);
// Uncompress the data
unsigned long dstLen = uncompressedSize;
if (!inflateZlib(uncompressedData, &dstLen, compressedData, compressedSize)) {
warning ("Could not uncompress cmov chunk");
free(compressedData);
free(uncompressedData);
return -1;
}
// Load data into a new MemoryReadStream and assign _fd to be that
SeekableReadStream *oldStream = _fd;
_fd = new MemoryReadStream(uncompressedData, uncompressedSize, DisposeAfterUse::YES);
// Read the contents of the uncompressed data
Atom a = { MKTAG('m', 'o', 'o', 'v'), 0, uncompressedSize };
int err = readDefault(a);
// Assign the file handle back to the original handle
free(compressedData);
delete _fd;
_fd = oldStream;
return err;
}
int QuickTimeParser::readMVHD(Atom atom) {
byte version = _fd->readByte(); // version
_fd->readByte(); _fd->readByte(); _fd->readByte(); // flags
if (version == 1) {
warning("QuickTime version 1");
_fd->readUint32BE(); _fd->readUint32BE();
_fd->readUint32BE(); _fd->readUint32BE();
} else {
_fd->readUint32BE(); // creation time
_fd->readUint32BE(); // modification time
}
_timeScale = _fd->readUint32BE(); // time scale
debug(0, "time scale = %i\n", _timeScale);
// duration
_duration = (version == 1) ? (_fd->readUint32BE(), _fd->readUint32BE()) : _fd->readUint32BE();
_fd->readUint32BE(); // preferred scale
_fd->readUint16BE(); // preferred volume
_fd->seek(10, SEEK_CUR); // reserved
// We only need two values from the movie display matrix. Most of the values are just
// skipped. xMod and yMod are 16:16 fixed point numbers, the last part of the 3x3 matrix
// is 2:30.
uint32 xMod = _fd->readUint32BE();
_fd->skip(12);
uint32 yMod = _fd->readUint32BE();
_fd->skip(16);
_scaleFactorX = Rational(0x10000, xMod);
_scaleFactorY = Rational(0x10000, yMod);
_scaleFactorX.debugPrint(1, "readMVHD(): scaleFactorX =");
_scaleFactorY.debugPrint(1, "readMVHD(): scaleFactorY =");
_fd->readUint32BE(); // preview time
_fd->readUint32BE(); // preview duration
_fd->readUint32BE(); // poster time
_fd->readUint32BE(); // selection time
_fd->readUint32BE(); // selection duration
_fd->readUint32BE(); // current time
_fd->readUint32BE(); // next track ID
return 0;
}
int QuickTimeParser::readTRAK(Atom atom) {
Track *track = new Track();
track->codecType = CODEC_TYPE_MOV_OTHER;
_tracks.push_back(track);
return readDefault(atom);
}
int QuickTimeParser::readSMHD(Atom atom) {
Track *track = _tracks.back();
_fd->readUint32BE(); // version + flags
track->soundBalance = _fd->readUint16BE();
_fd->readUint16BE(); // reserved
return 0;
}
int QuickTimeParser::readTKHD(Atom atom) {
Track *track = _tracks.back();
byte version = _fd->readByte();
_fd->readByte(); _fd->readByte();
_fd->readByte(); // flags
//
//MOV_TRACK_ENABLED 0x0001
//MOV_TRACK_IN_MOVIE 0x0002
//MOV_TRACK_IN_PREVIEW 0x0004
//MOV_TRACK_IN_POSTER 0x0008
//
if (version == 1) {
_fd->readUint32BE(); _fd->readUint32BE();
_fd->readUint32BE(); _fd->readUint32BE();
} else {
_fd->readUint32BE(); // creation time
_fd->readUint32BE(); // modification time
}
/* track->id = */_fd->readUint32BE(); // track id (NOT 0 !)
_fd->readUint32BE(); // reserved
track->duration = (version == 1) ? (_fd->readUint32BE(), _fd->readUint32BE()) : _fd->readUint32BE(); // highlevel (considering edits) duration in movie timebase
_fd->readUint32BE(); // reserved
_fd->readUint32BE(); // reserved
_fd->readUint16BE(); // layer
_fd->readUint16BE(); // alternate group
_fd->readUint16BE(); // volume
_fd->readUint16BE(); // reserved
// We only need the two values from the displacement matrix for a track.
// See readMVHD() for more information.
uint32 xMod = _fd->readUint32BE();
_fd->skip(12);
uint32 yMod = _fd->readUint32BE();
_fd->skip(16);
track->scaleFactorX = Rational(0x10000, xMod);
track->scaleFactorY = Rational(0x10000, yMod);
track->scaleFactorX.debugPrint(1, "readTKHD(): scaleFactorX =");
track->scaleFactorY.debugPrint(1, "readTKHD(): scaleFactorY =");
// these are fixed-point, 16:16
//_fd->readUint32BE() >> 16; // track width
//_fd->readUint32BE() >> 16; // track height
return 0;
}
// edit list atom
int QuickTimeParser::readELST(Atom atom) {
Track *track = _tracks.back();
_fd->readByte(); // version
_fd->readByte(); _fd->readByte(); _fd->readByte(); // flags
uint32 editCount = _fd->readUint32BE();
track->editList.resize(editCount);
debug(2, "Track %d edit list count: %d", _tracks.size() - 1, editCount);
uint32 offset = 0;
for (uint32 i = 0; i < editCount; i++) {
track->editList[i].trackDuration = _fd->readUint32BE();
track->editList[i].mediaTime = _fd->readSint32BE();
track->editList[i].mediaRate = Rational(_fd->readUint32BE(), 0x10000);
track->editList[i].timeOffset = offset;
debugN(3, "\tDuration = %d (Offset = %d), Media Time = %d, ", track->editList[i].trackDuration, offset, track->editList[i].mediaTime);
track->editList[i].mediaRate.debugPrint(3, "Media Rate =");
offset += track->editList[i].trackDuration;
}
return 0;
}
int QuickTimeParser::readHDLR(Atom atom) {
Track *track = _tracks.back();
_fd->readByte(); // version
_fd->readByte(); _fd->readByte(); _fd->readByte(); // flags
// component type
uint32 ctype = _fd->readUint32BE();
uint32 type = _fd->readUint32BE(); // component subtype
debug(0, "ctype= %s (0x%08lx)", tag2str(ctype), (long)ctype);
debug(0, "stype= %s", tag2str(type));
if (ctype == MKTAG('m', 'h', 'l', 'r')) // MOV
debug(0, "MOV detected");
else if (ctype == 0)
debug(0, "MPEG-4 detected");
if (type == MKTAG('v', 'i', 'd', 'e'))
track->codecType = CODEC_TYPE_VIDEO;
else if (type == MKTAG('s', 'o', 'u', 'n'))
track->codecType = CODEC_TYPE_AUDIO;
else if (type == MKTAG('m', 'u', 's', 'i'))
track->codecType = CODEC_TYPE_MIDI;
else if (type == MKTAG('S', 'T', 'p', 'n') || type == MKTAG('s', 't', 'p', 'n'))
track->codecType = CODEC_TYPE_PANO;
_fd->readUint32BE(); // component manufacture
_fd->readUint32BE(); // component flags
_fd->readUint32BE(); // component flags mask
if (atom.size <= 24)
return 0; // nothing left to read
// .mov: PASCAL string
byte len = _fd->readByte();
_fd->seek(len, SEEK_CUR);
_fd->seek(atom.size - (_fd->pos() - atom.offset), SEEK_CUR);
return 0;
}
int QuickTimeParser::readMDHD(Atom atom) {
Track *track = _tracks.back();
byte version = _fd->readByte();
if (version > 1)
return 1; // unsupported
_fd->readByte(); _fd->readByte();
_fd->readByte(); // flags
if (version == 1) {
_fd->readUint32BE(); _fd->readUint32BE();
_fd->readUint32BE(); _fd->readUint32BE();
} else {
_fd->readUint32BE(); // creation time
_fd->readUint32BE(); // modification time
}
track->timeScale = _fd->readUint32BE();
track->mediaDuration = (version == 1) ? (_fd->readUint32BE(), _fd->readUint32BE()) : _fd->readUint32BE(); // duration
_fd->readUint16BE(); // language
_fd->readUint16BE(); // quality
return 0;
}
int QuickTimeParser::readSTSD(Atom atom) {
Track *track = _tracks.back();
_fd->readByte(); // version
_fd->readByte(); _fd->readByte(); _fd->readByte(); // flags
uint32 entryCount = _fd->readUint32BE();
track->sampleDescs.reserve(entryCount);
for (uint32 i = 0; i < entryCount; i++) { // Parsing Sample description table
Atom a = { 0, 0, 0 };
uint32 start_pos = _fd->pos();
int size = _fd->readUint32BE(); // size
uint32 format = _fd->readUint32BE(); // data format
_fd->readUint32BE(); // reserved
_fd->readUint16BE(); // reserved
_fd->readUint16BE(); // index
track->sampleDescs.push_back(readSampleDesc(track, format, size - 16));
debug(0, "size=%d 4CC= %s codec_type=%d", size, tag2str(format), track->codecType);
if (!track->sampleDescs[i]) {
// other codec type, just skip (rtp, mp4s, tmcd ...)
_fd->seek(size - (_fd->pos() - start_pos), SEEK_CUR);
}
// this will read extra atoms at the end (wave, alac, damr, avcC, SMI ...)
a.size = size - (_fd->pos() - start_pos);
if (a.size > 8)
readDefault(a);
else if (a.size > 0)
_fd->seek(a.size, SEEK_CUR);
}
return 0;
}
int QuickTimeParser::readSTSC(Atom atom) {
Track *track = _tracks.back();
_fd->readByte(); // version
_fd->readByte(); _fd->readByte(); _fd->readByte(); // flags
track->sampleToChunkCount = _fd->readUint32BE();
debug(0, "track[%i].stsc.entries = %i", _tracks.size() - 1, track->sampleToChunkCount);
track->sampleToChunk = new SampleToChunkEntry[track->sampleToChunkCount];
if (!track->sampleToChunk)
return -1;
for (uint32 i = 0; i < track->sampleToChunkCount; i++) {
track->sampleToChunk[i].first = _fd->readUint32BE() - 1;
track->sampleToChunk[i].count = _fd->readUint32BE();
track->sampleToChunk[i].id = _fd->readUint32BE();
//warning("Sample to Chunk[%d]: First = %d, Count = %d", i, track->sampleToChunk[i].first, track->sampleToChunk[i].count);
}
return 0;
}
int QuickTimeParser::readSTSS(Atom atom) {
Track *track = _tracks.back();
_fd->readByte(); // version
_fd->readByte(); _fd->readByte(); _fd->readByte(); // flags
track->keyframeCount = _fd->readUint32BE();
debug(0, "keyframeCount = %d", track->keyframeCount);
track->keyframes = new uint32[track->keyframeCount];
if (!track->keyframes)
return -1;
for (uint32 i = 0; i < track->keyframeCount; i++) {
track->keyframes[i] = _fd->readUint32BE() - 1; // Adjust here, the frames are based on 1
debug(6, "keyframes[%d] = %d", i, track->keyframes[i]);
}
return 0;
}
int QuickTimeParser::readSTSZ(Atom atom) {
Track *track = _tracks.back();
_fd->readByte(); // version
_fd->readByte(); _fd->readByte(); _fd->readByte(); // flags
track->sampleSize = _fd->readUint32BE();
track->sampleCount = _fd->readUint32BE();
debug(5, "sampleSize = %d sampleCount = %d", track->sampleSize, track->sampleCount);
if (track->sampleSize)
return 0; // there isn't any table following
track->sampleSizes = new uint32[track->sampleCount];
if (!track->sampleSizes)
return -1;
for(uint32 i = 0; i < track->sampleCount; i++) {
track->sampleSizes[i] = _fd->readUint32BE();
debug(6, "sampleSizes[%d] = %d", i, track->sampleSizes[i]);
}
return 0;
}
int QuickTimeParser::readSTTS(Atom atom) {
Track *track = _tracks.back();
uint32 totalSampleCount = 0;
_fd->readByte(); // version
_fd->readByte(); _fd->readByte(); _fd->readByte(); // flags
track->timeToSampleCount = _fd->readUint32BE();
track->timeToSample = new TimeToSampleEntry[track->timeToSampleCount];
debug(0, "track[%d].stts.entries = %d", _tracks.size() - 1, track->timeToSampleCount);
for (int32 i = 0; i < track->timeToSampleCount; i++) {
track->timeToSample[i].count = _fd->readUint32BE();
track->timeToSample[i].duration = _fd->readUint32BE();
debug(1, "\tCount = %d, Duration = %d", track->timeToSample[i].count, track->timeToSample[i].duration);
totalSampleCount += track->timeToSample[i].count;
}
track->frameCount = totalSampleCount;
return 0;
}
int QuickTimeParser::readVMHD(Atom atom) {
Track *track = _tracks.back();
_fd->readUint32BE(); // version + flags
track->graphicsMode = (GraphicsMode)_fd->readUint16BE();
_fd->readMultipleBE(track->opcolor);
return 0;
}
int QuickTimeParser::readSTCO(Atom atom) {
Track *track = _tracks.back();
_fd->readByte(); // version
_fd->readByte(); _fd->readByte(); _fd->readByte(); // flags
track->chunkCount = _fd->readUint32BE();
track->chunkOffsets = new uint32[track->chunkCount];
if (!track->chunkOffsets)
return -1;
for (uint32 i = 0; i < track->chunkCount; i++) {
// WORKAROUND/HACK: The offsets in Riven videos (ones inside the Mohawk archives themselves)
// have offsets relative to the archive and not the video. This is quite nasty. We subtract
// the initial offset of the stream to get the correct value inside of the stream.
track->chunkOffsets[i] = _fd->readUint32BE() - _beginOffset;
}
return 0;
}
int QuickTimeParser::readWAVE(Atom atom) {
if (_tracks.empty())
return 0;
Track *track = _tracks.back();
if (atom.size > (1 << 30))
return -1;
// We should only get here within an stsd atom
if (track->sampleDescs.empty())
return -1;
SampleDesc *sampleDesc = track->sampleDescs.back();
if (sampleDesc->getCodecTag() == MKTAG('Q', 'D', 'M', '2')) // Read extra data for QDM2
sampleDesc->_extraData = _fd->readStream(atom.size);
else if (atom.size > 8)
return readDefault(atom);
else
_fd->skip(atom.size);
return 0;
}
enum {
kMP4IODescTag = 2,
kMP4ESDescTag = 3,
kMP4DecConfigDescTag = 4,
kMP4DecSpecificDescTag = 5
};
static int readMP4DescLength(SeekableReadStream *stream) {
int length = 0;
int count = 4;
while (count--) {
byte c = stream->readByte();
length = (length << 7) | (c & 0x7f);
if (!(c & 0x80))
break;
}
return length;
}
static void readMP4Desc(SeekableReadStream *stream, byte &tag, int &length) {
tag = stream->readByte();
length = readMP4DescLength(stream);
}
int QuickTimeParser::readESDS(Atom atom) {
if (_tracks.empty())
return 0;
Track *track = _tracks.back();
// We should only get here within an stsd atom
if (track->sampleDescs.empty())
return -1;
SampleDesc *sampleDesc = track->sampleDescs.back();
_fd->readUint32BE(); // version + flags
byte tag;
int length;
readMP4Desc(_fd, tag, length);
_fd->readUint16BE(); // id
if (tag == kMP4ESDescTag)
_fd->readByte(); // priority
// Check if we've got the Config MPEG-4 header
readMP4Desc(_fd, tag, length);
if (tag != kMP4DecConfigDescTag)
return 0;
sampleDesc->_objectTypeMP4 = _fd->readByte();
_fd->readByte(); // stream type
_fd->readUint16BE(); _fd->readByte(); // buffer size
_fd->readUint32BE(); // max bitrate
_fd->readUint32BE(); // avg bitrate
// Check if we've got the Specific MPEG-4 header
readMP4Desc(_fd, tag, length);
if (tag != kMP4DecSpecificDescTag)
return 0;
sampleDesc->_extraData = _fd->readStream(length);
debug(0, "MPEG-4 object type = %02x", sampleDesc->_objectTypeMP4);
return 0;
}
int QuickTimeParser::readSMI(Atom atom) {
if (_tracks.empty())
return 0;
Track *track = _tracks.back();
// We should only get here within an stsd atom
if (track->sampleDescs.empty())
return -1;
SampleDesc *sampleDesc = track->sampleDescs.back();
// This atom just contains SVQ3 extra data
sampleDesc->_extraData = _fd->readStream(atom.size);
return 0;
}
int QuickTimeParser::readCTYP(Atom atom) {
uint32 ctype = _fd->readUint32BE();
switch (ctype) {
case MKTAG('s', 't', 'n', 'a'):
_qtvrType = QTVRType::OBJECT;
break;
case MKTAG('S', 'T', 'p', 'n'):
case MKTAG('s', 't', 'p', 'n'):
_qtvrType = QTVRType::PANORAMA;
break;
default:
_qtvrType = QTVRType::OTHER;
warning("QuickTimeParser::readCTYP(): Unknown QTVR Type ('%s')", tag2str(ctype));
break;
}
return 0;
}
int QuickTimeParser::readWLOC(Atom atom) {
_winX = _fd->readUint16BE();
_winY = _fd->readUint16BE();
return 0;
}
static float readAppleFloatField(SeekableReadStream *stream) {
int16 a = stream->readSint16BE();
uint16 b = stream->readUint16BE();
float value = (float)a + (float)b / 65536.0f;
return value;
}
int QuickTimeParser::readNAVG(Atom atom) {
_fd->readUint16BE(); // version
_nav.columns = _fd->readUint16BE();
_nav.rows = _fd->readUint16BE();
_fd->readUint16BE(); // reserved
_nav.loop_size = _fd->readUint16BE();
_nav.frame_duration = _fd->readUint16BE();
_nav.movie_type = (MovieType)_fd->readUint16BE();
_nav.loop_ticks = _fd->readUint16BE();
_nav.field_of_view = readAppleFloatField(_fd);
_nav.startHPan = readAppleFloatField(_fd);
_nav.endHPan = readAppleFloatField(_fd);
_nav.endVPan = readAppleFloatField(_fd);
_nav.startVPan = readAppleFloatField(_fd);
_nav.initialHPan = readAppleFloatField(_fd);
_nav.initialVPan = readAppleFloatField(_fd);
_fd->readUint32BE(); // reserved2
return 0;
}
int QuickTimeParser::readGMIN(Atom atom) {
Track *track = _tracks.back();
_fd->readUint32BE(); // version + flags
track->graphicsMode = (GraphicsMode)_fd->readUint16BE();
_fd->readMultipleBE(track->opcolor);
track->soundBalance = _fd->readUint16BE();
_fd->readUint16BE(); // reserved
return 0;
}
int QuickTimeParser::readPINF(Atom atom) {
Track *track = _tracks.back();
track->panoInfo.name = _fd->readPascalString();
_fd->seek((int64)atom.offset + 32);
track->panoInfo.defNodeID = _fd->readUint32BE();
track->panoInfo.defZoom = readAppleFloatField(_fd);
_fd->readUint32BE(); // reserved
_fd->readSint16BE(); // padding
int16 numEntries = _fd->readSint16BE();
track->panoInfo.nodes.resize(numEntries);
for (int16 i = 0; i < numEntries; i++) {
track->panoInfo.nodes[i].nodeID = _fd->readUint32BE();
track->panoInfo.nodes[i].timestamp = _fd->readUint32BE();
}
return 0;
}
int QuickTimeParser::readDREF(Atom atom) {
if (atom.size > 1) {
Track *track = _tracks.back();
uint32 endPos = _fd->pos() + atom.size;
_fd->readUint32BE(); // version + flags
uint32 entries = _fd->readUint32BE();
for (uint32 i = 0; i < entries && _fd->pos() < endPos; i++) {
uint32 size = _fd->readUint32BE();
uint32 next = _fd->pos() + size - 4;
if (next > endPos) {
warning("DREF chunk overflows atom bounds");
return 1;
}
uint32 type = _fd->readUint32BE();
_fd->readUint32BE(); // version + flags
if (type == MKTAG('a', 'l', 'i', 's')) {
if (size < 150) {
_fd->seek(next, SEEK_SET);
continue;
}
// Macintosh alias record
_fd->seek(10, SEEK_CUR);
uint8 volumeSize = MIN((uint8)27, _fd->readByte());
track->volume = _fd->readString('\0', volumeSize);
_fd->seek(27 - volumeSize, SEEK_CUR);
_fd->seek(12, SEEK_CUR);
uint8 filenameSize = MIN((uint8)63, _fd->readByte());
track->filename = _fd->readString('\0', filenameSize);
_fd->seek(63 - filenameSize, SEEK_CUR);
_fd->seek(16, SEEK_CUR);
debug(5, "volume: %s, filename: %s", track->volume.c_str(), track->filename.c_str());
track->nlvlFrom = _fd->readSint16BE();
track->nlvlTo = _fd->readSint16BE();
_fd->seek(16, SEEK_CUR);
debug(5, "nlvlFrom: %d, nlvlTo: %d", track->nlvlFrom, track->nlvlTo);
for (int16 subType = 0; subType != -1 && _fd->pos() < endPos;) {
subType = _fd->readSint16BE();
uint16 subTypeSize = _fd->readUint16BE();
subTypeSize += subTypeSize & 1 ? 1 : 0;
if (subType == 2) { // Absolute path
track->path = _fd->readString('\0', subTypeSize);
if (track->path.substr(0, volumeSize) == track->volume) {
track->path = track->path.substr(volumeSize);
}
debug(5, "path: %s", track->path.c_str());
} else if (subType == 0) {
track->directory = _fd->readString('\0', subTypeSize);
debug(5, "directory: %s", track->directory.c_str());
} else {
_fd->seek(subTypeSize, SEEK_CUR);
}
}
} else {
warning("Unknown DREF type %s", tag2str(type));
_fd->seek(next, SEEK_SET);
}
}
_fd->seek(endPos, SEEK_SET);
}
return 0;
}
int QuickTimeParser::readPHDR(Atom atom) {
PanoSampleHeader &pHdr = _panoTrack->panoSamples.back().hdr;
pHdr.nodeID = _fd->readUint32BE();
pHdr.defHPan = readAppleFloatField(_fd);
pHdr.defVPan = readAppleFloatField(_fd);
pHdr.defZoom = readAppleFloatField(_fd);
pHdr.minHPan = readAppleFloatField(_fd);
pHdr.minVPan = readAppleFloatField(_fd);
pHdr.minZoom = readAppleFloatField(_fd);
pHdr.maxHPan = readAppleFloatField(_fd);
pHdr.maxVPan = readAppleFloatField(_fd);
pHdr.minHPan = readAppleFloatField(_fd);
_fd->readSint64BE(); // reserved1 + reserved2
pHdr.nameStrOffset = _fd->readSint32BE();
pHdr.commentStrOffset = _fd->readSint32BE();
return 0;
}
int QuickTimeParser::readPHOT(Atom atom) {
PanoHotSpotTable &pHotSpotTable = _panoTrack->panoSamples.back().hotSpotTable;
_fd->readUint16BE(); // padding
int16 numHotSpots = _fd->readSint16BE();
pHotSpotTable.hotSpots.resize(numHotSpots);
for (int i = 0; i < numHotSpots; i++) {
pHotSpotTable.hotSpots[i].id = _fd->readUint16BE();
_fd->readUint16BE(); // reserved
uint32 type = _fd->readUint32BE();
switch (type) {
case MKTAG('l', 'i', 'n', 'k'):
pHotSpotTable.hotSpots[i].type = HotSpotType::link;
break;
case MKTAG('n', 'a', 'v', 'g'):
pHotSpotTable.hotSpots[i].type = HotSpotType::navg;
break;
default:
pHotSpotTable.hotSpots[i].type = HotSpotType::undefined;
warning("QuickTimeParser::readPHOT(): Unknown HotSpot Type ('%s')", tag2str(type));
break;
}
pHotSpotTable.hotSpots[i].typeData = _fd->readUint32BE();
pHotSpotTable.hotSpots[i].viewHPan = readAppleFloatField(_fd);
pHotSpotTable.hotSpots[i].viewVPan = readAppleFloatField(_fd);
pHotSpotTable.hotSpots[i].viewZoom = readAppleFloatField(_fd);
pHotSpotTable.hotSpots[i].rect.top = _fd->readSint16BE();
pHotSpotTable.hotSpots[i].rect.left = _fd->readSint16BE();
pHotSpotTable.hotSpots[i].rect.bottom = _fd->readSint16BE();
pHotSpotTable.hotSpots[i].rect.right = _fd->readSint16BE();
pHotSpotTable.hotSpots[i].mouseOverCursorID = _fd->readSint32BE();
pHotSpotTable.hotSpots[i].mouseDownCursorID = _fd->readSint32BE();
pHotSpotTable.hotSpots[i].mouseUpCursorID = _fd->readSint32BE();
_fd->readSint32BE(); // reserved2
pHotSpotTable.hotSpots[i].nameStrOffset = _fd->readSint32BE();
pHotSpotTable.hotSpots[i].commentStrOffset = _fd->readSint32BE();
}
return 0;
}
int QuickTimeParser::readSTRT(Atom atom) {
PanoStringTable &pStrTable = _panoTrack->panoSamples.back().strTable;
pStrTable.strings = _fd->readString(0, atom.size);
return 0;
}
int QuickTimeParser::readPLNK(Atom atom) {
PanoLinkTable &pLinkTable = _panoTrack->panoSamples.back().linkTable;
_fd->readUint16BE(); // padding
int16 numLinks = _fd->readSint16BE();
pLinkTable.links.resize(numLinks);
for (int i = 0; i < numLinks; i++) {
pLinkTable.links[i].id = _fd->readUint16BE();
_fd->readUint16BE(); // reserved
_fd->readUint64BE(); // reserved2 + reserved3
pLinkTable.links[i].toNodeID = _fd->readUint32BE();
_fd->skip(12); // reserved4
pLinkTable.links[i].toHPan = readAppleFloatField(_fd);
pLinkTable.links[i].toVPan = readAppleFloatField(_fd);
pLinkTable.links[i].toZoom = readAppleFloatField(_fd);
_fd->readUint64BE(); // reserved5 + reserved6
pLinkTable.links[i].nameStrOffset = _fd->readSint32BE();
pLinkTable.links[i].commentStrOffset = _fd->readSint32BE();
}
return 0;
}
int QuickTimeParser::readPNAV(Atom atom) {
PanoNavigationTable &pLinkTable = _panoTrack->panoSamples.back().navTable;
_fd->readUint16BE(); // padding
int16 numNavs = _fd->readSint16BE();
pLinkTable.navs.resize(numNavs);
for (int i = 0; i < numNavs; i++) {
pLinkTable.navs[i].id = _fd->readUint16BE();
_fd->readUint16BE(); // reserved
_fd->readUint32BE(); // reserved2
pLinkTable.navs[i].rect.top = _fd->readSint16BE();
pLinkTable.navs[i].rect.left = _fd->readSint16BE();
pLinkTable.navs[i].rect.bottom = _fd->readSint16BE();
pLinkTable.navs[i].rect.right = _fd->readSint16BE();
_fd->readSint32BE(); // reserved3
pLinkTable.navs[i].nameStrOffset = _fd->readSint32BE();
pLinkTable.navs[i].commentStrOffset = _fd->readSint32BE();
}
return 0;
}
void QuickTimeParser::close() {
for (uint32 i = 0; i < _tracks.size(); i++)
delete _tracks[i];
_tracks.clear();
if (_disposeFileHandle == DisposeAfterUse::YES)
delete _fd;
_fd = nullptr;
}
void QuickTimeParser::flattenEditLists() {
// This flattens the movie edit list, collapsing everything into a single edit.
// This is necessary to work around sound popping in Obsidian on certain movies:
//
// For some reason, numerous movies have audio tracks with edit lists consisting
// off numerous 0.5-second duration chunks, which is 22050 audio examples at the
// 44100Hz media rate, but the edit media times are spaced out 22080 apart.
//
// The QuickTime File Format reference seems to suggest that this means the audio
// would skip ahead 30 samples every half-second, which is what the playback code
// currently does, and that causes audible popping in some movies (such as the
// cube maze greeter vidbot when she says "Take take take, that's all you ever do!"
// after repeatedly visiting her.)
//
// Other players seem to just play the audio track chunks consecutively without the
// 30-sample skips, which produces the correct results, not sure why.
//
//
// We also need to account for mixed silent and non-silent tracks. In Obsidian's
// Japanese localization, the vidbot that you talk to at the end of the maze (asset
// 4375) has a brief silent edit followed by the actual audio track. If we
// collapse the audio track into the silent edit, then it causes the entire track
// to be silent.
for (Track *track : _tracks) {
if (track->editList.size() >= 2) {
Common::Array<EditListEntry> newEdits;
for (const EditListEntry &curEdit : track->editList) {
if (newEdits.size() == 0) {
newEdits.push_back(curEdit);
continue;
}
EditListEntry &prevEdit = newEdits.back();
bool prevIsSilent = (prevEdit.mediaTime == -1);
bool currentIsSilent = (curEdit.mediaTime == -1);
if (prevIsSilent != currentIsSilent) {
newEdits.push_back(curEdit);
continue;
} else
prevEdit.trackDuration += curEdit.trackDuration;
}
track->editList = Common::move(newEdits);
}
}
}
QuickTimeParser::SampleDesc::SampleDesc(Track *parentTrack, uint32 codecTag) {
_parentTrack = parentTrack;
_codecTag = codecTag;
_extraData = nullptr;
_objectTypeMP4 = 0;
}
QuickTimeParser::SampleDesc::~SampleDesc() {
delete _extraData;
}
QuickTimeParser::Track::Track() {
chunkCount = 0;
chunkOffsets = nullptr;
timeToSampleCount = 0;
timeToSample = nullptr;
sampleToChunkCount = 0;
sampleToChunk = nullptr;
sampleSize = 0;
sampleCount = 0;
sampleSizes = nullptr;
keyframeCount = 0;
keyframes = nullptr;
timeScale = 0;
width = 0;
height = 0;
codecType = CODEC_TYPE_MOV_OTHER;
frameCount = 0;
duration = 0;
mediaDuration = 0;
nlvlFrom = -1;
nlvlTo = -1;
graphicsMode = GraphicsMode::COPY;
opcolor[0] = opcolor[1] = opcolor[2] = 0;
soundBalance = 0;
}
String QuickTimeParser::PanoStringTable::getString(int32 offset) const {
offset -= 8;
if (offset < 0)
return String();
int32 str_start = offset + 1;
int32 str_length = strings[offset];
return strings.substr(str_start, str_length);
}
QuickTimeParser::Track::~Track() {
delete[] chunkOffsets;
delete[] timeToSample;
delete[] sampleToChunk;
delete[] sampleSizes;
delete[] keyframes;
for (uint32 i = 0; i < sampleDescs.size(); i++)
delete sampleDescs[i];
}
} // End of namespace Video
|