Loading include/private/media/VideoFrame.h +5 −3 Original line number Diff line number Diff line Loading @@ -38,13 +38,13 @@ public: VideoFrame(uint32_t width, uint32_t height, uint32_t displayWidth, uint32_t displayHeight, uint32_t tileWidth, uint32_t tileHeight, uint32_t angle, uint32_t bpp, bool hasData, size_t iccSize): uint32_t angle, uint32_t bpp, uint32_t bitDepth, bool hasData, size_t iccSize): mWidth(width), mHeight(height), mDisplayWidth(displayWidth), mDisplayHeight(displayHeight), mTileWidth(tileWidth), mTileHeight(tileHeight), mDurationUs(0), mRotationAngle(angle), mBytesPerPixel(bpp), mRowBytes(bpp * width), mSize(hasData ? (bpp * width * height) : 0), mIccSize(iccSize), mReserved(0) { mIccSize(iccSize), mBitDepth(bitDepth) { } void init(const VideoFrame& copy, const void* iccData, size_t iccSize) { Loading Loading @@ -84,7 +84,9 @@ public: uint32_t mRowBytes; // Number of bytes per row before rotation uint32_t mSize; // Number of bytes of frame data uint32_t mIccSize; // Number of bytes of ICC data uint32_t mReserved; // (padding to make mData 64-bit aligned) uint32_t mBitDepth; // number of bits per R / G / B channel // Adding new items must be 64-bit aligned. }; }; // namespace android Loading media/libheif/HeifDecoderImpl.cpp +13 −2 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ void initFrameInfo(HeifFrameInfo *info, const VideoFrame *videoFrame) { info->mRotationAngle = videoFrame->mRotationAngle; info->mBytesPerPixel = videoFrame->mBytesPerPixel; info->mDurationUs = videoFrame->mDurationUs; info->mBitDepth = videoFrame->mBitDepth; if (videoFrame->mIccSize > 0) { info->mIccData.assign( videoFrame->getFlattenedIccData(), Loading Loading @@ -377,13 +378,14 @@ bool HeifDecoderImpl::reinit(HeifFrameInfo* frameInfo) { // issue (e.g. by copying). VideoFrame* videoFrame = static_cast<VideoFrame*>(sharedMem->unsecurePointer()); ALOGV("Image dimension %dx%d, display %dx%d, angle %d, iccSize %d", ALOGV("Image dimension %dx%d, display %dx%d, angle %d, iccSize %d, bitDepth %d", videoFrame->mWidth, videoFrame->mHeight, videoFrame->mDisplayWidth, videoFrame->mDisplayHeight, videoFrame->mRotationAngle, videoFrame->mIccSize); videoFrame->mIccSize, videoFrame->mBitDepth); initFrameInfo(&mImageInfo, videoFrame); Loading Loading @@ -729,4 +731,13 @@ size_t HeifDecoderImpl::skipScanlines(size_t count) { return (mCurScanline > oldScanline) ? (mCurScanline - oldScanline) : 0; } uint32_t HeifDecoderImpl::getColorDepth() { HeifFrameInfo* info = &mImageInfo; if (info != nullptr) { return mImageInfo.mBitDepth; } return 0; } } // namespace android media/libheif/HeifDecoderImpl.h +2 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ public: size_t skipScanlines(size_t count) override; uint32_t getColorDepth() override; private: struct DecodeThread; Loading media/libheif/include/HeifDecoderAPI.h +7 −1 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ struct HeifFrameInfo { int32_t mRotationAngle; // Rotation angle, clockwise, should be multiple of 90 uint32_t mBytesPerPixel; // Number of bytes for one pixel int64_t mDurationUs; // Duration of the frame in us uint32_t mBitDepth; // Number of bits for each of the R/G/B channels std::vector<uint8_t> mIccData; // ICC data array }; Loading Loading @@ -162,6 +163,11 @@ struct HeifDecoder { */ virtual size_t skipScanlines(size_t count) = 0; /* * Returns color depth in bits for each of the R/G/B channels. */ virtual uint32_t getColorDepth() = 0; private: HeifDecoder(const HeifFrameInfo&) = delete; HeifDecoder& operator=(const HeifFrameInfo&) = delete; Loading media/libmediaplayerservice/StagefrightMetadataRetriever.cpp +36 −15 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ #include <datasource/PlayerServiceDataSourceFactory.h> #include <datasource/PlayerServiceFileSource.h> #include <media/IMediaHTTPService.h> #include <media/stagefright/MediaCodecConstants.h> #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/foundation/AMessage.h> #include <media/stagefright/MediaCodecList.h> Loading Loading @@ -194,17 +195,6 @@ sp<IMemory> StagefrightMetadataRetriever::getImageInternal( return NULL; } if (metaOnly) { return FrameDecoder::getMetadataOnly(trackMeta, colorFormat, thumbnail); } sp<IMediaSource> source = mExtractor->getTrack(i); if (source.get() == NULL) { ALOGE("unable to instantiate image track."); return NULL; } const char *mime; bool isHeif = false; if (!trackMeta->findCString(kKeyMIMEType, &mime)) { Loading @@ -223,16 +213,47 @@ sp<IMemory> StagefrightMetadataRetriever::getImageInternal( trackMeta->setCString(kKeyMIMEType, mime); } bool preferhw = property_get_bool( "media.stagefright.thumbnail.prefer_hw_codecs", false); uint32_t flags = preferhw ? 0 : MediaCodecList::kPreferSoftwareCodecs; Vector<AString> matchingCodecs; sp<AMessage> format = new AMessage; status_t err = convertMetaDataToMessage(trackMeta, &format); if (err != OK) { format = NULL; } uint32_t bitDepth = 8; if (!strcasecmp(mime, MEDIA_MIMETYPE_VIDEO_HEVC)) { int32_t profile; if (format->findInt32("profile", &profile)) { if (HEVCProfileMain10 == profile || HEVCProfileMain10HDR10 == profile || HEVCProfileMain10HDR10Plus == profile) { bitDepth = 10; } } } else if (!strcasecmp(mime, MEDIA_MIMETYPE_VIDEO_AV1)) { int32_t profile; if (format->findInt32("profile", &profile)) { if (AV1ProfileMain10 == profile || AV1ProfileMain10HDR10 == profile || AV1ProfileMain10HDR10Plus == profile) { bitDepth = 10; } } } if (metaOnly) { return FrameDecoder::getMetadataOnly(trackMeta, colorFormat, thumbnail, bitDepth); } sp<IMediaSource> source = mExtractor->getTrack(i); if (source.get() == NULL) { ALOGE("unable to instantiate image track."); return NULL; } bool preferhw = property_get_bool( "media.stagefright.thumbnail.prefer_hw_codecs", false); uint32_t flags = preferhw ? 0 : MediaCodecList::kPreferSoftwareCodecs; Vector<AString> matchingCodecs; // If decoding thumbnail check decoder supports thumbnail dimensions instead int32_t thumbHeight, thumbWidth; if (thumbnail && format != NULL Loading Loading
include/private/media/VideoFrame.h +5 −3 Original line number Diff line number Diff line Loading @@ -38,13 +38,13 @@ public: VideoFrame(uint32_t width, uint32_t height, uint32_t displayWidth, uint32_t displayHeight, uint32_t tileWidth, uint32_t tileHeight, uint32_t angle, uint32_t bpp, bool hasData, size_t iccSize): uint32_t angle, uint32_t bpp, uint32_t bitDepth, bool hasData, size_t iccSize): mWidth(width), mHeight(height), mDisplayWidth(displayWidth), mDisplayHeight(displayHeight), mTileWidth(tileWidth), mTileHeight(tileHeight), mDurationUs(0), mRotationAngle(angle), mBytesPerPixel(bpp), mRowBytes(bpp * width), mSize(hasData ? (bpp * width * height) : 0), mIccSize(iccSize), mReserved(0) { mIccSize(iccSize), mBitDepth(bitDepth) { } void init(const VideoFrame& copy, const void* iccData, size_t iccSize) { Loading Loading @@ -84,7 +84,9 @@ public: uint32_t mRowBytes; // Number of bytes per row before rotation uint32_t mSize; // Number of bytes of frame data uint32_t mIccSize; // Number of bytes of ICC data uint32_t mReserved; // (padding to make mData 64-bit aligned) uint32_t mBitDepth; // number of bits per R / G / B channel // Adding new items must be 64-bit aligned. }; }; // namespace android Loading
media/libheif/HeifDecoderImpl.cpp +13 −2 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ void initFrameInfo(HeifFrameInfo *info, const VideoFrame *videoFrame) { info->mRotationAngle = videoFrame->mRotationAngle; info->mBytesPerPixel = videoFrame->mBytesPerPixel; info->mDurationUs = videoFrame->mDurationUs; info->mBitDepth = videoFrame->mBitDepth; if (videoFrame->mIccSize > 0) { info->mIccData.assign( videoFrame->getFlattenedIccData(), Loading Loading @@ -377,13 +378,14 @@ bool HeifDecoderImpl::reinit(HeifFrameInfo* frameInfo) { // issue (e.g. by copying). VideoFrame* videoFrame = static_cast<VideoFrame*>(sharedMem->unsecurePointer()); ALOGV("Image dimension %dx%d, display %dx%d, angle %d, iccSize %d", ALOGV("Image dimension %dx%d, display %dx%d, angle %d, iccSize %d, bitDepth %d", videoFrame->mWidth, videoFrame->mHeight, videoFrame->mDisplayWidth, videoFrame->mDisplayHeight, videoFrame->mRotationAngle, videoFrame->mIccSize); videoFrame->mIccSize, videoFrame->mBitDepth); initFrameInfo(&mImageInfo, videoFrame); Loading Loading @@ -729,4 +731,13 @@ size_t HeifDecoderImpl::skipScanlines(size_t count) { return (mCurScanline > oldScanline) ? (mCurScanline - oldScanline) : 0; } uint32_t HeifDecoderImpl::getColorDepth() { HeifFrameInfo* info = &mImageInfo; if (info != nullptr) { return mImageInfo.mBitDepth; } return 0; } } // namespace android
media/libheif/HeifDecoderImpl.h +2 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ public: size_t skipScanlines(size_t count) override; uint32_t getColorDepth() override; private: struct DecodeThread; Loading
media/libheif/include/HeifDecoderAPI.h +7 −1 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ struct HeifFrameInfo { int32_t mRotationAngle; // Rotation angle, clockwise, should be multiple of 90 uint32_t mBytesPerPixel; // Number of bytes for one pixel int64_t mDurationUs; // Duration of the frame in us uint32_t mBitDepth; // Number of bits for each of the R/G/B channels std::vector<uint8_t> mIccData; // ICC data array }; Loading Loading @@ -162,6 +163,11 @@ struct HeifDecoder { */ virtual size_t skipScanlines(size_t count) = 0; /* * Returns color depth in bits for each of the R/G/B channels. */ virtual uint32_t getColorDepth() = 0; private: HeifDecoder(const HeifFrameInfo&) = delete; HeifDecoder& operator=(const HeifFrameInfo&) = delete; Loading
media/libmediaplayerservice/StagefrightMetadataRetriever.cpp +36 −15 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ #include <datasource/PlayerServiceDataSourceFactory.h> #include <datasource/PlayerServiceFileSource.h> #include <media/IMediaHTTPService.h> #include <media/stagefright/MediaCodecConstants.h> #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/foundation/AMessage.h> #include <media/stagefright/MediaCodecList.h> Loading Loading @@ -194,17 +195,6 @@ sp<IMemory> StagefrightMetadataRetriever::getImageInternal( return NULL; } if (metaOnly) { return FrameDecoder::getMetadataOnly(trackMeta, colorFormat, thumbnail); } sp<IMediaSource> source = mExtractor->getTrack(i); if (source.get() == NULL) { ALOGE("unable to instantiate image track."); return NULL; } const char *mime; bool isHeif = false; if (!trackMeta->findCString(kKeyMIMEType, &mime)) { Loading @@ -223,16 +213,47 @@ sp<IMemory> StagefrightMetadataRetriever::getImageInternal( trackMeta->setCString(kKeyMIMEType, mime); } bool preferhw = property_get_bool( "media.stagefright.thumbnail.prefer_hw_codecs", false); uint32_t flags = preferhw ? 0 : MediaCodecList::kPreferSoftwareCodecs; Vector<AString> matchingCodecs; sp<AMessage> format = new AMessage; status_t err = convertMetaDataToMessage(trackMeta, &format); if (err != OK) { format = NULL; } uint32_t bitDepth = 8; if (!strcasecmp(mime, MEDIA_MIMETYPE_VIDEO_HEVC)) { int32_t profile; if (format->findInt32("profile", &profile)) { if (HEVCProfileMain10 == profile || HEVCProfileMain10HDR10 == profile || HEVCProfileMain10HDR10Plus == profile) { bitDepth = 10; } } } else if (!strcasecmp(mime, MEDIA_MIMETYPE_VIDEO_AV1)) { int32_t profile; if (format->findInt32("profile", &profile)) { if (AV1ProfileMain10 == profile || AV1ProfileMain10HDR10 == profile || AV1ProfileMain10HDR10Plus == profile) { bitDepth = 10; } } } if (metaOnly) { return FrameDecoder::getMetadataOnly(trackMeta, colorFormat, thumbnail, bitDepth); } sp<IMediaSource> source = mExtractor->getTrack(i); if (source.get() == NULL) { ALOGE("unable to instantiate image track."); return NULL; } bool preferhw = property_get_bool( "media.stagefright.thumbnail.prefer_hw_codecs", false); uint32_t flags = preferhw ? 0 : MediaCodecList::kPreferSoftwareCodecs; Vector<AString> matchingCodecs; // If decoding thumbnail check decoder supports thumbnail dimensions instead int32_t thumbHeight, thumbWidth; if (thumbnail && format != NULL Loading