Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4a3d693c
authored
Dec 15, 2022
by
claincly
Committed by
Tianyi Feng
Dec 21, 2022
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Replace Pair with Size in effects.
PiperOrigin-RevId: 495646341
parent
33f8f406
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
225 additions
and
228 deletions
demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/BitmapOverlayProcessor.java
demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/PeriodicVignetteProcessor.java
library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/ContrastPixelTest.java
library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/CropPixelTest.java
library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessorPixelTest.java
library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/HslAdjustmentPixelTest.java
library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/OverlayTextureProcessorPixelTest.java
library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/PresentationPixelTest.java
library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/RgbAdjustmentPixelTest.java
library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/RgbFilterPixelTest.java
library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/SingleColorLutPixelTest.java
library/effect/src/main/java/com/google/android/exoplayer2/effect/BitmapOverlay.java
library/effect/src/main/java/com/google/android/exoplayer2/effect/ColorLutProcessor.java
library/effect/src/main/java/com/google/android/exoplayer2/effect/ContrastProcessor.java
library/effect/src/main/java/com/google/android/exoplayer2/effect/Crop.java
library/effect/src/main/java/com/google/android/exoplayer2/effect/FinalMatrixTextureProcessorWrapper.java
library/effect/src/main/java/com/google/android/exoplayer2/effect/GlMatrixTransformation.java
library/effect/src/main/java/com/google/android/exoplayer2/effect/HslProcessor.java
library/effect/src/main/java/com/google/android/exoplayer2/effect/MatrixTextureProcessor.java
library/effect/src/main/java/com/google/android/exoplayer2/effect/MatrixUtils.java
library/effect/src/main/java/com/google/android/exoplayer2/effect/OverlayTextureProcessor.java
library/effect/src/main/java/com/google/android/exoplayer2/effect/Presentation.java
library/effect/src/main/java/com/google/android/exoplayer2/effect/ScaleToFitTransformation.java
library/effect/src/main/java/com/google/android/exoplayer2/effect/SingleFrameGlTextureProcessor.java
library/effect/src/main/java/com/google/android/exoplayer2/effect/TextureOverlay.java
library/effect/src/test/java/com/google/android/exoplayer2/effect/CropTest.java
library/effect/src/test/java/com/google/android/exoplayer2/effect/PresentationTest.java
library/effect/src/test/java/com/google/android/exoplayer2/effect/ScaleToFitTransformationTest.java
demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/BitmapOverlayProcessor.java
View file @
4a3d693c
...
@@ -28,12 +28,12 @@ import android.graphics.Paint;
...
@@ -28,12 +28,12 @@ import android.graphics.Paint;
import
android.graphics.drawable.BitmapDrawable
;
import
android.graphics.drawable.BitmapDrawable
;
import
android.opengl.GLES20
;
import
android.opengl.GLES20
;
import
android.opengl.GLUtils
;
import
android.opengl.GLUtils
;
import
android.util.Pair
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.effect.SingleFrameGlTextureProcessor
;
import
com.google.android.exoplayer2.effect.SingleFrameGlTextureProcessor
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.GlProgram
;
import
com.google.android.exoplayer2.util.GlProgram
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.Size
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Locale
;
import
java.util.Locale
;
...
@@ -111,7 +111,7 @@ import java.util.Locale;
...
@@ -111,7 +111,7 @@ import java.util.Locale;
}
}
@Override
@Override
public
Pair
<
Integer
,
Integer
>
configure
(
int
inputWidth
,
int
inputHeight
)
{
public
Size
configure
(
int
inputWidth
,
int
inputHeight
)
{
if
(
inputWidth
>
inputHeight
)
{
if
(
inputWidth
>
inputHeight
)
{
bitmapScaleX
=
inputWidth
/
(
float
)
inputHeight
;
bitmapScaleX
=
inputWidth
/
(
float
)
inputHeight
;
bitmapScaleY
=
1
f
;
bitmapScaleY
=
1
f
;
...
@@ -123,7 +123,7 @@ import java.util.Locale;
...
@@ -123,7 +123,7 @@ import java.util.Locale;
glProgram
.
setFloatUniform
(
"uScaleX"
,
bitmapScaleX
);
glProgram
.
setFloatUniform
(
"uScaleX"
,
bitmapScaleX
);
glProgram
.
setFloatUniform
(
"uScaleY"
,
bitmapScaleY
);
glProgram
.
setFloatUniform
(
"uScaleY"
,
bitmapScaleY
);
return
Pair
.
creat
e
(
inputWidth
,
inputHeight
);
return
new
Siz
e
(
inputWidth
,
inputHeight
);
}
}
@Override
@Override
...
...
demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/PeriodicVignetteProcessor.java
View file @
4a3d693c
...
@@ -19,11 +19,11 @@ import static com.google.android.exoplayer2.util.Assertions.checkArgument;
...
@@ -19,11 +19,11 @@ import static com.google.android.exoplayer2.util.Assertions.checkArgument;
import
android.content.Context
;
import
android.content.Context
;
import
android.opengl.GLES20
;
import
android.opengl.GLES20
;
import
android.util.Pair
;
import
com.google.android.exoplayer2.effect.SingleFrameGlTextureProcessor
;
import
com.google.android.exoplayer2.effect.SingleFrameGlTextureProcessor
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.GlProgram
;
import
com.google.android.exoplayer2.util.GlProgram
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.Size
;
import
java.io.IOException
;
import
java.io.IOException
;
/**
/**
...
@@ -90,8 +90,8 @@ import java.io.IOException;
...
@@ -90,8 +90,8 @@ import java.io.IOException;
}
}
@Override
@Override
public
Pair
<
Integer
,
Integer
>
configure
(
int
inputWidth
,
int
inputHeight
)
{
public
Size
configure
(
int
inputWidth
,
int
inputHeight
)
{
return
Pair
.
creat
e
(
inputWidth
,
inputHeight
);
return
new
Siz
e
(
inputWidth
,
inputHeight
);
}
}
@Override
@Override
...
...
library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/ContrastPixelTest.java
View file @
4a3d693c
...
@@ -33,10 +33,10 @@ import android.graphics.Color;
...
@@ -33,10 +33,10 @@ import android.graphics.Color;
import
android.opengl.EGLContext
;
import
android.opengl.EGLContext
;
import
android.opengl.EGLDisplay
;
import
android.opengl.EGLDisplay
;
import
android.opengl.EGLSurface
;
import
android.opengl.EGLSurface
;
import
android.util.Pair
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.Size
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
import
org.junit.After
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Before
;
...
@@ -100,13 +100,13 @@ public class ContrastPixelTest {
...
@@ -100,13 +100,13 @@ public class ContrastPixelTest {
String
testId
=
"drawFrame_noContrastChange"
;
String
testId
=
"drawFrame_noContrastChange"
;
contrastProcessor
=
contrastProcessor
=
new
Contrast
(
/* contrast= */
0.0f
).
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
new
Contrast
(
/* contrast= */
0.0f
).
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
contrastProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
contrastProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
contrastProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
contrastProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -119,8 +119,8 @@ public class ContrastPixelTest {
...
@@ -119,8 +119,8 @@ public class ContrastPixelTest {
String
testId
=
"drawFrame_minimumContrast"
;
String
testId
=
"drawFrame_minimumContrast"
;
contrastProcessor
=
contrastProcessor
=
new
Contrast
(
/* contrast= */
-
1.0f
).
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
new
Contrast
(
/* contrast= */
-
1.0f
).
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
contrastProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
contrastProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
Bitmap
expectedBitmap
=
createArgb8888BitmapWithSolidColor
(
createArgb8888BitmapWithSolidColor
(
inputWidth
,
inputWidth
,
...
@@ -130,7 +130,7 @@ public class ContrastPixelTest {
...
@@ -130,7 +130,7 @@ public class ContrastPixelTest {
contrastProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
contrastProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -144,13 +144,13 @@ public class ContrastPixelTest {
...
@@ -144,13 +144,13 @@ public class ContrastPixelTest {
String
testId
=
"drawFrame_decreaseContrast"
;
String
testId
=
"drawFrame_decreaseContrast"
;
contrastProcessor
=
contrastProcessor
=
new
Contrast
(
/* contrast= */
-
0.75f
).
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
new
Contrast
(
/* contrast= */
-
0.75f
).
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
contrastProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
contrastProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
readBitmap
(
DECREASE_CONTRAST_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
DECREASE_CONTRAST_PNG_ASSET_PATH
);
contrastProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
contrastProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -164,13 +164,13 @@ public class ContrastPixelTest {
...
@@ -164,13 +164,13 @@ public class ContrastPixelTest {
String
testId
=
"drawFrame_increaseContrast"
;
String
testId
=
"drawFrame_increaseContrast"
;
contrastProcessor
=
contrastProcessor
=
new
Contrast
(
/* contrast= */
0.75f
).
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
new
Contrast
(
/* contrast= */
0.75f
).
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
contrastProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
contrastProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
readBitmap
(
INCREASE_CONTRAST_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
INCREASE_CONTRAST_PNG_ASSET_PATH
);
contrastProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
contrastProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -183,13 +183,13 @@ public class ContrastPixelTest {
...
@@ -183,13 +183,13 @@ public class ContrastPixelTest {
String
testId
=
"drawFrame_maximumContrast"
;
String
testId
=
"drawFrame_maximumContrast"
;
contrastProcessor
=
contrastProcessor
=
new
Contrast
(
/* contrast= */
1.0f
).
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
new
Contrast
(
/* contrast= */
1.0f
).
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
contrastProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
contrastProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
readBitmap
(
MAXIMUM_CONTRAST_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
MAXIMUM_CONTRAST_PNG_ASSET_PATH
);
contrastProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
contrastProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
...
library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/CropPixelTest.java
View file @
4a3d693c
...
@@ -30,10 +30,10 @@ import android.graphics.Bitmap;
...
@@ -30,10 +30,10 @@ import android.graphics.Bitmap;
import
android.opengl.EGLContext
;
import
android.opengl.EGLContext
;
import
android.opengl.EGLDisplay
;
import
android.opengl.EGLDisplay
;
import
android.opengl.EGLSurface
;
import
android.opengl.EGLSurface
;
import
android.util.Pair
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.Size
;
import
java.io.IOException
;
import
java.io.IOException
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
import
org.junit.After
;
import
org.junit.After
;
...
@@ -96,13 +96,13 @@ public final class CropPixelTest {
...
@@ -96,13 +96,13 @@ public final class CropPixelTest {
cropTextureProcessor
=
cropTextureProcessor
=
new
Crop
(
/* left= */
-
1
,
/* right= */
1
,
/* bottom= */
-
1
,
/* top= */
1
)
new
Crop
(
/* left= */
-
1
,
/* right= */
1
,
/* bottom= */
-
1
,
/* top= */
1
)
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
cropTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
cropTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
cropTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
cropTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
...
@@ -117,13 +117,13 @@ public final class CropPixelTest {
...
@@ -117,13 +117,13 @@ public final class CropPixelTest {
cropTextureProcessor
=
cropTextureProcessor
=
new
Crop
(
/* left= */
-.
9
f
,
/* right= */
.
1
f
,
/* bottom= */
-
1
f
,
/* top= */
.
5
f
)
new
Crop
(
/* left= */
-.
9
f
,
/* right= */
.
1
f
,
/* bottom= */
-
1
f
,
/* top= */
.
5
f
)
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
cropTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
cropTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
readBitmap
(
CROP_SMALLER_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
CROP_SMALLER_PNG_ASSET_PATH
);
cropTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
cropTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
...
@@ -138,13 +138,13 @@ public final class CropPixelTest {
...
@@ -138,13 +138,13 @@ public final class CropPixelTest {
cropTextureProcessor
=
cropTextureProcessor
=
new
Crop
(
/* left= */
-
2
f
,
/* right= */
2
f
,
/* bottom= */
-
1
f
,
/* top= */
2
f
)
new
Crop
(
/* left= */
-
2
f
,
/* right= */
2
f
,
/* bottom= */
-
1
f
,
/* top= */
2
f
)
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
cropTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
cropTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
readBitmap
(
CROP_LARGER_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
CROP_LARGER_PNG_ASSET_PATH
);
cropTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
cropTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
...
...
library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessorPixelTest.java
View file @
4a3d693c
...
@@ -33,7 +33,6 @@ import android.graphics.PixelFormat;
...
@@ -33,7 +33,6 @@ import android.graphics.PixelFormat;
import
android.media.Image
;
import
android.media.Image
;
import
android.media.ImageReader
;
import
android.media.ImageReader
;
import
android.media.MediaFormat
;
import
android.media.MediaFormat
;
import
android.util.Pair
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.testutil.DecodeOneFrameUtil
;
import
com.google.android.exoplayer2.testutil.DecodeOneFrameUtil
;
...
@@ -42,6 +41,7 @@ import com.google.android.exoplayer2.util.Effect;
...
@@ -42,6 +41,7 @@ import com.google.android.exoplayer2.util.Effect;
import
com.google.android.exoplayer2.util.FrameInfo
;
import
com.google.android.exoplayer2.util.FrameInfo
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.FrameProcessor
;
import
com.google.android.exoplayer2.util.FrameProcessor
;
import
com.google.android.exoplayer2.util.Size
;
import
com.google.android.exoplayer2.util.SurfaceInfo
;
import
com.google.android.exoplayer2.util.SurfaceInfo
;
import
com.google.android.exoplayer2.video.ColorInfo
;
import
com.google.android.exoplayer2.video.ColorInfo
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableList
;
...
@@ -547,14 +547,14 @@ public final class GlEffectsFrameProcessorPixelTest {
...
@@ -547,14 +547,14 @@ public final class GlEffectsFrameProcessorPixelTest {
}
}
@Override
@Override
public
Pair
<
Integer
,
Integer
>
configure
(
int
inputWidth
,
int
inputHeight
)
{
public
Size
configure
(
int
inputWidth
,
int
inputHeight
)
{
adjustedTransformationMatrix
=
new
Matrix
();
adjustedTransformationMatrix
=
new
Matrix
();
adjustedTransformationMatrix
.
postRotate
(
degrees
);
adjustedTransformationMatrix
.
postRotate
(
degrees
);
float
inputAspectRatio
=
(
float
)
inputWidth
/
inputHeight
;
float
inputAspectRatio
=
(
float
)
inputWidth
/
inputHeight
;
adjustedTransformationMatrix
.
preScale
(
/* sx= */
inputAspectRatio
,
/* sy= */
1
f
);
adjustedTransformationMatrix
.
preScale
(
/* sx= */
inputAspectRatio
,
/* sy= */
1
f
);
adjustedTransformationMatrix
.
postScale
(
/* sx= */
1
f
/
inputAspectRatio
,
/* sy= */
1
f
);
adjustedTransformationMatrix
.
postScale
(
/* sx= */
1
f
/
inputAspectRatio
,
/* sy= */
1
f
);
return
Pair
.
creat
e
(
inputWidth
,
inputHeight
);
return
new
Siz
e
(
inputWidth
,
inputHeight
);
}
}
@Override
@Override
...
...
library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/HslAdjustmentPixelTest.java
View file @
4a3d693c
This diff is collapsed.
Click to expand it.
library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/OverlayTextureProcessorPixelTest.java
View file @
4a3d693c
...
@@ -35,10 +35,10 @@ import android.opengl.Matrix;
...
@@ -35,10 +35,10 @@ import android.opengl.Matrix;
import
android.text.Spannable
;
import
android.text.Spannable
;
import
android.text.SpannableString
;
import
android.text.SpannableString
;
import
android.text.style.ForegroundColorSpan
;
import
android.text.style.ForegroundColorSpan
;
import
android.util.Pair
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.Size
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableList
;
import
java.io.IOException
;
import
java.io.IOException
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
...
@@ -107,13 +107,13 @@ public class OverlayTextureProcessorPixelTest {
...
@@ -107,13 +107,13 @@ public class OverlayTextureProcessorPixelTest {
overlayTextureProcessor
=
overlayTextureProcessor
=
new
OverlayEffect
(
/* textureOverlays= */
ImmutableList
.
of
())
new
OverlayEffect
(
/* textureOverlays= */
ImmutableList
.
of
())
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
overlayTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
overlayTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
overlayTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
overlayTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -129,13 +129,13 @@ public class OverlayTextureProcessorPixelTest {
...
@@ -129,13 +129,13 @@ public class OverlayTextureProcessorPixelTest {
overlayTextureProcessor
=
overlayTextureProcessor
=
new
OverlayEffect
(
ImmutableList
.
of
(
scaledBitmapOverlay
))
new
OverlayEffect
(
ImmutableList
.
of
(
scaledBitmapOverlay
))
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
overlayTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
overlayTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
readBitmap
(
OVERLAY_BITMAP_DEFAULT
);
Bitmap
expectedBitmap
=
readBitmap
(
OVERLAY_BITMAP_DEFAULT
);
overlayTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
overlayTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -155,13 +155,13 @@ public class OverlayTextureProcessorPixelTest {
...
@@ -155,13 +155,13 @@ public class OverlayTextureProcessorPixelTest {
overlayTextureProcessor
=
overlayTextureProcessor
=
new
OverlayEffect
(
ImmutableList
.
of
(
staticBitmapOverlay
))
new
OverlayEffect
(
ImmutableList
.
of
(
staticBitmapOverlay
))
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
overlayTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
overlayTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
readBitmap
(
OVERLAY_BITMAP_SCALED
);
Bitmap
expectedBitmap
=
readBitmap
(
OVERLAY_BITMAP_SCALED
);
overlayTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
overlayTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -179,13 +179,13 @@ public class OverlayTextureProcessorPixelTest {
...
@@ -179,13 +179,13 @@ public class OverlayTextureProcessorPixelTest {
overlayTextureProcessor
=
overlayTextureProcessor
=
new
OverlayEffect
(
ImmutableList
.
of
(
translucentBitmapOverlay
))
new
OverlayEffect
(
ImmutableList
.
of
(
translucentBitmapOverlay
))
.
toGlTextureProcessor
(
context
,
false
);
.
toGlTextureProcessor
(
context
,
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
overlayTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
overlayTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
readBitmap
(
OVERLAY_BITMAP_TRANSLUCENT
);
Bitmap
expectedBitmap
=
readBitmap
(
OVERLAY_BITMAP_TRANSLUCENT
);
overlayTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
overlayTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -208,13 +208,13 @@ public class OverlayTextureProcessorPixelTest {
...
@@ -208,13 +208,13 @@ public class OverlayTextureProcessorPixelTest {
overlayTextureProcessor
=
overlayTextureProcessor
=
new
OverlayEffect
(
ImmutableList
.
of
(
staticTextOverlay
))
new
OverlayEffect
(
ImmutableList
.
of
(
staticTextOverlay
))
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
overlayTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
overlayTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
overlayTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
overlayTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -235,13 +235,13 @@ public class OverlayTextureProcessorPixelTest {
...
@@ -235,13 +235,13 @@ public class OverlayTextureProcessorPixelTest {
overlayTextureProcessor
=
overlayTextureProcessor
=
new
OverlayEffect
(
ImmutableList
.
of
(
staticTextOverlay
))
new
OverlayEffect
(
ImmutableList
.
of
(
staticTextOverlay
))
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
overlayTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
overlayTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
readBitmap
(
OVERLAY_TEXT_DEFAULT
);
Bitmap
expectedBitmap
=
readBitmap
(
OVERLAY_TEXT_DEFAULT
);
overlayTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
overlayTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -267,13 +267,13 @@ public class OverlayTextureProcessorPixelTest {
...
@@ -267,13 +267,13 @@ public class OverlayTextureProcessorPixelTest {
overlayTextureProcessor
=
overlayTextureProcessor
=
new
OverlayEffect
(
ImmutableList
.
of
(
staticTextOverlay
))
new
OverlayEffect
(
ImmutableList
.
of
(
staticTextOverlay
))
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
overlayTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
overlayTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
readBitmap
(
OVERLAY_TEXT_TRANSLATE
);
Bitmap
expectedBitmap
=
readBitmap
(
OVERLAY_TEXT_TRANSLATE
);
overlayTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
overlayTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
...
library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/PresentationPixelTest.java
View file @
4a3d693c
...
@@ -30,11 +30,11 @@ import android.graphics.Bitmap;
...
@@ -30,11 +30,11 @@ import android.graphics.Bitmap;
import
android.opengl.EGLContext
;
import
android.opengl.EGLContext
;
import
android.opengl.EGLDisplay
;
import
android.opengl.EGLDisplay
;
import
android.opengl.EGLSurface
;
import
android.opengl.EGLSurface
;
import
android.util.Pair
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.Size
;
import
java.io.IOException
;
import
java.io.IOException
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
import
org.junit.After
;
import
org.junit.After
;
...
@@ -105,14 +105,13 @@ public final class PresentationPixelTest {
...
@@ -105,14 +105,13 @@ public final class PresentationPixelTest {
presentationTextureProcessor
=
presentationTextureProcessor
=
Presentation
.
createForHeight
(
C
.
LENGTH_UNSET
)
Presentation
.
createForHeight
(
C
.
LENGTH_UNSET
)
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
Size
outputSize
=
presentationTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
presentationTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
());
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
presentationTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
presentationTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
...
@@ -128,14 +127,13 @@ public final class PresentationPixelTest {
...
@@ -128,14 +127,13 @@ public final class PresentationPixelTest {
presentationTextureProcessor
=
presentationTextureProcessor
=
Presentation
.
createForAspectRatio
(
/* aspectRatio= */
1
f
,
Presentation
.
LAYOUT_SCALE_TO_FIT
)
Presentation
.
createForAspectRatio
(
/* aspectRatio= */
1
f
,
Presentation
.
LAYOUT_SCALE_TO_FIT
)
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
Size
outputSize
=
presentationTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
presentationTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
());
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
Bitmap
expectedBitmap
=
readBitmap
(
ASPECT_RATIO_SCALE_TO_FIT_NARROW_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
ASPECT_RATIO_SCALE_TO_FIT_NARROW_PNG_ASSET_PATH
);
presentationTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
presentationTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
...
@@ -151,14 +149,13 @@ public final class PresentationPixelTest {
...
@@ -151,14 +149,13 @@ public final class PresentationPixelTest {
presentationTextureProcessor
=
presentationTextureProcessor
=
Presentation
.
createForAspectRatio
(
/* aspectRatio= */
2
f
,
Presentation
.
LAYOUT_SCALE_TO_FIT
)
Presentation
.
createForAspectRatio
(
/* aspectRatio= */
2
f
,
Presentation
.
LAYOUT_SCALE_TO_FIT
)
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
Size
outputSize
=
presentationTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
presentationTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
());
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
Bitmap
expectedBitmap
=
readBitmap
(
ASPECT_RATIO_SCALE_TO_FIT_WIDE_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
ASPECT_RATIO_SCALE_TO_FIT_WIDE_PNG_ASSET_PATH
);
presentationTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
presentationTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
...
@@ -175,14 +172,13 @@ public final class PresentationPixelTest {
...
@@ -175,14 +172,13 @@ public final class PresentationPixelTest {
Presentation
.
createForAspectRatio
(
Presentation
.
createForAspectRatio
(
/* aspectRatio= */
1
f
,
Presentation
.
LAYOUT_SCALE_TO_FIT_WITH_CROP
)
/* aspectRatio= */
1
f
,
Presentation
.
LAYOUT_SCALE_TO_FIT_WITH_CROP
)
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
Size
outputSize
=
presentationTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
presentationTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
());
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
Bitmap
expectedBitmap
=
readBitmap
(
ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_NARROW_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_NARROW_PNG_ASSET_PATH
);
presentationTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
presentationTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
...
@@ -199,14 +195,13 @@ public final class PresentationPixelTest {
...
@@ -199,14 +195,13 @@ public final class PresentationPixelTest {
Presentation
.
createForAspectRatio
(
Presentation
.
createForAspectRatio
(
/* aspectRatio= */
2
f
,
Presentation
.
LAYOUT_SCALE_TO_FIT_WITH_CROP
)
/* aspectRatio= */
2
f
,
Presentation
.
LAYOUT_SCALE_TO_FIT_WITH_CROP
)
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
Size
outputSize
=
presentationTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
presentationTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
());
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
Bitmap
expectedBitmap
=
readBitmap
(
ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_WIDE_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_WIDE_PNG_ASSET_PATH
);
presentationTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
presentationTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
...
@@ -222,14 +217,13 @@ public final class PresentationPixelTest {
...
@@ -222,14 +217,13 @@ public final class PresentationPixelTest {
presentationTextureProcessor
=
presentationTextureProcessor
=
Presentation
.
createForAspectRatio
(
/* aspectRatio= */
1
f
,
Presentation
.
LAYOUT_STRETCH_TO_FIT
)
Presentation
.
createForAspectRatio
(
/* aspectRatio= */
1
f
,
Presentation
.
LAYOUT_STRETCH_TO_FIT
)
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
Size
outputSize
=
presentationTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
presentationTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
());
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
Bitmap
expectedBitmap
=
readBitmap
(
ASPECT_RATIO_STRETCH_TO_FIT_NARROW_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
ASPECT_RATIO_STRETCH_TO_FIT_NARROW_PNG_ASSET_PATH
);
presentationTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
presentationTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
...
@@ -245,14 +239,13 @@ public final class PresentationPixelTest {
...
@@ -245,14 +239,13 @@ public final class PresentationPixelTest {
presentationTextureProcessor
=
presentationTextureProcessor
=
Presentation
.
createForAspectRatio
(
/* aspectRatio= */
2
f
,
Presentation
.
LAYOUT_STRETCH_TO_FIT
)
Presentation
.
createForAspectRatio
(
/* aspectRatio= */
2
f
,
Presentation
.
LAYOUT_STRETCH_TO_FIT
)
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
Size
outputSize
=
presentationTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
presentationTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
());
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
Bitmap
expectedBitmap
=
readBitmap
(
ASPECT_RATIO_STRETCH_TO_FIT_WIDE_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
ASPECT_RATIO_STRETCH_TO_FIT_WIDE_PNG_ASSET_PATH
);
presentationTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
presentationTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
// TODO(b/207848601): switch to using proper tooling for testing against golden data.
...
...
library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/RgbAdjustmentPixelTest.java
View file @
4a3d693c
...
@@ -33,10 +33,10 @@ import android.graphics.Color;
...
@@ -33,10 +33,10 @@ import android.graphics.Color;
import
android.opengl.EGLContext
;
import
android.opengl.EGLContext
;
import
android.opengl.EGLDisplay
;
import
android.opengl.EGLDisplay
;
import
android.opengl.EGLSurface
;
import
android.opengl.EGLSurface
;
import
android.util.Pair
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.Size
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableList
;
import
java.io.IOException
;
import
java.io.IOException
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
...
@@ -110,12 +110,12 @@ public final class RgbAdjustmentPixelTest {
...
@@ -110,12 +110,12 @@ public final class RgbAdjustmentPixelTest {
String
testId
=
"drawFrame_identityMatrix"
;
String
testId
=
"drawFrame_identityMatrix"
;
RgbMatrix
identityMatrix
=
new
RgbAdjustment
.
Builder
().
build
();
RgbMatrix
identityMatrix
=
new
RgbAdjustment
.
Builder
().
build
();
matrixTextureProcessor
=
identityMatrix
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
matrixTextureProcessor
=
identityMatrix
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
matrixTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
matrixTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
matrixTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
matrixTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -129,13 +129,14 @@ public final class RgbAdjustmentPixelTest {
...
@@ -129,13 +129,14 @@ public final class RgbAdjustmentPixelTest {
RgbMatrix
removeColorMatrix
=
RgbMatrix
removeColorMatrix
=
new
RgbAdjustment
.
Builder
().
setRedScale
(
0
).
setGreenScale
(
0
).
setBlueScale
(
0
).
build
();
new
RgbAdjustment
.
Builder
().
setRedScale
(
0
).
setGreenScale
(
0
).
setBlueScale
(
0
).
build
();
matrixTextureProcessor
=
removeColorMatrix
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
matrixTextureProcessor
=
removeColorMatrix
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
matrixTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
matrixTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Bitmap
expectedBitmap
=
Bitmap
expectedBitmap
=
createArgb8888BitmapWithSolidColor
(
outputSize
.
first
,
outputSize
.
second
,
Color
.
BLACK
);
createArgb8888BitmapWithSolidColor
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
(),
Color
.
BLACK
);
matrixTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
matrixTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -148,12 +149,12 @@ public final class RgbAdjustmentPixelTest {
...
@@ -148,12 +149,12 @@ public final class RgbAdjustmentPixelTest {
String
testId
=
"drawFrame_redOnlyFilter"
;
String
testId
=
"drawFrame_redOnlyFilter"
;
RgbMatrix
redOnlyMatrix
=
new
RgbAdjustment
.
Builder
().
setBlueScale
(
0
).
setGreenScale
(
0
).
build
();
RgbMatrix
redOnlyMatrix
=
new
RgbAdjustment
.
Builder
().
setBlueScale
(
0
).
setGreenScale
(
0
).
build
();
matrixTextureProcessor
=
redOnlyMatrix
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
matrixTextureProcessor
=
redOnlyMatrix
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
matrixTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
matrixTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Bitmap
expectedBitmap
=
readBitmap
(
ONLY_RED_CHANNEL_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
ONLY_RED_CHANNEL_PNG_ASSET_PATH
);
matrixTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
matrixTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -166,12 +167,12 @@ public final class RgbAdjustmentPixelTest {
...
@@ -166,12 +167,12 @@ public final class RgbAdjustmentPixelTest {
String
testId
=
"drawFrame_increaseRedChannel"
;
String
testId
=
"drawFrame_increaseRedChannel"
;
RgbMatrix
increaseRedMatrix
=
new
RgbAdjustment
.
Builder
().
setRedScale
(
5
).
build
();
RgbMatrix
increaseRedMatrix
=
new
RgbAdjustment
.
Builder
().
setRedScale
(
5
).
build
();
matrixTextureProcessor
=
increaseRedMatrix
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
matrixTextureProcessor
=
increaseRedMatrix
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
matrixTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
matrixTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Bitmap
expectedBitmap
=
readBitmap
(
INCREASE_RED_CHANNEL_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
INCREASE_RED_CHANNEL_PNG_ASSET_PATH
);
matrixTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
matrixTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -186,12 +187,12 @@ public final class RgbAdjustmentPixelTest {
...
@@ -186,12 +187,12 @@ public final class RgbAdjustmentPixelTest {
new
RgbAdjustment
.
Builder
().
setRedScale
(
5
).
setGreenScale
(
5
).
setBlueScale
(
5
).
build
();
new
RgbAdjustment
.
Builder
().
setRedScale
(
5
).
setGreenScale
(
5
).
setBlueScale
(
5
).
build
();
matrixTextureProcessor
=
matrixTextureProcessor
=
increaseBrightnessMatrix
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
increaseBrightnessMatrix
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
matrixTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
matrixTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Bitmap
expectedBitmap
=
readBitmap
(
INCREASE_BRIGHTNESS_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
INCREASE_BRIGHTNESS_PNG_ASSET_PATH
);
matrixTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
matrixTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -211,13 +212,14 @@ public final class RgbAdjustmentPixelTest {
...
@@ -211,13 +212,14 @@ public final class RgbAdjustmentPixelTest {
/* matrixTransformations= */
ImmutableList
.
of
(),
/* matrixTransformations= */
ImmutableList
.
of
(),
/* rgbMatrices= */
ImmutableList
.
of
(
noRed
,
noGreen
,
noBlue
),
/* rgbMatrices= */
ImmutableList
.
of
(
noRed
,
noGreen
,
noBlue
),
/* useHdr= */
false
);
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
matrixTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
matrixTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Bitmap
expectedBitmap
=
Bitmap
expectedBitmap
=
createArgb8888BitmapWithSolidColor
(
outputSize
.
first
,
outputSize
.
second
,
Color
.
BLACK
);
createArgb8888BitmapWithSolidColor
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
(),
Color
.
BLACK
);
matrixTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
matrixTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -236,12 +238,12 @@ public final class RgbAdjustmentPixelTest {
...
@@ -236,12 +238,12 @@ public final class RgbAdjustmentPixelTest {
/* matrixTransformations= */
ImmutableList
.
of
(),
/* matrixTransformations= */
ImmutableList
.
of
(),
/* rgbMatrices= */
ImmutableList
.
of
(
noGreen
,
noBlue
),
/* rgbMatrices= */
ImmutableList
.
of
(
noGreen
,
noBlue
),
/* useHdr= */
false
);
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
matrixTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
matrixTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Bitmap
expectedBitmap
=
readBitmap
(
ONLY_RED_CHANNEL_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
ONLY_RED_CHANNEL_PNG_ASSET_PATH
);
matrixTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
matrixTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -262,12 +264,12 @@ public final class RgbAdjustmentPixelTest {
...
@@ -262,12 +264,12 @@ public final class RgbAdjustmentPixelTest {
/* matrixTransformations= */
ImmutableList
.
of
(),
/* matrixTransformations= */
ImmutableList
.
of
(),
/* rgbMatrices= */
ImmutableList
.
of
(
scaleRedMatrix
,
scaleRedByInverseMatrix
),
/* rgbMatrices= */
ImmutableList
.
of
(
scaleRedMatrix
,
scaleRedByInverseMatrix
),
/* useHdr= */
false
);
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
matrixTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
matrixTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
matrixTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
matrixTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
...
library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/RgbFilterPixelTest.java
View file @
4a3d693c
...
@@ -31,10 +31,10 @@ import android.graphics.Bitmap;
...
@@ -31,10 +31,10 @@ import android.graphics.Bitmap;
import
android.opengl.EGLContext
;
import
android.opengl.EGLContext
;
import
android.opengl.EGLDisplay
;
import
android.opengl.EGLDisplay
;
import
android.opengl.EGLSurface
;
import
android.opengl.EGLSurface
;
import
android.util.Pair
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.Size
;
import
java.io.IOException
;
import
java.io.IOException
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
import
org.junit.After
;
import
org.junit.After
;
...
@@ -105,12 +105,12 @@ public final class RgbFilterPixelTest {
...
@@ -105,12 +105,12 @@ public final class RgbFilterPixelTest {
String
testId
=
"drawFrame_grayscale"
;
String
testId
=
"drawFrame_grayscale"
;
RgbMatrix
grayscaleMatrix
=
RgbFilter
.
createGrayscaleFilter
();
RgbMatrix
grayscaleMatrix
=
RgbFilter
.
createGrayscaleFilter
();
matrixTextureProcessor
=
grayscaleMatrix
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
matrixTextureProcessor
=
grayscaleMatrix
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
matrixTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
matrixTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Bitmap
expectedBitmap
=
readBitmap
(
GRAYSCALE_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
GRAYSCALE_PNG_ASSET_PATH
);
matrixTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
matrixTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -123,12 +123,12 @@ public final class RgbFilterPixelTest {
...
@@ -123,12 +123,12 @@ public final class RgbFilterPixelTest {
String
testId
=
"drawFrame_inverted"
;
String
testId
=
"drawFrame_inverted"
;
RgbMatrix
invertedMatrix
=
RgbFilter
.
createInvertedFilter
();
RgbMatrix
invertedMatrix
=
RgbFilter
.
createInvertedFilter
();
matrixTextureProcessor
=
invertedMatrix
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
matrixTextureProcessor
=
invertedMatrix
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
matrixTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
matrixTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Bitmap
expectedBitmap
=
readBitmap
(
INVERT_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
INVERT_PNG_ASSET_PATH
);
matrixTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
matrixTextureProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
/* bitmapLabel= */
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
...
library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/SingleColorLutPixelTest.java
View file @
4a3d693c
...
@@ -32,10 +32,10 @@ import android.graphics.Color;
...
@@ -32,10 +32,10 @@ import android.graphics.Color;
import
android.opengl.EGLContext
;
import
android.opengl.EGLContext
;
import
android.opengl.EGLDisplay
;
import
android.opengl.EGLDisplay
;
import
android.opengl.EGLSurface
;
import
android.opengl.EGLSurface
;
import
android.util.Pair
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.Size
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
import
org.junit.After
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Before
;
...
@@ -101,13 +101,13 @@ public class SingleColorLutPixelTest {
...
@@ -101,13 +101,13 @@ public class SingleColorLutPixelTest {
colorLutProcessor
=
colorLutProcessor
=
SingleColorLut
.
createFromCube
(
cubeIdentityLut
)
SingleColorLut
.
createFromCube
(
cubeIdentityLut
)
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
colorLutProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
colorLutProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
colorLutProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
colorLutProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -122,13 +122,13 @@ public class SingleColorLutPixelTest {
...
@@ -122,13 +122,13 @@ public class SingleColorLutPixelTest {
colorLutProcessor
=
colorLutProcessor
=
SingleColorLut
.
createFromCube
(
cubeIdentityLut
)
SingleColorLut
.
createFromCube
(
cubeIdentityLut
)
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
colorLutProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
colorLutProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
colorLutProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
colorLutProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -143,13 +143,13 @@ public class SingleColorLutPixelTest {
...
@@ -143,13 +143,13 @@ public class SingleColorLutPixelTest {
colorLutProcessor
=
colorLutProcessor
=
SingleColorLut
.
createFromBitmap
(
bitmapLut
)
SingleColorLut
.
createFromBitmap
(
bitmapLut
)
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
colorLutProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
colorLutProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
colorLutProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
colorLutProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -164,13 +164,13 @@ public class SingleColorLutPixelTest {
...
@@ -164,13 +164,13 @@ public class SingleColorLutPixelTest {
colorLutProcessor
=
colorLutProcessor
=
SingleColorLut
.
createFromBitmap
(
bitmapLut
)
SingleColorLut
.
createFromBitmap
(
bitmapLut
)
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
colorLutProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
colorLutProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
colorLutProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
colorLutProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -185,13 +185,13 @@ public class SingleColorLutPixelTest {
...
@@ -185,13 +185,13 @@ public class SingleColorLutPixelTest {
colorLutProcessor
=
colorLutProcessor
=
SingleColorLut
.
createFromBitmap
(
bitmapLut
)
SingleColorLut
.
createFromBitmap
(
bitmapLut
)
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
colorLutProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
colorLutProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
ORIGINAL_PNG_ASSET_PATH
);
colorLutProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
colorLutProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -208,13 +208,13 @@ public class SingleColorLutPixelTest {
...
@@ -208,13 +208,13 @@ public class SingleColorLutPixelTest {
colorLutProcessor
=
colorLutProcessor
=
SingleColorLut
.
createFromCube
(
mapWhiteToGreen
)
SingleColorLut
.
createFromCube
(
mapWhiteToGreen
)
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
colorLutProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
colorLutProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
readBitmap
(
LUT_MAP_WHITE_TO_GREEN_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
LUT_MAP_WHITE_TO_GREEN_ASSET_PATH
);
colorLutProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
colorLutProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -229,13 +229,13 @@ public class SingleColorLutPixelTest {
...
@@ -229,13 +229,13 @@ public class SingleColorLutPixelTest {
colorLutProcessor
=
colorLutProcessor
=
SingleColorLut
.
createFromBitmap
(
invertedLutBitmap
)
SingleColorLut
.
createFromBitmap
(
invertedLutBitmap
)
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
colorLutProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
colorLutProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
readBitmap
(
INVERT_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
INVERT_PNG_ASSET_PATH
);
colorLutProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
colorLutProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
@@ -250,13 +250,13 @@ public class SingleColorLutPixelTest {
...
@@ -250,13 +250,13 @@ public class SingleColorLutPixelTest {
colorLutProcessor
=
colorLutProcessor
=
SingleColorLut
.
createFromBitmap
(
grayscaleLutBitmap
)
SingleColorLut
.
createFromBitmap
(
grayscaleLutBitmap
)
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
.
toGlTextureProcessor
(
context
,
/* useHdr= */
false
);
Pair
<
Integer
,
Integer
>
outputSize
=
colorLutProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
colorLutProcessor
.
configure
(
inputWidth
,
inputHeight
);
setupOutputTexture
(
outputSize
.
first
,
outputSize
.
second
);
setupOutputTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
Bitmap
expectedBitmap
=
readBitmap
(
GRAYSCALE_PNG_ASSET_PATH
);
Bitmap
expectedBitmap
=
readBitmap
(
GRAYSCALE_PNG_ASSET_PATH
);
colorLutProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
colorLutProcessor
.
drawFrame
(
inputTexId
,
/* presentationTimeUs= */
0
);
Bitmap
actualBitmap
=
Bitmap
actualBitmap
=
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
first
,
outputSize
.
second
);
createArgb8888BitmapFromCurrentGlFramebuffer
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
"actual"
,
actualBitmap
);
maybeSaveTestBitmapToCacheDirectory
(
testId
,
"actual"
,
actualBitmap
);
float
averagePixelAbsoluteDifference
=
float
averagePixelAbsoluteDifference
=
...
...
library/effect/src/main/java/com/google/android/exoplayer2/effect/BitmapOverlay.java
View file @
4a3d693c
...
@@ -21,9 +21,9 @@ import android.graphics.Bitmap;
...
@@ -21,9 +21,9 @@ import android.graphics.Bitmap;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.opengl.GLES20
;
import
android.opengl.GLES20
;
import
android.opengl.GLUtils
;
import
android.opengl.GLUtils
;
import
android.util.Pair
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.Size
;
import
com.google.common.util.concurrent.ListenableFuture
;
import
com.google.common.util.concurrent.ListenableFuture
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ExecutionException
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
...
@@ -53,8 +53,8 @@ public abstract class BitmapOverlay extends TextureOverlay {
...
@@ -53,8 +53,8 @@ public abstract class BitmapOverlay extends TextureOverlay {
* @param presentationTimeUs The presentation timestamp of the current frame, in microseconds.
* @param presentationTimeUs The presentation timestamp of the current frame, in microseconds.
*/
*/
@Override
@Override
public
Pair
<
Integer
,
Integer
>
getTextureSize
(
long
presentationTimeUs
)
{
public
Size
getTextureSize
(
long
presentationTimeUs
)
{
return
Pair
.
creat
e
(
checkNotNull
(
lastBitmap
).
getWidth
(),
checkNotNull
(
lastBitmap
).
getHeight
());
return
new
Siz
e
(
checkNotNull
(
lastBitmap
).
getWidth
(),
checkNotNull
(
lastBitmap
).
getHeight
());
}
}
@Override
@Override
...
...
library/effect/src/main/java/com/google/android/exoplayer2/effect/ColorLutProcessor.java
View file @
4a3d693c
...
@@ -20,10 +20,10 @@ import static com.google.android.exoplayer2.util.Assertions.checkArgument;
...
@@ -20,10 +20,10 @@ import static com.google.android.exoplayer2.util.Assertions.checkArgument;
import
android.content.Context
;
import
android.content.Context
;
import
android.opengl.GLES20
;
import
android.opengl.GLES20
;
import
android.util.Pair
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.GlProgram
;
import
com.google.android.exoplayer2.util.GlProgram
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.Size
;
import
java.io.IOException
;
import
java.io.IOException
;
/** Applies a {@link ColorLut} to each frame in the fragment shader. */
/** Applies a {@link ColorLut} to each frame in the fragment shader. */
...
@@ -68,8 +68,8 @@ import java.io.IOException;
...
@@ -68,8 +68,8 @@ import java.io.IOException;
}
}
@Override
@Override
public
Pair
<
Integer
,
Integer
>
configure
(
int
inputWidth
,
int
inputHeight
)
{
public
Size
configure
(
int
inputWidth
,
int
inputHeight
)
{
return
Pair
.
creat
e
(
inputWidth
,
inputHeight
);
return
new
Siz
e
(
inputWidth
,
inputHeight
);
}
}
@Override
@Override
...
...
library/effect/src/main/java/com/google/android/exoplayer2/effect/ContrastProcessor.java
View file @
4a3d693c
...
@@ -18,10 +18,10 @@ package com.google.android.exoplayer2.effect;
...
@@ -18,10 +18,10 @@ package com.google.android.exoplayer2.effect;
import
android.content.Context
;
import
android.content.Context
;
import
android.opengl.GLES20
;
import
android.opengl.GLES20
;
import
android.util.Pair
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.GlProgram
;
import
com.google.android.exoplayer2.util.GlProgram
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.Size
;
import
java.io.IOException
;
import
java.io.IOException
;
/** Applies a {@link Contrast} to each frame in the fragment shader. */
/** Applies a {@link Contrast} to each frame in the fragment shader. */
...
@@ -65,8 +65,8 @@ import java.io.IOException;
...
@@ -65,8 +65,8 @@ import java.io.IOException;
}
}
@Override
@Override
public
Pair
<
Integer
,
Integer
>
configure
(
int
inputWidth
,
int
inputHeight
)
{
public
Size
configure
(
int
inputWidth
,
int
inputHeight
)
{
return
Pair
.
creat
e
(
inputWidth
,
inputHeight
);
return
new
Siz
e
(
inputWidth
,
inputHeight
);
}
}
@Override
@Override
...
...
library/effect/src/main/java/com/google/android/exoplayer2/effect/Crop.java
View file @
4a3d693c
...
@@ -19,8 +19,8 @@ import static com.google.android.exoplayer2.util.Assertions.checkArgument;
...
@@ -19,8 +19,8 @@ import static com.google.android.exoplayer2.util.Assertions.checkArgument;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkStateNotNull
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkStateNotNull
;
import
android.graphics.Matrix
;
import
android.graphics.Matrix
;
import
android.util.Pair
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.Size
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
/**
/**
...
@@ -64,14 +64,14 @@ public final class Crop implements MatrixTransformation {
...
@@ -64,14 +64,14 @@ public final class Crop implements MatrixTransformation {
}
}
@Override
@Override
public
Pair
<
Integer
,
Integer
>
configure
(
int
inputWidth
,
int
inputHeight
)
{
public
Size
configure
(
int
inputWidth
,
int
inputHeight
)
{
checkArgument
(
inputWidth
>
0
,
"inputWidth must be positive"
);
checkArgument
(
inputWidth
>
0
,
"inputWidth must be positive"
);
checkArgument
(
inputHeight
>
0
,
"inputHeight must be positive"
);
checkArgument
(
inputHeight
>
0
,
"inputHeight must be positive"
);
transformationMatrix
=
new
Matrix
();
transformationMatrix
=
new
Matrix
();
if
(
left
==
-
1
f
&&
right
==
1
f
&&
bottom
==
-
1
f
&&
top
==
1
f
)
{
if
(
left
==
-
1
f
&&
right
==
1
f
&&
bottom
==
-
1
f
&&
top
==
1
f
)
{
// No crop needed.
// No crop needed.
return
Pair
.
creat
e
(
inputWidth
,
inputHeight
);
return
new
Siz
e
(
inputWidth
,
inputHeight
);
}
}
float
scaleX
=
(
right
-
left
)
/
GlUtil
.
LENGTH_NDC
;
float
scaleX
=
(
right
-
left
)
/
GlUtil
.
LENGTH_NDC
;
...
@@ -84,7 +84,7 @@ public final class Crop implements MatrixTransformation {
...
@@ -84,7 +84,7 @@ public final class Crop implements MatrixTransformation {
int
outputWidth
=
Math
.
round
(
inputWidth
*
scaleX
);
int
outputWidth
=
Math
.
round
(
inputWidth
*
scaleX
);
int
outputHeight
=
Math
.
round
(
inputHeight
*
scaleY
);
int
outputHeight
=
Math
.
round
(
inputHeight
*
scaleY
);
return
Pair
.
creat
e
(
outputWidth
,
outputHeight
);
return
new
Siz
e
(
outputWidth
,
outputHeight
);
}
}
@Override
@Override
...
...
library/effect/src/main/java/com/google/android/exoplayer2/effect/FinalMatrixTextureProcessorWrapper.java
View file @
4a3d693c
...
@@ -38,6 +38,7 @@ import com.google.android.exoplayer2.util.FrameProcessingException;
...
@@ -38,6 +38,7 @@ import com.google.android.exoplayer2.util.FrameProcessingException;
import
com.google.android.exoplayer2.util.FrameProcessor
;
import
com.google.android.exoplayer2.util.FrameProcessor
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.Log
;
import
com.google.android.exoplayer2.util.Log
;
import
com.google.android.exoplayer2.util.Size
;
import
com.google.android.exoplayer2.util.SurfaceInfo
;
import
com.google.android.exoplayer2.util.SurfaceInfo
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.video.ColorInfo
;
import
com.google.android.exoplayer2.video.ColorInfo
;
...
@@ -84,7 +85,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -84,7 +85,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@Nullable
private
MatrixTextureProcessor
matrixTextureProcessor
;
@Nullable
private
MatrixTextureProcessor
matrixTextureProcessor
;
@Nullable
private
SurfaceViewWrapper
debugSurfaceViewWrapper
;
@Nullable
private
SurfaceViewWrapper
debugSurfaceViewWrapper
;
private
InputListener
inputListener
;
private
InputListener
inputListener
;
private
@MonotonicNonNull
Pair
<
Integer
,
Integer
>
outputSizeBeforeSurfaceTransformation
;
private
@MonotonicNonNull
Size
outputSizeBeforeSurfaceTransformation
;
@Nullable
private
SurfaceView
debugSurfaceView
;
@Nullable
private
SurfaceView
debugSurfaceView
;
private
volatile
boolean
outputSizeOrRotationChanged
;
private
volatile
boolean
outputSizeOrRotationChanged
;
...
@@ -313,7 +314,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -313,7 +314,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
||
this
.
outputSizeBeforeSurfaceTransformation
==
null
)
{
||
this
.
outputSizeBeforeSurfaceTransformation
==
null
)
{
this
.
inputWidth
=
inputWidth
;
this
.
inputWidth
=
inputWidth
;
this
.
inputHeight
=
inputHeight
;
this
.
inputHeight
=
inputHeight
;
Pair
<
Integer
,
Integer
>
outputSizeBeforeSurfaceTransformation
=
Size
outputSizeBeforeSurfaceTransformation
=
MatrixUtils
.
configureAndGetOutputSize
(
inputWidth
,
inputHeight
,
matrixTransformations
);
MatrixUtils
.
configureAndGetOutputSize
(
inputWidth
,
inputHeight
,
matrixTransformations
);
if
(!
Util
.
areEqual
(
if
(!
Util
.
areEqual
(
this
.
outputSizeBeforeSurfaceTransformation
,
outputSizeBeforeSurfaceTransformation
))
{
this
.
outputSizeBeforeSurfaceTransformation
,
outputSizeBeforeSurfaceTransformation
))
{
...
@@ -321,8 +322,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -321,8 +322,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
frameProcessorListenerExecutor
.
execute
(
frameProcessorListenerExecutor
.
execute
(
()
->
()
->
frameProcessorListener
.
onOutputSizeChanged
(
frameProcessorListener
.
onOutputSizeChanged
(
outputSizeBeforeSurfaceTransformation
.
first
,
outputSizeBeforeSurfaceTransformation
.
getWidth
()
,
outputSizeBeforeSurfaceTransformation
.
second
));
outputSizeBeforeSurfaceTransformation
.
getHeight
()
));
}
}
}
}
...
@@ -406,9 +407,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -406,9 +407,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
}
}
matrixTextureProcessor
.
setTextureTransformMatrix
(
textureTransformMatrix
);
matrixTextureProcessor
.
setTextureTransformMatrix
(
textureTransformMatrix
);
Pair
<
Integer
,
Integer
>
outputSize
=
matrixTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
matrixTextureProcessor
.
configure
(
inputWidth
,
inputHeight
);
checkState
(
outputSize
.
first
==
outputSurfaceInfo
.
width
);
checkState
(
outputSize
.
getWidth
()
==
outputSurfaceInfo
.
width
);
checkState
(
outputSize
.
second
==
outputSurfaceInfo
.
height
);
checkState
(
outputSize
.
getHeight
()
==
outputSurfaceInfo
.
height
);
return
matrixTextureProcessor
;
return
matrixTextureProcessor
;
}
}
...
...
library/effect/src/main/java/com/google/android/exoplayer2/effect/GlMatrixTransformation.java
View file @
4a3d693c
...
@@ -17,8 +17,8 @@ package com.google.android.exoplayer2.effect;
...
@@ -17,8 +17,8 @@ package com.google.android.exoplayer2.effect;
import
android.content.Context
;
import
android.content.Context
;
import
android.opengl.Matrix
;
import
android.opengl.Matrix
;
import
android.util.Pair
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.Size
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableList
;
/**
/**
...
@@ -41,8 +41,8 @@ public interface GlMatrixTransformation extends GlEffect {
...
@@ -41,8 +41,8 @@ public interface GlMatrixTransformation extends GlEffect {
* @param inputHeight The input frame height, in pixels.
* @param inputHeight The input frame height, in pixels.
* @return The output frame width and height, in pixels.
* @return The output frame width and height, in pixels.
*/
*/
default
Pair
<
Integer
,
Integer
>
configure
(
int
inputWidth
,
int
inputHeight
)
{
default
Size
configure
(
int
inputWidth
,
int
inputHeight
)
{
return
Pair
.
creat
e
(
inputWidth
,
inputHeight
);
return
new
Siz
e
(
inputWidth
,
inputHeight
);
}
}
/**
/**
...
...
library/effect/src/main/java/com/google/android/exoplayer2/effect/HslProcessor.java
View file @
4a3d693c
...
@@ -20,10 +20,10 @@ import static com.google.android.exoplayer2.util.Assertions.checkArgument;
...
@@ -20,10 +20,10 @@ import static com.google.android.exoplayer2.util.Assertions.checkArgument;
import
android.content.Context
;
import
android.content.Context
;
import
android.opengl.GLES20
;
import
android.opengl.GLES20
;
import
android.util.Pair
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.GlProgram
;
import
com.google.android.exoplayer2.util.GlProgram
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.Size
;
import
java.io.IOException
;
import
java.io.IOException
;
/** Applies the {@link HslAdjustment} to each frame in the fragment shader. */
/** Applies the {@link HslAdjustment} to each frame in the fragment shader. */
...
@@ -73,8 +73,8 @@ import java.io.IOException;
...
@@ -73,8 +73,8 @@ import java.io.IOException;
}
}
@Override
@Override
public
Pair
<
Integer
,
Integer
>
configure
(
int
inputWidth
,
int
inputHeight
)
{
public
Size
configure
(
int
inputWidth
,
int
inputHeight
)
{
return
Pair
.
creat
e
(
inputWidth
,
inputHeight
);
return
new
Siz
e
(
inputWidth
,
inputHeight
);
}
}
@Override
@Override
...
...
library/effect/src/main/java/com/google/android/exoplayer2/effect/MatrixTextureProcessor.java
View file @
4a3d693c
...
@@ -21,12 +21,12 @@ import static com.google.android.exoplayer2.util.Assertions.checkState;
...
@@ -21,12 +21,12 @@ import static com.google.android.exoplayer2.util.Assertions.checkState;
import
android.content.Context
;
import
android.content.Context
;
import
android.opengl.GLES20
;
import
android.opengl.GLES20
;
import
android.opengl.Matrix
;
import
android.opengl.Matrix
;
import
android.util.Pair
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.GlProgram
;
import
com.google.android.exoplayer2.util.GlProgram
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.Size
;
import
com.google.android.exoplayer2.video.ColorInfo
;
import
com.google.android.exoplayer2.video.ColorInfo
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableList
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -354,7 +354,7 @@ import java.util.List;
...
@@ -354,7 +354,7 @@ import java.util.List;
}
}
@Override
@Override
public
Pair
<
Integer
,
Integer
>
configure
(
int
inputWidth
,
int
inputHeight
)
{
public
Size
configure
(
int
inputWidth
,
int
inputHeight
)
{
return
MatrixUtils
.
configureAndGetOutputSize
(
inputWidth
,
inputHeight
,
matrixTransformations
);
return
MatrixUtils
.
configureAndGetOutputSize
(
inputWidth
,
inputHeight
,
matrixTransformations
);
}
}
...
...
library/effect/src/main/java/com/google/android/exoplayer2/effect/MatrixUtils.java
View file @
4a3d693c
...
@@ -18,7 +18,7 @@ package com.google.android.exoplayer2.effect;
...
@@ -18,7 +18,7 @@ package com.google.android.exoplayer2.effect;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkArgument
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkArgument
;
import
android.opengl.Matrix
;
import
android.opengl.Matrix
;
import
android.util.Pair
;
import
com.google.android.exoplayer2.util.Size
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
...
@@ -222,16 +222,17 @@ import java.util.Arrays;
...
@@ -222,16 +222,17 @@ import java.util.Arrays;
* Returns the output frame size after applying the given list of {@link GlMatrixTransformation
* Returns the output frame size after applying the given list of {@link GlMatrixTransformation
* GlMatrixTransformations} to an input frame with the given size.
* GlMatrixTransformations} to an input frame with the given size.
*/
*/
public
static
Pair
<
Integer
,
Integer
>
configureAndGetOutputSize
(
public
static
Size
configureAndGetOutputSize
(
int
inputWidth
,
int
inputWidth
,
int
inputHeight
,
int
inputHeight
,
ImmutableList
<
GlMatrixTransformation
>
matrixTransformations
)
{
ImmutableList
<
GlMatrixTransformation
>
matrixTransformations
)
{
checkArgument
(
inputWidth
>
0
,
"inputWidth must be positive"
);
checkArgument
(
inputWidth
>
0
,
"inputWidth must be positive"
);
checkArgument
(
inputHeight
>
0
,
"inputHeight must be positive"
);
checkArgument
(
inputHeight
>
0
,
"inputHeight must be positive"
);
Pair
<
Integer
,
Integer
>
outputSize
=
Pair
.
creat
e
(
inputWidth
,
inputHeight
);
Size
outputSize
=
new
Siz
e
(
inputWidth
,
inputHeight
);
for
(
int
i
=
0
;
i
<
matrixTransformations
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
matrixTransformations
.
size
();
i
++)
{
outputSize
=
matrixTransformations
.
get
(
i
).
configure
(
outputSize
.
first
,
outputSize
.
second
);
outputSize
=
matrixTransformations
.
get
(
i
).
configure
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
());
}
}
return
outputSize
;
return
outputSize
;
...
...
library/effect/src/main/java/com/google/android/exoplayer2/effect/OverlayTextureProcessor.java
View file @
4a3d693c
...
@@ -20,10 +20,10 @@ import static com.google.android.exoplayer2.util.Assertions.checkArgument;
...
@@ -20,10 +20,10 @@ import static com.google.android.exoplayer2.util.Assertions.checkArgument;
import
android.content.Context
;
import
android.content.Context
;
import
android.opengl.GLES20
;
import
android.opengl.GLES20
;
import
android.opengl.Matrix
;
import
android.opengl.Matrix
;
import
android.util.Pair
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.GlProgram
;
import
com.google.android.exoplayer2.util.GlProgram
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.Size
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableList
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -76,10 +76,10 @@ import java.io.IOException;
...
@@ -76,10 +76,10 @@ import java.io.IOException;
}
}
@Override
@Override
public
Pair
<
Integer
,
Integer
>
configure
(
int
inputWidth
,
int
inputHeight
)
{
public
Size
configure
(
int
inputWidth
,
int
inputHeight
)
{
videoWidth
=
inputWidth
;
videoWidth
=
inputWidth
;
videoHeight
=
inputHeight
;
videoHeight
=
inputHeight
;
return
Pair
.
creat
e
(
inputWidth
,
inputHeight
);
return
new
Siz
e
(
inputWidth
,
inputHeight
);
}
}
@Override
@Override
...
@@ -90,13 +90,13 @@ import java.io.IOException;
...
@@ -90,13 +90,13 @@ import java.io.IOException;
TextureOverlay
overlay
=
overlays
.
get
(
0
);
TextureOverlay
overlay
=
overlays
.
get
(
0
);
glProgram
.
setSamplerTexIdUniform
(
glProgram
.
setSamplerTexIdUniform
(
"uOverlayTexSampler1"
,
overlay
.
getTextureId
(
presentationTimeUs
),
/* texUnitIndex= */
1
);
"uOverlayTexSampler1"
,
overlay
.
getTextureId
(
presentationTimeUs
),
/* texUnitIndex= */
1
);
Pair
<
Integer
,
Integer
>
overlayTextureSize
=
overlay
.
getTextureSize
(
presentationTimeUs
);
Size
overlayTextureSize
=
overlay
.
getTextureSize
(
presentationTimeUs
);
GlUtil
.
setToIdentity
(
aspectRatioMatrix
);
GlUtil
.
setToIdentity
(
aspectRatioMatrix
);
Matrix
.
scaleM
(
Matrix
.
scaleM
(
aspectRatioMatrix
,
aspectRatioMatrix
,
MATRIX_OFFSET
,
MATRIX_OFFSET
,
videoWidth
/
(
float
)
overlayTextureSize
.
first
,
videoWidth
/
(
float
)
overlayTextureSize
.
getWidth
()
,
videoHeight
/
(
float
)
overlayTextureSize
.
second
,
videoHeight
/
(
float
)
overlayTextureSize
.
getHeight
()
,
/* z= */
1
);
/* z= */
1
);
glProgram
.
setFloatsUniform
(
"uAspectRatioMatrix"
,
aspectRatioMatrix
);
glProgram
.
setFloatsUniform
(
"uAspectRatioMatrix"
,
aspectRatioMatrix
);
Matrix
.
invertM
(
Matrix
.
invertM
(
...
...
library/effect/src/main/java/com/google/android/exoplayer2/effect/Presentation.java
View file @
4a3d693c
...
@@ -21,9 +21,9 @@ import static java.lang.annotation.ElementType.TYPE_USE;
...
@@ -21,9 +21,9 @@ import static java.lang.annotation.ElementType.TYPE_USE;
import
static
java
.
lang
.
annotation
.
RetentionPolicy
.
SOURCE
;
import
static
java
.
lang
.
annotation
.
RetentionPolicy
.
SOURCE
;
import
android.graphics.Matrix
;
import
android.graphics.Matrix
;
import
android.util.Pair
;
import
androidx.annotation.IntDef
;
import
androidx.annotation.IntDef
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.util.Size
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.Target
;
import
java.lang.annotation.Target
;
...
@@ -179,7 +179,7 @@ public final class Presentation implements MatrixTransformation {
...
@@ -179,7 +179,7 @@ public final class Presentation implements MatrixTransformation {
}
}
@Override
@Override
public
Pair
<
Integer
,
Integer
>
configure
(
int
inputWidth
,
int
inputHeight
)
{
public
Size
configure
(
int
inputWidth
,
int
inputHeight
)
{
checkArgument
(
inputWidth
>
0
,
"inputWidth must be positive"
);
checkArgument
(
inputWidth
>
0
,
"inputWidth must be positive"
);
checkArgument
(
inputHeight
>
0
,
"inputHeight must be positive"
);
checkArgument
(
inputHeight
>
0
,
"inputHeight must be positive"
);
...
@@ -204,7 +204,7 @@ public final class Presentation implements MatrixTransformation {
...
@@ -204,7 +204,7 @@ public final class Presentation implements MatrixTransformation {
}
}
outputHeight
=
requestedHeightPixels
;
outputHeight
=
requestedHeightPixels
;
}
}
return
Pair
.
creat
e
(
Math
.
round
(
outputWidth
),
Math
.
round
(
outputHeight
));
return
new
Siz
e
(
Math
.
round
(
outputWidth
),
Math
.
round
(
outputHeight
));
}
}
@Override
@Override
...
...
library/effect/src/main/java/com/google/android/exoplayer2/effect/ScaleToFitTransformation.java
View file @
4a3d693c
...
@@ -21,8 +21,8 @@ import static java.lang.Math.max;
...
@@ -21,8 +21,8 @@ import static java.lang.Math.max;
import
static
java
.
lang
.
Math
.
min
;
import
static
java
.
lang
.
Math
.
min
;
import
android.graphics.Matrix
;
import
android.graphics.Matrix
;
import
android.util.Pair
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.Size
;
import
com.google.errorprone.annotations.CanIgnoreReturnValue
;
import
com.google.errorprone.annotations.CanIgnoreReturnValue
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
...
@@ -103,14 +103,14 @@ public final class ScaleToFitTransformation implements MatrixTransformation {
...
@@ -103,14 +103,14 @@ public final class ScaleToFitTransformation implements MatrixTransformation {
}
}
@Override
@Override
public
Pair
<
Integer
,
Integer
>
configure
(
int
inputWidth
,
int
inputHeight
)
{
public
Size
configure
(
int
inputWidth
,
int
inputHeight
)
{
checkArgument
(
inputWidth
>
0
,
"inputWidth must be positive"
);
checkArgument
(
inputWidth
>
0
,
"inputWidth must be positive"
);
checkArgument
(
inputHeight
>
0
,
"inputHeight must be positive"
);
checkArgument
(
inputHeight
>
0
,
"inputHeight must be positive"
);
adjustedTransformationMatrix
=
new
Matrix
(
transformationMatrix
);
adjustedTransformationMatrix
=
new
Matrix
(
transformationMatrix
);
if
(
transformationMatrix
.
isIdentity
())
{
if
(
transformationMatrix
.
isIdentity
())
{
return
Pair
.
creat
e
(
inputWidth
,
inputHeight
);
return
new
Siz
e
(
inputWidth
,
inputHeight
);
}
}
float
inputAspectRatio
=
(
float
)
inputWidth
/
inputHeight
;
float
inputAspectRatio
=
(
float
)
inputWidth
/
inputHeight
;
...
@@ -139,7 +139,7 @@ public final class ScaleToFitTransformation implements MatrixTransformation {
...
@@ -139,7 +139,7 @@ public final class ScaleToFitTransformation implements MatrixTransformation {
float
scaleX
=
(
maxX
-
minX
)
/
GlUtil
.
LENGTH_NDC
;
float
scaleX
=
(
maxX
-
minX
)
/
GlUtil
.
LENGTH_NDC
;
float
scaleY
=
(
maxY
-
minY
)
/
GlUtil
.
LENGTH_NDC
;
float
scaleY
=
(
maxY
-
minY
)
/
GlUtil
.
LENGTH_NDC
;
adjustedTransformationMatrix
.
postScale
(
1
f
/
scaleX
,
1
f
/
scaleY
);
adjustedTransformationMatrix
.
postScale
(
1
f
/
scaleX
,
1
f
/
scaleY
);
return
Pair
.
creat
e
(
Math
.
round
(
inputWidth
*
scaleX
),
Math
.
round
(
inputHeight
*
scaleY
));
return
new
Siz
e
(
Math
.
round
(
inputWidth
*
scaleX
),
Math
.
round
(
inputHeight
*
scaleY
));
}
}
@Override
@Override
...
...
library/effect/src/main/java/com/google/android/exoplayer2/effect/SingleFrameGlTextureProcessor.java
View file @
4a3d693c
...
@@ -17,10 +17,10 @@ package com.google.android.exoplayer2.effect;
...
@@ -17,10 +17,10 @@ package com.google.android.exoplayer2.effect;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkState
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkState
;
import
android.util.Pair
;
import
androidx.annotation.CallSuper
;
import
androidx.annotation.CallSuper
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.Size
;
import
com.google.common.util.concurrent.MoreExecutors
;
import
com.google.common.util.concurrent.MoreExecutors
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.Executor
;
import
org.checkerframework.checker.nullness.qual.EnsuresNonNull
;
import
org.checkerframework.checker.nullness.qual.EnsuresNonNull
;
...
@@ -73,7 +73,7 @@ public abstract class SingleFrameGlTextureProcessor implements GlTextureProcesso
...
@@ -73,7 +73,7 @@ public abstract class SingleFrameGlTextureProcessor implements GlTextureProcesso
* @param inputHeight The input height, in pixels.
* @param inputHeight The input height, in pixels.
* @return The output width and height of frames processed through {@link #drawFrame(int, long)}.
* @return The output width and height of frames processed through {@link #drawFrame(int, long)}.
*/
*/
public
abstract
Pair
<
Integer
,
Integer
>
configure
(
int
inputWidth
,
int
inputHeight
);
public
abstract
Size
configure
(
int
inputWidth
,
int
inputHeight
);
/**
/**
* Draws one frame.
* Draws one frame.
...
@@ -145,17 +145,17 @@ public abstract class SingleFrameGlTextureProcessor implements GlTextureProcesso
...
@@ -145,17 +145,17 @@ public abstract class SingleFrameGlTextureProcessor implements GlTextureProcesso
private
void
configureOutputTexture
(
int
inputWidth
,
int
inputHeight
)
throws
GlUtil
.
GlException
{
private
void
configureOutputTexture
(
int
inputWidth
,
int
inputHeight
)
throws
GlUtil
.
GlException
{
this
.
inputWidth
=
inputWidth
;
this
.
inputWidth
=
inputWidth
;
this
.
inputHeight
=
inputHeight
;
this
.
inputHeight
=
inputHeight
;
Pair
<
Integer
,
Integer
>
outputSize
=
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
configure
(
inputWidth
,
inputHeight
);
if
(
outputTexture
==
null
if
(
outputTexture
==
null
||
outputSize
.
first
!=
outputTexture
.
width
||
outputSize
.
getWidth
()
!=
outputTexture
.
width
||
outputSize
.
second
!=
outputTexture
.
height
)
{
||
outputSize
.
getHeight
()
!=
outputTexture
.
height
)
{
if
(
outputTexture
!=
null
)
{
if
(
outputTexture
!=
null
)
{
GlUtil
.
deleteTexture
(
outputTexture
.
texId
);
GlUtil
.
deleteTexture
(
outputTexture
.
texId
);
}
}
int
outputTexId
=
GlUtil
.
createTexture
(
outputSize
.
first
,
outputSize
.
second
,
useHdr
);
int
outputTexId
=
GlUtil
.
createTexture
(
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
,
useHdr
);
int
outputFboId
=
GlUtil
.
createFboForTexture
(
outputTexId
);
int
outputFboId
=
GlUtil
.
createFboForTexture
(
outputTexId
);
outputTexture
=
outputTexture
=
new
TextureInfo
(
outputTexId
,
outputFboId
,
outputSize
.
first
,
outputSize
.
second
);
new
TextureInfo
(
outputTexId
,
outputFboId
,
outputSize
.
getWidth
(),
outputSize
.
getHeight
()
);
}
}
}
}
...
...
library/effect/src/main/java/com/google/android/exoplayer2/effect/TextureOverlay.java
View file @
4a3d693c
...
@@ -15,8 +15,8 @@
...
@@ -15,8 +15,8 @@
*/
*/
package
com
.
google
.
android
.
exoplayer2
.
effect
;
package
com
.
google
.
android
.
exoplayer2
.
effect
;
import
android.util.Pair
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.FrameProcessingException
;
import
com.google.android.exoplayer2.util.Size
;
/** Creates overlays from OpenGL textures. */
/** Creates overlays from OpenGL textures. */
public
abstract
class
TextureOverlay
{
public
abstract
class
TextureOverlay
{
...
@@ -37,7 +37,7 @@ public abstract class TextureOverlay {
...
@@ -37,7 +37,7 @@ public abstract class TextureOverlay {
*
*
* @param presentationTimeUs The presentation timestamp of the current frame, in microseconds.
* @param presentationTimeUs The presentation timestamp of the current frame, in microseconds.
*/
*/
public
abstract
Pair
<
Integer
,
Integer
>
getTextureSize
(
long
presentationTimeUs
);
public
abstract
Size
getTextureSize
(
long
presentationTimeUs
);
/**
/**
* Returns the {@link OverlaySettings} controlling how the overlay is displayed at the specified
* Returns the {@link OverlaySettings} controlling how the overlay is displayed at the specified
...
...
library/effect/src/test/java/com/google/android/exoplayer2/effect/CropTest.java
View file @
4a3d693c
...
@@ -17,9 +17,9 @@ package com.google.android.exoplayer2.effect;
...
@@ -17,9 +17,9 @@ package com.google.android.exoplayer2.effect;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
android.util.Pair
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.Size
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
...
@@ -36,10 +36,10 @@ public final class CropTest {
...
@@ -36,10 +36,10 @@ public final class CropTest {
int
inputHeight
=
150
;
int
inputHeight
=
150
;
Crop
crop
=
new
Crop
(
/* left= */
-
1
,
/* right= */
1
,
/* bottom= */
-
1
,
/* top= */
1
);
Crop
crop
=
new
Crop
(
/* left= */
-
1
,
/* right= */
1
,
/* bottom= */
-
1
,
/* top= */
1
);
Pair
<
Integer
,
Integer
>
outputSize
=
crop
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
crop
.
configure
(
inputWidth
,
inputHeight
);
assertThat
(
outputSize
.
first
).
isEqualTo
(
inputWidth
);
assertThat
(
outputSize
.
getWidth
()
).
isEqualTo
(
inputWidth
);
assertThat
(
outputSize
.
second
).
isEqualTo
(
inputHeight
);
assertThat
(
outputSize
.
getHeight
()
).
isEqualTo
(
inputHeight
);
}
}
@Test
@Test
...
@@ -52,11 +52,11 @@ public final class CropTest {
...
@@ -52,11 +52,11 @@ public final class CropTest {
float
top
=
1
f
;
float
top
=
1
f
;
Crop
crop
=
new
Crop
(
left
,
right
,
bottom
,
top
);
Crop
crop
=
new
Crop
(
left
,
right
,
bottom
,
top
);
Pair
<
Integer
,
Integer
>
outputSize
=
crop
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
crop
.
configure
(
inputWidth
,
inputHeight
);
int
expectedPostCropWidth
=
Math
.
round
(
inputWidth
*
(
right
-
left
)
/
GlUtil
.
LENGTH_NDC
);
int
expectedPostCropWidth
=
Math
.
round
(
inputWidth
*
(
right
-
left
)
/
GlUtil
.
LENGTH_NDC
);
int
expectedPostCropHeight
=
Math
.
round
(
inputHeight
*
(
top
-
bottom
)
/
GlUtil
.
LENGTH_NDC
);
int
expectedPostCropHeight
=
Math
.
round
(
inputHeight
*
(
top
-
bottom
)
/
GlUtil
.
LENGTH_NDC
);
assertThat
(
outputSize
.
first
).
isEqualTo
(
expectedPostCropWidth
);
assertThat
(
outputSize
.
getWidth
()
).
isEqualTo
(
expectedPostCropWidth
);
assertThat
(
outputSize
.
second
).
isEqualTo
(
expectedPostCropHeight
);
assertThat
(
outputSize
.
getHeight
()
).
isEqualTo
(
expectedPostCropHeight
);
}
}
}
}
library/effect/src/test/java/com/google/android/exoplayer2/effect/PresentationTest.java
View file @
4a3d693c
...
@@ -17,9 +17,9 @@ package com.google.android.exoplayer2.effect;
...
@@ -17,9 +17,9 @@ package com.google.android.exoplayer2.effect;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
android.util.Pair
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.util.Size
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
...
@@ -36,10 +36,10 @@ public final class PresentationTest {
...
@@ -36,10 +36,10 @@ public final class PresentationTest {
int
inputHeight
=
150
;
int
inputHeight
=
150
;
Presentation
presentation
=
Presentation
.
createForHeight
(
C
.
LENGTH_UNSET
);
Presentation
presentation
=
Presentation
.
createForHeight
(
C
.
LENGTH_UNSET
);
Pair
<
Integer
,
Integer
>
outputSize
=
presentation
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
presentation
.
configure
(
inputWidth
,
inputHeight
);
assertThat
(
outputSize
.
first
).
isEqualTo
(
inputWidth
);
assertThat
(
outputSize
.
getWidth
()
).
isEqualTo
(
inputWidth
);
assertThat
(
outputSize
.
second
).
isEqualTo
(
inputHeight
);
assertThat
(
outputSize
.
getHeight
()
).
isEqualTo
(
inputHeight
);
}
}
@Test
@Test
...
@@ -49,10 +49,10 @@ public final class PresentationTest {
...
@@ -49,10 +49,10 @@ public final class PresentationTest {
int
requestedHeight
=
300
;
int
requestedHeight
=
300
;
Presentation
presentation
=
Presentation
.
createForHeight
(
requestedHeight
);
Presentation
presentation
=
Presentation
.
createForHeight
(
requestedHeight
);
Pair
<
Integer
,
Integer
>
outputSize
=
presentation
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
presentation
.
configure
(
inputWidth
,
inputHeight
);
assertThat
(
outputSize
.
first
).
isEqualTo
(
requestedHeight
*
inputWidth
/
inputHeight
);
assertThat
(
outputSize
.
getWidth
()
).
isEqualTo
(
requestedHeight
*
inputWidth
/
inputHeight
);
assertThat
(
outputSize
.
second
).
isEqualTo
(
requestedHeight
);
assertThat
(
outputSize
.
getHeight
()
).
isEqualTo
(
requestedHeight
);
}
}
@Test
@Test
...
@@ -63,10 +63,10 @@ public final class PresentationTest {
...
@@ -63,10 +63,10 @@ public final class PresentationTest {
Presentation
presentation
=
Presentation
presentation
=
Presentation
.
createForAspectRatio
(
aspectRatio
,
Presentation
.
LAYOUT_SCALE_TO_FIT
);
Presentation
.
createForAspectRatio
(
aspectRatio
,
Presentation
.
LAYOUT_SCALE_TO_FIT
);
Pair
<
Integer
,
Integer
>
outputSize
=
presentation
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
presentation
.
configure
(
inputWidth
,
inputHeight
);
assertThat
(
outputSize
.
first
).
isEqualTo
(
Math
.
round
(
aspectRatio
*
inputHeight
));
assertThat
(
outputSize
.
getWidth
()
).
isEqualTo
(
Math
.
round
(
aspectRatio
*
inputHeight
));
assertThat
(
outputSize
.
second
).
isEqualTo
(
inputHeight
);
assertThat
(
outputSize
.
getHeight
()
).
isEqualTo
(
inputHeight
);
}
}
@Test
@Test
...
@@ -79,9 +79,9 @@ public final class PresentationTest {
...
@@ -79,9 +79,9 @@ public final class PresentationTest {
Presentation
.
createForWidthAndHeight
(
Presentation
.
createForWidthAndHeight
(
requestedWidth
,
requestedHeight
,
Presentation
.
LAYOUT_SCALE_TO_FIT
);
requestedWidth
,
requestedHeight
,
Presentation
.
LAYOUT_SCALE_TO_FIT
);
Pair
<
Integer
,
Integer
>
outputSize
=
presentation
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
presentation
.
configure
(
inputWidth
,
inputHeight
);
assertThat
(
outputSize
.
first
).
isEqualTo
(
requestedWidth
);
assertThat
(
outputSize
.
getWidth
()
).
isEqualTo
(
requestedWidth
);
assertThat
(
outputSize
.
second
).
isEqualTo
(
requestedHeight
);
assertThat
(
outputSize
.
getHeight
()
).
isEqualTo
(
requestedHeight
);
}
}
}
}
library/effect/src/test/java/com/google/android/exoplayer2/effect/ScaleToFitTransformationTest.java
View file @
4a3d693c
...
@@ -17,8 +17,8 @@ package com.google.android.exoplayer2.effect;
...
@@ -17,8 +17,8 @@ package com.google.android.exoplayer2.effect;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
android.util.Pair
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.util.Size
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
...
@@ -38,10 +38,10 @@ public final class ScaleToFitTransformationTest {
...
@@ -38,10 +38,10 @@ public final class ScaleToFitTransformationTest {
ScaleToFitTransformation
scaleToFitTransformation
=
ScaleToFitTransformation
scaleToFitTransformation
=
new
ScaleToFitTransformation
.
Builder
().
build
();
new
ScaleToFitTransformation
.
Builder
().
build
();
Pair
<
Integer
,
Integer
>
outputSize
=
scaleToFitTransformation
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
scaleToFitTransformation
.
configure
(
inputWidth
,
inputHeight
);
assertThat
(
outputSize
.
first
).
isEqualTo
(
inputWidth
);
assertThat
(
outputSize
.
getWidth
()
).
isEqualTo
(
inputWidth
);
assertThat
(
outputSize
.
second
).
isEqualTo
(
inputHeight
);
assertThat
(
outputSize
.
getHeight
()
).
isEqualTo
(
inputHeight
);
}
}
@Test
@Test
...
@@ -53,10 +53,10 @@ public final class ScaleToFitTransformationTest {
...
@@ -53,10 +53,10 @@ public final class ScaleToFitTransformationTest {
.
setScale
(
/* scaleX= */
.
5
f
,
/* scaleY= */
1
f
)
.
setScale
(
/* scaleX= */
.
5
f
,
/* scaleY= */
1
f
)
.
build
();
.
build
();
Pair
<
Integer
,
Integer
>
outputSize
=
scaleToFitTransformation
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
scaleToFitTransformation
.
configure
(
inputWidth
,
inputHeight
);
assertThat
(
outputSize
.
first
).
isEqualTo
(
Math
.
round
(
inputWidth
*
.
5
f
));
assertThat
(
outputSize
.
getWidth
()
).
isEqualTo
(
Math
.
round
(
inputWidth
*
.
5
f
));
assertThat
(
outputSize
.
second
).
isEqualTo
(
inputHeight
);
assertThat
(
outputSize
.
getHeight
()
).
isEqualTo
(
inputHeight
);
}
}
@Test
@Test
...
@@ -66,10 +66,10 @@ public final class ScaleToFitTransformationTest {
...
@@ -66,10 +66,10 @@ public final class ScaleToFitTransformationTest {
ScaleToFitTransformation
scaleToFitTransformation
=
ScaleToFitTransformation
scaleToFitTransformation
=
new
ScaleToFitTransformation
.
Builder
().
setScale
(
/* scaleX= */
2
f
,
/* scaleY= */
1
f
).
build
();
new
ScaleToFitTransformation
.
Builder
().
setScale
(
/* scaleX= */
2
f
,
/* scaleY= */
1
f
).
build
();
Pair
<
Integer
,
Integer
>
outputSize
=
scaleToFitTransformation
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
scaleToFitTransformation
.
configure
(
inputWidth
,
inputHeight
);
assertThat
(
outputSize
.
first
).
isEqualTo
(
inputWidth
*
2
);
assertThat
(
outputSize
.
getWidth
()
).
isEqualTo
(
inputWidth
*
2
);
assertThat
(
outputSize
.
second
).
isEqualTo
(
inputHeight
);
assertThat
(
outputSize
.
getHeight
()
).
isEqualTo
(
inputHeight
);
}
}
@Test
@Test
...
@@ -79,10 +79,10 @@ public final class ScaleToFitTransformationTest {
...
@@ -79,10 +79,10 @@ public final class ScaleToFitTransformationTest {
ScaleToFitTransformation
scaleToFitTransformation
=
ScaleToFitTransformation
scaleToFitTransformation
=
new
ScaleToFitTransformation
.
Builder
().
setScale
(
/* scaleX= */
1
f
,
/* scaleY= */
2
f
).
build
();
new
ScaleToFitTransformation
.
Builder
().
setScale
(
/* scaleX= */
1
f
,
/* scaleY= */
2
f
).
build
();
Pair
<
Integer
,
Integer
>
outputSize
=
scaleToFitTransformation
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
scaleToFitTransformation
.
configure
(
inputWidth
,
inputHeight
);
assertThat
(
outputSize
.
first
).
isEqualTo
(
inputWidth
);
assertThat
(
outputSize
.
getWidth
()
).
isEqualTo
(
inputWidth
);
assertThat
(
outputSize
.
second
).
isEqualTo
(
inputHeight
*
2
);
assertThat
(
outputSize
.
getHeight
()
).
isEqualTo
(
inputHeight
*
2
);
}
}
@Test
@Test
...
@@ -92,10 +92,10 @@ public final class ScaleToFitTransformationTest {
...
@@ -92,10 +92,10 @@ public final class ScaleToFitTransformationTest {
ScaleToFitTransformation
scaleToFitTransformation
=
ScaleToFitTransformation
scaleToFitTransformation
=
new
ScaleToFitTransformation
.
Builder
().
setRotationDegrees
(
90
).
build
();
new
ScaleToFitTransformation
.
Builder
().
setRotationDegrees
(
90
).
build
();
Pair
<
Integer
,
Integer
>
outputSize
=
scaleToFitTransformation
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
scaleToFitTransformation
.
configure
(
inputWidth
,
inputHeight
);
assertThat
(
outputSize
.
first
).
isEqualTo
(
inputHeight
);
assertThat
(
outputSize
.
getWidth
()
).
isEqualTo
(
inputHeight
);
assertThat
(
outputSize
.
second
).
isEqualTo
(
inputWidth
);
assertThat
(
outputSize
.
getHeight
()
).
isEqualTo
(
inputWidth
);
}
}
@Test
@Test
...
@@ -106,9 +106,9 @@ public final class ScaleToFitTransformationTest {
...
@@ -106,9 +106,9 @@ public final class ScaleToFitTransformationTest {
new
ScaleToFitTransformation
.
Builder
().
setRotationDegrees
(
45
).
build
();
new
ScaleToFitTransformation
.
Builder
().
setRotationDegrees
(
45
).
build
();
long
expectedOutputWidthHeight
=
247
;
long
expectedOutputWidthHeight
=
247
;
Pair
<
Integer
,
Integer
>
outputSize
=
scaleToFitTransformation
.
configure
(
inputWidth
,
inputHeight
);
Size
outputSize
=
scaleToFitTransformation
.
configure
(
inputWidth
,
inputHeight
);
assertThat
(
outputSize
.
first
).
isEqualTo
(
expectedOutputWidthHeight
);
assertThat
(
outputSize
.
getWidth
()
).
isEqualTo
(
expectedOutputWidthHeight
);
assertThat
(
outputSize
.
second
).
isEqualTo
(
expectedOutputWidthHeight
);
assertThat
(
outputSize
.
getHeight
()
).
isEqualTo
(
expectedOutputWidthHeight
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment