Re: Optimisation OT
- From: "Nils Haeck" <bla@xxxxxxx>
- Date: Thu, 17 May 2007 01:48:33 +0200
This conversion should be correct.. can you test? It adds a few int
multiplications, which can be avoided by adding another set of tables. But I
don't want to do that before I know for sure this one works.
Nils
procedure TsdTransformYCCKToRGBAdobe.Transform(Source, Dest: pointer;
Count: integer);
// YCCK to RGB for Adobe images is different. First, the Y, Cr and Cb are
inverted,
// and k* = 220 - K. The normal YCbCr to RGB is then applied. As a last
step,
// the values are scaled by 0.65 around 128
const
c0_65: integer = round(0.65 * cColorConvScale);
c44_8: integer = round(44.8 * cColorConvScale);// 128 - 0.65 * 128
var
R, G, B, Y, Cb, Cr, K: PByte;
Yi, Ki, Ri, Gi, Bi, Cbi, Cri: integer;
function ScaleAndRangeLimit(A: integer): integer;
begin
// First the scaling
A := (A * c0_65) div cColorConvScale + c44_8;
// Undo fixed precision and range limit
Result := A div cColorConvScale;
if Result < 0 then
Result := 0
else
if Result > 255 then
Result := 255;
end;
begin
Y := Source;
Cb := Source; inc(Cb);
Cr := Source; inc(Cr, 2);
K := Source; inc(K, 3);
// RGB is layed out in memory as BGR
B := Dest;
G := Dest; inc(G);
R := Dest; inc(R, 2);
// Repeat Count times..
while Count > 0 do
begin
// Do the conversion in int
Yi := cY_toRT[255 - Y^];
Cbi := 255 - Cb^;
Cri := 255 - Cr^;
Ki := (220 - K^) * cColorConvScale;
Ri := Yi + cCrtoRT[Cri] + c__toR - Ki;
Gi := Yi + cCbToGT[Cbi] + cCrtoGT[Cri] + c__toG - Ki;
Bi := Yi + cCbtoBT[Cbi] + c__toB - Ki;
R^ := ScaleAndRangeLimit(Ri);
G^ := ScaleAndRangeLimit(Gi);
B^ := ScaleAndRangeLimit(Bi);
// Advance pointers
inc(Y, 4); inc(Cb, 4); inc(Cr, 4); inc(K, 4);
inc(R, 3); inc(G, 3); inc(B, 3);
dec(Count);
end;
end;
.
- Follow-Ups:
- Re: Optimisation OT
- From: Sanyin
- Re: Optimisation OT
- References:
- Optimisation
- From: Sanyin
- Re: Optimisation
- From: Nils Haeck
- Re: Optimisation OT
- From: Sanyin
- Optimisation
- Prev by Date: Re: Optimisation
- Next by Date: Any known fast hash algorithms ?
- Previous by thread: Re: Optimisation OT
- Next by thread: Re: Optimisation OT
- Index(es):
Relevant Pages
|