diff options
author | dcommander <dcommander@3789f03b-4d11-0410-bbf8-ca57d06f2519> | 2012-06-29 23:46:38 +0000 |
---|---|---|
committer | dcommander <dcommander@3789f03b-4d11-0410-bbf8-ca57d06f2519> | 2012-06-29 23:46:38 +0000 |
commit | b0a9d68d28ca1ab2012cfde7a960cc54fdcc08d8 (patch) | |
tree | 6c108bda5554e028ae8ecd08c0849e2a5fc4a3d6 /trunk/java/TJExample.java | |
parent | 4ef5093e3e4fb69d9d37137804ceccc73b48ccad (diff) |
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: https://libjpeg-turbo.svn.sourceforge.net/svnroot/libjpeg-turbo@851 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'trunk/java/TJExample.java')
-rw-r--r-- | trunk/java/TJExample.java | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/trunk/java/TJExample.java b/trunk/java/TJExample.java index 36c1a8f..e726892 100644 --- a/trunk/java/TJExample.java +++ b/trunk/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 @@ public class TJExample implements TJCustomFilter { 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 @@ public class TJExample implements TJCustomFilter { BufferedImage img = null; byte[] bmpBuf = null; TJTransform xform = new TJTransform(); + int flags = 0; try { @@ -187,6 +194,18 @@ public class TJExample implements TJCustomFilter { } 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 @@ public class TJExample implements TJCustomFilter { 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 @@ public class TJExample implements TJCustomFilter { 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(); |