From 32861ab0a77e8c7ab1c9d195c5fe9ababaa1eec4 Mon Sep 17 00:00:00 2001 From: "Reynaldo H. Verdejo Pinochet" Date: Tue, 16 Oct 2012 17:50:03 -0300 Subject: [PATCH] eglglessink: Move DAR query & store to surface init The DAR (display's pixel aspect ratio) should remain a constant at runtime so there's no point on repeatedly query and store this value. Doing it at surface setup should be enough. As an added bonus this change should make rendering a bit faster. --- ext/eglgles/gsteglglessink.c | 71 ++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/ext/eglgles/gsteglglessink.c b/ext/eglgles/gsteglglessink.c index e713405..2890ddd 100644 --- a/ext/eglgles/gsteglglessink.c +++ b/ext/eglgles/gsteglglessink.c @@ -1538,7 +1538,6 @@ static gboolean gst_eglglessink_update_surface_dimensions (GstEglGlesSink * eglglessink) { gint width, height; - EGLint display_par; /* Save surface dims */ eglQuerySurface (eglglessink->eglglesctx.display, @@ -1546,41 +1545,6 @@ gst_eglglessink_update_surface_dimensions (GstEglGlesSink * eglglessink) eglQuerySurface (eglglessink->eglglesctx.display, eglglessink->eglglesctx.surface, EGL_HEIGHT, &height); - /* Save display's pixel aspect ratio - * - * DAR is reported as w/h * EGL_DISPLAY_SCALING wich is - * a constant with value 10000. This attribute is only - * supported if the EGL version is >= 1.2 - * XXX: Setup this as a property. - * XXX: Move this initialization out to init_egl_surface() - * or some other one time check. Right now it's being called once - * per frame. - */ - if (eglglessink->eglglesctx.egl_major == 1 && - eglglessink->eglglesctx.egl_minor < 2) { - GST_DEBUG_OBJECT (eglglessink, "Can't query PAR. Using default: %dx%d", - EGL_DISPLAY_SCALING, EGL_DISPLAY_SCALING); - eglglessink->eglglesctx.pixel_aspect_ratio = EGL_DISPLAY_SCALING; - } else { - eglQuerySurface (eglglessink->eglglesctx.display, - eglglessink->eglglesctx.surface, EGL_PIXEL_ASPECT_RATIO, - &display_par); - /* Fix for outbound DAR reporting on some implementations not - * honoring the 'should return w/h * EGL_DISPLAY_SCALING' spec - * requirement - */ - if (display_par == EGL_UNKNOWN || display_par < EGL_SANE_DAR_MIN || - display_par > EGL_SANE_DAR_MAX) { - GST_DEBUG_OBJECT (eglglessink, "Nonsensical PAR value returned: %d. " - "Bad EGL implementation? " - "Will use default: %d/%d", eglglessink->eglglesctx.pixel_aspect_ratio, - EGL_DISPLAY_SCALING, EGL_DISPLAY_SCALING); - eglglessink->eglglesctx.pixel_aspect_ratio = EGL_DISPLAY_SCALING; - } else { - eglglessink->eglglesctx.pixel_aspect_ratio = display_par; - } - } - if (width != eglglessink->eglglesctx.surface_width || height != eglglessink->eglglesctx.surface_height) { eglglessink->eglglesctx.surface_width = width; @@ -1635,6 +1599,7 @@ gst_eglglessink_init_egl_surface (GstEglGlesSink * eglglessink) GLint test; GLboolean ret; GLchar *info_log; + EGLint display_par; const gchar *texnames[3] = { NULL, }; gchar *tmp_prog = NULL; @@ -1654,6 +1619,40 @@ gst_eglglessink_init_egl_surface (GstEglGlesSink * eglglessink) if (!gst_eglglessink_context_make_current (eglglessink, TRUE)) goto HANDLE_EGL_ERROR_LOCKED; + /* Save display's pixel aspect ratio + * + * DAR is reported as w/h * EGL_DISPLAY_SCALING wich is + * a constant with value 10000. This attribute is only + * supported if the EGL version is >= 1.2 + * XXX: Setup this as a property. + * or some other one time check. Right now it's being called once + * per frame. + */ + if (eglglessink->eglglesctx.egl_major == 1 && + eglglessink->eglglesctx.egl_minor < 2) { + GST_DEBUG_OBJECT (eglglessink, "Can't query PAR. Using default: %dx%d", + EGL_DISPLAY_SCALING, EGL_DISPLAY_SCALING); + eglglessink->eglglesctx.pixel_aspect_ratio = EGL_DISPLAY_SCALING; + } else { + eglQuerySurface (eglglessink->eglglesctx.display, + eglglessink->eglglesctx.surface, EGL_PIXEL_ASPECT_RATIO, + &display_par); + /* Fix for outbound DAR reporting on some implementations not + * honoring the 'should return w/h * EGL_DISPLAY_SCALING' spec + * requirement + */ + if (display_par == EGL_UNKNOWN || display_par < EGL_SANE_DAR_MIN || + display_par > EGL_SANE_DAR_MAX) { + GST_DEBUG_OBJECT (eglglessink, "Nonsensical PAR value returned: %d. " + "Bad EGL implementation? " + "Will use default: %d/%d", eglglessink->eglglesctx.pixel_aspect_ratio, + EGL_DISPLAY_SCALING, EGL_DISPLAY_SCALING); + eglglessink->eglglesctx.pixel_aspect_ratio = EGL_DISPLAY_SCALING; + } else { + eglglessink->eglglesctx.pixel_aspect_ratio = display_par; + } + } + /* Save surface dims */ gst_eglglessink_update_surface_dimensions (eglglessink); -- 2.7.4