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