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