diff --git a/modules/codec/omxil/iomx_hwbuffer.c b/modules/codec/omxil/iomx_hwbuffer.c index 4eb75482cdaffa927319c866d8ea1a842a1d9401..f62f4ab30960c032cfb739653e2f55655517abbb 100644 --- a/modules/codec/omxil/iomx_hwbuffer.c +++ b/modules/codec/omxil/iomx_hwbuffer.c @@ -27,6 +27,9 @@ #include <errno.h> #include <stdio.h> +#include <OMX_Core.h> +#include <OMX_Component.h> + #if ANDROID_API <= 11 #include <ui/android_native_buffer.h> #include <ui/egl/android_natives.h> @@ -100,6 +103,25 @@ int IOMXHWBuffer_Disconnect( void *window ) } +int IOMXHWBuffer_GetHalFormat( const char *comp_name, int* hal_format ) +{ + if( !strncmp( comp_name, "OMX.SEC.", 8 ) ) { + switch( *hal_format ) { + case OMX_COLOR_FormatYUV420SemiPlanar: + *hal_format = 0x105; // HAL_PIXEL_FORMAT_YCbCr_420_SP + break; + case OMX_COLOR_FormatYUV420Planar: + *hal_format = 0x101; // HAL_PIXEL_FORMAT_YCbCr_420_P + break; + } + } + else if( !strcmp( comp_name, "OMX.TI.720P.Decoder" ) || + !strcmp( comp_name, "OMX.TI.Video.Decoder" ) ) + *hal_format = 0x14; // HAL_PIXEL_FORMAT_YCbCr_422_I + + return 0; +} + int IOMXHWBuffer_Setup( void *window, int w, int h, int hal_format, int hw_usage ) { ANativeWindow *anw = (ANativeWindow *)window; diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c index b7a586f28eb1a958adbf5ca8e43efbd07aba60e5..376aa44289991b08867407b2eb16289ee2fad501 100644 --- a/modules/codec/omxil/omxil.c +++ b/modules/codec/omxil/omxil.c @@ -2055,6 +2055,7 @@ static void HwBuffer_Init( decoder_t *p_dec, OmxPort *p_port ) pf_omx_hwbuffer_set_buffer_count && pf_omx_hwbuffer_setcrop && pf_omx_hwbuffer_dequeue && pf_omx_hwbuffer_lock && pf_omx_hwbuffer_queue && pf_omx_hwbuffer_cancel && + pf_omx_hwbuffer_get_hal_format && ((OMX_COMPONENTTYPE*)p_port->omx_handle)->UseBuffer) ) { msg_Warn( p_dec, "direct output port enabled but can't find " @@ -2157,19 +2158,11 @@ static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port ) if( !p_port->p_hwbuf ) return 0; - if( !strncmp( p_sys->psz_component, "OMX.SEC.", 8 ) ) { - switch( colorFormat ) { - case OMX_COLOR_FormatYUV420SemiPlanar: - colorFormat = 0x105; // HAL_PIXEL_FORMAT_YCbCr_420_SP - break; - case OMX_COLOR_FormatYUV420Planar: - colorFormat = 0x101; // HAL_PIXEL_FORMAT_YCbCr_420_P - break; - } + omx_error = pf_omx_hwbuffer_get_hal_format( p_sys->psz_component, &colorFormat ); + if( omx_error != OMX_ErrorNone ) + { + msg_Warn( p_dec, "pf_omx_hwbuffer_get_hal_format failed (Not fatal)" ); } - else if( !strcmp( p_sys->psz_component, "OMX.TI.720P.Decoder" ) || - !strcmp( p_sys->psz_component, "OMX.TI.Video.Decoder" ) ) - colorFormat = 0x14; // HAL_PIXEL_FORMAT_YCbCr_422_I omx_error = pf_get_graphic_buffer_usage( p_port->omx_handle, p_port->i_port_index, diff --git a/modules/codec/omxil/omxil_core.c b/modules/codec/omxil/omxil_core.c index aed525162811c20cc50fa4888fc0a68b0a4bdba6..c196ec21b421d600969dbe38d3bc64a0ee01d198 100644 --- a/modules/codec/omxil/omxil_core.c +++ b/modules/codec/omxil/omxil_core.c @@ -92,6 +92,7 @@ OMX_ERRORTYPE (*pf_get_graphic_buffer_usage)(OMX_HANDLETYPE, OMX_U32, OMX_U32*); int (*pf_omx_hwbuffer_connect) (void *); int (*pf_omx_hwbuffer_disconnect) (void *); +int (*pf_omx_hwbuffer_get_hal_format) (const char *, int *); int (*pf_omx_hwbuffer_setup) (void *, int, int, int, int ); int (*pf_omx_hwbuffer_get_min_undequeued) (void *, unsigned int *); int (*pf_omx_hwbuffer_set_buffer_count) (void *, unsigned int ); @@ -179,6 +180,7 @@ int InitOmxCore(vlc_object_t *p_this) pf_omx_hwbuffer_connect = dlsym( dll_handle, "OMXHWBuffer_Connect" ); pf_omx_hwbuffer_disconnect = dlsym( dll_handle, "OMXHWBuffer_Disconnect" ); + pf_omx_hwbuffer_get_hal_format = dlsym( dll_handle, "OMXHWBuffer_GetHalFormat" ); pf_omx_hwbuffer_setup = dlsym( dll_handle, "OMXHWBuffer_Setup" ); pf_omx_hwbuffer_get_min_undequeued = dlsym( dll_handle, "OMXHWBuffer_GetMinUndequeued" ); pf_omx_hwbuffer_set_buffer_count = dlsym( dll_handle, "OMXHWBuffer_SetBufferCount" ); diff --git a/modules/codec/omxil/omxil_core.h b/modules/codec/omxil/omxil_core.h index 955e9659024176cd34630db0fb7b81bf61f31261..92d8caa2e7a8d0417e7483d771aefd68e6ff9eb9 100644 --- a/modules/codec/omxil/omxil_core.h +++ b/modules/codec/omxil/omxil_core.h @@ -40,6 +40,7 @@ OMX_ERRORTYPE (*pf_get_graphic_buffer_usage)(OMX_HANDLETYPE, OMX_U32, OMX_U32*); /* OMXHWBuffer functions */ int (*pf_omx_hwbuffer_connect) (void *); int (*pf_omx_hwbuffer_disconnect) (void *); +int (*pf_omx_hwbuffer_get_hal_format) (const char *, int *); int (*pf_omx_hwbuffer_setup) (void *, int, int, int, int ); int (*pf_omx_hwbuffer_get_min_undequeued) (void *, unsigned int *); int (*pf_omx_hwbuffer_set_buffer_count) (void *, unsigned int );