Skip to content

Commit 672669a

Browse files
committed
fix crash, get closer to up-to-date for 64-bit
1 parent b65cf18 commit 672669a

7 files changed

+58
-47
lines changed

macosx/makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
# limitations under the License.
1616
#
1717

18-
#CFLAGS = -g -DLITTLEENDIAN -Wno-multichar
19-
CFLAGS = -gdwarf-2 -Wno-multichar -DUSE_STRCASECMP -arch i386
18+
#CFLAGS = -g -DLITTLEENDIAN -Wno-multichar -arch i386
19+
CFLAGS = -gdwarf-2 -Wno-multichar -DUSE_STRCASECMP
2020
PreprocessOptions = "-d forPublicRelease -d no3GP"
2121

2222
SRCDIR = ../src

src/ValidateAtomList.c

+12-5
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ OSErr ValidateFileAtoms( atomOffsetEntry *aoe, void *refcon )
125125
BAILIFERR( FindAtomOffsets( aoe, minOffset, maxOffset, &cnt, &list ) );
126126

127127
// Process 'ftyp' atom
128-
128+
129129
atomerr = ValidateAtomOfType( 'ftyp', kTypeAtomFlagMustHaveOne | kTypeAtomFlagCanHaveAtMostOne | kTypeAtomFlagMustBeFirst,
130130
Validate_ftyp_Atom, cnt, list, nil );
131131
if (!err) err = atomerr;
@@ -1048,7 +1048,7 @@ OSErr Validate_moov_Atom( atomOffsetEntry *aoe, void *refcon )
10481048
if (entry->type == 'trak') {
10491049
++(mir->numTIRs);
10501050
atomerr = Get_trak_Type(entry, &(mir->tirList[thisTrakIndex]));
1051-
entry->refconOverride = (long)&(mir->tirList[thisTrakIndex]);
1051+
entry->refconOverride = (void*)&(mir->tirList[thisTrakIndex]);
10521052
++thisTrakIndex;
10531053
}
10541054
}
@@ -1162,6 +1162,7 @@ OSErr Validate_moov_Atom( atomOffsetEntry *aoe, void *refcon )
11621162
// if that is beyond the highest chunk end we have seen, we append it; otherwise (the rare case)
11631163
// we insert it into the sorted list. this gives us a rapid check and an output sorted list without
11641164
// an n-squared overlap check and without a post-sort
1165+
//if (mir->numTIRs > 0)
11651166
{
11661167
UInt32 totalChunks = 0;
11671168
TrackInfoRec *tir;
@@ -1187,7 +1188,7 @@ OSErr Validate_moov_Atom( atomOffsetEntry *aoe, void *refcon )
11871188

11881189
}
11891190
BAILIFNULL( corp = calloc(totalChunks,sizeof(chunkOverlapRec)), allocFailedErr );
1190-
1191+
11911192
highwatermark = 0; // the highest chunk end seen
11921193

11931194
do { // until we have processed all chunks of all tracks
@@ -1211,8 +1212,11 @@ OSErr Validate_moov_Atom( atomOffsetEntry *aoe, void *refcon )
12111212
}
12121213
}
12131214
}
1214-
if (lowest == -1)
1215+
1216+
if (lowest == -1) {
12151217
errprint("aargh: program error!!!\n");
1218+
BAILIFERR( programErr );
1219+
}
12161220

12171221
tir = &(mir->tirList[lowest]);
12181222
BAILIFERR( GetChunkOffsetSize(tir, trk[lowest].chunk_num, &chunkOffset, &chunkSize, nil) );
@@ -1223,7 +1227,10 @@ OSErr Validate_moov_Atom( atomOffsetEntry *aoe, void *refcon )
12231227
}
12241228
chunkStop = chunkOffset + chunkSize -1;
12251229

1226-
if (chunkOffset != low_offset) errprint("Aargh! program error\n");
1230+
if (chunkOffset != low_offset) {
1231+
errprint("Aargh! program error\n");
1232+
BAILIFERR( programErr );
1233+
}
12271234

