diff --git a/mm-video-v4l2/vidc/vdec/inc/omx_vdec.h b/mm-video-v4l2/vidc/vdec/inc/omx_vdec.h index ed39edb8..a8c2f522 100644 --- a/mm-video-v4l2/vidc/vdec/inc/omx_vdec.h +++ b/mm-video-v4l2/vidc/vdec/inc/omx_vdec.h @@ -1250,10 +1250,18 @@ class omx_vdec: public qc_omx_component OMX_U32 bytes); OMX_ERRORTYPE free_output_buffer(OMX_BUFFERHEADERTYPE *bufferHdr); bool is_color_conversion_enabled() {return enabled;} + bool is_client_buffers_disabled() {return client_buffers_disabled;} + void set_client_buffers_disabled(bool val) {client_buffers_disabled = val;} + // Returns a specific C2D state, if true current buffers should undergo C2D conversion + // otherwise C2D is in quasi enabled state where in C2D src and dst formats are set but + // color conversion doesnt take place. This state is needed to handle color conversion + // of interlaced clips during port reconfig. + bool client_buffers_invalid() {return (!enabled || client_buffers_disabled);} private: #define MAX_COUNT MAX_NUM_INPUT_OUTPUT_BUFFERS omx_vdec *omx; bool enabled; + bool client_buffers_disabled; OMX_COLOR_FORMATTYPE ColorFormat; void init_members(); bool color_convert_mode; diff --git a/mm-video-v4l2/vidc/vdec/src/omx_vdec_v4l2.cpp b/mm-video-v4l2/vidc/vdec/src/omx_vdec_v4l2.cpp index 9ff88dd4..a128afea 100644 --- a/mm-video-v4l2/vidc/vdec/src/omx_vdec_v4l2.cpp +++ b/mm-video-v4l2/vidc/vdec/src/omx_vdec_v4l2.cpp @@ -2020,7 +2020,7 @@ int omx_vdec::log_input_buffers(const char *buffer_addr, int buffer_len, uint64_ } int omx_vdec::log_cc_output_buffers(OMX_BUFFERHEADERTYPE *buffer) { - if (!client_buffers.is_color_conversion_enabled() || + if (client_buffers.client_buffers_invalid() || !m_debug.out_cc_buffer_log || !buffer || !buffer->nFilledLen) return 0; @@ -2407,6 +2407,8 @@ OMX_ERRORTYPE omx_vdec::component_init(OMX_STRING role) eRet = OMX_ErrorInvalidComponentName; } + m_progressive = MSM_VIDC_PIC_STRUCT_PROGRESSIVE; + if (eRet == OMX_ErrorNone) { OMX_COLOR_FORMATTYPE dest_color_format; if (m_disable_ubwc_mode) { @@ -2426,7 +2428,6 @@ OMX_ERRORTYPE omx_vdec::component_init(OMX_STRING role) } dpb_bit_depth = MSM_VIDC_BIT_DEPTH_8; - m_progressive = MSM_VIDC_PIC_STRUCT_PROGRESSIVE; is_flexible_format = FALSE; if (m_disable_ubwc_mode) { @@ -3689,10 +3690,26 @@ OMX_ERRORTYPE omx_vdec::get_parameter(OMX_IN OMX_HANDLETYPE hComp, OMX_PARAM_PORTDEFINITIONTYPE *portDefn = (OMX_PARAM_PORTDEFINITIONTYPE *) paramData; DEBUG_PRINT_LOW("get_parameter: OMX_IndexParamPortDefinition"); + + OMX_COLOR_FORMATTYPE drv_color_format; + bool status = false; + + if (in_reconfig && !client_buffers.is_color_conversion_enabled()) { + status = client_buffers.get_color_format(drv_color_format); + } + if (decide_dpb_buffer_mode(is_down_scalar_enabled)) { DEBUG_PRINT_ERROR("%s:decide_dpb_buffer_mode failed", __func__); return OMX_ErrorBadParameter; } + + if (in_reconfig && status) { + if (!client_buffers.is_color_conversion_enabled()) { + client_buffers.set_client_buffers_disabled(true); + client_buffers.set_color_format(drv_color_format); + } + } + eRet = update_portdef(portDefn); if (eRet == OMX_ErrorNone) m_port_def = *portDefn; @@ -12112,6 +12129,7 @@ OMX_ERRORTYPE omx_vdec::handle_demux_data(OMX_BUFFERHEADERTYPE *p_buf_hdr) omx_vdec::allocate_color_convert_buf::allocate_color_convert_buf() { enabled = false; + client_buffers_disabled = false; omx = NULL; init_members(); ColorFormat = OMX_COLOR_FormatMax; @@ -12212,7 +12230,8 @@ bool omx_vdec::allocate_color_convert_buf::update_buffer_req() if (status != false) { if (omx->drv_ctx.output_format != VDEC_YUV_FORMAT_NV12 && (ColorFormat != OMX_COLOR_FormatYUV420Planar && - ColorFormat != OMX_COLOR_FormatYUV420SemiPlanar)) { + ColorFormat != OMX_COLOR_FormatYUV420SemiPlanar && + ColorFormat != (OMX_COLOR_FORMATTYPE)QOMX_COLOR_FORMATYUV420PackedSemiPlanar32m)) { DEBUG_PRINT_ERROR("update_buffer_req: Unsupported color conversion"); status = false; } else { @@ -12293,9 +12312,17 @@ bool omx_vdec::allocate_color_convert_buf::set_color_format( if (status && drv_colorformat_c2d_enable && dest_color_format_c2d_enable) { DEBUG_PRINT_LOW("Enabling C2D"); if (dest_color_format == OMX_COLOR_FormatYUV420Planar || - dest_color_format == OMX_COLOR_FormatYUV420SemiPlanar ) { + dest_color_format == OMX_COLOR_FormatYUV420SemiPlanar || + (omx->m_progressive != MSM_VIDC_PIC_STRUCT_PROGRESSIVE && + dest_color_format == (OMX_COLOR_FORMATTYPE)QOMX_COLOR_FORMATYUV420PackedSemiPlanar32m)) { ColorFormat = dest_color_format; - dest_format = dest_color_format == OMX_COLOR_FormatYUV420Planar? YCbCr420P: YCbCr420SP; + if (dest_color_format == OMX_COLOR_FormatYUV420Planar) { + dest_format = YCbCr420P; + } else if( dest_color_format == OMX_COLOR_FormatYUV420SemiPlanar) { + dest_format = YCbCr420SP; + } else { + dest_format = NV12_128m; + } enabled = true; } else { DEBUG_PRINT_ERROR("Unsupported output color format for c2d (%d)", @@ -12316,7 +12343,7 @@ OMX_BUFFERHEADERTYPE* omx_vdec::allocate_color_convert_buf::get_il_buf_hdr() DEBUG_PRINT_ERROR("Invalid param get_buf_hdr"); return NULL; } - if (!enabled) + if (client_buffers_invalid()) return omx->m_out_mem_ptr; return m_out_mem_ptr_client; } @@ -12328,7 +12355,7 @@ OMX_BUFFERHEADERTYPE* omx_vdec::allocate_color_convert_buf::get_il_buf_hdr() DEBUG_PRINT_ERROR("Invalid param get_buf_hdr"); return NULL; } - if (!enabled) + if (client_buffers_invalid()) return bufadd; unsigned index = 0; @@ -12374,7 +12401,7 @@ OMX_BUFFERHEADERTYPE* omx_vdec::allocate_color_convert_buf::get_il_buf_hdr() DEBUG_PRINT_ERROR("Invalid param get_buf_hdr"); return NULL; } - if (!enabled) + if (client_buffers_invalid()) return bufadd; unsigned index = 0; index = bufadd - m_out_mem_ptr_client; @@ -12440,7 +12467,7 @@ OMX_ERRORTYPE omx_vdec::allocate_color_convert_buf::free_output_buffer( { unsigned int index = 0; - if (!enabled) + if (client_buffers_invalid()) return omx->free_output_buffer(bufhdr); if (enabled && omx->is_component_secure()) return OMX_ErrorNone; @@ -12498,6 +12525,8 @@ OMX_ERRORTYPE omx_vdec::allocate_color_convert_buf::allocate_buffers_color_conve DEBUG_PRINT_ERROR("Actual count err in allocate_buffers_color_convert"); return OMX_ErrorInsufficientResources; } + + client_buffers_disabled = false; OMX_BUFFERHEADERTYPE *temp_bufferHdr = NULL; eRet = omx->allocate_output_buffer(hComp,&temp_bufferHdr, port,appData,omx->drv_ctx.op_buf.buffer_size); @@ -12583,10 +12612,12 @@ bool omx_vdec::allocate_color_convert_buf::get_color_format(OMX_COLOR_FORMATTYPE } } else { if (ColorFormat == OMX_COLOR_FormatYUV420Planar || - ColorFormat == OMX_COLOR_FormatYUV420SemiPlanar) { + ColorFormat == OMX_COLOR_FormatYUV420SemiPlanar || + ColorFormat == (OMX_COLOR_FORMATTYPE) QOMX_COLOR_FORMATYUV420PackedSemiPlanar32m) { dest_color_format = ColorFormat; - } else + } else { status = false; + } } return status; }