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

Commit e2faa808 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "C2SoftAvcEnc: More QP bounding interface work" am: fd4ce6af am: 73f82f32 am: 6053f70a

parents 31cb5c00 6053f70a
Loading
Loading
Loading
Loading
+12 −10
Original line number Diff line number Diff line
@@ -392,9 +392,9 @@ public:
    static C2R PictureQuantizationSetter(bool mayBlock,
                                         C2P<C2StreamPictureQuantizationTuning::output> &me) {
        (void)mayBlock;
        (void)me;

        // TODO: refactor with same algorithm in the SetQp()
        // these are the ones we're going to set, so want them to default
        // to the DEFAULT values for the codec
        int32_t iMin = DEFAULT_I_QP_MIN, pMin = DEFAULT_P_QP_MIN, bMin = DEFAULT_B_QP_MIN;
        int32_t iMax = DEFAULT_I_QP_MAX, pMax = DEFAULT_P_QP_MAX, bMax = DEFAULT_B_QP_MAX;

@@ -419,13 +419,14 @@ public:
        ALOGV("PictureQuantizationSetter(entry): i %d-%d p %d-%d b %d-%d",
              iMin, iMax, pMin, pMax, bMin, bMax);

        // ensure we have legal values
        iMax = std::clamp(iMax, CODEC_QP_MIN, CODEC_QP_MAX);
        iMin = std::clamp(iMin, CODEC_QP_MIN, CODEC_QP_MAX);
        pMax = std::clamp(pMax, CODEC_QP_MIN, CODEC_QP_MAX);
        pMin = std::clamp(pMin, CODEC_QP_MIN, CODEC_QP_MAX);
        bMax = std::clamp(bMax, CODEC_QP_MIN, CODEC_QP_MAX);
        bMin = std::clamp(bMin, CODEC_QP_MIN, CODEC_QP_MAX);
        // min is clamped to [AVC_QP_MIN, max] to avoid error
        // cases where layer.min > layer.max
        iMax = std::clamp(iMax, AVC_QP_MIN, AVC_QP_MAX);
        iMin = std::clamp(iMin, AVC_QP_MIN, iMax);
        pMax = std::clamp(pMax, AVC_QP_MIN, AVC_QP_MAX);
        pMin = std::clamp(pMin, AVC_QP_MIN, pMax);
        bMax = std::clamp(bMax, AVC_QP_MIN, AVC_QP_MAX);
        bMin = std::clamp(bMin, AVC_QP_MIN, bMax);

        // put them back into the structure
        for (size_t i = 0; i < me.v.flexCount(); ++i) {
@@ -819,7 +820,8 @@ c2_status_t C2SoftAvcEnc::setQp() {
    s_qp_ip.e_cmd = IVE_CMD_VIDEO_CTL;
    s_qp_ip.e_sub_cmd = IVE_CMD_CTL_SET_QP;

    // TODO: refactor with same algorithm in the PictureQuantizationSetter()
    // we resolved out-of-bound and unspecified values in PictureQuantizationSetter()
    // so we can start with defaults that are overridden as needed.
    int32_t iMin = DEFAULT_I_QP_MIN, pMin = DEFAULT_P_QP_MIN, bMin = DEFAULT_B_QP_MIN;
    int32_t iMax = DEFAULT_I_QP_MAX, pMax = DEFAULT_P_QP_MAX, bMax = DEFAULT_B_QP_MAX;

+2 −2
Original line number Diff line number Diff line
@@ -103,8 +103,8 @@ namespace android {
/** limits as specified by h264
 *  (QP_MIN==4 is actually a limitation of this SW codec, not the H.264 standard)
 **/
#define CODEC_QP_MIN                4
#define CODEC_QP_MAX                51
#define AVC_QP_MIN                4
#define AVC_QP_MAX                51


#define MIN(a, b) ((a) < (b))? (a) : (b)