├── AlphaGhost.mvid.7z ├── AlphaGhost_opt_nc.apng.7z ├── AnimationFrames ├── BouncingBalls01.png ├── BouncingBalls02.png ├── BouncingBalls03.png ├── BouncingBalls04.png ├── BouncingBalls05.png ├── BouncingBalls06.png ├── BouncingBalls07.png ├── BouncingBalls08.png ├── BouncingBalls09.png ├── BouncingBalls10.png ├── BouncingBalls11.png ├── BouncingBalls12.png ├── BouncingBalls13.png ├── BouncingBalls14.png ├── BouncingBalls15.png ├── BouncingBalls16.png ├── BouncingBalls17.png ├── BouncingBalls18.png ├── BouncingBalls19.png ├── BouncingBalls20.png ├── BouncingBalls21.png ├── BouncingBalls22.png ├── BouncingBalls23.png ├── BouncingBalls24.png ├── BouncingBalls25.png ├── BouncingBalls26.png ├── BouncingBalls27.png ├── BouncingBalls28.png ├── BouncingBalls29.png └── BouncingBalls30.png ├── Beaker.gif ├── Bounce_16BPP_15FPS.mvid.7z ├── Bounce_24BPP_15FPS.mvid.7z ├── Bounce_32BPP_15FPS.mvid.7z ├── Classes ├── AVAnimator │ ├── AV7zApng2MvidResourceLoader.h │ ├── AV7zApng2MvidResourceLoader.m │ ├── AV7zAppResourceLoader.h │ ├── AV7zAppResourceLoader.m │ ├── AVAnimatorH264AlphaPlayer.h │ ├── AVAnimatorH264AlphaPlayer.m │ ├── AVAnimatorLayer.h │ ├── AVAnimatorLayer.m │ ├── AVAnimatorLayerPrivate.h │ ├── AVAnimatorMedia.h │ ├── AVAnimatorMedia.m │ ├── AVAnimatorMediaPrivate.h │ ├── AVAnimatorMediaRendererProtocol.h │ ├── AVAnimatorOpenGLView.h │ ├── AVAnimatorOpenGLView.m │ ├── AVAnimatorOpenGLViewPrivate.h │ ├── AVAnimatorView.h │ ├── AVAnimatorView.m │ ├── AVAnimatorViewPrivate.h │ ├── AVApng2MvidResourceLoader.h │ ├── AVApng2MvidResourceLoader.m │ ├── AVAppResourceLoader.h │ ├── AVAppResourceLoader.m │ ├── AVAsset2MvidResourceLoader.h │ ├── AVAsset2MvidResourceLoader.m │ ├── AVAssetAlphaFrameDecoder.h │ ├── AVAssetAlphaFrameDecoder.m │ ├── AVAssetConvertCommon.h │ ├── AVAssetFrameDecoder.h │ ├── AVAssetFrameDecoder.m │ ├── AVAssetJoinAlphaResourceLoader.h │ ├── AVAssetJoinAlphaResourceLoader.m │ ├── AVAssetMixAlphaResourceLoader.h │ ├── AVAssetMixAlphaResourceLoader.m │ ├── AVAssetReaderConvertMaxvid.h │ ├── AVAssetReaderConvertMaxvid.m │ ├── AVAssetWriterConvertFromMaxvid.h │ ├── AVAssetWriterConvertFromMaxvid.m │ ├── AVFileUtil.h │ ├── AVFileUtil.m │ ├── AVFrame.h │ ├── AVFrame.m │ ├── AVFrameDecoder.h │ ├── AVFrameDecoder.m │ ├── AVGIF89A2MvidResourceLoader.h │ ├── AVGIF89A2MvidResourceLoader.m │ ├── AVImageFrameDecoder.h │ ├── AVImageFrameDecoder.m │ ├── AVMvidFileWriter.h │ ├── AVMvidFileWriter.m │ ├── AVMvidFrameDecoder.h │ ├── AVMvidFrameDecoder.m │ ├── AVOfflineComposition.h │ ├── AVOfflineComposition.m │ ├── AVResourceLoader.h │ ├── AVResourceLoader.m │ ├── AVStreamEncodeDecode.h │ ├── AVStreamEncodeDecode.m │ ├── ApngConvertMaxvid.h │ ├── ApngConvertMaxvid.m │ ├── CGFrameBuffer.h │ ├── CGFrameBuffer.m │ ├── MutableAttrString.h │ ├── MutableAttrString.m │ ├── SegmentedMappedData.h │ ├── SegmentedMappedData.m │ ├── libapng.c │ ├── libapng.h │ ├── maxvid_decode.c │ ├── maxvid_decode.h │ ├── maxvid_decode_arm.s │ ├── maxvid_deltas.h │ ├── maxvid_deltas.m │ ├── maxvid_encode.h │ ├── maxvid_encode.m │ ├── maxvid_file.c │ ├── maxvid_file.h │ ├── movdata.c │ └── movdata.h ├── AutoPropertyRelease.h ├── AutoPropertyRelease.m ├── LZMASDK │ ├── 7z.h │ ├── 7zBuf.c │ ├── 7zBuf.h │ ├── 7zBuf2.c │ ├── 7zDec.c │ ├── 7zFile.c │ ├── 7zFile.h │ ├── 7zIn.c │ ├── 7zStream.c │ ├── 7zVersion.h │ ├── Alloc.c │ ├── Alloc.h │ ├── CpuArch.c │ ├── CpuArch.h │ ├── Delta.c │ ├── Delta.h │ ├── LZMAExtractor.h │ ├── LZMAExtractor.m │ ├── LzHash.h │ ├── Lzma2Dec.c │ ├── Lzma2Dec.h │ ├── LzmaDec.c │ ├── LzmaDec.h │ ├── Ppmd.h │ ├── Ppmd7.c │ ├── Ppmd7.h │ ├── Ppmd7Dec.c │ ├── Ppmd8.c │ ├── Ppmd8.h │ ├── Ppmd8Dec.c │ ├── RotateDefs.h │ ├── Types.h │ └── Util │ │ └── 7z │ │ ├── 7zAlloc.c │ │ ├── 7zAlloc.h │ │ └── 7zMain.c ├── MovieControls │ ├── MovieControlsViewController.h │ ├── MovieControlsViewController.m │ ├── MovieTransportBackground.png │ ├── VolumeLeftTall.png │ ├── VolumeRightTall.png │ ├── nexttrack.png │ ├── pause.png │ ├── play.png │ └── prevtrack.png ├── MovieControlsAdaptor.h ├── MovieControlsAdaptor.m ├── QTFileParserAppAppDelegate.h ├── QTFileParserAppAppDelegate.m ├── QTFileParserAppViewController.h ├── QTFileParserAppViewController.m └── Tests │ ├── 124x124_black_blue_h264.mov │ ├── 128x128_black_blue_h264.mov │ ├── 129x128_black_blue_h264.mov │ ├── 132x128_black_blue_h264.mov │ ├── 192x128_black_blue_h264.mov │ ├── 1x1.gif │ ├── 240x160_black_blue_h264.mov │ ├── 2x2_16BPP_1FPS_3Frames_nop.mvid │ ├── 2x2_alpha_reveal_32BPP.apng │ ├── 2x2_alpha_reveal_palette.apng │ ├── 2x2_black_blue_16BPP.mvid │ ├── 2x2_black_blue_16BPP.mvid.7z │ ├── 2x2_black_blue_1LD_opt.apng │ ├── 2x2_black_blue_24BPP.apng │ ├── 2x2_black_blue_24BPP.mvid │ ├── 2x2_black_blue_24BPP_opt_nc.apng.7z │ ├── 2x2_black_blue_32BPP.mvid │ ├── 2x2_nop.apng │ ├── 32x32_black_blue_h264.mov │ ├── 3x3_bwd_ANI_16BPP.mvid │ ├── 3x3_bwd_ANI_24BPP.mvid │ ├── 480x320_black_blue_16BPP.mvid.7z │ ├── 480x320_black_blue_1LD_16BPP.mvid.7z │ ├── 480x320_black_blue_1LD_24BPP.mvid.7z │ ├── 64x64_nop_3frames_h264.mov │ ├── AVAnimatorLayerTests.m │ ├── AVAnimatorMediaTests.m │ ├── AVAnimatorOpenGLViewTests.m │ ├── AVAnimatorViewTests.m │ ├── AVAssetJoinAlphaResourceLoaderTests.m │ ├── AVFrameDecoderTests.m │ ├── AVMvidFileWriterTests.m │ ├── AVOfflineComposition2xScale.plist │ ├── AVOfflineComposition32x32BlackBlueTest.plist │ ├── AVOfflineCompositionManyTextFields.plist │ ├── AVOfflineCompositionTests.m │ ├── AVOfflineCompositionTwoFrameBlackBlueMovieTest.plist │ ├── AVOfflineCompositionTwoFrameBlackBlueScaleMovieTest.plist │ ├── AVOfflineCompositionTwoFrameBlueBackgroundTest.plist │ ├── AVOfflineCompositionTwoFrameStaticImageAndTextTest.plist │ ├── AVOfflineCompositionTwoFrameStaticImageAndTwoTextTest.plist │ ├── AVOfflineCompositionTwoFrameStaticImageTest.plist │ ├── AVResourceLoaderTests.m │ ├── AlphaGhost_alpha_CRF_30_24BPP.m4v │ ├── AlphaGhost_rgb_CRF_30_24BPP.m4v │ ├── Colorbands_sRGB.png │ ├── ColorspaceTests.m │ ├── ExplosionAdjusted_alpha_CRF_30_24BPP.m4v │ ├── ExplosionAdjusted_rgb_CRF_30_24BPP.m4v │ ├── Grayscale256x256.m4v │ ├── Grayscale256x256.png │ ├── H264AlphaPlayerTests.m │ ├── H264EncoderDecoderTests.m │ ├── MaxvidEncodeDecodeTests.m │ ├── MaxvidEncodeTests.m │ ├── PremultiplyTests.m │ ├── RGB3Frame_mix.m4v │ ├── RegressionTests.h │ ├── RegressionTests.m │ ├── SegmentedMappedDataTests.m │ ├── Silence3S.wav │ ├── ViewLoadTests.m │ ├── Waterfall_tiny_h264.mov │ ├── stutterwalk_h264.mov │ └── superwalk_h264.mov ├── CountingAnimation ├── Counting01.png ├── Counting02.png ├── Counting03.png ├── Counting04.png ├── Counting05.png ├── Counting06.png ├── Counting07.png └── Counting08.png ├── CountingLandscape ├── CountingLandscape01.png ├── CountingLandscape02.png ├── CountingLandscape03.png ├── CountingLandscape04.png └── CountingLandscape05.png ├── CrewSub_200_16BPP.mvid.7z ├── Default-568h@2x.png ├── GradientColorWheel_2FPS_32BPP_Keyframes.mvid.7z ├── Icon.png ├── JigsawPuzzle_205_99_10FPS_16BPP.mvid ├── LCD.jpg ├── LICENSE ├── License.txt ├── MainWindow.xib ├── Matrix_480_320_10FPS_16BPP.mvid.7z ├── QTFileParserApp-Info.plist ├── QTFileParserApp.xcodeproj ├── mo.mode1v3 ├── mo.pbxuser └── project.pbxproj ├── QTFileParserAppViewController.xib ├── QTFileParserApp_Prefix.pch ├── README.md ├── RedSquare_16BPP.mvid.7z ├── RegressionTests-Info.plist ├── Sweep15FPS.caf ├── Sweep15FPS.m4a ├── Sweep15FPS.mvid.7z ├── main.m ├── smiley.png └── superwalk.gif /AlphaGhost.mvid.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AlphaGhost.mvid.7z -------------------------------------------------------------------------------- /AlphaGhost_opt_nc.apng.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AlphaGhost_opt_nc.apng.7z -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls01.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls02.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls03.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls04.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls05.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls06.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls07.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls08.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls09.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls10.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls11.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls12.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls13.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls14.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls15.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls16.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls17.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls18.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls19.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls20.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls21.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls22.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls23.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls24.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls25.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls26.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls27.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls28.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls29.png -------------------------------------------------------------------------------- /AnimationFrames/BouncingBalls30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/AnimationFrames/BouncingBalls30.png -------------------------------------------------------------------------------- /Beaker.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Beaker.gif -------------------------------------------------------------------------------- /Bounce_16BPP_15FPS.mvid.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Bounce_16BPP_15FPS.mvid.7z -------------------------------------------------------------------------------- /Bounce_24BPP_15FPS.mvid.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Bounce_24BPP_15FPS.mvid.7z -------------------------------------------------------------------------------- /Bounce_32BPP_15FPS.mvid.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Bounce_32BPP_15FPS.mvid.7z -------------------------------------------------------------------------------- /Classes/AVAnimator/AV7zApng2MvidResourceLoader.h: -------------------------------------------------------------------------------- 1 | // 2 | // AV7zApng2MvidResourceLoader.h 3 | // 4 | // Created by Moses DeJong on 5/2/11. 5 | // 6 | // License terms defined in License.txt. 7 | // 8 | // This loader decompresses a 7zip resource that contains a .apng movie 9 | // and converts to a .mvid video file. See AVApng2MvidResourceLoader.h 10 | // for more info about APNG format support. 11 | 12 | #import 13 | 14 | #import "AV7zAppResourceLoader.h" 15 | 16 | @interface AV7zApng2MvidResourceLoader : AV7zAppResourceLoader { 17 | BOOL m_alwaysGenerateAdler; 18 | } 19 | 20 | @property (nonatomic, assign) BOOL alwaysGenerateAdler; 21 | 22 | + (AV7zApng2MvidResourceLoader*) aV7zApng2MvidResourceLoader; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AV7zAppResourceLoader.h: -------------------------------------------------------------------------------- 1 | // 2 | // AV7zAppResourceLoader.h 3 | // 4 | // Created by Moses DeJong on 4/22/11. 5 | // 6 | // License terms defined in License.txt. 7 | // 8 | // Extend AVAppResourceLoader to support loading of 7zip compressed resource files. 9 | // For example, a resource named "2x2_black_blue_16BPP.mvid.7z" could be decompressed 10 | // to "2x2_black_blue_16BPP.mvid". The file is decompressed into the tmp dir in 11 | // a second thread. The caller must define the archiveFilename, movieFilename, and 12 | // outPath properties. The outPath is a .mvid file path. 13 | 14 | #import 15 | 16 | #import "AVAppResourceLoader.h" 17 | 18 | #import "AVAssetConvertCommon.h" 19 | 20 | @interface AV7zAppResourceLoader : AVAppResourceLoader { 21 | NSString *m_archiveFilename; 22 | NSString *m_outPath; 23 | BOOL startedLoading; 24 | 25 | #if defined(HAS_LIB_COMPRESSION_API) 26 | BOOL m_compressed; 27 | #endif // HAS_LIB_COMPRESSION_API 28 | } 29 | 30 | // The name of the archive resource file. Typically: "XYZ.mvid.7z" but 31 | // any file type can be 7z decoded. 32 | @property (nonatomic, copy) NSString *archiveFilename; 33 | 34 | // The fully qualified filename for the extracted data. For example: "XYZ.mov" 35 | @property (nonatomic, copy) NSString *outPath; 36 | 37 | // Set this property to TRUE to indicate that the file to be decompressed 38 | // is a .mvid file and that the result should be processed to flatten out 39 | // all delta frames into keyframes. This typically results in a larger 40 | // .mvid file when written to disk but it makes possible the use of 41 | // a mapped memory optimization that can directly blit whole pages 42 | // into video memory without having to copy data. Setting the property 43 | // to TRUE while decompressing a .mvid that contains only keyframes is a nop. 44 | 45 | @property (nonatomic, assign) BOOL flattenMvid; 46 | 47 | // Set this property to TRUE to enable keyframe compression, if this property 48 | // is set then flattenMvid is implicitly TRUE. 49 | 50 | #if defined(HAS_LIB_COMPRESSION_API) 51 | @property (nonatomic, assign) BOOL compressed; 52 | #endif // HAS_LIB_COMPRESSION_API 53 | 54 | + (AV7zAppResourceLoader*) aV7zAppResourceLoader; 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVAnimatorH264AlphaPlayer.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVAnimatorH264AlphaPlayer.h 3 | // 4 | // Created by Moses DeJong on 2/27/16. 5 | // 6 | // License terms defined in License.txt. 7 | // 8 | // The AVAnimatorH264AlphaPlayer class provides a self contained player 9 | // for a mixed H264 video that contains both RGB + Alpha channels of 10 | // data encoded as interleaved frames. This class extends GLKView 11 | // and provides functionality that decodes video data from a resource 12 | // file or regular file and then sends the video data to the view. 13 | // Any audio data contained in the asset is ignored. 14 | // 15 | // Because of the way iOS implements asset loading, it is not possible 16 | // to seamlessly loop an asset video. The prepareToAnimate method must be 17 | // invoked in order to kick off an animation loop, then the startAnimator 18 | // method should be invoked in the AVAnimatorPreparedToAnimateNotification 19 | // callback. The asset must be loaded on a background thread to avoid 20 | // blocking the main thread before each animation cycle can begin. 21 | // 22 | // Note that playback on iOS supports only video data encoded at 23 | // 30 FPS (the standard 29.97 FPS is close enough). Playback will 24 | // smoothly render at exactly 30 FPS via a display link timed 25 | // OpenGL render and a high prio background thread. Note that the 26 | // caller should be careful to invoke stopAnimator when the view 27 | // is going away or the whole app is going into the background. 28 | 29 | #import "AVAssetConvertCommon.h" 30 | 31 | #if defined(HAS_AVASSET_READ_COREVIDEO_BUFFER_AS_TEXTURE) 32 | 33 | #import 34 | #import 35 | 36 | #import "AVAssetFrameDecoder.h" 37 | 38 | // These notifications are delived from the AVAnimatorH264AlphaPlayer 39 | 40 | #define AVAnimatorPreparedToAnimateNotification @"AVAnimatorPreparedToAnimateNotification" 41 | #define AVAnimatorFailedToLoadNotification @"AVAnimatorFailedToLoadNotification" 42 | 43 | #define AVAnimatorDidStartNotification @"AVAnimatorDidStartNotification" 44 | #define AVAnimatorDidStopNotification @"AVAnimatorDidStopNotification" 45 | 46 | 47 | @interface AVAnimatorH264AlphaPlayer : GLKView 48 | 49 | // static ctor : create view that has the screen dimensions 50 | + (AVAnimatorH264AlphaPlayer*) aVAnimatorH264AlphaPlayer; 51 | 52 | // static ctor : create view with the given dimensions 53 | + (AVAnimatorH264AlphaPlayer*) aVAnimatorH264AlphaPlayerWithFrame:(CGRect)viewFrame; 54 | 55 | // Set this property to indicate the name of the asset to be 56 | // loaded as a result of calling startAnimator. 57 | 58 | @property (atomic, copy) NSString *assetFilename; 59 | 60 | @property (atomic, retain) AVAssetFrameDecoder *frameDecoder; 61 | 62 | // In DEBUG mode, this property can be set to a directory and each rendered 63 | // output frame will be captured as BGRA and saved in a PNG. 64 | 65 | #if defined(DEBUG) 66 | @property (nonatomic, copy) NSString *captureDir; 67 | #endif // DEBUG 68 | 69 | // Invoke this metho to read from the named asset and being loading initial data 70 | 71 | - (void) prepareToAnimate; 72 | 73 | // After an animator has been prepared and the AVAnimatorPreparedToAnimateNotification has 74 | // been delivered this startAnimator API can be invoked to actually kick off the playback loop. 75 | 76 | - (void) startAnimator; 77 | 78 | // Stop playback of animator, nop is not currently animating 79 | 80 | - (void) stopAnimator; 81 | 82 | @end 83 | 84 | #endif // HAS_AVASSET_READ_COREVIDEO_BUFFER_AS_TEXTURE 85 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVAnimatorLayer.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVAnimatorLayer.h 3 | // 4 | // Created by Moses DeJong on 3/18/09. 5 | // 6 | // License terms defined in License.txt. 7 | // 8 | // The AVAnimatorLayer class provides a way to render 9 | // media frames into a CALayer object. Media frames 10 | // with whole or partial transparency are supported 11 | // automatically. One would allocate an AVAnimatorLayer 12 | // and pass the CALayer ref that will be the target 13 | // of the rendering operation. 14 | 15 | #import 16 | 17 | #import "AVAnimatorMediaRendererProtocol.h" 18 | 19 | @class AVAnimatorMedia; 20 | 21 | @interface AVAnimatorLayer : NSObject { 22 | @private 23 | CALayer *m_layerObj; 24 | AVAnimatorMedia *m_mediaObj; 25 | AVFrame *m_frameObj; 26 | BOOL mediaDidLoad; 27 | } 28 | 29 | // public properties 30 | 31 | @property (nonatomic, readonly) CALayer *layer; 32 | @property (nonatomic, readonly) AVAnimatorMedia *media; 33 | 34 | // static ctor : create view that renders to the core animation layer 35 | + (AVAnimatorLayer*) aVAnimatorLayer:(CALayer*)layer; 36 | 37 | // A media item is attached to the view to indicate that the media will 38 | // render to this view. 39 | 40 | - (void) attachMedia:(AVAnimatorMedia*)inMedia; 41 | 42 | // Implement AVAnimatorMediaRendererProtocol protocol 43 | 44 | // Invoked with TRUE argument once renderer has been attached to loaded media, 45 | // otherwise FALSE is passed to indicate the renderer could not be attached 46 | 47 | - (void) mediaAttached:(BOOL)worked; 48 | 49 | // setter for obj.AVFrame property 50 | 51 | - (void) setAVFrame:(AVFrame*)inFrame; 52 | 53 | // getter for obj.AVFrame property 54 | 55 | - (AVFrame*) AVFrame; 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVAnimatorLayer.m: -------------------------------------------------------------------------------- 1 | // 2 | // AVAnimatorLayer.m 3 | // 4 | // Created by Moses DeJong on 3/18/09. 5 | // 6 | // License terms defined in License.txt. 7 | 8 | #import 9 | 10 | #import "AVAnimatorMedia.h" 11 | 12 | // private properties declaration for AVAnimatorLayer class 13 | #import "AVAnimatorLayerPrivate.h" 14 | 15 | // private method in Media class 16 | #include "AVAnimatorMediaPrivate.h" 17 | 18 | #if __has_feature(objc_arc) 19 | #else 20 | #import "AutoPropertyRelease.h" 21 | #endif // objc_arc 22 | 23 | #import "AVFrame.h" 24 | 25 | // AVAnimatorLayer class 26 | 27 | @implementation AVAnimatorLayer 28 | 29 | // public properties 30 | 31 | @synthesize layerObj = m_layerObj; 32 | @synthesize mediaObj = m_mediaObj; 33 | @synthesize frameObj = m_frameObj; 34 | 35 | - (void) dealloc { 36 | // Detach but don't bother making a copy of the final image 37 | 38 | if (self.mediaObj) { 39 | [self.mediaObj detachFromRenderer:self copyFinalFrame:FALSE]; 40 | } 41 | 42 | self.layer.contents = nil; 43 | 44 | #if __has_feature(objc_arc) 45 | #else 46 | [AutoPropertyRelease releaseProperties:self thisClass:AVAnimatorLayer.class]; 47 | [super dealloc]; 48 | #endif // objc_arc 49 | } 50 | 51 | // static ctor 52 | 53 | + (AVAnimatorLayer*) aVAnimatorLayer:(CALayer*)layer 54 | { 55 | NSAssert(layer, @"layer"); 56 | AVAnimatorLayer *obj = [[AVAnimatorLayer alloc] init]; 57 | #if __has_feature(objc_arc) 58 | #else 59 | obj = [obj autorelease]; 60 | #endif // objc_arc 61 | obj.layerObj = layer; 62 | return obj; 63 | } 64 | 65 | // Invoked with TRUE argument once renderer has been attached to loaded media, 66 | // otherwise FALSE is passed to indicate the renderer could not be attached 67 | 68 | - (void) mediaAttached:(BOOL)worked 69 | { 70 | if (worked) { 71 | NSAssert(self.media, @"media is nil"); 72 | NSAssert(self.media.frameDecoder, @"frameDecoder is nil"); 73 | 74 | self->mediaDidLoad = TRUE; 75 | } else { 76 | self.mediaObj = nil; 77 | self->mediaDidLoad = FALSE; 78 | } 79 | 80 | return; 81 | } 82 | 83 | - (void) attachMedia:(AVAnimatorMedia*)inMedia 84 | { 85 | #if defined(DEBUG) 86 | assert([NSThread currentThread] == [NSThread mainThread]); 87 | #endif // DEBUG 88 | 89 | AVAnimatorMedia *currentMedia = self.mediaObj; 90 | 91 | if (currentMedia == inMedia) { 92 | // Detaching and the reattaching the same media is a no-op 93 | return; 94 | } 95 | 96 | if (inMedia == nil) { 97 | // Detach case, not attaching another media object so copy 98 | // the last rendered frame. 99 | 100 | [currentMedia detachFromRenderer:self copyFinalFrame:TRUE]; 101 | self.mediaObj = nil; 102 | self.frameObj = nil; 103 | self->mediaDidLoad = FALSE; 104 | return; 105 | } 106 | 107 | [currentMedia detachFromRenderer:self copyFinalFrame:FALSE]; 108 | self.mediaObj = inMedia; 109 | self.frameObj = nil; 110 | self->mediaDidLoad = FALSE; 111 | [inMedia attachToRenderer:self]; 112 | return; 113 | } 114 | 115 | // Implement read-only property for use outside this class 116 | 117 | - (AVAnimatorMedia*) media 118 | { 119 | return self->m_mediaObj; 120 | } 121 | 122 | - (CALayer*) layer 123 | { 124 | return self->m_layerObj; 125 | } 126 | 127 | // This method is invoked as part of the AVAnimatorMediaRendererProtocol when 128 | // a new frame is generated by the media. Note that we only need to 129 | // set the contents of the CALayer when the image actually 130 | // changes. A duplicate frame would contain the same image data as the previous 131 | // frame and redrawing would be a serious performance issue. 132 | // Rendering the CGImageRef is handled by the CALayer class. 133 | 134 | // setter for obj.AVFrame property 135 | 136 | - (void) setAVFrame:(AVFrame*)inFrame 137 | { 138 | if (inFrame == nil) { 139 | self.frameObj = nil; 140 | self.layer.contents = nil; 141 | } else { 142 | self.frameObj = inFrame; 143 | if (inFrame.isDuplicate == FALSE) { 144 | UIImage *image = inFrame.image; 145 | CGImageRef cgImage = image.CGImage; 146 | 147 | self.layer.contents = 148 | #if __has_feature(objc_arc) 149 | (__bridge id) cgImage; 150 | #else 151 | (id) cgImage; 152 | #endif // objc_arc 153 | } 154 | } 155 | } 156 | 157 | // getter for obj.AVFrame property 158 | 159 | - (AVFrame*) AVFrame 160 | { 161 | return self.frameObj; 162 | } 163 | 164 | @end 165 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVAnimatorLayerPrivate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVAnimatorLayerPrivate.h 3 | // 4 | // Created by Moses DeJong on 1/8/11. 5 | // 6 | // This file defines the private members of the AVAnimatorLayer. 7 | // These fields would typically be used only by the implementation 8 | // of AVAnimatorLayer, but could be needed for regression tests. 9 | // 10 | // License terms defined in License.txt. 11 | 12 | #import 13 | 14 | #import 15 | 16 | #import "AVAnimatorLayer.h" 17 | 18 | // private properties declaration for AVAnimatorLayer class 19 | 20 | @interface AVAnimatorLayer () 21 | 22 | @property (nonatomic, retain) CALayer *layerObj; 23 | 24 | @property (nonatomic, retain) AVAnimatorMedia *mediaObj; 25 | 26 | @property (nonatomic, retain) AVFrame *frameObj; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVAnimatorMediaPrivate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVAnimatorMediaPrivate.h 3 | // 4 | // Created by Moses DeJong on 1/8/11. 5 | // 6 | // This file defines the private members of the AVAnimatorMedia. 7 | // These fields would typically be used only by the implementation 8 | // of AVAnimatorMedia, but could be needed for regression tests. 9 | // 10 | // License terms defined in License.txt. 11 | 12 | #import 13 | 14 | #import 15 | 16 | #import "AVAnimatorMedia.h" 17 | 18 | // private properties declaration for AVAnimatorMedia class 19 | 20 | @interface AVAnimatorMedia () 21 | 22 | @property (nonatomic, assign) id renderer; 23 | 24 | @property (nonatomic, copy) NSURL *animatorAudioURL; 25 | 26 | @property (nonatomic, retain) AVFrame *prevFrame; 27 | @property (nonatomic, retain) AVFrame *nextFrame; 28 | 29 | @property (nonatomic, retain) NSTimer *animatorPrepTimer; 30 | @property (nonatomic, retain) NSTimer *animatorReadyTimer; 31 | @property (nonatomic, retain) NSTimer *animatorDecodeTimer; 32 | @property (nonatomic, retain) NSTimer *animatorDisplayTimer; 33 | 34 | // currentFrame is the frame index for the frame on the left 35 | // of a decode time window. When decoding, the frame just 36 | // before the one to be decoded next will be calculated 37 | // from the time and saved as currentFrame. Basically this 38 | // is the index of the frame being displayed "now". The 39 | // tricky part is that on init or after a stop, the 40 | // current frame is -1 to indicate that no specific 41 | // frame is being displayed. 42 | 43 | @property (nonatomic, assign) NSInteger currentFrame; 44 | 45 | @property (nonatomic, assign) NSUInteger repeatedFrameCount; 46 | 47 | @property (nonatomic, retain) AVAudioPlayer *avAudioPlayer; 48 | 49 | // originalAudioDelegate and retainedAudioDelegate are not properties 50 | 51 | @property (nonatomic, retain) NSDate *audioSimulatedStartTime; 52 | @property (nonatomic, retain) NSDate *audioSimulatedNowTime; 53 | @property (nonatomic, retain) NSDate *audioPlayerFallbackStartTime; 54 | @property (nonatomic, retain) NSDate *audioPlayerFallbackNowTime; 55 | 56 | @property (nonatomic, assign) AVAnimatorPlayerState state; 57 | @property (nonatomic, assign) NSTimeInterval pauseTimeInterval; 58 | @property (nonatomic, assign) NSTimeInterval animatorMaxClockTime; 59 | @property (nonatomic, assign) NSTimeInterval animatorDecodeTimerInterval; 60 | 61 | @property (nonatomic, assign) BOOL startAnimatorWhenReady; 62 | 63 | @property (nonatomic, assign) BOOL decodedSecondFrame; 64 | @property (nonatomic, assign) BOOL ignoreRepeatedFirstFrameReport; 65 | @property (nonatomic, assign) BOOL decodedLastFrame; 66 | @property (nonatomic, assign) BOOL reportTimeFromFallbackClock; 67 | 68 | // private methods 69 | 70 | - (BOOL) _animatorDecodeNextFrame; 71 | 72 | - (void) _animatorDecodeInitialFrameCallback: (NSTimer *)timer; 73 | 74 | - (void) _animatorDecodeFrameCallback: (NSTimer *)timer; 75 | 76 | - (void) _animatorDisplayFrameCallback: (NSTimer *)timer; 77 | 78 | -(void) _setAudioSessionCategory; 79 | 80 | // These next two method should be invoked from a renderer to signal 81 | // when this media item is attached to and detached from a renderer. 82 | 83 | - (BOOL) attachToRenderer:(id)renderer; 84 | 85 | - (void) detachFromRenderer:(id)renderer copyFinalFrame:(BOOL)copyFinalFrame; 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVAnimatorMediaRendererProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVAnimatorMediaRendererProtocol.h 3 | // 4 | // Created by Moses DeJong on 1/20/10. 5 | // 6 | // License terms defined in License.txt. 7 | // 8 | // This class defines the protocol that a media render must implement. 9 | // The object that contains a AVAnimatorMedia object must set the 10 | // media.renderer reference so that the media is able to update 11 | // the on screen display when media data is updated. Each time a frame 12 | // of video data is ready, the setFrame setter method is invoked. 13 | 14 | #import 15 | 16 | @class AVFrame; 17 | 18 | @protocol AVAnimatorMediaRendererProtocol 19 | 20 | // Invoked with TRUE argument once renderer has been attached to loaded media, 21 | // otherwise FALSE is passed to indicate the renderer could not be attached 22 | 23 | - (void) mediaAttached:(BOOL)worked; 24 | 25 | // setter for obj.AVFrame property 26 | 27 | - (void) setAVFrame:(AVFrame*)inFrame; 28 | 29 | // getter for obj.AVFrame property 30 | 31 | - (AVFrame*) AVFrame; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVAnimatorOpenGLView.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVAnimatorOpenGLView.h 3 | // 4 | // Created by Moses DeJong on 7/29/13. 5 | // 6 | // License terms defined in License.txt. 7 | // 8 | // The AVAnimatorOpenGLView class provides a view implementation that 9 | // is able to render CoreVideo pixel buffers directly without costly 10 | // framebuffer copy operations. This implementation is based on use of 11 | // AVAsset to decode h.264 video in hardware and then OpenGL to 12 | // actually present the hardware decoded frame on screen in an optimal 13 | // way. This implementation depends on CoreVideo APIs introdued in iOS 14 | // 5.0, so it will not function on earlier versions of iOS. 15 | 16 | #import "AVAssetConvertCommon.h" 17 | 18 | #if defined(HAS_AVASSET_READ_COREVIDEO_BUFFER_AS_TEXTURE) 19 | 20 | #import 21 | #import 22 | 23 | #import "AVAnimatorMediaRendererProtocol.h" 24 | 25 | @class AVAnimatorMedia; 26 | 27 | @interface AVAnimatorOpenGLView : GLKView 28 | 29 | // public properties 30 | 31 | @property (nonatomic, readonly) AVAnimatorMedia *media; 32 | 33 | // static ctor : create view that has the screen dimensions 34 | + (AVAnimatorOpenGLView*) aVAnimatorOpenGLView; 35 | 36 | // static ctor : create view with the given dimensions 37 | + (AVAnimatorOpenGLView*) aVAnimatorOpenGLViewWithFrame:(CGRect)viewFrame; 38 | 39 | // A media item is attached to the view to indicate that the media will 40 | // render to this view. 41 | 42 | - (void) attachMedia:(AVAnimatorMedia*)inMedia; 43 | 44 | // Implement AVAnimatorMediaRendererProtocol protocol 45 | 46 | // Invoked with TRUE argument once renderer has been attached to loaded media, 47 | // otherwise FALSE is passed to indicate the renderer could not be attached 48 | 49 | - (void) mediaAttached:(BOOL)worked; 50 | 51 | // Note that the superclass implicitly defines setImage 52 | 53 | @end 54 | 55 | #endif // HAS_AVASSET_READ_COREVIDEO_BUFFER_AS_TEXTURE 56 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVAnimatorOpenGLViewPrivate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVAnimatorOpenGLViewPrivate.h 3 | // 4 | // Created by Moses DeJong on 7/29/13. 5 | // 6 | // This file defines the private members of the AVAnimatorOpenGLView. 7 | // These fields would typically be used only by the implementation 8 | // of AVAnimatorOpenGLView, but could be needed for regression tests. 9 | // 10 | // License terms defined in License.txt. 11 | 12 | #import 13 | 14 | #import 15 | 16 | #import "AVAnimatorOpenGLView.h" 17 | 18 | // private properties declaration for AVAnimatorOpenGLView class 19 | 20 | @interface AVAnimatorOpenGLView () 21 | 22 | @property (nonatomic, assign) CGSize renderSize; 23 | 24 | @property (nonatomic, retain) AVAnimatorMedia *mediaObj; 25 | 26 | @property (nonatomic, retain) AVFrame *frameObj; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVAnimatorView.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVAnimatorView.h 3 | // 4 | // Created by Moses DeJong on 3/18/09. 5 | // 6 | // License terms defined in License.txt. 7 | // 8 | // The AVAnimatorView class provides a view that an animator can 9 | // render into. The view renders UIImage objects generated 10 | // by an attached media object. When the media renders an image 11 | // that is the exact same size as the view, the image will be 12 | // displayed at exact pixel resolution. Otherwise, the rendered 13 | // image will be scaled to fit into the view in the ways supported 14 | // by the UIImageView class. Media frames with whole or partial 15 | // transparency are supported automatically. 16 | 17 | #import 18 | 19 | #import "AVAnimatorMediaRendererProtocol.h" 20 | 21 | @class AVAnimatorMedia; 22 | 23 | @interface AVAnimatorView : UIImageView { 24 | @private 25 | UIImageOrientation m_animatorOrientation; 26 | CGSize m_renderSize; 27 | AVAnimatorMedia *m_mediaObj; 28 | AVFrame *m_frameObj; 29 | BOOL mediaDidLoad; 30 | } 31 | 32 | // public properties 33 | 34 | // UIImageOrientationUp, UIImageOrientationDown, UIImageOrientationLeft, UIImageOrientationRight 35 | // defaults to UIImageOrientationUp 36 | @property (nonatomic, assign) UIImageOrientation animatorOrientation; 37 | 38 | @property (nonatomic, readonly) AVAnimatorMedia *media; 39 | 40 | // static ctor : create view that has the screen dimensions 41 | + (AVAnimatorView*) aVAnimatorView; 42 | 43 | // static ctor : create view with the given dimensions 44 | + (AVAnimatorView*) aVAnimatorViewWithFrame:(CGRect)viewFrame; 45 | 46 | // A media item is attached to the view to indicate that the media will 47 | // render to this view. 48 | 49 | - (void) attachMedia:(AVAnimatorMedia*)inMedia; 50 | 51 | // Implement AVAnimatorMediaRendererProtocol protocol 52 | 53 | // Invoked with TRUE argument once renderer has been attached to loaded media, 54 | // otherwise FALSE is passed to indicate the renderer could not be attached 55 | 56 | - (void) mediaAttached:(BOOL)worked; 57 | 58 | // Note that the superclass implicitly defines setImage 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVAnimatorViewPrivate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVAnimatorViewPrivate.h 3 | // 4 | // Created by Moses DeJong on 1/8/11. 5 | // 6 | // This file defines the private members of the AVAnimatorView. 7 | // These fields would typically be used only by the implementation 8 | // of AVAnimatorView, but could be needed for regression tests. 9 | // 10 | // License terms defined in License.txt. 11 | 12 | #import 13 | 14 | #import 15 | 16 | #import "AVAnimatorView.h" 17 | 18 | // private properties declaration for AVAnimatorView class 19 | 20 | @interface AVAnimatorView () 21 | 22 | @property (nonatomic, assign) CGSize renderSize; 23 | 24 | @property (nonatomic, retain) AVAnimatorMedia *mediaObj; 25 | 26 | @property (nonatomic, retain) AVFrame *frameObj; 27 | 28 | // private methods 29 | 30 | - (void) rotateToPortrait; 31 | 32 | - (void) rotateToLandscape; 33 | 34 | - (void) rotateToLandscapeRight; 35 | 36 | - (void) rotateToUpsidedown; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVApng2MvidResourceLoader.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVApng2MvidResourceLoader.h 3 | // 4 | // Created by Moses DeJong on 5/2/11. 5 | // 6 | // License terms defined in License.txt. 7 | // 8 | // This loader converts an APNG resource .apng to a .mvid movie file. 9 | // This class works only on a file with the .apng extension. 10 | // Don't attach an animated PNG file with the .png extension, because 11 | // Xcode will modify the internal format and compression in a way that 12 | // makes the file unreadable to libpng. 13 | // 14 | // The APNG converter makes use of libpng plus the APNG patch to decode 15 | // image data as a series of frames. Any of the formats supported by 16 | // libpng can be decoded. All formats will be decoded to 24 BPP or 32 BPP 17 | // if an alpha channel or transparency is used. Unlike the Quicktime Animation 18 | // decoder, the APNG decoder has no 16BPP (Thousands of colors) support. 19 | // The PNG image format is able to achive some impressive compression ratios 20 | // for a variety of input. The most effective results come with computer generated 21 | // images that use a limited number of colors. 22 | // 23 | // The APNG decoder will decode all frames as keyframes, so the resulting .mvid 24 | // file can grow quite large. A user of this class should take care to delete 25 | // these tmp files when no longer needed. This behavior is a design trade off, 26 | // because while the intermediate files are large, the runtime performance is 27 | // exceptionally good as a result of a special zero copy optimization. 28 | // In practice, one should be able to get 30 FPS performance for full screen 480x320 29 | // video that was decoded from a .apng file, even on an old iPhone 3g. 30 | 31 | #import 32 | 33 | #import "AV7zAppResourceLoader.h" 34 | 35 | @interface AVApng2MvidResourceLoader : AVAppResourceLoader { 36 | NSString *m_outPath; 37 | BOOL startedLoading; 38 | BOOL m_alwaysGenerateAdler; 39 | } 40 | 41 | // The fully qualified filename for the extracted data. For example: "XYZ.mvid" 42 | @property (nonatomic, copy) NSString *outPath; 43 | 44 | @property (nonatomic, assign) BOOL alwaysGenerateAdler; 45 | 46 | + (AVApng2MvidResourceLoader*) aVApng2MvidResourceLoader; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVAppResourceLoader.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVAppResourceLoader.h 3 | // 4 | // Created by Moses DeJong on 7/13/10. 5 | // 6 | // License terms defined in License.txt. 7 | // 8 | // The AVAppResourceLoader class implements loading of animation 9 | // data from the compiled in app resources of an iOS project. 10 | // An app resource file does not need to be copied into the tmp 11 | // dir, it can be opened and read like and other file, so no 12 | // intermediate tmp files are needed. 13 | 14 | #import 15 | 16 | #import "AVResourceLoader.h" 17 | 18 | #import "AVAppResourceLoader.h" 19 | 20 | @interface AVAppResourceLoader : AVResourceLoader { 21 | NSString *m_movieFilename; 22 | NSString *m_audioFilename; 23 | } 24 | 25 | // Both filename properties can be either a fully qualified file path 26 | // or a simple filename. A simple filename is assumed to be a resource. 27 | 28 | @property (nonatomic, copy) NSString *movieFilename; 29 | @property (nonatomic, copy) NSString *audioFilename; 30 | 31 | + (AVAppResourceLoader*) aVAppResourceLoader; 32 | 33 | - (BOOL) isReady; 34 | 35 | // Note that invoking load multiple times is not going to cause problems, 36 | // multiple requests will be ignored since the cached file would already 37 | // exist when the next request comes in. 38 | 39 | - (void) load; 40 | 41 | // Non-Public methods 42 | 43 | - (NSString*) _getMoviePath; 44 | 45 | - (NSString*) _getAudioPath:(NSString*)audioFilename; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVAppResourceLoader.m: -------------------------------------------------------------------------------- 1 | // 2 | // AVAppResourceLoader.m 3 | // 4 | // Created by Moses DeJong on 7/13/10. 5 | // 6 | // License terms defined in License.txt. 7 | 8 | #import "AVAppResourceLoader.h" 9 | 10 | #import "AVFileUtil.h" 11 | 12 | @implementation AVAppResourceLoader 13 | 14 | @synthesize movieFilename = m_movieFilename; 15 | @synthesize audioFilename = m_audioFilename; 16 | 17 | - (void) dealloc 18 | { 19 | self.movieFilename = nil; 20 | self.audioFilename = nil; 21 | 22 | #if __has_feature(objc_arc) 23 | #else 24 | [super dealloc]; 25 | #endif // objc_arc 26 | } 27 | 28 | + (AVAppResourceLoader*) aVAppResourceLoader 29 | { 30 | AVAppResourceLoader *obj = [[AVAppResourceLoader alloc] init]; 31 | #if __has_feature(objc_arc) 32 | return obj; 33 | #else 34 | return [obj autorelease]; 35 | #endif // objc_arc 36 | } 37 | 38 | - (NSString*) _getMoviePath 39 | { 40 | // If movieFilename is a fully qualified path that indicates an existing file, 41 | // the load that file directly. This makes it possible to use a file from the 42 | // tmp dir or some other location. If the file name is not fully qualified 43 | // then it must be a resource filename. 44 | 45 | NSString *qualPath = [AVFileUtil getQualifiedFilenameOrResource:self.movieFilename]; 46 | NSAssert(qualPath, @"qualPath"); 47 | return qualPath; 48 | } 49 | 50 | - (NSString*) _getAudioPath:(NSString*)audioFilename 51 | { 52 | // If audioFilename is a fully qualified path that indicates an existing file, 53 | // the load that file directly. This makes it possible to use a file from the 54 | // tmp dir or some other location. If the file name is not fully qualified 55 | // then it must be a resource filename. 56 | 57 | NSString *qualPath = [AVFileUtil getQualifiedFilenameOrResource:audioFilename]; 58 | NSAssert(qualPath, @"qualPath"); 59 | return qualPath; 60 | } 61 | 62 | - (BOOL) isMovieReady 63 | { 64 | BOOL isMovieReady = FALSE; 65 | 66 | NSAssert(self.movieFilename, @"movieFilename is nil"); 67 | 68 | // Return TRUE if the mov file exists in the app resources 69 | 70 | NSString *tmpMoviePath = [self _getMoviePath]; 71 | 72 | if ([AVFileUtil fileExists:tmpMoviePath]) { 73 | isMovieReady = TRUE; 74 | } 75 | 76 | return isMovieReady; 77 | } 78 | 79 | - (BOOL) isAudioReady 80 | { 81 | BOOL isAudioReady = FALSE; 82 | 83 | if (self.audioFilename != nil) { 84 | // Check for audio file in tmp dir 85 | NSString *tmpTracksPath = [self _getAudioPath:self.audioFilename]; 86 | NSAssert(tmpTracksPath, @"tmpTracksPath is nil"); 87 | 88 | if ([AVFileUtil fileExists:tmpTracksPath]) { 89 | isAudioReady = TRUE; 90 | } 91 | } else { 92 | isAudioReady = TRUE; 93 | } 94 | 95 | return isAudioReady; 96 | } 97 | 98 | // Getter for isReady property defined in superclass 99 | 100 | - (BOOL) isReady 101 | { 102 | BOOL isMovieReady = FALSE; 103 | BOOL isAudioReady = FALSE; 104 | 105 | isMovieReady = [self isMovieReady]; 106 | isAudioReady = [self isAudioReady]; 107 | 108 | if (isMovieReady && isAudioReady) { 109 | self.isReady = TRUE; 110 | return TRUE; 111 | } else { 112 | return FALSE; 113 | } 114 | } 115 | 116 | - (NSArray*) getResources 117 | { 118 | if (!self.isReady) { 119 | NSAssert(FALSE, @"resources not ready"); 120 | } 121 | NSMutableArray *mArr = [NSMutableArray array]; 122 | NSString *tmpAnimationsPath = [self _getMoviePath]; 123 | [mArr addObject:tmpAnimationsPath]; 124 | if (self.audioFilename != nil) { 125 | NSString *tmpTracksPath = [self _getAudioPath:self.audioFilename]; 126 | [mArr addObject:tmpTracksPath]; 127 | } 128 | return [NSArray arrayWithArray:mArr]; 129 | } 130 | 131 | - (void) load 132 | { 133 | NSAssert(self.movieFilename, @"movieFilename is nil"); 134 | 135 | // audioFilename can be nil 136 | //NSAssert(self.audioFilename, @"audioFilename is nil"); 137 | 138 | // No-op since the movie must exist as a resource 139 | 140 | return; 141 | } 142 | 143 | @end 144 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVAsset2MvidResourceLoader.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVAsset2MvidResourceLoader.h 3 | // 4 | // Created by Moses DeJong on 2/24/12. 5 | // 6 | // License terms defined in License.txt. 7 | // 8 | // This loader will decompress the video portion of an existing 9 | // asset and save as a .mvid file. This module makes it possible 10 | // to decode H.264 stored as a .mov file that has been attached 11 | // to the project as a resource. 12 | 13 | #import 14 | 15 | #import 16 | 17 | #import "AVAppResourceLoader.h" 18 | 19 | #import "AVAssetConvertCommon.h" 20 | 21 | #if defined(HAS_AVASSET_CONVERT_MAXVID) 22 | 23 | @interface AVAsset2MvidResourceLoader : AVAppResourceLoader { 24 | NSString *m_outPath; 25 | BOOL m_alwaysGenerateAdler; 26 | BOOL startedLoading; 27 | CGSize m_movieSize; 28 | 29 | #if defined(HAS_LIB_COMPRESSION_API) 30 | BOOL m_compressed; 31 | #endif // HAS_LIB_COMPRESSION_API 32 | } 33 | 34 | // The fully qualified filename for the extracted data. For example: "XYZ.mvid" 35 | @property (nonatomic, copy) NSString *outPath; 36 | 37 | @property (nonatomic, assign) BOOL alwaysGenerateAdler; 38 | 39 | @property (nonatomic, assign) CGSize movieSize; 40 | 41 | #if defined(HAS_LIB_COMPRESSION_API) 42 | @property (nonatomic, assign) BOOL compressed; 43 | #endif // HAS_LIB_COMPRESSION_API 44 | 45 | + (AVAsset2MvidResourceLoader*) aVAsset2MvidResourceLoader; 46 | 47 | @end 48 | 49 | #endif // HAS_AVASSET_CONVERT_MAXVID 50 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVAssetAlphaFrameDecoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVAssetAlphaFrameDecoder.h 3 | // 4 | // Created by Moses DeJong on 1/4/13. 5 | // 6 | // License terms defined in License.txt. 7 | // 8 | // This frame decoder interface will read video frames from an AVAsset which 9 | // typically means a h264 video attached to the project file. Other file 10 | // types could be supported by iOS, but currently h264 is the only one that 11 | // actually works. A Frame decoder interface will load and decompress a 12 | // specific frame of video using the h264 decoder handware included in iOS. 13 | // Note that this frame decoder is currently limited in that only 1 frame 14 | // can be in memory at any one time, the decoder only supports 15 | // sequential access to frames, and frame can only be decoded once. 16 | // This frame decoder does not support random access, frame cannot be skipped 17 | // or repeated and one cannot loop or rewind the decode frame position. This 18 | // decoder should not be used with a AVAnimatorMedia object, it should only 19 | // be used to read frames from an asset is a non-realtime blocking usage. 20 | 21 | #import 22 | #import 23 | 24 | #import "AVAssetConvertCommon.h" 25 | 26 | #import "AVFrameDecoder.h" 27 | 28 | #if defined(HAS_AVASSET_CONVERT_MAXVID) 29 | 30 | @class AVFrame; 31 | @class AVAssetFrameDecoder; 32 | @class AVAssetReader; 33 | @class AVAssetReaderOutput; 34 | 35 | @interface AVAssetAlphaFrameDecoder : AVFrameDecoder 36 | { 37 | @private 38 | AVAssetFrameDecoder *m_rgbAssetDecoder; 39 | AVAssetFrameDecoder *m_alphaAssetDecoder; 40 | AVFrame *m_currentFrame; 41 | NSString *m_movieRGBFilename; 42 | NSString *m_movieAlphaFilename; 43 | } 44 | 45 | @property (nonatomic, readonly) NSUInteger numFrames; 46 | 47 | @property (nonatomic, retain) AVAssetFrameDecoder *rgbAssetDecoder; 48 | @property (nonatomic, retain) AVAssetFrameDecoder *alphaAssetDecoder; 49 | 50 | // The name of the RGB portion of the movie should be saved in the 51 | // "movieRGBFilename" property. 52 | 53 | @property (nonatomic, copy) NSString *movieRGBFilename; 54 | 55 | // The name of the ALPHA portion of the movie should be saved in the 56 | // "movieAlphaFilename" property. 57 | 58 | @property (nonatomic, copy) NSString *movieAlphaFilename; 59 | 60 | // Constructor 61 | 62 | + (AVAssetAlphaFrameDecoder*) aVAssetAlphaFrameDecoder; 63 | 64 | // Return TRUE if opening the rgb and alpha asset file is successful. 65 | // This method could return FALSE when the file does not exist or 66 | // it is the wrong format. 67 | 68 | - (BOOL) openForReading; 69 | 70 | @end 71 | 72 | #endif // HAS_AVASSET_CONVERT_MAXVID 73 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVAssetConvertCommon.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVAssetConvertCommon.h 3 | // 4 | // Created by Moses DeJong on 7/8/12. 5 | // 6 | // License terms defined in License.txt. 7 | 8 | #import 9 | 10 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_4_1 // iOS 4.1 or newer (iOS Deployment Target) 11 | 12 | #define HAS_AVASSET_CONVERT_MAXVID 13 | 14 | #endif // iOS 4.1 or newer 15 | 16 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_5_0 // iOS 5.0 or newer (iOS Deployment Target) 17 | 18 | // Note that one can comment out this define and then the project would not 19 | // need to link to GLKit or OpenGLES frameworks. The only class that depends 20 | // on these two frameworks is AVAnimatorOpenGLView 21 | 22 | #define HAS_AVASSET_READ_COREVIDEO_BUFFER_AS_TEXTURE 23 | 24 | #endif // iOS 5.0 or newer 25 | 26 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0 // iOS 9.0 or newer (iOS Deployment Target) 27 | 28 | // Note that one can comment out this define and then the project would not 29 | // need to link to GLKit or OpenGLES frameworks. The only class that depends 30 | // on these two frameworks is AVAnimatorOpenGLView 31 | 32 | #define HAS_LIB_COMPRESSION_API 33 | 34 | #endif // iOS 9.0 or newer 35 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVAssetFrameDecoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVAssetFrameDecoder.h 3 | // 4 | // Created by Moses DeJong on 1/4/13. 5 | // 6 | // License terms defined in License.txt. 7 | // 8 | // This frame decoder interface will read video frames from an AVAsset which 9 | // typically means a h264 video attached to the project file. Other file 10 | // types could be supported by iOS, but currently h264 is the only one that 11 | // actually works. A Frame decoder interface will load and decompress a 12 | // specific frame of video using the h264 decoder handware included in iOS. 13 | // Note that this frame decoder is currently limited in that only 1 frame 14 | // can be in memory at any one time, the decoder only supports 15 | // sequential access to frames, and frame can only be decoded once. 16 | // This frame decoder does not support random access, frame cannot be skipped 17 | // or repeated and one cannot loop or rewind the decode frame position. This 18 | // decoder should not be used with a AVAnimatorMedia object, it should only 19 | // be used to read frames from an asset is a non-realtime blocking usage. 20 | 21 | #import 22 | #import 23 | 24 | #import "AVAssetConvertCommon.h" 25 | 26 | #import "AVFrameDecoder.h" 27 | 28 | #if defined(HAS_AVASSET_CONVERT_MAXVID) 29 | 30 | @class AVAssetReader; 31 | @class AVAssetReaderOutput; 32 | 33 | @interface AVAssetFrameDecoder : AVFrameDecoder 34 | { 35 | @private 36 | NSURL *m_assetURL; 37 | AVAssetReader *m_aVAssetReader; 38 | AVAssetReaderOutput *m_aVAssetReaderOutput; 39 | 40 | NSTimeInterval m_frameDuration; 41 | NSUInteger m_numFrames; 42 | int frameIndex; 43 | 44 | CGSize detectedMovieSize; 45 | float prevFrameDisplayTime; 46 | int numTrailingNopFrames; 47 | 48 | BOOL m_isOpen; 49 | BOOL m_isReading; 50 | BOOL m_readingFinished; 51 | BOOL m_produceCoreVideoPixelBuffers; 52 | BOOL m_produceYUV420Buffers; 53 | BOOL m_dropFrames; 54 | } 55 | 56 | @property (nonatomic, readonly) NSUInteger numFrames; 57 | 58 | // If this flag is set to TRUE (the default is FALSE) then each AVFrame produced 59 | // by this frame decoder will contain a CVPixelBufferRef instead of an 60 | // image. This optimized path avoids multiple pointless framebuffer copies. 61 | // Because video data can be very very large, this optimal execution path can 62 | // save a significant amount of execution time, but it is only valid if the rendering 63 | // target is able to accept a CoreVideo pixel buffer directly. Currently, only a 64 | // AVAnimatorOpenGLView is able to accept CoreVideo buffers directly. 65 | // This value should not be changed while actually decoding frames, it should 66 | // only be set before rendering of frames begins. 67 | 68 | @property (nonatomic, assign) BOOL produceCoreVideoPixelBuffers; 69 | 70 | // If self.produceCoreVideoPixelBuffers is TRUE and this flag is set then the 71 | // H264 decoder will produce YUV 4:2:0 buffers as opposed to a flat BGRA buffer. 72 | // A 4:2:0 features subsampling for the UV components. 73 | 74 | @property (nonatomic, assign) BOOL produceYUV420Buffers; 75 | 76 | // This flag defaults to TRUE, when it is TRUE then the decoder will drop 77 | // a frame if the indicated display time less than the expected interval 78 | // time to the next frame. Note that this frame drop logic is not always 79 | // correct, in the case where a video encodes a frame at a time and no 80 | // frame should be dropped based on the timing info, then this flag should 81 | // be set to FALSE. 82 | 83 | @property (nonatomic, assign) BOOL dropFrames; 84 | 85 | + (AVAssetFrameDecoder*) aVAssetFrameDecoder; 86 | 87 | @end 88 | 89 | #endif // HAS_AVASSET_CONVERT_MAXVID 90 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVAssetJoinAlphaResourceLoader.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVAssetJoinAlphaResourceLoader.h 3 | // 4 | // Created by Moses DeJong on 1/1/13. 5 | // 6 | // License terms defined in License.txt. 7 | // 8 | // This loader will decompress a video with a full alpha channel stored 9 | // as a pair of h264 encoded videos. The first video contains the RGB 10 | // values while the second video contains just the alpha channel 11 | // stored as grayscale. Typically, the h264 video should be encoded with 12 | // ffmpeg+x264 and it would be stored in a .m4v file. 13 | 14 | @class AVAsset2MvidResourceLoader; 15 | 16 | #import 17 | 18 | #import "AVAppResourceLoader.h" 19 | 20 | #import "AVAssetConvertCommon.h" 21 | 22 | @interface AVAssetJoinAlphaResourceLoader : AVAppResourceLoader 23 | { 24 | NSString *m_movieRGBFilename; 25 | NSString *m_movieAlphaFilename; 26 | NSString *m_outPath; 27 | BOOL m_alwaysGenerateAdler; 28 | BOOL startedLoading; 29 | 30 | #if defined(HAS_LIB_COMPRESSION_API) 31 | BOOL m_compressed; 32 | #endif // HAS_LIB_COMPRESSION_API 33 | } 34 | 35 | // The name of the RGB portion of the movie should be saved in the 36 | // "movieRGBFilename" property. 37 | 38 | @property (nonatomic, copy) NSString *movieRGBFilename; 39 | 40 | // The name of the ALPHA portion of the movie should be saved in the 41 | // "movieAlphaFilename" property. 42 | 43 | @property (nonatomic, copy) NSString *movieAlphaFilename; 44 | 45 | // The fully qualified filename of the final result file, for example 46 | // the output path might be constructed by combining the mvid filename 47 | // like "Ghost.mvid" with the tmp dir. 48 | 49 | @property (nonatomic, copy) NSString *outPath; 50 | 51 | @property (nonatomic, assign) BOOL alwaysGenerateAdler; 52 | 53 | // Set this property to TRUE to enable compression of each keyframe 54 | 55 | #if defined(HAS_LIB_COMPRESSION_API) 56 | @property (nonatomic, assign) BOOL compressed; 57 | #endif // HAS_LIB_COMPRESSION_API 58 | 59 | // constructor 60 | 61 | + (AVAssetJoinAlphaResourceLoader*) aVAssetJoinAlphaResourceLoader; 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVAssetMixAlphaResourceLoader.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVAssetMixAlphaResourceLoader.h 3 | // 4 | // Created by Moses DeJong on 1/1/13. 5 | // 6 | // License terms defined in License.txt. 7 | // 8 | // This loader will decompress a "mixed" video where RGB and Alpha frames 9 | // are mixed together. A video of this type must be encoded with the main 10 | // profile so that effective compression is retained. 11 | 12 | @class AVAsset2MvidResourceLoader; 13 | 14 | #import 15 | 16 | #import "AVAppResourceLoader.h" 17 | 18 | @interface AVAssetMixAlphaResourceLoader : AVAppResourceLoader 19 | 20 | // The fully qualified filename of the final result file, for example 21 | // the output path might be constructed by combining the mvid filename 22 | // like "Ghost.mvid" with the tmp dir. 23 | 24 | @property (nonatomic, copy) NSString *outPath; 25 | 26 | @property (nonatomic, assign) BOOL alwaysGenerateAdler; 27 | 28 | // constructor 29 | 30 | + (AVAssetMixAlphaResourceLoader*) aVAssetMixAlphaResourceLoader; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVAssetReaderConvertMaxvid.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVAssetReaderConvertMaxvid.h 3 | // 4 | // Created by Moses DeJong on 2/4/12. 5 | // 6 | // License terms defined in License.txt. 7 | // 8 | // This module implements a h264 to MVID decoder that can be used to 9 | // save the raw bits of a h264 video into a file. The h264 format supports 10 | // only 24 BPP mode, so no alpha channel can appear in a h264 video. 11 | // But, the compression available in h264 saves a whole lot of space 12 | // as compared to lossless compression. 13 | 14 | #include "AVAssetConvertCommon.h" 15 | 16 | #if defined(HAS_AVASSET_CONVERT_MAXVID) 17 | 18 | #import "AVMvidFileWriter.h" 19 | 20 | // The following notification is delivered when the conversion process is complete. 21 | // The notification is delivered in both the success and failure case. The caller 22 | // can check the object.state value to determine the actual result. 23 | 24 | extern NSString * const AVAssetReaderConvertMaxvidCompletedNotification; 25 | 26 | @class AVAssetFrameDecoder; 27 | 28 | @interface AVAssetReaderConvertMaxvid : AVMvidFileWriter { 29 | @private 30 | NSURL *m_assetURL; 31 | AVAssetFrameDecoder *m_frameDecoder; 32 | BOOL m_wasSuccessful; 33 | #if defined(HAS_LIB_COMPRESSION_API) 34 | BOOL m_compressed; 35 | #endif // HAS_LIB_COMPRESSION_API 36 | } 37 | 38 | @property (nonatomic, copy) NSURL *assetURL; 39 | 40 | @property (nonatomic, assign) BOOL wasSuccessful; 41 | 42 | #if defined(HAS_LIB_COMPRESSION_API) 43 | @property (nonatomic, assign) BOOL compressed; 44 | #endif // HAS_LIB_COMPRESSION_API 45 | 46 | + (AVAssetReaderConvertMaxvid*) aVAssetReaderConvertMaxvid; 47 | 48 | // This method is a blocking call that will read data from the 49 | // asset and write the output as a .mvid file. Note that decoding 50 | // is done in the calling thread, so this method should typically 51 | // be invoked only from a secondary thread. 52 | // Return TRUE if successful, FALSE otherwise. 53 | 54 | - (BOOL) blockingDecode; 55 | 56 | // Kick off an async (non-blocking call) decode operation in a secondary 57 | // thread. This method will deliver a AVAssetReaderConvertMaxvidCompletedNotification 58 | // in the main thread when complete. Check the state property during this notification to 59 | // determine if the encoding process was a success or a failure. 60 | 61 | - (void) nonblockingDecode; 62 | 63 | @end 64 | 65 | #endif // HAS_AVASSET_CONVERT_MAXVID : iOS 4.1 or newer 66 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVAssetWriterConvertFromMaxvid.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVAssetWriterConvertFromMaxvid.h 3 | // 4 | // Created by Moses DeJong on 7/8/12. 5 | // 6 | // License terms defined in License.txt. 7 | // 8 | // This module implements a MVID to H264 encoder API that can be used to 9 | // encode the video frames from an MVID file into a H264 video in 10 | // a Quicktime container (.mvid -> .mov). The H264 video format is 11 | // lossy as compared to the lossless MVID format, but the space savings 12 | // can be quite significant. Note that because this module depends on 13 | // a hardware encoder on the iOS device, it will not function on devices 14 | // that do not include an H264 encoder. For example, iPhones earlier than 15 | // the iPhone4 (like the 3G and 3GS) do not include a hardware h264 encoder. 16 | // All iPad devices include H264 encoding hardware. 17 | // 18 | // Note that there are some restrictions imposed by the H264 encoder 19 | // hardware on iOS devices. The smallest video successfully encoded 20 | // on tested iOS hardware appears to be 128x128. A video with a dimension 21 | // smaller than 128 will either fail to encode (iPad2) or it will encode 22 | // with corrupted video data (iPhone4). Video with well known aspect 23 | // ratios (2:1, 3:2, 4:3) encode correctly. Also note that video dimensions 24 | // should be a multiple of 4. 25 | // 26 | // See http://en.wikipedia.org/wiki/Display_resolution for examples of resolutions 27 | // that are standard and known to work. Because H264 encoding hardware differs from 28 | // model to model, you will have to test the encoding logic with your specific 29 | // hardware and the specific input dimensions. If you find that the encoded video is 30 | // corrupted in strange ways, change the width x height of the video and see if that 31 | // fixes the problem. The corruption happens at the hardware level, there is no 32 | // available workaround as the problem is not at a software level. 33 | // 34 | // In addition, H264 supports only 24BPP fully opaque video. Attempting to 35 | // encode a .mvid with an alpha channel will not work as expected, the 36 | // alpha channel will compose over a black background since the output 37 | // must be opaque. 38 | 39 | #include "AVAssetConvertCommon.h" 40 | 41 | #if defined(HAS_AVASSET_CONVERT_MAXVID) 42 | 43 | typedef enum 44 | { 45 | AVAssetWriterConvertFromMaxvidStateInit = 0, 46 | AVAssetWriterConvertFromMaxvidStateSuccess, 47 | AVAssetWriterConvertFromMaxvidStateFailed 48 | } AVAssetWriterConvertFromMaxvidState; 49 | 50 | @class AVFrameDecoder; 51 | 52 | // The following notification is delivered when the conversion process is complete. 53 | // The notification is delivered in both the success and failure case. The caller 54 | // can check the object.state value to determine the actual result. 55 | 56 | extern NSString * const AVAssetWriterConvertFromMaxvidCompletedNotification; 57 | 58 | // AVAssetWriterConvertFromMaxvid 59 | 60 | @interface AVAssetWriterConvertFromMaxvid : NSObject 61 | 62 | // This state value starts life as AVAssetWriterConvertFromMaxvidStateInit and 63 | // gets set to AVAssetWriterConvertFromMaxvidStateSuccess on success. If the 64 | // encode operation fails then another enum value is set to indicate a reason. 65 | 66 | @property (nonatomic, assign) AVAssetWriterConvertFromMaxvidState state; 67 | 68 | // The input path is the fully qualified filename for the .mvid video input file 69 | 70 | @property (nonatomic, copy) NSString *inputPath; 71 | 72 | // The output path is the fully qualified filename for the .mov or .m4v H264 73 | // video file to be written. 74 | 75 | @property (nonatomic, copy) NSString *outputPath; 76 | 77 | #if defined(REGRESSION_TESTS) 78 | @property (nonatomic, retain) AVFrameDecoder *frameDecoder; 79 | #endif // REGRESSION_TESTS 80 | 81 | // constructor 82 | 83 | + (AVAssetWriterConvertFromMaxvid*) aVAssetWriterConvertFromMaxvid; 84 | 85 | // Kick off an encode operation. This will block the calling thread until 86 | // the encoding operation is completed. Be careful not to block the main 87 | // thread with this invocation, this method would typically only be used 88 | // from a secondary thread. 89 | 90 | - (void) blockingEncode; 91 | 92 | // Kick off an async (non-blocking call) encode operation in a secondary 93 | // thread. This method will deliver a AVAssetWriterConvertFromMaxvidCompletedNotification 94 | // in the main thread when complete. Check the state property during this notification to 95 | // determine if the encoding process was a success or a failure. 96 | 97 | - (void) nonblockingEncode; 98 | 99 | // Return TRUE if a hardware h264 encoder is available for use with this 100 | // iPhone, iPod Touch, or iPad model. This function always returns TRUE 101 | // in the simulator. 102 | 103 | + (BOOL) isHardwareEncoderAvailable; 104 | 105 | @end 106 | 107 | #endif // HAS_AVASSET_CONVERT_MAXVID : iOS 4.1 or newer 108 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVFileUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Moses DeJong on 4/22/11. 3 | // 4 | // License terms defined in License.txt. 5 | // 6 | // File related utility functions. 7 | 8 | #import 9 | 10 | @interface AVFileUtil : NSObject { 11 | 12 | } 13 | 14 | // Given a filename like "foo.txt", return the fully qualified path 15 | // in the temp dir (like "/tmp/foo.txt"). The tmp dir is the app defined 16 | // temp directory. 17 | 18 | + (NSString*) getTmpDirPath:(NSString*)filename; 19 | 20 | // Return TRUE if a file exists with the indicated path, FALSE otherwise. 21 | 22 | + (BOOL) fileExists:(NSString*)path; 23 | 24 | // Return the path for a resource file 25 | 26 | + (NSString*) getResourcePath:(NSString*)resFilename; 27 | 28 | // Return a fully qualified path to a unique filename in the tmp dir. 29 | // This filename will not be the same as a previously used filename 30 | // and it will not conflict with an existing file in the tmp dir. 31 | // This method should only be invoked from the main thread, in order 32 | // to ensure that there are no thread race conditions present when 33 | // generating the tmp filename. 34 | 35 | + (NSString*) generateUniqueTmpPath; 36 | 37 | // If the filename is fully qualified, then check that the file 38 | // exists and return nil if it does not exist. If the filename 39 | // is a simple filename, then check that a resource file with 40 | // that filename exists and return nil if the resource does not exist. 41 | // In either case, a fully qualified path of a file that is known 42 | // to exist is returned, otherwise nil. 43 | 44 | + (NSString*) getQualifiedFilenameOrResource:(NSString*)filename; 45 | 46 | // Rename the file at path to the file indicated by toPath. 47 | // This util method will remove an existing file at toPath 48 | // and assert that the move operation was successful. 49 | 50 | + (void) renameFile:(NSString*)path toPath:(NSString*)toPath; 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVFileUtil.m: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Moses DeJong on 4/22/11. 3 | // 4 | // License terms defined in License.txt. 5 | // 6 | // File related utility functions. 7 | 8 | #import "AVFileUtil.h" 9 | 10 | @implementation AVFileUtil 11 | 12 | // Given a filename (typically an archive entry name), return the filename 13 | // in the tmp dir that corresponds to the entry. For example, 14 | // "2x2_black_blue_16BPP.mvid" -> "/tmp/2x2_black_blue_16BPP.mvid" where "/tmp" 15 | // is the app tmp dir. 16 | 17 | + (NSString*) getTmpDirPath:(NSString*)filename 18 | { 19 | NSString *tmpDir = NSTemporaryDirectory(); 20 | NSAssert(tmpDir, @"tmpDir"); 21 | NSString *outPath = [tmpDir stringByAppendingPathComponent:filename]; 22 | NSAssert(outPath, @"outPath"); 23 | return outPath; 24 | } 25 | 26 | + (BOOL) fileExists:(NSString*)path 27 | { 28 | return [[NSFileManager defaultManager] fileExistsAtPath:path]; 29 | } 30 | 31 | + (NSString*) getResourcePath:(NSString*)resFilename 32 | { 33 | NSBundle* appBundle = [NSBundle mainBundle]; 34 | NSString* movieFilePath = [appBundle pathForResource:resFilename ofType:nil]; 35 | NSAssert(movieFilePath, @"movieFilePath is nil"); 36 | return movieFilePath; 37 | } 38 | 39 | + (NSString*) generateUniqueTmpPath 40 | { 41 | NSString *tmpDir = NSTemporaryDirectory(); 42 | 43 | NSDate *nowDate = [NSDate date]; 44 | NSTimeInterval ti = [nowDate timeIntervalSinceReferenceDate]; 45 | 46 | // Format number of seconds as a string with a decimal separator 47 | NSString *doubleString = [NSString stringWithFormat:@"%f", ti]; 48 | 49 | // Remove the decimal point so that the file name consists of 50 | // numeric characters only. 51 | 52 | NSRange range = NSMakeRange(0, [doubleString length]); 53 | 54 | NSString *noDecimalString = [doubleString stringByReplacingOccurrencesOfString:@"." 55 | withString:@"" 56 | options:0 57 | range:range]; 58 | 59 | NSString *tmpPath = [tmpDir stringByAppendingPathComponent:noDecimalString]; 60 | 61 | return tmpPath; 62 | } 63 | 64 | + (NSString*) getQualifiedFilenameOrResource:(NSString*)filename 65 | { 66 | if ([filename hasPrefix:@"/"]) { 67 | if ([[NSFileManager defaultManager] fileExistsAtPath:filename isDirectory:NULL]) { 68 | return filename; 69 | } else { 70 | return nil; 71 | } 72 | } else { 73 | return [AVFileUtil getResourcePath:filename]; 74 | } 75 | } 76 | 77 | + (void) renameFile:(NSString*)path toPath:(NSString*)toPath 78 | { 79 | // The temp filename holding the maxvid data is now completely written, rename it to "XYZ.mvid" 80 | 81 | NSError *error = nil; 82 | BOOL worked; 83 | 84 | if ([[NSFileManager defaultManager] fileExistsAtPath:toPath]) { 85 | worked = [[NSFileManager defaultManager] removeItemAtPath:toPath error:&error]; 86 | NSAssert(worked, @"removeItemAtPath failed : %@", error); 87 | } 88 | 89 | #if defined(DEBUG) 90 | BOOL existedBefore = [[NSFileManager defaultManager] fileExistsAtPath:path]; 91 | NSAssert(existedBefore, @"src file does not exist : %@", path); 92 | BOOL existedToToPathBefore = [[NSFileManager defaultManager] fileExistsAtPath:toPath]; 93 | NSAssert(existedToToPathBefore == FALSE, @"dst file must not exist : %@", toPath); 94 | #endif // DEBUG 95 | 96 | error = nil; 97 | worked = [[NSFileManager defaultManager] moveItemAtPath:path toPath:toPath error:&error]; 98 | if (!worked) { 99 | BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:path]; 100 | NSAssert(exists, @"src file does not exist : %@", path); 101 | NSAssert(worked, @"moveItemAtPath failed for decode result : %@", error); 102 | } 103 | 104 | return; 105 | } 106 | 107 | @end 108 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVFrame.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVFrame.h 3 | // 4 | // Created by Moses DeJong on 9/2/12. 5 | // 6 | // License terms defined in License.txt. 7 | // 8 | // This class defines a platform specific "frame" object that "contains" visual 9 | // information for one specific frame in an animaton or movie. Code that executes 10 | // only on one platform may access platform specific properties, but general 11 | // purpose code can safely pass around a reference to a AVFrame without platform 12 | // specific concerns. 13 | 14 | #import 15 | 16 | #if TARGET_OS_IPHONE 17 | #import 18 | #else 19 | #import 20 | #endif 21 | 22 | @class CGFrameBuffer; 23 | 24 | @interface AVFrame : NSObject 25 | { 26 | #if TARGET_OS_IPHONE 27 | UIImage *m_image; 28 | #else 29 | NSImage *m_image; 30 | #endif // TARGET_OS_IPHONE 31 | 32 | CGFrameBuffer *m_cgFrameBuffer; 33 | CVImageBufferRef m_cvBufferRef; 34 | BOOL m_isDuplicate; 35 | } 36 | 37 | #if TARGET_OS_IPHONE 38 | @property (nonatomic, retain) UIImage *image; 39 | #else 40 | @property (nonatomic, retain) NSImage *image; 41 | #endif // TARGET_OS_IPHONE 42 | 43 | // If the frame data is already formatted as a pixel buffer, then 44 | // this field is non-nil. A pixel buffer can be wrapped into 45 | // platform specific image data. 46 | 47 | @property (nonatomic, retain) CGFrameBuffer *cgFrameBuffer; 48 | 49 | // A frame decoder might provide a buffer directly as a CoreVideo image 50 | // buffer as opposed to an image. Typically, this ref actually points 51 | // at a CVPixelBufferRef, but CVImageBufferRef is a more generic superclass 52 | // ref that could also apply to an OpenGL buffer. The AVAssetFrameDecoder 53 | // class can decode this type of CoreVideo buffer directly. 54 | 55 | @property (nonatomic, assign) CVImageBufferRef cvBufferRef; 56 | 57 | @property (nonatomic, assign) BOOL isDuplicate; 58 | 59 | // Constructor 60 | 61 | + (AVFrame*) aVFrame; 62 | 63 | // If the image property is nil but the cgFrameBuffer is not nil, then 64 | // create the image object from the contents of the cgFrameBuffer. This 65 | // method attempts to verify that the image object is created and initialized 66 | // as much as possible, though some image operations may still be deferred 67 | // until the render cycle. 68 | 69 | - (void) makeImageFromFramebuffer; 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVFrame.m: -------------------------------------------------------------------------------- 1 | // 2 | // AVFrame.m 3 | // 4 | // Created by Moses DeJong on 9/2/12. 5 | // 6 | // License terms defined in License.txt. 7 | 8 | #import "AVFrame.h" 9 | 10 | #import "CGFrameBuffer.h" 11 | 12 | @implementation AVFrame 13 | 14 | @synthesize image = m_image; 15 | @synthesize cgFrameBuffer = m_cgFrameBuffer; 16 | @synthesize cvBufferRef = m_cvBufferRef; 17 | @synthesize isDuplicate = m_isDuplicate; 18 | 19 | // Constructor 20 | 21 | + (AVFrame*) aVFrame 22 | { 23 | AVFrame *obj = [[AVFrame alloc] init]; 24 | #if __has_feature(objc_arc) 25 | return obj; 26 | #else 27 | return [obj autorelease]; 28 | #endif // objc_arc 29 | } 30 | 31 | - (void) dealloc 32 | { 33 | self.image = nil; 34 | self.cgFrameBuffer = nil; 35 | self.cvBufferRef = NULL; 36 | 37 | #if __has_feature(objc_arc) 38 | #else 39 | [super dealloc]; 40 | #endif // objc_arc 41 | } 42 | 43 | - (void) makeImageFromFramebuffer 44 | { 45 | // Release previous image if there was one created from this frame buffer 46 | 47 | self.image = nil; 48 | 49 | CGFrameBuffer *cgFrameBuffer = self.cgFrameBuffer; 50 | 51 | CGImageRef imgRef = [cgFrameBuffer createCGImageRef]; 52 | NSAssert(imgRef != NULL, @"CGImageRef returned by createCGImageRef is NULL"); 53 | 54 | // Note that we create a pool around the allocation of the image object 55 | // so that after the assignment to self.image, the only active reference 56 | // lives in this object. If the image object is created in the caller's 57 | // autorelease pool then we could not set image property to release. 58 | 59 | @autoreleasepool { 60 | 61 | #if TARGET_OS_IPHONE 62 | UIImage *uiImage = [UIImage imageWithCGImage:imgRef]; 63 | NSAssert(uiImage, @"uiImage is nil"); 64 | 65 | self.image = uiImage; 66 | #else 67 | // Mac OS X 68 | 69 | NSSize size = NSMakeSize(cgFrameBuffer.width, cgFrameBuffer.height); 70 | NSImage *nsImage = [[[NSImage alloc] initWithCGImage:imgRef size:size] autorelease]; 71 | NSAssert(nsImage, @"nsImage is nil"); 72 | 73 | self.image = nsImage; 74 | #endif // TARGET_OS_IPHONE 75 | 76 | CGImageRelease(imgRef); 77 | 78 | } 79 | 80 | NSAssert(cgFrameBuffer.isLockedByDataProvider, @"image buffer should be locked by frame image"); 81 | } 82 | 83 | // Setter for self.cvBufferRef, this logic holds on to a retain for the CoreVideo buffer 84 | 85 | - (void) setCvBufferRef:(CVImageBufferRef)cvBufferRef 86 | { 87 | if (cvBufferRef) { 88 | CFRetain(cvBufferRef); 89 | } 90 | if (self->m_cvBufferRef) { 91 | CFRelease(self->m_cvBufferRef); 92 | } 93 | self->m_cvBufferRef = cvBufferRef; 94 | } 95 | 96 | - (NSString*) description 97 | { 98 | return [NSString stringWithFormat:@"AVFrame %p (isDuplicate = %d), self.image %p, self.cgFrameBuffer %p, self.cvBufferRef %p", 99 | self, 100 | self.isDuplicate, 101 | self.image, 102 | self.cgFrameBuffer, 103 | self.cvBufferRef]; 104 | } 105 | 106 | @end 107 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVFrameDecoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVFrameDecoder.h 3 | // 4 | // Created by Moses DeJong on 12/30/10. 5 | // 6 | // License terms defined in License.txt. 7 | // 8 | // This abstract superclass defines the interface that needs to be implemented by 9 | // a class that implements frame decoding logic. A frame is 2D image decoded from 10 | // video data from a file or other resource. 11 | 12 | #import 13 | 14 | @class AVFrame; 15 | @class CGFrameBuffer; 16 | 17 | @interface AVFrameDecoder : NSObject { 18 | } 19 | 20 | // Open resource identified by path 21 | 22 | - (BOOL) openForReading:(NSString*)path; 23 | 24 | // Close resource opened earlier 25 | 26 | - (void) close; 27 | 28 | // Reset current frame index to -1, before the first frame 29 | 30 | - (void) rewind; 31 | 32 | // Advance the current frame index to the indicated frame index. Return the new frame 33 | // object, the frame contains the platform specific image object. If a duplicate (no-op) 34 | // frame is found then the frame data has not changed. A no-op frame is indicated by 35 | // the frame.isDuplicate property being set to TRUE. Note that this advanceToFrame 36 | // method should never return nil, even in the case where the frame data cannot be 37 | // loaded, a valid AVFrame should be returned with a nil image property to indicate failure. 38 | 39 | - (AVFrame*) advanceToFrame:(NSUInteger)newFrameIndex; 40 | 41 | // Decoding frames may require additional resources that are not required 42 | // to open the file and examine the header contents. This method will 43 | // allocate decoding resources that are required to actually decode the 44 | // video frames from a specific file. It is possible that allocation 45 | // could fail, for example if decoding would require too much memory. 46 | // The caller would need to check for a FALSE return value to determine 47 | // how to handle the case where allocation of decode resources fails. 48 | 49 | - (BOOL) allocateDecodeResources; 50 | 51 | - (void) releaseDecodeResources; 52 | 53 | // Returns TRUE if resources are "limited" meaning decode resource are not allocated. 54 | 55 | - (BOOL) isResourceUsageLimit; 56 | 57 | // Return a copy of the last frame returned via advanceToFrame. 58 | // This copy will not be associated with the frame decoder and 59 | // it will not contain any external references to shared memory. 60 | // This method is useful only for the case where holding onto a 61 | // ref to the final frame will waste significant resources, for 62 | // example if the normal frames hold references to mapped memory. 63 | 64 | - (AVFrame*) duplicateCurrentFrame; 65 | 66 | // Properties 67 | 68 | // Dimensions of each frame 69 | - (NSUInteger) width; 70 | - (NSUInteger) height; 71 | 72 | // True when resource has been opened via openForReading 73 | - (BOOL) isOpen; 74 | 75 | // Total frame count 76 | - (NSUInteger) numFrames; 77 | 78 | // Current frame index, can be -1 at init or after rewind 79 | - (NSInteger) frameIndex; 80 | 81 | // Time each frame shold be displayed 82 | - (NSTimeInterval) frameDuration; 83 | 84 | // TRUE if the decoded frame supports and alpha channel. 85 | - (BOOL) hasAlphaChannel; 86 | 87 | // True when all mvid frames are keyframes. This means that none of 88 | // the frames are delta frames that require a previous state in order 89 | // to apply a delta. 90 | 91 | - (BOOL) isAllKeyframes; 92 | 93 | @end 94 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVFrameDecoder.m: -------------------------------------------------------------------------------- 1 | // 2 | // AVFrameDecoder.m 3 | // 4 | // Created by Moses DeJong on 12/30/10. 5 | // 6 | // License terms defined in License.txt. 7 | 8 | #import "AVFrameDecoder.h" 9 | 10 | @implementation AVFrameDecoder 11 | 12 | - (void) dealloc 13 | { 14 | #if __has_feature(objc_arc) 15 | #else 16 | [super dealloc]; 17 | #endif // objc_arc 18 | } 19 | 20 | - (BOOL) openForReading:(NSString*)path 21 | { 22 | [self doesNotRecognizeSelector:_cmd]; 23 | return FALSE; 24 | } 25 | 26 | - (void) close 27 | { 28 | [self doesNotRecognizeSelector:_cmd]; 29 | return; 30 | } 31 | 32 | - (void) rewind 33 | { 34 | [self doesNotRecognizeSelector:_cmd]; 35 | return; 36 | } 37 | 38 | - (AVFrame*) advanceToFrame:(NSUInteger)newFrameIndex 39 | { 40 | [self doesNotRecognizeSelector:_cmd]; 41 | return FALSE; 42 | } 43 | 44 | - (BOOL) allocateDecodeResources 45 | { 46 | [self doesNotRecognizeSelector:_cmd]; 47 | return FALSE; 48 | } 49 | 50 | - (void) releaseDecodeResources 51 | { 52 | [self doesNotRecognizeSelector:_cmd]; 53 | return; 54 | } 55 | 56 | - (BOOL) isResourceUsageLimit 57 | { 58 | [self doesNotRecognizeSelector:_cmd]; 59 | return FALSE; 60 | } 61 | 62 | - (AVFrame*) duplicateCurrentFrame 63 | { 64 | [self doesNotRecognizeSelector:_cmd]; 65 | return nil; 66 | } 67 | 68 | // Properties 69 | 70 | - (NSUInteger) width 71 | { 72 | [self doesNotRecognizeSelector:_cmd]; 73 | return 0; 74 | } 75 | 76 | - (NSUInteger) height 77 | { 78 | [self doesNotRecognizeSelector:_cmd]; 79 | return 0; 80 | } 81 | 82 | - (BOOL) isOpen 83 | { 84 | [self doesNotRecognizeSelector:_cmd]; 85 | return FALSE; 86 | } 87 | 88 | - (NSUInteger) numFrames 89 | { 90 | [self doesNotRecognizeSelector:_cmd]; 91 | return 0; 92 | } 93 | 94 | - (NSInteger) frameIndex 95 | { 96 | [self doesNotRecognizeSelector:_cmd]; 97 | return 0; 98 | } 99 | 100 | - (NSTimeInterval) frameDuration 101 | { 102 | [self doesNotRecognizeSelector:_cmd]; 103 | return 0; 104 | } 105 | 106 | - (BOOL) hasAlphaChannel 107 | { 108 | [self doesNotRecognizeSelector:_cmd]; 109 | return FALSE; 110 | } 111 | 112 | - (BOOL) isAllKeyframes 113 | { 114 | [self doesNotRecognizeSelector:_cmd]; 115 | return FALSE; 116 | } 117 | 118 | @end 119 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVGIF89A2MvidResourceLoader.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVGIF89A2MvidResourceLoader.h 3 | // 4 | // Created by Moses DeJong on 6/5/13. 5 | // 6 | // License terms defined in License.txt. 7 | // 8 | // This loader converts an animated GIF89a file to the .mvid format. 9 | // An animated GIF contains multiple frames of video data and can 10 | // be loaded from an asset, a local file, or a URL. Because animated 11 | // GIFs could be quite large, it is not a good idea to actually hold 12 | // all the UIImage items in memory at the same time on an iOS device. 13 | // This loader makes it possible to convert a GIF to MVID format so 14 | // that the superior memory usage of the MVID format and loader code 15 | // can selectively load specific keyframes as needed. 16 | 17 | #import 18 | 19 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000 // iOS 4.0 or newer 20 | 21 | #define AVANIMATOR_HAS_IMAGEIO_FRAMEWORK 22 | 23 | #endif // iOS 4.0 or newer 24 | 25 | #ifdef AVANIMATOR_HAS_IMAGEIO_FRAMEWORK 26 | 27 | #import "AVAppResourceLoader.h" 28 | 29 | @interface AVGIF89A2MvidResourceLoader : AVAppResourceLoader { 30 | NSString *m_outPath; 31 | BOOL startedLoading; 32 | BOOL m_alwaysGenerateAdler; 33 | } 34 | 35 | // The fully qualified filename for the extracted data. For example: "XYZ.mvid" 36 | 37 | @property (nonatomic, copy) NSString *outPath; 38 | 39 | @property (nonatomic, assign) BOOL alwaysGenerateAdler; 40 | 41 | + (AVGIF89A2MvidResourceLoader*) aVGIF89A2MvidResourceLoader; 42 | 43 | @end 44 | 45 | #endif // AVANIMATOR_HAS_IMAGEIO_FRAMEWORK -------------------------------------------------------------------------------- /Classes/AVAnimator/AVImageFrameDecoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVImageFrameDecoder.h 3 | // QTFileParserApp 4 | // 5 | // Created by Moses DeJong on 1/4/11. 6 | // 7 | // License terms defined in License.txt. 8 | // 9 | // This class implements the AVFrameDecoder interface and supports 10 | // loading "frames" from individual images files. These image files 11 | // could be PNG, JPEG, or any other format supported by the system. 12 | // This implementation works, but does not work that well since 13 | // decoding an entire image each frame is not optimal. This class 14 | // is mostly a proof of concept. A real implementation would use 15 | // a file format that supports frame deltas, since frame deltas 16 | // provide reasonable memory and cpu usage results. This implementation 17 | // holds the entire encoded image data in memory, since IO between 18 | // frame rendering is too slow to produce useful results. 19 | 20 | #import 21 | #import "AVFrameDecoder.h" 22 | 23 | @class UIImage; 24 | 25 | @interface AVImageFrameDecoder : AVFrameDecoder { 26 | NSArray *m_cgFrameBuffers; 27 | NSArray *m_urls; 28 | NSArray *m_dataObjs; 29 | NSArray *m_cachedImageObjs; 30 | UIImage *m_currentFrameImage; 31 | NSTimeInterval m_frameDuration; 32 | BOOL m_resourceUsageLimit; 33 | } 34 | 35 | @property (nonatomic, copy) NSArray *cgFrameBuffers; 36 | @property (nonatomic, copy) NSArray *urls; 37 | @property (nonatomic, copy) NSArray *dataObjs; 38 | @property (nonatomic, copy) NSArray *cachedImageObjs; 39 | @property (nonatomic, retain) UIImage *currentFrameImage; 40 | 41 | + (NSArray*) arrayWithNumberedNames:(NSString*)filenamePrefix 42 | rangeStart:(NSInteger)rangeStart 43 | rangeEnd:(NSInteger)rangeEnd 44 | suffixFormat:(NSString*)suffixFormat; 45 | 46 | + (NSArray*) arrayWithResourcePrefixedURLs:(NSArray*)inNumberedNames; 47 | 48 | // Create instance of AVImageFrameDecoder. Typically one would want to 49 | // use this constructor as opposed to the next one. 50 | 51 | + (AVImageFrameDecoder*) aVImageFrameDecoder:(NSArray*)urls; 52 | 53 | // This constructor provides an optional cacheDecodedImages that makes it possible 54 | // to cache the decoded image data in memory. But, this will use up a ton a memory 55 | // so it should only be used if you really know what you are doing! 56 | 57 | + (AVImageFrameDecoder*) aVImageFrameDecoder:(NSArray*)urls cacheDecodedImages:(BOOL)cacheDecodedImages; 58 | 59 | // Open resource identified by path 60 | 61 | - (BOOL) openForReading:(NSString*)path; 62 | 63 | // Close resource opened earlier 64 | 65 | - (void) close; 66 | 67 | // Reset current frame index to -1, before the first frame 68 | 69 | - (void) rewind; 70 | 71 | // Advance the current frame index, see AVFrameDecoder.h for full method description. 72 | 73 | - (AVFrame*) advanceToFrame:(NSUInteger)newFrameIndex; 74 | 75 | // Decoding frames may require additional resources that are not required 76 | // to open the file and examine the header contents. This method will 77 | // allocate decoding resources that are required to actually decode the 78 | // video frames from a specific file. It is possible that allocation 79 | // could fail, for example if decoding would require too much memory. 80 | // The caller would need to check for a FALSE return value to determine 81 | // how to handle the case where allocation of decode resources fails. 82 | 83 | - (BOOL) allocateDecodeResources; 84 | 85 | - (void) releaseDecodeResources; 86 | 87 | - (BOOL) isResourceUsageLimit; 88 | 89 | // Properties 90 | 91 | // Dimensions of each frame 92 | - (NSUInteger) width; 93 | - (NSUInteger) height; 94 | 95 | // True when resource has been opened via openForReading 96 | - (BOOL) isOpen; 97 | 98 | // Total frame count 99 | - (NSUInteger) numFrames; 100 | 101 | // Current frame index, can be -1 at init or after rewind 102 | - (NSInteger) frameIndex; 103 | 104 | // Time each frame shold be displayed 105 | - (NSTimeInterval) frameDuration; 106 | 107 | // This method will explicitly set value returned by frameDuration. 108 | - (void) setFrameDuration:(NSTimeInterval)duration; 109 | 110 | - (BOOL) hasAlphaChannel; 111 | 112 | // True when all mvid frames are keyframes. This means that none of 113 | // the frames are delta frames that require a previous state in order 114 | // to apply a delta. 115 | 116 | - (BOOL) isAllKeyframes; 117 | 118 | @end 119 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVMvidFileWriter.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVMvidFileWriter.h 3 | // 4 | // Created by Moses DeJong on 2/20/12. 5 | // 6 | // License terms defined in License.txt. 7 | // 8 | // This module implements a class that handles the details of writing a .mvid 9 | // file. This file type is a specially optimized binary layout of pixel data 10 | // useful for animations and general video. Pixels in a .mvid file are optimized 11 | // so that regions can be blitted into memory as quickly as possible. In addition 12 | // memory is configured on page bounds and word bounds for maximum efficiency 13 | // at the cost of a little on disk space. 14 | 15 | #import 16 | 17 | #import 18 | 19 | #import "maxvid_file.h" 20 | 21 | @interface AVMvidFileWriter : NSObject { 22 | @private 23 | NSString *m_mvidPath; 24 | float m_frameDuration; 25 | int frameNum; 26 | int m_totalNumFrames; 27 | MVFileHeader *mvHeader; 28 | void *mvFramesArray; 29 | uint32_t framesArrayNumBytes; 30 | uint32_t m_bpp; 31 | 32 | FILE *maxvidOutFile; 33 | 34 | off_t offset; 35 | CGSize m_movieSize; 36 | 37 | BOOL isOpen; 38 | BOOL m_genAdler; 39 | BOOL m_isAllKeyframes; 40 | BOOL m_genV3; 41 | #if MV_ENABLE_DELTAS 42 | BOOL m_isDeltas; 43 | #endif // MV_ENABLE_DELTAS 44 | } 45 | 46 | @property (nonatomic, copy) NSString *mvidPath; 47 | @property (nonatomic, assign) float frameDuration; 48 | @property (nonatomic, readonly) int frameNum; 49 | @property (nonatomic, assign) int totalNumFrames; 50 | @property (nonatomic, assign) BOOL genAdler; 51 | @property (nonatomic, assign) uint32_t bpp; 52 | @property (nonatomic, assign) CGSize movieSize; 53 | 54 | // TRUE by default, if writeDeltaframe is invoked then this 55 | // property is set to FALSE. 56 | 57 | @property (nonatomic, assign) BOOL isAllKeyframes; 58 | 59 | // Set this property to TRUE when a generated V3 file 60 | // that contains compressed data blocks at known page 61 | // offsets should be generated. This type of file need 62 | // not be memory mapped and it can support much larger 63 | // sizes that previous versions since all frame sizes 64 | // are implicitly stored as page offsets. 65 | 66 | @property (nonatomic, assign) BOOL genV3; 67 | 68 | #if MV_ENABLE_DELTAS 69 | 70 | // FALSE by default, if the mvid file was created with the 71 | // -deltas option then this property would be TRUE. 72 | 73 | @property (nonatomic, assign) BOOL isDeltas; 74 | 75 | #endif // MV_ENABLE_DELTAS 76 | 77 | + (AVMvidFileWriter*) aVMvidFileWriter; 78 | 79 | - (BOOL) open; 80 | 81 | - (void) close; 82 | 83 | // Write a single nop frame after a keyframe or a delta frame 84 | 85 | - (void) writeNopFrame; 86 | 87 | #if MV_ENABLE_DELTAS 88 | 89 | // Write special case nop frame that appears at the begining of 90 | // the file. The weird special case bascially means that the 91 | // first frame is constructed by applying a frame delta to an 92 | // all black framebuffer. 93 | 94 | - (void) writeInitialNopFrame; 95 | 96 | #endif // MV_ENABLE_DELTAS 97 | 98 | // Count up the number of nop frames that would appear after the indicated 99 | // frame display time. The currentFrameDuration is the duration that 100 | // a frame would be displayed, it could be longer than the expected FPS 101 | // duration indicated by the frameDuration argument. 102 | 103 | + (int) countTrailingNopFrames:(float)currentFrameDuration 104 | frameDuration:(float)frameDuration; 105 | 106 | // Write 0 to N trailing nop frames, pass in total frame display time 107 | 108 | - (void) writeTrailingNopFrames:(float)frameDuration; 109 | 110 | - (void) skipToNextPageBound; 111 | 112 | // Write a self contained key frame. Note that the bufferSize argument 113 | // here should contain all the pixels and any zero pading in the case 114 | // of an odd number of pixels. 115 | 116 | - (BOOL) writeKeyframe:(char*)ptr bufferSize:(int)bufferSize; 117 | 118 | // This version of writeKeyframe stores a non-zero adler passed in to the method 119 | 120 | - (BOOL) writeKeyframe:(char*)ptr bufferSize:(int)bufferSize adler:(uint32_t)adler isCompressed:(BOOL)isCompressed; 121 | 122 | // Write a delta frame that depends on the previous frame. The adler needs to be 123 | // generated in the caller since both previous and current frames would need to be 124 | // decoded in order to generate the adler. 125 | 126 | - (BOOL) writeDeltaframe:(char*)ptr bufferSize:(int)bufferSize adler:(uint32_t)adler; 127 | 128 | - (BOOL) rewriteHeader; 129 | 130 | @end 131 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVResourceLoader.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVResourceLoader.h 3 | // AVAnimatorDemo 4 | // 5 | // Created by Moses DeJong on 4/7/09. 6 | // 7 | // License terms defined in License.txt. 8 | 9 | #import 10 | 11 | // Create a resource loader and attach it to the media 12 | // object to implement a specific type of resource loading. 13 | // The type of resource might be a URL or a file, but the 14 | // exact method used to load the resource is defined by 15 | // a specific implementation. 16 | 17 | @interface AVResourceLoader : NSObject { 18 | @private 19 | BOOL m_isReady; 20 | BOOL m_serialLoading; 21 | } 22 | 23 | // TRUE if if resource(s) have already been created 24 | // and are ready to be loaded without a long delay. This 25 | // method can be invoked before a call to load. 26 | 27 | @property (nonatomic, assign) BOOL isReady; 28 | 29 | // If this property is set to TRUE before the loading 30 | // process begins, then secondary loading threads will 31 | // be run one at a time. This means resources will load 32 | // one at a time, so if decoding multiple resources 33 | // would consume too much CPU or memory resources, this 34 | // flag provides a way to limit resource usage by loading 35 | // one resource at a time. 36 | 37 | @property (nonatomic, assign) BOOL serialLoading; 38 | 39 | // Invoked to load resources, this call assumes that 40 | // isReady has been invoked to check if the resources 41 | // actually need to be loaded. This call must be 42 | // non-blocking and return right away. If a loading 43 | // operation will take time to execute, it should be 44 | // implemented as a secondary thread. 45 | 46 | - (void) load; 47 | 48 | // Return an array that contains 1 to N resources. The 49 | // contents of the array depends on the implementation 50 | // of the resource loaded, but typically the array 51 | // contains NString* that contains the filename of 52 | // a resource in the tmp dir. 53 | 54 | - (NSArray*) getResources; 55 | 56 | // Use these methods to implement serial resource loading 57 | // logic in subclasses of AVResourceLoader. 58 | 59 | + (void) grabSerialResourceLoaderLock; 60 | 61 | + (void) releaseSerialResourceLoaderLock; 62 | 63 | // This method will deallocate the shared global memory 64 | // associated with the serial resource loader lock. 65 | // This method is provided for completeness, it would 66 | // not typically be invoked at runtime. 67 | 68 | + (void) freeSerialResourceLoaderLock; 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVResourceLoader.m: -------------------------------------------------------------------------------- 1 | // 2 | // AVResourceLoader.m 3 | // AVAnimatorDemo 4 | // 5 | // Created by Moses DeJong on 4/7/09. 6 | // 7 | // License terms defined in License.txt. 8 | 9 | #import "AVResourceLoader.h" 10 | 11 | static NSLock *serialResourceLoaderLock = nil; 12 | 13 | @implementation AVResourceLoader 14 | 15 | @synthesize isReady = m_isReady; 16 | @synthesize serialLoading = m_serialLoading; 17 | 18 | // This static method is invoked when this class or a subclass is loaded. 19 | // The goal here is to only invoke the lock init logic one time so that 20 | // only a single lock ever exists. 21 | 22 | + (void) initialize 23 | { 24 | if (self == [AVResourceLoader class]) { 25 | if (serialResourceLoaderLock == nil) { 26 | NSLock *obj = [[NSLock alloc] init]; 27 | NSAssert(obj, @"NSLock could not be allocated"); 28 | serialResourceLoaderLock = obj; 29 | [serialResourceLoaderLock setName:@"serialResourceLoaderLock"]; 30 | #if __has_feature(objc_arc) 31 | #else 32 | [serialResourceLoaderLock retain]; 33 | [obj release]; 34 | #endif // objc_arc 35 | } 36 | } 37 | } 38 | 39 | + (void) freeSerialResourceLoaderLock 40 | { 41 | #if __has_feature(objc_arc) 42 | serialResourceLoaderLock = nil; 43 | #else 44 | NSLock *obj = serialResourceLoaderLock; 45 | serialResourceLoaderLock = nil; 46 | [obj release]; 47 | #endif // objc_arc 48 | } 49 | 50 | + (void) grabSerialResourceLoaderLock 51 | { 52 | NSAssert(serialResourceLoaderLock, @"serialResourceLoaderLock"); 53 | [serialResourceLoaderLock lock]; 54 | } 55 | 56 | + (void) releaseSerialResourceLoaderLock 57 | { 58 | NSAssert(serialResourceLoaderLock, @"serialResourceLoaderLock"); 59 | [serialResourceLoaderLock unlock]; 60 | } 61 | 62 | - (BOOL) isReady 63 | { 64 | [self doesNotRecognizeSelector:_cmd]; 65 | return FALSE; 66 | } 67 | 68 | - (void) load 69 | { 70 | [self doesNotRecognizeSelector:_cmd]; 71 | } 72 | 73 | - (NSArray*) getResources 74 | { 75 | [self doesNotRecognizeSelector:_cmd]; 76 | return nil; 77 | } 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /Classes/AVAnimator/AVStreamEncodeDecode.h: -------------------------------------------------------------------------------- 1 | // 2 | // AVStreamEncodeDecode.h 3 | // 4 | // Created by Moses DeJong on 2/24/16. 5 | // 6 | // License terms defined in License.txt. 7 | 8 | #import 9 | 10 | #import "AVAssetConvertCommon.h" // HAS_LIB_COMPRESSION_API 11 | 12 | #if defined(HAS_LIB_COMPRESSION_API) 13 | 14 | #import "compression.h" 15 | 16 | @interface AVStreamEncodeDecode : NSObject 17 | 18 | // Stream compression interface, compress input and store into encodedData buffer 19 | 20 | + (void) streamCompress:(NSData*)inputData 21 | encodedData:(NSMutableData*)encodedData 22 | algorithm:(compression_algorithm)algorithm; 23 | 24 | // Streaming delta + compress encoding operation that reads 16, 24, 32 BPP pixels 25 | // and writes data to an output mutable data that contains encoded bytes 26 | 27 | + (BOOL) streamDeltaAndCompress:(NSData*)inputData 28 | encodedData:(NSMutableData*)encodedData 29 | bpp:(int)bpp 30 | algorithm:(compression_algorithm)algorithm; 31 | 32 | // Undo the delta + compress operation so that the original pixel data is recovered 33 | // and written to the indicated pixel buffer. 34 | 35 | + (BOOL) streamUnDeltaAndUncompress:(NSData*)encodedData 36 | frameBuffer:(void*)frameBuffer 37 | frameBufferNumBytes:(uint32_t)frameBufferNumBytes 38 | bpp:(int)bpp 39 | algorithm:(compression_algorithm)algorithm; 40 | 41 | @end 42 | 43 | #endif // HAS_LIB_COMPRESSION_API 44 | -------------------------------------------------------------------------------- /Classes/AVAnimator/ApngConvertMaxvid.h: -------------------------------------------------------------------------------- 1 | // apng convert to maxvid module 2 | // 3 | // License terms defined in License.txt. 4 | // 5 | // This module defines logic that convert from an APNG to a memory mapped maxvid file. 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | // Convert each frame of .apng data into a maxvid frame and save to .mvid file. 20 | 21 | uint32_t 22 | apng_convert_maxvid_file( 23 | char *inAPNGPath, 24 | char *outMaxvidPath, 25 | uint32_t genAdler); 26 | 27 | uint32_t 28 | apng_verify_png_is_animated(char *inAPNGPath); 29 | 30 | // class ApngConvertMaxvid 31 | 32 | #import 33 | 34 | @interface ApngConvertMaxvid : NSObject 35 | 36 | + (uint32_t) convertToMaxvid:(NSString*)inAPNGPath 37 | outMaxvidPath:(NSString*)outMaxvidPath 38 | genAdler:(BOOL)genAdler; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Classes/AVAnimator/MutableAttrString.h: -------------------------------------------------------------------------------- 1 | // 2 | // MutableAttrString.h 3 | // Created by Moses DeJong on 1/1/10. 4 | // 5 | // License terms defined in License.txt. 6 | // 7 | // A simple wrapper class that contains a CFMutableAttributedStringRef for use with CoreText. 8 | 9 | #import 10 | #import 11 | 12 | @interface MutableAttrString : NSObject 13 | 14 | // This pointer is to a C attr string object 15 | 16 | @property (nonatomic, assign) CFMutableAttributedStringRef attrString; 17 | 18 | // This is the range of the entire attributed string. This value is 19 | // only valid after doneAppendingText has been invoked. 20 | 21 | @property (nonatomic, assign) CFRange stringRange; 22 | 23 | // Each of the following properties are reset to the default value by resetDefaults. 24 | 25 | // The current text color. 26 | 27 | @property (nonatomic, assign) CGColorRef color; 28 | 29 | // The current text bold property. This property defaults to FALSE and must be 30 | // explicitly set to TRUE. Note that this method will use the bold font only 31 | // in the case where the self.font value is the default font. 32 | 33 | @property (nonatomic, assign) BOOL bold; 34 | 35 | // The current text font. This property defaults to the value indicated in setFont. 36 | // If a specific font is needed for a specific word, then this font property 37 | // should be set before a call to appendText. 38 | 39 | @property (nonatomic, assign) CTFontRef font; 40 | 41 | // contructor 42 | 43 | + (MutableAttrString*) mutableAttrString; 44 | 45 | // Set the default font properties that will be used for plain and bold font types. 46 | // Note that this method must be invoked before strings are appended with appendText. 47 | 48 | - (void) setDefaults:(CGColorRef)textColor 49 | fontSize:(NSUInteger)fontSize 50 | plainFontName:(NSString*)plainFontName 51 | boldFontName:(NSString*)boldFontName; 52 | 53 | // This method is used to reset the properties related to text rendering to the 54 | // default values. The default values are defined by the initial settings passed 55 | // to the setFont method. Render logic will invoke resetDefaults to ensure that 56 | // the next string appended to the attr string will have the default properties. 57 | 58 | - (void) resetDefaults; 59 | 60 | // Append a string or characters with markup attributes defined by the current 61 | // properties. 62 | 63 | - (void) appendText:(NSString*)string; 64 | 65 | // This method must be invoked after all textual elements have been appended. 66 | 67 | - (void) doneAppendingText; 68 | 69 | // Measure the height required to display the attr string given a known width. 70 | // This logic returns a height without an upper bound. The measurement is always 71 | // in terms of whole pixels. Be aware that this method cannot be 72 | // safely invoked on a secondary thread since this portion of 73 | // CoreText is not thread safe. This logic must be synced to 74 | // the main thread. 75 | 76 | - (NSUInteger) measureHeightForWidth:(NSUInteger)width; 77 | 78 | // Use CoreText to render rich text into a static bounding box 79 | // of the given context. Be aware that this method cannot be 80 | // safely invoked on a secondary thread since this portion of 81 | // CoreText is not thread safe. This logic must be synced to 82 | // the main thread. 83 | 84 | - (void) render:(CGContextRef)bitmapContext 85 | bounds:(CGRect)bounds; 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /Classes/AVAnimator/SegmentedMappedData.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Moses DeJong on 1/22/12. 3 | // 4 | // License terms defined in License.txt. 5 | // 6 | // A segmented mapped data object extends NSData so that the lifetime of a set 7 | // of mapped file segments can be managed as a group of objects. If the container 8 | // SegmentedMappedData is deallocated, then each segmented mapping it contains 9 | // it deallocated assuming there are no other active references. 10 | // 11 | // Unlike a plain mapped file, a SegmentedMappedData will put off creating 12 | // a specific mapping until the data for a specific segment is needed. 13 | // The segment objets support and explicit mapSegment/unmapSegment API 14 | // that is used to map the segment into memory before use of the data. 15 | 16 | #import 17 | 18 | @class RefCountedFD; 19 | 20 | @interface SegmentedMappedData : NSData 21 | { 22 | NSString *m_filePath; 23 | 24 | // This pointer is that starting point where the OS 25 | // maps the start of a page into memory. 26 | 27 | void *m_mappedData; 28 | 29 | // A specific segment returns a pointer and 30 | // length in terms of the byte offset where 31 | // a specific segment was indicated. These 32 | // are returned by the bytes and length methods. 33 | 34 | off_t m_mappedOffset; 35 | off_t m_mappedLen; 36 | 37 | // In addition, the actual page starting offset 38 | // and the actual length of the mapping are 39 | // stored. If the mapping offset does not 40 | // begin on a page bound, then these values+ // Indicate the OS level values. 41 | 42 | off_t m_mappedOSOffset; 43 | off_t m_mappedOSLen; 44 | 45 | RefCountedFD *m_refCountedFD; 46 | 47 | BOOL isContainer; 48 | BOOL writeMapping; 49 | } 50 | 51 | @property (nonatomic, readonly) off_t mappedOffset; 52 | @property (nonatomic, readonly) off_t mappedLen; 53 | 54 | @property (nonatomic, readonly) off_t mappedOSOffset; 55 | @property (nonatomic, readonly) off_t mappedOSLen; 56 | 57 | 58 | + (SegmentedMappedData*) segmentedMappedData:(NSString*)filename; 59 | 60 | // Special purpose write only mapping over a specific range of whole pages 61 | 62 | + (SegmentedMappedData*) segmentedMappedDataWithWriteMapping:(NSString*)filePath 63 | file:(FILE*)file 64 | offset:(off_t)offset 65 | len:(off_t)len; 66 | 67 | // This API will create a mapped segment subrange. A segment can be mapped 68 | // and unmapped as needed and will automatically be unmapped when the last 69 | // ref is dropped. Note that the actual mapping is not created until the 70 | // mapSegment API is invoked on a specific segment. 71 | 72 | - (SegmentedMappedData*) subdataWithOffset:(off_t)offset len:(off_t)len; 73 | 74 | // This method will invoke mmap to actually map a segment into a memory buffer. 75 | // If the memory was successfully mapped, then TRUE is returned. Otherwise FALSE. 76 | 77 | - (BOOL) mapSegment; 78 | 79 | // This method will unmap a currently mapped segment, if 80 | // not currently mapped then a no-op. 81 | 82 | - (void) unmapSegment; 83 | 84 | // Return the starting address of this specific segment mapping. 85 | // The container will assert if bytes is invoked on it. 86 | // A segment will assert if mapSegment has not been invoked. 87 | 88 | - (const void*) bytes; 89 | 90 | // For a segment this returns the number of bytes in a segment. 91 | // For the container, this returns the length of the whole file in bytes. 92 | 93 | - (off_t) length; 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /Classes/AVAnimator/libapng.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009 Max Stepin 3 | * maxst at users.sourceforge.net 4 | * 5 | * zlib license 6 | * ------------ 7 | * 8 | * This software is provided 'as-is', without any express or implied 9 | * warranty. In no event will the authors be held liable for any damages 10 | * arising from the use of this software. 11 | * 12 | * Permission is granted to anyone to use this software for any purpose, 13 | * including commercial applications, and to alter it and redistribute it 14 | * freely, subject to the following restrictions: 15 | * 16 | * 1. The origin of this software must not be misrepresented; you must not 17 | * claim that you wrote the original software. If you use this software 18 | * in a product, an acknowledgment in the product documentation would be 19 | * appreciated but is not required. 20 | * 2. Altered source versions must be plainly marked as such, and must not be 21 | * misrepresented as being the original software. 22 | * 3. This notice may not be removed or altered from any source distribution. 23 | */ 24 | 25 | // This header defines a simple interface to a library that decodes frames from an APNG file. 26 | 27 | #ifndef LIBAPNG_H 28 | #define LIBAPNG_H 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #define LIBAPNG_ERROR_CODE_INVALID_INPUT 1 43 | #define LIBAPNG_ERROR_CODE_INVALID_FILENAME 2 44 | #define LIBAPNG_ERROR_CODE_WRITE_FAILED 3 45 | #define LIBAPNG_ERROR_CODE_READ_FAILED 4 46 | 47 | typedef int (*libapng_frame_func)( 48 | uint32_t* framebuffer, 49 | uint32_t framei, 50 | uint32_t width, uint32_t height, 51 | uint32_t delta_x, uint32_t delta_y, uint32_t delta_width, uint32_t delta_height, 52 | uint32_t delay_num, uint32_t delay_den, 53 | uint32_t bpp, 54 | void *userData); 55 | 56 | FILE* 57 | libapng_open(char *apngPath); 58 | 59 | void 60 | libapng_close(FILE *apngFILE); 61 | 62 | uint32_t 63 | libapng_main(FILE *apngFile, libapng_frame_func frame_func, void *userData); 64 | 65 | float 66 | libapng_frame_delay(uint32_t numerator, uint32_t denominator); 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /Classes/AVAnimator/maxvid_decode.h: -------------------------------------------------------------------------------- 1 | // maxvid_decode module 2 | // 3 | // License terms defined in License.txt. 4 | // 5 | // This module defines a runtime execution speed optimized video decoder library for iOS. 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | typedef enum { 20 | SKIP = 0, 21 | DUP = 1, 22 | COPY = 2, 23 | DONE = 3 24 | } MV_GENERIC_CODE; 25 | 26 | // Error codes returned by encode functions 27 | 28 | #define MV_ERROR_CODE_INVALID_INPUT 1 29 | #define MV_ERROR_CODE_INVALID_OUTPUT 2 30 | #define MV_ERROR_CODE_WRITE_FAILED 3 31 | #define MV_ERROR_CODE_READ_FAILED 4 32 | 33 | // These bit packing macros should not be invoked in user code 34 | 35 | // This is the upper limit for a combined "num" and "val" 36 | // field. This number is so large, that it is basically 37 | // impossible for any reasonable app to ever need to emit 38 | // more than this many pixels in any operation. 39 | 40 | #define MV_MAX_2_BITS 0x3 41 | #define MV_MAX_5_BITS 0x1F 42 | #define MV_MAX_8_BITS 0xFF 43 | #define MV_MAX_11_BITS 0x7FF 44 | #define MV_MAX_14_BITS 0x3FFF 45 | #define MV_MAX_16_BITS 0xFFFF 46 | #define MV_MAX_22_BITS 0x3FFFFF 47 | #define MV_MAX_24_BITS 0xFFFFFF 48 | #define MV_MAX_30_BITS 0x3FFFFFFF 49 | #define MV_MAX_32_BITS 0xFFFFFFFF 50 | 51 | // Previously, MV_PAGESIZE was 4 kB. This caused a problem on ARM64 because 52 | // Apple changed the OS pagesize() to 16 kB. So, as of v2 change the default 53 | // padding to always be 16 kB so that both 32 and 64 runtimes will be 54 | // exactly page aligned when a keyframe starts. 55 | 56 | #define MV_PAGESIZE (4096*4) 57 | 58 | #define MV16_NUM_PIXELS_ONE_PAGE (MV_PAGESIZE / sizeof(uint16_t)) 59 | #define MV_NUM_WORDS_ONE_PAGE (MV_PAGESIZE / sizeof(uint32_t)) 60 | 61 | // bitwise AND version of (ptr % pot) 62 | 63 | #if __LP64__ 64 | // CPU uses 64 bit pointers, need additional cast to avoid compiler warning 65 | #define UINTMOD(ptr, pot) (((uint32_t)(uint64_t)ptr) & (pot - 1)) 66 | #else 67 | // Regular 32 bit system 68 | #define UINTMOD(ptr, pot) (((uint32_t)ptr) & (pot - 1)) 69 | #endif 70 | 71 | // These next two macros will decode 3 values from a word code 72 | // and save the results in const variables. 73 | // word is a uint32_t that contains the word to be parsed 74 | // op is a 2 bit MV_GENERIC_CODE. 75 | // val is a 14 bit value. 76 | // num is a 16 bit value. 77 | 78 | # define MV16_READ_OP_VAL_NUM(word, op, val, num) \ 79 | const uint32_t op = word >> 30; \ 80 | const uint32_t val = (word >> 16) & MV_MAX_14_BITS; \ 81 | const uint32_t num = (uint16_t) word; \ 82 | if (0) { assert(op); } \ 83 | if (0) { assert(val); } \ 84 | if (0) { assert(num); } 85 | 86 | // 24 and 32 bit generic codes share a common format, each pixel is a whole word 87 | 88 | # define MV32_PARSE_OP_NUM_SKIP(word, op, num, skip) \ 89 | const uint32_t op = (word >> 8) & 0x3; \ 90 | const uint32_t num = ((word >> (8+2)) & MV_MAX_22_BITS); \ 91 | const uint32_t skip = (word & MV_MAX_8_BITS); \ 92 | if (0) { assert(op); } \ 93 | if (0) { assert(num); } \ 94 | if (0) { assert(skip); } 95 | 96 | #if !defined(MAXVID_NON_DEFAULT_MODULE_PREFIX) 97 | 98 | uint32_t 99 | maxvid_decode_c4_sample16( 100 | uint16_t * restrict frameBuffer16, 101 | const uint32_t * restrict inputBuffer32, 102 | const uint32_t inputBuffer32NumWords, 103 | const uint32_t frameBufferSize); 104 | 105 | uint32_t 106 | maxvid_decode_c4_sample32( 107 | uint32_t * restrict frameBuffer32, 108 | const uint32_t * restrict inputBuffer32, 109 | const uint32_t inputBuffer32NumWords, 110 | const uint32_t frameBufferSize); 111 | 112 | #endif // MAXVID_DEFAULT_MODULE_PREFIX 113 | -------------------------------------------------------------------------------- /Classes/AVAnimator/maxvid_deltas.h: -------------------------------------------------------------------------------- 1 | // maxvid_deltas module 2 | // 3 | // License terms defined in License.txt. 4 | // 5 | // This module contains logic related to the "deltas" file format which is like 6 | // a normal maxvid file except that all frames are deltas and the pixels are 7 | // stored in a format that makes it easier to compress. This module trades 8 | // execution time for maximum compactness in the data being sent to the 9 | // compressor. Note that this delta file format is not related to frame to 10 | // frame deltas, which are used to implement the basic diff and patch logic 11 | // for frames (fast blit). 12 | 13 | #import "maxvid_file.h" 14 | 15 | #import 16 | 17 | // Set this value to 1 to enable simple "diff" from one pixel value to the next. 18 | 19 | #define MV_DELTAS_SUBTRACT_PIXELS 0 20 | 21 | #if MV_ENABLE_DELTAS 22 | 23 | BOOL 24 | maxvid_deltas_compress(NSData *maxvidInData, 25 | NSMutableData *maxvidOutData, 26 | void *inputBuffer, 27 | uint32_t inputBufferNumBytes, 28 | NSUInteger frameBufferNumPixels, 29 | uint32_t processAsBPP); 30 | 31 | // Rewrite generic maxvid delta codes to "pixel delta" codes where each 32 | // pixel data element is a delta as compared to the previous pixel. 33 | 34 | uint32_t 35 | maxvid_deltas_decompress16(uint32_t *inputBuffer32, uint32_t *outputBuffer32, uint32_t inputBuffer32NumWords); 36 | 37 | uint32_t 38 | maxvid_deltas_decompress32(uint32_t *inputBuffer32, uint32_t *outputBuffer32, uint32_t inputBuffer32NumWords); 39 | 40 | #endif // MV_ENABLE_DELTAS 41 | -------------------------------------------------------------------------------- /Classes/AVAnimator/maxvid_file.c: -------------------------------------------------------------------------------- 1 | // maxvid_file module 2 | // 3 | // License terms defined in License.txt. 4 | // 5 | // This module defines the format and logic to read and write a maxvid file. 6 | 7 | #include "maxvid_file.h" 8 | 9 | /* largest prime smaller than 65536 */ 10 | #define BASE 65521L 11 | 12 | /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ 13 | #define NMAX 5552 14 | 15 | #define DO1(buf, i) { s1 += buf[i]; s2 += s1; } 16 | #define DO2(buf, i) DO1(buf, i); DO1(buf, i + 1); 17 | #define DO4(buf, i) DO2(buf, i); DO2(buf, i + 2); 18 | #define DO8(buf, i) DO4(buf, i); DO4(buf, i + 4); 19 | #define DO16(buf) DO8(buf, 0); DO8(buf, 8); 20 | 21 | uint32_t maxvid_adler32( 22 | uint32_t adler, 23 | unsigned char const *buf, 24 | uint32_t len) 25 | { 26 | int k; 27 | uint32_t s1 = adler & 0xffff; 28 | uint32_t s2 = (adler >> 16) & 0xffff; 29 | 30 | if (!buf) 31 | return 1; 32 | 33 | while (len > 0) { 34 | k = len < NMAX ? len :NMAX; 35 | len -= k; 36 | while (k >= 16) { 37 | DO16(buf); 38 | buf += 16; 39 | k -= 16; 40 | } 41 | if (k != 0) 42 | do { 43 | s1 += *buf++; 44 | s2 += s1; 45 | } while (--k); 46 | s1 %= BASE; 47 | s2 %= BASE; 48 | } 49 | 50 | uint32_t result = (s2 << 16) | s1; 51 | 52 | if (result == 0) { 53 | // All zero input, use 0xFFFFFFFF instead 54 | result = 0xFFFFFFFF; 55 | } 56 | 57 | return result; 58 | } 59 | -------------------------------------------------------------------------------- /Classes/AutoPropertyRelease.h: -------------------------------------------------------------------------------- 1 | // 2 | // AutoPropertyRelease.h 3 | // 4 | // Created by Moses DeJong on 11/11/09. 5 | // Placed in the public domain. 6 | // 7 | // This class implements a runtime property deallocator. 8 | // The Objective-C compiler really should implement 9 | // automatic deallocation of properties that retain/copy. 10 | // Until that happens, this class provides a simple way 11 | // to ensure that all retained objects are actually released. 12 | // Be aware that this releaseProperties method can only be 13 | // invoked safely from the dealloc method of a class. 14 | // 15 | // @implementation MyClass 16 | // @synthesize ...; 17 | // 18 | // - (void) dealloc { 19 | // [AutoPropertyRelease releaseProperties:self thisClass:[MyClass class]]; 20 | // [super dealloc]; 21 | // } 22 | // 23 | // The releaseProperties method sets each object property to nil, so 24 | // you could optionally invoke it from viewDidUnload in addition to 25 | // dealloc in a gui class that extends NSView. Note that the usage 26 | // below will release all the properties, not just those that extend NSView. 27 | // 28 | //- (void)viewDidUnload { 29 | // [AutoPropertyRelease releaseProperties:self thisClass:[MyClass class]]; 30 | //} 31 | 32 | #if __has_feature(objc_arc) 33 | // No-op 34 | #else 35 | 36 | #import 37 | 38 | @interface AutoPropertyRelease : NSObject { 39 | } 40 | 41 | + (void)releaseProperties:(NSObject*)obj thisClass:(Class)thisClass; 42 | 43 | @end 44 | 45 | #endif // objc_arc 46 | -------------------------------------------------------------------------------- /Classes/LZMASDK/7zBuf.c: -------------------------------------------------------------------------------- 1 | /* 7zBuf.c -- Byte Buffer 2 | 2008-03-28 3 | Igor Pavlov 4 | Public domain */ 5 | 6 | #include "7zBuf.h" 7 | 8 | void Buf_Init(CBuf *p) 9 | { 10 | p->data = 0; 11 | p->size = 0; 12 | } 13 | 14 | int Buf_Create(CBuf *p, size_t size, ISzAlloc *alloc) 15 | { 16 | p->size = 0; 17 | if (size == 0) 18 | { 19 | p->data = 0; 20 | return 1; 21 | } 22 | p->data = (Byte *)alloc->Alloc(alloc, size); 23 | if (p->data != 0) 24 | { 25 | p->size = size; 26 | return 1; 27 | } 28 | return 0; 29 | } 30 | 31 | void Buf_Free(CBuf *p, ISzAlloc *alloc) 32 | { 33 | alloc->Free(alloc, p->data); 34 | p->data = 0; 35 | p->size = 0; 36 | } 37 | -------------------------------------------------------------------------------- /Classes/LZMASDK/7zBuf.h: -------------------------------------------------------------------------------- 1 | /* 7zBuf.h -- Byte Buffer 2 | 2009-02-07 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_BUF_H 5 | #define __7Z_BUF_H 6 | 7 | #include "Types.h" 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | typedef struct 14 | { 15 | Byte *data; 16 | size_t size; 17 | } CBuf; 18 | 19 | void Buf_Init(CBuf *p); 20 | int Buf_Create(CBuf *p, size_t size, ISzAlloc *alloc); 21 | void Buf_Free(CBuf *p, ISzAlloc *alloc); 22 | 23 | typedef struct 24 | { 25 | Byte *data; 26 | size_t size; 27 | size_t pos; 28 | } CDynBuf; 29 | 30 | void DynBuf_Construct(CDynBuf *p); 31 | void DynBuf_SeekToBeg(CDynBuf *p); 32 | int DynBuf_Write(CDynBuf *p, const Byte *buf, size_t size, ISzAlloc *alloc); 33 | void DynBuf_Free(CDynBuf *p, ISzAlloc *alloc); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Classes/LZMASDK/7zBuf2.c: -------------------------------------------------------------------------------- 1 | /* 7zBuf2.c -- Byte Buffer 2 | 2008-10-04 : Igor Pavlov : Public domain */ 3 | 4 | #include 5 | #include "7zBuf.h" 6 | 7 | void DynBuf_Construct(CDynBuf *p) 8 | { 9 | p->data = 0; 10 | p->size = 0; 11 | p->pos = 0; 12 | } 13 | 14 | void DynBuf_SeekToBeg(CDynBuf *p) 15 | { 16 | p->pos = 0; 17 | } 18 | 19 | int DynBuf_Write(CDynBuf *p, const Byte *buf, size_t size, ISzAlloc *alloc) 20 | { 21 | if (size > p->size - p->pos) 22 | { 23 | size_t newSize = p->pos + size; 24 | Byte *data; 25 | newSize += newSize / 4; 26 | data = (Byte *)alloc->Alloc(alloc, newSize); 27 | if (data == 0) 28 | return 0; 29 | p->size = newSize; 30 | memcpy(data, p->data, p->pos); 31 | alloc->Free(alloc, p->data); 32 | p->data = data; 33 | } 34 | memcpy(p->data + p->pos, buf, size); 35 | p->pos += size; 36 | return 1; 37 | } 38 | 39 | void DynBuf_Free(CDynBuf *p, ISzAlloc *alloc) 40 | { 41 | alloc->Free(alloc, p->data); 42 | p->data = 0; 43 | p->size = 0; 44 | p->pos = 0; 45 | } 46 | -------------------------------------------------------------------------------- /Classes/LZMASDK/7zFile.h: -------------------------------------------------------------------------------- 1 | /* 7zFile.h -- File IO 2 | 2009-11-24 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_FILE_H 5 | #define __7Z_FILE_H 6 | 7 | #ifdef _WIN32 8 | #define USE_WINDOWS_FILE 9 | #endif 10 | 11 | #ifdef USE_WINDOWS_FILE 12 | #include 13 | #else 14 | #include 15 | #endif 16 | 17 | #include "Types.h" 18 | 19 | EXTERN_C_BEGIN 20 | 21 | /* ---------- File ---------- */ 22 | 23 | typedef struct 24 | { 25 | #ifdef USE_WINDOWS_FILE 26 | HANDLE handle; 27 | #else 28 | FILE *file; 29 | #endif 30 | } CSzFile; 31 | 32 | void File_Construct(CSzFile *p); 33 | #if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE) 34 | WRes InFile_Open(CSzFile *p, const char *name); 35 | WRes OutFile_Open(CSzFile *p, const char *name, const char *threadCwd); 36 | #endif 37 | #ifdef USE_WINDOWS_FILE 38 | WRes InFile_OpenW(CSzFile *p, const WCHAR *name); 39 | WRes OutFile_OpenW(CSzFile *p, const WCHAR *name, const WCHAR *threadCwd); 40 | #endif 41 | WRes File_Close(CSzFile *p); 42 | 43 | /* reads max(*size, remain file's size) bytes */ 44 | WRes File_Read(CSzFile *p, void *data, size_t *size); 45 | 46 | /* writes *size bytes */ 47 | WRes File_Write(CSzFile *p, const void *data, size_t *size); 48 | 49 | WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin); 50 | WRes File_GetLength(CSzFile *p, UInt64 *length); 51 | 52 | 53 | /* ---------- FileInStream ---------- */ 54 | 55 | typedef struct 56 | { 57 | ISeqInStream s; 58 | CSzFile file; 59 | } CFileSeqInStream; 60 | 61 | void FileSeqInStream_CreateVTable(CFileSeqInStream *p); 62 | 63 | 64 | typedef struct 65 | { 66 | ISeekInStream s; 67 | CSzFile file; 68 | } CFileInStream; 69 | 70 | void FileInStream_CreateVTable(CFileInStream *p); 71 | 72 | 73 | typedef struct 74 | { 75 | ISeqOutStream s; 76 | CSzFile file; 77 | } CFileOutStream; 78 | 79 | void FileOutStream_CreateVTable(CFileOutStream *p); 80 | 81 | EXTERN_C_END 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /Classes/LZMASDK/7zStream.c: -------------------------------------------------------------------------------- 1 | /* 7zStream.c -- 7z Stream functions 2 | 2010-03-11 : Igor Pavlov : Public domain */ 3 | 4 | #include 5 | 6 | #include "Types.h" 7 | 8 | SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType) 9 | { 10 | while (size != 0) 11 | { 12 | size_t processed = size; 13 | RINOK(stream->Read(stream, buf, &processed)); 14 | if (processed == 0) 15 | return errorType; 16 | buf = (void *)((Byte *)buf + processed); 17 | size -= processed; 18 | } 19 | return SZ_OK; 20 | } 21 | 22 | SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size) 23 | { 24 | return SeqInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); 25 | } 26 | 27 | SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf) 28 | { 29 | size_t processed = 1; 30 | RINOK(stream->Read(stream, buf, &processed)); 31 | return (processed == 1) ? SZ_OK : SZ_ERROR_INPUT_EOF; 32 | } 33 | 34 | SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset) 35 | { 36 | Int64 t = offset; 37 | return stream->Seek(stream, &t, SZ_SEEK_SET); 38 | } 39 | 40 | SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size) 41 | { 42 | const void *lookBuf; 43 | if (*size == 0) 44 | return SZ_OK; 45 | RINOK(stream->Look(stream, &lookBuf, size)); 46 | memcpy(buf, lookBuf, *size); 47 | return stream->Skip(stream, *size); 48 | } 49 | 50 | SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType) 51 | { 52 | while (size != 0) 53 | { 54 | size_t processed = size; 55 | RINOK(stream->Read(stream, buf, &processed)); 56 | if (processed == 0) 57 | return errorType; 58 | buf = (void *)((Byte *)buf + processed); 59 | size -= processed; 60 | } 61 | return SZ_OK; 62 | } 63 | 64 | SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size) 65 | { 66 | return LookInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); 67 | } 68 | 69 | static SRes LookToRead_Look_Lookahead(void *pp, const void **buf, size_t *size) 70 | { 71 | SRes res = SZ_OK; 72 | CLookToRead *p = (CLookToRead *)pp; 73 | size_t size2 = p->size - p->pos; 74 | if (size2 == 0 && *size > 0) 75 | { 76 | p->pos = 0; 77 | size2 = LookToRead_BUF_SIZE; 78 | res = p->realStream->Read(p->realStream, p->buf, &size2); 79 | p->size = size2; 80 | } 81 | if (size2 < *size) 82 | *size = size2; 83 | *buf = p->buf + p->pos; 84 | return res; 85 | } 86 | 87 | static SRes LookToRead_Look_Exact(void *pp, const void **buf, size_t *size) 88 | { 89 | SRes res = SZ_OK; 90 | CLookToRead *p = (CLookToRead *)pp; 91 | size_t size2 = p->size - p->pos; 92 | if (size2 == 0 && *size > 0) 93 | { 94 | p->pos = 0; 95 | if (*size > LookToRead_BUF_SIZE) 96 | *size = LookToRead_BUF_SIZE; 97 | res = p->realStream->Read(p->realStream, p->buf, size); 98 | size2 = p->size = *size; 99 | } 100 | if (size2 < *size) 101 | *size = size2; 102 | *buf = p->buf + p->pos; 103 | return res; 104 | } 105 | 106 | static SRes LookToRead_Skip(void *pp, size_t offset) 107 | { 108 | CLookToRead *p = (CLookToRead *)pp; 109 | p->pos += offset; 110 | return SZ_OK; 111 | } 112 | 113 | static SRes LookToRead_Read(void *pp, void *buf, size_t *size) 114 | { 115 | CLookToRead *p = (CLookToRead *)pp; 116 | size_t rem = p->size - p->pos; 117 | if (rem == 0) 118 | return p->realStream->Read(p->realStream, buf, size); 119 | if (rem > *size) 120 | rem = *size; 121 | memcpy(buf, p->buf + p->pos, rem); 122 | p->pos += rem; 123 | *size = rem; 124 | return SZ_OK; 125 | } 126 | 127 | static SRes LookToRead_Seek(void *pp, Int64 *pos, ESzSeek origin) 128 | { 129 | CLookToRead *p = (CLookToRead *)pp; 130 | p->pos = p->size = 0; 131 | return p->realStream->Seek(p->realStream, pos, origin); 132 | } 133 | 134 | void LookToRead_CreateVTable(CLookToRead *p, int lookahead) 135 | { 136 | p->s.Look = lookahead ? 137 | LookToRead_Look_Lookahead : 138 | LookToRead_Look_Exact; 139 | p->s.Skip = LookToRead_Skip; 140 | p->s.Read = LookToRead_Read; 141 | p->s.Seek = LookToRead_Seek; 142 | } 143 | 144 | void LookToRead_Init(CLookToRead *p) 145 | { 146 | p->pos = p->size = 0; 147 | } 148 | 149 | static SRes SecToLook_Read(void *pp, void *buf, size_t *size) 150 | { 151 | CSecToLook *p = (CSecToLook *)pp; 152 | return LookInStream_LookRead(p->realStream, buf, size); 153 | } 154 | 155 | void SecToLook_CreateVTable(CSecToLook *p) 156 | { 157 | p->s.Read = SecToLook_Read; 158 | } 159 | 160 | static SRes SecToRead_Read(void *pp, void *buf, size_t *size) 161 | { 162 | CSecToRead *p = (CSecToRead *)pp; 163 | return p->realStream->Read(p->realStream, buf, size); 164 | } 165 | 166 | void SecToRead_CreateVTable(CSecToRead *p) 167 | { 168 | p->s.Read = SecToRead_Read; 169 | } 170 | -------------------------------------------------------------------------------- /Classes/LZMASDK/7zVersion.h: -------------------------------------------------------------------------------- 1 | #define MY_VER_MAJOR 9 2 | #define MY_VER_MINOR 22 3 | #define MY_VER_BUILD 00 4 | #define MY_VERSION "9.22 beta" 5 | #define MY_7ZIP_VERSION "9.22 beta" 6 | #define MY_DATE "2011-04-18" 7 | #define MY_COPYRIGHT ": Igor Pavlov : Public domain" 8 | #define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " : " MY_DATE 9 | -------------------------------------------------------------------------------- /Classes/LZMASDK/Alloc.c: -------------------------------------------------------------------------------- 1 | /* Alloc.c -- Memory allocation functions 2 | 2008-09-24 3 | Igor Pavlov 4 | Public domain */ 5 | 6 | #ifdef _WIN32 7 | #include 8 | #endif 9 | #include 10 | 11 | #include "Alloc.h" 12 | 13 | /* #define _SZ_ALLOC_DEBUG */ 14 | 15 | /* use _SZ_ALLOC_DEBUG to debug alloc/free operations */ 16 | #ifdef _SZ_ALLOC_DEBUG 17 | #include 18 | int g_allocCount = 0; 19 | int g_allocCountMid = 0; 20 | int g_allocCountBig = 0; 21 | #endif 22 | 23 | void *MyAlloc(size_t size) 24 | { 25 | if (size == 0) 26 | return 0; 27 | #ifdef _SZ_ALLOC_DEBUG 28 | { 29 | void *p = malloc(size); 30 | fprintf(stderr, "\nAlloc %10d bytes, count = %10d, addr = %8X", size, g_allocCount++, (unsigned)p); 31 | return p; 32 | } 33 | #else 34 | return malloc(size); 35 | #endif 36 | } 37 | 38 | void MyFree(void *address) 39 | { 40 | #ifdef _SZ_ALLOC_DEBUG 41 | if (address != 0) 42 | fprintf(stderr, "\nFree; count = %10d, addr = %8X", --g_allocCount, (unsigned)address); 43 | #endif 44 | free(address); 45 | } 46 | 47 | #ifdef _WIN32 48 | 49 | void *MidAlloc(size_t size) 50 | { 51 | if (size == 0) 52 | return 0; 53 | #ifdef _SZ_ALLOC_DEBUG 54 | fprintf(stderr, "\nAlloc_Mid %10d bytes; count = %10d", size, g_allocCountMid++); 55 | #endif 56 | return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE); 57 | } 58 | 59 | void MidFree(void *address) 60 | { 61 | #ifdef _SZ_ALLOC_DEBUG 62 | if (address != 0) 63 | fprintf(stderr, "\nFree_Mid; count = %10d", --g_allocCountMid); 64 | #endif 65 | if (address == 0) 66 | return; 67 | VirtualFree(address, 0, MEM_RELEASE); 68 | } 69 | 70 | #ifndef MEM_LARGE_PAGES 71 | #undef _7ZIP_LARGE_PAGES 72 | #endif 73 | 74 | #ifdef _7ZIP_LARGE_PAGES 75 | SIZE_T g_LargePageSize = 0; 76 | typedef SIZE_T (WINAPI *GetLargePageMinimumP)(); 77 | #endif 78 | 79 | void SetLargePageSize() 80 | { 81 | #ifdef _7ZIP_LARGE_PAGES 82 | SIZE_T size = 0; 83 | GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP) 84 | GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum"); 85 | if (largePageMinimum == 0) 86 | return; 87 | size = largePageMinimum(); 88 | if (size == 0 || (size & (size - 1)) != 0) 89 | return; 90 | g_LargePageSize = size; 91 | #endif 92 | } 93 | 94 | 95 | void *BigAlloc(size_t size) 96 | { 97 | if (size == 0) 98 | return 0; 99 | #ifdef _SZ_ALLOC_DEBUG 100 | fprintf(stderr, "\nAlloc_Big %10d bytes; count = %10d", size, g_allocCountBig++); 101 | #endif 102 | 103 | #ifdef _7ZIP_LARGE_PAGES 104 | if (g_LargePageSize != 0 && g_LargePageSize <= (1 << 30) && size >= (1 << 18)) 105 | { 106 | void *res = VirtualAlloc(0, (size + g_LargePageSize - 1) & (~(g_LargePageSize - 1)), 107 | MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE); 108 | if (res != 0) 109 | return res; 110 | } 111 | #endif 112 | return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE); 113 | } 114 | 115 | void BigFree(void *address) 116 | { 117 | #ifdef _SZ_ALLOC_DEBUG 118 | if (address != 0) 119 | fprintf(stderr, "\nFree_Big; count = %10d", --g_allocCountBig); 120 | #endif 121 | 122 | if (address == 0) 123 | return; 124 | VirtualFree(address, 0, MEM_RELEASE); 125 | } 126 | 127 | #endif 128 | -------------------------------------------------------------------------------- /Classes/LZMASDK/Alloc.h: -------------------------------------------------------------------------------- 1 | /* Alloc.h -- Memory allocation functions 2 | 2009-02-07 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __COMMON_ALLOC_H 5 | #define __COMMON_ALLOC_H 6 | 7 | #include 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | void *MyAlloc(size_t size); 14 | void MyFree(void *address); 15 | 16 | #ifdef _WIN32 17 | 18 | void SetLargePageSize(); 19 | 20 | void *MidAlloc(size_t size); 21 | void MidFree(void *address); 22 | void *BigAlloc(size_t size); 23 | void BigFree(void *address); 24 | 25 | #else 26 | 27 | #define MidAlloc(size) MyAlloc(size) 28 | #define MidFree(address) MyFree(address) 29 | #define BigAlloc(size) MyAlloc(size) 30 | #define BigFree(address) MyFree(address) 31 | 32 | #endif 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /Classes/LZMASDK/CpuArch.c: -------------------------------------------------------------------------------- 1 | /* CpuArch.c -- CPU specific code 2 | 2009-12-12: Igor Pavlov : Public domain */ 3 | 4 | #pragma clang diagnostic ignored "-Wmissing-prototypes" 5 | 6 | #include "CpuArch.h" 7 | 8 | -------------------------------------------------------------------------------- /Classes/LZMASDK/CpuArch.h: -------------------------------------------------------------------------------- 1 | /* CpuArch.h -- CPU specific code 2 | 2010-12-01: Igor Pavlov : Public domain */ 3 | 4 | #ifndef __CPU_ARCH_H 5 | #define __CPU_ARCH_H 6 | 7 | #include "Types.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | /* 12 | MY_CPU_LE means that CPU is LITTLE ENDIAN. 13 | If MY_CPU_LE is not defined, we don't know about that property of platform (it can be LITTLE ENDIAN). 14 | 15 | MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned memory accesses. 16 | If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of platform. 17 | */ 18 | 19 | #if defined(_M_X64) || defined(_M_AMD64) || defined(__x86_64__) 20 | #define MY_CPU_AMD64 21 | #endif 22 | 23 | #if defined(MY_CPU_AMD64) || defined(_M_IA64) 24 | #define MY_CPU_64BIT 25 | #endif 26 | 27 | #if defined(_M_IX86) || defined(__i386__) 28 | #define MY_CPU_X86 29 | #endif 30 | 31 | #if defined(MY_CPU_X86) || defined(MY_CPU_AMD64) 32 | #define MY_CPU_X86_OR_AMD64 33 | #endif 34 | 35 | #if defined(MY_CPU_X86) || defined(_M_ARM) 36 | #define MY_CPU_32BIT 37 | #endif 38 | 39 | #if defined(_WIN32) && defined(_M_ARM) 40 | #define MY_CPU_ARM_LE 41 | #endif 42 | 43 | #if defined(_WIN32) && defined(_M_IA64) 44 | #define MY_CPU_IA64_LE 45 | #endif 46 | 47 | #if defined(MY_CPU_X86_OR_AMD64) 48 | #define MY_CPU_LE_UNALIGN 49 | #endif 50 | 51 | #if defined(MY_CPU_X86_OR_AMD64) || defined(MY_CPU_ARM_LE) || defined(MY_CPU_IA64_LE) || defined(__ARMEL__) || defined(__MIPSEL__) || defined(__LITTLE_ENDIAN__) 52 | #define MY_CPU_LE 53 | #endif 54 | 55 | #if defined(__BIG_ENDIAN__) || defined(__m68k__) || defined(__ARMEB__) || defined(__MIPSEB__) 56 | #define MY_CPU_BE 57 | #endif 58 | 59 | #if defined(MY_CPU_LE) && defined(MY_CPU_BE) 60 | Stop_Compiling_Bad_Endian 61 | #endif 62 | 63 | #ifdef MY_CPU_LE_UNALIGN 64 | 65 | #define GetUi16(p) (*(const UInt16 *)(p)) 66 | #define GetUi32(p) (*(const UInt32 *)(p)) 67 | #define GetUi64(p) (*(const UInt64 *)(p)) 68 | #define SetUi16(p, d) *(UInt16 *)(p) = (d); 69 | #define SetUi32(p, d) *(UInt32 *)(p) = (d); 70 | #define SetUi64(p, d) *(UInt64 *)(p) = (d); 71 | 72 | #else 73 | 74 | #define GetUi16(p) (((const Byte *)(p))[0] | ((UInt16)((const Byte *)(p))[1] << 8)) 75 | 76 | #define GetUi32(p) ( \ 77 | ((const Byte *)(p))[0] | \ 78 | ((UInt32)((const Byte *)(p))[1] << 8) | \ 79 | ((UInt32)((const Byte *)(p))[2] << 16) | \ 80 | ((UInt32)((const Byte *)(p))[3] << 24)) 81 | 82 | #define GetUi64(p) (GetUi32(p) | ((UInt64)GetUi32(((const Byte *)(p)) + 4) << 32)) 83 | 84 | #define SetUi16(p, d) { UInt32 _x_ = (d); \ 85 | ((Byte *)(p))[0] = (Byte)_x_; \ 86 | ((Byte *)(p))[1] = (Byte)(_x_ >> 8); } 87 | 88 | #define SetUi32(p, d) { UInt32 _x_ = (d); \ 89 | ((Byte *)(p))[0] = (Byte)_x_; \ 90 | ((Byte *)(p))[1] = (Byte)(_x_ >> 8); \ 91 | ((Byte *)(p))[2] = (Byte)(_x_ >> 16); \ 92 | ((Byte *)(p))[3] = (Byte)(_x_ >> 24); } 93 | 94 | #define SetUi64(p, d) { UInt64 _x64_ = (d); \ 95 | SetUi32(p, (UInt32)_x64_); \ 96 | SetUi32(((Byte *)(p)) + 4, (UInt32)(_x64_ >> 32)); } 97 | 98 | #endif 99 | 100 | #if defined(MY_CPU_LE_UNALIGN) && defined(_WIN64) && (_MSC_VER >= 1300) 101 | 102 | #pragma intrinsic(_byteswap_ulong) 103 | #pragma intrinsic(_byteswap_uint64) 104 | #define GetBe32(p) _byteswap_ulong(*(const UInt32 *)(const Byte *)(p)) 105 | #define GetBe64(p) _byteswap_uint64(*(const UInt64 *)(const Byte *)(p)) 106 | 107 | #else 108 | 109 | #define GetBe32(p) ( \ 110 | ((UInt32)((const Byte *)(p))[0] << 24) | \ 111 | ((UInt32)((const Byte *)(p))[1] << 16) | \ 112 | ((UInt32)((const Byte *)(p))[2] << 8) | \ 113 | ((const Byte *)(p))[3] ) 114 | 115 | #define GetBe64(p) (((UInt64)GetBe32(p) << 32) | GetBe32(((const Byte *)(p)) + 4)) 116 | 117 | #endif 118 | 119 | #define GetBe16(p) (((UInt16)((const Byte *)(p))[0] << 8) | ((const Byte *)(p))[1]) 120 | 121 | EXTERN_C_END 122 | 123 | #endif 124 | -------------------------------------------------------------------------------- /Classes/LZMASDK/Delta.c: -------------------------------------------------------------------------------- 1 | /* Delta.c -- Delta converter 2 | 2009-05-26 : Igor Pavlov : Public domain */ 3 | 4 | #include "Delta.h" 5 | 6 | void Delta_Init(Byte *state) 7 | { 8 | unsigned i; 9 | for (i = 0; i < DELTA_STATE_SIZE; i++) 10 | state[i] = 0; 11 | } 12 | 13 | static void MyMemCpy(Byte *dest, const Byte *src, unsigned size) 14 | { 15 | unsigned i; 16 | for (i = 0; i < size; i++) 17 | dest[i] = src[i]; 18 | } 19 | 20 | void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size) 21 | { 22 | Byte buf[DELTA_STATE_SIZE]; 23 | unsigned j = 0; 24 | MyMemCpy(buf, state, delta); 25 | { 26 | SizeT i; 27 | for (i = 0; i < size;) 28 | { 29 | for (j = 0; j < delta && i < size; i++, j++) 30 | { 31 | Byte b = data[i]; 32 | data[i] = (Byte)(b - buf[j]); 33 | buf[j] = b; 34 | } 35 | } 36 | } 37 | if (j == delta) 38 | j = 0; 39 | MyMemCpy(state, buf + j, delta - j); 40 | MyMemCpy(state + delta - j, buf, j); 41 | } 42 | 43 | void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size) 44 | { 45 | Byte buf[DELTA_STATE_SIZE]; 46 | unsigned j = 0; 47 | MyMemCpy(buf, state, delta); 48 | { 49 | SizeT i; 50 | for (i = 0; i < size;) 51 | { 52 | for (j = 0; j < delta && i < size; i++, j++) 53 | { 54 | buf[j] = data[i] = (Byte)(buf[j] + data[i]); 55 | } 56 | } 57 | } 58 | if (j == delta) 59 | j = 0; 60 | MyMemCpy(state, buf + j, delta - j); 61 | MyMemCpy(state + delta - j, buf, j); 62 | } 63 | -------------------------------------------------------------------------------- /Classes/LZMASDK/Delta.h: -------------------------------------------------------------------------------- 1 | /* Delta.h -- Delta converter 2 | 2009-04-15 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __DELTA_H 5 | #define __DELTA_H 6 | 7 | #include "Types.h" 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | #define DELTA_STATE_SIZE 256 14 | 15 | void Delta_Init(Byte *state); 16 | void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size); 17 | void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /Classes/LZMASDK/LZMAExtractor.h: -------------------------------------------------------------------------------- 1 | // 2 | // LZMAExtractor.h 3 | // lzmaSDK 4 | // 5 | // Created by Brian Chaikelson on 11/19/09. 6 | // Copyright 2009 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface LZMAExtractor : NSObject { 12 | } 13 | 14 | // Extract all the contents of a .7z archive directly into the indicated dir. 15 | // Directory structure is ignored if preserveDir is false. 16 | 17 | + (NSArray*) extract7zArchive:(NSString*)archivePath 18 | dirName:(NSString*)dirName 19 | preserveDir:(BOOL)preserveDir; 20 | 21 | // Extract all the contents of a .7z archive into the indicated temp dir 22 | // and return an array of the fully qualified filenames. This API 23 | // implicitly passes preserveDir as FALSE, so directory elements in the 24 | // entry name are always ignored as files are extracted. If multiple 25 | // entries have duplicated filenames in different directories, then 26 | // this API would would overwrite the duplicate entry file. 27 | 28 | + (NSArray*) extract7zArchive:(NSString*)archivePath 29 | tmpDirName:(NSString*)tmpDirName; 30 | 31 | // Extract just one entry from an archive and save it at the 32 | // path indicated by outPath. 33 | 34 | + (BOOL) extractArchiveEntry:(NSString*)archivePath 35 | archiveEntry:(NSString*)archiveEntry 36 | outPath:(NSString*)outPath; 37 | 38 | @end 39 | 40 | -------------------------------------------------------------------------------- /Classes/LZMASDK/LzHash.h: -------------------------------------------------------------------------------- 1 | /* LzHash.h -- HASH functions for LZ algorithms 2 | 2009-02-07 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZ_HASH_H 5 | #define __LZ_HASH_H 6 | 7 | #define kHash2Size (1 << 10) 8 | #define kHash3Size (1 << 16) 9 | #define kHash4Size (1 << 20) 10 | 11 | #define kFix3HashSize (kHash2Size) 12 | #define kFix4HashSize (kHash2Size + kHash3Size) 13 | #define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size) 14 | 15 | #define HASH2_CALC hashValue = cur[0] | ((UInt32)cur[1] << 8); 16 | 17 | #define HASH3_CALC { \ 18 | UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ 19 | hash2Value = temp & (kHash2Size - 1); \ 20 | hashValue = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; } 21 | 22 | #define HASH4_CALC { \ 23 | UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ 24 | hash2Value = temp & (kHash2Size - 1); \ 25 | hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ 26 | hashValue = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & p->hashMask; } 27 | 28 | #define HASH5_CALC { \ 29 | UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ 30 | hash2Value = temp & (kHash2Size - 1); \ 31 | hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ 32 | hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)); \ 33 | hashValue = (hash4Value ^ (p->crc[cur[4]] << 3)) & p->hashMask; \ 34 | hash4Value &= (kHash4Size - 1); } 35 | 36 | /* #define HASH_ZIP_CALC hashValue = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */ 37 | #define HASH_ZIP_CALC hashValue = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF; 38 | 39 | 40 | #define MT_HASH2_CALC \ 41 | hash2Value = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1); 42 | 43 | #define MT_HASH3_CALC { \ 44 | UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ 45 | hash2Value = temp & (kHash2Size - 1); \ 46 | hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); } 47 | 48 | #define MT_HASH4_CALC { \ 49 | UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ 50 | hash2Value = temp & (kHash2Size - 1); \ 51 | hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ 52 | hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /Classes/LZMASDK/Lzma2Dec.h: -------------------------------------------------------------------------------- 1 | /* Lzma2Dec.h -- LZMA2 Decoder 2 | 2009-05-03 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZMA2_DEC_H 5 | #define __LZMA2_DEC_H 6 | 7 | #include "LzmaDec.h" 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /* ---------- State Interface ---------- */ 14 | 15 | typedef struct 16 | { 17 | CLzmaDec decoder; 18 | UInt32 packSize; 19 | UInt32 unpackSize; 20 | int state; 21 | Byte control; 22 | Bool needInitDic; 23 | Bool needInitState; 24 | Bool needInitProp; 25 | } CLzma2Dec; 26 | 27 | #define Lzma2Dec_Construct(p) LzmaDec_Construct(&(p)->decoder) 28 | #define Lzma2Dec_FreeProbs(p, alloc) LzmaDec_FreeProbs(&(p)->decoder, alloc); 29 | #define Lzma2Dec_Free(p, alloc) LzmaDec_Free(&(p)->decoder, alloc); 30 | 31 | SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, Byte prop, ISzAlloc *alloc); 32 | SRes Lzma2Dec_Allocate(CLzma2Dec *p, Byte prop, ISzAlloc *alloc); 33 | void Lzma2Dec_Init(CLzma2Dec *p); 34 | 35 | 36 | /* 37 | finishMode: 38 | It has meaning only if the decoding reaches output limit (*destLen or dicLimit). 39 | LZMA_FINISH_ANY - use smallest number of input bytes 40 | LZMA_FINISH_END - read EndOfStream marker after decoding 41 | 42 | Returns: 43 | SZ_OK 44 | status: 45 | LZMA_STATUS_FINISHED_WITH_MARK 46 | LZMA_STATUS_NOT_FINISHED 47 | LZMA_STATUS_NEEDS_MORE_INPUT 48 | SZ_ERROR_DATA - Data error 49 | */ 50 | 51 | SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, 52 | const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); 53 | 54 | SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen, 55 | const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); 56 | 57 | 58 | /* ---------- One Call Interface ---------- */ 59 | 60 | /* 61 | finishMode: 62 | It has meaning only if the decoding reaches output limit (*destLen). 63 | LZMA_FINISH_ANY - use smallest number of input bytes 64 | LZMA_FINISH_END - read EndOfStream marker after decoding 65 | 66 | Returns: 67 | SZ_OK 68 | status: 69 | LZMA_STATUS_FINISHED_WITH_MARK 70 | LZMA_STATUS_NOT_FINISHED 71 | SZ_ERROR_DATA - Data error 72 | SZ_ERROR_MEM - Memory allocation error 73 | SZ_ERROR_UNSUPPORTED - Unsupported properties 74 | SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). 75 | */ 76 | 77 | SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, 78 | Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc); 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /Classes/LZMASDK/Ppmd.h: -------------------------------------------------------------------------------- 1 | /* Ppmd.h -- PPMD codec common code 2 | 2011-01-27 : Igor Pavlov : Public domain 3 | This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */ 4 | 5 | #ifndef __PPMD_H 6 | #define __PPMD_H 7 | 8 | #include "Types.h" 9 | #include "CpuArch.h" 10 | 11 | EXTERN_C_BEGIN 12 | 13 | #ifdef MY_CPU_32BIT 14 | #define PPMD_32BIT 15 | #endif 16 | 17 | #define PPMD_INT_BITS 7 18 | #define PPMD_PERIOD_BITS 7 19 | #define PPMD_BIN_SCALE (1 << (PPMD_INT_BITS + PPMD_PERIOD_BITS)) 20 | 21 | #define PPMD_GET_MEAN_SPEC(summ, shift, round) (((summ) + (1 << ((shift) - (round)))) >> (shift)) 22 | #define PPMD_GET_MEAN(summ) PPMD_GET_MEAN_SPEC((summ), PPMD_PERIOD_BITS, 2) 23 | #define PPMD_UPDATE_PROB_0(prob) ((prob) + (1 << PPMD_INT_BITS) - PPMD_GET_MEAN(prob)) 24 | #define PPMD_UPDATE_PROB_1(prob) ((prob) - PPMD_GET_MEAN(prob)) 25 | 26 | #define PPMD_N1 4 27 | #define PPMD_N2 4 28 | #define PPMD_N3 4 29 | #define PPMD_N4 ((128 + 3 - 1 * PPMD_N1 - 2 * PPMD_N2 - 3 * PPMD_N3) / 4) 30 | #define PPMD_NUM_INDEXES (PPMD_N1 + PPMD_N2 + PPMD_N3 + PPMD_N4) 31 | 32 | #pragma pack(push, 1) 33 | /* Most compilers works OK here even without #pragma pack(push, 1), but some GCC compilers need it. */ 34 | 35 | /* SEE-contexts for PPM-contexts with masked symbols */ 36 | typedef struct 37 | { 38 | UInt16 Summ; /* Freq */ 39 | Byte Shift; /* Speed of Freq change; low Shift is for fast change */ 40 | Byte Count; /* Count to next change of Shift */ 41 | } CPpmd_See; 42 | 43 | #define Ppmd_See_Update(p) if ((p)->Shift < PPMD_PERIOD_BITS && --(p)->Count == 0) \ 44 | { (p)->Summ <<= 1; (p)->Count = (Byte)(3 << (p)->Shift++); } 45 | 46 | typedef struct 47 | { 48 | Byte Symbol; 49 | Byte Freq; 50 | UInt16 SuccessorLow; 51 | UInt16 SuccessorHigh; 52 | } CPpmd_State; 53 | 54 | #pragma pack(pop) 55 | 56 | typedef 57 | #ifdef PPMD_32BIT 58 | CPpmd_State * 59 | #else 60 | UInt32 61 | #endif 62 | CPpmd_State_Ref; 63 | 64 | typedef 65 | #ifdef PPMD_32BIT 66 | void * 67 | #else 68 | UInt32 69 | #endif 70 | CPpmd_Void_Ref; 71 | 72 | typedef 73 | #ifdef PPMD_32BIT 74 | Byte * 75 | #else 76 | UInt32 77 | #endif 78 | CPpmd_Byte_Ref; 79 | 80 | #define PPMD_SetAllBitsIn256Bytes(p) \ 81 | { unsigned i; for (i = 0; i < 256 / sizeof(p[0]); i += 8) { \ 82 | p[i+7] = p[i+6] = p[i+5] = p[i+4] = p[i+3] = p[i+2] = p[i+1] = p[i+0] = ~(size_t)0; }} 83 | 84 | EXTERN_C_END 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /Classes/LZMASDK/Ppmd7.h: -------------------------------------------------------------------------------- 1 | /* Ppmd7.h -- PPMdH compression codec 2 | 2010-03-12 : Igor Pavlov : Public domain 3 | This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */ 4 | 5 | /* This code supports virtual RangeDecoder and includes the implementation 6 | of RangeCoder from 7z, instead of RangeCoder from original PPMd var.H. 7 | If you need the compatibility with original PPMd var.H, you can use external RangeDecoder */ 8 | 9 | #ifndef __PPMD7_H 10 | #define __PPMD7_H 11 | 12 | #include "Ppmd.h" 13 | 14 | EXTERN_C_BEGIN 15 | 16 | #define PPMD7_MIN_ORDER 2 17 | #define PPMD7_MAX_ORDER 64 18 | 19 | #define PPMD7_MIN_MEM_SIZE (1 << 11) 20 | #define PPMD7_MAX_MEM_SIZE (0xFFFFFFFF - 12 * 3) 21 | 22 | struct CPpmd7_Context_; 23 | 24 | typedef 25 | #ifdef PPMD_32BIT 26 | struct CPpmd7_Context_ * 27 | #else 28 | UInt32 29 | #endif 30 | CPpmd7_Context_Ref; 31 | 32 | typedef struct CPpmd7_Context_ 33 | { 34 | UInt16 NumStats; 35 | UInt16 SummFreq; 36 | CPpmd_State_Ref Stats; 37 | CPpmd7_Context_Ref Suffix; 38 | } CPpmd7_Context; 39 | 40 | #define Ppmd7Context_OneState(p) ((CPpmd_State *)&(p)->SummFreq) 41 | 42 | typedef struct 43 | { 44 | CPpmd7_Context *MinContext, *MaxContext; 45 | CPpmd_State *FoundState; 46 | unsigned OrderFall, InitEsc, PrevSuccess, MaxOrder, HiBitsFlag; 47 | Int32 RunLength, InitRL; /* must be 32-bit at least */ 48 | 49 | UInt32 Size; 50 | UInt32 GlueCount; 51 | Byte *Base, *LoUnit, *HiUnit, *Text, *UnitsStart; 52 | UInt32 AlignOffset; 53 | 54 | Byte Indx2Units[PPMD_NUM_INDEXES]; 55 | Byte Units2Indx[128]; 56 | CPpmd_Void_Ref FreeList[PPMD_NUM_INDEXES]; 57 | Byte NS2Indx[256], NS2BSIndx[256], HB2Flag[256]; 58 | CPpmd_See DummySee, See[25][16]; 59 | UInt16 BinSumm[128][64]; 60 | } CPpmd7; 61 | 62 | void Ppmd7_Construct(CPpmd7 *p); 63 | Bool Ppmd7_Alloc(CPpmd7 *p, UInt32 size, ISzAlloc *alloc); 64 | void Ppmd7_Free(CPpmd7 *p, ISzAlloc *alloc); 65 | void Ppmd7_Init(CPpmd7 *p, unsigned maxOrder); 66 | #define Ppmd7_WasAllocated(p) ((p)->Base != NULL) 67 | 68 | 69 | /* ---------- Internal Functions ---------- */ 70 | 71 | extern const Byte PPMD7_kExpEscape[16]; 72 | 73 | #ifdef PPMD_32BIT 74 | #define Ppmd7_GetPtr(p, ptr) (ptr) 75 | #define Ppmd7_GetContext(p, ptr) (ptr) 76 | #define Ppmd7_GetStats(p, ctx) ((ctx)->Stats) 77 | #else 78 | #define Ppmd7_GetPtr(p, offs) ((void *)((p)->Base + (offs))) 79 | #define Ppmd7_GetContext(p, offs) ((CPpmd7_Context *)Ppmd7_GetPtr((p), (offs))) 80 | #define Ppmd7_GetStats(p, ctx) ((CPpmd_State *)Ppmd7_GetPtr((p), ((ctx)->Stats))) 81 | #endif 82 | 83 | void Ppmd7_Update1(CPpmd7 *p); 84 | void Ppmd7_Update1_0(CPpmd7 *p); 85 | void Ppmd7_Update2(CPpmd7 *p); 86 | void Ppmd7_UpdateBin(CPpmd7 *p); 87 | 88 | #define Ppmd7_GetBinSumm(p) \ 89 | &p->BinSumm[Ppmd7Context_OneState(p->MinContext)->Freq - 1][p->PrevSuccess + \ 90 | p->NS2BSIndx[Ppmd7_GetContext(p, p->MinContext->Suffix)->NumStats - 1] + \ 91 | (p->HiBitsFlag = p->HB2Flag[p->FoundState->Symbol]) + \ 92 | 2 * p->HB2Flag[Ppmd7Context_OneState(p->MinContext)->Symbol] + \ 93 | ((p->RunLength >> 26) & 0x20)] 94 | 95 | CPpmd_See *Ppmd7_MakeEscFreq(CPpmd7 *p, unsigned numMasked, UInt32 *scale); 96 | 97 | 98 | /* ---------- Decode ---------- */ 99 | 100 | typedef struct 101 | { 102 | UInt32 (*GetThreshold)(void *p, UInt32 total); 103 | void (*Decode)(void *p, UInt32 start, UInt32 size); 104 | UInt32 (*DecodeBit)(void *p, UInt32 size0); 105 | } IPpmd7_RangeDec; 106 | 107 | typedef struct 108 | { 109 | IPpmd7_RangeDec p; 110 | UInt32 Range; 111 | UInt32 Code; 112 | IByteIn *Stream; 113 | } CPpmd7z_RangeDec; 114 | 115 | void Ppmd7z_RangeDec_CreateVTable(CPpmd7z_RangeDec *p); 116 | Bool Ppmd7z_RangeDec_Init(CPpmd7z_RangeDec *p); 117 | #define Ppmd7z_RangeDec_IsFinishedOK(p) ((p)->Code == 0) 118 | 119 | int Ppmd7_DecodeSymbol(CPpmd7 *p, IPpmd7_RangeDec *rc); 120 | 121 | 122 | /* ---------- Encode ---------- */ 123 | 124 | typedef struct 125 | { 126 | UInt64 Low; 127 | UInt32 Range; 128 | Byte Cache; 129 | UInt64 CacheSize; 130 | IByteOut *Stream; 131 | } CPpmd7z_RangeEnc; 132 | 133 | void Ppmd7z_RangeEnc_Init(CPpmd7z_RangeEnc *p); 134 | void Ppmd7z_RangeEnc_FlushData(CPpmd7z_RangeEnc *p); 135 | 136 | void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol); 137 | 138 | EXTERN_C_END 139 | 140 | #endif 141 | -------------------------------------------------------------------------------- /Classes/LZMASDK/Ppmd8.h: -------------------------------------------------------------------------------- 1 | /* Ppmd8.h -- PPMdI codec 2 | 2010-03-24 : Igor Pavlov : Public domain 3 | This code is based on: 4 | PPMd var.I (2002): Dmitry Shkarin : Public domain 5 | Carryless rangecoder (1999): Dmitry Subbotin : Public domain */ 6 | 7 | #ifndef __PPMD8_H 8 | #define __PPMD8_H 9 | 10 | #include "Ppmd.h" 11 | 12 | EXTERN_C_BEGIN 13 | 14 | #define PPMD8_MIN_ORDER 2 15 | #define PPMD8_MAX_ORDER 16 16 | 17 | struct CPpmd8_Context_; 18 | 19 | typedef 20 | #ifdef PPMD_32BIT 21 | struct CPpmd8_Context_ * 22 | #else 23 | UInt32 24 | #endif 25 | CPpmd8_Context_Ref; 26 | 27 | typedef struct CPpmd8_Context_ 28 | { 29 | Byte NumStats; 30 | Byte Flags; 31 | UInt16 SummFreq; 32 | CPpmd_State_Ref Stats; 33 | CPpmd8_Context_Ref Suffix; 34 | } CPpmd8_Context; 35 | 36 | #define Ppmd8Context_OneState(p) ((CPpmd_State *)&(p)->SummFreq) 37 | 38 | /* The BUG in Shkarin's code for FREEZE mode was fixed, but that fixed 39 | code is not compatible with original code for some files compressed 40 | in FREEZE mode. So we disable FREEZE mode support. */ 41 | 42 | enum 43 | { 44 | PPMD8_RESTORE_METHOD_RESTART, 45 | PPMD8_RESTORE_METHOD_CUT_OFF 46 | #ifdef PPMD8_FREEZE_SUPPORT 47 | , PPMD8_RESTORE_METHOD_FREEZE 48 | #endif 49 | }; 50 | 51 | typedef struct 52 | { 53 | CPpmd8_Context *MinContext, *MaxContext; 54 | CPpmd_State *FoundState; 55 | unsigned OrderFall, InitEsc, PrevSuccess, MaxOrder; 56 | Int32 RunLength, InitRL; /* must be 32-bit at least */ 57 | 58 | UInt32 Size; 59 | UInt32 GlueCount; 60 | Byte *Base, *LoUnit, *HiUnit, *Text, *UnitsStart; 61 | UInt32 AlignOffset; 62 | unsigned RestoreMethod; 63 | 64 | /* Range Coder */ 65 | UInt32 Range; 66 | UInt32 Code; 67 | UInt32 Low; 68 | union 69 | { 70 | IByteIn *In; 71 | IByteOut *Out; 72 | } Stream; 73 | 74 | Byte Indx2Units[PPMD_NUM_INDEXES]; 75 | Byte Units2Indx[128]; 76 | CPpmd_Void_Ref FreeList[PPMD_NUM_INDEXES]; 77 | UInt32 Stamps[PPMD_NUM_INDEXES]; 78 | 79 | Byte NS2BSIndx[256], NS2Indx[260]; 80 | CPpmd_See DummySee, See[24][32]; 81 | UInt16 BinSumm[25][64]; 82 | } CPpmd8; 83 | 84 | void Ppmd8_Construct(CPpmd8 *p); 85 | Bool Ppmd8_Alloc(CPpmd8 *p, UInt32 size, ISzAlloc *alloc); 86 | void Ppmd8_Free(CPpmd8 *p, ISzAlloc *alloc); 87 | void Ppmd8_Init(CPpmd8 *p, unsigned maxOrder, unsigned restoreMethod); 88 | #define Ppmd8_WasAllocated(p) ((p)->Base != NULL) 89 | 90 | 91 | /* ---------- Internal Functions ---------- */ 92 | 93 | extern const Byte PPMD8_kExpEscape[16]; 94 | 95 | #ifdef PPMD_32BIT 96 | #define Ppmd8_GetPtr(p, ptr) (ptr) 97 | #define Ppmd8_GetContext(p, ptr) (ptr) 98 | #define Ppmd8_GetStats(p, ctx) ((ctx)->Stats) 99 | #else 100 | #define Ppmd8_GetPtr(p, offs) ((void *)((p)->Base + (offs))) 101 | #define Ppmd8_GetContext(p, offs) ((CPpmd8_Context *)Ppmd8_GetPtr((p), (offs))) 102 | #define Ppmd8_GetStats(p, ctx) ((CPpmd_State *)Ppmd8_GetPtr((p), ((ctx)->Stats))) 103 | #endif 104 | 105 | void Ppmd8_Update1(CPpmd8 *p); 106 | void Ppmd8_Update1_0(CPpmd8 *p); 107 | void Ppmd8_Update2(CPpmd8 *p); 108 | void Ppmd8_UpdateBin(CPpmd8 *p); 109 | 110 | #define Ppmd8_GetBinSumm(p) \ 111 | &p->BinSumm[p->NS2Indx[Ppmd8Context_OneState(p->MinContext)->Freq - 1]][ \ 112 | p->NS2BSIndx[Ppmd8_GetContext(p, p->MinContext->Suffix)->NumStats] + \ 113 | p->PrevSuccess + p->MinContext->Flags + ((p->RunLength >> 26) & 0x20)] 114 | 115 | CPpmd_See *Ppmd8_MakeEscFreq(CPpmd8 *p, unsigned numMasked, UInt32 *scale); 116 | 117 | 118 | /* ---------- Decode ---------- */ 119 | 120 | Bool Ppmd8_RangeDec_Init(CPpmd8 *p); 121 | #define Ppmd8_RangeDec_IsFinishedOK(p) ((p)->Code == 0) 122 | int Ppmd8_DecodeSymbol(CPpmd8 *p); /* returns: -1 as EndMarker, -2 as DataError */ 123 | 124 | 125 | /* ---------- Encode ---------- */ 126 | 127 | #define Ppmd8_RangeEnc_Init(p) { (p)->Low = 0; (p)->Range = 0xFFFFFFFF; } 128 | void Ppmd8_RangeEnc_FlushData(CPpmd8 *p); 129 | void Ppmd8_EncodeSymbol(CPpmd8 *p, int symbol); /* symbol = -1 means EndMarker */ 130 | 131 | EXTERN_C_END 132 | 133 | #endif 134 | -------------------------------------------------------------------------------- /Classes/LZMASDK/Ppmd8Dec.c: -------------------------------------------------------------------------------- 1 | /* Ppmd8Dec.c -- PPMdI Decoder 2 | 2010-04-16 : Igor Pavlov : Public domain 3 | This code is based on: 4 | PPMd var.I (2002): Dmitry Shkarin : Public domain 5 | Carryless rangecoder (1999): Dmitry Subbotin : Public domain */ 6 | 7 | #include "Ppmd8.h" 8 | 9 | #define kTop (1 << 24) 10 | #define kBot (1 << 15) 11 | 12 | Bool Ppmd8_RangeDec_Init(CPpmd8 *p) 13 | { 14 | unsigned i; 15 | p->Low = 0; 16 | p->Range = 0xFFFFFFFF; 17 | p->Code = 0; 18 | for (i = 0; i < 4; i++) 19 | p->Code = (p->Code << 8) | p->Stream.In->Read(p->Stream.In); 20 | return (p->Code < 0xFFFFFFFF); 21 | } 22 | 23 | static UInt32 RangeDec_GetThreshold(CPpmd8 *p, UInt32 total) 24 | { 25 | return p->Code / (p->Range /= total); 26 | } 27 | 28 | static void RangeDec_Decode(CPpmd8 *p, UInt32 start, UInt32 size) 29 | { 30 | start *= p->Range; 31 | p->Low += start; 32 | p->Code -= start; 33 | p->Range *= size; 34 | 35 | while ((p->Low ^ (p->Low + p->Range)) < kTop || 36 | (p->Range < kBot && ((p->Range = (0 - p->Low) & (kBot - 1)), 1))) 37 | { 38 | p->Code = (p->Code << 8) | p->Stream.In->Read(p->Stream.In); 39 | p->Range <<= 8; 40 | p->Low <<= 8; 41 | } 42 | } 43 | 44 | #define MASK(sym) ((signed char *)charMask)[sym] 45 | 46 | int Ppmd8_DecodeSymbol(CPpmd8 *p) 47 | { 48 | size_t charMask[256 / sizeof(size_t)]; 49 | if (p->MinContext->NumStats != 0) 50 | { 51 | CPpmd_State *s = Ppmd8_GetStats(p, p->MinContext); 52 | unsigned i; 53 | UInt32 count, hiCnt; 54 | if ((count = RangeDec_GetThreshold(p, p->MinContext->SummFreq)) < (hiCnt = s->Freq)) 55 | { 56 | Byte symbol; 57 | RangeDec_Decode(p, 0, s->Freq); 58 | p->FoundState = s; 59 | symbol = s->Symbol; 60 | Ppmd8_Update1_0(p); 61 | return symbol; 62 | } 63 | p->PrevSuccess = 0; 64 | i = p->MinContext->NumStats; 65 | do 66 | { 67 | if ((hiCnt += (++s)->Freq) > count) 68 | { 69 | Byte symbol; 70 | RangeDec_Decode(p, hiCnt - s->Freq, s->Freq); 71 | p->FoundState = s; 72 | symbol = s->Symbol; 73 | Ppmd8_Update1(p); 74 | return symbol; 75 | } 76 | } 77 | while (--i); 78 | if (count >= p->MinContext->SummFreq) 79 | return -2; 80 | RangeDec_Decode(p, hiCnt, p->MinContext->SummFreq - hiCnt); 81 | PPMD_SetAllBitsIn256Bytes(charMask); 82 | MASK(s->Symbol) = 0; 83 | i = p->MinContext->NumStats; 84 | do { MASK((--s)->Symbol) = 0; } while (--i); 85 | } 86 | else 87 | { 88 | UInt16 *prob = Ppmd8_GetBinSumm(p); 89 | if (((p->Code / (p->Range >>= 14)) < *prob)) 90 | { 91 | Byte symbol; 92 | RangeDec_Decode(p, 0, *prob); 93 | *prob = (UInt16)PPMD_UPDATE_PROB_0(*prob); 94 | symbol = (p->FoundState = Ppmd8Context_OneState(p->MinContext))->Symbol; 95 | Ppmd8_UpdateBin(p); 96 | return symbol; 97 | } 98 | RangeDec_Decode(p, *prob, (1 << 14) - *prob); 99 | *prob = (UInt16)PPMD_UPDATE_PROB_1(*prob); 100 | p->InitEsc = PPMD8_kExpEscape[*prob >> 10]; 101 | PPMD_SetAllBitsIn256Bytes(charMask); 102 | MASK(Ppmd8Context_OneState(p->MinContext)->Symbol) = 0; 103 | p->PrevSuccess = 0; 104 | } 105 | for (;;) 106 | { 107 | CPpmd_State *ps[256], *s; 108 | UInt32 freqSum, count, hiCnt; 109 | CPpmd_See *see; 110 | unsigned i, num, numMasked = p->MinContext->NumStats; 111 | do 112 | { 113 | p->OrderFall++; 114 | if (!p->MinContext->Suffix) 115 | return -1; 116 | p->MinContext = Ppmd8_GetContext(p, p->MinContext->Suffix); 117 | } 118 | while (p->MinContext->NumStats == numMasked); 119 | hiCnt = 0; 120 | s = Ppmd8_GetStats(p, p->MinContext); 121 | i = 0; 122 | num = p->MinContext->NumStats - numMasked; 123 | do 124 | { 125 | int k = (int)(MASK(s->Symbol)); 126 | hiCnt += (s->Freq & k); 127 | ps[i] = s++; 128 | i -= k; 129 | } 130 | while (i != num); 131 | 132 | see = Ppmd8_MakeEscFreq(p, numMasked, &freqSum); 133 | freqSum += hiCnt; 134 | count = RangeDec_GetThreshold(p, freqSum); 135 | 136 | if (count < hiCnt) 137 | { 138 | Byte symbol; 139 | CPpmd_State **pps = ps; 140 | for (hiCnt = 0; (hiCnt += (*pps)->Freq) <= count; pps++); 141 | s = *pps; 142 | RangeDec_Decode(p, hiCnt - s->Freq, s->Freq); 143 | Ppmd_See_Update(see); 144 | p->FoundState = s; 145 | symbol = s->Symbol; 146 | Ppmd8_Update2(p); 147 | return symbol; 148 | } 149 | if (count >= freqSum) 150 | return -2; 151 | RangeDec_Decode(p, hiCnt, freqSum - hiCnt); 152 | see->Summ = (UInt16)(see->Summ + freqSum); 153 | do { MASK(ps[--i]->Symbol) = 0; } while (i != 0); 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /Classes/LZMASDK/RotateDefs.h: -------------------------------------------------------------------------------- 1 | /* RotateDefs.h -- Rotate functions 2 | 2009-02-07 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __ROTATE_DEFS_H 5 | #define __ROTATE_DEFS_H 6 | 7 | #ifdef _MSC_VER 8 | 9 | #include 10 | #define rotlFixed(x, n) _rotl((x), (n)) 11 | #define rotrFixed(x, n) _rotr((x), (n)) 12 | 13 | #else 14 | 15 | #define rotlFixed(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) 16 | #define rotrFixed(x, n) (((x) >> (n)) | ((x) << (32 - (n)))) 17 | 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /Classes/LZMASDK/Util/7z/7zAlloc.c: -------------------------------------------------------------------------------- 1 | /* 7zAlloc.c -- Allocation functions 2 | 2010-10-29 : Igor Pavlov : Public domain */ 3 | 4 | #include "7zAlloc.h" 5 | 6 | /* #define _SZ_ALLOC_DEBUG */ 7 | /* use _SZ_ALLOC_DEBUG to debug alloc/free operations */ 8 | 9 | #ifdef _SZ_ALLOC_DEBUG 10 | 11 | #ifdef _WIN32 12 | #include 13 | #endif 14 | 15 | #include 16 | int g_allocCount = 0; 17 | int g_allocCountTemp = 0; 18 | 19 | #endif 20 | 21 | void *SzAlloc(void *p, size_t size) 22 | { 23 | p = p; 24 | if (size == 0) 25 | return 0; 26 | #ifdef _SZ_ALLOC_DEBUG 27 | fprintf(stderr, "\nAlloc %10d bytes; count = %10d", size, g_allocCount); 28 | g_allocCount++; 29 | #endif 30 | return malloc(size); 31 | } 32 | 33 | void SzFree(void *p, void *address) 34 | { 35 | p = p; 36 | #ifdef _SZ_ALLOC_DEBUG 37 | if (address != 0) 38 | { 39 | g_allocCount--; 40 | fprintf(stderr, "\nFree; count = %10d", g_allocCount); 41 | } 42 | #endif 43 | free(address); 44 | } 45 | 46 | void *SzAllocTemp(void *p, size_t size) 47 | { 48 | p = p; 49 | if (size == 0) 50 | return 0; 51 | #ifdef _SZ_ALLOC_DEBUG 52 | fprintf(stderr, "\nAlloc_temp %10d bytes; count = %10d", size, g_allocCountTemp); 53 | g_allocCountTemp++; 54 | #ifdef _WIN32 55 | return HeapAlloc(GetProcessHeap(), 0, size); 56 | #endif 57 | #endif 58 | return malloc(size); 59 | } 60 | 61 | void SzFreeTemp(void *p, void *address) 62 | { 63 | p = p; 64 | #ifdef _SZ_ALLOC_DEBUG 65 | if (address != 0) 66 | { 67 | g_allocCountTemp--; 68 | fprintf(stderr, "\nFree_temp; count = %10d", g_allocCountTemp); 69 | } 70 | #ifdef _WIN32 71 | HeapFree(GetProcessHeap(), 0, address); 72 | return; 73 | #endif 74 | #endif 75 | free(address); 76 | } 77 | -------------------------------------------------------------------------------- /Classes/LZMASDK/Util/7z/7zAlloc.h: -------------------------------------------------------------------------------- 1 | /* 7zAlloc.h -- Allocation functions 2 | 2010-10-29 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_ALLOC_H 5 | #define __7Z_ALLOC_H 6 | 7 | #include 8 | 9 | void *SzAlloc(void *p, size_t size); 10 | void SzFree(void *p, void *address); 11 | 12 | void *SzAllocTemp(void *p, size_t size); 13 | void SzFreeTemp(void *p, void *address); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /Classes/MovieControls/MovieControlsViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MovieControlsViewController.h 3 | // 4 | // Created by Moses DeJong on 4/8/09. 5 | // 6 | // License terms defined in License.txt. 7 | 8 | #import 9 | #import 10 | 11 | @class MPVolumeView; 12 | 13 | // The 4 state notifications supported by movie controls. 14 | // The play state notification is delivered when changing 15 | // from the pause state to the playing state. The pause 16 | // state notification is delivered when changing from 17 | // the playing state to the pause state. The done notification 18 | // is delivered when the Done button is pressed. The rewind 19 | // notification indicates that the movie should be started 20 | // over at the begining. 21 | 22 | #define MovieControlsDoneNotification @"MovieControlsDoneNotification" 23 | #define MovieControlsPlayNotification @"MovieControlsPlayNotification" 24 | #define MovieControlsPauseNotification @"MovieControlsPauseNotification" 25 | #define MovieControlsRewindNotification @"MovieControlsRewindNotification" 26 | #define MovieControlsFastForwardNotification @"MovieControlsFastForwardNotification" 27 | 28 | @interface MovieControlsViewController : UIViewController { 29 | #if __has_feature(objc_arc) 30 | __unsafe_unretained 31 | #else 32 | #endif // objc_arc 33 | UIWindow *m_mainWindow; 34 | 35 | // All elements that float over self.view are contained in this subview 36 | UIView *m_overlaySubview; 37 | 38 | // Elements in nav subview at top of window 39 | 40 | UIBarButtonItem *m_doneButton; 41 | 42 | // Elements in floating "controls" subview 43 | 44 | UIView *controlsSubview; 45 | UIImageView *controlsImageView; 46 | UIImage *controlsBackgroundImage; 47 | 48 | UIButton *playPauseButton; 49 | UIButton *m_rewindButton; 50 | UIButton *m_fastForwardButton; 51 | UIImage *playImage; 52 | UIImage *pauseImage; 53 | UIImage *m_rewindImage; 54 | UIImage *m_fastForwardImage; 55 | 56 | UIView *volumeSubview; 57 | MPVolumeView *volumeView; 58 | 59 | NSTimer *hideControlsTimer; 60 | NSTimer *hideControlsFromPlayTimer; 61 | 62 | CFAbsoluteTime lastEventTime; 63 | 64 | CGRect portraitFrame; 65 | CATransform3D portraitTransform; 66 | 67 | BOOL controlsVisable; 68 | BOOL isPlaying; 69 | BOOL isPaused; 70 | BOOL touchBeganOutsideControls; 71 | BOOL showVolumeControls; 72 | BOOL portraitMode; 73 | } 74 | 75 | @property (nonatomic, assign) UIWindow *mainWindow; 76 | @property (nonatomic, retain) UIView *overlaySubview; 77 | 78 | @property (nonatomic, retain) UIBarButtonItem *doneButton; 79 | 80 | @property (nonatomic, retain) UIView *controlsSubview; 81 | @property (nonatomic, retain) UIImageView *controlsImageView; 82 | @property (nonatomic, retain) UIImage *controlsBackgroundImage; 83 | 84 | @property (nonatomic, retain) UIView *volumeSubview; 85 | @property (nonatomic, retain) UIButton *playPauseButton; 86 | @property (nonatomic, retain) UIButton *rewindButton; 87 | @property (nonatomic, retain) UIButton *fastForwardButton; 88 | @property (nonatomic, retain) UIImage *playImage; 89 | @property (nonatomic, retain) UIImage *pauseImage; 90 | @property (nonatomic, retain) UIImage *rewindImage; 91 | @property (nonatomic, retain) UIImage *fastForwardImage; 92 | 93 | @property (nonatomic, retain) MPVolumeView *volumeView; 94 | 95 | @property (nonatomic, retain) NSTimer *hideControlsTimer; 96 | @property (nonatomic, retain) NSTimer *hideControlsFromPlayTimer; 97 | 98 | @property (nonatomic, assign) BOOL showVolumeControls; 99 | @property (nonatomic, assign) BOOL portraitMode; 100 | 101 | // static ctor : pass view that controls will appear over 102 | + (MovieControlsViewController*) movieControlsViewController:(UIView*)overView; 103 | 104 | - (void) pressPlayPause:(id)sender; 105 | - (void) pressDone:(id)sender; 106 | - (void) pressOutsideControls:(id)sender; 107 | - (void) pressRewind:(id)sender; 108 | 109 | - (void) showControls; 110 | - (void) hideControls; 111 | 112 | // FIXME: make these private 113 | - (void)loadViewImpl; 114 | 115 | - (void) setMainWindow:(UIWindow*)mainWindow; 116 | 117 | - (void) touchesAnyEvent; 118 | 119 | - (void) disableUserInteraction; 120 | 121 | - (void) enableUserInteraction; 122 | 123 | @end 124 | 125 | -------------------------------------------------------------------------------- /Classes/MovieControls/MovieTransportBackground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/MovieControls/MovieTransportBackground.png -------------------------------------------------------------------------------- /Classes/MovieControls/VolumeLeftTall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/MovieControls/VolumeLeftTall.png -------------------------------------------------------------------------------- /Classes/MovieControls/VolumeRightTall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/MovieControls/VolumeRightTall.png -------------------------------------------------------------------------------- /Classes/MovieControls/nexttrack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/MovieControls/nexttrack.png -------------------------------------------------------------------------------- /Classes/MovieControls/pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/MovieControls/pause.png -------------------------------------------------------------------------------- /Classes/MovieControls/play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/MovieControls/play.png -------------------------------------------------------------------------------- /Classes/MovieControls/prevtrack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/MovieControls/prevtrack.png -------------------------------------------------------------------------------- /Classes/MovieControlsAdaptor.h: -------------------------------------------------------------------------------- 1 | // 2 | // MovieControlsAdaptor.h 3 | // 4 | // Created by Moses DeJong on 12/17/10. 5 | // 6 | // License terms defined in License.txt. 7 | // 8 | // This class provides a default implementation that connects an AVAnimatorViewController 9 | // and a MovieControlsViewController. The movie controller can then control the function 10 | // of the animator via notifications. This is a util class that keeps most of the notification 11 | // logic out of the app delegate. 12 | 13 | #import 14 | 15 | @class AVAnimatorView; 16 | @class MovieControlsViewController; 17 | 18 | @interface MovieControlsAdaptor : NSObject { 19 | AVAnimatorView *m_animatorView; 20 | MovieControlsViewController *m_movieControlsViewController; 21 | } 22 | 23 | @property (nonatomic, retain) AVAnimatorView *animatorView; 24 | @property (nonatomic, retain) MovieControlsViewController *movieControlsViewController; 25 | 26 | // static ctor 27 | 28 | + (MovieControlsAdaptor*) movieControlsAdaptor; 29 | 30 | - (void) startAnimator; 31 | 32 | - (void) stopAnimator; 33 | 34 | @end 35 | 36 | -------------------------------------------------------------------------------- /Classes/QTFileParserAppAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // QTFileParserAppAppDelegate.h 3 | // 4 | // Created by Moses DeJong on 12/17/10. 5 | // 6 | // 7 | // License terms defined in License.txt. 8 | 9 | #import 10 | 11 | @class QTFileParserAppViewController; 12 | @class AVAnimatorView; 13 | @class MovieControlsViewController; 14 | @class MovieControlsAdaptor; 15 | @class AVAnimatorLayer; 16 | 17 | @interface QTFileParserAppAppDelegate : NSObject { 18 | UIWindow *m_window; 19 | 20 | QTFileParserAppViewController *m_viewController; 21 | 22 | MovieControlsViewController *m_movieControlsViewController; 23 | 24 | AVAnimatorView *m_animatorView; 25 | 26 | MovieControlsAdaptor *m_movieControlsAdaptor; 27 | 28 | // Used in a couple of examples. 29 | UIView *m_plainView; 30 | AVAnimatorLayer *m_animatorLayer; 31 | } 32 | 33 | @property (nonatomic, retain) IBOutlet UIWindow *window; 34 | 35 | @property (nonatomic, retain) IBOutlet QTFileParserAppViewController *viewController; 36 | 37 | @property (nonatomic, retain) MovieControlsViewController *movieControlsViewController; 38 | 39 | @property (nonatomic, retain) AVAnimatorView *animatorView; 40 | 41 | @property (nonatomic, retain) MovieControlsAdaptor *movieControlsAdaptor; 42 | 43 | @property (nonatomic, retain) UIView *plainView; 44 | 45 | @property (nonatomic, retain) AVAnimatorLayer *animatorLayer; 46 | 47 | - (void) stopAnimator; 48 | 49 | - (void) loadIndexedExample:(NSUInteger)index 50 | fps:(NSInteger)fps; 51 | 52 | @end 53 | 54 | -------------------------------------------------------------------------------- /Classes/QTFileParserAppViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // QTFileParserAppViewController.h 3 | // 4 | // Created by Moses DeJong on 12/17/10. 5 | // 6 | // License terms defined in License.txt. 7 | 8 | #import 9 | 10 | @interface QTFileParserAppViewController : UIViewController { 11 | UISegmentedControl *m_segControl; 12 | UIScrollView *m_scrollView; 13 | } 14 | 15 | @property (nonatomic, retain) IBOutlet UISegmentedControl *segControl; 16 | @property (nonatomic, retain) IBOutlet UIScrollView *scrollView; 17 | 18 | - (IBAction) runExampleOne:(id) sender; 19 | 20 | - (IBAction) runExampleTwo:(id) sender; 21 | 22 | - (IBAction) runExampleThree:(id) sender; 23 | 24 | - (IBAction) runExampleFour:(id) sender; 25 | 26 | - (IBAction) runExampleFive:(id) sender; 27 | 28 | - (IBAction) runExampleSix:(id) sender; 29 | 30 | - (IBAction) runExampleSeven:(id) sender; 31 | 32 | - (IBAction) runExampleEight:(id) sender; 33 | 34 | - (IBAction) runExampleNine:(id) sender; 35 | 36 | - (IBAction) runExampleTen:(id) sender; 37 | 38 | - (IBAction) runExampleEleven:(id) sender; 39 | 40 | - (IBAction) runExampleTwelve:(id) sender; 41 | 42 | - (IBAction) runExampleThirteen:(id) sender; 43 | 44 | - (IBAction) runExampleFourteen:(id) sender; 45 | 46 | - (IBAction) runExampleFifteen:(id) sender; 47 | 48 | - (IBAction) runExampleSixteen:(id) sender; 49 | 50 | - (IBAction) runExampleSeventeen:(id) sender; 51 | 52 | - (IBAction) runExampleEighteen:(id) sender; 53 | 54 | - (IBAction) runExampleNineteen:(id) sender; 55 | 56 | - (IBAction) runExampleTwenty:(id) sender; 57 | 58 | @end 59 | 60 | -------------------------------------------------------------------------------- /Classes/Tests/124x124_black_blue_h264.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/124x124_black_blue_h264.mov -------------------------------------------------------------------------------- /Classes/Tests/128x128_black_blue_h264.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/128x128_black_blue_h264.mov -------------------------------------------------------------------------------- /Classes/Tests/129x128_black_blue_h264.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/129x128_black_blue_h264.mov -------------------------------------------------------------------------------- /Classes/Tests/132x128_black_blue_h264.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/132x128_black_blue_h264.mov -------------------------------------------------------------------------------- /Classes/Tests/192x128_black_blue_h264.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/192x128_black_blue_h264.mov -------------------------------------------------------------------------------- /Classes/Tests/1x1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/1x1.gif -------------------------------------------------------------------------------- /Classes/Tests/240x160_black_blue_h264.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/240x160_black_blue_h264.mov -------------------------------------------------------------------------------- /Classes/Tests/2x2_16BPP_1FPS_3Frames_nop.mvid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/2x2_16BPP_1FPS_3Frames_nop.mvid -------------------------------------------------------------------------------- /Classes/Tests/2x2_alpha_reveal_32BPP.apng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/2x2_alpha_reveal_32BPP.apng -------------------------------------------------------------------------------- /Classes/Tests/2x2_alpha_reveal_palette.apng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/2x2_alpha_reveal_palette.apng -------------------------------------------------------------------------------- /Classes/Tests/2x2_black_blue_16BPP.mvid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/2x2_black_blue_16BPP.mvid -------------------------------------------------------------------------------- /Classes/Tests/2x2_black_blue_16BPP.mvid.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/2x2_black_blue_16BPP.mvid.7z -------------------------------------------------------------------------------- /Classes/Tests/2x2_black_blue_1LD_opt.apng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/2x2_black_blue_1LD_opt.apng -------------------------------------------------------------------------------- /Classes/Tests/2x2_black_blue_24BPP.apng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/2x2_black_blue_24BPP.apng -------------------------------------------------------------------------------- /Classes/Tests/2x2_black_blue_24BPP.mvid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/2x2_black_blue_24BPP.mvid -------------------------------------------------------------------------------- /Classes/Tests/2x2_black_blue_24BPP_opt_nc.apng.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/2x2_black_blue_24BPP_opt_nc.apng.7z -------------------------------------------------------------------------------- /Classes/Tests/2x2_black_blue_32BPP.mvid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/2x2_black_blue_32BPP.mvid -------------------------------------------------------------------------------- /Classes/Tests/2x2_nop.apng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/2x2_nop.apng -------------------------------------------------------------------------------- /Classes/Tests/32x32_black_blue_h264.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/32x32_black_blue_h264.mov -------------------------------------------------------------------------------- /Classes/Tests/3x3_bwd_ANI_16BPP.mvid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/3x3_bwd_ANI_16BPP.mvid -------------------------------------------------------------------------------- /Classes/Tests/3x3_bwd_ANI_24BPP.mvid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/3x3_bwd_ANI_24BPP.mvid -------------------------------------------------------------------------------- /Classes/Tests/480x320_black_blue_16BPP.mvid.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/480x320_black_blue_16BPP.mvid.7z -------------------------------------------------------------------------------- /Classes/Tests/480x320_black_blue_1LD_16BPP.mvid.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/480x320_black_blue_1LD_16BPP.mvid.7z -------------------------------------------------------------------------------- /Classes/Tests/480x320_black_blue_1LD_24BPP.mvid.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/480x320_black_blue_1LD_24BPP.mvid.7z -------------------------------------------------------------------------------- /Classes/Tests/64x64_nop_3frames_h264.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/64x64_nop_3frames_h264.mov -------------------------------------------------------------------------------- /Classes/Tests/AVAnimatorOpenGLViewTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // AVAnimatorOpenGLViewTests 3 | // 4 | // Created by Moses DeJong on 8/19/13. 5 | // 6 | // License terms defined in License.txt. 7 | 8 | #import "RegressionTests.h" 9 | 10 | #import "AVAnimatorOpenGLView.h" 11 | #include "AVAnimatorOpenGLViewPrivate.h" 12 | 13 | #import "AVAnimatorMedia.h" 14 | #import "AVAnimatorMediaPrivate.h" 15 | 16 | #import "AVAppResourceLoader.h" 17 | 18 | #import "AVAssetFrameDecoder.h" 19 | 20 | #import "AVFileUtil.h" 21 | 22 | @interface AVAnimatorOpenGLViewTests : NSObject {} 23 | @end 24 | 25 | // The methods named test* will be automatically invoked by the RegressionTests harness. 26 | 27 | @implementation AVAnimatorOpenGLViewTests 28 | 29 | // This test checks the implementation of the attachMedia method 30 | // in the AVAnimatorOpenGLViewTests class. Only a single media item can be 31 | // attached to a rendering view at a time, and only an attached 32 | // media element has resources like allocated framebuffers. 33 | 34 | + (void) testAttachDetachMedia 35 | { 36 | id appDelegate = [[UIApplication sharedApplication] delegate]; 37 | UIWindow *window = [appDelegate window]; 38 | NSAssert(window, @"window"); 39 | 40 | NSString *resourceName = @"32x32_black_blue_h264.mov"; 41 | 42 | NSString *resPath; 43 | resPath = [AVFileUtil getResourcePath:resourceName]; 44 | 45 | // Create a plain AVAnimatorView without a movie controls and display 46 | // in portrait mode. This setup involves no containing views and 47 | // has no transforms applied to the AVAnimatorView. 48 | 49 | CGRect frame = CGRectMake(0, 0, 200, 200); 50 | AVAnimatorOpenGLView *animatorView = [AVAnimatorOpenGLView aVAnimatorOpenGLViewWithFrame:frame]; 51 | 52 | [animatorView attachMedia:nil]; 53 | 54 | NSAssert(animatorView.media == nil, @"media"); 55 | 56 | // Create Media object and link it to the animatorView 57 | 58 | AVAnimatorMedia *media = [AVAnimatorMedia aVAnimatorMedia]; 59 | 60 | NSAssert(media, @"media"); 61 | NSAssert(media.currentFrame == -1, @"currentFrame"); 62 | 63 | // Create loader and frame decoder that will read from h.264 app asset 64 | 65 | AVAppResourceLoader *resLoader = [AVAppResourceLoader aVAppResourceLoader]; 66 | resLoader.movieFilename = resPath; 67 | 68 | AVAssetFrameDecoder *frameDecoder = [AVAssetFrameDecoder aVAssetFrameDecoder]; 69 | frameDecoder.produceCoreVideoPixelBuffers = TRUE; 70 | 71 | media.resourceLoader = resLoader; 72 | media.frameDecoder = frameDecoder; 73 | 74 | [window addSubview:animatorView]; 75 | 76 | [media prepareToAnimate]; 77 | 78 | BOOL worked = [RegressionTests waitUntilTrue:media 79 | selector:@selector(isReadyToAnimate) 80 | maxWaitTime:10.0]; 81 | NSAssert(worked, @"worked"); 82 | 83 | // The media was not attached on load, so currentFrame is still -1 84 | 85 | NSAssert(media.currentFrame == -1, @"currentFrame"); 86 | 87 | // The media is now ready, attaching will display the first keyframe. 88 | 89 | [animatorView attachMedia:media]; 90 | 91 | NSAssert(animatorView.media == media, @"media"); 92 | 93 | NSAssert(media.currentFrame == 0, @"currentFrame"); 94 | 95 | [animatorView attachMedia:nil]; 96 | 97 | NSAssert(animatorView.media == nil, @"media"); 98 | 99 | // Detach from renderer implicity invoked stopAnimator 100 | 101 | NSAssert(media.currentFrame == -1, @"currentFrame"); 102 | 103 | // FIXME: should work this way 104 | 105 | // Note that detaching from the renderer made a copy of the CoreVideo pixel 106 | // buffer, but it is not the one delivered by mediaserverd. Instead, that 107 | // data was copied into a duplicate CoreVideo pixel buffer so that the 108 | // copy backed by an OpenGL texture is no longer used. 109 | 110 | return; 111 | } 112 | 113 | @end 114 | -------------------------------------------------------------------------------- /Classes/Tests/AVOfflineComposition2xScale.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ABOUT 6 | Explicitly set CompScale to 2x, output bitmap at 512 x 512 7 | Source 8 | AVOfflineComposition2xScale.plist 9 | Destination 10 | AVOfflineComposition2xScale.mvid 11 | CompDurationSeconds 12 | 10 13 | CompFramesPerSecond 14 | 10 15 | CompWidth 16 | 256 17 | CompHeight 18 | 256 19 | CompScale 20 | 2 21 | CompBackgroundColor 22 | #FFFFFF 23 | CompClips 24 | 25 | 26 | ClipSource 27 | Grayscale256x256 28 | ClipType 29 | image 30 | ClipX 31 | 0 32 | ClipY 33 | 0 34 | ClipWidth 35 | 256 36 | ClipHeight 37 | 256 38 | ClipStartSeconds 39 | 0 40 | ClipEndSeconds 41 | 10 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Classes/Tests/AVOfflineComposition32x32BlackBlueTest.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ABOUT 6 | H264 video, 32x32, 2 frames at 15FPS 7 | Source 8 | AVOfflineComposition32x32BlackBlueTest.plist 9 | Destination 10 | AVOfflineComposition32x32BlackBlueTest.mvid 11 | CompDurationSeconds 12 | 0.13 13 | CompFramesPerSecond 14 | 15 15 | CompWidth 16 | 32 17 | CompHeight 18 | 32 19 | CompClips 20 | 21 | 22 | ClipSource 23 | 32x32_black_blue_h264.mov 24 | ClipType 25 | h264 26 | ClipX 27 | 0 28 | ClipY 29 | 0 30 | ClipWidth 31 | 32 32 | ClipHeight 33 | 32 34 | ClipStartSeconds 35 | 0 36 | ClipEndSeconds 37 | 0.13 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Classes/Tests/AVOfflineCompositionManyTextFields.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ABOUT 6 | Many images to test text rendering 7 | Source 8 | AVOfflineCompositionManyTextFields.plist 9 | Destination 10 | AVOfflineCompositionManyTextFields.mvid 11 | CompDurationSeconds 12 | 10 13 | CompFramesPerSecond 14 | 30 15 | CompWidth 16 | 256 17 | CompHeight 18 | 256 19 | CompBackgroundColor 20 | #FFFFFF 21 | CompClips 22 | 23 | 24 | ClipText 25 | text1 26 | ClipType 27 | text 28 | ClipX 29 | 0 30 | ClipY 31 | 0 32 | ClipWidth 33 | 50 34 | ClipHeight 35 | 50 36 | ClipStartSeconds 37 | 0 38 | ClipEndSeconds 39 | 10 40 | 41 | 42 | ClipText 43 | text2 44 | ClipType 45 | text 46 | ClipX 47 | 0 48 | ClipY 49 | 50 50 | ClipWidth 51 | 50 52 | ClipHeight 53 | 50 54 | ClipStartSeconds 55 | 0 56 | ClipEndSeconds 57 | 10 58 | 59 | 60 | ClipText 61 | text3 62 | ClipType 63 | text 64 | ClipX 65 | 0 66 | ClipY 67 | 100 68 | ClipWidth 69 | 50 70 | ClipHeight 71 | 50 72 | ClipStartSeconds 73 | 0 74 | ClipEndSeconds 75 | 10 76 | 77 | 78 | ClipText 79 | text4 80 | ClipType 81 | text 82 | ClipX 83 | 0 84 | ClipY 85 | 150 86 | ClipWidth 87 | 50 88 | ClipHeight 89 | 50 90 | ClipStartSeconds 91 | 0 92 | ClipEndSeconds 93 | 10 94 | 95 | 96 | ClipText 97 | text5 98 | ClipType 99 | text 100 | ClipX 101 | 0 102 | ClipY 103 | 200 104 | ClipWidth 105 | 50 106 | ClipHeight 107 | 50 108 | ClipStartSeconds 109 | 0 110 | ClipEndSeconds 111 | 10 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /Classes/Tests/AVOfflineCompositionTwoFrameBlackBlueMovieTest.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ABOUT 6 | 2 frames. First is black. Second is blue. 7 | Source 8 | AVOfflineCompositionTwoFrameBlackBlueMovieTest.plist 9 | Destination 10 | AVOfflineCompositionTwoFrameBlackBlueMovieTest.mvid 11 | CompDurationSeconds 12 | 2 13 | CompFramesPerSecond 14 | 1 15 | CompWidth 16 | 2 17 | CompHeight 18 | 2 19 | CompClips 20 | 21 | 22 | ClipSource 23 | 2x2_black_blue_16BPP.mvid 24 | ClipType 25 | mvid 26 | ClipX 27 | 0 28 | ClipY 29 | 0 30 | ClipWidth 31 | 2 32 | ClipHeight 33 | 2 34 | ClipStartSeconds 35 | 0 36 | ClipEndSeconds 37 | 2 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Classes/Tests/AVOfflineCompositionTwoFrameBlackBlueScaleMovieTest.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ABOUT 6 | 2 frames. First is black. Second is blue. Clip framerate is scaled to 2x normal duration. Total of 4 comp frames. 7 | Source 8 | AVOfflineCompositionTwoFrameBlackBlueScaleMovieTest.plist 9 | Destination 10 | AVOfflineCompositionTwoFrameBlackBlueScaleMovieTest.mvid 11 | CompDurationSeconds 12 | 4 13 | CompFramesPerSecond 14 | 1 15 | CompWidth 16 | 2 17 | CompHeight 18 | 2 19 | CompClips 20 | 21 | 22 | ClipSource 23 | 2x2_black_blue_16BPP.mvid 24 | ClipType 25 | mvid 26 | ClipX 27 | 0 28 | ClipY 29 | 0 30 | ClipWidth 31 | 2 32 | ClipHeight 33 | 2 34 | ClipStartSeconds 35 | 0 36 | ClipEndSeconds 37 | 4 38 | ClipScaleFramePerSecond 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Classes/Tests/AVOfflineCompositionTwoFrameBlueBackgroundTest.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ABOUT 6 | Blue background, 2 frames 7 | Source 8 | AVOfflineCompositionTwoFrameBlueBackgroundTest.plist 9 | Destination 10 | AVOfflineCompositionTwoFrameBlueBackgroundTest.mvid 11 | CompDurationSeconds 12 | 1 13 | CompFramesPerSecond 14 | 2 15 | CompBackgroundColor 16 | #0000FF 17 | CompWidth 18 | 2 19 | CompHeight 20 | 2 21 | 22 | 23 | -------------------------------------------------------------------------------- /Classes/Tests/AVOfflineCompositionTwoFrameStaticImageAndTextTest.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ABOUT 6 | 2 frames. Static background image with image in lower right corner 7 | Source 8 | AVOfflineCompositionTwoFrameStaticImageAndTextTest.plist 9 | Destination 10 | AVOfflineCompositionTwoFrameStaticImageAndTextTest.mvid 11 | CompDurationSeconds 12 | 2 13 | CompFramesPerSecond 14 | 1 15 | CompWidth 16 | 256 17 | CompHeight 18 | 256 19 | Font 20 | AmericanTypewriter 21 | FontSize 22 | 14 23 | FontColor 24 | #00FF00 25 | CompClips 26 | 27 | 28 | ClipSource 29 | Grayscale256x256 30 | ClipType 31 | image 32 | ClipX 33 | 0 34 | ClipY 35 | 0 36 | ClipWidth 37 | 256 38 | ClipHeight 39 | 256 40 | ClipStartSeconds 41 | 0 42 | ClipEndSeconds 43 | 2 44 | 45 | 46 | ClipText 47 | Test String 48 | ClipType 49 | text 50 | ClipX 51 | 25 52 | ClipY 53 | 25 54 | ClipWidth 55 | 100 56 | ClipHeight 57 | 50 58 | ClipStartSeconds 59 | 1 60 | ClipEndSeconds 61 | 2 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /Classes/Tests/AVOfflineCompositionTwoFrameStaticImageAndTwoTextTest.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ABOUT 6 | 2 frames. image with 2 text boxes with different fonts and font colors 7 | Source 8 | AVOfflineCompositionTwoFrameStaticImageAndTwoTextTest.plist 9 | Destination 10 | AVOfflineCompositionTwoFrameStaticImageAndTwoTextTest.mvid 11 | CompDurationSeconds 12 | 2 13 | CompFramesPerSecond 14 | 1 15 | CompWidth 16 | 256 17 | CompHeight 18 | 256 19 | FontColor 20 | #0000FF 21 | CompClips 22 | 23 | 24 | ClipSource 25 | Grayscale256x256 26 | ClipType 27 | image 28 | ClipX 29 | 0 30 | ClipY 31 | 0 32 | ClipWidth 33 | 256 34 | ClipHeight 35 | 256 36 | ClipStartSeconds 37 | 0 38 | ClipEndSeconds 39 | 2 40 | 41 | 42 | ClipText 43 | DefaultFont 44 | ClipType 45 | text 46 | ClipX 47 | 50 48 | ClipY 49 | 40 50 | ClipWidth 51 | 100 52 | ClipHeight 53 | 50 54 | ClipStartSeconds 55 | 1 56 | ClipEndSeconds 57 | 2 58 | 59 | 60 | ClipText 61 | AnotherFont 62 | ClipType 63 | text 64 | ClipX 65 | 50 66 | ClipY 67 | 90 68 | ClipWidth 69 | 100 70 | ClipHeight 71 | 50 72 | ClipStartSeconds 73 | 1 74 | ClipEndSeconds 75 | 2 76 | FontSize 77 | 18 78 | Font 79 | CourierNewPS-BoldMT 80 | FontColor 81 | #00FFFF 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /Classes/Tests/AVOfflineCompositionTwoFrameStaticImageTest.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ABOUT 6 | 2 frames. Static background image with small image in upper left corner 7 | Source 8 | AVOfflineCompositionTwoFrameStaticImageTest.plist 9 | Destination 10 | AVOfflineCompositionTwoFrameStaticImageTest.mvid 11 | CompDurationSeconds 12 | 2 13 | CompFramesPerSecond 14 | 1 15 | CompWidth 16 | 256 17 | CompHeight 18 | 256 19 | CompClips 20 | 21 | 22 | ClipSource 23 | Grayscale256x256 24 | ClipType 25 | image 26 | ClipX 27 | 0 28 | ClipY 29 | 0 30 | ClipWidth 31 | 256 32 | ClipHeight 33 | 256 34 | ClipStartSeconds 35 | 0 36 | ClipEndSeconds 37 | 2 38 | 39 | 40 | ClipSource 41 | smiley.png 42 | ClipType 43 | image 44 | ClipX 45 | 10 46 | ClipY 47 | 10 48 | ClipWidth 49 | 20 50 | ClipHeight 51 | 20 52 | ClipStartSeconds 53 | 1 54 | ClipEndSeconds 55 | 2 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /Classes/Tests/AlphaGhost_alpha_CRF_30_24BPP.m4v: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/AlphaGhost_alpha_CRF_30_24BPP.m4v -------------------------------------------------------------------------------- /Classes/Tests/AlphaGhost_rgb_CRF_30_24BPP.m4v: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/AlphaGhost_rgb_CRF_30_24BPP.m4v -------------------------------------------------------------------------------- /Classes/Tests/Colorbands_sRGB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/Colorbands_sRGB.png -------------------------------------------------------------------------------- /Classes/Tests/ExplosionAdjusted_alpha_CRF_30_24BPP.m4v: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/ExplosionAdjusted_alpha_CRF_30_24BPP.m4v -------------------------------------------------------------------------------- /Classes/Tests/ExplosionAdjusted_rgb_CRF_30_24BPP.m4v: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/ExplosionAdjusted_rgb_CRF_30_24BPP.m4v -------------------------------------------------------------------------------- /Classes/Tests/Grayscale256x256.m4v: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/Grayscale256x256.m4v -------------------------------------------------------------------------------- /Classes/Tests/Grayscale256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/Grayscale256x256.png -------------------------------------------------------------------------------- /Classes/Tests/H264AlphaPlayerTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // H264AlphaPlayerTests.m 3 | // 4 | // Created by Mo DeJong on 3/16/16. 5 | 6 | #import 7 | 8 | #import "RegressionTests.h" 9 | 10 | #import "AVAnimatorH264AlphaPlayer.h" 11 | 12 | @interface AVAnimatorH264AlphaPlayer () 13 | 14 | + (uint32_t) timeIntervalToFrameOffset:(CFTimeInterval)elapsed 15 | fps:(CFTimeInterval)fps; 16 | 17 | @end 18 | 19 | @interface H264AlphaPlayerTests : NSObject 20 | 21 | @end 22 | 23 | @implementation H264AlphaPlayerTests 24 | 25 | // Test measurement of frame offset based on elapsed time 26 | 27 | - (void)testFrameTime1 { 28 | CFTimeInterval elapsed = 0.0; 29 | CFTimeInterval fps = 2.0; 30 | uint32_t frameOffset; 31 | 32 | frameOffset = [AVAnimatorH264AlphaPlayer timeIntervalToFrameOffset:elapsed fps:fps]; 33 | 34 | NSAssert(frameOffset == 1, @""); 35 | } 36 | 37 | - (void)testFrameTime2 { 38 | CFTimeInterval elapsed = 0.1; 39 | CFTimeInterval fps = 2.0; 40 | uint32_t frameOffset; 41 | 42 | frameOffset = [AVAnimatorH264AlphaPlayer timeIntervalToFrameOffset:elapsed fps:fps]; 43 | 44 | NSAssert(frameOffset == 1, @""); 45 | } 46 | 47 | - (void)testFrameTime3 { 48 | CFTimeInterval elapsed = 0.49; 49 | CFTimeInterval fps = 2.0; 50 | uint32_t frameOffset; 51 | 52 | frameOffset = [AVAnimatorH264AlphaPlayer timeIntervalToFrameOffset:elapsed fps:fps]; 53 | 54 | NSAssert(frameOffset == 1, @""); 55 | } 56 | 57 | - (void)testFrameTime4 { 58 | CFTimeInterval elapsed = 0.50; 59 | CFTimeInterval fps = 2.0; 60 | uint32_t frameOffset; 61 | 62 | frameOffset = [AVAnimatorH264AlphaPlayer timeIntervalToFrameOffset:elapsed fps:fps]; 63 | 64 | NSAssert(frameOffset == 1, @""); 65 | } 66 | 67 | - (void)testFrameTime5 { 68 | CFTimeInterval elapsed = 0.51; 69 | CFTimeInterval fps = 2.0; 70 | uint32_t frameOffset; 71 | 72 | frameOffset = [AVAnimatorH264AlphaPlayer timeIntervalToFrameOffset:elapsed fps:fps]; 73 | 74 | NSAssert(frameOffset == 1, @""); 75 | } 76 | 77 | - (void)testFrameTime6 { 78 | CFTimeInterval elapsed = 0.6; 79 | CFTimeInterval fps = 2.0; 80 | uint32_t frameOffset; 81 | 82 | frameOffset = [AVAnimatorH264AlphaPlayer timeIntervalToFrameOffset:elapsed fps:fps]; 83 | NSAssert(frameOffset == 1, @""); 84 | } 85 | 86 | // Rounds up to frame 2 at this point 87 | 88 | - (void)testFrameTime7 { 89 | CFTimeInterval elapsed = 0.75; 90 | CFTimeInterval fps = 2.0; 91 | uint32_t frameOffset; 92 | 93 | frameOffset = [AVAnimatorH264AlphaPlayer timeIntervalToFrameOffset:elapsed fps:fps]; 94 | NSAssert(frameOffset == 2, @""); 95 | } 96 | 97 | @end 98 | -------------------------------------------------------------------------------- /Classes/Tests/RGB3Frame_mix.m4v: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/RGB3Frame_mix.m4v -------------------------------------------------------------------------------- /Classes/Tests/RegressionTests.h: -------------------------------------------------------------------------------- 1 | // Created by Moses DeJong on 11/8/09. 2 | // 3 | // License terms defined in License.txt. 4 | 5 | #if !defined(REGRESSION_TESTS) 6 | #error "RegressionTests.h should not be included unless REGRESSION_TESTS is defined" 7 | #endif // REGRESSION_TESTS 8 | 9 | #import 10 | 11 | @interface RegressionTests : NSObject { 12 | } 13 | 14 | // Entry point for app self test, iterate over all classes named "*Test" and 15 | // invoke test methods named "test*". 16 | 17 | + (void) testApp; 18 | 19 | + (void) cleanupAfterTest; 20 | 21 | // Wait inside the event loop for a period of time indicated in seconds 22 | 23 | + (void) waitFor:(NSTimeInterval)maxWaitTime; 24 | 25 | // Invoke the indicated selector for the object until it returns TRUE. 26 | // The maxWaitTime indicates the maximum number of seconds to wait. 27 | // Each time the selector returns FALSE, the event loop will be entered 28 | // for 1 second so that events can be processed. This method returns 29 | // TRUE if the selector returned TRUE before maxWaitTime is reached. 30 | 31 | + (BOOL) waitUntilTrue:(id)object 32 | selector:(SEL)selector 33 | maxWaitTime:(NSTimeInterval)maxWaitTime; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Classes/Tests/Silence3S.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/Silence3S.wav -------------------------------------------------------------------------------- /Classes/Tests/ViewLoadTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewLoadTests.m 3 | // 4 | // Created by Moses DeJong on 11/8/09. 5 | // 6 | // License terms defined in License.txt. 7 | 8 | #import "RegressionTests.h" 9 | 10 | @interface ViewLoadTests : NSObject {} 11 | + (void) testApp; 12 | @end 13 | 14 | @interface ViewLoadTests_SubviewController1 : UIViewController { 15 | @public 16 | BOOL viewDidLoadFlag; 17 | } 18 | + (ViewLoadTests_SubviewController1*) subviewController1; 19 | @end 20 | 21 | 22 | @implementation ViewLoadTests 23 | 24 | // Define a method named "testApp", it will be invoked dynamically from 25 | // RegressionTest.m at runtime 26 | 27 | + (void) testApp { 28 | id appDelegate = [[UIApplication sharedApplication] delegate]; 29 | UIWindow *window = [appDelegate window]; 30 | NSAssert(window, @"window"); 31 | 32 | // Create a UIView and add it as a subview of the main app window 33 | 34 | ViewLoadTests_SubviewController1 *subview = [ViewLoadTests_SubviewController1 subviewController1]; 35 | [window addSubview:subview.view]; 36 | 37 | // Spin event loop for a bit so view will be created 38 | 39 | [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 40 | 41 | // Check that viewDidLoad was invoked 42 | 43 | NSAssert(subview->viewDidLoadFlag, @"viewDidLoad was not invoked"); 44 | 45 | return; 46 | } 47 | 48 | @end 49 | 50 | // SubviewController1 51 | 52 | @implementation ViewLoadTests_SubviewController1 53 | 54 | // Instance allocator for SubviewController1 55 | 56 | + (ViewLoadTests_SubviewController1*) subviewController1 { 57 | ViewLoadTests_SubviewController1 *vc = [[ViewLoadTests_SubviewController1 alloc] init]; 58 | if (vc == nil) 59 | return nil; 60 | #if __has_feature(objc_arc) 61 | return vc; 62 | #else 63 | return [vc autorelease]; 64 | #endif // objc_arc 65 | } 66 | 67 | - (void)loadView { 68 | CGRect frame = CGRectMake(0,0,10,10); 69 | 70 | UIView *view = [[UIView alloc] initWithFrame:frame]; 71 | 72 | #if __has_feature(objc_arc) 73 | #else 74 | view = [view autorelease]; 75 | #endif // objc_arc 76 | 77 | self.view = view; 78 | 79 | NSAssert(self.view, @"view is nil"); 80 | } 81 | 82 | - (void) viewDidLoad { 83 | [super viewDidLoad]; 84 | self->viewDidLoadFlag = TRUE; 85 | } 86 | 87 | @end // SubviewController1 88 | 89 | -------------------------------------------------------------------------------- /Classes/Tests/Waterfall_tiny_h264.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/Waterfall_tiny_h264.mov -------------------------------------------------------------------------------- /Classes/Tests/stutterwalk_h264.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/stutterwalk_h264.mov -------------------------------------------------------------------------------- /Classes/Tests/superwalk_h264.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Classes/Tests/superwalk_h264.mov -------------------------------------------------------------------------------- /CountingAnimation/Counting01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/CountingAnimation/Counting01.png -------------------------------------------------------------------------------- /CountingAnimation/Counting02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/CountingAnimation/Counting02.png -------------------------------------------------------------------------------- /CountingAnimation/Counting03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/CountingAnimation/Counting03.png -------------------------------------------------------------------------------- /CountingAnimation/Counting04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/CountingAnimation/Counting04.png -------------------------------------------------------------------------------- /CountingAnimation/Counting05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/CountingAnimation/Counting05.png -------------------------------------------------------------------------------- /CountingAnimation/Counting06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/CountingAnimation/Counting06.png -------------------------------------------------------------------------------- /CountingAnimation/Counting07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/CountingAnimation/Counting07.png -------------------------------------------------------------------------------- /CountingAnimation/Counting08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/CountingAnimation/Counting08.png -------------------------------------------------------------------------------- /CountingLandscape/CountingLandscape01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/CountingLandscape/CountingLandscape01.png -------------------------------------------------------------------------------- /CountingLandscape/CountingLandscape02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/CountingLandscape/CountingLandscape02.png -------------------------------------------------------------------------------- /CountingLandscape/CountingLandscape03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/CountingLandscape/CountingLandscape03.png -------------------------------------------------------------------------------- /CountingLandscape/CountingLandscape04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/CountingLandscape/CountingLandscape04.png -------------------------------------------------------------------------------- /CountingLandscape/CountingLandscape05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/CountingLandscape/CountingLandscape05.png -------------------------------------------------------------------------------- /CrewSub_200_16BPP.mvid.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/CrewSub_200_16BPP.mvid.7z -------------------------------------------------------------------------------- /Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Default-568h@2x.png -------------------------------------------------------------------------------- /GradientColorWheel_2FPS_32BPP_Keyframes.mvid.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/GradientColorWheel_2FPS_32BPP_Keyframes.mvid.7z -------------------------------------------------------------------------------- /Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Icon.png -------------------------------------------------------------------------------- /JigsawPuzzle_205_99_10FPS_16BPP.mvid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/JigsawPuzzle_205_99_10FPS_16BPP.mvid -------------------------------------------------------------------------------- /LCD.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/LCD.jpg -------------------------------------------------------------------------------- /MainWindow.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Matrix_480_320_10FPS_16BPP.mvid.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Matrix_480_320_10FPS_16BPP.mvid.7z -------------------------------------------------------------------------------- /QTFileParserApp-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | com.helpurock.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | UIStatusBarHidden 26 | 27 | LSRequiresIPhoneOS 28 | 29 | NSMainNibFile 30 | MainWindow 31 | UIViewControllerBasedStatusBarAppearance 32 | 33 | UIRequiredDeviceCapabilities 34 | 35 | armv6 36 | armv7 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /QTFileParserApp_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'QTFileParserApp' target in the 'QTFileParserApp' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | AVAnimator 2 | ========== 3 | 4 | AVAnimator is an iOS library that makes it easy to implement non-trivial animated/video content in iOS. 5 | 6 | See the project homepage for more information and example xcode projects: 7 | 8 | http://www.modejong.com/AVAnimator/ 9 | 10 | This is an Open Source project, it is free as in "liberty" but that does not mean it is free as in "free beer". 11 | The specific goal of this project is to provide a professional library that can be incorporated into real iOS apps. 12 | Please take a moment to understand the dual license and how legal use of software is important. 13 | 14 | http://www.modejong.com/AVAnimator/license.html 15 | 16 | Example iOS projects: 17 | 18 | http://www.modejong.com/AVAnimator/examples.html 19 | -------------------------------------------------------------------------------- /RedSquare_16BPP.mvid.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/RedSquare_16BPP.mvid.7z -------------------------------------------------------------------------------- /RegressionTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | com.helpurock.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | NSMainNibFile 28 | MainWindow 29 | UIRequiredDeviceCapabilities 30 | 31 | armv6 32 | armv7 33 | 34 | UIStatusBarHidden 35 | 36 | UISupportedInterfaceOrientations 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Sweep15FPS.caf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Sweep15FPS.caf -------------------------------------------------------------------------------- /Sweep15FPS.m4a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Sweep15FPS.m4a -------------------------------------------------------------------------------- /Sweep15FPS.mvid.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/Sweep15FPS.mvid.7z -------------------------------------------------------------------------------- /main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // QTFileParserApp 4 | // 5 | // Created by Moses DeJong on 12/17/10. 6 | // Copyright 2010 HelpURock. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) { 12 | int retVal; 13 | @autoreleasepool { 14 | retVal = UIApplicationMain(argc, argv, nil, nil); 15 | } 16 | return retVal; 17 | } 18 | -------------------------------------------------------------------------------- /smiley.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/smiley.png -------------------------------------------------------------------------------- /superwalk.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdejong/AVAnimator/86a9ebe77ac5b3ae163cc3267da34e914c42bcf1/superwalk.gif --------------------------------------------------------------------------------