Skip to content

Commit aaa58c5

Browse files
committed
fix dolby-vision
1 parent cda405b commit aaa58c5

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ private void eglSetup() {
6161
// to minimize artifacts from possible YUV conversion.
6262
int[] attribList = {
6363
EGL14.EGL_RED_SIZE, 8,
64-
EGL14.EGL_GREEN_SIZE, 8,
65-
EGL14.EGL_BLUE_SIZE, 8,
66-
EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
67-
EGLExt.EGL_RECORDABLE_ANDROID, 1,
64+
EGL14.EGL_RED_SIZE, 10,
65+
EGL14.EGL_GREEN_SIZE, 10,
66+
EGL14.EGL_BLUE_SIZE, 10,
67+
EGL14.EGL_ALPHA_SIZE, 2,
68+
EGL14.EGL_RENDERABLE_TYPE, EGLExt.EGL_OPENGL_ES3_BIT_KHR,
69+
// EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
6870
EGL14.EGL_NONE
6971
};
7072
int[] numConfigs = new int[1];
@@ -102,6 +104,13 @@ public void updateSize(int width, int height) {
102104
}
103105
}
104106

107+
// private int EGL_GL_COLORSPACE_KHR = 0x309D;
108+
// private int EGL_GL_COLORSPACE_BT2020_LINEAR_EXT = 0x333F;
109+
// private int EGL_GL_COLORSPACE_BT2020_PQ_EXT = 0x3340;
110+
// private int EGL_GL_COLORSPACE_DISPLAY_P3_LINEAR_EXT = 0x3362;
111+
// private int EGL_GL_COLORSPACE_DISPLAY_P3_EXT = 0x3363;
112+
// private int EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT = 0x3490;
113+
105114
private void createEGLSurface() {
106115
//EGLConfig[] configs = new EGLConfig[1];
107116
int[] surfaceAttribs = {

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,17 @@ private void prepareEncoder() throws Exception {
303303
mOutputFormat.setByteBuffer(MediaFormat.KEY_HDR_STATIC_INFO,
304304
mOriVideoFormat.getByteBuffer(MediaFormat.KEY_HDR_STATIC_INFO));
305305
}
306-
mOutputFormat.setFeatureEnabled("hdr-editing", true);
307306
if (isDolby) {
308307
//如果是杜比
309-
mOutputFormat.setInteger(MediaFormat.KEY_PROFILE,
310-
MediaCodecInfo.CodecProfileLevel.DolbyVisionProfileDvheSt);
308+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
309+
mOutputFormat.setInteger(MediaFormat.KEY_PROFILE,
310+
MediaCodecInfo.CodecProfileLevel.DolbyVisionProfileDvheSt);
311+
} else {
312+
mOutputFormat.setInteger(MediaFormat.KEY_PROFILE,
313+
MediaCodecInfo.CodecProfileLevel.DolbyVisionProfileDvheStn);
314+
}
311315
} else {
316+
mOutputFormat.setFeatureEnabled("hdr-editing", true);
312317
switch (colorTransfer) {
313318
case MediaFormat.COLOR_TRANSFER_HLG:
314319
//HLG(HGL10)

0 commit comments

Comments
 (0)