Raise an exception to head off a weird asdcplib error with empty JPEG2000 comments.
authorCarl Hetherington <cth@carlh.net>
Sun, 13 Dec 2020 20:22:15 +0000 (21:22 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 17 Jan 2021 19:13:22 +0000 (20:13 +0100)
src/j2k.cc

index 032c7caa73a832bf09f4408a302598c8a2bf792c..654146ca848845e3cc735fa517ad247189688385 100644 (file)
@@ -283,6 +283,11 @@ dcp::compress_j2k (shared_ptr<const OpenJPEGImage> xyz, int bandwidth, int frame
                throw MiscError ("could not create JPEG2000 encoder");
        }
 
+       if (comment.empty()) {
+               /* asdcplib complains with "Illegal data size" when reading frames encoded with an empty comment */
+               throw MiscError("compress_j2k comment can not be an empty string");
+       }
+
        opj_set_error_handler (encoder, compress_error_callback, 0);
 
        /* Set encoding parameters to default values */