summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/codecs
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2013-07-19 11:00:43 -0700
committerAndreas Huber <andih@google.com>2013-07-19 13:50:31 -0700
commit336da16a12423c496efba6ca9813d5d42a1f70f6 (patch)
tree137d928ecf461cabdf494d6ead85f200a9b7c8fd /media/libstagefright/codecs
parenta05822a368dfc8c220b413c3d23dcc1af58b4b5f (diff)
downloadframeworks_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')
-rw-r--r--media/libstagefright/codecs/on2/enc/SoftVPXEncoder.cpp33
-rw-r--r--media/libstagefright/codecs/on2/enc/SoftVPXEncoder.h5
2 files changed, 36 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");
diff --git a/media/libstagefright/codecs/on2/enc/SoftVPXEncoder.h b/media/libstagefright/codecs/on2/enc/SoftVPXEncoder.h
index d570154..4ee5e51 100644
--- a/media/libstagefright/codecs/on2/enc/SoftVPXEncoder.h
+++ b/media/libstagefright/codecs/on2/enc/SoftVPXEncoder.h
@@ -78,6 +78,9 @@ protected:
virtual OMX_ERRORTYPE internalSetParameter(
OMX_INDEXTYPE index, const OMX_PTR param);
+ virtual OMX_ERRORTYPE setConfig(
+ OMX_INDEXTYPE index, const OMX_PTR params);
+
// OMX callback when buffers available
// Note that both an input and output buffer
// is expected to be available to carry out
@@ -163,6 +166,8 @@ private:
bool mInputDataIsMeta;
const hw_module_t *mGrallocModule;
+ bool mKeyFrameRequested;
+
// Initializes input and output OMX ports with sensible
// default values.
void initPorts();