From f103baf3875d1cd7065d9519bd82651bb0d552ad Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Tue, 26 May 2020 13:24:23 +0300 Subject: [PATCH] Video editor fixes --- .../blank.mp4 | Bin 0 -> 6628 bytes .../blank_1080p.mp4 | Bin 58848 -> 0 bytes .../LegacyComponents/Sources/GPUImage.h | 1 - .../Sources/GPUImageFramebuffer.h | 2 + .../Sources/GPUImageFramebuffer.m | 38 +++++- .../Sources/GPUImageTextureInput.h | 2 + .../Sources/GPUImageTextureInput.m | 128 ++++++++++++------ .../Sources/GPUImageTextureOutput.h | 24 ---- .../Sources/GPUImageTextureOutput.m | 94 ------------- .../LegacyComponents/Sources/PGPhotoEditor.m | 46 +++---- .../Sources/TGMediaVideoConverter.m | 4 +- 11 files changed, 150 insertions(+), 189 deletions(-) create mode 100644 submodules/LegacyComponents/Resources/LegacyComponentsResources.bundle/blank.mp4 delete mode 100644 submodules/LegacyComponents/Resources/LegacyComponentsResources.bundle/blank_1080p.mp4 delete mode 100755 submodules/LegacyComponents/Sources/GPUImageTextureOutput.h delete mode 100755 submodules/LegacyComponents/Sources/GPUImageTextureOutput.m diff --git a/submodules/LegacyComponents/Resources/LegacyComponentsResources.bundle/blank.mp4 b/submodules/LegacyComponents/Resources/LegacyComponentsResources.bundle/blank.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..6779f4a4cc8fd3949367df8b2b0f55643e55a744 GIT binary patch literal 6628 zcmeI0eM}Tb6u{ry7YBkp@xTL5SR$rsAVSq(RN@hBYGSd8sIgH~Pj-ofTMus6BN!9b z;76jhZ8TES#D>(w_!V0!XiXcuRHD{T6498(RxBDc($*+ZNYM4o?ychO>R-mseem|Z znfdK}?9Q8+Jpk~Qi8Ymc<)n`QfRqbC9{qeR&9i)yslyu7w%X?=3F%ISjSZB>}j@MVN+3B`XC7D`-R`l?Wws_JwG+~bnA)F1M{vVX6|d)k@S1h zm!Boi`P&_LohfO$eXV&WG2B;Or=+Q)o7@<rod0BUCEX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uIm3`q|+cmaEa%zLZNKS|e$qC_j<$7ec7_m1=O)WTrTT&BZLTW-dBGmK_sR^O- z3{n$fLTW-dqC&mjlAI7Ll2bblk`rPQ;hg?WYC@<;P3<^HO^8W^n*K*>La0bh?KntH zh)Gna_Z-Oyu_8IO;~+U9CK1l*6;cyIMQUotL25!wBGmLBQWHW&YHG(pYC=q+LOuG* z38C^0`j8w!Avqx&5zdL!gh-K^I^ZBRAt(`Q`aOku2$g4$Z$eB+O$bL+sP`Jl39%wM zwc{W;Atn*di9$U@$~VY4AtIde1n`5faPx4I&m1mHe5ED`p!Vwkfogq0PRwSo(93&^iB*Hm8 zLux{(NKNfHNKJ@IgqrA&oDeDBpimD%AvGZ!QK8;1$T=ZaoM9AtI0}FX3O}=hO&eAAFdx8{vAxtBl=poU#3Ie+QhyaDGf=It@Q!1Ms6q5+=R2 zO5lnmf<**~01+SpM1TnF0D%}AUFo^@@vC0GkcV)ktKcN|g)R$r*WC7(ip659y}MuN zd%4?jOm>TI`^VDN42o`e5H2SOtG!pfaCz4&;qIrqT|-?@+_o2t^^C6c?*Hh(Kc2eq z#mBlG4!_hv#Cl?@d#-!r;E&h3MUZ~A+mhQprCnF(QMi#Pz*@M4D2%S`k&o|x=W`cU z#itovz4)c=D(Sln)^^Z`uLuc!_=<2ueE3R#+KEW{2B`@_AvGZ!QQr){1`lx%wD#Tc z$icU}4q9)0wJW#YT`;gir927;hytvI1W_1W=^J@(2d)0T(4VEX5L@k6i2_h45{1!~ z{)yw#1An~m-TS+Bc{iTxw&V_ZzKg9^c*-jeJu)`bb-Zwse2F6fWFCd1L;==9i71S& vTzQ=Kh1lxVAE&hd6h285fWl{p!syD?4cZrCs{@?Y0#GoC0#K;Ew<-J|nEH<+ diff --git a/submodules/LegacyComponents/Sources/GPUImage.h b/submodules/LegacyComponents/Sources/GPUImage.h index 7f2e0b82a2..7de9b9c7aa 100755 --- a/submodules/LegacyComponents/Sources/GPUImage.h +++ b/submodules/LegacyComponents/Sources/GPUImage.h @@ -9,7 +9,6 @@ #import "GPUImagePicture.h" #import "GPUImageRawDataInput.h" #import "GPUImageRawDataOutput.h" -#import "GPUImageTextureOutput.h" #import "GPUImageFilterGroup.h" #import "GPUImageFramebuffer.h" #import "GPUImageFramebufferCache.h" diff --git a/submodules/LegacyComponents/Sources/GPUImageFramebuffer.h b/submodules/LegacyComponents/Sources/GPUImageFramebuffer.h index 21b352edc2..17a742678e 100755 --- a/submodules/LegacyComponents/Sources/GPUImageFramebuffer.h +++ b/submodules/LegacyComponents/Sources/GPUImageFramebuffer.h @@ -31,8 +31,10 @@ typedef struct GPUTextureOptions { - (id)initWithSize:(CGSize)framebufferSize; - (id)initWithSize:(CGSize)framebufferSize textureOptions:(GPUTextureOptions)fboTextureOptions onlyTexture:(BOOL)onlyGenerateTexture; - (id)initWithSize:(CGSize)framebufferSize overriddenTexture:(GLuint)inputTexture; +- (id)initWithSize:(CGSize)framebufferSize overridenFramebuffer:(GLuint)overridenFramebuffer overriddenTexture:(GLuint)inputTexture; // Usage +- (void)useFramebuffer; - (void)activateFramebuffer; // Reference counting diff --git a/submodules/LegacyComponents/Sources/GPUImageFramebuffer.m b/submodules/LegacyComponents/Sources/GPUImageFramebuffer.m index 4f96d38ba9..b686a787d4 100755 --- a/submodules/LegacyComponents/Sources/GPUImageFramebuffer.m +++ b/submodules/LegacyComponents/Sources/GPUImageFramebuffer.m @@ -92,6 +92,33 @@ static BOOL mark = false; return self; } +- (id)initWithSize:(CGSize)framebufferSize overridenFramebuffer:(GLuint)overridenFramebuffer overriddenTexture:(GLuint)inputTexture +{ + if (!(self = [super init])) + { + return nil; + } + _mark = mark; + GPUTextureOptions defaultTextureOptions; + defaultTextureOptions.minFilter = GL_LINEAR; + defaultTextureOptions.magFilter = GL_LINEAR; + defaultTextureOptions.wrapS = GL_CLAMP_TO_EDGE; + defaultTextureOptions.wrapT = GL_CLAMP_TO_EDGE; + defaultTextureOptions.internalFormat = GL_RGBA; + defaultTextureOptions.format = GL_BGRA; + defaultTextureOptions.type = GL_UNSIGNED_BYTE; + + _textureOptions = defaultTextureOptions; + _size = framebufferSize; + framebufferReferenceCount = 0; + referenceCountingDisabled = YES; + + framebuffer = overridenFramebuffer; + _texture = inputTexture; + + return self; +} + - (id)initWithSize:(CGSize)framebufferSize { _mark = mark; @@ -243,6 +270,11 @@ static BOOL mark = false; #pragma mark - #pragma mark Usage +- (void)useFramebuffer +{ + glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); +} + - (void)activateFramebuffer { glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); @@ -263,6 +295,8 @@ static BOOL mark = false; [fixer invalidate]; fixer = nil; + + NSLog(@"Lock, %@, count = %d", self, framebufferReferenceCount); } - (void)unlock @@ -275,13 +309,15 @@ static BOOL mark = false; NSAssert(framebufferReferenceCount > 0, @"Tried to overrelease a framebuffer, did you forget to call -useNextFrameForImageCapture before using -imageFromCurrentFramebuffer?"); framebufferReferenceCount--; + NSLog(@"Unlock, %@, count = %d", self, framebufferReferenceCount); + if (framebufferReferenceCount < 1) { [[GPUImageContext sharedFramebufferCache] returnFramebufferToCache:self]; [fixer invalidate]; fixer = nil; } else if (framebufferReferenceCount == 1 && self.mark) { - fixer = [TGTimerTarget scheduledMainThreadTimerWithTarget:self action:@selector(fixTick) interval:0.35 repeat:false]; +// fixer = [TGTimerTarget scheduledMainThreadTimerWithTarget:self action:@selector(fixTick) interval:0.35 repeat:false]; } } diff --git a/submodules/LegacyComponents/Sources/GPUImageTextureInput.h b/submodules/LegacyComponents/Sources/GPUImageTextureInput.h index bd987f5e0c..6296f76e38 100755 --- a/submodules/LegacyComponents/Sources/GPUImageTextureInput.h +++ b/submodules/LegacyComponents/Sources/GPUImageTextureInput.h @@ -9,6 +9,8 @@ - (instancetype)initWithTexture:(GLuint)newInputTexture size:(CGSize)newTextureSize; - (instancetype)initWithCIImage:(CIImage *)ciImage; +- (void)setCIImage:(CIImage *)ciImage; + - (void)processTextureWithFrameTime:(CMTime)frameTime synchronous:(bool)synchronous; - (CGSize)textureSize; diff --git a/submodules/LegacyComponents/Sources/GPUImageTextureInput.m b/submodules/LegacyComponents/Sources/GPUImageTextureInput.m index b21fe87c99..3ab77c19cf 100755 --- a/submodules/LegacyComponents/Sources/GPUImageTextureInput.m +++ b/submodules/LegacyComponents/Sources/GPUImageTextureInput.m @@ -1,7 +1,9 @@ #import "GPUImageTextureInput.h" @implementation GPUImageTextureInput - +{ + CIContext *ciContext; +} #pragma mark - #pragma mark Initialization and teardown @@ -12,13 +14,10 @@ return nil; } + textureSize = newTextureSize; + runSynchronouslyOnVideoProcessingQueue(^{ [GPUImageContext useImageProcessingContext]; - }); - - textureSize = newTextureSize; - - runSynchronouslyOnVideoProcessingQueue(^{ outputFramebuffer = [[GPUImageFramebuffer alloc] initWithSize:newTextureSize overriddenTexture:newInputTexture]; }); @@ -27,45 +26,92 @@ - (instancetype)initWithCIImage:(CIImage *)ciImage { - EAGLContext *context = [[GPUImageContext sharedImageProcessingContext] context]; - [EAGLContext setCurrentContext:context]; - - GLsizei backingWidth = ciImage.extent.size.width; - GLsizei backingHeight = ciImage.extent.size.height; - GLuint outputTexture, defaultFramebuffer; - - glActiveTexture(GL_TEXTURE0); - glGenTextures(1, &outputTexture); - glBindTexture(GL_TEXTURE_2D, outputTexture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glBindTexture(GL_TEXTURE_2D, 0); - - glActiveTexture(GL_TEXTURE1); - glGenFramebuffers(1, &defaultFramebuffer); - glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer); - - glBindTexture(GL_TEXTURE_2D, outputTexture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, backingWidth, backingHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, outputTexture, 0); - - NSAssert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE, @"Incomplete filter FBO: %d", glCheckFramebufferStatus(GL_FRAMEBUFFER)); - - glBindTexture(GL_TEXTURE_2D, 0); - - ciImage = [ciImage imageByApplyingTransform:CGAffineTransformConcat(CGAffineTransformMakeScale(1.0f, -1.0f), CGAffineTransformMakeTranslation(0.0f, ciImage.extent.size.height))]; - - CIContext *ciContext = [CIContext contextWithEAGLContext:context options:@{kCIContextWorkingColorSpace: [NSNull null]}]; - [ciContext drawImage:ciImage inRect:ciImage.extent fromRect:ciImage.extent]; - - if (self = [self initWithTexture:outputTexture size:ciImage.extent.size]) { - textureSize = ciImage.extent.size; + if (!(self = [super init])) + { + return nil; } + textureSize = ciImage.extent.size; + + runSynchronouslyOnVideoProcessingQueue(^{ + EAGLContext *context = [[GPUImageContext sharedImageProcessingContext] context]; + [EAGLContext setCurrentContext:context]; + + GLsizei backingWidth = ciImage.extent.size.width; + GLsizei backingHeight = ciImage.extent.size.height; + GLuint outputTexture, defaultFramebuffer; + + glActiveTexture(GL_TEXTURE0); + glGenTextures(1, &outputTexture); + glBindTexture(GL_TEXTURE_2D, outputTexture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glBindTexture(GL_TEXTURE_2D, 0); + + glActiveTexture(GL_TEXTURE1); + glGenFramebuffers(1, &defaultFramebuffer); + glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer); + + glBindTexture(GL_TEXTURE_2D, outputTexture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, backingWidth, backingHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, outputTexture, 0); + + NSAssert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE, @"Incomplete filter FBO: %d", glCheckFramebufferStatus(GL_FRAMEBUFFER)); + + glBindTexture(GL_TEXTURE_2D, 0); + + CIImage *updatedCIImage = [ciImage imageByApplyingTransform:CGAffineTransformConcat(CGAffineTransformMakeScale(1.0f, -1.0f), CGAffineTransformMakeTranslation(0.0f, ciImage.extent.size.height))]; + + ciContext = [CIContext contextWithEAGLContext:context options:@{kCIContextWorkingColorSpace: [NSNull null]}]; + [ciContext drawImage:updatedCIImage inRect:updatedCIImage.extent fromRect:updatedCIImage.extent]; + + [GPUImageContext useImageProcessingContext]; + outputFramebuffer = [[GPUImageFramebuffer alloc] initWithSize:ciImage.extent.size overridenFramebuffer:defaultFramebuffer overriddenTexture:outputTexture]; + }); + return self; } +- (void)dealloc { + NSLog(@"deall texinp"); +} + +- (void)setCIImage:(CIImage *)ciImage { + runSynchronouslyOnVideoProcessingQueue(^{ + EAGLContext *context = [[GPUImageContext sharedImageProcessingContext] context]; + [EAGLContext setCurrentContext:context]; + + GLsizei backingWidth = ciImage.extent.size.width; + GLsizei backingHeight = ciImage.extent.size.height; + + GLint outputTexture = outputFramebuffer.texture; + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, outputTexture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glBindTexture(GL_TEXTURE_2D, 0); + + glActiveTexture(GL_TEXTURE1); + [outputFramebuffer useFramebuffer]; + + glBindTexture(GL_TEXTURE_2D, outputTexture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, backingWidth, backingHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, outputTexture, 0); + + NSAssert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE, @"Incomplete filter FBO: %d", glCheckFramebufferStatus(GL_FRAMEBUFFER)); + + glBindTexture(GL_TEXTURE_2D, 0); + + CIImage *updatedCIImage = [ciImage imageByApplyingTransform:CGAffineTransformConcat(CGAffineTransformMakeScale(1.0f, -1.0f), CGAffineTransformMakeTranslation(0.0f, ciImage.extent.size.height))]; + + [ciContext drawImage:updatedCIImage inRect:updatedCIImage.extent fromRect:updatedCIImage.extent]; + }); +} + - (void)processTextureWithFrameTime:(CMTime)frameTime synchronous:(bool)synchronous { void (^block)(void) = ^ diff --git a/submodules/LegacyComponents/Sources/GPUImageTextureOutput.h b/submodules/LegacyComponents/Sources/GPUImageTextureOutput.h deleted file mode 100755 index 51bcd814f4..0000000000 --- a/submodules/LegacyComponents/Sources/GPUImageTextureOutput.h +++ /dev/null @@ -1,24 +0,0 @@ -#import -#import -#import "GPUImageContext.h" - -@protocol GPUImageTextureOutputDelegate; - -@interface GPUImageTextureOutput : NSObject -{ - GPUImageFramebuffer *firstInputFramebuffer; -} - -@property(readwrite, unsafe_unretained, nonatomic) id delegate; -@property(readonly) GLuint texture; -@property(nonatomic) BOOL enabled; - -- (CIImage *)CIImageWithSize:(CGSize)size; - -- (void)doneWithTexture; - -@end - -@protocol GPUImageTextureOutputDelegate -- (void)newFrameReadyFromTextureOutput:(GPUImageTextureOutput *)callbackTextureOutput; -@end diff --git a/submodules/LegacyComponents/Sources/GPUImageTextureOutput.m b/submodules/LegacyComponents/Sources/GPUImageTextureOutput.m deleted file mode 100755 index 360e74ae41..0000000000 --- a/submodules/LegacyComponents/Sources/GPUImageTextureOutput.m +++ /dev/null @@ -1,94 +0,0 @@ -#import "GPUImageTextureOutput.h" - -@implementation GPUImageTextureOutput - -@synthesize delegate = _delegate; -@synthesize texture = _texture; -@synthesize enabled; - -#pragma mark - -#pragma mark Initialization and teardown - -- (id)init; -{ - if (!(self = [super init])) - { - return nil; - } - - self.enabled = YES; - - return self; -} - -- (void)doneWithTexture; -{ - [firstInputFramebuffer unlock]; -} - -#pragma mark - -#pragma mark GPUImageInput protocol - -- (void)newFrameReadyAtTime:(CMTime)frameTime atIndex:(NSInteger)textureIndex; -{ - [_delegate newFrameReadyFromTextureOutput:self]; -} - -- (NSInteger)nextAvailableTextureIndex; -{ - return 0; -} - -- (CIImage *)CIImageWithSize:(CGSize)size -{ - EAGLContext *context = [[GPUImageContext sharedImageProcessingContext] context]; - [EAGLContext setCurrentContext:context]; - - CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); - CIImage *image = [[CIImage alloc] initWithTexture:self.texture size:size flipped:true colorSpace:colorSpace]; - CGColorSpaceRelease(colorSpace); - return image; -} - -// TODO: Deal with the fact that the texture changes regularly as a result of the caching -- (void)setInputFramebuffer:(GPUImageFramebuffer *)newInputFramebuffer atIndex:(NSInteger)textureIndex; -{ - firstInputFramebuffer = newInputFramebuffer; - [firstInputFramebuffer lock]; - - _texture = [firstInputFramebuffer texture]; -} - -- (void)setInputRotation:(GPUImageRotationMode)newInputRotation atIndex:(NSInteger)textureIndex; -{ -} - -- (void)setInputSize:(CGSize)newSize atIndex:(NSInteger)textureIndex; -{ -} - -- (CGSize)maximumOutputSize; -{ - return CGSizeZero; -} - -- (void)endProcessing -{ -} - -- (BOOL)shouldIgnoreUpdatesToThisTarget; -{ - return NO; -} - -- (BOOL)wantsMonochromeInput; -{ - return NO; -} - -- (void)setCurrentlyReceivingMonochromeInput:(BOOL)newValue; -{ - -} - -@end diff --git a/submodules/LegacyComponents/Sources/PGPhotoEditor.m b/submodules/LegacyComponents/Sources/PGPhotoEditor.m index 63e0d84b62..80eda8cd75 100644 --- a/submodules/LegacyComponents/Sources/PGPhotoEditor.m +++ b/submodules/LegacyComponents/Sources/PGPhotoEditor.m @@ -11,7 +11,6 @@ #import "PGPhotoEditorPicture.h" #import "GPUImageTextureInput.h" -#import "GPUImageTextureOutput.h" #import #import @@ -46,9 +45,7 @@ GPUImageOutput *_currentInput; NSArray *_currentProcessChain; GPUImageOutput *_finalFilter; - - GPUImageTextureOutput *_textureOutput; - + PGPhotoHistogram *_currentHistogram; PGPhotoHistogramGenerator *_histogramGenerator; @@ -94,17 +91,19 @@ _histogramPipe = [[SPipe alloc] init]; - __weak PGPhotoEditor *weakSelf = self; - _histogramGenerator = [[PGPhotoHistogramGenerator alloc] init]; - _histogramGenerator.histogramReady = ^(PGPhotoHistogram *histogram) - { - __strong PGPhotoEditor *strongSelf = weakSelf; - if (strongSelf == nil) - return; + if (!forVideo) { + __weak PGPhotoEditor *weakSelf = self; + _histogramGenerator = [[PGPhotoHistogramGenerator alloc] init]; + _histogramGenerator.histogramReady = ^(PGPhotoHistogram *histogram) + { + __strong PGPhotoEditor *strongSelf = weakSelf; + if (strongSelf == nil) + return; - strongSelf->_currentHistogram = histogram; - strongSelf->_histogramPipe.sink(histogram); - }; + strongSelf->_currentHistogram = histogram; + strongSelf->_histogramPipe.sink(histogram); + }; + } [self importAdjustments:adjustments]; } @@ -176,11 +175,12 @@ _currentProcessChain = nil; [_currentInput removeAllTargets]; - GPUImageTextureInput *input = [[GPUImageTextureInput alloc] initWithCIImage:ciImage]; - _currentInput = input; - if (_textureOutput == nil) { - _textureOutput = [[GPUImageTextureOutput alloc] init]; + if ([_currentInput isKindOfClass:[GPUImageTextureInput class]]) { + [(GPUImageTextureInput *)_currentInput setCIImage:ciImage]; + } else { + GPUImageTextureInput *input = [[GPUImageTextureInput alloc] initWithCIImage:ciImage]; + _currentInput = input; } _fullSize = true; @@ -355,15 +355,11 @@ } _finalFilter = lastFilter; - if (_textureOutput != nil) { - [_finalFilter addTarget:_textureOutput]; - } - if (previewOutput != nil) { [_finalFilter addTarget:previewOutput.imageView]; } - if (!self.forVideo) { + if (_histogramGenerator != nil && !self.standalone) { [_finalFilter addTarget:_histogramGenerator]; } } @@ -394,13 +390,9 @@ - (CIImage *)currentResultCIImage { __block CIImage *image = nil; - GPUImageOutput *currentInput = _currentInput; [self processAnimated:false capture:true synchronous:true completion:^ { image = [_finalFilter newCIImageFromCurrentlyProcessedOutput]; -// if ([currentInput isKindOfClass:[GPUImageTextureInput class]]) { -// image = [_textureOutput CIImageWithSize:[(GPUImageTextureInput *)currentInput textureSize]]; -// } }]; return image; } diff --git a/submodules/LegacyComponents/Sources/TGMediaVideoConverter.m b/submodules/LegacyComponents/Sources/TGMediaVideoConverter.m index 07ae33cc5a..d2af5054d4 100644 --- a/submodules/LegacyComponents/Sources/TGMediaVideoConverter.m +++ b/submodules/LegacyComponents/Sources/TGMediaVideoConverter.m @@ -221,7 +221,7 @@ SAtomic *context = [[SAtomic alloc] initWithValue:[TGMediaVideoConversionContext contextWithQueue:queue subscriber:subscriber]]; NSURL *outputUrl = [self _randomTemporaryURL]; - NSString *path = TGComponentsPathForResource(@"blank_1080p", @"mp4"); + NSString *path = TGComponentsPathForResource(@"blank", @"mp4"); AVAsset *avAsset = [[AVURLAsset alloc] initWithURL:[NSURL fileURLWithPath:path] options:nil]; NSArray *requiredKeys = @[ @"tracks", @"duration", @"playable" ]; @@ -388,8 +388,10 @@ CGSize size = resultImage.extent.size; if (editor != nil) { + NSLog(@"setCIImage"); [editor setCIImage:resultImage]; resultImage = editor.currentResultCIImage; + NSLog(@"resultCIImage"); } if (overlayImage != nil && overlayImage.size.width > 0.0) {