C2SoftVpxEnc: fixup handle dynamic config params
fix rounding and framerate default
Test: cts -m CtsMediaTestCases -t android.media.cts.VpxEncoderTest#\
testDynamicBitrateChangeVP8
Bug: 110265995
Change-Id: If4119e283e5b2da22c7fcb238d9f1ee6a0fe914b
diff --git a/media/codecs/vpx/C2SoftVpxEnc.cpp b/media/codecs/vpx/C2SoftVpxEnc.cpp
index 9a7c105..0fe4770 100644
--- a/media/codecs/vpx/C2SoftVpxEnc.cpp
+++ b/media/codecs/vpx/C2SoftVpxEnc.cpp
@@ -120,9 +120,9 @@
mFrameRate = mIntf->getFrameRate_l();
mIntraRefresh = mIntf->getIntraRefresh_l();
mRequestSync = mIntf->getRequestSync_l();
+ mTemporalLayers = mIntf->getTemporalLayers_l()->m.layerCount;
}
- mTemporalLayers = mIntf->getTemporalLayers_l()->m.layerCount;
setCodecSpecificInterface();
if (!mCodecInterface) goto CleanUp;
@@ -272,8 +272,7 @@
1);
if (codec_return == VPX_CODEC_OK) {
uint32_t rc_max_intra_target =
- mCodecConfiguration->rc_buf_optimal_sz *
- ((uint32_t)(mFrameRate->value + 0.5) >> 1) / 10;
+ (uint32_t)(mCodecConfiguration->rc_buf_optimal_sz * mFrameRate->value / 20 + 0.5);
// Don't go below 3 times per frame bandwidth.
if (rc_max_intra_target < 300) {
rc_max_intra_target = 300;
@@ -561,8 +560,11 @@
frameDuration = (uint32_t)(inputTimeStamp - mLastTimestamp);
} else {
// Use default of 30 fps in case of 0 frame rate.
- uint32_t framerate = mFrameRate->value + 0.5 ?: 30;
- frameDuration = (uint32_t)((uint64_t)1000000 / framerate);
+ float frameRate = mFrameRate->value;
+ if (frameRate < 0.001) {
+ frameRate = 30;
+ }
+ frameDuration = (uint32_t)(1000000 / frameRate + 0.5);
}
mLastTimestamp = inputTimeStamp;
diff --git a/media/codecs/vpx/C2SoftVpxEnc.h b/media/codecs/vpx/C2SoftVpxEnc.h
index 806b7ee..6d175f1 100644
--- a/media/codecs/vpx/C2SoftVpxEnc.h
+++ b/media/codecs/vpx/C2SoftVpxEnc.h
@@ -307,14 +307,8 @@
addParameter(
DefineParam(mIntraRefresh, C2_PARAMKEY_INTRA_REFRESH)
- .withDefault(new C2StreamIntraRefreshTuning::output(
- 0u, C2Config::INTRA_REFRESH_DISABLED, 0.))
- .withFields({
- C2F(mIntraRefresh, mode).oneOf({
- C2Config::INTRA_REFRESH_DISABLED, C2Config::INTRA_REFRESH_ARBITRARY }),
- C2F(mIntraRefresh, period).any()
- })
- .withSetter(IntraRefreshSetter)
+ .withConstValue(new C2StreamIntraRefreshTuning::output(
+ 0u, C2Config::INTRA_REFRESH_DISABLED, 0.))
.build());
addParameter(
@@ -376,20 +370,6 @@
return C2R::Ok();
}
- static C2R IntraRefreshSetter(bool mayBlock, C2P<C2StreamIntraRefreshTuning::output> &me) {
- (void)mayBlock;
- C2R res = C2R::Ok();
- if (me.v.period < 1) {
- me.set().mode = C2Config::INTRA_REFRESH_DISABLED;
- me.set().period = 0;
- } else {
- // only support arbitrary mode (cyclic in our case)
- me.set().mode = C2Config::INTRA_REFRESH_ARBITRARY;
- }
- return res;
- }
-
-
static C2R LayeringSetter(bool mayBlock, C2P<C2StreamTemporalLayeringTuning::output>& me) {
(void)mayBlock;
C2R res = C2R::Ok();