2 * Copyright (C) 2010-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
20 //#define DEBUG_VERBOSE 1
23 #if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
28 #include "system_gl.h"
31 #include "guilib/MatrixGLES.h"
32 #include "LinuxRendererGLES.h"
33 #include "utils/fastmemcpy.h"
34 #include "utils/MathUtils.h"
35 #include "utils/GLUtils.h"
36 #include "settings/AdvancedSettings.h"
37 #include "settings/DisplaySettings.h"
38 #include "settings/MediaSettings.h"
39 #include "settings/Settings.h"
40 #include "guilib/FrameBufferObject.h"
41 #include "VideoShaders/YUV2RGBShader.h"
42 #include "VideoShaders/VideoFilterShader.h"
43 #include "windowing/WindowingFactory.h"
44 #include "dialogs/GUIDialogKaiToast.h"
45 #include "guilib/Texture.h"
46 #include "lib/DllSwScale.h"
47 #include "../dvdplayer/DVDCodecs/Video/OpenMaxVideo.h"
48 #include "threads/SingleLock.h"
49 #include "RenderCapture.h"
50 #include "RenderFormats.h"
51 #include "xbmc/Application.h"
52 #include "cores/IPlayer.h"
54 #if defined(__ARM_NEON__)
55 #include "yuv2rgb.neon.h"
56 #include "utils/CPUInfo.h"
58 #ifdef HAVE_VIDEOTOOLBOXDECODER
59 #include "DVDCodecs/Video/DVDVideoCodecVideoToolBox.h"
60 #include <CoreVideo/CoreVideo.h>
62 #ifdef TARGET_DARWIN_IOS
63 #include "osx/DarwinUtils.h"
65 #if defined(HAS_LIBSTAGEFRIGHT)
67 #include <EGL/eglext.h>
68 #include "windowing/egl/EGLWrapper.h"
69 #include "android/activity/XBMCApp.h"
70 #include "DVDCodecs/Video/StageFrightVideo.h"
72 // EGL extension functions
73 static PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR;
74 static PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR;
75 static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES;
78 using namespace Shaders;
80 CLinuxRendererGLES::YUVBUFFER::YUVBUFFER()
82 memset(&fields, 0, sizeof(fields));
83 memset(&image , 0, sizeof(image));
85 #ifdef HAVE_LIBOPENMAX
88 #ifdef HAVE_VIDEOTOOLBOXDECODER
91 #ifdef HAS_LIBSTAGEFRIGHT
93 eglimg = EGL_NO_IMAGE_KHR;
97 CLinuxRendererGLES::YUVBUFFER::~YUVBUFFER()
101 CLinuxRendererGLES::CLinuxRendererGLES()
103 m_textureTarget = GL_TEXTURE_2D;
105 m_renderMethod = RENDER_GLSL;
106 m_oldRenderMethod = m_renderMethod;
107 m_renderQuality = RQ_SINGLEPASS;
109 m_format = RENDER_FMT_NONE;
111 m_iYV12RenderBuffer = 0;
113 m_currentField = FIELD_FULL;
116 m_pVideoFilterShader = NULL;
117 m_scalingMethod = VS_SCALINGMETHOD_LINEAR;
118 m_scalingMethodGui = (ESCALINGMETHOD)-1;
120 // default texture handlers to YUV
121 m_textureUpload = &CLinuxRendererGLES::UploadYV12Texture;
122 m_textureCreate = &CLinuxRendererGLES::CreateYV12Texture;
123 m_textureDelete = &CLinuxRendererGLES::DeleteYV12Texture;
128 m_dllSwScale = new DllSwScale;
130 m_NumYV12Buffers = 0;
131 m_iLastRenderBuffer = 0;
132 m_bConfigured = false;
133 m_bValidated = false;
134 m_bImageReady = false;
135 m_StrictBinding = false;
136 m_clearColour = 0.0f;
138 #ifdef HAS_LIBSTAGEFRIGHT
139 if (!eglCreateImageKHR)
140 eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC) CEGLWrapper::GetProcAddress("eglCreateImageKHR");
141 if (!eglDestroyImageKHR)
142 eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC) CEGLWrapper::GetProcAddress("eglDestroyImageKHR");
143 if (!glEGLImageTargetTexture2DOES)
144 glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) CEGLWrapper::GetProcAddress("glEGLImageTargetTexture2DOES");
148 CLinuxRendererGLES::~CLinuxRendererGLES()
152 if (m_rgbBuffer != NULL) {
153 delete [] m_rgbBuffer;
159 m_pYUVShader->Free();
167 bool CLinuxRendererGLES::ValidateRenderTarget()
171 CLog::Log(LOGNOTICE,"Using GL_TEXTURE_2D");
173 // create the yuv textures
176 for (int i = 0 ; i < m_NumYV12Buffers ; i++)
177 (this->*m_textureCreate)(i);
185 bool CLinuxRendererGLES::Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, ERenderFormat format, unsigned extended_format, unsigned int orientation)
187 m_sourceWidth = width;
188 m_sourceHeight = height;
189 m_renderOrientation = orientation;
195 // Calculate the input frame aspect ratio.
196 CalculateFrameAspectRatio(d_width, d_height);
197 ChooseBestResolution(fps);
198 SetViewMode(CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode);
201 m_bConfigured = true;
202 m_bImageReady = false;
203 m_scalingMethodGui = (ESCALINGMETHOD)-1;
205 // Ensure that textures are recreated and rendering starts only after the 1st
206 // frame is loaded after every call to Configure().
207 m_bValidated = false;
209 for (int i = 0 ; i<m_NumYV12Buffers ; i++)
210 m_buffers[i].image.flags = 0;
212 m_iLastRenderBuffer = -1;
214 m_RenderUpdateCallBackFn = NULL;
215 m_RenderUpdateCallBackCtx = NULL;
216 if ((m_format == RENDER_FMT_BYPASS) && g_application.GetCurrentPlayer())
218 m_renderFeatures.clear();
219 m_scalingMethods.clear();
220 m_deinterlaceModes.clear();
221 m_deinterlaceMethods.clear();
223 if (m_RenderFeaturesCallBackFn)
225 (*m_RenderFeaturesCallBackFn)(m_RenderFeaturesCallBackCtx, m_renderFeatures);
226 // after setting up m_renderFeatures, we are done with the callback
227 m_RenderFeaturesCallBackFn = NULL;
228 m_RenderFeaturesCallBackCtx = NULL;
230 g_application.m_pPlayer->GetRenderFeatures(m_renderFeatures);
231 g_application.m_pPlayer->GetDeinterlaceMethods(m_deinterlaceMethods);
232 g_application.m_pPlayer->GetDeinterlaceModes(m_deinterlaceModes);
233 g_application.m_pPlayer->GetScalingMethods(m_scalingMethods);
239 int CLinuxRendererGLES::NextYV12Texture()
241 return (m_iYV12RenderBuffer + 1) % m_NumYV12Buffers;
244 int CLinuxRendererGLES::GetImage(YV12Image *image, int source, bool readonly)
246 if (!image) return -1;
247 if (!m_bValidated) return -1;
249 /* take next available buffer */
250 if( source == AUTOSOURCE )
251 source = NextYV12Texture();
253 if ( m_renderMethod & RENDER_OMXEGL )
257 #ifdef HAS_LIBSTAGEFRIGHT
258 if ( m_renderMethod & RENDER_EGLIMG )
263 #ifdef HAVE_VIDEOTOOLBOXDECODER
264 if (m_renderMethod & RENDER_CVREF )
270 YV12Image &im = m_buffers[source].image;
272 if ((im.flags&(~IMAGE_FLAG_READY)) != 0)
274 CLog::Log(LOGDEBUG, "CLinuxRenderer::GetImage - request image but none to give");
279 im.flags |= IMAGE_FLAG_READING;
281 im.flags |= IMAGE_FLAG_WRITING;
283 // copy the image - should be operator of YV12Image
284 for (int p=0;p<MAX_PLANES;p++)
286 image->plane[p] = im.plane[p];
287 image->stride[p] = im.stride[p];
289 image->width = im.width;
290 image->height = im.height;
291 image->flags = im.flags;
292 image->cshift_x = im.cshift_x;
293 image->cshift_y = im.cshift_y;
299 void CLinuxRendererGLES::ReleaseImage(int source, bool preserve)
301 YV12Image &im = m_buffers[source].image;
303 im.flags &= ~IMAGE_FLAG_INUSE;
304 im.flags |= IMAGE_FLAG_READY;
305 /* if image should be preserved reserve it so it's not auto seleceted */
308 im.flags |= IMAGE_FLAG_RESERVED;
310 m_bImageReady = true;
313 void CLinuxRendererGLES::CalculateTextureSourceRects(int source, int num_planes)
315 YUVBUFFER& buf = m_buffers[source];
316 YV12Image* im = &buf.image;
317 YUVFIELDS& fields = buf.fields;
319 // calculate the source rectangle
320 for(int field = 0; field < 3; field++)
322 for(int plane = 0; plane < num_planes; plane++)
324 YUVPLANE& p = fields[field][plane];
326 p.rect = m_sourceRect;
328 p.height = im->height;
330 if(field != FIELD_FULL)
332 /* correct for field offsets and chroma offsets */
333 float offset_y = 0.5;
336 if(field == FIELD_BOT)
339 p.rect.y1 += offset_y;
340 p.rect.y2 += offset_y;
342 /* half the height if this is a field */
350 p.width /= 1 << im->cshift_x;
351 p.height /= 1 << im->cshift_y;
353 p.rect.x1 /= 1 << im->cshift_x;
354 p.rect.x2 /= 1 << im->cshift_x;
355 p.rect.y1 /= 1 << im->cshift_y;
356 p.rect.y2 /= 1 << im->cshift_y;
359 if (m_textureTarget == GL_TEXTURE_2D)
361 p.height /= p.texheight;
362 p.rect.y1 /= p.texheight;
363 p.rect.y2 /= p.texheight;
364 p.width /= p.texwidth;
365 p.rect.x1 /= p.texwidth;
366 p.rect.x2 /= p.texwidth;
372 void CLinuxRendererGLES::LoadPlane( YUVPLANE& plane, int type, unsigned flipindex
373 , unsigned width, unsigned height
374 , unsigned int stride, void* data )
376 if(plane.flipindex == flipindex)
379 const GLvoid *pixelData = data;
381 int bps = glFormatElementByteCount(type);
383 glBindTexture(m_textureTarget, plane.id);
385 // OpenGL ES does not support strided texture input.
386 if(stride != width * bps)
388 unsigned char* src = (unsigned char*)data;
389 for (unsigned int y = 0; y < height;++y, src += stride)
390 glTexSubImage2D(m_textureTarget, 0, 0, y, width, 1, type, GL_UNSIGNED_BYTE, src);
392 glTexSubImage2D(m_textureTarget, 0, 0, 0, width, height, type, GL_UNSIGNED_BYTE, pixelData);
395 /* check if we need to load any border pixels */
396 if(height < plane.texheight)
397 glTexSubImage2D( m_textureTarget, 0
398 , 0, height, width, 1
399 , type, GL_UNSIGNED_BYTE
400 , (unsigned char*)pixelData + stride * (height-1));
402 if(width < plane.texwidth)
403 glTexSubImage2D( m_textureTarget, 0
404 , width, 0, 1, height
405 , type, GL_UNSIGNED_BYTE
406 , (unsigned char*)pixelData + bps * (width-1));
408 glBindTexture(m_textureTarget, 0);
410 plane.flipindex = flipindex;
413 void CLinuxRendererGLES::Reset()
415 for(int i=0; i<m_NumYV12Buffers; i++)
417 /* reset all image flags, this will cleanup textures later */
418 m_buffers[i].image.flags = 0;
422 void CLinuxRendererGLES::Update()
424 if (!m_bConfigured) return;
428 void CLinuxRendererGLES::RenderUpdate(bool clear, DWORD flags, DWORD alpha)
430 if (!m_bConfigured) return;
432 // if its first pass, just init textures and return
433 if (ValidateRenderTarget())
436 if (m_renderMethod & RENDER_BYPASS)
439 // if running bypass, then the player might need the src/dst rects
440 // for sizing video playback on a layer other than the gles layer.
441 if (m_RenderUpdateCallBackFn)
442 (*m_RenderUpdateCallBackFn)(m_RenderUpdateCallBackCtx, m_sourceRect, m_destRect);
444 CRect old = g_graphicsContext.GetScissors();
446 g_graphicsContext.BeginPaint();
447 g_graphicsContext.SetScissors(m_destRect);
450 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
451 glClearColor(0, 0, 0, 0);
452 glClear(GL_COLOR_BUFFER_BIT);
454 g_graphicsContext.SetScissors(old);
455 g_graphicsContext.EndPaint();
459 // this needs to be checked after texture validation
460 if (!m_bImageReady) return;
462 int index = m_iYV12RenderBuffer;
463 YUVBUFFER& buf = m_buffers[index];
465 if (m_format != RENDER_FMT_OMXEGL && m_format != RENDER_FMT_EGLIMG)
467 if (!buf.fields[FIELD_FULL][0].id) return;
469 if (buf.image.flags==0)
474 g_graphicsContext.BeginPaint();
476 m_iLastRenderBuffer = index;
480 glClearColor(m_clearColour, m_clearColour, m_clearColour, 0);
481 glClear(GL_COLOR_BUFFER_BIT);
482 glClearColor(0,0,0,0);
488 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
490 m_pYUVShader->SetAlpha(alpha / 255.0f);
496 m_pYUVShader->SetAlpha(1.0f);
499 if ((flags & RENDER_FLAG_TOP) && (flags & RENDER_FLAG_BOT))
500 CLog::Log(LOGERROR, "GLES: Cannot render stipple!");
502 Render(flags, index);
507 g_graphicsContext.EndPaint();
510 void CLinuxRendererGLES::FlipPage(int source)
512 if( source >= 0 && source < m_NumYV12Buffers )
513 m_iYV12RenderBuffer = source;
515 m_iYV12RenderBuffer = NextYV12Texture();
517 m_buffers[m_iYV12RenderBuffer].flipindex = ++m_flipindex;
522 unsigned int CLinuxRendererGLES::PreInit()
524 CSingleLock lock(g_graphicsContext);
525 m_bConfigured = false;
526 m_bValidated = false;
528 m_resolution = CDisplaySettings::Get().GetCurrentResolution();
529 if ( m_resolution == RES_WINDOW )
530 m_resolution = RES_DESKTOP;
532 m_iYV12RenderBuffer = 0;
533 m_NumYV12Buffers = 2;
535 m_formats.push_back(RENDER_FMT_YUV420P);
536 m_formats.push_back(RENDER_FMT_BYPASS);
537 #if defined(HAVE_LIBOPENMAX)
538 m_formats.push_back(RENDER_FMT_OMXEGL);
540 #ifdef HAVE_VIDEOTOOLBOXDECODER
541 m_formats.push_back(RENDER_FMT_CVBREF);
543 #ifdef HAS_LIBSTAGEFRIGHT
544 m_formats.push_back(RENDER_FMT_EGLIMG);
547 // setup the background colour
548 m_clearColour = (float)(g_advancedSettings.m_videoBlackBarColour & 0xff) / 0xff;
550 if (!m_dllSwScale->Load())
551 CLog::Log(LOGERROR,"CLinuxRendererGL::PreInit - failed to load rescale libraries!");
556 void CLinuxRendererGLES::UpdateVideoFilter()
558 if (m_scalingMethodGui == CMediaSettings::Get().GetCurrentVideoSettings().m_ScalingMethod)
560 m_scalingMethodGui = CMediaSettings::Get().GetCurrentVideoSettings().m_ScalingMethod;
561 m_scalingMethod = m_scalingMethodGui;
563 if(!Supports(m_scalingMethod))
565 CLog::Log(LOGWARNING, "CLinuxRendererGLES::UpdateVideoFilter - choosen scaling method %d, is not supported by renderer", (int)m_scalingMethod);
566 m_scalingMethod = VS_SCALINGMETHOD_LINEAR;
569 if (m_pVideoFilterShader)
571 m_pVideoFilterShader->Free();
572 delete m_pVideoFilterShader;
573 m_pVideoFilterShader = NULL;
579 switch (m_scalingMethod)
581 case VS_SCALINGMETHOD_NEAREST:
582 SetTextureFilter(GL_NEAREST);
583 m_renderQuality = RQ_SINGLEPASS;
586 case VS_SCALINGMETHOD_LINEAR:
587 SetTextureFilter(GL_LINEAR);
588 m_renderQuality = RQ_SINGLEPASS;
591 case VS_SCALINGMETHOD_CUBIC:
592 CLog::Log(LOGERROR, "GLES: CUBIC not supported!");
595 case VS_SCALINGMETHOD_LANCZOS2:
596 case VS_SCALINGMETHOD_LANCZOS3:
597 case VS_SCALINGMETHOD_SINC8:
598 case VS_SCALINGMETHOD_NEDI:
599 CLog::Log(LOGERROR, "GL: TODO: This scaler has not yet been implemented");
606 CGUIDialogKaiToast::QueueNotification("Video Renderering", "Failed to init video filters/scalers, falling back to bilinear scaling");
607 CLog::Log(LOGERROR, "GL: Falling back to bilinear due to failure to init scaler");
608 if (m_pVideoFilterShader)
610 m_pVideoFilterShader->Free();
611 delete m_pVideoFilterShader;
612 m_pVideoFilterShader = NULL;
616 SetTextureFilter(GL_LINEAR);
617 m_renderQuality = RQ_SINGLEPASS;
620 void CLinuxRendererGLES::LoadShaders(int field)
622 #ifdef TARGET_DARWIN_IOS
623 float ios_version = GetIOSVersion();
625 int requestedMethod = CSettings::Get().GetInt("videoplayer.rendermethod");
626 CLog::Log(LOGDEBUG, "GL: Requested render method: %d", requestedMethod);
630 m_pYUVShader->Free();
635 switch(requestedMethod)
637 case RENDER_METHOD_AUTO:
638 case RENDER_METHOD_GLSL:
639 if (m_format == RENDER_FMT_OMXEGL)
641 CLog::Log(LOGNOTICE, "GL: Using OMXEGL RGBA render method");
642 m_renderMethod = RENDER_OMXEGL;
645 else if (m_format == RENDER_FMT_EGLIMG)
647 CLog::Log(LOGNOTICE, "GL: Using EGL Image render method");
648 m_renderMethod = RENDER_EGLIMG;
651 else if (m_format == RENDER_FMT_BYPASS)
653 CLog::Log(LOGNOTICE, "GL: Using BYPASS render method");
654 m_renderMethod = RENDER_BYPASS;
657 else if (m_format == RENDER_FMT_CVBREF)
659 CLog::Log(LOGNOTICE, "GL: Using CoreVideoRef RGBA render method");
660 m_renderMethod = RENDER_CVREF;
663 #if defined(TARGET_DARWIN_IOS)
664 else if (ios_version < 5.0 && m_format == RENDER_FMT_YUV420P)
666 CLog::Log(LOGNOTICE, "GL: Using software color conversion/RGBA render method");
667 m_renderMethod = RENDER_SW;
671 // Try GLSL shaders if supported and user requested auto or GLSL.
674 // create regular progressive scan shader
675 m_pYUVShader = new YUV2RGBProgressiveShader(false, m_iFlags, m_format);
676 CLog::Log(LOGNOTICE, "GL: Selecting Single Pass YUV 2 RGB shader");
678 if (m_pYUVShader && m_pYUVShader->CompileAndLink())
680 m_renderMethod = RENDER_GLSL;
684 else if (m_pYUVShader)
686 m_pYUVShader->Free();
689 CLog::Log(LOGERROR, "GL: Error enabling YUV2RGB GLSL shader");
690 // drop through and try SW
693 case RENDER_METHOD_SOFTWARE:
696 // Use software YUV 2 RGB conversion if user requested it or GLSL failed
697 m_renderMethod = RENDER_SW ;
698 CLog::Log(LOGNOTICE, "GL: Using software color conversion/RGBA rendering");
702 // determine whether GPU supports NPOT textures
703 if (!g_Windowing.IsExtSupported("GL_TEXTURE_NPOT"))
705 CLog::Log(LOGNOTICE, "GL: GL_ARB_texture_rectangle not supported and OpenGL version is not 2.x");
706 CLog::Log(LOGNOTICE, "GL: Reverting to POT textures");
707 m_renderMethod |= RENDER_POT;
710 CLog::Log(LOGNOTICE, "GL: NPOT texture support detected");
712 // Now that we now the render method, setup texture function handlers
713 if (m_format == RENDER_FMT_CVBREF)
715 m_textureUpload = &CLinuxRendererGLES::UploadCVRefTexture;
716 m_textureCreate = &CLinuxRendererGLES::CreateCVRefTexture;
717 m_textureDelete = &CLinuxRendererGLES::DeleteCVRefTexture;
719 else if (m_format == RENDER_FMT_BYPASS)
721 m_textureUpload = &CLinuxRendererGLES::UploadBYPASSTexture;
722 m_textureCreate = &CLinuxRendererGLES::CreateBYPASSTexture;
723 m_textureDelete = &CLinuxRendererGLES::DeleteBYPASSTexture;
725 else if (m_format == RENDER_FMT_EGLIMG)
727 m_textureUpload = &CLinuxRendererGLES::UploadEGLIMGTexture;
728 m_textureCreate = &CLinuxRendererGLES::CreateEGLIMGTexture;
729 m_textureDelete = &CLinuxRendererGLES::DeleteEGLIMGTexture;
733 // default to YV12 texture handlers
734 m_textureUpload = &CLinuxRendererGLES::UploadYV12Texture;
735 m_textureCreate = &CLinuxRendererGLES::CreateYV12Texture;
736 m_textureDelete = &CLinuxRendererGLES::DeleteYV12Texture;
739 if (m_oldRenderMethod != m_renderMethod)
741 CLog::Log(LOGDEBUG, "CLinuxRendererGLES: Reorder drawpoints due to method change from %i to %i", m_oldRenderMethod, m_renderMethod);
743 m_oldRenderMethod = m_renderMethod;
747 void CLinuxRendererGLES::UnInit()
749 CLog::Log(LOGDEBUG, "LinuxRendererGL: Cleaning up GL resources");
750 CSingleLock lock(g_graphicsContext);
752 if (m_rgbBuffer != NULL)
754 delete [] m_rgbBuffer;
760 for (int i = 0; i < NUM_BUFFERS; ++i)
761 (this->*m_textureDelete)(i);
763 if (m_dllSwScale && m_sw_context)
765 m_dllSwScale->sws_freeContext(m_sw_context);
769 // cleanup framebuffer object if it was in use
771 m_bValidated = false;
772 m_bImageReady = false;
773 m_bConfigured = false;
774 m_RenderUpdateCallBackFn = NULL;
775 m_RenderUpdateCallBackCtx = NULL;
776 m_RenderFeaturesCallBackFn = NULL;
777 m_RenderFeaturesCallBackCtx = NULL;
780 inline void CLinuxRendererGLES::ReorderDrawPoints()
783 CBaseRenderer::ReorderDrawPoints();//call base impl. for rotating the points
785 //corevideo and EGL are flipped in y
786 if(m_renderMethod & RENDER_CVREF)
789 tmp = m_rotatedDestCoords[0];
790 m_rotatedDestCoords[0] = m_rotatedDestCoords[3];
791 m_rotatedDestCoords[3] = tmp;
792 tmp = m_rotatedDestCoords[1];
793 m_rotatedDestCoords[1] = m_rotatedDestCoords[2];
794 m_rotatedDestCoords[2] = tmp;
798 void CLinuxRendererGLES::Render(DWORD flags, int index)
800 // If rendered directly by the hardware
801 if (m_renderMethod & RENDER_BYPASS)
804 // obtain current field, if interlaced
805 if( flags & RENDER_FLAG_TOP)
806 m_currentField = FIELD_TOP;
808 else if (flags & RENDER_FLAG_BOT)
809 m_currentField = FIELD_BOT;
812 m_currentField = FIELD_FULL;
814 (this->*m_textureUpload)(index);
816 if (m_renderMethod & RENDER_GLSL)
819 switch(m_renderQuality)
823 RenderSinglePass(index, m_currentField);
828 RenderMultiPass(index, m_currentField);
833 RenderSoftware(index, m_currentField);
838 else if (m_renderMethod & RENDER_OMXEGL)
840 RenderOpenMax(index, m_currentField);
843 else if (m_renderMethod & RENDER_EGLIMG)
845 RenderEglImage(index, m_currentField);
848 else if (m_renderMethod & RENDER_CVREF)
850 RenderCoreVideoRef(index, m_currentField);
855 RenderSoftware(index, m_currentField);
860 void CLinuxRendererGLES::RenderSinglePass(int index, int field)
862 YV12Image &im = m_buffers[index].image;
863 YUVFIELDS &fields = m_buffers[index].fields;
864 YUVPLANES &planes = fields[field];
872 glDisable(GL_DEPTH_TEST);
875 glActiveTexture(GL_TEXTURE0);
876 glEnable(m_textureTarget);
877 glBindTexture(m_textureTarget, planes[0].id);
880 glActiveTexture(GL_TEXTURE1);
881 glEnable(m_textureTarget);
882 glBindTexture(m_textureTarget, planes[1].id);
885 glActiveTexture(GL_TEXTURE2);
886 glEnable(m_textureTarget);
887 glBindTexture(m_textureTarget, planes[2].id);
889 glActiveTexture(GL_TEXTURE0);
892 m_pYUVShader->SetBlack(CMediaSettings::Get().GetCurrentVideoSettings().m_Brightness * 0.01f - 0.5f);
893 m_pYUVShader->SetContrast(CMediaSettings::Get().GetCurrentVideoSettings().m_Contrast * 0.02f);
894 m_pYUVShader->SetWidth(im.width);
895 m_pYUVShader->SetHeight(im.height);
896 if (field == FIELD_TOP)
897 m_pYUVShader->SetField(1);
898 else if(field == FIELD_BOT)
899 m_pYUVShader->SetField(0);
901 m_pYUVShader->SetMatrices(g_matrices.GetMatrix(MM_PROJECTION), g_matrices.GetMatrix(MM_MODELVIEW));
902 m_pYUVShader->Enable();
904 GLubyte idx[4] = {0, 1, 3, 2}; //determines order of triangle strip
905 GLfloat m_vert[4][3];
906 GLfloat m_tex[3][4][2];
908 GLint vertLoc = m_pYUVShader->GetVertexLoc();
909 GLint Yloc = m_pYUVShader->GetYcoordLoc();
910 GLint Uloc = m_pYUVShader->GetUcoordLoc();
911 GLint Vloc = m_pYUVShader->GetVcoordLoc();
913 glVertexAttribPointer(vertLoc, 3, GL_FLOAT, 0, 0, m_vert);
914 glVertexAttribPointer(Yloc, 2, GL_FLOAT, 0, 0, m_tex[0]);
915 glVertexAttribPointer(Uloc, 2, GL_FLOAT, 0, 0, m_tex[1]);
916 glVertexAttribPointer(Vloc, 2, GL_FLOAT, 0, 0, m_tex[2]);
918 glEnableVertexAttribArray(vertLoc);
919 glEnableVertexAttribArray(Yloc);
920 glEnableVertexAttribArray(Uloc);
921 glEnableVertexAttribArray(Vloc);
923 // Setup vertex position values
924 for(int i = 0; i < 4; i++)
926 m_vert[i][0] = m_rotatedDestCoords[i].x;
927 m_vert[i][1] = m_rotatedDestCoords[i].y;
928 m_vert[i][2] = 0.0f;// set z to 0
931 // Setup texture coordinates
932 for (int i=0; i<3; i++)
934 m_tex[i][0][0] = m_tex[i][3][0] = planes[i].rect.x1;
935 m_tex[i][0][1] = m_tex[i][1][1] = planes[i].rect.y1;
936 m_tex[i][1][0] = m_tex[i][2][0] = planes[i].rect.x2;
937 m_tex[i][2][1] = m_tex[i][3][1] = planes[i].rect.y2;
940 glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, idx);
944 m_pYUVShader->Disable();
947 glDisableVertexAttribArray(vertLoc);
948 glDisableVertexAttribArray(Yloc);
949 glDisableVertexAttribArray(Uloc);
950 glDisableVertexAttribArray(Vloc);
952 glActiveTexture(GL_TEXTURE1);
953 glDisable(m_textureTarget);
955 glActiveTexture(GL_TEXTURE2);
956 glDisable(m_textureTarget);
958 glActiveTexture(GL_TEXTURE0);
959 glDisable(m_textureTarget);
961 g_matrices.MatrixMode(MM_MODELVIEW);
966 void CLinuxRendererGLES::RenderMultiPass(int index, int field)
968 // TODO: Multipass rendering does not currently work! FIX!
969 CLog::Log(LOGERROR, "GLES: MULTIPASS rendering was called! But it doesnt work!!!");
972 YV12Image &im = m_buffers[index].image;
973 YUVPLANES &planes = m_buffers[index].fields[field];
978 LoadShaders(m_currentField);
981 glDisable(GL_DEPTH_TEST);
984 glEnable(m_textureTarget);
985 glActiveTexture(GL_TEXTURE0);
986 glBindTexture(m_textureTarget, planes[0].id);
990 glActiveTexture(GL_TEXTURE1);
991 glEnable(m_textureTarget);
992 glBindTexture(m_textureTarget, planes[1].id);
996 glActiveTexture(GL_TEXTURE2);
997 glEnable(m_textureTarget);
998 glBindTexture(m_textureTarget, planes[2].id);
1001 glActiveTexture(GL_TEXTURE0);
1004 // make sure the yuv shader is loaded and ready to go
1005 if (!m_pYUVShader || (!m_pYUVShader->OK()))
1007 CLog::Log(LOGERROR, "GL: YUV shader not active, cannot do multipass render");
1011 m_fbo.BeginRender();
1014 m_pYUVShader->SetBlack(CMediaSettings::Get().GetCurrentVideoSettings().m_Brightness * 0.01f - 0.5f);
1015 m_pYUVShader->SetContrast(CMediaSettings::Get().GetCurrentVideoSettings().m_Contrast * 0.02f);
1016 m_pYUVShader->SetWidth(im.width);
1017 m_pYUVShader->SetHeight(im.height);
1018 if (field == FIELD_TOP)
1019 m_pYUVShader->SetField(1);
1020 else if(field == FIELD_BOT)
1021 m_pYUVShader->SetField(0);
1025 // glPushAttrib(GL_VIEWPORT_BIT);
1026 // glPushAttrib(GL_SCISSOR_BIT);
1027 g_matrices.MatrixMode(MM_MODELVIEW);
1028 g_matrices.PushMatrix();
1029 g_matrices.LoadIdentity();
1032 g_matrices.MatrixMode(MM_PROJECTION);
1033 g_matrices.PushMatrix();
1034 g_matrices.LoadIdentity();
1036 g_matrices.Ortho2D(0, m_sourceWidth, 0, m_sourceHeight);
1037 glViewport(0, 0, m_sourceWidth, m_sourceHeight);
1038 glScissor(0, 0, m_sourceWidth, m_sourceHeight);
1039 g_matrices.MatrixMode(MM_MODELVIEW);
1043 if (!m_pYUVShader->Enable())
1045 CLog::Log(LOGERROR, "GL: Error enabling YUV shader");
1048 // 1st Pass to video frame size
1050 // float imgwidth = planes[0].rect.x2 - planes[0].rect.x1;
1051 // float imgheight = planes[0].rect.y2 - planes[0].rect.y1;
1052 // if (m_textureTarget == GL_TEXTURE_2D)
1054 // imgwidth *= planes[0].texwidth;
1055 // imgheight *= planes[0].texheight;
1058 // glBegin(GL_QUADS);
1060 // glMultiTexCoord2fARB(GL_TEXTURE0, planes[0].rect.x1, planes[0].rect.y1);
1061 // glMultiTexCoord2fARB(GL_TEXTURE1, planes[1].rect.x1, planes[1].rect.y1);
1062 // glMultiTexCoord2fARB(GL_TEXTURE2, planes[2].rect.x1, planes[2].rect.y1);
1063 // glVertex2f(0.0f , 0.0f);
1065 // glMultiTexCoord2fARB(GL_TEXTURE0, planes[0].rect.x2, planes[0].rect.y1);
1066 // glMultiTexCoord2fARB(GL_TEXTURE1, planes[1].rect.x2, planes[1].rect.y1);
1067 // glMultiTexCoord2fARB(GL_TEXTURE2, planes[2].rect.x2, planes[2].rect.y1);
1068 // glVertex2f(imgwidth, 0.0f);
1070 // glMultiTexCoord2fARB(GL_TEXTURE0, planes[0].rect.x2, planes[0].rect.y2);
1071 // glMultiTexCoord2fARB(GL_TEXTURE1, planes[1].rect.x2, planes[1].rect.y2);
1072 // glMultiTexCoord2fARB(GL_TEXTURE2, planes[2].rect.x2, planes[2].rect.y2);
1073 // glVertex2f(imgwidth, imgheight);
1075 // glMultiTexCoord2fARB(GL_TEXTURE0, planes[0].rect.x1, planes[0].rect.y2);
1076 // glMultiTexCoord2fARB(GL_TEXTURE1, planes[1].rect.x1, planes[1].rect.y2);
1077 // glMultiTexCoord2fARB(GL_TEXTURE2, planes[2].rect.x1, planes[2].rect.y2);
1078 // glVertex2f(0.0f , imgheight);
1083 m_pYUVShader->Disable();
1085 g_matrices.MatrixMode(MM_MODELVIEW);
1086 g_matrices.PopMatrix(); // pop modelview
1087 g_matrices.MatrixMode(MM_PROJECTION);
1088 g_matrices.PopMatrix(); // pop projection
1090 // glPopAttrib(); // pop scissor
1091 // glPopAttrib(); // pop viewport
1092 g_matrices.MatrixMode(MM_MODELVIEW);
1097 glActiveTexture(GL_TEXTURE1);
1098 glDisable(m_textureTarget);
1099 glActiveTexture(GL_TEXTURE2);
1100 glDisable(m_textureTarget);
1101 glActiveTexture(GL_TEXTURE0);
1102 glDisable(m_textureTarget);
1104 glEnable(GL_TEXTURE_2D);
1105 glBindTexture(GL_TEXTURE_2D, m_fbo.Texture());
1108 // Use regular normalized texture coordinates
1110 // 2nd Pass to screen size with optional video filter
1112 if (m_pVideoFilterShader)
1114 m_fbo.SetFiltering(GL_TEXTURE_2D, GL_NEAREST);
1115 m_pVideoFilterShader->SetSourceTexture(0);
1116 m_pVideoFilterShader->SetWidth(m_sourceWidth);
1117 m_pVideoFilterShader->SetHeight(m_sourceHeight);
1118 m_pVideoFilterShader->Enable();
1121 m_fbo.SetFiltering(GL_TEXTURE_2D, GL_LINEAR);
1126 // imgwidth /= m_sourceWidth;
1127 // imgheight /= m_sourceHeight;
1129 // glBegin(GL_QUADS);
1131 // glMultiTexCoord2fARB(GL_TEXTURE0, 0.0f , 0.0f);
1132 // glVertex4f(m_destRect.x1, m_destRect.y1, 0, 1.0f );
1134 // glMultiTexCoord2fARB(GL_TEXTURE0, imgwidth, 0.0f);
1135 // glVertex4f(m_destRect.x2, m_destRect.y1, 0, 1.0f);
1137 // glMultiTexCoord2fARB(GL_TEXTURE0, imgwidth, imgheight);
1138 // glVertex4f(m_destRect.x2, m_destRect.y2, 0, 1.0f);
1140 // glMultiTexCoord2fARB(GL_TEXTURE0, 0.0f , imgheight);
1141 // glVertex4f(m_destRect.x1, m_destRect.y2, 0, 1.0f);
1147 if (m_pVideoFilterShader)
1148 m_pVideoFilterShader->Disable();
1152 glDisable(m_textureTarget);
1156 void CLinuxRendererGLES::RenderSoftware(int index, int field)
1158 YUVPLANES &planes = m_buffers[index].fields[field];
1160 glDisable(GL_DEPTH_TEST);
1163 glEnable(m_textureTarget);
1164 glActiveTexture(GL_TEXTURE0);
1165 glBindTexture(m_textureTarget, planes[0].id);
1167 g_Windowing.EnableGUIShader(SM_TEXTURE_RGBA);
1169 GLubyte idx[4] = {0, 1, 3, 2}; //determines order of triangle strip
1174 for (int index = 0;index < 4;++index)
1175 col[index][0] = col[index][1] = col[index][2] = 1.0;
1177 GLint posLoc = g_Windowing.GUIShaderGetPos();
1178 GLint texLoc = g_Windowing.GUIShaderGetCoord0();
1179 GLint colLoc = g_Windowing.GUIShaderGetCol();
1181 glVertexAttribPointer(posLoc, 4, GL_FLOAT, 0, 0, ver);
1182 glVertexAttribPointer(texLoc, 2, GL_FLOAT, 0, 0, tex);
1183 glVertexAttribPointer(colLoc, 3, GL_FLOAT, 0, 0, col);
1185 glEnableVertexAttribArray(posLoc);
1186 glEnableVertexAttribArray(texLoc);
1187 glEnableVertexAttribArray(colLoc);
1189 // Set vertex coordinates
1190 for(int i = 0; i < 4; i++)
1192 ver[i][0] = m_rotatedDestCoords[i].x;
1193 ver[i][1] = m_rotatedDestCoords[i].y;
1194 ver[i][2] = 0.0f;// set z to 0
1198 // Set texture coordinates
1199 tex[0][0] = tex[3][0] = planes[0].rect.x1;
1200 tex[0][1] = tex[1][1] = planes[0].rect.y1;
1201 tex[1][0] = tex[2][0] = planes[0].rect.x2;
1202 tex[2][1] = tex[3][1] = planes[0].rect.y2;
1204 glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, idx);
1206 glDisableVertexAttribArray(posLoc);
1207 glDisableVertexAttribArray(texLoc);
1208 glDisableVertexAttribArray(colLoc);
1210 g_Windowing.DisableGUIShader();
1214 glDisable(m_textureTarget);
1218 void CLinuxRendererGLES::RenderOpenMax(int index, int field)
1220 #if defined(HAVE_LIBOPENMAX)
1221 GLuint textureId = m_buffers[index].openMaxBuffer->texture_id;
1223 glDisable(GL_DEPTH_TEST);
1226 glEnable(m_textureTarget);
1227 glActiveTexture(GL_TEXTURE0);
1228 glBindTexture(m_textureTarget, textureId);
1230 g_Windowing.EnableGUIShader(SM_TEXTURE_RGBA);
1232 GLubyte idx[4] = {0, 1, 3, 2}; //determines order of triangle strip
1237 for (int index = 0;index < 4;++index)
1239 col[index][0] = col[index][1] = col[index][2] = 1.0;
1242 GLint posLoc = g_Windowing.GUIShaderGetPos();
1243 GLint texLoc = g_Windowing.GUIShaderGetCoord0();
1244 GLint colLoc = g_Windowing.GUIShaderGetCol();
1246 glVertexAttribPointer(posLoc, 4, GL_FLOAT, 0, 0, ver);
1247 glVertexAttribPointer(texLoc, 2, GL_FLOAT, 0, 0, tex);
1248 glVertexAttribPointer(colLoc, 3, GL_FLOAT, 0, 0, col);
1250 glEnableVertexAttribArray(posLoc);
1251 glEnableVertexAttribArray(texLoc);
1252 glEnableVertexAttribArray(colLoc);
1254 // Set vertex coordinates
1255 for(int i = 0; i < 4; i++)
1257 ver[i][0] = m_rotatedDestCoords[i].x;
1258 ver[i][1] = m_rotatedDestCoords[i].y;
1259 ver[i][2] = 0.0f;// set z to 0
1263 // Set texture coordinates
1264 tex[0][0] = tex[3][0] = 0;
1265 tex[0][1] = tex[1][1] = 0;
1266 tex[1][0] = tex[2][0] = 1;
1267 tex[2][1] = tex[3][1] = 1;
1269 glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, idx);
1271 glDisableVertexAttribArray(posLoc);
1272 glDisableVertexAttribArray(texLoc);
1273 glDisableVertexAttribArray(colLoc);
1275 g_Windowing.DisableGUIShader();
1279 glDisable(m_textureTarget);
1284 void CLinuxRendererGLES::RenderEglImage(int index, int field)
1286 #if defined(HAS_LIBSTAGEFRIGHT)
1287 #ifdef DEBUG_VERBOSE
1288 unsigned int time = XbmcThreads::SystemClockMillis();
1291 YUVPLANE &plane = m_buffers[index].fields[field][0];
1293 glDisable(GL_DEPTH_TEST);
1295 glActiveTexture(GL_TEXTURE0);
1296 glBindTexture(m_textureTarget, plane.id);
1298 g_Windowing.EnableGUIShader(SM_TEXTURE_RGBA);
1300 GLubyte idx[4] = {0, 1, 3, 2}; //determines order of triangle strip
1305 for (int i = 0;i < 4;++i)
1307 col[i][0] = col[i][1] = col[i][2] = 1.0;
1310 GLint posLoc = g_Windowing.GUIShaderGetPos();
1311 GLint texLoc = g_Windowing.GUIShaderGetCoord0();
1312 GLint colLoc = g_Windowing.GUIShaderGetCol();
1314 glVertexAttribPointer(posLoc, 4, GL_FLOAT, 0, 0, ver);
1315 glVertexAttribPointer(texLoc, 2, GL_FLOAT, 0, 0, tex);
1316 glVertexAttribPointer(colLoc, 3, GL_FLOAT, 0, 0, col);
1318 glEnableVertexAttribArray(posLoc);
1319 glEnableVertexAttribArray(texLoc);
1320 glEnableVertexAttribArray(colLoc);
1322 // Set vertex coordinates
1323 for(int i = 0; i < 4; i++)
1325 ver[i][0] = m_rotatedDestCoords[i].x;
1326 ver[i][1] = m_rotatedDestCoords[i].y;
1327 ver[i][2] = 0.0f;// set z to 0
1331 // Set texture coordinates (is flipped in y)
1332 tex[0][0] = tex[3][0] = 0;
1333 tex[0][1] = tex[1][1] = 1;
1334 tex[1][0] = tex[2][0] = 1;
1335 tex[2][1] = tex[3][1] = 0;
1337 glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, idx);
1339 glDisableVertexAttribArray(posLoc);
1340 glDisableVertexAttribArray(texLoc);
1341 glDisableVertexAttribArray(colLoc);
1343 g_Windowing.DisableGUIShader();
1346 glBindTexture(m_textureTarget, 0);
1349 #ifdef DEBUG_VERBOSE
1350 CLog::Log(LOGDEBUG, "RenderEglImage %d: tm:%d\n", index, XbmcThreads::SystemClockMillis() - time);
1355 void CLinuxRendererGLES::RenderCoreVideoRef(int index, int field)
1357 #ifdef HAVE_VIDEOTOOLBOXDECODER
1358 YUVPLANE &plane = m_buffers[index].fields[field][0];
1360 glDisable(GL_DEPTH_TEST);
1362 glEnable(m_textureTarget);
1363 glActiveTexture(GL_TEXTURE0);
1364 glBindTexture(m_textureTarget, plane.id);
1366 g_Windowing.EnableGUIShader(SM_TEXTURE_RGBA);
1368 GLubyte idx[4] = {0, 1, 3, 2}; //determines order of triangle strip
1373 for (int index = 0;index < 4;++index)
1375 col[index][0] = col[index][1] = col[index][2] = 1.0;
1378 GLint posLoc = g_Windowing.GUIShaderGetPos();
1379 GLint texLoc = g_Windowing.GUIShaderGetCoord0();
1380 GLint colLoc = g_Windowing.GUIShaderGetCol();
1382 glVertexAttribPointer(posLoc, 4, GL_FLOAT, 0, 0, ver);
1383 glVertexAttribPointer(texLoc, 2, GL_FLOAT, 0, 0, tex);
1384 glVertexAttribPointer(colLoc, 3, GL_FLOAT, 0, 0, col);
1386 glEnableVertexAttribArray(posLoc);
1387 glEnableVertexAttribArray(texLoc);
1388 glEnableVertexAttribArray(colLoc);
1390 // Set vertex coordinates
1391 for(int i = 0; i < 4; i++)
1393 ver[i][0] = m_rotatedDestCoords[i].x;
1394 ver[i][1] = m_rotatedDestCoords[i].y;
1395 ver[i][2] = 0.0f;// set z to 0
1399 // Set texture coordinates (corevideo is flipped in y)
1400 tex[0][0] = tex[3][0] = 0;
1401 tex[0][1] = tex[1][1] = 1;
1402 tex[1][0] = tex[2][0] = 1;
1403 tex[2][1] = tex[3][1] = 0;
1405 glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, idx);
1407 glDisableVertexAttribArray(posLoc);
1408 glDisableVertexAttribArray(texLoc);
1409 glDisableVertexAttribArray(colLoc);
1411 g_Windowing.DisableGUIShader();
1414 glDisable(m_textureTarget);
1419 bool CLinuxRendererGLES::RenderCapture(CRenderCapture* capture)
1424 // save current video rect
1425 CRect saveSize = m_destRect;
1426 saveRotatedCoords();//backup current m_rotatedDestCoords
1428 // new video rect is thumbnail size
1429 m_destRect.SetRect(0, 0, (float)capture->GetWidth(), (float)capture->GetHeight());
1431 syncDestRectToRotatedPoints();//syncs the changed destRect to m_rotatedDestCoords
1432 // clear framebuffer and invert Y axis to get non-inverted image
1433 glDisable(GL_BLEND);
1435 g_matrices.MatrixMode(MM_MODELVIEW);
1436 g_matrices.PushMatrix();
1437 // fixme - we know that cvref & eglimg are already flipped in y direction
1438 // but somehow this also effects the rendercapture here
1439 // therefore we have to skip the flip here or we get upside down
1441 if (m_renderMethod != RENDER_CVREF)
1443 g_matrices.Translatef(0.0f, capture->GetHeight(), 0.0f);
1444 g_matrices.Scalef(1.0f, -1.0f, 1.0f);
1447 capture->BeginRender();
1449 Render(RENDER_FLAG_NOOSD, m_iYV12RenderBuffer);
1451 glReadPixels(0, g_graphicsContext.GetHeight() - capture->GetHeight(), capture->GetWidth(), capture->GetHeight(),
1452 GL_RGBA, GL_UNSIGNED_BYTE, capture->GetRenderBuffer());
1454 // OpenGLES returns in RGBA order but CRenderCapture needs BGRA order
1455 // XOR Swap RGBA -> BGRA
1456 unsigned char* pixels = (unsigned char*)capture->GetRenderBuffer();
1457 for (unsigned int i = 0; i < capture->GetWidth() * capture->GetHeight(); i++, pixels+=4)
1459 std::swap(pixels[0], pixels[2]);
1462 capture->EndRender();
1464 // revert model view matrix
1465 g_matrices.MatrixMode(MM_MODELVIEW);
1466 g_matrices.PopMatrix();
1468 // restore original video rect
1469 m_destRect = saveSize;
1470 restoreRotatedCoords();//restores the previous state of the rotated dest coords
1475 //********************************************************************************************************
1476 // YV12 Texture creation, deletion, copying + clearing
1477 //********************************************************************************************************
1478 void CLinuxRendererGLES::UploadYV12Texture(int source)
1480 YUVBUFFER& buf = m_buffers[source];
1481 YV12Image* im = &buf.image;
1482 YUVFIELDS& fields = buf.fields;
1485 #if defined(HAVE_LIBOPENMAX)
1486 if (!(im->flags&IMAGE_FLAG_READY) || m_buffers[source].openMaxBuffer)
1488 if (!(im->flags&IMAGE_FLAG_READY))
1494 // if we don't have a shader, fallback to SW YUV2RGB for now
1495 if (m_renderMethod & RENDER_SW)
1497 if(m_rgbBufferSize < m_sourceWidth * m_sourceHeight * 4)
1499 delete [] m_rgbBuffer;
1500 m_rgbBufferSize = m_sourceWidth*m_sourceHeight*4;
1501 m_rgbBuffer = new BYTE[m_rgbBufferSize];
1504 #if defined(__ARM_NEON__)
1505 if (g_cpuInfo.GetCPUFeatures() & CPU_FEATURE_NEON)
1507 yuv420_2_rgb8888_neon(m_rgbBuffer, im->plane[0], im->plane[2], im->plane[1],
1508 m_sourceWidth, m_sourceHeight, im->stride[0], im->stride[1], m_sourceWidth * 4);
1513 m_sw_context = m_dllSwScale->sws_getCachedContext(m_sw_context,
1514 im->width, im->height, PIX_FMT_YUV420P,
1515 im->width, im->height, PIX_FMT_RGBA,
1516 SWS_FAST_BILINEAR, NULL, NULL, NULL);
1518 uint8_t *src[] = { im->plane[0], im->plane[1], im->plane[2], 0 };
1519 int srcStride[] = { im->stride[0], im->stride[1], im->stride[2], 0 };
1520 uint8_t *dst[] = { m_rgbBuffer, 0, 0, 0 };
1521 int dstStride[] = { m_sourceWidth*4, 0, 0, 0 };
1522 m_dllSwScale->sws_scale(m_sw_context, src, srcStride, 0, im->height, dst, dstStride);
1527 if (m_currentField == FIELD_FULL)
1528 deinterlacing = false;
1530 deinterlacing = true;
1532 glEnable(m_textureTarget);
1535 if (m_renderMethod & RENDER_SW)
1540 LoadPlane( fields[FIELD_TOP][0] , GL_RGBA, buf.flipindex
1541 , im->width, im->height >> 1
1542 , m_sourceWidth*8, m_rgbBuffer );
1544 LoadPlane( fields[FIELD_BOT][0], GL_RGBA, buf.flipindex
1545 , im->width, im->height >> 1
1546 , m_sourceWidth*8, m_rgbBuffer + m_sourceWidth*4);
1550 LoadPlane( fields[FIELD_FULL][0], GL_RGBA, buf.flipindex
1551 , im->width, im->height
1552 , m_sourceWidth*4, m_rgbBuffer );
1557 glPixelStorei(GL_UNPACK_ALIGNMENT,1);
1562 LoadPlane( fields[FIELD_TOP][0] , GL_LUMINANCE, buf.flipindex
1563 , im->width, im->height >> 1
1564 , im->stride[0]*2, im->plane[0] );
1566 LoadPlane( fields[FIELD_BOT][0], GL_LUMINANCE, buf.flipindex
1567 , im->width, im->height >> 1
1568 , im->stride[0]*2, im->plane[0] + im->stride[0]) ;
1573 LoadPlane( fields[FIELD_FULL][0], GL_LUMINANCE, buf.flipindex
1574 , im->width, im->height
1575 , im->stride[0], im->plane[0] );
1581 if (!(m_renderMethod & RENDER_SW))
1583 glPixelStorei(GL_UNPACK_ALIGNMENT,1);
1587 // Load Even U & V Fields
1588 LoadPlane( fields[FIELD_TOP][1], GL_LUMINANCE, buf.flipindex
1589 , im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
1590 , im->stride[1]*2, im->plane[1] );
1592 LoadPlane( fields[FIELD_TOP][2], GL_LUMINANCE, buf.flipindex
1593 , im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
1594 , im->stride[2]*2, im->plane[2] );
1596 // Load Odd U & V Fields
1597 LoadPlane( fields[FIELD_BOT][1], GL_LUMINANCE, buf.flipindex
1598 , im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
1599 , im->stride[1]*2, im->plane[1] + im->stride[1] );
1601 LoadPlane( fields[FIELD_BOT][2], GL_LUMINANCE, buf.flipindex
1602 , im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
1603 , im->stride[2]*2, im->plane[2] + im->stride[2] );
1608 LoadPlane( fields[FIELD_FULL][1], GL_LUMINANCE, buf.flipindex
1609 , im->width >> im->cshift_x, im->height >> im->cshift_y
1610 , im->stride[1], im->plane[1] );
1612 LoadPlane( fields[FIELD_FULL][2], GL_LUMINANCE, buf.flipindex
1613 , im->width >> im->cshift_x, im->height >> im->cshift_y
1614 , im->stride[2], im->plane[2] );
1617 CalculateTextureSourceRects(source, 3);
1619 glDisable(m_textureTarget);
1622 void CLinuxRendererGLES::DeleteYV12Texture(int index)
1624 YV12Image &im = m_buffers[index].image;
1625 YUVFIELDS &fields = m_buffers[index].fields;
1627 if( fields[FIELD_FULL][0].id == 0 ) return;
1629 /* finish up all textures, and delete them */
1630 g_graphicsContext.BeginPaint(); //FIXME
1631 for(int f = 0;f<MAX_FIELDS;f++)
1633 for(int p = 0;p<MAX_PLANES;p++)
1635 if( fields[f][p].id )
1637 if (glIsTexture(fields[f][p].id))
1638 glDeleteTextures(1, &fields[f][p].id);
1639 fields[f][p].id = 0;
1643 g_graphicsContext.EndPaint();
1645 for(int p = 0;p<MAX_PLANES;p++)
1649 delete[] im.plane[p];
1655 bool CLinuxRendererGLES::CreateYV12Texture(int index)
1657 /* since we also want the field textures, pitch must be texture aligned */
1658 YV12Image &im = m_buffers[index].image;
1659 YUVFIELDS &fields = m_buffers[index].fields;
1661 DeleteYV12Texture(index);
1663 im.height = m_sourceHeight;
1664 im.width = m_sourceWidth;
1668 im.stride[0] = im.width;
1669 im.stride[1] = im.width >> im.cshift_x;
1670 im.stride[2] = im.width >> im.cshift_x;
1672 im.planesize[0] = im.stride[0] * im.height;
1673 im.planesize[1] = im.stride[1] * ( im.height >> im.cshift_y );
1674 im.planesize[2] = im.stride[2] * ( im.height >> im.cshift_y );
1676 for (int i = 0; i < 3; i++)
1677 im.plane[i] = new BYTE[im.planesize[i]];
1679 glEnable(m_textureTarget);
1680 for(int f = 0;f<MAX_FIELDS;f++)
1682 for(int p = 0;p<MAX_PLANES;p++)
1684 if (!glIsTexture(fields[f][p].id))
1686 glGenTextures(1, &fields[f][p].id);
1693 for (int f = FIELD_FULL; f<=FIELD_BOT ; f++)
1695 int fieldshift = (f==FIELD_FULL) ? 0 : 1;
1696 YUVPLANES &planes = fields[f];
1698 planes[0].texwidth = im.width;
1699 planes[0].texheight = im.height >> fieldshift;
1701 if (m_renderMethod & RENDER_SW)
1703 planes[1].texwidth = 0;
1704 planes[1].texheight = 0;
1705 planes[2].texwidth = 0;
1706 planes[2].texheight = 0;
1710 planes[1].texwidth = planes[0].texwidth >> im.cshift_x;
1711 planes[1].texheight = planes[0].texheight >> im.cshift_y;
1712 planes[2].texwidth = planes[0].texwidth >> im.cshift_x;
1713 planes[2].texheight = planes[0].texheight >> im.cshift_y;
1716 if(m_renderMethod & RENDER_POT)
1718 for(int p = 0; p < 3; p++)
1720 planes[p].texwidth = NP2(planes[p].texwidth);
1721 planes[p].texheight = NP2(planes[p].texheight);
1725 for(int p = 0; p < 3; p++)
1727 YUVPLANE &plane = planes[p];
1728 if (plane.texwidth * plane.texheight == 0)
1731 glBindTexture(m_textureTarget, plane.id);
1732 if (m_renderMethod & RENDER_SW)
1734 if(m_renderMethod & RENDER_POT)
1735 CLog::Log(LOGDEBUG, "GL: Creating RGB POT texture of size %d x %d", plane.texwidth, plane.texheight);
1737 CLog::Log(LOGDEBUG, "GL: Creating RGB NPOT texture of size %d x %d", plane.texwidth, plane.texheight);
1739 glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
1740 glTexImage2D(m_textureTarget, 0, GL_RGBA, plane.texwidth, plane.texheight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1744 if(m_renderMethod & RENDER_POT)
1745 CLog::Log(LOGDEBUG, "GL: Creating YUV POT texture of size %d x %d", plane.texwidth, plane.texheight);
1747 CLog::Log(LOGDEBUG, "GL: Creating YUV NPOT texture of size %d x %d", plane.texwidth, plane.texheight);
1749 glTexImage2D(m_textureTarget, 0, GL_LUMINANCE, plane.texwidth, plane.texheight, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
1752 glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1753 glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1754 glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1755 glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1759 glDisable(m_textureTarget);
1763 //********************************************************************************************************
1764 // CoreVideoRef Texture creation, deletion, copying + clearing
1765 //********************************************************************************************************
1766 void CLinuxRendererGLES::UploadCVRefTexture(int index)
1768 #ifdef HAVE_VIDEOTOOLBOXDECODER
1769 CVBufferRef cvBufferRef = m_buffers[index].cvBufferRef;
1773 YUVPLANE &plane = m_buffers[index].fields[0][0];
1775 CVPixelBufferLockBaseAddress(cvBufferRef, kCVPixelBufferLock_ReadOnly);
1776 #if !TARGET_OS_IPHONE
1777 int rowbytes = CVPixelBufferGetBytesPerRow(cvBufferRef);
1779 int bufferWidth = CVPixelBufferGetWidth(cvBufferRef);
1780 int bufferHeight = CVPixelBufferGetHeight(cvBufferRef);
1781 unsigned char *bufferBase = (unsigned char *)CVPixelBufferGetBaseAddress(cvBufferRef);
1783 glEnable(m_textureTarget);
1786 glBindTexture(m_textureTarget, plane.id);
1787 #if !TARGET_OS_IPHONE
1788 #ifdef GL_UNPACK_ROW_LENGTH
1790 glPixelStorei( GL_UNPACK_ROW_LENGTH, rowbytes);
1792 #ifdef GL_TEXTURE_STORAGE_HINT_APPLE
1793 // Set storage hint. Can also use GL_STORAGE_SHARED_APPLE see docs.
1794 glTexParameteri(m_textureTarget, GL_TEXTURE_STORAGE_HINT_APPLE , GL_STORAGE_CACHED_APPLE);
1798 // Using BGRA extension to pull in video frame data directly
1799 glTexSubImage2D(m_textureTarget, 0, 0, 0, bufferWidth, bufferHeight, GL_BGRA_EXT, GL_UNSIGNED_BYTE, bufferBase);
1801 #if !TARGET_OS_IPHONE
1802 #ifdef GL_UNPACK_ROW_LENGTH
1804 glPixelStorei( GL_UNPACK_ROW_LENGTH, 0);
1807 glBindTexture(m_textureTarget, 0);
1809 glDisable(m_textureTarget);
1812 CVPixelBufferUnlockBaseAddress(cvBufferRef, kCVPixelBufferLock_ReadOnly);
1813 CVBufferRelease(m_buffers[index].cvBufferRef);
1814 m_buffers[index].cvBufferRef = NULL;
1816 plane.flipindex = m_buffers[index].flipindex;
1820 void CLinuxRendererGLES::DeleteCVRefTexture(int index)
1822 #ifdef HAVE_VIDEOTOOLBOXDECODER
1823 YUVPLANE &plane = m_buffers[index].fields[0][0];
1825 if (m_buffers[index].cvBufferRef)
1826 CVBufferRelease(m_buffers[index].cvBufferRef);
1827 m_buffers[index].cvBufferRef = NULL;
1829 if(plane.id && glIsTexture(plane.id))
1830 glDeleteTextures(1, &plane.id);
1834 bool CLinuxRendererGLES::CreateCVRefTexture(int index)
1836 #ifdef HAVE_VIDEOTOOLBOXDECODER
1837 YV12Image &im = m_buffers[index].image;
1838 YUVFIELDS &fields = m_buffers[index].fields;
1839 YUVPLANE &plane = fields[0][0];
1841 DeleteCVRefTexture(index);
1843 memset(&im , 0, sizeof(im));
1844 memset(&fields, 0, sizeof(fields));
1846 im.height = m_sourceHeight;
1847 im.width = m_sourceWidth;
1849 plane.texwidth = im.width;
1850 plane.texheight = im.height;
1852 if(m_renderMethod & RENDER_POT)
1854 plane.texwidth = NP2(plane.texwidth);
1855 plane.texheight = NP2(plane.texheight);
1857 glEnable(m_textureTarget);
1858 glGenTextures(1, &plane.id);
1861 glBindTexture(m_textureTarget, plane.id);
1862 #if !TARGET_OS_IPHONE
1863 #ifdef GL_UNPACK_ROW_LENGTH
1865 glPixelStorei(GL_UNPACK_ROW_LENGTH, m_sourceWidth);
1867 #ifdef GL_TEXTURE_STORAGE_HINT_APPLE
1868 // Set storage hint. Can also use GL_STORAGE_SHARED_APPLE see docs.
1869 glTexParameteri(m_textureTarget, GL_TEXTURE_STORAGE_HINT_APPLE , GL_STORAGE_CACHED_APPLE);
1870 // Set client storage
1872 glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
1875 glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1876 glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1877 // This is necessary for non-power-of-two textures
1878 glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1879 glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1880 glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
1881 glTexImage2D(m_textureTarget, 0, GL_RGBA, plane.texwidth, plane.texheight, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL);
1883 #if !TARGET_OS_IPHONE
1884 // turn off client storage so it doesn't get picked up for the next texture
1885 glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE);
1887 glBindTexture(m_textureTarget, 0);
1888 glDisable(m_textureTarget);
1893 //********************************************************************************************************
1894 // BYPASS creation, deletion, copying + clearing
1895 //********************************************************************************************************
1896 void CLinuxRendererGLES::UploadBYPASSTexture(int index)
1899 void CLinuxRendererGLES::DeleteBYPASSTexture(int index)
1902 bool CLinuxRendererGLES::CreateBYPASSTexture(int index)
1907 //********************************************************************************************************
1908 // EGLIMG creation, deletion, copying + clearing
1909 //********************************************************************************************************
1910 void CLinuxRendererGLES::UploadEGLIMGTexture(int index)
1912 #ifdef HAS_LIBSTAGEFRIGHT
1913 #ifdef DEBUG_VERBOSE
1914 unsigned int time = XbmcThreads::SystemClockMillis();
1917 if(m_buffers[index].eglimg != EGL_NO_IMAGE_KHR)
1919 YUVPLANE &plane = m_buffers[index].fields[0][0];
1921 glActiveTexture(GL_TEXTURE0);
1922 glBindTexture(m_textureTarget, plane.id);
1923 glEGLImageTargetTexture2DOES(m_textureTarget, (EGLImageKHR)m_buffers[index].eglimg);
1924 glBindTexture(m_textureTarget, 0);
1926 plane.flipindex = m_buffers[index].flipindex;
1929 #ifdef DEBUG_VERBOSE
1930 CLog::Log(LOGDEBUG, "UploadEGLIMGTexture %d: img:%p, tm:%d\n", index, m_buffers[index].eglimg, XbmcThreads::SystemClockMillis() - time);
1934 void CLinuxRendererGLES::DeleteEGLIMGTexture(int index)
1936 #ifdef HAS_LIBSTAGEFRIGHT
1937 YUVPLANE &plane = m_buffers[index].fields[0][0];
1939 if(plane.id && glIsTexture(plane.id))
1940 glDeleteTextures(1, &plane.id);
1944 bool CLinuxRendererGLES::CreateEGLIMGTexture(int index)
1946 #ifdef HAS_LIBSTAGEFRIGHT
1947 YV12Image &im = m_buffers[index].image;
1948 YUVFIELDS &fields = m_buffers[index].fields;
1949 YUVPLANE &plane = fields[0][0];
1951 DeleteEGLIMGTexture(index);
1953 memset(&im , 0, sizeof(im));
1954 memset(&fields, 0, sizeof(fields));
1956 im.height = m_sourceHeight;
1957 im.width = m_sourceWidth;
1959 plane.texwidth = im.width;
1960 plane.texheight = im.height;
1962 if(m_renderMethod & RENDER_POT)
1964 plane.texwidth = NP2(plane.texwidth);
1965 plane.texheight = NP2(plane.texheight);
1967 glEnable(m_textureTarget);
1968 glGenTextures(1, &plane.id);
1971 glBindTexture(m_textureTarget, plane.id);
1973 glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1974 glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1975 // This is necessary for non-power-of-two textures
1976 glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1977 glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1979 glTexImage2D(m_textureTarget, 0, GL_RGBA, plane.texwidth, plane.texheight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1981 glDisable(m_textureTarget);
1986 void CLinuxRendererGLES::SetTextureFilter(GLenum method)
1988 for (int i = 0 ; i<m_NumYV12Buffers ; i++)
1990 YUVFIELDS &fields = m_buffers[i].fields;
1992 for (int f = FIELD_FULL; f<=FIELD_BOT ; f++)
1994 glBindTexture(m_textureTarget, fields[f][0].id);
1995 glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, method);
1996 glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, method);
1999 if (!(m_renderMethod & RENDER_SW))
2001 glBindTexture(m_textureTarget, fields[f][1].id);
2002 glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, method);
2003 glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, method);
2006 glBindTexture(m_textureTarget, fields[f][2].id);
2007 glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, method);
2008 glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, method);
2015 bool CLinuxRendererGLES::Supports(ERENDERFEATURE feature)
2017 // Player controls render, let it dictate available render features
2018 if((m_renderMethod & RENDER_BYPASS))
2020 Features::iterator itr = std::find(m_renderFeatures.begin(),m_renderFeatures.end(), feature);
2021 return itr != m_renderFeatures.end();
2024 if(feature == RENDERFEATURE_BRIGHTNESS)
2027 if(feature == RENDERFEATURE_CONTRAST)
2030 if(feature == RENDERFEATURE_GAMMA)
2033 if(feature == RENDERFEATURE_NOISE)
2036 if(feature == RENDERFEATURE_SHARPNESS)
2039 if (feature == RENDERFEATURE_NONLINSTRETCH)
2042 if (feature == RENDERFEATURE_STRETCH ||
2043 feature == RENDERFEATURE_CROP ||
2044 feature == RENDERFEATURE_ZOOM ||
2045 feature == RENDERFEATURE_VERTICAL_SHIFT ||
2046 feature == RENDERFEATURE_PIXEL_RATIO ||
2047 feature == RENDERFEATURE_POSTPROCESS ||
2048 feature == RENDERFEATURE_ROTATION)
2055 bool CLinuxRendererGLES::SupportsMultiPassRendering()
2060 bool CLinuxRendererGLES::Supports(EDEINTERLACEMODE mode)
2062 // Player controls render, let it dictate available deinterlace modes
2063 if((m_renderMethod & RENDER_BYPASS))
2065 Features::iterator itr = std::find(m_deinterlaceModes.begin(),m_deinterlaceModes.end(), mode);
2066 return itr != m_deinterlaceModes.end();
2069 if (mode == VS_DEINTERLACEMODE_OFF)
2072 if(m_renderMethod & RENDER_OMXEGL)
2075 if(m_renderMethod & RENDER_EGLIMG)
2078 if(m_renderMethod & RENDER_CVREF)
2081 if(mode == VS_DEINTERLACEMODE_AUTO
2082 || mode == VS_DEINTERLACEMODE_FORCE)
2088 bool CLinuxRendererGLES::Supports(EINTERLACEMETHOD method)
2090 // Player controls render, let it dictate available deinterlace methods
2091 if((m_renderMethod & RENDER_BYPASS))
2093 Features::iterator itr = std::find(m_deinterlaceMethods.begin(),m_deinterlaceMethods.end(), method);
2094 return itr != m_deinterlaceMethods.end();
2097 if(m_renderMethod & RENDER_OMXEGL)
2100 if(m_renderMethod & RENDER_EGLIMG)
2103 if(m_renderMethod & RENDER_CVREF)
2106 if(method == VS_INTERLACEMETHOD_AUTO)
2109 #if defined(__i386__) || defined(__x86_64__)
2110 if(method == VS_INTERLACEMETHOD_DEINTERLACE
2111 || method == VS_INTERLACEMETHOD_DEINTERLACE_HALF
2112 || method == VS_INTERLACEMETHOD_SW_BLEND)
2114 if(method == VS_INTERLACEMETHOD_SW_BLEND)
2121 bool CLinuxRendererGLES::Supports(ESCALINGMETHOD method)
2123 // Player controls render, let it dictate available scaling methods
2124 if((m_renderMethod & RENDER_BYPASS))
2126 Features::iterator itr = std::find(m_scalingMethods.begin(),m_scalingMethods.end(), method);
2127 return itr != m_scalingMethods.end();
2130 if(method == VS_SCALINGMETHOD_NEAREST
2131 || method == VS_SCALINGMETHOD_LINEAR)
2137 EINTERLACEMETHOD CLinuxRendererGLES::AutoInterlaceMethod()
2139 // Player controls render, let it pick the auto-deinterlace method
2140 if((m_renderMethod & RENDER_BYPASS))
2142 if (!m_deinterlaceMethods.empty())
2143 return ((EINTERLACEMETHOD)m_deinterlaceMethods[0]);
2145 return VS_INTERLACEMETHOD_NONE;
2148 if(m_renderMethod & RENDER_OMXEGL)
2149 return VS_INTERLACEMETHOD_NONE;
2151 if(m_renderMethod & RENDER_EGLIMG)
2152 return VS_INTERLACEMETHOD_NONE;
2154 if(m_renderMethod & RENDER_CVREF)
2155 return VS_INTERLACEMETHOD_NONE;
2157 #if defined(__i386__) || defined(__x86_64__)
2158 return VS_INTERLACEMETHOD_DEINTERLACE_HALF;
2160 return VS_INTERLACEMETHOD_SW_BLEND;
2164 unsigned int CLinuxRendererGLES::GetProcessorSize()
2166 if(m_format == RENDER_FMT_OMXEGL
2167 || m_format == RENDER_FMT_CVBREF
2168 || m_format == RENDER_FMT_EGLIMG)
2174 #ifdef HAVE_LIBOPENMAX
2175 void CLinuxRendererGLES::AddProcessor(COpenMax* openMax, DVDVideoPicture *picture, int index)
2177 YUVBUFFER &buf = m_buffers[index];
2178 buf.openMaxBuffer = picture->openMaxBuffer;
2181 #ifdef HAVE_VIDEOTOOLBOXDECODER
2182 void CLinuxRendererGLES::AddProcessor(struct __CVBuffer *cvBufferRef, int index)
2184 YUVBUFFER &buf = m_buffers[index];
2185 if (buf.cvBufferRef)
2186 CVBufferRelease(buf.cvBufferRef);
2187 buf.cvBufferRef = cvBufferRef;
2188 // retain another reference, this way dvdplayer and renderer can issue releases.
2189 CVBufferRetain(buf.cvBufferRef);
2192 #ifdef HAS_LIBSTAGEFRIGHT
2193 void CLinuxRendererGLES::AddProcessor(CStageFrightVideo* stf, EGLImageKHR eglimg, int index)
2195 #ifdef DEBUG_VERBOSE
2196 unsigned int time = XbmcThreads::SystemClockMillis();
2199 YUVBUFFER &buf = m_buffers[index];
2200 if (buf.eglimg != EGL_NO_IMAGE_KHR)
2201 stf->ReleaseBuffer(buf.eglimg);
2202 stf->LockBuffer(eglimg);
2205 buf.eglimg = eglimg;
2207 #ifdef DEBUG_VERBOSE
2208 CLog::Log(LOGDEBUG, "AddProcessor %d: img:%p: tm:%d\n", index, eglimg, XbmcThreads::SystemClockMillis() - time);