• 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   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   int *mt_current_mb_col; /* Each row remembers its already decoded column. */
80   pthread_mutex_t *pmutex;
81   pthread_mutex_t mt_mutex; /* mutex for b_multithreaded_rd */
82 
83   unsigned char **mt_yabove_row; /* mb_rows x width */
84   unsigned char **mt_uabove_row;
85   unsigned char **mt_vabove_row;
86   unsigned char **mt_yleft_col; /* mb_rows x 16 */
87   unsigned char **mt_uleft_col; /* mb_rows x 8 */
88   unsigned char **mt_vleft_col; /* mb_rows x 8 */
89 
90   MB_ROW_DEC *mb_row_di;
91   DECODETHREAD_DATA *de_thread_data;
92 
93   pthread_t *h_decoding_thread;
94   sem_t *h_event_start_decoding;
95   sem_t h_event_end_decoding;
96 /* end of threading data */
97 #endif
98 
99   int64_t last_time_stamp;
100   int ready_for_new_data;
101 
102   vp8_prob prob_intra;
103   vp8_prob prob_last;
104   vp8_prob prob_gf;
105   vp8_prob prob_skip_false;
106 
107 #if CONFIG_ERROR_CONCEALMENT
108   MB_OVERLAP *overlaps;
109   /* the mb num from which modes and mvs (first partition) are corrupt */
110   unsigned int mvs_corrupt_from_mb;
111 #endif
112   int ec_enabled;
113   int ec_active;
114   int decoded_key_frame;
115   int independent_partitions;
116   int frame_corrupt_residual;
117 
118   vpx_decrypt_cb decrypt_cb;
119   void *decrypt_state;
120 } VP8D_COMP;
121 
122 int vp8_decode_frame(VP8D_COMP *cpi);
123 
124 int vp8_create_decoder_instances(struct frame_buffers *fb, VP8D_CONFIG *oxcf);
125 int vp8_remove_decoder_instances(struct frame_buffers *fb);
126 
127 #if CONFIG_DEBUG
128 #define CHECK_MEM_ERROR(lval, expr)                                         \
129   do {                                                                      \
130     lval = (expr);                                                          \
131     if (!lval)                                                              \
132       vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR,           \
133                          "Failed to allocate " #lval " at %s:%d", __FILE__, \
134                          __LINE__);                                         \
135   } while (0)
136 #else
137 #define CHECK_MEM_ERROR(lval, expr)                               \
138   do {                                                            \
139     lval = (expr);                                                \
140     if (!lval)                                                    \
141       vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR, \
142                          "Failed to allocate " #lval);            \
143   } while (0)
144 #endif
145 
146 #ifdef __cplusplus
147 }  // extern "C"
148 #endif
149 
150 #endif  // VP8_DECODER_ONYXD_INT_H_
151