MCPcopy Create free account
hub / github.com/carlonluca/pot / doLoadTextureFromImage

Method doLoadTextureFromImage

piomxtextures_src/openmaxiltextureloader.cpp:119–375  ·  view source on GitHub ↗

------------------------------------------------------------------------------ | OpenMAXILTextureLoader::loadTexture +-----------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

117| OpenMAXILTextureLoader::loadTexture
118+-----------------------------------------------------------------------------*/
119inline
120void OpenMAXILTextureLoader::doLoadTextureFromImage(
121 QString fileAbsPath,
122 EGLDisplay eglDisplay,
123 EGLContext eglContext,
124 GLuint& texture
125 )
126{
127 QFile file(fileAbsPath);
128 if (!file.exists())
129 throw runtime_error("File does not exist.");
130 if (!file.open(QIODevice::ReadOnly))
131 throw runtime_error("Failed to open file.");
132
133 core = OMX_Core::instance();
134 Q_UNUSED(core);
135
136 // Get components.
137 compImageDecoder = OMXComponentFactory<OMXComponent>::getInstance("OMX.broadcom.image_decode");
138 compEGLRender = OMXComponentFactory<OMXComponent>::getInstance("OMX.broadcom.egl_render");
139
140 // Check the number of ports is correct.
141 OMX_PORT_PARAM_TYPE port;
142 port.nSize = sizeof(OMX_PORT_PARAM_TYPE);
143 port.nVersion.nVersion = OMX_VERSION;
144 compImageDecoder->GetParameter(OMX_IndexParamImageInit, &port);
145 if (port.nPorts != 2)
146 throw runtime_error("Unexpected number of ports returned from decoder.");
147 m_iInPortDecode = port.nStartPortNumber;
148 m_iOutPortDecode = port.nStartPortNumber + 1;
149
150 compEGLRender->GetParameter(OMX_IndexParamVideoInit, &port);
151 if (port.nPorts != 2)
152 throw runtime_error("Unexpected number of ports returned from renderer.");
153 m_iInPortRender = port.nStartPortNumber;
154 m_iOutPortRender = port.nStartPortNumber + 1;
155
156 // Disable all ports.
157 LOG_VERBOSE(LOG_TAG, "Disabling all the ports...");
158 compImageDecoder->sendCommand(OMX_CommandPortDisable, m_iInPortDecode, NULL);
159 compImageDecoder->waitForEvent(OMX_EventCmdComplete, OMX_CommandPortDisable, m_iInPortDecode, TIMEOUT_MS);
160 compImageDecoder->sendCommand(OMX_CommandPortDisable, m_iOutPortDecode, NULL);
161 compImageDecoder->waitForEvent(OMX_EventCmdComplete, OMX_CommandPortDisable, m_iOutPortDecode, TIMEOUT_MS);
162 compEGLRender->sendCommand(OMX_CommandPortDisable, m_iInPortRender, NULL);
163 compEGLRender->waitForEvent(OMX_EventCmdComplete, OMX_CommandPortDisable, m_iInPortRender, TIMEOUT_MS);
164 compEGLRender->sendCommand(OMX_CommandPortDisable, m_iOutPortRender, NULL);
165 compEGLRender->waitForEvent(OMX_EventCmdComplete, OMX_CommandPortDisable, m_iOutPortRender, TIMEOUT_MS);
166 LOG_VERBOSE(LOG_TAG, "All the ports were disabled.");
167
168 // move decoder component into idle state
169 LOG_VERBOSE(LOG_TAG, "Changing decoder state to IDLE...");
170 compImageDecoder->sendCommand(OMX_CommandStateSet, OMX_StateIdle, NULL);
171 compImageDecoder->waitForEvent(OMX_EventCmdComplete, OMX_CommandStateSet, OMX_StateIdle, TIMEOUT_MS);
172 LOG_VERBOSE(LOG_TAG, "Decoder state changed to IDLE.");
173
174 // Set input format.
175 OMX_IMAGE_PARAM_PORTFORMATTYPE portFormat;
176 OMX_INIT_STRUCTURE(portFormat);

Callers

nothing calls this directly

Calls 15

sendCommandMethod · 0.80
waitForEventMethod · 0.80
UseBufferMethod · 0.80
WaitForEventOrEmptyMethod · 0.80
ToEventMethod · 0.80
ToEmptyMethod · 0.80
WaitForFillMethod · 0.80
GetPendingEventCountMethod · 0.80
GetPendingEmptyCountMethod · 0.80
GetPendingFillCountMethod · 0.80
FreeBufferMethod · 0.80
RemoveTunnelMethod · 0.80

Tested by

no test coverage detected