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

Use scaled integer array (ifld) in OpenJPEG version of enc_jpeg2000 #510

Merged
merged 4 commits into from
Sep 30, 2024

Conversation

DusanJovic-NOAA
Copy link
Contributor

@DusanJovic-NOAA DusanJovic-NOAA commented Sep 19, 2024

This PR fixes a bug in OpenJPEG version of enc_jpeg2000 routine by using scaled integer array instead of packed character buffer.

Fixes #518

@DusanJovic-NOAA
Copy link
Contributor Author

Test tst_jpeg tests these functions. This test currently pass because the range of values being encoded is such that scaled integers fit in one byte. However, if I make these changes in tst_jpeg:

diff --git a/tests/tst_jpeg.c b/tests/tst_jpeg.c
index 40789ce..ca24378 100644
--- a/tests/tst_jpeg.c
+++ b/tests/tst_jpeg.c
@@ -80,7 +80,7 @@ main()

         printf("Testing jpcpack()/jpcunpack() call...");
         {
-            float fld[DATA_LEN] = {1.0, 2.0, 3.0, 0.0};
+            float fld[DATA_LEN] = {100.0, 200.0, 300.0, 0.0};
             float fld_in[DATA_LEN];
             g2int lcpack = PACKED_LEN;
             g2int idrstmpl[7] = {0, 1, 1, 16, 0, 0, 0};
@@ -103,7 +103,7 @@ main()
         printf("ok!\n");
         printf("Testing g2c_jpcpackd()/g2c_jpcunpackd() call...");
         {
-            double fld[DATA_LEN] = {1.0, 2.0, 3.0, 0.0};
+            double fld[DATA_LEN] = {10000.0, 20000.0, 30000.0, 0.0};
             double fld_in[DATA_LEN];
             size_t lcpack_st = PACKED_LEN;
             int idrstmpl[7] = {0, 1, 1, 16, 0, 0, 0};
@@ -125,7 +125,7 @@ main()
         printf("ok!\n");
         printf("Testing g2c_jpcpackf()/g2c_jpcunpackf() call...");
         {
-            float fld[DATA_LEN] = {1.0, 2.0, 3.0, 0.0};
+            float fld[DATA_LEN] = {1000.0, 2000.0, 3000.0, 0.0};
             float fld_in[DATA_LEN];
             size_t lcpack_st = PACKED_LEN;
             int idrstmpl[7] = {0, 1, 1, 16, 0, 0, 0};

test fails in current develop branch.

I'll update this test in my branch.

@edwardhartnett edwardhartnett merged commit d680985 into NOAA-EMC:develop Sep 30, 2024
33 checks passed
@DusanJovic-NOAA DusanJovic-NOAA deleted the openjpeg_enc_fix branch September 30, 2024 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants