summaryrefslogtreecommitdiffstats
path: root/decoder/ihevcd_statistics.h
blob: 58f35d6b50f69b04bf1483cbdfc812f2343102f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/******************************************************************************
*
* 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
*  ihevcd_statistics.h
*
* @brief
*  Contains macros for generating stats about hevc decoder
*
* @author
*  Naveen SR
*
* @par List of Functions:
*
* @remarks
*  None
*
*******************************************************************************
*/

#ifndef _IHEVCD_STATISTICS_H_
#define _IHEVCD_STATISTICS_H_

#include <stdio.h>
#include "ihevc_typedefs.h"
#include "iv.h"
#include "ivd.h"
#include "ihevcd_cxa.h"
#include "ithread.h"

#include "ihevc_defs.h"
#include "ihevc_structs.h"

#include "ihevc_cabac_tables.h"
#include "ihevcd_defs.h"

#include "ihevcd_structs.h"
#include "ihevcd_iquant_itrans_recon_ctb.h"
#include "ihevcd_statistics.h"

#define STATISTICS_ENABLE 0

#if STATISTICS_ENABLE

typedef struct
{
    UWORD32 num_4x4_dst;
    UWORD32 num_4x4;
    UWORD32 num_8x8;
    UWORD32 num_16x16;
    UWORD32 num_32x32;
    UWORD32 num_64x64;
}stat_trans_t;

typedef struct
{
    /* 4x4 Subblock count */
    UWORD32 trans_4x4_dst[1];
    UWORD32 trans_4x4[1];
    UWORD32 trans_8x8[4];
    UWORD32 trans_16x16[16];
    UWORD32 trans_32x32[64];
}stat_sblk_histogram_t;

typedef struct
{
    /* 4x4 Subblock count */
    UWORD32 trans_4x4_dst[16];
    UWORD32 trans_4x4[16];
    UWORD32 trans_8x8[64];
    UWORD32 trans_16x16[256];
    UWORD32 trans_32x32[1024];
}stat_coeff_histogram_t;

typedef struct
{
    stat_trans_t stat_num_all_trans_block[2]; /* Y and UV */
    stat_trans_t stat_num_coded_trans_block[2]; /* Y and UV */
    stat_trans_t stat_num_coded_dc_block[2]; /* Y and UV */
    stat_trans_t stat_num_coded_one_coeff_block[2]; /* Y and UV */
    stat_sblk_histogram_t stat_last_sblk_pos_histogram; /* Y + UV */
    stat_sblk_histogram_t stat_num_coded_sblk_histogram; /* Y + UV */
    stat_coeff_histogram_t stat_num_coded_coeff_histogram; /* Y + UV */
    UWORD32   stat_pu_all_size_hist[16][16]; /* PU Sizes [Width from 4 to 64 in steps of 4] [Height from 4 to 64 in steps of 4]*/
    UWORD32   stat_pu_skip_size_hist[16][16]; /* PU sizes for skip [Width from 4 to 64 in steps of 4] [Height from 4 to 64 in steps of 4]*/
    UWORD32   stat_pu_inter_size_hist[16][16]; /* PU sizes for inter [Width from 4 to 64 in steps of 4] [Height from 4 to 64 in steps of 4]*/
    UWORD32   stat_pu_intra_size_hist[16][16]; /* PU sizes for intra [Width from 4 to 64 in steps of 4] [Height from 4 to 64 in steps of 4]*/
    UWORD32   stat_pu_bipred_size_hist[16][16]; /* PU sizes for bipred [Width from 4 to 64 in steps of 4] [Height from 4 to 64 in steps of 4]*/
    UWORD32   stat_pu_merge_size_hist[16][16]; /* PU sizes for merge [Width from 4 to 64 in steps of 4] [Height from 4 to 64 in steps of 4]*/
    UWORD32   stat_pu_zeromv_size_hist[16][16]; /* PU sizes for Zero MV [Width from 4 to 64 in steps of 4] [Height from 4 to 64 in steps of 4]*/
    UWORD32   stat_pu_zeromvfpel_size_hist[16][16]; /* PU sizes for Zero MV (includes subpel less than +/- 1 full pel units [Width from 4 to 64 in steps of 4] [Height from 4 to 64 in steps of 4]*/
    UWORD32 last_sblk_pos_x; /* Last sblk pos of transform block in processing */
    UWORD32 last_sblk_pos_y;
    UWORD32 num_coded_sblk;
    UWORD32 num_coded_coeffs;
}statistics_t;

