Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: source/libvpx/vp9/common/vp9_onyxc_int.h

Issue 898943004: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/libvpx/vp9/common/vp9_mvref_common.c ('k') | source/libvpx/vp9/common/vp9_postproc.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef VP9_COMMON_VP9_ONYXC_INT_H_ 11 #ifndef VP9_COMMON_VP9_ONYXC_INT_H_
12 #define VP9_COMMON_VP9_ONYXC_INT_H_ 12 #define VP9_COMMON_VP9_ONYXC_INT_H_
13 13
14 #include "./vpx_config.h" 14 #include "./vpx_config.h"
15 #include "vpx/internal/vpx_codec_internal.h" 15 #include "vpx/internal/vpx_codec_internal.h"
16 #include "./vp9_rtcd.h" 16 #include "./vp9_rtcd.h"
17 #include "vp9/common/vp9_loopfilter.h" 17 #include "vp9/common/vp9_loopfilter.h"
18 #include "vp9/common/vp9_entropymv.h" 18 #include "vp9/common/vp9_entropymv.h"
19 #include "vp9/common/vp9_entropy.h" 19 #include "vp9/common/vp9_entropy.h"
20 #include "vp9/common/vp9_entropymode.h" 20 #include "vp9/common/vp9_entropymode.h"
21 #include "vp9/common/vp9_frame_buffers.h" 21 #include "vp9/common/vp9_frame_buffers.h"
22 #include "vp9/common/vp9_quant_common.h" 22 #include "vp9/common/vp9_quant_common.h"
23 #include "vp9/common/vp9_thread.h"
23 #include "vp9/common/vp9_tile_common.h" 24 #include "vp9/common/vp9_tile_common.h"
24 25
25 #if CONFIG_VP9_POSTPROC 26 #if CONFIG_VP9_POSTPROC
26 #include "vp9/common/vp9_postproc.h" 27 #include "vp9/common/vp9_postproc.h"
27 #endif 28 #endif
28 29
29 #ifdef __cplusplus 30 #ifdef __cplusplus
30 extern "C" { 31 extern "C" {
31 #endif 32 #endif
32 33
33 #define REFS_PER_FRAME 3 34 #define REFS_PER_FRAME 3
34 35
35 #define REF_FRAMES_LOG2 3 36 #define REF_FRAMES_LOG2 3
36 #define REF_FRAMES (1 << REF_FRAMES_LOG2) 37 #define REF_FRAMES (1 << REF_FRAMES_LOG2)
37 38
38 // 1 scratch frame for the new frame, 3 for scaled references on the encoder 39 // 4 scratch frames for the new frames to support a maximum of 4 cores decoding
40 // in parallel, 3 for scaled references on the encoder.
41 // TODO(hkuang): Add ondemand frame buffers instead of hardcoding the number
42 // of framebuffers.
39 // TODO(jkoleszar): These 3 extra references could probably come from the 43 // TODO(jkoleszar): These 3 extra references could probably come from the
40 // normal reference pool. 44 // normal reference pool.
41 #define FRAME_BUFFERS (REF_FRAMES + 4) 45 #define FRAME_BUFFERS (REF_FRAMES + 7)
42 46
43 #define FRAME_CONTEXTS_LOG2 2 47 #define FRAME_CONTEXTS_LOG2 2
44 #define FRAME_CONTEXTS (1 << FRAME_CONTEXTS_LOG2) 48 #define FRAME_CONTEXTS (1 << FRAME_CONTEXTS_LOG2)
45 49
50 #define NUM_PING_PONG_BUFFERS 2
51
46 extern const struct { 52 extern const struct {
47 PARTITION_CONTEXT above; 53 PARTITION_CONTEXT above;
48 PARTITION_CONTEXT left; 54 PARTITION_CONTEXT left;
49 } partition_context_lookup[BLOCK_SIZES]; 55 } partition_context_lookup[BLOCK_SIZES];
50 56
51 57
52 typedef enum { 58 typedef enum {
53 SINGLE_REFERENCE = 0, 59 SINGLE_REFERENCE = 0,
54 COMPOUND_REFERENCE = 1, 60 COMPOUND_REFERENCE = 1,
55 REFERENCE_MODE_SELECT = 2, 61 REFERENCE_MODE_SELECT = 2,
56 REFERENCE_MODES = 3, 62 REFERENCE_MODES = 3,
57 } REFERENCE_MODE; 63 } REFERENCE_MODE;
58 64
59 typedef struct { 65 typedef struct {
60 int_mv mv[2]; 66 int_mv mv[2];
61 MV_REFERENCE_FRAME ref_frame[2]; 67 MV_REFERENCE_FRAME ref_frame[2];
62 } MV_REF; 68 } MV_REF;
63 69
64 typedef struct { 70 typedef struct {
65 int ref_count; 71 int ref_count;
66 MV_REF *mvs; 72 MV_REF *mvs;
67 int mi_rows; 73 int mi_rows;
68 int mi_cols; 74 int mi_cols;
69 vpx_codec_frame_buffer_t raw_frame_buffer; 75 vpx_codec_frame_buffer_t raw_frame_buffer;
70 YV12_BUFFER_CONFIG buf; 76 YV12_BUFFER_CONFIG buf;
77
78 // The Following variables will only be used in frame parallel decode.
79
80 // frame_worker_owner indicates which FrameWorker owns this buffer. NULL means
81 // that no FrameWorker owns, or is decoding, this buffer.
82 VP9Worker *frame_worker_owner;
83
84 // row and col indicate which position frame has been decoded to in real
85 // pixel unit. They are reset to -1 when decoding begins and set to INT_MAX
86 // when the frame is fully decoded.
87 int row;
88 int col;
71 } RefCntBuffer; 89 } RefCntBuffer;
72 90
91 typedef struct {
92 // Protect BufferPool from being accessed by several FrameWorkers at
93 // the same time during frame parallel decode.
94 // TODO(hkuang): Try to use atomic variable instead of locking the whole pool.
95 #if CONFIG_MULTITHREAD
96 pthread_mutex_t pool_mutex;
97 #endif
98
99 // Private data associated with the frame buffer callbacks.
100 void *cb_priv;
101
102 vpx_get_frame_buffer_cb_fn_t get_fb_cb;
103 vpx_release_frame_buffer_cb_fn_t release_fb_cb;
104
105 RefCntBuffer frame_bufs[FRAME_BUFFERS];
106
107 // Frame buffers allocated internally by the codec.
108 InternalFrameBufferList int_frame_buffers;
109 } BufferPool;
110
73 typedef struct VP9Common { 111 typedef struct VP9Common {
74 struct vpx_internal_error_info error; 112 struct vpx_internal_error_info error;
75 113
76 DECLARE_ALIGNED(16, int16_t, y_dequant[QINDEX_RANGE][8]); 114 DECLARE_ALIGNED(16, int16_t, y_dequant[QINDEX_RANGE][8]);
77 DECLARE_ALIGNED(16, int16_t, uv_dequant[QINDEX_RANGE][8]); 115 DECLARE_ALIGNED(16, int16_t, uv_dequant[QINDEX_RANGE][8]);
78 116
79 vpx_color_space_t color_space; 117 vpx_color_space_t color_space;
80 118
81 int width; 119 int width;
82 int height; 120 int height;
83 int display_width; 121 int display_width;
84 int display_height; 122 int display_height;
85 int last_width; 123 int last_width;
86 int last_height; 124 int last_height;
87 125
88 // TODO(jkoleszar): this implies chroma ss right now, but could vary per 126 // TODO(jkoleszar): this implies chroma ss right now, but could vary per
89 // plane. Revisit as part of the future change to YV12_BUFFER_CONFIG to 127 // plane. Revisit as part of the future change to YV12_BUFFER_CONFIG to
90 // support additional planes. 128 // support additional planes.
91 int subsampling_x; 129 int subsampling_x;
92 int subsampling_y; 130 int subsampling_y;
93 131
94 #if CONFIG_VP9_HIGHBITDEPTH 132 #if CONFIG_VP9_HIGHBITDEPTH
95 int use_highbitdepth; // Marks if we need to use 16bit frame buffers. 133 int use_highbitdepth; // Marks if we need to use 16bit frame buffers.
96 #endif 134 #endif
97 135
98 YV12_BUFFER_CONFIG *frame_to_show; 136 YV12_BUFFER_CONFIG *frame_to_show;
99 RefCntBuffer frame_bufs[FRAME_BUFFERS];
100 RefCntBuffer *prev_frame; 137 RefCntBuffer *prev_frame;
101 138
102 // TODO(hkuang): Combine this with cur_buf in macroblockd. 139 // TODO(hkuang): Combine this with cur_buf in macroblockd.
103 RefCntBuffer *cur_frame; 140 RefCntBuffer *cur_frame;
104 141
105 int ref_frame_map[REF_FRAMES]; /* maps fb_idx to reference slot */ 142 int ref_frame_map[REF_FRAMES]; /* maps fb_idx to reference slot */
106 143
144 // Prepare ref_frame_map for the next frame.
145 // Only used in frame parallel decode.
146 int next_ref_frame_map[REF_FRAMES];
147
107 // TODO(jkoleszar): could expand active_ref_idx to 4, with 0 as intra, and 148 // TODO(jkoleszar): could expand active_ref_idx to 4, with 0 as intra, and
108 // roll new_fb_idx into it. 149 // roll new_fb_idx into it.
109 150
110 // Each frame can reference REFS_PER_FRAME buffers 151 // Each frame can reference REFS_PER_FRAME buffers
111 RefBuffer frame_refs[REFS_PER_FRAME]; 152 RefBuffer frame_refs[REFS_PER_FRAME];
112 153
113 int new_fb_idx; 154 int new_fb_idx;
114 155
115 #if CONFIG_VP9_POSTPROC 156 #if CONFIG_VP9_POSTPROC
116 YV12_BUFFER_CONFIG post_proc_buffer; 157 YV12_BUFFER_CONFIG post_proc_buffer;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 // Separate mi functions between encoder and decoder. 204 // Separate mi functions between encoder and decoder.
164 int (*alloc_mi)(struct VP9Common *cm, int mi_size); 205 int (*alloc_mi)(struct VP9Common *cm, int mi_size);
165 void (*free_mi)(struct VP9Common *cm); 206 void (*free_mi)(struct VP9Common *cm);
166 void (*setup_mi)(struct VP9Common *cm); 207 void (*setup_mi)(struct VP9Common *cm);
167 208
168 209
169 // Whether to use previous frame's motion vectors for prediction. 210 // Whether to use previous frame's motion vectors for prediction.
170 int use_prev_frame_mvs; 211 int use_prev_frame_mvs;
171 212
172 // Persistent mb segment id map used in prediction. 213 // Persistent mb segment id map used in prediction.
173 unsigned char *last_frame_seg_map; 214 int seg_map_idx;
215 int prev_seg_map_idx;
216
217 uint8_t *seg_map_array[NUM_PING_PONG_BUFFERS];
218 uint8_t *last_frame_seg_map;
219 uint8_t *current_frame_seg_map;
174 220
175 INTERP_FILTER interp_filter; 221 INTERP_FILTER interp_filter;
176 222
177 loop_filter_info_n lf_info; 223 loop_filter_info_n lf_info;
178 224
179 int refresh_frame_context; /* Two state 0 = NO, 1 = YES */ 225 int refresh_frame_context; /* Two state 0 = NO, 1 = YES */
180 226
181 int ref_frame_sign_bias[MAX_REF_FRAMES]; /* Two state 0, 1 */ 227 int ref_frame_sign_bias[MAX_REF_FRAMES]; /* Two state 0, 1 */
182 228
183 struct loopfilter lf; 229 struct loopfilter lf;
184 struct segmentation seg; 230 struct segmentation seg;
185 231
232 // TODO(hkuang): Remove this as it is the same as frame_parallel_decode
233 // in pbi.
234 int frame_parallel_decode; // frame-based threading.
235
186 // Context probabilities for reference frame prediction 236 // Context probabilities for reference frame prediction
187 MV_REFERENCE_FRAME comp_fixed_ref; 237 MV_REFERENCE_FRAME comp_fixed_ref;
188 MV_REFERENCE_FRAME comp_var_ref[2]; 238 MV_REFERENCE_FRAME comp_var_ref[2];
189 REFERENCE_MODE reference_mode; 239 REFERENCE_MODE reference_mode;
190 240
191 FRAME_CONTEXT *fc; /* this frame entropy */ 241 FRAME_CONTEXT *fc; /* this frame entropy */
192 FRAME_CONTEXT *frame_contexts; // FRAME_CONTEXTS 242 FRAME_CONTEXT *frame_contexts; // FRAME_CONTEXTS
193 unsigned int frame_context_idx; /* Context to use/update */ 243 unsigned int frame_context_idx; /* Context to use/update */
194 FRAME_COUNTS counts; 244 FRAME_COUNTS counts;
195 245
(...skipping 15 matching lines...) Expand all
211 int byte_alignment; 261 int byte_alignment;
212 262
213 // Private data associated with the frame buffer callbacks. 263 // Private data associated with the frame buffer callbacks.
214 void *cb_priv; 264 void *cb_priv;
215 vpx_get_frame_buffer_cb_fn_t get_fb_cb; 265 vpx_get_frame_buffer_cb_fn_t get_fb_cb;
216 vpx_release_frame_buffer_cb_fn_t release_fb_cb; 266 vpx_release_frame_buffer_cb_fn_t release_fb_cb;
217 267
218 // Handles memory for the codec. 268 // Handles memory for the codec.
219 InternalFrameBufferList int_frame_buffers; 269 InternalFrameBufferList int_frame_buffers;
220 270
271 // External BufferPool passed from outside.
272 BufferPool *buffer_pool;
273
221 PARTITION_CONTEXT *above_seg_context; 274 PARTITION_CONTEXT *above_seg_context;
222 ENTROPY_CONTEXT *above_context; 275 ENTROPY_CONTEXT *above_context;
223 } VP9_COMMON; 276 } VP9_COMMON;
224 277
278 // TODO(hkuang): Don't need to lock the whole pool after implementing atomic
279 // frame reference count.
280 void lock_buffer_pool(BufferPool *const pool);
281 void unlock_buffer_pool(BufferPool *const pool);
282
225 static INLINE YV12_BUFFER_CONFIG *get_ref_frame(VP9_COMMON *cm, int index) { 283 static INLINE YV12_BUFFER_CONFIG *get_ref_frame(VP9_COMMON *cm, int index) {
226 if (index < 0 || index >= REF_FRAMES) 284 if (index < 0 || index >= REF_FRAMES)
227 return NULL; 285 return NULL;
228 if (cm->ref_frame_map[index] < 0) 286 if (cm->ref_frame_map[index] < 0)
229 return NULL; 287 return NULL;
230 assert(cm->ref_frame_map[index] < FRAME_BUFFERS); 288 assert(cm->ref_frame_map[index] < FRAME_BUFFERS);
231 return &cm->frame_bufs[cm->ref_frame_map[index]].buf; 289 return &cm->buffer_pool->frame_bufs[cm->ref_frame_map[index]].buf;
232 } 290 }
233 291
234 static INLINE YV12_BUFFER_CONFIG *get_frame_new_buffer(VP9_COMMON *cm) { 292 static INLINE YV12_BUFFER_CONFIG *get_frame_new_buffer(VP9_COMMON *cm) {
235 return &cm->frame_bufs[cm->new_fb_idx].buf; 293 return &cm->buffer_pool->frame_bufs[cm->new_fb_idx].buf;
236 } 294 }
237 295
238 static INLINE int get_free_fb(VP9_COMMON *cm) { 296 static INLINE int get_free_fb(VP9_COMMON *cm) {
297 RefCntBuffer *const frame_bufs = cm->buffer_pool->frame_bufs;
239 int i; 298 int i;
240 for (i = 0; i < FRAME_BUFFERS; i++) 299
241 if (cm->frame_bufs[i].ref_count == 0) 300 lock_buffer_pool(cm->buffer_pool);
301 for (i = 0; i < FRAME_BUFFERS; ++i)
302 if (frame_bufs[i].ref_count == 0)
242 break; 303 break;
243 304
244 assert(i < FRAME_BUFFERS); 305 assert(i < FRAME_BUFFERS);
245 cm->frame_bufs[i].ref_count = 1; 306 frame_bufs[i].ref_count = 1;
307 unlock_buffer_pool(cm->buffer_pool);
246 return i; 308 return i;
247 } 309 }
248 310
249 static INLINE void ref_cnt_fb(RefCntBuffer *bufs, int *idx, int new_idx) { 311 static INLINE void ref_cnt_fb(RefCntBuffer *bufs, int *idx, int new_idx) {
250 const int ref_index = *idx; 312 const int ref_index = *idx;
251 313
252 if (ref_index >= 0 && bufs[ref_index].ref_count > 0) 314 if (ref_index >= 0 && bufs[ref_index].ref_count > 0)
253 bufs[ref_index].ref_count--; 315 bufs[ref_index].ref_count--;
254 316
255 *idx = new_idx; 317 *idx = new_idx;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 left = (left & bs) > 0; 430 left = (left & bs) > 0;
369 431
370 return (left * 2 + above) + bsl * PARTITION_PLOFFSET; 432 return (left * 2 + above) + bsl * PARTITION_PLOFFSET;
371 } 433 }
372 434
373 #ifdef __cplusplus 435 #ifdef __cplusplus
374 } // extern "C" 436 } // extern "C"
375 #endif 437 #endif
376 438
377 #endif // VP9_COMMON_VP9_ONYXC_INT_H_ 439 #endif // VP9_COMMON_VP9_ONYXC_INT_H_
OLDNEW
« no previous file with comments | « source/libvpx/vp9/common/vp9_mvref_common.c ('k') | source/libvpx/vp9/common/vp9_postproc.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698