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

Side by Side Diff: talk/app/webrtc/java/android/org/webrtc/SurfaceViewRenderer.java

Issue 1378033003: Android MediaCodecVideoDecoder: Manage lifetime of texture frames (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Add comment about disconnect() and synchronization Created 5 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 | talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.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 * libjingle 2 * libjingle
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 final VideoRenderer.I420Frame frame; 382 final VideoRenderer.I420Frame frame;
383 synchronized (frameLock) { 383 synchronized (frameLock) {
384 if (pendingFrame == null) { 384 if (pendingFrame == null) {
385 return; 385 return;
386 } 386 }
387 frame = pendingFrame; 387 frame = pendingFrame;
388 pendingFrame = null; 388 pendingFrame = null;
389 } 389 }
390 390
391 final long startTimeNs = System.nanoTime(); 391 final long startTimeNs = System.nanoTime();
392 final float[] samplingMatrix;
393 if (frame.yuvFrame) {
394 // The convention in WebRTC is that the first element in a ByteBuffer corr esponds to the
395 // top-left corner of the image, but in glTexImage2D() the first element c orresponds to the
396 // bottom-left corner. We correct this discrepancy by setting a vertical f lip as sampling
397 // matrix.
398 samplingMatrix = RendererCommon.verticalFlipMatrix();
399 } else {
400 // TODO(magjed): Move updateTexImage() to the video source instead.
401 SurfaceTexture surfaceTexture = (SurfaceTexture) frame.textureObject;
402 surfaceTexture.updateTexImage();
403 samplingMatrix = new float[16];
404 surfaceTexture.getTransformMatrix(samplingMatrix);
405 }
406
407 final float[] texMatrix; 392 final float[] texMatrix;
408 synchronized (layoutLock) { 393 synchronized (layoutLock) {
409 final float[] rotatedSamplingMatrix = 394 final float[] rotatedSamplingMatrix =
410 RendererCommon.rotateTextureMatrix(samplingMatrix, frame.rotationDegre e); 395 RendererCommon.rotateTextureMatrix(frame.samplingMatrix, frame.rotatio nDegree);
411 final float[] layoutMatrix = RendererCommon.getLayoutMatrix( 396 final float[] layoutMatrix = RendererCommon.getLayoutMatrix(
412 mirror, frameAspectRatio(), (float) layoutWidth / layoutHeight); 397 mirror, frameAspectRatio(), (float) layoutWidth / layoutHeight);
413 texMatrix = RendererCommon.multiplyMatrices(rotatedSamplingMatrix, layoutM atrix); 398 texMatrix = RendererCommon.multiplyMatrices(rotatedSamplingMatrix, layoutM atrix);
414 } 399 }
415 400
416 GLES20.glViewport(0, 0, surfaceWidth, surfaceHeight); 401 GLES20.glViewport(0, 0, surfaceWidth, surfaceHeight);
417 if (frame.yuvFrame) { 402 if (frame.yuvFrame) {
418 // Make sure YUV textures are allocated. 403 // Make sure YUV textures are allocated.
419 if (yuvTextures == null) { 404 if (yuvTextures == null) {
420 yuvTextures = new int[3]; 405 yuvTextures = new int[3];
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 if (framesReceived > 0 && framesRendered > 0) { 468 if (framesReceived > 0 && framesRendered > 0) {
484 final long timeSinceFirstFrameNs = System.nanoTime() - firstFrameTimeNs; 469 final long timeSinceFirstFrameNs = System.nanoTime() - firstFrameTimeNs;
485 Logging.d(TAG, "Duration: " + (int) (timeSinceFirstFrameNs / 1e6) + 470 Logging.d(TAG, "Duration: " + (int) (timeSinceFirstFrameNs / 1e6) +
486 " ms. FPS: " + (float) framesRendered * 1e9 / timeSinceFirstFrameNs) ; 471 " ms. FPS: " + (float) framesRendered * 1e9 / timeSinceFirstFrameNs) ;
487 Logging.d(TAG, "Average render time: " 472 Logging.d(TAG, "Average render time: "
488 + (int) (renderTimeNs / (1000 * framesRendered)) + " us."); 473 + (int) (renderTimeNs / (1000 * framesRendered)) + " us.");
489 } 474 }
490 } 475 }
491 } 476 }
492 } 477 }
OLDNEW
« no previous file with comments | « no previous file | talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698