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

Commit 8430448d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "restrict sizes shaped (and requests to codec to shape)" into sc-dev am: 0ff42938

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/av/+/15192057

Change-Id: I3452de71912d2bd8b5910d305b54b377c74fd545
parents b5c47906 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;