Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license | |
| 5 * that can be found in the LICENSE file in the root of the source | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #include <metal_stdlib> | |
| 12 #include <simd/simd.h> | |
| 13 | |
| 14 using namespace metal; | |
| 15 | |
| 16 typedef struct { | |
| 17 packed_float2 position; | |
| 18 packed_float2 texcoord; | |
| 19 } Vertex; | |
| 20 | |
| 21 | |
| 22 typedef struct { | |
| 23 float4 position [[position]]; | |
| 24 float2 texcoord; | |
| 25 } Varyings; | |
| 26 | |
| 27 vertex Varyings vertexPassthrough( | |
| 28 device Vertex* verticies [[ buffer(0) ]], | |
| 29 unsigned int vid [[ vertex_id ]] | |
| 30 ) { | |
| 31 Varyings out; | |
| 32 | |
|
magjed_webrtc
2017/02/07 12:12:41
Maybe remove these empty lines between?
daniela-webrtc
2017/02/07 13:36:16
Done.
| |
| 33 device Vertex& v = verticies[vid]; | |
| 34 | |
| 35 out.position = float4(float2(v.position), 0.0, 1.0); | |
| 36 | |
| 37 out.texcoord = v.texcoord; | |
| 38 | |
| 39 return out; | |
| 40 } | |
| 41 | |
| 42 fragment half4 fragmentColorConversion( | |
| 43 Varyings in [[ stage_in ]], | |
| 44 texture2d<float, access::sample> textureY [[ texture(0) ]], | |
| 45 texture2d<float, access::sample> textureC bCr [[ texture(1) ]] | |
| 46 ) { | |
| 47 constexpr sampler s(address::clamp_to_edge, filter::linear); | |
| 48 float y; | |
| 49 float2 uv; | |
| 50 y = textureY.sample(s, in.texcoord).r; | |
| 51 uv = textureCbCr.sample(s, in.texcoord).rg - float2(0.5,0.5); | |
|
magjed_webrtc
2017/02/07 12:12:41
nit: add space between '0.5,0.5', i.e. '0.5, 0.5'
daniela-webrtc
2017/02/07 13:36:16
Done.
| |
| 52 | |
| 53 float4 out = float4(y + 1.403 * uv.y, | |
| 54 y - 0.344 * uv.x - 0.714 * uv.y, | |
| 55 y + 1.770 * uv.x, | |
| 56 1.0); | |
| 57 | |
| 58 return half4(out); | |
| 59 } | |
| OLD | NEW |