Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imagecodecs v2023.3.16 #79

Conversation

regro-cf-autotick-bot
Copy link
Contributor

It is very likely that the current package version for this feedstock is out of date.

Checklist before merging this PR:

  • Dependencies have been updated if changed: see upstream
  • Tests have passed
  • Updated license if changed and license_file is packaged

Information about this PR:

  1. Feel free to push to the bot's branch to update this PR if needed.
  2. The bot will almost always only open one PR per version.
  3. The bot will stop issuing PRs if more than 3 version bump PRs generated by the bot are open. If you don't want to package a particular version please close the PR.
  4. If you want these PRs to be merged automatically, make an issue with @conda-forge-admin,please add bot automerge in the title and merge the resulting PR. This command will add our bot automerge feature to your feedstock.
  5. If this PR was opened in error or needs to be updated please add the bot-rerun label to this PR. The bot will close this PR and schedule another one. If you do not have permissions to add this label, you can use the phrase @conda-forge-admin, please rerun bot in a PR comment to have the conda-forge-admin add it for you.

Pending Dependency Version Updates

Here is a list of all the pending dependency version updates for this repo. Please double check all dependencies before merging.

Name Upstream Version Current Version
lerc 4.0.1 Anaconda-Server Badge
libjpeg-turbo 9e Anaconda-Server Badge

Dependency Analysis

We couldn't run dependency analysis due to an internal error in the bot. :/ Help is very welcome!

This PR was created by the regro-cf-autotick-bot. The regro-cf-autotick-bot is a service to automatically track the dependency graph, migrate packages, and propose package version updates for conda-forge. Feel free to drop us a line if there are any issues! This PR was generated by https://github.com/regro/cf-scripts/actions/runs/4443892489, please use this URL for debugging.

@conda-forge-webservices
Copy link
Contributor

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipe) and found it was in an excellent condition.

@hmaarrfk
Copy link
Contributor

I think we need to use jpeg turbo with 12 bit. but that is only in beta.

cgohlke/imagecodecs#65

@martindurant
Copy link

PING: anything that can be done to unstick this? I would like to see SZIP released.

@hmaarrfk
Copy link
Contributor

Patch out 12 bit jpeg? Or find the appropriate flag to disable this.

I don't want to release pre-release libjpegturbo yet

@martindurant
Copy link

@cgohlke , thoughts?

@cgohlke
Copy link

cgohlke commented Mar 31, 2023

I presume removing the 12-bit, 16-bit, and lossless code paths should work (not tested).

