Files
libpag/ios/PAGViewer/Full/ViewController/RegisterSoftwareDecoderViewController.mm

35 lines
1.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#import "RegisterSoftwareDecoderViewController.h"
#import <libpag/PAGVideoDecoder.h>
#include <ffavc/ffavc.h>
static bool hasRegistered = false;
@implementation RegisterSoftwareDecoderViewController
- (void)viewDidLoad {
if (!hasRegistered) {
[self registerSoftwareDecoder];
}
[super viewDidLoad];
}
- (NSString *)resourcePath {
return [[NSBundle mainBundle] pathForResource:@"particle_video" ofType:@"pag"];
}
/**
SoftwareDecoder程序生命周期内注册一次即可不需要多次注册。建议放在application启动时注册。
软解注册功能是为了满足用户减少包体而设计如果用户应用中本身有类似ffmpeg这种软解库可以通过注册外部软解的方式让pag提供不带软解的库从而保证包体更小
pag在使用过程中会优先使用硬件解码之后是外部注册解码器最后是自带软件解码有些版本的pag库没有这个解码器解码器要求支持x264解码。如果解码器不存在或者无法解码x264则素材中的视频序列帧(videoComposition)会无法显示
*/
- (void)registerSoftwareDecoder {
// 注册软件解码器工厂指针
[PAGVideoDecoder RegisterSoftwareDecoderFactory:ffavc::DecoderFactory::GetHandle()];
//注意这里是为了测试需要把pag中同时使用的最大硬解数量设置为-1。正常使用中除非不希望使用硬解否则不要设置为<=0的数
[PAGVideoDecoder SetMaxHardwareDecoderCount:-1];
hasRegistered = true;
}
@end