Home | History | Annotate | Download | only in decoder
      1 /******************************************************************************
      2 *
      3 * Copyright (C) 2012 Ittiam Systems Pvt Ltd, Bangalore
      4 *
      5 * Licensed under the Apache License, Version 2.0 (the "License");
      6 * you may not use this file except in compliance with the License.
      7 * You may obtain a copy of the License at:
      8 *
      9 * http://www.apache.org/licenses/LICENSE-2.0
     10 *
     11 * Unless required by applicable law or agreed to in writing, software
     12 * distributed under the License is distributed on an "AS IS" BASIS,
     13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14 * See the License for the specific language governing permissions and
     15 * limitations under the License.
     16 *
     17 ******************************************************************************/
     18 /**
     19 *******************************************************************************
     20 * @file
     21 *  ihevcd_trace.h
     22 *
     23 * @brief
     24 *  Header for codec trace messages
     25 *
     26 * @author
     27 *  Ittiam
     28 *
     29 * @remarks
     30 *  None
     31 *
     32 *******************************************************************************
     33 */
     34 #ifndef _IHEVCD_TRACE_H_
     35 #define _IHEVCD_TRACE_H_
     36 
     37 #define FULLRANGE 1
     38 
     39 
     40 #define RANGE_NUMBITS 31
     41 #define RANGE_SHIFT  (RANGE_NUMBITS - 9)
     42 
     43 #ifdef TRACE
     44 /**
     45  * Context for trace
     46  */
     47 typedef struct
     48 {
     49     /**
     50      * fp
     51      */
     52     FILE    *fp;
     53 
     54     /**
     55      * u8_cnt
     56      */
     57     ULWORD64  u8_cnt;
     58 }trace_t;
     59 
     60 /**
     61  * Global context for trace info
     62  */
     63 extern trace_t g_trace;
     64 
     65 /**
     66  * Call ihevcd_bits_get() to read from bitstream and dumps the data to trace file
     67  */
     68 #define BITS_PARSE(m_str, m_value, m_ps_bitstrm, m_numbits)                 \
     69 {                                                                           \
     70     m_value = ihevcd_bits_get(m_ps_bitstrm, m_numbits);                     \
     71     fprintf( g_trace.fp, "%-40s u(%d) : %d\n", m_str, m_numbits, m_value ); \
     72     fflush ( g_trace.fp);                                                   \
     73 }
     74 
     75 /**
     76  * Call ihevcd_uev() to read from bitstream and dumps the data to trace file
     77  */
     78 
     79 #define UEV_PARSE(m_str, m_value, m_ps_bitstrm)                             \
     80 {                                                                           \
     81     m_value = ihevcd_uev(m_ps_bitstrm);                                     \
     82     fprintf( g_trace.fp, "%-40s ue(v) : %d\n", m_str, m_value );            \
     83     fflush ( g_trace.fp);                                                   \
     84 }
     85 /**
     86  * Call ihevcd_sev() to read from bitstream and dumps the data to trace file
     87  */
     88 #define SEV_PARSE(m_str, m_value, m_ps_bitstrm)                             \
     89 {                                                                           \
     90     m_value = ihevcd_sev(m_ps_bitstrm);                                     \
     91     fprintf( g_trace.fp, "%-40s se(v) : %d\n", m_str, m_value );            \
     92     fflush ( g_trace.fp);                                                   \
     93 }
     94 
     95 
     96 #if FULLRANGE
     97 #define TRACE_CABAC_CTXT(m_string, m_range, m_ctxt_idx)                  \
     98 {                                                                        \
     99     UWORD32 m_clz, m_range_shift, m_state_mps;                           \
    100     m_state_mps = ps_cabac->au1_ctxt_models[m_ctxt_idx];                  \
    101     m_clz = CLZ(m_range);                                                \
    102     m_clz -= (32 - RANGE_NUMBITS);                                       \
    103     m_range_shift = m_range << m_clz;                                    \
    104     m_range_shift = m_range_shift >> RANGE_SHIFT;                        \
    105     fprintf( g_trace.fp, "%-40s: Range:%3d State:%3d MPS:%1d\n",         \
    106         m_string, m_range_shift, m_state_mps >> 1, m_state_mps & 1);     \
    107     fflush ( g_trace.fp);                                                \
    108 }
    109 #define AEV_TRACE(m_str, m_value, m_range)                                  \
    110 {                                                                           \
    111     UWORD32 m_clz, m_range_shift;                                           \
    112     m_clz = CLZ(m_range);                                                   \
    113     m_clz -= (32 - RANGE_NUMBITS);                                       \
    114     m_range_shift = m_range << m_clz;                                       \
    115     m_range_shift = m_range_shift >> RANGE_SHIFT;                           \
    116     fprintf( g_trace.fp, "%-40s:%8d R:%d\n", m_str, m_value, m_range_shift);\
    117     fflush ( g_trace.fp);                                                   \
    118 }
    119 #else
    120 #define TRACE_CABAC_CTXT(m_string, m_range, m_ctxt_idx)                  \
    121 {                                                                        \
    122     UWORD32 m_state_mps;                                                 \
    123     m_state_mps = ps_cabac->au1_ctxt_models[m_ctxt_idx];                 \
    124     fprintf( g_trace.fp, "%-40s: Range:%3d State:%3d MPS:%1d\n",         \
    125         m_string, m_range, m_state_mps >> 1, m_state_mps & 1);           \
    126     fflush ( g_trace.fp);                                                \
    127 }
    128 
    129 #define AEV_TRACE(m_str, m_value, m_range)                              \
    130 {                                                                       \
    131     fprintf( g_trace.fp, "%-40s:%8d R:%d\n", m_str, m_value, m_range);  \
    132     fflush ( g_trace.fp);                                               \
    133 }
    134 #endif
    135 
    136 #define TUV_PARSE(m_str, m_value, m_ps_bitstrm)                      \
    137     m_value = ihevcd_bits_get(m_ps_bitstrm, 1);
    138 
    139 #define TRACE_INIT(a)   ihevcd_trace_init(a)
    140 #define TRACE_DEINIT(a) ihevcd_trace_deinit(a)
    141 
    142 #else /* TRACE */
    143 /**
    144  * Call ihevcd_bits_get() to read from bitstream
    145  */
    146 
    147 #define BITS_PARSE(m_str, m_value, m_ps_bitstrm, m_numbits)           \
    148     m_value = ihevcd_bits_get(m_ps_bitstrm, m_numbits);
    149 
    150 /**
    151  * Call ihevcd_uev() to read from bitstream
    152  */
    153 
    154 #define UEV_PARSE(m_str, m_value, m_ps_bitstrm)                       \
    155     m_value = ihevcd_uev(m_ps_bitstrm);
    156 
    157 /**
    158  * Call ihevcd_sev() to read from bitstream
    159  */
    160 
    161 #define SEV_PARSE(m_str, m_value, m_ps_bitstrm)                       \
    162     m_value = ihevcd_sev(m_ps_bitstrm);
    163 
    164 #define TUV_PARSE(m_str, m_value, m_ps_bitstrm)                      \
    165     m_value = ihevcd_bits_get(m_ps_bitstrm, 1);
    166 
    167 #define TRACE_CABAC_CTXT(m_string, m_range, m_state_mps)
    168 
    169 #define AEV_TRACE(m_str, m_value, m_range)
    170 
    171 
    172 #define TRACE_INIT(a)
    173 #define TRACE_DEINIT(a)
    174 #endif /* TRACE */
    175 #endif /* _IHEVCD_TRACE_H_ */
    176