Skip to content

Commit

Permalink
Merge branch 'master' into hotfix/FatalWhenPlaybackFailure
Browse files Browse the repository at this point in the history
  • Loading branch information
noppefoxwolf authored Nov 13, 2020
2 parents 55190ee + 78f5e1c commit 487d06d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
1 change: 1 addition & 0 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 76ed2f2b7a60b498883386901c667ffa48dbcb69

COCOAPODS: 1.10.0

3 changes: 0 additions & 3 deletions Kitsunebi/Classes/AnimationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ open class PlayerView: UIView {
let baseYTexture = try textureCache.makeTextureFromImage(basePixelBuffer, pixelFormat: .r8Unorm, planeIndex: 0).texture
let baseCbCrTexture = try textureCache.makeTextureFromImage(basePixelBuffer, pixelFormat: .rg8Unorm, planeIndex: 1).texture
let alphaYTexture = try textureCache.makeTextureFromImage(alphaPixelBuffer, pixelFormat: .r8Unorm, planeIndex: 0).texture
let alphaCbCrTexture = try textureCache.makeTextureFromImage(alphaPixelBuffer, pixelFormat: .rg8Unorm, planeIndex: 1).texture


let renderDesc = MTLRenderPassDescriptor()
renderDesc.colorAttachments[0].texture = nextDrawable.texture
Expand All @@ -112,7 +110,6 @@ open class PlayerView: UIView {
renderEncoder.setFragmentTexture(baseYTexture, index: 0)
renderEncoder.setFragmentTexture(alphaYTexture, index: 1)
renderEncoder.setFragmentTexture(baseCbCrTexture, index: 2)
renderEncoder.setFragmentTexture(alphaCbCrTexture, index: 3)
renderEncoder.drawPrimitives(type: .triangleStrip, vertexStart: 0, vertexCount: 4)
renderEncoder.endEncoding()

Expand Down
7 changes: 2 additions & 5 deletions Kitsunebi/Classes/default.metal
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ vertex ColorInOut vertexShader(const device float4 *position [[ buffer(0) ]],
fragment float4 fragmentShader(ColorInOut in [[ stage_in ]],
texture2d<float> baseYTexture [[ texture(0) ]],
texture2d<float> alphaYTexture [[ texture(1) ]],
texture2d<float> baseCbCrTexture [[ texture(2) ]],
texture2d<float> alphaCbCrTexture [[ texture(3) ]]) {
texture2d<float> baseCbCrTexture [[ texture(2) ]]) {
constexpr sampler colorSampler;
const float4x4 ycbcrToRGBTransform = float4x4(
float4(+1.0000f, +1.0000f, +1.0000f, +0.0000f),
Expand All @@ -39,9 +38,7 @@ fragment float4 fragmentShader(ColorInOut in [[ stage_in ]],
baseCbCrTexture.sample(colorSampler, in.texCoords).rg,
1.0);

float4 alphaColor = ycbcrToRGBTransform * float4(alphaYTexture.sample(colorSampler, in.texCoords).r,
alphaCbCrTexture.sample(colorSampler, in.texCoords).rg,
1.0);
float4 alphaColor = alphaYTexture.sample(colorSampler, in.texCoords).r;

return float4(baseColor.r, baseColor.g, baseColor.b, alphaColor.r);
}
Expand Down

0 comments on commit 487d06d

Please sign in to comment.