[TCSACR-490][ImageUtil] Support JPEG XL image encoder, decoder 27/277327/5
authorHaesu Gwon <haesu.gwon@samsung.com>
Tue, 5 Jul 2022 07:28:55 +0000 (16:28 +0900)
committerHaesu Gwon <haesu.gwon@samsung.com>
Mon, 25 Jul 2022 02:59:53 +0000 (02:59 +0000)
Change-Id: Ie4d77b7298d7c94ecb80889f3e35f7a1f5415e36

tct-suite-vs/Tizen.MultimediaUtil.Tests/res/test_jxl.jxl [new file with mode: 0755]
tct-suite-vs/Tizen.MultimediaUtil.Tests/testcase/ImageUtil/TSImageDecoder.cs
tct-suite-vs/Tizen.MultimediaUtil.Tests/testcase/ImageUtil/TSImageEncoder.cs
tct-suite-vs/Tizen.MultimediaUtil.Tests/testcase/ImageUtil/TSJpegXlDecoder.cs [new file with mode: 0755]
tct-suite-vs/Tizen.MultimediaUtil.Tests/testcase/ImageUtil/TSJpegXlEncoder.cs [new file with mode: 0644]
tct-suite-vs/Tizen.MultimediaUtil.Tests/testcase/support/ImageUtilConstants.cs

diff --git a/tct-suite-vs/Tizen.MultimediaUtil.Tests/res/test_jxl.jxl b/tct-suite-vs/Tizen.MultimediaUtil.Tests/res/test_jxl.jxl
new file mode 100755 (executable)
index 0000000..70c7665
Binary files /dev/null and b/tct-suite-vs/Tizen.MultimediaUtil.Tests/res/test_jxl.jxl differ
index 0ac20b3..cb17c13 100755 (executable)
@@ -21,6 +21,7 @@ namespace Tizen.Multimedia.Util.Tests
         private BmpDecoder _bmpDecoder;
         private GifDecoder _gifDecoder;
         private JpegDecoder _jpegDecoder;
+        private JpegXlDecoder _jpegXlDecoder;
         private PngDecoder _pngDecoder;
         private WebPDecoder _webPDecoder;
         private HeifDecoder _heifDecoder;
@@ -31,12 +32,15 @@ namespace Tizen.Multimedia.Util.Tests
             _bmpDecoder = new BmpDecoder();
             _gifDecoder = new GifDecoder();
             _jpegDecoder = new JpegDecoder();
+            _jpegXlDecoder = new JpegXlDecoder();
             _pngDecoder = new PngDecoder();
             _webPDecoder = new WebPDecoder();
             _heifDecoder = new HeifDecoder();
+
             Assert.IsNotNull(_bmpDecoder, "Object(BmpDecoder) should not be null to start test");
             Assert.IsNotNull(_gifDecoder, "Object(GifDecoder) should not be null to start test");
             Assert.IsNotNull(_jpegDecoder, "Object(JpegDecoder) should not be null to start test");
+            Assert.IsNotNull(_jpegXlDecoder, "Object(JpegXlDecoder) should not be null to start test");
             Assert.IsNotNull(_pngDecoder, "Object(PngDecoder) should not be null to start test");
             Assert.IsNotNull(_webPDecoder, "Object(WebPDecoder) should not be null to start test");
             Assert.IsNotNull(_heifDecoder, "Object(HeifDecoder) should not be null to start test");
@@ -45,12 +49,13 @@ namespace Tizen.Multimedia.Util.Tests
         [TearDown]
         public void Destroy()
         {
-            _bmpDecoder.Dispose();
-            _gifDecoder.Dispose();
-            _jpegDecoder.Dispose();
-            _pngDecoder.Dispose();
-            _webPDecoder.Dispose();
-            _heifDecoder.Dispose();
+            _bmpDecoder?.Dispose();
+            _gifDecoder?.Dispose();
+            _jpegDecoder?.Dispose();
+            _jpegXlDecoder?.Dispose();
+            _pngDecoder?.Dispose();
+            _webPDecoder?.Dispose();
+            _heifDecoder?.Dispose();
         }
 
         [Test]
