mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Repect Composition's HDR mode setting using OpenGL
Subsequent CLs will add support for other HDR modes PiperOrigin-RevId: 708340216
This commit is contained in:
parent
5c40498054
commit
8188f7a865
@ -123,6 +123,7 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
|||||||
private PreviewingVideoGraph.@MonotonicNonNull Factory previewingVideoGraphFactory;
|
private PreviewingVideoGraph.@MonotonicNonNull Factory previewingVideoGraphFactory;
|
||||||
private List<Effect> compositionEffects;
|
private List<Effect> compositionEffects;
|
||||||
private Clock clock;
|
private Clock clock;
|
||||||
|
private boolean requestOpenGlToneMapping;
|
||||||
private boolean built;
|
private boolean built;
|
||||||
|
|
||||||
/** Creates a builder. */
|
/** Creates a builder. */
|
||||||
@ -192,6 +193,20 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether to tone map the input video with OpenGL.
|
||||||
|
*
|
||||||
|
* <p>By default, the input is not tone mapped.
|
||||||
|
*
|
||||||
|
* @param requestOpenGlToneMapping Whether tone mapping is requested.
|
||||||
|
* @return This builder, for convenience.
|
||||||
|
*/
|
||||||
|
@CanIgnoreReturnValue
|
||||||
|
public Builder setRequestOpenGlToneMapping(boolean requestOpenGlToneMapping) {
|
||||||
|
this.requestOpenGlToneMapping = requestOpenGlToneMapping;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the {@link PlaybackVideoGraphWrapper}.
|
* Builds the {@link PlaybackVideoGraphWrapper}.
|
||||||
*
|
*
|
||||||
@ -241,6 +256,7 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
|||||||
private final VideoSink.VideoFrameHandler videoFrameHandler;
|
private final VideoSink.VideoFrameHandler videoFrameHandler;
|
||||||
private final Clock clock;
|
private final Clock clock;
|
||||||
private final CopyOnWriteArraySet<PlaybackVideoGraphWrapper.Listener> listeners;
|
private final CopyOnWriteArraySet<PlaybackVideoGraphWrapper.Listener> listeners;
|
||||||
|
private final boolean requestOpenGlToneMapping;
|
||||||
|
|
||||||
private Format videoGraphOutputFormat;
|
private Format videoGraphOutputFormat;
|
||||||
private @MonotonicNonNull HandlerWrapper handler;
|
private @MonotonicNonNull HandlerWrapper handler;
|
||||||
@ -291,6 +307,7 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
|||||||
};
|
};
|
||||||
listeners = new CopyOnWriteArraySet<>();
|
listeners = new CopyOnWriteArraySet<>();
|
||||||
listeners.add(inputVideoSink);
|
listeners.add(inputVideoSink);
|
||||||
|
requestOpenGlToneMapping = builder.requestOpenGlToneMapping;
|
||||||
videoGraphOutputFormat = new Format.Builder().build();
|
videoGraphOutputFormat = new Format.Builder().build();
|
||||||
state = STATE_CREATED;
|
state = STATE_CREATED;
|
||||||
lastOutputBufferPresentationTimeUs = C.TIME_UNSET;
|
lastOutputBufferPresentationTimeUs = C.TIME_UNSET;
|
||||||
@ -425,13 +442,18 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
|||||||
checkState(state == STATE_CREATED);
|
checkState(state == STATE_CREATED);
|
||||||
|
|
||||||
ColorInfo inputColorInfo = getAdjustedInputColorInfo(sourceFormat.colorInfo);
|
ColorInfo inputColorInfo = getAdjustedInputColorInfo(sourceFormat.colorInfo);
|
||||||
ColorInfo outputColorInfo = inputColorInfo;
|
ColorInfo outputColorInfo;
|
||||||
if (inputColorInfo.colorTransfer == C.COLOR_TRANSFER_HLG && Util.SDK_INT < 34) {
|
if (requestOpenGlToneMapping) {
|
||||||
|
outputColorInfo = ColorInfo.SDR_BT709_LIMITED;
|
||||||
|
} else {
|
||||||
|
outputColorInfo = inputColorInfo;
|
||||||
|
if (outputColorInfo.colorTransfer == C.COLOR_TRANSFER_HLG && Util.SDK_INT < 34) {
|
||||||
// PQ SurfaceView output is supported from API 33, but HLG output is supported from API 34.
|
// PQ SurfaceView output is supported from API 33, but HLG output is supported from API 34.
|
||||||
// Therefore, convert HLG to PQ below API 34, so that HLG input can be displayed properly on
|
// Therefore, convert HLG to PQ below API 34, so that HLG input can be displayed properly on
|
||||||
// API 33.
|
// API 33.
|
||||||
outputColorInfo =
|
outputColorInfo =
|
||||||
inputColorInfo.buildUpon().setColorTransfer(C.COLOR_TRANSFER_ST2084).build();
|
outputColorInfo.buildUpon().setColorTransfer(C.COLOR_TRANSFER_ST2084).build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
handler = clock.createHandler(checkStateNotNull(Looper.myLooper()), /* callback= */ null);
|
handler = clock.createHandler(checkStateNotNull(Looper.myLooper()), /* callback= */ null);
|
||||||
try {
|
try {
|
||||||
|
@ -674,6 +674,8 @@ public final class CompositionPlayer extends SimpleBasePlayer
|
|||||||
.setPreviewingVideoGraphFactory(checkNotNull(previewingVideoGraphFactory))
|
.setPreviewingVideoGraphFactory(checkNotNull(previewingVideoGraphFactory))
|
||||||
.setCompositionEffects(composition.effects.videoEffects)
|
.setCompositionEffects(composition.effects.videoEffects)
|
||||||
.setClock(clock)
|
.setClock(clock)
|
||||||
|
.setRequestOpenGlToneMapping(
|
||||||
|
composition.hdrMode == Composition.HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_OPEN_GL)
|
||||||
.build();
|
.build();
|
||||||
playbackVideoGraphWrapper.addListener(this);
|
playbackVideoGraphWrapper.addListener(this);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user