libjpeg-turbo: Upgrade to 1.5.1

The changes from 1.4.2 to 1.5.1 include
a big amount of fixes and huge performance improvements.
As highlights there is a full ARM 64-bit (ARMv8) NEON SIMD
implementation which improves compression of full-color JPEGs
by about 2-2.5x on average on Cortex-A53 and Cortex-A57 cores.
Also  SIMD acceleration for Huffman encoding on NEON-capable
ARM 32-bit and 64-bit platforms was added.
Performance on x86/x86_64 was also improved by
adding better optimized SSE2 routines.

For the full changelog, please see the ChangeLog.md
file.

Partial decoding optimizations, the security fix
to adress b/27494207 and the fix for the AARCH64
conformance issueare present in the release.
The README.android file was edited to reflect this.

The configuration files were regenerated
and all Android specific changes were applied.

BUG:28268702

Change-Id: I538291d894df1da01d3f733771647df1fb61ec42
Signed-off-by: Alex Naidis <alex.naidis@linux.com>
diff --git a/jcmaster.c b/jcmaster.c
index ea13d0d..03a8b40 100644
--- a/jcmaster.c
+++ b/jcmaster.c
@@ -5,8 +5,9 @@
  * Copyright (C) 1991-1997, Thomas G. Lane.
  * Modified 2003-2010 by Guido Vollbeding.
  * libjpeg-turbo Modifications:
- * Copyright (C) 2010, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README file.
+ * Copyright (C) 2010, 2016, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
  *
  * This file contains master control logic for the JPEG compressor.
  * These routines are concerned with parameter validation, initial setup,
@@ -18,6 +19,7 @@
 #include "jinclude.h"
 #include "jpeglib.h"
 #include "jpegcomp.h"
+#include "jconfigint.h"
 
 
 /* Private state */
@@ -37,9 +39,19 @@
   int total_passes;             /* total # of passes needed */
 
   int scan_number;              /* current index in scan_info[] */
+
+  /*
+   * This is here so we can add libjpeg-turbo version/build information to the
+   * global string table without introducing a new global symbol.  Adding this
+   * information to the global string table allows one to examine a binary
+   * object and determine which version of libjpeg-turbo it was built from or
+   * linked against.
+   */
+  const char *jpeg_version;
+
 } my_comp_master;
 
-typedef my_comp_master * my_master_ptr;
+typedef my_comp_master *my_master_ptr;
 
 
 /*
@@ -167,12 +179,12 @@
  * determine whether it uses progressive JPEG, and set cinfo->progressive_mode.
  */
 {
-  const jpeg_scan_info * scanptr;
+  const jpeg_scan_info *scanptr;
   int scanno, ncomps, ci, coefi, thisi;
   int Ss, Se, Ah, Al;
   boolean component_sent[MAX_COMPONENTS];
 #ifdef C_PROGRESSIVE_SUPPORTED
-  int * last_bitpos_ptr;
+  int *last_bitpos_ptr;
   int last_bitpos[MAX_COMPONENTS][DCTSIZE2];
   /* -1 until that coefficient has been seen; then last Al for it */
 #endif
@@ -308,7 +320,7 @@
   if (cinfo->scan_info != NULL) {
     /* Prepare for current scan --- the script is already validated */
     my_master_ptr master = (my_master_ptr) cinfo->master;
-    const jpeg_scan_info * scanptr = cinfo->scan_info + master->scan_number;
+    const jpeg_scan_info *scanptr = cinfo->scan_info + master->scan_number;
 
     cinfo->comps_in_scan = scanptr->comps_in_scan;
     for (ci = 0; ci < scanptr->comps_in_scan; ci++) {
@@ -602,7 +614,7 @@
     cinfo->num_scans = 1;
   }
 
-  if (cinfo->progressive_mode && !cinfo->arith_code)    /*  TEMPORARY HACK ??? */
+  if (cinfo->progressive_mode && !cinfo->arith_code)  /*  TEMPORARY HACK ??? */
     cinfo->optimize_coding = TRUE; /* assume default tables no good for progressive mode */
 
   /* Initialize my private state */
@@ -622,4 +634,6 @@
     master->total_passes = cinfo->num_scans * 2;
   else
     master->total_passes = cinfo->num_scans;
+
+  master->jpeg_version = PACKAGE_NAME " version " VERSION " (build " BUILD ")";
 }