Add flags to the TurboJPEG API that allow the caller to force the use of either the fast or the accurate DCT/IDCT algorithms in the underlying codec.


git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@851 632fc199-4ca6-4c93-a231-07263d6284db
diff --git a/java/TJExample.java b/java/TJExample.java
index 36c1a8f..e726892 100644
--- a/java/TJExample.java
+++ b/java/TJExample.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C)2011 D. R. Commander.  All Rights Reserved.
+ * Copyright (C)2011-2012 D. R. Commander.  All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -81,6 +81,12 @@
     System.out.println("     for 4:2:0.)\n");
     System.out.println("-display = Display output image (Output file need not be specified in this");
     System.out.println("     case.)\n");
+    System.out.println("-fastupsample = Use the fastest chrominance upsampling algorithm available in");
+    System.out.println("     the underlying codec\n");
+    System.out.println("-fastdct = Use the fastest DCT/IDCT algorithms available in the underlying");
+    System.out.println("     codec\n");
+    System.out.println("-accuratedct = Use the most accurate DCT/IDCT algorithms available in the");
+    System.out.println("     underlying codec\n");
     System.exit(1);
   }
 
@@ -92,6 +98,7 @@
 
     BufferedImage img = null;  byte[] bmpBuf = null;
     TJTransform xform = new TJTransform();
+    int flags = 0;
 
     try {
 
@@ -187,6 +194,18 @@
           }
           if(argv[i].substring(0, 2).equalsIgnoreCase("-d"))
             display = true;
+          if(argv[i].equalsIgnoreCase("-fastupsample")) {
+            System.out.println("Using fast upsampling code");
+            flags |= TJ.FLAG_FASTUPSAMPLE;
+          }
+          if(argv[i].equalsIgnoreCase("-fastdct")) {
+            System.out.println("Using fastest DCT/IDCT algorithm");
+            flags |= TJ.FLAG_FASTDCT;
+          }
+          if(argv[i].equalsIgnoreCase("-accuratedct")) {
+            System.out.println("Using most accurate DCT/IDCT algorithm");
+            flags |= TJ.FLAG_ACCURATEDCT;
+          }
         }
       }
       String[] inFileTokens = argv[0].split("\\.");
@@ -247,8 +266,9 @@
         height = scaleFactor.getScaled(height);
 
         if(!outFormat.equalsIgnoreCase("jpg"))
-          img = tjd.decompress(width, height, BufferedImage.TYPE_INT_RGB, 0);
-        else bmpBuf = tjd.decompress(width, 0, height, TJ.PF_BGRX, 0);
+          img = tjd.decompress(width, height, BufferedImage.TYPE_INT_RGB,
+                               flags);
+        else bmpBuf = tjd.decompress(width, 0, height, TJ.PF_BGRX, flags);
         tjd.close();
       }
       else {
@@ -282,10 +302,10 @@
         tjc.setSubsamp(outSubsamp);
         tjc.setJPEGQuality(outQual);
         if(img != null)
-          jpegBuf = tjc.compress(img, 0);
+          jpegBuf = tjc.compress(img, flags);
         else {
           tjc.setSourceImage(bmpBuf, width, 0, height, TJ.PF_BGRX);
-          jpegBuf = tjc.compress(0);
+          jpegBuf = tjc.compress(flags);
         }
         jpegSize = tjc.getCompressedSize();
         tjc.close();