diff options
author | Steve Kondik <steve@cyngn.com> | 2015-02-02 23:23:50 -0800 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-02-02 23:23:50 -0800 |
commit | df7cca649246eae27a464d835c64cfa3c017e1ae (patch) | |
tree | 858a1cf62ab3934ca0fc5ddbbb76b2d07fc51f33 | |
parent | c8b6d5ceaf831f7b0ba551687eaa099b05cdb156 (diff) | |
parent | 8445212133cbf17621015a8befde24d02354e896 (diff) | |
download | android_hardware_qcom_media-df7cca649246eae27a464d835c64cfa3c017e1ae.tar.gz android_hardware_qcom_media-df7cca649246eae27a464d835c64cfa3c017e1ae.tar.bz2 android_hardware_qcom_media-df7cca649246eae27a464d835c64cfa3c017e1ae.zip |
Merge branch 'LA.BR.1.2.1_rb2.12' of git://codeaurora.org/platform/hardware/qcom/media into cm-12.0stable/cm-12.0-caf-8916-YNG4Nstable/cm-12.0-caf-8916-YNG3Cstable/cm-12.0-caf-8916-YNG1TAstable/cm-12.0-caf-8916-YNG1Tcm-12.0-caf-8916
-rw-r--r-- | mm-video-v4l2/vidc/vdec/src/omx_vdec_hevc_swvdec.cpp | 50 | ||||
-rw-r--r-- | mm-video-v4l2/vidc/vdec/src/omx_vdec_msm8974.cpp | 65 | ||||
-rw-r--r-- | mm-video-v4l2/vidc/venc/Android.mk | 8 | ||||
-rw-r--r-- | mm-video-v4l2/vidc/venc/inc/omx_swvenc_mpeg4.h | 4 | ||||
-rw-r--r-- | mm-video-v4l2/vidc/venc/inc/video_encoder_device_v4l2.h | 6 | ||||
-rw-r--r-- | mm-video-v4l2/vidc/venc/src/omx_swvenc_mpeg4.cpp | 57 | ||||
-rw-r--r-- | mm-video-v4l2/vidc/venc/src/omx_video_base.cpp | 4 | ||||
-rw-r--r-- | mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp | 37 |
8 files changed, 167 insertions, 64 deletions
diff --git a/mm-video-v4l2/vidc/vdec/src/omx_vdec_hevc_swvdec.cpp b/mm-video-v4l2/vidc/vdec/src/omx_vdec_hevc_swvdec.cpp index 4c88661a..0e83cf6b 100644 --- a/mm-video-v4l2/vidc/vdec/src/omx_vdec_hevc_swvdec.cpp +++ b/mm-video-v4l2/vidc/vdec/src/omx_vdec_hevc_swvdec.cpp @@ -999,6 +999,32 @@ void omx_vdec::process_event_cb(void *ctxt, unsigned char id) if (pThis->m_pSwVdec) { + if (pThis->in_reconfig) { + pThis->in_reconfig = false; + SWVDEC_PROP prop; + DEBUG_PRINT_HIGH("swvdec port settings changed"); + + // get_buffer_req and populate port defn structure + prop.ePropId = SWVDEC_PROP_ID_DIMENSIONS; + SwVdec_GetProperty(pThis->m_pSwVdec, &prop); + pThis->update_resolution(prop.uProperty.sDimensions.nWidth, + prop.uProperty.sDimensions.nHeight, + prop.uProperty.sDimensions.nWidth, + prop.uProperty.sDimensions.nHeight); + pThis->drv_ctx.video_resolution.stride = + (prop.uProperty.sDimensions.nWidth + 127) & (~127); + pThis->drv_ctx.video_resolution.scan_lines = + (prop.uProperty.sDimensions.nHeight + 31) & (~31); + + pThis->m_port_def.nPortIndex = 1; + pThis->update_portdef(&pThis->m_port_def); + + //Set property for dimensions and attrb to SwVdec + SwVdec_SetProperty(pThis->m_pSwVdec,&prop); + prop.ePropId = SWVDEC_PROP_ID_FRAME_ATTR; + prop.uProperty.sFrameAttr.eColorFormat = SWVDEC_FORMAT_NV12; + SwVdec_SetProperty(pThis->m_pSwVdec,&prop); + } SWVDEC_STATUS SwStatus; DEBUG_PRINT_HIGH("In port reconfig, SwVdec_Stop"); SwStatus = SwVdec_Stop(pThis->m_pSwVdec); @@ -10772,31 +10798,7 @@ void omx_vdec::swvdec_handle_event(SWVDEC_EVENTHANDLER *pEvent) case SWVDEC_RECONFIG_INSUFFICIENT_RESOURCES: { - SWVDEC_PROP prop; - DEBUG_PRINT_HIGH("swvdec port settings changed"); in_reconfig = true; - // get_buffer_req and populate port defn structure - prop.ePropId = SWVDEC_PROP_ID_DIMENSIONS; - SwVdec_GetProperty(m_pSwVdec, &prop); - - update_resolution(prop.uProperty.sDimensions.nWidth, - prop.uProperty.sDimensions.nHeight, - prop.uProperty.sDimensions.nWidth, - prop.uProperty.sDimensions.nHeight); - drv_ctx.video_resolution.stride = - (prop.uProperty.sDimensions.nWidth + 127) & (~127); - drv_ctx.video_resolution.scan_lines = - (prop.uProperty.sDimensions.nHeight + 31) & (~31); - - m_port_def.nPortIndex = 1; - update_portdef(&m_port_def); - - //Set property for dimensions and attrb to SwVdec - SwVdec_SetProperty(m_pSwVdec,&prop); - prop.ePropId = SWVDEC_PROP_ID_FRAME_ATTR; - prop.uProperty.sFrameAttr.eColorFormat = SWVDEC_FORMAT_NV12; - SwVdec_SetProperty(m_pSwVdec,&prop); - post_event (OMX_CORE_OUTPUT_PORT_INDEX, OMX_IndexParamPortDefinition, OMX_COMPONENT_GENERATE_PORT_RECONFIG); } 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 e386a3c4..9a4086ce 100644 --- a/mm-video-v4l2/vidc/vdec/src/omx_vdec_msm8974.cpp +++ b/mm-video-v4l2/vidc/vdec/src/omx_vdec_msm8974.cpp @@ -1,5 +1,5 @@ /*-------------------------------------------------------------------------- -Copyright (c) 2010 - 2014, The Linux Foundation. All rights reserved. +Copyright (c) 2010 - 2015, The Linux Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -54,6 +54,7 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <stdlib.h> #include <media/hardware/HardwareAPI.h> #include <media/msm_media_info.h> +#include <OMX_VideoExt.h> #ifndef _ANDROID_ #include <sys/ioctl.h> @@ -1325,6 +1326,10 @@ void omx_vdec::process_event_cb(void *ctxt, unsigned char id) DEBUG_PRINT_ERROR("Rxd Invalid PORT_RECONFIG event (%lu)", p2); break; } + if (pThis->m_debug.outfile) { + fclose(pThis->m_debug.outfile); + pThis->m_debug.outfile = NULL; + } if (pThis->m_cb.EventHandler) { pThis->m_cb.EventHandler(&pThis->m_cmp, pThis->m_app_data, OMX_EventPortSettingsChanged, p1, p2, NULL ); @@ -2874,9 +2879,14 @@ OMX_ERRORTYPE omx_vdec::get_supported_profile_level_for_1080p(OMX_VIDEO_PARAM_PR eRet = OMX_ErrorNoMore; } } else if (!strncmp(drv_ctx.kind, "OMX.qcom.video.decoder.hevc", OMX_MAX_STRINGNAME_SIZE)) { + if (profileLevelType->nProfileIndex == 0) { + profileLevelType->eProfile = OMX_VIDEO_HEVCProfileMain; + profileLevelType->eLevel = OMX_VIDEO_HEVCMainTierLevel41; + } else { DEBUG_PRINT_LOW("get_parameter: OMX_IndexParamVideoProfileLevelQuerySupported nProfileIndex ret NoMore %u", (unsigned int)profileLevelType->nProfileIndex); eRet = OMX_ErrorNoMore; + } } else if ((!strncmp(drv_ctx.kind, "OMX.qcom.video.decoder.h263",OMX_MAX_STRINGNAME_SIZE))) { if (profileLevelType->nProfileIndex == 0) { profileLevelType->eProfile = OMX_VIDEO_H263ProfileBaseline; @@ -6250,16 +6260,17 @@ if (buffer->nFlags & QOMX_VIDEO_BUFFERFLAG_EOSEQ) { buf.flags |= (buffer->nFlags & OMX_BUFFERFLAG_CODECCONFIG) ? V4L2_QCOM_BUF_FLAG_CODECCONFIG: 0; buf.flags |= (buffer->nFlags & OMX_BUFFERFLAG_DECODEONLY) ? V4L2_QCOM_BUF_FLAG_DECODEONLY: 0; + if (buffer->nFlags & OMX_BUFFERFLAG_CODECCONFIG) { + DEBUG_PRINT_LOW("Increment codec_config buffer counter"); + android_atomic_inc(&m_queued_codec_config_count); + } + rc = ioctl(drv_ctx.video_driver_fd, VIDIOC_QBUF, &buf); if (rc) { DEBUG_PRINT_ERROR("Failed to qbuf Input buffer to driver"); return OMX_ErrorHardware; } - if (buffer->nFlags & OMX_BUFFERFLAG_CODECCONFIG) { - android_atomic_inc(&m_queued_codec_config_count); - } - if (codec_config_flag && !(buffer->nFlags & OMX_BUFFERFLAG_CODECCONFIG)) { codec_config_flag = false; } @@ -7293,19 +7304,6 @@ OMX_ERRORTYPE omx_vdec::empty_buffer_done(OMX_HANDLETYPE hComp, DEBUG_PRINT_LOW("empty_buffer_done: bufhdr = %p, bufhdr->pBuffer = %p, bufhdr->nFlags = %x", buffer, buffer->pBuffer, buffer->nFlags); pending_input_buffers--; - if (buffer->nFlags & OMX_BUFFERFLAG_CODECCONFIG) { - int pending_flush_waiters; - - while (pending_flush_waiters = INT_MAX, - sem_getvalue(&m_safe_flush, &pending_flush_waiters), - /* 0 == there /are/ waiters depending on POSIX implementation */ - pending_flush_waiters <= 0 ) { - DEBUG_PRINT_LOW("sem post for %d EBD of CODEC CONFIG buffer", m_queued_codec_config_count); - sem_post(&m_safe_flush); - } - - android_atomic_and(0, &m_queued_codec_config_count); /* no clearer way to set to 0 */ - } if (arbitrary_bytes) { if (pdest_frame == NULL && input_flush_progress == false) { @@ -7414,6 +7412,21 @@ int omx_vdec::async_message_process (void *context, void* message) omxhdr->nFlags |= OMX_BUFFERFLAG_DATACORRUPT; vdec_msg->status_code = VDEC_S_INPUT_BITSTREAM_ERR; } + if (omxhdr->nFlags & OMX_BUFFERFLAG_CODECCONFIG) { + int pending_flush_waiters; + + while (pending_flush_waiters = INT_MAX, + sem_getvalue(&omx->m_safe_flush, &pending_flush_waiters), + /* 0 == there /are/ waiters depending on POSIX implementation */ + pending_flush_waiters <= 0 ) { + DEBUG_PRINT_LOW("sem post for %d EBD of CODEC CONFIG buffer", + omx->m_queued_codec_config_count); + sem_post(&omx->m_safe_flush); + } + DEBUG_PRINT_LOW("Reset codec_config buffer counter"); + android_atomic_and(0, &omx->m_queued_codec_config_count); /* no clearer way to set to 0 */ + } + omx->post_event ((unsigned long)omxhdr,vdec_msg->status_code, OMX_COMPONENT_GENERATE_EBD); break; @@ -7533,7 +7546,12 @@ int omx_vdec::async_message_process (void *context, void* message) vdec_msg->msgdata.output_frame.picsize.frame_width; omx->drv_ctx.video_resolution.frame_height = vdec_msg->msgdata.output_frame.picsize.frame_height; - + if (omx->drv_ctx.output_format == VDEC_YUV_FORMAT_NV12) { + omx->drv_ctx.video_resolution.stride = + VENUS_Y_STRIDE(COLOR_FMT_NV12, omx->drv_ctx.video_resolution.frame_width); + omx->drv_ctx.video_resolution.scan_lines = + VENUS_Y_SCANLINES(COLOR_FMT_NV12, omx->drv_ctx.video_resolution.frame_height); + } memcpy(&omx->drv_ctx.frame_size, &vdec_msg->msgdata.output_frame.framesize, sizeof(struct vdec_framesize)); @@ -8619,11 +8637,11 @@ OMX_ERRORTYPE omx_vdec::set_buffer_req(vdec_allocatorproperty *buffer_prop) memset(&fmt, 0x0, sizeof(struct v4l2_format)); fmt.fmt.pix_mp.height = drv_ctx.video_resolution.frame_height; fmt.fmt.pix_mp.width = drv_ctx.video_resolution.frame_width; + fmt.fmt.pix_mp.plane_fmt[0].sizeimage = buf_size; if (buffer_prop->buffer_type == VDEC_BUFFER_TYPE_INPUT) { fmt.type =V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; fmt.fmt.pix_mp.pixelformat = output_capability; - fmt.fmt.pix_mp.plane_fmt[0].sizeimage = buf_size; } else if (buffer_prop->buffer_type == VDEC_BUFFER_TYPE_OUTPUT) { fmt.type =V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; fmt.fmt.pix_mp.pixelformat = capture_capability; @@ -8758,8 +8776,10 @@ OMX_ERRORTYPE omx_vdec::update_portdef(OMX_PARAM_PORTDEFINITIONTYPE *portDefn) if ((portDefn->format.video.eColorFormat == OMX_COLOR_FormatYUV420Planar) || (portDefn->format.video.eColorFormat == OMX_COLOR_FormatYUV420SemiPlanar)) { - portDefn->format.video.nStride = ALIGN(drv_ctx.video_resolution.frame_width, 16); - portDefn->format.video.nSliceHeight = drv_ctx.video_resolution.frame_height; + portDefn->format.video.nStride = VENUS_Y_STRIDE(COLOR_FMT_NV12, + drv_ctx.video_resolution.frame_width); + portDefn->format.video.nSliceHeight = VENUS_Y_SCANLINES(COLOR_FMT_NV12, + drv_ctx.video_resolution.frame_height); } DEBUG_PRINT_HIGH("update_portdef(%u): Width = %u Height = %u Stride = %d " "SliceHeight = %u eColorFormat = %d nBufSize %u nBufCnt %u", @@ -10598,6 +10618,7 @@ OMX_ERRORTYPE omx_vdec::enable_adaptive_playback(unsigned long nMaxFrameWidth, drv_ctx.op_buf.mincount = min_res_buf_count; drv_ctx.op_buf.actualcount = min_res_buf_count; + drv_ctx.op_buf.buffer_size = drv_ctx.op_buf.buffer_size; eRet = set_buffer_req(&drv_ctx.op_buf); if (eRet != OMX_ErrorNone) { DEBUG_PRINT_ERROR("failed to set_buffer_req"); diff --git a/mm-video-v4l2/vidc/venc/Android.mk b/mm-video-v4l2/vidc/venc/Android.mk index 2f3564a1..bf7c2ae6 100644 --- a/mm-video-v4l2/vidc/venc/Android.mk +++ b/mm-video-v4l2/vidc/venc/Android.mk @@ -21,7 +21,7 @@ libmm-venc-def += -Werror libmm-venc-def += -D_ANDROID_ICS_ libmm-venc-def += -D_MSM8974_ -TARGETS_THAT_USE_FLAG_MSM8226 := msm8226 msm8916 msm8909 +TARGETS_THAT_USE_FLAG_MSM8226 := msm8226 msm8916 TARGETS_THAT_NEED_SW_VENC_MPEG4 := msm8909 TARGETS_THAT_NEED_SW_VENC_HEVC := msm8992 @@ -41,6 +41,10 @@ ifeq ($(call is-board-platform-in-list, $(TARGETS_THAT_USE_FLAG_MSM8226)),true) libmm-venc-def += -D_MSM8226_ endif +ifeq ($(TARGET_BOARD_PLATFORM),msm8909) +libmm-venc-def += -D_MSM8909_ +endif + ifeq ($(TARGET_USES_ION),true) libmm-venc-def += -DUSE_ION endif @@ -84,6 +88,7 @@ LOCAL_SRC_FILES += src/video_encoder_device_v4l2.cpp include $(BUILD_SHARED_LIBRARY) +ifeq ($(BOARD_USES_QCOM_HARDWARE),true) ifeq ($(call is-board-platform-in-list, $(TARGETS_THAT_NEED_SW_VENC_MPEG4)),true) # --------------------------------------------------------------------------------- # Make the Shared library (libOmxSwVencMpeg4) @@ -111,6 +116,7 @@ LOCAL_SRC_FILES += src/omx_swvenc_mpeg4.cpp include $(BUILD_SHARED_LIBRARY) endif +endif ifeq ($(call is-board-platform-in-list, $(TARGETS_THAT_NEED_SW_VENC_HEVC)),true) # --------------------------------------------------------------------------------- diff --git a/mm-video-v4l2/vidc/venc/inc/omx_swvenc_mpeg4.h b/mm-video-v4l2/vidc/venc/inc/omx_swvenc_mpeg4.h index ec2fc32f..63c8da76 100644 --- a/mm-video-v4l2/vidc/venc/inc/omx_swvenc_mpeg4.h +++ b/mm-video-v4l2/vidc/venc/inc/omx_swvenc_mpeg4.h @@ -84,6 +84,10 @@ class omx_venc: public omx_video SWVENC_IPBUFFER *p_ipbuffer, void *p_client ); + SWVENC_STATUS swvenc_empty_buffer_done + ( + SWVENC_IPBUFFER *p_ipbuffer + ); static SWVENC_STATUS swvenc_fill_buffer_done_cb ( SWVENC_HANDLE swvenc, 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 0cbbbb27..ed79eb4c 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 @@ -224,6 +224,12 @@ struct extradata_buffer_info { #endif }; +struct statistics { + struct timeval prev_tv; + int prev_fbd; + int bytes_generated; +}; + enum rc_modes { RC_VBR_VFR = BIT(0), RC_VBR_CFR = BIT(1), diff --git a/mm-video-v4l2/vidc/venc/src/omx_swvenc_mpeg4.cpp b/mm-video-v4l2/vidc/venc/src/omx_swvenc_mpeg4.cpp index e1082978..e2e52e1f 100644 --- a/mm-video-v4l2/vidc/venc/src/omx_swvenc_mpeg4.cpp +++ b/mm-video-v4l2/vidc/venc/src/omx_swvenc_mpeg4.cpp @@ -2326,30 +2326,69 @@ SWVENC_STATUS omx_venc::swvenc_empty_buffer_done_cb { ENTER_FUNC(); + (void)swvenc; + SWVENC_STATUS eRet = SWVENC_S_SUCCESS; + omx_venc *omx = reinterpret_cast<omx_venc*>(p_client); + + if (p_ipbuffer == NULL) + { + eRet = SWVENC_S_FAILURE; + } + else + { + omx->swvenc_empty_buffer_done(p_ipbuffer); + } + return eRet; +} + +SWVENC_STATUS omx_venc::swvenc_empty_buffer_done +( + SWVENC_IPBUFFER *p_ipbuffer +) +{ SWVENC_STATUS eRet = SWVENC_S_SUCCESS; OMX_ERRORTYPE error = OMX_ErrorNone; OMX_BUFFERHEADERTYPE* omxhdr = NULL; - omx_video *omx = reinterpret_cast<omx_video*>(p_client); - - (void)swvenc; + //omx_video *omx = reinterpret_cast<omx_video*>(p_client); omxhdr = (OMX_BUFFERHEADERTYPE*)p_ipbuffer->p_client_data; DEBUG_PRINT_LOW("EBD: clientData (%p)", p_ipbuffer->p_client_data); if ( (omxhdr == NULL) || - ( ((OMX_U32)(omxhdr - omx->m_inp_mem_ptr) > omx->m_sInPortDef.nBufferCountActual) && - ((OMX_U32)(omxhdr - omx->meta_buffer_hdr) > omx->m_sInPortDef.nBufferCountActual) + ( ((OMX_U32)(omxhdr - m_inp_mem_ptr) >m_sInPortDef.nBufferCountActual) && + ((OMX_U32)(omxhdr - meta_buffer_hdr) >m_sInPortDef.nBufferCountActual) ) ) { omxhdr = NULL; error = OMX_ErrorUndefined; } - - omx->omx_release_meta_buffer(omxhdr); - - omx->post_event ((unsigned long)omxhdr,error,OMX_COMPONENT_GENERATE_EBD); + // unmap the input buffer->pBuffer + omx_release_meta_buffer(omxhdr); +#ifdef _ANDROID_ICS_ + if (meta_mode_enable) + { + encoder_media_buffer_type *meta_buf = NULL; + unsigned int size = 0; + meta_buf = (encoder_media_buffer_type *)omxhdr->pBuffer; + if (meta_buf) + { + if (meta_buf->buffer_type == kMetadataBufferTypeCameraSource) + { + size = meta_buf->meta_handle->data[2]; + } + else if (meta_buf->buffer_type == kMetadataBufferTypeGrallocSource) + { + private_handle_t *handle = (private_handle_t *)meta_buf->meta_handle; + size = handle->size; + } + } + int status = munmap(p_ipbuffer->p_buffer, size); + DEBUG_PRINT_HIGH("Unmapped pBuffer <%p> size <%d> status <%d>", p_ipbuffer->p_buffer, size, status); + } +#endif + post_event ((unsigned long)omxhdr,error,OMX_COMPONENT_GENERATE_EBD); RETURN(eRet); } diff --git a/mm-video-v4l2/vidc/venc/src/omx_video_base.cpp b/mm-video-v4l2/vidc/venc/src/omx_video_base.cpp index 875c7955..fb49db2b 100644 --- a/mm-video-v4l2/vidc/venc/src/omx_video_base.cpp +++ b/mm-video-v4l2/vidc/venc/src/omx_video_base.cpp @@ -4121,7 +4121,7 @@ void omx_video::complete_pending_buffer_done_cbs() } } -#ifdef MAX_RES_720P +#if defined(MAX_RES_720P) || defined(_MSM8909_) OMX_ERRORTYPE omx_video::get_supported_profile_level(OMX_VIDEO_PARAM_PROFILELEVELTYPE *profileLevelType) { OMX_ERRORTYPE eRet = OMX_ErrorNone; @@ -4174,7 +4174,7 @@ OMX_ERRORTYPE omx_video::get_supported_profile_level(OMX_VIDEO_PARAM_PROFILELEVE } #endif -#ifdef MAX_RES_1080P +#if defined(MAX_RES_1080P) && !defined(_MSM8909_) OMX_ERRORTYPE omx_video::get_supported_profile_level(OMX_VIDEO_PARAM_PROFILELEVELTYPE *profileLevelType) { OMX_ERRORTYPE eRet = OMX_ErrorNone; 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 5dcaebf5..d4cf21c1 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 @@ -56,8 +56,8 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define MPEG4_ASP_START (MPEG4_SP_START + 10) #define H263_BP_START 0 #define H264_BP_START 0 -#define H264_HP_START (H264_BP_START + 17) -#define H264_MP_START (H264_BP_START + 34) +#define H264_HP_START (H264_BP_START + 18) +#define H264_MP_START (H264_BP_START + 36) #define HEVC_MAIN_START 0 #define HEVC_MAIN10_START (HEVC_MAIN_START + 12) #define POLL_TIMEOUT 1000 @@ -66,6 +66,8 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define SZ_4K 0x1000 #define SZ_1M 0x100000 +#define METADATA_INPUT_BUFFER_COUNT 5 + /* MPEG4 profile and level table*/ static const unsigned int mpeg4_profile_level_table[][MAX_PROFILE_PARAMS]= { /*max mb per frame, max mb per sec, max bitrate, level, profile, dpbmbs*/ @@ -284,10 +286,12 @@ void* venc_dev::async_venc_message_thread (void *input) struct pollfd pfd; struct v4l2_buffer v4l2_buf; struct v4l2_event dqevent; + struct statistics stats; pfd.events = POLLIN | POLLRDNORM | POLLOUT | POLLWRNORM | POLLRDBAND | POLLPRI; pfd.fd = omx->handle->m_nDriver_fd; int error_code = 0,rc=0; + memset(&stats, 0, sizeof(statistics)); memset(&v4l2_buf, 0, sizeof(v4l2_buf)); while (1) { @@ -315,6 +319,7 @@ void* venc_dev::async_venc_message_thread (void *input) pthread_mutex_unlock(&omx->handle->pause_resume_mlock); break; } + memset(&stats, 0, sizeof(statistics)); } pthread_mutex_unlock(&omx->handle->pause_resume_mlock); @@ -370,6 +375,7 @@ void* venc_dev::async_venc_message_thread (void *input) venc_msg.buf.flags |= OMX_BUFFERFLAG_ENDOFFRAME; omx->handle->fbd++; + stats.bytes_generated += venc_msg.buf.len; if (omx->async_message_process(input,&venc_msg) < 0) { DEBUG_PRINT_ERROR("ERROR: Wrong ioctl message"); @@ -444,6 +450,25 @@ void* venc_dev::async_venc_message_thread (void *input) } } } + + /* calc avg. fps, bitrate */ + struct timeval tv; + gettimeofday(&tv,NULL); + OMX_U64 time_diff = (OMX_U32)((tv.tv_sec * 1000000 + tv.tv_usec) - + (stats.prev_tv.tv_sec * 1000000 + stats.prev_tv.tv_usec)); + if (time_diff >= 5000000) { + if (stats.prev_tv.tv_sec) { + OMX_U32 num_fbd = omx->handle->fbd - stats.prev_fbd; + float framerate = num_fbd * 1000000/(float)time_diff; + OMX_U32 bitrate = (stats.bytes_generated * 8/num_fbd) * framerate; + DEBUG_PRINT_HIGH("stats: avg. fps %0.2f, bitrate %d", + framerate, bitrate); + } + stats.prev_tv = tv; + stats.bytes_generated = 0; + stats.prev_fbd = omx->handle->fbd; + } + } DEBUG_PRINT_HIGH("omx_venc: Async Thread exit"); @@ -1169,10 +1194,10 @@ bool venc_dev::venc_get_buf_req(OMX_U32 *min_buff_count, // Increase buffer-header count for metadata-mode on input port // to improve buffering and reduce bottlenecks in clients - if (metadatamode && (bufreq.count < 9)) { - DEBUG_PRINT_LOW("FW returned buffer count = %d , overwriting with 16", - bufreq.count); - bufreq.count = 9; + if (metadatamode && (bufreq.count < METADATA_INPUT_BUFFER_COUNT)) { + DEBUG_PRINT_LOW("FW returned buffer count = %d , overwriting with %d", + bufreq.count, METADATA_INPUT_BUFFER_COUNT); + bufreq.count = METADATA_INPUT_BUFFER_COUNT; } bufreq.type=V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |