Home | History | Annotate | Download | only in decoder
      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 #ifndef __INC_VP8D_INT_H
     13 #define __INC_VP8D_INT_H
     14 #include "vpx_ports/config.h"
     15 #include "onyxd.h"
     16 #include "treereader.h"
     17 #include "onyxc_int.h"
     18 #include "threading.h"
     19 #include "dequantize.h"
     20 
     21 typedef struct
     22 {
     23     int ithread;
     24     void *ptr1;
     25     void *ptr2;
     26 } DECODETHREAD_DATA;
     27 
     28 typedef struct
     29 {
     30     MACROBLOCKD  mbd;
     31     int mb_row;
     32     int current_mb_col;
     33     short *coef_ptr;
     34 } MB_ROW_DEC;
     35 
     36 typedef struct
     37 {
     38     INT64 time_stamp;
     39     int size;
     40 } DATARATE;
     41 
     42 typedef struct
     43 {
     44     INT16         min_val;
     45     INT16         Length;
     46     UINT8 Probs[12];
     47 } TOKENEXTRABITS;
     48 
     49 typedef struct
     50 {
     51     int const *scan;
     52     UINT8 const *ptr_block2leftabove;
     53     vp8_tree_index const *vp8_coef_tree_ptr;
     54     TOKENEXTRABITS const *teb_base_ptr;
     55     unsigned char *norm_ptr;
     56     UINT8 *ptr_coef_bands_x;
     57 
     58     ENTROPY_CONTEXT_PLANES *A;
     59     ENTROPY_CONTEXT_PLANES *L;
     60 
     61     INT16 *qcoeff_start_ptr;
     62     BOOL_DECODER *current_bc;
     63 
     64     vp8_prob const *coef_probs[4];
     65 
     66     UINT8 eob[25];
     67 
     68 } DETOK;
     69 
     70 typedef struct VP8Decompressor
     71 {
     72     DECLARE_ALIGNED(16, MACROBLOCKD, mb);
     73 
     74     DECLARE_ALIGNED(16, VP8_COMMON, common);
     75 
     76     vp8_reader bc, bc2;
     77 
     78     VP8D_CONFIG oxcf;
     79 
     80 
     81     const unsigned char *Source;
     82     unsigned int   source_sz;
     83 
     84 
     85     unsigned int CPUFreq;
     86     unsigned int decode_microseconds;
     87     unsigned int time_decoding;
     88     unsigned int time_loop_filtering;
     89 
     90     volatile int b_multithreaded_rd;
     91     volatile int b_multithreaded_lf;
     92     int max_threads;
     93     int last_mb_row_decoded;
     94     int current_mb_col_main;
     95     int decoding_thread_count;
     96     int allocated_decoding_thread_count;
     97     int *current_mb_col;                  //Each row remembers its already decoded column.
     98     int mt_baseline_filter_level[MAX_MB_SEGMENTS];
     99 
    100     // variable for threading
    101     DECLARE_ALIGNED(16, MACROBLOCKD, lpfmb);
    102 #if CONFIG_MULTITHREAD
    103     //pthread_t           h_thread_lpf;         // thread for postprocessing
    104     sem_t               h_event_end_lpf;          // Event for post_proc completed
    105     sem_t               *h_event_start_lpf;
    106 #endif
    107     MB_ROW_DEC           *mb_row_di;
    108     DECODETHREAD_DATA   *de_thread_data;
    109 #if CONFIG_MULTITHREAD
    110     pthread_t           *h_decoding_thread;
    111     sem_t               *h_event_start_decoding;
    112     sem_t               h_event_end_decoding;
    113     // end of threading data
    114 #endif
    115     vp8_reader *mbc;
    116     INT64 last_time_stamp;
    117     int   ready_for_new_data;
    118 
    119     DATARATE dr[16];
    120 
    121     DETOK detoken;
    122 
    123 #if CONFIG_RUNTIME_CPU_DETECT
    124     vp8_dequant_rtcd_vtable_t        dequant;
    125     struct vp8_dboolhuff_rtcd_vtable dboolhuff;
    126 #endif
    127 
    128 
    129     vp8_prob prob_intra;
    130     vp8_prob prob_last;
    131     vp8_prob prob_gf;
    132     vp8_prob prob_skip_false;
    133 
    134 } VP8D_COMP;
    135 
    136 int vp8_decode_frame(VP8D_COMP *cpi);
    137 void vp8_dmachine_specific_config(VP8D_COMP *pbi);
    138 
    139 
    140 #if CONFIG_DEBUG
    141 #define CHECK_MEM_ERROR(lval,expr) do {\
    142         lval = (expr); \
    143         if(!lval) \
    144             vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR,\
    145                                "Failed to allocate "#lval" at %s:%d", \
    146                                __FILE__,__LINE__);\
    147     } while(0)
    148 #else
    149 #define CHECK_MEM_ERROR(lval,expr) do {\
    150         lval = (expr); \
    151         if(!lval) \
    152             vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR,\
    153                                "Failed to allocate "#lval);\
    154     } while(0)
    155 #endif
    156 
    157 #endif
    158