summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/FFMPEGSoftCodec.cpp
diff options
context:
space:
mode:
authorSteve Kondik <steve@cyngn.com>2015-12-26 22:07:56 -0800
committerSteve Kondik <shade@chemlab.org>2015-12-28 02:13:17 -0800
commit1bb6c3edfea2a8b961e9550bd02a1e0e3d79db22 (patch)
tree05415e70d1fe311af426274fce027422cef00bc1 /media/libstagefright/FFMPEGSoftCodec.cpp
parent1b5f480d61432ab5aeb090f96823ed59dbc727bc (diff)
downloadframeworks_av-1bb6c3edfea2a8b961e9550bd02a1e0e3d79db22.zip
frameworks_av-1bb6c3edfea2a8b961e9550bd02a1e0e3d79db22.tar.gz
frameworks_av-1bb6c3edfea2a8b961e9550bd02a1e0e3d79db22.tar.bz2
stagefright: Add more hardware codec support for our extractor
* Additional cases for timestamp reordering (smooth out AVI playback) * Enable hardware thumbnailer Change-Id: If828181850a5627dc1f91b118974905d22ab24e9
Diffstat (limited to 'media/libstagefright/FFMPEGSoftCodec.cpp')
-rw-r--r--media/libstagefright/FFMPEGSoftCodec.cpp127
1 files changed, 88 insertions, 39 deletions
diff --git a/media/libstagefright/FFMPEGSoftCodec.cpp b/media/libstagefright/FFMPEGSoftCodec.cpp
index 9d72609..26afd89 100644
--- a/media/libstagefright/FFMPEGSoftCodec.cpp
+++ b/media/libstagefright/FFMPEGSoftCodec.cpp
@@ -254,56 +254,63 @@ void FFMPEGSoftCodec::overrideComponentName(
}
status_t FFMPEGSoftCodec::setVideoFormat(
+ status_t status,
const sp<AMessage> &msg, const char* mime, sp<IOMX> OMXhandle,
IOMX::node_id nodeID, bool isEncoder,
OMX_VIDEO_CODINGTYPE *compressionFormat,
const char* componentName) {
status_t err = OK;
- if (isEncoder) {
- ALOGE("Encoding not supported");
- err = BAD_VALUE;
-
- } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_WMV, mime)) {
- if (strncmp(componentName, "OMX.ffmpeg.", 11) == 0) {
- err = setWMVFormat(msg, OMXhandle, nodeID);
+ //ALOGD("setVideoFormat: %s", msg->debugString(0).c_str());
+
+ /* status passed in is the result of the normal codec lookup */
+ if (status != OK) {
+
+ if (isEncoder) {
+ ALOGE("Encoding not supported");
+ err = BAD_VALUE;
+
+ } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_WMV, mime)) {
+ if (strncmp(componentName, "OMX.ffmpeg.", 11) == 0) {
+ err = setWMVFormat(msg, OMXhandle, nodeID);
+ if (err != OK) {
+ ALOGE("setWMVFormat() failed (err = %d)", err);
+ }
+ }
+ *compressionFormat = OMX_VIDEO_CodingWMV;
+ } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_RV, mime)) {
+ err = setRVFormat(msg, OMXhandle, nodeID);
if (err != OK) {
- ALOGE("setWMVFormat() failed (err = %d)", err);
+ ALOGE("setRVFormat() failed (err = %d)", err);
+ } else {
+ *compressionFormat = OMX_VIDEO_CodingRV;
}
- }
- *compressionFormat = OMX_VIDEO_CodingWMV;
- } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_RV, mime)) {
- err = setRVFormat(msg, OMXhandle, nodeID);
- if (err != OK) {
- ALOGE("setRVFormat() failed (err = %d)", err);
- } else {
- *compressionFormat = OMX_VIDEO_CodingRV;
- }
- } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_VC1, mime)) {
- *compressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVC1;
- } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_FLV1, mime)) {
- *compressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingFLV1;
- } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_DIVX, mime)) {
- *compressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingDIVX;
+ } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_VC1, mime)) {
+ *compressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVC1;
+ } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_FLV1, mime)) {
+ *compressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingFLV1;
+ } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_DIVX, mime)) {
+ *compressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingDIVX;
#ifdef QCOM_HARDWARE
- // compressionFormat will be override later
- } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_DIVX4, mime)) {
- *compressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingDIVX;
- } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_DIVX311, mime)) {
- *compressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingDIVX;
+ // compressionFormat will be override later
+ } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_DIVX4, mime)) {
+ *compressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingDIVX;
+ } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_DIVX311, mime)) {
+ *compressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingDIVX;
#endif
- } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_HEVC, mime)) {
- *compressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingHEVC;
- } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_FFMPEG, mime)) {
- ALOGV("Setting the OMX_VIDEO_PARAM_FFMPEGTYPE params");
- err = setFFmpegVideoFormat(msg, OMXhandle, nodeID);
- if (err != OK) {
- ALOGE("setFFmpegVideoFormat() failed (err = %d)", err);
+ } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_HEVC, mime)) {
+ *compressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingHEVC;
+ } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_FFMPEG, mime)) {
+ ALOGV("Setting the OMX_VIDEO_PARAM_FFMPEGTYPE params");
+ err = setFFmpegVideoFormat(msg, OMXhandle, nodeID);
+ if (err != OK) {
+ ALOGE("setFFmpegVideoFormat() failed (err = %d)", err);
+ } else {
+ *compressionFormat = OMX_VIDEO_CodingAutoDetect;
+ }
} else {
- *compressionFormat = OMX_VIDEO_CodingAutoDetect;
+ err = BAD_TYPE;
}
- } else {
- err = BAD_TYPE;
}
#ifdef QCOM_HARDWARE
@@ -312,7 +319,7 @@ status_t FFMPEGSoftCodec::setVideoFormat(
// from the CAF L release. It was unfortunately moved to a proprietary
// blob and an architecture which is hellish for OEMs who wish to
// customize the platform.
- if (err != BAD_TYPE && (!strncmp(componentName, "OMX.qcom.", 9))) {
+ if (err == OK && (!strncmp(componentName, "OMX.qcom.", 9))) {
status_t xerr = OK;
@@ -344,13 +351,29 @@ status_t FFMPEGSoftCodec::setVideoFormat(
// Enable timestamp reordering for mpeg4 and vc1 codec types, the AVI file
// type, and hevc content in the ts container
+ AString container;
+ const char * containerStr = NULL;
+ if (msg->findString("file-format", &container)) {
+ containerStr = container.c_str();
+ }
+
bool tsReorder = false;
const char* roleVC1 = "OMX.qcom.video.decoder.vc1";
const char* roleMPEG4 = "OMX.qcom.video.decoder.mpeg4";
+ const char* roleHEVC = "OMX.qcom.video.decoder.hevc";
if (!strncmp(componentName, roleVC1, strlen(roleVC1)) ||
!strncmp(componentName, roleMPEG4, strlen(roleMPEG4))) {
// The codec requires timestamp reordering
tsReorder = true;
+ } else if (containerStr != NULL) {
+ if (!strncmp(containerStr, MEDIA_MIMETYPE_CONTAINER_AVI,
+ strlen(MEDIA_MIMETYPE_CONTAINER_AVI))) {
+ tsReorder = true;
+ } else if (!strncmp(containerStr, MEDIA_MIMETYPE_CONTAINER_MPEG2TS,
+ strlen(MEDIA_MIMETYPE_CONTAINER_MPEG2TS)) ||
+ !strncmp(componentName, roleHEVC, strlen(roleHEVC))) {
+ tsReorder = true;
+ }
}
if (tsReorder) {
@@ -368,6 +391,32 @@ status_t FFMPEGSoftCodec::setVideoFormat(
}
}
+ // Enable Sync-frame decode mode for thumbnails
+ int32_t thumbnailMode = 0;
+ if (msg->findInt32("thumbnail-mode", &thumbnailMode) &&
+ thumbnailMode > 0) {
+ ALOGV("Enabling thumbnail mode.");
+ QOMX_ENABLETYPE enableType;
+ OMX_INDEXTYPE indexType;
+
+ status_t err = OMXhandle->getExtensionIndex(
+ nodeID, OMX_QCOM_INDEX_PARAM_VIDEO_SYNCFRAMEDECODINGMODE,
+ &indexType);
+ if (err != OK) {
+ ALOGW("Failed to get extension for SYNCFRAMEDECODINGMODE");
+ } else {
+
+ enableType.bEnable = OMX_TRUE;
+ err = OMXhandle->setParameter(nodeID,indexType,
+ (void *)&enableType, sizeof(enableType));
+ if (err != OK) {
+ ALOGW("Failed to get extension for SYNCFRAMEDECODINGMODE");
+ } else {
+ ALOGI("Thumbnail mode enabled.");
+ }
+ }
+ }
+
// MediaCodec clients can request decoder extradata by setting
// "enable-extradata-<type>" in MediaFormat.
// Following <type>s are supported: