This commit is contained in:
Roy Tam 2019-02-22 21:51:15 +08:00
commit bc3f20e378
17 changed files with 106 additions and 47 deletions

View file

@ -216,7 +216,7 @@ compute_reciprocal (UINT16 divisor, DCTELEM *dtbl)
#endif #endif
dtbl[DCTSIZE2 * 3] = (DCTELEM) r - sizeof(DCTELEM)*8; /* shift */ dtbl[DCTSIZE2 * 3] = (DCTELEM) r - sizeof(DCTELEM)*8; /* shift */
if(r <= 16) return 0; if (r <= 16) return 0;
else return 1; else return 1;
} }

View file

@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2010, 2015-2016, D. R. Commander. * Copyright (C) 2010, 2015-2017, D. R. Commander.
* Copyright (C) 2015, Google, Inc. * Copyright (C) 2015, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg * For conditions of distribution and use, see the accompanying README.ijg
* file. * file.
@ -190,6 +190,9 @@ jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
* single-pass decompression case, allowing us to use the same MCU column * single-pass decompression case, allowing us to use the same MCU column
* width for all of the components. * width for all of the components.
*/ */
if (cinfo->comps_in_scan == 1 && cinfo->num_components == 1)
align = cinfo->_min_DCT_scaled_size;
else
align = cinfo->_min_DCT_scaled_size * cinfo->max_h_samp_factor; align = cinfo->_min_DCT_scaled_size * cinfo->max_h_samp_factor;
/* Adjust xoffset to the nearest iMCU boundary <= the requested value */ /* Adjust xoffset to the nearest iMCU boundary <= the requested value */
@ -215,6 +218,9 @@ jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
int hsf = (cinfo->comps_in_scan == 1 && cinfo->num_components == 1) ?
1 : compptr->h_samp_factor;
/* Set downsampled_width to the new output width. */ /* Set downsampled_width to the new output width. */
orig_downsampled_width = compptr->downsampled_width; orig_downsampled_width = compptr->downsampled_width;
compptr->downsampled_width = compptr->downsampled_width =
@ -228,11 +234,10 @@ jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
* values will be used in multi-scan decompressions. * values will be used in multi-scan decompressions.
*/ */
cinfo->master->first_MCU_col[ci] = cinfo->master->first_MCU_col[ci] =
(JDIMENSION) (long) (*xoffset * compptr->h_samp_factor) / (JDIMENSION) (long) (*xoffset * hsf) / (long) align;
(long) align;
cinfo->master->last_MCU_col[ci] = cinfo->master->last_MCU_col[ci] =
(JDIMENSION) jdiv_round_up((long) ((*xoffset + cinfo->output_width) * (JDIMENSION) jdiv_round_up((long) ((*xoffset + cinfo->output_width) *
compptr->h_samp_factor), hsf),
(long) align) - 1; (long) align) - 1;
} }
@ -293,6 +298,14 @@ noop_convert (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
} }
/* Dummy quantize function used by jpeg_skip_scanlines() */
LOCAL(void)
noop_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
JSAMPARRAY output_buf, int num_rows)
{
}
/* /*
* In some cases, it is best to call jpeg_read_scanlines() and discard the * In some cases, it is best to call jpeg_read_scanlines() and discard the
* output, rather than skipping the scanlines, because this allows us to * output, rather than skipping the scanlines, because this allows us to
@ -308,14 +321,22 @@ read_and_discard_scanlines (j_decompress_ptr cinfo, JDIMENSION num_lines)
void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf, void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
JDIMENSION input_row, JSAMPARRAY output_buf, JDIMENSION input_row, JSAMPARRAY output_buf,
int num_rows); int num_rows);
void (*color_quantize) (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
JSAMPARRAY output_buf, int num_rows) = NULL;
color_convert = cinfo->cconvert->color_convert; color_convert = cinfo->cconvert->color_convert;
cinfo->cconvert->color_convert = noop_convert; cinfo->cconvert->color_convert = noop_convert;
if (cinfo->cquantize && cinfo->cquantize->color_quantize) {
color_quantize = cinfo->cquantize->color_quantize;
cinfo->cquantize->color_quantize = noop_quantize;
}
for (n = 0; n < num_lines; n++) for (n = 0; n < num_lines; n++)
jpeg_read_scanlines(cinfo, NULL, 1); jpeg_read_scanlines(cinfo, NULL, 1);
cinfo->cconvert->color_convert = color_convert; cinfo->cconvert->color_convert = color_convert;
if (color_quantize)
cinfo->cquantize->color_quantize = color_quantize;
} }
@ -370,6 +391,8 @@ jpeg_skip_scanlines (j_decompress_ptr cinfo, JDIMENSION num_lines)
/* Do not skip past the bottom of the image. */ /* Do not skip past the bottom of the image. */
if (cinfo->output_scanline + num_lines >= cinfo->output_height) { if (cinfo->output_scanline + num_lines >= cinfo->output_height) {
cinfo->output_scanline = cinfo->output_height; cinfo->output_scanline = cinfo->output_height;
(*cinfo->inputctl->finish_input_pass) (cinfo);
cinfo->inputctl->eoi_reached = TRUE;
return cinfo->output_height - cinfo->output_scanline; return cinfo->output_height - cinfo->output_scanline;
} }

View file

@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Developed 1997-2015 by Guido Vollbeding. * Developed 1997-2015 by Guido Vollbeding.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2015-2016, D. R. Commander. * Copyright (C) 2015-2017, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg * For conditions of distribution and use, see the accompanying README.ijg
* file. * file.
* *
@ -21,6 +21,9 @@
#include "jpeglib.h" #include "jpeglib.h"
#define NEG_1 ((unsigned int)-1)
/* Expanded entropy decoder object for arithmetic decoding. */ /* Expanded entropy decoder object for arithmetic decoding. */
typedef struct { typedef struct {
@ -303,7 +306,7 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
while (m >>= 1) while (m >>= 1)
if (arith_decode(cinfo, st)) v |= m; if (arith_decode(cinfo, st)) v |= m;
v += 1; if (sign) v = -v; v += 1; if (sign) v = -v;
entropy->last_dc_val[ci] += v; entropy->last_dc_val[ci] = (entropy->last_dc_val[ci] + v) & 0xffff;
} }
/* Scale and output the DC coefficient (assumes jpeg_natural_order[0]=0) */ /* Scale and output the DC coefficient (assumes jpeg_natural_order[0]=0) */
@ -450,7 +453,7 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
tbl = cinfo->cur_comp_info[0]->ac_tbl_no; tbl = cinfo->cur_comp_info[0]->ac_tbl_no;
p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */ m1 = (NEG_1) << cinfo->Al; /* -1 in the bit position being coded */
/* Establish EOBx (previous stage end-of-block) index */ /* Establish EOBx (previous stage end-of-block) index */
for (kex = cinfo->Se; kex > 0; kex--) for (kex = cinfo->Se; kex > 0; kex--)
@ -561,7 +564,7 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
while (m >>= 1) while (m >>= 1)
if (arith_decode(cinfo, st)) v |= m; if (arith_decode(cinfo, st)) v |= m;
v += 1; if (sign) v = -v; v += 1; if (sign) v = -v;
entropy->last_dc_val[ci] += v; entropy->last_dc_val[ci] = (entropy->last_dc_val[ci] + v) & 0xffff;
} }
if (block) if (block)

View file

@ -616,7 +616,7 @@ static const JLONG dither_matrix[4] = {
static INLINE boolean is_big_endian(void) static INLINE boolean is_big_endian(void)
{ {
int test_value = 1; int test_value = 1;
if(*(char *)&test_value != 1) if (*(char *)&test_value != 1)
return TRUE; return TRUE;
return FALSE; return FALSE;
} }

View file

@ -503,7 +503,7 @@ static const JLONG dither_matrix[4] = {
static INLINE boolean is_big_endian(void) static INLINE boolean is_big_endian(void)
{ {
int test_value = 1; int test_value = 1;
if(*(char *)&test_value != 1) if (*(char *)&test_value != 1)
return TRUE; return TRUE;
return FALSE; return FALSE;
} }

View file

@ -5,7 +5,7 @@
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2013, Linaro Limited. * Copyright (C) 2013, Linaro Limited.
* Copyright (C) 2014-2015, D. R. Commander. * Copyright (C) 2014-2015, 2018, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg * For conditions of distribution and use, see the accompanying README.ijg
* file. * file.
* *
@ -304,20 +304,20 @@ h2v2_merged_upsample_565D_internal (j_decompress_ptr cinfo,
rgb = PACK_SHORT_565(r, g, b); rgb = PACK_SHORT_565(r, g, b);
y = GETJSAMPLE(*inptr00++); y = GETJSAMPLE(*inptr00++);
r = range_limit[DITHER_565_R(y + cred, d1)]; r = range_limit[DITHER_565_R(y + cred, d0)];
g = range_limit[DITHER_565_G(y + cgreen, d1)]; g = range_limit[DITHER_565_G(y + cgreen, d0)];
b = range_limit[DITHER_565_B(y + cblue, d1)]; b = range_limit[DITHER_565_B(y + cblue, d0)];
d1 = DITHER_ROTATE(d1); d0 = DITHER_ROTATE(d0);
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b)); rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
WRITE_TWO_PIXELS(outptr0, rgb); WRITE_TWO_PIXELS(outptr0, rgb);
outptr0 += 4; outptr0 += 4;
y = GETJSAMPLE(*inptr01++); y = GETJSAMPLE(*inptr01++);
r = range_limit[DITHER_565_R(y + cred, d0)]; r = range_limit[DITHER_565_R(y + cred, d1)];
g = range_limit[DITHER_565_G(y + cgreen, d0)]; g = range_limit[DITHER_565_G(y + cgreen, d1)];
b = range_limit[DITHER_565_B(y + cblue, d0)]; b = range_limit[DITHER_565_B(y + cblue, d1)];
d0 = DITHER_ROTATE(d0); d1 = DITHER_ROTATE(d1);
rgb = PACK_SHORT_565(r, g, b); rgb = PACK_SHORT_565(r, g, b);
y = GETJSAMPLE(*inptr01++); y = GETJSAMPLE(*inptr01++);

View file

@ -32,8 +32,10 @@
#include "jinclude.h" #include "jinclude.h"
#include "jpeglib.h" #include "jpeglib.h"
#include "jmemsys.h" /* import the system-dependent declarations */ #include "jmemsys.h" /* import the system-dependent declarations */
#ifndef _WIN32
#include <stdint.h> #include <stdint.h>
#include <limits.h> /* some NDKs define SIZE_MAX in limits.h */ #endif
#include <limits.h>
#ifndef NO_GETENV #ifndef NO_GETENV
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare getenv() */ #ifndef HAVE_STDLIB_H /* <stdlib.h> should declare getenv() */

View file

@ -3,8 +3,8 @@
* *
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1992-1996, Thomas G. Lane. * Copyright (C) 1992-1996, Thomas G. Lane.
* It was modified by The libjpeg-turbo Project to include only code and * libjpeg-turbo Modifications:
* information relevant to libjpeg-turbo. * Copyright (C) 2017, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg * For conditions of distribution and use, see the accompanying README.ijg
* file. * file.
* *
@ -15,7 +15,6 @@
* This is very portable in the sense that it'll compile on almost anything, * This is very portable in the sense that it'll compile on almost anything,
* but you'd better have lots of main memory (or virtual memory) if you want * but you'd better have lots of main memory (or virtual memory) if you want
* to process big images. * to process big images.
* Note that the max_memory_to_use option is ignored by this implementation.
*/ */
#define JPEG_INTERNALS #define JPEG_INTERNALS
@ -66,14 +65,21 @@ jpeg_free_large (j_common_ptr cinfo, void *object, size_t sizeofobject)
/* /*
* This routine computes the total memory space available for allocation. * This routine computes the total memory space available for allocation.
* Here we always say, "we got all you want bud!"
*/ */
GLOBAL(size_t) GLOBAL(size_t)
jpeg_mem_available (j_common_ptr cinfo, size_t min_bytes_needed, jpeg_mem_available (j_common_ptr cinfo, size_t min_bytes_needed,
size_t max_bytes_needed, size_t already_allocated) size_t max_bytes_needed, size_t already_allocated)
{ {
if (cinfo->mem->max_memory_to_use) {
if (cinfo->mem->max_memory_to_use > already_allocated)
return cinfo->mem->max_memory_to_use - already_allocated;
else
return 0;
} else {
/* Here we always say, "we got all you want bud!" */
return max_bytes_needed; return max_bytes_needed;
}
} }

View file

@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-2012, Thomas G. Lane, Guido Vollbeding. * Copyright (C) 1991-2012, Thomas G. Lane, Guido Vollbeding.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2010, 2012-2016, D. R. Commander. * Copyright (C) 2010, 2012-2017, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg * For conditions of distribution and use, see the accompanying README.ijg
* file. * file.
* *
@ -35,7 +35,7 @@
* their code * their code
*/ */
#define JCOPYRIGHT "Copyright (C) 2009-2016 D. R. Commander\n" \ #define JCOPYRIGHT "Copyright (C) 2009-2017 D. R. Commander\n" \
"Copyright (C) 2011-2016 Siarhei Siamashka\n" \ "Copyright (C) 2011-2016 Siarhei Siamashka\n" \
"Copyright (C) 2015-2016 Matthieu Darbois\n" \ "Copyright (C) 2015-2016 Matthieu Darbois\n" \
"Copyright (C) 2015 Google, Inc.\n" \ "Copyright (C) 2015 Google, Inc.\n" \
@ -46,4 +46,4 @@
"Copyright (C) 1999-2006 MIYASAKA Masaru\n" \ "Copyright (C) 1999-2006 MIYASAKA Masaru\n" \
"Copyright (C) 1991-2016 Thomas G. Lane, Guido Vollbeding" \ "Copyright (C) 1991-2016 Thomas G. Lane, Guido Vollbeding" \
#define JCOPYRIGHT_SHORT "Copyright (C) 1991-2016 The libjpeg-turbo Project and many others" #define JCOPYRIGHT_SHORT "Copyright (C) 1991-2017 The libjpeg-turbo Project and many others"

View file

@ -195,11 +195,11 @@ EXTN(jsimd_huff_encode_one_block_sse2):
lea rsp, [t2] lea rsp, [t2]
collect_args collect_args
%ifdef WIN64 %ifdef WIN64
movaps XMMWORD [rsp-1*SIZEOF_XMMWORD], xmm8
movaps XMMWORD [rsp-2*SIZEOF_XMMWORD], xmm9
movaps XMMWORD [rsp-3*SIZEOF_XMMWORD], xmm10
movaps XMMWORD [rsp-4*SIZEOF_XMMWORD], xmm11
sub rsp, 4*SIZEOF_XMMWORD sub rsp, 4*SIZEOF_XMMWORD
movaps XMMWORD [rsp+0*SIZEOF_XMMWORD], xmm8
movaps XMMWORD [rsp+1*SIZEOF_XMMWORD], xmm9
movaps XMMWORD [rsp+2*SIZEOF_XMMWORD], xmm10
movaps XMMWORD [rsp+3*SIZEOF_XMMWORD], xmm11
%endif %endif
push rbx push rbx
@ -343,10 +343,10 @@ EXTN(jsimd_huff_encode_one_block_sse2):
pop rbx pop rbx
%ifdef WIN64 %ifdef WIN64
movaps xmm11, XMMWORD [rsp+0*SIZEOF_XMMWORD] movaps xmm8, XMMWORD [rsp+0*SIZEOF_XMMWORD]
movaps xmm10, XMMWORD [rsp+1*SIZEOF_XMMWORD] movaps xmm9, XMMWORD [rsp+1*SIZEOF_XMMWORD]
movaps xmm9, XMMWORD [rsp+2*SIZEOF_XMMWORD] movaps xmm10, XMMWORD [rsp+2*SIZEOF_XMMWORD]
movaps xmm8, XMMWORD [rsp+3*SIZEOF_XMMWORD] movaps xmm11, XMMWORD [rsp+3*SIZEOF_XMMWORD]
add rsp, 4*SIZEOF_XMMWORD add rsp, 4*SIZEOF_XMMWORD
%endif %endif
uncollect_args uncollect_args

View file

@ -1,7 +1,7 @@
; ;
; jchuff-sse2.asm - Huffman entropy encoding (SSE2) ; jchuff-sse2.asm - Huffman entropy encoding (SSE2)
; ;
; Copyright (C) 2009-2011, 2014-2016, D. R. Commander. ; Copyright (C) 2009-2011, 2014-2017, D. R. Commander.
; Copyright (C) 2015, Matthieu Darbois. ; Copyright (C) 2015, Matthieu Darbois.
; ;
; Based on the x86 SIMD extension for IJG JPEG library ; Based on the x86 SIMD extension for IJG JPEG library
@ -288,13 +288,13 @@ EXTN(jsimd_huff_encode_one_block_sse2):
.BLOOP: .BLOOP:
bsf ecx, edx ; r = __builtin_ctzl(index); bsf ecx, edx ; r = __builtin_ctzl(index);
jz .ELOOP jz near .ELOOP
lea esi, [esi+ecx*2] ; k += r; lea esi, [esi+ecx*2] ; k += r;
shr edx, cl ; index >>= r; shr edx, cl ; index >>= r;
mov DWORD [esp+temp3], edx mov DWORD [esp+temp3], edx
.BRLOOP: .BRLOOP:
cmp ecx, 16 ; while (r > 15) { cmp ecx, 16 ; while (r > 15) {
jl .ERLOOP jl near .ERLOOP
sub ecx, 16 ; r -= 16; sub ecx, 16 ; r -= 16;
mov DWORD [esp+temp], ecx mov DWORD [esp+temp], ecx
mov eax, INT [ebp + 240 * 4] ; code_0xf0 = actbl->ehufco[0xf0]; mov eax, INT [ebp + 240 * 4] ; code_0xf0 = actbl->ehufco[0xf0];
@ -348,7 +348,7 @@ EXTN(jsimd_huff_encode_one_block_sse2):
sub eax, esi sub eax, esi
shr eax, 1 shr eax, 1
bsf ecx, edx ; r = __builtin_ctzl(index); bsf ecx, edx ; r = __builtin_ctzl(index);
jz .ELOOP2 jz near .ELOOP2
shr edx, cl ; index >>= r; shr edx, cl ; index >>= r;
add ecx, eax add ecx, eax
lea esi, [esi+ecx*2] ; k += r; lea esi, [esi+ecx*2] ; k += r;
@ -356,13 +356,13 @@ EXTN(jsimd_huff_encode_one_block_sse2):
jmp .BRLOOP2 jmp .BRLOOP2
.BLOOP2: .BLOOP2:
bsf ecx, edx ; r = __builtin_ctzl(index); bsf ecx, edx ; r = __builtin_ctzl(index);
jz .ELOOP2 jz near .ELOOP2
lea esi, [esi+ecx*2] ; k += r; lea esi, [esi+ecx*2] ; k += r;
shr edx, cl ; index >>= r; shr edx, cl ; index >>= r;
mov DWORD [esp+temp3], edx mov DWORD [esp+temp3], edx
.BRLOOP2: .BRLOOP2:
cmp ecx, 16 ; while (r > 15) { cmp ecx, 16 ; while (r > 15) {
jl .ERLOOP2 jl near .ERLOOP2
sub ecx, 16 ; r -= 16; sub ecx, 16 ; r -= 16;
mov DWORD [esp+temp], ecx mov DWORD [esp+temp], ecx
mov eax, INT [ebp + 240 * 4] ; code_0xf0 = actbl->ehufco[0xf0]; mov eax, INT [ebp + 240 * 4] ; code_0xf0 = actbl->ehufco[0xf0];

View file

@ -2,6 +2,7 @@
* jsimd_arm.c * jsimd_arm.c
* *
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
* Copyright (C) 2011, Nokia Corporation and/or its subsidiary(-ies).
* Copyright (C) 2009-2011, 2013-2014, 2016, D. R. Commander. * Copyright (C) 2009-2011, 2013-2014, 2016, D. R. Commander.
* Copyright (C) 2015-2016, Matthieu Darbois. * Copyright (C) 2015-2016, Matthieu Darbois.
* *

View file

@ -2,6 +2,7 @@
* jsimd_arm64.c * jsimd_arm64.c
* *
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
* Copyright (C) 2011, Nokia Corporation and/or its subsidiary(-ies).
* Copyright (C) 2009-2011, 2013-2014, 2016, D. R. Commander. * Copyright (C) 2009-2011, 2013-2014, 2016, D. R. Commander.
* Copyright (C) 2015-2016, Matthieu Darbois. * Copyright (C) 2015-2016, Matthieu Darbois.
* *

View file

@ -63,6 +63,8 @@ parse_proc_cpuinfo(const char* search_string)
LOCAL(void) LOCAL(void)
init_simd (void) init_simd (void)
{ {
char *env = NULL;
if (simd_support != ~0U) if (simd_support != ~0U)
return; return;

View file

@ -4484,4 +4484,3 @@ LEAF_MIPS_DSPR2(jsimd_convsamp_float_mips_dspr2)
END(jsimd_convsamp_float_mips_dspr2) END(jsimd_convsamp_float_mips_dspr2)
/*****************************************************************************/ /*****************************************************************************/

View file

@ -281,5 +281,3 @@ LEAF_MIPS32R2(symbol) \
addiu sp, sp, \stack_offset addiu sp, sp, \stack_offset
.endif .endif
.endm .endm

View file

@ -14,6 +14,11 @@
* PowerPC architecture. * PowerPC architecture.
*/ */
#ifdef __amigaos4__
/* This must be defined first as it re-defines GLOBAL otherwise */
#include <proto/exec.h>
#endif
#define JPEG_INTERNALS #define JPEG_INTERNALS
#include "../jinclude.h" #include "../jinclude.h"
#include "../jpeglib.h" #include "../jpeglib.h"
@ -26,6 +31,12 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#if defined(__OpenBSD__)
#include <sys/param.h>
#include <sys/sysctl.h>
#include <machine/cpu.h>
#endif
static unsigned int simd_support = ~0; static unsigned int simd_support = ~0;
#if defined(__linux__) || defined(ANDROID) || defined(__ANDROID__) #if defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)
@ -101,6 +112,12 @@ init_simd (void)
char *env = NULL; char *env = NULL;
#if !defined(__ALTIVEC__) && (defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)) #if !defined(__ALTIVEC__) && (defined(__linux__) || defined(ANDROID) || defined(__ANDROID__))
int bufsize = 1024; /* an initial guess for the line buffer size limit */ int bufsize = 1024; /* an initial guess for the line buffer size limit */
#elif defined(__amigaos4__)
uint32 altivec = 0;
#elif defined(__OpenBSD__)
int mib[2] = { CTL_MACHDEP, CPU_ALTIVEC };
int altivec;
size_t len = sizeof(altivec);
#endif #endif
if (simd_support != ~0U) if (simd_support != ~0U)
@ -116,6 +133,13 @@ init_simd (void)
if (bufsize > SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT) if (bufsize > SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT)
break; break;
} }
#elif defined(__amigaos4__)
IExec->GetCPUInfoTags(GCIT_VectorUnit, &altivec, TAG_DONE);
if(altivec == VECTORTYPE_ALTIVEC)
simd_support |= JSIMD_ALTIVEC;
#elif defined(__OpenBSD__)
if (sysctl(mib, 2, &altivec, &len, NULL, 0) == 0 && altivec != 0)
simd_support |= JSIMD_ALTIVEC;
#endif #endif
/* Force different settings through environment variables */ /* Force different settings through environment variables */