Guest User

Untitled

a guest
Dec 12th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.88 KB | None | 0 0
  1. diff --git a/mythtv/libs/libmythtv/openglvideo.cpp b/mythtv/libs/libmythtv/openglvideo.cpp
  2. index 33a5ea0582..f978362ea2 100644
  3. --- a/mythtv/libs/libmythtv/openglvideo.cpp
  4. +++ b/mythtv/libs/libmythtv/openglvideo.cpp
  5. @@ -291,6 +291,7 @@ bool OpenGLVideo::Init(MythRenderOpenGL *glcontext, VideoColourSpace *colourspac
  6. LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("MMX: %1 PBO: %2")
  7. .arg(mmx).arg((gl_features & kGLExtPBufObj) > 0));
  8.  
  9. + DebugFilterChain();
  10. return true;
  11. }
  12.  
  13. @@ -462,7 +463,7 @@ bool OpenGLVideo::AddFilter(OpenGLFilterType filter)
  14. break;
  15.  
  16. case kGLFilterBicubic:
  17. - if (!(gl_features & kGLExtFragProg) || !(gl_features & kGLExtFBufObj))
  18. + if ((!(gl_features & kGLExtFragProg) && !(gl_features & kGLSL)) || !(gl_features & kGLExtFBufObj))
  19. {
  20. LOG(VB_PLAYBACK, LOG_ERR, LOC +
  21. "Features not available for bicubic filter.");
  22. @@ -506,7 +507,10 @@ bool OpenGLVideo::AddFilter(OpenGLFilterType filter)
  23.  
  24. helperTexture = gl_context->CreateHelperTexture();
  25. if (!helperTexture)
  26. + {
  27. + LOG(VB_GENERAL, LOG_ERR, "Failed to create bicubic helper texture");
  28. success = false;
  29. + }
  30. }
  31.  
  32. if (success &&
  33. @@ -801,7 +805,7 @@ uint OpenGLVideo::CreateVideoTexture(QSize size, QSize &tex_size)
  34.  
  35. QSize OpenGLVideo::GetTextureSize(const QSize &size)
  36. {
  37. - if (textureRects)
  38. + if (!textureParametric)
  39. return size;
  40.  
  41. int w = 64;
  42. @@ -978,7 +982,7 @@ void OpenGLVideo::PrepareFrame(bool topfieldfirst, FrameScanType scan,
  43. video_rect.left() + video_rect.width(),
  44. video_rect.top() + video_rect.height());
  45.  
  46. - if (!textureRects && (inputsize.height() > 0))
  47. + if (textureParametric && (inputsize.height() > 0))
  48. trueheight /= inputsize.height();
  49.  
  50. // software bobdeint
  51. @@ -1426,9 +1430,9 @@ QString OpenGLVideo::GetProgramString(OpenGLFilterType name,
  52.  
  53. void OpenGLVideo::CustomiseProgramString(QString &string)
  54. {
  55. - string.replace("%1", textureRects ? "RECT" : "2D");
  56. + string.replace("%1", (textureRects && !textureParametric) ? "RECT" : "2D");
  57.  
  58. - if (!textureRects)
  59. + if (textureParametric)
  60. {
  61. string.replace("GLSL_SAMPLER", "sampler2D");
  62. string.replace("GLSL_TEXTURE", "texture2D");
  63. @@ -1439,7 +1443,7 @@ void OpenGLVideo::CustomiseProgramString(QString &string)
  64. float yselect = 1.0f;
  65. QSize fb_size = GetTextureSize(video_disp_dim);
  66.  
  67. - if (!textureRects &&
  68. + if (textureParametric &&
  69. (inputTextureSize.height() > 0))
  70. {
  71. lineHeight /= inputTextureSize.height();
  72. @@ -1878,3 +1882,136 @@ void OpenGLVideo::GetProgramStrings(QString &vertex, QString &fragment,
  73. CustomiseProgramString(vertex);
  74. CustomiseProgramString(fragment);
  75. }
  76. +
  77. +QString OpenGLVideo::TextureInfo(uint Type, QSize Size)
  78. +{
  79. + QString typestr = "Unknown";
  80. + uint data_type = GL_UNSIGNED_BYTE;
  81. + QSize size(Size);
  82. + switch (Type)
  83. + {
  84. + case GL_RGBA: typestr = "GL_RGBA"; break;
  85. + case GL_BGRA: typestr = "GL_BGRA"; break;
  86. + case GL_YCBCR_MESA: typestr = "GL_YCBCR_MESA"; break;
  87. + case GL_YCBCR_422_APPLE: typestr = "GL_YCBCR_422_APPLE"; break;
  88. + case MYTHTV_YV12: typestr = "Mythtv YV12"; break;
  89. + case MYTHTV_UYVY: typestr = "UYVY (YUV422)"; break;
  90. + default: break;
  91. + }
  92. +
  93. + return QString("%1 (%2x%3: %4 bytes)")
  94. + .arg(typestr).arg(size.width()).arg(size.height()).arg(MythRenderOpenGL::GetBufferSize(size, Type, data_type));
  95. +}
  96. +
  97. +void OpenGLVideo::DebugFilterChain(void)
  98. +{
  99. + LOG(VB_GENERAL, LOG_INFO, "------------ OpenGLVideo Filter stages ------------");
  100. + QString cpuload = "High - software YUV to RGB conversion";
  101. + QSize inputtexturesize(video_dim);
  102. +
  103. + if (GL_RGBA == videoTextureType)
  104. + {
  105. + cpuload = "None";
  106. + LOG(VB_GENERAL, LOG_INFO, QString("GPU accceleration\t\t: Video frame already in GPU memory"));
  107. + }
  108. + else
  109. + {
  110. + cpuload = "Medium - repack from planar to packed format";
  111. + LOG(VB_GENERAL, LOG_INFO, QString("Main memory video frame\t: %1")
  112. + .arg(QString("YV12/YV420P (%1x%2: %3 bytes)").arg(video_dim.width()).arg(video_dim.height()).arg(video_dim.width() * video_dim.height() * 3 / 2)));
  113. +
  114. + if (MYTHTV_UYVY == videoTextureType || GL_YCBCR_422_APPLE == videoTextureType || GL_YCBCR_MESA == videoTextureType)
  115. + {
  116. + if (gl_features & kGLExtPBufObj)
  117. + {
  118. + LOG(VB_GENERAL, LOG_INFO, QString("Main memory to GPU\t\t: Packed with FFmpeg directly to %1").arg(TextureInfo(videoTextureType, inputTextureSize)));
  119. + LOG(VB_GENERAL, LOG_INFO, QString("\t\t\t\t in GPU memory (PixelBufferObject support)"));
  120. + }
  121. + else
  122. + {
  123. + LOG(VB_GENERAL, LOG_INFO, QString("Main memory processing\t : Packed using FFmpeg to %1").arg(TextureInfo(videoTextureType, video_dim)));
  124. + LOG(VB_GENERAL, LOG_INFO, QString("Main memory to GPU\t: Uploaded to GPU with standard glTexSubImage2D"));
  125. + }
  126. +
  127. + if (MYTHTV_UYVY == videoTextureType)
  128. + inputtexturesize.setWidth(video_dim.width() >> 1);
  129. + }
  130. + else if (MYTHTV_YV12 == videoTextureType)
  131. + {
  132. + cpuload = "Low - no repacking/conversion";
  133. + if (gl_features & kGLExtPBufObj)
  134. + LOG(VB_GENERAL, LOG_INFO, QString("Main memory to GPU\t\t: Simple copy direct to GPU memory (PixelBufferObject support)"));
  135. + else
  136. + LOG(VB_GENERAL, LOG_INFO, QString("Main memory to GPU\t: Uploaded to GPU with standard glTexSubImage2D"));
  137. + }
  138. + else if (GL_BGRA == videoTextureType) // no custom texturing
  139. + {
  140. +#ifdef MMX
  141. + cpuload = "Medium - MMX assisted repack to packed format";
  142. + if (gl_features & kGLExtPBufObj)
  143. + {
  144. + LOG(VB_GENERAL, LOG_INFO, QString("Main memory to GPU\t\t: Packed with MMX directly to %1").arg(TextureInfo(videoTextureType, inputTextureSize)));
  145. + LOG(VB_GENERAL, LOG_INFO, QString("\t\t\t\t in GPU memory (PixelBufferObject support) (No YUV to RGB conversion)"));
  146. + }
  147. + else
  148. + {
  149. + LOG(VB_GENERAL, LOG_INFO, QString("Main memory processing\t : Packed with MMX to %1 (NO YUV to RGB conversion)").arg(TextureInfo(videoTextureType, video_dim)));
  150. + LOG(VB_GENERAL, LOG_INFO, QString("Main memory to GPU\t: Uploaded to GPU with standard glTexSubImage2D"));
  151. + }
  152. +#else
  153. + cpuload = "Medium to high - plain 'C' used to repack. No CPU architecture support";
  154. + if (gl_features & kGLExtPBufObj)
  155. + {
  156. + LOG(VB_GENERAL, LOG_INFO, QString("Main memory to GPU\t\t: Packed usinf 'C' code directly to %1").arg(TextureInfo(videoTextureType, inputTextureSize)));
  157. + LOG(VB_GENERAL, LOG_INFO, QString("\t\t\t\t in GPU memory (PixelBufferObject support) (NO YUV to RGB conversion)"));
  158. + }
  159. + else
  160. + {
  161. + LOG(VB_GENERAL, LOG_INFO, QString("Main memory processing\t : Packed using 'C' code to %1 (NO YUV to RGB conversion)").arg(TextureInfo(videoTextureType, video_dim)));
  162. + LOG(VB_GENERAL, LOG_INFO, QString("Main memory to GPU\t: Uploaded to GPU with standard glTexSubImage2D"));
  163. + }
  164. +#endif
  165. + }
  166. + else //
  167. + { /* software RGB to YUV conversion is broken... */ }
  168. + }
  169. +
  170. + QString source = TextureInfo(GL_RGBA == videoTextureType ? GL_RGBA : GL_BGRA, inputtexturesize);
  171. + LOG(VB_GENERAL, LOG_INFO, QString("GPU unpacked texture \t: %1").arg(source));
  172. +
  173. + // GPU stages
  174. + source = "Tex " + source;
  175. + uint fboswitches = 0;
  176. + glfilt_map_t::iterator it;
  177. + for (it = filters.begin(); it != filters.end(); ++it)
  178. + {
  179. + if (it != filters.begin())
  180. + fboswitches++;
  181. +
  182. + OpenGLFilterType type = it->first;
  183. + OpenGLFilter *filter = it->second;
  184. +
  185. + QString filt;
  186. + switch (type)
  187. + {
  188. + case kGLFilterNone: filt = "None"; break;
  189. + case kGLFilterResize: filt = "Resize"; break;
  190. + case kGLFilterBicubic: filt = "Bicubic upsize"; break;
  191. + case kGLFilterYUV2RGB: filt = "YUV2 to RGB"; break;
  192. + case kGLFilterYV12RGB: filt = "YV12 to RGB"; break;
  193. + }
  194. +
  195. + QString dest = QString("FBO %1").arg(TextureInfo(GL_RGBA, frameBufferRect.size()));
  196. + if (filter->outputBuffer == kDefaultBuffer)
  197. + dest = QString("Screen %1x%2").arg(display_visible_rect.width()).arg(display_visible_rect.height());
  198. + LOG(VB_GENERAL, LOG_INFO, QString("Source: %1\t Dest: %2\t Filter: %3")
  199. + .arg(source).arg(dest).arg(filt));
  200. +
  201. + source = dest;
  202. + }
  203. +
  204. + LOG(VB_GENERAL, LOG_INFO, QString("Analysis"));
  205. + LOG(VB_GENERAL, LOG_INFO, QString("CPU usage\t\t\t: ") + cpuload);
  206. + LOG(VB_GENERAL, LOG_INFO, QString("Framebuffer switches\t: %1").arg(fboswitches));
  207. + LOG(VB_GENERAL, LOG_INFO, "------------ ------------------------- ------------");
  208. +}
  209. diff --git a/mythtv/libs/libmythtv/openglvideo.h b/mythtv/libs/libmythtv/openglvideo.h
  210. index 08dfb3daf4..cd42a4793e 100644
  211. --- a/mythtv/libs/libmythtv/openglvideo.h
  212. +++ b/mythtv/libs/libmythtv/openglvideo.h
  213. @@ -98,6 +98,8 @@ class OpenGLVideo
  214. void SetTextureFilters(vector<GLuint> *textures, int filt, int clamp);
  215. void DeleteTextures(vector<GLuint> *textures);
  216. void TearDownDeinterlacer(void);
  217. + QString TextureInfo(uint Type, QSize Size);
  218. + void DebugFilterChain(void);
  219.  
  220. MythRenderOpenGL *gl_context;
  221. QSize video_disp_dim;
  222. @@ -122,6 +124,7 @@ class OpenGLVideo
  223. bool inputUpdated;
  224. int refsNeeded;
  225. bool textureRects;
  226. + bool textureParametric;
  227. uint textureType;
  228. uint helperTexture;
  229. OpenGLFilterType defaultUpsize;
Add Comment
Please, Sign In to add comment