diff options
author | Andreas Huber <andih@google.com> | 2013-07-19 11:00:43 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2013-07-19 13:50:31 -0700 |
commit | 336da16a12423c496efba6ca9813d5d42a1f70f6 (patch) | |
tree | 137d928ecf461cabdf494d6ead85f200a9b7c8fd /media/libstagefright/codecs/on2/enc/SoftVPXEncoder.cpp | |
parent | a05822a368dfc8c220b413c3d23dcc1af58b4b5f (diff) | |
download | frameworks_av-336da16a12423c496efba6ca9813d5d42a1f70f6.zip frameworks_av-336da16a12423c496efba6ca9813d5d42a1f70f6.tar.gz frameworks_av-336da16a12423c496efba6ca9813d5d42a1f70f6.tar.bz2 |
Enable support for explicitly requesting an encoded keyframe from the vp8
encoder.
Change-Id: I370d5831f7d6037faf361a92521390f19f179cbe
Diffstat (limited to 'media/libstagefright/codecs/on2/enc/SoftVPXEncoder.cpp')
-rw-r--r-- | media/libstagefright/codecs/on2/enc/SoftVPXEncoder.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/media/libstagefright/codecs/on2/enc/SoftVPXEncoder.cpp b/media/libstagefright/codecs/on2/enc/SoftVPXEncoder.cpp index d8456fe..5f2b5c8 100644 --- a/media/libstagefright/codecs/on2/enc/SoftVPXEncoder.cpp +++ b/media/libstagefright/codecs/on2/enc/SoftVPXEncoder.cpp @@ -149,7 +149,8 @@ SoftVPXEncoder::SoftVPXEncoder(const char *name, mLevel(OMX_VIDEO_VP8Level_Version0), mConversionBuffer(NULL), mInputDataIsMeta(false), - mGrallocModule(NULL) { + mGrallocModule(NULL), + mKeyFrameRequested(false) { initPorts(); } @@ -519,6 +520,27 @@ OMX_ERRORTYPE SoftVPXEncoder::internalSetParameter(OMX_INDEXTYPE index, } } +OMX_ERRORTYPE SoftVPXEncoder::setConfig( + OMX_INDEXTYPE index, const OMX_PTR _params) { + switch (index) { + case OMX_IndexConfigVideoIntraVOPRefresh: + { + OMX_CONFIG_INTRAREFRESHVOPTYPE *params = + (OMX_CONFIG_INTRAREFRESHVOPTYPE *)_params; + + if (params->nPortIndex != kOutputPortIndex) { + return OMX_ErrorBadPortIndex; + } + + mKeyFrameRequested = params->IntraRefreshVOP; + return OMX_ErrorNone; + } + + default: + return SimpleSoftOMXComponent::setConfig(index, _params); + } +} + OMX_ERRORTYPE SoftVPXEncoder::internalSetProfileLevel( const OMX_VIDEO_PARAM_PROFILELEVELTYPE* profileAndLevel) { if (profileAndLevel->nPortIndex != kOutputPortIndex) { @@ -750,12 +772,19 @@ void SoftVPXEncoder::onQueueFilled(OMX_U32 portIndex) { vpx_image_t raw_frame; vpx_img_wrap(&raw_frame, VPX_IMG_FMT_I420, mWidth, mHeight, kInputBufferAlignment, source); + + vpx_enc_frame_flags_t flags = 0; + if (mKeyFrameRequested) { + flags |= VPX_EFLAG_FORCE_KF; + mKeyFrameRequested = false; + } + codec_return = vpx_codec_encode( mCodecContext, &raw_frame, inputBufferHeader->nTimeStamp, // in timebase units mFrameDurationUs, // frame duration in timebase units - 0, // frame flags + flags, // frame flags VPX_DL_REALTIME); // encoding deadline if (codec_return != VPX_CODEC_OK) { ALOGE("vpx encoder failed to encode frame"); |