@@ -330,6 +335,36 @@ namespace Tizen.Multimedia.Util.Tests
         }
 
         [Test]
+        [Category("P1")]
+        [Description("Decode jpegxl image using input buffer")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ImageDecoder.DecodeAsync M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        [Property("COVPARAM", "byte[]")]
+        public async Task DecodeAsync_INPUTBUFFER_JPEGXL_CHECK_RETURN_VALUE()
+        {
+            var frame = (await _jpegXlDecoder.DecodeAsync(File.ReadAllBytes(ImageUtilConstants.JpegXlPath))).FirstOrDefault();
+
+            Assert.That(frame.Size.Height, Is.Positive);
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Decode jpegxl image using input path")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ImageDecoder.DecodeAsync M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        [Property("COVPARAM", "string")]
+        public async Task DecodeAsync_INPUTPATH_JPEGXL_CHECK_RETURN_VALUE()
+        {
+            var frame = (await _jpegXlDecoder.DecodeAsync(ImageUtilConstants.JpegXlPath)).FirstOrDefault();
+
+            Assert.That(frame.Size.Height, Is.Positive);
+        }
+
+        [Test]
         [Category("P2")]
         [Description("Check if it throws argument exception for setting color space with an invalid color space value")]
         [Property("SPEC", "Tizen.Multimedia.Util.ImageDecoder.SetColorSpace M")]
@@ -439,5 +474,17 @@ namespace Tizen.Multimedia.Util.Tests
         {
             Assert.That(_heifDecoder.InputFormat, Is.EqualTo(ImageFormat.Heif));
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("Get input format for jpegxl object")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ImageDecoder.InputFormat A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRE")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void InputFormat_PROPERTY_GET_ENUM_IMAGEFORMAT_JPEGXL()
+        {
+            Assert.That(_jpegXlDecoder.InputFormat, Is.EqualTo(ImageFormat.JpegXl));
+        }
     }
 }
index 8f43c80..2120159 100755 (executable)
@@ -23,7 +23,9 @@ namespace Tizen.Multimedia.Util.Tests
         private BmpEncoder _bmpEncoder;
         private GifEncoder _gifEncoder;
         private JpegEncoder _jpegEncoder;
+        private JpegXlEncoder _jpegXlEncoder;
         private PngEncoder _pngEncoder;
+        private WebPEncoder _webPEncoder;
 
         [SetUp]
         public void Init()
@@ -31,20 +33,27 @@ namespace Tizen.Multimedia.Util.Tests
             _bmpEncoder = new BmpEncoder();
             _gifEncoder = new GifEncoder();
             _jpegEncoder = new JpegEncoder();
+            _jpegXlEncoder = new JpegXlEncoder();
             _pngEncoder = new PngEncoder();
+            _webPEncoder = new WebPEncoder();
+
             Assert.IsNotNull(_bmpEncoder, "Object(BmpEncoder) should not be null to start test");
             Assert.IsNotNull(_gifEncoder, "Object(GifEncoder) should not be null to start test");
             Assert.IsNotNull(_jpegEncoder, "Object(JpegEncoder) should not be null to start test");
+            Assert.IsNotNull(_jpegXlEncoder, "Object(JpegXlEncoder) should not be null to start test");
             Assert.IsNotNull(_pngEncoder, "Object(PngEncoder) should not be null to start test");
+            Assert.IsNotNull(_webPEncoder, "Object(WebPEncoder) should not be null to start test");
         }
 
         [TearDown]
         public void Destroy()
         {
-            _bmpEncoder.Dispose();
-            _gifEncoder.Dispose();
-            _jpegEncoder.Dispose();
-            _pngEncoder.Dispose();
+            _bmpEncoder?.Dispose();
+            _gifEncoder?.Dispose();
+            _jpegEncoder?.Dispose();
+            _jpegXlEncoder?.Dispose();
+            _pngEncoder?.Dispose();
+            _webPEncoder?.Dispose();
         }
 
         [Test]
