OMX_ERRORTYPE OMXVideoDecoderBase::PrepareConfigBuffer(VideoConfigBuffer *p) { // default config buffer preparation memset(p, 0, sizeof(VideoConfigBuffer)); const OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionInput = this->ports[INPORT_INDEX]->GetPortDefinition(); if (paramPortDefinitionInput == NULL) { return OMX_ErrorBadParameter; } if (mWorkingMode == GRAPHICBUFFER_MODE) { p->surfaceNumber = mOMXBufferHeaderTypePtrNum; for (int i = 0; i < mOMXBufferHeaderTypePtrNum; i++){ OMX_BUFFERHEADERTYPE *buffer_hdr = mOMXBufferHeaderTypePtrArray[i]; p->graphicBufferHandler[i] = buffer_hdr->pBuffer; ALOGV("PrepareConfigBuffer bufferid = %p, handle = %p", buffer_hdr, buffer_hdr->pBuffer); } p->flag |= USE_NATIVE_GRAPHIC_BUFFER; p->graphicBufferStride = mGraphicBufferParam.graphicBufferStride; p->graphicBufferColorFormat = mGraphicBufferParam.graphicBufferColorFormat; p->graphicBufferWidth = mGraphicBufferParam.graphicBufferWidth; p->graphicBufferHeight = mGraphicBufferParam.graphicBufferHeight; if (p->graphicBufferColorFormat == OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar_Tiled #ifdef USE_GEN_HW || p->graphicBufferColorFormat == HAL_PIXEL_FORMAT_NV12_X_TILED_INTEL #endif ) p->flag |= USE_TILING_MEMORY; if (mEnableAdaptivePlayback) p->flag |= WANT_ADAPTIVE_PLAYBACK; PortVideo *port = NULL; port = static_cast<PortVideo *>(this->ports[INPORT_INDEX]); OMX_PARAM_PORTDEFINITIONTYPE port_def; memcpy(&port_def, port->GetPortDefinition(), sizeof(port_def)); if (port_def.format.video.pNativeWindow != NULL) { p->nativeWindow = port_def.format.video.pNativeWindow; ALOGD("NativeWindow = %p", p->nativeWindow); } } p->rotationDegrees = mRotationDegrees; #ifdef TARGET_HAS_VPP p->vppBufferNum = mVppBufferNum; #endif p->width = paramPortDefinitionInput->format.video.nFrameWidth; p->height = paramPortDefinitionInput->format.video.nFrameHeight; return OMX_ErrorNone; }
OMX_ERRORTYPE OMXVideoEncoderBase::SetStoreMetaDataInBuffers(OMX_PTR pStructure) { OMX_ERRORTYPE ret; StoreMetaDataInBuffersParams *p = (StoreMetaDataInBuffersParams *)pStructure; VideoParamsStoreMetaDataInBuffers StoreMetaDataInBuffers; PortVideo *port = static_cast<PortVideo *>(this->ports[INPORT_INDEX]); CHECK_TYPE_HEADER(p); CHECK_PORT_INDEX(p, INPORT_INDEX); LOGD("SetStoreMetaDataInBuffers (enabled = %x)", p->bStoreMetaData); if(mStoreMetaDataInBuffers == p->bStoreMetaData) return OMX_ErrorNone; StoreMetaDataInBuffers.isEnabled = p->bStoreMetaData; if (mVideoEncoder->setParameters(&StoreMetaDataInBuffers) != ENCODE_SUCCESS) return OMX_ErrorNotReady; mStoreMetaDataInBuffers = p->bStoreMetaData; if(mStoreMetaDataInBuffers){ // for input port buffer OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionInput; const OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionInput_get; paramPortDefinitionInput_get = port->GetPortDefinition(); paramPortDefinitionInput = (OMX_PARAM_PORTDEFINITIONTYPE *)paramPortDefinitionInput_get; paramPortDefinitionInput->nBufferSize = IntelMetadataBuffer::GetMaxBufferSize(); } else { const OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionInput_get; paramPortDefinitionInput_get = port->GetPortDefinition(); port->SetPortDefinition(paramPortDefinitionInput_get, true); } LOGD("SetStoreMetaDataInBuffers success"); return OMX_ErrorNone; };
bool OMXVideoDecoderVP9Hybrid::IsAllBufferAvailable(void) { bool b = ComponentBase::IsAllBufferAvailable(); if (b == false) { return false; } PortVideo *port = NULL; port = static_cast<PortVideo *>(this->ports[OUTPORT_INDEX]); const OMX_PARAM_PORTDEFINITIONTYPE* port_def = port->GetPortDefinition(); // if output port is disabled, retain the input buffer if (!port_def->bEnabled) { return false; } return mCheckBufferAvailable(mHybridCtx); }
OMX_ERRORTYPE OMXVideoDecoderBase::SetNativeBufferModeSpecific(OMX_PTR pStructure) { OMX_ERRORTYPE ret; EnableAndroidNativeBuffersParams *param = (EnableAndroidNativeBuffersParams*)pStructure; CHECK_TYPE_HEADER(param); CHECK_PORT_INDEX_RANGE(param); CHECK_SET_PARAM_STATE(); PortVideo *port = NULL; port = static_cast<PortVideo *>(this->ports[OUTPORT_INDEX]); OMX_PARAM_PORTDEFINITIONTYPE port_def; memcpy(&port_def,port->GetPortDefinition(),sizeof(port_def)); if (!param->enable) { mWorkingMode = RAWDATA_MODE; // If it is fallback from native mode the color format has been // already set to INTEL format. // We need to set back the default color format and Native stuff. port_def.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; port_def.format.video.pNativeRender = NULL; port_def.format.video.pNativeWindow = NULL; port->SetPortDefinition(&port_def,true); return OMX_ErrorNone; } mWorkingMode = GRAPHICBUFFER_MODE; port_def.nBufferCountMin = mNativeBufferCount; if (mEnableAdaptivePlayback) { SetMaxOutputBufferCount(&port_def); } else { port_def.nBufferCountActual = mNativeBufferCount; } port_def.format.video.cMIMEType = (OMX_STRING)VA_VED_RAW_MIME_TYPE; port_def.format.video.eColorFormat = OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar; port_def.format.video.nFrameHeight = (port_def.format.video.nFrameHeight + 0x1f) & ~0x1f; port_def.format.video.eColorFormat = GetOutputColorFormat( port_def.format.video.nFrameWidth); port->SetPortDefinition(&port_def,true); return OMX_ErrorNone; }