@@ -627,8 +627,6 @@ bool EGLRenderer::setupVideoRenderingState() {
627627 glGenTextures (EGL_MAX_PLANES , m_Textures);
628628 for (size_t i = 0 ; i < EGL_MAX_PLANES ; ++i) {
629629 glBindTexture (GL_TEXTURE_EXTERNAL_OES , m_Textures[i]);
630- glTexParameteri (GL_TEXTURE_EXTERNAL_OES , GL_TEXTURE_MIN_FILTER , GL_LINEAR );
631- glTexParameteri (GL_TEXTURE_EXTERNAL_OES , GL_TEXTURE_MAG_FILTER , GL_LINEAR );
632630 glTexParameteri (GL_TEXTURE_EXTERNAL_OES , GL_TEXTURE_WRAP_S , GL_CLAMP_TO_EDGE );
633631 glTexParameteri (GL_TEXTURE_EXTERNAL_OES , GL_TEXTURE_WRAP_T , GL_CLAMP_TO_EDGE );
634632 }
@@ -682,8 +680,8 @@ bool EGLRenderer::setupOverlayRenderingState() {
682680 for (size_t i = 0 ; i < Overlay::OverlayMax; ++i) {
683681 // Set up the overlay texture
684682 glBindTexture (GL_TEXTURE_2D , m_OverlayTextures[i]);
685- glTexParameteri (GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER , GL_LINEAR );
686- glTexParameteri (GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER , GL_LINEAR );
683+ glTexParameteri (GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER , GL_NEAREST );
684+ glTexParameteri (GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER , GL_NEAREST );
687685 glTexParameteri (GL_TEXTURE_2D , GL_TEXTURE_WRAP_S , GL_CLAMP_TO_EDGE );
688686 glTexParameteri (GL_TEXTURE_2D , GL_TEXTURE_WRAP_T , GL_CLAMP_TO_EDGE );
689687
@@ -786,13 +784,33 @@ void EGLRenderer::renderFrame(AVFrame* frame)
786784 }
787785 }
788786
787+ int drawableWidth, drawableHeight;
788+ SDL_GL_GetDrawableSize (m_Window, &drawableWidth, &drawableHeight);
789+ SDL_Rect src, dst;
790+ src.x = src.y = dst.x = dst.y = 0 ;
791+ src.w = frame->width ;
792+ src.h = frame->height ;
793+ dst.w = drawableWidth;
794+ dst.h = drawableHeight;
795+ StreamUtils::scaleSourceToDestinationSurface (&src, &dst);
796+
789797 ssize_t plane_count = m_Backend->exportEGLImages (frame, m_EGLDisplay, imgs);
790798 if (plane_count < 0 )
791799 return ;
792800 for (ssize_t i = 0 ; i < plane_count; ++i) {
793801 glActiveTexture (GL_TEXTURE0 + i);
794802 glBindTexture (GL_TEXTURE_EXTERNAL_OES , m_Textures[i]);
795803 m_glEGLImageTargetTexture2DOES (GL_TEXTURE_EXTERNAL_OES , imgs[i]);
804+
805+ // Use GL_NEAREST to reduce sampling if the video region is a multiple of the frame size
806+ if (dst.w % frame->width == 0 && dst.h % frame->height == 0 ) {
807+ glTexParameteri (GL_TEXTURE_EXTERNAL_OES , GL_TEXTURE_MIN_FILTER , GL_NEAREST );
808+ glTexParameteri (GL_TEXTURE_EXTERNAL_OES , GL_TEXTURE_MAG_FILTER , GL_NEAREST );
809+ }
810+ else {
811+ glTexParameteri (GL_TEXTURE_EXTERNAL_OES , GL_TEXTURE_MIN_FILTER , GL_LINEAR );
812+ glTexParameteri (GL_TEXTURE_EXTERNAL_OES , GL_TEXTURE_MAG_FILTER , GL_LINEAR );
813+ }
796814 }
797815
798816 // We already called glClear() after last frame's SDL_GL_SwapWindow()
@@ -801,17 +819,7 @@ void EGLRenderer::renderFrame(AVFrame* frame)
801819 glClear (GL_COLOR_BUFFER_BIT );
802820 }
803821
804- int drawableWidth, drawableHeight;
805- SDL_GL_GetDrawableSize (m_Window, &drawableWidth, &drawableHeight);
806-
807822 // Set the viewport to the size of the aspect-ratio-scaled video
808- SDL_Rect src, dst;
809- src.x = src.y = dst.x = dst.y = 0 ;
810- src.w = frame->width ;
811- src.h = frame->height ;
812- dst.w = drawableWidth;
813- dst.h = drawableHeight;
814- StreamUtils::scaleSourceToDestinationSurface (&src, &dst);
815823 glViewport (dst.x , dst.y , dst.w , dst.h );
816824
817825 glUseProgram (m_ShaderProgram);
0 commit comments