summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShalaj Jain <shalajj@codeaurora.org>2013-01-22 18:45:15 -0800
committerSteve Kondik <shade@chemlab.org>2013-02-19 11:13:40 -0800
commite4a52e7469c5a7c247424777c2350e6a85ea685e (patch)
treea33b6c38314be36543d6a300b99a4a87629aaec9
parent63614c132b320a6146b6be85b8f3131135db4ba2 (diff)
downloadframeworks_av-e4a52e7469c5a7c247424777c2350e6a85ea685e.zip
frameworks_av-e4a52e7469c5a7c247424777c2350e6a85ea685e.tar.gz
frameworks_av-e4a52e7469c5a7c247424777c2350e6a85ea685e.tar.bz2
libstagefright: Add support for frame-by-frame mode
- Set decoder in frame-by-frame mode always, except for interlaced content, for which arbitary mode should be set Change-Id: I8195a40549898b43a0e03d65663c7148f458c448
-rw-r--r--include/media/stagefright/QCOMXCodec.h4
-rw-r--r--media/libstagefright/MPEG4Extractor.cpp7
-rw-r--r--media/libstagefright/OMXCodec.cpp6
-rw-r--r--media/libstagefright/QCOMXCodec.cpp20
-rw-r--r--media/libstagefright/avc_utils.cpp6
-rw-r--r--media/libstagefright/include/avc_utils.h2
6 files changed, 40 insertions, 5 deletions
diff --git a/include/media/stagefright/QCOMXCodec.h b/include/media/stagefright/QCOMXCodec.h
index 485c187..ee6ea88 100644
--- a/include/media/stagefright/QCOMXCodec.h
+++ b/include/media/stagefright/QCOMXCodec.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -94,6 +94,8 @@ struct QCOMXCodec {
static void setQCSpecificVideoFormat(const sp<MetaData> &meta, sp<IOMX> OMXhandle,
IOMX::node_id nodeID, char* componentName );
+ static void checkIfInterlaced(const uint8_t *ptr, const sp<MetaData> &meta);
+
};
}
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp
index 488c2a3..dd1e60b 100644
--- a/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/MPEG4Extractor.cpp
@@ -42,6 +42,7 @@
#include <utils/String8.h>
#ifdef QCOM_HARDWARE
#include <QCMediaDefs.h>
+#include <QCMetaData.h>
#endif
namespace android {
@@ -2002,6 +2003,12 @@ MPEG4Source::MPEG4Source(
// The number of bytes used to encode the length of a NAL unit.
mNALLengthSize = 1 + (ptr[4] & 3);
}
+
+#ifdef QCOM_HARDWARE
+ //MPEG4 extractor can give complete frames,
+ //set arbitrary mode to false
+ mFormat->setInt32(kKeyUseArbitraryMode, 0);
+#endif
}
MPEG4Source::~MPEG4Source() {
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 5988061..02993d0 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2009 The Android Open Source Project
- * Copyright (c) 2010 - 2012, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2010 - 2013, The Linux Foundation. All rights reserved.
*
* Not a Contribution, Apache license notifications and license are retained
* for attribution purposes only.
@@ -611,6 +611,10 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
return err;
}
+#ifdef QCOM_HARDWARE
+ QCOMXCodec::checkIfInterlaced((const uint8_t *)data, meta);
+#endif
+
CODEC_LOGI(
"AVC profile = %u (%s), level = %u",
profile, AVCProfileToString(profile), level);
diff --git a/media/libstagefright/QCOMXCodec.cpp b/media/libstagefright/QCOMXCodec.cpp
index 0d5768a..fcc57f2 100644
--- a/media/libstagefright/QCOMXCodec.cpp
+++ b/media/libstagefright/QCOMXCodec.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -45,6 +45,7 @@
#include <OMX_Component.h>
#include <QOMX_AudioExtensions.h>
+#include "include/avc_utils.h"
namespace android {
@@ -589,4 +590,21 @@ void QCOMXCodec::setQCSpecificVideoFormat(const sp<MetaData> &meta, sp<IOMX> OMX
}
}
+void QCOMXCodec::checkIfInterlaced(const uint8_t *ptr, const sp<MetaData> &meta)
+{
+ uint16_t spsSize = (((uint16_t)ptr[6]) << 8) + (uint16_t)(ptr[7]);
+ int32_t width = 0, height = 0, isInterlaced = 0;
+ const uint8_t *spsStart = &ptr[8];
+
+ sp<ABuffer> seqParamSet = new ABuffer(spsSize);
+ memcpy(seqParamSet->data(), spsStart, spsSize);
+ FindAVCDimensions(seqParamSet, &width, &height, &isInterlaced);
+
+ ALOGV("height is %d, width is %d, isInterlaced is %d\n", height, width, isInterlaced);
+ if (isInterlaced) {
+ meta->setInt32(kKeyUseArbitraryMode, 1);
+ }
+ return;
+}
+
}
diff --git a/media/libstagefright/avc_utils.cpp b/media/libstagefright/avc_utils.cpp
index a141752..fbe98f1 100644
--- a/media/libstagefright/avc_utils.cpp
+++ b/media/libstagefright/avc_utils.cpp
@@ -41,7 +41,7 @@ unsigned parseUE(ABitReader *br) {
// Determine video dimensions from the sequence parameterset.
void FindAVCDimensions(
- const sp<ABuffer> &seqParamSet, int32_t *width, int32_t *height) {
+ const sp<ABuffer> &seqParamSet, int32_t *width, int32_t *height, int32_t *isInterlaced) {
ABitReader br(seqParamSet->data() + 1, seqParamSet->size() - 1);
unsigned profile_idc = br.getBits(8);
@@ -128,6 +128,10 @@ void FindAVCDimensions(
(frame_crop_left_offset + frame_crop_right_offset) * cropUnitX;
*height -=
(frame_crop_top_offset + frame_crop_bottom_offset) * cropUnitY;
+
+ if (isInterlaced != NULL) {
+ *isInterlaced = !frame_mbs_only_flag;
+ }
}
}
diff --git a/media/libstagefright/include/avc_utils.h b/media/libstagefright/include/avc_utils.h
index e418822..d385bc1 100644
--- a/media/libstagefright/include/avc_utils.h
+++ b/media/libstagefright/include/avc_utils.h
@@ -37,7 +37,7 @@ enum {
};
void FindAVCDimensions(
- const sp<ABuffer> &seqParamSet, int32_t *width, int32_t *height);
+ const sp<ABuffer> &seqParamSet, int32_t *width, int32_t *height, int32_t *isInterlaced = NULL);
unsigned parseUE(ABitReader *br);