MythTV  master
mythvideotextureopengl.cpp
Go to the documentation of this file.
1 // MythTV
2 #include "mythlogging.h"
4 
5 #define LOC QString("MythVidTex: ")
6 
8  : MythGLTexture(Texture)
9 {
10 }
11 
13  : MythGLTexture(Texture)
14 {
15 }
16 
18 {
19  if (!Context || !Texture)
20  return;
21 
22  OpenGLLocker locker(Context);
23  delete Texture->m_copyContext;
24  delete Texture->m_texture;
25  delete [] Texture->m_data;
26  delete Texture->m_vbo;
27 
28  delete Texture;
29 }
30 
31 void MythVideoTextureOpenGL::DeleteTextures(MythRenderOpenGL *Context, std::vector<MythVideoTextureOpenGL *> &Textures)
32 {
33  if (!Context || Textures.empty())
34  return;
35  for (auto & Texture : Textures)
36  DeleteTexture(Context, Texture);
37  Textures.clear();
38 }
39 
41  const std::vector<MythVideoTextureOpenGL *> &Textures,
42  QOpenGLTexture::Filter Filter,
43  QOpenGLTexture::WrapMode Wrap)
44 {
45  for (uint i = 0; (i < Textures.size()) && Context; i++)
46  {
47  Textures[i]->m_filter = Filter;
48  Context->SetTextureFilters(reinterpret_cast<MythGLTexture*>(Textures[i]), Filter, Wrap);
49  }
50 }
51 
57 std::vector<MythVideoTextureOpenGL*> MythVideoTextureOpenGL::CreateTextures(MythRenderOpenGL *Context,
58  VideoFrameType Type,
60  std::vector<QSize> Sizes,
61  GLenum Target)
62 {
63  std::vector<MythVideoTextureOpenGL*> result;
64  if (!Context || Sizes.empty())
65  return result;
66  if (Sizes[0].isEmpty())
67  return result;
68 
69  OpenGLLocker locker(Context);
70 
71  // Hardware frames
73  return CreateHardwareTextures(Context, Type, Format, Sizes, Target);
74 
75  return CreateSoftwareTextures(Context, Type, Format, Sizes, Target);
76 }
77 
85 std::vector<MythVideoTextureOpenGL*> MythVideoTextureOpenGL::CreateHardwareTextures(MythRenderOpenGL *Context,
86  VideoFrameType Type,
88  std::vector<QSize> Sizes,
89  GLenum Target)
90 {
91  std::vector<MythVideoTextureOpenGL*> result;
92 
94  if (count < 1)
95  {
96  LOG(VB_GENERAL, LOG_ERR, LOC + "Invalid hardware frame format");
97  return result;
98  }
99 
100  if (count != Sizes.size())
101  {
102  LOG(VB_GENERAL, LOG_ERR, LOC + "Inconsistent plane count");
103  return result;
104  }
105 
106  for (uint plane = 0; plane < count; ++plane)
107  {
108  GLuint textureid = 0;
109  Context->glGenTextures(1, &textureid);
110  if (!textureid)
111  continue;
112 
113  auto* texture = new MythVideoTextureOpenGL(textureid);
114  texture->m_frameType = Type;
115  texture->m_frameFormat = Format;
116  texture->m_plane = plane;
117  texture->m_planeCount = count;
118  texture->m_target = Target;
119  texture->m_size = Sizes[plane];
120  texture->m_totalSize = Context->GetTextureSize(Sizes[plane], texture->m_target != QOpenGLTexture::TargetRectangle);
121  texture->m_vbo = Context->CreateVBO(static_cast<int>(MythRenderOpenGL::kVertexSize));
122  result.push_back(texture);
123  }
124 
125  SetTextureFilters(Context, result, QOpenGLTexture::Linear);
126  return result;
127 }
128 
133 std::vector<MythVideoTextureOpenGL*> MythVideoTextureOpenGL::CreateSoftwareTextures(MythRenderOpenGL *Context,
134  VideoFrameType Type,
136  std::vector<QSize> Sizes,
137  GLenum Target)
138 {
139  std::vector<MythVideoTextureOpenGL*> result;
140 
142  if (count < 1)
143  {
144  LOG(VB_GENERAL, LOG_ERR, LOC + "Invalid software frame format");
145  return result;
146  }
147 
148  // OpenGL ES 2.0 has very limited texture format support
149  bool legacy = (Context->GetExtraFeatures() & kGLLegacyTextures) != 0;
150  // GLES3 supports GL_RED etc and 16bit formats but there are no unsigned,
151  // normalised 16bit integer formats. So we must use unsigned integer formats
152  // for 10bit video textures which force:-
153  // - only nearest texture filtering - so we must use the resize stage
154  // - no GLSL mix method for uint/uvec4
155  // - must use unsigned samplers in the shaders - and convert uint to normalised float as necessary
156  // - need to use GLSL ES 3.00 - which means new/updated shaders
157  bool gles3 = Context->isOpenGLES() && Context->format().majorVersion() > 2;
158  QOpenGLTexture::PixelFormat r8pixelfmtnorm = QOpenGLTexture::Red;
159  QOpenGLTexture::PixelFormat r8pixelfmtuint = QOpenGLTexture::Red;
160  QOpenGLTexture::PixelFormat rg8pixelfmtnorm = QOpenGLTexture::RG;
161  QOpenGLTexture::PixelFormat rg8pixelfmtuint = QOpenGLTexture::RG;
162  QOpenGLTexture::TextureFormat r8internalfmt = QOpenGLTexture::R8_UNorm;
163  QOpenGLTexture::TextureFormat r16internalfmt = QOpenGLTexture::R16_UNorm;
164  QOpenGLTexture::TextureFormat rg8internalfmt = QOpenGLTexture::RG8_UNorm;
165  QOpenGLTexture::TextureFormat rg16internalfmt = QOpenGLTexture::RG16_UNorm;
166 
167  if (gles3)
168  {
169  r8pixelfmtuint = QOpenGLTexture::Red_Integer;
170  rg8pixelfmtuint = QOpenGLTexture::RG_Integer;
171  r16internalfmt = QOpenGLTexture::R16U;
172  rg16internalfmt = QOpenGLTexture::RG16U;
173  }
174  else if (legacy)
175  {
176  r8pixelfmtnorm = QOpenGLTexture::Luminance;
177  r8internalfmt = QOpenGLTexture::LuminanceFormat;
178  }
179 
180  for (uint plane = 0; plane < count; ++plane)
181  {
182  QSize size = Sizes[0];
183  MythVideoTextureOpenGL* texture = nullptr;
184  switch (Format)
185  {
186  case FMT_YV12:
187  if (plane > 0)
188  size = QSize(size.width() >> 1, size.height() >> 1);
189  texture = CreateTexture(Context, size, Target,
190  QOpenGLTexture::UInt8, r8pixelfmtnorm, r8internalfmt);
191  break;
192  case FMT_YUV420P9:
193  case FMT_YUV420P10:
194  case FMT_YUV420P12:
195  case FMT_YUV420P14:
196  case FMT_YUV420P16:
197  if (plane > 0)
198  size = QSize(size.width() >> 1, size.height() >> 1);
199  texture = CreateTexture(Context, size, Target,
200  QOpenGLTexture::UInt16, r8pixelfmtuint, r16internalfmt);
201  break;
202  case FMT_YUY2:
203  size.setWidth(size.width() >> 1);
204  texture = CreateTexture(Context, size, Target);
205  break;
206  case FMT_NV12:
207  if (plane == 0)
208  {
209  texture = CreateTexture(Context, size, Target,
210  QOpenGLTexture::UInt8, r8pixelfmtnorm, r8internalfmt);
211  }
212  else
213  {
214  size = QSize(size.width() >> 1, size.height() >> 1);
215  texture = CreateTexture(Context, size, Target,
216  QOpenGLTexture::UInt8, rg8pixelfmtnorm, rg8internalfmt);
217  }
218  break;
219  case FMT_P010:
220  case FMT_P016:
221  if (plane == 0)
222  {
223  texture = CreateTexture(Context, size, Target,
224  QOpenGLTexture::UInt16, r8pixelfmtuint, r16internalfmt);
225  }
226  else
227  {
228  size = QSize(size.width() >> 1, size.height() >> 1);
229  texture = CreateTexture(Context, size, Target,
230  QOpenGLTexture::UInt16, rg8pixelfmtuint, rg16internalfmt);
231  }
232  break;
233  case FMT_YUV422P:
234  if (plane > 0)
235  size = QSize(size.width() >> 1, size.height());
236  texture = CreateTexture(Context, size, Target,
237  QOpenGLTexture::UInt8, r8pixelfmtnorm, r8internalfmt);
238  break;
239  case FMT_YUV422P9:
240  case FMT_YUV422P10:
241  case FMT_YUV422P12:
242  case FMT_YUV422P14:
243  case FMT_YUV422P16:
244  if (plane > 0)
245  size = QSize(size.width() >> 1, size.height());
246  texture = CreateTexture(Context, size, Target,
247  QOpenGLTexture::UInt16, r8pixelfmtuint, r16internalfmt);
248  break;
249  case FMT_YUV444P:
250  texture = CreateTexture(Context, size, Target,
251  QOpenGLTexture::UInt8, r8pixelfmtnorm, r8internalfmt);
252  break;
253  case FMT_YUV444P9:
254  case FMT_YUV444P10:
255  case FMT_YUV444P12:
256  case FMT_YUV444P14:
257  case FMT_YUV444P16:
258  texture = CreateTexture(Context, size, Target,
259  QOpenGLTexture::UInt16, r8pixelfmtuint, r16internalfmt);
260  break;
261  default: break;
262  }
263  if (texture)
264  {
265  texture->m_plane = plane;
266  texture->m_planeCount = count;
267  texture->m_frameType = Type;
268  texture->m_frameFormat = Format;
269  result.push_back(texture);
270  }
271  }
272 
273  if (result.size() != count)
274  LOG(VB_GENERAL, LOG_ERR, LOC + QString("Failed to create all textures: %1 < %2")
275  .arg(result.size()).arg(count));
276  return result;
277 }
278 
282  const MythVideoFrame *Frame,
283  const std::vector<MythVideoTextureOpenGL*> &Textures)
284 {
285  if (!Context || !Frame || Textures.empty())
286  {
287  LOG(VB_GENERAL, LOG_ERR, LOC + QString("Texture error: Context %1 Frame %2 Textures %3")
288  .arg(Context != nullptr).arg(Frame != nullptr).arg(Textures.size()));
289  return;
290  }
291 
292  if (Frame->m_type != Textures[0]->m_frameType)
293  {
294  LOG(VB_GENERAL, LOG_ERR, LOC + "Inconsistent video and texture frame types");
295  return;
296  }
297 
298  uint count = MythVideoFrame::GetNumPlanes(Textures[0]->m_frameFormat);
299  if (!count || (count != Textures.size()))
300  {
301  LOG(VB_GENERAL, LOG_ERR, LOC + "Invalid software frame type");
302  return;
303  }
304 
305  OpenGLLocker locker(Context);
306 
307  for (uint i = 0; i < count; ++i)
308  {
309  MythVideoTextureOpenGL *texture = Textures[i];
310  if (!texture)
311  continue;
312  if (!texture->m_texture)
313  continue;
314 
315  if (i != texture->m_plane)
316  {
317  LOG(VB_GENERAL, LOG_ERR, LOC + "Inconsistent plane numbering");
318  continue;
319  }
320 
321  switch (texture->m_frameType)
322  {
323  case FMT_YV12:
324  {
325  switch (texture->m_frameFormat)
326  {
327  case FMT_YV12: YV12ToYV12(Context, Frame, texture, i); break;
328  case FMT_YUY2: YV12ToYUYV(Frame, texture); break;
329  default: break;
330  }
331  break;
332  }
333  case FMT_YUV420P9:
334  case FMT_YUV420P10:
335  case FMT_YUV420P12:
336  case FMT_YUV420P14:
337  case FMT_YUV420P16:
338  {
339  switch (texture->m_frameFormat)
340  {
341  case FMT_YUV420P9:
342  case FMT_YUV420P10:
343  case FMT_YUV420P12:
344  case FMT_YUV420P14:
345  case FMT_YUV420P16: YV12ToYV12(Context, Frame, texture, i); break;
346  default: break;
347  }
348  break;
349  }
350  case FMT_NV12:
351  {
352  switch (texture->m_frameFormat)
353  {
354  case FMT_NV12: NV12ToNV12(Context, Frame, texture, i); break;
355  default: break;
356  }
357  break;
358  }
359  case FMT_P010:
360  case FMT_P016:
361  {
362  switch (texture->m_frameFormat)
363  {
364  case FMT_P010:
365  case FMT_P016: NV12ToNV12(Context, Frame, texture, i); break;
366  default: break;
367  }
368  break;
369  }
370  case FMT_YUV422P:
371  {
372  switch (texture->m_frameFormat)
373  {
374  case FMT_YUV422P: YV12ToYV12(Context, Frame, texture, i); break;
375  default: break;
376  }
377  break;
378  }
379  case FMT_YUV422P9:
380  case FMT_YUV422P10:
381  case FMT_YUV422P12:
382  case FMT_YUV422P14:
383  case FMT_YUV422P16:
384  {
385  switch (texture->m_frameFormat)
386  {
387  case FMT_YUV422P9:
388  case FMT_YUV422P10:
389  case FMT_YUV422P12:
390  case FMT_YUV422P14:
391  case FMT_YUV422P16: YV12ToYV12(Context, Frame, texture, i); break;
392  default: break;
393  }
394  break;
395  }
396  case FMT_YUV444P:
397  {
398  switch (texture->m_frameFormat)
399  {
400  case FMT_YUV444P: YV12ToYV12(Context, Frame, texture, i); break;
401  default: break;
402  }
403  break;
404  }
405  case FMT_YUV444P9:
406  case FMT_YUV444P10:
407  case FMT_YUV444P12:
408  case FMT_YUV444P14:
409  case FMT_YUV444P16:
410  {
411  switch (texture->m_frameFormat)
412  {
413  case FMT_YUV444P9:
414  case FMT_YUV444P10:
415  case FMT_YUV444P12:
416  case FMT_YUV444P14:
417  case FMT_YUV444P16: YV12ToYV12(Context, Frame, texture, i); break;
418  default: break;
419  }
420  break;
421  }
422  default: break;
423  }
424  }
425 }
426 
433  QSize Size,
434  GLenum Target,
435  QOpenGLTexture::PixelType PixelType,
436  QOpenGLTexture::PixelFormat PixelFormat,
437  QOpenGLTexture::TextureFormat Format,
438  QOpenGLTexture::Filter Filter,
439  QOpenGLTexture::WrapMode Wrap)
440 {
441  if (!Context)
442  return nullptr;
443 
444  OpenGLLocker locker(Context);
445 
446  int datasize = MythRenderOpenGL::GetBufferSize(Size, PixelFormat, PixelType);
447  if (!datasize)
448  return nullptr;
449 
450  auto *texture = new QOpenGLTexture(static_cast<QOpenGLTexture::Target>(Target));
451  texture->setAutoMipMapGenerationEnabled(false);
452  texture->setMipLevels(1);
453  texture->setSize(Size.width(), Size.height()); // this triggers creation
454  if (!texture->textureId())
455  {
456  LOG(VB_GENERAL, LOG_INFO, LOC + "Failed to create texture");
457  delete texture;
458  return nullptr;
459  }
460 
461  if (Format == QOpenGLTexture::NoFormat)
462  {
463  if (Context->GetExtraFeatures() & kGLLegacyTextures)
464  Format = QOpenGLTexture::RGBAFormat;
465  else
466  Format = QOpenGLTexture::RGBA8_UNorm;
467  }
468  texture->setFormat(Format);
469  texture->allocateStorage(PixelFormat, PixelType);
470  texture->setMinMagFilters(Filter, Filter);
471  texture->setWrapMode(Wrap);
472 
473  auto *result = new MythVideoTextureOpenGL(texture);
474  result->m_target = Target;
475  result->m_pixelFormat = PixelFormat;
476  result->m_pixelType = PixelType;
477  result->m_vbo = Context->CreateVBO(static_cast<int>(MythRenderOpenGL::kVertexSize));
478  result->m_totalSize = Context->GetTextureSize(Size, result->m_target != QOpenGLTexture::TargetRectangle);
479  result->m_bufferSize = datasize;
480  result->m_size = Size;
481  return result;
482 }
483 
486  MythVideoTextureOpenGL *Texture, uint Plane)
487 {
488  if (Context->GetExtraFeatures() & kGLExtSubimage)
489  {
490  int pitch = (Frame->m_type == FMT_YV12 || Frame->m_type == FMT_YUV422P || Frame->m_type == FMT_YUV444P) ?
491  Frame->m_pitches[Plane] : Frame->m_pitches[Plane] >> 1;
492  Context->glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch);
493  Texture->m_texture->setData(Texture->m_pixelFormat, Texture->m_pixelType,
494  static_cast<uint8_t*>(Frame->m_buffer) + Frame->m_offsets[Plane]);
495  Context->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
496  }
497  else
498  {
499  if (!Texture->m_data)
500  if (!CreateBuffer(Texture, Texture->m_bufferSize))
501  return;
502  int pitch = (Frame->m_type == FMT_YV12 || Frame->m_type == FMT_YUV422P || Frame->m_type == FMT_YUV444P) ?
503  Texture->m_size.width() : Texture->m_size.width() << 1;
504  MythVideoFrame::CopyPlane(Texture->m_data, pitch, Frame->m_buffer + Frame->m_offsets[Plane],
505  Frame->m_pitches[Plane], pitch, Texture->m_size.height());
506  Texture->m_texture->setData(Texture->m_pixelFormat, Texture->m_pixelType, Texture->m_data);
507  }
508  Texture->m_valid = true;
509 }
510 
513 {
514  // Create a buffer
515  if (!Texture->m_data)
516  if (!CreateBuffer(Texture, Texture->m_bufferSize))
517  return;
518  void* buffer = Texture->m_data;
519 
520  // Create a copy context
521  if (!Texture->m_copyContext)
522  {
523  Texture->m_copyContext = new MythAVCopy();
524  if (!Texture->m_copyContext)
525  return;
526  }
527 
528  // Convert
529  AVFrame out;
530  Texture->m_copyContext->Copy(&out, Frame, static_cast<unsigned char*>(buffer), AV_PIX_FMT_UYVY422);
531 
532  // Update
533  Texture->m_texture->setData(Texture->m_pixelFormat, Texture->m_pixelType, buffer);
534  Texture->m_valid = true;
535 }
536 
539  MythVideoTextureOpenGL *Texture, uint Plane)
540 {
541  if (Context->GetExtraFeatures() & kGLExtSubimage)
542  {
543  bool hdr = Texture->m_frameFormat != FMT_NV12;
544  Context->glPixelStorei(GL_UNPACK_ROW_LENGTH, Plane ? Frame->m_pitches[Plane] >> (hdr ? 2 : 1) :
545  Frame->m_pitches[Plane] >> (hdr ? 1 : 0));
546  Texture->m_texture->setData(Texture->m_pixelFormat, Texture->m_pixelType,
547  static_cast<uint8_t*>(Frame->m_buffer) + Frame->m_offsets[Plane]);
548  Context->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
549  }
550  else
551  {
552  if (!Texture->m_data)
553  if (!CreateBuffer(Texture, Texture->m_bufferSize))
554  return;
555  MythVideoFrame::CopyPlane(Texture->m_data, Frame->m_pitches[Plane], Frame->m_buffer + Frame->m_offsets[Plane],
556  Frame->m_pitches[Plane], Frame->m_pitches[Plane], Texture->m_size.height());
557  Texture->m_texture->setData(Texture->m_pixelFormat, Texture->m_pixelType, Texture->m_data);
558  }
559  Texture->m_valid = true;
560 }
561 
564 {
565  if (!Texture || Size < 1)
566  return false;
567 
568  unsigned char *scratch = MythVideoFrame::GetAlignedBuffer(static_cast<size_t>(Size));
569  if (scratch)
570  {
571  memset(scratch, 0, static_cast<size_t>(Size));
572  Texture->m_data = scratch;
573  return true;
574  }
575 
576  LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to allocate texture buffer");
577  return false;
578 }
579 
581  QSize Size, bool HighPrecision)
582 {
583  // Use a 16bit float framebuffer if requested/required and available (not GLES2) to maintain precision.
584  // The depth check will pick up all software formats as well as NVDEC, VideoToolBox and VAAPI DRM.
585  // VAAPI GLXPixmap and GLXCopy are currently not 10/12bit aware and VDPAU has no 10bit support -
586  // and all return RGB formats anyway. The MediaCodec texture format is an unknown but resizing will
587  // never be enabled as it returns an RGB frame - so if MediaCodec uses a 16bit texture, precision
588  // will be preserved.
589  bool sixteenbitfb = Context->GetExtraFeatures() & kGL16BitFBO;
590  bool sixteenbitvid = HighPrecision ? true : MythVideoFrame::ColorDepth(OutputType) > 8;
591  if (sixteenbitfb && sixteenbitvid)
592  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Requesting 16bit framebuffer texture");
593  auto * framebuffer = Context->CreateFramebuffer(Size, sixteenbitfb && sixteenbitvid);
594  if (framebuffer == nullptr)
595  return { nullptr, nullptr };
596  auto * texture = new MythVideoTextureOpenGL(framebuffer->texture());
597  texture->m_size = texture->m_totalSize = framebuffer->size();
598  texture->m_vbo = Context->CreateVBO(static_cast<int>(MythRenderOpenGL::kVertexSize));
599  texture->m_flip = false;
600  texture->m_planeCount = 1;
601  texture->m_frameType = FMT_RGBA32;
602  texture->m_frameFormat = FMT_RGBA32;
603  texture->m_valid = true;
604  return { framebuffer, texture };
605 }
MythGLTexture
Definition: mythrenderopengl.h:59
FMT_YUV420P10
@ FMT_YUV420P10
Definition: mythframe.h:26
MythGLTexture::m_texture
QOpenGLTexture * m_texture
Definition: mythrenderopengl.h:69
FMT_YUV420P16
@ FMT_YUV420P16
Definition: mythframe.h:29
FMT_YUV420P14
@ FMT_YUV420P14
Definition: mythframe.h:28
MythVideoTextureOpenGL
Definition: mythvideotextureopengl.h:21
MythVideoTextureOpenGL::m_planeCount
uint m_planeCount
Definition: mythvideotextureopengl.h:54
FMT_YUV444P10
@ FMT_YUV444P10
Definition: mythframe.h:46
FMT_YUV422P14
@ FMT_YUV422P14
Definition: mythframe.h:41
Frame
Definition: zmdefines.h:93
MythGLTexture::m_pixelFormat
QOpenGLTexture::PixelFormat m_pixelFormat
Definition: mythrenderopengl.h:70
FMT_P010
@ FMT_P010
Definition: mythframe.h:54
MythGLTexture::m_data
unsigned char * m_data
Definition: mythrenderopengl.h:66
MythVideoTextureOpenGL::MythVideoTextureOpenGL
MythVideoTextureOpenGL(GLuint Texture)
Definition: mythvideotextureopengl.cpp:12
GL_UNPACK_ROW_LENGTH
#define GL_UNPACK_ROW_LENGTH
Definition: mythrenderopengldefs.h:17
MythDate::Format
Format
Definition: mythdate.h:15
FMT_YUV422P
@ FMT_YUV422P
Definition: mythframe.h:37
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
MythVideoTextureOpenGL::m_frameFormat
VideoFrameType m_frameFormat
Definition: mythvideotextureopengl.h:52
MythVideoFrame::HardwareFormat
static bool HardwareFormat(VideoFrameType Type)
Definition: mythframe.h:425
kGLLegacyTextures
@ kGLLegacyTextures
Definition: mythrenderopengl.h:50
MythVideoTextureOpenGL::SetTextureFilters
static void SetTextureFilters(MythRenderOpenGL *Context, const std::vector< MythVideoTextureOpenGL * > &Textures, QOpenGLTexture::Filter Filter, QOpenGLTexture::WrapMode Wrap=QOpenGLTexture::ClampToEdge)
Definition: mythvideotextureopengl.cpp:40
mythvideotextureopengl.h
MythVideoTextureOpenGL::UpdateTextures
static void UpdateTextures(MythRenderOpenGL *Context, const MythVideoFrame *Frame, const std::vector< MythVideoTextureOpenGL * > &Textures)
Update the contents of the given Textures for data held in Frame.
Definition: mythvideotextureopengl.cpp:281
kGLExtSubimage
@ kGLExtSubimage
Definition: mythrenderopengl.h:48
true
VERBOSE_PREAMBLE Most true
Definition: verbosedefs.h:91
FMT_YUV444P14
@ FMT_YUV444P14
Definition: mythframe.h:48
FMT_YUV444P
@ FMT_YUV444P
Definition: mythframe.h:44
MythGLTexture::m_pixelType
QOpenGLTexture::PixelType m_pixelType
Definition: mythrenderopengl.h:71
AVFrame
struct AVFrame AVFrame
Definition: BorderDetector.h:15
MythVideoTextureOpenGL::CreateSoftwareTextures
static std::vector< MythVideoTextureOpenGL * > CreateSoftwareTextures(MythRenderOpenGL *Context, VideoFrameType Type, VideoFrameType Format, std::vector< QSize > Sizes, GLenum Target)
Create a set of OpenGL textures to represent the given Format.
Definition: mythvideotextureopengl.cpp:133
mythlogging.h
kGL16BitFBO
@ kGL16BitFBO
Definition: mythrenderopengl.h:52
MythRenderOpenGL::kVertexSize
static const GLuint kVertexSize
Definition: mythrenderopengl.h:132
MythGLTexture::m_vbo
QOpenGLBuffer * m_vbo
Definition: mythrenderopengl.h:72
MythVideoFrame::CopyPlane
static void CopyPlane(uint8_t *To, int ToPitch, const uint8_t *From, int FromPitch, int PlaneWidth, int PlaneHeight)
Definition: mythframe.cpp:188
FMT_YUV444P9
@ FMT_YUV444P9
Definition: mythframe.h:45
FMT_YV12
@ FMT_YV12
Definition: mythframe.h:24
FMT_YUV422P10
@ FMT_YUV422P10
Definition: mythframe.h:39
FMT_YUV444P16
@ FMT_YUV444P16
Definition: mythframe.h:49
LOC
#define LOC
Definition: mythvideotextureopengl.cpp:5
FMT_YUV420P12
@ FMT_YUV420P12
Definition: mythframe.h:27
MythVideoFrame::ColorDepth
static int ColorDepth(int Format)
Definition: mythframe.h:399
MythVideoTextureOpenGL::DeleteTexture
static void DeleteTexture(MythRenderOpenGL *Context, MythVideoTextureOpenGL *Texture)
Definition: mythvideotextureopengl.cpp:17
MythRenderOpenGL::GetExtraFeatures
int GetExtraFeatures(void) const
Definition: mythrenderopengl.cpp:453
MythRenderOpenGL::CreateVBO
QOpenGLBuffer * CreateVBO(int Size, bool Release=true)
Definition: mythrenderopengl.cpp:1076
uint
unsigned int uint
Definition: compat.h:140
MythGLTexture::m_bufferSize
int m_bufferSize
Definition: mythrenderopengl.h:67
FMT_YUV444P12
@ FMT_YUV444P12
Definition: mythframe.h:47
MythVideoTextureOpenGL::m_plane
uint m_plane
Definition: mythvideotextureopengl.h:53
VideoFramebuffer
std::pair< QOpenGLFramebufferObject *, MythVideoTextureOpenGL * > VideoFramebuffer
Definition: mythvideotextureopengl.h:19
MythRenderOpenGL
Definition: mythrenderopengl.h:99
FMT_YUV422P9
@ FMT_YUV422P9
Definition: mythframe.h:38
FMT_YUV420P9
@ FMT_YUV420P9
Definition: mythframe.h:25
FMT_YUV422P16
@ FMT_YUV422P16
Definition: mythframe.h:42
FMT_YUY2
@ FMT_YUY2
Definition: mythframe.h:51
MythVideoTextureOpenGL::CreateHardwareTextures
static std::vector< MythVideoTextureOpenGL * > CreateHardwareTextures(MythRenderOpenGL *Context, VideoFrameType Type, VideoFrameType Format, std::vector< QSize > Sizes, GLenum Target)
Create a set of hardware textures suitable for the given format.
Definition: mythvideotextureopengl.cpp:85
FMT_YUV422P12
@ FMT_YUV422P12
Definition: mythframe.h:40
MythVideoTextureOpenGL::DeleteTextures
static void DeleteTextures(MythRenderOpenGL *Context, std::vector< MythVideoTextureOpenGL * > &Textures)
Definition: mythvideotextureopengl.cpp:31
MythVideoTextureOpenGL::CreateVideoFrameBuffer
static VideoFramebuffer CreateVideoFrameBuffer(MythRenderOpenGL *Context, VideoFrameType OutputType, QSize Size, bool HighPrecision=true)
Definition: mythvideotextureopengl.cpp:580
MythGLTexture::m_size
QSize m_size
Definition: mythrenderopengl.h:73
MythRenderOpenGL::CreateFramebuffer
QOpenGLFramebufferObject * CreateFramebuffer(QSize &Size, bool SixteenBit=false)
Definition: mythrenderopengl.cpp:729
MythRenderOpenGL::SetTextureFilters
void SetTextureFilters(MythGLTexture *Texture, QOpenGLTexture::Filter Filter, QOpenGLTexture::WrapMode Wrap=QOpenGLTexture::ClampToEdge)
Definition: mythrenderopengl.cpp:677
MythVideoTextureOpenGL::YV12ToYV12
static void YV12ToYV12(MythRenderOpenGL *Context, const MythVideoFrame *Frame, MythVideoTextureOpenGL *Texture, uint Plane)
Copy YV12 frame data to 'YV12' textures.
Definition: mythvideotextureopengl.cpp:485
MythVideoTextureOpenGL::CreateBuffer
static bool CreateBuffer(MythVideoTextureOpenGL *Texture, int Size)
Create a data buffer for holding CPU side texture data.
Definition: mythvideotextureopengl.cpp:563
MythVideoFrame::GetNumPlanes
static uint GetNumPlanes(VideoFrameType Type)
Definition: mythframe.h:214
MythAVCopy
Definition: mythavutil.h:47
MythVideoTextureOpenGL::m_frameType
VideoFrameType m_frameType
Definition: mythvideotextureopengl.h:51
MythVideoFrame::GetAlignedBuffer
static uint8_t * GetAlignedBuffer(size_t Size)
Definition: mythframe.cpp:430
VideoFrameType
VideoFrameType
Definition: mythframe.h:20
MythVideoTextureOpenGL::CreateTexture
static MythVideoTextureOpenGL * CreateTexture(MythRenderOpenGL *Context, QSize Size, GLenum Target=QOpenGLTexture::Target2D, QOpenGLTexture::PixelType PixelType=QOpenGLTexture::UInt8, QOpenGLTexture::PixelFormat PixelFormat=QOpenGLTexture::RGBA, QOpenGLTexture::TextureFormat Format=QOpenGLTexture::NoFormat, QOpenGLTexture::Filter Filter=QOpenGLTexture::Linear, QOpenGLTexture::WrapMode Wrap=QOpenGLTexture::ClampToEdge)
Create and initialise a MythVideoTexture that is backed by a QOpenGLTexture.
Definition: mythvideotextureopengl.cpp:432
MythVideoFrame
Definition: mythframe.h:88
FMT_NV12
@ FMT_NV12
Definition: mythframe.h:53
MythVideoTextureOpenGL::NV12ToNV12
static void NV12ToNV12(MythRenderOpenGL *Context, const MythVideoFrame *Frame, MythVideoTextureOpenGL *Texture, uint Plane)
Copy NV12 video frame data to 'NV12' textures.
Definition: mythvideotextureopengl.cpp:538
MythAVCopy::Copy
int Copy(AVFrame *To, const MythVideoFrame *From, unsigned char *Buffer, AVPixelFormat Fmt=AV_PIX_FMT_YUV420P)
Initialise AVFrame and copy contents of VideoFrame frame into it, performing any required conversion.
Definition: mythavutil.cpp:229
FMT_P016
@ FMT_P016
Definition: mythframe.h:55
MythRenderOpenGL::GetTextureSize
QSize GetTextureSize(QSize Size, bool Normalised)
Definition: mythrenderopengl.cpp:656
MythRenderOpenGL::GetBufferSize
static int GetBufferSize(QSize Size, QOpenGLTexture::PixelFormat Format, QOpenGLTexture::PixelType Type)
Definition: mythrenderopengl.cpp:1317
MythVideoTextureOpenGL::YV12ToYUYV
static void YV12ToYUYV(const MythVideoFrame *Frame, MythVideoTextureOpenGL *Texture)
Copy YV12 frame data to a YUYV texture.
Definition: mythvideotextureopengl.cpp:512
MythVideoTextureOpenGL::CreateTextures
static std::vector< MythVideoTextureOpenGL * > CreateTextures(MythRenderOpenGL *Context, VideoFrameType Type, VideoFrameType Format, std::vector< QSize > Sizes, GLenum Target=QOpenGLTexture::Target2D)
Create a set of textures suitable for the given Type and Format.
Definition: mythvideotextureopengl.cpp:57
MythVideoTextureOpenGL::m_copyContext
MythAVCopy * m_copyContext
Definition: mythvideotextureopengl.h:59
FMT_RGBA32
@ FMT_RGBA32
Definition: mythframe.h:35
OpenGLLocker
Definition: mythrenderopengl.h:261
MythVideoTextureOpenGL::m_valid
bool m_valid
Definition: mythvideotextureopengl.h:49