text stringlengths 0 234 |
|---|
cb_val:= flat(Cb, xmb, ymb) - 128; |
cr_val:= flat(Cr, xmb, ymb) - 128; |
Out_Pixel_8( |
br => U8(Clip((y_val + 359 * cr_val + 128) / 256)), |
bg => U8(Clip((y_val - 88 * cb_val - 183 * cr_val + 128) / 256)), |
bb => U8(Clip((y_val + 454 * cb_val + 128) / 256)) |
); |
when Y_Grey => |
y_val_8:= U8(flat(Y, xmb, ymb)); |
Out_Pixel_8(y_val_8, y_val_8, y_val_8); |
when CMYK => |
-- !! find a working conversion formula. |
-- perhaps it is more complicated (APP_2 |
-- color profile must be used ?) |
c_val:= flat(Y, xmb, ymb); |
m_val:= flat(Cb, xmb, ymb); |
y_val:= flat(Cr, xmb, ymb); |
w_val:= flat(I, xmb, ymb)-255; |
Out_Pixel_8( |
br => U8(255-Clip(c_val+w_val)), |
bg => U8(255-Clip(m_val+w_val)), |
bb => U8(255-Clip(y_val+w_val)) |
); |
end case; |
end loop; |
end loop; |
end Color_transformation_and_output; |
-- |
procedure Ct_YCbCr is new Color_transformation_and_output(YCbCr); |
procedure Ct_Y_Grey is new Color_transformation_and_output(Y_Grey); |
procedure Ct_CMYK is new Color_transformation_and_output(CMYK); |
blk_idx: Integer; |
upsx, upsy: Natural; |
begin |
-- Step 4 happens here: Upsampling |
for c in Component loop |
if image.JPEG_stuff.components(c) then |
upsx:= info_A(c).up_factor_x; |
upsy:= info_A(c).up_factor_y; |
for x in reverse 1..info_A(c).samples_hor loop |
for y in reverse 1..info_A(c).samples_ver loop |
-- We are at the 8x8 block level |
blk_idx:= 63; |
for y8 in reverse 0..7 loop |
for x8 in reverse 0..7 loop |
declare |
val: constant Integer:= m(c,x,y)(blk_idx); |
big_pixel_x: constant Natural:= upsx * (x8 + 8*(x-1)); |
big_pixel_y: constant Natural:= upsy * (y8 + 8*(y-1)); |
begin |
-- Repeat pixels for component c, sample (x,y), |
-- position (x8,y8). |
for rx in reverse 0..upsx-1 loop |
for ry in reverse 0..upsy-1 loop |
flat(c, rx + big_pixel_x, ry + big_pixel_y):= val; |
end loop; |
end loop; |
Function Definition: procedure Read_SOS is |
Function Body: components, b, id_base: U8; |
compo: Component:= Component'First; |
mbx, mby: Natural:= 0; |
mbsizex, mbsizey, mbwidth, mbheight: Natural; |
rstcount: Natural:= image.JPEG_stuff.restart_interval; |
nextrst: U16:= 0; |
w: U16; |
start_spectral_selection, |
end_spectral_selection, |
successive_approximation: U8; |
begin |
Get_Byte(image.buffer, components); |
if some_trace then |
Put_Line( |
"Start of Scan (SOS), with" & U8'Image(components) & " components" |
); |
end if; |
if image.subformat_id /= Natural(components) then |
Raise_Exception( |
error_in_image_data'Identity, |
"JPEG: components mismatch in Scan segment" |
); |
end if; |
id_base := 1; |
for i in 1..components loop |
Get_Byte(image.buffer, b); |
if b = 0 then |
-- Workaround for bugged encoder (see above) |
id_base := 0; |
end if; |
if b - id_base > Component'Pos(Component'Last) then |
Raise_Exception(error_in_image_data'Identity, "Scan: invalid ID: " & U8'Image(b)); |
end if; |
compo:= Component'Val(b - id_base); |
if not image.JPEG_stuff.components(compo) then |
Raise_Exception( |
error_in_image_data'Identity, |
"JPEG: component " & Component'Image(compo) & |
" has not been defined in the header (SOF) segment" |
); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.