PAGDecoder Class Reference
Inherits from | NSObject |
---|---|
Declared in | PAGDecoder.h |
Overview
PAGDecoder provides a utility to read image frames directly from a PAGComposition, and caches the image frames as a sequence file on the disk, which may significantly speed up the reading process depending on the complexity of the PAG files. You can use the PAGDiskCache::SetMaxDiskSize() method to manage the cache limit of the disk usage.
+ Make:
Creates a new PAGDecoder with the specified PAGComposition, using the composition’s frame rate and size. Please only keep an external reference to the PAGComposition if you need to modify it in the feature. Otherwise, the internal composition will not be released automatically after the associated disk cache is complete, which may cost more memory than necessary. Returns nil if the composition is nil. Note that the returned PAGDecoder may become invalid if the associated PAGComposition is added to a PAGPlayer or another PAGDecoder.
+ (nullable instancetype)Make:(nullable PAGComposition *)composition
Declared In
PAGDecoder.h
+ Make:maxFrameRate:scale:
Creates a PAGDecoder with a PAGComposition, a frame rate limit, and a scale factor for the decoded image size. Please only keep an external reference to the PAGComposition if you need to modify it in the feature. Otherwise, the internal composition will not be released automatically after the associated disk cache is complete, which may cost more memory than necessary. Returns nullptr if the composition is nullptr. Note that the returned PAGDecoder may become invalid if the associated PAGComposition is added to a PAGPlayer or another PAGDecoder.
+ (nullable instancetype)Make:(nullable PAGComposition *)composition maxFrameRate:(float)maxFrameRate scale:(float)scale
Declared In
PAGDecoder.h
– numFrames
Returns the number of frames in the PAGDecoder. Note that the value may change if the associated PAGComposition was modified.
- (NSInteger)numFrames
Declared In
PAGDecoder.h
– frameRate
Returns the frame rate of decoded image frames. The value may change if the associated PAGComposition was modified.
- (float)frameRate
Declared In
PAGDecoder.h
– checkFrameChanged:
Returns true if the frame at the given index has changed since the last copyFrameTo(), readFrameTo(), or frameAtIndex() call. The caller should skip the corresponding call if the frame has not changed.
- (BOOL)checkFrameChanged:(int)index
Declared In
PAGDecoder.h
– copyFrameTo:rowBytes:at:
Copies pixels of the image frame at the given index to the specified memory address. The format of the copied pixels is in the BGRA color type with the premultiplied alpha type. Returns false if failed. Note that caller must ensure that the rowBytes stays the same throughout every copying call. Otherwise, it may return false.
- (BOOL)copyFrameTo:(void *)pixels rowBytes:(size_t)rowBytes at:(NSInteger)index
Declared In
PAGDecoder.h
– readFrame:to:
Reads pixels of the image frame at the given index into the specified CVPixelBuffer. Returns false if failed. Reading image frames into HardwareBuffer usually has better performance than reading into memory.
- (BOOL)readFrame:(NSInteger)index to:(CVPixelBufferRef)pixelBuffer
Declared In
PAGDecoder.h
– frameAtIndex:
Returns the image frame at the specified index. Note that this method must be called while the app is not in the background. Otherwise, it may return nil because the GPU code may not be executed. It’s recommended to read the image frames in forward order for better performance.
- (nullable UIImage *)frameAtIndex:(NSInteger)index
Declared In
PAGDecoder.h