Merge "SoftAVCEnc: Modified the code for runtime change in params to be generic" into nyc-dev
diff --git a/media/libstagefright/codecs/avcenc/SoftAVCEnc.cpp b/media/libstagefright/codecs/avcenc/SoftAVCEnc.cpp
index 4ff6be3..cc727f2 100644
--- a/media/libstagefright/codecs/avcenc/SoftAVCEnc.cpp
+++ b/media/libstagefright/codecs/avcenc/SoftAVCEnc.cpp
@@ -159,8 +159,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),
@@ -1061,7 +1060,9 @@
return OMX_ErrorBadPortIndex;
}
- mKeyFrameRequested = params->IntraRefreshVOP;
+ if (params->IntraRefreshVOP) {
+ mUpdateFlag |= kRequestKeyFrame;
+ }
return OMX_ErrorNone;
}
@@ -1076,7 +1077,7 @@
if (mBitrate != params->nEncodeBitrate) {
mBitrate = params->nEncodeBitrate;
- mBitrateUpdated = true;
+ mUpdateFlag |= kUpdateBitrate;
}
return OMX_ErrorNone;
}
@@ -1111,7 +1112,7 @@
}
mBitrate = bitrate->nTargetBitrate;
- mBitrateUpdated = true;
+ mUpdateFlag |= kUpdateBitrate;
return OMX_ErrorNone;
}
@@ -1331,12 +1332,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 5dbe437..3c811d2 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];