зеркало из https://github.com/mozilla/gecko-dev.git
Bug 834150 - Just Say No to the fallback SW decoder. r=doublec, a=tef+
This commit is contained in:
Родитель
74524acb8a
Коммит
737ae90723
|
@ -230,53 +230,42 @@ bool OmxDecoder::Init() {
|
|||
sp<MediaSource> videoTrack;
|
||||
sp<MediaSource> videoSource;
|
||||
if (videoTrackIndex != -1 && (videoTrack = extractor->getTrack(videoTrackIndex)) != nullptr) {
|
||||
int flags = 0; // prefer hw codecs
|
||||
|
||||
// XXX is this called off the main thread?
|
||||
if (mozilla::Preferences::GetBool("media.omx.prefer_software_codecs", false)) {
|
||||
flags |= kPreferSoftwareCodecs;
|
||||
// Experience with OMX codecs is that only the HW decoders are
|
||||
// worth bothering with, at least on the platforms where this code
|
||||
// is currently used, and for formats this code is currently used
|
||||
// for (h.264). So if we don't get a hardware decoder, just give
|
||||
// up.
|
||||
int flags = kHardwareCodecsOnly;
|
||||
videoSource = OMXCodec::Create(GetOMX(),
|
||||
videoTrack->getFormat(),
|
||||
false, // decoder
|
||||
videoTrack,
|
||||
nullptr,
|
||||
flags,
|
||||
mNativeWindow);
|
||||
if (videoSource == nullptr) {
|
||||
NS_WARNING("Couldn't create OMX video source");
|
||||
return false;
|
||||
}
|
||||
|
||||
do {
|
||||
videoSource = OMXCodec::Create(GetOMX(),
|
||||
videoTrack->getFormat(),
|
||||
false, // decoder
|
||||
videoTrack,
|
||||
nullptr,
|
||||
flags,
|
||||
mNativeWindow);
|
||||
if (videoSource == nullptr) {
|
||||
NS_WARNING("Couldn't create OMX video source");
|
||||
return false;
|
||||
}
|
||||
// Check if this video is sized such that we're comfortable
|
||||
// possibly using an OMX decoder.
|
||||
int32_t maxWidth, maxHeight;
|
||||
char propValue[PROPERTY_VALUE_MAX];
|
||||
property_get("ro.moz.omx.hw.max_width", propValue, "-1");
|
||||
maxWidth = atoi(propValue);
|
||||
property_get("ro.moz.omx.hw.max_height", propValue, "-1");
|
||||
maxHeight = atoi(propValue);
|
||||
|
||||
if (flags & kSoftwareCodecsOnly) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Check if this video is sized such that we're comfortable
|
||||
// possibly using a hardware decoder. If we can't get the size,
|
||||
// fall back on SW to be safe.
|
||||
int32_t maxWidth, maxHeight;
|
||||
char propValue[PROPERTY_VALUE_MAX];
|
||||
property_get("ro.moz.omx.hw.max_width", propValue, "-1");
|
||||
maxWidth = atoi(propValue);
|
||||
property_get("ro.moz.omx.hw.max_height", propValue, "-1");
|
||||
maxHeight = atoi(propValue);
|
||||
|
||||
int32_t width = -1, height = -1;
|
||||
if (maxWidth > 0 && maxHeight > 0 &&
|
||||
!(videoSource->getFormat()->findInt32(kKeyWidth, &width) &&
|
||||
videoSource->getFormat()->findInt32(kKeyHeight, &height) &&
|
||||
width * height <= maxWidth * maxHeight)) {
|
||||
printf_stderr("Failed to get video size, or it was too large for HW decoder (<w=%d, h=%d> but <maxW=%d, maxH=%d>)",
|
||||
width, height, maxWidth, maxHeight);
|
||||
videoSource.clear();
|
||||
flags |= kSoftwareCodecsOnly;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
} while(true);
|
||||
int32_t width = -1, height = -1;
|
||||
if (maxWidth > 0 && maxHeight > 0 &&
|
||||
!(videoSource->getFormat()->findInt32(kKeyWidth, &width) &&
|
||||
videoSource->getFormat()->findInt32(kKeyHeight, &height) &&
|
||||
width * height <= maxWidth * maxHeight)) {
|
||||
printf_stderr("Failed to get video size, or it was too large for HW decoder (<w=%d, h=%d> but <maxW=%d, maxH=%d>)",
|
||||
width, height, maxWidth, maxHeight);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (videoSource->start() != OK) {
|
||||
NS_WARNING("Couldn't start OMX video source");
|
||||
|
|
Загрузка…
Ссылка в новой задаче