PyTurboJPEG 2.2.0__tar.gz → 2.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyturbojpeg-2.2.0 → pyturbojpeg-2.3.0}/PKG-INFO +1 -1
- {pyturbojpeg-2.2.0 → pyturbojpeg-2.3.0}/PyTurboJPEG.egg-info/PKG-INFO +1 -1
- {pyturbojpeg-2.2.0 → pyturbojpeg-2.3.0}/setup.py +1 -1
- {pyturbojpeg-2.2.0 → pyturbojpeg-2.3.0}/turbojpeg.py +20 -18
- {pyturbojpeg-2.2.0 → pyturbojpeg-2.3.0}/LICENSE +0 -0
- {pyturbojpeg-2.2.0 → pyturbojpeg-2.3.0}/PyTurboJPEG.egg-info/SOURCES.txt +0 -0
- {pyturbojpeg-2.2.0 → pyturbojpeg-2.3.0}/PyTurboJPEG.egg-info/dependency_links.txt +0 -0
- {pyturbojpeg-2.2.0 → pyturbojpeg-2.3.0}/PyTurboJPEG.egg-info/requires.txt +0 -0
- {pyturbojpeg-2.2.0 → pyturbojpeg-2.3.0}/PyTurboJPEG.egg-info/top_level.txt +0 -0
- {pyturbojpeg-2.2.0 → pyturbojpeg-2.3.0}/README.md +0 -0
- {pyturbojpeg-2.2.0 → pyturbojpeg-2.3.0}/setup.cfg +0 -0
- {pyturbojpeg-2.2.0 → pyturbojpeg-2.3.0}/tests/test_turbojpeg.py +0 -0
|
@@ -2,7 +2,7 @@ import io
|
|
|
2
2
|
from setuptools import setup, find_packages
|
|
3
3
|
setup(
|
|
4
4
|
name='PyTurboJPEG',
|
|
5
|
-
version='2.
|
|
5
|
+
version='2.3.0',
|
|
6
6
|
description='A Python wrapper of libjpeg-turbo for decoding and encoding JPEG image.',
|
|
7
7
|
author='Lilo Huang',
|
|
8
8
|
author_email='kuso.cc@gmail.com',
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
# SOFTWARE.
|
|
24
24
|
|
|
25
25
|
__author__ = 'Lilo Huang <kuso.cc@gmail.com>'
|
|
26
|
-
__version__ = '2.
|
|
26
|
+
__version__ = '2.3.0'
|
|
27
27
|
|
|
28
28
|
from ctypes import *
|
|
29
29
|
from ctypes.util import find_library
|
|
@@ -305,12 +305,12 @@ def fill_background(coeffs_ptr, arrayRegion, planeRegion, componentID, transform
|
|
|
305
305
|
min(arrayRegion.y+arrayRegion.h, background_data.h)
|
|
306
306
|
- arrayRegion.y
|
|
307
307
|
)
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
308
|
+
y_start = left_start_row // MCU_HEIGHT
|
|
309
|
+
y_end = left_end_row // MCU_HEIGHT
|
|
310
|
+
x_start = background_data.w // MCU_WIDTH
|
|
311
|
+
x_end = planeRegion.w // MCU_WIDTH
|
|
312
|
+
if y_end > y_start and x_end > x_start:
|
|
313
|
+
coeffs[y_start:y_end, x_start:x_end, 0] = background_data.lum
|
|
314
314
|
|
|
315
315
|
# fill mcus under image
|
|
316
316
|
bottom_start_row = (
|
|
@@ -320,12 +320,11 @@ def fill_background(coeffs_ptr, arrayRegion, planeRegion, componentID, transform
|
|
|
320
320
|
max(arrayRegion.y+arrayRegion.h, background_data.h)
|
|
321
321
|
- arrayRegion.y
|
|
322
322
|
)
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
coeffs[y][x][0] = background_data.lum
|
|
323
|
+
y_start = bottom_start_row // MCU_HEIGHT
|
|
324
|
+
y_end = bottom_end_row // MCU_HEIGHT
|
|
325
|
+
x_end = planeRegion.w // MCU_WIDTH
|
|
326
|
+
if y_end > y_start and x_end > 0:
|
|
327
|
+
coeffs[y_start:y_end, 0:x_end, 0] = background_data.lum
|
|
329
328
|
|
|
330
329
|
return 1
|
|
331
330
|
|
|
@@ -1311,6 +1310,8 @@ class TurboJPEG(object):
|
|
|
1311
1310
|
|
|
1312
1311
|
# Define crop transforms from cropping_regions
|
|
1313
1312
|
crop_transforms = (TransformStruct * number_of_operations)()
|
|
1313
|
+
# Pre-compute luminance coefficient once for all crops
|
|
1314
|
+
lum_coefficient = None
|
|
1314
1315
|
for i, crop_region in enumerate(crop_regions):
|
|
1315
1316
|
# The fill_background callback is slow, only use it if needed
|
|
1316
1317
|
if self.__need_fill_background(
|
|
@@ -1318,14 +1319,16 @@ class TurboJPEG(object):
|
|
|
1318
1319
|
(image_width, image_height),
|
|
1319
1320
|
background_luminance
|
|
1320
1321
|
):
|
|
1322
|
+
if lum_coefficient is None:
|
|
1323
|
+
lum_coefficient = self.__map_luminance_to_dc_dct_coefficient(
|
|
1324
|
+
bytearray(jpeg_buf),
|
|
1325
|
+
background_luminance
|
|
1326
|
+
)
|
|
1321
1327
|
# Use callback to fill in background post-transform
|
|
1322
1328
|
callback_data = BackgroundStruct(
|
|
1323
1329
|
image_width,
|
|
1324
1330
|
image_height,
|
|
1325
|
-
|
|
1326
|
-
bytearray(jpeg_buf),
|
|
1327
|
-
background_luminance
|
|
1328
|
-
)
|
|
1331
|
+
lum_coefficient
|
|
1329
1332
|
)
|
|
1330
1333
|
callback = CUSTOMFILTER(fill_background)
|
|
1331
1334
|
crop_transforms[i] = TransformStruct(
|
|
@@ -1350,7 +1353,6 @@ class TurboJPEG(object):
|
|
|
1350
1353
|
|
|
1351
1354
|
def buffer_size(self, img_array, jpeg_subsample=TJSAMP_422):
|
|
1352
1355
|
"""Get maximum number of bytes of compressed jpeg data"""
|
|
1353
|
-
img_array = np.ascontiguousarray(img_array)
|
|
1354
1356
|
height, width = img_array.shape[:2]
|
|
1355
1357
|
return self.__buffer_size(width, height, jpeg_subsample)
|
|
1356
1358
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|