OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 return width; | 60 return width; |
61 } | 61 } |
62 | 62 |
63 @Override | 63 @Override |
64 public int getHeight() { | 64 public int getHeight() { |
65 return height; | 65 return height; |
66 } | 66 } |
67 | 67 |
68 @Override | 68 @Override |
69 public VideoFrame.I420Buffer toI420() { | 69 public VideoFrame.I420Buffer toI420() { |
| 70 if (type == Type.RGB) { |
| 71 throw new RuntimeException("toI420 for RGB frames not implemented yet"); |
| 72 } |
70 // SurfaceTextureHelper requires a stride that is divisible by 8. Round wid
th up. | 73 // SurfaceTextureHelper requires a stride that is divisible by 8. Round wid
th up. |
71 // See SurfaceTextureHelper for details on the size and format. | 74 // See SurfaceTextureHelper for details on the size and format. |
72 int stride = ((width + 7) / 8) * 8; | 75 int stride = ((width + 7) / 8) * 8; |
73 int uvHeight = (height + 1) / 2; | 76 int uvHeight = (height + 1) / 2; |
74 // Due to the layout used by SurfaceTextureHelper, vPos + stride * uvHeight
would overrun the | 77 // Due to the layout used by SurfaceTextureHelper, vPos + stride * uvHeight
would overrun the |
75 // buffer. Add one row at the bottom to compensate for this. There will ne
ver be data in the | 78 // buffer. Add one row at the bottom to compensate for this. There will ne
ver be data in the |
76 // extra row, but now other code does not have to deal with v stride * v hei
ght exceeding the | 79 // extra row, but now other code does not have to deal with v stride * v hei
ght exceeding the |
77 // buffer's capacity. | 80 // buffer's capacity. |
78 int size = stride * (height + uvHeight + 1); | 81 int size = stride * (height + uvHeight + 1); |
79 ByteBuffer buffer = ByteBuffer.allocateDirect(size); | 82 ByteBuffer buffer = ByteBuffer.allocateDirect(size); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 130 |
128 return new TextureBufferImpl( | 131 return new TextureBufferImpl( |
129 scaleWidth, scaleHeight, type, id, newMatrix, surfaceTextureHelper, new
Runnable() { | 132 scaleWidth, scaleHeight, type, id, newMatrix, surfaceTextureHelper, new
Runnable() { |
130 @Override | 133 @Override |
131 public void run() { | 134 public void run() { |
132 release(); | 135 release(); |
133 } | 136 } |
134 }); | 137 }); |
135 } | 138 } |
136 } | 139 } |
OLD | NEW |