Loading apex/AndroidManifest-media.xml +2 −3 Original line number Diff line number Diff line Loading @@ -18,10 +18,9 @@ package="com.android.media"> <!-- APEX does not have classes.dex --> <application android:hasCode="false" /> <!-- Setting maxSdk to lock the module to Q. minSdk is 28 for now to cover Q beta devices. --> <!-- Setting maxSdk to lock the module to Q. minSdk is auto-set by build system --> <uses-sdk android:minSdkVersion="28" android:maxSdkVersion="29" android:targetSdkVersion="28" android:targetSdkVersion="29" /> </manifest> apex/AndroidManifest-swcodec.xml +2 −3 Original line number Diff line number Diff line Loading @@ -18,10 +18,9 @@ package="com.android.media.swcodec"> <!-- APEX does not have classes.dex --> <application android:hasCode="false" /> <!-- Setting maxSdk to lock the module to Q. minSdk is 28 for now to cover Q beta devices. --> <!-- Setting maxSdk to lock the module to Q. minSdk is auto-set by build system --> <uses-sdk android:minSdkVersion="28" android:maxSdkVersion="29" android:targetSdkVersion="28" android:targetSdkVersion="29" /> </manifest> media/codec2/components/aac/C2SoftAacEnc.cpp +41 −24 Original line number Diff line number Diff line Loading @@ -103,11 +103,24 @@ public: }) .withSetter(ProfileLevelSetter) .build()); addParameter( DefineParam(mSBRMode, C2_PARAMKEY_AAC_SBR_MODE) .withDefault(new C2StreamAacSbrModeTuning::input(0u, AAC_SBR_AUTO)) .withFields({C2F(mSBRMode, value).oneOf({ C2Config::AAC_SBR_OFF, C2Config::AAC_SBR_SINGLE_RATE, C2Config::AAC_SBR_DUAL_RATE, C2Config::AAC_SBR_AUTO })}) .withSetter(Setter<decltype(*mSBRMode)>::NonStrictValueWithNoDeps) .build()); } uint32_t getSampleRate() const { return mSampleRate->value; } uint32_t getChannelCount() const { return mChannelCount->value; } uint32_t getBitrate() const { return mBitrate->value; } uint32_t getSBRMode() const { return mSBRMode->value; } uint32_t getProfile() const { return mProfileLevel->profile; } static C2R ProfileLevelSetter(bool mayBlock, C2P<C2StreamProfileLevelInfo::output> &me) { (void)mayBlock; (void)me; // TODO: validate Loading @@ -129,6 +142,7 @@ private: std::shared_ptr<C2StreamBitrateInfo::output> mBitrate; std::shared_ptr<C2StreamMaxBufferSizeInfo::input> mInputMaxBufSize; std::shared_ptr<C2StreamProfileLevelInfo::output> mProfileLevel; std::shared_ptr<C2StreamAacSbrModeTuning::input> mSBRMode; }; C2SoftAacEnc::C2SoftAacEnc( Loading @@ -138,9 +152,6 @@ C2SoftAacEnc::C2SoftAacEnc( : SimpleC2Component(std::make_shared<SimpleInterface<IntfImpl>>(name, id, intfImpl)), mIntf(intfImpl), mAACEncoder(nullptr), mSBRMode(-1), mSBRRatio(0), mAACProfile(AOT_AAC_LC), mNumBytesPerInputFrame(0u), mOutBufferSize(0u), mSentCodecSpecificData(false), Loading Loading @@ -208,31 +219,37 @@ static CHANNEL_MODE getChannelMode(uint32_t nChannels) { return chMode; } //static AUDIO_OBJECT_TYPE getAOTFromProfile(OMX_U32 profile) { // if (profile == OMX_AUDIO_AACObjectLC) { // return AOT_AAC_LC; // } else if (profile == OMX_AUDIO_AACObjectHE) { // return AOT_SBR; // } else if (profile == OMX_AUDIO_AACObjectHE_PS) { // return AOT_PS; // } else if (profile == OMX_AUDIO_AACObjectLD) { // return AOT_ER_AAC_LD; // } else if (profile == OMX_AUDIO_AACObjectELD) { // return AOT_ER_AAC_ELD; // } else { // ALOGW("Unsupported AAC profile - defaulting to AAC-LC"); // return AOT_AAC_LC; // } //} static AUDIO_OBJECT_TYPE getAOTFromProfile(uint32_t profile) { if (profile == C2Config::PROFILE_AAC_LC) { return AOT_AAC_LC; } else if (profile == C2Config::PROFILE_AAC_HE) { return AOT_SBR; } else if (profile == C2Config::PROFILE_AAC_HE_PS) { return AOT_PS; } else if (profile == C2Config::PROFILE_AAC_LD) { return AOT_ER_AAC_LD; } else if (profile == C2Config::PROFILE_AAC_ELD) { return AOT_ER_AAC_ELD; } else { ALOGW("Unsupported AAC profile - defaulting to AAC-LC"); return AOT_AAC_LC; } } status_t C2SoftAacEnc::setAudioParams() { // We call this whenever sample rate, number of channels, bitrate or SBR mode change // in reponse to setParameter calls. int32_t sbrRatio = 0; uint32_t sbrMode = mIntf->getSBRMode(); if (sbrMode == AAC_SBR_SINGLE_RATE) sbrRatio = 1; else if (sbrMode == AAC_SBR_DUAL_RATE) sbrRatio = 2; ALOGV("setAudioParams: %u Hz, %u channels, %u bps, %i sbr mode, %i sbr ratio", mIntf->getSampleRate(), mIntf->getChannelCount(), mIntf->getBitrate(), mSBRMode, mSBRRatio); mIntf->getSampleRate(), mIntf->getChannelCount(), mIntf->getBitrate(), sbrMode, sbrRatio); if (AACENC_OK != aacEncoder_SetParam(mAACEncoder, AACENC_AOT, mAACProfile)) { uint32_t aacProfile = mIntf->getProfile(); if (AACENC_OK != aacEncoder_SetParam(mAACEncoder, AACENC_AOT, getAOTFromProfile(aacProfile))) { ALOGE("Failed to set AAC encoder parameters"); return UNKNOWN_ERROR; } Loading @@ -255,8 +272,8 @@ status_t C2SoftAacEnc::setAudioParams() { return UNKNOWN_ERROR; } if (mSBRMode != -1 && mAACProfile == AOT_ER_AAC_ELD) { if (AACENC_OK != aacEncoder_SetParam(mAACEncoder, AACENC_SBR_MODE, mSBRMode)) { if (sbrMode != -1 && aacProfile == C2Config::PROFILE_AAC_ELD) { if (AACENC_OK != aacEncoder_SetParam(mAACEncoder, AACENC_SBR_MODE, sbrMode)) { ALOGE("Failed to set AAC encoder parameters"); return UNKNOWN_ERROR; } Loading @@ -268,7 +285,7 @@ status_t C2SoftAacEnc::setAudioParams() { 1: Downsampled SBR (default for ELD) 2: Dualrate SBR (default for HE-AAC) */ if (AACENC_OK != aacEncoder_SetParam(mAACEncoder, AACENC_SBR_RATIO, mSBRRatio)) { if (AACENC_OK != aacEncoder_SetParam(mAACEncoder, AACENC_SBR_RATIO, sbrRatio)) { ALOGE("Failed to set AAC encoder parameters"); return UNKNOWN_ERROR; } Loading media/codec2/components/aac/C2SoftAacEnc.h +0 −3 Original line number Diff line number Diff line Loading @@ -50,9 +50,6 @@ private: HANDLE_AACENCODER mAACEncoder; int32_t mSBRMode; int32_t mSBRRatio; AUDIO_OBJECT_TYPE mAACProfile; UINT mNumBytesPerInputFrame; UINT mOutBufferSize; Loading media/codec2/components/avc/C2SoftAvcEnc.cpp +89 −3 Original line number Diff line number Diff line Loading @@ -41,6 +41,37 @@ namespace { constexpr char COMPONENT_NAME[] = "c2.android.avc.encoder"; void ParseGop( const C2StreamGopTuning::output &gop, uint32_t *syncInterval, uint32_t *iInterval, uint32_t *maxBframes) { uint32_t syncInt = 1; uint32_t iInt = 1; for (size_t i = 0; i < gop.flexCount(); ++i) { const C2GopLayerStruct &layer = gop.m.values[i]; if (layer.count == UINT32_MAX) { syncInt = 0; } else if (syncInt <= UINT32_MAX / (layer.count + 1)) { syncInt *= (layer.count + 1); } if ((layer.type_ & I_FRAME) == 0) { if (layer.count == UINT32_MAX) { iInt = 0; } else if (iInt <= UINT32_MAX / (layer.count + 1)) { iInt *= (layer.count + 1); } } if (layer.type_ == C2Config::picture_type_t(P_FRAME | B_FRAME) && maxBframes) { *maxBframes = layer.count; } } if (syncInterval) { *syncInterval = syncInt; } if (iInterval) { *iInterval = iInt; } } } // namespace class C2SoftAvcEnc::IntfImpl : public SimpleInterface<void>::BaseParams { Loading Loading @@ -80,11 +111,20 @@ public: .withSetter(SizeSetter) .build()); addParameter( DefineParam(mGop, C2_PARAMKEY_GOP) .withDefault(C2StreamGopTuning::output::AllocShared( 0 /* flexCount */, 0u /* stream */)) .withFields({C2F(mGop, m.values[0].type_).any(), C2F(mGop, m.values[0].count).any()}) .withSetter(GopSetter) .build()); addParameter( DefineParam(mActualInputDelay, C2_PARAMKEY_INPUT_DELAY) .withDefault(new C2PortActualDelayTuning::input(DEFAULT_B_FRAMES)) .withFields({C2F(mActualInputDelay, value).inRange(0, MAX_B_FRAMES)}) .withSetter(Setter<decltype(*mActualInputDelay)>::StrictValueWithNoDeps) .calculatedAs(InputDelaySetter, mGop) .build()); addParameter( Loading Loading @@ -160,6 +200,17 @@ public: .build()); } static C2R InputDelaySetter( bool mayBlock, C2P<C2PortActualDelayTuning::input> &me, const C2P<C2StreamGopTuning::output> &gop) { (void)mayBlock; uint32_t maxBframes = 0; ParseGop(gop.v, nullptr, nullptr, &maxBframes); me.set().value = maxBframes; return C2R::Ok(); } static C2R BitrateSetter(bool mayBlock, C2P<C2StreamBitrateInfo::output> &me) { (void)mayBlock; C2R res = C2R::Ok(); Loading Loading @@ -273,6 +324,18 @@ public: return res; } static C2R GopSetter(bool mayBlock, C2P<C2StreamGopTuning::output> &me) { (void)mayBlock; for (size_t i = 0; i < me.v.flexCount(); ++i) { const C2GopLayerStruct &layer = me.v.m.values[0]; if (layer.type_ == C2Config::picture_type_t(P_FRAME | B_FRAME) && layer.count > MAX_B_FRAMES) { me.set().m.values[i].count = MAX_B_FRAMES; } } return C2R::Ok(); } IV_PROFILE_T getProfile_l() const { switch (mProfileLevel->profile) { case PROFILE_AVC_CONSTRAINED_BASELINE: [[fallthrough]]; Loading Loading @@ -314,6 +377,7 @@ public: ALOGD("Unrecognized level: %x", mProfileLevel->level); return 41; } uint32_t getSyncFramePeriod_l() const { if (mSyncFramePeriod->value < 0 || mSyncFramePeriod->value == INT64_MAX) { return 0; Loading @@ -328,6 +392,7 @@ public: std::shared_ptr<C2StreamFrameRateInfo::output> getFrameRate_l() const { return mFrameRate; } std::shared_ptr<C2StreamBitrateInfo::output> getBitrate_l() const { return mBitrate; } std::shared_ptr<C2StreamRequestSyncFrameTuning::output> getRequestSync_l() const { return mRequestSync; } std::shared_ptr<C2StreamGopTuning::output> getGop_l() const { return mGop; } private: std::shared_ptr<C2StreamUsageTuning::input> mUsage; Loading @@ -338,6 +403,7 @@ private: std::shared_ptr<C2StreamBitrateInfo::output> mBitrate; std::shared_ptr<C2StreamProfileLevelInfo::output> mProfileLevel; std::shared_ptr<C2StreamSyncFrameIntervalTuning::output> mSyncFramePeriod; std::shared_ptr<C2StreamGopTuning::output> mGop; }; #define ive_api_function ih264e_api_function Loading Loading @@ -850,6 +916,7 @@ c2_status_t C2SoftAvcEnc::initEncoder() { c2_status_t errType = C2_OK; std::shared_ptr<C2StreamGopTuning::output> gop; { IntfImpl::Lock lock = mIntf->lock(); mSize = mIntf->getSize_l(); Loading @@ -859,6 +926,25 @@ c2_status_t C2SoftAvcEnc::initEncoder() { mAVCEncLevel = mIntf->getLevel_l(); mIInterval = mIntf->getSyncFramePeriod_l(); mIDRInterval = mIntf->getSyncFramePeriod_l(); gop = mIntf->getGop_l(); } if (gop && gop->flexCount() > 0) { uint32_t syncInterval = 1; uint32_t iInterval = 1; uint32_t maxBframes = 0; ParseGop(*gop, &syncInterval, &iInterval, &maxBframes); if (syncInterval > 0) { ALOGD("Updating IDR interval from GOP: old %u new %u", mIDRInterval, syncInterval); mIDRInterval = syncInterval; } if (iInterval > 0) { ALOGD("Updating I interval from GOP: old %u new %u", mIInterval, iInterval); mIInterval = iInterval; } if (mBframes != maxBframes) { ALOGD("Updating max B frames from GOP: old %u new %u", mBframes, maxBframes); mBframes = maxBframes; } } uint32_t width = mSize->width; uint32_t height = mSize->height; Loading @@ -868,8 +954,8 @@ c2_status_t C2SoftAvcEnc::initEncoder() { // TODO mIvVideoColorFormat = IV_YUV_420P; ALOGD("Params width %d height %d level %d colorFormat %d", width, height, mAVCEncLevel, mIvVideoColorFormat); ALOGD("Params width %d height %d level %d colorFormat %d bframes %d", width, height, mAVCEncLevel, mIvVideoColorFormat, mBframes); /* Getting Number of MemRecords */ { Loading Loading
apex/AndroidManifest-media.xml +2 −3 Original line number Diff line number Diff line Loading @@ -18,10 +18,9 @@ package="com.android.media"> <!-- APEX does not have classes.dex --> <application android:hasCode="false" /> <!-- Setting maxSdk to lock the module to Q. minSdk is 28 for now to cover Q beta devices. --> <!-- Setting maxSdk to lock the module to Q. minSdk is auto-set by build system --> <uses-sdk android:minSdkVersion="28" android:maxSdkVersion="29" android:targetSdkVersion="28" android:targetSdkVersion="29" /> </manifest>
apex/AndroidManifest-swcodec.xml +2 −3 Original line number Diff line number Diff line Loading @@ -18,10 +18,9 @@ package="com.android.media.swcodec"> <!-- APEX does not have classes.dex --> <application android:hasCode="false" /> <!-- Setting maxSdk to lock the module to Q. minSdk is 28 for now to cover Q beta devices. --> <!-- Setting maxSdk to lock the module to Q. minSdk is auto-set by build system --> <uses-sdk android:minSdkVersion="28" android:maxSdkVersion="29" android:targetSdkVersion="28" android:targetSdkVersion="29" /> </manifest>
media/codec2/components/aac/C2SoftAacEnc.cpp +41 −24 Original line number Diff line number Diff line Loading @@ -103,11 +103,24 @@ public: }) .withSetter(ProfileLevelSetter) .build()); addParameter( DefineParam(mSBRMode, C2_PARAMKEY_AAC_SBR_MODE) .withDefault(new C2StreamAacSbrModeTuning::input(0u, AAC_SBR_AUTO)) .withFields({C2F(mSBRMode, value).oneOf({ C2Config::AAC_SBR_OFF, C2Config::AAC_SBR_SINGLE_RATE, C2Config::AAC_SBR_DUAL_RATE, C2Config::AAC_SBR_AUTO })}) .withSetter(Setter<decltype(*mSBRMode)>::NonStrictValueWithNoDeps) .build()); } uint32_t getSampleRate() const { return mSampleRate->value; } uint32_t getChannelCount() const { return mChannelCount->value; } uint32_t getBitrate() const { return mBitrate->value; } uint32_t getSBRMode() const { return mSBRMode->value; } uint32_t getProfile() const { return mProfileLevel->profile; } static C2R ProfileLevelSetter(bool mayBlock, C2P<C2StreamProfileLevelInfo::output> &me) { (void)mayBlock; (void)me; // TODO: validate Loading @@ -129,6 +142,7 @@ private: std::shared_ptr<C2StreamBitrateInfo::output> mBitrate; std::shared_ptr<C2StreamMaxBufferSizeInfo::input> mInputMaxBufSize; std::shared_ptr<C2StreamProfileLevelInfo::output> mProfileLevel; std::shared_ptr<C2StreamAacSbrModeTuning::input> mSBRMode; }; C2SoftAacEnc::C2SoftAacEnc( Loading @@ -138,9 +152,6 @@ C2SoftAacEnc::C2SoftAacEnc( : SimpleC2Component(std::make_shared<SimpleInterface<IntfImpl>>(name, id, intfImpl)), mIntf(intfImpl), mAACEncoder(nullptr), mSBRMode(-1), mSBRRatio(0), mAACProfile(AOT_AAC_LC), mNumBytesPerInputFrame(0u), mOutBufferSize(0u), mSentCodecSpecificData(false), Loading Loading @@ -208,31 +219,37 @@ static CHANNEL_MODE getChannelMode(uint32_t nChannels) { return chMode; } //static AUDIO_OBJECT_TYPE getAOTFromProfile(OMX_U32 profile) { // if (profile == OMX_AUDIO_AACObjectLC) { // return AOT_AAC_LC; // } else if (profile == OMX_AUDIO_AACObjectHE) { // return AOT_SBR; // } else if (profile == OMX_AUDIO_AACObjectHE_PS) { // return AOT_PS; // } else if (profile == OMX_AUDIO_AACObjectLD) { // return AOT_ER_AAC_LD; // } else if (profile == OMX_AUDIO_AACObjectELD) { // return AOT_ER_AAC_ELD; // } else { // ALOGW("Unsupported AAC profile - defaulting to AAC-LC"); // return AOT_AAC_LC; // } //} static AUDIO_OBJECT_TYPE getAOTFromProfile(uint32_t profile) { if (profile == C2Config::PROFILE_AAC_LC) { return AOT_AAC_LC; } else if (profile == C2Config::PROFILE_AAC_HE) { return AOT_SBR; } else if (profile == C2Config::PROFILE_AAC_HE_PS) { return AOT_PS; } else if (profile == C2Config::PROFILE_AAC_LD) { return AOT_ER_AAC_LD; } else if (profile == C2Config::PROFILE_AAC_ELD) { return AOT_ER_AAC_ELD; } else { ALOGW("Unsupported AAC profile - defaulting to AAC-LC"); return AOT_AAC_LC; } } status_t C2SoftAacEnc::setAudioParams() { // We call this whenever sample rate, number of channels, bitrate or SBR mode change // in reponse to setParameter calls. int32_t sbrRatio = 0; uint32_t sbrMode = mIntf->getSBRMode(); if (sbrMode == AAC_SBR_SINGLE_RATE) sbrRatio = 1; else if (sbrMode == AAC_SBR_DUAL_RATE) sbrRatio = 2; ALOGV("setAudioParams: %u Hz, %u channels, %u bps, %i sbr mode, %i sbr ratio", mIntf->getSampleRate(), mIntf->getChannelCount(), mIntf->getBitrate(), mSBRMode, mSBRRatio); mIntf->getSampleRate(), mIntf->getChannelCount(), mIntf->getBitrate(), sbrMode, sbrRatio); if (AACENC_OK != aacEncoder_SetParam(mAACEncoder, AACENC_AOT, mAACProfile)) { uint32_t aacProfile = mIntf->getProfile(); if (AACENC_OK != aacEncoder_SetParam(mAACEncoder, AACENC_AOT, getAOTFromProfile(aacProfile))) { ALOGE("Failed to set AAC encoder parameters"); return UNKNOWN_ERROR; } Loading @@ -255,8 +272,8 @@ status_t C2SoftAacEnc::setAudioParams() { return UNKNOWN_ERROR; } if (mSBRMode != -1 && mAACProfile == AOT_ER_AAC_ELD) { if (AACENC_OK != aacEncoder_SetParam(mAACEncoder, AACENC_SBR_MODE, mSBRMode)) { if (sbrMode != -1 && aacProfile == C2Config::PROFILE_AAC_ELD) { if (AACENC_OK != aacEncoder_SetParam(mAACEncoder, AACENC_SBR_MODE, sbrMode)) { ALOGE("Failed to set AAC encoder parameters"); return UNKNOWN_ERROR; } Loading @@ -268,7 +285,7 @@ status_t C2SoftAacEnc::setAudioParams() { 1: Downsampled SBR (default for ELD) 2: Dualrate SBR (default for HE-AAC) */ if (AACENC_OK != aacEncoder_SetParam(mAACEncoder, AACENC_SBR_RATIO, mSBRRatio)) { if (AACENC_OK != aacEncoder_SetParam(mAACEncoder, AACENC_SBR_RATIO, sbrRatio)) { ALOGE("Failed to set AAC encoder parameters"); return UNKNOWN_ERROR; } Loading
media/codec2/components/aac/C2SoftAacEnc.h +0 −3 Original line number Diff line number Diff line Loading @@ -50,9 +50,6 @@ private: HANDLE_AACENCODER mAACEncoder; int32_t mSBRMode; int32_t mSBRRatio; AUDIO_OBJECT_TYPE mAACProfile; UINT mNumBytesPerInputFrame; UINT mOutBufferSize; Loading
media/codec2/components/avc/C2SoftAvcEnc.cpp +89 −3 Original line number Diff line number Diff line Loading @@ -41,6 +41,37 @@ namespace { constexpr char COMPONENT_NAME[] = "c2.android.avc.encoder"; void ParseGop( const C2StreamGopTuning::output &gop, uint32_t *syncInterval, uint32_t *iInterval, uint32_t *maxBframes) { uint32_t syncInt = 1; uint32_t iInt = 1; for (size_t i = 0; i < gop.flexCount(); ++i) { const C2GopLayerStruct &layer = gop.m.values[i]; if (layer.count == UINT32_MAX) { syncInt = 0; } else if (syncInt <= UINT32_MAX / (layer.count + 1)) { syncInt *= (layer.count + 1); } if ((layer.type_ & I_FRAME) == 0) { if (layer.count == UINT32_MAX) { iInt = 0; } else if (iInt <= UINT32_MAX / (layer.count + 1)) { iInt *= (layer.count + 1); } } if (layer.type_ == C2Config::picture_type_t(P_FRAME | B_FRAME) && maxBframes) { *maxBframes = layer.count; } } if (syncInterval) { *syncInterval = syncInt; } if (iInterval) { *iInterval = iInt; } } } // namespace class C2SoftAvcEnc::IntfImpl : public SimpleInterface<void>::BaseParams { Loading Loading @@ -80,11 +111,20 @@ public: .withSetter(SizeSetter) .build()); addParameter( DefineParam(mGop, C2_PARAMKEY_GOP) .withDefault(C2StreamGopTuning::output::AllocShared( 0 /* flexCount */, 0u /* stream */)) .withFields({C2F(mGop, m.values[0].type_).any(), C2F(mGop, m.values[0].count).any()}) .withSetter(GopSetter) .build()); addParameter( DefineParam(mActualInputDelay, C2_PARAMKEY_INPUT_DELAY) .withDefault(new C2PortActualDelayTuning::input(DEFAULT_B_FRAMES)) .withFields({C2F(mActualInputDelay, value).inRange(0, MAX_B_FRAMES)}) .withSetter(Setter<decltype(*mActualInputDelay)>::StrictValueWithNoDeps) .calculatedAs(InputDelaySetter, mGop) .build()); addParameter( Loading Loading @@ -160,6 +200,17 @@ public: .build()); } static C2R InputDelaySetter( bool mayBlock, C2P<C2PortActualDelayTuning::input> &me, const C2P<C2StreamGopTuning::output> &gop) { (void)mayBlock; uint32_t maxBframes = 0; ParseGop(gop.v, nullptr, nullptr, &maxBframes); me.set().value = maxBframes; return C2R::Ok(); } static C2R BitrateSetter(bool mayBlock, C2P<C2StreamBitrateInfo::output> &me) { (void)mayBlock; C2R res = C2R::Ok(); Loading Loading @@ -273,6 +324,18 @@ public: return res; } static C2R GopSetter(bool mayBlock, C2P<C2StreamGopTuning::output> &me) { (void)mayBlock; for (size_t i = 0; i < me.v.flexCount(); ++i) { const C2GopLayerStruct &layer = me.v.m.values[0]; if (layer.type_ == C2Config::picture_type_t(P_FRAME | B_FRAME) && layer.count > MAX_B_FRAMES) { me.set().m.values[i].count = MAX_B_FRAMES; } } return C2R::Ok(); } IV_PROFILE_T getProfile_l() const { switch (mProfileLevel->profile) { case PROFILE_AVC_CONSTRAINED_BASELINE: [[fallthrough]]; Loading Loading @@ -314,6 +377,7 @@ public: ALOGD("Unrecognized level: %x", mProfileLevel->level); return 41; } uint32_t getSyncFramePeriod_l() const { if (mSyncFramePeriod->value < 0 || mSyncFramePeriod->value == INT64_MAX) { return 0; Loading @@ -328,6 +392,7 @@ public: std::shared_ptr<C2StreamFrameRateInfo::output> getFrameRate_l() const { return mFrameRate; } std::shared_ptr<C2StreamBitrateInfo::output> getBitrate_l() const { return mBitrate; } std::shared_ptr<C2StreamRequestSyncFrameTuning::output> getRequestSync_l() const { return mRequestSync; } std::shared_ptr<C2StreamGopTuning::output> getGop_l() const { return mGop; } private: std::shared_ptr<C2StreamUsageTuning::input> mUsage; Loading @@ -338,6 +403,7 @@ private: std::shared_ptr<C2StreamBitrateInfo::output> mBitrate; std::shared_ptr<C2StreamProfileLevelInfo::output> mProfileLevel; std::shared_ptr<C2StreamSyncFrameIntervalTuning::output> mSyncFramePeriod; std::shared_ptr<C2StreamGopTuning::output> mGop; }; #define ive_api_function ih264e_api_function Loading Loading @@ -850,6 +916,7 @@ c2_status_t C2SoftAvcEnc::initEncoder() { c2_status_t errType = C2_OK; std::shared_ptr<C2StreamGopTuning::output> gop; { IntfImpl::Lock lock = mIntf->lock(); mSize = mIntf->getSize_l(); Loading @@ -859,6 +926,25 @@ c2_status_t C2SoftAvcEnc::initEncoder() { mAVCEncLevel = mIntf->getLevel_l(); mIInterval = mIntf->getSyncFramePeriod_l(); mIDRInterval = mIntf->getSyncFramePeriod_l(); gop = mIntf->getGop_l(); } if (gop && gop->flexCount() > 0) { uint32_t syncInterval = 1; uint32_t iInterval = 1; uint32_t maxBframes = 0; ParseGop(*gop, &syncInterval, &iInterval, &maxBframes); if (syncInterval > 0) { ALOGD("Updating IDR interval from GOP: old %u new %u", mIDRInterval, syncInterval); mIDRInterval = syncInterval; } if (iInterval > 0) { ALOGD("Updating I interval from GOP: old %u new %u", mIInterval, iInterval); mIInterval = iInterval; } if (mBframes != maxBframes) { ALOGD("Updating max B frames from GOP: old %u new %u", mBframes, maxBframes); mBframes = maxBframes; } } uint32_t width = mSize->width; uint32_t height = mSize->height; Loading @@ -868,8 +954,8 @@ c2_status_t C2SoftAvcEnc::initEncoder() { // TODO mIvVideoColorFormat = IV_YUV_420P; ALOGD("Params width %d height %d level %d colorFormat %d", width, height, mAVCEncLevel, mIvVideoColorFormat); ALOGD("Params width %d height %d level %d colorFormat %d bframes %d", width, height, mAVCEncLevel, mIvVideoColorFormat, mBframes); /* Getting Number of MemRecords */ { Loading