diff --git a/NEWS b/NEWS index 90eb307daea4e3f440baf3370c9f2e4a4ca082d7..f7afadbd3153c613d4baab0b6208a2a161035df2 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,7 @@ Platform support changes: Codecs: * Support for experimental AV1 video encoding * WebVTT encoder + * Remove iomx support for Android Video ouput: * Remove aa plugin diff --git a/modules/MODULES_LIST b/modules/MODULES_LIST index 747ea67d599fcaaf1e034336b4b25b2522d9d9b5..6acae780e801547d475aa18b737f299b239e15f6 100644 --- a/modules/MODULES_LIST +++ b/modules/MODULES_LIST @@ -204,7 +204,6 @@ $Id$ * inflate: zlib decompression stream_filter module * integer_mixer: Integer audio mixer * invert: inverse video filter - * iomx: IPC/OpenMaxIL for Android * jack: jack server audio output * jpeg: JPEG image decoder * kai: OS/2 audio output diff --git a/modules/codec/Makefile.am b/modules/codec/Makefile.am index d4df5a7a90d16ba8781353934123e1e35cc6eb45..a52d37d68eb7d7b256726f826910b8eeec2bcaf2 100644 --- a/modules/codec/Makefile.am +++ b/modules/codec/Makefile.am @@ -478,10 +478,6 @@ libomxil_plugin_la_SOURCES = \ packetizer/hevc_nal.c packetizer/hevc_nal.h \ codec/omxil/qcom.c codec/omxil/qcom.h \ codec/omxil/omxil.c codec/omxil/omxil.h codec/omxil/omxil_core.c codec/omxil/omxil_core.h -if HAVE_ANDROID -libomxil_plugin_la_SOURCES += video_output/android/utils.c video_output/android/utils.h \ - video_output/android/display.h -endif libomxil_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/codec/omxil $(CFLAGS_omxil) libomxil_plugin_la_LIBADD = libchroma_copy.la $(LIBDL) libomxil_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(codecdir)' @@ -491,10 +487,6 @@ libomxil_vout_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/codec/omxil $(CFLA libomxil_vout_plugin_la_LIBADD = libchroma_copy.la $(LIBDL) libomxil_vout_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(codecdir)' -libiomx_plugin_la_SOURCES = $(libomxil_plugin_la_SOURCES) -libiomx_plugin_la_CPPFLAGS = $(libomxil_plugin_la_CPPFLAGS) -DUSE_IOMX -libiomx_plugin_la_LIBADD = $(libomxil_plugin_la_LIBADD) - libmediacodec_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/codec/omxil libmediacodec_plugin_la_SOURCES = codec/omxil/mediacodec.c codec/omxil/mediacodec.h \ codec/omxil/mediacodec_jni.c codec/omxil/mediacodec_ndk.c codec/omxil/utils.c \ @@ -508,7 +500,7 @@ libmediacodec_plugin_la_LIBADD = libchroma_copy.la codec_LTLIBRARIES += $(LTLIBomxil) $(LTLIBomxil_vout) EXTRA_LTLIBRARIES += libomxil_plugin.la libomxil_vout_plugin.la if HAVE_ANDROID -codec_LTLIBRARIES += libiomx_plugin.la libmediacodec_plugin.la +codec_LTLIBRARIES += libmediacodec_plugin.la endif diff --git a/modules/codec/omxil/iomx.cpp b/modules/codec/omxil/iomx.cpp deleted file mode 100644 index 894b09a200ab469e96dff3d1e4bcc9cb14d10399..0000000000000000000000000000000000000000 --- a/modules/codec/omxil/iomx.cpp +++ /dev/null @@ -1,456 +0,0 @@ -/***************************************************************************** - * iomx.cpp: OpenMAX interface implementation based on IOMX - ***************************************************************************** - * Copyright (C) 2011 VLC authors and VideoLAN - * - * Authors: Martin Storsjo - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -/***************************************************************************** - * Preamble - *****************************************************************************/ - -#include -#include -#include -#include - -#define PREFIX(x) I ## x - -#if ANDROID_API >= 11 -#define HAS_USE_BUFFER -#endif - -using namespace android; - -class IOMXContext { -public: - IOMXContext() { - } - - sp iomx; - List components; -}; - -static IOMXContext *ctx; - -class OMXNode; - -class OMXCodecObserver : public BnOMXObserver { -public: - OMXCodecObserver() { - node = NULL; - } - void setNode(OMXNode* n) { - node = n; - } - void onMessage(const omx_message &msg); - void registerBuffers(const sp &) { - } -private: - OMXNode *node; -}; - -class OMXNode { -public: - IOMX::node_id node; - sp observer; - OMX_CALLBACKTYPE callbacks; - OMX_PTR app_data; - OMX_STATETYPE state; - List buffers; - OMX_HANDLETYPE handle; - String8 component_name; -}; - -class OMXBuffer { -public: - sp dealer; -#ifdef HAS_USE_BUFFER - sp graphicBuffer; -#endif - IOMX::buffer_id id; -}; - -void OMXCodecObserver::onMessage(const omx_message &msg) -{ - if (!node) - return; - switch (msg.type) { - case omx_message::EVENT: - // TODO: Needs locking - if (msg.u.event_data.event == OMX_EventCmdComplete && msg.u.event_data.data1 == OMX_CommandStateSet) - node->state = (OMX_STATETYPE) msg.u.event_data.data2; - node->callbacks.EventHandler(node->handle, node->app_data, msg.u.event_data.event, msg.u.event_data.data1, msg.u.event_data.data2, NULL); - break; - case omx_message::EMPTY_BUFFER_DONE: - for( List::iterator it = node->buffers.begin(); it != node->buffers.end(); ++it ) { - OMXBuffer* info = (OMXBuffer*) (*it)->pPlatformPrivate; - if (msg.u.buffer_data.buffer == info->id) { - node->callbacks.EmptyBufferDone(node->handle, node->app_data, *it); - break; - } - } - break; - case omx_message::FILL_BUFFER_DONE: - for( List::iterator it = node->buffers.begin(); it != node->buffers.end(); ++it ) { - OMXBuffer* info = (OMXBuffer*) (*it)->pPlatformPrivate; - if (msg.u.extended_buffer_data.buffer == info->id) { - OMX_BUFFERHEADERTYPE *buffer = *it; - buffer->nOffset = msg.u.extended_buffer_data.range_offset; - buffer->nFilledLen = msg.u.extended_buffer_data.range_length; - buffer->nFlags = msg.u.extended_buffer_data.flags; - buffer->nTimeStamp = msg.u.extended_buffer_data.timestamp; - node->callbacks.FillBufferDone(node->handle, node->app_data, buffer); - break; - } - } - break; - default: - break; - } -} - -static OMX_ERRORTYPE get_error(status_t err) -{ - if (err == OK) - return OMX_ErrorNone; - return OMX_ErrorUndefined; -} - -static OMX_ERRORTYPE iomx_send_command(OMX_HANDLETYPE component, OMX_COMMANDTYPE command, OMX_U32 param1, OMX_PTR) -{ - OMXNode* node = (OMXNode*) ((OMX_COMPONENTTYPE*)component)->pComponentPrivate; - return get_error(ctx->iomx->sendCommand(node->node, command, param1)); -} - -static OMX_ERRORTYPE iomx_get_parameter(OMX_HANDLETYPE component, OMX_INDEXTYPE param_index, OMX_PTR param) -{ - /* - * Some QCOM OMX_getParameter implementations override the nSize element to - * a bad value. So, save the initial nSize in order to restore it after. - */ - OMX_U32 nSize = *(OMX_U32*)param; - OMX_ERRORTYPE error; - OMXNode* node = (OMXNode*) ((OMX_COMPONENTTYPE*)component)->pComponentPrivate; - - error = get_error(ctx->iomx->getParameter(node->node, param_index, param, nSize)); - *(OMX_U32*)param = nSize; - return error; -} - -static OMX_ERRORTYPE iomx_set_parameter(OMX_HANDLETYPE component, OMX_INDEXTYPE param_index, OMX_PTR param) -{ - OMXNode* node = (OMXNode*) ((OMX_COMPONENTTYPE*)component)->pComponentPrivate; - return get_error(ctx->iomx->setParameter(node->node, param_index, param, *(OMX_U32*)param)); -} - -static OMX_ERRORTYPE iomx_get_state(OMX_HANDLETYPE component, OMX_STATETYPE *ptr) { - OMXNode* node = (OMXNode*) ((OMX_COMPONENTTYPE*)component)->pComponentPrivate; - *ptr = node->state; - return OMX_ErrorNone; -} - -static OMX_ERRORTYPE iomx_allocate_buffer(OMX_HANDLETYPE component, OMX_BUFFERHEADERTYPE **bufferptr, OMX_U32 port_index, OMX_PTR app_private, OMX_U32 size) -{ - OMXNode* node = (OMXNode*) ((OMX_COMPONENTTYPE*)component)->pComponentPrivate; - OMXBuffer* info = new OMXBuffer; -#ifdef HAS_USE_BUFFER - info->graphicBuffer = NULL; -#endif - info->dealer = new MemoryDealer(size + 4096); // Do we need to keep this around, or is it kept alive via the IMemory that references it? - sp mem = info->dealer->allocate(size); - int ret = ctx->iomx->allocateBufferWithBackup(node->node, port_index, mem, &info->id); - if (ret != OK) - return OMX_ErrorUndefined; - OMX_BUFFERHEADERTYPE *buffer = (OMX_BUFFERHEADERTYPE*) calloc(1, sizeof(OMX_BUFFERHEADERTYPE)); - *bufferptr = buffer; - buffer->pPlatformPrivate = info; - buffer->pAppPrivate = app_private; - buffer->nAllocLen = size; - buffer->pBuffer = (OMX_U8*) mem->pointer(); - node->buffers.push_back(buffer); - return OMX_ErrorNone; -} - -#ifdef HAS_USE_BUFFER -static OMX_ERRORTYPE iomx_use_buffer(OMX_HANDLETYPE component, OMX_BUFFERHEADERTYPE **bufferptr, OMX_U32 port_index, OMX_PTR app_private, OMX_U32 size, OMX_U8* data) -{ - OMXNode* node = (OMXNode*) ((OMX_COMPONENTTYPE*)component)->pComponentPrivate; - OMXBuffer* info = new OMXBuffer; - info->dealer = NULL; -#if ANDROID_API <= 13 - info->graphicBuffer = new GraphicBuffer((android_native_buffer_t*) data, false); -#else - info->graphicBuffer = new GraphicBuffer((ANativeWindowBuffer*) data, false); -#endif - int ret = ctx->iomx->useGraphicBuffer(node->node, port_index, info->graphicBuffer, &info->id); - if (ret != OK) - return OMX_ErrorUndefined; - OMX_BUFFERHEADERTYPE *buffer = (OMX_BUFFERHEADERTYPE*) calloc(1, sizeof(OMX_BUFFERHEADERTYPE)); - *bufferptr = buffer; - buffer->pPlatformPrivate = info; - buffer->pAppPrivate = app_private; - buffer->nAllocLen = size; - buffer->pBuffer = data; - node->buffers.push_back(buffer); - return OMX_ErrorNone; -} -#endif - -static OMX_ERRORTYPE iomx_free_buffer(OMX_HANDLETYPE component, OMX_U32 port, OMX_BUFFERHEADERTYPE *buffer) -{ - OMXNode* node = (OMXNode*) ((OMX_COMPONENTTYPE*)component)->pComponentPrivate; - OMXBuffer* info = (OMXBuffer*) buffer->pPlatformPrivate; - status_t ret = ctx->iomx->freeBuffer(node->node, port, info->id); - for( List::iterator it = node->buffers.begin(); it != node->buffers.end(); ++it ) { - if (buffer == *it) { - node->buffers.erase(it); - break; - } - } - free(buffer); - delete info; - return get_error(ret); -} - -static OMX_ERRORTYPE iomx_empty_this_buffer(OMX_HANDLETYPE component, OMX_BUFFERHEADERTYPE *buffer) -{ - OMXNode* node = (OMXNode*) ((OMX_COMPONENTTYPE*)component)->pComponentPrivate; - OMXBuffer* info = (OMXBuffer*) buffer->pPlatformPrivate; - return get_error(ctx->iomx->emptyBuffer(node->node, info->id, buffer->nOffset, buffer->nFilledLen, buffer->nFlags, buffer->nTimeStamp)); -} - -static OMX_ERRORTYPE iomx_fill_this_buffer(OMX_HANDLETYPE component, OMX_BUFFERHEADERTYPE *buffer) -{ - OMXNode* node = (OMXNode*) ((OMX_COMPONENTTYPE*)component)->pComponentPrivate; - OMXBuffer* info = (OMXBuffer*) buffer->pPlatformPrivate; - return get_error(ctx->iomx->fillBuffer(node->node, info->id)); -} - -static OMX_ERRORTYPE iomx_component_role_enum(OMX_HANDLETYPE component, OMX_U8 *role, OMX_U32 index) -{ - OMXNode* node = (OMXNode*) ((OMX_COMPONENTTYPE*)component)->pComponentPrivate; - for( List::iterator it = ctx->components.begin(); it != ctx->components.end(); ++it ) { - if (node->component_name == it->mName) { - if (index >= it->mRoles.size()) - return OMX_ErrorNoMore; - List::iterator it2 = it->mRoles.begin(); - for( OMX_U32 i = 0; it2 != it->mRoles.end() && i < index; i++, ++it2 ) ; - strncpy((char*)role, it2->string(), OMX_MAX_STRINGNAME_SIZE); - if (it2->length() >= OMX_MAX_STRINGNAME_SIZE) - role[OMX_MAX_STRINGNAME_SIZE - 1] = '\0'; - return OMX_ErrorNone; - } - } - return OMX_ErrorInvalidComponentName; -} - -static OMX_ERRORTYPE iomx_get_extension_index(OMX_HANDLETYPE component, OMX_STRING parameter, OMX_INDEXTYPE *index) -{ - OMXNode* node = (OMXNode*) ((OMX_COMPONENTTYPE*)component)->pComponentPrivate; - return get_error(ctx->iomx->getExtensionIndex(node->node, parameter, index)); -} - -static OMX_ERRORTYPE iomx_set_config(OMX_HANDLETYPE component, OMX_INDEXTYPE index, OMX_PTR param) -{ - OMXNode* node = (OMXNode*) ((OMX_COMPONENTTYPE*)component)->pComponentPrivate; - return get_error(ctx->iomx->setConfig(node->node, index, param, *(OMX_U32*)param)); -} - -static OMX_ERRORTYPE iomx_get_config(OMX_HANDLETYPE component, OMX_INDEXTYPE index, OMX_PTR param) -{ - OMXNode* node = (OMXNode*) ((OMX_COMPONENTTYPE*)component)->pComponentPrivate; - return get_error(ctx->iomx->getConfig(node->node, index, param, *(OMX_U32*)param)); -} - -extern "C" { -OMX_ERRORTYPE PREFIX(OMX_GetHandle)(OMX_HANDLETYPE *handle_ptr, OMX_STRING component_name, OMX_PTR app_data, OMX_CALLBACKTYPE *callbacks) -{ - OMXNode* node = new OMXNode(); - node->app_data = app_data; - node->callbacks = *callbacks; - node->observer = new OMXCodecObserver(); - node->observer->setNode(node); - node->state = OMX_StateLoaded; - node->component_name = component_name; - - OMX_COMPONENTTYPE* component = (OMX_COMPONENTTYPE*) malloc(sizeof(OMX_COMPONENTTYPE)); - memset(component, 0, sizeof(OMX_COMPONENTTYPE)); - component->nSize = sizeof(OMX_COMPONENTTYPE); - component->nVersion.s.nVersionMajor = 1; - component->nVersion.s.nVersionMinor = 1; - component->nVersion.s.nRevision = 0; - component->nVersion.s.nStep = 0; - component->pComponentPrivate = node; - component->SendCommand = iomx_send_command; - component->GetParameter = iomx_get_parameter; - component->SetParameter = iomx_set_parameter; - component->FreeBuffer = iomx_free_buffer; - component->EmptyThisBuffer = iomx_empty_this_buffer; - component->FillThisBuffer = iomx_fill_this_buffer; - component->GetState = iomx_get_state; - component->AllocateBuffer = iomx_allocate_buffer; -#ifdef HAS_USE_BUFFER - component->UseBuffer = iomx_use_buffer; -#else - component->UseBuffer = NULL; -#endif - component->ComponentRoleEnum = iomx_component_role_enum; - component->GetExtensionIndex = iomx_get_extension_index; - component->SetConfig = iomx_set_config; - component->GetConfig = iomx_get_config; - - *handle_ptr = component; - node->handle = component; - status_t ret; - if ((ret = ctx->iomx->allocateNode( component_name, node->observer, &node->node )) != OK) - return OMX_ErrorUndefined; - return OMX_ErrorNone; -} - -OMX_ERRORTYPE PREFIX(OMX_FreeHandle)(OMX_HANDLETYPE handle) -{ - OMXNode* node = (OMXNode*) ((OMX_COMPONENTTYPE*)handle)->pComponentPrivate; - ctx->iomx->freeNode( node->node ); - node->observer->setNode(NULL); - delete node; - free(handle); - return OMX_ErrorNone; -} - -OMX_ERRORTYPE PREFIX(OMX_Init)(void) -{ - OMXClient client; - if (client.connect() != OK) - return OMX_ErrorUndefined; - - if (!ctx) - ctx = new IOMXContext(); - ctx->iomx = client.interface(); - ctx->iomx->listNodes(&ctx->components); - return OMX_ErrorNone; -} - -OMX_ERRORTYPE PREFIX(OMX_Deinit)(void) -{ - ctx->iomx = NULL; - delete ctx; - ctx = NULL; - return OMX_ErrorNone; -} - -OMX_ERRORTYPE PREFIX(OMX_ComponentNameEnum)(OMX_STRING component_name, OMX_U32 name_length, OMX_U32 index) -{ - if (index >= ctx->components.size()) - return OMX_ErrorNoMore; - List::iterator it = ctx->components.begin(); - for( OMX_U32 i = 0; i < index; i++ ) - ++it; - strncpy(component_name, it->mName.string(), name_length); - component_name[name_length - 1] = '\0'; - return OMX_ErrorNone; -} - -OMX_ERRORTYPE PREFIX(OMX_GetRolesOfComponent)(OMX_STRING component_name, OMX_U32 *num_roles, OMX_U8 **roles) -{ - for( List::iterator it = ctx->components.begin(); it != ctx->components.end(); ++it ) { - if (!strcmp(component_name, it->mName.string())) { - if (!roles) { - *num_roles = it->mRoles.size(); - return OMX_ErrorNone; - } - if (*num_roles < it->mRoles.size()) - return OMX_ErrorInsufficientResources; - *num_roles = it->mRoles.size(); - OMX_U32 i = 0; - for( List::iterator it2 = it->mRoles.begin(); it2 != it->mRoles.end(); i++, ++it2 ) { - strncpy((char*)roles[i], it2->string(), OMX_MAX_STRINGNAME_SIZE); - roles[i][OMX_MAX_STRINGNAME_SIZE - 1] = '\0'; - } - return OMX_ErrorNone; - } - } - return OMX_ErrorInvalidComponentName; -} - -OMX_ERRORTYPE PREFIX(OMX_GetComponentsOfRole)(OMX_STRING role, OMX_U32 *num_comps, OMX_U8 **comp_names) -{ - OMX_U32 i = 0; - for( List::iterator it = ctx->components.begin(); it != ctx->components.end(); ++it ) { - for( List::iterator it2 = it->mRoles.begin(); it2 != it->mRoles.end(); ++it2 ) { - if (!strcmp(it2->string(), role)) { - if (comp_names) { - if (*num_comps < i) - return OMX_ErrorInsufficientResources; - strncpy((char*)comp_names[i], it->mName.string(), OMX_MAX_STRINGNAME_SIZE); - comp_names[i][OMX_MAX_STRINGNAME_SIZE - 1] = '\0'; - } - i++; - break; - } - } - } - *num_comps = i; - return OMX_ErrorNone; -} - -#ifdef HAS_USE_BUFFER -OMX_ERRORTYPE PREFIX(OMXAndroid_EnableGraphicBuffers)(OMX_HANDLETYPE component, OMX_U32 port_index, OMX_BOOL enable) -{ - OMXNode* node = (OMXNode*) ((OMX_COMPONENTTYPE*)component)->pComponentPrivate; - int ret = ctx->iomx->enableGraphicBuffers(node->node, port_index, enable); - if (ret != OK) - return OMX_ErrorUndefined; - return OMX_ErrorNone; -} - -OMX_ERRORTYPE PREFIX(OMXAndroid_GetGraphicBufferUsage)(OMX_HANDLETYPE component, OMX_U32 port_index, OMX_U32* usage) -{ - OMXNode* node = (OMXNode*) ((OMX_COMPONENTTYPE*)component)->pComponentPrivate; - int ret = ctx->iomx->getGraphicBufferUsage(node->node, port_index, usage); - if (ret != OK) - return OMX_ErrorUndefined; - return OMX_ErrorNone; -} - -OMX_ERRORTYPE PREFIX(OMXAndroid_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 -#if ANDROID_API <= 13 // Required on msm8660 on 3.2, not required on 4.1 - else if( !strcmp( comp_name, "OMX.qcom.video.decoder.avc" )) - *hal_format = 0x108; -#endif - - return OMX_ErrorNone; -} - -#endif -} - diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c index 619e90a28051bfdcc9e8fb2f4fba847b6d185fa9..1658633888c3ab71cd414c1f90fa799ca92fdb08 100644 --- a/modules/codec/omxil/omxil.c +++ b/modules/codec/omxil/omxil.c @@ -42,12 +42,6 @@ #include "omxil_core.h" #include "OMX_Broadcom.h" -#if defined(USE_IOMX) -#include -#include -#include "../../video_output/android/display.h" -#endif - #ifndef NDEBUG # define OMX_DBG(...) msg_Dbg( p_dec, __VA_ARGS__ ) #else @@ -64,11 +58,6 @@ /* Defined in the broadcom version of OMX_Core.h */ #define OMX_EventParamOrConfigChanged 0x7F000001 -#if defined(USE_IOMX) -/* JNI functions to get/set an Android Surface object. */ -#define THREAD_NAME "omxil" -#endif - /***************************************************************************** * Local prototypes *****************************************************************************/ @@ -89,50 +78,6 @@ static OMX_ERRORTYPE OmxEmptyBufferDone( OMX_HANDLETYPE, OMX_PTR, static OMX_ERRORTYPE OmxFillBufferDone( OMX_HANDLETYPE, OMX_PTR, OMX_BUFFERHEADERTYPE * ); -#if defined(USE_IOMX) -static void *DequeueThread( void *data ); -static void ReleasePicture( decoder_t *p_dec, unsigned int i_index, bool b_render ); -static void HwBuffer_Init( decoder_t *p_dec, OmxPort *p_port ); -static void HwBuffer_Destroy( decoder_t *p_dec, OmxPort *p_port ); -static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port ); -static int HwBuffer_FreeBuffers( decoder_t *p_dec, OmxPort *p_port ); -static int HwBuffer_Start( decoder_t *p_dec, OmxPort *p_port ); -static int HwBuffer_Stop( decoder_t *p_dec, OmxPort *p_port ); -static int HwBuffer_Join( decoder_t *p_dec, OmxPort *p_port ); -static int HwBuffer_GetPic( decoder_t *p_dec, OmxPort *p_port, - picture_t **pp_pic ); -static void HwBuffer_SetCrop( decoder_t *p_dec, OmxPort *p_port, - OMX_CONFIG_RECTTYPE *p_rect ); -static void HwBuffer_ChangeState( decoder_t *p_dec, OmxPort *p_port, - int i_index, int i_state ); - -#define HWBUFFER_LOCK(p_port) vlc_mutex_lock( &(p_port)->p_hwbuf->lock ) -#define HWBUFFER_UNLOCK(p_port) vlc_mutex_unlock( &(p_port)->p_hwbuf->lock ) -#define HWBUFFER_WAIT(p_port) vlc_cond_wait( &(p_port)->p_hwbuf->wait, \ - &(p_port)->p_hwbuf->lock ) -#define HWBUFFER_BROADCAST(p_port) vlc_cond_broadcast( &(p_port)->p_hwbuf->wait ) - -#else -static inline int HwBuffer_dummy( ) -{ - return 0; -} -#define HwBuffer_Init(p_dec, p_port) do { } while (0) -#define HwBuffer_Destroy(p_dec, p_port) do { } while (0) -#define HwBuffer_AllocateBuffers(p_dec, p_port) HwBuffer_dummy() -#define HwBuffer_FreeBuffers(p_dec, p_port) HwBuffer_dummy() -#define HwBuffer_Start(p_dec, p_port) HwBuffer_dummy() -#define HwBuffer_Stop(p_dec, p_port) HwBuffer_dummy() -#define HwBuffer_Join(p_dec, p_port) HwBuffer_dummy() -#define HwBuffer_GetPic(p_dec, p_port, pp_pic) HwBuffer_dummy() -#define HwBuffer_SetCrop(p_dec, p_port, p_rect) do { } while (0) - -#define HWBUFFER_LOCK(p_port) do { } while (0) -#define HWBUFFER_UNLOCK(p_port) do { } while (0) -#define HWBUFFER_WAIT(p_port) do { } while (0) -#define HWBUFFER_BROADCAST(p_port) do { } while (0) -#endif - /***************************************************************************** * Module descriptor *****************************************************************************/ @@ -146,24 +91,11 @@ vlc_module_begin () set_category( CAT_INPUT ) set_subcategory( SUBCAT_INPUT_VCODEC ) set_section( N_("Decoding") , NULL ) -#if defined(USE_IOMX) - /* For IOMX, don't enable it automatically via priorities, - * enable it only via the --codec iomx command line parameter when - * wanted. */ - set_capability( "video decoder", 0 ) - add_bool(CFG_PREFIX "dr", true, - DIRECTRENDERING_TEXT, DIRECTRENDERING_LONGTEXT, true) -#else set_capability( "video decoder", 80 ) -#endif set_callbacks( OpenDecoder, CloseGeneric ) #ifndef __ANDROID__ add_submodule() -# if defined(USE_IOMX) - set_capability("audio decoder", 0) -# else set_capability("audio decoder", 80) -# endif set_callbacks(OpenDecoder, CloseGeneric) #endif @@ -304,12 +236,6 @@ static OMX_ERRORTYPE SetPortDefinition(decoder_t *p_dec, OmxPort *p_port, } else { - if( p_port->p_hwbuf ) - { - p_fmt->i_codec = VLC_CODEC_ANDROID_OPAQUE; - break; - } - if( !GetVlcChromaFormat( def->format.video.eColorFormat, &p_fmt->i_codec, 0 ) ) { @@ -395,7 +321,7 @@ static OMX_ERRORTYPE SetPortDefinition(decoder_t *p_dec, OmxPort *p_port, } } if (!strcmp(p_dec->p_sys->psz_component, "OMX.TI.DUCATI1.VIDEO.DECODER") && - def->eDir == OMX_DirOutput && !p_port->p_hwbuf) + def->eDir == OMX_DirOutput) { /* When setting the output buffer size above, the decoder actually * sets the buffer size to a lower value than what was chosen. If @@ -466,18 +392,7 @@ static OMX_ERRORTYPE AllocateBuffers(decoder_t *p_dec, OmxPort *p_port) p_port->pp_buffers[i] = (void *)ALIGN((uintptr_t)p_buf, p_port->definition.nBufferAlignment); #endif - if( p_port->p_hwbuf ) - { - omx_error = - OMX_UseBuffer( p_sys->omx_handle, &p_port->pp_buffers[i], - p_port->i_port_index, 0, - p_port->definition.nBufferSize, - p_port->p_hwbuf->pp_handles[i] ); - OMX_DBG( "OMX_UseBuffer(%d) %p, %p", def->eDir, - (void *)p_port->pp_buffers[i], - p_port->p_hwbuf->pp_handles[i] ); - } - else if( p_port->b_direct ) + if( p_port->b_direct ) { omx_error = OMX_UseBuffer( p_sys->omx_handle, &p_port->pp_buffers[i], @@ -503,8 +418,7 @@ static OMX_ERRORTYPE AllocateBuffers(decoder_t *p_dec, OmxPort *p_port) p_port->i_buffers = i; break; } - if( !p_port->p_hwbuf ) - OMX_FIFO_PUT(&p_port->fifo, p_port->pp_buffers[i]); + OMX_FIFO_PUT(&p_port->fifo, p_port->pp_buffers[i]); } CHECK_ERROR(omx_error, "AllocateBuffers failed (%x, %i)", @@ -526,17 +440,7 @@ static OMX_ERRORTYPE FreeBuffers(decoder_t *p_dec, OmxPort *p_port) OMX_BUFFERHEADERTYPE *p_buffer; unsigned int i, i_wait_buffers; - /* Normally, all buffers are in the port fifo, or given to the codec that - * will return them when disabling the port or changing state, therefore we - * normally wait for all buffers. For IOMX direct rendering (HwBuffer), - * only a few buffers are given to the codec at a time, thus we can only - * wait for that many buffers. And after that, we can still free all OMX - * buffers since we either got some of them returned via OMX_FIFO_GET, or - * never passed them to the codec at all. */ - if( p_port->p_hwbuf ) - i_wait_buffers = p_port->p_hwbuf->i_owned; - else - i_wait_buffers = p_port->i_buffers; + i_wait_buffers = p_port->i_buffers; OMX_DBG( "FreeBuffers(%d), waiting for %u buffers", def->eDir, i_wait_buffers); @@ -622,9 +526,6 @@ static OMX_ERRORTYPE GetPortDefinition(decoder_t *p_dec, OmxPort *p_port, p_fmt->video.i_visible_height = crop_rect.nHeight; if (def->format.video.eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar) def->format.video.nSliceHeight -= crop_rect.nTop/2; - - if( p_port->p_hwbuf ) - HwBuffer_SetCrop( p_dec, p_port, &crop_rect ); } else { @@ -632,11 +533,6 @@ static OMX_ERRORTYPE GetPortDefinition(decoder_t *p_dec, OmxPort *p_port, omx_error = OMX_ErrorNone; } - if( p_port->p_hwbuf ) - { - UpdatePixelAspect(p_dec); - break; - } /* Hack: Nexus One (stock firmware with binary OMX driver blob) * claims to output 420Planar even though it in in practice is * NV21. */ @@ -748,9 +644,6 @@ static OMX_ERRORTYPE DeinitialiseComponent(decoder_t *p_dec, omx_error = OMX_GetState(omx_handle, &state); CHECK_ERROR(omx_error, "OMX_GetState failed (%x)", omx_error ); - if( p_sys->out.p_hwbuf && HwBuffer_Stop( p_dec, &p_sys->out ) != 0 ) - msg_Warn( p_dec, "HwBuffer_Stop failed" ); - if(state == OMX_StateExecuting) { omx_error = OMX_SendCommand( omx_handle, OMX_CommandStateSet, @@ -783,11 +676,6 @@ static OMX_ERRORTYPE DeinitialiseComponent(decoder_t *p_dec, omx_error = FreeBuffers( p_dec, p_port ); CHECK_ERROR(omx_error, "FreeBuffers failed (%x, %i)", omx_error, (int)p_port->i_port_index ); - if( p_port->p_hwbuf ) - { - HwBuffer_FreeBuffers( p_dec, p_port ); - HwBuffer_Join( p_dec, p_port ); - } } omx_error = WaitForSpecificOmxEvent(&p_sys->event_queue, OMX_EventCmdComplete, 0, 0, 0); @@ -813,7 +701,6 @@ static OMX_ERRORTYPE DeinitialiseComponent(decoder_t *p_dec, msg_Warn( p_dec, "Stray buffer left in fifo, %p", (void *)p_buffer ); } - HwBuffer_Destroy( p_dec, p_port ); } omx_error = pf_free_handle( omx_handle ); return omx_error; @@ -909,7 +796,6 @@ static OMX_ERRORTYPE InitialiseComponent(decoder_t *p_dec, p_port->i_port_index = definition.nPortIndex; p_port->definition = definition; p_port->omx_handle = omx_handle; - HwBuffer_Init( p_dec, p_port ); } if(!p_sys->in.b_valid || !p_sys->out.b_valid) @@ -918,8 +804,7 @@ static OMX_ERRORTYPE InitialiseComponent(decoder_t *p_dec, CHECK_ERROR(omx_error, "couldn't find an input and output port"); } - if( !p_sys->out.p_hwbuf && !strncmp(p_sys->psz_component, "OMX.SEC.", 8) && - p_dec->fmt_in.i_cat == VIDEO_ES ) + if( !strncmp(p_sys->psz_component, "OMX.SEC.", 8) && p_dec->fmt_in.i_cat == VIDEO_ES ) { OMX_INDEXTYPE index; omx_error = OMX_GetExtensionIndex(omx_handle, (OMX_STRING) "OMX.SEC.index.ThumbnailMode", &index); @@ -1094,11 +979,7 @@ static int OpenGeneric( vlc_object_t *p_this, bool b_encode ) p_sys->in.b_flushed = true; p_sys->in.p_fmt = &p_dec->fmt_in; OMX_FIFO_INIT (&p_sys->out.fifo, pInputPortPrivate ); -#if defined(USE_IOMX) - p_sys->out.b_direct = var_InheritBool(p_dec, CFG_PREFIX "dr"); -#else p_sys->out.b_direct = false; -#endif p_sys->out.b_flushed = true; p_sys->out.p_fmt = &p_dec->fmt_out; p_sys->ports = 2; @@ -1144,14 +1025,6 @@ static int OpenGeneric( vlc_object_t *p_this, bool b_encode ) for(i = 0; i < p_sys->ports; i++) { OmxPort *p_port = &p_sys->p_ports[i]; - if( p_port->p_hwbuf ) - { - if( HwBuffer_AllocateBuffers( p_dec, p_port ) != 0 ) - { - omx_error = OMX_ErrorInsufficientResources; - goto error; - } - } omx_error = AllocateBuffers( p_dec, p_port ); CHECK_ERROR(omx_error, "AllocateBuffers failed (%x, %i)", omx_error, (int)p_port->i_port_index ); @@ -1166,12 +1039,6 @@ static int OpenGeneric( vlc_object_t *p_this, bool b_encode ) omx_error = WaitForSpecificOmxEvent(&p_sys->event_queue, OMX_EventCmdComplete, 0, 0, 0); CHECK_ERROR(omx_error, "Wait for Executing failed (%x)", omx_error ); - if( p_sys->out.p_hwbuf && HwBuffer_Start( p_dec, &p_sys->out ) != 0 ) - { - omx_error = OMX_ErrorUndefined; - goto error; - } - /* Send codec configuration data */ if( p_dec->fmt_in.i_extra ) { @@ -1291,9 +1158,6 @@ static OMX_ERRORTYPE PortReconfigure(decoder_t *p_dec, OmxPort *p_port) !definition.format.video.nFrameHeight)) ) return OMX_ErrorUndefined; - if( p_port->p_hwbuf && HwBuffer_Stop( p_dec, p_port ) != 0 ) - msg_Warn( p_dec, "HwBuffer_Stop failed" ); - omx_error = OMX_SendCommand( p_sys->omx_handle, OMX_CommandPortDisable, p_port->i_port_index, NULL); CHECK_ERROR(omx_error, "OMX_CommandPortDisable on %i failed (%x)", @@ -1303,12 +1167,6 @@ static OMX_ERRORTYPE PortReconfigure(decoder_t *p_dec, OmxPort *p_port) CHECK_ERROR(omx_error, "FreeBuffers failed (%x, %i)", omx_error, (int)p_port->i_port_index ); - if( p_port->p_hwbuf ) - { - HwBuffer_FreeBuffers( p_dec, p_port ); - HwBuffer_Join( p_dec, p_port ); - } - omx_error = WaitForSpecificOmxEvent(&p_sys->event_queue, OMX_EventCmdComplete, 0, 0, 0); CHECK_ERROR(omx_error, "Wait for PortDisable failed (%x)", omx_error ); @@ -1316,15 +1174,7 @@ static OMX_ERRORTYPE PortReconfigure(decoder_t *p_dec, OmxPort *p_port) omx_error = GetPortDefinition(p_dec, &p_sys->out, p_sys->out.p_fmt); if(omx_error != OMX_ErrorNone) goto error; - if( p_port->p_hwbuf ) - { - if( HwBuffer_AllocateBuffers( p_dec, p_port ) != 0 ) - { - omx_error = OMX_ErrorInsufficientResources; - goto error; - } - } - else if( p_dec->fmt_in.i_cat != AUDIO_ES ) + if( p_dec->fmt_in.i_cat != AUDIO_ES ) { /* Don't explicitly set the new parameters that we got with * OMX_GetParameter above when using audio codecs. @@ -1355,12 +1205,6 @@ static OMX_ERRORTYPE PortReconfigure(decoder_t *p_dec, OmxPort *p_port) omx_error = WaitForSpecificOmxEvent(&p_sys->event_queue, OMX_EventCmdComplete, 0, 0, 0); CHECK_ERROR(omx_error, "Wait for PortEnable failed (%x)", omx_error ); - if( p_port->p_hwbuf && HwBuffer_Start( p_dec, p_port ) != 0 ) - { - omx_error = OMX_ErrorUndefined; - goto error; - } - PrintOmx(p_dec, p_sys->omx_handle, p_dec->p_sys->in.i_port_index); PrintOmx(p_dec, p_sys->omx_handle, p_dec->p_sys->out.i_port_index); @@ -1393,14 +1237,6 @@ static int DecodeVideoOutput( decoder_t *p_dec, OmxPort *p_port, picture_t **pp_ if( decoder_UpdateVideoFormat( p_dec ) ) goto error; - if( p_port->p_hwbuf ) - { - if( HwBuffer_GetPic( p_dec, p_port, &p_pic ) != 0 ) - goto error; - else - continue; - } - if(p_header->nFilledLen) { p_pic = p_header->pAppPrivate; @@ -1621,31 +1457,6 @@ static int DecodeVideo( decoder_t *p_dec, block_t *p_block ) continue; } attempts++; - /* With opaque DR the output buffers are released by the - vout therefore we implement a timeout for polling in - order to avoid being indefinitely stalled in this loop, if - playback is paused. */ - if( p_sys->out.p_hwbuf && attempts == max_polling_attempts ) { -#ifdef USE_IOMX - picture_t *invalid_picture = NULL; - if( !decoder_UpdateVideoFormat(p_dec)) - invalid_picture = decoder_NewPicture(p_dec); - if (invalid_picture) { - invalid_picture->date = VLC_TS_INVALID; - picture_sys_t *p_picsys = invalid_picture->p_sys; - p_picsys->hw.p_dec = NULL; - p_picsys->hw.i_index = -1; - return VLCDEC_SUCCESS; - } else { - /* If we cannot return a picture we must free the - block since the decoder will proceed with the - next block. */ - block_Release(p_block); - p_block = NULL; - return VLCDEC_SUCCESS; - } -#endif - } } return VLCDEC_SUCCESS; @@ -2012,589 +1823,3 @@ static OMX_ERRORTYPE OmxFillBufferDone( OMX_HANDLETYPE omx_handle, return OMX_ErrorNone; } - -#if defined(USE_IOMX) - -/* Life cycle of buffers when using IOMX direct rendering (HwBuffer): - * - * <- android display - * DequeueThread owned++ - * -> OMX_FillThisBuffer - * ... - * <- FillBufferDone OMX_FIFO_PUT - * ... - * DecodeVideoOutput OMX_FIFO_GET - * -> vlc core - * ... - * DisplayBuffer - * -> android display owned-- - */ - -/***************************************************************************** - * HwBuffer_ChangeState - *****************************************************************************/ -static void HwBuffer_ChangeState( decoder_t *p_dec, OmxPort *p_port, - int i_index, int i_state ) -{ - VLC_UNUSED( p_dec ); - p_port->p_hwbuf->i_states[i_index] = i_state; - if( i_state == BUF_STATE_OWNED ) - p_port->p_hwbuf->i_owned++; - else - p_port->p_hwbuf->i_owned--; - - OMX_DBG( "buffer[%d]: state -> %d, owned buffers: %u", - i_index, i_state, p_port->p_hwbuf->i_owned ); -} - -/***************************************************************************** - * HwBuffer_Init - *****************************************************************************/ -static void HwBuffer_Init( decoder_t *p_dec, OmxPort *p_port ) -{ - VLC_UNUSED( p_dec ); - OMX_ERRORTYPE omx_error; - picture_t *p_dummy_hwpic = NULL; - - if( !p_port->b_direct || p_port->definition.eDir != OMX_DirOutput || - p_port->p_fmt->i_cat != VIDEO_ES ) - return; - - msg_Dbg( p_dec, "HwBuffer_Init"); - - if( !(pf_enable_graphic_buffers && pf_get_graphic_buffer_usage && - pf_get_hal_format && - ((OMX_COMPONENTTYPE*)p_port->omx_handle)->UseBuffer) ) - { - msg_Warn( p_dec, "direct output port enabled but can't find " - "extra symbols, switch back to non direct" ); - goto error; - } - - p_dec->fmt_out.i_codec = VLC_CODEC_ANDROID_OPAQUE; - if (decoder_UpdateVideoFormat(p_dec) != 0 - || (p_dummy_hwpic = decoder_NewPicture(p_dec)) == NULL) - { - msg_Err(p_dec, "Opaque Vout request failed"); - goto error; - } - ANativeWindow *p_anw = p_dummy_hwpic->p_sys->hw.p_surface; - if( !p_anw ) - goto error; - - p_port->p_hwbuf = calloc(1, sizeof(HwBuffer)); - if( !p_port->p_hwbuf ) - { - goto error; - } - vlc_mutex_init (&p_port->p_hwbuf->lock); - vlc_cond_init (&p_port->p_hwbuf->wait); - - if( android_loadNativeWindowPrivApi( &p_port->p_hwbuf->anwpriv ) ) - { - msg_Warn( p_dec, "android_loadNativeWindowPrivApi failed" ); - goto error; - } - - p_port->p_hwbuf->window_priv = p_port->p_hwbuf->anwpriv.connect( p_anw ); - if( !p_port->p_hwbuf->window_priv ) { - msg_Warn( p_dec, "connect failed" ); - goto error; - } - - omx_error = pf_enable_graphic_buffers( p_port->omx_handle, - p_port->i_port_index, OMX_TRUE ); - CHECK_ERROR( omx_error, "can't enable graphic buffers" ); - - /* PortDefinition may change after pf_enable_graphic_buffers call */ - omx_error = OMX_GetParameter( p_port->omx_handle, - OMX_IndexParamPortDefinition, - &p_port->definition ); - CHECK_ERROR( omx_error, "OMX_GetParameter failed (GraphicBuffers) (%x : %s)", - omx_error, ErrorToString(omx_error) ); - - - msg_Dbg( p_dec, "direct output port enabled" ); - if (p_dummy_hwpic != NULL) - picture_Release(p_dummy_hwpic); - return; -error: - if (p_dummy_hwpic != NULL) - picture_Release(p_dummy_hwpic); - /* if HwBuffer_Init fails, we can fall back to non direct buffers */ - HwBuffer_Destroy( p_dec, p_port ); -} - -/***************************************************************************** - * HwBuffer_Destroy - *****************************************************************************/ -static void HwBuffer_Destroy( decoder_t *p_dec, OmxPort *p_port ) -{ - if( p_port->p_hwbuf ) - { - if( p_port->p_hwbuf->window_priv ) - { - HwBuffer_Stop( p_dec, p_port ); - HwBuffer_FreeBuffers( p_dec, p_port ); - HwBuffer_Join( p_dec, p_port ); - p_port->p_hwbuf->anwpriv.disconnect( p_port->p_hwbuf->window_priv ); - pf_enable_graphic_buffers( p_port->omx_handle, - p_port->i_port_index, OMX_FALSE ); - } - - vlc_cond_destroy( &p_port->p_hwbuf->wait ); - vlc_mutex_destroy( &p_port->p_hwbuf->lock ); - free( p_port->p_hwbuf ); - p_port->p_hwbuf = NULL; - } - p_port->b_direct = false; -} - -/***************************************************************************** - * HwBuffer_AllocateBuffers - *****************************************************************************/ -static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port ) -{ - decoder_sys_t *p_sys = p_dec->p_sys; - OMX_PARAM_PORTDEFINITIONTYPE *def = &p_port->definition; - unsigned int min_undequeued = 0; - unsigned int i = 0; - int colorFormat = def->format.video.eColorFormat; - OMX_ERRORTYPE omx_error; - OMX_U32 i_hw_usage; - - if( !p_port->p_hwbuf ) - return 0; - - omx_error = pf_get_hal_format( p_sys->psz_component, &colorFormat ); - if( omx_error != OMX_ErrorNone ) - { - msg_Warn( p_dec, "pf_get_hal_format failed (Not fatal)" ); - } - - omx_error = pf_get_graphic_buffer_usage( p_port->omx_handle, - p_port->i_port_index, - &i_hw_usage ); - if( omx_error != OMX_ErrorNone ) - { - msg_Warn( p_dec, "pf_get_graphic_buffer_usage failed (Not fatal)" ); - i_hw_usage = 0; - } - - if( p_port->p_fmt->video.orientation != ORIENT_NORMAL ) - { - int i_angle; - - switch( p_port->p_fmt->video.orientation ) - { - case ORIENT_ROTATED_90: - i_angle = 90; - break; - case ORIENT_ROTATED_180: - i_angle = 180; - break; - case ORIENT_ROTATED_270: - i_angle = 270; - break; - default: - i_angle = 0; - } - p_port->p_hwbuf->anwpriv.setOrientation( p_port->p_hwbuf->window_priv, - i_angle ); - } - - if( p_port->p_hwbuf->anwpriv.setUsage( p_port->p_hwbuf->window_priv, - true, (int) i_hw_usage ) != 0 ) - { - msg_Err( p_dec, "can't set usage" ); - goto error; - } - if( p_port->p_hwbuf->anwpriv.setBuffersGeometry( p_port->p_hwbuf->window_priv, - def->format.video.nFrameWidth, - def->format.video.nFrameHeight, - colorFormat ) != 0 ) - { - msg_Err( p_dec, "can't set buffers geometry" ); - goto error; - } - - if( p_port->p_hwbuf->anwpriv.getMinUndequeued( p_port->p_hwbuf->window_priv, - &min_undequeued ) != 0 ) - { - msg_Err( p_dec, "can't get min_undequeued" ); - goto error; - } - - if( def->nBufferCountActual < def->nBufferCountMin + min_undequeued ) - { - unsigned int new_frames_num = def->nBufferCountMin + min_undequeued; - - OMX_DBG( "AllocateBuffers: video out wants more frames: %lu vs %u", - p_port->definition.nBufferCountActual, new_frames_num ); - - p_port->definition.nBufferCountActual = new_frames_num; - omx_error = OMX_SetParameter( p_dec->p_sys->omx_handle, - OMX_IndexParamPortDefinition, - &p_port->definition ); - CHECK_ERROR( omx_error, "OMX_SetParameter failed (%x : %s)", - omx_error, ErrorToString(omx_error) ); - } - - if( p_port->p_hwbuf->anwpriv.setBufferCount( p_port->p_hwbuf->window_priv, - def->nBufferCountActual ) != 0 ) - { - msg_Err( p_dec, "can't set buffer_count" ); - goto error; - } - - p_port->p_hwbuf->i_buffers = p_port->definition.nBufferCountActual; - p_port->p_hwbuf->i_max_owned = p_port->p_hwbuf->i_buffers - min_undequeued; - - p_port->p_hwbuf->pp_handles = calloc( p_port->p_hwbuf->i_buffers, - sizeof(void *) ); - if( !p_port->p_hwbuf->pp_handles ) - goto error; - - p_port->p_hwbuf->i_states = calloc( p_port->p_hwbuf->i_buffers, sizeof(int) ); - if( !p_port->p_hwbuf->i_states ) - goto error; - - p_port->p_hwbuf->inflight_picture = calloc( p_port->p_hwbuf->i_buffers, - sizeof(picture_sys_t*) ); - if( !p_port->p_hwbuf->inflight_picture ) - goto error; - - for(i = 0; i < p_port->p_hwbuf->i_buffers; i++) - { - void *p_handle = NULL; - - if( p_port->p_hwbuf->anwpriv.dequeue( p_port->p_hwbuf->window_priv, - &p_handle ) != 0 ) - { - msg_Err( p_dec, "OMXHWBuffer_dequeue Fail" ); - goto error; - } - p_port->p_hwbuf->pp_handles[i] = p_handle; - } - for(i = 0; i < p_port->p_hwbuf->i_max_owned; i++) - HwBuffer_ChangeState( p_dec, p_port, i, BUF_STATE_OWNED ); - for(; i < p_port->p_hwbuf->i_buffers; i++) - { - OMX_DBG( "canceling buffer(%d)", i ); - p_port->p_hwbuf->anwpriv.cancel( p_port->p_hwbuf->window_priv, - p_port->p_hwbuf->pp_handles[i] ); - } - - return 0; - -error: - - msg_Err( p_dec, "HwBuffer_AllocateBuffers(%d) failed", def->eDir ); - return -1; -} - -/***************************************************************************** - * HwBuffer_FreeBuffers - *****************************************************************************/ -static int HwBuffer_FreeBuffers( decoder_t *p_dec, OmxPort *p_port ) -{ - msg_Dbg( p_dec, "HwBuffer_FreeBuffers"); - - HWBUFFER_LOCK( p_port ); - - p_port->p_hwbuf->b_run = false; - - if( p_port->p_hwbuf->pp_handles ) - { - for(unsigned int i = 0; i < p_port->p_hwbuf->i_buffers; i++) - { - void *p_handle = p_port->p_hwbuf->pp_handles[i]; - - if( p_handle && p_port->p_hwbuf->i_states[i] == BUF_STATE_OWNED ) - { - p_port->p_hwbuf->anwpriv.cancel( p_port->p_hwbuf->window_priv, p_handle ); - HwBuffer_ChangeState( p_dec, p_port, i, BUF_STATE_NOT_OWNED ); - } - } - } - HWBUFFER_BROADCAST( p_port ); - - HWBUFFER_UNLOCK( p_port ); - - p_port->p_hwbuf->i_buffers = 0; - - free( p_port->p_hwbuf->pp_handles ); - p_port->p_hwbuf->pp_handles = NULL; - - free( p_port->p_hwbuf->i_states ); - p_port->p_hwbuf->i_states = NULL; - - free( p_port->p_hwbuf->inflight_picture ); - p_port->p_hwbuf->inflight_picture = NULL; - - return 0; -} - -/***************************************************************************** - * HwBuffer_Start - *****************************************************************************/ -static int HwBuffer_Start( decoder_t *p_dec, OmxPort *p_port ) -{ - OMX_BUFFERHEADERTYPE *p_header; - - msg_Dbg( p_dec, "HwBuffer_Start" ); - HWBUFFER_LOCK( p_port ); - - /* fill all owned buffers dequeued by HwBuffer_AllocatesBuffers */ - for(unsigned int i = 0; i < p_port->p_hwbuf->i_buffers; i++) - { - p_header = p_port->pp_buffers[i]; - - if( p_header && p_port->p_hwbuf->i_states[i] == BUF_STATE_OWNED ) - { - if( p_port->p_hwbuf->anwpriv.lock( p_port->p_hwbuf->window_priv, - p_header->pBuffer ) != 0 ) - { - msg_Err( p_dec, "lock failed" ); - HWBUFFER_UNLOCK( p_port ); - return -1; - } - OMX_DBG( "FillThisBuffer %p, %p", (void *)p_header, - (void *)p_header->pBuffer ); - OMX_FillThisBuffer( p_port->omx_handle, p_header ); - } - } - - p_port->p_hwbuf->b_run = true; - if( vlc_clone( &p_port->p_hwbuf->dequeue_thread, - DequeueThread, p_dec, VLC_THREAD_PRIORITY_LOW ) ) - { - p_port->p_hwbuf->b_run = false; - HWBUFFER_UNLOCK( p_port ); - return -1; - } - - HWBUFFER_UNLOCK( p_port ); - - return 0; -} - -/***************************************************************************** - * HwBuffer_Stop: stop DequeueThread and invalidate all pictures that are sent - * to vlc core. The thread can be stuck in dequeue, so don't - * join it now since it can be unblocked later by HwBuffer_FreeBuffers. - *****************************************************************************/ -static int HwBuffer_Stop( decoder_t *p_dec, OmxPort *p_port ) -{ - VLC_UNUSED( p_dec ); - - msg_Dbg( p_dec, "HwBuffer_Stop" ); - HWBUFFER_LOCK( p_port ); - - p_port->p_hwbuf->b_run = false; - - /* invalidate and release all inflight pictures */ - if( p_port->p_hwbuf->inflight_picture ) { - for( unsigned int i = 0; i < p_port->i_buffers; ++i ) { - picture_sys_t *p_picsys = p_port->p_hwbuf->inflight_picture[i]; - if( p_picsys ) - { - AndroidOpaquePicture_DetachDecoder(p_picsys); - p_port->p_hwbuf->inflight_picture[i] = NULL; - } - } - } - - HWBUFFER_BROADCAST( p_port ); - - HWBUFFER_UNLOCK( p_port ); - - return 0; -} - -/***************************************************************************** - * HwBuffer_Join: join DequeueThread previously stopped by HwBuffer_Stop. - *****************************************************************************/ -static int HwBuffer_Join( decoder_t *p_dec, OmxPort *p_port ) -{ - VLC_UNUSED( p_dec ); - - if( p_port->p_hwbuf->dequeue_thread ) - { - vlc_join( p_port->p_hwbuf->dequeue_thread, NULL ); - p_port->p_hwbuf->dequeue_thread = NULL; - } - return 0; -} - -/***************************************************************************** - * HwBuffer_GetPic - *****************************************************************************/ -static int HwBuffer_GetPic( decoder_t *p_dec, OmxPort *p_port, - picture_t **pp_pic) -{ - int i_index = -1; - picture_t *p_pic; - picture_sys_t *p_picsys; - OMX_BUFFERHEADERTYPE *p_header; - - OMX_FIFO_PEEK(&p_port->fifo, p_header); - - if( !p_header ) - return 0; - - for(unsigned int i = 0; i < p_port->i_buffers; i++) - { - if( p_port->pp_buffers[i] == p_header ) - { - i_index = i; - break; - } - } - if( i_index == -1 ) - { - msg_Err( p_dec, "output buffer not found" ); - return -1; - } - - p_pic = decoder_NewPicture( p_dec ); - if(!p_pic) - { - msg_Err( p_dec, "decoder_NewPicture failed" ); - return -1; - } - p_pic->date = FromOmxTicks( p_header->nTimeStamp ); - - p_picsys = p_pic->p_sys; - p_picsys->hw.i_index = i_index; - p_picsys->hw.p_dec = p_dec; - p_picsys->hw.pf_release = ReleasePicture; - - p_port->p_hwbuf->inflight_picture[i_index] = p_picsys; - - *pp_pic = p_pic; - OMX_FIFO_GET( &p_port->fifo, p_header ); - return 0; -} - -/***************************************************************************** - * HwBuffer_SetCrop - *****************************************************************************/ -static void HwBuffer_SetCrop( decoder_t *p_dec, OmxPort *p_port, - OMX_CONFIG_RECTTYPE *p_rect ) -{ - VLC_UNUSED( p_dec ); - - p_port->p_hwbuf->anwpriv.setCrop( p_port->p_hwbuf->window_priv, - p_rect->nLeft, p_rect->nTop, - p_rect->nWidth, p_rect->nHeight ); -} - -/***************************************************************************** - * DequeueThread - *****************************************************************************/ -static void *DequeueThread( void *data ) -{ - decoder_t *p_dec = data; - decoder_sys_t *p_sys = p_dec->p_sys;; - OmxPort *p_port = &p_sys->out; - unsigned int i; - int i_index = -1; - int err; - void *p_handle = NULL; - OMX_BUFFERHEADERTYPE *p_header; - - msg_Dbg( p_dec, "DequeueThread running"); - HWBUFFER_LOCK( p_port ); - while( p_port->p_hwbuf->b_run ) - { - while( p_port->p_hwbuf->b_run && - p_port->p_hwbuf->i_owned >= p_port->p_hwbuf->i_max_owned ) - HWBUFFER_WAIT( p_port ); - - if( !p_port->p_hwbuf->b_run ) continue; - - HWBUFFER_UNLOCK( p_port ); - - - /* The thread can be stuck here. It shouldn't happen since we make sure - * we call the dequeue function if there is at least one buffer - * available. */ - err = p_port->p_hwbuf->anwpriv.dequeue( p_port->p_hwbuf->window_priv, &p_handle ); - if( err == 0 ) - err = p_port->p_hwbuf->anwpriv.lock( p_port->p_hwbuf->window_priv, p_handle ); - - HWBUFFER_LOCK( p_port ); - - if( err != 0 ) { - if( err != -EBUSY ) - p_port->p_hwbuf->b_run = false; - continue; - } - - if( !p_port->p_hwbuf->b_run ) - { - p_port->p_hwbuf->anwpriv.cancel( p_port->p_hwbuf->window_priv, p_handle ); - continue; - } - - for(i = 0; i < p_port->i_buffers; i++) - { - if( p_port->pp_buffers[i]->pBuffer == p_handle ) - { - i_index = i; - p_header = p_port->pp_buffers[i_index]; - break; - } - } - if( i_index == -1 ) - { - msg_Err( p_dec, "p_port->p_hwbuf->anwpriv.dequeue returned unknown handle" ); - continue; - } - - HwBuffer_ChangeState( p_dec, p_port, i_index, BUF_STATE_OWNED ); - - OMX_DBG( "FillThisBuffer %p, %p", (void *)p_header, - (void *)p_header->pBuffer ); - OMX_FillThisBuffer( p_sys->omx_handle, p_header ); - - HWBUFFER_BROADCAST( p_port ); - } - HWBUFFER_UNLOCK( p_port ); - - msg_Dbg( p_dec, "DequeueThread stopped"); - return NULL; -} - -/***************************************************************************** - * vout callbacks - *****************************************************************************/ -static void ReleasePicture( decoder_t *p_dec, unsigned int i_index, - bool b_render ) -{ - decoder_sys_t *p_sys = p_dec->p_sys; - OmxPort *p_port = &p_sys->out; - void *p_handle; - - p_handle = p_port->pp_buffers[i_index]->pBuffer; - - OMX_DBG( "DisplayBuffer: %s %p", - b_render ? "render" : "cancel", p_handle ); - - if( !p_handle ) - { - msg_Err( p_dec, "DisplayBuffer: buffer handle invalid" ); - return; - } - - if( b_render ) - p_port->p_hwbuf->anwpriv.queue( p_port->p_hwbuf->window_priv, p_handle ); - else - p_port->p_hwbuf->anwpriv.cancel( p_port->p_hwbuf->window_priv, p_handle ); - - HwBuffer_ChangeState( p_dec, p_port, i_index, BUF_STATE_NOT_OWNED ); - HWBUFFER_BROADCAST( p_port ); -} - -#endif // USE_IOMX diff --git a/modules/codec/omxil/omxil.h b/modules/codec/omxil/omxil.h index 66b75a41d3f2f67d4c738822c657b1b2bf7c28d2..bec0a51799be67b6d4c5a1fc50c042bb9739848d 100644 --- a/modules/codec/omxil/omxil.h +++ b/modules/codec/omxil/omxil.h @@ -36,10 +36,6 @@ #include "omxil_utils.h" #include "omxil_core.h" -#if defined(USE_IOMX) -#include "../../video_output/android/utils.h" -#endif - enum { BUF_STATE_NOT_OWNED = 0, @@ -61,27 +57,6 @@ typedef struct OmxFifo } OmxFifo; -typedef struct HwBuffer -{ - vlc_thread_t dequeue_thread; - bool b_run; - vlc_mutex_t lock; - vlc_cond_t wait; - picture_sys_t** inflight_picture; /**< stores the inflight picture for each output buffer or NULL */ - - unsigned int i_buffers; - void **pp_handles; - int *i_states; - unsigned int i_max_owned; - unsigned int i_owned; - -#if defined(USE_IOMX) - native_window_priv_api_t anwpriv; - native_window_priv *window_priv; -#endif - -} HwBuffer; - typedef struct OmxPort { bool b_valid; @@ -105,9 +80,6 @@ typedef struct OmxPort OMX_BOOL b_update_def; OMX_BOOL b_direct; OMX_BOOL b_flushed; - - HwBuffer *p_hwbuf; - } OmxPort; struct decoder_sys_t diff --git a/modules/codec/omxil/omxil_core.c b/modules/codec/omxil/omxil_core.c index e55488c9dadf1d9185e236384c0954e4528b5583..d783ed9e1dd04509d608766049227e5dce1e54e9 100644 --- a/modules/codec/omxil/omxil_core.c +++ b/modules/codec/omxil/omxil_core.c @@ -29,15 +29,8 @@ #endif #include -#if defined(USE_IOMX) -/* On dll_open, just check that the OMX_Init symbol already is loaded */ -# define dll_open(name) dlsym(RTLD_DEFAULT, "OMX_Init") -# define dll_close(handle) do { } while (0) -# define dlsym(handle, name) dlsym(RTLD_DEFAULT, "I" name) -#else -# define dll_open(name) dlopen( name, RTLD_NOW ) -# define dll_close(handle) dlclose(handle) -#endif +#define dll_open(name) dlopen( name, RTLD_NOW ) +#define dll_close(handle) dlclose(handle) #include #include @@ -53,9 +46,7 @@ *****************************************************************************/ static const char *ppsz_dll_list[] = { -#if defined(USE_IOMX) - "libiomx.so", /* Not used when using IOMX, the lib should already be loaded */ -#elif defined(RPI_OMX) +#if defined(RPI_OMX) "/opt/vc/lib/libopenmaxil.so", /* Broadcom IL core */ #elif 1 "libOMX_Core.so", /* TI OMAP IL core */ @@ -88,9 +79,6 @@ OMX_ERRORTYPE (*pf_get_handle) (OMX_HANDLETYPE *, OMX_STRING, OMX_ERRORTYPE (*pf_free_handle) (OMX_HANDLETYPE); OMX_ERRORTYPE (*pf_component_enum)(OMX_STRING, OMX_U32, OMX_U32); OMX_ERRORTYPE (*pf_get_roles_of_component)(OMX_STRING, OMX_U32 *, OMX_U8 **); -OMX_ERRORTYPE (*pf_enable_graphic_buffers)(OMX_HANDLETYPE, OMX_U32, OMX_BOOL); -OMX_ERRORTYPE (*pf_get_graphic_buffer_usage)(OMX_HANDLETYPE, OMX_U32, OMX_U32*); -OMX_ERRORTYPE (*pf_get_hal_format) (const char *, int *); #ifdef RPI_OMX static void *extra_dll_handle; @@ -164,11 +152,6 @@ int InitOmxCore(vlc_object_t *p_this) vlc_mutex_unlock( &omx_core_mutex ); return VLC_EGENERIC; } -#if defined(USE_IOMX) - pf_enable_graphic_buffers = dlsym( dll_handle, "OMXAndroid_EnableGraphicBuffers" ); - pf_get_graphic_buffer_usage = dlsym( dll_handle, "OMXAndroid_GetGraphicBufferUsage" ); - pf_get_hal_format = dlsym( dll_handle, "OMXAndroid_GetHalFormat" ); -#endif /* Initialise the OMX core */ OMX_ERRORTYPE omx_error = pf_init(); diff --git a/modules/codec/omxil/omxil_core.h b/modules/codec/omxil/omxil_core.h index 30ffdcf4e9fcb4905456cbc53349c03ccc120026..b223f6b854dbe21ab7add76727add7f24fd79521 100644 --- a/modules/codec/omxil/omxil_core.h +++ b/modules/codec/omxil/omxil_core.h @@ -33,11 +33,6 @@ OMX_ERRORTYPE (*pf_free_handle) (OMX_HANDLETYPE); OMX_ERRORTYPE (*pf_component_enum)(OMX_STRING, OMX_U32, OMX_U32); OMX_ERRORTYPE (*pf_get_roles_of_component)(OMX_STRING, OMX_U32 *, OMX_U8 **); -/* Extra IOMX android functions. Can be NULL if we don't link with libiomx */ -OMX_ERRORTYPE (*pf_enable_graphic_buffers)(OMX_HANDLETYPE, OMX_U32, OMX_BOOL); -OMX_ERRORTYPE (*pf_get_graphic_buffer_usage)(OMX_HANDLETYPE, OMX_U32, OMX_U32*); -OMX_ERRORTYPE (*pf_get_hal_format) (const char *, int *); - int InitOmxCore(vlc_object_t *p_this); void DeinitOmxCore(void);