summaryrefslogtreecommitdiff
path: root/pxl_jpeg.c
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2011-08-29 13:30:00 +0200
committerDidier Raboud <odyx@debian.org>2011-08-29 13:30:00 +0200
commit9b551a7d5bd2082f0ba641c5ff01bf0aced82952 (patch)
tree06e9fb5bfb364644e17b2f63e6e29dfca76a09ff /pxl_jpeg.c
Imported Upstream version 1.3
Diffstat (limited to 'pxl_jpeg.c')
-rw-r--r--pxl_jpeg.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/pxl_jpeg.c b/pxl_jpeg.c
new file mode 100644
index 0000000..df556de
--- /dev/null
+++ b/pxl_jpeg.c
@@ -0,0 +1,84 @@
+/**
+ * Copyright (c) 2005 Hin-Tak Leung. All rights reserved.
+ *
+ **/
+/*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+/**
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ **/
+
+#include <stdio.h>
+#define JPEG_INTERNALS
+#include "jinclude.h"
+#include "jpeglib.h"
+#include "i_job_info.h"
+
+
+EXTERN(void) rgb_jrycc_start (j_compress_ptr cinfo);
+
+EXTERN(void) rgb_jrycc_convert (j_compress_ptr cinfo,
+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
+ JDIMENSION output_row, int num_rows);
+
+/* jpeg quantization table */
+static unsigned int qtable[64] = { 2,3,4,5,5,5,5,5,
+ 3,6,5,8,5,8,5,8,
+ 4,5,5,5,5,5,5,5,
+ 5,8,5,8,5,8,5,8,
+ 5,5,5,5,5,5,5,5,
+ 5,8,5,8,5,8,5,8,
+ 5,5,5,5,5,5,5,5,
+ 5,8,5,8,5,8,5,8 };
+
+void pxl_set_jpeg_custom_params(i_job_info_t *job_info)
+{
+ int i,j;
+
+ /* the driver uses 1 for auto setting, 6 for max compression */
+ int qfactor = job_info->qfactor;
+
+ for(i = 0; i < 3; i++)
+ {
+ jpeg_add_quant_table(job_info->cinfo, i, qtable, 0, FALSE);
+
+ for(j =0; j < 64; j++)
+ {
+ job_info->cinfo->quant_tbl_ptrs[i]->quantval[j] = qtable[j] * qfactor ;
+ }
+
+ job_info->cinfo->quant_tbl_ptrs[i]->quantval[0] = qtable[0];
+
+ job_info->cinfo->quant_tbl_ptrs[i]->quantval[1] = qtable[1] * (1 + (qfactor - 1) * 0.25) + 0.5;
+ job_info->cinfo->quant_tbl_ptrs[i]->quantval[8] = qtable[8] * (1 + (qfactor - 1) * 0.25) + 0.5;
+
+ job_info->cinfo->quant_tbl_ptrs[i]->quantval[2] = qtable[2] * (1 + (qfactor - 1) * 0.5) + 0.5;
+ job_info->cinfo->quant_tbl_ptrs[i]->quantval[9] = qtable[9] * (1 + (qfactor - 1) * 0.5) + 0.5;
+ job_info->cinfo->quant_tbl_ptrs[i]->quantval[16] = qtable[16] * (1 + (qfactor - 1) * 0.5) + 0.5;
+
+ }
+
+ job_info->cinfo->comp_info[0].h_samp_factor = 1;
+ job_info->cinfo->comp_info[0].v_samp_factor = 1;
+ return;
+}