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 ONYXD_INT_H_
     13 #define ONYXD_INT_H_
     14 
     15 #include "vpx_config.h"
     16 #include "vp8/common/onyxd.h"
     17 #include "treereader.h"
     18 #include "vp8/common/onyxc_int.h"
     19 #include "vp8/common/threading.h"
     20 
     21 #if CONFIG_ERROR_CONCEALMENT
     22 #include "ec_types.h"
     23 #endif
     24 
     25 typedef struct
     26 {
     27     int ithread;
     28     void *ptr1;
     29     void *ptr2;
     30 } DECODETHREAD_DATA;
     31 
     32 typedef struct
     33 {
     34     MACROBLOCKD  mbd;
     35 } MB_ROW_DEC;
     36 
     37 
     38 typedef struct
     39 {
     40     int enabled;
     41     unsigned int count;
     42     const unsigned char *ptrs[MAX_PARTITIONS];
     43     unsigned int sizes[MAX_PARTITIONS];
     44 } FRAGMENT_DATA;
     45 
     46 #define MAX_FB_MT_DEC 32
     47 
     48 struct frame_buffers
     49 {
     50     /*
     51      * this struct will be populated with frame buffer management
     52      * info in future commits. */
     53 
     54     /* enable/disable frame-based threading */
     55     int     use_frame_threads;
     56 
     57     /* decoder instances */
     58     struct VP8D_COMP *pbi[MAX_FB_MT_DEC];
     59 
     60 };
     61 
     62 typedef struct VP8D_COMP
     63 {
     64     DECLARE_ALIGNED(16, MACROBLOCKD, mb);
     65 
     66     YV12_BUFFER_CONFIG *dec_fb_ref[NUM_YV12_BUFFERS];
     67 
     68     DECLARE_ALIGNED(16, VP8_COMMON, common);
     69 
     70     /* the last partition will be used for the modes/mvs */
     71     vp8_reader mbc[MAX_PARTITIONS];
     72 
     73     VP8D_CONFIG oxcf;
     74 
     75     FRAGMENT_DATA fragments;
     76 
     77 #if CONFIG_MULTITHREAD
     78     /* variable for threading */
     79 
     80     volatile int b_multithreaded_rd;
     81     int max_threads;
     82     int current_mb_col_main;
     83     unsigned int decoding_thread_count;
     84     int allocated_decoding_thread_count;
     85 
     86     int mt_baseline_filter_level[MAX_MB_SEGMENTS];
     87     int sync_range;
     88     int *mt_current_mb_col;                  /* Each row remembers its already decoded column. */
     89 
     90     unsigned char **mt_yabove_row;           /* mb_rows x width */
     91     unsigned char **mt_uabove_row;
     92     unsigned char **mt_vabove_row;
     93     unsigned char **mt_yleft_col;            /* mb_rows x 16 */
     94     unsigned char **mt_uleft_col;            /* mb_rows x 8 */
     95     unsigned char **mt_vleft_col;            /* mb_rows x 8 */
     96 
     97     MB_ROW_DEC           *mb_row_di;
     98     DECODETHREAD_DATA    *de_thread_data;
     99 
    100     pthread_t           *h_decoding_thread;
    101     sem_t               *h_event_start_decoding;
    102     sem_t                h_event_end_decoding;
    103     /* end of threading data */
    104 #endif
    105 
    106     int64_t last_time_stamp;
    107     int   ready_for_new_data;
    108 
    109     vp8_prob prob_intra;
    110     vp8_prob prob_last;
    111     vp8_prob prob_gf;
    112     vp8_prob prob_skip_false;
    113 
    114 #if CONFIG_ERROR_CONCEALMENT
    115     MB_OVERLAP *overlaps;
    116     /* the mb num from which modes and mvs (first partition) are corrupt */
    117     unsigned int mvs_corrupt_from_mb;
    118 #endif
    119     int ec_enabled;
    120     int ec_active;
    121     int decoded_key_frame;
    122     int independent_partitions;
    123     int frame_corrupt_residual;
    124 
    125     vp8_decrypt_cb *decrypt_cb;
    126     void *decrypt_state;
    127 } VP8D_COMP;
    128 
    129 int vp8_decode_frame(VP8D_COMP *cpi);
    130 
    131 int vp8_create_decoder_instances(struct frame_buffers *fb, VP8D_CONFIG *oxcf);
    132 int vp8_remove_decoder_instances(struct frame_buffers *fb);
    133 
    134 #if CONFIG_DEBUG
    135 #define CHECK_MEM_ERROR(lval,expr) do {\
    136         lval = (expr); \
    137         if(!lval) \
    138             vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR,\
    139                                "Failed to allocate "#lval" at %s:%d", \
    140                                __FILE__,__LINE__);\
    141     } while(0)
    142 #else
    143 #define CHECK_MEM_ERROR(lval,expr) do {\
    144         lval = (expr); \
    145         if(!lval) \
    146             vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR,\
    147                                "Failed to allocate "#lval);\
    148     } while(0)
    149 #endif
    150 
    151 #endif  // ONYXD_INT_H_
    152