summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPraveen Chavan <pchavan@codeaurora.org>2015-04-30 20:28:44 -0700
committerRonghua Wu <ronghuawu@google.com>2015-07-09 11:17:38 -0700
commitdce0acfcb3cdf6eceef84f22def392cc6d4557ab (patch)
treefb003c4ff6cc87758f58a95195c090a8e105cfce
parentc63a274a815a5d76f8815f48b3be767d3eb8a414 (diff)
downloadandroid_hardware_qcom_media-dce0acfcb3cdf6eceef84f22def392cc6d4557ab.tar.gz
android_hardware_qcom_media-dce0acfcb3cdf6eceef84f22def392cc6d4557ab.tar.bz2
android_hardware_qcom_media-dce0acfcb3cdf6eceef84f22def392cc6d4557ab.zip
mm-video-v4l2: vidc: add support for setting operating-rate
Operating-rate hints the incoming rate of frames in real-time which can be different from the content fps. This rate will use used to set the correct operating point for encoder and decoder. This config will fail with InSufficientResources if the hardware cannot accomodate the requested operating rate. Amended by Ashray Kulkarni <ashrayk@codeaurora.org> bug: 20134262 Change-Id: If3f21067e31a4646ba143b1acd2d075421a6277a
-rw-r--r--mm-video-v4l2/vidc/vdec/src/omx_vdec_msm8974.cpp16
-rw-r--r--mm-video-v4l2/vidc/venc/inc/video_encoder_device_v4l2.h2
-rw-r--r--mm-video-v4l2/vidc/venc/src/omx_video_encoder.cpp9
-rw-r--r--mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp34
4 files changed, 60 insertions, 1 deletions
diff --git a/mm-video-v4l2/vidc/vdec/src/omx_vdec_msm8974.cpp b/mm-video-v4l2/vidc/vdec/src/omx_vdec_msm8974.cpp
index c101346f..2e840c12 100644
--- a/mm-video-v4l2/vidc/vdec/src/omx_vdec_msm8974.cpp
+++ b/mm-video-v4l2/vidc/vdec/src/omx_vdec_msm8974.cpp
@@ -4462,6 +4462,22 @@ OMX_ERRORTYPE omx_vdec::set_config(OMX_IN OMX_HANDLETYPE hComp,
ret = OMX_ErrorUnsupportedSetting;
}
return ret;
+ } else if ((int)configIndex == (int)OMX_IndexConfigOperatingRate) {
+ OMX_PARAM_U32TYPE *rate = (OMX_PARAM_U32TYPE *)configData;
+ DEBUG_PRINT_LOW("Set_config: operating-rate %u fps", rate->nU32 >> 16);
+
+ struct v4l2_control control;
+
+ control.id = V4L2_CID_MPEG_VIDC_VIDEO_OPERATING_RATE;
+ control.value = rate->nU32;
+
+ if (ioctl(drv_ctx.video_driver_fd, VIDIOC_S_CTRL, &control)) {
+ ret = errno == -EBUSY ? OMX_ErrorInsufficientResources :
+ OMX_ErrorUnsupportedSetting;
+ DEBUG_PRINT_ERROR("Failed to set operating rate %u fps (%s)",
+ rate->nU32 >> 16, errno == -EBUSY ? "HW Overload" : strerror(errno));
+ }
+ return ret;
}
return OMX_ErrorNotImplemented;
diff --git a/mm-video-v4l2/vidc/venc/inc/video_encoder_device_v4l2.h b/mm-video-v4l2/vidc/venc/inc/video_encoder_device_v4l2.h
index f8a8ffae..e2bdaf72 100644
--- a/mm-video-v4l2/vidc/venc/inc/video_encoder_device_v4l2.h
+++ b/mm-video-v4l2/vidc/venc/inc/video_encoder_device_v4l2.h
@@ -357,6 +357,7 @@ class venc_dev
struct msm_venc_ltrinfo ltrinfo;
struct msm_venc_vpx_error_resilience vpx_err_resilience;
struct msm_venc_priority sess_priority;
+ OMX_U32 operating_rate;
bool venc_set_profile_level(OMX_U32 eProfile,OMX_U32 eLevel);
bool venc_set_intra_period(OMX_U32 nPFrames, OMX_U32 nBFrames);
@@ -398,6 +399,7 @@ class venc_dev
bool venc_calibrate_gop();
bool venc_validate_hybridhp_params(OMX_U32 layers, OMX_U32 bFrames, OMX_U32 count, int mode);
bool venc_set_session_priority(OMX_U32 priority);
+ bool venc_set_operatingrate(OMX_U32 rate);
#ifdef MAX_RES_1080P
OMX_U32 pmem_free();
diff --git a/mm-video-v4l2/vidc/venc/src/omx_video_encoder.cpp b/mm-video-v4l2/vidc/venc/src/omx_video_encoder.cpp
index cbe7a385..a72e07eb 100644
--- a/mm-video-v4l2/vidc/venc/src/omx_video_encoder.cpp
+++ b/mm-video-v4l2/vidc/venc/src/omx_video_encoder.cpp
@@ -1783,6 +1783,15 @@ OMX_ERRORTYPE omx_venc::set_config(OMX_IN OMX_HANDLETYPE hComp,
}
break;
}
+ case OMX_IndexConfigOperatingRate:
+ {
+ if (!handle->venc_set_config(configData, (OMX_INDEXTYPE)OMX_IndexConfigOperatingRate)) {
+ DEBUG_PRINT_ERROR("Failed to set OMX_IndexConfigOperatingRate");
+ return handle->hw_overload ? OMX_ErrorInsufficientResources :
+ OMX_ErrorUnsupportedSetting;
+ }
+ break;
+ }
default:
DEBUG_PRINT_ERROR("ERROR: unsupported index %d", (int) configIndex);
break;
diff --git a/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp b/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp
index 7d500d7e..96fbbe67 100644
--- a/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp
+++ b/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp
@@ -254,6 +254,7 @@ venc_dev::venc_dev(class omx_venc *venc_class)
camera_mode_enabled = false;
memset(&ltrinfo, 0, sizeof(ltrinfo));
sess_priority.priority = 1;
+ operating_rate = 0;
char property_value[PROPERTY_VALUE_MAX] = {0};
property_get("vidc.enc.log.in", property_value, "0");
@@ -2104,7 +2105,16 @@ bool venc_dev::venc_set_config(void *configData, OMX_INDEXTYPE index)
}
break;
}
-
+ case OMX_IndexConfigOperatingRate:
+ {
+ OMX_PARAM_U32TYPE *rate = (OMX_PARAM_U32TYPE *)configData;
+ DEBUG_PRINT_LOW("Set_config: operating rate %d", rate->nU32);
+ if (!venc_set_operatingrate(rate->nU32)) {
+ DEBUG_PRINT_ERROR("Failed to set operating rate");
+ return false;
+ }
+ break;
+ }
default:
DEBUG_PRINT_ERROR("Unsupported config index = %u", index);
break;
@@ -2350,6 +2360,8 @@ void venc_dev::venc_config_print()
DEBUG_PRINT_HIGH("ENC_CONFIG: Peak bitrate: %d", peak_bitrate.peakbitrate);
DEBUG_PRINT_HIGH("ENC_CONFIG: Session Priority: %u", sess_priority.priority);
+
+ DEBUG_PRINT_HIGH("ENC_CONFIG: Operating Rate: %u", operating_rate);
}
bool venc_dev::venc_reconfig_reqbufs()
@@ -4680,6 +4692,26 @@ bool venc_dev::venc_set_session_priority(OMX_U32 priority) {
return true;
}
+bool venc_dev::venc_set_operatingrate(OMX_U32 rate) {
+ struct v4l2_control control;
+
+ control.id = V4L2_CID_MPEG_VIDC_VIDEO_OPERATING_RATE;
+ control.value = rate;
+
+ DEBUG_PRINT_LOW("venc_set_operating_rate: %d fps", rate >> 16);
+ DEBUG_PRINT_LOW("Calling IOCTL set control for id=%d, val=%d", control.id, control.value);
+
+ if(ioctl(m_nDriver_fd, VIDIOC_S_CTRL, &control)) {
+ hw_overload = errno == EBUSY;
+ DEBUG_PRINT_ERROR("Failed to set operating rate %d fps (%s)",
+ rate >> 16, hw_overload ? "HW overload" : strerror(errno));
+ return false;
+ }
+ operating_rate = rate;
+ DEBUG_PRINT_LOW("Operating Rate Set = %d fps", rate >> 16);
+ return true;
+}
+
bool venc_dev::venc_get_profile_level(OMX_U32 *eProfile,OMX_U32 *eLevel)
{
bool status = true;