118 if (glcontext == 0) {
123 static PFNGLTEXDIRECTVIVPROC glTexDirectVIV_LOCAL = 0;
124 static PFNGLTEXDIRECTVIVMAPPROC glTexDirectVIVMap_LOCAL = 0;
125 static PFNGLTEXDIRECTINVALIDATEVIVPROC glTexDirectInvalidateVIV_LOCAL = 0;
127 if (glTexDirectVIV_LOCAL == 0 || glTexDirectVIVMap_LOCAL == 0 || glTexDirectInvalidateVIV_LOCAL == 0) {
128 glTexDirectVIV_LOCAL =
reinterpret_cast<PFNGLTEXDIRECTVIVPROC
>(glcontext->getProcAddress(
"glTexDirectVIV"));
129 glTexDirectVIVMap_LOCAL =
reinterpret_cast<PFNGLTEXDIRECTVIVMAPPROC
>(glcontext->getProcAddress(
"glTexDirectVIVMap"));
130 glTexDirectInvalidateVIV_LOCAL =
reinterpret_cast<PFNGLTEXDIRECTINVALIDATEVIVPROC
>(glcontext->getProcAddress(
"glTexDirectInvalidateVIV"));
132 if (glTexDirectVIV_LOCAL == 0 || glTexDirectVIVMap_LOCAL == 0 || glTexDirectInvalidateVIV_LOCAL == 0) {
133 qWarning() <<
Q_FUNC_INFO <<
"couldn't find \"glTexDirectVIVMap\" and/or \"glTexDirectInvalidateVIV\" => do nothing and return";
137 if (mWidth != vF.width() || mHeight != vF.height() || mFormat != vF.pixelFormat()) {
139 mHeight = vF.height();
140 mFormat = vF.pixelFormat();
141 mMapError = GL_NO_ERROR;
148 if (!mBitsToTextureMap.
contains(vF.bits())) {
151 glGenTextures(1, &tmpTexId);
152 mBitsToTextureMap.
insert(vF.bits(), tmpTexId);
167 int fullHeight = (vF.planeCount() > 1) ? ((vF.bits(1) - vF.bits(0)) / vF.bytesPerLine()) : vF.height();
176 float uScale = float(vF.width()) / float(fullWidth);
177 float vScale = float(vF.height()) / float(fullHeight);
180 const uchar *constBits = vF.bits();
181 void *
bits = (
void*)constBits;
183#ifdef QT_VIVANTE_VIDEO_DEBUG
185 <<
"new texture, texId: " << tmpTexId
186 <<
"; constBits: " << constBits
187 <<
"; actual/full width: " << vF.width() <<
"/" << fullWidth
188 <<
"; actual/full height: " << vF.height() <<
"/" << fullHeight
189 <<
"; UV scale: U " << uScale <<
" V " << vScale;
193#if GST_CHECK_VERSION(1,14,0)
195 auto mem = gst_buffer_peek_memory(
buffer->buffer(), 0);
196 auto phys_addr = gst_is_phys_memory(mem) ? gst_phys_memory_get_phys_addr(mem) : 0;
198 physical = phys_addr;
200 glBindTexture(GL_TEXTURE_2D, tmpTexId);
201 glTexDirectVIVMap_LOCAL(GL_TEXTURE_2D,
202 fullWidth, fullHeight,
206 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
207 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
210 glTexDirectInvalidateVIV_LOCAL(GL_TEXTURE_2D);
212 mMapError = glGetError();
213 if (mMapError == GL_NO_ERROR)
221 glBindTexture(GL_TEXTURE_2D, mBitsToTextureMap.
value(vF.bits()));
222 glTexDirectInvalidateVIV_LOCAL(GL_TEXTURE_2D);
223 return mBitsToTextureMap.
value(vF.bits());
228 if (!mTexDirectTexture) {
229 glGenTextures(1, &mTexDirectTexture);
230 glBindTexture(GL_TEXTURE_2D, mTexDirectTexture);
231 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
232 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
235 glTexDirectVIV_LOCAL(GL_TEXTURE_2D, mCurrentFrame.
width(), mCurrentFrame.
height(),
237 (GLvoid **) &mTexDirectPlanes);
239 glBindTexture(GL_TEXTURE_2D, mTexDirectTexture);
244 memcpy(mTexDirectPlanes[0], mCurrentFrame.
bits(0), mCurrentFrame.
height() * mCurrentFrame.
bytesPerLine(0));
245 memcpy(mTexDirectPlanes[1], mCurrentFrame.
bits(1), mCurrentFrame.
height() / 2 * mCurrentFrame.
bytesPerLine(1));
246 memcpy(mTexDirectPlanes[2], mCurrentFrame.
bits(2), mCurrentFrame.
height() / 2 * mCurrentFrame.
bytesPerLine(2));
250 memcpy(mTexDirectPlanes[0], mCurrentFrame.
bits(0), mCurrentFrame.
height() * mCurrentFrame.
bytesPerLine(0));
251 memcpy(mTexDirectPlanes[1], mCurrentFrame.
bits(1), mCurrentFrame.
height() / 2 * mCurrentFrame.
bytesPerLine(1));
257 glTexDirectInvalidateVIV_LOCAL(GL_TEXTURE_2D);
258 return mTexDirectTexture;
261#ifdef QT_VIVANTE_VIDEO_DEBUG
262 qWarning() <<
" couldn't map the QVideoFrame vF: " << vF;
static QOpenGLContext * currentContext()
Returns the last context which called makeCurrent in the current thread, or \nullptr,...