12281235
if (chunkOffset >= vg.inMaxOffset)
12291236
{

src/ValidateAtoms.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ OSErr Validate_iods_Atom( atomOffsetEntry *aoe, void *refcon )
7272
UInt32 flags;
7373
UInt64 offset;
7474
Ptr odDataP = nil;
75-
unsigned long odSize;
75+
UInt32 odSize;
7676

7777
// Get version/flags
7878
BAILIFERR( GetFullAtomVersionFlags( aoe, &version, &flags, &offset ) );
@@ -100,10 +100,10 @@ typedef struct MovieHeaderCommonRecord {
100100
Fixed preferredRate; // must be 1.0 for mp4
101101

102102
SInt16 preferredVolume; // must be 1.0 for mp4
103-
short reserved1; // must be 0
103+
int16_t reserved1; // must be 0
104104

105-
long preferredLong1; // must be 0 for mp4
106-
long preferredLong2; // must be 0 for mp4
105+
uint32_t preferredLong1; // must be 0 for mp4
106+
uint32_t preferredLong2; // must be 0 for mp4
107107

108108
MatrixRecord matrix; // must be identity for mp4
109109

@@ -116,7 +116,7 @@ typedef struct MovieHeaderCommonRecord {
116116
TimeValue selectionDuration; // must be 0 for mp4
117117
TimeValue currentTime; // must be 0 for mp4
118118

119-
long nextTrackID;
119+
uint32_t nextTrackID;
120120
} MovieHeaderCommonRecord;
121121

122122
typedef struct MovieHeaderVers0Record {
@@ -2425,7 +2425,7 @@ OSErr Validate_ESDAtom( atomOffsetEntry *aoe, void *refcon, ValidateBitstreamPro
24252425
UInt32 flags;
24262426
UInt64 offset;
24272427
Ptr esDataP = nil;
2428-
unsigned long esSize;
2428+
UInt32 esSize;
24292429
BitBuffer bb;
24302430

24312431
atomprint("<ESD"); vg.tabcnt++;
@@ -2645,7 +2645,7 @@ OSErr Validate_m4ds_Atom( atomOffsetEntry *aoe, void *refcon, char *esName )
26452645
OSErr err = noErr;
26462646
UInt64 offset;
26472647
Ptr esDataP = nil;
2648-
unsigned long esSize;
2648+
UInt32 esSize;
26492649
BitBuffer bb;
26502650

26512651
atomprint("<m4ds>\n"); vg.tabcnt++;
@@ -2813,9 +2813,9 @@ OSErr Validate_loci_Atom( atomOffsetEntry *aoe, void *refcon )
28132813

28142814
atomprint("role=\"%d\"\n", role );
28152815

2816-
atomprint("longitude=\"%d.%d\"\n", lngi >> 16, ((UInt32) lngi) && 0xFFFF );
2817-
atomprint("latitude=\"%d.%d\"\n", lati >> 16, ((UInt32) lati) && 0xFFFF );
2818-
atomprint("altitude=\"%d.%d\"\n", alti >> 16, ((UInt32) alti) && 0xFFFF );
2816+
atomprint("longitude=\"%1.5f\"\n", lngi / 65536.0 );
2817+
atomprint("latitude=\"%1.5f\"\n", lati / 65536.0 );
2818+
atomprint("altitude=\"%1.5f\"\n", alti / 65536.0 );
28192819

28202820

28212821
BAILIFERR( GetFileUTFString( aoe, &noticeP, offset, aoe->maxOffset - offset, &offset ) );

src/ValidateBitStreams.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -1732,6 +1732,7 @@ OSErr Validate_level_IDC( UInt8 profile, UInt8 level, UInt8 constraint_set3_flag
17321732
else if (constraint_set3_flag == 1)
17331733
warnprint("Warning: constraint_set3_flag==1 when it seems to be reserved to zero\n");
17341734
}
1735+
return noErr;
17351736
}
17361737

17371738
OSErr Validate_AVCConfigRecord( BitBuffer *bb, void *refcon )
@@ -1780,7 +1781,7 @@ OSErr Validate_AVCConfigRecord( BitBuffer *bb, void *refcon )
17801781
avcHeader.lengthsize = GetBits(bb, 8, &err); if (err) goto bail;
17811782

17821783
if ((avcHeader.lengthsize & 0xFC) != 0xFC) {
1783-
errprint( "reserved 1 bits are not 1 %x", avcHeader.lengthsize && 0xFC );
1784+
errprint( "reserved 1 bits are not 1 %x", avcHeader.lengthsize & 0xFC );
17841785
}
17851786
avcHeader.lengthsize = avcHeader.lengthsize & 3;
17861787
codec_specific[0] = avcHeader.lengthsize + 1;
@@ -1791,7 +1792,7 @@ OSErr Validate_AVCConfigRecord( BitBuffer *bb, void *refcon )
17911792

17921793
avcHeader.sps_count = GetBits(bb, 8, &err); if (err) goto bail;
17931794
if ((avcHeader.sps_count & 0xE0) != 0xE0) {
1794-
errprint( "reserved 1 bits are not 1 %x", avcHeader.sps_count && 0xE0 );
1795+
errprint( "reserved 1 bits are not 1 %x", avcHeader.sps_count & 0xE0 );
17951796
}
17961797
avcHeader.sps_count = avcHeader.sps_count & 0x1F;
17971798
atomprint("sps_count=\"%d\"\n", avcHeader.sps_count );
@@ -2916,7 +2917,7 @@ OSErr CheckValuesInContext( UInt32 bufferSize, UInt32 maxBitrate, UInt32 avgBitr
29162917
break;
29172918

29182919
default:
2919-
sprintf(profString,"WARNING: unknown visual profile= %lu\n",p_vsc->profileLevelInd);
2920+
sprintf(profString,"WARNING: unknown visual profile= %lu\n",(unsigned long) p_vsc->profileLevelInd);
29202921
if( p_vsc->profileLevelInd == 255 ){
29212922
err = 1;
29222923
errprint("invalid visual profile= %lu\n",p_vsc->profileLevelInd);

src/ValidateHints.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ static OSErr Validate_Data_Entry( HintInfoRec *hir, char *inEntry )
664664
goto bail;
665665
}
666666

667-
BAILIFERR( err = get_track_sample(thisTIR, sampleNum, &sampleData, &sampleDataLength, NULL) );
667+
BAILIFERR( get_track_sample(thisTIR, sampleNum, &sampleData, &sampleDataLength, NULL) );
668668
if (offset+length >sampleDataLength) {
669669
errprint("[2] data entry - offset(%d) + length(%d) > samplelength (%d)\n", offset, length, sampleDataLength);
670670
err = paramErr;
@@ -735,7 +735,7 @@ static OSErr Validate_rfc3016_Payload( char *inPayload, UInt32 inLength, void *i
735735

736736
BitBuffer_Init(&bb, (void *)inPayload, inLength);
737737
if (BitBuffer_IsVideoStartCode(&bb)) {
738-
BAILIFERR( err = BitBuffer_GetVideoStartCode(&bb, &startCodeTag) );
738+
BAILIFERR( BitBuffer_GetVideoStartCode(&bb, &startCodeTag) );
739739
switch (startCodeTag) {
740740
case kMPEG4StartCode_VOS:
741741
case kMPEG4StartCode_GOV:
@@ -1748,7 +1748,7 @@ static OSErr Validate_isma_attribute( HintInfoRec *hir, char *inValue)
17481748
{
17491749
#pragma unused(hir)
17501750
OSErr err = noErr;
1751-
SInt32 profile, i;
1751+
int profile, i;
17521752
float lowest, authored;
17531753

17541754
i = sscanf(inValue,"%d,%f,%f",&profile,&lowest,&authored);
@@ -2232,9 +2232,9 @@ static OSErr get_track_sample(TrackInfoRec *tir, UInt32 inSampleNum, Ptr *dataOu
22322232
UInt64 sampleOffset;
22332233

22342234
if (tir != NULL) {
2235-
BAILIFERR( err = GetSampleOffsetSize( tir, inSampleNum, &sampleOffset, sizeOut, sampleDescriptionIndexOut ) );
2235+
BAILIFERR( GetSampleOffsetSize( tir, inSampleNum, &sampleOffset, sizeOut, sampleDescriptionIndexOut ) );
22362236
BAILIFNIL( *dataOut = malloc(*sizeOut), allocFailedErr );
2237-
BAILIFERR( err = GetFileData( vg.fileaoe, *dataOut, sampleOffset, *sizeOut, nil ) );
2237+
BAILIFERR( GetFileData( vg.fileaoe, *dataOut, sampleOffset, *sizeOut, nil ) );
22382238
}
22392239
bail:
22402240
return err;

src/ValidateMP4.c

+11-10
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,8 @@ void atomprintnotab(const char *formatStr, ...)
382382
va_list ap;
383383
va_start(ap, formatStr);
384384

385-
if (vg.printatom) {
385+
//if (vg.printatom)
386+
{
386387
vfprintf( _stdout, formatStr, (void *)ap );
387388
}
388389

@@ -631,9 +632,9 @@ char *int64toxstr(UInt64 num)
631632
hi = num>>32;
632633
lo = num&(0xffffffff);
633634
if (hi) {
634-
sprintf(str,"0x%lx%8.8lx",hi,lo);
635+
sprintf(str,"0x%lx%8.8lx",(unsigned long) hi,(unsigned long) lo);
635636
} else {
636-
sprintf(str,"0x%lx",lo);
637+
sprintf(str,"0x%lx",(unsigned long) lo);
637638
}
638639
return str;
639640
}
@@ -645,9 +646,9 @@ char *int64toxstr_r(UInt64 num, char * str)
645646
hi = num>>32;
646647
lo = num&(0xffffffff);
647648
if (hi) {
648-
sprintf(str,"0x%lx%8.8lx",hi,lo);
649+
sprintf(str,"0x%lx%8.8lx",(unsigned long) hi,(unsigned long) lo);
649650
} else {
650-
sprintf(str,"0x%lx",lo);
651+
sprintf(str,"0x%lx",(unsigned long) lo);
651652
}
652653
return str;
653654
}
@@ -663,9 +664,9 @@ char *int64todstr(UInt64 num)
663664
lo = num&(0xffffffff);
664665

665666
if (hi)
666-
sprintf(str,"%ld%8.8ld",hi,lo);
667+
sprintf(str,"%ld%8.8ld",(unsigned long) hi,(unsigned long) lo);
667668
else
668-
sprintf(str,"%ld",lo);
669+
sprintf(str,"%ld",(unsigned long) lo);
669670
return str;
670671
}
671672

@@ -678,9 +679,9 @@ char *int64todstr_r(UInt64 num, char * str)
678679
lo = num&(0xffffffff);
679680

680681
if (hi)
681-
sprintf(str,"%ld%8.8ld",hi,lo);
682+
sprintf(str,"%ld%8.8ld",(unsigned long) hi,(unsigned long) lo);
682683
else
683-
sprintf(str,"%ld",lo);
684+
sprintf(str,"%ld",(unsigned long) lo);
684685
return str;
685686
}
686687

@@ -689,7 +690,7 @@ char *langtodstr(UInt16 num)
689690
{
690691
static char str[4];
691692

692-
str[4] = 0;
693+
str[3] = 0;
693694

694695
if (num==0) {
695696
str[0] = str[1] = str[2] = ' ';

src/ValidateMP4.h

+14-12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ limitations under the License.
2222
#include <stdlib.h>
2323
#include <ctype.h>
2424
#include <string.h>
25+
#include <stdint.h>
2526

2627
#if defined(__GNUC__) && ( defined(__APPLE_CPP__) || defined(__APPLE_CC__) || defined(__MACOS_CLASSIC__) )
2728
#if defined(__i386__) || defined(__x86_64__)
@@ -49,7 +50,7 @@ limitations under the License.
4950
#endif
5051

5152
typedef char *Ptr;
52-
typedef unsigned long OSType;
53+
typedef uint32_t OSType;
5354
typedef unsigned char Boolean;
5455
typedef short OSErr;
5556

@@ -63,21 +64,21 @@ enum {
6364
kSkipUnknownAtoms = 1L<<0
6465
};
6566

66-
typedef unsigned char UInt8;
67-
typedef char SInt8;
68-
typedef long SInt32;
69-
typedef unsigned long UInt32;
70-
typedef short SInt16;
71-
typedef unsigned short UInt16;
67+
typedef uint8_t UInt8;
68+
typedef int8_t SInt8;
69+
typedef int32_t SInt32;
70+
typedef uint32_t UInt32;
71+
typedef int16_t SInt16;
72+
typedef uint16_t UInt16;
7273
typedef UInt32 UnsignedFixed;
7374

7475
typedef unsigned char uuidType[16]; // 128-bit uuid (guid)
7576
#ifdef _MSC_VER
7677
typedef unsigned __int64 UInt64;
7778
typedef __int64 SInt64;
7879
#else
79-
typedef unsigned long long UInt64;
80-
typedef long long SInt64;
80+
typedef uint64_t UInt64;
81+
typedef int64_t SInt64;
8182
#endif
8283
typedef UInt32 TimeValue;
8384
typedef UInt32 PriorityType;
@@ -111,7 +112,7 @@ typedef struct atomOffsetEntry {
111112
UInt32 atomStartSize; // size of id & size info, so it is easy to skip
112113

113114
UInt32 aoeflags; // used for processing
114-
UInt32 refconOverride; // used for processing
115+
void* refconOverride; // used for processing
115116
} atomOffsetEntry;
116117

117118
enum {
@@ -132,7 +133,8 @@ enum {
132133
badAtomErr = -2024,
133134
atomOverRunErr = -2025,
134135
badPublicMovieAtom = -2026,
135-
dataSharedErr = -2027
136+
dataSharedErr = -2027,
137+
programErr = -2028
136138
};
137139

138140
typedef struct {
@@ -389,7 +391,7 @@ typedef struct {
389391
extern ValidateGlobals vg;
390392

391393
typedef struct AtomSizeType {
392-
unsigned long atomSize;
394+
UInt32 atomSize;
393395
OSType atomType;
394396
} AtomSizeType;
395397

0 commit comments

Comments
 (0)