Merge "SoftAVCEnc: Modified the code for runtime change in params to be generic"
diff --git a/media/libstagefright/codecs/avcenc/SoftAVCEnc.cpp b/media/libstagefright/codecs/avcenc/SoftAVCEnc.cpp
index 387d17d..d0ad4f8 100644
--- a/media/libstagefright/codecs/avcenc/SoftAVCEnc.cpp
+++ b/media/libstagefright/codecs/avcenc/SoftAVCEnc.cpp
@@ -157,8 +157,7 @@
kProfileLevels, NELEM(kProfileLevels),
176 /* width */, 144 /* height */,
callbacks, appData, component),
- mBitrateUpdated(false),
- mKeyFrameRequested(false),
+ mUpdateFlag(0),
mIvVideoColorFormat(IV_YUV_420P),
mAVCEncProfile(IV_PROFILE_BASE),
mAVCEncLevel(41),
@@ -1039,7 +1038,9 @@
return OMX_ErrorBadPortIndex;
}
- mKeyFrameRequested = params->IntraRefreshVOP;
+ if (params->IntraRefreshVOP) {
+ mUpdateFlag |= kRequestKeyFrame;
+ }
return OMX_ErrorNone;
}
@@ -1054,7 +1055,7 @@
if (mBitrate != params->nEncodeBitrate) {
mBitrate = params->nEncodeBitrate;
- mBitrateUpdated = true;
+ mUpdateFlag |= kUpdateBitrate;
}
return OMX_ErrorNone;
}
@@ -1071,7 +1072,7 @@
}
mBitrate = bitrate->nTargetBitrate;
- mBitrateUpdated = true;
+ mUpdateFlag |= kUpdateBitrate;
return OMX_ErrorNone;
}
@@ -1291,12 +1292,14 @@
return;
}
- if (mBitrateUpdated) {
- setBitRate();
- }
-
- if (mKeyFrameRequested) {
- setFrameType(IV_IDR_FRAME);
+ if (mUpdateFlag) {
+ if (mUpdateFlag & kUpdateBitrate) {
+ setBitRate();
+ }
+ if (mUpdateFlag & kRequestKeyFrame) {
+ setFrameType(IV_IDR_FRAME);
+ }
+ mUpdateFlag = 0;
}
if ((inputBufferHeader != NULL)
diff --git a/media/libstagefright/codecs/avcenc/SoftAVCEnc.h b/media/libstagefright/codecs/avcenc/SoftAVCEnc.h
index 4418a7f..6a3bc0f 100644
--- a/media/libstagefright/codecs/avcenc/SoftAVCEnc.h
+++ b/media/libstagefright/codecs/avcenc/SoftAVCEnc.h
@@ -142,6 +142,11 @@
kNumBuffers = 2,
};
+ enum {
+ kUpdateBitrate = 1 << 0,
+ kRequestKeyFrame = 1 << 1,
+ };
+
// OMX input buffer's timestamp and flags
typedef struct {
int64_t mTimeUs;
@@ -153,11 +158,7 @@
struct timeval mTimeStart; // Time at the start of decode()
struct timeval mTimeEnd; // Time at the end of decode()
-
- // If a request for a change it bitrate has been received.
- bool mBitrateUpdated;
-
- bool mKeyFrameRequested;
+ int mUpdateFlag;
#ifdef FILE_DUMP_ENABLE
char mInFile[200];