Home | History | Annotate | Download | only in encoder
      1 /*
      2  * Copyright (c) 2016, Alliance for Open Media. All rights reserved
      3  *
      4  * This source code is subject to the terms of the BSD 2 Clause License and
      5  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
      6  * was not distributed with this source code in the LICENSE file, you can
      7  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
      8  * Media Patent License 1.0 was not distributed with this source code in the
      9  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
     10  */
     11 
     12 #ifndef AOM_AV1_ENCODER_PUSTATS_H_
     13 #define AOM_AV1_ENCODER_PUSTATS_H_
     14 
     15 #ifdef __cplusplus
     16 extern "C" {
     17 #endif
     18 
     19 #include "av1/encoder/ml.h"
     20 
     21 #define NUM_FEATURES_PUSTATS 8
     22 #define NUM_HIDDEN_LAYERS 2
     23 #define HIDDEN_LAYERS_0_NODES 12
     24 #define HIDDEN_LAYERS_1_NODES 10
     25 #define LOGITS_NODES 1
     26 
     27 static const float
     28     av1_pustats_rate_hiddenlayer_0_kernel[NUM_FEATURES_PUSTATS *
     29                                           HIDDEN_LAYERS_0_NODES] = {
     30       -0.1758f, -0.0499f, -10.0069f, -2.2838f,  -0.3359f,  0.3459f,  -0.3285f,
     31       -0.0515f, -0.5417f, 0.2357f,   -0.0575f,  -69.0782f, 0.5348f,  1.4068f,
     32       0.2213f,  -1.0490f, -0.0636f,  0.1654f,   1.1002f,   33.4924f, 0.4358f,
     33       1.2499f,  0.1143f,  0.0592f,   -1.6335f,  -0.0092f,  1.2207f,  -28.4543f,
     34       -0.4973f, 0.4368f,  0.2341f,   -0.1623f,  -3.8986f,  0.1311f,  -1.8789f,
     35       -3.9079f, -0.8158f, -0.8420f,  1.4295f,   -2.3629f,  -1.4825f, 0.6498f,
     36       -5.3669f, 6.4434f,  1.8393f,   -35.0678f, 3.7459f,   -2.8504f, 2.0502f,
     37       -0.1812f, -3.9011f, -1.0155f,  1.8375f,   -1.4517f,  1.3917f,  3.8664f,
     38       0.8345f,  -0.3472f, 5.7740f,   -1.1196f,  -0.3264f,  -1.2481f, -0.9284f,
     39       -4.9657f, 2.2831f,  0.7337f,   2.3176f,   0.6416f,   0.8804f,  1.9988f,
     40       -1.3426f, 1.2728f,  1.2249f,   -0.1551f,  5.6045f,   0.2046f,  -2.1464f,
     41       -2.4922f, -0.5334f, 12.1055f,  7.2467f,   -0.0070f,  0.0234f,  0.0021f,
     42       0.0215f,  -0.0098f, -0.0682f,  -6.1494f,  -0.3176f,  -1.6069f, -0.2119f,
     43       -1.0533f, -0.3566f, 0.5294f,   -0.4335f,  0.1626f,
     44     };
     45 
     46 static const float av1_pustats_rate_hiddenlayer_0_bias[HIDDEN_LAYERS_0_NODES] =
     47     {
     48       10.5266f, 5.3268f, -1.0678f, 7.7411f,  8.7164f,  -0.3235f,
     49       7.3028f,  9.0874f, -6.4594f, -1.0102f, -1.1146f, 10.8419f,
     50     };
     51 
     52 static const float
     53     av1_pustats_rate_hiddenlayer_1_kernel[HIDDEN_LAYERS_0_NODES *
     54                                           HIDDEN_LAYERS_1_NODES] = {
     55       10.5932f,  2.5192f,  -0.0015f, 5.9479f,   5.2426f,   -0.4091f, 5.3220f,
     56       6.0469f,   0.7200f,  3.3241f,  5.5006f,   12.8290f,  -1.6396f, 0.5743f,
     57       -0.8370f,  1.9956f,  -4.9270f, -1.5295f,  2.1350f,   -9.4415f, -0.7094f,
     58       5.1822f,   19.7287f, -3.0444f, -0.3320f,  0.0031f,   -0.2709f, -0.5249f,
     59       0.3281f,   -0.2240f, 0.2225f,  -0.2386f,  -0.4370f,  -0.2438f, -0.4928f,
     60       -0.2842f,  -2.1772f, 9.2570f,  -17.6655f, 3.5448f,   -2.8394f, -1.0167f,
     61       -0.5115f,  -1.9260f, -0.2111f, -0.7528f,  -1.2387f,  -0.0401f, 5.0716f,
     62       -3.3763f,  -0.2898f, -0.4956f, -7.9993f,  0.1526f,   -0.0242f, 0.7354f,
     63       6.0432f,   4.8043f,  7.4790f,  -0.6295f,  1.7565f,   3.7197f,  -2.3963f,
     64       6.8945f,   2.9717f,  -3.1623f, 3.4241f,   4.4676f,   -1.8154f, -2.9401f,
     65       -8.5657f,  -3.0240f, -1.4661f, 8.1145f,   -12.7858f, 3.3624f,  -1.0819f,
     66       -4.2856f,  1.1801f,  -0.5587f, -1.6062f,  -1.1813f,  -3.5882f, -0.2490f,
     67       -24.9566f, -0.4140f, -0.1113f, 3.5537f,   4.4112f,   0.1367f,  -1.5876f,
     68       1.6605f,   1.3903f,  -0.0253f, -2.1419f,  -2.2197f,  -0.7659f, -0.4249f,
     69       -0.0424f,  0.1486f,  0.4643f,  -0.9068f,  -0.3619f,  -0.7624f, -0.9132f,
     70       -0.4947f,  -0.3527f, -0.5445f, -0.4768f,  -1.7761f,  -1.0686f, 0.5462f,
     71       1.3371f,   4.3116f,  0.0777f,  -2.7216f,  -1.8908f,  3.4989f,  7.7269f,
     72       -2.7566f,
     73     };
     74 
     75 static const float av1_pustats_rate_hiddenlayer_1_bias[HIDDEN_LAYERS_1_NODES] =
     76     {
     77       13.2435f, -8.5477f, -0.0998f, -1.5131f, -12.0187f,
     78       6.1715f,  0.5094f,  7.6433f,  -0.3992f, -1.3555f,
     79     };
     80 
     81 static const float
     82     av1_pustats_rate_logits_kernel[HIDDEN_LAYERS_1_NODES * LOGITS_NODES] = {
     83       4.3078f, -17.3497f, 0.0195f,  34.6032f, -5.0127f,
     84       5.3079f, 10.0077f,  -13.129f, 0.0087f,  -8.4009f,
     85     };
     86 
     87 static const float av1_pustats_rate_logits_bias[LOGITS_NODES] = {
     88   4.5103f,
     89 };
     90 
     91 static const NN_CONFIG av1_pustats_rate_nnconfig = {
     92   NUM_FEATURES_PUSTATS,                              // num_inputs
     93   LOGITS_NODES,                                      // num_outputs
     94   NUM_HIDDEN_LAYERS,                                 // num_hidden_layers
     95   { HIDDEN_LAYERS_0_NODES, HIDDEN_LAYERS_1_NODES },  // num_hidden_nodes
     96   {
     97       av1_pustats_rate_hiddenlayer_0_kernel,
     98       av1_pustats_rate_hiddenlayer_1_kernel,
     99       av1_pustats_rate_logits_kernel,
    100   },
    101   {
    102       av1_pustats_rate_hiddenlayer_0_bias,
    103       av1_pustats_rate_hiddenlayer_1_bias,
    104       av1_pustats_rate_logits_bias,
    105   },
    106 };
    107 
    108 static const float
    109     av1_pustats_dist_hiddenlayer_0_kernel[NUM_FEATURES_PUSTATS *
    110                                           HIDDEN_LAYERS_0_NODES] = {
    111       -0.2560f, 0.1105f,  -0.8434f, -0.0132f, -8.9371f, -1.1176f, -0.3655f,
    112       0.4885f,  1.7518f,  0.4985f,  0.5582f,  -0.3739f, 0.9403f,  0.3874f,
    113       0.3265f,  1.7383f,  3.1747f,  0.0285f,  3.3942f,  -0.0123f, 0.5057f,
    114       0.1584f,  0.2697f,  4.6151f,  3.6251f,  -0.0121f, -1.0047f, -0.0037f,
    115       0.0127f,  0.1935f,  -0.5277f, -2.7144f, 0.0729f,  -0.1457f, -0.0816f,
    116       -0.5462f, 0.4738f,  0.3599f,  -0.0564f, 0.0910f,  0.0126f,  -0.0310f,
    117       -2.1311f, -0.4666f, -0.0074f, -0.0765f, 0.0287f,  -0.2662f, -0.0999f,
    118       -0.2983f, -0.4899f, -0.2314f, 0.2873f,  -0.3614f, 0.1783f,  -0.1210f,
    119       0.3569f,  0.5436f,  -8.0536f, -0.0044f, -1.5255f, -0.8247f, -0.4556f,
    120       1.9045f,  0.5463f,  0.1102f,  -0.9293f, -0.0185f, -0.8302f, -0.4378f,
    121       -0.3531f, -1.3095f, 0.6099f,  0.7977f,  4.1950f,  -0.0067f, -0.2762f,
    122       -0.1574f, -0.2149f, 0.6104f,  -1.7053f, 0.1904f,  4.2402f,  -0.2671f,
    123       0.8940f,  0.6820f,  0.2241f,  -0.9459f, 1.4571f,  0.5255f,  2.3352f,
    124       -0.0806f, 0.5231f,  0.3928f,  0.4146f,  2.0956f,
    125     };
    126 
    127 static const float av1_pustats_dist_hiddenlayer_0_bias[HIDDEN_LAYERS_0_NODES] =
    128     {
    129       1.1597f, 0.0836f, -0.7471f, -0.2439f, -0.0438f, 2.4626f,
    130       0.f,     1.1485f, 2.7085f,  -4.7897f, 1.4093f,  -1.657f,
    131     };
    132 
    133 static const float
    134     av1_pustats_dist_hiddenlayer_1_kernel[HIDDEN_LAYERS_0_NODES *
    135                                           HIDDEN_LAYERS_1_NODES] = {
    136       -0.5203f, -1.3468f, 0.3865f,  -0.6859f, 0.0058f,  4.0682f,  0.4807f,
    137       -0.1380f, 0.6050f,  0.8958f,  0.7748f,  -0.1311f, 1.7317f,  1.1265f,
    138       0.0827f,  0.1407f,  -0.3605f, 0.5429f,  0.1880f,  -0.1439f, 0.2837f,
    139       1.6477f,  0.0832f,  0.0593f,  -1.8464f, -0.7241f, -1.0672f, -0.3546f,
    140       -0.3842f, -2.3637f, 0.2514f,  0.8263f,  -0.1872f, 0.5774f,  -0.3610f,
    141       -0.0205f, 1.3977f,  -0.1083f, 0.6923f,  1.3039f,  -0.2870f, 1.0622f,
    142       -0.0566f, 0.2697f,  -0.5429f, -0.6193f, 1.7559f,  0.3246f,  1.9159f,
    143       0.3744f,  0.0686f,  1.0191f,  -0.4212f, 1.9591f,  -0.0691f, -0.1085f,
    144       -1.2034f, 0.0606f,  1.0116f,  0.5565f,  -0.1874f, -0.7898f, 0.4796f,
    145       0.2290f,  0.4334f,  -0.5817f, -0.2949f, 0.1367f,  -0.2932f, -1.1265f,
    146       0.0133f,  -0.5309f, -3.3191f, 0.0939f,  0.3895f,  -2.5812f, -0.0066f,
    147       -3.0063f, -0.2982f, 0.7309f,  -0.2422f, -0.2770f, -0.7152f, 0.1700f,
    148       1.9630f,  0.1988f,  0.4194f,  0.8762f,  0.3402f,  0.1051f,  -0.1598f,
    149       0.2405f,  0.0392f,  1.1256f,  1.5245f,  0.0950f,  0.2160f,  -0.5023f,
    150       0.2584f,  0.2074f,  0.2218f,  0.3966f,  -0.0921f, -0.2435f, -0.4560f,
    151       -1.1923f, -0.3716f, -0.3286f, -1.3225f, 0.1896f,  -0.3342f, -0.7888f,
    152       -0.4488f, -1.7168f, 0.3341f,  0.1146f,  0.5226f,  0.2610f,  -0.4574f,
    153       -0.4164f,
    154     };
    155 
    156 static const float av1_pustats_dist_hiddenlayer_1_bias[HIDDEN_LAYERS_1_NODES] =
    157     {
    158       -2.3014f, -2.4292f, 1.3317f, -3.2361f, -1.918f,
    159       2.7149f,  -2.5649f, 2.7765f, 2.9617f,  2.7684f,
    160     };
    161 
    162 static const float
    163     av1_pustats_dist_logits_kernel[HIDDEN_LAYERS_1_NODES * LOGITS_NODES] = {
    164       -0.6868f, -0.6715f, 0.449f,  -1.293f, 0.6214f,
    165       0.9894f,  -0.4342f, 0.7002f, 1.4363f, 0.6951f,
    166     };
    167 
    168 static const float av1_pustats_dist_logits_bias[LOGITS_NODES] = {
    169   2.3371f,
    170 };
    171 
    172 static const NN_CONFIG av1_pustats_dist_nnconfig = {
    173   NUM_FEATURES_PUSTATS,                              // num_inputs
    174   LOGITS_NODES,                                      // num_outputs
    175   NUM_HIDDEN_LAYERS,                                 // num_hidden_layers
    176   { HIDDEN_LAYERS_0_NODES, HIDDEN_LAYERS_1_NODES },  // num_hidden_nodes
    177   {
    178       av1_pustats_dist_hiddenlayer_0_kernel,
    179       av1_pustats_dist_hiddenlayer_1_kernel,
    180       av1_pustats_dist_logits_kernel,
    181   },
    182   {
    183       av1_pustats_dist_hiddenlayer_0_bias,
    184       av1_pustats_dist_hiddenlayer_1_bias,
    185       av1_pustats_dist_logits_bias,
    186   },
    187 };
    188 
    189 #undef NUM_HIDDEN_LAYERS
    190 #undef HIDDEN_LAYERS_0_NODES
    191 #undef HIDDEN_LAYERS_1_NODES
    192 #undef LOGITS_NODES
    193 
    194 #ifdef __cplusplus
    195 }  // extern "C"
    196 #endif
    197 
    198 #endif  // AOM_AV1_ENCODER_PUSTATS_H_
    199