xref: /aosp_15_r20/external/libvpx/vp8/decoder/onyxd_int.h (revision fb1b10ab9aebc7c7068eedab379b749d7e3900be)
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 "vpx_util/vpx_pthread.h"
18 #include "vp8/common/onyxd.h"
19 #include "treereader.h"
20 #include "vp8/common/onyxc_int.h"
21 #include "vp8/common/threading.h"
22 
23 #if CONFIG_ERROR_CONCEALMENT
24 #include "ec_types.h"
25 #endif
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 typedef struct {
32   int ithread;
33   void *ptr1;
34   void *ptr2;
35 } DECODETHREAD_DATA;
36 
37 typedef struct {
38   MACROBLOCKD mbd;
39 } MB_ROW_DEC;
40 
41 typedef struct {
42   int enabled;
43   unsigned int count;
44   const unsigned char *ptrs[MAX_PARTITIONS];
45   unsigned int sizes[MAX_PARTITIONS];
46 } FRAGMENT_DATA;
47 
48 #define MAX_FB_MT_DEC 32
49 
50 struct frame_buffers {
51   /*
52    * this struct will be populated with frame buffer management
53    * info in future commits. */
54 
55   /* decoder instances */
56   struct VP8D_COMP *pbi[MAX_FB_MT_DEC];
57 };
58 
59 typedef struct VP8D_COMP {
60   DECLARE_ALIGNED(16, MACROBLOCKD, mb);
61 
62   YV12_BUFFER_CONFIG *dec_fb_ref[NUM_YV12_BUFFERS];
63 
64   DECLARE_ALIGNED(16, VP8_COMMON, common);
65 
66   /* the last partition will be used for the modes/mvs */
67   vp8_reader mbc[MAX_PARTITIONS];
68 
69   VP8D_CONFIG oxcf;
70 
71   FRAGMENT_DATA fragments;
72 
73 #if CONFIG_MULTITHREAD
74   /* variable for threading */
75 
76   vpx_atomic_int b_multithreaded_rd;
77   int max_threads;
78   int current_mb_col_main;
79   unsigned int decoding_thread_count;
80   int allocated_decoding_thread_count;
81 
82   int mt_baseline_filter_level[MAX_MB_SEGMENTS];
83   int sync_range;
84   /* Each row remembers its already decoded column. */
85   vpx_atomic_int *mt_current_mb_col;
86 
87   unsigned char **mt_yabove_row; /* mb_rows x width */
88   unsigned char **mt_uabove_row;
89   unsigned char **mt_vabove_row;
90   unsigned char **mt_yleft_col; /* mb_rows x 16 */
91   unsigned char **mt_uleft_col; /* mb_rows x 8 */
92   unsigned char **mt_vleft_col; /* mb_rows x 8 */
93 
94   MB_ROW_DEC *mb_row_di;
95   DECODETHREAD_DATA *de_thread_data;
96 
97   pthread_t *h_decoding_thread;
98   vp8_sem_t *h_event_start_decoding;
99   vp8_sem_t h_event_end_decoding;
100 /* end of threading data */
101 #endif
102 
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 #ifdef __cplusplus
139 }  // extern "C"
140 #endif
141 
142 #endif  // VPX_VP8_DECODER_ONYXD_INT_H_
143