Move playback tests outside of performance directory
PiperOrigin-RevId: 658055853
This commit is contained in:
parent
40de898b22
commit
ffc45820b9
Binary file not shown.
Before Width: | Height: | Size: 526 KiB After Width: | Height: | Size: 527 KiB |
@ -327,15 +327,15 @@ public class BitmapPixelTestUtil {
|
||||
}
|
||||
int alphaDifference = abs(Color.alpha(actualColor) - Color.alpha(expectedColor));
|
||||
int redDifference = abs(Color.red(actualColor) - Color.red(expectedColor));
|
||||
int blueDifference = abs(Color.blue(actualColor) - Color.blue(expectedColor));
|
||||
int greenDifference = abs(Color.green(actualColor) - Color.green(expectedColor));
|
||||
differencesBitmap.setPixel(x, y, Color.rgb(redDifference, blueDifference, greenDifference));
|
||||
int blueDifference = abs(Color.blue(actualColor) - Color.blue(expectedColor));
|
||||
differencesBitmap.setPixel(x, y, Color.rgb(redDifference, greenDifference, blueDifference));
|
||||
|
||||
int maximumAbsoluteDifference = 0;
|
||||
maximumAbsoluteDifference = max(maximumAbsoluteDifference, alphaDifference);
|
||||
maximumAbsoluteDifference = max(maximumAbsoluteDifference, redDifference);
|
||||
maximumAbsoluteDifference = max(maximumAbsoluteDifference, blueDifference);
|
||||
maximumAbsoluteDifference = max(maximumAbsoluteDifference, greenDifference);
|
||||
maximumAbsoluteDifference = max(maximumAbsoluteDifference, blueDifference);
|
||||
|
||||
sumMaximumAbsoluteDifferences += maximumAbsoluteDifference;
|
||||
}
|
||||
|
@ -31,10 +31,16 @@ import static org.junit.Assume.assumeFalse;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap.Config;
|
||||
import android.graphics.Color;
|
||||
import android.media.Image;
|
||||
import android.media.MediaFormat;
|
||||
import android.opengl.EGLContext;
|
||||
import android.opengl.EGLDisplay;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.AbsoluteSizeSpan;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.text.style.TypefaceSpan;
|
||||
import android.util.Pair;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.media3.common.C;
|
||||
@ -47,7 +53,9 @@ import androidx.media3.common.util.Log;
|
||||
import androidx.media3.common.util.MediaFormatUtil;
|
||||
import androidx.media3.common.util.Util;
|
||||
import androidx.media3.effect.DefaultGlObjectsProvider;
|
||||
import androidx.media3.effect.OverlayEffect;
|
||||
import androidx.media3.effect.ScaleAndRotateTransformation;
|
||||
import androidx.media3.effect.TextOverlay;
|
||||
import androidx.media3.exoplayer.mediacodec.MediaCodecUtil;
|
||||
import androidx.media3.test.utils.BitmapPixelTestUtil;
|
||||
import androidx.media3.test.utils.VideoDecodingWrapper;
|
||||
@ -930,6 +938,34 @@ public final class AndroidTestUtil {
|
||||
return eglContext;
|
||||
}
|
||||
|
||||
/** Creates an {@link OverlayEffect} that draws the timestamp onto frames. */
|
||||
public static OverlayEffect createTimestampOverlay() {
|
||||
return new OverlayEffect(
|
||||
ImmutableList.of(
|
||||
new TextOverlay() {
|
||||
@Override
|
||||
public SpannableString getText(long presentationTimeUs) {
|
||||
SpannableString text = new SpannableString(String.valueOf(presentationTimeUs));
|
||||
text.setSpan(
|
||||
new ForegroundColorSpan(Color.WHITE),
|
||||
/* start= */ 0,
|
||||
text.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
text.setSpan(
|
||||
new AbsoluteSizeSpan(/* size= */ 96),
|
||||
/* start= */ 0,
|
||||
text.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
text.setSpan(
|
||||
new TypefaceSpan(/* family= */ "sans-serif"),
|
||||
/* start= */ 0,
|
||||
text.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
return text;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a {@linkplain android.opengl.GLES10#GL_TEXTURE_2D traditional GLES texture} from the
|
||||
* given bitmap.
|
||||
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package androidx.media3.transformer.mh.performance;
|
||||
package androidx.media3.transformer;
|
||||
|
||||
import static androidx.media3.test.utils.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE;
|
||||
import static androidx.media3.test.utils.BitmapPixelTestUtil.createArgb8888BitmapFromRgba8888Image;
|
||||
@ -22,7 +22,7 @@ import static androidx.media3.test.utils.BitmapPixelTestUtil.getBitmapAveragePix
|
||||
import static androidx.media3.test.utils.BitmapPixelTestUtil.readBitmap;
|
||||
import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET;
|
||||
import static androidx.media3.transformer.AndroidTestUtil.PNG_ASSET;
|
||||
import static androidx.media3.transformer.mh.performance.PlaybackTestUtil.createTimestampOverlay;
|
||||
import static androidx.media3.transformer.AndroidTestUtil.createTimestampOverlay;
|
||||
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
@ -38,13 +38,6 @@ import androidx.media3.common.util.ConditionVariable;
|
||||
import androidx.media3.common.util.Size;
|
||||
import androidx.media3.common.util.Util;
|
||||
import androidx.media3.effect.GlEffect;
|
||||
import androidx.media3.transformer.Composition;
|
||||
import androidx.media3.transformer.CompositionPlayer;
|
||||
import androidx.media3.transformer.EditedMediaItem;
|
||||
import androidx.media3.transformer.EditedMediaItemSequence;
|
||||
import androidx.media3.transformer.Effects;
|
||||
import androidx.media3.transformer.InputTimestampRecordingShaderProgram;
|
||||
import androidx.media3.transformer.PlayerTestListener;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package androidx.media3.transformer.mh.performance;
|
||||
package androidx.media3.transformer;
|
||||
|
||||
import static androidx.media3.common.Player.STATE_ENDED;
|
||||
import static androidx.media3.common.util.Assertions.checkNotNull;
|
||||
@ -25,7 +25,7 @@ import static androidx.media3.test.utils.BitmapPixelTestUtil.createArgb8888Bitma
|
||||
import static androidx.media3.test.utils.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888;
|
||||
import static androidx.media3.test.utils.BitmapPixelTestUtil.readBitmap;
|
||||
import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET;
|
||||
import static androidx.media3.transformer.mh.performance.PlaybackTestUtil.createTimestampOverlay;
|
||||
import static androidx.media3.transformer.AndroidTestUtil.createTimestampOverlay;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static org.junit.Assume.assumeTrue;
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package androidx.media3.transformer.mh.performance;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.AbsoluteSizeSpan;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.text.style.TypefaceSpan;
|
||||
import androidx.media3.effect.OverlayEffect;
|
||||
import androidx.media3.effect.TextOverlay;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
/** Utilities for playback tests. */
|
||||
/* package */ final class PlaybackTestUtil {
|
||||
|
||||
private PlaybackTestUtil() {}
|
||||
|
||||
/** Creates an {@link OverlayEffect} that draws the timestamp onto frames. */
|
||||
public static OverlayEffect createTimestampOverlay() {
|
||||
return new OverlayEffect(
|
||||
ImmutableList.of(
|
||||
new TextOverlay() {
|
||||
@Override
|
||||
public SpannableString getText(long presentationTimeUs) {
|
||||
SpannableString text = new SpannableString(String.valueOf(presentationTimeUs));
|
||||
text.setSpan(
|
||||
new ForegroundColorSpan(Color.WHITE),
|
||||
/* start= */ 0,
|
||||
text.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
text.setSpan(
|
||||
new AbsoluteSizeSpan(/* size= */ 96),
|
||||
/* start= */ 0,
|
||||
text.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
text.setSpan(
|
||||
new TypefaceSpan(/* family= */ "sans-serif"),
|
||||
/* start= */ 0,
|
||||
text.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
return text;
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user