/******************************************************************************
*
* Copyright (C) 2012 Ittiam Systems Pvt Ltd, Bangalore
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/**
*******************************************************************************
* @file
*  ihevc_tables_x86_intr.c
*
* @brief
*  Contains function Definition for intra prediction  interpolation filters
*
*
* @author
*  Rishab
*
* @par List of Functions:

* @remarks
*  None
*
*******************************************************************************
*/


/*****************************************************************************/
/* File Includes                                                             */
/*****************************************************************************/

#include "ihevc_typedefs.h"
#include "ihevc_platform_macros.h"
#include "ihevc_macros.h"
#include "ihevc_func_selector.h"
#include "ihevc_defs.h"
#include "ihevc_mem_fns.h"
#include "ihevc_tables_x86_intr.h"

// LUMA INTRA PRED
const UWORD8 IHEVCE_SHUFFLEMASKY1[16] = { 0x03, 0x02, 0x01, 0x00,
    0x02, 0x03, 0x03, 0x04,
    0x08, 0x08, 0x08, 0x08,
    0x08, 0x08, 0x08, 0x08 };

const UWORD8 IHEVCE_SHUFFLEMASKY2[16] = { 0x07, 0x06, 0x05, 0x04,
    0x03, 0x02, 0x01, 0x00,
    0x08, 0x08, 0x08, 0x08,
    0x08, 0x08, 0x08, 0x08 };

const UWORD8 IHEVCE_SHUFFLEMASKY3[16] = { 0x0f, 0x0e, 0x0d, 0x0c,
    0x0b, 0x0a, 0x09, 0x08,
    0x07, 0x06, 0x05, 0x04,
    0x03, 0x02, 0x01, 0x00 };

const UWORD8 IHEVCE_SHUFFLEMASK4[16] = { 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00 };

const UWORD8 IHEVCE_SHUFFLEMASK5[16] = { 0x00, 0x01, 0x08, 0x09,
    0x0f, 0x0f, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f,
    0x0f, 0x0f, 0x0f, 0x0f };
/// CHROMA INTRA PRED
const UWORD8 IHEVCE_SHUFFLEMASKY7[16] = { 0x06, 0x07, 0x04, 0x05,
    0x02, 0x03, 0x00, 0x01,
    0x08, 0x08, 0x08, 0x08,
    0x08, 0x08, 0x08, 0x08 };

const UWORD8 IHEVCE_SHUFFLEMASKY8[16] = { 0x0e, 0x0f, 0x0c, 0x0d,
    0x0a, 0x0b, 0x08, 0x09,
    0x06, 0x07, 0x04, 0x05,
    0x02, 0x03, 0x00, 0x01 };

const UWORD8 IHEVCE_SHUFFLEMASKY9[16] = { 0x00, 0x01, 0x04, 0x05,
    0x08, 0x09, 0x0c, 0x0d,
    0x02, 0x03, 0x06, 0x07,
    0x0a, 0x0b, 0x0e, 0x0f };

const UWORD8 IHEVCE_SHUFFLEMASKY11[16] = { 0x01, 0x00, 0x02, 0x01,
    0x03, 0x02, 0x04, 0x03,
    0x05, 0x04, 0x06, 0x05,
    0x07, 0x06, 0x08, 0x07 };
//INTRAPRED
const UWORD8 inv_angle_shuffle[7][32] =
{
    { 3, 0x80, 0x80, 0x80, 1, 2, 4, 5, 6, 7, 9, 10, 11, 12, 14, 15, 0x80, 0x80, 0x80, 0, 1, 2, 4, 5, 6, 7, 9, 10, 11, 12, 14, 15 },
    { 6, 0x80, 0x80, 0x80, 0x80, 0x80, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 1, 2, 4, 5, 7, 8, 10, 11, 13, 14 },
    { 8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 2, 4, 6, 8, 9, 11, 13, 15, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 1, 3, 5, 7, 8, 10, 12, 14 },
    { 10, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 2, 5, 7, 10, 12, 15, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 1, 4, 6, 9, 11, 14 },
    { 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 4, 7, 11, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 2, 5, 9, 12 },
    { 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 6, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 3, 10 },
    { 15, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0 }
};

/// DEBLOCK TABLES
const WORD8 coef_d[16] = { 0, 1, -2, 1, 1, -2, 1, 0, 0, 1, -2, 1, 1, -2, 1, 0 };
const WORD8 coef_de1[16] = { 3, -9, 9, -3, 3, -9, 9, -3, 3, -9, 9, -3, 3, -9, 9, -3 };
const WORD8 coef_dep1[16] = { -2, 1, 1, -2, -2, 1, 1, -2, -2, 1, 1, -2, -2, 1, 1, -2 };
const WORD32 shuffle_d[4] = { 0x80800403, 0x80800c0b, 0x03000704, 0x0b080f0c };
const WORD32 shuffle0[2] = { 0x80098001, 0x800e8006 };
const WORD32 shuffle1[4] = { 0x05040100, 0x0d0c0908, 0x07060302, 0x0f0e0b0a };
const WORD32 shuffle2[4] = { 0x80808080, 0x03020100, 0x07060504, 0x80808080 };
const WORD32 shuffle3[4] = { 0x80808080, 0x0b0a0908, 0x0f0e0d0c, 0x80808080 };

const WORD8 delta0[16] =  { 1, -4, 1, -4, 1, -4, 1, -4, 1, -4, 1, -4, 1, -4, 1, -4 };
const WORD8 delta1[16] =  { 4, -1, 4, -1, 4, -1, 4, -1, 4, -1, 4, -1, 4, -1, 4, -1 };
const WORD32 shuffle_uv[4] = { 0x03010200, 0x0b090a08, 0x07050604, 0x0f0d0e0c };