diff options
| author | Arun Menon <avmenon@codeaurora.org> | 2013-08-29 18:16:51 +0800 |
|---|---|---|
| committer | Vineeta Srivastava <vsrivastava@google.com> | 2013-11-12 12:55:53 -0800 |
| commit | 2e277fbebd51de1d4f029f7950ed2a98731177dc (patch) | |
| tree | a144ae8914ffbab417b3720fc05b3b8e73708a97 | |
| parent | 9051a9833db84a4dad38adebc94fdb0861ae3b94 (diff) | |
| download | android_hardware_qcom_media-2e277fbebd51de1d4f029f7950ed2a98731177dc.tar.gz android_hardware_qcom_media-2e277fbebd51de1d4f029f7950ed2a98731177dc.tar.bz2 android_hardware_qcom_media-2e277fbebd51de1d4f029f7950ed2a98731177dc.zip | |
mm-video: venc: switch between executing and loaded.
when the v4l2 modules stopped, it will free all output
and input buffers. So when it is re-started again,
re-do the VIDIOC_REQBUFS command again.
b/11051201
Signed-off: Kim Zhang<xiazhang@codeaurora.org>
Change-Id: I7c6de237fdd7476ca4ebc7d1f1016e86f3af9d95
| -rwxr-xr-x | mm-video-v4l2/vidc/venc/inc/video_encoder_device_v4l2.h | 3 | ||||
| -rwxr-xr-x | mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp | 35 |
2 files changed, 37 insertions, 1 deletions
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 7b4b250f..557ba2c3 100755 --- a/mm-video-v4l2/vidc/venc/inc/video_encoder_device_v4l2.h +++ b/mm-video-v4l2/vidc/venc/inc/video_encoder_device_v4l2.h @@ -251,6 +251,7 @@ class venc_dev }; int stopped; + int resume_in_stopped; bool m_max_allowed_bitrate_check; pthread_t m_tid; bool async_thread_created; @@ -300,6 +301,8 @@ class venc_dev bool venc_set_slice_delivery_mode(OMX_U32 enable); bool venc_set_extradata(OMX_U32 extra_data); bool venc_set_idr_period(OMX_U32 nPFrames, OMX_U32 nIDRPeriod); + bool venc_reconfig_reqbufs(); + #ifdef MAX_RES_1080P OMX_U32 pmem_free(); OMX_U32 pmem_allocate(OMX_U32 size, OMX_U32 alignment, OMX_U32 count); 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 98443b76..7dcfcb44 100755 --- a/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp +++ b/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp @@ -677,6 +677,7 @@ bool venc_dev::venc_open(OMX_U32 codec) m_sOutput_buff_property.mincount = m_sOutput_buff_property.actualcount = bufreq.count; + resume_in_stopped = 0; metadatamode = 0; control.id = V4L2_CID_MPEG_VIDEO_HEADER_MODE; @@ -1491,6 +1492,9 @@ unsigned venc_dev::venc_stop( void) if (!rc && !ret) { venc_stop_done(); stopped = 1; + /*set flag to re-configure when started again*/ + resume_in_stopped = 1; + } } @@ -1558,6 +1562,12 @@ unsigned venc_dev::venc_start(void) venc_config_print(); + if(resume_in_stopped){ + /*set buffercount when restarted*/ + venc_reconfig_reqbufs(); + resume_in_stopped = 0; + } + /* Check if slice_delivery mode is enabled & max slices is sufficient for encoding complete frame */ if (slice_mode.enable && multislice.mslice_size && (m_sVenc_cfg.input_width * m_sVenc_cfg.input_height)/(256 * multislice.mslice_size) >= MAX_SUPPORTED_SLICES_PER_FRAME) { @@ -1611,6 +1621,29 @@ void venc_dev::venc_config_print() } +bool venc_dev::venc_reconfig_reqbufs() +{ + struct v4l2_requestbuffers bufreq; + + bufreq.memory = V4L2_MEMORY_USERPTR; + bufreq.count = m_sInput_buff_property.actualcount; + bufreq.type=V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; + if(ioctl(m_nDriver_fd,VIDIOC_REQBUFS, &bufreq)) { + DEBUG_PRINT_ERROR("\n VIDIOC_REQBUFS OUTPUT_MPLANE Failed when resume\n"); + return false; + } + + bufreq.memory = V4L2_MEMORY_USERPTR; + bufreq.count = m_sOutput_buff_property.actualcount; + bufreq.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + if(ioctl(m_nDriver_fd,VIDIOC_REQBUFS, &bufreq)) + { + DEBUG_PRINT_ERROR("\nERROR: Request for setting o/p buffer count failed when resume\n"); + return false; + } + return true; +} + unsigned venc_dev::venc_flush( unsigned port) { struct v4l2_encoder_cmd enc; @@ -2544,7 +2577,7 @@ bool venc_dev::venc_set_entropy_config(OMX_BOOL enable, OMX_U32 i_cabac_level) } DEBUG_PRINT_LOW("Success IOCTL set control for id=%d, value=%d\n", control.id, control.value); - entropy.longentropysel=control.value; + entropy.cabacmodel=control.value; } else if (!enable) { control.value = V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC; control.id = V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE; |
