feelgood

09-08-2003, 08:52 PM

OK, I have an application that decodes YUV video

that is textured in GL (on a mac), I would like to

use ATI_text_fragment_shader for video processing

but I need to do a YUV -> RGB color conversion

using a shader first (stupid ATI). Here is what I have come up

with so far (currently goes from VUY -> BGR):

!!ATIfs1.0

StartConstants;

CONSTANT c0 = {1.16400, 1.59600, 2.01800, 0.81300};

CONSTANT c1 = {1.08175, 0.39100, 0.87075, 0.28375};

EndConstants;

StartPrelimPass;

SampleMap r1, t0.str;

MUL r1.r, c0.r, r1.r; # 1.16400 * Y

MUL r1.g, c0.b, r1.g; # 2.01800 * U

MUL r1.b, c0.a, r1.b; # 0.81300 * V

MUL r2.g, c1.g, r1.b; # 0.39100 * U

MUL r2.b, c0.g, r1.b; # 1.59600 * V

ADD r2.r, r1.r, r1.g; # 1.16400 * Y + 2.01800 * U

SUB r2.r, r2.r, c1.r; # 1.16400 * Y + 2.01800 * U - 1.08175

MOV r0.b, r2.r;

EndPass;

StartOutputPass;

PassTexCoord r1, r1.str;

PassTexCoord r2, r2.str;

ADD r2.r, r1.r, r1.b; # 1.16400 * Y + 0.81300 * V

SUB r2.r, r2.r, r2.g; # 1.16400 * Y + 0.81300 * V - 0.39100 * U

ADD r2.r, r2.r, c1.a; # 1.16400 * Y + 0.81300 * V - 0.39100 * U + 0.28375

MOV r0.g, r2.r;

ADD r2.r, r1.r, r1.b; # 1.16400 * Y + 1.59600 * V

SUB r2.r, r2.r, c1.b; # 1.16400 * Y + 1.59600 * V - 0.87075

MOV r0.b, r2.r;

EndPass;

Heh, the problem is that this does not currently work (everything is green), so any help at all (a working

shader anyone ???) is greatly appreciated...

that is textured in GL (on a mac), I would like to

use ATI_text_fragment_shader for video processing

but I need to do a YUV -> RGB color conversion

using a shader first (stupid ATI). Here is what I have come up

with so far (currently goes from VUY -> BGR):

!!ATIfs1.0

StartConstants;

CONSTANT c0 = {1.16400, 1.59600, 2.01800, 0.81300};

CONSTANT c1 = {1.08175, 0.39100, 0.87075, 0.28375};

EndConstants;

StartPrelimPass;

SampleMap r1, t0.str;

MUL r1.r, c0.r, r1.r; # 1.16400 * Y

MUL r1.g, c0.b, r1.g; # 2.01800 * U

MUL r1.b, c0.a, r1.b; # 0.81300 * V

MUL r2.g, c1.g, r1.b; # 0.39100 * U

MUL r2.b, c0.g, r1.b; # 1.59600 * V

ADD r2.r, r1.r, r1.g; # 1.16400 * Y + 2.01800 * U

SUB r2.r, r2.r, c1.r; # 1.16400 * Y + 2.01800 * U - 1.08175

MOV r0.b, r2.r;

EndPass;

StartOutputPass;

PassTexCoord r1, r1.str;

PassTexCoord r2, r2.str;

ADD r2.r, r1.r, r1.b; # 1.16400 * Y + 0.81300 * V

SUB r2.r, r2.r, r2.g; # 1.16400 * Y + 0.81300 * V - 0.39100 * U

ADD r2.r, r2.r, c1.a; # 1.16400 * Y + 0.81300 * V - 0.39100 * U + 0.28375

MOV r0.g, r2.r;

ADD r2.r, r1.r, r1.b; # 1.16400 * Y + 1.59600 * V

SUB r2.r, r2.r, c1.b; # 1.16400 * Y + 1.59600 * V - 0.87075

MOV r0.b, r2.r;

EndPass;

Heh, the problem is that this does not currently work (everything is green), so any help at all (a working

shader anyone ???) is greatly appreciated...