Loading media/libmediaformatshaper/CodecProperties.cpp +23 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,13 @@ void CodecProperties::setTargetQpMax(int qpMax) { mTargetQpMax = qpMax; } void CodecProperties::setMissingQpBoost(double boost) { mMissingQpBoost = boost; } void CodecProperties::setPhaseOut(double phaseout) { mPhaseOut = phaseout; } // what API is this codec set up for (e.g. API of the associated partition) // vendor-side (OEM) codecs may be older, due to 'vendor freeze' and treble int CodecProperties::supportedApi() { Loading Loading @@ -134,6 +141,22 @@ void CodecProperties::setTuningValue(std::string key, std::string value) { setBpp(bpp); legal = true; } } else if (!strcmp(key.c_str(), "vq-bitrate-phaseout")) { const char *p = value.c_str(); char *q; double phaseout = strtod(p, &q); if (q != p) { setPhaseOut(phaseout); legal = true; } } else if (!strcmp(key.c_str(), "vq-boost-missing-qp")) { const char *p = value.c_str(); char *q; double boost = strtod(p, &q); if (q != p) { setMissingQpBoost(boost); legal = true; } } else { legal = true; } Loading media/libmediaformatshaper/CodecProperties.h +13 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,14 @@ class CodecProperties { void setSupportsQp(bool supported) { mSupportsQp = supported;} bool supportsQp() { return mSupportsQp;} // defines our range of operation -- multiplier on the floor bitrate double getPhaseOut() { return mPhaseOut; } void setPhaseOut(double overageMultiplier); // how much (0.20 = +20%) do we add if Qp is requested but unsupported double getMissingQpBoost() {return mMissingQpBoost; } void setMissingQpBoost(double boost); int supportedApi(); // a codec is not usable until it has been registered with its Loading @@ -98,6 +106,11 @@ class CodecProperties { bool mSupportsQp = false; double mBpp = 0.0; // target bitrates above floor * mPhaseOut are left untouched double mPhaseOut = 1.75; // 20% bump if QP is configured but it is unavailable double mMissingQpBoost = 0.20; // allow different target bits-per-pixel based on resolution // similar to codec 'performance points' // uses 'next largest' (by pixel count) point as minimum bpp Loading media/libmediaformatshaper/CodecSeeding.cpp +9 −6 Original line number Diff line number Diff line Loading @@ -49,25 +49,28 @@ typedef struct { */ static preloadTuning_t featuresAvc[] = { // {true, "vq-target-bpp", "2.45"}, {true, "vq-target-bpp-1080p", "2.40"}, {true, "vq-target-bpp-540p", "2.60"}, {true, "vq-target-bpp-1080p", "1.90"}, {true, "vq-target-bpp-720p", "2.25"}, {true, "vq-target-bpp-540p", "2.65"}, {true, "vq-target-bpp-480p", "3.00"}, {true, "vq-target-qpmax", "40"}, {true, "vq-bitrate-phaseout", "1.75"}, {true, "vq-boost-missing-qp", "0.20"}, {true, nullptr, 0} }; static preloadTuning_t featuresHevc[] = { // {true, "vq-target-bpp", "1.80"}, {true, "vq-target-bpp-1080p", "1.50"}, {true, "vq-target-bpp-720p", "1.80"}, {true, "vq-target-bpp-540p", "2.10"}, // no qp for hevc, at least for now {true, "vq-target-qpmax", "40"}, {true, "vq-bitrate-phaseout", "1.75"}, {true, "vq-boost-missing-qp", "0.20"}, {true, nullptr, 0} }; static preloadTuning_t featuresGenericVideo[] = { {true, "vq-target-bpp", "2.40"}, {true, "vq-target-bpp", "2.00"}, {true, nullptr, 0} }; Loading media/libmediaformatshaper/VQApply.cpp +3 −12 Original line number Diff line number Diff line Loading @@ -49,14 +49,6 @@ namespace mediaformatshaper { static const int BITRATE_MODE_VBR = 1; // constants we use within the calculations // constexpr double BITRATE_LEAVE_UNTOUCHED = 1.75; // 20% bump if QP is configured but it is unavailable constexpr double BITRATE_QP_UNAVAILABLE_BOOST = 0.20; // // Caller retains ownership of and responsibility for inFormat // Loading Loading @@ -100,7 +92,7 @@ int VQApply(CodecProperties *codec, vqOps_t *info, AMediaFormat* inFormat, int f double minimumBpp = codec->getBpp(width, height); int64_t bitrateFloor = pixels * minimumBpp; int64_t bitrateCeiling = bitrateFloor * BITRATE_LEAVE_UNTOUCHED; int64_t bitrateCeiling = bitrateFloor * codec->getPhaseOut(); if (bitrateFloor > INT32_MAX) bitrateFloor = INT32_MAX; if (bitrateCeiling > INT32_MAX) bitrateCeiling = INT32_MAX; Loading Loading @@ -144,8 +136,7 @@ int VQApply(CodecProperties *codec, vqOps_t *info, AMediaFormat* inFormat, int f // if QP is desired but not supported, compensate with additional bits if (!codec->supportsQp()) { if (qpChosen != INT32_MAX) { int64_t boost = 0; boost = bitrateChosen * BITRATE_QP_UNAVAILABLE_BOOST; int64_t boost = bitrateChosen * codec->getMissingQpBoost(); ALOGD("minquality: requested QP unsupported, boost bitrate %" PRId64 " by %" PRId64, bitrateChosen, boost); bitrateChosen = bitrateChosen + boost; Loading @@ -165,7 +156,7 @@ int VQApply(CodecProperties *codec, vqOps_t *info, AMediaFormat* inFormat, int f if (bitrateChosen != bitrateConfigured) { if (bitrateChosen > bitrateCeiling) { ALOGD("minquality: bitrate clamped at ceiling %" PRId64, bitrateCeiling); ALOGD("minquality: bitrate increase clamped at ceiling %" PRId64, bitrateCeiling); bitrateChosen = bitrateCeiling; } ALOGD("minquality/target bitrate raised from %" PRId64 " to %" PRId64 " bps", Loading Loading
media/libmediaformatshaper/CodecProperties.cpp +23 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,13 @@ void CodecProperties::setTargetQpMax(int qpMax) { mTargetQpMax = qpMax; } void CodecProperties::setMissingQpBoost(double boost) { mMissingQpBoost = boost; } void CodecProperties::setPhaseOut(double phaseout) { mPhaseOut = phaseout; } // what API is this codec set up for (e.g. API of the associated partition) // vendor-side (OEM) codecs may be older, due to 'vendor freeze' and treble int CodecProperties::supportedApi() { Loading Loading @@ -134,6 +141,22 @@ void CodecProperties::setTuningValue(std::string key, std::string value) { setBpp(bpp); legal = true; } } else if (!strcmp(key.c_str(), "vq-bitrate-phaseout")) { const char *p = value.c_str(); char *q; double phaseout = strtod(p, &q); if (q != p) { setPhaseOut(phaseout); legal = true; } } else if (!strcmp(key.c_str(), "vq-boost-missing-qp")) { const char *p = value.c_str(); char *q; double boost = strtod(p, &q); if (q != p) { setMissingQpBoost(boost); legal = true; } } else { legal = true; } Loading
media/libmediaformatshaper/CodecProperties.h +13 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,14 @@ class CodecProperties { void setSupportsQp(bool supported) { mSupportsQp = supported;} bool supportsQp() { return mSupportsQp;} // defines our range of operation -- multiplier on the floor bitrate double getPhaseOut() { return mPhaseOut; } void setPhaseOut(double overageMultiplier); // how much (0.20 = +20%) do we add if Qp is requested but unsupported double getMissingQpBoost() {return mMissingQpBoost; } void setMissingQpBoost(double boost); int supportedApi(); // a codec is not usable until it has been registered with its Loading @@ -98,6 +106,11 @@ class CodecProperties { bool mSupportsQp = false; double mBpp = 0.0; // target bitrates above floor * mPhaseOut are left untouched double mPhaseOut = 1.75; // 20% bump if QP is configured but it is unavailable double mMissingQpBoost = 0.20; // allow different target bits-per-pixel based on resolution // similar to codec 'performance points' // uses 'next largest' (by pixel count) point as minimum bpp Loading
media/libmediaformatshaper/CodecSeeding.cpp +9 −6 Original line number Diff line number Diff line Loading @@ -49,25 +49,28 @@ typedef struct { */ static preloadTuning_t featuresAvc[] = { // {true, "vq-target-bpp", "2.45"}, {true, "vq-target-bpp-1080p", "2.40"}, {true, "vq-target-bpp-540p", "2.60"}, {true, "vq-target-bpp-1080p", "1.90"}, {true, "vq-target-bpp-720p", "2.25"}, {true, "vq-target-bpp-540p", "2.65"}, {true, "vq-target-bpp-480p", "3.00"}, {true, "vq-target-qpmax", "40"}, {true, "vq-bitrate-phaseout", "1.75"}, {true, "vq-boost-missing-qp", "0.20"}, {true, nullptr, 0} }; static preloadTuning_t featuresHevc[] = { // {true, "vq-target-bpp", "1.80"}, {true, "vq-target-bpp-1080p", "1.50"}, {true, "vq-target-bpp-720p", "1.80"}, {true, "vq-target-bpp-540p", "2.10"}, // no qp for hevc, at least for now {true, "vq-target-qpmax", "40"}, {true, "vq-bitrate-phaseout", "1.75"}, {true, "vq-boost-missing-qp", "0.20"}, {true, nullptr, 0} }; static preloadTuning_t featuresGenericVideo[] = { {true, "vq-target-bpp", "2.40"}, {true, "vq-target-bpp", "2.00"}, {true, nullptr, 0} }; Loading
media/libmediaformatshaper/VQApply.cpp +3 −12 Original line number Diff line number Diff line Loading @@ -49,14 +49,6 @@ namespace mediaformatshaper { static const int BITRATE_MODE_VBR = 1; // constants we use within the calculations // constexpr double BITRATE_LEAVE_UNTOUCHED = 1.75; // 20% bump if QP is configured but it is unavailable constexpr double BITRATE_QP_UNAVAILABLE_BOOST = 0.20; // // Caller retains ownership of and responsibility for inFormat // Loading Loading @@ -100,7 +92,7 @@ int VQApply(CodecProperties *codec, vqOps_t *info, AMediaFormat* inFormat, int f double minimumBpp = codec->getBpp(width, height); int64_t bitrateFloor = pixels * minimumBpp; int64_t bitrateCeiling = bitrateFloor * BITRATE_LEAVE_UNTOUCHED; int64_t bitrateCeiling = bitrateFloor * codec->getPhaseOut(); if (bitrateFloor > INT32_MAX) bitrateFloor = INT32_MAX; if (bitrateCeiling > INT32_MAX) bitrateCeiling = INT32_MAX; Loading Loading @@ -144,8 +136,7 @@ int VQApply(CodecProperties *codec, vqOps_t *info, AMediaFormat* inFormat, int f // if QP is desired but not supported, compensate with additional bits if (!codec->supportsQp()) { if (qpChosen != INT32_MAX) { int64_t boost = 0; boost = bitrateChosen * BITRATE_QP_UNAVAILABLE_BOOST; int64_t boost = bitrateChosen * codec->getMissingQpBoost(); ALOGD("minquality: requested QP unsupported, boost bitrate %" PRId64 " by %" PRId64, bitrateChosen, boost); bitrateChosen = bitrateChosen + boost; Loading @@ -165,7 +156,7 @@ int VQApply(CodecProperties *codec, vqOps_t *info, AMediaFormat* inFormat, int f if (bitrateChosen != bitrateConfigured) { if (bitrateChosen > bitrateCeiling) { ALOGD("minquality: bitrate clamped at ceiling %" PRId64, bitrateCeiling); ALOGD("minquality: bitrate increase clamped at ceiling %" PRId64, bitrateCeiling); bitrateChosen = bitrateCeiling; } ALOGD("minquality/target bitrate raised from %" PRId64 " to %" PRId64 " bps", Loading