void ihevcd_update_num_all_trans_blocks(TRANSFORM_TYPE e_trans_type, WORD32 c_idx);
void ihevcd_update_num_trans_blocks(TRANSFORM_TYPE e_trans_type, WORD32 c_idx, WORD32 update_type);
void ihevcd_update_sblk_and_coeff_histogram(TRANSFORM_TYPE e_trans_type, WORD32 t_skip_or_tq_bypass);
void ihevcd_sblk_pos_init();
void ihevcd_sblk_pos_update(TRANSFORM_TYPE e_trans_type, WORD32 t_skip_or_tq_bypass, UWORD32 sblk_x, UWORD32 sblk_y);
void ihevcd_print_transform_statistics();
void ihevcd_update_coeff_count();
void ihevcd_update_pu_size(pu_t *ps_pu);
void ihevcd_update_pu_skip_size(pu_t *ps_pu);
#endif //STATISTICS_ENABLE

#if STATISTICS_ENABLE
#define STATS_INIT()  ihevcd_init_statistics();
#define STATS_UPDATE_ALL_TRANS(e_trans_type, c_idx) ihevcd_update_num_all_trans_blocks(e_trans_type, c_idx);
#define STATS_UPDATE_CODED_TRANS(e_trans_type, c_idx, update_type) ihevcd_update_num_trans_blocks(e_trans_type, c_idx, update_type);
#define STATS_PRINT() ihevcd_print_statistics();
#define STATS_INIT_SBLK_AND_COEFF_POS() ihevcd_sblk_pos_init();
#define STATS_LAST_SBLK_POS_UPDATE(e_trans_type, t_skip_or_tq_bypass, sblk_x, sblk_y) ihevcd_sblk_pos_update(e_trans_type, t_skip_or_tq_bypass, sblk_x, sblk_y);
#define STATS_UPDATE_SBLK_AND_COEFF_HISTOGRAM(e_trans_type, t_skip_or_tq_bypass) ihevcd_update_sblk_and_coeff_histogram(e_trans_type, t_skip_or_tq_bypass);
#define STATS_UPDATE_COEFF_COUNT() ihevcd_update_coeff_count();
#define STATS_UPDATE_PU_SIZE(ps_pu) ihevcd_update_pu_size(ps_pu);
#define STATS_UPDATE_PU_SKIP_SIZE(ps_pu) ihevcd_update_pu_skip_size(ps_pu);
#else
#define STATS_INIT()  ;
#define STATS_UPDATE_ALL_TRANS(e_trans_type, c_idx) ;
#define STATS_UPDATE_CODED_TRANS(e_trans_type, c_idx, update_type) ;
#define STATS_PRINT() ;
#define STATS_INIT_SBLK_AND_COEFF_POS() ;
#define STATS_LAST_SBLK_POS_UPDATE(e_trans_type, t_skip_or_tq_bypass, sblk_x, sblk_y) ;
#define STATS_UPDATE_SBLK_AND_COEFF_HISTOGRAM(e_trans_type, t_skip_or_tq_bypass) ;
#define STATS_UPDATE_COEFF_COUNT() ;
#define STATS_UPDATE_PU_SIZE(ps_pu) ;
#define STATS_UPDATE_PU_SKIP_SIZE(ps_pu) ;
#endif

#endif /* _IHEVCD_STATISTICS_H_ */