[PATCH xserver 3/3] glamor: add support for NV12 in Xv
Matt Turner
mattst88 at gmail.com
Tue Sep 11 15:41:38 UTC 2018
On Thu, Sep 6, 2018 at 3:40 PM Julien Isorce <julien.isorce at gmail.com> wrote:
>
> Useful when video decoders only support NV12. Currently
> glamor Xv only supports I420 and YV12.
>
> Note that Intel's sna supports I420, YV12, YUY2, UYVY, NV12.
>
> Test: xvinfo | grep NV12
> Test: gst-launch-1.0 videotestsrc ! video/x-raw, format=NV12 ! xvimagesink
>
> Signed-off-by: Julien Isorce <jisorce at oblong.com>
> ---
> glamor/glamor_xv.c | 180 +++++++++++++++++++++++++++++++++++++++++++++--------
> 1 file changed, 155 insertions(+), 25 deletions(-)
>
> diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
> index 62fc4ff..5631293 100644
> --- a/glamor/glamor_xv.c
> +++ b/glamor/glamor_xv.c
> @@ -59,8 +59,40 @@ typedef struct tagREF_TRANSFORM {
> #define RTFContrast(a) (1.0 + ((a)*1.0)/1000.0)
> #define RTFHue(a) (((a)*3.1416)/1000.0)
>
> -static const glamor_facet glamor_facet_xv_planar = {
> - .name = "xv_planar",
> +static const glamor_facet glamor_facet_xv_planar_2 = {
> + .name = "xv_planar_2",
> +
> + .version = 120,
> +
> + .source_name = "v_texcoord0",
> + .vs_vars = ("attribute vec2 position;\n"
> + "attribute vec2 v_texcoord0;\n"
> + "varying vec2 tcs;\n"),
> + .vs_exec = (GLAMOR_POS(gl_Position, position)
> + " tcs = v_texcoord0;\n"),
> +
> + .fs_vars = ("uniform sampler2D y_sampler;\n"
> + "uniform sampler2D u_sampler;\n"
> + "uniform vec4 offsetyco;\n"
> + "uniform vec4 ucogamma;\n"
> + "uniform vec4 vco;\n"
> + "varying vec2 tcs;\n"),
> + .fs_exec = (
> + " float sample;\n"
> + " vec4 temp1;\n"
> + " sample = texture2D(y_sampler, tcs).w;\n"
> + " temp1.xyz = offsetyco.www * vec3(sample) + offsetyco.xyz;\n"
> + " sample = texture2D(u_sampler, tcs).x;\n"
> + " temp1.xyz = ucogamma.xyz * vec3(sample) + temp1.xyz;\n"
> + " sample = texture2D(u_sampler, tcs).y;\n"
Might as well combine the two texture2Ds on u_sampler. I expect most
GLSL compilers will be able to combine them into one operation, but
there's no point in leaving it to chance.
More information about the xorg-devel
mailing list