Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt6 reading JPEG encoded as Progressive using more memory (sometimes till out-of-memory) than Baseline
Forum Updated to NodeBB v4.3 + New Features

Qt6 reading JPEG encoded as Progressive using more memory (sometimes till out-of-memory) than Baseline

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 2 Posters 224 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wahabshah
    wrote last edited by wahabshah
    #1

    Hey all,

    • We are using Qt6 on an embedded device (ARM64 imx8) with limited RAM (total about 400MB).
    • While loading JPEG image (Iink) which is encoded as progressive in an Qt Widget application :-
      bailey.jpg: JPEG image data, JFIF standard 1.02, resolution (DPI), density 72x72, segment length 16, progressive, precision 8, 7360x4912, frames 3
      
    • using QImageReader::read to read image scaled to 30px x 30px instead of 7360px x4912px :-
       // Reader for JPEG
       QImageReader reader("bailey.jpg");
       reader.setScaledSize(QSize(30, 30)); // directly decode at 30x30
      
       QImage image30x30;
       if (!reader.read(&image30x30)) {
           qWarning() << "Failed to load:" << reader.errorString();
           return -1;
       }
      
      
    • Even though a scaled down version of image e.g 30px x 30px is asked
      • From my understanding that memory used during decompression (using IDCT shrink-on-load from libjpeg (link)) should be :-
        width × height × channels × bytes per channel = memory (MB)
        
      • calculation for above image :-
        7360 * 4912 * 3 * 1  = 103MB
        
      • But since we are asking for a scaled version so libjpeg would scale to 1/8 as its theoratical limit
        (7360 / 8 ) * (614 / 8) * 3 * 1 = 1.7MB
        
      • so expect it to maximum consume 1.7MB and not 103MB
      • may be i am wrong about it but this is just little knowledge of how i have it
    • During the read, it seems like it is loading whole image that it causes out-of-memory for kernel to kill the application eventually.
    • The default QJpegPlugin linked is libjpeg :-
      $ ldd /usr/lib/plugins/imageformats/libqjpeg.so 
      ...
      libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0x0000ffffbd350000)
      
    • But when same image was converted from progressive to baseline (Iink) then it did use some memory but not till out-of-memory
      bailey.jpg: JPEG image data, JFIF standard 1.02, resolution (DPI), density 72x72, segment length 16, baseline, precision 8, 7360x4912, components 3
      
    • Therefore the question is :-
      • does QJpegPlugin and eventually libjpeg can they handle progressive images efficiently or is it a bug or limitation of library itself?
      • or should we convert JPEG to baselines as it seems to respect the downscaling and not load whole image into memory ?
    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote last edited by
      #2

      Please provide a small jpeg and create a bug report. I can only think that libjpeg does either something wrong here or the Qt plugin does not handle a specific combination of parameters correctly.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • W Offline
        W Offline
        wahabshah
        wrote last edited by wahabshah
        #3
        • I added the links to the image in the description above but adding under again :-
          • https://gist.github.com/wahabshah/a36cd8524e098a58e3909cc5c3592436#jpeg-progressive
          • https://gist.github.com/wahabshah/a36cd8524e098a58e3909cc5c3592436#jpeg-baseline
        • yeah sure i added that as a bug to be checked by the Qt Team :-
          • https://bugreports.qt.io/browse/QTBUG-140124
        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved