Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d336e05d authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 7521311 from 0ff42938 to sc-release

Change-Id: I638b5015f35c44bbc4bfa66b1aa4f885c5f2eaa0
parents 5eff9d69 0ff42938
Loading
Loading
Loading
Loading
+30 −7
Original line number Diff line number Diff line
@@ -71,14 +71,40 @@ int VQApply(CodecProperties *codec, vqOps_t *info, AMediaFormat* inFormat, int f
    //
    int32_t isVQEligible = 0;
    (void) codec->getFeatureValue("_vq_eligible.device", &isVQEligible);
    ALOGD("minquality:  are we eligible: %d", isVQEligible);
    if (!isVQEligible) {
        ALOGD("minquality: not an eligible device class");
        return 0;
    }

    // look at resolution to determine if we want any shaping/modification at all.
    //
    // we currently only shape (or ask the underlying codec to shape) for
    // resolution range  320x240 < target <= 1920x1080
    // NB: the < vs <=, that is deliberate.
    //

    int32_t width = 0;
    (void) AMediaFormat_getInt32(inFormat, AMEDIAFORMAT_KEY_WIDTH, &width);
    int32_t height = 0;
    (void) AMediaFormat_getInt32(inFormat, AMEDIAFORMAT_KEY_HEIGHT, &height);
    int64_t pixels = ((int64_t)width) * height;

    bool eligibleSize = true;
    if (pixels <= 320 * 240) {
        eligibleSize = false;
    } else if (pixels > 1920 * 1088) {
        eligibleSize = false;
    }

    if (!eligibleSize) {
        // we won't shape, and ask that the codec not shape
        ALOGD("minquality: %dx%d outside of shaping range", width, height);
        AMediaFormat_setInt32(inFormat, "android._encoding-quality-level", 0);
        return 0;
    }

    if (codec->supportedMinimumQuality() > 0) {
        // allow the codec provided minimum quality behavior to work at it
        // have the codec-provided minimum quality behavior to work at it
        ALOGD("minquality: codec claims to implement minquality=%d",
              codec->supportedMinimumQuality());

@@ -107,11 +133,8 @@ int VQApply(CodecProperties *codec, vqOps_t *info, AMediaFormat* inFormat, int f
    bitrateConfigured = bitrateConfiguredTmp;
    bitrateChosen = bitrateConfigured;

    int32_t width = 0;
    (void) AMediaFormat_getInt32(inFormat, AMEDIAFORMAT_KEY_WIDTH, &width);
    int32_t height = 0;
    (void) AMediaFormat_getInt32(inFormat, AMEDIAFORMAT_KEY_HEIGHT, &height);
    int64_t pixels = ((int64_t)width) * height;
    // width, height, and pixels are calculated above

    double minimumBpp = codec->getBpp(width, height);

    int64_t bitrateFloor = pixels * minimumBpp;