Loading media/libmediaformatshaper/VQApply.cpp +30 −7 Original line number Diff line number Diff line Loading @@ -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()); Loading Loading @@ -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; Loading Loading
media/libmediaformatshaper/VQApply.cpp +30 −7 Original line number Diff line number Diff line Loading @@ -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()); Loading Loading @@ -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; Loading