Loading media/libmedia/include/media/MediaResource.h +2 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,8 @@ public: kUnspecified = 0, kSecureCodec, kNonSecureCodec, kGraphicMemory kGraphicMemory, kCpuBoost, }; enum SubType { Loading media/libstagefright/MediaCodec.cpp +28 −0 Original line number Diff line number Diff line Loading @@ -523,6 +523,7 @@ MediaCodec::MediaCodec(const sp<ALooper> &looper, pid_t pid, uid_t uid) mDequeueOutputReplyID(0), mHaveInputSurface(false), mHavePendingInputBuffers(false), mCpuBoostRequested(false), mLatencyUnknown(0) { if (uid == kNoUid) { mUid = IPCThreadState::self()->getCallingUid(); Loading Loading @@ -1638,6 +1639,31 @@ void MediaCodec::requestActivityNotification(const sp<AMessage> ¬ify) { msg->post(); } void MediaCodec::requestCpuBoostIfNeeded() { if (mCpuBoostRequested) { return; } int32_t colorFormat; if (mSoftRenderer != NULL && mOutputFormat->contains("hdr-static-info") && mOutputFormat->findInt32("color-format", &colorFormat) && (colorFormat == OMX_COLOR_FormatYUV420Planar16)) { int32_t left, top, right, bottom, width, height; int64_t totalPixel = 0; if (mOutputFormat->findRect("crop", &left, &top, &right, &bottom)) { totalPixel = (right - left + 1) * (bottom - top + 1); } else if (mOutputFormat->findInt32("width", &width) && mOutputFormat->findInt32("height", &height)) { totalPixel = width * height; } if (totalPixel >= 1920 * 1080) { addResource(MediaResource::kCpuBoost, MediaResource::kUnspecifiedSubType, 1); mCpuBoostRequested = true; } } } //////////////////////////////////////////////////////////////////////////////// void MediaCodec::cancelPendingDequeueOperations() { Loading Loading @@ -2160,6 +2186,8 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { } } requestCpuBoostIfNeeded(); if (mFlags & kFlagIsEncoder) { // Before we announce the format change we should // collect codec specific data and amend the output Loading media/libstagefright/include/media/stagefright/MediaCodec.h +2 −0 Original line number Diff line number Diff line Loading @@ -369,6 +369,7 @@ private: bool mHaveInputSurface; bool mHavePendingInputBuffers; bool mCpuBoostRequested; std::shared_ptr<BufferChannelBase> mBufferChannel; Loading Loading @@ -425,6 +426,7 @@ private: uint64_t getGraphicBufferSize(); void addResource(MediaResource::Type type, MediaResource::SubType subtype, uint64_t value); void requestCpuBoostIfNeeded(); bool hasPendingBuffer(int portIndex); bool hasPendingBuffer(); Loading media/utils/ISchedulingPolicyService.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ namespace android { // Keep in sync with frameworks/base/core/java/android/os/ISchedulingPolicyService.aidl enum { REQUEST_PRIORITY_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, REQUEST_CPUSET_BOOST, }; // ---------------------------------------------------------------------- Loading Loading @@ -60,6 +61,23 @@ public: } return reply.readInt32(); } virtual int requestCpusetBoost(bool enable, const sp<IInterface>& client) { Parcel data, reply; data.writeInterfaceToken(ISchedulingPolicyService::getInterfaceDescriptor()); data.writeInt32(enable); data.writeStrongBinder(IInterface::asBinder(client)); status_t status = remote()->transact(REQUEST_CPUSET_BOOST, data, &reply, 0); if (status != NO_ERROR) { return status; } // fail on exception: force binder reconnection if (reply.readExceptionCode() != 0) { return DEAD_OBJECT; } return reply.readInt32(); } }; IMPLEMENT_META_INTERFACE(SchedulingPolicyService, "android.os.ISchedulingPolicyService"); Loading @@ -71,6 +89,7 @@ status_t BnSchedulingPolicyService::onTransact( { switch (code) { case REQUEST_PRIORITY_TRANSACTION: case REQUEST_CPUSET_BOOST: // Not reached return NO_ERROR; break; Loading media/utils/ISchedulingPolicyService.h +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ public: virtual int requestPriority(/*pid_t*/int32_t pid, /*pid_t*/int32_t tid, int32_t prio, bool isForApp, bool asynchronous) = 0; virtual int requestCpusetBoost(bool enable, const sp<IInterface>& client) = 0; }; class BnSchedulingPolicyService : public BnInterface<ISchedulingPolicyService> Loading Loading
media/libmedia/include/media/MediaResource.h +2 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,8 @@ public: kUnspecified = 0, kSecureCodec, kNonSecureCodec, kGraphicMemory kGraphicMemory, kCpuBoost, }; enum SubType { Loading
media/libstagefright/MediaCodec.cpp +28 −0 Original line number Diff line number Diff line Loading @@ -523,6 +523,7 @@ MediaCodec::MediaCodec(const sp<ALooper> &looper, pid_t pid, uid_t uid) mDequeueOutputReplyID(0), mHaveInputSurface(false), mHavePendingInputBuffers(false), mCpuBoostRequested(false), mLatencyUnknown(0) { if (uid == kNoUid) { mUid = IPCThreadState::self()->getCallingUid(); Loading Loading @@ -1638,6 +1639,31 @@ void MediaCodec::requestActivityNotification(const sp<AMessage> ¬ify) { msg->post(); } void MediaCodec::requestCpuBoostIfNeeded() { if (mCpuBoostRequested) { return; } int32_t colorFormat; if (mSoftRenderer != NULL && mOutputFormat->contains("hdr-static-info") && mOutputFormat->findInt32("color-format", &colorFormat) && (colorFormat == OMX_COLOR_FormatYUV420Planar16)) { int32_t left, top, right, bottom, width, height; int64_t totalPixel = 0; if (mOutputFormat->findRect("crop", &left, &top, &right, &bottom)) { totalPixel = (right - left + 1) * (bottom - top + 1); } else if (mOutputFormat->findInt32("width", &width) && mOutputFormat->findInt32("height", &height)) { totalPixel = width * height; } if (totalPixel >= 1920 * 1080) { addResource(MediaResource::kCpuBoost, MediaResource::kUnspecifiedSubType, 1); mCpuBoostRequested = true; } } } //////////////////////////////////////////////////////////////////////////////// void MediaCodec::cancelPendingDequeueOperations() { Loading Loading @@ -2160,6 +2186,8 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { } } requestCpuBoostIfNeeded(); if (mFlags & kFlagIsEncoder) { // Before we announce the format change we should // collect codec specific data and amend the output Loading
media/libstagefright/include/media/stagefright/MediaCodec.h +2 −0 Original line number Diff line number Diff line Loading @@ -369,6 +369,7 @@ private: bool mHaveInputSurface; bool mHavePendingInputBuffers; bool mCpuBoostRequested; std::shared_ptr<BufferChannelBase> mBufferChannel; Loading Loading @@ -425,6 +426,7 @@ private: uint64_t getGraphicBufferSize(); void addResource(MediaResource::Type type, MediaResource::SubType subtype, uint64_t value); void requestCpuBoostIfNeeded(); bool hasPendingBuffer(int portIndex); bool hasPendingBuffer(); Loading
media/utils/ISchedulingPolicyService.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ namespace android { // Keep in sync with frameworks/base/core/java/android/os/ISchedulingPolicyService.aidl enum { REQUEST_PRIORITY_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, REQUEST_CPUSET_BOOST, }; // ---------------------------------------------------------------------- Loading Loading @@ -60,6 +61,23 @@ public: } return reply.readInt32(); } virtual int requestCpusetBoost(bool enable, const sp<IInterface>& client) { Parcel data, reply; data.writeInterfaceToken(ISchedulingPolicyService::getInterfaceDescriptor()); data.writeInt32(enable); data.writeStrongBinder(IInterface::asBinder(client)); status_t status = remote()->transact(REQUEST_CPUSET_BOOST, data, &reply, 0); if (status != NO_ERROR) { return status; } // fail on exception: force binder reconnection if (reply.readExceptionCode() != 0) { return DEAD_OBJECT; } return reply.readInt32(); } }; IMPLEMENT_META_INTERFACE(SchedulingPolicyService, "android.os.ISchedulingPolicyService"); Loading @@ -71,6 +89,7 @@ status_t BnSchedulingPolicyService::onTransact( { switch (code) { case REQUEST_PRIORITY_TRANSACTION: case REQUEST_CPUSET_BOOST: // Not reached return NO_ERROR; break; Loading
media/utils/ISchedulingPolicyService.h +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ public: virtual int requestPriority(/*pid_t*/int32_t pid, /*pid_t*/int32_t tid, int32_t prio, bool isForApp, bool asynchronous) = 0; virtual int requestCpusetBoost(bool enable, const sp<IInterface>& client) = 0; }; class BnSchedulingPolicyService : public BnInterface<ISchedulingPolicyService> Loading