Blame thirdparty/libjpeg-turbo/libjpeg-turbo-2.0.6/simd/loongson/jccolext-mmi.c

shun-iwasawa 82a8f5
/*
shun-iwasawa 82a8f5
 * Loongson MMI optimizations for libjpeg-turbo
shun-iwasawa 82a8f5
 *
shun-iwasawa 82a8f5
 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB</ossman@cendio.se>
shun-iwasawa 82a8f5
 * Copyright (C) 2014-2015, 2019, D. R. Commander.  All Rights Reserved.
shun-iwasawa 82a8f5
 * Copyright (C) 2016-2018, Loongson Technology Corporation Limited, BeiJing.
shun-iwasawa 82a8f5
 *                          All Rights Reserved.
shun-iwasawa 82a8f5
 * Authors:  ZhuChen     <zhuchen@loongson.cn></zhuchen@loongson.cn>
shun-iwasawa 82a8f5
 *           SunZhangzhi <sunzhangzhi-cq@loongson.cn></sunzhangzhi-cq@loongson.cn>
shun-iwasawa 82a8f5
 *           CaiWanwei   <caiwanwei@loongson.cn></caiwanwei@loongson.cn>
shun-iwasawa 82a8f5
 *           ZhangLixia  <zhanglixia-hf@loongson.cn></zhanglixia-hf@loongson.cn>
shun-iwasawa 82a8f5
 *
shun-iwasawa 82a8f5
 * Based on the x86 SIMD extension for IJG JPEG library
shun-iwasawa 82a8f5
 * Copyright (C) 1999-2006, MIYASAKA Masaru.
shun-iwasawa 82a8f5
 *
shun-iwasawa 82a8f5
 * This software is provided 'as-is', without any express or implied
shun-iwasawa 82a8f5
 * warranty.  In no event will the authors be held liable for any damages
shun-iwasawa 82a8f5
 * arising from the use of this software.
shun-iwasawa 82a8f5
 *
shun-iwasawa 82a8f5
 * Permission is granted to anyone to use this software for any purpose,
shun-iwasawa 82a8f5
 * including commercial applications, and to alter it and redistribute it
shun-iwasawa 82a8f5
 * freely, subject to the following restrictions:
shun-iwasawa 82a8f5
 *
shun-iwasawa 82a8f5
 * 1. The origin of this software must not be misrepresented; you must not
shun-iwasawa 82a8f5
 *    claim that you wrote the original software. If you use this software
shun-iwasawa 82a8f5
 *    in a product, an acknowledgment in the product documentation would be
shun-iwasawa 82a8f5
 *    appreciated but is not required.
shun-iwasawa 82a8f5
 * 2. Altered source versions must be plainly marked as such, and must not be
shun-iwasawa 82a8f5
 *    misrepresented as being the original software.
shun-iwasawa 82a8f5
 * 3. This notice may not be removed or altered from any source distribution.
shun-iwasawa 82a8f5
 */
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
/* This file is included by jccolor-mmi.c */
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
#if RGB_RED == 0
shun-iwasawa 82a8f5
#define mmA  mm0
shun-iwasawa 82a8f5
#define mmB  mm1
shun-iwasawa 82a8f5
#elif RGB_GREEN == 0
shun-iwasawa 82a8f5
#define mmA  mm2
shun-iwasawa 82a8f5
#define mmB  mm3
shun-iwasawa 82a8f5
#elif RGB_BLUE == 0
shun-iwasawa 82a8f5
#define mmA  mm4
shun-iwasawa 82a8f5
#define mmB  mm5
shun-iwasawa 82a8f5
#else
shun-iwasawa 82a8f5
#define mmA  mm6
shun-iwasawa 82a8f5
#define mmB  mm7
shun-iwasawa 82a8f5
#endif
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
#if RGB_RED == 1
shun-iwasawa 82a8f5
#define mmC  mm0
shun-iwasawa 82a8f5
#define mmD  mm1
shun-iwasawa 82a8f5
#elif RGB_GREEN == 1
shun-iwasawa 82a8f5
#define mmC  mm2
shun-iwasawa 82a8f5
#define mmD  mm3
shun-iwasawa 82a8f5
#elif RGB_BLUE == 1
shun-iwasawa 82a8f5
#define mmC  mm4
shun-iwasawa 82a8f5
#define mmD  mm5
shun-iwasawa 82a8f5
#else
shun-iwasawa 82a8f5
#define mmC  mm6
shun-iwasawa 82a8f5
#define mmD  mm7
shun-iwasawa 82a8f5
#endif
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
#if RGB_RED == 2
shun-iwasawa 82a8f5
#define mmE  mm0
shun-iwasawa 82a8f5
#define mmF  mm1
shun-iwasawa 82a8f5
#elif RGB_GREEN == 2
shun-iwasawa 82a8f5
#define mmE  mm2
shun-iwasawa 82a8f5
#define mmF  mm3
shun-iwasawa 82a8f5
#elif RGB_BLUE == 2
shun-iwasawa 82a8f5
#define mmE  mm4
shun-iwasawa 82a8f5
#define mmF  mm5
shun-iwasawa 82a8f5
#else
shun-iwasawa 82a8f5
#define mmE  mm6
shun-iwasawa 82a8f5
#define mmF  mm7
shun-iwasawa 82a8f5
#endif
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
#if RGB_RED == 3
shun-iwasawa 82a8f5
#define mmG  mm0
shun-iwasawa 82a8f5
#define mmH  mm1
shun-iwasawa 82a8f5
#elif RGB_GREEN == 3
shun-iwasawa 82a8f5
#define mmG  mm2
shun-iwasawa 82a8f5
#define mmH  mm3
shun-iwasawa 82a8f5
#elif RGB_BLUE == 3
shun-iwasawa 82a8f5
#define mmG  mm4
shun-iwasawa 82a8f5
#define mmH  mm5
shun-iwasawa 82a8f5
#else
shun-iwasawa 82a8f5
#define mmG  mm6
shun-iwasawa 82a8f5
#define mmH  mm7
shun-iwasawa 82a8f5
#endif
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
void jsimd_rgb_ycc_convert_mmi(JDIMENSION image_width, JSAMPARRAY input_buf,
shun-iwasawa 82a8f5
                               JSAMPIMAGE output_buf, JDIMENSION output_row,
shun-iwasawa 82a8f5
                               int num_rows)