@@ -221,6 +230,44 @@ namespace Tizen.Multimedia.Util.Tests
 
         [Test]
         [Category("P1")]
+        [Description("Test EncodeAsync with WebP whether throws exception or not.")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ImageEncoder.EncodeAsync M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public async Task EncodeAsync_WEBP_CHECK_RETURN_VALUE()
+        {
+            using (var outStream = File.Create(OutputPath))
+            using (var webPDecoder = new WebPDecoder())
+            {
+                var frame = (await webPDecoder.DecodeAsync(ImageUtilConstants.WebPPath)).FirstOrDefault();
+
+                _webPEncoder.SetResolution(new Size(100, 100));
+                Assert.That(() => _webPEncoder.EncodeAsync(frame.Buffer, outStream), Throws.Nothing);
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test EncodeAsync with JpegXl whether throws exception or not.")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ImageEncoder.EncodeAsync M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public async Task EncodeAsync_JPEGXL_CHECK_RETURN_VALUE()
+        {
+            using (var outStream = File.Create(OutputPath))
+            using (var jpegXlDecoder = new JpegXlDecoder())
+            {
+                var frame = (await jpegXlDecoder.DecodeAsync(ImageUtilConstants.JpegXlPath)).FirstOrDefault();
+
+                _jpegXlEncoder.SetResolution(new Size(100, 100));
+                Assert.That(() => _jpegXlEncoder.EncodeAsync(frame.Buffer, outStream), Throws.Nothing);
+            }
+        }
+
+        [Test]
+        [Category("P1")]
         [Description("Get output format for jpeg object")]
         [Property("SPEC", "Tizen.Multimedia.Util.ImageEncoder.OutputFormat A")]
         [Property("SPEC_URL", "-")]
@@ -266,5 +313,29 @@ namespace Tizen.Multimedia.Util.Tests
         {
             Assert.That(_bmpEncoder.OutputFormat, Is.EqualTo(ImageFormat.Bmp));
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("Get output format for webp object")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ImageEncoder.OutputFormat A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRE")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void OutputFormat_PROPERTY_GET_ENUM_IMAGEFORMAT_WEBP()
+        {
+            Assert.That(_webPEncoder.OutputFormat, Is.EqualTo(ImageFormat.WebP));
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Get output format for jpegxl object")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ImageEncoder.OutputFormat A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRE")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void OutputFormat_PROPERTY_GET_ENUM_IMAGEFORMAT_JPEGXL()
+        {
+            Assert.That(_jpegXlEncoder.OutputFormat, Is.EqualTo(ImageFormat.JpegXl));
+        }
     }
 }
diff --git a/tct-suite-vs/Tizen.MultimediaUtil.Tests/testcase/ImageUtil/TSJpegXlDecoder.cs b/tct-suite-vs/Tizen.MultimediaUtil.Tests/testcase/ImageUtil/TSJpegXlDecoder.cs
new file mode 100755 (executable)
index 0000000..882d3dd
--- /dev/null
@@ -0,0 +1,33 @@
+// Copyright 2022 by Samsung Electronics, Inc.,
+//
+// This software is the confidential and proprietary information
+// of Samsung Electronics, Inc. ("Confidential Information"). You
+// shall not disclose such Confidential Information and shall use
+// it only in accordance with the terms of the license agreement
+// you entered into with Samsung.
+
+using NUnit.Framework;
+
+namespace Tizen.Multimedia.Util.Tests
+{
+    [TestFixture]
+    [Description("Tests Tizen.Multimedia.Util.JpegXlDecoder class")]
+    public class JpegXlDecoderTests
+    {
+        [Test]
+        [Category("P1")]
+        [Description("Test: Constructor for JpegXl decoder - Object should not be null after initialization")]
+        [Property("SPEC", "Tizen.Multimedia.Util.JpegXlDecoder.JpegXlDecoder C")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "CONSTR")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void JpegXlDecoder_INIT()
+        {
+            using (var decoder = new JpegXlDecoder())
+            {
+                Assert.IsNotNull(decoder, "Should not null.");
+                Assert.IsInstanceOf<JpegXlDecoder>(decoder, "Should return JpegXlDecoder instance.");
+            }
+        }
+    }
+}
diff --git a/tct-suite-vs/Tizen.MultimediaUtil.Tests/testcase/ImageUtil/TSJpegXlEncoder.cs b/tct-suite-vs/Tizen.MultimediaUtil.Tests/testcase/ImageUtil/TSJpegXlEncoder.cs
new file mode 100644 (file)
index 0000000..49add5d
--- /dev/null
@@ -0,0 +1,83 @@
+// Copyright 2022 by Samsung Electronics, Inc.,
+//
+// This software is the confidential and proprietary information
+// of Samsung Electronics, Inc. ("Confidential Information"). You
+// shall not disclose such Confidential Information and shall use
+// it only in accordance with the terms of the license agreement
+// you entered into with Samsung.
+
+using NUnit.Framework;
+
+namespace Tizen.Multimedia.Util.Tests
+{
+    [TestFixture]
+    [Description("Tests Tizen.Multimedia.Util.JpegXlEncoder class")]
+    public class JpegXlEncoderTests
+    {
+        [Test]
+        [Category("P1")]
+        [Description("Test: Constructor for encoding JpegXl image - object should not be null after initializing")]
+        [Property("SPEC", "Tizen.Multimedia.Util.JpegXlEncoder.JpegXlEncoder C")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "CONSTR")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void JpegXlEncoder_INIT()
+        {
+            using (var encoder = new JpegXlEncoder())
+            {
+                Assert.IsNotNull(encoder, "Should not null.");
+                Assert.IsInstanceOf<JpegXlEncoder>(encoder, "Should return JpegXlEncoder instance.");
+                Assert.AreEqual(encoder.Lossless, false, "The default lossless value Should be false.");
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test: Constructor for encoding JpegXl image with lossless- object should not be null after initializing")]
+        [Property("SPEC", "Tizen.Multimedia.Util.JpegXlEncoder.JpegXlEncoder C")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "CONSTR")]
+        [Property("COVPARAM", "bool")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void JpegXlEncoder_INIT_WITH_Lossless()
+        {
+            using (var encoder = new JpegXlEncoder(true))
+            {
+                Assert.IsNotNull(encoder, "Should not null.");
+                Assert.IsInstanceOf<JpegXlEncoder>(encoder, "Should return JpegXlEncoder instance.");
+                Assert.AreEqual(encoder.Lossless, true, "Should be same value.");
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Check whether Lossless property is readable and writable.")]
+        [Property("SPEC", "Tizen.Multimedia.Util.JpegXlEncoder.Lossless A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRW")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Lossless_READ_WRITE()
+        {
+            using (var encoder = new JpegXlEncoder())
+            {
+                encoder.Lossless = true;
+                Assert.AreEqual(encoder.Lossless, true, "Should be same value.");
+
+                encoder.Lossless = false;
+                Assert.AreEqual(encoder.Lossless, false, "Should be same value.");
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Check whether the default value of Lossless property is false.")]
+        [Property("SPEC", "Tizen.Multimedia.Util.JpegXlEncoder.Lossless A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PDV")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Lossless_CHECK_DEFAULT_VALUE()
+        {
+            Assert.AreEqual(new JpegXlEncoder().Lossless, false, "The default value should be false.");
+        }
+    }
+}
index ca31365..eabd76d 100755 (executable)
@@ -2,6 +2,7 @@
 internal static class ImageUtilConstants
 {
     internal const string JpegPath = "/opt/usr/home/owner/share/res/test_jpeg.jpg";
+    internal const string JpegXlPath = "/opt/usr/home/owner/share/res/test_jxl.jxl";
     internal const string BitmapPath = "/opt/usr/home/owner/share/res/test_bmp.bmp";
     internal const string GifPath = "/opt/usr/home/owner/share/res/test_gif.gif";
     internal const string PngPath = "/opt/usr/home/owner/share/res/test_png.png";