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

Side by Side Diff: sdk/android/src/java/org/webrtc/HardwareVideoEncoder.java

Issue 3013903002: Slice video frame buffers before copying data from them into the encoder's input buffer (Closed)
Patch Set: Created 3 years, 2 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 | no next file » | 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 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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 } 535 }
536 } 536 }
537 537
538 /** 538 /**
539 * Enumeration of supported color formats used for MediaCodec's input. 539 * Enumeration of supported color formats used for MediaCodec's input.
540 */ 540 */
541 private static enum ColorFormat { 541 private static enum ColorFormat {
542 I420 { 542 I420 {
543 @Override 543 @Override
544 void fillBufferFromI420(ByteBuffer buffer, VideoFrame.I420Buffer i420) { 544 void fillBufferFromI420(ByteBuffer buffer, VideoFrame.I420Buffer i420) {
545 buffer.put(i420.getDataY()); 545 buffer.put(i420.getDataY().slice());
sakal 2017/09/28 07:43:53 Hmm, I think it is better to fix this at the Video
mellem 2017/09/28 17:02:39 Yes, I like that idea even better. I'll just aban
546 buffer.put(i420.getDataU()); 546 buffer.put(i420.getDataU().slice());
547 buffer.put(i420.getDataV()); 547 buffer.put(i420.getDataV().slice());
548 } 548 }
549 }, 549 },
550 NV12 { 550 NV12 {
551 @Override 551 @Override
552 void fillBufferFromI420(ByteBuffer buffer, VideoFrame.I420Buffer i420) { 552 void fillBufferFromI420(ByteBuffer buffer, VideoFrame.I420Buffer i420) {
553 buffer.put(i420.getDataY()); 553 buffer.put(i420.getDataY().slice());
554 554
555 // Interleave the bytes from the U and V portions, starting with U. 555 // Interleave the bytes from the U and V portions, starting with U.
556 ByteBuffer u = i420.getDataU(); 556 ByteBuffer u = i420.getDataU().slice();
557 ByteBuffer v = i420.getDataV(); 557 ByteBuffer v = i420.getDataV().slice();
558 int i = 0; 558 int i = 0;
559 while (u.hasRemaining() && v.hasRemaining()) { 559 while (u.hasRemaining() && v.hasRemaining()) {
560 buffer.put(u.get()); 560 buffer.put(u.get());
561 buffer.put(v.get()); 561 buffer.put(v.get());
562 } 562 }
563 } 563 }
564 }; 564 };
565 565
566 abstract void fillBufferFromI420(ByteBuffer buffer, VideoFrame.I420Buffer i4 20); 566 abstract void fillBufferFromI420(ByteBuffer buffer, VideoFrame.I420Buffer i4 20);
567 567
568 static ColorFormat valueOf(int colorFormat) { 568 static ColorFormat valueOf(int colorFormat) {
569 switch (colorFormat) { 569 switch (colorFormat) {
570 case MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar: 570 case MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar:
571 return I420; 571 return I420;
572 case MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420SemiPlanar: 572 case MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420SemiPlanar:
573 case MediaCodecInfo.CodecCapabilities.COLOR_QCOM_FormatYUV420SemiPlanar: 573 case MediaCodecInfo.CodecCapabilities.COLOR_QCOM_FormatYUV420SemiPlanar:
574 case MediaCodecUtils.COLOR_QCOM_FORMATYUV420PackedSemiPlanar32m: 574 case MediaCodecUtils.COLOR_QCOM_FORMATYUV420PackedSemiPlanar32m:
575 return NV12; 575 return NV12;
576 default: 576 default:
577 throw new IllegalArgumentException("Unsupported colorFormat: " + color Format); 577 throw new IllegalArgumentException("Unsupported colorFormat: " + color Format);
578 } 578 }
579 } 579 }
580 } 580 }
581 } 581 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698