shun-iwasawa 82a8f5
{
shun-iwasawa 82a8f5
  JSAMPROW inptr, outptr0, outptr1, outptr2;
shun-iwasawa 82a8f5
  int num_cols, col;
shun-iwasawa 82a8f5
  __m64 mm0, mm1, mm2, mm3, mm4, mm5, mm6, mm7;
shun-iwasawa 82a8f5
  __m64 wk[7];
shun-iwasawa 82a8f5
  __m64 Y_BG, Cb_RG, Cr_BG;
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  while (--num_rows >= 0) {
shun-iwasawa 82a8f5
    inptr = *input_buf++;
shun-iwasawa 82a8f5
    outptr0 = output_buf[0][output_row];
shun-iwasawa 82a8f5
    outptr1 = output_buf[1][output_row];
shun-iwasawa 82a8f5
    outptr2 = output_buf[2][output_row];
shun-iwasawa 82a8f5
    output_row++;
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    for (num_cols = image_width; num_cols > 0; num_cols -= 8,
shun-iwasawa 82a8f5
         outptr0 += 8, outptr1 += 8, outptr2 += 8) {
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
#if RGB_PIXELSIZE == 3
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      if (num_cols < 8) {
shun-iwasawa 82a8f5
        col = num_cols * 3;
shun-iwasawa 82a8f5
        asm(".set noreorder\r\n"
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
            "li     $8, 1\r\n"
shun-iwasawa 82a8f5
            "move   $9, %3\r\n"
shun-iwasawa 82a8f5
            "and    $10, $9, $8\r\n"
shun-iwasawa 82a8f5
            "beqz   $10, 1f\r\n"
shun-iwasawa 82a8f5
            "nop    \r\n"
shun-iwasawa 82a8f5
            "subu   $9, $9, 1\r\n"
shun-iwasawa 82a8f5
            "xor    $12, $12, $12\r\n"
shun-iwasawa 82a8f5
            "move   $13, %5\r\n"
shun-iwasawa 82a8f5
            "dadd   $13, $13, $9\r\n"
shun-iwasawa 82a8f5
            "lbu    $12, 0($13)\r\n"
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
            "1:     \r\n"
shun-iwasawa 82a8f5
            "li     $8, 2\r\n"
shun-iwasawa 82a8f5
            "and    $10, $9, $8\r\n"
shun-iwasawa 82a8f5
            "beqz   $10, 2f\r\n"
shun-iwasawa 82a8f5
            "nop    \r\n"
shun-iwasawa 82a8f5
            "subu   $9, $9, 2\r\n"
shun-iwasawa 82a8f5
            "xor    $11, $11, $11\r\n"
shun-iwasawa 82a8f5
            "move   $13, %5\r\n"
shun-iwasawa 82a8f5
            "dadd   $13, $13, $9\r\n"
shun-iwasawa 82a8f5
            "lhu    $11, 0($13)\r\n"
shun-iwasawa 82a8f5
            "sll    $12, $12, 16\r\n"
shun-iwasawa 82a8f5
            "or     $12, $12, $11\r\n"
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
            "2:     \r\n"
shun-iwasawa 82a8f5
            "dmtc1  $12, %0\r\n"
shun-iwasawa 82a8f5
            "li     $8, 4\r\n"
shun-iwasawa 82a8f5
            "and    $10, $9, $8\r\n"
shun-iwasawa 82a8f5
            "beqz   $10, 3f\r\n"
shun-iwasawa 82a8f5
            "nop    \r\n"
shun-iwasawa 82a8f5
            "subu   $9, $9, 4\r\n"
shun-iwasawa 82a8f5
            "move   $13, %5\r\n"
shun-iwasawa 82a8f5
            "dadd   $13, $13, $9\r\n"
shun-iwasawa 82a8f5
            "lwu    $14, 0($13)\r\n"
shun-iwasawa 82a8f5
            "dmtc1  $14, %1\r\n"
shun-iwasawa 82a8f5
            "dsll32 $12, $12, 0\r\n"
shun-iwasawa 82a8f5
            "or     $12, $12, $14\r\n"
shun-iwasawa 82a8f5
            "dmtc1  $12, %0\r\n"
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
            "3:     \r\n"
shun-iwasawa 82a8f5
            "li     $8, 8\r\n"
shun-iwasawa 82a8f5
            "and    $10, $9, $8\r\n"
shun-iwasawa 82a8f5
            "beqz   $10, 4f\r\n"
shun-iwasawa 82a8f5
            "nop    \r\n"
shun-iwasawa 82a8f5
            "mov.s  %1, %0\r\n"
shun-iwasawa 82a8f5
            "ldc1   %0, 0(%5)\r\n"
shun-iwasawa 82a8f5
            "li     $9, 8\r\n"
shun-iwasawa 82a8f5
            "j      5f\r\n"
shun-iwasawa 82a8f5
            "nop    \r\n"
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
            "4:     \r\n"
shun-iwasawa 82a8f5
            "li     $8, 16\r\n"
shun-iwasawa 82a8f5
            "and    $10, $9, $8\r\n"
shun-iwasawa 82a8f5
            "beqz   $10, 5f\r\n"
shun-iwasawa 82a8f5
            "nop    \r\n"
shun-iwasawa 82a8f5
            "mov.s  %2, %0\r\n"
shun-iwasawa 82a8f5
            "ldc1   %0, 0(%5)\r\n"
shun-iwasawa 82a8f5
            "ldc1   %1, 8(%5)\r\n"
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
            "5:     \r\n"
shun-iwasawa 82a8f5
            "nop    \r\n"
shun-iwasawa 82a8f5
            ".set reorder\r\n"
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
            : "=f" (mmA), "=f" (mmG), "=f" (mmF)
shun-iwasawa 82a8f5
            : "r" (col), "r" (num_rows), "r" (inptr)
shun-iwasawa 82a8f5
            : "$f0", "$f2", "$f4", "$8", "$9", "$10", "$11", "$12", "$13",
shun-iwasawa 82a8f5
              "$14", "memory"
shun-iwasawa 82a8f5
           );
shun-iwasawa 82a8f5
      } else {
shun-iwasawa 82a8f5
        if (!(((long)inptr) & 7)) {
shun-iwasawa 82a8f5
          mmA = _mm_load_si64((__m64 *)&inptr[0]);
shun-iwasawa 82a8f5
          mmG = _mm_load_si64((__m64 *)&inptr[8]);
shun-iwasawa 82a8f5
          mmF = _mm_load_si64((__m64 *)&inptr[16]);
shun-iwasawa 82a8f5
        } else {
shun-iwasawa 82a8f5
          mmA = _mm_loadu_si64((__m64 *)&inptr[0]);
shun-iwasawa 82a8f5
          mmG = _mm_loadu_si64((__m64 *)&inptr[8]);
shun-iwasawa 82a8f5
          mmF = _mm_loadu_si64((__m64 *)&inptr[16]);
shun-iwasawa 82a8f5
        }
shun-iwasawa 82a8f5
        inptr += RGB_PIXELSIZE * 8;
shun-iwasawa 82a8f5
      }
shun-iwasawa 82a8f5
      mmD = mmA;
shun-iwasawa 82a8f5
      mmA = _mm_slli_si64(mmA, 4 * BYTE_BIT);
shun-iwasawa 82a8f5
      mmD = _mm_srli_si64(mmD, 4 * BYTE_BIT);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mmA = _mm_unpackhi_pi8(mmA, mmG);
shun-iwasawa 82a8f5
      mmG = _mm_slli_si64(mmG, 4 * BYTE_BIT);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mmD = _mm_unpacklo_pi8(mmD, mmF);
shun-iwasawa 82a8f5
      mmG = _mm_unpackhi_pi8(mmG, mmF);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mmE = mmA;
shun-iwasawa 82a8f5
      mmA = _mm_slli_si64(mmA, 4 * BYTE_BIT);
shun-iwasawa 82a8f5
      mmE = _mm_srli_si64(mmE, 4 * BYTE_BIT);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mmA = _mm_unpackhi_pi8(mmA, mmD);
shun-iwasawa 82a8f5
      mmD = _mm_slli_si64(mmD, 4 * BYTE_BIT);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mmE = _mm_unpacklo_pi8(mmE, mmG);
shun-iwasawa 82a8f5
      mmD = _mm_unpackhi_pi8(mmD, mmG);
shun-iwasawa 82a8f5
      mmC = mmA;
shun-iwasawa 82a8f5
      mmA = _mm_loadlo_pi8_f(mmA);
shun-iwasawa 82a8f5
      mmC = _mm_loadhi_pi8_f(mmC);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mmB = mmE;
shun-iwasawa 82a8f5
      mmE = _mm_loadlo_pi8_f(mmE);
shun-iwasawa 82a8f5
      mmB = _mm_loadhi_pi8_f(mmB);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mmF = mmD;
shun-iwasawa 82a8f5
      mmD = _mm_loadlo_pi8_f(mmD);
shun-iwasawa 82a8f5
      mmF = _mm_loadhi_pi8_f(mmF);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
#else  /* RGB_PIXELSIZE == 4 */
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      if (num_cols < 8) {
shun-iwasawa 82a8f5
        col = num_cols;
shun-iwasawa 82a8f5
        asm(".set noreorder\r\n"
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
            "li     $8, 1\r\n"
shun-iwasawa 82a8f5
            "move   $9, %4\r\n"
shun-iwasawa 82a8f5
            "and    $10, $9, $8\r\n"
shun-iwasawa 82a8f5
            "beqz   $10, 1f\r\n"
shun-iwasawa 82a8f5
            "nop    \r\n"
shun-iwasawa 82a8f5
            "subu   $9, $9, 1\r\n"
shun-iwasawa 82a8f5
            "dsll   $11, $9, 2\r\n"
shun-iwasawa 82a8f5
            "move   $13, %5\r\n"
shun-iwasawa 82a8f5
            "daddu  $13, $13, $11\r\n"
shun-iwasawa 82a8f5
            "lwc1   %0, 0($13)\r\n"
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
            "1:     \r\n"
shun-iwasawa 82a8f5
            "li     $8, 2\r\n"
shun-iwasawa 82a8f5
            "and    $10, $9, $8\r\n"
shun-iwasawa 82a8f5
            "beqz   $10, 2f\r\n"
shun-iwasawa 82a8f5
            "nop    \r\n"
shun-iwasawa 82a8f5
            "subu   $9, $9, 2\r\n"
shun-iwasawa 82a8f5
            "dsll   $11, $9, 2\r\n"
shun-iwasawa 82a8f5
            "move   $13, %5\r\n"
shun-iwasawa 82a8f5
            "daddu  $13, $13, $11\r\n"
shun-iwasawa 82a8f5
            "mov.s  %1, %0\r\n"
shun-iwasawa 82a8f5
            "ldc1   %0, 0($13)\r\n"
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
            "2:     \r\n"
shun-iwasawa 82a8f5
            "li     $8, 4\r\n"
shun-iwasawa 82a8f5
            "and    $10, $9, $8\r\n"
shun-iwasawa 82a8f5
            "beqz   $10, 3f\r\n"
shun-iwasawa 82a8f5
            "nop    \r\n"
shun-iwasawa 82a8f5
            "mov.s  %2, %0\r\n"
shun-iwasawa 82a8f5
            "mov.s  %3, %1\r\n"
shun-iwasawa 82a8f5
            "ldc1   %0, 0(%5)\r\n"
shun-iwasawa 82a8f5
            "ldc1   %1, 8(%5)\r\n"
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
            "3:     \r\n"
shun-iwasawa 82a8f5
            "nop    \r\n"
shun-iwasawa 82a8f5
            ".set reorder\r\n"
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
            : "=f" (mmA), "=f" (mmF), "=f" (mmD), "=f" (mmC)
shun-iwasawa 82a8f5
            : "r" (col), "r" (inptr)
shun-iwasawa 82a8f5
            : "$f0", "$f2", "$8", "$9", "$10", "$11", "$13", "memory"
shun-iwasawa 82a8f5
           );
shun-iwasawa 82a8f5
      } else {
shun-iwasawa 82a8f5
        if (!(((long)inptr) & 7)) {
shun-iwasawa 82a8f5
          mmA = _mm_load_si64((__m64 *)&inptr[0]);
shun-iwasawa 82a8f5
          mmF = _mm_load_si64((__m64 *)&inptr[8]);
shun-iwasawa 82a8f5
          mmD = _mm_load_si64((__m64 *)&inptr[16]);
shun-iwasawa 82a8f5
          mmC = _mm_load_si64((__m64 *)&inptr[24]);
shun-iwasawa 82a8f5
        } else {
shun-iwasawa 82a8f5
          mmA = _mm_loadu_si64((__m64 *)&inptr[0]);
shun-iwasawa 82a8f5
          mmF = _mm_loadu_si64((__m64 *)&inptr[8]);
shun-iwasawa 82a8f5
          mmD = _mm_loadu_si64((__m64 *)&inptr[16]);
shun-iwasawa 82a8f5
          mmC = _mm_loadu_si64((__m64 *)&inptr[24]);
shun-iwasawa 82a8f5
        }
shun-iwasawa 82a8f5
        inptr += RGB_PIXELSIZE * 8;
shun-iwasawa 82a8f5
      }
shun-iwasawa 82a8f5
      mmB = mmA;
shun-iwasawa 82a8f5
      mmA = _mm_unpacklo_pi8(mmA, mmF);
shun-iwasawa 82a8f5
      mmB = _mm_unpackhi_pi8(mmB, mmF);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mmG = mmD;
shun-iwasawa 82a8f5
      mmD = _mm_unpacklo_pi8(mmD, mmC);
shun-iwasawa 82a8f5
      mmG = _mm_unpackhi_pi8(mmG, mmC);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mmE = mmA;
shun-iwasawa 82a8f5
      mmA = _mm_unpacklo_pi16(mmA, mmD);
shun-iwasawa 82a8f5
      mmE = _mm_unpackhi_pi16(mmE, mmD);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mmH = mmB;
shun-iwasawa 82a8f5
      mmB = _mm_unpacklo_pi16(mmB, mmG);
shun-iwasawa 82a8f5
      mmH = _mm_unpackhi_pi16(mmH, mmG);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mmC = mmA;
shun-iwasawa 82a8f5
      mmA = _mm_loadlo_pi8_f(mmA);
shun-iwasawa 82a8f5
      mmC = _mm_loadhi_pi8_f(mmC);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mmD = mmB;
shun-iwasawa 82a8f5
      mmB = _mm_loadlo_pi8_f(mmB);
shun-iwasawa 82a8f5
      mmD = _mm_loadhi_pi8_f(mmD);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mmG = mmE;
shun-iwasawa 82a8f5
      mmE = _mm_loadlo_pi8_f(mmE);
shun-iwasawa 82a8f5
      mmG = _mm_loadhi_pi8_f(mmG);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mmF = mmH;
shun-iwasawa 82a8f5
      mmF = _mm_unpacklo_pi8(mmF, mmH);
shun-iwasawa 82a8f5
      mmH = _mm_unpackhi_pi8(mmH, mmH);
shun-iwasawa 82a8f5
      mmF = _mm_srli_pi16(mmF, BYTE_BIT);
shun-iwasawa 82a8f5
      mmH = _mm_srli_pi16(mmH, BYTE_BIT);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
#endif
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      wk[0] = mm0;
shun-iwasawa 82a8f5
      wk[1] = mm1;
shun-iwasawa 82a8f5
      wk[2] = mm4;
shun-iwasawa 82a8f5
      wk[3] = mm5;
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mm6 = mm1;
shun-iwasawa 82a8f5
      mm1 = _mm_unpacklo_pi16(mm1, mm3);
shun-iwasawa 82a8f5
      mm6 = _mm_unpackhi_pi16(mm6, mm3);
shun-iwasawa 82a8f5
      mm7 = mm1;
shun-iwasawa 82a8f5
      mm4 = mm6;
shun-iwasawa 82a8f5
      mm1 = _mm_madd_pi16(mm1, PW_F0299_F0337);
shun-iwasawa 82a8f5
      mm6 = _mm_madd_pi16(mm6, PW_F0299_F0337);
shun-iwasawa 82a8f5
      mm7 = _mm_madd_pi16(mm7, PW_MF016_MF033);
shun-iwasawa 82a8f5
      mm4 = _mm_madd_pi16(mm4, PW_MF016_MF033);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      wk[4] = mm1;
shun-iwasawa 82a8f5
      wk[5] = mm6;
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mm1 = _mm_loadlo_pi16_f(mm5);
shun-iwasawa 82a8f5
      mm6 = _mm_loadhi_pi16_f(mm5);
shun-iwasawa 82a8f5
      mm1 = _mm_srli_pi32(mm1, 1);
shun-iwasawa 82a8f5
      mm6 = _mm_srli_pi32(mm6, 1);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mm5 = PD_ONEHALFM1_CJ;
shun-iwasawa 82a8f5
      mm7 = _mm_add_pi32(mm7, mm1);
shun-iwasawa 82a8f5
      mm4 = _mm_add_pi32(mm4, mm6);
shun-iwasawa 82a8f5
      mm7 = _mm_add_pi32(mm7, mm5);
shun-iwasawa 82a8f5
      mm4 = _mm_add_pi32(mm4, mm5);
shun-iwasawa 82a8f5
      mm7 = _mm_srli_pi32(mm7, SCALEBITS);
shun-iwasawa 82a8f5
      mm4 = _mm_srli_pi32(mm4, SCALEBITS);
shun-iwasawa 82a8f5
      mm7 = _mm_packs_pi32(mm7, mm4);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mm1 = wk[2];
shun-iwasawa 82a8f5
      mm6 = mm0;
shun-iwasawa 82a8f5
      mm0 = _mm_unpacklo_pi16(mm0, mm2);
shun-iwasawa 82a8f5
      mm6 = _mm_unpackhi_pi16(mm6, mm2);
shun-iwasawa 82a8f5
      mm5 = mm0;
shun-iwasawa 82a8f5
      mm4 = mm6;
shun-iwasawa 82a8f5
      mm0 = _mm_madd_pi16(mm0, PW_F0299_F0337);
shun-iwasawa 82a8f5
      mm6 = _mm_madd_pi16(mm6, PW_F0299_F0337);
shun-iwasawa 82a8f5
      mm5 = _mm_madd_pi16(mm5, PW_MF016_MF033);
shun-iwasawa 82a8f5
      mm4 = _mm_madd_pi16(mm4, PW_MF016_MF033);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      wk[6] = mm0;
shun-iwasawa 82a8f5
      wk[7] = mm6;
shun-iwasawa 82a8f5
      mm0 = _mm_loadlo_pi16_f(mm1);
shun-iwasawa 82a8f5
      mm6 = _mm_loadhi_pi16_f(mm1);
shun-iwasawa 82a8f5
      mm0 = _mm_srli_pi32(mm0, 1);
shun-iwasawa 82a8f5
      mm6 = _mm_srli_pi32(mm6, 1);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mm1 = PD_ONEHALFM1_CJ;
shun-iwasawa 82a8f5
      mm5 = _mm_add_pi32(mm5, mm0);
shun-iwasawa 82a8f5
      mm4 = _mm_add_pi32(mm4, mm6);
shun-iwasawa 82a8f5
      mm5 = _mm_add_pi32(mm5, mm1);
shun-iwasawa 82a8f5
      mm4 = _mm_add_pi32(mm4, mm1);
shun-iwasawa 82a8f5
      mm5 = _mm_srli_pi32(mm5, SCALEBITS);
shun-iwasawa 82a8f5
      mm4 = _mm_srli_pi32(mm4, SCALEBITS);
shun-iwasawa 82a8f5
      mm5 = _mm_packs_pi32(mm5, mm4);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mm7 = _mm_slli_pi16(mm7, BYTE_BIT);
shun-iwasawa 82a8f5
      mm5  = _mm_or_si64(mm5, mm7);
shun-iwasawa 82a8f5
      Cb_RG = mm5;
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mm0 = wk[3];
shun-iwasawa 82a8f5
      mm6 = wk[2];
shun-iwasawa 82a8f5
      mm1 = wk[1];
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mm4 = mm0;
shun-iwasawa 82a8f5
      mm0 = _mm_unpacklo_pi16(mm0, mm3);
shun-iwasawa 82a8f5
      mm4 = _mm_unpackhi_pi16(mm4, mm3);
shun-iwasawa 82a8f5
      mm7 = mm0;
shun-iwasawa 82a8f5
      mm5 = mm4;
shun-iwasawa 82a8f5
      mm0 = _mm_madd_pi16(mm0, PW_F0114_F0250);
shun-iwasawa 82a8f5
      mm4 = _mm_madd_pi16(mm4, PW_F0114_F0250);
shun-iwasawa 82a8f5
      mm7 = _mm_madd_pi16(mm7, PW_MF008_MF041);
shun-iwasawa 82a8f5
      mm5 = _mm_madd_pi16(mm5, PW_MF008_MF041);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mm3 = PD_ONEHALF;
shun-iwasawa 82a8f5
      mm0 = _mm_add_pi32(mm0, wk[4]);
shun-iwasawa 82a8f5
      mm4 = _mm_add_pi32(mm4, wk[5]);
shun-iwasawa 82a8f5
      mm0 = _mm_add_pi32(mm0, mm3);
shun-iwasawa 82a8f5
      mm4 = _mm_add_pi32(mm4, mm3);
shun-iwasawa 82a8f5
      mm0 = _mm_srli_pi32(mm0, SCALEBITS);
shun-iwasawa 82a8f5
      mm4 = _mm_srli_pi32(mm4, SCALEBITS);
shun-iwasawa 82a8f5
      mm0 = _mm_packs_pi32(mm0, mm4);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mm3 = _mm_loadlo_pi16_f(mm1);
shun-iwasawa 82a8f5
      mm4 = _mm_loadhi_pi16_f(mm1);
shun-iwasawa 82a8f5
      mm3 = _mm_srli_pi32(mm3, 1);
shun-iwasawa 82a8f5
      mm4 = _mm_srli_pi32(mm4, 1);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mm1 = PD_ONEHALFM1_CJ;
shun-iwasawa 82a8f5
      mm7 = _mm_add_pi32(mm7, mm3);
shun-iwasawa 82a8f5
      mm5 = _mm_add_pi32(mm5, mm4);
shun-iwasawa 82a8f5
      mm7 = _mm_add_pi32(mm7, mm1);
shun-iwasawa 82a8f5
      mm5 = _mm_add_pi32(mm5, mm1);
shun-iwasawa 82a8f5
      mm7 = _mm_srli_pi32(mm7, SCALEBITS);
shun-iwasawa 82a8f5
      mm5 = _mm_srli_pi32(mm5, SCALEBITS);
shun-iwasawa 82a8f5
      mm7 = _mm_packs_pi32(mm7, mm5);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mm3 = wk[0];
shun-iwasawa 82a8f5
      mm4 = mm6;
shun-iwasawa 82a8f5
      mm6 = _mm_unpacklo_pi16(mm6, mm2);
shun-iwasawa 82a8f5
      mm4 = _mm_unpackhi_pi16(mm4, mm2);
shun-iwasawa 82a8f5
      mm1 = mm6;
shun-iwasawa 82a8f5
      mm5 = mm4;
shun-iwasawa 82a8f5
      mm6 = _mm_madd_pi16(mm6, PW_F0114_F0250);
shun-iwasawa 82a8f5
      mm4 = _mm_madd_pi16(mm4, PW_F0114_F0250);
shun-iwasawa 82a8f5
      mm1 = _mm_madd_pi16(mm1, PW_MF008_MF041);
shun-iwasawa 82a8f5
      mm5 = _mm_madd_pi16(mm5, PW_MF008_MF041);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mm2 = PD_ONEHALF;
shun-iwasawa 82a8f5
      mm6 = _mm_add_pi32(mm6, wk[6]);
shun-iwasawa 82a8f5
      mm4 = _mm_add_pi32(mm4, wk[7]);
shun-iwasawa 82a8f5
      mm6 = _mm_add_pi32(mm6, mm2);
shun-iwasawa 82a8f5
      mm4 = _mm_add_pi32(mm4, mm2);
shun-iwasawa 82a8f5
      mm6 = _mm_srli_pi32(mm6, SCALEBITS);
shun-iwasawa 82a8f5
      mm4 = _mm_srli_pi32(mm4, SCALEBITS);
shun-iwasawa 82a8f5
      mm6 = _mm_packs_pi32(mm6, mm4);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mm0 = _mm_slli_pi16(mm0, BYTE_BIT);
shun-iwasawa 82a8f5
      mm6 = _mm_or_si64(mm6, mm0);
shun-iwasawa 82a8f5
      Y_BG = mm6;
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mm2 = _mm_loadlo_pi16_f(mm3);
shun-iwasawa 82a8f5
      mm4 = _mm_loadhi_pi16_f(mm3);
shun-iwasawa 82a8f5
      mm2 = _mm_srli_pi32(mm2, 1);
shun-iwasawa 82a8f5
      mm4 = _mm_srli_pi32(mm4, 1);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mm0 = PD_ONEHALFM1_CJ;
shun-iwasawa 82a8f5
      mm1 = _mm_add_pi32(mm1, mm2);
shun-iwasawa 82a8f5
      mm5 = _mm_add_pi32(mm5, mm4);
shun-iwasawa 82a8f5
      mm1 = _mm_add_pi32(mm1, mm0);
shun-iwasawa 82a8f5
      mm5 = _mm_add_pi32(mm5, mm0);
shun-iwasawa 82a8f5
      mm1 = _mm_srli_pi32(mm1, SCALEBITS);
shun-iwasawa 82a8f5
      mm5 = _mm_srli_pi32(mm5, SCALEBITS);
shun-iwasawa 82a8f5
      mm1 = _mm_packs_pi32(mm1, mm5);
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      mm7 = _mm_slli_pi16(mm7, BYTE_BIT);
shun-iwasawa 82a8f5
      mm1 = _mm_or_si64(mm1, mm7);
shun-iwasawa 82a8f5
      Cr_BG = mm1;
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
      _mm_store_si64((__m64 *)&outptr0[0], Y_BG);
shun-iwasawa 82a8f5
      _mm_store_si64((__m64 *)&outptr1[0], Cb_RG);
shun-iwasawa 82a8f5
      _mm_store_si64((__m64 *)&outptr2[0], Cr_BG);
shun-iwasawa 82a8f5
    }
shun-iwasawa 82a8f5
  }
shun-iwasawa 82a8f5
}
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
#undef mmA
shun-iwasawa 82a8f5
#undef mmB
shun-iwasawa 82a8f5
#undef mmC
shun-iwasawa 82a8f5
#undef mmD
shun-iwasawa 82a8f5
#undef mmE
shun-iwasawa 82a8f5
#undef mmF
shun-iwasawa 82a8f5
#undef mmG
shun-iwasawa 82a8f5
#undef mmH