Permalink
Browse files

libstagefright: OMAP_COMPAT flag to allow use of omap3 codec table

Require TARGET_USE_OMAP_COMPAT:=true or -DOMAP_COMPAT global cflag

Note: Defy, Droid 2, Droid X and Cliq 2 use these codecs
      and are not compatible with OMAP_ENHANCEMENT

Change-Id: I13a01acf600caf50d954f8c0f833a220d314bf56
  • Loading branch information...
1 parent d6ced5d commit d3935fb90d5787664921dc3940bed1a63a209359 @tpruvot tpruvot committed with cyanogen Oct 19, 2011
View
14 cmds/stagefright/Android.mk
@@ -1,5 +1,13 @@
LOCAL_PATH:= $(call my-dir)
+# common CFLAGS
+cflags := -Wno-multichar
+
+# CFLAGS for includes
+ifeq ($(TARGET_USE_OMAP_COMPAT),true)
+ cflags += -DOMAP_COMPAT
+endif
+
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
@@ -15,7 +23,7 @@ LOCAL_C_INCLUDES:= \
frameworks/base/media/libstagefright/include \
$(TOP)/frameworks/base/include/media/stagefright/openmax
-LOCAL_CFLAGS += -Wno-multichar
+LOCAL_CFLAGS += ${cflags}
LOCAL_MODULE_TAGS := debug
@@ -39,7 +47,7 @@ LOCAL_C_INCLUDES:= \
frameworks/base/media/libstagefright \
$(TOP)/frameworks/base/include/media/stagefright/openmax
-LOCAL_CFLAGS += -Wno-multichar
+LOCAL_CFLAGS += ${cflags}
LOCAL_MODULE_TAGS := debug
@@ -63,7 +71,7 @@ LOCAL_C_INCLUDES:= \
frameworks/base/media/libstagefright \
$(TOP)/frameworks/base/include/media/stagefright/openmax
-LOCAL_CFLAGS += -Wno-multichar
+LOCAL_CFLAGS += ${cflags}
LOCAL_MODULE_TAGS := debug
View
6 include/media/stagefright/OMXCodec.h
@@ -38,7 +38,7 @@ struct OMXCodec : public MediaSource,
// The client wants to access the output buffer's video
// data for example for thumbnail extraction.
kClientNeedsFramebuffer = 4,
-#ifdef OMAP_ENHANCEMENT
+#if defined(OMAP_ENHANCEMENT) || defined(OMAP_COMPAT)
kPreferThumbnailMode = 0x8,
kPreferInterlacedOutputContent = 0x10,
MAX_RESOLUTION = 414720, // video resolution for TI Vid Dec
@@ -141,7 +141,7 @@ struct OMXCodec : public MediaSource,
kStoreMetaDataInInputVideoBuffers = 16384,
kCanNotSetVideoParameters = 32768,
kDoesNotRequireMemcpyOnOutputPort = 65536,
-#ifdef OMAP_ENHANCEMENT
+#if defined(OMAP_ENHANCEMENT) || defined(OMAP_COMPAT)
kDecoderNeedsPortReconfiguration = 131072,
kDecoderCantRenderSmallClips = 262144,
kInterlacedOutputContent = 524288,
@@ -309,7 +309,7 @@ struct OMXCodec : public MediaSource,
#endif
status_t configureCodec(const sp<MetaData> &meta, uint32_t flags);
-#ifdef OMAP_ENHANCEMENT
+#if defined(OMAP_ENHANCEMENT) || defined(OMAP_COMPAT)
protected:
static uint32_t getComponentQuirks(const char *componentName, bool isEncoder, uint32_t flags = 0);
int32_t mVideoFPS;
View
5 media/libmediaplayerservice/Android.mk
@@ -48,6 +48,11 @@ else
LOCAL_CFLAGS += -DNO_OPENCORE
endif
+# CFLAGS for StagefrightRecorder includes
+ifeq ($(TARGET_USE_OMAP_COMPAT),true)
+ LOCAL_CFLAGS += -DOMAP_COMPAT
+endif
+
ifneq ($(TARGET_SIMULATOR),true)
LOCAL_SHARED_LIBRARIES += libdl
endif
View
4 media/libstagefright/Android.mk
@@ -152,6 +152,10 @@ ifeq ($(TARGET_DONT_SET_AUDIO_AAC_FORMAT),true)
LOCAL_CFLAGS += -DDONT_SET_AUDIO_AAC_FORMAT
endif
+ifeq ($(TARGET_USE_OMAP_COMPAT),true)
+ LOCAL_CFLAGS += -DOMAP_COMPAT
+endif
+
ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true)
LOCAL_LDLIBS += -lpthread
endif
View
4 media/libstagefright/MPEG4Writer.cpp
@@ -1854,7 +1854,7 @@ status_t MPEG4Writer::Track::threadEntry() {
uint32_t previousSampleSize = 0; // Size of the previous sample
int64_t previousPausedDurationUs = 0;
int64_t timestampUs;
-#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP3)
+#if (defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP3)) || defined(OMAP_COMPAT)
uint8_t *copy_spspps;
int32_t copy_spspps_size = 0;
#endif
@@ -1914,7 +1914,7 @@ status_t MPEG4Writer::Track::threadEntry() {
mGotAllCodecSpecificData = true;
continue;
}
-#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP3)
+#if (defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP3)) || defined(OMAP_COMPAT)
else if (mIsAvc && count < 3) {
size_t size = buffer->range_length();
size_t start_code_size = 0;
View
63 media/libstagefright/OMXCodec.cpp
@@ -234,7 +234,7 @@ static sp<MediaSource> InstantiateSoftwareCodec(
#undef FACTORY_REF
#undef FACTORY_CREATE
-#ifdef OMAP_ENHANCEMENT
+#if defined(OMAP_ENHANCEMENT) || defined(OMAP_COMPAT)
#ifdef TARGET_OMAP4
//Enable Ducati Codecs for Video, PV SW codecs for Audio
static const CodecInfo kDecoderInfo[] = {
@@ -281,7 +281,9 @@ static const CodecInfo kDecoderInfo[] = {
{ MEDIA_MIMETYPE_AUDIO_AAC, "AACDecoder" },
{ MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.TI.Video.Decoder" },
{ MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.TI.720P.Decoder" },
+ { MEDIA_MIMETYPE_VIDEO_MPEG4, "M4vH263Decoder" },
{ MEDIA_MIMETYPE_VIDEO_H263, "OMX.TI.Video.Decoder" },
+ { MEDIA_MIMETYPE_VIDEO_H263, "M4vH263Decoder" },
/* 720p Video Decoder must be placed before the TI Video Decoder.
DO NOT CHANGE THIS SEQUENCE. IT WILL BREAK FLASH. */
{ MEDIA_MIMETYPE_VIDEO_AVC, "OMX.TI.720P.Decoder" },
@@ -403,6 +405,7 @@ static const CodecInfo kEncoderInfo[] = {
#endif
#ifndef OMAP_ENHANCEMENT
+// the new omap one is defined in .h
struct OMXCodecObserver : public BnOMXObserver {
OMXCodecObserver() {
}
@@ -540,11 +543,10 @@ static int CompareSoftwareCodecsFirst(
}
// static
-#ifdef OMAP_ENHANCEMENT
+#if defined(OMAP_ENHANCEMENT) || defined(OMAP_COMPAT)
uint32_t OMXCodec::getComponentQuirks(const char *componentName,bool isEncoder, uint32_t flags) {
#else
-uint32_t OMXCodec::getComponentQuirks(
- const char *componentName, bool isEncoder) {
+uint32_t OMXCodec::getComponentQuirks(const char *componentName, bool isEncoder) {
#endif
uint32_t quirks = 0;
@@ -562,7 +564,7 @@ uint32_t OMXCodec::getComponentQuirks(
if (!strcmp(componentName, "OMX.TI.MP3.decode")) {
quirks |= kNeedsFlushBeforeDisable;
quirks |= kDecoderLiesAboutNumberOfChannels;
-#ifdef OMAP_ENHANCEMENT
+#if defined(OMAP_ENHANCEMENT) || defined(OMAP_COMPAT)
quirks |= kSupportsMultipleFramesPerInputBuffer;
quirks |= kDecoderCantRenderSmallClips;
#endif
@@ -572,7 +574,7 @@ uint32_t OMXCodec::getComponentQuirks(
quirks |= kRequiresFlushCompleteEmulation;
quirks |= kSupportsMultipleFramesPerInputBuffer;
}
-#ifdef OMAP_ENHANCEMENT
+#if defined(OMAP_ENHANCEMENT) || defined(OMAP_COMPAT)
if (!strcmp(componentName, "OMX.TI.WMA.decode")) {
quirks |= kNeedsFlushBeforeDisable;
quirks |= kRequiresFlushCompleteEmulation;
@@ -628,7 +630,7 @@ uint32_t OMXCodec::getComponentQuirks(
quirks |= kDefersOutputBufferAllocation;
quirks |= kDoesNotRequireMemcpyOnOutputPort;
}
-#ifdef OMAP_ENHANCEMENT
+#if defined(OMAP_ENHANCEMENT) || defined(OMAP_COMPAT)
if (!strcmp(componentName, "OMX.TI.Video.Decoder") ||
!strcmp(componentName, "OMX.TI.720P.Decoder")) {
// TI Video Decoder and TI 720p Decoder must use buffers allocated
@@ -683,7 +685,7 @@ uint32_t OMXCodec::getComponentQuirks(
}
#endif
}
-#ifndef OMAP_ENHANCEMENT
+#if !(defined(OMAP_ENHANCEMENT) || defined(OMAP_COMPAT))
if (!strcmp(componentName, "OMX.TI.Video.Decoder")) {
quirks |= kInputBufferSizesAreBogus;
}
@@ -791,11 +793,28 @@ sp<MediaSource> OMXCodec::Create(
}
LOGV("Attempting to allocate OMX node '%s'", componentName);
-#ifdef OMAP_ENHANCEMENT
-uint32_t quirks = getComponentQuirks(componentName, createEncoder, flags);
+#if defined(OMAP_ENHANCEMENT) || defined(OMAP_COMPAT)
+ uint32_t quirks = getComponentQuirks(componentName, createEncoder, flags);
#else
uint32_t quirks = getComponentQuirks(componentName, createEncoder);
#endif
+
+#ifdef OMAP_COMPAT
+ if (!strcmp(componentName, "OMX.TI.Video.Decoder")) {
+ int32_t width, height;
+ bool success = meta->findInt32(kKeyWidth, &width);
+ success = success && meta->findInt32(kKeyHeight, &height);
+ CHECK(success);
+ // We need this for 720p video without AVC profile
+ // Not a good solution, but ..
+ if (width*height > 409920) { //854*480
+ componentName = "OMX.TI.720P.Decoder";
+ LOGE("Format exceed the decoder's capabilities.");
+ continue;
+ }
+ }
+#endif
+
if (!createEncoder
&& (quirks & kOutputBuffersAreUnreadable)
&& (flags & kClientNeedsFramebuffer)) {
@@ -880,7 +899,7 @@ sp<MediaSource> OMXCodec::Create(
if (err == OK) {
LOGV("Successfully allocated OMX node '%s'", componentName);
-#ifdef TARGET_OMAP4
+#if defined(OMAP_ENHANCEMENT) || defined(OMAP_COMPAT)
sp<OMXCodec> codec = new OMXCodec(
omx, node, getComponentQuirks(componentName,createEncoder,flags),
createEncoder, mime, componentName,
@@ -1047,7 +1066,7 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta, uint32_t flags) {
LOGE("Profile and/or level exceed the decoder's capabilities.");
return ERROR_UNSUPPORTED;
}
-#ifdef OMAP_ENHANCEMENT
+#if defined(OMAP_ENHANCEMENT) || defined(OMAP_COMPAT)
int32_t width, height;
bool success = meta->findInt32(kKeyWidth, &width);
success = success && meta->findInt32(kKeyHeight, &height);
@@ -1126,14 +1145,22 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta, uint32_t flags) {
if (mIsEncoder) {
CHECK(meta->findInt32(kKeyBitRate, &bitRate));
-#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP3)
+#if (defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP3)) || defined(OMAP_COMPAT)
+
+ // required to prefer the 720P encoder on Defy red lens, and Defy+
+ #ifdef OMAP_COMPAT
+ # define MAX_ENCODER_RESOLUTION 848*480
+ #else
+ # define MAX_ENCODER_RESOLUTION MAX_RESOLUTION
+ #endif
+
if (!strcmp(mComponentName, "OMX.TI.Video.encoder")) {
int32_t width, height;
bool success = meta->findInt32(kKeyWidth, &width);
success = success && meta->findInt32(kKeyHeight, &height);
CHECK(success);
- if (width*height > MAX_RESOLUTION) {
- // need OMX.TI.720P.Encoder
+ if (width*height > MAX_ENCODER_RESOLUTION) {
+ // require OMX.TI.720P.Encoder
return ERROR_UNSUPPORTED;
}
}
@@ -2437,7 +2464,7 @@ status_t OMXCodec::setVideoOutputFormat(
compressionFormat = OMX_VIDEO_CodingMPEG4;
} else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_H263, mime)) {
compressionFormat = OMX_VIDEO_CodingH263;
-#if defined(OMAP_ENHANCEMENT)
+#if defined(OMAP_ENHANCEMENT) || defined(OMAP_COMPAT)
#if defined(TARGET_OMAP4)
} else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_VP6, mime)) {
compressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVP6;
@@ -2741,13 +2768,10 @@ void OMXCodec::setComponentRole(
"video_decoder.mpeg4", "video_encoder.mpeg4" },
{ MEDIA_MIMETYPE_VIDEO_H263,
"video_decoder.h263", "video_encoder.h263" },
-#if defined(OMAP_ENHANCEMENT)
-#if defined(TARGET_OMAP4)
{ MEDIA_MIMETYPE_VIDEO_VP6,
"video_decoder.vp6", NULL },
{ MEDIA_MIMETYPE_VIDEO_VP7,
"video_decoder.vp7", NULL },
-#endif
{ MEDIA_MIMETYPE_VIDEO_WMV,
"video_decoder.wmv", "video_encoder.wmv" },
{ MEDIA_MIMETYPE_AUDIO_WMA,
@@ -2756,7 +2780,6 @@ void OMXCodec::setComponentRole(
"audio_decoder.wmapro", "audio_encoder.wmapro" },
{ MEDIA_MIMETYPE_AUDIO_WMALSL,
"audio_decoder.wmalsl", "audio_encoder.wmalsl" },
-#endif
};
static const size_t kNumMimeToRole =

0 comments on commit d3935fb

Please sign in to comment.