@@ -622,6 +622,7 @@ omx_vdec::omx_vdec(): m_state(OMX_StateInvalid),
622622 drv_ctx.video_driver_fd = -1 ;
623623 m_vendor_config.pData = NULL ;
624624 pthread_mutex_init (&m_lock, NULL );
625+ pthread_mutex_init (&c_lock, NULL );
625626 sem_init (&m_cmd_lock,0 ,0 );
626627#ifdef _ANDROID_
627628 char extradata_value[PROPERTY_VALUE_MAX] = {0 };
@@ -705,6 +706,7 @@ omx_vdec::~omx_vdec()
705706 drv_ctx.video_driver_fd = -1 ;
706707
707708 pthread_mutex_destroy (&m_lock);
709+ pthread_mutex_destroy (&c_lock);
708710 sem_destroy (&m_cmd_lock);
709711#ifdef _ANDROID_
710712 if (perf_flag)
@@ -2929,6 +2931,9 @@ OMX_ERRORTYPE omx_vdec::get_parameter(OMX_IN OMX_HANDLETYPE hComp,
29292931 portFmt->eColorFormat = (OMX_COLOR_FORMATTYPE)
29302932 QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka;
29312933 else if (1 == portFmt->nIndex ) {
2934+ portFmt->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
2935+ }
2936+ else if (2 == portFmt->nIndex ) {
29322937 portFmt->eColorFormat = OMX_COLOR_FormatYUV420Planar;
29332938 }
29342939 else
@@ -3386,11 +3391,12 @@ OMX_ERRORTYPE omx_vdec::set_parameter(OMX_IN OMX_HANDLETYPE hComp,
33863391 if (1 == portFmt->nPortIndex )
33873392 {
33883393 enum vdec_output_fromat op_format;
3389- if (portFmt-> eColorFormat == OMX_COLOR_FormatYUV420SemiPlanar)
3390- op_format = VDEC_YUV_FORMAT_NV12 ;
3391- else if (portFmt->eColorFormat ==
3394+ DEBUG_PRINT_HIGH ( " Set_parameter: OMX_IndexParamVideoPortFormat: "
3395+ " portFmt->eColorFormat = %d " , portFmt-> eColorFormat ) ;
3396+ if (portFmt->eColorFormat ==
33923397 QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka ||
3393- portFmt->eColorFormat == OMX_COLOR_FormatYUV420Planar)
3398+ portFmt->eColorFormat == OMX_COLOR_FormatYUV420Planar ||
3399+ portFmt->eColorFormat == OMX_COLOR_FormatYUV420SemiPlanar )
33943400 op_format = VDEC_YUV_FORMAT_TILE_4x2;
33953401 else
33963402 eRet = OMX_ErrorBadParameter;
@@ -8511,6 +8517,11 @@ OMX_ERRORTYPE omx_vdec::update_portdef(OMX_PARAM_PORTDEFINITIONTYPE *portDefn)
85118517 portDefn->format .video .nFrameWidth = drv_ctx.video_resolution .frame_width ;
85128518 portDefn->format .video .nStride = drv_ctx.video_resolution .stride ;
85138519 portDefn->format .video .nSliceHeight = drv_ctx.video_resolution .scan_lines ;
8520+ if ((portDefn->format .video .eColorFormat == OMX_COLOR_FormatYUV420Planar) ||
8521+ (portDefn->format .video .eColorFormat == OMX_COLOR_FormatYUV420SemiPlanar)) {
8522+ portDefn->format .video .nStride = drv_ctx.video_resolution .frame_width ;
8523+ portDefn->format .video .nFrameHeight = drv_ctx.video_resolution .frame_height ;
8524+ }
85148525 DEBUG_PRINT_LOW (" update_portdef: PortIndex = %u, Width = %d Height = %d "
85158526 " Stride = %u SliceHeight = %u output format = 0x%x, eColorFormat = 0x%x" ,
85168527 portDefn->nPortIndex ,
@@ -10123,6 +10134,7 @@ omx_vdec::allocate_color_convert_buf::allocate_color_convert_buf()
1012310134 omx = NULL ;
1012410135 init_members ();
1012510136 ColorFormat = OMX_COLOR_FormatMax;
10137+ dest_format = YCbCr420P;
1012610138}
1012710139
1012810140void omx_vdec::allocate_color_convert_buf::set_vdec_client (void *client)
@@ -10165,11 +10177,13 @@ bool omx_vdec::allocate_color_convert_buf::update_buffer_req()
1016510177 DEBUG_PRINT_ERROR (" \n update_buffer_req: Unsupported color conversion" );
1016610178 return false ;
1016710179 }
10180+
10181+ pthread_mutex_lock (&omx->c_lock );
1016810182 c2d.close ();
1016910183
1017010184 status = c2d.open (omx->drv_ctx .video_resolution .frame_height ,
1017110185 omx->drv_ctx .video_resolution .frame_width ,
10172- YCbCr420Tile,YCbCr420P , 0 );
10186+ YCbCr420Tile, dest_format , 0 );
1017310187 if (status) {
1017410188 status = c2d.get_buffer_size (C2D_INPUT,src_size);
1017510189 if (status)
@@ -10192,6 +10206,7 @@ bool omx_vdec::allocate_color_convert_buf::update_buffer_req()
1019210206 buffer_alignment_req = omx->drv_ctx .op_buf .alignment ;
1019310207 }
1019410208 }
10209+ pthread_mutex_unlock (&omx->c_lock );
1019510210 return status;
1019610211}
1019710212
@@ -10204,6 +10219,7 @@ bool omx_vdec::allocate_color_convert_buf::set_color_format(
1020410219 DEBUG_PRINT_ERROR (" \n Invalid client in color convert" );
1020510220 return false ;
1020610221 }
10222+ pthread_mutex_lock (&omx->c_lock );
1020710223 if (omx->drv_ctx .output_format == VDEC_YUV_FORMAT_TILE_4x2)
1020810224 drv_color_format = (OMX_COLOR_FORMATTYPE)
1020910225 QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka;
@@ -10213,11 +10229,14 @@ bool omx_vdec::allocate_color_convert_buf::set_color_format(
1021310229 }
1021410230 if (status && (drv_color_format != dest_color_format)) {
1021510231 DEBUG_PRINT_ERROR (" " );
10216- if (dest_color_format != OMX_COLOR_FormatYUV420Planar) {
10232+ if ((dest_color_format != OMX_COLOR_FormatYUV420Planar) &&
10233+ (dest_color_format != OMX_COLOR_FormatYUV420SemiPlanar)){
1021710234 DEBUG_PRINT_ERROR (" \n Unsupported color format for c2d" );
1021810235 status = false ;
1021910236 } else {
10220- ColorFormat = OMX_COLOR_FormatYUV420Planar;
10237+ ColorFormat = dest_color_format;
10238+ dest_format = (dest_color_format == OMX_COLOR_FormatYUV420Planar) ?
10239+ YCbCr420P : YCbCr420SP;
1022110240 if (enabled)
1022210241 c2d.destroy ();
1022310242 enabled = false ;
@@ -10232,6 +10251,7 @@ bool omx_vdec::allocate_color_convert_buf::set_color_format(
1023210251 c2d.destroy ();
1023310252 enabled = false ;
1023410253 }
10254+ pthread_mutex_unlock (&omx->c_lock );
1023510255 return status;
1023610256}
1023710257
@@ -10262,9 +10282,11 @@ OMX_BUFFERHEADERTYPE* omx_vdec::allocate_color_convert_buf::get_il_buf_hdr
1026210282 m_out_mem_ptr_client[index].nTimeStamp = bufadd->nTimeStamp ;
1026310283 bool status;
1026410284 if (!omx->in_reconfig && !omx->output_flush_progress ) {
10285+ pthread_mutex_lock (&omx->c_lock );
1026510286 status = c2d.convert (omx->drv_ctx .ptr_outputbuffer [index].pmem_fd ,
1026610287 bufadd->pBuffer ,pmem_fd[index],pmem_baseaddress[index]);
1026710288 m_out_mem_ptr_client[index].nFilledLen = buffer_size_req;
10289+ pthread_mutex_unlock (&omx->c_lock );
1026810290 if (!status){
1026910291 DEBUG_PRINT_ERROR (" \n Failed color conversion %d" , status);
1027010292 return NULL ;
@@ -10299,10 +10321,14 @@ bool omx_vdec::allocate_color_convert_buf::get_buffer_req
1029910321{
1030010322 if (!enabled)
1030110323 buffer_size = omx->drv_ctx .op_buf .buffer_size ;
10302- else
10324+ else {
10325+ pthread_mutex_lock (&omx->c_lock );
1030310326 if (!c2d.get_buffer_size (C2D_OUTPUT,buffer_size)) {
1030410327 DEBUG_PRINT_ERROR (" \n Get buffer size failed" );
10328+ pthread_mutex_unlock (&omx->c_lock );
1030510329 return false ;
10330+ }
10331+ pthread_mutex_unlock (&omx->c_lock );
1030610332 }
1030710333 if (buffer_size < omx->drv_ctx .op_buf .buffer_size )
1030810334 buffer_size = omx->drv_ctx .op_buf .buffer_size ;
@@ -10338,8 +10364,10 @@ OMX_ERRORTYPE omx_vdec::allocate_color_convert_buf::free_output_buffer(
1033810364 else
1033910365 allocated_count = 0 ;
1034010366 if (!allocated_count) {
10367+ pthread_mutex_lock (&omx->c_lock );
1034110368 c2d.close ();
1034210369 init_members ();
10370+ pthread_mutex_unlock (&omx->c_lock );
1034310371 }
1034410372 return omx->free_output_buffer (&omx->m_out_mem_ptr [index]);
1034510373}
@@ -10505,10 +10533,12 @@ bool omx_vdec::allocate_color_convert_buf::get_color_format(OMX_COLOR_FORMATTYPE
1050510533 else
1050610534 status = false ;
1050710535 } else {
10508- if (ColorFormat != OMX_COLOR_FormatYUV420Planar) {
10536+ if ((ColorFormat == OMX_COLOR_FormatYUV420Planar)||
10537+ (ColorFormat == OMX_COLOR_FormatYUV420SemiPlanar)) {
10538+ dest_color_format = ColorFormat;
10539+ } else {
1050910540 status = false ;
10510- } else
10511- dest_color_format = OMX_COLOR_FormatYUV420Planar;
10541+ }
1051210542 }
1051310543 return status;
1051410544}
0 commit comments