ExoPlayer
ExoPlayer copied to clipboard
Add Dialog Enhancement Control support for AC4 audio tracks
The AC4 audio decoder features a dialog enhancement mode that allows the user to boost the dialog from the played content. The boost of the dialog can be tuned to the listener's need. This patch maps the control of the dialog boost as a user controllable playback parameter (like playback speed or pitch) and proposes a possible implementation in the UI in the form of "off, low, mid, high" presets.
- tested on Lenovo P11 tablet and samsung phones
Signed-off-by: glass [email protected]
I think this should be implemented in a format agnostic way, more along the lines of the approach suggested in https://github.com/google/ExoPlayer/issues/8636 where there's a generic MSG_SET_CODEC_PARAMETERS that can be used to send arbitrary parameters to the codecs within the renderers.
Hi, thanks for sharing the view and proposing to implement a codec/renderer specific messaging and a setCodecParameters() as opposed to reusing the exisiting setPlaybackParameters().
How different would the suggested setCodecParametes() be from the existing sendRendererMessage():
private void sendVolumeToRenderers() {
float scaledVolume = volume * audioFocusManager.getVolumeMultiplier();
sendRendererMessage(TRACK_TYPE_AUDIO, MSG_SET_VOLUME, scaledVolume);
}
I understand that the MSG_SET_CODEC_PARAMETERS would have to bundle multiple controls , say multiple TLV fields , one of them being the AC4_DIALOG_ENHANCEMENT, others the AAC_DRC parameters and so on and that the message parser would have to dispatch the TLVs to the actual codec.setParameter function as in the ConfigureAC4() from my commit :
public void ConfigureAC4(int dialogEnhancementGain) {
if (audioCodecInfo != null && audioCodecInfo.name.contains("ac4")) {
Bundle bundle = new Bundle(1);
bundle.putInt("vendor.dolby.dialog-enhancement-gain.value", dialogEnhancementGain);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
super.getCodec().setParameters(bundle);
}
}
}
Is my understanding correct ? or did you target a larger refactoring that would replace AAC_DRC_PARAMETERs with codec agnostic DRC parameters and my AC4_DIALOG_ENHANCEMENT gain with a codec agnostic dialog enhancement gain without knowing whether the underlying codec will actually apply it or ignore it ?
How different would the suggested setCodecParametes() be from the existing sendRendererMessage()
I would have thought that you'd want to send them to all renderers, which can apply or ignore them as needed. In which case the implementation would look something like:
@Override
public void setCodecParameters(CodecParameters params) {
verifyApplicationThread();
for (Renderer renderer : renderers) {
createMessageInternal(renderer).setType(MSG_SET_CODEC_PARAMETERS).setPayload(params).send();
}
}
Alternatively, the method could also take a trackType argument and use sendRendererMessage to send the parameters to all renderers of that track type.
CodecParameters should be a fairly generic (key,value) object. It shouldn't contain anything AC4 specific, except perhaps some public static final String KEY_DOLBY_XYZ style constants. In other words, it should be equally possibly to use CodecParameters to deliver some custom video parameter to a video codec.
@g-lass - Just checking, are you planning to work on a generic version of this? Thanks!
Hi, I have reworked my commit so that it implements a generic MediaCodecParameter messaging between the application and the exoplayer renderers. The new MediaCodecParameters class defines the DIALOG_ENHANCEMENT_LEVEL Key and should be extendable with any other codec parameters. In this commit only the audioRenderer has been modified to manage the message.
Hi, Any comment / further guidance with respect to the review of my last commit ?
Closing all PRs on this deprecated project. We are now unable to merge PRs from here. If you would like us to consider this change again please file a new PR on the media3 project: https://github.com/androidx/media/pulls