/** * Look for a decoder that supports a colour format that we support. */ static bool FindPreferredDecoderAndColorFormat(const sp<IOMX>& aOmx, char *aDecoderName, size_t aDecoderLen, OMX_COLOR_FORMATTYPE *aColorFormat) { Vector<CodecCapabilities> codecs; // Get all AVC decoder/colour format pairs that this device supports. QueryCodecs(aOmx, AVC_MIME_TYPE, true /* queryDecoders */, &codecs); // We assume that faster (hardware accelerated) decoders come first in the // list, so we choose the first decoder with a colour format we can use. for (uint32_t i = 0; i < codecs.size(); i++) { const CodecCapabilities &caps = codecs[i]; const Vector<OMX_U32> &colors = caps.mColorFormats; bool found = false; for (uint32_t j = 0; j < colors.size(); j++) { OMX_COLOR_FORMATTYPE color = (OMX_COLOR_FORMATTYPE)colors[j]; LOG("Decoder %s can output colour format %#x.\n", caps.mComponentName.string(), color); ColorFormatSupport supported = IsColorFormatSupported(color); if (supported) { strncpy(aDecoderName, caps.mComponentName.string(), aDecoderLen); *aColorFormat = color; found = true; } if (supported == ColorFormatSupportPreferred) { // The colour format is natively supported -- that's as good as we're // going to get. break; } } if (found) { return true; } } return false; }
static bool isYUV420PlanarSupported( OMXClient *client, const sp<MetaData> &trackMeta) { const char *mime; CHECK(trackMeta->findCString(kKeyMIMEType, &mime)); Vector<CodecCapabilities> caps; if (QueryCodecs(client->interface(), mime, true, /* queryDecoders */ true, /* hwCodecOnly */ &caps) == OK) { for (size_t j = 0; j < caps.size(); ++j) { CodecCapabilities cap = caps[j]; for (size_t i = 0; i < cap.mColorFormats.size(); ++i) { if (cap.mColorFormats[i] == OMX_COLOR_FormatYUV420Planar) { return true; } } } } return false; }