--- /dev/null
+This software is based in part on the work of the Independent JPEG Group.
+
+
+
+Copyright (C) 2009-2015 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:
+
+- Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+- Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+- Neither the name of the libjpeg-turbo Project nor the names of its
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+
+
+Copyright (C) 1988-1989 by Jef Poskanzer.
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted, provided
+that the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation. This software is provided "as is" without express or
+implied warranty.
JDIMENSION start_col, output_col;
jpeg_component_info *compptr;
inverse_DCT_method_ptr inverse_DCT;
+#if _USE_PRODUCT_TV
+ /* region decoding. this limits decode to the set of blocks +- 1 outside
+ * bounding blocks around the desired region to decode */
+ int blk1 = 0, blk2 = 0, skip = 0;
+
+ if ((cinfo->region_w > 0) && (cinfo->region_h > 0)) {
+ int bsz_w = 0, bsz_h = 0;
+
+ for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
+ compptr = cinfo->cur_comp_info[ci];
+ if (compptr->MCU_sample_width > bsz_w)
+ bsz_w = compptr->MCU_sample_width;
+ if ((compptr->MCU_height * 8) > bsz_h)
+ bsz_h = compptr->MCU_height * 8;
+ }
+ int _region_y = (int)cinfo->region_y;
+ _region_y = (_region_y>>1)<<1;
+ if (((int)cinfo->output_scanline < (_region_y - bsz_h - 1)) ||
+ ((int)cinfo->output_scanline > (_region_y + cinfo->region_h + bsz_h)))
+ skip = 1;
+ if (bsz_w != 0)
+ blk1 = (cinfo->region_x / bsz_w) - 1;
+ if (blk1 < 0)
+ blk1 = 0;
+ if (bsz_w != 0)
+ blk2 = ((cinfo->region_x + cinfo->region_w + bsz_w - 1) / bsz_w) + 1;
+ if (blk2 < 0)
+ blk2 = 0;
+ }
+#endif
/* Loop to process as much as one whole iMCU row */
for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
yoffset++) {
for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
MCU_col_num++) {
+#if _USE_PRODUCT_TV
+ /* see if we need to skip this MCU or not */
+ if ((cinfo->region_w > 0) && (cinfo->region_h > 0)) {
+ if (!((MCU_col_num < blk1) || (MCU_col_num > blk2) || skip))
+ skip = 0;
+ }
+ /* if we are not skipping this MCU, zero it ready for huffman decode */
+ if (!skip)
+ jzero_far((void FAR *) coef->MCU_buffer[0],
+ (size_t) (cinfo->blocks_in_MCU * sizeof(JBLOCK)));
+#endif
/* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */
+#if _USE_PRODUCT_TV
+ jzero_far((void FAR *) coef->MCU_buffer[0],
+ (size_t) (cinfo->blocks_in_MCU * sizeof(JBLOCK)));
+#else
jzero_far((void *)coef->MCU_buffer[0],
(size_t)(cinfo->blocks_in_MCU * sizeof(JBLOCK)));
+#endif
if (!(*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
/* Suspension forced; update state counters and exit */
coef->MCU_vert_offset = yoffset;
coef->MCU_ctr = MCU_col_num;
return JPEG_SUSPENDED;
}
+#if _USE_PRODUCT_TV
+ /* region decoding. this limits decode to the set of blocks +- 1 outside
+ * bounding blocks around the desired region to decode */
+ if (skip)
+ continue;
+#endif
/* Only perform the IDCT on blocks that are contained within the desired
* cropping region.
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
JSAMPROW work_ptrs[2];
JDIMENSION num_rows; /* number of rows returned to caller */
+#if _USE_PRODUCT_TV
+ int skip = 0;
+#endif
if (upsample->spare_full) {
/* If we have a spare row saved from a previous cycle, just return it. */
JDIMENSION size = upsample->out_row_width;
if (cinfo->out_color_space == JCS_RGB565)
size = cinfo->output_width * 2;
+#if _USE_PRODUCT_TV
+ jcopy_sample_rows(& upsample->spare_row, 0, output_buf + *out_row_ctr, 0, 1,
+ upsample->out_row_width);
+#else
jcopy_sample_rows(&upsample->spare_row, 0, output_buf + *out_row_ctr, 0, 1,
size);
+#endif
num_rows = 1;
upsample->spare_full = FALSE;
} else {
+#if _USE_PRODUCT_TV
+ int _region_y = (int)cinfo->region_y;
+ _region_y = (_region_y>>1)<<1;
+ if ((cinfo->region_w > 0) && (cinfo->region_h > 0)) {
+ if (((int)cinfo->output_scanline < _region_y) ||
+ ((int)cinfo->output_scanline >= (_region_y + (int)cinfo->region_h)))
+ skip = 1;
+ }
+#endif
/* Figure number of rows to return to caller. */
num_rows = 2;
/* Not more than the distance to the end of the image. */
upsample->spare_full = TRUE;
}
/* Now do the upsampling. */
+#if _USE_PRODUCT_TV
+ if (!skip)
+ (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, work_ptrs);
+#else
(*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, work_ptrs);
+#endif
}
/* Adjust counts */
typedef struct jpeg_compress_struct *j_compress_ptr;
typedef struct jpeg_decompress_struct *j_decompress_ptr;
+typedef struct _Pick_Color_
+{
+ unsigned int sumR;
+ unsigned int sumG;
+ unsigned int sumB;
+ int enablePickColor;
+ int perc;
+ int x1;
+ int y1;
+ int x2;
+ int y2;
+}PickColor;
/* Master record for a compression instance */
unsigned int scale_num, scale_denom; /* fraction by which to scale image */
+#ifdef COLOR_PICKER_ENABLE
+ unsigned int region_x, region_y, region_w, region_h; /* if region_w && region_h > 0, then use this region to decode. scale above is done prior to region select */
+#endif
+
double output_gamma; /* image gamma wanted in output */
boolean buffered_image; /* TRUE=multiple output passes */
struct jpeg_upsampler *upsample;
struct jpeg_color_deconverter *cconvert;
struct jpeg_color_quantizer *cquantize;
+
+#ifdef COLOR_PICKER_ENABLE
+ struct _Pick_Color_ *pick_color_data;
+#endif
};
}
}
+#if _USE_PRODUCT_TV
+ if(total != 0) {
+ cinfo->colormap[0][icolor] = (JSAMPLE)((c0total + (total>>1)) / total);
+ cinfo->colormap[1][icolor] = (JSAMPLE)((c1total + (total>>1)) / total);
+ cinfo->colormap[2][icolor] = (JSAMPLE)((c2total + (total>>1)) / total);
+ }
+#else
cinfo->colormap[0][icolor] = (JSAMPLE)((c0total + (total >> 1)) / total);
cinfo->colormap[1][icolor] = (JSAMPLE)((c1total + (total >> 1)) / total);
cinfo->colormap[2][icolor] = (JSAMPLE)((c2total + (total >> 1)) / total);
+#endif
}
#endif
if (f < 0)
return 0;
- if (fstat(f, &stbuf) < 0)
+ if (fstat(f, &stbuf) < 0) {
+ close(f);
return 0;
+ }
if (ofs > stbuf.st_size)
ofs = stbuf.st_size;
if ((len == 0) || (len > stbuf.st_size - ofs))
len = stbuf.st_size - ofs;
- if (lseek(f, ofs, SEEK_SET) < 0)
+ if (lseek(f, ofs, SEEK_SET) < 0) {
+ close(f);
return 0;
+ }
n = len;
i = 0;
while (n > 0) {
--- /dev/null
+libjpeg
+libjpeg-devel
--- /dev/null
+* Mon Jan 5 2015 Manuel Bachmann <manuel.bachmann@open.eurogiciel.org> upstream/1.3.1@be98490
+
+* Fri Jun 14 2013 Anas Nashif <anas.nashif@intel.com> submit/tizen/20130509.181119@e374876
+- Provide libjpeg8-devel and fix groups
+
+* Sat Dec 29 2012 Anas Nashif <anas.nashif@intel.com> upstream/1.2.1@b4693c7
+- install libturbojpeg.so
+
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
--- /dev/null
+%define libver 8.1.2
+
+Name: libjpeg-turbo
+Version: 2.0.1
+Release: 1
+Summary: A MMX/SSE2 accelerated library for manipulating JPEG image files
+License: BSD License (BSD 3-clause, Historic Permission Notice and Disclaimer, libjpeg License)
+Group: Graphics & UI Framework/Libraries
+Url: http://sourceforge.net/projects/libjpeg-turbo
+Source0: %{name}-%{version}.tar.gz
+Source1001: libjpeg-turbo.manifest
+BuildRequires: cmake
+BuildRequires: gcc-c++
+BuildRequires: libtool
+BuildRequires: yasm
+
+%description
+The libjpeg-turbo package contains a library of functions for manipulating
+JPEG images.
+
+%package -n libjpeg
+
+Version: %{libver}
+Release: 0
+Summary: The MMX/SSE accelerated JPEG compression/decompression library
+Group: Graphics & UI Framework/Libraries
+
+Provides: libjpeg = %{version}
+Provides: libjpeg8
+Obsoletes: libjpeg < %{version}
+
+%description -n libjpeg
+This library contains MMX/SSE accelerated functions for manipulating
+JPEG images.
+
+%package -n libjpeg-devel
+Version: %{libver}
+Release: 0
+Summary: Development Tools for applications which will use the Libjpeg Library
+Group: Graphics & UI Framework/Development
+
+Provides: libjpeg-turbo-devel
+Requires: libjpeg = %{version}
+Provides: libjpeg-devel = %{version}
+Obsoletes: libjpeg-devel < %{version}
+
+%description -n libjpeg-devel
+The libjpeg-devel package includes the header files and libraries
+necessary for compiling and linking programs which will manipulate JPEG
+files using the libjpeg library.
+
+%prep
+%setup -q
+cp %{SOURCE1001} .
+
+%build
+%if "%{tizen_profile_name}" == "tv"
+echo "tizen_product_tv"
+export CFLAGS="$CFLAGS -D_TIZEN_PRODUCT_TV -D_USE_PRODUCT_TV -DCOLOR_PICKER_ENABLE"
+%endif
+%cmake . -DCMAKE_BUILD_TYPE=Release -DENABLE_SHARED=TRUE -DENABLE_STATIC=FALSE -DWITH_JPEG8=TRUE
+%__make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+
+%make_install
+
+# Remove unwanted files
+rm %{buildroot}%{_bindir}/*
+
+# Remove docs, we'll select docs manually
+rm -rf %{buildroot}%{_datadir}/doc/
+
+%post -n libjpeg -p /sbin/ldconfig
+
+%postun -n libjpeg -p /sbin/ldconfig
+
+%docs_package
+
+%files
+%manifest %{name}.manifest
+%defattr(-,root,root)
+%license README.ijg
+%license COPYING
+
+%files -n libjpeg
+%manifest %{name}.manifest
+%defattr(-,root,root)
+%{_libdir}/libturbojpeg.so.*
+%{_libdir}/libjpeg.so.*
+%license README.ijg
+%license COPYING
+
+%files -n libjpeg-devel
+%defattr(-,root,root)
+%{_includedir}/*.h
+%{_libdir}/pkgconfig/libturbojpeg.pc
+%{_libdir}/pkgconfig/libjpeg.pc
+%{_libdir}/libturbojpeg.so
+%{_libdir}/libjpeg.so
+%doc coderules.txt jconfig.txt libjpeg.txt structure.txt example.txt
+
+%changelog
#include <string.h>
#include <ctype.h>
+#if _USE_PRODUCT_TV
+//Changes for JPEG GAMMA enhancement in thumbnail
+#include <unistd.h>
+#endif
+
static unsigned int simd_support = ~0;
static unsigned int simd_huffman = 1;
break;
}
+#if _USE_PRODUCT_TV
+ if (simd_support & JSIMD_NEON) {
+ neonfct(cinfo->output_width, input_buf, input_row, output_buf, num_rows);
+ PickColor* pickColor = cinfo->pick_color_data;
+ if(pickColor && pickColor->enablePickColor && output_buf) {
+ int w = cinfo->output_width;
+ unsigned char *ptr = *output_buf;
+ if(pickColor->perc <= 0) {
+ w = pickColor->x2 - pickColor->x1 + 1;
+ ptr = (*output_buf) + (pickColor->x1 * 3);
+ }
+ jsimd_pick_color(ptr, pickColor, w);
+ }
+ }
+#else
neonfct(cinfo->output_width, input_buf, input_row, output_buf, num_rows);
+#endif
}
GLOBAL(void)
.purgem emit_byte
.purgem put_bits
.purgem checkbuf15
+
+#if _USE_PRODUCT_TV
+asm_function jsimd_pick_color
+
+@ RGB_BUFFER .req r0
+@ RGB_RET .req r1
+@ OUTPUT_WIDTH .req r2
+
+ push {r3, r4, r5, lr}
+ vpush {d8-d15}
+ MOV r5, #0
+ VDUP.32 d0, r5
+ VDUP.32 d1, r5
+ VDUP.32 d2, r5
+ VDUP.32 d3, r5
+ VDUP.32 d4, r5
+ VDUP.32 d5, r5
+ VDUP.32 d6, r5
+ VDUP.32 d7, r5
+ VDUP.32 d8, r5
+
+ CMP r2,#0x8
+ BCC UNDER_8
+
+ CMP r2,#0x10
+ BCC UNDER_16
+
+ VLD3.8 {d0, d2, d4}, [r0]!
+ VLD3.8 {d1, d3, d5}, [r0]!
+
+ SUB r2, r2, #16
+ VPADDL.U8 q0,q0
+ VPADDL.U8 q1,q1
+ VPADDL.U8 q2,q2
+
+
+ PROCESS_LOOP:
+
+ CMP r2, #0x10
+ BCC LOOP_BREAK
+
+ SUB r2, r2, #16
+ CMP r2, #0
+ BLT LOOP_BREAK
+
+ VLD3.8 {d6, d8, d10}, [r0]!
+ VLD3.8 {d7, d9, d11}, [r0]!
+
+ VPADAL.U8 q0,q3
+ VPADAL.U8 q1,q4
+ VPADAL.U8 q2,q5
+
+ B PROCESS_LOOP
+
+ LOOP_BREAK:
+
+ VPADDL.U16 q0, q0
+ VPADDL.U16 q1, q1
+ VPADDL.U16 q2, q2
+
+ VPADDL.U32 q0, q0
+ VPADDL.U32 q1, q1
+ VPADDL.U32 q2, q2
+
+ VADD.I64 d0, d0, d1
+ VADD.I64 d2, d2, d3
+ VADD.I64 d4, d4, d5
+
+ PROCESS_REST:
+ CMP r2, #8
+ BLT PROCESS_U_8 @ignore less than 8 pixels as of now
+
+ VLD3.8 {d6, d7, d8}, [r0]!
+ VPADDL.U8 d6, d6
+ VPADDL.U8 d7, d7
+ VPADDL.U8 d8, d8
+
+ VPADDL.U16 d6, d6
+ VPADDL.U16 d7, d7
+ VPADDL.U16 d8, d8
+
+ VPADDL.U32 d6, d6
+ VPADDL.U32 d7, d7
+ VPADDL.U32 d8, d8
+
+ VADD.I64 d0, d0, d6
+ VADD.I64 d2, d2, d7
+ VADD.I64 d4, d4, d8
+
+ SUB r2, r2, #8
+
+ PROCESS_U_8:
+ CMP r2, #4
+ BLT PROCESS_U_4
+
+ VLD3.8 {d6[0], d7[0], d8[0]}, [r0]!
+ VLD3.8 {d6[1], d7[1], d8[1]}, [r0]!
+ VLD3.8 {d6[2], d7[2], d8[2]}, [r0]!
+ VLD3.8 {d6[3], d7[3], d8[3]}, [r0]!
+
+ VPADDL.U8 d6, d6
+ VPADDL.U8 d7, d7
+ VPADDL.U8 d8, d8
+
+ VPADDL.U16 d6, d6
+ VPADDL.U16 d7, d7
+ VPADDL.U16 d8, d8
+
+ VADD.I64 d0, d0, d6
+ VADD.I64 d2, d2, d7
+ VADD.I64 d4, d4, d8
+
+ SUB r2, r2, #4
+
+ PROCESS_U_4:
+@ CMP r2, #2
+@ BLT PROCESS_U_2
+
+ B STORE
+
+
+ UNDER_16:
+
+ VLD3.8 {d0, d2, d4}, [r0]!
+ VPADDL.U8 d0, d0
+ VPADDL.U8 d2, d2
+ VPADDL.U8 d4, d4
+
+ VPADDL.U16 d0, d0
+ VPADDL.U16 d2, d2
+ VPADDL.U16 d4, d4
+
+ VPADDL.U32 d0, d0
+ VPADDL.U32 d2, d2
+ VPADDL.U32 d4, d4
+
+ B STORE
+
+ STORE:
+ VMOV.U32 r3, d0[0]
+ LDR r4, [r1]
+ ADD r4, r4, r3
+ STR r4, [r1]
+
+ VMOV.U32 r3, d2[0]
+ LDR r4, [r1, #4]
+ ADD r4, r4, r3
+ STR r4, [r1, #4]
+
+ VMOV.U32 r3, d4[0]
+ LDR r4, [r1, #8]
+ ADD r4, r4, r3
+ STR r4, [r1, #8]
+
+ UNDER_8:
+ vpop {d8-d15}
+ pop {r3, r4, r5, pc}
+#endif
EXTERN(int) jsimd_encode_mcu_AC_refine_prepare_sse2
(const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
JCOEF *absvalues, size_t *bits);
+
+/* TIZEN_PRODUCT_TV */
+EXTERN(void) jsimd_pick_color
+ JPP((JSAMPARRAY output_buf,
+ void *pickColor,
+ JDIMENSION out_width));
+
+EXTERN(void) jsimd_h2v1_fancy_upsample_neon
+ JPP((int max_v_samp_factor, JDIMENSION downsampled_width,
+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr));
printf("ERROR in line %d while %s:\n%s\n", __LINE__, op, err); \
retval = -1; goto bailout; \
}
+
+#if _USE_PRODUCT_TV
+#define _throwunix(m) { \
+ char err_str[256]; \
+ strerror_r(errno, err_str, 256); \
+ _throw(m, err_str) \
+}
+#else
#define _throwunix(m) _throw(m, strerror(errno))
+#endif
char tjErrorStr[JMSG_LENGTH_MAX] = "\0", tjErrorMsg[JMSG_LENGTH_MAX] = "\0";
int tjErrorLine = -1, tjErrorCode = -1;
FILE *file = fopen(filename, "wb");
if (!file || fwrite(jpegBuf, jpegSize, 1, file) != 1) {
+#if _USE_PRODUCT_TV
+ char err_str[256];
+ strerror_r(errno, err_str, 256);
+ printf("ERROR: Could not write to %s.\n%s\n", filename, err_str);
+#else
printf("ERROR: Could not write to %s.\n%s\n", filename, strerror(errno));
+#endif
bailout()
}