diff --git a/Dockerfile b/Dockerfile index 5bc205da..72618f13 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ RUN apt -y install \ apache2 apache2-doc php php-dev php-xml php-curl php-xdebug libapache2-mod-php \ python2.7 \ openjdk-8-jdk ant \ - gcc-multilib g++-multilib + g++ RUN curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py RUN python2.7 get-pip.py RUN pip2 install matplotlib diff --git a/ISOSegmentValidator/public/linux/Makefile b/ISOSegmentValidator/public/linux/Makefile index 746b4413..fb045142 100755 --- a/ISOSegmentValidator/public/linux/Makefile +++ b/ISOSegmentValidator/public/linux/Makefile @@ -8,15 +8,15 @@ NAME= ValidateMP4 -### include debug information: 1=yes, 0=no -DBG=1 -SAN=0 -COV=0 +### include debug information: 1=yes, 'empty'=no (don't set to 0) +DBG= +SAN= +COV= FLAGS+=-Wall -Wextra -Werror ## TODO: remove these -FLAGS+=-Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-label -Wno-unused-parameter -Wno-int-to-pointer-cast -Wno-sequence-point -Wno-stringop-truncation +FLAGS+=-Wno-unused-result -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-label -Wno-unused-parameter -Wno-int-to-pointer-cast -Wno-sequence-point -Wno-stringop-truncation #compatibility=-static-libstdc++ @@ -33,9 +33,9 @@ CC= $(shell which g++) FLAGS+=-std=c++11 -ffloat-store -Wall -I$(INCDIR) -DLITTLEENDIAN -Wno-multichar -Wno-unknown-pragmas -fpermissive -Wno-write-strings -fno-stack-protector ifdef COV -LIBS= -lgcov #-lcurl -FLAGS+=-fprofile-generate -fprofile-arcs -ftest-coverage -Wl,-lgcov -LDFLAGS+=" -lgcov --coverage -WL -lgcov" +OBJDIR=$(BINDIR) +LIBS= -lgcov +FLAGS+=--coverage -fno-inline -fno-elide-constructors -fprofile-generate -fprofile-arcs -ftest-coverage -Wl,-lgcov endif ifdef SAN @@ -49,7 +49,7 @@ SUFFIX= #.dbg FLAGS+= -g else SUFFIX= -FLAGS+= -O2 -DGCC +FLAGS+= -Os -DGCC endif ifdef COV @@ -64,7 +64,7 @@ OBJ= $(SRC:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o$(SUFFIX)) BIN= $(BINDIR)/$(NAME)$(SUFFIX).exe -default: depend bin tags +default: depend $(BINDIR) $(OBJDIR) binaries tags dependencies: @echo "" >dependencies @@ -80,10 +80,10 @@ tags: @echo update tag table @ctags $(INCDIR)/*.h $(SRCDIR)/*.cpp -bin: $(OBJ) +binaries: $(OBJ) @echo @echo 'creating binary "$(BIN)"' - @$(CC) $(compatibility) -o $(BIN) $(OBJ) $(LIBS) + @$(CC) $(compatibility) -o $(BIN) $(OBJ) $(LIBS) $(LDFLAGS) @echo '... done' @echo @@ -93,6 +93,12 @@ depend: @$(SHELL) -ec '$(CC) -MM $(CFLAGS) -I$(INCDIR) $(SRC) | sed '\''s@\(.*\)\.o[ :]@$(OBJDIR)/\1.o$(SUFFIX):@g'\'' >$(DEPEND)' @echo +$(OBJDIR): + mkdir -p $(OBJDIR) + +$(BINDIR): + mkdir -p $(BINDIR) + $(OBJDIR)/%.o$(SUFFIX): $(SRCDIR)/%.cpp @echo 'compiling object file "$@" ...' @$(CC) $(compatibility) -c -o $@ $(FLAGS) $< diff --git a/ISOSegmentValidator/public/linux/bin/Assemble b/ISOSegmentValidator/public/linux/bin/Assemble deleted file mode 100755 index f184fa2a..00000000 --- a/ISOSegmentValidator/public/linux/bin/Assemble +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -mergedFileName="tempMerged.mp4" -tempMergedFile="tempMerged2.mp4" -segmentSizeInfoFile="segmentSizeInfoFile.txt" - -if [ $# -lt 2 ] -then - echo "Usage: Assemble [1/0] (initialization segment), segment 1, segment 2,..." - echo "1: first file is an initialization segment, 0 otherwise." - exit -fi - -if [ $1 -eq 1 ] -then - index=0 -else - index=1 -fi - -shift - -rm -f $mergedFileName -rm -f $segmentSizeInfoFile - -touch $mergedFileName - -while [ $# -ne 0 ] - do - - cat $mergedFileName $1 > $tempMergedFile - - rm $mergedFileName - - mv $tempMergedFile $mergedFileName - - fileSize=`stat -c %s $1` - echo $index $fileSize >> $segmentSizeInfoFile - index=`expr $index + 1` - shift - -done - diff --git a/ISOSegmentValidator/public/linux/bin/ValidateMP4.exe b/ISOSegmentValidator/public/linux/bin/ValidateMP4.exe deleted file mode 100755 index 0abe56a6..00000000 Binary files a/ISOSegmentValidator/public/linux/bin/ValidateMP4.exe and /dev/null differ diff --git a/ISOSegmentValidator/public/linux/dependencies b/ISOSegmentValidator/public/linux/dependencies deleted file mode 100755 index 3c241bb9..00000000 --- a/ISOSegmentValidator/public/linux/dependencies +++ /dev/null @@ -1,22 +0,0 @@ -./obj/ValidateBitStreams.o: ../src/ValidateBitStreams.cpp ../src/ValidateMP4.h \ - ../src/EndianMP4.h -./obj/ValidateMdatAtom.o: ../src/ValidateMdatAtom.cpp ../src/ValidateMP4.h \ - ../src/EndianMP4.h -./obj/ValidateDolby.o: ../src/ValidateDolby.cpp ../src/ValidateMP4.h \ - ../src/EndianMP4.h -./obj/PostprocessData.o: ../src/PostprocessData.cpp ../src/HelperMethods.h \ - ../src/ValidateMP4.h ../src/EndianMP4.h ../src/PostprocessData.h -./obj/ValidateHints.o: ../src/ValidateHints.cpp ../src/ValidateMP4.h \ - ../src/EndianMP4.h -./obj/HelperMethods.o: ../src/HelperMethods.cpp ../src/HelperMethods.h \ - ../src/ValidateMP4.h ../src/EndianMP4.h ../src/PostprocessData.h -./obj/ValidateAtomList.o: ../src/ValidateAtomList.cpp ../src/ValidateMP4.h \ - ../src/EndianMP4.h ../src/HelperMethods.h ../src/PostprocessData.h -./obj/ValidateMP4.o: ../src/ValidateMP4.cpp ../src/ValidateMP4.h \ - ../src/EndianMP4.h -./obj/ValidateBits.o: ../src/ValidateBits.cpp ../src/ValidateMP4.h \ - ../src/EndianMP4.h -./obj/ValidateAtoms.o: ../src/ValidateAtoms.cpp ../src/ValidateMP4.h \ - ../src/EndianMP4.h -./obj/ValidateFileIO.o: ../src/ValidateFileIO.cpp ../src/ValidateMP4.h \ - ../src/EndianMP4.h diff --git a/ISOSegmentValidator/public/linux/obj/HelperMethods.o b/ISOSegmentValidator/public/linux/obj/HelperMethods.o deleted file mode 100644 index 9a047287..00000000 Binary files a/ISOSegmentValidator/public/linux/obj/HelperMethods.o and /dev/null differ diff --git a/ISOSegmentValidator/public/linux/obj/PostprocessData.o b/ISOSegmentValidator/public/linux/obj/PostprocessData.o deleted file mode 100644 index 90016f61..00000000 Binary files a/ISOSegmentValidator/public/linux/obj/PostprocessData.o and /dev/null differ diff --git a/ISOSegmentValidator/public/linux/obj/ValidateAtomList.o b/ISOSegmentValidator/public/linux/obj/ValidateAtomList.o deleted file mode 100644 index 9fd936d4..00000000 Binary files a/ISOSegmentValidator/public/linux/obj/ValidateAtomList.o and /dev/null differ diff --git a/ISOSegmentValidator/public/linux/obj/ValidateAtoms.o b/ISOSegmentValidator/public/linux/obj/ValidateAtoms.o deleted file mode 100644 index db51e114..00000000 Binary files a/ISOSegmentValidator/public/linux/obj/ValidateAtoms.o and /dev/null differ diff --git a/ISOSegmentValidator/public/linux/obj/ValidateBitStreams.o b/ISOSegmentValidator/public/linux/obj/ValidateBitStreams.o deleted file mode 100644 index 07b4add0..00000000 Binary files a/ISOSegmentValidator/public/linux/obj/ValidateBitStreams.o and /dev/null differ diff --git a/ISOSegmentValidator/public/linux/obj/ValidateBits.o b/ISOSegmentValidator/public/linux/obj/ValidateBits.o deleted file mode 100644 index 2000e764..00000000 Binary files a/ISOSegmentValidator/public/linux/obj/ValidateBits.o and /dev/null differ diff --git a/ISOSegmentValidator/public/linux/obj/ValidateDolby.o b/ISOSegmentValidator/public/linux/obj/ValidateDolby.o deleted file mode 100644 index c37c1511..00000000 Binary files a/ISOSegmentValidator/public/linux/obj/ValidateDolby.o and /dev/null differ diff --git a/ISOSegmentValidator/public/linux/obj/ValidateFileIO.o b/ISOSegmentValidator/public/linux/obj/ValidateFileIO.o deleted file mode 100644 index dface770..00000000 Binary files a/ISOSegmentValidator/public/linux/obj/ValidateFileIO.o and /dev/null differ diff --git a/ISOSegmentValidator/public/linux/obj/ValidateHints.o b/ISOSegmentValidator/public/linux/obj/ValidateHints.o deleted file mode 100644 index d2297e1b..00000000 Binary files a/ISOSegmentValidator/public/linux/obj/ValidateHints.o and /dev/null differ diff --git a/ISOSegmentValidator/public/linux/obj/ValidateMP4.o b/ISOSegmentValidator/public/linux/obj/ValidateMP4.o deleted file mode 100644 index 597d1b7b..00000000 Binary files a/ISOSegmentValidator/public/linux/obj/ValidateMP4.o and /dev/null differ diff --git a/ISOSegmentValidator/public/linux/obj/ValidateMdatAtom.o b/ISOSegmentValidator/public/linux/obj/ValidateMdatAtom.o deleted file mode 100644 index ad006cb7..00000000 Binary files a/ISOSegmentValidator/public/linux/obj/ValidateMdatAtom.o and /dev/null differ diff --git a/ISOSegmentValidator/public/linux/tags b/ISOSegmentValidator/public/linux/tags deleted file mode 100755 index d01d39bc..00000000 --- a/ISOSegmentValidator/public/linux/tags +++ /dev/null @@ -1,6 +0,0 @@ -!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ -!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ -!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/ -!_TAG_PROGRAM_NAME Exuberant Ctags // -!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ -!_TAG_PROGRAM_VERSION 5.8 // diff --git a/ISOSegmentValidator/public/src/EndianMP4.h b/ISOSegmentValidator/public/src/EndianMP4.h index cfe7864c..e30f463a 100755 --- a/ISOSegmentValidator/public/src/EndianMP4.h +++ b/ISOSegmentValidator/public/src/EndianMP4.h @@ -60,7 +60,7 @@ extern "C" { For example, to convert a Big Endian 32-bit unsigned integer to the current native format use: - long i = EndianU32_BtoN(data); + SInt32 i = EndianU32_BtoN(data); This file is set up so that the function macro to nothing when the target runtime already is the desired format (e.g. on Big Endian machines, EndianU32_BtoN() macros away). @@ -321,7 +321,7 @@ typedef OSType BigEndianOSType; /* - Implement ÅLtoB and ÅBtoL + Implement �LtoB and �BtoL */ #define EndianS16_LtoB(value) ((SInt16)Endian16_Swap(value)) #define EndianS16_BtoL(value) ((SInt16)Endian16_Swap(value)) @@ -339,7 +339,7 @@ typedef OSType BigEndianOSType; /* - Implement low level Å_Swap functions. + Implement low level �_Swap functions. extern UInt16 Endian16_Swap(UInt16 value); extern UInt32 Endian32_Swap(UInt32 value); diff --git a/ISOSegmentValidator/public/src/HelperMethods.cpp b/ISOSegmentValidator/public/src/HelperMethods.cpp index d910be16..d23a8943 100755 --- a/ISOSegmentValidator/public/src/HelperMethods.cpp +++ b/ISOSegmentValidator/public/src/HelperMethods.cpp @@ -25,19 +25,19 @@ limitations under the License. //========================================================================================== int FindAtomOffsets( atomOffsetEntry *aoe, UInt64 minOffset, UInt64 maxOffset, - long *atomCountOut, atomOffsetEntry **atomOffsetsOut ) + SInt32 *atomCountOut, atomOffsetEntry **atomOffsetsOut ) { int err = noErr; - long cnt = 0; + SInt32 cnt = 0; atomOffsetEntry *atomOffsets = nil; - long max = 20; + SInt32 max = 20; startAtomType startAtom; UInt64 largeSize; uuidType uuid; UInt64 curOffset = minOffset; - long minAtomSize; + SInt32 minAtomSize; - printf ("<%s> : min %08llX max %08llX\n", __FUNCTION__, minOffset, maxOffset); + printf ("<%s> : min %08lX max %08lX\n", __FUNCTION__, minOffset, maxOffset); BAILIFNULL( atomOffsets = (atomOffsetEntry *)calloc( max, sizeof(atomOffsetEntry)), allocFailedErr ); @@ -61,7 +61,7 @@ int FindAtomOffsets( atomOffsetEntry *aoe, UInt64 minOffset, UInt64 maxOffset, atom_name[1] = ((char*)(&startAtom.type))[2]; atom_name[2] = ((char*)(&startAtom.type))[1]; atom_name[3] = ((char*)(&startAtom.type))[0]; - printf ("atom_name <%s> offset %08llX\n",atom_name, curOffset - sizeof(startAtom.type)); + printf ("atom_name <%s> offset %08lX\n",atom_name, curOffset - sizeof(startAtom.type)); if (startAtom.type == 'uuid') { BAILIFERR( GetFileData( aoe, &uuid, curOffset, sizeof(uuid), &curOffset ) ); @@ -206,12 +206,12 @@ void logtempInfo(MovieInfoRec *mir) return; } - fprintf(leafInfoFile,"%ld\n",mir->numTIRs); + fprintf(leafInfoFile,"%u\n",mir->numTIRs); for(int i = 0 ; i < mir->numTIRs ; i++) { TrackInfoRec *tir = &(mir->tirList[i]); - fprintf(leafInfoFile,"%lu\n",tir->mediaTimeScale); + fprintf(leafInfoFile,"%u\n",tir->mediaTimeScale); } @@ -229,7 +229,7 @@ void logtempInfo(MovieInfoRec *mir) for(UInt32 j = 0 ; j < tir->numLeafs ; j++) if(tir->leafInfo[j].hasFragments) - fprintf(leafInfoFile,"%d, %llu, %llu\n",tir->leafInfo[j].firstInSegment,(UInt64)roundl(tir->leafInfo[j].earliestPresentationTime*(long double)tir->mediaTimeScale),tir->leafInfo[j].offset); + fprintf(leafInfoFile,"%d, %lu, %lu\n",tir->leafInfo[j].firstInSegment,(UInt64)roundl(tir->leafInfo[j].earliestPresentationTime*(long double)tir->mediaTimeScale),tir->leafInfo[j].offset); } fclose(leafInfoFile); @@ -247,15 +247,15 @@ void logLeafInfo(MovieInfoRec *mir) return; } - fprintf(leafInfoFile,"%lu\n",vg.accessUnitDurationNonIndexedTrack); + fprintf(leafInfoFile,"%u\n",vg.accessUnitDurationNonIndexedTrack); - fprintf(leafInfoFile,"%ld\n",mir->numTIRs); + fprintf(leafInfoFile,"%u\n",mir->numTIRs); for(int i = 0 ; i < mir->numTIRs ; i++) { TrackInfoRec *tir = &(mir->tirList[i]); - fprintf(leafInfoFile,"%lu %lu\n",tir->trackID,tir->hdlrInfo->componentSubType); + fprintf(leafInfoFile,"%u %u\n",tir->trackID,tir->hdlrInfo->componentSubType); } @@ -320,12 +320,12 @@ UInt64 GetVariableLengthData(BitBuffer *bb, UInt32 wordLength, OSErr *errout) data64 <<= wordLength; dataTemp = GetBits(bb, wordLength + 1, &err); if (err) GOTOBAIL; data64 |= (dataTemp & ~testMask); - printf ("dataTemp %llu data64 %llu testMask %llu\n", dataTemp, data64, testMask); + printf ("dataTemp %lu data64 %lu testMask %lu\n", dataTemp, data64, testMask); } while ((dataTemp & testMask) != 0); bail: - printf ("return %llu\n", data64); + printf ("return %lu\n", data64); *errout = err; return data64; } diff --git a/ISOSegmentValidator/public/src/HelperMethods.h b/ISOSegmentValidator/public/src/HelperMethods.h index 7b5f51e2..f2e203a4 100755 --- a/ISOSegmentValidator/public/src/HelperMethods.h +++ b/ISOSegmentValidator/public/src/HelperMethods.h @@ -26,7 +26,7 @@ limitations under the License. #define ABS(a) (((a) < 0) ? -(a) : (a)); int FindAtomOffsets( atomOffsetEntry *aoe, UInt64 minOffset, UInt64 maxOffset, - long *atomCountOut, atomOffsetEntry **atomOffsetsOut ); + SInt32 *atomCountOut, atomOffsetEntry **atomOffsetsOut ); TrackInfoRec * check_track( UInt32 theID ); UInt32 getTrakIndexByID(UInt32 track_ID); UInt32 getMoofIndexByOffset(MoofInfoRec *moofInfo, UInt32 numFragments, UInt64 offset); diff --git a/ISOSegmentValidator/public/src/PostprocessData.cpp b/ISOSegmentValidator/public/src/PostprocessData.cpp index 2cae7308..4aa2fa32 100755 --- a/ISOSegmentValidator/public/src/PostprocessData.cpp +++ b/ISOSegmentValidator/public/src/PostprocessData.cpp @@ -28,7 +28,7 @@ limitations under the License. #define scaleToTIR(x) ((long double)(x)/(long double)tir->mediaTimeScale) using namespace std; -void checkDASHBoxOrder(long cnt, atomOffsetEntry *list, long segmentInfoSize, bool initializationSegment, UInt64 *segmentSizes, MovieInfoRec *mir) { +void checkDASHBoxOrder(SInt32 cnt, atomOffsetEntry *list, SInt32 segmentInfoSize, bool initializationSegment, UInt64 *segmentSizes, MovieInfoRec *mir) { UInt64 offset = 0; if (initializationSegment) { @@ -73,7 +73,7 @@ void checkDASHBoxOrder(long cnt, atomOffsetEntry *list, long segmentInfoSize, bo bool fragmentInSegmentFound = false; bool moovInSegmentFound = false; - for (int j = i; list[j].offset < (offset + segmentSizes[index]); j++) { + for (int j = i; list[j].offset < (offset + segmentSizes[index]) && j < cnt; j++) { if (list[j].type == 'ftyp') { ftypFound = 1; } else if (list[j].type == 'moov') { @@ -91,18 +91,18 @@ void checkDASHBoxOrder(long cnt, atomOffsetEntry *list, long segmentInfoSize, bo if (list[j].type == 'moof') { if (j == (cnt - 1) || list[j + 1].offset >= (offset + segmentSizes[index]) || list[j + 1].type != 'mdat'){ - errprint("mdat not found following a moof in segment %d (at file absolute offset %lld), violating: ISO/IEC 23009-1:2012(E), 6.3.4.2: Each Media Segment shall contain one or more whole self-contained movie fragments. A whole, self-contained movie fragment is a movie fragment ('moof') box and a media data ('mdat') box that contains all the media samples that do not use external data references referenced by the track runs in the movie fragment box.\n", index, list[j].offset); + errprint("mdat not found following a moof in segment %d (at file absolute offset %ld), violating: ISO/IEC 23009-1:2012(E), 6.3.4.2: Each Media Segment shall contain one or more whole self-contained movie fragments. A whole, self-contained movie fragment is a movie fragment ('moof') box and a media data ('mdat') box that contains all the media samples that do not use external data references referenced by the track runs in the movie fragment box.\n", index, list[j].offset); if(vg.cmaf){ - errprint("CMAF check violated: Section 7.5.19. \"Each CMAF Fragment SHALL contain one or more Media Data Box(es)\", not found in Segment/Fragment %d (at file absolute offset %lld).\n",index, list[j].offset); - errprint("CMAF check violated: Section 7.3.2.4. \"A CMAF Fragment SHALL consist of one or more ISO Base Media segments that contains one MovieFragmentBox followed by one or more Media Data Box(es) containing the samples it references\", but mdat not found following a moof in Segment/Fragment %d (at file absolute offset %lld).\n",index, list[j].offset); + errprint("CMAF check violated: Section 7.5.19. \"Each CMAF Fragment SHALL contain one or more Media Data Box(es)\", not found in Segment/Fragment %d (at file absolute offset %ld).\n",index, list[j].offset); + errprint("CMAF check violated: Section 7.3.2.4. \"A CMAF Fragment SHALL consist of one or more ISO Base Media segments that contains one MovieFragmentBox followed by one or more Media Data Box(es) containing the samples it references\", but mdat not found following a moof in Segment/Fragment %d (at file absolute offset %ld).\n",index, list[j].offset); if(vg.cmafChunk) - errprint("CMAF check violated: Section 7.3.2.3 \"A CMAF Chunk SHALL contain one ISOBMFF segment contraints to include one MovieFragmentBox followed by one Media Data Box\", but mdat not found following a moof in Chunk %d (at file absolute offset %lld).\n", index, list[j].offset); + errprint("CMAF check violated: Section 7.3.2.3 \"A CMAF Chunk SHALL contain one ISOBMFF segment contraints to include one MovieFragmentBox followed by one Media Data Box\", but mdat not found following a moof in Chunk %d (at file absolute offset %ld).\n", index, list[j].offset); } if(vg.dashifll){ - errprint("CMAF check violated: Section 7.3.2.4. \"A CMAF Fragment SHALL consist of one or more ISO Base Media segments that contains one MovieFragmentBox followed by one or more Media Data Box(es) containing the samples it references\", but mdat not found following a moof in Segment/Fragment %d (at file absolute offset %lld).\n",index, list[j].offset); + errprint("CMAF check violated: Section 7.3.2.4. \"A CMAF Fragment SHALL consist of one or more ISO Base Media segments that contains one MovieFragmentBox followed by one or more Media Data Box(es) containing the samples it references\", but mdat not found following a moof in Segment/Fragment %d (at file absolute offset %ld).\n",index, list[j].offset); } if(vg.hbbtv) - errprint("### HbbTV check violated Section E.3.2: 'Each Segment shall consists of a whole self-contained movie fragment', mdat not found following a moof in segment %d (at file absolute offset %lld),\n", index, list[j].offset); + errprint("### HbbTV check violated Section E.3.2: 'Each Segment shall consists of a whole self-contained movie fragment', mdat not found following a moof in segment %d (at file absolute offset %ld),\n", index, list[j].offset); } fragmentInSegmentFound = true; @@ -110,21 +110,21 @@ void checkDASHBoxOrder(long cnt, atomOffsetEntry *list, long segmentInfoSize, bo if (list[j].type == 'sidx' && vg.simsInStyp[index] && !ssixFoundInSegment) { if (j == (cnt - 1) || list[j + 1].offset >= (offset + segmentSizes[index]) || list[j + 1].type != 'ssix') - errprint("ssix not found following the sidx in segment %d (at file absolute offset %lld), violating: ISO/IEC 23009-1:2012(E), 6.3.4.4: The Subsegment Index box ('ssix') shall be present and shall follow immediately after the 'sidx' box that documents the same Subsegment\n", index, list[j].offset); + errprint("ssix not found following the sidx in segment %d (at file absolute offset %ld), violating: ISO/IEC 23009-1:2012(E), 6.3.4.4: The Subsegment Index box ('ssix') shall be present and shall follow immediately after the 'sidx' box that documents the same Subsegment\n", index, list[j].offset); ssixFoundInSegment = true; } /*JLF: this is only valid for onDemand profile (8.3.3) and live (8.4.3)*/ if (fragmentInSegmentFound && (list[j].type == 'sidx' || list[j].type == 'ssix')) { if (vg.isoondemand || vg.dash264base || vg.dashifbase) { - errprint("Indexing information (sidx/ssix) found in segment %d (at file absolute offset %lld) following a moof, violating: ", index, list[j].offset); + errprint("Indexing information (sidx/ssix) found in segment %d (at file absolute offset %ld) following a moof, violating: ", index, list[j].offset); if (vg.isoondemand) errprint("ISO/IEC 23009-1:2012(E), 8.3.3: All Segment Index ('sidx') and Subsegment Index ('ssix') boxes shall be placed before any Movie Fragment ('moof') boxes\n"); else errprint("Section 3.2.3. Interoperability Point DASH264: In Media Segments, all Segment Index ('sidx') and Subsegment Index ('ssix') boxes, if present, shall be placed before any Movie Fragment ('moof') boxes.\n"); } else if (vg.isoLive) - errprint("Indexing information (sidx/ssix) found in segment %d (at file absolute offset %lld) following a moof, violating: ISO/IEC 23009-1:2012(E), 8.4.3: In Media Segments, all Segment Index ('sidx') and Subsegment Index ('ssix') boxes shall be placed before any Movie Fragment ('moof') boxes\n", index, list[j].offset); + errprint("Indexing information (sidx/ssix) found in segment %d (at file absolute offset %ld) following a moof, violating: ISO/IEC 23009-1:2012(E), 8.4.3: In Media Segments, all Segment Index ('sidx') and Subsegment Index ('ssix') boxes shall be placed before any Movie Fragment ('moof') boxes\n", index, list[j].offset); } } @@ -207,7 +207,7 @@ OSErr postprocessFragmentInfo(MovieInfoRec *mir) { for (i = 0; i < mir->numFragments; i++) { - for (long k = 0; k < mir->numTIRs; k++) { + for (SInt32 k = 0; k < mir->numTIRs; k++) { mir->moofInfo[i].tfdt[k] = mir->tirList[k].cumulatedTackFragmentDecodeTime; } @@ -241,12 +241,12 @@ OSErr postprocessFragmentInfo(MovieInfoRec *mir) { return noErr; } -void initializeLeafInfo(MovieInfoRec *mir, long numMediaSegments) { +void initializeLeafInfo(MovieInfoRec *mir, SInt32 numMediaSegments) { - for (long i = 0; i < mir->numTIRs; i++) { + for (SInt32 i = 0; i < mir->numTIRs; i++) { if (mir->tirList[i].numLeafs > 0) //Indexed { - mir->tirList[i].leafInfo = (LeafInfo *) malloc(mir->tirList[i].numLeafs * sizeof (LeafInfo)); + mir->tirList[i].leafInfo = (LeafInfo *) calloc(mir->tirList[i].numLeafs, sizeof (LeafInfo)); for (UInt32 j = 0; j < mir->tirList[i].numLeafs; j++) mir->tirList[i].leafInfo[j].segmentIndexed = true; @@ -255,7 +255,7 @@ void initializeLeafInfo(MovieInfoRec *mir, long numMediaSegments) { } else { mir->tirList[i].numLeafs = numMediaSegments; - mir->tirList[i].leafInfo = (LeafInfo *) malloc(mir->tirList[i].numLeafs * sizeof (LeafInfo)); + mir->tirList[i].leafInfo = (LeafInfo *) calloc(mir->tirList[i].numLeafs, sizeof (LeafInfo)); for (UInt32 j = 0; j < mir->tirList[i].numLeafs; j++) mir->tirList[i].leafInfo[j].segmentIndexed = false; @@ -280,7 +280,7 @@ void initializeLeafInfo(MovieInfoRec *mir, long numMediaSegments) { mir->tirList[i].leafInfo[mediaSegmentNumber - 1].offset = mir->moofInfo[k - 1].offset; } - if ((long) mediaSegmentNumber == (numMediaSegments - 1)) { + if ((SInt32) mediaSegmentNumber == (numMediaSegments - 1)) { mir->tirList[i].leafInfo[mediaSegmentNumber].lastMoofIndex = mir->moofInfo[mir->numFragments - 1].index; mir->tirList[i].leafInfo[mediaSegmentNumber].lastPresentationTime = mir->moofInfo[mir->numFragments - 1].moofLastPresentationTimePerTrack[i]; mir->tirList[i].leafInfo[mediaSegmentNumber].presentationEndTime = mir->moofInfo[mir->numFragments - 1].moofPresentationEndTimePerTrack[i]; @@ -402,7 +402,7 @@ void estimatePresentationTimes(MovieInfoRec *mir) { } void processSAP34(MovieInfoRec *mir) { - for (long i = 0; i < mir->numTIRs; i++) { + for (SInt32 i = 0; i < mir->numTIRs; i++) { TrackInfoRec *tir = &(mir->tirList[i]); for (UInt32 j = 0; j < mir->numFragments; j++) { @@ -556,7 +556,7 @@ void checkNonIndexedSamples(MovieInfoRec *mir) { } if (!currentTrackIndexed && indexedTrackFound && nonSyncSamples > 0) - errprint("%lld non-sync samples found out of total %lld samples, for non-indexed track %d, violating ISO/IEC 23009-1:2012(E), 6.2.3.2: every access unit of the non-indexed streams shall be a SAP of type 1.\n", nonSyncSamples, nonSyncSamples + syncSamples, mir->tirList[i].trackID); + errprint("%ld non-sync samples found out of total %ld samples, for non-indexed track %d, violating ISO/IEC 23009-1:2012(E), 6.2.3.2: every access unit of the non-indexed streams shall be a SAP of type 1.\n", nonSyncSamples, nonSyncSamples + syncSamples, mir->tirList[i].trackID); } vg.accessUnitDurationNonIndexedTrack = nonIndexTrackFound ? accessUnitDuration : 0; //To store for this represntation in file @@ -645,7 +645,7 @@ void verifyBSS(MovieInfoRec *mir) { if (!vg.bss) return; - if (mir->numTIRs != (long) vg.numControlTracks) + if (mir->numTIRs != (SInt32) vg.numControlTracks) errprint("Number of tracks %d is not equal to number of tracks (%d) in control info, bitstream switching is not possible.", mir->numTIRs, vg.numControlTracks); for (int i = 0; i < mir->numTIRs; i++) { @@ -667,7 +667,7 @@ void verifyBSS(MovieInfoRec *mir) { } void checkSegmentStartWithSAP(int startWithSAP, MovieInfoRec *mir) { - for (long i = 0; i < mir->numTIRs; i++) { + for (SInt32 i = 0; i < mir->numTIRs; i++) { bool segmentStarted = false; int segmentCount = 0; @@ -713,7 +713,7 @@ OSErr processIndexingInfo(MovieInfoRec *mir) { int firstMediaSegment = vg.initializationSegment ? 1 : 0; - for (long trackIndex = 0; trackIndex < mir->numTIRs; trackIndex++) { + for (SInt32 trackIndex = 0; trackIndex < mir->numTIRs; trackIndex++) { for (i = firstMediaSegment; i < (UInt32) vg.segmentInfoSize; i++) { SidxInfoRec *firstSidxOfSegment = NULL; @@ -780,7 +780,7 @@ OSErr processIndexingInfo(MovieInfoRec *mir) { if (mir->sidxInfo[i].references[j].reference_type == 1) { sidx = getSidxByOffset(mir->sidxInfo, mir->numSidx, absoluteOffset); if (sidx == NULL) - errprint("Referenced sidx not found for sidx number %d at reference count %d: Offset %lld\n", i + 1, j, absoluteOffset); + errprint("Referenced sidx not found for sidx number %d at reference count %d: Offset %ld\n", i + 1, j, absoluteOffset); if (mir->sidxInfo[i].reference_ID != sidx->reference_ID) errprint("Referenced sidx reference_ID %d does not match to reference_ID %d for sidx number %d at reference count %d ; Section 8.16.3.3 of ISO/IEC 14496-12 4th edition: if this Segment Index box is referenced from a \"parent\" Segment Index box, the value of reference_ID shall be the same as the value of reference_ID of the \"parent\" Segment Index box\n", sidx->reference_ID, mir->sidxInfo[i].reference_ID, i + 1, j); @@ -810,7 +810,7 @@ OSErr processIndexingInfo(MovieInfoRec *mir) { TrackInfoRec *tir = &(mir->tirList[trackIndex]); if (moofIndex >= mir->numFragments) { - errprint("Referenced moof not found for sidx number %d at reference count %d: Offset %lld\n", i + 1, j, absoluteOffset); + errprint("Referenced moof not found for sidx number %d at reference count %d: Offset %ld\n", i + 1, j, absoluteOffset); continue; } @@ -951,7 +951,7 @@ OSErr processIndexingInfo(MovieInfoRec *mir) { } -void processBuffering(long cnt, atomOffsetEntry *list, MovieInfoRec *mir) { +void processBuffering(SInt32 cnt, atomOffsetEntry *list, MovieInfoRec *mir) { SInt64 initSize = 0; SInt64 offset; @@ -1035,7 +1035,7 @@ void processBuffering(long cnt, atomOffsetEntry *list, MovieInfoRec *mir) { if (moof->trafInfo[k].trunInfo[l].data_offset_present) offset = moof->offset - initSize + moof->trafInfo[k].trunInfo[l].data_offset; else if (l == 0) - errprint("data_offset absent for the first run of fragment number %d (absolute moof file offset %lld), unexpected!\n", k + 1, moof->offset); + errprint("data_offset absent for the first run of fragment number %d (absolute moof file offset %ld), unexpected!\n", k + 1, moof->offset); for (UInt32 m = 0; m < moof->trafInfo[k].trunInfo[l].sample_count; m++) { @@ -1063,7 +1063,7 @@ void processBuffering(long cnt, atomOffsetEntry *list, MovieInfoRec *mir) { totalDataRemoved += dataSizeToRemove; lastOffset = offset; - //fprintf(stderr,"Total bits removed: %Lf, Size to remove: %Lf, Buffer Fullness: %Lf, average input rate: %Lf, duration: %Lf, sample %d, run %d, track fragment %d, fragment %d, track id %d (sample absolute offset %lld, fragment absolute file offset %lld)\n",totalDataRemoved,dataSizeToRemove,bufferFullness/8.0,totalBitsAdded/(((long double)timeNowInTicks/(long double)tir->mediaTimeScale)-0),((long double)moof->trafInfo[k].trunInfo[l].sample_duration[m]/(long double)tir->mediaTimeScale),m+1,l+1,k+1,j+1,tir->trackID,offset - moof->trafInfo[k].trunInfo[l].sample_size[m] + initSize, moof->offset); + //fprintf(stderr,"Total bits removed: %Lf, Size to remove: %Lf, Buffer Fullness: %Lf, average input rate: %Lf, duration: %Lf, sample %d, run %d, track fragment %d, fragment %d, track id %d (sample absolute offset %ld, fragment absolute file offset %ld)\n",totalDataRemoved,dataSizeToRemove,bufferFullness/8.0,totalBitsAdded/(((long double)timeNowInTicks/(long double)tir->mediaTimeScale)-0),((long double)moof->trafInfo[k].trunInfo[l].sample_duration[m]/(long double)tir->mediaTimeScale),m+1,l+1,k+1,j+1,tir->trackID,offset - moof->trafInfo[k].trunInfo[l].sample_size[m] + initSize, moof->offset); @@ -1081,7 +1081,7 @@ void processBuffering(long cnt, atomOffsetEntry *list, MovieInfoRec *mir) { long double finalBufferFullness = bufferFullness - dataSizeToRemove * 8; //unused long double targetBitrate = (long double) (8 * (offset - initSize)) / ((long double) timeNowInTicks / (long double) tir->mediaTimeScale); // unused //Direct bitrate calculation - //fprintf(stderr,"Recalculated: targetBitrate %Lf, byte offset %lld, time %lld: %Lf, total removed %Lf\n",targetBitrate,offset - initSize,timeNowInTicks,((long double)timeNowInTicks/(long double)tir->mediaTimeScale),totalDataRemoved,((long double)offset - initSize)-totalDataRemoved); + //fprintf(stderr,"Recalculated: targetBitrate %Lf, byte offset %ld, time %ld: %Lf, total removed %Lf\n",targetBitrate,offset - initSize,timeNowInTicks,((long double)timeNowInTicks/(long double)tir->mediaTimeScale),totalDataRemoved,((long double)offset - initSize)-totalDataRemoved); if (targetBitrate <= currentBandwidth) { ; //fprintf(stderr,"Program error: unexpected: calculated target bitrate %Lf for this non-conforming track (with buffer under-run) is less than or equal to its actual bandwidth %Lf , exiting!\n",targetBitrate,currentBandwidth); @@ -1142,9 +1142,9 @@ void processBuffering(long cnt, atomOffsetEntry *list, MovieInfoRec *mir) { if(currentBandwidth > vg.bandwidth && mpd_val_conf) currentBandwidth = (long double)vg.bandwidth; if(mpd_val_conf) - fprintf(stderr, "According to DASH-IF IOP Section 3.2.8 @bandwidth of the Representation (%ld bps) is set too high given the @minimumBufferTime (%ld s), the minimum @bandwidth value required to conform is %ld bps.\n", (UInt32) vg.bandwidth, (UInt32) vg.minBufferTime, (UInt32) currentBandwidth); + fprintf(stderr, "According to DASH-IF IOP Section 3.2.8 @bandwidth of the Representation (%ld bps) is set too high given the @minimumBufferTime (%ld s), the minimum @bandwidth value required to conform is %ld bps.\n", (long) vg.bandwidth, (long) vg.minBufferTime, (long) currentBandwidth); else - errprint("According to DASH-IF IOP Section 3.2.8 @bandwidth of the Representation (%ld bps) is set too low given the @minimumBufferTime (%ld s), the minimum @bandwidth value required to conform is %ld bps.\n", (UInt32) vg.bandwidth, (UInt32) vg.minBufferTime, (UInt32) currentBandwidth); + errprint("According to DASH-IF IOP Section 3.2.8 @bandwidth of the Representation (%ld bps) is set too low given the @minimumBufferTime (%ld s), the minimum @bandwidth value required to conform is %ld bps.\n", (long) vg.bandwidth, (long) vg.minBufferTime, (long) currentBandwidth); /*if (trackNonConforming || (currentBandwidth != (long double) vg.bandwidth) ) //Latter means vg.suggestBandwidth is set and new bw is calculated { @@ -1166,7 +1166,7 @@ void processBuffering(long cnt, atomOffsetEntry *list, MovieInfoRec *mir) { return; } -void checkCMAFBoxOrder(long cnt, atomOffsetEntry *list, long segmentInfoSize, bool CMAFHeader, UInt64 *segmentSizes) +void checkCMAFBoxOrder(SInt32 cnt, atomOffsetEntry *list, SInt32 segmentInfoSize, bool CMAFHeader, UInt64 *segmentSizes) { UInt64 offset = 0; //In this function,all top level boxes like ftyp, moov , moof etc are checked for order. Other lower level boxes have separate functions. @@ -1215,7 +1215,7 @@ void checkCMAFBoxOrder(long cnt, atomOffsetEntry *list, long segmentInfoSize, bo bool cmafFragmentInCMAFSegmentFound = false; - for (int j = i; list[j].offset < (offset + segmentSizes[index]); j++) {//For all boxes inside a Media Segment. + for (int j = i; list[j].offset < (offset + segmentSizes[index]) && j < cnt; j++) {//For all boxes inside a Media Segment. if(list[j].type == 'emsg' && cmafFragmentInCMAFSegmentFound){ errprint("CMAF check violated: Section 7.4.5, \"If 'emsg' is present, SHALL precede the first 'moof' in the CMAF Fragment \", in segment %d 'moof' found before 'emsg'\n", index); @@ -1223,7 +1223,7 @@ void checkCMAFBoxOrder(long cnt, atomOffsetEntry *list, long segmentInfoSize, bo } if (list[j].type == 'moof') { //This condition is also implemented in Dash box order. if (j == (cnt - 1) || list[j + 1].offset >= (offset + segmentSizes[index]) || list[j + 1].type != 'mdat') { - errprint("mdat not found following a moof in segment %d (at file absolute offset %lld), violating: CMAF Section 7.3.1 (ordinality/nesting), 'mdat' follows 'moof' in box order and ISO/IEC 23009-1:2012(E), 6.3.4.2: Each Media Segment shall contain one or more whole self-contained movie fragments. A whole, self-contained movie fragment is a movie fragment ('moof') box and a media data ('mdat') box that contains all the media samples that do not use external data references referenced by the track runs in the movie fragment box.\n", index, list[j].offset); + errprint("mdat not found following a moof in segment %d (at file absolute offset %ld), violating: CMAF Section 7.3.1 (ordinality/nesting), 'mdat' follows 'moof' in box order and ISO/IEC 23009-1:2012(E), 6.3.4.2: Each Media Segment shall contain one or more whole self-contained movie fragments. A whole, self-contained movie fragment is a movie fragment ('moof') box and a media data ('mdat') box that contains all the media samples that do not use external data references referenced by the track runs in the movie fragment box.\n", index, list[j].offset); } cmafFragmentInCMAFSegmentFound = true; @@ -1242,7 +1242,7 @@ void checkCMAFBoxOrder(long cnt, atomOffsetEntry *list, long segmentInfoSize, bo } } -void checkCMAFBoxOrder_moov(long cnt,atomOffsetEntry *list) +void checkCMAFBoxOrder_moov(SInt32 cnt,atomOffsetEntry *list) { bool ord_err=false; char err_order[50]; @@ -1268,7 +1268,7 @@ void checkCMAFBoxOrder_moov(long cnt,atomOffsetEntry *list) } -void checkCMAFBoxOrder_trak(long cnt,atomOffsetEntry *list) +void checkCMAFBoxOrder_trak(SInt32 cnt,atomOffsetEntry *list) { int edts_flag=0; bool ord_err=false; @@ -1297,7 +1297,7 @@ void checkCMAFBoxOrder_trak(long cnt,atomOffsetEntry *list) } -void checkCMAFBoxOrder_mdia(long cnt,atomOffsetEntry *list) +void checkCMAFBoxOrder_mdia(SInt32 cnt,atomOffsetEntry *list) { int elng_flag=0; bool ord_err=false; @@ -1326,7 +1326,7 @@ void checkCMAFBoxOrder_mdia(long cnt,atomOffsetEntry *list) } } -void checkCMAFBoxOrder_minf(long cnt,atomOffsetEntry *list) +void checkCMAFBoxOrder_minf(SInt32 cnt,atomOffsetEntry *list) { bool ord_err=false; char err_order[50]; @@ -1349,7 +1349,7 @@ void checkCMAFBoxOrder_minf(long cnt,atomOffsetEntry *list) } } -void checkCMAFBoxOrder_stbl(long cnt,atomOffsetEntry *list) +void checkCMAFBoxOrder_stbl(SInt32 cnt,atomOffsetEntry *list) { bool ord_err=false; char err_order[50]; @@ -1376,7 +1376,7 @@ void checkCMAFBoxOrder_stbl(long cnt,atomOffsetEntry *list) } } -void checkCMAFBoxOrder_sinf(long cnt,atomOffsetEntry *list) +void checkCMAFBoxOrder_sinf(SInt32 cnt,atomOffsetEntry *list) { bool ord_err=false; char err_order[50]; @@ -1398,7 +1398,7 @@ void checkCMAFBoxOrder_sinf(long cnt,atomOffsetEntry *list) errprint("CMAF check violated (ordinality/nesting) : \"In 'sinf', the allowed box order as per Section 7.3.1. of ISO/IEC 23000-19(E) is: frma--schm--schi \", but order found is: %s \n", err_order); } } -void checkCMAFBoxOrder_moof(long cnt,atomOffsetEntry *list) +void checkCMAFBoxOrder_moof(SInt32 cnt,atomOffsetEntry *list) { bool ord_err=false; char err_order[50]; @@ -1419,7 +1419,7 @@ void checkCMAFBoxOrder_moof(long cnt,atomOffsetEntry *list) } } -void checkCMAFBoxOrder_traf(long cnt,atomOffsetEntry *list) +void checkCMAFBoxOrder_traf(SInt32 cnt,atomOffsetEntry *list) { bool ord_err=false; char err_order[50]; diff --git a/ISOSegmentValidator/public/src/PostprocessData.h b/ISOSegmentValidator/public/src/PostprocessData.h index f94c9514..455da540 100755 --- a/ISOSegmentValidator/public/src/PostprocessData.h +++ b/ISOSegmentValidator/public/src/PostprocessData.h @@ -32,26 +32,26 @@ class AudioVisualRollRecoveryEntry OSErr postprocessFragmentInfo(MovieInfoRec *mir); void verifyLeafDurations(MovieInfoRec *mir); -void initializeLeafInfo(MovieInfoRec *mir, long numMediaSegments); +void initializeLeafInfo(MovieInfoRec *mir, SInt32 numMediaSegments); void checkNonIndexedSamples(MovieInfoRec *mir); void verifyAlignment(MovieInfoRec *mir); void verifyBSS(MovieInfoRec *mir); void processSAP34(MovieInfoRec *mir); OSErr processIndexingInfo(MovieInfoRec *mir); -void checkDASHBoxOrder(long cnt, atomOffsetEntry *list, long segmentInfoSize, bool initializationSegment, UInt64 *segmentSizes, MovieInfoRec *mir); +void checkDASHBoxOrder(SInt32 cnt, atomOffsetEntry *list, SInt32 segmentInfoSize, bool initializationSegment, UInt64 *segmentSizes, MovieInfoRec *mir); void checkSegmentStartWithSAP(int startWithSAP, MovieInfoRec *mir); void estimatePresentationTimes(MovieInfoRec*mir); -void processBuffering(long cnt, atomOffsetEntry *list, MovieInfoRec *mir); +void processBuffering(SInt32 cnt, atomOffsetEntry *list, MovieInfoRec *mir); //CMAF box order checks' function definitions. -void checkCMAFBoxOrder(long cnt, atomOffsetEntry *list, long segmentInfoSize, bool CMAFHeader, UInt64 *segmentSizes); -void checkCMAFBoxOrder_moov(long cnt,atomOffsetEntry *list); -void checkCMAFBoxOrder_trak(long cnt,atomOffsetEntry *list); -void checkCMAFBoxOrder_mdia(long cnt,atomOffsetEntry *list); -void checkCMAFBoxOrder_minf(long cnt,atomOffsetEntry *list); -void checkCMAFBoxOrder_stbl(long cnt,atomOffsetEntry *list); -void checkCMAFBoxOrder_sinf(long cnt,atomOffsetEntry *list); -void checkCMAFBoxOrder_moof(long cnt,atomOffsetEntry *list); -void checkCMAFBoxOrder_traf(long cnt,atomOffsetEntry *list); +void checkCMAFBoxOrder(SInt32 cnt, atomOffsetEntry *list, SInt32 segmentInfoSize, bool CMAFHeader, UInt64 *segmentSizes); +void checkCMAFBoxOrder_moov(SInt32 cnt,atomOffsetEntry *list); +void checkCMAFBoxOrder_trak(SInt32 cnt,atomOffsetEntry *list); +void checkCMAFBoxOrder_mdia(SInt32 cnt,atomOffsetEntry *list); +void checkCMAFBoxOrder_minf(SInt32 cnt,atomOffsetEntry *list); +void checkCMAFBoxOrder_stbl(SInt32 cnt,atomOffsetEntry *list); +void checkCMAFBoxOrder_sinf(SInt32 cnt,atomOffsetEntry *list); +void checkCMAFBoxOrder_moof(SInt32 cnt,atomOffsetEntry *list); +void checkCMAFBoxOrder_traf(SInt32 cnt,atomOffsetEntry *list); #endif //#define _SRC_POST_PROCESS_DATA_H_ diff --git a/ISOSegmentValidator/public/src/ValidateAtomList.cpp b/ISOSegmentValidator/public/src/ValidateAtomList.cpp index 99297af5..544b1de0 100755 --- a/ISOSegmentValidator/public/src/ValidateAtomList.cpp +++ b/ISOSegmentValidator/public/src/ValidateAtomList.cpp @@ -45,9 +45,9 @@ OSErr ValidateFileAtoms( atomOffsetEntry *aoe, void *refcon ) { #pragma unused(refcon) OSErr err = noErr; - long cnt; + SInt32 cnt; atomOffsetEntry *list; - long i; + SInt32 i; OSErr atomerr = noErr; atomOffsetEntry *entry; UInt64 minOffset, maxOffset; @@ -107,7 +107,7 @@ OSErr ValidateFileAtoms( atomOffsetEntry *aoe, void *refcon ) vg.mir->moofInfo = (MoofInfoRec *)malloc(vg.mir->numFragments*sizeof(MoofInfoRec)); vg.mir->processedFragments = 0; - for (i = 0; i < (long)vg.mir->numFragments ; i++) + for (i = 0; i < (SInt32)vg.mir->numFragments ; i++) { vg.mir->moofInfo[i].compositionInfoMissingPerTrack = (Boolean*)malloc(vg.mir->numTIRs*sizeof(Boolean)); vg.mir->moofInfo[i].moofEarliestPresentationTimePerTrack = (long double*)malloc(vg.mir->numTIRs*sizeof(long double)); @@ -264,9 +264,9 @@ OSErr Validate_dinf_Atom( atomOffsetEntry *aoe, void *refcon ) { #pragma unused(refcon) OSErr err = noErr; - long cnt; + SInt32 cnt; atomOffsetEntry *list; - long i; + SInt32 i; OSErr atomerr = noErr; atomOffsetEntry *entry; UInt64 minOffset, maxOffset; @@ -307,9 +307,9 @@ OSErr Validate_edts_Atom( atomOffsetEntry *aoe, void *refcon ) { #pragma unused(refcon) OSErr err = noErr; - long cnt; + SInt32 cnt; atomOffsetEntry *list; - long i; + SInt32 i; OSErr atomerr = noErr; atomOffsetEntry *entry; UInt64 minOffset, maxOffset; @@ -358,9 +358,9 @@ OSErr Validate_minf_Atom( atomOffsetEntry *aoe, void *refcon ) { #pragma unused(refcon) OSErr err = noErr; - long cnt; + SInt32 cnt; atomOffsetEntry *list; - long i; + SInt32 i; OSErr atomerr = noErr; atomOffsetEntry *entry; UInt64 minOffset, maxOffset; @@ -477,9 +477,9 @@ OSErr Validate_mdia_Atom( atomOffsetEntry *aoe, void *refcon ) { #pragma unused(refcon) OSErr err = noErr; - long cnt; + SInt32 cnt; atomOffsetEntry *list; - long i; + SInt32 i; OSErr atomerr = noErr; atomOffsetEntry *entry; UInt64 minOffset, maxOffset; @@ -547,16 +547,16 @@ OSErr Validate_mdia_Atom( atomOffsetEntry *aoe, void *refcon ) OSErr Get_trak_Type( atomOffsetEntry *aoe, TrackInfoRec *tir ) { OSErr err = noErr; - long cnt; + SInt32 cnt; atomOffsetEntry *list; - long i; + SInt32 i; atomOffsetEntry *entry; UInt64 minOffset, maxOffset; - long entrycnt; + SInt32 entrycnt; atomOffsetEntry *entrylist; atomOffsetEntry *entryentry; - long j; + SInt32 j; minOffset = aoe->offset + aoe->atomStartSize; maxOffset = aoe->offset + aoe->size - aoe->atomStartSize; @@ -589,9 +589,9 @@ OSErr Get_trak_Type( atomOffsetEntry *aoe, TrackInfoRec *tir ) OSErr Validate_trak_Atom( atomOffsetEntry *aoe, void *refcon ) { OSErr err = noErr; - long cnt; + SInt32 cnt; atomOffsetEntry *list; - long i; + SInt32 i; OSErr atomerr = noErr; atomOffsetEntry *entry; UInt64 minOffset, maxOffset; @@ -674,7 +674,7 @@ OSErr Validate_trak_Atom( atomOffsetEntry *aoe, void *refcon ) BitBuffer bb; sampleprint("\n"); vg.tabcnt++; - for (i = 1; i <= (long)tir->sampleSizeEntryCnt; i++) { + for (i = 1; i <= (SInt32)tir->sampleSizeEntryCnt; i++) { if ((vg.samplenumber==0) || (vg.samplenumber==i)) { err = GetSampleOffsetSize( tir, i, &sampleOffset, &sampleSize, &sampleDescriptionIndex ); sampleprint("\n",i,int64toxstr(sampleOffset),sampleSize); vg.tabcnt++; @@ -705,7 +705,7 @@ OSErr Validate_trak_Atom( atomOffsetEntry *aoe, void *refcon ) BitBuffer bb; sampleprint("\n"); vg.tabcnt++; - for (i = 1; i <= (long)tir->sampleSizeEntryCnt; i++) { + for (i = 1; i <= (SInt32)tir->sampleSizeEntryCnt; i++) { if ((vg.samplenumber==0) || (vg.samplenumber==i)) { err = GetSampleOffsetSize( tir, i, &sampleOffset, &sampleSize, &sampleDescriptionIndex ); sampleprint("\n",i,int64toxstr(sampleOffset),sampleSize); vg.tabcnt++; @@ -736,7 +736,7 @@ OSErr Validate_trak_Atom( atomOffsetEntry *aoe, void *refcon ) BitBuffer bb; sampleprint("\n"); vg.tabcnt++; - for (i = 1; i <= (long)tir->sampleSizeEntryCnt; i++) { + for (i = 1; i <= (SInt32)tir->sampleSizeEntryCnt; i++) { if ((vg.samplenumber==0) || (vg.samplenumber==i)) { err = GetSampleOffsetSize( tir, i, &sampleOffset, &sampleSize, &sampleDescriptionIndex ); sampleprint("\n",1,int64toxstr(sampleOffset),sampleSize); vg.tabcnt++; @@ -766,7 +766,7 @@ OSErr Validate_trak_Atom( atomOffsetEntry *aoe, void *refcon ) Ptr dataP = nil; BitBuffer bb; sampleprint("\n"); vg.tabcnt++; - for (i = 1; i <= (long)tir->sampleSizeEntryCnt; i++) { + for (i = 1; i <= (SInt32)tir->sampleSizeEntryCnt; i++) { if ((vg.samplenumber==0) || (vg.samplenumber==i)) { err = GetSampleOffsetSize( tir, i, &sampleOffset, &sampleSize, &sampleDescriptionIndex ); sampleprint("\n",1,int64toxstr(sampleOffset),sampleSize); vg.tabcnt++; @@ -808,9 +808,9 @@ OSErr Validate_trak_Atom( atomOffsetEntry *aoe, void *refcon ) OSErr Validate_stbl_Atom( atomOffsetEntry *aoe, void *refcon ) { OSErr err = noErr; - long cnt; + SInt32 cnt; atomOffsetEntry *list; - long i; + SInt32 i; OSErr atomerr = noErr; atomOffsetEntry *entry; UInt64 minOffset, maxOffset; @@ -897,16 +897,21 @@ OSErr Validate_stbl_Atom( atomOffsetEntry *aoe, void *refcon ) if (!err) err = atomerr; // Process 'sgpd' atoms - atomerr = ValidateAtomOfType( 'sgpd', kTypeAtomFlagCanHaveAtMostOne, - Validate_sgpd_Atom, cnt, list, tir ); - if (!err) err = atomerr; - - // Process 'subs' atoms - if(vg.cmaf){ - atomerr = ValidateAtomOfType( 'subs', 0, - Validate_subs_Atom, cnt, list, tir ); - if (!err) err = atomerr; - } + if (0) { + UInt32 moofIndex = getMoofIndexByOffset(vg.mir->moofInfo, vg.mir->numFragments, aoe->offset); + MoofInfoRec *moofInfoRec = &vg.mir->moofInfo[moofIndex]; + atomerr = ValidateAtomOfType( 'sgpd', kTypeAtomFlagCanHaveAtMostOne, + Validate_sgpd_Atom, cnt, list, &moofInfoRec->trafInfo[moofInfoRec->processedTrackFragments]); + if (!err) err = atomerr; + } + + // Process 'subs' atoms + if(vg.cmaf){ + atomerr = ValidateAtomOfType( 'subs', 0, + Validate_subs_Atom, cnt, list, tir ); + if (!err) err = atomerr; + } + // for (i = 0; i < cnt; i++) { entry = &list[i]; @@ -973,9 +978,9 @@ OSErr Validate_stbl_Atom( atomOffsetEntry *aoe, void *refcon ) OSErr Validate_mvex_Atom( atomOffsetEntry *aoe, void *refcon ) { OSErr err = noErr; - long cnt; + SInt32 cnt; atomOffsetEntry *list; - long i; + SInt32 i; OSErr atomerr = noErr; atomOffsetEntry *entry; UInt64 minOffset, maxOffset; @@ -1063,20 +1068,20 @@ OSErr Validate_mvex_Atom( atomOffsetEntry *aoe, void *refcon ) //========================================================================================== -OSErr ValidateAtomOfType( OSType theType, long flags, ValidateAtomTypeProcPtr validateProc, - long cnt, atomOffsetEntry *list, void *refcon ) +OSErr ValidateAtomOfType( OSType theType, SInt32 flags, ValidateAtomTypeProcPtr validateProc, + SInt32 cnt, atomOffsetEntry *list, void *refcon ) { - long i; + SInt32 i; OSErr err = noErr; char cstr[5] = {}; - long typeCnt = 0; + SInt32 typeCnt = 0; atomOffsetEntry *entry; OSErr atomerr; atompathType curatompath; Boolean curatomprint; Boolean cursampleprint; Boolean traf_exists = false; - long traf_cnt = 0; + SInt32 traf_cnt = 0; cstr[0] = (theType >> 24) & 0xff; cstr[1] = (theType >> 16) & 0xff; @@ -1210,11 +1215,11 @@ OSErr Validate_ftyp_Atom( atomOffsetEntry *aoe, void *refcon ) { #pragma unused(refcon) OSErr err = noErr; - UInt64 offset; - OSType majorBrand; - UInt32 version; - UInt32 compatBrandListSize, numCompatibleBrands; - char tempstr1[5], tempstr2[5]; + UInt64 offset = 0; + OSType majorBrand = 0; + UInt32 version = 0; + UInt32 compatBrandListSize = 0, numCompatibleBrands = 0; + char tempstr1[5] = {}, tempstr2[5] = {}; offset = aoe->offset + aoe->atomStartSize; @@ -1285,7 +1290,6 @@ OSErr Validate_ftyp_Atom( atomOffsetEntry *aoe, void *refcon ) } if (!majorBrandFoundAmongCompatibleBrands) { - warnprint("Warning: major brand ('%.4s') not also found in list of compatible brands\n", ostypetostr_r(majorBrand,tempstr2)); } @@ -1363,7 +1367,7 @@ OSErr Validate_styp_Atom( atomOffsetEntry *aoe, void *refcon ) vg.simsInStyp[segmentNum] = false; if(!segmentFound) - errprint("styp not at the begining of a segment (abs. file offset %lld), this is unexpected\n",aoe->offset); + errprint("styp not at the begining of a segment (abs. file offset %ld), this is unexpected\n",aoe->offset); /*skip styp size, tag, major brand and version*/ offset += 16; @@ -1460,12 +1464,12 @@ OSErr Validate_moov_Atom( atomOffsetEntry *aoe, void *refcon ) { #pragma unused(refcon) OSErr err = noErr; - long cnt; + SInt32 cnt; atomOffsetEntry *list; - long i; + SInt32 i; OSErr atomerr = noErr; - long trakCnt = 0; - long thisTrakIndex = 0; + SInt32 trakCnt = 0; + SInt32 thisTrakIndex = 0; atomOffsetEntry *entry; UInt64 minOffset, maxOffset; MovieInfoRec *mir = NULL; @@ -1525,7 +1529,7 @@ OSErr Validate_moov_Atom( atomOffsetEntry *aoe, void *refcon ) if (entry->type == 'trak') { ++(mir->numTIRs); atomerr = Get_trak_Type(entry, &(mir->tirList[thisTrakIndex])); - entry->refconOverride = (long)&(mir->tirList[thisTrakIndex]); + entry->refconOverride = (void*)&(mir->tirList[thisTrakIndex]); ++thisTrakIndex; } } @@ -1681,7 +1685,7 @@ OSErr Validate_moov_Atom( atomOffsetEntry *aoe, void *refcon ) BAILIFNULL( trk = (track_track *)calloc(trk_cnt,sizeof(track_track)), allocFailedErr ); - for (i=0; i<(long)trk_cnt; ++i) { + for (i=0; i<(SInt32)trk_cnt; ++i) { // find the chunk counts for each track and setup structures tir = &(mir->tirList[i]); totalChunks += tir->chunkOffsetEntryCnt; @@ -1703,7 +1707,7 @@ OSErr Validate_moov_Atom( atomOffsetEntry *aoe, void *refcon ) // find the next lowest chunk start lowest = -1; // next chunk not identified - for (i=0; i<(long)trk_cnt; i++) { + for (i=0; i<(SInt32)trk_cnt; i++) { UInt64 offset; tir = &(mir->tirList[i]); if (trk[i].chunk_num <= trk[i].chunk_cnt) { // track has chunks to process @@ -1811,7 +1815,7 @@ OSErr Validate_moov_Atom( atomOffsetEntry *aoe, void *refcon ) // see whether we have eaten all chunks for all tracks done = 1; - for (i=0; i<(long)trk_cnt; i++) { + for (i=0; i<(SInt32)trk_cnt; i++) { if (trk[i].chunk_num <= trk[i].chunk_cnt) { done = 0; break; } } } while (done != 1); @@ -1834,9 +1838,9 @@ OSErr Validate_moov_Atom( atomOffsetEntry *aoe, void *refcon ) OSErr Validate_moof_Atom( atomOffsetEntry *aoe, void *refcon ) { OSErr err = noErr; - long cnt; + SInt32 cnt; atomOffsetEntry *list; - long i; + SInt32 i; OSErr atomerr = noErr; atomOffsetEntry *entry; UInt64 minOffset, maxOffset; @@ -1844,8 +1848,8 @@ OSErr Validate_moof_Atom( atomOffsetEntry *aoe, void *refcon ) MoofInfoRec *moofInfo = &mir->moofInfo[mir->processedFragments]; - atomprint("size=\"%lld\"\n", aoe->size); - atomprint("offset=\"%lld\"\n", aoe->offset); + atomprint("size=\"%ld\"\n", aoe->size); + atomprint("offset=\"%ld\"\n", aoe->offset); atomprint(">\n"); minOffset = aoe->offset + aoe->atomStartSize; @@ -1940,9 +1944,9 @@ OSErr Validate_moof_Atom( atomOffsetEntry *aoe, void *refcon ) OSErr Validate_traf_Atom( atomOffsetEntry *aoe, void *refcon ) { OSErr err = noErr; - long cnt; + SInt32 cnt; atomOffsetEntry *list; - long i; + SInt32 i; OSErr atomerr = noErr; atomOffsetEntry *entry; UInt64 minOffset, maxOffset; @@ -2025,7 +2029,7 @@ OSErr Validate_traf_Atom( atomOffsetEntry *aoe, void *refcon ) if (!err) err = atomerr; } - long flags; + SInt32 flags; flags = kTypeAtomFlagCanHaveAtMostOne; @@ -2065,7 +2069,7 @@ OSErr Validate_traf_Atom( atomOffsetEntry *aoe, void *refcon ) //Accumulate durations now for later checking - for (i = 0; i < (long)trafInfo->numTrun; i++) + for (i = 0; i < (SInt32)trafInfo->numTrun; i++) { trafInfo->cummulatedSampleDuration+=trafInfo->trunInfo[i].cummulatedSampleDuration; @@ -2223,9 +2227,9 @@ void dispose_mir( MovieInfoRec *mir ) OSErr Validate_tref_Atom( atomOffsetEntry *aoe, void *refcon ) { OSErr err = noErr; - long cnt; + SInt32 cnt; atomOffsetEntry *list; - long i; + SInt32 i; OSErr atomerr = noErr; atomOffsetEntry *entry; UInt64 minOffset, maxOffset; @@ -2288,9 +2292,9 @@ OSErr Validate_udta_Atom( atomOffsetEntry *aoe, void *refcon ) { #pragma unused(refcon) OSErr err = noErr; - long cnt; + SInt32 cnt; atomOffsetEntry *list; - long i; + SInt32 i; OSErr atomerr = noErr; atomOffsetEntry *entry; UInt64 minOffset, maxOffset; @@ -2393,9 +2397,9 @@ static OSErr Validate_rtp_Atom( atomOffsetEntry *aoe, void *refcon ) OSErr Validate_moovhnti_Atom( atomOffsetEntry *aoe, void *refcon ) { OSErr err = noErr; - long cnt; + SInt32 cnt; atomOffsetEntry *list; - long i; + SInt32 i; OSErr atomerr = noErr; atomOffsetEntry *entry; UInt64 minOffset, maxOffset; @@ -2437,9 +2441,9 @@ OSErr Validate_sinf_Atom( atomOffsetEntry *aoe, void *refcon, UInt32 flags ) { #pragma unused(refcon) OSErr err = noErr; - long cnt; + SInt32 cnt; atomOffsetEntry *list; - long i; + SInt32 i; OSErr atomerr = noErr; atomOffsetEntry *entry; UInt64 minOffset, maxOffset; @@ -2494,9 +2498,9 @@ OSErr Validate_meta_Atom( atomOffsetEntry *aoe, void *refcon ) { #pragma unused(refcon) OSErr err = noErr; - long cnt; + SInt32 cnt; atomOffsetEntry *list; - long i; + SInt32 i; OSErr atomerr = noErr; atomOffsetEntry *entry; UInt64 offset, minOffset, maxOffset; diff --git a/ISOSegmentValidator/public/src/ValidateAtoms.cpp b/ISOSegmentValidator/public/src/ValidateAtoms.cpp index e9e714c4..638a3a35 100644 --- a/ISOSegmentValidator/public/src/ValidateAtoms.cpp +++ b/ISOSegmentValidator/public/src/ValidateAtoms.cpp @@ -76,7 +76,7 @@ OSErr Validate_iods_Atom( atomOffsetEntry *aoe, void *refcon ) UInt32 flags; UInt64 offset; Ptr odDataP = nil; - unsigned long odSize; + UInt32 odSize; // Get version/flags BAILIFERR( GetFullAtomVersionFlags( aoe, &version, &flags, &offset ) ); @@ -106,8 +106,8 @@ typedef struct MovieHeaderCommonRecord { SInt16 preferredVolume; // must be 1.0 for mp4 short reserved1; // must be 0 - long preferredLong1; // must be 0 for mp4 - long preferredLong2; // must be 0 for mp4 + SInt32 preferredLong1; // must be 0 for mp4 + SInt32 preferredLong2; // must be 0 for mp4 MatrixRecord matrix; // must be identity for mp4 @@ -120,7 +120,7 @@ typedef struct MovieHeaderCommonRecord { TimeValue selectionDuration; // must be 0 for mp4 TimeValue currentTime; // must be 0 for mp4 - long nextTrackID; + SInt32 nextTrackID; } MovieHeaderCommonRecord; typedef struct MovieHeaderVers0Record { @@ -356,7 +356,7 @@ OSErr Validate_tkhd_Atom( atomOffsetEntry *aoe, void *refcon ) if(vg.cmaf){ if(tkhdHead.duration != 0){ - errprint("CMAF check violated: Section 7.5.4. \"The value of the duration field SHALL be set to a value of zero\", found %llu\n",tkhdHead.duration); + errprint("CMAF check violated: Section 7.5.4. \"The value of the duration field SHALL be set to a value of zero\", found %lu\n",tkhdHead.duration); } if((tkhdHeadCommon.matrix[0][0] != 0 && tkhdHeadCommon.matrix[1][1] != 0 && tkhdHeadCommon.matrix[2][2] != 0x40000000) || (tkhdHeadCommon.matrix[0][0] != 0x00010000 && tkhdHeadCommon.matrix[1][1] != 0x00010000 && tkhdHeadCommon.matrix[2][2] != 0x40000000)){ @@ -1009,7 +1009,7 @@ OSErr Validate_dref_Atom( atomOffsetEntry *aoe, void *refcon ) { UInt64 minOffset, maxOffset; atomOffsetEntry *entry; - long cnt; + SInt32 cnt; atomOffsetEntry *list; int i; @@ -1148,7 +1148,7 @@ OSErr Validate_stts_Atom( atomOffsetEntry *aoe, void *refcon ) typedef struct CompositionTimeToSampleNum { - long sampleCount; + SInt32 sampleCount; TimeValue sampleOffset; } CompositionTimeToSampleNum; @@ -2117,7 +2117,7 @@ OSErr Validate_stsd_Atom( atomOffsetEntry *aoe, void *refcon ) { UInt64 minOffset, maxOffset; atomOffsetEntry *entry; - long cnt; + SInt32 cnt; atomOffsetEntry *list; int i; @@ -2315,7 +2315,7 @@ OSErr Validate_vide_SD_Entry( atomOffsetEntry *aoe, void *refcon ) { UInt64 minOffset, maxOffset; atomOffsetEntry *entry; - long cnt; + SInt32 cnt; atomOffsetEntry *list; int i; int is_protected = 0; @@ -2499,7 +2499,7 @@ OSErr Validate_mehd_Atom( atomOffsetEntry *aoe, void *refcon ) } atomprintnotab("\tversion=\"%d\" flags=\"%d\"\n", version, flags); - atomprint("fragmentDuration=\"%lld\"\n", (mir->fragment_duration)); + atomprint("fragmentDuration=\"%ld\"\n", (mir->fragment_duration)); atomprint(">\n"); if(vg.cmaf && mir->fragment_duration <=0) @@ -2534,7 +2534,7 @@ OSErr Validate_trep_Atom( atomOffsetEntry *aoe, void *refcon ) BAILIFERR( GetFileDataN32( aoe, &track_id, offset, &offset ) ); atomprintnotab("\tversion=\"%d\" flags=\"%d\"\n", version, flags); - atomprint("track_id=\"%lld\"\n", track_id); + atomprint("track_id=\"%ld\"\n", track_id); atomprint(">\n"); // All done @@ -2817,9 +2817,9 @@ OSErr Validate_trun_Atom( atomOffsetEntry *aoe, void *refcon ) sampleprint("trafInfo->default_base_is_moof %d\n", trafInfo->default_base_is_moof ); sampleprint("trunInfo->data_offset_present %d\n", trunInfo->data_offset_present ); - sampleprint("trunInfo->data_offset %08lluX\n", trunInfo->data_offset ); - sampleprint("moofInfo->offset %lld %08lluX\n", moofInfo->offset, moofInfo->offset ); - fprintf(stdout, "moofInfo->offset %lld %08lluX\n", moofInfo->offset, moofInfo->offset ); + sampleprint("trunInfo->data_offset %08uX\n", trunInfo->data_offset ); + sampleprint("moofInfo->offset %ld %08luX\n", moofInfo->offset, moofInfo->offset ); + fprintf(stdout, "moofInfo->offset %ld %08luX\n", moofInfo->offset, moofInfo->offset ); if (trafInfo->default_base_is_moof && trunInfo->data_offset_present) { @@ -2859,7 +2859,7 @@ OSErr Validate_trun_Atom( atomOffsetEntry *aoe, void *refcon ) trafInfo->processedTrun++; - atomprint("cummulatedSampleDuration=\"%lld\"\n", trunInfo->cummulatedSampleDuration); + atomprint("cummulatedSampleDuration=\"%ld\"\n", trunInfo->cummulatedSampleDuration); atomprint("earliestCompositionTime=\"%ld\"\n", trafInfo->earliestCompositionTimeInTrackFragment); atomprint("data_offset=\"%ld\"\n", trunInfo->data_offset); if(vg.cmaf) { @@ -2963,6 +2963,8 @@ OSErr Validate_sgpd_Atom( atomOffsetEntry *aoe, void *refcon ) { if(sgpdInfo->default_length == 0) BAILIFERR( GetFileDataN32( aoe, &sgpdInfo->description_length[i], offset, &offset )); + else + sgpdInfo->description_length[i] = sgpdInfo->default_length; sgpdInfo->SampleGroupDescriptionEntry[i] = (UInt32 *)malloc((sgpdInfo->default_length == 0 ? sgpdInfo->description_length[i] : sgpdInfo->default_length)*sizeof(UInt32)); } @@ -2979,8 +2981,8 @@ OSErr Validate_sgpd_Atom( atomOffsetEntry *aoe, void *refcon ) vg.tabcnt++; for(UInt32 i=0; ientry_count; i++){ - sampleprint("description_length[i])); - sampleprintnotab(" sampleGroupDescriptionEntry=\"%ld\"/>\n", EndianU32_BtoN(sgpdInfo->SampleGroupDescriptionEntry[i])); + sampleprint("description_length[i])); + sampleprintnotab(" sampleGroupDescriptionEntry=\"%u\"/>\n", EndianU64_BtoN(sgpdInfo->SampleGroupDescriptionEntry[i])); } --vg.tabcnt; @@ -3143,7 +3145,7 @@ OSErr Validate_tfdt_Atom( atomOffsetEntry *aoe, void *refcon ) trafInfo->tfdtFound = true; atomprintnotab("\tversion=\"%d\" flags=\"%d\"\n", version, flags); - atomprint("baseMediaDecodeTime=\"%lld\"\n", (trafInfo->baseMediaDecodeTime));//EndianU64_BtoN + atomprint("baseMediaDecodeTime=\"%ld\"\n", (trafInfo->baseMediaDecodeTime));//EndianU64_BtoN atomprint(">\n"); // All done @@ -3196,7 +3198,7 @@ OSErr Validate_pssh_Atom( atomOffsetEntry *aoe, void *refcon ) pssh_contents = new char[DataSize*2]; if(vg.pssh_count > 0) { - sprintf(pssh_contents, "%lu %lu %s %lu %s",version, flags, SystemID, DataSize, Data); + sprintf(pssh_contents, "%u %u %s %u %s",version, flags, SystemID, DataSize, Data); //Get pssh mentioned in MPD from a saved file char *pssh_file_contents; @@ -3232,7 +3234,7 @@ OSErr Validate_pssh_Atom( atomOffsetEntry *aoe, void *refcon ) } } - delete pssh_contents; + delete[] pssh_contents; free(Data); // All done @@ -3324,8 +3326,8 @@ OSErr Validate_sidx_Atom( atomOffsetEntry *aoe, void *refcon ) BAILIFERR( GetFileDataN64( aoe, &sidxInfo->first_offset, offset, &offset ) ); } - atomprint("earliestPresentationTime=\"%lld\"\n",sidxInfo->earliest_presentation_time); //int64todstr(EndianU64_BtoN(sidxInfo->earliest_presentation_time))); - atomprint("firstOffset=\"%lld\"\n", (EndianU64_BtoN(sidxInfo->first_offset))); + atomprint("earliestPresentationTime=\"%ld\"\n",sidxInfo->earliest_presentation_time); //int64todstr(EndianU64_BtoN(sidxInfo->earliest_presentation_time))); + atomprint("firstOffset=\"%ld\"\n", (EndianU64_BtoN(sidxInfo->first_offset))); BAILIFERR( GetFileDataN32( aoe, &temp, offset, &offset ) ); sidxInfo->reference_count = (UInt16)(temp & 0xFFFF); @@ -3493,7 +3495,7 @@ OSErr Validate_soun_SD_Entry( atomOffsetEntry *aoe, void *refcon ) UInt64 minOffset; UInt64 maxOffset; atomOffsetEntry *entry; - long cnt; + SInt32 cnt; atomOffsetEntry *list; int i; int sinfFound=0; @@ -3646,7 +3648,7 @@ OSErr Validate_subt_SD_Entry( atomOffsetEntry *aoe, void *refcon ) UInt64 minOffset, maxOffset; atomOffsetEntry *entry; atomOffsetEntry *list; - long cnt; + SInt32 cnt; int i; minOffset = offset; @@ -3697,7 +3699,7 @@ OSErr Validate_text_SD_Entry( atomOffsetEntry *aoe, void *refcon ) UInt64 minOffset, maxOffset; atomOffsetEntry *entry; atomOffsetEntry *list; - long cnt; + SInt32 cnt; int i; minOffset = offset; @@ -3754,7 +3756,7 @@ OSErr Validate_mp4_SD_Entry( atomOffsetEntry *aoe, void *refcon, ValidateBitstre { UInt64 minOffset, maxOffset; atomOffsetEntry *entry; - long cnt; + SInt32 cnt; atomOffsetEntry *list; int i; @@ -3862,7 +3864,7 @@ OSErr Validate_ESDAtom( atomOffsetEntry *aoe, void *refcon, ValidateBitstreamPro UInt32 flags; UInt64 offset; Ptr esDataP = nil; - unsigned long esSize; + UInt32 esSize; BitBuffer bb; atomprint("\n"); vg.tabcnt++; @@ -4122,7 +4124,7 @@ OSErr Validate_stpp_Atom( atomOffsetEntry *aoe, void *refcon, char *esname ) char *auxiliary_mime_types; UInt64 minOffset, maxOffset; atomOffsetEntry *entry; - long cnt; + SInt32 cnt; atomOffsetEntry *list; int i; @@ -4197,7 +4199,7 @@ OSErr Validate_wvtt_Atom( atomOffsetEntry *aoe, void *refcon, char *esname ) UInt64 minOffset, maxOffset; atomOffsetEntry *entry; atomOffsetEntry *list; - long cnt; + SInt32 cnt; int i; atomprint("<%s", esname); vg.tabcnt++; @@ -4528,7 +4530,7 @@ OSErr Validate_schm_Atom( atomOffsetEntry *aoe, void *refcon ) // Get version/flags offset = aoe->offset; - BAILIFERR( GetFileData( aoe, &ahdr, offset, sizeof( AtomStartRecord ), &offset ) ); + BAILIFERR( GetFileData( aoe, &ahdr, offset, sizeof( AtomSizeType ), &offset ) ); ahdr.atomSize = EndianU32_BtoN( ahdr.atomSize ); ahdr.atomType = EndianU32_BtoN( ahdr.atomType ); @@ -4566,9 +4568,9 @@ OSErr Validate_schm_Atom( atomOffsetEntry *aoe, void *refcon ) OSErr Validate_schi_Atom( atomOffsetEntry *aoe, void *refcon ) { OSErr err = noErr; - long cnt; + SInt32 cnt; atomOffsetEntry *list; - long i; + SInt32 i; OSErr atomerr = noErr; atomOffsetEntry *entry; UInt64 minOffset, maxOffset; @@ -4912,7 +4914,7 @@ OSErr Validate_ipro_Atom( atomOffsetEntry *aoe, void *refcon ) UInt64 minOffset; UInt64 maxOffset; atomOffsetEntry *entry; - long cnt; + SInt32 cnt; atomOffsetEntry *list; int i; @@ -5018,7 +5020,7 @@ OSErr Validate_iinf_Atom( atomOffsetEntry *aoe, void *refcon ) UInt64 minOffset; UInt64 maxOffset; atomOffsetEntry *entry; - long cnt; + SInt32 cnt; atomOffsetEntry *list; int i; diff --git a/ISOSegmentValidator/public/src/ValidateBitStreams.cpp b/ISOSegmentValidator/public/src/ValidateBitStreams.cpp index c9d24cb4..85fc5ae0 100755 --- a/ISOSegmentValidator/public/src/ValidateBitStreams.cpp +++ b/ISOSegmentValidator/public/src/ValidateBitStreams.cpp @@ -76,7 +76,7 @@ OSErr CheckValuesInContext( UInt32 bufferSize, UInt32 maxBitrate, UInt32 avgBitr //========================================================================================== -OSErr Validate_iods_OD_Bits( Ptr odDataP, unsigned long odSize, Boolean fileForm ) +OSErr Validate_iods_OD_Bits( Ptr odDataP, UInt32 odSize, Boolean fileForm ) { OSErr err; BitBuffer thebb; @@ -472,7 +472,7 @@ OSErr Validate_ES_Descriptor(BitBuffer *inbb, UInt8 Expect_ObjectType, UInt8 Exp VALIDATE_FIELD ("%d", ES_ID, 16 ); if(vg.cmaf && ES_ID != 0) { - errprint("CMAF check violated: Section 10.3.4.2.3. \"fields of the ES_Desciptor SHALL be set to the following values: ES_ID = 0.\", but found %d\n", ES_ID); + errprint("CMAF check violated: Section 10.3.4.2.3. \"fields of the ES_Descriptor SHALL be set to the following values: ES_ID = 0.\", but found %d\n", ES_ID); } if (fileForm) { FieldMustBe( ES_ID, 0, "Validate_ES_Descriptor: ES_ID should be %d not %d in media tracks\n" ); @@ -1926,7 +1926,7 @@ static OSErr Validate_HRD( BitBuffer *bb ) static OSErr Validate_HEVC_hrd_parameters( BitBuffer *bb, UInt32 commonInfPresentFlag, UInt8 maxNumSubLayersMinus1) { - UInt8 nal_hrd_parameters_present_flag,vcl_hrd_parameters_present_flag,sub_pic_hrd_params_present_flag,tick_divisor_minus2,du_cpb_removal_delay_increment_length_minus1,sub_pic_cpb_params_in_pic_timing_sei_flag,dpb_output_delay_du_length_minus1,bit_rate_scale,cpb_size_scale,cpb_size_du_scale + UInt8 nal_hrd_parameters_present_flag,vcl_hrd_parameters_present_flag,sub_pic_hrd_params_present_flag=0,tick_divisor_minus2,du_cpb_removal_delay_increment_length_minus1,sub_pic_cpb_params_in_pic_timing_sei_flag,dpb_output_delay_du_length_minus1,bit_rate_scale,cpb_size_scale,cpb_size_du_scale ,initial_cpb_removal_delay_length_minus1,au_cpb_removal_delay_length_minus1,dbp_output_delay_length_minus1,fixed_pic_rate_general_flag[8],fixed_pic_rate_within_cvs_flag[8],low_delay_hrd_flag[8]; UInt32 elemental_duration_in_tc_minus1[8],cpb_cnt_minus1[8],bit_rate_value_minus1[32],cpb_size_value_minus1[32],cpb_size_du_value_minus1[32],bit_rate_du_value_minus1[32],cbr_flag[32]; @@ -2971,7 +2971,7 @@ OSErr Validate_NAL_Unit_HEVC( BitBuffer *inbb, UInt8 expect_type, UInt32 nal_le UInt8 dependent_slice_segments_enabled_flag, output_flag_present_flag, num_extra_slice_header_bits, sign_data_hiding_enabled_flag, cabac_init_present_flag,constrained_intra_pred_flag,transform_skip_enabled_flag,cu_qp_delta_enabled_flag,pps_slice_chroma_qp_offsets_present_flag,weighted_pred_flag,weighted_bipred_flag,transquant_bypass_enabled_flag,tiles_enabled_flag,entropy_coding_sync_enabled_flag,uniform_spacing_flag,loop_filter_across_tiles_enabled_flag,pps_loop_filter_across_slices_enabled_flag,deblocking_filter_control_present_flag,deblocking_filter_override_enabled_flag,pps_deblocking_filter_disabled_flag,pps_scaling_list_data_present_flag,scaling_list_pred_mode_flag[4][6],lists_modification_present_flag,slice_segment_header_exension_present_flag,pps_extension_present_flag,pps_range_extension_flag=0,pps_multilayer_extension_flag=0,pps_3d_extension_flag=0,pps_scc_extension_flag=0,pps_extension_4bits=0,cross_component_prediction_enabled_flag,chroma_qp_offset_list_enabled_flag,poc_reset_info_present_flag,pps_infer_scaling_list_flag,pps_scaling_list_ref_layer_id,ref_loc_offset_layer_id[65],scaled_ref_layer_offset_present_flag[65],ref_region_offset_present_flag[65],resample_phase_set_present_flag[65],colour_mapping_enabled_flag,cm_ref_layer_id[62],cm_octant_depth,cm_y_part_num_log2,cm_res_quant_bits,cm_delta_flc_bits_minus1,dlts_present_flag,pps_depth_layers_minus1,pps_bit_depth_for_depth_layers_minus8,dlt_flag[65],dlt_pred_flag[65],dlt_val_flags_present_flag[65],dlt_value_flag[65][70],pps_curr_pic_ref_enabled_flag,residual_adaptive_colour_transform_enabled_flag,pps_slice_act_qp_offsets_present_flag,pps_palette_predictor_initializer_present_flag,monochrome_palette_flag,pps_extension_data_flag; - UInt32 i,j,k, pps_pic_parameter_set_id, pps_seq_parameter_set_id,num_ref_idx_l0_default_active_minus1,num_ref_idx_l1_default_active_minus1, diff_cu_qp_delta_depth,num_tile_columns_minus1,num_tile_rows_minus1,column_width_minus1,row_heigth_minus1,sizeId,matrixId,scaling_list_pred_matrix_id_delta[4][6],nextCoef,coefNum,ScalingList[4][6][64],log2_parallel_merge_level_minus2,log2_max_transform_skip_block_size2_minus2,diff_cu_chroma_qp_offset_depth,chroma_qp_offset_list_len_minus1,log2_sao_offset_scale_luma,log2_sao_offset_scale_chroma,num_ref_loc_offsets,phase_hor_luma,phase_ver_luma,phase_hor_chroma_plus8,phase_ver_chroma_plus8,num_cm_ref_layers_minus1,luma_bit_depth_cm_input_minus8,chroma_bit_depth_cm_input_minus8,luma_bit_depth_cm_output_minus8,chroma_bit_depth_cm_output_minus8,depthMaxValue,num_val_delta_dlt,max_diff,size_min_diff_minus1,min_diff_minus1,delta_dlt_val0,size_delta_val_diff_minus_min,delta_val_diff_minus_min,pps_num_palette_predictor_initializer,luma_bit_depth_entry_minus8,chroma_bit_depth_entry_minus8,numComps,comp,pps_palette_predictor_initializers; + UInt32 i,j,k, pps_pic_parameter_set_id, pps_seq_parameter_set_id,num_ref_idx_l0_default_active_minus1,num_ref_idx_l1_default_active_minus1, diff_cu_qp_delta_depth,num_tile_columns_minus1,num_tile_rows_minus1,column_width_minus1,row_heigth_minus1,sizeId,matrixId,scaling_list_pred_matrix_id_delta[4][6],nextCoef,coefNum,ScalingList[4][6][64],log2_parallel_merge_level_minus2,log2_max_transform_skip_block_size2_minus2,diff_cu_chroma_qp_offset_depth,chroma_qp_offset_list_len_minus1,log2_sao_offset_scale_luma,log2_sao_offset_scale_chroma,num_ref_loc_offsets,phase_hor_luma,phase_ver_luma,phase_hor_chroma_plus8,phase_ver_chroma_plus8,num_cm_ref_layers_minus1,luma_bit_depth_cm_input_minus8,chroma_bit_depth_cm_input_minus8,luma_bit_depth_cm_output_minus8,chroma_bit_depth_cm_output_minus8,depthMaxValue,num_val_delta_dlt,max_diff=0,size_min_diff_minus1,min_diff_minus1=0,delta_dlt_val0,size_delta_val_diff_minus_min,delta_val_diff_minus_min,pps_num_palette_predictor_initializer,luma_bit_depth_entry_minus8=0,chroma_bit_depth_entry_minus8=0,numComps,comp,pps_palette_predictor_initializers; SInt32 init_qp_minus26,pps_cb_qp_offset,pps_cr_qp_offset,pps_beta_offset_div2,pps_tc_offset_div2,scaling_list_dc_coef_minus8[4][6], scaling_list_delta_coef,cb_qp_offset_list,cr_qp_offset_list,scaled_ref_layer_left_offset,scaled_ref_layer_top_offset,scaled_ref_layer_right_offset,scaled_ref_layer_bottom_offset,ref_region_left_offset,ref_region_right_offset,ref_region_top_offset,ref_region_bottom_offset,cm_adapt_threshold_u_delta,cm_adapt_threshold_v_delta,pps_act_y_qp_offset_plus5,pps_act_cb_qp_offset_plus5,pps_act_cr_qp_offset_plus3; @@ -3258,7 +3258,7 @@ OSErr Validate_NAL_Unit_HEVC( BitBuffer *inbb, UInt8 expect_type, UInt32 nal_le OSErr Validate_colour_mapping_octants(BitBuffer *bb, UInt32 inpDepth,UInt32 idxY,UInt32 idxCb,UInt32 idxCr, UInt32 inpLength,UInt8 cm_octant_depth,UInt8 cm_y_part_num_log2,UInt8 cm_delta_flc_bits_minus1) { OSErr err = noErr; - UInt8 PartNumY,split_octant_flag,coded_res_flag,res_coeff_s; + UInt8 PartNumY,split_octant_flag=0,coded_res_flag,res_coeff_s; UInt32 k,m,n,idxShiftY,i,j,c,res_coeff_q,res_coeff_r; PartNumY=1<profileLevelInd); + sprintf(profString,"WARNING: unknown visual profile= %u\n",p_vsc->profileLevelInd); if( p_vsc->profileLevelInd == 255 ){ err = 1; errprint("invalid visual profile= %lu\n",p_vsc->profileLevelInd); @@ -3892,7 +3892,7 @@ OSErr Validate_HEVCConfigRecord( BitBuffer *bb, void *refcon ) HevcConfigInfo hevcHeader; //UInt32* codec_specific; //int counter = 0; - UInt32 j,i; + UInt32 j=0,i=0; //codec_specific = &((tir->validatedSampleDescriptionRefCons)[tir->currentSampleDescriptionIndex - 1]); hevcHeader.config_ver = GetBits(bb, 8, &err); if (err) goto bail; diff --git a/ISOSegmentValidator/public/src/ValidateBits.cpp b/ISOSegmentValidator/public/src/ValidateBits.cpp index 2227ec5d..9b3fdc55 100755 --- a/ISOSegmentValidator/public/src/ValidateBits.cpp +++ b/ISOSegmentValidator/public/src/ValidateBits.cpp @@ -87,7 +87,7 @@ UInt32 GetBits(BitBuffer *bb, UInt32 nBits, OSErr *errout) { OSErr err = noErr; int myBits; - int myValue = 0; + UInt32 myValue = 0; int myResidualBits; int leftToRead; @@ -131,9 +131,11 @@ UInt32 GetBits(BitBuffer *bb, UInt32 nBits, OSErr *errout) bb->cbyte = ((bb->cbyte) << myBits) & 0xff; if (leftToRead > 0) { - UInt32 newBits; + UInt32 newBits, msb = 0; newBits = GetBits(bb, leftToRead, &err); - myValue = (myValue< 5) { UInt8 n_skip_bytes = GetBits(bb, 7, &err); if (err) GOTOBAIL; - atomprint("n_skip_bytes_%lld=\"%d\"\n", count, n_skip_bytes); + atomprint("n_skip_bytes_%ld=\"%d\"\n", count, n_skip_bytes); bits_counter += 7; for(i = 0;i < n_skip_bytes; i++) @@ -472,26 +472,26 @@ OSErr Validate_ac4_presentation_v0_dsi( BitBuffer *bb, void *refcon, UInt8* pres } } UInt8 b_pre_virtualized = GetBits(bb, 1, &err); if (err) GOTOBAIL; - atomprint("b_pre_virtualized_%lld=\"%d\"\n", count, b_pre_virtualized); + atomprint("b_pre_virtualized_%ld=\"%d\"\n", count, b_pre_virtualized); b_add_emdf_substreams=GetBits(bb, 1, &err); if (err) GOTOBAIL; - atomprint("b_add_emdf_substreams_%lld=\"%d\"\n", count, b_add_emdf_substreams); + atomprint("b_add_emdf_substreams_%ld=\"%d\"\n", count, b_add_emdf_substreams); bits_counter+=2; } if(b_add_emdf_substreams) { UInt8 n_add_emdf_substreams=GetBits(bb, 7, &err); if (err) GOTOBAIL; - atomprint("n_add_emdf_substreams_%lld=\"%d\"\n", count, n_add_emdf_substreams); + atomprint("n_add_emdf_substreams_%ld=\"%d\"\n", count, n_add_emdf_substreams); bits_counter+=7; for(j = 0;j < n_add_emdf_substreams;j++) { UInt8 substream_emdf_version = GetBits(bb, 5, &err); if (err) GOTOBAIL; - atomprint("substream_emdf_version_%lld_%lld=\"%d\"\n", count, j, substream_emdf_version); + atomprint("substream_emdf_version_%lld_%ld=\"%d\"\n", count, j, substream_emdf_version); UInt16 substream_key_id = GetBits(bb, 10, &err); if (err) GOTOBAIL; - atomprint("substream_key_id_%lld_%lld=\"%d\"\n", count, j, substream_key_id); + atomprint("substream_key_id_%lld_%ld=\"%d\"\n", count, j, substream_key_id); bits_counter += 15; } @@ -515,18 +515,18 @@ OSErr Validate_ac4_substream_dsi( BitBuffer *bb, void *refcon, UInt64* bits_coun UInt64 i; UInt8 channel_mode; channel_mode=GetBits(bb, 5, &err); if (err) GOTOBAIL; - atomprint("channel_mode_%lld=\"%d\"\n",count, channel_mode); + atomprint("channel_mode_%ld=\"%d\"\n",count, channel_mode); UInt8 dsi_sf_multiplier; dsi_sf_multiplier = GetBits(bb, 2, &err); if (err) GOTOBAIL; - atomprint("dsi_sf_multiplier_%lld=\"%d\"\n",count, dsi_sf_multiplier); + atomprint("dsi_sf_multiplier_%ld=\"%d\"\n",count, dsi_sf_multiplier); UInt8 b_substream_bitrate_indicator; b_substream_bitrate_indicator=GetBits(bb, 1, &err); if (err) GOTOBAIL; - atomprint("b_substream_bitrate_indicator_%lld=\"%d\"\n",count, b_substream_bitrate_indicator); + atomprint("b_substream_bitrate_indicator_%ld=\"%d\"\n",count, b_substream_bitrate_indicator); *bits_counter+=8; if(b_substream_bitrate_indicator){ UInt8 substream_bitrate_indicator; substream_bitrate_indicator = GetBits(bb, 5, &err); if (err) GOTOBAIL; - atomprint("substream_bitrate_indicator_%lld=\"%d\"\n",count, substream_bitrate_indicator); + atomprint("substream_bitrate_indicator_%ld=\"%d\"\n",count, substream_bitrate_indicator); *bits_counter+=5; } @@ -536,33 +536,33 @@ OSErr Validate_ac4_substream_dsi( BitBuffer *bb, void *refcon, UInt64* bits_coun if((channel_mode >= 7) && (channel_mode <= 10)) { UInt8 add_ch_base; add_ch_base = GetBits(bb, 1, &err); if (err) GOTOBAIL; - atomprint("add_ch_base_%lld=\"%d\"\n",count, add_ch_base); + atomprint("add_ch_base_%ld=\"%d\"\n",count, add_ch_base); *bits_counter+=1; } UInt8 b_content_type; b_content_type = GetBits(bb, 1, &err); if (err) GOTOBAIL; - atomprint("b_content_type_%lld=\"%d\"\n",count, b_content_type); + atomprint("b_content_type_%ld=\"%d\"\n",count, b_content_type); *bits_counter+=1; if(b_content_type) { UInt8 content_classifier; content_classifier = GetBits(bb, 3, &err); if (err) GOTOBAIL; - atomprint("content_classifier_%lld=\"%d\"\n",count, content_classifier); + atomprint("content_classifier_%ld=\"%d\"\n",count, content_classifier); UInt8 b_language_indicator; b_language_indicator = GetBits(bb, 1, &err); if (err) GOTOBAIL; - atomprint("b_language_indicator_%lld=\"%d\"\n",count, b_language_indicator); + atomprint("b_language_indicator_%ld=\"%d\"\n",count, b_language_indicator); *bits_counter+=4; if(b_language_indicator) { UInt8 n_language_tag_bytes; n_language_tag_bytes = GetBits(bb, 6, &err); if (err) GOTOBAIL; - atomprint("n_language_tag_bytes_%lld=\"%d\"\n",count, n_language_tag_bytes); + atomprint("n_language_tag_bytes_%ld=\"%d\"\n",count, n_language_tag_bytes); *bits_counter+=6; for(i=0;i 0) if (offset64 <= (vg.offsetEntries[index - 1].offset + vg.offsetEntries[index - 1].sizeRemoved-1)) { - fprintf(stderr, "Program error! Requested infomration is at offset %llu, which is in a removed region at index %d (offset: %llu, removed size: %llu), exiting!", offset64, index, vg.offsetEntries[index - 1].offset, vg.offsetEntries[index - 1].sizeRemoved); + fprintf(stderr, "Program error! Requested information is at offset %lu, which is in a removed region at index %d (offset: %lu, removed size: %lu), exiting!", offset64, index, vg.offsetEntries[index - 1].offset, vg.offsetEntries[index - 1].sizeRemoved); exit(-1); } } @@ -91,7 +91,7 @@ int GetFileData( atomOffsetEntry *aoe, void *dataP, UInt64 offset64, UInt64 size { #pragma unused(aoe) int err = 0; - long amtRead = 0; + SInt32 amtRead = 0; UInt64 size = size64; if (offset64 > 0x7FFFFFFFL) { @@ -111,42 +111,6 @@ int GetFileData( atomOffsetEntry *aoe, void *dataP, UInt64 offset64, UInt64 size if (newoffset64) *newoffset64 = offset64 + size; - /*{ - static int first = 1, count = 0; - static FILE* dbg; - - if(count < 2048) - { - if(first) - { - dbg = fopen("debug.bin","wb"); - if(!dbg) - fprintf(stderr,"Could not open debug.bin!\n"); - } - else - { - dbg = fopen("debug.bin","a"); - if(!dbg) - fprintf(stderr,"Could not open debug.bin for appending!\n"); - } - - if(dbg) - { - for(int index = 0 ; index < size ; index ++) - { - fwrite (&(((unsigned char *)dataP)[index]),1,1,dbg); - if(count < 100); - //printf("%c ",(((unsigned char *)dataP)[index])); - } - - count += size; - } - - fclose(dbg); - } - first = 0; - }*/ - bail: return err; } @@ -307,7 +271,7 @@ int GetSampleOffsetSize( TrackInfoRec *tir, UInt32 sampleNum, UInt64 *offsetOut, UInt32 size = 0; UInt32 chunkNum; UInt32 sampleDelta; - UInt64 offset; + UInt64 offset = 0; UInt32 sampleDescriptionIndex = 0; if (sampleNum > tir->sampleSizeEntryCnt) { @@ -361,7 +325,7 @@ int GetChunkOffsetSize( TrackInfoRec *tir, UInt32 chunkNum, UInt64 *offsetOut, U UInt32 sampleCnt = 1; UInt32 samplesPerChunk; UInt32 size = 0; - UInt64 offset; + UInt64 offset = 0; UInt32 sampleDescriptionIndex = 0; if (chunkNum > tir->chunkOffsetEntryCnt) { diff --git a/ISOSegmentValidator/public/src/ValidateHints.cpp b/ISOSegmentValidator/public/src/ValidateHints.cpp index b0600ade..53ebae6d 100755 --- a/ISOSegmentValidator/public/src/ValidateHints.cpp +++ b/ISOSegmentValidator/public/src/ValidateHints.cpp @@ -271,7 +271,7 @@ OSErr Validate_Hint_Track( atomOffsetEntry *aoe, TrackInfoRec *tir ) HintInfoRec hir = {}; UInt64 minOffset, maxOffset; - long cnt; + SInt32 cnt; atomOffsetEntry *list; OSErr tempErr; @@ -360,7 +360,7 @@ OSErr Validate_Hint_Track( atomOffsetEntry *aoe, TrackInfoRec *tir ) H_ATOM_PRINT_INCR(("\n")); if(!vg.dashSegment) for (i = startSampleNum; i <= endSampleNum; i++) { - if ((vg.samplenumber==0) || (vg.samplenumber==(long)i)) { + if ((vg.samplenumber==0) || (vg.samplenumber==(SInt32)i)) { err = GetSampleOffsetSize( tir, i, &sampleOffset, &sampleSize, &sampleDescriptionIndex ); if (err != noErr) { errprint("couldn't GetSampleOffsetSize for sample %ld (err %ld)\n", i, err); @@ -799,7 +799,7 @@ static OSErr Validate_Generic_MPEG4_Audio_Payload( char *inPayload, UInt32 inLen HintInfoRec *hir = (HintInfoRec*)inRefCon; UInt32 temp32; UInt32 numHeaders; - UInt16 auLength; + UInt16 auLength = 0; char *headerCurrent; char *auCurrent; char *auMax; @@ -1093,7 +1093,7 @@ static OSErr Validate_hint_udta_Atom( atomOffsetEntry *aoe, void *refcon ) OSErr err = noErr; OSErr atomerr = noErr; UInt64 minOffset, maxOffset; - long cnt; + SInt32 cnt; atomOffsetEntry *list; minOffset = aoe->offset + aoe->atomStartSize; @@ -1750,10 +1750,10 @@ static OSErr Validate_isma_attribute( HintInfoRec *hir, char *inValue) { #pragma unused(hir) OSErr err = noErr; - long profile, i; + SInt32 profile, i; float lowest, authored; - i = sscanf(inValue,"%ld,%f,%f",&profile,&lowest,&authored); + i = sscanf(inValue,"%u,%f,%f",&profile,&lowest,&authored); if (i<3) errprint("Bad ISMA compliance attribute %s\n",inValue); else { if ((profile<0) || (profile>4)) errprint("Bad ISMA compliance profile value %s\n",inValue); @@ -1809,7 +1809,7 @@ OSErr Base64DecodeToBuffer(const char *inData, UInt32 *ioEncodedLength, char *ou { OSErr err = noErr; - long encodedDataProcessed = 0; + SInt32 encodedDataProcessed = 0; const char *current; const char *end; char lookupChar; @@ -1994,7 +1994,7 @@ static SInt32 Chars_To_Num( char *inCharsStart, char *inCharsEnd, Boolean *outFo memcpy(tempString, inCharsStart, length); tempString[length] = '\0'; - sscanf(tempString, "%ld", &value); + sscanf(tempString, "%d", &value); found = true; bail: @@ -2026,7 +2026,7 @@ static SInt32 Chars_To_hexNum( char *inCharsStart, char *inCharsEnd, Boolean *ou memcpy(tempString, inCharsStart, length); tempString[length] = '\0'; - sscanf(tempString, "%lx", &value); + sscanf(tempString, "%x", &value); found = true; bail: @@ -2128,7 +2128,7 @@ static Boolean get_next_fmtp_param(char **inLine, char **outTagString, char **ou Boolean found = false; Ptr tag = NULL; Ptr value = NULL; - long length; + SInt32 length; // strip off leading spaces? @@ -2202,7 +2202,7 @@ static Boolean get_next_fmtp_param(char **inLine, char **outTagString, char **ou static OSErr get_original_track_info(UInt32 inRefTrackID, TrackInfoRec **outTIR) { OSErr err = noErr; - long i; + SInt32 i; MovieInfoRec *mir = vg.mir; if (mir == NULL) { diff --git a/ISOSegmentValidator/public/src/ValidateMP4.cpp b/ISOSegmentValidator/public/src/ValidateMP4.cpp index 287bb982..79460726 100755 --- a/ISOSegmentValidator/public/src/ValidateMP4.cpp +++ b/ISOSegmentValidator/public/src/ValidateMP4.cpp @@ -245,7 +245,7 @@ int main(void) vg.dvb=false; vg.hbbtv=false; vg.ctawave=false; - //vg.indexRange='\0'; + memset(&vg.indexRange, 0, sizeof(vg.indexRange)); vg.pssh_count = 0; vg.sencFound=false; vg.suppressAtomLevel=false; @@ -443,8 +443,12 @@ int main(void) free(arrayArgc); - if (vg.indexRange != nullptr) - sscanf (vg.indexRange,"%d-%d",&vg.lowerindexRange,&vg.higherindexRange); + if (vg.indexRange[0] != 0) + if (2 != sscanf(vg.indexRange,"%d-%d",&vg.lowerindexRange,&vg.higherindexRange)) + { + fprintf(stderr, "Error parsing range \"%d-%d\" from \"%s\"!\n", vg.lowerindexRange, vg.higherindexRange, vg.indexRange); + vg.lowerindexRange = vg.higherindexRange = -1; //reset + } //===================== @@ -600,7 +604,7 @@ int main(void) { int temp1; UInt64 temp2; - int ret = fscanf(segmentOffsetInfoFile,"%d %lld\n",&temp1,&temp2); + int ret = fscanf(segmentOffsetInfoFile,"%d %ld\n",&temp1,&temp2); if(ret < 2) break; @@ -769,7 +773,7 @@ void loadLeafInfo(char *leafInfoFileName) return; } - fscanf(leafInfoFile,"%lu\n",&vg.accessUnitDurationNonIndexedTrack); + fscanf(leafInfoFile,"%u\n",&vg.accessUnitDurationNonIndexedTrack); fscanf(leafInfoFile,"%u\n",&vg.numControlTracks); @@ -779,7 +783,7 @@ void loadLeafInfo(char *leafInfoFileName) for(unsigned int i = 0 ; i < vg.numControlTracks ; i++) { - fscanf(leafInfoFile,"%lu %lu\n",&vg.trackTypeInfo[i].track_ID,&vg.trackTypeInfo[i].componentSubType); + fscanf(leafInfoFile,"%u %u\n",&vg.trackTypeInfo[i].track_ID,&vg.trackTypeInfo[i].componentSubType); } for(unsigned int i = 0 ; i < vg.numControlTracks ; i++) @@ -810,7 +814,7 @@ void loadOffsetInfo(char *offsetsFileName) while(1) { - int ret = fscanf(offsetsFile,"%llu %llu\n",&dummy1,&dummy2); + int ret = fscanf(offsetsFile,"%lu %lu\n",&dummy1,&dummy2); if(ret > 2) { printf("%d entries found on entry number %d, improper offset info file, exiting!\n",ret,numEntries+1); @@ -839,7 +843,7 @@ void loadOffsetInfo(char *offsetsFileName) for(unsigned int index = 0 ; index < vg.numOffsetEntries ; index ++) { - fscanf(offsetsFile,"%llu %llu\n",&vg.offsetEntries[index].offset,&vg.offsetEntries[index].sizeRemoved); + fscanf(offsetsFile,"%lu %lu\n",&vg.offsetEntries[index].offset,&vg.offsetEntries[index].sizeRemoved); index = index; } @@ -941,7 +945,7 @@ void atomprint(const char *formatStr, ...) if (vg.printatom) { printf ("vg.printatom\n"); - long tabcnt = vg.tabcnt; + SInt32 tabcnt = vg.tabcnt; while (tabcnt-- > 0) { fprintf(_stdout,myTAB); } @@ -949,7 +953,7 @@ void atomprint(const char *formatStr, ...) } if(vg.atomxml){ - long tabcnt = vg.tabcnt; + SInt32 tabcnt = vg.tabcnt; while (tabcnt-- > 0) { fprintf(f,myTAB); } @@ -995,7 +999,7 @@ void atomprintdetailed(const char *formatStr, ...) va_start(ap, formatStr); if (vg.printatom && vg.print_fulltable) { - long tabcnt = vg.tabcnt; + SInt32 tabcnt = vg.tabcnt; while (tabcnt-- > 0) { fprintf(_stdout,myTAB); } @@ -1011,7 +1015,7 @@ void sampleprint(const char *formatStr, ...) va_start(ap, formatStr); if (vg.printsample) { - long tabcnt = vg.tabcnt; + SInt32 tabcnt = vg.tabcnt; while (tabcnt-- > 0) { fprintf(_stdout,myTAB); } @@ -1243,15 +1247,15 @@ char *ostypetostr_r(UInt32 num, char * buffer) // for cases where you need it more than once in the same print statment, use int64toxstr_r() instead char *int64toxstr(UInt64 num) { - static char str[20]; + static char str[32]; UInt32 hi,lo; hi = num>>32; lo = num&(0xffffffff); if (hi) { - sprintf(str,"0x%lx%8.8lx",hi,lo); + sprintf(str,"0x%u%8.8u",hi,lo); } else { - sprintf(str,"0x%lx",lo); + sprintf(str,"0x%u",lo); } return str; } @@ -1263,9 +1267,9 @@ char *int64toxstr_r(UInt64 num, char * str) hi = num>>32; lo = num&(0xffffffff); if (hi) { - sprintf(str,"0x%lx%8.8lx",hi,lo); + sprintf(str,"0x%u%8.8u",hi,lo); } else { - sprintf(str,"0x%lx",lo); + sprintf(str,"0x%u",lo); } return str; } @@ -1281,9 +1285,9 @@ char *int64todstr(UInt64 num) lo = num&(0xffffffff); if (hi) - sprintf(str,"%ld%8.8ld",hi,lo); + sprintf(str,"%u%8.8u",hi,lo); else - sprintf(str,"%ld",lo); + sprintf(str,"%u",lo); return str; } @@ -1296,9 +1300,9 @@ char *int64todstr_r(UInt64 num, char * str) lo = num&(0xffffffff); if (hi) - sprintf(str,"%ld%8.8ld",hi,lo); + sprintf(str,"%u%8.8u",hi,lo); else - sprintf(str,"%ld",lo); + sprintf(str,"%u",lo); return str; } @@ -1531,7 +1535,7 @@ void addEscapedChar( char *str, char c ) strcat(str, addc); } -void addAtomToPath( atompathType workingpath, OSType atomId, long atomIndex, atompathType curpath ) +void addAtomToPath( atompathType workingpath, OSType atomId, SInt32 atomIndex, atompathType curpath ) { strcpy( curpath, workingpath ); if (workingpath[0]) @@ -1541,7 +1545,7 @@ void addAtomToPath( atompathType workingpath, OSType atomId, long atomIndex, ato addEscapedChar(workingpath, (atomId>> 8) & 0xff); addEscapedChar(workingpath, (atomId>> 0) & 0xff); strcat( workingpath, "-"); - sprintf(&workingpath[strlen(workingpath)],"%ld",atomIndex); + sprintf(&workingpath[strlen(workingpath)],"%u", atomIndex); } void restoreAtomPath( atompathType workingpath, atompathType curpath ) diff --git a/ISOSegmentValidator/public/src/ValidateMP4.h b/ISOSegmentValidator/public/src/ValidateMP4.h index fab830b2..70514add 100755 --- a/ISOSegmentValidator/public/src/ValidateMP4.h +++ b/ISOSegmentValidator/public/src/ValidateMP4.h @@ -28,6 +28,7 @@ limitations under the License. #include #include #include +#include #include #if defined(__GNUC__) && ( defined(__APPLE_CPP__) || defined(__APPLE_CC__) || defined(__MACOS_CLASSIC__) ) @@ -56,7 +57,7 @@ limitations under the License. #endif typedef char *Ptr; -typedef unsigned long OSType; +typedef uint32_t OSType; typedef unsigned char Boolean; typedef short OSErr; @@ -71,23 +72,19 @@ enum { kSkipUnknownAtoms = 1L<<0 }; -typedef unsigned char UInt8; -typedef char SInt8; -typedef long SInt32; -typedef unsigned long UInt32; -typedef long Int32; -typedef short SInt16; -typedef unsigned short UInt16; +typedef uint8_t UInt8; +typedef int8_t SInt8; +typedef int32_t SInt32; +typedef uint32_t UInt32; +typedef int32_t Int32; +typedef int16_t SInt16; +typedef uint16_t UInt16; typedef UInt32 UnsignedFixed; typedef unsigned char uuidType[16]; // 128-bit uuid (guid) -#ifdef _MSC_VER -typedef unsigned __int64 UInt64; -typedef __int64 SInt64; -#else -typedef unsigned long long UInt64; -typedef long long SInt64; -#endif + +typedef uint64_t UInt64; +typedef int64_t SInt64; typedef UInt32 TimeValue; typedef UInt32 PriorityType; typedef SInt32 Fixed; @@ -120,7 +117,7 @@ typedef struct atomOffsetEntry { UInt32 atomStartSize; // size of id & size info, so it is easy to skip UInt32 aoeflags; // used for processing - UInt32 refconOverride; // used for processing + void* refconOverride; // used for processing } atomOffsetEntry; enum { @@ -207,7 +204,7 @@ enum { typedef char atompathType[100]; typedef char argstr[1000]; -void addAtomToPath( atompathType workingpath, OSType atomId, long atomIndex, atompathType curpath ); +void addAtomToPath( atompathType workingpath, OSType atomId, SInt32 atomIndex, atompathType curpath ); void restoreAtomPath( atompathType workingpath, atompathType curpath ); @@ -521,7 +518,7 @@ typedef struct { UInt64 fragment_duration; UInt32 mvhd_timescale; - long numTIRs; + SInt32 numTIRs; TrackInfoRec tirList[1]; MoofInfoRec *moofInfo; @@ -568,13 +565,13 @@ typedef struct{ // Validate Globals typedef struct { FILE *inFile; - long inOffset; - long inMaxOffset; + SInt32 inOffset; + SInt32 inMaxOffset; atompathType curatompath; Boolean printatom; Boolean printsample; - long tabcnt; + SInt32 tabcnt; atomOffsetEntry *fileaoe; // used when you need to read file & size from the file @@ -589,8 +586,8 @@ typedef struct { bool *psshFoundInSegment; bool *tencFoundInSegment; bool *dsms; - long segmentInfoSize; - long processedStypes; + SInt32 segmentInfoSize; + SInt32 processedStypes; UInt32 accessUnitDurationNonIndexedTrack; bool initializationSegment; bool checkSegAlignment; @@ -650,11 +647,11 @@ typedef struct { argstr printtypestr; argstr segmentOffsetInfo; - long filetype; - long checklevel; - long samplenumber; + SInt32 filetype; + SInt32 checklevel; + SInt32 samplenumber; - long majorBrand; + SInt32 majorBrand; Boolean dashSegment; Boolean dashInFtyp; Boolean msixInFtyp; @@ -682,7 +679,7 @@ typedef struct { extern ValidateGlobals vg; typedef struct AtomSizeType { - unsigned long atomSize; + UInt32 atomSize; OSType atomType; } AtomSizeType; @@ -691,7 +688,7 @@ typedef struct AtomStartRecord { UInt32 versFlags; } AtomStartRecord; -typedef OSErr (*ValidateAtomProcPtr)(OSType atomId, unsigned long atomSize, void *atomRec); +typedef OSErr (*ValidateAtomProcPtr)(OSType atomId, UInt32 atomSize, void *atomRec); #define CallValidateAtomProc(userRoutine, atomId, atomSize, atomRec) \ (*(userRoutine))((atomId), (atomSize), (atomRec)) @@ -976,11 +973,11 @@ enum { OSErr PeekDescriptorTag(BitBuffer *bb, UInt32 *tag, UInt32 *size); OSErr GetDescriptorTagAndSize(BitBuffer *bb, UInt32 *tag, UInt32 *size); -OSErr Validate_iods_OD_Bits( Ptr dataP, unsigned long dataSize, Boolean fileForm ); +OSErr Validate_iods_OD_Bits( Ptr dataP, UInt32 dataSize, Boolean fileForm ); int FindAtomOffsets( atomOffsetEntry *aoe, UInt64 startOffset, UInt64 maxOffset, - long *atomCountOut, atomOffsetEntry **atomOffsetsOut ); + SInt32 *atomCountOut, atomOffsetEntry **atomOffsetsOut ); UInt64 getAdjustedFileOffset(UInt64 offset64); UInt64 inflateOffset(UInt64 offset64); int GetFileDataN64( atomOffsetEntry *aoe, void *dataP, UInt64 offset64, UInt64 *newoffset64 ); @@ -1147,8 +1144,8 @@ typedef OSErr (*ValidateAtomTypeProcPtr)( atomOffsetEntry *aoe, void *refcon ); #define CallValidateAtomTypeProc(userRoutine, aoe, refcon) \ (*(userRoutine))((aoe),(refcon)) -OSErr ValidateAtomOfType( OSType theType, long flags, ValidateAtomTypeProcPtr validateProc, - long cnt, atomOffsetEntry *list, void *refcon ); +OSErr ValidateAtomOfType( OSType theType, SInt32 flags, ValidateAtomTypeProcPtr validateProc, + SInt32 cnt, atomOffsetEntry *list, void *refcon ); #define FieldMustBe( num, value, errstr ) \ do { if ((num) != (value)) { err = badAtomErr; warnprint("Warning for ISO/IEC 14496-12 " errstr "\n", (value), num); } } while (false) diff --git a/ISOSegmentValidator/public/src/ValidateMdatAtom.cpp b/ISOSegmentValidator/public/src/ValidateMdatAtom.cpp index c9b9ba05..c94d43ae 100644 --- a/ISOSegmentValidator/public/src/ValidateMdatAtom.cpp +++ b/ISOSegmentValidator/public/src/ValidateMdatAtom.cpp @@ -240,7 +240,7 @@ inline OSErr variable_bits(BitBuffer *bb, UInt32 n_bits, UInt32 *value) { OSErr err = noErr; UInt8 b_read_more; - printf("<%s>: variable_bits(%lu)\n", __FILE__, n_bits); + printf("<%s>: variable_bits(%u)\n", __FILE__, n_bits); *value = 0; do { *value += GetBits(bb, n_bits, &err); @@ -289,7 +289,8 @@ presentation_version() OSErr Validate_AC4_emdf_protection(BitBuffer *bb, void *refcon) { OSErr err = noErr; - UInt32 primary_length; + UInt32 primary_length = 0; + UInt32 secondary_length = 0; printf ("<%s> : ent \n", __FUNCTION__); atomprint(" : table->protection_length_primary %lu is invalid\n", __FUNCTION__, table->protection_length_primary); + printf("<%s> : table->protection_length_primary %u is invalid\n", __FUNCTION__, table->protection_length_primary); break; } VALIDATE_FIELD("%d", table, protection_bits_primary, primary_length); - UInt32 secondary_length; switch (table->protection_length_secondary) { case 0: @@ -517,9 +517,9 @@ OSErr Validate_AC4_presentation_substream_info(BitBuffer *bb, void *refcon) VALIDATE_FIELD("%d",table, substream_index, 2); if (table->substream_index == 3) { - printf ("table->substream_index_1 %lu\n", table->substream_index); + printf ("table->substream_index_1 %u\n", table->substream_index); BAILIFERR(variable_bits(bb, 2, &table->substream_index)); - printf ("table->substream_index_2 %lu\n", table->substream_index); + printf ("table->substream_index_2 %u\n", table->substream_index); } bail: @@ -1082,7 +1082,7 @@ OSErr Validate_AC4_Toc( BitBuffer *bb, void *refcon) //========================================================================================== OSErr Validate_mdat_Atom( atomOffsetEntry *aoe, void *refcon) { - printf ("<%s> : ent : aoe %p refcon %p\n", __FUNCTION__, aoe, refcon); + //printf ("<%s> : ent : aoe %p refcon %p\n", __FUNCTION__, aoe, refcon); OSErr err = noErr; unsigned int size; unsigned int type; @@ -1121,6 +1121,6 @@ OSErr Validate_mdat_Atom( atomOffsetEntry *aoe, void *refcon) atomprint("\n"); free(bsDataP); - printf ("<%s> : ret : err %d\n", __FUNCTION__, err); + //printf ("<%s> : ret : err %d\n", __FUNCTION__, err); return err; }