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

Commit 1563f4ac authored by Vinay Kalia's avatar Vinay Kalia Committed by Steve Kondik
Browse files

Stagefright: Memcpy optimization on output port.

Adding changes to avoid memcpy on output
port of video decoder. Pmem fd will be
provided to client so that same buffer
as populated bu decoder can be accessed
and memcpy can be avoided.

Change-Id: I492fd1e9d2b68f62ef9936ec8ff0b5a8b8830164
parent a8dc09ca
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#define ANDROID_IOMX_H_

#include <binder/IInterface.h>
#include <binder/MemoryHeapBase.h>
#include <utils/List.h>
#include <utils/String8.h>

@@ -143,6 +144,7 @@ struct omx_message {
        EVENT,
        EMPTY_BUFFER_DONE,
        FILL_BUFFER_DONE,
        REGISTER_BUFFERS

    } type;

@@ -170,6 +172,7 @@ struct omx_message {
            OMX_TICKS timestamp;
            OMX_PTR platform_private;
            OMX_PTR data_ptr;
            OMX_U32 pmem_offset;
        } extended_buffer_data;

    } u;
@@ -180,6 +183,7 @@ public:
    DECLARE_META_INTERFACE(OMXObserver);

    virtual void onMessage(const omx_message &msg) = 0;
    virtual void registerBuffers(const sp<IMemoryHeap> &mem) = 0;
};

class IOMXRenderer : public IInterface {
+1 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ public:
    // Increments the reference count.
    void add_ref();

    void setData(void *);
    void *data() const;
    size_t size() const;

+4 −1
Original line number Diff line number Diff line
@@ -60,6 +60,8 @@ struct OMXCodec : public MediaSource,

    virtual status_t pause();

    void registerBuffers(const sp<IMemoryHeap> &mem);

    // from MediaBufferObserver
    virtual void signalBufferReturned(MediaBuffer *buffer);

@@ -116,6 +118,7 @@ private:
        kOutputBuffersAreUnreadable           = 8192,
        kStoreMetaDataInInputVideoBuffers     = 16384,
        kCanNotSetVideoParameters             = 32768,
        kDoesNotRequireMemcpyOnOutputPort     = 65536
    };

    struct BufferInfo {
@@ -143,7 +146,7 @@ private:
    sp<MediaSource> mSource;
    Vector<CodecSpecificData *> mCodecSpecificData;
    size_t mCodecSpecificDataIndex;

    sp<IMemoryHeap> mPmemInfo;
    sp<MemoryDealer> mDealer[2];

    State mState;
+15 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ enum {
    CREATE_RENDERER,
    OBSERVER_ON_MSG,
    RENDERER_RENDER,
    REGISTER_BUFFERS
};

sp<IOMXRenderer> IOMX::createRenderer(
@@ -721,6 +722,13 @@ public:

        remote()->transact(OBSERVER_ON_MSG, data, &reply, IBinder::FLAG_ONEWAY);
    }

    virtual void registerBuffers(const sp<IMemoryHeap> &mem) {
        Parcel data, reply;
        data.writeInterfaceToken(IOMXObserver::getInterfaceDescriptor());
        data.writeStrongBinder(mem->asBinder());
        remote()->transact(REGISTER_BUFFERS, data, &reply);
    }
};

IMPLEMENT_META_INTERFACE(OMXObserver, "android.hardware.IOMXObserver");
@@ -740,6 +748,13 @@ status_t BnOMXObserver::onTransact(

            return NO_ERROR;
        }
        case REGISTER_BUFFERS:
        {
            CHECK_INTERFACE(IOMXObserver, data, reply);
            sp<IMemoryHeap> mem =
               interface_cast<IMemoryHeap>(data.readStrongBinder());
            registerBuffers(mem);
        }

        default:
            return BBinder::onTransact(code, data, reply, flags);
+4 −0
Original line number Diff line number Diff line
@@ -91,6 +91,10 @@ void MediaBuffer::add_ref() {
    atomic_add(&mRefCount, 1);
}

void MediaBuffer::setData(void *data) {
    mData = data;
}

void *MediaBuffer::data() const {
    return mData;
}
Loading