[Lazarus] Using libjpeg

Sandro Cumerlato sandro.cumerlato at gmail.com
Mon Apr 18 15:12:26 CEST 2016


Hello Marc,
images are preloaded into separated memory streams, the core part of the
comparison is performed by a separated thread:

procedure TMyThread.Execute;
var
  jpegDecompressor: tjhandle;
  jpegWidth: cint;
  jpegHeight: cint;
  jpegSubsamp: cint;
begin
  while (not Terminated) do
  begin
    case FTest of
      1 : begin // LCL
        FPicture := TPicture.Create;
        Images[FIndex].Position:=0;
        FPicture.LoadFromStream(Images[FIndex]);

        if (not Terminated) then
          Synchronize(@ShowBitmap);

        FPicture.Free;
      end;
      2 : begin // libjpeg-turbo
        FPicture := TPicture.Create;
        FPicture.Bitmap.PixelFormat:=pf24bit;

        jpegDecompressor := tjInitDecompress();
        tjDecompressHeader2(jpegDecompressor, Images[FIndex].Memory,
Images[FIndex].Size, @jpegWidth, @jpegHeight, @jpegSubsamp);
        FPicture.Bitmap.SetSize(jpegWidth,jpegHeight);
        tjDecompress2(jpegDecompressor, Images[FIndex].Memory,
Images[FIndex].Size, FPicture.Bitmap.RawImage.Data, jpegWidth, 0,
jpegHeight, cint(TJPF_BGR), TJFLAG_FASTDCT);
        tjDestroy(jpegDecompressor);

        if (not Terminated) then
          Synchronize(@ShowBitmap);

        FPicture.Free;
      end;
    end;
    inc(FIndex);
    if (FIndex > high(Images)) then FIndex := low(Images);
  end;
end;



http://pasteboard.co/hlatrJG.png

Suggestions are welcome!

Sandro Cumerlato




On 18 April 2016 at 13:28, Marc Weustink <marc at dommelstein.nl> wrote:

> Sandro Cumerlato wrote:
>
>> Hello Ara, my tests with libjpeg-/turbo/are even more promising.
>>
>> The following comparison between LCL and libjpeg-/turbo/ was made
>> decompressing for about one minute a sequence of several 4000x3000 JPEG
>> pictures. The results are expressed in "pictures per second" and prove
>> that libjpeg-/turbo/ is about 7-8 times faster than LCL:
>>
>
> How did you compare ?
>
> IE, whats the source ?
>
> Marc
>
>
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20160418/4ccf18dc/attachment-0003.html>


More information about the Lazarus mailing list