mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Video avatar fixes
This commit is contained in:
parent
5c1263ff12
commit
fb5c983f04
@ -131,7 +131,7 @@
|
||||
{
|
||||
for (GPUImageOutput<GPUImageInput> *currentFilter in _initialFilters)
|
||||
{
|
||||
[currentFilter setInputRotation:newInputRotation atIndex:(NSInteger)textureIndex];
|
||||
[currentFilter setInputRotation:newInputRotation atIndex:(NSInteger)textureIndex];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,11 +194,11 @@ NSString *const kGPUImageThreeInputTextureVertexShaderString = SHADER_STRING
|
||||
{
|
||||
inputRotation = newInputRotation;
|
||||
}
|
||||
else if (textureIndex == 1)
|
||||
else if (textureIndex == 1 && !self.rotateOnlyFirstTexture)
|
||||
{
|
||||
inputRotation2 = newInputRotation;
|
||||
}
|
||||
else
|
||||
else if (textureIndex == 2 && !self.rotateOnlyFirstTexture)
|
||||
{
|
||||
inputRotation3 = newInputRotation;
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ extern NSString *const kGPUImageTwoInputTextureVertexShaderString;
|
||||
BOOL firstFrameCheckDisabled, secondFrameCheckDisabled;
|
||||
}
|
||||
|
||||
@property (nonatomic, assign) bool rotateOnlyFirstTexture;
|
||||
|
||||
- (void)disableFirstFrameCheck;
|
||||
- (void)disableSecondFrameCheck;
|
||||
|
||||
|
@ -176,7 +176,7 @@ NSString *const kGPUImageTwoInputTextureVertexShaderString = SHADER_STRING
|
||||
{
|
||||
inputRotation = newInputRotation;
|
||||
}
|
||||
else
|
||||
else if (textureIndex == 1 && !_rotateOnlyFirstTexture)
|
||||
{
|
||||
inputRotation2 = newInputRotation;
|
||||
}
|
||||
|
@ -1837,17 +1837,21 @@
|
||||
if (adjustments.toolsApplied) {
|
||||
image = [PGPhotoEditor resultImageForImage:image adjustments:adjustments];
|
||||
|
||||
CGSize fillSize = TGScaleToFillSize(videoDimensions, image.size);
|
||||
|
||||
UIGraphicsBeginImageContextWithOptions(fillSize, true, 0.0f);
|
||||
CGContextRef context = UIGraphicsGetCurrentContext();
|
||||
CGContextSetInterpolationQuality(context, kCGInterpolationMedium);
|
||||
|
||||
[image drawInRect:CGRectMake(0, 0, fillSize.width, fillSize.height)];
|
||||
[paintingImage drawInRect:CGRectMake(0, 0, fillSize.width, fillSize.height)];
|
||||
|
||||
fullImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
if ([self presentedForAvatarCreation]) {
|
||||
fullImage = TGPhotoEditorVideoCrop(image, paintingImage, adjustments.cropOrientation, adjustments.cropRotation, adjustments.cropRect, adjustments.cropMirrored, CGSizeMake(640, 640), item.originalSize, true, false);
|
||||
} else {
|
||||
CGSize fillSize = TGScaleToFillSize(videoDimensions, image.size);
|
||||
|
||||
UIGraphicsBeginImageContextWithOptions(fillSize, true, 0.0f);
|
||||
CGContextRef context = UIGraphicsGetCurrentContext();
|
||||
CGContextSetInterpolationQuality(context, kCGInterpolationMedium);
|
||||
|
||||
[image drawInRect:CGRectMake(0, 0, fillSize.width, fillSize.height)];
|
||||
[paintingImage drawInRect:CGRectMake(0, 0, fillSize.width, fillSize.height)];
|
||||
|
||||
fullImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
}
|
||||
} else {
|
||||
fullImage = TGPhotoEditorVideoCrop(image, paintingImage, adjustments.cropOrientation, adjustments.cropRotation, adjustments.cropRect, adjustments.cropMirrored, CGSizeMake(640, 640), item.originalSize, true, false);
|
||||
}
|
||||
@ -2320,14 +2324,16 @@
|
||||
if (self.requestOriginalScreenSizeImage == nil)
|
||||
return;
|
||||
|
||||
SSignal *cachedSignal = [[self.editingContext facesForItem:item] mapToSignal:^SSignal *(id result)
|
||||
SSignal *cachedFaces = self.editingContext != nil ? [self.editingContext facesForItem:item] : [SSignal single:nil];
|
||||
|
||||
SSignal *cachedSignal = [cachedFaces mapToSignal:^SSignal *(id result)
|
||||
{
|
||||
if (result == nil)
|
||||
return [SSignal fail:nil];
|
||||
return [SSignal single:result];
|
||||
}];
|
||||
SSignal *imageSignal = [self.requestOriginalScreenSizeImage(item, 0) take:1];
|
||||
SSignal *detectSignal = [[imageSignal filter:^bool(UIImage *image)
|
||||
SSignal *imageSignal = self.requestOriginalScreenSizeImage(item, 0);
|
||||
SSignal *detectSignal = [[[imageSignal filter:^bool(UIImage *image)
|
||||
{
|
||||
if (![image isKindOfClass:[UIImage class]])
|
||||
return false;
|
||||
@ -2336,7 +2342,7 @@
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}] mapToSignal:^SSignal *(UIImage *image) {
|
||||
}] take:1] mapToSignal:^SSignal *(UIImage *image) {
|
||||
return [[TGPaintFaceDetector detectFacesInImage:image originalSize:originalSize] startOn:[SQueue concurrentDefaultQueue]];
|
||||
}];
|
||||
|
||||
|
@ -60,7 +60,7 @@ SHADER_STRING
|
||||
|
||||
void main() {
|
||||
vec4 image = texture2D(sourceImage, texCoord);
|
||||
vec4 blurredImage = texture2D(inputImageTexture2, texCoord);
|
||||
vec4 blurredImage = texture2D(inputImageTexture2, texCoord2);
|
||||
gl_FragColor = vec4((image.rgb - blurredImage.rgb + vec3(0.5,0.5,0.5)), image.a);
|
||||
}
|
||||
);
|
||||
@ -202,8 +202,8 @@ SHADER_STRING
|
||||
|
||||
void main() {
|
||||
vec4 image = texture2D(sourceImage, texCoord);
|
||||
vec4 toneCurvedImage = texture2D(inputImageTexture2, texCoord);
|
||||
vec4 mask = texture2D(inputImageTexture3, texCoord);
|
||||
vec4 toneCurvedImage = texture2D(inputImageTexture2, texCoord2);
|
||||
vec4 mask = texture2D(inputImageTexture3, texCoord3);
|
||||
gl_FragColor = vec4(mix(image.rgb,toneCurvedImage.rgb,1.0 - mask.b),1.0);
|
||||
}
|
||||
);
|
||||
@ -240,12 +240,14 @@ SHADER_STRING
|
||||
self.skinToneCurveFilter = skinToneCurveFilter;
|
||||
|
||||
GPUImageDissolveBlendFilter *dissolveFilter = [[GPUImageDissolveBlendFilter alloc] init];
|
||||
dissolveFilter.rotateOnlyFirstTexture = true;
|
||||
[self addFilter:dissolveFilter];
|
||||
self.dissolveFilter = dissolveFilter;
|
||||
|
||||
[skinToneCurveFilter addTarget:dissolveFilter atTextureLocation:1];
|
||||
|
||||
GPUImageThreeInputFilter *composeFilter = [[GPUImageThreeInputFilter alloc] initWithFragmentShaderFromString:YUGPUImageHighpassSkinSmoothingCompositingFilterFragmentShaderString];
|
||||
composeFilter.rotateOnlyFirstTexture = true;
|
||||
[self addFilter:composeFilter];
|
||||
|
||||
[maskGenerator addTarget:composeFilter atTextureLocation:2];
|
||||
@ -281,6 +283,10 @@ SHADER_STRING
|
||||
[self updateHighPassRadius];
|
||||
}
|
||||
|
||||
- (void)setInputRotation:(GPUImageRotationMode)newInputRotation atIndex:(NSInteger)textureIndex {
|
||||
[super setInputRotation:newInputRotation atIndex:textureIndex];
|
||||
}
|
||||
|
||||
- (void)updateHighPassRadius {
|
||||
CGSize inputSize = self.currentInputSize;
|
||||
if (inputSize.width * inputSize.height > 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user