/src/libvpx/vp9/decoder/vp9_decoder.h
Line | Count | Source (jump to first uncovered line) |
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_VP9_DECODER_VP9_DECODER_H_ |
12 | | #define VPX_VP9_DECODER_VP9_DECODER_H_ |
13 | | |
14 | | #include "./vpx_config.h" |
15 | | |
16 | | #include "vpx/vpx_codec.h" |
17 | | #include "vpx_dsp/bitreader.h" |
18 | | #include "vpx_scale/yv12config.h" |
19 | | #include "vpx_util/vpx_pthread.h" |
20 | | #include "vpx_util/vpx_thread.h" |
21 | | |
22 | | #include "vp9/common/vp9_thread_common.h" |
23 | | #include "vp9/common/vp9_onyxc_int.h" |
24 | | #include "vp9/common/vp9_ppflags.h" |
25 | | #include "./vp9_job_queue.h" |
26 | | |
27 | | #ifdef __cplusplus |
28 | | extern "C" { |
29 | | #endif |
30 | | |
31 | 0 | #define EOBS_PER_SB_LOG2 8 |
32 | 0 | #define DQCOEFFS_PER_SB_LOG2 12 |
33 | 0 | #define PARTITIONS_PER_SB 85 |
34 | | |
35 | | typedef enum JobType { PARSE_JOB, RECON_JOB, LPF_JOB } JobType; |
36 | | |
37 | | typedef struct ThreadData { |
38 | | struct VP9Decoder *pbi; |
39 | | LFWorkerData *lf_data; |
40 | | VP9LfSync *lf_sync; |
41 | | } ThreadData; |
42 | | |
43 | | typedef struct TileBuffer { |
44 | | const uint8_t *data; |
45 | | size_t size; |
46 | | int col; // only used with multi-threaded decoding |
47 | | } TileBuffer; |
48 | | |
49 | | typedef struct TileWorkerData { |
50 | | const uint8_t *data_end; |
51 | | int buf_start, buf_end; // pbi->tile_buffers to decode, inclusive |
52 | | vpx_reader bit_reader; |
53 | | FRAME_COUNTS counts; |
54 | | LFWorkerData *lf_data; |
55 | | VP9LfSync *lf_sync; |
56 | | DECLARE_ALIGNED(16, MACROBLOCKD, xd); |
57 | | /* dqcoeff are shared by all the planes. So planes must be decoded serially */ |
58 | | DECLARE_ALIGNED(32, tran_low_t, dqcoeff[32 * 32]); |
59 | | DECLARE_ALIGNED(16, uint16_t, extend_and_predict_buf[80 * 2 * 80 * 2]); |
60 | | struct vpx_internal_error_info error_info; |
61 | | } TileWorkerData; |
62 | | |
63 | | typedef void (*process_block_fn_t)(TileWorkerData *twd, |
64 | | struct VP9Decoder *const pbi, int mi_row, |
65 | | int mi_col, BLOCK_SIZE bsize, int bwl, |
66 | | int bhl); |
67 | | |
68 | | typedef struct RowMTWorkerData { |
69 | | int num_sbs; |
70 | | int *eob[MAX_MB_PLANE]; |
71 | | PARTITION_TYPE *partition; |
72 | | tran_low_t *dqcoeff[MAX_MB_PLANE]; |
73 | | int8_t *recon_map; |
74 | | const uint8_t *data_end; |
75 | | uint8_t *jobq_buf; |
76 | | JobQueueRowMt jobq; |
77 | | size_t jobq_size; |
78 | | int num_tiles_done; |
79 | | int num_jobs; |
80 | | #if CONFIG_MULTITHREAD |
81 | | pthread_mutex_t recon_done_mutex; |
82 | | pthread_mutex_t *recon_sync_mutex; |
83 | | pthread_cond_t *recon_sync_cond; |
84 | | #endif |
85 | | ThreadData *thread_data; |
86 | | } RowMTWorkerData; |
87 | | |
88 | | /* Structure to queue and dequeue row decode jobs */ |
89 | | typedef struct Job { |
90 | | int row_num; |
91 | | int tile_col; |
92 | | JobType job_type; |
93 | | } Job; |
94 | | |
95 | | typedef struct VP9Decoder { |
96 | | DECLARE_ALIGNED(16, MACROBLOCKD, mb); |
97 | | |
98 | | DECLARE_ALIGNED(16, VP9_COMMON, common); |
99 | | |
100 | | int ready_for_new_data; |
101 | | |
102 | | int refresh_frame_flags; |
103 | | |
104 | | // TODO(hkuang): Combine this with cur_buf in macroblockd as they are |
105 | | // the same. |
106 | | RefCntBuffer *cur_buf; // Current decoding frame buffer. |
107 | | |
108 | | VPxWorker lf_worker; |
109 | | VPxWorker *tile_workers; |
110 | | TileWorkerData *tile_worker_data; |
111 | | TileBuffer tile_buffers[64]; |
112 | | int num_tile_workers; |
113 | | int total_tiles; |
114 | | |
115 | | VP9LfSync lf_row_sync; |
116 | | |
117 | | vpx_decrypt_cb decrypt_cb; |
118 | | void *decrypt_state; |
119 | | |
120 | | int max_threads; |
121 | | int inv_tile_order; |
122 | | int need_resync; // wait for key/intra-only frame. |
123 | | int hold_ref_buf; // hold the reference buffer. |
124 | | |
125 | | int row_mt; |
126 | | int lpf_mt_opt; |
127 | | RowMTWorkerData *row_mt_worker_data; |
128 | | } VP9Decoder; |
129 | | |
130 | | int vp9_receive_compressed_data(struct VP9Decoder *pbi, size_t size, |
131 | | const uint8_t **psource); |
132 | | |
133 | | int vp9_get_raw_frame(struct VP9Decoder *pbi, YV12_BUFFER_CONFIG *sd, |
134 | | vp9_ppflags_t *flags); |
135 | | |
136 | | vpx_codec_err_t vp9_copy_reference_dec(struct VP9Decoder *pbi, |
137 | | VP9_REFFRAME ref_frame_flag, |
138 | | YV12_BUFFER_CONFIG *sd); |
139 | | |
140 | | vpx_codec_err_t vp9_set_reference_dec(VP9_COMMON *cm, |
141 | | VP9_REFFRAME ref_frame_flag, |
142 | | YV12_BUFFER_CONFIG *sd); |
143 | | |
144 | | static INLINE uint8_t read_marker(vpx_decrypt_cb decrypt_cb, |
145 | 711k | void *decrypt_state, const uint8_t *data) { |
146 | 711k | if (decrypt_cb) { |
147 | 0 | uint8_t marker; |
148 | 0 | decrypt_cb(decrypt_state, data, &marker, 1); |
149 | 0 | return marker; |
150 | 0 | } |
151 | 711k | return *data; |
152 | 711k | } vp9_dx_iface.c:read_marker Line | Count | Source | 145 | 553k | void *decrypt_state, const uint8_t *data) { | 146 | 553k | if (decrypt_cb) { | 147 | 0 | uint8_t marker; | 148 | 0 | decrypt_cb(decrypt_state, data, &marker, 1); | 149 | 0 | return marker; | 150 | 0 | } | 151 | 553k | return *data; | 152 | 553k | } |
Unexecuted instantiation: vp9_decodeframe.c:read_marker Unexecuted instantiation: vp9_detokenize.c:read_marker vp9_decoder.c:read_marker Line | Count | Source | 145 | 157k | void *decrypt_state, const uint8_t *data) { | 146 | 157k | if (decrypt_cb) { | 147 | 0 | uint8_t marker; | 148 | 0 | decrypt_cb(decrypt_state, data, &marker, 1); | 149 | 0 | return marker; | 150 | 0 | } | 151 | 157k | return *data; | 152 | 157k | } |
Unexecuted instantiation: vp9_decodemv.c:read_marker |
153 | | |
154 | | // This function is exposed for use in tests, as well as the inlined function |
155 | | // "read_marker". |
156 | | vpx_codec_err_t vp9_parse_superframe_index(const uint8_t *data, size_t data_sz, |
157 | | uint32_t sizes[8], int *count, |
158 | | vpx_decrypt_cb decrypt_cb, |
159 | | void *decrypt_state); |
160 | | |
161 | | struct VP9Decoder *vp9_decoder_create(BufferPool *const pool); |
162 | | |
163 | | void vp9_decoder_remove(struct VP9Decoder *pbi); |
164 | | |
165 | | void vp9_dec_alloc_row_mt_mem(RowMTWorkerData *row_mt_worker_data, |
166 | | VP9_COMMON *cm, int num_sbs, int max_threads, |
167 | | int num_jobs); |
168 | | void vp9_dec_free_row_mt_mem(RowMTWorkerData *row_mt_worker_data); |
169 | | |
170 | | static INLINE void decrease_ref_count(int idx, RefCntBuffer *const frame_bufs, |
171 | 1.96M | BufferPool *const pool) { |
172 | 1.96M | if (idx >= 0 && frame_bufs[idx].ref_count > 0) { |
173 | 974k | --frame_bufs[idx].ref_count; |
174 | | // A worker may only get a free framebuffer index when calling get_free_fb. |
175 | | // But the private buffer is not set up until finish decoding header. |
176 | | // So any error happens during decoding header, the frame_bufs will not |
177 | | // have valid priv buffer. |
178 | 974k | if (!frame_bufs[idx].released && frame_bufs[idx].ref_count == 0 && |
179 | 974k | frame_bufs[idx].raw_frame_buffer.priv) { |
180 | 66.9k | pool->release_fb_cb(pool->cb_priv, &frame_bufs[idx].raw_frame_buffer); |
181 | 66.9k | frame_bufs[idx].released = 1; |
182 | 66.9k | } |
183 | 974k | } |
184 | 1.96M | } Unexecuted instantiation: vp9_dx_iface.c:decrease_ref_count Unexecuted instantiation: vp9_decodeframe.c:decrease_ref_count Unexecuted instantiation: vp9_detokenize.c:decrease_ref_count vp9_decoder.c:decrease_ref_count Line | Count | Source | 171 | 1.96M | BufferPool *const pool) { | 172 | 1.96M | if (idx >= 0 && frame_bufs[idx].ref_count > 0) { | 173 | 974k | --frame_bufs[idx].ref_count; | 174 | | // A worker may only get a free framebuffer index when calling get_free_fb. | 175 | | // But the private buffer is not set up until finish decoding header. | 176 | | // So any error happens during decoding header, the frame_bufs will not | 177 | | // have valid priv buffer. | 178 | 974k | if (!frame_bufs[idx].released && frame_bufs[idx].ref_count == 0 && | 179 | 974k | frame_bufs[idx].raw_frame_buffer.priv) { | 180 | 66.9k | pool->release_fb_cb(pool->cb_priv, &frame_bufs[idx].raw_frame_buffer); | 181 | 66.9k | frame_bufs[idx].released = 1; | 182 | 66.9k | } | 183 | 974k | } | 184 | 1.96M | } |
Unexecuted instantiation: vp9_decodemv.c:decrease_ref_count |
185 | | |
186 | | #ifdef __cplusplus |
187 | | } // extern "C" |
188 | | #endif |
189 | | |
190 | | #endif // VPX_VP9_DECODER_VP9_DECODER_H_ |