diff options
author | James Dong <jdong@google.com> | 2012-11-15 14:00:26 -0800 |
---|---|---|
committer | James Dong <jdong@google.com> | 2012-11-28 13:21:07 -0800 |
commit | 0dbe5a9321b24b6883fbb2fe97cd9d525128b0b5 (patch) | |
tree | f832d0b48a4541d34f84e550746702e982d07485 | |
parent | b7c8e91880463ff4981e3e53e98e45d68e2fe374 (diff) | |
download | frameworks_av-0dbe5a9321b24b6883fbb2fe97cd9d525128b0b5.zip frameworks_av-0dbe5a9321b24b6883fbb2fe97cd9d525128b0b5.tar.gz frameworks_av-0dbe5a9321b24b6883fbb2fe97cd9d525128b0b5.tar.bz2 |
Added optional intra macroblock refresh support for encoding
o related-to-bug: 7524791
Change-Id: I95ac4ee925e2dbeb00b3cfb2e29c611698c5cc9f
-rw-r--r-- | include/media/stagefright/ACodec.h | 1 | ||||
-rw-r--r-- | media/libstagefright/ACodec.cpp | 50 |
2 files changed, 50 insertions, 1 deletions
diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h index cba8a6b..df1c46b 100644 --- a/include/media/stagefright/ACodec.h +++ b/include/media/stagefright/ACodec.h @@ -184,6 +184,7 @@ private: bool mChannelMaskPresent; int32_t mChannelMask; + status_t setCyclicIntraMacroblockRefresh(const sp<AMessage> &msg, int32_t mode); status_t allocateBuffersOnPort(OMX_U32 portIndex); status_t freeBuffersOnPort(OMX_U32 portIndex); status_t freeBuffer(OMX_U32 portIndex, size_t i); diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index 84b4962..a01d03f 100644 --- a/media/libstagefright/ACodec.cpp +++ b/media/libstagefright/ACodec.cpp @@ -1630,6 +1630,43 @@ status_t ACodec::setupVideoEncoder(const char *mime, const sp<AMessage> &msg) { return err; } +status_t ACodec::setCyclicIntraMacroblockRefresh(const sp<AMessage> &msg, int32_t mode) { + OMX_VIDEO_PARAM_INTRAREFRESHTYPE params; + InitOMXParams(¶ms); + params.nPortIndex = kPortIndexOutput; + + params.eRefreshMode = static_cast<OMX_VIDEO_INTRAREFRESHTYPE>(mode); + + if (params.eRefreshMode == OMX_VIDEO_IntraRefreshCyclic || + params.eRefreshMode == OMX_VIDEO_IntraRefreshBoth) { + int32_t mbs; + if (!msg->findInt32("intra-refresh-CIR-mbs", &mbs)) { + return INVALID_OPERATION; + } + params.nCirMBs = mbs; + } + + if (params.eRefreshMode == OMX_VIDEO_IntraRefreshAdaptive || + params.eRefreshMode == OMX_VIDEO_IntraRefreshBoth) { + int32_t mbs; + if (!msg->findInt32("intra-refresh-AIR-mbs", &mbs)) { + return INVALID_OPERATION; + } + params.nAirMBs = mbs; + + int32_t ref; + if (!msg->findInt32("intra-refresh-AIR-ref", &ref)) { + return INVALID_OPERATION; + } + params.nAirRef = ref; + } + + status_t err = mOMX->setParameter( + mNode, OMX_IndexParamVideoIntraRefresh, + ¶ms, sizeof(params)); + return err; +} + static OMX_U32 setPFramesSpacing(int32_t iFramesInterval, int32_t frameRate) { if (iFramesInterval < 0) { return 0xFFFFFFFF; @@ -1825,11 +1862,22 @@ status_t ACodec::setupAVCEncoderParameters(const sp<AMessage> &msg) { frameRate = (float)tmp; } + status_t err = OK; + int32_t intraRefreshMode = 0; + if (msg->findInt32("intra-refresh-mode", &intraRefreshMode)) { + err = setCyclicIntraMacroblockRefresh(msg, intraRefreshMode); + if (err != OK) { + ALOGE("Setting intra macroblock refresh mode (%d) failed: 0x%x", + err, intraRefreshMode); + return err; + } + } + OMX_VIDEO_PARAM_AVCTYPE h264type; InitOMXParams(&h264type); h264type.nPortIndex = kPortIndexOutput; - status_t err = mOMX->getParameter( + err = mOMX->getParameter( mNode, OMX_IndexParamVideoAvc, &h264type, sizeof(h264type)); if (err != OK) { |