YUV -> RGB is a relatively simple converstion:
R = Y + 1.403V
G = Y - 0.344U - 0.714V
B = Y + 1.770U
It seems to me that I re-wrote this as a Core Image Kernel using dot
products... but I can lay my hands on that source code just now. Here's an
untested example adapted from Ms. Black's QC Kitchen...
kernel vec4 yuv2rgb(sampler image)
{
const vec3 yuv_r = vec3(1.0000, 0.0000, 1.4022 );
const vec3 yuv_g = vec3(1.0000, -0.3457, -0.7145);
const vec3 yuv_b = vec3(1.0000, 1.7710, 0.0000);
vec4 pixel = sample(image, samplerCoord(image)); /* YUVA image */
vec3 pixel_yuv = pixel.xyz;
vec3 pel;
pel.r = dot(pixel_yuv,yuv_r);
pel.g = dot(pixel_yuv,yuv_g);
pel.b = dot(pixel_yuv,yuv_b);
return vec4(pel.r,pel.g,pel.b,pixel.a);
}
Hope that helps...
Patrick Sheffield
Sheffield Softworks
On Oct 5, 2011, at 12:55 PM, [email protected] wrote:
> You guessed it right and my first approach was to develop a provider but QC
> was raising an exception whenever it called the outputImageProvider...
> function. I got overwhelmed and decided to choose an easier approach, but yes
> you are right I should follow the right approach.
>
> Another reason for switching to consumer was the input image pixel format
> which is 2yuv... (from decklink) and the QCPlugin supports RGBA type formats
> and I don't have a clue how to make the conversion.
>
> I also saw your movieloader patch and its code which can be a great help so
> will try again tomorrow.
>
> Thanks
> Nisar
> *** This Message Has Been Sent Using BlackBerry Internet Service from
> Mobilink ***
>
> From: vade <[email protected]>
> Date: Wed, 05 Oct 2011 15:44:11 -0400
> To: Nisar Ahmed<[email protected]>
> Cc: Christopher Wright<[email protected]>; quartzcomposer-dev list
> list<[email protected]>
> Subject: Re: Drawing inside QC Plugin using CIContext
>
> It looks like you are outputting an image from a decklink card (I am assuming
> this is going to be for a digitizer / video input replacement?)
>
> Assuming my assumption is correct, why not output the CVPIxelBufferRef ? It
> looks like you create one from the decklink IDeckLinkVideoInputFrame handler
> in your decklink callback, and make the patch be a provider, rather than a
> consumer and use the factory method
>
> outputImageProviderFromBufferWithPixelFormat:pixelsWide:pixelsHigh:baseAddress:bytesPerRow:releaseCallback:releaseContext:colorSpace:shouldColorMatch,
> or a custom QCPLuginOutputImageProvider class you implement and just output
> an image :)
>
> QC will handle everything else you need and you can additionally use image
> filters, CI Filters and GLSL shaders on your output image.
>
>
>
>
> On Oct 5, 2011, at 12:08 PM, Nisar Ahmed wrote:
>
>> Yes you are correct, I added this and it worked but.....
>>
>> //Creating image from a CVImageBufferRef
>> (Format=PAL)
>> image = [[CIImage alloc] initWithCVImageBuffer:pixelBuffer];
>>
>> //Resizing width and height of image to match input port's
>> width and height
>> width = [image extent].size.width*(self.inputWidth/2.0);
>> height = [image extent].size.height*(self.inputHeight/2.0);
>>
>> glViewport(self.inputX, self.inputY, width, height);
>> glMatrixMode(GL_MODELVIEW);
>> glLoadIdentity();
>>
>> glMatrixMode(GL_PROJECTION);
>> glLoadIdentity();
>> glOrtho(0, width, 0, height, -1.0, 1.0);
>> [ciContext drawImage:image inRect:CGRectMake(0, 0, width,
>> height) fromRect:[image extent]];
>>
>> Now I can see correct image inside. BUT the whole of QC View background is
>> painted in White and it's no more transparent like in other consumer
>> patches. The image in question is in PAL format.
>>
>> I have also attached a screen shot for reference
>>
>> Thank you
>> Nisar
>>
>>
>>
>> On Wed, Oct 5, 2011 at 8:27 PM, Christopher Wright
>> <[email protected]> wrote:
>>> Now I am a little confused about inRect and fromRect parameters of
>>> drawImage since the coordinate system is different and which OpenGL
>>> function should I include or remove from this function for it to work.
>>>
>>> I can only see a blank screen on top right corner of QC View
>>
>> You'll probably want to change the Projection matrix, since QC will have it
>> set to something you probably aren't interested in.
>>
>> --
>> Christopher Wright
>> [email protected]
>>
>>
>> <Screen shot 2011-10-05 at 9.07.16 PM.png>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Quartzcomposer-dev mailing list ([email protected])
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/quartzcomposer-dev/doktorp%40mac.com
>>
>> This email sent to [email protected]
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Quartzcomposer-dev mailing list ([email protected])
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/quartzcomposer-dev/psheffield%40earthlink.net
>
> This email sent to [email protected]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com
This email sent to [email protected]