Loading media/extractors/mp4/ItemTable.cpp +14 −5 Original line number Diff line number Diff line Loading @@ -1582,15 +1582,24 @@ AMediaFormat *ItemTable::getImageMeta(const uint32_t imageIndex) { ssize_t thumbItemIndex = mItemIdToItemMap.indexOfKey(image->thumbnails[0]); if (thumbItemIndex >= 0) { const ImageItem &thumbnail = mItemIdToItemMap[thumbItemIndex]; // TODO(vigneshv): Handle thumbnail for AVIF. if (thumbnail.hvcc != NULL) { if (thumbnail.hvcc != NULL || thumbnail.av1c != NULL) { AMediaFormat_setInt32(meta, AMEDIAFORMAT_KEY_THUMBNAIL_WIDTH, thumbnail.width); AMediaFormat_setInt32(meta, AMEDIAFORMAT_KEY_THUMBNAIL_HEIGHT, thumbnail.height); if (thumbnail.hvcc != NULL) { AMediaFormat_setBuffer(meta, AMEDIAFORMAT_KEY_THUMBNAIL_CSD_HEVC, thumbnail.hvcc->data(), thumbnail.hvcc->size()); } else { // We use a hard-coded string here instead of // AMEDIAFORMAT_KEY_THUMBNAIL_CSD_AV1C. The key is available only from SDK 31. // The mp4 extractor is part of mainline and builds against SDK 29 as of // writing. This hard-coded string can be replaced with the named constant once // the mp4 extractor is built against SDK >= 31. AMediaFormat_setBuffer(meta, "thumbnail-csd-av1c", thumbnail.av1c->data(), thumbnail.av1c->size()); } ALOGV("image[%u]: thumbnail: size %dx%d, item index %zd", imageIndex, thumbnail.width, thumbnail.height, thumbItemIndex); } else { Loading media/libstagefright/FrameDecoder.cpp +13 −2 Original line number Diff line number Diff line Loading @@ -121,15 +121,23 @@ sp<IMemory> allocMetaFrame(const sp<MetaData>& trackMeta, false /*allocRotated*/, true /*metaOnly*/); } bool isAvif(const sp<MetaData> &trackMeta) { const char *mime; return trackMeta->findCString(kKeyMIMEType, &mime) && (!strcasecmp(mime, MEDIA_MIMETYPE_VIDEO_AV1) || !strcasecmp(mime, MEDIA_MIMETYPE_IMAGE_AVIF)); } bool findThumbnailInfo( const sp<MetaData> &trackMeta, int32_t *width, int32_t *height, uint32_t *type = NULL, const void **data = NULL, size_t *size = NULL) { uint32_t dummyType; const void *dummyData; size_t dummySize; int codecConfigKey = isAvif(trackMeta) ? kKeyThumbnailAV1C : kKeyThumbnailHVCC; return trackMeta->findInt32(kKeyThumbnailWidth, width) && trackMeta->findInt32(kKeyThumbnailHeight, height) && trackMeta->findData(kKeyThumbnailHVCC, && trackMeta->findData(codecConfigKey, type ?: &dummyType, data ?: &dummyData, size ?: &dummySize); } Loading Loading @@ -752,7 +760,10 @@ sp<AMessage> ImageDecoder::onGetFormatAndSeekOptions( overrideMeta->remove(kKeyDisplayHeight); overrideMeta->setInt32(kKeyWidth, mWidth); overrideMeta->setInt32(kKeyHeight, mHeight); overrideMeta->setData(kKeyHVCC, type, data, size); // The AV1 codec configuration data is passed via CSD0 to the AV1 // decoder. const int codecConfigKey = isAvif(trackMeta()) ? kKeyOpaqueCSD0 : kKeyHVCC; overrideMeta->setData(codecConfigKey, type, data, size); options->setSeekTo(-1); } else { CHECK(trackMeta()->findInt32(kKeyWidth, &mWidth)); Loading Loading
media/extractors/mp4/ItemTable.cpp +14 −5 Original line number Diff line number Diff line Loading @@ -1582,15 +1582,24 @@ AMediaFormat *ItemTable::getImageMeta(const uint32_t imageIndex) { ssize_t thumbItemIndex = mItemIdToItemMap.indexOfKey(image->thumbnails[0]); if (thumbItemIndex >= 0) { const ImageItem &thumbnail = mItemIdToItemMap[thumbItemIndex]; // TODO(vigneshv): Handle thumbnail for AVIF. if (thumbnail.hvcc != NULL) { if (thumbnail.hvcc != NULL || thumbnail.av1c != NULL) { AMediaFormat_setInt32(meta, AMEDIAFORMAT_KEY_THUMBNAIL_WIDTH, thumbnail.width); AMediaFormat_setInt32(meta, AMEDIAFORMAT_KEY_THUMBNAIL_HEIGHT, thumbnail.height); if (thumbnail.hvcc != NULL) { AMediaFormat_setBuffer(meta, AMEDIAFORMAT_KEY_THUMBNAIL_CSD_HEVC, thumbnail.hvcc->data(), thumbnail.hvcc->size()); } else { // We use a hard-coded string here instead of // AMEDIAFORMAT_KEY_THUMBNAIL_CSD_AV1C. The key is available only from SDK 31. // The mp4 extractor is part of mainline and builds against SDK 29 as of // writing. This hard-coded string can be replaced with the named constant once // the mp4 extractor is built against SDK >= 31. AMediaFormat_setBuffer(meta, "thumbnail-csd-av1c", thumbnail.av1c->data(), thumbnail.av1c->size()); } ALOGV("image[%u]: thumbnail: size %dx%d, item index %zd", imageIndex, thumbnail.width, thumbnail.height, thumbItemIndex); } else { Loading
media/libstagefright/FrameDecoder.cpp +13 −2 Original line number Diff line number Diff line Loading @@ -121,15 +121,23 @@ sp<IMemory> allocMetaFrame(const sp<MetaData>& trackMeta, false /*allocRotated*/, true /*metaOnly*/); } bool isAvif(const sp<MetaData> &trackMeta) { const char *mime; return trackMeta->findCString(kKeyMIMEType, &mime) && (!strcasecmp(mime, MEDIA_MIMETYPE_VIDEO_AV1) || !strcasecmp(mime, MEDIA_MIMETYPE_IMAGE_AVIF)); } bool findThumbnailInfo( const sp<MetaData> &trackMeta, int32_t *width, int32_t *height, uint32_t *type = NULL, const void **data = NULL, size_t *size = NULL) { uint32_t dummyType; const void *dummyData; size_t dummySize; int codecConfigKey = isAvif(trackMeta) ? kKeyThumbnailAV1C : kKeyThumbnailHVCC; return trackMeta->findInt32(kKeyThumbnailWidth, width) && trackMeta->findInt32(kKeyThumbnailHeight, height) && trackMeta->findData(kKeyThumbnailHVCC, && trackMeta->findData(codecConfigKey, type ?: &dummyType, data ?: &dummyData, size ?: &dummySize); } Loading Loading @@ -752,7 +760,10 @@ sp<AMessage> ImageDecoder::onGetFormatAndSeekOptions( overrideMeta->remove(kKeyDisplayHeight); overrideMeta->setInt32(kKeyWidth, mWidth); overrideMeta->setInt32(kKeyHeight, mHeight); overrideMeta->setData(kKeyHVCC, type, data, size); // The AV1 codec configuration data is passed via CSD0 to the AV1 // decoder. const int codecConfigKey = isAvif(trackMeta()) ? kKeyOpaqueCSD0 : kKeyHVCC; overrideMeta->setData(codecConfigKey, type, data, size); options->setSeekTo(-1); } else { CHECK(trackMeta()->findInt32(kKeyWidth, &mWidth)); Loading