Quellcode durchsuchen

Added definable thread count. Fixed alignment.

Brucey vor 3 Jahren
Ursprung
Commit
638d404db3
1 geänderte Dateien mit 8 neuen und 5 gelöschten Zeilen
  1. 8 5
      jxl.mod/jxl.bmx

+ 8 - 5
jxl.mod/jxl.bmx

@@ -47,6 +47,12 @@ ModuleInfo "CC_OPTS: -DJPEGXL_PATCH_VERSION=0"
 
 
 Import "common.bmx"
 Import "common.bmx"
 
 
+Rem
+bbdoc: Number of threads to use during Jxl decoding.
+about: The default is to use only the current thread.
+End Rem
+Global JxlDecoderThreadCount:Int = 0
+
 Private
 Private
 
 
 Type TPixmapLoaderJXL Extends TPixmapLoader
 Type TPixmapLoaderJXL Extends TPixmapLoader
@@ -94,6 +100,7 @@ Type TJxlDecoder
 		End If
 		End If
 
 
 		runnerPtr = JxlResizableParallelRunnerCreate(Null)
 		runnerPtr = JxlResizableParallelRunnerCreate(Null)
+		JxlResizableParallelRunnerSetThreads(runnerPtr, Size_T(Max(0, JxlDecoderThreadCount)))
 
 
 		If bmx_jxl_JxlDecoderSetParallelRunner(decoderPtr, runnerPtr) <> JXL_DEC_SUCCESS Then
 		If bmx_jxl_JxlDecoderSetParallelRunner(decoderPtr, runnerPtr) <> JXL_DEC_SUCCESS Then
 			Return Null
 			Return Null
@@ -129,7 +136,7 @@ Type TJxlDecoder
 
 
 				If info.alpha_bits = 0 Then
 				If info.alpha_bits = 0 Then
 					format.num_channels = 3
 					format.num_channels = 3
-					format.align = 3
+					format.align = 4
 					pixFormat = PF_RGB888
 					pixFormat = PF_RGB888
 				End If
 				End If
 
 
@@ -142,10 +149,6 @@ Type TJxlDecoder
 					Return Null
 					Return Null
 				End If
 				End If
 
 
-				If bufferSize <> width * height * format.align Then
-					Return Null
-				End If
-
 				If JxlDecoderSetImageOutBuffer(decoderPtr, format, pix.pixels, Size_T(pix.capacity)) <> JXL_DEC_SUCCESS Then
 				If JxlDecoderSetImageOutBuffer(decoderPtr, format, pix.pixels, Size_T(pix.capacity)) <> JXL_DEC_SUCCESS Then
 					Return Null
 					Return Null
 				End If
 				End If