Skip to content

Commit b40a565

Browse files
c_sridurarco
authored andcommitted
media: Fix cts issues related to VideoEncoderDecoderTest
-Synchronize color conversion calls (from I333f1fa9a922e456f886f5b3d8081baa7ad53a4e) -Add YUV420SP color format support (from I4085d2e9c268e839d78f9bf4ff444de68278d272) -Allow 16-bit stride for NV12 format (from I5e42606a05dfb7ef55ea1eb1f06f581d23e123dd) -Add proper stride2 value for tile format Change-Id: I04387fefa71cc756b14bde75dfeeb051c827dac9
1 parent f6c8595 commit b40a565

File tree

3 files changed

+47
-15
lines changed

3 files changed

+47
-15
lines changed

libc2dcolorconvert/C2DColorConverter.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ void* C2DColorConverter::getDummySurfaceDef(ColorConvertFormat format, size_t wi
290290
surfaceDef->plane1 = (void *)0xaaaaaaaa;
291291
surfaceDef->phys1 = (void *)0xaaaaaaaa;
292292
surfaceDef->stride1 = calcStride(format, width);
293+
surfaceDef->stride2 = 0;
293294

294295
if (format == YCbCr420P ||
295296
format == YCrCb420P) {
@@ -401,7 +402,7 @@ size_t C2DColorConverter::calcStride(ColorConvertFormat format, size_t width)
401402
case YCbCr420Tile:
402403
return ALIGN(width, ALIGN128);
403404
case YCbCr420SP:
404-
return ALIGN(width, ALIGN32);
405+
return ALIGN(width, ALIGN16);
405406
case NV12_2K:
406407
return ALIGN(width, ALIGN16);
407408
case YCbCr420P:
@@ -417,7 +418,7 @@ size_t C2DColorConverter::calcYSize(ColorConvertFormat format, size_t width, siz
417418
{
418419
switch (format) {
419420
case YCbCr420SP:
420-
return (ALIGN(width, ALIGN32) * height);
421+
return (ALIGN(width, ALIGN16) * height);
421422
case YCbCr420P:
422423
return width * height;
423424
case YCrCb420P:
@@ -450,8 +451,8 @@ size_t C2DColorConverter::calcSize(ColorConvertFormat format, size_t width, size
450451
size = ALIGN(size, ALIGN4K);
451452
break;
452453
case YCbCr420SP:
453-
alignedw = ALIGN(width, ALIGN32);
454-
size = ALIGN((alignedw * height) + (ALIGN(width/2, ALIGN32) * (height/2) * 2), ALIGN4K);
454+
alignedw = ALIGN(width, ALIGN16);
455+
size = ALIGN((alignedw * height) + (ALIGN(width/2, ALIGN16) * (height/2) * 2), ALIGN4K);
455456
break;
456457
case YCbCr420P:
457458
size = ALIGN((width * height * 3 / 2), ALIGN4K);

mm-video/vidc/vdec/inc/omx_vdec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@ class omx_vdec: public qc_omx_component
684684
//*******************MEMBER VARIABLES *************************
685685
//*************************************************************
686686
pthread_mutex_t m_lock;
687+
pthread_mutex_t c_lock;
687688
//sem to handle the minimum procesing of commands
688689
sem_t m_cmd_lock;
689690
bool m_error_propogated;

mm-video/vidc/vdec/src/omx_vdec.cpp

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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

1012810140
void 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("\nupdate_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

Comments
 (0)