Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: webrtc/sdk/android/api/org/webrtc/MediaCodecVideoEncoder.java

Issue 3002263002: Add support for RGB frames in MediaCodecVideoEncoder. (Closed)
Patch Set: Address comments. Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/sdk/android/api/org/webrtc/RendererCommon.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2013 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 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 long presentationTimestampUs = TimeUnit.NANOSECONDS.toMicros(frame.getTime stampNs()); 609 long presentationTimestampUs = TimeUnit.NANOSECONDS.toMicros(frame.getTime stampNs());
610 checkKeyFrameRequired(isKeyframe, presentationTimestampUs); 610 checkKeyFrameRequired(isKeyframe, presentationTimestampUs);
611 611
612 VideoFrame.Buffer buffer = frame.getBuffer(); 612 VideoFrame.Buffer buffer = frame.getBuffer();
613 if (buffer instanceof VideoFrame.TextureBuffer) { 613 if (buffer instanceof VideoFrame.TextureBuffer) {
614 VideoFrame.TextureBuffer textureBuffer = (VideoFrame.TextureBuffer) buff er; 614 VideoFrame.TextureBuffer textureBuffer = (VideoFrame.TextureBuffer) buff er;
615 eglBase.makeCurrent(); 615 eglBase.makeCurrent();
616 // TODO(perkj): glClear() shouldn't be necessary since every pixel is co vered anyway, 616 // TODO(perkj): glClear() shouldn't be necessary since every pixel is co vered anyway,
617 // but it's a workaround for bug webrtc:5147. 617 // but it's a workaround for bug webrtc:5147.
618 GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); 618 GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
619 drawer.drawOes(textureBuffer.getTextureId(), 619 drawer.drawTexture(textureBuffer, new Matrix() /* renderMatrix */, width , height,
620 RendererCommon.convertMatrixFromAndroidGraphicsMatrix( 620 0 /* viewportX */, 0 /* viewportY */, width, height);
621 textureBuffer.getTransformMatrix()),
622 width, height, 0, 0, width, height);
623 eglBase.swapBuffers(frame.getTimestampNs()); 621 eglBase.swapBuffers(frame.getTimestampNs());
624 } else { 622 } else {
625 VideoFrame.I420Buffer i420Buffer = buffer.toI420(); 623 VideoFrame.I420Buffer i420Buffer = buffer.toI420();
626 nativeFillBuffer(nativeEncoder, bufferIndex, i420Buffer.getDataY(), i420 Buffer.getStrideY(), 624 nativeFillBuffer(nativeEncoder, bufferIndex, i420Buffer.getDataY(), i420 Buffer.getStrideY(),
627 i420Buffer.getDataU(), i420Buffer.getStrideU(), i420Buffer.getDataV( ), 625 i420Buffer.getDataU(), i420Buffer.getStrideU(), i420Buffer.getDataV( ),
628 i420Buffer.getStrideV()); 626 i420Buffer.getStrideV());
629 i420Buffer.release(); 627 i420Buffer.release();
630 // I420 consists of one full-resolution and two half-resolution planes. 628 // I420 consists of one full-resolution and two half-resolution planes.
631 // 1 + 1 / 4 + 1 / 4 = 3 / 2 629 // 1 + 1 / 4 + 1 / 4 = 3 / 2
632 int yuvSize = width * height * 3 / 2; 630 int yuvSize = width * height * 3 / 2;
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 } catch (IllegalStateException e) { 918 } catch (IllegalStateException e) {
921 Logging.e(TAG, "releaseOutputBuffer failed", e); 919 Logging.e(TAG, "releaseOutputBuffer failed", e);
922 return false; 920 return false;
923 } 921 }
924 } 922 }
925 923
926 /** Fills an inputBuffer with the given index with data from the byte buffers. */ 924 /** Fills an inputBuffer with the given index with data from the byte buffers. */
927 private static native void nativeFillBuffer(long nativeEncoder, int inputBuffe r, ByteBuffer dataY, 925 private static native void nativeFillBuffer(long nativeEncoder, int inputBuffe r, ByteBuffer dataY,
928 int strideY, ByteBuffer dataU, int strideU, ByteBuffer dataV, int strideV) ; 926 int strideY, ByteBuffer dataU, int strideU, ByteBuffer dataV, int strideV) ;
929 } 927 }
OLDNEW
« no previous file with comments | « no previous file | webrtc/sdk/android/api/org/webrtc/RendererCommon.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698