Skip to content

Commit 6808ff1

Browse files
committed
update
1 parent e6d963a commit 6808ff1

5 files changed

Lines changed: 22 additions & 84 deletions

File tree

app/src/main/java/com/demo/mediacodec/DecodersInfoActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
3636
MediaFormat format = cap.getDefaultFormat();
3737
s.append(format).append("\n");
3838

39-
if (cap.colorFormats != null) {
39+
if (cap.colorFormats != null && cap.colorFormats.length > 0) {
4040
s.append("colorFormat:[\n");
4141
for (int colorFormat : cap.colorFormats) {
4242
s.append(colorFormat).append(" ");

app/src/main/java/com/demo/mediacodec/EncodersInfoActivity.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
3737
continue;
3838
}
3939
MediaFormat defaultFormat = caps.getDefaultFormat();
40+
String mimeType = caps.getMimeType();
4041
s.append("defaultFormat: ").append(defaultFormat).append("\n");
4142
MediaCodecInfo.VideoCapabilities vcaps = caps.getVideoCapabilities();
4243
if (vcaps != null) {
@@ -47,17 +48,28 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
4748
Range<Integer> bitrateRange = vcaps.getBitrateRange();
4849
s.append("bitrateRange: ").append(bitrateRange.getLower()).append("-").append(bitrateRange.getUpper()).append("\n");
4950
}
50-
if (caps.colorFormats != null) {
51+
if (caps.colorFormats != null && caps.colorFormats.length > 0) {
5152
s.append("colorFormat:[\n");
53+
s.append("\t");
5254
for (int colorFormat : caps.colorFormats) {
5355
s.append(colorFormat).append(" ");
5456
}
5557
s.append("\n]\n");
5658
}
5759
if (caps.profileLevels != null) {
58-
s.append("profileLevels:[\n");
60+
s.append("profileLevels:[");
5961
for (MediaCodecInfo.CodecProfileLevel profileLevel : caps.profileLevels) {
60-
s.append("\tprofile:").append(profileLevel.profile).append(" ").append("level:").append(profileLevel.level).append("\n");
62+
s.append("\n");
63+
s.append("\tprofile:").append(profileLevel.profile).append(" ").append("level:").append(profileLevel.level);
64+
if ("video/avc".equalsIgnoreCase(mimeType)) {
65+
if (profileLevel.profile >= MediaCodecInfo.CodecProfileLevel.AV1ProfileMain10) {
66+
s.append("(HDR)");
67+
}
68+
} else if ("video/hevc".equalsIgnoreCase(mimeType)) {
69+
if (profileLevel.profile >= MediaCodecInfo.CodecProfileLevel.HEVCProfileMain10) {
70+
s.append("(HDR)");
71+
}
72+
}
6173
}
6274
s.append("\n]\n");
6375
}

app/src/main/java/com/demo/mediacodec/transcode/OutputSurface.java

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import android.graphics.SurfaceTexture;
55
import android.opengl.EGL14;
6-
import android.opengl.EGLConfig;
76
import android.opengl.EGLContext;
87
import android.opengl.EGLDisplay;
98
import android.opengl.EGLSurface;
@@ -42,22 +41,6 @@ public class OutputSurface implements SurfaceTexture.OnFrameAvailableListener {
4241

4342
private TextureRender mTextureRender;
4443

45-
/**
46-
* Creates an OutputSurface backed by a pbuffer with the specifed dimensions. The new
47-
* EGL context and surface will be made current. Creates a Surface that can be passed
48-
* to MediaCodec.configure().
49-
*/
50-
public OutputSurface(int width, int height) {
51-
if (width <= 0 || height <= 0) {
52-
throw new IllegalArgumentException();
53-
}
54-
55-
eglSetup(width, height);
56-
makeCurrent();
57-
58-
setup(this);
59-
}
60-
6144
/**
6245
* Creates an OutputSurface using the current EGL context (rather than establishing a
6346
* new one). Creates a Surface that can be passed to MediaCodec.configure().
@@ -66,10 +49,6 @@ public OutputSurface() {
6649
setup(this);
6750
}
6851

69-
public OutputSurface(final SurfaceTexture.OnFrameAvailableListener listener) {
70-
setup(listener);
71-
}
72-
7352
/**
7453
* Creates instances of TextureRender and SurfaceTexture, and a Surface associated
7554
* with the SurfaceTexture.
@@ -101,63 +80,6 @@ private void setup(SurfaceTexture.OnFrameAvailableListener listener) {
10180
mSurface = new Surface(mSurfaceTexture);
10281
}
10382

104-
/**
105-
* Prepares EGL. We want a GLES 2.0 context and a surface that supports pbuffer.
106-
*/
107-
private void eglSetup(int width, int height) {
108-
mEGLDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
109-
if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
110-
throw new RuntimeException("unable to get EGL14 display");
111-
}
112-
int[] version = new int[2];
113-
if (!EGL14.eglInitialize(mEGLDisplay, version, 0, version, 1)) {
114-
mEGLDisplay = null;
115-
throw new RuntimeException("unable to initialize EGL14");
116-
}
117-
118-
// Configure EGL for pbuffer and OpenGL ES 2.0. We want enough RGB bits
119-
// to be able to tell if the frame is reasonable.
120-
int[] attribList = {
121-
EGL14.EGL_RED_SIZE, 8,
122-
EGL14.EGL_GREEN_SIZE, 8,
123-
EGL14.EGL_BLUE_SIZE, 8,
124-
EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
125-
EGL14.EGL_SURFACE_TYPE, EGL14.EGL_PBUFFER_BIT,
126-
EGL14.EGL_NONE
127-
};
128-
EGLConfig[] configs = new EGLConfig[1];
129-
int[] numConfigs = new int[1];
130-
if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length,
131-
numConfigs, 0)) {
132-
throw new RuntimeException("unable to find RGB888+recordable ES2 EGL config");
133-
}
134-
135-
// Configure context for OpenGL ES 2.0.
136-
int[] attrib_list = {
137-
EGL14.EGL_CONTEXT_CLIENT_VERSION, 2,
138-
EGL14.EGL_NONE
139-
};
140-
mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT,
141-
attrib_list, 0);
142-
checkEglError("eglCreateContext");
143-
if (mEGLContext == null) {
144-
throw new RuntimeException("null context");
145-
}
146-
147-
// Create a pbuffer surface. By using this for output, we can use glReadPixels
148-
// to test values in the output.
149-
int[] surfaceAttribs = {
150-
EGL14.EGL_WIDTH, width,
151-
EGL14.EGL_HEIGHT, height,
152-
EGL14.EGL_NONE
153-
};
154-
mEGLSurface = EGL14.eglCreatePbufferSurface(mEGLDisplay, configs[0], surfaceAttribs, 0);
155-
checkEglError("eglCreatePbufferSurface");
156-
if (mEGLSurface == null) {
157-
throw new RuntimeException("surface was null");
158-
}
159-
}
160-
16183
/**
16284
* Discard all resources held by this class, notably the EGL context.
16385
*/

app/src/main/res/layout/activity_decoders_info.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@
66
<TextView
77
android:id="@+id/tv_decoders_info"
88
android:layout_width="match_parent"
9-
android:layout_height="wrap_content"/>
9+
android:layout_height="wrap_content"
10+
android:lineSpacingMultiplier="1.2"
11+
android:textSize="15sp" />
1012
</ScrollView>

app/src/main/res/layout/activity_encoders_info.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@
66
<TextView
77
android:id="@+id/tv_encoders_info"
88
android:layout_width="match_parent"
9-
android:layout_height="wrap_content"/>
9+
android:layout_height="wrap_content"
10+
android:lineSpacingMultiplier="1.2"
11+
android:textSize="15sp" />
1012
</ScrollView>

0 commit comments

Comments
 (0)