]> git.sesse.net Git - nageru/commitdiff
Fix a Clang 19 warning. master
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 13 May 2024 22:01:14 +0000 (00:01 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 13 May 2024 22:01:14 +0000 (00:01 +0200)
Clang rightfully pointed out that VLAs are a non-standard extension.
We can do just fine with three small heap allocations per software-decoded
JPEG (the main path is VA-API anyway).

futatabi/jpeg_frame_view.cpp

index 6ab19482fb93772956036c19175b6ecef36262e3..6dafb3e9ac7eb8adc5723a2cd61ab50a7b03de8c 100644 (file)
@@ -182,8 +182,10 @@ shared_ptr<Frame> decode_jpeg(const string &jpeg)
        }
 
        if (!error_mgr.run([&dinfo, &y_pix, &cb_pix, &cr_pix, pitch_y, pitch_chroma, v_mcu_size, mcu_height_blocks] {
-                   JSAMPROW yptr[v_mcu_size], cbptr[v_mcu_size], crptr[v_mcu_size];
-                   JSAMPARRAY data[3] = { yptr, cbptr, crptr };
+                   unique_ptr<JSAMPROW[]> yptr(new JSAMPROW[v_mcu_size]);
+                   unique_ptr<JSAMPROW[]> cbptr(new JSAMPROW[v_mcu_size]);
+                   unique_ptr<JSAMPROW[]> crptr(new JSAMPROW[v_mcu_size]);
+                   JSAMPARRAY data[3] = { yptr.get(), cbptr.get(), crptr.get() };
                    for (unsigned y = 0; y < mcu_height_blocks; ++y) {
                            // NOTE: The last elements of cbptr/crptr will be unused for vertically subsampled chroma.
                            for (unsigned yy = 0; yy < v_mcu_size; ++yy) {