diff options
author | James Dong <jdong@google.com> | 2011-07-14 09:59:24 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-07-14 09:59:24 -0700 |
commit | ad07457ece56ba710d3a0334eb8e711646c7141a (patch) | |
tree | ee9c0ae0e03fe26b28aa7c68059179330f3bc0e7 | |
parent | 840a02c3da40934bd3b4ab023d6d92f7161c6f4b (diff) | |
parent | fbb170ca9cbbd0c87c71ac39ecbb36086bca5ee2 (diff) | |
download | frameworks_base-ad07457ece56ba710d3a0334eb8e711646c7141a.zip frameworks_base-ad07457ece56ba710d3a0334eb8e711646c7141a.tar.gz frameworks_base-ad07457ece56ba710d3a0334eb8e711646c7141a.tar.bz2 |
Merge "Support profile and level query for SW video decoders"
-rw-r--r-- | include/media/IOMX.h | 5 | ||||
-rw-r--r-- | include/media/stagefright/OMXCodec.h | 5 | ||||
-rw-r--r-- | media/libstagefright/codecs/avc/dec/SoftAVC.cpp | 30 | ||||
-rw-r--r-- | media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp | 53 | ||||
-rw-r--r-- | media/libstagefright/codecs/on2/h264dec/SoftAVC.cpp | 42 |
5 files changed, 130 insertions, 5 deletions
diff --git a/include/media/IOMX.h b/include/media/IOMX.h index 3c65147..02ad703 100644 --- a/include/media/IOMX.h +++ b/include/media/IOMX.h @@ -184,6 +184,11 @@ public: uint32_t flags = 0); }; +struct CodecProfileLevel { + OMX_U32 mProfile; + OMX_U32 mLevel; +}; + } // namespace android #endif // ANDROID_IOMX_H_ diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h index 7f3c497..a042ddb 100644 --- a/include/media/stagefright/OMXCodec.h +++ b/include/media/stagefright/OMXCodec.h @@ -336,11 +336,6 @@ private: OMXCodec &operator=(const OMXCodec &); }; -struct CodecProfileLevel { - OMX_U32 mProfile; - OMX_U32 mLevel; -}; - struct CodecCapabilities { String8 mComponentName; Vector<CodecProfileLevel> mProfileLevels; diff --git a/media/libstagefright/codecs/avc/dec/SoftAVC.cpp b/media/libstagefright/codecs/avc/dec/SoftAVC.cpp index 9f141ac..6a476f6 100644 --- a/media/libstagefright/codecs/avc/dec/SoftAVC.cpp +++ b/media/libstagefright/codecs/avc/dec/SoftAVC.cpp @@ -23,6 +23,7 @@ #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/MediaDefs.h> #include <media/stagefright/MediaErrors.h> +#include <media/IOMX.h> #include "avcdec_api.h" #include "avcdec_int.h" @@ -31,6 +32,13 @@ namespace android { static const char kStartCode[4] = { 0x00, 0x00, 0x00, 0x01 }; +static const CodecProfileLevel kProfileLevels[] = { + { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel1 }, + { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel1b }, + { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel11 }, + { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel12 }, +}; + template<class T> static void InitOMXParams(T *params) { params->nSize = sizeof(T); @@ -181,6 +189,28 @@ OMX_ERRORTYPE SoftAVC::internalGetParameter( return OMX_ErrorNone; } + case OMX_IndexParamVideoProfileLevelQuerySupported: + { + OMX_VIDEO_PARAM_PROFILELEVELTYPE *profileLevel = + (OMX_VIDEO_PARAM_PROFILELEVELTYPE *) params; + + if (profileLevel->nPortIndex != 0) { // Input port only + LOGE("Invalid port index: %ld", profileLevel->nPortIndex); + return OMX_ErrorUnsupportedIndex; + } + + size_t index = profileLevel->nProfileIndex; + size_t nProfileLevels = + sizeof(kProfileLevels) / sizeof(kProfileLevels[0]); + if (index >= nProfileLevels) { + return OMX_ErrorNoMore; + } + + profileLevel->eProfile = kProfileLevels[index].mProfile; + profileLevel->eLevel = kProfileLevels[index].mLevel; + return OMX_ErrorNone; + } + default: return SimpleSoftOMXComponent::internalGetParameter(index, params); } diff --git a/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp b/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp index cffbfb5..ddced5f 100644 --- a/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp +++ b/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp @@ -23,11 +23,31 @@ #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/MediaDefs.h> #include <media/stagefright/MediaErrors.h> +#include <media/IOMX.h> #include "mp4dec_api.h" namespace android { +static const CodecProfileLevel kM4VProfileLevels[] = { + { OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level0 }, + { OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level0b }, + { OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level1 }, + { OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level2 }, + { OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level3 }, +}; + +static const CodecProfileLevel kH263ProfileLevels[] = { + { OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level10 }, + { OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level20 }, + { OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level30 }, + { OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level45 }, + { OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level10 }, + { OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level20 }, + { OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level30 }, + { OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level45 }, +}; + template<class T> static void InitOMXParams(T *params) { params->nSize = sizeof(T); @@ -181,6 +201,39 @@ OMX_ERRORTYPE SoftMPEG4::internalGetParameter( return OMX_ErrorNone; } + case OMX_IndexParamVideoProfileLevelQuerySupported: + { + OMX_VIDEO_PARAM_PROFILELEVELTYPE *profileLevel = + (OMX_VIDEO_PARAM_PROFILELEVELTYPE *) params; + + if (profileLevel->nPortIndex != 0) { // Input port only + LOGE("Invalid port index: %ld", profileLevel->nPortIndex); + return OMX_ErrorUnsupportedIndex; + } + + size_t index = profileLevel->nProfileIndex; + if (mMode == MODE_H263) { + size_t nProfileLevels = + sizeof(kH263ProfileLevels) / sizeof(kH263ProfileLevels[0]); + if (index >= nProfileLevels) { + return OMX_ErrorNoMore; + } + + profileLevel->eProfile = kH263ProfileLevels[index].mProfile; + profileLevel->eLevel = kH263ProfileLevels[index].mLevel; + } else { + size_t nProfileLevels = + sizeof(kM4VProfileLevels) / sizeof(kM4VProfileLevels[0]); + if (index >= nProfileLevels) { + return OMX_ErrorNoMore; + } + + profileLevel->eProfile = kM4VProfileLevels[index].mProfile; + profileLevel->eLevel = kM4VProfileLevels[index].mLevel; + } + return OMX_ErrorNone; + } + default: return SimpleSoftOMXComponent::internalGetParameter(index, params); } diff --git a/media/libstagefright/codecs/on2/h264dec/SoftAVC.cpp b/media/libstagefright/codecs/on2/h264dec/SoftAVC.cpp index ec7bd1c..740c957 100644 --- a/media/libstagefright/codecs/on2/h264dec/SoftAVC.cpp +++ b/media/libstagefright/codecs/on2/h264dec/SoftAVC.cpp @@ -23,10 +23,30 @@ #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/MediaDefs.h> #include <media/stagefright/MediaErrors.h> +#include <media/IOMX.h> namespace android { +static const CodecProfileLevel kProfileLevels[] = { + { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel1 }, + { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel1b }, + { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel11 }, + { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel12 }, + { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel13 }, + { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel2 }, + { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel21 }, + { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel22 }, + { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel3 }, + { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel31 }, + { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel32 }, + { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel4 }, + { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel41 }, + { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel42 }, + { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel5 }, + { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel51 }, +}; + template<class T> static void InitOMXParams(T *params) { params->nSize = sizeof(T); @@ -177,6 +197,28 @@ OMX_ERRORTYPE SoftAVC::internalGetParameter( return OMX_ErrorNone; } + case OMX_IndexParamVideoProfileLevelQuerySupported: + { + OMX_VIDEO_PARAM_PROFILELEVELTYPE *profileLevel = + (OMX_VIDEO_PARAM_PROFILELEVELTYPE *) params; + + if (profileLevel->nPortIndex != kInputPortIndex) { + LOGE("Invalid port index: %ld", profileLevel->nPortIndex); + return OMX_ErrorUnsupportedIndex; + } + + size_t index = profileLevel->nProfileIndex; + size_t nProfileLevels = + sizeof(kProfileLevels) / sizeof(kProfileLevels[0]); + if (index >= nProfileLevels) { + return OMX_ErrorNoMore; + } + + profileLevel->eProfile = kProfileLevels[index].mProfile; + profileLevel->eLevel = kProfileLevels[index].mLevel; + return OMX_ErrorNone; + } + default: return SimpleSoftOMXComponent::internalGetParameter(index, params); } |