119 if (glcontext == 0) {
124 static PFNGLTEXDIRECTVIVPROC glTexDirectVIV_LOCAL = 0;
125 static PFNGLTEXDIRECTVIVMAPPROC glTexDirectVIVMap_LOCAL = 0;
126 static PFNGLTEXDIRECTINVALIDATEVIVPROC glTexDirectInvalidateVIV_LOCAL = 0;
128 if (glTexDirectVIV_LOCAL == 0 || glTexDirectVIVMap_LOCAL == 0 || glTexDirectInvalidateVIV_LOCAL == 0) {
129 glTexDirectVIV_LOCAL =
reinterpret_cast<PFNGLTEXDIRECTVIVPROC
>(glcontext->getProcAddress(
"glTexDirectVIV"));
130 glTexDirectVIVMap_LOCAL =
reinterpret_cast<PFNGLTEXDIRECTVIVMAPPROC
>(glcontext->getProcAddress(
"glTexDirectVIVMap"));
131 glTexDirectInvalidateVIV_LOCAL =
reinterpret_cast<PFNGLTEXDIRECTINVALIDATEVIVPROC
>(glcontext->getProcAddress(
"glTexDirectInvalidateVIV"));
133 if (glTexDirectVIV_LOCAL == 0 || glTexDirectVIVMap_LOCAL == 0 || glTexDirectInvalidateVIV_LOCAL == 0) {
134 qWarning() <<
Q_FUNC_INFO <<
"couldn't find \"glTexDirectVIVMap\" and/or \"glTexDirectInvalidateVIV\" => do nothing and return";
138 if (mWidth != vF.width() || mHeight != vF.height() || mFormat != vF.pixelFormat()) {
140 mHeight = vF.height();
141 mFormat = vF.pixelFormat();
142 mMapError = GL_NO_ERROR;
149 if (!mBitsToTextureMap.
contains(vF.bits())) {
152 glGenTextures(1, &tmpTexId);
153 mBitsToTextureMap.
insert(vF.bits(), tmpTexId);
168 int fullHeight = (vF.planeCount() > 1) ? ((vF.bits(1) - vF.bits(0)) / vF.bytesPerLine()) : vF.height();
177 float uScale = float(vF.width()) / float(fullWidth);
178 float vScale = float(vF.height()) / float(fullHeight);
181 const uchar *constBits = vF.bits();
182 void *
bits = (
void*)constBits;
184#ifdef QT_VIVANTE_VIDEO_DEBUG
186 <<
"new texture, texId: " << tmpTexId
187 <<
"; constBits: " << constBits
188 <<
"; actual/full width: " << vF.width() <<
"/" << fullWidth
189 <<
"; actual/full height: " << vF.height() <<
"/" << fullHeight
190 <<
"; UV scale: U " << uScale <<
" V " << vScale;
194#if GST_CHECK_VERSION(1,14,0)
196 auto mem = gst_buffer_peek_memory(
buffer->buffer(), 0);
197 auto phys_addr = gst_is_phys_memory(mem) ? gst_phys_memory_get_phys_addr(mem) : 0;
199 physical = phys_addr;
201 glBindTexture(GL_TEXTURE_2D, tmpTexId);
202 glTexDirectVIVMap_LOCAL(GL_TEXTURE_2D,
203 fullWidth, fullHeight,
207 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
208 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
211 glTexDirectInvalidateVIV_LOCAL(GL_TEXTURE_2D);
213 mMapError = glGetError();
214 if (mMapError == GL_NO_ERROR)
222 glBindTexture(GL_TEXTURE_2D, mBitsToTextureMap.
value(vF.bits()));
223 glTexDirectInvalidateVIV_LOCAL(GL_TEXTURE_2D);
224 return mBitsToTextureMap.
value(vF.bits());
229 if (!mTexDirectTexture) {
230 glGenTextures(1, &mTexDirectTexture);
231 glBindTexture(GL_TEXTURE_2D, mTexDirectTexture);
232 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
233 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
236 glTexDirectVIV_LOCAL(GL_TEXTURE_2D, mCurrentFrame.
width(), mCurrentFrame.
height(),
238 (GLvoid **) &mTexDirectPlanes);
240 glBindTexture(GL_TEXTURE_2D, mTexDirectTexture);
245 memcpy(mTexDirectPlanes[0], mCurrentFrame.
bits(0), mCurrentFrame.
height() * mCurrentFrame.
bytesPerLine(0));
246 memcpy(mTexDirectPlanes[1], mCurrentFrame.
bits(1), mCurrentFrame.
height() / 2 * mCurrentFrame.
bytesPerLine(1));
247 memcpy(mTexDirectPlanes[2], mCurrentFrame.
bits(2), mCurrentFrame.
height() / 2 * mCurrentFrame.
bytesPerLine(2));
251 memcpy(mTexDirectPlanes[0], mCurrentFrame.
bits(0), mCurrentFrame.
height() * mCurrentFrame.
bytesPerLine(0));
252 memcpy(mTexDirectPlanes[1], mCurrentFrame.
bits(1), mCurrentFrame.
height() / 2 * mCurrentFrame.
bytesPerLine(1));
258 glTexDirectInvalidateVIV_LOCAL(GL_TEXTURE_2D);
259 return mTexDirectTexture;
262#ifdef QT_VIVANTE_VIDEO_DEBUG
263 qWarning() <<
" couldn't map the QVideoFrame vF: " << vF;
static QOpenGLContext * currentContext()
Returns the last context which called makeCurrent in the current thread, or \nullptr,...