Commit e510d990 by huangdarwin Committed by microkatz

HDR: Set decoder codec profile and level if available.

This should be necessary to ensure decoders see fewer errors.

Setting this resulted in removing native_dequeueOutputBuffer errors on OMX.MTK decoders for in-app tone mapping prototyping.

PiperOrigin-RevId: 486715941
parent 23e724a0
...@@ -22,11 +22,13 @@ import static androidx.media3.common.util.Util.SDK_INT; ...@@ -22,11 +22,13 @@ import static androidx.media3.common.util.Util.SDK_INT;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.media.MediaFormat; import android.media.MediaFormat;
import android.util.Pair;
import android.view.Surface; import android.view.Surface;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.media3.common.Format; import androidx.media3.common.Format;
import androidx.media3.common.MimeTypes; import androidx.media3.common.MimeTypes;
import androidx.media3.common.util.MediaFormatUtil; import androidx.media3.common.util.MediaFormatUtil;
import androidx.media3.exoplayer.mediacodec.MediaCodecUtil;
import org.checkerframework.checker.nullness.qual.RequiresNonNull; import org.checkerframework.checker.nullness.qual.RequiresNonNull;
/** A default implementation of {@link Codec.DecoderFactory}. */ /** A default implementation of {@link Codec.DecoderFactory}. */
...@@ -91,6 +93,13 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; ...@@ -91,6 +93,13 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
} }
@Nullable @Nullable
Pair<Integer, Integer> codecProfileAndLevel = MediaCodecUtil.getCodecProfileAndLevel(format);
if (codecProfileAndLevel != null) {
MediaFormatUtil.maybeSetInteger(
mediaFormat, MediaFormat.KEY_PROFILE, codecProfileAndLevel.first);
}
@Nullable
String mediaCodecName = EncoderUtil.findCodecForFormat(mediaFormat, /* isDecoder= */ true); String mediaCodecName = EncoderUtil.findCodecForFormat(mediaFormat, /* isDecoder= */ true);
if (mediaCodecName == null) { if (mediaCodecName == null) {
throw createTransformationException(format); throw createTransformationException(format);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment