C2SoftVpxEnc: Correct minimum level setting code
When the encoder is given a level lower than required for the
current configuration, plugin wasn't setting it correctly.
Bug: 151430764
Test: Uncomment the parameter for VP9 in the CTS test
atest android.mediav2.cts.EncoderProfileLevelTest
Change-Id: I123c8d00b6b09858b732d1f741cf92e241067a79
diff --git a/media/codec2/components/vpx/C2SoftVpxEnc.cpp b/media/codec2/components/vpx/C2SoftVpxEnc.cpp
index 2a019d4..5700e5d 100644
--- a/media/codec2/components/vpx/C2SoftVpxEnc.cpp
+++ b/media/codec2/components/vpx/C2SoftVpxEnc.cpp
@@ -264,23 +264,20 @@
// the requirements.
bool needsUpdate = false;
for (const LevelLimits& limit : kLimits) {
- if (samples > limit.samples) continue;
- if (samplesPerSec > limit.samplesPerSec) continue;
- if (bitrate.v.value > limit.bitrate) continue;
- if (dimension > limit.dimension) continue;
-
- // This is the lowest level that meets the requirements, and if
- // we haven't seen the supplied level yet, that means we don't
- // need the update.
- if (needsUpdate) {
- ALOGD("Given level %x does not cover current configuration: "
- "adjusting to %x",
- me.v.level, limit.level);
- me.set().level = limit.level;
+ if (samples <= limit.samples && samplesPerSec <= limit.samplesPerSec &&
+ bitrate.v.value <= limit.bitrate && dimension <= limit.dimension) {
+ // This is the lowest level that meets the requirements, and if
+ // we haven't seen the supplied level yet, that means we don't
+ // need the update.
+ if (needsUpdate) {
+ ALOGD("Given level %x does not cover current configuration: "
+ "adjusting to %x",
+ me.v.level, limit.level);
+ me.set().level = limit.level;
+ }
+ found = true;
+ break;
}
- found = true;
- break;
-
if (me.v.level == limit.level) {
// We break out of the loop when the lowest feasible level is
// found. The fact that we're here means that our level doesn't