Skip to content

Commit 850c2c3

Browse files
psanketiAndroid (Google) Code Review
authored andcommitted
Merge "Fixing the weird preview size w/ effects on camera" into jb-dev
2 parents 5d4d23e + b5af71f commit 850c2c3

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

media/mca/filterpacks/java/android/filterpacks/videosink/MediaEncoderFilter.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,6 @@ public boolean skipFrameAndModifyTimestamp(long timestampNs) {
376376

377377
@Override
378378
public void process(FilterContext context) {
379-
if (mLogVerbose) Log.v(TAG, "Starting frame processing");
380-
381379
GLEnvironment glEnv = context.getGLEnvironment();
382380
// Get input frame
383381
Frame input = pullInput("videoframe");

media/mca/filterpacks/java/android/filterpacks/videosrc/SurfaceTextureTarget.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ public synchronized void setupPorts() {
121121
}
122122

123123
public void updateRenderMode() {
124+
if (mLogVerbose) Log.v(TAG, "updateRenderMode. Thread: " + Thread.currentThread());
124125
if (mRenderModeString != null) {
125126
if (mRenderModeString.equals("stretch")) {
126127
mRenderMode = RENDERMODE_STRETCH;
@@ -139,6 +140,7 @@ public void updateRenderMode() {
139140

140141
@Override
141142
public void prepare(FilterContext context) {
143+
if (mLogVerbose) Log.v(TAG, "Prepare. Thread: " + Thread.currentThread());
142144
// Create identity shader to render, and make sure to render upside-down, as textures
143145
// are stored internally bottom-to-top.
144146
mProgram = ShaderProgram.createIdentity(context);
@@ -214,8 +216,10 @@ public synchronized void process(FilterContext context) {
214216
float currentAspectRatio =
215217
(float)input.getFormat().getWidth() / input.getFormat().getHeight();
216218
if (currentAspectRatio != mAspectRatio) {
217-
if (mLogVerbose) Log.v(TAG, "New aspect ratio: " + currentAspectRatio +
218-
", previously: " + mAspectRatio);
219+
if (mLogVerbose) {
220+
Log.v(TAG, "Process. New aspect ratio: " + currentAspectRatio +
221+
", previously: " + mAspectRatio + ". Thread: " + Thread.currentThread());
222+
}
219223
mAspectRatio = currentAspectRatio;
220224
updateTargetRect();
221225
}
@@ -249,6 +253,7 @@ public synchronized void process(FilterContext context) {
249253

250254
@Override
251255
public void fieldPortValueUpdated(String name, FilterContext context) {
256+
if (mLogVerbose) Log.v(TAG, "FPVU. Thread: " + Thread.currentThread());
252257
updateRenderMode();
253258
}
254259

@@ -260,16 +265,22 @@ public void tearDown(FilterContext context) {
260265
}
261266

262267
private void updateTargetRect() {
268+
if (mLogVerbose) Log.v(TAG, "updateTargetRect. Thread: " + Thread.currentThread());
263269
if (mScreenWidth > 0 && mScreenHeight > 0 && mProgram != null) {
264270
float screenAspectRatio = (float)mScreenWidth / mScreenHeight;
265271
float relativeAspectRatio = screenAspectRatio / mAspectRatio;
272+
if (mLogVerbose) {
273+
Log.v(TAG, "UTR. screen w = " + (float)mScreenWidth + " x screen h = " +
274+
(float)mScreenHeight + " Screen AR: " + screenAspectRatio +
275+
", frame AR: " + mAspectRatio + ", relative AR: " + relativeAspectRatio);
276+
}
266277

267278
if (relativeAspectRatio == 1.0f && mRenderMode != RENDERMODE_CUSTOMIZE) {
279+
mProgram.setTargetRect(0, 0, 1, 1);
268280
mProgram.setClearsOutput(false);
269281
} else {
270282
switch (mRenderMode) {
271283
case RENDERMODE_STRETCH:
272-
mProgram.setTargetRect(0, 0, 1, 1);
273284
mTargetQuad.p0.set(0f, 0.0f);
274285
mTargetQuad.p1.set(1f, 0.0f);
275286
mTargetQuad.p2.set(0f, 1.0f);
@@ -313,6 +324,7 @@ private void updateTargetRect() {
313324
((ShaderProgram) mProgram).setSourceRegion(mSourceQuad);
314325
break;
315326
}
327+
if (mLogVerbose) Log.v(TAG, "UTR. quad: " + mTargetQuad);
316328
((ShaderProgram) mProgram).setTargetRegion(mTargetQuad);
317329
}
318330
}

0 commit comments

Comments
 (0)