Use fast IDCT for JPEG decoding by default (#5072)

This commit is contained in:
Marek Kolodziej 2016-10-31 11:39:24 -07:00 committed by Vijay Vasudevan
parent 443fea9b73
commit 2aeedc38c6
3 changed files with 8 additions and 5 deletions

View File

@ -139,8 +139,11 @@ uint8* UncompressLow(const void* srcdata, FewerArgsForCompiler* argball) {
cinfo.do_fancy_upsampling = boolean(flags.fancy_upscaling); cinfo.do_fancy_upsampling = boolean(flags.fancy_upscaling);
cinfo.scale_num = 1; cinfo.scale_num = 1;
cinfo.scale_denom = ratio; cinfo.scale_denom = ratio;
// Activating this has a quality/speed trade-off implication: // Activating this has a quality/speed trade-off implication.
// cinfo.dct_method = JDCT_IFAST; // However, most JPEGs are already compressed, and so the faster IDCT
// should have no effect on training. The fast setting speeds up training on the
// GPU, e.g. by about 30% for smaller networks such as AlexNet.
cinfo.dct_method = JDCT_IFAST;
jpeg_start_decompress(&cinfo); jpeg_start_decompress(&cinfo);

View File

@ -165,7 +165,7 @@ TEST(JpegMemTest, Jpeg2) {
// Compare the two images // Compare the two images
const int totalerr = ComputeSumAbsoluteDifference( const int totalerr = ComputeSumAbsoluteDifference(
imgdata1.get(), refdata1.get(), in_w, in_h, stride1, stride1); imgdata1.get(), refdata1.get(), in_w, in_h, stride1, stride1);
CHECK_LE(totalerr, 85000); CHECK_LE(totalerr, 120000);
} }
// check the second image too. Should be bitwise identical to the first. // check the second image too. Should be bitwise identical to the first.

View File

@ -1803,10 +1803,10 @@ class JpegTest(test_util.TensorFlowTestCase):
jpeg0, image0, image1, image2 = sess.run([jpeg0, image0, image1, image2]) jpeg0, image0, image1, image2 = sess.run([jpeg0, image0, image1, image2])
# The decoded-encoded image should be similar to the input # The decoded-encoded image should be similar to the input
self.assertLess(self.averageError(image0, image1), 0.6) self.assertLess(self.averageError(image0, image1), 0.7)
# We should be very close to a fixpoint # We should be very close to a fixpoint
self.assertLess(self.averageError(image1, image2), 0.02) self.assertLess(self.averageError(image1, image2), 0.6)
# Smooth ramps compress well (input size is 153600) # Smooth ramps compress well (input size is 153600)
self.assertGreaterEqual(len(jpeg0), 5000) self.assertGreaterEqual(len(jpeg0), 5000)