Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d5fa357d authored by Chong Zhang's avatar Chong Zhang
Browse files

Use heif embedded thumbnail if available

Add plumbing to retieve the embedded thumbnail from
MPEG4Extractor/ItemTable.

bug: 74395267
Test: CTS MediaMetadataRetriever test; manual test of thumbnail
extraction by browsing new folders containing heif files in
Downloads app.
Change-Id: Ic49f6dfa47eddc229b9f4b0e1835d58df1dce9f8
parent 2383098d
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -1591,10 +1591,9 @@ status_t ItemTable::findThumbnailItem(const uint32_t imageIndex, uint32_t *itemI

    ssize_t thumbItemIndex = mItemIdToItemMap.indexOfKey(masterImage.thumbnails[0]);
    if (thumbItemIndex < 0) {
        ALOGW("%s: Thumbnail item id %d not found, use master instead",
                __FUNCTION__, masterImage.thumbnails[0]);
        *itemIndex = masterItemIndex;
        return OK;
        // Do not return the master image in this case, fail it so that the
        // thumbnail extraction code knows we really don't have it.
        return INVALID_OPERATION;
    }

    *itemIndex = thumbItemIndex;
+8 −6
Original line number Diff line number Diff line
@@ -166,15 +166,16 @@ public:
        return interface_cast<IMemory>(reply.readStrongBinder());
    }

    sp<IMemory> getImageAtIndex(int index, int colorFormat, bool metaOnly)
    sp<IMemory> getImageAtIndex(int index, int colorFormat, bool metaOnly, bool thumbnail)
    {
        ALOGV("getImageAtIndex: index %d, colorFormat(%d) metaOnly(%d)",
                index, colorFormat, metaOnly);
        ALOGV("getImageAtIndex: index %d, colorFormat(%d) metaOnly(%d) thumbnail(%d)",
                index, colorFormat, metaOnly, thumbnail);
        Parcel data, reply;
        data.writeInterfaceToken(IMediaMetadataRetriever::getInterfaceDescriptor());
        data.writeInt32(index);
        data.writeInt32(colorFormat);
        data.writeInt32(metaOnly);
        data.writeInt32(thumbnail);
#ifndef DISABLE_GROUP_SCHEDULE_HACK
        sendSchedPolicy(data);
#endif
@@ -356,12 +357,13 @@ status_t BnMediaMetadataRetriever::onTransact(
            int index = data.readInt32();
            int colorFormat = data.readInt32();
            bool metaOnly = (data.readInt32() != 0);
            ALOGV("getImageAtIndex: index(%d), colorFormat(%d), metaOnly(%d)",
                    index, colorFormat, metaOnly);
            bool thumbnail = (data.readInt32() != 0);
            ALOGV("getImageAtIndex: index(%d), colorFormat(%d), metaOnly(%d), thumbnail(%d)",
                    index, colorFormat, metaOnly, thumbnail);
#ifndef DISABLE_GROUP_SCHEDULE_HACK
            setSchedPolicy(data);
#endif
            sp<IMemory> bitmap = getImageAtIndex(index, colorFormat, metaOnly);
            sp<IMemory> bitmap = getImageAtIndex(index, colorFormat, metaOnly, thumbnail);
            if (bitmap != 0) {  // Don't send NULL across the binder interface
                reply->writeInt32(NO_ERROR);
                reply->writeStrongBinder(IInterface::asBinder(bitmap));
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ public:
    virtual sp<IMemory>     getFrameAtTime(
            int64_t timeUs, int option, int colorFormat, bool metaOnly) = 0;
    virtual sp<IMemory>     getImageAtIndex(
            int index, int colorFormat, bool metaOnly) = 0;
            int index, int colorFormat, bool metaOnly, bool thumbnail) = 0;
    virtual status_t        getFrameAtIndex(
            std::vector<sp<IMemory> > *frames,
            int frameIndex, int numFrames, int colorFormat, bool metaOnly) = 0;
+2 −2
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ public:
    virtual VideoFrame* getFrameAtTime(
            int64_t timeUs, int option, int colorFormat, bool metaOnly) = 0;
    virtual VideoFrame* getImageAtIndex(
            int index, int colorFormat, bool metaOnly) = 0;
            int index, int colorFormat, bool metaOnly, bool thumbnail) = 0;
    virtual status_t getFrameAtIndex(
            std::vector<VideoFrame*>* frames,
            int frameIndex, int numFrames, int colorFormat, bool metaOnly) = 0;
@@ -65,7 +65,7 @@ public:
            int64_t /*timeUs*/, int /*option*/, int /*colorFormat*/, bool /*metaOnly*/)
    { return NULL; }
    virtual VideoFrame* getImageAtIndex(
            int /*index*/, int /*colorFormat*/, bool /*metaOnly*/)
            int /*index*/, int /*colorFormat*/, bool /*metaOnly*/, bool /*thumbnail*/)
    { return NULL; }
    virtual status_t getFrameAtIndex(
            std::vector<VideoFrame*>* /*frames*/,
+1 −1
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ public:
    sp<IMemory> getFrameAtTime(int64_t timeUs, int option,
            int colorFormat = HAL_PIXEL_FORMAT_RGB_565, bool metaOnly = false);
    sp<IMemory> getImageAtIndex(int index,
            int colorFormat = HAL_PIXEL_FORMAT_RGB_565, bool metaOnly = false);
            int colorFormat = HAL_PIXEL_FORMAT_RGB_565, bool metaOnly = false, bool thumbnail = false);
    status_t getFrameAtIndex(
            std::vector<sp<IMemory> > *frames, int frameIndex, int numFrames = 1,
            int colorFormat = HAL_PIXEL_FORMAT_RGB_565, bool metaOnly = false);
Loading