MythTV  master
mythopenglvideo.cpp
Go to the documentation of this file.
1 // Qt
2 #include <QPen>
3 
4 // MythTV
5 #include "mythcontext.h"
6 #include "tv.h"
8 #include "mythavutil.h"
10 #include "mythopengltonemap.h"
11 #include "mythopenglvideo.h"
12 
13 // std
14 #include <utility>
15 
16 // FFmpeg
17 extern "C" {
18 #include "libavutil/stereo3d.h"
19 }
20 
21 #define LOC QString("GLVid: ")
22 #define MAX_VIDEO_TEXTURES 10 // YV12 Kernel deinterlacer + 1
23 
35  MythVideoBounds* Bounds,
36  const QString& Profile)
37  : MythVideoGPU(Render, ColourSpace, Bounds, Profile),
38  m_openglRender(Render)
39 {
41  {
42  LOG(VB_GENERAL, LOG_ERR, LOC + "Fatal error");
43  return;
44  }
45 
46  OpenGLLocker ctx_lock(m_openglRender);
47  if (m_openglRender->isOpenGLES())
48  m_gles = m_openglRender->format().majorVersion();
49 
50  // Set OpenGL feature support
53  m_valid = true;
54 
55  m_chromaUpsamplingFilter = gCoreContext->GetBoolSetting("ChromaUpsamplingFilter", true);
56  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Chroma upsampling filter %1")
57  .arg(m_chromaUpsamplingFilter ? "enabled" : "disabled"));
58 }
59 
61 {
62  if (!m_openglRender)
63  return;
64 
67  delete m_toneMap;
69 }
70 
71 void MythOpenGLVideo::ColourSpaceUpdate(bool PrimariesChanged)
72 {
74 
75  // if input/output type are unset - we haven't created the shaders yet
76  if (PrimariesChanged && (m_outputType != FMT_NONE))
77  {
78  LOG(VB_GENERAL, LOG_INFO, LOC + "Primaries conversion changed - recreating shaders");
80  }
81 
82  float colourgamma = m_videoColourSpace->GetColourGamma();
83  float displaygamma = 1.0F / m_videoColourSpace->GetDisplayGamma();
84  QMatrix4x4 primary = m_videoColourSpace->GetPrimaryMatrix();
85  for (size_t i = Progressive; i < ShaderCount; ++i)
86  {
88  m_openglRender->SetShaderProgramParams(m_shaders[i], primary, "m_primaryMatrix");
89  if (m_shaders[i])
90  {
91  m_shaders[i]->setUniformValue("m_colourGamma", colourgamma);
92  m_shaders[i]->setUniformValue("m_displayGamma", displaygamma);
93  }
94  }
95 }
96 
98 {
99  if (m_inputTextureSize.isEmpty())
100  return;
101 
103  bool rect = m_textureTarget == QOpenGLTexture::TargetRectangle;
104  GLfloat lineheight = rect ? 1.0F : 1.0F / m_inputTextureSize.height();
105  GLfloat maxheight = rect ? m_videoDispDim.height() : m_videoDispDim.height() /
106  static_cast<GLfloat>(m_inputTextureSize.height());
107  GLfloat fieldsize = rect ? 0.5F : m_inputTextureSize.height() / 2.0F;
108  QVector4D parameters(lineheight, /* lineheight */
109  static_cast<GLfloat>(m_inputTextureSize.width()), /* 'Y' select */
110  maxheight - lineheight, /* maxheight */
111  fieldsize /* fieldsize */);
112 
113  for (size_t i = Progressive; i < ShaderCount; ++i)
114  {
115  if (m_shaders[i])
116  {
118  m_shaders[i]->setUniformValue("m_frameData", parameters);
119  }
120  }
121 }
122 
124 {
126  return TypeToProfile(m_inputType);
127  return TypeToProfile(m_outputType);
128 }
129 
131 {
132  // If switching off/from basic deinterlacing, then we need to delete and
133  // recreate the input textures and sometimes the shaders as well - so start
134  // from scratch
136  {
137  // Note. Textures will be created with linear filtering - which matches
138  // no resizing - which should be the case for the basic deinterlacer - and
139  // the call to SetupFrameFormat will reset resizing anyway
140  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Removing single field textures");
141  // revert to YUY2 if preferred
142  if ((m_inputType == FMT_YV12) && (m_profile == "opengl"))
145  emit OutputChanged(m_videoDim, m_videoDim, -1.0F);
146  }
149  m_deinterlacer2x = false;
150 }
151 
153  MythDeintType Filter /* = DEINT_SHADER */,
154  bool CreateReferences /* = true */)
155 {
156  if (!Frame)
157  return false;
158 
159  // do we want an opengl shader?
160  // shaders trump CPU deinterlacers if selected and driver deinterlacers will only
161  // be available under restricted circumstances
162  // N.B. there should in theory be no situation in which shader deinterlacing is not
163  // available for software formats, hence there should be no need to fallback to cpu
164 
165  if (!is_interlaced(Scan) || Frame->m_alreadyDeinterlaced)
166  {
168  return false;
169  }
170 
171  m_deinterlacer2x = true;
172  MythDeintType deinterlacer = Frame->GetDoubleRateOption(Filter);
173  MythDeintType other = Frame->GetDoubleRateOption(DEINT_DRIVER);
174  if (other) // another double rate deinterlacer is enabled
175  {
177  return false;
178  }
179 
180  if (!deinterlacer)
181  {
182  m_deinterlacer2x = false;
183  deinterlacer = Frame->GetSingleRateOption(Filter);
184  other = Frame->GetSingleRateOption(DEINT_DRIVER);
185  if (!deinterlacer || other) // no shader deinterlacer needed
186  {
188  return false;
189  }
190  }
191 
192  // if we get this far, we cannot use driver deinterlacers, shader deints
193  // are preferred over cpu, we have a deinterlacer but don't actually care whether
194  // it is single or double rate
195  if (m_deinterlacer == deinterlacer || (m_fallbackDeinterlacer && (m_fallbackDeinterlacer == deinterlacer)))
196  return true;
197 
198  // Lock
199  OpenGLLocker ctx_lock(m_openglRender);
200 
201  // delete old reference textures
204 
205  // For basic deinterlacing of software frames, we now create 2 sets of field
206  // based textures - which is the same approach taken by the CPU based onefield/bob
207  // deinterlacer and the EGL basic deinterlacer. The advantages of this
208  // approach are:-
209  // - no dependent texturing in the samplers (it is just a basic YUV to RGB conversion
210  // in the shader)
211  // - better quality (the onefield shader line doubles but does not have the
212  // implicit interpolation/smoothing of using separate textures directly,
213  // which leads to 'blockiness').
214  // - as we are not sampling other fields, there is no need to use an intermediate
215  // framebuffer to ensure accurate sampling - so we can skip the resize stage.
216  //
217  // YUYV formats are currently not supported as it does not work correctly - force YV12 instead.
218 
219  if (deinterlacer == DEINT_BASIC && MythVideoFrame::YUVFormat(m_inputType))
220  {
221  if (m_outputType == FMT_YUY2)
222  {
223  LOG(VB_GENERAL, LOG_INFO, LOC + "Forcing OpenGL YV12 for basic deinterlacer");
225  }
227  QSize size(m_videoDim.width(), m_videoDim.height() >> 1);
228  vector<QSize> sizes;
229  sizes.emplace_back(size);
230  // N.B. If we are currently resizing, it will be turned off for this
231  // deinterlacer, so the default linear texture filtering is OK.
233  // nextTextures will hold the other field
235  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Created %1 single field textures")
236  .arg(m_inputTextures.size() * 2));
237  // Con MythVideoBounds into display the field only
238  emit OutputChanged(m_videoDim, size, -1.0F);
239  }
240 
241  // sanity check max texture units. Should only be an issue on old hardware (e.g. Pi)
242  int max = m_openglRender->GetMaxTextureUnits();
243  uint refstocreate = ((deinterlacer == DEINT_HIGH) && CreateReferences) ? 2 : 0;
244  int totaltextures = static_cast<int>(MythVideoFrame::GetNumPlanes(m_outputType)) * static_cast<int>(refstocreate + 1);
245  if (totaltextures > max)
246  {
247  m_fallbackDeinterlacer = deinterlacer;
248  LOG(VB_GENERAL, LOG_WARNING, LOC + QString("Insufficent texture units for deinterlacer '%1' (%2 < %3)")
249  .arg(MythVideoFrame::DeinterlacerName(deinterlacer | DEINT_SHADER, m_deinterlacer2x)).arg(max).arg(totaltextures));
250  deinterlacer = DEINT_BASIC;
251  LOG(VB_GENERAL, LOG_WARNING, LOC + QString("Falling back to '%1'")
253  }
254 
255  // create new deinterlacers - the old ones will be deleted
256  if (!(CreateVideoShader(InterlacedBot, deinterlacer) && CreateVideoShader(InterlacedTop, deinterlacer)))
257  return false;
258 
259  // create the correct number of reference textures
260  if (refstocreate)
261  {
262  vector<QSize> sizes;
263  sizes.emplace_back(QSize(m_videoDim));
266  // ensure we use GL_NEAREST if resizing is already active and needed
267  if ((m_resizing & Sampling) == Sampling)
268  {
271  }
272  }
273 
274  // ensure they work correctly
275  UpdateColourSpace(false);
277  m_deinterlacer = deinterlacer;
278 
279  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Created deinterlacer '%1' (%2->%3)")
283  return true;
284 }
285 
294 {
295  if (!m_openglRender || !(m_features & QOpenGLFunctions::Shaders))
296  return false;
297 
298  // delete the old
299  if (m_shaders[Type])
301  m_shaders[Type] = nullptr;
302 
303  QStringList defines;
304  QString vertex = DefaultVertexShader;
305  QString fragment;
306  int cost = 1;
307 
309  defines << "EXTOES";
310 
311  if ((Default == Type) || (!MythVideoFrame::YUVFormat(m_outputType)))
312  {
313  QString glsldefines;
314  for (const QString& define : qAsConst(defines))
315  glsldefines += QString("#define MYTHTV_%1\n").arg(define);
316  fragment = glsldefines + YUVFragmentExtensions + RGBFragmentShader;
317 
318 #ifdef USING_MEDIACODEC
320  vertex = MediaCodecVertexShader;
321 #endif
322  }
323  // no interlaced shaders yet (i.e. interlaced chroma upsampling - not deinterlacers)
324  else
325  {
326  fragment = YUVFragmentShader;
327  QString extensions = YUVFragmentExtensions;
328  QString glsldefines;
329 
330  // Any software frames that are not 8bit need to use unsigned integer
331  // samplers with GLES3.x - which need more modern shaders
332  if ((m_gles > 2) && (MythVideoFrame::ColorDepth(m_inputType) > 8))
333  {
334  static const QString glsl300("#version 300 es\n");
335  fragment = GLSL300YUVFragmentShader;
336  extensions = GLSL300YUVFragmentExtensions;
337  vertex = glsl300 + GLSL300VertexShader;
338  glsldefines.append(glsl300);
339  }
340 
341  bool kernel = false;
342  bool topfield = InterlacedTop == Type;
343  bool progressive = (Progressive == Type) || (Deint == DEINT_NONE);
345  {
346  defines << "YV12";
347  cost = 3;
348  }
350  {
351  defines << "NV12";
352  cost = 2;
353  }
354  else if (FMT_YUY2 == m_outputType)
355  {
356  defines << "YUY2";
357  }
358 
359 #ifdef USING_VTB
360  // N.B. Rectangular texture support is only currently used for VideoToolBox
361  // video frames which are NV12. Do not use rectangular textures for the 'default'
362  // shaders as it breaks video resizing and would require changes to our
363  // FramebufferObject code.
364  if ((m_textureTarget == QOpenGLTexture::TargetRectangle) && (Default != Type))
365  defines << "RECTS";
366 #endif
367  if (!progressive)
368  {
369  bool basic = Deint == DEINT_BASIC && MythVideoFrame::YUVFormat(m_inputType);
370  // Chroma upsampling filter
372  m_chromaUpsamplingFilter && !basic)
373  {
374  defines << "CUE";
375  }
376 
377  // field
378  if (topfield && !basic)
379  defines << "TOPFIELD";
380 
381  switch (Deint)
382  {
383  case DEINT_BASIC:
384  if (!basic)
385  {
386  cost *= 2;
387  defines << "ONEFIELD";
388  }
389  break;
390  case DEINT_MEDIUM: cost *= 5; defines << "LINEARBLEND"; break;
391  case DEINT_HIGH: cost *= 15; defines << "KERNEL"; kernel = true; break;
392  default: break;
393  }
394  }
395 
396  // Start building the new fragment shader
397  // We do this in code otherwise the shader string becomes monolithic
398 
399  // 'expand' calls to sampleYUV for multiple planes
400  // do this before we add the samplers
401  int count = static_cast<int>(MythVideoFrame::GetNumPlanes(m_outputType));
402  for (int i = (kernel ? 2 : 0); (i >= 0) && count; i--)
403  {
404  QString find = QString("s_texture%1").arg(i);
405  QStringList replacelist;
406  for (int j = (i * count); j < ((i + 1) * count); ++j)
407  replacelist << QString("s_texture%1").arg(j);
408  fragment.replace(find, replacelist.join(", "));
409  }
410 
411  // 'expand' calls to the kernel function
412  if (kernel && count)
413  {
414  for (int i = 1 ; i >= 0; i--)
415  {
416  QString find1 = QString("sampler2D kernelTex%1").arg(i);
417  QString find2 = QString("kernelTex%1").arg(i);
418  QStringList replacelist1;
419  QStringList replacelist2;
420  for (int j = 0; j < count; ++j)
421  {
422  replacelist1 << QString("sampler2D kernelTexture%1%2").arg(i).arg(j);
423  replacelist2 << QString("kernelTexture%1%2").arg(i).arg(j);
424  }
425  fragment.replace(find1, replacelist1.join(", "));
426  fragment.replace(find2, replacelist2.join(", "));
427  }
428  }
429 
430  // Retrieve colour mappping defines
432 
433  // Add defines
434  for (const QString& define : qAsConst(defines))
435  glsldefines += QString("#define MYTHTV_%1\n").arg(define);
436 
437  // Add the required samplers
438  int start = 0;
439  int end = count;
440  if (kernel)
441  {
442  end *= 3;
443  if (topfield)
444  start += count;
445  else
446  end -= count;
447  }
448  QString glslsamplers;
449  for (int i = start; i < end; ++i)
450  glslsamplers += QString("uniform sampler2D s_texture%1;\n").arg(i);
451 
452  // construct the final shader string
453  fragment = glsldefines + extensions + glslsamplers + fragment;
454  }
455 
456  m_shaderCost[Type] = cost;
457  QOpenGLShaderProgram *program = m_openglRender->CreateShaderProgram(vertex, fragment);
458  if (!program)
459  return false;
460 
461  m_shaders[Type] = program;
462  return true;
463 }
464 
466  QSize Size, GLenum TextureTarget)
467 {
468  QString texnew = (TextureTarget == QOpenGLTexture::TargetRectangle) ? "Rect" :
469  (TextureTarget == GL_TEXTURE_EXTERNAL_OES) ? "OES" : "2D";
470  QString texold = (m_textureTarget == QOpenGLTexture::TargetRectangle) ? "Rect" :
471  (m_textureTarget == GL_TEXTURE_EXTERNAL_OES) ? "OES" : "2D";
472  LOG(VB_GENERAL, LOG_INFO, LOC +
473  QString("New frame format: %1:%2 %3x%4 (Tex: %5) -> %6:%7 %8x%9 (Tex: %10)")
476  .arg(m_videoDim.width()).arg(m_videoDim.height()).arg(texold)
477  .arg(MythVideoFrame::FormatDescription(InputType))
478  .arg(MythVideoFrame::FormatDescription(OutputType))
479  .arg(Size.width()).arg(Size.height()).arg(texnew));
480 
482 
483  m_inputType = InputType;
484  m_outputType = OutputType;
485  m_textureTarget = TextureTarget;
486  m_videoDim = Size;
487 
488  // This is only currently needed for RGBA32 frames from composed DRM_PRIME
489  // textures that may be half height for simple bob deinterlacing
491  emit OutputChanged(m_videoDim, m_videoDim, -1.0F);
492 
493  if (!MythVideoFrame::HardwareFormat(InputType))
494  {
495  vector<QSize> sizes;
496  sizes.push_back(Size);
498  if (m_inputTextures.empty())
499  {
500  LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create input textures");
501  return false;
502  }
503 
504  m_inputTextureSize = m_inputTextures[0]->m_totalSize;
505  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Created %1 input textures for '%2'")
506  .arg(m_inputTextures.size()).arg(GetProfile()));
507  }
508  else
509  {
510  m_inputTextureSize = Size;
511  }
512 
513  // Create shaders
515  return false;
516 
517  UpdateColourSpace(false);
519  return true;
520 }
521 
523 {
524  for (auto & shader : m_shaders)
525  if (shader)
527  m_shaders.fill(nullptr);
528  m_shaderCost.fill(1);
532  m_textureTarget = QOpenGLTexture::Target2D;
536  m_frameBuffer = nullptr;
537  m_frameBufferTexture = nullptr;
538 
540 }
541 
544 {
545  if (Frame->m_type == FMT_NONE)
546  return;
547 
548  // Hardware frames are retrieved/updated in PrepareFrame but we need to
549  // reset software frames now if necessary
551  {
553  {
554  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Resetting input format");
556  }
557  return;
558  }
559 
560  // Sanitise frame
561  if ((Frame->m_width < 1) || (Frame->m_height < 1) || !Frame->m_buffer)
562  {
563  LOG(VB_GENERAL, LOG_ERR, LOC + "Invalid software frame");
564  return;
565  }
566 
567  // Can we render this frame format
568  if (!MythVideoFrame::YUVFormat(Frame->m_type))
569  {
570  LOG(VB_GENERAL, LOG_ERR, LOC + "Frame format is not supported");
571  return;
572  }
573 
574  // lock
575  OpenGLLocker ctx_lock(m_openglRender);
576 
577  // check for input changes
578  if ((Frame->m_width != m_videoDim.width()) ||
579  (Frame->m_height != m_videoDim.height()) ||
580  (Frame->m_type != m_inputType))
581  {
582  VideoFrameType frametype = Frame->m_type;
583  if ((frametype == FMT_YV12) && (m_profile == "opengl"))
584  frametype = FMT_YUY2;
585  QSize size(Frame->m_width, Frame->m_height);
586  if (!SetupFrameFormat(Frame->m_type, frametype, size, QOpenGLTexture::Target2D))
587  return;
588  }
589 
590  // Setup deinterlacing if required
591  AddDeinterlacer(Frame, Scan);
592 
593  if (VERBOSE_LEVEL_CHECK(VB_GPU, LOG_INFO))
594  m_openglRender->logDebugMarker(LOC + "UPDATE_FRAME_START");
595 
597 
598  // Rotate textures if necessary
599  bool current = true;
601  {
602  if (!m_nextTextures.empty() && !m_prevTextures.empty())
603  {
604  if (qAbs(Frame->m_frameCounter - m_discontinuityCounter) > 1)
605  ResetTextures();
606  vector<MythVideoTexture*> temp = m_prevTextures;
609  m_nextTextures = temp;
610  current = false;
611  }
612  }
613 
614  m_discontinuityCounter = Frame->m_frameCounter;
615 
617  {
618  // first field. Fake the pitches
619  FramePitches pitches = Frame->m_pitches;
620  Frame->m_pitches[0] = Frame->m_pitches[0] << 1;
621  Frame->m_pitches[1] = Frame->m_pitches[1] << 1;
622  Frame->m_pitches[2] = Frame->m_pitches[2] << 1;
624  // second field. Fake the offsets as well.
625  FrameOffsets offsets = Frame->m_offsets;
626  Frame->m_offsets[0] = Frame->m_offsets[0] + pitches[0];
627  Frame->m_offsets[1] = Frame->m_offsets[1] + pitches[1];
628  Frame->m_offsets[2] = Frame->m_offsets[2] + pitches[2];
630  Frame->m_pitches = pitches;
631  Frame->m_offsets = offsets;
632  }
633  else
634  {
636  }
637 
638  if (VERBOSE_LEVEL_CHECK(VB_GPU, LOG_INFO))
639  m_openglRender->logDebugMarker(LOC + "UPDATE_FRAME_END");
640 }
641 
643  StereoscopicMode StereoOverride, bool DrawBorder)
644 {
645  if (!m_openglRender)
646  return;
647 
649 
650  if (VERBOSE_LEVEL_CHECK(VB_GPU, LOG_INFO))
651  m_openglRender->logDebugMarker(LOC + "RENDER_FRAME_START");
652 
653  // Set required input textures for the last stage
654  // ProcessFrame is always called first, which will create/destroy software
655  // textures as needed
656  bool hwframes = false;
657  bool useframebufferimage = false;
658 
659  // for tiled renderers (e.g. Pi), enable scissoring to try and improve performance
660  // when not full screen and avoid the resize stage unless absolutely necessary
661  bool tiled = m_extraFeatures & kGLTiled;
662 
663  // We lose the pause frame when seeking and using VDPAU/VAAPI/NVDEC direct rendering.
664  // As a workaround, we always use the resize stage so the last displayed frame
665  // should be retained in the Framebuffer used for resizing. If there is
666  // nothing to display, then fallback to this framebuffer.
667  // N.B. this is now strictly necessary with v4l2 and DRM PRIME direct rendering
668  // but ignore now for performance reasons
669  VideoResizing resize = Frame ? (MythVideoFrame::HardwareFramesFormat(Frame->m_type) ? Framebuffer : None) :
671 
672  vector<MythVideoTexture*> inputtextures = m_inputTextures;
673  if (inputtextures.empty())
674  {
675  // Pull in any hardware frames
677  if (!inputtextures.empty())
678  {
679  hwframes = true;
680  QSize newsize = inputtextures[0]->m_size;
681  VideoFrameType newsourcetype = inputtextures[0]->m_frameType;
682  VideoFrameType newtargettype = inputtextures[0]->m_frameFormat;
683  GLenum newtargettexture = inputtextures[0]->m_target;
684  if ((m_outputType != newtargettype) || (m_textureTarget != newtargettexture) ||
685  (m_inputType != newsourcetype) || (newsize != m_inputTextureSize))
686  {
687  SetupFrameFormat(newsourcetype, newtargettype, newsize, newtargettexture);
688  }
689 
690 #ifdef USING_MEDIACODEC
691  // Set the texture transform for mediacodec
693  {
694  if (inputtextures[0]->m_transform && m_shaders[Default])
695  {
697  m_shaders[Default]->setUniformValue("u_transform", *inputtextures[0]->m_transform);
698  }
699  }
700 #endif
701  // Enable deinterlacing for NVDEC, VTB and VAAPI DRM if VPP is not available
702  if (inputtextures[0]->m_allowGLSLDeint)
703  AddDeinterlacer(Frame, Scan, DEINT_SHADER | DEINT_CPU, false); // pickup shader or cpu prefs
704  }
705  else
706  {
707  if ((resize == Framebuffer) && m_frameBuffer && m_frameBufferTexture)
708  {
709  LOG(VB_PLAYBACK, LOG_DEBUG, "Using existing framebuffer");
710  useframebufferimage = true;
711  }
712  else
713  {
714  LOG(VB_PLAYBACK, LOG_DEBUG, LOC + "Nothing to display");
715  // if this is live tv startup and the window rect has changed we
716  // must set the viewport
718  return;
719  }
720  }
721  }
722 
723  // Determine which shader to use. This helps optimise the resize check.
724  bool deinterlacing = false;
725  bool basicdeinterlacing = false;
727  if (m_deinterlacer != DEINT_NONE)
728  {
729  if (Scan == kScan_Interlaced)
730  {
731  program = TopFieldFirst ? InterlacedTop : InterlacedBot;
732  deinterlacing = true;
733  }
734  else if (Scan == kScan_Intr2ndField)
735  {
736  program = TopFieldFirst ? InterlacedBot : InterlacedTop;
737  deinterlacing = true;
738  }
739 
740  // select the correct field for the basic deinterlacer
742  {
743  basicdeinterlacing = true;
744  if (program == InterlacedBot)
745  inputtextures = m_nextTextures;
746  }
747  }
748 
749  // Set deinterlacer type for debug OSD
750  if (deinterlacing && Frame)
751  {
752  Frame->m_deinterlaceInuse = m_deinterlacer | DEINT_SHADER;
753  Frame->m_deinterlaceInuse2x = m_deinterlacer2x;
754  }
755 
756  // Tonemapping can only render to a texture
757  if (m_toneMap)
758  resize |= ToneMap;
759 
760  // Decide whether to use render to texture - for performance or quality
761  if (MythVideoFrame::YUVFormat(m_outputType) && !resize)
762  {
763  // ensure deinterlacing works correctly when down scaling in height
764  // N.B. not needed for the basic deinterlacer
765  if (deinterlacing && !basicdeinterlacing && (m_videoDispDim.height() > m_displayVideoRect.height()))
766  resize |= Deinterlacer;
767 
768  // NB GL_NEAREST introduces some 'minor' chroma sampling errors
769  // for the following 2 cases. For YUY2 this may be better handled in the
770  // shader. For GLES3.0 10bit textures - Vulkan is probably the better solution.
771 
772  // UYVY packed pixels must be sampled exactly with GL_NEAREST
773  if (FMT_YUY2 == m_outputType)
774  resize |= Sampling;
775  // unsigned integer texture formats need GL_NEAREST sampling
776  if ((m_gles > 2) && (MythVideoFrame::ColorDepth(m_inputType) > 8))
777  resize |= Sampling;
778 
779  // don't enable resizing if the cost of a framebuffer switch may be
780  // prohibitive (e.g. Raspberry Pi/tiled renderers) or for basic deinterlacing,
781  // where we are trying to simplifiy/optimise rendering (and the framebuffer
782  // sizing gets confused by the change to m_videoDispDim)
783  if (!resize && !tiled && !basicdeinterlacing)
784  {
785  // improve performance. This is an educated guess on the relative cost
786  // of render to texture versus straight rendering.
787  int totexture = m_videoDispDim.width() * m_videoDispDim.height() * m_shaderCost[program];
788  int blitcost = m_displayVideoRect.width() * m_displayVideoRect.height() * m_shaderCost[Default];
789  int noresizecost = m_displayVideoRect.width() * m_displayVideoRect.height() * m_shaderCost[program];
790  if ((totexture + blitcost) < noresizecost)
791  resize |= Performance;
792  }
793  }
794 
795  // set software frame filtering if resizing has changed
796  if (!resize && m_resizing)
797  {
798  // remove framebuffer
800  {
802  m_frameBufferTexture = nullptr;
803  }
804  if (m_frameBuffer)
805  {
807  m_frameBuffer = nullptr;
808  }
809  // set filtering
813  m_resizing = None;
814  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Disabled resizing");
815  }
816  else if (!m_resizing && resize)
817  {
818  // framebuffer will be created as needed below
819  QOpenGLTexture::Filter filter = ((resize & Sampling) == Sampling) ? QOpenGLTexture::Nearest : QOpenGLTexture::Linear;
823  m_resizing = resize;
824  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Resizing from %1x%2 to %3x%4 for %5")
825  .arg(m_videoDispDim.width()).arg(m_videoDispDim.height())
826  .arg(m_displayVideoRect.width()).arg(m_displayVideoRect.height())
827  .arg(VideoResizeToString(resize)));
828  }
829 
830  // check hardware frames have the correct filtering
831  if (hwframes)
832  {
833  QOpenGLTexture::Filter filter = ((resize & Sampling) == Sampling) ? QOpenGLTexture::Nearest : QOpenGLTexture::Linear;
834  if (inputtextures[0]->m_filter != filter)
835  MythVideoTexture::SetTextureFilters(m_openglRender, inputtextures, filter);
836  }
837 
838  // texture coordinates
839  QRect trect(m_videoRect);
840 
841  if (resize)
842  {
843  MythVideoTexture* nexttexture = nullptr;
844 
845  // only render to the framebuffer if there is something to update
846  if (useframebufferimage)
847  {
848  if (m_toneMap)
849  {
850  nexttexture = m_toneMap->GetTexture();
851  trect = QRect(QPoint(0, 0), m_displayVideoRect.size());
852  }
853  else
854  {
855  nexttexture = m_frameBufferTexture;
856  }
857  }
858  else if (m_toneMap)
859  {
860  if (VERBOSE_LEVEL_CHECK(VB_GPU, LOG_INFO))
861  m_openglRender->logDebugMarker(LOC + "RENDER_TO_TEXTURE");
862  nexttexture = m_toneMap->Map(inputtextures, m_displayVideoRect.size());
863  trect = QRect(QPoint(0, 0), m_displayVideoRect.size());
864  }
865  else
866  {
867  // render to texture stage
868  if (VERBOSE_LEVEL_CHECK(VB_GPU, LOG_INFO))
869  m_openglRender->logDebugMarker(LOC + "RENDER_TO_TEXTURE");
870 
871  // we need a framebuffer
872  if (!m_frameBuffer)
873  {
875  if (!m_frameBuffer)
876  return;
877  }
878 
879  // and its associated texture
881  {
884  return;
885  m_openglRender->SetTextureFilters(m_frameBufferTexture, QOpenGLTexture::Linear);
886  }
887 
888  // coordinates
889  QRect vrect(QPoint(0, 0), m_videoDispDim);
890  QRect trect2 = vrect;
891  if (FMT_YUY2 == m_outputType)
892  trect2.setWidth(m_videoDispDim.width() >> 1);
893 
894  // framebuffer
896  m_openglRender->SetViewPort(vrect);
897 
898  // bind correct textures
899  vector<MythGLTexture*> textures {};
900  BindTextures(deinterlacing, inputtextures, textures);
901 
902  // render
904  trect2, vrect, m_shaders[program], 0);
905  nexttexture = m_frameBufferTexture;
906  }
907 
908  // reset for next stage
909  inputtextures.clear();
910  inputtextures.push_back(nexttexture);
911  program = Default;
912  deinterlacing = false;
913  }
914 
915  // render to default framebuffer/screen
916  if (VERBOSE_LEVEL_CHECK(VB_GPU, LOG_INFO))
917  m_openglRender->logDebugMarker(LOC + "RENDER_TO_SCREEN");
918 
919  // discard stereoscopic fields
920  StereoscopicMode stereo = StereoOverride;
921  m_lastStereo = Frame ? Frame->m_stereo3D : m_lastStereo;
922  // N.B. kStereoscopicModeSideBySideDiscard is a proxy here for discard of all types
923  if ((stereo == kStereoscopicModeAuto) &&
925  (m_lastStereo != AV_STEREO3D_2D))
926  {
927  if (m_lastStereo == AV_STEREO3D_SIDEBYSIDE)
929  else if (m_lastStereo == AV_STEREO3D_TOPBOTTOM)
931  }
932 
934  trect = QRect(trect.left() >> 1, trect.top(), trect.width() >> 1, trect.height());
935  else if (kStereoscopicModeTopAndBottomDiscard == stereo)
936  trect = QRect(trect.left(), trect.top() >> 1, trect.width(), trect.height() >> 1);
937 
938  // bind default framebuffer
941 
942  // PiP border
943  if (DrawBorder)
944  {
945  QRect piprect = m_displayVideoRect.adjusted(-10, -10, +10, +10);
946  static const QPen kNopen(Qt::NoPen);
947  static const QBrush kRedBrush(QBrush(QColor(127, 0, 0, 255)));
948  m_openglRender->DrawRect(nullptr, piprect, kRedBrush, kNopen, 255);
949  }
950 
951  // bind correct textures
952  vector<MythGLTexture*> textures;
953  BindTextures(deinterlacing, inputtextures, textures);
954 
955  // rotation
956  if (Frame)
957  m_lastRotation = Frame->m_rotation;
958 
959  // apply scissoring
960  if (tiled)
961  {
962  // N.B. It's not obvious whether this helps
963  m_openglRender->glEnable(GL_SCISSOR_TEST);
964  m_openglRender->glScissor(m_displayVideoRect.left() - 1, m_displayVideoRect.top() - 1,
965  m_displayVideoRect.width() + 2, m_displayVideoRect.height() + 2);
966  }
967 
968  // draw
969  m_openglRender->DrawBitmap(textures, nullptr, trect,
971 
972  // disable scissoring
973  if (tiled)
974  m_openglRender->glDisable(GL_SCISSOR_TEST);
975 
976  if (VERBOSE_LEVEL_CHECK(VB_GPU, LOG_INFO))
977  m_openglRender->logDebugMarker(LOC + "RENDER_FRAME_END");
978 }
979 
982 {
983  for (auto & texture : m_inputTextures)
984  texture->m_valid = false;
985  for (auto & texture : m_prevTextures)
986  texture->m_valid = false;
987  for (auto & texture : m_nextTextures)
988  texture->m_valid = false;
989 }
990 
991 void MythOpenGLVideo::BindTextures(bool Deinterlacing, vector<MythVideoTexture*>& Current,
992  vector<MythGLTexture*>& Textures)
993 {
994  if (Deinterlacing && !MythVideoFrame::HardwareFormat(m_inputType))
995  {
996  if ((m_nextTextures.size() == Current.size()) && (m_prevTextures.size() == Current.size()))
997  {
998  // if we are using reference frames, we want the current frame in the middle
999  // but next will be the first valid, followed by current...
1000  size_t count = Current.size();
1001  vector<MythVideoTexture*>& current = Current[0]->m_valid ? Current : m_nextTextures;
1002  vector<MythVideoTexture*>& prev = m_prevTextures[0]->m_valid ? m_prevTextures : current;
1003 
1004  for (uint i = 0; i < count; ++i)
1005  Textures.push_back(reinterpret_cast<MythGLTexture*>(prev[i]));
1006  for (uint i = 0; i < count; ++i)
1007  Textures.push_back(reinterpret_cast<MythGLTexture*>(current[i]));
1008  for (uint i = 0; i < count; ++i)
1009  Textures.push_back(reinterpret_cast<MythGLTexture*>(m_nextTextures[i]));
1010  return;
1011  }
1012  }
1013 
1014  std::transform(Current.cbegin(), Current.cend(), std::back_inserter(Textures),
1015  [](MythVideoTexture* Tex) { return reinterpret_cast<MythGLTexture*>(Tex); });
1016 }
1017 
1019 {
1021  return "opengl-hw";
1022 
1023  switch (Type)
1024  {
1025  case FMT_YUY2: return "opengl"; // compatibility with old profiles
1026  case FMT_YV12: return "opengl-yv12";
1027  case FMT_NV12: return "opengl-nv12";
1028  default: break;
1029  }
1030  return "opengl";
1031 }
1032 
1033 QOpenGLFramebufferObject* MythOpenGLVideo::CreateVideoFrameBuffer(VideoFrameType OutputType, QSize Size)
1034 {
1035  // Use a 16bit float framebuffer if necessary and available (not GLES2) to maintain precision.
1036  // The depth check will pick up all software formats as well as NVDEC, VideoToolBox and VAAPI DRM.
1037  // VAAPI GLXPixmap and GLXCopy are currently not 10/12bit aware and VDPAU has no 10bit support -
1038  // and all return RGB formats anyway. The MediaCodec texture format is an unknown but resizing will
1039  // never be enabled as it returns an RGB frame - so if MediaCodec uses a 16bit texture, precision
1040  // will be preserved.
1041  bool sixteenbitfb = m_extraFeatures & kGL16BitFBO;
1042  bool sixteenbitvid = MythVideoFrame::ColorDepth(OutputType) > 8;
1043  if (sixteenbitfb && sixteenbitvid)
1044  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Requesting 16bit framebuffer texture");
1045  return m_openglRender->CreateFramebuffer(Size, sixteenbitfb && sixteenbitvid);
1046 }
FMT_MEDIACODEC
@ FMT_MEDIACODEC
Definition: mythframe.h:56
MythOpenGLVideo::m_toneMap
MythOpenGLTonemap * m_toneMap
Definition: mythopenglvideo.h:84
DEINT_DRIVER
@ DEINT_DRIVER
Definition: mythframe.h:70
tv.h
MythVideoGPU::m_discontinuityCounter
uint64_t m_discontinuityCounter
Definition: mythvideogpu.h:65
MythOpenGLVideo::m_gles
int m_gles
Definition: mythopenglvideo.h:71
MythGLTexture
Definition: mythrenderopengl.h:57
DEINT_MEDIUM
@ DEINT_MEDIUM
Definition: mythframe.h:66
MythVideoTexture::UpdateTextures
static void UpdateTextures(MythRenderOpenGL *Context, const MythVideoFrame *Frame, const std::vector< MythVideoTexture * > &Textures)
Update the contents of the given Textures for data held in Frame.
Definition: mythvideotexture.cpp:281
MythVideoGPU::m_lastStereo
uint m_lastStereo
Definition: mythvideogpu.h:82
MythVideoGPU::m_inputTextureSize
QSize m_inputTextureSize
Definition: mythvideogpu.h:75
MythVideoGPU::Sampling
@ Sampling
Definition: mythvideogpu.h:24
MythOpenGLVideo::CreateVideoFrameBuffer
QOpenGLFramebufferObject * CreateVideoFrameBuffer(VideoFrameType OutputType, QSize Size)
Definition: mythopenglvideo.cpp:1033
MythOpenGLVideo::InterlacedTop
@ InterlacedTop
Definition: mythopenglvideo.h:33
MythVideoTexture::CreateTextures
static std::vector< MythVideoTexture * > 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: mythvideotexture.cpp:57
MythOpenGLVideo::m_prevTextures
vector< MythVideoTexture * > m_prevTextures
Definition: mythopenglvideo.h:76
MythRenderOpenGL::DeleteFramebuffer
void DeleteFramebuffer(QOpenGLFramebufferObject *Framebuffer)
Definition: mythrenderopengl.cpp:772
MythVideoTexture::SetTextureFilters
static void SetTextureFilters(MythRenderOpenGL *Context, const std::vector< MythVideoTexture * > &Textures, QOpenGLTexture::Filter Filter, QOpenGLTexture::WrapMode Wrap=QOpenGLTexture::ClampToEdge)
Definition: mythvideotexture.cpp:40
DEINT_SHADER
@ DEINT_SHADER
Definition: mythframe.h:69
MythVideoFrame::HardwareFramesFormat
static bool HardwareFramesFormat(VideoFrameType Type)
Definition: mythframe.h:416
FMT_DRMPRIME
@ FMT_DRMPRIME
Definition: mythframe.h:59
MythVideoGPU::m_lastRotation
int m_lastRotation
Definition: mythvideogpu.h:77
MythOpenGLVideo::ResetTextures
void ResetTextures() override
Clear reference frames after a seek as they will contain old images.
Definition: mythopenglvideo.cpp:981
MythVideoGPU::m_resizing
VideoResizing m_resizing
Definition: mythvideogpu.h:76
Frame
Definition: zmdefines.h:94
MythVideoColourSpace::UpdateColourSpace
bool UpdateColourSpace(const MythVideoFrame *Frame)
Set the current colourspace to use.
Definition: mythvideocolourspace.cpp:329
MythRenderOpenGL::logDebugMarker
void logDebugMarker(const QString &Message)
Definition: mythrenderopengl.cpp:193
DEINT_NONE
@ DEINT_NONE
Definition: mythframe.h:64
MythVideoGPU::m_videoColourSpace
MythVideoColourSpace * m_videoColourSpace
Definition: mythvideogpu.h:74
MythOpenGLVideo::~MythOpenGLVideo
~MythOpenGLVideo() override
Definition: mythopenglvideo.cpp:60
arg
arg(title).arg(filename).arg(doDelete))
FrameScanType
FrameScanType
Definition: videoouttypes.h:95
FramePitches
std::array< int, 3 > FramePitches
Definition: mythframe.h:79
LOC
#define LOC
Definition: mythopenglvideo.cpp:21
MythRenderOpenGL::DrawBitmap
void DrawBitmap(MythGLTexture *Texture, QOpenGLFramebufferObject *Target, QRect Source, QRect Destination, QOpenGLShaderProgram *Program, int Alpha=255, qreal Scale=1.0)
Definition: mythrenderopengl.cpp:809
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
MythOpenGLVideo::m_frameBufferTexture
MythVideoTexture * m_frameBufferTexture
Definition: mythopenglvideo.h:79
MythVideoFrame::HardwareFormat
static bool HardwareFormat(VideoFrameType Type)
Definition: mythframe.h:408
MythVideoGPU::ToneMap
@ ToneMap
Definition: mythvideogpu.h:27
MythOpenGLVideo::PrepareFrame
void PrepareFrame(MythVideoFrame *Frame, FrameScanType Scan=kScan_Progressive) override
Update the current input texture using the data from the given video frame.
Definition: mythopenglvideo.cpp:543
FrameOffsets
std::array< int, 3 > FrameOffsets
Definition: mythframe.h:80
MythVideoFrame::FormatIs422
static bool FormatIs422(VideoFrameType Type)
Definition: mythframe.h:427
MythVideoGPU::m_videoDim
QSize m_videoDim
Definition: mythvideogpu.h:70
mythopenglvideoshaders.h
MythOpenGLVideo::SetupFrameFormat
bool SetupFrameFormat(VideoFrameType InputType, VideoFrameType OutputType, QSize Size, GLenum TextureTarget)
Definition: mythopenglvideo.cpp:465
MythRenderOpenGL::CreateFramebufferTexture
MythGLTexture * CreateFramebufferTexture(QOpenGLFramebufferObject *Framebuffer)
Definition: mythrenderopengl.cpp:760
mythopenglvideo.h
MythDate::current
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:10
MythRenderOpenGL::GetFeatures
QOpenGLFunctions::OpenGLFeatures GetFeatures(void) const
Definition: mythrenderopengl.cpp:466
MythOpenGLVideo::m_fallbackDeinterlacer
MythDeintType m_fallbackDeinterlacer
Definition: mythopenglvideo.h:72
MythRenderOpenGL::SetShaderProgramParams
void SetShaderProgramParams(QOpenGLShaderProgram *Program, const QMatrix4x4 &Value, const char *Uniform)
Definition: mythrenderopengl.cpp:1620
MythOpenGLVideo::m_frameBuffer
QOpenGLFramebufferObject * m_frameBuffer
Definition: mythopenglvideo.h:78
FMT_NONE
@ FMT_NONE
Definition: mythframe.h:17
MythVideoGPU
Definition: mythvideogpu.h:16
GL_TEXTURE_EXTERNAL_OES
#define GL_TEXTURE_EXTERNAL_OES
Definition: mythrenderopengldefs.h:13
MythOpenGLTonemap::Map
MythVideoTexture * Map(std::vector< MythVideoTexture * > &Inputs, QSize DisplaySize)
Definition: mythopengltonemap.cpp:74
DEINT_CPU
@ DEINT_CPU
Definition: mythframe.h:68
MythOpenGLInterop::Retrieve
static vector< MythVideoTexture * > Retrieve(MythRenderOpenGL *Context, MythVideoColourSpace *ColourSpace, MythVideoFrame *Frame, FrameScanType Scan)
Definition: mythopenglinterop.cpp:162
MythOpenGLVideo::BindTextures
void BindTextures(bool Deinterlacing, vector< MythVideoTexture * > &Current, vector< MythGLTexture * > &Textures)
Definition: mythopenglvideo.cpp:991
MythOpenGLVideo::MythOpenGLVideo
MythOpenGLVideo(MythRenderOpenGL *Render, MythVideoColourSpace *ColourSpace, MythVideoBounds *Bounds, const QString &Profile)
Definition: mythopenglvideo.cpp:34
MythVideoColourSpace::GetColourMappingDefines
QStringList GetColourMappingDefines(void)
Definition: mythvideocolourspace.cpp:449
mythrenderopengl.h
MythVideoFrame::YUVFormat
static bool YUVFormat(VideoFrameType Type)
Definition: mythframe.h:449
MythOpenGLVideo::m_features
QOpenGLFunctions::OpenGLFeatures m_features
Definition: mythopenglvideo.h:80
MythOpenGLTonemap::GetTexture
MythVideoTexture * GetTexture(void)
Definition: mythopengltonemap.cpp:69
kScan_Intr2ndField
@ kScan_Intr2ndField
Definition: videoouttypes.h:99
MythVideoGPU::m_profile
QString m_profile
Definition: mythvideogpu.h:66
kGL16BitFBO
@ kGL16BitFBO
Definition: mythrenderopengl.h:49
MythOpenGLVideo::ColourSpaceUpdate
void ColourSpaceUpdate(bool PrimariesChanged) override
Definition: mythopenglvideo.cpp:71
MythOpenGLVideo::m_openglRender
MythRenderOpenGL * m_openglRender
Definition: mythopenglvideo.h:70
MythOpenGLVideo::InterlacedBot
@ InterlacedBot
Definition: mythopenglvideo.h:34
MythRenderOpenGL::DrawRect
void DrawRect(QOpenGLFramebufferObject *Target, QRect Area, const QBrush &FillBrush, const QPen &LinePen, int Alpha)
Definition: mythrenderopengl.cpp:955
MythVideoGPU::m_videoDispDim
QSize m_videoDispDim
Definition: mythvideogpu.h:69
mythopengltonemap.h
FMT_YV12
@ FMT_YV12
Definition: mythframe.h:19
MythOpenGLVideo::TypeToProfile
static QString TypeToProfile(VideoFrameType Type)
Definition: mythopenglvideo.cpp:1018
MythOpenGLVideo::RenderFrame
void RenderFrame(MythVideoFrame *Frame, bool TopFieldFirst, FrameScanType Scan, StereoscopicMode StereoOverride, bool DrawBorder=false) override
Definition: mythopenglvideo.cpp:642
MythOpenGLVideo::m_chromaUpsamplingFilter
bool m_chromaUpsamplingFilter
Definition: mythopenglvideo.h:83
MythOpenGLVideo::m_textureTarget
GLenum m_textureTarget
Definition: mythopenglvideo.h:82
MythOpenGLVideo::AddDeinterlacer
bool AddDeinterlacer(const MythVideoFrame *Frame, FrameScanType Scan, MythDeintType Filter=DEINT_SHADER, bool CreateReferences=true)
Definition: mythopenglvideo.cpp:152
MythVideoColourSpace::GetColourGamma
float GetColourGamma(void) const
Definition: mythvideocolourspace.cpp:474
GLSL300VertexShader
static const QString GLSL300VertexShader
Definition: mythopenglvideoshaders.h:244
MythOpenGLVideo::Progressive
@ Progressive
Definition: mythopenglvideo.h:32
MythVideoGPU::VideoResizeToString
static QString VideoResizeToString(VideoResizing Resize)
Definition: mythvideogpu.cpp:90
MythRenderOpenGL::makeCurrent
void makeCurrent()
Definition: mythrenderopengl.cpp:564
MythVideoFrame::ColorDepth
static int ColorDepth(int Format)
Definition: mythframe.h:382
MythRenderOpenGL::DeleteTexture
void DeleteTexture(MythGLTexture *Texture)
Definition: mythrenderopengl.cpp:714
GLSL300YUVFragmentExtensions
static const QString GLSL300YUVFragmentExtensions
Definition: mythopenglvideoshaders.h:255
MythVideoGPU::m_deinterlacer
MythDeintType m_deinterlacer
Definition: mythvideogpu.h:78
MythOpenGLVideo::m_inputTextures
vector< MythVideoTexture * > m_inputTextures
Definition: mythopenglvideo.h:75
kStereoscopicModeTopAndBottomDiscard
@ kStereoscopicModeTopAndBottomDiscard
Definition: videoouttypes.h:139
MythOpenGLVideo::UpdateShaderParameters
void UpdateShaderParameters()
Definition: mythopenglvideo.cpp:97
MythRenderOpenGL::GetExtraFeatures
int GetExtraFeatures(void) const
Definition: mythrenderopengl.cpp:461
MythVideoGPU::m_outputType
VideoFrameType m_outputType
Definition: mythvideogpu.h:68
MythVideoColourSpace::GetDisplayGamma
float GetDisplayGamma(void) const
Definition: mythvideocolourspace.cpp:479
MythRenderOpenGL::DeleteShaderProgram
void DeleteShaderProgram(QOpenGLShaderProgram *Program)
Definition: mythrenderopengl.cpp:1586
MythOpenGLVideo::CleanupDeinterlacers
void CleanupDeinterlacers()
Definition: mythopenglvideo.cpp:130
uint
unsigned int uint
Definition: compat.h:141
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:60
MythVideoGPU::m_videoRect
QRect m_videoRect
Definition: mythvideogpu.h:73
kStereoscopicModeAuto
@ kStereoscopicModeAuto
Definition: videoouttypes.h:136
MythVideoGPU::Deinterlacer
@ Deinterlacer
Definition: mythvideogpu.h:23
MythVideoGPU::OutputChanged
void OutputChanged(QSize VideoDim, QSize VideoDispDim, float)
MythOpenGLVideo::VideoShaderType
VideoShaderType
Definition: mythopenglvideo.h:30
MythVideoGPU::m_stereoMode
StereoscopicMode m_stereoMode
Definition: mythvideogpu.h:83
MythVideoBounds
Definition: mythvideobounds.h:24
MythVideoFrame::FormatIs444
static bool FormatIs444(VideoFrameType Type)
Definition: mythframe.h:433
StereoscopicMode
StereoscopicMode
Definition: videoouttypes.h:135
MythCoreContext::GetBoolSetting
bool GetBoolSetting(const QString &key, bool defaultval=false)
Definition: mythcorecontext.cpp:927
MythRenderOpenGL::doneCurrent
void doneCurrent()
Definition: mythrenderopengl.cpp:572
MythVideoGPU::m_displayVideoRect
QRect m_displayVideoRect
Definition: mythvideogpu.h:72
MythRenderOpenGL::GetMaxTextureUnits
int GetMaxTextureUnits(void) const
Definition: mythrenderopengl.cpp:456
MythVideoFrame::FormatIs420
static bool FormatIs420(VideoFrameType Type)
Definition: mythframe.h:421
MythRenderOpenGL
Definition: mythrenderopengl.h:99
MythOpenGLVideo::Default
@ Default
Definition: mythopenglvideo.h:31
MythDeintType
MythDeintType
Definition: mythframe.h:63
MythOpenGLVideo::ShaderCount
@ ShaderCount
Definition: mythopenglvideo.h:35
VERBOSE_LEVEL_CHECK
#define VERBOSE_LEVEL_CHECK(_MASK_, _LEVEL_)
Definition: mythlogging.h:14
MythOpenGLVideo::m_shaders
std::array< QOpenGLShaderProgram *, ShaderCount > m_shaders
Definition: mythopenglvideo.h:73
MythRenderOpenGL::BindFramebuffer
void BindFramebuffer(QOpenGLFramebufferObject *Framebuffer)
Definition: mythrenderopengl.cpp:782
MythVideoFrame::FormatDescription
static QString FormatDescription(VideoFrameType Type)
Definition: mythframe.cpp:363
MythOpenGLVideo::CreateVideoShader
bool CreateVideoShader(VideoShaderType Type, MythDeintType Deint=DEINT_NONE)
Create the appropriate shader for the operation Type.
Definition: mythopenglvideo.cpp:293
kScan_Interlaced
@ kScan_Interlaced
Definition: videoouttypes.h:98
FMT_YUY2
@ FMT_YUY2
Definition: mythframe.h:46
YUVFragmentExtensions
static const QString YUVFragmentExtensions
Definition: mythopenglvideoshaders.h:41
MythVideoFrame::DeinterlacerName
static QString DeinterlacerName(MythDeintType Deint, bool DoubleRate, VideoFrameType Format=FMT_NONE)
Definition: mythframe.cpp:457
DEINT_HIGH
@ DEINT_HIGH
Definition: mythframe.h:67
mythavutil.h
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
mythcontext.h
MythVideoFrame::GetNumPlanes
static uint GetNumPlanes(VideoFrameType Type)
Definition: mythframe.h:197
MythVideoColourSpace::GetPrimaryMatrix
QMatrix4x4 GetPrimaryMatrix(void)
Definition: mythvideocolourspace.cpp:469
MythVideoGPU::m_valid
bool m_valid
Definition: mythvideogpu.h:80
DefaultVertexShader
static const QString DefaultVertexShader
Definition: mythopenglvideoshaders.h:6
YUVFragmentShader
static const QString YUVFragmentShader
Definition: mythopenglvideoshaders.h:56
MythVideoGPU::ResetFrameFormat
virtual void ResetFrameFormat()
Definition: mythvideogpu.cpp:80
VideoFrameType
VideoFrameType
Definition: mythframe.h:16
MythVideoGPU::UpdateColourSpace
void UpdateColourSpace(bool PrimariesChanged)
Definition: mythvideogpu.cpp:50
MythRenderOpenGL::SetViewPort
void SetViewPort(QRect Rect, bool ViewportOnly=false) override
Definition: mythrenderopengl.cpp:582
MythOpenGLVideo::m_extraFeatures
int m_extraFeatures
Definition: mythopenglvideo.h:81
MythOpenGLVideo::m_nextTextures
vector< MythVideoTexture * > m_nextTextures
Definition: mythopenglvideo.h:77
MythVideoGPU::m_deinterlacer2x
bool m_deinterlacer2x
Definition: mythvideogpu.h:79
MythVideoGPU::None
@ None
Definition: mythvideogpu.h:22
MythVideoFrame
Definition: mythframe.h:83
RGBFragmentShader
static const QString RGBFragmentShader
Definition: mythopenglvideoshaders.h:17
FMT_NV12
@ FMT_NV12
Definition: mythframe.h:48
DEINT_BASIC
@ DEINT_BASIC
Definition: mythframe.h:65
MythVideoTexture
Definition: mythvideotexture.h:20
MythVideoGPU::m_masterViewportSize
QSize m_masterViewportSize
Definition: mythvideogpu.h:71
is_interlaced
bool is_interlaced(FrameScanType Scan)
Definition: videoouttypes.h:188
MythVideoFrame::FormatIsNV12
static bool FormatIsNV12(VideoFrameType Type)
Definition: mythframe.h:439
MythOpenGLVideo::m_shaderCost
std::array< int, ShaderCount > m_shaderCost
Definition: mythopenglvideo.h:74
kStereoscopicModeSideBySideDiscard
@ kStereoscopicModeSideBySideDiscard
Definition: videoouttypes.h:138
kGLTiled
@ kGLTiled
Definition: mythrenderopengl.h:46
MythVideoColourSpace
MythVideoColourSpace contains a QMatrix4x4 that can convert YCbCr data to RGB.
Definition: mythvideocolourspace.h:21
MythVideoGPU::m_inputType
VideoFrameType m_inputType
Definition: mythvideogpu.h:67
MythVideoTexture::DeleteTextures
static void DeleteTextures(MythRenderOpenGL *Context, std::vector< MythVideoTexture * > &Textures)
Definition: mythvideotexture.cpp:31
GLSL300YUVFragmentShader
static const QString GLSL300YUVFragmentShader
Definition: mythopenglvideoshaders.h:262
find
static pid_list_t::iterator find(const PIDInfoMap &map, pid_list_t &list, pid_list_t::iterator begin, pid_list_t::iterator end, bool find_open)
Definition: dvbstreamhandler.cpp:356
MythVideoGPU::Performance
@ Performance
Definition: mythvideogpu.h:25
MythRenderOpenGL::CreateShaderProgram
QOpenGLShaderProgram * CreateShaderProgram(const QString &Vertex, const QString &Fragment)
Definition: mythrenderopengl.cpp:1537
MythRenderOpenGL::EnableShaderProgram
bool EnableShaderProgram(QOpenGLShaderProgram *Program)
Definition: mythrenderopengl.cpp:1596
FMT_RGBA32
@ FMT_RGBA32
Definition: mythframe.h:30
MythOpenGLVideo::GetProfile
QString GetProfile() const override
Definition: mythopenglvideo.cpp:123
MythOpenGLVideo::ResetFrameFormat
void ResetFrameFormat() override
Definition: mythopenglvideo.cpp:522
MythVideoGPU::Framebuffer
@ Framebuffer
Definition: mythvideogpu.h:26
OpenGLLocker
Definition: mythrenderopengl.h:255