diff --git a/imagecodecs/_jpeg8.pyx b/imagecodecs/_jpeg8.pyx
index 09191ac..31a6260 100644
--- a/imagecodecs/_jpeg8.pyx
+++ b/imagecodecs/_jpeg8.pyx
@@ -124,8 +124,6 @@ def jpeg8_encode(
         my_error_mgr err
         jpeg_compress_struct cinfo
         JSAMPROW rowpointer8
-        J12SAMPROW rowpointer12
-        J16SAMPROW rowpointer16
         J_COLOR_SPACE in_color_space = JCS_UNKNOWN
         J_COLOR_SPACE jpeg_color_space = JCS_UNKNOWN
         unsigned long outsize = 0
@@ -139,7 +137,7 @@ def jpeg8_encode(
         int predictor_selection_value = 0
 
     if not (
-        (src.dtype == numpy.uint8 or src.dtype == numpy.uint16)
+        src.dtype == numpy.uint8
         and src.ndim in (2, 3)
         # src.nbytes < 2 ** 31 and  # limit to 2 GB
         and samples in (1, 3, 4)
@@ -148,21 +146,6 @@ def jpeg8_encode(
     ):
         raise ValueError('invalid data shape, strides, or dtype')
 
-    if lossless:
-        predictor_selection_value = 1 if predictor is None else predictor
-
-    if bitspersample is not None:
-        if (
-            bitspersample not in (8, 12, 16)
-            or src.itemsize == 1 and bitspersample > 8
-        ):
-            raise ValueError(f'invalid bitspersample {bitspersample}')
-        data_precision = bitspersample
-
-    # if validate and bitspersample == 12 and not _check_range(src):
-    #     # values larger than 12-bit cause segfault
-    #     raise ValueError('all data values must be < 4096')
-
     if colorspace is not None:
         in_color_space = _jcs_colorspace(colorspace)
         if samples not in _jcs_colorspace_samples(in_color_space):
@@ -235,7 +218,6 @@ def jpeg8_encode(
         cinfo.image_height = <JDIMENSION> src.shape[0]
         cinfo.image_width = <JDIMENSION> src.shape[1]
         cinfo.input_components = samples
-        cinfo.data_precision = data_precision
 
         if in_color_space != JCS_UNKNOWN:
             cinfo.in_color_space = in_color_space
@@ -246,43 +228,27 @@ def jpeg8_encode(
         jpeg_mem_dest(&cinfo, &outbuffer, &outsize)  # must call after defaults
         jpeg_set_quality(&cinfo, quality, 1)
 
-        if predictor_selection_value > 0:
-            jpeg_enable_lossless(&cinfo, predictor_selection_value, 0)
-        else:
-            if smoothing_factor >= 0:
-                cinfo.smoothing_factor = smoothing_factor
-            if optimize_coding >= 0:
-                cinfo.optimize_coding = <boolean> optimize_coding
-            if h_samp_factor != 0:
-                cinfo.comp_info[0].h_samp_factor = h_samp_factor
-                cinfo.comp_info[0].v_samp_factor = v_samp_factor
-                cinfo.comp_info[1].h_samp_factor = 1
-                cinfo.comp_info[1].v_samp_factor = 1
-                cinfo.comp_info[2].h_samp_factor = 1
-                cinfo.comp_info[2].v_samp_factor = 1
+        if smoothing_factor >= 0:
+            cinfo.smoothing_factor = smoothing_factor
+        if optimize_coding >= 0:
+            cinfo.optimize_coding = <boolean> optimize_coding
+        if h_samp_factor != 0:
+            cinfo.comp_info[0].h_samp_factor = h_samp_factor
+            cinfo.comp_info[0].v_samp_factor = v_samp_factor
+            cinfo.comp_info[1].h_samp_factor = 1
+            cinfo.comp_info[1].v_samp_factor = 1
+            cinfo.comp_info[2].h_samp_factor = 1
+            cinfo.comp_info[2].v_samp_factor = 1
 
         # TODO: add option to use or return JPEG tables
 
         jpeg_start_compress(&cinfo, 1)
 
-        if cinfo.data_precision == 8:
-            while cinfo.next_scanline < cinfo.image_height:
-                rowpointer8 = <JSAMPROW> (
-                    <char*> src.data + cinfo.next_scanline * rowstride
-                )
-                jpeg_write_scanlines(&cinfo, &rowpointer8, 1)
-        elif cinfo.data_precision == 12:
-            while cinfo.next_scanline < cinfo.image_height:
-                rowpointer12 = <J12SAMPROW> (
-                    <char*> src.data + cinfo.next_scanline * rowstride
-                )
-                jpeg12_write_scanlines(&cinfo, &rowpointer12, 1)
-        elif cinfo.data_precision == 16:
-            while cinfo.next_scanline < cinfo.image_height:
-                rowpointer16 = <J16SAMPROW> (
-                    <char*> src.data + cinfo.next_scanline * rowstride
-                )
-                jpeg16_write_scanlines(&cinfo, &rowpointer16, 1)
+        while cinfo.next_scanline < cinfo.image_height:
+            rowpointer8 = <JSAMPROW> (
+                <char*> src.data + cinfo.next_scanline * rowstride
+            )
+            jpeg_write_scanlines(&cinfo, &rowpointer8, 1)
 
         jpeg_finish_compress(&cinfo)
         jpeg_destroy_compress(&cinfo)
@@ -320,8 +286,6 @@ def jpeg8_decode(
         my_error_mgr err
         jpeg_decompress_struct cinfo
         JSAMPROW rowpointer8
-        J12SAMPROW rowpointer12
-        J16SAMPROW rowpointer16
         J_COLOR_SPACE jpeg_color_space
         J_COLOR_SPACE out_color_space
         JDIMENSION width = 0
@@ -398,31 +362,16 @@ def jpeg8_decode(
 
             # TODO: allow strides
 
-            if cinfo.data_precision <= 8:
-                out = _create_array(out, shape, numpy.uint8)
-            else:
-                out = _create_array(out, shape, numpy.uint16)
+            out = _create_array(out, shape, numpy.uint8)
             dst = out
             dstsize = dst.nbytes
             rowstride = dst.strides[0] // dst.itemsize
 
         memset(<void*> dst.data, 0, dstsize)
-        if cinfo.data_precision <= 8:
-            rowpointer8 = <JSAMPROW> dst.data
-            while cinfo.output_scanline < cinfo.output_height:
-                jpeg_read_scanlines(&cinfo, &rowpointer8, 1)
-                rowpointer8 += rowstride
-        elif cinfo.data_precision == 12:
-            rowpointer12 = <J12SAMPROW> dst.data
-            while cinfo.output_scanline < cinfo.output_height:
-                jpeg12_read_scanlines(&cinfo, &rowpointer12, 1)
-                rowpointer12 += rowstride
-        else:
-            # elif cinfo.data_precision == 16:
-            rowpointer16 = <J16SAMPROW> dst.data
-            while cinfo.output_scanline < cinfo.output_height:
-                jpeg16_read_scanlines(&cinfo, &rowpointer16, 1)
-                rowpointer16 += rowstride
+        rowpointer8 = <JSAMPROW> dst.data
+        while cinfo.output_scanline < cinfo.output_height:
+            jpeg_read_scanlines(&cinfo, &rowpointer8, 1)
+            rowpointer8 += rowstride
         jpeg_finish_decompress(&cinfo)
         jpeg_destroy_decompress(&cinfo)
 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants