--- /dev/null
- simd/jimmxred.asm simd/jimmxint.asm simd/jimmxfst.asm
+noinst_LTLIBRARIES = libjpeg.la
+
+HDRS = jchuff.h jdct.h jdhuff.h jerror.h jinclude.h jmemsys.h jmorecfg.h \
+ jpegint.h jpeglib.h jversion.h jsimd.h jsimddct.h
+
+libjpeg_la_SOURCES = $(HDRS) jcapimin.c jcapistd.c jccoefct.c jccolor.c \
+ jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c \
+ jcomapi.c jcparam.c jcphuff.c jcprepct.c jcsample.c jctrans.c \
+ jdapimin.c jdapistd.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c \
+ jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c \
+ jdmerge.c jdphuff.c jdpostct.c jdsample.c jdtrans.c jerror.c \
+ jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c \
+ jidctred.c jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c \
+ jsimd.c
+
+if WITH_SIMD
+
+BUILT_SOURCES = simd/jsimdcfg.inc
+
+EXTRA_DIST = nasm_lt.sh
+
+libjpeg_la_SOURCES += simd/jsimd.h simd/jsimdcfg.inc.h \
+ simd/jsimdext.inc simd/jcolsamp.inc simd/jdct.inc \
+ simd/jsimdcpu.asm \
+ simd/jccolmmx.asm simd/jdcolmmx.asm \
+ simd/jcsammmx.asm simd/jdsammmx.asm simd/jdmermmx.asm \
+ simd/jcqntmmx.asm simd/jfmmxfst.asm simd/jfmmxint.asm \
++ simd/jimmxred.asm simd/jimmxint.asm simd/jimmxfst.asm \
++ simd/jcqnt3dn.asm simd/jf3dnflt.asm simd/ji3dnflt.asm
+
+endif
+
+.asm.lo:
+ $(LIBTOOL) --mode=compile --tag NASM ./nasm_lt.sh $(NASM) $(NAFLAGS) $< -o $@
+
+simd/jsimdcfg.inc: simd/jsimdcfg.inc.h jpeglib.h jconfig.h jmorecfg.h
+ $(CPP) $< | grep ^[\;%] | sed 's%_cpp_protection_%%' > $@
+
--- /dev/null
+/*
+ * jsimd.c
+ *
+ * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
+ *
+ * Based on the x86 SIMD extension for IJG JPEG library,
+ * Copyright (C) 1999-2006, MIYASAKA Masaru.
+ *
+ * This file contains the interface between the "normal" portions
+ * of the library and the SIMD implementations.
+ */
+
+#define JPEG_INTERNALS
+#include "jinclude.h"
+#include "jpeglib.h"
+#include "jsimd.h"
+#include "jdct.h"
+#include "jsimddct.h"
+#include "simd/jsimd.h"
+
+static unsigned int simd_support = ~0;
+
+/*
+ * Check what SIMD accelerations are supported.
+ *
+ * FIXME: This code is racy under a multi-threaded environment.
+ */
+LOCAL(void)
+init_simd (void)
+{
+ if (simd_support != ~0)
+ return;
+
+#ifdef WITH_SIMD
+ simd_support = jpeg_simd_cpu_support();
+#else
+ simd_support = JSIMD_NONE;
+#endif
+}
+
+GLOBAL(int)
+jsimd_can_rgb_ycc (void)
+{
+ init_simd();
+
+ /* The code is optimised for these values only */
+ if (BITS_IN_JSAMPLE != 8)
+ return 0;
+ if (sizeof(JDIMENSION) != 4)
+ return 0;
+ if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
+ return 0;
+
+ if (simd_support & JSIMD_MMX)
+ return 1;
+
+ return 0;
+}
+
+GLOBAL(int)
+jsimd_can_ycc_rgb (void)
+{
+ init_simd();
+
+ /* The code is optimised for these values only */
+ if (BITS_IN_JSAMPLE != 8)
+ return 0;
+ if (sizeof(JDIMENSION) != 4)
+ return 0;
+ if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
+ return 0;
+
+ if (simd_support & JSIMD_MMX)
+ return 1;
+
+ return 0;
+}
+
+GLOBAL(void)
+jsimd_rgb_ycc_convert (j_compress_ptr cinfo,
+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
+ JDIMENSION output_row, int num_rows)
+{
+#ifdef WITH_SIMD
+ if (simd_support & JSIMD_MMX)
+ jsimd_rgb_ycc_convert_mmx(cinfo->image_width, input_buf,
+ output_buf, output_row, num_rows);
+#endif
+}
+
+GLOBAL(void)
+jsimd_ycc_rgb_convert (j_decompress_ptr cinfo,
+ JSAMPIMAGE input_buf, JDIMENSION input_row,
+ JSAMPARRAY output_buf, int num_rows)
+{
+#ifdef WITH_SIMD
+ if (simd_support & JSIMD_MMX)
+ jsimd_ycc_rgb_convert_mmx(cinfo->output_width, input_buf,
+ input_row, output_buf, num_rows);
+#endif
+}
+
+GLOBAL(int)
+jsimd_can_h2v2_downsample (void)
+{
+ init_simd();
+
+ /* The code is optimised for these values only */
+ if (BITS_IN_JSAMPLE != 8)
+ return 0;
+ if (sizeof(JDIMENSION) != 4)
+ return 0;
+
+ if (simd_support & JSIMD_MMX)
+ return 1;
+
+ return 0;
+}
+
+GLOBAL(int)
+jsimd_can_h2v1_downsample (void)
+{
+ init_simd();
+
+ /* The code is optimised for these values only */
+ if (BITS_IN_JSAMPLE != 8)
+ return 0;
+ if (sizeof(JDIMENSION) != 4)
+ return 0;
+
+ if (simd_support & JSIMD_MMX)
+ return 1;
+
+ return 0;
+}
+
+GLOBAL(void)
+jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
+ JSAMPARRAY input_data, JSAMPARRAY output_data)
+{
+#ifdef WITH_SIMD
+ if (simd_support & JSIMD_MMX)
+ jsimd_h2v2_downsample_mmx(cinfo->image_width, cinfo->max_v_samp_factor,
+ compptr->v_samp_factor, compptr->width_in_blocks,
+ input_data, output_data);
+#endif
+}
+
+GLOBAL(void)
+jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
+ JSAMPARRAY input_data, JSAMPARRAY output_data)
+{
+#ifdef WITH_SIMD
+ if (simd_support & JSIMD_MMX)
+ jsimd_h2v1_downsample_mmx(cinfo->image_width, cinfo->max_v_samp_factor,
+ compptr->v_samp_factor, compptr->width_in_blocks,
+ input_data, output_data);
+#endif
+}
+
+GLOBAL(int)
+jsimd_can_h2v2_upsample (void)
+{
+ init_simd();
+
+ /* The code is optimised for these values only */
+ if (BITS_IN_JSAMPLE != 8)
+ return 0;
+ if (sizeof(JDIMENSION) != 4)
+ return 0;
+
+ if (simd_support & JSIMD_MMX)
+ return 1;
+
+ return 0;
+}
+
+GLOBAL(int)
+jsimd_can_h2v1_upsample (void)
+{
+ init_simd();
+
+ /* The code is optimised for these values only */
+ if (BITS_IN_JSAMPLE != 8)
+ return 0;
+ if (sizeof(JDIMENSION) != 4)
+ return 0;
+
+ if (simd_support & JSIMD_MMX)
+ return 1;
+
+ return 0;
+}
+
+GLOBAL(void)
+jsimd_h2v2_upsample (j_decompress_ptr cinfo,
+ jpeg_component_info * compptr,
+ JSAMPARRAY input_data,
+ JSAMPARRAY * output_data_ptr)
+{
+#ifdef WITH_SIMD
+ if (simd_support & JSIMD_MMX)
+ jsimd_h2v2_upsample_mmx(cinfo->max_v_samp_factor,
+ cinfo->output_width, input_data, output_data_ptr);
+#endif
+}
+
+GLOBAL(void)
+jsimd_h2v1_upsample (j_decompress_ptr cinfo,
+ jpeg_component_info * compptr,
+ JSAMPARRAY input_data,
+ JSAMPARRAY * output_data_ptr)
+{
+#ifdef WITH_SIMD
+ if (simd_support & JSIMD_MMX)
+ jsimd_h2v1_upsample_mmx(cinfo->max_v_samp_factor,
+ cinfo->output_width, input_data, output_data_ptr);
+#endif
+}
+
+GLOBAL(int)
+jsimd_can_h2v2_fancy_upsample (void)
+{
+ init_simd();
+
+ /* The code is optimised for these values only */
+ if (BITS_IN_JSAMPLE != 8)
+ return 0;
+ if (sizeof(JDIMENSION) != 4)
+ return 0;
+
+ if (simd_support & JSIMD_MMX)
+ return 1;
+
+ return 0;
+}
+
+GLOBAL(int)
+jsimd_can_h2v1_fancy_upsample (void)
+{
+ init_simd();
+
+ /* The code is optimised for these values only */
+ if (BITS_IN_JSAMPLE != 8)
+ return 0;
+ if (sizeof(JDIMENSION) != 4)
+ return 0;
+
+ if (simd_support & JSIMD_MMX)
+ return 1;
+
+ return 0;
+}
+
+GLOBAL(void)
+jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo,
+ jpeg_component_info * compptr,
+ JSAMPARRAY input_data,
+ JSAMPARRAY * output_data_ptr)
+{
+#ifdef WITH_SIMD
+ if (simd_support & JSIMD_MMX)
+ jsimd_h2v2_fancy_upsample_mmx(cinfo->max_v_samp_factor,
+ compptr->downsampled_width, input_data, output_data_ptr);
+#endif
+}
+
+GLOBAL(void)
+jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo,
+ jpeg_component_info * compptr,
+ JSAMPARRAY input_data,
+ JSAMPARRAY * output_data_ptr)
+{
+#ifdef WITH_SIMD
+ if (simd_support & JSIMD_MMX)
+ jsimd_h2v1_fancy_upsample_mmx(cinfo->max_v_samp_factor,
+ compptr->downsampled_width, input_data, output_data_ptr);
+#endif
+}
+
+GLOBAL(int)
+jsimd_can_h2v2_merged_upsample (void)
+{
+ init_simd();
+
+ /* The code is optimised for these values only */
+ if (BITS_IN_JSAMPLE != 8)
+ return 0;
+ if (sizeof(JDIMENSION) != 4)
+ return 0;
+
+ if (simd_support & JSIMD_MMX)
+ return 1;
+
+ return 0;
+}
+
+GLOBAL(int)
+jsimd_can_h2v1_merged_upsample (void)
+{
+ init_simd();
+
+ /* The code is optimised for these values only */
+ if (BITS_IN_JSAMPLE != 8)
+ return 0;
+ if (sizeof(JDIMENSION) != 4)
+ return 0;
+
+ if (simd_support & JSIMD_MMX)
+ return 1;
+
+ return 0;
+}
+
+GLOBAL(void)
+jsimd_h2v2_merged_upsample (j_decompress_ptr cinfo,
+ JSAMPIMAGE input_buf,
+ JDIMENSION in_row_group_ctr,
+ JSAMPARRAY output_buf)
+{
+#ifdef WITH_SIMD
+ if (simd_support & JSIMD_MMX)
+ jsimd_h2v2_merged_upsample_mmx(cinfo->output_width, input_buf,
+ in_row_group_ctr, output_buf);
+#endif
+}
+
+GLOBAL(void)
+jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo,
+ JSAMPIMAGE input_buf,
+ JDIMENSION in_row_group_ctr,
+ JSAMPARRAY output_buf)
+{
+#ifdef WITH_SIMD
+ if (simd_support & JSIMD_MMX)
+ jsimd_h2v1_merged_upsample_mmx(cinfo->output_width, input_buf,
+ in_row_group_ctr, output_buf);
+#endif
+}
+
+GLOBAL(int)
+jsimd_can_convsamp (void)
+{
+ init_simd();
+
+ /* The code is optimised for these values only */
+ if (DCTSIZE != 8)
+ return 0;
+ if (BITS_IN_JSAMPLE != 8)
+ return 0;
+ if (sizeof(JDIMENSION) != 4)
+ return 0;
+ if (sizeof(DCTELEM) != 2)
+ return 0;
+
+ if (simd_support & JSIMD_MMX)
+ return 1;
+
+ return 0;
+}
+
+GLOBAL(int)
+jsimd_can_convsamp_float (void)
+{
+ init_simd();
+
++ /* The code is optimised for these values only */
++ if (DCTSIZE != 8)
++ return 0;
++ if (BITS_IN_JSAMPLE != 8)
++ return 0;
++ if (sizeof(JDIMENSION) != 4)
++ return 0;
++ if (sizeof(FAST_FLOAT) != 4)
++ return 0;
++
++ if (simd_support & JSIMD_3DNOW)
++ return 1;
++
+ return 0;
+}
+
+GLOBAL(void)
+jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col,
+ DCTELEM * workspace)
+{
+#ifdef WITH_SIMD
+ if (simd_support & JSIMD_MMX)
+ jsimd_convsamp_mmx(sample_data, start_col, workspace);
+#endif
+}
+
+GLOBAL(void)
+jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col,
+ FAST_FLOAT * workspace)
+{
++#ifdef WITH_SIMD
++ if (simd_support & JSIMD_3DNOW)
++ jsimd_convsamp_float_3dnow(sample_data, start_col, workspace);
++#endif
+}
+
+GLOBAL(int)
+jsimd_can_fdct_islow (void)
+{
+ init_simd();
+
+ /* The code is optimised for these values only */
+ if (DCTSIZE != 8)
+ return 0;
+ if (sizeof(DCTELEM) != 2)
+ return 0;
+
+ if (simd_support & JSIMD_MMX)
+ return 1;
+
+ return 0;
+}
+
+GLOBAL(int)
+jsimd_can_fdct_ifast (void)
+{
+ init_simd();
+
+ /* The code is optimised for these values only */
+ if (DCTSIZE != 8)
+ return 0;
+ if (sizeof(DCTELEM) != 2)
+ return 0;
+
+ if (simd_support & JSIMD_MMX)
+ return 1;
+
+ return 0;
+}
+
+GLOBAL(int)
+jsimd_can_fdct_float (void)
+{
+ init_simd();
+
++ /* The code is optimised for these values only */
++ if (DCTSIZE != 8)
++ return 0;
++ if (sizeof(FAST_FLOAT) != 4)
++ return 0;
++
++ if (simd_support & JSIMD_3DNOW)
++ return 1;
++
+ return 0;
+}
+
+GLOBAL(void)
+jsimd_fdct_islow (DCTELEM * data)
+{
+#ifdef WITH_SIMD
+ if (simd_support & JSIMD_MMX)
+ jsimd_fdct_islow_mmx(data);
+#endif
+}
+
+GLOBAL(void)
+jsimd_fdct_ifast (DCTELEM * data)
+{
+#ifdef WITH_SIMD
+ if (simd_support & JSIMD_MMX)
+ jsimd_fdct_ifast_mmx(data);
+#endif
+}
+
+GLOBAL(void)
+jsimd_fdct_float (FAST_FLOAT * data)
+{
++#ifdef WITH_SIMD
++ if (simd_support & JSIMD_3DNOW)
++ jsimd_fdct_float_3dnow(data);
++#endif
+}
+
+GLOBAL(int)
+jsimd_can_quantize (void)
+{
+ init_simd();
+
+ /* The code is optimised for these values only */
+ if (DCTSIZE != 8)
+ return 0;
+ if (sizeof(JCOEF) != 2)
+ return 0;
+ if (sizeof(DCTELEM) != 2)
+ return 0;
+
+ if (simd_support & JSIMD_MMX)
+ return 1;
+
+ return 0;
+}
+
+GLOBAL(int)
+jsimd_can_quantize_float (void)
+{
+ init_simd();
+
++ /* The code is optimised for these values only */
++ if (DCTSIZE != 8)
++ return 0;
++ if (sizeof(JCOEF) != 2)
++ return 0;
++ if (sizeof(FAST_FLOAT) != 4)
++ return 0;
++
++ if (simd_support & JSIMD_3DNOW)
++ return 1;
++
+ return 0;
+}
+
+GLOBAL(void)
+jsimd_quantize (JCOEFPTR coef_block, DCTELEM * divisors,
+ DCTELEM * workspace)
+{
+#ifdef WITH_SIMD
+ if (simd_support & JSIMD_MMX)
+ jsimd_quantize_mmx(coef_block, divisors, workspace);
+#endif
+}
+
+GLOBAL(void)
+jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT * divisors,
+ FAST_FLOAT * workspace)
+{
++#ifdef WITH_SIMD
++ if (simd_support & JSIMD_3DNOW)
++ jsimd_quantize_float_3dnow(coef_block, divisors, workspace);
++#endif
+}
+
+GLOBAL(int)
+jsimd_can_idct_2x2 (void)
+{
+ init_simd();
+
+ /* The code is optimised for these values only */
+ if (DCTSIZE != 8)
+ return 0;
+ if (sizeof(JCOEF) != 2)
+ return 0;
+ if (BITS_IN_JSAMPLE != 8)
+ return 0;
+ if (sizeof(JDIMENSION) != 4)
+ return 0;
+ if (sizeof(ISLOW_MULT_TYPE) != 2)
+ return 0;
+
+ if (simd_support & JSIMD_MMX)
+ return 1;
+
+ return 0;
+}
+
+GLOBAL(int)
+jsimd_can_idct_4x4 (void)
+{
+ init_simd();
+
+ /* The code is optimised for these values only */
+ if (DCTSIZE != 8)
+ return 0;
+ if (sizeof(JCOEF) != 2)
+ return 0;
+ if (BITS_IN_JSAMPLE != 8)
+ return 0;
+ if (sizeof(JDIMENSION) != 4)
+ return 0;
+ if (sizeof(ISLOW_MULT_TYPE) != 2)
+ return 0;
+
+ if (simd_support & JSIMD_MMX)
+ return 1;
+
+ return 0;
+}
+
+GLOBAL(void)
+jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
+ JCOEFPTR coef_block, JSAMPARRAY output_buf,
+ JDIMENSION output_col)
+{
+#if WITH_SIMD
+ if (simd_support & JSIMD_MMX)
+ jsimd_idct_2x2_mmx(compptr->dct_table, coef_block, output_buf, output_col);
+#endif
+}
+
+GLOBAL(void)
+jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
+ JCOEFPTR coef_block, JSAMPARRAY output_buf,
+ JDIMENSION output_col)
+{
+#if WITH_SIMD
+ if (simd_support & JSIMD_MMX)
+ jsimd_idct_4x4_mmx(compptr->dct_table, coef_block, output_buf, output_col);
+#endif
+}
+
+GLOBAL(int)
+jsimd_can_idct_islow (void)
+{
+ init_simd();
+
+ /* The code is optimised for these values only */
+ if (DCTSIZE != 8)
+ return 0;
+ if (sizeof(JCOEF) != 2)
+ return 0;
+ if (BITS_IN_JSAMPLE != 8)
+ return 0;
+ if (sizeof(JDIMENSION) != 4)
+ return 0;
+ if (sizeof(ISLOW_MULT_TYPE) != 2)
+ return 0;
+
+ if (simd_support & JSIMD_MMX)
+ return 1;
+
+ return 0;
+}
+
+GLOBAL(int)
+jsimd_can_idct_ifast (void)
+{
+ init_simd();
+
+ /* The code is optimised for these values only */
+ if (DCTSIZE != 8)
+ return 0;
+ if (sizeof(JCOEF) != 2)
+ return 0;
+ if (BITS_IN_JSAMPLE != 8)
+ return 0;
+ if (sizeof(JDIMENSION) != 4)
+ return 0;
+ if (sizeof(IFAST_MULT_TYPE) != 2)
+ return 0;
+ if (IFAST_SCALE_BITS != 2)
+ return 0;
+
+ if (simd_support & JSIMD_MMX)
+ return 1;
+
+ return 0;
+}
+
+GLOBAL(int)
+jsimd_can_idct_float (void)
+{
+ init_simd();
+
++ if (DCTSIZE != 8)
++ return 0;
++ if (sizeof(JCOEF) != 2)
++ return 0;
++ if (BITS_IN_JSAMPLE != 8)
++ return 0;
++ if (sizeof(JDIMENSION) != 4)
++ return 0;
++ if (sizeof(FAST_FLOAT) != 4)
++ return 0;
++ if (sizeof(FLOAT_MULT_TYPE) != 4)
++ return 0;
++
++ if (simd_support & JSIMD_3DNOW)
++ return 1;
++
+ return 0;
+}
+
+GLOBAL(void)
+jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr,
+ JCOEFPTR coef_block, JSAMPARRAY output_buf,
+ JDIMENSION output_col)
+{
+#if WITH_SIMD
+ if (simd_support & JSIMD_MMX)
+ jsimd_idct_islow_mmx(compptr->dct_table, coef_block, output_buf, output_col);
+#endif
+}
+
+GLOBAL(void)
+jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
+ JCOEFPTR coef_block, JSAMPARRAY output_buf,
+ JDIMENSION output_col)
+{
+#if WITH_SIMD
+ if (simd_support & JSIMD_MMX)
+ jsimd_idct_ifast_mmx(compptr->dct_table, coef_block, output_buf, output_col);
+#endif
+}
+
+GLOBAL(void)
+jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr,
+ JCOEFPTR coef_block, JSAMPARRAY output_buf,
+ JDIMENSION output_col)
+{
++#if WITH_SIMD
++ if (simd_support & JSIMD_3DNOW)
++ jsimd_idct_float_3dnow(compptr->dct_table, coef_block,
++ output_buf, output_col);
++#endif
+}
+
--- /dev/null
-; Last Modified : January 23, 2006
-;
+ ;
+ ; jcqnt3dn.asm - sample data conversion and quantization (3DNow! & MMX)
+ ;
++; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
++;
++; Based on
+ ; x86 SIMD extension for IJG JPEG library
+ ; Copyright (C) 1999-2006, MIYASAKA Masaru.
+ ; For conditions of distribution and use, see copyright notice in jsimdext.inc
+ ;
+ ; This file should be assembled with NASM (Netwide Assembler),
+ ; can *not* be assembled with Microsoft's MASM or any compatible
+ ; assembler (including Borland's Turbo Assembler).
+ ; NASM is available from http://nasm.sourceforge.net/ or
+ ; http://sourceforge.net/project/showfiles.php?group_id=6208
+ ;
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-%ifdef DCT_FLOAT_SUPPORTED
-%ifdef JFDCT_FLT_3DNOW_MMX_SUPPORTED
-
-; This module is specialized to the case DCTSIZE = 8.
-;
-%if DCTSIZE != 8
-%error "Sorry, this code only copes with 8x8 DCTs."
-%endif
+ ; [TAB8]
+
-; jpeg_convsamp_flt_3dnow (JSAMPARRAY sample_data, JDIMENSION start_col,
-; FAST_FLOAT * workspace);
++%include "simd/jsimdext.inc"
++%include "simd/jdct.inc"
+
+ ; --------------------------------------------------------------------------
+ SECTION SEG_TEXT
+ BITS 32
+ ;
+ ; Load data into workspace, applying unsigned->signed conversion
+ ;
+ ; GLOBAL(void)
- global EXTN(jpeg_convsamp_flt_3dnow)
++; jsimd_convsamp_float_3dnow (JSAMPARRAY sample_data, JDIMENSION start_col,
++; FAST_FLOAT * workspace);
+ ;
+
+ %define sample_data ebp+8 ; JSAMPARRAY sample_data
+ %define start_col ebp+12 ; JDIMENSION start_col
+ %define workspace ebp+16 ; FAST_FLOAT * workspace
+
+ align 16
-EXTN(jpeg_convsamp_flt_3dnow):
++ global EXTN(jsimd_convsamp_float_3dnow)
+
-; jpeg_quantize_flt_3dnow (JCOEFPTR coef_block, FAST_FLOAT * divisors,
-; FAST_FLOAT * workspace);
++EXTN(jsimd_convsamp_float_3dnow):
+ push ebp
+ mov ebp,esp
+ push ebx
+ ; push ecx ; need not be preserved
+ ; push edx ; need not be preserved
+ push esi
+ push edi
+
+ pcmpeqw mm7,mm7
+ psllw mm7,7
+ packsswb mm7,mm7 ; mm7 = PB_CENTERJSAMPLE (0x808080..)
+
+ mov esi, JSAMPARRAY [sample_data] ; (JSAMPROW *)
+ mov eax, JDIMENSION [start_col]
+ mov edi, POINTER [workspace] ; (DCTELEM *)
+ mov ecx, DCTSIZE/2
+ alignx 16,7
+ .convloop:
+ mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
+ mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
+
+ movq mm0, MMWORD [ebx+eax*SIZEOF_JSAMPLE]
+ movq mm1, MMWORD [edx+eax*SIZEOF_JSAMPLE]
+
+ psubb mm0,mm7 ; mm0=(01234567)
+ psubb mm1,mm7 ; mm1=(89ABCDEF)
+
+ punpcklbw mm2,mm0 ; mm2=(*0*1*2*3)
+ punpckhbw mm0,mm0 ; mm0=(*4*5*6*7)
+ punpcklbw mm3,mm1 ; mm3=(*8*9*A*B)
+ punpckhbw mm1,mm1 ; mm1=(*C*D*E*F)
+
+ punpcklwd mm4,mm2 ; mm4=(***0***1)
+ punpckhwd mm2,mm2 ; mm2=(***2***3)
+ punpcklwd mm5,mm0 ; mm5=(***4***5)
+ punpckhwd mm0,mm0 ; mm0=(***6***7)
+
+ psrad mm4,(DWORD_BIT-BYTE_BIT) ; mm4=(01)
+ psrad mm2,(DWORD_BIT-BYTE_BIT) ; mm2=(23)
+ pi2fd mm4,mm4
+ pi2fd mm2,mm2
+ psrad mm5,(DWORD_BIT-BYTE_BIT) ; mm5=(45)
+ psrad mm0,(DWORD_BIT-BYTE_BIT) ; mm0=(67)
+ pi2fd mm5,mm5
+ pi2fd mm0,mm0
+
+ movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], mm4
+ movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], mm2
+ movq MMWORD [MMBLOCK(0,2,edi,SIZEOF_FAST_FLOAT)], mm5
+ movq MMWORD [MMBLOCK(0,3,edi,SIZEOF_FAST_FLOAT)], mm0
+
+ punpcklwd mm6,mm3 ; mm6=(***8***9)
+ punpckhwd mm3,mm3 ; mm3=(***A***B)
+ punpcklwd mm4,mm1 ; mm4=(***C***D)
+ punpckhwd mm1,mm1 ; mm1=(***E***F)
+
+ psrad mm6,(DWORD_BIT-BYTE_BIT) ; mm6=(89)
+ psrad mm3,(DWORD_BIT-BYTE_BIT) ; mm3=(AB)
+ pi2fd mm6,mm6
+ pi2fd mm3,mm3
+ psrad mm4,(DWORD_BIT-BYTE_BIT) ; mm4=(CD)
+ psrad mm1,(DWORD_BIT-BYTE_BIT) ; mm1=(EF)
+ pi2fd mm4,mm4
+ pi2fd mm1,mm1
+
+ movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], mm6
+ movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], mm3
+ movq MMWORD [MMBLOCK(1,2,edi,SIZEOF_FAST_FLOAT)], mm4
+ movq MMWORD [MMBLOCK(1,3,edi,SIZEOF_FAST_FLOAT)], mm1
+
+ add esi, byte 2*SIZEOF_JSAMPROW
+ add edi, byte 2*DCTSIZE*SIZEOF_FAST_FLOAT
+ dec ecx
+ jnz near .convloop
+
+ femms ; empty MMX/3DNow! state
+
+ pop edi
+ pop esi
+ ; pop edx ; need not be preserved
+ ; pop ecx ; need not be preserved
+ pop ebx
+ pop ebp
+ ret
+
+
+ ; --------------------------------------------------------------------------
+ ;
+ ; Quantize/descale the coefficients, and store into coef_block
+ ;
+ ; GLOBAL(void)
- global EXTN(jpeg_quantize_flt_3dnow)
++; jsimd_quantize_float_3dnow (JCOEFPTR coef_block, FAST_FLOAT * divisors,
++; FAST_FLOAT * workspace);
+ ;
+
+ %define coef_block ebp+8 ; JCOEFPTR coef_block
+ %define divisors ebp+12 ; FAST_FLOAT * divisors
+ %define workspace ebp+16 ; FAST_FLOAT * workspace
+
+ align 16
-EXTN(jpeg_quantize_flt_3dnow):
++ global EXTN(jsimd_quantize_float_3dnow)
+
-%endif ; JFDCT_FLT_3DNOW_MMX_SUPPORTED
-%endif ; DCT_FLOAT_SUPPORTED
++EXTN(jsimd_quantize_float_3dnow):
+ push ebp
+ mov ebp,esp
+ ; push ebx ; unused
+ ; push ecx ; unused
+ ; push edx ; need not be preserved
+ push esi
+ push edi
+
+ mov eax, 0x4B400000 ; (float)0x00C00000 (rndint_magic)
+ movd mm7,eax
+ punpckldq mm7,mm7 ; mm7={12582912.0F 12582912.0F}
+
+ mov esi, POINTER [workspace]
+ mov edx, POINTER [divisors]
+ mov edi, JCOEFPTR [coef_block]
+ mov eax, DCTSIZE2/16
+ alignx 16,7
+ .quantloop:
+ movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)]
+ movq mm1, MMWORD [MMBLOCK(0,1,esi,SIZEOF_FAST_FLOAT)]
+ pfmul mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)]
+ pfmul mm1, MMWORD [MMBLOCK(0,1,edx,SIZEOF_FAST_FLOAT)]
+ movq mm2, MMWORD [MMBLOCK(0,2,esi,SIZEOF_FAST_FLOAT)]
+ movq mm3, MMWORD [MMBLOCK(0,3,esi,SIZEOF_FAST_FLOAT)]
+ pfmul mm2, MMWORD [MMBLOCK(0,2,edx,SIZEOF_FAST_FLOAT)]
+ pfmul mm3, MMWORD [MMBLOCK(0,3,edx,SIZEOF_FAST_FLOAT)]
+
+ pfadd mm0,mm7 ; mm0=(00 ** 01 **)
+ pfadd mm1,mm7 ; mm1=(02 ** 03 **)
+ pfadd mm2,mm7 ; mm0=(04 ** 05 **)
+ pfadd mm3,mm7 ; mm1=(06 ** 07 **)
+
+ movq mm4,mm0
+ punpcklwd mm0,mm1 ; mm0=(00 02 ** **)
+ punpckhwd mm4,mm1 ; mm4=(01 03 ** **)
+ movq mm5,mm2
+ punpcklwd mm2,mm3 ; mm2=(04 06 ** **)
+ punpckhwd mm5,mm3 ; mm5=(05 07 ** **)
+
+ punpcklwd mm0,mm4 ; mm0=(00 01 02 03)
+ punpcklwd mm2,mm5 ; mm2=(04 05 06 07)
+
+ movq mm6, MMWORD [MMBLOCK(1,0,esi,SIZEOF_FAST_FLOAT)]
+ movq mm1, MMWORD [MMBLOCK(1,1,esi,SIZEOF_FAST_FLOAT)]
+ pfmul mm6, MMWORD [MMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)]
+ pfmul mm1, MMWORD [MMBLOCK(1,1,edx,SIZEOF_FAST_FLOAT)]
+ movq mm3, MMWORD [MMBLOCK(1,2,esi,SIZEOF_FAST_FLOAT)]
+ movq mm4, MMWORD [MMBLOCK(1,3,esi,SIZEOF_FAST_FLOAT)]
+ pfmul mm3, MMWORD [MMBLOCK(1,2,edx,SIZEOF_FAST_FLOAT)]
+ pfmul mm4, MMWORD [MMBLOCK(1,3,edx,SIZEOF_FAST_FLOAT)]
+
+ pfadd mm6,mm7 ; mm0=(10 ** 11 **)
+ pfadd mm1,mm7 ; mm4=(12 ** 13 **)
+ pfadd mm3,mm7 ; mm0=(14 ** 15 **)
+ pfadd mm4,mm7 ; mm4=(16 ** 17 **)
+
+ movq mm5,mm6
+ punpcklwd mm6,mm1 ; mm6=(10 12 ** **)
+ punpckhwd mm5,mm1 ; mm5=(11 13 ** **)
+ movq mm1,mm3
+ punpcklwd mm3,mm4 ; mm3=(14 16 ** **)
+ punpckhwd mm1,mm4 ; mm1=(15 17 ** **)
+
+ punpcklwd mm6,mm5 ; mm6=(10 11 12 13)
+ punpcklwd mm3,mm1 ; mm3=(14 15 16 17)
+
+ movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm0
+ movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_JCOEF)], mm2
+ movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm6
+ movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_JCOEF)], mm3
+
+ add esi, byte 16*SIZEOF_FAST_FLOAT
+ add edx, byte 16*SIZEOF_FAST_FLOAT
+ add edi, byte 16*SIZEOF_JCOEF
+ dec eax
+ jnz near .quantloop
+
+ femms ; empty MMX/3DNow! state
+
+ pop edi
+ pop esi
+ ; pop edx ; need not be preserved
+ ; pop ecx ; unused
+ ; pop ebx ; unused
+ pop ebp
+ ret
+
--- /dev/null
-; Last Modified : February 4, 2006
-;
+ ;
+ ; jf3dnflt.asm - floating-point FDCT (3DNow!)
+ ;
++; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
++;
++; Based on
+ ; x86 SIMD extension for IJG JPEG library
+ ; Copyright (C) 1999-2006, MIYASAKA Masaru.
+ ; For conditions of distribution and use, see copyright notice in jsimdext.inc
+ ;
+ ; This file should be assembled with NASM (Netwide Assembler),
+ ; can *not* be assembled with Microsoft's MASM or any compatible
+ ; assembler (including Borland's Turbo Assembler).
+ ; NASM is available from http://nasm.sourceforge.net/ or
+ ; http://sourceforge.net/project/showfiles.php?group_id=6208
+ ;
+ ; This file contains a floating-point implementation of the forward DCT
+ ; (Discrete Cosine Transform). The following code is based directly on
+ ; the IJG's original jfdctflt.c; see the jfdctflt.c for more details.
+ ;
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-%ifdef DCT_FLOAT_SUPPORTED
-%ifdef JFDCT_FLT_3DNOW_MMX_SUPPORTED
-
-; This module is specialized to the case DCTSIZE = 8.
-;
-%if DCTSIZE != 8
-%error "Sorry, this code only copes with 8x8 DCTs."
-%endif
+ ; [TAB8]
+
-; jpeg_fdct_float_3dnow (FAST_FLOAT * data)
++%include "simd/jsimdext.inc"
++%include "simd/jdct.inc"
+
+ ; --------------------------------------------------------------------------
+ SECTION SEG_CONST
+
+ alignz 16
+ global EXTN(jconst_fdct_float_3dnow)
+
+ EXTN(jconst_fdct_float_3dnow):
+
+ PD_0_382 times 2 dd 0.382683432365089771728460
+ PD_0_707 times 2 dd 0.707106781186547524400844
+ PD_0_541 times 2 dd 0.541196100146196984399723
+ PD_1_306 times 2 dd 1.306562964876376527856643
+
+ alignz 16
+
+ ; --------------------------------------------------------------------------
+ SECTION SEG_TEXT
+ BITS 32
+ ;
+ ; Perform the forward DCT on one block of samples.
+ ;
+ ; GLOBAL(void)
- global EXTN(jpeg_fdct_float_3dnow)
++; jsimd_fdct_float_3dnow (FAST_FLOAT * data)
+ ;
+
+ %define data(b) (b)+8 ; FAST_FLOAT * data
+
+ %define original_ebp ebp+0
+ %define wk(i) ebp-(WK_NUM-(i))*SIZEOF_MMWORD ; mmword wk[WK_NUM]
+ %define WK_NUM 2
+
+ align 16
-EXTN(jpeg_fdct_float_3dnow):
++ global EXTN(jsimd_fdct_float_3dnow)
+
-%endif ; JFDCT_FLT_3DNOW_MMX_SUPPORTED
-%endif ; DCT_FLOAT_SUPPORTED
++EXTN(jsimd_fdct_float_3dnow):
+ push ebp
+ mov eax,esp ; eax = original ebp
+ sub esp, byte 4
+ and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits
+ mov [esp],eax
+ mov ebp,esp ; ebp = aligned ebp
+ lea esp, [wk(0)]
+ pushpic ebx
+ ; push ecx ; need not be preserved
+ ; push edx ; need not be preserved
+ ; push esi ; unused
+ ; push edi ; unused
+
+ get_GOT ebx ; get GOT address
+
+ ; ---- Pass 1: process rows.
+
+ mov edx, POINTER [data(eax)] ; (FAST_FLOAT *)
+ mov ecx, DCTSIZE/2
+ alignx 16,7
+ .rowloop:
+
+ movq mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)]
+ movq mm1, MMWORD [MMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)]
+ movq mm2, MMWORD [MMBLOCK(0,3,edx,SIZEOF_FAST_FLOAT)]
+ movq mm3, MMWORD [MMBLOCK(1,3,edx,SIZEOF_FAST_FLOAT)]
+
+ ; mm0=(00 01), mm1=(10 11), mm2=(06 07), mm3=(16 17)
+
+ movq mm4,mm0 ; transpose coefficients
+ punpckldq mm0,mm1 ; mm0=(00 10)=data0
+ punpckhdq mm4,mm1 ; mm4=(01 11)=data1
+ movq mm5,mm2 ; transpose coefficients
+ punpckldq mm2,mm3 ; mm2=(06 16)=data6
+ punpckhdq mm5,mm3 ; mm5=(07 17)=data7
+
+ movq mm6,mm4
+ movq mm7,mm0
+ pfsub mm4,mm2 ; mm4=data1-data6=tmp6
+ pfsub mm0,mm5 ; mm0=data0-data7=tmp7
+ pfadd mm6,mm2 ; mm6=data1+data6=tmp1
+ pfadd mm7,mm5 ; mm7=data0+data7=tmp0
+
+ movq mm1, MMWORD [MMBLOCK(0,1,edx,SIZEOF_FAST_FLOAT)]
+ movq mm3, MMWORD [MMBLOCK(1,1,edx,SIZEOF_FAST_FLOAT)]
+ movq mm2, MMWORD [MMBLOCK(0,2,edx,SIZEOF_FAST_FLOAT)]
+ movq mm5, MMWORD [MMBLOCK(1,2,edx,SIZEOF_FAST_FLOAT)]
+
+ ; mm1=(02 03), mm3=(12 13), mm2=(04 05), mm5=(14 15)
+
+ movq MMWORD [wk(0)], mm4 ; wk(0)=tmp6
+ movq MMWORD [wk(1)], mm0 ; wk(1)=tmp7
+
+ movq mm4,mm1 ; transpose coefficients
+ punpckldq mm1,mm3 ; mm1=(02 12)=data2
+ punpckhdq mm4,mm3 ; mm4=(03 13)=data3
+ movq mm0,mm2 ; transpose coefficients
+ punpckldq mm2,mm5 ; mm2=(04 14)=data4
+ punpckhdq mm0,mm5 ; mm0=(05 15)=data5
+
+ movq mm3,mm4
+ movq mm5,mm1
+ pfadd mm4,mm2 ; mm4=data3+data4=tmp3
+ pfadd mm1,mm0 ; mm1=data2+data5=tmp2
+ pfsub mm3,mm2 ; mm3=data3-data4=tmp4
+ pfsub mm5,mm0 ; mm5=data2-data5=tmp5
+
+ ; -- Even part
+
+ movq mm2,mm7
+ movq mm0,mm6
+ pfsub mm7,mm4 ; mm7=tmp13
+ pfsub mm6,mm1 ; mm6=tmp12
+ pfadd mm2,mm4 ; mm2=tmp10
+ pfadd mm0,mm1 ; mm0=tmp11
+
+ pfadd mm6,mm7
+ pfmul mm6,[GOTOFF(ebx,PD_0_707)] ; mm6=z1
+
+ movq mm4,mm2
+ movq mm1,mm7
+ pfsub mm2,mm0 ; mm2=data4
+ pfsub mm7,mm6 ; mm7=data6
+ pfadd mm4,mm0 ; mm4=data0
+ pfadd mm1,mm6 ; mm1=data2
+
+ movq MMWORD [MMBLOCK(0,2,edx,SIZEOF_FAST_FLOAT)], mm2
+ movq MMWORD [MMBLOCK(0,3,edx,SIZEOF_FAST_FLOAT)], mm7
+ movq MMWORD [MMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)], mm4
+ movq MMWORD [MMBLOCK(0,1,edx,SIZEOF_FAST_FLOAT)], mm1
+
+ ; -- Odd part
+
+ movq mm0, MMWORD [wk(0)] ; mm0=tmp6
+ movq mm6, MMWORD [wk(1)] ; mm6=tmp7
+
+ pfadd mm3,mm5 ; mm3=tmp10
+ pfadd mm5,mm0 ; mm5=tmp11
+ pfadd mm0,mm6 ; mm0=tmp12, mm6=tmp7
+
+ pfmul mm5,[GOTOFF(ebx,PD_0_707)] ; mm5=z3
+
+ movq mm2,mm3 ; mm2=tmp10
+ pfsub mm3,mm0
+ pfmul mm3,[GOTOFF(ebx,PD_0_382)] ; mm3=z5
+ pfmul mm2,[GOTOFF(ebx,PD_0_541)] ; mm2=MULTIPLY(tmp10,FIX_0_54119610)
+ pfmul mm0,[GOTOFF(ebx,PD_1_306)] ; mm0=MULTIPLY(tmp12,FIX_1_30656296)
+ pfadd mm2,mm3 ; mm2=z2
+ pfadd mm0,mm3 ; mm0=z4
+
+ movq mm7,mm6
+ pfsub mm6,mm5 ; mm6=z13
+ pfadd mm7,mm5 ; mm7=z11
+
+ movq mm4,mm6
+ movq mm1,mm7
+ pfsub mm6,mm2 ; mm6=data3
+ pfsub mm7,mm0 ; mm7=data7
+ pfadd mm4,mm2 ; mm4=data5
+ pfadd mm1,mm0 ; mm1=data1
+
+ movq MMWORD [MMBLOCK(1,1,edx,SIZEOF_FAST_FLOAT)], mm6
+ movq MMWORD [MMBLOCK(1,3,edx,SIZEOF_FAST_FLOAT)], mm7
+ movq MMWORD [MMBLOCK(1,2,edx,SIZEOF_FAST_FLOAT)], mm4
+ movq MMWORD [MMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)], mm1
+
+ add edx, byte 2*DCTSIZE*SIZEOF_FAST_FLOAT
+ dec ecx
+ jnz near .rowloop
+
+ ; ---- Pass 2: process columns.
+
+ mov edx, POINTER [data(eax)] ; (FAST_FLOAT *)
+ mov ecx, DCTSIZE/2
+ alignx 16,7
+ .columnloop:
+
+ movq mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)]
+ movq mm1, MMWORD [MMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)]
+ movq mm2, MMWORD [MMBLOCK(6,0,edx,SIZEOF_FAST_FLOAT)]
+ movq mm3, MMWORD [MMBLOCK(7,0,edx,SIZEOF_FAST_FLOAT)]
+
+ ; mm0=(00 10), mm1=(01 11), mm2=(60 70), mm3=(61 71)
+
+ movq mm4,mm0 ; transpose coefficients
+ punpckldq mm0,mm1 ; mm0=(00 01)=data0
+ punpckhdq mm4,mm1 ; mm4=(10 11)=data1
+ movq mm5,mm2 ; transpose coefficients
+ punpckldq mm2,mm3 ; mm2=(60 61)=data6
+ punpckhdq mm5,mm3 ; mm5=(70 71)=data7
+
+ movq mm6,mm4
+ movq mm7,mm0
+ pfsub mm4,mm2 ; mm4=data1-data6=tmp6
+ pfsub mm0,mm5 ; mm0=data0-data7=tmp7
+ pfadd mm6,mm2 ; mm6=data1+data6=tmp1
+ pfadd mm7,mm5 ; mm7=data0+data7=tmp0
+
+ movq mm1, MMWORD [MMBLOCK(2,0,edx,SIZEOF_FAST_FLOAT)]
+ movq mm3, MMWORD [MMBLOCK(3,0,edx,SIZEOF_FAST_FLOAT)]
+ movq mm2, MMWORD [MMBLOCK(4,0,edx,SIZEOF_FAST_FLOAT)]
+ movq mm5, MMWORD [MMBLOCK(5,0,edx,SIZEOF_FAST_FLOAT)]
+
+ ; mm1=(20 30), mm3=(21 31), mm2=(40 50), mm5=(41 51)
+
+ movq MMWORD [wk(0)], mm4 ; wk(0)=tmp6
+ movq MMWORD [wk(1)], mm0 ; wk(1)=tmp7
+
+ movq mm4,mm1 ; transpose coefficients
+ punpckldq mm1,mm3 ; mm1=(20 21)=data2
+ punpckhdq mm4,mm3 ; mm4=(30 31)=data3
+ movq mm0,mm2 ; transpose coefficients
+ punpckldq mm2,mm5 ; mm2=(40 41)=data4
+ punpckhdq mm0,mm5 ; mm0=(50 51)=data5
+
+ movq mm3,mm4
+ movq mm5,mm1
+ pfadd mm4,mm2 ; mm4=data3+data4=tmp3
+ pfadd mm1,mm0 ; mm1=data2+data5=tmp2
+ pfsub mm3,mm2 ; mm3=data3-data4=tmp4
+ pfsub mm5,mm0 ; mm5=data2-data5=tmp5
+
+ ; -- Even part
+
+ movq mm2,mm7
+ movq mm0,mm6
+ pfsub mm7,mm4 ; mm7=tmp13
+ pfsub mm6,mm1 ; mm6=tmp12
+ pfadd mm2,mm4 ; mm2=tmp10
+ pfadd mm0,mm1 ; mm0=tmp11
+
+ pfadd mm6,mm7
+ pfmul mm6,[GOTOFF(ebx,PD_0_707)] ; mm6=z1
+
+ movq mm4,mm2
+ movq mm1,mm7
+ pfsub mm2,mm0 ; mm2=data4
+ pfsub mm7,mm6 ; mm7=data6
+ pfadd mm4,mm0 ; mm4=data0
+ pfadd mm1,mm6 ; mm1=data2
+
+ movq MMWORD [MMBLOCK(4,0,edx,SIZEOF_FAST_FLOAT)], mm2
+ movq MMWORD [MMBLOCK(6,0,edx,SIZEOF_FAST_FLOAT)], mm7
+ movq MMWORD [MMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)], mm4
+ movq MMWORD [MMBLOCK(2,0,edx,SIZEOF_FAST_FLOAT)], mm1
+
+ ; -- Odd part
+
+ movq mm0, MMWORD [wk(0)] ; mm0=tmp6
+ movq mm6, MMWORD [wk(1)] ; mm6=tmp7
+
+ pfadd mm3,mm5 ; mm3=tmp10
+ pfadd mm5,mm0 ; mm5=tmp11
+ pfadd mm0,mm6 ; mm0=tmp12, mm6=tmp7
+
+ pfmul mm5,[GOTOFF(ebx,PD_0_707)] ; mm5=z3
+
+ movq mm2,mm3 ; mm2=tmp10
+ pfsub mm3,mm0
+ pfmul mm3,[GOTOFF(ebx,PD_0_382)] ; mm3=z5
+ pfmul mm2,[GOTOFF(ebx,PD_0_541)] ; mm2=MULTIPLY(tmp10,FIX_0_54119610)
+ pfmul mm0,[GOTOFF(ebx,PD_1_306)] ; mm0=MULTIPLY(tmp12,FIX_1_30656296)
+ pfadd mm2,mm3 ; mm2=z2
+ pfadd mm0,mm3 ; mm0=z4
+
+ movq mm7,mm6
+ pfsub mm6,mm5 ; mm6=z13
+ pfadd mm7,mm5 ; mm7=z11
+
+ movq mm4,mm6
+ movq mm1,mm7
+ pfsub mm6,mm2 ; mm6=data3
+ pfsub mm7,mm0 ; mm7=data7
+ pfadd mm4,mm2 ; mm4=data5
+ pfadd mm1,mm0 ; mm1=data1
+
+ movq MMWORD [MMBLOCK(3,0,edx,SIZEOF_FAST_FLOAT)], mm6
+ movq MMWORD [MMBLOCK(7,0,edx,SIZEOF_FAST_FLOAT)], mm7
+ movq MMWORD [MMBLOCK(5,0,edx,SIZEOF_FAST_FLOAT)], mm4
+ movq MMWORD [MMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)], mm1
+
+ add edx, byte 2*SIZEOF_FAST_FLOAT
+ dec ecx
+ jnz near .columnloop
+
+ femms ; empty MMX/3DNow! state
+
+ ; pop edi ; unused
+ ; pop esi ; unused
+ ; pop edx ; need not be preserved
+ ; pop ecx ; need not be preserved
+ poppic ebx
+ mov esp,ebp ; esp <- aligned ebp
+ pop esp ; esp <- original ebp
+ pop ebp
+ ret
+
--- /dev/null
-; Last Modified : February 4, 2006
-;
+ ;
+ ; ji3dnflt.asm - floating-point IDCT (3DNow! & MMX)
+ ;
++; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
++;
++; Based on
+ ; x86 SIMD extension for IJG JPEG library
+ ; Copyright (C) 1999-2006, MIYASAKA Masaru.
+ ; For conditions of distribution and use, see copyright notice in jsimdext.inc
+ ;
+ ; This file should be assembled with NASM (Netwide Assembler),
+ ; can *not* be assembled with Microsoft's MASM or any compatible
+ ; assembler (including Borland's Turbo Assembler).
+ ; NASM is available from http://nasm.sourceforge.net/ or
+ ; http://sourceforge.net/project/showfiles.php?group_id=6208
+ ;
+ ; This file contains a floating-point implementation of the inverse DCT
+ ; (Discrete Cosine Transform). The following code is based directly on
+ ; the IJG's original jidctflt.c; see the jidctflt.c for more details.
+ ;
-%include "jsimdext.inc"
-%include "jdct.inc"
-
-%ifdef DCT_FLOAT_SUPPORTED
-%ifdef JIDCT_FLT_3DNOW_MMX_SUPPORTED
-
-; This module is specialized to the case DCTSIZE = 8.
-;
-%if DCTSIZE != 8
-%error "Sorry, this code only copes with 8x8 DCTs."
-%endif
+ ; [TAB8]
+
-; jpeg_idct_float_3dnow (j_decompress_ptr cinfo, jpeg_component_info * compptr,
-; JCOEFPTR coef_block,
-; JSAMPARRAY output_buf, JDIMENSION output_col)
++%include "simd/jsimdext.inc"
++%include "simd/jdct.inc"
+
+ ; --------------------------------------------------------------------------
+ SECTION SEG_CONST
+
+ alignz 16
+ global EXTN(jconst_idct_float_3dnow)
+
+ EXTN(jconst_idct_float_3dnow):
+
+ PD_1_414 times 2 dd 1.414213562373095048801689
+ PD_1_847 times 2 dd 1.847759065022573512256366
+ PD_1_082 times 2 dd 1.082392200292393968799446
+ PD_2_613 times 2 dd 2.613125929752753055713286
+ PD_RNDINT_MAGIC times 2 dd 100663296.0 ; (float)(0x00C00000 << 3)
+ PB_CENTERJSAMP times 8 db CENTERJSAMPLE
+
+ alignz 16
+
+ ; --------------------------------------------------------------------------
+ SECTION SEG_TEXT
+ BITS 32
+ ;
+ ; Perform dequantization and inverse DCT on one block of coefficients.
+ ;
+ ; GLOBAL(void)
-%define cinfo(b) (b)+8 ; j_decompress_ptr cinfo
-%define compptr(b) (b)+12 ; jpeg_component_info * compptr
-%define coef_block(b) (b)+16 ; JCOEFPTR coef_block
-%define output_buf(b) (b)+20 ; JSAMPARRAY output_buf
-%define output_col(b) (b)+24 ; JDIMENSION output_col
++; jsimd_idct_float_3dnow (void * dct_table, JCOEFPTR coef_block,
++; JSAMPARRAY output_buf, JDIMENSION output_col)
+ ;
+
- global EXTN(jpeg_idct_float_3dnow)
++%define dct_table(b) (b)+8 ; void * dct_table
++%define coef_block(b) (b)+12 ; JCOEFPTR coef_block
++%define output_buf(b) (b)+16 ; JSAMPARRAY output_buf
++%define output_col(b) (b)+20 ; JDIMENSION output_col
+
+ %define original_ebp ebp+0
+ %define wk(i) ebp-(WK_NUM-(i))*SIZEOF_MMWORD ; mmword wk[WK_NUM]
+ %define WK_NUM 2
+ %define workspace wk(0)-DCTSIZE2*SIZEOF_FAST_FLOAT
+ ; FAST_FLOAT workspace[DCTSIZE2]
+
+ align 16
-EXTN(jpeg_idct_float_3dnow):
++ global EXTN(jsimd_idct_float_3dnow)
+
- mov edx, POINTER [compptr(eax)]
- mov edx, POINTER [jcompinfo_dct_table(edx)] ; quantptr
++EXTN(jsimd_idct_float_3dnow):
+ push ebp
+ mov eax,esp ; eax = original ebp
+ sub esp, byte 4
+ and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits
+ mov [esp],eax
+ mov ebp,esp ; ebp = aligned ebp
+ lea esp, [workspace]
+ push ebx
+ ; push ecx ; need not be preserved
+ ; push edx ; need not be preserved
+ push esi
+ push edi
+
+ get_GOT ebx ; get GOT address
+
+ ; ---- Pass 1: process columns from input, store into work array.
+
+ ; mov eax, [original_ebp]
-%endif ; JIDCT_FLT_3DNOW_MMX_SUPPORTED
-%endif ; DCT_FLOAT_SUPPORTED
++ mov edx, POINTER [dct_table(eax)] ; quantptr
+ mov esi, JCOEFPTR [coef_block(eax)] ; inptr
+ lea edi, [workspace] ; FAST_FLOAT * wsptr
+ mov ecx, DCTSIZE/2 ; ctr
+ alignx 16,7
+ .columnloop:
+ %ifndef NO_ZERO_COLUMN_TEST_FLOAT_3DNOW
+ mov eax, DWORD [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
+ or eax, DWORD [DWBLOCK(2,0,esi,SIZEOF_JCOEF)]
+ jnz short .columnDCT
+
+ pushpic ebx ; save GOT address
+ mov ebx, DWORD [DWBLOCK(3,0,esi,SIZEOF_JCOEF)]
+ mov eax, DWORD [DWBLOCK(4,0,esi,SIZEOF_JCOEF)]
+ or ebx, DWORD [DWBLOCK(5,0,esi,SIZEOF_JCOEF)]
+ or eax, DWORD [DWBLOCK(6,0,esi,SIZEOF_JCOEF)]
+ or ebx, DWORD [DWBLOCK(7,0,esi,SIZEOF_JCOEF)]
+ or eax,ebx
+ poppic ebx ; restore GOT address
+ jnz short .columnDCT
+
+ ; -- AC terms all zero
+
+ movd mm0, DWORD [DWBLOCK(0,0,esi,SIZEOF_JCOEF)]
+
+ punpcklwd mm0,mm0
+ psrad mm0,(DWORD_BIT-WORD_BIT)
+ pi2fd mm0,mm0
+
+ pfmul mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
+
+ movq mm1,mm0
+ punpckldq mm0,mm0
+ punpckhdq mm1,mm1
+
+ movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], mm0
+ movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], mm0
+ movq MMWORD [MMBLOCK(0,2,edi,SIZEOF_FAST_FLOAT)], mm0
+ movq MMWORD [MMBLOCK(0,3,edi,SIZEOF_FAST_FLOAT)], mm0
+ movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], mm1
+ movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], mm1
+ movq MMWORD [MMBLOCK(1,2,edi,SIZEOF_FAST_FLOAT)], mm1
+ movq MMWORD [MMBLOCK(1,3,edi,SIZEOF_FAST_FLOAT)], mm1
+ jmp near .nextcolumn
+ alignx 16,7
+ %endif
+ .columnDCT:
+
+ ; -- Even part
+
+ movd mm0, DWORD [DWBLOCK(0,0,esi,SIZEOF_JCOEF)]
+ movd mm1, DWORD [DWBLOCK(2,0,esi,SIZEOF_JCOEF)]
+ movd mm2, DWORD [DWBLOCK(4,0,esi,SIZEOF_JCOEF)]
+ movd mm3, DWORD [DWBLOCK(6,0,esi,SIZEOF_JCOEF)]
+
+ punpcklwd mm0,mm0
+ punpcklwd mm1,mm1
+ psrad mm0,(DWORD_BIT-WORD_BIT)
+ psrad mm1,(DWORD_BIT-WORD_BIT)
+ pi2fd mm0,mm0
+ pi2fd mm1,mm1
+
+ pfmul mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
+ pfmul mm1, MMWORD [MMBLOCK(2,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
+
+ punpcklwd mm2,mm2
+ punpcklwd mm3,mm3
+ psrad mm2,(DWORD_BIT-WORD_BIT)
+ psrad mm3,(DWORD_BIT-WORD_BIT)
+ pi2fd mm2,mm2
+ pi2fd mm3,mm3
+
+ pfmul mm2, MMWORD [MMBLOCK(4,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
+ pfmul mm3, MMWORD [MMBLOCK(6,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
+
+ movq mm4,mm0
+ movq mm5,mm1
+ pfsub mm0,mm2 ; mm0=tmp11
+ pfsub mm1,mm3
+ pfadd mm4,mm2 ; mm4=tmp10
+ pfadd mm5,mm3 ; mm5=tmp13
+
+ pfmul mm1,[GOTOFF(ebx,PD_1_414)]
+ pfsub mm1,mm5 ; mm1=tmp12
+
+ movq mm6,mm4
+ movq mm7,mm0
+ pfsub mm4,mm5 ; mm4=tmp3
+ pfsub mm0,mm1 ; mm0=tmp2
+ pfadd mm6,mm5 ; mm6=tmp0
+ pfadd mm7,mm1 ; mm7=tmp1
+
+ movq MMWORD [wk(1)], mm4 ; tmp3
+ movq MMWORD [wk(0)], mm0 ; tmp2
+
+ ; -- Odd part
+
+ movd mm2, DWORD [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
+ movd mm3, DWORD [DWBLOCK(3,0,esi,SIZEOF_JCOEF)]
+ movd mm5, DWORD [DWBLOCK(5,0,esi,SIZEOF_JCOEF)]
+ movd mm1, DWORD [DWBLOCK(7,0,esi,SIZEOF_JCOEF)]
+
+ punpcklwd mm2,mm2
+ punpcklwd mm3,mm3
+ psrad mm2,(DWORD_BIT-WORD_BIT)
+ psrad mm3,(DWORD_BIT-WORD_BIT)
+ pi2fd mm2,mm2
+ pi2fd mm3,mm3
+
+ pfmul mm2, MMWORD [MMBLOCK(1,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
+ pfmul mm3, MMWORD [MMBLOCK(3,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
+
+ punpcklwd mm5,mm5
+ punpcklwd mm1,mm1
+ psrad mm5,(DWORD_BIT-WORD_BIT)
+ psrad mm1,(DWORD_BIT-WORD_BIT)
+ pi2fd mm5,mm5
+ pi2fd mm1,mm1
+
+ pfmul mm5, MMWORD [MMBLOCK(5,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
+ pfmul mm1, MMWORD [MMBLOCK(7,0,edx,SIZEOF_FLOAT_MULT_TYPE)]
+
+ movq mm4,mm2
+ movq mm0,mm5
+ pfadd mm2,mm1 ; mm2=z11
+ pfadd mm5,mm3 ; mm5=z13
+ pfsub mm4,mm1 ; mm4=z12
+ pfsub mm0,mm3 ; mm0=z10
+
+ movq mm1,mm2
+ pfsub mm2,mm5
+ pfadd mm1,mm5 ; mm1=tmp7
+
+ pfmul mm2,[GOTOFF(ebx,PD_1_414)] ; mm2=tmp11
+
+ movq mm3,mm0
+ pfadd mm0,mm4
+ pfmul mm0,[GOTOFF(ebx,PD_1_847)] ; mm0=z5
+ pfmul mm3,[GOTOFF(ebx,PD_2_613)] ; mm3=(z10 * 2.613125930)
+ pfmul mm4,[GOTOFF(ebx,PD_1_082)] ; mm4=(z12 * 1.082392200)
+ pfsubr mm3,mm0 ; mm3=tmp12
+ pfsub mm4,mm0 ; mm4=tmp10
+
+ ; -- Final output stage
+
+ pfsub mm3,mm1 ; mm3=tmp6
+ movq mm5,mm6
+ movq mm0,mm7
+ pfadd mm6,mm1 ; mm6=data0=(00 01)
+ pfadd mm7,mm3 ; mm7=data1=(10 11)
+ pfsub mm5,mm1 ; mm5=data7=(70 71)
+ pfsub mm0,mm3 ; mm0=data6=(60 61)
+ pfsub mm2,mm3 ; mm2=tmp5
+
+ movq mm1,mm6 ; transpose coefficients
+ punpckldq mm6,mm7 ; mm6=(00 10)
+ punpckhdq mm1,mm7 ; mm1=(01 11)
+ movq mm3,mm0 ; transpose coefficients
+ punpckldq mm0,mm5 ; mm0=(60 70)
+ punpckhdq mm3,mm5 ; mm3=(61 71)
+
+ movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], mm6
+ movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], mm1
+ movq MMWORD [MMBLOCK(0,3,edi,SIZEOF_FAST_FLOAT)], mm0
+ movq MMWORD [MMBLOCK(1,3,edi,SIZEOF_FAST_FLOAT)], mm3
+
+ movq mm7, MMWORD [wk(0)] ; mm7=tmp2
+ movq mm5, MMWORD [wk(1)] ; mm5=tmp3
+
+ pfadd mm4,mm2 ; mm4=tmp4
+ movq mm6,mm7
+ movq mm1,mm5
+ pfadd mm7,mm2 ; mm7=data2=(20 21)
+ pfadd mm5,mm4 ; mm5=data4=(40 41)
+ pfsub mm6,mm2 ; mm6=data5=(50 51)
+ pfsub mm1,mm4 ; mm1=data3=(30 31)
+
+ movq mm0,mm7 ; transpose coefficients
+ punpckldq mm7,mm1 ; mm7=(20 30)
+ punpckhdq mm0,mm1 ; mm0=(21 31)
+ movq mm3,mm5 ; transpose coefficients
+ punpckldq mm5,mm6 ; mm5=(40 50)
+ punpckhdq mm3,mm6 ; mm3=(41 51)
+
+ movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], mm7
+ movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], mm0
+ movq MMWORD [MMBLOCK(0,2,edi,SIZEOF_FAST_FLOAT)], mm5
+ movq MMWORD [MMBLOCK(1,2,edi,SIZEOF_FAST_FLOAT)], mm3
+
+ .nextcolumn:
+ add esi, byte 2*SIZEOF_JCOEF ; coef_block
+ add edx, byte 2*SIZEOF_FLOAT_MULT_TYPE ; quantptr
+ add edi, byte 2*DCTSIZE*SIZEOF_FAST_FLOAT ; wsptr
+ dec ecx ; ctr
+ jnz near .columnloop
+
+ ; -- Prefetch the next coefficient block
+
+ prefetch [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 0*32]
+ prefetch [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 1*32]
+ prefetch [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 2*32]
+ prefetch [esi + (DCTSIZE2-8)*SIZEOF_JCOEF + 3*32]
+
+ ; ---- Pass 2: process rows from work array, store into output array.
+
+ mov eax, [original_ebp]
+ lea esi, [workspace] ; FAST_FLOAT * wsptr
+ mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
+ mov eax, JDIMENSION [output_col(eax)]
+ mov ecx, DCTSIZE/2 ; ctr
+ alignx 16,7
+ .rowloop:
+
+ ; -- Even part
+
+ movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)]
+ movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_FAST_FLOAT)]
+ movq mm2, MMWORD [MMBLOCK(4,0,esi,SIZEOF_FAST_FLOAT)]
+ movq mm3, MMWORD [MMBLOCK(6,0,esi,SIZEOF_FAST_FLOAT)]
+
+ movq mm4,mm0
+ movq mm5,mm1
+ pfsub mm0,mm2 ; mm0=tmp11
+ pfsub mm1,mm3
+ pfadd mm4,mm2 ; mm4=tmp10
+ pfadd mm5,mm3 ; mm5=tmp13
+
+ pfmul mm1,[GOTOFF(ebx,PD_1_414)]
+ pfsub mm1,mm5 ; mm1=tmp12
+
+ movq mm6,mm4
+ movq mm7,mm0
+ pfsub mm4,mm5 ; mm4=tmp3
+ pfsub mm0,mm1 ; mm0=tmp2
+ pfadd mm6,mm5 ; mm6=tmp0
+ pfadd mm7,mm1 ; mm7=tmp1
+
+ movq MMWORD [wk(1)], mm4 ; tmp3
+ movq MMWORD [wk(0)], mm0 ; tmp2
+
+ ; -- Odd part
+
+ movq mm2, MMWORD [MMBLOCK(1,0,esi,SIZEOF_FAST_FLOAT)]
+ movq mm3, MMWORD [MMBLOCK(3,0,esi,SIZEOF_FAST_FLOAT)]
+ movq mm5, MMWORD [MMBLOCK(5,0,esi,SIZEOF_FAST_FLOAT)]
+ movq mm1, MMWORD [MMBLOCK(7,0,esi,SIZEOF_FAST_FLOAT)]
+
+ movq mm4,mm2
+ movq mm0,mm5
+ pfadd mm2,mm1 ; mm2=z11
+ pfadd mm5,mm3 ; mm5=z13
+ pfsub mm4,mm1 ; mm4=z12
+ pfsub mm0,mm3 ; mm0=z10
+
+ movq mm1,mm2
+ pfsub mm2,mm5
+ pfadd mm1,mm5 ; mm1=tmp7
+
+ pfmul mm2,[GOTOFF(ebx,PD_1_414)] ; mm2=tmp11
+
+ movq mm3,mm0
+ pfadd mm0,mm4
+ pfmul mm0,[GOTOFF(ebx,PD_1_847)] ; mm0=z5
+ pfmul mm3,[GOTOFF(ebx,PD_2_613)] ; mm3=(z10 * 2.613125930)
+ pfmul mm4,[GOTOFF(ebx,PD_1_082)] ; mm4=(z12 * 1.082392200)
+ pfsubr mm3,mm0 ; mm3=tmp12
+ pfsub mm4,mm0 ; mm4=tmp10
+
+ ; -- Final output stage
+
+ pfsub mm3,mm1 ; mm3=tmp6
+ movq mm5,mm6
+ movq mm0,mm7
+ pfadd mm6,mm1 ; mm6=data0=(00 10)
+ pfadd mm7,mm3 ; mm7=data1=(01 11)
+ pfsub mm5,mm1 ; mm5=data7=(07 17)
+ pfsub mm0,mm3 ; mm0=data6=(06 16)
+ pfsub mm2,mm3 ; mm2=tmp5
+
+ movq mm1,[GOTOFF(ebx,PD_RNDINT_MAGIC)] ; mm1=[PD_RNDINT_MAGIC]
+ pcmpeqd mm3,mm3
+ psrld mm3,WORD_BIT ; mm3={0xFFFF 0x0000 0xFFFF 0x0000}
+
+ pfadd mm6,mm1 ; mm6=roundint(data0/8)=(00 ** 10 **)
+ pfadd mm7,mm1 ; mm7=roundint(data1/8)=(01 ** 11 **)
+ pfadd mm0,mm1 ; mm0=roundint(data6/8)=(06 ** 16 **)
+ pfadd mm5,mm1 ; mm5=roundint(data7/8)=(07 ** 17 **)
+
+ pand mm6,mm3 ; mm6=(00 -- 10 --)
+ pslld mm7,WORD_BIT ; mm7=(-- 01 -- 11)
+ pand mm0,mm3 ; mm0=(06 -- 16 --)
+ pslld mm5,WORD_BIT ; mm5=(-- 07 -- 17)
+ por mm6,mm7 ; mm6=(00 01 10 11)
+ por mm0,mm5 ; mm0=(06 07 16 17)
+
+ movq mm1, MMWORD [wk(0)] ; mm1=tmp2
+ movq mm3, MMWORD [wk(1)] ; mm3=tmp3
+
+ pfadd mm4,mm2 ; mm4=tmp4
+ movq mm7,mm1
+ movq mm5,mm3
+ pfadd mm1,mm2 ; mm1=data2=(02 12)
+ pfadd mm3,mm4 ; mm3=data4=(04 14)
+ pfsub mm7,mm2 ; mm7=data5=(05 15)
+ pfsub mm5,mm4 ; mm5=data3=(03 13)
+
+ movq mm2,[GOTOFF(ebx,PD_RNDINT_MAGIC)] ; mm2=[PD_RNDINT_MAGIC]
+ pcmpeqd mm4,mm4
+ psrld mm4,WORD_BIT ; mm4={0xFFFF 0x0000 0xFFFF 0x0000}
+
+ pfadd mm3,mm2 ; mm3=roundint(data4/8)=(04 ** 14 **)
+ pfadd mm7,mm2 ; mm7=roundint(data5/8)=(05 ** 15 **)
+ pfadd mm1,mm2 ; mm1=roundint(data2/8)=(02 ** 12 **)
+ pfadd mm5,mm2 ; mm5=roundint(data3/8)=(03 ** 13 **)
+
+ pand mm3,mm4 ; mm3=(04 -- 14 --)
+ pslld mm7,WORD_BIT ; mm7=(-- 05 -- 15)
+ pand mm1,mm4 ; mm1=(02 -- 12 --)
+ pslld mm5,WORD_BIT ; mm5=(-- 03 -- 13)
+ por mm3,mm7 ; mm3=(04 05 14 15)
+ por mm1,mm5 ; mm1=(02 03 12 13)
+
+ movq mm2,[GOTOFF(ebx,PB_CENTERJSAMP)] ; mm2=[PB_CENTERJSAMP]
+
+ packsswb mm6,mm3 ; mm6=(00 01 10 11 04 05 14 15)
+ packsswb mm1,mm0 ; mm1=(02 03 12 13 06 07 16 17)
+ paddb mm6,mm2
+ paddb mm1,mm2
+
+ movq mm4,mm6 ; transpose coefficients(phase 2)
+ punpcklwd mm6,mm1 ; mm6=(00 01 02 03 10 11 12 13)
+ punpckhwd mm4,mm1 ; mm4=(04 05 06 07 14 15 16 17)
+
+ movq mm7,mm6 ; transpose coefficients(phase 3)
+ punpckldq mm6,mm4 ; mm6=(00 01 02 03 04 05 06 07)
+ punpckhdq mm7,mm4 ; mm7=(10 11 12 13 14 15 16 17)
+
+ pushpic ebx ; save GOT address
+
+ mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
+ mov ebx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
+ movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm6
+ movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm7
+
+ poppic ebx ; restore GOT address
+
+ add esi, byte 2*SIZEOF_FAST_FLOAT ; wsptr
+ add edi, byte 2*SIZEOF_JSAMPROW
+ dec ecx ; ctr
+ jnz near .rowloop
+
+ femms ; empty MMX/3DNow! state
+
+ pop edi
+ pop esi
+ ; pop edx ; need not be preserved
+ ; pop ecx ; need not be preserved
+ pop ebx
+ mov esp,ebp ; esp <- aligned ebp
+ pop esp ; esp <- original ebp
+ pop ebp
+ ret
+
--- /dev/null
+/*
+ * simd/jsimd.h
+ *
+ * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
+ *
+ * Based on the x86 SIMD extension for IJG JPEG library,
+ * Copyright (C) 1999-2006, MIYASAKA Masaru.
+ *
+ */
+
+/* Bitmask for supported acceleration methods */
+
+#define JSIMD_NONE 0x00
+#define JSIMD_MMX 0x01
++#define JSIMD_3DNOW 0x02
+
+/* Short forms of external names for systems with brain-damaged linkers. */
+
+#ifdef NEED_SHORT_EXTERNAL_NAMES
+#define jpeg_simd_cpu_support jSiCpuSupport
+#define jsimd_rgb_ycc_convert_mmx jSRGBYCCM
+#define jsimd_ycc_rgb_convert_mmx jSYCCRGBM
+#define jsimd_h2v2_downsample_mmx jSDnH2V2M
+#define jsimd_h2v1_downsample_mmx jSDnH2V1M
+#define jsimd_h2v2_upsample_mmx jSUpH2V2M
+#define jsimd_h2v1_upsample_mmx jSUpH2V1M
+#define jsimd_h2v2_fancy_upsample_mmx jSFUpH2V2M
+#define jsimd_h2v1_fancy_upsample_mmx jSFUpH2V1M
+#define jsimd_h2v2_merged_upsample_mmx jSMUpH2V2M
+#define jsimd_h2v1_merged_upsample_mmx jSMUpH2V1M
+#define jsimd_convsamp_mmx jSConvM
++#define jsimd_convsamp_float_3dnow jSConvF3D
+#define jsimd_fdct_islow_mmx jSFDMIS
+#define jsimd_fdct_ifast_mmx jSFDMIF
++#define jsimd_fdct_float_3dnow jSFD3DF
+#define jsimd_quantize_mmx jSQuantM
++#define jsimd_quantize_float_3dnow jSQuantF3D
+#define jsimd_idct_2x2_mmx jSIDM22
+#define jsimd_idct_4x4_mmx jSIDM44
+#define jsimd_idct_islow_mmx jSIDMIS
+#define jsimd_idct_ifast_mmx jSIDMIF
++#define jsimd_idct_float_3dnow jSID3DF
+#endif /* NEED_SHORT_EXTERNAL_NAMES */
+
+/* SIMD Ext: retrieve SIMD/CPU information */
+EXTERN(unsigned int) jpeg_simd_cpu_support JPP((void));
+
+/* SIMD Color Space Conversion */
+EXTERN(void) jsimd_rgb_ycc_convert_mmx
+ JPP((JDIMENSION img_width,
+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
+ JDIMENSION output_row, int num_rows));
+EXTERN(void) jsimd_ycc_rgb_convert_mmx
+ JPP((JDIMENSION out_width,
+ JSAMPIMAGE input_buf, JDIMENSION input_row,
+ JSAMPARRAY output_buf, int num_rows));
+
+/* SIMD Downsample */
+EXTERN(void) jsimd_h2v2_downsample_mmx
+ JPP((JDIMENSION image_width, int max_v_samp_factor,
+ JDIMENSION v_samp_factor, JDIMENSION width_blocks,
+ JSAMPARRAY input_data, JSAMPARRAY output_data));
+EXTERN(void) jsimd_h2v1_downsample_mmx
+ JPP((JDIMENSION image_width, int max_v_samp_factor,
+ JDIMENSION v_samp_factor, JDIMENSION width_blocks,
+ JSAMPARRAY input_data, JSAMPARRAY output_data));
+
+/* SIMD Upsample */
+EXTERN(void) jsimd_h2v2_upsample_mmx
+ JPP((int max_v_samp_factor, JDIMENSION output_width,
+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr));
+EXTERN(void) jsimd_h2v1_upsample_mmx
+ JPP((int max_v_samp_factor, JDIMENSION output_width,
+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr));
+
+EXTERN(void) jsimd_h2v2_fancy_upsample_mmx
+ JPP((int max_v_samp_factor, JDIMENSION downsampled_width,
+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr));
+EXTERN(void) jsimd_h2v1_fancy_upsample_mmx
+ JPP((int max_v_samp_factor, JDIMENSION downsampled_width,
+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr));
+
+EXTERN(void) jsimd_h2v2_merged_upsample_mmx
+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf,
+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf));
+EXTERN(void) jsimd_h2v1_merged_upsample_mmx
+ JPP((JDIMENSION output_width, JSAMPIMAGE input_buf,
+ JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf));
+
+/* SIMD Sample Conversion */
+EXTERN(void) jsimd_convsamp_mmx JPP((JSAMPARRAY sample_data,
+ JDIMENSION start_col,
+ DCTELEM * workspace));
+
++EXTERN(void) jsimd_convsamp_float_3dnow JPP((JSAMPARRAY sample_data,
++ JDIMENSION start_col,
++ FAST_FLOAT * workspace));
++
+/* SIMD Forward DCT */
+EXTERN(void) jsimd_fdct_islow_mmx JPP((DCTELEM * data));
+EXTERN(void) jsimd_fdct_ifast_mmx JPP((DCTELEM * data));
+
++EXTERN(void) jsimd_fdct_float_3dnow JPP((FAST_FLOAT * data));
++
+/* SIMD Quantization */
+EXTERN(void) jsimd_quantize_mmx JPP((JCOEFPTR coef_block,
+ DCTELEM * divisors,
+ DCTELEM * workspace));
+
++EXTERN(void) jsimd_quantize_float_3dnow JPP((JCOEFPTR coef_block,
++ FAST_FLOAT * divisors,
++ FAST_FLOAT * workspace));
++
+/* SIMD Reduced Inverse DCT */
+EXTERN(void) jsimd_idct_2x2_mmx JPP((void * dct_table,
+ JCOEFPTR coef_block,
+ JSAMPARRAY output_buf,
+ JDIMENSION output_col));
+EXTERN(void) jsimd_idct_4x4_mmx JPP((void * dct_table,
+ JCOEFPTR coef_block,
+ JSAMPARRAY output_buf,
+ JDIMENSION output_col));
+
+/* SIMD Inverse DCT */
+EXTERN(void) jsimd_idct_islow_mmx JPP((void * dct_table,
+ JCOEFPTR coef_block,
+ JSAMPARRAY output_buf,
+ JDIMENSION output_col));
+EXTERN(void) jsimd_idct_ifast_mmx JPP((void * dct_table,
+ JCOEFPTR coef_block,
+ JSAMPARRAY output_buf,
+ JDIMENSION output_col));
+
++EXTERN(void) jsimd_idct_float_3dnow JPP((void * dct_table,
++ JCOEFPTR coef_block,
++ JSAMPARRAY output_buf,
++ JDIMENSION output_col));
++
--- /dev/null
+// This file generates the include file for the assembly
+// implementations by abusing the C preprocessor.
+//
+// Note: Some things are manually defined as they need to
+// be mapped to NASM types.
+
+;
+; Automatically generated include file from jsimdcfg.inc.h
+;
+
+#define JPEG_INTERNALS
+
+#include "../jpeglib.h"
+#include "../jconfig.h"
+#include "../jmorecfg.h"
+#include "jsimd.h"
+
+#define define(var) %define _cpp_protection_##var
+#define definev(var) %define _cpp_protection_##var var
+
+;
+; -- jpeglib.h
+;
+
+definev(DCTSIZE)
+definev(DCTSIZE2)
+
+;
+; -- jmorecfg.h
+;
+
+definev(RGB_RED)
+definev(RGB_GREEN)
+definev(RGB_BLUE)
+
+definev(RGB_PIXELSIZE)
+
+; Representation of a single sample (pixel element value).
+; On this SIMD implementation, this must be 'unsigned char'.
+;
+
+%define JSAMPLE byte ; unsigned char
+%define SIZEOF_JSAMPLE SIZEOF_BYTE ; sizeof(JSAMPLE)
+
+definev(CENTERJSAMPLE)
+
+; Representation of a DCT frequency coefficient.
+; On this SIMD implementation, this must be 'short'.
+;
+%define JCOEF word ; short
+%define SIZEOF_JCOEF SIZEOF_WORD ; sizeof(JCOEF)
+
+; Datatype used for image dimensions.
+; On this SIMD implementation, this must be 'unsigned int'.
+;
+%define JDIMENSION dword ; unsigned int
+%define SIZEOF_JDIMENSION SIZEOF_DWORD ; sizeof(JDIMENSION)
+
+%define JSAMPROW POINTER ; JSAMPLE FAR * (jpeglib.h)
+%define JSAMPARRAY POINTER ; JSAMPROW * (jpeglib.h)
+%define JSAMPIMAGE POINTER ; JSAMPARRAY * (jpeglib.h)
+%define JCOEFPTR POINTER ; JCOEF FAR * (jpeglib.h)
+%define SIZEOF_JSAMPROW SIZEOF_POINTER ; sizeof(JSAMPROW)
+%define SIZEOF_JSAMPARRAY SIZEOF_POINTER ; sizeof(JSAMPARRAY)
+%define SIZEOF_JSAMPIMAGE SIZEOF_POINTER ; sizeof(JSAMPIMAGE)
+%define SIZEOF_JCOEFPTR SIZEOF_POINTER ; sizeof(JCOEFPTR)
+
+;
+; -- jdct.h
+;
+
+; A forward DCT routine is given a pointer to a work area of type DCTELEM[];
+; the DCT is to be performed in-place in that buffer.
+; To maximize parallelism, Type DCTELEM is changed to short (originally, int).
+;
+%define DCTELEM word ; short
+%define SIZEOF_DCTELEM SIZEOF_WORD ; sizeof(DCTELEM)
+
++%define FAST_FLOAT FP32 ; float
++%define SIZEOF_FAST_FLOAT SIZEOF_FP32 ; sizeof(FAST_FLOAT)
++
+; To maximize parallelism, Type MULTIPLIER is changed to short.
+;
+%define ISLOW_MULT_TYPE word ; must be short
+%define SIZEOF_ISLOW_MULT_TYPE SIZEOF_WORD ; sizeof(ISLOW_MULT_TYPE)
+
+%define IFAST_MULT_TYPE word ; must be short
+%define SIZEOF_IFAST_MULT_TYPE SIZEOF_WORD ; sizeof(IFAST_MULT_TYPE)
+%define IFAST_SCALE_BITS 2 ; fractional bits in scale factors
+
++%define FLOAT_MULT_TYPE FP32 ; must be float
++%define SIZEOF_FLOAT_MULT_TYPE SIZEOF_FP32 ; sizeof(FLOAT_MULT_TYPE)
++
+;
+; -- jsimd.h
+;
+
+definev(JSIMD_NONE)
+definev(JSIMD_MMX)
++definev(JSIMD_3DNOW)
+
+; Short forms of external names for systems with brain-damaged linkers.
+;
+#ifdef NEED_SHORT_EXTERNAL_NAMES
+definev(jpeg_simd_cpu_support)
+definev(jsimd_rgb_ycc_convert_mmx)
+definev(jsimd_ycc_rgb_convert_mmx)
+definev(jsimd_h2v2_downsample_mmx)
+definev(jsimd_h2v1_downsample_mmx)
+definev(jsimd_h2v2_upsample_mmx)
+definev(jsimd_h2v1_upsample_mmx)
+definev(jsimd_h2v1_fancy_upsample_mmx)
+definev(jsimd_h2v2_fancy_upsample_mmx)
+definev(jsimd_h2v1_merged_upsample_mmx)
+definev(jsimd_h2v2_merged_upsample_mmx)
+definev(jsimd_convsamp_mmx)
++definev(jsimd_convsamp_float_3dnow)
+definev(jsimd_fdct_islow_mmx)
+definev(jsimd_fdct_ifast_mmx)
++definev(jsimd_fdct_float_3dnow)
+definev(jsimd_quantize_mmx)
++definev(jsimd_quantize_float_3dnow)
+definev(jsimd_idct_2x2_mmx)
+definev(jsimd_idct_4x4_mmx)
+definev(jsimd_idct_islow_mmx)
+definev(jsimd_idct_ifast_mmx)
++definev(jsimd_idct_float_3dnow)
+#endif /* NEED_SHORT_EXTERNAL_NAMES */
+
jz short .no_mmx
or edi, byte JSIMD_MMX
.no_mmx:
- test eax, 1<<25 ; bit25:SSE
- jz short .no_sse
- or edi, byte JSIMD_SSE
-.no_sse:
- test eax, 1<<26 ; bit26:SSE2
- jz short .no_sse2
- or edi, byte JSIMD_SSE2
-.no_sse2:
+ ; Check for 3DNow! instruction support
+ mov eax, 0x80000000
+ cpuid
+ cmp eax, 0x80000000
+ jbe short .return
+
+ mov eax, 0x80000001
+ cpuid
+ mov eax,edx ; eax = Extended feature flags
+
+ test eax, 1<<31 ; bit31:3DNow!(vendor independent)
+ jz short .no_3dnow
+ or edi, byte JSIMD_3DNOW
+ .no_3dnow:
+
.return:
mov eax,edi
; ==========================================================================
-; ---- jpeglib.h -----------------------------------------------------------
-
-%define DCTSIZE 8 ; The basic DCT block is 8x8 samples
-%define DCTSIZE2 64 ; DCTSIZE squared; # of elements in a block
-
-%define JSIMD_NONE 0x00 ; bitflags for jpeg_simd_*_support()
-%define JSIMD_MMX 0x01
-%define JSIMD_3DNOW 0x02
-%define JSIMD_SSE 0x04
-%define JSIMD_SSE2 0x08
-%define JSIMD_ALL (JSIMD_MMX | JSIMD_3DNOW | JSIMD_SSE | JSIMD_SSE2)
-
-; ---- jpegint.h -----------------------------------------------------------
-
-; Short forms of external names for systems with brain-damaged linkers.
-;
-%ifdef NEED_SHORT_EXTERNAL_NAMES
-%define jpeg_simd_cpu_support jSiCpuSupport
-%define jpeg_simd_os_support jSiOsSupport
-%endif ; NEED_SHORT_EXTERNAL_NAMES
-
-; ---- jmorecfg.h ----------------------------------------------------------
-;
-; BITS_IN_JSAMPLE==8 (8-bit sample values) is the only valid setting
-; on this SIMD implementation.
-;
-%define BITS_IN_JSAMPLE 8 ; Caution: Cannot be changed
-
-; Representation of a single sample (pixel element value).
-; On this SIMD implementation, this must be 'unsigned char'.
+; --------------------------------------------------------------------------
+; Common types
;
-%define JSAMPLE byte ; unsigned char
-%define SIZEOF_JSAMPLE SIZEOF_BYTE ; sizeof(JSAMPLE)
-%define MAXJSAMPLE 255
-%define CENTERJSAMPLE 128
+%define POINTER dword ; general pointer type
+%define SIZEOF_POINTER SIZEOF_DWORD ; sizeof(POINTER)
+%define POINTER_BIT DWORD_BIT ; sizeof(POINTER)*BYTE_BIT
-; Representation of a DCT frequency coefficient.
-; On this SIMD implementation, this must be 'short'.
-;
-%define JCOEF word ; short
-%define SIZEOF_JCOEF SIZEOF_WORD ; sizeof(JCOEF)
+%define INT dword ; signed integer type
+%define SIZEOF_INT SIZEOF_DWORD ; sizeof(INT)
+%define INT_BIT DWORD_BIT ; sizeof(INT)*BYTE_BIT
-; INT32 must hold at least signed 32-bit values.
-; On this SIMD implementation, this must be 'long'.
-;
-%define INT32 dword ; long
-%define SIZEOF_INT32 SIZEOF_DWORD ; sizeof(INT32)
++%define FP32 dword ; IEEE754 single
++%define SIZEOF_FP32 SIZEOF_DWORD ; sizeof(FP32)
++%define FP32_BIT DWORD_BIT ; sizeof(FP32)*BYTE_BIT
+
-; Datatype used for image dimensions.
-; On this SIMD implementation, this must be 'unsigned int'.
-;
-%define JDIMENSION dword ; unsigned int
-%define SIZEOF_JDIMENSION SIZEOF_DWORD ; sizeof(JDIMENSION)
+%define MMWORD qword ; int64 (MMX register)
+%define SIZEOF_MMWORD SIZEOF_QWORD ; sizeof(MMWORD)
+%define MMWORD_BIT QWORD_BIT ; sizeof(MMWORD)*BYTE_BIT
-; --------------------------------------------------------------------------
+%define SIZEOF_BYTE 1 ; sizeof(BYTE)
+%define SIZEOF_WORD 2 ; sizeof(WORD)
+%define SIZEOF_DWORD 4 ; sizeof(DWORD)
+%define SIZEOF_QWORD 8 ; sizeof(QWORD)
-%define JSAMPROW POINTER ; JSAMPLE FAR * (jpeglib.h)
-%define JSAMPARRAY POINTER ; JSAMPROW * (jpeglib.h)
-%define JSAMPIMAGE POINTER ; JSAMPARRAY * (jpeglib.h)
-%define JCOEFPTR POINTER ; JCOEF FAR * (jpeglib.h)
-%define SIZEOF_JSAMPROW SIZEOF_POINTER ; sizeof(JSAMPROW)
-%define SIZEOF_JSAMPARRAY SIZEOF_POINTER ; sizeof(JSAMPARRAY)
-%define SIZEOF_JSAMPIMAGE SIZEOF_POINTER ; sizeof(JSAMPIMAGE)
-%define SIZEOF_JCOEFPTR SIZEOF_POINTER ; sizeof(JCOEFPTR)
-
-%define POINTER dword ; general pointer type
-%define SIZEOF_POINTER SIZEOF_DWORD ; sizeof(POINTER)
-%define POINTER_BIT DWORD_BIT ; sizeof(POINTER)*BYTE_BIT
-
-%define INT dword ; signed integer type
-%define SIZEOF_INT SIZEOF_DWORD ; sizeof(INT)
-%define INT_BIT DWORD_BIT ; sizeof(INT)*BYTE_BIT
-
-%define FP32 dword ; IEEE754 single
-%define SIZEOF_FP32 SIZEOF_DWORD ; sizeof(FP32)
-%define FP32_BIT DWORD_BIT ; sizeof(FP32)*BYTE_BIT
-
-%define FP64 qword ; IEEE754 double
-%define SIZEOF_FP64 SIZEOF_QWORD ; sizeof(FP64)
-%define FP64_BIT QWORD_BIT ; sizeof(FP64)*BYTE_BIT
-
-%define FP80 tword ; IEEE754 double-extended(x86)
-%define SIZEOF_FP80 SIZEOF_TWORD ; sizeof(FP80)
-%define FP80_BIT TWORD_BIT ; sizeof(FP80)*BYTE_BIT
-
-%define MMWORD qword ; int64 (MMX register)
-%define SIZEOF_MMWORD SIZEOF_QWORD ; sizeof(MMWORD)
-%define MMWORD_BIT QWORD_BIT ; sizeof(MMWORD)*BYTE_BIT
-
-%define XMMWORD dqword ; int128 (SSE register)
-%define SIZEOF_XMMWORD SIZEOF_DQWORD ; sizeof(XMMWORD)
-%define XMMWORD_BIT DQWORD_BIT ; sizeof(XMMWORD)*BYTE_BIT
-
-%define SIZEOF_BYTE 1 ; sizeof(BYTE)
-%define SIZEOF_WORD 2 ; sizeof(WORD)
-%define SIZEOF_DWORD 4 ; sizeof(DWORD)
-%define SIZEOF_QWORD 8 ; sizeof(QWORD)
-%define SIZEOF_TBYTE 10 ; sizeof(TBYTE)
-%define SIZEOF_TWORD 10 ; sizeof(TWORD)
-%define SIZEOF_DQWORD 16 ; sizeof(DQWORD)
-
-%define BYTE_BIT 8 ; CHAR_BIT in C
-%define WORD_BIT 16 ; sizeof(WORD)*BYTE_BIT
-%define DWORD_BIT 32 ; sizeof(DWORD)*BYTE_BIT
-%define QWORD_BIT 64 ; sizeof(QWORD)*BYTE_BIT
-%define TBYTE_BIT 80 ; sizeof(TBYTE)*BYTE_BIT
-%define TWORD_BIT 80 ; sizeof(TWORD)*BYTE_BIT
-%define DQWORD_BIT 128 ; sizeof(DQWORD)*BYTE_BIT
-
-%idefine TBYTE TWORD ; NASM uses the keyword 'TWORD' instead of 'TBYTE'
-%idefine DQWORD ; currently not supported by NASM
-%idefine _MMWORD ;
-%idefine _DWORD ;
+%define BYTE_BIT 8 ; CHAR_BIT in C
+%define WORD_BIT 16 ; sizeof(WORD)*BYTE_BIT
+%define DWORD_BIT 32 ; sizeof(DWORD)*BYTE_BIT
+%define QWORD_BIT 64 ; sizeof(QWORD)*BYTE_BIT
; --------------------------------------------------------------------------
; External Symbol Name