Loading include/media/IOMX.h +1 −0 Original line number Diff line number Diff line Loading @@ -147,6 +147,7 @@ public: INTERNAL_OPTION_SUSPEND, // data is a bool INTERNAL_OPTION_REPEAT_PREVIOUS_FRAME_DELAY, // data is an int64_t INTERNAL_OPTION_MAX_TIMESTAMP_GAP, // data is int64_t INTERNAL_OPTION_MAX_FPS, // data is float INTERNAL_OPTION_START_TIME, // data is an int64_t INTERNAL_OPTION_TIME_LAPSE, // data is an int64_t[2] }; Loading include/media/stagefright/ACodec.h +1 −0 Original line number Diff line number Diff line Loading @@ -214,6 +214,7 @@ private: int64_t mRepeatFrameDelayUs; int64_t mMaxPtsGapUs; float mMaxFps; int64_t mTimePerFrameUs; int64_t mTimePerCaptureUs; Loading media/libstagefright/ACodec.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -419,6 +419,7 @@ ACodec::ACodec() mMetaDataBuffersToSubmit(0), mRepeatFrameDelayUs(-1ll), mMaxPtsGapUs(-1ll), mMaxFps(-1), mTimePerFrameUs(-1ll), mTimePerCaptureUs(-1ll), mCreateInputBuffersSuspended(false), Loading Loading @@ -1259,6 +1260,10 @@ status_t ACodec::configureCodec( mMaxPtsGapUs = -1ll; } if (!msg->findFloat("max-fps-to-encoder", &mMaxFps)) { mMaxFps = -1; } if (!msg->findInt64("time-lapse", &mTimePerCaptureUs)) { mTimePerCaptureUs = -1ll; } Loading Loading @@ -5110,6 +5115,21 @@ void ACodec::LoadedState::onCreateInputSurface( } } if (err == OK && mCodec->mMaxFps > 0) { err = mCodec->mOMX->setInternalOption( mCodec->mNode, kPortIndexInput, IOMX::INTERNAL_OPTION_MAX_FPS, &mCodec->mMaxFps, sizeof(mCodec->mMaxFps)); if (err != OK) { ALOGE("[%s] Unable to configure max fps (err %d)", mCodec->mComponentName.c_str(), err); } } if (err == OK && mCodec->mTimePerCaptureUs > 0ll && mCodec->mTimePerFrameUs > 0ll) { int64_t timeLapse[2]; Loading media/libstagefright/omx/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ ifeq ($(TARGET_DEVICE), manta) endif LOCAL_SRC_FILES:= \ FrameDropper.cpp \ GraphicBufferSource.cpp \ OMX.cpp \ OMXMaster.cpp \ Loading media/libstagefright/omx/FrameDropper.cpp 0 → 100644 +70 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ //#define LOG_NDEBUG 0 #define LOG_TAG "FrameDropper" #include <utils/Log.h> #include "FrameDropper.h" #include <media/stagefright/foundation/ADebug.h> namespace android { static const int64_t kMaxJitterUs = 2000; FrameDropper::FrameDropper() : mDesiredMinTimeUs(-1), mMinIntervalUs(0) { } FrameDropper::~FrameDropper() { } status_t FrameDropper::setMaxFrameRate(float maxFrameRate) { if (maxFrameRate <= 0) { ALOGE("framerate should be positive but got %f.", maxFrameRate); return BAD_VALUE; } mMinIntervalUs = (int64_t) (1000000.0f / maxFrameRate); return OK; } bool FrameDropper::shouldDrop(int64_t timeUs) { if (mMinIntervalUs <= 0) { return false; } if (mDesiredMinTimeUs < 0) { mDesiredMinTimeUs = timeUs + mMinIntervalUs; ALOGV("first frame %lld, next desired frame %lld", timeUs, mDesiredMinTimeUs); return false; } if (timeUs < (mDesiredMinTimeUs - kMaxJitterUs)) { ALOGV("drop frame %lld, desired frame %lld, diff %lld", timeUs, mDesiredMinTimeUs, mDesiredMinTimeUs - timeUs); return true; } int64_t n = (timeUs - mDesiredMinTimeUs + kMaxJitterUs) / mMinIntervalUs; mDesiredMinTimeUs += (n + 1) * mMinIntervalUs; ALOGV("keep frame %lld, next desired frame %lld, diff %lld", timeUs, mDesiredMinTimeUs, mDesiredMinTimeUs - timeUs); return false; } } // namespace android Loading
include/media/IOMX.h +1 −0 Original line number Diff line number Diff line Loading @@ -147,6 +147,7 @@ public: INTERNAL_OPTION_SUSPEND, // data is a bool INTERNAL_OPTION_REPEAT_PREVIOUS_FRAME_DELAY, // data is an int64_t INTERNAL_OPTION_MAX_TIMESTAMP_GAP, // data is int64_t INTERNAL_OPTION_MAX_FPS, // data is float INTERNAL_OPTION_START_TIME, // data is an int64_t INTERNAL_OPTION_TIME_LAPSE, // data is an int64_t[2] }; Loading
include/media/stagefright/ACodec.h +1 −0 Original line number Diff line number Diff line Loading @@ -214,6 +214,7 @@ private: int64_t mRepeatFrameDelayUs; int64_t mMaxPtsGapUs; float mMaxFps; int64_t mTimePerFrameUs; int64_t mTimePerCaptureUs; Loading
media/libstagefright/ACodec.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -419,6 +419,7 @@ ACodec::ACodec() mMetaDataBuffersToSubmit(0), mRepeatFrameDelayUs(-1ll), mMaxPtsGapUs(-1ll), mMaxFps(-1), mTimePerFrameUs(-1ll), mTimePerCaptureUs(-1ll), mCreateInputBuffersSuspended(false), Loading Loading @@ -1259,6 +1260,10 @@ status_t ACodec::configureCodec( mMaxPtsGapUs = -1ll; } if (!msg->findFloat("max-fps-to-encoder", &mMaxFps)) { mMaxFps = -1; } if (!msg->findInt64("time-lapse", &mTimePerCaptureUs)) { mTimePerCaptureUs = -1ll; } Loading Loading @@ -5110,6 +5115,21 @@ void ACodec::LoadedState::onCreateInputSurface( } } if (err == OK && mCodec->mMaxFps > 0) { err = mCodec->mOMX->setInternalOption( mCodec->mNode, kPortIndexInput, IOMX::INTERNAL_OPTION_MAX_FPS, &mCodec->mMaxFps, sizeof(mCodec->mMaxFps)); if (err != OK) { ALOGE("[%s] Unable to configure max fps (err %d)", mCodec->mComponentName.c_str(), err); } } if (err == OK && mCodec->mTimePerCaptureUs > 0ll && mCodec->mTimePerFrameUs > 0ll) { int64_t timeLapse[2]; Loading
media/libstagefright/omx/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ ifeq ($(TARGET_DEVICE), manta) endif LOCAL_SRC_FILES:= \ FrameDropper.cpp \ GraphicBufferSource.cpp \ OMX.cpp \ OMXMaster.cpp \ Loading
media/libstagefright/omx/FrameDropper.cpp 0 → 100644 +70 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ //#define LOG_NDEBUG 0 #define LOG_TAG "FrameDropper" #include <utils/Log.h> #include "FrameDropper.h" #include <media/stagefright/foundation/ADebug.h> namespace android { static const int64_t kMaxJitterUs = 2000; FrameDropper::FrameDropper() : mDesiredMinTimeUs(-1), mMinIntervalUs(0) { } FrameDropper::~FrameDropper() { } status_t FrameDropper::setMaxFrameRate(float maxFrameRate) { if (maxFrameRate <= 0) { ALOGE("framerate should be positive but got %f.", maxFrameRate); return BAD_VALUE; } mMinIntervalUs = (int64_t) (1000000.0f / maxFrameRate); return OK; } bool FrameDropper::shouldDrop(int64_t timeUs) { if (mMinIntervalUs <= 0) { return false; } if (mDesiredMinTimeUs < 0) { mDesiredMinTimeUs = timeUs + mMinIntervalUs; ALOGV("first frame %lld, next desired frame %lld", timeUs, mDesiredMinTimeUs); return false; } if (timeUs < (mDesiredMinTimeUs - kMaxJitterUs)) { ALOGV("drop frame %lld, desired frame %lld, diff %lld", timeUs, mDesiredMinTimeUs, mDesiredMinTimeUs - timeUs); return true; } int64_t n = (timeUs - mDesiredMinTimeUs + kMaxJitterUs) / mMinIntervalUs; mDesiredMinTimeUs += (n + 1) * mMinIntervalUs; ALOGV("keep frame %lld, next desired frame %lld, diff %lld", timeUs, mDesiredMinTimeUs, mDesiredMinTimeUs - timeUs); return false; } } // namespace android