media/libvpx/vp9/common/vp9_scan.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libvpx/vp9/common/vp9_scan.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,199 @@
     1.4 +/*
     1.5 + *  Copyright (c) 2013 The WebM project authors. All Rights Reserved.
     1.6 + *
     1.7 + *  Use of this source code is governed by a BSD-style license
     1.8 + *  that can be found in the LICENSE file in the root of the source
     1.9 + *  tree. An additional intellectual property rights grant can be found
    1.10 + *  in the file PATENTS.  All contributing project authors may
    1.11 + *  be found in the AUTHORS file in the root of the source tree.
    1.12 + */
    1.13 +
    1.14 +#ifndef VP9_COMMON_VP9_SCAN_H_
    1.15 +#define VP9_COMMON_VP9_SCAN_H_
    1.16 +
    1.17 +#include "vpx/vpx_integer.h"
    1.18 +#include "vpx_ports/mem.h"
    1.19 +
    1.20 +#include "vp9/common/vp9_enums.h"
    1.21 +
    1.22 +#define MAX_NEIGHBORS 2
    1.23 +
    1.24 +extern DECLARE_ALIGNED(16, const int16_t, vp9_default_scan_4x4[16]);
    1.25 +extern DECLARE_ALIGNED(16, const int16_t, vp9_col_scan_4x4[16]);
    1.26 +extern DECLARE_ALIGNED(16, const int16_t, vp9_row_scan_4x4[16]);
    1.27 +
    1.28 +extern DECLARE_ALIGNED(16, const int16_t, vp9_default_scan_8x8[64]);
    1.29 +extern DECLARE_ALIGNED(16, const int16_t, vp9_col_scan_8x8[64]);
    1.30 +extern DECLARE_ALIGNED(16, const int16_t, vp9_row_scan_8x8[64]);
    1.31 +
    1.32 +extern DECLARE_ALIGNED(16, const int16_t, vp9_default_scan_16x16[256]);
    1.33 +extern DECLARE_ALIGNED(16, const int16_t, vp9_col_scan_16x16[256]);
    1.34 +extern DECLARE_ALIGNED(16, const int16_t, vp9_row_scan_16x16[256]);
    1.35 +
    1.36 +extern DECLARE_ALIGNED(16, const int16_t, vp9_default_scan_32x32[1024]);
    1.37 +
    1.38 +extern DECLARE_ALIGNED(16, int16_t, vp9_default_iscan_4x4[16]);
    1.39 +extern DECLARE_ALIGNED(16, int16_t, vp9_col_iscan_4x4[16]);
    1.40 +extern DECLARE_ALIGNED(16, int16_t, vp9_row_iscan_4x4[16]);
    1.41 +
    1.42 +extern DECLARE_ALIGNED(16, int16_t, vp9_default_iscan_8x8[64]);
    1.43 +extern DECLARE_ALIGNED(16, int16_t, vp9_col_iscan_8x8[64]);
    1.44 +extern DECLARE_ALIGNED(16, int16_t, vp9_row_iscan_8x8[64]);
    1.45 +
    1.46 +extern DECLARE_ALIGNED(16, int16_t, vp9_default_iscan_16x16[256]);
    1.47 +extern DECLARE_ALIGNED(16, int16_t, vp9_col_iscan_16x16[256]);
    1.48 +extern DECLARE_ALIGNED(16, int16_t, vp9_row_iscan_16x16[256]);
    1.49 +
    1.50 +extern DECLARE_ALIGNED(16, int16_t, vp9_default_iscan_32x32[1024]);
    1.51 +
    1.52 +extern DECLARE_ALIGNED(16, int16_t,
    1.53 +                       vp9_default_scan_4x4_neighbors[17 * MAX_NEIGHBORS]);
    1.54 +extern DECLARE_ALIGNED(16, int16_t,
    1.55 +                       vp9_col_scan_4x4_neighbors[17 * MAX_NEIGHBORS]);
    1.56 +extern DECLARE_ALIGNED(16, int16_t,
    1.57 +                       vp9_row_scan_4x4_neighbors[17 * MAX_NEIGHBORS]);
    1.58 +extern DECLARE_ALIGNED(16, int16_t,
    1.59 +                       vp9_col_scan_8x8_neighbors[65 * MAX_NEIGHBORS]);
    1.60 +extern DECLARE_ALIGNED(16, int16_t,
    1.61 +                       vp9_row_scan_8x8_neighbors[65 * MAX_NEIGHBORS]);
    1.62 +extern DECLARE_ALIGNED(16, int16_t,
    1.63 +                       vp9_default_scan_8x8_neighbors[65 * MAX_NEIGHBORS]);
    1.64 +extern DECLARE_ALIGNED(16, int16_t,
    1.65 +                       vp9_col_scan_16x16_neighbors[257 * MAX_NEIGHBORS]);
    1.66 +extern DECLARE_ALIGNED(16, int16_t,
    1.67 +                       vp9_row_scan_16x16_neighbors[257 * MAX_NEIGHBORS]);
    1.68 +extern DECLARE_ALIGNED(16, int16_t,
    1.69 +                       vp9_default_scan_16x16_neighbors[257 * MAX_NEIGHBORS]);
    1.70 +extern DECLARE_ALIGNED(16, int16_t,
    1.71 +                       vp9_default_scan_32x32_neighbors[1025 * MAX_NEIGHBORS]);
    1.72 +
    1.73 +
    1.74 +void vp9_init_neighbors();
    1.75 +
    1.76 +static INLINE const int16_t* get_scan_4x4(TX_TYPE tx_type) {
    1.77 +  switch (tx_type) {
    1.78 +    case ADST_DCT:
    1.79 +      return vp9_row_scan_4x4;
    1.80 +    case DCT_ADST:
    1.81 +      return vp9_col_scan_4x4;
    1.82 +    default:
    1.83 +      return vp9_default_scan_4x4;
    1.84 +  }
    1.85 +}
    1.86 +
    1.87 +static INLINE void get_scan_nb_4x4(TX_TYPE tx_type,
    1.88 +                                   const int16_t **scan, const int16_t **nb) {
    1.89 +  switch (tx_type) {
    1.90 +    case ADST_DCT:
    1.91 +      *scan = vp9_row_scan_4x4;
    1.92 +      *nb = vp9_row_scan_4x4_neighbors;
    1.93 +      break;
    1.94 +    case DCT_ADST:
    1.95 +      *scan = vp9_col_scan_4x4;
    1.96 +      *nb = vp9_col_scan_4x4_neighbors;
    1.97 +      break;
    1.98 +    default:
    1.99 +      *scan = vp9_default_scan_4x4;
   1.100 +      *nb = vp9_default_scan_4x4_neighbors;
   1.101 +      break;
   1.102 +  }
   1.103 +}
   1.104 +
   1.105 +static INLINE const int16_t* get_iscan_4x4(TX_TYPE tx_type) {
   1.106 +  switch (tx_type) {
   1.107 +    case ADST_DCT:
   1.108 +      return vp9_row_iscan_4x4;
   1.109 +    case DCT_ADST:
   1.110 +      return vp9_col_iscan_4x4;
   1.111 +    default:
   1.112 +      return vp9_default_iscan_4x4;
   1.113 +  }
   1.114 +}
   1.115 +
   1.116 +static INLINE const int16_t* get_scan_8x8(TX_TYPE tx_type) {
   1.117 +  switch (tx_type) {
   1.118 +    case ADST_DCT:
   1.119 +      return vp9_row_scan_8x8;
   1.120 +    case DCT_ADST:
   1.121 +      return vp9_col_scan_8x8;
   1.122 +    default:
   1.123 +      return vp9_default_scan_8x8;
   1.124 +  }
   1.125 +}
   1.126 +
   1.127 +static INLINE void get_scan_nb_8x8(TX_TYPE tx_type,
   1.128 +                                   const int16_t **scan, const int16_t **nb) {
   1.129 +  switch (tx_type) {
   1.130 +    case ADST_DCT:
   1.131 +      *scan = vp9_row_scan_8x8;
   1.132 +      *nb = vp9_row_scan_8x8_neighbors;
   1.133 +      break;
   1.134 +    case DCT_ADST:
   1.135 +      *scan = vp9_col_scan_8x8;
   1.136 +      *nb = vp9_col_scan_8x8_neighbors;
   1.137 +      break;
   1.138 +    default:
   1.139 +      *scan = vp9_default_scan_8x8;
   1.140 +      *nb = vp9_default_scan_8x8_neighbors;
   1.141 +      break;
   1.142 +  }
   1.143 +}
   1.144 +
   1.145 +static INLINE const int16_t* get_iscan_8x8(TX_TYPE tx_type) {
   1.146 +  switch (tx_type) {
   1.147 +    case ADST_DCT:
   1.148 +      return vp9_row_iscan_8x8;
   1.149 +    case DCT_ADST:
   1.150 +      return vp9_col_iscan_8x8;
   1.151 +    default:
   1.152 +      return vp9_default_iscan_8x8;
   1.153 +  }
   1.154 +}
   1.155 +
   1.156 +static INLINE const int16_t* get_scan_16x16(TX_TYPE tx_type) {
   1.157 +  switch (tx_type) {
   1.158 +    case ADST_DCT:
   1.159 +      return vp9_row_scan_16x16;
   1.160 +    case DCT_ADST:
   1.161 +      return vp9_col_scan_16x16;
   1.162 +    default:
   1.163 +      return vp9_default_scan_16x16;
   1.164 +  }
   1.165 +}
   1.166 +
   1.167 +static INLINE void get_scan_nb_16x16(TX_TYPE tx_type,
   1.168 +                                     const int16_t **scan, const int16_t **nb) {
   1.169 +  switch (tx_type) {
   1.170 +    case ADST_DCT:
   1.171 +      *scan = vp9_row_scan_16x16;
   1.172 +      *nb = vp9_row_scan_16x16_neighbors;
   1.173 +      break;
   1.174 +    case DCT_ADST:
   1.175 +      *scan = vp9_col_scan_16x16;
   1.176 +      *nb = vp9_col_scan_16x16_neighbors;
   1.177 +      break;
   1.178 +    default:
   1.179 +      *scan = vp9_default_scan_16x16;
   1.180 +      *nb = vp9_default_scan_16x16_neighbors;
   1.181 +      break;
   1.182 +  }
   1.183 +}
   1.184 +
   1.185 +static INLINE const int16_t* get_iscan_16x16(TX_TYPE tx_type) {
   1.186 +  switch (tx_type) {
   1.187 +    case ADST_DCT:
   1.188 +      return vp9_row_iscan_16x16;
   1.189 +    case DCT_ADST:
   1.190 +      return vp9_col_iscan_16x16;
   1.191 +    default:
   1.192 +      return vp9_default_iscan_16x16;
   1.193 +  }
   1.194 +}
   1.195 +
   1.196 +static INLINE int get_coef_context(const int16_t *neighbors,
   1.197 +                                   const uint8_t *token_cache, int c) {
   1.198 +  return (1 + token_cache[neighbors[MAX_NEIGHBORS * c + 0]] +
   1.199 +          token_cache[neighbors[MAX_NEIGHBORS * c + 1]]) >> 1;
   1.200 +}
   1.201 +
   1.202 +#endif  // VP9_COMMON_VP9_SCAN_H_

mercurial