Loading media/libstagefright/MediaCodec.cpp +104 −59 Original line number Diff line number Diff line Loading @@ -807,9 +807,7 @@ MediaCodec::MediaCodec( mWidth(0), mHeight(0), mRotationDegrees(0), mConfigColorTransfer(-1), mHDRStaticInfo(false), mHDR10PlusInfo(false), mHdrInfoFlags(0), mDequeueInputTimeoutGeneration(0), mDequeueInputReplyID(0), mDequeueOutputTimeoutGeneration(0), Loading Loading @@ -968,29 +966,73 @@ void MediaCodec::updateMediametrics() { mIndexOfFirstFrameWhenLowLatencyOn); } mediametrics_setInt32(mMetricsHandle, kCodecHDRStaticInfo, mHDRStaticInfo ? 1 : 0); mediametrics_setInt32(mMetricsHandle, kCodecHDR10PlusInfo, mHDR10PlusInfo ? 1 : 0); #if 0 // enable for short term, only while debugging updateEphemeralMediametrics(mMetricsHandle); #endif } void MediaCodec::updateHDRFormatMetric() { void MediaCodec::updateHdrMetrics(bool isConfig) { if ((mDomain != DOMAIN_VIDEO && mDomain != DOMAIN_IMAGE) || mMetricsHandle == 0) { return; } int32_t colorStandard = -1; if (mOutputFormat->findInt32(KEY_COLOR_STANDARD, &colorStandard)) { mediametrics_setInt32(mMetricsHandle, isConfig ? kCodecConfigColorStandard : kCodecParsedColorStandard, colorStandard); } int32_t colorRange = -1; if (mOutputFormat->findInt32(KEY_COLOR_RANGE, &colorRange)) { mediametrics_setInt32(mMetricsHandle, isConfig ? kCodecConfigColorRange : kCodecParsedColorRange, colorRange); } int32_t colorTransfer = -1; if (mOutputFormat->findInt32(KEY_COLOR_TRANSFER, &colorTransfer)) { mediametrics_setInt32(mMetricsHandle, isConfig ? kCodecConfigColorTransfer : kCodecParsedColorTransfer, colorTransfer); } HDRStaticInfo info; if (ColorUtils::getHDRStaticInfoFromFormat(mOutputFormat, &info) && ColorUtils::isHDRStaticInfoValid(&info)) { mHdrInfoFlags |= kFlagHasHdrStaticInfo; } mediametrics_setInt32(mMetricsHandle, kCodecHDRStaticInfo, (mHdrInfoFlags & kFlagHasHdrStaticInfo) ? 1 : 0); sp<ABuffer> hdr10PlusInfo; if (mOutputFormat->findBuffer("hdr10-plus-info", &hdr10PlusInfo) && hdr10PlusInfo != nullptr && hdr10PlusInfo->size() > 0) { mHdrInfoFlags |= kFlagHasHdr10PlusInfo; } mediametrics_setInt32(mMetricsHandle, kCodecHDR10PlusInfo, (mHdrInfoFlags & kFlagHasHdr10PlusInfo) ? 1 : 0); // hdr format sp<AMessage> codedFormat = (mFlags & kFlagIsEncoder) ? mOutputFormat : mInputFormat; AString mime; int32_t profile = -1; AString mediaType; if (mOutputFormat->findInt32(KEY_PROFILE, &profile) && mOutputFormat->findString("mime", &mediaType)) { hdr_format hdrFormat = getHDRFormat(profile, mConfigColorTransfer, mediaType); if (codedFormat->findString("mime", &mime) && codedFormat->findInt32(KEY_PROFILE, &profile) && colorTransfer != -1) { hdr_format hdrFormat = getHdrFormat(mime, profile, colorTransfer); mediametrics_setInt32(mMetricsHandle, kCodecHDRFormat, static_cast<int>(hdrFormat)); } } hdr_format MediaCodec::getHDRFormat(const int32_t profile, const int32_t transfer, const AString &mediaType) { switch (transfer) { hdr_format MediaCodec::getHdrFormat(const AString &mime, const int32_t profile, const int32_t colorTransfer) { return (mFlags & kFlagIsEncoder) ? getHdrFormatForEncoder(mime, profile, colorTransfer) : getHdrFormatForDecoder(mime, profile, colorTransfer); } hdr_format MediaCodec::getHdrFormatForEncoder(const AString &mime, const int32_t profile, const int32_t colorTransfer) { switch (colorTransfer) { case COLOR_TRANSFER_ST2084: if (mediaType.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_VP9)) { if (mime.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_VP9)) { switch (profile) { case VP9Profile2HDR: return HDR_FORMAT_HDR10; Loading @@ -999,7 +1041,7 @@ hdr_format MediaCodec::getHDRFormat(const int32_t profile, const int32_t transfe default: return HDR_FORMAT_NONE; } } else if (mediaType.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_AV1)) { } else if (mime.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_AV1)) { switch (profile) { case AV1ProfileMain10HDR10: return HDR_FORMAT_HDR10; Loading @@ -1008,7 +1050,7 @@ hdr_format MediaCodec::getHDRFormat(const int32_t profile, const int32_t transfe default: return HDR_FORMAT_NONE; } } else if (mediaType.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_HEVC)) { } else if (mime.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_HEVC)) { switch (profile) { case HEVCProfileMain10HDR10: return HDR_FORMAT_HDR10; Loading @@ -1021,7 +1063,7 @@ hdr_format MediaCodec::getHDRFormat(const int32_t profile, const int32_t transfe return HDR_FORMAT_NONE; } case COLOR_TRANSFER_HLG: if (!mediaType.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_DOLBY_VISION)) { if (!mime.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_DOLBY_VISION)) { return HDR_FORMAT_HLG; } else { // TODO: DOLBY format Loading @@ -1032,6 +1074,47 @@ hdr_format MediaCodec::getHDRFormat(const int32_t profile, const int32_t transfe } } hdr_format MediaCodec::getHdrFormatForDecoder(const AString &mime, const int32_t profile, const int32_t colorTransfer) { switch (colorTransfer) { case COLOR_TRANSFER_ST2084: if (!(mHdrInfoFlags & kFlagHasHdrStaticInfo) || !profileSupport10Bits(mime, profile)) { return HDR_FORMAT_NONE; } return mHdrInfoFlags & kFlagHasHdr10PlusInfo ? HDR_FORMAT_HDR10PLUS : HDR_FORMAT_HDR10; case COLOR_TRANSFER_HLG: if (!mime.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_DOLBY_VISION)) { return HDR_FORMAT_HLG; } // TODO: DOLBY format } return HDR_FORMAT_NONE; } bool MediaCodec::profileSupport10Bits(const AString &mime, const int32_t profile) { if (mime.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_AV1)) { return true; } else if (mime.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_VP9)) { switch (profile) { case VP9Profile2: case VP9Profile3: case VP9Profile2HDR: case VP9Profile3HDR: case VP9Profile2HDR10Plus: case VP9Profile3HDR10Plus: return true; } } else if (mime.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_HEVC)) { switch (profile) { case HEVCProfileMain10: case HEVCProfileMain10HDR10: case HEVCProfileMain10HDR10Plus: return true; } } return false; } // called to update info being passed back via getMetrics(), which is a // unique copy for that call, no concurrent access worries. Loading Loading @@ -1081,6 +1164,7 @@ void MediaCodec::flushMediametrics() { // ensure mutex while we do our own work Mutex::Autolock _lock(mMetricsLock); mHdrInfoFlags = 0; if (mMetricsHandle != 0) { if (mediametrics_count(mMetricsHandle) > 0) { mediametrics_selfRecord(mMetricsHandle); Loading Loading @@ -1735,24 +1819,6 @@ status_t MediaCodec::configure( mediametrics_setInt32(nextMetricsHandle, kCodecPriority, priority); } } int32_t colorStandard = -1; if (format->findInt32(KEY_COLOR_STANDARD, &colorStandard)) { mediametrics_setInt32(mMetricsHandle, kCodecConfigColorStandard, colorStandard); } int32_t colorRange = -1; if (format->findInt32(KEY_COLOR_RANGE, &colorRange)) { mediametrics_setInt32(mMetricsHandle, kCodecConfigColorRange, colorRange); } int32_t colorTransfer = -1; if (format->findInt32(KEY_COLOR_TRANSFER, &colorTransfer)) { mConfigColorTransfer = colorTransfer; mediametrics_setInt32(mMetricsHandle, kCodecConfigColorTransfer, colorTransfer); } HDRStaticInfo info; if (ColorUtils::getHDRStaticInfoFromFormat(format, &info) && ColorUtils::isHDRStaticInfoValid(&info)) { mHDRStaticInfo = true; } } // Prevent possible integer overflow in downstream code. Loading Loading @@ -3439,8 +3505,6 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { CHECK(msg->findMessage("input-format", &mInputFormat)); CHECK(msg->findMessage("output-format", &mOutputFormat)); updateHDRFormatMetric(); // limit to confirming the opt-in behavior to minimize any behavioral change if (mSurface != nullptr && !mAllowFrameDroppingBySurface) { // signal frame dropping mode in the input format as this may also be Loading Loading @@ -3483,6 +3547,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { if (interestingFormat->findInt32("level", &level)) { mediametrics_setInt32(mMetricsHandle, kCodecLevel, level); } updateHdrMetrics(true /* isConfig */); // bitrate and bitrate mode, encoder only if (mFlags & kFlagIsEncoder) { // encoder specific values Loading Loading @@ -3522,7 +3587,6 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { mComponentName.c_str(), mInputFormat->debugString(4).c_str(), mOutputFormat->debugString(4).c_str()); updateHDRFormatMetric(); CHECK(obj != NULL); response->setObject("input-surface", obj); mHaveInputSurface = true; Loading @@ -3547,7 +3611,6 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { if (!msg->findInt32("err", &err)) { CHECK(msg->findMessage("input-format", &mInputFormat)); CHECK(msg->findMessage("output-format", &mOutputFormat)); updateHDRFormatMetric(); mHaveInputSurface = true; } else { response->setInt32("err", err); Loading Loading @@ -4760,7 +4823,6 @@ void MediaCodec::handleOutputFormatChangeIfNeeded(const sp<MediaCodecBuffer> &bu buffer->meta()->setObject("changedKeys", changedKeys); } mOutputFormat = format; updateHDRFormatMetric(); mapFormat(mComponentName, format, nullptr, true); ALOGV("[%s] output format changed to: %s", mComponentName.c_str(), mOutputFormat->debugString(4).c_str()); Loading @@ -4786,9 +4848,6 @@ void MediaCodec::handleOutputFormatChangeIfNeeded(const sp<MediaCodecBuffer> &bu HDRStaticInfo info; if (ColorUtils::getHDRStaticInfoFromFormat(mOutputFormat, &info)) { setNativeWindowHdrMetadata(mSurface.get(), &info); if (ColorUtils::isHDRStaticInfoValid(&info)) { mHDRStaticInfo = true; } } } Loading @@ -4797,7 +4856,6 @@ void MediaCodec::handleOutputFormatChangeIfNeeded(const sp<MediaCodecBuffer> &bu && hdr10PlusInfo != nullptr && hdr10PlusInfo->size() > 0) { native_window_set_buffers_hdr10_plus_metadata(mSurface.get(), hdr10PlusInfo->size(), hdr10PlusInfo->data()); mHDR10PlusInfo = true; } if (mime.startsWithIgnoreCase("video/")) { Loading Loading @@ -4843,20 +4901,7 @@ void MediaCodec::handleOutputFormatChangeIfNeeded(const sp<MediaCodecBuffer> &bu } } if (mMetricsHandle != 0) { int32_t colorStandard = -1; if (format->findInt32(KEY_COLOR_STANDARD, &colorStandard)) { mediametrics_setInt32(mMetricsHandle, kCodecParsedColorStandard, colorStandard); } int32_t colorRange = -1; if (format->findInt32( KEY_COLOR_RANGE, &colorRange)) { mediametrics_setInt32(mMetricsHandle, kCodecParsedColorRange, colorRange); } int32_t colorTransfer = -1; if (format->findInt32(KEY_COLOR_TRANSFER, &colorTransfer)) { mediametrics_setInt32(mMetricsHandle, kCodecParsedColorTransfer, colorTransfer); } } updateHdrMetrics(false /* isConfig */); } void MediaCodec::extractCSD(const sp<AMessage> &format) { Loading media/libstagefright/include/media/stagefright/MediaCodec.h +13 −6 Original line number Diff line number Diff line Loading @@ -456,12 +456,19 @@ private: int32_t mRotationDegrees; int32_t mAllowFrameDroppingBySurface; int32_t mConfigColorTransfer; bool mHDRStaticInfo; bool mHDR10PlusInfo; void updateHDRFormatMetric(); hdr_format getHDRFormat(const int32_t profile, const int32_t transfer, const AString &mediaType); enum { kFlagHasHdrStaticInfo = 1, kFlagHasHdr10PlusInfo = 2, }; uint32_t mHdrInfoFlags; void updateHdrMetrics(bool isConfig); hdr_format getHdrFormat(const AString &mime, const int32_t profile, const int32_t colorTransfer); hdr_format getHdrFormatForEncoder(const AString &mime, const int32_t profile, const int32_t colorTransfer); hdr_format getHdrFormatForDecoder(const AString &mime, const int32_t profile, const int32_t colorTransfer); bool profileSupport10Bits(const AString &mime, const int32_t profile); // initial create parameters AString mInitName; Loading Loading
media/libstagefright/MediaCodec.cpp +104 −59 Original line number Diff line number Diff line Loading @@ -807,9 +807,7 @@ MediaCodec::MediaCodec( mWidth(0), mHeight(0), mRotationDegrees(0), mConfigColorTransfer(-1), mHDRStaticInfo(false), mHDR10PlusInfo(false), mHdrInfoFlags(0), mDequeueInputTimeoutGeneration(0), mDequeueInputReplyID(0), mDequeueOutputTimeoutGeneration(0), Loading Loading @@ -968,29 +966,73 @@ void MediaCodec::updateMediametrics() { mIndexOfFirstFrameWhenLowLatencyOn); } mediametrics_setInt32(mMetricsHandle, kCodecHDRStaticInfo, mHDRStaticInfo ? 1 : 0); mediametrics_setInt32(mMetricsHandle, kCodecHDR10PlusInfo, mHDR10PlusInfo ? 1 : 0); #if 0 // enable for short term, only while debugging updateEphemeralMediametrics(mMetricsHandle); #endif } void MediaCodec::updateHDRFormatMetric() { void MediaCodec::updateHdrMetrics(bool isConfig) { if ((mDomain != DOMAIN_VIDEO && mDomain != DOMAIN_IMAGE) || mMetricsHandle == 0) { return; } int32_t colorStandard = -1; if (mOutputFormat->findInt32(KEY_COLOR_STANDARD, &colorStandard)) { mediametrics_setInt32(mMetricsHandle, isConfig ? kCodecConfigColorStandard : kCodecParsedColorStandard, colorStandard); } int32_t colorRange = -1; if (mOutputFormat->findInt32(KEY_COLOR_RANGE, &colorRange)) { mediametrics_setInt32(mMetricsHandle, isConfig ? kCodecConfigColorRange : kCodecParsedColorRange, colorRange); } int32_t colorTransfer = -1; if (mOutputFormat->findInt32(KEY_COLOR_TRANSFER, &colorTransfer)) { mediametrics_setInt32(mMetricsHandle, isConfig ? kCodecConfigColorTransfer : kCodecParsedColorTransfer, colorTransfer); } HDRStaticInfo info; if (ColorUtils::getHDRStaticInfoFromFormat(mOutputFormat, &info) && ColorUtils::isHDRStaticInfoValid(&info)) { mHdrInfoFlags |= kFlagHasHdrStaticInfo; } mediametrics_setInt32(mMetricsHandle, kCodecHDRStaticInfo, (mHdrInfoFlags & kFlagHasHdrStaticInfo) ? 1 : 0); sp<ABuffer> hdr10PlusInfo; if (mOutputFormat->findBuffer("hdr10-plus-info", &hdr10PlusInfo) && hdr10PlusInfo != nullptr && hdr10PlusInfo->size() > 0) { mHdrInfoFlags |= kFlagHasHdr10PlusInfo; } mediametrics_setInt32(mMetricsHandle, kCodecHDR10PlusInfo, (mHdrInfoFlags & kFlagHasHdr10PlusInfo) ? 1 : 0); // hdr format sp<AMessage> codedFormat = (mFlags & kFlagIsEncoder) ? mOutputFormat : mInputFormat; AString mime; int32_t profile = -1; AString mediaType; if (mOutputFormat->findInt32(KEY_PROFILE, &profile) && mOutputFormat->findString("mime", &mediaType)) { hdr_format hdrFormat = getHDRFormat(profile, mConfigColorTransfer, mediaType); if (codedFormat->findString("mime", &mime) && codedFormat->findInt32(KEY_PROFILE, &profile) && colorTransfer != -1) { hdr_format hdrFormat = getHdrFormat(mime, profile, colorTransfer); mediametrics_setInt32(mMetricsHandle, kCodecHDRFormat, static_cast<int>(hdrFormat)); } } hdr_format MediaCodec::getHDRFormat(const int32_t profile, const int32_t transfer, const AString &mediaType) { switch (transfer) { hdr_format MediaCodec::getHdrFormat(const AString &mime, const int32_t profile, const int32_t colorTransfer) { return (mFlags & kFlagIsEncoder) ? getHdrFormatForEncoder(mime, profile, colorTransfer) : getHdrFormatForDecoder(mime, profile, colorTransfer); } hdr_format MediaCodec::getHdrFormatForEncoder(const AString &mime, const int32_t profile, const int32_t colorTransfer) { switch (colorTransfer) { case COLOR_TRANSFER_ST2084: if (mediaType.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_VP9)) { if (mime.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_VP9)) { switch (profile) { case VP9Profile2HDR: return HDR_FORMAT_HDR10; Loading @@ -999,7 +1041,7 @@ hdr_format MediaCodec::getHDRFormat(const int32_t profile, const int32_t transfe default: return HDR_FORMAT_NONE; } } else if (mediaType.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_AV1)) { } else if (mime.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_AV1)) { switch (profile) { case AV1ProfileMain10HDR10: return HDR_FORMAT_HDR10; Loading @@ -1008,7 +1050,7 @@ hdr_format MediaCodec::getHDRFormat(const int32_t profile, const int32_t transfe default: return HDR_FORMAT_NONE; } } else if (mediaType.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_HEVC)) { } else if (mime.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_HEVC)) { switch (profile) { case HEVCProfileMain10HDR10: return HDR_FORMAT_HDR10; Loading @@ -1021,7 +1063,7 @@ hdr_format MediaCodec::getHDRFormat(const int32_t profile, const int32_t transfe return HDR_FORMAT_NONE; } case COLOR_TRANSFER_HLG: if (!mediaType.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_DOLBY_VISION)) { if (!mime.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_DOLBY_VISION)) { return HDR_FORMAT_HLG; } else { // TODO: DOLBY format Loading @@ -1032,6 +1074,47 @@ hdr_format MediaCodec::getHDRFormat(const int32_t profile, const int32_t transfe } } hdr_format MediaCodec::getHdrFormatForDecoder(const AString &mime, const int32_t profile, const int32_t colorTransfer) { switch (colorTransfer) { case COLOR_TRANSFER_ST2084: if (!(mHdrInfoFlags & kFlagHasHdrStaticInfo) || !profileSupport10Bits(mime, profile)) { return HDR_FORMAT_NONE; } return mHdrInfoFlags & kFlagHasHdr10PlusInfo ? HDR_FORMAT_HDR10PLUS : HDR_FORMAT_HDR10; case COLOR_TRANSFER_HLG: if (!mime.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_DOLBY_VISION)) { return HDR_FORMAT_HLG; } // TODO: DOLBY format } return HDR_FORMAT_NONE; } bool MediaCodec::profileSupport10Bits(const AString &mime, const int32_t profile) { if (mime.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_AV1)) { return true; } else if (mime.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_VP9)) { switch (profile) { case VP9Profile2: case VP9Profile3: case VP9Profile2HDR: case VP9Profile3HDR: case VP9Profile2HDR10Plus: case VP9Profile3HDR10Plus: return true; } } else if (mime.equalsIgnoreCase(MEDIA_MIMETYPE_VIDEO_HEVC)) { switch (profile) { case HEVCProfileMain10: case HEVCProfileMain10HDR10: case HEVCProfileMain10HDR10Plus: return true; } } return false; } // called to update info being passed back via getMetrics(), which is a // unique copy for that call, no concurrent access worries. Loading Loading @@ -1081,6 +1164,7 @@ void MediaCodec::flushMediametrics() { // ensure mutex while we do our own work Mutex::Autolock _lock(mMetricsLock); mHdrInfoFlags = 0; if (mMetricsHandle != 0) { if (mediametrics_count(mMetricsHandle) > 0) { mediametrics_selfRecord(mMetricsHandle); Loading Loading @@ -1735,24 +1819,6 @@ status_t MediaCodec::configure( mediametrics_setInt32(nextMetricsHandle, kCodecPriority, priority); } } int32_t colorStandard = -1; if (format->findInt32(KEY_COLOR_STANDARD, &colorStandard)) { mediametrics_setInt32(mMetricsHandle, kCodecConfigColorStandard, colorStandard); } int32_t colorRange = -1; if (format->findInt32(KEY_COLOR_RANGE, &colorRange)) { mediametrics_setInt32(mMetricsHandle, kCodecConfigColorRange, colorRange); } int32_t colorTransfer = -1; if (format->findInt32(KEY_COLOR_TRANSFER, &colorTransfer)) { mConfigColorTransfer = colorTransfer; mediametrics_setInt32(mMetricsHandle, kCodecConfigColorTransfer, colorTransfer); } HDRStaticInfo info; if (ColorUtils::getHDRStaticInfoFromFormat(format, &info) && ColorUtils::isHDRStaticInfoValid(&info)) { mHDRStaticInfo = true; } } // Prevent possible integer overflow in downstream code. Loading Loading @@ -3439,8 +3505,6 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { CHECK(msg->findMessage("input-format", &mInputFormat)); CHECK(msg->findMessage("output-format", &mOutputFormat)); updateHDRFormatMetric(); // limit to confirming the opt-in behavior to minimize any behavioral change if (mSurface != nullptr && !mAllowFrameDroppingBySurface) { // signal frame dropping mode in the input format as this may also be Loading Loading @@ -3483,6 +3547,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { if (interestingFormat->findInt32("level", &level)) { mediametrics_setInt32(mMetricsHandle, kCodecLevel, level); } updateHdrMetrics(true /* isConfig */); // bitrate and bitrate mode, encoder only if (mFlags & kFlagIsEncoder) { // encoder specific values Loading Loading @@ -3522,7 +3587,6 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { mComponentName.c_str(), mInputFormat->debugString(4).c_str(), mOutputFormat->debugString(4).c_str()); updateHDRFormatMetric(); CHECK(obj != NULL); response->setObject("input-surface", obj); mHaveInputSurface = true; Loading @@ -3547,7 +3611,6 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { if (!msg->findInt32("err", &err)) { CHECK(msg->findMessage("input-format", &mInputFormat)); CHECK(msg->findMessage("output-format", &mOutputFormat)); updateHDRFormatMetric(); mHaveInputSurface = true; } else { response->setInt32("err", err); Loading Loading @@ -4760,7 +4823,6 @@ void MediaCodec::handleOutputFormatChangeIfNeeded(const sp<MediaCodecBuffer> &bu buffer->meta()->setObject("changedKeys", changedKeys); } mOutputFormat = format; updateHDRFormatMetric(); mapFormat(mComponentName, format, nullptr, true); ALOGV("[%s] output format changed to: %s", mComponentName.c_str(), mOutputFormat->debugString(4).c_str()); Loading @@ -4786,9 +4848,6 @@ void MediaCodec::handleOutputFormatChangeIfNeeded(const sp<MediaCodecBuffer> &bu HDRStaticInfo info; if (ColorUtils::getHDRStaticInfoFromFormat(mOutputFormat, &info)) { setNativeWindowHdrMetadata(mSurface.get(), &info); if (ColorUtils::isHDRStaticInfoValid(&info)) { mHDRStaticInfo = true; } } } Loading @@ -4797,7 +4856,6 @@ void MediaCodec::handleOutputFormatChangeIfNeeded(const sp<MediaCodecBuffer> &bu && hdr10PlusInfo != nullptr && hdr10PlusInfo->size() > 0) { native_window_set_buffers_hdr10_plus_metadata(mSurface.get(), hdr10PlusInfo->size(), hdr10PlusInfo->data()); mHDR10PlusInfo = true; } if (mime.startsWithIgnoreCase("video/")) { Loading Loading @@ -4843,20 +4901,7 @@ void MediaCodec::handleOutputFormatChangeIfNeeded(const sp<MediaCodecBuffer> &bu } } if (mMetricsHandle != 0) { int32_t colorStandard = -1; if (format->findInt32(KEY_COLOR_STANDARD, &colorStandard)) { mediametrics_setInt32(mMetricsHandle, kCodecParsedColorStandard, colorStandard); } int32_t colorRange = -1; if (format->findInt32( KEY_COLOR_RANGE, &colorRange)) { mediametrics_setInt32(mMetricsHandle, kCodecParsedColorRange, colorRange); } int32_t colorTransfer = -1; if (format->findInt32(KEY_COLOR_TRANSFER, &colorTransfer)) { mediametrics_setInt32(mMetricsHandle, kCodecParsedColorTransfer, colorTransfer); } } updateHdrMetrics(false /* isConfig */); } void MediaCodec::extractCSD(const sp<AMessage> &format) { Loading
media/libstagefright/include/media/stagefright/MediaCodec.h +13 −6 Original line number Diff line number Diff line Loading @@ -456,12 +456,19 @@ private: int32_t mRotationDegrees; int32_t mAllowFrameDroppingBySurface; int32_t mConfigColorTransfer; bool mHDRStaticInfo; bool mHDR10PlusInfo; void updateHDRFormatMetric(); hdr_format getHDRFormat(const int32_t profile, const int32_t transfer, const AString &mediaType); enum { kFlagHasHdrStaticInfo = 1, kFlagHasHdr10PlusInfo = 2, }; uint32_t mHdrInfoFlags; void updateHdrMetrics(bool isConfig); hdr_format getHdrFormat(const AString &mime, const int32_t profile, const int32_t colorTransfer); hdr_format getHdrFormatForEncoder(const AString &mime, const int32_t profile, const int32_t colorTransfer); hdr_format getHdrFormatForDecoder(const AString &mime, const int32_t profile, const int32_t colorTransfer); bool profileSupport10Bits(const AString &mime, const int32_t profile); // initial create parameters AString mInitName; Loading