vlc | branch: master | Thomas Guillem <[email protected]> | Thu Jun 22 11:27:32 2017 +0200| [d80be7a2a146d1bc1ee7475965d622bb3e2d65f5] | committer: Thomas Guillem
gl: converters: change the way to pass the video_format_t And merge tc->orientation with the new tc->fmt. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d80be7a2a146d1bc1ee7475965d622bb3e2d65f5 --- modules/video_output/opengl/converter_android.c | 27 ++++++----- modules/video_output/opengl/converter_cvpx.c | 18 ++++---- modules/video_output/opengl/converter_vaapi.c | 19 ++++---- modules/video_output/opengl/converters.c | 61 ++++++++++++------------- modules/video_output/opengl/internal.h | 25 ++++------ modules/video_output/opengl/vout_helper.c | 13 +++--- 6 files changed, 74 insertions(+), 89 deletions(-) diff --git a/modules/video_output/opengl/converter_android.c b/modules/video_output/opengl/converter_android.c index 6814e2c359..95eea3b305 100644 --- a/modules/video_output/opengl/converter_android.c +++ b/modules/video_output/opengl/converter_android.c @@ -79,8 +79,7 @@ tc_anop_allocate_textures(const opengl_tex_converter_t *tc, GLuint *textures, } static picture_pool_t * -tc_anop_get_pool(const opengl_tex_converter_t *tc, const video_format_t *fmt, - unsigned requested_count) +tc_anop_get_pool(const opengl_tex_converter_t *tc, unsigned requested_count) { struct priv *priv = tc->priv; #define FORCED_COUNT 31 @@ -104,7 +103,7 @@ tc_anop_get_pool(const opengl_tex_converter_t *tc, const video_format_t *fmt, p_picsys->hw.i_index = -1; vlc_mutex_init(&p_picsys->hw.lock); - picture[count] = picture_NewFromResource(fmt, &rsc); + picture[count] = picture_NewFromResource(&tc->fmt, &rsc); if (!picture[count]) { free(p_picsys); @@ -193,9 +192,9 @@ tc_anop_release(const opengl_tex_converter_t *tc) } GLuint -opengl_tex_converter_anop_init(video_format_t *fmt, opengl_tex_converter_t *tc) +opengl_tex_converter_anop_init(opengl_tex_converter_t *tc) { - if (fmt->i_chroma != VLC_CODEC_ANDROID_OPAQUE + if (tc->fmt.i_chroma != VLC_CODEC_ANDROID_OPAQUE || !tc->gl->surface->handle.anativewindow) return 0; @@ -223,31 +222,31 @@ opengl_tex_converter_anop_init(video_format_t *fmt, opengl_tex_converter_t *tc) /* The transform Matrix (uSTMatrix) given by the SurfaceTexture is not * using the same origin than us. Ask the caller to rotate textures * coordinates, via the vertex shader, by forcing an orientation. */ - switch (tc->orientation) + switch (tc->fmt.orientation) { case ORIENT_TOP_LEFT: - tc->orientation = ORIENT_BOTTOM_LEFT; + tc->fmt.orientation = ORIENT_BOTTOM_LEFT; break; case ORIENT_TOP_RIGHT: - tc->orientation = ORIENT_BOTTOM_RIGHT; + tc->fmt.orientation = ORIENT_BOTTOM_RIGHT; break; case ORIENT_BOTTOM_LEFT: - tc->orientation = ORIENT_TOP_LEFT; + tc->fmt.orientation = ORIENT_TOP_LEFT; break; case ORIENT_BOTTOM_RIGHT: - tc->orientation = ORIENT_TOP_RIGHT; + tc->fmt.orientation = ORIENT_TOP_RIGHT; break; case ORIENT_LEFT_TOP: - tc->orientation = ORIENT_RIGHT_TOP; + tc->fmt.orientation = ORIENT_RIGHT_TOP; break; case ORIENT_LEFT_BOTTOM: - tc->orientation = ORIENT_RIGHT_BOTTOM; + tc->fmt.orientation = ORIENT_RIGHT_BOTTOM; break; case ORIENT_RIGHT_TOP: - tc->orientation = ORIENT_LEFT_TOP; + tc->fmt.orientation = ORIENT_LEFT_TOP; break; case ORIENT_RIGHT_BOTTOM: - tc->orientation = ORIENT_LEFT_BOTTOM; + tc->fmt.orientation = ORIENT_LEFT_BOTTOM; break; } diff --git a/modules/video_output/opengl/converter_cvpx.c b/modules/video_output/opengl/converter_cvpx.c index 6486469eec..0876094015 100644 --- a/modules/video_output/opengl/converter_cvpx.c +++ b/modules/video_output/opengl/converter_cvpx.c @@ -158,12 +158,12 @@ tc_cvpx_release(const opengl_tex_converter_t *tc) } GLuint -opengl_tex_converter_cvpx_init(video_format_t *fmt, opengl_tex_converter_t *tc) +opengl_tex_converter_cvpx_init(opengl_tex_converter_t *tc) { - if (fmt->i_chroma != VLC_CODEC_CVPX_UYVY - && fmt->i_chroma != VLC_CODEC_CVPX_NV12 - && fmt->i_chroma != VLC_CODEC_CVPX_I420 - && fmt->i_chroma != VLC_CODEC_CVPX_BGRA) + if (tc->fmt.i_chroma != VLC_CODEC_CVPX_UYVY + && tc->fmt.i_chroma != VLC_CODEC_CVPX_NV12 + && tc->fmt.i_chroma != VLC_CODEC_CVPX_I420 + && tc->fmt.i_chroma != VLC_CODEC_CVPX_BGRA) return 0; struct priv *priv = calloc(1, sizeof(struct priv)); @@ -191,12 +191,12 @@ opengl_tex_converter_cvpx_init(video_format_t *fmt, opengl_tex_converter_t *tc) #endif GLuint fragment_shader; - switch (fmt->i_chroma) + switch (tc->fmt.i_chroma) { case VLC_CODEC_CVPX_UYVY: fragment_shader = opengl_fragment_shader_init(tc, tex_target, VLC_CODEC_UYVY, - fmt->space); + tc->fmt.space); tc->texs[0].internal = GL_RGB; tc->texs[0].format = GL_RGB_422_APPLE; tc->texs[0].type = GL_UNSIGNED_SHORT_8_8_APPLE; @@ -205,13 +205,13 @@ opengl_tex_converter_cvpx_init(video_format_t *fmt, opengl_tex_converter_t *tc) { fragment_shader = opengl_fragment_shader_init(tc, tex_target, VLC_CODEC_NV12, - fmt->space); + tc->fmt.space); break; } case VLC_CODEC_CVPX_I420: fragment_shader = opengl_fragment_shader_init(tc, tex_target, VLC_CODEC_I420, - fmt->space); + tc->fmt.space); break; case VLC_CODEC_CVPX_BGRA: fragment_shader = diff --git a/modules/video_output/opengl/converter_vaapi.c b/modules/video_output/opengl/converter_vaapi.c index c991dc8b35..72232f1494 100644 --- a/modules/video_output/opengl/converter_vaapi.c +++ b/modules/video_output/opengl/converter_vaapi.c @@ -50,7 +50,6 @@ struct priv Display *x11dpy; #endif - video_color_space_t yuv_space; unsigned fourcc; EGLint drm_fourccs[3]; @@ -233,14 +232,13 @@ tc_vaegl_release(const opengl_tex_converter_t *tc) } static GLuint -tc_vaegl_init(video_format_t *fmt, opengl_tex_converter_t *tc, VADisplay *vadpy) +tc_vaegl_init(opengl_tex_converter_t *tc, VADisplay *vadpy) { if (vadpy == NULL) return 0; struct priv *priv = tc->priv; priv->vadpy = vadpy; priv->fourcc = 0; - priv->yuv_space = fmt->space; if (!HasExtension(tc->glexts, "GL_OES_EGL_image")) return 0; @@ -271,21 +269,20 @@ tc_vaegl_init(video_format_t *fmt, opengl_tex_converter_t *tc, VADisplay *vadpy) GLuint fshader = opengl_fragment_shader_init(tc, GL_TEXTURE_2D, VLC_CODEC_NV12, - fmt->space); + tc->fmt.space); if (fshader == 0) vlc_vaapi_ReleaseInstance(priv->vadpy); return fshader; } static picture_pool_t * -tc_va_get_pool(const opengl_tex_converter_t *tc, const video_format_t *fmt, - unsigned requested_count) +tc_va_get_pool(const opengl_tex_converter_t *tc, unsigned requested_count) { struct priv *priv = tc->priv; picture_pool_t *pool = vlc_vaapi_PoolNew(VLC_OBJECT(tc->gl), priv->vadpy, requested_count, - &priv->va_surface_ids, fmt, VA_RT_FORMAT_YUV420, + &priv->va_surface_ids, &tc->fmt, VA_RT_FORMAT_YUV420, VA_FOURCC_NV12); if (!pool) return NULL; @@ -294,9 +291,9 @@ tc_va_get_pool(const opengl_tex_converter_t *tc, const video_format_t *fmt, } GLuint -opengl_tex_converter_vaapi_init(video_format_t *fmt, opengl_tex_converter_t *tc) +opengl_tex_converter_vaapi_init(opengl_tex_converter_t *tc) { - if (fmt->i_chroma != VLC_CODEC_VAAPI_420 || tc->gl->ext != VLC_GL_EXT_EGL + if (tc->fmt.i_chroma != VLC_CODEC_VAAPI_420 || tc->gl->ext != VLC_GL_EXT_EGL || tc->gl->egl.createImageKHR == NULL || tc->gl->egl.destroyImageKHR == NULL) return 0; @@ -320,7 +317,7 @@ opengl_tex_converter_vaapi_init(video_format_t *fmt, opengl_tex_converter_t *tc) return VLC_ENOMEM; } - fshader = tc_vaegl_init(fmt, tc, vaGetDisplay(x11dpy)); + fshader = tc_vaegl_init(tc, vaGetDisplay(x11dpy)); if (fshader == 0) { XCloseDisplay(x11dpy); @@ -337,7 +334,7 @@ opengl_tex_converter_vaapi_init(video_format_t *fmt, opengl_tex_converter_t *tc) if (unlikely(tc->priv == NULL)) return VLC_ENOMEM; - fshader = tc_vaegl_init(fmt, tc, + fshader = tc_vaegl_init(tc, vaGetDisplayWl(tc->gl->surface->display.wl)); if (fshader == 0) { diff --git a/modules/video_output/opengl/converters.c b/modules/video_output/opengl/converters.c index 9730957a89..1c02152f25 100644 --- a/modules/video_output/opengl/converters.c +++ b/modules/video_output/opengl/converters.c @@ -507,7 +507,7 @@ opengl_fragment_shader_init(opengl_tex_converter_t *tc, GLenum tex_target, # endif static picture_t * -pbo_picture_create(const opengl_tex_converter_t *tc, const video_format_t *fmt, +pbo_picture_create(const opengl_tex_converter_t *tc, void (*pf_destroy)(picture_t *)) { picture_sys_t *picsys = calloc(1, sizeof(*picsys)); @@ -519,13 +519,13 @@ pbo_picture_create(const opengl_tex_converter_t *tc, const video_format_t *fmt, .pf_destroy = pf_destroy, }; - picture_t *pic = picture_NewFromResource(fmt, &rsc); + picture_t *pic = picture_NewFromResource(&tc->fmt, &rsc); if (pic == NULL) { free(picsys); return NULL; } - if (picture_Setup(pic, fmt)) + if (picture_Setup(pic, &tc->fmt)) { picture_Release(pic); return NULL; @@ -583,13 +583,13 @@ picture_pbo_destroy_cb(picture_t *pic) } static int -pbo_pics_alloc(const opengl_tex_converter_t *tc, const video_format_t *fmt) +pbo_pics_alloc(const opengl_tex_converter_t *tc) { struct priv *priv = tc->priv; for (size_t i = 0; i < PBO_DISPLAY_COUNT; ++i) { picture_t *pic = priv->pbo.display_pics[i] = - pbo_picture_create(tc, fmt, picture_pbo_destroy_cb); + pbo_picture_create(tc, picture_pbo_destroy_cb); if (pic == NULL) goto error; @@ -816,8 +816,7 @@ picture_persistent_destroy_cb(picture_t *pic) } static picture_pool_t * -tc_persistent_get_pool(const opengl_tex_converter_t *tc, const video_format_t *fmt, - unsigned requested_count) +tc_persistent_get_pool(const opengl_tex_converter_t *tc, unsigned requested_count) { struct priv *priv = tc->priv; picture_t *pictures[VLCGL_PICTURE_MAX]; @@ -829,7 +828,7 @@ tc_persistent_get_pool(const opengl_tex_converter_t *tc, const video_format_t *f for (count = 0; count < requested_count; count++) { picture_t *pic = pictures[count] = - pbo_picture_create(tc, fmt, picture_persistent_destroy_cb); + pbo_picture_create(tc, picture_persistent_destroy_cb); if (pic == NULL) break; #ifndef NDEBUG @@ -1041,22 +1040,23 @@ xyz12_shader_init(opengl_tex_converter_t *tc) } static GLuint -generic_init(video_format_t *fmt, opengl_tex_converter_t *tc, bool allow_dr) +generic_init(opengl_tex_converter_t *tc, bool allow_dr) { const vlc_chroma_description_t *desc = - vlc_fourcc_GetChromaDescription(fmt->i_chroma); + vlc_fourcc_GetChromaDescription(tc->fmt.i_chroma); + assert(desc); if (!desc) return 0; GLuint fragment_shader = 0; - if (fmt->i_chroma == VLC_CODEC_XYZ12) + if (tc->fmt.i_chroma == VLC_CODEC_XYZ12) fragment_shader = xyz12_shader_init(tc); else { video_color_space_t space; const vlc_fourcc_t *(*get_fallback)(vlc_fourcc_t i_fourcc); - if (vlc_fourcc_IsYUV(fmt->i_chroma)) + if (vlc_fourcc_IsYUV(tc->fmt.i_chroma)) { GLint max_texture_units = 0; glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &max_texture_units); @@ -1064,7 +1064,7 @@ generic_init(video_format_t *fmt, opengl_tex_converter_t *tc, bool allow_dr) return 0; get_fallback = vlc_fourcc_GetYUVFallback; - space = fmt->space; + space = tc->fmt.space; } else { @@ -1072,27 +1072,27 @@ generic_init(video_format_t *fmt, opengl_tex_converter_t *tc, bool allow_dr) space = COLOR_SPACE_UNDEF; } - const vlc_fourcc_t *list = get_fallback(fmt->i_chroma); + const vlc_fourcc_t *list = get_fallback(tc->fmt.i_chroma); while (*list) { fragment_shader = opengl_fragment_shader_init(tc, GL_TEXTURE_2D, *list, space); if (fragment_shader != 0) { - fmt->i_chroma = *list; + tc->fmt.i_chroma = *list; - if (fmt->i_chroma == VLC_CODEC_RGB32) + if (tc->fmt.i_chroma == VLC_CODEC_RGB32) { #if defined(WORDS_BIGENDIAN) - fmt->i_rmask = 0xff000000; - fmt->i_gmask = 0x00ff0000; - fmt->i_bmask = 0x0000ff00; + tc->fmt.i_rmask = 0xff000000; + tc->fmt.i_gmask = 0x00ff0000; + tc->fmt.i_bmask = 0x0000ff00; #else - fmt->i_rmask = 0x000000ff; - fmt->i_gmask = 0x0000ff00; - fmt->i_bmask = 0x00ff0000; + tc->fmt.i_rmask = 0x000000ff; + tc->fmt.i_gmask = 0x0000ff00; + tc->fmt.i_bmask = 0x00ff0000; #endif - video_format_FixRgb(fmt); + video_format_FixRgb(&tc->fmt); } break; } @@ -1139,7 +1139,7 @@ generic_init(video_format_t *fmt, opengl_tex_converter_t *tc, bool allow_dr) { const bool supports_pbo = has_pbo && tc->api->BufferData && tc->api->BufferSubData; - if (supports_pbo && pbo_pics_alloc(tc, fmt) == VLC_SUCCESS) + if (supports_pbo && pbo_pics_alloc(tc) == VLC_SUCCESS) { tc->pf_update = tc_pbo_update; tc->pf_release = tc_pbo_release; @@ -1163,17 +1163,14 @@ error: } GLuint -opengl_tex_converter_subpictures_init(const video_format_t *fmt, - opengl_tex_converter_t *tc) +opengl_tex_converter_subpictures_init(opengl_tex_converter_t *tc) { - video_format_t sub_fmt = *fmt; - sub_fmt.i_chroma = VLC_CODEC_RGB32; - return generic_init(&sub_fmt, tc, false); + tc->fmt.i_chroma = VLC_CODEC_RGB32; + return generic_init(tc, false); } GLuint -opengl_tex_converter_generic_init(video_format_t *fmt, - opengl_tex_converter_t *tc) +opengl_tex_converter_generic_init(opengl_tex_converter_t *tc) { - return generic_init(fmt, tc, true); + return generic_init(tc, true); } diff --git a/modules/video_output/opengl/internal.h b/modules/video_output/opengl/internal.h index 9f0f75d931..1a50a11ceb 100644 --- a/modules/video_output/opengl/internal.h +++ b/modules/video_output/opengl/internal.h @@ -164,8 +164,7 @@ typedef struct opengl_tex_converter_t opengl_tex_converter_t; * \param fc OpenGL tex converter that needs to be filled on success * \return VLC_SUCCESS or a VLC error */ -typedef GLuint (*opengl_tex_converter_init_cb)(video_format_t *fmt, - opengl_tex_converter_t *fc); +typedef GLuint (*opengl_tex_converter_init_cb)(opengl_tex_converter_t *fc); /* * Structure that is filled by an opengl_tex_converter_init_cb function @@ -178,8 +177,9 @@ struct opengl_tex_converter_t const opengl_shaders_api_t *api; /* Available gl extensions (from GL_EXTENSIONS) */ const char *glexts; - /* Set it to request a special orientation (by default = fmt.orientation) */ - video_orientation_t orientation; + + /* Can only be changed from the module open function */ + video_format_t fmt; /* Number of textures, cannot be 0 */ unsigned tex_count; @@ -240,12 +240,10 @@ struct opengl_tex_converter_t * pictures allocated from the video_format_t will be used. * * \param fc OpenGL tex converter - * \param fmt video format * \param requested_count number of pictures to allocate * \return the picture pool or NULL in case of error */ picture_pool_t *(*pf_get_pool)(const opengl_tex_converter_t *fc, - const video_format_t *fmt, unsigned requested_count); /* @@ -324,29 +322,24 @@ opengl_fragment_shader_init(opengl_tex_converter_t *tc, GLenum tex_target, vlc_fourcc_t chroma, video_color_space_t yuv_space); GLuint -opengl_tex_converter_subpictures_init(const video_format_t *, - opengl_tex_converter_t *); +opengl_tex_converter_subpictures_init(opengl_tex_converter_t *); GLuint -opengl_tex_converter_generic_init(video_format_t *, - opengl_tex_converter_t *); +opengl_tex_converter_generic_init(opengl_tex_converter_t *); #ifdef __ANDROID__ GLuint -opengl_tex_converter_anop_init(video_format_t *, - opengl_tex_converter_t *); +opengl_tex_converter_anop_init(opengl_tex_converter_t *); #endif #ifdef VLCGL_CONV_CVPX GLuint -opengl_tex_converter_cvpx_init(video_format_t *fmt, - opengl_tex_converter_t *tc); +opengl_tex_converter_cvpx_init(opengl_tex_converter_t *tc); #endif #ifdef VLCGL_CONV_VA GLuint -opengl_tex_converter_vaapi_init(video_format_t *fmt, - opengl_tex_converter_t *tc); +opengl_tex_converter_vaapi_init(opengl_tex_converter_t *tc); #endif #endif /* include-guard */ diff --git a/modules/video_output/opengl/vout_helper.c b/modules/video_output/opengl/vout_helper.c index e5b0e8b5fc..1784a97dde 100644 --- a/modules/video_output/opengl/vout_helper.c +++ b/modules/video_output/opengl/vout_helper.c @@ -658,12 +658,11 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt, .gl = vgl->gl, .api = &vgl->api, .glexts = extensions, - .orientation = fmt->orientation, + .fmt = *fmt, }; /* RGBA is needed for subpictures or for non YUV pictures */ - GLuint fshader = opengl_tex_converter_subpictures_init(fmt, - &vgl->sub_prgm->tc); + GLuint fshader = opengl_tex_converter_subpictures_init(&vgl->sub_prgm->tc); int ret = opengl_link_program(vgl->sub_prgm, fshader); if (ret != VLC_SUCCESS) { @@ -679,9 +678,9 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt, .gl = vgl->gl, .api = &vgl->api, .glexts = extensions, - .orientation = fmt->orientation, + .fmt = *fmt, }; - fshader = opengl_tex_converter_init_cbs[j](fmt, &vgl->prgm->tc); + fshader = opengl_tex_converter_init_cbs[j](&vgl->prgm->tc); ret = opengl_link_program(vgl->prgm, fshader); if (ret == VLC_SUCCESS) { @@ -706,7 +705,7 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt, return NULL; } - getOrientationTransformMatrix(vgl->prgm->tc.orientation, + getOrientationTransformMatrix(vgl->prgm->tc.fmt.orientation, vgl->prgm->var.OrientationMatrix); getViewpointMatrixes(vgl, vgl->fmt.projection_mode, vgl->prgm); @@ -901,7 +900,7 @@ picture_pool_t *vout_display_opengl_GetPool(vout_display_opengl_t *vgl, unsigned /* Allocate with tex converter pool callback if it exists */ if (tc->pf_get_pool != NULL) { - vgl->pool = tc->pf_get_pool(tc, &vgl->fmt, requested_count); + vgl->pool = tc->pf_get_pool(tc, requested_count); if (!vgl->pool) goto error; return vgl->pool; _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
