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

Commit d72e751f authored by Lajos Molnar's avatar Lajos Molnar
Browse files

SoftAVCEnc/SoftMPEG4Enc: support updated i-frame interval and encoder settings

- use key-frame interval in MPEG4 encoder
- use updated definition of nBFrames and nPFrames in AVC encoder

Bug: 30096321
Bug: 28027692
Change-Id: I68d0d5182b462cad567c329a07fdafea55d19ff7
parent 210c67fe
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -1016,10 +1016,10 @@ OMX_ERRORTYPE SoftAVC::internalSetParameter(OMX_INDEXTYPE index, const OMX_PTR p

            if ((avcType->nAllowedPictureTypes & OMX_VIDEO_PictureTypeB) &&
                    avcType->nPFrames) {
                mBframes = avcType->nBFrames / avcType->nPFrames;
                mBframes = avcType->nBFrames;
            }

            mIInterval = avcType->nPFrames + avcType->nBFrames;
            mIInterval = (avcType->nPFrames + 1) * (avcType->nBFrames + 1);
            mConstrainedIntraFlag = avcType->bconstIpred;

            if (OMX_VIDEO_AVCLoopFilterDisable == avcType->eLoopFilterMode)
@@ -1033,7 +1033,9 @@ OMX_ERRORTYPE SoftAVC::internalSetParameter(OMX_INDEXTYPE index, const OMX_PTR p
                    || avcType->bDirect8x8Inference != OMX_FALSE
                    || avcType->bDirectSpatialTemporal != OMX_FALSE
                    || avcType->nCabacInitIdc != 0) {
                return OMX_ErrorUndefined;
                // OMX does not allow a way to signal what values are wrong, so it's
                // best for components to just do best effort in supporting these values
                ALOGV("ignoring unsupported settings");
            }

            if (OK != ConvertOmxAvcLevelToAvcSpecLevel(avcType->eLevel, &mAVCEncLevel)) {
+4 −9
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ SoftMPEG4Encoder::SoftMPEG4Encoder(
            176 /* width */, 144 /* height */,
            callbacks, appData, component),
      mEncodeMode(COMBINE_MODE_WITH_ERR_RES),
      mIDRFrameRefreshIntervalInSec(1),
      mKeyFrameInterval(30),
      mNumInputFrames(-1),
      mStarted(false),
      mSawInputEOS(false),
@@ -159,14 +159,7 @@ OMX_ERRORTYPE SoftMPEG4Encoder::initEncParams() {
    }

    // Set IDR frame refresh interval
    if (mIDRFrameRefreshIntervalInSec < 0) {
        mEncParams->intraPeriod = -1;
    } else if (mIDRFrameRefreshIntervalInSec == 0) {
        mEncParams->intraPeriod = 1;  // All I frames
    } else {
        mEncParams->intraPeriod =
            (mIDRFrameRefreshIntervalInSec * mFramerate) >> 16;
    }
    mEncParams->intraPeriod = mKeyFrameInterval;

    mEncParams->numIntraMB = 0;
    mEncParams->sceneDetect = PV_ON;
@@ -378,6 +371,8 @@ OMX_ERRORTYPE SoftMPEG4Encoder::internalSetParameter(
                return OMX_ErrorUndefined;
            }

            mKeyFrameInterval = int32_t(mpeg4type->nPFrames + 1);

            return OMX_ErrorNone;
        }

+1 −1
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ private:
    } InputBufferInfo;

    MP4EncodingMode mEncodeMode;
    int32_t  mIDRFrameRefreshIntervalInSec;
    int32_t  mKeyFrameInterval; // 1: all I-frames, <0: infinite

    int64_t  mNumInputFrames;
    bool     mStarted;