int32_t C2DColorConverter::getBuffReq(int32_t port, C2DBuffReq *req) { if (!req) return -1; if (port != C2D_INPUT && port != C2D_OUTPUT) return -1; memset(req, 0, sizeof(C2DBuffReq)); if (port == C2D_INPUT) { req->width = mSrcWidth; req->height = mSrcHeight; req->stride = calcStride(mSrcFormat, mSrcWidth); req->sliceHeight = mSrcHeight; req->lumaAlign = calcLumaAlign(mSrcFormat); req->sizeAlign = calcSizeAlign(mSrcFormat); req->size = calcSize(mSrcFormat, mSrcWidth, mSrcHeight); //add bpp? ALOGV("input req->size = %d\n", req->size); } else if (port == C2D_OUTPUT) { req->width = mDstWidth; req->height = mDstHeight; req->stride = calcStride(mDstFormat, mDstWidth); req->sliceHeight = mDstHeight; req->lumaAlign = calcLumaAlign(mDstFormat); req->sizeAlign = calcSizeAlign(mDstFormat); req->size = calcSize(mDstFormat, mDstWidth, mDstHeight); ALOGV("output req->size = %d\n", req->size); } return 0; }
LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) : LLRefCount(), mNumVerts(0), mNumIndices(0), mUsage(usage), mGLBuffer(0), mGLIndices(0), mMappedData(NULL), mMappedIndexData(NULL), mLocked(FALSE), mFinal(FALSE), mFilthy(FALSE), mEmpty(TRUE), mResized(FALSE), mDynamicSize(FALSE) { LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); if (!sEnableVBOs) { mUsage = 0 ; } if (mUsage == GL_STREAM_DRAW_ARB && !sUseStreamDraw) { mUsage = 0; } S32 stride = calcStride(typemask, mOffsets); mTypeMask = typemask; mStride = stride; sCount++; }
void* C2DColorConverter::getDummySurfaceDef(ColorConvertFormat format, size_t width, size_t height, bool isSource) { if (isYUVSurface(format)) { C2D_YUV_SURFACE_DEF * surfaceDef = new C2D_YUV_SURFACE_DEF; surfaceDef->format = getC2DFormat(format); surfaceDef->width = width; surfaceDef->height = height; surfaceDef->plane0 = (void *)0xaaaaaaaa; surfaceDef->phys0 = (void *)0xaaaaaaaa; surfaceDef->stride0 = calcStride(format, width); surfaceDef->plane1 = (void *)0xaaaaaaaa; surfaceDef->phys1 = (void *)0xaaaaaaaa; surfaceDef->stride1 = calcStride(format, width); surfaceDef->stride2 = 0; if (format == YCbCr420P || format == YCrCb420P) { printf("half stride for Cb Cr planes \n"); surfaceDef->stride1 = calcStride(format, width) / 2; surfaceDef->phys2 = (void *)0xaaaaaaaa; surfaceDef->stride2 = calcStride(format, width) / 2; } mC2DCreateSurface(isSource ? &mSrcSurface : &mDstSurface, isSource ? C2D_SOURCE : C2D_TARGET, (C2D_SURFACE_TYPE)(C2D_SURFACE_YUV_HOST | C2D_SURFACE_WITH_PHYS | C2D_SURFACE_WITH_PHYS_DUMMY), &(*surfaceDef)); return ((void *)surfaceDef); } else { C2D_RGB_SURFACE_DEF * surfaceDef = new C2D_RGB_SURFACE_DEF; surfaceDef->format = getC2DFormat(format); surfaceDef->width = width; surfaceDef->height = height; surfaceDef->buffer = (void *)0xaaaaaaaa; surfaceDef->phys = (void *)0xaaaaaaaa; surfaceDef->stride = calcStride(format, width); mC2DCreateSurface(isSource ? &mSrcSurface : &mDstSurface, isSource ? C2D_SOURCE : C2D_TARGET, (C2D_SURFACE_TYPE)(C2D_SURFACE_RGB_HOST | C2D_SURFACE_WITH_PHYS | C2D_SURFACE_WITH_PHYS_DUMMY), &(*surfaceDef)); return ((void *)surfaceDef); } }
/** The Constructor * * @param openmaxStandComp is the handle to be constructed * @param cComponentName is the name of the constructed component * */ OMX_ERRORTYPE omx_xvideo_sink_component_Constructor(OMX_COMPONENTTYPE *openmaxStandComp,OMX_STRING cComponentName) { OMX_ERRORTYPE err = OMX_ErrorNone; omx_xvideo_sink_component_PortType *pPort; omx_xvideo_sink_component_PrivateType* omx_xvideo_sink_component_Private; if (!openmaxStandComp->pComponentPrivate) { DEBUG(DEB_LEV_FUNCTION_NAME, "In %s, allocating component\n", __func__); openmaxStandComp->pComponentPrivate = calloc(1, sizeof(omx_xvideo_sink_component_PrivateType)); if(openmaxStandComp->pComponentPrivate == NULL) { return OMX_ErrorInsufficientResources; } } else { DEBUG(DEB_LEV_FUNCTION_NAME, "In %s, Error Component %x Already Allocated\n", __func__, (int)openmaxStandComp->pComponentPrivate); } omx_xvideo_sink_component_Private = openmaxStandComp->pComponentPrivate; omx_xvideo_sink_component_Private->ports = NULL; /** we could create our own port structures here * fixme maybe the base class could use a "port factory" function pointer? */ err = omx_base_sink_Constructor(openmaxStandComp, cComponentName); omx_xvideo_sink_component_Private->sPortTypesParam[OMX_PortDomainVideo].nStartPortNumber = 0; omx_xvideo_sink_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts = 1; /** Allocate Ports and call port constructor. */ if ((omx_xvideo_sink_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts ) && !omx_xvideo_sink_component_Private->ports) { omx_xvideo_sink_component_Private->ports = calloc((omx_xvideo_sink_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts ), sizeof(omx_base_PortType *)); if (!omx_xvideo_sink_component_Private->ports) { return OMX_ErrorInsufficientResources; } omx_xvideo_sink_component_Private->ports[0] = calloc(1, sizeof(omx_xvideo_sink_component_PortType)); if (!omx_xvideo_sink_component_Private->ports[0]) { return OMX_ErrorInsufficientResources; } base_video_port_Constructor(openmaxStandComp, &omx_xvideo_sink_component_Private->ports[0], 0, OMX_TRUE); } pPort = (omx_xvideo_sink_component_PortType *) omx_xvideo_sink_component_Private->ports[OMX_BASE_SINK_INPUTPORT_INDEX]; /** Domain specific section for the allocated port. */ pPort->sPortParam.format.video.nFrameWidth = 352; pPort->sPortParam.format.video.nFrameHeight = 288; pPort->sPortParam.format.video.nBitrate = 0; pPort->sPortParam.format.video.xFramerate = 25; pPort->sPortParam.format.video.eColorFormat = OMX_COLOR_FormatYUV420Planar; // Figure out stride, slice height, min buffer size pPort->sPortParam.format.video.nStride = calcStride(pPort->sPortParam.format.video.nFrameWidth, pPort->sPortParam.format.video.eColorFormat); pPort->sPortParam.format.video.nSliceHeight = pPort->sPortParam.format.video.nFrameHeight; // No support for slices yet pPort->sPortParam.nBufferSize = (OMX_U32) abs(pPort->sPortParam.format.video.nStride) * pPort->sPortParam.format.video.nSliceHeight; pPort->sVideoParam.eColorFormat = OMX_COLOR_FormatYUV420Planar; pPort->sVideoParam.xFramerate = 25; DEBUG(DEB_LEV_PARAMS, "In %s, bSize=%d stride=%d\n", __func__,(int)pPort->sPortParam.nBufferSize,(int)pPort->sPortParam.format.video.nStride); /** Set configs */ setHeader(&pPort->omxConfigCrop, sizeof(OMX_CONFIG_RECTTYPE)); pPort->omxConfigCrop.nPortIndex = OMX_BASE_SINK_INPUTPORT_INDEX; pPort->omxConfigCrop.nLeft = pPort->omxConfigCrop.nTop = 0; pPort->omxConfigCrop.nWidth = pPort->omxConfigCrop.nHeight = 0; setHeader(&pPort->omxConfigRotate, sizeof(OMX_CONFIG_ROTATIONTYPE)); pPort->omxConfigRotate.nPortIndex = OMX_BASE_SINK_INPUTPORT_INDEX; pPort->omxConfigRotate.nRotation = 0; //Default: No rotation (0 degrees) setHeader(&pPort->omxConfigMirror, sizeof(OMX_CONFIG_MIRRORTYPE)); pPort->omxConfigMirror.nPortIndex = OMX_BASE_SINK_INPUTPORT_INDEX; pPort->omxConfigMirror.eMirror = OMX_MirrorNone; //Default: No mirroring setHeader(&pPort->omxConfigScale, sizeof(OMX_CONFIG_SCALEFACTORTYPE)); pPort->omxConfigScale.nPortIndex = OMX_BASE_SINK_INPUTPORT_INDEX; pPort->omxConfigScale.xWidth = pPort->omxConfigScale.xHeight = 0x10000; //Default: No scaling (scale factor = 1) setHeader(&pPort->omxConfigOutputPosition, sizeof(OMX_CONFIG_POINTTYPE)); pPort->omxConfigOutputPosition.nPortIndex = OMX_BASE_SINK_INPUTPORT_INDEX; pPort->omxConfigOutputPosition.nX = pPort->omxConfigOutputPosition.nY = 0; //Default: No shift in output position (0,0) /** set the function pointers */ omx_xvideo_sink_component_Private->destructor = omx_xvideo_sink_component_Destructor; omx_xvideo_sink_component_Private->BufferMgmtCallback = omx_xvideo_sink_component_BufferMgmtCallback; openmaxStandComp->SetParameter = omx_xvideo_sink_component_SetParameter; openmaxStandComp->GetParameter = omx_xvideo_sink_component_GetParameter; omx_xvideo_sink_component_Private->messageHandler = omx_xvideo_sink_component_MessageHandler; omx_xvideo_sink_component_Private->bIsXVideoInit = OMX_FALSE; if(!omx_xvideo_sink_component_Private->xvideoSyncSem) { omx_xvideo_sink_component_Private->xvideoSyncSem = calloc(1,sizeof(tsem_t)); if(omx_xvideo_sink_component_Private->xvideoSyncSem == NULL) { return OMX_ErrorInsufficientResources; } tsem_init(omx_xvideo_sink_component_Private->xvideoSyncSem, 0); } noxvideo_sinkInstance++; if(noxvideo_sinkInstance > MAX_COMPONENT_XVIDEOSINK) { DEBUG(DEB_LEV_ERR, "Reached Max Instances %d\n",(int)noxvideo_sinkInstance); return OMX_ErrorInsufficientResources; } return err; }
OMX_ERRORTYPE omx_xvideo_sink_component_SetParameter( OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nParamIndex, OMX_PTR ComponentParameterStructure) { OMX_ERRORTYPE err = OMX_ErrorNone; OMX_PARAM_PORTDEFINITIONTYPE *pPortDef; OMX_VIDEO_PARAM_PORTFORMATTYPE *pVideoPortFormat; OMX_U32 portIndex; /* Check which structure we are being fed and make control its header */ OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE *)hComponent; omx_xvideo_sink_component_PrivateType* omx_xvideo_sink_component_Private = openmaxStandComp->pComponentPrivate; omx_xvideo_sink_component_PortType *pPort; if (ComponentParameterStructure == NULL) { return OMX_ErrorBadParameter; } DEBUG(DEB_LEV_SIMPLE_SEQ, " Setting parameter %i\n", nParamIndex); switch(nParamIndex) { case OMX_IndexParamPortDefinition: pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure; portIndex = pPortDef->nPortIndex; err = omx_base_component_ParameterSanityCheck(hComponent, portIndex, pPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); if(err!=OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,err); break; } if(portIndex > (omx_xvideo_sink_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts)) { return OMX_ErrorBadPortIndex; } if(portIndex == 0) { pPort = (omx_xvideo_sink_component_PortType *) omx_xvideo_sink_component_Private->ports[portIndex]; pPort->sPortParam.nBufferCountActual = pPortDef->nBufferCountActual; // Copy stuff from OMX_VIDEO_PORTDEFINITIONTYPE structure if(pPortDef->format.video.cMIMEType != NULL) { strcpy(pPort->sPortParam.format.video.cMIMEType , pPortDef->format.video.cMIMEType); } pPort->sPortParam.format.video.nFrameWidth = pPortDef->format.video.nFrameWidth; pPort->sPortParam.format.video.nFrameHeight = pPortDef->format.video.nFrameHeight; pPort->sPortParam.format.video.nBitrate = pPortDef->format.video.nBitrate; pPort->sPortParam.format.video.xFramerate = pPortDef->format.video.xFramerate; pPort->sPortParam.format.video.bFlagErrorConcealment = pPortDef->format.video.bFlagErrorConcealment; pPort->sVideoParam.eColorFormat = pPortDef->format.video.eColorFormat;; pPort->sPortParam.format.video.eColorFormat = pPortDef->format.video.eColorFormat; // Figure out stride, slice height, min buffer size pPort->sPortParam.format.video.nStride = calcStride(pPort->sPortParam.format.video.nFrameWidth, pPort->sVideoParam.eColorFormat); pPort->sPortParam.format.video.nSliceHeight = pPort->sPortParam.format.video.nFrameHeight; // No support for slices yet // Read-only field by spec pPort->sPortParam.nBufferSize = (OMX_U32) abs(pPort->sPortParam.format.video.nStride) * pPort->sPortParam.format.video.nSliceHeight; pPort->omxConfigCrop.nWidth = pPort->sPortParam.format.video.nFrameWidth; pPort->omxConfigCrop.nHeight = pPort->sPortParam.format.video.nFrameHeight; } break; case OMX_IndexParamVideoPortFormat: // FIXME: How do we handle the nIndex member? pVideoPortFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE*)ComponentParameterStructure; portIndex = pVideoPortFormat->nPortIndex; err = omx_base_component_ParameterSanityCheck(hComponent, portIndex, pVideoPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); if(err!=OMX_ErrorNone) { DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,err); break; } pPort = (omx_xvideo_sink_component_PortType *) omx_xvideo_sink_component_Private->ports[portIndex]; if(portIndex != 0) { return OMX_ErrorBadPortIndex; } if (pVideoPortFormat->eCompressionFormat != OMX_VIDEO_CodingUnused) { // No compression allowed return OMX_ErrorUnsupportedSetting; } if(pVideoPortFormat->xFramerate > 0) { nFrameProcessTime = 1000000 / pVideoPortFormat->xFramerate; } pPort->sVideoParam.xFramerate = pVideoPortFormat->xFramerate; pPort->sVideoParam.eCompressionFormat = pVideoPortFormat->eCompressionFormat; pPort->sVideoParam.eColorFormat = pVideoPortFormat->eColorFormat; pPort->sPortParam.format.video.eColorFormat = pVideoPortFormat->eColorFormat; // Figure out stride, slice height, min buffer size pPort->sPortParam.format.video.nStride = calcStride(pPort->sPortParam.format.video.nFrameWidth, pPort->sVideoParam.eColorFormat); pPort->sPortParam.format.video.nSliceHeight = pPort->sPortParam.format.video.nFrameHeight; // No support for slices yet pPort->sPortParam.nBufferSize = (OMX_U32) abs(pPort->sPortParam.format.video.nStride) * pPort->sPortParam.format.video.nSliceHeight; break; default: /*Call the base component function*/ return omx_base_component_SetParameter(hComponent, nParamIndex, ComponentParameterStructure); } return err; }