LCOV - code coverage report
Current view: directory - media/libvpx/vp8/common - entropy.c (source / functions) Found Hit Coverage
Test: app.info Lines: 34 0 0.0 %
Date: 2012-06-02 Functions: 5 0 0.0 %

       1                 : /*
       2                 :  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
       3                 :  *
       4                 :  *  Use of this source code is governed by a BSD-style license
       5                 :  *  that can be found in the LICENSE file in the root of the source
       6                 :  *  tree. An additional intellectual property rights grant can be found
       7                 :  *  in the file PATENTS.  All contributing project authors may
       8                 :  *  be found in the AUTHORS file in the root of the source tree.
       9                 :  */
      10                 : 
      11                 : 
      12                 : #include <stdio.h>
      13                 : 
      14                 : #include "entropy.h"
      15                 : #include "string.h"
      16                 : #include "blockd.h"
      17                 : #include "onyxc_int.h"
      18                 : 
      19                 : #define uchar unsigned char     /* typedefs can clash */
      20                 : #define uint  unsigned int
      21                 : 
      22                 : typedef const uchar cuchar;
      23                 : typedef const uint cuint;
      24                 : 
      25                 : typedef vp8_prob Prob;
      26                 : 
      27                 : #include "coefupdateprobs.h"
      28                 : 
      29                 : DECLARE_ALIGNED(16, const unsigned char, vp8_norm[256]) =
      30                 : {
      31                 :     0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
      32                 :     3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
      33                 :     2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
      34                 :     2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
      35                 :     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
      36                 :     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
      37                 :     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
      38                 :     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
      39                 :     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      40                 :     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      41                 :     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      42                 :     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      43                 :     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      44                 :     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      45                 :     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      46                 :     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
      47                 : };
      48                 : 
      49                 : DECLARE_ALIGNED(16, cuchar, vp8_coef_bands[16]) =
      50                 : { 0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7};
      51                 : 
      52                 : DECLARE_ALIGNED(16, cuchar, vp8_prev_token_class[MAX_ENTROPY_TOKENS]) =
      53                 : { 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0};
      54                 : 
      55                 : DECLARE_ALIGNED(16, const int, vp8_default_zig_zag1d[16]) =
      56                 : {
      57                 :     0,  1,  4,  8,
      58                 :     5,  2,  3,  6,
      59                 :     9, 12, 13, 10,
      60                 :     7, 11, 14, 15,
      61                 : };
      62                 : 
      63                 : DECLARE_ALIGNED(16, const short, vp8_default_inv_zig_zag[16]) =
      64                 : {
      65                 :     1,  2,  6,  7,
      66                 :     3,  5,  8, 13,
      67                 :     4,  9, 12, 14,
      68                 :    10, 11, 15, 16
      69                 : };
      70                 : 
      71                 : DECLARE_ALIGNED(16, short, vp8_default_zig_zag_mask[16]);
      72                 : 
      73                 : const int vp8_mb_feature_data_bits[MB_LVL_MAX] = {7, 6};
      74                 : 
      75                 : /* Array indices are identical to previously-existing CONTEXT_NODE indices */
      76                 : 
      77                 : const vp8_tree_index vp8_coef_tree[ 22] =     /* corresponding _CONTEXT_NODEs */
      78                 : {
      79                 :     -DCT_EOB_TOKEN, 2,                             /* 0 = EOB */
      80                 :     -ZERO_TOKEN, 4,                               /* 1 = ZERO */
      81                 :     -ONE_TOKEN, 6,                               /* 2 = ONE */
      82                 :     8, 12,                                      /* 3 = LOW_VAL */
      83                 :     -TWO_TOKEN, 10,                            /* 4 = TWO */
      84                 :     -THREE_TOKEN, -FOUR_TOKEN,                /* 5 = THREE */
      85                 :     14, 16,                                    /* 6 = HIGH_LOW */
      86                 :     -DCT_VAL_CATEGORY1, -DCT_VAL_CATEGORY2,   /* 7 = CAT_ONE */
      87                 :     18, 20,                                   /* 8 = CAT_THREEFOUR */
      88                 :     -DCT_VAL_CATEGORY3, -DCT_VAL_CATEGORY4,  /* 9 = CAT_THREE */
      89                 :     -DCT_VAL_CATEGORY5, -DCT_VAL_CATEGORY6   /* 10 = CAT_FIVE */
      90                 : };
      91                 : 
      92                 : struct vp8_token_struct vp8_coef_encodings[MAX_ENTROPY_TOKENS];
      93                 : 
      94                 : /* Trees for extra bits.  Probabilities are constant and
      95                 :    do not depend on previously encoded bits */
      96                 : 
      97                 : static const Prob Pcat1[] = { 159};
      98                 : static const Prob Pcat2[] = { 165, 145};
      99                 : static const Prob Pcat3[] = { 173, 148, 140};
     100                 : static const Prob Pcat4[] = { 176, 155, 140, 135};
     101                 : static const Prob Pcat5[] = { 180, 157, 141, 134, 130};
     102                 : static const Prob Pcat6[] =
     103                 : { 254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129};
     104                 : 
     105                 : static vp8_tree_index cat1[2], cat2[4], cat3[6], cat4[8], cat5[10], cat6[22];
     106                 : 
     107               0 : void vp8_init_scan_order_mask()
     108                 : {
     109                 :     int i;
     110                 : 
     111               0 :     for (i = 0; i < 16; i++)
     112                 :     {
     113               0 :         vp8_default_zig_zag_mask[vp8_default_zig_zag1d[i]] = 1 << i;
     114                 :     }
     115                 : 
     116               0 : }
     117                 : 
     118               0 : static void init_bit_tree(vp8_tree_index *p, int n)
     119                 : {
     120               0 :     int i = 0;
     121                 : 
     122               0 :     while (++i < n)
     123                 :     {
     124               0 :         p[0] = p[1] = i << 1;
     125               0 :         p += 2;
     126                 :     }
     127                 : 
     128               0 :     p[0] = p[1] = 0;
     129               0 : }
     130                 : 
     131               0 : static void init_bit_trees()
     132                 : {
     133               0 :     init_bit_tree(cat1, 1);
     134               0 :     init_bit_tree(cat2, 2);
     135               0 :     init_bit_tree(cat3, 3);
     136               0 :     init_bit_tree(cat4, 4);
     137               0 :     init_bit_tree(cat5, 5);
     138               0 :     init_bit_tree(cat6, 11);
     139               0 : }
     140                 : 
     141                 : vp8_extra_bit_struct vp8_extra_bits[12] =
     142                 : {
     143                 :     { 0, 0, 0, 0},
     144                 :     { 0, 0, 0, 1},
     145                 :     { 0, 0, 0, 2},
     146                 :     { 0, 0, 0, 3},
     147                 :     { 0, 0, 0, 4},
     148                 :     { cat1, Pcat1, 1, 5},
     149                 :     { cat2, Pcat2, 2, 7},
     150                 :     { cat3, Pcat3, 3, 11},
     151                 :     { cat4, Pcat4, 4, 19},
     152                 :     { cat5, Pcat5, 5, 35},
     153                 :     { cat6, Pcat6, 11, 67},
     154                 :     { 0, 0, 0, 0}
     155                 : };
     156                 : #include "defaultcoefcounts.h"
     157                 : 
     158               0 : void vp8_default_coef_probs(VP8_COMMON *pc)
     159                 : {
     160               0 :     int h = 0;
     161                 : 
     162                 :     do
     163                 :     {
     164               0 :         int i = 0;
     165                 : 
     166                 :         do
     167                 :         {
     168               0 :             int k = 0;
     169                 : 
     170                 :             do
     171                 :             {
     172                 :                 unsigned int branch_ct [ENTROPY_NODES] [2];
     173               0 :                 vp8_tree_probs_from_distribution(
     174                 :                     MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
     175               0 :                     pc->fc.coef_probs[h][i][k],
     176                 :                     branch_ct,
     177               0 :                     vp8_default_coef_counts[h][i][k],
     178                 :                     256, 1);
     179                 : 
     180                 :             }
     181               0 :             while (++k < PREV_COEF_CONTEXTS);
     182                 :         }
     183               0 :         while (++i < COEF_BANDS);
     184                 :     }
     185               0 :     while (++h < BLOCK_TYPES);
     186               0 : }
     187                 : 
     188                 : 
     189               0 : void vp8_coef_tree_initialize()
     190                 : {
     191               0 :     init_bit_trees();
     192               0 :     vp8_tokens_from_tree(vp8_coef_encodings, vp8_coef_tree);
     193               0 : }

Generated by: LCOV version 1.7